diff --git a/xess/ChangeLog b/xess/ChangeLog deleted file mode 100644 index 0babf10..0000000 --- a/xess/ChangeLog +++ /dev/null @@ -1,6 +0,0 @@ -# Release 1.0.1 -- Bugfixes for 1.0 release -- Added Chinese Developer Guide - -# Release 1.0 -- Initial public release diff --git a/xess/README.md b/xess/README.md deleted file mode 100644 index 55248b7..0000000 --- a/xess/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# XeSS SDK - -Intel(R) Xe Super Sampling (XeSS) enables an innovative framerate boosting technology supported by Intel(R) Arc(TM) graphics cards and other GPU vendors. -Using AI deep-learning to perform upscaling, XeSS offers higher framerates without degrading the image. - -Please see the Developer Guide in the /doc folder for getting started information and https://www.intel.com/content/www/us/en/products/docs/arc-discrete-graphics/xess.html for more information. - -# Package contents - -| Folder / file | Description | -| ----------- | ----------- | -| README.md | This readme file | -| ChangeLog.md | List of changes | -| bin | DLLs, executables, configurations and kernels required to run | -| inc | Required header files | -| lib | Static libraries | -| doc | Documentation | -| licenses | Licenses for the SDK itself and its components | -| samples | Source code and license for samples | diff --git a/xess/bin/DroidSans.ttf b/xess/bin/DroidSans.ttf deleted file mode 100644 index 767c63a..0000000 Binary files a/xess/bin/DroidSans.ttf and /dev/null differ diff --git a/xess/bin/shaders.hlsl b/xess/bin/shaders.hlsl deleted file mode 100644 index 39649e2..0000000 --- a/xess/bin/shaders.hlsl +++ /dev/null @@ -1,97 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -cbuffer SceneConstantBuffer : register(b0) -{ - float4 offset; - float4 velocity; - float4 resolution; - float4 padding[13]; -}; - -struct PSInput -{ - float4 position : SV_POSITION; - float4 color : COLOR; -}; - -struct PSOutputColor -{ - float4 Color: SV_Target0; -}; - -PSInput VSMainColor(float4 position : POSITION, float4 color : COLOR) -{ - PSInput result; - - result.position = float4(position.xyz, 1.); - result.position.xy += offset.xy + 2. * (offset.zw / resolution.xy); - result.color = color; - - return result; -} - -PSOutputColor PSMainColor(PSInput input) : SV_TARGET -{ - PSOutputColor output; - output.Color = input.color; - - return output; -} - -PSInput VSMainVelocity(float4 position : POSITION, float4 color : COLOR) -{ - PSInput result; - - result.position = position; - result.position.xy += offset.xy + 2. * (offset.zw / resolution.xy ); - result.color = color; - - return result; -} - -struct PSOutputVelocity -{ - float2 Velocity: SV_Target0; -}; - -PSOutputVelocity PSMainVelocity(PSInput input) : SV_TARGET -{ - PSOutputVelocity output; - output.Velocity = velocity.xy; - - return output; -} - -struct PSInputFSQ -{ - float4 position: SV_POSITION; - float2 texcoord: TEXCOORD; -}; - -Texture2D input_color: register(t0); -SamplerState samp: register(s0); - -PSInputFSQ VSMainFSQ(uint vertex_id: SV_VERTEXID) -{ - PSInputFSQ output; - output.texcoord = float2(vertex_id & 2, (vertex_id << 1) & 2); - output.position = float4(output.texcoord * 2.0 - 1.0, 0.0, 1.0); - output.texcoord.y = 1.0f - output.texcoord.y; - - return output; -} - -float4 PSMainFSQ(PSInputFSQ input) : SV_TARGET -{ - return input_color.Sample(samp, input.texcoord); -} - diff --git a/xess/doc/XeSS Developer Guide Chinese.pdf b/xess/doc/XeSS Developer Guide Chinese.pdf deleted file mode 100644 index 3031ede..0000000 Binary files a/xess/doc/XeSS Developer Guide Chinese.pdf and /dev/null differ diff --git a/xess/doc/XeSS Developer Guide English.pdf b/xess/doc/XeSS Developer Guide English.pdf deleted file mode 100644 index ac0ee42..0000000 Binary files a/xess/doc/XeSS Developer Guide English.pdf and /dev/null differ diff --git a/xess/doc/XeSS Localization Strings.zip b/xess/doc/XeSS Localization Strings.zip deleted file mode 100644 index 62def09..0000000 Binary files a/xess/doc/XeSS Localization Strings.zip and /dev/null differ diff --git a/xess/doc/doxygen/_r_e_a_d_m_e_8md.html b/xess/doc/doxygen/_r_e_a_d_m_e_8md.html deleted file mode 100644 index fff2105..0000000 --- a/xess/doc/doxygen/_r_e_a_d_m_e_8md.html +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: README.md File Reference - - - - - - - - - - - - - -
-
- - - - - - - -
-
XeSS SDK API Reference Guide 1.0.0 -
-
-
- - - - - - - -
-
- -
-
-
- -
- -
-
- - -
- -
- -
-
README.md File Reference
-
-
-
-
- - - - diff --git a/xess/doc/doxygen/annotated.html b/xess/doc/doxygen/annotated.html deleted file mode 100644 index e5e22af..0000000 --- a/xess/doc/doxygen/annotated.html +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: Data Structures - - - - - - - - - - - - - -
-
- - - - - - - -
-
XeSS SDK API Reference Guide 1.0.0 -
-
-
- - - - - - - -
-
- -
-
-
- -
- -
-
- - -
- -
- -
-
Data Structures
-
-
-
Here are the data structures with brief descriptions:
- - - - - - - - - - -
 C_xess_2d_t2D variable
 C_xess_d3d12_execute_params_tExecution parameters for XeSS D3D12
 C_xess_d3d12_init_params_tInitialization parameters for XeSS D3D12
 C_xess_dump_parameters_t
 C_xess_profiled_frame_data_t
 C_xess_profiling_data_t
 C_xess_properties_tProperties for internal XeSS resources
 C_xess_resources_to_dump_t
 C_xess_version_tXeSS version
-
-
-
- - - - diff --git a/xess/doc/doxygen/annotated_dup.js b/xess/doc/doxygen/annotated_dup.js deleted file mode 100644 index f6509ad..0000000 --- a/xess/doc/doxygen/annotated_dup.js +++ /dev/null @@ -1,12 +0,0 @@ -var annotated_dup = -[ - [ "_xess_2d_t", "struct__xess__2d__t.html", "struct__xess__2d__t" ], - [ "_xess_d3d12_execute_params_t", "struct__xess__d3d12__execute__params__t.html", "struct__xess__d3d12__execute__params__t" ], - [ "_xess_d3d12_init_params_t", "struct__xess__d3d12__init__params__t.html", "struct__xess__d3d12__init__params__t" ], - [ "_xess_dump_parameters_t", "struct__xess__dump__parameters__t.html", "struct__xess__dump__parameters__t" ], - [ "_xess_profiled_frame_data_t", "struct__xess__profiled__frame__data__t.html", "struct__xess__profiled__frame__data__t" ], - [ "_xess_profiling_data_t", "struct__xess__profiling__data__t.html", "struct__xess__profiling__data__t" ], - [ "_xess_properties_t", "struct__xess__properties__t.html", "struct__xess__properties__t" ], - [ "_xess_resources_to_dump_t", "struct__xess__resources__to__dump__t.html", "struct__xess__resources__to__dump__t" ], - [ "_xess_version_t", "struct__xess__version__t.html", "struct__xess__version__t" ] -]; \ No newline at end of file diff --git a/xess/doc/doxygen/bc_s.png b/xess/doc/doxygen/bc_s.png deleted file mode 100644 index 224b29a..0000000 Binary files a/xess/doc/doxygen/bc_s.png and /dev/null differ diff --git a/xess/doc/doxygen/bdwn.png b/xess/doc/doxygen/bdwn.png deleted file mode 100644 index 940a0b9..0000000 Binary files a/xess/doc/doxygen/bdwn.png and /dev/null differ diff --git a/xess/doc/doxygen/classes.html b/xess/doc/doxygen/classes.html deleted file mode 100644 index 541060b..0000000 --- a/xess/doc/doxygen/classes.html +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: Data Structure Index - - - - - - - - - - - - - -
-
- - - - - - - -
-
XeSS SDK API Reference Guide 1.0.0 -
-
-
- - - - - - - -
-
- -
-
-
- -
- -
-
- - -
- -
- -
-
Data Structure Index
-
-
- - -
-
- - - - diff --git a/xess/doc/doxygen/closed.png b/xess/doc/doxygen/closed.png deleted file mode 100644 index 98cc2c9..0000000 Binary files a/xess/doc/doxygen/closed.png and /dev/null differ diff --git a/xess/doc/doxygen/dir_4a251d3eb62f66b4b6f58851eefb73f5.html b/xess/doc/doxygen/dir_4a251d3eb62f66b4b6f58851eefb73f5.html deleted file mode 100644 index bb3f3dd..0000000 --- a/xess/doc/doxygen/dir_4a251d3eb62f66b4b6f58851eefb73f5.html +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: D:/qb/workspace/29555/source/libraries.gpu.rendering.xess.xess-sdk/libxess/include/xess Directory Reference - - - - - - - - - - - - - -
-
- - - - - - - -
-
XeSS SDK API Reference Guide 1.0.0 -
-
-
- - - - - - - -
-
- -
-
-
- -
- -
-
- - -
- -
- -
-
xess Directory Reference
-
-
- - - - - - - - - - -

-Files

file  xess.h [code]
 
file  xess_d3d12.h [code]
 
file  xess_d3d12_debug.h [code]
 
file  xess_debug.h [code]
 
-
-
- - - - diff --git a/xess/doc/doxygen/dir_4a251d3eb62f66b4b6f58851eefb73f5.js b/xess/doc/doxygen/dir_4a251d3eb62f66b4b6f58851eefb73f5.js deleted file mode 100644 index 52c5936..0000000 --- a/xess/doc/doxygen/dir_4a251d3eb62f66b4b6f58851eefb73f5.js +++ /dev/null @@ -1,7 +0,0 @@ -var dir_4a251d3eb62f66b4b6f58851eefb73f5 = -[ - [ "xess.h", "xess_8h.html", "xess_8h" ], - [ "xess_d3d12.h", "xess__d3d12_8h.html", "xess__d3d12_8h" ], - [ "xess_d3d12_debug.h", "xess__d3d12__debug_8h.html", "xess__d3d12__debug_8h" ], - [ "xess_debug.h", "xess__debug_8h.html", "xess__debug_8h" ] -]; \ No newline at end of file diff --git a/xess/doc/doxygen/dir_5ad0abcc15ef4bac8507fd4204e78835.html b/xess/doc/doxygen/dir_5ad0abcc15ef4bac8507fd4204e78835.html deleted file mode 100644 index 3cc7577..0000000 --- a/xess/doc/doxygen/dir_5ad0abcc15ef4bac8507fd4204e78835.html +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: D:/qb/workspace/29555/source/libraries.gpu.rendering.xess.xess-sdk/libxess Directory Reference - - - - - - - - - - - - - -
-
- - - - - - - -
-
XeSS SDK API Reference Guide 1.0.0 -
-
-
- - - - - - - -
-
- -
-
-
- -
- -
-
- - -
- -
- -
-
libxess Directory Reference
-
-
- - - - -

-Directories

directory  include
 
-
-
- - - - diff --git a/xess/doc/doxygen/dir_5ad0abcc15ef4bac8507fd4204e78835.js b/xess/doc/doxygen/dir_5ad0abcc15ef4bac8507fd4204e78835.js deleted file mode 100644 index 1d2e01b..0000000 --- a/xess/doc/doxygen/dir_5ad0abcc15ef4bac8507fd4204e78835.js +++ /dev/null @@ -1,4 +0,0 @@ -var dir_5ad0abcc15ef4bac8507fd4204e78835 = -[ - [ "include", "dir_ad7b8b496e7eff69e811d1861bea65db.html", "dir_ad7b8b496e7eff69e811d1861bea65db" ] -]; \ No newline at end of file diff --git a/xess/doc/doxygen/dir_ad7b8b496e7eff69e811d1861bea65db.html b/xess/doc/doxygen/dir_ad7b8b496e7eff69e811d1861bea65db.html deleted file mode 100644 index 3185b94..0000000 --- a/xess/doc/doxygen/dir_ad7b8b496e7eff69e811d1861bea65db.html +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: D:/qb/workspace/29555/source/libraries.gpu.rendering.xess.xess-sdk/libxess/include Directory Reference - - - - - - - - - - - - - -
-
- - - - - - - -
-
XeSS SDK API Reference Guide 1.0.0 -
-
-
- - - - - - - -
-
- -
-
-
- -
- -
-
- - -
- -
- -
-
include Directory Reference
-
-
- - - - -

-Directories

directory  xess
 
-
-
- - - - diff --git a/xess/doc/doxygen/dir_ad7b8b496e7eff69e811d1861bea65db.js b/xess/doc/doxygen/dir_ad7b8b496e7eff69e811d1861bea65db.js deleted file mode 100644 index 65ee4b0..0000000 --- a/xess/doc/doxygen/dir_ad7b8b496e7eff69e811d1861bea65db.js +++ /dev/null @@ -1,4 +0,0 @@ -var dir_ad7b8b496e7eff69e811d1861bea65db = -[ - [ "xess", "dir_4a251d3eb62f66b4b6f58851eefb73f5.html", "dir_4a251d3eb62f66b4b6f58851eefb73f5" ] -]; \ No newline at end of file diff --git a/xess/doc/doxygen/doc.png b/xess/doc/doxygen/doc.png deleted file mode 100644 index 17edabf..0000000 Binary files a/xess/doc/doxygen/doc.png and /dev/null differ diff --git a/xess/doc/doxygen/doxygen.css b/xess/doc/doxygen/doxygen.css deleted file mode 100644 index 9036737..0000000 --- a/xess/doc/doxygen/doxygen.css +++ /dev/null @@ -1,1841 +0,0 @@ -/* The standard CSS for doxygen 1.9.3 */ - -body, table, div, p, dl { - font: 400 14px/22px Roboto,sans-serif; -} - -p.reference, p.definition { - font: 400 14px/22px Roboto,sans-serif; -} - -/* @group Heading Levels */ - -h1.groupheader { - font-size: 150%; -} - -.title { - font: 400 14px/28px Roboto,sans-serif; - font-size: 150%; - font-weight: bold; - margin: 10px 2px; -} - -h2.groupheader { - border-bottom: 1px solid #879ECB; - color: #354C7B; - font-size: 150%; - font-weight: normal; - margin-top: 1.75em; - padding-top: 8px; - padding-bottom: 4px; - width: 100%; -} - -h3.groupheader { - font-size: 100%; -} - -h1, h2, h3, h4, h5, h6 { - -webkit-transition: text-shadow 0.5s linear; - -moz-transition: text-shadow 0.5s linear; - -ms-transition: text-shadow 0.5s linear; - -o-transition: text-shadow 0.5s linear; - transition: text-shadow 0.5s linear; - margin-right: 15px; -} - -h1.glow, h2.glow, h3.glow, h4.glow, h5.glow, h6.glow { - text-shadow: 0 0 15px cyan; -} - -dt { - font-weight: bold; -} - -ul.multicol { - -moz-column-gap: 1em; - -webkit-column-gap: 1em; - column-gap: 1em; - -moz-column-count: 3; - -webkit-column-count: 3; - column-count: 3; -} - -p.startli, p.startdd { - margin-top: 2px; -} - -th p.starttd, th p.intertd, th p.endtd { - font-size: 100%; - font-weight: 700; -} - -p.starttd { - margin-top: 0px; -} - -p.endli { - margin-bottom: 0px; -} - -p.enddd { - margin-bottom: 4px; -} - -p.endtd { - margin-bottom: 2px; -} - -p.interli { -} - -p.interdd { -} - -p.intertd { -} - -/* @end */ - -caption { - font-weight: bold; -} - -span.legend { - font-size: 70%; - text-align: center; -} - -h3.version { - font-size: 90%; - text-align: center; -} - -div.navtab { - border-right: 1px solid #A3B4D7; - padding-right: 15px; - text-align: right; - line-height: 110%; -} - -div.navtab table { - border-spacing: 0; -} - -td.navtab { - padding-right: 6px; - padding-left: 6px; -} -td.navtabHL { - background-image: url('tab_a.png'); - background-repeat:repeat-x; - padding-right: 6px; - padding-left: 6px; -} - -td.navtabHL a, td.navtabHL a:visited { - color: #fff; - text-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0); -} - -a.navtab { - font-weight: bold; -} - -div.qindex{ - text-align: center; - width: 100%; - line-height: 140%; - font-size: 130%; - color: #A0A0A0; -} - -dt.alphachar{ - font-size: 180%; - font-weight: bold; -} - -.alphachar a{ - color: black; -} - -.alphachar a:hover, .alphachar a:visited{ - text-decoration: none; -} - -.classindex dl { - padding: 25px; - column-count:1 -} - -.classindex dd { - display:inline-block; - margin-left: 50px; - width: 90%; - line-height: 1.15em; -} - -.classindex dl.odd { - background-color: #F8F9FC; -} - -@media(min-width: 1120px) { - .classindex dl { - column-count:2 - } -} - -@media(min-width: 1320px) { - .classindex dl { - column-count:3 - } -} - - -/* @group Link Styling */ - -a { - color: #3D578C; - font-weight: normal; - text-decoration: none; -} - -.contents a:visited { - color: #4665A2; -} - -a:hover { - text-decoration: underline; -} - -.contents a.qindexHL:visited { - color: #FFFFFF; -} - -a.el { - font-weight: bold; -} - -a.elRef { -} - -a.code, a.code:visited, a.line, a.line:visited { - color: #4665A2; -} - -a.codeRef, a.codeRef:visited, a.lineRef, a.lineRef:visited { - color: #4665A2; -} - -a.code.hl_class { /* style for links to class names in code snippets */ } -a.code.hl_struct { /* style for links to struct names in code snippets */ } -a.code.hl_union { /* style for links to union names in code snippets */ } -a.code.hl_interface { /* style for links to interface names in code snippets */ } -a.code.hl_protocol { /* style for links to protocol names in code snippets */ } -a.code.hl_category { /* style for links to category names in code snippets */ } -a.code.hl_exception { /* style for links to exception names in code snippets */ } -a.code.hl_service { /* style for links to service names in code snippets */ } -a.code.hl_singleton { /* style for links to singleton names in code snippets */ } -a.code.hl_concept { /* style for links to concept names in code snippets */ } -a.code.hl_namespace { /* style for links to namespace names in code snippets */ } -a.code.hl_package { /* style for links to package names in code snippets */ } -a.code.hl_define { /* style for links to macro names in code snippets */ } -a.code.hl_function { /* style for links to function names in code snippets */ } -a.code.hl_variable { /* style for links to variable names in code snippets */ } -a.code.hl_typedef { /* style for links to typedef names in code snippets */ } -a.code.hl_enumvalue { /* style for links to enum value names in code snippets */ } -a.code.hl_enumeration { /* style for links to enumeration names in code snippets */ } -a.code.hl_signal { /* style for links to Qt signal names in code snippets */ } -a.code.hl_slot { /* style for links to Qt slot names in code snippets */ } -a.code.hl_friend { /* style for links to friend names in code snippets */ } -a.code.hl_dcop { /* style for links to KDE3 DCOP names in code snippets */ } -a.code.hl_property { /* style for links to property names in code snippets */ } -a.code.hl_event { /* style for links to event names in code snippets */ } -a.code.hl_sequence { /* style for links to sequence names in code snippets */ } -a.code.hl_dictionary { /* style for links to dictionary names in code snippets */ } - -/* @end */ - -dl.el { - margin-left: -1cm; -} - -ul { - overflow: visible; -} - -#side-nav ul { - overflow: visible; /* reset ul rule for scroll bar in GENERATE_TREEVIEW window */ -} - -#main-nav ul { - overflow: visible; /* reset ul rule for the navigation bar drop down lists */ -} - -.fragment { - text-align: left; - direction: ltr; - overflow-x: auto; /*Fixed: fragment lines overlap floating elements*/ - overflow-y: hidden; -} - -pre.fragment { - border: 1px solid #C4CFE5; - background-color: #FBFCFD; - padding: 4px 6px; - margin: 4px 8px 4px 2px; - overflow: auto; - word-wrap: break-word; - font-size: 9pt; - line-height: 125%; - font-family: monospace, fixed; - font-size: 105%; -} - -div.fragment { - padding: 0 0 1px 0; /*Fixed: last line underline overlap border*/ - margin: 4px 8px 4px 2px; - background-color: #FBFCFD; - border: 1px solid #C4CFE5; -} - -div.line { - font-family: monospace, fixed; - font-size: 13px; - min-height: 13px; - line-height: 1.0; - text-wrap: unrestricted; - white-space: -moz-pre-wrap; /* Moz */ - white-space: -pre-wrap; /* Opera 4-6 */ - white-space: -o-pre-wrap; /* Opera 7 */ - white-space: pre-wrap; /* CSS3 */ - word-wrap: break-word; /* IE 5.5+ */ - text-indent: -53px; - padding-left: 53px; - padding-bottom: 0px; - margin: 0px; - -webkit-transition-property: background-color, box-shadow; - -webkit-transition-duration: 0.5s; - -moz-transition-property: background-color, box-shadow; - -moz-transition-duration: 0.5s; - -ms-transition-property: background-color, box-shadow; - -ms-transition-duration: 0.5s; - -o-transition-property: background-color, box-shadow; - -o-transition-duration: 0.5s; - transition-property: background-color, box-shadow; - transition-duration: 0.5s; -} - -div.line:after { - content:"\000A"; - white-space: pre; -} - -div.line.glow { - background-color: cyan; - box-shadow: 0 0 10px cyan; -} - - -span.lineno { - padding-right: 4px; - margin-right: 9px; - text-align: right; - border-right: 2px solid #0F0; - background-color: #E8E8E8; - white-space: pre; -} -span.lineno a { - background-color: #D8D8D8; -} - -span.lineno a:hover { - background-color: #C8C8C8; -} - -.lineno { - -webkit-touch-callout: none; - -webkit-user-select: none; - -khtml-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} - -div.ah, span.ah { - background-color: black; - font-weight: bold; - color: #FFFFFF; - margin-bottom: 3px; - margin-top: 3px; - padding: 0.2em; - border: solid thin #333; - border-radius: 0.5em; - -webkit-border-radius: .5em; - -moz-border-radius: .5em; - box-shadow: 2px 2px 3px #999; - -webkit-box-shadow: 2px 2px 3px #999; - -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; - background-image: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#000),color-stop(0.3, #444)); - background-image: -moz-linear-gradient(center top, #eee 0%, #444 40%, #000 110%); -} - -div.classindex ul { - list-style: none; - padding-left: 0; -} - -div.classindex span.ai { - display: inline-block; -} - -div.groupHeader { - margin-left: 16px; - margin-top: 12px; - font-weight: bold; -} - -div.groupText { - margin-left: 16px; - font-style: italic; -} - -body { - background-color: white; - color: black; - margin: 0; -} - -div.contents { - margin-top: 10px; - margin-left: 12px; - margin-right: 8px; -} - -td.indexkey { - background-color: #EBEFF6; - font-weight: bold; - border: 1px solid #C4CFE5; - margin: 2px 0px 2px 0; - padding: 2px 10px; - white-space: nowrap; - vertical-align: top; -} - -td.indexvalue { - background-color: #EBEFF6; - border: 1px solid #C4CFE5; - padding: 2px 10px; - margin: 2px 0px; -} - -tr.memlist { - background-color: #EEF1F7; -} - -p.formulaDsp { - text-align: center; -} - -img.formulaDsp { - -} - -img.formulaInl, img.inline { - vertical-align: middle; -} - -div.center { - text-align: center; - margin-top: 0px; - margin-bottom: 0px; - padding: 0px; -} - -div.center img { - border: 0px; -} - -address.footer { - text-align: right; - padding-right: 12px; -} - -img.footer { - border: 0px; - vertical-align: middle; -} - -.compoundTemplParams { - color: #4665A2; - font-size: 80%; - line-height: 120%; -} - -/* @group Code Colorization */ - -span.keyword { - color: #008000 -} - -span.keywordtype { - color: #604020 -} - -span.keywordflow { - color: #e08000 -} - -span.comment { - color: #800000 -} - -span.preprocessor { - color: #806020 -} - -span.stringliteral { - color: #002080 -} - -span.charliteral { - color: #008080 -} - -span.vhdldigit { - color: #ff00ff -} - -span.vhdlchar { - color: #000000 -} - -span.vhdlkeyword { - color: #700070 -} - -span.vhdllogic { - color: #ff0000 -} - -blockquote { - background-color: #F7F8FB; - border-left: 2px solid #9CAFD4; - margin: 0 24px 0 4px; - padding: 0 12px 0 16px; -} - -blockquote.DocNodeRTL { - border-left: 0; - border-right: 2px solid #9CAFD4; - margin: 0 4px 0 24px; - padding: 0 16px 0 12px; -} - -/* @end */ - -/* -.search { - color: #003399; - font-weight: bold; -} - -form.search { - margin-bottom: 0px; - margin-top: 0px; -} - -input.search { - font-size: 75%; - color: #000080; - font-weight: normal; - background-color: #e8eef2; -} -*/ - -td.tiny { - font-size: 75%; -} - -.dirtab { - padding: 4px; - border-collapse: collapse; - border: 1px solid #A3B4D7; -} - -th.dirtab { - background: #EBEFF6; - font-weight: bold; -} - -hr { - height: 0px; - border: none; - border-top: 1px solid #4A6AAA; -} - -hr.footer { - height: 1px; -} - -/* @group Member Descriptions */ - -table.memberdecls { - border-spacing: 0px; - padding: 0px; -} - -.memberdecls td, .fieldtable tr { - -webkit-transition-property: background-color, box-shadow; - -webkit-transition-duration: 0.5s; - -moz-transition-property: background-color, box-shadow; - -moz-transition-duration: 0.5s; - -ms-transition-property: background-color, box-shadow; - -ms-transition-duration: 0.5s; - -o-transition-property: background-color, box-shadow; - -o-transition-duration: 0.5s; - transition-property: background-color, box-shadow; - transition-duration: 0.5s; -} - -.memberdecls td.glow, .fieldtable tr.glow { - background-color: cyan; - box-shadow: 0 0 15px cyan; -} - -.mdescLeft, .mdescRight, -.memItemLeft, .memItemRight, -.memTemplItemLeft, .memTemplItemRight, .memTemplParams { - background-color: #F9FAFC; - border: none; - margin: 4px; - padding: 1px 0 0 8px; -} - -.mdescLeft, .mdescRight { - padding: 0px 8px 4px 8px; - color: #555; -} - -.memSeparator { - border-bottom: 1px solid #DEE4F0; - line-height: 1px; - margin: 0px; - padding: 0px; -} - -.memItemLeft, .memTemplItemLeft { - white-space: nowrap; -} - -.memItemRight, .memTemplItemRight { - width: 100%; -} - -.memTemplParams { - color: #4665A2; - white-space: nowrap; - font-size: 80%; -} - -/* @end */ - -/* @group Member Details */ - -/* Styles for detailed member documentation */ - -.memtitle { - padding: 8px; - border-top: 1px solid #A8B8D9; - border-left: 1px solid #A8B8D9; - border-right: 1px solid #A8B8D9; - border-top-right-radius: 4px; - border-top-left-radius: 4px; - margin-bottom: -1px; - background-image: url('nav_f.png'); - background-repeat: repeat-x; - background-color: #E2E8F2; - line-height: 1.25; - font-weight: 300; - float:left; -} - -.permalink -{ - font-size: 65%; - display: inline-block; - vertical-align: middle; -} - -.memtemplate { - font-size: 80%; - color: #4665A2; - font-weight: normal; - margin-left: 9px; -} - -.memnav { - background-color: #EBEFF6; - border: 1px solid #A3B4D7; - text-align: center; - margin: 2px; - margin-right: 15px; - padding: 2px; -} - -.mempage { - width: 100%; -} - -.memitem { - padding: 0; - margin-bottom: 10px; - margin-right: 5px; - -webkit-transition: box-shadow 0.5s linear; - -moz-transition: box-shadow 0.5s linear; - -ms-transition: box-shadow 0.5s linear; - -o-transition: box-shadow 0.5s linear; - transition: box-shadow 0.5s linear; - display: table !important; - width: 100%; -} - -.memitem.glow { - box-shadow: 0 0 15px cyan; -} - -.memname { - font-weight: 400; - margin-left: 6px; -} - -.memname td { - vertical-align: bottom; -} - -.memproto, dl.reflist dt { - border-top: 1px solid #A8B8D9; - border-left: 1px solid #A8B8D9; - border-right: 1px solid #A8B8D9; - padding: 6px 0px 6px 0px; - color: #253555; - font-weight: bold; - text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); - background-color: #DFE5F1; - /* opera specific markup */ - box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); - border-top-right-radius: 4px; - /* firefox specific markup */ - -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; - -moz-border-radius-topright: 4px; - /* webkit specific markup */ - -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); - -webkit-border-top-right-radius: 4px; - -} - -.overload { - font-family: "courier new",courier,monospace; - font-size: 65%; -} - -.memdoc, dl.reflist dd { - border-bottom: 1px solid #A8B8D9; - border-left: 1px solid #A8B8D9; - border-right: 1px solid #A8B8D9; - padding: 6px 10px 2px 10px; - background-color: #FBFCFD; - border-top-width: 0; - background-image:url('nav_g.png'); - background-repeat:repeat-x; - background-color: #FFFFFF; - /* opera specific markup */ - border-bottom-left-radius: 4px; - border-bottom-right-radius: 4px; - box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); - /* firefox specific markup */ - -moz-border-radius-bottomleft: 4px; - -moz-border-radius-bottomright: 4px; - -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; - /* webkit specific markup */ - -webkit-border-bottom-left-radius: 4px; - -webkit-border-bottom-right-radius: 4px; - -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); -} - -dl.reflist dt { - padding: 5px; -} - -dl.reflist dd { - margin: 0px 0px 10px 0px; - padding: 5px; -} - -.paramkey { - text-align: right; -} - -.paramtype { - white-space: nowrap; -} - -.paramname { - color: #602020; - white-space: nowrap; -} -.paramname em { - font-style: normal; -} -.paramname code { - line-height: 14px; -} - -.params, .retval, .exception, .tparams { - margin-left: 0px; - padding-left: 0px; -} - -.params .paramname, .retval .paramname, .tparams .paramname, .exception .paramname { - font-weight: bold; - vertical-align: top; -} - -.params .paramtype, .tparams .paramtype { - font-style: italic; - vertical-align: top; -} - -.params .paramdir, .tparams .paramdir { - font-family: "courier new",courier,monospace; - vertical-align: top; -} - -table.mlabels { - border-spacing: 0px; -} - -td.mlabels-left { - width: 100%; - padding: 0px; -} - -td.mlabels-right { - vertical-align: bottom; - padding: 0px; - white-space: nowrap; -} - -span.mlabels { - margin-left: 8px; -} - -span.mlabel { - background-color: #728DC1; - border-top:1px solid #5373B4; - border-left:1px solid #5373B4; - border-right:1px solid #C4CFE5; - border-bottom:1px solid #C4CFE5; - text-shadow: none; - color: white; - margin-right: 4px; - padding: 2px 3px; - border-radius: 3px; - font-size: 7pt; - white-space: nowrap; - vertical-align: middle; -} - - - -/* @end */ - -/* these are for tree view inside a (index) page */ - -div.directory { - margin: 10px 0px; - border-top: 1px solid #9CAFD4; - border-bottom: 1px solid #9CAFD4; - width: 100%; -} - -.directory table { - border-collapse:collapse; -} - -.directory td { - margin: 0px; - padding: 0px; - vertical-align: top; -} - -.directory td.entry { - white-space: nowrap; - padding-right: 6px; - padding-top: 3px; -} - -.directory td.entry a { - outline:none; -} - -.directory td.entry a img { - border: none; -} - -.directory td.desc { - width: 100%; - padding-left: 6px; - padding-right: 6px; - padding-top: 3px; - border-left: 1px solid rgba(0,0,0,0.05); -} - -.directory tr.even { - padding-left: 6px; - background-color: #F7F8FB; -} - -.directory img { - vertical-align: -30%; -} - -.directory .levels { - white-space: nowrap; - width: 100%; - text-align: right; - font-size: 9pt; -} - -.directory .levels span { - cursor: pointer; - padding-left: 2px; - padding-right: 2px; - color: #3D578C; -} - -.arrow { - color: #9CAFD4; - -webkit-user-select: none; - -khtml-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - cursor: pointer; - font-size: 80%; - display: inline-block; - width: 16px; - height: 22px; -} - -.icon { - font-family: Arial, Helvetica; - font-weight: bold; - font-size: 12px; - height: 14px; - width: 16px; - display: inline-block; - background-color: #728DC1; - color: white; - text-align: center; - border-radius: 4px; - margin-left: 2px; - margin-right: 2px; -} - -.icona { - width: 24px; - height: 22px; - display: inline-block; -} - -.iconfopen { - width: 24px; - height: 18px; - margin-bottom: 4px; - background-image:url('folderopen.png'); - background-position: 0px -4px; - background-repeat: repeat-y; - vertical-align:top; - display: inline-block; -} - -.iconfclosed { - width: 24px; - height: 18px; - margin-bottom: 4px; - background-image:url('folderclosed.png'); - background-position: 0px -4px; - background-repeat: repeat-y; - vertical-align:top; - display: inline-block; -} - -.icondoc { - width: 24px; - height: 18px; - margin-bottom: 4px; - background-image:url('doc.png'); - background-position: 0px -4px; - background-repeat: repeat-y; - vertical-align:top; - display: inline-block; -} - -table.directory { - font: 400 14px Roboto,sans-serif; -} - -/* @end */ - -div.dynheader { - margin-top: 8px; - -webkit-touch-callout: none; - -webkit-user-select: none; - -khtml-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} - -address { - font-style: normal; - color: #2A3D61; -} - -table.doxtable caption { - caption-side: top; -} - -table.doxtable { - border-collapse:collapse; - margin-top: 4px; - margin-bottom: 4px; -} - -table.doxtable td, table.doxtable th { - border: 1px solid #2D4068; - padding: 3px 7px 2px; -} - -table.doxtable th { - background-color: #374F7F; - color: #FFFFFF; - font-size: 110%; - padding-bottom: 4px; - padding-top: 5px; -} - -table.fieldtable { - /*width: 100%;*/ - margin-bottom: 10px; - border: 1px solid #A8B8D9; - border-spacing: 0px; - -moz-border-radius: 4px; - -webkit-border-radius: 4px; - border-radius: 4px; - -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; - -webkit-box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15); - box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15); -} - -.fieldtable td, .fieldtable th { - padding: 3px 7px 2px; -} - -.fieldtable td.fieldtype, .fieldtable td.fieldname { - white-space: nowrap; - border-right: 1px solid #A8B8D9; - border-bottom: 1px solid #A8B8D9; - vertical-align: top; -} - -.fieldtable td.fieldname { - padding-top: 3px; -} - -.fieldtable td.fielddoc { - border-bottom: 1px solid #A8B8D9; - /*width: 100%;*/ -} - -.fieldtable td.fielddoc p:first-child { - margin-top: 0px; -} - -.fieldtable td.fielddoc p:last-child { - margin-bottom: 2px; -} - -.fieldtable tr:last-child td { - border-bottom: none; -} - -.fieldtable th { - background-image:url('nav_f.png'); - background-repeat:repeat-x; - background-color: #E2E8F2; - font-size: 90%; - color: #253555; - padding-bottom: 4px; - padding-top: 5px; - text-align:left; - font-weight: 400; - -moz-border-radius-topleft: 4px; - -moz-border-radius-topright: 4px; - -webkit-border-top-left-radius: 4px; - -webkit-border-top-right-radius: 4px; - border-top-left-radius: 4px; - border-top-right-radius: 4px; - border-bottom: 1px solid #A8B8D9; -} - - -.tabsearch { - top: 0px; - left: 10px; - height: 36px; - background-image: url('tab_b.png'); - z-index: 101; - overflow: hidden; - font-size: 13px; -} - -.navpath ul -{ - font-size: 11px; - background-image:url('tab_b.png'); - background-repeat:repeat-x; - background-position: 0 -5px; - height:30px; - line-height:30px; - color:#8AA0CC; - border:solid 1px #C2CDE4; - overflow:hidden; - margin:0px; - padding:0px; -} - -.navpath li -{ - list-style-type:none; - float:left; - padding-left:10px; - padding-right:15px; - background-image:url('bc_s.png'); - background-repeat:no-repeat; - background-position:right; - color:#364D7C; -} - -.navpath li.navelem a -{ - height:32px; - display:block; - text-decoration: none; - outline: none; - color: #283A5D; - font-family: 'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; - text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); - text-decoration: none; -} - -.navpath li.navelem a:hover -{ - color:#6884BD; -} - -.navpath li.footer -{ - list-style-type:none; - float:right; - padding-left:10px; - padding-right:15px; - background-image:none; - background-repeat:no-repeat; - background-position:right; - color:#364D7C; - font-size: 8pt; -} - - -div.summary -{ - float: right; - font-size: 8pt; - padding-right: 5px; - width: 50%; - text-align: right; -} - -div.summary a -{ - white-space: nowrap; -} - -table.classindex -{ - margin: 10px; - white-space: nowrap; - margin-left: 3%; - margin-right: 3%; - width: 94%; - border: 0; - border-spacing: 0; - padding: 0; -} - -div.ingroups -{ - font-size: 8pt; - width: 50%; - text-align: left; -} - -div.ingroups a -{ - white-space: nowrap; -} - -div.header -{ - background-image:url('nav_h.png'); - background-repeat:repeat-x; - background-color: #F9FAFC; - margin: 0px; - border-bottom: 1px solid #C4CFE5; -} - -div.headertitle -{ - padding: 5px 5px 5px 10px; -} - -.PageDocRTL-title div.headertitle { - text-align: right; - direction: rtl; -} - -dl { - padding: 0 0 0 0; -} - -/* dl.note, dl.warning, dl.attention, dl.pre, dl.post, dl.invariant, dl.deprecated, dl.todo, dl.test, dl.bug, dl.examples */ -dl.section { - margin-left: 0px; - padding-left: 0px; -} - -dl.section.DocNodeRTL { - margin-right: 0px; - padding-right: 0px; -} - -dl.note { - margin-left: -7px; - padding-left: 3px; - border-left: 4px solid; - border-color: #D0C000; -} - -dl.note.DocNodeRTL { - margin-left: 0; - padding-left: 0; - border-left: 0; - margin-right: -7px; - padding-right: 3px; - border-right: 4px solid; - border-color: #D0C000; -} - -dl.warning, dl.attention { - margin-left: -7px; - padding-left: 3px; - border-left: 4px solid; - border-color: #FF0000; -} - -dl.warning.DocNodeRTL, dl.attention.DocNodeRTL { - margin-left: 0; - padding-left: 0; - border-left: 0; - margin-right: -7px; - padding-right: 3px; - border-right: 4px solid; - border-color: #FF0000; -} - -dl.pre, dl.post, dl.invariant { - margin-left: -7px; - padding-left: 3px; - border-left: 4px solid; - border-color: #00D000; -} - -dl.pre.DocNodeRTL, dl.post.DocNodeRTL, dl.invariant.DocNodeRTL { - margin-left: 0; - padding-left: 0; - border-left: 0; - margin-right: -7px; - padding-right: 3px; - border-right: 4px solid; - border-color: #00D000; -} - -dl.deprecated { - margin-left: -7px; - padding-left: 3px; - border-left: 4px solid; - border-color: #505050; -} - -dl.deprecated.DocNodeRTL { - margin-left: 0; - padding-left: 0; - border-left: 0; - margin-right: -7px; - padding-right: 3px; - border-right: 4px solid; - border-color: #505050; -} - -dl.todo { - margin-left: -7px; - padding-left: 3px; - border-left: 4px solid; - border-color: #00C0E0; -} - -dl.todo.DocNodeRTL { - margin-left: 0; - padding-left: 0; - border-left: 0; - margin-right: -7px; - padding-right: 3px; - border-right: 4px solid; - border-color: #00C0E0; -} - -dl.test { - margin-left: -7px; - padding-left: 3px; - border-left: 4px solid; - border-color: #3030E0; -} - -dl.test.DocNodeRTL { - margin-left: 0; - padding-left: 0; - border-left: 0; - margin-right: -7px; - padding-right: 3px; - border-right: 4px solid; - border-color: #3030E0; -} - -dl.bug { - margin-left: -7px; - padding-left: 3px; - border-left: 4px solid; - border-color: #C08050; -} - -dl.bug.DocNodeRTL { - margin-left: 0; - padding-left: 0; - border-left: 0; - margin-right: -7px; - padding-right: 3px; - border-right: 4px solid; - border-color: #C08050; -} - -dl.section dd { - margin-bottom: 6px; -} - - -#projectrow -{ - height: 56px; -} - -#projectlogo -{ - text-align: center; - vertical-align: bottom; - border-collapse: separate; -} - -#projectlogo img -{ - border: 0px none; -} - -#projectalign -{ - vertical-align: middle; - padding-left: 0.5em; -} - -#projectname -{ - font: 200% Tahoma, Arial,sans-serif; - margin: 0px; - padding: 2px 0px; -} - -#projectbrief -{ - font: 90% Tahoma, Arial,sans-serif; - margin: 0px; - padding: 0px; -} - -#projectnumber -{ - font: 50% Tahoma, Arial,sans-serif; - margin: 0px; - padding: 0px; -} - -#titlearea -{ - padding: 0px; - margin: 0px; - width: 100%; - border-bottom: 1px solid #5373B4; -} - -.image -{ - text-align: center; -} - -.dotgraph -{ - text-align: center; -} - -.mscgraph -{ - text-align: center; -} - -.plantumlgraph -{ - text-align: center; -} - -.diagraph -{ - text-align: center; -} - -.caption -{ - font-weight: bold; -} - -div.zoom -{ - border: 1px solid #90A5CE; -} - -dl.citelist { - margin-bottom:50px; -} - -dl.citelist dt { - color:#334975; - float:left; - font-weight:bold; - margin-right:10px; - padding:5px; - text-align:right; - width:52px; -} - -dl.citelist dd { - margin:2px 0 2px 72px; - padding:5px 0; -} - -div.toc { - padding: 14px 25px; - background-color: #F4F6FA; - border: 1px solid #D8DFEE; - border-radius: 7px 7px 7px 7px; - float: right; - height: auto; - margin: 0 8px 10px 10px; - width: 200px; -} - -.PageDocRTL-title div.toc { - float: left !important; - text-align: right; -} - -div.toc li { - background: url("bdwn.png") no-repeat scroll 0 5px transparent; - font: 10px/1.2 Verdana,DejaVu Sans,Geneva,sans-serif; - margin-top: 5px; - padding-left: 10px; - padding-top: 2px; -} - -.PageDocRTL-title div.toc li { - background-position-x: right !important; - padding-left: 0 !important; - padding-right: 10px; -} - -div.toc h3 { - font: bold 12px/1.2 Arial,FreeSans,sans-serif; - color: #4665A2; - border-bottom: 0 none; - margin: 0; -} - -div.toc ul { - list-style: none outside none; - border: medium none; - padding: 0px; -} - -div.toc li.level1 { - margin-left: 0px; -} - -div.toc li.level2 { - margin-left: 15px; -} - -div.toc li.level3 { - margin-left: 30px; -} - -div.toc li.level4 { - margin-left: 45px; -} - -span.emoji { - /* font family used at the site: https://unicode.org/emoji/charts/full-emoji-list.html - * font-family: "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", Times, Symbola, Aegyptus, Code2000, Code2001, Code2002, Musica, serif, LastResort; - */ -} - -span.obfuscator { - display: none; -} - -.PageDocRTL-title div.toc li.level1 { - margin-left: 0 !important; - margin-right: 0; -} - -.PageDocRTL-title div.toc li.level2 { - margin-left: 0 !important; - margin-right: 15px; -} - -.PageDocRTL-title div.toc li.level3 { - margin-left: 0 !important; - margin-right: 30px; -} - -.PageDocRTL-title div.toc li.level4 { - margin-left: 0 !important; - margin-right: 45px; -} - -.inherit_header { - font-weight: bold; - color: gray; - cursor: pointer; - -webkit-touch-callout: none; - -webkit-user-select: none; - -khtml-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} - -.inherit_header td { - padding: 6px 0px 2px 5px; -} - -.inherit { - display: none; -} - -tr.heading h2 { - margin-top: 12px; - margin-bottom: 4px; -} - -/* tooltip related style info */ - -.ttc { - position: absolute; - display: none; -} - -#powerTip { - cursor: default; - /*white-space: nowrap;*/ - background-color: white; - border: 1px solid gray; - border-radius: 4px 4px 4px 4px; - box-shadow: 1px 1px 7px gray; - display: none; - font-size: smaller; - max-width: 80%; - opacity: 0.9; - padding: 1ex 1em 1em; - position: absolute; - z-index: 2147483647; -} - -#powerTip div.ttdoc { - color: grey; - font-style: italic; -} - -#powerTip div.ttname a { - font-weight: bold; -} - -#powerTip div.ttname { - font-weight: bold; -} - -#powerTip div.ttdeci { - color: #006318; -} - -#powerTip div { - margin: 0px; - padding: 0px; - font: 12px/16px Roboto,sans-serif; -} - -#powerTip:before, #powerTip:after { - content: ""; - position: absolute; - margin: 0px; -} - -#powerTip.n:after, #powerTip.n:before, -#powerTip.s:after, #powerTip.s:before, -#powerTip.w:after, #powerTip.w:before, -#powerTip.e:after, #powerTip.e:before, -#powerTip.ne:after, #powerTip.ne:before, -#powerTip.se:after, #powerTip.se:before, -#powerTip.nw:after, #powerTip.nw:before, -#powerTip.sw:after, #powerTip.sw:before { - border: solid transparent; - content: " "; - height: 0; - width: 0; - position: absolute; -} - -#powerTip.n:after, #powerTip.s:after, -#powerTip.w:after, #powerTip.e:after, -#powerTip.nw:after, #powerTip.ne:after, -#powerTip.sw:after, #powerTip.se:after { - border-color: rgba(255, 255, 255, 0); -} - -#powerTip.n:before, #powerTip.s:before, -#powerTip.w:before, #powerTip.e:before, -#powerTip.nw:before, #powerTip.ne:before, -#powerTip.sw:before, #powerTip.se:before { - border-color: rgba(128, 128, 128, 0); -} - -#powerTip.n:after, #powerTip.n:before, -#powerTip.ne:after, #powerTip.ne:before, -#powerTip.nw:after, #powerTip.nw:before { - top: 100%; -} - -#powerTip.n:after, #powerTip.ne:after, #powerTip.nw:after { - border-top-color: #FFFFFF; - border-width: 10px; - margin: 0px -10px; -} -#powerTip.n:before { - border-top-color: #808080; - border-width: 11px; - margin: 0px -11px; -} -#powerTip.n:after, #powerTip.n:before { - left: 50%; -} - -#powerTip.nw:after, #powerTip.nw:before { - right: 14px; -} - -#powerTip.ne:after, #powerTip.ne:before { - left: 14px; -} - -#powerTip.s:after, #powerTip.s:before, -#powerTip.se:after, #powerTip.se:before, -#powerTip.sw:after, #powerTip.sw:before { - bottom: 100%; -} - -#powerTip.s:after, #powerTip.se:after, #powerTip.sw:after { - border-bottom-color: #FFFFFF; - border-width: 10px; - margin: 0px -10px; -} - -#powerTip.s:before, #powerTip.se:before, #powerTip.sw:before { - border-bottom-color: #808080; - border-width: 11px; - margin: 0px -11px; -} - -#powerTip.s:after, #powerTip.s:before { - left: 50%; -} - -#powerTip.sw:after, #powerTip.sw:before { - right: 14px; -} - -#powerTip.se:after, #powerTip.se:before { - left: 14px; -} - -#powerTip.e:after, #powerTip.e:before { - left: 100%; -} -#powerTip.e:after { - border-left-color: #FFFFFF; - border-width: 10px; - top: 50%; - margin-top: -10px; -} -#powerTip.e:before { - border-left-color: #808080; - border-width: 11px; - top: 50%; - margin-top: -11px; -} - -#powerTip.w:after, #powerTip.w:before { - right: 100%; -} -#powerTip.w:after { - border-right-color: #FFFFFF; - border-width: 10px; - top: 50%; - margin-top: -10px; -} -#powerTip.w:before { - border-right-color: #808080; - border-width: 11px; - top: 50%; - margin-top: -11px; -} - -@media print -{ - #top { display: none; } - #side-nav { display: none; } - #nav-path { display: none; } - body { overflow:visible; } - h1, h2, h3, h4, h5, h6 { page-break-after: avoid; } - .summary { display: none; } - .memitem { page-break-inside: avoid; } - #doc-content - { - margin-left:0 !important; - height:auto !important; - width:auto !important; - overflow:inherit; - display:inline; - } -} - -/* @group Markdown */ - -table.markdownTable { - border-collapse:collapse; - margin-top: 4px; - margin-bottom: 4px; -} - -table.markdownTable td, table.markdownTable th { - border: 1px solid #2D4068; - padding: 3px 7px 2px; -} - -table.markdownTable tr { -} - -th.markdownTableHeadLeft, th.markdownTableHeadRight, th.markdownTableHeadCenter, th.markdownTableHeadNone { - background-color: #374F7F; - color: #FFFFFF; - font-size: 110%; - padding-bottom: 4px; - padding-top: 5px; -} - -th.markdownTableHeadLeft, td.markdownTableBodyLeft { - text-align: left -} - -th.markdownTableHeadRight, td.markdownTableBodyRight { - text-align: right -} - -th.markdownTableHeadCenter, td.markdownTableBodyCenter { - text-align: center -} - -.DocNodeRTL { - text-align: right; - direction: rtl; -} - -.DocNodeLTR { - text-align: left; - direction: ltr; -} - -table.DocNodeRTL { - width: auto; - margin-right: 0; - margin-left: auto; -} - -table.DocNodeLTR { - width: auto; - margin-right: auto; - margin-left: 0; -} - -code.JavaDocCode - direction:ltr; -} - -tt, code, kbd, samp -{ - display: inline-block; - direction:ltr; -} -/* @end */ - -u { - text-decoration: underline; -} - diff --git a/xess/doc/doxygen/doxygen.svg b/xess/doc/doxygen/doxygen.svg deleted file mode 100644 index d42dad5..0000000 --- a/xess/doc/doxygen/doxygen.svg +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xess/doc/doxygen/dynsections.js b/xess/doc/doxygen/dynsections.js deleted file mode 100644 index 7906639..0000000 --- a/xess/doc/doxygen/dynsections.js +++ /dev/null @@ -1,128 +0,0 @@ -/* - @licstart The following is the entire license notice for the JavaScript code in this file. - - The MIT License (MIT) - - Copyright (C) 1997-2020 by Dimitri van Heesch - - Permission is hereby granted, free of charge, to any person obtaining a copy of this software - and associated documentation files (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, publish, distribute, - sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or - substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING - BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - @licend The above is the entire license notice for the JavaScript code in this file - */ -function toggleVisibility(linkObj) -{ - var base = $(linkObj).attr('id'); - var summary = $('#'+base+'-summary'); - var content = $('#'+base+'-content'); - var trigger = $('#'+base+'-trigger'); - var src=$(trigger).attr('src'); - if (content.is(':visible')===true) { - content.hide(); - summary.show(); - $(linkObj).addClass('closed').removeClass('opened'); - $(trigger).attr('src',src.substring(0,src.length-8)+'closed.png'); - } else { - content.show(); - summary.hide(); - $(linkObj).removeClass('closed').addClass('opened'); - $(trigger).attr('src',src.substring(0,src.length-10)+'open.png'); - } - return false; -} - -function updateStripes() -{ - $('table.directory tr'). - removeClass('even').filter(':visible:even').addClass('even'); -} - -function toggleLevel(level) -{ - $('table.directory tr').each(function() { - var l = this.id.split('_').length-1; - var i = $('#img'+this.id.substring(3)); - var a = $('#arr'+this.id.substring(3)); - if (l - - - - - - -XeSS SDK API Reference Guide: File List - - - - - - - - - - - - - -
-
- - - - - - - -
-
XeSS SDK API Reference Guide 1.0.0 -
-
-
- - - - - - - -
-
- -
-
-
- -
- -
-
- - -
- -
- -
-
File List
-
-
-
Here is a list of all files with brief descriptions:
-
[detail level 1234]
- - - - - - - -
  libxess
  include
  xess
 xess.h
 xess_d3d12.h
 xess_d3d12_debug.h
 xess_debug.h
-
-
-
- - - - diff --git a/xess/doc/doxygen/files_dup.js b/xess/doc/doxygen/files_dup.js deleted file mode 100644 index 162676f..0000000 --- a/xess/doc/doxygen/files_dup.js +++ /dev/null @@ -1,4 +0,0 @@ -var files_dup = -[ - [ "libxess", "dir_5ad0abcc15ef4bac8507fd4204e78835.html", "dir_5ad0abcc15ef4bac8507fd4204e78835" ] -]; \ No newline at end of file diff --git a/xess/doc/doxygen/folderclosed.png b/xess/doc/doxygen/folderclosed.png deleted file mode 100644 index bb8ab35..0000000 Binary files a/xess/doc/doxygen/folderclosed.png and /dev/null differ diff --git a/xess/doc/doxygen/folderopen.png b/xess/doc/doxygen/folderopen.png deleted file mode 100644 index d6c7f67..0000000 Binary files a/xess/doc/doxygen/folderopen.png and /dev/null differ diff --git a/xess/doc/doxygen/functions.html b/xess/doc/doxygen/functions.html deleted file mode 100644 index 61815f0..0000000 --- a/xess/doc/doxygen/functions.html +++ /dev/null @@ -1,224 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: Data Fields - - - - - - - - - - - - - -
-
- - - - - - - -
-
XeSS SDK API Reference Guide 1.0.0 -
-
-
- - - - - - - -
-
- -
-
-
- -
- -
-
- - -
- -
- -
-
Here is a list of all struct and union fields with links to the structures/unions they belong to:
- -

- a -

- - -

- b -

- - -

- c -

- - -

- d -

- - -

- e -

- - -

- f -

- - -

- g -

- - -

- i -

- - -

- j -

- - -

- m -

- - -

- o -

- - -

- p -

- - -

- q -

- - -

- r -

- - -

- t -

- - -

- v -

- - -

- x -

- - -

- y -

-
-
- - - - diff --git a/xess/doc/doxygen/functions_vars.html b/xess/doc/doxygen/functions_vars.html deleted file mode 100644 index fb763a9..0000000 --- a/xess/doc/doxygen/functions_vars.html +++ /dev/null @@ -1,224 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: Data Fields - Variables - - - - - - - - - - - - - -
-
- - - - - - - -
-
XeSS SDK API Reference Guide 1.0.0 -
-
-
- - - - - - - -
-
- -
-
-
- -
- -
-
- - -
- -
- -
-  - -

- a -

- - -

- b -

- - -

- c -

- - -

- d -

- - -

- e -

- - -

- f -

- - -

- g -

- - -

- i -

- - -

- j -

- - -

- m -

- - -

- o -

- - -

- p -

- - -

- q -

- - -

- r -

- - -

- t -

- - -

- v -

- - -

- x -

- - -

- y -

-
-
- - - - diff --git a/xess/doc/doxygen/globals.html b/xess/doc/doxygen/globals.html deleted file mode 100644 index a30e875..0000000 --- a/xess/doc/doxygen/globals.html +++ /dev/null @@ -1,198 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: Globals - - - - - - - - - - - - - -
-
- - - - - - - -
-
XeSS SDK API Reference Guide 1.0.0 -
-
-
- - - - - - - -
-
- -
-
-
- -
- -
-
- - -
- -
- -
-
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:
- -

- _ -

- - -

- s -

- - -

- x -

-
-
- - - - diff --git a/xess/doc/doxygen/globals_defs.html b/xess/doc/doxygen/globals_defs.html deleted file mode 100644 index e73c923..0000000 --- a/xess/doc/doxygen/globals_defs.html +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: Globals - - - - - - - - - - - - - -
-
- - - - - - - -
-
XeSS SDK API Reference Guide 1.0.0 -
-
-
- - - - - - - -
-
- -
-
-
- -
- -
-
- - -
- -
- -
-
-
- - - - diff --git a/xess/doc/doxygen/globals_enum.html b/xess/doc/doxygen/globals_enum.html deleted file mode 100644 index 62541f0..0000000 --- a/xess/doc/doxygen/globals_enum.html +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: Globals - - - - - - - - - - - - - -
-
- - - - - - - -
-
XeSS SDK API Reference Guide 1.0.0 -
-
-
- - - - - - - -
-
- -
-
-
- -
- -
-
- - -
- -
- -
-
-
- - - - diff --git a/xess/doc/doxygen/globals_eval.html b/xess/doc/doxygen/globals_eval.html deleted file mode 100644 index 2f8a45a..0000000 --- a/xess/doc/doxygen/globals_eval.html +++ /dev/null @@ -1,142 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: Globals - - - - - - - - - - - - - -
-
- - - - - - - -
-
XeSS SDK API Reference Guide 1.0.0 -
-
-
- - - - - - - -
-
- -
-
-
- -
- -
-
- - -
- -
- -
-  - -

- x -

    -
  • XESS_DUMP_ALL : xess_debug.h
  • -
  • XESS_DUMP_ALL_INPUTS : xess_debug.h
  • -
  • XESS_DUMP_EXECUTION_PARAMETERS : xess_debug.h
  • -
  • XESS_DUMP_HISTORY : xess_debug.h
  • -
  • XESS_DUMP_INPUT_COLOR : xess_debug.h
  • -
  • XESS_DUMP_INPUT_DEPTH : xess_debug.h
  • -
  • XESS_DUMP_INPUT_EXPOSURE_SCALE : xess_debug.h
  • -
  • XESS_DUMP_INPUT_RESPONSIVE_PIXEL_MASK : xess_debug.h
  • -
  • XESS_DUMP_INPUT_VELOCITY : xess_debug.h
  • -
  • XESS_DUMP_OUTPUT : xess_debug.h
  • -
  • XESS_INIT_FLAG_EXPOSURE_SCALE_TEXTURE : xess.h
  • -
  • XESS_INIT_FLAG_EXTERNAL_DESCRIPTOR_HEAP : xess.h
  • -
  • XESS_INIT_FLAG_HIGH_RES_MV : xess.h
  • -
  • XESS_INIT_FLAG_INVERTED_DEPTH : xess.h
  • -
  • XESS_INIT_FLAG_JITTERED_MV : xess.h
  • -
  • XESS_INIT_FLAG_LDR_INPUT_COLOR : xess.h
  • -
  • XESS_INIT_FLAG_NONE : xess.h
  • -
  • XESS_INIT_FLAG_RESPONSIVE_PIXEL_MASK : xess.h
  • -
  • XESS_INIT_FLAG_USE_NDC_VELOCITY : xess.h
  • -
  • XESS_LOGGING_LEVEL_DEBUG : xess.h
  • -
  • XESS_LOGGING_LEVEL_ERROR : xess.h
  • -
  • XESS_LOGGING_LEVEL_INFO : xess.h
  • -
  • XESS_LOGGING_LEVEL_WARNING : xess.h
  • -
  • XESS_NETWORK_MODEL_KPSS : xess_debug.h
  • -
  • XESS_NETWORK_MODEL_SPLAT : xess_debug.h
  • -
  • XESS_QUALITY_SETTING_BALANCED : xess.h
  • -
  • XESS_QUALITY_SETTING_PERFORMANCE : xess.h
  • -
  • XESS_QUALITY_SETTING_QUALITY : xess.h
  • -
  • XESS_QUALITY_SETTING_ULTRA_QUALITY : xess.h
  • -
  • XESS_RESULT_ERROR_CANT_LOAD_LIBRARY : xess.h
  • -
  • XESS_RESULT_ERROR_DEVICE : xess.h
  • -
  • XESS_RESULT_ERROR_DEVICE_OUT_OF_MEMORY : xess.h
  • -
  • XESS_RESULT_ERROR_INVALID_ARGUMENT : xess.h
  • -
  • XESS_RESULT_ERROR_INVALID_CONTEXT : xess.h
  • -
  • XESS_RESULT_ERROR_NOT_IMPLEMENTED : xess.h
  • -
  • XESS_RESULT_ERROR_OPERATION_IN_PROGRESS : xess.h
  • -
  • XESS_RESULT_ERROR_UNINITIALIZED : xess.h
  • -
  • XESS_RESULT_ERROR_UNKNOWN : xess.h
  • -
  • XESS_RESULT_ERROR_UNSUPPORTED : xess.h
  • -
  • XESS_RESULT_ERROR_UNSUPPORTED_DEVICE : xess.h
  • -
  • XESS_RESULT_ERROR_UNSUPPORTED_DRIVER : xess.h
  • -
  • XESS_RESULT_SUCCESS : xess.h
  • -
  • XESS_RESULT_WARNING_NONEXISTING_FOLDER : xess.h
  • -
-
-
- - - - diff --git a/xess/doc/doxygen/globals_func.html b/xess/doc/doxygen/globals_func.html deleted file mode 100644 index 326a619..0000000 --- a/xess/doc/doxygen/globals_func.html +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: Globals - - - - - - - - - - - - - -
-
- - - - - - - -
-
XeSS SDK API Reference Guide 1.0.0 -
-
-
- - - - - - - -
-
- -
-
-
- -
- -
-
- - -
- -
- -
-
-
- - - - diff --git a/xess/doc/doxygen/globals_type.html b/xess/doc/doxygen/globals_type.html deleted file mode 100644 index 9ed6096..0000000 --- a/xess/doc/doxygen/globals_type.html +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: Globals - - - - - - - - - - - - - -
-
- - - - - - - -
-
XeSS SDK API Reference Guide 1.0.0 -
-
-
- - - - - - - -
-
- -
-
-
- -
- -
-
- - -
- -
- -
-
-
- - - - diff --git a/xess/doc/doxygen/group__xess-d3d12-debug.html b/xess/doc/doxygen/group__xess-d3d12-debug.html deleted file mode 100644 index 408a3db..0000000 --- a/xess/doc/doxygen/group__xess-d3d12-debug.html +++ /dev/null @@ -1,188 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: XeSS D3D12 API debug exports - - - - - - - - - - - - - -
-
- - - - - - - -
-
XeSS SDK API Reference Guide 1.0.0 -
-
-
- - - - - - - -
-
- -
-
-
- -
- -
-
- - -
- -
- -
- -
XeSS D3D12 API debug exports
-
-
- - - - - - - - -

-Functions

XESS_API xess_result_t xessD3D12GetResourcesToDump (xess_context_handle_t hContext, xess_resources_to_dump_t **pResourcesToDump)
 Query XeSS model to retrieve internal resources marked for dumping for further debug and inspection. More...
 
XESS_API xess_result_t xessD3D12GetProfilingData (xess_context_handle_t hContext, xess_profiling_data_t **pProfilingData)
 Query XeSS model performance data for past executions. To enable performance collection, context must be initialized with XESS_D3D12_DEBUG_ENABLE_PROFILING flag added to xess_d3d12_init_params_t::initFlags. If profiling is enabled, user must poll for profiling data after executing one or more command lists, otherwise implementation will keep growing internal CPU buffers to accomodate all profiling data available. Due to async nature of execution on GPU, data may not be available after submitting command lists to device queue. It is advised to check any_profiling_data_in_flight flag in case all workloads has been submitted, but profiling data for some frames is still not available. Data pointed to by pProfilingData item(s) belongs to context instance and is valid until next call to xessD3D12GetProfilingData for owning context. More...
 
-

Detailed Description

-

Function Documentation

- -

◆ xessD3D12GetProfilingData()

- -
-
- - - - - - - - - - - - - - - - - - -
XESS_API xess_result_t xessD3D12GetProfilingData (xess_context_handle_t hContext,
xess_profiling_data_t ** pProfilingData 
)
-
- -

Query XeSS model performance data for past executions. To enable performance collection, context must be initialized with XESS_D3D12_DEBUG_ENABLE_PROFILING flag added to xess_d3d12_init_params_t::initFlags. If profiling is enabled, user must poll for profiling data after executing one or more command lists, otherwise implementation will keep growing internal CPU buffers to accomodate all profiling data available. Due to async nature of execution on GPU, data may not be available after submitting command lists to device queue. It is advised to check any_profiling_data_in_flight flag in case all workloads has been submitted, but profiling data for some frames is still not available. Data pointed to by pProfilingData item(s) belongs to context instance and is valid until next call to xessD3D12GetProfilingData for owning context.

-
Parameters
- - - -
hContextThe XeSS context handle.
pProfilingDatapointer to profiling data structure to be filled by implementation.
-
-
-
Returns
XeSS return status code.
- -
-
- -

◆ xessD3D12GetResourcesToDump()

- -
-
- - - - - - - - - - - - - - - - - - -
XESS_API xess_result_t xessD3D12GetResourcesToDump (xess_context_handle_t hContext,
xess_resources_to_dump_t ** pResourcesToDump 
)
-
- -

Query XeSS model to retrieve internal resources marked for dumping for further debug and inspection.

-
Parameters
- - - -
hContextThe XeSS context handle.
pResourcesToDumpPointer to user-provided pointer to structure to be filled with debug resource array, their names and recommended dumping parameters. pResourcesToDump must not be null, In case of failure (xess_result_t is not equal to XESS_RESULT_SUCCESS) **pResourcesToDump contents is undefined and must not be used. In case of success, *pResourcesToDump may still be null, if no internal resources were added to dumping queue. Build configuration for certain implementations may have dumping functionality compiled-out and XESS_RESULT_ERROR_NOT_IMPLEMENTED return code.
-
-
-
Returns
XeSS return status code.
- -
-
-
-
- - - - diff --git a/xess/doc/doxygen/group__xess-d3d12-debug.js b/xess/doc/doxygen/group__xess-d3d12-debug.js deleted file mode 100644 index 31cebc8..0000000 --- a/xess/doc/doxygen/group__xess-d3d12-debug.js +++ /dev/null @@ -1,5 +0,0 @@ -var group__xess_d3d12_debug = -[ - [ "xessD3D12GetProfilingData", "group__xess-d3d12-debug.html#ga3a8e8bee0b8ba06871c765648202c938", null ], - [ "xessD3D12GetResourcesToDump", "group__xess-d3d12-debug.html#gaf62cb7b5e756de611a19896a5248c92b", null ] -]; \ No newline at end of file diff --git a/xess/doc/doxygen/group__xess-d3d12.html b/xess/doc/doxygen/group__xess-d3d12.html deleted file mode 100644 index 8acdd74..0000000 --- a/xess/doc/doxygen/group__xess-d3d12.html +++ /dev/null @@ -1,291 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: XeSS D3D12 API exports - - - - - - - - - - - - - -
-
- - - - - - - -
-
XeSS SDK API Reference Guide 1.0.0 -
-
-
- - - - - - - -
-
- -
-
-
- -
- -
-
- - -
- -
- -
- -
XeSS D3D12 API exports
-
-
- - - - - - - - - - - - - - -

-Functions

XESS_API xess_result_t xessD3D12CreateContext (ID3D12Device *pDevice, xess_context_handle_t *phContext)
 Create an XeSS D3D12 context. More...
 
XESS_API xess_result_t xessD3D12BuildPipelines (xess_context_handle_t hContext, ID3D12PipelineLibrary *pPipelineLibrary, bool blocking, uint32_t initFlags)
 Initiates pipeline build process This function can only be called between xessD3D12CreateContext and xessD3D12Init This call initiates build of DX12 pipelines and kernel compilation This call can be blocking (if blocking set to true) or non-blocking. In case of non-blocking call library will wait for pipeline build on call to xessD3D12Init If pPipelineLibrary passed to this call - same pipeline library must be passed to xessD3D12Init. More...
 
XESS_API xess_result_t xessD3D12Init (xess_context_handle_t hContext, const xess_d3d12_init_params_t *pInitParams)
 Initialize XeSS D3D12. This is a blocking call that initializes XeSS and triggers internal resources allocation and JIT for the XeSS kernels. The user must ensure that any pending command lists are completed before re-initialization. When During initialization, XeSS can create staging buffers and copy queues to upload internal data. These will be destroyed at the end of initialization. More...
 
XESS_API xess_result_t xessD3D12Execute (xess_context_handle_t hContext, ID3D12GraphicsCommandList *pCommandList, const xess_d3d12_execute_params_t *pExecParams)
 Record XeSS upscaling commands into the command list. More...
 
-

Detailed Description

-

Function Documentation

- -

◆ xessD3D12BuildPipelines()

- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XESS_API xess_result_t xessD3D12BuildPipelines (xess_context_handle_t hContext,
ID3D12PipelineLibrary * pPipelineLibrary,
bool blocking,
uint32_t initFlags 
)
-
- -

Initiates pipeline build process This function can only be called between xessD3D12CreateContext and xessD3D12Init This call initiates build of DX12 pipelines and kernel compilation This call can be blocking (if blocking set to true) or non-blocking. In case of non-blocking call library will wait for pipeline build on call to xessD3D12Init If pPipelineLibrary passed to this call - same pipeline library must be passed to xessD3D12Init.

-
Parameters
- - - - - -
hContextThe XeSS context handle.
pPipelineLibraryOptional pointer to pipeline library for pipeline caching.
blockingWait for kernel compilation and pipeline creation to finish or not
init_flagsInitialization flags. Must be identical to flags passed to xessD3D12Init
-
-
- -
-
- -

◆ xessD3D12CreateContext()

- -
-
- - - - - - - - - - - - - - - - - - -
XESS_API xess_result_t xessD3D12CreateContext (ID3D12Device * pDevice,
xess_context_handle_tphContext 
)
-
- -

Create an XeSS D3D12 context.

-
Parameters
- - - -
pDeviceA D3D12 device created by the user.
[out]phContextReturned xess context handle.
-
-
-
Returns
XeSS return status code.
- -
-
- -

◆ xessD3D12Execute()

- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
XESS_API xess_result_t xessD3D12Execute (xess_context_handle_t hContext,
ID3D12GraphicsCommandList * pCommandList,
const xess_d3d12_execute_params_tpExecParams 
)
-
- -

Record XeSS upscaling commands into the command list.

-
Parameters
- - - - -
hContextThe XeSS context handle.
pCommandListThe command list for XeSS commands.
pExecParamsExecution parameters.
-
-
-
Returns
XeSS return status code.
- -
-
- -

◆ xessD3D12Init()

- -
-
- - - - - - - - - - - - - - - - - - -
XESS_API xess_result_t xessD3D12Init (xess_context_handle_t hContext,
const xess_d3d12_init_params_tpInitParams 
)
-
- -

Initialize XeSS D3D12. This is a blocking call that initializes XeSS and triggers internal resources allocation and JIT for the XeSS kernels. The user must ensure that any pending command lists are completed before re-initialization. When During initialization, XeSS can create staging buffers and copy queues to upload internal data. These will be destroyed at the end of initialization.

-
Note
XeSS supports devices starting from D3D12_RESOURCE_HEAP_TIER_1, which means that buffers and textures can not live in the same resource heap.
-
Parameters
- - - -
hContextThe XeSS context handle.
pInitParamsInitialization parameters.
-
-
-
Returns
XeSS return status code.
- -
-
-
-
- - - - diff --git a/xess/doc/doxygen/group__xess-d3d12.js b/xess/doc/doxygen/group__xess-d3d12.js deleted file mode 100644 index 301ba75..0000000 --- a/xess/doc/doxygen/group__xess-d3d12.js +++ /dev/null @@ -1,7 +0,0 @@ -var group__xess_d3d12 = -[ - [ "xessD3D12BuildPipelines", "group__xess-d3d12.html#gac39e8fcd2d1575ab36e54aacbc3d3b6a", null ], - [ "xessD3D12CreateContext", "group__xess-d3d12.html#ga6b15c60fbdeefc17a1064950c90d2e2d", null ], - [ "xessD3D12Execute", "group__xess-d3d12.html#gaf8e15aa3a0915546fdfcaa899f58c102", null ], - [ "xessD3D12Init", "group__xess-d3d12.html#gafb211935ba10efefc5a7063b276fce31", null ] -]; \ No newline at end of file diff --git a/xess/doc/doxygen/group__xess-debug.html b/xess/doc/doxygen/group__xess-debug.html deleted file mode 100644 index 571eb02..0000000 --- a/xess/doc/doxygen/group__xess-debug.html +++ /dev/null @@ -1,180 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: XeSS API debug exports - - - - - - - - - - - - - -
-
- - - - - - - -
-
XeSS SDK API Reference Guide 1.0.0 -
-
-
- - - - - - - -
-
- -
-
-
- -
- -
-
- - -
- -
- -
- -
XeSS API debug exports
-
-
- - - - - - - -

-Functions

XESS_API xess_result_t xessSelectNetworkModel (xess_context_handle_t hContext, xess_network_model_t network)
 Select network to be used by XeSS. More...
 
XESS_API xess_result_t xessStartDump (xess_context_handle_t hContext, const xess_dump_parameters_t *dump_parameters)
 
-

Detailed Description

-

Function Documentation

- -

◆ xessSelectNetworkModel()

- -
-
- - - - - - - - - - - - - - - - - - -
XESS_API xess_result_t xessSelectNetworkModel (xess_context_handle_t hContext,
xess_network_model_t network 
)
-
- -

Select network to be used by XeSS.

-

Selects network model to use by XeSS. After call to this function - XeSS init function must be called

- -
-
- -

◆ xessStartDump()

- -
-
- - - - - - - - - - - - - - - - - - -
XESS_API xess_result_t xessStartDump (xess_context_handle_t hContext,
const xess_dump_parameters_tdump_parameters 
)
-
-

Dumps sequence of frames to the provided folder

-

Call to this function initiates a dump for selected elements. XeSS SDK uses RAM cache to reduce dump overhead. Application should provide reasonable value for xess_dump_parameters_t::frame_count frames (about 50 megs needed per cached frame). To enable several dumps per run application should provide correct xess_dump_parameters_t::frame_idx value. This value used as a start index for frame dumping. After call to this function - each call to xessD3D12Execute will result in new frame dumped to RAM cache. After xess_dump_parameters_t::frame_count frames application will be blocked on call to xessD3D12Execute in order to save cached frames to disk. This operation can take long time. Repetetive calls to this function can result in XESS_RESULT_ERROR_OPERATION_IN_PROGRESS which means that frame dump is in progress.

-
Parameters
- - - -
hContextXeSS context
dump_parametersdump configuration
-
-
-
Returns
operation status
- -
-
-
-
- - - - diff --git a/xess/doc/doxygen/group__xess-debug.js b/xess/doc/doxygen/group__xess-debug.js deleted file mode 100644 index e5d94d3..0000000 --- a/xess/doc/doxygen/group__xess-debug.js +++ /dev/null @@ -1,5 +0,0 @@ -var group__xess_debug = -[ - [ "xessSelectNetworkModel", "group__xess-debug.html#ga596f2374ff85d63d430d885da295818b", null ], - [ "xessStartDump", "group__xess-debug.html#gaa320ed0d9c03d6abb26f37647b12db7e", null ] -]; \ No newline at end of file diff --git a/xess/doc/doxygen/group__xess.html b/xess/doc/doxygen/group__xess.html deleted file mode 100644 index 42f492e..0000000 --- a/xess/doc/doxygen/group__xess.html +++ /dev/null @@ -1,446 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: XeSS API exports - - - - - - - - - - - - - -
-
- - - - - - - -
-
XeSS SDK API Reference Guide 1.0.0 -
-
-
- - - - - - - -
-
- -
-
-
- -
- -
-
- - -
- -
- -
- -
XeSS API exports
-
-
- - - - - - - - - - - - - - - - - - - - - - - -

-Functions

XESS_API xess_result_t xessGetVersion (xess_version_t *pVersion)
 Gets the XeSS version. This is baked into the XeSS SDK release. More...
 
XESS_API xess_result_t xessGetIntelXeFXVersion (xess_context_handle_t hContext, xess_version_t *pVersion)
 Gets the version of the loaded Intel XeFX library. When running on Intel platforms this function will return the version of the loaded Intel XeFX library, for other platforms 0.0.0 will be returned. More...
 
XESS_API xess_result_t xessGetProperties (xess_context_handle_t hContext, const xess_2d_t *pOutputResolution, xess_properties_t *pBindingProperties)
 Gets XeSS internal resources properties. More...
 
XESS_API xess_result_t xessGetInputResolution (xess_context_handle_t hContext, const xess_2d_t *pOutputResolution, xess_quality_settings_t qualitySettings, xess_2d_t *pInputResolution)
 Get the input resolution for a specified output resolution for a given quality setting. XeSS expects all the input buffers except motion vectors to be in the returned resolution. Motion vectors can be either in output resolution (XESS_INIT_FLAG_HIGH_RES_MV) or returned resolution (default). More...
 
XESS_API xess_result_t xessDestroyContext (xess_context_handle_t hContext)
 Destroys the XeSS context. The user must ensure that any pending command lists are completed before destroying the context. More...
 
XESS_API xess_result_t xessSetJitterScale (xess_context_handle_t hContext, float x, float y)
 
XESS_API xess_result_t xessSetVelocityScale (xess_context_handle_t hContext, float x, float y)
 
XESS_API xess_result_t xessSetLoggingCallback (xess_context_handle_t hContext, xess_logging_level_t loggingLevel, xess_app_log_callback_t loggingCallback)
 
-

Detailed Description

-

Function Documentation

- -

◆ xessDestroyContext()

- -
-
- - - - - - - - -
XESS_API xess_result_t xessDestroyContext (xess_context_handle_t hContext)
-
- -

Destroys the XeSS context. The user must ensure that any pending command lists are completed before destroying the context.

-
Parameters
- - -
hContextThe XeSS context handle.
-
-
-
Returns
XeSS return status code.
- -
-
- -

◆ xessGetInputResolution()

- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
XESS_API xess_result_t xessGetInputResolution (xess_context_handle_t hContext,
const xess_2d_tpOutputResolution,
xess_quality_settings_t qualitySettings,
xess_2d_tpInputResolution 
)
-
- -

Get the input resolution for a specified output resolution for a given quality setting. XeSS expects all the input buffers except motion vectors to be in the returned resolution. Motion vectors can be either in output resolution (XESS_INIT_FLAG_HIGH_RES_MV) or returned resolution (default).

-
Parameters
- - - - - -
hContextThe XeSS context handle.
pOutputResolutionOutput resolution to calculate input resolution for.
qualitySettingsDesired quality setting.
[out]pInputResolutionRequired input resolution.
-
-
-
Returns
XeSS return status code.
- -
-
- -

◆ xessGetIntelXeFXVersion()

- -
-
- - - - - - - - - - - - - - - - - - -
XESS_API xess_result_t xessGetIntelXeFXVersion (xess_context_handle_t hContext,
xess_version_tpVersion 
)
-
- -

Gets the version of the loaded Intel XeFX library. When running on Intel platforms this function will return the version of the loaded Intel XeFX library, for other platforms 0.0.0 will be returned.

-
Parameters
- - - -
hContextThe XeSS context handle.
[out]pVersionReturned Intel XeFX library version.
-
-
-
Returns
XeSS return status code.
- -
-
- -

◆ xessGetProperties()

- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
XESS_API xess_result_t xessGetProperties (xess_context_handle_t hContext,
const xess_2d_tpOutputResolution,
xess_properties_tpBindingProperties 
)
-
- -

Gets XeSS internal resources properties.

-
Parameters
- - - - -
hContextThe XeSS context handle.
pOutputResolutionOutput resolution to calculate properties for.
[out]pBindingPropetiesRetured properties.
-
-
-
Returns
XeSS return status code.
- -
-
- -

◆ xessGetVersion()

- -
-
- - - - - - - - -
XESS_API xess_result_t xessGetVersion (xess_version_tpVersion)
-
- -

Gets the XeSS version. This is baked into the XeSS SDK release.

-
Parameters
- - -
[out]pVersionReturned XeSS version.
-
-
-
Returns
XeSS return status code.
- -
-
- -

◆ xessSetJitterScale()

- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
XESS_API xess_result_t xessSetJitterScale (xess_context_handle_t hContext,
float x,
float y 
)
-
-

Sets jitter scale value

Parameters
- - - - -
hContextThe XeSS context handle.
xscale for the X axis
yscale for the Y axis
-
-
-
Returns
XeSS return status code.
- -
-
- -

◆ xessSetLoggingCallback()

- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
XESS_API xess_result_t xessSetLoggingCallback (xess_context_handle_t hContext,
xess_logging_level_t loggingLevel,
xess_app_log_callback_t loggingCallback 
)
-
-

Sets logging callback

-
Parameters
- - - - -
hContextThe XeSS context handle.
loggingLevelMinimum logging level for logging callback.
loggingCallbackLogging callback
-
-
-
Returns
XeSS return status code.
- -
-
- -

◆ xessSetVelocityScale()

- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
XESS_API xess_result_t xessSetVelocityScale (xess_context_handle_t hContext,
float x,
float y 
)
-
-

Sets velocity scale value

Parameters
- - - - -
hContextThe XeSS context handle.
xscale for the X axis
yscale for the Y axis
-
-
-
Returns
XeSS return status code.
- -
-
-
-
- - - - diff --git a/xess/doc/doxygen/group__xess.js b/xess/doc/doxygen/group__xess.js deleted file mode 100644 index 6ad4912..0000000 --- a/xess/doc/doxygen/group__xess.js +++ /dev/null @@ -1,11 +0,0 @@ -var group__xess = -[ - [ "xessDestroyContext", "group__xess.html#gae5d88d9bdb50033ab254aa2e692c9bc0", null ], - [ "xessGetInputResolution", "group__xess.html#ga6ed6ab924e0a41ff56485b562acd5073", null ], - [ "xessGetIntelXeFXVersion", "group__xess.html#ga88ea52641806d14ef5a4995b5d78ea91", null ], - [ "xessGetProperties", "group__xess.html#gaae4893a4bfed059402ca55f256738773", null ], - [ "xessGetVersion", "group__xess.html#ga0fc6e0c7b21322a0af96f1ee1e4667d3", null ], - [ "xessSetJitterScale", "group__xess.html#ga30e9bee98f90568e6a9d39bd7d1ccd74", null ], - [ "xessSetLoggingCallback", "group__xess.html#gaaf68a347af5e5c9c1e518f0bc5daaf1c", null ], - [ "xessSetVelocityScale", "group__xess.html#ga0f95b12fe2611b877d72efdd9f050639", null ] -]; \ No newline at end of file diff --git a/xess/doc/doxygen/index.html b/xess/doc/doxygen/index.html deleted file mode 100644 index ff9b62a..0000000 --- a/xess/doc/doxygen/index.html +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: XeSS SDK - - - - - - - - - - - - - -
-
- - - - - - - -
-
XeSS SDK API Reference Guide 1.0.0 -
-
-
- - - - - - - -
-
- -
-
-
- -
- -
-
- - -
- -
- -
-
XeSS SDK
-
-
-

Intel(R) Xe Super Sampling (XeSS) enables an innovative framerate boosting technology supported by Intel(R) Arc(TM) graphics cards and other GPU vendors. Using AI deep-learning to perform upscaling, XeSS offers higher framerates without degrading the image.

-

Please see the Developer Guide in the /doc folder for getting started information.

-

-Package contents

- - - - - - - - - - - - - - - - - - - -
Folder / file Description
README.md This readme file
ChangeLog List of changes
bin DLLs, executables, configurations and kernels required to run
inc Required header files
lib Static libraries
doc Documentation
licenses Licenses for the SDK itself and its components
samples Sample code
-
-
-
- - - - diff --git a/xess/doc/doxygen/intel-logo.jpg b/xess/doc/doxygen/intel-logo.jpg deleted file mode 100644 index 3b83143..0000000 Binary files a/xess/doc/doxygen/intel-logo.jpg and /dev/null differ diff --git a/xess/doc/doxygen/jquery.js b/xess/doc/doxygen/jquery.js deleted file mode 100644 index c9ed3d9..0000000 --- a/xess/doc/doxygen/jquery.js +++ /dev/null @@ -1,35 +0,0 @@ -/*! jQuery v3.6.0 | (c) OpenJS Foundation and other contributors | jquery.org/license */ -!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],r=Object.getPrototypeOf,s=t.slice,g=t.flat?function(e){return t.flat.call(e)}:function(e){return t.concat.apply([],e)},u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType&&"function"!=typeof e.item},x=function(e){return null!=e&&e===e.window},E=C.document,c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.6.0",S=function(e,t){return new S.fn.init(e,t)};function p(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp(F),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+F),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/HTML$/i,Q=/^(?:input|select|textarea|button)$/i,J=/^h\d$/i,K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\[\\da-fA-F]{1,6}"+M+"?|\\\\([^\\r\\n\\f])","g"),ne=function(e,t){var n="0x"+e.slice(1)-65536;return t||(n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320))},re=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){T()},ae=be(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{H.apply(t=O.call(p.childNodes),p.childNodes),t[p.childNodes.length].nodeType}catch(e){H={apply:t.length?function(e,t){L.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function se(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&(T(e),e=e||C,E)){if(11!==p&&(u=Z.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(f&&(a=f.getElementById(i))&&y(e,a)&&a.id===i)return n.push(a),n}else{if(u[2])return H.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&d.getElementsByClassName&&e.getElementsByClassName)return H.apply(n,e.getElementsByClassName(i)),n}if(d.qsa&&!N[t+" "]&&(!v||!v.test(t))&&(1!==p||"object"!==e.nodeName.toLowerCase())){if(c=t,f=e,1===p&&(U.test(t)||z.test(t))){(f=ee.test(t)&&ye(e.parentNode)||e)===e&&d.scope||((s=e.getAttribute("id"))?s=s.replace(re,ie):e.setAttribute("id",s=S)),o=(l=h(t)).length;while(o--)l[o]=(s?"#"+s:":scope")+" "+xe(l[o]);c=l.join(",")}try{return H.apply(n,f.querySelectorAll(c)),n}catch(e){N(t,!0)}finally{s===S&&e.removeAttribute("id")}}}return g(t.replace($,"$1"),e,n,r)}function ue(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function le(e){return e[S]=!0,e}function ce(e){var t=C.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function fe(e,t){var n=e.split("|"),r=n.length;while(r--)b.attrHandle[n[r]]=t}function pe(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function de(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function he(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function ge(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&ae(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ve(a){return le(function(o){return o=+o,le(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function ye(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}for(e in d=se.support={},i=se.isXML=function(e){var t=e&&e.namespaceURI,n=e&&(e.ownerDocument||e).documentElement;return!Y.test(t||n&&n.nodeName||"HTML")},T=se.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:p;return r!=C&&9===r.nodeType&&r.documentElement&&(a=(C=r).documentElement,E=!i(C),p!=C&&(n=C.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",oe,!1):n.attachEvent&&n.attachEvent("onunload",oe)),d.scope=ce(function(e){return a.appendChild(e).appendChild(C.createElement("div")),"undefined"!=typeof e.querySelectorAll&&!e.querySelectorAll(":scope fieldset div").length}),d.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),d.getElementsByTagName=ce(function(e){return e.appendChild(C.createComment("")),!e.getElementsByTagName("*").length}),d.getElementsByClassName=K.test(C.getElementsByClassName),d.getById=ce(function(e){return a.appendChild(e).id=S,!C.getElementsByName||!C.getElementsByName(S).length}),d.getById?(b.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(te,ne);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=d.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):d.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},b.find.CLASS=d.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&E)return t.getElementsByClassName(e)},s=[],v=[],(d.qsa=K.test(C.querySelectorAll))&&(ce(function(e){var t;a.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&v.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||v.push("\\["+M+"*(?:value|"+R+")"),e.querySelectorAll("[id~="+S+"-]").length||v.push("~="),(t=C.createElement("input")).setAttribute("name",""),e.appendChild(t),e.querySelectorAll("[name='']").length||v.push("\\["+M+"*name"+M+"*="+M+"*(?:''|\"\")"),e.querySelectorAll(":checked").length||v.push(":checked"),e.querySelectorAll("a#"+S+"+*").length||v.push(".#.+[+~]"),e.querySelectorAll("\\\f"),v.push("[\\r\\n\\f]")}),ce(function(e){e.innerHTML="";var t=C.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&v.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&v.push(":enabled",":disabled"),a.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&v.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),v.push(",.*:")})),(d.matchesSelector=K.test(c=a.matches||a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.msMatchesSelector))&&ce(function(e){d.disconnectedMatch=c.call(e,"*"),c.call(e,"[s!='']:x"),s.push("!=",F)}),v=v.length&&new RegExp(v.join("|")),s=s.length&&new RegExp(s.join("|")),t=K.test(a.compareDocumentPosition),y=t||K.test(a.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},j=t?function(e,t){if(e===t)return l=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!d.sortDetached&&t.compareDocumentPosition(e)===n?e==C||e.ownerDocument==p&&y(p,e)?-1:t==C||t.ownerDocument==p&&y(p,t)?1:u?P(u,e)-P(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return l=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e==C?-1:t==C?1:i?-1:o?1:u?P(u,e)-P(u,t):0;if(i===o)return pe(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?pe(a[r],s[r]):a[r]==p?-1:s[r]==p?1:0}),C},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if(T(e),d.matchesSelector&&E&&!N[t+" "]&&(!s||!s.test(t))&&(!v||!v.test(t)))try{var n=c.call(e,t);if(n||d.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){N(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=h(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ne).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=m[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&m(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=se.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,n,r){return m(n)?S.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?S.grep(e,function(e){return e===n!==r}):"string"!=typeof n?S.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/;(S.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||D,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:q.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof S?t[0]:t,S.merge(this,S.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:E,!0)),N.test(r[1])&&S.isPlainObject(t))for(r in t)m(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=E.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):m(e)?void 0!==n.ready?n.ready(e):e(S):S.makeArray(e,this)}).prototype=S.fn,D=S(E);var L=/^(?:parents|prev(?:Until|All))/,H={children:!0,contents:!0,next:!0,prev:!0};function O(e,t){while((e=e[t])&&1!==e.nodeType);return e}S.fn.extend({has:function(e){var t=S(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,he=/^$|^module$|\/(?:java|ecma)script/i;ce=E.createDocumentFragment().appendChild(E.createElement("div")),(fe=E.createElement("input")).setAttribute("type","radio"),fe.setAttribute("checked","checked"),fe.setAttribute("name","t"),ce.appendChild(fe),y.checkClone=ce.cloneNode(!0).cloneNode(!0).lastChild.checked,ce.innerHTML="",y.noCloneChecked=!!ce.cloneNode(!0).lastChild.defaultValue,ce.innerHTML="",y.option=!!ce.lastChild;var ge={thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function ve(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?S.merge([e],n):n}function ye(e,t){for(var n=0,r=e.length;n",""]);var me=/<|&#?\w+;/;function xe(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),p=[],d=0,h=e.length;d\s*$/g;function je(e,t){return A(e,"table")&&A(11!==t.nodeType?t:t.firstChild,"tr")&&S(e).children("tbody")[0]||e}function De(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function qe(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Le(e,t){var n,r,i,o,a,s;if(1===t.nodeType){if(Y.hasData(e)&&(s=Y.get(e).events))for(i in Y.remove(t,"handle events"),s)for(n=0,r=s[i].length;n").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",i=function(e){r.remove(),i=null,e&&t("error"===e.type?404:200,e.type)}),E.head.appendChild(r[0])},abort:function(){i&&i()}}});var _t,zt=[],Ut=/(=)\?(?=&|$)|\?\?/;S.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=zt.pop()||S.expando+"_"+wt.guid++;return this[e]=!0,e}}),S.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Ut.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Ut.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=m(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Ut,"$1"+r):!1!==e.jsonp&&(e.url+=(Tt.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||S.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=C[r],C[r]=function(){o=arguments},n.always(function(){void 0===i?S(C).removeProp(r):C[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,zt.push(r)),o&&m(i)&&i(o[0]),o=i=void 0}),"script"}),y.createHTMLDocument=((_t=E.implementation.createHTMLDocument("").body).innerHTML="
",2===_t.childNodes.length),S.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(y.createHTMLDocument?((r=(t=E.implementation.createHTMLDocument("")).createElement("base")).href=E.location.href,t.head.appendChild(r)):t=E),o=!n&&[],(i=N.exec(e))?[t.createElement(i[1])]:(i=xe([e],t,o),o&&o.length&&S(o).remove(),S.merge([],i.childNodes)));var r,i,o},S.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1").append(S.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},S.expr.pseudos.animated=function(t){return S.grep(S.timers,function(e){return t===e.elem}).length},S.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=S.css(e,"position"),c=S(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=S.css(e,"top"),u=S.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),m(t)&&(t=t.call(e,n,S.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},S.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){S.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===S.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===S.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=S(e).offset()).top+=S.css(e,"borderTopWidth",!0),i.left+=S.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-S.css(r,"marginTop",!0),left:t.left-i.left-S.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===S.css(e,"position"))e=e.offsetParent;return e||re})}}),S.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;S.fn[t]=function(e){return $(this,function(e,t,n){var r;if(x(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),S.each(["top","left"],function(e,n){S.cssHooks[n]=Fe(y.pixelPosition,function(e,t){if(t)return t=We(e,n),Pe.test(t)?S(e).position()[n]+"px":t})}),S.each({Height:"height",Width:"width"},function(a,s){S.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){S.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return $(this,function(e,t,n){var r;return x(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?S.css(e,t,i):S.style(e,t,n,i)},s,n?e:void 0,n)}})}),S.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){S.fn[t]=function(e){return this.on(t,e)}}),S.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),S.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){S.fn[n]=function(e,t){return 0a;a++)for(i in o[a])n=o[a][i],o[a].hasOwnProperty(i)&&void 0!==n&&(e[i]=t.isPlainObject(n)?t.isPlainObject(e[i])?t.widget.extend({},e[i],n):t.widget.extend({},n):n);return e},t.widget.bridge=function(e,i){var n=i.prototype.widgetFullName||e;t.fn[e]=function(o){var a="string"==typeof o,r=s.call(arguments,1),h=this;return a?this.length||"instance"!==o?this.each(function(){var i,s=t.data(this,n);return"instance"===o?(h=s,!1):s?t.isFunction(s[o])&&"_"!==o.charAt(0)?(i=s[o].apply(s,r),i!==s&&void 0!==i?(h=i&&i.jquery?h.pushStack(i.get()):i,!1):void 0):t.error("no such method '"+o+"' for "+e+" widget instance"):t.error("cannot call methods on "+e+" prior to initialization; "+"attempted to call method '"+o+"'")}):h=void 0:(r.length&&(o=t.widget.extend.apply(null,[o].concat(r))),this.each(function(){var e=t.data(this,n);e?(e.option(o||{}),e._init&&e._init()):t.data(this,n,new i(o,this))})),h}},t.Widget=function(){},t.Widget._childConstructors=[],t.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"
",options:{classes:{},disabled:!1,create:null},_createWidget:function(e,s){s=t(s||this.defaultElement||this)[0],this.element=t(s),this.uuid=i++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=t(),this.hoverable=t(),this.focusable=t(),this.classesElementLookup={},s!==this&&(t.data(s,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===s&&this.destroy()}}),this.document=t(s.style?s.ownerDocument:s.document||s),this.window=t(this.document[0].defaultView||this.document[0].parentWindow)),this.options=t.widget.extend({},this.options,this._getCreateOptions(),e),this._create(),this.options.disabled&&this._setOptionDisabled(this.options.disabled),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:function(){return{}},_getCreateEventData:t.noop,_create:t.noop,_init:t.noop,destroy:function(){var e=this;this._destroy(),t.each(this.classesElementLookup,function(t,i){e._removeClass(i,t)}),this.element.off(this.eventNamespace).removeData(this.widgetFullName),this.widget().off(this.eventNamespace).removeAttr("aria-disabled"),this.bindings.off(this.eventNamespace)},_destroy:t.noop,widget:function(){return this.element},option:function(e,i){var s,n,o,a=e;if(0===arguments.length)return t.widget.extend({},this.options);if("string"==typeof e)if(a={},s=e.split("."),e=s.shift(),s.length){for(n=a[e]=t.widget.extend({},this.options[e]),o=0;s.length-1>o;o++)n[s[o]]=n[s[o]]||{},n=n[s[o]];if(e=s.pop(),1===arguments.length)return void 0===n[e]?null:n[e];n[e]=i}else{if(1===arguments.length)return void 0===this.options[e]?null:this.options[e];a[e]=i}return this._setOptions(a),this},_setOptions:function(t){var e;for(e in t)this._setOption(e,t[e]);return this},_setOption:function(t,e){return"classes"===t&&this._setOptionClasses(e),this.options[t]=e,"disabled"===t&&this._setOptionDisabled(e),this},_setOptionClasses:function(e){var i,s,n;for(i in e)n=this.classesElementLookup[i],e[i]!==this.options.classes[i]&&n&&n.length&&(s=t(n.get()),this._removeClass(n,i),s.addClass(this._classes({element:s,keys:i,classes:e,add:!0})))},_setOptionDisabled:function(t){this._toggleClass(this.widget(),this.widgetFullName+"-disabled",null,!!t),t&&(this._removeClass(this.hoverable,null,"ui-state-hover"),this._removeClass(this.focusable,null,"ui-state-focus"))},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions({disabled:!0})},_classes:function(e){function i(i,o){var a,r;for(r=0;i.length>r;r++)a=n.classesElementLookup[i[r]]||t(),a=e.add?t(t.unique(a.get().concat(e.element.get()))):t(a.not(e.element).get()),n.classesElementLookup[i[r]]=a,s.push(i[r]),o&&e.classes[i[r]]&&s.push(e.classes[i[r]])}var s=[],n=this;return e=t.extend({element:this.element,classes:this.options.classes||{}},e),this._on(e.element,{remove:"_untrackClassesElement"}),e.keys&&i(e.keys.match(/\S+/g)||[],!0),e.extra&&i(e.extra.match(/\S+/g)||[]),s.join(" ")},_untrackClassesElement:function(e){var i=this;t.each(i.classesElementLookup,function(s,n){-1!==t.inArray(e.target,n)&&(i.classesElementLookup[s]=t(n.not(e.target).get()))})},_removeClass:function(t,e,i){return this._toggleClass(t,e,i,!1)},_addClass:function(t,e,i){return this._toggleClass(t,e,i,!0)},_toggleClass:function(t,e,i,s){s="boolean"==typeof s?s:i;var n="string"==typeof t||null===t,o={extra:n?e:i,keys:n?t:e,element:n?this.element:t,add:s};return o.element.toggleClass(this._classes(o),s),this},_on:function(e,i,s){var n,o=this;"boolean"!=typeof e&&(s=i,i=e,e=!1),s?(i=n=t(i),this.bindings=this.bindings.add(i)):(s=i,i=this.element,n=this.widget()),t.each(s,function(s,a){function r(){return e||o.options.disabled!==!0&&!t(this).hasClass("ui-state-disabled")?("string"==typeof a?o[a]:a).apply(o,arguments):void 0}"string"!=typeof a&&(r.guid=a.guid=a.guid||r.guid||t.guid++);var h=s.match(/^([\w:-]*)\s*(.*)$/),l=h[1]+o.eventNamespace,c=h[2];c?n.on(l,c,r):i.on(l,r)})},_off:function(e,i){i=(i||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,e.off(i).off(i),this.bindings=t(this.bindings.not(e).get()),this.focusable=t(this.focusable.not(e).get()),this.hoverable=t(this.hoverable.not(e).get())},_delay:function(t,e){function i(){return("string"==typeof t?s[t]:t).apply(s,arguments)}var s=this;return setTimeout(i,e||0)},_hoverable:function(e){this.hoverable=this.hoverable.add(e),this._on(e,{mouseenter:function(e){this._addClass(t(e.currentTarget),null,"ui-state-hover")},mouseleave:function(e){this._removeClass(t(e.currentTarget),null,"ui-state-hover")}})},_focusable:function(e){this.focusable=this.focusable.add(e),this._on(e,{focusin:function(e){this._addClass(t(e.currentTarget),null,"ui-state-focus")},focusout:function(e){this._removeClass(t(e.currentTarget),null,"ui-state-focus")}})},_trigger:function(e,i,s){var n,o,a=this.options[e];if(s=s||{},i=t.Event(i),i.type=(e===this.widgetEventPrefix?e:this.widgetEventPrefix+e).toLowerCase(),i.target=this.element[0],o=i.originalEvent)for(n in o)n in i||(i[n]=o[n]);return this.element.trigger(i,s),!(t.isFunction(a)&&a.apply(this.element[0],[i].concat(s))===!1||i.isDefaultPrevented())}},t.each({show:"fadeIn",hide:"fadeOut"},function(e,i){t.Widget.prototype["_"+e]=function(s,n,o){"string"==typeof n&&(n={effect:n});var a,r=n?n===!0||"number"==typeof n?i:n.effect||i:e;n=n||{},"number"==typeof n&&(n={duration:n}),a=!t.isEmptyObject(n),n.complete=o,n.delay&&s.delay(n.delay),a&&t.effects&&t.effects.effect[r]?s[e](n):r!==e&&s[r]?s[r](n.duration,n.easing,o):s.queue(function(i){t(this)[e](),o&&o.call(s[0]),i()})}}),t.widget,function(){function e(t,e,i){return[parseFloat(t[0])*(u.test(t[0])?e/100:1),parseFloat(t[1])*(u.test(t[1])?i/100:1)]}function i(e,i){return parseInt(t.css(e,i),10)||0}function s(e){var i=e[0];return 9===i.nodeType?{width:e.width(),height:e.height(),offset:{top:0,left:0}}:t.isWindow(i)?{width:e.width(),height:e.height(),offset:{top:e.scrollTop(),left:e.scrollLeft()}}:i.preventDefault?{width:0,height:0,offset:{top:i.pageY,left:i.pageX}}:{width:e.outerWidth(),height:e.outerHeight(),offset:e.offset()}}var n,o=Math.max,a=Math.abs,r=/left|center|right/,h=/top|center|bottom/,l=/[\+\-]\d+(\.[\d]+)?%?/,c=/^\w+/,u=/%$/,d=t.fn.position;t.position={scrollbarWidth:function(){if(void 0!==n)return n;var e,i,s=t("
"),o=s.children()[0];return t("body").append(s),e=o.offsetWidth,s.css("overflow","scroll"),i=o.offsetWidth,e===i&&(i=s[0].clientWidth),s.remove(),n=e-i},getScrollInfo:function(e){var i=e.isWindow||e.isDocument?"":e.element.css("overflow-x"),s=e.isWindow||e.isDocument?"":e.element.css("overflow-y"),n="scroll"===i||"auto"===i&&e.widthi?"left":e>0?"right":"center",vertical:0>r?"top":s>0?"bottom":"middle"};l>p&&p>a(e+i)&&(u.horizontal="center"),c>f&&f>a(s+r)&&(u.vertical="middle"),u.important=o(a(e),a(i))>o(a(s),a(r))?"horizontal":"vertical",n.using.call(this,t,u)}),h.offset(t.extend(D,{using:r}))})},t.ui.position={fit:{left:function(t,e){var i,s=e.within,n=s.isWindow?s.scrollLeft:s.offset.left,a=s.width,r=t.left-e.collisionPosition.marginLeft,h=n-r,l=r+e.collisionWidth-a-n;e.collisionWidth>a?h>0&&0>=l?(i=t.left+h+e.collisionWidth-a-n,t.left+=h-i):t.left=l>0&&0>=h?n:h>l?n+a-e.collisionWidth:n:h>0?t.left+=h:l>0?t.left-=l:t.left=o(t.left-r,t.left)},top:function(t,e){var i,s=e.within,n=s.isWindow?s.scrollTop:s.offset.top,a=e.within.height,r=t.top-e.collisionPosition.marginTop,h=n-r,l=r+e.collisionHeight-a-n;e.collisionHeight>a?h>0&&0>=l?(i=t.top+h+e.collisionHeight-a-n,t.top+=h-i):t.top=l>0&&0>=h?n:h>l?n+a-e.collisionHeight:n:h>0?t.top+=h:l>0?t.top-=l:t.top=o(t.top-r,t.top)}},flip:{left:function(t,e){var i,s,n=e.within,o=n.offset.left+n.scrollLeft,r=n.width,h=n.isWindow?n.scrollLeft:n.offset.left,l=t.left-e.collisionPosition.marginLeft,c=l-h,u=l+e.collisionWidth-r-h,d="left"===e.my[0]?-e.elemWidth:"right"===e.my[0]?e.elemWidth:0,p="left"===e.at[0]?e.targetWidth:"right"===e.at[0]?-e.targetWidth:0,f=-2*e.offset[0];0>c?(i=t.left+d+p+f+e.collisionWidth-r-o,(0>i||a(c)>i)&&(t.left+=d+p+f)):u>0&&(s=t.left-e.collisionPosition.marginLeft+d+p+f-h,(s>0||u>a(s))&&(t.left+=d+p+f))},top:function(t,e){var i,s,n=e.within,o=n.offset.top+n.scrollTop,r=n.height,h=n.isWindow?n.scrollTop:n.offset.top,l=t.top-e.collisionPosition.marginTop,c=l-h,u=l+e.collisionHeight-r-h,d="top"===e.my[1],p=d?-e.elemHeight:"bottom"===e.my[1]?e.elemHeight:0,f="top"===e.at[1]?e.targetHeight:"bottom"===e.at[1]?-e.targetHeight:0,m=-2*e.offset[1];0>c?(s=t.top+p+f+m+e.collisionHeight-r-o,(0>s||a(c)>s)&&(t.top+=p+f+m)):u>0&&(i=t.top-e.collisionPosition.marginTop+p+f+m-h,(i>0||u>a(i))&&(t.top+=p+f+m))}},flipfit:{left:function(){t.ui.position.flip.left.apply(this,arguments),t.ui.position.fit.left.apply(this,arguments)},top:function(){t.ui.position.flip.top.apply(this,arguments),t.ui.position.fit.top.apply(this,arguments)}}}}(),t.ui.position,t.extend(t.expr[":"],{data:t.expr.createPseudo?t.expr.createPseudo(function(e){return function(i){return!!t.data(i,e)}}):function(e,i,s){return!!t.data(e,s[3])}}),t.fn.extend({disableSelection:function(){var t="onselectstart"in document.createElement("div")?"selectstart":"mousedown";return function(){return this.on(t+".ui-disableSelection",function(t){t.preventDefault()})}}(),enableSelection:function(){return this.off(".ui-disableSelection")}}),t.ui.focusable=function(i,s){var n,o,a,r,h,l=i.nodeName.toLowerCase();return"area"===l?(n=i.parentNode,o=n.name,i.href&&o&&"map"===n.nodeName.toLowerCase()?(a=t("img[usemap='#"+o+"']"),a.length>0&&a.is(":visible")):!1):(/^(input|select|textarea|button|object)$/.test(l)?(r=!i.disabled,r&&(h=t(i).closest("fieldset")[0],h&&(r=!h.disabled))):r="a"===l?i.href||s:s,r&&t(i).is(":visible")&&e(t(i)))},t.extend(t.expr[":"],{focusable:function(e){return t.ui.focusable(e,null!=t.attr(e,"tabindex"))}}),t.ui.focusable,t.fn.form=function(){return"string"==typeof this[0].form?this.closest("form"):t(this[0].form)},t.ui.formResetMixin={_formResetHandler:function(){var e=t(this);setTimeout(function(){var i=e.data("ui-form-reset-instances");t.each(i,function(){this.refresh()})})},_bindFormResetHandler:function(){if(this.form=this.element.form(),this.form.length){var t=this.form.data("ui-form-reset-instances")||[];t.length||this.form.on("reset.ui-form-reset",this._formResetHandler),t.push(this),this.form.data("ui-form-reset-instances",t)}},_unbindFormResetHandler:function(){if(this.form.length){var e=this.form.data("ui-form-reset-instances");e.splice(t.inArray(this,e),1),e.length?this.form.data("ui-form-reset-instances",e):this.form.removeData("ui-form-reset-instances").off("reset.ui-form-reset")}}},"1.7"===t.fn.jquery.substring(0,3)&&(t.each(["Width","Height"],function(e,i){function s(e,i,s,o){return t.each(n,function(){i-=parseFloat(t.css(e,"padding"+this))||0,s&&(i-=parseFloat(t.css(e,"border"+this+"Width"))||0),o&&(i-=parseFloat(t.css(e,"margin"+this))||0)}),i}var n="Width"===i?["Left","Right"]:["Top","Bottom"],o=i.toLowerCase(),a={innerWidth:t.fn.innerWidth,innerHeight:t.fn.innerHeight,outerWidth:t.fn.outerWidth,outerHeight:t.fn.outerHeight};t.fn["inner"+i]=function(e){return void 0===e?a["inner"+i].call(this):this.each(function(){t(this).css(o,s(this,e)+"px")})},t.fn["outer"+i]=function(e,n){return"number"!=typeof e?a["outer"+i].call(this,e):this.each(function(){t(this).css(o,s(this,e,!0,n)+"px")})}}),t.fn.addBack=function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}),t.ui.keyCode={BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38},t.ui.escapeSelector=function(){var t=/([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g;return function(e){return e.replace(t,"\\$1")}}(),t.fn.labels=function(){var e,i,s,n,o;return this[0].labels&&this[0].labels.length?this.pushStack(this[0].labels):(n=this.eq(0).parents("label"),s=this.attr("id"),s&&(e=this.eq(0).parents().last(),o=e.add(e.length?e.siblings():this.siblings()),i="label[for='"+t.ui.escapeSelector(s)+"']",n=n.add(o.find(i).addBack(i))),this.pushStack(n))},t.fn.scrollParent=function(e){var i=this.css("position"),s="absolute"===i,n=e?/(auto|scroll|hidden)/:/(auto|scroll)/,o=this.parents().filter(function(){var e=t(this);return s&&"static"===e.css("position")?!1:n.test(e.css("overflow")+e.css("overflow-y")+e.css("overflow-x"))}).eq(0);return"fixed"!==i&&o.length?o:t(this[0].ownerDocument||document)},t.extend(t.expr[":"],{tabbable:function(e){var i=t.attr(e,"tabindex"),s=null!=i;return(!s||i>=0)&&t.ui.focusable(e,s)}}),t.fn.extend({uniqueId:function(){var t=0;return function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++t)})}}(),removeUniqueId:function(){return this.each(function(){/^ui-id-\d+$/.test(this.id)&&t(this).removeAttr("id")})}}),t.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase());var n=!1;t(document).on("mouseup",function(){n=!1}),t.widget("ui.mouse",{version:"1.12.1",options:{cancel:"input, textarea, button, select, option",distance:1,delay:0},_mouseInit:function(){var e=this;this.element.on("mousedown."+this.widgetName,function(t){return e._mouseDown(t)}).on("click."+this.widgetName,function(i){return!0===t.data(i.target,e.widgetName+".preventClickEvent")?(t.removeData(i.target,e.widgetName+".preventClickEvent"),i.stopImmediatePropagation(),!1):void 0}),this.started=!1},_mouseDestroy:function(){this.element.off("."+this.widgetName),this._mouseMoveDelegate&&this.document.off("mousemove."+this.widgetName,this._mouseMoveDelegate).off("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(e){if(!n){this._mouseMoved=!1,this._mouseStarted&&this._mouseUp(e),this._mouseDownEvent=e;var i=this,s=1===e.which,o="string"==typeof this.options.cancel&&e.target.nodeName?t(e.target).closest(this.options.cancel).length:!1;return s&&!o&&this._mouseCapture(e)?(this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){i.mouseDelayMet=!0},this.options.delay)),this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=this._mouseStart(e)!==!1,!this._mouseStarted)?(e.preventDefault(),!0):(!0===t.data(e.target,this.widgetName+".preventClickEvent")&&t.removeData(e.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(t){return i._mouseMove(t)},this._mouseUpDelegate=function(t){return i._mouseUp(t)},this.document.on("mousemove."+this.widgetName,this._mouseMoveDelegate).on("mouseup."+this.widgetName,this._mouseUpDelegate),e.preventDefault(),n=!0,!0)):!0}},_mouseMove:function(e){if(this._mouseMoved){if(t.ui.ie&&(!document.documentMode||9>document.documentMode)&&!e.button)return this._mouseUp(e);if(!e.which)if(e.originalEvent.altKey||e.originalEvent.ctrlKey||e.originalEvent.metaKey||e.originalEvent.shiftKey)this.ignoreMissingWhich=!0;else if(!this.ignoreMissingWhich)return this._mouseUp(e)}return(e.which||e.button)&&(this._mouseMoved=!0),this._mouseStarted?(this._mouseDrag(e),e.preventDefault()):(this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,e)!==!1,this._mouseStarted?this._mouseDrag(e):this._mouseUp(e)),!this._mouseStarted)},_mouseUp:function(e){this.document.off("mousemove."+this.widgetName,this._mouseMoveDelegate).off("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,e.target===this._mouseDownEvent.target&&t.data(e.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(e)),this._mouseDelayTimer&&(clearTimeout(this._mouseDelayTimer),delete this._mouseDelayTimer),this.ignoreMissingWhich=!1,n=!1,e.preventDefault()},_mouseDistanceMet:function(t){return Math.max(Math.abs(this._mouseDownEvent.pageX-t.pageX),Math.abs(this._mouseDownEvent.pageY-t.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}}),t.ui.plugin={add:function(e,i,s){var n,o=t.ui[e].prototype;for(n in s)o.plugins[n]=o.plugins[n]||[],o.plugins[n].push([i,s[n]])},call:function(t,e,i,s){var n,o=t.plugins[e];if(o&&(s||t.element[0].parentNode&&11!==t.element[0].parentNode.nodeType))for(n=0;o.length>n;n++)t.options[o[n][0]]&&o[n][1].apply(t.element,i)}},t.widget("ui.resizable",t.ui.mouse,{version:"1.12.1",widgetEventPrefix:"resize",options:{alsoResize:!1,animate:!1,animateDuration:"slow",animateEasing:"swing",aspectRatio:!1,autoHide:!1,classes:{"ui-resizable-se":"ui-icon ui-icon-gripsmall-diagonal-se"},containment:!1,ghost:!1,grid:!1,handles:"e,s,se",helper:!1,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:90,resize:null,start:null,stop:null},_num:function(t){return parseFloat(t)||0},_isNumber:function(t){return!isNaN(parseFloat(t))},_hasScroll:function(e,i){if("hidden"===t(e).css("overflow"))return!1;var s=i&&"left"===i?"scrollLeft":"scrollTop",n=!1;return e[s]>0?!0:(e[s]=1,n=e[s]>0,e[s]=0,n)},_create:function(){var e,i=this.options,s=this;this._addClass("ui-resizable"),t.extend(this,{_aspectRatio:!!i.aspectRatio,aspectRatio:i.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:i.helper||i.ghost||i.animate?i.helper||"ui-resizable-helper":null}),this.element[0].nodeName.match(/^(canvas|textarea|input|select|button|img)$/i)&&(this.element.wrap(t("
").css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("ui-resizable",this.element.resizable("instance")),this.elementIsWrapper=!0,e={marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom"),marginLeft:this.originalElement.css("marginLeft")},this.element.css(e),this.originalElement.css("margin",0),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css(e),this._proportionallyResize()),this._setupHandles(),i.autoHide&&t(this.element).on("mouseenter",function(){i.disabled||(s._removeClass("ui-resizable-autohide"),s._handles.show())}).on("mouseleave",function(){i.disabled||s.resizing||(s._addClass("ui-resizable-autohide"),s._handles.hide())}),this._mouseInit()},_destroy:function(){this._mouseDestroy();var e,i=function(e){t(e).removeData("resizable").removeData("ui-resizable").off(".resizable").find(".ui-resizable-handle").remove()};return this.elementIsWrapper&&(i(this.element),e=this.element,this.originalElement.css({position:e.css("position"),width:e.outerWidth(),height:e.outerHeight(),top:e.css("top"),left:e.css("left")}).insertAfter(e),e.remove()),this.originalElement.css("resize",this.originalResizeStyle),i(this.originalElement),this},_setOption:function(t,e){switch(this._super(t,e),t){case"handles":this._removeHandles(),this._setupHandles();break;default:}},_setupHandles:function(){var e,i,s,n,o,a=this.options,r=this;if(this.handles=a.handles||(t(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se"),this._handles=t(),this.handles.constructor===String)for("all"===this.handles&&(this.handles="n,e,s,w,se,sw,ne,nw"),s=this.handles.split(","),this.handles={},i=0;s.length>i;i++)e=t.trim(s[i]),n="ui-resizable-"+e,o=t("
"),this._addClass(o,"ui-resizable-handle "+n),o.css({zIndex:a.zIndex}),this.handles[e]=".ui-resizable-"+e,this.element.append(o);this._renderAxis=function(e){var i,s,n,o;e=e||this.element;for(i in this.handles)this.handles[i].constructor===String?this.handles[i]=this.element.children(this.handles[i]).first().show():(this.handles[i].jquery||this.handles[i].nodeType)&&(this.handles[i]=t(this.handles[i]),this._on(this.handles[i],{mousedown:r._mouseDown})),this.elementIsWrapper&&this.originalElement[0].nodeName.match(/^(textarea|input|select|button)$/i)&&(s=t(this.handles[i],this.element),o=/sw|ne|nw|se|n|s/.test(i)?s.outerHeight():s.outerWidth(),n=["padding",/ne|nw|n/.test(i)?"Top":/se|sw|s/.test(i)?"Bottom":/^e$/.test(i)?"Right":"Left"].join(""),e.css(n,o),this._proportionallyResize()),this._handles=this._handles.add(this.handles[i])},this._renderAxis(this.element),this._handles=this._handles.add(this.element.find(".ui-resizable-handle")),this._handles.disableSelection(),this._handles.on("mouseover",function(){r.resizing||(this.className&&(o=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)),r.axis=o&&o[1]?o[1]:"se")}),a.autoHide&&(this._handles.hide(),this._addClass("ui-resizable-autohide"))},_removeHandles:function(){this._handles.remove()},_mouseCapture:function(e){var i,s,n=!1;for(i in this.handles)s=t(this.handles[i])[0],(s===e.target||t.contains(s,e.target))&&(n=!0);return!this.options.disabled&&n},_mouseStart:function(e){var i,s,n,o=this.options,a=this.element;return this.resizing=!0,this._renderProxy(),i=this._num(this.helper.css("left")),s=this._num(this.helper.css("top")),o.containment&&(i+=t(o.containment).scrollLeft()||0,s+=t(o.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:i,top:s},this.size=this._helper?{width:this.helper.width(),height:this.helper.height()}:{width:a.width(),height:a.height()},this.originalSize=this._helper?{width:a.outerWidth(),height:a.outerHeight()}:{width:a.width(),height:a.height()},this.sizeDiff={width:a.outerWidth()-a.width(),height:a.outerHeight()-a.height()},this.originalPosition={left:i,top:s},this.originalMousePosition={left:e.pageX,top:e.pageY},this.aspectRatio="number"==typeof o.aspectRatio?o.aspectRatio:this.originalSize.width/this.originalSize.height||1,n=t(".ui-resizable-"+this.axis).css("cursor"),t("body").css("cursor","auto"===n?this.axis+"-resize":n),this._addClass("ui-resizable-resizing"),this._propagate("start",e),!0},_mouseDrag:function(e){var i,s,n=this.originalMousePosition,o=this.axis,a=e.pageX-n.left||0,r=e.pageY-n.top||0,h=this._change[o];return this._updatePrevProperties(),h?(i=h.apply(this,[e,a,r]),this._updateVirtualBoundaries(e.shiftKey),(this._aspectRatio||e.shiftKey)&&(i=this._updateRatio(i,e)),i=this._respectSize(i,e),this._updateCache(i),this._propagate("resize",e),s=this._applyChanges(),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),t.isEmptyObject(s)||(this._updatePrevProperties(),this._trigger("resize",e,this.ui()),this._applyChanges()),!1):!1},_mouseStop:function(e){this.resizing=!1;var i,s,n,o,a,r,h,l=this.options,c=this;return this._helper&&(i=this._proportionallyResizeElements,s=i.length&&/textarea/i.test(i[0].nodeName),n=s&&this._hasScroll(i[0],"left")?0:c.sizeDiff.height,o=s?0:c.sizeDiff.width,a={width:c.helper.width()-o,height:c.helper.height()-n},r=parseFloat(c.element.css("left"))+(c.position.left-c.originalPosition.left)||null,h=parseFloat(c.element.css("top"))+(c.position.top-c.originalPosition.top)||null,l.animate||this.element.css(t.extend(a,{top:h,left:r})),c.helper.height(c.size.height),c.helper.width(c.size.width),this._helper&&!l.animate&&this._proportionallyResize()),t("body").css("cursor","auto"),this._removeClass("ui-resizable-resizing"),this._propagate("stop",e),this._helper&&this.helper.remove(),!1},_updatePrevProperties:function(){this.prevPosition={top:this.position.top,left:this.position.left},this.prevSize={width:this.size.width,height:this.size.height}},_applyChanges:function(){var t={};return this.position.top!==this.prevPosition.top&&(t.top=this.position.top+"px"),this.position.left!==this.prevPosition.left&&(t.left=this.position.left+"px"),this.size.width!==this.prevSize.width&&(t.width=this.size.width+"px"),this.size.height!==this.prevSize.height&&(t.height=this.size.height+"px"),this.helper.css(t),t},_updateVirtualBoundaries:function(t){var e,i,s,n,o,a=this.options;o={minWidth:this._isNumber(a.minWidth)?a.minWidth:0,maxWidth:this._isNumber(a.maxWidth)?a.maxWidth:1/0,minHeight:this._isNumber(a.minHeight)?a.minHeight:0,maxHeight:this._isNumber(a.maxHeight)?a.maxHeight:1/0},(this._aspectRatio||t)&&(e=o.minHeight*this.aspectRatio,s=o.minWidth/this.aspectRatio,i=o.maxHeight*this.aspectRatio,n=o.maxWidth/this.aspectRatio,e>o.minWidth&&(o.minWidth=e),s>o.minHeight&&(o.minHeight=s),o.maxWidth>i&&(o.maxWidth=i),o.maxHeight>n&&(o.maxHeight=n)),this._vBoundaries=o},_updateCache:function(t){this.offset=this.helper.offset(),this._isNumber(t.left)&&(this.position.left=t.left),this._isNumber(t.top)&&(this.position.top=t.top),this._isNumber(t.height)&&(this.size.height=t.height),this._isNumber(t.width)&&(this.size.width=t.width)},_updateRatio:function(t){var e=this.position,i=this.size,s=this.axis;return this._isNumber(t.height)?t.width=t.height*this.aspectRatio:this._isNumber(t.width)&&(t.height=t.width/this.aspectRatio),"sw"===s&&(t.left=e.left+(i.width-t.width),t.top=null),"nw"===s&&(t.top=e.top+(i.height-t.height),t.left=e.left+(i.width-t.width)),t},_respectSize:function(t){var e=this._vBoundaries,i=this.axis,s=this._isNumber(t.width)&&e.maxWidth&&e.maxWidtht.width,a=this._isNumber(t.height)&&e.minHeight&&e.minHeight>t.height,r=this.originalPosition.left+this.originalSize.width,h=this.originalPosition.top+this.originalSize.height,l=/sw|nw|w/.test(i),c=/nw|ne|n/.test(i);return o&&(t.width=e.minWidth),a&&(t.height=e.minHeight),s&&(t.width=e.maxWidth),n&&(t.height=e.maxHeight),o&&l&&(t.left=r-e.minWidth),s&&l&&(t.left=r-e.maxWidth),a&&c&&(t.top=h-e.minHeight),n&&c&&(t.top=h-e.maxHeight),t.width||t.height||t.left||!t.top?t.width||t.height||t.top||!t.left||(t.left=null):t.top=null,t},_getPaddingPlusBorderDimensions:function(t){for(var e=0,i=[],s=[t.css("borderTopWidth"),t.css("borderRightWidth"),t.css("borderBottomWidth"),t.css("borderLeftWidth")],n=[t.css("paddingTop"),t.css("paddingRight"),t.css("paddingBottom"),t.css("paddingLeft")];4>e;e++)i[e]=parseFloat(s[e])||0,i[e]+=parseFloat(n[e])||0;return{height:i[0]+i[2],width:i[1]+i[3]}},_proportionallyResize:function(){if(this._proportionallyResizeElements.length)for(var t,e=0,i=this.helper||this.element;this._proportionallyResizeElements.length>e;e++)t=this._proportionallyResizeElements[e],this.outerDimensions||(this.outerDimensions=this._getPaddingPlusBorderDimensions(t)),t.css({height:i.height()-this.outerDimensions.height||0,width:i.width()-this.outerDimensions.width||0})},_renderProxy:function(){var e=this.element,i=this.options;this.elementOffset=e.offset(),this._helper?(this.helper=this.helper||t("
"),this._addClass(this.helper,this._helper),this.helper.css({width:this.element.outerWidth(),height:this.element.outerHeight(),position:"absolute",left:this.elementOffset.left+"px",top:this.elementOffset.top+"px",zIndex:++i.zIndex}),this.helper.appendTo("body").disableSelection()):this.helper=this.element -},_change:{e:function(t,e){return{width:this.originalSize.width+e}},w:function(t,e){var i=this.originalSize,s=this.originalPosition;return{left:s.left+e,width:i.width-e}},n:function(t,e,i){var s=this.originalSize,n=this.originalPosition;return{top:n.top+i,height:s.height-i}},s:function(t,e,i){return{height:this.originalSize.height+i}},se:function(e,i,s){return t.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[e,i,s]))},sw:function(e,i,s){return t.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[e,i,s]))},ne:function(e,i,s){return t.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[e,i,s]))},nw:function(e,i,s){return t.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[e,i,s]))}},_propagate:function(e,i){t.ui.plugin.call(this,e,[i,this.ui()]),"resize"!==e&&this._trigger(e,i,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),t.ui.plugin.add("resizable","animate",{stop:function(e){var i=t(this).resizable("instance"),s=i.options,n=i._proportionallyResizeElements,o=n.length&&/textarea/i.test(n[0].nodeName),a=o&&i._hasScroll(n[0],"left")?0:i.sizeDiff.height,r=o?0:i.sizeDiff.width,h={width:i.size.width-r,height:i.size.height-a},l=parseFloat(i.element.css("left"))+(i.position.left-i.originalPosition.left)||null,c=parseFloat(i.element.css("top"))+(i.position.top-i.originalPosition.top)||null;i.element.animate(t.extend(h,c&&l?{top:c,left:l}:{}),{duration:s.animateDuration,easing:s.animateEasing,step:function(){var s={width:parseFloat(i.element.css("width")),height:parseFloat(i.element.css("height")),top:parseFloat(i.element.css("top")),left:parseFloat(i.element.css("left"))};n&&n.length&&t(n[0]).css({width:s.width,height:s.height}),i._updateCache(s),i._propagate("resize",e)}})}}),t.ui.plugin.add("resizable","containment",{start:function(){var e,i,s,n,o,a,r,h=t(this).resizable("instance"),l=h.options,c=h.element,u=l.containment,d=u instanceof t?u.get(0):/parent/.test(u)?c.parent().get(0):u;d&&(h.containerElement=t(d),/document/.test(u)||u===document?(h.containerOffset={left:0,top:0},h.containerPosition={left:0,top:0},h.parentData={element:t(document),left:0,top:0,width:t(document).width(),height:t(document).height()||document.body.parentNode.scrollHeight}):(e=t(d),i=[],t(["Top","Right","Left","Bottom"]).each(function(t,s){i[t]=h._num(e.css("padding"+s))}),h.containerOffset=e.offset(),h.containerPosition=e.position(),h.containerSize={height:e.innerHeight()-i[3],width:e.innerWidth()-i[1]},s=h.containerOffset,n=h.containerSize.height,o=h.containerSize.width,a=h._hasScroll(d,"left")?d.scrollWidth:o,r=h._hasScroll(d)?d.scrollHeight:n,h.parentData={element:d,left:s.left,top:s.top,width:a,height:r}))},resize:function(e){var i,s,n,o,a=t(this).resizable("instance"),r=a.options,h=a.containerOffset,l=a.position,c=a._aspectRatio||e.shiftKey,u={top:0,left:0},d=a.containerElement,p=!0;d[0]!==document&&/static/.test(d.css("position"))&&(u=h),l.left<(a._helper?h.left:0)&&(a.size.width=a.size.width+(a._helper?a.position.left-h.left:a.position.left-u.left),c&&(a.size.height=a.size.width/a.aspectRatio,p=!1),a.position.left=r.helper?h.left:0),l.top<(a._helper?h.top:0)&&(a.size.height=a.size.height+(a._helper?a.position.top-h.top:a.position.top),c&&(a.size.width=a.size.height*a.aspectRatio,p=!1),a.position.top=a._helper?h.top:0),n=a.containerElement.get(0)===a.element.parent().get(0),o=/relative|absolute/.test(a.containerElement.css("position")),n&&o?(a.offset.left=a.parentData.left+a.position.left,a.offset.top=a.parentData.top+a.position.top):(a.offset.left=a.element.offset().left,a.offset.top=a.element.offset().top),i=Math.abs(a.sizeDiff.width+(a._helper?a.offset.left-u.left:a.offset.left-h.left)),s=Math.abs(a.sizeDiff.height+(a._helper?a.offset.top-u.top:a.offset.top-h.top)),i+a.size.width>=a.parentData.width&&(a.size.width=a.parentData.width-i,c&&(a.size.height=a.size.width/a.aspectRatio,p=!1)),s+a.size.height>=a.parentData.height&&(a.size.height=a.parentData.height-s,c&&(a.size.width=a.size.height*a.aspectRatio,p=!1)),p||(a.position.left=a.prevPosition.left,a.position.top=a.prevPosition.top,a.size.width=a.prevSize.width,a.size.height=a.prevSize.height)},stop:function(){var e=t(this).resizable("instance"),i=e.options,s=e.containerOffset,n=e.containerPosition,o=e.containerElement,a=t(e.helper),r=a.offset(),h=a.outerWidth()-e.sizeDiff.width,l=a.outerHeight()-e.sizeDiff.height;e._helper&&!i.animate&&/relative/.test(o.css("position"))&&t(this).css({left:r.left-n.left-s.left,width:h,height:l}),e._helper&&!i.animate&&/static/.test(o.css("position"))&&t(this).css({left:r.left-n.left-s.left,width:h,height:l})}}),t.ui.plugin.add("resizable","alsoResize",{start:function(){var e=t(this).resizable("instance"),i=e.options;t(i.alsoResize).each(function(){var e=t(this);e.data("ui-resizable-alsoresize",{width:parseFloat(e.width()),height:parseFloat(e.height()),left:parseFloat(e.css("left")),top:parseFloat(e.css("top"))})})},resize:function(e,i){var s=t(this).resizable("instance"),n=s.options,o=s.originalSize,a=s.originalPosition,r={height:s.size.height-o.height||0,width:s.size.width-o.width||0,top:s.position.top-a.top||0,left:s.position.left-a.left||0};t(n.alsoResize).each(function(){var e=t(this),s=t(this).data("ui-resizable-alsoresize"),n={},o=e.parents(i.originalElement[0]).length?["width","height"]:["width","height","top","left"];t.each(o,function(t,e){var i=(s[e]||0)+(r[e]||0);i&&i>=0&&(n[e]=i||null)}),e.css(n)})},stop:function(){t(this).removeData("ui-resizable-alsoresize")}}),t.ui.plugin.add("resizable","ghost",{start:function(){var e=t(this).resizable("instance"),i=e.size;e.ghost=e.originalElement.clone(),e.ghost.css({opacity:.25,display:"block",position:"relative",height:i.height,width:i.width,margin:0,left:0,top:0}),e._addClass(e.ghost,"ui-resizable-ghost"),t.uiBackCompat!==!1&&"string"==typeof e.options.ghost&&e.ghost.addClass(this.options.ghost),e.ghost.appendTo(e.helper)},resize:function(){var e=t(this).resizable("instance");e.ghost&&e.ghost.css({position:"relative",height:e.size.height,width:e.size.width})},stop:function(){var e=t(this).resizable("instance");e.ghost&&e.helper&&e.helper.get(0).removeChild(e.ghost.get(0))}}),t.ui.plugin.add("resizable","grid",{resize:function(){var e,i=t(this).resizable("instance"),s=i.options,n=i.size,o=i.originalSize,a=i.originalPosition,r=i.axis,h="number"==typeof s.grid?[s.grid,s.grid]:s.grid,l=h[0]||1,c=h[1]||1,u=Math.round((n.width-o.width)/l)*l,d=Math.round((n.height-o.height)/c)*c,p=o.width+u,f=o.height+d,m=s.maxWidth&&p>s.maxWidth,g=s.maxHeight&&f>s.maxHeight,_=s.minWidth&&s.minWidth>p,v=s.minHeight&&s.minHeight>f;s.grid=h,_&&(p+=l),v&&(f+=c),m&&(p-=l),g&&(f-=c),/^(se|s|e)$/.test(r)?(i.size.width=p,i.size.height=f):/^(ne)$/.test(r)?(i.size.width=p,i.size.height=f,i.position.top=a.top-d):/^(sw)$/.test(r)?(i.size.width=p,i.size.height=f,i.position.left=a.left-u):((0>=f-c||0>=p-l)&&(e=i._getPaddingPlusBorderDimensions(this)),f-c>0?(i.size.height=f,i.position.top=a.top-d):(f=c-e.height,i.size.height=f,i.position.top=a.top+o.height-f),p-l>0?(i.size.width=p,i.position.left=a.left-u):(p=l-e.width,i.size.width=p,i.position.left=a.left+o.width-p))}}),t.ui.resizable});/** - * Copyright (c) 2007 Ariel Flesler - aflesler ○ gmail • com | https://github.com/flesler - * Licensed under MIT - * @author Ariel Flesler - * @version 2.1.2 - */ -;(function(f){"use strict";"function"===typeof define&&define.amd?define(["jquery"],f):"undefined"!==typeof module&&module.exports?module.exports=f(require("jquery")):f(jQuery)})(function($){"use strict";function n(a){return!a.nodeName||-1!==$.inArray(a.nodeName.toLowerCase(),["iframe","#document","html","body"])}function h(a){return $.isFunction(a)||$.isPlainObject(a)?a:{top:a,left:a}}var p=$.scrollTo=function(a,d,b){return $(window).scrollTo(a,d,b)};p.defaults={axis:"xy",duration:0,limit:!0};$.fn.scrollTo=function(a,d,b){"object"=== typeof d&&(b=d,d=0);"function"===typeof b&&(b={onAfter:b});"max"===a&&(a=9E9);b=$.extend({},p.defaults,b);d=d||b.duration;var u=b.queue&&1=f[g]?0:Math.min(f[g],n));!a&&1-1){targetElements.on(evt+EVENT_NAMESPACE,function elementToggle(event){$.powerTip.toggle(this,event)})}else{targetElements.on(evt+EVENT_NAMESPACE,function elementOpen(event){$.powerTip.show(this,event)})}});$.each(options.closeEvents,function(idx,evt){if($.inArray(evt,options.openEvents)<0){targetElements.on(evt+EVENT_NAMESPACE,function elementClose(event){$.powerTip.hide(this,!isMouseEvent(event))})}});targetElements.on("keydown"+EVENT_NAMESPACE,function elementKeyDown(event){if(event.keyCode===27){$.powerTip.hide(this,true)}})}return targetElements};$.fn.powerTip.defaults={fadeInTime:200,fadeOutTime:100,followMouse:false,popupId:"powerTip",popupClass:null,intentSensitivity:7,intentPollInterval:100,closeDelay:100,placement:"n",smartPlacement:false,offset:10,mouseOnToPopup:false,manual:false,openEvents:["mouseenter","focus"],closeEvents:["mouseleave","blur"]};$.fn.powerTip.smartPlacementLists={n:["n","ne","nw","s"],e:["e","ne","se","w","nw","sw","n","s","e"],s:["s","se","sw","n"],w:["w","nw","sw","e","ne","se","n","s","w"],nw:["nw","w","sw","n","s","se","nw"],ne:["ne","e","se","n","s","sw","ne"],sw:["sw","w","nw","s","n","ne","sw"],se:["se","e","ne","s","n","nw","se"],"nw-alt":["nw-alt","n","ne-alt","sw-alt","s","se-alt","w","e"],"ne-alt":["ne-alt","n","nw-alt","se-alt","s","sw-alt","e","w"],"sw-alt":["sw-alt","s","se-alt","nw-alt","n","ne-alt","w","e"],"se-alt":["se-alt","s","sw-alt","ne-alt","n","nw-alt","e","w"]};$.powerTip={show:function apiShowTip(element,event){if(isMouseEvent(event)){trackMouse(event);session.previousX=event.pageX;session.previousY=event.pageY;$(element).data(DATA_DISPLAYCONTROLLER).show()}else{$(element).first().data(DATA_DISPLAYCONTROLLER).show(true,true)}return element},reposition:function apiResetPosition(element){$(element).first().data(DATA_DISPLAYCONTROLLER).resetPosition();return element},hide:function apiCloseTip(element,immediate){var displayController;immediate=element?immediate:true;if(element){displayController=$(element).first().data(DATA_DISPLAYCONTROLLER)}else if(session.activeHover){displayController=session.activeHover.data(DATA_DISPLAYCONTROLLER)}if(displayController){displayController.hide(immediate)}return element},toggle:function apiToggle(element,event){if(session.activeHover&&session.activeHover.is(element)){$.powerTip.hide(element,!isMouseEvent(event))}else{$.powerTip.show(element,event)}return element}};$.powerTip.showTip=$.powerTip.show;$.powerTip.closeTip=$.powerTip.hide;function CSSCoordinates(){var me=this;me.top="auto";me.left="auto";me.right="auto";me.bottom="auto";me.set=function(property,value){if($.isNumeric(value)){me[property]=Math.round(value)}}}function DisplayController(element,options,tipController){var hoverTimer=null,myCloseDelay=null;function openTooltip(immediate,forceOpen){cancelTimer();if(!element.data(DATA_HASACTIVEHOVER)){if(!immediate){session.tipOpenImminent=true;hoverTimer=setTimeout(function intentDelay(){hoverTimer=null;checkForIntent()},options.intentPollInterval)}else{if(forceOpen){element.data(DATA_FORCEDOPEN,true)}closeAnyDelayed();tipController.showTip(element)}}else{cancelClose()}}function closeTooltip(disableDelay){if(myCloseDelay){myCloseDelay=session.closeDelayTimeout=clearTimeout(myCloseDelay);session.delayInProgress=false}cancelTimer();session.tipOpenImminent=false;if(element.data(DATA_HASACTIVEHOVER)){element.data(DATA_FORCEDOPEN,false);if(!disableDelay){session.delayInProgress=true;session.closeDelayTimeout=setTimeout(function closeDelay(){session.closeDelayTimeout=null;tipController.hideTip(element);session.delayInProgress=false;myCloseDelay=null},options.closeDelay);myCloseDelay=session.closeDelayTimeout}else{tipController.hideTip(element)}}}function checkForIntent(){var xDifference=Math.abs(session.previousX-session.currentX),yDifference=Math.abs(session.previousY-session.currentY),totalDifference=xDifference+yDifference;if(totalDifference",{id:options.popupId});if($body.length===0){$body=$("body")}$body.append(tipElement);session.tooltips=session.tooltips?session.tooltips.add(tipElement):tipElement}if(options.followMouse){if(!tipElement.data(DATA_HASMOUSEMOVE)){$document.on("mousemove"+EVENT_NAMESPACE,positionTipOnCursor);$window.on("scroll"+EVENT_NAMESPACE,positionTipOnCursor);tipElement.data(DATA_HASMOUSEMOVE,true)}}function beginShowTip(element){element.data(DATA_HASACTIVEHOVER,true);tipElement.queue(function queueTipInit(next){showTip(element);next()})}function showTip(element){var tipContent;if(!element.data(DATA_HASACTIVEHOVER)){return}if(session.isTipOpen){if(!session.isClosing){hideTip(session.activeHover)}tipElement.delay(100).queue(function queueTipAgain(next){showTip(element);next()});return}element.trigger("powerTipPreRender");tipContent=getTooltipContent(element);if(tipContent){tipElement.empty().append(tipContent)}else{return}element.trigger("powerTipRender");session.activeHover=element;session.isTipOpen=true;tipElement.data(DATA_MOUSEONTOTIP,options.mouseOnToPopup);tipElement.addClass(options.popupClass);if(!options.followMouse||element.data(DATA_FORCEDOPEN)){positionTipOnElement(element);session.isFixedTipOpen=true}else{positionTipOnCursor()}if(!element.data(DATA_FORCEDOPEN)&&!options.followMouse){$document.on("click"+EVENT_NAMESPACE,function documentClick(event){var target=event.target;if(target!==element[0]){if(options.mouseOnToPopup){if(target!==tipElement[0]&&!$.contains(tipElement[0],target)){$.powerTip.hide()}}else{$.powerTip.hide()}}})}if(options.mouseOnToPopup&&!options.manual){tipElement.on("mouseenter"+EVENT_NAMESPACE,function tipMouseEnter(){if(session.activeHover){session.activeHover.data(DATA_DISPLAYCONTROLLER).cancel()}});tipElement.on("mouseleave"+EVENT_NAMESPACE,function tipMouseLeave(){if(session.activeHover){session.activeHover.data(DATA_DISPLAYCONTROLLER).hide()}})}tipElement.fadeIn(options.fadeInTime,function fadeInCallback(){if(!session.desyncTimeout){session.desyncTimeout=setInterval(closeDesyncedTip,500)}element.trigger("powerTipOpen")})}function hideTip(element){session.isClosing=true;session.isTipOpen=false;session.desyncTimeout=clearInterval(session.desyncTimeout);element.data(DATA_HASACTIVEHOVER,false);element.data(DATA_FORCEDOPEN,false);$document.off("click"+EVENT_NAMESPACE);tipElement.off(EVENT_NAMESPACE);tipElement.fadeOut(options.fadeOutTime,function fadeOutCallback(){var coords=new CSSCoordinates;session.activeHover=null;session.isClosing=false;session.isFixedTipOpen=false;tipElement.removeClass();coords.set("top",session.currentY+options.offset);coords.set("left",session.currentX+options.offset);tipElement.css(coords);element.trigger("powerTipClose")})}function positionTipOnCursor(){var tipWidth,tipHeight,coords,collisions,collisionCount;if(!session.isFixedTipOpen&&(session.isTipOpen||session.tipOpenImminent&&tipElement.data(DATA_HASMOUSEMOVE))){tipWidth=tipElement.outerWidth();tipHeight=tipElement.outerHeight();coords=new CSSCoordinates;coords.set("top",session.currentY+options.offset);coords.set("left",session.currentX+options.offset);collisions=getViewportCollisions(coords,tipWidth,tipHeight);if(collisions!==Collision.none){collisionCount=countFlags(collisions);if(collisionCount===1){if(collisions===Collision.right){coords.set("left",session.scrollLeft+session.windowWidth-tipWidth)}else if(collisions===Collision.bottom){coords.set("top",session.scrollTop+session.windowHeight-tipHeight)}}else{coords.set("left",session.currentX-tipWidth-options.offset);coords.set("top",session.currentY-tipHeight-options.offset)}}tipElement.css(coords)}}function positionTipOnElement(element){var priorityList,finalPlacement;if(options.smartPlacement||options.followMouse&&element.data(DATA_FORCEDOPEN)){priorityList=$.fn.powerTip.smartPlacementLists[options.placement];$.each(priorityList,function(idx,pos){var collisions=getViewportCollisions(placeTooltip(element,pos),tipElement.outerWidth(),tipElement.outerHeight());finalPlacement=pos;return collisions!==Collision.none})}else{placeTooltip(element,options.placement);finalPlacement=options.placement}tipElement.removeClass("w nw sw e ne se n s w se-alt sw-alt ne-alt nw-alt");tipElement.addClass(finalPlacement)}function placeTooltip(element,placement){var iterationCount=0,tipWidth,tipHeight,coords=new CSSCoordinates;coords.set("top",0);coords.set("left",0);tipElement.css(coords);do{tipWidth=tipElement.outerWidth();tipHeight=tipElement.outerHeight();coords=placementCalculator.compute(element,placement,tipWidth,tipHeight,options.offset);tipElement.css(coords)}while(++iterationCount<=5&&(tipWidth!==tipElement.outerWidth()||tipHeight!==tipElement.outerHeight()));return coords}function closeDesyncedTip(){var isDesynced=false,hasDesyncableCloseEvent=$.grep(["mouseleave","mouseout","blur","focusout"],function(eventType){return $.inArray(eventType,options.closeEvents)!==-1}).length>0;if(session.isTipOpen&&!session.isClosing&&!session.delayInProgress&&hasDesyncableCloseEvent){if(session.activeHover.data(DATA_HASACTIVEHOVER)===false||session.activeHover.is(":disabled")){isDesynced=true}else if(!isMouseOver(session.activeHover)&&!session.activeHover.is(":focus")&&!session.activeHover.data(DATA_FORCEDOPEN)){if(tipElement.data(DATA_MOUSEONTOTIP)){if(!isMouseOver(tipElement)){isDesynced=true}}else{isDesynced=true}}if(isDesynced){hideTip(session.activeHover)}}}this.showTip=beginShowTip;this.hideTip=hideTip;this.resetPosition=positionTipOnElement}function isSvgElement(element){return Boolean(window.SVGElement&&element[0]instanceof SVGElement)}function isMouseEvent(event){return Boolean(event&&$.inArray(event.type,MOUSE_EVENTS)>-1&&typeof event.pageX==="number")}function initTracking(){if(!session.mouseTrackingActive){session.mouseTrackingActive=true;getViewportDimensions();$(getViewportDimensions);$document.on("mousemove"+EVENT_NAMESPACE,trackMouse);$window.on("resize"+EVENT_NAMESPACE,trackResize);$window.on("scroll"+EVENT_NAMESPACE,trackScroll)}}function getViewportDimensions(){session.scrollLeft=$window.scrollLeft();session.scrollTop=$window.scrollTop();session.windowWidth=$window.width();session.windowHeight=$window.height()}function trackResize(){session.windowWidth=$window.width();session.windowHeight=$window.height()}function trackScroll(){var x=$window.scrollLeft(),y=$window.scrollTop();if(x!==session.scrollLeft){session.currentX+=x-session.scrollLeft;session.scrollLeft=x}if(y!==session.scrollTop){session.currentY+=y-session.scrollTop;session.scrollTop=y}}function trackMouse(event){session.currentX=event.pageX;session.currentY=event.pageY}function isMouseOver(element){var elementPosition=element.offset(),elementBox=element[0].getBoundingClientRect(),elementWidth=elementBox.right-elementBox.left,elementHeight=elementBox.bottom-elementBox.top;return session.currentX>=elementPosition.left&&session.currentX<=elementPosition.left+elementWidth&&session.currentY>=elementPosition.top&&session.currentY<=elementPosition.top+elementHeight}function getTooltipContent(element){var tipText=element.data(DATA_POWERTIP),tipObject=element.data(DATA_POWERTIPJQ),tipTarget=element.data(DATA_POWERTIPTARGET),targetElement,content;if(tipText){if($.isFunction(tipText)){tipText=tipText.call(element[0])}content=tipText}else if(tipObject){if($.isFunction(tipObject)){tipObject=tipObject.call(element[0])}if(tipObject.length>0){content=tipObject.clone(true,true)}}else if(tipTarget){targetElement=$("#"+tipTarget);if(targetElement.length>0){content=targetElement.html()}}return content}function getViewportCollisions(coords,elementWidth,elementHeight){var viewportTop=session.scrollTop,viewportLeft=session.scrollLeft,viewportBottom=viewportTop+session.windowHeight,viewportRight=viewportLeft+session.windowWidth,collisions=Collision.none;if(coords.topviewportBottom||Math.abs(coords.bottom-session.windowHeight)>viewportBottom){collisions|=Collision.bottom}if(coords.leftviewportRight){collisions|=Collision.left}if(coords.left+elementWidth>viewportRight||coords.right1)){a.preventDefault();var c=a.originalEvent.changedTouches[0],d=document.createEvent("MouseEvents");d.initMouseEvent(b,!0,!0,window,1,c.screenX,c.screenY,c.clientX,c.clientY,!1,!1,!1,!1,0,null),a.target.dispatchEvent(d)}}if(a.support.touch="ontouchend"in document,a.support.touch){var e,b=a.ui.mouse.prototype,c=b._mouseInit,d=b._mouseDestroy;b._touchStart=function(a){var b=this;!e&&b._mouseCapture(a.originalEvent.changedTouches[0])&&(e=!0,b._touchMoved=!1,f(a,"mouseover"),f(a,"mousemove"),f(a,"mousedown"))},b._touchMove=function(a){e&&(this._touchMoved=!0,f(a,"mousemove"))},b._touchEnd=function(a){e&&(f(a,"mouseup"),f(a,"mouseout"),this._touchMoved||f(a,"click"),e=!1)},b._mouseInit=function(){var b=this;b.element.bind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),c.call(b)},b._mouseDestroy=function(){var b=this;b.element.unbind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),d.call(b)}}}(jQuery);/*! SmartMenus jQuery Plugin - v1.1.0 - September 17, 2017 - * http://www.smartmenus.org/ - * Copyright Vasil Dinkov, Vadikom Web Ltd. http://vadikom.com; Licensed MIT */(function(t){"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof module&&"object"==typeof module.exports?module.exports=t(require("jquery")):t(jQuery)})(function($){function initMouseDetection(t){var e=".smartmenus_mouse";if(mouseDetectionEnabled||t)mouseDetectionEnabled&&t&&($(document).off(e),mouseDetectionEnabled=!1);else{var i=!0,s=null,o={mousemove:function(t){var e={x:t.pageX,y:t.pageY,timeStamp:(new Date).getTime()};if(s){var o=Math.abs(s.x-e.x),a=Math.abs(s.y-e.y);if((o>0||a>0)&&2>=o&&2>=a&&300>=e.timeStamp-s.timeStamp&&(mouse=!0,i)){var n=$(t.target).closest("a");n.is("a")&&$.each(menuTrees,function(){return $.contains(this.$root[0],n[0])?(this.itemEnter({currentTarget:n[0]}),!1):void 0}),i=!1}}s=e}};o[touchEvents?"touchstart":"pointerover pointermove pointerout MSPointerOver MSPointerMove MSPointerOut"]=function(t){isTouchEvent(t.originalEvent)&&(mouse=!1)},$(document).on(getEventsNS(o,e)),mouseDetectionEnabled=!0}}function isTouchEvent(t){return!/^(4|mouse)$/.test(t.pointerType)}function getEventsNS(t,e){e||(e="");var i={};for(var s in t)i[s.split(" ").join(e+" ")+e]=t[s];return i}var menuTrees=[],mouse=!1,touchEvents="ontouchstart"in window,mouseDetectionEnabled=!1,requestAnimationFrame=window.requestAnimationFrame||function(t){return setTimeout(t,1e3/60)},cancelAnimationFrame=window.cancelAnimationFrame||function(t){clearTimeout(t)},canAnimate=!!$.fn.animate;return $.SmartMenus=function(t,e){this.$root=$(t),this.opts=e,this.rootId="",this.accessIdPrefix="",this.$subArrow=null,this.activatedItems=[],this.visibleSubMenus=[],this.showTimeout=0,this.hideTimeout=0,this.scrollTimeout=0,this.clickActivated=!1,this.focusActivated=!1,this.zIndexInc=0,this.idInc=0,this.$firstLink=null,this.$firstSub=null,this.disabled=!1,this.$disableOverlay=null,this.$touchScrollingSub=null,this.cssTransforms3d="perspective"in t.style||"webkitPerspective"in t.style,this.wasCollapsible=!1,this.init()},$.extend($.SmartMenus,{hideAll:function(){$.each(menuTrees,function(){this.menuHideAll()})},destroy:function(){for(;menuTrees.length;)menuTrees[0].destroy();initMouseDetection(!0)},prototype:{init:function(t){var e=this;if(!t){menuTrees.push(this),this.rootId=((new Date).getTime()+Math.random()+"").replace(/\D/g,""),this.accessIdPrefix="sm-"+this.rootId+"-",this.$root.hasClass("sm-rtl")&&(this.opts.rightToLeftSubMenus=!0);var i=".smartmenus";this.$root.data("smartmenus",this).attr("data-smartmenus-id",this.rootId).dataSM("level",1).on(getEventsNS({"mouseover focusin":$.proxy(this.rootOver,this),"mouseout focusout":$.proxy(this.rootOut,this),keydown:$.proxy(this.rootKeyDown,this)},i)).on(getEventsNS({mouseenter:$.proxy(this.itemEnter,this),mouseleave:$.proxy(this.itemLeave,this),mousedown:$.proxy(this.itemDown,this),focus:$.proxy(this.itemFocus,this),blur:$.proxy(this.itemBlur,this),click:$.proxy(this.itemClick,this)},i),"a"),i+=this.rootId,this.opts.hideOnClick&&$(document).on(getEventsNS({touchstart:$.proxy(this.docTouchStart,this),touchmove:$.proxy(this.docTouchMove,this),touchend:$.proxy(this.docTouchEnd,this),click:$.proxy(this.docClick,this)},i)),$(window).on(getEventsNS({"resize orientationchange":$.proxy(this.winResize,this)},i)),this.opts.subIndicators&&(this.$subArrow=$("").addClass("sub-arrow"),this.opts.subIndicatorsText&&this.$subArrow.html(this.opts.subIndicatorsText)),initMouseDetection()}if(this.$firstSub=this.$root.find("ul").each(function(){e.menuInit($(this))}).eq(0),this.$firstLink=this.$root.find("a").eq(0),this.opts.markCurrentItem){var s=/(index|default)\.[^#\?\/]*/i,o=/#.*/,a=window.location.href.replace(s,""),n=a.replace(o,"");this.$root.find("a").each(function(){var t=this.href.replace(s,""),i=$(this);(t==a||t==n)&&(i.addClass("current"),e.opts.markCurrentTree&&i.parentsUntil("[data-smartmenus-id]","ul").each(function(){$(this).dataSM("parent-a").addClass("current")}))})}this.wasCollapsible=this.isCollapsible()},destroy:function(t){if(!t){var e=".smartmenus";this.$root.removeData("smartmenus").removeAttr("data-smartmenus-id").removeDataSM("level").off(e),e+=this.rootId,$(document).off(e),$(window).off(e),this.opts.subIndicators&&(this.$subArrow=null)}this.menuHideAll();var i=this;this.$root.find("ul").each(function(){var t=$(this);t.dataSM("scroll-arrows")&&t.dataSM("scroll-arrows").remove(),t.dataSM("shown-before")&&((i.opts.subMenusMinWidth||i.opts.subMenusMaxWidth)&&t.css({width:"",minWidth:"",maxWidth:""}).removeClass("sm-nowrap"),t.dataSM("scroll-arrows")&&t.dataSM("scroll-arrows").remove(),t.css({zIndex:"",top:"",left:"",marginLeft:"",marginTop:"",display:""})),0==(t.attr("id")||"").indexOf(i.accessIdPrefix)&&t.removeAttr("id")}).removeDataSM("in-mega").removeDataSM("shown-before").removeDataSM("scroll-arrows").removeDataSM("parent-a").removeDataSM("level").removeDataSM("beforefirstshowfired").removeAttr("role").removeAttr("aria-hidden").removeAttr("aria-labelledby").removeAttr("aria-expanded"),this.$root.find("a.has-submenu").each(function(){var t=$(this);0==t.attr("id").indexOf(i.accessIdPrefix)&&t.removeAttr("id")}).removeClass("has-submenu").removeDataSM("sub").removeAttr("aria-haspopup").removeAttr("aria-controls").removeAttr("aria-expanded").closest("li").removeDataSM("sub"),this.opts.subIndicators&&this.$root.find("span.sub-arrow").remove(),this.opts.markCurrentItem&&this.$root.find("a.current").removeClass("current"),t||(this.$root=null,this.$firstLink=null,this.$firstSub=null,this.$disableOverlay&&(this.$disableOverlay.remove(),this.$disableOverlay=null),menuTrees.splice($.inArray(this,menuTrees),1))},disable:function(t){if(!this.disabled){if(this.menuHideAll(),!t&&!this.opts.isPopup&&this.$root.is(":visible")){var e=this.$root.offset();this.$disableOverlay=$('
').css({position:"absolute",top:e.top,left:e.left,width:this.$root.outerWidth(),height:this.$root.outerHeight(),zIndex:this.getStartZIndex(!0),opacity:0}).appendTo(document.body)}this.disabled=!0}},docClick:function(t){return this.$touchScrollingSub?(this.$touchScrollingSub=null,void 0):((this.visibleSubMenus.length&&!$.contains(this.$root[0],t.target)||$(t.target).closest("a").length)&&this.menuHideAll(),void 0)},docTouchEnd:function(){if(this.lastTouch){if(!(!this.visibleSubMenus.length||void 0!==this.lastTouch.x2&&this.lastTouch.x1!=this.lastTouch.x2||void 0!==this.lastTouch.y2&&this.lastTouch.y1!=this.lastTouch.y2||this.lastTouch.target&&$.contains(this.$root[0],this.lastTouch.target))){this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=0);var t=this;this.hideTimeout=setTimeout(function(){t.menuHideAll()},350)}this.lastTouch=null}},docTouchMove:function(t){if(this.lastTouch){var e=t.originalEvent.touches[0];this.lastTouch.x2=e.pageX,this.lastTouch.y2=e.pageY}},docTouchStart:function(t){var e=t.originalEvent.touches[0];this.lastTouch={x1:e.pageX,y1:e.pageY,target:e.target}},enable:function(){this.disabled&&(this.$disableOverlay&&(this.$disableOverlay.remove(),this.$disableOverlay=null),this.disabled=!1)},getClosestMenu:function(t){for(var e=$(t).closest("ul");e.dataSM("in-mega");)e=e.parent().closest("ul");return e[0]||null},getHeight:function(t){return this.getOffset(t,!0)},getOffset:function(t,e){var i;"none"==t.css("display")&&(i={position:t[0].style.position,visibility:t[0].style.visibility},t.css({position:"absolute",visibility:"hidden"}).show());var s=t[0].getBoundingClientRect&&t[0].getBoundingClientRect(),o=s&&(e?s.height||s.bottom-s.top:s.width||s.right-s.left);return o||0===o||(o=e?t[0].offsetHeight:t[0].offsetWidth),i&&t.hide().css(i),o},getStartZIndex:function(t){var e=parseInt(this[t?"$root":"$firstSub"].css("z-index"));return!t&&isNaN(e)&&(e=parseInt(this.$root.css("z-index"))),isNaN(e)?1:e},getTouchPoint:function(t){return t.touches&&t.touches[0]||t.changedTouches&&t.changedTouches[0]||t},getViewport:function(t){var e=t?"Height":"Width",i=document.documentElement["client"+e],s=window["inner"+e];return s&&(i=Math.min(i,s)),i},getViewportHeight:function(){return this.getViewport(!0)},getViewportWidth:function(){return this.getViewport()},getWidth:function(t){return this.getOffset(t)},handleEvents:function(){return!this.disabled&&this.isCSSOn()},handleItemEvents:function(t){return this.handleEvents()&&!this.isLinkInMegaMenu(t)},isCollapsible:function(){return"static"==this.$firstSub.css("position")},isCSSOn:function(){return"inline"!=this.$firstLink.css("display")},isFixed:function(){var t="fixed"==this.$root.css("position");return t||this.$root.parentsUntil("body").each(function(){return"fixed"==$(this).css("position")?(t=!0,!1):void 0}),t},isLinkInMegaMenu:function(t){return $(this.getClosestMenu(t[0])).hasClass("mega-menu")},isTouchMode:function(){return!mouse||this.opts.noMouseOver||this.isCollapsible()},itemActivate:function(t,e){var i=t.closest("ul"),s=i.dataSM("level");if(s>1&&(!this.activatedItems[s-2]||this.activatedItems[s-2][0]!=i.dataSM("parent-a")[0])){var o=this;$(i.parentsUntil("[data-smartmenus-id]","ul").get().reverse()).add(i).each(function(){o.itemActivate($(this).dataSM("parent-a"))})}if((!this.isCollapsible()||e)&&this.menuHideSubMenus(this.activatedItems[s-1]&&this.activatedItems[s-1][0]==t[0]?s:s-1),this.activatedItems[s-1]=t,this.$root.triggerHandler("activate.smapi",t[0])!==!1){var a=t.dataSM("sub");a&&(this.isTouchMode()||!this.opts.showOnClick||this.clickActivated)&&this.menuShow(a)}},itemBlur:function(t){var e=$(t.currentTarget);this.handleItemEvents(e)&&this.$root.triggerHandler("blur.smapi",e[0])},itemClick:function(t){var e=$(t.currentTarget);if(this.handleItemEvents(e)){if(this.$touchScrollingSub&&this.$touchScrollingSub[0]==e.closest("ul")[0])return this.$touchScrollingSub=null,t.stopPropagation(),!1;if(this.$root.triggerHandler("click.smapi",e[0])===!1)return!1;var i=$(t.target).is(".sub-arrow"),s=e.dataSM("sub"),o=s?2==s.dataSM("level"):!1,a=this.isCollapsible(),n=/toggle$/.test(this.opts.collapsibleBehavior),r=/link$/.test(this.opts.collapsibleBehavior),h=/^accordion/.test(this.opts.collapsibleBehavior);if(s&&!s.is(":visible")){if((!r||!a||i)&&(this.opts.showOnClick&&o&&(this.clickActivated=!0),this.itemActivate(e,h),s.is(":visible")))return this.focusActivated=!0,!1}else if(a&&(n||i))return this.itemActivate(e,h),this.menuHide(s),n&&(this.focusActivated=!1),!1;return this.opts.showOnClick&&o||e.hasClass("disabled")||this.$root.triggerHandler("select.smapi",e[0])===!1?!1:void 0}},itemDown:function(t){var e=$(t.currentTarget);this.handleItemEvents(e)&&e.dataSM("mousedown",!0)},itemEnter:function(t){var e=$(t.currentTarget);if(this.handleItemEvents(e)){if(!this.isTouchMode()){this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=0);var i=this;this.showTimeout=setTimeout(function(){i.itemActivate(e)},this.opts.showOnClick&&1==e.closest("ul").dataSM("level")?1:this.opts.showTimeout)}this.$root.triggerHandler("mouseenter.smapi",e[0])}},itemFocus:function(t){var e=$(t.currentTarget);this.handleItemEvents(e)&&(!this.focusActivated||this.isTouchMode()&&e.dataSM("mousedown")||this.activatedItems.length&&this.activatedItems[this.activatedItems.length-1][0]==e[0]||this.itemActivate(e,!0),this.$root.triggerHandler("focus.smapi",e[0]))},itemLeave:function(t){var e=$(t.currentTarget);this.handleItemEvents(e)&&(this.isTouchMode()||(e[0].blur(),this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=0)),e.removeDataSM("mousedown"),this.$root.triggerHandler("mouseleave.smapi",e[0]))},menuHide:function(t){if(this.$root.triggerHandler("beforehide.smapi",t[0])!==!1&&(canAnimate&&t.stop(!0,!0),"none"!=t.css("display"))){var e=function(){t.css("z-index","")};this.isCollapsible()?canAnimate&&this.opts.collapsibleHideFunction?this.opts.collapsibleHideFunction.call(this,t,e):t.hide(this.opts.collapsibleHideDuration,e):canAnimate&&this.opts.hideFunction?this.opts.hideFunction.call(this,t,e):t.hide(this.opts.hideDuration,e),t.dataSM("scroll")&&(this.menuScrollStop(t),t.css({"touch-action":"","-ms-touch-action":"","-webkit-transform":"",transform:""}).off(".smartmenus_scroll").removeDataSM("scroll").dataSM("scroll-arrows").hide()),t.dataSM("parent-a").removeClass("highlighted").attr("aria-expanded","false"),t.attr({"aria-expanded":"false","aria-hidden":"true"});var i=t.dataSM("level");this.activatedItems.splice(i-1,1),this.visibleSubMenus.splice($.inArray(t,this.visibleSubMenus),1),this.$root.triggerHandler("hide.smapi",t[0])}},menuHideAll:function(){this.showTimeout&&(clearTimeout(this.showTimeout),this.showTimeout=0);for(var t=this.opts.isPopup?1:0,e=this.visibleSubMenus.length-1;e>=t;e--)this.menuHide(this.visibleSubMenus[e]);this.opts.isPopup&&(canAnimate&&this.$root.stop(!0,!0),this.$root.is(":visible")&&(canAnimate&&this.opts.hideFunction?this.opts.hideFunction.call(this,this.$root):this.$root.hide(this.opts.hideDuration))),this.activatedItems=[],this.visibleSubMenus=[],this.clickActivated=!1,this.focusActivated=!1,this.zIndexInc=0,this.$root.triggerHandler("hideAll.smapi")},menuHideSubMenus:function(t){for(var e=this.activatedItems.length-1;e>=t;e--){var i=this.activatedItems[e].dataSM("sub");i&&this.menuHide(i)}},menuInit:function(t){if(!t.dataSM("in-mega")){t.hasClass("mega-menu")&&t.find("ul").dataSM("in-mega",!0);for(var e=2,i=t[0];(i=i.parentNode.parentNode)!=this.$root[0];)e++;var s=t.prevAll("a").eq(-1);s.length||(s=t.prevAll().find("a").eq(-1)),s.addClass("has-submenu").dataSM("sub",t),t.dataSM("parent-a",s).dataSM("level",e).parent().dataSM("sub",t);var o=s.attr("id")||this.accessIdPrefix+ ++this.idInc,a=t.attr("id")||this.accessIdPrefix+ ++this.idInc;s.attr({id:o,"aria-haspopup":"true","aria-controls":a,"aria-expanded":"false"}),t.attr({id:a,role:"group","aria-hidden":"true","aria-labelledby":o,"aria-expanded":"false"}),this.opts.subIndicators&&s[this.opts.subIndicatorsPos](this.$subArrow.clone())}},menuPosition:function(t){var e,i,s=t.dataSM("parent-a"),o=s.closest("li"),a=o.parent(),n=t.dataSM("level"),r=this.getWidth(t),h=this.getHeight(t),u=s.offset(),l=u.left,c=u.top,d=this.getWidth(s),m=this.getHeight(s),p=$(window),f=p.scrollLeft(),v=p.scrollTop(),b=this.getViewportWidth(),S=this.getViewportHeight(),g=a.parent().is("[data-sm-horizontal-sub]")||2==n&&!a.hasClass("sm-vertical"),M=this.opts.rightToLeftSubMenus&&!o.is("[data-sm-reverse]")||!this.opts.rightToLeftSubMenus&&o.is("[data-sm-reverse]"),w=2==n?this.opts.mainMenuSubOffsetX:this.opts.subMenusSubOffsetX,T=2==n?this.opts.mainMenuSubOffsetY:this.opts.subMenusSubOffsetY;if(g?(e=M?d-r-w:w,i=this.opts.bottomToTopSubMenus?-h-T:m+T):(e=M?w-r:d-w,i=this.opts.bottomToTopSubMenus?m-T-h:T),this.opts.keepInViewport){var y=l+e,I=c+i;if(M&&f>y?e=g?f-y+e:d-w:!M&&y+r>f+b&&(e=g?f+b-r-y+e:w-r),g||(S>h&&I+h>v+S?i+=v+S-h-I:(h>=S||v>I)&&(i+=v-I)),g&&(I+h>v+S+.49||v>I)||!g&&h>S+.49){var x=this;t.dataSM("scroll-arrows")||t.dataSM("scroll-arrows",$([$('')[0],$('')[0]]).on({mouseenter:function(){t.dataSM("scroll").up=$(this).hasClass("scroll-up"),x.menuScroll(t)},mouseleave:function(e){x.menuScrollStop(t),x.menuScrollOut(t,e)},"mousewheel DOMMouseScroll":function(t){t.preventDefault()}}).insertAfter(t));var A=".smartmenus_scroll";if(t.dataSM("scroll",{y:this.cssTransforms3d?0:i-m,step:1,itemH:m,subH:h,arrowDownH:this.getHeight(t.dataSM("scroll-arrows").eq(1))}).on(getEventsNS({mouseover:function(e){x.menuScrollOver(t,e)},mouseout:function(e){x.menuScrollOut(t,e)},"mousewheel DOMMouseScroll":function(e){x.menuScrollMousewheel(t,e)}},A)).dataSM("scroll-arrows").css({top:"auto",left:"0",marginLeft:e+(parseInt(t.css("border-left-width"))||0),width:r-(parseInt(t.css("border-left-width"))||0)-(parseInt(t.css("border-right-width"))||0),zIndex:t.css("z-index")}).eq(g&&this.opts.bottomToTopSubMenus?0:1).show(),this.isFixed()){var C={};C[touchEvents?"touchstart touchmove touchend":"pointerdown pointermove pointerup MSPointerDown MSPointerMove MSPointerUp"]=function(e){x.menuScrollTouch(t,e)},t.css({"touch-action":"none","-ms-touch-action":"none"}).on(getEventsNS(C,A))}}}t.css({top:"auto",left:"0",marginLeft:e,marginTop:i-m})},menuScroll:function(t,e,i){var s,o=t.dataSM("scroll"),a=t.dataSM("scroll-arrows"),n=o.up?o.upEnd:o.downEnd;if(!e&&o.momentum){if(o.momentum*=.92,s=o.momentum,.5>s)return this.menuScrollStop(t),void 0}else s=i||(e||!this.opts.scrollAccelerate?this.opts.scrollStep:Math.floor(o.step));var r=t.dataSM("level");if(this.activatedItems[r-1]&&this.activatedItems[r-1].dataSM("sub")&&this.activatedItems[r-1].dataSM("sub").is(":visible")&&this.menuHideSubMenus(r-1),o.y=o.up&&o.y>=n||!o.up&&n>=o.y?o.y:Math.abs(n-o.y)>s?o.y+(o.up?s:-s):n,t.css(this.cssTransforms3d?{"-webkit-transform":"translate3d(0, "+o.y+"px, 0)",transform:"translate3d(0, "+o.y+"px, 0)"}:{marginTop:o.y}),mouse&&(o.up&&o.y>o.downEnd||!o.up&&o.y0;t.dataSM("scroll-arrows").eq(i?0:1).is(":visible")&&(t.dataSM("scroll").up=i,this.menuScroll(t,!0))}e.preventDefault()},menuScrollOut:function(t,e){mouse&&(/^scroll-(up|down)/.test((e.relatedTarget||"").className)||(t[0]==e.relatedTarget||$.contains(t[0],e.relatedTarget))&&this.getClosestMenu(e.relatedTarget)==t[0]||t.dataSM("scroll-arrows").css("visibility","hidden"))},menuScrollOver:function(t,e){if(mouse&&!/^scroll-(up|down)/.test(e.target.className)&&this.getClosestMenu(e.target)==t[0]){this.menuScrollRefreshData(t);var i=t.dataSM("scroll"),s=$(window).scrollTop()-t.dataSM("parent-a").offset().top-i.itemH;t.dataSM("scroll-arrows").eq(0).css("margin-top",s).end().eq(1).css("margin-top",s+this.getViewportHeight()-i.arrowDownH).end().css("visibility","visible")}},menuScrollRefreshData:function(t){var e=t.dataSM("scroll"),i=$(window).scrollTop()-t.dataSM("parent-a").offset().top-e.itemH;this.cssTransforms3d&&(i=-(parseFloat(t.css("margin-top"))-i)),$.extend(e,{upEnd:i,downEnd:i+this.getViewportHeight()-e.subH})},menuScrollStop:function(t){return this.scrollTimeout?(cancelAnimationFrame(this.scrollTimeout),this.scrollTimeout=0,t.dataSM("scroll").step=1,!0):void 0},menuScrollTouch:function(t,e){if(e=e.originalEvent,isTouchEvent(e)){var i=this.getTouchPoint(e);if(this.getClosestMenu(i.target)==t[0]){var s=t.dataSM("scroll");if(/(start|down)$/i.test(e.type))this.menuScrollStop(t)?(e.preventDefault(),this.$touchScrollingSub=t):this.$touchScrollingSub=null,this.menuScrollRefreshData(t),$.extend(s,{touchStartY:i.pageY,touchStartTime:e.timeStamp});else if(/move$/i.test(e.type)){var o=void 0!==s.touchY?s.touchY:s.touchStartY;if(void 0!==o&&o!=i.pageY){this.$touchScrollingSub=t;var a=i.pageY>o;void 0!==s.up&&s.up!=a&&$.extend(s,{touchStartY:i.pageY,touchStartTime:e.timeStamp}),$.extend(s,{up:a,touchY:i.pageY}),this.menuScroll(t,!0,Math.abs(i.pageY-o))}e.preventDefault()}else void 0!==s.touchY&&((s.momentum=15*Math.pow(Math.abs(i.pageY-s.touchStartY)/(e.timeStamp-s.touchStartTime),2))&&(this.menuScrollStop(t),this.menuScroll(t),e.preventDefault()),delete s.touchY)}}},menuShow:function(t){if((t.dataSM("beforefirstshowfired")||(t.dataSM("beforefirstshowfired",!0),this.$root.triggerHandler("beforefirstshow.smapi",t[0])!==!1))&&this.$root.triggerHandler("beforeshow.smapi",t[0])!==!1&&(t.dataSM("shown-before",!0),canAnimate&&t.stop(!0,!0),!t.is(":visible"))){var e=t.dataSM("parent-a"),i=this.isCollapsible();if((this.opts.keepHighlighted||i)&&e.addClass("highlighted"),i)t.removeClass("sm-nowrap").css({zIndex:"",width:"auto",minWidth:"",maxWidth:"",top:"",left:"",marginLeft:"",marginTop:""});else{if(t.css("z-index",this.zIndexInc=(this.zIndexInc||this.getStartZIndex())+1),(this.opts.subMenusMinWidth||this.opts.subMenusMaxWidth)&&(t.css({width:"auto",minWidth:"",maxWidth:""}).addClass("sm-nowrap"),this.opts.subMenusMinWidth&&t.css("min-width",this.opts.subMenusMinWidth),this.opts.subMenusMaxWidth)){var s=this.getWidth(t);t.css("max-width",this.opts.subMenusMaxWidth),s>this.getWidth(t)&&t.removeClass("sm-nowrap").css("width",this.opts.subMenusMaxWidth)}this.menuPosition(t)}var o=function(){t.css("overflow","")};i?canAnimate&&this.opts.collapsibleShowFunction?this.opts.collapsibleShowFunction.call(this,t,o):t.show(this.opts.collapsibleShowDuration,o):canAnimate&&this.opts.showFunction?this.opts.showFunction.call(this,t,o):t.show(this.opts.showDuration,o),e.attr("aria-expanded","true"),t.attr({"aria-expanded":"true","aria-hidden":"false"}),this.visibleSubMenus.push(t),this.$root.triggerHandler("show.smapi",t[0])}},popupHide:function(t){this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=0);var e=this;this.hideTimeout=setTimeout(function(){e.menuHideAll()},t?1:this.opts.hideTimeout)},popupShow:function(t,e){if(!this.opts.isPopup)return alert('SmartMenus jQuery Error:\n\nIf you want to show this menu via the "popupShow" method, set the isPopup:true option.'),void 0;if(this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=0),this.$root.dataSM("shown-before",!0),canAnimate&&this.$root.stop(!0,!0),!this.$root.is(":visible")){this.$root.css({left:t,top:e});var i=this,s=function(){i.$root.css("overflow","")};canAnimate&&this.opts.showFunction?this.opts.showFunction.call(this,this.$root,s):this.$root.show(this.opts.showDuration,s),this.visibleSubMenus[0]=this.$root}},refresh:function(){this.destroy(!0),this.init(!0)},rootKeyDown:function(t){if(this.handleEvents())switch(t.keyCode){case 27:var e=this.activatedItems[0];if(e){this.menuHideAll(),e[0].focus();var i=e.dataSM("sub");i&&this.menuHide(i)}break;case 32:var s=$(t.target);if(s.is("a")&&this.handleItemEvents(s)){var i=s.dataSM("sub");i&&!i.is(":visible")&&(this.itemClick({currentTarget:t.target}),t.preventDefault())}}},rootOut:function(t){if(this.handleEvents()&&!this.isTouchMode()&&t.target!=this.$root[0]&&(this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=0),!this.opts.showOnClick||!this.opts.hideOnClick)){var e=this;this.hideTimeout=setTimeout(function(){e.menuHideAll()},this.opts.hideTimeout)}},rootOver:function(t){this.handleEvents()&&!this.isTouchMode()&&t.target!=this.$root[0]&&this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=0)},winResize:function(t){if(this.handleEvents()){if(!("onorientationchange"in window)||"orientationchange"==t.type){var e=this.isCollapsible();this.wasCollapsible&&e||(this.activatedItems.length&&this.activatedItems[this.activatedItems.length-1][0].blur(),this.menuHideAll()),this.wasCollapsible=e}}else if(this.$disableOverlay){var i=this.$root.offset();this.$disableOverlay.css({top:i.top,left:i.left,width:this.$root.outerWidth(),height:this.$root.outerHeight()})}}}}),$.fn.dataSM=function(t,e){return e?this.data(t+"_smartmenus",e):this.data(t+"_smartmenus")},$.fn.removeDataSM=function(t){return this.removeData(t+"_smartmenus")},$.fn.smartmenus=function(options){if("string"==typeof options){var args=arguments,method=options;return Array.prototype.shift.call(args),this.each(function(){var t=$(this).data("smartmenus");t&&t[method]&&t[method].apply(t,args)})}return this.each(function(){var dataOpts=$(this).data("sm-options")||null;if(dataOpts)try{dataOpts=eval("("+dataOpts+")")}catch(e){dataOpts=null,alert('ERROR\n\nSmartMenus jQuery init:\nInvalid "data-sm-options" attribute value syntax.')}new $.SmartMenus(this,$.extend({},$.fn.smartmenus.defaults,options,dataOpts))})},$.fn.smartmenus.defaults={isPopup:!1,mainMenuSubOffsetX:0,mainMenuSubOffsetY:0,subMenusSubOffsetX:0,subMenusSubOffsetY:0,subMenusMinWidth:"10em",subMenusMaxWidth:"20em",subIndicators:!0,subIndicatorsPos:"append",subIndicatorsText:"",scrollStep:30,scrollAccelerate:!0,showTimeout:250,hideTimeout:500,showDuration:0,showFunction:null,hideDuration:0,hideFunction:function(t,e){t.fadeOut(200,e)},collapsibleShowDuration:0,collapsibleShowFunction:function(t,e){t.slideDown(200,e)},collapsibleHideDuration:0,collapsibleHideFunction:function(t,e){t.slideUp(200,e)},showOnClick:!1,hideOnClick:!0,noMouseOver:!1,keepInViewport:!0,keepHighlighted:!0,markCurrentItem:!1,markCurrentTree:!0,rightToLeftSubMenus:!1,bottomToTopSubMenus:!1,collapsibleBehavior:"default"},$}); \ No newline at end of file diff --git a/xess/doc/doxygen/menu.js b/xess/doc/doxygen/menu.js deleted file mode 100644 index 54e81cf..0000000 --- a/xess/doc/doxygen/menu.js +++ /dev/null @@ -1,127 +0,0 @@ -/* - @licstart The following is the entire license notice for the JavaScript code in this file. - - The MIT License (MIT) - - Copyright (C) 1997-2020 by Dimitri van Heesch - - Permission is hereby granted, free of charge, to any person obtaining a copy of this software - and associated documentation files (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, publish, distribute, - sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or - substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING - BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - @licend The above is the entire license notice for the JavaScript code in this file - */ -function initMenu(relPath,searchEnabled,serverSide,searchPage,search) { - function makeTree(data,relPath) { - var result=''; - if ('children' in data) { - result+=''; - } - return result; - } - var searchBox; - if (searchEnabled) { - if (serverSide) { - searchBox='
'+ - '
'+ - '
'+ - ''+ - '
'+ - '
'+ - '
'+ - '
'; - } else { - searchBox='
'+ - ''+ - ''+ - ''+ - ''+ - ''+ - '' - '' - '
'; - } - } - - $('#main-nav').before('
'+ - ''+ - ''+ - '
'); - $('#main-nav').append(makeTree(menudata,relPath)); - $('#main-nav').children(':first').addClass('sm sm-dox').attr('id','main-menu'); - if (searchBox) { - $('#main-menu').append('
  • '); - } - var $mainMenuState = $('#main-menu-state'); - var prevWidth = 0; - if ($mainMenuState.length) { - function initResizableIfExists() { - if (typeof initResizable==='function') initResizable(); - } - // animate mobile menu - $mainMenuState.change(function(e) { - var $menu = $('#main-menu'); - var options = { duration: 250, step: initResizableIfExists }; - if (this.checked) { - options['complete'] = function() { $menu.css('display', 'block') }; - $menu.hide().slideDown(options); - } else { - options['complete'] = function() { $menu.css('display', 'none') }; - $menu.show().slideUp(options); - } - }); - // set default menu visibility - function resetState() { - var $menu = $('#main-menu'); - var $mainMenuState = $('#main-menu-state'); - var newWidth = $(window).outerWidth(); - if (newWidth!=prevWidth) { - if ($(window).outerWidth()<768) { - $mainMenuState.prop('checked',false); $menu.hide(); - $('#searchBoxPos1').html(searchBox); - $('#searchBoxPos2').hide(); - } else { - $menu.show(); - $('#searchBoxPos1').empty(); - $('#searchBoxPos2').html(searchBox); - $('#searchBoxPos2').show(); - } - prevWidth = newWidth; - } - } - $(window).ready(function() { resetState(); initResizableIfExists(); }); - $(window).resize(resetState); - } - $('#main-menu').smartmenus(); -} -/* @license-end */ diff --git a/xess/doc/doxygen/menudata.js b/xess/doc/doxygen/menudata.js deleted file mode 100644 index e70f2aa..0000000 --- a/xess/doc/doxygen/menudata.js +++ /dev/null @@ -1,82 +0,0 @@ -/* - @licstart The following is the entire license notice for the JavaScript code in this file. - - The MIT License (MIT) - - Copyright (C) 1997-2020 by Dimitri van Heesch - - Permission is hereby granted, free of charge, to any person obtaining a copy of this software - and associated documentation files (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, publish, distribute, - sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or - substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING - BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - @licend The above is the entire license notice for the JavaScript code in this file -*/ -var menudata={children:[ -{text:"Main Page",url:"index.html"}, -{text:"Modules",url:"modules.html"}, -{text:"Data Structures",url:"annotated.html",children:[ -{text:"Data Structures",url:"annotated.html"}, -{text:"Data Structure Index",url:"classes.html"}, -{text:"Data Fields",url:"functions.html",children:[ -{text:"All",url:"functions.html",children:[ -{text:"a",url:"functions.html#index_a"}, -{text:"b",url:"functions.html#index_b"}, -{text:"c",url:"functions.html#index_c"}, -{text:"d",url:"functions.html#index_d"}, -{text:"e",url:"functions.html#index_e"}, -{text:"f",url:"functions.html#index_f"}, -{text:"g",url:"functions.html#index_g"}, -{text:"i",url:"functions.html#index_i"}, -{text:"j",url:"functions.html#index_j"}, -{text:"m",url:"functions.html#index_m"}, -{text:"o",url:"functions.html#index_o"}, -{text:"p",url:"functions.html#index_p"}, -{text:"q",url:"functions.html#index_q"}, -{text:"r",url:"functions.html#index_r"}, -{text:"t",url:"functions.html#index_t"}, -{text:"v",url:"functions.html#index_v"}, -{text:"x",url:"functions.html#index_x"}, -{text:"y",url:"functions.html#index_y"}]}, -{text:"Variables",url:"functions_vars.html",children:[ -{text:"a",url:"functions_vars.html#index_a"}, -{text:"b",url:"functions_vars.html#index_b"}, -{text:"c",url:"functions_vars.html#index_c"}, -{text:"d",url:"functions_vars.html#index_d"}, -{text:"e",url:"functions_vars.html#index_e"}, -{text:"f",url:"functions_vars.html#index_f"}, -{text:"g",url:"functions_vars.html#index_g"}, -{text:"i",url:"functions_vars.html#index_i"}, -{text:"j",url:"functions_vars.html#index_j"}, -{text:"m",url:"functions_vars.html#index_m"}, -{text:"o",url:"functions_vars.html#index_o"}, -{text:"p",url:"functions_vars.html#index_p"}, -{text:"q",url:"functions_vars.html#index_q"}, -{text:"r",url:"functions_vars.html#index_r"}, -{text:"t",url:"functions_vars.html#index_t"}, -{text:"v",url:"functions_vars.html#index_v"}, -{text:"x",url:"functions_vars.html#index_x"}, -{text:"y",url:"functions_vars.html#index_y"}]}]}]}, -{text:"Files",url:"files.html",children:[ -{text:"File List",url:"files.html"}, -{text:"Globals",url:"globals.html",children:[ -{text:"All",url:"globals.html",children:[ -{text:"_",url:"globals.html#index__5F"}, -{text:"s",url:"globals.html#index_s"}, -{text:"x",url:"globals.html#index_x"}]}, -{text:"Functions",url:"globals_func.html"}, -{text:"Typedefs",url:"globals_type.html"}, -{text:"Enumerations",url:"globals_enum.html"}, -{text:"Enumerator",url:"globals_eval.html",children:[ -{text:"x",url:"globals_eval.html#index_x"}]}, -{text:"Macros",url:"globals_defs.html"}]}]}]} diff --git a/xess/doc/doxygen/modules.html b/xess/doc/doxygen/modules.html deleted file mode 100644 index 21c39a5..0000000 --- a/xess/doc/doxygen/modules.html +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: Modules - - - - - - - - - - - - - -
    -
    - - - - - - - -
    -
    XeSS SDK API Reference Guide 1.0.0 -
    -
    -
    - - - - - - - -
    -
    - -
    -
    -
    - -
    - -
    -
    - - -
    - -
    - -
    -
    Modules
    -
    - -
    - - - - diff --git a/xess/doc/doxygen/modules.js b/xess/doc/doxygen/modules.js deleted file mode 100644 index 05560a0..0000000 --- a/xess/doc/doxygen/modules.js +++ /dev/null @@ -1,7 +0,0 @@ -var modules = -[ - [ "XeSS API exports", "group__xess.html", "group__xess" ], - [ "XeSS D3D12 API exports", "group__xess-d3d12.html", "group__xess-d3d12" ], - [ "XeSS D3D12 API debug exports", "group__xess-d3d12-debug.html", "group__xess-d3d12-debug" ], - [ "XeSS API debug exports", "group__xess-debug.html", "group__xess-debug" ] -]; \ No newline at end of file diff --git a/xess/doc/doxygen/nav_f.png b/xess/doc/doxygen/nav_f.png deleted file mode 100644 index 72a58a5..0000000 Binary files a/xess/doc/doxygen/nav_f.png and /dev/null differ diff --git a/xess/doc/doxygen/nav_g.png b/xess/doc/doxygen/nav_g.png deleted file mode 100644 index 2093a23..0000000 Binary files a/xess/doc/doxygen/nav_g.png and /dev/null differ diff --git a/xess/doc/doxygen/nav_h.png b/xess/doc/doxygen/nav_h.png deleted file mode 100644 index 33389b1..0000000 Binary files a/xess/doc/doxygen/nav_h.png and /dev/null differ diff --git a/xess/doc/doxygen/navtree.css b/xess/doc/doxygen/navtree.css deleted file mode 100644 index d8a311a..0000000 --- a/xess/doc/doxygen/navtree.css +++ /dev/null @@ -1,147 +0,0 @@ -#nav-tree .children_ul { - margin:0; - padding:4px; -} - -#nav-tree ul { - list-style:none outside none; - margin:0px; - padding:0px; -} - -#nav-tree li { - white-space:nowrap; - margin:0px; - padding:0px; -} - -#nav-tree .plus { - margin:0px; -} - -#nav-tree .selected { - background-image: url('tab_a.png'); - background-repeat:repeat-x; - color: #fff; - text-shadow: 0px 1px 1px rgba(0, 0, 0, 1.0); -} - -#nav-tree img { - margin:0px; - padding:0px; - border:0px; - vertical-align: middle; -} - -#nav-tree a { - text-decoration:none; - padding:0px; - margin:0px; - outline:none; -} - -#nav-tree .label { - margin:0px; - padding:0px; - font: 12px 'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; -} - -#nav-tree .label a { - padding:2px; -} - -#nav-tree .selected a { - text-decoration:none; - color:#fff; -} - -#nav-tree .children_ul { - margin:0px; - padding:0px; -} - -#nav-tree .item { - margin:0px; - padding:0px; -} - -#nav-tree { - padding: 0px 0px; - background-color: #FAFAFF; - font-size:14px; - overflow:auto; -} - -#doc-content { - overflow:auto; - display:block; - padding:0px; - margin:0px; - -webkit-overflow-scrolling : touch; /* iOS 5+ */ -} - -#side-nav { - padding:0 6px 0 0; - margin: 0px; - display:block; - position: absolute; - left: 0px; - width: 250px; - overflow : hidden; -} - -.ui-resizable .ui-resizable-handle { - display:block; -} - -.ui-resizable-e { - background-image:url("splitbar.png"); - background-size:100%; - background-repeat:repeat-y; - background-attachment: scroll; - cursor:ew-resize; - height:100%; - right:0; - top:0; - width:6px; -} - -.ui-resizable-handle { - display:none; - font-size:0.1px; - position:absolute; - z-index:1; -} - -#nav-tree-contents { - margin: 6px 0px 0px 0px; -} - -#nav-tree { - background-image:url('nav_h.png'); - background-repeat:repeat-x; - background-color: #F9FAFC; - -webkit-overflow-scrolling : touch; /* iOS 5+ */ -} - -#nav-sync { - position:absolute; - top:5px; - right:24px; - z-index:0; -} - -#nav-sync img { - opacity:0.3; -} - -#nav-sync img:hover { - opacity:0.9; -} - -@media print -{ - #nav-tree { display: none; } - div.ui-resizable-handle { display: none; position: relative; } -} - diff --git a/xess/doc/doxygen/navtree.js b/xess/doc/doxygen/navtree.js deleted file mode 100644 index 2798368..0000000 --- a/xess/doc/doxygen/navtree.js +++ /dev/null @@ -1,549 +0,0 @@ -/* - @licstart The following is the entire license notice for the JavaScript code in this file. - - The MIT License (MIT) - - Copyright (C) 1997-2020 by Dimitri van Heesch - - Permission is hereby granted, free of charge, to any person obtaining a copy of this software - and associated documentation files (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, publish, distribute, - sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or - substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING - BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - @licend The above is the entire license notice for the JavaScript code in this file - */ -var navTreeSubIndices = new Array(); -var arrowDown = '▼'; -var arrowRight = '►'; - -function getData(varName) -{ - var i = varName.lastIndexOf('/'); - var n = i>=0 ? varName.substring(i+1) : varName; - return eval(n.replace(/\-/g,'_')); -} - -function stripPath(uri) -{ - return uri.substring(uri.lastIndexOf('/')+1); -} - -function stripPath2(uri) -{ - var i = uri.lastIndexOf('/'); - var s = uri.substring(i+1); - var m = uri.substring(0,i+1).match(/\/d\w\/d\w\w\/$/); - return m ? uri.substring(i-6) : s; -} - -function hashValue() -{ - return $(location).attr('hash').substring(1).replace(/[^\w\-]/g,''); -} - -function hashUrl() -{ - return '#'+hashValue(); -} - -function pathName() -{ - return $(location).attr('pathname').replace(/[^-A-Za-z0-9+&@#/%?=~_|!:,.;\(\)]/g, ''); -} - -function localStorageSupported() -{ - try { - return 'localStorage' in window && window['localStorage'] !== null && window.localStorage.getItem; - } - catch(e) { - return false; - } -} - -function storeLink(link) -{ - if (!$("#nav-sync").hasClass('sync') && localStorageSupported()) { - window.localStorage.setItem('navpath',link); - } -} - -function deleteLink() -{ - if (localStorageSupported()) { - window.localStorage.setItem('navpath',''); - } -} - -function cachedLink() -{ - if (localStorageSupported()) { - return window.localStorage.getItem('navpath'); - } else { - return ''; - } -} - -function getScript(scriptName,func,show) -{ - var head = document.getElementsByTagName("head")[0]; - var script = document.createElement('script'); - script.id = scriptName; - script.type = 'text/javascript'; - script.onload = func; - script.src = scriptName+'.js'; - head.appendChild(script); -} - -function createIndent(o,domNode,node,level) -{ - var level=-1; - var n = node; - while (n.parentNode) { level++; n=n.parentNode; } - if (node.childrenData) { - var imgNode = document.createElement("span"); - imgNode.className = 'arrow'; - imgNode.style.paddingLeft=(16*level).toString()+'px'; - imgNode.innerHTML=arrowRight; - node.plus_img = imgNode; - node.expandToggle = document.createElement("a"); - node.expandToggle.href = "javascript:void(0)"; - node.expandToggle.onclick = function() { - if (node.expanded) { - $(node.getChildrenUL()).slideUp("fast"); - node.plus_img.innerHTML=arrowRight; - node.expanded = false; - } else { - expandNode(o, node, false, false); - } - } - node.expandToggle.appendChild(imgNode); - domNode.appendChild(node.expandToggle); - } else { - var span = document.createElement("span"); - span.className = 'arrow'; - span.style.width = 16*(level+1)+'px'; - span.innerHTML = ' '; - domNode.appendChild(span); - } -} - -var animationInProgress = false; - -function gotoAnchor(anchor,aname,updateLocation) -{ - var pos, docContent = $('#doc-content'); - var ancParent = $(anchor.parent()); - if (ancParent.hasClass('memItemLeft') || - ancParent.hasClass('memtitle') || - ancParent.hasClass('fieldname') || - ancParent.hasClass('fieldtype') || - ancParent.is(':header')) - { - pos = ancParent.position().top; - } else if (anchor.position()) { - pos = anchor.position().top; - } - if (pos) { - var dist = Math.abs(Math.min( - pos-docContent.offset().top, - docContent[0].scrollHeight- - docContent.height()-docContent.scrollTop())); - animationInProgress=true; - docContent.animate({ - scrollTop: pos + docContent.scrollTop() - docContent.offset().top - },Math.max(50,Math.min(500,dist)),function(){ - if (updateLocation) window.location.href=aname; - animationInProgress=false; - }); - } -} - -function newNode(o, po, text, link, childrenData, lastNode) -{ - var node = new Object(); - node.children = Array(); - node.childrenData = childrenData; - node.depth = po.depth + 1; - node.relpath = po.relpath; - node.isLast = lastNode; - - node.li = document.createElement("li"); - po.getChildrenUL().appendChild(node.li); - node.parentNode = po; - - node.itemDiv = document.createElement("div"); - node.itemDiv.className = "item"; - - node.labelSpan = document.createElement("span"); - node.labelSpan.className = "label"; - - createIndent(o,node.itemDiv,node,0); - node.itemDiv.appendChild(node.labelSpan); - node.li.appendChild(node.itemDiv); - - var a = document.createElement("a"); - node.labelSpan.appendChild(a); - node.label = document.createTextNode(text); - node.expanded = false; - a.appendChild(node.label); - if (link) { - var url; - if (link.substring(0,1)=='^') { - url = link.substring(1); - link = url; - } else { - url = node.relpath+link; - } - a.className = stripPath(link.replace('#',':')); - if (link.indexOf('#')!=-1) { - var aname = '#'+link.split('#')[1]; - var srcPage = stripPath(pathName()); - var targetPage = stripPath(link.split('#')[0]); - a.href = srcPage!=targetPage ? url : "javascript:void(0)"; - a.onclick = function(){ - storeLink(link); - if (!$(a).parent().parent().hasClass('selected')) - { - $('.item').removeClass('selected'); - $('.item').removeAttr('id'); - $(a).parent().parent().addClass('selected'); - $(a).parent().parent().attr('id','selected'); - } - var anchor = $(aname); - gotoAnchor(anchor,aname,true); - }; - } else { - a.href = url; - a.onclick = function() { storeLink(link); } - } - } else { - if (childrenData != null) - { - a.className = "nolink"; - a.href = "javascript:void(0)"; - a.onclick = node.expandToggle.onclick; - } - } - - node.childrenUL = null; - node.getChildrenUL = function() { - if (!node.childrenUL) { - node.childrenUL = document.createElement("ul"); - node.childrenUL.className = "children_ul"; - node.childrenUL.style.display = "none"; - node.li.appendChild(node.childrenUL); - } - return node.childrenUL; - }; - - return node; -} - -function showRoot() -{ - var headerHeight = $("#top").height(); - var footerHeight = $("#nav-path").height(); - var windowHeight = $(window).height() - headerHeight - footerHeight; - (function (){ // retry until we can scroll to the selected item - try { - var navtree=$('#nav-tree'); - navtree.scrollTo('#selected',100,{offset:-windowHeight/2}); - } catch (err) { - setTimeout(arguments.callee, 0); - } - })(); -} - -function expandNode(o, node, imm, showRoot) -{ - if (node.childrenData && !node.expanded) { - if (typeof(node.childrenData)==='string') { - var varName = node.childrenData; - getScript(node.relpath+varName,function(){ - node.childrenData = getData(varName); - expandNode(o, node, imm, showRoot); - }, showRoot); - } else { - if (!node.childrenVisited) { - getNode(o, node); - } - $(node.getChildrenUL()).slideDown("fast"); - node.plus_img.innerHTML = arrowDown; - node.expanded = true; - } - } -} - -function glowEffect(n,duration) -{ - n.addClass('glow').delay(duration).queue(function(next){ - $(this).removeClass('glow');next(); - }); -} - -function highlightAnchor() -{ - var aname = hashUrl(); - var anchor = $(aname); - if (anchor.parent().attr('class')=='memItemLeft'){ - var rows = $('.memberdecls tr[class$="'+hashValue()+'"]'); - glowEffect(rows.children(),300); // member without details - } else if (anchor.parent().attr('class')=='fieldname'){ - glowEffect(anchor.parent().parent(),1000); // enum value - } else if (anchor.parent().attr('class')=='fieldtype'){ - glowEffect(anchor.parent().parent(),1000); // struct field - } else if (anchor.parent().is(":header")) { - glowEffect(anchor.parent(),1000); // section header - } else { - glowEffect(anchor.next(),1000); // normal member - } -} - -function selectAndHighlight(hash,n) -{ - var a; - if (hash) { - var link=stripPath(pathName())+':'+hash.substring(1); - a=$('.item a[class$="'+link+'"]'); - } - if (a && a.length) { - a.parent().parent().addClass('selected'); - a.parent().parent().attr('id','selected'); - highlightAnchor(); - } else if (n) { - $(n.itemDiv).addClass('selected'); - $(n.itemDiv).attr('id','selected'); - } - var topOffset=5; - if (typeof page_layout!=='undefined' && page_layout==1) { - topOffset+=$('#top').outerHeight(); - } - if ($('#nav-tree-contents .item:first').hasClass('selected')) { - topOffset+=25; - } - $('#nav-sync').css('top',topOffset+'px'); - showRoot(); -} - -function showNode(o, node, index, hash) -{ - if (node && node.childrenData) { - if (typeof(node.childrenData)==='string') { - var varName = node.childrenData; - getScript(node.relpath+varName,function(){ - node.childrenData = getData(varName); - showNode(o,node,index,hash); - },true); - } else { - if (!node.childrenVisited) { - getNode(o, node); - } - $(node.getChildrenUL()).css({'display':'block'}); - node.plus_img.innerHTML = arrowDown; - node.expanded = true; - var n = node.children[o.breadcrumbs[index]]; - if (index+11) hash = '#'+parts[1].replace(/[^\w\-]/g,''); - else hash=''; - } - if (hash.match(/^#l\d+$/)) { - var anchor=$('a[name='+hash.substring(1)+']'); - glowEffect(anchor.parent(),1000); // line number - hash=''; // strip line number anchors - } - var url=root+hash; - var i=-1; - while (NAVTREEINDEX[i+1]<=url) i++; - if (i==-1) { i=0; root=NAVTREE[0][1]; } // fallback: show index - if (navTreeSubIndices[i]) { - gotoNode(o,i,root,hash,relpath) - } else { - getScript(relpath+'navtreeindex'+i,function(){ - navTreeSubIndices[i] = eval('NAVTREEINDEX'+i); - if (navTreeSubIndices[i]) { - gotoNode(o,i,root,hash,relpath); - } - },true); - } -} - -function showSyncOff(n,relpath) -{ - n.html(''); -} - -function showSyncOn(n,relpath) -{ - n.html(''); -} - -function toggleSyncButton(relpath) -{ - var navSync = $('#nav-sync'); - if (navSync.hasClass('sync')) { - navSync.removeClass('sync'); - showSyncOff(navSync,relpath); - storeLink(stripPath2(pathName())+hashUrl()); - } else { - navSync.addClass('sync'); - showSyncOn(navSync,relpath); - deleteLink(); - } -} - -var loadTriggered = false; -var readyTriggered = false; -var loadObject,loadToRoot,loadUrl,loadRelPath; - -$(window).on('load',function(){ - if (readyTriggered) { // ready first - navTo(loadObject,loadToRoot,loadUrl,loadRelPath); - showRoot(); - } - loadTriggered=true; -}); - -function initNavTree(toroot,relpath) -{ - var o = new Object(); - o.toroot = toroot; - o.node = new Object(); - o.node.li = document.getElementById("nav-tree-contents"); - o.node.childrenData = NAVTREE; - o.node.children = new Array(); - o.node.childrenUL = document.createElement("ul"); - o.node.getChildrenUL = function() { return o.node.childrenUL; }; - o.node.li.appendChild(o.node.childrenUL); - o.node.depth = 0; - o.node.relpath = relpath; - o.node.expanded = false; - o.node.isLast = true; - o.node.plus_img = document.createElement("span"); - o.node.plus_img.className = 'arrow'; - o.node.plus_img.innerHTML = arrowRight; - - if (localStorageSupported()) { - var navSync = $('#nav-sync'); - if (cachedLink()) { - showSyncOff(navSync,relpath); - navSync.removeClass('sync'); - } else { - showSyncOn(navSync,relpath); - } - navSync.click(function(){ toggleSyncButton(relpath); }); - } - - if (loadTriggered) { // load before ready - navTo(o,toroot,hashUrl(),relpath); - showRoot(); - } else { // ready before load - loadObject = o; - loadToRoot = toroot; - loadUrl = hashUrl(); - loadRelPath = relpath; - readyTriggered=true; - } - - $(window).bind('hashchange', function(){ - if (window.location.hash && window.location.hash.length>1){ - var a; - if ($(location).attr('hash')){ - var clslink=stripPath(pathName())+':'+hashValue(); - a=$('.item a[class$="'+clslink.replace(/=desktop_vp) { - if (!collapsed) { - collapseExpand(); - } - } else if (width>desktop_vp && collapsedWidth0) { - restoreWidth(0); - collapsed=true; - } - else { - var width = readCookie('width'); - if (width>200 && width<$(window).width()) { restoreWidth(width); } else { restoreWidth(200); } - collapsed=false; - } - } - - header = $("#top"); - sidenav = $("#side-nav"); - content = $("#doc-content"); - navtree = $("#nav-tree"); - footer = $("#nav-path"); - $(".side-nav-resizable").resizable({resize: function(e, ui) { resizeWidth(); } }); - $(sidenav).resizable({ minWidth: 0 }); - $(window).resize(function() { resizeHeight(); }); - var device = navigator.userAgent.toLowerCase(); - var touch_device = device.match(/(iphone|ipod|ipad|android)/); - if (touch_device) { /* wider split bar for touch only devices */ - $(sidenav).css({ paddingRight:'20px' }); - $('.ui-resizable-e').css({ width:'20px' }); - $('#nav-sync').css({ right:'34px' }); - barWidth=20; - } - var width = readCookie('width'); - if (width) { restoreWidth(width); } else { resizeWidth(); } - resizeHeight(); - var url = location.href; - var i=url.indexOf("#"); - if (i>=0) window.location.hash=url.substr(i); - var _preventDefault = function(evt) { evt.preventDefault(); }; - $("#splitbar").bind("dragstart", _preventDefault).bind("selectstart", _preventDefault); - $(".ui-resizable-handle").dblclick(collapseExpand); - $(window).on('load',resizeHeight); -} -/* @license-end */ diff --git a/xess/doc/doxygen/search/all_0.html b/xess/doc/doxygen/search/all_0.html deleted file mode 100644 index c36c9af..0000000 --- a/xess/doc/doxygen/search/all_0.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/all_0.js b/xess/doc/doxygen/search/all_0.js deleted file mode 100644 index 5da476c..0000000 --- a/xess/doc/doxygen/search/all_0.js +++ /dev/null @@ -1,18 +0,0 @@ -var searchData= -[ - ['_5fxess_5f2d_5ft_0',['_xess_2d_t',['../struct__xess__2d__t.html',1,'']]], - ['_5fxess_5fd3d12_5fexecute_5fparams_5ft_1',['_xess_d3d12_execute_params_t',['../struct__xess__d3d12__execute__params__t.html',1,'']]], - ['_5fxess_5fd3d12_5finit_5fparams_5ft_2',['_xess_d3d12_init_params_t',['../struct__xess__d3d12__init__params__t.html',1,'']]], - ['_5fxess_5fdump_5felement_5fbits_5ft_3',['_xess_dump_element_bits_t',['../xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83',1,'xess_debug.h']]], - ['_5fxess_5fdump_5fparameters_5ft_4',['_xess_dump_parameters_t',['../struct__xess__dump__parameters__t.html',1,'']]], - ['_5fxess_5finit_5fflags_5ft_5',['_xess_init_flags_t',['../xess_8h.html#a4f25323a8c073a84d49a93e0cdeaddf1',1,'xess.h']]], - ['_5fxess_5flogging_5flevel_5ft_6',['_xess_logging_level_t',['../xess_8h.html#a12f0fd50664b1a61319821499ec24721',1,'xess.h']]], - ['_5fxess_5fnetwork_5fmodel_5ft_7',['_xess_network_model_t',['../xess__debug_8h.html#ace50e033796a986a57623170306b41ed',1,'xess_debug.h']]], - ['_5fxess_5fprofiled_5fframe_5fdata_5ft_8',['_xess_profiled_frame_data_t',['../struct__xess__profiled__frame__data__t.html',1,'']]], - ['_5fxess_5fprofiling_5fdata_5ft_9',['_xess_profiling_data_t',['../struct__xess__profiling__data__t.html',1,'']]], - ['_5fxess_5fproperties_5ft_10',['_xess_properties_t',['../struct__xess__properties__t.html',1,'']]], - ['_5fxess_5fquality_5fsettings_5ft_11',['_xess_quality_settings_t',['../xess_8h.html#acc1be3e82183f25c7188fa6b5cbf1e34',1,'xess.h']]], - ['_5fxess_5fresources_5fto_5fdump_5ft_12',['_xess_resources_to_dump_t',['../struct__xess__resources__to__dump__t.html',1,'']]], - ['_5fxess_5fresult_5ft_13',['_xess_result_t',['../xess_8h.html#a31952a580a4d5d26c6224183f62d2612',1,'xess.h']]], - ['_5fxess_5fversion_5ft_14',['_xess_version_t',['../struct__xess__version__t.html',1,'']]] -]; diff --git a/xess/doc/doxygen/search/all_1.html b/xess/doc/doxygen/search/all_1.html deleted file mode 100644 index 91cfe8a..0000000 --- a/xess/doc/doxygen/search/all_1.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/all_1.js b/xess/doc/doxygen/search/all_1.js deleted file mode 100644 index eab109b..0000000 --- a/xess/doc/doxygen/search/all_1.js +++ /dev/null @@ -1,5 +0,0 @@ -var searchData= -[ - ['any_5fprofiling_5fdata_5fin_5fflight_0',['any_profiling_data_in_flight',['../struct__xess__profiling__data__t.html#a7ce6d3494f6a8695edf94fcad38c455e',1,'_xess_profiling_data_t']]], - ['as_5ftensor_1',['as_tensor',['../struct__xess__resources__to__dump__t.html#a055a00bb33a3ade096f537cee6d614ca',1,'_xess_resources_to_dump_t']]] -]; diff --git a/xess/doc/doxygen/search/all_10.html b/xess/doc/doxygen/search/all_10.html deleted file mode 100644 index 765f584..0000000 --- a/xess/doc/doxygen/search/all_10.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/all_10.js b/xess/doc/doxygen/search/all_10.js deleted file mode 100644 index fb096f6..0000000 --- a/xess/doc/doxygen/search/all_10.js +++ /dev/null @@ -1,9 +0,0 @@ -var searchData= -[ - ['tempbufferheapsize_0',['tempBufferHeapSize',['../struct__xess__properties__t.html#a0db8617705e860098e048d7f3e5466ff',1,'_xess_properties_t']]], - ['temptextureheapsize_1',['tempTextureHeapSize',['../struct__xess__properties__t.html#a209e8c58699154a12ca8c51d190565ee',1,'_xess_properties_t']]], - ['tensor_5fchannel_5fcount_2',['tensor_channel_count',['../struct__xess__resources__to__dump__t.html#ae59e9714ae9a69c614783e31a585a221',1,'_xess_resources_to_dump_t']]], - ['tensor_5fheight_3',['tensor_height',['../struct__xess__resources__to__dump__t.html#a7d6bf0ceee8b6abbb2678a630531e4fb',1,'_xess_resources_to_dump_t']]], - ['tensor_5fwidth_4',['tensor_width',['../struct__xess__resources__to__dump__t.html#a1b5c859fbf4a5eb748d5381e6063f673',1,'_xess_resources_to_dump_t']]], - ['textureheapoffset_5',['textureHeapOffset',['../struct__xess__d3d12__init__params__t.html#a9e2ba8ca5471d07e4bb30183deb00e56',1,'_xess_d3d12_init_params_t']]] -]; diff --git a/xess/doc/doxygen/search/all_11.html b/xess/doc/doxygen/search/all_11.html deleted file mode 100644 index e2183ee..0000000 --- a/xess/doc/doxygen/search/all_11.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/all_11.js b/xess/doc/doxygen/search/all_11.js deleted file mode 100644 index 88216c6..0000000 --- a/xess/doc/doxygen/search/all_11.js +++ /dev/null @@ -1,4 +0,0 @@ -var searchData= -[ - ['visiblenodemask_0',['visibleNodeMask',['../struct__xess__d3d12__init__params__t.html#a153b79c833ddce15c33d78691a679ca3',1,'_xess_d3d12_init_params_t']]] -]; diff --git a/xess/doc/doxygen/search/all_12.html b/xess/doc/doxygen/search/all_12.html deleted file mode 100644 index 9b9621c..0000000 --- a/xess/doc/doxygen/search/all_12.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/all_12.js b/xess/doc/doxygen/search/all_12.js deleted file mode 100644 index 56c3063..0000000 --- a/xess/doc/doxygen/search/all_12.js +++ /dev/null @@ -1,97 +0,0 @@ -var searchData= -[ - ['x_0',['x',['../struct__xess__2d__t.html#aae8a40a17c0be29c1f06ca6b4f9e2235',1,'_xess_2d_t']]], - ['xess_20api_20debug_20exports_1',['XeSS API debug exports',['../group__xess-debug.html',1,'']]], - ['xess_20api_20exports_2',['XeSS API exports',['../group__xess.html',1,'']]], - ['xess_20d3d12_20api_20debug_20exports_3',['XeSS D3D12 API debug exports',['../group__xess-d3d12-debug.html',1,'']]], - ['xess_20d3d12_20api_20exports_4',['XeSS D3D12 API exports',['../group__xess-d3d12.html',1,'']]], - ['xess_20sdk_5',['XeSS SDK',['../index.html',1,'']]], - ['xess_2eh_6',['xess.h',['../xess_8h.html',1,'']]], - ['xess_5f2d_5ft_7',['xess_2d_t',['../xess_8h.html#a3839d654f9989ed64bc09f3a93f16bbb',1,'xess.h']]], - ['xess_5fapi_8',['XESS_API',['../xess_8h.html#ac7ba74abaad1e5cf4ca1fffa7fee838c',1,'xess.h']]], - ['xess_5fapp_5flog_5fcallback_5ft_9',['xess_app_log_callback_t',['../xess_8h.html#a6c757a86356ec78ea12f7a0569a945f8',1,'xess.h']]], - ['xess_5fcontext_5fhandle_5ft_10',['xess_context_handle_t',['../xess_8h.html#af31f441c4909f7bbf9fb4491b5f9b927',1,'xess.h']]], - ['xess_5fcoord_5ft_11',['xess_coord_t',['../xess_8h.html#ab4b757ead636df148ed7dbcaf8a86d2f',1,'xess.h']]], - ['xess_5fd3d12_2eh_12',['xess_d3d12.h',['../xess__d3d12_8h.html',1,'']]], - ['xess_5fd3d12_5fdebug_2eh_13',['xess_d3d12_debug.h',['../xess__d3d12__debug_8h.html',1,'']]], - ['xess_5fd3d12_5fdebug_5fenable_5fprofiling_14',['XESS_D3D12_DEBUG_ENABLE_PROFILING',['../xess__d3d12__debug_8h.html#ad587f5e54cc2f41c539dd8983e248cb2',1,'xess_d3d12_debug.h']]], - ['xess_5fd3d12_5fexecute_5fparams_5ft_15',['xess_d3d12_execute_params_t',['../xess__d3d12_8h.html#a013d859444728ce4c0b3b95e5437caf5',1,'xess_d3d12.h']]], - ['xess_5fd3d12_5finit_5fparams_5ft_16',['xess_d3d12_init_params_t',['../xess__d3d12_8h.html#a8738b1b1df89db7fcdb1647af648c7d7',1,'xess_d3d12.h']]], - ['xess_5fdebug_2eh_17',['xess_debug.h',['../xess__debug_8h.html',1,'']]], - ['xess_5fdump_5fall_18',['XESS_DUMP_ALL',['../xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83a312ca9873e04595421188f6345d28f82',1,'xess_debug.h']]], - ['xess_5fdump_5fall_5finputs_19',['XESS_DUMP_ALL_INPUTS',['../xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83a5bde5b4edb7c99106b7ad168d3da89fe',1,'xess_debug.h']]], - ['xess_5fdump_5felement_5fbits_5ft_20',['xess_dump_element_bits_t',['../xess__debug_8h.html#a516d71b76c0d19198beed6465eb4535c',1,'xess_debug.h']]], - ['xess_5fdump_5felements_5fmask_5ft_21',['xess_dump_elements_mask_t',['../xess__debug_8h.html#a508c6f679546883d9c849cbfd3615363',1,'xess_debug.h']]], - ['xess_5fdump_5fexecution_5fparameters_22',['XESS_DUMP_EXECUTION_PARAMETERS',['../xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83a60e0f8ed79622d3f7e4588a658fc484a',1,'xess_debug.h']]], - ['xess_5fdump_5fhistory_23',['XESS_DUMP_HISTORY',['../xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83ae98ac97ee61128c3b0632a8ccbefc6bc',1,'xess_debug.h']]], - ['xess_5fdump_5finput_5fcolor_24',['XESS_DUMP_INPUT_COLOR',['../xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83a623a94758729c9bcdc65df0547b1974f',1,'xess_debug.h']]], - ['xess_5fdump_5finput_5fdepth_25',['XESS_DUMP_INPUT_DEPTH',['../xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83aa9f414176cfe6c87f0e7b62d60976a88',1,'xess_debug.h']]], - ['xess_5fdump_5finput_5fexposure_5fscale_26',['XESS_DUMP_INPUT_EXPOSURE_SCALE',['../xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83a89c37b4f5e86951bddd55fb8a5164bcc',1,'xess_debug.h']]], - ['xess_5fdump_5finput_5fresponsive_5fpixel_5fmask_27',['XESS_DUMP_INPUT_RESPONSIVE_PIXEL_MASK',['../xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83a002eada067830ed6c0aa36fbc60a21f2',1,'xess_debug.h']]], - ['xess_5fdump_5finput_5fvelocity_28',['XESS_DUMP_INPUT_VELOCITY',['../xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83a660e96b09d4656899f05260d1e7622a3',1,'xess_debug.h']]], - ['xess_5fdump_5foutput_29',['XESS_DUMP_OUTPUT',['../xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83ab5fabbdd4efc47253723dd02ac132121',1,'xess_debug.h']]], - ['xess_5fdump_5fparameters_5ft_30',['xess_dump_parameters_t',['../xess__debug_8h.html#a7a40b052b76b6b70177eb6bca388a214',1,'xess_debug.h']]], - ['xess_5finit_5fflag_5fexposure_5fscale_5ftexture_31',['XESS_INIT_FLAG_EXPOSURE_SCALE_TEXTURE',['../xess_8h.html#a4f25323a8c073a84d49a93e0cdeaddf1a99164122cf8c776c7ce5bfdfe3fd0492',1,'xess.h']]], - ['xess_5finit_5fflag_5fexternal_5fdescriptor_5fheap_32',['XESS_INIT_FLAG_EXTERNAL_DESCRIPTOR_HEAP',['../xess_8h.html#a4f25323a8c073a84d49a93e0cdeaddf1a7a765c7ec24c2b4193baf2e0a30fb4c7',1,'xess.h']]], - ['xess_5finit_5fflag_5fhigh_5fres_5fmv_33',['XESS_INIT_FLAG_HIGH_RES_MV',['../xess_8h.html#a4f25323a8c073a84d49a93e0cdeaddf1a88dbf4a687acc9bd1281778570c7c757',1,'xess.h']]], - ['xess_5finit_5fflag_5finverted_5fdepth_34',['XESS_INIT_FLAG_INVERTED_DEPTH',['../xess_8h.html#a4f25323a8c073a84d49a93e0cdeaddf1a91fe3728f6cafc03e6da0a064389859a',1,'xess.h']]], - ['xess_5finit_5fflag_5fjittered_5fmv_35',['XESS_INIT_FLAG_JITTERED_MV',['../xess_8h.html#a4f25323a8c073a84d49a93e0cdeaddf1a8390a8a09d1f38a88608644929954028',1,'xess.h']]], - ['xess_5finit_5fflag_5fldr_5finput_5fcolor_36',['XESS_INIT_FLAG_LDR_INPUT_COLOR',['../xess_8h.html#a4f25323a8c073a84d49a93e0cdeaddf1a0eb16d799c44bab1bbf3c59dfd97ceb9',1,'xess.h']]], - ['xess_5finit_5fflag_5fnone_37',['XESS_INIT_FLAG_NONE',['../xess_8h.html#a4f25323a8c073a84d49a93e0cdeaddf1a93cdd13324042072081453aeaadf0e1e',1,'xess.h']]], - ['xess_5finit_5fflag_5fresponsive_5fpixel_5fmask_38',['XESS_INIT_FLAG_RESPONSIVE_PIXEL_MASK',['../xess_8h.html#a4f25323a8c073a84d49a93e0cdeaddf1ad1f14cc0ac79131e639d3bab61c5f48c',1,'xess.h']]], - ['xess_5finit_5fflag_5fuse_5fndc_5fvelocity_39',['XESS_INIT_FLAG_USE_NDC_VELOCITY',['../xess_8h.html#a4f25323a8c073a84d49a93e0cdeaddf1a2c868f941d0829edc844b93bd76cf0f2',1,'xess.h']]], - ['xess_5finit_5fflags_5ft_40',['xess_init_flags_t',['../xess_8h.html#a4d9dd06b8ad6424f988f53522f8969a8',1,'xess.h']]], - ['xess_5flogging_5flevel_5fdebug_41',['XESS_LOGGING_LEVEL_DEBUG',['../xess_8h.html#a12f0fd50664b1a61319821499ec24721a526588cb8c0fe38b7bb35479bd44b710',1,'xess.h']]], - ['xess_5flogging_5flevel_5ferror_42',['XESS_LOGGING_LEVEL_ERROR',['../xess_8h.html#a12f0fd50664b1a61319821499ec24721a7142dcde3f8100558086ad32c674242b',1,'xess.h']]], - ['xess_5flogging_5flevel_5finfo_43',['XESS_LOGGING_LEVEL_INFO',['../xess_8h.html#a12f0fd50664b1a61319821499ec24721a02d7dfe8174efddabcf108baf804b4a6',1,'xess.h']]], - ['xess_5flogging_5flevel_5ft_44',['xess_logging_level_t',['../xess_8h.html#a6432053aa5103ccd9df8618a7eaaacb8',1,'xess.h']]], - ['xess_5flogging_5flevel_5fwarning_45',['XESS_LOGGING_LEVEL_WARNING',['../xess_8h.html#a12f0fd50664b1a61319821499ec24721a089568d56d50438813be38513b886486',1,'xess.h']]], - ['xess_5fnetwork_5fmodel_5fkpss_46',['XESS_NETWORK_MODEL_KPSS',['../xess__debug_8h.html#ace50e033796a986a57623170306b41eda1489add6542185904900e0b6796b8215',1,'xess_debug.h']]], - ['xess_5fnetwork_5fmodel_5fsplat_47',['XESS_NETWORK_MODEL_SPLAT',['../xess__debug_8h.html#ace50e033796a986a57623170306b41eda89d379244951ad3c2988a0d303b4a0cb',1,'xess_debug.h']]], - ['xess_5fnetwork_5fmodel_5ft_48',['xess_network_model_t',['../xess__debug_8h.html#a0f8d91004ab90548549da8adb0d4f195',1,'xess_debug.h']]], - ['xess_5fpack_5fb_49',['XESS_PACK_B',['../xess_8h.html#a3c68605bee1e217a930c4ae6aa218fd1',1,'xess.h']]], - ['xess_5fpack_5fb_5fx_50',['XESS_PACK_B_X',['../xess_8h.html#a0cbf0d6231ec6ae03e685f2ddee69a95',1,'xess.h']]], - ['xess_5fpack_5fe_51',['XESS_PACK_E',['../xess_8h.html#a36808d4ffd35a951c364418a19468cf8',1,'xess.h']]], - ['xess_5fpragma_52',['XESS_PRAGMA',['../xess_8h.html#af3af4f4afda4277313b1b91dbf1f7497',1,'xess.h']]], - ['xess_5fprofiled_5fframe_5fdata_5ft_53',['xess_profiled_frame_data_t',['../xess__d3d12__debug_8h.html#a8fb30e1bc4f2c5e8dab3d8a80c30e3be',1,'xess_d3d12_debug.h']]], - ['xess_5fprofiling_5fdata_5ft_54',['xess_profiling_data_t',['../xess__d3d12__debug_8h.html#ad7d2b8797e2ede0f09b73e1a240583f9',1,'xess_d3d12_debug.h']]], - ['xess_5fproperties_5ft_55',['xess_properties_t',['../xess_8h.html#a81c9ce6225897595f26130f90c41f3e2',1,'xess.h']]], - ['xess_5fquality_5fsetting_5fbalanced_56',['XESS_QUALITY_SETTING_BALANCED',['../xess_8h.html#acc1be3e82183f25c7188fa6b5cbf1e34af42585b087b48ac84f15147eca7f84fc',1,'xess.h']]], - ['xess_5fquality_5fsetting_5fperformance_57',['XESS_QUALITY_SETTING_PERFORMANCE',['../xess_8h.html#acc1be3e82183f25c7188fa6b5cbf1e34a375807073d5e41d49599bc4c3796a298',1,'xess.h']]], - ['xess_5fquality_5fsetting_5fquality_58',['XESS_QUALITY_SETTING_QUALITY',['../xess_8h.html#acc1be3e82183f25c7188fa6b5cbf1e34aad6611bfc9d8b4367d40cc4341781071',1,'xess.h']]], - ['xess_5fquality_5fsetting_5fultra_5fquality_59',['XESS_QUALITY_SETTING_ULTRA_QUALITY',['../xess_8h.html#acc1be3e82183f25c7188fa6b5cbf1e34a2307f69631f48661ec35997e6b9dfa7b',1,'xess.h']]], - ['xess_5fquality_5fsettings_5ft_60',['xess_quality_settings_t',['../xess_8h.html#a2a85ea1304caf14b2c008457ee75c7cc',1,'xess.h']]], - ['xess_5fresources_5fto_5fdump_5ft_61',['xess_resources_to_dump_t',['../xess__d3d12__debug_8h.html#a16c2ebf61da2c3a48f3c985c1fb9b8e7',1,'xess_d3d12_debug.h']]], - ['xess_5fresult_5ferror_5fcant_5fload_5flibrary_62',['XESS_RESULT_ERROR_CANT_LOAD_LIBRARY',['../xess_8h.html#a31952a580a4d5d26c6224183f62d2612ab0c58d47a6858d66925b00e17bda81f5',1,'xess.h']]], - ['xess_5fresult_5ferror_5fdevice_63',['XESS_RESULT_ERROR_DEVICE',['../xess_8h.html#a31952a580a4d5d26c6224183f62d2612a47d58f63ff4815586df793c60eed4dc0',1,'xess.h']]], - ['xess_5fresult_5ferror_5fdevice_5fout_5fof_5fmemory_64',['XESS_RESULT_ERROR_DEVICE_OUT_OF_MEMORY',['../xess_8h.html#a31952a580a4d5d26c6224183f62d2612ac8e207e9005b05302499f10cda8d58f5',1,'xess.h']]], - ['xess_5fresult_5ferror_5finvalid_5fargument_65',['XESS_RESULT_ERROR_INVALID_ARGUMENT',['../xess_8h.html#a31952a580a4d5d26c6224183f62d2612a30021fa62d2929cc6bf0d47d07e3c59e',1,'xess.h']]], - ['xess_5fresult_5ferror_5finvalid_5fcontext_66',['XESS_RESULT_ERROR_INVALID_CONTEXT',['../xess_8h.html#a31952a580a4d5d26c6224183f62d2612a27d5e96802336368594096df18a1ae06',1,'xess.h']]], - ['xess_5fresult_5ferror_5fnot_5fimplemented_67',['XESS_RESULT_ERROR_NOT_IMPLEMENTED',['../xess_8h.html#a31952a580a4d5d26c6224183f62d2612a1953e4a40daecb661d97b031c38ce1f6',1,'xess.h']]], - ['xess_5fresult_5ferror_5foperation_5fin_5fprogress_68',['XESS_RESULT_ERROR_OPERATION_IN_PROGRESS',['../xess_8h.html#a31952a580a4d5d26c6224183f62d2612a8ca9ff62f59f7b647e62dc3c52ec6ac8',1,'xess.h']]], - ['xess_5fresult_5ferror_5funinitialized_69',['XESS_RESULT_ERROR_UNINITIALIZED',['../xess_8h.html#a31952a580a4d5d26c6224183f62d2612a635c3fdf5ff04d037167f1cb37d46e23',1,'xess.h']]], - ['xess_5fresult_5ferror_5funknown_70',['XESS_RESULT_ERROR_UNKNOWN',['../xess_8h.html#a31952a580a4d5d26c6224183f62d2612a1a08d6aec7e38e2f0bd03893c05b9d2f',1,'xess.h']]], - ['xess_5fresult_5ferror_5funsupported_71',['XESS_RESULT_ERROR_UNSUPPORTED',['../xess_8h.html#a31952a580a4d5d26c6224183f62d2612aa1255da83c4c0fcc2b4a2d7bb4af02bf',1,'xess.h']]], - ['xess_5fresult_5ferror_5funsupported_5fdevice_72',['XESS_RESULT_ERROR_UNSUPPORTED_DEVICE',['../xess_8h.html#a31952a580a4d5d26c6224183f62d2612a00eab4ebb1fb95a65e2b4d82981fb3f8',1,'xess.h']]], - ['xess_5fresult_5ferror_5funsupported_5fdriver_73',['XESS_RESULT_ERROR_UNSUPPORTED_DRIVER',['../xess_8h.html#a31952a580a4d5d26c6224183f62d2612a15bd2bd2e7ae00b9ddd87fa5a43b1ee2',1,'xess.h']]], - ['xess_5fresult_5fsuccess_74',['XESS_RESULT_SUCCESS',['../xess_8h.html#a31952a580a4d5d26c6224183f62d2612afd64586bcb0f0638509e4ae5506c72cf',1,'xess.h']]], - ['xess_5fresult_5ft_75',['xess_result_t',['../xess_8h.html#a3aa6a07808627ac723a9da324abf10b4',1,'xess.h']]], - ['xess_5fresult_5fwarning_5fnonexisting_5ffolder_76',['XESS_RESULT_WARNING_NONEXISTING_FOLDER',['../xess_8h.html#a31952a580a4d5d26c6224183f62d2612a7f8d0f6dc01ba497911fdbdb02b05a45',1,'xess.h']]], - ['xess_5fversion_5ft_77',['xess_version_t',['../xess_8h.html#a5b198528154044a5bc33a464e62d34a0',1,'xess.h']]], - ['xessd3d12buildpipelines_78',['xessD3D12BuildPipelines',['../group__xess-d3d12.html#gac39e8fcd2d1575ab36e54aacbc3d3b6a',1,'xess_d3d12.h']]], - ['xessd3d12createcontext_79',['xessD3D12CreateContext',['../group__xess-d3d12.html#ga6b15c60fbdeefc17a1064950c90d2e2d',1,'xess_d3d12.h']]], - ['xessd3d12execute_80',['xessD3D12Execute',['../group__xess-d3d12.html#gaf8e15aa3a0915546fdfcaa899f58c102',1,'xess_d3d12.h']]], - ['xessd3d12getprofilingdata_81',['xessD3D12GetProfilingData',['../group__xess-d3d12-debug.html#ga3a8e8bee0b8ba06871c765648202c938',1,'xess_d3d12_debug.h']]], - ['xessd3d12getresourcestodump_82',['xessD3D12GetResourcesToDump',['../group__xess-d3d12-debug.html#gaf62cb7b5e756de611a19896a5248c92b',1,'xess_d3d12_debug.h']]], - ['xessd3d12init_83',['xessD3D12Init',['../group__xess-d3d12.html#gafb211935ba10efefc5a7063b276fce31',1,'xess_d3d12.h']]], - ['xessdestroycontext_84',['xessDestroyContext',['../group__xess.html#gae5d88d9bdb50033ab254aa2e692c9bc0',1,'xess.h']]], - ['xessgetinputresolution_85',['xessGetInputResolution',['../group__xess.html#ga6ed6ab924e0a41ff56485b562acd5073',1,'xess.h']]], - ['xessgetintelxefxversion_86',['xessGetIntelXeFXVersion',['../group__xess.html#ga88ea52641806d14ef5a4995b5d78ea91',1,'xess.h']]], - ['xessgetproperties_87',['xessGetProperties',['../group__xess.html#gaae4893a4bfed059402ca55f256738773',1,'xess.h']]], - ['xessgetversion_88',['xessGetVersion',['../group__xess.html#ga0fc6e0c7b21322a0af96f1ee1e4667d3',1,'xess.h']]], - ['xessselectnetworkmodel_89',['xessSelectNetworkModel',['../group__xess-debug.html#ga596f2374ff85d63d430d885da295818b',1,'xess_debug.h']]], - ['xesssetjitterscale_90',['xessSetJitterScale',['../group__xess.html#ga30e9bee98f90568e6a9d39bd7d1ccd74',1,'xess.h']]], - ['xesssetloggingcallback_91',['xessSetLoggingCallback',['../group__xess.html#gaaf68a347af5e5c9c1e518f0bc5daaf1c',1,'xess.h']]], - ['xesssetvelocityscale_92',['xessSetVelocityScale',['../group__xess.html#ga0f95b12fe2611b877d72efdd9f050639',1,'xess.h']]], - ['xessstartdump_93',['xessStartDump',['../group__xess-debug.html#gaa320ed0d9c03d6abb26f37647b12db7e',1,'xess_debug.h']]] -]; diff --git a/xess/doc/doxygen/search/all_13.html b/xess/doc/doxygen/search/all_13.html deleted file mode 100644 index 4acb7f9..0000000 --- a/xess/doc/doxygen/search/all_13.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/all_13.js b/xess/doc/doxygen/search/all_13.js deleted file mode 100644 index f63239b..0000000 --- a/xess/doc/doxygen/search/all_13.js +++ /dev/null @@ -1,4 +0,0 @@ -var searchData= -[ - ['y_0',['y',['../struct__xess__2d__t.html#a9c02f93c9698e4486878867c4f265c48',1,'_xess_2d_t']]] -]; diff --git a/xess/doc/doxygen/search/all_2.html b/xess/doc/doxygen/search/all_2.html deleted file mode 100644 index 259dde4..0000000 --- a/xess/doc/doxygen/search/all_2.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/all_2.js b/xess/doc/doxygen/search/all_2.js deleted file mode 100644 index b64d219..0000000 --- a/xess/doc/doxygen/search/all_2.js +++ /dev/null @@ -1,5 +0,0 @@ -var searchData= -[ - ['border_5fpixels_5fto_5fskip_5fcount_0',['border_pixels_to_skip_count',['../struct__xess__resources__to__dump__t.html#a4b329d03d60ffb48e496e41169018a31',1,'_xess_resources_to_dump_t']]], - ['bufferheapoffset_1',['bufferHeapOffset',['../struct__xess__d3d12__init__params__t.html#aca551e5731fdfe7679b6f3e24cc01d0c',1,'_xess_d3d12_init_params_t']]] -]; diff --git a/xess/doc/doxygen/search/all_3.html b/xess/doc/doxygen/search/all_3.html deleted file mode 100644 index 1e60c94..0000000 --- a/xess/doc/doxygen/search/all_3.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/all_3.js b/xess/doc/doxygen/search/all_3.js deleted file mode 100644 index f0a7e8e..0000000 --- a/xess/doc/doxygen/search/all_3.js +++ /dev/null @@ -1,4 +0,0 @@ -var searchData= -[ - ['creationnodemask_0',['creationNodeMask',['../struct__xess__d3d12__init__params__t.html#a5a826e34a732802a584fc78091837dc4',1,'_xess_d3d12_init_params_t']]] -]; diff --git a/xess/doc/doxygen/search/all_4.html b/xess/doc/doxygen/search/all_4.html deleted file mode 100644 index 08f1aed..0000000 --- a/xess/doc/doxygen/search/all_4.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/all_4.js b/xess/doc/doxygen/search/all_4.js deleted file mode 100644 index dd85e09..0000000 --- a/xess/doc/doxygen/search/all_4.js +++ /dev/null @@ -1,5 +0,0 @@ -var searchData= -[ - ['descriptorheapoffset_0',['descriptorHeapOffset',['../struct__xess__d3d12__execute__params__t.html#ab718f6c8f437c74e2ad08ace9ee9f130',1,'_xess_d3d12_execute_params_t']]], - ['dump_5felements_5fmask_1',['dump_elements_mask',['../struct__xess__dump__parameters__t.html#a1dd8e9870444dc41b3c1602b15dae269',1,'_xess_dump_parameters_t']]] -]; diff --git a/xess/doc/doxygen/search/all_5.html b/xess/doc/doxygen/search/all_5.html deleted file mode 100644 index 0d85fcc..0000000 --- a/xess/doc/doxygen/search/all_5.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/all_5.js b/xess/doc/doxygen/search/all_5.js deleted file mode 100644 index 0435e34..0000000 --- a/xess/doc/doxygen/search/all_5.js +++ /dev/null @@ -1,4 +0,0 @@ -var searchData= -[ - ['exposurescale_0',['exposureScale',['../struct__xess__d3d12__execute__params__t.html#a26bc83e12624ccf3b3c793a717e284ff',1,'_xess_d3d12_execute_params_t']]] -]; diff --git a/xess/doc/doxygen/search/all_6.html b/xess/doc/doxygen/search/all_6.html deleted file mode 100644 index 7e088b8..0000000 --- a/xess/doc/doxygen/search/all_6.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/all_6.js b/xess/doc/doxygen/search/all_6.js deleted file mode 100644 index 8af014d..0000000 --- a/xess/doc/doxygen/search/all_6.js +++ /dev/null @@ -1,7 +0,0 @@ -var searchData= -[ - ['frame_5fcount_0',['frame_count',['../struct__xess__profiling__data__t.html#a75021619d6a71e1e1a4ea1efb3c62138',1,'_xess_profiling_data_t::frame_count()'],['../struct__xess__dump__parameters__t.html#ae3e00071db1070451c10872b09360cad',1,'_xess_dump_parameters_t::frame_count()']]], - ['frame_5fidx_1',['frame_idx',['../struct__xess__dump__parameters__t.html#a675e89be435aec170285f3a1e7e25edf',1,'_xess_dump_parameters_t']]], - ['frame_5findex_2',['frame_index',['../struct__xess__profiled__frame__data__t.html#a7b9f42d4c57d1fe01c782d735be98074',1,'_xess_profiled_frame_data_t']]], - ['frames_3',['frames',['../struct__xess__profiling__data__t.html#a34fa47cf13f15a0c84ae5bc36f08fc1e',1,'_xess_profiling_data_t']]] -]; diff --git a/xess/doc/doxygen/search/all_7.html b/xess/doc/doxygen/search/all_7.html deleted file mode 100644 index d2b1825..0000000 --- a/xess/doc/doxygen/search/all_7.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/all_7.js b/xess/doc/doxygen/search/all_7.js deleted file mode 100644 index ad7567c..0000000 --- a/xess/doc/doxygen/search/all_7.js +++ /dev/null @@ -1,6 +0,0 @@ -var searchData= -[ - ['gpu_5fduration_5fnames_0',['gpu_duration_names',['../struct__xess__profiled__frame__data__t.html#a46e787a4e8a96da32fe2b173f3720d6f',1,'_xess_profiled_frame_data_t']]], - ['gpu_5fduration_5frecord_5fcount_1',['gpu_duration_record_count',['../struct__xess__profiled__frame__data__t.html#ab142b6f60de7c00c227011353cb602e5',1,'_xess_profiled_frame_data_t']]], - ['gpu_5fduration_5fvalues_2',['gpu_duration_values',['../struct__xess__profiled__frame__data__t.html#a8f6650843400b1532bdd0ce000a0e689',1,'_xess_profiled_frame_data_t']]] -]; diff --git a/xess/doc/doxygen/search/all_8.html b/xess/doc/doxygen/search/all_8.html deleted file mode 100644 index f4e3a2a..0000000 --- a/xess/doc/doxygen/search/all_8.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/all_8.js b/xess/doc/doxygen/search/all_8.js deleted file mode 100644 index a0f5763..0000000 --- a/xess/doc/doxygen/search/all_8.js +++ /dev/null @@ -1,10 +0,0 @@ -var searchData= -[ - ['initflags_0',['initFlags',['../struct__xess__d3d12__init__params__t.html#a2778ccc4a0cacda6c2c73482a77f6e05',1,'_xess_d3d12_init_params_t']]], - ['inputcolorbase_1',['inputColorBase',['../struct__xess__d3d12__execute__params__t.html#a4afe3dfda80148f5a10fa368f3d6a6f8',1,'_xess_d3d12_execute_params_t']]], - ['inputdepthbase_2',['inputDepthBase',['../struct__xess__d3d12__execute__params__t.html#ae6ec27f307c8f3dbf95472d73fc8797a',1,'_xess_d3d12_execute_params_t']]], - ['inputheight_3',['inputHeight',['../struct__xess__d3d12__execute__params__t.html#a2ee55ecbea691cf3d9c000055e8dfe1b',1,'_xess_d3d12_execute_params_t']]], - ['inputmotionvectorbase_4',['inputMotionVectorBase',['../struct__xess__d3d12__execute__params__t.html#abbd7c1808dbafcb1aa0475fd8ab70066',1,'_xess_d3d12_execute_params_t']]], - ['inputresponsivemaskbase_5',['inputResponsiveMaskBase',['../struct__xess__d3d12__execute__params__t.html#accb3d97fb6ba85e6560c9871010a3c57',1,'_xess_d3d12_execute_params_t']]], - ['inputwidth_6',['inputWidth',['../struct__xess__d3d12__execute__params__t.html#ad57863724c458e3583d0acb4be23cb7b',1,'_xess_d3d12_execute_params_t']]] -]; diff --git a/xess/doc/doxygen/search/all_9.html b/xess/doc/doxygen/search/all_9.html deleted file mode 100644 index 89177a8..0000000 --- a/xess/doc/doxygen/search/all_9.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/all_9.js b/xess/doc/doxygen/search/all_9.js deleted file mode 100644 index 5ae439b..0000000 --- a/xess/doc/doxygen/search/all_9.js +++ /dev/null @@ -1,5 +0,0 @@ -var searchData= -[ - ['jitteroffsetx_0',['jitterOffsetX',['../struct__xess__d3d12__execute__params__t.html#a701953ac726be26afde35ba21b1854f5',1,'_xess_d3d12_execute_params_t']]], - ['jitteroffsety_1',['jitterOffsetY',['../struct__xess__d3d12__execute__params__t.html#ab8fec73568168bc8ba655190c20b98b0',1,'_xess_d3d12_execute_params_t']]] -]; diff --git a/xess/doc/doxygen/search/all_a.html b/xess/doc/doxygen/search/all_a.html deleted file mode 100644 index 1f90b7a..0000000 --- a/xess/doc/doxygen/search/all_a.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/all_a.js b/xess/doc/doxygen/search/all_a.js deleted file mode 100644 index 0e84dfc..0000000 --- a/xess/doc/doxygen/search/all_a.js +++ /dev/null @@ -1,5 +0,0 @@ -var searchData= -[ - ['major_0',['major',['../struct__xess__version__t.html#a600930655b7237315b72223c48327ea8',1,'_xess_version_t']]], - ['minor_1',['minor',['../struct__xess__version__t.html#a9f280ce3ae5b6cd9346fd7a09ff29168',1,'_xess_version_t']]] -]; diff --git a/xess/doc/doxygen/search/all_b.html b/xess/doc/doxygen/search/all_b.html deleted file mode 100644 index b7ad6e6..0000000 --- a/xess/doc/doxygen/search/all_b.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/all_b.js b/xess/doc/doxygen/search/all_b.js deleted file mode 100644 index 4a6343b..0000000 --- a/xess/doc/doxygen/search/all_b.js +++ /dev/null @@ -1,5 +0,0 @@ -var searchData= -[ - ['outputcolorbase_0',['outputColorBase',['../struct__xess__d3d12__execute__params__t.html#a6408622b605e51416238460aa3e58533',1,'_xess_d3d12_execute_params_t']]], - ['outputresolution_1',['outputResolution',['../struct__xess__d3d12__init__params__t.html#adefd841ee2588585d89bf91ced85e84c',1,'_xess_d3d12_init_params_t']]] -]; diff --git a/xess/doc/doxygen/search/all_c.html b/xess/doc/doxygen/search/all_c.html deleted file mode 100644 index 829c917..0000000 --- a/xess/doc/doxygen/search/all_c.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/all_c.js b/xess/doc/doxygen/search/all_c.js deleted file mode 100644 index 3698e8f..0000000 --- a/xess/doc/doxygen/search/all_c.js +++ /dev/null @@ -1,15 +0,0 @@ -var searchData= -[ - ['patch_0',['patch',['../struct__xess__version__t.html#ab74656704767a7e73da4cd20dfd51a5d',1,'_xess_version_t']]], - ['path_1',['path',['../struct__xess__dump__parameters__t.html#a3b02c6de5c049804444a246f7fdf46b4',1,'_xess_dump_parameters_t']]], - ['pcolortexture_2',['pColorTexture',['../struct__xess__d3d12__execute__params__t.html#af0438b6fee2a81109430081d6d822090',1,'_xess_d3d12_execute_params_t']]], - ['pdepthtexture_3',['pDepthTexture',['../struct__xess__d3d12__execute__params__t.html#a0aced69da09a2f6ef2e7034270ca513c',1,'_xess_d3d12_execute_params_t']]], - ['pdescriptorheap_4',['pDescriptorHeap',['../struct__xess__d3d12__execute__params__t.html#a6a5db20b91a54c5160e350c7ba544c51',1,'_xess_d3d12_execute_params_t']]], - ['pexposurescaletexture_5',['pExposureScaleTexture',['../struct__xess__d3d12__execute__params__t.html#a848453834ef179e0694c525051fbf493',1,'_xess_d3d12_execute_params_t']]], - ['poutputtexture_6',['pOutputTexture',['../struct__xess__d3d12__execute__params__t.html#a680b0c0b8f150bd2f8a4bd07da22519e',1,'_xess_d3d12_execute_params_t']]], - ['ppipelinelibrary_7',['pPipelineLibrary',['../struct__xess__d3d12__init__params__t.html#a254d1c85f1dde5405a267084da481ad9',1,'_xess_d3d12_init_params_t']]], - ['presponsivepixelmasktexture_8',['pResponsivePixelMaskTexture',['../struct__xess__d3d12__execute__params__t.html#aa9210e99440b1564285d6d88ddf4d789',1,'_xess_d3d12_execute_params_t']]], - ['ptempbufferheap_9',['pTempBufferHeap',['../struct__xess__d3d12__init__params__t.html#a8b41cbb0e0c875bf2631ef6b414d4259',1,'_xess_d3d12_init_params_t']]], - ['ptemptextureheap_10',['pTempTextureHeap',['../struct__xess__d3d12__init__params__t.html#a32b6ed71e10b2df805c033b158f9d1f5',1,'_xess_d3d12_init_params_t']]], - ['pvelocitytexture_11',['pVelocityTexture',['../struct__xess__d3d12__execute__params__t.html#a112aa451fae1a83e2bc6ffc999206c2a',1,'_xess_d3d12_execute_params_t']]] -]; diff --git a/xess/doc/doxygen/search/all_d.html b/xess/doc/doxygen/search/all_d.html deleted file mode 100644 index d32b28e..0000000 --- a/xess/doc/doxygen/search/all_d.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/all_d.js b/xess/doc/doxygen/search/all_d.js deleted file mode 100644 index c239569..0000000 --- a/xess/doc/doxygen/search/all_d.js +++ /dev/null @@ -1,4 +0,0 @@ -var searchData= -[ - ['qualitysetting_0',['qualitySetting',['../struct__xess__d3d12__init__params__t.html#ad1566e156f30842fc8a32e5e508094b2',1,'_xess_d3d12_init_params_t']]] -]; diff --git a/xess/doc/doxygen/search/all_e.html b/xess/doc/doxygen/search/all_e.html deleted file mode 100644 index ce450a2..0000000 --- a/xess/doc/doxygen/search/all_e.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/all_e.js b/xess/doc/doxygen/search/all_e.js deleted file mode 100644 index ce51169..0000000 --- a/xess/doc/doxygen/search/all_e.js +++ /dev/null @@ -1,11 +0,0 @@ -var searchData= -[ - ['readme_2emd_0',['README.md',['../_r_e_a_d_m_e_8md.html',1,'']]], - ['requireddescriptorcount_1',['requiredDescriptorCount',['../struct__xess__properties__t.html#a2dc96375a6205c03219a9904a568c01c',1,'_xess_properties_t']]], - ['reserved_2',['reserved',['../struct__xess__version__t.html#a5a6ed8c04a3db86066924b1a1bf4dad3',1,'_xess_version_t']]], - ['reserved0_3',['reserved0',['../struct__xess__d3d12__execute__params__t.html#a99430c650ba489b07be8478c32b22606',1,'_xess_d3d12_execute_params_t']]], - ['resethistory_4',['resetHistory',['../struct__xess__d3d12__execute__params__t.html#af2336172df07c9d4a8d36a9a1f188a2e',1,'_xess_d3d12_execute_params_t']]], - ['resource_5fcount_5',['resource_count',['../struct__xess__resources__to__dump__t.html#afa5d343e953478907a576e9c372a5838',1,'_xess_resources_to_dump_t']]], - ['resource_5fnames_6',['resource_names',['../struct__xess__resources__to__dump__t.html#a4f61a0f5b6b502a4cd89405410853fde',1,'_xess_resources_to_dump_t']]], - ['resources_7',['resources',['../struct__xess__resources__to__dump__t.html#aeb3cb43b5376fe80794c4f5e4b47ff68',1,'_xess_resources_to_dump_t']]] -]; diff --git a/xess/doc/doxygen/search/all_f.html b/xess/doc/doxygen/search/all_f.html deleted file mode 100644 index 59cfe49..0000000 --- a/xess/doc/doxygen/search/all_f.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/all_f.js b/xess/doc/doxygen/search/all_f.js deleted file mode 100644 index 4cd0f0b..0000000 --- a/xess/doc/doxygen/search/all_f.js +++ /dev/null @@ -1,4 +0,0 @@ -var searchData= -[ - ['sizecheck_5f_5fline_5f_5f_0',['sizecheck__LINE__',['../xess_8h.html#a8b1577973a08cac2cbbe31bb1297eff5',1,'sizecheck__LINE__(): xess.h'],['../xess__debug_8h.html#a368b9d0a82e205f30f7e7c0da413e318',1,'sizecheck__LINE__(): xess_debug.h']]] -]; diff --git a/xess/doc/doxygen/search/classes_0.html b/xess/doc/doxygen/search/classes_0.html deleted file mode 100644 index 8361bcd..0000000 --- a/xess/doc/doxygen/search/classes_0.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/classes_0.js b/xess/doc/doxygen/search/classes_0.js deleted file mode 100644 index fc7b556..0000000 --- a/xess/doc/doxygen/search/classes_0.js +++ /dev/null @@ -1,12 +0,0 @@ -var searchData= -[ - ['_5fxess_5f2d_5ft_0',['_xess_2d_t',['../struct__xess__2d__t.html',1,'']]], - ['_5fxess_5fd3d12_5fexecute_5fparams_5ft_1',['_xess_d3d12_execute_params_t',['../struct__xess__d3d12__execute__params__t.html',1,'']]], - ['_5fxess_5fd3d12_5finit_5fparams_5ft_2',['_xess_d3d12_init_params_t',['../struct__xess__d3d12__init__params__t.html',1,'']]], - ['_5fxess_5fdump_5fparameters_5ft_3',['_xess_dump_parameters_t',['../struct__xess__dump__parameters__t.html',1,'']]], - ['_5fxess_5fprofiled_5fframe_5fdata_5ft_4',['_xess_profiled_frame_data_t',['../struct__xess__profiled__frame__data__t.html',1,'']]], - ['_5fxess_5fprofiling_5fdata_5ft_5',['_xess_profiling_data_t',['../struct__xess__profiling__data__t.html',1,'']]], - ['_5fxess_5fproperties_5ft_6',['_xess_properties_t',['../struct__xess__properties__t.html',1,'']]], - ['_5fxess_5fresources_5fto_5fdump_5ft_7',['_xess_resources_to_dump_t',['../struct__xess__resources__to__dump__t.html',1,'']]], - ['_5fxess_5fversion_5ft_8',['_xess_version_t',['../struct__xess__version__t.html',1,'']]] -]; diff --git a/xess/doc/doxygen/search/close.svg b/xess/doc/doxygen/search/close.svg deleted file mode 100644 index a933eea..0000000 --- a/xess/doc/doxygen/search/close.svg +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - diff --git a/xess/doc/doxygen/search/defines_0.html b/xess/doc/doxygen/search/defines_0.html deleted file mode 100644 index fd147db..0000000 --- a/xess/doc/doxygen/search/defines_0.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/defines_0.js b/xess/doc/doxygen/search/defines_0.js deleted file mode 100644 index 484ce3d..0000000 --- a/xess/doc/doxygen/search/defines_0.js +++ /dev/null @@ -1,9 +0,0 @@ -var searchData= -[ - ['xess_5fapi_0',['XESS_API',['../xess_8h.html#ac7ba74abaad1e5cf4ca1fffa7fee838c',1,'xess.h']]], - ['xess_5fd3d12_5fdebug_5fenable_5fprofiling_1',['XESS_D3D12_DEBUG_ENABLE_PROFILING',['../xess__d3d12__debug_8h.html#ad587f5e54cc2f41c539dd8983e248cb2',1,'xess_d3d12_debug.h']]], - ['xess_5fpack_5fb_2',['XESS_PACK_B',['../xess_8h.html#a3c68605bee1e217a930c4ae6aa218fd1',1,'xess.h']]], - ['xess_5fpack_5fb_5fx_3',['XESS_PACK_B_X',['../xess_8h.html#a0cbf0d6231ec6ae03e685f2ddee69a95',1,'xess.h']]], - ['xess_5fpack_5fe_4',['XESS_PACK_E',['../xess_8h.html#a36808d4ffd35a951c364418a19468cf8',1,'xess.h']]], - ['xess_5fpragma_5',['XESS_PRAGMA',['../xess_8h.html#af3af4f4afda4277313b1b91dbf1f7497',1,'xess.h']]] -]; diff --git a/xess/doc/doxygen/search/enums_0.html b/xess/doc/doxygen/search/enums_0.html deleted file mode 100644 index eb1f873..0000000 --- a/xess/doc/doxygen/search/enums_0.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/enums_0.js b/xess/doc/doxygen/search/enums_0.js deleted file mode 100644 index 65051f7..0000000 --- a/xess/doc/doxygen/search/enums_0.js +++ /dev/null @@ -1,9 +0,0 @@ -var searchData= -[ - ['_5fxess_5fdump_5felement_5fbits_5ft_0',['_xess_dump_element_bits_t',['../xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83',1,'xess_debug.h']]], - ['_5fxess_5finit_5fflags_5ft_1',['_xess_init_flags_t',['../xess_8h.html#a4f25323a8c073a84d49a93e0cdeaddf1',1,'xess.h']]], - ['_5fxess_5flogging_5flevel_5ft_2',['_xess_logging_level_t',['../xess_8h.html#a12f0fd50664b1a61319821499ec24721',1,'xess.h']]], - ['_5fxess_5fnetwork_5fmodel_5ft_3',['_xess_network_model_t',['../xess__debug_8h.html#ace50e033796a986a57623170306b41ed',1,'xess_debug.h']]], - ['_5fxess_5fquality_5fsettings_5ft_4',['_xess_quality_settings_t',['../xess_8h.html#acc1be3e82183f25c7188fa6b5cbf1e34',1,'xess.h']]], - ['_5fxess_5fresult_5ft_5',['_xess_result_t',['../xess_8h.html#a31952a580a4d5d26c6224183f62d2612',1,'xess.h']]] -]; diff --git a/xess/doc/doxygen/search/enumvalues_0.html b/xess/doc/doxygen/search/enumvalues_0.html deleted file mode 100644 index 7a520ff..0000000 --- a/xess/doc/doxygen/search/enumvalues_0.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/enumvalues_0.js b/xess/doc/doxygen/search/enumvalues_0.js deleted file mode 100644 index ca62e1b..0000000 --- a/xess/doc/doxygen/search/enumvalues_0.js +++ /dev/null @@ -1,46 +0,0 @@ -var searchData= -[ - ['xess_5fdump_5fall_0',['XESS_DUMP_ALL',['../xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83a312ca9873e04595421188f6345d28f82',1,'xess_debug.h']]], - ['xess_5fdump_5fall_5finputs_1',['XESS_DUMP_ALL_INPUTS',['../xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83a5bde5b4edb7c99106b7ad168d3da89fe',1,'xess_debug.h']]], - ['xess_5fdump_5fexecution_5fparameters_2',['XESS_DUMP_EXECUTION_PARAMETERS',['../xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83a60e0f8ed79622d3f7e4588a658fc484a',1,'xess_debug.h']]], - ['xess_5fdump_5fhistory_3',['XESS_DUMP_HISTORY',['../xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83ae98ac97ee61128c3b0632a8ccbefc6bc',1,'xess_debug.h']]], - ['xess_5fdump_5finput_5fcolor_4',['XESS_DUMP_INPUT_COLOR',['../xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83a623a94758729c9bcdc65df0547b1974f',1,'xess_debug.h']]], - ['xess_5fdump_5finput_5fdepth_5',['XESS_DUMP_INPUT_DEPTH',['../xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83aa9f414176cfe6c87f0e7b62d60976a88',1,'xess_debug.h']]], - ['xess_5fdump_5finput_5fexposure_5fscale_6',['XESS_DUMP_INPUT_EXPOSURE_SCALE',['../xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83a89c37b4f5e86951bddd55fb8a5164bcc',1,'xess_debug.h']]], - ['xess_5fdump_5finput_5fresponsive_5fpixel_5fmask_7',['XESS_DUMP_INPUT_RESPONSIVE_PIXEL_MASK',['../xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83a002eada067830ed6c0aa36fbc60a21f2',1,'xess_debug.h']]], - ['xess_5fdump_5finput_5fvelocity_8',['XESS_DUMP_INPUT_VELOCITY',['../xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83a660e96b09d4656899f05260d1e7622a3',1,'xess_debug.h']]], - ['xess_5fdump_5foutput_9',['XESS_DUMP_OUTPUT',['../xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83ab5fabbdd4efc47253723dd02ac132121',1,'xess_debug.h']]], - ['xess_5finit_5fflag_5fexposure_5fscale_5ftexture_10',['XESS_INIT_FLAG_EXPOSURE_SCALE_TEXTURE',['../xess_8h.html#a4f25323a8c073a84d49a93e0cdeaddf1a99164122cf8c776c7ce5bfdfe3fd0492',1,'xess.h']]], - ['xess_5finit_5fflag_5fexternal_5fdescriptor_5fheap_11',['XESS_INIT_FLAG_EXTERNAL_DESCRIPTOR_HEAP',['../xess_8h.html#a4f25323a8c073a84d49a93e0cdeaddf1a7a765c7ec24c2b4193baf2e0a30fb4c7',1,'xess.h']]], - ['xess_5finit_5fflag_5fhigh_5fres_5fmv_12',['XESS_INIT_FLAG_HIGH_RES_MV',['../xess_8h.html#a4f25323a8c073a84d49a93e0cdeaddf1a88dbf4a687acc9bd1281778570c7c757',1,'xess.h']]], - ['xess_5finit_5fflag_5finverted_5fdepth_13',['XESS_INIT_FLAG_INVERTED_DEPTH',['../xess_8h.html#a4f25323a8c073a84d49a93e0cdeaddf1a91fe3728f6cafc03e6da0a064389859a',1,'xess.h']]], - ['xess_5finit_5fflag_5fjittered_5fmv_14',['XESS_INIT_FLAG_JITTERED_MV',['../xess_8h.html#a4f25323a8c073a84d49a93e0cdeaddf1a8390a8a09d1f38a88608644929954028',1,'xess.h']]], - ['xess_5finit_5fflag_5fldr_5finput_5fcolor_15',['XESS_INIT_FLAG_LDR_INPUT_COLOR',['../xess_8h.html#a4f25323a8c073a84d49a93e0cdeaddf1a0eb16d799c44bab1bbf3c59dfd97ceb9',1,'xess.h']]], - ['xess_5finit_5fflag_5fnone_16',['XESS_INIT_FLAG_NONE',['../xess_8h.html#a4f25323a8c073a84d49a93e0cdeaddf1a93cdd13324042072081453aeaadf0e1e',1,'xess.h']]], - ['xess_5finit_5fflag_5fresponsive_5fpixel_5fmask_17',['XESS_INIT_FLAG_RESPONSIVE_PIXEL_MASK',['../xess_8h.html#a4f25323a8c073a84d49a93e0cdeaddf1ad1f14cc0ac79131e639d3bab61c5f48c',1,'xess.h']]], - ['xess_5finit_5fflag_5fuse_5fndc_5fvelocity_18',['XESS_INIT_FLAG_USE_NDC_VELOCITY',['../xess_8h.html#a4f25323a8c073a84d49a93e0cdeaddf1a2c868f941d0829edc844b93bd76cf0f2',1,'xess.h']]], - ['xess_5flogging_5flevel_5fdebug_19',['XESS_LOGGING_LEVEL_DEBUG',['../xess_8h.html#a12f0fd50664b1a61319821499ec24721a526588cb8c0fe38b7bb35479bd44b710',1,'xess.h']]], - ['xess_5flogging_5flevel_5ferror_20',['XESS_LOGGING_LEVEL_ERROR',['../xess_8h.html#a12f0fd50664b1a61319821499ec24721a7142dcde3f8100558086ad32c674242b',1,'xess.h']]], - ['xess_5flogging_5flevel_5finfo_21',['XESS_LOGGING_LEVEL_INFO',['../xess_8h.html#a12f0fd50664b1a61319821499ec24721a02d7dfe8174efddabcf108baf804b4a6',1,'xess.h']]], - ['xess_5flogging_5flevel_5fwarning_22',['XESS_LOGGING_LEVEL_WARNING',['../xess_8h.html#a12f0fd50664b1a61319821499ec24721a089568d56d50438813be38513b886486',1,'xess.h']]], - ['xess_5fnetwork_5fmodel_5fkpss_23',['XESS_NETWORK_MODEL_KPSS',['../xess__debug_8h.html#ace50e033796a986a57623170306b41eda1489add6542185904900e0b6796b8215',1,'xess_debug.h']]], - ['xess_5fnetwork_5fmodel_5fsplat_24',['XESS_NETWORK_MODEL_SPLAT',['../xess__debug_8h.html#ace50e033796a986a57623170306b41eda89d379244951ad3c2988a0d303b4a0cb',1,'xess_debug.h']]], - ['xess_5fquality_5fsetting_5fbalanced_25',['XESS_QUALITY_SETTING_BALANCED',['../xess_8h.html#acc1be3e82183f25c7188fa6b5cbf1e34af42585b087b48ac84f15147eca7f84fc',1,'xess.h']]], - ['xess_5fquality_5fsetting_5fperformance_26',['XESS_QUALITY_SETTING_PERFORMANCE',['../xess_8h.html#acc1be3e82183f25c7188fa6b5cbf1e34a375807073d5e41d49599bc4c3796a298',1,'xess.h']]], - ['xess_5fquality_5fsetting_5fquality_27',['XESS_QUALITY_SETTING_QUALITY',['../xess_8h.html#acc1be3e82183f25c7188fa6b5cbf1e34aad6611bfc9d8b4367d40cc4341781071',1,'xess.h']]], - ['xess_5fquality_5fsetting_5fultra_5fquality_28',['XESS_QUALITY_SETTING_ULTRA_QUALITY',['../xess_8h.html#acc1be3e82183f25c7188fa6b5cbf1e34a2307f69631f48661ec35997e6b9dfa7b',1,'xess.h']]], - ['xess_5fresult_5ferror_5fcant_5fload_5flibrary_29',['XESS_RESULT_ERROR_CANT_LOAD_LIBRARY',['../xess_8h.html#a31952a580a4d5d26c6224183f62d2612ab0c58d47a6858d66925b00e17bda81f5',1,'xess.h']]], - ['xess_5fresult_5ferror_5fdevice_30',['XESS_RESULT_ERROR_DEVICE',['../xess_8h.html#a31952a580a4d5d26c6224183f62d2612a47d58f63ff4815586df793c60eed4dc0',1,'xess.h']]], - ['xess_5fresult_5ferror_5fdevice_5fout_5fof_5fmemory_31',['XESS_RESULT_ERROR_DEVICE_OUT_OF_MEMORY',['../xess_8h.html#a31952a580a4d5d26c6224183f62d2612ac8e207e9005b05302499f10cda8d58f5',1,'xess.h']]], - ['xess_5fresult_5ferror_5finvalid_5fargument_32',['XESS_RESULT_ERROR_INVALID_ARGUMENT',['../xess_8h.html#a31952a580a4d5d26c6224183f62d2612a30021fa62d2929cc6bf0d47d07e3c59e',1,'xess.h']]], - ['xess_5fresult_5ferror_5finvalid_5fcontext_33',['XESS_RESULT_ERROR_INVALID_CONTEXT',['../xess_8h.html#a31952a580a4d5d26c6224183f62d2612a27d5e96802336368594096df18a1ae06',1,'xess.h']]], - ['xess_5fresult_5ferror_5fnot_5fimplemented_34',['XESS_RESULT_ERROR_NOT_IMPLEMENTED',['../xess_8h.html#a31952a580a4d5d26c6224183f62d2612a1953e4a40daecb661d97b031c38ce1f6',1,'xess.h']]], - ['xess_5fresult_5ferror_5foperation_5fin_5fprogress_35',['XESS_RESULT_ERROR_OPERATION_IN_PROGRESS',['../xess_8h.html#a31952a580a4d5d26c6224183f62d2612a8ca9ff62f59f7b647e62dc3c52ec6ac8',1,'xess.h']]], - ['xess_5fresult_5ferror_5funinitialized_36',['XESS_RESULT_ERROR_UNINITIALIZED',['../xess_8h.html#a31952a580a4d5d26c6224183f62d2612a635c3fdf5ff04d037167f1cb37d46e23',1,'xess.h']]], - ['xess_5fresult_5ferror_5funknown_37',['XESS_RESULT_ERROR_UNKNOWN',['../xess_8h.html#a31952a580a4d5d26c6224183f62d2612a1a08d6aec7e38e2f0bd03893c05b9d2f',1,'xess.h']]], - ['xess_5fresult_5ferror_5funsupported_38',['XESS_RESULT_ERROR_UNSUPPORTED',['../xess_8h.html#a31952a580a4d5d26c6224183f62d2612aa1255da83c4c0fcc2b4a2d7bb4af02bf',1,'xess.h']]], - ['xess_5fresult_5ferror_5funsupported_5fdevice_39',['XESS_RESULT_ERROR_UNSUPPORTED_DEVICE',['../xess_8h.html#a31952a580a4d5d26c6224183f62d2612a00eab4ebb1fb95a65e2b4d82981fb3f8',1,'xess.h']]], - ['xess_5fresult_5ferror_5funsupported_5fdriver_40',['XESS_RESULT_ERROR_UNSUPPORTED_DRIVER',['../xess_8h.html#a31952a580a4d5d26c6224183f62d2612a15bd2bd2e7ae00b9ddd87fa5a43b1ee2',1,'xess.h']]], - ['xess_5fresult_5fsuccess_41',['XESS_RESULT_SUCCESS',['../xess_8h.html#a31952a580a4d5d26c6224183f62d2612afd64586bcb0f0638509e4ae5506c72cf',1,'xess.h']]], - ['xess_5fresult_5fwarning_5fnonexisting_5ffolder_42',['XESS_RESULT_WARNING_NONEXISTING_FOLDER',['../xess_8h.html#a31952a580a4d5d26c6224183f62d2612a7f8d0f6dc01ba497911fdbdb02b05a45',1,'xess.h']]] -]; diff --git a/xess/doc/doxygen/search/files_0.html b/xess/doc/doxygen/search/files_0.html deleted file mode 100644 index da83704..0000000 --- a/xess/doc/doxygen/search/files_0.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/files_0.js b/xess/doc/doxygen/search/files_0.js deleted file mode 100644 index 4accdc1..0000000 --- a/xess/doc/doxygen/search/files_0.js +++ /dev/null @@ -1,4 +0,0 @@ -var searchData= -[ - ['readme_2emd_0',['README.md',['../_r_e_a_d_m_e_8md.html',1,'']]] -]; diff --git a/xess/doc/doxygen/search/files_1.html b/xess/doc/doxygen/search/files_1.html deleted file mode 100644 index f7e1582..0000000 --- a/xess/doc/doxygen/search/files_1.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/files_1.js b/xess/doc/doxygen/search/files_1.js deleted file mode 100644 index e5e9b66..0000000 --- a/xess/doc/doxygen/search/files_1.js +++ /dev/null @@ -1,7 +0,0 @@ -var searchData= -[ - ['xess_2eh_0',['xess.h',['../xess_8h.html',1,'']]], - ['xess_5fd3d12_2eh_1',['xess_d3d12.h',['../xess__d3d12_8h.html',1,'']]], - ['xess_5fd3d12_5fdebug_2eh_2',['xess_d3d12_debug.h',['../xess__d3d12__debug_8h.html',1,'']]], - ['xess_5fdebug_2eh_3',['xess_debug.h',['../xess__debug_8h.html',1,'']]] -]; diff --git a/xess/doc/doxygen/search/functions_0.html b/xess/doc/doxygen/search/functions_0.html deleted file mode 100644 index 2d2d950..0000000 --- a/xess/doc/doxygen/search/functions_0.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/functions_0.js b/xess/doc/doxygen/search/functions_0.js deleted file mode 100644 index a60b986..0000000 --- a/xess/doc/doxygen/search/functions_0.js +++ /dev/null @@ -1,19 +0,0 @@ -var searchData= -[ - ['xessd3d12buildpipelines_0',['xessD3D12BuildPipelines',['../group__xess-d3d12.html#gac39e8fcd2d1575ab36e54aacbc3d3b6a',1,'xess_d3d12.h']]], - ['xessd3d12createcontext_1',['xessD3D12CreateContext',['../group__xess-d3d12.html#ga6b15c60fbdeefc17a1064950c90d2e2d',1,'xess_d3d12.h']]], - ['xessd3d12execute_2',['xessD3D12Execute',['../group__xess-d3d12.html#gaf8e15aa3a0915546fdfcaa899f58c102',1,'xess_d3d12.h']]], - ['xessd3d12getprofilingdata_3',['xessD3D12GetProfilingData',['../group__xess-d3d12-debug.html#ga3a8e8bee0b8ba06871c765648202c938',1,'xess_d3d12_debug.h']]], - ['xessd3d12getresourcestodump_4',['xessD3D12GetResourcesToDump',['../group__xess-d3d12-debug.html#gaf62cb7b5e756de611a19896a5248c92b',1,'xess_d3d12_debug.h']]], - ['xessd3d12init_5',['xessD3D12Init',['../group__xess-d3d12.html#gafb211935ba10efefc5a7063b276fce31',1,'xess_d3d12.h']]], - ['xessdestroycontext_6',['xessDestroyContext',['../group__xess.html#gae5d88d9bdb50033ab254aa2e692c9bc0',1,'xess.h']]], - ['xessgetinputresolution_7',['xessGetInputResolution',['../group__xess.html#ga6ed6ab924e0a41ff56485b562acd5073',1,'xess.h']]], - ['xessgetintelxefxversion_8',['xessGetIntelXeFXVersion',['../group__xess.html#ga88ea52641806d14ef5a4995b5d78ea91',1,'xess.h']]], - ['xessgetproperties_9',['xessGetProperties',['../group__xess.html#gaae4893a4bfed059402ca55f256738773',1,'xess.h']]], - ['xessgetversion_10',['xessGetVersion',['../group__xess.html#ga0fc6e0c7b21322a0af96f1ee1e4667d3',1,'xess.h']]], - ['xessselectnetworkmodel_11',['xessSelectNetworkModel',['../group__xess-debug.html#ga596f2374ff85d63d430d885da295818b',1,'xess_debug.h']]], - ['xesssetjitterscale_12',['xessSetJitterScale',['../group__xess.html#ga30e9bee98f90568e6a9d39bd7d1ccd74',1,'xess.h']]], - ['xesssetloggingcallback_13',['xessSetLoggingCallback',['../group__xess.html#gaaf68a347af5e5c9c1e518f0bc5daaf1c',1,'xess.h']]], - ['xesssetvelocityscale_14',['xessSetVelocityScale',['../group__xess.html#ga0f95b12fe2611b877d72efdd9f050639',1,'xess.h']]], - ['xessstartdump_15',['xessStartDump',['../group__xess-debug.html#gaa320ed0d9c03d6abb26f37647b12db7e',1,'xess_debug.h']]] -]; diff --git a/xess/doc/doxygen/search/groups_0.html b/xess/doc/doxygen/search/groups_0.html deleted file mode 100644 index c8654e6..0000000 --- a/xess/doc/doxygen/search/groups_0.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/groups_0.js b/xess/doc/doxygen/search/groups_0.js deleted file mode 100644 index 446dc5f..0000000 --- a/xess/doc/doxygen/search/groups_0.js +++ /dev/null @@ -1,7 +0,0 @@ -var searchData= -[ - ['xess_20api_20debug_20exports_0',['XeSS API debug exports',['../group__xess-debug.html',1,'']]], - ['xess_20api_20exports_1',['XeSS API exports',['../group__xess.html',1,'']]], - ['xess_20d3d12_20api_20debug_20exports_2',['XeSS D3D12 API debug exports',['../group__xess-d3d12-debug.html',1,'']]], - ['xess_20d3d12_20api_20exports_3',['XeSS D3D12 API exports',['../group__xess-d3d12.html',1,'']]] -]; diff --git a/xess/doc/doxygen/search/mag_sel.svg b/xess/doc/doxygen/search/mag_sel.svg deleted file mode 100644 index 03626f6..0000000 --- a/xess/doc/doxygen/search/mag_sel.svg +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - image/svg+xml - - - - - - - - - - - diff --git a/xess/doc/doxygen/search/nomatches.html b/xess/doc/doxygen/search/nomatches.html deleted file mode 100644 index 2b9360b..0000000 --- a/xess/doc/doxygen/search/nomatches.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - -
    -
    No Matches
    -
    - - diff --git a/xess/doc/doxygen/search/pages_0.html b/xess/doc/doxygen/search/pages_0.html deleted file mode 100644 index e53c280..0000000 --- a/xess/doc/doxygen/search/pages_0.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/pages_0.js b/xess/doc/doxygen/search/pages_0.js deleted file mode 100644 index 28bce99..0000000 --- a/xess/doc/doxygen/search/pages_0.js +++ /dev/null @@ -1,4 +0,0 @@ -var searchData= -[ - ['xess_20sdk_0',['XeSS SDK',['../index.html',1,'']]] -]; diff --git a/xess/doc/doxygen/search/search.css b/xess/doc/doxygen/search/search.css deleted file mode 100644 index 648a792..0000000 --- a/xess/doc/doxygen/search/search.css +++ /dev/null @@ -1,263 +0,0 @@ -/*---------------- Search Box */ - -#MSearchBox { - white-space : nowrap; - background: white; - border-radius: 0.65em; - box-shadow: inset 0.5px 0.5px 3px 0px #555; - z-index: 102; -} - -#MSearchBox .left { - display: inline-block; - vertical-align: middle; - height: 1.4em; -} - -#MSearchSelect { - display: inline-block; - vertical-align: middle; - height: 19px; - padding: 0 0 0 0.3em; - margin: 0; -} - -#MSearchField { - display: inline-block; - vertical-align: middle; - width: 7.5em; - height: 19px; - margin: 0 0.15em; - padding: 0; - line-height: 1em; - border:none; - color: #909090; - outline: none; - font-family: Arial, Verdana, sans-serif; - -webkit-border-radius: 0px; - border-radius: 0px; - background: none; -} - -@media(hover: none) { - /* to avoid zooming on iOS */ - #MSearchField { - font-size: 16px; - } -} - -#MSearchBox .right { - display: inline-block; - vertical-align: middle; - width: 1.4em; - height: 1.4em; -} - -#MSearchClose { - display: none; - font-size: inherit; - background : none; - border: none; - margin: 0; - padding: 0; - outline: none; - -} - -#MSearchCloseImg { - height: 1.4em; - padding: 0.3em; - margin: 0; -} - -.MSearchBoxActive #MSearchField { - color: #000000; -} - -#main-menu > li:last-child { - /* This
  • object is the parent of the search bar */ - display: flex; - justify-content: center; - align-items: center; - height: 36px; - margin-right: 1em; -} - -/*---------------- Search filter selection */ - -#MSearchSelectWindow { - display: none; - position: absolute; - left: 0; top: 0; - border: 1px solid #90A5CE; - background-color: #F9FAFC; - z-index: 10001; - padding-top: 4px; - padding-bottom: 4px; - -moz-border-radius: 4px; - -webkit-border-top-left-radius: 4px; - -webkit-border-top-right-radius: 4px; - -webkit-border-bottom-left-radius: 4px; - -webkit-border-bottom-right-radius: 4px; - -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); -} - -.SelectItem { - font: 8pt Arial, Verdana, sans-serif; - padding-left: 2px; - padding-right: 12px; - border: 0px; -} - -span.SelectionMark { - margin-right: 4px; - font-family: monospace; - outline-style: none; - text-decoration: none; -} - -a.SelectItem { - display: block; - outline-style: none; - color: #000000; - text-decoration: none; - padding-left: 6px; - padding-right: 12px; -} - -a.SelectItem:focus, -a.SelectItem:active { - color: #000000; - outline-style: none; - text-decoration: none; -} - -a.SelectItem:hover { - color: #FFFFFF; - background-color: #3D578C; - outline-style: none; - text-decoration: none; - cursor: pointer; - display: block; -} - -/*---------------- Search results window */ - -iframe#MSearchResults { - /*width: 60ex;*/ - height: 15em; -} - -#MSearchResultsWindow { - display: none; - position: absolute; - left: 0; top: 0; - border: 1px solid #000; - background-color: #EEF1F7; - z-index:10000; -} - -/* ----------------------------------- */ - - -#SRIndex { - clear:both; - padding-bottom: 15px; -} - -.SREntry { - font-size: 10pt; - padding-left: 1ex; -} - -.SRPage .SREntry { - font-size: 8pt; - padding: 1px 5px; -} - -body.SRPage { - margin: 5px 2px; -} - -.SRChildren { - padding-left: 3ex; padding-bottom: .5em -} - -.SRPage .SRChildren { - display: none; -} - -.SRSymbol { - font-weight: bold; - color: #425E97; - font-family: Arial, Verdana, sans-serif; - text-decoration: none; - outline: none; -} - -a.SRScope { - display: block; - color: #425E97; - font-family: Arial, Verdana, sans-serif; - text-decoration: none; - outline: none; -} - -a.SRSymbol:focus, a.SRSymbol:active, -a.SRScope:focus, a.SRScope:active { - text-decoration: underline; -} - -span.SRScope { - padding-left: 4px; - font-family: Arial, Verdana, sans-serif; -} - -.SRPage .SRStatus { - padding: 2px 5px; - font-size: 8pt; - font-style: italic; - font-family: Arial, Verdana, sans-serif; -} - -.SRResult { - display: none; -} - -div.searchresults { - margin-left: 10px; - margin-right: 10px; -} - -/*---------------- External search page results */ - -.searchresult { - background-color: #F0F3F8; -} - -.pages b { - color: white; - padding: 5px 5px 3px 5px; - background-image: url("../tab_a.png"); - background-repeat: repeat-x; - text-shadow: 0 1px 1px #000000; -} - -.pages { - line-height: 17px; - margin-left: 4px; - text-decoration: none; -} - -.hl { - font-weight: bold; -} - -#searchresults { - margin-bottom: 20px; -} - -.searchpages { - margin-top: 10px; -} - diff --git a/xess/doc/doxygen/search/search.js b/xess/doc/doxygen/search/search.js deleted file mode 100644 index ac8055d..0000000 --- a/xess/doc/doxygen/search/search.js +++ /dev/null @@ -1,794 +0,0 @@ -/* - @licstart The following is the entire license notice for the JavaScript code in this file. - - The MIT License (MIT) - - Copyright (C) 1997-2020 by Dimitri van Heesch - - Permission is hereby granted, free of charge, to any person obtaining a copy of this software - and associated documentation files (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, publish, distribute, - sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or - substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING - BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - @licend The above is the entire license notice for the JavaScript code in this file - */ -function convertToId(search) -{ - var result = ''; - for (i=0;i do a search - { - this.Search(); - } - } - - this.OnSearchSelectKey = function(evt) - { - var e = (evt) ? evt : window.event; // for IE - if (e.keyCode==40 && this.searchIndex0) // Up - { - this.searchIndex--; - this.OnSelectItem(this.searchIndex); - } - else if (e.keyCode==13 || e.keyCode==27) - { - this.OnSelectItem(this.searchIndex); - this.CloseSelectionWindow(); - this.DOMSearchField().focus(); - } - return false; - } - - // --------- Actions - - // Closes the results window. - this.CloseResultsWindow = function() - { - this.DOMPopupSearchResultsWindow().style.display = 'none'; - this.DOMSearchClose().style.display = 'none'; - this.Activate(false); - } - - this.CloseSelectionWindow = function() - { - this.DOMSearchSelectWindow().style.display = 'none'; - } - - // Performs a search. - this.Search = function() - { - this.keyTimeout = 0; - - // strip leading whitespace - var searchValue = this.DOMSearchField().value.replace(/^ +/, ""); - - var code = searchValue.toLowerCase().charCodeAt(0); - var idxChar = searchValue.substr(0, 1).toLowerCase(); - if ( 0xD800 <= code && code <= 0xDBFF && searchValue > 1) // surrogate pair - { - idxChar = searchValue.substr(0, 2); - } - - var resultsPage; - var resultsPageWithSearch; - var hasResultsPage; - - var idx = indexSectionsWithContent[this.searchIndex].indexOf(idxChar); - if (idx!=-1) - { - var hexCode=idx.toString(16); - resultsPage = this.resultsPath + '/' + indexSectionNames[this.searchIndex] + '_' + hexCode + this.extension; - resultsPageWithSearch = resultsPage+'?'+escape(searchValue); - hasResultsPage = true; - } - else // nothing available for this search term - { - resultsPage = this.resultsPath + '/nomatches' + this.extension; - resultsPageWithSearch = resultsPage; - hasResultsPage = false; - } - - window.frames.MSearchResults.location = resultsPageWithSearch; - var domPopupSearchResultsWindow = this.DOMPopupSearchResultsWindow(); - - if (domPopupSearchResultsWindow.style.display!='block') - { - var domSearchBox = this.DOMSearchBox(); - this.DOMSearchClose().style.display = 'inline-block'; - var domPopupSearchResults = this.DOMPopupSearchResults(); - var left = getXPos(domSearchBox) + 150; // domSearchBox.offsetWidth; - var top = getYPos(domSearchBox) + 20; // domSearchBox.offsetHeight + 1; - domPopupSearchResultsWindow.style.display = 'block'; - left -= domPopupSearchResults.offsetWidth; - var maxWidth = document.body.clientWidth; - var width = 400; - if (left<10) left=10; - if (width+left+8>maxWidth) width=maxWidth-left-8; - domPopupSearchResultsWindow.style.top = top + 'px'; - domPopupSearchResultsWindow.style.left = left + 'px'; - domPopupSearchResultsWindow.style.width = width + 'px'; - } - - this.lastSearchValue = searchValue; - this.lastResultsPage = resultsPage; - } - - // -------- Activation Functions - - // Activates or deactivates the search panel, resetting things to - // their default values if necessary. - this.Activate = function(isActive) - { - if (isActive || // open it - this.DOMPopupSearchResultsWindow().style.display == 'block' - ) - { - this.DOMSearchBox().className = 'MSearchBoxActive'; - - var searchField = this.DOMSearchField(); - - if (searchField.value == this.searchLabel) // clear "Search" term upon entry - { - searchField.value = ''; - this.searchActive = true; - } - } - else if (!isActive) // directly remove the panel - { - this.DOMSearchBox().className = 'MSearchBoxInactive'; - this.DOMSearchField().value = this.searchLabel; - this.searchActive = false; - this.lastSearchValue = '' - this.lastResultsPage = ''; - } - } -} - -// ----------------------------------------------------------------------- - -// The class that handles everything on the search results page. -function SearchResults(name) -{ - // The number of matches from the last run of . - this.lastMatchCount = 0; - this.lastKey = 0; - this.repeatOn = false; - - // Toggles the visibility of the passed element ID. - this.FindChildElement = function(id) - { - var parentElement = document.getElementById(id); - var element = parentElement.firstChild; - - while (element && element!=parentElement) - { - if (element.nodeName.toLowerCase() == 'div' && element.className == 'SRChildren') - { - return element; - } - - if (element.nodeName.toLowerCase() == 'div' && element.hasChildNodes()) - { - element = element.firstChild; - } - else if (element.nextSibling) - { - element = element.nextSibling; - } - else - { - do - { - element = element.parentNode; - } - while (element && element!=parentElement && !element.nextSibling); - - if (element && element!=parentElement) - { - element = element.nextSibling; - } - } - } - } - - this.Toggle = function(id) - { - var element = this.FindChildElement(id); - if (element) - { - if (element.style.display == 'block') - { - element.style.display = 'none'; - } - else - { - element.style.display = 'block'; - } - } - } - - // Searches for the passed string. If there is no parameter, - // it takes it from the URL query. - // - // Always returns true, since other documents may try to call it - // and that may or may not be possible. - this.Search = function(search) - { - if (!search) // get search word from URL - { - search = window.location.search; - search = search.substring(1); // Remove the leading '?' - search = unescape(search); - } - - search = search.replace(/^ +/, ""); // strip leading spaces - search = search.replace(/ +$/, ""); // strip trailing spaces - search = search.toLowerCase(); - search = convertToId(search); - - var resultRows = document.getElementsByTagName("div"); - var matches = 0; - - var i = 0; - while (i < resultRows.length) - { - var row = resultRows.item(i); - if (row.className == "SRResult") - { - var rowMatchName = row.id.toLowerCase(); - rowMatchName = rowMatchName.replace(/^sr\d*_/, ''); // strip 'sr123_' - - if (search.length<=rowMatchName.length && - rowMatchName.substr(0, search.length)==search) - { - row.style.display = 'block'; - matches++; - } - else - { - row.style.display = 'none'; - } - } - i++; - } - document.getElementById("Searching").style.display='none'; - if (matches == 0) // no results - { - document.getElementById("NoMatches").style.display='block'; - } - else // at least one result - { - document.getElementById("NoMatches").style.display='none'; - } - this.lastMatchCount = matches; - return true; - } - - // return the first item with index index or higher that is visible - this.NavNext = function(index) - { - var focusItem; - while (1) - { - var focusName = 'Item'+index; - focusItem = document.getElementById(focusName); - if (focusItem && focusItem.parentNode.parentNode.style.display=='block') - { - break; - } - else if (!focusItem) // last element - { - break; - } - focusItem=null; - index++; - } - return focusItem; - } - - this.NavPrev = function(index) - { - var focusItem; - while (1) - { - var focusName = 'Item'+index; - focusItem = document.getElementById(focusName); - if (focusItem && focusItem.parentNode.parentNode.style.display=='block') - { - break; - } - else if (!focusItem) // last element - { - break; - } - focusItem=null; - index--; - } - return focusItem; - } - - this.ProcessKeys = function(e) - { - if (e.type == "keydown") - { - this.repeatOn = false; - this.lastKey = e.keyCode; - } - else if (e.type == "keypress") - { - if (!this.repeatOn) - { - if (this.lastKey) this.repeatOn = true; - return false; // ignore first keypress after keydown - } - } - else if (e.type == "keyup") - { - this.lastKey = 0; - this.repeatOn = false; - } - return this.lastKey!=0; - } - - this.Nav = function(evt,itemIndex) - { - var e = (evt) ? evt : window.event; // for IE - if (e.keyCode==13) return true; - if (!this.ProcessKeys(e)) return false; - - if (this.lastKey==38) // Up - { - var newIndex = itemIndex-1; - var focusItem = this.NavPrev(newIndex); - if (focusItem) - { - var child = this.FindChildElement(focusItem.parentNode.parentNode.id); - if (child && child.style.display == 'block') // children visible - { - var n=0; - var tmpElem; - while (1) // search for last child - { - tmpElem = document.getElementById('Item'+newIndex+'_c'+n); - if (tmpElem) - { - focusItem = tmpElem; - } - else // found it! - { - break; - } - n++; - } - } - } - if (focusItem) - { - focusItem.focus(); - } - else // return focus to search field - { - parent.document.getElementById("MSearchField").focus(); - } - } - else if (this.lastKey==40) // Down - { - var newIndex = itemIndex+1; - var focusItem; - var item = document.getElementById('Item'+itemIndex); - var elem = this.FindChildElement(item.parentNode.parentNode.id); - if (elem && elem.style.display == 'block') // children visible - { - focusItem = document.getElementById('Item'+itemIndex+'_c0'); - } - if (!focusItem) focusItem = this.NavNext(newIndex); - if (focusItem) focusItem.focus(); - } - else if (this.lastKey==39) // Right - { - var item = document.getElementById('Item'+itemIndex); - var elem = this.FindChildElement(item.parentNode.parentNode.id); - if (elem) elem.style.display = 'block'; - } - else if (this.lastKey==37) // Left - { - var item = document.getElementById('Item'+itemIndex); - var elem = this.FindChildElement(item.parentNode.parentNode.id); - if (elem) elem.style.display = 'none'; - } - else if (this.lastKey==27) // Escape - { - parent.searchBox.CloseResultsWindow(); - parent.document.getElementById("MSearchField").focus(); - } - else if (this.lastKey==13) // Enter - { - return true; - } - return false; - } - - this.NavChild = function(evt,itemIndex,childIndex) - { - var e = (evt) ? evt : window.event; // for IE - if (e.keyCode==13) return true; - if (!this.ProcessKeys(e)) return false; - - if (this.lastKey==38) // Up - { - if (childIndex>0) - { - var newIndex = childIndex-1; - document.getElementById('Item'+itemIndex+'_c'+newIndex).focus(); - } - else // already at first child, jump to parent - { - document.getElementById('Item'+itemIndex).focus(); - } - } - else if (this.lastKey==40) // Down - { - var newIndex = childIndex+1; - var elem = document.getElementById('Item'+itemIndex+'_c'+newIndex); - if (!elem) // last child, jump to parent next parent - { - elem = this.NavNext(itemIndex+1); - } - if (elem) - { - elem.focus(); - } - } - else if (this.lastKey==27) // Escape - { - parent.searchBox.CloseResultsWindow(); - parent.document.getElementById("MSearchField").focus(); - } - else if (this.lastKey==13) // Enter - { - return true; - } - return false; - } -} - -function setKeyActions(elem,action) -{ - elem.setAttribute('onkeydown',action); - elem.setAttribute('onkeypress',action); - elem.setAttribute('onkeyup',action); -} - -function setClassAttr(elem,attr) -{ - elem.setAttribute('class',attr); - elem.setAttribute('className',attr); -} - -function createResults() -{ - var results = document.getElementById("SRResults"); - for (var e=0; e - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/typedefs_0.js b/xess/doc/doxygen/search/typedefs_0.js deleted file mode 100644 index 4cd0f0b..0000000 --- a/xess/doc/doxygen/search/typedefs_0.js +++ /dev/null @@ -1,4 +0,0 @@ -var searchData= -[ - ['sizecheck_5f_5fline_5f_5f_0',['sizecheck__LINE__',['../xess_8h.html#a8b1577973a08cac2cbbe31bb1297eff5',1,'sizecheck__LINE__(): xess.h'],['../xess__debug_8h.html#a368b9d0a82e205f30f7e7c0da413e318',1,'sizecheck__LINE__(): xess_debug.h']]] -]; diff --git a/xess/doc/doxygen/search/typedefs_1.html b/xess/doc/doxygen/search/typedefs_1.html deleted file mode 100644 index 54ce58e..0000000 --- a/xess/doc/doxygen/search/typedefs_1.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/typedefs_1.js b/xess/doc/doxygen/search/typedefs_1.js deleted file mode 100644 index 728ed7d..0000000 --- a/xess/doc/doxygen/search/typedefs_1.js +++ /dev/null @@ -1,22 +0,0 @@ -var searchData= -[ - ['xess_5f2d_5ft_0',['xess_2d_t',['../xess_8h.html#a3839d654f9989ed64bc09f3a93f16bbb',1,'xess.h']]], - ['xess_5fapp_5flog_5fcallback_5ft_1',['xess_app_log_callback_t',['../xess_8h.html#a6c757a86356ec78ea12f7a0569a945f8',1,'xess.h']]], - ['xess_5fcontext_5fhandle_5ft_2',['xess_context_handle_t',['../xess_8h.html#af31f441c4909f7bbf9fb4491b5f9b927',1,'xess.h']]], - ['xess_5fcoord_5ft_3',['xess_coord_t',['../xess_8h.html#ab4b757ead636df148ed7dbcaf8a86d2f',1,'xess.h']]], - ['xess_5fd3d12_5fexecute_5fparams_5ft_4',['xess_d3d12_execute_params_t',['../xess__d3d12_8h.html#a013d859444728ce4c0b3b95e5437caf5',1,'xess_d3d12.h']]], - ['xess_5fd3d12_5finit_5fparams_5ft_5',['xess_d3d12_init_params_t',['../xess__d3d12_8h.html#a8738b1b1df89db7fcdb1647af648c7d7',1,'xess_d3d12.h']]], - ['xess_5fdump_5felement_5fbits_5ft_6',['xess_dump_element_bits_t',['../xess__debug_8h.html#a516d71b76c0d19198beed6465eb4535c',1,'xess_debug.h']]], - ['xess_5fdump_5felements_5fmask_5ft_7',['xess_dump_elements_mask_t',['../xess__debug_8h.html#a508c6f679546883d9c849cbfd3615363',1,'xess_debug.h']]], - ['xess_5fdump_5fparameters_5ft_8',['xess_dump_parameters_t',['../xess__debug_8h.html#a7a40b052b76b6b70177eb6bca388a214',1,'xess_debug.h']]], - ['xess_5finit_5fflags_5ft_9',['xess_init_flags_t',['../xess_8h.html#a4d9dd06b8ad6424f988f53522f8969a8',1,'xess.h']]], - ['xess_5flogging_5flevel_5ft_10',['xess_logging_level_t',['../xess_8h.html#a6432053aa5103ccd9df8618a7eaaacb8',1,'xess.h']]], - ['xess_5fnetwork_5fmodel_5ft_11',['xess_network_model_t',['../xess__debug_8h.html#a0f8d91004ab90548549da8adb0d4f195',1,'xess_debug.h']]], - ['xess_5fprofiled_5fframe_5fdata_5ft_12',['xess_profiled_frame_data_t',['../xess__d3d12__debug_8h.html#a8fb30e1bc4f2c5e8dab3d8a80c30e3be',1,'xess_d3d12_debug.h']]], - ['xess_5fprofiling_5fdata_5ft_13',['xess_profiling_data_t',['../xess__d3d12__debug_8h.html#ad7d2b8797e2ede0f09b73e1a240583f9',1,'xess_d3d12_debug.h']]], - ['xess_5fproperties_5ft_14',['xess_properties_t',['../xess_8h.html#a81c9ce6225897595f26130f90c41f3e2',1,'xess.h']]], - ['xess_5fquality_5fsettings_5ft_15',['xess_quality_settings_t',['../xess_8h.html#a2a85ea1304caf14b2c008457ee75c7cc',1,'xess.h']]], - ['xess_5fresources_5fto_5fdump_5ft_16',['xess_resources_to_dump_t',['../xess__d3d12__debug_8h.html#a16c2ebf61da2c3a48f3c985c1fb9b8e7',1,'xess_d3d12_debug.h']]], - ['xess_5fresult_5ft_17',['xess_result_t',['../xess_8h.html#a3aa6a07808627ac723a9da324abf10b4',1,'xess.h']]], - ['xess_5fversion_5ft_18',['xess_version_t',['../xess_8h.html#a5b198528154044a5bc33a464e62d34a0',1,'xess.h']]] -]; diff --git a/xess/doc/doxygen/search/variables_0.html b/xess/doc/doxygen/search/variables_0.html deleted file mode 100644 index 950bfc5..0000000 --- a/xess/doc/doxygen/search/variables_0.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/variables_0.js b/xess/doc/doxygen/search/variables_0.js deleted file mode 100644 index eab109b..0000000 --- a/xess/doc/doxygen/search/variables_0.js +++ /dev/null @@ -1,5 +0,0 @@ -var searchData= -[ - ['any_5fprofiling_5fdata_5fin_5fflight_0',['any_profiling_data_in_flight',['../struct__xess__profiling__data__t.html#a7ce6d3494f6a8695edf94fcad38c455e',1,'_xess_profiling_data_t']]], - ['as_5ftensor_1',['as_tensor',['../struct__xess__resources__to__dump__t.html#a055a00bb33a3ade096f537cee6d614ca',1,'_xess_resources_to_dump_t']]] -]; diff --git a/xess/doc/doxygen/search/variables_1.html b/xess/doc/doxygen/search/variables_1.html deleted file mode 100644 index fed58a5..0000000 --- a/xess/doc/doxygen/search/variables_1.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/variables_1.js b/xess/doc/doxygen/search/variables_1.js deleted file mode 100644 index b64d219..0000000 --- a/xess/doc/doxygen/search/variables_1.js +++ /dev/null @@ -1,5 +0,0 @@ -var searchData= -[ - ['border_5fpixels_5fto_5fskip_5fcount_0',['border_pixels_to_skip_count',['../struct__xess__resources__to__dump__t.html#a4b329d03d60ffb48e496e41169018a31',1,'_xess_resources_to_dump_t']]], - ['bufferheapoffset_1',['bufferHeapOffset',['../struct__xess__d3d12__init__params__t.html#aca551e5731fdfe7679b6f3e24cc01d0c',1,'_xess_d3d12_init_params_t']]] -]; diff --git a/xess/doc/doxygen/search/variables_10.html b/xess/doc/doxygen/search/variables_10.html deleted file mode 100644 index e2896f5..0000000 --- a/xess/doc/doxygen/search/variables_10.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/variables_10.js b/xess/doc/doxygen/search/variables_10.js deleted file mode 100644 index a1ce063..0000000 --- a/xess/doc/doxygen/search/variables_10.js +++ /dev/null @@ -1,4 +0,0 @@ -var searchData= -[ - ['x_0',['x',['../struct__xess__2d__t.html#aae8a40a17c0be29c1f06ca6b4f9e2235',1,'_xess_2d_t']]] -]; diff --git a/xess/doc/doxygen/search/variables_11.html b/xess/doc/doxygen/search/variables_11.html deleted file mode 100644 index 0aedfd5..0000000 --- a/xess/doc/doxygen/search/variables_11.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/variables_11.js b/xess/doc/doxygen/search/variables_11.js deleted file mode 100644 index f63239b..0000000 --- a/xess/doc/doxygen/search/variables_11.js +++ /dev/null @@ -1,4 +0,0 @@ -var searchData= -[ - ['y_0',['y',['../struct__xess__2d__t.html#a9c02f93c9698e4486878867c4f265c48',1,'_xess_2d_t']]] -]; diff --git a/xess/doc/doxygen/search/variables_2.html b/xess/doc/doxygen/search/variables_2.html deleted file mode 100644 index 761c194..0000000 --- a/xess/doc/doxygen/search/variables_2.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/variables_2.js b/xess/doc/doxygen/search/variables_2.js deleted file mode 100644 index f0a7e8e..0000000 --- a/xess/doc/doxygen/search/variables_2.js +++ /dev/null @@ -1,4 +0,0 @@ -var searchData= -[ - ['creationnodemask_0',['creationNodeMask',['../struct__xess__d3d12__init__params__t.html#a5a826e34a732802a584fc78091837dc4',1,'_xess_d3d12_init_params_t']]] -]; diff --git a/xess/doc/doxygen/search/variables_3.html b/xess/doc/doxygen/search/variables_3.html deleted file mode 100644 index 78bfe03..0000000 --- a/xess/doc/doxygen/search/variables_3.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/variables_3.js b/xess/doc/doxygen/search/variables_3.js deleted file mode 100644 index dd85e09..0000000 --- a/xess/doc/doxygen/search/variables_3.js +++ /dev/null @@ -1,5 +0,0 @@ -var searchData= -[ - ['descriptorheapoffset_0',['descriptorHeapOffset',['../struct__xess__d3d12__execute__params__t.html#ab718f6c8f437c74e2ad08ace9ee9f130',1,'_xess_d3d12_execute_params_t']]], - ['dump_5felements_5fmask_1',['dump_elements_mask',['../struct__xess__dump__parameters__t.html#a1dd8e9870444dc41b3c1602b15dae269',1,'_xess_dump_parameters_t']]] -]; diff --git a/xess/doc/doxygen/search/variables_4.html b/xess/doc/doxygen/search/variables_4.html deleted file mode 100644 index 4d608da..0000000 --- a/xess/doc/doxygen/search/variables_4.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/variables_4.js b/xess/doc/doxygen/search/variables_4.js deleted file mode 100644 index 0435e34..0000000 --- a/xess/doc/doxygen/search/variables_4.js +++ /dev/null @@ -1,4 +0,0 @@ -var searchData= -[ - ['exposurescale_0',['exposureScale',['../struct__xess__d3d12__execute__params__t.html#a26bc83e12624ccf3b3c793a717e284ff',1,'_xess_d3d12_execute_params_t']]] -]; diff --git a/xess/doc/doxygen/search/variables_5.html b/xess/doc/doxygen/search/variables_5.html deleted file mode 100644 index 6342402..0000000 --- a/xess/doc/doxygen/search/variables_5.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/variables_5.js b/xess/doc/doxygen/search/variables_5.js deleted file mode 100644 index 8af014d..0000000 --- a/xess/doc/doxygen/search/variables_5.js +++ /dev/null @@ -1,7 +0,0 @@ -var searchData= -[ - ['frame_5fcount_0',['frame_count',['../struct__xess__profiling__data__t.html#a75021619d6a71e1e1a4ea1efb3c62138',1,'_xess_profiling_data_t::frame_count()'],['../struct__xess__dump__parameters__t.html#ae3e00071db1070451c10872b09360cad',1,'_xess_dump_parameters_t::frame_count()']]], - ['frame_5fidx_1',['frame_idx',['../struct__xess__dump__parameters__t.html#a675e89be435aec170285f3a1e7e25edf',1,'_xess_dump_parameters_t']]], - ['frame_5findex_2',['frame_index',['../struct__xess__profiled__frame__data__t.html#a7b9f42d4c57d1fe01c782d735be98074',1,'_xess_profiled_frame_data_t']]], - ['frames_3',['frames',['../struct__xess__profiling__data__t.html#a34fa47cf13f15a0c84ae5bc36f08fc1e',1,'_xess_profiling_data_t']]] -]; diff --git a/xess/doc/doxygen/search/variables_6.html b/xess/doc/doxygen/search/variables_6.html deleted file mode 100644 index 80db039..0000000 --- a/xess/doc/doxygen/search/variables_6.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/variables_6.js b/xess/doc/doxygen/search/variables_6.js deleted file mode 100644 index ad7567c..0000000 --- a/xess/doc/doxygen/search/variables_6.js +++ /dev/null @@ -1,6 +0,0 @@ -var searchData= -[ - ['gpu_5fduration_5fnames_0',['gpu_duration_names',['../struct__xess__profiled__frame__data__t.html#a46e787a4e8a96da32fe2b173f3720d6f',1,'_xess_profiled_frame_data_t']]], - ['gpu_5fduration_5frecord_5fcount_1',['gpu_duration_record_count',['../struct__xess__profiled__frame__data__t.html#ab142b6f60de7c00c227011353cb602e5',1,'_xess_profiled_frame_data_t']]], - ['gpu_5fduration_5fvalues_2',['gpu_duration_values',['../struct__xess__profiled__frame__data__t.html#a8f6650843400b1532bdd0ce000a0e689',1,'_xess_profiled_frame_data_t']]] -]; diff --git a/xess/doc/doxygen/search/variables_7.html b/xess/doc/doxygen/search/variables_7.html deleted file mode 100644 index bf8eb38..0000000 --- a/xess/doc/doxygen/search/variables_7.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/variables_7.js b/xess/doc/doxygen/search/variables_7.js deleted file mode 100644 index a0f5763..0000000 --- a/xess/doc/doxygen/search/variables_7.js +++ /dev/null @@ -1,10 +0,0 @@ -var searchData= -[ - ['initflags_0',['initFlags',['../struct__xess__d3d12__init__params__t.html#a2778ccc4a0cacda6c2c73482a77f6e05',1,'_xess_d3d12_init_params_t']]], - ['inputcolorbase_1',['inputColorBase',['../struct__xess__d3d12__execute__params__t.html#a4afe3dfda80148f5a10fa368f3d6a6f8',1,'_xess_d3d12_execute_params_t']]], - ['inputdepthbase_2',['inputDepthBase',['../struct__xess__d3d12__execute__params__t.html#ae6ec27f307c8f3dbf95472d73fc8797a',1,'_xess_d3d12_execute_params_t']]], - ['inputheight_3',['inputHeight',['../struct__xess__d3d12__execute__params__t.html#a2ee55ecbea691cf3d9c000055e8dfe1b',1,'_xess_d3d12_execute_params_t']]], - ['inputmotionvectorbase_4',['inputMotionVectorBase',['../struct__xess__d3d12__execute__params__t.html#abbd7c1808dbafcb1aa0475fd8ab70066',1,'_xess_d3d12_execute_params_t']]], - ['inputresponsivemaskbase_5',['inputResponsiveMaskBase',['../struct__xess__d3d12__execute__params__t.html#accb3d97fb6ba85e6560c9871010a3c57',1,'_xess_d3d12_execute_params_t']]], - ['inputwidth_6',['inputWidth',['../struct__xess__d3d12__execute__params__t.html#ad57863724c458e3583d0acb4be23cb7b',1,'_xess_d3d12_execute_params_t']]] -]; diff --git a/xess/doc/doxygen/search/variables_8.html b/xess/doc/doxygen/search/variables_8.html deleted file mode 100644 index 92a55e9..0000000 --- a/xess/doc/doxygen/search/variables_8.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/variables_8.js b/xess/doc/doxygen/search/variables_8.js deleted file mode 100644 index 5ae439b..0000000 --- a/xess/doc/doxygen/search/variables_8.js +++ /dev/null @@ -1,5 +0,0 @@ -var searchData= -[ - ['jitteroffsetx_0',['jitterOffsetX',['../struct__xess__d3d12__execute__params__t.html#a701953ac726be26afde35ba21b1854f5',1,'_xess_d3d12_execute_params_t']]], - ['jitteroffsety_1',['jitterOffsetY',['../struct__xess__d3d12__execute__params__t.html#ab8fec73568168bc8ba655190c20b98b0',1,'_xess_d3d12_execute_params_t']]] -]; diff --git a/xess/doc/doxygen/search/variables_9.html b/xess/doc/doxygen/search/variables_9.html deleted file mode 100644 index 1aec773..0000000 --- a/xess/doc/doxygen/search/variables_9.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/variables_9.js b/xess/doc/doxygen/search/variables_9.js deleted file mode 100644 index 0e84dfc..0000000 --- a/xess/doc/doxygen/search/variables_9.js +++ /dev/null @@ -1,5 +0,0 @@ -var searchData= -[ - ['major_0',['major',['../struct__xess__version__t.html#a600930655b7237315b72223c48327ea8',1,'_xess_version_t']]], - ['minor_1',['minor',['../struct__xess__version__t.html#a9f280ce3ae5b6cd9346fd7a09ff29168',1,'_xess_version_t']]] -]; diff --git a/xess/doc/doxygen/search/variables_a.html b/xess/doc/doxygen/search/variables_a.html deleted file mode 100644 index 8090d16..0000000 --- a/xess/doc/doxygen/search/variables_a.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/variables_a.js b/xess/doc/doxygen/search/variables_a.js deleted file mode 100644 index 4a6343b..0000000 --- a/xess/doc/doxygen/search/variables_a.js +++ /dev/null @@ -1,5 +0,0 @@ -var searchData= -[ - ['outputcolorbase_0',['outputColorBase',['../struct__xess__d3d12__execute__params__t.html#a6408622b605e51416238460aa3e58533',1,'_xess_d3d12_execute_params_t']]], - ['outputresolution_1',['outputResolution',['../struct__xess__d3d12__init__params__t.html#adefd841ee2588585d89bf91ced85e84c',1,'_xess_d3d12_init_params_t']]] -]; diff --git a/xess/doc/doxygen/search/variables_b.html b/xess/doc/doxygen/search/variables_b.html deleted file mode 100644 index 5ceb53f..0000000 --- a/xess/doc/doxygen/search/variables_b.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/variables_b.js b/xess/doc/doxygen/search/variables_b.js deleted file mode 100644 index 3698e8f..0000000 --- a/xess/doc/doxygen/search/variables_b.js +++ /dev/null @@ -1,15 +0,0 @@ -var searchData= -[ - ['patch_0',['patch',['../struct__xess__version__t.html#ab74656704767a7e73da4cd20dfd51a5d',1,'_xess_version_t']]], - ['path_1',['path',['../struct__xess__dump__parameters__t.html#a3b02c6de5c049804444a246f7fdf46b4',1,'_xess_dump_parameters_t']]], - ['pcolortexture_2',['pColorTexture',['../struct__xess__d3d12__execute__params__t.html#af0438b6fee2a81109430081d6d822090',1,'_xess_d3d12_execute_params_t']]], - ['pdepthtexture_3',['pDepthTexture',['../struct__xess__d3d12__execute__params__t.html#a0aced69da09a2f6ef2e7034270ca513c',1,'_xess_d3d12_execute_params_t']]], - ['pdescriptorheap_4',['pDescriptorHeap',['../struct__xess__d3d12__execute__params__t.html#a6a5db20b91a54c5160e350c7ba544c51',1,'_xess_d3d12_execute_params_t']]], - ['pexposurescaletexture_5',['pExposureScaleTexture',['../struct__xess__d3d12__execute__params__t.html#a848453834ef179e0694c525051fbf493',1,'_xess_d3d12_execute_params_t']]], - ['poutputtexture_6',['pOutputTexture',['../struct__xess__d3d12__execute__params__t.html#a680b0c0b8f150bd2f8a4bd07da22519e',1,'_xess_d3d12_execute_params_t']]], - ['ppipelinelibrary_7',['pPipelineLibrary',['../struct__xess__d3d12__init__params__t.html#a254d1c85f1dde5405a267084da481ad9',1,'_xess_d3d12_init_params_t']]], - ['presponsivepixelmasktexture_8',['pResponsivePixelMaskTexture',['../struct__xess__d3d12__execute__params__t.html#aa9210e99440b1564285d6d88ddf4d789',1,'_xess_d3d12_execute_params_t']]], - ['ptempbufferheap_9',['pTempBufferHeap',['../struct__xess__d3d12__init__params__t.html#a8b41cbb0e0c875bf2631ef6b414d4259',1,'_xess_d3d12_init_params_t']]], - ['ptemptextureheap_10',['pTempTextureHeap',['../struct__xess__d3d12__init__params__t.html#a32b6ed71e10b2df805c033b158f9d1f5',1,'_xess_d3d12_init_params_t']]], - ['pvelocitytexture_11',['pVelocityTexture',['../struct__xess__d3d12__execute__params__t.html#a112aa451fae1a83e2bc6ffc999206c2a',1,'_xess_d3d12_execute_params_t']]] -]; diff --git a/xess/doc/doxygen/search/variables_c.html b/xess/doc/doxygen/search/variables_c.html deleted file mode 100644 index 5dbea70..0000000 --- a/xess/doc/doxygen/search/variables_c.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/variables_c.js b/xess/doc/doxygen/search/variables_c.js deleted file mode 100644 index c239569..0000000 --- a/xess/doc/doxygen/search/variables_c.js +++ /dev/null @@ -1,4 +0,0 @@ -var searchData= -[ - ['qualitysetting_0',['qualitySetting',['../struct__xess__d3d12__init__params__t.html#ad1566e156f30842fc8a32e5e508094b2',1,'_xess_d3d12_init_params_t']]] -]; diff --git a/xess/doc/doxygen/search/variables_d.html b/xess/doc/doxygen/search/variables_d.html deleted file mode 100644 index e7cd3a3..0000000 --- a/xess/doc/doxygen/search/variables_d.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/variables_d.js b/xess/doc/doxygen/search/variables_d.js deleted file mode 100644 index e54e566..0000000 --- a/xess/doc/doxygen/search/variables_d.js +++ /dev/null @@ -1,10 +0,0 @@ -var searchData= -[ - ['requireddescriptorcount_0',['requiredDescriptorCount',['../struct__xess__properties__t.html#a2dc96375a6205c03219a9904a568c01c',1,'_xess_properties_t']]], - ['reserved_1',['reserved',['../struct__xess__version__t.html#a5a6ed8c04a3db86066924b1a1bf4dad3',1,'_xess_version_t']]], - ['reserved0_2',['reserved0',['../struct__xess__d3d12__execute__params__t.html#a99430c650ba489b07be8478c32b22606',1,'_xess_d3d12_execute_params_t']]], - ['resethistory_3',['resetHistory',['../struct__xess__d3d12__execute__params__t.html#af2336172df07c9d4a8d36a9a1f188a2e',1,'_xess_d3d12_execute_params_t']]], - ['resource_5fcount_4',['resource_count',['../struct__xess__resources__to__dump__t.html#afa5d343e953478907a576e9c372a5838',1,'_xess_resources_to_dump_t']]], - ['resource_5fnames_5',['resource_names',['../struct__xess__resources__to__dump__t.html#a4f61a0f5b6b502a4cd89405410853fde',1,'_xess_resources_to_dump_t']]], - ['resources_6',['resources',['../struct__xess__resources__to__dump__t.html#aeb3cb43b5376fe80794c4f5e4b47ff68',1,'_xess_resources_to_dump_t']]] -]; diff --git a/xess/doc/doxygen/search/variables_e.html b/xess/doc/doxygen/search/variables_e.html deleted file mode 100644 index b2e6719..0000000 --- a/xess/doc/doxygen/search/variables_e.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/variables_e.js b/xess/doc/doxygen/search/variables_e.js deleted file mode 100644 index fb096f6..0000000 --- a/xess/doc/doxygen/search/variables_e.js +++ /dev/null @@ -1,9 +0,0 @@ -var searchData= -[ - ['tempbufferheapsize_0',['tempBufferHeapSize',['../struct__xess__properties__t.html#a0db8617705e860098e048d7f3e5466ff',1,'_xess_properties_t']]], - ['temptextureheapsize_1',['tempTextureHeapSize',['../struct__xess__properties__t.html#a209e8c58699154a12ca8c51d190565ee',1,'_xess_properties_t']]], - ['tensor_5fchannel_5fcount_2',['tensor_channel_count',['../struct__xess__resources__to__dump__t.html#ae59e9714ae9a69c614783e31a585a221',1,'_xess_resources_to_dump_t']]], - ['tensor_5fheight_3',['tensor_height',['../struct__xess__resources__to__dump__t.html#a7d6bf0ceee8b6abbb2678a630531e4fb',1,'_xess_resources_to_dump_t']]], - ['tensor_5fwidth_4',['tensor_width',['../struct__xess__resources__to__dump__t.html#a1b5c859fbf4a5eb748d5381e6063f673',1,'_xess_resources_to_dump_t']]], - ['textureheapoffset_5',['textureHeapOffset',['../struct__xess__d3d12__init__params__t.html#a9e2ba8ca5471d07e4bb30183deb00e56',1,'_xess_d3d12_init_params_t']]] -]; diff --git a/xess/doc/doxygen/search/variables_f.html b/xess/doc/doxygen/search/variables_f.html deleted file mode 100644 index fe01445..0000000 --- a/xess/doc/doxygen/search/variables_f.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
    -
    Loading...
    -
    - -
    Searching...
    -
    No Matches
    - -
    - - diff --git a/xess/doc/doxygen/search/variables_f.js b/xess/doc/doxygen/search/variables_f.js deleted file mode 100644 index 88216c6..0000000 --- a/xess/doc/doxygen/search/variables_f.js +++ /dev/null @@ -1,4 +0,0 @@ -var searchData= -[ - ['visiblenodemask_0',['visibleNodeMask',['../struct__xess__d3d12__init__params__t.html#a153b79c833ddce15c33d78691a679ca3',1,'_xess_d3d12_init_params_t']]] -]; diff --git a/xess/doc/doxygen/splitbar.png b/xess/doc/doxygen/splitbar.png deleted file mode 100644 index fe895f2..0000000 Binary files a/xess/doc/doxygen/splitbar.png and /dev/null differ diff --git a/xess/doc/doxygen/struct__xess__2d__t.html b/xess/doc/doxygen/struct__xess__2d__t.html deleted file mode 100644 index f497f2a..0000000 --- a/xess/doc/doxygen/struct__xess__2d__t.html +++ /dev/null @@ -1,154 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: _xess_2d_t Struct Reference - - - - - - - - - - - - - -
    -
    - - - - - - - -
    -
    XeSS SDK API Reference Guide 1.0.0 -
    -
    -
    - - - - - - - -
    -
    - -
    -
    -
    - -
    - -
    -
    - - -
    - -
    - -
    - -
    _xess_2d_t Struct Reference
    -
    -
    - -

    2D variable. - More...

    - -

    #include <xess.h>

    - - - - - - -

    -Data Fields

    uint32_t x
     
    uint32_t y
     
    -

    Detailed Description

    -

    2D variable.

    - -

    Definition at line 79 of file xess.h.

    -

    Field Documentation

    - -

    ◆ x

    - -
    -
    - - - - -
    uint32_t x
    -
    - -

    Definition at line 81 of file xess.h.

    - -
    -
    - -

    ◆ y

    - -
    -
    - - - - -
    uint32_t y
    -
    - -

    Definition at line 82 of file xess.h.

    - -
    -
    -
    The documentation for this struct was generated from the following file:
      -
    • D:/qb/workspace/29555/source/libraries.gpu.rendering.xess.xess-sdk/libxess/include/xess/xess.h
    • -
    -
    -
    - - - - diff --git a/xess/doc/doxygen/struct__xess__2d__t.js b/xess/doc/doxygen/struct__xess__2d__t.js deleted file mode 100644 index 2dd7d9a..0000000 --- a/xess/doc/doxygen/struct__xess__2d__t.js +++ /dev/null @@ -1,5 +0,0 @@ -var struct__xess__2d__t = -[ - [ "x", "struct__xess__2d__t.html#aae8a40a17c0be29c1f06ca6b4f9e2235", null ], - [ "y", "struct__xess__2d__t.html#a9c02f93c9698e4486878867c4f265c48", null ] -]; \ No newline at end of file diff --git a/xess/doc/doxygen/struct__xess__d3d12__execute__params__t.html b/xess/doc/doxygen/struct__xess__d3d12__execute__params__t.html deleted file mode 100644 index 7fb2f99..0000000 --- a/xess/doc/doxygen/struct__xess__d3d12__execute__params__t.html +++ /dev/null @@ -1,498 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: _xess_d3d12_execute_params_t Struct Reference - - - - - - - - - - - - - -
    -
    - - - - - - - -
    -
    XeSS SDK API Reference Guide 1.0.0 -
    -
    -
    - - - - - - - -
    -
    - -
    -
    -
    - -
    - -
    -
    - - -
    - -
    - -
    - -
    _xess_d3d12_execute_params_t Struct Reference
    -
    -
    - -

    Execution parameters for XeSS D3D12. - More...

    - -

    #include <xess_d3d12.h>

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    -Data Fields

    ID3D12Resource * pColorTexture
     
    ID3D12Resource * pVelocityTexture
     
    ID3D12Resource * pDepthTexture
     
    ID3D12Resource * pExposureScaleTexture
     
    ID3D12Resource * pResponsivePixelMaskTexture
     
    ID3D12Resource * pOutputTexture
     
    float jitterOffsetX
     
    float jitterOffsetY
     
    float exposureScale
     
    uint32_t resetHistory
     
    uint32_t inputWidth
     
    uint32_t inputHeight
     
    xess_coord_t inputColorBase
     
    xess_coord_t inputMotionVectorBase
     
    xess_coord_t inputDepthBase
     
    xess_coord_t inputResponsiveMaskBase
     
    xess_coord_t reserved0
     
    xess_coord_t outputColorBase
     
    ID3D12DescriptorHeap * pDescriptorHeap
     
    uint32_t descriptorHeapOffset
     
    -

    Detailed Description

    -

    Execution parameters for XeSS D3D12.

    - -

    Definition at line 33 of file xess_d3d12.h.

    -

    Field Documentation

    - -

    ◆ descriptorHeapOffset

    - -
    -
    - - - - -
    uint32_t descriptorHeapOffset
    -
    -

    Offset in external descriptor heap in bytes.

    - -

    Definition at line 78 of file xess_d3d12.h.

    - -
    -
    - -

    ◆ exposureScale

    - -
    -
    - - - - -
    float exposureScale
    -
    -

    Optional input color scaling. Default is 1.

    - -

    Definition at line 56 of file xess_d3d12.h.

    - -
    -
    - -

    ◆ inputColorBase

    - -
    -
    - - - - -
    xess_coord_t inputColorBase
    -
    -

    Base coordinate for the input color in the texture. Default is (0,0).

    - -

    Definition at line 64 of file xess_d3d12.h.

    - -
    -
    - -

    ◆ inputDepthBase

    - -
    -
    - - - - -
    xess_coord_t inputDepthBase
    -
    -

    Base coordinate for the input depth in the texture. Default is (0,0).

    - -

    Definition at line 68 of file xess_d3d12.h.

    - -
    -
    - -

    ◆ inputHeight

    - -
    -
    - - - - -
    uint32_t inputHeight
    -
    -

    Input color height.

    - -

    Definition at line 62 of file xess_d3d12.h.

    - -
    -
    - -

    ◆ inputMotionVectorBase

    - -
    -
    - - - - -
    xess_coord_t inputMotionVectorBase
    -
    -

    Base coordinate for the input motion vector in the texture. Default is (0,0).

    - -

    Definition at line 66 of file xess_d3d12.h.

    - -
    -
    - -

    ◆ inputResponsiveMaskBase

    - -
    -
    - - - - -
    xess_coord_t inputResponsiveMaskBase
    -
    -

    Base coordinate for the input responsive pixel mask in the texture. Default is (0,0).

    - -

    Definition at line 70 of file xess_d3d12.h.

    - -
    -
    - -

    ◆ inputWidth

    - -
    -
    - - - - -
    uint32_t inputWidth
    -
    -

    Input color width.

    - -

    Definition at line 60 of file xess_d3d12.h.

    - -
    -
    - -

    ◆ jitterOffsetX

    - -
    -
    - - - - -
    float jitterOffsetX
    -
    -

    Jitter X coordinate in the range [-0.5, 0.5].

    - -

    Definition at line 52 of file xess_d3d12.h.

    - -
    -
    - -

    ◆ jitterOffsetY

    - -
    -
    - - - - -
    float jitterOffsetY
    -
    -

    Jitter Y coordinate in the range [-0.5, 0.5].

    - -

    Definition at line 54 of file xess_d3d12.h.

    - -
    -
    - -

    ◆ outputColorBase

    - -
    -
    - - - - -
    xess_coord_t outputColorBase
    -
    -

    Base coordinate for the output color. Default is (0,0).

    - -

    Definition at line 74 of file xess_d3d12.h.

    - -
    -
    - -

    ◆ pColorTexture

    - -
    -
    - - - - -
    ID3D12Resource* pColorTexture
    -
    -

    Input color texture. Must be in NON_PIXEL_SHADER_RESOURCE state.

    - -

    Definition at line 36 of file xess_d3d12.h.

    - -
    -
    - -

    ◆ pDepthTexture

    - -
    -
    - - - - -
    ID3D12Resource* pDepthTexture
    -
    -

    Optional depth texture. Required if XESS_INIT_FLAG_HIGH_RES_MV has not been specified. Must be in NON_PIXEL_SHADER_RESOURCE state.

    - -

    Definition at line 41 of file xess_d3d12.h.

    - -
    -
    - -

    ◆ pDescriptorHeap

    - -
    -
    - - - - -
    ID3D12DescriptorHeap* pDescriptorHeap
    -
    -

    Optional external descriptor heap.

    - -

    Definition at line 76 of file xess_d3d12.h.

    - -
    -
    - -

    ◆ pExposureScaleTexture

    - -
    -
    - - - - -
    ID3D12Resource* pExposureScaleTexture
    -
    -

    Optional 1x1 exposure scale texture. Required if XESS_INIT_FLAG_EXPOSURE_TEXTURE has been specified. Must be in NON_PIXEL_SHADER_RESOURCE state

    - -

    Definition at line 44 of file xess_d3d12.h.

    - -
    -
    - -

    ◆ pOutputTexture

    - -
    -
    - - - - -
    ID3D12Resource* pOutputTexture
    -
    -

    Output texture in target resolution. Must be in UNORDERED_ACCESS state.

    - -

    Definition at line 49 of file xess_d3d12.h.

    - -
    -
    - -

    ◆ pResponsivePixelMaskTexture

    - -
    -
    - - - - -
    ID3D12Resource* pResponsivePixelMaskTexture
    -
    -

    Optional responsive pixel mask texture. Required if XESS_INIT_FLAG_RESPONSIVE_PIXEL_MASK has been specified. Must be in NON_PIXEL_SHADER_RESOURCE state

    - -

    Definition at line 47 of file xess_d3d12.h.

    - -
    -
    - -

    ◆ pVelocityTexture

    - -
    -
    - - - - -
    ID3D12Resource* pVelocityTexture
    -
    -

    Input motion vector texture. Must be in NON_PIXEL_SHADER_RESOURCE state.

    - -

    Definition at line 38 of file xess_d3d12.h.

    - -
    -
    - -

    ◆ reserved0

    - -
    -
    - - - - -
    xess_coord_t reserved0
    -
    -

    Reserved parameter.

    - -

    Definition at line 72 of file xess_d3d12.h.

    - -
    -
    - -

    ◆ resetHistory

    - -
    -
    - - - - -
    uint32_t resetHistory
    -
    -

    Resets the history accumulation in this frame.

    - -

    Definition at line 58 of file xess_d3d12.h.

    - -
    -
    -
    The documentation for this struct was generated from the following file:
      -
    • D:/qb/workspace/29555/source/libraries.gpu.rendering.xess.xess-sdk/libxess/include/xess/xess_d3d12.h
    • -
    -
    -
    - - - - diff --git a/xess/doc/doxygen/struct__xess__d3d12__execute__params__t.js b/xess/doc/doxygen/struct__xess__d3d12__execute__params__t.js deleted file mode 100644 index 3394992..0000000 --- a/xess/doc/doxygen/struct__xess__d3d12__execute__params__t.js +++ /dev/null @@ -1,23 +0,0 @@ -var struct__xess__d3d12__execute__params__t = -[ - [ "descriptorHeapOffset", "struct__xess__d3d12__execute__params__t.html#ab718f6c8f437c74e2ad08ace9ee9f130", null ], - [ "exposureScale", "struct__xess__d3d12__execute__params__t.html#a26bc83e12624ccf3b3c793a717e284ff", null ], - [ "inputColorBase", "struct__xess__d3d12__execute__params__t.html#a4afe3dfda80148f5a10fa368f3d6a6f8", null ], - [ "inputDepthBase", "struct__xess__d3d12__execute__params__t.html#ae6ec27f307c8f3dbf95472d73fc8797a", null ], - [ "inputHeight", "struct__xess__d3d12__execute__params__t.html#a2ee55ecbea691cf3d9c000055e8dfe1b", null ], - [ "inputMotionVectorBase", "struct__xess__d3d12__execute__params__t.html#abbd7c1808dbafcb1aa0475fd8ab70066", null ], - [ "inputResponsiveMaskBase", "struct__xess__d3d12__execute__params__t.html#accb3d97fb6ba85e6560c9871010a3c57", null ], - [ "inputWidth", "struct__xess__d3d12__execute__params__t.html#ad57863724c458e3583d0acb4be23cb7b", null ], - [ "jitterOffsetX", "struct__xess__d3d12__execute__params__t.html#a701953ac726be26afde35ba21b1854f5", null ], - [ "jitterOffsetY", "struct__xess__d3d12__execute__params__t.html#ab8fec73568168bc8ba655190c20b98b0", null ], - [ "outputColorBase", "struct__xess__d3d12__execute__params__t.html#a6408622b605e51416238460aa3e58533", null ], - [ "pColorTexture", "struct__xess__d3d12__execute__params__t.html#af0438b6fee2a81109430081d6d822090", null ], - [ "pDepthTexture", "struct__xess__d3d12__execute__params__t.html#a0aced69da09a2f6ef2e7034270ca513c", null ], - [ "pDescriptorHeap", "struct__xess__d3d12__execute__params__t.html#a6a5db20b91a54c5160e350c7ba544c51", null ], - [ "pExposureScaleTexture", "struct__xess__d3d12__execute__params__t.html#a848453834ef179e0694c525051fbf493", null ], - [ "pOutputTexture", "struct__xess__d3d12__execute__params__t.html#a680b0c0b8f150bd2f8a4bd07da22519e", null ], - [ "pResponsivePixelMaskTexture", "struct__xess__d3d12__execute__params__t.html#aa9210e99440b1564285d6d88ddf4d789", null ], - [ "pVelocityTexture", "struct__xess__d3d12__execute__params__t.html#a112aa451fae1a83e2bc6ffc999206c2a", null ], - [ "reserved0", "struct__xess__d3d12__execute__params__t.html#a99430c650ba489b07be8478c32b22606", null ], - [ "resetHistory", "struct__xess__d3d12__execute__params__t.html#af2336172df07c9d4a8d36a9a1f188a2e", null ] -]; \ No newline at end of file diff --git a/xess/doc/doxygen/struct__xess__d3d12__init__params__t.html b/xess/doc/doxygen/struct__xess__d3d12__init__params__t.html deleted file mode 100644 index f9cd2b8..0000000 --- a/xess/doc/doxygen/struct__xess__d3d12__init__params__t.html +++ /dev/null @@ -1,308 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: _xess_d3d12_init_params_t Struct Reference - - - - - - - - - - - - - -
    -
    - - - - - - - -
    -
    XeSS SDK API Reference Guide 1.0.0 -
    -
    -
    - - - - - - - -
    -
    - -
    -
    -
    - -
    - -
    -
    - - -
    - -
    - -
    - -
    _xess_d3d12_init_params_t Struct Reference
    -
    -
    - -

    Initialization parameters for XeSS D3D12. - More...

    - -

    #include <xess_d3d12.h>

    - - - - - - - - - - - - - - - - - - - - - - -

    -Data Fields

    xess_2d_t outputResolution
     
    xess_quality_settings_t qualitySetting
     
    uint32_t initFlags
     
    uint32_t creationNodeMask
     
    uint32_t visibleNodeMask
     
    ID3D12Heap * pTempBufferHeap
     
    uint64_t bufferHeapOffset
     
    ID3D12Heap * pTempTextureHeap
     
    uint64_t textureHeapOffset
     
    ID3D12PipelineLibrary * pPipelineLibrary
     
    -

    Detailed Description

    -

    Initialization parameters for XeSS D3D12.

    - -

    Definition at line 86 of file xess_d3d12.h.

    -

    Field Documentation

    - -

    ◆ bufferHeapOffset

    - -
    -
    - - - - -
    uint64_t bufferHeapOffset
    -
    -

    Offset in the externally allocated heap for temporary buffer storage.

    - -

    Definition at line 105 of file xess_d3d12.h.

    - -
    -
    - -

    ◆ creationNodeMask

    - -
    -
    - - - - -
    uint32_t creationNodeMask
    -
    -

    Specifies the node mask for internally created resources on multi-adapter systems.

    - -

    Definition at line 96 of file xess_d3d12.h.

    - -
    -
    - -

    ◆ initFlags

    - -
    -
    - - - - -
    uint32_t initFlags
    -
    -

    Initialization flags.

    - -

    Definition at line 93 of file xess_d3d12.h.

    - -
    -
    - -

    ◆ outputResolution

    - -
    -
    - - - - -
    xess_2d_t outputResolution
    -
    -

    Output width and height.

    - -

    Definition at line 89 of file xess_d3d12.h.

    - -
    -
    - -

    ◆ pPipelineLibrary

    - -
    -
    - - - - -
    ID3D12PipelineLibrary* pPipelineLibrary
    -
    -

    Pointer to pipeline library. If not NULL will be used for pipeline caching.

    - -

    Definition at line 113 of file xess_d3d12.h.

    - -
    -
    - -

    ◆ pTempBufferHeap

    - -
    -
    - - - - -
    ID3D12Heap* pTempBufferHeap
    -
    -

    Optional externally allocated buffer storage for XeSS. If NULL the storage is allocated internally. If allocated, the heap type must be D3D12_HEAP_TYPE_DEFAULT. This heap is not accessed by the CPU.

    - -

    Definition at line 103 of file xess_d3d12.h.

    - -
    -
    - -

    ◆ pTempTextureHeap

    - -
    -
    - - - - -
    ID3D12Heap* pTempTextureHeap
    -
    -

    Optional externally allocated texture storage for XeSS. If NULL the storage is allocated internally. If allocated, the heap type must be D3D12_HEAP_TYPE_DEFAULT. This heap is not accessed by the CPU.

    - -

    Definition at line 109 of file xess_d3d12.h.

    - -
    -
    - -

    ◆ qualitySetting

    - -
    -
    - - - - -
    xess_quality_settings_t qualitySetting
    -
    -

    Quality setting

    - -

    Definition at line 91 of file xess_d3d12.h.

    - -
    -
    - -

    ◆ textureHeapOffset

    - -
    -
    - - - - -
    uint64_t textureHeapOffset
    -
    -

    Offset in the externally allocated heap for temporary texture storage.

    - -

    Definition at line 111 of file xess_d3d12.h.

    - -
    -
    - -

    ◆ visibleNodeMask

    - -
    -
    - - - - -
    uint32_t visibleNodeMask
    -
    -

    Specifies the node visibility mask for internally created resources on multi-adapter systems.

    - -

    Definition at line 99 of file xess_d3d12.h.

    - -
    -
    -
    The documentation for this struct was generated from the following file:
      -
    • D:/qb/workspace/29555/source/libraries.gpu.rendering.xess.xess-sdk/libxess/include/xess/xess_d3d12.h
    • -
    -
    -
    - - - - diff --git a/xess/doc/doxygen/struct__xess__d3d12__init__params__t.js b/xess/doc/doxygen/struct__xess__d3d12__init__params__t.js deleted file mode 100644 index b450712..0000000 --- a/xess/doc/doxygen/struct__xess__d3d12__init__params__t.js +++ /dev/null @@ -1,13 +0,0 @@ -var struct__xess__d3d12__init__params__t = -[ - [ "bufferHeapOffset", "struct__xess__d3d12__init__params__t.html#aca551e5731fdfe7679b6f3e24cc01d0c", null ], - [ "creationNodeMask", "struct__xess__d3d12__init__params__t.html#a5a826e34a732802a584fc78091837dc4", null ], - [ "initFlags", "struct__xess__d3d12__init__params__t.html#a2778ccc4a0cacda6c2c73482a77f6e05", null ], - [ "outputResolution", "struct__xess__d3d12__init__params__t.html#adefd841ee2588585d89bf91ced85e84c", null ], - [ "pPipelineLibrary", "struct__xess__d3d12__init__params__t.html#a254d1c85f1dde5405a267084da481ad9", null ], - [ "pTempBufferHeap", "struct__xess__d3d12__init__params__t.html#a8b41cbb0e0c875bf2631ef6b414d4259", null ], - [ "pTempTextureHeap", "struct__xess__d3d12__init__params__t.html#a32b6ed71e10b2df805c033b158f9d1f5", null ], - [ "qualitySetting", "struct__xess__d3d12__init__params__t.html#ad1566e156f30842fc8a32e5e508094b2", null ], - [ "textureHeapOffset", "struct__xess__d3d12__init__params__t.html#a9e2ba8ca5471d07e4bb30183deb00e56", null ], - [ "visibleNodeMask", "struct__xess__d3d12__init__params__t.html#a153b79c833ddce15c33d78691a679ca3", null ] -]; \ No newline at end of file diff --git a/xess/doc/doxygen/struct__xess__dump__parameters__t.html b/xess/doc/doxygen/struct__xess__dump__parameters__t.html deleted file mode 100644 index 254d361..0000000 --- a/xess/doc/doxygen/struct__xess__dump__parameters__t.html +++ /dev/null @@ -1,190 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: _xess_dump_parameters_t Struct Reference - - - - - - - - - - - - - -
    -
    - - - - - - - -
    -
    XeSS SDK API Reference Guide 1.0.0 -
    -
    -
    - - - - - - - -
    -
    - -
    -
    -
    - -
    - -
    -
    - - -
    - -
    - -
    - -
    _xess_dump_parameters_t Struct Reference
    -
    -
    - -

    #include <xess_debug.h>

    - - - - - - - - - - -

    -Data Fields

    const char * path
     
    uint32_t frame_idx
     
    uint32_t frame_count
     
    xess_dump_elements_mask_t dump_elements_mask
     
    -

    Detailed Description

    -
    -

    Definition at line 55 of file xess_debug.h.

    -

    Field Documentation

    - -

    ◆ dump_elements_mask

    - -
    -
    - - - - -
    xess_dump_elements_mask_t dump_elements_mask
    -
    -

    Bitset showing set of elements that must be dumped. Element will be dumped if it exist and corrseponding bit is not 0. Since it's meaningless to call Dump with empty set value of 0 will mean DUMP_ALL_INPUTS

    - -

    Definition at line 73 of file xess_debug.h.

    - -
    -
    - -

    ◆ frame_count

    - -
    -
    - - - - -
    uint32_t frame_count
    -
    -

    Frame count to dump. Few frames less may be dumped due to possible frames in flight in application

    - -

    Definition at line 68 of file xess_debug.h.

    - -
    -
    - -

    ◆ frame_idx

    - -
    -
    - - - - -
    uint32_t frame_idx
    -
    -

    Frame index. Will be used as start for frame sequence.

    - -

    Definition at line 64 of file xess_debug.h.

    - -
    -
    - -

    ◆ path

    - -
    -
    - - - - -
    const char* path
    -
    -

    NULL-terminated ASCII string to existing folder where dump files should be written. Library do not create the folder. Files in provided folder will be overwritten.

    - -

    Definition at line 62 of file xess_debug.h.

    - -
    -
    -
    The documentation for this struct was generated from the following file:
      -
    • D:/qb/workspace/29555/source/libraries.gpu.rendering.xess.xess-sdk/libxess/include/xess/xess_debug.h
    • -
    -
    -
    - - - - diff --git a/xess/doc/doxygen/struct__xess__dump__parameters__t.js b/xess/doc/doxygen/struct__xess__dump__parameters__t.js deleted file mode 100644 index 72b22c9..0000000 --- a/xess/doc/doxygen/struct__xess__dump__parameters__t.js +++ /dev/null @@ -1,7 +0,0 @@ -var struct__xess__dump__parameters__t = -[ - [ "dump_elements_mask", "struct__xess__dump__parameters__t.html#a1dd8e9870444dc41b3c1602b15dae269", null ], - [ "frame_count", "struct__xess__dump__parameters__t.html#ae3e00071db1070451c10872b09360cad", null ], - [ "frame_idx", "struct__xess__dump__parameters__t.html#a675e89be435aec170285f3a1e7e25edf", null ], - [ "path", "struct__xess__dump__parameters__t.html#a3b02c6de5c049804444a246f7fdf46b4", null ] -]; \ No newline at end of file diff --git a/xess/doc/doxygen/struct__xess__profiled__frame__data__t.html b/xess/doc/doxygen/struct__xess__profiled__frame__data__t.html deleted file mode 100644 index 08cfe07..0000000 --- a/xess/doc/doxygen/struct__xess__profiled__frame__data__t.html +++ /dev/null @@ -1,190 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: _xess_profiled_frame_data_t Struct Reference - - - - - - - - - - - - - -
    -
    - - - - - - - -
    -
    XeSS SDK API Reference Guide 1.0.0 -
    -
    -
    - - - - - - - -
    -
    - -
    -
    -
    - -
    - -
    -
    - - -
    - -
    - -
    - -
    _xess_profiled_frame_data_t Struct Reference
    -
    -
    - -

    #include <xess_d3d12_debug.h>

    - - - - - - - - - - -

    -Data Fields

    uint64_t frame_index
     
    uint64_t gpu_duration_record_count
     
    const char *const * gpu_duration_names
     
    const double * gpu_duration_values
     
    -

    Detailed Description

    -
    -

    Definition at line 61 of file xess_d3d12_debug.h.

    -

    Field Documentation

    - -

    ◆ frame_index

    - -
    -
    - - - - -
    uint64_t frame_index
    -
    -

    Execution index in context's instance.

    - -

    Definition at line 64 of file xess_d3d12_debug.h.

    - -
    -
    - -

    ◆ gpu_duration_names

    - -
    -
    - - - - -
    const char* const* gpu_duration_names
    -
    -

    Pointer to an internal array of duration names.

    - -

    Definition at line 68 of file xess_d3d12_debug.h.

    - -
    -
    - -

    ◆ gpu_duration_record_count

    - -
    -
    - - - - -
    uint64_t gpu_duration_record_count
    -
    -

    Total labeled gpu duration records stored in gpu_duration* arrays.

    - -

    Definition at line 66 of file xess_d3d12_debug.h.

    - -
    -
    - -

    ◆ gpu_duration_values

    - -
    -
    - - - - -
    const double* gpu_duration_values
    -
    -

    Pointer to an internal array of duration values. [seconds]

    - -

    Definition at line 70 of file xess_d3d12_debug.h.

    - -
    -
    -
    The documentation for this struct was generated from the following file:
      -
    • D:/qb/workspace/29555/source/libraries.gpu.rendering.xess.xess-sdk/libxess/include/xess/xess_d3d12_debug.h
    • -
    -
    -
    - - - - diff --git a/xess/doc/doxygen/struct__xess__profiled__frame__data__t.js b/xess/doc/doxygen/struct__xess__profiled__frame__data__t.js deleted file mode 100644 index c8cd6ad..0000000 --- a/xess/doc/doxygen/struct__xess__profiled__frame__data__t.js +++ /dev/null @@ -1,7 +0,0 @@ -var struct__xess__profiled__frame__data__t = -[ - [ "frame_index", "struct__xess__profiled__frame__data__t.html#a7b9f42d4c57d1fe01c782d735be98074", null ], - [ "gpu_duration_names", "struct__xess__profiled__frame__data__t.html#a46e787a4e8a96da32fe2b173f3720d6f", null ], - [ "gpu_duration_record_count", "struct__xess__profiled__frame__data__t.html#ab142b6f60de7c00c227011353cb602e5", null ], - [ "gpu_duration_values", "struct__xess__profiled__frame__data__t.html#a8f6650843400b1532bdd0ce000a0e689", null ] -]; \ No newline at end of file diff --git a/xess/doc/doxygen/struct__xess__profiling__data__t.html b/xess/doc/doxygen/struct__xess__profiling__data__t.html deleted file mode 100644 index caa0828..0000000 --- a/xess/doc/doxygen/struct__xess__profiling__data__t.html +++ /dev/null @@ -1,171 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: _xess_profiling_data_t Struct Reference - - - - - - - - - - - - - -
    -
    - - - - - - - -
    -
    XeSS SDK API Reference Guide 1.0.0 -
    -
    -
    - - - - - - - -
    -
    - -
    -
    -
    - -
    - -
    -
    - - -
    - -
    - -
    - -
    _xess_profiling_data_t Struct Reference
    -
    -
    - -

    #include <xess_d3d12_debug.h>

    - - - - - - - - -

    -Data Fields

    uint64_t frame_count
     
    xess_profiled_frame_data_tframes
     
    uint32_t any_profiling_data_in_flight
     
    -

    Detailed Description

    -
    -

    Definition at line 75 of file xess_d3d12_debug.h.

    -

    Field Documentation

    - -

    ◆ any_profiling_data_in_flight

    - -
    -
    - - - - -
    uint32_t any_profiling_data_in_flight
    -
    -

    Flag indicating if more profiling data will be available when GPU finishes executing submitted frames. Useful to collect profiling data without forcing full CPU-GPU sync. Zero value indicates no pending profiling data.

    - -

    Definition at line 86 of file xess_d3d12_debug.h.

    - -
    -
    - -

    ◆ frame_count

    - -
    -
    - - - - -
    uint64_t frame_count
    -
    -

    Total profiled frame records storage in frames/executions array.

    - -

    Definition at line 78 of file xess_d3d12_debug.h.

    - -
    -
    - -

    ◆ frames

    - -
    -
    - - - - -
    xess_profiled_frame_data_t* frames
    -
    -

    Pointers to an internal storage with per frame/execution data.

    - -

    Definition at line 80 of file xess_d3d12_debug.h.

    - -
    -
    -
    The documentation for this struct was generated from the following file:
      -
    • D:/qb/workspace/29555/source/libraries.gpu.rendering.xess.xess-sdk/libxess/include/xess/xess_d3d12_debug.h
    • -
    -
    -
    - - - - diff --git a/xess/doc/doxygen/struct__xess__profiling__data__t.js b/xess/doc/doxygen/struct__xess__profiling__data__t.js deleted file mode 100644 index 0948c95..0000000 --- a/xess/doc/doxygen/struct__xess__profiling__data__t.js +++ /dev/null @@ -1,6 +0,0 @@ -var struct__xess__profiling__data__t = -[ - [ "any_profiling_data_in_flight", "struct__xess__profiling__data__t.html#a7ce6d3494f6a8695edf94fcad38c455e", null ], - [ "frame_count", "struct__xess__profiling__data__t.html#a75021619d6a71e1e1a4ea1efb3c62138", null ], - [ "frames", "struct__xess__profiling__data__t.html#a34fa47cf13f15a0c84ae5bc36f08fc1e", null ] -]; \ No newline at end of file diff --git a/xess/doc/doxygen/struct__xess__properties__t.html b/xess/doc/doxygen/struct__xess__properties__t.html deleted file mode 100644 index 3359bf0..0000000 --- a/xess/doc/doxygen/struct__xess__properties__t.html +++ /dev/null @@ -1,175 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: _xess_properties_t Struct Reference - - - - - - - - - - - - - -
    -
    - - - - - - - -
    -
    XeSS SDK API Reference Guide 1.0.0 -
    -
    -
    - - - - - - - -
    -
    - -
    -
    -
    - -
    - -
    -
    - - -
    - -
    - -
    - -
    _xess_properties_t Struct Reference
    -
    -
    - -

    Properties for internal XeSS resources. - More...

    - -

    #include <xess.h>

    - - - - - - - - -

    -Data Fields

    uint32_t requiredDescriptorCount
     
    uint64_t tempBufferHeapSize
     
    uint64_t tempTextureHeapSize
     
    -

    Detailed Description

    -

    Properties for internal XeSS resources.

    - -

    Definition at line 130 of file xess.h.

    -

    Field Documentation

    - -

    ◆ requiredDescriptorCount

    - -
    -
    - - - - -
    uint32_t requiredDescriptorCount
    -
    -

    Required amount of descriptors for XeSS

    - -

    Definition at line 133 of file xess.h.

    - -
    -
    - -

    ◆ tempBufferHeapSize

    - -
    -
    - - - - -
    uint64_t tempBufferHeapSize
    -
    -

    The heap size required by XeSS for temporary buffer storage.

    - -

    Definition at line 135 of file xess.h.

    - -
    -
    - -

    ◆ tempTextureHeapSize

    - -
    -
    - - - - -
    uint64_t tempTextureHeapSize
    -
    -

    The heap size required by XeSS for temporary texture storage.

    - -

    Definition at line 137 of file xess.h.

    - -
    -
    -
    The documentation for this struct was generated from the following file:
      -
    • D:/qb/workspace/29555/source/libraries.gpu.rendering.xess.xess-sdk/libxess/include/xess/xess.h
    • -
    -
    -
    - - - - diff --git a/xess/doc/doxygen/struct__xess__properties__t.js b/xess/doc/doxygen/struct__xess__properties__t.js deleted file mode 100644 index 3fe4de6..0000000 --- a/xess/doc/doxygen/struct__xess__properties__t.js +++ /dev/null @@ -1,6 +0,0 @@ -var struct__xess__properties__t = -[ - [ "requiredDescriptorCount", "struct__xess__properties__t.html#a2dc96375a6205c03219a9904a568c01c", null ], - [ "tempBufferHeapSize", "struct__xess__properties__t.html#a0db8617705e860098e048d7f3e5466ff", null ], - [ "tempTextureHeapSize", "struct__xess__properties__t.html#a209e8c58699154a12ca8c51d190565ee", null ] -]; \ No newline at end of file diff --git a/xess/doc/doxygen/struct__xess__resources__to__dump__t.html b/xess/doc/doxygen/struct__xess__resources__to__dump__t.html deleted file mode 100644 index 7c843f4..0000000 --- a/xess/doc/doxygen/struct__xess__resources__to__dump__t.html +++ /dev/null @@ -1,261 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: _xess_resources_to_dump_t Struct Reference - - - - - - - - - - - - - -
    -
    - - - - - - - -
    -
    XeSS SDK API Reference Guide 1.0.0 -
    -
    -
    - - - - - - - -
    -
    - -
    -
    -
    - -
    - -
    -
    - - -
    - -
    - -
    - -
    _xess_resources_to_dump_t Struct Reference
    -
    -
    - -

    #include <xess_d3d12_debug.h>

    - - - - - - - - - - - - - - - - - - -

    -Data Fields

    uint32_t resource_count
     
    ID3D12Resource *const * resources
     
    const char *const * resource_names
     
    const uint32_t * as_tensor
     
    const uint32_t * border_pixels_to_skip_count
     
    const uint32_t * tensor_channel_count
     
    const uint32_t * tensor_width
     
    const uint32_t * tensor_height
     
    -

    Detailed Description

    -
    -

    Definition at line 34 of file xess_d3d12_debug.h.

    -

    Field Documentation

    - -

    ◆ as_tensor

    - -
    -
    - - - - -
    const uint32_t* as_tensor
    -
    - -

    Definition at line 44 of file xess_d3d12_debug.h.

    - -
    -
    - -

    ◆ border_pixels_to_skip_count

    - -
    -
    - - - - -
    const uint32_t* border_pixels_to_skip_count
    -
    - -

    Definition at line 47 of file xess_d3d12_debug.h.

    - -
    -
    - -

    ◆ resource_count

    - -
    -
    - - - - -
    uint32_t resource_count
    -
    -

    Total resource count. In case it equal to zero content of other structure members is undefined.

    - -

    Definition at line 37 of file xess_d3d12_debug.h.

    - -
    -
    - -

    ◆ resource_names

    - -
    -
    - - - - -
    const char* const* resource_names
    -
    -

    Pointer to an internal array of D3D12 resource names. Array length is resource_count.

    - -

    Definition at line 41 of file xess_d3d12_debug.h.

    - -
    -
    - -

    ◆ resources

    - -
    -
    - - - - -
    ID3D12Resource* const* resources
    -
    -

    Pointer to an internal array of D3D12 resources. Array length is resource_count.

    - -

    Definition at line 39 of file xess_d3d12_debug.h.

    - -
    -
    - -

    ◆ tensor_channel_count

    - -
    -
    - - - - -
    const uint32_t* tensor_channel_count
    -
    - -

    Definition at line 50 of file xess_d3d12_debug.h.

    - -
    -
    - -

    ◆ tensor_height

    - -
    -
    - - - - -
    const uint32_t* tensor_height
    -
    - -

    Definition at line 56 of file xess_d3d12_debug.h.

    - -
    -
    - -

    ◆ tensor_width

    - -
    -
    - - - - -
    const uint32_t* tensor_width
    -
    - -

    Definition at line 53 of file xess_d3d12_debug.h.

    - -
    -
    -
    The documentation for this struct was generated from the following file:
      -
    • D:/qb/workspace/29555/source/libraries.gpu.rendering.xess.xess-sdk/libxess/include/xess/xess_d3d12_debug.h
    • -
    -
    -
    - - - - diff --git a/xess/doc/doxygen/struct__xess__resources__to__dump__t.js b/xess/doc/doxygen/struct__xess__resources__to__dump__t.js deleted file mode 100644 index ac782a7..0000000 --- a/xess/doc/doxygen/struct__xess__resources__to__dump__t.js +++ /dev/null @@ -1,11 +0,0 @@ -var struct__xess__resources__to__dump__t = -[ - [ "as_tensor", "struct__xess__resources__to__dump__t.html#a055a00bb33a3ade096f537cee6d614ca", null ], - [ "border_pixels_to_skip_count", "struct__xess__resources__to__dump__t.html#a4b329d03d60ffb48e496e41169018a31", null ], - [ "resource_count", "struct__xess__resources__to__dump__t.html#afa5d343e953478907a576e9c372a5838", null ], - [ "resource_names", "struct__xess__resources__to__dump__t.html#a4f61a0f5b6b502a4cd89405410853fde", null ], - [ "resources", "struct__xess__resources__to__dump__t.html#aeb3cb43b5376fe80794c4f5e4b47ff68", null ], - [ "tensor_channel_count", "struct__xess__resources__to__dump__t.html#ae59e9714ae9a69c614783e31a585a221", null ], - [ "tensor_height", "struct__xess__resources__to__dump__t.html#a7d6bf0ceee8b6abbb2678a630531e4fb", null ], - [ "tensor_width", "struct__xess__resources__to__dump__t.html#a1b5c859fbf4a5eb748d5381e6063f673", null ] -]; \ No newline at end of file diff --git a/xess/doc/doxygen/struct__xess__version__t.html b/xess/doc/doxygen/struct__xess__version__t.html deleted file mode 100644 index 2f2e06a..0000000 --- a/xess/doc/doxygen/struct__xess__version__t.html +++ /dev/null @@ -1,195 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: _xess_version_t Struct Reference - - - - - - - - - - - - - -
    -
    - - - - - - - -
    -
    XeSS SDK API Reference Guide 1.0.0 -
    -
    -
    - - - - - - - -
    -
    - -
    -
    -
    - -
    - -
    -
    - - -
    - -
    - -
    - -
    _xess_version_t Struct Reference
    -
    -
    - -

    XeSS version. - More...

    - -

    #include <xess.h>

    - - - - - - - - - - -

    -Data Fields

    uint16_t major
     
    uint16_t minor
     
    uint16_t patch
     
    uint16_t reserved
     
    -

    Detailed Description

    -

    XeSS version.

    -

    XeSS uses major.minor.patch version format and Numeric 90+ scheme for development stage builds.

    - -

    Definition at line 57 of file xess.h.

    -

    Field Documentation

    - -

    ◆ major

    - -
    -
    - - - - -
    uint16_t major
    -
    -

    A major version increment indicates a new API and potentially a break in functionality.

    - -

    Definition at line 61 of file xess.h.

    - -
    -
    - -

    ◆ minor

    - -
    -
    - - - - -
    uint16_t minor
    -
    -

    A minor version increment indicates incremental changes such as optional inputs or flags. This does not break existing functionality.

    - -

    Definition at line 64 of file xess.h.

    - -
    -
    - -

    ◆ patch

    - -
    -
    - - - - -
    uint16_t patch
    -
    -

    A patch version increment may include performance or quality tweaks or fixes for known issues. There's no change in the interfaces. Versions beyond 90 used for development builds to change the interface for the next release.

    - -

    Definition at line 69 of file xess.h.

    - -
    -
    - -

    ◆ reserved

    - -
    -
    - - - - -
    uint16_t reserved
    -
    -

    Reserved for future use.

    - -

    Definition at line 71 of file xess.h.

    - -
    -
    -
    The documentation for this struct was generated from the following file:
      -
    • D:/qb/workspace/29555/source/libraries.gpu.rendering.xess.xess-sdk/libxess/include/xess/xess.h
    • -
    -
    -
    - - - - diff --git a/xess/doc/doxygen/struct__xess__version__t.js b/xess/doc/doxygen/struct__xess__version__t.js deleted file mode 100644 index 38bfdab..0000000 --- a/xess/doc/doxygen/struct__xess__version__t.js +++ /dev/null @@ -1,7 +0,0 @@ -var struct__xess__version__t = -[ - [ "major", "struct__xess__version__t.html#a600930655b7237315b72223c48327ea8", null ], - [ "minor", "struct__xess__version__t.html#a9f280ce3ae5b6cd9346fd7a09ff29168", null ], - [ "patch", "struct__xess__version__t.html#ab74656704767a7e73da4cd20dfd51a5d", null ], - [ "reserved", "struct__xess__version__t.html#a5a6ed8c04a3db86066924b1a1bf4dad3", null ] -]; \ No newline at end of file diff --git a/xess/doc/doxygen/sync_off.png b/xess/doc/doxygen/sync_off.png deleted file mode 100644 index 3b443fc..0000000 Binary files a/xess/doc/doxygen/sync_off.png and /dev/null differ diff --git a/xess/doc/doxygen/sync_on.png b/xess/doc/doxygen/sync_on.png deleted file mode 100644 index e08320f..0000000 Binary files a/xess/doc/doxygen/sync_on.png and /dev/null differ diff --git a/xess/doc/doxygen/tab_a.png b/xess/doc/doxygen/tab_a.png deleted file mode 100644 index 3b725c4..0000000 Binary files a/xess/doc/doxygen/tab_a.png and /dev/null differ diff --git a/xess/doc/doxygen/tab_b.png b/xess/doc/doxygen/tab_b.png deleted file mode 100644 index e2b4a86..0000000 Binary files a/xess/doc/doxygen/tab_b.png and /dev/null differ diff --git a/xess/doc/doxygen/tab_h.png b/xess/doc/doxygen/tab_h.png deleted file mode 100644 index fd5cb70..0000000 Binary files a/xess/doc/doxygen/tab_h.png and /dev/null differ diff --git a/xess/doc/doxygen/tab_s.png b/xess/doc/doxygen/tab_s.png deleted file mode 100644 index ab478c9..0000000 Binary files a/xess/doc/doxygen/tab_s.png and /dev/null differ diff --git a/xess/doc/doxygen/tabs.css b/xess/doc/doxygen/tabs.css deleted file mode 100644 index 00d1c60..0000000 --- a/xess/doc/doxygen/tabs.css +++ /dev/null @@ -1 +0,0 @@ -.sm{position:relative;z-index:9999}.sm,.sm ul,.sm li{display:block;list-style:none;margin:0;padding:0;line-height:normal;direction:ltr;text-align:left;-webkit-tap-highlight-color:rgba(0,0,0,0)}.sm-rtl,.sm-rtl ul,.sm-rtl li{direction:rtl;text-align:right}.sm>li>h1,.sm>li>h2,.sm>li>h3,.sm>li>h4,.sm>li>h5,.sm>li>h6{margin:0;padding:0}.sm ul{display:none}.sm li,.sm a{position:relative}.sm a{display:block}.sm a.disabled{cursor:not-allowed}.sm:after{content:"\00a0";display:block;height:0;font:0/0 serif;clear:both;visibility:hidden;overflow:hidden}.sm,.sm *,.sm *:before,.sm *:after{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}.main-menu-btn{position:relative;display:inline-block;width:36px;height:36px;text-indent:36px;margin-left:8px;white-space:nowrap;overflow:hidden;cursor:pointer;-webkit-tap-highlight-color:rgba(0,0,0,0)}.main-menu-btn-icon,.main-menu-btn-icon:before,.main-menu-btn-icon:after{position:absolute;top:50%;left:2px;height:2px;width:24px;background:#666;-webkit-transition:all .25s;transition:all .25s}.main-menu-btn-icon:before{content:'';top:-7px;left:0}.main-menu-btn-icon:after{content:'';top:7px;left:0}#main-menu-state:checked ~ .main-menu-btn .main-menu-btn-icon{height:0}#main-menu-state:checked ~ .main-menu-btn .main-menu-btn-icon:before{top:0;-webkit-transform:rotate(-45deg);transform:rotate(-45deg)}#main-menu-state:checked ~ .main-menu-btn .main-menu-btn-icon:after{top:0;-webkit-transform:rotate(45deg);transform:rotate(45deg)}#main-menu-state{position:absolute;width:1px;height:1px;margin:-1px;border:0;padding:0;overflow:hidden;clip:rect(1px,1px,1px,1px)}#main-menu-state:not(:checked) ~ #main-menu{display:none}#main-menu-state:checked ~ #main-menu{display:block}@media(min-width:768px){.main-menu-btn{position:absolute;top:-99999px}#main-menu-state:not(:checked) ~ #main-menu{display:block}}.sm-dox{background-image:url("tab_b.png")}.sm-dox a,.sm-dox a:focus,.sm-dox a:hover,.sm-dox a:active{padding:0 12px;padding-right:43px;font-family:"Lucida Grande","Geneva","Helvetica",Arial,sans-serif;font-size:13px;font-weight:bold;line-height:36px;text-decoration:none;text-shadow:0 1px 1px rgba(255,255,255,0.9);color:#283a5d;outline:0}.sm-dox a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:white;text-shadow:0 1px 1px black}.sm-dox a.current{color:#d23600}.sm-dox a.disabled{color:#bbb}.sm-dox a span.sub-arrow{position:absolute;top:50%;margin-top:-14px;left:auto;right:3px;width:28px;height:28px;overflow:hidden;font:bold 12px/28px monospace !important;text-align:center;text-shadow:none;background:rgba(255,255,255,0.5);-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px}.sm-dox a span.sub-arrow:before{display:block;content:'+'}.sm-dox a.highlighted span.sub-arrow:before{display:block;content:'-'}.sm-dox>li:first-child>a,.sm-dox>li:first-child>:not(ul) a{-moz-border-radius:5px 5px 0 0;-webkit-border-radius:5px;border-radius:5px 5px 0 0}.sm-dox>li:last-child>a,.sm-dox>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul{-moz-border-radius:0 0 5px 5px;-webkit-border-radius:0;border-radius:0 0 5px 5px}.sm-dox>li:last-child>a.highlighted,.sm-dox>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a.highlighted{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0}.sm-dox ul{background:rgba(162,162,162,0.1)}.sm-dox ul a,.sm-dox ul a:focus,.sm-dox ul a:hover,.sm-dox ul a:active{font-size:12px;border-left:8px solid transparent;line-height:36px;text-shadow:none;background-color:white;background-image:none}.sm-dox ul a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:white;text-shadow:0 1px 1px black}.sm-dox ul ul a,.sm-dox ul ul a:hover,.sm-dox ul ul a:focus,.sm-dox ul ul a:active{border-left:16px solid transparent}.sm-dox ul ul ul a,.sm-dox ul ul ul a:hover,.sm-dox ul ul ul a:focus,.sm-dox ul ul ul a:active{border-left:24px solid transparent}.sm-dox ul ul ul ul a,.sm-dox ul ul ul ul a:hover,.sm-dox ul ul ul ul a:focus,.sm-dox ul ul ul ul a:active{border-left:32px solid transparent}.sm-dox ul ul ul ul ul a,.sm-dox ul ul ul ul ul a:hover,.sm-dox ul ul ul ul ul a:focus,.sm-dox ul ul ul ul ul a:active{border-left:40px solid transparent}@media(min-width:768px){.sm-dox ul{position:absolute;width:12em}.sm-dox li{float:left}.sm-dox.sm-rtl li{float:right}.sm-dox ul li,.sm-dox.sm-rtl ul li,.sm-dox.sm-vertical li{float:none}.sm-dox a{white-space:nowrap}.sm-dox ul a,.sm-dox.sm-vertical a{white-space:normal}.sm-dox .sm-nowrap>li>a,.sm-dox .sm-nowrap>li>:not(ul) a{white-space:nowrap}.sm-dox{padding:0 10px;background-image:url("tab_b.png");line-height:36px}.sm-dox a span.sub-arrow{top:50%;margin-top:-2px;right:12px;width:0;height:0;border-width:4px;border-style:solid dashed dashed dashed;border-color:#283a5d transparent transparent transparent;background:transparent;-moz-border-radius:0;-webkit-border-radius:0;border-radius:0}.sm-dox a,.sm-dox a:focus,.sm-dox a:active,.sm-dox a:hover,.sm-dox a.highlighted{padding:0 12px;background-image:url("tab_s.png");background-repeat:no-repeat;background-position:right;-moz-border-radius:0 !important;-webkit-border-radius:0;border-radius:0 !important}.sm-dox a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:white;text-shadow:0 1px 1px black}.sm-dox a:hover span.sub-arrow{border-color:white transparent transparent transparent}.sm-dox a.has-submenu{padding-right:24px}.sm-dox li{border-top:0}.sm-dox>li>ul:before,.sm-dox>li>ul:after{content:'';position:absolute;top:-18px;left:30px;width:0;height:0;overflow:hidden;border-width:9px;border-style:dashed dashed solid dashed;border-color:transparent transparent #bbb transparent}.sm-dox>li>ul:after{top:-16px;left:31px;border-width:8px;border-color:transparent transparent #fff transparent}.sm-dox ul{border:1px solid #bbb;padding:5px 0;background:#fff;-moz-border-radius:5px !important;-webkit-border-radius:5px;border-radius:5px !important;-moz-box-shadow:0 5px 9px rgba(0,0,0,0.2);-webkit-box-shadow:0 5px 9px rgba(0,0,0,0.2);box-shadow:0 5px 9px rgba(0,0,0,0.2)}.sm-dox ul a span.sub-arrow{right:8px;top:50%;margin-top:-5px;border-width:5px;border-color:transparent transparent transparent #555;border-style:dashed dashed dashed solid}.sm-dox ul a,.sm-dox ul a:hover,.sm-dox ul a:focus,.sm-dox ul a:active,.sm-dox ul a.highlighted{color:#555;background-image:none;border:0 !important;color:#555;background-image:none}.sm-dox ul a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:white;text-shadow:0 1px 1px black}.sm-dox ul a:hover span.sub-arrow{border-color:transparent transparent transparent white}.sm-dox span.scroll-up,.sm-dox span.scroll-down{position:absolute;display:none;visibility:hidden;overflow:hidden;background:#fff;height:36px}.sm-dox span.scroll-up:hover,.sm-dox span.scroll-down:hover{background:#eee}.sm-dox span.scroll-up:hover span.scroll-up-arrow,.sm-dox span.scroll-up:hover span.scroll-down-arrow{border-color:transparent transparent #d23600 transparent}.sm-dox span.scroll-down:hover span.scroll-down-arrow{border-color:#d23600 transparent transparent transparent}.sm-dox span.scroll-up-arrow,.sm-dox span.scroll-down-arrow{position:absolute;top:0;left:50%;margin-left:-6px;width:0;height:0;overflow:hidden;border-width:6px;border-style:dashed dashed solid dashed;border-color:transparent transparent #555 transparent}.sm-dox span.scroll-down-arrow{top:8px;border-style:solid dashed dashed dashed;border-color:#555 transparent transparent transparent}.sm-dox.sm-rtl a.has-submenu{padding-right:12px;padding-left:24px}.sm-dox.sm-rtl a span.sub-arrow{right:auto;left:12px}.sm-dox.sm-rtl.sm-vertical a.has-submenu{padding:10px 20px}.sm-dox.sm-rtl.sm-vertical a span.sub-arrow{right:auto;left:8px;border-style:dashed solid dashed dashed;border-color:transparent #555 transparent transparent}.sm-dox.sm-rtl>li>ul:before{left:auto;right:30px}.sm-dox.sm-rtl>li>ul:after{left:auto;right:31px}.sm-dox.sm-rtl ul a.has-submenu{padding:10px 20px !important}.sm-dox.sm-rtl ul a span.sub-arrow{right:auto;left:8px;border-style:dashed solid dashed dashed;border-color:transparent #555 transparent transparent}.sm-dox.sm-vertical{padding:10px 0;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px}.sm-dox.sm-vertical a{padding:10px 20px}.sm-dox.sm-vertical a:hover,.sm-dox.sm-vertical a:focus,.sm-dox.sm-vertical a:active,.sm-dox.sm-vertical a.highlighted{background:#fff}.sm-dox.sm-vertical a.disabled{background-image:url("tab_b.png")}.sm-dox.sm-vertical a span.sub-arrow{right:8px;top:50%;margin-top:-5px;border-width:5px;border-style:dashed dashed dashed solid;border-color:transparent transparent transparent #555}.sm-dox.sm-vertical>li>ul:before,.sm-dox.sm-vertical>li>ul:after{display:none}.sm-dox.sm-vertical ul a{padding:10px 20px}.sm-dox.sm-vertical ul a:hover,.sm-dox.sm-vertical ul a:focus,.sm-dox.sm-vertical ul a:active,.sm-dox.sm-vertical ul a.highlighted{background:#eee}.sm-dox.sm-vertical ul a.disabled{background:#fff}} \ No newline at end of file diff --git a/xess/doc/doxygen/xess_8h.html b/xess/doc/doxygen/xess_8h.html deleted file mode 100644 index 23c42fb..0000000 --- a/xess/doc/doxygen/xess_8h.html +++ /dev/null @@ -1,656 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: D:/qb/workspace/29555/source/libraries.gpu.rendering.xess.xess-sdk/libxess/include/xess/xess.h File Reference - - - - - - - - - - - - - -
    -
    - - - - - - - -
    -
    XeSS SDK API Reference Guide 1.0.0 -
    -
    -
    - - - - - - - -
    -
    - -
    -
    -
    - -
    - -
    -
    - - -
    - -
    - -
    - -
    xess.h File Reference
    -
    -
    -
    #include <stdint.h>
    -
    -

    Go to the source code of this file.

    - - - - - - - - - - - -

    -Data Structures

    struct  _xess_version_t
     XeSS version. More...
     
    struct  _xess_2d_t
     2D variable. More...
     
    struct  _xess_properties_t
     Properties for internal XeSS resources. More...
     
    - - - - - - - - - - - -

    -Macros

    #define XESS_API
     
    #define XESS_PRAGMA(x)   _Pragma(#x)
     
    #define XESS_PACK_B_X(x)   XESS_PRAGMA(pack(push, x))
     
    #define XESS_PACK_E()   XESS_PRAGMA(pack(pop))
     
    #define XESS_PACK_B()   XESS_PACK_B_X(8)
     
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    -Typedefs

    typedef struct _xess_context_handle_t * xess_context_handle_t
     
    typedef struct _xess_version_t xess_version_t
     XeSS version. More...
     
    typedef struct _xess_2d_t xess_2d_t
     2D variable. More...
     
    typedef xess_2d_t xess_coord_t
     2D coordinates. More...
     
    typedef enum _xess_quality_settings_t xess_quality_settings_t
     XeSS quality settings. More...
     
    typedef enum _xess_init_flags_t xess_init_flags_t
     XeSS initialization flags. More...
     
    typedef struct _xess_properties_t xess_properties_t
     Properties for internal XeSS resources. More...
     
    typedef enum _xess_result_t xess_result_t
     XeSS return codes. More...
     
    typedef enum _xess_logging_level_t xess_logging_level_t
     XeSS logging level. More...
     
    typedef void(* xess_app_log_callback_t) (const char *message, xess_logging_level_t loging_level)
     
    typedef char sizecheck__LINE__[(sizeof(xess_quality_settings_t)==4) ? 1 :-1]
     
    - - - - - - - - - - - - - -

    -Enumerations

    enum  _xess_quality_settings_t { XESS_QUALITY_SETTING_PERFORMANCE = 101 -, XESS_QUALITY_SETTING_BALANCED = 102 -, XESS_QUALITY_SETTING_QUALITY = 103 -, XESS_QUALITY_SETTING_ULTRA_QUALITY = 104 - }
     XeSS quality settings. More...
     
    enum  _xess_init_flags_t {
    -  XESS_INIT_FLAG_NONE = 0 -, XESS_INIT_FLAG_HIGH_RES_MV = 1 << 0 -, XESS_INIT_FLAG_INVERTED_DEPTH = 1 << 1 -, XESS_INIT_FLAG_EXPOSURE_SCALE_TEXTURE = 1 << 2 -,
    -  XESS_INIT_FLAG_RESPONSIVE_PIXEL_MASK = 1 << 3 -, XESS_INIT_FLAG_USE_NDC_VELOCITY = 1 << 4 -, XESS_INIT_FLAG_EXTERNAL_DESCRIPTOR_HEAP = 1 << 5 -, XESS_INIT_FLAG_LDR_INPUT_COLOR = 1 << 6 -,
    -  XESS_INIT_FLAG_JITTERED_MV = 1 << 7 -
    - }
     XeSS initialization flags. More...
     
    enum  _xess_result_t {
    -  XESS_RESULT_WARNING_NONEXISTING_FOLDER = 1 -, XESS_RESULT_SUCCESS = 0 -, XESS_RESULT_ERROR_UNSUPPORTED_DEVICE = -1 -, XESS_RESULT_ERROR_UNSUPPORTED_DRIVER = -2 -,
    -  XESS_RESULT_ERROR_UNINITIALIZED = -3 -, XESS_RESULT_ERROR_INVALID_ARGUMENT = -4 -, XESS_RESULT_ERROR_DEVICE_OUT_OF_MEMORY = -5 -, XESS_RESULT_ERROR_DEVICE = -6 -,
    -  XESS_RESULT_ERROR_NOT_IMPLEMENTED = -7 -, XESS_RESULT_ERROR_INVALID_CONTEXT = -8 -, XESS_RESULT_ERROR_OPERATION_IN_PROGRESS = -9 -, XESS_RESULT_ERROR_UNSUPPORTED = -10 -,
    -  XESS_RESULT_ERROR_CANT_LOAD_LIBRARY = -11 -, XESS_RESULT_ERROR_UNKNOWN = -1000 -
    - }
     XeSS return codes. More...
     
    enum  _xess_logging_level_t { XESS_LOGGING_LEVEL_DEBUG = 0 -, XESS_LOGGING_LEVEL_INFO = 1 -, XESS_LOGGING_LEVEL_WARNING = 2 -, XESS_LOGGING_LEVEL_ERROR = 3 - }
     XeSS logging level. More...
     
    - - - - - - - - - - - - - - - - - - - - - - -

    -Functions

    XESS_API xess_result_t xessGetVersion (xess_version_t *pVersion)
     Gets the XeSS version. This is baked into the XeSS SDK release. More...
     
    XESS_API xess_result_t xessGetIntelXeFXVersion (xess_context_handle_t hContext, xess_version_t *pVersion)
     Gets the version of the loaded Intel XeFX library. When running on Intel platforms this function will return the version of the loaded Intel XeFX library, for other platforms 0.0.0 will be returned. More...
     
    XESS_API xess_result_t xessGetProperties (xess_context_handle_t hContext, const xess_2d_t *pOutputResolution, xess_properties_t *pBindingProperties)
     Gets XeSS internal resources properties. More...
     
    XESS_API xess_result_t xessGetInputResolution (xess_context_handle_t hContext, const xess_2d_t *pOutputResolution, xess_quality_settings_t qualitySettings, xess_2d_t *pInputResolution)
     Get the input resolution for a specified output resolution for a given quality setting. XeSS expects all the input buffers except motion vectors to be in the returned resolution. Motion vectors can be either in output resolution (XESS_INIT_FLAG_HIGH_RES_MV) or returned resolution (default). More...
     
    XESS_API xess_result_t xessDestroyContext (xess_context_handle_t hContext)
     Destroys the XeSS context. The user must ensure that any pending command lists are completed before destroying the context. More...
     
    XESS_API xess_result_t xessSetJitterScale (xess_context_handle_t hContext, float x, float y)
     
    XESS_API xess_result_t xessSetVelocityScale (xess_context_handle_t hContext, float x, float y)
     
    XESS_API xess_result_t xessSetLoggingCallback (xess_context_handle_t hContext, xess_logging_level_t loggingLevel, xess_app_log_callback_t loggingCallback)
     
    -

    Macro Definition Documentation

    - -

    ◆ XESS_API

    - -
    -
    - - - - -
    #define XESS_API
    -
    - -

    Definition at line 31 of file xess.h.

    - -
    -
    - -

    ◆ XESS_PACK_B

    - -
    -
    - - - - - - - -
    #define XESS_PACK_B()   XESS_PACK_B_X(8)
    -
    - -

    Definition at line 41 of file xess.h.

    - -
    -
    - -

    ◆ XESS_PACK_B_X

    - -
    -
    - - - - - - - - -
    #define XESS_PACK_B_X( x)   XESS_PRAGMA(pack(push, x))
    -
    - -

    Definition at line 39 of file xess.h.

    - -
    -
    - -

    ◆ XESS_PACK_E

    - -
    -
    - - - - - - - -
    #define XESS_PACK_E()   XESS_PRAGMA(pack(pop))
    -
    - -

    Definition at line 40 of file xess.h.

    - -
    -
    - -

    ◆ XESS_PRAGMA

    - -
    -
    - - - - - - - - -
    #define XESS_PRAGMA( x)   _Pragma(#x)
    -
    - -

    Definition at line 35 of file xess.h.

    - -
    -
    -

    Typedef Documentation

    - -

    ◆ sizecheck__LINE__

    - -
    -
    - - - - -
    typedef char sizecheck__LINE__[(sizeof(xess_dump_element_bits_t)==4) ? 1 :-1]
    -
    - -

    Definition at line 286 of file xess.h.

    - -
    -
    - -

    ◆ xess_2d_t

    - -
    -
    - - - - -
    typedef struct _xess_2d_t xess_2d_t
    -
    - -

    2D variable.

    - -
    -
    - -

    ◆ xess_app_log_callback_t

    - -
    -
    - - - - -
    typedef void(* xess_app_log_callback_t) (const char *message, xess_logging_level_t loging_level)
    -
    -

    A logging callback provided by the application. This callback can be called from other threads. Message pointer are only valid inside function and may be invalid right after return call. Message is a null-terminated utf-8 string

    - -

    Definition at line 192 of file xess.h.

    - -
    -
    - -

    ◆ xess_context_handle_t

    - -
    -
    - - - - -
    typedef struct _xess_context_handle_t* xess_context_handle_t
    -
    - -

    Definition at line 49 of file xess.h.

    - -
    -
    - -

    ◆ xess_coord_t

    - -
    -
    - - - - -
    typedef xess_2d_t xess_coord_t
    -
    - -

    2D coordinates.

    - -

    Definition at line 89 of file xess.h.

    - -
    -
    - -

    ◆ xess_init_flags_t

    - -
    -
    - - - - -
    typedef enum _xess_init_flags_t xess_init_flags_t
    -
    - -

    XeSS initialization flags.

    - -
    -
    - -

    ◆ xess_logging_level_t

    - -
    -
    - -

    XeSS logging level.

    - -
    -
    - -

    ◆ xess_properties_t

    - -
    -
    - - - - -
    typedef struct _xess_properties_t xess_properties_t
    -
    - -

    Properties for internal XeSS resources.

    - -
    -
    - -

    ◆ xess_quality_settings_t

    - -
    -
    - -

    XeSS quality settings.

    - -
    -
    - -

    ◆ xess_result_t

    - -
    -
    - - - - -
    typedef enum _xess_result_t xess_result_t
    -
    - -

    XeSS return codes.

    - -
    -
    - -

    ◆ xess_version_t

    - -
    -
    - - - - -
    typedef struct _xess_version_t xess_version_t
    -
    - -

    XeSS version.

    -

    XeSS uses major.minor.patch version format and Numeric 90+ scheme for development stage builds.

    - -
    -
    -

    Enumeration Type Documentation

    - -

    ◆ _xess_init_flags_t

    - -
    -
    - - - - -
    enum _xess_init_flags_t
    -
    - -

    XeSS initialization flags.

    - - - - - - - - - - -
    Enumerator
    XESS_INIT_FLAG_NONE 
    XESS_INIT_FLAG_HIGH_RES_MV 

    Use motion vectors at target resolution.

    -
    XESS_INIT_FLAG_INVERTED_DEPTH 

    Use inverted (increased precision) depth encoding

    -
    XESS_INIT_FLAG_EXPOSURE_SCALE_TEXTURE 

    Use exposure texture to scale input color.

    -
    XESS_INIT_FLAG_RESPONSIVE_PIXEL_MASK 

    Use responsive pixel mask texture.

    -
    XESS_INIT_FLAG_USE_NDC_VELOCITY 

    Use velocity in NDC

    -
    XESS_INIT_FLAG_EXTERNAL_DESCRIPTOR_HEAP 

    Use external descriptor heap

    -
    XESS_INIT_FLAG_LDR_INPUT_COLOR 

    Disable tonemapping for input and output

    -
    XESS_INIT_FLAG_JITTERED_MV 

    Remove jitter from input velocity

    -
    - -

    Definition at line 105 of file xess.h.

    - -
    -
    - -

    ◆ _xess_logging_level_t

    - -
    -
    - - - - -
    enum _xess_logging_level_t
    -
    - -

    XeSS logging level.

    - - - - - -
    Enumerator
    XESS_LOGGING_LEVEL_DEBUG 
    XESS_LOGGING_LEVEL_INFO 
    XESS_LOGGING_LEVEL_WARNING 
    XESS_LOGGING_LEVEL_ERROR 
    - -

    Definition at line 179 of file xess.h.

    - -
    -
    - -

    ◆ _xess_quality_settings_t

    - -
    -
    - - - - -
    enum _xess_quality_settings_t
    -
    - -

    XeSS quality settings.

    - - - - - -
    Enumerator
    XESS_QUALITY_SETTING_PERFORMANCE 
    XESS_QUALITY_SETTING_BALANCED 
    XESS_QUALITY_SETTING_QUALITY 
    XESS_QUALITY_SETTING_ULTRA_QUALITY 
    - -

    Definition at line 94 of file xess.h.

    - -
    -
    - -

    ◆ _xess_result_t

    - -
    -
    - - - - -
    enum _xess_result_t
    -
    - -

    XeSS return codes.

    - - - - - - - - - - - - - - - -
    Enumerator
    XESS_RESULT_WARNING_NONEXISTING_FOLDER 

    Warning. Folder to store dump data doesn't exist. Write operation skipped.

    -
    XESS_RESULT_SUCCESS 

    XeSS operation was successful.

    -
    XESS_RESULT_ERROR_UNSUPPORTED_DEVICE 

    XeSS not supported on the GPU. An SM 6.4 capable GPU is required.

    -
    XESS_RESULT_ERROR_UNSUPPORTED_DRIVER 

    An outdated driver.

    -
    XESS_RESULT_ERROR_UNINITIALIZED 

    Execute called without initialization.

    -
    XESS_RESULT_ERROR_INVALID_ARGUMENT 

    Invalid argument such as descriptor handles.

    -
    XESS_RESULT_ERROR_DEVICE_OUT_OF_MEMORY 

    Not enough available GPU memory.

    -
    XESS_RESULT_ERROR_DEVICE 

    Device function such as resource or descriptor creation.

    -
    XESS_RESULT_ERROR_NOT_IMPLEMENTED 

    The function is not implemented

    -
    XESS_RESULT_ERROR_INVALID_CONTEXT 

    Invalid context.

    -
    XESS_RESULT_ERROR_OPERATION_IN_PROGRESS 

    Operation not finished yet.

    -
    XESS_RESULT_ERROR_UNSUPPORTED 

    Operation not supported in current configuration.

    -
    XESS_RESULT_ERROR_CANT_LOAD_LIBRARY 

    The library cannot be loaded.

    -
    XESS_RESULT_ERROR_UNKNOWN 

    Unknown internal failure

    -
    - -

    Definition at line 144 of file xess.h.

    - -
    -
    -
    -
    - - - - diff --git a/xess/doc/doxygen/xess_8h.js b/xess/doc/doxygen/xess_8h.js deleted file mode 100644 index 2b3499b..0000000 --- a/xess/doc/doxygen/xess_8h.js +++ /dev/null @@ -1,69 +0,0 @@ -var xess_8h = -[ - [ "_xess_version_t", "struct__xess__version__t.html", "struct__xess__version__t" ], - [ "_xess_2d_t", "struct__xess__2d__t.html", "struct__xess__2d__t" ], - [ "_xess_properties_t", "struct__xess__properties__t.html", "struct__xess__properties__t" ], - [ "XESS_API", "xess_8h.html#ac7ba74abaad1e5cf4ca1fffa7fee838c", null ], - [ "XESS_PACK_B", "xess_8h.html#a3c68605bee1e217a930c4ae6aa218fd1", null ], - [ "XESS_PACK_B_X", "xess_8h.html#a0cbf0d6231ec6ae03e685f2ddee69a95", null ], - [ "XESS_PACK_E", "xess_8h.html#a36808d4ffd35a951c364418a19468cf8", null ], - [ "XESS_PRAGMA", "xess_8h.html#af3af4f4afda4277313b1b91dbf1f7497", null ], - [ "sizecheck__LINE__", "xess_8h.html#a8b1577973a08cac2cbbe31bb1297eff5", null ], - [ "xess_2d_t", "xess_8h.html#a3839d654f9989ed64bc09f3a93f16bbb", null ], - [ "xess_app_log_callback_t", "xess_8h.html#a6c757a86356ec78ea12f7a0569a945f8", null ], - [ "xess_context_handle_t", "xess_8h.html#af31f441c4909f7bbf9fb4491b5f9b927", null ], - [ "xess_coord_t", "xess_8h.html#ab4b757ead636df148ed7dbcaf8a86d2f", null ], - [ "xess_init_flags_t", "xess_8h.html#a4d9dd06b8ad6424f988f53522f8969a8", null ], - [ "xess_logging_level_t", "xess_8h.html#a6432053aa5103ccd9df8618a7eaaacb8", null ], - [ "xess_properties_t", "xess_8h.html#a81c9ce6225897595f26130f90c41f3e2", null ], - [ "xess_quality_settings_t", "xess_8h.html#a2a85ea1304caf14b2c008457ee75c7cc", null ], - [ "xess_result_t", "xess_8h.html#a3aa6a07808627ac723a9da324abf10b4", null ], - [ "xess_version_t", "xess_8h.html#a5b198528154044a5bc33a464e62d34a0", null ], - [ "_xess_init_flags_t", "xess_8h.html#a4f25323a8c073a84d49a93e0cdeaddf1", [ - [ "XESS_INIT_FLAG_NONE", "xess_8h.html#a4f25323a8c073a84d49a93e0cdeaddf1a93cdd13324042072081453aeaadf0e1e", null ], - [ "XESS_INIT_FLAG_HIGH_RES_MV", "xess_8h.html#a4f25323a8c073a84d49a93e0cdeaddf1a88dbf4a687acc9bd1281778570c7c757", null ], - [ "XESS_INIT_FLAG_INVERTED_DEPTH", "xess_8h.html#a4f25323a8c073a84d49a93e0cdeaddf1a91fe3728f6cafc03e6da0a064389859a", null ], - [ "XESS_INIT_FLAG_EXPOSURE_SCALE_TEXTURE", "xess_8h.html#a4f25323a8c073a84d49a93e0cdeaddf1a99164122cf8c776c7ce5bfdfe3fd0492", null ], - [ "XESS_INIT_FLAG_RESPONSIVE_PIXEL_MASK", "xess_8h.html#a4f25323a8c073a84d49a93e0cdeaddf1ad1f14cc0ac79131e639d3bab61c5f48c", null ], - [ "XESS_INIT_FLAG_USE_NDC_VELOCITY", "xess_8h.html#a4f25323a8c073a84d49a93e0cdeaddf1a2c868f941d0829edc844b93bd76cf0f2", null ], - [ "XESS_INIT_FLAG_EXTERNAL_DESCRIPTOR_HEAP", "xess_8h.html#a4f25323a8c073a84d49a93e0cdeaddf1a7a765c7ec24c2b4193baf2e0a30fb4c7", null ], - [ "XESS_INIT_FLAG_LDR_INPUT_COLOR", "xess_8h.html#a4f25323a8c073a84d49a93e0cdeaddf1a0eb16d799c44bab1bbf3c59dfd97ceb9", null ], - [ "XESS_INIT_FLAG_JITTERED_MV", "xess_8h.html#a4f25323a8c073a84d49a93e0cdeaddf1a8390a8a09d1f38a88608644929954028", null ] - ] ], - [ "_xess_logging_level_t", "xess_8h.html#a12f0fd50664b1a61319821499ec24721", [ - [ "XESS_LOGGING_LEVEL_DEBUG", "xess_8h.html#a12f0fd50664b1a61319821499ec24721a526588cb8c0fe38b7bb35479bd44b710", null ], - [ "XESS_LOGGING_LEVEL_INFO", "xess_8h.html#a12f0fd50664b1a61319821499ec24721a02d7dfe8174efddabcf108baf804b4a6", null ], - [ "XESS_LOGGING_LEVEL_WARNING", "xess_8h.html#a12f0fd50664b1a61319821499ec24721a089568d56d50438813be38513b886486", null ], - [ "XESS_LOGGING_LEVEL_ERROR", "xess_8h.html#a12f0fd50664b1a61319821499ec24721a7142dcde3f8100558086ad32c674242b", null ] - ] ], - [ "_xess_quality_settings_t", "xess_8h.html#acc1be3e82183f25c7188fa6b5cbf1e34", [ - [ "XESS_QUALITY_SETTING_PERFORMANCE", "xess_8h.html#acc1be3e82183f25c7188fa6b5cbf1e34a375807073d5e41d49599bc4c3796a298", null ], - [ "XESS_QUALITY_SETTING_BALANCED", "xess_8h.html#acc1be3e82183f25c7188fa6b5cbf1e34af42585b087b48ac84f15147eca7f84fc", null ], - [ "XESS_QUALITY_SETTING_QUALITY", "xess_8h.html#acc1be3e82183f25c7188fa6b5cbf1e34aad6611bfc9d8b4367d40cc4341781071", null ], - [ "XESS_QUALITY_SETTING_ULTRA_QUALITY", "xess_8h.html#acc1be3e82183f25c7188fa6b5cbf1e34a2307f69631f48661ec35997e6b9dfa7b", null ] - ] ], - [ "_xess_result_t", "xess_8h.html#a31952a580a4d5d26c6224183f62d2612", [ - [ "XESS_RESULT_WARNING_NONEXISTING_FOLDER", "xess_8h.html#a31952a580a4d5d26c6224183f62d2612a7f8d0f6dc01ba497911fdbdb02b05a45", null ], - [ "XESS_RESULT_SUCCESS", "xess_8h.html#a31952a580a4d5d26c6224183f62d2612afd64586bcb0f0638509e4ae5506c72cf", null ], - [ "XESS_RESULT_ERROR_UNSUPPORTED_DEVICE", "xess_8h.html#a31952a580a4d5d26c6224183f62d2612a00eab4ebb1fb95a65e2b4d82981fb3f8", null ], - [ "XESS_RESULT_ERROR_UNSUPPORTED_DRIVER", "xess_8h.html#a31952a580a4d5d26c6224183f62d2612a15bd2bd2e7ae00b9ddd87fa5a43b1ee2", null ], - [ "XESS_RESULT_ERROR_UNINITIALIZED", "xess_8h.html#a31952a580a4d5d26c6224183f62d2612a635c3fdf5ff04d037167f1cb37d46e23", null ], - [ "XESS_RESULT_ERROR_INVALID_ARGUMENT", "xess_8h.html#a31952a580a4d5d26c6224183f62d2612a30021fa62d2929cc6bf0d47d07e3c59e", null ], - [ "XESS_RESULT_ERROR_DEVICE_OUT_OF_MEMORY", "xess_8h.html#a31952a580a4d5d26c6224183f62d2612ac8e207e9005b05302499f10cda8d58f5", null ], - [ "XESS_RESULT_ERROR_DEVICE", "xess_8h.html#a31952a580a4d5d26c6224183f62d2612a47d58f63ff4815586df793c60eed4dc0", null ], - [ "XESS_RESULT_ERROR_NOT_IMPLEMENTED", "xess_8h.html#a31952a580a4d5d26c6224183f62d2612a1953e4a40daecb661d97b031c38ce1f6", null ], - [ "XESS_RESULT_ERROR_INVALID_CONTEXT", "xess_8h.html#a31952a580a4d5d26c6224183f62d2612a27d5e96802336368594096df18a1ae06", null ], - [ "XESS_RESULT_ERROR_OPERATION_IN_PROGRESS", "xess_8h.html#a31952a580a4d5d26c6224183f62d2612a8ca9ff62f59f7b647e62dc3c52ec6ac8", null ], - [ "XESS_RESULT_ERROR_UNSUPPORTED", "xess_8h.html#a31952a580a4d5d26c6224183f62d2612aa1255da83c4c0fcc2b4a2d7bb4af02bf", null ], - [ "XESS_RESULT_ERROR_CANT_LOAD_LIBRARY", "xess_8h.html#a31952a580a4d5d26c6224183f62d2612ab0c58d47a6858d66925b00e17bda81f5", null ], - [ "XESS_RESULT_ERROR_UNKNOWN", "xess_8h.html#a31952a580a4d5d26c6224183f62d2612a1a08d6aec7e38e2f0bd03893c05b9d2f", null ] - ] ], - [ "xessDestroyContext", "group__xess.html#gae5d88d9bdb50033ab254aa2e692c9bc0", null ], - [ "xessGetInputResolution", "group__xess.html#ga6ed6ab924e0a41ff56485b562acd5073", null ], - [ "xessGetIntelXeFXVersion", "group__xess.html#ga88ea52641806d14ef5a4995b5d78ea91", null ], - [ "xessGetProperties", "group__xess.html#gaae4893a4bfed059402ca55f256738773", null ], - [ "xessGetVersion", "group__xess.html#ga0fc6e0c7b21322a0af96f1ee1e4667d3", null ], - [ "xessSetJitterScale", "group__xess.html#ga30e9bee98f90568e6a9d39bd7d1ccd74", null ], - [ "xessSetLoggingCallback", "group__xess.html#gaaf68a347af5e5c9c1e518f0bc5daaf1c", null ], - [ "xessSetVelocityScale", "group__xess.html#ga0f95b12fe2611b877d72efdd9f050639", null ] -]; \ No newline at end of file diff --git a/xess/doc/doxygen/xess_8h_source.html b/xess/doc/doxygen/xess_8h_source.html deleted file mode 100644 index 734e292..0000000 --- a/xess/doc/doxygen/xess_8h_source.html +++ /dev/null @@ -1,334 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: D:/qb/workspace/29555/source/libraries.gpu.rendering.xess.xess-sdk/libxess/include/xess/xess.h Source File - - - - - - - - - - - - - -
    -
    - - - - - - - -
    -
    XeSS SDK API Reference Guide 1.0.0 -
    -
    -
    - - - - - - - -
    -
    - -
    -
    -
    - -
    - -
    -
    - - -
    - -
    - -
    -
    xess.h
    -
    -
    -Go to the documentation of this file.
    1/*******************************************************************************
    -
    2 * INTEL CONFIDENTIAL
    -
    3 *
    -
    4 * Copyright (C) 2021 Intel Corporation
    -
    5 *
    -
    6 * This software and the related documents are Intel copyrighted materials, and
    -
    7 * your use of them is governed by the express license under which they were
    -
    8 * provided to you ("License"). Unless the License provides otherwise, you may
    -
    9 * not use, modify, copy, publish, distribute, disclose or transmit this
    -
    10 * software or the related documents without Intel's prior written permission.
    -
    11 *
    -
    12 * This software and the related documents are provided as is, with no express
    -
    13 * or implied warranties, other than those that are expressly stated in the
    -
    14 * License.
    -
    15 ******************************************************************************/
    -
    16
    -
    17#ifndef XESS_H
    -
    18#define XESS_H
    -
    19
    -
    20#ifdef XESS_SHARED_LIB
    -
    21#ifdef _WIN32
    -
    22#ifdef XESS_EXPORT_API
    -
    23#define XESS_API __declspec(dllexport)
    -
    24#else
    -
    25#define XESS_API __declspec(dllimport)
    -
    26#endif
    -
    27#else
    -
    28#define XESS_API __attribute__((visibility("default")))
    -
    29#endif
    -
    30#else
    -
    31#define XESS_API
    -
    32#endif
    -
    33
    -
    34#if !defined _MSC_VER || (_MSC_VER >= 1928)
    -
    35#define XESS_PRAGMA(x) _Pragma(#x)
    -
    36#else
    -
    37#define XESS_PRAGMA(x) __pragma(x)
    -
    38#endif
    -
    39#define XESS_PACK_B_X(x) XESS_PRAGMA(pack(push, x))
    -
    40#define XESS_PACK_E() XESS_PRAGMA(pack(pop))
    -
    41#define XESS_PACK_B() XESS_PACK_B_X(8)
    -
    42
    -
    43#include <stdint.h>
    -
    44
    -
    45#ifdef __cplusplus
    -
    46extern "C" {
    -
    47#endif
    -
    48
    -
    49typedef struct _xess_context_handle_t* xess_context_handle_t;
    -
    50
    - -
    57typedef struct _xess_version_t
    -
    58{
    -
    61 uint16_t major;
    -
    64 uint16_t minor;
    -
    69 uint16_t patch;
    -
    71 uint16_t reserved;
    - - -
    74
    - -
    79typedef struct _xess_2d_t
    -
    80{
    -
    81 uint32_t x;
    -
    82 uint32_t y;
    - - -
    85
    -
    86
    - -
    90
    - -
    95{
    - - - - - -
    101
    - -
    106{
    - - - - - - - - - - -
    125
    - -
    130typedef struct _xess_properties_t
    -
    131{
    - - - - - -
    140
    -
    141
    -
    144typedef enum _xess_result_t
    -
    145{
    - - - - - - - - - - - - - - - -
    175
    - -
    180{
    - - - - - -
    186
    -
    192 typedef void (*xess_app_log_callback_t)(const char *message, xess_logging_level_t loging_level);
    -
    193
    -
    194#ifndef XESS_TYPES_ONLY
    -
    195
    - -
    206
    - -
    216 xess_version_t* pVersion);
    -
    217
    - -
    226 const xess_2d_t* pOutputResolution, xess_properties_t* pBindingProperties);
    -
    227
    - -
    241 const xess_2d_t* pOutputResolution, xess_quality_settings_t qualitySettings,
    -
    242 xess_2d_t* pInputResolution);
    -
    243
    - -
    251
    - -
    260
    - -
    269
    - -
    279 xess_logging_level_t loggingLevel, xess_app_log_callback_t loggingCallback);
    -
    280
    -
    283#endif
    -
    284
    -
    285// Enum size checks. All enums must be 4 bytes
    -
    286typedef char sizecheck__LINE__[ (sizeof(xess_quality_settings_t) == 4) ? 1 : -1];
    -
    287typedef char sizecheck__LINE__[ (sizeof(xess_init_flags_t) == 4) ? 1 : -1];
    -
    288typedef char sizecheck__LINE__[ (sizeof(xess_result_t) == 4) ? 1 : -1];
    -
    289typedef char sizecheck__LINE__[ (sizeof(xess_logging_level_t) == 4) ? 1 : -1];
    -
    290
    -
    291
    -
    292#ifdef __cplusplus
    -
    293}
    -
    294#endif
    -
    295
    -
    296#endif
    -
    XESS_API xess_result_t xessSetVelocityScale(xess_context_handle_t hContext, float x, float y)
    -
    XESS_API xess_result_t xessGetVersion(xess_version_t *pVersion)
    Gets the XeSS version. This is baked into the XeSS SDK release.
    -
    XESS_API xess_result_t xessSetJitterScale(xess_context_handle_t hContext, float x, float y)
    -
    XESS_API xess_result_t xessGetInputResolution(xess_context_handle_t hContext, const xess_2d_t *pOutputResolution, xess_quality_settings_t qualitySettings, xess_2d_t *pInputResolution)
    Get the input resolution for a specified output resolution for a given quality setting....
    -
    XESS_API xess_result_t xessGetIntelXeFXVersion(xess_context_handle_t hContext, xess_version_t *pVersion)
    Gets the version of the loaded Intel XeFX library. When running on Intel platforms this function will...
    -
    XESS_API xess_result_t xessGetProperties(xess_context_handle_t hContext, const xess_2d_t *pOutputResolution, xess_properties_t *pBindingProperties)
    Gets XeSS internal resources properties.
    -
    XESS_API xess_result_t xessSetLoggingCallback(xess_context_handle_t hContext, xess_logging_level_t loggingLevel, xess_app_log_callback_t loggingCallback)
    -
    XESS_API xess_result_t xessDestroyContext(xess_context_handle_t hContext)
    Destroys the XeSS context. The user must ensure that any pending command lists are completed before d...
    -
    2D variable.
    Definition: xess.h:80
    -
    uint32_t y
    Definition: xess.h:82
    -
    uint32_t x
    Definition: xess.h:81
    -
    Properties for internal XeSS resources.
    Definition: xess.h:131
    -
    uint64_t tempBufferHeapSize
    Definition: xess.h:135
    -
    uint64_t tempTextureHeapSize
    Definition: xess.h:137
    -
    uint32_t requiredDescriptorCount
    Definition: xess.h:133
    -
    XeSS version.
    Definition: xess.h:58
    -
    uint16_t reserved
    Definition: xess.h:71
    -
    uint16_t major
    Definition: xess.h:61
    -
    uint16_t minor
    Definition: xess.h:64
    -
    uint16_t patch
    Definition: xess.h:69
    -
    _xess_logging_level_t
    XeSS logging level.
    Definition: xess.h:180
    -
    @ XESS_LOGGING_LEVEL_INFO
    Definition: xess.h:182
    -
    @ XESS_LOGGING_LEVEL_WARNING
    Definition: xess.h:183
    -
    @ XESS_LOGGING_LEVEL_DEBUG
    Definition: xess.h:181
    -
    @ XESS_LOGGING_LEVEL_ERROR
    Definition: xess.h:184
    -
    enum _xess_quality_settings_t xess_quality_settings_t
    XeSS quality settings.
    -
    _xess_result_t
    XeSS return codes.
    Definition: xess.h:145
    -
    @ XESS_RESULT_ERROR_UNSUPPORTED_DEVICE
    Definition: xess.h:151
    -
    @ XESS_RESULT_ERROR_UNSUPPORTED_DRIVER
    Definition: xess.h:153
    -
    @ XESS_RESULT_ERROR_NOT_IMPLEMENTED
    Definition: xess.h:163
    -
    @ XESS_RESULT_ERROR_UNKNOWN
    Definition: xess.h:173
    -
    @ XESS_RESULT_ERROR_INVALID_CONTEXT
    Definition: xess.h:165
    -
    @ XESS_RESULT_ERROR_INVALID_ARGUMENT
    Definition: xess.h:157
    -
    @ XESS_RESULT_ERROR_DEVICE
    Definition: xess.h:161
    -
    @ XESS_RESULT_ERROR_UNINITIALIZED
    Definition: xess.h:155
    -
    @ XESS_RESULT_WARNING_NONEXISTING_FOLDER
    Definition: xess.h:147
    -
    @ XESS_RESULT_ERROR_OPERATION_IN_PROGRESS
    Definition: xess.h:167
    -
    @ XESS_RESULT_ERROR_UNSUPPORTED
    Definition: xess.h:169
    -
    @ XESS_RESULT_ERROR_CANT_LOAD_LIBRARY
    Definition: xess.h:171
    -
    @ XESS_RESULT_ERROR_DEVICE_OUT_OF_MEMORY
    Definition: xess.h:159
    -
    @ XESS_RESULT_SUCCESS
    Definition: xess.h:149
    -
    #define XESS_PACK_E()
    Definition: xess.h:40
    -
    struct _xess_2d_t xess_2d_t
    2D variable.
    -
    enum _xess_result_t xess_result_t
    XeSS return codes.
    -
    #define XESS_PACK_B()
    Definition: xess.h:41
    -
    enum _xess_init_flags_t xess_init_flags_t
    XeSS initialization flags.
    -
    _xess_init_flags_t
    XeSS initialization flags.
    Definition: xess.h:106
    -
    @ XESS_INIT_FLAG_LDR_INPUT_COLOR
    Definition: xess.h:121
    -
    @ XESS_INIT_FLAG_USE_NDC_VELOCITY
    Definition: xess.h:117
    -
    @ XESS_INIT_FLAG_EXTERNAL_DESCRIPTOR_HEAP
    Definition: xess.h:119
    -
    @ XESS_INIT_FLAG_JITTERED_MV
    Definition: xess.h:123
    -
    @ XESS_INIT_FLAG_HIGH_RES_MV
    Definition: xess.h:109
    -
    @ XESS_INIT_FLAG_INVERTED_DEPTH
    Definition: xess.h:111
    -
    @ XESS_INIT_FLAG_NONE
    Definition: xess.h:107
    -
    @ XESS_INIT_FLAG_EXPOSURE_SCALE_TEXTURE
    Definition: xess.h:113
    -
    @ XESS_INIT_FLAG_RESPONSIVE_PIXEL_MASK
    Definition: xess.h:115
    -
    struct _xess_version_t xess_version_t
    XeSS version.
    -
    enum _xess_logging_level_t xess_logging_level_t
    XeSS logging level.
    -
    void(* xess_app_log_callback_t)(const char *message, xess_logging_level_t loging_level)
    Definition: xess.h:192
    -
    struct _xess_properties_t xess_properties_t
    Properties for internal XeSS resources.
    -
    char sizecheck__LINE__[(sizeof(xess_quality_settings_t)==4) ? 1 :-1]
    Definition: xess.h:286
    -
    #define XESS_API
    Definition: xess.h:31
    -
    _xess_quality_settings_t
    XeSS quality settings.
    Definition: xess.h:95
    -
    @ XESS_QUALITY_SETTING_ULTRA_QUALITY
    Definition: xess.h:99
    -
    @ XESS_QUALITY_SETTING_PERFORMANCE
    Definition: xess.h:96
    -
    @ XESS_QUALITY_SETTING_QUALITY
    Definition: xess.h:98
    -
    @ XESS_QUALITY_SETTING_BALANCED
    Definition: xess.h:97
    -
    struct _xess_context_handle_t * xess_context_handle_t
    Definition: xess.h:49
    -
    -
    - - - - diff --git a/xess/doc/doxygen/xess__d3d12_8h.html b/xess/doc/doxygen/xess__d3d12_8h.html deleted file mode 100644 index d77d579..0000000 --- a/xess/doc/doxygen/xess__d3d12_8h.html +++ /dev/null @@ -1,174 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: D:/qb/workspace/29555/source/libraries.gpu.rendering.xess.xess-sdk/libxess/include/xess/xess_d3d12.h File Reference - - - - - - - - - - - - - -
    -
    - - - - - - - -
    -
    XeSS SDK API Reference Guide 1.0.0 -
    -
    -
    - - - - - - - -
    -
    - -
    -
    -
    - -
    - -
    -
    - - -
    - -
    - -
    - -
    xess_d3d12.h File Reference
    -
    -
    -
    #include <d3d12.h>
    -#include "xess.h"
    -
    -

    Go to the source code of this file.

    - - - - - - - - -

    -Data Structures

    struct  _xess_d3d12_execute_params_t
     Execution parameters for XeSS D3D12. More...
     
    struct  _xess_d3d12_init_params_t
     Initialization parameters for XeSS D3D12. More...
     
    - - - - - - - -

    -Typedefs

    typedef struct _xess_d3d12_execute_params_t xess_d3d12_execute_params_t
     Execution parameters for XeSS D3D12. More...
     
    typedef struct _xess_d3d12_init_params_t xess_d3d12_init_params_t
     Initialization parameters for XeSS D3D12. More...
     
    - - - - - - - - - - - - - -

    -Functions

    XESS_API xess_result_t xessD3D12CreateContext (ID3D12Device *pDevice, xess_context_handle_t *phContext)
     Create an XeSS D3D12 context. More...
     
    XESS_API xess_result_t xessD3D12BuildPipelines (xess_context_handle_t hContext, ID3D12PipelineLibrary *pPipelineLibrary, bool blocking, uint32_t initFlags)
     Initiates pipeline build process This function can only be called between xessD3D12CreateContext and xessD3D12Init This call initiates build of DX12 pipelines and kernel compilation This call can be blocking (if blocking set to true) or non-blocking. In case of non-blocking call library will wait for pipeline build on call to xessD3D12Init If pPipelineLibrary passed to this call - same pipeline library must be passed to xessD3D12Init. More...
     
    XESS_API xess_result_t xessD3D12Init (xess_context_handle_t hContext, const xess_d3d12_init_params_t *pInitParams)
     Initialize XeSS D3D12. This is a blocking call that initializes XeSS and triggers internal resources allocation and JIT for the XeSS kernels. The user must ensure that any pending command lists are completed before re-initialization. When During initialization, XeSS can create staging buffers and copy queues to upload internal data. These will be destroyed at the end of initialization. More...
     
    XESS_API xess_result_t xessD3D12Execute (xess_context_handle_t hContext, ID3D12GraphicsCommandList *pCommandList, const xess_d3d12_execute_params_t *pExecParams)
     Record XeSS upscaling commands into the command list. More...
     
    -

    Typedef Documentation

    - -

    ◆ xess_d3d12_execute_params_t

    - -
    -
    - -

    Execution parameters for XeSS D3D12.

    - -
    -
    - -

    ◆ xess_d3d12_init_params_t

    - -
    -
    - -

    Initialization parameters for XeSS D3D12.

    - -
    -
    -
    -
    - - - - diff --git a/xess/doc/doxygen/xess__d3d12_8h.js b/xess/doc/doxygen/xess__d3d12_8h.js deleted file mode 100644 index b5b0e60..0000000 --- a/xess/doc/doxygen/xess__d3d12_8h.js +++ /dev/null @@ -1,11 +0,0 @@ -var xess__d3d12_8h = -[ - [ "_xess_d3d12_execute_params_t", "struct__xess__d3d12__execute__params__t.html", "struct__xess__d3d12__execute__params__t" ], - [ "_xess_d3d12_init_params_t", "struct__xess__d3d12__init__params__t.html", "struct__xess__d3d12__init__params__t" ], - [ "xess_d3d12_execute_params_t", "xess__d3d12_8h.html#a013d859444728ce4c0b3b95e5437caf5", null ], - [ "xess_d3d12_init_params_t", "xess__d3d12_8h.html#a8738b1b1df89db7fcdb1647af648c7d7", null ], - [ "xessD3D12BuildPipelines", "group__xess-d3d12.html#gac39e8fcd2d1575ab36e54aacbc3d3b6a", null ], - [ "xessD3D12CreateContext", "group__xess-d3d12.html#ga6b15c60fbdeefc17a1064950c90d2e2d", null ], - [ "xessD3D12Execute", "group__xess-d3d12.html#gaf8e15aa3a0915546fdfcaa899f58c102", null ], - [ "xessD3D12Init", "group__xess-d3d12.html#gafb211935ba10efefc5a7063b276fce31", null ] -]; \ No newline at end of file diff --git a/xess/doc/doxygen/xess__d3d12_8h_source.html b/xess/doc/doxygen/xess__d3d12_8h_source.html deleted file mode 100644 index b582d85..0000000 --- a/xess/doc/doxygen/xess__d3d12_8h_source.html +++ /dev/null @@ -1,234 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: D:/qb/workspace/29555/source/libraries.gpu.rendering.xess.xess-sdk/libxess/include/xess/xess_d3d12.h Source File - - - - - - - - - - - - - -
    -
    - - - - - - - -
    -
    XeSS SDK API Reference Guide 1.0.0 -
    -
    -
    - - - - - - - -
    -
    - -
    -
    -
    - -
    - -
    -
    - - -
    - -
    - -
    -
    xess_d3d12.h
    -
    -
    -Go to the documentation of this file.
    1/*******************************************************************************
    -
    2 * INTEL CONFIDENTIAL
    -
    3 *
    -
    4 * Copyright (C) 2021 Intel Corporation
    -
    5 *
    -
    6 * This software and the related documents are Intel copyrighted materials, and
    -
    7 * your use of them is governed by the express license under which they were
    -
    8 * provided to you ("License"). Unless the License provides otherwise, you may
    -
    9 * not use, modify, copy, publish, distribute, disclose or transmit this
    -
    10 * software or the related documents without Intel's prior written permission.
    -
    11 *
    -
    12 * This software and the related documents are provided as is, with no express
    -
    13 * or implied warranties, other than those that are expressly stated in the
    -
    14 * License.
    -
    15 ******************************************************************************/
    -
    16
    -
    17
    -
    18#ifndef XESS_D3D12_H
    -
    19#define XESS_D3D12_H
    -
    20
    -
    21#include <d3d12.h>
    -
    22
    -
    23#include "xess.h"
    -
    24
    -
    25#ifdef __cplusplus
    -
    26extern "C" {
    -
    27#endif
    -
    28
    - - -
    34{
    -
    36 ID3D12Resource *pColorTexture;
    -
    38 ID3D12Resource *pVelocityTexture;
    -
    41 ID3D12Resource *pDepthTexture;
    -
    44 ID3D12Resource *pExposureScaleTexture;
    - -
    49 ID3D12Resource *pOutputTexture;
    -
    50
    - - - -
    58 uint32_t resetHistory;
    -
    60 uint32_t inputWidth;
    -
    62 uint32_t inputHeight;
    - - - - - - -
    76 ID3D12DescriptorHeap* pDescriptorHeap;
    - - - -
    81
    - - -
    87{
    - - -
    93 uint32_t initFlags;
    - - -
    103 ID3D12Heap* pTempBufferHeap;
    - -
    109 ID3D12Heap* pTempTextureHeap;
    - -
    113 ID3D12PipelineLibrary *pPipelineLibrary;
    - - -
    116
    -
    117
    - -
    127 ID3D12Device* pDevice, xess_context_handle_t* phContext);
    -
    128
    - -
    146 ID3D12PipelineLibrary *pPipelineLibrary, bool blocking, uint32_t initFlags);
    -
    147
    - -
    164 xess_context_handle_t hContext, const xess_d3d12_init_params_t* pInitParams);
    -
    165
    - -
    175 ID3D12GraphicsCommandList* pCommandList, const xess_d3d12_execute_params_t* pExecParams);
    -
    178#ifdef __cplusplus
    -
    179}
    -
    180#endif
    -
    181
    -
    182
    -
    183#endif // XESS_D3D12_H
    -
    XESS_API xess_result_t xessD3D12CreateContext(ID3D12Device *pDevice, xess_context_handle_t *phContext)
    Create an XeSS D3D12 context.
    -
    XESS_API xess_result_t xessD3D12BuildPipelines(xess_context_handle_t hContext, ID3D12PipelineLibrary *pPipelineLibrary, bool blocking, uint32_t initFlags)
    Initiates pipeline build process This function can only be called between xessD3D12CreateContext and ...
    -
    XESS_API xess_result_t xessD3D12Execute(xess_context_handle_t hContext, ID3D12GraphicsCommandList *pCommandList, const xess_d3d12_execute_params_t *pExecParams)
    Record XeSS upscaling commands into the command list.
    -
    XESS_API xess_result_t xessD3D12Init(xess_context_handle_t hContext, const xess_d3d12_init_params_t *pInitParams)
    Initialize XeSS D3D12. This is a blocking call that initializes XeSS and triggers internal resources ...
    -
    2D variable.
    Definition: xess.h:80
    -
    Execution parameters for XeSS D3D12.
    Definition: xess_d3d12.h:34
    -
    ID3D12Resource * pDepthTexture
    Definition: xess_d3d12.h:41
    -
    ID3D12Resource * pVelocityTexture
    Definition: xess_d3d12.h:38
    - - - -
    xess_coord_t outputColorBase
    Definition: xess_d3d12.h:74
    -
    ID3D12Resource * pOutputTexture
    Definition: xess_d3d12.h:49
    -
    ID3D12DescriptorHeap * pDescriptorHeap
    Definition: xess_d3d12.h:76
    - -
    ID3D12Resource * pExposureScaleTexture
    Definition: xess_d3d12.h:44
    - -
    ID3D12Resource * pResponsivePixelMaskTexture
    Definition: xess_d3d12.h:47
    - - -
    xess_coord_t inputMotionVectorBase
    Definition: xess_d3d12.h:66
    -
    xess_coord_t inputResponsiveMaskBase
    Definition: xess_d3d12.h:70
    - - -
    ID3D12Resource * pColorTexture
    Definition: xess_d3d12.h:36
    - -
    Initialization parameters for XeSS D3D12.
    Definition: xess_d3d12.h:87
    - -
    ID3D12PipelineLibrary * pPipelineLibrary
    Definition: xess_d3d12.h:113
    - -
    ID3D12Heap * pTempTextureHeap
    Definition: xess_d3d12.h:109
    - -
    ID3D12Heap * pTempBufferHeap
    Definition: xess_d3d12.h:103
    - - -
    xess_quality_settings_t qualitySetting
    Definition: xess_d3d12.h:91
    - - -
    enum _xess_quality_settings_t xess_quality_settings_t
    XeSS quality settings.
    -
    #define XESS_PACK_E()
    Definition: xess.h:40
    -
    enum _xess_result_t xess_result_t
    XeSS return codes.
    -
    #define XESS_PACK_B()
    Definition: xess.h:41
    -
    #define XESS_API
    Definition: xess.h:31
    -
    struct _xess_context_handle_t * xess_context_handle_t
    Definition: xess.h:49
    -
    struct _xess_d3d12_execute_params_t xess_d3d12_execute_params_t
    Execution parameters for XeSS D3D12.
    -
    struct _xess_d3d12_init_params_t xess_d3d12_init_params_t
    Initialization parameters for XeSS D3D12.
    -
    -
    - - - - diff --git a/xess/doc/doxygen/xess__d3d12__debug_8h.html b/xess/doc/doxygen/xess__d3d12__debug_8h.html deleted file mode 100644 index ea5e15a..0000000 --- a/xess/doc/doxygen/xess__d3d12__debug_8h.html +++ /dev/null @@ -1,201 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: D:/qb/workspace/29555/source/libraries.gpu.rendering.xess.xess-sdk/libxess/include/xess/xess_d3d12_debug.h File Reference - - - - - - - - - - - - - -
    -
    - - - - - - - -
    -
    XeSS SDK API Reference Guide 1.0.0 -
    -
    -
    - - - - - - - -
    -
    - -
    -
    -
    - -
    - -
    -
    - - -
    - -
    - -
    - -
    xess_d3d12_debug.h File Reference
    -
    -
    -
    #include <d3d12.h>
    -#include "xess.h"
    -
    -

    Go to the source code of this file.

    - - - - - - - - -

    -Data Structures

    struct  _xess_resources_to_dump_t
     
    struct  _xess_profiled_frame_data_t
     
    struct  _xess_profiling_data_t
     
    - - - -

    -Macros

    #define XESS_D3D12_DEBUG_ENABLE_PROFILING   (1U << 30)
     
    - - - - - - - -

    -Typedefs

    typedef struct _xess_resources_to_dump_t xess_resources_to_dump_t
     
    typedef struct _xess_profiled_frame_data_t xess_profiled_frame_data_t
     
    typedef struct _xess_profiling_data_t xess_profiling_data_t
     
    - - - - - - - -

    -Functions

    XESS_API xess_result_t xessD3D12GetResourcesToDump (xess_context_handle_t hContext, xess_resources_to_dump_t **pResourcesToDump)
     Query XeSS model to retrieve internal resources marked for dumping for further debug and inspection. More...
     
    XESS_API xess_result_t xessD3D12GetProfilingData (xess_context_handle_t hContext, xess_profiling_data_t **pProfilingData)
     Query XeSS model performance data for past executions. To enable performance collection, context must be initialized with XESS_D3D12_DEBUG_ENABLE_PROFILING flag added to xess_d3d12_init_params_t::initFlags. If profiling is enabled, user must poll for profiling data after executing one or more command lists, otherwise implementation will keep growing internal CPU buffers to accomodate all profiling data available. Due to async nature of execution on GPU, data may not be available after submitting command lists to device queue. It is advised to check any_profiling_data_in_flight flag in case all workloads has been submitted, but profiling data for some frames is still not available. Data pointed to by pProfilingData item(s) belongs to context instance and is valid until next call to xessD3D12GetProfilingData for owning context. More...
     
    -

    Macro Definition Documentation

    - -

    ◆ XESS_D3D12_DEBUG_ENABLE_PROFILING

    - -
    -
    - - - - -
    #define XESS_D3D12_DEBUG_ENABLE_PROFILING   (1U << 30)
    -
    - -

    Definition at line 30 of file xess_d3d12_debug.h.

    - -
    -
    -

    Typedef Documentation

    - -

    ◆ xess_profiled_frame_data_t

    - -
    -
    - -
    -
    - -

    ◆ xess_profiling_data_t

    - -
    -
    - - - - -
    typedef struct _xess_profiling_data_t xess_profiling_data_t
    -
    - -
    -
    - -

    ◆ xess_resources_to_dump_t

    - -
    -
    - -
    -
    -
    -
    - - - - diff --git a/xess/doc/doxygen/xess__d3d12__debug_8h.js b/xess/doc/doxygen/xess__d3d12__debug_8h.js deleted file mode 100644 index de02315..0000000 --- a/xess/doc/doxygen/xess__d3d12__debug_8h.js +++ /dev/null @@ -1,12 +0,0 @@ -var xess__d3d12__debug_8h = -[ - [ "_xess_resources_to_dump_t", "struct__xess__resources__to__dump__t.html", "struct__xess__resources__to__dump__t" ], - [ "_xess_profiled_frame_data_t", "struct__xess__profiled__frame__data__t.html", "struct__xess__profiled__frame__data__t" ], - [ "_xess_profiling_data_t", "struct__xess__profiling__data__t.html", "struct__xess__profiling__data__t" ], - [ "XESS_D3D12_DEBUG_ENABLE_PROFILING", "xess__d3d12__debug_8h.html#ad587f5e54cc2f41c539dd8983e248cb2", null ], - [ "xess_profiled_frame_data_t", "xess__d3d12__debug_8h.html#a8fb30e1bc4f2c5e8dab3d8a80c30e3be", null ], - [ "xess_profiling_data_t", "xess__d3d12__debug_8h.html#ad7d2b8797e2ede0f09b73e1a240583f9", null ], - [ "xess_resources_to_dump_t", "xess__d3d12__debug_8h.html#a16c2ebf61da2c3a48f3c985c1fb9b8e7", null ], - [ "xessD3D12GetProfilingData", "group__xess-d3d12-debug.html#ga3a8e8bee0b8ba06871c765648202c938", null ], - [ "xessD3D12GetResourcesToDump", "group__xess-d3d12-debug.html#gaf62cb7b5e756de611a19896a5248c92b", null ] -]; \ No newline at end of file diff --git a/xess/doc/doxygen/xess__d3d12__debug_8h_source.html b/xess/doc/doxygen/xess__d3d12__debug_8h_source.html deleted file mode 100644 index 6a7f01a..0000000 --- a/xess/doc/doxygen/xess__d3d12__debug_8h_source.html +++ /dev/null @@ -1,216 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: D:/qb/workspace/29555/source/libraries.gpu.rendering.xess.xess-sdk/libxess/include/xess/xess_d3d12_debug.h Source File - - - - - - - - - - - - - -
    -
    - - - - - - - -
    -
    XeSS SDK API Reference Guide 1.0.0 -
    -
    -
    - - - - - - - -
    -
    - -
    -
    -
    - -
    - -
    -
    - - -
    - -
    - -
    -
    xess_d3d12_debug.h
    -
    -
    -Go to the documentation of this file.
    1/*******************************************************************************
    -
    2 * INTEL CONFIDENTIAL
    -
    3 *
    -
    4 * Copyright (C) 2021 Intel Corporation
    -
    5 *
    -
    6 * This software and the related documents are Intel copyrighted materials, and
    -
    7 * your use of them is governed by the express license under which they were
    -
    8 * provided to you ("License"). Unless the License provides otherwise, you may
    -
    9 * not use, modify, copy, publish, distribute, disclose or transmit this
    -
    10 * software or the related documents without Intel's prior written permission.
    -
    11 *
    -
    12 * This software and the related documents are provided as is, with no express
    -
    13 * or implied warranties, other than those that are expressly stated in the
    -
    14 * License.
    -
    15 ******************************************************************************/
    -
    16
    -
    17
    -
    18#ifndef XESS_D3D12_DEBUG_H
    -
    19#define XESS_D3D12_DEBUG_H
    -
    20
    -
    21#include <d3d12.h>
    -
    22
    -
    23#include "xess.h"
    -
    24
    -
    25#ifdef __cplusplus
    -
    26extern "C" {
    -
    27#endif
    -
    28
    -
    29#ifndef XESS_D3D12_DEBUG_ENABLE_PROFILING
    -
    30#define XESS_D3D12_DEBUG_ENABLE_PROFILING (1U << 30)
    -
    31#endif
    -
    32
    - - -
    35{
    - -
    39 ID3D12Resource* const* resources;
    -
    41 const char* const* resource_names;
    -
    42 /* Pointer to an internal array of suggested resource dump modes. Array length is `resource_count.`
    -
    43 * If as_tensor is 0 (FALSE), then it is suggested to dump resource as RGBA texture.*/
    -
    44 const uint32_t* as_tensor; // 0 = false
    -
    45 /* Pointer to an internal array of paddings to be used during resource dump. Array length is `resource_count`.
    -
    46 * Padding is assumed to be symmetrical across spatial dimensions and has same value for both borders in each dimension.*/
    - -
    48 /* Pointer to an internal array of channel count for each resource. If resource dimension is "buffer" value is non zero,
    -
    49 * count is zero otherwise. Array length is `resource_count`.*/
    -
    50 const uint32_t* tensor_channel_count;
    -
    51 /* Pointer to an internal array of tensor width for each resource. Width must include padding on both sides.
    -
    52 * If resource dimension is "buffer" value is non zero, * count is zero otherwise. Array length is `resource_count`.*/
    -
    53 const uint32_t* tensor_width;
    -
    54 /* Pointer to an internal array of tensor width for each resource. Height must include padding on both sides.
    -
    55 * If resource dimension is "buffer" value is non zero, * count is zero otherwise. Array length is `resource_count`.*/
    -
    56 const uint32_t* tensor_height;
    - - -
    59
    - - -
    62{
    -
    64 uint64_t frame_index;
    - -
    68 const char* const* gpu_duration_names;
    -
    70 const double* gpu_duration_values;
    - - -
    73
    - - -
    76{
    -
    78 uint64_t frame_count;
    - - - - -
    89
    -
    90
    -
    91
    - -
    106
    - -
    122
    -
    123
    -
    126#ifdef __cplusplus
    -
    127}
    -
    128#endif
    -
    129
    -
    130
    -
    131#endif // XESS_D3D12_H
    -
    XESS_API xess_result_t xessD3D12GetProfilingData(xess_context_handle_t hContext, xess_profiling_data_t **pProfilingData)
    Query XeSS model performance data for past executions. To enable performance collection,...
    -
    XESS_API xess_result_t xessD3D12GetResourcesToDump(xess_context_handle_t hContext, xess_resources_to_dump_t **pResourcesToDump)
    Query XeSS model to retrieve internal resources marked for dumping for further debug and inspection.
    - -
    const char *const * gpu_duration_names
    - -
    const double * gpu_duration_values
    - - -
    xess_profiled_frame_data_t * frames
    - -
    uint32_t any_profiling_data_in_flight
    - -
    const uint32_t * as_tensor
    -
    const uint32_t * tensor_width
    -
    const uint32_t * border_pixels_to_skip_count
    -
    const char *const * resource_names
    -
    const uint32_t * tensor_height
    -
    const uint32_t * tensor_channel_count
    -
    ID3D12Resource *const * resources
    - - -
    #define XESS_PACK_E()
    Definition: xess.h:40
    -
    enum _xess_result_t xess_result_t
    XeSS return codes.
    -
    #define XESS_PACK_B()
    Definition: xess.h:41
    -
    #define XESS_API
    Definition: xess.h:31
    -
    struct _xess_context_handle_t * xess_context_handle_t
    Definition: xess.h:49
    -
    struct _xess_resources_to_dump_t xess_resources_to_dump_t
    -
    struct _xess_profiled_frame_data_t xess_profiled_frame_data_t
    -
    struct _xess_profiling_data_t xess_profiling_data_t
    -
    -
    - - - - diff --git a/xess/doc/doxygen/xess__debug_8h.html b/xess/doc/doxygen/xess__debug_8h.html deleted file mode 100644 index 259cb27..0000000 --- a/xess/doc/doxygen/xess__debug_8h.html +++ /dev/null @@ -1,288 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: D:/qb/workspace/29555/source/libraries.gpu.rendering.xess.xess-sdk/libxess/include/xess/xess_debug.h File Reference - - - - - - - - - - - - - -
    -
    - - - - - - - -
    -
    XeSS SDK API Reference Guide 1.0.0 -
    -
    -
    - - - - - - - -
    -
    - -
    -
    -
    - -
    - -
    -
    - - -
    - -
    - -
    - -
    xess_debug.h File Reference
    -
    -
    -
    #include "xess.h"
    -
    -

    Go to the source code of this file.

    - - - - -

    -Data Structures

    struct  _xess_dump_parameters_t
     
    - - - - - - - - - - - - -

    -Typedefs

    typedef enum _xess_network_model_t xess_network_model_t
     XeSS network type. More...
     
    typedef enum _xess_dump_element_bits_t xess_dump_element_bits_t
     
    typedef uint32_t xess_dump_elements_mask_t
     
    typedef struct _xess_dump_parameters_t xess_dump_parameters_t
     
    typedef char sizecheck__LINE__[(sizeof(xess_network_model_t)==4) ? 1 :-1]
     
    - - - - - - -

    -Enumerations

    enum  _xess_network_model_t { XESS_NETWORK_MODEL_KPSS = 0 -, XESS_NETWORK_MODEL_SPLAT = 1 - }
     XeSS network type. More...
     
    enum  _xess_dump_element_bits_t {
    -  XESS_DUMP_INPUT_COLOR = 0x01 -, XESS_DUMP_INPUT_VELOCITY = 0x02 -, XESS_DUMP_INPUT_DEPTH = 0x04 -, XESS_DUMP_INPUT_EXPOSURE_SCALE = 0x08 -,
    -  XESS_DUMP_INPUT_RESPONSIVE_PIXEL_MASK = 0x10 -, XESS_DUMP_OUTPUT = 0x20 -, XESS_DUMP_HISTORY = 0x40 -, XESS_DUMP_EXECUTION_PARAMETERS = 0x80 -,
    -  XESS_DUMP_ALL_INPUTS -, XESS_DUMP_ALL = 0x7FFFFFFF -
    - }
     
    - - - - - - -

    -Functions

    XESS_API xess_result_t xessSelectNetworkModel (xess_context_handle_t hContext, xess_network_model_t network)
     Select network to be used by XeSS. More...
     
    XESS_API xess_result_t xessStartDump (xess_context_handle_t hContext, const xess_dump_parameters_t *dump_parameters)
     
    -

    Typedef Documentation

    - -

    ◆ sizecheck__LINE__

    - -
    -
    - - - - -
    typedef char sizecheck__LINE__[(sizeof(xess_dump_element_bits_t)==4) ? 1 :-1]
    -
    - -

    Definition at line 117 of file xess_debug.h.

    - -
    -
    - -

    ◆ xess_dump_element_bits_t

    - -
    -
    - -
    -
    - -

    ◆ xess_dump_elements_mask_t

    - -
    -
    - - - - -
    typedef uint32_t xess_dump_elements_mask_t
    -
    - -

    Definition at line 52 of file xess_debug.h.

    - -
    -
    - -

    ◆ xess_dump_parameters_t

    - -
    -
    - -
    -
    - -

    ◆ xess_network_model_t

    - -
    -
    - -

    XeSS network type.

    - -
    -
    -

    Enumeration Type Documentation

    - -

    ◆ _xess_dump_element_bits_t

    - -
    -
    - - - - -
    enum _xess_dump_element_bits_t
    -
    - - - - - - - - - - - -
    Enumerator
    XESS_DUMP_INPUT_COLOR 
    XESS_DUMP_INPUT_VELOCITY 
    XESS_DUMP_INPUT_DEPTH 
    XESS_DUMP_INPUT_EXPOSURE_SCALE 
    XESS_DUMP_INPUT_RESPONSIVE_PIXEL_MASK 
    XESS_DUMP_OUTPUT 
    XESS_DUMP_HISTORY 
    XESS_DUMP_EXECUTION_PARAMETERS 

    All parameters passed to xessExecute.

    -
    XESS_DUMP_ALL_INPUTS 
    XESS_DUMP_ALL 
    - -

    Definition at line 36 of file xess_debug.h.

    - -
    -
    - -

    ◆ _xess_network_model_t

    - -
    -
    - - - - -
    enum _xess_network_model_t
    -
    - -

    XeSS network type.

    - - - -
    Enumerator
    XESS_NETWORK_MODEL_KPSS 
    XESS_NETWORK_MODEL_SPLAT 
    - -

    Definition at line 30 of file xess_debug.h.

    - -
    -
    -
    -
    - - - - diff --git a/xess/doc/doxygen/xess__debug_8h.js b/xess/doc/doxygen/xess__debug_8h.js deleted file mode 100644 index 93e6134..0000000 --- a/xess/doc/doxygen/xess__debug_8h.js +++ /dev/null @@ -1,27 +0,0 @@ -var xess__debug_8h = -[ - [ "_xess_dump_parameters_t", "struct__xess__dump__parameters__t.html", "struct__xess__dump__parameters__t" ], - [ "sizecheck__LINE__", "xess__debug_8h.html#a368b9d0a82e205f30f7e7c0da413e318", null ], - [ "xess_dump_element_bits_t", "xess__debug_8h.html#a516d71b76c0d19198beed6465eb4535c", null ], - [ "xess_dump_elements_mask_t", "xess__debug_8h.html#a508c6f679546883d9c849cbfd3615363", null ], - [ "xess_dump_parameters_t", "xess__debug_8h.html#a7a40b052b76b6b70177eb6bca388a214", null ], - [ "xess_network_model_t", "xess__debug_8h.html#a0f8d91004ab90548549da8adb0d4f195", null ], - [ "_xess_dump_element_bits_t", "xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83", [ - [ "XESS_DUMP_INPUT_COLOR", "xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83a623a94758729c9bcdc65df0547b1974f", null ], - [ "XESS_DUMP_INPUT_VELOCITY", "xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83a660e96b09d4656899f05260d1e7622a3", null ], - [ "XESS_DUMP_INPUT_DEPTH", "xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83aa9f414176cfe6c87f0e7b62d60976a88", null ], - [ "XESS_DUMP_INPUT_EXPOSURE_SCALE", "xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83a89c37b4f5e86951bddd55fb8a5164bcc", null ], - [ "XESS_DUMP_INPUT_RESPONSIVE_PIXEL_MASK", "xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83a002eada067830ed6c0aa36fbc60a21f2", null ], - [ "XESS_DUMP_OUTPUT", "xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83ab5fabbdd4efc47253723dd02ac132121", null ], - [ "XESS_DUMP_HISTORY", "xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83ae98ac97ee61128c3b0632a8ccbefc6bc", null ], - [ "XESS_DUMP_EXECUTION_PARAMETERS", "xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83a60e0f8ed79622d3f7e4588a658fc484a", null ], - [ "XESS_DUMP_ALL_INPUTS", "xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83a5bde5b4edb7c99106b7ad168d3da89fe", null ], - [ "XESS_DUMP_ALL", "xess__debug_8h.html#ae4b7d329863e03ff19925bf82c8c2b83a312ca9873e04595421188f6345d28f82", null ] - ] ], - [ "_xess_network_model_t", "xess__debug_8h.html#ace50e033796a986a57623170306b41ed", [ - [ "XESS_NETWORK_MODEL_KPSS", "xess__debug_8h.html#ace50e033796a986a57623170306b41eda1489add6542185904900e0b6796b8215", null ], - [ "XESS_NETWORK_MODEL_SPLAT", "xess__debug_8h.html#ace50e033796a986a57623170306b41eda89d379244951ad3c2988a0d303b4a0cb", null ] - ] ], - [ "xessSelectNetworkModel", "group__xess-debug.html#ga596f2374ff85d63d430d885da295818b", null ], - [ "xessStartDump", "group__xess-debug.html#gaa320ed0d9c03d6abb26f37647b12db7e", null ] -]; \ No newline at end of file diff --git a/xess/doc/doxygen/xess__debug_8h_source.html b/xess/doc/doxygen/xess__debug_8h_source.html deleted file mode 100644 index 86098fb..0000000 --- a/xess/doc/doxygen/xess__debug_8h_source.html +++ /dev/null @@ -1,205 +0,0 @@ - - - - - - - -XeSS SDK API Reference Guide: D:/qb/workspace/29555/source/libraries.gpu.rendering.xess.xess-sdk/libxess/include/xess/xess_debug.h Source File - - - - - - - - - - - - - -
    -
    - - - - - - - -
    -
    XeSS SDK API Reference Guide 1.0.0 -
    -
    -
    - - - - - - - -
    -
    - -
    -
    -
    - -
    - -
    -
    - - -
    - -
    - -
    -
    xess_debug.h
    -
    -
    -Go to the documentation of this file.
    1/*******************************************************************************
    -
    2 * INTEL CONFIDENTIAL
    -
    3 *
    -
    4 * Copyright (C) 2021 Intel Corporation
    -
    5 *
    -
    6 * This software and the related documents are Intel copyrighted materials, and
    -
    7 * your use of them is governed by the express license under which they were
    -
    8 * provided to you ("License"). Unless the License provides otherwise, you may
    -
    9 * not use, modify, copy, publish, distribute, disclose or transmit this
    -
    10 * software or the related documents without Intel's prior written permission.
    -
    11 *
    -
    12 * This software and the related documents are provided as is, with no express
    -
    13 * or implied warranties, other than those that are expressly stated in the
    -
    14 * License.
    -
    15 ******************************************************************************/
    -
    16
    -
    17
    -
    18#ifndef XESS_DEBUG_H
    -
    19#define XESS_DEBUG_H
    -
    20
    -
    21#include "xess.h"
    -
    22
    -
    23#ifdef __cplusplus
    -
    24extern "C" {
    -
    25#endif
    -
    26
    - -
    31{
    - - - -
    35
    - -
    37{
    - - - - - - - - - - - -
    49 XESS_DUMP_ALL = 0x7FFFFFFF,
    - -
    51
    - -
    53
    - - -
    56{
    -
    62 const char *path;
    -
    64 uint32_t frame_idx;
    -
    68 uint32_t frame_count;
    - - - -
    79
    -
    80
    - -
    91
    - -
    113
    -
    116// Enum size checks. All enums must be 4 bytes
    -
    117typedef char sizecheck__LINE__[ (sizeof(xess_network_model_t) == 4) ? 1 : -1];
    -
    118typedef char sizecheck__LINE__[ (sizeof(xess_dump_element_bits_t) == 4) ? 1 : -1];
    -
    119
    -
    120#ifdef __cplusplus
    -
    121}
    -
    122#endif
    -
    123
    -
    124#endif
    -
    XESS_API xess_result_t xessSelectNetworkModel(xess_context_handle_t hContext, xess_network_model_t network)
    Select network to be used by XeSS.
    -
    XESS_API xess_result_t xessStartDump(xess_context_handle_t hContext, const xess_dump_parameters_t *dump_parameters)
    - -
    xess_dump_elements_mask_t dump_elements_mask
    Definition: xess_debug.h:73
    - - - - -
    #define XESS_PACK_E()
    Definition: xess.h:40
    -
    enum _xess_result_t xess_result_t
    XeSS return codes.
    -
    #define XESS_PACK_B()
    Definition: xess.h:41
    -
    #define XESS_API
    Definition: xess.h:31
    -
    struct _xess_context_handle_t * xess_context_handle_t
    Definition: xess.h:49
    -
    enum _xess_network_model_t xess_network_model_t
    XeSS network type.
    -
    char sizecheck__LINE__[(sizeof(xess_network_model_t)==4) ? 1 :-1]
    Definition: xess_debug.h:117
    -
    uint32_t xess_dump_elements_mask_t
    Definition: xess_debug.h:52
    -
    enum _xess_dump_element_bits_t xess_dump_element_bits_t
    -
    struct _xess_dump_parameters_t xess_dump_parameters_t
    -
    _xess_network_model_t
    XeSS network type.
    Definition: xess_debug.h:31
    -
    @ XESS_NETWORK_MODEL_KPSS
    Definition: xess_debug.h:32
    -
    @ XESS_NETWORK_MODEL_SPLAT
    Definition: xess_debug.h:33
    -
    _xess_dump_element_bits_t
    Definition: xess_debug.h:37
    -
    @ XESS_DUMP_INPUT_RESPONSIVE_PIXEL_MASK
    Definition: xess_debug.h:42
    -
    @ XESS_DUMP_ALL
    Definition: xess_debug.h:49
    -
    @ XESS_DUMP_ALL_INPUTS
    Definition: xess_debug.h:46
    -
    @ XESS_DUMP_EXECUTION_PARAMETERS
    All parameters passed to xessExecute.
    Definition: xess_debug.h:45
    -
    @ XESS_DUMP_INPUT_COLOR
    Definition: xess_debug.h:38
    -
    @ XESS_DUMP_INPUT_VELOCITY
    Definition: xess_debug.h:39
    -
    @ XESS_DUMP_INPUT_EXPOSURE_SCALE
    Definition: xess_debug.h:41
    -
    @ XESS_DUMP_INPUT_DEPTH
    Definition: xess_debug.h:40
    -
    @ XESS_DUMP_OUTPUT
    Definition: xess_debug.h:43
    -
    @ XESS_DUMP_HISTORY
    Definition: xess_debug.h:44
    -
    -
    - - - - diff --git a/xess/inc/xess/xess.h b/xess/inc/xess/xess.h deleted file mode 100644 index dd57496..0000000 --- a/xess/inc/xess/xess.h +++ /dev/null @@ -1,294 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2021 Intel Corporation - * - * This software and the related documents are Intel copyrighted materials, and - * your use of them is governed by the express license under which they were - * provided to you ("License"). Unless the License provides otherwise, you may - * not use, modify, copy, publish, distribute, disclose or transmit this - * software or the related documents without Intel's prior written permission. - * - * This software and the related documents are provided as is, with no express - * or implied warranties, other than those that are expressly stated in the - * License. - ******************************************************************************/ - -#ifndef XESS_H -#define XESS_H - -#ifdef XESS_SHARED_LIB -#ifdef _WIN32 -#ifdef XESS_EXPORT_API -#define XESS_API __declspec(dllexport) -#else -#define XESS_API __declspec(dllimport) -#endif -#else -#define XESS_API __attribute__((visibility("default"))) -#endif -#else -#define XESS_API -#endif - -#if !defined _MSC_VER || (_MSC_VER >= 1928) -#define XESS_PRAGMA(x) _Pragma(#x) -#else -#define XESS_PRAGMA(x) __pragma(x) -#endif -#define XESS_PACK_B_X(x) XESS_PRAGMA(pack(push, x)) -#define XESS_PACK_E() XESS_PRAGMA(pack(pop)) -#define XESS_PACK_B() XESS_PACK_B_X(8) - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct _xess_context_handle_t* xess_context_handle_t; - -XESS_PACK_B() -/** - * @brief XeSS version. - * - * XeSS uses major.minor.patch version format and Numeric 90+ scheme for development stage builds. - */ -typedef struct _xess_version_t -{ - /** A major version increment indicates a new API and potentially a - * break in functionality. */ - uint16_t major; - /** A minor version increment indicates incremental changes such as - * optional inputs or flags. This does not break existing functionality. */ - uint16_t minor; - /** A patch version increment may include performance or quality tweaks or fixes for known issues. - * There's no change in the interfaces. - * Versions beyond 90 used for development builds to change the interface for the next release. - */ - uint16_t patch; - /** Reserved for future use. */ - uint16_t reserved; -} xess_version_t; -XESS_PACK_E() - -XESS_PACK_B() -/** - * @brief 2D variable. - */ -typedef struct _xess_2d_t -{ - uint32_t x; - uint32_t y; -} xess_2d_t; -XESS_PACK_E() - -/** - * @brief 2D coordinates. - */ -typedef xess_2d_t xess_coord_t; - -/** - * @brief XeSS quality settings. - */ -typedef enum _xess_quality_settings_t -{ - XESS_QUALITY_SETTING_PERFORMANCE = 101, - XESS_QUALITY_SETTING_BALANCED = 102, - XESS_QUALITY_SETTING_QUALITY = 103, - XESS_QUALITY_SETTING_ULTRA_QUALITY = 104, -} xess_quality_settings_t; - -/** - * @brief XeSS initialization flags. - */ -typedef enum _xess_init_flags_t -{ - XESS_INIT_FLAG_NONE = 0, - /** Use motion vectors at target resolution. */ - XESS_INIT_FLAG_HIGH_RES_MV = 1 << 0, - /** Use inverted (increased precision) depth encoding */ - XESS_INIT_FLAG_INVERTED_DEPTH = 1 << 1, - /** Use exposure texture to scale input color. */ - XESS_INIT_FLAG_EXPOSURE_SCALE_TEXTURE = 1 << 2, - /** Use responsive pixel mask texture. */ - XESS_INIT_FLAG_RESPONSIVE_PIXEL_MASK = 1 << 3, - /** Use velocity in NDC */ - XESS_INIT_FLAG_USE_NDC_VELOCITY = 1 << 4, - /** Use external descriptor heap */ - XESS_INIT_FLAG_EXTERNAL_DESCRIPTOR_HEAP = 1 << 5, - /** Disable tonemapping for input and output */ - XESS_INIT_FLAG_LDR_INPUT_COLOR = 1 << 6, - /** Remove jitter from input velocity*/ - XESS_INIT_FLAG_JITTERED_MV = 1 << 7, -} xess_init_flags_t; - -XESS_PACK_B() -/** - * @brief Properties for internal XeSS resources. - */ -typedef struct _xess_properties_t -{ - /** Required amount of descriptors for XeSS */ - uint32_t requiredDescriptorCount; - /** The heap size required by XeSS for temporary buffer storage. */ - uint64_t tempBufferHeapSize; - /** The heap size required by XeSS for temporary texture storage. */ - uint64_t tempTextureHeapSize; -} xess_properties_t; -XESS_PACK_E() - -/** - * @brief XeSS return codes. - */ -typedef enum _xess_result_t -{ - /** Warning. Folder to store dump data doesn't exist. Write operation skipped.*/ - XESS_RESULT_WARNING_NONEXISTING_FOLDER = 1, - /** XeSS operation was successful. */ - XESS_RESULT_SUCCESS = 0, - /** XeSS not supported on the GPU. An SM 6.4 capable GPU is required. */ - XESS_RESULT_ERROR_UNSUPPORTED_DEVICE = -1, - /** An outdated driver. */ - XESS_RESULT_ERROR_UNSUPPORTED_DRIVER = -2, - /** Execute called without initialization. */ - XESS_RESULT_ERROR_UNINITIALIZED = -3, - /** Invalid argument such as descriptor handles. */ - XESS_RESULT_ERROR_INVALID_ARGUMENT = -4, - /** Not enough available GPU memory. */ - XESS_RESULT_ERROR_DEVICE_OUT_OF_MEMORY = -5, - /** Device function such as resource or descriptor creation. */ - XESS_RESULT_ERROR_DEVICE = -6, - /** The function is not implemented */ - XESS_RESULT_ERROR_NOT_IMPLEMENTED = -7, - /** Invalid context. */ - XESS_RESULT_ERROR_INVALID_CONTEXT = -8, - /** Operation not finished yet. */ - XESS_RESULT_ERROR_OPERATION_IN_PROGRESS = -9, - /** Operation not supported in current configuration. */ - XESS_RESULT_ERROR_UNSUPPORTED = -10, - /** The library cannot be loaded. */ - XESS_RESULT_ERROR_CANT_LOAD_LIBRARY = -11, - /** Unknown internal failure */ - XESS_RESULT_ERROR_UNKNOWN = -1000, -} xess_result_t; - -/** - * @brief XeSS logging level - */ -typedef enum _xess_logging_level_t -{ - XESS_LOGGING_LEVEL_DEBUG = 0, - XESS_LOGGING_LEVEL_INFO = 1, - XESS_LOGGING_LEVEL_WARNING = 2, - XESS_LOGGING_LEVEL_ERROR = 3 -} xess_logging_level_t; - -/** - * A logging callback provided by the application. This callback can be called from other threads. - * Message pointer are only valid inside function and may be invalid right after return call. - * Message is a null-terminated utf-8 string - */ - typedef void (*xess_app_log_callback_t)(const char *message, xess_logging_level_t loging_level); - -#ifndef XESS_TYPES_ONLY - -/** @addtogroup xess XeSS API exports - * @{ - */ - -/** - * @brief Gets the XeSS version. This is baked into the XeSS SDK release. - * @param[out] pVersion Returned XeSS version. - * @return XeSS return status code. - */ -XESS_API xess_result_t xessGetVersion(xess_version_t* pVersion); - -/** - * @brief Gets the version of the loaded Intel XeFX library. When running on Intel platforms - * this function will return the version of the loaded Intel XeFX library, for other - * platforms 0.0.0 will be returned. - * @param hContext The XeSS context handle. - * @param[out] pVersion Returned Intel XeFX library version. - * @return XeSS return status code. - */ -XESS_API xess_result_t xessGetIntelXeFXVersion(xess_context_handle_t hContext, - xess_version_t* pVersion); - -/** - * @brief Gets XeSS internal resources properties. - * @param hContext The XeSS context handle. - * @param pOutputResolution Output resolution to calculate properties for. - * @param[out] pBindingPropeties Retured properties. - * @return XeSS return status code. - */ -XESS_API xess_result_t xessGetProperties(xess_context_handle_t hContext, - const xess_2d_t* pOutputResolution, xess_properties_t* pBindingProperties); - -/** - * @brief Get the input resolution for a specified output resolution for a given quality setting. - * XeSS expects all the input buffers except motion vectors to be in the returned resolution. - * Motion vectors can be either in output resolution (XESS_INIT_FLAG_HIGH_RES_MV) or - * returned resolution (default). - * - * @param hContext: The XeSS context handle. - * @param pOutputResolution Output resolution to calculate input resolution for. - * @param qualitySettings Desired quality setting. - * @param[out] pInputResolution Required input resolution. - * @return XeSS return status code. - */ -XESS_API xess_result_t xessGetInputResolution(xess_context_handle_t hContext, - const xess_2d_t* pOutputResolution, xess_quality_settings_t qualitySettings, - xess_2d_t* pInputResolution); - -/** - * @brief Destroys the XeSS context. - * The user must ensure that any pending command lists are completed before destroying the context. - * @param hContext: The XeSS context handle. - * @return XeSS return status code. - */ -XESS_API xess_result_t xessDestroyContext(xess_context_handle_t hContext); - -/** - * Sets jitter scale value - * @param hContext The XeSS context handle. - * @param x scale for the X axis - * @param y scale for the Y axis - * @return XeSS return status code. - */ -XESS_API xess_result_t xessSetJitterScale(xess_context_handle_t hContext, float x, float y); - -/** - * Sets velocity scale value - * @param hContext The XeSS context handle. - * @param x scale for the X axis - * @param y scale for the Y axis - * @return XeSS return status code. - */ -XESS_API xess_result_t xessSetVelocityScale(xess_context_handle_t hContext, float x, float y); - -/** - * Sets logging callback - * - * @param hContext The XeSS context handle. - * @param loggingLevel Minimum logging level for logging callback. - * @param loggingCallback Logging callback - * @return XeSS return status code. - */ -XESS_API xess_result_t xessSetLoggingCallback(xess_context_handle_t hContext, - xess_logging_level_t loggingLevel, xess_app_log_callback_t loggingCallback); - -/** @}*/ - -#endif - -// Enum size checks. All enums must be 4 bytes -typedef char sizecheck__LINE__[ (sizeof(xess_quality_settings_t) == 4) ? 1 : -1]; -typedef char sizecheck__LINE__[ (sizeof(xess_init_flags_t) == 4) ? 1 : -1]; -typedef char sizecheck__LINE__[ (sizeof(xess_result_t) == 4) ? 1 : -1]; -typedef char sizecheck__LINE__[ (sizeof(xess_logging_level_t) == 4) ? 1 : -1]; - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/xess/inc/xess/xess_d3d12.h b/xess/inc/xess/xess_d3d12.h deleted file mode 100644 index 64774e5..0000000 --- a/xess/inc/xess/xess_d3d12.h +++ /dev/null @@ -1,181 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2021 Intel Corporation - * - * This software and the related documents are Intel copyrighted materials, and - * your use of them is governed by the express license under which they were - * provided to you ("License"). Unless the License provides otherwise, you may - * not use, modify, copy, publish, distribute, disclose or transmit this - * software or the related documents without Intel's prior written permission. - * - * This software and the related documents are provided as is, with no express - * or implied warranties, other than those that are expressly stated in the - * License. - ******************************************************************************/ - - -#ifndef XESS_D3D12_H -#define XESS_D3D12_H - -#include - -#include "xess.h" - -#ifdef __cplusplus -extern "C" { -#endif - -XESS_PACK_B() -/** - * @brief Execution parameters for XeSS D3D12. - */ -typedef struct _xess_d3d12_execute_params_t -{ - /** Input color texture. Must be in NON_PIXEL_SHADER_RESOURCE state.*/ - ID3D12Resource *pColorTexture; - /** Input motion vector texture. Must be in NON_PIXEL_SHADER_RESOURCE state.*/ - ID3D12Resource *pVelocityTexture; - /** Optional depth texture. Required if XESS_INIT_FLAG_HIGH_RES_MV has not been specified. - * Must be in NON_PIXEL_SHADER_RESOURCE state.*/ - ID3D12Resource *pDepthTexture; - /** Optional 1x1 exposure scale texture. Required if XESS_INIT_FLAG_EXPOSURE_TEXTURE has been - * specified. Must be in NON_PIXEL_SHADER_RESOURCE state */ - ID3D12Resource *pExposureScaleTexture; - /** Optional responsive pixel mask texture. Required if XESS_INIT_FLAG_RESPONSIVE_PIXEL_MASK - * has been specified. Must be in NON_PIXEL_SHADER_RESOURCE state */ - ID3D12Resource *pResponsivePixelMaskTexture; - /** Output texture in target resolution. Must be in UNORDERED_ACCESS state.*/ - ID3D12Resource *pOutputTexture; - - /** Jitter X coordinate in the range [-0.5, 0.5]. */ - float jitterOffsetX; - /** Jitter Y coordinate in the range [-0.5, 0.5]. */ - float jitterOffsetY; - /** Optional input color scaling. Default is 1. */ - float exposureScale; - /** Resets the history accumulation in this frame. */ - uint32_t resetHistory; - /** Input color width. */ - uint32_t inputWidth; - /** Input color height. */ - uint32_t inputHeight; - /** Base coordinate for the input color in the texture. Default is (0,0). */ - xess_coord_t inputColorBase; - /** Base coordinate for the input motion vector in the texture. Default is (0,0). */ - xess_coord_t inputMotionVectorBase; - /** Base coordinate for the input depth in the texture. Default is (0,0). */ - xess_coord_t inputDepthBase; - /** Base coordinate for the input responsive pixel mask in the texture. Default is (0,0). */ - xess_coord_t inputResponsiveMaskBase; - /** Reserved parameter. */ - xess_coord_t reserved0; - /** Base coordinate for the output color. Default is (0,0). */ - xess_coord_t outputColorBase; - /** Optional external descriptor heap. */ - ID3D12DescriptorHeap* pDescriptorHeap; - /** Offset in external descriptor heap in bytes.*/ - uint32_t descriptorHeapOffset; -} xess_d3d12_execute_params_t; -XESS_PACK_E() - -XESS_PACK_B() -/** - * @brief Initialization parameters for XeSS D3D12. - */ -typedef struct _xess_d3d12_init_params_t -{ - /** Output width and height. */ - xess_2d_t outputResolution; - /** Quality setting */ - xess_quality_settings_t qualitySetting; - /** Initialization flags. */ - uint32_t initFlags; - /** Specifies the node mask for internally created resources on - * multi-adapter systems. */ - uint32_t creationNodeMask; - /** Specifies the node visibility mask for internally created resources - * on multi-adapter systems. */ - uint32_t visibleNodeMask; - /** Optional externally allocated buffer storage for XeSS. If NULL the - * storage is allocated internally. If allocated, the heap type must be - * D3D12_HEAP_TYPE_DEFAULT. This heap is not accessed by the CPU. */ - ID3D12Heap* pTempBufferHeap; - /** Offset in the externally allocated heap for temporary buffer storage. */ - uint64_t bufferHeapOffset; - /** Optional externally allocated texture storage for XeSS. If NULL the - * storage is allocated internally. If allocated, the heap type must be - * D3D12_HEAP_TYPE_DEFAULT. This heap is not accessed by the CPU. */ - ID3D12Heap* pTempTextureHeap; - /** Offset in the externally allocated heap for temporary texture storage. */ - uint64_t textureHeapOffset; - /** Pointer to pipeline library. If not NULL will be used for pipeline caching. */ - ID3D12PipelineLibrary *pPipelineLibrary; -} xess_d3d12_init_params_t; -XESS_PACK_E() - -/** @addtogroup xess-d3d12 XeSS D3D12 API exports - * @{ - */ -/** - * @brief Create an XeSS D3D12 context. - * @param pDevice: A D3D12 device created by the user. - * @param[out] phContext: Returned xess context handle. - * @return XeSS return status code. - */ -XESS_API xess_result_t xessD3D12CreateContext( - ID3D12Device* pDevice, xess_context_handle_t* phContext); - -/** - * @brief Initiates pipeline build process - * This function can only be called between @ref xessD3D12CreateContext and - * @ref xessD3D12Init - * This call initiates build of DX12 pipelines and kernel compilation - * This call can be blocking (if @ref blocking set to true) or non-blocking. - * In case of non-blocking call library will wait for pipeline build on call to - * @ref xessD3D12Init - * If @ref pPipelineLibrary passed to this call - same pipeline library must be passed - * to @ref xessD3D12Init - * - * @param hContext The XeSS context handle. - * @param pPipelineLibrary Optional pointer to pipeline library for pipeline caching. - * @param blocking Wait for kernel compilation and pipeline creation to finish or not - * @param init_flags Initialization flags. *Must* be identical to flags passed to @ref xessD3D12Init - */ -XESS_API xess_result_t xessD3D12BuildPipelines(xess_context_handle_t hContext, - ID3D12PipelineLibrary *pPipelineLibrary, bool blocking, uint32_t initFlags); - -/** - * @brief Initialize XeSS D3D12. - * This is a blocking call that initializes XeSS and triggers internal - * resources allocation and JIT for the XeSS kernels. The user must ensure that - * any pending command lists are completed before re-initialization. When - * During initialization, XeSS can create staging buffers and copy queues to - * upload internal data. These will be destroyed at the end of initialization. - * - * @note XeSS supports devices starting from D3D12_RESOURCE_HEAP_TIER_1, which means - * that buffers and textures can not live in the same resource heap. - * - * @param hContext: The XeSS context handle. - * @param pInitParams: Initialization parameters. - * @return XeSS return status code. - */ -XESS_API xess_result_t xessD3D12Init( - xess_context_handle_t hContext, const xess_d3d12_init_params_t* pInitParams); - -/** - * @brief Record XeSS upscaling commands into the command list. - * @param hContext: The XeSS context handle. - * @param pCommandList: The command list for XeSS commands. - * @param pExecParams: Execution parameters. - * @return XeSS return status code. - */ - -XESS_API xess_result_t xessD3D12Execute(xess_context_handle_t hContext, - ID3D12GraphicsCommandList* pCommandList, const xess_d3d12_execute_params_t* pExecParams); -/** @}*/ - -#ifdef __cplusplus -} -#endif - - -#endif // XESS_D3D12_H diff --git a/xess/inc/xess/xess_d3d12_debug.h b/xess/inc/xess/xess_d3d12_debug.h deleted file mode 100644 index 8587138..0000000 --- a/xess/inc/xess/xess_d3d12_debug.h +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2021 Intel Corporation - * - * This software and the related documents are Intel copyrighted materials, and - * your use of them is governed by the express license under which they were - * provided to you ("License"). Unless the License provides otherwise, you may - * not use, modify, copy, publish, distribute, disclose or transmit this - * software or the related documents without Intel's prior written permission. - * - * This software and the related documents are provided as is, with no express - * or implied warranties, other than those that are expressly stated in the - * License. - ******************************************************************************/ - - -#ifndef XESS_D3D12_DEBUG_H -#define XESS_D3D12_DEBUG_H - -#include - -#include "xess.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef XESS_D3D12_DEBUG_ENABLE_PROFILING -#define XESS_D3D12_DEBUG_ENABLE_PROFILING (1U << 30) -#endif - -XESS_PACK_B() -typedef struct _xess_resources_to_dump_t -{ - /** Total resource count. In case it equal to zero content of other structure members is undefined.*/ - uint32_t resource_count; - /** Pointer to an internal array of D3D12 resources. Array length is `resource_count`.*/ - ID3D12Resource* const* resources; - /** Pointer to an internal array of D3D12 resource names. Array length is `resource_count`.*/ - const char* const* resource_names; - /* Pointer to an internal array of suggested resource dump modes. Array length is `resource_count.` - * If as_tensor is 0 (FALSE), then it is suggested to dump resource as RGBA texture.*/ - const uint32_t* as_tensor; // 0 = false - /* Pointer to an internal array of paddings to be used during resource dump. Array length is `resource_count`. - * Padding is assumed to be symmetrical across spatial dimensions and has same value for both borders in each dimension.*/ - const uint32_t* border_pixels_to_skip_count; - /* Pointer to an internal array of channel count for each resource. If resource dimension is "buffer" value is non zero, - * count is zero otherwise. Array length is `resource_count`.*/ - const uint32_t* tensor_channel_count; - /* Pointer to an internal array of tensor width for each resource. Width must include padding on both sides. - * If resource dimension is "buffer" value is non zero, * count is zero otherwise. Array length is `resource_count`.*/ - const uint32_t* tensor_width; - /* Pointer to an internal array of tensor width for each resource. Height must include padding on both sides. - * If resource dimension is "buffer" value is non zero, * count is zero otherwise. Array length is `resource_count`.*/ - const uint32_t* tensor_height; -} xess_resources_to_dump_t; -XESS_PACK_E() - -XESS_PACK_B() -typedef struct _xess_profiled_frame_data_t -{ - /** Execution index in context's instance. */ - uint64_t frame_index; - /** Total labeled gpu duration records stored in gpu_duration* arrays.*/ - uint64_t gpu_duration_record_count; - /** Pointer to an internal array of duration names.*/ - const char* const* gpu_duration_names; - /** Pointer to an internal array of duration values. [seconds]*/ - const double* gpu_duration_values; -} xess_profiled_frame_data_t; -XESS_PACK_E() - -XESS_PACK_B() -typedef struct _xess_profiling_data_t -{ - /** Total profiled frame records storage in frames/executions array.*/ - uint64_t frame_count; - /** Pointers to an internal storage with per frame/execution data.*/ - xess_profiled_frame_data_t* frames; - /** Flag indicating if more profiling data will be available when GPU finishes - * executing submitted frames. - * Useful to collect profiling data without forcing full CPU-GPU sync. - * Zero value indicates no pending profiling data. - */ - uint32_t any_profiling_data_in_flight; -} xess_profiling_data_t; -XESS_PACK_E() - - -/** @addtogroup xess-d3d12-debug XeSS D3D12 API debug exports - * @{ - */ -/** - * @brief Query XeSS model to retrieve internal resources marked for dumping for further - * debug and inspection. - * @param hContext: The XeSS context handle. - * @param pResourcesToDump: Pointer to user-provided pointer to structure to be filled with - * debug resource array, their names and recommended dumping parameters. pResourcesToDump must not be null, - * In case of failure (xess_result_t is not equal to XESS_RESULT_SUCCESS) **pResourcesToDump contents is undefined and must not be used. - * In case of success, *pResourcesToDump may still be null, if no internal resources were added to dumping queue. - * Build configuration for certain implementations may have dumping functionality compiled-out and XESS_RESULT_ERROR_NOT_IMPLEMENTED return code. - * @return XeSS return status code. - */ -XESS_API xess_result_t xessD3D12GetResourcesToDump(xess_context_handle_t hContext, xess_resources_to_dump_t** pResourcesToDump); - -/** - * @brief Query XeSS model performance data for past executions. To enable performance collection, - * context must be initialized with XESS_D3D12_DEBUG_ENABLE_PROFILING flag added to xess_d3d12_init_params_t::initFlags. - * If profiling is enabled, user must poll for profiling data after executing one or more command lists, otherwise - * implementation will keep growing internal CPU buffers to accomodate all profiling data available. - * Due to async nature of execution on GPU, data may not be available after submitting command lists to device queue. - * It is advised to check `any_profiling_data_in_flight` flag in case all workloads has been submitted, but profiling - * data for some frames is still not available. - * Data pointed to by pProfilingData item(s) belongs to context instance and - * is valid until next call to xessD3D12GetProfilingData for owning context. - * @param hContext: The XeSS context handle. - * @param pProfilingData: pointer to profiling data structure to be filled by implementation. - * @return XeSS return status code. -*/ -XESS_API xess_result_t xessD3D12GetProfilingData(xess_context_handle_t hContext, xess_profiling_data_t** pProfilingData); - - -/** @}*/ - -#ifdef __cplusplus -} -#endif - - -#endif // XESS_D3D12_H diff --git a/xess/inc/xess/xess_debug.h b/xess/inc/xess/xess_debug.h deleted file mode 100644 index ff393c0..0000000 --- a/xess/inc/xess/xess_debug.h +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2021 Intel Corporation - * - * This software and the related documents are Intel copyrighted materials, and - * your use of them is governed by the express license under which they were - * provided to you ("License"). Unless the License provides otherwise, you may - * not use, modify, copy, publish, distribute, disclose or transmit this - * software or the related documents without Intel's prior written permission. - * - * This software and the related documents are provided as is, with no express - * or implied warranties, other than those that are expressly stated in the - * License. - ******************************************************************************/ - - -#ifndef XESS_DEBUG_H -#define XESS_DEBUG_H - -#include "xess.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief XeSS network type. - */ -typedef enum _xess_network_model_t -{ - XESS_NETWORK_MODEL_KPSS = 0, - XESS_NETWORK_MODEL_SPLAT = 1, -} xess_network_model_t; - -typedef enum _xess_dump_element_bits_t -{ - XESS_DUMP_INPUT_COLOR = 0x01, - XESS_DUMP_INPUT_VELOCITY = 0x02, - XESS_DUMP_INPUT_DEPTH = 0x04, - XESS_DUMP_INPUT_EXPOSURE_SCALE = 0x08, - XESS_DUMP_INPUT_RESPONSIVE_PIXEL_MASK = 0x10, - XESS_DUMP_OUTPUT = 0x20, - XESS_DUMP_HISTORY = 0x40, - XESS_DUMP_EXECUTION_PARAMETERS = 0x80, ///< All parameters passed to xessExecute - XESS_DUMP_ALL_INPUTS = XESS_DUMP_INPUT_COLOR | XESS_DUMP_INPUT_VELOCITY | - XESS_DUMP_INPUT_DEPTH | XESS_DUMP_INPUT_EXPOSURE_SCALE | - XESS_DUMP_INPUT_RESPONSIVE_PIXEL_MASK | XESS_DUMP_EXECUTION_PARAMETERS, - XESS_DUMP_ALL = 0x7FFFFFFF, -} xess_dump_element_bits_t; - -typedef uint32_t xess_dump_elements_mask_t; - -XESS_PACK_B() -typedef struct _xess_dump_parameters_t -{ - /** - * NULL-terminated ASCII string to *existing folder* where dump files should be written. - * Library do not create the folder. - * Files in provided folder will be overwritten. - */ - const char *path; - /** Frame index. Will be used as start for frame sequence. */ - uint32_t frame_idx; - /** Frame count to dump. Few frames less may be dumped due to possible frames in flight in - * application - */ - uint32_t frame_count; - /** Bitset showing set of elements that must be dumped. Element will be dumped if it exist - * and corrseponding bit is not 0. - * Since it's meaningless to call Dump with empty set value of 0 will mean DUMP_ALL_INPUTS - */ - xess_dump_elements_mask_t dump_elements_mask; - /** In case of depth render target with TYPELESS format it is not always possible - * to interpret depth values during dumping process. - */ -} xess_dump_parameters_t; -XESS_PACK_E() - -/** @addtogroup xess-debug XeSS API debug exports - * @{ - */ - -/** - * @brief Select network to be used by XeSS - * - * Selects network model to use by XeSS. - * After call to this function - XeSS init function *must* be called - */ -XESS_API xess_result_t xessSelectNetworkModel(xess_context_handle_t hContext, xess_network_model_t network); - -/** - * Dumps sequence of frames to the provided folder - * - * Call to this function initiates a dump for selected elements. - * XeSS SDK uses RAM cache to reduce dump overhead. Application should provide reasonable - * value for @ref xess_dump_parameters_t::frame_count frames (about 50 megs needed per cached frame). - * To enable several dumps per run application should provide correct - * @ref xess_dump_parameters_t::frame_idx value. This value used as a start index for frame - * dumping. - * After call to this function - each call to @ref xessD3D12Execute will result in new frame dumped to - * RAM cache. - * After @ref xess_dump_parameters_t::frame_count frames application will be blocked on call to - * @ref xessD3D12Execute in order to save cached frames to disk. This operation can take long time. - * Repetetive calls to this function can result in XESS_RESULT_ERROR_OPERATION_IN_PROGRESS which means that - * frame dump is in progress. - * - * @param hContext XeSS context - * @param dump_parameters dump configuration - * @return operation status - */ -XESS_API xess_result_t xessStartDump(xess_context_handle_t hContext, const xess_dump_parameters_t *dump_parameters); - -/** @}*/ - -// Enum size checks. All enums must be 4 bytes -typedef char sizecheck__LINE__[ (sizeof(xess_network_model_t) == 4) ? 1 : -1]; -typedef char sizecheck__LINE__[ (sizeof(xess_dump_element_bits_t) == 4) ? 1 : -1]; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/xess/licenses/LICENSE.pdf b/xess/licenses/LICENSE.pdf deleted file mode 100644 index 3d06c30..0000000 Binary files a/xess/licenses/LICENSE.pdf and /dev/null differ diff --git a/xess/licenses/third-party-programs.txt b/xess/licenses/third-party-programs.txt deleted file mode 100644 index c043b09..0000000 --- a/xess/licenses/third-party-programs.txt +++ /dev/null @@ -1,404 +0,0 @@ -This file is the "third-party-programs.txt" file specified in the associated Intel end user license agreement for the Intel software you are licensing. - -Third party programs and their corresponding required notices and/or license terms are listed below. - -------------------------------------------------------------------------------------- -1. effcee - Copyright 2017 The Effcee Authors. - - SPIRV-Tools - - -Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS ------------------------------------------------------------------------------------- -2. CLIUtils CLI11 - CLI11 1.8 Copyright (c) 2017-2019 University of Cincinnati, developed by Henry - Schreiner under NSF AWARD 1414736. All rights reserved. - - OpenEXR - Copyright (c) Contributors to the OpenEXR Project. All rights reserved. - -BSD 3-Clause -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -------------------------------------------------------------------------------------- -3. Google Test - Copyright 2008, Google Inc. - All rights reserved. - - RE2 - Copyright (c) 2009 The RE2 Authors. All rights reserved. - -BSD 3-Clause (Google customized) -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------------- -4. DirectX Shader Compiler - Copyright (c) 2003-2015 University of Illinois at Urbana-Champaign. - All rights reserved. - - -LLVM Release License - -Developed by: - - LLVM Team - - University of Illinois at Urbana-Champaign - - http://llvm.org - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal with -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimers. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimers in the - documentation and/or other materials provided with the distribution. - - * Neither the names of the LLVM Team, University of Illinois at - Urbana-Champaign, nor the names of its contributors may be used to - endorse or promote products derived from this Software without specific - prior written permission. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE -SOFTWARE. - -============================================================================== -Copyrights and Licenses for Third Party Software Distributed with LLVM: -============================================================================== -The LLVM software contains code written by third parties. Such software will -have its own individual LICENSE.TXT file in the directory in which it appears. -This file will describe the copyrights, license, and restrictions which apply -to that code. - -The disclaimer of warranty in the University of Illinois Open Source License -applies to all code in the LLVM Distribution, and nothing in any of the -other licenses gives permission to use the names of the LLVM Team or the -University of Illinois to endorse or promote products derived from this -Software. - -The following pieces of software have additional or alternate copyrights, -licenses, and/or restrictions: - -Program Directory -------- --------- -Autoconf llvm/autoconf - llvm/projects/ModuleMaker/autoconf -Google Test llvm/utils/unittest/googletest -OpenBSD regex llvm/lib/Support/{reg*, COPYRIGHT.regex} -pyyaml tests llvm/test/YAMLParser/{*.data, LICENSE.TXT} -ARM contributions llvm/lib/Target/ARM/LICENSE.TXT -md5 contributions llvm/lib/Support/MD5.cpp llvm/include/llvm/Support/MD5.h -miniz llvm/lib/Miniz/miniz.c llvm/include/miniz/miniz.h llvm/lib/Miniz/LICENSE.txt - -------------------------------------------------------------------------------------- -5. Dear ImGui - Copyright (c) 2014-2021 Omar Cornut - - Microsoft/DirectX-Graphics-Samples - Copyright (c) 2015 Microsoft - - Microsoft/DirectXMesh - Copyright (c) 2014-2022 Microsoft Corp - - Microsoft/DirectXTex - Copyright (c) 2011-2022 Microsoft Corp - - RapidJSON - Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. - - renderdoc - Copyright (c) 2015-2021 Baldur Karlsson - Copyright (c) 2014 Crytek - Copyright (c) 1998-2018 Third party code and tools - - -MIT License - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - -------------------------------------------------------------------------------------- -6. SPIRV Headers - Copyright (c) 2015-2018 The Khronos Group Inc. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and/or associated documentation files (the -"Materials"), to deal in the Materials without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Materials, and to -permit persons to whom the Materials are furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Materials. - -MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS -KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS -SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT - https://www.khronos.org/registry/ - -THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. - -------------------------------------------------------------------------------------- -7. WinPixEventRuntime - Copyright Microsoft Corp. - -Terms for Microsoft “Distributable Code” provided as part of Microsoft’s Visual Studio Enterprise and Professional software under the terms of the MICROSOFT VISUAL STUDIO ENTERPRISE 2017, VISUAL STUDIO PROFESSIONAL 2017, VISUAL STUDIO TEST PROFESSIONAL 2017 AND TRIAL EDITION AGREEMENT - -1. License. This software package from Intel (the “Software Package”) contains code from Microsoft (the “Distributable Code”). You are provided a non-transferable, non-exclusive, non-sublicensable, limited right and license only to use and redistribute the Distributable Code as part of this Software Package. You are not allowed to copy, modify, remove the Distributable Code from the Software Package or redistribute the Distributable Code on a stand-alone basis. - -2. Restrictions. The Distributable Code is licensed, not sold. You are only provided the above rights to use the Distributable Code. Intel and Microsoft reserve all other rights. Unless applicable law gives you more rights, you may use the Distributable Code only as expressly permitted in these terms. In using the Distributable Code, you must comply with any technical limitations in the Distributable Code that only allow you to use it in certain ways. You may not: -• work around any technical limitations in the Distributable Code; -• reverse engineer, decompile or disassemble the software, or otherwise attempt to derive the source code for the Distributable Code, except and to the extent required by third party licensing terms governing use of certain open source components that may be included in the Distributable Code; -• remove, minimize, block or modify any notices of Intel, Microsoft or its suppliers in the Distributable Code; -• use the Distributable Code in any way that is against the law; or -• share, publish, rent or lease the software, or provide the Distributable Code as a stand-alone offering for others to use. - -3. NO WARRANTY. THE DISTRIBUTABLE CODE IS PROVIDED “AS IS” WITHOUT ANY EXPRESS OR IMPLIED WARRANTY OF ANY KIND INCLUDING WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, OR FITNESS FOR A PARTICULAR PURPOSE. - -4. LIMITATION ON AND EXCLUSION OF DAMAGES. YOU CAN RECOVER FROM INTEL, MICROSOFT OR THEIR SUPPLIERS ONLY DIRECT DAMAGES UP TO $5.00. YOU CANNOT RECOVER ANY OTHER DAMAGES, INCLUDING CONSEQUENTIAL, LOST PROFITS, SPECIAL, INDIRECT OR INCIDENTAL DAMAGES. -This limitation applies to (a) anything related to the Distributable Code; and (b) claims for breach of contract, breach of warranty, guarantee or condition, strict liability, negligence, or other tort to the extent permitted by applicable law. It also applies even if Intel or Microsoft knew or should have known about the possibility of the damages. The above limitation or exclusion may not apply to you because your state or country may not allow the exclusion or limitation of incidental, consequential or other damages. - -5. Export Restrictions. You must comply with all domestic and international export laws and regulations that apply to the software, which include restrictions on destinations, end users, and end use. For further information on export restrictions, visit www.microsoft.com/exporting. -------------------------------------------------------------------------------------- - diff --git a/xess/samples/basic_sample/CMakeLists.txt b/xess/samples/basic_sample/CMakeLists.txt deleted file mode 100644 index 23f6701..0000000 --- a/xess/samples/basic_sample/CMakeLists.txt +++ /dev/null @@ -1,87 +0,0 @@ -################################################################################ -# INTEL CONFIDENTIAL -# -# Copyright (C) 2021 Intel Corporation -# -# This software and the related documents are Intel copyrighted materials, and -# your use of them is governed by the express license under which they were -# provided to you ("License"). Unless the License provides otherwise, you may -# not use, modify, copy, publish, distribute, disclose or transmit this -# software or the related documents without Intel's prior written permission. -# -# This software and the related documents are provided as is, with no express -# or implied warranties, other than those that are expressly stated in the -# License. -################################################################################ - -project(BasicSample) - -set(SOURCES - basic_sample.cpp - basic_sample.h - DXSample.cpp - DXSample.h - DXSampleHelper.h - Main.cpp - Win32Application.cpp - Win32Application.h - d3dx12.h - stdafx.cpp - stdafx.h - utils.cpp - utils.h -) - -set(RESOURCES shaders.hlsl) - -if (NOT XESS_BUILD_INTERNAL_SAMPLE) - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) -endif() - -add_executable(BasicSample WIN32 ${SOURCES}) - -set_target_properties(BasicSample PROPERTIES RESOURCE "${RESOURCES}") - -target_link_libraries(BasicSample PRIVATE d3d12 dxgi dxguid d3dcompiler) - -if (NOT XESS_BUILD_INTERNAL_SAMPLE) - include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../inc) - target_link_libraries(BasicSample PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../lib/libxess) -else() - target_link_libraries(BasicSample PRIVATE project_options project_warnings libxess) -endif() - -target_compile_definitions(BasicSample PRIVATE UNICODE) - -# Copy shaders -if (MSVC AND (NOT (${CMAKE_GENERATOR} STREQUAL "Ninja"))) - set(DEST_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$) -else () - set(DEST_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) -endif() - -add_custom_target(CopyBasicSampleRequiredFiles ALL - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/shaders.hlsl "${DEST_DIR}/shaders.hlsl" -) - -if (NOT XESS_BUILD_INTERNAL_SAMPLE) - - set(SRC_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../bin/") - add_custom_target(CopyRequiredDLLs ALL - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_PATH}/dxcompiler.dll" "${DEST_DIR}/dxcompiler.dll" - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_PATH}/dxil.dll" "${DEST_DIR}/dxil.dll" - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_PATH}/igxess.dll" "${DEST_DIR}/igxess.dll" - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_PATH}/libxess.dll" "${DEST_DIR}/libxess.dll" - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_PATH}/XeFX.dll" "${DEST_DIR}/XeFX.dll" - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_PATH}/XeFX_loader.dll" "${DEST_DIR}/XeFX_loader.dll" - ) -else () - install(TARGETS BasicSample - RUNTIME DESTINATION bin - ARCHIVE DESTINATION lib - PUBLIC_HEADER DESTINATION inc - RESOURCE DESTINATION bin - ) -endif() diff --git a/xess/samples/basic_sample/DXSample.cpp b/xess/samples/basic_sample/DXSample.cpp deleted file mode 100644 index 8e5c08a..0000000 --- a/xess/samples/basic_sample/DXSample.cpp +++ /dev/null @@ -1,127 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -#include "stdafx.h" -#include "DXSample.h" - -using namespace Microsoft::WRL; - -DXSample::DXSample(UINT width, UINT height, std::wstring name) : - m_width(width), - m_height(height), - m_useWarpDevice(false), - m_title(name) -{ - WCHAR assetsPath[512]; - GetAssetsPath(assetsPath, _countof(assetsPath)); - m_assetsPath = assetsPath; - - m_aspectRatio = static_cast(width) / static_cast(height); -} - -DXSample::~DXSample() -{ -} - -// Helper function for resolving the full path of assets. -std::wstring DXSample::GetAssetFullPath(LPCWSTR assetName) -{ - return m_assetsPath + assetName; -} - -// Helper function for acquiring the first available hardware adapter that supports Direct3D 12. -// If no such adapter can be found, *ppAdapter will be set to nullptr. -_Use_decl_annotations_ -void DXSample::GetHardwareAdapter( - IDXGIFactory1* pFactory, - IDXGIAdapter1** ppAdapter, - bool requestHighPerformanceAdapter) -{ - *ppAdapter = nullptr; - - ComPtr adapter; - - ComPtr factory6; - if (SUCCEEDED(pFactory->QueryInterface(IID_PPV_ARGS(&factory6)))) - { - for ( - UINT adapterIndex = 0; - DXGI_ERROR_NOT_FOUND != factory6->EnumAdapterByGpuPreference( - adapterIndex, - requestHighPerformanceAdapter == true ? DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE : DXGI_GPU_PREFERENCE_UNSPECIFIED, - IID_PPV_ARGS(&adapter)); - ++adapterIndex) - { - DXGI_ADAPTER_DESC1 desc; - adapter->GetDesc1(&desc); - - if (desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE) - { - // Don't select the Basic Render Driver adapter. - // If you want a software adapter, pass in "/warp" on the command line. - continue; - } - - // Check to see whether the adapter supports Direct3D 12, but don't create the - // actual device yet. - if (SUCCEEDED(D3D12CreateDevice(adapter.Get(), D3D_FEATURE_LEVEL_11_0, _uuidof(ID3D12Device), nullptr))) - { - break; - } - } - } - else - { - for (UINT adapterIndex = 0; DXGI_ERROR_NOT_FOUND != pFactory->EnumAdapters1(adapterIndex, &adapter); ++adapterIndex) - { - DXGI_ADAPTER_DESC1 desc; - adapter->GetDesc1(&desc); - - if (desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE) - { - // Don't select the Basic Render Driver adapter. - // If you want a software adapter, pass in "/warp" on the command line. - continue; - } - - // Check to see whether the adapter supports Direct3D 12, but don't create the - // actual device yet. - if (SUCCEEDED(D3D12CreateDevice(adapter.Get(), D3D_FEATURE_LEVEL_11_0, _uuidof(ID3D12Device), nullptr))) - { - break; - } - } - } - - *ppAdapter = adapter.Detach(); -} - -// Helper function for setting the window's title text. -void DXSample::SetCustomWindowText(LPCWSTR text) -{ - std::wstring windowText = m_title + L": " + text; - SetWindowText(Win32Application::GetHwnd(), windowText.c_str()); -} - -// Helper function for parsing any supplied command line args. -_Use_decl_annotations_ -void DXSample::ParseCommandLineArgs(WCHAR* argv[], int argc) -{ - for (int i = 1; i < argc; ++i) - { - if (_wcsnicmp(argv[i], L"-warp", wcslen(argv[i])) == 0 || - _wcsnicmp(argv[i], L"/warp", wcslen(argv[i])) == 0) - { - m_useWarpDevice = true; - m_title = m_title + L" (WARP)"; - } - } -} diff --git a/xess/samples/basic_sample/DXSample.h b/xess/samples/basic_sample/DXSample.h deleted file mode 100644 index 247677b..0000000 --- a/xess/samples/basic_sample/DXSample.h +++ /dev/null @@ -1,64 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -#pragma once - -#include "DXSampleHelper.h" -#include "Win32Application.h" -#include "stdafx.h" - - -class DXSample -{ -public: - DXSample(UINT width, UINT height, std::wstring name); - virtual ~DXSample(); - - virtual void OnInit() = 0; - virtual void OnUpdate() = 0; - virtual void OnRender() = 0; - virtual void OnDestroy() = 0; - - // Samples override the event handlers to handle specific messages. - virtual void OnKeyDown(UINT8 /*key*/) {} - virtual void OnKeyUp(UINT8 /*key*/) {} - - // Accessors. - UINT GetWidth() const { return m_width; } - UINT GetHeight() const { return m_height; } - const WCHAR* GetTitle() const { return m_title.c_str(); } - - void ParseCommandLineArgs(_In_reads_(argc) WCHAR* argv[], int argc); - -protected: - std::wstring GetAssetFullPath(LPCWSTR assetName); - - void GetHardwareAdapter(_In_ IDXGIFactory1* pFactory, - _Outptr_result_maybenull_ IDXGIAdapter1** ppAdapter, - bool requestHighPerformanceAdapter = false); - - void SetCustomWindowText(LPCWSTR text); - - // Viewport dimensions. - UINT m_width; - UINT m_height; - float m_aspectRatio; - - // Adapter info. - bool m_useWarpDevice; - -private: - // Root assets path. - std::wstring m_assetsPath; - - // Window title. - std::wstring m_title; -}; diff --git a/xess/samples/basic_sample/DXSampleHelper.h b/xess/samples/basic_sample/DXSampleHelper.h deleted file mode 100644 index 34a1c06..0000000 --- a/xess/samples/basic_sample/DXSampleHelper.h +++ /dev/null @@ -1,269 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -#pragma once - -#include - -#include "stdafx.h" - - -// Note that while ComPtr is used to manage the lifetime of resources on the CPU, -// it has no understanding of the lifetime of resources on the GPU. Apps must account -// for the GPU lifetime of resources to avoid destroying objects that may still be -// referenced by the GPU. -using Microsoft::WRL::ComPtr; - -inline std::string HrToString(HRESULT hr) -{ - char s_str[64] = {}; - sprintf_s(s_str, "HRESULT of 0x%08X", static_cast(hr)); - return std::string(s_str); -} - -class HrException : public std::runtime_error -{ -public: - HrException(HRESULT hr) : std::runtime_error(HrToString(hr)), m_hr(hr) {} - HRESULT Error() const { return m_hr; } - -private: - const HRESULT m_hr; -}; - -#define SAFE_RELEASE(p) \ - if (p) \ - (p)->Release() - -inline void ThrowIfFailed(HRESULT hr) -{ - if (FAILED(hr)) - { - throw HrException(hr); - } -} - -inline void GetAssetsPath(_Out_writes_(pathSize) WCHAR* path, UINT pathSize) -{ - if (path == nullptr) - { - throw std::exception(); - } - - DWORD size = GetModuleFileName(nullptr, path, pathSize); - if (size == 0 || size == pathSize) - { - // Method failed or path was truncated. - throw std::exception(); - } - - WCHAR* lastSlash = wcsrchr(path, L'\\'); - if (lastSlash) - { - *(lastSlash + 1) = L'\0'; - } -} - -inline HRESULT ReadDataFromFile(LPCWSTR filename, byte** data, UINT* size) -{ - using namespace Microsoft::WRL; - -#if WINVER >= _WIN32_WINNT_WIN8 - CREATEFILE2_EXTENDED_PARAMETERS extendedParams = {}; - extendedParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS); - extendedParams.dwFileAttributes = FILE_ATTRIBUTE_NORMAL; - extendedParams.dwFileFlags = FILE_FLAG_SEQUENTIAL_SCAN; - extendedParams.dwSecurityQosFlags = SECURITY_ANONYMOUS; - extendedParams.lpSecurityAttributes = nullptr; - extendedParams.hTemplateFile = nullptr; - - Wrappers::FileHandle file( - CreateFile2(filename, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, &extendedParams)); -#else - Wrappers::FileHandle file(CreateFile(filename, - GENERIC_READ, - FILE_SHARE_READ, - nullptr, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN | SECURITY_SQOS_PRESENT | - SECURITY_ANONYMOUS, - nullptr)); -#endif - if (file.Get() == INVALID_HANDLE_VALUE) - { - throw std::exception(); - } - - FILE_STANDARD_INFO fileInfo = {}; - if (!GetFileInformationByHandleEx(file.Get(), FileStandardInfo, &fileInfo, sizeof(fileInfo))) - { - throw std::exception(); - } - - if (fileInfo.EndOfFile.HighPart != 0) - { - throw std::exception(); - } - - *data = reinterpret_cast(malloc(fileInfo.EndOfFile.LowPart)); - *size = fileInfo.EndOfFile.LowPart; - - if (!ReadFile(file.Get(), *data, fileInfo.EndOfFile.LowPart, nullptr, nullptr)) - { - throw std::exception(); - } - - return S_OK; -} - -inline HRESULT ReadDataFromDDSFile(LPCWSTR filename, byte** data, UINT* offset, UINT* size) -{ - if (FAILED(ReadDataFromFile(filename, data, size))) - { - return E_FAIL; - } - - // DDS files always start with the same magic number. - static const UINT DDS_MAGIC = 0x20534444; - UINT magicNumber = *reinterpret_cast(*data); - if (magicNumber != DDS_MAGIC) - { - return E_FAIL; - } - - struct DDS_PIXELFORMAT - { - UINT size; - UINT flags; - UINT fourCC; - UINT rgbBitCount; - UINT rBitMask; - UINT gBitMask; - UINT bBitMask; - UINT aBitMask; - }; - - struct DDS_HEADER - { - UINT size; - UINT flags; - UINT height; - UINT width; - UINT pitchOrLinearSize; - UINT depth; - UINT mipMapCount; - UINT reserved1[11]; - DDS_PIXELFORMAT ddsPixelFormat; - UINT caps; - UINT caps2; - UINT caps3; - UINT caps4; - UINT reserved2; - }; - - auto ddsHeader = reinterpret_cast(*data + sizeof(UINT)); - if (ddsHeader->size != sizeof(DDS_HEADER) || - ddsHeader->ddsPixelFormat.size != sizeof(DDS_PIXELFORMAT)) - { - return E_FAIL; - } - - const ptrdiff_t ddsDataOffset = sizeof(UINT) + sizeof(DDS_HEADER); - *offset = ddsDataOffset; - *size = *size - ddsDataOffset; - - return S_OK; -} - -// Assign a name to the object to aid with debugging. -#if defined(_DEBUG) || defined(DBG) -inline void SetName(ID3D12Object* pObject, LPCWSTR name) -{ - pObject->SetName(name); -} -inline void SetNameIndexed(ID3D12Object* pObject, LPCWSTR name, UINT index) -{ - WCHAR fullName[50]; - if (swprintf_s(fullName, L"%s[%u]", name, index) > 0) - { - pObject->SetName(fullName); - } -} -#else -inline void SetName(ID3D12Object*, LPCWSTR) -{ -} -inline void SetNameIndexed(ID3D12Object*, LPCWSTR, UINT) -{ -} -#endif - -// Naming helper for ComPtr. -// Assigns the name of the variable as the name of the object. -// The indexed variant will include the index in the name of the object. -#define NAME_D3D12_OBJECT(x) SetName((x).Get(), L#x) -#define NAME_D3D12_OBJECT_INDEXED(x, n) SetNameIndexed((x)[n].Get(), L#x, n) - -inline UINT CalculateConstantBufferByteSize(UINT byteSize) -{ - // Constant buffer size is required to be aligned. - return (byteSize + ((UINT)D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT - 1)) & - ~((UINT)D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT - 1); -} - -#ifdef D3D_COMPILE_STANDARD_FILE_INCLUDE -inline Microsoft::WRL::ComPtr CompileShader(const std::wstring& filename, - const D3D_SHADER_MACRO* defines, - const std::string& entrypoint, - const std::string& target) -{ - UINT compileFlags = 0; -#if defined(_DEBUG) || defined(DBG) - compileFlags = D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION; -#endif - - HRESULT hr; - - Microsoft::WRL::ComPtr byteCode = nullptr; - Microsoft::WRL::ComPtr errors; - hr = D3DCompileFromFile(filename.c_str(), - defines, - D3D_COMPILE_STANDARD_FILE_INCLUDE, - entrypoint.c_str(), - target.c_str(), - compileFlags, - 0, - &byteCode, - &errors); - - if (errors != nullptr) - { - OutputDebugStringA((char*)errors->GetBufferPointer()); - } - ThrowIfFailed(hr); - - return byteCode; -} -#endif - -// Resets all elements in a ComPtr array. -template -void ResetComPtrArray(T* comPtrArray) -{ - for (auto& i : *comPtrArray) { i.Reset(); } -} - -// Resets all elements in a unique_ptr array. -template -void ResetUniquePtrArray(T* uniquePtrArray) -{ - for (auto& i : *uniquePtrArray) { i.reset(); } -} diff --git a/xess/samples/basic_sample/Main.cpp b/xess/samples/basic_sample/Main.cpp deleted file mode 100644 index c3fa975..0000000 --- a/xess/samples/basic_sample/Main.cpp +++ /dev/null @@ -1,21 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -#include "stdafx.h" -#include "basic_sample.h" - -_Use_decl_annotations_ -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow) -{ - SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_SYSTEM_AWARE); - BasicSample sample(1920, 1080, L"D3D12 Hello Constant Buffers"); - return Win32Application::Run(&sample, hInstance, nCmdShow); -} diff --git a/xess/samples/basic_sample/Win32Application.cpp b/xess/samples/basic_sample/Win32Application.cpp deleted file mode 100644 index e64b7dc..0000000 --- a/xess/samples/basic_sample/Win32Application.cpp +++ /dev/null @@ -1,119 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -#include "stdafx.h" -#include "Win32Application.h" - -HWND Win32Application::m_hwnd = nullptr; - -int Win32Application::Run(DXSample* pSample, HINSTANCE hInstance, int nCmdShow) -{ - // Parse the command line parameters - int argc; - LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc); - pSample->ParseCommandLineArgs(argv, argc); - LocalFree(argv); - - // Initialize the window class. - WNDCLASSEX windowClass = { }; - windowClass.cbSize = sizeof(WNDCLASSEX); - windowClass.style = CS_HREDRAW | CS_VREDRAW; - windowClass.lpfnWndProc = WindowProc; - windowClass.hInstance = hInstance; - windowClass.hCursor = LoadCursor(NULL, IDC_ARROW); - windowClass.lpszClassName = L"DXSampleClass"; - RegisterClassEx(&windowClass); - - RECT windowRect = { 0, 0, static_cast(pSample->GetWidth()), static_cast(pSample->GetHeight()) }; - AdjustWindowRect(&windowRect, WS_OVERLAPPEDWINDOW, FALSE); - - // Create the window and store a handle to it. - m_hwnd = CreateWindow( - windowClass.lpszClassName, - pSample->GetTitle(), - WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, - CW_USEDEFAULT, - windowRect.right - windowRect.left, - windowRect.bottom - windowRect.top, - nullptr, // We have no parent window. - nullptr, // We aren't using menus. - hInstance, - pSample); - - // Initialize the sample. OnInit is defined in each child-implementation of DXSample. - pSample->OnInit(); - - ShowWindow(m_hwnd, nCmdShow); - - // Main sample loop. - MSG msg = {}; - while (msg.message != WM_QUIT) - { - // Process any messages in the queue. - if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - } - - pSample->OnDestroy(); - - // Return this part of the WM_QUIT message to Windows. - return static_cast(msg.wParam); -} - -// Main message handler for the sample. -LRESULT CALLBACK Win32Application::WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - DXSample* pSample = reinterpret_cast(GetWindowLongPtr(hWnd, GWLP_USERDATA)); - - switch (message) - { - case WM_CREATE: - { - // Save the DXSample* passed in to CreateWindow. - LPCREATESTRUCT pCreateStruct = reinterpret_cast(lParam); - SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast(pCreateStruct->lpCreateParams)); - } - return 0; - - case WM_KEYDOWN: - if (pSample) - { - pSample->OnKeyDown(static_cast(wParam)); - } - return 0; - - case WM_KEYUP: - if (pSample) - { - pSample->OnKeyUp(static_cast(wParam)); - } - return 0; - - case WM_PAINT: - if (pSample) - { - pSample->OnUpdate(); - pSample->OnRender(); - } - return 0; - - case WM_DESTROY: - PostQuitMessage(0); - return 0; - } - - // Handle any messages the switch statement didn't. - return DefWindowProc(hWnd, message, wParam, lParam); -} diff --git a/xess/samples/basic_sample/Win32Application.h b/xess/samples/basic_sample/Win32Application.h deleted file mode 100644 index 812a8f8..0000000 --- a/xess/samples/basic_sample/Win32Application.h +++ /dev/null @@ -1,29 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -#pragma once - -#include "DXSample.h" - -class DXSample; - -class Win32Application -{ -public: - static int Run(DXSample* pSample, HINSTANCE hInstance, int nCmdShow); - static HWND GetHwnd() { return m_hwnd; } - -protected: - static LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); - -private: - static HWND m_hwnd; -}; diff --git a/xess/samples/basic_sample/basic_sample.cpp b/xess/samples/basic_sample/basic_sample.cpp deleted file mode 100644 index 5150dfe..0000000 --- a/xess/samples/basic_sample/basic_sample.cpp +++ /dev/null @@ -1,1002 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -#include "basic_sample.h" - -#include - -#include "stdafx.h" -#include "utils.h" -#include "xess/xess_d3d12.h" -#include "xess/xess_debug.h" - -//#define USE_LOWRES_MV 1 - -void BasicSample::OnKeyUp(UINT8 key) -{ - switch (key) - { - case 0x31: // Key 1 - m_outputIndex = DHI_Color; - break; - case 0x32: // Key 2 - m_outputIndex = DHI_Velocity; - break; - case 0x33: // Key 3 - m_outputIndex = DHI_XeSSOutputSRV; - break; - case 0x34: // Key 4 - { - xess_dump_parameters_t dump_params{"dump", 0, 200, XESS_DUMP_ALL_INPUTS}; - xessStartDump(m_xessContext, &dump_params); - break; - } - case VK_SPACE: - m_pause = !m_pause; - break; - } -} - -BasicSample::BasicSample(UINT width, UINT height, std::wstring name) - : DXSample(width, height, name) - , m_viewport(0.0f, 0.0f, static_cast(width), static_cast(height)) - , m_scissorRect(0, 0, static_cast(width), static_cast(height)) - , m_rtvDescriptorSize(0) - , m_constantBufferData{} - , m_pCbvDataBegin(nullptr) - , m_frameIndex(0) - , m_desiredOutputResolution{width, height} - -{ - m_haltonPointSet = Utils::GenerateHalton(2, 3, 1, 32); -} - -void BasicSample::OnInit() -{ - InitDx(); - InitXess(); - LoadPipeline(); - LoadAssets(); - CreateFSQPipeline(); - PopulateDescriptorHeap(); -} - -void BasicSample::InitDx() -{ - UINT dxgiFactoryFlags = 0; - -#ifdef ENABLE_DX_DEBUG_LAYER - // Enable the debug layer (requires the Graphics Tools "optional feature"). - // NOTE: Enabling the debug layer after device creation will invalidate the active device. - { - ComPtr debugController; - if (SUCCEEDED(D3D12GetDebugInterface(IID_PPV_ARGS(&debugController)))) - { - debugController->EnableDebugLayer(); - - // Enable additional debug layers. - dxgiFactoryFlags |= DXGI_CREATE_FACTORY_DEBUG; - } - } -#endif - - ComPtr factory; - ThrowIfFailed(CreateDXGIFactory2(dxgiFactoryFlags, IID_PPV_ARGS(&factory))); - - if (m_useWarpDevice) - { - ComPtr warpAdapter; - ThrowIfFailed(factory->EnumWarpAdapter(IID_PPV_ARGS(&warpAdapter))); - - ThrowIfFailed( - D3D12CreateDevice(warpAdapter.Get(), D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&m_device))); - } else - { - ComPtr hardwareAdapter; - GetHardwareAdapter(factory.Get(), &hardwareAdapter, true); - - ThrowIfFailed(D3D12CreateDevice( - hardwareAdapter.Get(), D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&m_device))); - } - - // Describe and create the command queue. - D3D12_COMMAND_QUEUE_DESC queueDesc = {}; - queueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE; - queueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT; - - ThrowIfFailed(m_device->CreateCommandQueue(&queueDesc, IID_PPV_ARGS(&m_commandQueue))); - - // Describe and create the swap chain. - DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {}; - swapChainDesc.BufferCount = FrameCount; - swapChainDesc.Width = m_width; - swapChainDesc.Height = m_height; - swapChainDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; - swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; - swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; - swapChainDesc.SampleDesc.Count = 1; - - ComPtr swapChain; - ThrowIfFailed(factory->CreateSwapChainForHwnd( - m_commandQueue.Get(), // Swap chain needs the queue so that it can force a flush on it. - Win32Application::GetHwnd(), &swapChainDesc, nullptr, nullptr, &swapChain)); - - // This sample does not support fullscreen transitions. - ThrowIfFailed( - factory->MakeWindowAssociation(Win32Application::GetHwnd(), DXGI_MWA_NO_ALT_ENTER)); - - ThrowIfFailed(swapChain.As(&m_swapChain)); - m_frameIndex = m_swapChain->GetCurrentBackBufferIndex(); - - D3D12_DESCRIPTOR_HEAP_DESC descriptor_heap_desc{D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, - AppDescriptorCount, D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE, 0}; - - m_device->CreateDescriptorHeap(&descriptor_heap_desc, IID_PPV_ARGS(&m_appDescriptorHeap)); - m_appDescriptorHeap->SetName(L"app_descriptor_heap"); -} - -void BasicSample::InitXess() -{ - auto status = xessD3D12CreateContext(m_device.Get(), &m_xessContext); - if (status != XESS_RESULT_SUCCESS) - { - throw std::runtime_error("Unable to create XeSS context"); - } - - xess_properties_t props; - status = xessGetProperties(m_xessContext, &m_desiredOutputResolution, &props); - if (status != XESS_RESULT_SUCCESS) - { - throw std::runtime_error("Unable to get XeSS props"); - } - - xess_version_t xefx_version; - status = xessGetIntelXeFXVersion(m_xessContext, &xefx_version); - if (status != XESS_RESULT_SUCCESS) - { - throw std::runtime_error("Unable to get XeFX version"); - } - - D3D12_HEAP_DESC textures_heap_desc{props.tempTextureHeapSize, - {D3D12_HEAP_TYPE_DEFAULT, D3D12_CPU_PAGE_PROPERTY_UNKNOWN, D3D12_MEMORY_POOL_UNKNOWN, 0, 0}, - 0, D3D12_HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES}; - - m_device->CreateHeap(&textures_heap_desc, IID_PPV_ARGS(&m_texturesHeap)); - m_texturesHeap->SetName(L"xess_textures_heap"); - - m_uavDescriptorSize = - m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - - xess_d3d12_init_params_t params = { - /* Output width and height. */ - m_desiredOutputResolution, - /* Quality setting */ - m_quality, - /* Initialization flags. */ - #if defined(USE_LOWRES_MV) - XESS_INIT_FLAG_NONE, - #else - XESS_INIT_FLAG_HIGH_RES_MV, - #endif - /* Specfies the node mask for internally created resources on - * multi-adapter systems. */ - 0, - /* Specfies the node visibility mask for internally created resources - * on multi-adapter systems. */ - 0, - /* Optional externally allocated buffers storage for XeSS. If NULL the - * storage is allocated internally. If allocated, the heap type must be - * D3D12_HEAP_TYPE_DEFAULT. This heap is not accessed by the CPU. */ - nullptr, - /* Offset in the externally allocated heap for temporary buffers storage. */ - 0, - /* Optional externally allocated textures storage for XeSS. If NULL the - * storage is allocated internally. If allocated, the heap type must be - * D3D12_HEAP_TYPE_DEFAULT. This heap is not accessed by the CPU. */ - m_texturesHeap.Get(), - /* Offset in the externally allocated heap for temporary textures storage. */ - 0, - /* No pipeline library */ - NULL - }; - - status = xessD3D12Init(m_xessContext, ¶ms); - if (status != XESS_RESULT_SUCCESS) - { - throw std::runtime_error("Unable to get XeSS props"); - } - - // Get optimal input resolution - status = xessGetInputResolution( - m_xessContext, &m_desiredOutputResolution, m_quality, &m_renderResolution); - if (status != XESS_RESULT_SUCCESS) - { - throw std::runtime_error("Unable to get XeSS props"); - } -} - -// Load the rendering pipeline dependencies. -void BasicSample::LoadPipeline() -{ - // Create descriptor heaps. - { - // Describe and create a render target view (RTV) descriptor heap. - D3D12_DESCRIPTOR_HEAP_DESC rtvHeapDesc = {}; - rtvHeapDesc.NumDescriptors = FrameCount * RTCount; - rtvHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV; - rtvHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; - ThrowIfFailed(m_device->CreateDescriptorHeap(&rtvHeapDesc, IID_PPV_ARGS(&m_rtvHeap))); - - m_rtvDescriptorSize = - m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV); - } - { - // Describe and create a depth stencil view (DSV) descriptor heap. - D3D12_DESCRIPTOR_HEAP_DESC rtvHeapDesc = {}; - rtvHeapDesc.NumDescriptors = FrameCount; - rtvHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_DSV; - rtvHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; - ThrowIfFailed(m_device->CreateDescriptorHeap(&rtvHeapDesc, IID_PPV_ARGS(&m_dsvHeap))); - - m_dsvDescriptorSize = - m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_DSV); - } - - constexpr int depth_case = 2; // used to test various depth formats with xess*Dump calls. - switch (depth_case) - { - case 0: - m_dsvFormat = DXGI_FORMAT_D32_FLOAT; - m_dsvTypedFormat = DXGI_FORMAT_D32_FLOAT; - break; - case 1: - m_dsvFormat = DXGI_FORMAT_R32_TYPELESS; - m_dsvTypedFormat = DXGI_FORMAT_D32_FLOAT; - break; - case 2: - m_dsvFormat = DXGI_FORMAT_R32G8X24_TYPELESS; - m_dsvTypedFormat = DXGI_FORMAT_D32_FLOAT_S8X24_UINT; - break; - case 3: - m_dsvFormat = DXGI_FORMAT_R24G8_TYPELESS; - m_dsvTypedFormat = DXGI_FORMAT_D24_UNORM_S8_UINT; - break; - case 4: - m_dsvFormat = DXGI_FORMAT_R24_UNORM_X8_TYPELESS; - m_dsvTypedFormat = DXGI_FORMAT_D24_UNORM_S8_UINT; - break; - case 5: - m_dsvFormat = DXGI_FORMAT_R16_TYPELESS; - m_dsvTypedFormat = DXGI_FORMAT_D16_UNORM; - break; - case 6: - m_dsvFormat = DXGI_FORMAT_R16_UINT; - m_dsvTypedFormat = DXGI_FORMAT_D16_UNORM; - break; - default: - throw std::runtime_error("Please select depth format case!"); - break; - } - - // Create frame resources. - { - CD3DX12_CPU_DESCRIPTOR_HANDLE rtvHandle(m_rtvHeap->GetCPUDescriptorHandleForHeapStart()); - CD3DX12_CPU_DESCRIPTOR_HANDLE dsvHandle(m_dsvHeap->GetCPUDescriptorHandleForHeapStart()); - - // Create render targets and xes output for each frame - for (UINT n = 0; n < FrameCount; n++) - { - D3D12_HEAP_PROPERTIES heap_props = CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT); - DXGI_FORMAT fmt = DXGI_FORMAT_R16G16B16A16_FLOAT; - D3D12_RESOURCE_DESC tex_desc = - CD3DX12_RESOURCE_DESC::Tex2D(fmt, m_renderResolution.x, m_renderResolution.y); - tex_desc.MipLevels = 1; - - // Get swapchain - ThrowIfFailed(m_swapChain->GetBuffer(n, IID_PPV_ARGS(&m_presentRenderTargets[n]))); - - D3D12_CLEAR_VALUE clear_value; - clear_value.Color[0] = m_clearColor[0]; - clear_value.Color[1] = m_clearColor[1]; - clear_value.Color[2] = m_clearColor[2]; - clear_value.Color[3] = m_clearColor[3]; - clear_value.Format = fmt; - - // Render target - tex_desc.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET; - ThrowIfFailed(m_device->CreateCommittedResource(&heap_props, D3D12_HEAP_FLAG_NONE, - &tex_desc, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, &clear_value, - IID_PPV_ARGS(&m_renderTargets[n]))); - - tex_desc.Flags = D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL; - tex_desc.Format = m_dsvFormat; - ThrowIfFailed(m_device->CreateCommittedResource(&heap_props, D3D12_HEAP_FLAG_NONE, - &tex_desc, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, nullptr, - IID_PPV_ARGS(&m_depthTargets[n]))); - - // XeSS output - tex_desc = CD3DX12_RESOURCE_DESC::Tex2D( - fmt, m_desiredOutputResolution.x, m_desiredOutputResolution.y); - tex_desc.Flags = D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; - ThrowIfFailed(m_device->CreateCommittedResource(&heap_props, D3D12_HEAP_FLAG_NONE, - &tex_desc, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, nullptr, - IID_PPV_ARGS(&m_xessOutput[n]))); - - // Velocity - fmt = DXGI_FORMAT_R16G16_FLOAT; - tex_desc = CD3DX12_RESOURCE_DESC::Tex2D( - fmt, m_desiredOutputResolution.x, m_desiredOutputResolution.y); - tex_desc.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET; - clear_value.Format = fmt; - ThrowIfFailed(m_device->CreateCommittedResource(&heap_props, D3D12_HEAP_FLAG_NONE, - &tex_desc, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, &clear_value, - IID_PPV_ARGS(&m_renderTargetsVelocity[n]))); - - // Create RTVs - // RT_Present - m_device->CreateRenderTargetView(m_presentRenderTargets[n].Get(), nullptr, rtvHandle); - rtvHandle.Offset(1, m_rtvDescriptorSize); - - // RT_Color - m_device->CreateRenderTargetView(m_renderTargets[n].Get(), nullptr, rtvHandle); - rtvHandle.Offset(1, m_rtvDescriptorSize); - - // RT_Velocity - m_device->CreateRenderTargetView(m_renderTargetsVelocity[n].Get(), nullptr, rtvHandle); - rtvHandle.Offset(1, m_rtvDescriptorSize); - - // RT_Depth - auto dsv_desc = D3D12_DEPTH_STENCIL_VIEW_DESC{}; - dsv_desc.Format = m_dsvTypedFormat; - dsv_desc.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2D; - dsv_desc.Flags = D3D12_DSV_FLAG_NONE; - dsv_desc.Texture2D = D3D12_TEX2D_DSV{}; - dsv_desc.Texture2D.MipSlice = 0; - m_device->CreateDepthStencilView(m_depthTargets[n].Get(), &dsv_desc, dsvHandle); - dsvHandle.Offset(1, m_dsvDescriptorSize); - - m_presentRenderTargets[n]->SetName( - (std::wstring(L"Present") + std::to_wstring(n)).c_str()); - m_renderTargets[n]->SetName((std::wstring(L"Color") + std::to_wstring(n)).c_str()); - m_depthTargets[n]->SetName((std::wstring(L"Depth") + std::to_wstring(n)).c_str()); - m_xessOutput[n]->SetName((std::wstring(L"XeSSOutput") + std::to_wstring(n)).c_str()); - m_renderTargetsVelocity[n]->SetName( - (std::wstring(L"Velocity") + std::to_wstring(n)).c_str()); - } - } - - ThrowIfFailed(m_device->CreateCommandAllocator( - D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&m_commandAllocator))); -} - -// Load the sample assets. -void BasicSample::LoadAssets() -{ - // Create a root signature consisting of a descriptor table with a single CBV. - { - D3D12_FEATURE_DATA_ROOT_SIGNATURE featureData = {}; - - // This is the highest version the sample supports. If CheckFeatureSupport succeeds, the - // HighestVersion returned will not be greater than this. - featureData.HighestVersion = D3D_ROOT_SIGNATURE_VERSION_1_1; - - if (FAILED(m_device->CheckFeatureSupport( - D3D12_FEATURE_ROOT_SIGNATURE, &featureData, sizeof(featureData)))) - { - featureData.HighestVersion = D3D_ROOT_SIGNATURE_VERSION_1_0; - } - - CD3DX12_DESCRIPTOR_RANGE1 ranges[1]; - CD3DX12_ROOT_PARAMETER1 rootParameters[1]; - - ranges[0].Init( - D3D12_DESCRIPTOR_RANGE_TYPE_CBV, 1, 0, 0, D3D12_DESCRIPTOR_RANGE_FLAG_DATA_STATIC); - rootParameters[0].InitAsDescriptorTable(1, &ranges[0], D3D12_SHADER_VISIBILITY_ALL); - - // Allow input layout and deny uneccessary access to certain pipeline stages. - D3D12_ROOT_SIGNATURE_FLAGS rootSignatureFlags = - D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | - D3D12_ROOT_SIGNATURE_FLAG_DENY_HULL_SHADER_ROOT_ACCESS | - D3D12_ROOT_SIGNATURE_FLAG_DENY_DOMAIN_SHADER_ROOT_ACCESS | - D3D12_ROOT_SIGNATURE_FLAG_DENY_GEOMETRY_SHADER_ROOT_ACCESS; - - CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC rootSignatureDesc; - rootSignatureDesc.Init_1_1( - _countof(rootParameters), rootParameters, 0, nullptr, rootSignatureFlags); - - ComPtr signature; - ComPtr error; - ThrowIfFailed(D3DX12SerializeVersionedRootSignature( - &rootSignatureDesc, featureData.HighestVersion, &signature, &error)); - ThrowIfFailed(m_device->CreateRootSignature(0, signature->GetBufferPointer(), - signature->GetBufferSize(), IID_PPV_ARGS(&m_rootSignature))); - } - - // Create the pipeline state, which includes compiling and loading shaders. - { - ComPtr vertexShader; - ComPtr pixelShader; - -#if defined(_DEBUG) - // Enable better shader debugging with the graphics debugging tools. - UINT compileFlags = D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION; -#else - UINT compileFlags = 0; -#endif - - ThrowIfFailed(D3DCompileFromFile(GetAssetFullPath(L"shaders.hlsl").c_str(), nullptr, - nullptr, "VSMainColor", "vs_5_0", compileFlags, 0, &vertexShader, nullptr)); - ThrowIfFailed(D3DCompileFromFile(GetAssetFullPath(L"shaders.hlsl").c_str(), nullptr, - nullptr, "PSMainColor", "ps_5_0", compileFlags, 0, &pixelShader, nullptr)); - - // Define the vertex input layout. - D3D12_INPUT_ELEMENT_DESC inputElementDescs[] = { - {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, - D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0}, - {"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, - D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0}}; - - // Describe and create the graphics pipeline state object (PSO). - D3D12_GRAPHICS_PIPELINE_STATE_DESC psoDesc = {}; - psoDesc.InputLayout = {inputElementDescs, _countof(inputElementDescs)}; - psoDesc.pRootSignature = m_rootSignature.Get(); - psoDesc.VS = CD3DX12_SHADER_BYTECODE(vertexShader.Get()); - psoDesc.PS = CD3DX12_SHADER_BYTECODE(pixelShader.Get()); - psoDesc.RasterizerState = CD3DX12_RASTERIZER_DESC(D3D12_DEFAULT); - psoDesc.BlendState = CD3DX12_BLEND_DESC(D3D12_DEFAULT); - psoDesc.DepthStencilState.DepthEnable = TRUE; - psoDesc.DepthStencilState.DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ALL; - psoDesc.DepthStencilState.DepthFunc = D3D12_COMPARISON_FUNC_ALWAYS; - psoDesc.DepthStencilState.StencilEnable = TRUE; - psoDesc.DepthStencilState.FrontFace = psoDesc.DepthStencilState.BackFace = - D3D12_DEPTH_STENCILOP_DESC{D3D12_STENCIL_OP_KEEP, D3D12_STENCIL_OP_KEEP, - D3D12_STENCIL_OP_KEEP, D3D12_COMPARISON_FUNC_ALWAYS}; - psoDesc.DepthStencilState.StencilReadMask = (UINT8)0xff; - psoDesc.DepthStencilState.StencilWriteMask = (UINT8)0xff; - psoDesc.SampleMask = UINT_MAX; - psoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; - psoDesc.NumRenderTargets = 1; - psoDesc.RTVFormats[0] = DXGI_FORMAT_R16G16B16A16_FLOAT; - psoDesc.DSVFormat = m_dsvTypedFormat; - psoDesc.SampleDesc.Count = 1; - - ThrowIfFailed(m_device->CreateGraphicsPipelineState( - &psoDesc, IID_PPV_ARGS(&m_pipelineStateColorPass))); - } - - // Create velocity pass - { - ComPtr vertexShader; - ComPtr pixelShader; - -#if defined(_DEBUG) - // Enable better shader debugging with the graphics debugging tools. - UINT compileFlags = D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION; -#else - UINT compileFlags = 0; -#endif - - ThrowIfFailed(D3DCompileFromFile(GetAssetFullPath(L"shaders.hlsl").c_str(), nullptr, - nullptr, "VSMainVelocity", "vs_5_0", compileFlags, 0, &vertexShader, nullptr)); - ThrowIfFailed(D3DCompileFromFile(GetAssetFullPath(L"shaders.hlsl").c_str(), nullptr, - nullptr, "PSMainVelocity", "ps_5_0", compileFlags, 0, &pixelShader, nullptr)); - - // Define the vertex input layout. - D3D12_INPUT_ELEMENT_DESC inputElementDescs[] = { - {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, - D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0}, - {"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, - D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0}}; - - // Describe and create the graphics pipeline state object (PSO). - D3D12_GRAPHICS_PIPELINE_STATE_DESC psoDesc = {}; - psoDesc.InputLayout = {inputElementDescs, _countof(inputElementDescs)}; - psoDesc.pRootSignature = m_rootSignature.Get(); - psoDesc.VS = CD3DX12_SHADER_BYTECODE(vertexShader.Get()); - psoDesc.PS = CD3DX12_SHADER_BYTECODE(pixelShader.Get()); - psoDesc.RasterizerState = CD3DX12_RASTERIZER_DESC(D3D12_DEFAULT); - psoDesc.BlendState = CD3DX12_BLEND_DESC(D3D12_DEFAULT); - psoDesc.DepthStencilState.DepthEnable = FALSE; - psoDesc.DepthStencilState.StencilEnable = FALSE; - psoDesc.SampleMask = UINT_MAX; - psoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; - psoDesc.NumRenderTargets = 1; - psoDesc.RTVFormats[0] = DXGI_FORMAT_R16G16_FLOAT; - psoDesc.SampleDesc.Count = 1; - - ThrowIfFailed(m_device->CreateGraphicsPipelineState( - &psoDesc, IID_PPV_ARGS(&m_pipelineStateVelocityPass))); - } - - // Create the command list. - ThrowIfFailed(m_device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, - m_commandAllocator.Get(), m_pipelineStateColorPass.Get(), IID_PPV_ARGS(&m_commandList))); - - // Command lists are created in the recording state, but there is nothing - // to record yet. The main loop expects it to be closed, so close it now. - ThrowIfFailed(m_commandList->Close()); - - // Create the vertex buffer. - { - // Define the geometry for a triangle. - Vertex triangleVertices[] = { - {{0.0f, 0.25f * m_aspectRatio, 0.01f}, {1.0f, 0.0f, 0.0f, 1.0f}}, - {{0.25f, -0.25f * m_aspectRatio, 0.5f}, {0.0f, 1.0f, 0.0f, 1.0f}}, - {{-0.25f, -0.25f * m_aspectRatio, 0.2f}, {0.0f, 0.0f, 1.0f, 1.0f}}}; - - const UINT vertexBufferSize = sizeof(triangleVertices); - - // Note: using upload heaps to transfer static data like vert buffers is not - // recommended. Every time the GPU needs it, the upload heap will be marshalled - // over. Please read up on Default Heap usage. An upload heap is used here for - // code simplicity and because there are very few verts to actually transfer. - auto heap_props = CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_UPLOAD); - auto resource_desc = CD3DX12_RESOURCE_DESC::Buffer(vertexBufferSize); - ThrowIfFailed( - m_device->CreateCommittedResource(&heap_props, D3D12_HEAP_FLAG_NONE, &resource_desc, - D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, IID_PPV_ARGS(&m_vertexBuffer))); - - // Copy the triangle data to the vertex buffer. - UINT8* pVertexDataBegin; - CD3DX12_RANGE readRange(0, 0); // We do not intend to read from this resource on the CPU. - ThrowIfFailed( - m_vertexBuffer->Map(0, &readRange, reinterpret_cast(&pVertexDataBegin))); - memcpy(pVertexDataBegin, triangleVertices, sizeof(triangleVertices)); - m_vertexBuffer->Unmap(0, nullptr); - - // Initialize the vertex buffer view. - m_vertexBufferView.BufferLocation = m_vertexBuffer->GetGPUVirtualAddress(); - m_vertexBufferView.StrideInBytes = sizeof(Vertex); - m_vertexBufferView.SizeInBytes = vertexBufferSize; - } - - // Create the constant buffer. - { - const UINT constantBufferSize = - sizeof(SceneConstantBuffer); // CB size is required to be 256-byte aligned. - - auto heap_props = CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_UPLOAD); - auto resource_desc = CD3DX12_RESOURCE_DESC::Buffer(constantBufferSize); - ThrowIfFailed( - m_device->CreateCommittedResource(&heap_props, D3D12_HEAP_FLAG_NONE, &resource_desc, - D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, IID_PPV_ARGS(&m_constantBuffer))); - - // Describe and create a constant buffer view. - D3D12_CONSTANT_BUFFER_VIEW_DESC cbvDesc = {}; - cbvDesc.BufferLocation = m_constantBuffer->GetGPUVirtualAddress(); - cbvDesc.SizeInBytes = constantBufferSize; - m_device->CreateConstantBufferView( - &cbvDesc, m_appDescriptorHeap->GetCPUDescriptorHandleForHeapStart()); - - // Map and initialize the constant buffer. We don't unmap this until the - // app closes. Keeping things mapped for the lifetime of the resource is okay. - CD3DX12_RANGE readRange(0, 0); // We do not intend to read from this resource on the CPU. - ThrowIfFailed( - m_constantBuffer->Map(0, &readRange, reinterpret_cast(&m_pCbvDataBegin))); - memcpy(m_pCbvDataBegin, &m_constantBufferData, sizeof(m_constantBufferData)); - } - - // Create synchronization objects and wait until assets have been uploaded to the GPU. - { - ThrowIfFailed(m_device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&m_fence))); - m_fenceValue = 1; - - // Create an event handle to use for frame synchronization. - m_fenceEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); - if (m_fenceEvent == nullptr) - { - ThrowIfFailed(HRESULT_FROM_WIN32(GetLastError())); - } - - // Wait for the command list to execute; we are reusing the same command - // list in our main loop but for now, we just want to wait for setup to - // complete before continuing. - WaitForPreviousFrame(); - } -} - -void BasicSample::PopulateDescriptorHeap() -{ - auto addTexture = - [&](std::uint32_t index, ID3D12Resource* resource, DXGI_FORMAT fmt, bool is_uav = false) - { - CD3DX12_CPU_DESCRIPTOR_HANDLE cpuDescHandle( - m_appDescriptorHeap->GetCPUDescriptorHandleForHeapStart(), (INT)index, m_uavDescriptorSize); - - if (is_uav) - { - D3D12_UNORDERED_ACCESS_VIEW_DESC uavDesc = {}; - - uavDesc.Format = fmt; - uavDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2D; - uavDesc.Texture2D.MipSlice = 0; - uavDesc.Texture2D.PlaneSlice = 0; - - m_device->CreateUnorderedAccessView(resource, nullptr, &uavDesc, cpuDescHandle); - } else - { - D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; - - srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; - srvDesc.Format = fmt; - srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; - srvDesc.Texture2D.MipLevels = 1; - srvDesc.Texture2D.MostDetailedMip = 0; - srvDesc.Texture2D.PlaneSlice = 0; - m_device->CreateShaderResourceView(resource, &srvDesc, cpuDescHandle); - } - }; - - for (UINT n = 0; n < FrameCount; ++n) - { - addTexture(DescriptorsPerFrame * n + DHI_Color, m_renderTargets[n].Get(), - DXGI_FORMAT_R16G16B16A16_FLOAT); - addTexture(DescriptorsPerFrame * n + DHI_Velocity, - m_renderTargetsVelocity[n].Get(), DXGI_FORMAT_R16G16_FLOAT); - addTexture(DescriptorsPerFrame * n + DHI_XeSSOutputUAV, m_xessOutput[n].Get(), - DXGI_FORMAT_R16G16B16A16_FLOAT, true); - addTexture(DescriptorsPerFrame * n + DHI_XeSSOutputSRV, m_xessOutput[n].Get(), - DXGI_FORMAT_R16G16B16A16_FLOAT); - } -} - -void BasicSample::CreateFSQPipeline() -{ - // Create a root signature - { - D3D12_FEATURE_DATA_ROOT_SIGNATURE featureData = {}; - - // This is the highest version the sample supports. If CheckFeatureSupport succeeds, the - // HighestVersion returned will not be greater than this. - featureData.HighestVersion = D3D_ROOT_SIGNATURE_VERSION_1_1; - - if (FAILED(m_device->CheckFeatureSupport( - D3D12_FEATURE_ROOT_SIGNATURE, &featureData, sizeof(featureData)))) - { - featureData.HighestVersion = D3D_ROOT_SIGNATURE_VERSION_1_0; - } - - CD3DX12_DESCRIPTOR_RANGE1 ranges[1]; - ranges[0].Init( - D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 1, 0, 0, D3D12_DESCRIPTOR_RANGE_FLAG_DATA_VOLATILE); - - CD3DX12_ROOT_PARAMETER1 rootParameters[1]; - rootParameters[0].InitAsDescriptorTable(1, &ranges[0], D3D12_SHADER_VISIBILITY_PIXEL); - - D3D12_STATIC_SAMPLER_DESC sampler = {}; - sampler.Filter = D3D12_FILTER_MIN_MAG_MIP_POINT; - sampler.AddressU = D3D12_TEXTURE_ADDRESS_MODE_BORDER; - sampler.AddressV = D3D12_TEXTURE_ADDRESS_MODE_BORDER; - sampler.AddressW = D3D12_TEXTURE_ADDRESS_MODE_BORDER; - sampler.MipLODBias = 0; - sampler.MaxAnisotropy = 0; - sampler.ComparisonFunc = D3D12_COMPARISON_FUNC_NEVER; - sampler.BorderColor = D3D12_STATIC_BORDER_COLOR_TRANSPARENT_BLACK; - sampler.MinLOD = 0.0f; - sampler.MaxLOD = D3D12_FLOAT32_MAX; - sampler.ShaderRegister = 0; - sampler.RegisterSpace = 0; - sampler.ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL; - - CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC rootSignatureDesc; - rootSignatureDesc.Init_1_1(_countof(rootParameters), rootParameters, 1, &sampler, - D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT); - - ComPtr signature; - ComPtr error; - ThrowIfFailed(D3DX12SerializeVersionedRootSignature( - &rootSignatureDesc, featureData.HighestVersion, &signature, &error)); - ThrowIfFailed(m_device->CreateRootSignature(0, signature->GetBufferPointer(), - signature->GetBufferSize(), IID_PPV_ARGS(&m_rootSignatureFSQ))); - } - - // Create the pipeline state, which includes compiling and loading shaders. - { - ComPtr vertexShader; - ComPtr pixelShader; - -#if defined(_DEBUG) - // Enable better shader debugging with the graphics debugging tools. - UINT compileFlags = D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION; -#else - UINT compileFlags = 0; -#endif - - ThrowIfFailed(D3DCompileFromFile(GetAssetFullPath(L"shaders.hlsl").c_str(), nullptr, - nullptr, "VSMainFSQ", "vs_5_0", compileFlags, 0, &vertexShader, nullptr)); - ThrowIfFailed(D3DCompileFromFile(GetAssetFullPath(L"shaders.hlsl").c_str(), nullptr, - nullptr, "PSMainFSQ", "ps_5_0", compileFlags, 0, &pixelShader, nullptr)); - - // Describe and create the graphics pipeline state object (PSO). - D3D12_GRAPHICS_PIPELINE_STATE_DESC psoDesc = {}; - psoDesc.InputLayout = {}; - psoDesc.pRootSignature = m_rootSignatureFSQ.Get(); - psoDesc.VS = CD3DX12_SHADER_BYTECODE(vertexShader.Get()); - psoDesc.PS = CD3DX12_SHADER_BYTECODE(pixelShader.Get()); - psoDesc.RasterizerState = CD3DX12_RASTERIZER_DESC(D3D12_DEFAULT); - psoDesc.BlendState = CD3DX12_BLEND_DESC(D3D12_DEFAULT); - psoDesc.DepthStencilState.DepthEnable = FALSE; - psoDesc.DepthStencilState.StencilEnable = FALSE; - psoDesc.SampleMask = UINT_MAX; - psoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; - psoDesc.NumRenderTargets = 1; - psoDesc.RTVFormats[0] = DXGI_FORMAT_R8G8B8A8_UNORM; - psoDesc.SampleDesc.Count = 1; - - ThrowIfFailed( - m_device->CreateGraphicsPipelineState(&psoDesc, IID_PPV_ARGS(&m_pipelineStateFSQPass))); - } -} - -// Update frame-based values. -void BasicSample::OnUpdate() -{ - if (last_time.time_since_epoch().count() == 0) - { - last_time = std::chrono::high_resolution_clock::now(); - } - - auto current_time = std::chrono::high_resolution_clock::now(); - std::chrono::duration elapsed_seconds = current_time - last_time; - last_time = current_time; - - const double speed = 1. / 2; //4 second for screen - float translationSpeed = m_pause ? 0.f : (float)(speed * elapsed_seconds.count()); - const float offsetBounds = 1.25f; - - m_constantBufferData.offset.x += translationSpeed; - if (m_constantBufferData.offset.x > offsetBounds) - { - m_constantBufferData.offset.x = -offsetBounds; - } - - auto haltonValue = m_haltonPointSet[m_haltonIndex]; - m_haltonIndex = (m_haltonIndex + 1) % m_haltonPointSet.size(); - - jitter[0] = haltonValue.first; - jitter[1] = haltonValue.second; - - m_constantBufferData.offset.z = jitter[0]; - m_constantBufferData.offset.w = jitter[1]; - - m_constantBufferData.resolution.x = (float)m_renderResolution.x; - m_constantBufferData.resolution.y = (float)m_renderResolution.y; - - m_constantBufferData.velocity.x = -translationSpeed * ((float)m_desiredOutputResolution.x / 2.f); - - memcpy(m_pCbvDataBegin, &m_constantBufferData, sizeof(m_constantBufferData)); -} - -// Render the scene. -void BasicSample::OnRender() -{ - // Record all the commands we need to render the scene into the command list. - PopulateCommandList(); - - // Execute the command list. - ID3D12CommandList* ppCommandLists[] = {m_commandList.Get()}; - m_commandQueue->ExecuteCommandLists(_countof(ppCommandLists), ppCommandLists); - - // Present the frame. - ThrowIfFailed(m_swapChain->Present(1, 0)); - - WaitForPreviousFrame(); -} - -void BasicSample::OnDestroy() -{ - // Ensure that the GPU is no longer referencing resources that are about to be - // cleaned up by the destructor. - WaitForPreviousFrame(); - - auto status = xessDestroyContext(m_xessContext); - if (status != XESS_RESULT_SUCCESS) - { - throw std::runtime_error("Unable to destroy XeSS context"); - } - - CloseHandle(m_fenceEvent); -} - -// Fill the command list with all the render commands and dependent state. -void BasicSample::PopulateCommandList() -{ - // Command list allocators can only be reset when the associated - // command lists have finished execution on the GPU; apps should use - // fences to determine GPU execution progress. - ThrowIfFailed(m_commandAllocator->Reset()); - - // However, when ExecuteCommandList() is called on a particular command - // list, that command list can then be reset at any time and must be before - // re-recording. - ThrowIfFailed(m_commandList->Reset(m_commandAllocator.Get(), m_pipelineStateColorPass.Get())); - - // Run Color pass - { - // Set necessary state. - m_commandList->SetGraphicsRootSignature(m_rootSignature.Get()); - - ID3D12DescriptorHeap* ppHeaps[] = {m_appDescriptorHeap.Get()}; - m_commandList->SetDescriptorHeaps(_countof(ppHeaps), ppHeaps); - - CD3DX12_VIEWPORT render_res_viewport( - 0.f, 0.f, (float)m_renderResolution.x, (float)m_renderResolution.y); - CD3DX12_RECT render_res_scissors(0, 0, (LONG)m_renderResolution.x, (LONG)m_renderResolution.y); - - m_commandList->SetGraphicsRootDescriptorTable( - 0, m_appDescriptorHeap->GetGPUDescriptorHandleForHeapStart()); - m_commandList->RSSetViewports(1, &render_res_viewport); - m_commandList->RSSetScissorRects(1, &render_res_scissors); - - // Transition Color buffer to render target - std::vector transition = - { CD3DX12_RESOURCE_BARRIER::Transition(m_renderTargets[m_frameIndex].Get(), - D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET), - CD3DX12_RESOURCE_BARRIER::Transition(m_depthTargets[m_frameIndex].Get(), - D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_DEPTH_WRITE), - - }; - m_commandList->ResourceBarrier((UINT)transition.size(), transition.data()); - - CD3DX12_CPU_DESCRIPTOR_HANDLE rtvHandle = - CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtvHeap->GetCPUDescriptorHandleForHeapStart(), - (INT)(m_frameIndex * RTCount + RT_Color), m_rtvDescriptorSize); - CD3DX12_CPU_DESCRIPTOR_HANDLE dsvHandle = - CD3DX12_CPU_DESCRIPTOR_HANDLE(m_dsvHeap->GetCPUDescriptorHandleForHeapStart(), - (INT)(m_frameIndex), m_dsvDescriptorSize); - m_commandList->OMSetRenderTargets(1, &rtvHandle, FALSE, &dsvHandle); - - // Record commands. - m_commandList->ClearRenderTargetView(rtvHandle, m_clearColor, 0, nullptr); - m_commandList->ClearDepthStencilView( - dsvHandle, D3D12_CLEAR_FLAG_DEPTH | D3D12_CLEAR_FLAG_STENCIL, 0.0f, 0, 0, nullptr); - m_commandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - m_commandList->IASetVertexBuffers(0, 1, &m_vertexBufferView); - m_commandList->DrawInstanced(3, 1, 0, 0); - } - - // Run velocity pass - { - m_commandList->SetPipelineState(m_pipelineStateVelocityPass.Get()); - - m_commandList->RSSetViewports(1, &m_viewport); - m_commandList->RSSetScissorRects(1, &m_scissorRect); - - // Indicate that the back buffer will be used as a render target. - CD3DX12_RESOURCE_BARRIER transition = - CD3DX12_RESOURCE_BARRIER::Transition(m_renderTargetsVelocity[m_frameIndex].Get(), - D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_RENDER_TARGET); - m_commandList->ResourceBarrier(1, &transition); - - CD3DX12_CPU_DESCRIPTOR_HANDLE rtvHandle = - CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtvHeap->GetCPUDescriptorHandleForHeapStart(), - (INT)(m_frameIndex * RTCount + RT_Velocity), m_rtvDescriptorSize); - m_commandList->OMSetRenderTargets(1, &rtvHandle, FALSE, nullptr); - - // Record commands. - m_commandList->ClearRenderTargetView(rtvHandle, m_clearColor, 0, nullptr); - m_commandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - m_commandList->IASetVertexBuffers(0, 1, &m_vertexBufferView); - m_commandList->DrawInstanced(3, 1, 0, 0); - } - - // Transition render targets D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE for XeSS - std::vector transitions = { - CD3DX12_RESOURCE_BARRIER::Transition(m_renderTargets[m_frameIndex].Get(), - D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE), - CD3DX12_RESOURCE_BARRIER::Transition(m_renderTargetsVelocity[m_frameIndex].Get(), - D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE), - CD3DX12_RESOURCE_BARRIER::Transition(m_depthTargets[m_frameIndex].Get(), - D3D12_RESOURCE_STATE_DEPTH_WRITE, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE), - }; - m_commandList->ResourceBarrier((UINT)transitions.size(), transitions.data()); - - // Run XeSS - { - xess_d3d12_execute_params_t exec_params{}; - exec_params.inputWidth = m_renderResolution.x; - exec_params.inputHeight = m_renderResolution.y; - exec_params.jitterOffsetX = jitter[0]; - exec_params.jitterOffsetY = -jitter[1]; - exec_params.exposureScale = 1.0f; - - exec_params.pColorTexture = m_renderTargets[m_frameIndex].Get(); - exec_params.pVelocityTexture = m_renderTargetsVelocity[m_frameIndex].Get(); - exec_params.pOutputTexture = m_xessOutput[m_frameIndex].Get(); - #if defined(USE_LOWRES_MV) - exec_params.pDepthTexture = m_depthTargets[m_frameIndex].Get(); - #else - exec_params.pDepthTexture = nullptr; - #endif - exec_params.pExposureScaleTexture = 0; - auto status = xessD3D12Execute(m_xessContext, m_commandList.Get(), &exec_params); - if (status != XESS_RESULT_SUCCESS) - { - throw std::runtime_error("Unable to run XeSS"); - } - } - - // Render XeSS output using full screen quad - { - ID3D12DescriptorHeap* ppHeaps[] = {m_appDescriptorHeap.Get()}; - m_commandList->SetDescriptorHeaps(_countof(ppHeaps), ppHeaps); - - // Transition XeSS output is in UAV so we need to transition it to SRV - CD3DX12_RESOURCE_BARRIER transition = CD3DX12_RESOURCE_BARRIER::Transition( - m_xessOutput[m_frameIndex].Get(), D3D12_RESOURCE_STATE_UNORDERED_ACCESS, - D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - m_commandList->ResourceBarrier(1, &transition); - - m_commandList->SetPipelineState(m_pipelineStateFSQPass.Get()); - - m_commandList->SetGraphicsRootSignature(m_rootSignatureFSQ.Get()); - - // Use selected output (DHI_XeSSOutputSRV by default) - CD3DX12_GPU_DESCRIPTOR_HANDLE gpuDescHandle( - m_appDescriptorHeap->GetGPUDescriptorHandleForHeapStart(), - (INT)((DescriptorsPerFrame * m_frameIndex) + m_outputIndex), m_uavDescriptorSize); - m_commandList->SetGraphicsRootDescriptorTable(0, gpuDescHandle); - m_commandList->RSSetViewports(1, &m_viewport); - m_commandList->RSSetScissorRects(1, &m_scissorRect); - - // Indicate that the back buffer will be used as a render target. - transition = - CD3DX12_RESOURCE_BARRIER::Transition(m_presentRenderTargets[m_frameIndex].Get(), - D3D12_RESOURCE_STATE_PRESENT, D3D12_RESOURCE_STATE_RENDER_TARGET); - m_commandList->ResourceBarrier(1, &transition); - - CD3DX12_CPU_DESCRIPTOR_HANDLE rtvHandle = - CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtvHeap->GetCPUDescriptorHandleForHeapStart(), - (INT)(m_frameIndex * RTCount), m_rtvDescriptorSize); - m_commandList->OMSetRenderTargets(1, &rtvHandle, FALSE, nullptr); - - // Record commands. - m_commandList->ClearRenderTargetView(rtvHandle, m_clearColor, 0, nullptr); - m_commandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - m_commandList->IASetVertexBuffers(0, 1, &m_vertexBufferView); - m_commandList->DrawInstanced(3, 1, 0, 0); - - // Transition RT to present - transition = - CD3DX12_RESOURCE_BARRIER::Transition(m_presentRenderTargets[m_frameIndex].Get(), - D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PRESENT); - m_commandList->ResourceBarrier(1, &transition); - - // Transition XeSS output to UAV for future use - transition = CD3DX12_RESOURCE_BARRIER::Transition(m_xessOutput[m_frameIndex].Get(), - D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - m_commandList->ResourceBarrier(1, &transition); - } - - ThrowIfFailed(m_commandList->Close()); -} - -void BasicSample::WaitForPreviousFrame() -{ - // WAITING FOR THE FRAME TO COMPLETE BEFORE CONTINUING IS NOT BEST PRACTICE. - // This is code implemented as such for simplicity. The D3D12HelloFrameBuffering - // sample illustrates how to use fences for efficient resource usage and to - // maximize GPU utilization. - - // Signal and increment the fence value. - const UINT64 fence = m_fenceValue; - ThrowIfFailed(m_commandQueue->Signal(m_fence.Get(), fence)); - m_fenceValue++; - - // Wait until the previous frame is finished. - if (m_fence->GetCompletedValue() < fence) - { - ThrowIfFailed(m_fence->SetEventOnCompletion(fence, m_fenceEvent)); - WaitForSingleObject(m_fenceEvent, INFINITE); - } - - m_frameIndex = m_swapChain->GetCurrentBackBufferIndex(); -} diff --git a/xess/samples/basic_sample/basic_sample.h b/xess/samples/basic_sample/basic_sample.h deleted file mode 100644 index 215f409..0000000 --- a/xess/samples/basic_sample/basic_sample.h +++ /dev/null @@ -1,151 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -#pragma once - -#include "DXSample.h" -#include "xess/xess_d3d12.h" - -#include - -using namespace DirectX; - -// Note that while ComPtr is used to manage the lifetime of resources on the CPU, -// it has no understanding of the lifetime of resources on the GPU. Apps must account -// for the GPU lifetime of resources to avoid destroying objects that may still be -// referenced by the GPU. -// An example of this can be found in the class method: OnDestroy(). -using Microsoft::WRL::ComPtr; - -class BasicSample : public DXSample -{ -public: - BasicSample(UINT width, UINT height, std::wstring name); - - virtual void OnInit(); - virtual void OnUpdate(); - virtual void OnRender(); - virtual void OnDestroy(); - - virtual void OnKeyUp(UINT8 key); - -private: - enum DescriptorHeapIndices - { - DHI_Scene = 0, - DHI_Color = 1, - DHI_Velocity = 2, - DHI_Depth = 3, - DHI_XeSSOutputUAV = 4, - DHI_XeSSOutputSRV = 5 - }; - - enum RTIndices - { - RT_Present = 0, - RT_Color = 1, - RT_Velocity = 2, - RT_Depth = 3, - }; - - static const UINT DescriptorsPerFrame = 5; - static const UINT FrameCount = 2; - static const uint32_t AppDescriptorCount = 64; - static const UINT RTCount = 3; - - virtual void InitDx(); - virtual void InitXess(); - virtual void CreateFSQPipeline(); - virtual void PopulateDescriptorHeap(); - - struct Vertex - { - XMFLOAT3 position; - XMFLOAT4 color; - }; - - struct SceneConstantBuffer - { - XMFLOAT4 offset; // X, Y - offset, Z, W - jitter - XMFLOAT4 velocity; - XMFLOAT4 resolution; - float padding[52]; // Padding so the constant buffer is 256-byte aligned. - }; - static_assert((sizeof(SceneConstantBuffer) % 256) == 0, - "Constant Buffer size must be 256-byte aligned"); - - // Pipeline objects. - CD3DX12_VIEWPORT m_viewport; - CD3DX12_RECT m_scissorRect; - ComPtr m_swapChain; - ComPtr m_device; - ComPtr m_renderTargets[FrameCount]; - ComPtr m_depthTargets[FrameCount]; - ComPtr m_renderTargetsVelocity[FrameCount]; - ComPtr m_presentRenderTargets[FrameCount]; - ComPtr m_commandAllocator; - ComPtr m_commandQueue; - ComPtr m_rootSignature; - ComPtr m_rtvHeap; - ComPtr m_dsvHeap; - ComPtr m_appDescriptorHeap; - ComPtr m_pipelineStateColorPass; - ComPtr m_pipelineStateVelocityPass; - ComPtr m_commandList; - DXGI_FORMAT m_dsvFormat; - DXGI_FORMAT m_dsvTypedFormat; - - std::uint32_t m_outputIndex = DHI_XeSSOutputSRV; - UINT m_rtvDescriptorSize; - UINT m_dsvDescriptorSize; - UINT m_uavDescriptorSize; - - ComPtr m_rootSignatureFSQ; - ComPtr m_pipelineStateFSQPass; - ComPtr m_sapmlerFSQ; - - const float m_clearColor[4] = {0.0f, 0.0f, 0.0f, 0.0f}; - - // App resources. - ComPtr m_vertexBuffer; - D3D12_VERTEX_BUFFER_VIEW m_vertexBufferView; - ComPtr m_constantBuffer; - SceneConstantBuffer m_constantBufferData; - UINT8* m_pCbvDataBegin; - - // Synchronization objects. - UINT m_frameIndex; - HANDLE m_fenceEvent; - ComPtr m_fence; - UINT64 m_fenceValue; - - bool m_pause = false; - - // Jitter - std::vector> m_haltonPointSet; - std::size_t m_haltonIndex = 0; - float jitter[2]; - - // XeSS - xess_context_handle_t m_xessContext = nullptr; - xess_2d_t m_desiredOutputResolution; - xess_2d_t m_renderResolution; - ComPtr m_texturesHeap; - ComPtr m_xessOutput[FrameCount]; - const xess_quality_settings_t m_quality = XESS_QUALITY_SETTING_PERFORMANCE; - - std::chrono::time_point last_time; - - void LoadPipeline(); - void LoadAssets(); - void PopulateCommandList(); - void WaitForPreviousFrame(); -}; diff --git a/xess/samples/basic_sample/d3dx12.h b/xess/samples/basic_sample/d3dx12.h deleted file mode 100644 index 3959e94..0000000 --- a/xess/samples/basic_sample/d3dx12.h +++ /dev/null @@ -1,3905 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -#ifndef __D3DX12_H__ -#define __D3DX12_H__ - -#include "d3d12.h" - -#if defined( __cplusplus ) - -struct CD3DX12_DEFAULT {}; -extern const DECLSPEC_SELECTANY CD3DX12_DEFAULT D3D12_DEFAULT; - -//------------------------------------------------------------------------------------------------ -inline bool operator==( const D3D12_VIEWPORT& l, const D3D12_VIEWPORT& r ) noexcept -{ - return l.TopLeftX == r.TopLeftX && l.TopLeftY == r.TopLeftY && l.Width == r.Width && - l.Height == r.Height && l.MinDepth == r.MinDepth && l.MaxDepth == r.MaxDepth; -} - -//------------------------------------------------------------------------------------------------ -inline bool operator!=( const D3D12_VIEWPORT& l, const D3D12_VIEWPORT& r ) noexcept -{ return !( l == r ); } - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_RECT : public D3D12_RECT -{ - CD3DX12_RECT() = default; - explicit CD3DX12_RECT( const D3D12_RECT& o ) noexcept : - D3D12_RECT( o ) - {} - explicit CD3DX12_RECT( - LONG Left, - LONG Top, - LONG Right, - LONG Bottom ) noexcept - { - left = Left; - top = Top; - right = Right; - bottom = Bottom; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_VIEWPORT : public D3D12_VIEWPORT -{ - CD3DX12_VIEWPORT() = default; - explicit CD3DX12_VIEWPORT( const D3D12_VIEWPORT& o ) noexcept : - D3D12_VIEWPORT( o ) - {} - explicit CD3DX12_VIEWPORT( - FLOAT topLeftX, - FLOAT topLeftY, - FLOAT width, - FLOAT height, - FLOAT minDepth = D3D12_MIN_DEPTH, - FLOAT maxDepth = D3D12_MAX_DEPTH ) noexcept - { - TopLeftX = topLeftX; - TopLeftY = topLeftY; - Width = width; - Height = height; - MinDepth = minDepth; - MaxDepth = maxDepth; - } - explicit CD3DX12_VIEWPORT( - _In_ ID3D12Resource* pResource, - UINT mipSlice = 0, - FLOAT topLeftX = 0.0f, - FLOAT topLeftY = 0.0f, - FLOAT minDepth = D3D12_MIN_DEPTH, - FLOAT maxDepth = D3D12_MAX_DEPTH ) noexcept - { - auto Desc = pResource->GetDesc(); - const UINT64 SubresourceWidth = Desc.Width >> mipSlice; - const UINT64 SubresourceHeight = Desc.Height >> mipSlice; - switch (Desc.Dimension) - { - case D3D12_RESOURCE_DIMENSION_BUFFER: - TopLeftX = topLeftX; - TopLeftY = 0.0f; - Width = float(Desc.Width) - topLeftX; - Height = 1.0f; - break; - case D3D12_RESOURCE_DIMENSION_TEXTURE1D: - TopLeftX = topLeftX; - TopLeftY = 0.0f; - Width = (SubresourceWidth ? float(SubresourceWidth) : 1.0f) - topLeftX; - Height = 1.0f; - break; - case D3D12_RESOURCE_DIMENSION_TEXTURE2D: - case D3D12_RESOURCE_DIMENSION_TEXTURE3D: - TopLeftX = topLeftX; - TopLeftY = topLeftY; - Width = (SubresourceWidth ? float(SubresourceWidth) : 1.0f) - topLeftX; - Height = (SubresourceHeight ? float(SubresourceHeight) : 1.0f) - topLeftY; - break; - default: break; - } - - MinDepth = minDepth; - MaxDepth = maxDepth; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_BOX : public D3D12_BOX -{ - CD3DX12_BOX() = default; - explicit CD3DX12_BOX( const D3D12_BOX& o ) noexcept : - D3D12_BOX( o ) - {} - explicit CD3DX12_BOX( - LONG Left, - LONG Right ) noexcept - { - left = static_cast(Left); - top = 0; - front = 0; - right = static_cast(Right); - bottom = 1; - back = 1; - } - explicit CD3DX12_BOX( - LONG Left, - LONG Top, - LONG Right, - LONG Bottom ) noexcept - { - left = static_cast(Left); - top = static_cast(Top); - front = 0; - right = static_cast(Right); - bottom = static_cast(Bottom); - back = 1; - } - explicit CD3DX12_BOX( - LONG Left, - LONG Top, - LONG Front, - LONG Right, - LONG Bottom, - LONG Back ) noexcept - { - left = static_cast(Left); - top = static_cast(Top); - front = static_cast(Front); - right = static_cast(Right); - bottom = static_cast(Bottom); - back = static_cast(Back); - } -}; -inline bool operator==( const D3D12_BOX& l, const D3D12_BOX& r ) noexcept -{ - return l.left == r.left && l.top == r.top && l.front == r.front && - l.right == r.right && l.bottom == r.bottom && l.back == r.back; -} -inline bool operator!=( const D3D12_BOX& l, const D3D12_BOX& r ) noexcept -{ return !( l == r ); } - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_DEPTH_STENCIL_DESC : public D3D12_DEPTH_STENCIL_DESC -{ - CD3DX12_DEPTH_STENCIL_DESC() = default; - explicit CD3DX12_DEPTH_STENCIL_DESC( const D3D12_DEPTH_STENCIL_DESC& o ) noexcept : - D3D12_DEPTH_STENCIL_DESC( o ) - {} - explicit CD3DX12_DEPTH_STENCIL_DESC( CD3DX12_DEFAULT ) noexcept - { - DepthEnable = TRUE; - DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ALL; - DepthFunc = D3D12_COMPARISON_FUNC_LESS; - StencilEnable = FALSE; - StencilReadMask = D3D12_DEFAULT_STENCIL_READ_MASK; - StencilWriteMask = D3D12_DEFAULT_STENCIL_WRITE_MASK; - const D3D12_DEPTH_STENCILOP_DESC defaultStencilOp = - { D3D12_STENCIL_OP_KEEP, D3D12_STENCIL_OP_KEEP, D3D12_STENCIL_OP_KEEP, D3D12_COMPARISON_FUNC_ALWAYS }; - FrontFace = defaultStencilOp; - BackFace = defaultStencilOp; - } - explicit CD3DX12_DEPTH_STENCIL_DESC( - BOOL depthEnable, - D3D12_DEPTH_WRITE_MASK depthWriteMask, - D3D12_COMPARISON_FUNC depthFunc, - BOOL stencilEnable, - UINT8 stencilReadMask, - UINT8 stencilWriteMask, - D3D12_STENCIL_OP frontStencilFailOp, - D3D12_STENCIL_OP frontStencilDepthFailOp, - D3D12_STENCIL_OP frontStencilPassOp, - D3D12_COMPARISON_FUNC frontStencilFunc, - D3D12_STENCIL_OP backStencilFailOp, - D3D12_STENCIL_OP backStencilDepthFailOp, - D3D12_STENCIL_OP backStencilPassOp, - D3D12_COMPARISON_FUNC backStencilFunc ) noexcept - { - DepthEnable = depthEnable; - DepthWriteMask = depthWriteMask; - DepthFunc = depthFunc; - StencilEnable = stencilEnable; - StencilReadMask = stencilReadMask; - StencilWriteMask = stencilWriteMask; - FrontFace.StencilFailOp = frontStencilFailOp; - FrontFace.StencilDepthFailOp = frontStencilDepthFailOp; - FrontFace.StencilPassOp = frontStencilPassOp; - FrontFace.StencilFunc = frontStencilFunc; - BackFace.StencilFailOp = backStencilFailOp; - BackFace.StencilDepthFailOp = backStencilDepthFailOp; - BackFace.StencilPassOp = backStencilPassOp; - BackFace.StencilFunc = backStencilFunc; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_DEPTH_STENCIL_DESC1 : public D3D12_DEPTH_STENCIL_DESC1 -{ - CD3DX12_DEPTH_STENCIL_DESC1() = default; - explicit CD3DX12_DEPTH_STENCIL_DESC1( const D3D12_DEPTH_STENCIL_DESC1& o ) noexcept : - D3D12_DEPTH_STENCIL_DESC1( o ) - {} - explicit CD3DX12_DEPTH_STENCIL_DESC1( const D3D12_DEPTH_STENCIL_DESC& o ) noexcept - { - DepthEnable = o.DepthEnable; - DepthWriteMask = o.DepthWriteMask; - DepthFunc = o.DepthFunc; - StencilEnable = o.StencilEnable; - StencilReadMask = o.StencilReadMask; - StencilWriteMask = o.StencilWriteMask; - FrontFace.StencilFailOp = o.FrontFace.StencilFailOp; - FrontFace.StencilDepthFailOp = o.FrontFace.StencilDepthFailOp; - FrontFace.StencilPassOp = o.FrontFace.StencilPassOp; - FrontFace.StencilFunc = o.FrontFace.StencilFunc; - BackFace.StencilFailOp = o.BackFace.StencilFailOp; - BackFace.StencilDepthFailOp = o.BackFace.StencilDepthFailOp; - BackFace.StencilPassOp = o.BackFace.StencilPassOp; - BackFace.StencilFunc = o.BackFace.StencilFunc; - DepthBoundsTestEnable = FALSE; - } - explicit CD3DX12_DEPTH_STENCIL_DESC1( CD3DX12_DEFAULT ) noexcept - { - DepthEnable = TRUE; - DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ALL; - DepthFunc = D3D12_COMPARISON_FUNC_LESS; - StencilEnable = FALSE; - StencilReadMask = D3D12_DEFAULT_STENCIL_READ_MASK; - StencilWriteMask = D3D12_DEFAULT_STENCIL_WRITE_MASK; - const D3D12_DEPTH_STENCILOP_DESC defaultStencilOp = - { D3D12_STENCIL_OP_KEEP, D3D12_STENCIL_OP_KEEP, D3D12_STENCIL_OP_KEEP, D3D12_COMPARISON_FUNC_ALWAYS }; - FrontFace = defaultStencilOp; - BackFace = defaultStencilOp; - DepthBoundsTestEnable = FALSE; - } - explicit CD3DX12_DEPTH_STENCIL_DESC1( - BOOL depthEnable, - D3D12_DEPTH_WRITE_MASK depthWriteMask, - D3D12_COMPARISON_FUNC depthFunc, - BOOL stencilEnable, - UINT8 stencilReadMask, - UINT8 stencilWriteMask, - D3D12_STENCIL_OP frontStencilFailOp, - D3D12_STENCIL_OP frontStencilDepthFailOp, - D3D12_STENCIL_OP frontStencilPassOp, - D3D12_COMPARISON_FUNC frontStencilFunc, - D3D12_STENCIL_OP backStencilFailOp, - D3D12_STENCIL_OP backStencilDepthFailOp, - D3D12_STENCIL_OP backStencilPassOp, - D3D12_COMPARISON_FUNC backStencilFunc, - BOOL depthBoundsTestEnable ) noexcept - { - DepthEnable = depthEnable; - DepthWriteMask = depthWriteMask; - DepthFunc = depthFunc; - StencilEnable = stencilEnable; - StencilReadMask = stencilReadMask; - StencilWriteMask = stencilWriteMask; - FrontFace.StencilFailOp = frontStencilFailOp; - FrontFace.StencilDepthFailOp = frontStencilDepthFailOp; - FrontFace.StencilPassOp = frontStencilPassOp; - FrontFace.StencilFunc = frontStencilFunc; - BackFace.StencilFailOp = backStencilFailOp; - BackFace.StencilDepthFailOp = backStencilDepthFailOp; - BackFace.StencilPassOp = backStencilPassOp; - BackFace.StencilFunc = backStencilFunc; - DepthBoundsTestEnable = depthBoundsTestEnable; - } - operator D3D12_DEPTH_STENCIL_DESC() const noexcept - { - D3D12_DEPTH_STENCIL_DESC D; - D.DepthEnable = DepthEnable; - D.DepthWriteMask = DepthWriteMask; - D.DepthFunc = DepthFunc; - D.StencilEnable = StencilEnable; - D.StencilReadMask = StencilReadMask; - D.StencilWriteMask = StencilWriteMask; - D.FrontFace.StencilFailOp = FrontFace.StencilFailOp; - D.FrontFace.StencilDepthFailOp = FrontFace.StencilDepthFailOp; - D.FrontFace.StencilPassOp = FrontFace.StencilPassOp; - D.FrontFace.StencilFunc = FrontFace.StencilFunc; - D.BackFace.StencilFailOp = BackFace.StencilFailOp; - D.BackFace.StencilDepthFailOp = BackFace.StencilDepthFailOp; - D.BackFace.StencilPassOp = BackFace.StencilPassOp; - D.BackFace.StencilFunc = BackFace.StencilFunc; - return D; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_BLEND_DESC : public D3D12_BLEND_DESC -{ - CD3DX12_BLEND_DESC() = default; - explicit CD3DX12_BLEND_DESC( const D3D12_BLEND_DESC& o ) noexcept : - D3D12_BLEND_DESC( o ) - {} - explicit CD3DX12_BLEND_DESC( CD3DX12_DEFAULT ) noexcept - { - AlphaToCoverageEnable = FALSE; - IndependentBlendEnable = FALSE; - const D3D12_RENDER_TARGET_BLEND_DESC defaultRenderTargetBlendDesc = - { - FALSE,FALSE, - D3D12_BLEND_ONE, D3D12_BLEND_ZERO, D3D12_BLEND_OP_ADD, - D3D12_BLEND_ONE, D3D12_BLEND_ZERO, D3D12_BLEND_OP_ADD, - D3D12_LOGIC_OP_NOOP, - D3D12_COLOR_WRITE_ENABLE_ALL, - }; - for (UINT i = 0; i < D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i) - RenderTarget[ i ] = defaultRenderTargetBlendDesc; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_RASTERIZER_DESC : public D3D12_RASTERIZER_DESC -{ - CD3DX12_RASTERIZER_DESC() = default; - explicit CD3DX12_RASTERIZER_DESC( const D3D12_RASTERIZER_DESC& o ) noexcept : - D3D12_RASTERIZER_DESC( o ) - {} - explicit CD3DX12_RASTERIZER_DESC( CD3DX12_DEFAULT ) noexcept - { - FillMode = D3D12_FILL_MODE_SOLID; - CullMode = D3D12_CULL_MODE_BACK; - FrontCounterClockwise = FALSE; - DepthBias = D3D12_DEFAULT_DEPTH_BIAS; - DepthBiasClamp = D3D12_DEFAULT_DEPTH_BIAS_CLAMP; - SlopeScaledDepthBias = D3D12_DEFAULT_SLOPE_SCALED_DEPTH_BIAS; - DepthClipEnable = TRUE; - MultisampleEnable = FALSE; - AntialiasedLineEnable = FALSE; - ForcedSampleCount = 0; - ConservativeRaster = D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF; - } - explicit CD3DX12_RASTERIZER_DESC( - D3D12_FILL_MODE fillMode, - D3D12_CULL_MODE cullMode, - BOOL frontCounterClockwise, - INT depthBias, - FLOAT depthBiasClamp, - FLOAT slopeScaledDepthBias, - BOOL depthClipEnable, - BOOL multisampleEnable, - BOOL antialiasedLineEnable, - UINT forcedSampleCount, - D3D12_CONSERVATIVE_RASTERIZATION_MODE conservativeRaster) noexcept - { - FillMode = fillMode; - CullMode = cullMode; - FrontCounterClockwise = frontCounterClockwise; - DepthBias = depthBias; - DepthBiasClamp = depthBiasClamp; - SlopeScaledDepthBias = slopeScaledDepthBias; - DepthClipEnable = depthClipEnable; - MultisampleEnable = multisampleEnable; - AntialiasedLineEnable = antialiasedLineEnable; - ForcedSampleCount = forcedSampleCount; - ConservativeRaster = conservativeRaster; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_RESOURCE_ALLOCATION_INFO : public D3D12_RESOURCE_ALLOCATION_INFO -{ - CD3DX12_RESOURCE_ALLOCATION_INFO() = default; - explicit CD3DX12_RESOURCE_ALLOCATION_INFO( const D3D12_RESOURCE_ALLOCATION_INFO& o ) noexcept : - D3D12_RESOURCE_ALLOCATION_INFO( o ) - {} - CD3DX12_RESOURCE_ALLOCATION_INFO( - UINT64 size, - UINT64 alignment ) noexcept - { - SizeInBytes = size; - Alignment = alignment; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_HEAP_PROPERTIES : public D3D12_HEAP_PROPERTIES -{ - CD3DX12_HEAP_PROPERTIES() = default; - explicit CD3DX12_HEAP_PROPERTIES(const D3D12_HEAP_PROPERTIES &o) noexcept : - D3D12_HEAP_PROPERTIES(o) - {} - CD3DX12_HEAP_PROPERTIES( - D3D12_CPU_PAGE_PROPERTY cpuPageProperty, - D3D12_MEMORY_POOL memoryPoolPreference, - UINT creationNodeMask = 1, - UINT nodeMask = 1 ) noexcept - { - Type = D3D12_HEAP_TYPE_CUSTOM; - CPUPageProperty = cpuPageProperty; - MemoryPoolPreference = memoryPoolPreference; - CreationNodeMask = creationNodeMask; - VisibleNodeMask = nodeMask; - } - explicit CD3DX12_HEAP_PROPERTIES( - D3D12_HEAP_TYPE type, - UINT creationNodeMask = 1, - UINT nodeMask = 1 ) noexcept - { - Type = type; - CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; - MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; - CreationNodeMask = creationNodeMask; - VisibleNodeMask = nodeMask; - } - bool IsCPUAccessible() const noexcept - { - return Type == D3D12_HEAP_TYPE_UPLOAD || Type == D3D12_HEAP_TYPE_READBACK || (Type == D3D12_HEAP_TYPE_CUSTOM && - (CPUPageProperty == D3D12_CPU_PAGE_PROPERTY_WRITE_COMBINE || CPUPageProperty == D3D12_CPU_PAGE_PROPERTY_WRITE_BACK)); - } -}; -inline bool operator==( const D3D12_HEAP_PROPERTIES& l, const D3D12_HEAP_PROPERTIES& r ) noexcept -{ - return l.Type == r.Type && l.CPUPageProperty == r.CPUPageProperty && - l.MemoryPoolPreference == r.MemoryPoolPreference && - l.CreationNodeMask == r.CreationNodeMask && - l.VisibleNodeMask == r.VisibleNodeMask; -} -inline bool operator!=( const D3D12_HEAP_PROPERTIES& l, const D3D12_HEAP_PROPERTIES& r ) noexcept -{ return !( l == r ); } - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_HEAP_DESC : public D3D12_HEAP_DESC -{ - CD3DX12_HEAP_DESC() = default; - explicit CD3DX12_HEAP_DESC(const D3D12_HEAP_DESC &o) noexcept : - D3D12_HEAP_DESC(o) - {} - CD3DX12_HEAP_DESC( - UINT64 size, - D3D12_HEAP_PROPERTIES properties, - UINT64 alignment = 0, - D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE ) noexcept - { - SizeInBytes = size; - Properties = properties; - Alignment = alignment; - Flags = flags; - } - CD3DX12_HEAP_DESC( - UINT64 size, - D3D12_HEAP_TYPE type, - UINT64 alignment = 0, - D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE ) noexcept - { - SizeInBytes = size; - Properties = CD3DX12_HEAP_PROPERTIES( type ); - Alignment = alignment; - Flags = flags; - } - CD3DX12_HEAP_DESC( - UINT64 size, - D3D12_CPU_PAGE_PROPERTY cpuPageProperty, - D3D12_MEMORY_POOL memoryPoolPreference, - UINT64 alignment = 0, - D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE ) noexcept - { - SizeInBytes = size; - Properties = CD3DX12_HEAP_PROPERTIES( cpuPageProperty, memoryPoolPreference ); - Alignment = alignment; - Flags = flags; - } - CD3DX12_HEAP_DESC( - const D3D12_RESOURCE_ALLOCATION_INFO& resAllocInfo, - D3D12_HEAP_PROPERTIES properties, - D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE ) noexcept - { - SizeInBytes = resAllocInfo.SizeInBytes; - Properties = properties; - Alignment = resAllocInfo.Alignment; - Flags = flags; - } - CD3DX12_HEAP_DESC( - const D3D12_RESOURCE_ALLOCATION_INFO& resAllocInfo, - D3D12_HEAP_TYPE type, - D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE ) noexcept - { - SizeInBytes = resAllocInfo.SizeInBytes; - Properties = CD3DX12_HEAP_PROPERTIES( type ); - Alignment = resAllocInfo.Alignment; - Flags = flags; - } - CD3DX12_HEAP_DESC( - const D3D12_RESOURCE_ALLOCATION_INFO& resAllocInfo, - D3D12_CPU_PAGE_PROPERTY cpuPageProperty, - D3D12_MEMORY_POOL memoryPoolPreference, - D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE ) noexcept - { - SizeInBytes = resAllocInfo.SizeInBytes; - Properties = CD3DX12_HEAP_PROPERTIES( cpuPageProperty, memoryPoolPreference ); - Alignment = resAllocInfo.Alignment; - Flags = flags; - } - bool IsCPUAccessible() const noexcept - { return static_cast< const CD3DX12_HEAP_PROPERTIES* >( &Properties )->IsCPUAccessible(); } -}; -inline bool operator==( const D3D12_HEAP_DESC& l, const D3D12_HEAP_DESC& r ) noexcept -{ - return l.SizeInBytes == r.SizeInBytes && - l.Properties == r.Properties && - l.Alignment == r.Alignment && - l.Flags == r.Flags; -} -inline bool operator!=( const D3D12_HEAP_DESC& l, const D3D12_HEAP_DESC& r ) noexcept -{ return !( l == r ); } - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_CLEAR_VALUE : public D3D12_CLEAR_VALUE -{ - CD3DX12_CLEAR_VALUE() = default; - explicit CD3DX12_CLEAR_VALUE(const D3D12_CLEAR_VALUE &o) noexcept : - D3D12_CLEAR_VALUE(o) - {} - CD3DX12_CLEAR_VALUE( - DXGI_FORMAT format, - const FLOAT color[4] ) noexcept - { - Format = format; - memcpy( Color, color, sizeof( Color ) ); - } - CD3DX12_CLEAR_VALUE( - DXGI_FORMAT format, - FLOAT depth, - UINT8 stencil ) noexcept - { - Format = format; - memset( &Color, 0, sizeof( Color ) ); - /* Use memcpy to preserve NAN values */ - memcpy( &DepthStencil.Depth, &depth, sizeof( depth ) ); - DepthStencil.Stencil = stencil; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_RANGE : public D3D12_RANGE -{ - CD3DX12_RANGE() = default; - explicit CD3DX12_RANGE(const D3D12_RANGE &o) noexcept : - D3D12_RANGE(o) - {} - CD3DX12_RANGE( - SIZE_T begin, - SIZE_T end ) noexcept - { - Begin = begin; - End = end; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_RANGE_UINT64 : public D3D12_RANGE_UINT64 -{ - CD3DX12_RANGE_UINT64() = default; - explicit CD3DX12_RANGE_UINT64(const D3D12_RANGE_UINT64 &o) noexcept : - D3D12_RANGE_UINT64(o) - {} - CD3DX12_RANGE_UINT64( - UINT64 begin, - UINT64 end ) noexcept - { - Begin = begin; - End = end; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_SUBRESOURCE_RANGE_UINT64 : public D3D12_SUBRESOURCE_RANGE_UINT64 -{ - CD3DX12_SUBRESOURCE_RANGE_UINT64() = default; - explicit CD3DX12_SUBRESOURCE_RANGE_UINT64(const D3D12_SUBRESOURCE_RANGE_UINT64 &o) noexcept : - D3D12_SUBRESOURCE_RANGE_UINT64(o) - {} - CD3DX12_SUBRESOURCE_RANGE_UINT64( - UINT subresource, - const D3D12_RANGE_UINT64& range ) noexcept - { - Subresource = subresource; - Range = range; - } - CD3DX12_SUBRESOURCE_RANGE_UINT64( - UINT subresource, - UINT64 begin, - UINT64 end ) noexcept - { - Subresource = subresource; - Range.Begin = begin; - Range.End = end; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_SHADER_BYTECODE : public D3D12_SHADER_BYTECODE -{ - CD3DX12_SHADER_BYTECODE() = default; - explicit CD3DX12_SHADER_BYTECODE(const D3D12_SHADER_BYTECODE &o) noexcept : - D3D12_SHADER_BYTECODE(o) - {} - CD3DX12_SHADER_BYTECODE( - _In_ ID3DBlob* pShaderBlob ) noexcept - { - pShaderBytecode = pShaderBlob->GetBufferPointer(); - BytecodeLength = pShaderBlob->GetBufferSize(); - } - CD3DX12_SHADER_BYTECODE( - const void* _pShaderBytecode, - SIZE_T bytecodeLength ) noexcept - { - pShaderBytecode = _pShaderBytecode; - BytecodeLength = bytecodeLength; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_TILED_RESOURCE_COORDINATE : public D3D12_TILED_RESOURCE_COORDINATE -{ - CD3DX12_TILED_RESOURCE_COORDINATE() = default; - explicit CD3DX12_TILED_RESOURCE_COORDINATE(const D3D12_TILED_RESOURCE_COORDINATE &o) noexcept : - D3D12_TILED_RESOURCE_COORDINATE(o) - {} - CD3DX12_TILED_RESOURCE_COORDINATE( - UINT x, - UINT y, - UINT z, - UINT subresource ) noexcept - { - X = x; - Y = y; - Z = z; - Subresource = subresource; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_TILE_REGION_SIZE : public D3D12_TILE_REGION_SIZE -{ - CD3DX12_TILE_REGION_SIZE() = default; - explicit CD3DX12_TILE_REGION_SIZE(const D3D12_TILE_REGION_SIZE &o) noexcept : - D3D12_TILE_REGION_SIZE(o) - {} - CD3DX12_TILE_REGION_SIZE( - UINT numTiles, - BOOL useBox, - UINT width, - UINT16 height, - UINT16 depth ) noexcept - { - NumTiles = numTiles; - UseBox = useBox; - Width = width; - Height = height; - Depth = depth; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_SUBRESOURCE_TILING : public D3D12_SUBRESOURCE_TILING -{ - CD3DX12_SUBRESOURCE_TILING() = default; - explicit CD3DX12_SUBRESOURCE_TILING(const D3D12_SUBRESOURCE_TILING &o) noexcept : - D3D12_SUBRESOURCE_TILING(o) - {} - CD3DX12_SUBRESOURCE_TILING( - UINT widthInTiles, - UINT16 heightInTiles, - UINT16 depthInTiles, - UINT startTileIndexInOverallResource ) noexcept - { - WidthInTiles = widthInTiles; - HeightInTiles = heightInTiles; - DepthInTiles = depthInTiles; - StartTileIndexInOverallResource = startTileIndexInOverallResource; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_TILE_SHAPE : public D3D12_TILE_SHAPE -{ - CD3DX12_TILE_SHAPE() = default; - explicit CD3DX12_TILE_SHAPE(const D3D12_TILE_SHAPE &o) noexcept : - D3D12_TILE_SHAPE(o) - {} - CD3DX12_TILE_SHAPE( - UINT widthInTexels, - UINT heightInTexels, - UINT depthInTexels ) noexcept - { - WidthInTexels = widthInTexels; - HeightInTexels = heightInTexels; - DepthInTexels = depthInTexels; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_RESOURCE_BARRIER : public D3D12_RESOURCE_BARRIER -{ - CD3DX12_RESOURCE_BARRIER() = default; - explicit CD3DX12_RESOURCE_BARRIER(const D3D12_RESOURCE_BARRIER &o) noexcept : - D3D12_RESOURCE_BARRIER(o) - {} - static inline CD3DX12_RESOURCE_BARRIER Transition( - _In_ ID3D12Resource* pResource, - D3D12_RESOURCE_STATES stateBefore, - D3D12_RESOURCE_STATES stateAfter, - UINT subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES, - D3D12_RESOURCE_BARRIER_FLAGS flags = D3D12_RESOURCE_BARRIER_FLAG_NONE) noexcept - { - CD3DX12_RESOURCE_BARRIER result = {}; - D3D12_RESOURCE_BARRIER &barrier = result; - result.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; - result.Flags = flags; - barrier.Transition.pResource = pResource; - barrier.Transition.StateBefore = stateBefore; - barrier.Transition.StateAfter = stateAfter; - barrier.Transition.Subresource = subresource; - return result; - } - static inline CD3DX12_RESOURCE_BARRIER Aliasing( - _In_ ID3D12Resource* pResourceBefore, - _In_ ID3D12Resource* pResourceAfter) noexcept - { - CD3DX12_RESOURCE_BARRIER result = {}; - D3D12_RESOURCE_BARRIER &barrier = result; - result.Type = D3D12_RESOURCE_BARRIER_TYPE_ALIASING; - barrier.Aliasing.pResourceBefore = pResourceBefore; - barrier.Aliasing.pResourceAfter = pResourceAfter; - return result; - } - static inline CD3DX12_RESOURCE_BARRIER UAV( - _In_ ID3D12Resource* pResource) noexcept - { - CD3DX12_RESOURCE_BARRIER result = {}; - D3D12_RESOURCE_BARRIER &barrier = result; - result.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV; - barrier.UAV.pResource = pResource; - return result; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_PACKED_MIP_INFO : public D3D12_PACKED_MIP_INFO -{ - CD3DX12_PACKED_MIP_INFO() = default; - explicit CD3DX12_PACKED_MIP_INFO(const D3D12_PACKED_MIP_INFO &o) noexcept : - D3D12_PACKED_MIP_INFO(o) - {} - CD3DX12_PACKED_MIP_INFO( - UINT8 numStandardMips, - UINT8 numPackedMips, - UINT numTilesForPackedMips, - UINT startTileIndexInOverallResource ) noexcept - { - NumStandardMips = numStandardMips; - NumPackedMips = numPackedMips; - NumTilesForPackedMips = numTilesForPackedMips; - StartTileIndexInOverallResource = startTileIndexInOverallResource; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_SUBRESOURCE_FOOTPRINT : public D3D12_SUBRESOURCE_FOOTPRINT -{ - CD3DX12_SUBRESOURCE_FOOTPRINT() = default; - explicit CD3DX12_SUBRESOURCE_FOOTPRINT(const D3D12_SUBRESOURCE_FOOTPRINT &o) noexcept : - D3D12_SUBRESOURCE_FOOTPRINT(o) - {} - CD3DX12_SUBRESOURCE_FOOTPRINT( - DXGI_FORMAT format, - UINT width, - UINT height, - UINT depth, - UINT rowPitch ) noexcept - { - Format = format; - Width = width; - Height = height; - Depth = depth; - RowPitch = rowPitch; - } - explicit CD3DX12_SUBRESOURCE_FOOTPRINT( - const D3D12_RESOURCE_DESC& resDesc, - UINT rowPitch ) noexcept - { - Format = resDesc.Format; - Width = UINT( resDesc.Width ); - Height = resDesc.Height; - Depth = (resDesc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D ? resDesc.DepthOrArraySize : 1); - RowPitch = rowPitch; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_TEXTURE_COPY_LOCATION : public D3D12_TEXTURE_COPY_LOCATION -{ - CD3DX12_TEXTURE_COPY_LOCATION() = default; - explicit CD3DX12_TEXTURE_COPY_LOCATION(const D3D12_TEXTURE_COPY_LOCATION &o) noexcept : - D3D12_TEXTURE_COPY_LOCATION(o) - {} - CD3DX12_TEXTURE_COPY_LOCATION(_In_ ID3D12Resource* pRes) noexcept - { - pResource = pRes; - Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX; - PlacedFootprint = {}; - } - CD3DX12_TEXTURE_COPY_LOCATION(_In_ ID3D12Resource* pRes, D3D12_PLACED_SUBRESOURCE_FOOTPRINT const& Footprint) noexcept - { - pResource = pRes; - Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT; - PlacedFootprint = Footprint; - } - CD3DX12_TEXTURE_COPY_LOCATION(_In_ ID3D12Resource* pRes, UINT Sub) noexcept - { - pResource = pRes; - Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX; - PlacedFootprint = {}; - SubresourceIndex = Sub; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_DESCRIPTOR_RANGE : public D3D12_DESCRIPTOR_RANGE -{ - CD3DX12_DESCRIPTOR_RANGE() = default; - explicit CD3DX12_DESCRIPTOR_RANGE(const D3D12_DESCRIPTOR_RANGE &o) noexcept : - D3D12_DESCRIPTOR_RANGE(o) - {} - CD3DX12_DESCRIPTOR_RANGE( - D3D12_DESCRIPTOR_RANGE_TYPE rangeType, - UINT numDescriptors, - UINT baseShaderRegister, - UINT registerSpace = 0, - UINT offsetInDescriptorsFromTableStart = - D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) noexcept - { - Init(rangeType, numDescriptors, baseShaderRegister, registerSpace, offsetInDescriptorsFromTableStart); - } - - inline void Init( - D3D12_DESCRIPTOR_RANGE_TYPE rangeType, - UINT numDescriptors, - UINT baseShaderRegister, - UINT registerSpace = 0, - UINT offsetInDescriptorsFromTableStart = - D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) noexcept - { - Init(*this, rangeType, numDescriptors, baseShaderRegister, registerSpace, offsetInDescriptorsFromTableStart); - } - - static inline void Init( - _Out_ D3D12_DESCRIPTOR_RANGE &range, - D3D12_DESCRIPTOR_RANGE_TYPE rangeType, - UINT numDescriptors, - UINT baseShaderRegister, - UINT registerSpace = 0, - UINT offsetInDescriptorsFromTableStart = - D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) noexcept - { - range.RangeType = rangeType; - range.NumDescriptors = numDescriptors; - range.BaseShaderRegister = baseShaderRegister; - range.RegisterSpace = registerSpace; - range.OffsetInDescriptorsFromTableStart = offsetInDescriptorsFromTableStart; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_ROOT_DESCRIPTOR_TABLE : public D3D12_ROOT_DESCRIPTOR_TABLE -{ - CD3DX12_ROOT_DESCRIPTOR_TABLE() = default; - explicit CD3DX12_ROOT_DESCRIPTOR_TABLE(const D3D12_ROOT_DESCRIPTOR_TABLE &o) noexcept : - D3D12_ROOT_DESCRIPTOR_TABLE(o) - {} - CD3DX12_ROOT_DESCRIPTOR_TABLE( - UINT numDescriptorRanges, - _In_reads_opt_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE* _pDescriptorRanges) noexcept - { - Init(numDescriptorRanges, _pDescriptorRanges); - } - - inline void Init( - UINT numDescriptorRanges, - _In_reads_opt_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE* _pDescriptorRanges) noexcept - { - Init(*this, numDescriptorRanges, _pDescriptorRanges); - } - - static inline void Init( - _Out_ D3D12_ROOT_DESCRIPTOR_TABLE &rootDescriptorTable, - UINT numDescriptorRanges, - _In_reads_opt_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE* _pDescriptorRanges) noexcept - { - rootDescriptorTable.NumDescriptorRanges = numDescriptorRanges; - rootDescriptorTable.pDescriptorRanges = _pDescriptorRanges; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_ROOT_CONSTANTS : public D3D12_ROOT_CONSTANTS -{ - CD3DX12_ROOT_CONSTANTS() = default; - explicit CD3DX12_ROOT_CONSTANTS(const D3D12_ROOT_CONSTANTS &o) noexcept : - D3D12_ROOT_CONSTANTS(o) - {} - CD3DX12_ROOT_CONSTANTS( - UINT num32BitValues, - UINT shaderRegister, - UINT registerSpace = 0) noexcept - { - Init(num32BitValues, shaderRegister, registerSpace); - } - - inline void Init( - UINT num32BitValues, - UINT shaderRegister, - UINT registerSpace = 0) noexcept - { - Init(*this, num32BitValues, shaderRegister, registerSpace); - } - - static inline void Init( - _Out_ D3D12_ROOT_CONSTANTS &rootConstants, - UINT num32BitValues, - UINT shaderRegister, - UINT registerSpace = 0) noexcept - { - rootConstants.Num32BitValues = num32BitValues; - rootConstants.ShaderRegister = shaderRegister; - rootConstants.RegisterSpace = registerSpace; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_ROOT_DESCRIPTOR : public D3D12_ROOT_DESCRIPTOR -{ - CD3DX12_ROOT_DESCRIPTOR() = default; - explicit CD3DX12_ROOT_DESCRIPTOR(const D3D12_ROOT_DESCRIPTOR &o) noexcept : - D3D12_ROOT_DESCRIPTOR(o) - {} - CD3DX12_ROOT_DESCRIPTOR( - UINT shaderRegister, - UINT registerSpace = 0) noexcept - { - Init(shaderRegister, registerSpace); - } - - inline void Init( - UINT shaderRegister, - UINT registerSpace = 0) noexcept - { - Init(*this, shaderRegister, registerSpace); - } - - static inline void Init(_Out_ D3D12_ROOT_DESCRIPTOR &table, UINT shaderRegister, UINT registerSpace = 0) noexcept - { - table.ShaderRegister = shaderRegister; - table.RegisterSpace = registerSpace; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_ROOT_PARAMETER : public D3D12_ROOT_PARAMETER -{ - CD3DX12_ROOT_PARAMETER() = default; - explicit CD3DX12_ROOT_PARAMETER(const D3D12_ROOT_PARAMETER &o) noexcept : - D3D12_ROOT_PARAMETER(o) - {} - - static inline void InitAsDescriptorTable( - _Out_ D3D12_ROOT_PARAMETER &rootParam, - UINT numDescriptorRanges, - _In_reads_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE* pDescriptorRanges, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; - rootParam.ShaderVisibility = visibility; - CD3DX12_ROOT_DESCRIPTOR_TABLE::Init(rootParam.DescriptorTable, numDescriptorRanges, pDescriptorRanges); - } - - static inline void InitAsConstants( - _Out_ D3D12_ROOT_PARAMETER &rootParam, - UINT num32BitValues, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS; - rootParam.ShaderVisibility = visibility; - CD3DX12_ROOT_CONSTANTS::Init(rootParam.Constants, num32BitValues, shaderRegister, registerSpace); - } - - static inline void InitAsConstantBufferView( - _Out_ D3D12_ROOT_PARAMETER &rootParam, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; - rootParam.ShaderVisibility = visibility; - CD3DX12_ROOT_DESCRIPTOR::Init(rootParam.Descriptor, shaderRegister, registerSpace); - } - - static inline void InitAsShaderResourceView( - _Out_ D3D12_ROOT_PARAMETER &rootParam, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_SRV; - rootParam.ShaderVisibility = visibility; - CD3DX12_ROOT_DESCRIPTOR::Init(rootParam.Descriptor, shaderRegister, registerSpace); - } - - static inline void InitAsUnorderedAccessView( - _Out_ D3D12_ROOT_PARAMETER &rootParam, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_UAV; - rootParam.ShaderVisibility = visibility; - CD3DX12_ROOT_DESCRIPTOR::Init(rootParam.Descriptor, shaderRegister, registerSpace); - } - - inline void InitAsDescriptorTable( - UINT numDescriptorRanges, - _In_reads_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE* pDescriptorRanges, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - InitAsDescriptorTable(*this, numDescriptorRanges, pDescriptorRanges, visibility); - } - - inline void InitAsConstants( - UINT num32BitValues, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - InitAsConstants(*this, num32BitValues, shaderRegister, registerSpace, visibility); - } - - inline void InitAsConstantBufferView( - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - InitAsConstantBufferView(*this, shaderRegister, registerSpace, visibility); - } - - inline void InitAsShaderResourceView( - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - InitAsShaderResourceView(*this, shaderRegister, registerSpace, visibility); - } - - inline void InitAsUnorderedAccessView( - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - InitAsUnorderedAccessView(*this, shaderRegister, registerSpace, visibility); - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_STATIC_SAMPLER_DESC : public D3D12_STATIC_SAMPLER_DESC -{ - CD3DX12_STATIC_SAMPLER_DESC() = default; - explicit CD3DX12_STATIC_SAMPLER_DESC(const D3D12_STATIC_SAMPLER_DESC &o) noexcept : - D3D12_STATIC_SAMPLER_DESC(o) - {} - CD3DX12_STATIC_SAMPLER_DESC( - UINT shaderRegister, - D3D12_FILTER filter = D3D12_FILTER_ANISOTROPIC, - D3D12_TEXTURE_ADDRESS_MODE addressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP, - D3D12_TEXTURE_ADDRESS_MODE addressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP, - D3D12_TEXTURE_ADDRESS_MODE addressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP, - FLOAT mipLODBias = 0, - UINT maxAnisotropy = 16, - D3D12_COMPARISON_FUNC comparisonFunc = D3D12_COMPARISON_FUNC_LESS_EQUAL, - D3D12_STATIC_BORDER_COLOR borderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE, - FLOAT minLOD = 0.f, - FLOAT maxLOD = D3D12_FLOAT32_MAX, - D3D12_SHADER_VISIBILITY shaderVisibility = D3D12_SHADER_VISIBILITY_ALL, - UINT registerSpace = 0) noexcept - { - Init( - shaderRegister, - filter, - addressU, - addressV, - addressW, - mipLODBias, - maxAnisotropy, - comparisonFunc, - borderColor, - minLOD, - maxLOD, - shaderVisibility, - registerSpace); - } - - static inline void Init( - _Out_ D3D12_STATIC_SAMPLER_DESC &samplerDesc, - UINT shaderRegister, - D3D12_FILTER filter = D3D12_FILTER_ANISOTROPIC, - D3D12_TEXTURE_ADDRESS_MODE addressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP, - D3D12_TEXTURE_ADDRESS_MODE addressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP, - D3D12_TEXTURE_ADDRESS_MODE addressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP, - FLOAT mipLODBias = 0, - UINT maxAnisotropy = 16, - D3D12_COMPARISON_FUNC comparisonFunc = D3D12_COMPARISON_FUNC_LESS_EQUAL, - D3D12_STATIC_BORDER_COLOR borderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE, - FLOAT minLOD = 0.f, - FLOAT maxLOD = D3D12_FLOAT32_MAX, - D3D12_SHADER_VISIBILITY shaderVisibility = D3D12_SHADER_VISIBILITY_ALL, - UINT registerSpace = 0) noexcept - { - samplerDesc.ShaderRegister = shaderRegister; - samplerDesc.Filter = filter; - samplerDesc.AddressU = addressU; - samplerDesc.AddressV = addressV; - samplerDesc.AddressW = addressW; - samplerDesc.MipLODBias = mipLODBias; - samplerDesc.MaxAnisotropy = maxAnisotropy; - samplerDesc.ComparisonFunc = comparisonFunc; - samplerDesc.BorderColor = borderColor; - samplerDesc.MinLOD = minLOD; - samplerDesc.MaxLOD = maxLOD; - samplerDesc.ShaderVisibility = shaderVisibility; - samplerDesc.RegisterSpace = registerSpace; - } - inline void Init( - UINT shaderRegister, - D3D12_FILTER filter = D3D12_FILTER_ANISOTROPIC, - D3D12_TEXTURE_ADDRESS_MODE addressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP, - D3D12_TEXTURE_ADDRESS_MODE addressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP, - D3D12_TEXTURE_ADDRESS_MODE addressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP, - FLOAT mipLODBias = 0, - UINT maxAnisotropy = 16, - D3D12_COMPARISON_FUNC comparisonFunc = D3D12_COMPARISON_FUNC_LESS_EQUAL, - D3D12_STATIC_BORDER_COLOR borderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE, - FLOAT minLOD = 0.f, - FLOAT maxLOD = D3D12_FLOAT32_MAX, - D3D12_SHADER_VISIBILITY shaderVisibility = D3D12_SHADER_VISIBILITY_ALL, - UINT registerSpace = 0) noexcept - { - Init( - *this, - shaderRegister, - filter, - addressU, - addressV, - addressW, - mipLODBias, - maxAnisotropy, - comparisonFunc, - borderColor, - minLOD, - maxLOD, - shaderVisibility, - registerSpace); - } - -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_ROOT_SIGNATURE_DESC : public D3D12_ROOT_SIGNATURE_DESC -{ - CD3DX12_ROOT_SIGNATURE_DESC() = default; - explicit CD3DX12_ROOT_SIGNATURE_DESC(const D3D12_ROOT_SIGNATURE_DESC &o) noexcept : - D3D12_ROOT_SIGNATURE_DESC(o) - {} - CD3DX12_ROOT_SIGNATURE_DESC( - UINT numParameters, - _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters, - UINT numStaticSamplers = 0, - _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, - D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept - { - Init(numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags); - } - CD3DX12_ROOT_SIGNATURE_DESC(CD3DX12_DEFAULT) noexcept - { - Init(0, nullptr, 0, nullptr, D3D12_ROOT_SIGNATURE_FLAG_NONE); - } - - inline void Init( - UINT numParameters, - _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters, - UINT numStaticSamplers = 0, - _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, - D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept - { - Init(*this, numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags); - } - - static inline void Init( - _Out_ D3D12_ROOT_SIGNATURE_DESC &desc, - UINT numParameters, - _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters, - UINT numStaticSamplers = 0, - _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, - D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept - { - desc.NumParameters = numParameters; - desc.pParameters = _pParameters; - desc.NumStaticSamplers = numStaticSamplers; - desc.pStaticSamplers = _pStaticSamplers; - desc.Flags = flags; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_DESCRIPTOR_RANGE1 : public D3D12_DESCRIPTOR_RANGE1 -{ - CD3DX12_DESCRIPTOR_RANGE1() = default; - explicit CD3DX12_DESCRIPTOR_RANGE1(const D3D12_DESCRIPTOR_RANGE1 &o) noexcept : - D3D12_DESCRIPTOR_RANGE1(o) - {} - CD3DX12_DESCRIPTOR_RANGE1( - D3D12_DESCRIPTOR_RANGE_TYPE rangeType, - UINT numDescriptors, - UINT baseShaderRegister, - UINT registerSpace = 0, - D3D12_DESCRIPTOR_RANGE_FLAGS flags = D3D12_DESCRIPTOR_RANGE_FLAG_NONE, - UINT offsetInDescriptorsFromTableStart = - D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) noexcept - { - Init(rangeType, numDescriptors, baseShaderRegister, registerSpace, flags, offsetInDescriptorsFromTableStart); - } - - inline void Init( - D3D12_DESCRIPTOR_RANGE_TYPE rangeType, - UINT numDescriptors, - UINT baseShaderRegister, - UINT registerSpace = 0, - D3D12_DESCRIPTOR_RANGE_FLAGS flags = D3D12_DESCRIPTOR_RANGE_FLAG_NONE, - UINT offsetInDescriptorsFromTableStart = - D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) noexcept - { - Init(*this, rangeType, numDescriptors, baseShaderRegister, registerSpace, flags, offsetInDescriptorsFromTableStart); - } - - static inline void Init( - _Out_ D3D12_DESCRIPTOR_RANGE1 &range, - D3D12_DESCRIPTOR_RANGE_TYPE rangeType, - UINT numDescriptors, - UINT baseShaderRegister, - UINT registerSpace = 0, - D3D12_DESCRIPTOR_RANGE_FLAGS flags = D3D12_DESCRIPTOR_RANGE_FLAG_NONE, - UINT offsetInDescriptorsFromTableStart = - D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) noexcept - { - range.RangeType = rangeType; - range.NumDescriptors = numDescriptors; - range.BaseShaderRegister = baseShaderRegister; - range.RegisterSpace = registerSpace; - range.Flags = flags; - range.OffsetInDescriptorsFromTableStart = offsetInDescriptorsFromTableStart; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_ROOT_DESCRIPTOR_TABLE1 : public D3D12_ROOT_DESCRIPTOR_TABLE1 -{ - CD3DX12_ROOT_DESCRIPTOR_TABLE1() = default; - explicit CD3DX12_ROOT_DESCRIPTOR_TABLE1(const D3D12_ROOT_DESCRIPTOR_TABLE1 &o) noexcept : - D3D12_ROOT_DESCRIPTOR_TABLE1(o) - {} - CD3DX12_ROOT_DESCRIPTOR_TABLE1( - UINT numDescriptorRanges, - _In_reads_opt_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE1* _pDescriptorRanges) noexcept - { - Init(numDescriptorRanges, _pDescriptorRanges); - } - - inline void Init( - UINT numDescriptorRanges, - _In_reads_opt_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE1* _pDescriptorRanges) noexcept - { - Init(*this, numDescriptorRanges, _pDescriptorRanges); - } - - static inline void Init( - _Out_ D3D12_ROOT_DESCRIPTOR_TABLE1 &rootDescriptorTable, - UINT numDescriptorRanges, - _In_reads_opt_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE1* _pDescriptorRanges) noexcept - { - rootDescriptorTable.NumDescriptorRanges = numDescriptorRanges; - rootDescriptorTable.pDescriptorRanges = _pDescriptorRanges; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_ROOT_DESCRIPTOR1 : public D3D12_ROOT_DESCRIPTOR1 -{ - CD3DX12_ROOT_DESCRIPTOR1() = default; - explicit CD3DX12_ROOT_DESCRIPTOR1(const D3D12_ROOT_DESCRIPTOR1 &o) noexcept : - D3D12_ROOT_DESCRIPTOR1(o) - {} - CD3DX12_ROOT_DESCRIPTOR1( - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE) noexcept - { - Init(shaderRegister, registerSpace, flags); - } - - inline void Init( - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE) noexcept - { - Init(*this, shaderRegister, registerSpace, flags); - } - - static inline void Init( - _Out_ D3D12_ROOT_DESCRIPTOR1 &table, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE) noexcept - { - table.ShaderRegister = shaderRegister; - table.RegisterSpace = registerSpace; - table.Flags = flags; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_ROOT_PARAMETER1 : public D3D12_ROOT_PARAMETER1 -{ - CD3DX12_ROOT_PARAMETER1() = default; - explicit CD3DX12_ROOT_PARAMETER1(const D3D12_ROOT_PARAMETER1 &o) noexcept : - D3D12_ROOT_PARAMETER1(o) - {} - - static inline void InitAsDescriptorTable( - _Out_ D3D12_ROOT_PARAMETER1 &rootParam, - UINT numDescriptorRanges, - _In_reads_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE1* pDescriptorRanges, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; - rootParam.ShaderVisibility = visibility; - CD3DX12_ROOT_DESCRIPTOR_TABLE1::Init(rootParam.DescriptorTable, numDescriptorRanges, pDescriptorRanges); - } - - static inline void InitAsConstants( - _Out_ D3D12_ROOT_PARAMETER1 &rootParam, - UINT num32BitValues, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS; - rootParam.ShaderVisibility = visibility; - CD3DX12_ROOT_CONSTANTS::Init(rootParam.Constants, num32BitValues, shaderRegister, registerSpace); - } - - static inline void InitAsConstantBufferView( - _Out_ D3D12_ROOT_PARAMETER1 &rootParam, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; - rootParam.ShaderVisibility = visibility; - CD3DX12_ROOT_DESCRIPTOR1::Init(rootParam.Descriptor, shaderRegister, registerSpace, flags); - } - - static inline void InitAsShaderResourceView( - _Out_ D3D12_ROOT_PARAMETER1 &rootParam, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_SRV; - rootParam.ShaderVisibility = visibility; - CD3DX12_ROOT_DESCRIPTOR1::Init(rootParam.Descriptor, shaderRegister, registerSpace, flags); - } - - static inline void InitAsUnorderedAccessView( - _Out_ D3D12_ROOT_PARAMETER1 &rootParam, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_UAV; - rootParam.ShaderVisibility = visibility; - CD3DX12_ROOT_DESCRIPTOR1::Init(rootParam.Descriptor, shaderRegister, registerSpace, flags); - } - - inline void InitAsDescriptorTable( - UINT numDescriptorRanges, - _In_reads_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE1* pDescriptorRanges, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - InitAsDescriptorTable(*this, numDescriptorRanges, pDescriptorRanges, visibility); - } - - inline void InitAsConstants( - UINT num32BitValues, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - InitAsConstants(*this, num32BitValues, shaderRegister, registerSpace, visibility); - } - - inline void InitAsConstantBufferView( - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - InitAsConstantBufferView(*this, shaderRegister, registerSpace, flags, visibility); - } - - inline void InitAsShaderResourceView( - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - InitAsShaderResourceView(*this, shaderRegister, registerSpace, flags, visibility); - } - - inline void InitAsUnorderedAccessView( - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - InitAsUnorderedAccessView(*this, shaderRegister, registerSpace, flags, visibility); - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC : public D3D12_VERSIONED_ROOT_SIGNATURE_DESC -{ - CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC() = default; - explicit CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC &o) noexcept : - D3D12_VERSIONED_ROOT_SIGNATURE_DESC(o) - {} - explicit CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC(const D3D12_ROOT_SIGNATURE_DESC &o) noexcept - { - Version = D3D_ROOT_SIGNATURE_VERSION_1_0; - Desc_1_0 = o; - } - explicit CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC(const D3D12_ROOT_SIGNATURE_DESC1 &o) noexcept - { - Version = D3D_ROOT_SIGNATURE_VERSION_1_1; - Desc_1_1 = o; - } - CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC( - UINT numParameters, - _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters, - UINT numStaticSamplers = 0, - _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, - D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept - { - Init_1_0(numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags); - } - CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC( - UINT numParameters, - _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER1* _pParameters, - UINT numStaticSamplers = 0, - _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, - D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept - { - Init_1_1(numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags); - } - CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC(CD3DX12_DEFAULT) noexcept - { - Init_1_1(0, nullptr, 0, nullptr, D3D12_ROOT_SIGNATURE_FLAG_NONE); - } - - inline void Init_1_0( - UINT numParameters, - _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters, - UINT numStaticSamplers = 0, - _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, - D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept - { - Init_1_0(*this, numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags); - } - - static inline void Init_1_0( - _Out_ D3D12_VERSIONED_ROOT_SIGNATURE_DESC &desc, - UINT numParameters, - _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters, - UINT numStaticSamplers = 0, - _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, - D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept - { - desc.Version = D3D_ROOT_SIGNATURE_VERSION_1_0; - desc.Desc_1_0.NumParameters = numParameters; - desc.Desc_1_0.pParameters = _pParameters; - desc.Desc_1_0.NumStaticSamplers = numStaticSamplers; - desc.Desc_1_0.pStaticSamplers = _pStaticSamplers; - desc.Desc_1_0.Flags = flags; - } - - inline void Init_1_1( - UINT numParameters, - _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER1* _pParameters, - UINT numStaticSamplers = 0, - _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, - D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept - { - Init_1_1(*this, numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags); - } - - static inline void Init_1_1( - _Out_ D3D12_VERSIONED_ROOT_SIGNATURE_DESC &desc, - UINT numParameters, - _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER1* _pParameters, - UINT numStaticSamplers = 0, - _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, - D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept - { - desc.Version = D3D_ROOT_SIGNATURE_VERSION_1_1; - desc.Desc_1_1.NumParameters = numParameters; - desc.Desc_1_1.pParameters = _pParameters; - desc.Desc_1_1.NumStaticSamplers = numStaticSamplers; - desc.Desc_1_1.pStaticSamplers = _pStaticSamplers; - desc.Desc_1_1.Flags = flags; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_CPU_DESCRIPTOR_HANDLE : public D3D12_CPU_DESCRIPTOR_HANDLE -{ - CD3DX12_CPU_DESCRIPTOR_HANDLE() = default; - explicit CD3DX12_CPU_DESCRIPTOR_HANDLE(const D3D12_CPU_DESCRIPTOR_HANDLE &o) noexcept : - D3D12_CPU_DESCRIPTOR_HANDLE(o) - {} - CD3DX12_CPU_DESCRIPTOR_HANDLE(CD3DX12_DEFAULT) noexcept { ptr = 0; } - CD3DX12_CPU_DESCRIPTOR_HANDLE(_In_ const D3D12_CPU_DESCRIPTOR_HANDLE &other, INT offsetScaledByIncrementSize) noexcept - { - InitOffsetted(other, offsetScaledByIncrementSize); - } - CD3DX12_CPU_DESCRIPTOR_HANDLE(_In_ const D3D12_CPU_DESCRIPTOR_HANDLE &other, INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept - { - InitOffsetted(other, offsetInDescriptors, descriptorIncrementSize); - } - CD3DX12_CPU_DESCRIPTOR_HANDLE& Offset(INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept - { - ptr = SIZE_T(INT64(ptr) + INT64(offsetInDescriptors) * INT64(descriptorIncrementSize)); - return *this; - } - CD3DX12_CPU_DESCRIPTOR_HANDLE& Offset(INT offsetScaledByIncrementSize) noexcept - { - ptr = SIZE_T(INT64(ptr) + INT64(offsetScaledByIncrementSize)); - return *this; - } - bool operator==(_In_ const D3D12_CPU_DESCRIPTOR_HANDLE& other) const noexcept - { - return (ptr == other.ptr); - } - bool operator!=(_In_ const D3D12_CPU_DESCRIPTOR_HANDLE& other) const noexcept - { - return (ptr != other.ptr); - } - CD3DX12_CPU_DESCRIPTOR_HANDLE &operator=(const D3D12_CPU_DESCRIPTOR_HANDLE &other) noexcept - { - ptr = other.ptr; - return *this; - } - - inline void InitOffsetted(_In_ const D3D12_CPU_DESCRIPTOR_HANDLE &base, INT offsetScaledByIncrementSize) noexcept - { - InitOffsetted(*this, base, offsetScaledByIncrementSize); - } - - inline void InitOffsetted(_In_ const D3D12_CPU_DESCRIPTOR_HANDLE &base, INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept - { - InitOffsetted(*this, base, offsetInDescriptors, descriptorIncrementSize); - } - - static inline void InitOffsetted(_Out_ D3D12_CPU_DESCRIPTOR_HANDLE &handle, _In_ const D3D12_CPU_DESCRIPTOR_HANDLE &base, INT offsetScaledByIncrementSize) noexcept - { - handle.ptr = SIZE_T(INT64(base.ptr) + INT64(offsetScaledByIncrementSize)); - } - - static inline void InitOffsetted(_Out_ D3D12_CPU_DESCRIPTOR_HANDLE &handle, _In_ const D3D12_CPU_DESCRIPTOR_HANDLE &base, INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept - { - handle.ptr = SIZE_T(INT64(base.ptr) + INT64(offsetInDescriptors) * INT64(descriptorIncrementSize)); - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_GPU_DESCRIPTOR_HANDLE : public D3D12_GPU_DESCRIPTOR_HANDLE -{ - CD3DX12_GPU_DESCRIPTOR_HANDLE() = default; - explicit CD3DX12_GPU_DESCRIPTOR_HANDLE(const D3D12_GPU_DESCRIPTOR_HANDLE &o) noexcept : - D3D12_GPU_DESCRIPTOR_HANDLE(o) - {} - CD3DX12_GPU_DESCRIPTOR_HANDLE(CD3DX12_DEFAULT) noexcept { ptr = 0; } - CD3DX12_GPU_DESCRIPTOR_HANDLE(_In_ const D3D12_GPU_DESCRIPTOR_HANDLE &other, INT offsetScaledByIncrementSize) noexcept - { - InitOffsetted(other, offsetScaledByIncrementSize); - } - CD3DX12_GPU_DESCRIPTOR_HANDLE(_In_ const D3D12_GPU_DESCRIPTOR_HANDLE &other, INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept - { - InitOffsetted(other, offsetInDescriptors, descriptorIncrementSize); - } - CD3DX12_GPU_DESCRIPTOR_HANDLE& Offset(INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept - { - ptr = UINT64(INT64(ptr) + INT64(offsetInDescriptors) * INT64(descriptorIncrementSize)); - return *this; - } - CD3DX12_GPU_DESCRIPTOR_HANDLE& Offset(INT offsetScaledByIncrementSize) noexcept - { - ptr = UINT64(INT64(ptr) + INT64(offsetScaledByIncrementSize)); - return *this; - } - inline bool operator==(_In_ const D3D12_GPU_DESCRIPTOR_HANDLE& other) const noexcept - { - return (ptr == other.ptr); - } - inline bool operator!=(_In_ const D3D12_GPU_DESCRIPTOR_HANDLE& other) const noexcept - { - return (ptr != other.ptr); - } - CD3DX12_GPU_DESCRIPTOR_HANDLE &operator=(const D3D12_GPU_DESCRIPTOR_HANDLE &other) noexcept - { - ptr = other.ptr; - return *this; - } - - inline void InitOffsetted(_In_ const D3D12_GPU_DESCRIPTOR_HANDLE &base, INT offsetScaledByIncrementSize) noexcept - { - InitOffsetted(*this, base, offsetScaledByIncrementSize); - } - - inline void InitOffsetted(_In_ const D3D12_GPU_DESCRIPTOR_HANDLE &base, INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept - { - InitOffsetted(*this, base, offsetInDescriptors, descriptorIncrementSize); - } - - static inline void InitOffsetted(_Out_ D3D12_GPU_DESCRIPTOR_HANDLE &handle, _In_ const D3D12_GPU_DESCRIPTOR_HANDLE &base, INT offsetScaledByIncrementSize) noexcept - { - handle.ptr = UINT64(INT64(base.ptr) + INT64(offsetScaledByIncrementSize)); - } - - static inline void InitOffsetted(_Out_ D3D12_GPU_DESCRIPTOR_HANDLE &handle, _In_ const D3D12_GPU_DESCRIPTOR_HANDLE &base, INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept - { - handle.ptr = UINT64(INT64(base.ptr) + INT64(offsetInDescriptors) * INT64(descriptorIncrementSize)); - } -}; - -//------------------------------------------------------------------------------------------------ -inline constexpr UINT D3D12CalcSubresource( UINT MipSlice, UINT ArraySlice, UINT PlaneSlice, UINT MipLevels, UINT ArraySize ) noexcept -{ - return MipSlice + ArraySlice * MipLevels + PlaneSlice * MipLevels * ArraySize; -} - -//------------------------------------------------------------------------------------------------ -template -inline void D3D12DecomposeSubresource( UINT Subresource, UINT MipLevels, UINT ArraySize, _Out_ T& MipSlice, _Out_ U& ArraySlice, _Out_ V& PlaneSlice ) noexcept -{ - MipSlice = static_cast(Subresource % MipLevels); - ArraySlice = static_cast((Subresource / MipLevels) % ArraySize); - PlaneSlice = static_cast(Subresource / (MipLevels * ArraySize)); -} - -//------------------------------------------------------------------------------------------------ -inline UINT8 D3D12GetFormatPlaneCount( - _In_ ID3D12Device* pDevice, - DXGI_FORMAT Format - ) noexcept -{ - D3D12_FEATURE_DATA_FORMAT_INFO formatInfo = { Format, 0 }; - if (FAILED(pDevice->CheckFeatureSupport(D3D12_FEATURE_FORMAT_INFO, &formatInfo, sizeof(formatInfo)))) - { - return 0; - } - return formatInfo.PlaneCount; -} - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_RESOURCE_DESC : public D3D12_RESOURCE_DESC -{ - CD3DX12_RESOURCE_DESC() = default; - explicit CD3DX12_RESOURCE_DESC( const D3D12_RESOURCE_DESC& o ) noexcept : - D3D12_RESOURCE_DESC( o ) - {} - CD3DX12_RESOURCE_DESC( - D3D12_RESOURCE_DIMENSION dimension, - UINT64 alignment, - UINT64 width, - UINT height, - UINT16 depthOrArraySize, - UINT16 mipLevels, - DXGI_FORMAT format, - UINT sampleCount, - UINT sampleQuality, - D3D12_TEXTURE_LAYOUT layout, - D3D12_RESOURCE_FLAGS flags ) noexcept - { - Dimension = dimension; - Alignment = alignment; - Width = width; - Height = height; - DepthOrArraySize = depthOrArraySize; - MipLevels = mipLevels; - Format = format; - SampleDesc.Count = sampleCount; - SampleDesc.Quality = sampleQuality; - Layout = layout; - Flags = flags; - } - static inline CD3DX12_RESOURCE_DESC Buffer( - const D3D12_RESOURCE_ALLOCATION_INFO& resAllocInfo, - D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE ) noexcept - { - return CD3DX12_RESOURCE_DESC( D3D12_RESOURCE_DIMENSION_BUFFER, resAllocInfo.Alignment, resAllocInfo.SizeInBytes, - 1, 1, 1, DXGI_FORMAT_UNKNOWN, 1, 0, D3D12_TEXTURE_LAYOUT_ROW_MAJOR, flags ); - } - static inline CD3DX12_RESOURCE_DESC Buffer( - UINT64 width, - D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, - UINT64 alignment = 0 ) noexcept - { - return CD3DX12_RESOURCE_DESC( D3D12_RESOURCE_DIMENSION_BUFFER, alignment, width, 1, 1, 1, - DXGI_FORMAT_UNKNOWN, 1, 0, D3D12_TEXTURE_LAYOUT_ROW_MAJOR, flags ); - } - static inline CD3DX12_RESOURCE_DESC Tex1D( - DXGI_FORMAT format, - UINT64 width, - UINT16 arraySize = 1, - UINT16 mipLevels = 0, - D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, - D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, - UINT64 alignment = 0 ) noexcept - { - return CD3DX12_RESOURCE_DESC( D3D12_RESOURCE_DIMENSION_TEXTURE1D, alignment, width, 1, arraySize, - mipLevels, format, 1, 0, layout, flags ); - } - static inline CD3DX12_RESOURCE_DESC Tex2D( - DXGI_FORMAT format, - UINT64 width, - UINT height, - UINT16 arraySize = 1, - UINT16 mipLevels = 0, - UINT sampleCount = 1, - UINT sampleQuality = 0, - D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, - D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, - UINT64 alignment = 0 ) noexcept - { - return CD3DX12_RESOURCE_DESC( D3D12_RESOURCE_DIMENSION_TEXTURE2D, alignment, width, height, arraySize, - mipLevels, format, sampleCount, sampleQuality, layout, flags ); - } - static inline CD3DX12_RESOURCE_DESC Tex3D( - DXGI_FORMAT format, - UINT64 width, - UINT height, - UINT16 depth, - UINT16 mipLevels = 0, - D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, - D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, - UINT64 alignment = 0 ) noexcept - { - return CD3DX12_RESOURCE_DESC( D3D12_RESOURCE_DIMENSION_TEXTURE3D, alignment, width, height, depth, - mipLevels, format, 1, 0, layout, flags ); - } - inline UINT16 Depth() const noexcept - { return (Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D ? DepthOrArraySize : 1); } - inline UINT16 ArraySize() const noexcept - { return (Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE3D ? DepthOrArraySize : 1); } - inline UINT8 PlaneCount(_In_ ID3D12Device* pDevice) const noexcept - { return D3D12GetFormatPlaneCount(pDevice, Format); } - inline UINT Subresources(_In_ ID3D12Device* pDevice) const noexcept - { return MipLevels * ArraySize() * PlaneCount(pDevice); } - inline UINT CalcSubresource(UINT MipSlice, UINT ArraySlice, UINT PlaneSlice) noexcept - { return D3D12CalcSubresource(MipSlice, ArraySlice, PlaneSlice, MipLevels, ArraySize()); } -}; -inline bool operator==( const D3D12_RESOURCE_DESC& l, const D3D12_RESOURCE_DESC& r ) noexcept -{ - return l.Dimension == r.Dimension && - l.Alignment == r.Alignment && - l.Width == r.Width && - l.Height == r.Height && - l.DepthOrArraySize == r.DepthOrArraySize && - l.MipLevels == r.MipLevels && - l.Format == r.Format && - l.SampleDesc.Count == r.SampleDesc.Count && - l.SampleDesc.Quality == r.SampleDesc.Quality && - l.Layout == r.Layout && - l.Flags == r.Flags; -} -inline bool operator!=( const D3D12_RESOURCE_DESC& l, const D3D12_RESOURCE_DESC& r ) noexcept -{ return !( l == r ); } - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_RESOURCE_DESC1 : public D3D12_RESOURCE_DESC1 -{ - CD3DX12_RESOURCE_DESC1() = default; - explicit CD3DX12_RESOURCE_DESC1( const D3D12_RESOURCE_DESC1& o ) noexcept : - D3D12_RESOURCE_DESC1( o ) - {} - CD3DX12_RESOURCE_DESC1( - D3D12_RESOURCE_DIMENSION dimension, - UINT64 alignment, - UINT64 width, - UINT height, - UINT16 depthOrArraySize, - UINT16 mipLevels, - DXGI_FORMAT format, - UINT sampleCount, - UINT sampleQuality, - D3D12_TEXTURE_LAYOUT layout, - D3D12_RESOURCE_FLAGS flags, - UINT samplerFeedbackMipRegionWidth = 0, - UINT samplerFeedbackMipRegionHeight = 0, - UINT samplerFeedbackMipRegionDepth = 0) noexcept - { - Dimension = dimension; - Alignment = alignment; - Width = width; - Height = height; - DepthOrArraySize = depthOrArraySize; - MipLevels = mipLevels; - Format = format; - SampleDesc.Count = sampleCount; - SampleDesc.Quality = sampleQuality; - Layout = layout; - Flags = flags; - SamplerFeedbackMipRegion.Width = samplerFeedbackMipRegionWidth; - SamplerFeedbackMipRegion.Height = samplerFeedbackMipRegionHeight; - SamplerFeedbackMipRegion.Depth = samplerFeedbackMipRegionDepth; - } - static inline CD3DX12_RESOURCE_DESC1 Buffer( - const D3D12_RESOURCE_ALLOCATION_INFO& resAllocInfo, - D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE ) noexcept - { - return CD3DX12_RESOURCE_DESC1( D3D12_RESOURCE_DIMENSION_BUFFER, resAllocInfo.Alignment, resAllocInfo.SizeInBytes, - 1, 1, 1, DXGI_FORMAT_UNKNOWN, 1, 0, D3D12_TEXTURE_LAYOUT_ROW_MAJOR, flags, 0, 0, 0 ); - } - static inline CD3DX12_RESOURCE_DESC1 Buffer( - UINT64 width, - D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, - UINT64 alignment = 0 ) noexcept - { - return CD3DX12_RESOURCE_DESC1( D3D12_RESOURCE_DIMENSION_BUFFER, alignment, width, 1, 1, 1, - DXGI_FORMAT_UNKNOWN, 1, 0, D3D12_TEXTURE_LAYOUT_ROW_MAJOR, flags, 0, 0, 0 ); - } - static inline CD3DX12_RESOURCE_DESC1 Tex1D( - DXGI_FORMAT format, - UINT64 width, - UINT16 arraySize = 1, - UINT16 mipLevels = 0, - D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, - D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, - UINT64 alignment = 0 ) noexcept - { - return CD3DX12_RESOURCE_DESC1( D3D12_RESOURCE_DIMENSION_TEXTURE1D, alignment, width, 1, arraySize, - mipLevels, format, 1, 0, layout, flags, 0, 0, 0 ); - } - static inline CD3DX12_RESOURCE_DESC1 Tex2D( - DXGI_FORMAT format, - UINT64 width, - UINT height, - UINT16 arraySize = 1, - UINT16 mipLevels = 0, - UINT sampleCount = 1, - UINT sampleQuality = 0, - D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, - D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, - UINT64 alignment = 0, - UINT samplerFeedbackMipRegionWidth = 0, - UINT samplerFeedbackMipRegionHeight = 0, - UINT samplerFeedbackMipRegionDepth = 0) noexcept - { - return CD3DX12_RESOURCE_DESC1( D3D12_RESOURCE_DIMENSION_TEXTURE2D, alignment, width, height, arraySize, - mipLevels, format, sampleCount, sampleQuality, layout, flags, samplerFeedbackMipRegionWidth, - samplerFeedbackMipRegionHeight, samplerFeedbackMipRegionDepth ); - } - static inline CD3DX12_RESOURCE_DESC1 Tex3D( - DXGI_FORMAT format, - UINT64 width, - UINT height, - UINT16 depth, - UINT16 mipLevels = 0, - D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, - D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, - UINT64 alignment = 0 ) noexcept - { - return CD3DX12_RESOURCE_DESC1( D3D12_RESOURCE_DIMENSION_TEXTURE3D, alignment, width, height, depth, - mipLevels, format, 1, 0, layout, flags, 0, 0, 0 ); - } - inline UINT16 Depth() const noexcept - { return (Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D ? DepthOrArraySize : 1); } - inline UINT16 ArraySize() const noexcept - { return (Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE3D ? DepthOrArraySize : 1); } - inline UINT8 PlaneCount(_In_ ID3D12Device* pDevice) const noexcept - { return D3D12GetFormatPlaneCount(pDevice, Format); } - inline UINT Subresources(_In_ ID3D12Device* pDevice) const noexcept - { return MipLevels * ArraySize() * PlaneCount(pDevice); } - inline UINT CalcSubresource(UINT MipSlice, UINT ArraySlice, UINT PlaneSlice) noexcept - { return D3D12CalcSubresource(MipSlice, ArraySlice, PlaneSlice, MipLevels, ArraySize()); } -}; -inline bool operator==( const D3D12_RESOURCE_DESC1& l, const D3D12_RESOURCE_DESC1& r ) noexcept -{ - return l.Dimension == r.Dimension && - l.Alignment == r.Alignment && - l.Width == r.Width && - l.Height == r.Height && - l.DepthOrArraySize == r.DepthOrArraySize && - l.MipLevels == r.MipLevels && - l.Format == r.Format && - l.SampleDesc.Count == r.SampleDesc.Count && - l.SampleDesc.Quality == r.SampleDesc.Quality && - l.Layout == r.Layout && - l.Flags == r.Flags && - l.SamplerFeedbackMipRegion.Width == r.SamplerFeedbackMipRegion.Width && - l.SamplerFeedbackMipRegion.Height == r.SamplerFeedbackMipRegion.Height && - l.SamplerFeedbackMipRegion.Depth == r.SamplerFeedbackMipRegion.Depth; -} -inline bool operator!=( const D3D12_RESOURCE_DESC1& l, const D3D12_RESOURCE_DESC1& r ) noexcept -{ return !( l == r ); } - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_VIEW_INSTANCING_DESC : public D3D12_VIEW_INSTANCING_DESC -{ - CD3DX12_VIEW_INSTANCING_DESC() = default; - explicit CD3DX12_VIEW_INSTANCING_DESC( const D3D12_VIEW_INSTANCING_DESC& o ) noexcept : - D3D12_VIEW_INSTANCING_DESC( o ) - {} - explicit CD3DX12_VIEW_INSTANCING_DESC( CD3DX12_DEFAULT ) noexcept - { - ViewInstanceCount = 0; - pViewInstanceLocations = nullptr; - Flags = D3D12_VIEW_INSTANCING_FLAG_NONE; - } - explicit CD3DX12_VIEW_INSTANCING_DESC( - UINT InViewInstanceCount, - const D3D12_VIEW_INSTANCE_LOCATION* InViewInstanceLocations, - D3D12_VIEW_INSTANCING_FLAGS InFlags) noexcept - { - ViewInstanceCount = InViewInstanceCount; - pViewInstanceLocations = InViewInstanceLocations; - Flags = InFlags; - } -}; - -//------------------------------------------------------------------------------------------------ -// Row-by-row memcpy -inline void MemcpySubresource( - _In_ const D3D12_MEMCPY_DEST* pDest, - _In_ const D3D12_SUBRESOURCE_DATA* pSrc, - SIZE_T RowSizeInBytes, - UINT NumRows, - UINT NumSlices) noexcept -{ - for (UINT z = 0; z < NumSlices; ++z) - { - auto pDestSlice = static_cast(pDest->pData) + pDest->SlicePitch * z; - auto pSrcSlice = static_cast(pSrc->pData) + pSrc->SlicePitch * LONG_PTR(z); - for (UINT y = 0; y < NumRows; ++y) - { - memcpy(pDestSlice + pDest->RowPitch * y, - pSrcSlice + pSrc->RowPitch * LONG_PTR(y), - RowSizeInBytes); - } - } -} - -//------------------------------------------------------------------------------------------------ -// Returns required size of a buffer to be used for data upload -inline UINT64 GetRequiredIntermediateSize( - _In_ ID3D12Resource* pDestinationResource, - _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, - _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources) noexcept -{ - auto Desc = pDestinationResource->GetDesc(); - UINT64 RequiredSize = 0; - - ID3D12Device* pDevice = nullptr; - pDestinationResource->GetDevice(IID_ID3D12Device, reinterpret_cast(&pDevice)); - pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, 0, nullptr, nullptr, nullptr, &RequiredSize); - pDevice->Release(); - - return RequiredSize; -} - -//------------------------------------------------------------------------------------------------ -// All arrays must be populated (e.g. by calling GetCopyableFootprints) -inline UINT64 UpdateSubresources( - _In_ ID3D12GraphicsCommandList* pCmdList, - _In_ ID3D12Resource* pDestinationResource, - _In_ ID3D12Resource* pIntermediate, - _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, - _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, - UINT64 RequiredSize, - _In_reads_(NumSubresources) const D3D12_PLACED_SUBRESOURCE_FOOTPRINT* pLayouts, - _In_reads_(NumSubresources) const UINT* pNumRows, - _In_reads_(NumSubresources) const UINT64* pRowSizesInBytes, - _In_reads_(NumSubresources) const D3D12_SUBRESOURCE_DATA* pSrcData) noexcept -{ - // Minor validation - auto IntermediateDesc = pIntermediate->GetDesc(); - auto DestinationDesc = pDestinationResource->GetDesc(); - if (IntermediateDesc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER || - IntermediateDesc.Width < RequiredSize + pLayouts[0].Offset || - RequiredSize > SIZE_T(-1) || - (DestinationDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER && - (FirstSubresource != 0 || NumSubresources != 1))) - { - return 0; - } - - BYTE* pData; - HRESULT hr = pIntermediate->Map(0, nullptr, reinterpret_cast(&pData)); - if (FAILED(hr)) - { - return 0; - } - - for (UINT i = 0; i < NumSubresources; ++i) - { - if (pRowSizesInBytes[i] > SIZE_T(-1)) return 0; - D3D12_MEMCPY_DEST DestData = { pData + pLayouts[i].Offset, pLayouts[i].Footprint.RowPitch, SIZE_T(pLayouts[i].Footprint.RowPitch) * SIZE_T(pNumRows[i]) }; - MemcpySubresource(&DestData, &pSrcData[i], static_cast(pRowSizesInBytes[i]), pNumRows[i], pLayouts[i].Footprint.Depth); - } - pIntermediate->Unmap(0, nullptr); - - if (DestinationDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER) - { - pCmdList->CopyBufferRegion( - pDestinationResource, 0, pIntermediate, pLayouts[0].Offset, pLayouts[0].Footprint.Width); - } - else - { - for (UINT i = 0; i < NumSubresources; ++i) - { - CD3DX12_TEXTURE_COPY_LOCATION Dst(pDestinationResource, i + FirstSubresource); - CD3DX12_TEXTURE_COPY_LOCATION Src(pIntermediate, pLayouts[i]); - pCmdList->CopyTextureRegion(&Dst, 0, 0, 0, &Src, nullptr); - } - } - return RequiredSize; -} - -//------------------------------------------------------------------------------------------------ -// Heap-allocating UpdateSubresources implementation -inline UINT64 UpdateSubresources( - _In_ ID3D12GraphicsCommandList* pCmdList, - _In_ ID3D12Resource* pDestinationResource, - _In_ ID3D12Resource* pIntermediate, - UINT64 IntermediateOffset, - _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, - _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, - _In_reads_(NumSubresources) const D3D12_SUBRESOURCE_DATA* pSrcData) noexcept -{ - UINT64 RequiredSize = 0; - UINT64 MemToAlloc = static_cast(sizeof(D3D12_PLACED_SUBRESOURCE_FOOTPRINT) + sizeof(UINT) + sizeof(UINT64)) * NumSubresources; - if (MemToAlloc > SIZE_MAX) - { - return 0; - } - void* pMem = HeapAlloc(GetProcessHeap(), 0, static_cast(MemToAlloc)); - if (pMem == nullptr) - { - return 0; - } - auto pLayouts = static_cast(pMem); - UINT64* pRowSizesInBytes = reinterpret_cast(pLayouts + NumSubresources); - UINT* pNumRows = reinterpret_cast(pRowSizesInBytes + NumSubresources); - - auto Desc = pDestinationResource->GetDesc(); - ID3D12Device* pDevice = nullptr; - pDestinationResource->GetDevice(IID_ID3D12Device, reinterpret_cast(&pDevice)); - pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, IntermediateOffset, pLayouts, pNumRows, pRowSizesInBytes, &RequiredSize); - pDevice->Release(); - - UINT64 Result = UpdateSubresources(pCmdList, pDestinationResource, pIntermediate, FirstSubresource, NumSubresources, RequiredSize, pLayouts, pNumRows, pRowSizesInBytes, pSrcData); - HeapFree(GetProcessHeap(), 0, pMem); - return Result; -} - -//------------------------------------------------------------------------------------------------ -// Stack-allocating UpdateSubresources implementation -template -inline UINT64 UpdateSubresources( - _In_ ID3D12GraphicsCommandList* pCmdList, - _In_ ID3D12Resource* pDestinationResource, - _In_ ID3D12Resource* pIntermediate, - UINT64 IntermediateOffset, - _In_range_(0, MaxSubresources) UINT FirstSubresource, - _In_range_(1, MaxSubresources - FirstSubresource) UINT NumSubresources, - _In_reads_(NumSubresources) const D3D12_SUBRESOURCE_DATA* pSrcData) noexcept -{ - UINT64 RequiredSize = 0; - D3D12_PLACED_SUBRESOURCE_FOOTPRINT Layouts[MaxSubresources]; - UINT NumRows[MaxSubresources]; - UINT64 RowSizesInBytes[MaxSubresources]; - - auto Desc = pDestinationResource->GetDesc(); - ID3D12Device* pDevice = nullptr; - pDestinationResource->GetDevice(IID_ID3D12Device, reinterpret_cast(&pDevice)); - pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, IntermediateOffset, Layouts, NumRows, RowSizesInBytes, &RequiredSize); - pDevice->Release(); - - return UpdateSubresources(pCmdList, pDestinationResource, pIntermediate, FirstSubresource, NumSubresources, RequiredSize, Layouts, NumRows, RowSizesInBytes, pSrcData); -} - -//------------------------------------------------------------------------------------------------ -inline constexpr bool D3D12IsLayoutOpaque( D3D12_TEXTURE_LAYOUT Layout ) noexcept -{ return Layout == D3D12_TEXTURE_LAYOUT_UNKNOWN || Layout == D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE; } - -//------------------------------------------------------------------------------------------------ -template -inline ID3D12CommandList * const * CommandListCast(t_CommandListType * const * pp) noexcept -{ - // This cast is useful for passing strongly typed command list pointers into - // ExecuteCommandLists. - // This cast is valid as long as the const-ness is respected. D3D12 APIs do - // respect the const-ness of their arguments. - return reinterpret_cast(pp); -} - -//------------------------------------------------------------------------------------------------ -// D3D12 exports a new method for serializing root signatures in the Windows 10 Anniversary Update. -// To help enable root signature 1.1 features when they are available and not require maintaining -// two code paths for building root signatures, this helper method reconstructs a 1.0 signature when -// 1.1 is not supported. -inline HRESULT D3DX12SerializeVersionedRootSignature( - _In_ const D3D12_VERSIONED_ROOT_SIGNATURE_DESC* pRootSignatureDesc, - D3D_ROOT_SIGNATURE_VERSION MaxVersion, - _Outptr_ ID3DBlob** ppBlob, - _Always_(_Outptr_opt_result_maybenull_) ID3DBlob** ppErrorBlob) noexcept -{ - if (ppErrorBlob != nullptr) - { - *ppErrorBlob = nullptr; - } - - switch (MaxVersion) - { - case D3D_ROOT_SIGNATURE_VERSION_1_0: - switch (pRootSignatureDesc->Version) - { - case D3D_ROOT_SIGNATURE_VERSION_1_0: - return D3D12SerializeRootSignature(&pRootSignatureDesc->Desc_1_0, D3D_ROOT_SIGNATURE_VERSION_1, ppBlob, ppErrorBlob); - - case D3D_ROOT_SIGNATURE_VERSION_1_1: - { - HRESULT hr = S_OK; - const D3D12_ROOT_SIGNATURE_DESC1& desc_1_1 = pRootSignatureDesc->Desc_1_1; - - const SIZE_T ParametersSize = sizeof(D3D12_ROOT_PARAMETER) * desc_1_1.NumParameters; - void* pParameters = (ParametersSize > 0) ? HeapAlloc(GetProcessHeap(), 0, ParametersSize) : nullptr; - if (ParametersSize > 0 && pParameters == nullptr) - { - hr = E_OUTOFMEMORY; - } - auto pParameters_1_0 = static_cast(pParameters); - - if (SUCCEEDED(hr)) - { - for (UINT n = 0; n < desc_1_1.NumParameters; n++) - { - __analysis_assume(ParametersSize == sizeof(D3D12_ROOT_PARAMETER) * desc_1_1.NumParameters); - pParameters_1_0[n].ParameterType = desc_1_1.pParameters[n].ParameterType; - pParameters_1_0[n].ShaderVisibility = desc_1_1.pParameters[n].ShaderVisibility; - - switch (desc_1_1.pParameters[n].ParameterType) - { - case D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS: - pParameters_1_0[n].Constants.Num32BitValues = desc_1_1.pParameters[n].Constants.Num32BitValues; - pParameters_1_0[n].Constants.RegisterSpace = desc_1_1.pParameters[n].Constants.RegisterSpace; - pParameters_1_0[n].Constants.ShaderRegister = desc_1_1.pParameters[n].Constants.ShaderRegister; - break; - - case D3D12_ROOT_PARAMETER_TYPE_CBV: - case D3D12_ROOT_PARAMETER_TYPE_SRV: - case D3D12_ROOT_PARAMETER_TYPE_UAV: - pParameters_1_0[n].Descriptor.RegisterSpace = desc_1_1.pParameters[n].Descriptor.RegisterSpace; - pParameters_1_0[n].Descriptor.ShaderRegister = desc_1_1.pParameters[n].Descriptor.ShaderRegister; - break; - - case D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE: - const D3D12_ROOT_DESCRIPTOR_TABLE1& table_1_1 = desc_1_1.pParameters[n].DescriptorTable; - - const SIZE_T DescriptorRangesSize = sizeof(D3D12_DESCRIPTOR_RANGE) * table_1_1.NumDescriptorRanges; - void* pDescriptorRanges = (DescriptorRangesSize > 0 && SUCCEEDED(hr)) ? HeapAlloc(GetProcessHeap(), 0, DescriptorRangesSize) : nullptr; - if (DescriptorRangesSize > 0 && pDescriptorRanges == nullptr) - { - hr = E_OUTOFMEMORY; - } - auto pDescriptorRanges_1_0 = static_cast(pDescriptorRanges); - - if (SUCCEEDED(hr)) - { - for (UINT x = 0; x < table_1_1.NumDescriptorRanges; x++) - { - __analysis_assume(DescriptorRangesSize == sizeof(D3D12_DESCRIPTOR_RANGE) * table_1_1.NumDescriptorRanges); - pDescriptorRanges_1_0[x].BaseShaderRegister = table_1_1.pDescriptorRanges[x].BaseShaderRegister; - pDescriptorRanges_1_0[x].NumDescriptors = table_1_1.pDescriptorRanges[x].NumDescriptors; - pDescriptorRanges_1_0[x].OffsetInDescriptorsFromTableStart = table_1_1.pDescriptorRanges[x].OffsetInDescriptorsFromTableStart; - pDescriptorRanges_1_0[x].RangeType = table_1_1.pDescriptorRanges[x].RangeType; - pDescriptorRanges_1_0[x].RegisterSpace = table_1_1.pDescriptorRanges[x].RegisterSpace; - } - } - - D3D12_ROOT_DESCRIPTOR_TABLE& table_1_0 = pParameters_1_0[n].DescriptorTable; - table_1_0.NumDescriptorRanges = table_1_1.NumDescriptorRanges; - table_1_0.pDescriptorRanges = pDescriptorRanges_1_0; - } - } - } - - if (SUCCEEDED(hr)) - { - CD3DX12_ROOT_SIGNATURE_DESC desc_1_0(desc_1_1.NumParameters, pParameters_1_0, desc_1_1.NumStaticSamplers, desc_1_1.pStaticSamplers, desc_1_1.Flags); - hr = D3D12SerializeRootSignature(&desc_1_0, D3D_ROOT_SIGNATURE_VERSION_1, ppBlob, ppErrorBlob); - } - - if (pParameters) - { - for (UINT n = 0; n < desc_1_1.NumParameters; n++) - { - if (desc_1_1.pParameters[n].ParameterType == D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE) - { - HeapFree(GetProcessHeap(), 0, reinterpret_cast(const_cast(pParameters_1_0[n].DescriptorTable.pDescriptorRanges))); - } - } - HeapFree(GetProcessHeap(), 0, pParameters); - } - return hr; - } - } - break; - - case D3D_ROOT_SIGNATURE_VERSION_1_1: - return D3D12SerializeVersionedRootSignature(pRootSignatureDesc, ppBlob, ppErrorBlob); - } - - return E_INVALIDARG; -} - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_RT_FORMAT_ARRAY : public D3D12_RT_FORMAT_ARRAY -{ - CD3DX12_RT_FORMAT_ARRAY() = default; - explicit CD3DX12_RT_FORMAT_ARRAY(const D3D12_RT_FORMAT_ARRAY& o) noexcept - : D3D12_RT_FORMAT_ARRAY(o) - {} - explicit CD3DX12_RT_FORMAT_ARRAY(_In_reads_(NumFormats) const DXGI_FORMAT* pFormats, UINT NumFormats) noexcept - { - NumRenderTargets = NumFormats; - memcpy(RTFormats, pFormats, sizeof(RTFormats)); - // assumes ARRAY_SIZE(pFormats) == ARRAY_SIZE(RTFormats) - } -}; - -//------------------------------------------------------------------------------------------------ -// Pipeline State Stream Helpers -//------------------------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------------------------ -// Stream Subobjects, i.e. elements of a stream - -struct DefaultSampleMask { operator UINT() noexcept { return UINT_MAX; } }; -struct DefaultSampleDesc { operator DXGI_SAMPLE_DESC() noexcept { return DXGI_SAMPLE_DESC{1, 0}; } }; - -#pragma warning(push) -#pragma warning(disable : 4324) -template -class alignas(void*) CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT -{ -private: - D3D12_PIPELINE_STATE_SUBOBJECT_TYPE _Type; - InnerStructType _Inner; -public: - CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT() noexcept : _Type(Type), _Inner(DefaultArg()) {} - CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT(InnerStructType const& i) noexcept : _Type(Type), _Inner(i) {} - CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT& operator=(InnerStructType const& i) noexcept { _Type = Type; _Inner = i; return *this; } - operator InnerStructType const&() const noexcept { return _Inner; } - operator InnerStructType&() noexcept { return _Inner; } - InnerStructType* operator&() noexcept { return &_Inner; } - InnerStructType const* operator&() const noexcept { return &_Inner; } -}; -#pragma warning(pop) -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_PIPELINE_STATE_FLAGS, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_FLAGS> CD3DX12_PIPELINE_STATE_STREAM_FLAGS; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< UINT, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_NODE_MASK> CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< ID3D12RootSignature*, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_ROOT_SIGNATURE> CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_INPUT_LAYOUT_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_INPUT_LAYOUT> CD3DX12_PIPELINE_STATE_STREAM_INPUT_LAYOUT; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_INDEX_BUFFER_STRIP_CUT_VALUE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_IB_STRIP_CUT_VALUE> CD3DX12_PIPELINE_STATE_STREAM_IB_STRIP_CUT_VALUE; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_PRIMITIVE_TOPOLOGY_TYPE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PRIMITIVE_TOPOLOGY> CD3DX12_PIPELINE_STATE_STREAM_PRIMITIVE_TOPOLOGY; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VS> CD3DX12_PIPELINE_STATE_STREAM_VS; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_GS> CD3DX12_PIPELINE_STATE_STREAM_GS; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_STREAM_OUTPUT_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_STREAM_OUTPUT> CD3DX12_PIPELINE_STATE_STREAM_STREAM_OUTPUT; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_HS> CD3DX12_PIPELINE_STATE_STREAM_HS; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DS> CD3DX12_PIPELINE_STATE_STREAM_DS; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PS> CD3DX12_PIPELINE_STATE_STREAM_PS; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_AS> CD3DX12_PIPELINE_STATE_STREAM_AS; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MS> CD3DX12_PIPELINE_STATE_STREAM_MS; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CS> CD3DX12_PIPELINE_STATE_STREAM_CS; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_BLEND_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_BLEND, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_DEPTH_STENCIL_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_DEPTH_STENCIL_DESC1, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL1; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< DXGI_FORMAT, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL_FORMAT> CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL_FORMAT; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_RASTERIZER_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_RT_FORMAT_ARRAY, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RENDER_TARGET_FORMATS> CD3DX12_PIPELINE_STATE_STREAM_RENDER_TARGET_FORMATS; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< DXGI_SAMPLE_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_DESC, DefaultSampleDesc> CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_DESC; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< UINT, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_MASK, DefaultSampleMask> CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_MASK; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_CACHED_PIPELINE_STATE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CACHED_PSO> CD3DX12_PIPELINE_STATE_STREAM_CACHED_PSO; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_VIEW_INSTANCING_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VIEW_INSTANCING, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_VIEW_INSTANCING; - -//------------------------------------------------------------------------------------------------ -// Stream Parser Helpers - -struct ID3DX12PipelineParserCallbacks -{ - // Subobject Callbacks - virtual void FlagsCb(D3D12_PIPELINE_STATE_FLAGS) {} - virtual void NodeMaskCb(UINT) {} - virtual void RootSignatureCb(ID3D12RootSignature*) {} - virtual void InputLayoutCb(const D3D12_INPUT_LAYOUT_DESC&) {} - virtual void IBStripCutValueCb(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE) {} - virtual void PrimitiveTopologyTypeCb(D3D12_PRIMITIVE_TOPOLOGY_TYPE) {} - virtual void VSCb(const D3D12_SHADER_BYTECODE&) {} - virtual void GSCb(const D3D12_SHADER_BYTECODE&) {} - virtual void StreamOutputCb(const D3D12_STREAM_OUTPUT_DESC&) {} - virtual void HSCb(const D3D12_SHADER_BYTECODE&) {} - virtual void DSCb(const D3D12_SHADER_BYTECODE&) {} - virtual void PSCb(const D3D12_SHADER_BYTECODE&) {} - virtual void CSCb(const D3D12_SHADER_BYTECODE&) {} - virtual void ASCb(const D3D12_SHADER_BYTECODE&) {} - virtual void MSCb(const D3D12_SHADER_BYTECODE&) {} - virtual void BlendStateCb(const D3D12_BLEND_DESC&) {} - virtual void DepthStencilStateCb(const D3D12_DEPTH_STENCIL_DESC&) {} - virtual void DepthStencilState1Cb(const D3D12_DEPTH_STENCIL_DESC1&) {} - virtual void DSVFormatCb(DXGI_FORMAT) {} - virtual void RasterizerStateCb(const D3D12_RASTERIZER_DESC&) {} - virtual void RTVFormatsCb(const D3D12_RT_FORMAT_ARRAY&) {} - virtual void SampleDescCb(const DXGI_SAMPLE_DESC&) {} - virtual void SampleMaskCb(UINT) {} - virtual void ViewInstancingCb(const D3D12_VIEW_INSTANCING_DESC&) {} - virtual void CachedPSOCb(const D3D12_CACHED_PIPELINE_STATE&) {} - - // Error Callbacks - virtual void ErrorBadInputParameter(UINT /*ParameterIndex*/) {} - virtual void ErrorDuplicateSubobject(D3D12_PIPELINE_STATE_SUBOBJECT_TYPE /*DuplicateType*/) {} - virtual void ErrorUnknownSubobject(UINT /*UnknownTypeValue*/) {} - - virtual ~ID3DX12PipelineParserCallbacks() = default; -}; - -struct D3DX12_MESH_SHADER_PIPELINE_STATE_DESC -{ - ID3D12RootSignature* pRootSignature; - D3D12_SHADER_BYTECODE AS; - D3D12_SHADER_BYTECODE MS; - D3D12_SHADER_BYTECODE PS; - D3D12_BLEND_DESC BlendState; - UINT SampleMask; - D3D12_RASTERIZER_DESC RasterizerState; - D3D12_DEPTH_STENCIL_DESC DepthStencilState; - D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType; - UINT NumRenderTargets; - DXGI_FORMAT RTVFormats[ D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT ]; - DXGI_FORMAT DSVFormat; - DXGI_SAMPLE_DESC SampleDesc; - UINT NodeMask; - D3D12_CACHED_PIPELINE_STATE CachedPSO; - D3D12_PIPELINE_STATE_FLAGS Flags; -}; - -// CD3DX12_PIPELINE_STATE_STREAM2 Works on OS Build 19041+ (where there is a new mesh shader pipeline). -// Use CD3DX12_PIPELINE_STATE_STREAM1 for OS Build 16299+ (where there is a new view instancing subobject). -// Use CD3DX12_PIPELINE_STATE_STREAM for OS Build 15063+ support. -struct CD3DX12_PIPELINE_STATE_STREAM2 -{ - CD3DX12_PIPELINE_STATE_STREAM2() = default; - // Mesh and amplification shaders must be set manually, since they do not have representation in D3D12_GRAPHICS_PIPELINE_STATE_DESC - CD3DX12_PIPELINE_STATE_STREAM2(const D3D12_GRAPHICS_PIPELINE_STATE_DESC& Desc) noexcept - : Flags(Desc.Flags) - , NodeMask(Desc.NodeMask) - , pRootSignature(Desc.pRootSignature) - , InputLayout(Desc.InputLayout) - , IBStripCutValue(Desc.IBStripCutValue) - , PrimitiveTopologyType(Desc.PrimitiveTopologyType) - , VS(Desc.VS) - , GS(Desc.GS) - , StreamOutput(Desc.StreamOutput) - , HS(Desc.HS) - , DS(Desc.DS) - , PS(Desc.PS) - , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) - , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC1(Desc.DepthStencilState)) - , DSVFormat(Desc.DSVFormat) - , RasterizerState(CD3DX12_RASTERIZER_DESC(Desc.RasterizerState)) - , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) - , SampleDesc(Desc.SampleDesc) - , SampleMask(Desc.SampleMask) - , CachedPSO(Desc.CachedPSO) - , ViewInstancingDesc(CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT())) - {} - CD3DX12_PIPELINE_STATE_STREAM2(const D3DX12_MESH_SHADER_PIPELINE_STATE_DESC& Desc) noexcept - : Flags(Desc.Flags) - , NodeMask(Desc.NodeMask) - , pRootSignature(Desc.pRootSignature) - , PrimitiveTopologyType(Desc.PrimitiveTopologyType) - , PS(Desc.PS) - , AS(Desc.AS) - , MS(Desc.MS) - , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) - , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC1(Desc.DepthStencilState)) - , DSVFormat(Desc.DSVFormat) - , RasterizerState(CD3DX12_RASTERIZER_DESC(Desc.RasterizerState)) - , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) - , SampleDesc(Desc.SampleDesc) - , SampleMask(Desc.SampleMask) - , CachedPSO(Desc.CachedPSO) - , ViewInstancingDesc(CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT())) - {} - CD3DX12_PIPELINE_STATE_STREAM2(const D3D12_COMPUTE_PIPELINE_STATE_DESC& Desc) noexcept - : Flags(Desc.Flags) - , NodeMask(Desc.NodeMask) - , pRootSignature(Desc.pRootSignature) - , CS(CD3DX12_SHADER_BYTECODE(Desc.CS)) - , CachedPSO(Desc.CachedPSO) - { - static_cast(DepthStencilState).DepthEnable = false; - } - CD3DX12_PIPELINE_STATE_STREAM_FLAGS Flags; - CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK NodeMask; - CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE pRootSignature; - CD3DX12_PIPELINE_STATE_STREAM_INPUT_LAYOUT InputLayout; - CD3DX12_PIPELINE_STATE_STREAM_IB_STRIP_CUT_VALUE IBStripCutValue; - CD3DX12_PIPELINE_STATE_STREAM_PRIMITIVE_TOPOLOGY PrimitiveTopologyType; - CD3DX12_PIPELINE_STATE_STREAM_VS VS; - CD3DX12_PIPELINE_STATE_STREAM_GS GS; - CD3DX12_PIPELINE_STATE_STREAM_STREAM_OUTPUT StreamOutput; - CD3DX12_PIPELINE_STATE_STREAM_HS HS; - CD3DX12_PIPELINE_STATE_STREAM_DS DS; - CD3DX12_PIPELINE_STATE_STREAM_PS PS; - CD3DX12_PIPELINE_STATE_STREAM_AS AS; - CD3DX12_PIPELINE_STATE_STREAM_MS MS; - CD3DX12_PIPELINE_STATE_STREAM_CS CS; - CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC BlendState; - CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL1 DepthStencilState; - CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL_FORMAT DSVFormat; - CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER RasterizerState; - CD3DX12_PIPELINE_STATE_STREAM_RENDER_TARGET_FORMATS RTVFormats; - CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_DESC SampleDesc; - CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_MASK SampleMask; - CD3DX12_PIPELINE_STATE_STREAM_CACHED_PSO CachedPSO; - CD3DX12_PIPELINE_STATE_STREAM_VIEW_INSTANCING ViewInstancingDesc; - D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDescV0() const noexcept - { - D3D12_GRAPHICS_PIPELINE_STATE_DESC D; - D.Flags = this->Flags; - D.NodeMask = this->NodeMask; - D.pRootSignature = this->pRootSignature; - D.InputLayout = this->InputLayout; - D.IBStripCutValue = this->IBStripCutValue; - D.PrimitiveTopologyType = this->PrimitiveTopologyType; - D.VS = this->VS; - D.GS = this->GS; - D.StreamOutput = this->StreamOutput; - D.HS = this->HS; - D.DS = this->DS; - D.PS = this->PS; - D.BlendState = this->BlendState; - D.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(D3D12_DEPTH_STENCIL_DESC1(this->DepthStencilState)); - D.DSVFormat = this->DSVFormat; - D.RasterizerState = this->RasterizerState; - D.NumRenderTargets = D3D12_RT_FORMAT_ARRAY(this->RTVFormats).NumRenderTargets; - memcpy(D.RTVFormats, D3D12_RT_FORMAT_ARRAY(this->RTVFormats).RTFormats, sizeof(D.RTVFormats)); - D.SampleDesc = this->SampleDesc; - D.SampleMask = this->SampleMask; - D.CachedPSO = this->CachedPSO; - return D; - } - D3D12_COMPUTE_PIPELINE_STATE_DESC ComputeDescV0() const noexcept - { - D3D12_COMPUTE_PIPELINE_STATE_DESC D; - D.Flags = this->Flags; - D.NodeMask = this->NodeMask; - D.pRootSignature = this->pRootSignature; - D.CS = this->CS; - D.CachedPSO = this->CachedPSO; - return D; - } -}; - -// CD3DX12_PIPELINE_STATE_STREAM1 Works on OS Build 16299+ (where there is a new view instancing subobject). -// Use CD3DX12_PIPELINE_STATE_STREAM for OS Build 15063+ support. -struct CD3DX12_PIPELINE_STATE_STREAM1 -{ - CD3DX12_PIPELINE_STATE_STREAM1() = default; - // Mesh and amplification shaders must be set manually, since they do not have representation in D3D12_GRAPHICS_PIPELINE_STATE_DESC - CD3DX12_PIPELINE_STATE_STREAM1(const D3D12_GRAPHICS_PIPELINE_STATE_DESC& Desc) noexcept - : Flags(Desc.Flags) - , NodeMask(Desc.NodeMask) - , pRootSignature(Desc.pRootSignature) - , InputLayout(Desc.InputLayout) - , IBStripCutValue(Desc.IBStripCutValue) - , PrimitiveTopologyType(Desc.PrimitiveTopologyType) - , VS(Desc.VS) - , GS(Desc.GS) - , StreamOutput(Desc.StreamOutput) - , HS(Desc.HS) - , DS(Desc.DS) - , PS(Desc.PS) - , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) - , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC1(Desc.DepthStencilState)) - , DSVFormat(Desc.DSVFormat) - , RasterizerState(CD3DX12_RASTERIZER_DESC(Desc.RasterizerState)) - , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) - , SampleDesc(Desc.SampleDesc) - , SampleMask(Desc.SampleMask) - , CachedPSO(Desc.CachedPSO) - , ViewInstancingDesc(CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT())) - {} - CD3DX12_PIPELINE_STATE_STREAM1(const D3DX12_MESH_SHADER_PIPELINE_STATE_DESC& Desc) noexcept - : Flags(Desc.Flags) - , NodeMask(Desc.NodeMask) - , pRootSignature(Desc.pRootSignature) - , PrimitiveTopologyType(Desc.PrimitiveTopologyType) - , PS(Desc.PS) - , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) - , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC1(Desc.DepthStencilState)) - , DSVFormat(Desc.DSVFormat) - , RasterizerState(CD3DX12_RASTERIZER_DESC(Desc.RasterizerState)) - , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) - , SampleDesc(Desc.SampleDesc) - , SampleMask(Desc.SampleMask) - , CachedPSO(Desc.CachedPSO) - , ViewInstancingDesc(CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT())) - {} - CD3DX12_PIPELINE_STATE_STREAM1(const D3D12_COMPUTE_PIPELINE_STATE_DESC& Desc) noexcept - : Flags(Desc.Flags) - , NodeMask(Desc.NodeMask) - , pRootSignature(Desc.pRootSignature) - , CS(CD3DX12_SHADER_BYTECODE(Desc.CS)) - , CachedPSO(Desc.CachedPSO) - { - static_cast(DepthStencilState).DepthEnable = false; - } - CD3DX12_PIPELINE_STATE_STREAM_FLAGS Flags; - CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK NodeMask; - CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE pRootSignature; - CD3DX12_PIPELINE_STATE_STREAM_INPUT_LAYOUT InputLayout; - CD3DX12_PIPELINE_STATE_STREAM_IB_STRIP_CUT_VALUE IBStripCutValue; - CD3DX12_PIPELINE_STATE_STREAM_PRIMITIVE_TOPOLOGY PrimitiveTopologyType; - CD3DX12_PIPELINE_STATE_STREAM_VS VS; - CD3DX12_PIPELINE_STATE_STREAM_GS GS; - CD3DX12_PIPELINE_STATE_STREAM_STREAM_OUTPUT StreamOutput; - CD3DX12_PIPELINE_STATE_STREAM_HS HS; - CD3DX12_PIPELINE_STATE_STREAM_DS DS; - CD3DX12_PIPELINE_STATE_STREAM_PS PS; - CD3DX12_PIPELINE_STATE_STREAM_CS CS; - CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC BlendState; - CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL1 DepthStencilState; - CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL_FORMAT DSVFormat; - CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER RasterizerState; - CD3DX12_PIPELINE_STATE_STREAM_RENDER_TARGET_FORMATS RTVFormats; - CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_DESC SampleDesc; - CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_MASK SampleMask; - CD3DX12_PIPELINE_STATE_STREAM_CACHED_PSO CachedPSO; - CD3DX12_PIPELINE_STATE_STREAM_VIEW_INSTANCING ViewInstancingDesc; - D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDescV0() const noexcept - { - D3D12_GRAPHICS_PIPELINE_STATE_DESC D; - D.Flags = this->Flags; - D.NodeMask = this->NodeMask; - D.pRootSignature = this->pRootSignature; - D.InputLayout = this->InputLayout; - D.IBStripCutValue = this->IBStripCutValue; - D.PrimitiveTopologyType = this->PrimitiveTopologyType; - D.VS = this->VS; - D.GS = this->GS; - D.StreamOutput = this->StreamOutput; - D.HS = this->HS; - D.DS = this->DS; - D.PS = this->PS; - D.BlendState = this->BlendState; - D.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(D3D12_DEPTH_STENCIL_DESC1(this->DepthStencilState)); - D.DSVFormat = this->DSVFormat; - D.RasterizerState = this->RasterizerState; - D.NumRenderTargets = D3D12_RT_FORMAT_ARRAY(this->RTVFormats).NumRenderTargets; - memcpy(D.RTVFormats, D3D12_RT_FORMAT_ARRAY(this->RTVFormats).RTFormats, sizeof(D.RTVFormats)); - D.SampleDesc = this->SampleDesc; - D.SampleMask = this->SampleMask; - D.CachedPSO = this->CachedPSO; - return D; - } - D3D12_COMPUTE_PIPELINE_STATE_DESC ComputeDescV0() const noexcept - { - D3D12_COMPUTE_PIPELINE_STATE_DESC D; - D.Flags = this->Flags; - D.NodeMask = this->NodeMask; - D.pRootSignature = this->pRootSignature; - D.CS = this->CS; - D.CachedPSO = this->CachedPSO; - return D; - } -}; - - -struct CD3DX12_PIPELINE_MESH_STATE_STREAM -{ - CD3DX12_PIPELINE_MESH_STATE_STREAM() = default; - CD3DX12_PIPELINE_MESH_STATE_STREAM(const D3DX12_MESH_SHADER_PIPELINE_STATE_DESC& Desc) noexcept - : Flags(Desc.Flags) - , NodeMask(Desc.NodeMask) - , pRootSignature(Desc.pRootSignature) - , PS(Desc.PS) - , AS(Desc.AS) - , MS(Desc.MS) - , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) - , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC1(Desc.DepthStencilState)) - , DSVFormat(Desc.DSVFormat) - , RasterizerState(CD3DX12_RASTERIZER_DESC(Desc.RasterizerState)) - , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) - , SampleDesc(Desc.SampleDesc) - , SampleMask(Desc.SampleMask) - , CachedPSO(Desc.CachedPSO) - , ViewInstancingDesc(CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT())) - {} - CD3DX12_PIPELINE_STATE_STREAM_FLAGS Flags; - CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK NodeMask; - CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE pRootSignature; - CD3DX12_PIPELINE_STATE_STREAM_PS PS; - CD3DX12_PIPELINE_STATE_STREAM_AS AS; - CD3DX12_PIPELINE_STATE_STREAM_MS MS; - CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC BlendState; - CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL1 DepthStencilState; - CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL_FORMAT DSVFormat; - CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER RasterizerState; - CD3DX12_PIPELINE_STATE_STREAM_RENDER_TARGET_FORMATS RTVFormats; - CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_DESC SampleDesc; - CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_MASK SampleMask; - CD3DX12_PIPELINE_STATE_STREAM_CACHED_PSO CachedPSO; - CD3DX12_PIPELINE_STATE_STREAM_VIEW_INSTANCING ViewInstancingDesc; - D3DX12_MESH_SHADER_PIPELINE_STATE_DESC MeshShaderDescV0() const noexcept - { - D3DX12_MESH_SHADER_PIPELINE_STATE_DESC D; - D.Flags = this->Flags; - D.NodeMask = this->NodeMask; - D.pRootSignature = this->pRootSignature; - D.PS = this->PS; - D.AS = this->AS; - D.MS = this->MS; - D.BlendState = this->BlendState; - D.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(D3D12_DEPTH_STENCIL_DESC1(this->DepthStencilState)); - D.DSVFormat = this->DSVFormat; - D.RasterizerState = this->RasterizerState; - D.NumRenderTargets = D3D12_RT_FORMAT_ARRAY(this->RTVFormats).NumRenderTargets; - memcpy(D.RTVFormats, D3D12_RT_FORMAT_ARRAY(this->RTVFormats).RTFormats, sizeof(D.RTVFormats)); - D.SampleDesc = this->SampleDesc; - D.SampleMask = this->SampleMask; - D.CachedPSO = this->CachedPSO; - return D; - } -}; - -// CD3DX12_PIPELINE_STATE_STREAM works on OS Build 15063+ but does not support new subobject(s) added in OS Build 16299+. -// See CD3DX12_PIPELINE_STATE_STREAM1 for instance. -struct CD3DX12_PIPELINE_STATE_STREAM -{ - CD3DX12_PIPELINE_STATE_STREAM() = default; - CD3DX12_PIPELINE_STATE_STREAM(const D3D12_GRAPHICS_PIPELINE_STATE_DESC& Desc) noexcept - : Flags(Desc.Flags) - , NodeMask(Desc.NodeMask) - , pRootSignature(Desc.pRootSignature) - , InputLayout(Desc.InputLayout) - , IBStripCutValue(Desc.IBStripCutValue) - , PrimitiveTopologyType(Desc.PrimitiveTopologyType) - , VS(Desc.VS) - , GS(Desc.GS) - , StreamOutput(Desc.StreamOutput) - , HS(Desc.HS) - , DS(Desc.DS) - , PS(Desc.PS) - , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) - , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC1(Desc.DepthStencilState)) - , DSVFormat(Desc.DSVFormat) - , RasterizerState(CD3DX12_RASTERIZER_DESC(Desc.RasterizerState)) - , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) - , SampleDesc(Desc.SampleDesc) - , SampleMask(Desc.SampleMask) - , CachedPSO(Desc.CachedPSO) - {} - CD3DX12_PIPELINE_STATE_STREAM(const D3D12_COMPUTE_PIPELINE_STATE_DESC& Desc) noexcept - : Flags(Desc.Flags) - , NodeMask(Desc.NodeMask) - , pRootSignature(Desc.pRootSignature) - , CS(CD3DX12_SHADER_BYTECODE(Desc.CS)) - , CachedPSO(Desc.CachedPSO) - {} - CD3DX12_PIPELINE_STATE_STREAM_FLAGS Flags; - CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK NodeMask; - CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE pRootSignature; - CD3DX12_PIPELINE_STATE_STREAM_INPUT_LAYOUT InputLayout; - CD3DX12_PIPELINE_STATE_STREAM_IB_STRIP_CUT_VALUE IBStripCutValue; - CD3DX12_PIPELINE_STATE_STREAM_PRIMITIVE_TOPOLOGY PrimitiveTopologyType; - CD3DX12_PIPELINE_STATE_STREAM_VS VS; - CD3DX12_PIPELINE_STATE_STREAM_GS GS; - CD3DX12_PIPELINE_STATE_STREAM_STREAM_OUTPUT StreamOutput; - CD3DX12_PIPELINE_STATE_STREAM_HS HS; - CD3DX12_PIPELINE_STATE_STREAM_DS DS; - CD3DX12_PIPELINE_STATE_STREAM_PS PS; - CD3DX12_PIPELINE_STATE_STREAM_CS CS; - CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC BlendState; - CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL1 DepthStencilState; - CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL_FORMAT DSVFormat; - CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER RasterizerState; - CD3DX12_PIPELINE_STATE_STREAM_RENDER_TARGET_FORMATS RTVFormats; - CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_DESC SampleDesc; - CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_MASK SampleMask; - CD3DX12_PIPELINE_STATE_STREAM_CACHED_PSO CachedPSO; - D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDescV0() const noexcept - { - D3D12_GRAPHICS_PIPELINE_STATE_DESC D; - D.Flags = this->Flags; - D.NodeMask = this->NodeMask; - D.pRootSignature = this->pRootSignature; - D.InputLayout = this->InputLayout; - D.IBStripCutValue = this->IBStripCutValue; - D.PrimitiveTopologyType = this->PrimitiveTopologyType; - D.VS = this->VS; - D.GS = this->GS; - D.StreamOutput = this->StreamOutput; - D.HS = this->HS; - D.DS = this->DS; - D.PS = this->PS; - D.BlendState = this->BlendState; - D.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(D3D12_DEPTH_STENCIL_DESC1(this->DepthStencilState)); - D.DSVFormat = this->DSVFormat; - D.RasterizerState = this->RasterizerState; - D.NumRenderTargets = D3D12_RT_FORMAT_ARRAY(this->RTVFormats).NumRenderTargets; - memcpy(D.RTVFormats, D3D12_RT_FORMAT_ARRAY(this->RTVFormats).RTFormats, sizeof(D.RTVFormats)); - D.SampleDesc = this->SampleDesc; - D.SampleMask = this->SampleMask; - D.CachedPSO = this->CachedPSO; - return D; - } - D3D12_COMPUTE_PIPELINE_STATE_DESC ComputeDescV0() const noexcept - { - D3D12_COMPUTE_PIPELINE_STATE_DESC D; - D.Flags = this->Flags; - D.NodeMask = this->NodeMask; - D.pRootSignature = this->pRootSignature; - D.CS = this->CS; - D.CachedPSO = this->CachedPSO; - return D; - } -}; - -struct CD3DX12_PIPELINE_STATE_STREAM2_PARSE_HELPER : public ID3DX12PipelineParserCallbacks -{ - CD3DX12_PIPELINE_STATE_STREAM2 PipelineStream; - CD3DX12_PIPELINE_STATE_STREAM2_PARSE_HELPER() noexcept - : SeenDSS(false) - { - // Adjust defaults to account for absent members. - PipelineStream.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; - - // Depth disabled if no DSV format specified. - static_cast(PipelineStream.DepthStencilState).DepthEnable = false; - } - - // ID3DX12PipelineParserCallbacks - void FlagsCb(D3D12_PIPELINE_STATE_FLAGS Flags) override {PipelineStream.Flags = Flags;} - void NodeMaskCb(UINT NodeMask) override {PipelineStream.NodeMask = NodeMask;} - void RootSignatureCb(ID3D12RootSignature* pRootSignature) override {PipelineStream.pRootSignature = pRootSignature;} - void InputLayoutCb(const D3D12_INPUT_LAYOUT_DESC& InputLayout) override {PipelineStream.InputLayout = InputLayout;} - void IBStripCutValueCb(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue) override {PipelineStream.IBStripCutValue = IBStripCutValue;} - void PrimitiveTopologyTypeCb(D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType) override {PipelineStream.PrimitiveTopologyType = PrimitiveTopologyType;} - void VSCb(const D3D12_SHADER_BYTECODE& VS) override {PipelineStream.VS = VS;} - void GSCb(const D3D12_SHADER_BYTECODE& GS) override {PipelineStream.GS = GS;} - void StreamOutputCb(const D3D12_STREAM_OUTPUT_DESC& StreamOutput) override {PipelineStream.StreamOutput = StreamOutput;} - void HSCb(const D3D12_SHADER_BYTECODE& HS) override {PipelineStream.HS = HS;} - void DSCb(const D3D12_SHADER_BYTECODE& DS) override {PipelineStream.DS = DS;} - void PSCb(const D3D12_SHADER_BYTECODE& PS) override {PipelineStream.PS = PS;} - void CSCb(const D3D12_SHADER_BYTECODE& CS) override {PipelineStream.CS = CS;} - void ASCb(const D3D12_SHADER_BYTECODE& AS) override {PipelineStream.AS = AS;} - void MSCb(const D3D12_SHADER_BYTECODE& MS) override {PipelineStream.MS = MS;} - void BlendStateCb(const D3D12_BLEND_DESC& BlendState) override {PipelineStream.BlendState = CD3DX12_BLEND_DESC(BlendState);} - void DepthStencilStateCb(const D3D12_DEPTH_STENCIL_DESC& DepthStencilState) override - { - PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(DepthStencilState); - SeenDSS = true; - } - void DepthStencilState1Cb(const D3D12_DEPTH_STENCIL_DESC1& DepthStencilState) override - { - PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(DepthStencilState); - SeenDSS = true; - } - void DSVFormatCb(DXGI_FORMAT DSVFormat) override - { - PipelineStream.DSVFormat = DSVFormat; - if (!SeenDSS && DSVFormat != DXGI_FORMAT_UNKNOWN) - { - // Re-enable depth for the default state. - static_cast(PipelineStream.DepthStencilState).DepthEnable = true; - } - } - void RasterizerStateCb(const D3D12_RASTERIZER_DESC& RasterizerState) override {PipelineStream.RasterizerState = CD3DX12_RASTERIZER_DESC(RasterizerState);} - void RTVFormatsCb(const D3D12_RT_FORMAT_ARRAY& RTVFormats) override {PipelineStream.RTVFormats = RTVFormats;} - void SampleDescCb(const DXGI_SAMPLE_DESC& SampleDesc) override {PipelineStream.SampleDesc = SampleDesc;} - void SampleMaskCb(UINT SampleMask) override {PipelineStream.SampleMask = SampleMask;} - void ViewInstancingCb(const D3D12_VIEW_INSTANCING_DESC& ViewInstancingDesc) override {PipelineStream.ViewInstancingDesc = CD3DX12_VIEW_INSTANCING_DESC(ViewInstancingDesc);} - void CachedPSOCb(const D3D12_CACHED_PIPELINE_STATE& CachedPSO) override {PipelineStream.CachedPSO = CachedPSO;} - -private: - bool SeenDSS; -}; - - -struct CD3DX12_PIPELINE_STATE_STREAM_PARSE_HELPER : public ID3DX12PipelineParserCallbacks -{ - CD3DX12_PIPELINE_STATE_STREAM1 PipelineStream; - CD3DX12_PIPELINE_STATE_STREAM_PARSE_HELPER() noexcept - : SeenDSS(false) - { - // Adjust defaults to account for absent members. - PipelineStream.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; - - // Depth disabled if no DSV format specified. - static_cast(PipelineStream.DepthStencilState).DepthEnable = false; - } - - // ID3DX12PipelineParserCallbacks - void FlagsCb(D3D12_PIPELINE_STATE_FLAGS Flags) override {PipelineStream.Flags = Flags;} - void NodeMaskCb(UINT NodeMask) override {PipelineStream.NodeMask = NodeMask;} - void RootSignatureCb(ID3D12RootSignature* pRootSignature) override {PipelineStream.pRootSignature = pRootSignature;} - void InputLayoutCb(const D3D12_INPUT_LAYOUT_DESC& InputLayout) override {PipelineStream.InputLayout = InputLayout;} - void IBStripCutValueCb(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue) override {PipelineStream.IBStripCutValue = IBStripCutValue;} - void PrimitiveTopologyTypeCb(D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType) override {PipelineStream.PrimitiveTopologyType = PrimitiveTopologyType;} - void VSCb(const D3D12_SHADER_BYTECODE& VS) override {PipelineStream.VS = VS;} - void GSCb(const D3D12_SHADER_BYTECODE& GS) override {PipelineStream.GS = GS;} - void StreamOutputCb(const D3D12_STREAM_OUTPUT_DESC& StreamOutput) override {PipelineStream.StreamOutput = StreamOutput;} - void HSCb(const D3D12_SHADER_BYTECODE& HS) override {PipelineStream.HS = HS;} - void DSCb(const D3D12_SHADER_BYTECODE& DS) override {PipelineStream.DS = DS;} - void PSCb(const D3D12_SHADER_BYTECODE& PS) override {PipelineStream.PS = PS;} - void CSCb(const D3D12_SHADER_BYTECODE& CS) override {PipelineStream.CS = CS;} - void BlendStateCb(const D3D12_BLEND_DESC& BlendState) override {PipelineStream.BlendState = CD3DX12_BLEND_DESC(BlendState);} - void DepthStencilStateCb(const D3D12_DEPTH_STENCIL_DESC& DepthStencilState) override - { - PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(DepthStencilState); - SeenDSS = true; - } - void DepthStencilState1Cb(const D3D12_DEPTH_STENCIL_DESC1& DepthStencilState) override - { - PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(DepthStencilState); - SeenDSS = true; - } - void DSVFormatCb(DXGI_FORMAT DSVFormat) override - { - PipelineStream.DSVFormat = DSVFormat; - if (!SeenDSS && DSVFormat != DXGI_FORMAT_UNKNOWN) - { - // Re-enable depth for the default state. - static_cast(PipelineStream.DepthStencilState).DepthEnable = true; - } - } - void RasterizerStateCb(const D3D12_RASTERIZER_DESC& RasterizerState) override {PipelineStream.RasterizerState = CD3DX12_RASTERIZER_DESC(RasterizerState);} - void RTVFormatsCb(const D3D12_RT_FORMAT_ARRAY& RTVFormats) override {PipelineStream.RTVFormats = RTVFormats;} - void SampleDescCb(const DXGI_SAMPLE_DESC& SampleDesc) override {PipelineStream.SampleDesc = SampleDesc;} - void SampleMaskCb(UINT SampleMask) override {PipelineStream.SampleMask = SampleMask;} - void ViewInstancingCb(const D3D12_VIEW_INSTANCING_DESC& ViewInstancingDesc) override {PipelineStream.ViewInstancingDesc = CD3DX12_VIEW_INSTANCING_DESC(ViewInstancingDesc);} - void CachedPSOCb(const D3D12_CACHED_PIPELINE_STATE& CachedPSO) override {PipelineStream.CachedPSO = CachedPSO;} - -private: - bool SeenDSS; -}; - -inline D3D12_PIPELINE_STATE_SUBOBJECT_TYPE D3DX12GetBaseSubobjectType(D3D12_PIPELINE_STATE_SUBOBJECT_TYPE SubobjectType) noexcept -{ - switch (SubobjectType) - { - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1: - return D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL; - default: - return SubobjectType; - } -} - -inline HRESULT D3DX12ParsePipelineStream(const D3D12_PIPELINE_STATE_STREAM_DESC& Desc, ID3DX12PipelineParserCallbacks* pCallbacks) -{ - if (pCallbacks == nullptr) - { - return E_INVALIDARG; - } - - if (Desc.SizeInBytes == 0 || Desc.pPipelineStateSubobjectStream == nullptr) - { - pCallbacks->ErrorBadInputParameter(1); // first parameter issue - return E_INVALIDARG; - } - - bool SubobjectSeen[D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MAX_VALID] = {}; - for (SIZE_T CurOffset = 0, SizeOfSubobject = 0; CurOffset < Desc.SizeInBytes; CurOffset += SizeOfSubobject) - { - BYTE* pStream = static_cast(Desc.pPipelineStateSubobjectStream)+CurOffset; - auto SubobjectType = *reinterpret_cast(pStream); - if (SubobjectType < 0 || SubobjectType >= D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MAX_VALID) - { - pCallbacks->ErrorUnknownSubobject(SubobjectType); - return E_INVALIDARG; - } - if (SubobjectSeen[D3DX12GetBaseSubobjectType(SubobjectType)]) - { - pCallbacks->ErrorDuplicateSubobject(SubobjectType); - return E_INVALIDARG; // disallow subobject duplicates in a stream - } - SubobjectSeen[SubobjectType] = true; - switch (SubobjectType) - { - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_ROOT_SIGNATURE: - pCallbacks->RootSignatureCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::pRootSignature); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VS: - pCallbacks->VSCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::VS); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PS: - pCallbacks->PSCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::PS); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DS: - pCallbacks->DSCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::DS); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_HS: - pCallbacks->HSCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::HS); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_GS: - pCallbacks->GSCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::GS); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CS: - pCallbacks->CSCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::CS); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_AS: - pCallbacks->ASCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM2::AS); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MS: - pCallbacks->MSCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM2::MS); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_STREAM_OUTPUT: - pCallbacks->StreamOutputCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::StreamOutput); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_BLEND: - pCallbacks->BlendStateCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::BlendState); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_MASK: - pCallbacks->SampleMaskCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::SampleMask); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER: - pCallbacks->RasterizerStateCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::RasterizerState); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL: - pCallbacks->DepthStencilStateCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1: - pCallbacks->DepthStencilState1Cb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::DepthStencilState); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_INPUT_LAYOUT: - pCallbacks->InputLayoutCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::InputLayout); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_IB_STRIP_CUT_VALUE: - pCallbacks->IBStripCutValueCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::IBStripCutValue); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PRIMITIVE_TOPOLOGY: - pCallbacks->PrimitiveTopologyTypeCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::PrimitiveTopologyType); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RENDER_TARGET_FORMATS: - pCallbacks->RTVFormatsCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::RTVFormats); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL_FORMAT: - pCallbacks->DSVFormatCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::DSVFormat); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_DESC: - pCallbacks->SampleDescCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::SampleDesc); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_NODE_MASK: - pCallbacks->NodeMaskCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::NodeMask); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CACHED_PSO: - pCallbacks->CachedPSOCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::CachedPSO); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_FLAGS: - pCallbacks->FlagsCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::Flags); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VIEW_INSTANCING: - pCallbacks->ViewInstancingCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM1::ViewInstancingDesc); - break; - default: - pCallbacks->ErrorUnknownSubobject(SubobjectType); - return E_INVALIDARG; - } - } - - return S_OK; -} - -//------------------------------------------------------------------------------------------------ -inline bool operator==( const D3D12_CLEAR_VALUE &a, const D3D12_CLEAR_VALUE &b) noexcept -{ - if (a.Format != b.Format) return false; - if (a.Format == DXGI_FORMAT_D24_UNORM_S8_UINT - || a.Format == DXGI_FORMAT_D16_UNORM - || a.Format == DXGI_FORMAT_D32_FLOAT - || a.Format == DXGI_FORMAT_D32_FLOAT_S8X24_UINT) - { - return (a.DepthStencil.Depth == b.DepthStencil.Depth) && - (a.DepthStencil.Stencil == b.DepthStencil.Stencil); - } else { - return (a.Color[0] == b.Color[0]) && - (a.Color[1] == b.Color[1]) && - (a.Color[2] == b.Color[2]) && - (a.Color[3] == b.Color[3]); - } -} -inline bool operator==( const D3D12_RENDER_PASS_BEGINNING_ACCESS_CLEAR_PARAMETERS &a, const D3D12_RENDER_PASS_BEGINNING_ACCESS_CLEAR_PARAMETERS &b) noexcept -{ - return a.ClearValue == b.ClearValue; -} -inline bool operator==( const D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_PARAMETERS &a, const D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_PARAMETERS &b) noexcept -{ - if (a.pSrcResource != b.pSrcResource) return false; - if (a.pDstResource != b.pDstResource) return false; - if (a.SubresourceCount != b.SubresourceCount) return false; - if (a.Format != b.Format) return false; - if (a.ResolveMode != b.ResolveMode) return false; - if (a.PreserveResolveSource != b.PreserveResolveSource) return false; - return true; -} -inline bool operator==( const D3D12_RENDER_PASS_BEGINNING_ACCESS &a, const D3D12_RENDER_PASS_BEGINNING_ACCESS &b) noexcept -{ - if (a.Type != b.Type) return false; - if (a.Type == D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_CLEAR && !(a.Clear == b.Clear)) return false; - return true; -} -inline bool operator==( const D3D12_RENDER_PASS_ENDING_ACCESS &a, const D3D12_RENDER_PASS_ENDING_ACCESS &b) noexcept -{ - if (a.Type != b.Type) return false; - if (a.Type == D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_RESOLVE && !(a.Resolve == b.Resolve)) return false; - return true; -} -inline bool operator==( const D3D12_RENDER_PASS_RENDER_TARGET_DESC &a, const D3D12_RENDER_PASS_RENDER_TARGET_DESC &b) noexcept -{ - if (a.cpuDescriptor.ptr != b.cpuDescriptor.ptr) return false; - if (!(a.BeginningAccess == b.BeginningAccess)) return false; - if (!(a.EndingAccess == b.EndingAccess)) return false; - return true; -} -inline bool operator==( const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC &a, const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC &b) noexcept -{ - if (a.cpuDescriptor.ptr != b.cpuDescriptor.ptr) return false; - if (!(a.DepthBeginningAccess == b.DepthBeginningAccess)) return false; - if (!(a.StencilBeginningAccess == b.StencilBeginningAccess)) return false; - if (!(a.DepthEndingAccess == b.DepthEndingAccess)) return false; - if (!(a.StencilEndingAccess == b.StencilEndingAccess)) return false; - return true; -} - - -#ifndef D3DX12_NO_STATE_OBJECT_HELPERS - -//================================================================================================ -// D3DX12 State Object Creation Helpers -// -// Helper classes for creating new style state objects out of an arbitrary set of subobjects. -// Uses STL -// -// Start by instantiating CD3DX12_STATE_OBJECT_DESC (see it's public methods). -// One of its methods is CreateSubobject(), which has a comment showing a couple of options for -// defining subobjects using the helper classes for each subobject (CD3DX12_DXIL_LIBRARY_SUBOBJECT -// etc.). The subobject helpers each have methods specific to the subobject for configuring it's -// contents. -// -//================================================================================================ -#include -#include -#include -#include -#ifndef D3DX12_USE_ATL -#include -#define D3DX12_COM_PTR Microsoft::WRL::ComPtr -#define D3DX12_COM_PTR_GET(x) x.Get() -#define D3DX12_COM_PTR_ADDRESSOF(x) x.GetAddressOf() -#else -#include -#define D3DX12_COM_PTR ATL::CComPtr -#define D3DX12_COM_PTR_GET(x) x.p -#define D3DX12_COM_PTR_ADDRESSOF(x) &x.p -#endif - -//------------------------------------------------------------------------------------------------ -class CD3DX12_STATE_OBJECT_DESC -{ -public: - CD3DX12_STATE_OBJECT_DESC() noexcept - { - Init(D3D12_STATE_OBJECT_TYPE_COLLECTION); - } - CD3DX12_STATE_OBJECT_DESC(D3D12_STATE_OBJECT_TYPE Type) noexcept - { - Init(Type); - } - void SetStateObjectType(D3D12_STATE_OBJECT_TYPE Type) noexcept { m_Desc.Type = Type; } - operator const D3D12_STATE_OBJECT_DESC&() - { - // Do final preparation work - m_RepointedAssociations.clear(); - m_SubobjectArray.clear(); - m_SubobjectArray.reserve(m_Desc.NumSubobjects); - // Flatten subobjects into an array (each flattened subobject still has a - // member that's a pointer to it's desc that's not flattened) - for (auto Iter = m_SubobjectList.begin(); - Iter != m_SubobjectList.end(); Iter++) - { - m_SubobjectArray.push_back(*Iter); - // Store new location in array so we can redirect pointers contained in subobjects - Iter->pSubobjectArrayLocation = &m_SubobjectArray.back(); - } - // For subobjects with pointer fields, create a new copy of those subobject definitions - // with fixed pointers - for (UINT i = 0; i < m_Desc.NumSubobjects; i++) - { - if (m_SubobjectArray[i].Type == D3D12_STATE_SUBOBJECT_TYPE_SUBOBJECT_TO_EXPORTS_ASSOCIATION) - { - auto pOriginalSubobjectAssociation = - static_cast(m_SubobjectArray[i].pDesc); - D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION Repointed = *pOriginalSubobjectAssociation; - auto pWrapper = - static_cast(pOriginalSubobjectAssociation->pSubobjectToAssociate); - Repointed.pSubobjectToAssociate = pWrapper->pSubobjectArrayLocation; - m_RepointedAssociations.push_back(Repointed); - m_SubobjectArray[i].pDesc = &m_RepointedAssociations.back(); - } - } - // Below: using ugly way to get pointer in case .data() is not defined - m_Desc.pSubobjects = m_Desc.NumSubobjects ? &m_SubobjectArray[0] : nullptr; - return m_Desc; - } - operator const D3D12_STATE_OBJECT_DESC*() - { - // Cast calls the above final preparation work - return &static_cast(*this); - } - - // CreateSubobject creates a sububject helper (e.g. CD3DX12_HIT_GROUP_SUBOBJECT) - // whose lifetime is owned by this class. - // e.g. - // - // CD3DX12_STATE_OBJECT_DESC Collection1(D3D12_STATE_OBJECT_TYPE_COLLECTION); - // auto Lib0 = Collection1.CreateSubobject(); - // Lib0->SetDXILLibrary(&pMyAppDxilLibs[0]); - // Lib0->DefineExport(L"rayGenShader0"); // in practice these export listings might be - // // data/engine driven - // etc. - // - // Alternatively, users can instantiate sububject helpers explicitly, such as via local - // variables instead, passing the state object desc that should point to it into the helper - // constructor (or call mySubobjectHelper.AddToStateObject(Collection1)). - // In this alternative scenario, the user must keep the subobject alive as long as the state - // object it is associated with is alive, else it's pointer references will be stale. - // e.g. - // - // CD3DX12_STATE_OBJECT_DESC RaytracingState2(D3D12_STATE_OBJECT_TYPE_RAYTRACING_PIPELINE); - // CD3DX12_DXIL_LIBRARY_SUBOBJECT LibA(RaytracingState2); - // LibA.SetDXILLibrary(&pMyAppDxilLibs[4]); // not manually specifying exports - // // - meaning all exports in the libraries - // // are exported - // etc. - - template - T* CreateSubobject() - { - T* pSubobject = new T(*this); - m_OwnedSubobjectHelpers.emplace_back(pSubobject); - return pSubobject; - } - -private: - D3D12_STATE_SUBOBJECT* TrackSubobject(D3D12_STATE_SUBOBJECT_TYPE Type, void* pDesc) - { - SUBOBJECT_WRAPPER Subobject; - Subobject.pSubobjectArrayLocation = nullptr; - Subobject.Type = Type; - Subobject.pDesc = pDesc; - m_SubobjectList.push_back(Subobject); - m_Desc.NumSubobjects++; - return &m_SubobjectList.back(); - } - void Init(D3D12_STATE_OBJECT_TYPE Type) noexcept - { - SetStateObjectType(Type); - m_Desc.pSubobjects = nullptr; - m_Desc.NumSubobjects = 0; - m_SubobjectList.clear(); - m_SubobjectArray.clear(); - m_RepointedAssociations.clear(); - } - typedef struct SUBOBJECT_WRAPPER : public D3D12_STATE_SUBOBJECT - { - D3D12_STATE_SUBOBJECT* pSubobjectArrayLocation; // new location when flattened into array - // for repointing pointers in subobjects - } SUBOBJECT_WRAPPER; - D3D12_STATE_OBJECT_DESC m_Desc; - std::list m_SubobjectList; // Pointers to list nodes handed out so - // these can be edited live - std::vector m_SubobjectArray; // Built at the end, copying list contents - - std::list - m_RepointedAssociations; // subobject type that contains pointers to other subobjects, - // repointed to flattened array - - class StringContainer - { - public: - LPCWSTR LocalCopy(LPCWSTR string, bool bSingleString = false) - { - if (string) - { - if (bSingleString) - { - m_Strings.clear(); - m_Strings.push_back(string); - } - else - { - m_Strings.push_back(string); - } - return m_Strings.back().c_str(); - } - else - { - return nullptr; - } - } - void clear() noexcept { m_Strings.clear(); } - private: - std::list m_Strings; - }; - - class SUBOBJECT_HELPER_BASE - { - public: - SUBOBJECT_HELPER_BASE() noexcept { Init(); } - virtual ~SUBOBJECT_HELPER_BASE() = default; - virtual D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept = 0; - void AddToStateObject(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - m_pSubobject = ContainingStateObject.TrackSubobject(Type(), Data()); - } - protected: - virtual void* Data() noexcept = 0; - void Init() noexcept { m_pSubobject = nullptr; } - D3D12_STATE_SUBOBJECT* m_pSubobject; - }; - -#if(__cplusplus >= 201103L) - std::list> m_OwnedSubobjectHelpers; -#else - class OWNED_HELPER - { - public: - OWNED_HELPER(const SUBOBJECT_HELPER_BASE* pHelper) noexcept { m_pHelper = pHelper; } - ~OWNED_HELPER() { delete m_pHelper; } - const SUBOBJECT_HELPER_BASE* m_pHelper; - }; - - std::list m_OwnedSubobjectHelpers; -#endif - - friend class CD3DX12_DXIL_LIBRARY_SUBOBJECT; - friend class CD3DX12_EXISTING_COLLECTION_SUBOBJECT; - friend class CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT; - friend class CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION; - friend class CD3DX12_HIT_GROUP_SUBOBJECT; - friend class CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT; - friend class CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT; - friend class CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT; - friend class CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT; - friend class CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT; - friend class CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT; - friend class CD3DX12_NODE_MASK_SUBOBJECT; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_DXIL_LIBRARY_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_DXIL_LIBRARY_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_DXIL_LIBRARY_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void SetDXILLibrary(const D3D12_SHADER_BYTECODE* pCode) noexcept - { - static const D3D12_SHADER_BYTECODE Default = {}; - m_Desc.DXILLibrary = pCode ? *pCode : Default; - } - void DefineExport( - LPCWSTR Name, - LPCWSTR ExportToRename = nullptr, - D3D12_EXPORT_FLAGS Flags = D3D12_EXPORT_FLAG_NONE) - { - D3D12_EXPORT_DESC Export; - Export.Name = m_Strings.LocalCopy(Name); - Export.ExportToRename = m_Strings.LocalCopy(ExportToRename); - Export.Flags = Flags; - m_Exports.push_back(Export); - m_Desc.pExports = &m_Exports[0]; // using ugly way to get pointer in case .data() is not defined - m_Desc.NumExports = static_cast(m_Exports.size()); - } - template - void DefineExports(LPCWSTR(&Exports)[N]) - { - for (UINT i = 0; i < N; i++) - { - DefineExport(Exports[i]); - } - } - void DefineExports(const LPCWSTR* Exports, UINT N) - { - for (UINT i = 0; i < N; i++) - { - DefineExport(Exports[i]); - } - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_DXIL_LIBRARY; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator const D3D12_DXIL_LIBRARY_DESC&() const noexcept { return m_Desc; } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_Desc = {}; - m_Strings.clear(); - m_Exports.clear(); - } - void* Data() noexcept override { return &m_Desc; } - D3D12_DXIL_LIBRARY_DESC m_Desc; - CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings; - std::vector m_Exports; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_EXISTING_COLLECTION_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_EXISTING_COLLECTION_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_EXISTING_COLLECTION_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void SetExistingCollection(ID3D12StateObject*pExistingCollection) noexcept - { - m_Desc.pExistingCollection = pExistingCollection; - m_CollectionRef = pExistingCollection; - } - void DefineExport( - LPCWSTR Name, - LPCWSTR ExportToRename = nullptr, - D3D12_EXPORT_FLAGS Flags = D3D12_EXPORT_FLAG_NONE) - { - D3D12_EXPORT_DESC Export; - Export.Name = m_Strings.LocalCopy(Name); - Export.ExportToRename = m_Strings.LocalCopy(ExportToRename); - Export.Flags = Flags; - m_Exports.push_back(Export); - m_Desc.pExports = &m_Exports[0]; // using ugly way to get pointer in case .data() is not defined - m_Desc.NumExports = static_cast(m_Exports.size()); - } - template - void DefineExports(LPCWSTR(&Exports)[N]) - { - for (UINT i = 0; i < N; i++) - { - DefineExport(Exports[i]); - } - } - void DefineExports(const LPCWSTR* Exports, UINT N) - { - for (UINT i = 0; i < N; i++) - { - DefineExport(Exports[i]); - } - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_EXISTING_COLLECTION; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator const D3D12_EXISTING_COLLECTION_DESC&() const noexcept { return m_Desc; } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_Desc = {}; - m_CollectionRef = nullptr; - m_Strings.clear(); - m_Exports.clear(); - } - void* Data() noexcept override { return &m_Desc; } - D3D12_EXISTING_COLLECTION_DESC m_Desc; - D3DX12_COM_PTR m_CollectionRef; - CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings; - std::vector m_Exports; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void SetSubobjectToAssociate(const D3D12_STATE_SUBOBJECT& SubobjectToAssociate) noexcept - { - m_Desc.pSubobjectToAssociate = &SubobjectToAssociate; - } - void AddExport(LPCWSTR Export) - { - m_Desc.NumExports++; - m_Exports.push_back(m_Strings.LocalCopy(Export)); - m_Desc.pExports = &m_Exports[0]; // using ugly way to get pointer in case .data() is not defined - } - template - void AddExports(LPCWSTR (&Exports)[N]) - { - for (UINT i = 0; i < N; i++) - { - AddExport(Exports[i]); - } - } - void AddExports(const LPCWSTR* Exports, UINT N) - { - for (UINT i = 0; i < N; i++) - { - AddExport(Exports[i]); - } - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_SUBOBJECT_TO_EXPORTS_ASSOCIATION; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator const D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION&() const noexcept { return m_Desc; } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_Desc = {}; - m_Strings.clear(); - m_Exports.clear(); - } - void* Data() noexcept override { return &m_Desc; } - D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION m_Desc; - CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings; - std::vector m_Exports; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION() noexcept - { - Init(); - } - CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void SetSubobjectNameToAssociate(LPCWSTR SubobjectToAssociate) - { - m_Desc.SubobjectToAssociate = m_SubobjectName.LocalCopy(SubobjectToAssociate, true); - } - void AddExport(LPCWSTR Export) - { - m_Desc.NumExports++; - m_Exports.push_back(m_Strings.LocalCopy(Export)); - m_Desc.pExports = &m_Exports[0]; // using ugly way to get pointer in case .data() is not defined - } - template - void AddExports(LPCWSTR (&Exports)[N]) - { - for (UINT i = 0; i < N; i++) - { - AddExport(Exports[i]); - } - } - void AddExports(const LPCWSTR* Exports, UINT N) - { - for (UINT i = 0; i < N; i++) - { - AddExport(Exports[i]); - } - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator const D3D12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION&() const noexcept { return m_Desc; } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_Desc = {}; - m_Strings.clear(); - m_SubobjectName.clear(); - m_Exports.clear(); - } - void* Data() noexcept override { return &m_Desc; } - D3D12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION m_Desc; - CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings; - CD3DX12_STATE_OBJECT_DESC::StringContainer m_SubobjectName; - std::vector m_Exports; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_HIT_GROUP_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_HIT_GROUP_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_HIT_GROUP_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void SetHitGroupExport(LPCWSTR exportName) - { - m_Desc.HitGroupExport = m_Strings[0].LocalCopy(exportName, true); - } - void SetHitGroupType(D3D12_HIT_GROUP_TYPE Type) noexcept { m_Desc.Type = Type; } - void SetAnyHitShaderImport(LPCWSTR importName) - { - m_Desc.AnyHitShaderImport = m_Strings[1].LocalCopy(importName, true); - } - void SetClosestHitShaderImport(LPCWSTR importName) - { - m_Desc.ClosestHitShaderImport = m_Strings[2].LocalCopy(importName, true); - } - void SetIntersectionShaderImport(LPCWSTR importName) - { - m_Desc.IntersectionShaderImport = m_Strings[3].LocalCopy(importName, true); - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_HIT_GROUP; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator const D3D12_HIT_GROUP_DESC&() const noexcept { return m_Desc; } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_Desc = {}; - for (UINT i = 0; i < m_NumStrings; i++) - { - m_Strings[i].clear(); - } - } - void* Data() noexcept override { return &m_Desc; } - D3D12_HIT_GROUP_DESC m_Desc; - static const UINT m_NumStrings = 4; - CD3DX12_STATE_OBJECT_DESC::StringContainer - m_Strings[m_NumStrings]; // one string for every entrypoint name -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void Config(UINT MaxPayloadSizeInBytes, UINT MaxAttributeSizeInBytes) noexcept - { - m_Desc.MaxPayloadSizeInBytes = MaxPayloadSizeInBytes; - m_Desc.MaxAttributeSizeInBytes = MaxAttributeSizeInBytes; - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_SHADER_CONFIG; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator const D3D12_RAYTRACING_SHADER_CONFIG&() const noexcept { return m_Desc; } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_Desc = {}; - } - void* Data() noexcept override { return &m_Desc; } - D3D12_RAYTRACING_SHADER_CONFIG m_Desc; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void Config(UINT MaxTraceRecursionDepth) noexcept - { - m_Desc.MaxTraceRecursionDepth = MaxTraceRecursionDepth; - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_PIPELINE_CONFIG; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator const D3D12_RAYTRACING_PIPELINE_CONFIG&() const noexcept { return m_Desc; } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_Desc = {}; - } - void* Data() noexcept override { return &m_Desc; } - D3D12_RAYTRACING_PIPELINE_CONFIG m_Desc; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void Config(UINT MaxTraceRecursionDepth, D3D12_RAYTRACING_PIPELINE_FLAGS Flags) noexcept - { - m_Desc.MaxTraceRecursionDepth = MaxTraceRecursionDepth; - m_Desc.Flags = Flags; - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_PIPELINE_CONFIG1; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator const D3D12_RAYTRACING_PIPELINE_CONFIG1&() const noexcept { return m_Desc; } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_Desc = {}; - } - void* Data() noexcept override { return &m_Desc; } - D3D12_RAYTRACING_PIPELINE_CONFIG1 m_Desc; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void SetRootSignature(ID3D12RootSignature* pRootSig) noexcept - { - m_pRootSig = pRootSig; - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_GLOBAL_ROOT_SIGNATURE; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator ID3D12RootSignature*() const noexcept { return D3DX12_COM_PTR_GET(m_pRootSig); } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_pRootSig = nullptr; - } - void* Data() noexcept override { return D3DX12_COM_PTR_ADDRESSOF(m_pRootSig); } - D3DX12_COM_PTR m_pRootSig; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void SetRootSignature(ID3D12RootSignature* pRootSig) noexcept - { - m_pRootSig = pRootSig; - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_LOCAL_ROOT_SIGNATURE; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator ID3D12RootSignature*() const noexcept { return D3DX12_COM_PTR_GET(m_pRootSig); } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_pRootSig = nullptr; - } - void* Data() noexcept override { return D3DX12_COM_PTR_ADDRESSOF(m_pRootSig); } - D3DX12_COM_PTR m_pRootSig; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void SetFlags(D3D12_STATE_OBJECT_FLAGS Flags) noexcept - { - m_Desc.Flags = Flags; - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_STATE_OBJECT_CONFIG; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator const D3D12_STATE_OBJECT_CONFIG&() const noexcept { return m_Desc; } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_Desc = {}; - } - void* Data() noexcept override { return &m_Desc; } - D3D12_STATE_OBJECT_CONFIG m_Desc; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_NODE_MASK_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_NODE_MASK_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_NODE_MASK_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void SetNodeMask(UINT NodeMask) noexcept - { - m_Desc.NodeMask = NodeMask; - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_NODE_MASK; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator const D3D12_NODE_MASK&() const noexcept { return m_Desc; } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_Desc = {}; - } - void* Data() noexcept override { return &m_Desc; } - D3D12_NODE_MASK m_Desc; -}; - -#undef D3DX12_COM_PTR -#undef D3DX12_COM_PTR_GET -#undef D3DX12_COM_PTR_ADDRESSOF -#endif // #ifndef D3DX12_NO_STATE_OBJECT_HELPERS - -#endif // defined( __cplusplus ) - -#endif //__D3DX12_H__ - - diff --git a/xess/samples/basic_sample/shaders.hlsl b/xess/samples/basic_sample/shaders.hlsl deleted file mode 100644 index 39649e2..0000000 --- a/xess/samples/basic_sample/shaders.hlsl +++ /dev/null @@ -1,97 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -cbuffer SceneConstantBuffer : register(b0) -{ - float4 offset; - float4 velocity; - float4 resolution; - float4 padding[13]; -}; - -struct PSInput -{ - float4 position : SV_POSITION; - float4 color : COLOR; -}; - -struct PSOutputColor -{ - float4 Color: SV_Target0; -}; - -PSInput VSMainColor(float4 position : POSITION, float4 color : COLOR) -{ - PSInput result; - - result.position = float4(position.xyz, 1.); - result.position.xy += offset.xy + 2. * (offset.zw / resolution.xy); - result.color = color; - - return result; -} - -PSOutputColor PSMainColor(PSInput input) : SV_TARGET -{ - PSOutputColor output; - output.Color = input.color; - - return output; -} - -PSInput VSMainVelocity(float4 position : POSITION, float4 color : COLOR) -{ - PSInput result; - - result.position = position; - result.position.xy += offset.xy + 2. * (offset.zw / resolution.xy ); - result.color = color; - - return result; -} - -struct PSOutputVelocity -{ - float2 Velocity: SV_Target0; -}; - -PSOutputVelocity PSMainVelocity(PSInput input) : SV_TARGET -{ - PSOutputVelocity output; - output.Velocity = velocity.xy; - - return output; -} - -struct PSInputFSQ -{ - float4 position: SV_POSITION; - float2 texcoord: TEXCOORD; -}; - -Texture2D input_color: register(t0); -SamplerState samp: register(s0); - -PSInputFSQ VSMainFSQ(uint vertex_id: SV_VERTEXID) -{ - PSInputFSQ output; - output.texcoord = float2(vertex_id & 2, (vertex_id << 1) & 2); - output.position = float4(output.texcoord * 2.0 - 1.0, 0.0, 1.0); - output.texcoord.y = 1.0f - output.texcoord.y; - - return output; -} - -float4 PSMainFSQ(PSInputFSQ input) : SV_TARGET -{ - return input_color.Sample(samp, input.texcoord); -} - diff --git a/xess/samples/basic_sample/stdafx.cpp b/xess/samples/basic_sample/stdafx.cpp deleted file mode 100644 index a6533dc..0000000 --- a/xess/samples/basic_sample/stdafx.cpp +++ /dev/null @@ -1,12 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -#include "stdafx.h" diff --git a/xess/samples/basic_sample/stdafx.h b/xess/samples/basic_sample/stdafx.h deleted file mode 100644 index 23137b8..0000000 --- a/xess/samples/basic_sample/stdafx.h +++ /dev/null @@ -1,38 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently. - -#pragma once - -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers. -#endif - -#pragma warning(push) -#pragma warning(disable : 4265) - -#include - -#include -#include -#include -#include -#include -#include -#include - -#pragma warning(pop) - -#include "d3dx12.h" - diff --git a/xess/samples/basic_sample/utils.cpp b/xess/samples/basic_sample/utils.cpp deleted file mode 100644 index 1fe605e..0000000 --- a/xess/samples/basic_sample/utils.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * INTEL CONFIDENTIAL - * - * Copyright (C) 2021 Intel Corporation - * - * This software and the related documents are Intel copyrighted materials, and - * your use of them is governed by the express license under which they were - * provided to you ("License"). Unless the License provides otherwise, you may - * not use, modify, copy, publish, distribute, disclose or transmit this - * software or the related documents without Intel's prior written permission. - * - * This software and the related documents are provided as is, with no express - * or implied warranties, other than those that are expressly stated in the - * License. - ******************************************************************************/ - -#include "utils.h" - -namespace -{ - float GetCorput(std::uint32_t index, std::uint32_t base) - { - float result = 0; - float bk = 1.f; - - while (index > 0) - { - bk /= (float)base; - result += (float)(index % base) * bk; - index /= base; - } - - return result; - } -} - - -std::vector> Utils::GenerateHalton(std::uint32_t base1, std::uint32_t base2, - std::uint32_t start_index, std::uint32_t count, float offset1, float offset2) -{ - std::vector> result; - result.reserve(count); - - for (std::uint32_t a = start_index; a < count + start_index; ++a) - { - result.emplace_back(GetCorput(a, base1) + offset1, GetCorput(a, base2) + offset2); - } - return result; -} diff --git a/xess/samples/basic_sample/utils.h b/xess/samples/basic_sample/utils.h deleted file mode 100644 index 1b56158..0000000 --- a/xess/samples/basic_sample/utils.h +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * INTEL CONFIDENTIAL - * - * Copyright (C) 2021 Intel Corporation - * - * This software and the related documents are Intel copyrighted materials, and - * your use of them is governed by the express license under which they were - * provided to you ("License"). Unless the License provides otherwise, you may - * not use, modify, copy, publish, distribute, disclose or transmit this - * software or the related documents without Intel's prior written permission. - * - * This software and the related documents are provided as is, with no express - * or implied warranties, other than those that are expressly stated in the - * License. - ******************************************************************************/ - -#pragma once - -#include -#include -#include - -namespace Utils -{ -/** - * Generates halton sequence with optional point shift using van der Corput sequence - * @param base1 - base for first Corput sequence (X coordinate) - * @param base2 - base for second Corput sequence (Y coordinate) - * @param start_index - initial index for halton set - * @param offset1 - offset for first Corput sequence - * @param offset2 - offset for second Corput sequence - * @return vector of pairs with two sets - */ -std::vector> GenerateHalton(std::uint32_t base1, std::uint32_t base2, - std::uint32_t start_index, std::uint32_t count, float offset1 = -0.5f, float offset2 = -0.5f); -} diff --git a/xess/samples/license.txt b/xess/samples/license.txt deleted file mode 100644 index e38f4e1..0000000 --- a/xess/samples/license.txt +++ /dev/null @@ -1,21 +0,0 @@ - The MIT License (MIT) - -Copyright (c) 2014-2022 Microsoft Corp -Copyright (c) 2022 Intel Corporation - -Permission is hereby granted, free of charge, to any person obtaining a copy of this -software and associated documentation files (the "Software"), to deal in the Software -without restriction, including without limitation the rights to use, copy, modify, -merge, publish, distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE -OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/xess/samples/xess_demo/Assets/Particle/fire.dds b/xess/samples/xess_demo/Assets/Particle/fire.dds deleted file mode 100644 index a6ccd85..0000000 Binary files a/xess/samples/xess_demo/Assets/Particle/fire.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Particle/particles.json b/xess/samples/xess_demo/Assets/Particle/particles.json deleted file mode 100644 index 5976f59..0000000 --- a/xess/samples/xess_demo/Assets/Particle/particles.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "ParticleEmitters": [ - { - "TexturePath": "Particle/sparkTex.dds", - "MinStartColor": [ 1, 1, 1, 0 ], - "MaxStartColor": [ 1, 1, 1, 0 ], - "MinEndColor": [ 1, 1, 1, 0 ], - "MaxEndColor": [ 1, 1, 1, 0 ], - "TotalActiveLifetime": 0.0, - "Size": [ 4, 8, 4, 8 ], - "Velocity": [ 20, 200, 50, 180 ], - "LifeMinMax": [ 1, 3 ], - "MassMinMax": [ 4.5, 15 ], - "EmitProperties": { - "Gravity": [ 0, -100, 0 ], - "FloorHeight": -0.5, - "EmitPosW": [ -1200, 185, -445 ], - "LastEmitPosW": [ -1200, 185, -445 ], - "MaxParticles": 800 - }, - "EmitRate": 64, - "Spread": [ 20, 50, 0.1 ] - }, - - { - "TexturePath": "Particle/smoke.dds", - "TotalActiveLifetime": 0.0, - "EmitProperties": { - "MaxParticles": 25, - "EmitPosW": [ 1120, 185, -445 ], - "LastEmitPosW": [ 1120, 185, -445 ] - }, - "EmitRate": 64, - "LifeMinMax": [ 2.5, 4 ], - "Size": [ 60, 108, 30, 208 ], - "Velocity": [ 30, 30, 10, 40 ], - "MassMinMax": [ 1, 3.5 ], - "Spread": [ 60, 70, 20 ] - }, - - { - "TexturePath": "Particle/fire.dds", - "TotalActiveLifetime": 0.0, - "MinStartColor": [ 8, 8, 8, 0 ], - "MaxStartColor": [ 8, 8, 8, 0 ], - "MinEndColor": [ 8, 8, 8, 0 ], - "MaxEndColor": [ 8, 8, 8, 0 ], - - "Size": [ 54, 68, 0.1, 0.3 ], - "Velocity": [ 10, 30, 50, 50 ], - "LifeMinMax": [ 1, 3 ], - "MassMinMax": [ 10.5, 14.0 ], - "EmitProperties": { - "Gravity": [ 0, 1, 0 ], - "EmitPosW": [ 1120, 125, 405 ], - "LastEmitPosW": [ 1120, 125, 405 ], - "MaxParticles": 25 - }, - "EmitRate": 64, - "Spread": [1, 60, 0.1] - } - - ] -} \ No newline at end of file diff --git a/xess/samples/xess_demo/Assets/Particle/smoke.dds b/xess/samples/xess_demo/Assets/Particle/smoke.dds deleted file mode 100644 index d83fcd9..0000000 Binary files a/xess/samples/xess_demo/Assets/Particle/smoke.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Particle/sparkTex.dds b/xess/samples/xess_demo/Assets/Particle/sparkTex.dds deleted file mode 100644 index f4950c5..0000000 Binary files a/xess/samples/xess_demo/Assets/Particle/sparkTex.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/README.txt b/xess/samples/xess_demo/Assets/Sponza/README.txt deleted file mode 100644 index d18ce3b..0000000 --- a/xess/samples/xess_demo/Assets/Sponza/README.txt +++ /dev/null @@ -1 +0,0 @@ -The original PBR version of Sponza within MiniEngine is modifed to reduce the overal size. \ No newline at end of file diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/background_baseColor.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/background_baseColor.jpg deleted file mode 100644 index 33a2f9b..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/background_baseColor.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/background_basecolor.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/background_basecolor.dds deleted file mode 100644 index 46e72b1..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/background_basecolor.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/background_metallicRoughness.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/background_metallicRoughness.jpg deleted file mode 100644 index 3bbb5e6..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/background_metallicRoughness.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/background_metallicroughness.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/background_metallicroughness.dds deleted file mode 100644 index 3f8ec73..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/background_metallicroughness.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/background_normal.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/background_normal.dds deleted file mode 100644 index 4993579..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/background_normal.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/background_normal.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/background_normal.jpg deleted file mode 100644 index af38c77..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/background_normal.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/chain_texture_baseColor.png b/xess/samples/xess_demo/Assets/Sponza/pbr/chain_texture_baseColor.png deleted file mode 100644 index 3f6c633..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/chain_texture_baseColor.png and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/chain_texture_basecolor.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/chain_texture_basecolor.dds deleted file mode 100644 index 023dd98..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/chain_texture_basecolor.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/chain_texture_metallicRoughness.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/chain_texture_metallicRoughness.jpg deleted file mode 100644 index 40dae15..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/chain_texture_metallicRoughness.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/chain_texture_metallicroughness.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/chain_texture_metallicroughness.dds deleted file mode 100644 index 836fd1a..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/chain_texture_metallicroughness.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/chain_texture_normal.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/chain_texture_normal.dds deleted file mode 100644 index 650dd24..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/chain_texture_normal.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/chain_texture_normal.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/chain_texture_normal.jpg deleted file mode 100644 index 398844d..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/chain_texture_normal.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/copyright.txt b/xess/samples/xess_demo/Assets/Sponza/pbr/copyright.txt deleted file mode 100644 index a71ea1b..0000000 --- a/xess/samples/xess_demo/Assets/Sponza/pbr/copyright.txt +++ /dev/null @@ -1,31 +0,0 @@ -PBR textures for the Sponza model. -For more informations: www.alexandre-pestana.com - - -Original copyright: - -July 14, 2011 Morgan McGuire modified the model from Crytek's OBJ -export to correct some small errors. He computed bump maps from the -normal maps using normal2bump.cpp (since -MTL files expect height bumps, not normals), put the "mask" textures -into the alpha channel of the associated diffuse texture, cleaned up -noise in the masks, created the missing gi_flag.tga texture, and -removed the long untextured banner floating in the middle of the -atrium that appears in the file but in none of the published images of -the model. The banner is in banner.obj. - - - -http://www.crytek.com/cryengine/cryengine3/downloads - - -Sponza Model -August 19, 2010 -The Atrium Sponza Palace, Dubrovnik, is an elegant and improved model created by Frank Meinl. The original Sponza model was created by Marko Dabrovic in early 2002. Over the years, the Sponza Atrium scene has become one of the most popular 3D scenes for testing global illumination and radiosity due to it's specific architectural structure which is particularly complex for global illumination light. - -However, nowadays it is considered as a simple model, thus it was decided to crate a new model with highly improved appearance and scene complexity. It is donated to the public for radiosity and is represented in several different formats (3ds, Obj) for use with various commercial 3D applications and renderers. - - -Screenshot from the I3D paper -http://crytek.com/sites/default/files/20100301_lpv.pdf diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/lion_baseColor.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/lion_baseColor.jpg deleted file mode 100644 index 86c1040..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/lion_baseColor.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/lion_basecolor.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/lion_basecolor.dds deleted file mode 100644 index f978746..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/lion_basecolor.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/lion_metallicRoughness.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/lion_metallicRoughness.jpg deleted file mode 100644 index 8366eb0..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/lion_metallicRoughness.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/lion_metallicroughness.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/lion_metallicroughness.dds deleted file mode 100644 index 7e4f215..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/lion_metallicroughness.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/lion_normal.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/lion_normal.dds deleted file mode 100644 index c7ca1eb..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/lion_normal.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/lion_normal.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/lion_normal.jpg deleted file mode 100644 index 1976c79..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/lion_normal.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza2.bin b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza2.bin deleted file mode 100644 index b00b6d0..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza2.bin and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza2.gltf b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza2.gltf deleted file mode 100644 index 36aeb4a..0000000 --- a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza2.gltf +++ /dev/null @@ -1,28895 +0,0 @@ -{ - "asset" : { - "generator" : "Khronos glTF Blender I/O v1.8.19", - "version" : "2.0" - }, - "scene" : 0, - "scenes" : [ - { - "name" : "Scene", - "nodes" : [ - 0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 59, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, - 68, - 69, - 70, - 71, - 72, - 73, - 74, - 75, - 76, - 77, - 78, - 79, - 80, - 81, - 82, - 83, - 84, - 85, - 86, - 87, - 88, - 89, - 90, - 91, - 92, - 93, - 94, - 95, - 96, - 97, - 98, - 99, - 100, - 101, - 102, - 103, - 104, - 105, - 106, - 107, - 108, - 109, - 110, - 111, - 112, - 113, - 114, - 115, - 116, - 117, - 118, - 119, - 120, - 121, - 122, - 123, - 124, - 125, - 126, - 127, - 128, - 129, - 130, - 131, - 132, - 133, - 134, - 135, - 136, - 137, - 138, - 139, - 140, - 141, - 142, - 143, - 144, - 145, - 146, - 147, - 148, - 149, - 150, - 151, - 152, - 153, - 154, - 155, - 156, - 157, - 158, - 159, - 160, - 161, - 162, - 163, - 164, - 165, - 166, - 167, - 168, - 169, - 170, - 171, - 172, - 173, - 174, - 175, - 176, - 177, - 178, - 179, - 180, - 181, - 182, - 183, - 184, - 185, - 186, - 187, - 188, - 189, - 190, - 191, - 192, - 193, - 194, - 195, - 196, - 197, - 198, - 199, - 200, - 201, - 202, - 203, - 204, - 205, - 206, - 207, - 208, - 209, - 210, - 211, - 212, - 213, - 214, - 215, - 216, - 217, - 218, - 219, - 220, - 221, - 222, - 223, - 224, - 225, - 226, - 227, - 228, - 229, - 230, - 231, - 232, - 233, - 234, - 235, - 236, - 237, - 238, - 239, - 240, - 241, - 242, - 243, - 244, - 245, - 246, - 247, - 248, - 249, - 250, - 251, - 252, - 253, - 254, - 255, - 256, - 257, - 258, - 259, - 260, - 261, - 262, - 263, - 264, - 265, - 266, - 267, - 268, - 269, - 270, - 271, - 272, - 273, - 274, - 275, - 276, - 277, - 278, - 279, - 280, - 281, - 282, - 283, - 284, - 285, - 286, - 287, - 288, - 289, - 290, - 291, - 292, - 293, - 294, - 295, - 296, - 297, - 298, - 299, - 300, - 301, - 302, - 303, - 304, - 305, - 306, - 307, - 308, - 309, - 310, - 311, - 312, - 313, - 314, - 315, - 316, - 317, - 318, - 319, - 320, - 321, - 322, - 323, - 324, - 325, - 326, - 327, - 328, - 329, - 330, - 331, - 332, - 333, - 334, - 335, - 336, - 337, - 338, - 339, - 340, - 341, - 342, - 343, - 344, - 345, - 346, - 347, - 348, - 349, - 350, - 351, - 352, - 353, - 354, - 355, - 356, - 357, - 358, - 359, - 360, - 361, - 362, - 363, - 364, - 365, - 366, - 367, - 368, - 369, - 370, - 371, - 372, - 373, - 374, - 375, - 376, - 377, - 378, - 379, - 380 - ] - } - ], - "nodes" : [ - { - "mesh" : 0, - "name" : "Mesh_0" - }, - { - "mesh" : 1, - "name" : "Mesh_1" - }, - { - "mesh" : 2, - "name" : "Mesh_2" - }, - { - "mesh" : 3, - "name" : "Mesh_3" - }, - { - "mesh" : 4, - "name" : "Mesh_4" - }, - { - "mesh" : 5, - "name" : "Mesh_5" - }, - { - "mesh" : 6, - "name" : "Mesh_6" - }, - { - "mesh" : 7, - "name" : "Mesh_7" - }, - { - "mesh" : 8, - "name" : "Mesh_18" - }, - { - "mesh" : 9, - "name" : "Mesh_8" - }, - { - "mesh" : 10, - "name" : "Mesh_9" - }, - { - "mesh" : 11, - "name" : "Mesh_10" - }, - { - "mesh" : 12, - "name" : "Mesh_11" - }, - { - "mesh" : 13, - "name" : "Mesh_12" - }, - { - "mesh" : 14, - "name" : "Mesh_13" - }, - { - "mesh" : 15, - "name" : "Mesh_14" - }, - { - "mesh" : 16, - "name" : "Mesh_15" - }, - { - "mesh" : 17, - "name" : "Mesh_16" - }, - { - "mesh" : 18, - "name" : "Mesh_17" - }, - { - "mesh" : 19, - "name" : "Mesh_29" - }, - { - "mesh" : 20, - "name" : "Mesh_19" - }, - { - "mesh" : 21, - "name" : "Mesh_20" - }, - { - "mesh" : 22, - "name" : "Mesh_21" - }, - { - "mesh" : 23, - "name" : "Mesh_22" - }, - { - "mesh" : 24, - "name" : "Mesh_23" - }, - { - "mesh" : 25, - "name" : "Mesh_24" - }, - { - "mesh" : 26, - "name" : "Mesh_25" - }, - { - "mesh" : 27, - "name" : "Mesh_26" - }, - { - "mesh" : 28, - "name" : "Mesh_27" - }, - { - "mesh" : 29, - "name" : "Mesh_28" - }, - { - "mesh" : 30, - "name" : "Mesh_40" - }, - { - "mesh" : 31, - "name" : "Mesh_30" - }, - { - "mesh" : 32, - "name" : "Mesh_31" - }, - { - "mesh" : 33, - "name" : "Mesh_32" - }, - { - "mesh" : 34, - "name" : "Mesh_33" - }, - { - "mesh" : 35, - "name" : "Mesh_34" - }, - { - "mesh" : 36, - "name" : "Mesh_35" - }, - { - "mesh" : 37, - "name" : "Mesh_36" - }, - { - "mesh" : 38, - "name" : "Mesh_37" - }, - { - "mesh" : 39, - "name" : "Mesh_38" - }, - { - "mesh" : 40, - "name" : "Mesh_39" - }, - { - "mesh" : 41, - "name" : "Mesh_51" - }, - { - "mesh" : 42, - "name" : "Mesh_41" - }, - { - "mesh" : 43, - "name" : "Mesh_42" - }, - { - "mesh" : 44, - "name" : "Mesh_43" - }, - { - "mesh" : 45, - "name" : "Mesh_44" - }, - { - "mesh" : 46, - "name" : "Mesh_45" - }, - { - "mesh" : 47, - "name" : "Mesh_46" - }, - { - "mesh" : 48, - "name" : "Mesh_47" - }, - { - "mesh" : 49, - "name" : "Mesh_48" - }, - { - "mesh" : 50, - "name" : "Mesh_49" - }, - { - "mesh" : 51, - "name" : "Mesh_50" - }, - { - "mesh" : 52, - "name" : "Mesh_62" - }, - { - "mesh" : 53, - "name" : "Mesh_52" - }, - { - "mesh" : 54, - "name" : "Mesh_53" - }, - { - "mesh" : 55, - "name" : "Mesh_54" - }, - { - "mesh" : 56, - "name" : "Mesh_55" - }, - { - "mesh" : 57, - "name" : "Mesh_56" - }, - { - "mesh" : 58, - "name" : "Mesh_57" - }, - { - "mesh" : 59, - "name" : "Mesh_58" - }, - { - "mesh" : 60, - "name" : "Mesh_59" - }, - { - "mesh" : 61, - "name" : "Mesh_60" - }, - { - "mesh" : 62, - "name" : "Mesh_61" - }, - { - "mesh" : 63, - "name" : "Mesh_73" - }, - { - "mesh" : 64, - "name" : "Mesh_63" - }, - { - "mesh" : 65, - "name" : "Mesh_64" - }, - { - "mesh" : 66, - "name" : "Mesh_65" - }, - { - "mesh" : 67, - "name" : "Mesh_66" - }, - { - "mesh" : 68, - "name" : "Mesh_67" - }, - { - "mesh" : 69, - "name" : "Mesh_68" - }, - { - "mesh" : 70, - "name" : "Mesh_69" - }, - { - "mesh" : 71, - "name" : "Mesh_70" - }, - { - "mesh" : 72, - "name" : "Mesh_71" - }, - { - "mesh" : 73, - "name" : "Mesh_72" - }, - { - "mesh" : 74, - "name" : "Mesh_84" - }, - { - "mesh" : 75, - "name" : "Mesh_74" - }, - { - "mesh" : 76, - "name" : "Mesh_75" - }, - { - "mesh" : 77, - "name" : "Mesh_76" - }, - { - "mesh" : 78, - "name" : "Mesh_77" - }, - { - "mesh" : 79, - "name" : "Mesh_78" - }, - { - "mesh" : 80, - "name" : "Mesh_79" - }, - { - "mesh" : 81, - "name" : "Mesh_80" - }, - { - "mesh" : 82, - "name" : "Mesh_81" - }, - { - "mesh" : 83, - "name" : "Mesh_82" - }, - { - "mesh" : 84, - "name" : "Mesh_83" - }, - { - "mesh" : 85, - "name" : "Mesh_95" - }, - { - "mesh" : 86, - "name" : "Mesh_85" - }, - { - "mesh" : 87, - "name" : "Mesh_86" - }, - { - "mesh" : 88, - "name" : "Mesh_87" - }, - { - "mesh" : 89, - "name" : "Mesh_88" - }, - { - "mesh" : 90, - "name" : "Mesh_89" - }, - { - "mesh" : 91, - "name" : "Mesh_90" - }, - { - "mesh" : 92, - "name" : "Mesh_91" - }, - { - "mesh" : 93, - "name" : "Mesh_92" - }, - { - "mesh" : 94, - "name" : "Mesh_93" - }, - { - "mesh" : 95, - "name" : "Mesh_94" - }, - { - "mesh" : 96, - "name" : "Mesh_106" - }, - { - "mesh" : 97, - "name" : "Mesh_96" - }, - { - "mesh" : 98, - "name" : "Mesh_97" - }, - { - "mesh" : 99, - "name" : "Mesh_98" - }, - { - "mesh" : 100, - "name" : "Mesh_99" - }, - { - "mesh" : 101, - "name" : "Mesh_100" - }, - { - "mesh" : 102, - "name" : "Mesh_101" - }, - { - "mesh" : 103, - "name" : "Mesh_102" - }, - { - "mesh" : 104, - "name" : "Mesh_103" - }, - { - "mesh" : 105, - "name" : "Mesh_104" - }, - { - "mesh" : 106, - "name" : "Mesh_105" - }, - { - "mesh" : 107, - "name" : "Mesh_117" - }, - { - "mesh" : 108, - "name" : "Mesh_107" - }, - { - "mesh" : 109, - "name" : "Mesh_108" - }, - { - "mesh" : 110, - "name" : "Mesh_109" - }, - { - "mesh" : 111, - "name" : "Mesh_110" - }, - { - "mesh" : 112, - "name" : "Mesh_111" - }, - { - "mesh" : 113, - "name" : "Mesh_112" - }, - { - "mesh" : 114, - "name" : "Mesh_113" - }, - { - "mesh" : 115, - "name" : "Mesh_114" - }, - { - "mesh" : 116, - "name" : "Mesh_115" - }, - { - "mesh" : 117, - "name" : "Mesh_116" - }, - { - "mesh" : 118, - "name" : "Mesh_128" - }, - { - "mesh" : 119, - "name" : "Mesh_118" - }, - { - "mesh" : 120, - "name" : "Mesh_119" - }, - { - "mesh" : 121, - "name" : "Mesh_120" - }, - { - "mesh" : 122, - "name" : "Mesh_121" - }, - { - "mesh" : 123, - "name" : "Mesh_122" - }, - { - "mesh" : 124, - "name" : "Mesh_123" - }, - { - "mesh" : 125, - "name" : "Mesh_124" - }, - { - "mesh" : 126, - "name" : "Mesh_125" - }, - { - "mesh" : 127, - "name" : "Mesh_126" - }, - { - "mesh" : 128, - "name" : "Mesh_127" - }, - { - "mesh" : 129, - "name" : "Mesh_139" - }, - { - "mesh" : 130, - "name" : "Mesh_129" - }, - { - "mesh" : 131, - "name" : "Mesh_130" - }, - { - "mesh" : 132, - "name" : "Mesh_131" - }, - { - "mesh" : 133, - "name" : "Mesh_132" - }, - { - "mesh" : 134, - "name" : "Mesh_133" - }, - { - "mesh" : 135, - "name" : "Mesh_134" - }, - { - "mesh" : 136, - "name" : "Mesh_135" - }, - { - "mesh" : 137, - "name" : "Mesh_136" - }, - { - "mesh" : 138, - "name" : "Mesh_137" - }, - { - "mesh" : 139, - "name" : "Mesh_138" - }, - { - "mesh" : 140, - "name" : "Mesh_150" - }, - { - "mesh" : 141, - "name" : "Mesh_140" - }, - { - "mesh" : 142, - "name" : "Mesh_141" - }, - { - "mesh" : 143, - "name" : "Mesh_142" - }, - { - "mesh" : 144, - "name" : "Mesh_143" - }, - { - "mesh" : 145, - "name" : "Mesh_144" - }, - { - "mesh" : 146, - "name" : "Mesh_145" - }, - { - "mesh" : 147, - "name" : "Mesh_146" - }, - { - "mesh" : 148, - "name" : "Mesh_147" - }, - { - "mesh" : 149, - "name" : "Mesh_148" - }, - { - "mesh" : 150, - "name" : "Mesh_149" - }, - { - "mesh" : 151, - "name" : "Mesh_161" - }, - { - "mesh" : 152, - "name" : "Mesh_151" - }, - { - "mesh" : 153, - "name" : "Mesh_152" - }, - { - "mesh" : 154, - "name" : "Mesh_153" - }, - { - "mesh" : 155, - "name" : "Mesh_154" - }, - { - "mesh" : 156, - "name" : "Mesh_155" - }, - { - "mesh" : 157, - "name" : "Mesh_156" - }, - { - "mesh" : 158, - "name" : "Mesh_157" - }, - { - "mesh" : 159, - "name" : "Mesh_158" - }, - { - "mesh" : 160, - "name" : "Mesh_159" - }, - { - "mesh" : 161, - "name" : "Mesh_160" - }, - { - "mesh" : 162, - "name" : "Mesh_172" - }, - { - "mesh" : 163, - "name" : "Mesh_162" - }, - { - "mesh" : 164, - "name" : "Mesh_163" - }, - { - "mesh" : 165, - "name" : "Mesh_164" - }, - { - "mesh" : 166, - "name" : "Mesh_165" - }, - { - "mesh" : 167, - "name" : "Mesh_166" - }, - { - "mesh" : 168, - "name" : "Mesh_167" - }, - { - "mesh" : 169, - "name" : "Mesh_168" - }, - { - "mesh" : 170, - "name" : "Mesh_169" - }, - { - "mesh" : 171, - "name" : "Mesh_170" - }, - { - "mesh" : 172, - "name" : "Mesh_171" - }, - { - "mesh" : 173, - "name" : "Mesh_183" - }, - { - "mesh" : 174, - "name" : "Mesh_173" - }, - { - "mesh" : 175, - "name" : "Mesh_174" - }, - { - "mesh" : 176, - "name" : "Mesh_175" - }, - { - "mesh" : 177, - "name" : "Mesh_176" - }, - { - "mesh" : 178, - "name" : "Mesh_177" - }, - { - "mesh" : 179, - "name" : "Mesh_178" - }, - { - "mesh" : 180, - "name" : "Mesh_179" - }, - { - "mesh" : 181, - "name" : "Mesh_180" - }, - { - "mesh" : 182, - "name" : "Mesh_181" - }, - { - "mesh" : 183, - "name" : "Mesh_182" - }, - { - "mesh" : 184, - "name" : "Mesh_194" - }, - { - "mesh" : 185, - "name" : "Mesh_184" - }, - { - "mesh" : 186, - "name" : "Mesh_185" - }, - { - "mesh" : 187, - "name" : "Mesh_186" - }, - { - "mesh" : 188, - "name" : "Mesh_187" - }, - { - "mesh" : 189, - "name" : "Mesh_188" - }, - { - "mesh" : 190, - "name" : "Mesh_189" - }, - { - "mesh" : 191, - "name" : "Mesh_190" - }, - { - "mesh" : 192, - "name" : "Mesh_191" - }, - { - "mesh" : 193, - "name" : "Mesh_192" - }, - { - "mesh" : 194, - "name" : "Mesh_193" - }, - { - "mesh" : 195, - "name" : "Mesh_205" - }, - { - "mesh" : 196, - "name" : "Mesh_195" - }, - { - "mesh" : 197, - "name" : "Mesh_196" - }, - { - "mesh" : 198, - "name" : "Mesh_197" - }, - { - "mesh" : 199, - "name" : "Mesh_198" - }, - { - "mesh" : 200, - "name" : "Mesh_199" - }, - { - "mesh" : 201, - "name" : "Mesh_200" - }, - { - "mesh" : 202, - "name" : "Mesh_201" - }, - { - "mesh" : 203, - "name" : "Mesh_202" - }, - { - "mesh" : 204, - "name" : "Mesh_203" - }, - { - "mesh" : 205, - "name" : "Mesh_204" - }, - { - "mesh" : 206, - "name" : "Mesh_216" - }, - { - "mesh" : 207, - "name" : "Mesh_206" - }, - { - "mesh" : 208, - "name" : "Mesh_207" - }, - { - "mesh" : 209, - "name" : "Mesh_208" - }, - { - "mesh" : 210, - "name" : "Mesh_209" - }, - { - "mesh" : 211, - "name" : "Mesh_210" - }, - { - "mesh" : 212, - "name" : "Mesh_211" - }, - { - "mesh" : 213, - "name" : "Mesh_212" - }, - { - "mesh" : 214, - "name" : "Mesh_213" - }, - { - "mesh" : 215, - "name" : "Mesh_214" - }, - { - "mesh" : 216, - "name" : "Mesh_215" - }, - { - "mesh" : 217, - "name" : "Mesh_227" - }, - { - "mesh" : 218, - "name" : "Mesh_217" - }, - { - "mesh" : 219, - "name" : "Mesh_218" - }, - { - "mesh" : 220, - "name" : "Mesh_219" - }, - { - "mesh" : 221, - "name" : "Mesh_220" - }, - { - "mesh" : 222, - "name" : "Mesh_221" - }, - { - "mesh" : 223, - "name" : "Mesh_222" - }, - { - "mesh" : 224, - "name" : "Mesh_223" - }, - { - "mesh" : 225, - "name" : "Mesh_224" - }, - { - "mesh" : 226, - "name" : "Mesh_225" - }, - { - "mesh" : 227, - "name" : "Mesh_226" - }, - { - "mesh" : 228, - "name" : "Mesh_238" - }, - { - "mesh" : 229, - "name" : "Mesh_228" - }, - { - "mesh" : 230, - "name" : "Mesh_229" - }, - { - "mesh" : 231, - "name" : "Mesh_230" - }, - { - "mesh" : 232, - "name" : "Mesh_231" - }, - { - "mesh" : 233, - "name" : "Mesh_232" - }, - { - "mesh" : 234, - "name" : "Mesh_233" - }, - { - "mesh" : 235, - "name" : "Mesh_234" - }, - { - "mesh" : 236, - "name" : "Mesh_235" - }, - { - "mesh" : 237, - "name" : "Mesh_236" - }, - { - "mesh" : 238, - "name" : "Mesh_237" - }, - { - "mesh" : 239, - "name" : "Mesh_249" - }, - { - "mesh" : 240, - "name" : "Mesh_239" - }, - { - "mesh" : 241, - "name" : "Mesh_240" - }, - { - "mesh" : 242, - "name" : "Mesh_241" - }, - { - "mesh" : 243, - "name" : "Mesh_242" - }, - { - "mesh" : 244, - "name" : "Mesh_243" - }, - { - "mesh" : 245, - "name" : "Mesh_244" - }, - { - "mesh" : 246, - "name" : "Mesh_245" - }, - { - "mesh" : 247, - "name" : "Mesh_246" - }, - { - "mesh" : 248, - "name" : "Mesh_247" - }, - { - "mesh" : 249, - "name" : "Mesh_248" - }, - { - "mesh" : 250, - "name" : "Mesh_260" - }, - { - "mesh" : 251, - "name" : "Mesh_250" - }, - { - "mesh" : 252, - "name" : "Mesh_251" - }, - { - "mesh" : 253, - "name" : "Mesh_252" - }, - { - "mesh" : 254, - "name" : "Mesh_253" - }, - { - "mesh" : 255, - "name" : "Mesh_254" - }, - { - "mesh" : 256, - "name" : "Mesh_255" - }, - { - "mesh" : 257, - "name" : "Mesh_256" - }, - { - "mesh" : 258, - "name" : "Mesh_257" - }, - { - "mesh" : 259, - "name" : "Mesh_258" - }, - { - "mesh" : 260, - "name" : "Mesh_259" - }, - { - "mesh" : 261, - "name" : "Mesh_271" - }, - { - "mesh" : 262, - "name" : "Mesh_261" - }, - { - "mesh" : 263, - "name" : "Mesh_262" - }, - { - "mesh" : 264, - "name" : "Mesh_263" - }, - { - "mesh" : 265, - "name" : "Mesh_264" - }, - { - "mesh" : 266, - "name" : "Mesh_265" - }, - { - "mesh" : 267, - "name" : "Mesh_266" - }, - { - "mesh" : 268, - "name" : "Mesh_267" - }, - { - "mesh" : 269, - "name" : "Mesh_268" - }, - { - "mesh" : 270, - "name" : "Mesh_269" - }, - { - "mesh" : 271, - "name" : "Mesh_270" - }, - { - "mesh" : 272, - "name" : "Mesh_282" - }, - { - "mesh" : 273, - "name" : "Mesh_272" - }, - { - "mesh" : 274, - "name" : "Mesh_273" - }, - { - "mesh" : 275, - "name" : "Mesh_274" - }, - { - "mesh" : 276, - "name" : "Mesh_275" - }, - { - "mesh" : 277, - "name" : "Mesh_276" - }, - { - "mesh" : 278, - "name" : "Mesh_277" - }, - { - "mesh" : 279, - "name" : "Mesh_278" - }, - { - "mesh" : 280, - "name" : "Mesh_279" - }, - { - "mesh" : 281, - "name" : "Mesh_280" - }, - { - "mesh" : 282, - "name" : "Mesh_281" - }, - { - "mesh" : 283, - "name" : "Mesh_293" - }, - { - "mesh" : 284, - "name" : "Mesh_283" - }, - { - "mesh" : 285, - "name" : "Mesh_284" - }, - { - "mesh" : 286, - "name" : "Mesh_285" - }, - { - "mesh" : 287, - "name" : "Mesh_286" - }, - { - "mesh" : 288, - "name" : "Mesh_287" - }, - { - "mesh" : 289, - "name" : "Mesh_288" - }, - { - "mesh" : 290, - "name" : "Mesh_289" - }, - { - "mesh" : 291, - "name" : "Mesh_290" - }, - { - "mesh" : 292, - "name" : "Mesh_291" - }, - { - "mesh" : 293, - "name" : "Mesh_292" - }, - { - "mesh" : 294, - "name" : "Mesh_304" - }, - { - "mesh" : 295, - "name" : "Mesh_294" - }, - { - "mesh" : 296, - "name" : "Mesh_295" - }, - { - "mesh" : 297, - "name" : "Mesh_296" - }, - { - "mesh" : 298, - "name" : "Mesh_297" - }, - { - "mesh" : 299, - "name" : "Mesh_298" - }, - { - "mesh" : 300, - "name" : "Mesh_299" - }, - { - "mesh" : 301, - "name" : "Mesh_300" - }, - { - "mesh" : 302, - "name" : "Mesh_301" - }, - { - "mesh" : 303, - "name" : "Mesh_302" - }, - { - "mesh" : 304, - "name" : "Mesh_303" - }, - { - "mesh" : 305, - "name" : "Mesh_315" - }, - { - "mesh" : 306, - "name" : "Mesh_305" - }, - { - "mesh" : 307, - "name" : "Mesh_306" - }, - { - "mesh" : 308, - "name" : "Mesh_307" - }, - { - "mesh" : 309, - "name" : "Mesh_308" - }, - { - "mesh" : 310, - "name" : "Mesh_309" - }, - { - "mesh" : 311, - "name" : "Mesh_310" - }, - { - "mesh" : 312, - "name" : "Mesh_311" - }, - { - "mesh" : 313, - "name" : "Mesh_312" - }, - { - "mesh" : 314, - "name" : "Mesh_313" - }, - { - "mesh" : 315, - "name" : "Mesh_314" - }, - { - "mesh" : 316, - "name" : "Mesh_319" - }, - { - "mesh" : 317, - "name" : "Mesh_316" - }, - { - "mesh" : 318, - "name" : "Mesh_317" - }, - { - "mesh" : 319, - "name" : "Mesh_318" - }, - { - "mesh" : 320, - "name" : "Mesh_320" - }, - { - "mesh" : 321, - "name" : "Mesh_321" - }, - { - "mesh" : 322, - "name" : "Mesh_322" - }, - { - "mesh" : 323, - "name" : "Mesh_323" - }, - { - "mesh" : 324, - "name" : "Mesh_324" - }, - { - "mesh" : 325, - "name" : "Mesh_325" - }, - { - "mesh" : 326, - "name" : "Mesh_326" - }, - { - "mesh" : 327, - "name" : "Mesh_327" - }, - { - "mesh" : 328, - "name" : "Mesh_328" - }, - { - "mesh" : 329, - "name" : "Mesh_329" - }, - { - "mesh" : 330, - "name" : "Mesh_330" - }, - { - "mesh" : 331, - "name" : "Mesh_331" - }, - { - "mesh" : 332, - "name" : "Mesh_332" - }, - { - "mesh" : 333, - "name" : "Mesh_333" - }, - { - "mesh" : 334, - "name" : "Mesh_334" - }, - { - "mesh" : 335, - "name" : "Mesh_335" - }, - { - "mesh" : 336, - "name" : "Mesh_336" - }, - { - "mesh" : 337, - "name" : "Mesh_337" - }, - { - "mesh" : 338, - "name" : "Mesh_338" - }, - { - "mesh" : 339, - "name" : "Mesh_339" - }, - { - "mesh" : 340, - "name" : "Mesh_340" - }, - { - "mesh" : 341, - "name" : "Mesh_341" - }, - { - "mesh" : 342, - "name" : "Mesh_342" - }, - { - "mesh" : 343, - "name" : "Mesh_343" - }, - { - "mesh" : 344, - "name" : "Mesh_344" - }, - { - "mesh" : 345, - "name" : "Mesh_345" - }, - { - "mesh" : 346, - "name" : "Mesh_346" - }, - { - "mesh" : 347, - "name" : "Mesh_347" - }, - { - "mesh" : 348, - "name" : "Mesh_348" - }, - { - "mesh" : 349, - "name" : "Mesh_349" - }, - { - "mesh" : 350, - "name" : "Mesh_350" - }, - { - "mesh" : 351, - "name" : "Mesh_351" - }, - { - "mesh" : 352, - "name" : "Mesh_352" - }, - { - "mesh" : 353, - "name" : "Mesh_353" - }, - { - "mesh" : 354, - "name" : "Mesh_354" - }, - { - "mesh" : 355, - "name" : "Mesh_355" - }, - { - "mesh" : 356, - "name" : "Mesh_356" - }, - { - "mesh" : 357, - "name" : "Mesh_357" - }, - { - "mesh" : 358, - "name" : "Mesh_358" - }, - { - "mesh" : 359, - "name" : "Mesh_359" - }, - { - "mesh" : 360, - "name" : "Mesh_360" - }, - { - "mesh" : 361, - "name" : "Mesh_361" - }, - { - "mesh" : 362, - "name" : "Mesh_362" - }, - { - "mesh" : 363, - "name" : "Mesh_363" - }, - { - "mesh" : 364, - "name" : "Mesh_364" - }, - { - "mesh" : 365, - "name" : "Mesh_365" - }, - { - "mesh" : 366, - "name" : "Mesh_366" - }, - { - "mesh" : 367, - "name" : "Mesh_367" - }, - { - "mesh" : 368, - "name" : "Mesh_368" - }, - { - "mesh" : 369, - "name" : "Mesh_369" - }, - { - "mesh" : 370, - "name" : "Mesh_370" - }, - { - "mesh" : 371, - "name" : "Mesh_371" - }, - { - "mesh" : 372, - "name" : "Mesh_372" - }, - { - "mesh" : 373, - "name" : "Mesh_373" - }, - { - "mesh" : 374, - "name" : "Mesh_374" - }, - { - "mesh" : 375, - "name" : "Mesh_375" - }, - { - "mesh" : 376, - "name" : "Mesh_376" - }, - { - "mesh" : 377, - "name" : "Mesh_377" - }, - { - "mesh" : 378, - "name" : "Mesh_378" - }, - { - "mesh" : 379, - "name" : "Mesh_379" - }, - { - "mesh" : 380, - "name" : "Mesh_380" - } - ], - "materials" : [ - { - "alphaCutoff" : 0.5, - "alphaMode" : "MASK", - "doubleSided" : true, - "name" : "leaf", - "normalTexture" : { - "index" : 0 - }, - "pbrMetallicRoughness" : { - "baseColorTexture" : { - "index" : 1 - }, - "metallicRoughnessTexture" : { - "index" : 2 - } - } - }, - { - "alphaCutoff" : 0.5, - "alphaMode" : "MASK", - "doubleSided" : true, - "name" : "Material__57", - "normalTexture" : { - "index" : 3 - }, - "pbrMetallicRoughness" : { - "baseColorTexture" : { - "index" : 4 - }, - "metallicRoughnessTexture" : { - "index" : 5 - } - } - }, - { - "name" : "vase_round", - "normalTexture" : { - "index" : 6 - }, - "pbrMetallicRoughness" : { - "baseColorTexture" : { - "index" : 7 - }, - "metallicRoughnessTexture" : { - "index" : 8 - } - } - }, - { - "name" : "Material__298", - "normalTexture" : { - "index" : 9 - }, - "pbrMetallicRoughness" : { - "baseColorTexture" : { - "index" : 10 - }, - "metallicRoughnessTexture" : { - "index" : 11 - } - } - }, - { - "name" : "bricks", - "normalTexture" : { - "index" : 12 - }, - "pbrMetallicRoughness" : { - "baseColorTexture" : { - "index" : 13 - }, - "metallicRoughnessTexture" : { - "index" : 14 - } - } - }, - { - "name" : "arch", - "normalTexture" : { - "index" : 15 - }, - "pbrMetallicRoughness" : { - "baseColorTexture" : { - "index" : 16 - }, - "metallicRoughnessTexture" : { - "index" : 17 - } - } - }, - { - "name" : "ceiling", - "normalTexture" : { - "index" : 18 - }, - "pbrMetallicRoughness" : { - "baseColorTexture" : { - "index" : 19 - }, - "metallicRoughnessTexture" : { - "index" : 20 - } - } - }, - { - "name" : "column_a", - "normalTexture" : { - "index" : 21 - }, - "pbrMetallicRoughness" : { - "baseColorTexture" : { - "index" : 22 - }, - "metallicRoughnessTexture" : { - "index" : 23 - } - } - }, - { - "name" : "column_c", - "normalTexture" : { - "index" : 24 - }, - "pbrMetallicRoughness" : { - "baseColorTexture" : { - "index" : 25 - }, - "metallicRoughnessTexture" : { - "index" : 26 - } - } - }, - { - "name" : "floor", - "normalTexture" : { - "index" : 27 - }, - "pbrMetallicRoughness" : { - "baseColorTexture" : { - "index" : 28 - }, - "metallicRoughnessTexture" : { - "index" : 29 - } - } - }, - { - "name" : "column_b", - "normalTexture" : { - "index" : 30 - }, - "pbrMetallicRoughness" : { - "baseColorTexture" : { - "index" : 31 - }, - "metallicRoughnessTexture" : { - "index" : 32 - } - } - }, - { - "name" : "16___Default", - "pbrMetallicRoughness" : {} - }, - { - "name" : "flagpole", - "normalTexture" : { - "index" : 33 - }, - "pbrMetallicRoughness" : { - "baseColorTexture" : { - "index" : 34 - }, - "metallicRoughnessTexture" : { - "index" : 35 - } - } - }, - { - "name" : "fabric_e", - "normalTexture" : { - "index" : 36 - }, - "pbrMetallicRoughness" : { - "baseColorTexture" : { - "index" : 37 - }, - "metallicRoughnessTexture" : { - "index" : 38 - } - } - }, - { - "name" : "fabric_d", - "normalTexture" : { - "index" : 39 - }, - "pbrMetallicRoughness" : { - "baseColorTexture" : { - "index" : 40 - }, - "metallicRoughnessTexture" : { - "index" : 41 - } - } - }, - { - "name" : "fabric_a", - "normalTexture" : { - "index" : 42 - }, - "pbrMetallicRoughness" : { - "baseColorTexture" : { - "index" : 43 - }, - "metallicRoughnessTexture" : { - "index" : 44 - } - } - }, - { - "name" : "fabric_g", - "normalTexture" : { - "index" : 45 - }, - "pbrMetallicRoughness" : { - "baseColorTexture" : { - "index" : 46 - }, - "metallicRoughnessTexture" : { - "index" : 47 - } - } - }, - { - "name" : "fabric_c", - "normalTexture" : { - "index" : 48 - }, - "pbrMetallicRoughness" : { - "baseColorTexture" : { - "index" : 49 - }, - "metallicRoughnessTexture" : { - "index" : 50 - } - } - }, - { - "name" : "fabric_f", - "normalTexture" : { - "index" : 51 - }, - "pbrMetallicRoughness" : { - "baseColorTexture" : { - "index" : 52 - }, - "metallicRoughnessTexture" : { - "index" : 53 - } - } - }, - { - "alphaCutoff" : 0.5, - "alphaMode" : "MASK", - "doubleSided" : true, - "name" : "chain", - "normalTexture" : { - "index" : 54 - }, - "pbrMetallicRoughness" : { - "baseColorTexture" : { - "index" : 55 - }, - "metallicRoughnessTexture" : { - "index" : 56 - } - } - }, - { - "name" : "vase_hanging", - "normalTexture" : { - "index" : 57 - }, - "pbrMetallicRoughness" : { - "baseColorTexture" : { - "index" : 58 - }, - "metallicRoughnessTexture" : { - "index" : 59 - } - } - }, - { - "name" : "vase", - "normalTexture" : { - "index" : 60 - }, - "pbrMetallicRoughness" : { - "baseColorTexture" : { - "index" : 61 - }, - "metallicRoughnessTexture" : { - "index" : 62 - } - } - }, - { - "name" : "Material__25", - "normalTexture" : { - "index" : 63 - }, - "pbrMetallicRoughness" : { - "baseColorTexture" : { - "index" : 64 - }, - "metallicRoughnessTexture" : { - "index" : 65 - } - } - }, - { - "name" : "roof", - "normalTexture" : { - "index" : 66 - }, - "pbrMetallicRoughness" : { - "baseColorTexture" : { - "index" : 67 - }, - "metallicRoughnessTexture" : { - "index" : 68 - } - } - }, - { - "name" : "details", - "normalTexture" : { - "index" : 69 - }, - "pbrMetallicRoughness" : { - "baseColorTexture" : { - "index" : 70 - }, - "metallicRoughnessTexture" : { - "index" : 71 - } - } - } - ], - "meshes" : [ - { - "name" : "Mesh_0", - "primitives" : [ - { - "attributes" : { - "POSITION" : 0, - "NORMAL" : 1, - "TEXCOORD_0" : 2 - }, - "indices" : 3, - "material" : 0 - } - ] - }, - { - "name" : "Mesh_1", - "primitives" : [ - { - "attributes" : { - "POSITION" : 4, - "NORMAL" : 5, - "TEXCOORD_0" : 6 - }, - "indices" : 7, - "material" : 1 - }, - { - "attributes" : { - "POSITION" : 8, - "NORMAL" : 9, - "TEXCOORD_0" : 10 - }, - "indices" : 11, - "material" : 2 - } - ] - }, - { - "name" : "Mesh_2", - "primitives" : [ - { - "attributes" : { - "POSITION" : 12, - "NORMAL" : 13, - "TEXCOORD_0" : 14 - }, - "indices" : 15, - "material" : 3 - } - ] - }, - { - "name" : "Mesh_3", - "primitives" : [ - { - "attributes" : { - "POSITION" : 16, - "NORMAL" : 17, - "TEXCOORD_0" : 18 - }, - "indices" : 19, - "material" : 4 - } - ] - }, - { - "name" : "Mesh_4", - "primitives" : [ - { - "attributes" : { - "POSITION" : 20, - "NORMAL" : 21, - "TEXCOORD_0" : 22 - }, - "indices" : 23, - "material" : 4 - } - ] - }, - { - "name" : "Mesh_5", - "primitives" : [ - { - "attributes" : { - "POSITION" : 24, - "NORMAL" : 25, - "TEXCOORD_0" : 26 - }, - "indices" : 27, - "material" : 5 - } - ] - }, - { - "name" : "Mesh_6", - "primitives" : [ - { - "attributes" : { - "POSITION" : 28, - "NORMAL" : 29, - "TEXCOORD_0" : 30 - }, - "indices" : 31, - "material" : 6 - } - ] - }, - { - "name" : "Mesh_7", - "primitives" : [ - { - "attributes" : { - "POSITION" : 32, - "NORMAL" : 33, - "TEXCOORD_0" : 34 - }, - "indices" : 35, - "material" : 7 - } - ] - }, - { - "name" : "Mesh_18", - "primitives" : [ - { - "attributes" : { - "POSITION" : 36, - "NORMAL" : 37, - "TEXCOORD_0" : 38 - }, - "indices" : 39, - "material" : 7 - } - ] - }, - { - "name" : "Mesh_8", - "primitives" : [ - { - "attributes" : { - "POSITION" : 40, - "NORMAL" : 41, - "TEXCOORD_0" : 42 - }, - "indices" : 43, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_9", - "primitives" : [ - { - "attributes" : { - "POSITION" : 44, - "NORMAL" : 45, - "TEXCOORD_0" : 46 - }, - "indices" : 47, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_10", - "primitives" : [ - { - "attributes" : { - "POSITION" : 48, - "NORMAL" : 49, - "TEXCOORD_0" : 50 - }, - "indices" : 51, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_11", - "primitives" : [ - { - "attributes" : { - "POSITION" : 52, - "NORMAL" : 53, - "TEXCOORD_0" : 54 - }, - "indices" : 55, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_12", - "primitives" : [ - { - "attributes" : { - "POSITION" : 56, - "NORMAL" : 57, - "TEXCOORD_0" : 58 - }, - "indices" : 59, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_13", - "primitives" : [ - { - "attributes" : { - "POSITION" : 60, - "NORMAL" : 61, - "TEXCOORD_0" : 62 - }, - "indices" : 63, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_14", - "primitives" : [ - { - "attributes" : { - "POSITION" : 64, - "NORMAL" : 65, - "TEXCOORD_0" : 66 - }, - "indices" : 67, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_15", - "primitives" : [ - { - "attributes" : { - "POSITION" : 68, - "NORMAL" : 69, - "TEXCOORD_0" : 70 - }, - "indices" : 71, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_16", - "primitives" : [ - { - "attributes" : { - "POSITION" : 72, - "NORMAL" : 73, - "TEXCOORD_0" : 74 - }, - "indices" : 67, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_17", - "primitives" : [ - { - "attributes" : { - "POSITION" : 75, - "NORMAL" : 76, - "TEXCOORD_0" : 77 - }, - "indices" : 78, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_29", - "primitives" : [ - { - "attributes" : { - "POSITION" : 79, - "NORMAL" : 80, - "TEXCOORD_0" : 81 - }, - "indices" : 82, - "material" : 7 - } - ] - }, - { - "name" : "Mesh_19", - "primitives" : [ - { - "attributes" : { - "POSITION" : 83, - "NORMAL" : 84, - "TEXCOORD_0" : 85 - }, - "indices" : 86, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_20", - "primitives" : [ - { - "attributes" : { - "POSITION" : 87, - "NORMAL" : 88, - "TEXCOORD_0" : 89 - }, - "indices" : 90, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_21", - "primitives" : [ - { - "attributes" : { - "POSITION" : 91, - "NORMAL" : 92, - "TEXCOORD_0" : 93 - }, - "indices" : 94, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_22", - "primitives" : [ - { - "attributes" : { - "POSITION" : 95, - "NORMAL" : 96, - "TEXCOORD_0" : 97 - }, - "indices" : 98, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_23", - "primitives" : [ - { - "attributes" : { - "POSITION" : 99, - "NORMAL" : 100, - "TEXCOORD_0" : 101 - }, - "indices" : 102, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_24", - "primitives" : [ - { - "attributes" : { - "POSITION" : 103, - "NORMAL" : 104, - "TEXCOORD_0" : 105 - }, - "indices" : 106, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_25", - "primitives" : [ - { - "attributes" : { - "POSITION" : 107, - "NORMAL" : 108, - "TEXCOORD_0" : 109 - }, - "indices" : 110, - "material" : 4 - } - ] - }, - { - "name" : "Mesh_26", - "primitives" : [ - { - "attributes" : { - "POSITION" : 111, - "NORMAL" : 112, - "TEXCOORD_0" : 113 - }, - "indices" : 114, - "material" : 9 - } - ] - }, - { - "name" : "Mesh_27", - "primitives" : [ - { - "attributes" : { - "POSITION" : 115, - "NORMAL" : 116, - "TEXCOORD_0" : 117 - }, - "indices" : 118, - "material" : 7 - } - ] - }, - { - "name" : "Mesh_28", - "primitives" : [ - { - "attributes" : { - "POSITION" : 119, - "NORMAL" : 120, - "TEXCOORD_0" : 121 - }, - "indices" : 122, - "material" : 7 - } - ] - }, - { - "name" : "Mesh_40", - "primitives" : [ - { - "attributes" : { - "POSITION" : 123, - "NORMAL" : 124, - "TEXCOORD_0" : 125 - }, - "indices" : 126, - "material" : 7 - } - ] - }, - { - "name" : "Mesh_30", - "primitives" : [ - { - "attributes" : { - "POSITION" : 127, - "NORMAL" : 128, - "TEXCOORD_0" : 129 - }, - "indices" : 130, - "material" : 7 - } - ] - }, - { - "name" : "Mesh_31", - "primitives" : [ - { - "attributes" : { - "POSITION" : 131, - "NORMAL" : 132, - "TEXCOORD_0" : 133 - }, - "indices" : 134, - "material" : 7 - } - ] - }, - { - "name" : "Mesh_32", - "primitives" : [ - { - "attributes" : { - "POSITION" : 135, - "NORMAL" : 136, - "TEXCOORD_0" : 137 - }, - "indices" : 138, - "material" : 5 - } - ] - }, - { - "name" : "Mesh_33", - "primitives" : [ - { - "attributes" : { - "POSITION" : 139, - "NORMAL" : 140, - "TEXCOORD_0" : 141 - }, - "indices" : 142, - "material" : 5 - } - ] - }, - { - "name" : "Mesh_34", - "primitives" : [ - { - "attributes" : { - "POSITION" : 143, - "NORMAL" : 144, - "TEXCOORD_0" : 145 - }, - "indices" : 146, - "material" : 5 - } - ] - }, - { - "name" : "Mesh_35", - "primitives" : [ - { - "attributes" : { - "POSITION" : 147, - "NORMAL" : 148, - "TEXCOORD_0" : 149 - }, - "indices" : 150, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_36", - "primitives" : [ - { - "attributes" : { - "POSITION" : 151, - "NORMAL" : 152, - "TEXCOORD_0" : 153 - }, - "indices" : 154, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_37", - "primitives" : [ - { - "attributes" : { - "POSITION" : 155, - "NORMAL" : 156, - "TEXCOORD_0" : 157 - }, - "indices" : 158, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_38", - "primitives" : [ - { - "attributes" : { - "POSITION" : 159, - "NORMAL" : 160, - "TEXCOORD_0" : 161 - }, - "indices" : 162, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_39", - "primitives" : [ - { - "attributes" : { - "POSITION" : 163, - "NORMAL" : 164, - "TEXCOORD_0" : 165 - }, - "indices" : 166, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_51", - "primitives" : [ - { - "attributes" : { - "POSITION" : 167, - "NORMAL" : 168, - "TEXCOORD_0" : 169 - }, - "indices" : 170, - "material" : 7 - } - ] - }, - { - "name" : "Mesh_41", - "primitives" : [ - { - "attributes" : { - "POSITION" : 171, - "NORMAL" : 172, - "TEXCOORD_0" : 173 - }, - "indices" : 174, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_42", - "primitives" : [ - { - "attributes" : { - "POSITION" : 175, - "NORMAL" : 176, - "TEXCOORD_0" : 177 - }, - "indices" : 178, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_43", - "primitives" : [ - { - "attributes" : { - "POSITION" : 179, - "NORMAL" : 180, - "TEXCOORD_0" : 181 - }, - "indices" : 182, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_44", - "primitives" : [ - { - "attributes" : { - "POSITION" : 183, - "NORMAL" : 184, - "TEXCOORD_0" : 185 - }, - "indices" : 186, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_45", - "primitives" : [ - { - "attributes" : { - "POSITION" : 187, - "NORMAL" : 188, - "TEXCOORD_0" : 189 - }, - "indices" : 190, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_46", - "primitives" : [ - { - "attributes" : { - "POSITION" : 191, - "NORMAL" : 192, - "TEXCOORD_0" : 193 - }, - "indices" : 194, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_47", - "primitives" : [ - { - "attributes" : { - "POSITION" : 195, - "NORMAL" : 196, - "TEXCOORD_0" : 197 - }, - "indices" : 198, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_48", - "primitives" : [ - { - "attributes" : { - "POSITION" : 199, - "NORMAL" : 200, - "TEXCOORD_0" : 201 - }, - "indices" : 202, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_49", - "primitives" : [ - { - "attributes" : { - "POSITION" : 203, - "NORMAL" : 204, - "TEXCOORD_0" : 205 - }, - "indices" : 206, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_50", - "primitives" : [ - { - "attributes" : { - "POSITION" : 207, - "NORMAL" : 208, - "TEXCOORD_0" : 209 - }, - "indices" : 210, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_62", - "primitives" : [ - { - "attributes" : { - "POSITION" : 211, - "NORMAL" : 212, - "TEXCOORD_0" : 213 - }, - "indices" : 214, - "material" : 7 - } - ] - }, - { - "name" : "Mesh_52", - "primitives" : [ - { - "attributes" : { - "POSITION" : 215, - "NORMAL" : 216, - "TEXCOORD_0" : 217 - }, - "indices" : 218, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_53", - "primitives" : [ - { - "attributes" : { - "POSITION" : 219, - "NORMAL" : 220, - "TEXCOORD_0" : 221 - }, - "indices" : 222, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_54", - "primitives" : [ - { - "attributes" : { - "POSITION" : 223, - "NORMAL" : 224, - "TEXCOORD_0" : 225 - }, - "indices" : 226, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_55", - "primitives" : [ - { - "attributes" : { - "POSITION" : 227, - "NORMAL" : 228, - "TEXCOORD_0" : 229 - }, - "indices" : 230, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_56", - "primitives" : [ - { - "attributes" : { - "POSITION" : 231, - "NORMAL" : 232, - "TEXCOORD_0" : 233 - }, - "indices" : 234, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_57", - "primitives" : [ - { - "attributes" : { - "POSITION" : 235, - "NORMAL" : 236, - "TEXCOORD_0" : 237 - }, - "indices" : 238, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_58", - "primitives" : [ - { - "attributes" : { - "POSITION" : 239, - "NORMAL" : 240, - "TEXCOORD_0" : 241 - }, - "indices" : 242, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_59", - "primitives" : [ - { - "attributes" : { - "POSITION" : 243, - "NORMAL" : 244, - "TEXCOORD_0" : 245 - }, - "indices" : 246, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_60", - "primitives" : [ - { - "attributes" : { - "POSITION" : 247, - "NORMAL" : 248, - "TEXCOORD_0" : 249 - }, - "indices" : 250, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_61", - "primitives" : [ - { - "attributes" : { - "POSITION" : 251, - "NORMAL" : 252, - "TEXCOORD_0" : 253 - }, - "indices" : 254, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_73", - "primitives" : [ - { - "attributes" : { - "POSITION" : 255, - "NORMAL" : 256, - "TEXCOORD_0" : 257 - }, - "indices" : 258, - "material" : 7 - } - ] - }, - { - "name" : "Mesh_63", - "primitives" : [ - { - "attributes" : { - "POSITION" : 259, - "NORMAL" : 260, - "TEXCOORD_0" : 261 - }, - "indices" : 262, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_64", - "primitives" : [ - { - "attributes" : { - "POSITION" : 263, - "NORMAL" : 264, - "TEXCOORD_0" : 265 - }, - "indices" : 266, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_65", - "primitives" : [ - { - "attributes" : { - "POSITION" : 267, - "NORMAL" : 268, - "TEXCOORD_0" : 269 - }, - "indices" : 270, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_66", - "primitives" : [ - { - "attributes" : { - "POSITION" : 271, - "NORMAL" : 272, - "TEXCOORD_0" : 273 - }, - "indices" : 274, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_67", - "primitives" : [ - { - "attributes" : { - "POSITION" : 275, - "NORMAL" : 276, - "TEXCOORD_0" : 277 - }, - "indices" : 278, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_68", - "primitives" : [ - { - "attributes" : { - "POSITION" : 279, - "NORMAL" : 280, - "TEXCOORD_0" : 281 - }, - "indices" : 282, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_69", - "primitives" : [ - { - "attributes" : { - "POSITION" : 283, - "NORMAL" : 284, - "TEXCOORD_0" : 285 - }, - "indices" : 286, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_70", - "primitives" : [ - { - "attributes" : { - "POSITION" : 287, - "NORMAL" : 288, - "TEXCOORD_0" : 289 - }, - "indices" : 290, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_71", - "primitives" : [ - { - "attributes" : { - "POSITION" : 291, - "NORMAL" : 292, - "TEXCOORD_0" : 293 - }, - "indices" : 294, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_72", - "primitives" : [ - { - "attributes" : { - "POSITION" : 295, - "NORMAL" : 296, - "TEXCOORD_0" : 297 - }, - "indices" : 298, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_84", - "primitives" : [ - { - "attributes" : { - "POSITION" : 299, - "NORMAL" : 300, - "TEXCOORD_0" : 301 - }, - "indices" : 302, - "material" : 7 - } - ] - }, - { - "name" : "Mesh_74", - "primitives" : [ - { - "attributes" : { - "POSITION" : 303, - "NORMAL" : 304, - "TEXCOORD_0" : 305 - }, - "indices" : 306, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_75", - "primitives" : [ - { - "attributes" : { - "POSITION" : 307, - "NORMAL" : 308, - "TEXCOORD_0" : 309 - }, - "indices" : 310, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_76", - "primitives" : [ - { - "attributes" : { - "POSITION" : 311, - "NORMAL" : 312, - "TEXCOORD_0" : 313 - }, - "indices" : 314, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_77", - "primitives" : [ - { - "attributes" : { - "POSITION" : 315, - "NORMAL" : 316, - "TEXCOORD_0" : 317 - }, - "indices" : 318, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_78", - "primitives" : [ - { - "attributes" : { - "POSITION" : 319, - "NORMAL" : 320, - "TEXCOORD_0" : 321 - }, - "indices" : 322, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_79", - "primitives" : [ - { - "attributes" : { - "POSITION" : 323, - "NORMAL" : 324, - "TEXCOORD_0" : 325 - }, - "indices" : 326, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_80", - "primitives" : [ - { - "attributes" : { - "POSITION" : 327, - "NORMAL" : 328, - "TEXCOORD_0" : 329 - }, - "indices" : 330, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_81", - "primitives" : [ - { - "attributes" : { - "POSITION" : 331, - "NORMAL" : 332, - "TEXCOORD_0" : 333 - }, - "indices" : 334, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_82", - "primitives" : [ - { - "attributes" : { - "POSITION" : 335, - "NORMAL" : 336, - "TEXCOORD_0" : 337 - }, - "indices" : 338, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_83", - "primitives" : [ - { - "attributes" : { - "POSITION" : 339, - "NORMAL" : 340, - "TEXCOORD_0" : 341 - }, - "indices" : 342, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_95", - "primitives" : [ - { - "attributes" : { - "POSITION" : 343, - "NORMAL" : 344, - "TEXCOORD_0" : 345 - }, - "indices" : 346, - "material" : 5 - } - ] - }, - { - "name" : "Mesh_85", - "primitives" : [ - { - "attributes" : { - "POSITION" : 347, - "NORMAL" : 348, - "TEXCOORD_0" : 349 - }, - "indices" : 350, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_86", - "primitives" : [ - { - "attributes" : { - "POSITION" : 351, - "NORMAL" : 352, - "TEXCOORD_0" : 353 - }, - "indices" : 354, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_87", - "primitives" : [ - { - "attributes" : { - "POSITION" : 355, - "NORMAL" : 356, - "TEXCOORD_0" : 357 - }, - "indices" : 358, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_88", - "primitives" : [ - { - "attributes" : { - "POSITION" : 359, - "NORMAL" : 360, - "TEXCOORD_0" : 361 - }, - "indices" : 362, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_89", - "primitives" : [ - { - "attributes" : { - "POSITION" : 363, - "NORMAL" : 364, - "TEXCOORD_0" : 365 - }, - "indices" : 366, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_90", - "primitives" : [ - { - "attributes" : { - "POSITION" : 367, - "NORMAL" : 368, - "TEXCOORD_0" : 369 - }, - "indices" : 370, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_91", - "primitives" : [ - { - "attributes" : { - "POSITION" : 371, - "NORMAL" : 372, - "TEXCOORD_0" : 373 - }, - "indices" : 374, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_92", - "primitives" : [ - { - "attributes" : { - "POSITION" : 375, - "NORMAL" : 376, - "TEXCOORD_0" : 377 - }, - "indices" : 378, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_93", - "primitives" : [ - { - "attributes" : { - "POSITION" : 379, - "NORMAL" : 380, - "TEXCOORD_0" : 381 - }, - "indices" : 382, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_94", - "primitives" : [ - { - "attributes" : { - "POSITION" : 383, - "NORMAL" : 384, - "TEXCOORD_0" : 385 - }, - "indices" : 386, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_106", - "primitives" : [ - { - "attributes" : { - "POSITION" : 387, - "NORMAL" : 388, - "TEXCOORD_0" : 389 - }, - "indices" : 390, - "material" : 9 - } - ] - }, - { - "name" : "Mesh_96", - "primitives" : [ - { - "attributes" : { - "POSITION" : 391, - "NORMAL" : 392, - "TEXCOORD_0" : 393 - }, - "indices" : 394, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_97", - "primitives" : [ - { - "attributes" : { - "POSITION" : 395, - "NORMAL" : 396, - "TEXCOORD_0" : 397 - }, - "indices" : 398, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_98", - "primitives" : [ - { - "attributes" : { - "POSITION" : 399, - "NORMAL" : 400, - "TEXCOORD_0" : 401 - }, - "indices" : 402, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_99", - "primitives" : [ - { - "attributes" : { - "POSITION" : 403, - "NORMAL" : 404, - "TEXCOORD_0" : 405 - }, - "indices" : 406, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_100", - "primitives" : [ - { - "attributes" : { - "POSITION" : 407, - "NORMAL" : 408, - "TEXCOORD_0" : 409 - }, - "indices" : 410, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_101", - "primitives" : [ - { - "attributes" : { - "POSITION" : 411, - "NORMAL" : 412, - "TEXCOORD_0" : 413 - }, - "indices" : 414, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_102", - "primitives" : [ - { - "attributes" : { - "POSITION" : 415, - "NORMAL" : 416, - "TEXCOORD_0" : 417 - }, - "indices" : 418, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_103", - "primitives" : [ - { - "attributes" : { - "POSITION" : 419, - "NORMAL" : 420, - "TEXCOORD_0" : 421 - }, - "indices" : 422, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_104", - "primitives" : [ - { - "attributes" : { - "POSITION" : 423, - "NORMAL" : 424, - "TEXCOORD_0" : 425 - }, - "indices" : 426, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_105", - "primitives" : [ - { - "attributes" : { - "POSITION" : 427, - "NORMAL" : 428, - "TEXCOORD_0" : 429 - }, - "indices" : 430, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_117", - "primitives" : [ - { - "attributes" : { - "POSITION" : 431, - "NORMAL" : 432, - "TEXCOORD_0" : 433 - }, - "indices" : 434, - "material" : 6 - } - ] - }, - { - "name" : "Mesh_107", - "primitives" : [ - { - "attributes" : { - "POSITION" : 435, - "NORMAL" : 436, - "TEXCOORD_0" : 437 - }, - "indices" : 438, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_108", - "primitives" : [ - { - "attributes" : { - "POSITION" : 439, - "NORMAL" : 440, - "TEXCOORD_0" : 441 - }, - "indices" : 442, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_109", - "primitives" : [ - { - "attributes" : { - "POSITION" : 443, - "NORMAL" : 444, - "TEXCOORD_0" : 445 - }, - "indices" : 446, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_110", - "primitives" : [ - { - "attributes" : { - "POSITION" : 447, - "NORMAL" : 448, - "TEXCOORD_0" : 449 - }, - "indices" : 450, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_111", - "primitives" : [ - { - "attributes" : { - "POSITION" : 451, - "NORMAL" : 452, - "TEXCOORD_0" : 453 - }, - "indices" : 454, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_112", - "primitives" : [ - { - "attributes" : { - "POSITION" : 455, - "NORMAL" : 456, - "TEXCOORD_0" : 457 - }, - "indices" : 458, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_113", - "primitives" : [ - { - "attributes" : { - "POSITION" : 459, - "NORMAL" : 460, - "TEXCOORD_0" : 461 - }, - "indices" : 462, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_114", - "primitives" : [ - { - "attributes" : { - "POSITION" : 463, - "NORMAL" : 464, - "TEXCOORD_0" : 465 - }, - "indices" : 466, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_115", - "primitives" : [ - { - "attributes" : { - "POSITION" : 467, - "NORMAL" : 468, - "TEXCOORD_0" : 469 - }, - "indices" : 470, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_116", - "primitives" : [ - { - "attributes" : { - "POSITION" : 471, - "NORMAL" : 472, - "TEXCOORD_0" : 473 - }, - "indices" : 474, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_128", - "primitives" : [ - { - "attributes" : { - "POSITION" : 475, - "NORMAL" : 476, - "TEXCOORD_0" : 477 - }, - "indices" : 478, - "material" : 5 - } - ] - }, - { - "name" : "Mesh_118", - "primitives" : [ - { - "attributes" : { - "POSITION" : 479, - "NORMAL" : 480, - "TEXCOORD_0" : 481 - }, - "indices" : 482, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_119", - "primitives" : [ - { - "attributes" : { - "POSITION" : 483, - "NORMAL" : 484, - "TEXCOORD_0" : 485 - }, - "indices" : 486, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_120", - "primitives" : [ - { - "attributes" : { - "POSITION" : 487, - "NORMAL" : 488, - "TEXCOORD_0" : 489 - }, - "indices" : 490, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_121", - "primitives" : [ - { - "attributes" : { - "POSITION" : 491, - "NORMAL" : 492, - "TEXCOORD_0" : 493 - }, - "indices" : 494, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_122", - "primitives" : [ - { - "attributes" : { - "POSITION" : 495, - "NORMAL" : 496, - "TEXCOORD_0" : 497 - }, - "indices" : 498, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_123", - "primitives" : [ - { - "attributes" : { - "POSITION" : 499, - "NORMAL" : 500, - "TEXCOORD_0" : 501 - }, - "indices" : 262, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_124", - "primitives" : [ - { - "attributes" : { - "POSITION" : 502, - "NORMAL" : 503, - "TEXCOORD_0" : 504 - }, - "indices" : 505, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_125", - "primitives" : [ - { - "attributes" : { - "POSITION" : 506, - "NORMAL" : 507, - "TEXCOORD_0" : 508 - }, - "indices" : 509, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_126", - "primitives" : [ - { - "attributes" : { - "POSITION" : 510, - "NORMAL" : 511, - "TEXCOORD_0" : 512 - }, - "indices" : 513, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_127", - "primitives" : [ - { - "attributes" : { - "POSITION" : 514, - "NORMAL" : 515, - "TEXCOORD_0" : 516 - }, - "indices" : 517, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_139", - "primitives" : [ - { - "attributes" : { - "POSITION" : 518, - "NORMAL" : 519, - "TEXCOORD_0" : 520 - }, - "indices" : 521, - "material" : 5 - } - ] - }, - { - "name" : "Mesh_129", - "primitives" : [ - { - "attributes" : { - "POSITION" : 522, - "NORMAL" : 523, - "TEXCOORD_0" : 524 - }, - "indices" : 525, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_130", - "primitives" : [ - { - "attributes" : { - "POSITION" : 526, - "NORMAL" : 527, - "TEXCOORD_0" : 528 - }, - "indices" : 529, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_131", - "primitives" : [ - { - "attributes" : { - "POSITION" : 530, - "NORMAL" : 531, - "TEXCOORD_0" : 532 - }, - "indices" : 533, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_132", - "primitives" : [ - { - "attributes" : { - "POSITION" : 534, - "NORMAL" : 535, - "TEXCOORD_0" : 536 - }, - "indices" : 537, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_133", - "primitives" : [ - { - "attributes" : { - "POSITION" : 538, - "NORMAL" : 539, - "TEXCOORD_0" : 540 - }, - "indices" : 541, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_134", - "primitives" : [ - { - "attributes" : { - "POSITION" : 542, - "NORMAL" : 543, - "TEXCOORD_0" : 544 - }, - "indices" : 545, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_135", - "primitives" : [ - { - "attributes" : { - "POSITION" : 546, - "NORMAL" : 547, - "TEXCOORD_0" : 548 - }, - "indices" : 549, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_136", - "primitives" : [ - { - "attributes" : { - "POSITION" : 550, - "NORMAL" : 551, - "TEXCOORD_0" : 552 - }, - "indices" : 553, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_137", - "primitives" : [ - { - "attributes" : { - "POSITION" : 554, - "NORMAL" : 555, - "TEXCOORD_0" : 556 - }, - "indices" : 318, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_138", - "primitives" : [ - { - "attributes" : { - "POSITION" : 557, - "NORMAL" : 558, - "TEXCOORD_0" : 559 - }, - "indices" : 560, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_150", - "primitives" : [ - { - "attributes" : { - "POSITION" : 561, - "NORMAL" : 562, - "TEXCOORD_0" : 563 - }, - "indices" : 564, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_140", - "primitives" : [ - { - "attributes" : { - "POSITION" : 565, - "NORMAL" : 566, - "TEXCOORD_0" : 567 - }, - "indices" : 326, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_141", - "primitives" : [ - { - "attributes" : { - "POSITION" : 568, - "NORMAL" : 569, - "TEXCOORD_0" : 570 - }, - "indices" : 571, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_142", - "primitives" : [ - { - "attributes" : { - "POSITION" : 572, - "NORMAL" : 573, - "TEXCOORD_0" : 574 - }, - "indices" : 575, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_143", - "primitives" : [ - { - "attributes" : { - "POSITION" : 576, - "NORMAL" : 577, - "TEXCOORD_0" : 578 - }, - "indices" : 579, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_144", - "primitives" : [ - { - "attributes" : { - "POSITION" : 580, - "NORMAL" : 581, - "TEXCOORD_0" : 582 - }, - "indices" : 583, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_145", - "primitives" : [ - { - "attributes" : { - "POSITION" : 584, - "NORMAL" : 585, - "TEXCOORD_0" : 586 - }, - "indices" : 587, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_146", - "primitives" : [ - { - "attributes" : { - "POSITION" : 588, - "NORMAL" : 589, - "TEXCOORD_0" : 590 - }, - "indices" : 591, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_147", - "primitives" : [ - { - "attributes" : { - "POSITION" : 592, - "NORMAL" : 593, - "TEXCOORD_0" : 594 - }, - "indices" : 595, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_148", - "primitives" : [ - { - "attributes" : { - "POSITION" : 596, - "NORMAL" : 597, - "TEXCOORD_0" : 598 - }, - "indices" : 599, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_149", - "primitives" : [ - { - "attributes" : { - "POSITION" : 600, - "NORMAL" : 601, - "TEXCOORD_0" : 602 - }, - "indices" : 603, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_161", - "primitives" : [ - { - "attributes" : { - "POSITION" : 604, - "NORMAL" : 605, - "TEXCOORD_0" : 606 - }, - "indices" : 607, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_151", - "primitives" : [ - { - "attributes" : { - "POSITION" : 608, - "NORMAL" : 609, - "TEXCOORD_0" : 610 - }, - "indices" : 611, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_152", - "primitives" : [ - { - "attributes" : { - "POSITION" : 612, - "NORMAL" : 613, - "TEXCOORD_0" : 614 - }, - "indices" : 615, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_153", - "primitives" : [ - { - "attributes" : { - "POSITION" : 616, - "NORMAL" : 617, - "TEXCOORD_0" : 618 - }, - "indices" : 619, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_154", - "primitives" : [ - { - "attributes" : { - "POSITION" : 620, - "NORMAL" : 621, - "TEXCOORD_0" : 622 - }, - "indices" : 623, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_155", - "primitives" : [ - { - "attributes" : { - "POSITION" : 624, - "NORMAL" : 625, - "TEXCOORD_0" : 626 - }, - "indices" : 627, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_156", - "primitives" : [ - { - "attributes" : { - "POSITION" : 628, - "NORMAL" : 629, - "TEXCOORD_0" : 630 - }, - "indices" : 631, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_157", - "primitives" : [ - { - "attributes" : { - "POSITION" : 632, - "NORMAL" : 633, - "TEXCOORD_0" : 634 - }, - "indices" : 635, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_158", - "primitives" : [ - { - "attributes" : { - "POSITION" : 636, - "NORMAL" : 637, - "TEXCOORD_0" : 638 - }, - "indices" : 639, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_159", - "primitives" : [ - { - "attributes" : { - "POSITION" : 640, - "NORMAL" : 641, - "TEXCOORD_0" : 642 - }, - "indices" : 643, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_160", - "primitives" : [ - { - "attributes" : { - "POSITION" : 644, - "NORMAL" : 645, - "TEXCOORD_0" : 646 - }, - "indices" : 647, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_172", - "primitives" : [ - { - "attributes" : { - "POSITION" : 648, - "NORMAL" : 649, - "TEXCOORD_0" : 650 - }, - "indices" : 651, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_162", - "primitives" : [ - { - "attributes" : { - "POSITION" : 652, - "NORMAL" : 653, - "TEXCOORD_0" : 654 - }, - "indices" : 655, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_163", - "primitives" : [ - { - "attributes" : { - "POSITION" : 656, - "NORMAL" : 657, - "TEXCOORD_0" : 658 - }, - "indices" : 659, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_164", - "primitives" : [ - { - "attributes" : { - "POSITION" : 660, - "NORMAL" : 661, - "TEXCOORD_0" : 662 - }, - "indices" : 663, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_165", - "primitives" : [ - { - "attributes" : { - "POSITION" : 664, - "NORMAL" : 665, - "TEXCOORD_0" : 666 - }, - "indices" : 667, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_166", - "primitives" : [ - { - "attributes" : { - "POSITION" : 668, - "NORMAL" : 669, - "TEXCOORD_0" : 670 - }, - "indices" : 671, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_167", - "primitives" : [ - { - "attributes" : { - "POSITION" : 672, - "NORMAL" : 673, - "TEXCOORD_0" : 674 - }, - "indices" : 675, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_168", - "primitives" : [ - { - "attributes" : { - "POSITION" : 676, - "NORMAL" : 677, - "TEXCOORD_0" : 678 - }, - "indices" : 679, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_169", - "primitives" : [ - { - "attributes" : { - "POSITION" : 680, - "NORMAL" : 681, - "TEXCOORD_0" : 682 - }, - "indices" : 683, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_170", - "primitives" : [ - { - "attributes" : { - "POSITION" : 684, - "NORMAL" : 685, - "TEXCOORD_0" : 686 - }, - "indices" : 687, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_171", - "primitives" : [ - { - "attributes" : { - "POSITION" : 688, - "NORMAL" : 689, - "TEXCOORD_0" : 690 - }, - "indices" : 691, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_183", - "primitives" : [ - { - "attributes" : { - "POSITION" : 692, - "NORMAL" : 693, - "TEXCOORD_0" : 694 - }, - "indices" : 695, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_173", - "primitives" : [ - { - "attributes" : { - "POSITION" : 696, - "NORMAL" : 697, - "TEXCOORD_0" : 698 - }, - "indices" : 699, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_174", - "primitives" : [ - { - "attributes" : { - "POSITION" : 700, - "NORMAL" : 701, - "TEXCOORD_0" : 702 - }, - "indices" : 703, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_175", - "primitives" : [ - { - "attributes" : { - "POSITION" : 704, - "NORMAL" : 705, - "TEXCOORD_0" : 706 - }, - "indices" : 707, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_176", - "primitives" : [ - { - "attributes" : { - "POSITION" : 708, - "NORMAL" : 709, - "TEXCOORD_0" : 710 - }, - "indices" : 711, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_177", - "primitives" : [ - { - "attributes" : { - "POSITION" : 712, - "NORMAL" : 713, - "TEXCOORD_0" : 714 - }, - "indices" : 715, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_178", - "primitives" : [ - { - "attributes" : { - "POSITION" : 716, - "NORMAL" : 717, - "TEXCOORD_0" : 718 - }, - "indices" : 719, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_179", - "primitives" : [ - { - "attributes" : { - "POSITION" : 720, - "NORMAL" : 721, - "TEXCOORD_0" : 722 - }, - "indices" : 723, - "material" : 10 - } - ] - }, - { - "name" : "Mesh_180", - "primitives" : [ - { - "attributes" : { - "POSITION" : 724, - "NORMAL" : 725, - "TEXCOORD_0" : 726 - }, - "indices" : 727, - "material" : 11 - } - ] - }, - { - "name" : "Mesh_181", - "primitives" : [ - { - "attributes" : { - "POSITION" : 728, - "NORMAL" : 729, - "TEXCOORD_0" : 730 - }, - "indices" : 731, - "material" : 4 - } - ] - }, - { - "name" : "Mesh_182", - "primitives" : [ - { - "attributes" : { - "POSITION" : 732, - "NORMAL" : 733, - "TEXCOORD_0" : 734 - }, - "indices" : 735, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_194", - "primitives" : [ - { - "attributes" : { - "POSITION" : 736, - "NORMAL" : 737, - "TEXCOORD_0" : 738 - }, - "indices" : 739, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_184", - "primitives" : [ - { - "attributes" : { - "POSITION" : 740, - "NORMAL" : 741, - "TEXCOORD_0" : 742 - }, - "indices" : 743, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_185", - "primitives" : [ - { - "attributes" : { - "POSITION" : 744, - "NORMAL" : 745, - "TEXCOORD_0" : 746 - }, - "indices" : 747, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_186", - "primitives" : [ - { - "attributes" : { - "POSITION" : 748, - "NORMAL" : 749, - "TEXCOORD_0" : 750 - }, - "indices" : 751, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_187", - "primitives" : [ - { - "attributes" : { - "POSITION" : 752, - "NORMAL" : 753, - "TEXCOORD_0" : 754 - }, - "indices" : 755, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_188", - "primitives" : [ - { - "attributes" : { - "POSITION" : 756, - "NORMAL" : 757, - "TEXCOORD_0" : 758 - }, - "indices" : 735, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_189", - "primitives" : [ - { - "attributes" : { - "POSITION" : 759, - "NORMAL" : 760, - "TEXCOORD_0" : 761 - }, - "indices" : 762, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_190", - "primitives" : [ - { - "attributes" : { - "POSITION" : 763, - "NORMAL" : 764, - "TEXCOORD_0" : 765 - }, - "indices" : 735, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_191", - "primitives" : [ - { - "attributes" : { - "POSITION" : 766, - "NORMAL" : 767, - "TEXCOORD_0" : 768 - }, - "indices" : 769, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_192", - "primitives" : [ - { - "attributes" : { - "POSITION" : 770, - "NORMAL" : 771, - "TEXCOORD_0" : 772 - }, - "indices" : 773, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_193", - "primitives" : [ - { - "attributes" : { - "POSITION" : 774, - "NORMAL" : 775, - "TEXCOORD_0" : 776 - }, - "indices" : 777, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_205", - "primitives" : [ - { - "attributes" : { - "POSITION" : 778, - "NORMAL" : 779, - "TEXCOORD_0" : 780 - }, - "indices" : 781, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_195", - "primitives" : [ - { - "attributes" : { - "POSITION" : 782, - "NORMAL" : 783, - "TEXCOORD_0" : 784 - }, - "indices" : 785, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_196", - "primitives" : [ - { - "attributes" : { - "POSITION" : 786, - "NORMAL" : 787, - "TEXCOORD_0" : 788 - }, - "indices" : 789, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_197", - "primitives" : [ - { - "attributes" : { - "POSITION" : 790, - "NORMAL" : 791, - "TEXCOORD_0" : 792 - }, - "indices" : 769, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_198", - "primitives" : [ - { - "attributes" : { - "POSITION" : 793, - "NORMAL" : 794, - "TEXCOORD_0" : 795 - }, - "indices" : 796, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_199", - "primitives" : [ - { - "attributes" : { - "POSITION" : 797, - "NORMAL" : 798, - "TEXCOORD_0" : 799 - }, - "indices" : 769, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_200", - "primitives" : [ - { - "attributes" : { - "POSITION" : 800, - "NORMAL" : 801, - "TEXCOORD_0" : 802 - }, - "indices" : 803, - "material" : 0 - } - ] - }, - { - "name" : "Mesh_201", - "primitives" : [ - { - "attributes" : { - "POSITION" : 804, - "NORMAL" : 805, - "TEXCOORD_0" : 806 - }, - "indices" : 807, - "material" : 0 - } - ] - }, - { - "name" : "Mesh_202", - "primitives" : [ - { - "attributes" : { - "POSITION" : 808, - "NORMAL" : 809, - "TEXCOORD_0" : 810 - }, - "indices" : 811, - "material" : 0 - } - ] - }, - { - "name" : "Mesh_203", - "primitives" : [ - { - "attributes" : { - "POSITION" : 812, - "NORMAL" : 813, - "TEXCOORD_0" : 814 - }, - "indices" : 815, - "material" : 0 - } - ] - }, - { - "name" : "Mesh_204", - "primitives" : [ - { - "attributes" : { - "POSITION" : 816, - "NORMAL" : 817, - "TEXCOORD_0" : 818 - }, - "indices" : 819, - "material" : 0 - } - ] - }, - { - "name" : "Mesh_216", - "primitives" : [ - { - "attributes" : { - "POSITION" : 820, - "NORMAL" : 821, - "TEXCOORD_0" : 822 - }, - "indices" : 823, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_206", - "primitives" : [ - { - "attributes" : { - "POSITION" : 824, - "NORMAL" : 825, - "TEXCOORD_0" : 826 - }, - "indices" : 827, - "material" : 0 - } - ] - }, - { - "name" : "Mesh_207", - "primitives" : [ - { - "attributes" : { - "POSITION" : 828, - "NORMAL" : 829, - "TEXCOORD_0" : 830 - }, - "indices" : 831, - "material" : 0 - } - ] - }, - { - "name" : "Mesh_208", - "primitives" : [ - { - "attributes" : { - "POSITION" : 832, - "NORMAL" : 833, - "TEXCOORD_0" : 834 - }, - "indices" : 835, - "material" : 13 - } - ] - }, - { - "name" : "Mesh_209", - "primitives" : [ - { - "attributes" : { - "POSITION" : 836, - "NORMAL" : 837, - "TEXCOORD_0" : 838 - }, - "indices" : 839, - "material" : 14 - } - ] - }, - { - "name" : "Mesh_210", - "primitives" : [ - { - "attributes" : { - "POSITION" : 840, - "NORMAL" : 841, - "TEXCOORD_0" : 842 - }, - "indices" : 843, - "material" : 15 - } - ] - }, - { - "name" : "Mesh_211", - "primitives" : [ - { - "attributes" : { - "POSITION" : 844, - "NORMAL" : 845, - "TEXCOORD_0" : 846 - }, - "indices" : 847, - "material" : 13 - } - ] - }, - { - "name" : "Mesh_212", - "primitives" : [ - { - "attributes" : { - "POSITION" : 848, - "NORMAL" : 849, - "TEXCOORD_0" : 850 - }, - "indices" : 851, - "material" : 14 - } - ] - }, - { - "name" : "Mesh_213", - "primitives" : [ - { - "attributes" : { - "POSITION" : 852, - "NORMAL" : 853, - "TEXCOORD_0" : 854 - }, - "indices" : 855, - "material" : 13 - } - ] - }, - { - "name" : "Mesh_214", - "primitives" : [ - { - "attributes" : { - "POSITION" : 856, - "NORMAL" : 857, - "TEXCOORD_0" : 858 - }, - "indices" : 859, - "material" : 15 - } - ] - }, - { - "name" : "Mesh_215", - "primitives" : [ - { - "attributes" : { - "POSITION" : 860, - "NORMAL" : 861, - "TEXCOORD_0" : 862 - }, - "indices" : 863, - "material" : 14 - } - ] - }, - { - "name" : "Mesh_227", - "primitives" : [ - { - "attributes" : { - "POSITION" : 864, - "NORMAL" : 865, - "TEXCOORD_0" : 866 - }, - "indices" : 867, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_217", - "primitives" : [ - { - "attributes" : { - "POSITION" : 868, - "NORMAL" : 869, - "TEXCOORD_0" : 870 - }, - "indices" : 871, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_218", - "primitives" : [ - { - "attributes" : { - "POSITION" : 872, - "NORMAL" : 873, - "TEXCOORD_0" : 874 - }, - "indices" : 875, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_219", - "primitives" : [ - { - "attributes" : { - "POSITION" : 876, - "NORMAL" : 877, - "TEXCOORD_0" : 878 - }, - "indices" : 879, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_220", - "primitives" : [ - { - "attributes" : { - "POSITION" : 880, - "NORMAL" : 881, - "TEXCOORD_0" : 882 - }, - "indices" : 883, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_221", - "primitives" : [ - { - "attributes" : { - "POSITION" : 884, - "NORMAL" : 885, - "TEXCOORD_0" : 886 - }, - "indices" : 875, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_222", - "primitives" : [ - { - "attributes" : { - "POSITION" : 887, - "NORMAL" : 888, - "TEXCOORD_0" : 889 - }, - "indices" : 890, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_223", - "primitives" : [ - { - "attributes" : { - "POSITION" : 891, - "NORMAL" : 892, - "TEXCOORD_0" : 893 - }, - "indices" : 894, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_224", - "primitives" : [ - { - "attributes" : { - "POSITION" : 895, - "NORMAL" : 896, - "TEXCOORD_0" : 897 - }, - "indices" : 898, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_225", - "primitives" : [ - { - "attributes" : { - "POSITION" : 899, - "NORMAL" : 900, - "TEXCOORD_0" : 901 - }, - "indices" : 879, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_226", - "primitives" : [ - { - "attributes" : { - "POSITION" : 902, - "NORMAL" : 903, - "TEXCOORD_0" : 904 - }, - "indices" : 905, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_238", - "primitives" : [ - { - "attributes" : { - "POSITION" : 906, - "NORMAL" : 907, - "TEXCOORD_0" : 908 - }, - "indices" : 909, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_228", - "primitives" : [ - { - "attributes" : { - "POSITION" : 910, - "NORMAL" : 911, - "TEXCOORD_0" : 912 - }, - "indices" : 875, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_229", - "primitives" : [ - { - "attributes" : { - "POSITION" : 913, - "NORMAL" : 914, - "TEXCOORD_0" : 915 - }, - "indices" : 879, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_230", - "primitives" : [ - { - "attributes" : { - "POSITION" : 916, - "NORMAL" : 917, - "TEXCOORD_0" : 918 - }, - "indices" : 919, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_231", - "primitives" : [ - { - "attributes" : { - "POSITION" : 920, - "NORMAL" : 921, - "TEXCOORD_0" : 922 - }, - "indices" : 875, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_232", - "primitives" : [ - { - "attributes" : { - "POSITION" : 923, - "NORMAL" : 924, - "TEXCOORD_0" : 925 - }, - "indices" : 879, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_233", - "primitives" : [ - { - "attributes" : { - "POSITION" : 926, - "NORMAL" : 927, - "TEXCOORD_0" : 928 - }, - "indices" : 871, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_234", - "primitives" : [ - { - "attributes" : { - "POSITION" : 929, - "NORMAL" : 930, - "TEXCOORD_0" : 931 - }, - "indices" : 875, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_235", - "primitives" : [ - { - "attributes" : { - "POSITION" : 932, - "NORMAL" : 933, - "TEXCOORD_0" : 934 - }, - "indices" : 879, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_236", - "primitives" : [ - { - "attributes" : { - "POSITION" : 935, - "NORMAL" : 936, - "TEXCOORD_0" : 937 - }, - "indices" : 919, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_237", - "primitives" : [ - { - "attributes" : { - "POSITION" : 938, - "NORMAL" : 939, - "TEXCOORD_0" : 940 - }, - "indices" : 875, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_249", - "primitives" : [ - { - "attributes" : { - "POSITION" : 941, - "NORMAL" : 942, - "TEXCOORD_0" : 943 - }, - "indices" : 944, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_239", - "primitives" : [ - { - "attributes" : { - "POSITION" : 945, - "NORMAL" : 946, - "TEXCOORD_0" : 947 - }, - "indices" : 879, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_240", - "primitives" : [ - { - "attributes" : { - "POSITION" : 948, - "NORMAL" : 949, - "TEXCOORD_0" : 950 - }, - "indices" : 883, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_241", - "primitives" : [ - { - "attributes" : { - "POSITION" : 951, - "NORMAL" : 952, - "TEXCOORD_0" : 953 - }, - "indices" : 875, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_242", - "primitives" : [ - { - "attributes" : { - "POSITION" : 954, - "NORMAL" : 955, - "TEXCOORD_0" : 956 - }, - "indices" : 890, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_243", - "primitives" : [ - { - "attributes" : { - "POSITION" : 957, - "NORMAL" : 958, - "TEXCOORD_0" : 959 - }, - "indices" : 894, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_244", - "primitives" : [ - { - "attributes" : { - "POSITION" : 960, - "NORMAL" : 961, - "TEXCOORD_0" : 962 - }, - "indices" : 898, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_245", - "primitives" : [ - { - "attributes" : { - "POSITION" : 963, - "NORMAL" : 964, - "TEXCOORD_0" : 965 - }, - "indices" : 879, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_246", - "primitives" : [ - { - "attributes" : { - "POSITION" : 966, - "NORMAL" : 967, - "TEXCOORD_0" : 968 - }, - "indices" : 905, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_247", - "primitives" : [ - { - "attributes" : { - "POSITION" : 969, - "NORMAL" : 970, - "TEXCOORD_0" : 971 - }, - "indices" : 875, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_248", - "primitives" : [ - { - "attributes" : { - "POSITION" : 972, - "NORMAL" : 973, - "TEXCOORD_0" : 974 - }, - "indices" : 879, - "material" : 12 - } - ] - }, - { - "name" : "Mesh_260", - "primitives" : [ - { - "attributes" : { - "POSITION" : 975, - "NORMAL" : 976, - "TEXCOORD_0" : 977 - }, - "indices" : 978, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_250", - "primitives" : [ - { - "attributes" : { - "POSITION" : 979, - "NORMAL" : 980, - "TEXCOORD_0" : 981 - }, - "indices" : 982, - "material" : 16 - } - ] - }, - { - "name" : "Mesh_251", - "primitives" : [ - { - "attributes" : { - "POSITION" : 983, - "NORMAL" : 984, - "TEXCOORD_0" : 985 - }, - "indices" : 986, - "material" : 17 - } - ] - }, - { - "name" : "Mesh_252", - "primitives" : [ - { - "attributes" : { - "POSITION" : 987, - "NORMAL" : 988, - "TEXCOORD_0" : 989 - }, - "indices" : 990, - "material" : 18 - } - ] - }, - { - "name" : "Mesh_253", - "primitives" : [ - { - "attributes" : { - "POSITION" : 991, - "NORMAL" : 992, - "TEXCOORD_0" : 993 - }, - "indices" : 994, - "material" : 17 - } - ] - }, - { - "name" : "Mesh_254", - "primitives" : [ - { - "attributes" : { - "POSITION" : 995, - "NORMAL" : 996, - "TEXCOORD_0" : 997 - }, - "indices" : 986, - "material" : 18 - } - ] - }, - { - "name" : "Mesh_255", - "primitives" : [ - { - "attributes" : { - "POSITION" : 998, - "NORMAL" : 999, - "TEXCOORD_0" : 1000 - }, - "indices" : 1001, - "material" : 17 - } - ] - }, - { - "name" : "Mesh_256", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1002, - "NORMAL" : 1003, - "TEXCOORD_0" : 1004 - }, - "indices" : 986, - "material" : 16 - } - ] - }, - { - "name" : "Mesh_257", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1005, - "NORMAL" : 1006, - "TEXCOORD_0" : 1007 - }, - "indices" : 1001, - "material" : 18 - } - ] - }, - { - "name" : "Mesh_258", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1008, - "NORMAL" : 1009, - "TEXCOORD_0" : 1010 - }, - "indices" : 986, - "material" : 17 - } - ] - }, - { - "name" : "Mesh_259", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1011, - "NORMAL" : 1012, - "TEXCOORD_0" : 1013 - }, - "indices" : 1014, - "material" : 16 - } - ] - }, - { - "name" : "Mesh_271", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1015, - "NORMAL" : 1016, - "TEXCOORD_0" : 1017 - }, - "indices" : 1018, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_261", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1019, - "NORMAL" : 1020, - "TEXCOORD_0" : 1021 - }, - "indices" : 1022, - "material" : 19 - } - ] - }, - { - "name" : "Mesh_262", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1023, - "NORMAL" : 1024, - "TEXCOORD_0" : 1025 - }, - "indices" : 1026, - "material" : 19 - } - ] - }, - { - "name" : "Mesh_263", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1027, - "NORMAL" : 1028, - "TEXCOORD_0" : 1029 - }, - "indices" : 1030, - "material" : 19 - } - ] - }, - { - "name" : "Mesh_264", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1031, - "NORMAL" : 1032, - "TEXCOORD_0" : 1033 - }, - "indices" : 1026, - "material" : 19 - } - ] - }, - { - "name" : "Mesh_265", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1034, - "NORMAL" : 1035, - "TEXCOORD_0" : 1036 - }, - "indices" : 1037, - "material" : 20 - } - ] - }, - { - "name" : "Mesh_266", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1038, - "NORMAL" : 1039, - "TEXCOORD_0" : 1040 - }, - "indices" : 1041, - "material" : 20 - } - ] - }, - { - "name" : "Mesh_267", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1042, - "NORMAL" : 1043, - "TEXCOORD_0" : 1044 - }, - "indices" : 1045, - "material" : 20 - } - ] - }, - { - "name" : "Mesh_268", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1046, - "NORMAL" : 1047, - "TEXCOORD_0" : 1048 - }, - "indices" : 1049, - "material" : 20 - } - ] - }, - { - "name" : "Mesh_269", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1050, - "NORMAL" : 1051, - "TEXCOORD_0" : 1052 - }, - "indices" : 1053, - "material" : 20 - } - ] - }, - { - "name" : "Mesh_270", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1054, - "NORMAL" : 1055, - "TEXCOORD_0" : 1056 - }, - "indices" : 1022, - "material" : 19 - } - ] - }, - { - "name" : "Mesh_282", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1057, - "NORMAL" : 1058, - "TEXCOORD_0" : 1059 - }, - "indices" : 1060, - "material" : 4 - } - ] - }, - { - "name" : "Mesh_272", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1061, - "NORMAL" : 1062, - "TEXCOORD_0" : 1063 - }, - "indices" : 1064, - "material" : 19 - } - ] - }, - { - "name" : "Mesh_273", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1065, - "NORMAL" : 1066, - "TEXCOORD_0" : 1067 - }, - "indices" : 1068, - "material" : 19 - } - ] - }, - { - "name" : "Mesh_274", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1069, - "NORMAL" : 1070, - "TEXCOORD_0" : 1071 - }, - "indices" : 1026, - "material" : 19 - } - ] - }, - { - "name" : "Mesh_275", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1072, - "NORMAL" : 1073, - "TEXCOORD_0" : 1074 - }, - "indices" : 1037, - "material" : 20 - } - ] - }, - { - "name" : "Mesh_276", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1075, - "NORMAL" : 1076, - "TEXCOORD_0" : 1077 - }, - "indices" : 1041, - "material" : 20 - } - ] - }, - { - "name" : "Mesh_277", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1078, - "NORMAL" : 1079, - "TEXCOORD_0" : 1080 - }, - "indices" : 1081, - "material" : 20 - } - ] - }, - { - "name" : "Mesh_278", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1082, - "NORMAL" : 1083, - "TEXCOORD_0" : 1084 - }, - "indices" : 1085, - "material" : 20 - } - ] - }, - { - "name" : "Mesh_279", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1086, - "NORMAL" : 1087, - "TEXCOORD_0" : 1088 - }, - "indices" : 1053, - "material" : 20 - } - ] - }, - { - "name" : "Mesh_280", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1089, - "NORMAL" : 1090, - "TEXCOORD_0" : 1091 - }, - "indices" : 1092, - "material" : 19 - } - ] - }, - { - "name" : "Mesh_281", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1093, - "NORMAL" : 1094, - "TEXCOORD_0" : 1095 - }, - "indices" : 1096, - "material" : 19 - } - ] - }, - { - "name" : "Mesh_293", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1097, - "NORMAL" : 1098, - "TEXCOORD_0" : 1099 - }, - "indices" : 1100, - "material" : 6 - } - ] - }, - { - "name" : "Mesh_283", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1101, - "NORMAL" : 1102, - "TEXCOORD_0" : 1103 - }, - "indices" : 1104, - "material" : 19 - } - ] - }, - { - "name" : "Mesh_284", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1105, - "NORMAL" : 1106, - "TEXCOORD_0" : 1107 - }, - "indices" : 1096, - "material" : 19 - } - ] - }, - { - "name" : "Mesh_285", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1108, - "NORMAL" : 1109, - "TEXCOORD_0" : 1110 - }, - "indices" : 1111, - "material" : 20 - } - ] - }, - { - "name" : "Mesh_286", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1112, - "NORMAL" : 1113, - "TEXCOORD_0" : 1114 - }, - "indices" : 1115, - "material" : 20 - } - ] - }, - { - "name" : "Mesh_287", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1116, - "NORMAL" : 1117, - "TEXCOORD_0" : 1118 - }, - "indices" : 1119, - "material" : 20 - } - ] - }, - { - "name" : "Mesh_288", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1120, - "NORMAL" : 1121, - "TEXCOORD_0" : 1122 - }, - "indices" : 1123, - "material" : 20 - } - ] - }, - { - "name" : "Mesh_289", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1124, - "NORMAL" : 1125, - "TEXCOORD_0" : 1126 - }, - "indices" : 1127, - "material" : 20 - } - ] - }, - { - "name" : "Mesh_290", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1128, - "NORMAL" : 1129, - "TEXCOORD_0" : 1130 - }, - "indices" : 1092, - "material" : 19 - } - ] - }, - { - "name" : "Mesh_291", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1131, - "NORMAL" : 1132, - "TEXCOORD_0" : 1133 - }, - "indices" : 1134, - "material" : 19 - } - ] - }, - { - "name" : "Mesh_292", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1135, - "NORMAL" : 1136, - "TEXCOORD_0" : 1137 - }, - "indices" : 1104, - "material" : 19 - } - ] - }, - { - "name" : "Mesh_304", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1138, - "NORMAL" : 1139, - "TEXCOORD_0" : 1140 - }, - "indices" : 1141, - "material" : 4 - } - ] - }, - { - "name" : "Mesh_294", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1142, - "NORMAL" : 1143, - "TEXCOORD_0" : 1144 - }, - "indices" : 1096, - "material" : 19 - } - ] - }, - { - "name" : "Mesh_295", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1145, - "NORMAL" : 1146, - "TEXCOORD_0" : 1147 - }, - "indices" : 1111, - "material" : 20 - } - ] - }, - { - "name" : "Mesh_296", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1148, - "NORMAL" : 1149, - "TEXCOORD_0" : 1150 - }, - "indices" : 1151, - "material" : 20 - } - ] - }, - { - "name" : "Mesh_297", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1152, - "NORMAL" : 1153, - "TEXCOORD_0" : 1154 - }, - "indices" : 1085, - "material" : 20 - } - ] - }, - { - "name" : "Mesh_298", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1155, - "NORMAL" : 1156, - "TEXCOORD_0" : 1157 - }, - "indices" : 1081, - "material" : 20 - } - ] - }, - { - "name" : "Mesh_299", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1158, - "NORMAL" : 1159, - "TEXCOORD_0" : 1160 - }, - "indices" : 1127, - "material" : 20 - } - ] - }, - { - "name" : "Mesh_300", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1161, - "NORMAL" : 1162, - "TEXCOORD_0" : 1163 - }, - "indices" : 1164, - "material" : 1 - }, - { - "attributes" : { - "POSITION" : 1165, - "NORMAL" : 1166, - "TEXCOORD_0" : 1167 - }, - "indices" : 1168, - "material" : 2 - } - ] - }, - { - "name" : "Mesh_301", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1169, - "NORMAL" : 1170, - "TEXCOORD_0" : 1171 - }, - "indices" : 1164, - "material" : 1 - }, - { - "attributes" : { - "POSITION" : 1172, - "NORMAL" : 1173, - "TEXCOORD_0" : 1174 - }, - "indices" : 1168, - "material" : 2 - } - ] - }, - { - "name" : "Mesh_302", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1175, - "NORMAL" : 1176, - "TEXCOORD_0" : 1177 - }, - "indices" : 7, - "material" : 1 - }, - { - "attributes" : { - "POSITION" : 1178, - "NORMAL" : 1179, - "TEXCOORD_0" : 1180 - }, - "indices" : 11, - "material" : 2 - } - ] - }, - { - "name" : "Mesh_303", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1181, - "NORMAL" : 1182, - "TEXCOORD_0" : 1183 - }, - "indices" : 1184, - "material" : 1 - }, - { - "attributes" : { - "POSITION" : 1185, - "NORMAL" : 1186, - "TEXCOORD_0" : 1187 - }, - "indices" : 1188, - "material" : 2 - } - ] - }, - { - "name" : "Mesh_315", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1189, - "NORMAL" : 1190, - "TEXCOORD_0" : 1191 - }, - "indices" : 1192, - "material" : 5 - } - ] - }, - { - "name" : "Mesh_305", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1193, - "NORMAL" : 1194, - "TEXCOORD_0" : 1195 - }, - "indices" : 1184, - "material" : 1 - }, - { - "attributes" : { - "POSITION" : 1196, - "NORMAL" : 1197, - "TEXCOORD_0" : 1198 - }, - "indices" : 1199, - "material" : 2 - } - ] - }, - { - "name" : "Mesh_306", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1200, - "NORMAL" : 1201, - "TEXCOORD_0" : 1202 - }, - "indices" : 1184, - "material" : 1 - }, - { - "attributes" : { - "POSITION" : 1203, - "NORMAL" : 1204, - "TEXCOORD_0" : 1205 - }, - "indices" : 1199, - "material" : 2 - } - ] - }, - { - "name" : "Mesh_307", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1206, - "NORMAL" : 1207, - "TEXCOORD_0" : 1208 - }, - "indices" : 1184, - "material" : 1 - }, - { - "attributes" : { - "POSITION" : 1209, - "NORMAL" : 1210, - "TEXCOORD_0" : 1211 - }, - "indices" : 1188, - "material" : 2 - } - ] - }, - { - "name" : "Mesh_308", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1212, - "NORMAL" : 1213, - "TEXCOORD_0" : 1214 - }, - "indices" : 1215, - "material" : 21 - } - ] - }, - { - "name" : "Mesh_309", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1216, - "NORMAL" : 1217, - "TEXCOORD_0" : 1218 - }, - "indices" : 1219, - "material" : 21 - } - ] - }, - { - "name" : "Mesh_310", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1220, - "NORMAL" : 1221, - "TEXCOORD_0" : 1222 - }, - "indices" : 1223, - "material" : 21 - } - ] - }, - { - "name" : "Mesh_311", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1224, - "NORMAL" : 1225, - "TEXCOORD_0" : 1226 - }, - "indices" : 1227, - "material" : 21 - } - ] - }, - { - "name" : "Mesh_312", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1228, - "NORMAL" : 1229, - "TEXCOORD_0" : 1230 - }, - "indices" : 1231, - "material" : 3 - }, - { - "attributes" : { - "POSITION" : 1232, - "NORMAL" : 1233, - "TEXCOORD_0" : 1234 - }, - "indices" : 1235, - "material" : 22 - } - ] - }, - { - "name" : "Mesh_313", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1236, - "NORMAL" : 1237, - "TEXCOORD_0" : 1238 - }, - "indices" : 1239, - "material" : 3 - }, - { - "attributes" : { - "POSITION" : 1240, - "NORMAL" : 1241, - "TEXCOORD_0" : 1242 - }, - "indices" : 1243, - "material" : 22 - } - ] - }, - { - "name" : "Mesh_314", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1244, - "NORMAL" : 1245, - "TEXCOORD_0" : 1246 - }, - "indices" : 1247, - "material" : 4 - } - ] - }, - { - "name" : "Mesh_319", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1248, - "NORMAL" : 1249, - "TEXCOORD_0" : 1250 - }, - "indices" : 1251, - "material" : 6 - } - ] - }, - { - "name" : "Mesh_316", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1252, - "NORMAL" : 1253, - "TEXCOORD_0" : 1254 - }, - "indices" : 1255, - "material" : 23 - } - ] - }, - { - "name" : "Mesh_317", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1256, - "NORMAL" : 1257, - "TEXCOORD_0" : 1258 - }, - "indices" : 1259, - "material" : 23 - } - ] - }, - { - "name" : "Mesh_318", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1260, - "NORMAL" : 1261, - "TEXCOORD_0" : 1262 - }, - "indices" : 1263, - "material" : 4 - } - ] - }, - { - "name" : "Mesh_320", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1264, - "NORMAL" : 1265, - "TEXCOORD_0" : 1266 - }, - "indices" : 1267, - "material" : 5 - } - ] - }, - { - "name" : "Mesh_321", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1268, - "NORMAL" : 1269, - "TEXCOORD_0" : 1270 - }, - "indices" : 1271, - "material" : 6 - } - ] - }, - { - "name" : "Mesh_322", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1272, - "NORMAL" : 1273, - "TEXCOORD_0" : 1274 - }, - "indices" : 1275, - "material" : 5 - } - ] - }, - { - "name" : "Mesh_323", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1276, - "NORMAL" : 1277, - "TEXCOORD_0" : 1278 - }, - "indices" : 1279, - "material" : 6 - } - ] - }, - { - "name" : "Mesh_324", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1280, - "NORMAL" : 1281, - "TEXCOORD_0" : 1282 - }, - "indices" : 1192, - "material" : 5 - } - ] - }, - { - "name" : "Mesh_325", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1283, - "NORMAL" : 1284, - "TEXCOORD_0" : 1285 - }, - "indices" : 1286, - "material" : 6 - } - ] - }, - { - "name" : "Mesh_326", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1287, - "NORMAL" : 1288, - "TEXCOORD_0" : 1289 - }, - "indices" : 1290, - "material" : 5 - } - ] - }, - { - "name" : "Mesh_327", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1291, - "NORMAL" : 1292, - "TEXCOORD_0" : 1293 - }, - "indices" : 1294, - "material" : 6 - } - ] - }, - { - "name" : "Mesh_328", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1295, - "NORMAL" : 1296, - "TEXCOORD_0" : 1297 - }, - "indices" : 1298, - "material" : 5 - } - ] - }, - { - "name" : "Mesh_329", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1299, - "NORMAL" : 1300, - "TEXCOORD_0" : 1301 - }, - "indices" : 1302, - "material" : 6 - } - ] - }, - { - "name" : "Mesh_330", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1303, - "NORMAL" : 1304, - "TEXCOORD_0" : 1305 - }, - "indices" : 1298, - "material" : 5 - } - ] - }, - { - "name" : "Mesh_331", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1306, - "NORMAL" : 1307, - "TEXCOORD_0" : 1308 - }, - "indices" : 1309, - "material" : 6 - } - ] - }, - { - "name" : "Mesh_332", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1310, - "NORMAL" : 1311, - "TEXCOORD_0" : 1312 - }, - "indices" : 1298, - "material" : 5 - } - ] - }, - { - "name" : "Mesh_333", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1313, - "NORMAL" : 1314, - "TEXCOORD_0" : 1315 - }, - "indices" : 1316, - "material" : 6 - } - ] - }, - { - "name" : "Mesh_334", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1317, - "NORMAL" : 1318, - "TEXCOORD_0" : 1319 - }, - "indices" : 1298, - "material" : 5 - } - ] - }, - { - "name" : "Mesh_335", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1320, - "NORMAL" : 1321, - "TEXCOORD_0" : 1322 - }, - "indices" : 1323, - "material" : 6 - } - ] - }, - { - "name" : "Mesh_336", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1324, - "NORMAL" : 1325, - "TEXCOORD_0" : 1326 - }, - "indices" : 1327, - "material" : 5 - } - ] - }, - { - "name" : "Mesh_337", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1328, - "NORMAL" : 1329, - "TEXCOORD_0" : 1330 - }, - "indices" : 1331, - "material" : 5 - } - ] - }, - { - "name" : "Mesh_338", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1332, - "NORMAL" : 1333, - "TEXCOORD_0" : 1334 - }, - "indices" : 1335, - "material" : 5 - } - ] - }, - { - "name" : "Mesh_339", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1336, - "NORMAL" : 1337, - "TEXCOORD_0" : 1338 - }, - "indices" : 1339, - "material" : 5 - } - ] - }, - { - "name" : "Mesh_340", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1340, - "NORMAL" : 1341, - "TEXCOORD_0" : 1342 - }, - "indices" : 1343, - "material" : 5 - } - ] - }, - { - "name" : "Mesh_341", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1344, - "NORMAL" : 1345, - "TEXCOORD_0" : 1346 - }, - "indices" : 1347, - "material" : 5 - } - ] - }, - { - "name" : "Mesh_342", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1348, - "NORMAL" : 1349, - "TEXCOORD_0" : 1350 - }, - "indices" : 1351, - "material" : 5 - } - ] - }, - { - "name" : "Mesh_343", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1352, - "NORMAL" : 1353, - "TEXCOORD_0" : 1354 - }, - "indices" : 1355, - "material" : 5 - } - ] - }, - { - "name" : "Mesh_344", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1356, - "NORMAL" : 1357, - "TEXCOORD_0" : 1358 - }, - "indices" : 1359, - "material" : 5 - } - ] - }, - { - "name" : "Mesh_345", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1360, - "NORMAL" : 1361, - "TEXCOORD_0" : 1362 - }, - "indices" : 1363, - "material" : 5 - } - ] - }, - { - "name" : "Mesh_346", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1364, - "NORMAL" : 1365, - "TEXCOORD_0" : 1366 - }, - "indices" : 1367, - "material" : 5 - } - ] - }, - { - "name" : "Mesh_347", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1368, - "NORMAL" : 1369, - "TEXCOORD_0" : 1370 - }, - "indices" : 1371, - "material" : 4 - } - ] - }, - { - "name" : "Mesh_348", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1372, - "NORMAL" : 1373, - "TEXCOORD_0" : 1374 - }, - "indices" : 1375, - "material" : 5 - } - ] - }, - { - "name" : "Mesh_349", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1376, - "NORMAL" : 1377, - "TEXCOORD_0" : 1378 - }, - "indices" : 1379, - "material" : 4 - } - ] - }, - { - "name" : "Mesh_350", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1380, - "NORMAL" : 1381, - "TEXCOORD_0" : 1382 - }, - "indices" : 1383, - "material" : 4 - } - ] - }, - { - "name" : "Mesh_351", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1384, - "NORMAL" : 1385, - "TEXCOORD_0" : 1386 - }, - "indices" : 1387, - "material" : 24 - } - ] - }, - { - "name" : "Mesh_352", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1388, - "NORMAL" : 1389, - "TEXCOORD_0" : 1390 - }, - "indices" : 1391, - "material" : 4 - }, - { - "attributes" : { - "POSITION" : 1392, - "NORMAL" : 1393, - "TEXCOORD_0" : 1394 - }, - "indices" : 1395, - "material" : 24 - } - ] - }, - { - "name" : "Mesh_353", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1396, - "NORMAL" : 1397, - "TEXCOORD_0" : 1398 - }, - "indices" : 1399, - "material" : 4 - }, - { - "attributes" : { - "POSITION" : 1400, - "NORMAL" : 1401, - "TEXCOORD_0" : 1402 - }, - "indices" : 1403, - "material" : 24 - } - ] - }, - { - "name" : "Mesh_354", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1404, - "NORMAL" : 1405, - "TEXCOORD_0" : 1406 - }, - "indices" : 1407, - "material" : 24 - } - ] - }, - { - "name" : "Mesh_355", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1408, - "NORMAL" : 1409, - "TEXCOORD_0" : 1410 - }, - "indices" : 1411, - "material" : 24 - } - ] - }, - { - "name" : "Mesh_356", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1412, - "NORMAL" : 1413, - "TEXCOORD_0" : 1414 - }, - "indices" : 1415, - "material" : 4 - } - ] - }, - { - "name" : "Mesh_357", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1416, - "NORMAL" : 1417, - "TEXCOORD_0" : 1418 - }, - "indices" : 1419, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_358", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1420, - "NORMAL" : 1421, - "TEXCOORD_0" : 1422 - }, - "indices" : 1423, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_359", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1424, - "NORMAL" : 1425, - "TEXCOORD_0" : 1426 - }, - "indices" : 1427, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_360", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1428, - "NORMAL" : 1429, - "TEXCOORD_0" : 1430 - }, - "indices" : 1431, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_361", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1432, - "NORMAL" : 1433, - "TEXCOORD_0" : 1434 - }, - "indices" : 43, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_362", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1435, - "NORMAL" : 1436, - "TEXCOORD_0" : 1437 - }, - "indices" : 1438, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_363", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1439, - "NORMAL" : 1440, - "TEXCOORD_0" : 1441 - }, - "indices" : 1442, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_364", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1443, - "NORMAL" : 1444, - "TEXCOORD_0" : 1445 - }, - "indices" : 1446, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_365", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1447, - "NORMAL" : 1448, - "TEXCOORD_0" : 1449 - }, - "indices" : 1450, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_366", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1451, - "NORMAL" : 1452, - "TEXCOORD_0" : 1453 - }, - "indices" : 1454, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_367", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1455, - "NORMAL" : 1456, - "TEXCOORD_0" : 1457 - }, - "indices" : 1458, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_368", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1459, - "NORMAL" : 1460, - "TEXCOORD_0" : 1461 - }, - "indices" : 1462, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_369", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1463, - "NORMAL" : 1464, - "TEXCOORD_0" : 1465 - }, - "indices" : 1466, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_370", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1467, - "NORMAL" : 1468, - "TEXCOORD_0" : 1469 - }, - "indices" : 1470, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_371", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1471, - "NORMAL" : 1472, - "TEXCOORD_0" : 1473 - }, - "indices" : 1474, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_372", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1475, - "NORMAL" : 1476, - "TEXCOORD_0" : 1477 - }, - "indices" : 1478, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_373", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1479, - "NORMAL" : 1480, - "TEXCOORD_0" : 1481 - }, - "indices" : 1482, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_374", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1483, - "NORMAL" : 1484, - "TEXCOORD_0" : 1485 - }, - "indices" : 1486, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_375", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1487, - "NORMAL" : 1488, - "TEXCOORD_0" : 1489 - }, - "indices" : 1490, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_376", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1491, - "NORMAL" : 1492, - "TEXCOORD_0" : 1493 - }, - "indices" : 1494, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_377", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1495, - "NORMAL" : 1496, - "TEXCOORD_0" : 1497 - }, - "indices" : 1498, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_378", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1499, - "NORMAL" : 1500, - "TEXCOORD_0" : 1501 - }, - "indices" : 1502, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_379", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1503, - "NORMAL" : 1504, - "TEXCOORD_0" : 1505 - }, - "indices" : 1506, - "material" : 8 - } - ] - }, - { - "name" : "Mesh_380", - "primitives" : [ - { - "attributes" : { - "POSITION" : 1507, - "NORMAL" : 1508, - "TEXCOORD_0" : 1509 - }, - "indices" : 1510, - "material" : 8 - } - ] - } - ], - "textures" : [ - { - "sampler" : 0, - "source" : 0 - }, - { - "sampler" : 0, - "source" : 1 - }, - { - "sampler" : 0, - "source" : 2 - }, - { - "sampler" : 0, - "source" : 3 - }, - { - "sampler" : 0, - "source" : 4 - }, - { - "sampler" : 0, - "source" : 5 - }, - { - "sampler" : 0, - "source" : 6 - }, - { - "sampler" : 0, - "source" : 7 - }, - { - "sampler" : 0, - "source" : 8 - }, - { - "sampler" : 0, - "source" : 9 - }, - { - "sampler" : 0, - "source" : 10 - }, - { - "sampler" : 0, - "source" : 11 - }, - { - "sampler" : 0, - "source" : 12 - }, - { - "sampler" : 0, - "source" : 13 - }, - { - "sampler" : 0, - "source" : 14 - }, - { - "sampler" : 0, - "source" : 15 - }, - { - "sampler" : 0, - "source" : 16 - }, - { - "sampler" : 0, - "source" : 17 - }, - { - "sampler" : 0, - "source" : 18 - }, - { - "sampler" : 0, - "source" : 19 - }, - { - "sampler" : 0, - "source" : 20 - }, - { - "sampler" : 0, - "source" : 21 - }, - { - "sampler" : 0, - "source" : 22 - }, - { - "sampler" : 0, - "source" : 23 - }, - { - "sampler" : 0, - "source" : 24 - }, - { - "sampler" : 0, - "source" : 25 - }, - { - "sampler" : 0, - "source" : 26 - }, - { - "sampler" : 0, - "source" : 27 - }, - { - "sampler" : 0, - "source" : 28 - }, - { - "sampler" : 0, - "source" : 29 - }, - { - "sampler" : 0, - "source" : 30 - }, - { - "sampler" : 0, - "source" : 31 - }, - { - "sampler" : 0, - "source" : 32 - }, - { - "sampler" : 0, - "source" : 33 - }, - { - "sampler" : 0, - "source" : 34 - }, - { - "sampler" : 0, - "source" : 35 - }, - { - "sampler" : 0, - "source" : 36 - }, - { - "sampler" : 0, - "source" : 37 - }, - { - "sampler" : 0, - "source" : 38 - }, - { - "sampler" : 0, - "source" : 36 - }, - { - "sampler" : 0, - "source" : 39 - }, - { - "sampler" : 0, - "source" : 38 - }, - { - "sampler" : 0, - "source" : 36 - }, - { - "sampler" : 0, - "source" : 40 - }, - { - "sampler" : 0, - "source" : 38 - }, - { - "sampler" : 0, - "source" : 41 - }, - { - "sampler" : 0, - "source" : 42 - }, - { - "sampler" : 0, - "source" : 43 - }, - { - "sampler" : 0, - "source" : 41 - }, - { - "sampler" : 0, - "source" : 44 - }, - { - "sampler" : 0, - "source" : 43 - }, - { - "sampler" : 0, - "source" : 41 - }, - { - "sampler" : 0, - "source" : 45 - }, - { - "sampler" : 0, - "source" : 43 - }, - { - "sampler" : 0, - "source" : 46 - }, - { - "sampler" : 0, - "source" : 47 - }, - { - "sampler" : 0, - "source" : 48 - }, - { - "sampler" : 0, - "source" : 49 - }, - { - "sampler" : 0, - "source" : 50 - }, - { - "sampler" : 0, - "source" : 51 - }, - { - "sampler" : 0, - "source" : 52 - }, - { - "sampler" : 0, - "source" : 53 - }, - { - "sampler" : 0, - "source" : 54 - }, - { - "sampler" : 0, - "source" : 55 - }, - { - "sampler" : 0, - "source" : 56 - }, - { - "sampler" : 0, - "source" : 57 - }, - { - "sampler" : 0, - "source" : 58 - }, - { - "sampler" : 0, - "source" : 59 - }, - { - "sampler" : 0, - "source" : 60 - }, - { - "sampler" : 0, - "source" : 61 - }, - { - "sampler" : 0, - "source" : 62 - }, - { - "sampler" : 0, - "source" : 63 - } - ], - "images" : [ - { - "mimeType" : "image/png", - "name" : "sponza_thorn_normal", - "uri" : "sponza_thorn_normal.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_thorn_basecolor", - "uri" : "sponza_thorn_basecolor.png" - }, - { - "mimeType" : "image/png", - "name" : "sponza_thorn_metallicroughness", - "uri" : "sponza_thorn_metallicroughness.jpg" - }, - { - "mimeType" : "image/png", - "name" : "vase_plant_normal", - "uri" : "vase_plant_normal.jpg" - }, - { - "mimeType" : "image/png", - "name" : "vase_plant_basecolor", - "uri" : "vase_plant_basecolor.png" - }, - { - "mimeType" : "image/png", - "name" : "vase_plant_metallicroughness", - "uri" : "vase_plant_metallicroughness.jpg" - }, - { - "mimeType" : "image/png", - "name" : "vase_round_normal", - "uri" : "vase_round_normal.jpg" - }, - { - "mimeType" : "image/png", - "name" : "vase_round_basecolor", - "uri" : "vase_round_basecolor.jpg" - }, - { - "mimeType" : "image/png", - "name" : "vase_round_metallicroughness", - "uri" : "vase_round_metallicroughness.jpg" - }, - { - "mimeType" : "image/png", - "name" : "background_normal", - "uri" : "background_normal.jpg" - }, - { - "mimeType" : "image/png", - "name" : "background_basecolor", - "uri" : "background_basecolor.jpg" - }, - { - "mimeType" : "image/png", - "name" : "background_metallicroughness", - "uri" : "background_metallicroughness.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_bricks_a_normal", - "uri" : "sponza_bricks_a_normal.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_bricks_a_basecolor", - "uri" : "sponza_bricks_a_basecolor.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_bricks_a_metallicroughness", - "uri" : "sponza_bricks_a_metallicroughness.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_arch_normal", - "uri" : "sponza_arch_normal.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_arch_basecolor", - "uri" : "sponza_arch_basecolor.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_arch_metallicroughness", - "uri" : "sponza_arch_metallicroughness.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_ceiling_a_normal", - "uri" : "sponza_ceiling_a_normal.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_ceiling_a_basecolor", - "uri" : "sponza_ceiling_a_basecolor.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_ceiling_a_metallicroughness", - "uri" : "sponza_ceiling_a_metallicroughness.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_column_a_normal", - "uri" : "sponza_column_a_normal.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_column_a_basecolor", - "uri" : "sponza_column_a_basecolor.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_column_a_metallicroughness", - "uri" : "sponza_column_a_metallicroughness.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_column_c_normal", - "uri" : "sponza_column_c_normal.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_column_c_basecolor", - "uri" : "sponza_column_c_basecolor.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_column_c_metallicroughness", - "uri" : "sponza_column_c_metallicroughness.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_floor_a_normal", - "uri" : "sponza_floor_a_normal.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_floor_a_basecolor", - "uri" : "sponza_floor_a_basecolor.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_floor_a_metallicroughness", - "uri" : "sponza_floor_a_metallicroughness.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_column_b_normal", - "uri" : "sponza_column_b_normal.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_column_b_basecolor", - "uri" : "sponza_column_b_basecolor.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_column_b_metallicroughness", - "uri" : "sponza_column_b_metallicroughness.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_flagpole_normal", - "uri" : "sponza_flagpole_normal.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_flagpole_basecolor", - "uri" : "sponza_flagpole_basecolor.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_flagpole_metallicroughness", - "uri" : "sponza_flagpole_metallicroughness.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_fabric_normal", - "uri" : "sponza_fabric_normal.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_fabric_green_basecolor", - "uri" : "sponza_fabric_green_basecolor.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_fabric_metallicroughness", - "uri" : "sponza_fabric_metallicroughness.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_fabric_blue_basecolor", - "uri" : "sponza_fabric_blue_basecolor.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_fabric_basecolor", - "uri" : "sponza_fabric_basecolor.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_curtain_normal", - "uri" : "sponza_curtain_normal.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_curtain_blue_basecolor", - "uri" : "sponza_curtain_blue_basecolor.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_curtain_metallicroughness", - "uri" : "sponza_curtain_metallicroughness.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_curtain_basecolor", - "uri" : "sponza_curtain_basecolor.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_curtain_green_basecolor", - "uri" : "sponza_curtain_green_basecolor.jpg" - }, - { - "mimeType" : "image/png", - "name" : "chain_texture_normal", - "uri" : "chain_texture_normal.jpg" - }, - { - "mimeType" : "image/png", - "name" : "chain_texture_basecolor", - "uri" : "chain_texture_basecolor.png" - }, - { - "mimeType" : "image/png", - "name" : "chain_texture_metallicroughness", - "uri" : "chain_texture_metallicroughness.jpg" - }, - { - "mimeType" : "image/png", - "name" : "vase_hanging_normal", - "uri" : "vase_hanging_normal.jpg" - }, - { - "mimeType" : "image/png", - "name" : "vase_hanging_basecolor", - "uri" : "vase_hanging_basecolor.jpg" - }, - { - "mimeType" : "image/png", - "name" : "vase_hanging_metallicroughness", - "uri" : "vase_hanging_metallicroughness.jpg" - }, - { - "mimeType" : "image/png", - "name" : "vase_normal", - "uri" : "vase_normal.jpg" - }, - { - "mimeType" : "image/png", - "name" : "vase_basecolor", - "uri" : "vase_basecolor.jpg" - }, - { - "mimeType" : "image/png", - "name" : "vase_metallicroughness", - "uri" : "vase_metallicroughness.jpg" - }, - { - "mimeType" : "image/png", - "name" : "lion_normal", - "uri" : "lion_normal.jpg" - }, - { - "mimeType" : "image/png", - "name" : "lion_basecolor", - "uri" : "lion_basecolor.jpg" - }, - { - "mimeType" : "image/png", - "name" : "lion_metallicroughness", - "uri" : "lion_metallicroughness.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_roof_normal", - "uri" : "sponza_roof_normal.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_roof_basecolor", - "uri" : "sponza_roof_basecolor.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_roof_metallicroughness", - "uri" : "sponza_roof_metallicroughness.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_details_normal", - "uri" : "sponza_details_normal.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_details_basecolor", - "uri" : "sponza_details_basecolor.jpg" - }, - { - "mimeType" : "image/png", - "name" : "sponza_details_metallicroughness", - "uri" : "sponza_details_metallicroughness.jpg" - } - ], - "accessors" : [ - { - "bufferView" : 0, - "componentType" : 5126, - "count" : 3159, - "max" : [ - 5.409964561462402, - 2.109433889389038, - 2.4489800930023193 - ], - "min" : [ - 4.495628833770752, - 0.8537139892578125, - 1.520906925201416 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1, - "componentType" : 5126, - "count" : 3159, - "type" : "VEC3" - }, - { - "bufferView" : 2, - "componentType" : 5126, - "count" : 3159, - "type" : "VEC2" - }, - { - "bufferView" : 3, - "componentType" : 5123, - "count" : 10920, - "type" : "SCALAR" - }, - { - "bufferView" : 4, - "componentType" : 5126, - "count" : 536, - "max" : [ - -2.091301918029785, - 0.731235921382904, - -1.8904279470443726 - ], - "min" : [ - -2.7735557556152344, - 0.4608149528503418, - -2.5299859046936035 - ], - "type" : "VEC3" - }, - { - "bufferView" : 5, - "componentType" : 5126, - "count" : 536, - "type" : "VEC3" - }, - { - "bufferView" : 6, - "componentType" : 5126, - "count" : 536, - "type" : "VEC2" - }, - { - "bufferView" : 7, - "componentType" : 5123, - "count" : 1404, - "type" : "SCALAR" - }, - { - "bufferView" : 8, - "componentType" : 5126, - "count" : 1230, - "max" : [ - -2.193237066268921, - 0.5619949698448181, - -1.9878801107406616 - ], - "min" : [ - -2.7125461101531982, - -0.0014009999576956034, - -2.50777006149292 - ], - "type" : "VEC3" - }, - { - "bufferView" : 9, - "componentType" : 5126, - "count" : 1230, - "type" : "VEC3" - }, - { - "bufferView" : 10, - "componentType" : 5126, - "count" : 1230, - "type" : "VEC2" - }, - { - "bufferView" : 11, - "componentType" : 5123, - "count" : 6633, - "type" : "SCALAR" - }, - { - "bufferView" : 12, - "componentType" : 5126, - "count" : 750, - "max" : [ - -14.016798973083496, - 7.585530757904053, - 0.8570510149002075 - ], - "min" : [ - -14.2466402053833, - 4.930471897125244, - -1.6338648796081543 - ], - "type" : "VEC3" - }, - { - "bufferView" : 13, - "componentType" : 5126, - "count" : 750, - "type" : "VEC3" - }, - { - "bufferView" : 14, - "componentType" : 5126, - "count" : 750, - "type" : "VEC2" - }, - { - "bufferView" : 15, - "componentType" : 5123, - "count" : 4086, - "type" : "SCALAR" - }, - { - "bufferView" : 16, - "componentType" : 5126, - "count" : 20, - "max" : [ - 9.1480073928833, - 4.940524578094482, - 2.3867948055267334 - ], - "min" : [ - -10.45741081237793, - 4.139111042022705, - -3.1013457775115967 - ], - "type" : "VEC3" - }, - { - "bufferView" : 17, - "componentType" : 5126, - "count" : 20, - "type" : "VEC3" - }, - { - "bufferView" : 18, - "componentType" : 5126, - "count" : 20, - "type" : "VEC2" - }, - { - "bufferView" : 19, - "componentType" : 5123, - "count" : 24, - "type" : "SCALAR" - }, - { - "bufferView" : 20, - "componentType" : 5126, - "count" : 166, - "max" : [ - 8.693511009216309, - 4.95689582824707, - 1.8013049364089966 - ], - "min" : [ - -9.985177040100098, - 2.214876890182495, - -2.5081787109375 - ], - "type" : "VEC3" - }, - { - "bufferView" : 21, - "componentType" : 5126, - "count" : 166, - "type" : "VEC3" - }, - { - "bufferView" : 22, - "componentType" : 5126, - "count" : 166, - "type" : "VEC2" - }, - { - "bufferView" : 23, - "componentType" : 5123, - "count" : 300, - "type" : "SCALAR" - }, - { - "bufferView" : 24, - "componentType" : 5126, - "count" : 548, - "max" : [ - 9.176836013793945, - 5.07803201675415, - 2.4355807304382324 - ], - "min" : [ - -10.483080863952637, - 4.929887771606445, - -3.1810600757598877 - ], - "type" : "VEC3" - }, - { - "bufferView" : 25, - "componentType" : 5126, - "count" : 548, - "type" : "VEC3" - }, - { - "bufferView" : 26, - "componentType" : 5126, - "count" : 548, - "type" : "VEC2" - }, - { - "bufferView" : 27, - "componentType" : 5123, - "count" : 840, - "type" : "SCALAR" - }, - { - "bufferView" : 28, - "componentType" : 5126, - "count" : 1848, - "max" : [ - 13.02202033996582, - 3.8398799896240234, - 5.749026775360107 - ], - "min" : [ - -14.294520378112793, - 2.1580357551574707, - -6.45148229598999 - ], - "type" : "VEC3" - }, - { - "bufferView" : 29, - "componentType" : 5126, - "count" : 1848, - "type" : "VEC3" - }, - { - "bufferView" : 30, - "componentType" : 5126, - "count" : 1848, - "type" : "VEC2" - }, - { - "bufferView" : 31, - "componentType" : 5123, - "count" : 6996, - "type" : "SCALAR" - }, - { - "bufferView" : 32, - "componentType" : 5126, - "count" : 231, - "max" : [ - -5.818408489227295, - 2.2099709510803223, - 2.4457008838653564 - ], - "min" : [ - -6.585947513580322, - -0.02460699900984764, - 1.676918864250183 - ], - "type" : "VEC3" - }, - { - "bufferView" : 33, - "componentType" : 5126, - "count" : 231, - "type" : "VEC3" - }, - { - "bufferView" : 34, - "componentType" : 5126, - "count" : 231, - "type" : "VEC2" - }, - { - "bufferView" : 35, - "componentType" : 5123, - "count" : 546, - "type" : "SCALAR" - }, - { - "bufferView" : 36, - "componentType" : 5126, - "count" : 229, - "max" : [ - -2.07704496383667, - 2.2099709510803223, - 2.4419548511505127 - ], - "min" : [ - -2.845825672149658, - -0.02460699900984764, - 1.6744158267974854 - ], - "type" : "VEC3" - }, - { - "bufferView" : 37, - "componentType" : 5126, - "count" : 229, - "type" : "VEC3" - }, - { - "bufferView" : 38, - "componentType" : 5126, - "count" : 229, - "type" : "VEC2" - }, - { - "bufferView" : 39, - "componentType" : 5123, - "count" : 546, - "type" : "SCALAR" - }, - { - "bufferView" : 40, - "componentType" : 5126, - "count" : 163, - "max" : [ - -5.890180587768555, - 2.1761178970336914, - 5.754880428314209 - ], - "min" : [ - -6.497213363647461, - 1.826522946357727, - 5.598720550537109 - ], - "type" : "VEC3" - }, - { - "bufferView" : 41, - "componentType" : 5126, - "count" : 163, - "type" : "VEC3" - }, - { - "bufferView" : 42, - "componentType" : 5126, - "count" : 163, - "type" : "VEC2" - }, - { - "bufferView" : 43, - "componentType" : 5123, - "count" : 264, - "type" : "SCALAR" - }, - { - "bufferView" : 44, - "componentType" : 5126, - "count" : 162, - "max" : [ - -9.627448081970215, - 2.176116943359375, - 5.754880428314209 - ], - "min" : [ - -10.49055004119873, - 1.826522946357727, - 5.598721981048584 - ], - "type" : "VEC3" - }, - { - "bufferView" : 45, - "componentType" : 5126, - "count" : 162, - "type" : "VEC3" - }, - { - "bufferView" : 46, - "componentType" : 5126, - "count" : 162, - "type" : "VEC2" - }, - { - "bufferView" : 47, - "componentType" : 5123, - "count" : 264, - "type" : "SCALAR" - }, - { - "bufferView" : 48, - "componentType" : 5126, - "count" : 163, - "max" : [ - -2.179433822631836, - 2.176116943359375, - 5.754880428314209 - ], - "min" : [ - -2.7864646911621094, - 1.826522946357727, - 5.598721981048584 - ], - "type" : "VEC3" - }, - { - "bufferView" : 49, - "componentType" : 5126, - "count" : 163, - "type" : "VEC3" - }, - { - "bufferView" : 50, - "componentType" : 5126, - "count" : 163, - "type" : "VEC2" - }, - { - "bufferView" : 51, - "componentType" : 5123, - "count" : 264, - "type" : "SCALAR" - }, - { - "bufferView" : 52, - "componentType" : 5126, - "count" : 163, - "max" : [ - 1.5290719270706177, - 2.176116943359375, - 5.754880428314209 - ], - "min" : [ - 0.9220399856567383, - 1.826522946357727, - 5.598721981048584 - ], - "type" : "VEC3" - }, - { - "bufferView" : 53, - "componentType" : 5126, - "count" : 163, - "type" : "VEC3" - }, - { - "bufferView" : 54, - "componentType" : 5126, - "count" : 163, - "type" : "VEC2" - }, - { - "bufferView" : 55, - "componentType" : 5123, - "count" : 264, - "type" : "SCALAR" - }, - { - "bufferView" : 56, - "componentType" : 5126, - "count" : 163, - "max" : [ - 5.233678340911865, - 2.176116943359375, - 5.754880428314209 - ], - "min" : [ - 4.626646995544434, - 1.826522946357727, - 5.598721981048584 - ], - "type" : "VEC3" - }, - { - "bufferView" : 57, - "componentType" : 5126, - "count" : 163, - "type" : "VEC3" - }, - { - "bufferView" : 58, - "componentType" : 5126, - "count" : 163, - "type" : "VEC2" - }, - { - "bufferView" : 59, - "componentType" : 5123, - "count" : 264, - "type" : "SCALAR" - }, - { - "bufferView" : 60, - "componentType" : 5126, - "count" : 161, - "max" : [ - 9.23731517791748, - 2.176116943359375, - 5.754880428314209 - ], - "min" : [ - 8.352161407470703, - 1.826522946357727, - 5.598721981048584 - ], - "type" : "VEC3" - }, - { - "bufferView" : 61, - "componentType" : 5126, - "count" : 161, - "type" : "VEC3" - }, - { - "bufferView" : 62, - "componentType" : 5126, - "count" : 161, - "type" : "VEC2" - }, - { - "bufferView" : 63, - "componentType" : 5123, - "count" : 264, - "type" : "SCALAR" - }, - { - "bufferView" : 64, - "componentType" : 5126, - "count" : 163, - "max" : [ - -5.890180587768555, - 2.1761178970336914, - -6.313518524169922 - ], - "min" : [ - -6.497213363647461, - 1.826522946357727, - -6.469677448272705 - ], - "type" : "VEC3" - }, - { - "bufferView" : 65, - "componentType" : 5126, - "count" : 163, - "type" : "VEC3" - }, - { - "bufferView" : 66, - "componentType" : 5126, - "count" : 163, - "type" : "VEC2" - }, - { - "bufferView" : 67, - "componentType" : 5123, - "count" : 264, - "type" : "SCALAR" - }, - { - "bufferView" : 68, - "componentType" : 5126, - "count" : 161, - "max" : [ - -9.627448081970215, - 2.176116943359375, - -6.313520908355713 - ], - "min" : [ - -10.49055004119873, - 1.826522946357727, - -6.46967887878418 - ], - "type" : "VEC3" - }, - { - "bufferView" : 69, - "componentType" : 5126, - "count" : 161, - "type" : "VEC3" - }, - { - "bufferView" : 70, - "componentType" : 5126, - "count" : 161, - "type" : "VEC2" - }, - { - "bufferView" : 71, - "componentType" : 5123, - "count" : 264, - "type" : "SCALAR" - }, - { - "bufferView" : 72, - "componentType" : 5126, - "count" : 163, - "max" : [ - -2.179433822631836, - 2.176116943359375, - -6.313520908355713 - ], - "min" : [ - -2.7864646911621094, - 1.826522946357727, - -6.46967887878418 - ], - "type" : "VEC3" - }, - { - "bufferView" : 73, - "componentType" : 5126, - "count" : 163, - "type" : "VEC3" - }, - { - "bufferView" : 74, - "componentType" : 5126, - "count" : 163, - "type" : "VEC2" - }, - { - "bufferView" : 75, - "componentType" : 5126, - "count" : 161, - "max" : [ - 1.5290719270706177, - 2.176116943359375, - -6.313520908355713 - ], - "min" : [ - 0.9220399856567383, - 1.826522946357727, - -6.46967887878418 - ], - "type" : "VEC3" - }, - { - "bufferView" : 76, - "componentType" : 5126, - "count" : 161, - "type" : "VEC3" - }, - { - "bufferView" : 77, - "componentType" : 5126, - "count" : 161, - "type" : "VEC2" - }, - { - "bufferView" : 78, - "componentType" : 5123, - "count" : 264, - "type" : "SCALAR" - }, - { - "bufferView" : 79, - "componentType" : 5126, - "count" : 228, - "max" : [ - 1.6041380167007446, - 2.2099709510803223, - 2.4446768760681152 - ], - "min" : [ - 0.8353559970855713, - -0.02460699900984764, - 1.677137851715088 - ], - "type" : "VEC3" - }, - { - "bufferView" : 80, - "componentType" : 5126, - "count" : 228, - "type" : "VEC3" - }, - { - "bufferView" : 81, - "componentType" : 5126, - "count" : 228, - "type" : "VEC2" - }, - { - "bufferView" : 82, - "componentType" : 5123, - "count" : 546, - "type" : "SCALAR" - }, - { - "bufferView" : 83, - "componentType" : 5126, - "count" : 164, - "max" : [ - 5.233678340911865, - 2.176116943359375, - -6.313520908355713 - ], - "min" : [ - 4.626646995544434, - 1.826522946357727, - -6.46967887878418 - ], - "type" : "VEC3" - }, - { - "bufferView" : 84, - "componentType" : 5126, - "count" : 164, - "type" : "VEC3" - }, - { - "bufferView" : 85, - "componentType" : 5126, - "count" : 164, - "type" : "VEC2" - }, - { - "bufferView" : 86, - "componentType" : 5123, - "count" : 264, - "type" : "SCALAR" - }, - { - "bufferView" : 87, - "componentType" : 5126, - "count" : 161, - "max" : [ - 9.23731517791748, - 2.176116943359375, - -6.313520908355713 - ], - "min" : [ - 8.352161407470703, - 1.826522946357727, - -6.46967887878418 - ], - "type" : "VEC3" - }, - { - "bufferView" : 88, - "componentType" : 5126, - "count" : 161, - "type" : "VEC3" - }, - { - "bufferView" : 89, - "componentType" : 5126, - "count" : 161, - "type" : "VEC2" - }, - { - "bufferView" : 90, - "componentType" : 5123, - "count" : 264, - "type" : "SCALAR" - }, - { - "bufferView" : 91, - "componentType" : 5126, - "count" : 165, - "max" : [ - -14.146899223327637, - 2.176116943359375, - -2.2154388427734375 - ], - "min" : [ - -14.30305004119873, - 1.826522946357727, - -3.1005918979644775 - ], - "type" : "VEC3" - }, - { - "bufferView" : 92, - "componentType" : 5126, - "count" : 165, - "type" : "VEC3" - }, - { - "bufferView" : 93, - "componentType" : 5126, - "count" : 165, - "type" : "VEC2" - }, - { - "bufferView" : 94, - "componentType" : 5123, - "count" : 264, - "type" : "SCALAR" - }, - { - "bufferView" : 95, - "componentType" : 5126, - "count" : 167, - "max" : [ - -14.146899223327637, - 2.176116943359375, - 2.4067718982696533 - ], - "min" : [ - -14.30305004119873, - 1.826522946357727, - 1.5216178894042969 - ], - "type" : "VEC3" - }, - { - "bufferView" : 96, - "componentType" : 5126, - "count" : 167, - "type" : "VEC3" - }, - { - "bufferView" : 97, - "componentType" : 5126, - "count" : 167, - "type" : "VEC2" - }, - { - "bufferView" : 98, - "componentType" : 5123, - "count" : 264, - "type" : "SCALAR" - }, - { - "bufferView" : 99, - "componentType" : 5126, - "count" : 127, - "max" : [ - -14.170490264892578, - 2.176116943359375, - -6.291940689086914 - ], - "min" : [ - -14.30150032043457, - 1.826522946357727, - -6.452885627746582 - ], - "type" : "VEC3" - }, - { - "bufferView" : 100, - "componentType" : 5126, - "count" : 127, - "type" : "VEC3" - }, - { - "bufferView" : 101, - "componentType" : 5126, - "count" : 127, - "type" : "VEC2" - }, - { - "bufferView" : 102, - "componentType" : 5123, - "count" : 222, - "type" : "SCALAR" - }, - { - "bufferView" : 103, - "componentType" : 5126, - "count" : 126, - "max" : [ - -14.170490264892578, - 2.176116943359375, - 5.757254600524902 - ], - "min" : [ - -14.30150032043457, - 1.826522946357727, - 5.596310138702393 - ], - "type" : "VEC3" - }, - { - "bufferView" : 104, - "componentType" : 5126, - "count" : 126, - "type" : "VEC3" - }, - { - "bufferView" : 105, - "componentType" : 5126, - "count" : 126, - "type" : "VEC2" - }, - { - "bufferView" : 106, - "componentType" : 5123, - "count" : 222, - "type" : "SCALAR" - }, - { - "bufferView" : 107, - "componentType" : 5126, - "count" : 118, - "max" : [ - 13.021909713745117, - 0.05625099688768387, - 5.740296363830566 - ], - "min" : [ - -14.285200119018555, - -0.03379400074481964, - -6.443113803863525 - ], - "type" : "VEC3" - }, - { - "bufferView" : 108, - "componentType" : 5126, - "count" : 118, - "type" : "VEC3" - }, - { - "bufferView" : 109, - "componentType" : 5126, - "count" : 118, - "type" : "VEC2" - }, - { - "bufferView" : 110, - "componentType" : 5123, - "count" : 150, - "type" : "SCALAR" - }, - { - "bufferView" : 111, - "componentType" : 5126, - "count" : 13, - "max" : [ - 13.021909713745117, - -0.025061998516321182, - 5.740296363830566 - ], - "min" : [ - -14.285200119018555, - -0.025061998516321182, - -6.443113803863525 - ], - "type" : "VEC3" - }, - { - "bufferView" : 112, - "componentType" : 5126, - "count" : 13, - "type" : "VEC3" - }, - { - "bufferView" : 113, - "componentType" : 5126, - "count" : 13, - "type" : "VEC2" - }, - { - "bufferView" : 114, - "componentType" : 5123, - "count" : 15, - "type" : "SCALAR" - }, - { - "bufferView" : 115, - "componentType" : 5126, - "count" : 422, - "max" : [ - -9.479555130004883, - 2.2099709510803223, - 2.466148853302002 - ], - "min" : [ - -10.572199821472168, - -0.02460699900984764, - 1.3735029697418213 - ], - "type" : "VEC3" - }, - { - "bufferView" : 116, - "componentType" : 5126, - "count" : 422, - "type" : "VEC3" - }, - { - "bufferView" : 117, - "componentType" : 5126, - "count" : 422, - "type" : "VEC2" - }, - { - "bufferView" : 118, - "componentType" : 5123, - "count" : 1020, - "type" : "SCALAR" - }, - { - "bufferView" : 119, - "componentType" : 5126, - "count" : 414, - "max" : [ - -9.479555130004883, - 2.2099709510803223, - -2.0760459899902344 - ], - "min" : [ - -10.572199821472168, - -0.02460699900984764, - -3.168691873550415 - ], - "type" : "VEC3" - }, - { - "bufferView" : 120, - "componentType" : 5126, - "count" : 414, - "type" : "VEC3" - }, - { - "bufferView" : 121, - "componentType" : 5126, - "count" : 414, - "type" : "VEC2" - }, - { - "bufferView" : 122, - "componentType" : 5123, - "count" : 1020, - "type" : "SCALAR" - }, - { - "bufferView" : 123, - "componentType" : 5126, - "count" : 242, - "max" : [ - 5.286698341369629, - 2.2099709510803223, - 2.445697784423828 - ], - "min" : [ - 4.519160270690918, - -0.02460699900984764, - 1.6769169569015503 - ], - "type" : "VEC3" - }, - { - "bufferView" : 124, - "componentType" : 5126, - "count" : 242, - "type" : "VEC3" - }, - { - "bufferView" : 125, - "componentType" : 5126, - "count" : 242, - "type" : "VEC2" - }, - { - "bufferView" : 126, - "componentType" : 5123, - "count" : 546, - "type" : "SCALAR" - }, - { - "bufferView" : 127, - "componentType" : 5126, - "count" : 407, - "max" : [ - 9.256037712097168, - 2.2099709510803223, - -2.0760459899902344 - ], - "min" : [ - 8.163393020629883, - -0.02460699900984764, - -3.168691873550415 - ], - "type" : "VEC3" - }, - { - "bufferView" : 128, - "componentType" : 5126, - "count" : 407, - "type" : "VEC3" - }, - { - "bufferView" : 129, - "componentType" : 5126, - "count" : 407, - "type" : "VEC2" - }, - { - "bufferView" : 130, - "componentType" : 5123, - "count" : 1020, - "type" : "SCALAR" - }, - { - "bufferView" : 131, - "componentType" : 5126, - "count" : 426, - "max" : [ - 9.256037712097168, - 2.2099709510803223, - 2.466148853302002 - ], - "min" : [ - 8.163393020629883, - -0.02460699900984764, - 1.3735029697418213 - ], - "type" : "VEC3" - }, - { - "bufferView" : 132, - "componentType" : 5126, - "count" : 426, - "type" : "VEC3" - }, - { - "bufferView" : 133, - "componentType" : 5126, - "count" : 426, - "type" : "VEC2" - }, - { - "bufferView" : 134, - "componentType" : 5123, - "count" : 1020, - "type" : "SCALAR" - }, - { - "bufferView" : 135, - "componentType" : 5126, - "count" : 35, - "max" : [ - 9.219354629516602, - 4.222416877746582, - 2.458141803741455 - ], - "min" : [ - -10.52876091003418, - 4.139111042022705, - -3.1726927757263184 - ], - "type" : "VEC3" - }, - { - "bufferView" : 136, - "componentType" : 5126, - "count" : 35, - "type" : "VEC3" - }, - { - "bufferView" : 137, - "componentType" : 5126, - "count" : 35, - "type" : "VEC2" - }, - { - "bufferView" : 138, - "componentType" : 5123, - "count" : 48, - "type" : "SCALAR" - }, - { - "bufferView" : 139, - "componentType" : 5126, - "count" : 2322, - "max" : [ - 8.624395370483398, - 8.233441352844238, - -2.447730779647827 - ], - "min" : [ - -9.904375076293945, - 6.909215450286865, - -3.023531675338745 - ], - "type" : "VEC3" - }, - { - "bufferView" : 140, - "componentType" : 5126, - "count" : 2322, - "type" : "VEC3" - }, - { - "bufferView" : 141, - "componentType" : 5126, - "count" : 2322, - "type" : "VEC2" - }, - { - "bufferView" : 142, - "componentType" : 5123, - "count" : 5580, - "type" : "SCALAR" - }, - { - "bufferView" : 143, - "componentType" : 5126, - "count" : 2310, - "max" : [ - 8.624396324157715, - 8.233441352844238, - 2.3143439292907715 - ], - "min" : [ - -9.904375076293945, - 6.909215450286865, - 1.7385419607162476 - ], - "type" : "VEC3" - }, - { - "bufferView" : 144, - "componentType" : 5126, - "count" : 2310, - "type" : "VEC3" - }, - { - "bufferView" : 145, - "componentType" : 5126, - "count" : 2310, - "type" : "VEC2" - }, - { - "bufferView" : 146, - "componentType" : 5123, - "count" : 5580, - "type" : "SCALAR" - }, - { - "bufferView" : 147, - "componentType" : 5126, - "count" : 1127, - "max" : [ - -9.894766807556152, - 6.924715518951416, - -0.1202629953622818 - ], - "min" : [ - -10.349499702453613, - 5.163723468780518, - -0.5746449828147888 - ], - "type" : "VEC3" - }, - { - "bufferView" : 148, - "componentType" : 5126, - "count" : 1127, - "type" : "VEC3" - }, - { - "bufferView" : 149, - "componentType" : 5126, - "count" : 1127, - "type" : "VEC2" - }, - { - "bufferView" : 150, - "componentType" : 5123, - "count" : 3660, - "type" : "SCALAR" - }, - { - "bufferView" : 151, - "componentType" : 5126, - "count" : 40, - "max" : [ - -10.077520370483398, - 6.922971725463867, - -0.4687189757823944 - ], - "min" : [ - -10.157400131225586, - 6.8095703125, - -0.5986160039901733 - ], - "type" : "VEC3" - }, - { - "bufferView" : 152, - "componentType" : 5126, - "count" : 40, - "type" : "VEC3" - }, - { - "bufferView" : 153, - "componentType" : 5126, - "count" : 40, - "type" : "VEC2" - }, - { - "bufferView" : 154, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 155, - "componentType" : 5126, - "count" : 64, - "max" : [ - -10.088150024414062, - 6.809845447540283, - -0.45008400082588196 - ], - "min" : [ - -10.147699356079102, - 6.6970038414001465, - -0.5725650191307068 - ], - "type" : "VEC3" - }, - { - "bufferView" : 156, - "componentType" : 5126, - "count" : 64, - "type" : "VEC3" - }, - { - "bufferView" : 157, - "componentType" : 5126, - "count" : 64, - "type" : "VEC2" - }, - { - "bufferView" : 158, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 159, - "componentType" : 5126, - "count" : 40, - "max" : [ - -9.86715030670166, - 6.922971725463867, - -0.30837297439575195 - ], - "min" : [ - -9.997050285339355, - 6.8095703125, - -0.3882579803466797 - ], - "type" : "VEC3" - }, - { - "bufferView" : 160, - "componentType" : 5126, - "count" : 40, - "type" : "VEC3" - }, - { - "bufferView" : 161, - "componentType" : 5126, - "count" : 40, - "type" : "VEC2" - }, - { - "bufferView" : 162, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 163, - "componentType" : 5126, - "count" : 81, - "max" : [ - -9.89320182800293, - 6.809845447540283, - -0.3190079927444458 - ], - "min" : [ - -10.015680313110352, - 6.6970038414001465, - -0.37855398654937744 - ], - "type" : "VEC3" - }, - { - "bufferView" : 164, - "componentType" : 5126, - "count" : 81, - "type" : "VEC3" - }, - { - "bufferView" : 165, - "componentType" : 5126, - "count" : 81, - "type" : "VEC2" - }, - { - "bufferView" : 166, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 167, - "componentType" : 5126, - "count" : 226, - "max" : [ - -5.814660549163818, - 2.2099709510803223, - -2.400134801864624 - ], - "min" : [ - -6.583441734313965, - -0.02460699900984764, - -3.1676738262176514 - ], - "type" : "VEC3" - }, - { - "bufferView" : 168, - "componentType" : 5126, - "count" : 226, - "type" : "VEC3" - }, - { - "bufferView" : 169, - "componentType" : 5126, - "count" : 226, - "type" : "VEC2" - }, - { - "bufferView" : 170, - "componentType" : 5123, - "count" : 546, - "type" : "SCALAR" - }, - { - "bufferView" : 171, - "componentType" : 5126, - "count" : 37, - "max" : [ - -10.078360557556152, - 6.922971725463867, - -0.09912099689245224 - ], - "min" : [ - -10.15825080871582, - 6.8095703125, - -0.22901800274848938 - ], - "type" : "VEC3" - }, - { - "bufferView" : 172, - "componentType" : 5126, - "count" : 37, - "type" : "VEC3" - }, - { - "bufferView" : 173, - "componentType" : 5126, - "count" : 37, - "type" : "VEC2" - }, - { - "bufferView" : 174, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 175, - "componentType" : 5126, - "count" : 66, - "max" : [ - -10.0880708694458, - 6.809845447540283, - -0.1251709908246994 - ], - "min" : [ - -10.147610664367676, - 6.6970038414001465, - -0.24765297770500183 - ], - "type" : "VEC3" - }, - { - "bufferView" : 176, - "componentType" : 5126, - "count" : 66, - "type" : "VEC3" - }, - { - "bufferView" : 177, - "componentType" : 5126, - "count" : 66, - "type" : "VEC2" - }, - { - "bufferView" : 178, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 179, - "componentType" : 5126, - "count" : 30, - "max" : [ - -10.238720893859863, - 6.922971725463867, - -0.3094789683818817 - ], - "min" : [ - -10.368610382080078, - 6.8095703125, - -0.38936296105384827 - ], - "type" : "VEC3" - }, - { - "bufferView" : 180, - "componentType" : 5126, - "count" : 30, - "type" : "VEC3" - }, - { - "bufferView" : 181, - "componentType" : 5126, - "count" : 30, - "type" : "VEC2" - }, - { - "bufferView" : 182, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 183, - "componentType" : 5126, - "count" : 86, - "max" : [ - -10.220080375671387, - 6.809845447540283, - -0.31918197870254517 - ], - "min" : [ - -10.342560768127441, - 6.6970038414001465, - -0.378728985786438 - ], - "type" : "VEC3" - }, - { - "bufferView" : 184, - "componentType" : 5126, - "count" : 86, - "type" : "VEC3" - }, - { - "bufferView" : 185, - "componentType" : 5126, - "count" : 86, - "type" : "VEC2" - }, - { - "bufferView" : 186, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 187, - "componentType" : 5126, - "count" : 292, - "max" : [ - -9.858739852905273, - 6.99611759185791, - -0.09251099079847336 - ], - "min" : [ - -10.376521110534668, - 6.922728538513184, - -0.609373927116394 - ], - "type" : "VEC3" - }, - { - "bufferView" : 188, - "componentType" : 5126, - "count" : 292, - "type" : "VEC3" - }, - { - "bufferView" : 189, - "componentType" : 5126, - "count" : 292, - "type" : "VEC2" - }, - { - "bufferView" : 190, - "componentType" : 5123, - "count" : 900, - "type" : "SCALAR" - }, - { - "bufferView" : 191, - "componentType" : 5126, - "count" : 209, - "max" : [ - -9.881155967712402, - 5.1652679443359375, - -0.11171899735927582 - ], - "min" : [ - -10.35690975189209, - 5.072018623352051, - -0.5875709652900696 - ], - "type" : "VEC3" - }, - { - "bufferView" : 192, - "componentType" : 5126, - "count" : 209, - "type" : "VEC3" - }, - { - "bufferView" : 193, - "componentType" : 5126, - "count" : 209, - "type" : "VEC2" - }, - { - "bufferView" : 194, - "componentType" : 5123, - "count" : 498, - "type" : "SCALAR" - }, - { - "bufferView" : 195, - "componentType" : 5126, - "count" : 1127, - "max" : [ - 7.03314733505249, - 6.87420654296875, - -2.54028582572937 - ], - "min" : [ - 6.508020401000977, - 5.172232627868652, - -3.0650057792663574 - ], - "type" : "VEC3" - }, - { - "bufferView" : 196, - "componentType" : 5126, - "count" : 1127, - "type" : "VEC3" - }, - { - "bufferView" : 197, - "componentType" : 5126, - "count" : 1127, - "type" : "VEC2" - }, - { - "bufferView" : 198, - "componentType" : 5123, - "count" : 3660, - "type" : "SCALAR" - }, - { - "bufferView" : 199, - "componentType" : 5126, - "count" : 36, - "max" : [ - 6.822110652923584, - 6.872191429138184, - -2.5126049518585205 - ], - "min" : [ - 6.729860782623291, - 6.741235733032227, - -2.6626100540161133 - ], - "type" : "VEC3" - }, - { - "bufferView" : 200, - "componentType" : 5126, - "count" : 36, - "type" : "VEC3" - }, - { - "bufferView" : 201, - "componentType" : 5126, - "count" : 36, - "type" : "VEC2" - }, - { - "bufferView" : 202, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 203, - "componentType" : 5126, - "count" : 76, - "max" : [ - 6.809830188751221, - 6.741554260253906, - -2.5426878929138184 - ], - "min" : [ - 6.741065502166748, - 6.611245155334473, - -2.6841301918029785 - ], - "type" : "VEC3" - }, - { - "bufferView" : 204, - "componentType" : 5126, - "count" : 76, - "type" : "VEC3" - }, - { - "bufferView" : 205, - "componentType" : 5126, - "count" : 76, - "type" : "VEC2" - }, - { - "bufferView" : 206, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 207, - "componentType" : 5126, - "count" : 37, - "max" : [ - 7.065038681030273, - 6.872191429138184, - -2.755525827407837 - ], - "min" : [ - 6.915033340454102, - 6.741235733032227, - -2.8477766513824463 - ], - "type" : "VEC3" - }, - { - "bufferView" : 208, - "componentType" : 5126, - "count" : 37, - "type" : "VEC3" - }, - { - "bufferView" : 209, - "componentType" : 5126, - "count" : 37, - "type" : "VEC2" - }, - { - "bufferView" : 210, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 211, - "componentType" : 5126, - "count" : 231, - "max" : [ - -2.07704496383667, - 2.2099709510803223, - -2.397408962249756 - ], - "min" : [ - -2.845824718475342, - -0.02460699900984764, - -3.164947748184204 - ], - "type" : "VEC3" - }, - { - "bufferView" : 212, - "componentType" : 5126, - "count" : 231, - "type" : "VEC3" - }, - { - "bufferView" : 213, - "componentType" : 5126, - "count" : 231, - "type" : "VEC2" - }, - { - "bufferView" : 214, - "componentType" : 5123, - "count" : 546, - "type" : "SCALAR" - }, - { - "bufferView" : 215, - "componentType" : 5126, - "count" : 93, - "max" : [ - 7.034955978393555, - 6.741554260253906, - -2.7667317390441895 - ], - "min" : [ - 6.8935136795043945, - 6.611245155334473, - -2.835495948791504 - ], - "type" : "VEC3" - }, - { - "bufferView" : 216, - "componentType" : 5126, - "count" : 93, - "type" : "VEC3" - }, - { - "bufferView" : 217, - "componentType" : 5126, - "count" : 93, - "type" : "VEC2" - }, - { - "bufferView" : 218, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 219, - "componentType" : 5126, - "count" : 38, - "max" : [ - 6.821131229400635, - 6.872191429138184, - -2.9394166469573975 - ], - "min" : [ - 6.728880405426025, - 6.741235733032227, - -3.0894219875335693 - ], - "type" : "VEC3" - }, - { - "bufferView" : 220, - "componentType" : 5126, - "count" : 38, - "type" : "VEC3" - }, - { - "bufferView" : 221, - "componentType" : 5126, - "count" : 38, - "type" : "VEC2" - }, - { - "bufferView" : 222, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 223, - "componentType" : 5126, - "count" : 63, - "max" : [ - 6.809925556182861, - 6.741554260253906, - -2.9178969860076904 - ], - "min" : [ - 6.741161823272705, - 6.611245155334473, - -3.059338092803955 - ], - "type" : "VEC3" - }, - { - "bufferView" : 224, - "componentType" : 5126, - "count" : 63, - "type" : "VEC3" - }, - { - "bufferView" : 225, - "componentType" : 5126, - "count" : 63, - "type" : "VEC2" - }, - { - "bufferView" : 226, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 227, - "componentType" : 5126, - "count" : 36, - "max" : [ - 6.635957717895508, - 6.872191429138184, - -2.7542500495910645 - ], - "min" : [ - 6.485952377319336, - 6.741235733032227, - -2.8464999198913574 - ], - "type" : "VEC3" - }, - { - "bufferView" : 228, - "componentType" : 5126, - "count" : 36, - "type" : "VEC3" - }, - { - "bufferView" : 229, - "componentType" : 5126, - "count" : 36, - "type" : "VEC2" - }, - { - "bufferView" : 230, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 231, - "componentType" : 5126, - "count" : 96, - "max" : [ - 6.657477855682373, - 6.741554260253906, - -2.7665300369262695 - ], - "min" : [ - 6.516035556793213, - 6.611245155334473, - -2.835294723510742 - ], - "type" : "VEC3" - }, - { - "bufferView" : 232, - "componentType" : 5126, - "count" : 96, - "type" : "VEC3" - }, - { - "bufferView" : 233, - "componentType" : 5126, - "count" : 96, - "type" : "VEC2" - }, - { - "bufferView" : 234, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 235, - "componentType" : 5126, - "count" : 268, - "max" : [ - 7.0747528076171875, - 6.956661701202393, - -2.500180959701538 - ], - "min" : [ - 6.476824760437012, - 6.871912479400635, - -3.097054958343506 - ], - "type" : "VEC3" - }, - { - "bufferView" : 236, - "componentType" : 5126, - "count" : 268, - "type" : "VEC3" - }, - { - "bufferView" : 237, - "componentType" : 5126, - "count" : 268, - "type" : "VEC2" - }, - { - "bufferView" : 238, - "componentType" : 5123, - "count" : 900, - "type" : "SCALAR" - }, - { - "bufferView" : 239, - "componentType" : 5126, - "count" : 214, - "max" : [ - 7.048864364624023, - 5.174014568328857, - -2.525360107421875 - ], - "min" : [ - 6.49946403503418, - 5.06633186340332, - -3.074873924255371 - ], - "type" : "VEC3" - }, - { - "bufferView" : 240, - "componentType" : 5126, - "count" : 214, - "type" : "VEC3" - }, - { - "bufferView" : 241, - "componentType" : 5126, - "count" : 214, - "type" : "VEC2" - }, - { - "bufferView" : 242, - "componentType" : 5123, - "count" : 498, - "type" : "SCALAR" - }, - { - "bufferView" : 243, - "componentType" : 5126, - "count" : 1127, - "max" : [ - 3.3218438625335693, - 6.87420654296875, - -2.54028582572937 - ], - "min" : [ - 2.796717882156372, - 5.172232627868652, - -3.0650057792663574 - ], - "type" : "VEC3" - }, - { - "bufferView" : 244, - "componentType" : 5126, - "count" : 1127, - "type" : "VEC3" - }, - { - "bufferView" : 245, - "componentType" : 5126, - "count" : 1127, - "type" : "VEC2" - }, - { - "bufferView" : 246, - "componentType" : 5123, - "count" : 3660, - "type" : "SCALAR" - }, - { - "bufferView" : 247, - "componentType" : 5126, - "count" : 35, - "max" : [ - 3.1000049114227295, - 6.872191429138184, - -2.5126049518585205 - ], - "min" : [ - 3.0077548027038574, - 6.741235733032227, - -2.6626100540161133 - ], - "type" : "VEC3" - }, - { - "bufferView" : 248, - "componentType" : 5126, - "count" : 35, - "type" : "VEC3" - }, - { - "bufferView" : 249, - "componentType" : 5126, - "count" : 35, - "type" : "VEC2" - }, - { - "bufferView" : 250, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 251, - "componentType" : 5126, - "count" : 75, - "max" : [ - 3.088798761367798, - 6.741554260253906, - -2.5426878929138184 - ], - "min" : [ - 3.0200347900390625, - 6.611245155334473, - -2.6841301918029785 - ], - "type" : "VEC3" - }, - { - "bufferView" : 252, - "componentType" : 5126, - "count" : 75, - "type" : "VEC3" - }, - { - "bufferView" : 253, - "componentType" : 5126, - "count" : 75, - "type" : "VEC2" - }, - { - "bufferView" : 254, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 255, - "componentType" : 5126, - "count" : 244, - "max" : [ - 1.6003919839859009, - 2.2099709510803223, - -2.3999109268188477 - ], - "min" : [ - 0.8328530192375183, - -0.02460699900984764, - -3.168691873550415 - ], - "type" : "VEC3" - }, - { - "bufferView" : 256, - "componentType" : 5126, - "count" : 244, - "type" : "VEC3" - }, - { - "bufferView" : 257, - "componentType" : 5126, - "count" : 244, - "type" : "VEC2" - }, - { - "bufferView" : 258, - "componentType" : 5123, - "count" : 546, - "type" : "SCALAR" - }, - { - "bufferView" : 259, - "componentType" : 5126, - "count" : 36, - "max" : [ - 2.9148318767547607, - 6.872191429138184, - -2.755525827407837 - ], - "min" : [ - 2.7648260593414307, - 6.741235733032227, - -2.84777569770813 - ], - "type" : "VEC3" - }, - { - "bufferView" : 260, - "componentType" : 5126, - "count" : 36, - "type" : "VEC3" - }, - { - "bufferView" : 261, - "componentType" : 5126, - "count" : 36, - "type" : "VEC2" - }, - { - "bufferView" : 262, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 263, - "componentType" : 5126, - "count" : 93, - "max" : [ - 2.9363510608673096, - 6.741554260253906, - -2.7667317390441895 - ], - "min" : [ - 2.794910192489624, - 6.611245155334473, - -2.835495948791504 - ], - "type" : "VEC3" - }, - { - "bufferView" : 264, - "componentType" : 5126, - "count" : 93, - "type" : "VEC3" - }, - { - "bufferView" : 265, - "componentType" : 5126, - "count" : 93, - "type" : "VEC2" - }, - { - "bufferView" : 266, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 267, - "componentType" : 5126, - "count" : 35, - "max" : [ - 3.1009838581085205, - 6.872191429138184, - -2.93941593170166 - ], - "min" : [ - 3.0087337493896484, - 6.741235733032227, - -3.0894219875335693 - ], - "type" : "VEC3" - }, - { - "bufferView" : 268, - "componentType" : 5126, - "count" : 35, - "type" : "VEC3" - }, - { - "bufferView" : 269, - "componentType" : 5126, - "count" : 35, - "type" : "VEC2" - }, - { - "bufferView" : 270, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 271, - "componentType" : 5126, - "count" : 69, - "max" : [ - 3.0887038707733154, - 6.741554260253906, - -2.9178969860076904 - ], - "min" : [ - 3.0199389457702637, - 6.611245155334473, - -3.059338092803955 - ], - "type" : "VEC3" - }, - { - "bufferView" : 272, - "componentType" : 5126, - "count" : 69, - "type" : "VEC3" - }, - { - "bufferView" : 273, - "componentType" : 5126, - "count" : 69, - "type" : "VEC2" - }, - { - "bufferView" : 274, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 275, - "componentType" : 5126, - "count" : 40, - "max" : [ - 3.34391188621521, - 6.872191429138184, - -2.7542500495910645 - ], - "min" : [ - 3.193906784057617, - 6.741235733032227, - -2.8464999198913574 - ], - "type" : "VEC3" - }, - { - "bufferView" : 276, - "componentType" : 5126, - "count" : 40, - "type" : "VEC3" - }, - { - "bufferView" : 277, - "componentType" : 5126, - "count" : 40, - "type" : "VEC2" - }, - { - "bufferView" : 278, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 279, - "componentType" : 5126, - "count" : 83, - "max" : [ - 3.313828945159912, - 6.741554260253906, - -2.7665300369262695 - ], - "min" : [ - 3.1723878383636475, - 6.611245155334473, - -2.835294723510742 - ], - "type" : "VEC3" - }, - { - "bufferView" : 280, - "componentType" : 5126, - "count" : 83, - "type" : "VEC3" - }, - { - "bufferView" : 281, - "componentType" : 5126, - "count" : 83, - "type" : "VEC2" - }, - { - "bufferView" : 282, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 283, - "componentType" : 5126, - "count" : 269, - "max" : [ - 3.3530399799346924, - 6.956661701202393, - -2.500180959701538 - ], - "min" : [ - 2.7551119327545166, - 6.871912479400635, - -3.097054958343506 - ], - "type" : "VEC3" - }, - { - "bufferView" : 284, - "componentType" : 5126, - "count" : 269, - "type" : "VEC3" - }, - { - "bufferView" : 285, - "componentType" : 5126, - "count" : 269, - "type" : "VEC2" - }, - { - "bufferView" : 286, - "componentType" : 5123, - "count" : 900, - "type" : "SCALAR" - }, - { - "bufferView" : 287, - "componentType" : 5126, - "count" : 210, - "max" : [ - 3.3304009437561035, - 5.174014568328857, - -2.525360107421875 - ], - "min" : [ - 2.781000852584839, - 5.06633186340332, - -3.074873924255371 - ], - "type" : "VEC3" - }, - { - "bufferView" : 288, - "componentType" : 5126, - "count" : 210, - "type" : "VEC3" - }, - { - "bufferView" : 289, - "componentType" : 5126, - "count" : 210, - "type" : "VEC2" - }, - { - "bufferView" : 290, - "componentType" : 5123, - "count" : 498, - "type" : "SCALAR" - }, - { - "bufferView" : 291, - "componentType" : 5126, - "count" : 1127, - "max" : [ - -0.3664289712905884, - 6.87420654296875, - -2.5322299003601074 - ], - "min" : [ - -0.8915549516677856, - 5.172232627868652, - -3.056950092315674 - ], - "type" : "VEC3" - }, - { - "bufferView" : 292, - "componentType" : 5126, - "count" : 1127, - "type" : "VEC3" - }, - { - "bufferView" : 293, - "componentType" : 5126, - "count" : 1127, - "type" : "VEC2" - }, - { - "bufferView" : 294, - "componentType" : 5123, - "count" : 3660, - "type" : "SCALAR" - }, - { - "bufferView" : 295, - "componentType" : 5126, - "count" : 41, - "max" : [ - -0.588267982006073, - 6.872191429138184, - -2.9346258640289307 - ], - "min" : [ - -0.6805179715156555, - 6.741235733032227, - -3.0846309661865234 - ], - "type" : "VEC3" - }, - { - "bufferView" : 296, - "componentType" : 5126, - "count" : 41, - "type" : "VEC3" - }, - { - "bufferView" : 297, - "componentType" : 5126, - "count" : 41, - "type" : "VEC2" - }, - { - "bufferView" : 298, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 299, - "componentType" : 5126, - "count" : 236, - "max" : [ - 5.2894110679626465, - 2.2099709510803223, - -2.396385908126831 - ], - "min" : [ - 4.521872043609619, - -0.02460699900984764, - -3.165167808532715 - ], - "type" : "VEC3" - }, - { - "bufferView" : 300, - "componentType" : 5126, - "count" : 236, - "type" : "VEC3" - }, - { - "bufferView" : 301, - "componentType" : 5126, - "count" : 236, - "type" : "VEC2" - }, - { - "bufferView" : 302, - "componentType" : 5123, - "count" : 546, - "type" : "SCALAR" - }, - { - "bufferView" : 303, - "componentType" : 5126, - "count" : 79, - "max" : [ - -0.5994729995727539, - 6.741554260253906, - -2.9131057262420654 - ], - "min" : [ - -0.6682379841804504, - 6.611245155334473, - -3.0545480251312256 - ], - "type" : "VEC3" - }, - { - "bufferView" : 304, - "componentType" : 5126, - "count" : 79, - "type" : "VEC3" - }, - { - "bufferView" : 305, - "componentType" : 5126, - "count" : 79, - "type" : "VEC2" - }, - { - "bufferView" : 306, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 307, - "componentType" : 5126, - "count" : 36, - "max" : [ - -0.7734410166740417, - 6.872191429138184, - -2.7494587898254395 - ], - "min" : [ - -0.9234469532966614, - 6.741235733032227, - -2.841710090637207 - ], - "type" : "VEC3" - }, - { - "bufferView" : 308, - "componentType" : 5126, - "count" : 36, - "type" : "VEC3" - }, - { - "bufferView" : 309, - "componentType" : 5126, - "count" : 36, - "type" : "VEC2" - }, - { - "bufferView" : 310, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 311, - "componentType" : 5126, - "count" : 88, - "max" : [ - -0.7519219517707825, - 6.741554260253906, - -2.76173996925354 - ], - "min" : [ - -0.8933629393577576, - 6.611245155334473, - -2.8305037021636963 - ], - "type" : "VEC3" - }, - { - "bufferView" : 312, - "componentType" : 5126, - "count" : 88, - "type" : "VEC3" - }, - { - "bufferView" : 313, - "componentType" : 5126, - "count" : 88, - "type" : "VEC2" - }, - { - "bufferView" : 314, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 315, - "componentType" : 5126, - "count" : 44, - "max" : [ - -0.5872889757156372, - 6.872191429138184, - -2.5078139305114746 - ], - "min" : [ - -0.6795389652252197, - 6.741235733032227, - -2.657819986343384 - ], - "type" : "VEC3" - }, - { - "bufferView" : 316, - "componentType" : 5126, - "count" : 44, - "type" : "VEC3" - }, - { - "bufferView" : 317, - "componentType" : 5126, - "count" : 44, - "type" : "VEC2" - }, - { - "bufferView" : 318, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 319, - "componentType" : 5126, - "count" : 67, - "max" : [ - -0.5995700359344482, - 6.741554260253906, - -2.5378968715667725 - ], - "min" : [ - -0.6683339476585388, - 6.611245155334473, - -2.6793389320373535 - ], - "type" : "VEC3" - }, - { - "bufferView" : 320, - "componentType" : 5126, - "count" : 67, - "type" : "VEC3" - }, - { - "bufferView" : 321, - "componentType" : 5126, - "count" : 67, - "type" : "VEC2" - }, - { - "bufferView" : 322, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 323, - "componentType" : 5126, - "count" : 36, - "max" : [ - -0.34435999393463135, - 6.872191429138184, - -2.7507357597351074 - ], - "min" : [ - -0.49436599016189575, - 6.741235733032227, - -2.8429858684539795 - ], - "type" : "VEC3" - }, - { - "bufferView" : 324, - "componentType" : 5126, - "count" : 36, - "type" : "VEC3" - }, - { - "bufferView" : 325, - "componentType" : 5126, - "count" : 36, - "type" : "VEC2" - }, - { - "bufferView" : 326, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 327, - "componentType" : 5126, - "count" : 91, - "max" : [ - -0.37444400787353516, - 6.741554260253906, - -2.7619409561157227 - ], - "min" : [ - -0.5158860087394714, - 6.611245155334473, - -2.8307058811187744 - ], - "type" : "VEC3" - }, - { - "bufferView" : 328, - "componentType" : 5126, - "count" : 91, - "type" : "VEC3" - }, - { - "bufferView" : 329, - "componentType" : 5126, - "count" : 91, - "type" : "VEC2" - }, - { - "bufferView" : 330, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 331, - "componentType" : 5126, - "count" : 267, - "max" : [ - -0.33523300290107727, - 6.956661701202393, - -2.500180959701538 - ], - "min" : [ - -0.9331609606742859, - 6.871912479400635, - -3.097054958343506 - ], - "type" : "VEC3" - }, - { - "bufferView" : 332, - "componentType" : 5126, - "count" : 267, - "type" : "VEC3" - }, - { - "bufferView" : 333, - "componentType" : 5126, - "count" : 267, - "type" : "VEC2" - }, - { - "bufferView" : 334, - "componentType" : 5123, - "count" : 900, - "type" : "SCALAR" - }, - { - "bufferView" : 335, - "componentType" : 5126, - "count" : 213, - "max" : [ - -0.35787200927734375, - 5.174014568328857, - -2.5223629474639893 - ], - "min" : [ - -0.9072719216346741, - 5.06633186340332, - -3.071875810623169 - ], - "type" : "VEC3" - }, - { - "bufferView" : 336, - "componentType" : 5126, - "count" : 213, - "type" : "VEC3" - }, - { - "bufferView" : 337, - "componentType" : 5126, - "count" : 213, - "type" : "VEC2" - }, - { - "bufferView" : 338, - "componentType" : 5123, - "count" : 498, - "type" : "SCALAR" - }, - { - "bufferView" : 339, - "componentType" : 5126, - "count" : 1127, - "max" : [ - -7.7908244132995605, - 6.87420654296875, - -2.532228946685791 - ], - "min" : [ - -8.315951347351074, - 5.172232627868652, - -3.056950092315674 - ], - "type" : "VEC3" - }, - { - "bufferView" : 340, - "componentType" : 5126, - "count" : 1127, - "type" : "VEC3" - }, - { - "bufferView" : 341, - "componentType" : 5126, - "count" : 1127, - "type" : "VEC2" - }, - { - "bufferView" : 342, - "componentType" : 5123, - "count" : 3660, - "type" : "SCALAR" - }, - { - "bufferView" : 343, - "componentType" : 5126, - "count" : 4749, - "max" : [ - 9.128480911254883, - 4.104053020477295, - 2.333263874053955 - ], - "min" : [ - -10.4122896194458, - 2.113954782485962, - -3.0553789138793945 - ], - "type" : "VEC3" - }, - { - "bufferView" : 344, - "componentType" : 5126, - "count" : 4749, - "type" : "VEC3" - }, - { - "bufferView" : 345, - "componentType" : 5126, - "count" : 4749, - "type" : "VEC2" - }, - { - "bufferView" : 346, - "componentType" : 5123, - "count" : 8688, - "type" : "SCALAR" - }, - { - "bufferView" : 347, - "componentType" : 5126, - "count" : 37, - "max" : [ - -8.001862525939941, - 6.872191429138184, - -2.9346258640289307 - ], - "min" : [ - -8.094112396240234, - 6.741235733032227, - -3.0846309661865234 - ], - "type" : "VEC3" - }, - { - "bufferView" : 348, - "componentType" : 5126, - "count" : 37, - "type" : "VEC3" - }, - { - "bufferView" : 349, - "componentType" : 5126, - "count" : 37, - "type" : "VEC2" - }, - { - "bufferView" : 350, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 351, - "componentType" : 5126, - "count" : 80, - "max" : [ - -8.014142990112305, - 6.741554260253906, - -2.9131057262420654 - ], - "min" : [ - -8.082907676696777, - 6.611245155334473, - -3.0545480251312256 - ], - "type" : "VEC3" - }, - { - "bufferView" : 352, - "componentType" : 5126, - "count" : 80, - "type" : "VEC3" - }, - { - "bufferView" : 353, - "componentType" : 5126, - "count" : 80, - "type" : "VEC2" - }, - { - "bufferView" : 354, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 355, - "componentType" : 5126, - "count" : 39, - "max" : [ - -7.7589335441589355, - 6.872191429138184, - -2.7494587898254395 - ], - "min" : [ - -7.908940315246582, - 6.741235733032227, - -2.841710090637207 - ], - "type" : "VEC3" - }, - { - "bufferView" : 356, - "componentType" : 5126, - "count" : 39, - "type" : "VEC3" - }, - { - "bufferView" : 357, - "componentType" : 5126, - "count" : 39, - "type" : "VEC2" - }, - { - "bufferView" : 358, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 359, - "componentType" : 5126, - "count" : 81, - "max" : [ - -7.7890167236328125, - 6.741554260253906, - -2.76173996925354 - ], - "min" : [ - -7.930459022521973, - 6.611245155334473, - -2.8305037021636963 - ], - "type" : "VEC3" - }, - { - "bufferView" : 360, - "componentType" : 5126, - "count" : 81, - "type" : "VEC3" - }, - { - "bufferView" : 361, - "componentType" : 5126, - "count" : 81, - "type" : "VEC2" - }, - { - "bufferView" : 362, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 363, - "componentType" : 5126, - "count" : 38, - "max" : [ - -8.00284194946289, - 6.872191429138184, - -2.5078139305114746 - ], - "min" : [ - -8.0950927734375, - 6.741235733032227, - -2.657819986343384 - ], - "type" : "VEC3" - }, - { - "bufferView" : 364, - "componentType" : 5126, - "count" : 38, - "type" : "VEC3" - }, - { - "bufferView" : 365, - "componentType" : 5126, - "count" : 38, - "type" : "VEC2" - }, - { - "bufferView" : 366, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 367, - "componentType" : 5126, - "count" : 72, - "max" : [ - -8.014047622680664, - 6.741554260253906, - -2.5378968715667725 - ], - "min" : [ - -8.082810401916504, - 6.611245155334473, - -2.6793389320373535 - ], - "type" : "VEC3" - }, - { - "bufferView" : 368, - "componentType" : 5126, - "count" : 72, - "type" : "VEC3" - }, - { - "bufferView" : 369, - "componentType" : 5126, - "count" : 72, - "type" : "VEC2" - }, - { - "bufferView" : 370, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 371, - "componentType" : 5126, - "count" : 35, - "max" : [ - -8.188014030456543, - 6.872191429138184, - -2.7507357597351074 - ], - "min" : [ - -8.338020324707031, - 6.741235733032227, - -2.8429858684539795 - ], - "type" : "VEC3" - }, - { - "bufferView" : 372, - "componentType" : 5126, - "count" : 35, - "type" : "VEC3" - }, - { - "bufferView" : 373, - "componentType" : 5126, - "count" : 35, - "type" : "VEC2" - }, - { - "bufferView" : 374, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 375, - "componentType" : 5126, - "count" : 92, - "max" : [ - -8.166494369506836, - 6.741554260253906, - -2.7619409561157227 - ], - "min" : [ - -8.307936668395996, - 6.611245155334473, - -2.8307058811187744 - ], - "type" : "VEC3" - }, - { - "bufferView" : 376, - "componentType" : 5126, - "count" : 92, - "type" : "VEC3" - }, - { - "bufferView" : 377, - "componentType" : 5126, - "count" : 92, - "type" : "VEC2" - }, - { - "bufferView" : 378, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 379, - "componentType" : 5126, - "count" : 267, - "max" : [ - -7.749220371246338, - 6.956661701202393, - -2.500180959701538 - ], - "min" : [ - -8.347147941589355, - 6.871912479400635, - -3.097054958343506 - ], - "type" : "VEC3" - }, - { - "bufferView" : 380, - "componentType" : 5126, - "count" : 267, - "type" : "VEC3" - }, - { - "bufferView" : 381, - "componentType" : 5126, - "count" : 267, - "type" : "VEC2" - }, - { - "bufferView" : 382, - "componentType" : 5123, - "count" : 900, - "type" : "SCALAR" - }, - { - "bufferView" : 383, - "componentType" : 5126, - "count" : 212, - "max" : [ - -7.775108337402344, - 5.174014568328857, - -2.5223617553710938 - ], - "min" : [ - -8.324508666992188, - 5.06633186340332, - -3.071875810623169 - ], - "type" : "VEC3" - }, - { - "bufferView" : 384, - "componentType" : 5126, - "count" : 212, - "type" : "VEC3" - }, - { - "bufferView" : 385, - "componentType" : 5126, - "count" : 212, - "type" : "VEC2" - }, - { - "bufferView" : 386, - "componentType" : 5123, - "count" : 498, - "type" : "SCALAR" - }, - { - "bufferView" : 387, - "componentType" : 5126, - "count" : 25, - "max" : [ - 13.022210121154785, - 4.155303001403809, - 5.741851806640625 - ], - "min" : [ - -14.322240829467773, - 4.155303001403809, - -6.454309940338135 - ], - "type" : "VEC3" - }, - { - "bufferView" : 388, - "componentType" : 5126, - "count" : 25, - "type" : "VEC3" - }, - { - "bufferView" : 389, - "componentType" : 5126, - "count" : 25, - "type" : "VEC2" - }, - { - "bufferView" : 390, - "componentType" : 5123, - "count" : 48, - "type" : "SCALAR" - }, - { - "bufferView" : 391, - "componentType" : 5126, - "count" : 1127, - "max" : [ - -4.0750627517700195, - 6.87420654296875, - -2.54028582572937 - ], - "min" : [ - -4.600190162658691, - 5.172232627868652, - -3.0650057792663574 - ], - "type" : "VEC3" - }, - { - "bufferView" : 392, - "componentType" : 5126, - "count" : 1127, - "type" : "VEC3" - }, - { - "bufferView" : 393, - "componentType" : 5126, - "count" : 1127, - "type" : "VEC2" - }, - { - "bufferView" : 394, - "componentType" : 5123, - "count" : 3660, - "type" : "SCALAR" - }, - { - "bufferView" : 395, - "componentType" : 5126, - "count" : 38, - "max" : [ - -4.2861008644104, - 6.872191429138184, - -2.5126049518585205 - ], - "min" : [ - -4.378350734710693, - 6.741235733032227, - -2.6626100540161133 - ], - "type" : "VEC3" - }, - { - "bufferView" : 396, - "componentType" : 5126, - "count" : 38, - "type" : "VEC3" - }, - { - "bufferView" : 397, - "componentType" : 5126, - "count" : 38, - "type" : "VEC2" - }, - { - "bufferView" : 398, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 399, - "componentType" : 5126, - "count" : 80, - "max" : [ - -4.2983808517456055, - 6.741554260253906, - -2.5426878929138184 - ], - "min" : [ - -4.367146015167236, - 6.611245155334473, - -2.6841301918029785 - ], - "type" : "VEC3" - }, - { - "bufferView" : 400, - "componentType" : 5126, - "count" : 80, - "type" : "VEC3" - }, - { - "bufferView" : 401, - "componentType" : 5126, - "count" : 80, - "type" : "VEC2" - }, - { - "bufferView" : 402, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 403, - "componentType" : 5126, - "count" : 42, - "max" : [ - -4.043172836303711, - 6.872191429138184, - -2.755525827407837 - ], - "min" : [ - -4.193179130554199, - 6.741235733032227, - -2.8477766513824463 - ], - "type" : "VEC3" - }, - { - "bufferView" : 404, - "componentType" : 5126, - "count" : 42, - "type" : "VEC3" - }, - { - "bufferView" : 405, - "componentType" : 5126, - "count" : 42, - "type" : "VEC2" - }, - { - "bufferView" : 406, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 407, - "componentType" : 5126, - "count" : 87, - "max" : [ - -4.073256015777588, - 6.741554260253906, - -2.7667317390441895 - ], - "min" : [ - -4.214696884155273, - 6.611245155334473, - -2.835495948791504 - ], - "type" : "VEC3" - }, - { - "bufferView" : 408, - "componentType" : 5126, - "count" : 87, - "type" : "VEC3" - }, - { - "bufferView" : 409, - "componentType" : 5126, - "count" : 87, - "type" : "VEC2" - }, - { - "bufferView" : 410, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 411, - "componentType" : 5126, - "count" : 40, - "max" : [ - -4.287079811096191, - 6.872191429138184, - -2.9394166469573975 - ], - "min" : [ - -4.379330635070801, - 6.741235733032227, - -3.0894219875335693 - ], - "type" : "VEC3" - }, - { - "bufferView" : 412, - "componentType" : 5126, - "count" : 40, - "type" : "VEC3" - }, - { - "bufferView" : 413, - "componentType" : 5126, - "count" : 40, - "type" : "VEC2" - }, - { - "bufferView" : 414, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 415, - "componentType" : 5126, - "count" : 61, - "max" : [ - -4.298285961151123, - 6.741554260253906, - -2.9178969860076904 - ], - "min" : [ - -4.3670501708984375, - 6.611245155334473, - -3.059338092803955 - ], - "type" : "VEC3" - }, - { - "bufferView" : 416, - "componentType" : 5126, - "count" : 61, - "type" : "VEC3" - }, - { - "bufferView" : 417, - "componentType" : 5126, - "count" : 61, - "type" : "VEC2" - }, - { - "bufferView" : 418, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 419, - "componentType" : 5126, - "count" : 38, - "max" : [ - -4.47225284576416, - 6.872191429138184, - -2.7542500495910645 - ], - "min" : [ - -4.622257709503174, - 6.741235733032227, - -2.8464999198913574 - ], - "type" : "VEC3" - }, - { - "bufferView" : 420, - "componentType" : 5126, - "count" : 38, - "type" : "VEC3" - }, - { - "bufferView" : 421, - "componentType" : 5126, - "count" : 38, - "type" : "VEC2" - }, - { - "bufferView" : 422, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 423, - "componentType" : 5126, - "count" : 97, - "max" : [ - -4.450733661651611, - 6.741554260253906, - -2.7665300369262695 - ], - "min" : [ - -4.592175006866455, - 6.611245155334473, - -2.835294723510742 - ], - "type" : "VEC3" - }, - { - "bufferView" : 424, - "componentType" : 5126, - "count" : 97, - "type" : "VEC3" - }, - { - "bufferView" : 425, - "componentType" : 5126, - "count" : 97, - "type" : "VEC2" - }, - { - "bufferView" : 426, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 427, - "componentType" : 5126, - "count" : 269, - "max" : [ - -4.0334577560424805, - 6.956661701202393, - -2.500180959701538 - ], - "min" : [ - -4.631386756896973, - 6.871912479400635, - -3.097054958343506 - ], - "type" : "VEC3" - }, - { - "bufferView" : 428, - "componentType" : 5126, - "count" : 269, - "type" : "VEC3" - }, - { - "bufferView" : 429, - "componentType" : 5126, - "count" : 269, - "type" : "VEC2" - }, - { - "bufferView" : 430, - "componentType" : 5123, - "count" : 900, - "type" : "SCALAR" - }, - { - "bufferView" : 431, - "componentType" : 5126, - "count" : 1848, - "max" : [ - 13.02202033996582, - 8.62651538848877, - 5.749026775360107 - ], - "min" : [ - -14.294520378112793, - 6.944672584533691, - -6.45148229598999 - ], - "type" : "VEC3" - }, - { - "bufferView" : 432, - "componentType" : 5126, - "count" : 1848, - "type" : "VEC3" - }, - { - "bufferView" : 433, - "componentType" : 5126, - "count" : 1848, - "type" : "VEC2" - }, - { - "bufferView" : 434, - "componentType" : 5123, - "count" : 6996, - "type" : "SCALAR" - }, - { - "bufferView" : 435, - "componentType" : 5126, - "count" : 213, - "max" : [ - -4.059346675872803, - 5.174014568328857, - -2.525360107421875 - ], - "min" : [ - -4.608747959136963, - 5.06633186340332, - -3.074873924255371 - ], - "type" : "VEC3" - }, - { - "bufferView" : 436, - "componentType" : 5126, - "count" : 213, - "type" : "VEC3" - }, - { - "bufferView" : 437, - "componentType" : 5126, - "count" : 213, - "type" : "VEC2" - }, - { - "bufferView" : 438, - "componentType" : 5123, - "count" : 498, - "type" : "SCALAR" - }, - { - "bufferView" : 439, - "componentType" : 5126, - "count" : 1127, - "max" : [ - 7.03314733505249, - 6.87420654296875, - 2.307628870010376 - ], - "min" : [ - 6.508020401000977, - 5.172232627868652, - 1.7829079627990723 - ], - "type" : "VEC3" - }, - { - "bufferView" : 440, - "componentType" : 5126, - "count" : 1127, - "type" : "VEC3" - }, - { - "bufferView" : 441, - "componentType" : 5126, - "count" : 1127, - "type" : "VEC2" - }, - { - "bufferView" : 442, - "componentType" : 5123, - "count" : 3660, - "type" : "SCALAR" - }, - { - "bufferView" : 443, - "componentType" : 5126, - "count" : 38, - "max" : [ - 6.822110652923584, - 6.872191429138184, - 2.3353099822998047 - ], - "min" : [ - 6.729860782623291, - 6.741235733032227, - 2.185304880142212 - ], - "type" : "VEC3" - }, - { - "bufferView" : 444, - "componentType" : 5126, - "count" : 38, - "type" : "VEC3" - }, - { - "bufferView" : 445, - "componentType" : 5126, - "count" : 38, - "type" : "VEC2" - }, - { - "bufferView" : 446, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 447, - "componentType" : 5126, - "count" : 68, - "max" : [ - 6.809830188751221, - 6.741554260253906, - 2.3052268028259277 - ], - "min" : [ - 6.741065502166748, - 6.611245155334473, - 2.163784980773926 - ], - "type" : "VEC3" - }, - { - "bufferView" : 448, - "componentType" : 5126, - "count" : 68, - "type" : "VEC3" - }, - { - "bufferView" : 449, - "componentType" : 5126, - "count" : 68, - "type" : "VEC2" - }, - { - "bufferView" : 450, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 451, - "componentType" : 5126, - "count" : 39, - "max" : [ - 7.065038681030273, - 6.872191429138184, - 2.0923879146575928 - ], - "min" : [ - 6.915033340454102, - 6.741235733032227, - 2.0001378059387207 - ], - "type" : "VEC3" - }, - { - "bufferView" : 452, - "componentType" : 5126, - "count" : 39, - "type" : "VEC3" - }, - { - "bufferView" : 453, - "componentType" : 5126, - "count" : 39, - "type" : "VEC2" - }, - { - "bufferView" : 454, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 455, - "componentType" : 5126, - "count" : 90, - "max" : [ - 7.034955978393555, - 6.741554260253906, - 2.0811829566955566 - ], - "min" : [ - 6.8935136795043945, - 6.611245155334473, - 2.0124189853668213 - ], - "type" : "VEC3" - }, - { - "bufferView" : 456, - "componentType" : 5126, - "count" : 90, - "type" : "VEC3" - }, - { - "bufferView" : 457, - "componentType" : 5126, - "count" : 90, - "type" : "VEC2" - }, - { - "bufferView" : 458, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 459, - "componentType" : 5126, - "count" : 42, - "max" : [ - 6.821131229400635, - 6.872191429138184, - 1.908497929573059 - ], - "min" : [ - 6.728880405426025, - 6.741235733032227, - 1.7584928274154663 - ], - "type" : "VEC3" - }, - { - "bufferView" : 460, - "componentType" : 5126, - "count" : 42, - "type" : "VEC3" - }, - { - "bufferView" : 461, - "componentType" : 5126, - "count" : 42, - "type" : "VEC2" - }, - { - "bufferView" : 462, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 463, - "componentType" : 5126, - "count" : 70, - "max" : [ - 6.809925556182861, - 6.741554260253906, - 1.9300179481506348 - ], - "min" : [ - 6.741161823272705, - 6.611245155334473, - 1.7885758876800537 - ], - "type" : "VEC3" - }, - { - "bufferView" : 464, - "componentType" : 5126, - "count" : 70, - "type" : "VEC3" - }, - { - "bufferView" : 465, - "componentType" : 5126, - "count" : 70, - "type" : "VEC2" - }, - { - "bufferView" : 466, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 467, - "componentType" : 5126, - "count" : 37, - "max" : [ - 6.635957717895508, - 6.872191429138184, - 2.0936648845672607 - ], - "min" : [ - 6.485952377319336, - 6.741235733032227, - 2.0014138221740723 - ], - "type" : "VEC3" - }, - { - "bufferView" : 468, - "componentType" : 5126, - "count" : 37, - "type" : "VEC3" - }, - { - "bufferView" : 469, - "componentType" : 5126, - "count" : 37, - "type" : "VEC2" - }, - { - "bufferView" : 470, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 471, - "componentType" : 5126, - "count" : 85, - "max" : [ - 6.657477855682373, - 6.741554260253906, - 2.0813839435577393 - ], - "min" : [ - 6.516035556793213, - 6.611245155334473, - 2.012619972229004 - ], - "type" : "VEC3" - }, - { - "bufferView" : 472, - "componentType" : 5126, - "count" : 85, - "type" : "VEC3" - }, - { - "bufferView" : 473, - "componentType" : 5126, - "count" : 85, - "type" : "VEC2" - }, - { - "bufferView" : 474, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 475, - "componentType" : 5126, - "count" : 874, - "max" : [ - -9.919081687927246, - 8.201327323913574, - 1.7145469188690186 - ], - "min" : [ - -10.291831016540527, - 6.957372665405273, - -2.4111900329589844 - ], - "type" : "VEC3" - }, - { - "bufferView" : 476, - "componentType" : 5126, - "count" : 874, - "type" : "VEC3" - }, - { - "bufferView" : 477, - "componentType" : 5126, - "count" : 874, - "type" : "VEC2" - }, - { - "bufferView" : 478, - "componentType" : 5123, - "count" : 1644, - "type" : "SCALAR" - }, - { - "bufferView" : 479, - "componentType" : 5126, - "count" : 269, - "max" : [ - 7.0747528076171875, - 6.956661701202393, - 2.3477330207824707 - ], - "min" : [ - 6.476824760437012, - 6.871912479400635, - 1.7508600950241089 - ], - "type" : "VEC3" - }, - { - "bufferView" : 480, - "componentType" : 5126, - "count" : 269, - "type" : "VEC3" - }, - { - "bufferView" : 481, - "componentType" : 5126, - "count" : 269, - "type" : "VEC2" - }, - { - "bufferView" : 482, - "componentType" : 5123, - "count" : 900, - "type" : "SCALAR" - }, - { - "bufferView" : 483, - "componentType" : 5126, - "count" : 208, - "max" : [ - 7.048864364624023, - 5.174014568328857, - 2.32255482673645 - ], - "min" : [ - 6.49946403503418, - 5.06633186340332, - 1.7730408906936646 - ], - "type" : "VEC3" - }, - { - "bufferView" : 484, - "componentType" : 5126, - "count" : 208, - "type" : "VEC3" - }, - { - "bufferView" : 485, - "componentType" : 5126, - "count" : 208, - "type" : "VEC2" - }, - { - "bufferView" : 486, - "componentType" : 5123, - "count" : 498, - "type" : "SCALAR" - }, - { - "bufferView" : 487, - "componentType" : 5126, - "count" : 1127, - "max" : [ - 3.3218438625335693, - 6.87420654296875, - 2.307628870010376 - ], - "min" : [ - 2.796717882156372, - 5.172232627868652, - 1.7829079627990723 - ], - "type" : "VEC3" - }, - { - "bufferView" : 488, - "componentType" : 5126, - "count" : 1127, - "type" : "VEC3" - }, - { - "bufferView" : 489, - "componentType" : 5126, - "count" : 1127, - "type" : "VEC2" - }, - { - "bufferView" : 490, - "componentType" : 5123, - "count" : 3660, - "type" : "SCALAR" - }, - { - "bufferView" : 491, - "componentType" : 5126, - "count" : 37, - "max" : [ - 3.1000049114227295, - 6.872191429138184, - 2.3353099822998047 - ], - "min" : [ - 3.0077548027038574, - 6.741235733032227, - 2.185304880142212 - ], - "type" : "VEC3" - }, - { - "bufferView" : 492, - "componentType" : 5126, - "count" : 37, - "type" : "VEC3" - }, - { - "bufferView" : 493, - "componentType" : 5126, - "count" : 37, - "type" : "VEC2" - }, - { - "bufferView" : 494, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 495, - "componentType" : 5126, - "count" : 72, - "max" : [ - 3.088798761367798, - 6.741554260253906, - 2.3052268028259277 - ], - "min" : [ - 3.0200347900390625, - 6.611245155334473, - 2.163784980773926 - ], - "type" : "VEC3" - }, - { - "bufferView" : 496, - "componentType" : 5126, - "count" : 72, - "type" : "VEC3" - }, - { - "bufferView" : 497, - "componentType" : 5126, - "count" : 72, - "type" : "VEC2" - }, - { - "bufferView" : 498, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 499, - "componentType" : 5126, - "count" : 36, - "max" : [ - 2.9148318767547607, - 6.872191429138184, - 2.0923879146575928 - ], - "min" : [ - 2.7648260593414307, - 6.741235733032227, - 2.0001378059387207 - ], - "type" : "VEC3" - }, - { - "bufferView" : 500, - "componentType" : 5126, - "count" : 36, - "type" : "VEC3" - }, - { - "bufferView" : 501, - "componentType" : 5126, - "count" : 36, - "type" : "VEC2" - }, - { - "bufferView" : 502, - "componentType" : 5126, - "count" : 84, - "max" : [ - 2.9363510608673096, - 6.741554260253906, - 2.0811829566955566 - ], - "min" : [ - 2.794910192489624, - 6.611245155334473, - 2.0124189853668213 - ], - "type" : "VEC3" - }, - { - "bufferView" : 503, - "componentType" : 5126, - "count" : 84, - "type" : "VEC3" - }, - { - "bufferView" : 504, - "componentType" : 5126, - "count" : 84, - "type" : "VEC2" - }, - { - "bufferView" : 505, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 506, - "componentType" : 5126, - "count" : 37, - "max" : [ - 3.1009838581085205, - 6.872191429138184, - 1.908499002456665 - ], - "min" : [ - 3.0087337493896484, - 6.741235733032227, - 1.7584928274154663 - ], - "type" : "VEC3" - }, - { - "bufferView" : 507, - "componentType" : 5126, - "count" : 37, - "type" : "VEC3" - }, - { - "bufferView" : 508, - "componentType" : 5126, - "count" : 37, - "type" : "VEC2" - }, - { - "bufferView" : 509, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 510, - "componentType" : 5126, - "count" : 72, - "max" : [ - 3.0887038707733154, - 6.741554260253906, - 1.9300179481506348 - ], - "min" : [ - 3.0199389457702637, - 6.611245155334473, - 1.7885758876800537 - ], - "type" : "VEC3" - }, - { - "bufferView" : 511, - "componentType" : 5126, - "count" : 72, - "type" : "VEC3" - }, - { - "bufferView" : 512, - "componentType" : 5126, - "count" : 72, - "type" : "VEC2" - }, - { - "bufferView" : 513, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 514, - "componentType" : 5126, - "count" : 35, - "max" : [ - 3.34391188621521, - 6.872191429138184, - 2.0936648845672607 - ], - "min" : [ - 3.193906784057617, - 6.741235733032227, - 2.0014150142669678 - ], - "type" : "VEC3" - }, - { - "bufferView" : 515, - "componentType" : 5126, - "count" : 35, - "type" : "VEC3" - }, - { - "bufferView" : 516, - "componentType" : 5126, - "count" : 35, - "type" : "VEC2" - }, - { - "bufferView" : 517, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 518, - "componentType" : 5126, - "count" : 899, - "max" : [ - 8.972500801086426, - 8.201327323913574, - 1.7145469188690186 - ], - "min" : [ - 8.599747657775879, - 6.957372665405273, - -2.4111900329589844 - ], - "type" : "VEC3" - }, - { - "bufferView" : 519, - "componentType" : 5126, - "count" : 899, - "type" : "VEC3" - }, - { - "bufferView" : 520, - "componentType" : 5126, - "count" : 899, - "type" : "VEC2" - }, - { - "bufferView" : 521, - "componentType" : 5123, - "count" : 1644, - "type" : "SCALAR" - }, - { - "bufferView" : 522, - "componentType" : 5126, - "count" : 82, - "max" : [ - 3.313828945159912, - 6.741554260253906, - 2.0813839435577393 - ], - "min" : [ - 3.1723878383636475, - 6.611245155334473, - 2.012619972229004 - ], - "type" : "VEC3" - }, - { - "bufferView" : 523, - "componentType" : 5126, - "count" : 82, - "type" : "VEC3" - }, - { - "bufferView" : 524, - "componentType" : 5126, - "count" : 82, - "type" : "VEC2" - }, - { - "bufferView" : 525, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 526, - "componentType" : 5126, - "count" : 266, - "max" : [ - 3.3530399799346924, - 6.956661701202393, - 2.347733974456787 - ], - "min" : [ - 2.7551119327545166, - 6.871912479400635, - 1.7508600950241089 - ], - "type" : "VEC3" - }, - { - "bufferView" : 527, - "componentType" : 5126, - "count" : 266, - "type" : "VEC3" - }, - { - "bufferView" : 528, - "componentType" : 5126, - "count" : 266, - "type" : "VEC2" - }, - { - "bufferView" : 529, - "componentType" : 5123, - "count" : 900, - "type" : "SCALAR" - }, - { - "bufferView" : 530, - "componentType" : 5126, - "count" : 207, - "max" : [ - 3.3304009437561035, - 5.174014568328857, - 2.32255482673645 - ], - "min" : [ - 2.781000852584839, - 5.06633186340332, - 1.7730408906936646 - ], - "type" : "VEC3" - }, - { - "bufferView" : 531, - "componentType" : 5126, - "count" : 207, - "type" : "VEC3" - }, - { - "bufferView" : 532, - "componentType" : 5126, - "count" : 207, - "type" : "VEC2" - }, - { - "bufferView" : 533, - "componentType" : 5123, - "count" : 498, - "type" : "SCALAR" - }, - { - "bufferView" : 534, - "componentType" : 5126, - "count" : 1127, - "max" : [ - -0.3664289712905884, - 6.87420654296875, - 2.3156850337982178 - ], - "min" : [ - -0.8915549516677856, - 5.172232627868652, - 1.790964961051941 - ], - "type" : "VEC3" - }, - { - "bufferView" : 535, - "componentType" : 5126, - "count" : 1127, - "type" : "VEC3" - }, - { - "bufferView" : 536, - "componentType" : 5126, - "count" : 1127, - "type" : "VEC2" - }, - { - "bufferView" : 537, - "componentType" : 5123, - "count" : 3660, - "type" : "SCALAR" - }, - { - "bufferView" : 538, - "componentType" : 5126, - "count" : 39, - "max" : [ - -0.588267982006073, - 6.872191429138184, - 1.9132888317108154 - ], - "min" : [ - -0.6805179715156555, - 6.741235733032227, - 1.7632828950881958 - ], - "type" : "VEC3" - }, - { - "bufferView" : 539, - "componentType" : 5126, - "count" : 39, - "type" : "VEC3" - }, - { - "bufferView" : 540, - "componentType" : 5126, - "count" : 39, - "type" : "VEC2" - }, - { - "bufferView" : 541, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 542, - "componentType" : 5126, - "count" : 70, - "max" : [ - -0.5994729995727539, - 6.741554260253906, - 1.9348078966140747 - ], - "min" : [ - -0.6682379841804504, - 6.611245155334473, - 1.7933669090270996 - ], - "type" : "VEC3" - }, - { - "bufferView" : 543, - "componentType" : 5126, - "count" : 70, - "type" : "VEC3" - }, - { - "bufferView" : 544, - "componentType" : 5126, - "count" : 70, - "type" : "VEC2" - }, - { - "bufferView" : 545, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 546, - "componentType" : 5126, - "count" : 35, - "max" : [ - -0.7734410166740417, - 6.872191429138184, - 2.0984559059143066 - ], - "min" : [ - -0.9234469532966614, - 6.741235733032227, - 2.006204843521118 - ], - "type" : "VEC3" - }, - { - "bufferView" : 547, - "componentType" : 5126, - "count" : 35, - "type" : "VEC3" - }, - { - "bufferView" : 548, - "componentType" : 5126, - "count" : 35, - "type" : "VEC2" - }, - { - "bufferView" : 549, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 550, - "componentType" : 5126, - "count" : 94, - "max" : [ - -0.7519219517707825, - 6.741554260253906, - 2.086174964904785 - ], - "min" : [ - -0.8933629393577576, - 6.611245155334473, - 2.0174107551574707 - ], - "type" : "VEC3" - }, - { - "bufferView" : 551, - "componentType" : 5126, - "count" : 94, - "type" : "VEC3" - }, - { - "bufferView" : 552, - "componentType" : 5126, - "count" : 94, - "type" : "VEC2" - }, - { - "bufferView" : 553, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 554, - "componentType" : 5126, - "count" : 44, - "max" : [ - -0.5872889757156372, - 6.872191429138184, - 2.340099811553955 - ], - "min" : [ - -0.6795389652252197, - 6.741235733032227, - 2.1900949478149414 - ], - "type" : "VEC3" - }, - { - "bufferView" : 555, - "componentType" : 5126, - "count" : 44, - "type" : "VEC3" - }, - { - "bufferView" : 556, - "componentType" : 5126, - "count" : 44, - "type" : "VEC2" - }, - { - "bufferView" : 557, - "componentType" : 5126, - "count" : 69, - "max" : [ - -0.5995700359344482, - 6.741554260253906, - 2.3100168704986572 - ], - "min" : [ - -0.6683339476585388, - 6.611245155334473, - 2.1685757637023926 - ], - "type" : "VEC3" - }, - { - "bufferView" : 558, - "componentType" : 5126, - "count" : 69, - "type" : "VEC3" - }, - { - "bufferView" : 559, - "componentType" : 5126, - "count" : 69, - "type" : "VEC2" - }, - { - "bufferView" : 560, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 561, - "componentType" : 5126, - "count" : 696, - "max" : [ - -9.481002807617188, - 6.953227519989014, - 2.4335010051727295 - ], - "min" : [ - -10.462919235229492, - 5.07139778137207, - 1.4515849351882935 - ], - "type" : "VEC3" - }, - { - "bufferView" : 562, - "componentType" : 5126, - "count" : 696, - "type" : "VEC3" - }, - { - "bufferView" : 563, - "componentType" : 5126, - "count" : 696, - "type" : "VEC2" - }, - { - "bufferView" : 564, - "componentType" : 5123, - "count" : 1188, - "type" : "SCALAR" - }, - { - "bufferView" : 565, - "componentType" : 5126, - "count" : 36, - "max" : [ - -0.34435999393463135, - 6.872191429138184, - 2.0971789360046387 - ], - "min" : [ - -0.49436599016189575, - 6.741235733032227, - 2.0049288272857666 - ], - "type" : "VEC3" - }, - { - "bufferView" : 566, - "componentType" : 5126, - "count" : 36, - "type" : "VEC3" - }, - { - "bufferView" : 567, - "componentType" : 5126, - "count" : 36, - "type" : "VEC2" - }, - { - "bufferView" : 568, - "componentType" : 5126, - "count" : 85, - "max" : [ - -0.37444400787353516, - 6.741554260253906, - 2.0859739780426025 - ], - "min" : [ - -0.5158860087394714, - 6.611245155334473, - 2.017209053039551 - ], - "type" : "VEC3" - }, - { - "bufferView" : 569, - "componentType" : 5126, - "count" : 85, - "type" : "VEC3" - }, - { - "bufferView" : 570, - "componentType" : 5126, - "count" : 85, - "type" : "VEC2" - }, - { - "bufferView" : 571, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 572, - "componentType" : 5126, - "count" : 267, - "max" : [ - -0.33523300290107727, - 6.956661701202393, - 2.3477330207824707 - ], - "min" : [ - -0.9331609606742859, - 6.871912479400635, - 1.7508600950241089 - ], - "type" : "VEC3" - }, - { - "bufferView" : 573, - "componentType" : 5126, - "count" : 267, - "type" : "VEC3" - }, - { - "bufferView" : 574, - "componentType" : 5126, - "count" : 267, - "type" : "VEC2" - }, - { - "bufferView" : 575, - "componentType" : 5123, - "count" : 900, - "type" : "SCALAR" - }, - { - "bufferView" : 576, - "componentType" : 5126, - "count" : 210, - "max" : [ - -0.35787200927734375, - 5.174014568328857, - 2.325551748275757 - ], - "min" : [ - -0.9072719216346741, - 5.06633186340332, - 1.7760388851165771 - ], - "type" : "VEC3" - }, - { - "bufferView" : 577, - "componentType" : 5126, - "count" : 210, - "type" : "VEC3" - }, - { - "bufferView" : 578, - "componentType" : 5126, - "count" : 210, - "type" : "VEC2" - }, - { - "bufferView" : 579, - "componentType" : 5123, - "count" : 498, - "type" : "SCALAR" - }, - { - "bufferView" : 580, - "componentType" : 5126, - "count" : 1127, - "max" : [ - -7.7908244132995605, - 6.87420654296875, - 2.3156850337982178 - ], - "min" : [ - -8.315951347351074, - 5.172232627868652, - 1.790964961051941 - ], - "type" : "VEC3" - }, - { - "bufferView" : 581, - "componentType" : 5126, - "count" : 1127, - "type" : "VEC3" - }, - { - "bufferView" : 582, - "componentType" : 5126, - "count" : 1127, - "type" : "VEC2" - }, - { - "bufferView" : 583, - "componentType" : 5123, - "count" : 3660, - "type" : "SCALAR" - }, - { - "bufferView" : 584, - "componentType" : 5126, - "count" : 35, - "max" : [ - -8.001862525939941, - 6.872191429138184, - 1.9132888317108154 - ], - "min" : [ - -8.094112396240234, - 6.741235733032227, - 1.7632828950881958 - ], - "type" : "VEC3" - }, - { - "bufferView" : 585, - "componentType" : 5126, - "count" : 35, - "type" : "VEC3" - }, - { - "bufferView" : 586, - "componentType" : 5126, - "count" : 35, - "type" : "VEC2" - }, - { - "bufferView" : 587, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 588, - "componentType" : 5126, - "count" : 73, - "max" : [ - -8.014142990112305, - 6.741554260253906, - 1.9348078966140747 - ], - "min" : [ - -8.082907676696777, - 6.611245155334473, - 1.7933669090270996 - ], - "type" : "VEC3" - }, - { - "bufferView" : 589, - "componentType" : 5126, - "count" : 73, - "type" : "VEC3" - }, - { - "bufferView" : 590, - "componentType" : 5126, - "count" : 73, - "type" : "VEC2" - }, - { - "bufferView" : 591, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 592, - "componentType" : 5126, - "count" : 34, - "max" : [ - -7.7589335441589355, - 6.872191429138184, - 2.0984559059143066 - ], - "min" : [ - -7.908940315246582, - 6.741235733032227, - 2.006204843521118 - ], - "type" : "VEC3" - }, - { - "bufferView" : 593, - "componentType" : 5126, - "count" : 34, - "type" : "VEC3" - }, - { - "bufferView" : 594, - "componentType" : 5126, - "count" : 34, - "type" : "VEC2" - }, - { - "bufferView" : 595, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 596, - "componentType" : 5126, - "count" : 85, - "max" : [ - -7.7890167236328125, - 6.741554260253906, - 2.086174964904785 - ], - "min" : [ - -7.930459022521973, - 6.611245155334473, - 2.0174107551574707 - ], - "type" : "VEC3" - }, - { - "bufferView" : 597, - "componentType" : 5126, - "count" : 85, - "type" : "VEC3" - }, - { - "bufferView" : 598, - "componentType" : 5126, - "count" : 85, - "type" : "VEC2" - }, - { - "bufferView" : 599, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 600, - "componentType" : 5126, - "count" : 40, - "max" : [ - -8.00284194946289, - 6.872191429138184, - 2.340099811553955 - ], - "min" : [ - -8.0950927734375, - 6.741235733032227, - 2.1900949478149414 - ], - "type" : "VEC3" - }, - { - "bufferView" : 601, - "componentType" : 5126, - "count" : 40, - "type" : "VEC3" - }, - { - "bufferView" : 602, - "componentType" : 5126, - "count" : 40, - "type" : "VEC2" - }, - { - "bufferView" : 603, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 604, - "componentType" : 5126, - "count" : 495, - "max" : [ - -5.810407638549805, - 6.953227519989014, - 2.4335010051727295 - ], - "min" : [ - -6.556130409240723, - 5.07139778137207, - 1.687882900238037 - ], - "type" : "VEC3" - }, - { - "bufferView" : 605, - "componentType" : 5126, - "count" : 495, - "type" : "VEC3" - }, - { - "bufferView" : 606, - "componentType" : 5126, - "count" : 495, - "type" : "VEC2" - }, - { - "bufferView" : 607, - "componentType" : 5123, - "count" : 786, - "type" : "SCALAR" - }, - { - "bufferView" : 608, - "componentType" : 5126, - "count" : 74, - "max" : [ - -8.014047622680664, - 6.741554260253906, - 2.3100168704986572 - ], - "min" : [ - -8.082810401916504, - 6.611245155334473, - 2.1685757637023926 - ], - "type" : "VEC3" - }, - { - "bufferView" : 609, - "componentType" : 5126, - "count" : 74, - "type" : "VEC3" - }, - { - "bufferView" : 610, - "componentType" : 5126, - "count" : 74, - "type" : "VEC2" - }, - { - "bufferView" : 611, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 612, - "componentType" : 5126, - "count" : 33, - "max" : [ - -8.188014030456543, - 6.872191429138184, - 2.0971789360046387 - ], - "min" : [ - -8.338020324707031, - 6.741235733032227, - 2.0049288272857666 - ], - "type" : "VEC3" - }, - { - "bufferView" : 613, - "componentType" : 5126, - "count" : 33, - "type" : "VEC3" - }, - { - "bufferView" : 614, - "componentType" : 5126, - "count" : 33, - "type" : "VEC2" - }, - { - "bufferView" : 615, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 616, - "componentType" : 5126, - "count" : 90, - "max" : [ - -8.166494369506836, - 6.741554260253906, - 2.0859739780426025 - ], - "min" : [ - -8.307936668395996, - 6.611245155334473, - 2.017209053039551 - ], - "type" : "VEC3" - }, - { - "bufferView" : 617, - "componentType" : 5126, - "count" : 90, - "type" : "VEC3" - }, - { - "bufferView" : 618, - "componentType" : 5126, - "count" : 90, - "type" : "VEC2" - }, - { - "bufferView" : 619, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 620, - "componentType" : 5126, - "count" : 267, - "max" : [ - -7.749220371246338, - 6.956661701202393, - 2.347733974456787 - ], - "min" : [ - -8.347147941589355, - 6.871912479400635, - 1.7508600950241089 - ], - "type" : "VEC3" - }, - { - "bufferView" : 621, - "componentType" : 5126, - "count" : 267, - "type" : "VEC3" - }, - { - "bufferView" : 622, - "componentType" : 5126, - "count" : 267, - "type" : "VEC2" - }, - { - "bufferView" : 623, - "componentType" : 5123, - "count" : 900, - "type" : "SCALAR" - }, - { - "bufferView" : 624, - "componentType" : 5126, - "count" : 199, - "max" : [ - -7.775108337402344, - 5.174014568328857, - 2.325551748275757 - ], - "min" : [ - -8.324508666992188, - 5.06633186340332, - 1.7760388851165771 - ], - "type" : "VEC3" - }, - { - "bufferView" : 625, - "componentType" : 5126, - "count" : 199, - "type" : "VEC3" - }, - { - "bufferView" : 626, - "componentType" : 5126, - "count" : 199, - "type" : "VEC2" - }, - { - "bufferView" : 627, - "componentType" : 5123, - "count" : 498, - "type" : "SCALAR" - }, - { - "bufferView" : 628, - "componentType" : 5126, - "count" : 1127, - "max" : [ - -4.0750627517700195, - 6.87420654296875, - 2.307628870010376 - ], - "min" : [ - -4.600190162658691, - 5.172232627868652, - 1.7829079627990723 - ], - "type" : "VEC3" - }, - { - "bufferView" : 629, - "componentType" : 5126, - "count" : 1127, - "type" : "VEC3" - }, - { - "bufferView" : 630, - "componentType" : 5126, - "count" : 1127, - "type" : "VEC2" - }, - { - "bufferView" : 631, - "componentType" : 5123, - "count" : 3660, - "type" : "SCALAR" - }, - { - "bufferView" : 632, - "componentType" : 5126, - "count" : 40, - "max" : [ - -4.2861008644104, - 6.872191429138184, - 2.3353099822998047 - ], - "min" : [ - -4.378350734710693, - 6.741235733032227, - 2.185304880142212 - ], - "type" : "VEC3" - }, - { - "bufferView" : 633, - "componentType" : 5126, - "count" : 40, - "type" : "VEC3" - }, - { - "bufferView" : 634, - "componentType" : 5126, - "count" : 40, - "type" : "VEC2" - }, - { - "bufferView" : 635, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 636, - "componentType" : 5126, - "count" : 70, - "max" : [ - -4.2983808517456055, - 6.741554260253906, - 2.3052268028259277 - ], - "min" : [ - -4.367146015167236, - 6.611245155334473, - 2.163784980773926 - ], - "type" : "VEC3" - }, - { - "bufferView" : 637, - "componentType" : 5126, - "count" : 70, - "type" : "VEC3" - }, - { - "bufferView" : 638, - "componentType" : 5126, - "count" : 70, - "type" : "VEC2" - }, - { - "bufferView" : 639, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 640, - "componentType" : 5126, - "count" : 36, - "max" : [ - -4.043172836303711, - 6.872191429138184, - 2.0923879146575928 - ], - "min" : [ - -4.193179130554199, - 6.741235733032227, - 2.0001378059387207 - ], - "type" : "VEC3" - }, - { - "bufferView" : 641, - "componentType" : 5126, - "count" : 36, - "type" : "VEC3" - }, - { - "bufferView" : 642, - "componentType" : 5126, - "count" : 36, - "type" : "VEC2" - }, - { - "bufferView" : 643, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 644, - "componentType" : 5126, - "count" : 92, - "max" : [ - -4.073256015777588, - 6.741554260253906, - 2.0811829566955566 - ], - "min" : [ - -4.214696884155273, - 6.611245155334473, - 2.0124189853668213 - ], - "type" : "VEC3" - }, - { - "bufferView" : 645, - "componentType" : 5126, - "count" : 92, - "type" : "VEC3" - }, - { - "bufferView" : 646, - "componentType" : 5126, - "count" : 92, - "type" : "VEC2" - }, - { - "bufferView" : 647, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 648, - "componentType" : 5126, - "count" : 498, - "max" : [ - -2.1150100231170654, - 6.953227519989014, - 2.4335010051727295 - ], - "min" : [ - -2.860734701156616, - 5.071398735046387, - 1.687882900238037 - ], - "type" : "VEC3" - }, - { - "bufferView" : 649, - "componentType" : 5126, - "count" : 498, - "type" : "VEC3" - }, - { - "bufferView" : 650, - "componentType" : 5126, - "count" : 498, - "type" : "VEC2" - }, - { - "bufferView" : 651, - "componentType" : 5123, - "count" : 786, - "type" : "SCALAR" - }, - { - "bufferView" : 652, - "componentType" : 5126, - "count" : 38, - "max" : [ - -4.287079811096191, - 6.872191429138184, - 1.908497929573059 - ], - "min" : [ - -4.379330635070801, - 6.741235733032227, - 1.7584928274154663 - ], - "type" : "VEC3" - }, - { - "bufferView" : 653, - "componentType" : 5126, - "count" : 38, - "type" : "VEC3" - }, - { - "bufferView" : 654, - "componentType" : 5126, - "count" : 38, - "type" : "VEC2" - }, - { - "bufferView" : 655, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 656, - "componentType" : 5126, - "count" : 68, - "max" : [ - -4.298285961151123, - 6.741554260253906, - 1.9300179481506348 - ], - "min" : [ - -4.3670501708984375, - 6.611245155334473, - 1.7885758876800537 - ], - "type" : "VEC3" - }, - { - "bufferView" : 657, - "componentType" : 5126, - "count" : 68, - "type" : "VEC3" - }, - { - "bufferView" : 658, - "componentType" : 5126, - "count" : 68, - "type" : "VEC2" - }, - { - "bufferView" : 659, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 660, - "componentType" : 5126, - "count" : 36, - "max" : [ - -4.47225284576416, - 6.872191429138184, - 2.0936648845672607 - ], - "min" : [ - -4.622257709503174, - 6.741235733032227, - 2.0014138221740723 - ], - "type" : "VEC3" - }, - { - "bufferView" : 661, - "componentType" : 5126, - "count" : 36, - "type" : "VEC3" - }, - { - "bufferView" : 662, - "componentType" : 5126, - "count" : 36, - "type" : "VEC2" - }, - { - "bufferView" : 663, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 664, - "componentType" : 5126, - "count" : 88, - "max" : [ - -4.450733661651611, - 6.741554260253906, - 2.0813839435577393 - ], - "min" : [ - -4.592175006866455, - 6.611245155334473, - 2.012619972229004 - ], - "type" : "VEC3" - }, - { - "bufferView" : 665, - "componentType" : 5126, - "count" : 88, - "type" : "VEC3" - }, - { - "bufferView" : 666, - "componentType" : 5126, - "count" : 88, - "type" : "VEC2" - }, - { - "bufferView" : 667, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 668, - "componentType" : 5126, - "count" : 268, - "max" : [ - -4.0334577560424805, - 6.956661701202393, - 2.3477330207824707 - ], - "min" : [ - -4.631386756896973, - 6.871912479400635, - 1.7508600950241089 - ], - "type" : "VEC3" - }, - { - "bufferView" : 669, - "componentType" : 5126, - "count" : 268, - "type" : "VEC3" - }, - { - "bufferView" : 670, - "componentType" : 5126, - "count" : 268, - "type" : "VEC2" - }, - { - "bufferView" : 671, - "componentType" : 5123, - "count" : 900, - "type" : "SCALAR" - }, - { - "bufferView" : 672, - "componentType" : 5126, - "count" : 206, - "max" : [ - -4.059346675872803, - 5.174014568328857, - 2.32255482673645 - ], - "min" : [ - -4.608747959136963, - 5.06633186340332, - 1.7730408906936646 - ], - "type" : "VEC3" - }, - { - "bufferView" : 673, - "componentType" : 5126, - "count" : 206, - "type" : "VEC3" - }, - { - "bufferView" : 674, - "componentType" : 5126, - "count" : 206, - "type" : "VEC2" - }, - { - "bufferView" : 675, - "componentType" : 5123, - "count" : 498, - "type" : "SCALAR" - }, - { - "bufferView" : 676, - "componentType" : 5126, - "count" : 1127, - "max" : [ - 9.038040161132812, - 6.924715518951416, - -0.1202629953622818 - ], - "min" : [ - 8.583305358886719, - 5.163723468780518, - -0.5746449828147888 - ], - "type" : "VEC3" - }, - { - "bufferView" : 677, - "componentType" : 5126, - "count" : 1127, - "type" : "VEC3" - }, - { - "bufferView" : 678, - "componentType" : 5126, - "count" : 1127, - "type" : "VEC2" - }, - { - "bufferView" : 679, - "componentType" : 5123, - "count" : 3660, - "type" : "SCALAR" - }, - { - "bufferView" : 680, - "componentType" : 5126, - "count" : 40, - "max" : [ - 8.855291366577148, - 6.922971725463867, - -0.4687189757823944 - ], - "min" : [ - 8.775408744812012, - 6.8095703125, - -0.5986160039901733 - ], - "type" : "VEC3" - }, - { - "bufferView" : 681, - "componentType" : 5126, - "count" : 40, - "type" : "VEC3" - }, - { - "bufferView" : 682, - "componentType" : 5126, - "count" : 40, - "type" : "VEC2" - }, - { - "bufferView" : 683, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 684, - "componentType" : 5126, - "count" : 70, - "max" : [ - 8.844656944274902, - 6.809845447540283, - -0.45008400082588196 - ], - "min" : [ - 8.785110473632812, - 6.6970038414001465, - -0.5725650191307068 - ], - "type" : "VEC3" - }, - { - "bufferView" : 685, - "componentType" : 5126, - "count" : 70, - "type" : "VEC3" - }, - { - "bufferView" : 686, - "componentType" : 5126, - "count" : 70, - "type" : "VEC2" - }, - { - "bufferView" : 687, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 688, - "componentType" : 5126, - "count" : 37, - "max" : [ - 9.065656661987305, - 6.922971725463867, - -0.30837297439575195 - ], - "min" : [ - 8.935757637023926, - 6.8095703125, - -0.3882579803466797 - ], - "type" : "VEC3" - }, - { - "bufferView" : 689, - "componentType" : 5126, - "count" : 37, - "type" : "VEC3" - }, - { - "bufferView" : 690, - "componentType" : 5126, - "count" : 37, - "type" : "VEC2" - }, - { - "bufferView" : 691, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 692, - "componentType" : 5126, - "count" : 498, - "max" : [ - 1.5723389387130737, - 6.953227519989014, - 2.4335010051727295 - ], - "min" : [ - 0.8266169428825378, - 5.07139778137207, - 1.687882900238037 - ], - "type" : "VEC3" - }, - { - "bufferView" : 693, - "componentType" : 5126, - "count" : 498, - "type" : "VEC3" - }, - { - "bufferView" : 694, - "componentType" : 5126, - "count" : 498, - "type" : "VEC2" - }, - { - "bufferView" : 695, - "componentType" : 5123, - "count" : 786, - "type" : "SCALAR" - }, - { - "bufferView" : 696, - "componentType" : 5126, - "count" : 84, - "max" : [ - 9.039605140686035, - 6.809845447540283, - -0.3190079927444458 - ], - "min" : [ - 8.917123794555664, - 6.6970038414001465, - -0.37855398654937744 - ], - "type" : "VEC3" - }, - { - "bufferView" : 697, - "componentType" : 5126, - "count" : 84, - "type" : "VEC3" - }, - { - "bufferView" : 698, - "componentType" : 5126, - "count" : 84, - "type" : "VEC2" - }, - { - "bufferView" : 699, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 700, - "componentType" : 5126, - "count" : 40, - "max" : [ - 8.85444450378418, - 6.922971725463867, - -0.09912099689245224 - ], - "min" : [ - 8.774558067321777, - 6.8095703125, - -0.22901800274848938 - ], - "type" : "VEC3" - }, - { - "bufferView" : 701, - "componentType" : 5126, - "count" : 40, - "type" : "VEC3" - }, - { - "bufferView" : 702, - "componentType" : 5126, - "count" : 40, - "type" : "VEC2" - }, - { - "bufferView" : 703, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 704, - "componentType" : 5126, - "count" : 66, - "max" : [ - 8.844740867614746, - 6.809845447540283, - -0.1251709908246994 - ], - "min" : [ - 8.785194396972656, - 6.6970038414001465, - -0.24765297770500183 - ], - "type" : "VEC3" - }, - { - "bufferView" : 705, - "componentType" : 5126, - "count" : 66, - "type" : "VEC3" - }, - { - "bufferView" : 706, - "componentType" : 5126, - "count" : 66, - "type" : "VEC2" - }, - { - "bufferView" : 707, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 708, - "componentType" : 5126, - "count" : 36, - "max" : [ - 8.694092750549316, - 6.922971725463867, - -0.3094789683818817 - ], - "min" : [ - 8.564196586608887, - 6.8095703125, - -0.38936296105384827 - ], - "type" : "VEC3" - }, - { - "bufferView" : 709, - "componentType" : 5126, - "count" : 36, - "type" : "VEC3" - }, - { - "bufferView" : 710, - "componentType" : 5126, - "count" : 36, - "type" : "VEC2" - }, - { - "bufferView" : 711, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 712, - "componentType" : 5126, - "count" : 90, - "max" : [ - 8.712727546691895, - 6.809845447540283, - -0.31918197870254517 - ], - "min" : [ - 8.590246200561523, - 6.6970038414001465, - -0.378728985786438 - ], - "type" : "VEC3" - }, - { - "bufferView" : 713, - "componentType" : 5126, - "count" : 90, - "type" : "VEC3" - }, - { - "bufferView" : 714, - "componentType" : 5126, - "count" : 90, - "type" : "VEC2" - }, - { - "bufferView" : 715, - "componentType" : 5123, - "count" : 132, - "type" : "SCALAR" - }, - { - "bufferView" : 716, - "componentType" : 5126, - "count" : 292, - "max" : [ - 9.074068069458008, - 6.99611759185791, - -0.09251099079847336 - ], - "min" : [ - 8.556291580200195, - 6.922728538513184, - -0.609373927116394 - ], - "type" : "VEC3" - }, - { - "bufferView" : 717, - "componentType" : 5126, - "count" : 292, - "type" : "VEC3" - }, - { - "bufferView" : 718, - "componentType" : 5126, - "count" : 292, - "type" : "VEC2" - }, - { - "bufferView" : 719, - "componentType" : 5123, - "count" : 900, - "type" : "SCALAR" - }, - { - "bufferView" : 720, - "componentType" : 5126, - "count" : 208, - "max" : [ - 9.051650047302246, - 5.1652679443359375, - -0.11171899735927582 - ], - "min" : [ - 8.575896263122559, - 5.072018623352051, - -0.5875709652900696 - ], - "type" : "VEC3" - }, - { - "bufferView" : 721, - "componentType" : 5126, - "count" : 208, - "type" : "VEC3" - }, - { - "bufferView" : 722, - "componentType" : 5126, - "count" : 208, - "type" : "VEC2" - }, - { - "bufferView" : 723, - "componentType" : 5123, - "count" : 498, - "type" : "SCALAR" - }, - { - "bufferView" : 724, - "componentType" : 5126, - "count" : 38, - "max" : [ - -0.08262899518013, - 3.481973886489868, - 5.755051612854004 - ], - "min" : [ - -1.194072961807251, - 2.567310094833374, - 5.686583518981934 - ], - "type" : "VEC3" - }, - { - "bufferView" : 725, - "componentType" : 5126, - "count" : 38, - "type" : "VEC3" - }, - { - "bufferView" : 726, - "componentType" : 5126, - "count" : 38, - "type" : "VEC2" - }, - { - "bufferView" : 727, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 728, - "componentType" : 5126, - "count" : 148, - "max" : [ - 9.975961685180664, - 13.307689666748047, - 3.1890077590942383 - ], - "min" : [ - -10.86423110961914, - 9.07744026184082, - -4.081467628479004 - ], - "type" : "VEC3" - }, - { - "bufferView" : 729, - "componentType" : 5126, - "count" : 148, - "type" : "VEC3" - }, - { - "bufferView" : 730, - "componentType" : 5126, - "count" : 148, - "type" : "VEC2" - }, - { - "bufferView" : 731, - "componentType" : 5123, - "count" : 192, - "type" : "SCALAR" - }, - { - "bufferView" : 732, - "componentType" : 5126, - "count" : 183, - "max" : [ - 4.969552040100098, - 8.861390113830566, - -0.7923719882965088 - ], - "min" : [ - 4.892256736755371, - 8.316546440124512, - -2.708303689956665 - ], - "type" : "VEC3" - }, - { - "bufferView" : 733, - "componentType" : 5126, - "count" : 183, - "type" : "VEC3" - }, - { - "bufferView" : 734, - "componentType" : 5126, - "count" : 183, - "type" : "VEC2" - }, - { - "bufferView" : 735, - "componentType" : 5123, - "count" : 678, - "type" : "SCALAR" - }, - { - "bufferView" : 736, - "componentType" : 5126, - "count" : 504, - "max" : [ - 5.2911810874938965, - 6.953227519989014, - 2.4335010051727295 - ], - "min" : [ - 4.54545783996582, - 5.07139778137207, - 1.687882900238037 - ], - "type" : "VEC3" - }, - { - "bufferView" : 737, - "componentType" : 5126, - "count" : 504, - "type" : "VEC3" - }, - { - "bufferView" : 738, - "componentType" : 5126, - "count" : 504, - "type" : "VEC2" - }, - { - "bufferView" : 739, - "componentType" : 5123, - "count" : 786, - "type" : "SCALAR" - }, - { - "bufferView" : 740, - "componentType" : 5126, - "count" : 317, - "max" : [ - 5.031985759735107, - 8.494707107543945, - -2.5038669109344482 - ], - "min" : [ - 4.825387954711914, - 8.288107872009277, - -2.5778377056121826 - ], - "type" : "VEC3" - }, - { - "bufferView" : 741, - "componentType" : 5126, - "count" : 317, - "type" : "VEC3" - }, - { - "bufferView" : 742, - "componentType" : 5126, - "count" : 317, - "type" : "VEC2" - }, - { - "bufferView" : 743, - "componentType" : 5123, - "count" : 1368, - "type" : "SCALAR" - }, - { - "bufferView" : 744, - "componentType" : 5126, - "count" : 317, - "max" : [ - 1.3211430311203003, - 8.494707107543945, - -2.5038669109344482 - ], - "min" : [ - 1.1145449876785278, - 8.288107872009277, - -2.5778377056121826 - ], - "type" : "VEC3" - }, - { - "bufferView" : 745, - "componentType" : 5126, - "count" : 317, - "type" : "VEC3" - }, - { - "bufferView" : 746, - "componentType" : 5126, - "count" : 317, - "type" : "VEC2" - }, - { - "bufferView" : 747, - "componentType" : 5123, - "count" : 1368, - "type" : "SCALAR" - }, - { - "bufferView" : 748, - "componentType" : 5126, - "count" : 183, - "max" : [ - 1.2587089538574219, - 8.861390113830566, - -0.7923719882965088 - ], - "min" : [ - 1.1814138889312744, - 8.316546440124512, - -2.708303689956665 - ], - "type" : "VEC3" - }, - { - "bufferView" : 749, - "componentType" : 5126, - "count" : 183, - "type" : "VEC3" - }, - { - "bufferView" : 750, - "componentType" : 5126, - "count" : 183, - "type" : "VEC2" - }, - { - "bufferView" : 751, - "componentType" : 5123, - "count" : 678, - "type" : "SCALAR" - }, - { - "bufferView" : 752, - "componentType" : 5126, - "count" : 317, - "max" : [ - -2.3765547275543213, - 8.494707107543945, - -2.5038669109344482 - ], - "min" : [ - -2.583153009414673, - 8.288107872009277, - -2.5778377056121826 - ], - "type" : "VEC3" - }, - { - "bufferView" : 753, - "componentType" : 5126, - "count" : 317, - "type" : "VEC3" - }, - { - "bufferView" : 754, - "componentType" : 5126, - "count" : 317, - "type" : "VEC2" - }, - { - "bufferView" : 755, - "componentType" : 5123, - "count" : 1368, - "type" : "SCALAR" - }, - { - "bufferView" : 756, - "componentType" : 5126, - "count" : 183, - "max" : [ - -2.4389889240264893, - 8.861390113830566, - -0.7923719882965088 - ], - "min" : [ - -2.5162837505340576, - 8.316546440124512, - -2.708303689956665 - ], - "type" : "VEC3" - }, - { - "bufferView" : 757, - "componentType" : 5126, - "count" : 183, - "type" : "VEC3" - }, - { - "bufferView" : 758, - "componentType" : 5126, - "count" : 183, - "type" : "VEC2" - }, - { - "bufferView" : 759, - "componentType" : 5126, - "count" : 317, - "max" : [ - -6.079936981201172, - 8.494707107543945, - -2.5038669109344482 - ], - "min" : [ - -6.286535739898682, - 8.288107872009277, - -2.5778377056121826 - ], - "type" : "VEC3" - }, - { - "bufferView" : 760, - "componentType" : 5126, - "count" : 317, - "type" : "VEC3" - }, - { - "bufferView" : 761, - "componentType" : 5126, - "count" : 317, - "type" : "VEC2" - }, - { - "bufferView" : 762, - "componentType" : 5123, - "count" : 1368, - "type" : "SCALAR" - }, - { - "bufferView" : 763, - "componentType" : 5126, - "count" : 183, - "max" : [ - -6.142370700836182, - 8.861390113830566, - -0.7923719882965088 - ], - "min" : [ - -6.219666004180908, - 8.316546440124512, - -2.708303689956665 - ], - "type" : "VEC3" - }, - { - "bufferView" : 764, - "componentType" : 5126, - "count" : 183, - "type" : "VEC3" - }, - { - "bufferView" : 765, - "componentType" : 5126, - "count" : 183, - "type" : "VEC2" - }, - { - "bufferView" : 766, - "componentType" : 5126, - "count" : 183, - "max" : [ - 4.969552040100098, - 8.861390113830566, - 1.9939069747924805 - ], - "min" : [ - 4.892256736755371, - 8.316546440124512, - 0.07797599583864212 - ], - "type" : "VEC3" - }, - { - "bufferView" : 767, - "componentType" : 5126, - "count" : 183, - "type" : "VEC3" - }, - { - "bufferView" : 768, - "componentType" : 5126, - "count" : 183, - "type" : "VEC2" - }, - { - "bufferView" : 769, - "componentType" : 5123, - "count" : 678, - "type" : "SCALAR" - }, - { - "bufferView" : 770, - "componentType" : 5126, - "count" : 317, - "max" : [ - 5.031985759735107, - 8.494707107543945, - 1.863441824913025 - ], - "min" : [ - 4.825387954711914, - 8.288107872009277, - 1.789470911026001 - ], - "type" : "VEC3" - }, - { - "bufferView" : 771, - "componentType" : 5126, - "count" : 317, - "type" : "VEC3" - }, - { - "bufferView" : 772, - "componentType" : 5126, - "count" : 317, - "type" : "VEC2" - }, - { - "bufferView" : 773, - "componentType" : 5123, - "count" : 1368, - "type" : "SCALAR" - }, - { - "bufferView" : 774, - "componentType" : 5126, - "count" : 317, - "max" : [ - 1.3211430311203003, - 8.494707107543945, - 1.863441824913025 - ], - "min" : [ - 1.1145449876785278, - 8.288107872009277, - 1.789470911026001 - ], - "type" : "VEC3" - }, - { - "bufferView" : 775, - "componentType" : 5126, - "count" : 317, - "type" : "VEC3" - }, - { - "bufferView" : 776, - "componentType" : 5126, - "count" : 317, - "type" : "VEC2" - }, - { - "bufferView" : 777, - "componentType" : 5123, - "count" : 1368, - "type" : "SCALAR" - }, - { - "bufferView" : 778, - "componentType" : 5126, - "count" : 710, - "max" : [ - 9.17502498626709, - 6.953227519989014, - 2.4335010051727295 - ], - "min" : [ - 8.193110466003418, - 5.07139778137207, - 1.4515849351882935 - ], - "type" : "VEC3" - }, - { - "bufferView" : 779, - "componentType" : 5126, - "count" : 710, - "type" : "VEC3" - }, - { - "bufferView" : 780, - "componentType" : 5126, - "count" : 710, - "type" : "VEC2" - }, - { - "bufferView" : 781, - "componentType" : 5123, - "count" : 1188, - "type" : "SCALAR" - }, - { - "bufferView" : 782, - "componentType" : 5126, - "count" : 183, - "max" : [ - 1.2587089538574219, - 8.861390113830566, - 1.9939069747924805 - ], - "min" : [ - 1.1814138889312744, - 8.316546440124512, - 0.07797599583864212 - ], - "type" : "VEC3" - }, - { - "bufferView" : 783, - "componentType" : 5126, - "count" : 183, - "type" : "VEC3" - }, - { - "bufferView" : 784, - "componentType" : 5126, - "count" : 183, - "type" : "VEC2" - }, - { - "bufferView" : 785, - "componentType" : 5123, - "count" : 678, - "type" : "SCALAR" - }, - { - "bufferView" : 786, - "componentType" : 5126, - "count" : 317, - "max" : [ - -2.3765547275543213, - 8.494707107543945, - 1.863441824913025 - ], - "min" : [ - -2.583153009414673, - 8.288107872009277, - 1.789470911026001 - ], - "type" : "VEC3" - }, - { - "bufferView" : 787, - "componentType" : 5126, - "count" : 317, - "type" : "VEC3" - }, - { - "bufferView" : 788, - "componentType" : 5126, - "count" : 317, - "type" : "VEC2" - }, - { - "bufferView" : 789, - "componentType" : 5123, - "count" : 1368, - "type" : "SCALAR" - }, - { - "bufferView" : 790, - "componentType" : 5126, - "count" : 183, - "max" : [ - -2.4389889240264893, - 8.861390113830566, - 1.9939069747924805 - ], - "min" : [ - -2.5162837505340576, - 8.316546440124512, - 0.07797599583864212 - ], - "type" : "VEC3" - }, - { - "bufferView" : 791, - "componentType" : 5126, - "count" : 183, - "type" : "VEC3" - }, - { - "bufferView" : 792, - "componentType" : 5126, - "count" : 183, - "type" : "VEC2" - }, - { - "bufferView" : 793, - "componentType" : 5126, - "count" : 317, - "max" : [ - -6.079936981201172, - 8.494707107543945, - 1.863441824913025 - ], - "min" : [ - -6.286535739898682, - 8.288107872009277, - 1.789470911026001 - ], - "type" : "VEC3" - }, - { - "bufferView" : 794, - "componentType" : 5126, - "count" : 317, - "type" : "VEC3" - }, - { - "bufferView" : 795, - "componentType" : 5126, - "count" : 317, - "type" : "VEC2" - }, - { - "bufferView" : 796, - "componentType" : 5123, - "count" : 1368, - "type" : "SCALAR" - }, - { - "bufferView" : 797, - "componentType" : 5126, - "count" : 183, - "max" : [ - -6.142370700836182, - 8.861390113830566, - 1.9939069747924805 - ], - "min" : [ - -6.219666004180908, - 8.316546440124512, - 0.07797599583864212 - ], - "type" : "VEC3" - }, - { - "bufferView" : 798, - "componentType" : 5126, - "count" : 183, - "type" : "VEC3" - }, - { - "bufferView" : 799, - "componentType" : 5126, - "count" : 183, - "type" : "VEC2" - }, - { - "bufferView" : 800, - "componentType" : 5126, - "count" : 4779, - "max" : [ - -1.8786509037017822, - 2.109433889389038, - 2.575565814971924 - ], - "min" : [ - -3.069924831390381, - -0.2804959714412689, - 1.5774189233779907 - ], - "type" : "VEC3" - }, - { - "bufferView" : 801, - "componentType" : 5126, - "count" : 4779, - "type" : "VEC3" - }, - { - "bufferView" : 802, - "componentType" : 5126, - "count" : 4779, - "type" : "VEC2" - }, - { - "bufferView" : 803, - "componentType" : 5123, - "count" : 17790, - "type" : "SCALAR" - }, - { - "bufferView" : 804, - "componentType" : 5126, - "count" : 3582, - "max" : [ - -5.479694843292236, - 2.2271640300750732, - 2.6644227504730225 - ], - "min" : [ - -6.80264139175415, - -0.2804959714412689, - 0.9150129556655884 - ], - "type" : "VEC3" - }, - { - "bufferView" : 805, - "componentType" : 5126, - "count" : 3582, - "type" : "VEC3" - }, - { - "bufferView" : 806, - "componentType" : 5126, - "count" : 3582, - "type" : "VEC2" - }, - { - "bufferView" : 807, - "componentType" : 5123, - "count" : 14466, - "type" : "SCALAR" - }, - { - "bufferView" : 808, - "componentType" : 5126, - "count" : 1581, - "max" : [ - -5.879343509674072, - 2.2271640300750732, - -2.4465978145599365 - ], - "min" : [ - -6.5320024490356445, - 1.2353029251098633, - -2.994365692138672 - ], - "type" : "VEC3" - }, - { - "bufferView" : 809, - "componentType" : 5126, - "count" : 1581, - "type" : "VEC3" - }, - { - "bufferView" : 810, - "componentType" : 5126, - "count" : 1581, - "type" : "VEC2" - }, - { - "bufferView" : 811, - "componentType" : 5123, - "count" : 6612, - "type" : "SCALAR" - }, - { - "bufferView" : 812, - "componentType" : 5126, - "count" : 3271, - "max" : [ - -1.977104902267456, - 2.109433889389038, - -2.2876830101013184 - ], - "min" : [ - -2.9012837409973145, - 0.967354953289032, - -3.2036449909210205 - ], - "type" : "VEC3" - }, - { - "bufferView" : 813, - "componentType" : 5126, - "count" : 3271, - "type" : "VEC3" - }, - { - "bufferView" : 814, - "componentType" : 5126, - "count" : 3271, - "type" : "VEC2" - }, - { - "bufferView" : 815, - "componentType" : 5123, - "count" : 11406, - "type" : "SCALAR" - }, - { - "bufferView" : 816, - "componentType" : 5126, - "count" : 2317, - "max" : [ - 1.766826868057251, - 2.251020908355713, - -2.1428709030151367 - ], - "min" : [ - 0.5852649807929993, - 1.099242925643921, - -3.3337008953094482 - ], - "type" : "VEC3" - }, - { - "bufferView" : 817, - "componentType" : 5126, - "count" : 2317, - "type" : "VEC3" - }, - { - "bufferView" : 818, - "componentType" : 5126, - "count" : 2317, - "type" : "VEC2" - }, - { - "bufferView" : 819, - "componentType" : 5123, - "count" : 9924, - "type" : "SCALAR" - }, - { - "bufferView" : 820, - "componentType" : 5126, - "count" : 697, - "max" : [ - -9.481002807617188, - 6.953227519989014, - -2.172560930252075 - ], - "min" : [ - -10.462919235229492, - 5.07139778137207, - -3.1544759273529053 - ], - "type" : "VEC3" - }, - { - "bufferView" : 821, - "componentType" : 5126, - "count" : 697, - "type" : "VEC3" - }, - { - "bufferView" : 822, - "componentType" : 5126, - "count" : 697, - "type" : "VEC2" - }, - { - "bufferView" : 823, - "componentType" : 5123, - "count" : 1188, - "type" : "SCALAR" - }, - { - "bufferView" : 824, - "componentType" : 5126, - "count" : 3132, - "max" : [ - 5.512263774871826, - 2.2271640300750732, - -2.1969778537750244 - ], - "min" : [ - 4.287768840789795, - -0.2804959714412689, - -3.4113619327545166 - ], - "type" : "VEC3" - }, - { - "bufferView" : 825, - "componentType" : 5126, - "count" : 3132, - "type" : "VEC3" - }, - { - "bufferView" : 826, - "componentType" : 5126, - "count" : 3132, - "type" : "VEC2" - }, - { - "bufferView" : 827, - "componentType" : 5123, - "count" : 13266, - "type" : "SCALAR" - }, - { - "bufferView" : 828, - "componentType" : 5126, - "count" : 2317, - "max" : [ - 1.7573429346084595, - 2.251020908355713, - 2.5378167629241943 - ], - "min" : [ - 0.6240909695625305, - 1.099242925643921, - 1.445435881614685 - ], - "type" : "VEC3" - }, - { - "bufferView" : 829, - "componentType" : 5126, - "count" : 2317, - "type" : "VEC3" - }, - { - "bufferView" : 830, - "componentType" : 5126, - "count" : 2317, - "type" : "VEC2" - }, - { - "bufferView" : 831, - "componentType" : 5123, - "count" : 9924, - "type" : "SCALAR" - }, - { - "bufferView" : 832, - "componentType" : 5126, - "count" : 3949, - "max" : [ - -4.538620948791504, - 5.205938816070557, - 2.522857904434204 - ], - "min" : [ - -7.837941646575928, - 3.394430160522461, - 1.5716428756713867 - ], - "type" : "VEC3" - }, - { - "bufferView" : 833, - "componentType" : 5126, - "count" : 3949, - "type" : "VEC3" - }, - { - "bufferView" : 834, - "componentType" : 5126, - "count" : 3949, - "type" : "VEC2" - }, - { - "bufferView" : 835, - "componentType" : 5123, - "count" : 16512, - "type" : "SCALAR" - }, - { - "bufferView" : 836, - "componentType" : 5126, - "count" : 3929, - "max" : [ - -0.8525600433349609, - 5.205938816070557, - 2.5228569507598877 - ], - "min" : [ - -4.151880264282227, - 3.394430160522461, - 1.5716419219970703 - ], - "type" : "VEC3" - }, - { - "bufferView" : 837, - "componentType" : 5126, - "count" : 3929, - "type" : "VEC3" - }, - { - "bufferView" : 838, - "componentType" : 5126, - "count" : 3929, - "type" : "VEC2" - }, - { - "bufferView" : 839, - "componentType" : 5123, - "count" : 16512, - "type" : "SCALAR" - }, - { - "bufferView" : 840, - "componentType" : 5126, - "count" : 3944, - "max" : [ - 2.8335018157958984, - 5.205938816070557, - 2.5228559970855713 - ], - "min" : [ - -0.46581897139549255, - 3.394430160522461, - 1.5716419219970703 - ], - "type" : "VEC3" - }, - { - "bufferView" : 841, - "componentType" : 5126, - "count" : 3944, - "type" : "VEC3" - }, - { - "bufferView" : 842, - "componentType" : 5126, - "count" : 3944, - "type" : "VEC2" - }, - { - "bufferView" : 843, - "componentType" : 5123, - "count" : 16512, - "type" : "SCALAR" - }, - { - "bufferView" : 844, - "componentType" : 5126, - "count" : 3944, - "max" : [ - 6.519561767578125, - 5.205938816070557, - 2.5228559970855713 - ], - "min" : [ - 3.2202420234680176, - 3.394430160522461, - 1.5716408491134644 - ], - "type" : "VEC3" - }, - { - "bufferView" : 845, - "componentType" : 5126, - "count" : 3944, - "type" : "VEC3" - }, - { - "bufferView" : 846, - "componentType" : 5126, - "count" : 3944, - "type" : "VEC2" - }, - { - "bufferView" : 847, - "componentType" : 5123, - "count" : 16512, - "type" : "SCALAR" - }, - { - "bufferView" : 848, - "componentType" : 5126, - "count" : 3948, - "max" : [ - 6.488516807556152, - 5.205938816070557, - -2.2940480709075928 - ], - "min" : [ - 3.189196825027466, - 3.394430160522461, - -3.2452616691589355 - ], - "type" : "VEC3" - }, - { - "bufferView" : 849, - "componentType" : 5126, - "count" : 3948, - "type" : "VEC3" - }, - { - "bufferView" : 850, - "componentType" : 5126, - "count" : 3948, - "type" : "VEC2" - }, - { - "bufferView" : 851, - "componentType" : 5123, - "count" : 16512, - "type" : "SCALAR" - }, - { - "bufferView" : 852, - "componentType" : 5126, - "count" : 3946, - "max" : [ - 2.8024559020996094, - 5.205938816070557, - -2.2940480709075928 - ], - "min" : [ - -0.4968639612197876, - 3.394430160522461, - -3.2452616691589355 - ], - "type" : "VEC3" - }, - { - "bufferView" : 853, - "componentType" : 5126, - "count" : 3946, - "type" : "VEC3" - }, - { - "bufferView" : 854, - "componentType" : 5126, - "count" : 3946, - "type" : "VEC2" - }, - { - "bufferView" : 855, - "componentType" : 5123, - "count" : 16512, - "type" : "SCALAR" - }, - { - "bufferView" : 856, - "componentType" : 5126, - "count" : 3943, - "max" : [ - -0.8836049437522888, - 5.205938816070557, - -2.2940480709075928 - ], - "min" : [ - -4.182925701141357, - 3.394430160522461, - -3.2452616691589355 - ], - "type" : "VEC3" - }, - { - "bufferView" : 857, - "componentType" : 5126, - "count" : 3943, - "type" : "VEC3" - }, - { - "bufferView" : 858, - "componentType" : 5126, - "count" : 3943, - "type" : "VEC2" - }, - { - "bufferView" : 859, - "componentType" : 5123, - "count" : 16512, - "type" : "SCALAR" - }, - { - "bufferView" : 860, - "componentType" : 5126, - "count" : 3963, - "max" : [ - -4.569665908813477, - 5.205938816070557, - -2.2940480709075928 - ], - "min" : [ - -7.8689866065979, - 3.394430160522461, - -3.2452616691589355 - ], - "type" : "VEC3" - }, - { - "bufferView" : 861, - "componentType" : 5126, - "count" : 3963, - "type" : "VEC3" - }, - { - "bufferView" : 862, - "componentType" : 5126, - "count" : 3963, - "type" : "VEC2" - }, - { - "bufferView" : 863, - "componentType" : 5123, - "count" : 16512, - "type" : "SCALAR" - }, - { - "bufferView" : 864, - "componentType" : 5126, - "count" : 499, - "max" : [ - -5.810407638549805, - 6.953227519989014, - -2.408857822418213 - ], - "min" : [ - -6.556130409240723, - 5.07139778137207, - -3.1544759273529053 - ], - "type" : "VEC3" - }, - { - "bufferView" : 865, - "componentType" : 5126, - "count" : 499, - "type" : "VEC3" - }, - { - "bufferView" : 866, - "componentType" : 5126, - "count" : 499, - "type" : "VEC2" - }, - { - "bufferView" : 867, - "componentType" : 5123, - "count" : 786, - "type" : "SCALAR" - }, - { - "bufferView" : 868, - "componentType" : 5126, - "count" : 317, - "max" : [ - -2.862592935562134, - 2.9411401748657227, - -2.690436840057373 - ], - "min" : [ - -2.990330696105957, - 2.749595880508423, - -2.897035837173462 - ], - "type" : "VEC3" - }, - { - "bufferView" : 869, - "componentType" : 5126, - "count" : 317, - "type" : "VEC3" - }, - { - "bufferView" : 870, - "componentType" : 5126, - "count" : 317, - "type" : "VEC2" - }, - { - "bufferView" : 871, - "componentType" : 5123, - "count" : 1368, - "type" : "SCALAR" - }, - { - "bufferView" : 872, - "componentType" : 5126, - "count" : 197, - "max" : [ - -2.7900869846343994, - 2.8438568115234375, - -2.7689967155456543 - ], - "min" : [ - -5.888857841491699, - 2.798811912536621, - -2.814042091369629 - ], - "type" : "VEC3" - }, - { - "bufferView" : 873, - "componentType" : 5126, - "count" : 197, - "type" : "VEC3" - }, - { - "bufferView" : 874, - "componentType" : 5126, - "count" : 197, - "type" : "VEC2" - }, - { - "bufferView" : 875, - "componentType" : 5123, - "count" : 576, - "type" : "SCALAR" - }, - { - "bufferView" : 876, - "componentType" : 5126, - "count" : 317, - "max" : [ - -5.688612461090088, - 2.9411401748657227, - -2.690436840057373 - ], - "min" : [ - -5.81635046005249, - 2.749595880508423, - -2.897035837173462 - ], - "type" : "VEC3" - }, - { - "bufferView" : 877, - "componentType" : 5126, - "count" : 317, - "type" : "VEC3" - }, - { - "bufferView" : 878, - "componentType" : 5126, - "count" : 317, - "type" : "VEC2" - }, - { - "bufferView" : 879, - "componentType" : 5123, - "count" : 1368, - "type" : "SCALAR" - }, - { - "bufferView" : 880, - "componentType" : 5126, - "count" : 317, - "max" : [ - 0.8522909283638, - 2.9411401748657227, - -2.690436840057373 - ], - "min" : [ - 0.7245529890060425, - 2.749595880508423, - -2.897035837173462 - ], - "type" : "VEC3" - }, - { - "bufferView" : 881, - "componentType" : 5126, - "count" : 317, - "type" : "VEC3" - }, - { - "bufferView" : 882, - "componentType" : 5126, - "count" : 317, - "type" : "VEC2" - }, - { - "bufferView" : 883, - "componentType" : 5123, - "count" : 1368, - "type" : "SCALAR" - }, - { - "bufferView" : 884, - "componentType" : 5126, - "count" : 197, - "max" : [ - 0.9247969388961792, - 2.8438568115234375, - -2.7689967155456543 - ], - "min" : [ - -2.17397403717041, - 2.798811912536621, - -2.814042091369629 - ], - "type" : "VEC3" - }, - { - "bufferView" : 885, - "componentType" : 5126, - "count" : 197, - "type" : "VEC3" - }, - { - "bufferView" : 886, - "componentType" : 5126, - "count" : 197, - "type" : "VEC2" - }, - { - "bufferView" : 887, - "componentType" : 5126, - "count" : 317, - "max" : [ - -1.973728895187378, - 2.9411401748657227, - -2.690436840057373 - ], - "min" : [ - -2.1014668941497803, - 2.749595880508423, - -2.897035837173462 - ], - "type" : "VEC3" - }, - { - "bufferView" : 888, - "componentType" : 5126, - "count" : 317, - "type" : "VEC3" - }, - { - "bufferView" : 889, - "componentType" : 5126, - "count" : 317, - "type" : "VEC2" - }, - { - "bufferView" : 890, - "componentType" : 5123, - "count" : 1368, - "type" : "SCALAR" - }, - { - "bufferView" : 891, - "componentType" : 5126, - "count" : 317, - "max" : [ - 4.551491737365723, - 2.9411401748657227, - -2.690436840057373 - ], - "min" : [ - 4.42375373840332, - 2.749595880508423, - -2.897035837173462 - ], - "type" : "VEC3" - }, - { - "bufferView" : 892, - "componentType" : 5126, - "count" : 317, - "type" : "VEC3" - }, - { - "bufferView" : 893, - "componentType" : 5126, - "count" : 317, - "type" : "VEC2" - }, - { - "bufferView" : 894, - "componentType" : 5123, - "count" : 1368, - "type" : "SCALAR" - }, - { - "bufferView" : 895, - "componentType" : 5126, - "count" : 197, - "max" : [ - 4.623999118804932, - 2.8438568115234375, - -2.7689967155456543 - ], - "min" : [ - 1.5252279043197632, - 2.798811912536621, - -2.814042091369629 - ], - "type" : "VEC3" - }, - { - "bufferView" : 896, - "componentType" : 5126, - "count" : 197, - "type" : "VEC3" - }, - { - "bufferView" : 897, - "componentType" : 5126, - "count" : 197, - "type" : "VEC2" - }, - { - "bufferView" : 898, - "componentType" : 5123, - "count" : 576, - "type" : "SCALAR" - }, - { - "bufferView" : 899, - "componentType" : 5126, - "count" : 317, - "max" : [ - 1.7254719734191895, - 2.9411401748657227, - -2.690436840057373 - ], - "min" : [ - 1.5977338552474976, - 2.749595880508423, - -2.897035837173462 - ], - "type" : "VEC3" - }, - { - "bufferView" : 900, - "componentType" : 5126, - "count" : 317, - "type" : "VEC3" - }, - { - "bufferView" : 901, - "componentType" : 5126, - "count" : 317, - "type" : "VEC2" - }, - { - "bufferView" : 902, - "componentType" : 5126, - "count" : 317, - "max" : [ - 8.230432510375977, - 2.9411401748657227, - -2.690436840057373 - ], - "min" : [ - 8.102693557739258, - 2.749595880508423, - -2.897035837173462 - ], - "type" : "VEC3" - }, - { - "bufferView" : 903, - "componentType" : 5126, - "count" : 317, - "type" : "VEC3" - }, - { - "bufferView" : 904, - "componentType" : 5126, - "count" : 317, - "type" : "VEC2" - }, - { - "bufferView" : 905, - "componentType" : 5123, - "count" : 1368, - "type" : "SCALAR" - }, - { - "bufferView" : 906, - "componentType" : 5126, - "count" : 503, - "max" : [ - -2.1150100231170654, - 6.953227519989014, - -2.408857822418213 - ], - "min" : [ - -2.860734701156616, - 5.07139778137207, - -3.1544759273529053 - ], - "type" : "VEC3" - }, - { - "bufferView" : 907, - "componentType" : 5126, - "count" : 503, - "type" : "VEC3" - }, - { - "bufferView" : 908, - "componentType" : 5126, - "count" : 503, - "type" : "VEC2" - }, - { - "bufferView" : 909, - "componentType" : 5123, - "count" : 786, - "type" : "SCALAR" - }, - { - "bufferView" : 910, - "componentType" : 5126, - "count" : 197, - "max" : [ - 8.302938461303711, - 2.8438568115234375, - -2.7689967155456543 - ], - "min" : [ - 5.20416784286499, - 2.798811912536621, - -2.814042091369629 - ], - "type" : "VEC3" - }, - { - "bufferView" : 911, - "componentType" : 5126, - "count" : 197, - "type" : "VEC3" - }, - { - "bufferView" : 912, - "componentType" : 5126, - "count" : 197, - "type" : "VEC2" - }, - { - "bufferView" : 913, - "componentType" : 5126, - "count" : 317, - "max" : [ - 5.404412746429443, - 2.9411401748657227, - -2.690436840057373 - ], - "min" : [ - 5.276674747467041, - 2.749595880508423, - -2.897035837173462 - ], - "type" : "VEC3" - }, - { - "bufferView" : 914, - "componentType" : 5126, - "count" : 317, - "type" : "VEC3" - }, - { - "bufferView" : 915, - "componentType" : 5126, - "count" : 317, - "type" : "VEC2" - }, - { - "bufferView" : 916, - "componentType" : 5126, - "count" : 317, - "max" : [ - -6.560713768005371, - 2.9411401748657227, - -2.690436840057373 - ], - "min" : [ - -6.688451290130615, - 2.749595880508423, - -2.897035837173462 - ], - "type" : "VEC3" - }, - { - "bufferView" : 917, - "componentType" : 5126, - "count" : 317, - "type" : "VEC3" - }, - { - "bufferView" : 918, - "componentType" : 5126, - "count" : 317, - "type" : "VEC2" - }, - { - "bufferView" : 919, - "componentType" : 5123, - "count" : 1368, - "type" : "SCALAR" - }, - { - "bufferView" : 920, - "componentType" : 5126, - "count" : 197, - "max" : [ - -6.48820686340332, - 2.8438568115234375, - -2.7689967155456543 - ], - "min" : [ - -9.586977005004883, - 2.798811912536621, - -2.814042091369629 - ], - "type" : "VEC3" - }, - { - "bufferView" : 921, - "componentType" : 5126, - "count" : 197, - "type" : "VEC3" - }, - { - "bufferView" : 922, - "componentType" : 5126, - "count" : 197, - "type" : "VEC2" - }, - { - "bufferView" : 923, - "componentType" : 5126, - "count" : 317, - "max" : [ - -9.38673210144043, - 2.9411401748657227, - -2.690436840057373 - ], - "min" : [ - -9.514471054077148, - 2.749595880508423, - -2.897035837173462 - ], - "type" : "VEC3" - }, - { - "bufferView" : 924, - "componentType" : 5126, - "count" : 317, - "type" : "VEC3" - }, - { - "bufferView" : 925, - "componentType" : 5126, - "count" : 317, - "type" : "VEC2" - }, - { - "bufferView" : 926, - "componentType" : 5126, - "count" : 317, - "max" : [ - -2.862592935562134, - 2.9411401748657227, - 2.0911500453948975 - ], - "min" : [ - -2.990330696105957, - 2.749595880508423, - 1.884550929069519 - ], - "type" : "VEC3" - }, - { - "bufferView" : 927, - "componentType" : 5126, - "count" : 317, - "type" : "VEC3" - }, - { - "bufferView" : 928, - "componentType" : 5126, - "count" : 317, - "type" : "VEC2" - }, - { - "bufferView" : 929, - "componentType" : 5126, - "count" : 197, - "max" : [ - -2.7900869846343994, - 2.8438568115234375, - 2.012589931488037 - ], - "min" : [ - -5.888857841491699, - 2.798811912536621, - 1.9675449132919312 - ], - "type" : "VEC3" - }, - { - "bufferView" : 930, - "componentType" : 5126, - "count" : 197, - "type" : "VEC3" - }, - { - "bufferView" : 931, - "componentType" : 5126, - "count" : 197, - "type" : "VEC2" - }, - { - "bufferView" : 932, - "componentType" : 5126, - "count" : 317, - "max" : [ - -5.688612461090088, - 2.9411401748657227, - 2.0911500453948975 - ], - "min" : [ - -5.81635046005249, - 2.749595880508423, - 1.884550929069519 - ], - "type" : "VEC3" - }, - { - "bufferView" : 933, - "componentType" : 5126, - "count" : 317, - "type" : "VEC3" - }, - { - "bufferView" : 934, - "componentType" : 5126, - "count" : 317, - "type" : "VEC2" - }, - { - "bufferView" : 935, - "componentType" : 5126, - "count" : 317, - "max" : [ - -6.560713768005371, - 2.9411401748657227, - 2.0911500453948975 - ], - "min" : [ - -6.688451290130615, - 2.749595880508423, - 1.884550929069519 - ], - "type" : "VEC3" - }, - { - "bufferView" : 936, - "componentType" : 5126, - "count" : 317, - "type" : "VEC3" - }, - { - "bufferView" : 937, - "componentType" : 5126, - "count" : 317, - "type" : "VEC2" - }, - { - "bufferView" : 938, - "componentType" : 5126, - "count" : 197, - "max" : [ - -6.48820686340332, - 2.8438568115234375, - 2.012589931488037 - ], - "min" : [ - -9.586977005004883, - 2.798811912536621, - 1.9675449132919312 - ], - "type" : "VEC3" - }, - { - "bufferView" : 939, - "componentType" : 5126, - "count" : 197, - "type" : "VEC3" - }, - { - "bufferView" : 940, - "componentType" : 5126, - "count" : 197, - "type" : "VEC2" - }, - { - "bufferView" : 941, - "componentType" : 5126, - "count" : 488, - "max" : [ - 1.5723389387130737, - 6.953227519989014, - -2.408857822418213 - ], - "min" : [ - 0.8266169428825378, - 5.07139778137207, - -3.1544759273529053 - ], - "type" : "VEC3" - }, - { - "bufferView" : 942, - "componentType" : 5126, - "count" : 488, - "type" : "VEC3" - }, - { - "bufferView" : 943, - "componentType" : 5126, - "count" : 488, - "type" : "VEC2" - }, - { - "bufferView" : 944, - "componentType" : 5123, - "count" : 786, - "type" : "SCALAR" - }, - { - "bufferView" : 945, - "componentType" : 5126, - "count" : 317, - "max" : [ - -9.38673210144043, - 2.9411401748657227, - 2.0911500453948975 - ], - "min" : [ - -9.514471054077148, - 2.749595880508423, - 1.884550929069519 - ], - "type" : "VEC3" - }, - { - "bufferView" : 946, - "componentType" : 5126, - "count" : 317, - "type" : "VEC3" - }, - { - "bufferView" : 947, - "componentType" : 5126, - "count" : 317, - "type" : "VEC2" - }, - { - "bufferView" : 948, - "componentType" : 5126, - "count" : 317, - "max" : [ - 0.8522909283638, - 2.9411401748657227, - 2.0911500453948975 - ], - "min" : [ - 0.7245529890060425, - 2.749595880508423, - 1.884550929069519 - ], - "type" : "VEC3" - }, - { - "bufferView" : 949, - "componentType" : 5126, - "count" : 317, - "type" : "VEC3" - }, - { - "bufferView" : 950, - "componentType" : 5126, - "count" : 317, - "type" : "VEC2" - }, - { - "bufferView" : 951, - "componentType" : 5126, - "count" : 197, - "max" : [ - 0.9247969388961792, - 2.8438568115234375, - 2.012589931488037 - ], - "min" : [ - -2.17397403717041, - 2.798811912536621, - 1.9675449132919312 - ], - "type" : "VEC3" - }, - { - "bufferView" : 952, - "componentType" : 5126, - "count" : 197, - "type" : "VEC3" - }, - { - "bufferView" : 953, - "componentType" : 5126, - "count" : 197, - "type" : "VEC2" - }, - { - "bufferView" : 954, - "componentType" : 5126, - "count" : 317, - "max" : [ - -1.973728895187378, - 2.9411401748657227, - 2.0911500453948975 - ], - "min" : [ - -2.1014668941497803, - 2.749595880508423, - 1.884550929069519 - ], - "type" : "VEC3" - }, - { - "bufferView" : 955, - "componentType" : 5126, - "count" : 317, - "type" : "VEC3" - }, - { - "bufferView" : 956, - "componentType" : 5126, - "count" : 317, - "type" : "VEC2" - }, - { - "bufferView" : 957, - "componentType" : 5126, - "count" : 317, - "max" : [ - 4.551491737365723, - 2.9411401748657227, - 2.0911500453948975 - ], - "min" : [ - 4.42375373840332, - 2.749595880508423, - 1.884550929069519 - ], - "type" : "VEC3" - }, - { - "bufferView" : 958, - "componentType" : 5126, - "count" : 317, - "type" : "VEC3" - }, - { - "bufferView" : 959, - "componentType" : 5126, - "count" : 317, - "type" : "VEC2" - }, - { - "bufferView" : 960, - "componentType" : 5126, - "count" : 197, - "max" : [ - 4.623999118804932, - 2.8438568115234375, - 2.012589931488037 - ], - "min" : [ - 1.5252279043197632, - 2.798811912536621, - 1.9675449132919312 - ], - "type" : "VEC3" - }, - { - "bufferView" : 961, - "componentType" : 5126, - "count" : 197, - "type" : "VEC3" - }, - { - "bufferView" : 962, - "componentType" : 5126, - "count" : 197, - "type" : "VEC2" - }, - { - "bufferView" : 963, - "componentType" : 5126, - "count" : 317, - "max" : [ - 1.7254719734191895, - 2.9411401748657227, - 2.0911500453948975 - ], - "min" : [ - 1.5977338552474976, - 2.749595880508423, - 1.884550929069519 - ], - "type" : "VEC3" - }, - { - "bufferView" : 964, - "componentType" : 5126, - "count" : 317, - "type" : "VEC3" - }, - { - "bufferView" : 965, - "componentType" : 5126, - "count" : 317, - "type" : "VEC2" - }, - { - "bufferView" : 966, - "componentType" : 5126, - "count" : 317, - "max" : [ - 8.230432510375977, - 2.9411401748657227, - 2.0911500453948975 - ], - "min" : [ - 8.102693557739258, - 2.749595880508423, - 1.884550929069519 - ], - "type" : "VEC3" - }, - { - "bufferView" : 967, - "componentType" : 5126, - "count" : 317, - "type" : "VEC3" - }, - { - "bufferView" : 968, - "componentType" : 5126, - "count" : 317, - "type" : "VEC2" - }, - { - "bufferView" : 969, - "componentType" : 5126, - "count" : 197, - "max" : [ - 8.302938461303711, - 2.8438568115234375, - 2.012589931488037 - ], - "min" : [ - 5.20416784286499, - 2.798811912536621, - 1.9675449132919312 - ], - "type" : "VEC3" - }, - { - "bufferView" : 970, - "componentType" : 5126, - "count" : 197, - "type" : "VEC3" - }, - { - "bufferView" : 971, - "componentType" : 5126, - "count" : 197, - "type" : "VEC2" - }, - { - "bufferView" : 972, - "componentType" : 5126, - "count" : 317, - "max" : [ - 5.404412746429443, - 2.9411401748657227, - 2.0911500453948975 - ], - "min" : [ - 5.276674747467041, - 2.749595880508423, - 1.884550929069519 - ], - "type" : "VEC3" - }, - { - "bufferView" : 973, - "componentType" : 5126, - "count" : 317, - "type" : "VEC3" - }, - { - "bufferView" : 974, - "componentType" : 5126, - "count" : 317, - "type" : "VEC2" - }, - { - "bufferView" : 975, - "componentType" : 5126, - "count" : 495, - "max" : [ - 5.2911810874938965, - 6.953227519989014, - -2.408857822418213 - ], - "min" : [ - 4.54545783996582, - 5.07139778137207, - -3.1544759273529053 - ], - "type" : "VEC3" - }, - { - "bufferView" : 976, - "componentType" : 5126, - "count" : 495, - "type" : "VEC3" - }, - { - "bufferView" : 977, - "componentType" : 5126, - "count" : 495, - "type" : "VEC2" - }, - { - "bufferView" : 978, - "componentType" : 5123, - "count" : 786, - "type" : "SCALAR" - }, - { - "bufferView" : 979, - "componentType" : 5126, - "count" : 2456, - "max" : [ - 0.8235979080200195, - 2.830152750015259, - 2.1348249912261963 - ], - "min" : [ - -2.0493738651275635, - 0.0013050000416114926, - 1.889017939567566 - ], - "type" : "VEC3" - }, - { - "bufferView" : 980, - "componentType" : 5126, - "count" : 2456, - "type" : "VEC3" - }, - { - "bufferView" : 981, - "componentType" : 5126, - "count" : 2456, - "type" : "VEC2" - }, - { - "bufferView" : 982, - "componentType" : 5123, - "count" : 14592, - "type" : "SCALAR" - }, - { - "bufferView" : 983, - "componentType" : 5126, - "count" : 2512, - "max" : [ - -2.9057703018188477, - 2.8368098735809326, - 2.0821239948272705 - ], - "min" : [ - -5.7762017250061035, - -0.003089000005275011, - 1.829042911529541 - ], - "type" : "VEC3" - }, - { - "bufferView" : 984, - "componentType" : 5126, - "count" : 2512, - "type" : "VEC3" - }, - { - "bufferView" : 985, - "componentType" : 5126, - "count" : 2512, - "type" : "VEC2" - }, - { - "bufferView" : 986, - "componentType" : 5123, - "count" : 13824, - "type" : "SCALAR" - }, - { - "bufferView" : 987, - "componentType" : 5126, - "count" : 2456, - "max" : [ - -6.589406490325928, - 2.830152750015259, - 2.1348249912261963 - ], - "min" : [ - -9.46237850189209, - 0.0013050000416114926, - 1.889017939567566 - ], - "type" : "VEC3" - }, - { - "bufferView" : 988, - "componentType" : 5126, - "count" : 2456, - "type" : "VEC3" - }, - { - "bufferView" : 989, - "componentType" : 5126, - "count" : 2456, - "type" : "VEC2" - }, - { - "bufferView" : 990, - "componentType" : 5123, - "count" : 14592, - "type" : "SCALAR" - }, - { - "bufferView" : 991, - "componentType" : 5126, - "count" : 2456, - "max" : [ - -6.589406490325928, - 2.830152750015259, - -2.6467621326446533 - ], - "min" : [ - -9.46237850189209, - 0.0013050000416114926, - -2.892568826675415 - ], - "type" : "VEC3" - }, - { - "bufferView" : 992, - "componentType" : 5126, - "count" : 2456, - "type" : "VEC3" - }, - { - "bufferView" : 993, - "componentType" : 5126, - "count" : 2456, - "type" : "VEC2" - }, - { - "bufferView" : 994, - "componentType" : 5123, - "count" : 14592, - "type" : "SCALAR" - }, - { - "bufferView" : 995, - "componentType" : 5126, - "count" : 2512, - "max" : [ - 4.480337619781494, - 2.8368098735809326, - 2.0821239948272705 - ], - "min" : [ - 1.6099048852920532, - -0.003089000005275011, - 1.829042911529541 - ], - "type" : "VEC3" - }, - { - "bufferView" : 996, - "componentType" : 5126, - "count" : 2512, - "type" : "VEC3" - }, - { - "bufferView" : 997, - "componentType" : 5126, - "count" : 2512, - "type" : "VEC2" - }, - { - "bufferView" : 998, - "componentType" : 5126, - "count" : 2456, - "max" : [ - 8.201740264892578, - 2.830152750015259, - 2.1348249912261963 - ], - "min" : [ - 5.328767776489258, - 0.0013050000416114926, - 1.889017939567566 - ], - "type" : "VEC3" - }, - { - "bufferView" : 999, - "componentType" : 5126, - "count" : 2456, - "type" : "VEC3" - }, - { - "bufferView" : 1000, - "componentType" : 5126, - "count" : 2456, - "type" : "VEC2" - }, - { - "bufferView" : 1001, - "componentType" : 5123, - "count" : 14592, - "type" : "SCALAR" - }, - { - "bufferView" : 1002, - "componentType" : 5126, - "count" : 2512, - "max" : [ - -2.9057703018188477, - 2.8368098735809326, - -2.699462890625 - ], - "min" : [ - -5.7762017250061035, - -0.003089000005275011, - -2.9525439739227295 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1003, - "componentType" : 5126, - "count" : 2512, - "type" : "VEC3" - }, - { - "bufferView" : 1004, - "componentType" : 5126, - "count" : 2512, - "type" : "VEC2" - }, - { - "bufferView" : 1005, - "componentType" : 5126, - "count" : 2456, - "max" : [ - 0.8235979080200195, - 2.830152750015259, - -2.6467621326446533 - ], - "min" : [ - -2.0493738651275635, - 0.0013050000416114926, - -2.892568826675415 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1006, - "componentType" : 5126, - "count" : 2456, - "type" : "VEC3" - }, - { - "bufferView" : 1007, - "componentType" : 5126, - "count" : 2456, - "type" : "VEC2" - }, - { - "bufferView" : 1008, - "componentType" : 5126, - "count" : 2512, - "max" : [ - 4.480337619781494, - 2.8368098735809326, - -2.699462890625 - ], - "min" : [ - 1.6099048852920532, - -0.003089000005275011, - -2.9525439739227295 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1009, - "componentType" : 5126, - "count" : 2512, - "type" : "VEC3" - }, - { - "bufferView" : 1010, - "componentType" : 5126, - "count" : 2512, - "type" : "VEC2" - }, - { - "bufferView" : 1011, - "componentType" : 5126, - "count" : 2456, - "max" : [ - 8.201740264892578, - 2.830152750015259, - -2.6467621326446533 - ], - "min" : [ - 5.328767776489258, - 0.0013050000416114926, - -2.892568826675415 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1012, - "componentType" : 5126, - "count" : 2456, - "type" : "VEC3" - }, - { - "bufferView" : 1013, - "componentType" : 5126, - "count" : 2456, - "type" : "VEC2" - }, - { - "bufferView" : 1014, - "componentType" : 5123, - "count" : 14592, - "type" : "SCALAR" - }, - { - "bufferView" : 1015, - "componentType" : 5126, - "count" : 703, - "max" : [ - 9.17502498626709, - 6.953227519989014, - -2.172560930252075 - ], - "min" : [ - 8.193110466003418, - 5.07139778137207, - -3.1544759273529053 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1016, - "componentType" : 5126, - "count" : 703, - "type" : "VEC3" - }, - { - "bufferView" : 1017, - "componentType" : 5126, - "count" : 703, - "type" : "VEC2" - }, - { - "bufferView" : 1018, - "componentType" : 5123, - "count" : 1188, - "type" : "SCALAR" - }, - { - "bufferView" : 1019, - "componentType" : 5126, - "count" : 4, - "max" : [ - 5.118712425231934, - 2.1369729042053223, - -2.179137945175171 - ], - "min" : [ - 4.871608734130859, - 1.3415701389312744, - -2.214871883392334 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1020, - "componentType" : 5126, - "count" : 4, - "type" : "VEC3" - }, - { - "bufferView" : 1021, - "componentType" : 5126, - "count" : 4, - "type" : "VEC2" - }, - { - "bufferView" : 1022, - "componentType" : 5123, - "count" : 6, - "type" : "SCALAR" - }, - { - "bufferView" : 1023, - "componentType" : 5126, - "count" : 4, - "max" : [ - 4.890719890594482, - 2.1435487270355225, - -2.197005033493042 - ], - "min" : [ - 4.619029998779297, - 1.3375129699707031, - -2.197005033493042 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1024, - "componentType" : 5126, - "count" : 4, - "type" : "VEC3" - }, - { - "bufferView" : 1025, - "componentType" : 5126, - "count" : 4, - "type" : "VEC2" - }, - { - "bufferView" : 1026, - "componentType" : 5123, - "count" : 6, - "type" : "SCALAR" - }, - { - "bufferView" : 1027, - "componentType" : 5126, - "count" : 6, - "max" : [ - 5.133056640625, - 2.1413300037384033, - -2.197005033493042 - ], - "min" : [ - 4.857263565063477, - 1.3372129201889038, - -2.197005033493042 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1028, - "componentType" : 5126, - "count" : 6, - "type" : "VEC3" - }, - { - "bufferView" : 1029, - "componentType" : 5126, - "count" : 6, - "type" : "VEC2" - }, - { - "bufferView" : 1030, - "componentType" : 5123, - "count" : 6, - "type" : "SCALAR" - }, - { - "bufferView" : 1031, - "componentType" : 5126, - "count" : 4, - "max" : [ - 4.886728763580322, - 2.1369469165802, - -2.179137945175171 - ], - "min" : [ - 4.628350257873535, - 1.3441150188446045, - -2.214871883392334 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1032, - "componentType" : 5126, - "count" : 4, - "type" : "VEC3" - }, - { - "bufferView" : 1033, - "componentType" : 5126, - "count" : 4, - "type" : "VEC2" - }, - { - "bufferView" : 1034, - "componentType" : 5126, - "count" : 900, - "max" : [ - 5.128174781799316, - 1.2814610004425049, - -1.943250060081482 - ], - "min" : [ - 4.6200666427612305, - 1.0480189323425293, - -2.450788736343384 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1035, - "componentType" : 5126, - "count" : 900, - "type" : "VEC3" - }, - { - "bufferView" : 1036, - "componentType" : 5126, - "count" : 900, - "type" : "VEC2" - }, - { - "bufferView" : 1037, - "componentType" : 5123, - "count" : 4923, - "type" : "SCALAR" - }, - { - "bufferView" : 1038, - "componentType" : 5126, - "count" : 326, - "max" : [ - 4.907547950744629, - 1.0480189323425293, - -2.1641979217529297 - ], - "min" : [ - 4.840766906738281, - 0.9867289662361145, - -2.230902910232544 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1039, - "componentType" : 5126, - "count" : 326, - "type" : "VEC3" - }, - { - "bufferView" : 1040, - "componentType" : 5126, - "count" : 326, - "type" : "VEC2" - }, - { - "bufferView" : 1041, - "componentType" : 5123, - "count" : 1674, - "type" : "SCALAR" - }, - { - "bufferView" : 1042, - "componentType" : 5126, - "count" : 628, - "max" : [ - 5.2261152267456055, - 1.3718829154968262, - -2.1757559776306152 - ], - "min" : [ - 5.0744147300720215, - 1.1189759969711304, - -2.2182538509368896 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1043, - "componentType" : 5126, - "count" : 628, - "type" : "VEC3" - }, - { - "bufferView" : 1044, - "componentType" : 5126, - "count" : 628, - "type" : "VEC2" - }, - { - "bufferView" : 1045, - "componentType" : 5123, - "count" : 3732, - "type" : "SCALAR" - }, - { - "bufferView" : 1046, - "componentType" : 5126, - "count" : 628, - "max" : [ - 4.678221702575684, - 1.3718829154968262, - -2.1757538318634033 - ], - "min" : [ - 4.526521682739258, - 1.1189759969711304, - -2.218251943588257 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1047, - "componentType" : 5126, - "count" : 628, - "type" : "VEC3" - }, - { - "bufferView" : 1048, - "componentType" : 5126, - "count" : 628, - "type" : "VEC2" - }, - { - "bufferView" : 1049, - "componentType" : 5123, - "count" : 3732, - "type" : "SCALAR" - }, - { - "bufferView" : 1050, - "componentType" : 5126, - "count" : 143, - "max" : [ - 4.89098596572876, - 2.169512987136841, - -2.116008758544922 - ], - "min" : [ - 4.8572540283203125, - 2.0745368003845215, - -2.4683449268341064 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1051, - "componentType" : 5126, - "count" : 143, - "type" : "VEC3" - }, - { - "bufferView" : 1052, - "componentType" : 5126, - "count" : 143, - "type" : "VEC2" - }, - { - "bufferView" : 1053, - "componentType" : 5123, - "count" : 810, - "type" : "SCALAR" - }, - { - "bufferView" : 1054, - "componentType" : 5126, - "count" : 4, - "max" : [ - -5.949647903442383, - 2.1369729042053223, - -2.179137945175171 - ], - "min" : [ - -6.196751594543457, - 1.3415701389312744, - -2.214871883392334 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1055, - "componentType" : 5126, - "count" : 4, - "type" : "VEC3" - }, - { - "bufferView" : 1056, - "componentType" : 5126, - "count" : 4, - "type" : "VEC2" - }, - { - "bufferView" : 1057, - "componentType" : 5126, - "count" : 409, - "max" : [ - 8.686470985412598, - 9.217284202575684, - 1.8596729040145874 - ], - "min" : [ - -10.023640632629395, - 6.9376678466796875, - -2.5932579040527344 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1058, - "componentType" : 5126, - "count" : 409, - "type" : "VEC3" - }, - { - "bufferView" : 1059, - "componentType" : 5126, - "count" : 409, - "type" : "VEC2" - }, - { - "bufferView" : 1060, - "componentType" : 5123, - "count" : 612, - "type" : "SCALAR" - }, - { - "bufferView" : 1061, - "componentType" : 5126, - "count" : 6, - "max" : [ - -6.177640438079834, - 2.1435487270355225, - -2.197005033493042 - ], - "min" : [ - -6.449330806732178, - 1.3375129699707031, - -2.197005033493042 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1062, - "componentType" : 5126, - "count" : 6, - "type" : "VEC3" - }, - { - "bufferView" : 1063, - "componentType" : 5126, - "count" : 6, - "type" : "VEC2" - }, - { - "bufferView" : 1064, - "componentType" : 5123, - "count" : 6, - "type" : "SCALAR" - }, - { - "bufferView" : 1065, - "componentType" : 5126, - "count" : 6, - "max" : [ - -5.935302734375, - 2.1413300037384033, - -2.197005033493042 - ], - "min" : [ - -6.21109676361084, - 1.3372129201889038, - -2.197005033493042 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1066, - "componentType" : 5126, - "count" : 6, - "type" : "VEC3" - }, - { - "bufferView" : 1067, - "componentType" : 5126, - "count" : 6, - "type" : "VEC2" - }, - { - "bufferView" : 1068, - "componentType" : 5123, - "count" : 6, - "type" : "SCALAR" - }, - { - "bufferView" : 1069, - "componentType" : 5126, - "count" : 4, - "max" : [ - -6.181630611419678, - 2.1369469165802, - -2.179137945175171 - ], - "min" : [ - -6.440011024475098, - 1.3441150188446045, - -2.214871883392334 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1070, - "componentType" : 5126, - "count" : 4, - "type" : "VEC3" - }, - { - "bufferView" : 1071, - "componentType" : 5126, - "count" : 4, - "type" : "VEC2" - }, - { - "bufferView" : 1072, - "componentType" : 5126, - "count" : 900, - "max" : [ - -5.940185546875, - 1.2814610004425049, - -1.943250060081482 - ], - "min" : [ - -6.4482927322387695, - 1.0480189323425293, - -2.450788736343384 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1073, - "componentType" : 5126, - "count" : 900, - "type" : "VEC3" - }, - { - "bufferView" : 1074, - "componentType" : 5126, - "count" : 900, - "type" : "VEC2" - }, - { - "bufferView" : 1075, - "componentType" : 5126, - "count" : 326, - "max" : [ - -6.160812854766846, - 1.0480189323425293, - -2.1641979217529297 - ], - "min" : [ - -6.227593898773193, - 0.9867289662361145, - -2.230902910232544 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1076, - "componentType" : 5126, - "count" : 326, - "type" : "VEC3" - }, - { - "bufferView" : 1077, - "componentType" : 5126, - "count" : 326, - "type" : "VEC2" - }, - { - "bufferView" : 1078, - "componentType" : 5126, - "count" : 628, - "max" : [ - -5.842246055603027, - 1.3718829154968262, - -2.1757559776306152 - ], - "min" : [ - -5.9939470291137695, - 1.1189759969711304, - -2.2182538509368896 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1079, - "componentType" : 5126, - "count" : 628, - "type" : "VEC3" - }, - { - "bufferView" : 1080, - "componentType" : 5126, - "count" : 628, - "type" : "VEC2" - }, - { - "bufferView" : 1081, - "componentType" : 5123, - "count" : 3732, - "type" : "SCALAR" - }, - { - "bufferView" : 1082, - "componentType" : 5126, - "count" : 628, - "max" : [ - -6.390137672424316, - 1.3718829154968262, - -2.1757538318634033 - ], - "min" : [ - -6.541837692260742, - 1.1189759969711304, - -2.218251943588257 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1083, - "componentType" : 5126, - "count" : 628, - "type" : "VEC3" - }, - { - "bufferView" : 1084, - "componentType" : 5126, - "count" : 628, - "type" : "VEC2" - }, - { - "bufferView" : 1085, - "componentType" : 5123, - "count" : 3732, - "type" : "SCALAR" - }, - { - "bufferView" : 1086, - "componentType" : 5126, - "count" : 143, - "max" : [ - -6.17737340927124, - 2.169512987136841, - -2.116008758544922 - ], - "min" : [ - -6.211106300354004, - 2.0745368003845215, - -2.4683449268341064 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1087, - "componentType" : 5126, - "count" : 143, - "type" : "VEC3" - }, - { - "bufferView" : 1088, - "componentType" : 5126, - "count" : 143, - "type" : "VEC2" - }, - { - "bufferView" : 1089, - "componentType" : 5126, - "count" : 4, - "max" : [ - -6.187331199645996, - 2.1369729042053223, - 1.4512840509414673 - ], - "min" : [ - -6.43443489074707, - 1.3415701389312744, - 1.4155499935150146 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1090, - "componentType" : 5126, - "count" : 4, - "type" : "VEC3" - }, - { - "bufferView" : 1091, - "componentType" : 5126, - "count" : 4, - "type" : "VEC2" - }, - { - "bufferView" : 1092, - "componentType" : 5123, - "count" : 6, - "type" : "SCALAR" - }, - { - "bufferView" : 1093, - "componentType" : 5126, - "count" : 4, - "max" : [ - -5.934752464294434, - 2.1435487270355225, - 1.4334168434143066 - ], - "min" : [ - -6.206442832946777, - 1.3375129699707031, - 1.4334168434143066 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1094, - "componentType" : 5126, - "count" : 4, - "type" : "VEC3" - }, - { - "bufferView" : 1095, - "componentType" : 5126, - "count" : 4, - "type" : "VEC2" - }, - { - "bufferView" : 1096, - "componentType" : 5123, - "count" : 6, - "type" : "SCALAR" - }, - { - "bufferView" : 1097, - "componentType" : 5126, - "count" : 407, - "max" : [ - 8.926568031311035, - 9.217284202575684, - 2.252952814102173 - ], - "min" : [ - -10.22567081451416, - 6.9376678466796875, - -2.9549407958984375 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1098, - "componentType" : 5126, - "count" : 407, - "type" : "VEC3" - }, - { - "bufferView" : 1099, - "componentType" : 5126, - "count" : 407, - "type" : "VEC2" - }, - { - "bufferView" : 1100, - "componentType" : 5123, - "count" : 612, - "type" : "SCALAR" - }, - { - "bufferView" : 1101, - "componentType" : 5126, - "count" : 6, - "max" : [ - -6.172985553741455, - 2.1413300037384033, - 1.4334179162979126 - ], - "min" : [ - -6.4487810134887695, - 1.3372129201889038, - 1.4334168434143066 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1102, - "componentType" : 5126, - "count" : 6, - "type" : "VEC3" - }, - { - "bufferView" : 1103, - "componentType" : 5126, - "count" : 6, - "type" : "VEC2" - }, - { - "bufferView" : 1104, - "componentType" : 5123, - "count" : 6, - "type" : "SCALAR" - }, - { - "bufferView" : 1105, - "componentType" : 5126, - "count" : 4, - "max" : [ - -5.944071292877197, - 2.1369469165802, - 1.4512840509414673 - ], - "min" : [ - -6.202451705932617, - 1.3441150188446045, - 1.4155499935150146 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1106, - "componentType" : 5126, - "count" : 4, - "type" : "VEC3" - }, - { - "bufferView" : 1107, - "componentType" : 5126, - "count" : 4, - "type" : "VEC2" - }, - { - "bufferView" : 1108, - "componentType" : 5126, - "count" : 900, - "max" : [ - -5.935790061950684, - 1.2814610004425049, - 1.687201976776123 - ], - "min" : [ - -6.443897724151611, - 1.0480189323425293, - 1.1796618700027466 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1109, - "componentType" : 5126, - "count" : 900, - "type" : "VEC3" - }, - { - "bufferView" : 1110, - "componentType" : 5126, - "count" : 900, - "type" : "VEC2" - }, - { - "bufferView" : 1111, - "componentType" : 5123, - "count" : 4923, - "type" : "SCALAR" - }, - { - "bufferView" : 1112, - "componentType" : 5126, - "count" : 325, - "max" : [ - -6.156490325927734, - 1.0480189323425293, - 1.467315912246704 - ], - "min" : [ - -6.223269939422607, - 0.9867289662361145, - 1.4006099700927734 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1113, - "componentType" : 5126, - "count" : 325, - "type" : "VEC3" - }, - { - "bufferView" : 1114, - "componentType" : 5126, - "count" : 325, - "type" : "VEC2" - }, - { - "bufferView" : 1115, - "componentType" : 5123, - "count" : 1674, - "type" : "SCALAR" - }, - { - "bufferView" : 1116, - "componentType" : 5126, - "count" : 628, - "max" : [ - -6.39013671875, - 1.3718829154968262, - 1.4546668529510498 - ], - "min" : [ - -6.541837692260742, - 1.1189759969711304, - 1.4121689796447754 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1117, - "componentType" : 5126, - "count" : 628, - "type" : "VEC3" - }, - { - "bufferView" : 1118, - "componentType" : 5126, - "count" : 628, - "type" : "VEC2" - }, - { - "bufferView" : 1119, - "componentType" : 5123, - "count" : 3732, - "type" : "SCALAR" - }, - { - "bufferView" : 1120, - "componentType" : 5126, - "count" : 628, - "max" : [ - -5.842243671417236, - 1.3718829154968262, - 1.4546648263931274 - ], - "min" : [ - -5.9939446449279785, - 1.1189759969711304, - 1.4121668338775635 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1121, - "componentType" : 5126, - "count" : 628, - "type" : "VEC3" - }, - { - "bufferView" : 1122, - "componentType" : 5126, - "count" : 628, - "type" : "VEC2" - }, - { - "bufferView" : 1123, - "componentType" : 5123, - "count" : 3732, - "type" : "SCALAR" - }, - { - "bufferView" : 1124, - "componentType" : 5126, - "count" : 143, - "max" : [ - -6.172976493835449, - 2.169512987136841, - 1.7047579288482666 - ], - "min" : [ - -6.206708908081055, - 2.0745368003845215, - 1.3524219989776611 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1125, - "componentType" : 5126, - "count" : 143, - "type" : "VEC3" - }, - { - "bufferView" : 1126, - "componentType" : 5126, - "count" : 143, - "type" : "VEC2" - }, - { - "bufferView" : 1127, - "componentType" : 5123, - "count" : 810, - "type" : "SCALAR" - }, - { - "bufferView" : 1128, - "componentType" : 5126, - "count" : 4, - "max" : [ - 4.881028652191162, - 2.1369729042053223, - 1.4512829780578613 - ], - "min" : [ - 4.633925914764404, - 1.3415701389312744, - 1.4155479669570923 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1129, - "componentType" : 5126, - "count" : 4, - "type" : "VEC3" - }, - { - "bufferView" : 1130, - "componentType" : 5126, - "count" : 4, - "type" : "VEC2" - }, - { - "bufferView" : 1131, - "componentType" : 5126, - "count" : 6, - "max" : [ - 5.133607864379883, - 2.1435487270355225, - 1.4334160089492798 - ], - "min" : [ - 4.861917495727539, - 1.3375129699707031, - 1.4334160089492798 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1132, - "componentType" : 5126, - "count" : 6, - "type" : "VEC3" - }, - { - "bufferView" : 1133, - "componentType" : 5126, - "count" : 6, - "type" : "VEC2" - }, - { - "bufferView" : 1134, - "componentType" : 5123, - "count" : 6, - "type" : "SCALAR" - }, - { - "bufferView" : 1135, - "componentType" : 5126, - "count" : 6, - "max" : [ - 4.895374774932861, - 2.1413300037384033, - 1.4334160089492798 - ], - "min" : [ - 4.619579792022705, - 1.3372129201889038, - 1.4334160089492798 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1136, - "componentType" : 5126, - "count" : 6, - "type" : "VEC3" - }, - { - "bufferView" : 1137, - "componentType" : 5126, - "count" : 6, - "type" : "VEC2" - }, - { - "bufferView" : 1138, - "componentType" : 5126, - "count" : 311, - "max" : [ - 8.685941696166992, - 12.967110633850098, - 1.8129868507385254 - ], - "min" : [ - -10.023770332336426, - 9.217284202575684, - -2.5354859828948975 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1139, - "componentType" : 5126, - "count" : 311, - "type" : "VEC3" - }, - { - "bufferView" : 1140, - "componentType" : 5126, - "count" : 311, - "type" : "VEC2" - }, - { - "bufferView" : 1141, - "componentType" : 5123, - "count" : 444, - "type" : "SCALAR" - }, - { - "bufferView" : 1142, - "componentType" : 5126, - "count" : 4, - "max" : [ - 5.1242876052856445, - 2.1369469165802, - 1.4512829780578613 - ], - "min" : [ - 4.865907669067383, - 1.3441150188446045, - 1.4155479669570923 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1143, - "componentType" : 5126, - "count" : 4, - "type" : "VEC3" - }, - { - "bufferView" : 1144, - "componentType" : 5126, - "count" : 4, - "type" : "VEC2" - }, - { - "bufferView" : 1145, - "componentType" : 5126, - "count" : 900, - "max" : [ - 5.132570743560791, - 1.2814610004425049, - 1.6871999502182007 - ], - "min" : [ - 4.624462604522705, - 1.0480189323425293, - 1.1796599626541138 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1146, - "componentType" : 5126, - "count" : 900, - "type" : "VEC3" - }, - { - "bufferView" : 1147, - "componentType" : 5126, - "count" : 900, - "type" : "VEC2" - }, - { - "bufferView" : 1148, - "componentType" : 5126, - "count" : 325, - "max" : [ - 4.91187047958374, - 1.0480189323425293, - 1.4673140048980713 - ], - "min" : [ - 4.845090389251709, - 0.9867289662361145, - 1.4006088972091675 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1149, - "componentType" : 5126, - "count" : 325, - "type" : "VEC3" - }, - { - "bufferView" : 1150, - "componentType" : 5126, - "count" : 325, - "type" : "VEC2" - }, - { - "bufferView" : 1151, - "componentType" : 5123, - "count" : 1674, - "type" : "SCALAR" - }, - { - "bufferView" : 1152, - "componentType" : 5126, - "count" : 628, - "max" : [ - 4.678223609924316, - 1.3718829154968262, - 1.4546648263931274 - ], - "min" : [ - 4.526522636413574, - 1.1189759969711304, - 1.4121668338775635 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1153, - "componentType" : 5126, - "count" : 628, - "type" : "VEC3" - }, - { - "bufferView" : 1154, - "componentType" : 5126, - "count" : 628, - "type" : "VEC2" - }, - { - "bufferView" : 1155, - "componentType" : 5126, - "count" : 628, - "max" : [ - 5.226115703582764, - 1.3718829154968262, - 1.4546629190444946 - ], - "min" : [ - 5.0744147300720215, - 1.1189759969711304, - 1.4121649265289307 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1156, - "componentType" : 5126, - "count" : 628, - "type" : "VEC3" - }, - { - "bufferView" : 1157, - "componentType" : 5126, - "count" : 628, - "type" : "VEC2" - }, - { - "bufferView" : 1158, - "componentType" : 5126, - "count" : 143, - "max" : [ - 4.895384788513184, - 2.169512987136841, - 1.7047560214996338 - ], - "min" : [ - 4.86165189743042, - 2.0745368003845215, - 1.3524199724197388 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1159, - "componentType" : 5126, - "count" : 143, - "type" : "VEC3" - }, - { - "bufferView" : 1160, - "componentType" : 5126, - "count" : 143, - "type" : "VEC2" - }, - { - "bufferView" : 1161, - "componentType" : 5126, - "count" : 536, - "max" : [ - -9.290047645568848, - 0.731235921382904, - -1.9361118078231812 - ], - "min" : [ - -9.929603576660156, - 0.4608149528503418, - -2.6183648109436035 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1162, - "componentType" : 5126, - "count" : 536, - "type" : "VEC3" - }, - { - "bufferView" : 1163, - "componentType" : 5126, - "count" : 536, - "type" : "VEC2" - }, - { - "bufferView" : 1164, - "componentType" : 5123, - "count" : 1404, - "type" : "SCALAR" - }, - { - "bufferView" : 1165, - "componentType" : 5126, - "count" : 1230, - "max" : [ - -9.38749885559082, - 0.5619949698448181, - -1.997121810913086 - ], - "min" : [ - -9.907388687133789, - -0.0014009999576956034, - -2.5164308547973633 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1166, - "componentType" : 5126, - "count" : 1230, - "type" : "VEC3" - }, - { - "bufferView" : 1167, - "componentType" : 5126, - "count" : 1230, - "type" : "VEC2" - }, - { - "bufferView" : 1168, - "componentType" : 5123, - "count" : 6633, - "type" : "SCALAR" - }, - { - "bufferView" : 1169, - "componentType" : 5126, - "count" : 536, - "max" : [ - -9.290047645568848, - 0.6936119794845581, - 1.832831859588623 - ], - "min" : [ - -9.929603576660156, - 0.42319098114967346, - 1.1505789756774902 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1170, - "componentType" : 5126, - "count" : 536, - "type" : "VEC3" - }, - { - "bufferView" : 1171, - "componentType" : 5126, - "count" : 536, - "type" : "VEC2" - }, - { - "bufferView" : 1172, - "componentType" : 5126, - "count" : 1230, - "max" : [ - -9.38749885559082, - 0.5243709683418274, - 1.7718218564987183 - ], - "min" : [ - -9.907388687133789, - -0.039024997502565384, - 1.2525129318237305 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1173, - "componentType" : 5126, - "count" : 1230, - "type" : "VEC3" - }, - { - "bufferView" : 1174, - "componentType" : 5126, - "count" : 1230, - "type" : "VEC2" - }, - { - "bufferView" : 1175, - "componentType" : 5126, - "count" : 536, - "max" : [ - -2.091301918029785, - 0.6936119794845581, - 1.8785158395767212 - ], - "min" : [ - -2.7735557556152344, - 0.42319098114967346, - 1.2389580011367798 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1176, - "componentType" : 5126, - "count" : 536, - "type" : "VEC3" - }, - { - "bufferView" : 1177, - "componentType" : 5126, - "count" : 536, - "type" : "VEC2" - }, - { - "bufferView" : 1178, - "componentType" : 5126, - "count" : 1230, - "max" : [ - -2.193237066268921, - 0.5243709683418274, - 1.7810639142990112 - ], - "min" : [ - -2.7125461101531982, - -0.039024997502565384, - 1.261173963546753 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1179, - "componentType" : 5126, - "count" : 1230, - "type" : "VEC3" - }, - { - "bufferView" : 1180, - "componentType" : 5126, - "count" : 1230, - "type" : "VEC2" - }, - { - "bufferView" : 1181, - "componentType" : 5126, - "count" : 453, - "max" : [ - 1.4733439683914185, - 0.6706769466400146, - 1.8333748579025269 - ], - "min" : [ - 0.9180700182914734, - 0.43872296810150146, - 1.2615379095077515 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1182, - "componentType" : 5126, - "count" : 453, - "type" : "VEC3" - }, - { - "bufferView" : 1183, - "componentType" : 5126, - "count" : 453, - "type" : "VEC2" - }, - { - "bufferView" : 1184, - "componentType" : 5123, - "count" : 1200, - "type" : "SCALAR" - }, - { - "bufferView" : 1185, - "componentType" : 5126, - "count" : 1230, - "max" : [ - 1.4474408626556396, - 0.5230889916419983, - 1.7931078672409058 - ], - "min" : [ - 0.9275509715080261, - -0.040306996554136276, - 1.273798942565918 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1186, - "componentType" : 5126, - "count" : 1230, - "type" : "VEC3" - }, - { - "bufferView" : 1187, - "componentType" : 5126, - "count" : 1230, - "type" : "VEC2" - }, - { - "bufferView" : 1188, - "componentType" : 5123, - "count" : 6633, - "type" : "SCALAR" - }, - { - "bufferView" : 1189, - "componentType" : 5126, - "count" : 116, - "max" : [ - 5.359613418579102, - 12.734880447387695, - -2.4313318729400635 - ], - "min" : [ - 4.784943580627441, - 12.15902042388916, - -2.6362478733062744 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1190, - "componentType" : 5126, - "count" : 116, - "type" : "VEC3" - }, - { - "bufferView" : 1191, - "componentType" : 5126, - "count" : 116, - "type" : "VEC2" - }, - { - "bufferView" : 1192, - "componentType" : 5123, - "count" : 480, - "type" : "SCALAR" - }, - { - "bufferView" : 1193, - "componentType" : 5126, - "count" : 453, - "max" : [ - 8.618857383728027, - 0.6761940121650696, - 1.8333748579025269 - ], - "min" : [ - 8.063583374023438, - 0.4442400336265564, - 1.2615379095077515 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1194, - "componentType" : 5126, - "count" : 453, - "type" : "VEC3" - }, - { - "bufferView" : 1195, - "componentType" : 5126, - "count" : 453, - "type" : "VEC2" - }, - { - "bufferView" : 1196, - "componentType" : 5126, - "count" : 1230, - "max" : [ - 8.592954635620117, - 0.5286059975624084, - 1.7931078672409058 - ], - "min" : [ - 8.073064804077148, - -0.034790001809597015, - 1.273798942565918 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1197, - "componentType" : 5126, - "count" : 1230, - "type" : "VEC3" - }, - { - "bufferView" : 1198, - "componentType" : 5126, - "count" : 1230, - "type" : "VEC2" - }, - { - "bufferView" : 1199, - "componentType" : 5123, - "count" : 6633, - "type" : "SCALAR" - }, - { - "bufferView" : 1200, - "componentType" : 5126, - "count" : 453, - "max" : [ - 8.618857383728027, - 0.7095819711685181, - -1.935568928718567 - ], - "min" : [ - 8.063583374023438, - 0.4776289761066437, - -2.507405996322632 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1201, - "componentType" : 5126, - "count" : 453, - "type" : "VEC3" - }, - { - "bufferView" : 1202, - "componentType" : 5126, - "count" : 453, - "type" : "VEC2" - }, - { - "bufferView" : 1203, - "componentType" : 5126, - "count" : 1230, - "max" : [ - 8.592954635620117, - 0.5619949698448181, - -1.9758358001708984 - ], - "min" : [ - 8.073064804077148, - -0.0014009999576956034, - -2.495144844055176 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1204, - "componentType" : 5126, - "count" : 1230, - "type" : "VEC3" - }, - { - "bufferView" : 1205, - "componentType" : 5126, - "count" : 1230, - "type" : "VEC2" - }, - { - "bufferView" : 1206, - "componentType" : 5126, - "count" : 453, - "max" : [ - 1.4733439683914185, - 0.7095819711685181, - -1.935568928718567 - ], - "min" : [ - 0.9180700182914734, - 0.4776289761066437, - -2.507405996322632 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1207, - "componentType" : 5126, - "count" : 453, - "type" : "VEC3" - }, - { - "bufferView" : 1208, - "componentType" : 5126, - "count" : 453, - "type" : "VEC2" - }, - { - "bufferView" : 1209, - "componentType" : 5126, - "count" : 1230, - "max" : [ - 1.4474408626556396, - 0.5619949698448181, - -1.9758358001708984 - ], - "min" : [ - 0.9275509715080261, - -0.0014009999576956034, - -2.495144844055176 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1210, - "componentType" : 5126, - "count" : 1230, - "type" : "VEC3" - }, - { - "bufferView" : 1211, - "componentType" : 5126, - "count" : 1230, - "type" : "VEC2" - }, - { - "bufferView" : 1212, - "componentType" : 5126, - "count" : 1353, - "max" : [ - -11.277219772338867, - 1.3301680088043213, - 4.782617568969727 - ], - "min" : [ - -12.766730308532715, - -0.006933999713510275, - 3.2931017875671387 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1213, - "componentType" : 5126, - "count" : 1353, - "type" : "VEC3" - }, - { - "bufferView" : 1214, - "componentType" : 5126, - "count" : 1353, - "type" : "VEC2" - }, - { - "bufferView" : 1215, - "componentType" : 5123, - "count" : 6888, - "type" : "SCALAR" - }, - { - "bufferView" : 1216, - "componentType" : 5126, - "count" : 1353, - "max" : [ - -11.277219772338867, - 1.3301680088043213, - -3.7454800605773926 - ], - "min" : [ - -12.766730308532715, - -0.006933999713510275, - -5.2349958419799805 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1217, - "componentType" : 5126, - "count" : 1353, - "type" : "VEC3" - }, - { - "bufferView" : 1218, - "componentType" : 5126, - "count" : 1353, - "type" : "VEC2" - }, - { - "bufferView" : 1219, - "componentType" : 5123, - "count" : 6888, - "type" : "SCALAR" - }, - { - "bufferView" : 1220, - "componentType" : 5126, - "count" : 1354, - "max" : [ - 11.941709518432617, - 1.3301680088043213, - -3.7454800605773926 - ], - "min" : [ - 10.452189445495605, - -0.006933999713510275, - -5.2349958419799805 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1221, - "componentType" : 5126, - "count" : 1354, - "type" : "VEC3" - }, - { - "bufferView" : 1222, - "componentType" : 5126, - "count" : 1354, - "type" : "VEC2" - }, - { - "bufferView" : 1223, - "componentType" : 5123, - "count" : 6888, - "type" : "SCALAR" - }, - { - "bufferView" : 1224, - "componentType" : 5126, - "count" : 1351, - "max" : [ - 11.941709518432617, - 1.3301680088043213, - 4.782617568969727 - ], - "min" : [ - 10.452189445495605, - -0.006933999713510275, - 3.2931017875671387 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1225, - "componentType" : 5126, - "count" : 1351, - "type" : "VEC3" - }, - { - "bufferView" : 1226, - "componentType" : 5126, - "count" : 1351, - "type" : "VEC2" - }, - { - "bufferView" : 1227, - "componentType" : 5123, - "count" : 6888, - "type" : "SCALAR" - }, - { - "bufferView" : 1228, - "componentType" : 5126, - "count" : 747, - "max" : [ - 12.99867057800293, - 3.0632457733154297, - 0.8862659335136414 - ], - "min" : [ - 12.770230293273926, - 0.4081859886646271, - -1.6046500205993652 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1229, - "componentType" : 5126, - "count" : 747, - "type" : "VEC3" - }, - { - "bufferView" : 1230, - "componentType" : 5126, - "count" : 747, - "type" : "VEC2" - }, - { - "bufferView" : 1231, - "componentType" : 5123, - "count" : 4086, - "type" : "SCALAR" - }, - { - "bufferView" : 1232, - "componentType" : 5126, - "count" : 867, - "max" : [ - 12.990260124206543, - 2.6476118564605713, - 0.4146759808063507 - ], - "min" : [ - 12.240480422973633, - 0.7990480065345764, - -1.1469149589538574 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1233, - "componentType" : 5126, - "count" : 867, - "type" : "VEC3" - }, - { - "bufferView" : 1234, - "componentType" : 5126, - "count" : 867, - "type" : "VEC2" - }, - { - "bufferView" : 1235, - "componentType" : 5123, - "count" : 4563, - "type" : "SCALAR" - }, - { - "bufferView" : 1236, - "componentType" : 5126, - "count" : 747, - "max" : [ - -14.054309844970703, - 3.0632457733154297, - 0.8862689733505249 - ], - "min" : [ - -14.282750129699707, - 0.4081859886646271, - -1.6046459674835205 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1237, - "componentType" : 5126, - "count" : 747, - "type" : "VEC3" - }, - { - "bufferView" : 1238, - "componentType" : 5126, - "count" : 747, - "type" : "VEC2" - }, - { - "bufferView" : 1239, - "componentType" : 5123, - "count" : 4086, - "type" : "SCALAR" - }, - { - "bufferView" : 1240, - "componentType" : 5126, - "count" : 867, - "max" : [ - -13.52455997467041, - 2.6476118564605713, - 0.42853397130966187 - ], - "min" : [ - -14.274340629577637, - 0.7990480065345764, - -1.133056879043579 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1241, - "componentType" : 5126, - "count" : 867, - "type" : "VEC3" - }, - { - "bufferView" : 1242, - "componentType" : 5126, - "count" : 867, - "type" : "VEC2" - }, - { - "bufferView" : 1243, - "componentType" : 5123, - "count" : 4563, - "type" : "SCALAR" - }, - { - "bufferView" : 1244, - "componentType" : 5126, - "count" : 50, - "max" : [ - 17.466930389404297, - 13.471960067749023, - 10.397109985351562 - ], - "min" : [ - -18.669830322265625, - -1.2644249200820923, - -11.39030933380127 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1245, - "componentType" : 5126, - "count" : 50, - "type" : "VEC3" - }, - { - "bufferView" : 1246, - "componentType" : 5126, - "count" : 50, - "type" : "VEC2" - }, - { - "bufferView" : 1247, - "componentType" : 5123, - "count" : 84, - "type" : "SCALAR" - }, - { - "bufferView" : 1248, - "componentType" : 5126, - "count" : 199, - "max" : [ - 5.249011516571045, - 12.624040603637695, - -2.559670925140381 - ], - "min" : [ - 4.895544528961182, - 12.269850730895996, - -2.71464204788208 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1249, - "componentType" : 5126, - "count" : 199, - "type" : "VEC3" - }, - { - "bufferView" : 1250, - "componentType" : 5126, - "count" : 199, - "type" : "VEC2" - }, - { - "bufferView" : 1251, - "componentType" : 5123, - "count" : 336, - "type" : "SCALAR" - }, - { - "bufferView" : 1252, - "componentType" : 5126, - "count" : 380, - "max" : [ - 17.999080657958984, - 14.222129821777344, - 11.05426025390625 - ], - "min" : [ - -19.20945930480957, - 13.300320625305176, - -11.828069686889648 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1253, - "componentType" : 5126, - "count" : 380, - "type" : "VEC3" - }, - { - "bufferView" : 1254, - "componentType" : 5126, - "count" : 380, - "type" : "VEC2" - }, - { - "bufferView" : 1255, - "componentType" : 5123, - "count" : 1488, - "type" : "SCALAR" - }, - { - "bufferView" : 1256, - "componentType" : 5126, - "count" : 10546, - "max" : [ - 13.192880630493164, - 14.294330596923828, - 6.25956916809082 - ], - "min" : [ - -14.421850204467773, - 12.805130004882812, - -7.016911029815674 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1257, - "componentType" : 5126, - "count" : 10546, - "type" : "VEC3" - }, - { - "bufferView" : 1258, - "componentType" : 5126, - "count" : 10546, - "type" : "VEC2" - }, - { - "bufferView" : 1259, - "componentType" : 5123, - "count" : 41964, - "type" : "SCALAR" - }, - { - "bufferView" : 1260, - "componentType" : 5126, - "count" : 22, - "max" : [ - 13.8060302734375, - 12.710371017456055, - 6.747567653656006 - ], - "min" : [ - -15.044679641723633, - -1.1597908735275269, - -7.825202465057373 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1261, - "componentType" : 5126, - "count" : 22, - "type" : "VEC3" - }, - { - "bufferView" : 1262, - "componentType" : 5126, - "count" : 22, - "type" : "VEC2" - }, - { - "bufferView" : 1263, - "componentType" : 5123, - "count" : 30, - "type" : "SCALAR" - }, - { - "bufferView" : 1264, - "componentType" : 5126, - "count" : 116, - "max" : [ - 1.658350944519043, - 12.734880447387695, - -2.4313318729400635 - ], - "min" : [ - 1.0836809873580933, - 12.15902042388916, - -2.6362478733062744 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1265, - "componentType" : 5126, - "count" : 116, - "type" : "VEC3" - }, - { - "bufferView" : 1266, - "componentType" : 5126, - "count" : 116, - "type" : "VEC2" - }, - { - "bufferView" : 1267, - "componentType" : 5123, - "count" : 480, - "type" : "SCALAR" - }, - { - "bufferView" : 1268, - "componentType" : 5126, - "count" : 216, - "max" : [ - 1.5477490425109863, - 12.624040603637695, - -2.559670925140381 - ], - "min" : [ - 1.1942819356918335, - 12.269850730895996, - -2.71464204788208 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1269, - "componentType" : 5126, - "count" : 216, - "type" : "VEC3" - }, - { - "bufferView" : 1270, - "componentType" : 5126, - "count" : 216, - "type" : "VEC2" - }, - { - "bufferView" : 1271, - "componentType" : 5123, - "count" : 336, - "type" : "SCALAR" - }, - { - "bufferView" : 1272, - "componentType" : 5126, - "count" : 116, - "max" : [ - -2.3586528301239014, - 12.734880447387695, - -2.4313318729400635 - ], - "min" : [ - -2.9333229064941406, - 12.15902042388916, - -2.6362478733062744 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1273, - "componentType" : 5126, - "count" : 116, - "type" : "VEC3" - }, - { - "bufferView" : 1274, - "componentType" : 5126, - "count" : 116, - "type" : "VEC2" - }, - { - "bufferView" : 1275, - "componentType" : 5123, - "count" : 480, - "type" : "SCALAR" - }, - { - "bufferView" : 1276, - "componentType" : 5126, - "count" : 210, - "max" : [ - -2.469254970550537, - 12.624040603637695, - -2.559670925140381 - ], - "min" : [ - -2.8227217197418213, - 12.269850730895996, - -2.71464204788208 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1277, - "componentType" : 5126, - "count" : 210, - "type" : "VEC3" - }, - { - "bufferView" : 1278, - "componentType" : 5126, - "count" : 210, - "type" : "VEC2" - }, - { - "bufferView" : 1279, - "componentType" : 5123, - "count" : 336, - "type" : "SCALAR" - }, - { - "bufferView" : 1280, - "componentType" : 5126, - "count" : 116, - "max" : [ - -6.060910701751709, - 12.734880447387695, - -2.4313318729400635 - ], - "min" : [ - -6.635581016540527, - 12.15902042388916, - -2.6362478733062744 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1281, - "componentType" : 5126, - "count" : 116, - "type" : "VEC3" - }, - { - "bufferView" : 1282, - "componentType" : 5126, - "count" : 116, - "type" : "VEC2" - }, - { - "bufferView" : 1283, - "componentType" : 5126, - "count" : 192, - "max" : [ - -6.171513557434082, - 12.624040603637695, - -2.559670925140381 - ], - "min" : [ - -6.5249786376953125, - 12.269850730895996, - -2.71464204788208 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1284, - "componentType" : 5126, - "count" : 192, - "type" : "VEC3" - }, - { - "bufferView" : 1285, - "componentType" : 5126, - "count" : 192, - "type" : "VEC2" - }, - { - "bufferView" : 1286, - "componentType" : 5123, - "count" : 336, - "type" : "SCALAR" - }, - { - "bufferView" : 1287, - "componentType" : 5126, - "count" : 116, - "max" : [ - -9.921154975891113, - 12.750110626220703, - -0.06238099932670593 - ], - "min" : [ - -10.126070022583008, - 12.174250602722168, - -0.6370500326156616 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1288, - "componentType" : 5126, - "count" : 116, - "type" : "VEC3" - }, - { - "bufferView" : 1289, - "componentType" : 5126, - "count" : 116, - "type" : "VEC2" - }, - { - "bufferView" : 1290, - "componentType" : 5123, - "count" : 480, - "type" : "SCALAR" - }, - { - "bufferView" : 1291, - "componentType" : 5126, - "count" : 175, - "max" : [ - -10.04949951171875, - 12.639280319213867, - -0.17298299074172974 - ], - "min" : [ - -10.204460144042969, - 12.285079956054688, - -0.5264500379562378 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1292, - "componentType" : 5126, - "count" : 175, - "type" : "VEC3" - }, - { - "bufferView" : 1293, - "componentType" : 5126, - "count" : 175, - "type" : "VEC2" - }, - { - "bufferView" : 1294, - "componentType" : 5123, - "count" : 336, - "type" : "SCALAR" - }, - { - "bufferView" : 1295, - "componentType" : 5126, - "count" : 116, - "max" : [ - 5.359613418579102, - 12.734880447387695, - 1.8992849588394165 - ], - "min" : [ - 4.784943580627441, - 12.15902042388916, - 1.6943700313568115 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1296, - "componentType" : 5126, - "count" : 116, - "type" : "VEC3" - }, - { - "bufferView" : 1297, - "componentType" : 5126, - "count" : 116, - "type" : "VEC2" - }, - { - "bufferView" : 1298, - "componentType" : 5123, - "count" : 480, - "type" : "SCALAR" - }, - { - "bufferView" : 1299, - "componentType" : 5126, - "count" : 199, - "max" : [ - 5.249011516571045, - 12.624040603637695, - 1.977679967880249 - ], - "min" : [ - 4.895544528961182, - 12.269850730895996, - 1.8227088451385498 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1300, - "componentType" : 5126, - "count" : 199, - "type" : "VEC3" - }, - { - "bufferView" : 1301, - "componentType" : 5126, - "count" : 199, - "type" : "VEC2" - }, - { - "bufferView" : 1302, - "componentType" : 5123, - "count" : 336, - "type" : "SCALAR" - }, - { - "bufferView" : 1303, - "componentType" : 5126, - "count" : 116, - "max" : [ - 1.658350944519043, - 12.734880447387695, - 1.8992849588394165 - ], - "min" : [ - 1.0836809873580933, - 12.15902042388916, - 1.6943700313568115 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1304, - "componentType" : 5126, - "count" : 116, - "type" : "VEC3" - }, - { - "bufferView" : 1305, - "componentType" : 5126, - "count" : 116, - "type" : "VEC2" - }, - { - "bufferView" : 1306, - "componentType" : 5126, - "count" : 203, - "max" : [ - 1.5477490425109863, - 12.624040603637695, - 1.977679967880249 - ], - "min" : [ - 1.1942819356918335, - 12.269850730895996, - 1.8227088451385498 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1307, - "componentType" : 5126, - "count" : 203, - "type" : "VEC3" - }, - { - "bufferView" : 1308, - "componentType" : 5126, - "count" : 203, - "type" : "VEC2" - }, - { - "bufferView" : 1309, - "componentType" : 5123, - "count" : 336, - "type" : "SCALAR" - }, - { - "bufferView" : 1310, - "componentType" : 5126, - "count" : 116, - "max" : [ - -2.3586528301239014, - 12.734880447387695, - 1.8992849588394165 - ], - "min" : [ - -2.9333229064941406, - 12.15902042388916, - 1.6943700313568115 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1311, - "componentType" : 5126, - "count" : 116, - "type" : "VEC3" - }, - { - "bufferView" : 1312, - "componentType" : 5126, - "count" : 116, - "type" : "VEC2" - }, - { - "bufferView" : 1313, - "componentType" : 5126, - "count" : 195, - "max" : [ - -2.469254970550537, - 12.624040603637695, - 1.977678894996643 - ], - "min" : [ - -2.8227217197418213, - 12.269850730895996, - 1.8227088451385498 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1314, - "componentType" : 5126, - "count" : 195, - "type" : "VEC3" - }, - { - "bufferView" : 1315, - "componentType" : 5126, - "count" : 195, - "type" : "VEC2" - }, - { - "bufferView" : 1316, - "componentType" : 5123, - "count" : 336, - "type" : "SCALAR" - }, - { - "bufferView" : 1317, - "componentType" : 5126, - "count" : 116, - "max" : [ - -6.060910701751709, - 12.734880447387695, - 1.8992849588394165 - ], - "min" : [ - -6.635581016540527, - 12.15902042388916, - 1.6943700313568115 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1318, - "componentType" : 5126, - "count" : 116, - "type" : "VEC3" - }, - { - "bufferView" : 1319, - "componentType" : 5126, - "count" : 116, - "type" : "VEC2" - }, - { - "bufferView" : 1320, - "componentType" : 5126, - "count" : 199, - "max" : [ - -6.171513557434082, - 12.624040603637695, - 1.977678894996643 - ], - "min" : [ - -6.524980545043945, - 12.269850730895996, - 1.8227088451385498 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1321, - "componentType" : 5126, - "count" : 199, - "type" : "VEC3" - }, - { - "bufferView" : 1322, - "componentType" : 5126, - "count" : 199, - "type" : "VEC2" - }, - { - "bufferView" : 1323, - "componentType" : 5123, - "count" : 336, - "type" : "SCALAR" - }, - { - "bufferView" : 1324, - "componentType" : 5126, - "count" : 92, - "max" : [ - -7.597280025482178, - 10.144710540771484, - 2.0278708934783936 - ], - "min" : [ - -8.500575065612793, - 9.27363109588623, - 1.6931939125061035 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1325, - "componentType" : 5126, - "count" : 92, - "type" : "VEC3" - }, - { - "bufferView" : 1326, - "componentType" : 5126, - "count" : 92, - "type" : "VEC2" - }, - { - "bufferView" : 1327, - "componentType" : 5123, - "count" : 120, - "type" : "SCALAR" - }, - { - "bufferView" : 1328, - "componentType" : 5126, - "count" : 86, - "max" : [ - -3.8870129585266113, - 10.144710540771484, - 2.027869939804077 - ], - "min" : [ - -4.790307998657227, - 9.27363109588623, - 1.6931928396224976 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1329, - "componentType" : 5126, - "count" : 86, - "type" : "VEC3" - }, - { - "bufferView" : 1330, - "componentType" : 5126, - "count" : 86, - "type" : "VEC2" - }, - { - "bufferView" : 1331, - "componentType" : 5123, - "count" : 120, - "type" : "SCALAR" - }, - { - "bufferView" : 1332, - "componentType" : 5126, - "count" : 83, - "max" : [ - -0.16516299545764923, - 10.144710540771484, - 2.0278677940368652 - ], - "min" : [ - -1.0684579610824585, - 9.273633003234863, - 1.6931920051574707 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1333, - "componentType" : 5126, - "count" : 83, - "type" : "VEC3" - }, - { - "bufferView" : 1334, - "componentType" : 5126, - "count" : 83, - "type" : "VEC2" - }, - { - "bufferView" : 1335, - "componentType" : 5123, - "count" : 120, - "type" : "SCALAR" - }, - { - "bufferView" : 1336, - "componentType" : 5126, - "count" : 83, - "max" : [ - 3.5094308853149414, - 10.144710540771484, - 2.027866840362549 - ], - "min" : [ - 2.6061348915100098, - 9.273633003234863, - 1.6931909322738647 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1337, - "componentType" : 5126, - "count" : 83, - "type" : "VEC3" - }, - { - "bufferView" : 1338, - "componentType" : 5126, - "count" : 83, - "type" : "VEC2" - }, - { - "bufferView" : 1339, - "componentType" : 5123, - "count" : 120, - "type" : "SCALAR" - }, - { - "bufferView" : 1340, - "componentType" : 5126, - "count" : 84, - "max" : [ - 7.218197345733643, - 10.144710540771484, - 2.0278658866882324 - ], - "min" : [ - 6.314901828765869, - 9.273633003234863, - 1.6931889057159424 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1341, - "componentType" : 5126, - "count" : 84, - "type" : "VEC3" - }, - { - "bufferView" : 1342, - "componentType" : 5126, - "count" : 84, - "type" : "VEC2" - }, - { - "bufferView" : 1343, - "componentType" : 5123, - "count" : 120, - "type" : "SCALAR" - }, - { - "bufferView" : 1344, - "componentType" : 5126, - "count" : 79, - "max" : [ - -9.965863227844238, - 10.088360786437988, - 0.10976799577474594 - ], - "min" : [ - -10.300540924072266, - 9.217284202575684, - -0.7935279607772827 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1345, - "componentType" : 5126, - "count" : 79, - "type" : "VEC3" - }, - { - "bufferView" : 1346, - "componentType" : 5126, - "count" : 79, - "type" : "VEC2" - }, - { - "bufferView" : 1347, - "componentType" : 5123, - "count" : 120, - "type" : "SCALAR" - }, - { - "bufferView" : 1348, - "componentType" : 5126, - "count" : 86, - "max" : [ - -7.597280025482178, - 10.144710540771484, - -2.413100004196167 - ], - "min" : [ - -8.500575065612793, - 9.27363109588623, - -2.747776746749878 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1349, - "componentType" : 5126, - "count" : 86, - "type" : "VEC3" - }, - { - "bufferView" : 1350, - "componentType" : 5126, - "count" : 86, - "type" : "VEC2" - }, - { - "bufferView" : 1351, - "componentType" : 5123, - "count" : 120, - "type" : "SCALAR" - }, - { - "bufferView" : 1352, - "componentType" : 5126, - "count" : 83, - "max" : [ - -3.8870129585266113, - 10.144710540771484, - -2.413100004196167 - ], - "min" : [ - -4.790307998657227, - 9.27363109588623, - -2.747776746749878 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1353, - "componentType" : 5126, - "count" : 83, - "type" : "VEC3" - }, - { - "bufferView" : 1354, - "componentType" : 5126, - "count" : 83, - "type" : "VEC2" - }, - { - "bufferView" : 1355, - "componentType" : 5123, - "count" : 120, - "type" : "SCALAR" - }, - { - "bufferView" : 1356, - "componentType" : 5126, - "count" : 84, - "max" : [ - -0.16516299545764923, - 10.144710540771484, - -2.413100004196167 - ], - "min" : [ - -1.0684579610824585, - 9.273633003234863, - -2.747776746749878 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1357, - "componentType" : 5126, - "count" : 84, - "type" : "VEC3" - }, - { - "bufferView" : 1358, - "componentType" : 5126, - "count" : 84, - "type" : "VEC2" - }, - { - "bufferView" : 1359, - "componentType" : 5123, - "count" : 120, - "type" : "SCALAR" - }, - { - "bufferView" : 1360, - "componentType" : 5126, - "count" : 86, - "max" : [ - 3.5094308853149414, - 10.144710540771484, - -2.413100004196167 - ], - "min" : [ - 2.6061348915100098, - 9.273633003234863, - -2.747776746749878 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1361, - "componentType" : 5126, - "count" : 86, - "type" : "VEC3" - }, - { - "bufferView" : 1362, - "componentType" : 5126, - "count" : 86, - "type" : "VEC2" - }, - { - "bufferView" : 1363, - "componentType" : 5123, - "count" : 120, - "type" : "SCALAR" - }, - { - "bufferView" : 1364, - "componentType" : 5126, - "count" : 84, - "max" : [ - 7.218197345733643, - 10.144710540771484, - -2.413100004196167 - ], - "min" : [ - 6.314901828765869, - 9.273633003234863, - -2.747776746749878 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1365, - "componentType" : 5126, - "count" : 84, - "type" : "VEC3" - }, - { - "bufferView" : 1366, - "componentType" : 5126, - "count" : 84, - "type" : "VEC2" - }, - { - "bufferView" : 1367, - "componentType" : 5123, - "count" : 120, - "type" : "SCALAR" - }, - { - "bufferView" : 1368, - "componentType" : 5126, - "count" : 70, - "max" : [ - 9.975961685180664, - 13.144899368286133, - 3.1890077590942383 - ], - "min" : [ - -10.86423110961914, - 9.07744026184082, - -4.081467628479004 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1369, - "componentType" : 5126, - "count" : 70, - "type" : "VEC3" - }, - { - "bufferView" : 1370, - "componentType" : 5126, - "count" : 70, - "type" : "VEC2" - }, - { - "bufferView" : 1371, - "componentType" : 5123, - "count" : 96, - "type" : "SCALAR" - }, - { - "bufferView" : 1372, - "componentType" : 5126, - "count" : 584, - "max" : [ - 9.176836013793945, - 9.302658081054688, - 2.4355807304382324 - ], - "min" : [ - -10.483080863952637, - 9.154513359069824, - -3.1810600757598877 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1373, - "componentType" : 5126, - "count" : 584, - "type" : "VEC3" - }, - { - "bufferView" : 1374, - "componentType" : 5126, - "count" : 584, - "type" : "VEC2" - }, - { - "bufferView" : 1375, - "componentType" : 5123, - "count" : 840, - "type" : "SCALAR" - }, - { - "bufferView" : 1376, - "componentType" : 5126, - "count" : 30, - "max" : [ - 13.022210121154785, - 8.673871040344238, - 5.747061729431152 - ], - "min" : [ - -14.312000274658203, - 4.155303001403809, - -6.406331539154053 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1377, - "componentType" : 5126, - "count" : 30, - "type" : "VEC3" - }, - { - "bufferView" : 1378, - "componentType" : 5126, - "count" : 30, - "type" : "VEC2" - }, - { - "bufferView" : 1379, - "componentType" : 5123, - "count" : 54, - "type" : "SCALAR" - }, - { - "bufferView" : 1380, - "componentType" : 5126, - "count" : 79, - "max" : [ - 13.021909713745117, - 4.034478664398193, - 5.740296363830566 - ], - "min" : [ - -14.285200119018555, - -0.026201000437140465, - -6.443113803863525 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1381, - "componentType" : 5126, - "count" : 79, - "type" : "VEC3" - }, - { - "bufferView" : 1382, - "componentType" : 5126, - "count" : 79, - "type" : "VEC2" - }, - { - "bufferView" : 1383, - "componentType" : 5123, - "count" : 108, - "type" : "SCALAR" - }, - { - "bufferView" : 1384, - "componentType" : 5126, - "count" : 319, - "max" : [ - 0.4111109972000122, - 2.435642957687378, - 6.050136089324951 - ], - "min" : [ - -1.7002489566802979, - -0.021348997950553894, - 5.542697429656982 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1385, - "componentType" : 5126, - "count" : 319, - "type" : "VEC3" - }, - { - "bufferView" : 1386, - "componentType" : 5126, - "count" : 319, - "type" : "VEC2" - }, - { - "bufferView" : 1387, - "componentType" : 5123, - "count" : 480, - "type" : "SCALAR" - }, - { - "bufferView" : 1388, - "componentType" : 5126, - "count" : 50, - "max" : [ - -3.5712759494781494, - 2.893174886703491, - 5.8367204666137695 - ], - "min" : [ - -5.096835136413574, - 1.1980509757995605, - 5.731038570404053 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1389, - "componentType" : 5126, - "count" : 50, - "type" : "VEC3" - }, - { - "bufferView" : 1390, - "componentType" : 5126, - "count" : 50, - "type" : "VEC2" - }, - { - "bufferView" : 1391, - "componentType" : 5123, - "count" : 72, - "type" : "SCALAR" - }, - { - "bufferView" : 1392, - "componentType" : 5126, - "count" : 176, - "max" : [ - -3.5712759494781494, - 2.893174886703491, - 5.897528171539307 - ], - "min" : [ - -5.096832752227783, - 1.1980509757995605, - 5.731038570404053 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1393, - "componentType" : 5126, - "count" : 176, - "type" : "VEC3" - }, - { - "bufferView" : 1394, - "componentType" : 5126, - "count" : 176, - "type" : "VEC2" - }, - { - "bufferView" : 1395, - "componentType" : 5123, - "count" : 246, - "type" : "SCALAR" - }, - { - "bufferView" : 1396, - "componentType" : 5126, - "count" : 56, - "max" : [ - 3.841212749481201, - 2.8931758403778076, - 5.836721897125244 - ], - "min" : [ - 2.3156540393829346, - 1.1980509757995605, - 5.731040000915527 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1397, - "componentType" : 5126, - "count" : 56, - "type" : "VEC3" - }, - { - "bufferView" : 1398, - "componentType" : 5126, - "count" : 56, - "type" : "VEC2" - }, - { - "bufferView" : 1399, - "componentType" : 5123, - "count" : 72, - "type" : "SCALAR" - }, - { - "bufferView" : 1400, - "componentType" : 5126, - "count" : 180, - "max" : [ - 3.8412117958068848, - 2.8931758403778076, - 5.897528648376465 - ], - "min" : [ - 2.3156540393829346, - 1.1980509757995605, - 5.731040000915527 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1401, - "componentType" : 5126, - "count" : 180, - "type" : "VEC3" - }, - { - "bufferView" : 1402, - "componentType" : 5126, - "count" : 180, - "type" : "VEC2" - }, - { - "bufferView" : 1403, - "componentType" : 5123, - "count" : 246, - "type" : "SCALAR" - }, - { - "bufferView" : 1404, - "componentType" : 5126, - "count" : 513, - "max" : [ - 0.13023599982261658, - 3.003856658935547, - -6.326350688934326 - ], - "min" : [ - -1.4044690132141113, - -0.022154998034238815, - -6.515385150909424 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1405, - "componentType" : 5126, - "count" : 513, - "type" : "VEC3" - }, - { - "bufferView" : 1406, - "componentType" : 5126, - "count" : 513, - "type" : "VEC2" - }, - { - "bufferView" : 1407, - "componentType" : 5123, - "count" : 834, - "type" : "SCALAR" - }, - { - "bufferView" : 1408, - "componentType" : 5126, - "count" : 463, - "max" : [ - 13.155240058898926, - 7.168505668640137, - 0.4259200096130371 - ], - "min" : [ - 12.96621036529541, - 4.142493724822998, - -1.10878586769104 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1409, - "componentType" : 5126, - "count" : 463, - "type" : "VEC3" - }, - { - "bufferView" : 1410, - "componentType" : 5126, - "count" : 463, - "type" : "VEC2" - }, - { - "bufferView" : 1411, - "componentType" : 5123, - "count" : 834, - "type" : "SCALAR" - }, - { - "bufferView" : 1412, - "componentType" : 5126, - "count" : 127, - "max" : [ - 13.021909713745117, - 4.244658946990967, - 5.75300407409668 - ], - "min" : [ - -14.318989753723145, - 4.154613971710205, - -6.416023254394531 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1413, - "componentType" : 5126, - "count" : 127, - "type" : "VEC3" - }, - { - "bufferView" : 1414, - "componentType" : 5126, - "count" : 127, - "type" : "VEC2" - }, - { - "bufferView" : 1415, - "componentType" : 5123, - "count" : 150, - "type" : "SCALAR" - }, - { - "bufferView" : 1416, - "componentType" : 5126, - "count" : 126, - "max" : [ - 13.03104019165039, - 6.953226566314697, - -6.291940689086914 - ], - "min" : [ - 12.900020599365234, - 6.60363245010376, - -6.452885627746582 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1417, - "componentType" : 5126, - "count" : 126, - "type" : "VEC3" - }, - { - "bufferView" : 1418, - "componentType" : 5126, - "count" : 126, - "type" : "VEC2" - }, - { - "bufferView" : 1419, - "componentType" : 5123, - "count" : 222, - "type" : "SCALAR" - }, - { - "bufferView" : 1420, - "componentType" : 5126, - "count" : 126, - "max" : [ - 13.03104019165039, - 6.953226566314697, - 5.757254123687744 - ], - "min" : [ - 12.900020599365234, - 6.603631496429443, - 5.59630823135376 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1421, - "componentType" : 5126, - "count" : 126, - "type" : "VEC3" - }, - { - "bufferView" : 1422, - "componentType" : 5126, - "count" : 126, - "type" : "VEC2" - }, - { - "bufferView" : 1423, - "componentType" : 5123, - "count" : 222, - "type" : "SCALAR" - }, - { - "bufferView" : 1424, - "componentType" : 5126, - "count" : 166, - "max" : [ - 13.032720565795898, - 6.953225612640381, - -2.2154388427734375 - ], - "min" : [ - 12.87656021118164, - 6.603631496429443, - -3.1005918979644775 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1425, - "componentType" : 5126, - "count" : 166, - "type" : "VEC3" - }, - { - "bufferView" : 1426, - "componentType" : 5126, - "count" : 166, - "type" : "VEC2" - }, - { - "bufferView" : 1427, - "componentType" : 5123, - "count" : 264, - "type" : "SCALAR" - }, - { - "bufferView" : 1428, - "componentType" : 5126, - "count" : 167, - "max" : [ - 13.032720565795898, - 6.953225612640381, - 2.4067718982696533 - ], - "min" : [ - 12.87656021118164, - 6.603631496429443, - 1.5216178894042969 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1429, - "componentType" : 5126, - "count" : 167, - "type" : "VEC3" - }, - { - "bufferView" : 1430, - "componentType" : 5126, - "count" : 167, - "type" : "VEC2" - }, - { - "bufferView" : 1431, - "componentType" : 5123, - "count" : 264, - "type" : "SCALAR" - }, - { - "bufferView" : 1432, - "componentType" : 5126, - "count" : 163, - "max" : [ - -5.890180587768555, - 6.953226566314697, - 5.754880428314209 - ], - "min" : [ - -6.497213363647461, - 6.60363245010376, - 5.598720550537109 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1433, - "componentType" : 5126, - "count" : 163, - "type" : "VEC3" - }, - { - "bufferView" : 1434, - "componentType" : 5126, - "count" : 163, - "type" : "VEC2" - }, - { - "bufferView" : 1435, - "componentType" : 5126, - "count" : 158, - "max" : [ - -9.627448081970215, - 6.953226566314697, - 5.754880428314209 - ], - "min" : [ - -10.49055004119873, - 6.603631496429443, - 5.598721981048584 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1436, - "componentType" : 5126, - "count" : 158, - "type" : "VEC3" - }, - { - "bufferView" : 1437, - "componentType" : 5126, - "count" : 158, - "type" : "VEC2" - }, - { - "bufferView" : 1438, - "componentType" : 5123, - "count" : 264, - "type" : "SCALAR" - }, - { - "bufferView" : 1439, - "componentType" : 5126, - "count" : 158, - "max" : [ - -2.179433822631836, - 6.953226566314697, - 5.754880428314209 - ], - "min" : [ - -2.7864646911621094, - 6.603631496429443, - 5.598721981048584 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1440, - "componentType" : 5126, - "count" : 158, - "type" : "VEC3" - }, - { - "bufferView" : 1441, - "componentType" : 5126, - "count" : 158, - "type" : "VEC2" - }, - { - "bufferView" : 1442, - "componentType" : 5123, - "count" : 264, - "type" : "SCALAR" - }, - { - "bufferView" : 1443, - "componentType" : 5126, - "count" : 158, - "max" : [ - 1.5290719270706177, - 6.953226566314697, - 5.754880428314209 - ], - "min" : [ - 0.9220399856567383, - 6.603631496429443, - 5.598721981048584 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1444, - "componentType" : 5126, - "count" : 158, - "type" : "VEC3" - }, - { - "bufferView" : 1445, - "componentType" : 5126, - "count" : 158, - "type" : "VEC2" - }, - { - "bufferView" : 1446, - "componentType" : 5123, - "count" : 264, - "type" : "SCALAR" - }, - { - "bufferView" : 1447, - "componentType" : 5126, - "count" : 158, - "max" : [ - 5.233678340911865, - 6.953226566314697, - 5.754880428314209 - ], - "min" : [ - 4.626646995544434, - 6.603631496429443, - 5.598721981048584 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1448, - "componentType" : 5126, - "count" : 158, - "type" : "VEC3" - }, - { - "bufferView" : 1449, - "componentType" : 5126, - "count" : 158, - "type" : "VEC2" - }, - { - "bufferView" : 1450, - "componentType" : 5123, - "count" : 264, - "type" : "SCALAR" - }, - { - "bufferView" : 1451, - "componentType" : 5126, - "count" : 159, - "max" : [ - 9.23731517791748, - 6.953226566314697, - 5.754880428314209 - ], - "min" : [ - 8.352161407470703, - 6.603631496429443, - 5.598721981048584 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1452, - "componentType" : 5126, - "count" : 159, - "type" : "VEC3" - }, - { - "bufferView" : 1453, - "componentType" : 5126, - "count" : 159, - "type" : "VEC2" - }, - { - "bufferView" : 1454, - "componentType" : 5123, - "count" : 264, - "type" : "SCALAR" - }, - { - "bufferView" : 1455, - "componentType" : 5126, - "count" : 158, - "max" : [ - -5.890180587768555, - 6.953226566314697, - -6.313518524169922 - ], - "min" : [ - -6.497213363647461, - 6.60363245010376, - -6.469677448272705 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1456, - "componentType" : 5126, - "count" : 158, - "type" : "VEC3" - }, - { - "bufferView" : 1457, - "componentType" : 5126, - "count" : 158, - "type" : "VEC2" - }, - { - "bufferView" : 1458, - "componentType" : 5123, - "count" : 264, - "type" : "SCALAR" - }, - { - "bufferView" : 1459, - "componentType" : 5126, - "count" : 156, - "max" : [ - -9.627448081970215, - 6.953226566314697, - -6.313520908355713 - ], - "min" : [ - -10.49055004119873, - 6.603631496429443, - -6.46967887878418 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1460, - "componentType" : 5126, - "count" : 156, - "type" : "VEC3" - }, - { - "bufferView" : 1461, - "componentType" : 5126, - "count" : 156, - "type" : "VEC2" - }, - { - "bufferView" : 1462, - "componentType" : 5123, - "count" : 264, - "type" : "SCALAR" - }, - { - "bufferView" : 1463, - "componentType" : 5126, - "count" : 160, - "max" : [ - -2.179433822631836, - 6.953226566314697, - -6.313520908355713 - ], - "min" : [ - -2.7864646911621094, - 6.603631496429443, - -6.46967887878418 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1464, - "componentType" : 5126, - "count" : 160, - "type" : "VEC3" - }, - { - "bufferView" : 1465, - "componentType" : 5126, - "count" : 160, - "type" : "VEC2" - }, - { - "bufferView" : 1466, - "componentType" : 5123, - "count" : 264, - "type" : "SCALAR" - }, - { - "bufferView" : 1467, - "componentType" : 5126, - "count" : 156, - "max" : [ - 1.5290719270706177, - 6.953226566314697, - -6.313520908355713 - ], - "min" : [ - 0.9220399856567383, - 6.603631496429443, - -6.46967887878418 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1468, - "componentType" : 5126, - "count" : 156, - "type" : "VEC3" - }, - { - "bufferView" : 1469, - "componentType" : 5126, - "count" : 156, - "type" : "VEC2" - }, - { - "bufferView" : 1470, - "componentType" : 5123, - "count" : 264, - "type" : "SCALAR" - }, - { - "bufferView" : 1471, - "componentType" : 5126, - "count" : 159, - "max" : [ - 5.233678340911865, - 6.953226566314697, - -6.313520908355713 - ], - "min" : [ - 4.626646995544434, - 6.603631496429443, - -6.46967887878418 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1472, - "componentType" : 5126, - "count" : 159, - "type" : "VEC3" - }, - { - "bufferView" : 1473, - "componentType" : 5126, - "count" : 159, - "type" : "VEC2" - }, - { - "bufferView" : 1474, - "componentType" : 5123, - "count" : 264, - "type" : "SCALAR" - }, - { - "bufferView" : 1475, - "componentType" : 5126, - "count" : 159, - "max" : [ - 9.23731517791748, - 6.953226566314697, - -6.313520908355713 - ], - "min" : [ - 8.352161407470703, - 6.603631496429443, - -6.46967887878418 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1476, - "componentType" : 5126, - "count" : 159, - "type" : "VEC3" - }, - { - "bufferView" : 1477, - "componentType" : 5126, - "count" : 159, - "type" : "VEC2" - }, - { - "bufferView" : 1478, - "componentType" : 5123, - "count" : 264, - "type" : "SCALAR" - }, - { - "bufferView" : 1479, - "componentType" : 5126, - "count" : 165, - "max" : [ - -14.146899223327637, - 6.953225612640381, - -2.2154388427734375 - ], - "min" : [ - -14.30305004119873, - 6.603631496429443, - -3.1005918979644775 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1480, - "componentType" : 5126, - "count" : 165, - "type" : "VEC3" - }, - { - "bufferView" : 1481, - "componentType" : 5126, - "count" : 165, - "type" : "VEC2" - }, - { - "bufferView" : 1482, - "componentType" : 5123, - "count" : 264, - "type" : "SCALAR" - }, - { - "bufferView" : 1483, - "componentType" : 5126, - "count" : 165, - "max" : [ - -14.146899223327637, - 6.953225612640381, - 2.4067718982696533 - ], - "min" : [ - -14.30305004119873, - 6.603631496429443, - 1.5216178894042969 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1484, - "componentType" : 5126, - "count" : 165, - "type" : "VEC3" - }, - { - "bufferView" : 1485, - "componentType" : 5126, - "count" : 165, - "type" : "VEC2" - }, - { - "bufferView" : 1486, - "componentType" : 5123, - "count" : 264, - "type" : "SCALAR" - }, - { - "bufferView" : 1487, - "componentType" : 5126, - "count" : 126, - "max" : [ - -14.170490264892578, - 6.953226566314697, - -6.291940689086914 - ], - "min" : [ - -14.30150032043457, - 6.603631496429443, - -6.452885627746582 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1488, - "componentType" : 5126, - "count" : 126, - "type" : "VEC3" - }, - { - "bufferView" : 1489, - "componentType" : 5126, - "count" : 126, - "type" : "VEC2" - }, - { - "bufferView" : 1490, - "componentType" : 5123, - "count" : 222, - "type" : "SCALAR" - }, - { - "bufferView" : 1491, - "componentType" : 5126, - "count" : 125, - "max" : [ - -14.170490264892578, - 6.953225612640381, - 5.757254600524902 - ], - "min" : [ - -14.30150032043457, - 6.603631496429443, - 5.596310138702393 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1492, - "componentType" : 5126, - "count" : 125, - "type" : "VEC3" - }, - { - "bufferView" : 1493, - "componentType" : 5126, - "count" : 125, - "type" : "VEC2" - }, - { - "bufferView" : 1494, - "componentType" : 5123, - "count" : 222, - "type" : "SCALAR" - }, - { - "bufferView" : 1495, - "componentType" : 5126, - "count" : 127, - "max" : [ - 13.03104019165039, - 2.1761178970336914, - -6.291940689086914 - ], - "min" : [ - 12.900020599365234, - 1.826522946357727, - -6.452885627746582 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1496, - "componentType" : 5126, - "count" : 127, - "type" : "VEC3" - }, - { - "bufferView" : 1497, - "componentType" : 5126, - "count" : 127, - "type" : "VEC2" - }, - { - "bufferView" : 1498, - "componentType" : 5123, - "count" : 222, - "type" : "SCALAR" - }, - { - "bufferView" : 1499, - "componentType" : 5126, - "count" : 125, - "max" : [ - 13.03104019165039, - 2.176116943359375, - 5.757254123687744 - ], - "min" : [ - 12.900020599365234, - 1.826522946357727, - 5.59630823135376 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1500, - "componentType" : 5126, - "count" : 125, - "type" : "VEC3" - }, - { - "bufferView" : 1501, - "componentType" : 5126, - "count" : 125, - "type" : "VEC2" - }, - { - "bufferView" : 1502, - "componentType" : 5123, - "count" : 222, - "type" : "SCALAR" - }, - { - "bufferView" : 1503, - "componentType" : 5126, - "count" : 167, - "max" : [ - 13.032720565795898, - 2.176116943359375, - -2.2154388427734375 - ], - "min" : [ - 12.87656021118164, - 1.826522946357727, - -3.1005918979644775 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1504, - "componentType" : 5126, - "count" : 167, - "type" : "VEC3" - }, - { - "bufferView" : 1505, - "componentType" : 5126, - "count" : 167, - "type" : "VEC2" - }, - { - "bufferView" : 1506, - "componentType" : 5123, - "count" : 264, - "type" : "SCALAR" - }, - { - "bufferView" : 1507, - "componentType" : 5126, - "count" : 164, - "max" : [ - 13.032720565795898, - 2.176116943359375, - 2.4067718982696533 - ], - "min" : [ - 12.87656021118164, - 1.826522946357727, - 1.5216178894042969 - ], - "type" : "VEC3" - }, - { - "bufferView" : 1508, - "componentType" : 5126, - "count" : 164, - "type" : "VEC3" - }, - { - "bufferView" : 1509, - "componentType" : 5126, - "count" : 164, - "type" : "VEC2" - }, - { - "bufferView" : 1510, - "componentType" : 5123, - "count" : 264, - "type" : "SCALAR" - } - ], - "bufferViews" : [ - { - "buffer" : 0, - "byteLength" : 37908, - "byteOffset" : 0 - }, - { - "buffer" : 0, - "byteLength" : 37908, - "byteOffset" : 37908 - }, - { - "buffer" : 0, - "byteLength" : 25272, - "byteOffset" : 75816 - }, - { - "buffer" : 0, - "byteLength" : 21840, - "byteOffset" : 101088 - }, - { - "buffer" : 0, - "byteLength" : 6432, - "byteOffset" : 122928 - }, - { - "buffer" : 0, - "byteLength" : 6432, - "byteOffset" : 129360 - }, - { - "buffer" : 0, - "byteLength" : 4288, - "byteOffset" : 135792 - }, - { - "buffer" : 0, - "byteLength" : 2808, - "byteOffset" : 140080 - }, - { - "buffer" : 0, - "byteLength" : 14760, - "byteOffset" : 142888 - }, - { - "buffer" : 0, - "byteLength" : 14760, - "byteOffset" : 157648 - }, - { - "buffer" : 0, - "byteLength" : 9840, - "byteOffset" : 172408 - }, - { - "buffer" : 0, - "byteLength" : 13266, - "byteOffset" : 182248 - }, - { - "buffer" : 0, - "byteLength" : 9000, - "byteOffset" : 195516 - }, - { - "buffer" : 0, - "byteLength" : 9000, - "byteOffset" : 204516 - }, - { - "buffer" : 0, - "byteLength" : 6000, - "byteOffset" : 213516 - }, - { - "buffer" : 0, - "byteLength" : 8172, - "byteOffset" : 219516 - }, - { - "buffer" : 0, - "byteLength" : 240, - "byteOffset" : 227688 - }, - { - "buffer" : 0, - "byteLength" : 240, - "byteOffset" : 227928 - }, - { - "buffer" : 0, - "byteLength" : 160, - "byteOffset" : 228168 - }, - { - "buffer" : 0, - "byteLength" : 48, - "byteOffset" : 228328 - }, - { - "buffer" : 0, - "byteLength" : 1992, - "byteOffset" : 228376 - }, - { - "buffer" : 0, - "byteLength" : 1992, - "byteOffset" : 230368 - }, - { - "buffer" : 0, - "byteLength" : 1328, - "byteOffset" : 232360 - }, - { - "buffer" : 0, - "byteLength" : 600, - "byteOffset" : 233688 - }, - { - "buffer" : 0, - "byteLength" : 6576, - "byteOffset" : 234288 - }, - { - "buffer" : 0, - "byteLength" : 6576, - "byteOffset" : 240864 - }, - { - "buffer" : 0, - "byteLength" : 4384, - "byteOffset" : 247440 - }, - { - "buffer" : 0, - "byteLength" : 1680, - "byteOffset" : 251824 - }, - { - "buffer" : 0, - "byteLength" : 22176, - "byteOffset" : 253504 - }, - { - "buffer" : 0, - "byteLength" : 22176, - "byteOffset" : 275680 - }, - { - "buffer" : 0, - "byteLength" : 14784, - "byteOffset" : 297856 - }, - { - "buffer" : 0, - "byteLength" : 13992, - "byteOffset" : 312640 - }, - { - "buffer" : 0, - "byteLength" : 2772, - "byteOffset" : 326632 - }, - { - "buffer" : 0, - "byteLength" : 2772, - "byteOffset" : 329404 - }, - { - "buffer" : 0, - "byteLength" : 1848, - "byteOffset" : 332176 - }, - { - "buffer" : 0, - "byteLength" : 1092, - "byteOffset" : 334024 - }, - { - "buffer" : 0, - "byteLength" : 2748, - "byteOffset" : 335116 - }, - { - "buffer" : 0, - "byteLength" : 2748, - "byteOffset" : 337864 - }, - { - "buffer" : 0, - "byteLength" : 1832, - "byteOffset" : 340612 - }, - { - "buffer" : 0, - "byteLength" : 1092, - "byteOffset" : 342444 - }, - { - "buffer" : 0, - "byteLength" : 1956, - "byteOffset" : 343536 - }, - { - "buffer" : 0, - "byteLength" : 1956, - "byteOffset" : 345492 - }, - { - "buffer" : 0, - "byteLength" : 1304, - "byteOffset" : 347448 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 348752 - }, - { - "buffer" : 0, - "byteLength" : 1944, - "byteOffset" : 349280 - }, - { - "buffer" : 0, - "byteLength" : 1944, - "byteOffset" : 351224 - }, - { - "buffer" : 0, - "byteLength" : 1296, - "byteOffset" : 353168 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 354464 - }, - { - "buffer" : 0, - "byteLength" : 1956, - "byteOffset" : 354992 - }, - { - "buffer" : 0, - "byteLength" : 1956, - "byteOffset" : 356948 - }, - { - "buffer" : 0, - "byteLength" : 1304, - "byteOffset" : 358904 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 360208 - }, - { - "buffer" : 0, - "byteLength" : 1956, - "byteOffset" : 360736 - }, - { - "buffer" : 0, - "byteLength" : 1956, - "byteOffset" : 362692 - }, - { - "buffer" : 0, - "byteLength" : 1304, - "byteOffset" : 364648 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 365952 - }, - { - "buffer" : 0, - "byteLength" : 1956, - "byteOffset" : 366480 - }, - { - "buffer" : 0, - "byteLength" : 1956, - "byteOffset" : 368436 - }, - { - "buffer" : 0, - "byteLength" : 1304, - "byteOffset" : 370392 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 371696 - }, - { - "buffer" : 0, - "byteLength" : 1932, - "byteOffset" : 372224 - }, - { - "buffer" : 0, - "byteLength" : 1932, - "byteOffset" : 374156 - }, - { - "buffer" : 0, - "byteLength" : 1288, - "byteOffset" : 376088 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 377376 - }, - { - "buffer" : 0, - "byteLength" : 1956, - "byteOffset" : 377904 - }, - { - "buffer" : 0, - "byteLength" : 1956, - "byteOffset" : 379860 - }, - { - "buffer" : 0, - "byteLength" : 1304, - "byteOffset" : 381816 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 383120 - }, - { - "buffer" : 0, - "byteLength" : 1932, - "byteOffset" : 383648 - }, - { - "buffer" : 0, - "byteLength" : 1932, - "byteOffset" : 385580 - }, - { - "buffer" : 0, - "byteLength" : 1288, - "byteOffset" : 387512 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 388800 - }, - { - "buffer" : 0, - "byteLength" : 1956, - "byteOffset" : 389328 - }, - { - "buffer" : 0, - "byteLength" : 1956, - "byteOffset" : 391284 - }, - { - "buffer" : 0, - "byteLength" : 1304, - "byteOffset" : 393240 - }, - { - "buffer" : 0, - "byteLength" : 1932, - "byteOffset" : 394544 - }, - { - "buffer" : 0, - "byteLength" : 1932, - "byteOffset" : 396476 - }, - { - "buffer" : 0, - "byteLength" : 1288, - "byteOffset" : 398408 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 399696 - }, - { - "buffer" : 0, - "byteLength" : 2736, - "byteOffset" : 400224 - }, - { - "buffer" : 0, - "byteLength" : 2736, - "byteOffset" : 402960 - }, - { - "buffer" : 0, - "byteLength" : 1824, - "byteOffset" : 405696 - }, - { - "buffer" : 0, - "byteLength" : 1092, - "byteOffset" : 407520 - }, - { - "buffer" : 0, - "byteLength" : 1968, - "byteOffset" : 408612 - }, - { - "buffer" : 0, - "byteLength" : 1968, - "byteOffset" : 410580 - }, - { - "buffer" : 0, - "byteLength" : 1312, - "byteOffset" : 412548 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 413860 - }, - { - "buffer" : 0, - "byteLength" : 1932, - "byteOffset" : 414388 - }, - { - "buffer" : 0, - "byteLength" : 1932, - "byteOffset" : 416320 - }, - { - "buffer" : 0, - "byteLength" : 1288, - "byteOffset" : 418252 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 419540 - }, - { - "buffer" : 0, - "byteLength" : 1980, - "byteOffset" : 420068 - }, - { - "buffer" : 0, - "byteLength" : 1980, - "byteOffset" : 422048 - }, - { - "buffer" : 0, - "byteLength" : 1320, - "byteOffset" : 424028 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 425348 - }, - { - "buffer" : 0, - "byteLength" : 2004, - "byteOffset" : 425876 - }, - { - "buffer" : 0, - "byteLength" : 2004, - "byteOffset" : 427880 - }, - { - "buffer" : 0, - "byteLength" : 1336, - "byteOffset" : 429884 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 431220 - }, - { - "buffer" : 0, - "byteLength" : 1524, - "byteOffset" : 431748 - }, - { - "buffer" : 0, - "byteLength" : 1524, - "byteOffset" : 433272 - }, - { - "buffer" : 0, - "byteLength" : 1016, - "byteOffset" : 434796 - }, - { - "buffer" : 0, - "byteLength" : 444, - "byteOffset" : 435812 - }, - { - "buffer" : 0, - "byteLength" : 1512, - "byteOffset" : 436256 - }, - { - "buffer" : 0, - "byteLength" : 1512, - "byteOffset" : 437768 - }, - { - "buffer" : 0, - "byteLength" : 1008, - "byteOffset" : 439280 - }, - { - "buffer" : 0, - "byteLength" : 444, - "byteOffset" : 440288 - }, - { - "buffer" : 0, - "byteLength" : 1416, - "byteOffset" : 440732 - }, - { - "buffer" : 0, - "byteLength" : 1416, - "byteOffset" : 442148 - }, - { - "buffer" : 0, - "byteLength" : 944, - "byteOffset" : 443564 - }, - { - "buffer" : 0, - "byteLength" : 300, - "byteOffset" : 444508 - }, - { - "buffer" : 0, - "byteLength" : 156, - "byteOffset" : 444808 - }, - { - "buffer" : 0, - "byteLength" : 156, - "byteOffset" : 444964 - }, - { - "buffer" : 0, - "byteLength" : 104, - "byteOffset" : 445120 - }, - { - "buffer" : 0, - "byteLength" : 30, - "byteOffset" : 445224 - }, - { - "buffer" : 0, - "byteLength" : 5064, - "byteOffset" : 445256 - }, - { - "buffer" : 0, - "byteLength" : 5064, - "byteOffset" : 450320 - }, - { - "buffer" : 0, - "byteLength" : 3376, - "byteOffset" : 455384 - }, - { - "buffer" : 0, - "byteLength" : 2040, - "byteOffset" : 458760 - }, - { - "buffer" : 0, - "byteLength" : 4968, - "byteOffset" : 460800 - }, - { - "buffer" : 0, - "byteLength" : 4968, - "byteOffset" : 465768 - }, - { - "buffer" : 0, - "byteLength" : 3312, - "byteOffset" : 470736 - }, - { - "buffer" : 0, - "byteLength" : 2040, - "byteOffset" : 474048 - }, - { - "buffer" : 0, - "byteLength" : 2904, - "byteOffset" : 476088 - }, - { - "buffer" : 0, - "byteLength" : 2904, - "byteOffset" : 478992 - }, - { - "buffer" : 0, - "byteLength" : 1936, - "byteOffset" : 481896 - }, - { - "buffer" : 0, - "byteLength" : 1092, - "byteOffset" : 483832 - }, - { - "buffer" : 0, - "byteLength" : 4884, - "byteOffset" : 484924 - }, - { - "buffer" : 0, - "byteLength" : 4884, - "byteOffset" : 489808 - }, - { - "buffer" : 0, - "byteLength" : 3256, - "byteOffset" : 494692 - }, - { - "buffer" : 0, - "byteLength" : 2040, - "byteOffset" : 497948 - }, - { - "buffer" : 0, - "byteLength" : 5112, - "byteOffset" : 499988 - }, - { - "buffer" : 0, - "byteLength" : 5112, - "byteOffset" : 505100 - }, - { - "buffer" : 0, - "byteLength" : 3408, - "byteOffset" : 510212 - }, - { - "buffer" : 0, - "byteLength" : 2040, - "byteOffset" : 513620 - }, - { - "buffer" : 0, - "byteLength" : 420, - "byteOffset" : 515660 - }, - { - "buffer" : 0, - "byteLength" : 420, - "byteOffset" : 516080 - }, - { - "buffer" : 0, - "byteLength" : 280, - "byteOffset" : 516500 - }, - { - "buffer" : 0, - "byteLength" : 96, - "byteOffset" : 516780 - }, - { - "buffer" : 0, - "byteLength" : 27864, - "byteOffset" : 516876 - }, - { - "buffer" : 0, - "byteLength" : 27864, - "byteOffset" : 544740 - }, - { - "buffer" : 0, - "byteLength" : 18576, - "byteOffset" : 572604 - }, - { - "buffer" : 0, - "byteLength" : 11160, - "byteOffset" : 591180 - }, - { - "buffer" : 0, - "byteLength" : 27720, - "byteOffset" : 602340 - }, - { - "buffer" : 0, - "byteLength" : 27720, - "byteOffset" : 630060 - }, - { - "buffer" : 0, - "byteLength" : 18480, - "byteOffset" : 657780 - }, - { - "buffer" : 0, - "byteLength" : 11160, - "byteOffset" : 676260 - }, - { - "buffer" : 0, - "byteLength" : 13524, - "byteOffset" : 687420 - }, - { - "buffer" : 0, - "byteLength" : 13524, - "byteOffset" : 700944 - }, - { - "buffer" : 0, - "byteLength" : 9016, - "byteOffset" : 714468 - }, - { - "buffer" : 0, - "byteLength" : 7320, - "byteOffset" : 723484 - }, - { - "buffer" : 0, - "byteLength" : 480, - "byteOffset" : 730804 - }, - { - "buffer" : 0, - "byteLength" : 480, - "byteOffset" : 731284 - }, - { - "buffer" : 0, - "byteLength" : 320, - "byteOffset" : 731764 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 732084 - }, - { - "buffer" : 0, - "byteLength" : 768, - "byteOffset" : 732192 - }, - { - "buffer" : 0, - "byteLength" : 768, - "byteOffset" : 732960 - }, - { - "buffer" : 0, - "byteLength" : 512, - "byteOffset" : 733728 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 734240 - }, - { - "buffer" : 0, - "byteLength" : 480, - "byteOffset" : 734504 - }, - { - "buffer" : 0, - "byteLength" : 480, - "byteOffset" : 734984 - }, - { - "buffer" : 0, - "byteLength" : 320, - "byteOffset" : 735464 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 735784 - }, - { - "buffer" : 0, - "byteLength" : 972, - "byteOffset" : 735892 - }, - { - "buffer" : 0, - "byteLength" : 972, - "byteOffset" : 736864 - }, - { - "buffer" : 0, - "byteLength" : 648, - "byteOffset" : 737836 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 738484 - }, - { - "buffer" : 0, - "byteLength" : 2712, - "byteOffset" : 738748 - }, - { - "buffer" : 0, - "byteLength" : 2712, - "byteOffset" : 741460 - }, - { - "buffer" : 0, - "byteLength" : 1808, - "byteOffset" : 744172 - }, - { - "buffer" : 0, - "byteLength" : 1092, - "byteOffset" : 745980 - }, - { - "buffer" : 0, - "byteLength" : 444, - "byteOffset" : 747072 - }, - { - "buffer" : 0, - "byteLength" : 444, - "byteOffset" : 747516 - }, - { - "buffer" : 0, - "byteLength" : 296, - "byteOffset" : 747960 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 748256 - }, - { - "buffer" : 0, - "byteLength" : 792, - "byteOffset" : 748364 - }, - { - "buffer" : 0, - "byteLength" : 792, - "byteOffset" : 749156 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 749948 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 750476 - }, - { - "buffer" : 0, - "byteLength" : 360, - "byteOffset" : 750740 - }, - { - "buffer" : 0, - "byteLength" : 360, - "byteOffset" : 751100 - }, - { - "buffer" : 0, - "byteLength" : 240, - "byteOffset" : 751460 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 751700 - }, - { - "buffer" : 0, - "byteLength" : 1032, - "byteOffset" : 751808 - }, - { - "buffer" : 0, - "byteLength" : 1032, - "byteOffset" : 752840 - }, - { - "buffer" : 0, - "byteLength" : 688, - "byteOffset" : 753872 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 754560 - }, - { - "buffer" : 0, - "byteLength" : 3504, - "byteOffset" : 754824 - }, - { - "buffer" : 0, - "byteLength" : 3504, - "byteOffset" : 758328 - }, - { - "buffer" : 0, - "byteLength" : 2336, - "byteOffset" : 761832 - }, - { - "buffer" : 0, - "byteLength" : 1800, - "byteOffset" : 764168 - }, - { - "buffer" : 0, - "byteLength" : 2508, - "byteOffset" : 765968 - }, - { - "buffer" : 0, - "byteLength" : 2508, - "byteOffset" : 768476 - }, - { - "buffer" : 0, - "byteLength" : 1672, - "byteOffset" : 770984 - }, - { - "buffer" : 0, - "byteLength" : 996, - "byteOffset" : 772656 - }, - { - "buffer" : 0, - "byteLength" : 13524, - "byteOffset" : 773652 - }, - { - "buffer" : 0, - "byteLength" : 13524, - "byteOffset" : 787176 - }, - { - "buffer" : 0, - "byteLength" : 9016, - "byteOffset" : 800700 - }, - { - "buffer" : 0, - "byteLength" : 7320, - "byteOffset" : 809716 - }, - { - "buffer" : 0, - "byteLength" : 432, - "byteOffset" : 817036 - }, - { - "buffer" : 0, - "byteLength" : 432, - "byteOffset" : 817468 - }, - { - "buffer" : 0, - "byteLength" : 288, - "byteOffset" : 817900 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 818188 - }, - { - "buffer" : 0, - "byteLength" : 912, - "byteOffset" : 818296 - }, - { - "buffer" : 0, - "byteLength" : 912, - "byteOffset" : 819208 - }, - { - "buffer" : 0, - "byteLength" : 608, - "byteOffset" : 820120 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 820728 - }, - { - "buffer" : 0, - "byteLength" : 444, - "byteOffset" : 820992 - }, - { - "buffer" : 0, - "byteLength" : 444, - "byteOffset" : 821436 - }, - { - "buffer" : 0, - "byteLength" : 296, - "byteOffset" : 821880 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 822176 - }, - { - "buffer" : 0, - "byteLength" : 2772, - "byteOffset" : 822284 - }, - { - "buffer" : 0, - "byteLength" : 2772, - "byteOffset" : 825056 - }, - { - "buffer" : 0, - "byteLength" : 1848, - "byteOffset" : 827828 - }, - { - "buffer" : 0, - "byteLength" : 1092, - "byteOffset" : 829676 - }, - { - "buffer" : 0, - "byteLength" : 1116, - "byteOffset" : 830768 - }, - { - "buffer" : 0, - "byteLength" : 1116, - "byteOffset" : 831884 - }, - { - "buffer" : 0, - "byteLength" : 744, - "byteOffset" : 833000 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 833744 - }, - { - "buffer" : 0, - "byteLength" : 456, - "byteOffset" : 834008 - }, - { - "buffer" : 0, - "byteLength" : 456, - "byteOffset" : 834464 - }, - { - "buffer" : 0, - "byteLength" : 304, - "byteOffset" : 834920 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 835224 - }, - { - "buffer" : 0, - "byteLength" : 756, - "byteOffset" : 835332 - }, - { - "buffer" : 0, - "byteLength" : 756, - "byteOffset" : 836088 - }, - { - "buffer" : 0, - "byteLength" : 504, - "byteOffset" : 836844 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 837348 - }, - { - "buffer" : 0, - "byteLength" : 432, - "byteOffset" : 837612 - }, - { - "buffer" : 0, - "byteLength" : 432, - "byteOffset" : 838044 - }, - { - "buffer" : 0, - "byteLength" : 288, - "byteOffset" : 838476 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 838764 - }, - { - "buffer" : 0, - "byteLength" : 1152, - "byteOffset" : 838872 - }, - { - "buffer" : 0, - "byteLength" : 1152, - "byteOffset" : 840024 - }, - { - "buffer" : 0, - "byteLength" : 768, - "byteOffset" : 841176 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 841944 - }, - { - "buffer" : 0, - "byteLength" : 3216, - "byteOffset" : 842208 - }, - { - "buffer" : 0, - "byteLength" : 3216, - "byteOffset" : 845424 - }, - { - "buffer" : 0, - "byteLength" : 2144, - "byteOffset" : 848640 - }, - { - "buffer" : 0, - "byteLength" : 1800, - "byteOffset" : 850784 - }, - { - "buffer" : 0, - "byteLength" : 2568, - "byteOffset" : 852584 - }, - { - "buffer" : 0, - "byteLength" : 2568, - "byteOffset" : 855152 - }, - { - "buffer" : 0, - "byteLength" : 1712, - "byteOffset" : 857720 - }, - { - "buffer" : 0, - "byteLength" : 996, - "byteOffset" : 859432 - }, - { - "buffer" : 0, - "byteLength" : 13524, - "byteOffset" : 860428 - }, - { - "buffer" : 0, - "byteLength" : 13524, - "byteOffset" : 873952 - }, - { - "buffer" : 0, - "byteLength" : 9016, - "byteOffset" : 887476 - }, - { - "buffer" : 0, - "byteLength" : 7320, - "byteOffset" : 896492 - }, - { - "buffer" : 0, - "byteLength" : 420, - "byteOffset" : 903812 - }, - { - "buffer" : 0, - "byteLength" : 420, - "byteOffset" : 904232 - }, - { - "buffer" : 0, - "byteLength" : 280, - "byteOffset" : 904652 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 904932 - }, - { - "buffer" : 0, - "byteLength" : 900, - "byteOffset" : 905040 - }, - { - "buffer" : 0, - "byteLength" : 900, - "byteOffset" : 905940 - }, - { - "buffer" : 0, - "byteLength" : 600, - "byteOffset" : 906840 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 907440 - }, - { - "buffer" : 0, - "byteLength" : 2928, - "byteOffset" : 907704 - }, - { - "buffer" : 0, - "byteLength" : 2928, - "byteOffset" : 910632 - }, - { - "buffer" : 0, - "byteLength" : 1952, - "byteOffset" : 913560 - }, - { - "buffer" : 0, - "byteLength" : 1092, - "byteOffset" : 915512 - }, - { - "buffer" : 0, - "byteLength" : 432, - "byteOffset" : 916604 - }, - { - "buffer" : 0, - "byteLength" : 432, - "byteOffset" : 917036 - }, - { - "buffer" : 0, - "byteLength" : 288, - "byteOffset" : 917468 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 917756 - }, - { - "buffer" : 0, - "byteLength" : 1116, - "byteOffset" : 917864 - }, - { - "buffer" : 0, - "byteLength" : 1116, - "byteOffset" : 918980 - }, - { - "buffer" : 0, - "byteLength" : 744, - "byteOffset" : 920096 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 920840 - }, - { - "buffer" : 0, - "byteLength" : 420, - "byteOffset" : 921104 - }, - { - "buffer" : 0, - "byteLength" : 420, - "byteOffset" : 921524 - }, - { - "buffer" : 0, - "byteLength" : 280, - "byteOffset" : 921944 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 922224 - }, - { - "buffer" : 0, - "byteLength" : 828, - "byteOffset" : 922332 - }, - { - "buffer" : 0, - "byteLength" : 828, - "byteOffset" : 923160 - }, - { - "buffer" : 0, - "byteLength" : 552, - "byteOffset" : 923988 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 924540 - }, - { - "buffer" : 0, - "byteLength" : 480, - "byteOffset" : 924804 - }, - { - "buffer" : 0, - "byteLength" : 480, - "byteOffset" : 925284 - }, - { - "buffer" : 0, - "byteLength" : 320, - "byteOffset" : 925764 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 926084 - }, - { - "buffer" : 0, - "byteLength" : 996, - "byteOffset" : 926192 - }, - { - "buffer" : 0, - "byteLength" : 996, - "byteOffset" : 927188 - }, - { - "buffer" : 0, - "byteLength" : 664, - "byteOffset" : 928184 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 928848 - }, - { - "buffer" : 0, - "byteLength" : 3228, - "byteOffset" : 929112 - }, - { - "buffer" : 0, - "byteLength" : 3228, - "byteOffset" : 932340 - }, - { - "buffer" : 0, - "byteLength" : 2152, - "byteOffset" : 935568 - }, - { - "buffer" : 0, - "byteLength" : 1800, - "byteOffset" : 937720 - }, - { - "buffer" : 0, - "byteLength" : 2520, - "byteOffset" : 939520 - }, - { - "buffer" : 0, - "byteLength" : 2520, - "byteOffset" : 942040 - }, - { - "buffer" : 0, - "byteLength" : 1680, - "byteOffset" : 944560 - }, - { - "buffer" : 0, - "byteLength" : 996, - "byteOffset" : 946240 - }, - { - "buffer" : 0, - "byteLength" : 13524, - "byteOffset" : 947236 - }, - { - "buffer" : 0, - "byteLength" : 13524, - "byteOffset" : 960760 - }, - { - "buffer" : 0, - "byteLength" : 9016, - "byteOffset" : 974284 - }, - { - "buffer" : 0, - "byteLength" : 7320, - "byteOffset" : 983300 - }, - { - "buffer" : 0, - "byteLength" : 492, - "byteOffset" : 990620 - }, - { - "buffer" : 0, - "byteLength" : 492, - "byteOffset" : 991112 - }, - { - "buffer" : 0, - "byteLength" : 328, - "byteOffset" : 991604 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 991932 - }, - { - "buffer" : 0, - "byteLength" : 2832, - "byteOffset" : 992040 - }, - { - "buffer" : 0, - "byteLength" : 2832, - "byteOffset" : 994872 - }, - { - "buffer" : 0, - "byteLength" : 1888, - "byteOffset" : 997704 - }, - { - "buffer" : 0, - "byteLength" : 1092, - "byteOffset" : 999592 - }, - { - "buffer" : 0, - "byteLength" : 948, - "byteOffset" : 1000684 - }, - { - "buffer" : 0, - "byteLength" : 948, - "byteOffset" : 1001632 - }, - { - "buffer" : 0, - "byteLength" : 632, - "byteOffset" : 1002580 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1003212 - }, - { - "buffer" : 0, - "byteLength" : 432, - "byteOffset" : 1003476 - }, - { - "buffer" : 0, - "byteLength" : 432, - "byteOffset" : 1003908 - }, - { - "buffer" : 0, - "byteLength" : 288, - "byteOffset" : 1004340 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 1004628 - }, - { - "buffer" : 0, - "byteLength" : 1056, - "byteOffset" : 1004736 - }, - { - "buffer" : 0, - "byteLength" : 1056, - "byteOffset" : 1005792 - }, - { - "buffer" : 0, - "byteLength" : 704, - "byteOffset" : 1006848 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1007552 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 1007816 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 1008344 - }, - { - "buffer" : 0, - "byteLength" : 352, - "byteOffset" : 1008872 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 1009224 - }, - { - "buffer" : 0, - "byteLength" : 804, - "byteOffset" : 1009332 - }, - { - "buffer" : 0, - "byteLength" : 804, - "byteOffset" : 1010136 - }, - { - "buffer" : 0, - "byteLength" : 536, - "byteOffset" : 1010940 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1011476 - }, - { - "buffer" : 0, - "byteLength" : 432, - "byteOffset" : 1011740 - }, - { - "buffer" : 0, - "byteLength" : 432, - "byteOffset" : 1012172 - }, - { - "buffer" : 0, - "byteLength" : 288, - "byteOffset" : 1012604 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 1012892 - }, - { - "buffer" : 0, - "byteLength" : 1092, - "byteOffset" : 1013000 - }, - { - "buffer" : 0, - "byteLength" : 1092, - "byteOffset" : 1014092 - }, - { - "buffer" : 0, - "byteLength" : 728, - "byteOffset" : 1015184 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1015912 - }, - { - "buffer" : 0, - "byteLength" : 3204, - "byteOffset" : 1016176 - }, - { - "buffer" : 0, - "byteLength" : 3204, - "byteOffset" : 1019380 - }, - { - "buffer" : 0, - "byteLength" : 2136, - "byteOffset" : 1022584 - }, - { - "buffer" : 0, - "byteLength" : 1800, - "byteOffset" : 1024720 - }, - { - "buffer" : 0, - "byteLength" : 2556, - "byteOffset" : 1026520 - }, - { - "buffer" : 0, - "byteLength" : 2556, - "byteOffset" : 1029076 - }, - { - "buffer" : 0, - "byteLength" : 1704, - "byteOffset" : 1031632 - }, - { - "buffer" : 0, - "byteLength" : 996, - "byteOffset" : 1033336 - }, - { - "buffer" : 0, - "byteLength" : 13524, - "byteOffset" : 1034332 - }, - { - "buffer" : 0, - "byteLength" : 13524, - "byteOffset" : 1047856 - }, - { - "buffer" : 0, - "byteLength" : 9016, - "byteOffset" : 1061380 - }, - { - "buffer" : 0, - "byteLength" : 7320, - "byteOffset" : 1070396 - }, - { - "buffer" : 0, - "byteLength" : 56988, - "byteOffset" : 1077716 - }, - { - "buffer" : 0, - "byteLength" : 56988, - "byteOffset" : 1134704 - }, - { - "buffer" : 0, - "byteLength" : 37992, - "byteOffset" : 1191692 - }, - { - "buffer" : 0, - "byteLength" : 17376, - "byteOffset" : 1229684 - }, - { - "buffer" : 0, - "byteLength" : 444, - "byteOffset" : 1247060 - }, - { - "buffer" : 0, - "byteLength" : 444, - "byteOffset" : 1247504 - }, - { - "buffer" : 0, - "byteLength" : 296, - "byteOffset" : 1247948 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 1248244 - }, - { - "buffer" : 0, - "byteLength" : 960, - "byteOffset" : 1248352 - }, - { - "buffer" : 0, - "byteLength" : 960, - "byteOffset" : 1249312 - }, - { - "buffer" : 0, - "byteLength" : 640, - "byteOffset" : 1250272 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1250912 - }, - { - "buffer" : 0, - "byteLength" : 468, - "byteOffset" : 1251176 - }, - { - "buffer" : 0, - "byteLength" : 468, - "byteOffset" : 1251644 - }, - { - "buffer" : 0, - "byteLength" : 312, - "byteOffset" : 1252112 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 1252424 - }, - { - "buffer" : 0, - "byteLength" : 972, - "byteOffset" : 1252532 - }, - { - "buffer" : 0, - "byteLength" : 972, - "byteOffset" : 1253504 - }, - { - "buffer" : 0, - "byteLength" : 648, - "byteOffset" : 1254476 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1255124 - }, - { - "buffer" : 0, - "byteLength" : 456, - "byteOffset" : 1255388 - }, - { - "buffer" : 0, - "byteLength" : 456, - "byteOffset" : 1255844 - }, - { - "buffer" : 0, - "byteLength" : 304, - "byteOffset" : 1256300 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 1256604 - }, - { - "buffer" : 0, - "byteLength" : 864, - "byteOffset" : 1256712 - }, - { - "buffer" : 0, - "byteLength" : 864, - "byteOffset" : 1257576 - }, - { - "buffer" : 0, - "byteLength" : 576, - "byteOffset" : 1258440 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1259016 - }, - { - "buffer" : 0, - "byteLength" : 420, - "byteOffset" : 1259280 - }, - { - "buffer" : 0, - "byteLength" : 420, - "byteOffset" : 1259700 - }, - { - "buffer" : 0, - "byteLength" : 280, - "byteOffset" : 1260120 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 1260400 - }, - { - "buffer" : 0, - "byteLength" : 1104, - "byteOffset" : 1260508 - }, - { - "buffer" : 0, - "byteLength" : 1104, - "byteOffset" : 1261612 - }, - { - "buffer" : 0, - "byteLength" : 736, - "byteOffset" : 1262716 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1263452 - }, - { - "buffer" : 0, - "byteLength" : 3204, - "byteOffset" : 1263716 - }, - { - "buffer" : 0, - "byteLength" : 3204, - "byteOffset" : 1266920 - }, - { - "buffer" : 0, - "byteLength" : 2136, - "byteOffset" : 1270124 - }, - { - "buffer" : 0, - "byteLength" : 1800, - "byteOffset" : 1272260 - }, - { - "buffer" : 0, - "byteLength" : 2544, - "byteOffset" : 1274060 - }, - { - "buffer" : 0, - "byteLength" : 2544, - "byteOffset" : 1276604 - }, - { - "buffer" : 0, - "byteLength" : 1696, - "byteOffset" : 1279148 - }, - { - "buffer" : 0, - "byteLength" : 996, - "byteOffset" : 1280844 - }, - { - "buffer" : 0, - "byteLength" : 300, - "byteOffset" : 1281840 - }, - { - "buffer" : 0, - "byteLength" : 300, - "byteOffset" : 1282140 - }, - { - "buffer" : 0, - "byteLength" : 200, - "byteOffset" : 1282440 - }, - { - "buffer" : 0, - "byteLength" : 96, - "byteOffset" : 1282640 - }, - { - "buffer" : 0, - "byteLength" : 13524, - "byteOffset" : 1282736 - }, - { - "buffer" : 0, - "byteLength" : 13524, - "byteOffset" : 1296260 - }, - { - "buffer" : 0, - "byteLength" : 9016, - "byteOffset" : 1309784 - }, - { - "buffer" : 0, - "byteLength" : 7320, - "byteOffset" : 1318800 - }, - { - "buffer" : 0, - "byteLength" : 456, - "byteOffset" : 1326120 - }, - { - "buffer" : 0, - "byteLength" : 456, - "byteOffset" : 1326576 - }, - { - "buffer" : 0, - "byteLength" : 304, - "byteOffset" : 1327032 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 1327336 - }, - { - "buffer" : 0, - "byteLength" : 960, - "byteOffset" : 1327444 - }, - { - "buffer" : 0, - "byteLength" : 960, - "byteOffset" : 1328404 - }, - { - "buffer" : 0, - "byteLength" : 640, - "byteOffset" : 1329364 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1330004 - }, - { - "buffer" : 0, - "byteLength" : 504, - "byteOffset" : 1330268 - }, - { - "buffer" : 0, - "byteLength" : 504, - "byteOffset" : 1330772 - }, - { - "buffer" : 0, - "byteLength" : 336, - "byteOffset" : 1331276 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 1331612 - }, - { - "buffer" : 0, - "byteLength" : 1044, - "byteOffset" : 1331720 - }, - { - "buffer" : 0, - "byteLength" : 1044, - "byteOffset" : 1332764 - }, - { - "buffer" : 0, - "byteLength" : 696, - "byteOffset" : 1333808 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1334504 - }, - { - "buffer" : 0, - "byteLength" : 480, - "byteOffset" : 1334768 - }, - { - "buffer" : 0, - "byteLength" : 480, - "byteOffset" : 1335248 - }, - { - "buffer" : 0, - "byteLength" : 320, - "byteOffset" : 1335728 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 1336048 - }, - { - "buffer" : 0, - "byteLength" : 732, - "byteOffset" : 1336156 - }, - { - "buffer" : 0, - "byteLength" : 732, - "byteOffset" : 1336888 - }, - { - "buffer" : 0, - "byteLength" : 488, - "byteOffset" : 1337620 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1338108 - }, - { - "buffer" : 0, - "byteLength" : 456, - "byteOffset" : 1338372 - }, - { - "buffer" : 0, - "byteLength" : 456, - "byteOffset" : 1338828 - }, - { - "buffer" : 0, - "byteLength" : 304, - "byteOffset" : 1339284 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 1339588 - }, - { - "buffer" : 0, - "byteLength" : 1164, - "byteOffset" : 1339696 - }, - { - "buffer" : 0, - "byteLength" : 1164, - "byteOffset" : 1340860 - }, - { - "buffer" : 0, - "byteLength" : 776, - "byteOffset" : 1342024 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1342800 - }, - { - "buffer" : 0, - "byteLength" : 3228, - "byteOffset" : 1343064 - }, - { - "buffer" : 0, - "byteLength" : 3228, - "byteOffset" : 1346292 - }, - { - "buffer" : 0, - "byteLength" : 2152, - "byteOffset" : 1349520 - }, - { - "buffer" : 0, - "byteLength" : 1800, - "byteOffset" : 1351672 - }, - { - "buffer" : 0, - "byteLength" : 22176, - "byteOffset" : 1353472 - }, - { - "buffer" : 0, - "byteLength" : 22176, - "byteOffset" : 1375648 - }, - { - "buffer" : 0, - "byteLength" : 14784, - "byteOffset" : 1397824 - }, - { - "buffer" : 0, - "byteLength" : 13992, - "byteOffset" : 1412608 - }, - { - "buffer" : 0, - "byteLength" : 2556, - "byteOffset" : 1426600 - }, - { - "buffer" : 0, - "byteLength" : 2556, - "byteOffset" : 1429156 - }, - { - "buffer" : 0, - "byteLength" : 1704, - "byteOffset" : 1431712 - }, - { - "buffer" : 0, - "byteLength" : 996, - "byteOffset" : 1433416 - }, - { - "buffer" : 0, - "byteLength" : 13524, - "byteOffset" : 1434412 - }, - { - "buffer" : 0, - "byteLength" : 13524, - "byteOffset" : 1447936 - }, - { - "buffer" : 0, - "byteLength" : 9016, - "byteOffset" : 1461460 - }, - { - "buffer" : 0, - "byteLength" : 7320, - "byteOffset" : 1470476 - }, - { - "buffer" : 0, - "byteLength" : 456, - "byteOffset" : 1477796 - }, - { - "buffer" : 0, - "byteLength" : 456, - "byteOffset" : 1478252 - }, - { - "buffer" : 0, - "byteLength" : 304, - "byteOffset" : 1478708 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 1479012 - }, - { - "buffer" : 0, - "byteLength" : 816, - "byteOffset" : 1479120 - }, - { - "buffer" : 0, - "byteLength" : 816, - "byteOffset" : 1479936 - }, - { - "buffer" : 0, - "byteLength" : 544, - "byteOffset" : 1480752 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1481296 - }, - { - "buffer" : 0, - "byteLength" : 468, - "byteOffset" : 1481560 - }, - { - "buffer" : 0, - "byteLength" : 468, - "byteOffset" : 1482028 - }, - { - "buffer" : 0, - "byteLength" : 312, - "byteOffset" : 1482496 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 1482808 - }, - { - "buffer" : 0, - "byteLength" : 1080, - "byteOffset" : 1482916 - }, - { - "buffer" : 0, - "byteLength" : 1080, - "byteOffset" : 1483996 - }, - { - "buffer" : 0, - "byteLength" : 720, - "byteOffset" : 1485076 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1485796 - }, - { - "buffer" : 0, - "byteLength" : 504, - "byteOffset" : 1486060 - }, - { - "buffer" : 0, - "byteLength" : 504, - "byteOffset" : 1486564 - }, - { - "buffer" : 0, - "byteLength" : 336, - "byteOffset" : 1487068 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 1487404 - }, - { - "buffer" : 0, - "byteLength" : 840, - "byteOffset" : 1487512 - }, - { - "buffer" : 0, - "byteLength" : 840, - "byteOffset" : 1488352 - }, - { - "buffer" : 0, - "byteLength" : 560, - "byteOffset" : 1489192 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1489752 - }, - { - "buffer" : 0, - "byteLength" : 444, - "byteOffset" : 1490016 - }, - { - "buffer" : 0, - "byteLength" : 444, - "byteOffset" : 1490460 - }, - { - "buffer" : 0, - "byteLength" : 296, - "byteOffset" : 1490904 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 1491200 - }, - { - "buffer" : 0, - "byteLength" : 1020, - "byteOffset" : 1491308 - }, - { - "buffer" : 0, - "byteLength" : 1020, - "byteOffset" : 1492328 - }, - { - "buffer" : 0, - "byteLength" : 680, - "byteOffset" : 1493348 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1494028 - }, - { - "buffer" : 0, - "byteLength" : 10488, - "byteOffset" : 1494292 - }, - { - "buffer" : 0, - "byteLength" : 10488, - "byteOffset" : 1504780 - }, - { - "buffer" : 0, - "byteLength" : 6992, - "byteOffset" : 1515268 - }, - { - "buffer" : 0, - "byteLength" : 3288, - "byteOffset" : 1522260 - }, - { - "buffer" : 0, - "byteLength" : 3228, - "byteOffset" : 1525548 - }, - { - "buffer" : 0, - "byteLength" : 3228, - "byteOffset" : 1528776 - }, - { - "buffer" : 0, - "byteLength" : 2152, - "byteOffset" : 1532004 - }, - { - "buffer" : 0, - "byteLength" : 1800, - "byteOffset" : 1534156 - }, - { - "buffer" : 0, - "byteLength" : 2496, - "byteOffset" : 1535956 - }, - { - "buffer" : 0, - "byteLength" : 2496, - "byteOffset" : 1538452 - }, - { - "buffer" : 0, - "byteLength" : 1664, - "byteOffset" : 1540948 - }, - { - "buffer" : 0, - "byteLength" : 996, - "byteOffset" : 1542612 - }, - { - "buffer" : 0, - "byteLength" : 13524, - "byteOffset" : 1543608 - }, - { - "buffer" : 0, - "byteLength" : 13524, - "byteOffset" : 1557132 - }, - { - "buffer" : 0, - "byteLength" : 9016, - "byteOffset" : 1570656 - }, - { - "buffer" : 0, - "byteLength" : 7320, - "byteOffset" : 1579672 - }, - { - "buffer" : 0, - "byteLength" : 444, - "byteOffset" : 1586992 - }, - { - "buffer" : 0, - "byteLength" : 444, - "byteOffset" : 1587436 - }, - { - "buffer" : 0, - "byteLength" : 296, - "byteOffset" : 1587880 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 1588176 - }, - { - "buffer" : 0, - "byteLength" : 864, - "byteOffset" : 1588284 - }, - { - "buffer" : 0, - "byteLength" : 864, - "byteOffset" : 1589148 - }, - { - "buffer" : 0, - "byteLength" : 576, - "byteOffset" : 1590012 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1590588 - }, - { - "buffer" : 0, - "byteLength" : 432, - "byteOffset" : 1590852 - }, - { - "buffer" : 0, - "byteLength" : 432, - "byteOffset" : 1591284 - }, - { - "buffer" : 0, - "byteLength" : 288, - "byteOffset" : 1591716 - }, - { - "buffer" : 0, - "byteLength" : 1008, - "byteOffset" : 1592004 - }, - { - "buffer" : 0, - "byteLength" : 1008, - "byteOffset" : 1593012 - }, - { - "buffer" : 0, - "byteLength" : 672, - "byteOffset" : 1594020 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1594692 - }, - { - "buffer" : 0, - "byteLength" : 444, - "byteOffset" : 1594956 - }, - { - "buffer" : 0, - "byteLength" : 444, - "byteOffset" : 1595400 - }, - { - "buffer" : 0, - "byteLength" : 296, - "byteOffset" : 1595844 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 1596140 - }, - { - "buffer" : 0, - "byteLength" : 864, - "byteOffset" : 1596248 - }, - { - "buffer" : 0, - "byteLength" : 864, - "byteOffset" : 1597112 - }, - { - "buffer" : 0, - "byteLength" : 576, - "byteOffset" : 1597976 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1598552 - }, - { - "buffer" : 0, - "byteLength" : 420, - "byteOffset" : 1598816 - }, - { - "buffer" : 0, - "byteLength" : 420, - "byteOffset" : 1599236 - }, - { - "buffer" : 0, - "byteLength" : 280, - "byteOffset" : 1599656 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 1599936 - }, - { - "buffer" : 0, - "byteLength" : 10788, - "byteOffset" : 1600044 - }, - { - "buffer" : 0, - "byteLength" : 10788, - "byteOffset" : 1610832 - }, - { - "buffer" : 0, - "byteLength" : 7192, - "byteOffset" : 1621620 - }, - { - "buffer" : 0, - "byteLength" : 3288, - "byteOffset" : 1628812 - }, - { - "buffer" : 0, - "byteLength" : 984, - "byteOffset" : 1632100 - }, - { - "buffer" : 0, - "byteLength" : 984, - "byteOffset" : 1633084 - }, - { - "buffer" : 0, - "byteLength" : 656, - "byteOffset" : 1634068 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1634724 - }, - { - "buffer" : 0, - "byteLength" : 3192, - "byteOffset" : 1634988 - }, - { - "buffer" : 0, - "byteLength" : 3192, - "byteOffset" : 1638180 - }, - { - "buffer" : 0, - "byteLength" : 2128, - "byteOffset" : 1641372 - }, - { - "buffer" : 0, - "byteLength" : 1800, - "byteOffset" : 1643500 - }, - { - "buffer" : 0, - "byteLength" : 2484, - "byteOffset" : 1645300 - }, - { - "buffer" : 0, - "byteLength" : 2484, - "byteOffset" : 1647784 - }, - { - "buffer" : 0, - "byteLength" : 1656, - "byteOffset" : 1650268 - }, - { - "buffer" : 0, - "byteLength" : 996, - "byteOffset" : 1651924 - }, - { - "buffer" : 0, - "byteLength" : 13524, - "byteOffset" : 1652920 - }, - { - "buffer" : 0, - "byteLength" : 13524, - "byteOffset" : 1666444 - }, - { - "buffer" : 0, - "byteLength" : 9016, - "byteOffset" : 1679968 - }, - { - "buffer" : 0, - "byteLength" : 7320, - "byteOffset" : 1688984 - }, - { - "buffer" : 0, - "byteLength" : 468, - "byteOffset" : 1696304 - }, - { - "buffer" : 0, - "byteLength" : 468, - "byteOffset" : 1696772 - }, - { - "buffer" : 0, - "byteLength" : 312, - "byteOffset" : 1697240 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 1697552 - }, - { - "buffer" : 0, - "byteLength" : 840, - "byteOffset" : 1697660 - }, - { - "buffer" : 0, - "byteLength" : 840, - "byteOffset" : 1698500 - }, - { - "buffer" : 0, - "byteLength" : 560, - "byteOffset" : 1699340 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1699900 - }, - { - "buffer" : 0, - "byteLength" : 420, - "byteOffset" : 1700164 - }, - { - "buffer" : 0, - "byteLength" : 420, - "byteOffset" : 1700584 - }, - { - "buffer" : 0, - "byteLength" : 280, - "byteOffset" : 1701004 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 1701284 - }, - { - "buffer" : 0, - "byteLength" : 1128, - "byteOffset" : 1701392 - }, - { - "buffer" : 0, - "byteLength" : 1128, - "byteOffset" : 1702520 - }, - { - "buffer" : 0, - "byteLength" : 752, - "byteOffset" : 1703648 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1704400 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 1704664 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 1705192 - }, - { - "buffer" : 0, - "byteLength" : 352, - "byteOffset" : 1705720 - }, - { - "buffer" : 0, - "byteLength" : 828, - "byteOffset" : 1706072 - }, - { - "buffer" : 0, - "byteLength" : 828, - "byteOffset" : 1706900 - }, - { - "buffer" : 0, - "byteLength" : 552, - "byteOffset" : 1707728 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1708280 - }, - { - "buffer" : 0, - "byteLength" : 8352, - "byteOffset" : 1708544 - }, - { - "buffer" : 0, - "byteLength" : 8352, - "byteOffset" : 1716896 - }, - { - "buffer" : 0, - "byteLength" : 5568, - "byteOffset" : 1725248 - }, - { - "buffer" : 0, - "byteLength" : 2376, - "byteOffset" : 1730816 - }, - { - "buffer" : 0, - "byteLength" : 432, - "byteOffset" : 1733192 - }, - { - "buffer" : 0, - "byteLength" : 432, - "byteOffset" : 1733624 - }, - { - "buffer" : 0, - "byteLength" : 288, - "byteOffset" : 1734056 - }, - { - "buffer" : 0, - "byteLength" : 1020, - "byteOffset" : 1734344 - }, - { - "buffer" : 0, - "byteLength" : 1020, - "byteOffset" : 1735364 - }, - { - "buffer" : 0, - "byteLength" : 680, - "byteOffset" : 1736384 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1737064 - }, - { - "buffer" : 0, - "byteLength" : 3204, - "byteOffset" : 1737328 - }, - { - "buffer" : 0, - "byteLength" : 3204, - "byteOffset" : 1740532 - }, - { - "buffer" : 0, - "byteLength" : 2136, - "byteOffset" : 1743736 - }, - { - "buffer" : 0, - "byteLength" : 1800, - "byteOffset" : 1745872 - }, - { - "buffer" : 0, - "byteLength" : 2520, - "byteOffset" : 1747672 - }, - { - "buffer" : 0, - "byteLength" : 2520, - "byteOffset" : 1750192 - }, - { - "buffer" : 0, - "byteLength" : 1680, - "byteOffset" : 1752712 - }, - { - "buffer" : 0, - "byteLength" : 996, - "byteOffset" : 1754392 - }, - { - "buffer" : 0, - "byteLength" : 13524, - "byteOffset" : 1755388 - }, - { - "buffer" : 0, - "byteLength" : 13524, - "byteOffset" : 1768912 - }, - { - "buffer" : 0, - "byteLength" : 9016, - "byteOffset" : 1782436 - }, - { - "buffer" : 0, - "byteLength" : 7320, - "byteOffset" : 1791452 - }, - { - "buffer" : 0, - "byteLength" : 420, - "byteOffset" : 1798772 - }, - { - "buffer" : 0, - "byteLength" : 420, - "byteOffset" : 1799192 - }, - { - "buffer" : 0, - "byteLength" : 280, - "byteOffset" : 1799612 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 1799892 - }, - { - "buffer" : 0, - "byteLength" : 876, - "byteOffset" : 1800000 - }, - { - "buffer" : 0, - "byteLength" : 876, - "byteOffset" : 1800876 - }, - { - "buffer" : 0, - "byteLength" : 584, - "byteOffset" : 1801752 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1802336 - }, - { - "buffer" : 0, - "byteLength" : 408, - "byteOffset" : 1802600 - }, - { - "buffer" : 0, - "byteLength" : 408, - "byteOffset" : 1803008 - }, - { - "buffer" : 0, - "byteLength" : 272, - "byteOffset" : 1803416 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 1803688 - }, - { - "buffer" : 0, - "byteLength" : 1020, - "byteOffset" : 1803796 - }, - { - "buffer" : 0, - "byteLength" : 1020, - "byteOffset" : 1804816 - }, - { - "buffer" : 0, - "byteLength" : 680, - "byteOffset" : 1805836 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1806516 - }, - { - "buffer" : 0, - "byteLength" : 480, - "byteOffset" : 1806780 - }, - { - "buffer" : 0, - "byteLength" : 480, - "byteOffset" : 1807260 - }, - { - "buffer" : 0, - "byteLength" : 320, - "byteOffset" : 1807740 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 1808060 - }, - { - "buffer" : 0, - "byteLength" : 5940, - "byteOffset" : 1808168 - }, - { - "buffer" : 0, - "byteLength" : 5940, - "byteOffset" : 1814108 - }, - { - "buffer" : 0, - "byteLength" : 3960, - "byteOffset" : 1820048 - }, - { - "buffer" : 0, - "byteLength" : 1572, - "byteOffset" : 1824008 - }, - { - "buffer" : 0, - "byteLength" : 888, - "byteOffset" : 1825580 - }, - { - "buffer" : 0, - "byteLength" : 888, - "byteOffset" : 1826468 - }, - { - "buffer" : 0, - "byteLength" : 592, - "byteOffset" : 1827356 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1827948 - }, - { - "buffer" : 0, - "byteLength" : 396, - "byteOffset" : 1828212 - }, - { - "buffer" : 0, - "byteLength" : 396, - "byteOffset" : 1828608 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1829004 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 1829268 - }, - { - "buffer" : 0, - "byteLength" : 1080, - "byteOffset" : 1829376 - }, - { - "buffer" : 0, - "byteLength" : 1080, - "byteOffset" : 1830456 - }, - { - "buffer" : 0, - "byteLength" : 720, - "byteOffset" : 1831536 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1832256 - }, - { - "buffer" : 0, - "byteLength" : 3204, - "byteOffset" : 1832520 - }, - { - "buffer" : 0, - "byteLength" : 3204, - "byteOffset" : 1835724 - }, - { - "buffer" : 0, - "byteLength" : 2136, - "byteOffset" : 1838928 - }, - { - "buffer" : 0, - "byteLength" : 1800, - "byteOffset" : 1841064 - }, - { - "buffer" : 0, - "byteLength" : 2388, - "byteOffset" : 1842864 - }, - { - "buffer" : 0, - "byteLength" : 2388, - "byteOffset" : 1845252 - }, - { - "buffer" : 0, - "byteLength" : 1592, - "byteOffset" : 1847640 - }, - { - "buffer" : 0, - "byteLength" : 996, - "byteOffset" : 1849232 - }, - { - "buffer" : 0, - "byteLength" : 13524, - "byteOffset" : 1850228 - }, - { - "buffer" : 0, - "byteLength" : 13524, - "byteOffset" : 1863752 - }, - { - "buffer" : 0, - "byteLength" : 9016, - "byteOffset" : 1877276 - }, - { - "buffer" : 0, - "byteLength" : 7320, - "byteOffset" : 1886292 - }, - { - "buffer" : 0, - "byteLength" : 480, - "byteOffset" : 1893612 - }, - { - "buffer" : 0, - "byteLength" : 480, - "byteOffset" : 1894092 - }, - { - "buffer" : 0, - "byteLength" : 320, - "byteOffset" : 1894572 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 1894892 - }, - { - "buffer" : 0, - "byteLength" : 840, - "byteOffset" : 1895000 - }, - { - "buffer" : 0, - "byteLength" : 840, - "byteOffset" : 1895840 - }, - { - "buffer" : 0, - "byteLength" : 560, - "byteOffset" : 1896680 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1897240 - }, - { - "buffer" : 0, - "byteLength" : 432, - "byteOffset" : 1897504 - }, - { - "buffer" : 0, - "byteLength" : 432, - "byteOffset" : 1897936 - }, - { - "buffer" : 0, - "byteLength" : 288, - "byteOffset" : 1898368 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 1898656 - }, - { - "buffer" : 0, - "byteLength" : 1104, - "byteOffset" : 1898764 - }, - { - "buffer" : 0, - "byteLength" : 1104, - "byteOffset" : 1899868 - }, - { - "buffer" : 0, - "byteLength" : 736, - "byteOffset" : 1900972 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1901708 - }, - { - "buffer" : 0, - "byteLength" : 5976, - "byteOffset" : 1901972 - }, - { - "buffer" : 0, - "byteLength" : 5976, - "byteOffset" : 1907948 - }, - { - "buffer" : 0, - "byteLength" : 3984, - "byteOffset" : 1913924 - }, - { - "buffer" : 0, - "byteLength" : 1572, - "byteOffset" : 1917908 - }, - { - "buffer" : 0, - "byteLength" : 456, - "byteOffset" : 1919480 - }, - { - "buffer" : 0, - "byteLength" : 456, - "byteOffset" : 1919936 - }, - { - "buffer" : 0, - "byteLength" : 304, - "byteOffset" : 1920392 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 1920696 - }, - { - "buffer" : 0, - "byteLength" : 816, - "byteOffset" : 1920804 - }, - { - "buffer" : 0, - "byteLength" : 816, - "byteOffset" : 1921620 - }, - { - "buffer" : 0, - "byteLength" : 544, - "byteOffset" : 1922436 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1922980 - }, - { - "buffer" : 0, - "byteLength" : 432, - "byteOffset" : 1923244 - }, - { - "buffer" : 0, - "byteLength" : 432, - "byteOffset" : 1923676 - }, - { - "buffer" : 0, - "byteLength" : 288, - "byteOffset" : 1924108 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 1924396 - }, - { - "buffer" : 0, - "byteLength" : 1056, - "byteOffset" : 1924504 - }, - { - "buffer" : 0, - "byteLength" : 1056, - "byteOffset" : 1925560 - }, - { - "buffer" : 0, - "byteLength" : 704, - "byteOffset" : 1926616 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1927320 - }, - { - "buffer" : 0, - "byteLength" : 3216, - "byteOffset" : 1927584 - }, - { - "buffer" : 0, - "byteLength" : 3216, - "byteOffset" : 1930800 - }, - { - "buffer" : 0, - "byteLength" : 2144, - "byteOffset" : 1934016 - }, - { - "buffer" : 0, - "byteLength" : 1800, - "byteOffset" : 1936160 - }, - { - "buffer" : 0, - "byteLength" : 2472, - "byteOffset" : 1937960 - }, - { - "buffer" : 0, - "byteLength" : 2472, - "byteOffset" : 1940432 - }, - { - "buffer" : 0, - "byteLength" : 1648, - "byteOffset" : 1942904 - }, - { - "buffer" : 0, - "byteLength" : 996, - "byteOffset" : 1944552 - }, - { - "buffer" : 0, - "byteLength" : 13524, - "byteOffset" : 1945548 - }, - { - "buffer" : 0, - "byteLength" : 13524, - "byteOffset" : 1959072 - }, - { - "buffer" : 0, - "byteLength" : 9016, - "byteOffset" : 1972596 - }, - { - "buffer" : 0, - "byteLength" : 7320, - "byteOffset" : 1981612 - }, - { - "buffer" : 0, - "byteLength" : 480, - "byteOffset" : 1988932 - }, - { - "buffer" : 0, - "byteLength" : 480, - "byteOffset" : 1989412 - }, - { - "buffer" : 0, - "byteLength" : 320, - "byteOffset" : 1989892 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 1990212 - }, - { - "buffer" : 0, - "byteLength" : 840, - "byteOffset" : 1990320 - }, - { - "buffer" : 0, - "byteLength" : 840, - "byteOffset" : 1991160 - }, - { - "buffer" : 0, - "byteLength" : 560, - "byteOffset" : 1992000 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 1992560 - }, - { - "buffer" : 0, - "byteLength" : 444, - "byteOffset" : 1992824 - }, - { - "buffer" : 0, - "byteLength" : 444, - "byteOffset" : 1993268 - }, - { - "buffer" : 0, - "byteLength" : 296, - "byteOffset" : 1993712 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 1994008 - }, - { - "buffer" : 0, - "byteLength" : 5976, - "byteOffset" : 1994116 - }, - { - "buffer" : 0, - "byteLength" : 5976, - "byteOffset" : 2000092 - }, - { - "buffer" : 0, - "byteLength" : 3984, - "byteOffset" : 2006068 - }, - { - "buffer" : 0, - "byteLength" : 1572, - "byteOffset" : 2010052 - }, - { - "buffer" : 0, - "byteLength" : 1008, - "byteOffset" : 2011624 - }, - { - "buffer" : 0, - "byteLength" : 1008, - "byteOffset" : 2012632 - }, - { - "buffer" : 0, - "byteLength" : 672, - "byteOffset" : 2013640 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 2014312 - }, - { - "buffer" : 0, - "byteLength" : 480, - "byteOffset" : 2014576 - }, - { - "buffer" : 0, - "byteLength" : 480, - "byteOffset" : 2015056 - }, - { - "buffer" : 0, - "byteLength" : 320, - "byteOffset" : 2015536 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 2015856 - }, - { - "buffer" : 0, - "byteLength" : 792, - "byteOffset" : 2015964 - }, - { - "buffer" : 0, - "byteLength" : 792, - "byteOffset" : 2016756 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 2017548 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 2018076 - }, - { - "buffer" : 0, - "byteLength" : 432, - "byteOffset" : 2018340 - }, - { - "buffer" : 0, - "byteLength" : 432, - "byteOffset" : 2018772 - }, - { - "buffer" : 0, - "byteLength" : 288, - "byteOffset" : 2019204 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 2019492 - }, - { - "buffer" : 0, - "byteLength" : 1080, - "byteOffset" : 2019600 - }, - { - "buffer" : 0, - "byteLength" : 1080, - "byteOffset" : 2020680 - }, - { - "buffer" : 0, - "byteLength" : 720, - "byteOffset" : 2021760 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 2022480 - }, - { - "buffer" : 0, - "byteLength" : 3504, - "byteOffset" : 2022744 - }, - { - "buffer" : 0, - "byteLength" : 3504, - "byteOffset" : 2026248 - }, - { - "buffer" : 0, - "byteLength" : 2336, - "byteOffset" : 2029752 - }, - { - "buffer" : 0, - "byteLength" : 1800, - "byteOffset" : 2032088 - }, - { - "buffer" : 0, - "byteLength" : 2496, - "byteOffset" : 2033888 - }, - { - "buffer" : 0, - "byteLength" : 2496, - "byteOffset" : 2036384 - }, - { - "buffer" : 0, - "byteLength" : 1664, - "byteOffset" : 2038880 - }, - { - "buffer" : 0, - "byteLength" : 996, - "byteOffset" : 2040544 - }, - { - "buffer" : 0, - "byteLength" : 456, - "byteOffset" : 2041540 - }, - { - "buffer" : 0, - "byteLength" : 456, - "byteOffset" : 2041996 - }, - { - "buffer" : 0, - "byteLength" : 304, - "byteOffset" : 2042452 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 2042756 - }, - { - "buffer" : 0, - "byteLength" : 1776, - "byteOffset" : 2042864 - }, - { - "buffer" : 0, - "byteLength" : 1776, - "byteOffset" : 2044640 - }, - { - "buffer" : 0, - "byteLength" : 1184, - "byteOffset" : 2046416 - }, - { - "buffer" : 0, - "byteLength" : 384, - "byteOffset" : 2047600 - }, - { - "buffer" : 0, - "byteLength" : 2196, - "byteOffset" : 2047984 - }, - { - "buffer" : 0, - "byteLength" : 2196, - "byteOffset" : 2050180 - }, - { - "buffer" : 0, - "byteLength" : 1464, - "byteOffset" : 2052376 - }, - { - "buffer" : 0, - "byteLength" : 1356, - "byteOffset" : 2053840 - }, - { - "buffer" : 0, - "byteLength" : 6048, - "byteOffset" : 2055196 - }, - { - "buffer" : 0, - "byteLength" : 6048, - "byteOffset" : 2061244 - }, - { - "buffer" : 0, - "byteLength" : 4032, - "byteOffset" : 2067292 - }, - { - "buffer" : 0, - "byteLength" : 1572, - "byteOffset" : 2071324 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 2072896 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 2076700 - }, - { - "buffer" : 0, - "byteLength" : 2536, - "byteOffset" : 2080504 - }, - { - "buffer" : 0, - "byteLength" : 2736, - "byteOffset" : 2083040 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 2085776 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 2089580 - }, - { - "buffer" : 0, - "byteLength" : 2536, - "byteOffset" : 2093384 - }, - { - "buffer" : 0, - "byteLength" : 2736, - "byteOffset" : 2095920 - }, - { - "buffer" : 0, - "byteLength" : 2196, - "byteOffset" : 2098656 - }, - { - "buffer" : 0, - "byteLength" : 2196, - "byteOffset" : 2100852 - }, - { - "buffer" : 0, - "byteLength" : 1464, - "byteOffset" : 2103048 - }, - { - "buffer" : 0, - "byteLength" : 1356, - "byteOffset" : 2104512 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 2105868 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 2109672 - }, - { - "buffer" : 0, - "byteLength" : 2536, - "byteOffset" : 2113476 - }, - { - "buffer" : 0, - "byteLength" : 2736, - "byteOffset" : 2116012 - }, - { - "buffer" : 0, - "byteLength" : 2196, - "byteOffset" : 2118748 - }, - { - "buffer" : 0, - "byteLength" : 2196, - "byteOffset" : 2120944 - }, - { - "buffer" : 0, - "byteLength" : 1464, - "byteOffset" : 2123140 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 2124604 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 2128408 - }, - { - "buffer" : 0, - "byteLength" : 2536, - "byteOffset" : 2132212 - }, - { - "buffer" : 0, - "byteLength" : 2736, - "byteOffset" : 2134748 - }, - { - "buffer" : 0, - "byteLength" : 2196, - "byteOffset" : 2137484 - }, - { - "buffer" : 0, - "byteLength" : 2196, - "byteOffset" : 2139680 - }, - { - "buffer" : 0, - "byteLength" : 1464, - "byteOffset" : 2141876 - }, - { - "buffer" : 0, - "byteLength" : 2196, - "byteOffset" : 2143340 - }, - { - "buffer" : 0, - "byteLength" : 2196, - "byteOffset" : 2145536 - }, - { - "buffer" : 0, - "byteLength" : 1464, - "byteOffset" : 2147732 - }, - { - "buffer" : 0, - "byteLength" : 1356, - "byteOffset" : 2149196 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 2150552 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 2154356 - }, - { - "buffer" : 0, - "byteLength" : 2536, - "byteOffset" : 2158160 - }, - { - "buffer" : 0, - "byteLength" : 2736, - "byteOffset" : 2160696 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 2163432 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 2167236 - }, - { - "buffer" : 0, - "byteLength" : 2536, - "byteOffset" : 2171040 - }, - { - "buffer" : 0, - "byteLength" : 2736, - "byteOffset" : 2173576 - }, - { - "buffer" : 0, - "byteLength" : 8520, - "byteOffset" : 2176312 - }, - { - "buffer" : 0, - "byteLength" : 8520, - "byteOffset" : 2184832 - }, - { - "buffer" : 0, - "byteLength" : 5680, - "byteOffset" : 2193352 - }, - { - "buffer" : 0, - "byteLength" : 2376, - "byteOffset" : 2199032 - }, - { - "buffer" : 0, - "byteLength" : 2196, - "byteOffset" : 2201408 - }, - { - "buffer" : 0, - "byteLength" : 2196, - "byteOffset" : 2203604 - }, - { - "buffer" : 0, - "byteLength" : 1464, - "byteOffset" : 2205800 - }, - { - "buffer" : 0, - "byteLength" : 1356, - "byteOffset" : 2207264 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 2208620 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 2212424 - }, - { - "buffer" : 0, - "byteLength" : 2536, - "byteOffset" : 2216228 - }, - { - "buffer" : 0, - "byteLength" : 2736, - "byteOffset" : 2218764 - }, - { - "buffer" : 0, - "byteLength" : 2196, - "byteOffset" : 2221500 - }, - { - "buffer" : 0, - "byteLength" : 2196, - "byteOffset" : 2223696 - }, - { - "buffer" : 0, - "byteLength" : 1464, - "byteOffset" : 2225892 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 2227356 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 2231160 - }, - { - "buffer" : 0, - "byteLength" : 2536, - "byteOffset" : 2234964 - }, - { - "buffer" : 0, - "byteLength" : 2736, - "byteOffset" : 2237500 - }, - { - "buffer" : 0, - "byteLength" : 2196, - "byteOffset" : 2240236 - }, - { - "buffer" : 0, - "byteLength" : 2196, - "byteOffset" : 2242432 - }, - { - "buffer" : 0, - "byteLength" : 1464, - "byteOffset" : 2244628 - }, - { - "buffer" : 0, - "byteLength" : 57348, - "byteOffset" : 2246092 - }, - { - "buffer" : 0, - "byteLength" : 57348, - "byteOffset" : 2303440 - }, - { - "buffer" : 0, - "byteLength" : 38232, - "byteOffset" : 2360788 - }, - { - "buffer" : 0, - "byteLength" : 35580, - "byteOffset" : 2399020 - }, - { - "buffer" : 0, - "byteLength" : 42984, - "byteOffset" : 2434600 - }, - { - "buffer" : 0, - "byteLength" : 42984, - "byteOffset" : 2477584 - }, - { - "buffer" : 0, - "byteLength" : 28656, - "byteOffset" : 2520568 - }, - { - "buffer" : 0, - "byteLength" : 28932, - "byteOffset" : 2549224 - }, - { - "buffer" : 0, - "byteLength" : 18972, - "byteOffset" : 2578156 - }, - { - "buffer" : 0, - "byteLength" : 18972, - "byteOffset" : 2597128 - }, - { - "buffer" : 0, - "byteLength" : 12648, - "byteOffset" : 2616100 - }, - { - "buffer" : 0, - "byteLength" : 13224, - "byteOffset" : 2628748 - }, - { - "buffer" : 0, - "byteLength" : 39252, - "byteOffset" : 2641972 - }, - { - "buffer" : 0, - "byteLength" : 39252, - "byteOffset" : 2681224 - }, - { - "buffer" : 0, - "byteLength" : 26168, - "byteOffset" : 2720476 - }, - { - "buffer" : 0, - "byteLength" : 22812, - "byteOffset" : 2746644 - }, - { - "buffer" : 0, - "byteLength" : 27804, - "byteOffset" : 2769456 - }, - { - "buffer" : 0, - "byteLength" : 27804, - "byteOffset" : 2797260 - }, - { - "buffer" : 0, - "byteLength" : 18536, - "byteOffset" : 2825064 - }, - { - "buffer" : 0, - "byteLength" : 19848, - "byteOffset" : 2843600 - }, - { - "buffer" : 0, - "byteLength" : 8364, - "byteOffset" : 2863448 - }, - { - "buffer" : 0, - "byteLength" : 8364, - "byteOffset" : 2871812 - }, - { - "buffer" : 0, - "byteLength" : 5576, - "byteOffset" : 2880176 - }, - { - "buffer" : 0, - "byteLength" : 2376, - "byteOffset" : 2885752 - }, - { - "buffer" : 0, - "byteLength" : 37584, - "byteOffset" : 2888128 - }, - { - "buffer" : 0, - "byteLength" : 37584, - "byteOffset" : 2925712 - }, - { - "buffer" : 0, - "byteLength" : 25056, - "byteOffset" : 2963296 - }, - { - "buffer" : 0, - "byteLength" : 26532, - "byteOffset" : 2988352 - }, - { - "buffer" : 0, - "byteLength" : 27804, - "byteOffset" : 3014884 - }, - { - "buffer" : 0, - "byteLength" : 27804, - "byteOffset" : 3042688 - }, - { - "buffer" : 0, - "byteLength" : 18536, - "byteOffset" : 3070492 - }, - { - "buffer" : 0, - "byteLength" : 19848, - "byteOffset" : 3089028 - }, - { - "buffer" : 0, - "byteLength" : 47388, - "byteOffset" : 3108876 - }, - { - "buffer" : 0, - "byteLength" : 47388, - "byteOffset" : 3156264 - }, - { - "buffer" : 0, - "byteLength" : 31592, - "byteOffset" : 3203652 - }, - { - "buffer" : 0, - "byteLength" : 33024, - "byteOffset" : 3235244 - }, - { - "buffer" : 0, - "byteLength" : 47148, - "byteOffset" : 3268268 - }, - { - "buffer" : 0, - "byteLength" : 47148, - "byteOffset" : 3315416 - }, - { - "buffer" : 0, - "byteLength" : 31432, - "byteOffset" : 3362564 - }, - { - "buffer" : 0, - "byteLength" : 33024, - "byteOffset" : 3393996 - }, - { - "buffer" : 0, - "byteLength" : 47328, - "byteOffset" : 3427020 - }, - { - "buffer" : 0, - "byteLength" : 47328, - "byteOffset" : 3474348 - }, - { - "buffer" : 0, - "byteLength" : 31552, - "byteOffset" : 3521676 - }, - { - "buffer" : 0, - "byteLength" : 33024, - "byteOffset" : 3553228 - }, - { - "buffer" : 0, - "byteLength" : 47328, - "byteOffset" : 3586252 - }, - { - "buffer" : 0, - "byteLength" : 47328, - "byteOffset" : 3633580 - }, - { - "buffer" : 0, - "byteLength" : 31552, - "byteOffset" : 3680908 - }, - { - "buffer" : 0, - "byteLength" : 33024, - "byteOffset" : 3712460 - }, - { - "buffer" : 0, - "byteLength" : 47376, - "byteOffset" : 3745484 - }, - { - "buffer" : 0, - "byteLength" : 47376, - "byteOffset" : 3792860 - }, - { - "buffer" : 0, - "byteLength" : 31584, - "byteOffset" : 3840236 - }, - { - "buffer" : 0, - "byteLength" : 33024, - "byteOffset" : 3871820 - }, - { - "buffer" : 0, - "byteLength" : 47352, - "byteOffset" : 3904844 - }, - { - "buffer" : 0, - "byteLength" : 47352, - "byteOffset" : 3952196 - }, - { - "buffer" : 0, - "byteLength" : 31568, - "byteOffset" : 3999548 - }, - { - "buffer" : 0, - "byteLength" : 33024, - "byteOffset" : 4031116 - }, - { - "buffer" : 0, - "byteLength" : 47316, - "byteOffset" : 4064140 - }, - { - "buffer" : 0, - "byteLength" : 47316, - "byteOffset" : 4111456 - }, - { - "buffer" : 0, - "byteLength" : 31544, - "byteOffset" : 4158772 - }, - { - "buffer" : 0, - "byteLength" : 33024, - "byteOffset" : 4190316 - }, - { - "buffer" : 0, - "byteLength" : 47556, - "byteOffset" : 4223340 - }, - { - "buffer" : 0, - "byteLength" : 47556, - "byteOffset" : 4270896 - }, - { - "buffer" : 0, - "byteLength" : 31704, - "byteOffset" : 4318452 - }, - { - "buffer" : 0, - "byteLength" : 33024, - "byteOffset" : 4350156 - }, - { - "buffer" : 0, - "byteLength" : 5988, - "byteOffset" : 4383180 - }, - { - "buffer" : 0, - "byteLength" : 5988, - "byteOffset" : 4389168 - }, - { - "buffer" : 0, - "byteLength" : 3992, - "byteOffset" : 4395156 - }, - { - "buffer" : 0, - "byteLength" : 1572, - "byteOffset" : 4399148 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4400720 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4404524 - }, - { - "buffer" : 0, - "byteLength" : 2536, - "byteOffset" : 4408328 - }, - { - "buffer" : 0, - "byteLength" : 2736, - "byteOffset" : 4410864 - }, - { - "buffer" : 0, - "byteLength" : 2364, - "byteOffset" : 4413600 - }, - { - "buffer" : 0, - "byteLength" : 2364, - "byteOffset" : 4415964 - }, - { - "buffer" : 0, - "byteLength" : 1576, - "byteOffset" : 4418328 - }, - { - "buffer" : 0, - "byteLength" : 1152, - "byteOffset" : 4419904 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4421056 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4424860 - }, - { - "buffer" : 0, - "byteLength" : 2536, - "byteOffset" : 4428664 - }, - { - "buffer" : 0, - "byteLength" : 2736, - "byteOffset" : 4431200 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4433936 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4437740 - }, - { - "buffer" : 0, - "byteLength" : 2536, - "byteOffset" : 4441544 - }, - { - "buffer" : 0, - "byteLength" : 2736, - "byteOffset" : 4444080 - }, - { - "buffer" : 0, - "byteLength" : 2364, - "byteOffset" : 4446816 - }, - { - "buffer" : 0, - "byteLength" : 2364, - "byteOffset" : 4449180 - }, - { - "buffer" : 0, - "byteLength" : 1576, - "byteOffset" : 4451544 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4453120 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4456924 - }, - { - "buffer" : 0, - "byteLength" : 2536, - "byteOffset" : 4460728 - }, - { - "buffer" : 0, - "byteLength" : 2736, - "byteOffset" : 4463264 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4466000 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4469804 - }, - { - "buffer" : 0, - "byteLength" : 2536, - "byteOffset" : 4473608 - }, - { - "buffer" : 0, - "byteLength" : 2736, - "byteOffset" : 4476144 - }, - { - "buffer" : 0, - "byteLength" : 2364, - "byteOffset" : 4478880 - }, - { - "buffer" : 0, - "byteLength" : 2364, - "byteOffset" : 4481244 - }, - { - "buffer" : 0, - "byteLength" : 1576, - "byteOffset" : 4483608 - }, - { - "buffer" : 0, - "byteLength" : 1152, - "byteOffset" : 4485184 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4486336 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4490140 - }, - { - "buffer" : 0, - "byteLength" : 2536, - "byteOffset" : 4493944 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4496480 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4500284 - }, - { - "buffer" : 0, - "byteLength" : 2536, - "byteOffset" : 4504088 - }, - { - "buffer" : 0, - "byteLength" : 2736, - "byteOffset" : 4506624 - }, - { - "buffer" : 0, - "byteLength" : 6036, - "byteOffset" : 4509360 - }, - { - "buffer" : 0, - "byteLength" : 6036, - "byteOffset" : 4515396 - }, - { - "buffer" : 0, - "byteLength" : 4024, - "byteOffset" : 4521432 - }, - { - "buffer" : 0, - "byteLength" : 1572, - "byteOffset" : 4525456 - }, - { - "buffer" : 0, - "byteLength" : 2364, - "byteOffset" : 4527028 - }, - { - "buffer" : 0, - "byteLength" : 2364, - "byteOffset" : 4529392 - }, - { - "buffer" : 0, - "byteLength" : 1576, - "byteOffset" : 4531756 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4533332 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4537136 - }, - { - "buffer" : 0, - "byteLength" : 2536, - "byteOffset" : 4540940 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4543476 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4547280 - }, - { - "buffer" : 0, - "byteLength" : 2536, - "byteOffset" : 4551084 - }, - { - "buffer" : 0, - "byteLength" : 2736, - "byteOffset" : 4553620 - }, - { - "buffer" : 0, - "byteLength" : 2364, - "byteOffset" : 4556356 - }, - { - "buffer" : 0, - "byteLength" : 2364, - "byteOffset" : 4558720 - }, - { - "buffer" : 0, - "byteLength" : 1576, - "byteOffset" : 4561084 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4562660 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4566464 - }, - { - "buffer" : 0, - "byteLength" : 2536, - "byteOffset" : 4570268 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4572804 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4576608 - }, - { - "buffer" : 0, - "byteLength" : 2536, - "byteOffset" : 4580412 - }, - { - "buffer" : 0, - "byteLength" : 2364, - "byteOffset" : 4582948 - }, - { - "buffer" : 0, - "byteLength" : 2364, - "byteOffset" : 4585312 - }, - { - "buffer" : 0, - "byteLength" : 1576, - "byteOffset" : 4587676 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4589252 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4593056 - }, - { - "buffer" : 0, - "byteLength" : 2536, - "byteOffset" : 4596860 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4599396 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4603200 - }, - { - "buffer" : 0, - "byteLength" : 2536, - "byteOffset" : 4607004 - }, - { - "buffer" : 0, - "byteLength" : 2364, - "byteOffset" : 4609540 - }, - { - "buffer" : 0, - "byteLength" : 2364, - "byteOffset" : 4611904 - }, - { - "buffer" : 0, - "byteLength" : 1576, - "byteOffset" : 4614268 - }, - { - "buffer" : 0, - "byteLength" : 5856, - "byteOffset" : 4615844 - }, - { - "buffer" : 0, - "byteLength" : 5856, - "byteOffset" : 4621700 - }, - { - "buffer" : 0, - "byteLength" : 3904, - "byteOffset" : 4627556 - }, - { - "buffer" : 0, - "byteLength" : 1572, - "byteOffset" : 4631460 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4633032 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4636836 - }, - { - "buffer" : 0, - "byteLength" : 2536, - "byteOffset" : 4640640 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4643176 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4646980 - }, - { - "buffer" : 0, - "byteLength" : 2536, - "byteOffset" : 4650784 - }, - { - "buffer" : 0, - "byteLength" : 2364, - "byteOffset" : 4653320 - }, - { - "buffer" : 0, - "byteLength" : 2364, - "byteOffset" : 4655684 - }, - { - "buffer" : 0, - "byteLength" : 1576, - "byteOffset" : 4658048 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4659624 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4663428 - }, - { - "buffer" : 0, - "byteLength" : 2536, - "byteOffset" : 4667232 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4669768 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4673572 - }, - { - "buffer" : 0, - "byteLength" : 2536, - "byteOffset" : 4677376 - }, - { - "buffer" : 0, - "byteLength" : 2364, - "byteOffset" : 4679912 - }, - { - "buffer" : 0, - "byteLength" : 2364, - "byteOffset" : 4682276 - }, - { - "buffer" : 0, - "byteLength" : 1576, - "byteOffset" : 4684640 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4686216 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4690020 - }, - { - "buffer" : 0, - "byteLength" : 2536, - "byteOffset" : 4693824 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4696360 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4700164 - }, - { - "buffer" : 0, - "byteLength" : 2536, - "byteOffset" : 4703968 - }, - { - "buffer" : 0, - "byteLength" : 2364, - "byteOffset" : 4706504 - }, - { - "buffer" : 0, - "byteLength" : 2364, - "byteOffset" : 4708868 - }, - { - "buffer" : 0, - "byteLength" : 1576, - "byteOffset" : 4711232 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4712808 - }, - { - "buffer" : 0, - "byteLength" : 3804, - "byteOffset" : 4716612 - }, - { - "buffer" : 0, - "byteLength" : 2536, - "byteOffset" : 4720416 - }, - { - "buffer" : 0, - "byteLength" : 5940, - "byteOffset" : 4722952 - }, - { - "buffer" : 0, - "byteLength" : 5940, - "byteOffset" : 4728892 - }, - { - "buffer" : 0, - "byteLength" : 3960, - "byteOffset" : 4734832 - }, - { - "buffer" : 0, - "byteLength" : 1572, - "byteOffset" : 4738792 - }, - { - "buffer" : 0, - "byteLength" : 29472, - "byteOffset" : 4740364 - }, - { - "buffer" : 0, - "byteLength" : 29472, - "byteOffset" : 4769836 - }, - { - "buffer" : 0, - "byteLength" : 19648, - "byteOffset" : 4799308 - }, - { - "buffer" : 0, - "byteLength" : 29184, - "byteOffset" : 4818956 - }, - { - "buffer" : 0, - "byteLength" : 30144, - "byteOffset" : 4848140 - }, - { - "buffer" : 0, - "byteLength" : 30144, - "byteOffset" : 4878284 - }, - { - "buffer" : 0, - "byteLength" : 20096, - "byteOffset" : 4908428 - }, - { - "buffer" : 0, - "byteLength" : 27648, - "byteOffset" : 4928524 - }, - { - "buffer" : 0, - "byteLength" : 29472, - "byteOffset" : 4956172 - }, - { - "buffer" : 0, - "byteLength" : 29472, - "byteOffset" : 4985644 - }, - { - "buffer" : 0, - "byteLength" : 19648, - "byteOffset" : 5015116 - }, - { - "buffer" : 0, - "byteLength" : 29184, - "byteOffset" : 5034764 - }, - { - "buffer" : 0, - "byteLength" : 29472, - "byteOffset" : 5063948 - }, - { - "buffer" : 0, - "byteLength" : 29472, - "byteOffset" : 5093420 - }, - { - "buffer" : 0, - "byteLength" : 19648, - "byteOffset" : 5122892 - }, - { - "buffer" : 0, - "byteLength" : 29184, - "byteOffset" : 5142540 - }, - { - "buffer" : 0, - "byteLength" : 30144, - "byteOffset" : 5171724 - }, - { - "buffer" : 0, - "byteLength" : 30144, - "byteOffset" : 5201868 - }, - { - "buffer" : 0, - "byteLength" : 20096, - "byteOffset" : 5232012 - }, - { - "buffer" : 0, - "byteLength" : 29472, - "byteOffset" : 5252108 - }, - { - "buffer" : 0, - "byteLength" : 29472, - "byteOffset" : 5281580 - }, - { - "buffer" : 0, - "byteLength" : 19648, - "byteOffset" : 5311052 - }, - { - "buffer" : 0, - "byteLength" : 29184, - "byteOffset" : 5330700 - }, - { - "buffer" : 0, - "byteLength" : 30144, - "byteOffset" : 5359884 - }, - { - "buffer" : 0, - "byteLength" : 30144, - "byteOffset" : 5390028 - }, - { - "buffer" : 0, - "byteLength" : 20096, - "byteOffset" : 5420172 - }, - { - "buffer" : 0, - "byteLength" : 29472, - "byteOffset" : 5440268 - }, - { - "buffer" : 0, - "byteLength" : 29472, - "byteOffset" : 5469740 - }, - { - "buffer" : 0, - "byteLength" : 19648, - "byteOffset" : 5499212 - }, - { - "buffer" : 0, - "byteLength" : 30144, - "byteOffset" : 5518860 - }, - { - "buffer" : 0, - "byteLength" : 30144, - "byteOffset" : 5549004 - }, - { - "buffer" : 0, - "byteLength" : 20096, - "byteOffset" : 5579148 - }, - { - "buffer" : 0, - "byteLength" : 29472, - "byteOffset" : 5599244 - }, - { - "buffer" : 0, - "byteLength" : 29472, - "byteOffset" : 5628716 - }, - { - "buffer" : 0, - "byteLength" : 19648, - "byteOffset" : 5658188 - }, - { - "buffer" : 0, - "byteLength" : 29184, - "byteOffset" : 5677836 - }, - { - "buffer" : 0, - "byteLength" : 8436, - "byteOffset" : 5707020 - }, - { - "buffer" : 0, - "byteLength" : 8436, - "byteOffset" : 5715456 - }, - { - "buffer" : 0, - "byteLength" : 5624, - "byteOffset" : 5723892 - }, - { - "buffer" : 0, - "byteLength" : 2376, - "byteOffset" : 5729516 - }, - { - "buffer" : 0, - "byteLength" : 48, - "byteOffset" : 5731892 - }, - { - "buffer" : 0, - "byteLength" : 48, - "byteOffset" : 5731940 - }, - { - "buffer" : 0, - "byteLength" : 32, - "byteOffset" : 5731988 - }, - { - "buffer" : 0, - "byteLength" : 12, - "byteOffset" : 5732020 - }, - { - "buffer" : 0, - "byteLength" : 48, - "byteOffset" : 5732032 - }, - { - "buffer" : 0, - "byteLength" : 48, - "byteOffset" : 5732080 - }, - { - "buffer" : 0, - "byteLength" : 32, - "byteOffset" : 5732128 - }, - { - "buffer" : 0, - "byteLength" : 12, - "byteOffset" : 5732160 - }, - { - "buffer" : 0, - "byteLength" : 72, - "byteOffset" : 5732172 - }, - { - "buffer" : 0, - "byteLength" : 72, - "byteOffset" : 5732244 - }, - { - "buffer" : 0, - "byteLength" : 48, - "byteOffset" : 5732316 - }, - { - "buffer" : 0, - "byteLength" : 12, - "byteOffset" : 5732364 - }, - { - "buffer" : 0, - "byteLength" : 48, - "byteOffset" : 5732376 - }, - { - "buffer" : 0, - "byteLength" : 48, - "byteOffset" : 5732424 - }, - { - "buffer" : 0, - "byteLength" : 32, - "byteOffset" : 5732472 - }, - { - "buffer" : 0, - "byteLength" : 10800, - "byteOffset" : 5732504 - }, - { - "buffer" : 0, - "byteLength" : 10800, - "byteOffset" : 5743304 - }, - { - "buffer" : 0, - "byteLength" : 7200, - "byteOffset" : 5754104 - }, - { - "buffer" : 0, - "byteLength" : 9846, - "byteOffset" : 5761304 - }, - { - "buffer" : 0, - "byteLength" : 3912, - "byteOffset" : 5771152 - }, - { - "buffer" : 0, - "byteLength" : 3912, - "byteOffset" : 5775064 - }, - { - "buffer" : 0, - "byteLength" : 2608, - "byteOffset" : 5778976 - }, - { - "buffer" : 0, - "byteLength" : 3348, - "byteOffset" : 5781584 - }, - { - "buffer" : 0, - "byteLength" : 7536, - "byteOffset" : 5784932 - }, - { - "buffer" : 0, - "byteLength" : 7536, - "byteOffset" : 5792468 - }, - { - "buffer" : 0, - "byteLength" : 5024, - "byteOffset" : 5800004 - }, - { - "buffer" : 0, - "byteLength" : 7464, - "byteOffset" : 5805028 - }, - { - "buffer" : 0, - "byteLength" : 7536, - "byteOffset" : 5812492 - }, - { - "buffer" : 0, - "byteLength" : 7536, - "byteOffset" : 5820028 - }, - { - "buffer" : 0, - "byteLength" : 5024, - "byteOffset" : 5827564 - }, - { - "buffer" : 0, - "byteLength" : 7464, - "byteOffset" : 5832588 - }, - { - "buffer" : 0, - "byteLength" : 1716, - "byteOffset" : 5840052 - }, - { - "buffer" : 0, - "byteLength" : 1716, - "byteOffset" : 5841768 - }, - { - "buffer" : 0, - "byteLength" : 1144, - "byteOffset" : 5843484 - }, - { - "buffer" : 0, - "byteLength" : 1620, - "byteOffset" : 5844628 - }, - { - "buffer" : 0, - "byteLength" : 48, - "byteOffset" : 5846248 - }, - { - "buffer" : 0, - "byteLength" : 48, - "byteOffset" : 5846296 - }, - { - "buffer" : 0, - "byteLength" : 32, - "byteOffset" : 5846344 - }, - { - "buffer" : 0, - "byteLength" : 4908, - "byteOffset" : 5846376 - }, - { - "buffer" : 0, - "byteLength" : 4908, - "byteOffset" : 5851284 - }, - { - "buffer" : 0, - "byteLength" : 3272, - "byteOffset" : 5856192 - }, - { - "buffer" : 0, - "byteLength" : 1224, - "byteOffset" : 5859464 - }, - { - "buffer" : 0, - "byteLength" : 72, - "byteOffset" : 5860688 - }, - { - "buffer" : 0, - "byteLength" : 72, - "byteOffset" : 5860760 - }, - { - "buffer" : 0, - "byteLength" : 48, - "byteOffset" : 5860832 - }, - { - "buffer" : 0, - "byteLength" : 12, - "byteOffset" : 5860880 - }, - { - "buffer" : 0, - "byteLength" : 72, - "byteOffset" : 5860892 - }, - { - "buffer" : 0, - "byteLength" : 72, - "byteOffset" : 5860964 - }, - { - "buffer" : 0, - "byteLength" : 48, - "byteOffset" : 5861036 - }, - { - "buffer" : 0, - "byteLength" : 12, - "byteOffset" : 5861084 - }, - { - "buffer" : 0, - "byteLength" : 48, - "byteOffset" : 5861096 - }, - { - "buffer" : 0, - "byteLength" : 48, - "byteOffset" : 5861144 - }, - { - "buffer" : 0, - "byteLength" : 32, - "byteOffset" : 5861192 - }, - { - "buffer" : 0, - "byteLength" : 10800, - "byteOffset" : 5861224 - }, - { - "buffer" : 0, - "byteLength" : 10800, - "byteOffset" : 5872024 - }, - { - "buffer" : 0, - "byteLength" : 7200, - "byteOffset" : 5882824 - }, - { - "buffer" : 0, - "byteLength" : 3912, - "byteOffset" : 5890024 - }, - { - "buffer" : 0, - "byteLength" : 3912, - "byteOffset" : 5893936 - }, - { - "buffer" : 0, - "byteLength" : 2608, - "byteOffset" : 5897848 - }, - { - "buffer" : 0, - "byteLength" : 7536, - "byteOffset" : 5900456 - }, - { - "buffer" : 0, - "byteLength" : 7536, - "byteOffset" : 5907992 - }, - { - "buffer" : 0, - "byteLength" : 5024, - "byteOffset" : 5915528 - }, - { - "buffer" : 0, - "byteLength" : 7464, - "byteOffset" : 5920552 - }, - { - "buffer" : 0, - "byteLength" : 7536, - "byteOffset" : 5928016 - }, - { - "buffer" : 0, - "byteLength" : 7536, - "byteOffset" : 5935552 - }, - { - "buffer" : 0, - "byteLength" : 5024, - "byteOffset" : 5943088 - }, - { - "buffer" : 0, - "byteLength" : 7464, - "byteOffset" : 5948112 - }, - { - "buffer" : 0, - "byteLength" : 1716, - "byteOffset" : 5955576 - }, - { - "buffer" : 0, - "byteLength" : 1716, - "byteOffset" : 5957292 - }, - { - "buffer" : 0, - "byteLength" : 1144, - "byteOffset" : 5959008 - }, - { - "buffer" : 0, - "byteLength" : 48, - "byteOffset" : 5960152 - }, - { - "buffer" : 0, - "byteLength" : 48, - "byteOffset" : 5960200 - }, - { - "buffer" : 0, - "byteLength" : 32, - "byteOffset" : 5960248 - }, - { - "buffer" : 0, - "byteLength" : 12, - "byteOffset" : 5960280 - }, - { - "buffer" : 0, - "byteLength" : 48, - "byteOffset" : 5960292 - }, - { - "buffer" : 0, - "byteLength" : 48, - "byteOffset" : 5960340 - }, - { - "buffer" : 0, - "byteLength" : 32, - "byteOffset" : 5960388 - }, - { - "buffer" : 0, - "byteLength" : 12, - "byteOffset" : 5960420 - }, - { - "buffer" : 0, - "byteLength" : 4884, - "byteOffset" : 5960432 - }, - { - "buffer" : 0, - "byteLength" : 4884, - "byteOffset" : 5965316 - }, - { - "buffer" : 0, - "byteLength" : 3256, - "byteOffset" : 5970200 - }, - { - "buffer" : 0, - "byteLength" : 1224, - "byteOffset" : 5973456 - }, - { - "buffer" : 0, - "byteLength" : 72, - "byteOffset" : 5974680 - }, - { - "buffer" : 0, - "byteLength" : 72, - "byteOffset" : 5974752 - }, - { - "buffer" : 0, - "byteLength" : 48, - "byteOffset" : 5974824 - }, - { - "buffer" : 0, - "byteLength" : 12, - "byteOffset" : 5974872 - }, - { - "buffer" : 0, - "byteLength" : 48, - "byteOffset" : 5974884 - }, - { - "buffer" : 0, - "byteLength" : 48, - "byteOffset" : 5974932 - }, - { - "buffer" : 0, - "byteLength" : 32, - "byteOffset" : 5974980 - }, - { - "buffer" : 0, - "byteLength" : 10800, - "byteOffset" : 5975012 - }, - { - "buffer" : 0, - "byteLength" : 10800, - "byteOffset" : 5985812 - }, - { - "buffer" : 0, - "byteLength" : 7200, - "byteOffset" : 5996612 - }, - { - "buffer" : 0, - "byteLength" : 9846, - "byteOffset" : 6003812 - }, - { - "buffer" : 0, - "byteLength" : 3900, - "byteOffset" : 6013660 - }, - { - "buffer" : 0, - "byteLength" : 3900, - "byteOffset" : 6017560 - }, - { - "buffer" : 0, - "byteLength" : 2600, - "byteOffset" : 6021460 - }, - { - "buffer" : 0, - "byteLength" : 3348, - "byteOffset" : 6024060 - }, - { - "buffer" : 0, - "byteLength" : 7536, - "byteOffset" : 6027408 - }, - { - "buffer" : 0, - "byteLength" : 7536, - "byteOffset" : 6034944 - }, - { - "buffer" : 0, - "byteLength" : 5024, - "byteOffset" : 6042480 - }, - { - "buffer" : 0, - "byteLength" : 7464, - "byteOffset" : 6047504 - }, - { - "buffer" : 0, - "byteLength" : 7536, - "byteOffset" : 6054968 - }, - { - "buffer" : 0, - "byteLength" : 7536, - "byteOffset" : 6062504 - }, - { - "buffer" : 0, - "byteLength" : 5024, - "byteOffset" : 6070040 - }, - { - "buffer" : 0, - "byteLength" : 7464, - "byteOffset" : 6075064 - }, - { - "buffer" : 0, - "byteLength" : 1716, - "byteOffset" : 6082528 - }, - { - "buffer" : 0, - "byteLength" : 1716, - "byteOffset" : 6084244 - }, - { - "buffer" : 0, - "byteLength" : 1144, - "byteOffset" : 6085960 - }, - { - "buffer" : 0, - "byteLength" : 1620, - "byteOffset" : 6087104 - }, - { - "buffer" : 0, - "byteLength" : 48, - "byteOffset" : 6088724 - }, - { - "buffer" : 0, - "byteLength" : 48, - "byteOffset" : 6088772 - }, - { - "buffer" : 0, - "byteLength" : 32, - "byteOffset" : 6088820 - }, - { - "buffer" : 0, - "byteLength" : 72, - "byteOffset" : 6088852 - }, - { - "buffer" : 0, - "byteLength" : 72, - "byteOffset" : 6088924 - }, - { - "buffer" : 0, - "byteLength" : 48, - "byteOffset" : 6088996 - }, - { - "buffer" : 0, - "byteLength" : 12, - "byteOffset" : 6089044 - }, - { - "buffer" : 0, - "byteLength" : 72, - "byteOffset" : 6089056 - }, - { - "buffer" : 0, - "byteLength" : 72, - "byteOffset" : 6089128 - }, - { - "buffer" : 0, - "byteLength" : 48, - "byteOffset" : 6089200 - }, - { - "buffer" : 0, - "byteLength" : 3732, - "byteOffset" : 6089248 - }, - { - "buffer" : 0, - "byteLength" : 3732, - "byteOffset" : 6092980 - }, - { - "buffer" : 0, - "byteLength" : 2488, - "byteOffset" : 6096712 - }, - { - "buffer" : 0, - "byteLength" : 888, - "byteOffset" : 6099200 - }, - { - "buffer" : 0, - "byteLength" : 48, - "byteOffset" : 6100088 - }, - { - "buffer" : 0, - "byteLength" : 48, - "byteOffset" : 6100136 - }, - { - "buffer" : 0, - "byteLength" : 32, - "byteOffset" : 6100184 - }, - { - "buffer" : 0, - "byteLength" : 10800, - "byteOffset" : 6100216 - }, - { - "buffer" : 0, - "byteLength" : 10800, - "byteOffset" : 6111016 - }, - { - "buffer" : 0, - "byteLength" : 7200, - "byteOffset" : 6121816 - }, - { - "buffer" : 0, - "byteLength" : 3900, - "byteOffset" : 6129016 - }, - { - "buffer" : 0, - "byteLength" : 3900, - "byteOffset" : 6132916 - }, - { - "buffer" : 0, - "byteLength" : 2600, - "byteOffset" : 6136816 - }, - { - "buffer" : 0, - "byteLength" : 3348, - "byteOffset" : 6139416 - }, - { - "buffer" : 0, - "byteLength" : 7536, - "byteOffset" : 6142764 - }, - { - "buffer" : 0, - "byteLength" : 7536, - "byteOffset" : 6150300 - }, - { - "buffer" : 0, - "byteLength" : 5024, - "byteOffset" : 6157836 - }, - { - "buffer" : 0, - "byteLength" : 7536, - "byteOffset" : 6162860 - }, - { - "buffer" : 0, - "byteLength" : 7536, - "byteOffset" : 6170396 - }, - { - "buffer" : 0, - "byteLength" : 5024, - "byteOffset" : 6177932 - }, - { - "buffer" : 0, - "byteLength" : 1716, - "byteOffset" : 6182956 - }, - { - "buffer" : 0, - "byteLength" : 1716, - "byteOffset" : 6184672 - }, - { - "buffer" : 0, - "byteLength" : 1144, - "byteOffset" : 6186388 - }, - { - "buffer" : 0, - "byteLength" : 6432, - "byteOffset" : 6187532 - }, - { - "buffer" : 0, - "byteLength" : 6432, - "byteOffset" : 6193964 - }, - { - "buffer" : 0, - "byteLength" : 4288, - "byteOffset" : 6200396 - }, - { - "buffer" : 0, - "byteLength" : 2808, - "byteOffset" : 6204684 - }, - { - "buffer" : 0, - "byteLength" : 14760, - "byteOffset" : 6207492 - }, - { - "buffer" : 0, - "byteLength" : 14760, - "byteOffset" : 6222252 - }, - { - "buffer" : 0, - "byteLength" : 9840, - "byteOffset" : 6237012 - }, - { - "buffer" : 0, - "byteLength" : 13266, - "byteOffset" : 6246852 - }, - { - "buffer" : 0, - "byteLength" : 6432, - "byteOffset" : 6260120 - }, - { - "buffer" : 0, - "byteLength" : 6432, - "byteOffset" : 6266552 - }, - { - "buffer" : 0, - "byteLength" : 4288, - "byteOffset" : 6272984 - }, - { - "buffer" : 0, - "byteLength" : 14760, - "byteOffset" : 6277272 - }, - { - "buffer" : 0, - "byteLength" : 14760, - "byteOffset" : 6292032 - }, - { - "buffer" : 0, - "byteLength" : 9840, - "byteOffset" : 6306792 - }, - { - "buffer" : 0, - "byteLength" : 6432, - "byteOffset" : 6316632 - }, - { - "buffer" : 0, - "byteLength" : 6432, - "byteOffset" : 6323064 - }, - { - "buffer" : 0, - "byteLength" : 4288, - "byteOffset" : 6329496 - }, - { - "buffer" : 0, - "byteLength" : 14760, - "byteOffset" : 6333784 - }, - { - "buffer" : 0, - "byteLength" : 14760, - "byteOffset" : 6348544 - }, - { - "buffer" : 0, - "byteLength" : 9840, - "byteOffset" : 6363304 - }, - { - "buffer" : 0, - "byteLength" : 5436, - "byteOffset" : 6373144 - }, - { - "buffer" : 0, - "byteLength" : 5436, - "byteOffset" : 6378580 - }, - { - "buffer" : 0, - "byteLength" : 3624, - "byteOffset" : 6384016 - }, - { - "buffer" : 0, - "byteLength" : 2400, - "byteOffset" : 6387640 - }, - { - "buffer" : 0, - "byteLength" : 14760, - "byteOffset" : 6390040 - }, - { - "buffer" : 0, - "byteLength" : 14760, - "byteOffset" : 6404800 - }, - { - "buffer" : 0, - "byteLength" : 9840, - "byteOffset" : 6419560 - }, - { - "buffer" : 0, - "byteLength" : 13266, - "byteOffset" : 6429400 - }, - { - "buffer" : 0, - "byteLength" : 1392, - "byteOffset" : 6442668 - }, - { - "buffer" : 0, - "byteLength" : 1392, - "byteOffset" : 6444060 - }, - { - "buffer" : 0, - "byteLength" : 928, - "byteOffset" : 6445452 - }, - { - "buffer" : 0, - "byteLength" : 960, - "byteOffset" : 6446380 - }, - { - "buffer" : 0, - "byteLength" : 5436, - "byteOffset" : 6447340 - }, - { - "buffer" : 0, - "byteLength" : 5436, - "byteOffset" : 6452776 - }, - { - "buffer" : 0, - "byteLength" : 3624, - "byteOffset" : 6458212 - }, - { - "buffer" : 0, - "byteLength" : 14760, - "byteOffset" : 6461836 - }, - { - "buffer" : 0, - "byteLength" : 14760, - "byteOffset" : 6476596 - }, - { - "buffer" : 0, - "byteLength" : 9840, - "byteOffset" : 6491356 - }, - { - "buffer" : 0, - "byteLength" : 13266, - "byteOffset" : 6501196 - }, - { - "buffer" : 0, - "byteLength" : 5436, - "byteOffset" : 6514464 - }, - { - "buffer" : 0, - "byteLength" : 5436, - "byteOffset" : 6519900 - }, - { - "buffer" : 0, - "byteLength" : 3624, - "byteOffset" : 6525336 - }, - { - "buffer" : 0, - "byteLength" : 14760, - "byteOffset" : 6528960 - }, - { - "buffer" : 0, - "byteLength" : 14760, - "byteOffset" : 6543720 - }, - { - "buffer" : 0, - "byteLength" : 9840, - "byteOffset" : 6558480 - }, - { - "buffer" : 0, - "byteLength" : 5436, - "byteOffset" : 6568320 - }, - { - "buffer" : 0, - "byteLength" : 5436, - "byteOffset" : 6573756 - }, - { - "buffer" : 0, - "byteLength" : 3624, - "byteOffset" : 6579192 - }, - { - "buffer" : 0, - "byteLength" : 14760, - "byteOffset" : 6582816 - }, - { - "buffer" : 0, - "byteLength" : 14760, - "byteOffset" : 6597576 - }, - { - "buffer" : 0, - "byteLength" : 9840, - "byteOffset" : 6612336 - }, - { - "buffer" : 0, - "byteLength" : 16236, - "byteOffset" : 6622176 - }, - { - "buffer" : 0, - "byteLength" : 16236, - "byteOffset" : 6638412 - }, - { - "buffer" : 0, - "byteLength" : 10824, - "byteOffset" : 6654648 - }, - { - "buffer" : 0, - "byteLength" : 13776, - "byteOffset" : 6665472 - }, - { - "buffer" : 0, - "byteLength" : 16236, - "byteOffset" : 6679248 - }, - { - "buffer" : 0, - "byteLength" : 16236, - "byteOffset" : 6695484 - }, - { - "buffer" : 0, - "byteLength" : 10824, - "byteOffset" : 6711720 - }, - { - "buffer" : 0, - "byteLength" : 13776, - "byteOffset" : 6722544 - }, - { - "buffer" : 0, - "byteLength" : 16248, - "byteOffset" : 6736320 - }, - { - "buffer" : 0, - "byteLength" : 16248, - "byteOffset" : 6752568 - }, - { - "buffer" : 0, - "byteLength" : 10832, - "byteOffset" : 6768816 - }, - { - "buffer" : 0, - "byteLength" : 13776, - "byteOffset" : 6779648 - }, - { - "buffer" : 0, - "byteLength" : 16212, - "byteOffset" : 6793424 - }, - { - "buffer" : 0, - "byteLength" : 16212, - "byteOffset" : 6809636 - }, - { - "buffer" : 0, - "byteLength" : 10808, - "byteOffset" : 6825848 - }, - { - "buffer" : 0, - "byteLength" : 13776, - "byteOffset" : 6836656 - }, - { - "buffer" : 0, - "byteLength" : 8964, - "byteOffset" : 6850432 - }, - { - "buffer" : 0, - "byteLength" : 8964, - "byteOffset" : 6859396 - }, - { - "buffer" : 0, - "byteLength" : 5976, - "byteOffset" : 6868360 - }, - { - "buffer" : 0, - "byteLength" : 8172, - "byteOffset" : 6874336 - }, - { - "buffer" : 0, - "byteLength" : 10404, - "byteOffset" : 6882508 - }, - { - "buffer" : 0, - "byteLength" : 10404, - "byteOffset" : 6892912 - }, - { - "buffer" : 0, - "byteLength" : 6936, - "byteOffset" : 6903316 - }, - { - "buffer" : 0, - "byteLength" : 9126, - "byteOffset" : 6910252 - }, - { - "buffer" : 0, - "byteLength" : 8964, - "byteOffset" : 6919380 - }, - { - "buffer" : 0, - "byteLength" : 8964, - "byteOffset" : 6928344 - }, - { - "buffer" : 0, - "byteLength" : 5976, - "byteOffset" : 6937308 - }, - { - "buffer" : 0, - "byteLength" : 8172, - "byteOffset" : 6943284 - }, - { - "buffer" : 0, - "byteLength" : 10404, - "byteOffset" : 6951456 - }, - { - "buffer" : 0, - "byteLength" : 10404, - "byteOffset" : 6961860 - }, - { - "buffer" : 0, - "byteLength" : 6936, - "byteOffset" : 6972264 - }, - { - "buffer" : 0, - "byteLength" : 9126, - "byteOffset" : 6979200 - }, - { - "buffer" : 0, - "byteLength" : 600, - "byteOffset" : 6988328 - }, - { - "buffer" : 0, - "byteLength" : 600, - "byteOffset" : 6988928 - }, - { - "buffer" : 0, - "byteLength" : 400, - "byteOffset" : 6989528 - }, - { - "buffer" : 0, - "byteLength" : 168, - "byteOffset" : 6989928 - }, - { - "buffer" : 0, - "byteLength" : 2388, - "byteOffset" : 6990096 - }, - { - "buffer" : 0, - "byteLength" : 2388, - "byteOffset" : 6992484 - }, - { - "buffer" : 0, - "byteLength" : 1592, - "byteOffset" : 6994872 - }, - { - "buffer" : 0, - "byteLength" : 672, - "byteOffset" : 6996464 - }, - { - "buffer" : 0, - "byteLength" : 4560, - "byteOffset" : 6997136 - }, - { - "buffer" : 0, - "byteLength" : 4560, - "byteOffset" : 7001696 - }, - { - "buffer" : 0, - "byteLength" : 3040, - "byteOffset" : 7006256 - }, - { - "buffer" : 0, - "byteLength" : 2976, - "byteOffset" : 7009296 - }, - { - "buffer" : 0, - "byteLength" : 126552, - "byteOffset" : 7012272 - }, - { - "buffer" : 0, - "byteLength" : 126552, - "byteOffset" : 7138824 - }, - { - "buffer" : 0, - "byteLength" : 84368, - "byteOffset" : 7265376 - }, - { - "buffer" : 0, - "byteLength" : 83928, - "byteOffset" : 7349744 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 7433672 - }, - { - "buffer" : 0, - "byteLength" : 264, - "byteOffset" : 7433936 - }, - { - "buffer" : 0, - "byteLength" : 176, - "byteOffset" : 7434200 - }, - { - "buffer" : 0, - "byteLength" : 60, - "byteOffset" : 7434376 - }, - { - "buffer" : 0, - "byteLength" : 1392, - "byteOffset" : 7434436 - }, - { - "buffer" : 0, - "byteLength" : 1392, - "byteOffset" : 7435828 - }, - { - "buffer" : 0, - "byteLength" : 928, - "byteOffset" : 7437220 - }, - { - "buffer" : 0, - "byteLength" : 960, - "byteOffset" : 7438148 - }, - { - "buffer" : 0, - "byteLength" : 2592, - "byteOffset" : 7439108 - }, - { - "buffer" : 0, - "byteLength" : 2592, - "byteOffset" : 7441700 - }, - { - "buffer" : 0, - "byteLength" : 1728, - "byteOffset" : 7444292 - }, - { - "buffer" : 0, - "byteLength" : 672, - "byteOffset" : 7446020 - }, - { - "buffer" : 0, - "byteLength" : 1392, - "byteOffset" : 7446692 - }, - { - "buffer" : 0, - "byteLength" : 1392, - "byteOffset" : 7448084 - }, - { - "buffer" : 0, - "byteLength" : 928, - "byteOffset" : 7449476 - }, - { - "buffer" : 0, - "byteLength" : 960, - "byteOffset" : 7450404 - }, - { - "buffer" : 0, - "byteLength" : 2520, - "byteOffset" : 7451364 - }, - { - "buffer" : 0, - "byteLength" : 2520, - "byteOffset" : 7453884 - }, - { - "buffer" : 0, - "byteLength" : 1680, - "byteOffset" : 7456404 - }, - { - "buffer" : 0, - "byteLength" : 672, - "byteOffset" : 7458084 - }, - { - "buffer" : 0, - "byteLength" : 1392, - "byteOffset" : 7458756 - }, - { - "buffer" : 0, - "byteLength" : 1392, - "byteOffset" : 7460148 - }, - { - "buffer" : 0, - "byteLength" : 928, - "byteOffset" : 7461540 - }, - { - "buffer" : 0, - "byteLength" : 2304, - "byteOffset" : 7462468 - }, - { - "buffer" : 0, - "byteLength" : 2304, - "byteOffset" : 7464772 - }, - { - "buffer" : 0, - "byteLength" : 1536, - "byteOffset" : 7467076 - }, - { - "buffer" : 0, - "byteLength" : 672, - "byteOffset" : 7468612 - }, - { - "buffer" : 0, - "byteLength" : 1392, - "byteOffset" : 7469284 - }, - { - "buffer" : 0, - "byteLength" : 1392, - "byteOffset" : 7470676 - }, - { - "buffer" : 0, - "byteLength" : 928, - "byteOffset" : 7472068 - }, - { - "buffer" : 0, - "byteLength" : 960, - "byteOffset" : 7472996 - }, - { - "buffer" : 0, - "byteLength" : 2100, - "byteOffset" : 7473956 - }, - { - "buffer" : 0, - "byteLength" : 2100, - "byteOffset" : 7476056 - }, - { - "buffer" : 0, - "byteLength" : 1400, - "byteOffset" : 7478156 - }, - { - "buffer" : 0, - "byteLength" : 672, - "byteOffset" : 7479556 - }, - { - "buffer" : 0, - "byteLength" : 1392, - "byteOffset" : 7480228 - }, - { - "buffer" : 0, - "byteLength" : 1392, - "byteOffset" : 7481620 - }, - { - "buffer" : 0, - "byteLength" : 928, - "byteOffset" : 7483012 - }, - { - "buffer" : 0, - "byteLength" : 960, - "byteOffset" : 7483940 - }, - { - "buffer" : 0, - "byteLength" : 2388, - "byteOffset" : 7484900 - }, - { - "buffer" : 0, - "byteLength" : 2388, - "byteOffset" : 7487288 - }, - { - "buffer" : 0, - "byteLength" : 1592, - "byteOffset" : 7489676 - }, - { - "buffer" : 0, - "byteLength" : 672, - "byteOffset" : 7491268 - }, - { - "buffer" : 0, - "byteLength" : 1392, - "byteOffset" : 7491940 - }, - { - "buffer" : 0, - "byteLength" : 1392, - "byteOffset" : 7493332 - }, - { - "buffer" : 0, - "byteLength" : 928, - "byteOffset" : 7494724 - }, - { - "buffer" : 0, - "byteLength" : 2436, - "byteOffset" : 7495652 - }, - { - "buffer" : 0, - "byteLength" : 2436, - "byteOffset" : 7498088 - }, - { - "buffer" : 0, - "byteLength" : 1624, - "byteOffset" : 7500524 - }, - { - "buffer" : 0, - "byteLength" : 672, - "byteOffset" : 7502148 - }, - { - "buffer" : 0, - "byteLength" : 1392, - "byteOffset" : 7502820 - }, - { - "buffer" : 0, - "byteLength" : 1392, - "byteOffset" : 7504212 - }, - { - "buffer" : 0, - "byteLength" : 928, - "byteOffset" : 7505604 - }, - { - "buffer" : 0, - "byteLength" : 2340, - "byteOffset" : 7506532 - }, - { - "buffer" : 0, - "byteLength" : 2340, - "byteOffset" : 7508872 - }, - { - "buffer" : 0, - "byteLength" : 1560, - "byteOffset" : 7511212 - }, - { - "buffer" : 0, - "byteLength" : 672, - "byteOffset" : 7512772 - }, - { - "buffer" : 0, - "byteLength" : 1392, - "byteOffset" : 7513444 - }, - { - "buffer" : 0, - "byteLength" : 1392, - "byteOffset" : 7514836 - }, - { - "buffer" : 0, - "byteLength" : 928, - "byteOffset" : 7516228 - }, - { - "buffer" : 0, - "byteLength" : 2388, - "byteOffset" : 7517156 - }, - { - "buffer" : 0, - "byteLength" : 2388, - "byteOffset" : 7519544 - }, - { - "buffer" : 0, - "byteLength" : 1592, - "byteOffset" : 7521932 - }, - { - "buffer" : 0, - "byteLength" : 672, - "byteOffset" : 7523524 - }, - { - "buffer" : 0, - "byteLength" : 1104, - "byteOffset" : 7524196 - }, - { - "buffer" : 0, - "byteLength" : 1104, - "byteOffset" : 7525300 - }, - { - "buffer" : 0, - "byteLength" : 736, - "byteOffset" : 7526404 - }, - { - "buffer" : 0, - "byteLength" : 240, - "byteOffset" : 7527140 - }, - { - "buffer" : 0, - "byteLength" : 1032, - "byteOffset" : 7527380 - }, - { - "buffer" : 0, - "byteLength" : 1032, - "byteOffset" : 7528412 - }, - { - "buffer" : 0, - "byteLength" : 688, - "byteOffset" : 7529444 - }, - { - "buffer" : 0, - "byteLength" : 240, - "byteOffset" : 7530132 - }, - { - "buffer" : 0, - "byteLength" : 996, - "byteOffset" : 7530372 - }, - { - "buffer" : 0, - "byteLength" : 996, - "byteOffset" : 7531368 - }, - { - "buffer" : 0, - "byteLength" : 664, - "byteOffset" : 7532364 - }, - { - "buffer" : 0, - "byteLength" : 240, - "byteOffset" : 7533028 - }, - { - "buffer" : 0, - "byteLength" : 996, - "byteOffset" : 7533268 - }, - { - "buffer" : 0, - "byteLength" : 996, - "byteOffset" : 7534264 - }, - { - "buffer" : 0, - "byteLength" : 664, - "byteOffset" : 7535260 - }, - { - "buffer" : 0, - "byteLength" : 240, - "byteOffset" : 7535924 - }, - { - "buffer" : 0, - "byteLength" : 1008, - "byteOffset" : 7536164 - }, - { - "buffer" : 0, - "byteLength" : 1008, - "byteOffset" : 7537172 - }, - { - "buffer" : 0, - "byteLength" : 672, - "byteOffset" : 7538180 - }, - { - "buffer" : 0, - "byteLength" : 240, - "byteOffset" : 7538852 - }, - { - "buffer" : 0, - "byteLength" : 948, - "byteOffset" : 7539092 - }, - { - "buffer" : 0, - "byteLength" : 948, - "byteOffset" : 7540040 - }, - { - "buffer" : 0, - "byteLength" : 632, - "byteOffset" : 7540988 - }, - { - "buffer" : 0, - "byteLength" : 240, - "byteOffset" : 7541620 - }, - { - "buffer" : 0, - "byteLength" : 1032, - "byteOffset" : 7541860 - }, - { - "buffer" : 0, - "byteLength" : 1032, - "byteOffset" : 7542892 - }, - { - "buffer" : 0, - "byteLength" : 688, - "byteOffset" : 7543924 - }, - { - "buffer" : 0, - "byteLength" : 240, - "byteOffset" : 7544612 - }, - { - "buffer" : 0, - "byteLength" : 996, - "byteOffset" : 7544852 - }, - { - "buffer" : 0, - "byteLength" : 996, - "byteOffset" : 7545848 - }, - { - "buffer" : 0, - "byteLength" : 664, - "byteOffset" : 7546844 - }, - { - "buffer" : 0, - "byteLength" : 240, - "byteOffset" : 7547508 - }, - { - "buffer" : 0, - "byteLength" : 1008, - "byteOffset" : 7547748 - }, - { - "buffer" : 0, - "byteLength" : 1008, - "byteOffset" : 7548756 - }, - { - "buffer" : 0, - "byteLength" : 672, - "byteOffset" : 7549764 - }, - { - "buffer" : 0, - "byteLength" : 240, - "byteOffset" : 7550436 - }, - { - "buffer" : 0, - "byteLength" : 1032, - "byteOffset" : 7550676 - }, - { - "buffer" : 0, - "byteLength" : 1032, - "byteOffset" : 7551708 - }, - { - "buffer" : 0, - "byteLength" : 688, - "byteOffset" : 7552740 - }, - { - "buffer" : 0, - "byteLength" : 240, - "byteOffset" : 7553428 - }, - { - "buffer" : 0, - "byteLength" : 1008, - "byteOffset" : 7553668 - }, - { - "buffer" : 0, - "byteLength" : 1008, - "byteOffset" : 7554676 - }, - { - "buffer" : 0, - "byteLength" : 672, - "byteOffset" : 7555684 - }, - { - "buffer" : 0, - "byteLength" : 240, - "byteOffset" : 7556356 - }, - { - "buffer" : 0, - "byteLength" : 840, - "byteOffset" : 7556596 - }, - { - "buffer" : 0, - "byteLength" : 840, - "byteOffset" : 7557436 - }, - { - "buffer" : 0, - "byteLength" : 560, - "byteOffset" : 7558276 - }, - { - "buffer" : 0, - "byteLength" : 192, - "byteOffset" : 7558836 - }, - { - "buffer" : 0, - "byteLength" : 7008, - "byteOffset" : 7559028 - }, - { - "buffer" : 0, - "byteLength" : 7008, - "byteOffset" : 7566036 - }, - { - "buffer" : 0, - "byteLength" : 4672, - "byteOffset" : 7573044 - }, - { - "buffer" : 0, - "byteLength" : 1680, - "byteOffset" : 7577716 - }, - { - "buffer" : 0, - "byteLength" : 360, - "byteOffset" : 7579396 - }, - { - "buffer" : 0, - "byteLength" : 360, - "byteOffset" : 7579756 - }, - { - "buffer" : 0, - "byteLength" : 240, - "byteOffset" : 7580116 - }, - { - "buffer" : 0, - "byteLength" : 108, - "byteOffset" : 7580356 - }, - { - "buffer" : 0, - "byteLength" : 948, - "byteOffset" : 7580464 - }, - { - "buffer" : 0, - "byteLength" : 948, - "byteOffset" : 7581412 - }, - { - "buffer" : 0, - "byteLength" : 632, - "byteOffset" : 7582360 - }, - { - "buffer" : 0, - "byteLength" : 216, - "byteOffset" : 7582992 - }, - { - "buffer" : 0, - "byteLength" : 3828, - "byteOffset" : 7583208 - }, - { - "buffer" : 0, - "byteLength" : 3828, - "byteOffset" : 7587036 - }, - { - "buffer" : 0, - "byteLength" : 2552, - "byteOffset" : 7590864 - }, - { - "buffer" : 0, - "byteLength" : 960, - "byteOffset" : 7593416 - }, - { - "buffer" : 0, - "byteLength" : 600, - "byteOffset" : 7594376 - }, - { - "buffer" : 0, - "byteLength" : 600, - "byteOffset" : 7594976 - }, - { - "buffer" : 0, - "byteLength" : 400, - "byteOffset" : 7595576 - }, - { - "buffer" : 0, - "byteLength" : 144, - "byteOffset" : 7595976 - }, - { - "buffer" : 0, - "byteLength" : 2112, - "byteOffset" : 7596120 - }, - { - "buffer" : 0, - "byteLength" : 2112, - "byteOffset" : 7598232 - }, - { - "buffer" : 0, - "byteLength" : 1408, - "byteOffset" : 7600344 - }, - { - "buffer" : 0, - "byteLength" : 492, - "byteOffset" : 7601752 - }, - { - "buffer" : 0, - "byteLength" : 672, - "byteOffset" : 7602244 - }, - { - "buffer" : 0, - "byteLength" : 672, - "byteOffset" : 7602916 - }, - { - "buffer" : 0, - "byteLength" : 448, - "byteOffset" : 7603588 - }, - { - "buffer" : 0, - "byteLength" : 144, - "byteOffset" : 7604036 - }, - { - "buffer" : 0, - "byteLength" : 2160, - "byteOffset" : 7604180 - }, - { - "buffer" : 0, - "byteLength" : 2160, - "byteOffset" : 7606340 - }, - { - "buffer" : 0, - "byteLength" : 1440, - "byteOffset" : 7608500 - }, - { - "buffer" : 0, - "byteLength" : 492, - "byteOffset" : 7609940 - }, - { - "buffer" : 0, - "byteLength" : 6156, - "byteOffset" : 7610432 - }, - { - "buffer" : 0, - "byteLength" : 6156, - "byteOffset" : 7616588 - }, - { - "buffer" : 0, - "byteLength" : 4104, - "byteOffset" : 7622744 - }, - { - "buffer" : 0, - "byteLength" : 1668, - "byteOffset" : 7626848 - }, - { - "buffer" : 0, - "byteLength" : 5556, - "byteOffset" : 7628516 - }, - { - "buffer" : 0, - "byteLength" : 5556, - "byteOffset" : 7634072 - }, - { - "buffer" : 0, - "byteLength" : 3704, - "byteOffset" : 7639628 - }, - { - "buffer" : 0, - "byteLength" : 1668, - "byteOffset" : 7643332 - }, - { - "buffer" : 0, - "byteLength" : 1524, - "byteOffset" : 7645000 - }, - { - "buffer" : 0, - "byteLength" : 1524, - "byteOffset" : 7646524 - }, - { - "buffer" : 0, - "byteLength" : 1016, - "byteOffset" : 7648048 - }, - { - "buffer" : 0, - "byteLength" : 300, - "byteOffset" : 7649064 - }, - { - "buffer" : 0, - "byteLength" : 1512, - "byteOffset" : 7649364 - }, - { - "buffer" : 0, - "byteLength" : 1512, - "byteOffset" : 7650876 - }, - { - "buffer" : 0, - "byteLength" : 1008, - "byteOffset" : 7652388 - }, - { - "buffer" : 0, - "byteLength" : 444, - "byteOffset" : 7653396 - }, - { - "buffer" : 0, - "byteLength" : 1512, - "byteOffset" : 7653840 - }, - { - "buffer" : 0, - "byteLength" : 1512, - "byteOffset" : 7655352 - }, - { - "buffer" : 0, - "byteLength" : 1008, - "byteOffset" : 7656864 - }, - { - "buffer" : 0, - "byteLength" : 444, - "byteOffset" : 7657872 - }, - { - "buffer" : 0, - "byteLength" : 1992, - "byteOffset" : 7658316 - }, - { - "buffer" : 0, - "byteLength" : 1992, - "byteOffset" : 7660308 - }, - { - "buffer" : 0, - "byteLength" : 1328, - "byteOffset" : 7662300 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 7663628 - }, - { - "buffer" : 0, - "byteLength" : 2004, - "byteOffset" : 7664156 - }, - { - "buffer" : 0, - "byteLength" : 2004, - "byteOffset" : 7666160 - }, - { - "buffer" : 0, - "byteLength" : 1336, - "byteOffset" : 7668164 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 7669500 - }, - { - "buffer" : 0, - "byteLength" : 1956, - "byteOffset" : 7670028 - }, - { - "buffer" : 0, - "byteLength" : 1956, - "byteOffset" : 7671984 - }, - { - "buffer" : 0, - "byteLength" : 1304, - "byteOffset" : 7673940 - }, - { - "buffer" : 0, - "byteLength" : 1896, - "byteOffset" : 7675244 - }, - { - "buffer" : 0, - "byteLength" : 1896, - "byteOffset" : 7677140 - }, - { - "buffer" : 0, - "byteLength" : 1264, - "byteOffset" : 7679036 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 7680300 - }, - { - "buffer" : 0, - "byteLength" : 1896, - "byteOffset" : 7680828 - }, - { - "buffer" : 0, - "byteLength" : 1896, - "byteOffset" : 7682724 - }, - { - "buffer" : 0, - "byteLength" : 1264, - "byteOffset" : 7684620 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 7685884 - }, - { - "buffer" : 0, - "byteLength" : 1896, - "byteOffset" : 7686412 - }, - { - "buffer" : 0, - "byteLength" : 1896, - "byteOffset" : 7688308 - }, - { - "buffer" : 0, - "byteLength" : 1264, - "byteOffset" : 7690204 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 7691468 - }, - { - "buffer" : 0, - "byteLength" : 1896, - "byteOffset" : 7691996 - }, - { - "buffer" : 0, - "byteLength" : 1896, - "byteOffset" : 7693892 - }, - { - "buffer" : 0, - "byteLength" : 1264, - "byteOffset" : 7695788 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 7697052 - }, - { - "buffer" : 0, - "byteLength" : 1908, - "byteOffset" : 7697580 - }, - { - "buffer" : 0, - "byteLength" : 1908, - "byteOffset" : 7699488 - }, - { - "buffer" : 0, - "byteLength" : 1272, - "byteOffset" : 7701396 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 7702668 - }, - { - "buffer" : 0, - "byteLength" : 1896, - "byteOffset" : 7703196 - }, - { - "buffer" : 0, - "byteLength" : 1896, - "byteOffset" : 7705092 - }, - { - "buffer" : 0, - "byteLength" : 1264, - "byteOffset" : 7706988 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 7708252 - }, - { - "buffer" : 0, - "byteLength" : 1872, - "byteOffset" : 7708780 - }, - { - "buffer" : 0, - "byteLength" : 1872, - "byteOffset" : 7710652 - }, - { - "buffer" : 0, - "byteLength" : 1248, - "byteOffset" : 7712524 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 7713772 - }, - { - "buffer" : 0, - "byteLength" : 1920, - "byteOffset" : 7714300 - }, - { - "buffer" : 0, - "byteLength" : 1920, - "byteOffset" : 7716220 - }, - { - "buffer" : 0, - "byteLength" : 1280, - "byteOffset" : 7718140 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 7719420 - }, - { - "buffer" : 0, - "byteLength" : 1872, - "byteOffset" : 7719948 - }, - { - "buffer" : 0, - "byteLength" : 1872, - "byteOffset" : 7721820 - }, - { - "buffer" : 0, - "byteLength" : 1248, - "byteOffset" : 7723692 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 7724940 - }, - { - "buffer" : 0, - "byteLength" : 1908, - "byteOffset" : 7725468 - }, - { - "buffer" : 0, - "byteLength" : 1908, - "byteOffset" : 7727376 - }, - { - "buffer" : 0, - "byteLength" : 1272, - "byteOffset" : 7729284 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 7730556 - }, - { - "buffer" : 0, - "byteLength" : 1908, - "byteOffset" : 7731084 - }, - { - "buffer" : 0, - "byteLength" : 1908, - "byteOffset" : 7732992 - }, - { - "buffer" : 0, - "byteLength" : 1272, - "byteOffset" : 7734900 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 7736172 - }, - { - "buffer" : 0, - "byteLength" : 1980, - "byteOffset" : 7736700 - }, - { - "buffer" : 0, - "byteLength" : 1980, - "byteOffset" : 7738680 - }, - { - "buffer" : 0, - "byteLength" : 1320, - "byteOffset" : 7740660 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 7741980 - }, - { - "buffer" : 0, - "byteLength" : 1980, - "byteOffset" : 7742508 - }, - { - "buffer" : 0, - "byteLength" : 1980, - "byteOffset" : 7744488 - }, - { - "buffer" : 0, - "byteLength" : 1320, - "byteOffset" : 7746468 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 7747788 - }, - { - "buffer" : 0, - "byteLength" : 1512, - "byteOffset" : 7748316 - }, - { - "buffer" : 0, - "byteLength" : 1512, - "byteOffset" : 7749828 - }, - { - "buffer" : 0, - "byteLength" : 1008, - "byteOffset" : 7751340 - }, - { - "buffer" : 0, - "byteLength" : 444, - "byteOffset" : 7752348 - }, - { - "buffer" : 0, - "byteLength" : 1500, - "byteOffset" : 7752792 - }, - { - "buffer" : 0, - "byteLength" : 1500, - "byteOffset" : 7754292 - }, - { - "buffer" : 0, - "byteLength" : 1000, - "byteOffset" : 7755792 - }, - { - "buffer" : 0, - "byteLength" : 444, - "byteOffset" : 7756792 - }, - { - "buffer" : 0, - "byteLength" : 1524, - "byteOffset" : 7757236 - }, - { - "buffer" : 0, - "byteLength" : 1524, - "byteOffset" : 7758760 - }, - { - "buffer" : 0, - "byteLength" : 1016, - "byteOffset" : 7760284 - }, - { - "buffer" : 0, - "byteLength" : 444, - "byteOffset" : 7761300 - }, - { - "buffer" : 0, - "byteLength" : 1500, - "byteOffset" : 7761744 - }, - { - "buffer" : 0, - "byteLength" : 1500, - "byteOffset" : 7763244 - }, - { - "buffer" : 0, - "byteLength" : 1000, - "byteOffset" : 7764744 - }, - { - "buffer" : 0, - "byteLength" : 444, - "byteOffset" : 7765744 - }, - { - "buffer" : 0, - "byteLength" : 2004, - "byteOffset" : 7766188 - }, - { - "buffer" : 0, - "byteLength" : 2004, - "byteOffset" : 7768192 - }, - { - "buffer" : 0, - "byteLength" : 1336, - "byteOffset" : 7770196 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 7771532 - }, - { - "buffer" : 0, - "byteLength" : 1968, - "byteOffset" : 7772060 - }, - { - "buffer" : 0, - "byteLength" : 1968, - "byteOffset" : 7774028 - }, - { - "buffer" : 0, - "byteLength" : 1312, - "byteOffset" : 7775996 - }, - { - "buffer" : 0, - "byteLength" : 528, - "byteOffset" : 7777308 - } - ], - "samplers" : [ - { - "magFilter" : 9729, - "minFilter" : 9987 - } - ], - "buffers" : [ - { - "byteLength" : 7777836, - "uri" : "sponza2.bin" - } - ] -} diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza2.mini b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza2.mini deleted file mode 100644 index f7d8ec1..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza2.mini and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_arch_baseColor.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_arch_baseColor.jpg deleted file mode 100644 index 4369bc7..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_arch_baseColor.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_arch_basecolor.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_arch_basecolor.dds deleted file mode 100644 index c3be95c..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_arch_basecolor.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_arch_metallicRoughness.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_arch_metallicRoughness.jpg deleted file mode 100644 index a16c537..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_arch_metallicRoughness.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_arch_metallicroughness.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_arch_metallicroughness.dds deleted file mode 100644 index ae2e7c2..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_arch_metallicroughness.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_arch_normal.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_arch_normal.dds deleted file mode 100644 index adcfb7b..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_arch_normal.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_arch_normal.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_arch_normal.jpg deleted file mode 100644 index ef0e2dd..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_arch_normal.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_bricks_a_baseColor.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_bricks_a_baseColor.jpg deleted file mode 100644 index e5b5164..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_bricks_a_baseColor.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_bricks_a_basecolor.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_bricks_a_basecolor.dds deleted file mode 100644 index f01b193..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_bricks_a_basecolor.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_bricks_a_metallicRoughness.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_bricks_a_metallicRoughness.jpg deleted file mode 100644 index fc8a786..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_bricks_a_metallicRoughness.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_bricks_a_metallicroughness.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_bricks_a_metallicroughness.dds deleted file mode 100644 index 2afb768..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_bricks_a_metallicroughness.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_bricks_a_normal.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_bricks_a_normal.dds deleted file mode 100644 index 50962a4..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_bricks_a_normal.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_bricks_a_normal.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_bricks_a_normal.jpg deleted file mode 100644 index 7ae092c..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_bricks_a_normal.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_ceiling_a_baseColor.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_ceiling_a_baseColor.jpg deleted file mode 100644 index 0cffbd9..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_ceiling_a_baseColor.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_ceiling_a_basecolor.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_ceiling_a_basecolor.dds deleted file mode 100644 index c1a1794..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_ceiling_a_basecolor.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_ceiling_a_metallicRoughness.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_ceiling_a_metallicRoughness.jpg deleted file mode 100644 index 35210b0..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_ceiling_a_metallicRoughness.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_ceiling_a_metallicroughness.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_ceiling_a_metallicroughness.dds deleted file mode 100644 index 3c71f45..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_ceiling_a_metallicroughness.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_ceiling_a_normal.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_ceiling_a_normal.dds deleted file mode 100644 index c27d6d2..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_ceiling_a_normal.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_ceiling_a_normal.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_ceiling_a_normal.jpg deleted file mode 100644 index e61061b..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_ceiling_a_normal.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_a_baseColor.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_a_baseColor.jpg deleted file mode 100644 index 876fcc0..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_a_baseColor.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_a_basecolor.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_a_basecolor.dds deleted file mode 100644 index d398f42..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_a_basecolor.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_a_metallicRoughness.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_a_metallicRoughness.jpg deleted file mode 100644 index 85ddd13..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_a_metallicRoughness.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_a_metallicroughness.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_a_metallicroughness.dds deleted file mode 100644 index 42e9024..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_a_metallicroughness.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_a_normal.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_a_normal.dds deleted file mode 100644 index 54b6a05..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_a_normal.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_a_normal.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_a_normal.jpg deleted file mode 100644 index 9612fe2..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_a_normal.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_b_baseColor.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_b_baseColor.jpg deleted file mode 100644 index c2ebbcc..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_b_baseColor.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_b_basecolor.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_b_basecolor.dds deleted file mode 100644 index 7f907dc..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_b_basecolor.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_b_metallicRoughness.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_b_metallicRoughness.jpg deleted file mode 100644 index e43fb7e..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_b_metallicRoughness.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_b_metallicroughness.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_b_metallicroughness.dds deleted file mode 100644 index 6403b7a..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_b_metallicroughness.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_b_normal.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_b_normal.dds deleted file mode 100644 index 15fe9b9..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_b_normal.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_b_normal.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_b_normal.jpg deleted file mode 100644 index 975fcc6..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_b_normal.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_c_baseColor.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_c_baseColor.jpg deleted file mode 100644 index f80cfb8..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_c_baseColor.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_c_basecolor.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_c_basecolor.dds deleted file mode 100644 index 1bf618b..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_c_basecolor.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_c_metallicRoughness.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_c_metallicRoughness.jpg deleted file mode 100644 index 6d31090..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_c_metallicRoughness.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_c_metallicroughness.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_c_metallicroughness.dds deleted file mode 100644 index 0570e6e..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_c_metallicroughness.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_c_normal.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_c_normal.dds deleted file mode 100644 index fa96252..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_c_normal.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_c_normal.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_c_normal.jpg deleted file mode 100644 index 547bc68..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_column_c_normal.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_curtain_baseColor.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_curtain_baseColor.jpg deleted file mode 100644 index c738be8..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_curtain_baseColor.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_curtain_basecolor.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_curtain_basecolor.dds deleted file mode 100644 index b4ac90f..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_curtain_basecolor.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_curtain_blue_baseColor.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_curtain_blue_baseColor.jpg deleted file mode 100644 index 9db2fc5..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_curtain_blue_baseColor.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_curtain_blue_basecolor.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_curtain_blue_basecolor.dds deleted file mode 100644 index 760e0ff..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_curtain_blue_basecolor.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_curtain_green_baseColor.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_curtain_green_baseColor.jpg deleted file mode 100644 index 9c6c75f..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_curtain_green_baseColor.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_curtain_green_basecolor.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_curtain_green_basecolor.dds deleted file mode 100644 index b1d636e..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_curtain_green_basecolor.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_curtain_metallicRoughness.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_curtain_metallicRoughness.jpg deleted file mode 100644 index d0185c1..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_curtain_metallicRoughness.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_curtain_metallicroughness.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_curtain_metallicroughness.dds deleted file mode 100644 index 9630dd1..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_curtain_metallicroughness.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_curtain_normal.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_curtain_normal.dds deleted file mode 100644 index f41b3c4..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_curtain_normal.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_curtain_normal.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_curtain_normal.jpg deleted file mode 100644 index 6ec9413..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_curtain_normal.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_details_baseColor.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_details_baseColor.jpg deleted file mode 100644 index 8763238..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_details_baseColor.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_details_basecolor.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_details_basecolor.dds deleted file mode 100644 index 70c7a8b..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_details_basecolor.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_details_metallicRoughness.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_details_metallicRoughness.jpg deleted file mode 100644 index a021443..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_details_metallicRoughness.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_details_metallicroughness.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_details_metallicroughness.dds deleted file mode 100644 index 37bf567..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_details_metallicroughness.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_details_normal.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_details_normal.dds deleted file mode 100644 index 46002e6..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_details_normal.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_details_normal.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_details_normal.jpg deleted file mode 100644 index a9db3b6..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_details_normal.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_fabric_baseColor.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_fabric_baseColor.jpg deleted file mode 100644 index 7cadf3b..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_fabric_baseColor.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_fabric_basecolor.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_fabric_basecolor.dds deleted file mode 100644 index 294f681..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_fabric_basecolor.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_fabric_blue_baseColor.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_fabric_blue_baseColor.jpg deleted file mode 100644 index d26acf7..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_fabric_blue_baseColor.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_fabric_blue_basecolor.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_fabric_blue_basecolor.dds deleted file mode 100644 index 6ed7b4c..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_fabric_blue_basecolor.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_fabric_green_baseColor.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_fabric_green_baseColor.jpg deleted file mode 100644 index be547c7..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_fabric_green_baseColor.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_fabric_green_basecolor.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_fabric_green_basecolor.dds deleted file mode 100644 index fe7ab15..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_fabric_green_basecolor.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_fabric_metallicRoughness.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_fabric_metallicRoughness.jpg deleted file mode 100644 index 97a18fb..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_fabric_metallicRoughness.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_fabric_metallicroughness.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_fabric_metallicroughness.dds deleted file mode 100644 index 6b0d350..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_fabric_metallicroughness.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_fabric_normal.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_fabric_normal.dds deleted file mode 100644 index f7dc3b9..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_fabric_normal.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_fabric_normal.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_fabric_normal.jpg deleted file mode 100644 index af2b856..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_fabric_normal.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_flagpole_baseColor.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_flagpole_baseColor.jpg deleted file mode 100644 index 267b601..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_flagpole_baseColor.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_flagpole_basecolor.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_flagpole_basecolor.dds deleted file mode 100644 index 1037ec9..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_flagpole_basecolor.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_flagpole_metallicRoughness.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_flagpole_metallicRoughness.jpg deleted file mode 100644 index db87640..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_flagpole_metallicRoughness.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_flagpole_metallicroughness.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_flagpole_metallicroughness.dds deleted file mode 100644 index 7d20384..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_flagpole_metallicroughness.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_flagpole_normal.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_flagpole_normal.dds deleted file mode 100644 index a62c6e1..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_flagpole_normal.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_flagpole_normal.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_flagpole_normal.jpg deleted file mode 100644 index a868ec5..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_flagpole_normal.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_floor_a_baseColor.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_floor_a_baseColor.jpg deleted file mode 100644 index 7638971..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_floor_a_baseColor.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_floor_a_basecolor.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_floor_a_basecolor.dds deleted file mode 100644 index 1b63edf..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_floor_a_basecolor.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_floor_a_metallicRoughness.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_floor_a_metallicRoughness.jpg deleted file mode 100644 index eb43735..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_floor_a_metallicRoughness.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_floor_a_metallicroughness.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_floor_a_metallicroughness.dds deleted file mode 100644 index f4ea4e3..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_floor_a_metallicroughness.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_floor_a_normal.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_floor_a_normal.dds deleted file mode 100644 index 07ffd89..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_floor_a_normal.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_floor_a_normal.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_floor_a_normal.jpg deleted file mode 100644 index 0f0276e..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_floor_a_normal.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_roof_baseColor.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_roof_baseColor.jpg deleted file mode 100644 index d8b15ae..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_roof_baseColor.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_roof_basecolor.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_roof_basecolor.dds deleted file mode 100644 index 553b9bc..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_roof_basecolor.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_roof_metallicRoughness.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_roof_metallicRoughness.jpg deleted file mode 100644 index 0f9a484..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_roof_metallicRoughness.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_roof_metallicroughness.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_roof_metallicroughness.dds deleted file mode 100644 index 6e9a31b..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_roof_metallicroughness.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_roof_normal.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_roof_normal.dds deleted file mode 100644 index ea15d1d..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_roof_normal.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_roof_normal.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_roof_normal.jpg deleted file mode 100644 index 20f0b78..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_roof_normal.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_thorn_baseColor.png b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_thorn_baseColor.png deleted file mode 100644 index 5725934..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_thorn_baseColor.png and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_thorn_basecolor.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_thorn_basecolor.dds deleted file mode 100644 index a4a48c5..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_thorn_basecolor.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_thorn_metallicRoughness.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_thorn_metallicRoughness.jpg deleted file mode 100644 index b2c5338..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_thorn_metallicRoughness.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_thorn_metallicroughness.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_thorn_metallicroughness.dds deleted file mode 100644 index a2c28e5..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_thorn_metallicroughness.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_thorn_normal.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_thorn_normal.dds deleted file mode 100644 index 4ba52e7..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_thorn_normal.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_thorn_normal.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_thorn_normal.jpg deleted file mode 100644 index 731e7ca..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/sponza_thorn_normal.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_baseColor.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/vase_baseColor.jpg deleted file mode 100644 index 2530e8d..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_baseColor.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_basecolor.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/vase_basecolor.dds deleted file mode 100644 index 5dba451..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_basecolor.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_hanging_baseColor.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/vase_hanging_baseColor.jpg deleted file mode 100644 index a1fb2d9..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_hanging_baseColor.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_hanging_basecolor.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/vase_hanging_basecolor.dds deleted file mode 100644 index 2f4f3be..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_hanging_basecolor.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_hanging_metallicRoughness.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/vase_hanging_metallicRoughness.jpg deleted file mode 100644 index 05162f9..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_hanging_metallicRoughness.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_hanging_metallicroughness.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/vase_hanging_metallicroughness.dds deleted file mode 100644 index fdd4b8d..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_hanging_metallicroughness.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_hanging_normal.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/vase_hanging_normal.dds deleted file mode 100644 index be7d7bf..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_hanging_normal.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_hanging_normal.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/vase_hanging_normal.jpg deleted file mode 100644 index 9c085b6..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_hanging_normal.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_metallicRoughness.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/vase_metallicRoughness.jpg deleted file mode 100644 index 85c099c..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_metallicRoughness.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_metallicroughness.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/vase_metallicroughness.dds deleted file mode 100644 index 14a423c..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_metallicroughness.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_normal.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/vase_normal.dds deleted file mode 100644 index d29fca3..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_normal.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_normal.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/vase_normal.jpg deleted file mode 100644 index 94b2d6e..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_normal.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_plant_baseColor.png b/xess/samples/xess_demo/Assets/Sponza/pbr/vase_plant_baseColor.png deleted file mode 100644 index beb63a4..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_plant_baseColor.png and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_plant_basecolor.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/vase_plant_basecolor.dds deleted file mode 100644 index 3a009f7..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_plant_basecolor.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_plant_metallicRoughness.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/vase_plant_metallicRoughness.jpg deleted file mode 100644 index 0ffd724..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_plant_metallicRoughness.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_plant_metallicroughness.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/vase_plant_metallicroughness.dds deleted file mode 100644 index cefe2dc..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_plant_metallicroughness.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_plant_normal.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/vase_plant_normal.dds deleted file mode 100644 index 2837a3f..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_plant_normal.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_plant_normal.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/vase_plant_normal.jpg deleted file mode 100644 index 55fae0c..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_plant_normal.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_round_baseColor.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/vase_round_baseColor.jpg deleted file mode 100644 index 01d5563..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_round_baseColor.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_round_basecolor.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/vase_round_basecolor.dds deleted file mode 100644 index bb7a0e6..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_round_basecolor.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_round_metallicRoughness.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/vase_round_metallicRoughness.jpg deleted file mode 100644 index 5a1efbd..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_round_metallicRoughness.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_round_metallicroughness.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/vase_round_metallicroughness.dds deleted file mode 100644 index 40cca20..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_round_metallicroughness.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_round_normal.dds b/xess/samples/xess_demo/Assets/Sponza/pbr/vase_round_normal.dds deleted file mode 100644 index 18c69a3..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_round_normal.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_round_normal.jpg b/xess/samples/xess_demo/Assets/Sponza/pbr/vase_round_normal.jpg deleted file mode 100644 index 31fd24e..0000000 Binary files a/xess/samples/xess_demo/Assets/Sponza/pbr/vase_round_normal.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Textures/BRDF_LUT.dds b/xess/samples/xess_demo/Assets/Textures/BRDF_LUT.dds deleted file mode 100644 index 113b78d..0000000 Binary files a/xess/samples/xess_demo/Assets/Textures/BRDF_LUT.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Textures/Blouberg_diffuseIBL.dds b/xess/samples/xess_demo/Assets/Textures/Blouberg_diffuseIBL.dds deleted file mode 100644 index c7afc07..0000000 Binary files a/xess/samples/xess_demo/Assets/Textures/Blouberg_diffuseIBL.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Textures/Blouberg_specularIBL.dds b/xess/samples/xess_demo/Assets/Textures/Blouberg_specularIBL.dds deleted file mode 100644 index fe6b7ae..0000000 Binary files a/xess/samples/xess_demo/Assets/Textures/Blouberg_specularIBL.dds and /dev/null differ diff --git a/xess/samples/xess_demo/Assets/Textures/README.txt b/xess/samples/xess_demo/Assets/Textures/README.txt deleted file mode 100644 index 6f5e9cc..0000000 --- a/xess/samples/xess_demo/Assets/Textures/README.txt +++ /dev/null @@ -1 +0,0 @@ -Blouberg HDRI from - https://polyhaven.com/a/blouberg_sunrise_2, under CC0 license. \ No newline at end of file diff --git a/xess/samples/xess_demo/CMakeLists.txt b/xess/samples/xess_demo/CMakeLists.txt deleted file mode 100644 index 292d175..0000000 --- a/xess/samples/xess_demo/CMakeLists.txt +++ /dev/null @@ -1,190 +0,0 @@ -############################################################################### -# Copyright 2021 Intel Corporation -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files(the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions : -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -############################################################################## - -cmake_minimum_required(VERSION 3.12) - -#set_property(GLOBAL PROPERTY USE_FOLDERS ON) - -option(ENABLE_XESS_DEMO_ASSETS_COPY "Enable XeSS Demo Assets folder copy" ON) - -option(ENABLE_XESS_DEMO_SHADER_DEBUG "Enable XeSS Demo shaders debugging and disable optimizations" OFF) - -# Set minimum supported SDK and MSVC versions -set(MIN_SDK_VERSION "10.0.18363") -set(MIN_MSVC_VERSION "1920") - -set (TARGET_NAME XeSSDemo) - -project(${TARGET_NAME}) - -# Force MIN_SDK_VERSION or newer -if((${CMAKE_SYSTEM_VERSION} STRLESS ${MIN_SDK_VERSION}) AND ("$ENV{Version_Number}" STRLESS ${MIN_SDK_VERSION})) - message(FATAL_ERROR "Windows SDK ${MIN_SDK_VERSION} or later required. Installed: ${CMAKE_SYSTEM_VERSION}") -endif() - -#Force MIN_MSVC_VERSION or newer -if((${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC") AND (${MSVC_VERSION} STRLESS ${MIN_MSVC_VERSION})) - message(FATAL_ERROR "MSVC ${MIN_MSVC_VERSION} required. Installed: ${CMAKE_CXX_COMPILER_ID} - ${CMAKE_CXX_COMPILER_VERSION}") -endif() - -#set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) -#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) -#set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) - -file(GLOB_RECURSE SRC_FILES - "Source/*.cpp" - "Source/*.h" -) - -file(GLOB_RECURSE VERTEX_SHADER_FILES - "Source/*VS.hlsl" -) - -file(GLOB_RECURSE PIXEL_SHADER_FILES - "Source/*PS.hlsl" -) - -file(GLOB_RECURSE COMPUTE_SHADER_FILES - "Source/*CS.hlsl" -) - -file(GLOB_RECURSE SHADER_INCLUDE_FILES - "Source/*.hlsli" -) - -set(SHADER_INC_PATH - ${CMAKE_CURRENT_SOURCE_DIR}/MiniEngine/Core -) - -include(Script/utility.cmake) - -hlsl_compile("${VERTEX_SHADER_FILES}" Vertex "${SHADER_INC_PATH}" "_GAMING_DESKTOP=1" ENABLE_XESS_DEMO_SHADER_DEBUG) -hlsl_compile("${PIXEL_SHADER_FILES}" Pixel "${SHADER_INC_PATH}" "_GAMING_DESKTOP=1" ENABLE_XESS_DEMO_SHADER_DEBUG) -hlsl_compile("${COMPUTE_SHADER_FILES}" Compute "${SHADER_INC_PATH}" "_GAMING_DESKTOP=1" ENABLE_XESS_DEMO_SHADER_DEBUG) -set_property(SOURCE ${SHADER_INCLUDE_FILES} PROPERTY HEADER_FILE_ONLY true) - -set(SOURCE_FILES - ${SRC_FILES} - ${VERTEX_SHADER_FILES} - ${PIXEL_SHADER_FILES} - ${COMPUTE_SHADER_FILES} - ${SHADER_INCLUDE_FILES} -) - -source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCE_FILES}) - -add_executable(${TARGET_NAME} WIN32 ${SOURCE_FILES} Source/XeSSDemo.manifest) - -set_msvc_precompiled_header(pch.h Source/pch.cpp "${SOURCE_FILES}") - -target_compile_definitions(${TARGET_NAME} PRIVATE - UNICODE _UNICODE __WRL_NO_DEFAULT_LIB__ _GAMING_DESKTOP - $<$:_DEBUG> - $<$:RELEASE> - $<$:RELEASE> - $<$:PROFILE> # We treat RelWithDebInfo as "Profile" config -) - -target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Source - ${CMAKE_CURRENT_SOURCE_DIR}/MiniEngine/Core - ${CMAKE_CURRENT_SOURCE_DIR}/MiniEngine/Model - ${CMAKE_CURRENT_SOURCE_DIR}/MiniEngine/Dependencies/WinPixEventRuntime/Include/WinPixEventRuntime - ${CMAKE_CURRENT_SOURCE_DIR}/MiniEngine/Dependencies/imgui - ${CMAKE_SOURCE_DIR}/libxess/include - ${CMAKE_CURRENT_SOURCE_DIR}/../../inc - ${CMAKE_BINARY_DIR}/bin/$ - - ${PROJECT_BINARY_DIR}/MiniEngine/$ - ${PROJECT_BINARY_DIR}/$ -) - -#set_target_properties(${TARGET_NAME} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:MSVCRT") - -if (NOT XESS_BUILD_INTERNAL_SAMPLE) - set(XESS_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../lib) -else () - set(XESS_LIB_DIR ${CMAKE_BINARY_DIR}/bin/$) -endif() - -target_link_libraries(${TARGET_NAME} PRIVATE MiniEngine - ${XESS_LIB_DIR}/libxess.lib - DirectXMesh - DirectXTex - zlibstatic - ${CMAKE_CURRENT_SOURCE_DIR}/MiniEngine/Dependencies/WinPixEventRuntime/bin/x64/WinPixEventRuntime.lib -) - -# Custom command for copying font. -add_custom_command(TARGET ${TARGET_NAME} - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/MiniEngine/Dependencies/WinPixEventRuntime/bin/x64/WinPixEventRuntime.dll" - "$/WinPixEventRuntime.dll") - -if (ENABLE_XESS_DEMO_ASSETS_COPY) - # Custom command for copying art assets. - add_custom_command(TARGET ${TARGET_NAME} - COMMAND ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/Assets" "$/Assets") -endif() - -# Custom command for copying font. -add_custom_command(TARGET ${TARGET_NAME} - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/MiniEngine/Dependencies/imgui/misc/fonts/DroidSans.ttf" - "$/DroidSans.ttf") - -# Custom command for copying SDK dlls. -file(GLOB_RECURSE SDK_DLLS - "SDK/bin/*.dll" -) - -foreach(dll ${SDK_DLLS}) - add_custom_command(TARGET ${TARGET_NAME} - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${dll} "$") -endforeach() - -add_subdirectory(MiniEngine) - -# project folder -set_target_properties(zlibstatic PROPERTIES FOLDER "Dependencies") -set_target_properties(DirectXMesh PROPERTIES FOLDER "Dependencies") -set_target_properties(DirectXTex PROPERTIES FOLDER "Dependencies") - -if (NOT XESS_BUILD_INTERNAL_SAMPLE) - set(SRC_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../bin/") - add_custom_target(CopyRequiredDLLs ALL - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_PATH}/dxcompiler.dll" "$/dxcompiler.dll" - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_PATH}/dxil.dll" "$/dxil.dll" - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_PATH}/igxess.dll" "$/igxess.dll" - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_PATH}/libxess.dll" "$/libxess.dll" - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_PATH}/XeFX.dll" "$/XeFX.dll" - COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_PATH}/XeFX_loader.dll" "$/XeFX_loader.dll" - ) -else () - add_dependencies(${TARGET_NAME} libxess) - - install(TARGETS ${TARGET_NAME} - RUNTIME DESTINATION bin - ARCHIVE DESTINATION lib - PUBLIC_HEADER DESTINATION inc - RESOURCE DESTINATION bin -) - -install(FILES ${PROJECT_SOURCE_DIR}/MiniEngine/Dependencies/imgui/misc/fonts/DroidSans.ttf DESTINATION bin/) -endif() \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/.gitignore b/xess/samples/xess_demo/MiniEngine/.gitignore deleted file mode 100644 index b1d91da..0000000 --- a/xess/samples/xess_demo/MiniEngine/.gitignore +++ /dev/null @@ -1,22 +0,0 @@ -*.user -*.suo -*.VC.db* -*.shader_inc -*.vspscc -*.opensdf -*.sdf -*.ipch -*.cache -*.tlog -*.lastbuildstate -*.ilk -*.log -* - Copy*.* -Build_VS11 -Build_VS12 -Build_VS14 -Build_VS15 -Build -Packages -/ModelConverter/assimp.dll -Packages \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/CMakeLists.txt b/xess/samples/xess_demo/MiniEngine/CMakeLists.txt deleted file mode 100644 index 25e2454..0000000 --- a/xess/samples/xess_demo/MiniEngine/CMakeLists.txt +++ /dev/null @@ -1,128 +0,0 @@ -############################################################################### -# Copyright 2021 Intel Corporation -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files(the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions : -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -############################################################################## - -set (TARGET_NAME MiniEngine) - -option(ENABLE_MINIENGINE_SHADER_DEBUG "Enable MiniEngine shaders debugging and disable optimizations" OFF) - -file(GLOB_RECURSE SOURCE_FILES - "Core/*.cpp" - "Core/*.h" - "Model/*.cpp" - "Model/*.h" -) - -list(FILTER SOURCE_FILES EXCLUDE REGEX ".*GameInput.cpp$") - -file(GLOB_RECURSE VERTEX_SHADER_FILES - "Core/Shaders/*VS.hlsl" - "Model/Shaders/*VS.hlsl" -) - -file(GLOB_RECURSE PIXEL_SHADER_FILES - "Core/Shaders/*PS.hlsl" - "Model/Shaders/*PS.hlsl" -) - -file(GLOB_RECURSE COMPUTE_SHADER_FILES - "Core/Shaders/*CS.hlsl" - "Model/Shaders/*CS.hlsl" -) - -file(GLOB_RECURSE SHADER_INCLUDE_FILES - "Core/Shaders/*.hlsli" - "Model/Shaders/*.hlsli" -) - -set(THIRD_PARTY_SOURCE_FILES - "Dependencies/imgui/imgui.h" - "Dependencies/imgui/imgui.cpp" - "Dependencies/imgui/imgui_draw.cpp" - "Dependencies/imgui/imgui_internal.h" - "Dependencies/imgui/imgui_tables.cpp" - "Dependencies/imgui/imgui_widgets.cpp" - "Dependencies/imgui/backends/imgui_impl_win32.h" - "Dependencies/imgui/backends/imgui_impl_win32.cpp" -) - -set(SHADER_INC_PATH - ${CMAKE_CURRENT_SOURCE_DIR} -) - -include(../Script/utility.cmake) - -hlsl_compile("${VERTEX_SHADER_FILES}" Vertex "${SHADER_INC_PATH}" "_GAMING_DESKTOP=1" ENABLE_MINIENGINE_SHADER_DEBUG) -hlsl_compile("${PIXEL_SHADER_FILES}" Pixel "${SHADER_INC_PATH}" "_GAMING_DESKTOP=1" ENABLE_MINIENGINE_SHADER_DEBUG) -hlsl_compile("${COMPUTE_SHADER_FILES}" Compute "${SHADER_INC_PATH}" "_GAMING_DESKTOP=1" ENABLE_MINIENGINE_SHADER_DEBUG) -set_property(SOURCE ${SHADER_INCLUDE_FILES} PROPERTY HEADER_FILE_ONLY true) - -set_msvc_precompiled_header(pch.h Core/pch.cpp "${SOURCE_FILES}") - -set(SOURCE_FILES - ${SOURCE_FILES} - ${VERTEX_SHADER_FILES} - ${PIXEL_SHADER_FILES} - ${COMPUTE_SHADER_FILES} - ${SHADER_INCLUDE_FILES} - ${THIRD_PARTY_SOURCE_FILES} -) - -source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCE_FILES}) - -add_library (${TARGET_NAME} STATIC ${SOURCE_FILES}) - -target_compile_definitions(${TARGET_NAME} PRIVATE - UNICODE _UNICODE __WRL_NO_DEFAULT_LIB__ _GAMING_DESKTOP - $<$:_DEBUG> - $<$:RELEASE> - $<$:RELEASE> - $<$:PROFILE> # We treat RelWithDebInfo as "Profile" config -) - -#set_target_properties(${TARGET_NAME} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:MSVCRT") - -target_include_directories( - ${TARGET_NAME} PRIVATE ${PROJECT_BINARY_DIR}/MiniEngine/$ - ${TARGET_NAME} PRIVATE ${CMAKE_BINARY_DIR}/bin/$ - ${TARGET_NAME} PRIVATE ${PROJECT_BINARY_DIR}/MiniEngine/Dependencies/zlib - - ${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Core - ${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/DirectXMesh/DirectXMesh - ${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/DirectXTex/DirectXTex - ${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/zlib - ${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/WinPixEventRuntime/Include/WinPixEventRuntime - ${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/imgui -) - -# DirectXMesh dependency -option(BUILD_TOOLS "" OFF) -add_subdirectory(Dependencies/DirectXMesh) - -# DirectTex dependency -option(BUILD_SAMPLE "" OFF) -option(BUILD_TOOLS "" OFF) -option(BUILD_DX11 "" OFF) -add_subdirectory(Dependencies/DirectXTex) - -# zlib dependency -add_subdirectory(Dependencies/zlib) -target_compile_options(zlibstatic PRIVATE /wd4244) diff --git a/xess/samples/xess_demo/MiniEngine/Core/BitonicSort.cpp b/xess/samples/xess_demo/MiniEngine/Core/BitonicSort.cpp deleted file mode 100644 index 38878c4..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/BitonicSort.cpp +++ /dev/null @@ -1,245 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// - -#include "pch.h" -#include "BitonicSort.h" -#include "RootSignature.h" -#include "PipelineState.h" -#include "CommandContext.h" -#include "ReadbackBuffer.h" -#include "Math/Common.h" -#include "Math/Random.h" - -#include "CompiledShaders/BitonicIndirectArgsCS.h" -#include "CompiledShaders/Bitonic32PreSortCS.h" -#include "CompiledShaders/Bitonic32InnerSortCS.h" -#include "CompiledShaders/Bitonic32OuterSortCS.h" -#include "CompiledShaders/Bitonic64PreSortCS.h" -#include "CompiledShaders/Bitonic64InnerSortCS.h" -#include "CompiledShaders/Bitonic64OuterSortCS.h" - -namespace BitonicSort -{ - IndirectArgsBuffer s_DispatchArgs; - - RootSignature s_RootSignature; - ComputePSO s_BitonicIndirectArgsCS(L"Bitonic Sort: Indirect Args CS"); - ComputePSO s_Bitonic32PreSortCS(L"Bitonic Sort: 32 Pre Sort CS"); - ComputePSO s_Bitonic32InnerSortCS(L"Bitonic Sort: 32 Inner Sort CS"); - ComputePSO s_Bitonic32OuterSortCS(L"Bitonic Sort: 32 Outer Sort CS"); - ComputePSO s_Bitonic64PreSortCS(L"Bitonic Sort: 64 Pre Sort CS"); - ComputePSO s_Bitonic64InnerSortCS(L"Bitonic Sort: 64 Inner Sort CS"); - ComputePSO s_Bitonic64OuterSortCS(L"Bitonic Sort: 64 Outer Sort CS"); - - // Called once by Core to initialize shaders - void Initialize(void); - void Shutdown(void); -} - -void BitonicSort::Initialize( void ) -{ - s_DispatchArgs.Create(L"Bitonic sort dispatch args", 22*23/2, 12); - - s_RootSignature.Reset(4, 0); - s_RootSignature[0].InitAsConstants(0, 2); - s_RootSignature[1].InitAsDescriptorRange(D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 1); - s_RootSignature[2].InitAsDescriptorRange(D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 0, 1); - s_RootSignature[3].InitAsConstants(1, 2); - s_RootSignature.Finalize(L"Bitonic Sort"); - -#define CreatePSO( ObjName, ShaderByteCode ) \ - ObjName.SetRootSignature(s_RootSignature); \ - ObjName.SetComputeShader(ShaderByteCode, sizeof(ShaderByteCode) ); \ - ObjName.Finalize(); - - CreatePSO(s_BitonicIndirectArgsCS, g_pBitonicIndirectArgsCS); - CreatePSO(s_Bitonic32PreSortCS, g_pBitonic32PreSortCS); - CreatePSO(s_Bitonic32InnerSortCS, g_pBitonic32InnerSortCS); - CreatePSO(s_Bitonic32OuterSortCS, g_pBitonic32OuterSortCS); - CreatePSO(s_Bitonic64PreSortCS, g_pBitonic64PreSortCS); - CreatePSO(s_Bitonic64InnerSortCS, g_pBitonic64InnerSortCS); - CreatePSO(s_Bitonic64OuterSortCS, g_pBitonic64OuterSortCS); - -#undef CreatePSO -} - -void BitonicSort::Shutdown( void ) -{ - s_DispatchArgs.Destroy(); -} - -void BitonicSort::Sort( - ComputeContext& Context, - GpuBuffer& KeyIndexList, - GpuBuffer& CounterBuffer, - uint32_t CounterOffset, - bool IsPartiallyPreSorted, - bool SortAscending -) -{ - const uint32_t ElementSizeBytes = KeyIndexList.GetElementSize(); - const uint32_t MaxNumElements = KeyIndexList.GetElementCount(); - const uint32_t AlignedMaxNumElements = Math::AlignPowerOfTwo(MaxNumElements); - const uint32_t MaxIterations = Math::Log2(std::max(2048u, AlignedMaxNumElements)) - 10; - - ASSERT(ElementSizeBytes == 4 || ElementSizeBytes == 8, "Invalid key-index list for bitonic sort"); - - Context.SetRootSignature(s_RootSignature); - - // This controls two things. It is a key that will sort to the end, and it is a mask used to - // determine whether the current group should sort ascending or descending. - Context.SetConstants(3, CounterOffset, SortAscending ? 0xffffffff : 0); - - // Generate execute indirect arguments - Context.SetPipelineState(s_BitonicIndirectArgsCS); - Context.TransitionResource(CounterBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(s_DispatchArgs, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.SetConstants(0, MaxIterations); - Context.SetDynamicDescriptor(1, 0, CounterBuffer.GetSRV()); - Context.SetDynamicDescriptor(2, 0, s_DispatchArgs.GetUAV()); - Context.Dispatch(1, 1, 1); - - // Pre-Sort the buffer up to k = 2048. This also pads the list with invalid indices - // that will drift to the end of the sorted list. - Context.TransitionResource(s_DispatchArgs, D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT); - Context.TransitionResource(KeyIndexList, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.InsertUAVBarrier(KeyIndexList); - Context.SetDynamicDescriptor(2, 0, KeyIndexList.GetUAV()); - - if (!IsPartiallyPreSorted) - { - Context.SetPipelineState(ElementSizeBytes == 4 ? s_Bitonic32PreSortCS : s_Bitonic64PreSortCS); - Context.DispatchIndirect(s_DispatchArgs, 0); - Context.InsertUAVBarrier(KeyIndexList); - } - - uint32_t IndirectArgsOffset = 12; - - // We have already pre-sorted up through k = 2048 when first writing our list, so - // we continue sorting with k = 4096. For unnecessarily large values of k, these - // indirect dispatches will be skipped over with thread counts of 0. - - for (uint32_t k = 4096; k <= AlignedMaxNumElements; k *= 2) - { - Context.SetPipelineState(ElementSizeBytes == 4 ? s_Bitonic32OuterSortCS : s_Bitonic64OuterSortCS); - - for (uint32_t j = k / 2; j >= 2048; j /= 2) - { - Context.SetConstants(0, k, j); - Context.DispatchIndirect(s_DispatchArgs, IndirectArgsOffset); - Context.InsertUAVBarrier(KeyIndexList); - IndirectArgsOffset += 12; - } - - Context.SetPipelineState(ElementSizeBytes == 4 ? s_Bitonic32InnerSortCS : s_Bitonic64InnerSortCS); - Context.DispatchIndirect(s_DispatchArgs, IndirectArgsOffset); - Context.InsertUAVBarrier(KeyIndexList); - IndirectArgsOffset += 12; - } -} - -template -inline void VerifySort(T* List, uint32_t ListLength, bool bAscending) -{ - const T IndexMask = Math::AlignPowerOfTwo(ListLength) - 1; - - for (uint32_t i = 0; i < ListLength - 1; ++i) - { - ASSERT((List[i] & IndexMask) < ListLength, "Corrupted list index detected"); - - if (bAscending) - { - ASSERT(List[i] <= List[i + 1], "Invalid sort order: non-ascending"); - } - else - { - ASSERT(List[i] >= List[i + 1], "Invalid sort order: non-descending"); - } - } - - ASSERT((List[ListLength - 1] & IndexMask) < ListLength, "Corrupted list index detected"); -} - -void TestBitonicSort(uint32_t ListSize, bool b64Bit, bool bAscending) -{ - const uint32_t SizeOfElem = b64Bit ? sizeof(uint64_t) : sizeof(uint32_t); - const uint32_t IndexMask = Math::AlignPowerOfTwo(ListSize) - 1; - - // Allocate memory for list on CPU - void* BufferPtr = std::malloc(ListSize * SizeOfElem); - - // Initialize list with random keys and valid indices - if (b64Bit) - { - uint64_t* BufferPtr64 = (uint64_t*)BufferPtr; - for (uint32_t i = 0; i < ListSize; ++i) - BufferPtr64[i] = ((uint64_t)(uint32_t)Math::g_RNG.NextInt() << 32 | i); - } - else - { - uint32_t* BufferPtr32 = (uint32_t*)BufferPtr; - for (uint32_t i = 0; i < ListSize; ++i) - BufferPtr32[i] = (((uint32_t)Math::g_RNG.NextInt() & ~IndexMask) | i); - } - - // Upload list to GPU - ByteAddressBuffer RandomListGpu; - RandomListGpu.Create(L"GPU Sort List", ListSize, SizeOfElem, BufferPtr); - std::free(BufferPtr); - - // Put the list size in GPU memory - __declspec(align(16)) uint32_t ListCounter[1] = { ListSize }; - ByteAddressBuffer RandomListCount; - RandomListCount.Create(L"GPU List Counter", 1, sizeof(uint32_t), ListCounter); - - // Allocate readback buffers to view data with the CPU - ReadbackBuffer IndirectArgs; - IndirectArgs.Create(L"Readback Indirect Args", 22 * 23 / 2, 12); - - ReadbackBuffer ReadbackList; - ReadbackList.Create(L"Random List For Sort", ListSize, SizeOfElem); - - // Begin GPU work of sorting. Then copy results back to CPU. - ComputeContext& Ctx = ComputeContext::Begin(L"Bitonic Sort Test"); - BitonicSort::Sort(Ctx, RandomListGpu, RandomListCount, 0, false, bAscending); - Ctx.CopyBuffer(IndirectArgs, BitonicSort::s_DispatchArgs); - Ctx.CopyBuffer(ReadbackList, RandomListGpu); - Ctx.Finish(true); - - // For debug purposes, you may uncomment these lines to verify that the args were created correctly. - //typedef uint32_t Args[3]; - //Args* iArgs = (Args*)IndirectArgs.Map(); - BufferPtr = ReadbackList.Map(); - - // Scan through all items to ensure they are sorted in the proper order and that - // their sort index is in the right range (uncorrupted). - if (b64Bit) - VerifySort((uint64_t*)BufferPtr, ListSize, bAscending); - else - VerifySort((uint32_t*)BufferPtr, ListSize, bAscending); - - ReadbackList.Unmap(); - //IndirectArgs.Unmap(); -} - -void BitonicSort::Test( void ) -{ - for (uint32_t ThreadGroupCount = 1; ThreadGroupCount < 256; ++ThreadGroupCount) - { - uint32_t ListSize = 500 * ThreadGroupCount; - TestBitonicSort(ListSize, true, true); - TestBitonicSort(ListSize, true, false); - TestBitonicSort(ListSize, false, true); - TestBitonicSort(ListSize, false, false); - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/BitonicSort.h b/xess/samples/xess_demo/MiniEngine/Core/BitonicSort.h deleted file mode 100644 index b1f0f35..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/BitonicSort.h +++ /dev/null @@ -1,103 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// -// Bitonic Sort is a highly parallel sorting algorithm well-suited to the -// GPU. It has a complexity of O( N*(log N)^2 ), which is inferior to most -// traditional sorting algorithms, but because GPUs have so many threads, -// and because each thread can be utilized, the algorithm can fully load -// the GPU, taking advantage of its high ALU and bandwidth capabilities. -// -// Another reason why sorting on the GPU is useful is when the GPU is creating -// work on its own timeline and needs to sort the work without CPU intervention. -// One example in MiniEngine is with GPU simulated particle systems. Before -// rendering the particles, it is beneficial to sort the particles and render -// them either front-to-back or back-to-front. -// -// The way a bitonic sort works is by iteratively sorting groups of increasing -// size and then blending the sorted groups together to form larger sorted -// groups. The core of the algorithm can be expressed like so: -// -// for (k = 2; k < NumItems; k *= 2) // k = group size -// for (j = k / 2; j > 0; j /= 2) // j = compare distance -// for (i = 0; i < NumItems; ++i) // i = element index -// if (ShouldSwap(i, i ^ j)) // Are the two in proper order? -// Swap(i, i ^ j) // If not, swap them -// -// In this modified form of bitonic sort, all groups of size k are sorted in -// the same direction. This facilitates sorting lists with non-power-of-two -// lengths. So the ShouldSwap() test is informed only by the intent to have -// an ascending or descending list. If sorting ascending, null items should -// have a sort key of 0xffffffff to guarantee sorting to the end. Likewise, -// sorting descending has a null item of 0x00000000. -// -// The value of the null item is also useful in the key comparison. Notice -// that with ascending lists, we want A < B, and with descending lists, we -// want A > B. So if they are reversed, we must swap them. By using the -// null item value, we can automatically reverse the test like so: -// -// Descending: Swap if (A < B) == (A ^ 0x00000000 < B ^ 0x00000000) -// Ascending: Swap if (A > B) == (~A < ~B) == (A ^ 0xffffffff < B ^ 0xffffffff) -// Generalized: Swap if (A ^ NullItem) < (B ^ NullItem) -// -// As an optimization, you can pre-sort the list for k values up to 2048 in -// LDS before writing to memory. (You do not have to write null items at the -// end of your list to memory.) It is always better for the caller of this -// system to pre-sort their list as they create it. -// -// The expected usage of this API is that you will have an array of data of -// unspecified stride. You will generate a list of sort keys and array index -// pairs to pass to the system to be sorted. The sorted key/index pairs can -// then be used to reorder your data array (with a double buffer) or you can -// read your data array in place using indirection. -// -// We also expect that consumers of this system have a GPU-visible count of -// items. This probably came from an AppendBuffer (structured buffer with an -// atomic counter). So you will need to provide the counter buffer as well as -// the offset to the counter. -// -// Also note that key/index pairs may be packed into 32-bit words with the key -// in the most significant bits. Sorting 32-bit elements is faster than sorting -// 64-bit elements because it uses less bandwidth. - -#pragma once - -#include "GpuBuffer.h" - -namespace BitonicSort -{ - void Sort( - // An existing compute context - ComputeContext& Context, - - // List to be sorted. If element size is 4 bytes, it is assumed the key and index are packed - // together with the key in the most significant bytes. If element size is 8 bytes, the key - // is assumed in the upper 4 bytes (i.e. uint2.y). - GpuBuffer& KeyIndexList, - - // A buffer containing the count of items to be sorted. - GpuBuffer& CountBuffer, - - // Offset into counter buffer to find count for this list. Must be a multiple of 4 bytes. - uint32_t CounterOffset, - - // Pass 'true' if the list has already been sorted for k values up to 2048. That is, each - // group of 2048 is already sorted. This is common because you can combine generating a - // sort key list with sorting thread groups in groupshared (LDS) memory. - bool IsPartiallyPreSorted, - - // True to sort in ascending order (smallest to largest). False to sort in descending order. - bool SortAscending - ); - - void Test( void ); - -} // namespace BitonicSort diff --git a/xess/samples/xess_demo/MiniEngine/Core/BuddyAllocator.cpp b/xess/samples/xess_demo/MiniEngine/Core/BuddyAllocator.cpp deleted file mode 100644 index e990b9b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/BuddyAllocator.cpp +++ /dev/null @@ -1,264 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): Jack Elliott -// - -#include "pch.h" -#include "BuddyAllocator.h" -#include "GraphicsCore.h" -#include "CommandListManager.h" -#include "CommandContext.h" - -using namespace Graphics; -using namespace std; - -BuddyBlock::BuddyBlock(uint32_t heapOffset, uint32_t totalSize, uint32_t unpaddedSize) : - m_pBuffer(nullptr) - , m_pBackingHeap(nullptr) - , m_offset(heapOffset) - , m_fenceValue(0) - , m_size(totalSize) - , m_unpaddedSize(unpaddedSize) -{}; - -void BuddyBlock::InitPlaced(ID3D12Heap* pBackingHeap, uint32_t numElements, uint32_t elementSize, const void* initialData) -{ - m_pBuffer = new ByteAddressBuffer(); - m_pBackingHeap = pBackingHeap; - - const wstring name(L"Buddy Block"); - m_pBuffer->CreatePlaced(name, m_pBackingHeap, uint32_t(m_offset), numElements, elementSize, initialData); -} - -void BuddyBlock::InitFromResource(ByteAddressBuffer* pBuffer, uint32_t numElements, uint32_t elementSize, const void* initialData) -{ - m_pBuffer = pBuffer; - - if (initialData) - { - CommandContext::InitializeBuffer(*pBuffer, initialData, numElements * elementSize, m_offset); - } -} - -void BuddyBlock::Destroy() -{ - m_pBuffer->Destroy(); - m_pBuffer = nullptr; -} - -BuddyAllocator::BuddyAllocator(kBuddyAllocationStrategy allocationStrategy, D3D12_HEAP_TYPE heapType, size_t maxBlockSize, size_t MinBlockSize, size_t baseOffset) - : m_allocationStrategy(allocationStrategy) - , m_heapType(heapType) - , m_baseOffset(baseOffset) - , m_maxBlockSize(maxBlockSize) - , m_minBlockSize(MinBlockSize) - , m_pBackingHeap(nullptr) -#if defined(PROFILE) || defined(_DEBUG) - , m_SpaceUsed(0) - , m_InternalFragmentation(0) -#endif -{ - ASSERT(Math::IsDivisible(maxBlockSize, m_minBlockSize)); - ASSERT(Math::IsPowerOfTwo(maxBlockSize / m_minBlockSize)); - - m_maxOrder = UnitSizeToOrder(SizeToUnitSize(maxBlockSize)); - - Reset(); -} - -void BuddyAllocator::Initialize() -{ - if (m_allocationStrategy == kBuddyAllocationStrategy::kPlacedResourceStrategy) - { - D3D12_HEAP_PROPERTIES heapProps = CD3DX12_HEAP_PROPERTIES(m_heapType); - - D3D12_HEAP_DESC desc = {}; - desc.SizeInBytes = m_maxBlockSize; - desc.Properties = heapProps; - desc.Alignment = MIN_PLACED_BUFFER_SIZE; - desc.Flags = D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS; - - ASSERT_SUCCEEDED(g_Device->CreateHeap(&desc, MY_IID_PPV_ARGS(&m_pBackingHeap))); - } - else - { - m_BackingResource.Create(L"Buddy Allocator Backing Resource", uint32_t(m_maxBlockSize), 1, nullptr); - } -} - -void BuddyAllocator::Destroy() -{ - if (m_allocationStrategy == kBuddyAllocationStrategy::kPlacedResourceStrategy) - { - m_pBackingHeap->Release(); - } - else - { - m_BackingResource.Destroy(); - } -} - -size_t BuddyAllocator::AllocateBlock(UINT order) -{ - size_t offset; - - if (order > m_maxOrder) - { - throw(std::bad_alloc()); // Can't allocate a block that large - } - - auto it = m_freeBlocks[order].begin(); - - if (it == m_freeBlocks[order].end()) - { - // No free nodes in the requested pool. Try to find a higher-order block and split it. - size_t left = AllocateBlock(order + 1); - - size_t size = OrderToUnitSize(order); - - size_t right = left + size; - - m_freeBlocks[order].insert(right); // Add the right block to the free pool - - offset = left; // Return the left block - } - - else - { - offset = *it; - - // Remove the block from the free list - m_freeBlocks[order].erase(it); - } - - return offset; -} - -void BuddyAllocator::DeallocateBlock(size_t offset, UINT order) -{ - // See if the buddy block is free - size_t size = OrderToUnitSize(order); - - size_t buddy = GetBuddyOffset(offset, size); - - auto it = m_freeBlocks[order].find(buddy); - - if (it != m_freeBlocks[order].end()) - { - // Deallocate merged blocks - DeallocateBlock(min(offset, buddy), order + 1); - // Remove the buddy from the free list - m_freeBlocks[order].erase(it); - } - else - { - // Add the block to the free list - m_freeBlocks[order].insert(offset); // throw(std::bad_alloc) - } -} - -BuddyBlock* BuddyAllocator::Allocate(uint32_t numElements, uint32_t elementSize, const void* initialData) -{ - size_t size = numElements * elementSize; - size_t unitSize = SizeToUnitSize(size); - UINT order = UnitSizeToOrder(unitSize); - - try - { - size_t offset = AllocateBlock(order); - uint32_t paddedSize = uint32_t(OrderToUnitSize(order) * m_minBlockSize); - - uint32_t blockOffset = uint32_t(m_baseOffset + (offset * m_minBlockSize)); - - INCREASE_BUDDY_COUNTER(m_SpaceUsed, paddedSize); - INCREASE_BUDDY_COUNTER(m_InternalFragmentation, (paddedSize - size)); - - BuddyBlock* pBlock = new BuddyBlock(blockOffset, //offset - paddedSize, //total size (padded to fit a block) - numElements * elementSize); - - if (m_allocationStrategy == kBuddyAllocationStrategy::kPlacedResourceStrategy) - { - pBlock->InitPlaced(m_pBackingHeap, numElements, elementSize, initialData); - } - else - { - //TODO: To be truely thread-safe this operation should be atomic to guard against - // the case in which blocks from this allocator are used on multiple threads - // (because it's really only 1 resource underneath) - pBlock->InitFromResource(&m_BackingResource, numElements, elementSize, initialData); - } - - return pBlock; - } - - catch (std::bad_alloc&) - { - // There are no blocks available for the requested size so - // return the NULL block type - return new BuddyBlock(); - } -} - -/* -void BuddyAllocator::Deallocate(BuddyBlock* pBlock) -{ - pBlock->m_fenceValue = g_CommandManager.GetNextFenceValue(); - m_deferredDeletionQueue.push(pBlock); -} -*/ - -void BuddyAllocator::DeallocateInternal(BuddyBlock* pBlock) -{ - ASSERT(IsOwner(*pBlock)); - - size_t offset = SizeToUnitSize(pBlock->GetOffset() - m_baseOffset); - - size_t size = SizeToUnitSize(pBlock->GetSize()); - - UINT order = UnitSizeToOrder(size); - - try - { - DeallocateBlock(offset, order); // throw(std::bad_alloc) - - DECREASE_BUDDY_COUNTER(m_SpaceUsed, size); - DECREASE_BUDDY_COUNTER(m_InternalFragmentation, (size - pBlock->m_unpaddedSize)); - - if (m_allocationStrategy == kBuddyAllocationStrategy::kPlacedResourceStrategy) - { - // Release the resource - pBlock->Destroy(); - } - delete(pBlock); - } - - catch (std::bad_alloc&) - { - // Deallocate failed trying to add the free block to the pool - // resulting in a leak. Unfortunately there is not much we can do. - // Fortunately this is expected to be extremely rare as the storage - // needed for each deallocate is very small. - } -}; - -/* -void BuddyAllocator::CleanUpAllocations() -{ - while (m_deferredDeletionQueue.empty() == false && - g_CommandManager.IsFenceComplete(m_deferredDeletionQueue.front()->m_fenceValue)) - { - BuddyBlock* pBlock = m_deferredDeletionQueue.front(); - m_deferredDeletionQueue.pop(); - - DeallocateInternal(pBlock); - } -}*/ diff --git a/xess/samples/xess_demo/MiniEngine/Core/BuddyAllocator.h b/xess/samples/xess_demo/MiniEngine/Core/BuddyAllocator.h deleted file mode 100644 index 926710e..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/BuddyAllocator.h +++ /dev/null @@ -1,149 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: Jack Elliott. -// -// Allocates blocks from a fixed range using buddy allocation method. -// Buddy allocation allows reasonably fast allocation of arbitrary size blocks -// with minimal fragmentation and provides efficient reuse of freed ranges. -// When a block is de-allocated an attempt is made to merge it with it's -// neighbour (buddy) if it is contiguous and free. -// Based on reference implementation by Bill Kristiansen -// - -#pragma once - -#include "GpuBuffer.h" -#include -#include -#include -#include - -// Unfortunately the api restricts the minimum size of a placed buffer resource to 64k -#define MIN_PLACED_BUFFER_SIZE (64 * 1024) - -#if defined(PROFILE) || defined(_DEBUG) -#define INCREASE_BUDDY_COUNTER(A, B) (A = A + B); -#define DECREASE_BUDDY_COUNTER(A, B) (A = A - B); -#else -#define INCREASE_BUDDY_COUNTER(A, B) -#define DECREASE_BUDDY_COUNTER(A, B) -#endif - -enum kBuddyAllocationStrategy -{ - // This strategy uses Placed Resources to sub-allocate a buffer out of an underlying ID3D12Heap. - // The benefit of this is that each buffer can have it's own resource state and can be treated - // as any other buffer. The downside of this strategy is the API limitiation which enforces - // the minimum buffer size to 64k leading to large internal fragmentation in the allocator - kPlacedResourceStrategy, - // The alternative is to manualy sub-allocate out of a single large buffer which allows block - // allocation granularity down to 1 byte. However, this strategy is only really valid for buffers which - // will be treated as read-only after their creation (i.e. most Index and Vertex buffers). This - // is because the underlying resource can only have one state at a time. - kManualSubAllocationStrategy -}; - -struct BuddyBlock -{ - ByteAddressBuffer* m_pBuffer; - ID3D12Heap* m_pBackingHeap; - - size_t m_offset; - size_t m_size; - size_t m_unpaddedSize; - uint64_t m_fenceValue; - - inline size_t GetOffset() const { return m_offset; } - inline size_t GetSize() const { return m_size; } - - BuddyBlock() : m_pBuffer(nullptr), m_pBackingHeap(nullptr), m_offset(0), m_size(0), m_unpaddedSize(0), m_fenceValue(0) {}; - - BuddyBlock(uint32_t heapOffset, uint32_t totalSize, uint32_t unpaddedSize); - - void InitPlaced(ID3D12Heap* pBackingHeap, uint32_t numElements, uint32_t elementSize, const void* initialData = nullptr); - - void InitFromResource(ByteAddressBuffer* pBuffer, uint32_t numElements, uint32_t elementSize, const void* initialData = nullptr); - - void Destroy(); -}; - -class BuddyAllocator -{ -public: - - BuddyAllocator(kBuddyAllocationStrategy allocationStrategy, D3D12_HEAP_TYPE heapType, size_t maxBlockSize, size_t minBlockSize = MIN_PLACED_BUFFER_SIZE, size_t baseOffset = 0); - - void Initialize(); - - void Destroy(); - - BuddyBlock* Allocate(uint32_t numElements, uint32_t elementSize, const void* initialData = nullptr); - - void Deallocate(BuddyBlock* pBlock); - - inline bool IsOwner(const BuddyBlock &block) - { - return block.GetOffset() >= m_baseOffset && block.GetSize() <= m_maxBlockSize; - } - - inline void Reset() - { - // Clear the free blocks collection - m_freeBlocks.clear(); - - // Initialize the pool with a free inner block of max inner block size - m_freeBlocks.resize(m_maxOrder + 1); - m_freeBlocks[m_maxOrder].insert((size_t)0); - } - - void CleanUpAllocations(); - -private: - ID3D12Heap* m_pBackingHeap; - ByteAddressBuffer m_BackingResource; - - const D3D12_HEAP_TYPE m_heapType; - - std::queue m_deferredDeletionQueue; - std::vector> m_freeBlocks; - UINT m_maxOrder; - const size_t m_baseOffset; - const size_t m_maxBlockSize; - const size_t m_minBlockSize; - - const kBuddyAllocationStrategy m_allocationStrategy; - - inline size_t SizeToUnitSize(size_t size) const - { - return (size + (m_minBlockSize - 1)) / m_minBlockSize; - } - - inline UINT UnitSizeToOrder(size_t size) const - { - return Math::Log2(size); // Log2 rounds up fractions to next whole value - } - - inline size_t GetBuddyOffset(const size_t &offset, const size_t &size) - { - return offset ^ size; - } - - void DeallocateInternal(BuddyBlock* pBlock); - - size_t OrderToUnitSize(UINT order) const { return ((size_t)1) << order; } - size_t AllocateBlock(UINT order); - void DeallocateBlock(size_t offset, UINT order); - -#if defined(PROFILE) || defined(_DEBUG) - size_t m_SpaceUsed; - size_t m_InternalFragmentation; -#endif -}; diff --git a/xess/samples/xess_demo/MiniEngine/Core/BufferManager.cpp b/xess/samples/xess_demo/MiniEngine/Core/BufferManager.cpp deleted file mode 100644 index f1432c6..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/BufferManager.cpp +++ /dev/null @@ -1,380 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -// Modified 2022, Intel Corporation. -// Added support for super sampling. - -#include "pch.h" -#include "BufferManager.h" -#include "Display.h" -#include "CommandContext.h" -#include "EsramAllocator.h" -#include "TemporalEffects.h" -#include "IExtraRenderingBuffers.h" - -namespace Graphics -{ - DepthBuffer g_SceneDepthBuffer; - ColorBuffer g_SceneColorBuffer; - ColorBuffer g_UpscaledSceneColorBuffer; - ColorBuffer g_SceneNormalBuffer; - ColorBuffer g_PostEffectsBuffer; - ColorBuffer g_VelocityBuffer; - ColorBuffer g_UpscaledVelocityBuffer; - ColorBuffer g_OverlayBuffer; - ColorBuffer g_HorizontalBuffer; - ColorBuffer g_ResponsiveMaskBuffer; - - ShadowBuffer g_ShadowBuffer; - - ColorBuffer g_SSAOFullScreen(Color(1.0f, 1.0f, 1.0f)); - ColorBuffer g_LinearDepth[2]; - ColorBuffer g_MinMaxDepth8; - ColorBuffer g_MinMaxDepth16; - ColorBuffer g_MinMaxDepth32; - ColorBuffer g_DepthDownsize1; - ColorBuffer g_DepthDownsize2; - ColorBuffer g_DepthDownsize3; - ColorBuffer g_DepthDownsize4; - ColorBuffer g_DepthTiled1; - ColorBuffer g_DepthTiled2; - ColorBuffer g_DepthTiled3; - ColorBuffer g_DepthTiled4; - ColorBuffer g_AOMerged1; - ColorBuffer g_AOMerged2; - ColorBuffer g_AOMerged3; - ColorBuffer g_AOMerged4; - ColorBuffer g_AOSmooth1; - ColorBuffer g_AOSmooth2; - ColorBuffer g_AOSmooth3; - ColorBuffer g_AOHighQuality1; - ColorBuffer g_AOHighQuality2; - ColorBuffer g_AOHighQuality3; - ColorBuffer g_AOHighQuality4; - - ColorBuffer g_DoFTileClass[2]; - ColorBuffer g_DoFPresortBuffer; - ColorBuffer g_DoFPrefilter; - ColorBuffer g_DoFBlurColor[2]; - ColorBuffer g_DoFBlurAlpha[2]; - StructuredBuffer g_DoFWorkQueue; - StructuredBuffer g_DoFFastQueue; - StructuredBuffer g_DoFFixupQueue; - - ColorBuffer g_MotionPrepBuffer; - ColorBuffer g_LumaBuffer; - ColorBuffer g_TemporalColor[2]; - ColorBuffer g_TemporalMinBound; - ColorBuffer g_TemporalMaxBound; - ColorBuffer g_aBloomUAV1[2]; // 640x384 (1/3) - ColorBuffer g_aBloomUAV2[2]; // 320x192 (1/6) - ColorBuffer g_aBloomUAV3[2]; // 160x96 (1/12) - ColorBuffer g_aBloomUAV4[2]; // 80x48 (1/24) - ColorBuffer g_aBloomUAV5[2]; // 40x24 (1/48) - ColorBuffer g_LumaLR; - ByteAddressBuffer g_Histogram; - ByteAddressBuffer g_FXAAWorkQueue; - TypedBuffer g_FXAAColorQueue(DXGI_FORMAT_R11G11B10_FLOAT); - - // For testing GenerateMipMaps() - ColorBuffer g_GenMipsBuffer; - - DXGI_FORMAT DefaultHdrColorFormat = DXGI_FORMAT_R11G11B10_FLOAT; -} - -#define T2X_COLOR_FORMAT DXGI_FORMAT_R10G10B10A2_UNORM -#define HDR_MOTION_FORMAT DXGI_FORMAT_R16G16B16A16_FLOAT -#define DSV_FORMAT DXGI_FORMAT_D32_FLOAT - -void Graphics::InitializeRenderingBuffers( uint32_t bufferWidth, uint32_t bufferHeight ) -{ - GraphicsContext& InitContext = GraphicsContext::Begin(); - - bool upscalingMode = Graphics::IsUpscalingEnabled(); - - const uint32_t bufferWidth1 = (bufferWidth + 1) / 2; - const uint32_t bufferWidth2 = (bufferWidth + 3) / 4; - const uint32_t bufferWidth3 = (bufferWidth + 7) / 8; - const uint32_t bufferWidth4 = (bufferWidth + 15) / 16; - const uint32_t bufferWidth5 = (bufferWidth + 31) / 32; - const uint32_t bufferWidth6 = (bufferWidth + 63) / 64; - const uint32_t bufferHeight1 = (bufferHeight + 1) / 2; - const uint32_t bufferHeight2 = (bufferHeight + 3) / 4; - const uint32_t bufferHeight3 = (bufferHeight + 7) / 8; - const uint32_t bufferHeight4 = (bufferHeight + 15) / 16; - const uint32_t bufferHeight5 = (bufferHeight + 31) / 32; - const uint32_t bufferHeight6 = (bufferHeight + 63) / 64; - - EsramAllocator esram; - - esram.PushStack(); - - g_SceneColorBuffer.Create( L"Main Color Buffer", bufferWidth, bufferHeight, 1, DefaultHdrColorFormat, esram ); - g_SceneNormalBuffer.Create( L"Normals Buffer", bufferWidth, bufferHeight, 1, DXGI_FORMAT_R16G16B16A16_FLOAT, esram ); - g_VelocityBuffer.Create( L"Motion Vectors", bufferWidth, bufferHeight, 1, DXGI_FORMAT_R32_UINT ); - g_ResponsiveMaskBuffer.Create(L"Responsive Mask", bufferWidth, bufferHeight, 1, DXGI_FORMAT_R8_UNORM); - - if (upscalingMode) - { - g_UpscaledSceneColorBuffer.Create(L"Main Color Buffer - Upscaled", g_DisplayWidth, g_DisplayHeight, 1, DefaultHdrColorFormat); - g_UpscaledVelocityBuffer.Create(L"Motion Vectors - Upscaled", g_DisplayWidth, g_DisplayHeight, 1, DXGI_FORMAT_R16G16_FLOAT); - g_PostEffectsBuffer.Create( L"Post Effects Buffer - Upscaled", g_DisplayWidth, g_DisplayHeight, 1, DXGI_FORMAT_R32_UINT ); - } - else - { - g_PostEffectsBuffer.Create(L"Post Effects Buffer", bufferWidth, bufferHeight, 1, DXGI_FORMAT_R32_UINT); - } - - esram.PushStack(); // Render HDR image - - g_LinearDepth[0].Create( L"Linear Depth 0", bufferWidth, bufferHeight, 1, DXGI_FORMAT_R16_UNORM ); - g_LinearDepth[1].Create( L"Linear Depth 1", bufferWidth, bufferHeight, 1, DXGI_FORMAT_R16_UNORM ); - g_MinMaxDepth8.Create(L"MinMaxDepth 8x8", bufferWidth3, bufferHeight3, 1, DXGI_FORMAT_R32_UINT, esram ); - g_MinMaxDepth16.Create(L"MinMaxDepth 16x16", bufferWidth4, bufferHeight4, 1, DXGI_FORMAT_R32_UINT, esram ); - g_MinMaxDepth32.Create(L"MinMaxDepth 32x32", bufferWidth5, bufferHeight5, 1, DXGI_FORMAT_R32_UINT, esram ); - - g_SceneDepthBuffer.Create( L"Scene Depth Buffer", bufferWidth, bufferHeight, DSV_FORMAT, esram ); - - esram.PushStack(); // Begin opaque geometry - - esram.PushStack(); // Begin Shading - - g_SSAOFullScreen.Create( L"SSAO Full Res", bufferWidth, bufferHeight, 1, DXGI_FORMAT_R8_UNORM ); - - esram.PushStack(); // Begin generating SSAO - g_DepthDownsize1.Create( L"Depth Down-Sized 1", bufferWidth1, bufferHeight1, 1, DXGI_FORMAT_R32_FLOAT, esram ); - g_DepthDownsize2.Create( L"Depth Down-Sized 2", bufferWidth2, bufferHeight2, 1, DXGI_FORMAT_R32_FLOAT, esram ); - g_DepthDownsize3.Create( L"Depth Down-Sized 3", bufferWidth3, bufferHeight3, 1, DXGI_FORMAT_R32_FLOAT, esram ); - g_DepthDownsize4.Create( L"Depth Down-Sized 4", bufferWidth4, bufferHeight4, 1, DXGI_FORMAT_R32_FLOAT, esram ); - g_DepthTiled1.CreateArray( L"Depth De-Interleaved 1", bufferWidth3, bufferHeight3, 16, DXGI_FORMAT_R16_FLOAT, esram ); - g_DepthTiled2.CreateArray( L"Depth De-Interleaved 2", bufferWidth4, bufferHeight4, 16, DXGI_FORMAT_R16_FLOAT, esram ); - g_DepthTiled3.CreateArray( L"Depth De-Interleaved 3", bufferWidth5, bufferHeight5, 16, DXGI_FORMAT_R16_FLOAT, esram ); - g_DepthTiled4.CreateArray( L"Depth De-Interleaved 4", bufferWidth6, bufferHeight6, 16, DXGI_FORMAT_R16_FLOAT, esram ); - g_AOMerged1.Create( L"AO Re-Interleaved 1", bufferWidth1, bufferHeight1, 1, DXGI_FORMAT_R8_UNORM, esram ); - g_AOMerged2.Create( L"AO Re-Interleaved 2", bufferWidth2, bufferHeight2, 1, DXGI_FORMAT_R8_UNORM, esram ); - g_AOMerged3.Create( L"AO Re-Interleaved 3", bufferWidth3, bufferHeight3, 1, DXGI_FORMAT_R8_UNORM, esram ); - g_AOMerged4.Create( L"AO Re-Interleaved 4", bufferWidth4, bufferHeight4, 1, DXGI_FORMAT_R8_UNORM, esram ); - g_AOSmooth1.Create( L"AO Smoothed 1", bufferWidth1, bufferHeight1, 1, DXGI_FORMAT_R8_UNORM, esram ); - g_AOSmooth2.Create( L"AO Smoothed 2", bufferWidth2, bufferHeight2, 1, DXGI_FORMAT_R8_UNORM, esram ); - g_AOSmooth3.Create( L"AO Smoothed 3", bufferWidth3, bufferHeight3, 1, DXGI_FORMAT_R8_UNORM, esram ); - g_AOHighQuality1.Create( L"AO High Quality 1", bufferWidth1, bufferHeight1, 1, DXGI_FORMAT_R8_UNORM, esram ); - g_AOHighQuality2.Create( L"AO High Quality 2", bufferWidth2, bufferHeight2, 1, DXGI_FORMAT_R8_UNORM, esram ); - g_AOHighQuality3.Create( L"AO High Quality 3", bufferWidth3, bufferHeight3, 1, DXGI_FORMAT_R8_UNORM, esram ); - g_AOHighQuality4.Create( L"AO High Quality 4", bufferWidth4, bufferHeight4, 1, DXGI_FORMAT_R8_UNORM, esram ); - esram.PopStack(); // End generating SSAO - - g_ShadowBuffer.Create( L"Shadow Map", 2048, 2048, esram ); - - esram.PopStack(); // End Shading - - esram.PushStack(); // Begin depth of field - g_DoFTileClass[0].Create(L"DoF Tile Classification Buffer 0", bufferWidth4, bufferHeight4, 1, DXGI_FORMAT_R11G11B10_FLOAT); - g_DoFTileClass[1].Create(L"DoF Tile Classification Buffer 1", bufferWidth4, bufferHeight4, 1, DXGI_FORMAT_R11G11B10_FLOAT); - - g_DoFPresortBuffer.Create(L"DoF Presort Buffer", bufferWidth1, bufferHeight1, 1, DXGI_FORMAT_R11G11B10_FLOAT, esram ); - g_DoFPrefilter.Create(L"DoF PreFilter Buffer", bufferWidth1, bufferHeight1, 1, DXGI_FORMAT_R11G11B10_FLOAT, esram ); - g_DoFBlurColor[0].Create(L"DoF Blur Color", bufferWidth1, bufferHeight1, 1, DXGI_FORMAT_R11G11B10_FLOAT, esram ); - g_DoFBlurColor[1].Create(L"DoF Blur Color", bufferWidth1, bufferHeight1, 1, DXGI_FORMAT_R11G11B10_FLOAT, esram ); - g_DoFBlurAlpha[0].Create(L"DoF FG Alpha", bufferWidth1, bufferHeight1, 1, DXGI_FORMAT_R8_UNORM, esram ); - g_DoFBlurAlpha[1].Create(L"DoF FG Alpha", bufferWidth1, bufferHeight1, 1, DXGI_FORMAT_R8_UNORM, esram ); - g_DoFWorkQueue.Create(L"DoF Work Queue", bufferWidth4 * bufferHeight4, 4, esram ); - g_DoFFastQueue.Create(L"DoF Fast Queue", bufferWidth4 * bufferHeight4, 4, esram ); - g_DoFFixupQueue.Create(L"DoF Fixup Queue", bufferWidth4 * bufferHeight4, 4, esram ); - esram.PopStack(); // End depth of field - - g_TemporalColor[0].Create( L"Temporal Color 0", bufferWidth, bufferHeight, 1, DXGI_FORMAT_R16G16B16A16_FLOAT); - g_TemporalColor[1].Create( L"Temporal Color 1", bufferWidth, bufferHeight, 1, DXGI_FORMAT_R16G16B16A16_FLOAT); - TemporalEffects::ClearHistory(InitContext); - - g_TemporalMinBound.Create( L"Temporal Min Color", bufferWidth, bufferHeight, 1, DXGI_FORMAT_R11G11B10_FLOAT); - g_TemporalMaxBound.Create( L"Temporal Max Color", bufferWidth, bufferHeight, 1, DXGI_FORMAT_R11G11B10_FLOAT); - - esram.PushStack(); // Begin motion blur - - if (upscalingMode) - { - g_MotionPrepBuffer.Create(L"Motion Blur Prep - Upscaled", (g_DisplayWidth + 1) / 2, (g_DisplayHeight + 1) / 2, 1, HDR_MOTION_FORMAT, esram); - } - else - { - g_MotionPrepBuffer.Create(L"Motion Blur Prep", bufferWidth1, bufferHeight1, 1, HDR_MOTION_FORMAT, esram); - } - - esram.PopStack(); // End motion blur - - esram.PopStack(); // End opaque geometry - - esram.PopStack(); // End HDR image - - esram.PushStack(); // Begin post processing - - // This is useful for storing per-pixel weights such as motion strength or pixel luminance - if (upscalingMode) - { - g_LumaBuffer.Create( L"Luminance - Upscaled", g_DisplayWidth, g_DisplayHeight, 1, DXGI_FORMAT_R8_UNORM, esram ); - } - else - { - g_LumaBuffer.Create(L"Luminance", bufferWidth, bufferHeight, 1, DXGI_FORMAT_R8_UNORM, esram); - } - - g_Histogram.Create( L"Histogram", 256, 4, esram ); - - // Divisible by 128 so that after dividing by 16, we still have multiples of 8x8 tiles. The bloom - // dimensions must be at least 1/4 native resolution to avoid undersampling. - //uint32_t kBloomWidth = bufferWidth > 2560 ? Math::AlignUp(bufferWidth / 4, 128) : 640; - //uint32_t kBloomHeight = bufferHeight > 1440 ? Math::AlignUp(bufferHeight / 4, 128) : 384; - - uint32_t kBloomWidth; - uint32_t kBloomHeight; - - if (upscalingMode) - { - kBloomWidth = g_DisplayWidth > 2560 ? 1280 : 640; - kBloomHeight = g_DisplayHeight > 1440 ? 768 : 384; - } - else - { - kBloomWidth = bufferWidth > 2560 ? 1280 : 640; - kBloomHeight = bufferHeight > 1440 ? 768 : 384; - } - - esram.PushStack(); // Begin bloom and tone mapping - g_LumaLR.Create( L"Luma Buffer", kBloomWidth, kBloomHeight, 1, DXGI_FORMAT_R8_UINT, esram ); - g_aBloomUAV1[0].Create( L"Bloom Buffer 1a", kBloomWidth, kBloomHeight, 1, DefaultHdrColorFormat, esram ); - g_aBloomUAV1[1].Create( L"Bloom Buffer 1b", kBloomWidth, kBloomHeight, 1, DefaultHdrColorFormat, esram); - g_aBloomUAV2[0].Create( L"Bloom Buffer 2a", kBloomWidth/2, kBloomHeight/2, 1, DefaultHdrColorFormat, esram ); - g_aBloomUAV2[1].Create( L"Bloom Buffer 2b", kBloomWidth/2, kBloomHeight/2, 1, DefaultHdrColorFormat, esram ); - g_aBloomUAV3[0].Create( L"Bloom Buffer 3a", kBloomWidth/4, kBloomHeight/4, 1, DefaultHdrColorFormat, esram ); - g_aBloomUAV3[1].Create( L"Bloom Buffer 3b", kBloomWidth/4, kBloomHeight/4, 1, DefaultHdrColorFormat, esram ); - g_aBloomUAV4[0].Create( L"Bloom Buffer 4a", kBloomWidth/8, kBloomHeight/8, 1, DefaultHdrColorFormat, esram ); - g_aBloomUAV4[1].Create( L"Bloom Buffer 4b", kBloomWidth/8, kBloomHeight/8, 1, DefaultHdrColorFormat, esram ); - g_aBloomUAV5[0].Create( L"Bloom Buffer 5a", kBloomWidth/16, kBloomHeight/16, 1, DefaultHdrColorFormat, esram ); - g_aBloomUAV5[1].Create( L"Bloom Buffer 5b", kBloomWidth/16, kBloomHeight/16, 1, DefaultHdrColorFormat, esram ); - esram.PopStack(); // End tone mapping - - esram.PushStack(); // Begin antialiasing - const uint32_t kFXAAWorkSize = bufferWidth * bufferHeight / 4 + 128; - g_FXAAWorkQueue.Create( L"FXAA Work Queue", kFXAAWorkSize, sizeof(uint32_t), esram ); - g_FXAAColorQueue.Create( L"FXAA Color Queue", kFXAAWorkSize, sizeof(uint32_t), esram ); - esram.PopStack(); // End antialiasing - - esram.PopStack(); // End post processing - - esram.PushStack(); // GenerateMipMaps() test - g_GenMipsBuffer.Create(L"GenMips", bufferWidth, bufferHeight, 0, DXGI_FORMAT_R11G11B10_FLOAT, esram ); - esram.PopStack(); - - g_OverlayBuffer.Create( L"UI Overlay", g_DisplayWidth, g_DisplayHeight, 1, DXGI_FORMAT_R8G8B8A8_UNORM, esram ); - g_HorizontalBuffer.Create( L"Bicubic Intermediate", g_DisplayWidth, bufferHeight, 1, DefaultHdrColorFormat, esram ); - - IExtraRenderingBuffersHandler* extraBufferHandler = GetExtraRenderingBuffersHandler(); - if (extraBufferHandler) - { - extraBufferHandler->InitializeBuffers(bufferWidth, bufferHeight, g_DisplayWidth, g_DisplayHeight); - } - - esram.PopStack(); // End final image - - InitContext.Finish(); -} - -void Graphics::ResizeDisplayDependentBuffers(uint32_t NativeWidth, uint32_t NativeHeight) -{ - (NativeWidth); - g_OverlayBuffer.Create( L"UI Overlay", g_DisplayWidth, g_DisplayHeight, 1, DXGI_FORMAT_R8G8B8A8_UNORM ); - g_HorizontalBuffer.Create( L"Bicubic Intermediate", g_DisplayWidth, NativeHeight, 1, DefaultHdrColorFormat ); -} - -void Graphics::DestroyRenderingBuffers() -{ - IExtraRenderingBuffersHandler* extraBufferHandler = GetExtraRenderingBuffersHandler(); - if (extraBufferHandler) - { - extraBufferHandler->DestroyRenderingBuffers(); - } - - g_UpscaledVelocityBuffer.Destroy(); - g_UpscaledSceneColorBuffer.Destroy(); - g_SceneDepthBuffer.Destroy(); - g_SceneColorBuffer.Destroy(); - g_SceneNormalBuffer.Destroy(); - g_VelocityBuffer.Destroy(); - g_OverlayBuffer.Destroy(); - g_HorizontalBuffer.Destroy(); - g_PostEffectsBuffer.Destroy(); - g_ResponsiveMaskBuffer.Destroy(); - - g_ShadowBuffer.Destroy(); - - g_SSAOFullScreen.Destroy(); - g_LinearDepth[0].Destroy(); - g_LinearDepth[1].Destroy(); - g_MinMaxDepth8.Destroy(); - g_MinMaxDepth16.Destroy(); - g_MinMaxDepth32.Destroy(); - g_DepthDownsize1.Destroy(); - g_DepthDownsize2.Destroy(); - g_DepthDownsize3.Destroy(); - g_DepthDownsize4.Destroy(); - g_DepthTiled1.Destroy(); - g_DepthTiled2.Destroy(); - g_DepthTiled3.Destroy(); - g_DepthTiled4.Destroy(); - g_AOMerged1.Destroy(); - g_AOMerged2.Destroy(); - g_AOMerged3.Destroy(); - g_AOMerged4.Destroy(); - g_AOSmooth1.Destroy(); - g_AOSmooth2.Destroy(); - g_AOSmooth3.Destroy(); - g_AOHighQuality1.Destroy(); - g_AOHighQuality2.Destroy(); - g_AOHighQuality3.Destroy(); - g_AOHighQuality4.Destroy(); - - g_DoFTileClass[0].Destroy(); - g_DoFTileClass[1].Destroy(); - g_DoFPresortBuffer.Destroy(); - g_DoFPrefilter.Destroy(); - g_DoFBlurColor[0].Destroy(); - g_DoFBlurColor[1].Destroy(); - g_DoFBlurAlpha[0].Destroy(); - g_DoFBlurAlpha[1].Destroy(); - g_DoFWorkQueue.Destroy(); - g_DoFFastQueue.Destroy(); - g_DoFFixupQueue.Destroy(); - - g_MotionPrepBuffer.Destroy(); - g_LumaBuffer.Destroy(); - g_TemporalColor[0].Destroy(); - g_TemporalColor[1].Destroy(); - g_TemporalMinBound.Destroy(); - g_TemporalMaxBound.Destroy(); - g_aBloomUAV1[0].Destroy(); - g_aBloomUAV1[1].Destroy(); - g_aBloomUAV2[0].Destroy(); - g_aBloomUAV2[1].Destroy(); - g_aBloomUAV3[0].Destroy(); - g_aBloomUAV3[1].Destroy(); - g_aBloomUAV4[0].Destroy(); - g_aBloomUAV4[1].Destroy(); - g_aBloomUAV5[0].Destroy(); - g_aBloomUAV5[1].Destroy(); - g_LumaLR.Destroy(); - g_Histogram.Destroy(); - g_FXAAWorkQueue.Destroy(); - g_FXAAColorQueue.Destroy(); - - g_GenMipsBuffer.Destroy(); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/BufferManager.h b/xess/samples/xess_demo/MiniEngine/Core/BufferManager.h deleted file mode 100644 index e772d64..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/BufferManager.h +++ /dev/null @@ -1,95 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -// Modified 2022, Intel Corporation. -// Added support for super sampling. - -#pragma once - -#include "ColorBuffer.h" -#include "DepthBuffer.h" -#include "ShadowBuffer.h" -#include "GpuBuffer.h" -#include "GraphicsCore.h" - -namespace Graphics -{ - extern DepthBuffer g_SceneDepthBuffer; // D32_FLOAT_S8_UINT - extern ColorBuffer g_SceneColorBuffer; // R11G11B10_FLOAT - extern ColorBuffer g_UpscaledSceneColorBuffer; // R11G11B10_FLOAT - extern ColorBuffer g_SceneNormalBuffer; // R16G16B16A16_FLOAT - extern ColorBuffer g_PostEffectsBuffer; // R32_UINT (to support Read-Modify-Write with a UAV) - extern ColorBuffer g_OverlayBuffer; // R8G8B8A8_UNORM - extern ColorBuffer g_HorizontalBuffer; // For separable (bicubic) upsampling - - extern ColorBuffer g_ResponsiveMaskBuffer; // DXGI_FORMAT_R8_UNORM - - extern ColorBuffer g_VelocityBuffer; // R10G10B10 (3D velocity) - extern ColorBuffer g_UpscaledVelocityBuffer; // DXGI_FORMAT_R16G16_FLOAT - extern ShadowBuffer g_ShadowBuffer; - - extern ColorBuffer g_SSAOFullScreen; // R8_UNORM - extern ColorBuffer g_LinearDepth[2]; // Normalized planar distance (0 at eye, 1 at far plane) computed from the SceneDepthBuffer - extern ColorBuffer g_MinMaxDepth8; // Min and max depth values of 8x8 tiles - extern ColorBuffer g_MinMaxDepth16; // Min and max depth values of 16x16 tiles - extern ColorBuffer g_MinMaxDepth32; // Min and max depth values of 16x16 tiles - extern ColorBuffer g_DepthDownsize1; - extern ColorBuffer g_DepthDownsize2; - extern ColorBuffer g_DepthDownsize3; - extern ColorBuffer g_DepthDownsize4; - extern ColorBuffer g_DepthTiled1; - extern ColorBuffer g_DepthTiled2; - extern ColorBuffer g_DepthTiled3; - extern ColorBuffer g_DepthTiled4; - extern ColorBuffer g_AOMerged1; - extern ColorBuffer g_AOMerged2; - extern ColorBuffer g_AOMerged3; - extern ColorBuffer g_AOMerged4; - extern ColorBuffer g_AOSmooth1; - extern ColorBuffer g_AOSmooth2; - extern ColorBuffer g_AOSmooth3; - extern ColorBuffer g_AOHighQuality1; - extern ColorBuffer g_AOHighQuality2; - extern ColorBuffer g_AOHighQuality3; - extern ColorBuffer g_AOHighQuality4; - - extern ColorBuffer g_DoFTileClass[2]; - extern ColorBuffer g_DoFPresortBuffer; - extern ColorBuffer g_DoFPrefilter; - extern ColorBuffer g_DoFBlurColor[2]; - extern ColorBuffer g_DoFBlurAlpha[2]; - extern StructuredBuffer g_DoFWorkQueue; - extern StructuredBuffer g_DoFFastQueue; - extern StructuredBuffer g_DoFFixupQueue; - - extern ColorBuffer g_MotionPrepBuffer; // R10G10B10A2 - extern ColorBuffer g_LumaBuffer; - extern ColorBuffer g_TemporalColor[2]; - extern ColorBuffer g_TemporalMinBound; - extern ColorBuffer g_TemporalMaxBound; - - extern ColorBuffer g_aBloomUAV1[2]; // 640x384 (1/3) - extern ColorBuffer g_aBloomUAV2[2]; // 320x192 (1/6) - extern ColorBuffer g_aBloomUAV3[2]; // 160x96 (1/12) - extern ColorBuffer g_aBloomUAV4[2]; // 80x48 (1/24) - extern ColorBuffer g_aBloomUAV5[2]; // 40x24 (1/48) - extern ColorBuffer g_LumaLR; - extern ByteAddressBuffer g_Histogram; - extern ByteAddressBuffer g_FXAAWorkQueue; - extern TypedBuffer g_FXAAColorQueue; - - void InitializeRenderingBuffers(uint32_t NativeWidth, uint32_t NativeHeight ); - void ResizeDisplayDependentBuffers(uint32_t NativeWidth, uint32_t NativeHeight); - void DestroyRenderingBuffers(); - -} // namespace Graphics diff --git a/xess/samples/xess_demo/MiniEngine/Core/Camera.cpp b/xess/samples/xess_demo/MiniEngine/Core/Camera.cpp deleted file mode 100644 index dbfc8c2..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Camera.cpp +++ /dev/null @@ -1,112 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -// Modified 2022, Intel Corporation. -// Added support for camera jitter. - -#include "pch.h" -#include "Camera.h" -#include - -using namespace Math; - -void BaseCamera::SetLookDirection( Vector3 forward, Vector3 up ) -{ - // Given, but ensure normalization - Scalar forwardLenSq = LengthSquare(forward); - forward = Select(forward * RecipSqrt(forwardLenSq), -Vector3(kZUnitVector), forwardLenSq < Scalar(0.000001f)); - - // Deduce a valid, orthogonal right vector - Vector3 right = Cross(forward, up); - Scalar rightLenSq = LengthSquare(right); - right = Select(right * RecipSqrt(rightLenSq), Quaternion(Vector3(kYUnitVector), -XM_PIDIV2) * forward, rightLenSq < Scalar(0.000001f)); - - // Compute actual up vector - up = Cross(right, forward); - - // Finish constructing basis - m_Basis = Matrix3(right, up, -forward); - m_CameraToWorld.SetRotation(Quaternion(m_Basis)); -} - -void BaseCamera::Update() -{ - // Jitter is used in the projection matrix calculation, but jitter should not affect the re-projection between frames. - m_PreviousViewProjMatrix = m_ViewProjMatrixNoJitter; - - m_ViewMatrix = Matrix4(~m_CameraToWorld); - m_ViewProjMatrix = m_ProjMatrix * m_ViewMatrix; - - // We use "*NoJitter" version of matrices for velocity buffer calculation. - m_ViewProjMatrixNoJitter = m_ProjMatrixNoJitter * m_ViewMatrix; - m_ReprojectMatrix = m_PreviousViewProjMatrix * Invert(m_ViewProjMatrixNoJitter); - - m_FrustumVS = Frustum( m_ProjMatrix ); - m_FrustumWS = m_CameraToWorld * m_FrustumVS; -} - - -void Camera::UpdateProjMatrix( void ) -{ - float Y = 1.0f / std::tanf( m_VerticalFOV * 0.5f ); - float X = Y * m_AspectRatio; - - float Q1, Q2; - - // ReverseZ puts far plane at Z=0 and near plane at Z=1. This is never a bad idea, and it's - // actually a great idea with F32 depth buffers to redistribute precision more evenly across - // the entire range. It requires clearing Z to 0.0f and using a GREATER variant depth test. - // Some care must also be done to properly reconstruct linear W in a pixel shader from hyperbolic Z. - if (m_ReverseZ) - { - if (m_InfiniteZ) - { - Q1 = 0.0f; - Q2 = m_NearClip; - } - else - { - Q1 = m_NearClip / (m_FarClip - m_NearClip); - Q2 = Q1 * m_FarClip; - } - } - else - { - if (m_InfiniteZ) - { - Q1 = -1.0f; - Q2 = -m_NearClip; - } - else - { - Q1 = m_FarClip / (m_NearClip - m_FarClip); - Q2 = Q1 * m_NearClip; - } - } - - SetProjMatrix( Matrix4( - Vector4( X, 0.0f, 0.0f, 0.0f ), - Vector4( 0.0f, Y, 0.0f, 0.0f ), - Vector4( 0.0f, 0.0f, Q1, -1.0f ), - Vector4( 0.0f, 0.0f, Q2, 0.0f ) - ) ); -} - -void Camera::SetProjectMatrixJitter(float ProjectionJitterX, float ProjectionJitterY) -{ - Vector4 vec = m_ProjMatrix.GetZ(); - vec.SetX(ProjectionJitterX); - vec.SetY(ProjectionJitterY); - - m_ProjMatrix.SetZ(vec); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Camera.h b/xess/samples/xess_demo/MiniEngine/Core/Camera.h deleted file mode 100644 index c7defb0..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Camera.h +++ /dev/null @@ -1,181 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -// Modified 2022, Intel Corporation. -// Added support for camera jitter. - -#pragma once - -#include "VectorMath.h" -#include "Math/Frustum.h" - -namespace Math -{ - class BaseCamera - { - public: - - // Call this function once per frame and after you've changed any state. This - // regenerates all matrices. Calling it more or less than once per frame will break - // temporal effects and cause unpredictable results. - void Update(); - - // Public functions for controlling where the camera is and its orientation - void SetEyeAtUp( Vector3 eye, Vector3 at, Vector3 up ); - void SetLookDirection( Vector3 forward, Vector3 up ); - void SetRotation( Quaternion basisRotation ); - void SetPosition( Vector3 worldPos ); - void SetTransform( const AffineTransform& xform ); - void SetTransform( const OrthogonalTransform& xform ); - - const Quaternion GetRotation() const { return m_CameraToWorld.GetRotation(); } - const Vector3 GetRightVec() const { return m_Basis.GetX(); } - const Vector3 GetUpVec() const { return m_Basis.GetY(); } - const Vector3 GetForwardVec() const { return -m_Basis.GetZ(); } - const Vector3 GetPosition() const { return m_CameraToWorld.GetTranslation(); } - - // Accessors for reading the various matrices and frusta - const Matrix4& GetViewMatrix() const { return m_ViewMatrix; } - const Matrix4& GetProjMatrix() const { return m_ProjMatrix; } - const Matrix4& GetViewProjMatrix() const { return m_ViewProjMatrix; } - const Matrix4& GetReprojectionMatrix() const { return m_ReprojectMatrix; } - const Frustum& GetViewSpaceFrustum() const { return m_FrustumVS; } - const Frustum& GetWorldSpaceFrustum() const { return m_FrustumWS; } - - protected: - - BaseCamera() : - m_CameraToWorld(kIdentity), - m_Basis(kIdentity), - m_ViewMatrix(kIdentity), - m_ProjMatrix(kIdentity), - m_ViewProjMatrix(kIdentity), - m_ProjMatrixNoJitter(kIdentity), - m_ViewProjMatrixNoJitter(kIdentity), - m_PreviousViewProjMatrix(kIdentity), - m_ReprojectMatrix(kIdentity) - { - } - - void SetProjMatrix( const Matrix4& ProjMat ) { m_ProjMatrixNoJitter = m_ProjMatrix = ProjMat; } - - OrthogonalTransform m_CameraToWorld; - - // Redundant data cached for faster lookups. - Matrix3 m_Basis; - - // Transforms homogeneous coordinates from world space to view space. In this case, view space is defined as +X is - // to the right, +Y is up, and -Z is forward. This has to match what the projection matrix expects, but you might - // also need to know what the convention is if you work in view space in a shader. - Matrix4 m_ViewMatrix; // i.e. "World-to-View" matrix - - // The projection matrix transforms view space to clip space. Once division by W has occurred, the final coordinates - // can be transformed by the viewport matrix to screen space. The projection matrix is determined by the screen aspect - // and camera field of view. A projection matrix can also be orthographic. In that case, field of view would be defined - // in linear units, not angles. - Matrix4 m_ProjMatrix; // i.e. "View-to-Projection" matrix - - // A concatenation of the view and projection matrices. - Matrix4 m_ViewProjMatrix; // i.e. "World-To-Projection" matrix. - - Matrix4 m_ProjMatrixNoJitter; // m_ProjMatrix, but without jitter. - Matrix4 m_ViewProjMatrixNoJitter; // m_ViewProjMatrix, but without jitter. - - // The view-projection matrix from the previous frame - Matrix4 m_PreviousViewProjMatrix; - - // Projects a clip-space coordinate to the previous frame (useful for temporal effects). - Matrix4 m_ReprojectMatrix; - - Frustum m_FrustumVS; // View-space view frustum - Frustum m_FrustumWS; // World-space view frustum - - }; - - class Camera : public BaseCamera - { - public: - Camera(); - - // Controls the view-to-projection matrix - void SetPerspectiveMatrix( float verticalFovRadians, float aspectHeightOverWidth, float nearZClip, float farZClip ); - void SetFOV( float verticalFovInRadians ) { m_VerticalFOV = verticalFovInRadians; UpdateProjMatrix(); } - void SetAspectRatio( float heightOverWidth ) { m_AspectRatio = heightOverWidth; UpdateProjMatrix(); } - void SetZRange( float nearZ, float farZ) { m_NearClip = nearZ; m_FarClip = farZ; UpdateProjMatrix(); } - void ReverseZ( bool enable ) { m_ReverseZ = enable; UpdateProjMatrix(); } - - float GetFOV() const { return m_VerticalFOV; } - float GetNearClip() const { return m_NearClip; } - float GetFarClip() const { return m_FarClip; } - float GetClearDepth() const { return m_ReverseZ ? 0.0f : 1.0f; } - - // Set projection matrix with jitter. - void SetProjectMatrixJitter(float ProjectionJitterX, float ProjectionJitterY); - - private: - - void UpdateProjMatrix( void ); - - float m_VerticalFOV; // Field of view angle in radians - float m_AspectRatio; - float m_NearClip; - float m_FarClip; - bool m_ReverseZ; // Invert near and far clip distances so that Z=1 at the near plane - bool m_InfiniteZ; // Move the far plane to infinity - }; - - inline void BaseCamera::SetEyeAtUp( Vector3 eye, Vector3 at, Vector3 up ) - { - SetLookDirection(at - eye, up); - SetPosition(eye); - } - - inline void BaseCamera::SetPosition( Vector3 worldPos ) - { - m_CameraToWorld.SetTranslation( worldPos ); - } - - inline void BaseCamera::SetTransform( const AffineTransform& xform ) - { - // By using these functions, we rederive an orthogonal transform. - SetLookDirection(-xform.GetZ(), xform.GetY()); - SetPosition(xform.GetTranslation()); - } - - inline void BaseCamera::SetRotation( Quaternion basisRotation ) - { - m_CameraToWorld.SetRotation(Normalize(basisRotation)); - m_Basis = Matrix3(m_CameraToWorld.GetRotation()); - } - - inline Camera::Camera() : - BaseCamera(), - m_ReverseZ(true), - m_InfiniteZ(false) - { - SetPerspectiveMatrix( XM_PIDIV4, 9.0f / 16.0f, 1.0f, 1000.0f ); - } - - inline void Camera::SetPerspectiveMatrix( float verticalFovRadians, float aspectHeightOverWidth, float nearZClip, float farZClip ) - { - m_VerticalFOV = verticalFovRadians; - m_AspectRatio = aspectHeightOverWidth; - m_NearClip = nearZClip; - m_FarClip = farZClip; - - UpdateProjMatrix(); - - m_PreviousViewProjMatrix = m_ViewProjMatrixNoJitter; - } - -} // namespace Math diff --git a/xess/samples/xess_demo/MiniEngine/Core/CameraController.cpp b/xess/samples/xess_demo/MiniEngine/Core/CameraController.cpp deleted file mode 100644 index 7a1e13a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/CameraController.cpp +++ /dev/null @@ -1,212 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "CameraController.h" -#include "Camera.h" -#include "GameInput.h" - -using namespace Math; -using namespace GameCore; - -FlyingFPSCamera::FlyingFPSCamera( Camera& camera, Vector3 worldUp ) : CameraController( camera ) -{ - m_WorldUp = Normalize(worldUp); - m_WorldNorth = Normalize(Cross(m_WorldUp, Vector3(kXUnitVector))); - m_WorldEast = Cross(m_WorldNorth, m_WorldUp); - - m_HorizontalLookSensitivity = 2.0f; - m_VerticalLookSensitivity = 2.0f; - m_MoveSpeed = 1000.0f; - m_StrafeSpeed = 1000.0f; - m_MouseSensitivityX = 1.0f; - m_MouseSensitivityY = 1.0f; - - m_CurrentPitch = Sin(Dot(camera.GetForwardVec(), m_WorldUp)); - - Vector3 forward = Normalize(Cross(m_WorldUp, camera.GetRightVec())); - m_CurrentHeading = ATan2(-Dot(forward, m_WorldEast), Dot(forward, m_WorldNorth)); - - m_FineMovement = false; - m_FineRotation = false; - m_Momentum = true; - - m_LastYaw = 0.0f; - m_LastPitch = 0.0f; - m_LastForward = 0.0f; - m_LastStrafe = 0.0f; - m_LastAscent = 0.0f; -} - -namespace Graphics -{ - extern EnumVar DebugZoom; -} - -void FlyingFPSCamera::Update( float deltaTime ) -{ - (deltaTime); - - float timeScale = Graphics::DebugZoom == 0 ? 1.0f : Graphics::DebugZoom == 1 ? 0.5f : 0.25f; - - if (GameInput::IsFirstPressed(GameInput::kLThumbClick) || GameInput::IsFirstPressed(GameInput::kKey_lshift)) - m_FineMovement = !m_FineMovement; - - if (GameInput::IsFirstPressed(GameInput::kRThumbClick)) - m_FineRotation = !m_FineRotation; - - float speedScale = (m_FineMovement ? 0.1f : 1.0f) * timeScale; - float panScale = (m_FineRotation ? 0.5f : 1.0f) * timeScale; - - float yaw = GameInput::GetTimeCorrectedAnalogInput( GameInput::kAnalogRightStickX ) * m_HorizontalLookSensitivity * panScale; - float pitch = GameInput::GetTimeCorrectedAnalogInput( GameInput::kAnalogRightStickY ) * m_VerticalLookSensitivity * panScale; - float forward = m_MoveSpeed * speedScale * ( - GameInput::GetTimeCorrectedAnalogInput( GameInput::kAnalogLeftStickY ) + - (GameInput::IsPressed( GameInput::kKey_w ) ? deltaTime : 0.0f) + - (GameInput::IsPressed( GameInput::kKey_s ) ? -deltaTime : 0.0f) - ); - float strafe = m_StrafeSpeed * speedScale * ( - GameInput::GetTimeCorrectedAnalogInput( GameInput::kAnalogLeftStickX ) + - (GameInput::IsPressed( GameInput::kKey_d ) ? deltaTime : 0.0f) + - (GameInput::IsPressed( GameInput::kKey_a ) ? -deltaTime : 0.0f) - ); - float ascent = m_StrafeSpeed * speedScale * ( - GameInput::GetTimeCorrectedAnalogInput( GameInput::kAnalogRightTrigger ) - - GameInput::GetTimeCorrectedAnalogInput( GameInput::kAnalogLeftTrigger ) + - (GameInput::IsPressed( GameInput::kKey_e ) ? deltaTime : 0.0f) + - (GameInput::IsPressed( GameInput::kKey_q ) ? -deltaTime : 0.0f) - ); - - if (m_Momentum) - { - ApplyMomentum(m_LastYaw, yaw, deltaTime); - ApplyMomentum(m_LastPitch, pitch, deltaTime); - ApplyMomentum(m_LastForward, forward, deltaTime); - ApplyMomentum(m_LastStrafe, strafe, deltaTime); - ApplyMomentum(m_LastAscent, ascent, deltaTime); - } - - // don't apply momentum to mouse inputs - yaw += GameInput::GetAnalogInput(GameInput::kAnalogMouseX) * m_MouseSensitivityX; - pitch += GameInput::GetAnalogInput(GameInput::kAnalogMouseY) * m_MouseSensitivityY; - - m_CurrentPitch += pitch; - m_CurrentPitch = XMMin( XM_PIDIV2, m_CurrentPitch); - m_CurrentPitch = XMMax(-XM_PIDIV2, m_CurrentPitch); - - m_CurrentHeading -= yaw; - if (m_CurrentHeading > XM_PI) - m_CurrentHeading -= XM_2PI; - else if (m_CurrentHeading <= -XM_PI) - m_CurrentHeading += XM_2PI; - - Matrix3 orientation = Matrix3(m_WorldEast, m_WorldUp, -m_WorldNorth) * Matrix3::MakeYRotation( m_CurrentHeading ) * Matrix3::MakeXRotation( m_CurrentPitch ); - Vector3 position = orientation * Vector3( strafe, ascent, -forward ) + m_TargetCamera.GetPosition(); - - m_TargetCamera.SetTransform( AffineTransform( orientation, position ) ); - m_TargetCamera.Update(); -} - -void FlyingFPSCamera::SetHeadingPitchAndPosition(float heading, float pitch, const Vector3& position) -{ - m_CurrentHeading = heading; - if (m_CurrentHeading > XM_PI) - m_CurrentHeading -= XM_2PI; - else if (m_CurrentHeading <= -XM_PI) - m_CurrentHeading += XM_2PI; - - m_CurrentPitch = pitch; - m_CurrentPitch = XMMin( XM_PIDIV2, m_CurrentPitch); - m_CurrentPitch = XMMax(-XM_PIDIV2, m_CurrentPitch); - - Matrix3 orientation = - Matrix3(m_WorldEast, m_WorldUp, -m_WorldNorth) * - Matrix3::MakeYRotation( m_CurrentHeading ) * - Matrix3::MakeXRotation( m_CurrentPitch ); - - m_TargetCamera.SetTransform( AffineTransform( orientation, position ) ); - m_TargetCamera.Update(); -} - - -void CameraController::ApplyMomentum( float& oldValue, float& newValue, float deltaTime ) -{ - float blendedValue; - if (Abs(newValue) > Abs(oldValue)) - blendedValue = Lerp(newValue, oldValue, Pow(0.6f, deltaTime * 60.0f)); - else - blendedValue = Lerp(newValue, oldValue, Pow(0.8f, deltaTime * 60.0f)); - oldValue = blendedValue; - newValue = blendedValue; -} - -OrbitCamera::OrbitCamera( Camera& camera, Math::BoundingSphere focus, Vector3 worldUp ) : CameraController( camera ) -{ - m_ModelBounds = focus; - m_WorldUp = Normalize(worldUp); - - m_JoystickSensitivityX = 2.0f; - m_JoystickSensitivityY = 2.0f; - - m_MouseSensitivityX = 1.0f; - m_MouseSensitivityY = 1.0f; - - m_CurrentPitch = 0.0f; - m_CurrentHeading = 0.0f; - m_CurrentCloseness = 0.5f; - - m_Momentum = true; - - m_LastYaw = 0.0f; - m_LastPitch = 0.0f; -} - -void OrbitCamera::Update( float deltaTime ) -{ - (deltaTime); - - float timeScale = Graphics::DebugZoom == 0 ? 1.0f : Graphics::DebugZoom == 1 ? 0.5f : 0.25f; - - float yaw = GameInput::GetTimeCorrectedAnalogInput( GameInput::kAnalogLeftStickX ) * timeScale * m_JoystickSensitivityX; - float pitch = GameInput::GetTimeCorrectedAnalogInput( GameInput::kAnalogLeftStickY ) * timeScale * m_JoystickSensitivityY; - float closeness = GameInput::GetTimeCorrectedAnalogInput( GameInput::kAnalogRightStickY ) * timeScale; - - if (m_Momentum) - { - ApplyMomentum(m_LastYaw, yaw, deltaTime); - ApplyMomentum(m_LastPitch, pitch, deltaTime); - } - - // don't apply momentum to mouse inputs - yaw += GameInput::GetAnalogInput(GameInput::kAnalogMouseX) * m_MouseSensitivityX; - pitch += GameInput::GetAnalogInput(GameInput::kAnalogMouseY) * m_MouseSensitivityY; - closeness += GameInput::GetAnalogInput(GameInput::kAnalogMouseScroll) * 0.1f; - - m_CurrentPitch += pitch; - m_CurrentPitch = XMMin( XM_PIDIV2, m_CurrentPitch); - m_CurrentPitch = XMMax(-XM_PIDIV2, m_CurrentPitch); - - m_CurrentHeading -= yaw; - if (m_CurrentHeading > XM_PI) - m_CurrentHeading -= XM_2PI; - else if (m_CurrentHeading <= -XM_PI) - m_CurrentHeading += XM_2PI; - - m_CurrentCloseness += closeness; - m_CurrentCloseness = Clamp(m_CurrentCloseness, 0.0f, 1.0f); - - Matrix3 orientation = Matrix3::MakeYRotation( m_CurrentHeading ) * Matrix3::MakeXRotation( m_CurrentPitch ); - Vector3 position = orientation.GetZ() * (m_ModelBounds.GetRadius() * Lerp(3.0f, 1.0f, m_CurrentCloseness) + m_TargetCamera.GetNearClip()); - m_TargetCamera.SetTransform(AffineTransform(orientation, position + m_ModelBounds.GetCenter())); - m_TargetCamera.Update(); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/CameraController.h b/xess/samples/xess_demo/MiniEngine/Core/CameraController.h deleted file mode 100644 index d58cb19..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/CameraController.h +++ /dev/null @@ -1,117 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "GameCore.h" -#include "VectorMath.h" -#include "../Core/Math/BoundingSphere.h" - -namespace Math -{ - class Camera; -} - -using namespace Math; - -class CameraController -{ -public: - // Assumes worldUp is not the X basis vector - CameraController( Camera& camera ) : m_TargetCamera(camera) {} - virtual ~CameraController() {} - virtual void Update( float dt ) = 0; - - // Helper function - static void ApplyMomentum( float& oldValue, float& newValue, float deltaTime ); - -protected: - Camera& m_TargetCamera; - -private: - CameraController& operator=( const CameraController& ) {return *this;} -}; - -class FlyingFPSCamera : public CameraController -{ -public: - FlyingFPSCamera( Camera& camera, Vector3 worldUp ); - - virtual void Update( float dt ) override; - - void SlowMovement( bool enable ) { m_FineMovement = enable; } - void SlowRotation( bool enable ) { m_FineRotation = enable; } - - void EnableMomentum( bool enable ) { m_Momentum = enable; } - - void SetHeadingPitchAndPosition(float heading, float pitch, const Vector3& position); - -protected: - - Vector3 m_WorldUp; - Vector3 m_WorldNorth; - Vector3 m_WorldEast; - float m_HorizontalLookSensitivity; - float m_VerticalLookSensitivity; - float m_MoveSpeed; - float m_StrafeSpeed; - float m_MouseSensitivityX; - float m_MouseSensitivityY; - - float m_CurrentHeading; - float m_CurrentPitch; - - bool m_FineMovement; - bool m_FineRotation; - bool m_Momentum; - - float m_LastYaw; - float m_LastPitch; - float m_LastForward; - float m_LastStrafe; - float m_LastAscent; -}; - -class OrbitCamera : public CameraController -{ -public: - OrbitCamera( Math::Camera& camera, - Math::BoundingSphere focus, - Math::Vector3 upVec = Math::Vector3(Math::kYUnitVector) ); - - virtual void Update( float dt ) override; - - void EnableMomentum( bool enable ) { m_Momentum = enable; } - -private: - OrbitCamera& operator=( const OrbitCamera& ) {return *this;} - - Math::BoundingSphere m_ModelBounds; - Math::Vector3 m_WorldUp; - - float m_JoystickSensitivityX; - float m_JoystickSensitivityY; - - float m_MouseSensitivityX; - float m_MouseSensitivityY; - - float m_CurrentHeading; - float m_CurrentPitch; - float m_CurrentCloseness; - - bool m_Momentum; - - float m_LastYaw; - float m_LastPitch; - float m_LastForward; -}; diff --git a/xess/samples/xess_demo/MiniEngine/Core/Color.cpp b/xess/samples/xess_demo/MiniEngine/Core/Color.cpp deleted file mode 100644 index 47fba84..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Color.cpp +++ /dev/null @@ -1,152 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "Color.h" - -using DirectX::XMVECTORU32; - -uint32_t Color::R11G11B10F(bool RoundToEven) const -{ -#if 1 - static const float kMaxVal = float(1 << 16); - static const float kF32toF16 = (1.0 / (1ull << 56)) * (1.0 / (1ull << 56)); - - union { float f; uint32_t u; } R, G, B; - - R.f = Math::Clamp(m_value.f[0], 0.0f, kMaxVal) * kF32toF16; - G.f = Math::Clamp(m_value.f[1], 0.0f, kMaxVal) * kF32toF16; - B.f = Math::Clamp(m_value.f[2], 0.0f, kMaxVal) * kF32toF16; - - if (RoundToEven) - { - // Bankers rounding: 2.5 -> 2.0 ; 3.5 -> 4.0 - R.u += 0x0FFFF + ((R.u >> 16) & 1); - G.u += 0x0FFFF + ((G.u >> 16) & 1); - B.u += 0x1FFFF + ((B.u >> 17) & 1); - } - else - { - // Default rounding: 2.5 -> 3.0 ; 3.5 -> 4.0 - R.u += 0x00010000; - G.u += 0x00010000; - B.u += 0x00020000; - } - - R.u &= 0x0FFE0000; - G.u &= 0x0FFE0000; - B.u &= 0x0FFC0000; - - return R.u >> 17 | G.u >> 6 | B.u << 4; - -#else // SSE - - static XMVECTORU32 Scale = { 0x07800000, 0x07800000, 0x07800000, 0 }; // 2^-112 - static XMVECTORU32 Round1 = { 0x00010000, 0x00010000, 0x00020000, 0 }; - static XMVECTORU32 Round2 = { 0x0000FFFF, 0x0000FFFF, 0x0001FFFF, 0 }; - static XMVECTORU32 Mask = { 0x0FFE0000, 0x0FFE0000, 0x0FFC0000, 0 }; - - // Treat the values like integers as we clamp to [0, +Inf]. This translates 32-bit specials - // to 16-bit specials (while also turning anything greater than MAX_HALF into +INF). - __m128i ti = _mm_max_epi32(_mm_castps_si128(m_value), _mm_setzero_si128()); - ti = _mm_min_epi32(ti, _mm_set1_epi32(0x47800000)); // 2^16 = 65536.0f = INF - - // Bias the exponent by -112 (-127 + 15) to denormalize values < 2^-14 - ti = _mm_castps_si128(_mm_mul_ps(_mm_castsi128_ps(ti), Scale)); - - if (RoundToEven) - { - // Add 0x10000 when odd, 0x0FFFF when even (before truncating bits) - ti = _mm_add_epi32(ti, _mm_max_epi32(_mm_and_si128(_mm_srli_epi32(ti, 1), Round1), Round2)); - } - else //if (RoundToNearest) - { - ti = _mm_add_epi32(ti, Round1); - } - - XMVECTORU32 ret; - ret.v = _mm_castsi128_ps(_mm_and_si128(ti, Mask)); - return ret.u[0] >> 17 | ret.u[1] >> 6 | ret.u[2] << 4; - -#endif -} - -uint32_t Color::R9G9B9E5() const -{ -#if 1 - static const float kMaxVal = float(0x1FF << 7); - static const float kMinVal = float(1.f / (1 << 16)); - - // Clamp RGB to [0, 1.FF*2^16] - float r = Math::Clamp(m_value.f[0], 0.0f, kMaxVal); - float g = Math::Clamp(m_value.f[1], 0.0f, kMaxVal); - float b = Math::Clamp(m_value.f[2], 0.0f, kMaxVal); - - // Compute the maximum channel, no less than 1.0*2^-15 - float MaxChannel = Math::Max(Math::Max(r, g), Math::Max(b, kMinVal)); - - // Take the exponent of the maximum channel (rounding up the 9th bit) and - // add 15 to it. When added to the channels, it causes the implicit '1.0' - // bit and the first 8 mantissa bits to be shifted down to the low 9 bits - // of the mantissa, rounding the truncated bits. - union { float f; int32_t i; } R, G, B, E; - E.f = MaxChannel; - E.i += 0x07804000; // Add 15 to the exponent and 0x4000 to the mantissa - E.i &= 0x7F800000; // Zero the mantissa - - // This shifts the 9-bit values we need into the lowest bits, rounding as - // needed. Note that if the channel has a smaller exponent than the max - // channel, it will shift even more. This is intentional. - R.f = r + E.f; - G.f = g + E.f; - B.f = b + E.f; - - // Convert the Bias to the correct exponent in the upper 5 bits. - E.i <<= 4; - E.i += 0x10000000; - - // Combine the fields. RGB floats have unwanted data in the upper 9 - // bits. Only red needs to mask them off because green and blue shift - // it out to the left. - return E.i | B.i << 18 | G.i << 9 | R.i & 511; - -#else // SSE - - // Clamp RGB to [0, 1.FF*2^16] - __m128 kMaxVal = _mm_castsi128_ps(_mm_set1_epi32(0x477F8000)); - __m128 rgb = _mm_min_ps(_mm_max_ps(m_value, _mm_setzero_ps()), kMaxVal); - - // Compute the maximum channel, no less than 1.0*2^-15 - __m128 kMinVal = _mm_castsi128_ps(_mm_set1_epi32(0x37800000)); - __m128 MaxChannel = _mm_max_ps(rgb, kMinVal); - MaxChannel = _mm_max_ps( _mm_permute_ps(MaxChannel, _MM_SHUFFLE(3, 1, 0, 2)), - _mm_max_ps(_mm_permute_ps(MaxChannel, _MM_SHUFFLE(3, 0, 2, 1)), MaxChannel) ); - - // Add 15 to the exponent and 0x4000 to the mantissa - __m128i kBias15 = _mm_set1_epi32(0x07804000); - __m128i kExpMask = _mm_set1_epi32(0x7F800000); - __m128i Bias = _mm_and_si128(_mm_add_epi32(_mm_castps_si128(MaxChannel), kBias15), kExpMask); - - // rgb += Bias - rgb = _mm_add_ps(rgb, _mm_castsi128_ps(Bias)); - - // Exp = (Bias << 4) + 0x10000000; - __m128i Exp = _mm_add_epi32(_mm_slli_epi32(Bias, 4), _mm_set1_epi32(0x10000000)); - - // Combine words - XMVECTORU32 ret; - ret.v = _mm_insert_ps(rgb, _mm_castsi128_ps(Exp), 0x30); - return ret.u[3] | ret.u[2] << 18 | ret.u[1] << 9 | ret.u[0] & 511; - -#endif -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Color.h b/xess/samples/xess_demo/MiniEngine/Core/Color.h deleted file mode 100644 index 3b96a65..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Color.h +++ /dev/null @@ -1,153 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include - -using namespace DirectX; - -class Color -{ -public: - Color( ) : m_value(g_XMOne) {} - Color( FXMVECTOR vec ); - Color( const XMVECTORF32& vec ); - Color( float r, float g, float b, float a = 1.0f ); - Color( uint16_t r, uint16_t g, uint16_t b, uint16_t a = 255, uint16_t bitDepth = 8 ); - explicit Color( uint32_t rgbaLittleEndian ); - - float R() const { return XMVectorGetX(m_value); } - float G() const { return XMVectorGetY(m_value); } - float B() const { return XMVectorGetZ(m_value); } - float A() const { return XMVectorGetW(m_value); } - - bool operator==( const Color& rhs ) const { return XMVector4Equal(m_value, rhs.m_value); } - bool operator!=( const Color& rhs ) const { return !XMVector4Equal(m_value, rhs.m_value); } - - void SetR( float r ) { m_value.f[0] = r; } - void SetG( float g ) { m_value.f[1] = g; } - void SetB( float b ) { m_value.f[2] = b; } - void SetA( float a ) { m_value.f[3] = a; } - - float* GetPtr( void ) { return reinterpret_cast(this); } - float& operator[]( int idx ) { return GetPtr()[idx]; } - - void SetRGB( float r, float g, float b ) { m_value.v = XMVectorSelect( m_value, XMVectorSet(r, g, b, b), g_XMMask3 ); } - - Color ToSRGB() const; - Color FromSRGB() const; - Color ToREC709() const; - Color FromREC709() const; - - // Probably want to convert to sRGB or Rec709 first - uint32_t R10G10B10A2() const; - uint32_t R8G8B8A8() const; - - // Pack an HDR color into 32-bits - uint32_t R11G11B10F(bool RoundToEven=false) const; - uint32_t R9G9B9E5() const; - - operator XMVECTOR() const { return m_value; } - -private: - XMVECTORF32 m_value; -}; - -INLINE Color Max( Color a, Color b ) { return Color(XMVectorMax(a, b)); } -INLINE Color Min( Color a, Color b ) { return Color(XMVectorMin(a, b)); } -INLINE Color Clamp( Color x, Color a, Color b ) { return Color(XMVectorClamp(x, a, b)); } - - -inline Color::Color( FXMVECTOR vec ) -{ - m_value.v = vec; -} - -inline Color::Color( const XMVECTORF32& vec ) -{ - m_value = vec; -} - -inline Color::Color( float r, float g, float b, float a ) -{ - m_value.v = XMVectorSet(r, g, b, a); -} - -inline Color::Color( uint16_t r, uint16_t g, uint16_t b, uint16_t a, uint16_t bitDepth ) -{ - m_value.v = XMVectorScale(XMVectorSet(r, g, b, a), 1.0f / ((1 << bitDepth) - 1)); -} - -inline Color::Color( uint32_t u32 ) -{ - float r = (float)((u32 >> 0) & 0xFF); - float g = (float)((u32 >> 8) & 0xFF); - float b = (float)((u32 >> 16) & 0xFF); - float a = (float)((u32 >> 24) & 0xFF); - m_value.v = XMVectorScale( XMVectorSet(r, g, b, a), 1.0f / 255.0f ); -} - -inline Color Color::ToSRGB( void ) const -{ - XMVECTOR T = XMVectorSaturate(m_value); - XMVECTOR result = XMVectorSubtract(XMVectorScale(XMVectorPow(T, XMVectorReplicate(1.0f / 2.4f)), 1.055f), XMVectorReplicate(0.055f)); - result = XMVectorSelect(result, XMVectorScale(T, 12.92f), XMVectorLess(T, XMVectorReplicate(0.0031308f))); - return XMVectorSelect(T, result, g_XMSelect1110); -} - -inline Color Color::FromSRGB( void ) const -{ - XMVECTOR T = XMVectorSaturate(m_value); - XMVECTOR result = XMVectorPow(XMVectorScale(XMVectorAdd(T, XMVectorReplicate(0.055f)), 1.0f / 1.055f), XMVectorReplicate(2.4f)); - result = XMVectorSelect(result, XMVectorScale(T, 1.0f / 12.92f), XMVectorLess(T, XMVectorReplicate(0.0031308f))); - return XMVectorSelect(T, result, g_XMSelect1110); -} - -inline Color Color::ToREC709( void ) const -{ - XMVECTOR T = XMVectorSaturate(m_value); - XMVECTOR result = XMVectorSubtract(XMVectorScale(XMVectorPow(T, XMVectorReplicate(0.45f)), 1.099f), XMVectorReplicate(0.099f)); - result = XMVectorSelect(result, XMVectorScale(T, 4.5f), XMVectorLess(T, XMVectorReplicate(0.0018f))); - return XMVectorSelect(T, result, g_XMSelect1110); -} - -inline Color Color::FromREC709( void ) const -{ - XMVECTOR T = XMVectorSaturate(m_value); - XMVECTOR result = XMVectorPow(XMVectorScale(XMVectorAdd(T, XMVectorReplicate(0.099f)), 1.0f / 1.099f), XMVectorReplicate(1.0f / 0.45f)); - result = XMVectorSelect(result, XMVectorScale(T, 1.0f / 4.5f), XMVectorLess(T, XMVectorReplicate(0.0081f))); - return XMVectorSelect(T, result, g_XMSelect1110); -} - -inline uint32_t Color::R10G10B10A2( void ) const -{ - XMVECTOR result = XMVectorRound(XMVectorMultiply(XMVectorSaturate(m_value), XMVectorSet(1023.0f, 1023.0f, 1023.0f, 3.0f))); - result = _mm_castsi128_ps(_mm_cvttps_epi32(result)); - uint32_t r = XMVectorGetIntX(result); - uint32_t g = XMVectorGetIntY(result); - uint32_t b = XMVectorGetIntZ(result); - uint32_t a = XMVectorGetIntW(result) >> 8; - return a << 30 | b << 20 | g << 10 | r; -} - -inline uint32_t Color::R8G8B8A8( void ) const -{ - XMVECTOR result = XMVectorRound(XMVectorMultiply(XMVectorSaturate(m_value), XMVectorReplicate(255.0f))); - result = _mm_castsi128_ps(_mm_cvttps_epi32(result)); - uint32_t r = XMVectorGetIntX(result); - uint32_t g = XMVectorGetIntY(result); - uint32_t b = XMVectorGetIntZ(result); - uint32_t a = XMVectorGetIntW(result); - return a << 24 | b << 16 | g << 8 | r; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/ColorBuffer.cpp b/xess/samples/xess_demo/MiniEngine/Core/ColorBuffer.cpp deleted file mode 100644 index 3a07e99..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/ColorBuffer.cpp +++ /dev/null @@ -1,229 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "ColorBuffer.h" -#include "GraphicsCommon.h" -#include "CommandContext.h" -#include "EsramAllocator.h" - -using namespace Graphics; - -static uint64_t ColorBufferCount = 0; - -void ColorBuffer::CreateDerivedViews(ID3D12Device* Device, DXGI_FORMAT Format, uint32_t ArraySize, uint32_t NumMips) -{ - ASSERT(ArraySize == 1 || NumMips == 1, "We don't support auto-mips on texture arrays"); - - m_NumMipMaps = NumMips - 1; - - D3D12_RENDER_TARGET_VIEW_DESC RTVDesc = {}; - D3D12_UNORDERED_ACCESS_VIEW_DESC UAVDesc = {}; - D3D12_SHADER_RESOURCE_VIEW_DESC SRVDesc = {}; - - RTVDesc.Format = Format; - UAVDesc.Format = GetUAVFormat(Format); - SRVDesc.Format = Format; - SRVDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; - - if (ArraySize > 1) - { - RTVDesc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2DARRAY; - RTVDesc.Texture2DArray.MipSlice = 0; - RTVDesc.Texture2DArray.FirstArraySlice = 0; - RTVDesc.Texture2DArray.ArraySize = (UINT)ArraySize; - - UAVDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2DARRAY; - UAVDesc.Texture2DArray.MipSlice = 0; - UAVDesc.Texture2DArray.FirstArraySlice = 0; - UAVDesc.Texture2DArray.ArraySize = (UINT)ArraySize; - - SRVDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DARRAY; - SRVDesc.Texture2DArray.MipLevels = NumMips; - SRVDesc.Texture2DArray.MostDetailedMip = 0; - SRVDesc.Texture2DArray.FirstArraySlice = 0; - SRVDesc.Texture2DArray.ArraySize = (UINT)ArraySize; - } - else if (m_FragmentCount > 1) - { - RTVDesc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2DMS; - SRVDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DMS; - } - else - { - RTVDesc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D; - RTVDesc.Texture2D.MipSlice = 0; - - UAVDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2D; - UAVDesc.Texture2D.MipSlice = 0; - - SRVDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; - SRVDesc.Texture2D.MipLevels = NumMips; - SRVDesc.Texture2D.MostDetailedMip = 0; - } - - if (m_SRVHandle.ptr == D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN) - { - m_RTVHandle = Graphics::AllocateDescriptor(D3D12_DESCRIPTOR_HEAP_TYPE_RTV); - m_SRVHandle = Graphics::AllocateDescriptor(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - } - - ID3D12Resource* Resource = m_pResource.Get(); - - // Create the render target view - Device->CreateRenderTargetView(Resource, &RTVDesc, m_RTVHandle); - - // Create the shader resource view - Device->CreateShaderResourceView(Resource, &SRVDesc, m_SRVHandle); - - if (m_FragmentCount > 1) - return; - - // Create the UAVs for each mip level (RWTexture2D) - for (uint32_t i = 0; i < NumMips; ++i) - { - if (m_UAVHandle[i].ptr == D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN) - m_UAVHandle[i] = Graphics::AllocateDescriptor(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - - Device->CreateUnorderedAccessView(Resource, nullptr, &UAVDesc, m_UAVHandle[i]); - - UAVDesc.Texture2D.MipSlice++; - } -} - -void ColorBuffer::CreateFromSwapChain( const std::wstring& Name, ID3D12Resource* BaseResource ) -{ - AssociateWithResource(Graphics::g_Device, Name, BaseResource, D3D12_RESOURCE_STATE_PRESENT); - - //m_UAVHandle[0] = Graphics::AllocateDescriptor(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - //Graphics::g_Device->CreateUnorderedAccessView(m_pResource.Get(), nullptr, nullptr, m_UAVHandle[0]); - - m_RTVHandle = Graphics::AllocateDescriptor(D3D12_DESCRIPTOR_HEAP_TYPE_RTV); - Graphics::g_Device->CreateRenderTargetView(m_pResource.Get(), nullptr, m_RTVHandle); - - m_ColorBufferId = ++ColorBufferCount; -} - -void ColorBuffer::Create(const std::wstring& Name, uint32_t Width, uint32_t Height, uint32_t NumMips, - DXGI_FORMAT Format, D3D12_GPU_VIRTUAL_ADDRESS VidMem) -{ - NumMips = (NumMips == 0 ? ComputeNumMips(Width, Height) : NumMips); - D3D12_RESOURCE_FLAGS Flags = CombineResourceFlags(); - D3D12_RESOURCE_DESC ResourceDesc = DescribeTex2D(Width, Height, 1, NumMips, Format, Flags); - - ResourceDesc.SampleDesc.Count = m_FragmentCount; - ResourceDesc.SampleDesc.Quality = 0; - - D3D12_CLEAR_VALUE ClearValue = {}; - ClearValue.Format = Format; - ClearValue.Color[0] = m_ClearColor.R(); - ClearValue.Color[1] = m_ClearColor.G(); - ClearValue.Color[2] = m_ClearColor.B(); - ClearValue.Color[3] = m_ClearColor.A(); - - CreateTextureResource(Graphics::g_Device, Name, ResourceDesc, ClearValue, VidMem); - CreateDerivedViews(Graphics::g_Device, Format, 1, NumMips); - - m_ColorBufferId = ++ColorBufferCount; -} - -void ColorBuffer::Create(const std::wstring& Name, uint32_t Width, uint32_t Height, uint32_t NumMips, - DXGI_FORMAT Format, EsramAllocator&) -{ - Create(Name, Width, Height, NumMips, Format); -} - -void ColorBuffer::CreateArray( const std::wstring& Name, uint32_t Width, uint32_t Height, uint32_t ArrayCount, - DXGI_FORMAT Format, D3D12_GPU_VIRTUAL_ADDRESS VidMem ) -{ - D3D12_RESOURCE_FLAGS Flags = CombineResourceFlags(); - D3D12_RESOURCE_DESC ResourceDesc = DescribeTex2D(Width, Height, ArrayCount, 1, Format, Flags); - - D3D12_CLEAR_VALUE ClearValue = {}; - ClearValue.Format = Format; - ClearValue.Color[0] = m_ClearColor.R(); - ClearValue.Color[1] = m_ClearColor.G(); - ClearValue.Color[2] = m_ClearColor.B(); - ClearValue.Color[3] = m_ClearColor.A(); - - CreateTextureResource(Graphics::g_Device, Name, ResourceDesc, ClearValue, VidMem); - CreateDerivedViews(Graphics::g_Device, Format, ArrayCount, 1); - - m_ColorBufferId = ++ColorBufferCount; -} - -void ColorBuffer::CreateArray( const std::wstring& Name, uint32_t Width, uint32_t Height, uint32_t ArrayCount, - DXGI_FORMAT Format, EsramAllocator& ) -{ - CreateArray(Name, Width, Height, ArrayCount, Format); -} - -void ColorBuffer::GenerateMipMaps(CommandContext& BaseContext) -{ - if (m_NumMipMaps == 0) - return; - - ComputeContext& Context = BaseContext.GetComputeContext(); - - Context.SetRootSignature(Graphics::g_CommonRS); - - Context.TransitionResource(*this, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.SetDynamicDescriptor(1, 0, m_SRVHandle); - - for (uint32_t TopMip = 0; TopMip < m_NumMipMaps; ) - { - uint32_t SrcWidth = m_Width >> TopMip; - uint32_t SrcHeight = m_Height >> TopMip; - uint32_t DstWidth = SrcWidth >> 1; - uint32_t DstHeight = SrcHeight >> 1; - - // Determine if the first downsample is more than 2:1. This happens whenever - // the source width or height is odd. - uint32_t NonPowerOfTwo = (SrcWidth & 1) | (SrcHeight & 1) << 1; - if (m_Format == DXGI_FORMAT_R8G8B8A8_UNORM_SRGB) - Context.SetPipelineState(Graphics::g_GenerateMipsGammaPSO[NonPowerOfTwo]); - else - Context.SetPipelineState(Graphics::g_GenerateMipsLinearPSO[NonPowerOfTwo]); - - // We can downsample up to four times, but if the ratio between levels is not - // exactly 2:1, we have to shift our blend weights, which gets complicated or - // expensive. Maybe we can update the code later to compute sample weights for - // each successive downsample. We use _BitScanForward to count number of zeros - // in the low bits. Zeros indicate we can divide by two without truncating. - uint32_t AdditionalMips; - _BitScanForward((unsigned long*)&AdditionalMips, - (DstWidth == 1 ? DstHeight : DstWidth) | (DstHeight == 1 ? DstWidth : DstHeight)); - uint32_t NumMips = 1 + (AdditionalMips > 3 ? 3 : AdditionalMips); - if (TopMip + NumMips > m_NumMipMaps) - NumMips = m_NumMipMaps - TopMip; - - // These are clamped to 1 after computing additional mips because clamped - // dimensions should not limit us from downsampling multiple times. (E.g. - // 16x1 -> 8x1 -> 4x1 -> 2x1 -> 1x1.) - if (DstWidth == 0) - DstWidth = 1; - if (DstHeight == 0) - DstHeight = 1; - - Context.SetConstants(0, TopMip, NumMips, 1.0f / DstWidth, 1.0f / DstHeight); - Context.SetDynamicDescriptors(2, 0, NumMips, m_UAVHandle + TopMip + 1); - Context.Dispatch2D(DstWidth, DstHeight); - - Context.InsertUAVBarrier(*this); - - TopMip += NumMips; - } - - Context.TransitionResource(*this, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE | - D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/ColorBuffer.h b/xess/samples/xess_demo/MiniEngine/Core/ColorBuffer.h deleted file mode 100644 index 7a0ae22..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/ColorBuffer.h +++ /dev/null @@ -1,116 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "PixelBuffer.h" -#include "Color.h" -#include "GpuBuffer.h" - -class EsramAllocator; - -class ColorBuffer : public PixelBuffer -{ -public: - ColorBuffer( Color ClearColor = Color(0.0f, 0.0f, 0.0f, 0.0f) ) - : m_ClearColor(ClearColor), m_NumMipMaps(0), m_FragmentCount(1), m_SampleCount(1), m_ColorBufferId(0) - { - m_RTVHandle.ptr = D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN; - m_SRVHandle.ptr = D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN; - for (int i = 0; i < _countof(m_UAVHandle); ++i) - m_UAVHandle[i].ptr = D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN; - } - - // Create a color buffer from a swap chain buffer. Unordered access is restricted. - void CreateFromSwapChain( const std::wstring& Name, ID3D12Resource* BaseResource ); - - // Create a color buffer. If an address is supplied, memory will not be allocated. - // The vmem address allows you to alias buffers (which can be especially useful for - // reusing ESRAM across a frame.) - void Create(const std::wstring& Name, uint32_t Width, uint32_t Height, uint32_t NumMips, - DXGI_FORMAT Format, D3D12_GPU_VIRTUAL_ADDRESS VidMemPtr = D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN); - - // Create a color buffer. Memory will be allocated in ESRAM (on Xbox One). On Windows, - // this functions the same as Create() without a video address. - void Create(const std::wstring& Name, uint32_t Width, uint32_t Height, uint32_t NumMips, - DXGI_FORMAT Format, EsramAllocator& Allocator); - - // Create a color buffer. If an address is supplied, memory will not be allocated. - // The vmem address allows you to alias buffers (which can be especially useful for - // reusing ESRAM across a frame.) - void CreateArray(const std::wstring& Name, uint32_t Width, uint32_t Height, uint32_t ArrayCount, - DXGI_FORMAT Format, D3D12_GPU_VIRTUAL_ADDRESS VidMemPtr = D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN); - - // Create a color buffer. Memory will be allocated in ESRAM (on Xbox One). On Windows, - // this functions the same as Create() without a video address. - void CreateArray(const std::wstring& Name, uint32_t Width, uint32_t Height, uint32_t ArrayCount, - DXGI_FORMAT Format, EsramAllocator& Allocator); - - // Get pre-created CPU-visible descriptor handles - const D3D12_CPU_DESCRIPTOR_HANDLE& GetSRV(void) const { return m_SRVHandle; } - const D3D12_CPU_DESCRIPTOR_HANDLE& GetRTV(void) const { return m_RTVHandle; } - const D3D12_CPU_DESCRIPTOR_HANDLE& GetUAV(void) const { return m_UAVHandle[0]; } - - void SetClearColor( Color ClearColor ) { m_ClearColor = ClearColor; } - - void SetMsaaMode( uint32_t NumColorSamples, uint32_t NumCoverageSamples ) - { - ASSERT(NumCoverageSamples >= NumColorSamples); - m_FragmentCount = NumColorSamples; - m_SampleCount = NumCoverageSamples; - } - - Color GetClearColor(void) const { return m_ClearColor; } - - // This will work for all texture sizes, but it's recommended for speed and quality - // that you use dimensions with powers of two (but not necessarily square.) Pass - // 0 for ArrayCount to reserve space for mips at creation time. - void GenerateMipMaps(CommandContext& Context); - - // unique id for each buffer - uint64_t GetBufferId() { return m_ColorBufferId; } - -protected: - - D3D12_RESOURCE_FLAGS CombineResourceFlags( void ) const - { - D3D12_RESOURCE_FLAGS Flags = D3D12_RESOURCE_FLAG_NONE; - - if (Flags == D3D12_RESOURCE_FLAG_NONE && m_FragmentCount == 1) - Flags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; - - return D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET | Flags; - } - - // Compute the number of texture levels needed to reduce to 1x1. This uses - // _BitScanReverse to find the highest set bit. Each dimension reduces by - // half and truncates bits. The dimension 256 (0x100) has 9 mip levels, same - // as the dimension 511 (0x1FF). - static inline uint32_t ComputeNumMips(uint32_t Width, uint32_t Height) - { - uint32_t HighBit; - _BitScanReverse((unsigned long*)&HighBit, Width | Height); - return HighBit + 1; - } - - void CreateDerivedViews(ID3D12Device* Device, DXGI_FORMAT Format, uint32_t ArraySize, uint32_t NumMips = 1); - - Color m_ClearColor; - D3D12_CPU_DESCRIPTOR_HANDLE m_SRVHandle; - D3D12_CPU_DESCRIPTOR_HANDLE m_RTVHandle; - D3D12_CPU_DESCRIPTOR_HANDLE m_UAVHandle[12]; - uint32_t m_NumMipMaps; // number of texture sublevels - uint32_t m_FragmentCount; - uint32_t m_SampleCount; - uint64_t m_ColorBufferId; // unique id from 1 -}; diff --git a/xess/samples/xess_demo/MiniEngine/Core/CommandAllocatorPool.cpp b/xess/samples/xess_demo/MiniEngine/Core/CommandAllocatorPool.cpp deleted file mode 100644 index 0a9a188..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/CommandAllocatorPool.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "CommandAllocatorPool.h" - -CommandAllocatorPool::CommandAllocatorPool(D3D12_COMMAND_LIST_TYPE Type) : - m_cCommandListType(Type), - m_Device(nullptr) -{ -} - -CommandAllocatorPool::~CommandAllocatorPool() -{ - Shutdown(); -} - -void CommandAllocatorPool::Create(ID3D12Device * pDevice) -{ - m_Device = pDevice; -} - -void CommandAllocatorPool::Shutdown() -{ - for (size_t i = 0; i < m_AllocatorPool.size(); ++i) - m_AllocatorPool[i]->Release(); - - m_AllocatorPool.clear(); -} - -ID3D12CommandAllocator * CommandAllocatorPool::RequestAllocator(uint64_t CompletedFenceValue) -{ - std::lock_guard LockGuard(m_AllocatorMutex); - - ID3D12CommandAllocator* pAllocator = nullptr; - - if (!m_ReadyAllocators.empty()) - { - std::pair& AllocatorPair = m_ReadyAllocators.front(); - - if (AllocatorPair.first <= CompletedFenceValue) - { - pAllocator = AllocatorPair.second; - ASSERT_SUCCEEDED(pAllocator->Reset()); - m_ReadyAllocators.pop(); - } - } - - // If no allocator's were ready to be reused, create a new one - if (pAllocator == nullptr) - { - ASSERT_SUCCEEDED(m_Device->CreateCommandAllocator(m_cCommandListType, MY_IID_PPV_ARGS(&pAllocator))); - wchar_t AllocatorName[32]; - swprintf(AllocatorName, 32, L"CommandAllocator %zu", m_AllocatorPool.size()); - pAllocator->SetName(AllocatorName); - m_AllocatorPool.push_back(pAllocator); - } - - return pAllocator; -} - -void CommandAllocatorPool::DiscardAllocator(uint64_t FenceValue, ID3D12CommandAllocator * Allocator) -{ - std::lock_guard LockGuard(m_AllocatorMutex); - - // That fence value indicates we are free to reset the allocator - m_ReadyAllocators.push(std::make_pair(FenceValue, Allocator)); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/CommandAllocatorPool.h b/xess/samples/xess_demo/MiniEngine/Core/CommandAllocatorPool.h deleted file mode 100644 index 4fb2959..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/CommandAllocatorPool.h +++ /dev/null @@ -1,42 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include -#include -#include -#include - -class CommandAllocatorPool -{ -public: - CommandAllocatorPool(D3D12_COMMAND_LIST_TYPE Type); - ~CommandAllocatorPool(); - - void Create(ID3D12Device* pDevice); - void Shutdown(); - - ID3D12CommandAllocator* RequestAllocator(uint64_t CompletedFenceValue); - void DiscardAllocator(uint64_t FenceValue, ID3D12CommandAllocator* Allocator); - - inline size_t Size() { return m_AllocatorPool.size(); } - -private: - const D3D12_COMMAND_LIST_TYPE m_cCommandListType; - - ID3D12Device* m_Device; - std::vector m_AllocatorPool; - std::queue> m_ReadyAllocators; - std::mutex m_AllocatorMutex; -}; diff --git a/xess/samples/xess_demo/MiniEngine/Core/CommandContext.cpp b/xess/samples/xess_demo/MiniEngine/Core/CommandContext.cpp deleted file mode 100644 index 8563a0c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/CommandContext.cpp +++ /dev/null @@ -1,628 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "CommandContext.h" -#include "ColorBuffer.h" -#include "DepthBuffer.h" -#include "GraphicsCore.h" -#include "DescriptorHeap.h" -#include "EngineProfiling.h" -#include "UploadBuffer.h" -#include "ReadbackBuffer.h" - -#pragma warning(push) -#pragma warning(disable:4100) // unreferenced formal parameters in PIXCopyEventArguments() (WinPixEventRuntime.1.0.200127001) -#include -#pragma warning(pop) - -using namespace Graphics; - - -void ContextManager::DestroyAllContexts(void) -{ - for (uint32_t i = 0; i < 4; ++i) - sm_ContextPool[i].clear(); -} - -CommandContext* ContextManager::AllocateContext(D3D12_COMMAND_LIST_TYPE Type) -{ - std::lock_guard LockGuard(sm_ContextAllocationMutex); - - auto& AvailableContexts = sm_AvailableContexts[Type]; - - CommandContext* ret = nullptr; - if (AvailableContexts.empty()) - { - ret = new CommandContext(Type); - sm_ContextPool[Type].emplace_back(ret); - ret->Initialize(); - } - else - { - ret = AvailableContexts.front(); - AvailableContexts.pop(); - ret->Reset(); - } - ASSERT(ret != nullptr); - - ASSERT(ret->m_Type == Type); - - return ret; -} - -void ContextManager::FreeContext(CommandContext* UsedContext) -{ - ASSERT(UsedContext != nullptr); - std::lock_guard LockGuard(sm_ContextAllocationMutex); - sm_AvailableContexts[UsedContext->m_Type].push(UsedContext); -} - -void CommandContext::DestroyAllContexts(void) -{ - LinearAllocator::DestroyAll(); - DynamicDescriptorHeap::DestroyAll(); - g_ContextManager.DestroyAllContexts(); -} - -CommandContext& CommandContext::Begin( const std::wstring ID ) -{ - CommandContext* NewContext = g_ContextManager.AllocateContext(D3D12_COMMAND_LIST_TYPE_DIRECT); - NewContext->SetID(ID); - if (ID.length() > 0) - EngineProfiling::BeginBlock(ID, NewContext); - return *NewContext; -} - -ComputeContext& ComputeContext::Begin(const std::wstring& ID, bool Async) -{ - ComputeContext& NewContext = g_ContextManager.AllocateContext( - Async ? D3D12_COMMAND_LIST_TYPE_COMPUTE : D3D12_COMMAND_LIST_TYPE_DIRECT)->GetComputeContext(); - NewContext.SetID(ID); - if (ID.length() > 0) - EngineProfiling::BeginBlock(ID, &NewContext); - return NewContext; -} - -uint64_t CommandContext::Flush(bool WaitForCompletion) -{ - FlushResourceBarriers(); - - ASSERT(m_CurrentAllocator != nullptr); - - uint64_t FenceValue = g_CommandManager.GetQueue(m_Type).ExecuteCommandList(m_CommandList); - - if (WaitForCompletion) - g_CommandManager.WaitForFence(FenceValue); - - // - // Reset the command list and restore previous state - // - - m_CommandList->Reset(m_CurrentAllocator, nullptr); - - if (m_CurGraphicsRootSignature) - { - m_CommandList->SetGraphicsRootSignature(m_CurGraphicsRootSignature); - } - if (m_CurComputeRootSignature) - { - m_CommandList->SetComputeRootSignature(m_CurComputeRootSignature); - } - if (m_CurPipelineState) - { - m_CommandList->SetPipelineState(m_CurPipelineState); - } - - BindDescriptorHeaps(); - - return FenceValue; -} - -uint64_t CommandContext::Finish( bool WaitForCompletion ) -{ - ASSERT(m_Type == D3D12_COMMAND_LIST_TYPE_DIRECT || m_Type == D3D12_COMMAND_LIST_TYPE_COMPUTE); - - FlushResourceBarriers(); - - if (m_ID.length() > 0) - EngineProfiling::EndBlock(this); - - ASSERT(m_CurrentAllocator != nullptr); - - CommandQueue& Queue = g_CommandManager.GetQueue(m_Type); - - uint64_t FenceValue = Queue.ExecuteCommandList(m_CommandList); - Queue.DiscardAllocator(FenceValue, m_CurrentAllocator); - m_CurrentAllocator = nullptr; - - m_CpuLinearAllocator.CleanupUsedPages(FenceValue); - m_GpuLinearAllocator.CleanupUsedPages(FenceValue); - m_DynamicViewDescriptorHeap.CleanupUsedHeaps(FenceValue); - m_DynamicSamplerDescriptorHeap.CleanupUsedHeaps(FenceValue); - - if (WaitForCompletion) - g_CommandManager.WaitForFence(FenceValue); - - g_ContextManager.FreeContext(this); - - return FenceValue; -} - -CommandContext::CommandContext(D3D12_COMMAND_LIST_TYPE Type) : - m_Type(Type), - m_DynamicViewDescriptorHeap(*this, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV), - m_DynamicSamplerDescriptorHeap(*this, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER), - m_CpuLinearAllocator(kCpuWritable), - m_GpuLinearAllocator(kGpuExclusive) -{ - m_OwningManager = nullptr; - m_CommandList = nullptr; - m_CurrentAllocator = nullptr; - ZeroMemory(m_CurrentDescriptorHeaps, sizeof(m_CurrentDescriptorHeaps)); - - m_CurGraphicsRootSignature = nullptr; - m_CurComputeRootSignature = nullptr; - m_CurPipelineState = nullptr; - m_NumBarriersToFlush = 0; -} - -CommandContext::~CommandContext( void ) -{ - if (m_CommandList != nullptr) - m_CommandList->Release(); -} - -void CommandContext::Initialize(void) -{ - g_CommandManager.CreateNewCommandList(m_Type, &m_CommandList, &m_CurrentAllocator); -} - -void CommandContext::Reset( void ) -{ - // We only call Reset() on previously freed contexts. The command list persists, but we must - // request a new allocator. - ASSERT(m_CommandList != nullptr && m_CurrentAllocator == nullptr); - m_CurrentAllocator = g_CommandManager.GetQueue(m_Type).RequestAllocator(); - m_CommandList->Reset(m_CurrentAllocator, nullptr); - - m_CurGraphicsRootSignature = nullptr; - m_CurComputeRootSignature = nullptr; - m_CurPipelineState = nullptr; - m_NumBarriersToFlush = 0; - - BindDescriptorHeaps(); -} - -void CommandContext::BindDescriptorHeaps( void ) -{ - UINT NonNullHeaps = 0; - ID3D12DescriptorHeap* HeapsToBind[D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES]; - for (UINT i = 0; i < D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES; ++i) - { - ID3D12DescriptorHeap* HeapIter = m_CurrentDescriptorHeaps[i]; - if (HeapIter != nullptr) - HeapsToBind[NonNullHeaps++] = HeapIter; - } - - if (NonNullHeaps > 0) - m_CommandList->SetDescriptorHeaps(NonNullHeaps, HeapsToBind); -} - -void GraphicsContext::SetRenderTargets( UINT NumRTVs, const D3D12_CPU_DESCRIPTOR_HANDLE RTVs[], D3D12_CPU_DESCRIPTOR_HANDLE DSV ) -{ - m_CommandList->OMSetRenderTargets( NumRTVs, RTVs, FALSE, &DSV ); -} - -void GraphicsContext::SetRenderTargets(UINT NumRTVs, const D3D12_CPU_DESCRIPTOR_HANDLE RTVs[]) -{ - m_CommandList->OMSetRenderTargets(NumRTVs, RTVs, FALSE, nullptr); -} - -void GraphicsContext::BeginQuery(ID3D12QueryHeap* QueryHeap, D3D12_QUERY_TYPE Type, UINT HeapIndex) -{ - m_CommandList->BeginQuery(QueryHeap, Type, HeapIndex); -} - -void GraphicsContext::EndQuery(ID3D12QueryHeap* QueryHeap, D3D12_QUERY_TYPE Type, UINT HeapIndex) -{ - m_CommandList->EndQuery(QueryHeap, Type, HeapIndex); -} - -void GraphicsContext::ResolveQueryData(ID3D12QueryHeap* QueryHeap, D3D12_QUERY_TYPE Type, UINT StartIndex, UINT NumQueries, ID3D12Resource* DestinationBuffer, UINT64 DestinationBufferOffset) -{ - m_CommandList->ResolveQueryData(QueryHeap, Type, StartIndex, NumQueries, DestinationBuffer, DestinationBufferOffset); -} - -void GraphicsContext::ClearUAV( GpuBuffer& Target ) -{ - FlushResourceBarriers(); - - // After binding a UAV, we can get a GPU handle that is required to clear it as a UAV (because it essentially runs - // a shader to set all of the values). - D3D12_GPU_DESCRIPTOR_HANDLE GpuVisibleHandle = m_DynamicViewDescriptorHeap.UploadDirect(Target.GetUAV()); - const UINT ClearColor[4] = {}; - m_CommandList->ClearUnorderedAccessViewUint(GpuVisibleHandle, Target.GetUAV(), Target.GetResource(), ClearColor, 0, nullptr); -} - -void ComputeContext::ClearUAV( GpuBuffer& Target ) -{ - FlushResourceBarriers(); - - // After binding a UAV, we can get a GPU handle that is required to clear it as a UAV (because it essentially runs - // a shader to set all of the values). - D3D12_GPU_DESCRIPTOR_HANDLE GpuVisibleHandle = m_DynamicViewDescriptorHeap.UploadDirect(Target.GetUAV()); - const UINT ClearColor[4] = {}; - m_CommandList->ClearUnorderedAccessViewUint(GpuVisibleHandle, Target.GetUAV(), Target.GetResource(), ClearColor, 0, nullptr); -} - -void GraphicsContext::ClearUAV( ColorBuffer& Target ) -{ - FlushResourceBarriers(); - - // After binding a UAV, we can get a GPU handle that is required to clear it as a UAV (because it essentially runs - // a shader to set all of the values). - D3D12_GPU_DESCRIPTOR_HANDLE GpuVisibleHandle = m_DynamicViewDescriptorHeap.UploadDirect(Target.GetUAV()); - CD3DX12_RECT ClearRect(0, 0, (LONG)Target.GetWidth(), (LONG)Target.GetHeight()); - - //TODO: My Nvidia card is not clearing UAVs with either Float or Uint variants. - const float* ClearColor = Target.GetClearColor().GetPtr(); - m_CommandList->ClearUnorderedAccessViewFloat(GpuVisibleHandle, Target.GetUAV(), Target.GetResource(), ClearColor, 1, &ClearRect); -} - -void ComputeContext::ClearUAV( ColorBuffer& Target ) -{ - FlushResourceBarriers(); - - // After binding a UAV, we can get a GPU handle that is required to clear it as a UAV (because it essentially runs - // a shader to set all of the values). - D3D12_GPU_DESCRIPTOR_HANDLE GpuVisibleHandle = m_DynamicViewDescriptorHeap.UploadDirect(Target.GetUAV()); - CD3DX12_RECT ClearRect(0, 0, (LONG)Target.GetWidth(), (LONG)Target.GetHeight()); - - //TODO: My Nvidia card is not clearing UAVs with either Float or Uint variants. - const float* ClearColor = Target.GetClearColor().GetPtr(); - m_CommandList->ClearUnorderedAccessViewFloat(GpuVisibleHandle, Target.GetUAV(), Target.GetResource(), ClearColor, 1, &ClearRect); -} - -void ComputeContext::InvalidateStates() -{ - m_CurComputeRootSignature = nullptr; - m_CurPipelineState = nullptr; - - BindDescriptorHeaps(); -} - -void GraphicsContext::ClearColor( ColorBuffer& Target, D3D12_RECT* Rect ) -{ - FlushResourceBarriers(); - m_CommandList->ClearRenderTargetView(Target.GetRTV(), Target.GetClearColor().GetPtr(), (Rect == nullptr) ? 0 : 1, Rect); -} - -void GraphicsContext::ClearColor(ColorBuffer& Target, float Colour[4], D3D12_RECT* Rect) -{ - FlushResourceBarriers(); - m_CommandList->ClearRenderTargetView(Target.GetRTV(), Colour, (Rect == nullptr) ? 0 : 1, Rect); -} - -void GraphicsContext::ClearDepth( DepthBuffer& Target ) -{ - FlushResourceBarriers(); - m_CommandList->ClearDepthStencilView(Target.GetDSV(), D3D12_CLEAR_FLAG_DEPTH, Target.GetClearDepth(), Target.GetClearStencil(), 0, nullptr ); -} - -void GraphicsContext::ClearStencil( DepthBuffer& Target ) -{ - FlushResourceBarriers(); - m_CommandList->ClearDepthStencilView(Target.GetDSV(), D3D12_CLEAR_FLAG_STENCIL, Target.GetClearDepth(), Target.GetClearStencil(), 0, nullptr); -} - -void GraphicsContext::ClearDepthAndStencil( DepthBuffer& Target ) -{ - FlushResourceBarriers(); - m_CommandList->ClearDepthStencilView(Target.GetDSV(), D3D12_CLEAR_FLAG_DEPTH | D3D12_CLEAR_FLAG_STENCIL, Target.GetClearDepth(), Target.GetClearStencil(), 0, nullptr); -} - -void GraphicsContext::SetViewportAndScissor( const D3D12_VIEWPORT& vp, const D3D12_RECT& rect ) -{ - ASSERT(rect.left < rect.right && rect.top < rect.bottom); - m_CommandList->RSSetViewports( 1, &vp ); - m_CommandList->RSSetScissorRects( 1, &rect ); -} - -void GraphicsContext::SetViewport( const D3D12_VIEWPORT& vp ) -{ - m_CommandList->RSSetViewports( 1, &vp ); -} - -void GraphicsContext::SetViewport( FLOAT x, FLOAT y, FLOAT w, FLOAT h, FLOAT minDepth, FLOAT maxDepth ) -{ - D3D12_VIEWPORT vp; - vp.Width = w; - vp.Height = h; - vp.MinDepth = minDepth; - vp.MaxDepth = maxDepth; - vp.TopLeftX = x; - vp.TopLeftY = y; - m_CommandList->RSSetViewports( 1, &vp ); -} - -void GraphicsContext::SetScissor( const D3D12_RECT& rect ) -{ - ASSERT(rect.left < rect.right && rect.top < rect.bottom); - m_CommandList->RSSetScissorRects( 1, &rect ); -} - -void CommandContext::TransitionResource(GpuResource& Resource, D3D12_RESOURCE_STATES NewState, bool FlushImmediate) -{ - D3D12_RESOURCE_STATES OldState = Resource.m_UsageState; - - if (m_Type == D3D12_COMMAND_LIST_TYPE_COMPUTE) - { - ASSERT((OldState & VALID_COMPUTE_QUEUE_RESOURCE_STATES) == OldState); - ASSERT((NewState & VALID_COMPUTE_QUEUE_RESOURCE_STATES) == NewState); - } - - if (OldState != NewState) - { - ASSERT(m_NumBarriersToFlush < 16, "Exceeded arbitrary limit on buffered barriers"); - D3D12_RESOURCE_BARRIER& BarrierDesc = m_ResourceBarrierBuffer[m_NumBarriersToFlush++]; - - BarrierDesc.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; - BarrierDesc.Transition.pResource = Resource.GetResource(); - BarrierDesc.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES; - BarrierDesc.Transition.StateBefore = OldState; - BarrierDesc.Transition.StateAfter = NewState; - - // Check to see if we already started the transition - if (NewState == Resource.m_TransitioningState) - { - BarrierDesc.Flags = D3D12_RESOURCE_BARRIER_FLAG_END_ONLY; - Resource.m_TransitioningState = (D3D12_RESOURCE_STATES)-1; - } - else - BarrierDesc.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; - - Resource.m_UsageState = NewState; - } - else if (NewState == D3D12_RESOURCE_STATE_UNORDERED_ACCESS) - InsertUAVBarrier(Resource, FlushImmediate); - - if (FlushImmediate || m_NumBarriersToFlush == 16) - FlushResourceBarriers(); -} - -void CommandContext::BeginResourceTransition(GpuResource& Resource, D3D12_RESOURCE_STATES NewState, bool FlushImmediate) -{ - // If it's already transitioning, finish that transition - if (Resource.m_TransitioningState != (D3D12_RESOURCE_STATES)-1) - TransitionResource(Resource, Resource.m_TransitioningState); - - D3D12_RESOURCE_STATES OldState = Resource.m_UsageState; - - if (OldState != NewState) - { - ASSERT(m_NumBarriersToFlush < 16, "Exceeded arbitrary limit on buffered barriers"); - D3D12_RESOURCE_BARRIER& BarrierDesc = m_ResourceBarrierBuffer[m_NumBarriersToFlush++]; - - BarrierDesc.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; - BarrierDesc.Transition.pResource = Resource.GetResource(); - BarrierDesc.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES; - BarrierDesc.Transition.StateBefore = OldState; - BarrierDesc.Transition.StateAfter = NewState; - - BarrierDesc.Flags = D3D12_RESOURCE_BARRIER_FLAG_BEGIN_ONLY; - - Resource.m_TransitioningState = NewState; - } - - if (FlushImmediate || m_NumBarriersToFlush == 16) - FlushResourceBarriers(); -} - -void CommandContext::InsertUAVBarrier(GpuResource& Resource, bool FlushImmediate) -{ - ASSERT(m_NumBarriersToFlush < 16, "Exceeded arbitrary limit on buffered barriers"); - D3D12_RESOURCE_BARRIER& BarrierDesc = m_ResourceBarrierBuffer[m_NumBarriersToFlush++]; - - BarrierDesc.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV; - BarrierDesc.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; - BarrierDesc.UAV.pResource = Resource.GetResource(); - - if (FlushImmediate) - FlushResourceBarriers(); -} - -void CommandContext::InsertAliasBarrier(GpuResource& Before, GpuResource& After, bool FlushImmediate) -{ - ASSERT(m_NumBarriersToFlush < 16, "Exceeded arbitrary limit on buffered barriers"); - D3D12_RESOURCE_BARRIER& BarrierDesc = m_ResourceBarrierBuffer[m_NumBarriersToFlush++]; - - BarrierDesc.Type = D3D12_RESOURCE_BARRIER_TYPE_ALIASING; - BarrierDesc.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; - BarrierDesc.Aliasing.pResourceBefore = Before.GetResource(); - BarrierDesc.Aliasing.pResourceAfter = After.GetResource(); - - if (FlushImmediate) - FlushResourceBarriers(); -} - -void CommandContext::WriteBuffer( GpuResource& Dest, size_t DestOffset, const void* BufferData, size_t NumBytes ) -{ - ASSERT(BufferData != nullptr && Math::IsAligned(BufferData, 16)); - DynAlloc TempSpace = m_CpuLinearAllocator.Allocate( NumBytes, 512 ); - SIMDMemCopy(TempSpace.DataPtr, BufferData, Math::DivideByMultiple(NumBytes, 16)); - CopyBufferRegion(Dest, DestOffset, TempSpace.Buffer, TempSpace.Offset, NumBytes ); -} - -void CommandContext::FillBuffer( GpuResource& Dest, size_t DestOffset, DWParam Value, size_t NumBytes ) -{ - DynAlloc TempSpace = m_CpuLinearAllocator.Allocate( NumBytes, 512 ); - __m128 VectorValue = _mm_set1_ps(Value.Float); - SIMDMemFill(TempSpace.DataPtr, VectorValue, Math::DivideByMultiple(NumBytes, 16)); - CopyBufferRegion(Dest, DestOffset, TempSpace.Buffer, TempSpace.Offset, NumBytes ); -} - -void CommandContext::InitializeTexture( GpuResource& Dest, UINT NumSubresources, D3D12_SUBRESOURCE_DATA SubData[] ) -{ - UINT64 uploadBufferSize = GetRequiredIntermediateSize(Dest.GetResource(), 0, NumSubresources); - - CommandContext& InitContext = CommandContext::Begin(); - - // copy data to the intermediate upload heap and then schedule a copy from the upload heap to the default texture - DynAlloc mem = InitContext.ReserveUploadMemory(uploadBufferSize); - UpdateSubresources(InitContext.m_CommandList, Dest.GetResource(), mem.Buffer.GetResource(), 0, 0, NumSubresources, SubData); - InitContext.TransitionResource(Dest, D3D12_RESOURCE_STATE_GENERIC_READ); - - // Execute the command list and wait for it to finish so we can release the upload buffer - InitContext.Finish(true); -} - -void CommandContext::CopySubresource(GpuResource& Dest, UINT DestSubIndex, GpuResource& Src, UINT SrcSubIndex) -{ - FlushResourceBarriers(); - - D3D12_TEXTURE_COPY_LOCATION DestLocation = - { - Dest.GetResource(), - D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, - DestSubIndex - }; - - D3D12_TEXTURE_COPY_LOCATION SrcLocation = - { - Src.GetResource(), - D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, - SrcSubIndex - }; - - m_CommandList->CopyTextureRegion(&DestLocation, 0, 0, 0, &SrcLocation, nullptr); -} - -void CommandContext::InitializeTextureArraySlice(GpuResource& Dest, UINT SliceIndex, GpuResource& Src) -{ - CommandContext& Context = CommandContext::Begin(); - - Context.TransitionResource(Dest, D3D12_RESOURCE_STATE_COPY_DEST); - Context.FlushResourceBarriers(); - - const D3D12_RESOURCE_DESC& DestDesc = Dest.GetResource()->GetDesc(); - const D3D12_RESOURCE_DESC& SrcDesc = Src.GetResource()->GetDesc(); - - ASSERT(SliceIndex < DestDesc.DepthOrArraySize && - SrcDesc.DepthOrArraySize == 1 && - DestDesc.Width == SrcDesc.Width && - DestDesc.Height == SrcDesc.Height && - DestDesc.MipLevels <= SrcDesc.MipLevels - ); - - UINT SubResourceIndex = SliceIndex * DestDesc.MipLevels; - - for (UINT i = 0; i < DestDesc.MipLevels; ++i) - { - D3D12_TEXTURE_COPY_LOCATION destCopyLocation = - { - Dest.GetResource(), - D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, - SubResourceIndex + i - }; - - D3D12_TEXTURE_COPY_LOCATION srcCopyLocation = - { - Src.GetResource(), - D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX, - i - }; - - Context.m_CommandList->CopyTextureRegion(&destCopyLocation, 0, 0, 0, &srcCopyLocation, nullptr); - } - - Context.TransitionResource(Dest, D3D12_RESOURCE_STATE_GENERIC_READ); - Context.Finish(true); -} - -uint32_t CommandContext::ReadbackTexture(ReadbackBuffer& DstBuffer, PixelBuffer& SrcBuffer) -{ - uint64_t CopySize = 0; - - // The footprint may depend on the device of the resource, but we assume there is only one device. - D3D12_PLACED_SUBRESOURCE_FOOTPRINT PlacedFootprint; - g_Device->GetCopyableFootprints(&SrcBuffer.GetResource()->GetDesc(), 0, 1, 0, - &PlacedFootprint, nullptr, nullptr, &CopySize); - - DstBuffer.Create(L"Readback", (uint32_t)CopySize, 1); - - TransitionResource(SrcBuffer, D3D12_RESOURCE_STATE_COPY_SOURCE, true); - - m_CommandList->CopyTextureRegion( - &CD3DX12_TEXTURE_COPY_LOCATION(DstBuffer.GetResource(), PlacedFootprint), 0, 0, 0, - &CD3DX12_TEXTURE_COPY_LOCATION(SrcBuffer.GetResource(), 0), nullptr); - - return PlacedFootprint.Footprint.RowPitch; -} - -void CommandContext::InitializeBuffer( GpuBuffer& Dest, const void* BufferData, size_t NumBytes, size_t DestOffset) -{ - CommandContext& InitContext = CommandContext::Begin(); - - DynAlloc mem = InitContext.ReserveUploadMemory(NumBytes); - SIMDMemCopy(mem.DataPtr, BufferData, Math::DivideByMultiple(NumBytes, 16)); - - // copy data to the intermediate upload heap and then schedule a copy from the upload heap to the default texture - InitContext.TransitionResource(Dest, D3D12_RESOURCE_STATE_COPY_DEST, true); - InitContext.m_CommandList->CopyBufferRegion(Dest.GetResource(), DestOffset, mem.Buffer.GetResource(), 0, NumBytes); - InitContext.TransitionResource(Dest, D3D12_RESOURCE_STATE_GENERIC_READ, true); - - // Execute the command list and wait for it to finish so we can release the upload buffer - InitContext.Finish(true); -} - -void CommandContext::InitializeBuffer( GpuBuffer& Dest, const UploadBuffer& Src, size_t SrcOffset, size_t NumBytes, size_t DestOffset ) -{ - CommandContext& InitContext = CommandContext::Begin(); - - size_t MaxBytes = std::min(Dest.GetBufferSize() - DestOffset, Src.GetBufferSize() - SrcOffset); - NumBytes = std::min(MaxBytes, NumBytes); - - // copy data to the intermediate upload heap and then schedule a copy from the upload heap to the default texture - InitContext.TransitionResource(Dest, D3D12_RESOURCE_STATE_COPY_DEST, true); - InitContext.m_CommandList->CopyBufferRegion(Dest.GetResource(), DestOffset, (ID3D12Resource*)Src.GetResource(), SrcOffset, NumBytes); - InitContext.TransitionResource(Dest, D3D12_RESOURCE_STATE_GENERIC_READ, true); - - // Execute the command list and wait for it to finish so we can release the upload buffer - InitContext.Finish(true); -} - -void CommandContext::PIXBeginEvent(const wchar_t* label) -{ -#ifdef RELEASE - (label); -#else - ::PIXBeginEvent(m_CommandList, 0, label); -#endif -} - -void CommandContext::PIXEndEvent(void) -{ -#ifndef RELEASE - ::PIXEndEvent(m_CommandList); -#endif -} - -void CommandContext::PIXSetMarker(const wchar_t* label) -{ -#ifdef RELEASE - (label); -#else - ::PIXSetMarker(m_CommandList, 0, label); -#endif -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/CommandContext.h b/xess/samples/xess_demo/MiniEngine/Core/CommandContext.h deleted file mode 100644 index b3cccd8..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/CommandContext.h +++ /dev/null @@ -1,796 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "pch.h" -#include "CommandListManager.h" -#include "Color.h" -#include "PipelineState.h" -#include "RootSignature.h" -#include "GpuBuffer.h" -#include "Texture.h" -#include "PixelBuffer.h" -#include "DynamicDescriptorHeap.h" -#include "LinearAllocator.h" -#include "CommandSignature.h" -#include "GraphicsCore.h" -#include - -class ColorBuffer; -class DepthBuffer; -class Texture; -class GraphicsContext; -class ComputeContext; -class UploadBuffer; -class ReadbackBuffer; - -struct DWParam -{ - DWParam( FLOAT f ) : Float(f) {} - DWParam( UINT u ) : Uint(u) {} - DWParam( INT i ) : Int(i) {} - - void operator= ( FLOAT f ) { Float = f; } - void operator= ( UINT u ) { Uint = u; } - void operator= ( INT i ) { Int = i; } - - union - { - FLOAT Float; - UINT Uint; - INT Int; - }; -}; - -#define VALID_COMPUTE_QUEUE_RESOURCE_STATES \ - ( D3D12_RESOURCE_STATE_UNORDERED_ACCESS \ - | D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE \ - | D3D12_RESOURCE_STATE_COPY_DEST \ - | D3D12_RESOURCE_STATE_COPY_SOURCE ) - -class ContextManager -{ -public: - ContextManager(void) {} - - CommandContext* AllocateContext(D3D12_COMMAND_LIST_TYPE Type); - void FreeContext(CommandContext*); - void DestroyAllContexts(); - -private: - std::vector > sm_ContextPool[4]; - std::queue sm_AvailableContexts[4]; - std::mutex sm_ContextAllocationMutex; -}; - -struct NonCopyable -{ - NonCopyable() = default; - NonCopyable(const NonCopyable&) = delete; - NonCopyable & operator=(const NonCopyable&) = delete; -}; - -class CommandContext : NonCopyable -{ - friend ContextManager; -private: - - CommandContext(D3D12_COMMAND_LIST_TYPE Type); - - void Reset( void ); - -public: - - ~CommandContext(void); - - static void DestroyAllContexts(void); - - static CommandContext& Begin(const std::wstring ID = L""); - - // Flush existing commands to the GPU but keep the context alive - uint64_t Flush( bool WaitForCompletion = false ); - - // Flush existing commands and release the current context - uint64_t Finish( bool WaitForCompletion = false ); - - // Prepare to render by reserving a command list and command allocator - void Initialize(void); - - GraphicsContext& GetGraphicsContext() { - ASSERT(m_Type != D3D12_COMMAND_LIST_TYPE_COMPUTE, "Cannot convert async compute context to graphics"); - return reinterpret_cast(*this); - } - - ComputeContext& GetComputeContext() { - return reinterpret_cast(*this); - } - - ID3D12GraphicsCommandList* GetCommandList() { - return m_CommandList; - } - - void CopyBuffer( GpuResource& Dest, GpuResource& Src ); - void CopyBufferRegion( GpuResource& Dest, size_t DestOffset, GpuResource& Src, size_t SrcOffset, size_t NumBytes ); - void CopySubresource(GpuResource& Dest, UINT DestSubIndex, GpuResource& Src, UINT SrcSubIndex); - void CopyCounter(GpuResource& Dest, size_t DestOffset, StructuredBuffer& Src); - void CopyTextureRegion(GpuResource& Dest, UINT x, UINT y, UINT z, GpuResource& Source, RECT& rect); - void ResetCounter(StructuredBuffer& Buf, uint32_t Value = 0); - - // Creates a readback buffer of sufficient size, copies the texture into it, - // and returns row pitch in bytes. - uint32_t ReadbackTexture(ReadbackBuffer& DstBuffer, PixelBuffer& SrcBuffer); - - DynAlloc ReserveUploadMemory(size_t SizeInBytes) - { - return m_CpuLinearAllocator.Allocate(SizeInBytes); - } - - static void InitializeTexture( GpuResource& Dest, UINT NumSubresources, D3D12_SUBRESOURCE_DATA SubData[] ); - static void InitializeBuffer( GpuBuffer& Dest, const void* Data, size_t NumBytes, size_t DestOffset = 0); - static void InitializeBuffer( GpuBuffer& Dest, const UploadBuffer& Src, size_t SrcOffset, size_t NumBytes = -1, size_t DestOffset = 0 ); - static void InitializeTextureArraySlice(GpuResource& Dest, UINT SliceIndex, GpuResource& Src); - - void WriteBuffer( GpuResource& Dest, size_t DestOffset, const void* Data, size_t NumBytes ); - void FillBuffer( GpuResource& Dest, size_t DestOffset, DWParam Value, size_t NumBytes ); - - void TransitionResource(GpuResource& Resource, D3D12_RESOURCE_STATES NewState, bool FlushImmediate = false); - void BeginResourceTransition(GpuResource& Resource, D3D12_RESOURCE_STATES NewState, bool FlushImmediate = false); - void InsertUAVBarrier(GpuResource& Resource, bool FlushImmediate = false); - void InsertAliasBarrier(GpuResource& Before, GpuResource& After, bool FlushImmediate = false); - inline void FlushResourceBarriers(void); - - void InsertTimeStamp( ID3D12QueryHeap* pQueryHeap, uint32_t QueryIdx ); - void ResolveTimeStamps( ID3D12Resource* pReadbackHeap, ID3D12QueryHeap* pQueryHeap, uint32_t NumQueries ); - void PIXBeginEvent(const wchar_t* label); - void PIXEndEvent(void); - void PIXSetMarker(const wchar_t* label); - - void SetDescriptorHeap( D3D12_DESCRIPTOR_HEAP_TYPE Type, ID3D12DescriptorHeap* HeapPtr ); - void SetDescriptorHeaps( UINT HeapCount, D3D12_DESCRIPTOR_HEAP_TYPE Type[], ID3D12DescriptorHeap* HeapPtrs[] ); - void SetPipelineState( const PSO& PSO ); - - void SetPredication(ID3D12Resource* Buffer, UINT64 BufferOffset, D3D12_PREDICATION_OP Op); - -protected: - - void BindDescriptorHeaps( void ); - - CommandListManager* m_OwningManager; - ID3D12GraphicsCommandList* m_CommandList; - ID3D12CommandAllocator* m_CurrentAllocator; - - ID3D12RootSignature* m_CurGraphicsRootSignature; - ID3D12RootSignature* m_CurComputeRootSignature; - ID3D12PipelineState* m_CurPipelineState; - - DynamicDescriptorHeap m_DynamicViewDescriptorHeap; // HEAP_TYPE_CBV_SRV_UAV - DynamicDescriptorHeap m_DynamicSamplerDescriptorHeap; // HEAP_TYPE_SAMPLER - - D3D12_RESOURCE_BARRIER m_ResourceBarrierBuffer[16]; - UINT m_NumBarriersToFlush; - - ID3D12DescriptorHeap* m_CurrentDescriptorHeaps[D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES]; - - LinearAllocator m_CpuLinearAllocator; - LinearAllocator m_GpuLinearAllocator; - - std::wstring m_ID; - void SetID(const std::wstring& ID) { m_ID = ID; } - - D3D12_COMMAND_LIST_TYPE m_Type; -}; - -class GraphicsContext : public CommandContext -{ -public: - - static GraphicsContext& Begin(const std::wstring& ID = L"") - { - return CommandContext::Begin(ID).GetGraphicsContext(); - } - - void ClearUAV( GpuBuffer& Target ); - void ClearUAV( ColorBuffer& Target ); - void ClearColor( ColorBuffer& Target, D3D12_RECT* Rect = nullptr); - void ClearColor(ColorBuffer& Target, float Colour[4], D3D12_RECT* Rect = nullptr); - void ClearDepth( DepthBuffer& Target ); - void ClearStencil( DepthBuffer& Target ); - void ClearDepthAndStencil( DepthBuffer& Target ); - - void BeginQuery(ID3D12QueryHeap* QueryHeap, D3D12_QUERY_TYPE Type, UINT HeapIndex); - void EndQuery(ID3D12QueryHeap* QueryHeap, D3D12_QUERY_TYPE Type, UINT HeapIndex); - void ResolveQueryData(ID3D12QueryHeap* QueryHeap, D3D12_QUERY_TYPE Type, UINT StartIndex, UINT NumQueries, ID3D12Resource* DestinationBuffer, UINT64 DestinationBufferOffset); - - void SetRootSignature( const RootSignature& RootSig ); - - void SetRenderTargets(UINT NumRTVs, const D3D12_CPU_DESCRIPTOR_HANDLE RTVs[]); - void SetRenderTargets(UINT NumRTVs, const D3D12_CPU_DESCRIPTOR_HANDLE RTVs[], D3D12_CPU_DESCRIPTOR_HANDLE DSV); - void SetRenderTarget(D3D12_CPU_DESCRIPTOR_HANDLE RTV ) { SetRenderTargets(1, &RTV); } - void SetRenderTarget(D3D12_CPU_DESCRIPTOR_HANDLE RTV, D3D12_CPU_DESCRIPTOR_HANDLE DSV ) { SetRenderTargets(1, &RTV, DSV); } - void SetDepthStencilTarget(D3D12_CPU_DESCRIPTOR_HANDLE DSV ) { SetRenderTargets(0, nullptr, DSV); } - - void SetViewport( const D3D12_VIEWPORT& vp ); - void SetViewport( FLOAT x, FLOAT y, FLOAT w, FLOAT h, FLOAT minDepth = 0.0f, FLOAT maxDepth = 1.0f ); - void SetScissor( const D3D12_RECT& rect ); - void SetScissor( UINT left, UINT top, UINT right, UINT bottom ); - void SetViewportAndScissor( const D3D12_VIEWPORT& vp, const D3D12_RECT& rect ); - void SetViewportAndScissor( UINT x, UINT y, UINT w, UINT h ); - void SetStencilRef( UINT StencilRef ); - void SetBlendFactor( Color BlendFactor ); - void SetPrimitiveTopology( D3D12_PRIMITIVE_TOPOLOGY Topology ); - - void SetConstantArray( UINT RootIndex, UINT NumConstants, const void* pConstants ); - void SetConstant( UINT RootIndex, UINT Offset, DWParam Val ); - void SetConstants( UINT RootIndex, DWParam X ); - void SetConstants( UINT RootIndex, DWParam X, DWParam Y ); - void SetConstants( UINT RootIndex, DWParam X, DWParam Y, DWParam Z ); - void SetConstants( UINT RootIndex, DWParam X, DWParam Y, DWParam Z, DWParam W ); - void SetConstantBuffer( UINT RootIndex, D3D12_GPU_VIRTUAL_ADDRESS CBV ); - void SetDynamicConstantBufferView( UINT RootIndex, size_t BufferSize, const void* BufferData ); - void SetBufferSRV( UINT RootIndex, const GpuBuffer& SRV, UINT64 Offset = 0); - void SetBufferUAV( UINT RootIndex, const GpuBuffer& UAV, UINT64 Offset = 0); - void SetDescriptorTable( UINT RootIndex, D3D12_GPU_DESCRIPTOR_HANDLE FirstHandle ); - - void SetDynamicDescriptor( UINT RootIndex, UINT Offset, D3D12_CPU_DESCRIPTOR_HANDLE Handle ); - void SetDynamicDescriptors( UINT RootIndex, UINT Offset, UINT Count, const D3D12_CPU_DESCRIPTOR_HANDLE Handles[] ); - void SetDynamicSampler( UINT RootIndex, UINT Offset, D3D12_CPU_DESCRIPTOR_HANDLE Handle ); - void SetDynamicSamplers( UINT RootIndex, UINT Offset, UINT Count, const D3D12_CPU_DESCRIPTOR_HANDLE Handles[] ); - - void SetIndexBuffer( const D3D12_INDEX_BUFFER_VIEW& IBView ); - void SetVertexBuffer( UINT Slot, const D3D12_VERTEX_BUFFER_VIEW& VBView ); - void SetVertexBuffers( UINT StartSlot, UINT Count, const D3D12_VERTEX_BUFFER_VIEW VBViews[] ); - void SetDynamicVB( UINT Slot, size_t NumVertices, size_t VertexStride, const void* VBData ); - void SetDynamicIB( size_t IndexCount, const uint16_t* IBData ); - void SetDynamicSRV(UINT RootIndex, size_t BufferSize, const void* BufferData); - - void Draw( UINT VertexCount, UINT VertexStartOffset = 0 ); - void DrawIndexed(UINT IndexCount, UINT StartIndexLocation = 0, INT BaseVertexLocation = 0); - void DrawInstanced(UINT VertexCountPerInstance, UINT InstanceCount, - UINT StartVertexLocation = 0, UINT StartInstanceLocation = 0); - void DrawIndexedInstanced(UINT IndexCountPerInstance, UINT InstanceCount, UINT StartIndexLocation, - INT BaseVertexLocation, UINT StartInstanceLocation); - void DrawIndirect( GpuBuffer& ArgumentBuffer, uint64_t ArgumentBufferOffset = 0 ); - void ExecuteIndirect(CommandSignature& CommandSig, GpuBuffer& ArgumentBuffer, uint64_t ArgumentStartOffset = 0, - uint32_t MaxCommands = 1, GpuBuffer* CommandCounterBuffer = nullptr, uint64_t CounterOffset = 0); - -private: -}; - -class ComputeContext : public CommandContext -{ -public: - - static ComputeContext& Begin(const std::wstring& ID = L"", bool Async = false); - - void ClearUAV( GpuBuffer& Target ); - void ClearUAV( ColorBuffer& Target ); - - void SetRootSignature( const RootSignature& RootSig ); - - void SetConstantArray( UINT RootIndex, UINT NumConstants, const void* pConstants ); - void SetConstant( UINT RootIndex, UINT Offset, DWParam Val ); - void SetConstants( UINT RootIndex, DWParam X ); - void SetConstants( UINT RootIndex, DWParam X, DWParam Y ); - void SetConstants( UINT RootIndex, DWParam X, DWParam Y, DWParam Z ); - void SetConstants( UINT RootIndex, DWParam X, DWParam Y, DWParam Z, DWParam W ); - void SetConstantBuffer( UINT RootIndex, D3D12_GPU_VIRTUAL_ADDRESS CBV ); - void SetDynamicConstantBufferView( UINT RootIndex, size_t BufferSize, const void* BufferData ); - void SetDynamicSRV( UINT RootIndex, size_t BufferSize, const void* BufferData ); - void SetBufferSRV( UINT RootIndex, const GpuBuffer& SRV, UINT64 Offset = 0); - void SetBufferUAV( UINT RootIndex, const GpuBuffer& UAV, UINT64 Offset = 0); - void SetDescriptorTable( UINT RootIndex, D3D12_GPU_DESCRIPTOR_HANDLE FirstHandle ); - - void SetDynamicDescriptor( UINT RootIndex, UINT Offset, D3D12_CPU_DESCRIPTOR_HANDLE Handle ); - void SetDynamicDescriptors( UINT RootIndex, UINT Offset, UINT Count, const D3D12_CPU_DESCRIPTOR_HANDLE Handles[] ); - void SetDynamicSampler( UINT RootIndex, UINT Offset, D3D12_CPU_DESCRIPTOR_HANDLE Handle ); - void SetDynamicSamplers( UINT RootIndex, UINT Offset, UINT Count, const D3D12_CPU_DESCRIPTOR_HANDLE Handles[] ); - - void Dispatch( size_t GroupCountX = 1, size_t GroupCountY = 1, size_t GroupCountZ = 1 ); - void Dispatch1D( size_t ThreadCountX, size_t GroupSizeX = 64); - void Dispatch2D( size_t ThreadCountX, size_t ThreadCountY, size_t GroupSizeX = 8, size_t GroupSizeY = 8); - void Dispatch3D( size_t ThreadCountX, size_t ThreadCountY, size_t ThreadCountZ, size_t GroupSizeX, size_t GroupSizeY, size_t GroupSizeZ ); - void DispatchIndirect( GpuBuffer& ArgumentBuffer, uint64_t ArgumentBufferOffset = 0 ); - void ExecuteIndirect(CommandSignature& CommandSig, GpuBuffer& ArgumentBuffer, uint64_t ArgumentStartOffset = 0, - uint32_t MaxCommands = 1, GpuBuffer* CommandCounterBuffer = nullptr, uint64_t CounterOffset = 0); - - void InvalidateStates(); - -private: -}; - -inline void CommandContext::FlushResourceBarriers( void ) -{ - if (m_NumBarriersToFlush > 0) - { - m_CommandList->ResourceBarrier(m_NumBarriersToFlush, m_ResourceBarrierBuffer); - m_NumBarriersToFlush = 0; - } -} - -inline void GraphicsContext::SetRootSignature( const RootSignature& RootSig ) -{ - if (RootSig.GetSignature() == m_CurGraphicsRootSignature) - return; - - m_CommandList->SetGraphicsRootSignature(m_CurGraphicsRootSignature = RootSig.GetSignature()); - - m_DynamicViewDescriptorHeap.ParseGraphicsRootSignature(RootSig); - m_DynamicSamplerDescriptorHeap.ParseGraphicsRootSignature(RootSig); -} - -inline void ComputeContext::SetRootSignature( const RootSignature& RootSig ) -{ - if (RootSig.GetSignature() == m_CurComputeRootSignature) - return; - - m_CommandList->SetComputeRootSignature(m_CurComputeRootSignature = RootSig.GetSignature()); - - m_DynamicViewDescriptorHeap.ParseComputeRootSignature(RootSig); - m_DynamicSamplerDescriptorHeap.ParseComputeRootSignature(RootSig); -} - -inline void CommandContext::SetPipelineState( const PSO& PSO ) -{ - ID3D12PipelineState* PipelineState = PSO.GetPipelineStateObject(); - if (PipelineState == m_CurPipelineState) - return; - - m_CommandList->SetPipelineState(PipelineState); - m_CurPipelineState = PipelineState; -} - -inline void GraphicsContext::SetViewportAndScissor( UINT x, UINT y, UINT w, UINT h ) -{ - SetViewport((float)x, (float)y, (float)w, (float)h); - SetScissor(x, y, x + w, y + h); -} - -inline void GraphicsContext::SetScissor( UINT left, UINT top, UINT right, UINT bottom ) -{ - SetScissor(CD3DX12_RECT(left, top, right, bottom)); -} - -inline void GraphicsContext::SetStencilRef( UINT ref ) -{ - m_CommandList->OMSetStencilRef( ref ); -} - -inline void GraphicsContext::SetBlendFactor( Color BlendFactor ) -{ - m_CommandList->OMSetBlendFactor( BlendFactor.GetPtr() ); -} - -inline void GraphicsContext::SetPrimitiveTopology( D3D12_PRIMITIVE_TOPOLOGY Topology ) -{ - m_CommandList->IASetPrimitiveTopology(Topology); -} - -inline void ComputeContext::SetConstantArray( UINT RootEntry, UINT NumConstants, const void* pConstants ) -{ - m_CommandList->SetComputeRoot32BitConstants( RootEntry, NumConstants, pConstants, 0 ); -} - -inline void ComputeContext::SetConstant( UINT RootEntry, UINT Offset, DWParam Val ) -{ - m_CommandList->SetComputeRoot32BitConstant( RootEntry, Val.Uint, Offset ); -} - -inline void ComputeContext::SetConstants( UINT RootEntry, DWParam X ) -{ - m_CommandList->SetComputeRoot32BitConstant( RootEntry, X.Uint, 0 ); -} - -inline void ComputeContext::SetConstants( UINT RootEntry, DWParam X, DWParam Y ) -{ - m_CommandList->SetComputeRoot32BitConstant( RootEntry, X.Uint, 0 ); - m_CommandList->SetComputeRoot32BitConstant( RootEntry, Y.Uint, 1 ); -} - -inline void ComputeContext::SetConstants( UINT RootEntry, DWParam X, DWParam Y, DWParam Z ) -{ - m_CommandList->SetComputeRoot32BitConstant( RootEntry, X.Uint, 0 ); - m_CommandList->SetComputeRoot32BitConstant( RootEntry, Y.Uint, 1 ); - m_CommandList->SetComputeRoot32BitConstant( RootEntry, Z.Uint, 2 ); -} - -inline void ComputeContext::SetConstants( UINT RootEntry, DWParam X, DWParam Y, DWParam Z, DWParam W ) -{ - m_CommandList->SetComputeRoot32BitConstant( RootEntry, X.Uint, 0 ); - m_CommandList->SetComputeRoot32BitConstant( RootEntry, Y.Uint, 1 ); - m_CommandList->SetComputeRoot32BitConstant( RootEntry, Z.Uint, 2 ); - m_CommandList->SetComputeRoot32BitConstant( RootEntry, W.Uint, 3 ); -} - -inline void GraphicsContext::SetConstantArray( UINT RootIndex, UINT NumConstants, const void* pConstants ) -{ - m_CommandList->SetGraphicsRoot32BitConstants( RootIndex, NumConstants, pConstants, 0 ); -} - -inline void GraphicsContext::SetConstant( UINT RootEntry, UINT Offset, DWParam Val ) -{ - m_CommandList->SetGraphicsRoot32BitConstant( RootEntry, Val.Uint, Offset ); -} - -inline void GraphicsContext::SetConstants( UINT RootIndex, DWParam X ) -{ - m_CommandList->SetGraphicsRoot32BitConstant( RootIndex, X.Uint, 0 ); -} - -inline void GraphicsContext::SetConstants( UINT RootIndex, DWParam X, DWParam Y ) -{ - m_CommandList->SetGraphicsRoot32BitConstant( RootIndex, X.Uint, 0 ); - m_CommandList->SetGraphicsRoot32BitConstant( RootIndex, Y.Uint, 1 ); -} - -inline void GraphicsContext::SetConstants( UINT RootIndex, DWParam X, DWParam Y, DWParam Z ) -{ - m_CommandList->SetGraphicsRoot32BitConstant( RootIndex, X.Uint, 0 ); - m_CommandList->SetGraphicsRoot32BitConstant( RootIndex, Y.Uint, 1 ); - m_CommandList->SetGraphicsRoot32BitConstant( RootIndex, Z.Uint, 2 ); -} - -inline void GraphicsContext::SetConstants( UINT RootIndex, DWParam X, DWParam Y, DWParam Z, DWParam W ) -{ - m_CommandList->SetGraphicsRoot32BitConstant( RootIndex, X.Uint, 0 ); - m_CommandList->SetGraphicsRoot32BitConstant( RootIndex, Y.Uint, 1 ); - m_CommandList->SetGraphicsRoot32BitConstant( RootIndex, Z.Uint, 2 ); - m_CommandList->SetGraphicsRoot32BitConstant( RootIndex, W.Uint, 3 ); -} - -inline void ComputeContext::SetConstantBuffer( UINT RootIndex, D3D12_GPU_VIRTUAL_ADDRESS CBV ) -{ - m_CommandList->SetComputeRootConstantBufferView(RootIndex, CBV); -} - -inline void GraphicsContext::SetConstantBuffer( UINT RootIndex, D3D12_GPU_VIRTUAL_ADDRESS CBV ) -{ - m_CommandList->SetGraphicsRootConstantBufferView(RootIndex, CBV); -} - -inline void GraphicsContext::SetDynamicConstantBufferView( UINT RootIndex, size_t BufferSize, const void* BufferData ) -{ - ASSERT(BufferData != nullptr && Math::IsAligned(BufferData, 16)); - DynAlloc cb = m_CpuLinearAllocator.Allocate(BufferSize); - //SIMDMemCopy(cb.DataPtr, BufferData, Math::AlignUp(BufferSize, 16) >> 4); - memcpy(cb.DataPtr, BufferData, BufferSize); - m_CommandList->SetGraphicsRootConstantBufferView(RootIndex, cb.GpuAddress); -} - -inline void ComputeContext::SetDynamicConstantBufferView( UINT RootIndex, size_t BufferSize, const void* BufferData ) -{ - ASSERT(BufferData != nullptr && Math::IsAligned(BufferData, 16)); - DynAlloc cb = m_CpuLinearAllocator.Allocate(BufferSize); - //SIMDMemCopy(cb.DataPtr, BufferData, Math::AlignUp(BufferSize, 16) >> 4); - memcpy(cb.DataPtr, BufferData, BufferSize); - m_CommandList->SetComputeRootConstantBufferView(RootIndex, cb.GpuAddress); -} - -inline void GraphicsContext::SetDynamicVB( UINT Slot, size_t NumVertices, size_t VertexStride, const void* VertexData ) -{ - ASSERT(VertexData != nullptr && Math::IsAligned(VertexData, 16)); - - size_t BufferSize = Math::AlignUp(NumVertices * VertexStride, 16); - DynAlloc vb = m_CpuLinearAllocator.Allocate(BufferSize); - - SIMDMemCopy(vb.DataPtr, VertexData, BufferSize >> 4); - - D3D12_VERTEX_BUFFER_VIEW VBView; - VBView.BufferLocation = vb.GpuAddress; - VBView.SizeInBytes = (UINT)BufferSize; - VBView.StrideInBytes = (UINT)VertexStride; - - m_CommandList->IASetVertexBuffers(Slot, 1, &VBView); -} - -inline void GraphicsContext::SetDynamicIB( size_t IndexCount, const uint16_t* IndexData ) -{ - ASSERT(IndexData != nullptr && Math::IsAligned(IndexData, 16)); - - size_t BufferSize = Math::AlignUp(IndexCount * sizeof(uint16_t), 16); - DynAlloc ib = m_CpuLinearAllocator.Allocate(BufferSize); - - SIMDMemCopy(ib.DataPtr, IndexData, BufferSize >> 4); - - D3D12_INDEX_BUFFER_VIEW IBView; - IBView.BufferLocation = ib.GpuAddress; - IBView.SizeInBytes = (UINT)(IndexCount * sizeof(uint16_t)); - IBView.Format = DXGI_FORMAT_R16_UINT; - - m_CommandList->IASetIndexBuffer(&IBView); -} - -inline void GraphicsContext::SetDynamicSRV(UINT RootIndex, size_t BufferSize, const void* BufferData) -{ - ASSERT(BufferData != nullptr && Math::IsAligned(BufferData, 16)); - DynAlloc cb = m_CpuLinearAllocator.Allocate(BufferSize); - SIMDMemCopy(cb.DataPtr, BufferData, Math::AlignUp(BufferSize, 16) >> 4); - m_CommandList->SetGraphicsRootShaderResourceView(RootIndex, cb.GpuAddress); -} - -inline void ComputeContext::SetDynamicSRV(UINT RootIndex, size_t BufferSize, const void* BufferData) -{ - ASSERT(BufferData != nullptr && Math::IsAligned(BufferData, 16)); - DynAlloc cb = m_CpuLinearAllocator.Allocate(BufferSize); - SIMDMemCopy(cb.DataPtr, BufferData, Math::AlignUp(BufferSize, 16) >> 4); - m_CommandList->SetComputeRootShaderResourceView(RootIndex, cb.GpuAddress); -} - -inline void GraphicsContext::SetBufferSRV( UINT RootIndex, const GpuBuffer& SRV, UINT64 Offset) -{ - ASSERT((SRV.m_UsageState & (D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE)) != 0); - m_CommandList->SetGraphicsRootShaderResourceView(RootIndex, SRV.GetGpuVirtualAddress() + Offset); -} - -inline void ComputeContext::SetBufferSRV( UINT RootIndex, const GpuBuffer& SRV, UINT64 Offset) -{ - ASSERT((SRV.m_UsageState & D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE) != 0); - m_CommandList->SetComputeRootShaderResourceView(RootIndex, SRV.GetGpuVirtualAddress() + Offset); -} - -inline void GraphicsContext::SetBufferUAV( UINT RootIndex, const GpuBuffer& UAV, UINT64 Offset) -{ - ASSERT((UAV.m_UsageState & D3D12_RESOURCE_STATE_UNORDERED_ACCESS) != 0); - m_CommandList->SetGraphicsRootUnorderedAccessView(RootIndex, UAV.GetGpuVirtualAddress() + Offset); -} - -inline void ComputeContext::SetBufferUAV( UINT RootIndex, const GpuBuffer& UAV, UINT64 Offset) -{ - ASSERT((UAV.m_UsageState & D3D12_RESOURCE_STATE_UNORDERED_ACCESS) != 0); - m_CommandList->SetComputeRootUnorderedAccessView(RootIndex, UAV.GetGpuVirtualAddress() + Offset); -} - -inline void ComputeContext::Dispatch( size_t GroupCountX, size_t GroupCountY, size_t GroupCountZ ) -{ - FlushResourceBarriers(); - m_DynamicViewDescriptorHeap.CommitComputeRootDescriptorTables(m_CommandList); - m_DynamicSamplerDescriptorHeap.CommitComputeRootDescriptorTables(m_CommandList); - m_CommandList->Dispatch((UINT)GroupCountX, (UINT)GroupCountY, (UINT)GroupCountZ); -} - -inline void ComputeContext::Dispatch1D( size_t ThreadCountX, size_t GroupSizeX ) -{ - Dispatch( Math::DivideByMultiple(ThreadCountX, GroupSizeX), 1, 1 ); -} - -inline void ComputeContext::Dispatch2D( size_t ThreadCountX, size_t ThreadCountY, size_t GroupSizeX, size_t GroupSizeY ) -{ - Dispatch( - Math::DivideByMultiple(ThreadCountX, GroupSizeX), - Math::DivideByMultiple(ThreadCountY, GroupSizeY), 1); -} - -inline void ComputeContext::Dispatch3D( size_t ThreadCountX, size_t ThreadCountY, size_t ThreadCountZ, size_t GroupSizeX, size_t GroupSizeY, size_t GroupSizeZ ) -{ - Dispatch( - Math::DivideByMultiple(ThreadCountX, GroupSizeX), - Math::DivideByMultiple(ThreadCountY, GroupSizeY), - Math::DivideByMultiple(ThreadCountZ, GroupSizeZ)); -} - -inline void CommandContext::SetDescriptorHeap( D3D12_DESCRIPTOR_HEAP_TYPE Type, ID3D12DescriptorHeap* HeapPtr ) -{ - if (m_CurrentDescriptorHeaps[Type] != HeapPtr) - { - m_CurrentDescriptorHeaps[Type] = HeapPtr; - BindDescriptorHeaps(); - } -} - -inline void CommandContext::SetDescriptorHeaps( UINT HeapCount, D3D12_DESCRIPTOR_HEAP_TYPE Type[], ID3D12DescriptorHeap* HeapPtrs[] ) -{ - bool AnyChanged = false; - - for (UINT i = 0; i < HeapCount; ++i) - { - if (m_CurrentDescriptorHeaps[Type[i]] != HeapPtrs[i]) - { - m_CurrentDescriptorHeaps[Type[i]] = HeapPtrs[i]; - AnyChanged = true; - } - } - - if (AnyChanged) - BindDescriptorHeaps(); -} - -inline void CommandContext::SetPredication(ID3D12Resource* Buffer, UINT64 BufferOffset, D3D12_PREDICATION_OP Op) -{ - m_CommandList->SetPredication(Buffer, BufferOffset, Op); -} - -inline void GraphicsContext::SetDynamicDescriptor( UINT RootIndex, UINT Offset, D3D12_CPU_DESCRIPTOR_HANDLE Handle ) -{ - SetDynamicDescriptors(RootIndex, Offset, 1, &Handle); -} - -inline void ComputeContext::SetDynamicDescriptor( UINT RootIndex, UINT Offset, D3D12_CPU_DESCRIPTOR_HANDLE Handle ) -{ - SetDynamicDescriptors(RootIndex, Offset, 1, &Handle); -} - -inline void GraphicsContext::SetDynamicDescriptors( UINT RootIndex, UINT Offset, UINT Count, const D3D12_CPU_DESCRIPTOR_HANDLE Handles[] ) -{ - m_DynamicViewDescriptorHeap.SetGraphicsDescriptorHandles(RootIndex, Offset, Count, Handles); -} - -inline void ComputeContext::SetDynamicDescriptors( UINT RootIndex, UINT Offset, UINT Count, const D3D12_CPU_DESCRIPTOR_HANDLE Handles[] ) -{ - m_DynamicViewDescriptorHeap.SetComputeDescriptorHandles(RootIndex, Offset, Count, Handles); -} - -inline void GraphicsContext::SetDynamicSampler( UINT RootIndex, UINT Offset, D3D12_CPU_DESCRIPTOR_HANDLE Handle ) -{ - SetDynamicSamplers(RootIndex, Offset, 1, &Handle); -} - -inline void GraphicsContext::SetDynamicSamplers( UINT RootIndex, UINT Offset, UINT Count, const D3D12_CPU_DESCRIPTOR_HANDLE Handles[] ) -{ - m_DynamicSamplerDescriptorHeap.SetGraphicsDescriptorHandles(RootIndex, Offset, Count, Handles); -} - -inline void ComputeContext::SetDynamicSampler( UINT RootIndex, UINT Offset, D3D12_CPU_DESCRIPTOR_HANDLE Handle ) -{ - SetDynamicSamplers(RootIndex, Offset, 1, &Handle); -} - -inline void ComputeContext::SetDynamicSamplers( UINT RootIndex, UINT Offset, UINT Count, const D3D12_CPU_DESCRIPTOR_HANDLE Handles[] ) -{ - m_DynamicSamplerDescriptorHeap.SetComputeDescriptorHandles(RootIndex, Offset, Count, Handles); -} - -inline void GraphicsContext::SetDescriptorTable( UINT RootIndex, D3D12_GPU_DESCRIPTOR_HANDLE FirstHandle ) -{ - m_CommandList->SetGraphicsRootDescriptorTable( RootIndex, FirstHandle ); -} - -inline void ComputeContext::SetDescriptorTable( UINT RootIndex, D3D12_GPU_DESCRIPTOR_HANDLE FirstHandle ) -{ - m_CommandList->SetComputeRootDescriptorTable( RootIndex, FirstHandle ); -} - -inline void GraphicsContext::SetIndexBuffer( const D3D12_INDEX_BUFFER_VIEW& IBView ) -{ - m_CommandList->IASetIndexBuffer(&IBView); -} - -inline void GraphicsContext::SetVertexBuffer( UINT Slot, const D3D12_VERTEX_BUFFER_VIEW& VBView ) -{ - SetVertexBuffers(Slot, 1, &VBView); -} - -inline void GraphicsContext::SetVertexBuffers( UINT StartSlot, UINT Count, const D3D12_VERTEX_BUFFER_VIEW VBViews[] ) -{ - m_CommandList->IASetVertexBuffers(StartSlot, Count, VBViews); -} - -inline void GraphicsContext::Draw(UINT VertexCount, UINT VertexStartOffset) -{ - DrawInstanced(VertexCount, 1, VertexStartOffset, 0); -} - -inline void GraphicsContext::DrawIndexed(UINT IndexCount, UINT StartIndexLocation, INT BaseVertexLocation) -{ - DrawIndexedInstanced(IndexCount, 1, StartIndexLocation, BaseVertexLocation, 0); -} - -inline void GraphicsContext::DrawInstanced(UINT VertexCountPerInstance, UINT InstanceCount, - UINT StartVertexLocation, UINT StartInstanceLocation) -{ - FlushResourceBarriers(); - m_DynamicViewDescriptorHeap.CommitGraphicsRootDescriptorTables(m_CommandList); - m_DynamicSamplerDescriptorHeap.CommitGraphicsRootDescriptorTables(m_CommandList); - m_CommandList->DrawInstanced(VertexCountPerInstance, InstanceCount, StartVertexLocation, StartInstanceLocation); -} - -inline void GraphicsContext::DrawIndexedInstanced(UINT IndexCountPerInstance, UINT InstanceCount, UINT StartIndexLocation, - INT BaseVertexLocation, UINT StartInstanceLocation) -{ - FlushResourceBarriers(); - m_DynamicViewDescriptorHeap.CommitGraphicsRootDescriptorTables(m_CommandList); - m_DynamicSamplerDescriptorHeap.CommitGraphicsRootDescriptorTables(m_CommandList); - m_CommandList->DrawIndexedInstanced(IndexCountPerInstance, InstanceCount, StartIndexLocation, BaseVertexLocation, StartInstanceLocation); -} - -inline void GraphicsContext::ExecuteIndirect(CommandSignature& CommandSig, - GpuBuffer& ArgumentBuffer, uint64_t ArgumentStartOffset, - uint32_t MaxCommands, GpuBuffer* CommandCounterBuffer, uint64_t CounterOffset) -{ - FlushResourceBarriers(); - m_DynamicViewDescriptorHeap.CommitGraphicsRootDescriptorTables(m_CommandList); - m_DynamicSamplerDescriptorHeap.CommitGraphicsRootDescriptorTables(m_CommandList); - m_CommandList->ExecuteIndirect(CommandSig.GetSignature(), MaxCommands, - ArgumentBuffer.GetResource(), ArgumentStartOffset, - CommandCounterBuffer == nullptr ? nullptr : CommandCounterBuffer->GetResource(), CounterOffset); -} - -inline void GraphicsContext::DrawIndirect(GpuBuffer& ArgumentBuffer, uint64_t ArgumentBufferOffset) -{ - ExecuteIndirect(Graphics::DrawIndirectCommandSignature, ArgumentBuffer, ArgumentBufferOffset); -} - -inline void ComputeContext::ExecuteIndirect(CommandSignature& CommandSig, - GpuBuffer& ArgumentBuffer, uint64_t ArgumentStartOffset, - uint32_t MaxCommands, GpuBuffer* CommandCounterBuffer, uint64_t CounterOffset) -{ - FlushResourceBarriers(); - m_DynamicViewDescriptorHeap.CommitComputeRootDescriptorTables(m_CommandList); - m_DynamicSamplerDescriptorHeap.CommitComputeRootDescriptorTables(m_CommandList); - m_CommandList->ExecuteIndirect(CommandSig.GetSignature(), MaxCommands, - ArgumentBuffer.GetResource(), ArgumentStartOffset, - CommandCounterBuffer == nullptr ? nullptr : CommandCounterBuffer->GetResource(), CounterOffset); -} - -inline void ComputeContext::DispatchIndirect( GpuBuffer& ArgumentBuffer, uint64_t ArgumentBufferOffset ) -{ - ExecuteIndirect(Graphics::DispatchIndirectCommandSignature, ArgumentBuffer, ArgumentBufferOffset); -} - -inline void CommandContext::CopyBuffer( GpuResource& Dest, GpuResource& Src ) -{ - TransitionResource(Dest, D3D12_RESOURCE_STATE_COPY_DEST); - TransitionResource(Src, D3D12_RESOURCE_STATE_COPY_SOURCE); - FlushResourceBarriers(); - m_CommandList->CopyResource(Dest.GetResource(), Src.GetResource()); -} - -inline void CommandContext::CopyBufferRegion( GpuResource& Dest, size_t DestOffset, GpuResource& Src, size_t SrcOffset, size_t NumBytes ) -{ - TransitionResource(Dest, D3D12_RESOURCE_STATE_COPY_DEST); - //TransitionResource(Src, D3D12_RESOURCE_STATE_COPY_SOURCE); - FlushResourceBarriers(); - m_CommandList->CopyBufferRegion( Dest.GetResource(), DestOffset, Src.GetResource(), SrcOffset, NumBytes); -} - -inline void CommandContext::CopyCounter(GpuResource& Dest, size_t DestOffset, StructuredBuffer& Src) -{ - TransitionResource(Dest, D3D12_RESOURCE_STATE_COPY_DEST); - TransitionResource(Src.GetCounterBuffer(), D3D12_RESOURCE_STATE_COPY_SOURCE); - FlushResourceBarriers(); - m_CommandList->CopyBufferRegion(Dest.GetResource(), DestOffset, Src.GetCounterBuffer().GetResource(), 0, 4); -} - -inline void CommandContext::CopyTextureRegion(GpuResource& Dest, UINT x, UINT y, UINT z, GpuResource& Source, RECT& Rect) -{ - TransitionResource(Dest, D3D12_RESOURCE_STATE_COPY_DEST); - TransitionResource(Source, D3D12_RESOURCE_STATE_COPY_SOURCE); - FlushResourceBarriers(); - - D3D12_TEXTURE_COPY_LOCATION destLoc = CD3DX12_TEXTURE_COPY_LOCATION(Dest.GetResource(), 0); - D3D12_TEXTURE_COPY_LOCATION srcLoc = CD3DX12_TEXTURE_COPY_LOCATION(Source.GetResource(), 0); - - D3D12_BOX box = {}; - box.back = 1; - box.left = Rect.left; - box.right = Rect.right; - box.top = Rect.top; - box.bottom = Rect.bottom; - - m_CommandList->CopyTextureRegion(&destLoc, x, y, z, &srcLoc, &box); -} - -inline void CommandContext::ResetCounter(StructuredBuffer& Buf, uint32_t Value ) -{ - FillBuffer(Buf.GetCounterBuffer(), 0, Value, sizeof(uint32_t)); - TransitionResource(Buf.GetCounterBuffer(), D3D12_RESOURCE_STATE_UNORDERED_ACCESS); -} - -inline void CommandContext::InsertTimeStamp(ID3D12QueryHeap* pQueryHeap, uint32_t QueryIdx) -{ - m_CommandList->EndQuery(pQueryHeap, D3D12_QUERY_TYPE_TIMESTAMP, QueryIdx); -} - -inline void CommandContext::ResolveTimeStamps(ID3D12Resource* pReadbackHeap, ID3D12QueryHeap* pQueryHeap, uint32_t NumQueries) -{ - m_CommandList->ResolveQueryData(pQueryHeap, D3D12_QUERY_TYPE_TIMESTAMP, 0, NumQueries, pReadbackHeap, 0); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/CommandListManager.cpp b/xess/samples/xess_demo/MiniEngine/Core/CommandListManager.cpp deleted file mode 100644 index dbd5090..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/CommandListManager.cpp +++ /dev/null @@ -1,203 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "CommandListManager.h" - -CommandQueue::CommandQueue(D3D12_COMMAND_LIST_TYPE Type) : - m_Type(Type), - m_CommandQueue(nullptr), - m_pFence(nullptr), - m_NextFenceValue((uint64_t)Type << 56 | 1), - m_LastCompletedFenceValue((uint64_t)Type << 56), - m_AllocatorPool(Type) -{ -} - -CommandQueue::~CommandQueue() -{ - Shutdown(); -} - -void CommandQueue::Shutdown() -{ - if (m_CommandQueue == nullptr) - return; - - m_AllocatorPool.Shutdown(); - - CloseHandle(m_FenceEventHandle); - - m_pFence->Release(); - m_pFence = nullptr; - - m_CommandQueue->Release(); - m_CommandQueue = nullptr; -} - -CommandListManager::CommandListManager() : - m_Device(nullptr), - m_GraphicsQueue(D3D12_COMMAND_LIST_TYPE_DIRECT), - m_ComputeQueue(D3D12_COMMAND_LIST_TYPE_COMPUTE), - m_CopyQueue(D3D12_COMMAND_LIST_TYPE_COPY) -{ -} - -CommandListManager::~CommandListManager() -{ - Shutdown(); -} - -void CommandListManager::Shutdown() -{ - m_GraphicsQueue.Shutdown(); - m_ComputeQueue.Shutdown(); - m_CopyQueue.Shutdown(); -} - -void CommandQueue::Create(ID3D12Device* pDevice) -{ - ASSERT(pDevice != nullptr); - ASSERT(!IsReady()); - ASSERT(m_AllocatorPool.Size() == 0); - - D3D12_COMMAND_QUEUE_DESC QueueDesc = {}; - QueueDesc.Type = m_Type; - QueueDesc.NodeMask = 1; - pDevice->CreateCommandQueue(&QueueDesc, MY_IID_PPV_ARGS(&m_CommandQueue)); - m_CommandQueue->SetName(L"CommandListManager::m_CommandQueue"); - - ASSERT_SUCCEEDED(pDevice->CreateFence(0, D3D12_FENCE_FLAG_NONE, MY_IID_PPV_ARGS(&m_pFence))); - m_pFence->SetName(L"CommandListManager::m_pFence"); - m_pFence->Signal((uint64_t)m_Type << 56); - - m_FenceEventHandle = CreateEvent(nullptr, false, false, nullptr); - ASSERT(m_FenceEventHandle != NULL); - - m_AllocatorPool.Create(pDevice); - - ASSERT(IsReady()); -} - -void CommandListManager::Create(ID3D12Device* pDevice) -{ - ASSERT(pDevice != nullptr); - - m_Device = pDevice; - - m_GraphicsQueue.Create(pDevice); - m_ComputeQueue.Create(pDevice); - m_CopyQueue.Create(pDevice); -} - -void CommandListManager::CreateNewCommandList( D3D12_COMMAND_LIST_TYPE Type, ID3D12GraphicsCommandList** List, ID3D12CommandAllocator** Allocator ) -{ - ASSERT(Type != D3D12_COMMAND_LIST_TYPE_BUNDLE, "Bundles are not yet supported"); - switch (Type) - { - case D3D12_COMMAND_LIST_TYPE_DIRECT: *Allocator = m_GraphicsQueue.RequestAllocator(); break; - case D3D12_COMMAND_LIST_TYPE_BUNDLE: break; - case D3D12_COMMAND_LIST_TYPE_COMPUTE: *Allocator = m_ComputeQueue.RequestAllocator(); break; - case D3D12_COMMAND_LIST_TYPE_COPY: *Allocator = m_CopyQueue.RequestAllocator(); break; - } - - ASSERT_SUCCEEDED( m_Device->CreateCommandList(1, Type, *Allocator, nullptr, MY_IID_PPV_ARGS(List)) ); - (*List)->SetName(L"CommandList"); -} - -uint64_t CommandQueue::ExecuteCommandList( ID3D12CommandList* List ) -{ - std::lock_guard LockGuard(m_FenceMutex); - - ASSERT_SUCCEEDED(((ID3D12GraphicsCommandList*)List)->Close()); - - // Kickoff the command list - m_CommandQueue->ExecuteCommandLists(1, &List); - - // Signal the next fence value (with the GPU) - m_CommandQueue->Signal(m_pFence, m_NextFenceValue); - - // And increment the fence value. - return m_NextFenceValue++; -} - -uint64_t CommandQueue::IncrementFence(void) -{ - std::lock_guard LockGuard(m_FenceMutex); - m_CommandQueue->Signal(m_pFence, m_NextFenceValue); - return m_NextFenceValue++; -} - -bool CommandQueue::IsFenceComplete(uint64_t FenceValue) -{ - // Avoid querying the fence value by testing against the last one seen. - // The max() is to protect against an unlikely race condition that could cause the last - // completed fence value to regress. - if (FenceValue > m_LastCompletedFenceValue) - m_LastCompletedFenceValue = std::max(m_LastCompletedFenceValue, m_pFence->GetCompletedValue()); - - return FenceValue <= m_LastCompletedFenceValue; -} - -namespace Graphics -{ - extern CommandListManager g_CommandManager; -} - -void CommandQueue::StallForFence(uint64_t FenceValue) -{ - CommandQueue& Producer = Graphics::g_CommandManager.GetQueue((D3D12_COMMAND_LIST_TYPE)(FenceValue >> 56)); - m_CommandQueue->Wait(Producer.m_pFence, FenceValue); -} - -void CommandQueue::StallForProducer(CommandQueue& Producer) -{ - ASSERT(Producer.m_NextFenceValue > 0); - m_CommandQueue->Wait(Producer.m_pFence, Producer.m_NextFenceValue - 1); -} - -void CommandQueue::WaitForFence(uint64_t FenceValue) -{ - if (IsFenceComplete(FenceValue)) - return; - - // TODO: Think about how this might affect a multi-threaded situation. Suppose thread A - // wants to wait for fence 100, then thread B comes along and wants to wait for 99. If - // the fence can only have one event set on completion, then thread B has to wait for - // 100 before it knows 99 is ready. Maybe insert sequential events? - { - std::lock_guard LockGuard(m_EventMutex); - - m_pFence->SetEventOnCompletion(FenceValue, m_FenceEventHandle); - WaitForSingleObject(m_FenceEventHandle, INFINITE); - m_LastCompletedFenceValue = FenceValue; - } -} - -void CommandListManager::WaitForFence(uint64_t FenceValue) -{ - CommandQueue& Producer = Graphics::g_CommandManager.GetQueue((D3D12_COMMAND_LIST_TYPE)(FenceValue >> 56)); - Producer.WaitForFence(FenceValue); -} - -ID3D12CommandAllocator* CommandQueue::RequestAllocator() -{ - uint64_t CompletedFence = m_pFence->GetCompletedValue(); - - return m_AllocatorPool.RequestAllocator(CompletedFence); -} - -void CommandQueue::DiscardAllocator(uint64_t FenceValue, ID3D12CommandAllocator* Allocator) -{ - m_AllocatorPool.DiscardAllocator(FenceValue, Allocator); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/CommandListManager.h b/xess/samples/xess_demo/MiniEngine/Core/CommandListManager.h deleted file mode 100644 index ed6d7fe..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/CommandListManager.h +++ /dev/null @@ -1,136 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include -#include -#include -#include -#include "CommandAllocatorPool.h" - -class CommandQueue -{ - friend class CommandListManager; - friend class CommandContext; - -public: - CommandQueue(D3D12_COMMAND_LIST_TYPE Type); - ~CommandQueue(); - - void Create(ID3D12Device* pDevice); - void Shutdown(); - - inline bool IsReady() - { - return m_CommandQueue != nullptr; - } - - uint64_t IncrementFence(void); - bool IsFenceComplete(uint64_t FenceValue); - void StallForFence(uint64_t FenceValue); - void StallForProducer(CommandQueue& Producer); - void WaitForFence(uint64_t FenceValue); - void WaitForIdle(void) { WaitForFence(IncrementFence()); } - - ID3D12CommandQueue* GetCommandQueue() { return m_CommandQueue; } - - uint64_t GetNextFenceValue() { return m_NextFenceValue; } - -private: - - uint64_t ExecuteCommandList(ID3D12CommandList* List); - ID3D12CommandAllocator* RequestAllocator(void); - void DiscardAllocator(uint64_t FenceValueForReset, ID3D12CommandAllocator* Allocator); - - ID3D12CommandQueue* m_CommandQueue; - - const D3D12_COMMAND_LIST_TYPE m_Type; - - CommandAllocatorPool m_AllocatorPool; - std::mutex m_FenceMutex; - std::mutex m_EventMutex; - - // Lifetime of these objects is managed by the descriptor cache - ID3D12Fence* m_pFence; - uint64_t m_NextFenceValue; - uint64_t m_LastCompletedFenceValue; - HANDLE m_FenceEventHandle; - -}; - -class CommandListManager -{ - friend class CommandContext; - -public: - CommandListManager(); - ~CommandListManager(); - - void Create(ID3D12Device* pDevice); - void Shutdown(); - - CommandQueue& GetGraphicsQueue(void) { return m_GraphicsQueue; } - CommandQueue& GetComputeQueue(void) { return m_ComputeQueue; } - CommandQueue& GetCopyQueue(void) { return m_CopyQueue; } - - CommandQueue& GetQueue(D3D12_COMMAND_LIST_TYPE Type = D3D12_COMMAND_LIST_TYPE_DIRECT) - { - switch (Type) - { - case D3D12_COMMAND_LIST_TYPE_COMPUTE: return m_ComputeQueue; - case D3D12_COMMAND_LIST_TYPE_COPY: return m_CopyQueue; - default: return m_GraphicsQueue; - } - } - - ID3D12CommandQueue* GetCommandQueue() - { - return m_GraphicsQueue.GetCommandQueue(); - } - - void CreateNewCommandList( - D3D12_COMMAND_LIST_TYPE Type, - ID3D12GraphicsCommandList** List, - ID3D12CommandAllocator** Allocator); - - // Test to see if a fence has already been reached - bool IsFenceComplete(uint64_t FenceValue) - { - return GetQueue(D3D12_COMMAND_LIST_TYPE(FenceValue >> 56)).IsFenceComplete(FenceValue); - } - - // The CPU will wait for a fence to reach a specified value - void WaitForFence(uint64_t FenceValue); - - // The CPU will wait for all command queues to empty (so that the GPU is idle) - void IdleGPU(void) - { - if (m_GraphicsQueue.IsReady()) - m_GraphicsQueue.WaitForIdle(); - - if (m_ComputeQueue.IsReady()) - m_ComputeQueue.WaitForIdle(); - - if (m_CopyQueue.IsReady()) - m_CopyQueue.WaitForIdle(); - } - -private: - - ID3D12Device* m_Device; - - CommandQueue m_GraphicsQueue; - CommandQueue m_ComputeQueue; - CommandQueue m_CopyQueue; -}; diff --git a/xess/samples/xess_demo/MiniEngine/Core/CommandSignature.cpp b/xess/samples/xess_demo/MiniEngine/Core/CommandSignature.cpp deleted file mode 100644 index 78dfe34..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/CommandSignature.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "CommandSignature.h" -#include "RootSignature.h" -#include "GraphicsCore.h" - -using namespace Graphics; - -void CommandSignature::Finalize( const RootSignature* RootSignature ) -{ - if (m_Finalized) - return; - - UINT ByteStride = 0; - bool RequiresRootSignature = false; - - for (UINT i = 0; i < m_NumParameters; ++i) - { - switch (m_ParamArray[i].GetDesc().Type) - { - case D3D12_INDIRECT_ARGUMENT_TYPE_DRAW: - ByteStride += sizeof(D3D12_DRAW_ARGUMENTS); - break; - case D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED: - ByteStride += sizeof(D3D12_DRAW_INDEXED_ARGUMENTS); - break; - case D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH: - ByteStride += sizeof(D3D12_DISPATCH_ARGUMENTS); - break; - case D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT: - ByteStride += m_ParamArray[i].GetDesc().Constant.Num32BitValuesToSet * 4; - RequiresRootSignature = true; - break; - case D3D12_INDIRECT_ARGUMENT_TYPE_VERTEX_BUFFER_VIEW: - ByteStride += sizeof(D3D12_VERTEX_BUFFER_VIEW); - break; - case D3D12_INDIRECT_ARGUMENT_TYPE_INDEX_BUFFER_VIEW: - ByteStride += sizeof(D3D12_INDEX_BUFFER_VIEW); - break; - case D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT_BUFFER_VIEW: - case D3D12_INDIRECT_ARGUMENT_TYPE_SHADER_RESOURCE_VIEW: - case D3D12_INDIRECT_ARGUMENT_TYPE_UNORDERED_ACCESS_VIEW: - ByteStride += 8; - RequiresRootSignature = true; - break; - } - } - - D3D12_COMMAND_SIGNATURE_DESC CommandSignatureDesc; - CommandSignatureDesc.ByteStride = ByteStride; - CommandSignatureDesc.NumArgumentDescs = m_NumParameters; - CommandSignatureDesc.pArgumentDescs = (const D3D12_INDIRECT_ARGUMENT_DESC*)m_ParamArray.get(); - CommandSignatureDesc.NodeMask = 1; - - Microsoft::WRL::ComPtr pOutBlob, pErrorBlob; - - ID3D12RootSignature* pRootSig = RootSignature ? RootSignature->GetSignature() : nullptr; - if (RequiresRootSignature) - { - ASSERT(pRootSig != nullptr); - } - else - { - pRootSig = nullptr; - } - - ASSERT_SUCCEEDED( g_Device->CreateCommandSignature(&CommandSignatureDesc, pRootSig, - MY_IID_PPV_ARGS(&m_Signature)) ); - - m_Signature->SetName(L"CommandSignature"); - - m_Finalized = TRUE; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/CommandSignature.h b/xess/samples/xess_demo/MiniEngine/Core/CommandSignature.h deleted file mode 100644 index 2436259..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/CommandSignature.h +++ /dev/null @@ -1,137 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - - -#pragma once - -#include "pch.h" - -class RootSignature; - -class IndirectParameter -{ - friend class CommandSignature; -public: - - IndirectParameter() - { - m_IndirectParam.Type = (D3D12_INDIRECT_ARGUMENT_TYPE)0xFFFFFFFF; - } - - void Draw(void) - { - m_IndirectParam.Type = D3D12_INDIRECT_ARGUMENT_TYPE_DRAW; - } - - void DrawIndexed(void) - { - m_IndirectParam.Type = D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED; - } - - void Dispatch(void) - { - m_IndirectParam.Type = D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH; - } - - void VertexBufferView(UINT Slot) - { - m_IndirectParam.Type = D3D12_INDIRECT_ARGUMENT_TYPE_VERTEX_BUFFER_VIEW; - m_IndirectParam.VertexBuffer.Slot = Slot; - } - - void IndexBufferView(void) - { - m_IndirectParam.Type = D3D12_INDIRECT_ARGUMENT_TYPE_INDEX_BUFFER_VIEW; - } - - void Constant(UINT RootParameterIndex, UINT DestOffsetIn32BitValues, UINT Num32BitValuesToSet) - { - m_IndirectParam.Type = D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT; - m_IndirectParam.Constant.RootParameterIndex = RootParameterIndex; - m_IndirectParam.Constant.DestOffsetIn32BitValues = DestOffsetIn32BitValues; - m_IndirectParam.Constant.Num32BitValuesToSet = Num32BitValuesToSet; - } - - void ConstantBufferView(UINT RootParameterIndex) - { - m_IndirectParam.Type = D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT_BUFFER_VIEW; - m_IndirectParam.ConstantBufferView.RootParameterIndex = RootParameterIndex; - } - - void ShaderResourceView(UINT RootParameterIndex) - { - m_IndirectParam.Type = D3D12_INDIRECT_ARGUMENT_TYPE_SHADER_RESOURCE_VIEW; - m_IndirectParam.ShaderResourceView.RootParameterIndex = RootParameterIndex; - } - - void UnorderedAccessView(UINT RootParameterIndex) - { - m_IndirectParam.Type = D3D12_INDIRECT_ARGUMENT_TYPE_UNORDERED_ACCESS_VIEW; - m_IndirectParam.UnorderedAccessView.RootParameterIndex = RootParameterIndex; - } - - const D3D12_INDIRECT_ARGUMENT_DESC& GetDesc( void ) const { return m_IndirectParam; } - -protected: - - D3D12_INDIRECT_ARGUMENT_DESC m_IndirectParam; -}; - -class CommandSignature -{ -public: - - CommandSignature( UINT NumParams = 0 ) : m_Finalized(FALSE), m_NumParameters(NumParams) - { - Reset(NumParams); - } - - void Destroy( void ) - { - m_Signature = nullptr; - m_ParamArray = nullptr; - } - - void Reset( UINT NumParams ) - { - if (NumParams > 0) - m_ParamArray.reset(new IndirectParameter[NumParams]); - else - m_ParamArray = nullptr; - - m_NumParameters = NumParams; - } - - IndirectParameter& operator[] ( size_t EntryIndex ) - { - ASSERT(EntryIndex < m_NumParameters); - return m_ParamArray.get()[EntryIndex]; - } - - const IndirectParameter& operator[] ( size_t EntryIndex ) const - { - ASSERT(EntryIndex < m_NumParameters); - return m_ParamArray.get()[EntryIndex]; - } - - void Finalize( const RootSignature* RootSignature = nullptr ); - - ID3D12CommandSignature* GetSignature() const { return m_Signature.Get(); } - -protected: - - BOOL m_Finalized; - UINT m_NumParameters; - std::unique_ptr m_ParamArray; - Microsoft::WRL::ComPtr m_Signature; -}; diff --git a/xess/samples/xess_demo/MiniEngine/Core/Core.vcxproj b/xess/samples/xess_demo/MiniEngine/Core/Core.vcxproj deleted file mode 100644 index 6cef52c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Core.vcxproj +++ /dev/null @@ -1,517 +0,0 @@ - - - - - Debug - x64 - - - Profile - x64 - - - Release - x64 - - - - Core - {86A58508-0D6A-4786-A32F-01A301FDC6F3} - en-US - Win32Proj - 16.0 - 10.0.19041.0 - Native - - - - StaticLibrary - v142 - Unicode - false - false - - - - - - - - - - - - - - Use - pch.h - true - - - - - d3d11.lib;dxguid.lib;winmm.lib;comctl32.lib;%(AdditionalDependencies) - Windows - true - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - NotUsing - NotUsing - NotUsing - - - NotUsing - NotUsing - NotUsing - - - NotUsing - NotUsing - NotUsing - - - NotUsing - NotUsing - NotUsing - - - NotUsing - NotUsing - NotUsing - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Pixel - - - - - - - Pixel - - - Pixel - - - Pixel - - - Pixel - - - - - - - - - - Pixel - - - - - - - Pixel - - - - - - Pixel - - - Pixel - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Pixel - - - - - - - - - - - - - - - - - - - - - - - - - Pixel - Pixel - Pixel - - - Vertex - Vertex - Vertex - - - - - - - Pixel - - - Pixel - - - - Pixel - - - - Pixel - - - - Pixel - - - - - - - - - Pixel - Pixel - Pixel - - - - - Vertex - - - - Pixel - - - - - - - - - - - - - - - - - - - - - - - - - Vertex - - - Vertex - - - Pixel - - - Vertex - - - Pixel - - - Pixel - - - - Pixel - - - Pixel - - - Vertex - - - Vertex - - - Pixel - - - Pixel - - - - - Pixel - - - Pixel - - - Vertex - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ..\..\Packages\zlib-msvc-x64.1.2.11.8900\build\native\include;..\..\Packages\directxtex_desktop_win10.2021.8.2.1\include;..\..\Packages\WinPixEventRuntime.1.0.210818001\Include\WinPixEventRuntime;%(AdditionalIncludeDirectories) - _GAMING_DESKTOP;__WRL_NO_DEFAULT_LIB__;%(PreprocessorDefinitions) - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Core/Core.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Core/Core.vcxproj.filters deleted file mode 100644 index 9ee9fc5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Core.vcxproj.filters +++ /dev/null @@ -1,746 +0,0 @@ - - - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ThirdParty\imgui - - - ThirdParty\imgui - - - ThirdParty\imgui - - - ThirdParty\imgui - - - ThirdParty\imgui - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ThirdParty\imgui - - - ThirdParty\imgui - - - - - - - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - - - {c5df3e3a-73f5-4b5b-8688-112163941bea} - - - {c1be24e0-cb6a-4300-94a1-95e6baebcb93} - - - {3eb8d61d-4ab5-4c53-8d6f-30894e12c39f} - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Core/Cube.cpp b/xess/samples/xess_demo/MiniEngine/Core/Cube.cpp deleted file mode 100644 index 8532c74..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Cube.cpp +++ /dev/null @@ -1,113 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): Jack Elliott -// - -#include "pch.h" -#include "Cube.h" - -namespace Graphics -{ - namespace Shapes - { - namespace Cube - { - ByteAddressBuffer g_CubeVerts; - uint32_t g_NumVerts = 0; - uint32_t g_NumIndicies = 0; - - void InitializeCubeBuffers() - { - const XMFLOAT3 pos[] = - { - {-0.5f, -0.5f, -0.5f}, - {-0.5f, -0.5f, +0.5f}, - {+0.5f, -0.5f, +0.5f}, - {+0.5f, -0.5f, -0.5f}, - - {-0.5f, +0.5f, -0.5f}, - {-0.5f, +0.5f, +0.5f}, - {+0.5f, +0.5f, +0.5f}, - {+0.5f, +0.5f, -0.5f}, - }; - - const XMFLOAT2 uv[] = - { - {0, 0}, - {1, 0}, - {0, 1}, - {1, 1} - }; - - const XMFLOAT3 posX = { +1, +0, +0 }; - const XMFLOAT3 posY = { +0, +1, +0 }; - const XMFLOAT3 posZ = { +0, +0, +1 }; - const XMFLOAT3 negX = { -1, +0, +0 }; - const XMFLOAT3 negY = { +0, -1, +0 }; - const XMFLOAT3 negZ = { +0, +0, -1 }; - - CubeVertex verts[] = - { - { pos[4], uv[0], negZ, posX, posY }, //Front - { pos[7], uv[1], negZ, posX, posY }, - { pos[0], uv[2], negZ, posX, posY }, - { pos[0], uv[2], negZ, posX, posY }, - { pos[7], uv[1], negZ, posX, posY }, - { pos[3], uv[3], negZ, posX, posY }, - - { pos[7], uv[0], posX, posZ, posY }, //Right - { pos[6], uv[1], posX, posZ, posY }, - { pos[3], uv[2], posX, posZ, posY }, - { pos[3], uv[2], posX, posZ, posY }, - { pos[6], uv[1], posX, posZ, posY }, - { pos[2], uv[3], posX, posZ, posY }, - - { pos[6], uv[0], posZ, negX, posY }, //Back - { pos[5], uv[1], posZ, negX, posY }, - { pos[2], uv[2], posZ, negX, posY }, - { pos[2], uv[2], posZ, negX, posY }, - { pos[5], uv[1], posZ, negX, posY }, - { pos[1], uv[3], posZ, negX, posY }, - - { pos[5], uv[0], negX, posZ, posY }, //Left - { pos[4], uv[1], negX, posZ, posY }, - { pos[1], uv[2], negX, posZ, posY }, - { pos[1], uv[2], negX, posZ, posY }, - { pos[4], uv[1], negX, posZ, posY }, - { pos[0], uv[3], negX, posZ, posY }, - - { pos[5], uv[0], posY, posX, posZ }, //Top - { pos[6], uv[1], posY, posX, posZ }, - { pos[4], uv[2], posY, posX, posZ }, - { pos[4], uv[2], posY, posX, posZ }, - { pos[6], uv[1], posY, posX, posZ }, - { pos[7], uv[3], posY, posX, posZ }, - - { pos[0], uv[0], negY, posX, posZ }, //Bottom - { pos[3], uv[1], negY, posX, posZ }, - { pos[1], uv[2], negY, posX, posZ }, - { pos[1], uv[2], negY, posX, posZ }, - { pos[3], uv[1], negY, posX, posZ }, - { pos[2], uv[3], negY, posX, posZ }, - }; - - g_NumVerts = _countof(verts); - - g_CubeVerts.Create(L"Cube Vertices", _countof(verts), sizeof(verts[0]), verts); - } - - void DestroyCubeBuffers() - { - g_CubeVerts.Destroy(); - } - } - } -} \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Core/Cube.h b/xess/samples/xess_demo/MiniEngine/Core/Cube.h deleted file mode 100644 index 433b9a1..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Cube.h +++ /dev/null @@ -1,42 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): Jack Elliott -// - -#pragma once - -#include "GpuBuffer.h" -#include "GraphicsCore.h" - -namespace Graphics -{ - namespace Shapes - { - namespace Cube - { - struct CubeVertex - { - XMFLOAT3 position; - XMFLOAT2 texcoord; - XMFLOAT3 normal; - XMFLOAT3 tangent; - XMFLOAT3 bitangent; - }; - - extern ByteAddressBuffer g_CubeVerts; - extern uint32_t g_NumVerts; - extern uint32_t g_NumIndicies; - - void InitializeCubeBuffers(); - void DestroyCubeBuffers(); - } - } -} \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Core/DDSTextureLoader.cpp b/xess/samples/xess_demo/MiniEngine/Core/DDSTextureLoader.cpp deleted file mode 100644 index 4f4a733..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/DDSTextureLoader.cpp +++ /dev/null @@ -1,1350 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//-------------------------------------------------------------------------------------- -// -// Functions for loading a DDS texture and creating a Direct3D runtime resource for it -// -// Note these functions are useful as a light-weight runtime loader for DDS files. For -// a full-featured DDS file reader, writer, and texture processing pipeline see -// the 'Texconv' sample and the 'DirectXTex' library. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -// http://go.microsoft.com/fwlink/?LinkId=248929 -//-------------------------------------------------------------------------------------- - -#include "pch.h" - -#include "DDSTextureLoader.h" - -#include "dds.h" -#include "GpuResource.h" -#include "GraphicsCore.h" -#include "CommandContext.h" -#include "Utility.h" - -struct handle_closer { void operator()(HANDLE h) { if (h) CloseHandle(h); } }; -typedef public std::unique_ptr ScopedHandle; -inline HANDLE safe_handle( HANDLE h ) { return (h == INVALID_HANDLE_VALUE) ? 0 : h; } - - -//-------------------------------------------------------------------------------------- -static HRESULT LoadTextureDataFromFile( _In_z_ const wchar_t* fileName, - std::unique_ptr& ddsData, - DDS_HEADER** header, - uint8_t** bitData, - size_t* bitSize - ) -{ - if (!header || !bitData || !bitSize) - { - return E_POINTER; - } - - // open the file -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile( safe_handle( CreateFile2( fileName, - GENERIC_READ, - FILE_SHARE_READ, - OPEN_EXISTING, - nullptr ) ) ); -#else - ScopedHandle hFile( safe_handle( CreateFileW( fileName, - GENERIC_READ, - FILE_SHARE_READ, - nullptr, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - nullptr ) ) ); -#endif - - if ( !hFile ) - { - return HRESULT_FROM_WIN32( GetLastError() ); - } - - // Get the file size - LARGE_INTEGER FileSize = { 0 }; - -#if (_WIN32_WINNT >= _WIN32_WINNT_VISTA) - FILE_STANDARD_INFO fileInfo; - if ( !GetFileInformationByHandleEx( hFile.get(), FileStandardInfo, &fileInfo, sizeof(fileInfo) ) ) - { - return HRESULT_FROM_WIN32( GetLastError() ); - } - FileSize = fileInfo.EndOfFile; -#else - GetFileSizeEx( hFile.get(), &FileSize ); -#endif - - // File is too big for 32-bit allocation, so reject read - if (FileSize.HighPart > 0) - { - return E_FAIL; - } - - // Need at least enough data to fill the header and magic number to be a valid DDS - if (FileSize.LowPart < ( sizeof(DDS_HEADER) + sizeof(uint32_t) ) ) - { - return E_FAIL; - } - - // create enough space for the file data - ddsData.reset( new (std::nothrow) uint8_t[ FileSize.LowPart ] ); - if (!ddsData) - { - return E_OUTOFMEMORY; - } - - // read the data in - DWORD BytesRead = 0; - if (!ReadFile( hFile.get(), - ddsData.get(), - FileSize.LowPart, - &BytesRead, - nullptr - )) - { - return HRESULT_FROM_WIN32( GetLastError() ); - } - - if (BytesRead < FileSize.LowPart) - { - return E_FAIL; - } - - // DDS files always start with the same magic number ("DDS ") - uint32_t dwMagicNumber = *( const uint32_t* )( ddsData.get() ); - if (dwMagicNumber != DDS_MAGIC) - { - return E_FAIL; - } - - auto hdr = reinterpret_cast( ddsData.get() + sizeof( uint32_t ) ); - - // Verify header to validate DDS file - if (hdr->size != sizeof(DDS_HEADER) || - hdr->ddspf.size != sizeof(DDS_PIXELFORMAT)) - { - return E_FAIL; - } - - size_t offset = sizeof( uint32_t ) + sizeof( DDS_HEADER ); - - // Check for extensions - if (hdr->ddspf.flags & DDS_FOURCC) - { - if (MAKEFOURCC( 'D', 'X', '1', '0' ) == hdr->ddspf.fourCC) - offset += sizeof(DDS_HEADER_DXT10); - } - - // Must be long enough for all headers and magic value - if (FileSize.LowPart < offset) - return E_FAIL; - - // setup the pointers in the process request - *header = hdr; - *bitData = ddsData.get() + offset; - *bitSize = FileSize.LowPart - offset; - - return S_OK; -} - - -//-------------------------------------------------------------------------------------- -// Return the BPP for a particular format -//-------------------------------------------------------------------------------------- -size_t BitsPerPixel( _In_ DXGI_FORMAT fmt ) -{ - switch( fmt ) - { - case DXGI_FORMAT_R32G32B32A32_TYPELESS: - case DXGI_FORMAT_R32G32B32A32_FLOAT: - case DXGI_FORMAT_R32G32B32A32_UINT: - case DXGI_FORMAT_R32G32B32A32_SINT: - return 128; - - case DXGI_FORMAT_R32G32B32_TYPELESS: - case DXGI_FORMAT_R32G32B32_FLOAT: - case DXGI_FORMAT_R32G32B32_UINT: - case DXGI_FORMAT_R32G32B32_SINT: - return 96; - - case DXGI_FORMAT_R16G16B16A16_TYPELESS: - case DXGI_FORMAT_R16G16B16A16_FLOAT: - case DXGI_FORMAT_R16G16B16A16_UNORM: - case DXGI_FORMAT_R16G16B16A16_UINT: - case DXGI_FORMAT_R16G16B16A16_SNORM: - case DXGI_FORMAT_R16G16B16A16_SINT: - case DXGI_FORMAT_R32G32_TYPELESS: - case DXGI_FORMAT_R32G32_FLOAT: - case DXGI_FORMAT_R32G32_UINT: - case DXGI_FORMAT_R32G32_SINT: - case DXGI_FORMAT_R32G8X24_TYPELESS: - case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: - case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: - case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: - case DXGI_FORMAT_Y416: - case DXGI_FORMAT_Y210: - case DXGI_FORMAT_Y216: - return 64; - - case DXGI_FORMAT_R10G10B10A2_TYPELESS: - case DXGI_FORMAT_R10G10B10A2_UNORM: - case DXGI_FORMAT_R10G10B10A2_UINT: - case DXGI_FORMAT_R11G11B10_FLOAT: - case DXGI_FORMAT_R8G8B8A8_TYPELESS: - case DXGI_FORMAT_R8G8B8A8_UNORM: - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - case DXGI_FORMAT_R8G8B8A8_UINT: - case DXGI_FORMAT_R8G8B8A8_SNORM: - case DXGI_FORMAT_R8G8B8A8_SINT: - case DXGI_FORMAT_R16G16_TYPELESS: - case DXGI_FORMAT_R16G16_FLOAT: - case DXGI_FORMAT_R16G16_UNORM: - case DXGI_FORMAT_R16G16_UINT: - case DXGI_FORMAT_R16G16_SNORM: - case DXGI_FORMAT_R16G16_SINT: - case DXGI_FORMAT_R32_TYPELESS: - case DXGI_FORMAT_D32_FLOAT: - case DXGI_FORMAT_R32_FLOAT: - case DXGI_FORMAT_R32_UINT: - case DXGI_FORMAT_R32_SINT: - case DXGI_FORMAT_R24G8_TYPELESS: - case DXGI_FORMAT_D24_UNORM_S8_UINT: - case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: - case DXGI_FORMAT_X24_TYPELESS_G8_UINT: - case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: - case DXGI_FORMAT_R8G8_B8G8_UNORM: - case DXGI_FORMAT_G8R8_G8B8_UNORM: - case DXGI_FORMAT_B8G8R8A8_UNORM: - case DXGI_FORMAT_B8G8R8X8_UNORM: - case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: - case DXGI_FORMAT_B8G8R8A8_TYPELESS: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8X8_TYPELESS: - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - case DXGI_FORMAT_AYUV: - case DXGI_FORMAT_Y410: - case DXGI_FORMAT_YUY2: - return 32; - - case DXGI_FORMAT_P010: - case DXGI_FORMAT_P016: - return 24; - - case DXGI_FORMAT_R8G8_TYPELESS: - case DXGI_FORMAT_R8G8_UNORM: - case DXGI_FORMAT_R8G8_UINT: - case DXGI_FORMAT_R8G8_SNORM: - case DXGI_FORMAT_R8G8_SINT: - case DXGI_FORMAT_R16_TYPELESS: - case DXGI_FORMAT_R16_FLOAT: - case DXGI_FORMAT_D16_UNORM: - case DXGI_FORMAT_R16_UNORM: - case DXGI_FORMAT_R16_UINT: - case DXGI_FORMAT_R16_SNORM: - case DXGI_FORMAT_R16_SINT: - case DXGI_FORMAT_B5G6R5_UNORM: - case DXGI_FORMAT_B5G5R5A1_UNORM: - case DXGI_FORMAT_A8P8: - case DXGI_FORMAT_B4G4R4A4_UNORM: - return 16; - - case DXGI_FORMAT_NV12: - case DXGI_FORMAT_420_OPAQUE: - case DXGI_FORMAT_NV11: - return 12; - - case DXGI_FORMAT_R8_TYPELESS: - case DXGI_FORMAT_R8_UNORM: - case DXGI_FORMAT_R8_UINT: - case DXGI_FORMAT_R8_SNORM: - case DXGI_FORMAT_R8_SINT: - case DXGI_FORMAT_A8_UNORM: - case DXGI_FORMAT_AI44: - case DXGI_FORMAT_IA44: - case DXGI_FORMAT_P8: - return 8; - - case DXGI_FORMAT_R1_UNORM: - return 1; - - case DXGI_FORMAT_BC1_TYPELESS: - case DXGI_FORMAT_BC1_UNORM: - case DXGI_FORMAT_BC1_UNORM_SRGB: - case DXGI_FORMAT_BC4_TYPELESS: - case DXGI_FORMAT_BC4_UNORM: - case DXGI_FORMAT_BC4_SNORM: - return 4; - - case DXGI_FORMAT_BC2_TYPELESS: - case DXGI_FORMAT_BC2_UNORM: - case DXGI_FORMAT_BC2_UNORM_SRGB: - case DXGI_FORMAT_BC3_TYPELESS: - case DXGI_FORMAT_BC3_UNORM: - case DXGI_FORMAT_BC3_UNORM_SRGB: - case DXGI_FORMAT_BC5_TYPELESS: - case DXGI_FORMAT_BC5_UNORM: - case DXGI_FORMAT_BC5_SNORM: - case DXGI_FORMAT_BC6H_TYPELESS: - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - case DXGI_FORMAT_BC7_TYPELESS: - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: - return 8; - - default: - return 0; - } -} - - -//-------------------------------------------------------------------------------------- -// Get surface information for a particular format -//-------------------------------------------------------------------------------------- -static void GetSurfaceInfo( _In_ size_t width, - _In_ size_t height, - _In_ DXGI_FORMAT fmt, - _Out_opt_ size_t* outNumBytes, - _Out_opt_ size_t* outRowBytes, - _Out_opt_ size_t* outNumRows ) -{ - size_t numBytes = 0; - size_t rowBytes = 0; - size_t numRows = 0; - - bool bc = false; - bool packed = false; - bool planar = false; - size_t bpe = 0; - switch (fmt) - { - case DXGI_FORMAT_BC1_TYPELESS: - case DXGI_FORMAT_BC1_UNORM: - case DXGI_FORMAT_BC1_UNORM_SRGB: - case DXGI_FORMAT_BC4_TYPELESS: - case DXGI_FORMAT_BC4_UNORM: - case DXGI_FORMAT_BC4_SNORM: - bc=true; - bpe = 8; - break; - - case DXGI_FORMAT_BC2_TYPELESS: - case DXGI_FORMAT_BC2_UNORM: - case DXGI_FORMAT_BC2_UNORM_SRGB: - case DXGI_FORMAT_BC3_TYPELESS: - case DXGI_FORMAT_BC3_UNORM: - case DXGI_FORMAT_BC3_UNORM_SRGB: - case DXGI_FORMAT_BC5_TYPELESS: - case DXGI_FORMAT_BC5_UNORM: - case DXGI_FORMAT_BC5_SNORM: - case DXGI_FORMAT_BC6H_TYPELESS: - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - case DXGI_FORMAT_BC7_TYPELESS: - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: - bc = true; - bpe = 16; - break; - - case DXGI_FORMAT_R8G8_B8G8_UNORM: - case DXGI_FORMAT_G8R8_G8B8_UNORM: - case DXGI_FORMAT_YUY2: - packed = true; - bpe = 4; - break; - - case DXGI_FORMAT_Y210: - case DXGI_FORMAT_Y216: - packed = true; - bpe = 8; - break; - - case DXGI_FORMAT_NV12: - case DXGI_FORMAT_420_OPAQUE: - planar = true; - bpe = 2; - break; - - case DXGI_FORMAT_P010: - case DXGI_FORMAT_P016: - planar = true; - bpe = 4; - break; - - } - - if (bc) - { - size_t numBlocksWide = 0; - if (width > 0) - { - numBlocksWide = std::max( 1, (width + 3) / 4 ); - } - size_t numBlocksHigh = 0; - if (height > 0) - { - numBlocksHigh = std::max( 1, (height + 3) / 4 ); - } - rowBytes = numBlocksWide * bpe; - numRows = numBlocksHigh; - numBytes = rowBytes * numBlocksHigh; - } - else if (packed) - { - rowBytes = ( ( width + 1 ) >> 1 ) * bpe; - numRows = height; - numBytes = rowBytes * height; - } - else if ( fmt == DXGI_FORMAT_NV11 ) - { - rowBytes = ( ( width + 3 ) >> 2 ) * 4; - numRows = height * 2; // Direct3D makes this simplifying assumption, although it is larger than the 4:1:1 data - numBytes = rowBytes * numRows; - } - else if (planar) - { - rowBytes = ( ( width + 1 ) >> 1 ) * bpe; - numBytes = ( rowBytes * height ) + ( ( rowBytes * height + 1 ) >> 1 ); - numRows = height + ( ( height + 1 ) >> 1 ); - } - else - { - size_t bpp = BitsPerPixel( fmt ); - rowBytes = ( width * bpp + 7 ) / 8; // round up to nearest byte - numRows = height; - numBytes = rowBytes * height; - } - - if (outNumBytes) - { - *outNumBytes = numBytes; - } - if (outRowBytes) - { - *outRowBytes = rowBytes; - } - if (outNumRows) - { - *outNumRows = numRows; - } -} - - -//-------------------------------------------------------------------------------------- -#define ISBITMASK( r,g,b,a ) ( ddpf.RBitMask == r && ddpf.GBitMask == g && ddpf.BBitMask == b && ddpf.ABitMask == a ) - -static DXGI_FORMAT GetDXGIFormat( const DDS_PIXELFORMAT& ddpf ) -{ - if (ddpf.flags & DDS_RGB) - { - // Note that sRGB formats are written using the "DX10" extended header - - switch (ddpf.RGBBitCount) - { - case 32: - if (ISBITMASK(0x000000ff,0x0000ff00,0x00ff0000,0xff000000)) - { - return DXGI_FORMAT_R8G8B8A8_UNORM; - } - - if (ISBITMASK(0x00ff0000,0x0000ff00,0x000000ff,0xff000000)) - { - return DXGI_FORMAT_B8G8R8A8_UNORM; - } - - if (ISBITMASK(0x00ff0000,0x0000ff00,0x000000ff,0x00000000)) - { - return DXGI_FORMAT_B8G8R8X8_UNORM; - } - - // No DXGI format maps to ISBITMASK(0x000000ff,0x0000ff00,0x00ff0000,0x00000000) aka D3DFMT_X8B8G8R8 - - // Note that many common DDS reader/writers (including D3DX) swap the - // the RED/BLUE masks for 10:10:10:2 formats. We assumme - // below that the 'backwards' header mask is being used since it is most - // likely written by D3DX. The more robust solution is to use the 'DX10' - // header extension and specify the DXGI_FORMAT_R10G10B10A2_UNORM format directly - - // For 'correct' writers, this should be 0x000003ff,0x000ffc00,0x3ff00000 for RGB data - if (ISBITMASK(0x3ff00000,0x000ffc00,0x000003ff,0xc0000000)) - { - return DXGI_FORMAT_R10G10B10A2_UNORM; - } - - // No DXGI format maps to ISBITMASK(0x000003ff,0x000ffc00,0x3ff00000,0xc0000000) aka D3DFMT_A2R10G10B10 - - if (ISBITMASK(0x0000ffff,0xffff0000,0x00000000,0x00000000)) - { - return DXGI_FORMAT_R16G16_UNORM; - } - - if (ISBITMASK(0xffffffff,0x00000000,0x00000000,0x00000000)) - { - // Only 32-bit color channel format in D3D9 was R32F - return DXGI_FORMAT_R32_FLOAT; // D3DX writes this out as a FourCC of 114 - } - break; - - case 24: - // No 24bpp DXGI formats aka D3DFMT_R8G8B8 - break; - - case 16: - if (ISBITMASK(0x7c00,0x03e0,0x001f,0x8000)) - { - return DXGI_FORMAT_B5G5R5A1_UNORM; - } - if (ISBITMASK(0xf800,0x07e0,0x001f,0x0000)) - { - return DXGI_FORMAT_B5G6R5_UNORM; - } - - // No DXGI format maps to ISBITMASK(0x7c00,0x03e0,0x001f,0x0000) aka D3DFMT_X1R5G5B5 - - if (ISBITMASK(0x0f00,0x00f0,0x000f,0xf000)) - { - return DXGI_FORMAT_B4G4R4A4_UNORM; - } - - // No DXGI format maps to ISBITMASK(0x0f00,0x00f0,0x000f,0x0000) aka D3DFMT_X4R4G4B4 - - // No 3:3:2, 3:3:2:8, or paletted DXGI formats aka D3DFMT_A8R3G3B2, D3DFMT_R3G3B2, D3DFMT_P8, D3DFMT_A8P8, etc. - break; - } - } - else if (ddpf.flags & DDS_LUMINANCE) - { - if (8 == ddpf.RGBBitCount) - { - if (ISBITMASK(0x000000ff,0x00000000,0x00000000,0x00000000)) - { - return DXGI_FORMAT_R8_UNORM; // D3DX10/11 writes this out as DX10 extension - } - - // No DXGI format maps to ISBITMASK(0x0f,0x00,0x00,0xf0) aka D3DFMT_A4L4 - } - - if (16 == ddpf.RGBBitCount) - { - if (ISBITMASK(0x0000ffff,0x00000000,0x00000000,0x00000000)) - { - return DXGI_FORMAT_R16_UNORM; // D3DX10/11 writes this out as DX10 extension - } - if (ISBITMASK(0x000000ff,0x00000000,0x00000000,0x0000ff00)) - { - return DXGI_FORMAT_R8G8_UNORM; // D3DX10/11 writes this out as DX10 extension - } - } - } - else if (ddpf.flags & DDS_ALPHA) - { - if (8 == ddpf.RGBBitCount) - { - return DXGI_FORMAT_A8_UNORM; - } - } - else if (ddpf.flags & DDS_FOURCC) - { - if (MAKEFOURCC( 'D', 'X', 'T', '1' ) == ddpf.fourCC) - { - return DXGI_FORMAT_BC1_UNORM; - } - if (MAKEFOURCC( 'D', 'X', 'T', '3' ) == ddpf.fourCC) - { - return DXGI_FORMAT_BC2_UNORM; - } - if (MAKEFOURCC( 'D', 'X', 'T', '5' ) == ddpf.fourCC) - { - return DXGI_FORMAT_BC3_UNORM; - } - - // While pre-mulitplied alpha isn't directly supported by the DXGI formats, - // they are basically the same as these BC formats so they can be mapped - if (MAKEFOURCC( 'D', 'X', 'T', '2' ) == ddpf.fourCC) - { - return DXGI_FORMAT_BC2_UNORM; - } - if (MAKEFOURCC( 'D', 'X', 'T', '4' ) == ddpf.fourCC) - { - return DXGI_FORMAT_BC3_UNORM; - } - - if (MAKEFOURCC( 'A', 'T', 'I', '1' ) == ddpf.fourCC) - { - return DXGI_FORMAT_BC4_UNORM; - } - if (MAKEFOURCC( 'B', 'C', '4', 'U' ) == ddpf.fourCC) - { - return DXGI_FORMAT_BC4_UNORM; - } - if (MAKEFOURCC( 'B', 'C', '4', 'S' ) == ddpf.fourCC) - { - return DXGI_FORMAT_BC4_SNORM; - } - - if (MAKEFOURCC( 'A', 'T', 'I', '2' ) == ddpf.fourCC) - { - return DXGI_FORMAT_BC5_UNORM; - } - if (MAKEFOURCC( 'B', 'C', '5', 'U' ) == ddpf.fourCC) - { - return DXGI_FORMAT_BC5_UNORM; - } - if (MAKEFOURCC( 'B', 'C', '5', 'S' ) == ddpf.fourCC) - { - return DXGI_FORMAT_BC5_SNORM; - } - - // BC6H and BC7 are written using the "DX10" extended header - - if (MAKEFOURCC( 'R', 'G', 'B', 'G' ) == ddpf.fourCC) - { - return DXGI_FORMAT_R8G8_B8G8_UNORM; - } - if (MAKEFOURCC( 'G', 'R', 'G', 'B' ) == ddpf.fourCC) - { - return DXGI_FORMAT_G8R8_G8B8_UNORM; - } - - if (MAKEFOURCC('Y','U','Y','2') == ddpf.fourCC) - { - return DXGI_FORMAT_YUY2; - } - - // Check for D3DFORMAT enums being set here - switch( ddpf.fourCC ) - { - case 36: // D3DFMT_A16B16G16R16 - return DXGI_FORMAT_R16G16B16A16_UNORM; - - case 110: // D3DFMT_Q16W16V16U16 - return DXGI_FORMAT_R16G16B16A16_SNORM; - - case 111: // D3DFMT_R16F - return DXGI_FORMAT_R16_FLOAT; - - case 112: // D3DFMT_G16R16F - return DXGI_FORMAT_R16G16_FLOAT; - - case 113: // D3DFMT_A16B16G16R16F - return DXGI_FORMAT_R16G16B16A16_FLOAT; - - case 114: // D3DFMT_R32F - return DXGI_FORMAT_R32_FLOAT; - - case 115: // D3DFMT_G32R32F - return DXGI_FORMAT_R32G32_FLOAT; - - case 116: // D3DFMT_A32B32G32R32F - return DXGI_FORMAT_R32G32B32A32_FLOAT; - } - } - - return DXGI_FORMAT_UNKNOWN; -} - - -//-------------------------------------------------------------------------------------- -static DXGI_FORMAT MakeSRGB( _In_ DXGI_FORMAT format ) -{ - switch( format ) - { - case DXGI_FORMAT_R8G8B8A8_UNORM: - return DXGI_FORMAT_R8G8B8A8_UNORM_SRGB; - - case DXGI_FORMAT_BC1_UNORM: - return DXGI_FORMAT_BC1_UNORM_SRGB; - - case DXGI_FORMAT_BC2_UNORM: - return DXGI_FORMAT_BC2_UNORM_SRGB; - - case DXGI_FORMAT_BC3_UNORM: - return DXGI_FORMAT_BC3_UNORM_SRGB; - - case DXGI_FORMAT_B8G8R8A8_UNORM: - return DXGI_FORMAT_B8G8R8A8_UNORM_SRGB; - - case DXGI_FORMAT_B8G8R8X8_UNORM: - return DXGI_FORMAT_B8G8R8X8_UNORM_SRGB; - - case DXGI_FORMAT_BC7_UNORM: - return DXGI_FORMAT_BC7_UNORM_SRGB; - - default: - return format; - } -} - - -//-------------------------------------------------------------------------------------- -static HRESULT FillInitData( _In_ size_t width, - _In_ size_t height, - _In_ size_t depth, - _In_ size_t mipCount, - _In_ size_t arraySize, - _In_ DXGI_FORMAT format, - _In_ size_t maxsize, - _In_ size_t bitSize, - _In_reads_bytes_(bitSize) const uint8_t* bitData, - _Out_ size_t& twidth, - _Out_ size_t& theight, - _Out_ size_t& tdepth, - _Out_ size_t& skipMip, - _Out_writes_(mipCount*arraySize) D3D12_SUBRESOURCE_DATA* initData ) -{ - if ( !bitData || !initData ) - { - return E_POINTER; - } - - skipMip = 0; - twidth = 0; - theight = 0; - tdepth = 0; - - size_t NumBytes = 0; - size_t RowBytes = 0; - const uint8_t* pSrcBits = bitData; - const uint8_t* pEndBits = bitData + bitSize; - - size_t index = 0; - for( size_t j = 0; j < arraySize; j++ ) - { - size_t w = width; - size_t h = height; - size_t d = depth; - for( size_t i = 0; i < mipCount; i++ ) - { - GetSurfaceInfo( w, - h, - format, - &NumBytes, - &RowBytes, - nullptr - ); - - if ( (mipCount <= 1) || !maxsize || (w <= maxsize && h <= maxsize && d <= maxsize) ) - { - if ( !twidth ) - { - twidth = w; - theight = h; - tdepth = d; - } - - assert(index < mipCount * arraySize); - _Analysis_assume_(index < mipCount * arraySize); - initData[index].pData = ( const void* )pSrcBits; - initData[index].RowPitch = static_cast( RowBytes ); - initData[index].SlicePitch = static_cast( NumBytes ); - ++index; - } - else if ( !j ) - { - // Count number of skipped mipmaps (first item only) - ++skipMip; - } - - if (pSrcBits + (NumBytes*d) > pEndBits) - { - return HRESULT_FROM_WIN32( ERROR_HANDLE_EOF ); - } - - pSrcBits += NumBytes * d; - - w = w >> 1; - h = h >> 1; - d = d >> 1; - if (w == 0) - { - w = 1; - } - if (h == 0) - { - h = 1; - } - if (d == 0) - { - d = 1; - } - } - } - - return (index > 0) ? S_OK : E_FAIL; -} - - -//-------------------------------------------------------------------------------------- -static HRESULT CreateD3DResources( _In_ ID3D12Device* d3dDevice, - _In_ uint32_t resDim, - _In_ size_t width, - _In_ size_t height, - _In_ size_t depth, - _In_ size_t mipCount, - _In_ size_t arraySize, - _In_ DXGI_FORMAT format, - _In_ bool forceSRGB, - _In_ bool isCubeMap, - _Outptr_opt_ ID3D12Resource** texture, - _In_ D3D12_CPU_DESCRIPTOR_HANDLE textureView ) -{ - if ( !d3dDevice ) - return E_POINTER; - - HRESULT hr = E_FAIL; - - if ( forceSRGB ) - { - format = MakeSRGB( format ); - } - - D3D12_HEAP_PROPERTIES HeapProps; - HeapProps.Type = D3D12_HEAP_TYPE_DEFAULT; - HeapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; - HeapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; - HeapProps.CreationNodeMask = 1; - HeapProps.VisibleNodeMask = 1; - - D3D12_RESOURCE_DESC ResourceDesc; - ResourceDesc.Alignment = 0; - ResourceDesc.Width = static_cast( width ); - ResourceDesc.Height = static_cast( height ); - ResourceDesc.DepthOrArraySize = static_cast( arraySize ); - ResourceDesc.MipLevels = static_cast( mipCount ); - ResourceDesc.Format = format; - ResourceDesc.SampleDesc.Count = 1; - ResourceDesc.SampleDesc.Quality = 0; - ResourceDesc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN; - ResourceDesc.Flags = D3D12_RESOURCE_FLAG_NONE; - - switch ( resDim ) - { - case D3D12_RESOURCE_DIMENSION_TEXTURE1D: - { - ResourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE1D; - - ID3D12Resource* tex = nullptr; - hr = d3dDevice->CreateCommittedResource( &HeapProps, D3D12_HEAP_FLAG_NONE, &ResourceDesc, - D3D12_RESOURCE_STATE_COPY_DEST, nullptr, MY_IID_PPV_ARGS(&tex)); - - if (SUCCEEDED( hr ) && tex != nullptr) - { - D3D12_SHADER_RESOURCE_VIEW_DESC SRVDesc = {}; - SRVDesc.Format = format; - SRVDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; - - if (arraySize > 1) - { - SRVDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE1DARRAY; - SRVDesc.Texture1DArray.MipLevels = (!mipCount) ? -1 : ResourceDesc.MipLevels; - SRVDesc.Texture1DArray.ArraySize = static_cast( arraySize ); - } - else - { - SRVDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE1D; - SRVDesc.Texture1D.MipLevels = (!mipCount) ? -1 : ResourceDesc.MipLevels; - } - - d3dDevice->CreateShaderResourceView( tex, &SRVDesc, textureView ); - - if (texture != nullptr) - { - *texture = tex; - } - else - { - tex->SetName(L"DDS Texture (1D)"); - tex->Release(); - } - } - } - break; - - case D3D12_RESOURCE_DIMENSION_TEXTURE2D: - { - ResourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; - - ID3D12Resource* tex = nullptr; - hr = d3dDevice->CreateCommittedResource( &HeapProps, D3D12_HEAP_FLAG_NONE, &ResourceDesc, - D3D12_RESOURCE_STATE_COPY_DEST, nullptr, MY_IID_PPV_ARGS(&tex)); - - if (SUCCEEDED( hr ) && tex != 0) - { - D3D12_SHADER_RESOURCE_VIEW_DESC SRVDesc = {}; - SRVDesc.Format = format; - SRVDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; - - if ( isCubeMap ) - { - if (arraySize > 6) - { - SRVDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBEARRAY; - SRVDesc.TextureCubeArray.MipLevels = (!mipCount) ? -1 : ResourceDesc.MipLevels; - - // Earlier we set arraySize to (NumCubes * 6) - SRVDesc.TextureCubeArray.NumCubes = static_cast( arraySize / 6 ); - } - else - { - SRVDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBE; - SRVDesc.TextureCube.MipLevels = (!mipCount) ? -1 : ResourceDesc.MipLevels; - } - } - else if (arraySize > 1) - { - SRVDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DARRAY; - SRVDesc.Texture2DArray.MipLevels = (!mipCount) ? -1 : ResourceDesc.MipLevels; - SRVDesc.Texture2DArray.ArraySize = static_cast( arraySize ); - } - else - { - SRVDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; - SRVDesc.Texture2D.MipLevels = (!mipCount) ? -1 : ResourceDesc.MipLevels; - SRVDesc.Texture2D.MostDetailedMip = 0; - } - - d3dDevice->CreateShaderResourceView( tex, &SRVDesc, textureView ); - - if (texture != nullptr) - { - *texture = tex; - } - else - { - tex->SetName(L"DDS Texture (2D)"); - tex->Release(); - } - } - } - break; - - case D3D12_RESOURCE_DIMENSION_TEXTURE3D: - { - ResourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE3D; - ResourceDesc.DepthOrArraySize = static_cast( depth ); - - ID3D12Resource* tex = nullptr; - hr = d3dDevice->CreateCommittedResource( &HeapProps, D3D12_HEAP_FLAG_NONE, &ResourceDesc, - D3D12_RESOURCE_STATE_COPY_DEST, nullptr, MY_IID_PPV_ARGS(&tex)); - - if (SUCCEEDED( hr ) && tex != nullptr) - { - D3D12_SHADER_RESOURCE_VIEW_DESC SRVDesc = {}; - SRVDesc.Format = format; - SRVDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; - - SRVDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE3D; - SRVDesc.Texture3D.MipLevels = (!mipCount) ? -1 : ResourceDesc.MipLevels; - SRVDesc.Texture3D.MostDetailedMip = 0; - - d3dDevice->CreateShaderResourceView( tex, &SRVDesc, textureView ); - - if (texture != nullptr) - { - *texture = tex; - } - else - { - tex->SetName(L"DDS Texture (3D)"); - tex->Release(); - } - } - } - break; - } - - return hr; -} - -//-------------------------------------------------------------------------------------- -static HRESULT CreateTextureFromDDS( _In_ ID3D12Device* d3dDevice, - _In_ const DDS_HEADER* header, - _In_reads_bytes_(bitSize) const uint8_t* bitData, - _In_ size_t bitSize, - _In_ size_t maxsize, - _In_ bool forceSRGB, - _Outptr_opt_ ID3D12Resource** texture, - _In_ D3D12_CPU_DESCRIPTOR_HANDLE textureView ) -{ - HRESULT hr = S_OK; - - UINT width = header->width; - UINT height = header->height; - UINT depth = header->depth; - - uint32_t resDim = D3D12_RESOURCE_DIMENSION_UNKNOWN; - UINT arraySize = 1; - DXGI_FORMAT format = DXGI_FORMAT_UNKNOWN; - bool isCubeMap = false; - - size_t mipCount = header->mipMapCount; - if (0 == mipCount) - { - mipCount = 1; - } - - if ((header->ddspf.flags & DDS_FOURCC) && (MAKEFOURCC( 'D', 'X', '1', '0' ) == header->ddspf.fourCC )) - { - auto d3d10ext = reinterpret_cast( (const char*)header + sizeof(DDS_HEADER) ); - - arraySize = d3d10ext->arraySize; - if (arraySize == 0) - { - return HRESULT_FROM_WIN32( ERROR_INVALID_DATA ); - } - - switch( d3d10ext->dxgiFormat ) - { - case DXGI_FORMAT_AI44: - case DXGI_FORMAT_IA44: - case DXGI_FORMAT_P8: - case DXGI_FORMAT_A8P8: - return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); - - default: - if ( BitsPerPixel( d3d10ext->dxgiFormat ) == 0 ) - { - return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); - } - } - - format = d3d10ext->dxgiFormat; - - switch ( d3d10ext->resourceDimension ) - { - case D3D12_RESOURCE_DIMENSION_TEXTURE1D: - // D3DX writes 1D textures with a fixed Height of 1 - if ((header->flags & DDS_HEIGHT) && height != 1) - { - return HRESULT_FROM_WIN32( ERROR_INVALID_DATA ); - } - height = depth = 1; - break; - - case D3D12_RESOURCE_DIMENSION_TEXTURE2D: - if (d3d10ext->miscFlag & DDS_RESOURCE_MISC_TEXTURECUBE) - { - arraySize *= 6; - isCubeMap = true; - } - depth = 1; - break; - - case D3D12_RESOURCE_DIMENSION_TEXTURE3D: - if (!(header->flags & DDS_HEADER_FLAGS_VOLUME)) - { - return HRESULT_FROM_WIN32( ERROR_INVALID_DATA ); - } - - if (arraySize > 1) - { - return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); - } - break; - - default: - return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); - } - - resDim = d3d10ext->resourceDimension; - } - else - { - format = GetDXGIFormat( header->ddspf ); - - if (format == DXGI_FORMAT_UNKNOWN) - { - return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); - } - - if (header->flags & DDS_HEADER_FLAGS_VOLUME) - { - resDim = D3D12_RESOURCE_DIMENSION_TEXTURE3D; - } - else - { - if (header->caps2 & DDS_CUBEMAP) - { - // We require all six faces to be defined - if ((header->caps2 & DDS_CUBEMAP_ALLFACES ) != DDS_CUBEMAP_ALLFACES) - { - return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); - } - - arraySize = 6; - isCubeMap = true; - } - - depth = 1; - resDim = D3D12_RESOURCE_DIMENSION_TEXTURE2D; - - // Note there's no way for a legacy Direct3D 9 DDS to express a '1D' texture - } - - assert( BitsPerPixel( format ) != 0 ); - } - - // Bound sizes (for security purposes we don't trust DDS file metadata larger than the D3D 11.x hardware requirements) - if (mipCount > D3D12_REQ_MIP_LEVELS) - { - return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); - } - - switch ( resDim ) - { - case D3D12_RESOURCE_DIMENSION_TEXTURE1D: - if ((arraySize > D3D12_REQ_TEXTURE1D_ARRAY_AXIS_DIMENSION) || - (width > D3D12_REQ_TEXTURE1D_U_DIMENSION) ) - { - return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); - } - break; - - case D3D12_RESOURCE_DIMENSION_TEXTURE2D: - if ( isCubeMap ) - { - // This is the right bound because we set arraySize to (NumCubes*6) above - if ((arraySize > D3D12_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION) || - (width > D3D12_REQ_TEXTURECUBE_DIMENSION) || - (height > D3D12_REQ_TEXTURECUBE_DIMENSION)) - { - return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); - } - } - else if ((arraySize > D3D12_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION) || - (width > D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION) || - (height > D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION)) - { - return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); - } - break; - - case D3D12_RESOURCE_DIMENSION_TEXTURE3D: - if ((arraySize > 1) || - (width > D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION) || - (height > D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION) || - (depth > D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION) ) - { - return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); - } - break; - - default: - return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); - } - - { - // Create the texture - UINT subresourceCount = static_cast(mipCount) * arraySize; - std::unique_ptr initData( new (std::nothrow) D3D12_SUBRESOURCE_DATA[subresourceCount] ); - if ( !initData ) - { - return E_OUTOFMEMORY; - } - - size_t skipMip = 0; - size_t twidth = 0; - size_t theight = 0; - size_t tdepth = 0; - hr = FillInitData( width, height, depth, mipCount, arraySize, format, maxsize, bitSize, bitData, - twidth, theight, tdepth, skipMip, initData.get() ); - - if ( SUCCEEDED(hr) ) - { - hr = CreateD3DResources( d3dDevice, resDim, twidth, theight, tdepth, mipCount - skipMip, arraySize, - format, forceSRGB, - isCubeMap, texture, textureView ); - - if ( FAILED(hr) && !maxsize && (mipCount > 1) ) - { - // Retry with a maxsize determined by feature level - maxsize = (resDim == D3D12_RESOURCE_DIMENSION_TEXTURE3D) - ? 2048 /*D3D10_REQ_TEXTURE3D_U_V_OR_W_DIMENSION*/ - : 8192 /*D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION*/; - - hr = FillInitData( width, height, depth, mipCount, arraySize, format, maxsize, bitSize, bitData, - twidth, theight, tdepth, skipMip, initData.get() ); - if ( SUCCEEDED(hr) ) - { - hr = CreateD3DResources( d3dDevice, resDim, twidth, theight, tdepth, mipCount - skipMip, arraySize, - format, forceSRGB, - isCubeMap, texture, textureView ); - } - } - } - - if (SUCCEEDED(hr)) - { - GpuResource DestTexture(*texture, D3D12_RESOURCE_STATE_COPY_DEST); - CommandContext::InitializeTexture(DestTexture, subresourceCount, initData.get()); - } - } - - return hr; -} - - -//-------------------------------------------------------------------------------------- -static DDS_ALPHA_MODE GetAlphaMode( _In_ const DDS_HEADER* header ) -{ - if ( header->ddspf.flags & DDS_FOURCC ) - { - if ( MAKEFOURCC( 'D', 'X', '1', '0' ) == header->ddspf.fourCC ) - { - auto d3d10ext = reinterpret_cast( (const char*)header + sizeof(DDS_HEADER) ); - auto mode = static_cast( d3d10ext->miscFlags2 & DDS_MISC_FLAGS2_ALPHA_MODE_MASK ); - switch( mode ) - { - case DDS_ALPHA_MODE_STRAIGHT: - case DDS_ALPHA_MODE_PREMULTIPLIED: - case DDS_ALPHA_MODE_OPAQUE: - case DDS_ALPHA_MODE_CUSTOM: - return mode; - } - } - else if ( ( MAKEFOURCC( 'D', 'X', 'T', '2' ) == header->ddspf.fourCC ) - || ( MAKEFOURCC( 'D', 'X', 'T', '4' ) == header->ddspf.fourCC ) ) - { - return DDS_ALPHA_MODE_PREMULTIPLIED; - } - } - - return DDS_ALPHA_MODE_UNKNOWN; -} - - -_Use_decl_annotations_ -HRESULT CreateDDSTextureFromMemory( - ID3D12Device* d3dDevice, - const uint8_t* ddsData, - size_t ddsDataSize, - size_t maxsize, - bool forceSRGB, - ID3D12Resource** texture, - D3D12_CPU_DESCRIPTOR_HANDLE textureView, - DDS_ALPHA_MODE* alphaMode ) -{ - if ( texture ) - { - *texture = nullptr; - } - - if ( alphaMode ) - { - *alphaMode = DDS_ALPHA_MODE_UNKNOWN; - } - - if (!d3dDevice || !ddsData) - { - return E_INVALIDARG; - } - - // Validate DDS file in memory - if (ddsDataSize < (sizeof(uint32_t) + sizeof(DDS_HEADER))) - { - return E_FAIL; - } - - uint32_t dwMagicNumber = *( const uint32_t* )( ddsData ); - if (dwMagicNumber != DDS_MAGIC) - { - return E_FAIL; - } - - auto header = reinterpret_cast( ddsData + sizeof( uint32_t ) ); - - // Verify header to validate DDS file - if (header->size != sizeof(DDS_HEADER) || - header->ddspf.size != sizeof(DDS_PIXELFORMAT)) - { - return E_FAIL; - } - - size_t offset = sizeof(DDS_HEADER) + sizeof(uint32_t); - - // Check for extensions - if (header->ddspf.flags & DDS_FOURCC) - { - if (MAKEFOURCC( 'D', 'X', '1', '0' ) == header->ddspf.fourCC) - offset += sizeof(DDS_HEADER_DXT10); - } - - // Must be long enough for all headers and magic value - if (ddsDataSize < offset) - return E_FAIL; - - HRESULT hr = CreateTextureFromDDS( d3dDevice, - header, ddsData + offset, ddsDataSize - offset, maxsize, - forceSRGB, texture, textureView ); - if ( SUCCEEDED(hr) ) - { - if (texture != nullptr && *texture != nullptr) - { - (*texture)->SetName(L"DDSTextureLoader"); - } - - if ( alphaMode ) - *alphaMode = GetAlphaMode( header ); - } - - return hr; -} - - -_Use_decl_annotations_ -HRESULT CreateDDSTextureFromFile( - ID3D12Device* d3dDevice, - const wchar_t* fileName, - size_t maxsize, - bool forceSRGB, - ID3D12Resource** texture, - D3D12_CPU_DESCRIPTOR_HANDLE textureView, - DDS_ALPHA_MODE* alphaMode ) -{ - if ( texture ) - { - *texture = nullptr; - } - - if ( alphaMode ) - { - *alphaMode = DDS_ALPHA_MODE_UNKNOWN; - } - - if (!d3dDevice || !fileName) - { - return E_INVALIDARG; - } - - DDS_HEADER* header = nullptr; - uint8_t* bitData = nullptr; - size_t bitSize = 0; - - std::unique_ptr ddsData; - HRESULT hr = LoadTextureDataFromFile( fileName, ddsData, &header, &bitData, &bitSize ); - if (FAILED(hr)) - { - return hr; - } - - hr = CreateTextureFromDDS( d3dDevice, - header, bitData, bitSize, maxsize, - forceSRGB, texture, textureView ); - - if ( alphaMode ) - *alphaMode = GetAlphaMode( header ); - - if (SUCCEEDED(hr)) - (*texture)->SetName(fileName); - - return hr; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/DDSTextureLoader.h b/xess/samples/xess_demo/MiniEngine/Core/DDSTextureLoader.h deleted file mode 100644 index 7812cb5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/DDSTextureLoader.h +++ /dev/null @@ -1,58 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//-------------------------------------------------------------------------------------- -// -// Functions for loading a DDS texture and creating a Direct3D runtime resource for it -// -// Note these functions are useful as a light-weight runtime loader for DDS files. For -// a full-featured DDS file reader, writer, and texture processing pipeline see -// the 'Texconv' sample and the 'DirectXTex' library. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -// http://go.microsoft.com/fwlink/?LinkId=248929 -//-------------------------------------------------------------------------------------- - -#pragma once - -#include - -#pragma warning(push) -#pragma warning(disable : 4005) -#include -#pragma warning(pop) - -enum DDS_ALPHA_MODE -{ - DDS_ALPHA_MODE_UNKNOWN = 0, - DDS_ALPHA_MODE_STRAIGHT = 1, - DDS_ALPHA_MODE_PREMULTIPLIED = 2, - DDS_ALPHA_MODE_OPAQUE = 3, - DDS_ALPHA_MODE_CUSTOM = 4, -}; - -HRESULT __cdecl CreateDDSTextureFromMemory( _In_ ID3D12Device* d3dDevice, - _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, - _In_ size_t ddsDataSize, - _In_ size_t maxsize, - _In_ bool forceSRGB, - _Outptr_opt_ ID3D12Resource** texture, - _In_ D3D12_CPU_DESCRIPTOR_HANDLE textureView, - _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr - ); - -HRESULT __cdecl CreateDDSTextureFromFile( _In_ ID3D12Device* d3dDevice, - _In_z_ const wchar_t* szFileName, - _In_ size_t maxsize, - _In_ bool forceSRGB, - _Outptr_opt_ ID3D12Resource** texture, - _In_ D3D12_CPU_DESCRIPTOR_HANDLE textureView, - _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr - ); - -size_t BitsPerPixel(_In_ DXGI_FORMAT fmt); diff --git a/xess/samples/xess_demo/MiniEngine/Core/DepthBuffer.cpp b/xess/samples/xess_demo/MiniEngine/Core/DepthBuffer.cpp deleted file mode 100644 index 180dadd..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/DepthBuffer.cpp +++ /dev/null @@ -1,123 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "DepthBuffer.h" -#include "GraphicsCore.h" -#include "EsramAllocator.h" -#include "DescriptorHeap.h" - -using namespace Graphics; - -void DepthBuffer::Create( const std::wstring& Name, uint32_t Width, uint32_t Height, DXGI_FORMAT Format, D3D12_GPU_VIRTUAL_ADDRESS VidMemPtr ) -{ - Create(Name, Width, Height, 1, Format, VidMemPtr); -} - -void DepthBuffer::Create( const std::wstring& Name, uint32_t Width, uint32_t Height, uint32_t Samples, DXGI_FORMAT Format, D3D12_GPU_VIRTUAL_ADDRESS VidMemPtr ) -{ - D3D12_RESOURCE_DESC ResourceDesc = DescribeTex2D(Width, Height, 1, 1, Format, D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL); - ResourceDesc.SampleDesc.Count = Samples; - - D3D12_CLEAR_VALUE ClearValue = {}; - ClearValue.Format = Format; - CreateTextureResource(Graphics::g_Device, Name, ResourceDesc, ClearValue, VidMemPtr); - CreateDerivedViews(Graphics::g_Device, Format); -} - -void DepthBuffer::Create( const std::wstring& Name, uint32_t Width, uint32_t Height, DXGI_FORMAT Format, EsramAllocator& Allocator ) -{ - Create(Name, Width, Height, 1, Format, Allocator); -} - -void DepthBuffer::Create( const std::wstring& Name, uint32_t Width, uint32_t Height, uint32_t Samples, DXGI_FORMAT Format, EsramAllocator& ) -{ - Create(Name, Width, Height, Samples, Format); -} - -void DepthBuffer::CreateDerivedViews( ID3D12Device* Device, DXGI_FORMAT Format ) -{ - ID3D12Resource* Resource = m_pResource.Get(); - - D3D12_DEPTH_STENCIL_VIEW_DESC dsvDesc; - dsvDesc.Format = GetDSVFormat(Format); - if (Resource->GetDesc().SampleDesc.Count == 1) - { - dsvDesc.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2D; - dsvDesc.Texture2D.MipSlice = 0; - } - else - { - dsvDesc.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2DMS; - } - - if (m_hDSV[0].ptr == D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN) - { - m_hDSV[0] = Graphics::AllocateDescriptor(D3D12_DESCRIPTOR_HEAP_TYPE_DSV); - m_hDSV[1] = Graphics::AllocateDescriptor(D3D12_DESCRIPTOR_HEAP_TYPE_DSV); - } - - dsvDesc.Flags = D3D12_DSV_FLAG_NONE; - Device->CreateDepthStencilView(Resource, &dsvDesc, m_hDSV[0]); - - dsvDesc.Flags = D3D12_DSV_FLAG_READ_ONLY_DEPTH; - Device->CreateDepthStencilView(Resource, &dsvDesc, m_hDSV[1]); - - DXGI_FORMAT stencilReadFormat = GetStencilFormat(Format); - if (stencilReadFormat != DXGI_FORMAT_UNKNOWN) - { - if (m_hDSV[2].ptr == D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN) - { - m_hDSV[2] = Graphics::AllocateDescriptor(D3D12_DESCRIPTOR_HEAP_TYPE_DSV); - m_hDSV[3] = Graphics::AllocateDescriptor(D3D12_DESCRIPTOR_HEAP_TYPE_DSV); - } - - dsvDesc.Flags = D3D12_DSV_FLAG_READ_ONLY_STENCIL; - Device->CreateDepthStencilView(Resource, &dsvDesc, m_hDSV[2]); - - dsvDesc.Flags = D3D12_DSV_FLAG_READ_ONLY_DEPTH | D3D12_DSV_FLAG_READ_ONLY_STENCIL; - Device->CreateDepthStencilView(Resource, &dsvDesc, m_hDSV[3]); - } - else - { - m_hDSV[2] = m_hDSV[0]; - m_hDSV[3] = m_hDSV[1]; - } - - if (m_hDepthSRV.ptr == D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN) - m_hDepthSRV = Graphics::AllocateDescriptor(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - - // Create the shader resource view - D3D12_SHADER_RESOURCE_VIEW_DESC SRVDesc = {}; - SRVDesc.Format = GetDepthFormat(Format); - if (dsvDesc.ViewDimension == D3D12_DSV_DIMENSION_TEXTURE2D) - { - SRVDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; - SRVDesc.Texture2D.MipLevels = 1; - } - else - { - SRVDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DMS; - } - SRVDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; - Device->CreateShaderResourceView( Resource, &SRVDesc, m_hDepthSRV ); - - if (stencilReadFormat != DXGI_FORMAT_UNKNOWN) - { - if (m_hStencilSRV.ptr == D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN) - m_hStencilSRV = Graphics::AllocateDescriptor(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - - SRVDesc.Format = stencilReadFormat; - Device->CreateShaderResourceView( Resource, &SRVDesc, m_hStencilSRV ); - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/DepthBuffer.h b/xess/samples/xess_demo/MiniEngine/Core/DepthBuffer.h deleted file mode 100644 index cf875a1..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/DepthBuffer.h +++ /dev/null @@ -1,70 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "PixelBuffer.h" - -class EsramAllocator; - -class DepthBuffer : public PixelBuffer -{ -public: - DepthBuffer( float ClearDepth = 0.0f, uint8_t ClearStencil = 0 ) - : m_ClearDepth(ClearDepth), m_ClearStencil(ClearStencil) - { - m_hDSV[0].ptr = D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN; - m_hDSV[1].ptr = D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN; - m_hDSV[2].ptr = D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN; - m_hDSV[3].ptr = D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN; - m_hDepthSRV.ptr = D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN; - m_hStencilSRV.ptr = D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN; - } - - // Create a depth buffer. If an address is supplied, memory will not be allocated. - // The vmem address allows you to alias buffers (which can be especially useful for - // reusing ESRAM across a frame.) - void Create( const std::wstring& Name, uint32_t Width, uint32_t Height, DXGI_FORMAT Format, - D3D12_GPU_VIRTUAL_ADDRESS VidMemPtr = D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN ); - - // Create a depth buffer. Memory will be allocated in ESRAM (on Xbox One). On Windows, - // this functions the same as Create() without a video address. - void Create( const std::wstring& Name, uint32_t Width, uint32_t Height, DXGI_FORMAT Format, - EsramAllocator& Allocator ); - - void Create(const std::wstring& Name, uint32_t Width, uint32_t Height, uint32_t NumSamples, DXGI_FORMAT Format, - D3D12_GPU_VIRTUAL_ADDRESS VidMemPtr = D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN ); - void Create( const std::wstring& Name, uint32_t Width, uint32_t Height, uint32_t NumSamples, DXGI_FORMAT Format, - EsramAllocator& Allocator ); - - // Get pre-created CPU-visible descriptor handles - const D3D12_CPU_DESCRIPTOR_HANDLE& GetDSV() const { return m_hDSV[0]; } - const D3D12_CPU_DESCRIPTOR_HANDLE& GetDSV_DepthReadOnly() const { return m_hDSV[1]; } - const D3D12_CPU_DESCRIPTOR_HANDLE& GetDSV_StencilReadOnly() const { return m_hDSV[2]; } - const D3D12_CPU_DESCRIPTOR_HANDLE& GetDSV_ReadOnly() const { return m_hDSV[3]; } - const D3D12_CPU_DESCRIPTOR_HANDLE& GetDepthSRV() const { return m_hDepthSRV; } - const D3D12_CPU_DESCRIPTOR_HANDLE& GetStencilSRV() const { return m_hStencilSRV; } - - float GetClearDepth() const { return m_ClearDepth; } - uint8_t GetClearStencil() const { return m_ClearStencil; } - -protected: - - void CreateDerivedViews( ID3D12Device* Device, DXGI_FORMAT Format ); - - float m_ClearDepth; - uint8_t m_ClearStencil; - D3D12_CPU_DESCRIPTOR_HANDLE m_hDSV[4]; - D3D12_CPU_DESCRIPTOR_HANDLE m_hDepthSRV; - D3D12_CPU_DESCRIPTOR_HANDLE m_hStencilSRV; -}; diff --git a/xess/samples/xess_demo/MiniEngine/Core/DepthOfField.cpp b/xess/samples/xess_demo/MiniEngine/Core/DepthOfField.cpp deleted file mode 100644 index 6c80d03..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/DepthOfField.cpp +++ /dev/null @@ -1,358 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "DepthOfField.h" -#include "RootSignature.h" -#include "PipelineState.h" -#include "CommandContext.h" -#include "BufferManager.h" -#include "TemporalEffects.h" - -#include "CompiledShaders/DoFPass1CS.h" -#include "CompiledShaders/DoFTilePassCS.h" -#include "CompiledShaders/DoFTilePassFixupCS.h" -#include "CompiledShaders/DoFPreFilterCS.h" -#include "CompiledShaders/DoFPreFilterFastCS.h" -#include "CompiledShaders/DoFPreFilterFixupCS.h" -#include "CompiledShaders/DoFPass2CS.h" -#include "CompiledShaders/DoFPass2FastCS.h" -#include "CompiledShaders/DoFPass2FixupCS.h" -#include "CompiledShaders/DoFPass2DebugCS.h" -#include "CompiledShaders/DoFMedianFilterCS.h" -#include "CompiledShaders/DoFMedianFilterSepAlphaCS.h" -#include "CompiledShaders/DoFMedianFilterFixupCS.h" -#include "CompiledShaders/DoFCombineCS.h" -#include "CompiledShaders/DoFCombine2CS.h" -#include "CompiledShaders/DoFCombineFastCS.h" -#include "CompiledShaders/DoFCombineFast2CS.h" -#include "CompiledShaders/DoFDebugRedCS.h" -#include "CompiledShaders/DoFDebugGreenCS.h" -#include "CompiledShaders/DoFDebugBlueCS.h" - -using namespace Graphics; - -namespace DepthOfField -{ - BoolVar Enable("Graphics/Depth of Field/Enable", false); - BoolVar EnablePreFilter("Graphics/Depth of Field/PreFilter", true); - BoolVar MedianFilter("Graphics/Depth of Field/Median Filter", true); - BoolVar MedianAlpha("Graphics/Depth of Field/Median Alpha", false); - NumVar FocalDepth("Graphics/Depth of Field/Focal Center", 0.1f, 0.0f, 1.0f, 0.01f); - NumVar FocalRange("Graphics/Depth of Field/Focal Radius", 0.1f, 0.0f, 1.0f, 0.01f); - NumVar ForegroundRange("Graphics/Depth of Field/FG Range", 100.0f, 10.0f, 1000.0f, 10.0f); - NumVar AntiSparkleWeight("Graphics/Depth of Field/AntiSparkle", 1.0f, 0.0f, 10.0f, 1.0f); - const char* DebugLabels[] = { "Off", "Foreground", "Background", "FG Alpha", "CoC" }; - EnumVar DebugMode("Graphics/Depth of Field/Debug Mode", 0, _countof(DebugLabels), DebugLabels); - BoolVar DebugTiles("Graphics/Depth of Field/Debug Tiles", false); - BoolVar ForceSlow("Graphics/Depth of Field/Force Slow Path", false); - BoolVar ForceFast("Graphics/Depth of Field/Force Fast Path", false); - - RootSignature s_RootSignature; - - ComputePSO s_DoFPass1CS(L"DOF: Pass 1 CS"); // Responsible for classifying tiles (1st pass) - ComputePSO s_DoFTilePassCS(L"DOF: Tile Pass CS"); // Disperses tile info to its neighbors (3x3) - ComputePSO s_DoFTilePassFixupCS(L"DOF: Tile Pass Fixup CS"); // Searches for straggler tiles to "fixup" - - ComputePSO s_DoFPreFilterCS(L"DOF: Pre-Filter CS"); // Full pre-filter with variable focus - ComputePSO s_DoFPreFilterFastCS(L"DOF: Pre-Filter Fast CS"); // Pre-filter assuming near-constant focus - ComputePSO s_DoFPreFilterFixupCS(L"DOF: Pre-Filter Fixup CS"); // Pass through colors for completely in focus tile - - ComputePSO s_DoFPass2CS(L"DOF: Pass 2 CS"); // Perform full CoC convolution pass - ComputePSO s_DoFPass2FastCS(L"DOF: Pass 2 Fast CS"); // Perform color-only convolution for near-constant focus - ComputePSO s_DoFPass2FixupCS(L"DOF: Pass 2 Fixup CS"); // Pass through colors again - ComputePSO s_DoFPass2DebugCS(L"DOF: Pass 2 Debug CS"); // Full pass 2 shader with options for debugging - - ComputePSO s_DoFMedianFilterCS(L"DOF: Median Filter CS"); // 3x3 median filter to reduce fireflies - ComputePSO s_DoFMedianFilterSepAlphaCS(L"DOF: Median Filter Separate Alpha CS"); // 3x3 median filter to reduce fireflies (separate filter on alpha) - ComputePSO s_DoFMedianFilterFixupCS(L"DOF: Median Filter Fixup CS"); // Pass through without performing median - - ComputePSO s_DoFCombineCS(L"DOF: Combine CS"); // Combine DoF blurred buffer with focused color buffer - ComputePSO s_DoFCombineFastCS(L"DOF: Combine Fast CS"); // Upsample DoF blurred buffer - ComputePSO s_DoFDebugRedCS(L"DOF: Debug Red CS"); // Output red to entire tile for debugging - ComputePSO s_DoFDebugGreenCS(L"DOF: Debug Green CS"); // Output green to entire tile for debugging - ComputePSO s_DoFDebugBlueCS(L"DOF: Debug Blue CS"); // Output blue to entire tile for debugging - - IndirectArgsBuffer s_IndirectParameters; -} - -void DepthOfField::Initialize( void ) -{ - s_RootSignature.Reset(4, 3); - s_RootSignature.InitStaticSampler(0, SamplerPointBorderDesc); - s_RootSignature.InitStaticSampler(1, SamplerPointClampDesc); - s_RootSignature.InitStaticSampler(2, SamplerLinearClampDesc); - s_RootSignature[0].InitAsConstantBuffer(0); - s_RootSignature[1].InitAsDescriptorRange(D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 6); - s_RootSignature[2].InitAsDescriptorRange(D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 0, 3); - s_RootSignature[3].InitAsConstants(1, 1); - s_RootSignature.Finalize(L"Depth of Field"); - -#define CreatePSO( ObjName, ShaderByteCode ) \ - ObjName.SetRootSignature(s_RootSignature); \ - ObjName.SetComputeShader(ShaderByteCode, sizeof(ShaderByteCode) ); \ - ObjName.Finalize(); - - CreatePSO( s_DoFPass1CS, g_pDoFPass1CS); - CreatePSO( s_DoFTilePassCS, g_pDoFTilePassCS); - CreatePSO( s_DoFTilePassFixupCS, g_pDoFTilePassFixupCS); - CreatePSO( s_DoFPreFilterCS, g_pDoFPreFilterCS); - CreatePSO( s_DoFPreFilterFastCS, g_pDoFPreFilterFastCS); - CreatePSO( s_DoFPreFilterFixupCS, g_pDoFPreFilterFixupCS); - CreatePSO( s_DoFPass2CS, g_pDoFPass2CS); - CreatePSO( s_DoFPass2FastCS, g_pDoFPass2FastCS); - CreatePSO( s_DoFPass2FixupCS, g_pDoFPass2FixupCS); - CreatePSO( s_DoFPass2DebugCS, g_pDoFPass2DebugCS); - CreatePSO( s_DoFMedianFilterCS, g_pDoFMedianFilterCS ); - CreatePSO( s_DoFMedianFilterSepAlphaCS, g_pDoFMedianFilterSepAlphaCS ); - CreatePSO( s_DoFMedianFilterFixupCS, g_pDoFMedianFilterFixupCS ); - if (g_bTypedUAVLoadSupport_R11G11B10_FLOAT) - { - CreatePSO(s_DoFCombineCS, g_pDoFCombine2CS); - CreatePSO(s_DoFCombineFastCS, g_pDoFCombineFast2CS); - } - else - { - CreatePSO(s_DoFCombineCS, g_pDoFCombineCS); - CreatePSO(s_DoFCombineFastCS, g_pDoFCombineFastCS); - } - CreatePSO( s_DoFDebugRedCS, g_pDoFDebugRedCS ); - CreatePSO( s_DoFDebugGreenCS, g_pDoFDebugGreenCS ); - CreatePSO( s_DoFDebugBlueCS, g_pDoFDebugBlueCS ); - -#undef CreatePSO - - __declspec(align(16)) const uint32_t initArgs[9] = { 0, 1, 1, 0, 1, 1, 0, 1, 1 }; - s_IndirectParameters.Create(L"DoF Indirect Parameters", 3, sizeof(D3D12_DISPATCH_ARGUMENTS), initArgs); -} - -void DepthOfField::Shutdown( void ) -{ - s_IndirectParameters.Destroy(); -} - -void DepthOfField::Render( CommandContext& BaseContext, float /*NearClipDist*/, float FarClipDist ) -{ - ScopedTimer _prof(L"Depth of Field", BaseContext); - - if (!g_bTypedUAVLoadSupport_R11G11B10_FLOAT) - { - WARN_ONCE_IF(!g_bTypedUAVLoadSupport_R11G11B10_FLOAT, "Unable to perform final pass of DoF without support for R11G11B10F UAV loads"); - Enable = false; - } - - ComputeContext& Context = BaseContext.GetComputeContext(); - Context.SetRootSignature(s_RootSignature); - - ColorBuffer& LinearDepth = g_LinearDepth[ TemporalEffects::GetFrameIndexMod2() ]; - - uint32_t BufferWidth = (uint32_t)LinearDepth.GetWidth(); - uint32_t BufferHeight = (uint32_t)LinearDepth.GetHeight(); - uint32_t TiledWidth = (uint32_t)g_DoFTileClass[0].GetWidth(); - uint32_t TiledHeight = (uint32_t)g_DoFTileClass[0].GetHeight(); - - __declspec(align(16)) struct DoFConstantBuffer - { - float FocalCenter, FocalSpread; - float FocalMinZ, FocalMaxZ; - float RcpBufferWidth, RcpBufferHeight; - uint32_t BufferWidth, BufferHeight; - int32_t HalfWidth, HalfHeight; - uint32_t TiledWidth, TiledHeight; - float RcpTiledWidth, RcpTiledHeight; - uint32_t DebugState, DisablePreFilter; - float FGRange, RcpFGRange, AntiSparkleFilterStrength; - }; - DoFConstantBuffer cbuffer = - { - (float)FocalDepth, 1.0f / (float)FocalRange, - (float)FocalDepth - (float)FocalRange, (float)FocalDepth + (float)FocalRange, - 1.0f / BufferWidth, 1.0f / BufferHeight, - BufferWidth, BufferHeight, - (int32_t)Math::DivideByMultiple(BufferWidth, 2), (int32_t)Math::DivideByMultiple(BufferHeight, 2), - TiledWidth, TiledHeight, - 1.0f / TiledWidth, 1.0f / TiledHeight, - (uint32_t)DebugMode, EnablePreFilter ? 0u : 1u, - ForegroundRange / FarClipDist, FarClipDist / ForegroundRange, (float)AntiSparkleWeight - }; - Context.SetDynamicConstantBufferView(0, sizeof(cbuffer), &cbuffer); - - { - ScopedTimer _prof2(L"DoF Tiling", Context); - - // Initial pass to discover max CoC and closest depth in 16x16 tiles - Context.TransitionResource(LinearDepth, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_DoFTileClass[0], D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.SetPipelineState(s_DoFPass1CS); - Context.SetDynamicDescriptor(1, 0, LinearDepth.GetSRV()); - Context.SetDynamicDescriptor(2, 0, g_DoFTileClass[0].GetUAV()); - Context.Dispatch2D(BufferWidth, BufferHeight, 16, 16); - - Context.ResetCounter(g_DoFWorkQueue); - Context.ResetCounter(g_DoFFastQueue); - Context.ResetCounter(g_DoFFixupQueue); - - // 3x3 filter to spread max CoC and closest depth to neighboring tiles - Context.TransitionResource(g_DoFTileClass[0], D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_DoFTileClass[1], D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_DoFWorkQueue, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_DoFFastQueue, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.SetPipelineState(s_DoFTilePassCS); - Context.SetDynamicDescriptor(1, 0, g_DoFTileClass[0].GetSRV()); - Context.SetDynamicDescriptor(2, 0, g_DoFTileClass[1].GetUAV()); - Context.SetDynamicDescriptor(2, 1, g_DoFWorkQueue.GetUAV()); - Context.SetDynamicDescriptor(2, 2, g_DoFFastQueue.GetUAV()); - Context.Dispatch2D(TiledWidth, TiledHeight); - - Context.TransitionResource(g_DoFTileClass[1], D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_DoFFixupQueue, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.SetPipelineState(s_DoFTilePassFixupCS); - Context.SetDynamicDescriptor(1, 0, g_DoFTileClass[1].GetSRV()); - Context.SetDynamicDescriptor(2, 0, g_DoFFixupQueue.GetUAV()); - Context.Dispatch2D(TiledWidth, TiledHeight); - - Context.TransitionResource(g_DoFWorkQueue, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.CopyCounter(s_IndirectParameters, 0, g_DoFWorkQueue); - - Context.TransitionResource(g_DoFFastQueue, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.CopyCounter(s_IndirectParameters, 12, g_DoFFastQueue); - - Context.TransitionResource(g_DoFFixupQueue, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.CopyCounter(s_IndirectParameters, 24, g_DoFFixupQueue); - - Context.TransitionResource(s_IndirectParameters, D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT); - } - - { - ScopedTimer _prof2(L"DoF PreFilter", Context); - - if (ForceFast && !DebugMode) - Context.SetPipelineState(s_DoFPreFilterFastCS); - else - Context.SetPipelineState(s_DoFPreFilterCS); - Context.TransitionResource(g_SceneColorBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_DoFPresortBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_DoFPrefilter, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.SetDynamicDescriptor(1, 0, LinearDepth.GetSRV()); - Context.SetDynamicDescriptor(1, 1, g_DoFTileClass[1].GetSRV()); - Context.SetDynamicDescriptor(1, 2, g_SceneColorBuffer.GetSRV()); - Context.SetDynamicDescriptor(1, 3, g_DoFWorkQueue.GetSRV()); - Context.SetDynamicDescriptor(2, 0, g_DoFPresortBuffer.GetUAV()); - Context.SetDynamicDescriptor(2, 1, g_DoFPrefilter.GetUAV()); - Context.DispatchIndirect(s_IndirectParameters, 0); - - if (!ForceSlow && !DebugMode) - Context.SetPipelineState(s_DoFPreFilterFastCS); - Context.SetDynamicDescriptor(1, 3, g_DoFFastQueue.GetSRV()); - Context.DispatchIndirect(s_IndirectParameters, 12); - - Context.SetPipelineState(s_DoFPreFilterFixupCS); - Context.SetDynamicDescriptor(1, 3, g_DoFFixupQueue.GetSRV()); - Context.DispatchIndirect(s_IndirectParameters, 24); - } - - { - ScopedTimer _prof2(L"DoF Main Pass", Context); - - Context.TransitionResource(g_DoFPrefilter, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_DoFBlurColor[0], D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_DoFBlurAlpha[0], D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - if (ForceFast && !DebugMode) - Context.SetPipelineState(s_DoFPass2FastCS); - else - Context.SetPipelineState(DebugMode > 0 ? s_DoFPass2DebugCS : s_DoFPass2CS); - Context.SetDynamicDescriptor(1, 0, g_DoFPrefilter.GetSRV()); - Context.SetDynamicDescriptor(1, 1, g_DoFPresortBuffer.GetSRV()); - Context.SetDynamicDescriptor(1, 2, g_DoFTileClass[1].GetSRV()); - Context.SetDynamicDescriptor(1, 3, g_DoFWorkQueue.GetSRV()); - Context.SetDynamicDescriptor(2, 0, g_DoFBlurColor[0].GetUAV()); - Context.SetDynamicDescriptor(2, 1, g_DoFBlurAlpha[0].GetUAV()); - Context.DispatchIndirect(s_IndirectParameters, 0); - - if (!ForceSlow && !DebugMode) - Context.SetPipelineState(s_DoFPass2FastCS); - Context.SetDynamicDescriptor(1, 3, g_DoFFastQueue.GetSRV()); - Context.DispatchIndirect(s_IndirectParameters, 12); - - Context.SetPipelineState(s_DoFPass2FixupCS); - Context.SetDynamicDescriptor(1, 3, g_DoFFixupQueue.GetSRV()); - Context.DispatchIndirect(s_IndirectParameters, 24); - } - - { - ScopedTimer _prof2(L"DoF Median Pass", Context); - Context.TransitionResource(g_DoFBlurColor[0], D3D12_RESOURCE_STATE_GENERIC_READ); - Context.TransitionResource(g_DoFBlurAlpha[0], D3D12_RESOURCE_STATE_GENERIC_READ); - - if (MedianFilter) - { - Context.TransitionResource(g_DoFBlurColor[1], D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_DoFBlurAlpha[1], D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.SetPipelineState(MedianAlpha ? s_DoFMedianFilterSepAlphaCS : s_DoFMedianFilterCS); - Context.SetDynamicDescriptor(1, 0, g_DoFBlurColor[0].GetSRV()); - Context.SetDynamicDescriptor(1, 1, g_DoFBlurAlpha[0].GetSRV()); - Context.SetDynamicDescriptor(1, 2, g_DoFWorkQueue.GetSRV()); - Context.SetDynamicDescriptor(2, 0, g_DoFBlurColor[1].GetUAV()); - Context.SetDynamicDescriptor(2, 1, g_DoFBlurAlpha[1].GetUAV()); - Context.DispatchIndirect(s_IndirectParameters, 0); - - Context.SetDynamicDescriptor(1, 2, g_DoFFastQueue.GetSRV()); - Context.DispatchIndirect(s_IndirectParameters, 12); - - Context.SetPipelineState(s_DoFMedianFilterFixupCS); - Context.SetDynamicDescriptor(1, 2, g_DoFFixupQueue.GetSRV()); - Context.DispatchIndirect(s_IndirectParameters, 24); - - Context.TransitionResource(g_DoFBlurColor[1], D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_DoFBlurAlpha[1], D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - } - } - - { - ScopedTimer _prof2(L"DoF Final Combine", Context); - Context.TransitionResource(g_SceneColorBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - - if (DebugTiles) - { - Context.SetPipelineState(s_DoFDebugRedCS); - Context.SetDynamicDescriptor(1, 5, g_DoFWorkQueue.GetSRV()); - Context.SetDynamicDescriptor(2, 0, g_SceneColorBuffer.GetUAV()); - Context.DispatchIndirect(s_IndirectParameters, 0); - - Context.SetPipelineState(s_DoFDebugGreenCS); - Context.SetDynamicDescriptor(1, 5, g_DoFFastQueue.GetSRV()); - Context.DispatchIndirect(s_IndirectParameters, 12); - - Context.SetPipelineState(s_DoFDebugBlueCS); - Context.SetDynamicDescriptor(1, 5, g_DoFFixupQueue.GetSRV()); - Context.DispatchIndirect(s_IndirectParameters, 24); - } - else - { - Context.SetPipelineState(s_DoFCombineCS); - Context.SetDynamicDescriptor(1, 0, g_DoFBlurColor[MedianFilter ? 1 : 0].GetSRV()); - Context.SetDynamicDescriptor(1, 1, g_DoFBlurAlpha[MedianFilter ? 1 : 0].GetSRV()); - Context.SetDynamicDescriptor(1, 2, g_DoFTileClass[1].GetSRV()); - Context.SetDynamicDescriptor(1, 3, LinearDepth.GetSRV()); - Context.SetDynamicDescriptor(1, 4, g_DoFWorkQueue.GetSRV()); - Context.SetDynamicDescriptor(2, 0, g_SceneColorBuffer.GetUAV()); - Context.DispatchIndirect(s_IndirectParameters, 0); - - Context.SetPipelineState(s_DoFCombineFastCS); - Context.SetDynamicDescriptor(1, 4, g_DoFFastQueue.GetSRV()); - Context.DispatchIndirect(s_IndirectParameters, 12); - } - - Context.InsertUAVBarrier(g_SceneColorBuffer); - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/DepthOfField.h b/xess/samples/xess_demo/MiniEngine/Core/DepthOfField.h deleted file mode 100644 index 2b2e6b3..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/DepthOfField.h +++ /dev/null @@ -1,26 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "EngineTuning.h" - -namespace DepthOfField -{ - extern BoolVar Enable; - - void Initialize( void ); - void Shutdown( void ); - - void Render( CommandContext& BaseContext, float NearClipDist, float FarClipDist ); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/DescriptorHeap.cpp b/xess/samples/xess_demo/MiniEngine/Core/DescriptorHeap.cpp deleted file mode 100644 index 6d63188..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/DescriptorHeap.cpp +++ /dev/null @@ -1,113 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "DescriptorHeap.h" -#include "GraphicsCore.h" -#include "CommandListManager.h" - -using namespace Graphics; - -// -// DescriptorAllocator implementation -// -std::mutex DescriptorAllocator::sm_AllocationMutex; -std::vector> DescriptorAllocator::sm_DescriptorHeapPool; - -void DescriptorAllocator::DestroyAll(void) -{ - sm_DescriptorHeapPool.clear(); -} - -ID3D12DescriptorHeap* DescriptorAllocator::RequestNewHeap(D3D12_DESCRIPTOR_HEAP_TYPE Type) -{ - std::lock_guard LockGuard(sm_AllocationMutex); - - D3D12_DESCRIPTOR_HEAP_DESC Desc; - Desc.Type = Type; - Desc.NumDescriptors = sm_NumDescriptorsPerHeap; - Desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; - Desc.NodeMask = 1; - - Microsoft::WRL::ComPtr pHeap; - ASSERT_SUCCEEDED(Graphics::g_Device->CreateDescriptorHeap(&Desc, MY_IID_PPV_ARGS(&pHeap))); - sm_DescriptorHeapPool.emplace_back(pHeap); - return pHeap.Get(); -} - -D3D12_CPU_DESCRIPTOR_HANDLE DescriptorAllocator::Allocate( uint32_t Count ) -{ - if (m_CurrentHeap == nullptr || m_RemainingFreeHandles < Count) - { - m_CurrentHeap = RequestNewHeap(m_Type); - m_CurrentHandle = m_CurrentHeap->GetCPUDescriptorHandleForHeapStart(); - m_RemainingFreeHandles = sm_NumDescriptorsPerHeap; - - if (m_DescriptorSize == 0) - m_DescriptorSize = Graphics::g_Device->GetDescriptorHandleIncrementSize(m_Type); - } - - D3D12_CPU_DESCRIPTOR_HANDLE ret = m_CurrentHandle; - m_CurrentHandle.ptr += Count * m_DescriptorSize; - m_RemainingFreeHandles -= Count; - return ret; -} - -// -// DescriptorHeap implementation -// - -void DescriptorHeap::Create( const std::wstring& Name, D3D12_DESCRIPTOR_HEAP_TYPE Type, uint32_t MaxCount ) -{ - m_HeapDesc.Type = Type; - m_HeapDesc.NumDescriptors = MaxCount; - m_HeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; - m_HeapDesc.NodeMask = 1; - - ASSERT_SUCCEEDED(g_Device->CreateDescriptorHeap(&m_HeapDesc, MY_IID_PPV_ARGS(m_Heap.ReleaseAndGetAddressOf()))); - -#ifdef RELEASE - (void)Name; -#else - m_Heap->SetName(Name.c_str()); -#endif - - m_DescriptorSize = g_Device->GetDescriptorHandleIncrementSize(m_HeapDesc.Type); - m_NumFreeDescriptors = m_HeapDesc.NumDescriptors; - m_FirstHandle = DescriptorHandle( - m_Heap->GetCPUDescriptorHandleForHeapStart(), - m_Heap->GetGPUDescriptorHandleForHeapStart()); - m_NextFreeHandle = m_FirstHandle; -} - -DescriptorHandle DescriptorHeap::Alloc( uint32_t Count ) -{ - ASSERT(HasAvailableSpace(Count), "Descriptor Heap out of space. Increase heap size."); - DescriptorHandle ret = m_NextFreeHandle; - m_NextFreeHandle += Count * m_DescriptorSize; - m_NumFreeDescriptors -= Count; - return ret; -} - -bool DescriptorHeap::ValidateHandle( const DescriptorHandle& DHandle ) const -{ - if (DHandle.GetCpuPtr() < m_FirstHandle.GetCpuPtr() || - DHandle.GetCpuPtr() >= m_FirstHandle.GetCpuPtr() + m_HeapDesc.NumDescriptors * m_DescriptorSize) - return false; - - if (DHandle.GetGpuPtr() - m_FirstHandle.GetGpuPtr() != - DHandle.GetCpuPtr() - m_FirstHandle.GetCpuPtr()) - return false; - - return true; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/DescriptorHeap.h b/xess/samples/xess_demo/MiniEngine/Core/DescriptorHeap.h deleted file mode 100644 index 8b113b7..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/DescriptorHeap.h +++ /dev/null @@ -1,136 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include -#include -#include -#include - -// This is an unbounded resource descriptor allocator. It is intended to provide space for CPU-visible -// resource descriptors as resources are created. For those that need to be made shader-visible, they -// will need to be copied to a DescriptorHeap or a DynamicDescriptorHeap. -class DescriptorAllocator -{ -public: - DescriptorAllocator(D3D12_DESCRIPTOR_HEAP_TYPE Type) : - m_Type(Type), m_CurrentHeap(nullptr), m_DescriptorSize(0) - { - m_CurrentHandle.ptr = D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN; - } - - D3D12_CPU_DESCRIPTOR_HANDLE Allocate( uint32_t Count ); - - static void DestroyAll(void); - -protected: - - static const uint32_t sm_NumDescriptorsPerHeap = 256; - static std::mutex sm_AllocationMutex; - static std::vector> sm_DescriptorHeapPool; - static ID3D12DescriptorHeap* RequestNewHeap( D3D12_DESCRIPTOR_HEAP_TYPE Type ); - - D3D12_DESCRIPTOR_HEAP_TYPE m_Type; - ID3D12DescriptorHeap* m_CurrentHeap; - D3D12_CPU_DESCRIPTOR_HANDLE m_CurrentHandle; - uint32_t m_DescriptorSize; - uint32_t m_RemainingFreeHandles; -}; - -// This handle refers to a descriptor or a descriptor table (contiguous descriptors) that is shader visible. -class DescriptorHandle -{ -public: - DescriptorHandle() - { - m_CpuHandle.ptr = D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN; - m_GpuHandle.ptr = D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN; - } - - /* - // Should we allow constructing handles that might not be shader visible? - DescriptorHandle( D3D12_CPU_DESCRIPTOR_HANDLE CpuHandle ) - : m_CpuHandle(CpuHandle) - { - m_GpuHandle.ptr = D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN; - } - */ - - DescriptorHandle( D3D12_CPU_DESCRIPTOR_HANDLE CpuHandle, D3D12_GPU_DESCRIPTOR_HANDLE GpuHandle ) - : m_CpuHandle(CpuHandle), m_GpuHandle(GpuHandle) - { - } - - DescriptorHandle operator+ ( INT OffsetScaledByDescriptorSize ) const - { - DescriptorHandle ret = *this; - ret += OffsetScaledByDescriptorSize; - return ret; - } - - void operator += ( INT OffsetScaledByDescriptorSize ) - { - if (m_CpuHandle.ptr != D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN) - m_CpuHandle.ptr += OffsetScaledByDescriptorSize; - if (m_GpuHandle.ptr != D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN) - m_GpuHandle.ptr += OffsetScaledByDescriptorSize; - } - - const D3D12_CPU_DESCRIPTOR_HANDLE* operator&() const { return &m_CpuHandle; } - operator D3D12_CPU_DESCRIPTOR_HANDLE() const { return m_CpuHandle; } - operator D3D12_GPU_DESCRIPTOR_HANDLE() const { return m_GpuHandle; } - - size_t GetCpuPtr() const { return m_CpuHandle.ptr; } - uint64_t GetGpuPtr() const { return m_GpuHandle.ptr; } - bool IsNull() const { return m_CpuHandle.ptr == D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN; } - bool IsShaderVisible() const { return m_GpuHandle.ptr != D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN; } - -private: - D3D12_CPU_DESCRIPTOR_HANDLE m_CpuHandle; - D3D12_GPU_DESCRIPTOR_HANDLE m_GpuHandle; -}; - -class DescriptorHeap -{ -public: - - DescriptorHeap(void) {} - ~DescriptorHeap(void) { Destroy(); } - - void Create( const std::wstring& DebugHeapName, D3D12_DESCRIPTOR_HEAP_TYPE Type, uint32_t MaxCount ); - void Destroy(void) { m_Heap = nullptr; } - - bool HasAvailableSpace( uint32_t Count ) const { return Count <= m_NumFreeDescriptors; } - DescriptorHandle Alloc( uint32_t Count = 1 ); - - DescriptorHandle operator[] (uint32_t arrayIdx) const { return m_FirstHandle + arrayIdx * m_DescriptorSize; } - - uint32_t GetOffsetOfHandle(const DescriptorHandle& DHandle ) { - return (uint32_t)(DHandle.GetCpuPtr() - m_FirstHandle.GetCpuPtr()) / m_DescriptorSize; } - - bool ValidateHandle( const DescriptorHandle& DHandle ) const; - - ID3D12DescriptorHeap* GetHeapPointer() const { return m_Heap.Get(); } - - uint32_t GetDescriptorSize(void) const { return m_DescriptorSize; } - -private: - - Microsoft::WRL::ComPtr m_Heap; - D3D12_DESCRIPTOR_HEAP_DESC m_HeapDesc; - uint32_t m_DescriptorSize; - uint32_t m_NumFreeDescriptors; - DescriptorHandle m_FirstHandle; - DescriptorHandle m_NextFreeHandle; -}; diff --git a/xess/samples/xess_demo/MiniEngine/Core/Display.cpp b/xess/samples/xess_demo/MiniEngine/Core/Display.cpp deleted file mode 100644 index 06e5f18..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Display.cpp +++ /dev/null @@ -1,807 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -// Modified 2022, Intel Corporation. -// Added support for super sampling. Fullscreen, tearing, DPI scale, arbitrary resolution supported. - -#include "pch.h" -#include "Display.h" -#include "GraphicsCore.h" -#include "BufferManager.h" -#include "ColorBuffer.h" -#include "SystemTime.h" -#include "CommandContext.h" -#include "RootSignature.h" -#include "ImageScaling.h" -#include "TemporalEffects.h" -#include "shellscalingapi.h" - -#pragma comment(lib, "Shcore.lib") -#pragma comment(lib, "dxgi.lib") - -// This macro determines whether to detect if there is an HDR display and enable HDR10 output. -// Currently, with HDR display enabled, the pixel magnfication functionality is broken. -#define CONDITIONALLY_ENABLE_HDR_OUTPUT 1 - -namespace GameCore { extern HWND g_hWnd; } - -#include "CompiledShaders/ScreenQuadPresentVS.h" -#include "CompiledShaders/BufferCopyPS.h" -#include "CompiledShaders/PresentSDRPS.h" -#include "CompiledShaders/PresentHDRPS.h" -#include "CompiledShaders/CompositeSDRPS.h" -#include "CompiledShaders/ScaleAndCompositeSDRPS.h" -#include "CompiledShaders/CompositeHDRPS.h" -#include "CompiledShaders/BlendUIHDRPS.h" -#include "CompiledShaders/ScaleAndCompositeHDRPS.h" -#include "CompiledShaders/MagnifyPixelsPS.h" -#include "CompiledShaders/GenerateMipsLinearCS.h" -#include "CompiledShaders/GenerateMipsLinearOddCS.h" -#include "CompiledShaders/GenerateMipsLinearOddXCS.h" -#include "CompiledShaders/GenerateMipsLinearOddYCS.h" -#include "CompiledShaders/GenerateMipsGammaCS.h" -#include "CompiledShaders/GenerateMipsGammaOddCS.h" -#include "CompiledShaders/GenerateMipsGammaOddXCS.h" -#include "CompiledShaders/GenerateMipsGammaOddYCS.h" - -#define SWAP_CHAIN_BUFFER_COUNT 3 - -DXGI_FORMAT SwapChainFormat = DXGI_FORMAT_R10G10B10A2_UNORM; - -using namespace Math; -using namespace ImageScaling; -using namespace Graphics; - -namespace Display -{ - float s_FrameTime = 0.0f; - uint64_t s_FrameIndex = 0; - int64_t s_FrameStartTick = 0; - float s_DPIScale = 1.0f; - - BoolVar s_EnableVSync("Timing/VSync", true); - - bool g_SupportTearing = false; - bool s_Fullscreen = false; - DWORD s_WindowStyle = 0; - RECT s_WindowRect = { 0, 0, 100, 100 }; - //BoolVar s_LimitTo30Hz("Timing/Limit To 30Hz", false); - //BoolVar s_DropRandomFrames("Timing/Drop Random Frames", false); - - void CheckTearingSupport(); -} - -namespace Graphics -{ - void PreparePresentSDR(); - void PreparePresentHDR(); - void CompositeOverlays( GraphicsContext& Context ); - - enum eEQAAQuality { kEQAA1x1, kEQAA1x8, kEQAA1x16 }; - - const uint32_t kNumPredefinedResolutions = 6; - - const char* ResolutionLabels[] = { "1280x720", "1600x900", "1920x1080", "2560x1440", "3200x1800", "3840x2160" }; - - EnumVar NativeResolution("Graphics/Display/Native Resolution", k1080p, kNumPredefinedResolutions, ResolutionLabels); - -#ifdef _GAMING_DESKTOP - // This can set the window size to common dimensions. It's also possible for the window to take on other dimensions - // through resizing or going full-screen. - EnumVar DisplayResolution("Graphics/Display/Display Resolution", k1080p, kNumPredefinedResolutions, ResolutionLabels); -#endif - - bool g_bEnableHDROutput = false; - - bool g_bUpscalingEnabled = false; - - bool g_bArbitraryResolution = false; - - NumVar g_HDRPaperWhite("Graphics/Display/Paper White (nits)", 200.0f, 100.0f, 500.0f, 50.0f); - NumVar g_MaxDisplayLuminance("Graphics/Display/Peak Brightness (nits)", 1000.0f, 500.0f, 10000.0f, 100.0f); - const char* HDRModeLabels[] = { "HDR", "SDR", "Side-by-Side" }; - EnumVar HDRDebugMode("Graphics/Display/HDR Debug Mode", 0, 3, HDRModeLabels); - - uint32_t g_NativeWidth = 0; - uint32_t g_NativeHeight = 0; - uint32_t g_DisplayWidth = 2560; - uint32_t g_DisplayHeight = 1440; - - ColorBuffer g_PreDisplayBuffer; - - void ResolutionToUINT(eResolution res, uint32_t& width, uint32_t& height) - { - switch (res) - { - default: - case k720p: - width = 1280; - height = 720; - break; - case k900p: - width = 1600; - height = 900; - break; - case k1080p: - width = 1920; - height = 1080; - break; - case k1440p: - width = 2560; - height = 1440; - break; - case k1800p: - width = 3200; - height = 1800; - break; - case k2160p: - width = 3840; - height = 2160; - break; - } - } - - void SetNativeResolution(void) - { - if (g_bArbitraryResolution) - return; - - uint32_t NativeWidth, NativeHeight; - - ResolutionToUINT(eResolution((int)NativeResolution), NativeWidth, NativeHeight); - - if (g_NativeWidth == NativeWidth && g_NativeHeight == NativeHeight) - return; - LOG_DEBUGF("Changing native resolution to %ux%u.", NativeWidth, NativeHeight); - - g_NativeWidth = NativeWidth; - g_NativeHeight = NativeHeight; - - g_CommandManager.IdleGPU(); - - InitializeRenderingBuffers(NativeWidth, NativeHeight); - } - - void SetDisplayResolution(void) - { -#ifdef _GAMING_DESKTOP - if (g_bArbitraryResolution) - return; - - static int SelectedDisplayRes = DisplayResolution; - if (SelectedDisplayRes == DisplayResolution) - return; - - SelectedDisplayRes = DisplayResolution; - - ResolutionToUINT((eResolution)SelectedDisplayRes, g_DisplayWidth, g_DisplayHeight); - LOG_DEBUGF("Changing display resolution to %ux%u.", g_DisplayWidth, g_DisplayHeight); - - g_CommandManager.IdleGPU(); - - Display::Resize(g_DisplayWidth, g_DisplayHeight); - - RECT rc = { 0, 0, (LONG)g_DisplayWidth, (LONG)g_DisplayHeight }; - AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, FALSE); - - SetWindowPos(GameCore::g_hWnd, nullptr, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); -#endif - } - - void SetNativeResolutionAndUpscaling(uint32_t Width, uint32_t Height, bool UpscalingEnabled) - { - ASSERT(Width); - ASSERT(Height); - if (!Width || !Height) - return; - - if (!g_bArbitraryResolution) - return; - - if (g_NativeWidth == Width && g_NativeHeight == Height && g_bUpscalingEnabled == UpscalingEnabled) - return; - - LOG_DEBUGF("Set native resolution to %ux%u and upscaling=%d.", Width, Height, UpscalingEnabled); - - g_NativeWidth = Width; - g_NativeHeight = Height; - - g_bUpscalingEnabled = UpscalingEnabled; - - g_CommandManager.IdleGPU(); - - InitializeRenderingBuffers(Width, Height); - } - - ColorBuffer g_DisplayPlane[SWAP_CHAIN_BUFFER_COUNT]; - UINT g_CurrentBuffer = 0; - - IDXGISwapChain1* s_SwapChain1 = nullptr; - - RootSignature s_PresentRS; - GraphicsPSO s_BlendUIPSO(L"Core: BlendUI"); - GraphicsPSO s_BlendUIHDRPSO(L"Core: BlendUIHDR"); - GraphicsPSO PresentSDRPS(L"Core: PresentSDR"); - GraphicsPSO PresentHDRPS(L"Core: PresentHDR"); - GraphicsPSO CompositeSDRPS(L"Core: CompositeSDR"); - GraphicsPSO ScaleAndCompositeSDRPS(L"Core: ScaleAndCompositeSDR"); - GraphicsPSO CompositeHDRPS(L"Core: CompositeHDR"); - GraphicsPSO ScaleAndCompositeHDRPS(L"Core: ScaleAndCompositeHDR"); - GraphicsPSO MagnifyPixelsPS(L"Core: MagnifyPixels"); - - const char* FilterLabels[] = { "Bilinear", "Sharpening", "Bicubic", "Lanczos" }; - EnumVar UpsampleFilter("Graphics/Display/Scaling Filter", kSharpening, kFilterCount, FilterLabels); - - enum DebugZoomLevel { kDebugZoomOff, kDebugZoom2x, kDebugZoom4x, kDebugZoom8x, kDebugZoom16x, kDebugZoomCount }; - const char* DebugZoomLabels[] = { "Off", "2x Zoom", "4x Zoom", "8x Zoom", "16x Zoom" }; - EnumVar DebugZoom("Graphics/Display/Magnify Pixels", kDebugZoomOff, kDebugZoomCount, DebugZoomLabels); -} - -void Display::Resize(uint32_t width, uint32_t height) -{ - if (!width || !height) - return; - - g_CommandManager.IdleGPU(); - - g_DisplayWidth = width; - g_DisplayHeight = height; - - LOG_DEBUGF("Changing display resolution to %ux%u.", width, height); - - g_PreDisplayBuffer.Create(L"PreDisplay Buffer", width, height, 1, SwapChainFormat); - - for (uint32_t i = 0; i < SWAP_CHAIN_BUFFER_COUNT; ++i) - g_DisplayPlane[i].Destroy(); - - ASSERT(s_SwapChain1 != nullptr); - ASSERT_SUCCEEDED(s_SwapChain1->ResizeBuffers(SWAP_CHAIN_BUFFER_COUNT, width, height, SwapChainFormat, - g_SupportTearing ? (DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH | DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING) : DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH)); - - for (uint32_t i = 0; i < SWAP_CHAIN_BUFFER_COUNT; ++i) - { - ComPtr DisplayPlane; - ASSERT_SUCCEEDED(s_SwapChain1->GetBuffer(i, MY_IID_PPV_ARGS(&DisplayPlane))); - g_DisplayPlane[i].CreateFromSwapChain(L"Primary SwapChain Buffer", DisplayPlane.Detach()); - } - - g_CurrentBuffer = 0; - - g_CommandManager.IdleGPU(); - - ResizeDisplayDependentBuffers(g_NativeWidth, g_NativeHeight); -} - -// Initialize the DirectX resources required to run. -void Display::Initialize(void) -{ - ASSERT(s_SwapChain1 == nullptr, "Graphics has already been initialized"); - - // Test tearing support. - CheckTearingSupport(); - - ASSERT(GameCore::g_hWnd); - - // Record initial DPI scale. - UpdateDPIScale(); - - // Record window style. - s_WindowStyle = GetWindowLong(GameCore::g_hWnd, GWL_STYLE); - - // Record window rect. - GetWindowRect(GameCore::g_hWnd, &s_WindowRect); - - Microsoft::WRL::ComPtr dxgiFactory; - ASSERT_SUCCEEDED(CreateDXGIFactory2(0, MY_IID_PPV_ARGS(&dxgiFactory))); - - DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {}; - swapChainDesc.Width = g_DisplayWidth; - swapChainDesc.Height = g_DisplayHeight; - swapChainDesc.Format = SwapChainFormat; - swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; - swapChainDesc.BufferCount = SWAP_CHAIN_BUFFER_COUNT; - swapChainDesc.SampleDesc.Count = 1; - swapChainDesc.SampleDesc.Quality = 0; - swapChainDesc.Scaling = DXGI_SCALING_NONE; - swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; - swapChainDesc.AlphaMode = DXGI_ALPHA_MODE_IGNORE; - swapChainDesc.Flags = g_SupportTearing ? (DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH | DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING) : DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; - - DXGI_SWAP_CHAIN_FULLSCREEN_DESC fsSwapChainDesc = {}; - fsSwapChainDesc.Windowed = TRUE; - - ASSERT_SUCCEEDED(dxgiFactory->CreateSwapChainForHwnd( - g_CommandManager.GetCommandQueue(), - GameCore::g_hWnd, - &swapChainDesc, - &fsSwapChainDesc, - nullptr, - &s_SwapChain1)); - - // We will handle ALT+Enter key presses in the window message loop. - dxgiFactory->MakeWindowAssociation(GameCore::g_hWnd, DXGI_MWA_NO_ALT_ENTER); - -#if CONDITIONALLY_ENABLE_HDR_OUTPUT - { - IDXGISwapChain4* swapChain = (IDXGISwapChain4*)s_SwapChain1; - ComPtr output; - ComPtr output6; - DXGI_OUTPUT_DESC1 outputDesc; - UINT colorSpaceSupport; - - // Query support for ST.2084 on the display and set the color space accordingly - if (SUCCEEDED(swapChain->GetContainingOutput(&output)) && SUCCEEDED(output.As(&output6)) && - SUCCEEDED(output6->GetDesc1(&outputDesc)) && outputDesc.ColorSpace == DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020 && - SUCCEEDED(swapChain->CheckColorSpaceSupport(DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020, &colorSpaceSupport)) && - (colorSpaceSupport & DXGI_SWAP_CHAIN_COLOR_SPACE_SUPPORT_FLAG_PRESENT) && - SUCCEEDED(swapChain->SetColorSpace1(DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020))) - { - g_bEnableHDROutput = true; - } - } -#endif // End CONDITIONALLY_ENABLE_HDR_OUTPUT - - for (uint32_t i = 0; i < SWAP_CHAIN_BUFFER_COUNT; ++i) - { - ComPtr DisplayPlane; - ASSERT_SUCCEEDED(s_SwapChain1->GetBuffer(i, MY_IID_PPV_ARGS(&DisplayPlane))); - g_DisplayPlane[i].CreateFromSwapChain(L"Primary SwapChain Buffer", DisplayPlane.Detach()); - } - - s_PresentRS.Reset(4, 2); - s_PresentRS[0].InitAsDescriptorRange(D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 2); - s_PresentRS[1].InitAsConstants(0, 6, D3D12_SHADER_VISIBILITY_ALL); - s_PresentRS[2].InitAsBufferSRV(2, D3D12_SHADER_VISIBILITY_PIXEL); - s_PresentRS[3].InitAsDescriptorRange(D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 0, 2); - s_PresentRS.InitStaticSampler(0, SamplerLinearClampDesc); - s_PresentRS.InitStaticSampler(1, SamplerPointClampDesc); - s_PresentRS.Finalize(L"Present"); - - // Initialize PSOs - s_BlendUIPSO.SetRootSignature(s_PresentRS); - s_BlendUIPSO.SetRasterizerState( RasterizerTwoSided ); - s_BlendUIPSO.SetBlendState( BlendPreMultiplied ); - s_BlendUIPSO.SetDepthStencilState( DepthStateDisabled ); - s_BlendUIPSO.SetSampleMask(0xFFFFFFFF); - s_BlendUIPSO.SetInputLayout(0, nullptr); - s_BlendUIPSO.SetPrimitiveTopologyType(D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE); - s_BlendUIPSO.SetVertexShader( g_pScreenQuadPresentVS, sizeof(g_pScreenQuadPresentVS) ); - s_BlendUIPSO.SetPixelShader( g_pBufferCopyPS, sizeof(g_pBufferCopyPS) ); - s_BlendUIPSO.SetRenderTargetFormat(SwapChainFormat, DXGI_FORMAT_UNKNOWN); - s_BlendUIPSO.Finalize(); - - s_BlendUIHDRPSO = s_BlendUIPSO; - s_BlendUIHDRPSO.SetPixelShader(g_pBlendUIHDRPS, sizeof(g_pBlendUIHDRPS)); - s_BlendUIHDRPSO.Finalize(); - -#define CreatePSO( ObjName, ShaderByteCode ) \ - ObjName = s_BlendUIPSO; \ - ObjName.SetBlendState( BlendDisable ); \ - ObjName.SetPixelShader(ShaderByteCode, sizeof(ShaderByteCode) ); \ - ObjName.Finalize(); - - CreatePSO(PresentSDRPS, g_pPresentSDRPS); - CreatePSO(CompositeSDRPS, g_pCompositeSDRPS); - CreatePSO(ScaleAndCompositeSDRPS, g_pScaleAndCompositeSDRPS); - CreatePSO(CompositeHDRPS, g_pCompositeHDRPS); - CreatePSO(ScaleAndCompositeHDRPS, g_pScaleAndCompositeHDRPS); - CreatePSO(MagnifyPixelsPS, g_pMagnifyPixelsPS); - - PresentHDRPS = PresentSDRPS; - PresentHDRPS.SetPixelShader(g_pPresentHDRPS, sizeof(g_pPresentHDRPS)); - DXGI_FORMAT SwapChainFormats[2] = { DXGI_FORMAT_R10G10B10A2_UNORM, DXGI_FORMAT_R10G10B10A2_UNORM }; - PresentHDRPS.SetRenderTargetFormats(2, SwapChainFormats, DXGI_FORMAT_UNKNOWN ); - PresentHDRPS.Finalize(); - -#undef CreatePSO - - SetNativeResolution(); - - g_PreDisplayBuffer.Create(L"PreDisplay Buffer", g_DisplayWidth, g_DisplayHeight, 1, SwapChainFormat); - ImageScaling::Initialize(g_PreDisplayBuffer.GetFormat()); -} - -void Display::Shutdown( void ) -{ - s_SwapChain1->SetFullscreenState(FALSE, nullptr); - s_SwapChain1->Release(); - - for (UINT i = 0; i < SWAP_CHAIN_BUFFER_COUNT; ++i) - g_DisplayPlane[i].Destroy(); - - g_PreDisplayBuffer.Destroy(); -} - -void Graphics::PreparePresentHDR(void) -{ - GraphicsContext& Context = GraphicsContext::Begin(L"Present"); - Context.SetRootSignature(s_PresentRS); - Context.SetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - - bool isUpscalingMode = Graphics::IsUpscalingEnabled(); - - bool NeedsScaling = true; - - if (isUpscalingMode) - { - NeedsScaling = false; - } - else - { - NeedsScaling = g_NativeWidth != g_DisplayWidth || g_NativeHeight != g_DisplayHeight; - } - - if (isUpscalingMode) - { - Context.TransitionResource(g_UpscaledSceneColorBuffer, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - Context.SetDynamicDescriptor(0, 0, g_UpscaledSceneColorBuffer.GetSRV()); - } - else - { - Context.TransitionResource(g_SceneColorBuffer, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - Context.SetDynamicDescriptor(0, 0, g_SceneColorBuffer.GetSRV()); - } - - ColorBuffer& Dest = DebugZoom == kDebugZoomOff ? g_DisplayPlane[g_CurrentBuffer] : g_PreDisplayBuffer; - - // On Windows, prefer scaling and compositing in one step via pixel shader - Context.SetRootSignature(s_PresentRS); - Context.TransitionResource(g_OverlayBuffer, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - if (DebugZoom == kDebugZoomOff) - { - Context.SetDynamicDescriptor(0, 1, g_OverlayBuffer.GetSRV()); - Context.SetPipelineState(NeedsScaling ? ScaleAndCompositeHDRPS : CompositeHDRPS); - } - else - { - Context.SetDynamicDescriptor(0, 1, GetDefaultTexture(kBlackTransparent2D)); - Context.SetPipelineState(NeedsScaling ? ScaleAndCompositeHDRPS : PresentHDRPS); - } - Context.SetConstants(1, (float)g_HDRPaperWhite / 10000.0f, (float)g_MaxDisplayLuminance, - 0.7071f / g_NativeWidth, 0.7071f / g_NativeHeight); - Context.TransitionResource(Dest, D3D12_RESOURCE_STATE_RENDER_TARGET); - Context.SetRenderTarget(Dest.GetRTV()); - Context.SetViewportAndScissor(0, 0, g_DisplayWidth, g_DisplayHeight); - Context.Draw(3); - - // Magnify without stretching - if (DebugZoom != kDebugZoomOff) - { - Context.SetPipelineState(MagnifyPixelsPS); - Context.TransitionResource(g_PreDisplayBuffer, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_DisplayPlane[g_CurrentBuffer], D3D12_RESOURCE_STATE_RENDER_TARGET); - Context.SetRenderTarget(g_DisplayPlane[g_CurrentBuffer].GetRTV()); - Context.SetDynamicDescriptor(0, 0, g_PreDisplayBuffer.GetSRV()); - Context.SetViewportAndScissor(0, 0, g_DisplayWidth, g_DisplayHeight); - Context.SetConstants(1, 1.0f / ((int)DebugZoom + 1.0f)); - Context.Draw(3); - - CompositeOverlays(Context); - } - - Context.TransitionResource(g_DisplayPlane[g_CurrentBuffer], D3D12_RESOURCE_STATE_PRESENT); - - // Close the final context to be executed before frame present. - Context.Finish(); -} - -void Graphics::CompositeOverlays( GraphicsContext& Context ) -{ - // Now blend (or write) the UI overlay - Context.SetRootSignature(s_PresentRS); - Context.TransitionResource(g_OverlayBuffer, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - Context.SetDynamicDescriptor(0, 0, g_OverlayBuffer.GetSRV()); - Context.SetPipelineState(g_bEnableHDROutput ? s_BlendUIHDRPSO : s_BlendUIPSO); - Context.SetConstants(1, (float)g_HDRPaperWhite / 10000.0f, (float)g_MaxDisplayLuminance); - Context.Draw(3); -} - -void Graphics::PreparePresentSDR(void) -{ - GraphicsContext& Context = GraphicsContext::Begin(L"Present"); - - Context.SetRootSignature(s_PresentRS); - Context.SetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - - bool isUpscalingMode = Graphics::IsUpscalingEnabled(); - - if (isUpscalingMode) - { - Context.TransitionResource(g_UpscaledSceneColorBuffer, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE | - D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.SetDynamicDescriptor(0, 0, g_UpscaledSceneColorBuffer.GetSRV()); - } - else - { - Context.TransitionResource(g_SceneColorBuffer, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE | - D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.SetDynamicDescriptor(0, 0, g_SceneColorBuffer.GetSRV()); - } - - bool NeedsScaling = true; - - if (isUpscalingMode) - { - NeedsScaling = false; - } - else - { - NeedsScaling = g_NativeWidth != g_DisplayWidth || g_NativeHeight != g_DisplayHeight; - } - - // On Windows, prefer scaling and compositing in one step via pixel shader - if (DebugZoom == kDebugZoomOff && (UpsampleFilter == kSharpening || !NeedsScaling)) - { - Context.TransitionResource(g_OverlayBuffer, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - Context.SetDynamicDescriptor(0, 1, g_OverlayBuffer.GetSRV()); - Context.SetPipelineState(NeedsScaling ? ScaleAndCompositeSDRPS : CompositeSDRPS); - Context.SetConstants(1, 0.7071f / g_NativeWidth, 0.7071f / g_NativeHeight); - Context.TransitionResource(g_DisplayPlane[g_CurrentBuffer], D3D12_RESOURCE_STATE_RENDER_TARGET); - Context.SetRenderTarget(g_DisplayPlane[g_CurrentBuffer].GetRTV()); - Context.SetViewportAndScissor(0, 0, g_DisplayWidth, g_DisplayHeight); - Context.Draw(3); - } - else - { - ColorBuffer& Dest = DebugZoom == kDebugZoomOff ? g_DisplayPlane[g_CurrentBuffer] : g_PreDisplayBuffer; - - // Scale or Copy - if (NeedsScaling) - { - ImageScaling::Upscale(Context, Dest, g_SceneColorBuffer, eScalingFilter((int)UpsampleFilter)); - } - else - { - Context.SetPipelineState(PresentSDRPS); - Context.TransitionResource(Dest, D3D12_RESOURCE_STATE_RENDER_TARGET); - Context.SetRenderTarget(Dest.GetRTV()); - Context.SetViewportAndScissor(0, 0, g_DisplayWidth, g_DisplayHeight); - Context.Draw(3); - } - - // Magnify without stretching - if (DebugZoom != kDebugZoomOff) - { - Context.SetPipelineState(MagnifyPixelsPS); - Context.TransitionResource(g_PreDisplayBuffer, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_DisplayPlane[g_CurrentBuffer], D3D12_RESOURCE_STATE_RENDER_TARGET); - Context.SetRenderTarget(g_DisplayPlane[g_CurrentBuffer].GetRTV()); - Context.SetDynamicDescriptor(0, 0, g_PreDisplayBuffer.GetSRV()); - Context.SetViewportAndScissor(0, 0, g_DisplayWidth, g_DisplayHeight); - Context.SetConstants(1, 1.0f / ((int)DebugZoom + 1.0f)); - Context.Draw(3); - } - - CompositeOverlays(Context); - } - - - Context.TransitionResource(g_DisplayPlane[g_CurrentBuffer], D3D12_RESOURCE_STATE_PRESENT); - - // Close the final context to be executed before frame present. - Context.Finish(); -} - -void Display::Present(void) -{ - if (g_bEnableHDROutput) - PreparePresentHDR(); - else - PreparePresentSDR(); - - BOOL fullscreenState = FALSE; - ASSERT_SUCCEEDED(s_SwapChain1->GetFullscreenState(&fullscreenState, nullptr)); - - //UINT PresentInterval = s_EnableVSync ? std::min(4, (int)Round(s_FrameTime * 60.0f)) : 0; - - //s_SwapChain1->Present(PresentInterval, 0); - - if (s_EnableVSync) - s_SwapChain1->Present(1, 0); - else - { - s_SwapChain1->Present(0, (g_SupportTearing && !fullscreenState) ? DXGI_PRESENT_ALLOW_TEARING : 0); - } - - g_CurrentBuffer = (g_CurrentBuffer + 1) % SWAP_CHAIN_BUFFER_COUNT; - - // Test robustness to handle spikes in CPU time - //if (s_DropRandomFrames) - //{ - // if (std::rand() % 25 == 0) - // BusyLoopSleep(0.010); - //} - - int64_t CurrentTick = SystemTime::GetCurrentTick(); - - /* - if (s_EnableVSync) - { - // With VSync enabled, the time step between frames becomes a multiple of 16.666 ms. We need - // to add logic to vary between 1 and 2 (or 3 fields). This delta time also determines how - // long the previous frame should be displayed (i.e. the present interval.) - s_FrameTime = (s_LimitTo30Hz ? 2.0f : 1.0f) / 60.0f; - if (s_DropRandomFrames) - { - if (std::rand() % 50 == 0) - s_FrameTime += (1.0f / 60.0f); - } - } - else - { - // When running free, keep the most recent total frame time as the time step for - // the next frame simulation. This is not super-accurate, but assuming a frame - // time varies smoothly, it should be close enough. - s_FrameTime = (float)SystemTime::TimeBetweenTicks(s_FrameStartTick, CurrentTick); - } - */ - - s_FrameTime = (float)SystemTime::TimeBetweenTicks(s_FrameStartTick, CurrentTick); - - s_FrameStartTick = CurrentTick; - - ++s_FrameIndex; - - TemporalEffects::Update((uint32_t)s_FrameIndex); - - // We need to know the display resolution to create upscaled buffers with correct sizes. - // So we put SetDisplayResolution first. - SetDisplayResolution(); - SetNativeResolution(); -} - -void Display::CheckTearingSupport() -{ - ComPtr factory; - HRESULT hr = CreateDXGIFactory1(IID_PPV_ARGS(&factory)); - BOOL allowTearing = FALSE; - if (SUCCEEDED(hr)) - { - hr = factory->CheckFeatureSupport(DXGI_FEATURE_PRESENT_ALLOW_TEARING, &allowTearing, sizeof(allowTearing)); - } - - g_SupportTearing = SUCCEEDED(hr) && allowTearing; - - LOG_INFOF("Present tearing support: %d.", g_SupportTearing); -} - -bool Display::IsFullscreen() -{ - return s_Fullscreen; -} - -void Display::SetFullscreen(bool fullscreen) -{ - if (s_Fullscreen == fullscreen) - return; - - // Implementation based on D3D12Fullscreen sample: - // https://github.com/microsoft/DirectX-Graphics-Samples/tree/master/Samples/Desktop/D3D12Fullscreen - // In our implementation, if tearing is not supported, it actually falls back to borderless mode. - - if (fullscreen) - { - // Save the old window rect so we can restore it when exiting fullscreen mode. - GetWindowRect(GameCore::g_hWnd, &s_WindowRect); - - // Make the window borderless so that the client area can fill the screen. - SetWindowLong(GameCore::g_hWnd, GWL_STYLE, Display::s_WindowStyle & ~(WS_CAPTION | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SYSMENU | WS_THICKFRAME)); - - RECT fullscreenWindowRect = s_WindowRect; - - bool fullscreenRectGot = false; - - if (Graphics::s_SwapChain1) - { - // Get the settings of the display on which the app's window is currently displayed - ComPtr pOutput; - HRESULT hr = Graphics::s_SwapChain1->GetContainingOutput(&pOutput); - //ASSERT_SUCCEEDED(hr); - if (SUCCEEDED(hr)) - { - DXGI_OUTPUT_DESC Desc; - hr = pOutput->GetDesc(&Desc); - ASSERT_SUCCEEDED(hr); - if (SUCCEEDED(hr)) - { - fullscreenWindowRect = Desc.DesktopCoordinates; - fullscreenRectGot = true; - } - } - } - - if (!fullscreenRectGot) - { - MONITORINFO mi = { sizeof(mi) }; - if (GetMonitorInfo(MonitorFromWindow(GameCore::g_hWnd, MONITOR_DEFAULTTOPRIMARY), &mi)) - { - fullscreenWindowRect = mi.rcMonitor; - } - } - - SetWindowPos( - GameCore::g_hWnd, - HWND_TOPMOST, - fullscreenWindowRect.left, - fullscreenWindowRect.top, - fullscreenWindowRect.right, - fullscreenWindowRect.bottom, - SWP_FRAMECHANGED | SWP_NOACTIVATE); - - ShowWindow(GameCore::g_hWnd, SW_MAXIMIZE); - } - else - { - // Restore the window's attributes and size. - SetWindowLong(GameCore::g_hWnd, GWL_STYLE, Display::s_WindowStyle); - - SetWindowPos( - GameCore::g_hWnd, - HWND_NOTOPMOST, - s_WindowRect.left, - s_WindowRect.top, - s_WindowRect.right - s_WindowRect.left, - s_WindowRect.bottom - s_WindowRect.top, - SWP_FRAMECHANGED | SWP_NOACTIVATE); - - ShowWindow(GameCore::g_hWnd, SW_NORMAL); - } - - s_Fullscreen = fullscreen; -} - -void Display::UpdateDPIScale() -{ - ASSERT(GameCore::g_hWnd); - if (!GameCore::g_hWnd) - return; - - HMONITOR monitor = MonitorFromWindow(GameCore::g_hWnd, MONITOR_DEFAULTTONEAREST); - if (!monitor) - return; - - unsigned int dpiX; - unsigned int dpiY; - GetDpiForMonitor(monitor, MDT_EFFECTIVE_DPI, &dpiX, &dpiY); - if (dpiX == 0 || dpiY == 0) - return; - - s_DPIScale = std::max(dpiX / 96.f, dpiY / 96.f); - - LOG_DEBUGF("Display: DPI changed, DPI scale=%f", s_DPIScale); -} - -float Display::GetDPIScale() -{ - return s_DPIScale; -} - -uint64_t Graphics::GetFrameCount(void) -{ - return Display::s_FrameIndex; -} - -float Graphics::GetFrameTime(void) -{ - return Display::s_FrameTime; -} - -float Graphics::GetFrameRate(void) -{ - return Display::s_FrameTime == 0.0f ? 0.0f : 1.0f / Display::s_FrameTime; -} - -bool Graphics::IsUpscalingEnabled() -{ - return g_bUpscalingEnabled; -} \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Core/Display.h b/xess/samples/xess_demo/MiniEngine/Core/Display.h deleted file mode 100644 index d6f746a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Display.h +++ /dev/null @@ -1,72 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -// Modified 2022, Intel Corporation. -// Added support for super sampling. - -#pragma once - -#include - -namespace Display -{ - extern BoolVar s_EnableVSync; - - extern bool g_SupportTearing; - - void Initialize(void); - void Shutdown(void); - void Resize(uint32_t width, uint32_t height); - void Present(void); - - bool IsFullscreen(); - void SetFullscreen(bool fullscreen); - - void UpdateDPIScale(); - - float GetDPIScale(); -} - -namespace Graphics -{ - extern uint32_t g_DisplayWidth; - extern uint32_t g_DisplayHeight; - extern uint32_t g_NativeWidth; - extern uint32_t g_NativeHeight; - extern bool g_bEnableHDROutput; - - extern bool g_bArbitraryResolution; - - enum eResolution { k720p, k900p, k1080p, k1440p, k1800p, k2160p }; - - void ResolutionToUINT(eResolution res, uint32_t& width, uint32_t& height); - - // Returns the number of elapsed frames since application start - uint64_t GetFrameCount(void); - - // The amount of time elapsed during the last completed frame. The CPU and/or - // GPU may be idle during parts of the frame. The frame time measures the time - // between calls to present each frame. - float GetFrameTime(void); - - // The total number of frames per second - float GetFrameRate(void); - - extern bool g_bEnableHDROutput; - - // Returns if upscaling is enabled. - bool IsUpscalingEnabled(); - - // Set native resolution and if upscaling in the pipeline. - void SetNativeResolutionAndUpscaling(uint32_t Width, uint32_t Height, bool UpscalingEnabled); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/DynamicDescriptorHeap.cpp b/xess/samples/xess_demo/MiniEngine/Core/DynamicDescriptorHeap.cpp deleted file mode 100644 index a662975..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/DynamicDescriptorHeap.cpp +++ /dev/null @@ -1,346 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "DynamicDescriptorHeap.h" -#include "CommandContext.h" -#include "GraphicsCore.h" -#include "CommandListManager.h" -#include "RootSignature.h" - -using namespace Graphics; - -// -// DynamicDescriptorHeap Implementation -// - -std::mutex DynamicDescriptorHeap::sm_Mutex; -std::vector> DynamicDescriptorHeap::sm_DescriptorHeapPool[2]; -std::queue> DynamicDescriptorHeap::sm_RetiredDescriptorHeaps[2]; -std::queue DynamicDescriptorHeap::sm_AvailableDescriptorHeaps[2]; - -ID3D12DescriptorHeap* DynamicDescriptorHeap::RequestDescriptorHeap(D3D12_DESCRIPTOR_HEAP_TYPE HeapType) -{ - std::lock_guard LockGuard(sm_Mutex); - - uint32_t idx = HeapType == D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER ? 1 : 0; - - while (!sm_RetiredDescriptorHeaps[idx].empty() && g_CommandManager.IsFenceComplete(sm_RetiredDescriptorHeaps[idx].front().first)) - { - sm_AvailableDescriptorHeaps[idx].push(sm_RetiredDescriptorHeaps[idx].front().second); - sm_RetiredDescriptorHeaps[idx].pop(); - } - - if (!sm_AvailableDescriptorHeaps[idx].empty()) - { - ID3D12DescriptorHeap* HeapPtr = sm_AvailableDescriptorHeaps[idx].front(); - sm_AvailableDescriptorHeaps[idx].pop(); - return HeapPtr; - } - else - { - D3D12_DESCRIPTOR_HEAP_DESC HeapDesc = {}; - HeapDesc.Type = HeapType; - HeapDesc.NumDescriptors = kNumDescriptorsPerHeap; - HeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; - HeapDesc.NodeMask = 1; - Microsoft::WRL::ComPtr HeapPtr; - ASSERT_SUCCEEDED(g_Device->CreateDescriptorHeap(&HeapDesc, MY_IID_PPV_ARGS(&HeapPtr))); - sm_DescriptorHeapPool[idx].emplace_back(HeapPtr); - return HeapPtr.Get(); - } -} - -void DynamicDescriptorHeap::DiscardDescriptorHeaps( D3D12_DESCRIPTOR_HEAP_TYPE HeapType, uint64_t FenceValue, const std::vector& UsedHeaps ) -{ - uint32_t idx = HeapType == D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER ? 1 : 0; - std::lock_guard LockGuard(sm_Mutex); - for (auto iter = UsedHeaps.begin(); iter != UsedHeaps.end(); ++iter) - sm_RetiredDescriptorHeaps[idx].push(std::make_pair(FenceValue, *iter)); -} - -void DynamicDescriptorHeap::RetireCurrentHeap( void ) -{ - // Don't retire unused heaps. - if (m_CurrentOffset == 0) - { - ASSERT(m_CurrentHeapPtr == nullptr); - return; - } - - ASSERT(m_CurrentHeapPtr != nullptr); - m_RetiredHeaps.push_back(m_CurrentHeapPtr); - m_CurrentHeapPtr = nullptr; - m_CurrentOffset = 0; -} - -void DynamicDescriptorHeap::RetireUsedHeaps( uint64_t fenceValue ) -{ - DiscardDescriptorHeaps(m_DescriptorType, fenceValue, m_RetiredHeaps); - m_RetiredHeaps.clear(); -} - -DynamicDescriptorHeap::DynamicDescriptorHeap(CommandContext& OwningContext, D3D12_DESCRIPTOR_HEAP_TYPE HeapType) - : m_OwningContext(OwningContext), m_DescriptorType(HeapType) -{ - m_CurrentHeapPtr = nullptr; - m_CurrentOffset = 0; - m_DescriptorSize = Graphics::g_Device->GetDescriptorHandleIncrementSize(HeapType); -} - -DynamicDescriptorHeap::~DynamicDescriptorHeap() -{ -} - -void DynamicDescriptorHeap::CleanupUsedHeaps( uint64_t fenceValue ) -{ - RetireCurrentHeap(); - RetireUsedHeaps(fenceValue); - m_GraphicsHandleCache.ClearCache(); - m_ComputeHandleCache.ClearCache(); -} - -inline ID3D12DescriptorHeap* DynamicDescriptorHeap::GetHeapPointer() -{ - if (m_CurrentHeapPtr == nullptr) - { - ASSERT(m_CurrentOffset == 0); - m_CurrentHeapPtr = RequestDescriptorHeap(m_DescriptorType); - m_FirstDescriptor = DescriptorHandle( - m_CurrentHeapPtr->GetCPUDescriptorHandleForHeapStart(), - m_CurrentHeapPtr->GetGPUDescriptorHandleForHeapStart()); - } - - return m_CurrentHeapPtr; -} - -uint32_t DynamicDescriptorHeap::DescriptorHandleCache::ComputeStagedSize() -{ - // Sum the maximum assigned offsets of stale descriptor tables to determine total needed space. - uint32_t NeededSpace = 0; - uint32_t RootIndex; - uint32_t StaleParams = m_StaleRootParamsBitMap; - while (_BitScanForward((unsigned long*)&RootIndex, StaleParams)) - { - StaleParams ^= (1 << RootIndex); - - uint32_t MaxSetHandle; - ASSERT(TRUE == _BitScanReverse((unsigned long*)&MaxSetHandle, m_RootDescriptorTable[RootIndex].AssignedHandlesBitMap), - "Root entry marked as stale but has no stale descriptors"); - - NeededSpace += MaxSetHandle + 1; - } - return NeededSpace; -} - -void DynamicDescriptorHeap::DescriptorHandleCache::CopyAndBindStaleTables( - D3D12_DESCRIPTOR_HEAP_TYPE Type, uint32_t DescriptorSize, - DescriptorHandle DestHandleStart, ID3D12GraphicsCommandList* CmdList, - void (STDMETHODCALLTYPE ID3D12GraphicsCommandList::*SetFunc)(UINT, D3D12_GPU_DESCRIPTOR_HANDLE)) -{ - uint32_t StaleParamCount = 0; - uint32_t TableSize[DescriptorHandleCache::kMaxNumDescriptorTables]; - uint32_t RootIndices[DescriptorHandleCache::kMaxNumDescriptorTables]; - uint32_t NeededSpace = 0; - uint32_t RootIndex; - - // Sum the maximum assigned offsets of stale descriptor tables to determine total needed space. - uint32_t StaleParams = m_StaleRootParamsBitMap; - while (_BitScanForward((unsigned long*)&RootIndex, StaleParams)) - { - RootIndices[StaleParamCount] = RootIndex; - StaleParams ^= (1 << RootIndex); - - uint32_t MaxSetHandle; - ASSERT(TRUE == _BitScanReverse((unsigned long*)&MaxSetHandle, m_RootDescriptorTable[RootIndex].AssignedHandlesBitMap), - "Root entry marked as stale but has no stale descriptors"); - - NeededSpace += MaxSetHandle + 1; - TableSize[StaleParamCount] = MaxSetHandle + 1; - - ++StaleParamCount; - } - - ASSERT(StaleParamCount <= DescriptorHandleCache::kMaxNumDescriptorTables, - "We're only equipped to handle so many descriptor tables"); - - m_StaleRootParamsBitMap = 0; - - static const uint32_t kMaxDescriptorsPerCopy = 16; - UINT NumDestDescriptorRanges = 0; - D3D12_CPU_DESCRIPTOR_HANDLE pDestDescriptorRangeStarts[kMaxDescriptorsPerCopy]; - UINT pDestDescriptorRangeSizes[kMaxDescriptorsPerCopy]; - - UINT NumSrcDescriptorRanges = 0; - D3D12_CPU_DESCRIPTOR_HANDLE pSrcDescriptorRangeStarts[kMaxDescriptorsPerCopy]; - UINT pSrcDescriptorRangeSizes[kMaxDescriptorsPerCopy]; - - for (uint32_t i = 0; i < StaleParamCount; ++i) - { - RootIndex = RootIndices[i]; - (CmdList->*SetFunc)(RootIndex, DestHandleStart); - - DescriptorTableCache& RootDescTable = m_RootDescriptorTable[RootIndex]; - - D3D12_CPU_DESCRIPTOR_HANDLE* SrcHandles = RootDescTable.TableStart; - uint64_t SetHandles = (uint64_t)RootDescTable.AssignedHandlesBitMap; - D3D12_CPU_DESCRIPTOR_HANDLE CurDest = DestHandleStart; - DestHandleStart += TableSize[i] * DescriptorSize; - - unsigned long SkipCount; - while (_BitScanForward64(&SkipCount, SetHandles)) - { - // Skip over unset descriptor handles - SetHandles >>= SkipCount; - SrcHandles += SkipCount; - CurDest.ptr += SkipCount * DescriptorSize; - - unsigned long DescriptorCount; - _BitScanForward64(&DescriptorCount, ~SetHandles); - SetHandles >>= DescriptorCount; - - // If we run out of temp room, copy what we've got so far - if (NumSrcDescriptorRanges + DescriptorCount > kMaxDescriptorsPerCopy) - { - g_Device->CopyDescriptors( - NumDestDescriptorRanges, pDestDescriptorRangeStarts, pDestDescriptorRangeSizes, - NumSrcDescriptorRanges, pSrcDescriptorRangeStarts, pSrcDescriptorRangeSizes, - Type); - - NumSrcDescriptorRanges = 0; - NumDestDescriptorRanges = 0; - } - - // Setup destination range - pDestDescriptorRangeStarts[NumDestDescriptorRanges] = CurDest; - pDestDescriptorRangeSizes[NumDestDescriptorRanges] = DescriptorCount; - ++NumDestDescriptorRanges; - - // Setup source ranges (one descriptor each because we don't assume they are contiguous) - for (uint32_t j = 0; j < DescriptorCount; ++j) - { - pSrcDescriptorRangeStarts[NumSrcDescriptorRanges] = SrcHandles[j]; - pSrcDescriptorRangeSizes[NumSrcDescriptorRanges] = 1; - ++NumSrcDescriptorRanges; - } - - // Move the destination pointer forward by the number of descriptors we will copy - SrcHandles += DescriptorCount; - CurDest.ptr += DescriptorCount * DescriptorSize; - } - } - - g_Device->CopyDescriptors( - NumDestDescriptorRanges, pDestDescriptorRangeStarts, pDestDescriptorRangeSizes, - NumSrcDescriptorRanges, pSrcDescriptorRangeStarts, pSrcDescriptorRangeSizes, - Type); -} - -void DynamicDescriptorHeap::CopyAndBindStagedTables( DescriptorHandleCache& HandleCache, ID3D12GraphicsCommandList* CmdList, - void (STDMETHODCALLTYPE ID3D12GraphicsCommandList::*SetFunc)(UINT, D3D12_GPU_DESCRIPTOR_HANDLE)) -{ - uint32_t NeededSize = HandleCache.ComputeStagedSize(); - if (!HasSpace(NeededSize)) - { - RetireCurrentHeap(); - UnbindAllValid(); - NeededSize = HandleCache.ComputeStagedSize(); - } - - // This can trigger the creation of a new heap - m_OwningContext.SetDescriptorHeap(m_DescriptorType, GetHeapPointer()); - HandleCache.CopyAndBindStaleTables(m_DescriptorType, m_DescriptorSize, Allocate(NeededSize), CmdList, SetFunc); -} - -void DynamicDescriptorHeap::UnbindAllValid( void ) -{ - m_GraphicsHandleCache.UnbindAllValid(); - m_ComputeHandleCache.UnbindAllValid(); -} - -D3D12_GPU_DESCRIPTOR_HANDLE DynamicDescriptorHeap::UploadDirect( D3D12_CPU_DESCRIPTOR_HANDLE Handle ) -{ - if (!HasSpace(1)) - { - RetireCurrentHeap(); - UnbindAllValid(); - } - - m_OwningContext.SetDescriptorHeap(m_DescriptorType, GetHeapPointer()); - - DescriptorHandle DestHandle = m_FirstDescriptor + m_CurrentOffset * m_DescriptorSize; - m_CurrentOffset += 1; - - g_Device->CopyDescriptorsSimple(1, DestHandle, Handle, m_DescriptorType); - - return DestHandle; -} - -void DynamicDescriptorHeap::DescriptorHandleCache::UnbindAllValid() -{ - m_StaleRootParamsBitMap = 0; - - unsigned long TableParams = m_RootDescriptorTablesBitMap; - unsigned long RootIndex; - while (_BitScanForward(&RootIndex, TableParams)) - { - TableParams ^= (1 << RootIndex); - if (m_RootDescriptorTable[RootIndex].AssignedHandlesBitMap != 0) - m_StaleRootParamsBitMap |= (1 << RootIndex); - } -} - -void DynamicDescriptorHeap::DescriptorHandleCache::StageDescriptorHandles( UINT RootIndex, UINT Offset, UINT NumHandles, const D3D12_CPU_DESCRIPTOR_HANDLE Handles[] ) -{ - ASSERT(((1 << RootIndex) & m_RootDescriptorTablesBitMap) != 0, "Root parameter is not a CBV_SRV_UAV descriptor table"); - ASSERT(Offset + NumHandles <= m_RootDescriptorTable[RootIndex].TableSize); - - DescriptorTableCache& TableCache = m_RootDescriptorTable[RootIndex]; - D3D12_CPU_DESCRIPTOR_HANDLE* CopyDest = TableCache.TableStart + Offset; - for (UINT i = 0; i < NumHandles; ++i) - CopyDest[i] = Handles[i]; - TableCache.AssignedHandlesBitMap |= ((1 << NumHandles) - 1) << Offset; - m_StaleRootParamsBitMap |= (1 << RootIndex); -} - -void DynamicDescriptorHeap::DescriptorHandleCache::ParseRootSignature( D3D12_DESCRIPTOR_HEAP_TYPE Type, const RootSignature& RootSig ) -{ - UINT CurrentOffset = 0; - - ASSERT(RootSig.m_NumParameters <= 16, "Maybe we need to support something greater"); - - m_StaleRootParamsBitMap = 0; - m_RootDescriptorTablesBitMap = (Type == D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER ? - RootSig.m_SamplerTableBitMap : RootSig.m_DescriptorTableBitMap); - - unsigned long TableParams = m_RootDescriptorTablesBitMap; - unsigned long RootIndex; - while (_BitScanForward(&RootIndex, TableParams)) - { - TableParams ^= (1 << RootIndex); - - UINT TableSize = RootSig.m_DescriptorTableSize[RootIndex]; - ASSERT(TableSize > 0); - - DescriptorTableCache& RootDescriptorTable = m_RootDescriptorTable[RootIndex]; - RootDescriptorTable.AssignedHandlesBitMap = 0; - RootDescriptorTable.TableStart = m_HandleCache + CurrentOffset; - RootDescriptorTable.TableSize = TableSize; - - CurrentOffset += TableSize; - } - - m_MaxCachedDescriptors = CurrentOffset; - - ASSERT(m_MaxCachedDescriptors <= kMaxNumDescriptors, "Exceeded user-supplied maximum cache size"); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/DynamicDescriptorHeap.h b/xess/samples/xess_demo/MiniEngine/Core/DynamicDescriptorHeap.h deleted file mode 100644 index 025f8f0..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/DynamicDescriptorHeap.h +++ /dev/null @@ -1,170 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "DescriptorHeap.h" -#include "RootSignature.h" -#include -#include - -namespace Graphics -{ - extern ID3D12Device* g_Device; -} - -// This class is a linear allocation system for dynamically generated descriptor tables. It internally caches -// CPU descriptor handles so that when not enough space is available in the current heap, necessary descriptors -// can be re-copied to the new heap. -class DynamicDescriptorHeap -{ -public: - DynamicDescriptorHeap(CommandContext& OwningContext, D3D12_DESCRIPTOR_HEAP_TYPE HeapType); - ~DynamicDescriptorHeap(); - - static void DestroyAll(void) - { - sm_DescriptorHeapPool[0].clear(); - sm_DescriptorHeapPool[1].clear(); - } - - void CleanupUsedHeaps( uint64_t fenceValue ); - - // Copy multiple handles into the cache area reserved for the specified root parameter. - void SetGraphicsDescriptorHandles( UINT RootIndex, UINT Offset, UINT NumHandles, const D3D12_CPU_DESCRIPTOR_HANDLE Handles[] ) - { - m_GraphicsHandleCache.StageDescriptorHandles(RootIndex, Offset, NumHandles, Handles); - } - - void SetComputeDescriptorHandles( UINT RootIndex, UINT Offset, UINT NumHandles, const D3D12_CPU_DESCRIPTOR_HANDLE Handles[] ) - { - m_ComputeHandleCache.StageDescriptorHandles(RootIndex, Offset, NumHandles, Handles); - } - - // Bypass the cache and upload directly to the shader-visible heap - D3D12_GPU_DESCRIPTOR_HANDLE UploadDirect( D3D12_CPU_DESCRIPTOR_HANDLE Handles ); - - // Deduce cache layout needed to support the descriptor tables needed by the root signature. - void ParseGraphicsRootSignature( const RootSignature& RootSig ) - { - m_GraphicsHandleCache.ParseRootSignature(m_DescriptorType, RootSig); - } - - void ParseComputeRootSignature( const RootSignature& RootSig ) - { - m_ComputeHandleCache.ParseRootSignature(m_DescriptorType, RootSig); - } - - // Upload any new descriptors in the cache to the shader-visible heap. - inline void CommitGraphicsRootDescriptorTables( ID3D12GraphicsCommandList* CmdList ) - { - if (m_GraphicsHandleCache.m_StaleRootParamsBitMap != 0) - CopyAndBindStagedTables(m_GraphicsHandleCache, CmdList, &ID3D12GraphicsCommandList::SetGraphicsRootDescriptorTable); - } - - inline void CommitComputeRootDescriptorTables( ID3D12GraphicsCommandList* CmdList ) - { - if (m_ComputeHandleCache.m_StaleRootParamsBitMap != 0) - CopyAndBindStagedTables(m_ComputeHandleCache, CmdList, &ID3D12GraphicsCommandList::SetComputeRootDescriptorTable); - } - -private: - - // Static members - static const uint32_t kNumDescriptorsPerHeap = 1024; - static std::mutex sm_Mutex; - static std::vector> sm_DescriptorHeapPool[2]; - static std::queue> sm_RetiredDescriptorHeaps[2]; - static std::queue sm_AvailableDescriptorHeaps[2]; - - // Static methods - static ID3D12DescriptorHeap* RequestDescriptorHeap(D3D12_DESCRIPTOR_HEAP_TYPE HeapType); - static void DiscardDescriptorHeaps( D3D12_DESCRIPTOR_HEAP_TYPE HeapType, uint64_t FenceValueForReset, const std::vector& UsedHeaps ); - - // Non-static members - CommandContext& m_OwningContext; - ID3D12DescriptorHeap* m_CurrentHeapPtr; - const D3D12_DESCRIPTOR_HEAP_TYPE m_DescriptorType; - uint32_t m_DescriptorSize; - uint32_t m_CurrentOffset; - DescriptorHandle m_FirstDescriptor; - std::vector m_RetiredHeaps; - - // Describes a descriptor table entry: a region of the handle cache and which handles have been set - struct DescriptorTableCache - { - DescriptorTableCache() : AssignedHandlesBitMap(0) {} - uint32_t AssignedHandlesBitMap; - D3D12_CPU_DESCRIPTOR_HANDLE* TableStart; - uint32_t TableSize; - }; - - struct DescriptorHandleCache - { - DescriptorHandleCache() - { - ClearCache(); - } - - void ClearCache() - { - m_RootDescriptorTablesBitMap = 0; - m_StaleRootParamsBitMap = 0; - m_MaxCachedDescriptors = 0; - } - - uint32_t m_RootDescriptorTablesBitMap; - uint32_t m_StaleRootParamsBitMap; - uint32_t m_MaxCachedDescriptors; - - static const uint32_t kMaxNumDescriptors = 256; - static const uint32_t kMaxNumDescriptorTables = 16; - - uint32_t ComputeStagedSize(); - void CopyAndBindStaleTables( D3D12_DESCRIPTOR_HEAP_TYPE Type, uint32_t DescriptorSize, DescriptorHandle DestHandleStart, ID3D12GraphicsCommandList* CmdList, - void (STDMETHODCALLTYPE ID3D12GraphicsCommandList::*SetFunc)(UINT, D3D12_GPU_DESCRIPTOR_HANDLE)); - - DescriptorTableCache m_RootDescriptorTable[kMaxNumDescriptorTables]; - D3D12_CPU_DESCRIPTOR_HANDLE m_HandleCache[kMaxNumDescriptors]; - - void UnbindAllValid(); - void StageDescriptorHandles( UINT RootIndex, UINT Offset, UINT NumHandles, const D3D12_CPU_DESCRIPTOR_HANDLE Handles[] ); - void ParseRootSignature( D3D12_DESCRIPTOR_HEAP_TYPE Type, const RootSignature& RootSig ); - }; - - DescriptorHandleCache m_GraphicsHandleCache; - DescriptorHandleCache m_ComputeHandleCache; - - bool HasSpace( uint32_t Count ) - { - return (m_CurrentHeapPtr != nullptr && m_CurrentOffset + Count <= kNumDescriptorsPerHeap); - } - - void RetireCurrentHeap(void); - void RetireUsedHeaps( uint64_t fenceValue ); - ID3D12DescriptorHeap* GetHeapPointer(); - - DescriptorHandle Allocate( UINT Count ) - { - DescriptorHandle ret = m_FirstDescriptor + m_CurrentOffset * m_DescriptorSize; - m_CurrentOffset += Count; - return ret; - } - - void CopyAndBindStagedTables( DescriptorHandleCache& HandleCache, ID3D12GraphicsCommandList* CmdList, - void (STDMETHODCALLTYPE ID3D12GraphicsCommandList::*SetFunc)(UINT, D3D12_GPU_DESCRIPTOR_HANDLE) ); - - // Mark all descriptors in the cache as stale and in need of re-uploading. - void UnbindAllValid( void ); - -}; diff --git a/xess/samples/xess_demo/MiniEngine/Core/EngineProfiling.cpp b/xess/samples/xess_demo/MiniEngine/Core/EngineProfiling.cpp deleted file mode 100644 index ba8a3ef..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/EngineProfiling.cpp +++ /dev/null @@ -1,632 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -// Modified 2022, Intel Corporation. -// Exposed metrics for external usage. - -#include "pch.h" -#include "SystemTime.h" -#include "Display.h" -#include "TextRenderer.h" -#include "GraphRenderer.h" -#include "GameInput.h" -#include "GpuTimeManager.h" -#include "CommandContext.h" -#include -#include -#include - -using namespace Graphics; -using namespace GraphRenderer; -using namespace Math; -using namespace std; - -#define PERF_GRAPH_ERROR uint32_t(0xFFFFFFFF) -namespace EngineProfiling -{ - bool Paused = false; -} - -class StatHistory -{ -public: - StatHistory() - { - for (uint32_t i = 0; i < kHistorySize; ++i) - m_RecentHistory[i] = 0.0f; - for (uint32_t i = 0; i < kExtendedHistorySize; ++i) - m_ExtendedHistory[i] = 0.0f; - m_Average = 0.0f; - m_Minimum = 0.0f; - m_Maximum = 0.0f; - } - - void RecordStat( uint32_t FrameIndex, float Value ) - { - m_RecentHistory[FrameIndex % kHistorySize] = Value; - m_ExtendedHistory[FrameIndex % kExtendedHistorySize] = Value; - m_Recent = Value; - - uint32_t ValidCount = 0; - m_Minimum = FLT_MAX; - m_Maximum = 0.0f; - m_Average = 0.0f; - - for (float val : m_RecentHistory) - { - if (val > 0.0f) - { - ++ValidCount; - m_Average += val; - m_Minimum = min(val, m_Minimum); - m_Maximum = max(val, m_Maximum); - } - } - - if (ValidCount > 0) - m_Average /= (float)ValidCount; - else - m_Minimum = 0.0f; - } - - float GetLast(void) const { return m_Recent; } - float GetMax(void) const { return m_Maximum; } - float GetMin(void) const { return m_Minimum; } - float GetAvg(void) const { return m_Average; } - - const float* GetHistory(void) const { return m_ExtendedHistory; } - uint32_t GetHistoryLength(void) const { return kExtendedHistorySize; } - -private: - static const uint32_t kHistorySize = 64; - static const uint32_t kExtendedHistorySize = 256; - float m_RecentHistory[kHistorySize]; - float m_ExtendedHistory[kExtendedHistorySize]; - float m_Recent; - float m_Average; - float m_Minimum; - float m_Maximum; -}; - -class StatPlot -{ -public: - StatPlot(StatHistory& Data, Color Col = Color(1.0f, 1.0f, 1.0f)) - : m_StatData(Data), m_PlotColor(Col) - { - } - - void SetColor( Color Col ) - { - m_PlotColor = Col; - } - -private: - StatHistory& m_StatData; - Color m_PlotColor; -}; - -class StatGraph -{ -public: - StatGraph(const wstring& Label, D3D12_RECT Window) - : m_Label(Label), m_Window(Window), m_BGColor(0.0f, 0.0f, 0.0f, 0.2f) - { - } - - void SetLabel(const wstring& Label) - { - m_Label = Label; - } - - void SetWindow(D3D12_RECT Window) - { - m_Window = Window; - } - - uint32_t AddPlot( const StatPlot& P ) - { - uint32_t Idx = (uint32_t)m_Stats.size(); - m_Stats.push_back(P); - return Idx; - } - - StatPlot& GetPlot( uint32_t Handle ); - - void Draw( GraphicsContext& Context ); - -private: - wstring m_Label; - D3D12_RECT m_Window; - vector m_Stats; - Color m_BGColor; - float m_PeakValue; -}; - -class GraphManager -{ -public: - -private: - vector m_Graphs; -}; - -class GpuTimer -{ -public: - - GpuTimer::GpuTimer() - { - m_TimerIndex = GpuTimeManager::NewTimer(); - } - - void Start(CommandContext& Context) - { - GpuTimeManager::StartTimer(Context, m_TimerIndex); - } - - void Stop(CommandContext& Context) - { - GpuTimeManager::StopTimer(Context, m_TimerIndex); - } - - float GpuTimer::GetTime(void) - { - return GpuTimeManager::GetTime(m_TimerIndex); - } - - uint32_t GetTimerIndex(void) - { - return m_TimerIndex; - } -private: - - uint32_t m_TimerIndex; -}; - -class NestedTimingTree -{ -public: - NestedTimingTree( const wstring& name, NestedTimingTree* parent = nullptr ) - : m_Name(name), m_Parent(parent), m_IsExpanded(false), m_IsGraphed(false), m_GraphHandle(PERF_GRAPH_ERROR) {} - - NestedTimingTree* GetChild( const wstring& name ) - { - auto iter = m_LUT.find(name); - if (iter != m_LUT.end()) - return iter->second; - - NestedTimingTree* node = new NestedTimingTree(name, this); - m_Children.push_back(node); - m_LUT[name] = node; - return node; - } - - NestedTimingTree* NextScope( void ) - { - if (m_IsExpanded && m_Children.size() > 0) - return m_Children[0]; - - return m_Parent->NextChild(this); - } - - NestedTimingTree* PrevScope( void ) - { - NestedTimingTree* prev = m_Parent->PrevChild(this); - return prev == m_Parent ? prev : prev->LastChild(); - } - - NestedTimingTree* FirstChild( void ) - { - return m_Children.size() == 0 ? nullptr : m_Children[0]; - } - - NestedTimingTree* LastChild( void ) - { - if (!m_IsExpanded || m_Children.size() == 0) - return this; - - return m_Children.back()->LastChild(); - } - - NestedTimingTree* NextChild( NestedTimingTree* curChild ) - { - ASSERT(curChild->m_Parent == this); - - for (auto iter = m_Children.begin(); iter != m_Children.end(); ++iter) - { - if (*iter == curChild) - { - auto nextChild = iter; ++nextChild; - if (nextChild != m_Children.end()) - return *nextChild; - } - } - - if (m_Parent != nullptr) - return m_Parent->NextChild(this); - else - return &sm_RootScope; - } - - NestedTimingTree* PrevChild( NestedTimingTree* curChild ) - { - ASSERT(curChild->m_Parent == this); - - if (*m_Children.begin() == curChild) - { - if (this == &sm_RootScope) - return sm_RootScope.LastChild(); - else - return this; - } - - for (auto iter = m_Children.begin(); iter != m_Children.end(); ++iter) - { - if (*iter == curChild) - { - auto prevChild = iter; --prevChild; - return *prevChild; - } - } - - ERROR("All attempts to find a previous timing sample failed"); - return nullptr; - } - - void StartTiming( CommandContext* Context ) - { - m_StartTick = SystemTime::GetCurrentTick(); - if (Context == nullptr) - return; - - m_GpuTimer.Start(*Context); - - Context->PIXBeginEvent(m_Name.c_str()); - } - - void StopTiming( CommandContext* Context ) - { - m_EndTick = SystemTime::GetCurrentTick(); - if (Context == nullptr) - return; - - m_GpuTimer.Stop(*Context); - - Context->PIXEndEvent(); - } - - void GatherTimes(uint32_t FrameIndex) - { - if (sm_SelectedScope == this) - { - GraphRenderer::SetSelectedIndex(m_GpuTimer.GetTimerIndex()); - } - if (EngineProfiling::Paused) - { - for (auto node : m_Children) - node->GatherTimes(FrameIndex); - return; - } - m_CpuTime.RecordStat(FrameIndex, 1000.0f * (float)SystemTime::TimeBetweenTicks(m_StartTick, m_EndTick)); - m_GpuTime.RecordStat(FrameIndex, 1000.0f * m_GpuTimer.GetTime()); - - for (auto node : m_Children) - node->GatherTimes(FrameIndex); - - m_StartTick = 0; - m_EndTick = 0; - } - - void SumInclusiveTimes(float& cpuTime, float& gpuTime) - { - cpuTime = 0.0f; - gpuTime = 0.0f; - for (auto iter = m_Children.begin(); iter != m_Children.end(); ++iter) - { - cpuTime += (*iter)->m_CpuTime.GetLast(); - gpuTime += (*iter)->m_GpuTime.GetLast(); - } - } - - static void PushProfilingMarker( const wstring& name, CommandContext* Context ); - static void PopProfilingMarker( CommandContext* Context ); - static void Update( void ); - static void UpdateTimes( void ) - { - uint32_t FrameIndex = (uint32_t)Graphics::GetFrameCount(); - - GpuTimeManager::BeginReadBack(); - sm_RootScope.GatherTimes(FrameIndex); - s_FrameDelta.RecordStat(FrameIndex, GpuTimeManager::GetTime(0)); - GpuTimeManager::EndReadBack(); - - float TotalCpuTime, TotalGpuTime; - sm_RootScope.SumInclusiveTimes(TotalCpuTime, TotalGpuTime); - s_TotalCpuTime.RecordStat(FrameIndex, TotalCpuTime); - s_TotalGpuTime.RecordStat(FrameIndex, TotalGpuTime); - - GraphRenderer::Update(XMFLOAT2(TotalCpuTime, TotalGpuTime), 0, GraphType::Global); - } - - static float GetTotalCpuTime(void) { return s_TotalCpuTime.GetAvg(); } - static float GetTotalGpuTime(void) { return s_TotalGpuTime.GetAvg(); } - static float GetFrameDelta(void) { return s_FrameDelta.GetAvg(); } - - static void Display( TextContext& Text, float x ) - { - float curX = Text.GetCursorX(); - Text.DrawString(" "); - float indent = Text.GetCursorX() - curX; - Text.SetCursorX(curX); - sm_RootScope.DisplayNode( Text, x - indent, indent ); - sm_RootScope.StoreToGraph(); - } - - void Toggle() - { - //if (m_GraphHandle == PERF_GRAPH_ERROR) - // m_GraphHandle = GraphRenderer::InitGraph(GraphType::Profile); - //m_IsGraphed = GraphRenderer::ManageGraphs(m_GraphHandle, GraphType::Profile); - } - bool IsGraphed(){ return m_IsGraphed;} - -private: - - void DisplayNode( TextContext& Text, float x, float indent ); - void StoreToGraph(void); - void DeleteChildren( void ) - { - for (auto node : m_Children) - delete node; - m_Children.clear(); - } - - wstring m_Name; - NestedTimingTree* m_Parent; - vector m_Children; - unordered_map m_LUT; - int64_t m_StartTick; - int64_t m_EndTick; - StatHistory m_CpuTime; - StatHistory m_GpuTime; - bool m_IsExpanded; - GpuTimer m_GpuTimer; - bool m_IsGraphed; - GraphHandle m_GraphHandle; - static StatHistory s_TotalCpuTime; - static StatHistory s_TotalGpuTime; - static StatHistory s_FrameDelta; - static NestedTimingTree sm_RootScope; - static NestedTimingTree* sm_CurrentNode; - static NestedTimingTree* sm_SelectedScope; - - static bool sm_CursorOnGraph; - -}; - -StatHistory NestedTimingTree::s_TotalCpuTime; -StatHistory NestedTimingTree::s_TotalGpuTime; -StatHistory NestedTimingTree::s_FrameDelta; -NestedTimingTree NestedTimingTree::sm_RootScope(L""); -NestedTimingTree* NestedTimingTree::sm_CurrentNode = &NestedTimingTree::sm_RootScope; -NestedTimingTree* NestedTimingTree::sm_SelectedScope = &NestedTimingTree::sm_RootScope; -bool NestedTimingTree::sm_CursorOnGraph = false; -namespace EngineProfiling -{ - BoolVar DrawFrameRate("Display Frame Rate", true); - BoolVar DrawProfiler("Display Profiler", false); - //BoolVar DrawPerfGraph("Display Performance Graph", false); - const bool DrawPerfGraph = false; - - void Update( void ) - { - if (GameInput::IsFirstPressed( GameInput::kStartButton ) - || GameInput::IsFirstPressed( GameInput::kKey_space )) - { - Paused = !Paused; - } - NestedTimingTree::UpdateTimes(); - } - - void BeginBlock(const wstring& name, CommandContext* Context) - { - NestedTimingTree::PushProfilingMarker(name, Context); - } - - void EndBlock(CommandContext* Context) - { - NestedTimingTree::PopProfilingMarker(Context); - } - - bool IsPaused() - { - return Paused; - } - - float GetTotalCpuTime() - { - return NestedTimingTree::GetTotalCpuTime(); - } - - float GetTotalGpuTime() - { - return NestedTimingTree::GetTotalGpuTime(); - } - - float GetFrameRate() - { - float frameDelta = NestedTimingTree::GetFrameDelta(); - return (frameDelta > 0.0f) ? (1.0f / frameDelta) : 0.0f; - } - - void DisplayFrameRate(TextContext& Text) - { - if (!DrawFrameRate) - return; - - float cpuTime = NestedTimingTree::GetTotalCpuTime(); - float gpuTime = NestedTimingTree::GetTotalGpuTime(); - float frameRate = 1.0f / NestedTimingTree::GetFrameDelta(); - - Text.DrawFormattedString( "CPU %7.3f ms, GPU %7.3f ms, %3u Hz\n", - cpuTime, gpuTime, (uint32_t)(frameRate + 0.5f)); - } - - void DisplayPerfGraph( GraphicsContext& Context ) - { - if (DrawPerfGraph) - GraphRenderer::RenderGraphs(Context, GraphType::Global ); - } - - void Display( TextContext& Text, float x, float y, float /*w*/, float /*h*/ ) - { - Text.ResetCursor(x, y); - - if (DrawProfiler) - { - //Text.GetCommandContext().SetScissor((uint32_t)Floor(x), (uint32_t)Floor(y), (uint32_t)Ceiling(w), (uint32_t)Ceiling(h)); - - NestedTimingTree::Update(); - - Text.SetColor( Color(0.5f, 1.0f, 1.0f) ); - Text.DrawString("Engine Profiling"); - Text.SetColor(Color(0.8f, 0.8f, 0.8f)); - Text.SetTextSize(20.0f); - Text.DrawString(" CPU GPU"); - Text.SetTextSize(24.0f); - Text.NewLine(); - Text.SetTextSize(20.0f); - Text.SetColor( Color(1.0f, 1.0f, 1.0f) ); - - NestedTimingTree::Display( Text, x ); - } - - Text.GetCommandContext().SetScissor(0, 0, g_DisplayWidth, g_DisplayHeight); - } - -} // EngineProfiling - -void NestedTimingTree::PushProfilingMarker( const wstring& name, CommandContext* Context ) -{ - sm_CurrentNode = sm_CurrentNode->GetChild(name); - sm_CurrentNode->StartTiming(Context); -} - -void NestedTimingTree::PopProfilingMarker( CommandContext* Context ) -{ - sm_CurrentNode->StopTiming(Context); - sm_CurrentNode = sm_CurrentNode->m_Parent; -} - -void NestedTimingTree::Update( void ) -{ - ASSERT(sm_SelectedScope != nullptr, "Corrupted profiling data structure"); - - if (sm_SelectedScope == &sm_RootScope) - { - sm_SelectedScope = sm_RootScope.FirstChild(); - if (sm_SelectedScope == &sm_RootScope) - return; - } - - if (GameInput::IsFirstPressed( GameInput::kDPadLeft ) - || GameInput::IsFirstPressed( GameInput::kKey_left )) - { - //if still on graphs go back to text - if (sm_CursorOnGraph) - sm_CursorOnGraph = !sm_CursorOnGraph; - else - sm_SelectedScope->m_IsExpanded = false; - } - else if (GameInput::IsFirstPressed( GameInput::kDPadRight ) - || GameInput::IsFirstPressed( GameInput::kKey_right )) - { - if (sm_SelectedScope->m_IsExpanded == true && !sm_CursorOnGraph) - sm_CursorOnGraph = true; - else - sm_SelectedScope->m_IsExpanded = true; - //if already expanded go over to graphs - - } - else if (GameInput::IsFirstPressed( GameInput::kDPadDown ) - || GameInput::IsFirstPressed( GameInput::kKey_down )) - { - sm_SelectedScope = sm_SelectedScope ? sm_SelectedScope->NextScope() : nullptr; - } - else if (GameInput::IsFirstPressed( GameInput::kDPadUp ) - || GameInput::IsFirstPressed( GameInput::kKey_up )) - { - sm_SelectedScope = sm_SelectedScope ? sm_SelectedScope->PrevScope() : nullptr; - } - else if (GameInput::IsFirstPressed( GameInput::kAButton ) - || GameInput::IsFirstPressed( GameInput::kKey_return )) - { - sm_SelectedScope->Toggle(); - } - -} - -void NestedTimingTree::DisplayNode( TextContext& Text, float leftMargin, float indent ) -{ - if (this == &sm_RootScope) - { - m_IsExpanded = true; - sm_RootScope.FirstChild()->m_IsExpanded = true; - } - else - { - if (sm_SelectedScope == this && !sm_CursorOnGraph) - Text.SetColor( Color(1.0f, 1.0f, 0.5f) ); - else - Text.SetColor( Color(1.0f, 1.0f, 1.0f) ); - - - Text.SetLeftMargin(leftMargin); - Text.SetCursorX(leftMargin); - - if (m_Children.size() == 0) - Text.DrawString(" "); - else if (m_IsExpanded) - Text.DrawString("- "); - else - Text.DrawString("+ "); - - Text.DrawString(m_Name.c_str()); - Text.SetCursorX(leftMargin + 300.0f); - Text.DrawFormattedString("%6.3f %6.3f ", m_CpuTime.GetAvg(), m_GpuTime.GetAvg()); - - if (IsGraphed()) - { - Text.SetColor(GraphRenderer::GetGraphColor(m_GraphHandle, GraphType::Profile)); - Text.DrawString(" []\n"); - } - else - Text.DrawString("\n"); - } - - if (!m_IsExpanded) - return; - - for (auto node : m_Children) - node->DisplayNode(Text, leftMargin + indent, indent); -} - -void NestedTimingTree::StoreToGraph(void) -{ - if (m_GraphHandle != PERF_GRAPH_ERROR) - GraphRenderer::Update( XMFLOAT2(m_CpuTime.GetLast(), m_GpuTime.GetLast()), m_GraphHandle, GraphType::Profile); - - for (auto node : m_Children) - node->StoreToGraph(); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/EngineProfiling.h b/xess/samples/xess_demo/MiniEngine/Core/EngineProfiling.h deleted file mode 100644 index 8275c6f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/EngineProfiling.h +++ /dev/null @@ -1,68 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -// Modified 2022, Intel Corporation. -// Exposed metrics for external usage. - -#pragma once - -#include -#include "TextRenderer.h" - -class CommandContext; - -namespace EngineProfiling -{ - void Update(); - - void BeginBlock(const std::wstring& name, CommandContext* Context = nullptr); - void EndBlock(CommandContext* Context = nullptr); - - void DisplayFrameRate(TextContext& Text); - void DisplayPerfGraph(GraphicsContext& Text); - void Display(TextContext& Text, float x, float y, float w, float h); - bool IsPaused(); - - float GetTotalCpuTime(); - float GetTotalGpuTime(); - float GetFrameRate(); -} - -#ifdef RELEASE -class ScopedTimer -{ -public: - ScopedTimer(const std::wstring&) {} - ScopedTimer(const std::wstring&, CommandContext&) {} -}; -#else -class ScopedTimer -{ -public: - ScopedTimer( const std::wstring& name ) : m_Context(nullptr) - { - EngineProfiling::BeginBlock(name); - } - ScopedTimer( const std::wstring& name, CommandContext& Context ) : m_Context(&Context) - { - EngineProfiling::BeginBlock(name, m_Context); - } - ~ScopedTimer() - { - EngineProfiling::EndBlock(m_Context); - } - -private: - CommandContext* m_Context; -}; -#endif diff --git a/xess/samples/xess_demo/MiniEngine/Core/EngineTuning.cpp b/xess/samples/xess_demo/MiniEngine/Core/EngineTuning.cpp deleted file mode 100644 index 177630e..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/EngineTuning.cpp +++ /dev/null @@ -1,751 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -// Modified 2022, Intel Corporation. -// Support DPI scale change. - -#include "pch.h" -#include "TextRenderer.h" -#include "GameInput.h" -#include "Color.h" -#include "Display.h" -#include "CommandContext.h" -#include "GraphRenderer.h" -#include "ImGuiModule.h" - -using namespace std; -using namespace Math; -using namespace Graphics; - -namespace EngineTuning -{ - // For delayed registration. Some objects are constructed before we can add them to the graph (due - // to unreliable order of initialization.) - enum { kMaxUnregisteredTweaks = 1024 }; - char s_UnregisteredPath[kMaxUnregisteredTweaks][128]; - EngineVar* s_UnregisteredVariable[kMaxUnregisteredTweaks] = { nullptr }; - int32_t s_UnregisteredCount = 0; - - float s_ScrollOffset = 0.0f; - float s_ScrollTopTrigger = 1080.0f * 0.2f; - float s_ScrollBottomTrigger = 1080.0f * 0.8f; - - // Internal functions - void AddToVariableGraph( const string& path, EngineVar& var ); - void RegisterVariable( const string& path, EngineVar& var ); - - EngineVar* sm_SelectedVariable = nullptr; - bool sm_IsVisible = false; -} - -// Not open to the public. Groups are auto-created when a tweaker's path includes the group name. -class VariableGroup : public EngineVar -{ -public: - VariableGroup() : m_IsExpanded(false) {} - - EngineVar* FindChild( const string& name ) - { - auto iter = m_Children.find(name); - return iter == m_Children.end() ? nullptr : iter->second; - } - - void AddChild( const string& name, EngineVar& child ) - { - m_Children[name] = &child; - child.m_GroupPtr = this; - } - - void Display( TextContext& Text, float leftMargin, EngineVar* highlightedTweak ); - - void SaveToFile( FILE* file, int fileMargin ); - void LoadSettingsFromFile( FILE* file ); - - EngineVar* NextVariable( EngineVar* currentVariable ); - EngineVar* PrevVariable( EngineVar* currentVariable ); - EngineVar* FirstVariable( void ); - EngineVar* LastVariable( void ); - - bool IsExpanded( void ) const { return m_IsExpanded; } - - virtual void Increment( void ) override { m_IsExpanded = true; } - virtual void Decrement( void ) override { m_IsExpanded = false; } - virtual void Bang( void ) override { m_IsExpanded = !m_IsExpanded; } - - virtual void SetValue( FILE*, const std::string& ) override {} - - static VariableGroup sm_RootGroup; - -private: - bool m_IsExpanded; - std::map m_Children; -}; - -VariableGroup VariableGroup::sm_RootGroup; - -//===================================================================================================================== -// VariableGroup implementation - -void VariableGroup::Display( TextContext& Text, float leftMargin, EngineVar* highlightedTweak ) -{ - Text.SetLeftMargin(leftMargin); - Text.SetCursorX(leftMargin); - - for (auto iter = m_Children.begin(); iter != m_Children.end(); ++iter) - { - - if (iter->second == highlightedTweak) - { - Text.SetColor( Color(1.0f, 1.0f, 0.25f) ); - float temp1 = Text.GetCursorY() - EngineTuning::s_ScrollBottomTrigger; - float temp2 = Text.GetCursorY() - EngineTuning::s_ScrollTopTrigger; - if (temp1 > 0.0f) - { - EngineTuning::s_ScrollOffset += 0.2f * temp1; - } - else if (temp2 < 0.0f) - { - EngineTuning::s_ScrollOffset = max(0.0f, EngineTuning::s_ScrollOffset + 0.2f * temp2); - } - } - else - Text.SetColor( Color(1.0f, 1.0f, 1.0f) ); - - VariableGroup* subGroup = dynamic_cast(iter->second); - if (subGroup != nullptr) - { - - if (subGroup->IsExpanded()) - { - Text.DrawString("- "); - } - else - { - Text.DrawString("+ "); - } - Text.DrawString(iter->first); - Text.DrawString("/...\n"); - - if (subGroup->IsExpanded()) - { - subGroup->Display(Text, leftMargin + 30.0f, highlightedTweak); - Text.SetLeftMargin(leftMargin); - Text.SetCursorX(leftMargin); - } - - } - else - { - - iter->second->DisplayValue(Text); - Text.SetCursorX(leftMargin + 200.0f); - Text.DrawString(iter->first); - Text.NewLine(); - } - - } -} - -void VariableGroup::SaveToFile( FILE* file, int fileMargin ) -{ - for (auto iter = m_Children.begin(); iter != m_Children.end(); ++iter) - { - const char* buffer = (iter->first).c_str(); - - VariableGroup* subGroup = dynamic_cast(iter->second); - if (subGroup != nullptr) - { - fprintf(file, "%*c + %s ...\r\n", fileMargin, ' ', buffer); - subGroup->SaveToFile(file, fileMargin + 5); - } - else if (dynamic_cast(iter->second) == nullptr) - { - fprintf(file, "%*c %s: %s\r\n", fileMargin, ' ', buffer, iter->second->ToString().c_str()); - } - } -} - -void VariableGroup::LoadSettingsFromFile( FILE* file ) -{ - for (auto iter = m_Children.begin(); iter != m_Children.end(); ++iter) - { - VariableGroup* subGroup = dynamic_cast(iter->second); - if (subGroup != nullptr) - { - char skippedLines[100]; - fscanf_s(file, "%*s %[^\n]", skippedLines, (int)_countof(skippedLines)); - subGroup->LoadSettingsFromFile(file); - } - else - { - iter->second->SetValue(file, iter->first); - } - } -} - -EngineVar* VariableGroup::FirstVariable( void ) -{ - return m_Children.size() == 0 ? nullptr : m_Children.begin()->second; -} - -EngineVar* VariableGroup::LastVariable( void ) -{ - if (m_Children.size() == 0) - return this; - - auto LastVariable = m_Children.end(); - --LastVariable; - - VariableGroup* isGroup = dynamic_cast(LastVariable->second); - if (isGroup && isGroup->IsExpanded()) - return isGroup->LastVariable(); - - return LastVariable->second; -} - -EngineVar* VariableGroup::NextVariable( EngineVar* curVar ) -{ - auto iter = m_Children.begin(); - for (; iter != m_Children.end(); ++iter) - { - if (curVar == iter->second) - break; - } - - ASSERT( iter != m_Children.end(), "Did not find engine variable in its designated group" ); - - auto nextIter = iter; - ++nextIter; - - if (nextIter == m_Children.end()) - return m_GroupPtr ? m_GroupPtr->NextVariable(this) : nullptr; - else - return nextIter->second; -} - -EngineVar* VariableGroup::PrevVariable( EngineVar* curVar ) -{ - auto iter = m_Children.begin(); - for (; iter != m_Children.end(); ++iter) - { - if (curVar == iter->second) - break; - } - - ASSERT( iter != m_Children.end(), "Did not find engine variable in its designated group" ); - - if (iter == m_Children.begin()) - return this; - - auto prevIter = iter; - --prevIter; - - VariableGroup* isGroup = dynamic_cast(prevIter->second); - if (isGroup && isGroup->IsExpanded()) - return isGroup->LastVariable(); - - return prevIter->second; -} - -//===================================================================================================================== -// EngineVar implementations - -EngineVar::EngineVar( void ) : m_GroupPtr(nullptr) -{ -} - -EngineVar::EngineVar( const std::string& path, ActionCallback pfnCallback) : m_GroupPtr(nullptr), m_ActionCallback(pfnCallback) -{ - EngineTuning::RegisterVariable(path, *this); -} - - -EngineVar* EngineVar::NextVar( void ) -{ - EngineVar* next = nullptr; - VariableGroup* isGroup = dynamic_cast(this); - if (isGroup != nullptr && isGroup->IsExpanded()) - next = isGroup->FirstVariable(); - - if (next == nullptr) - next = m_GroupPtr->NextVariable(this); - - return next != nullptr ? next : this; -} - -EngineVar* EngineVar::PrevVar( void ) -{ - EngineVar* prev = m_GroupPtr->PrevVariable(this); - if (prev != nullptr && prev != m_GroupPtr) - { - VariableGroup* isGroup = dynamic_cast(prev); - if (isGroup != nullptr && isGroup->IsExpanded()) - prev = isGroup->LastVariable(); - } - return prev != nullptr ? prev : this; -} - -BoolVar::BoolVar( const std::string& path, bool val, ActionCallback pfnCallback ) - : EngineVar(path, pfnCallback) -{ - m_Flag = val; -} - -void BoolVar::DisplayValue( TextContext& Text ) const -{ - Text.DrawFormattedString("[%c]", m_Flag ? 'X' : '-'); -} - -std::string BoolVar::ToString( void ) const -{ - return m_Flag ? "on" : "off"; -} - -void BoolVar::SetValue(FILE* file, const std::string& setting) -{ - std::string pattern = "\n " + setting + ": %s"; - char valstr[6]; - - // Search through the file for an entry that matches this setting's name - fscanf_s(file, pattern.c_str(), valstr, _countof(valstr)); - - // Look for one of the many affirmations - m_Flag = ( - 0 == _stricmp(valstr, "1") || - 0 == _stricmp(valstr, "on") || - 0 == _stricmp(valstr, "yes") || - 0 == _stricmp(valstr, "true") ); -} - -NumVar::NumVar( const std::string& path, float val, float minVal, float maxVal, float stepSize, ActionCallback pfnCallback ) - : EngineVar(path, pfnCallback) -{ - ASSERT(minVal <= maxVal); - m_MinValue = minVal; - m_MaxValue = maxVal; - m_Value = Clamp(val); - m_StepSize = stepSize; -} - -void NumVar::DisplayValue( TextContext& Text ) const -{ - Text.DrawFormattedString("%-11f", m_Value); -} - -std::string NumVar::ToString( void ) const -{ - char buf[128]; - sprintf_s(buf, "%f", m_Value); - return buf; -} - -void NumVar::SetValue(FILE* file, const std::string& setting) -{ - std::string scanString = "\n" + setting + ": %f"; - float valueRead; - - //If we haven't read correctly, just keep m_Value at default value - if (fscanf_s(file, scanString.c_str(), &valueRead)) - *this = valueRead; -} - -#if _MSC_VER < 1800 -__forceinline float log2( float x ) { return log(x) / log(2.0f); } -__forceinline float exp2( float x ) { return pow(2.0f, x); } -#endif - -ExpVar::ExpVar( const std::string& path, float val, float minExp, float maxExp, float expStepSize, ActionCallback pfnCallback ) - : NumVar(path, log2f(val), minExp, maxExp, expStepSize, pfnCallback) -{ -} - -ExpVar& ExpVar::operator=( float val ) -{ - m_Value = Clamp(log2f(val)); - return *this; -} - -ExpVar::operator float() const -{ - return exp2f(m_Value); -} - -void ExpVar::DisplayValue( TextContext& Text ) const -{ - Text.DrawFormattedString("%-11f", (float)*this); -} - -std::string ExpVar::ToString( void ) const -{ - char buf[128]; - sprintf_s(buf, "%f", (float)*this); - return buf; -} - -void ExpVar::SetValue(FILE* file, const std::string& setting) -{ - std::string scanString = "\n" + setting + ": %f"; - float valueRead; - - //If we haven't read correctly, just keep m_Value at default value - if (fscanf_s(file, scanString.c_str(), &valueRead)) - *this = valueRead; -} - -IntVar::IntVar( const std::string& path, int32_t val, int32_t minVal, int32_t maxVal, int32_t stepSize, ActionCallback pfnCallback ) - : EngineVar(path, pfnCallback) -{ - ASSERT(minVal <= maxVal); - m_MinValue = minVal; - m_MaxValue = maxVal; - m_Value = Clamp(val); - m_StepSize = stepSize; -} - -void IntVar::DisplayValue( TextContext& Text ) const -{ - Text.DrawFormattedString("%-11d", m_Value); -} - -std::string IntVar::ToString( void ) const -{ - char buf[128]; - sprintf_s(buf, "%d", m_Value); - return buf; -} - -void IntVar::SetValue(FILE* file, const std::string& setting) -{ - std::string scanString = "\n" + setting + ": %d"; - int32_t valueRead; - - if (fscanf_s(file, scanString.c_str(), &valueRead)) - *this = valueRead; -} - - -EnumVar::EnumVar( const std::string& path, int32_t initialVal, int32_t listLength, const char** listLabels, ActionCallback pfnCallback ) - : EngineVar(path, pfnCallback) -{ - ASSERT(listLength > 0); - m_EnumLength = listLength; - m_EnumLabels = listLabels; - m_Value = Clamp(initialVal); -} - -void EnumVar::DisplayValue( TextContext& Text ) const -{ - Text.DrawString(m_EnumLabels[m_Value]); -} - -std::string EnumVar::ToString( void ) const -{ - return m_EnumLabels[m_Value]; -} - -void EnumVar::SetValue(FILE* file, const std::string& setting) -{ - std::string scanString = "\n" + setting + ": %[^\n]"; - char valueRead[14]; - - if (fscanf_s(file, scanString.c_str(), valueRead, _countof(valueRead)) == 1) - { - std::string valueReadStr = valueRead; - valueReadStr = valueReadStr.substr(0, valueReadStr.length() - 1); - - //if we don't find the string, then leave m_EnumLabes[m_Value] as default - for(int32_t i = 0; i < m_EnumLength; ++i) - { - if (m_EnumLabels[i] == valueReadStr) - { - m_Value = i; - break; - } - } - } -} - -DynamicEnumVar::DynamicEnumVar( const std::string& path, ActionCallback pfnCallback ) - : EngineVar(path, pfnCallback) -{ - m_EnumCount = 0; - m_Value = 0; -} - -void DynamicEnumVar::DisplayValue( TextContext& Text ) const -{ - Text.DrawString(m_EnumLabels[m_Value]); -} - -std::string DynamicEnumVar::ToString( void ) const -{ - return Utility::WideStringToUTF8(m_EnumLabels[m_Value]); -} - -void DynamicEnumVar::SetValue(FILE* file, const std::string& setting) -{ - std::string scanString = "\n" + setting + ": %[^\n]"; - char valueRead[14]; - - if (fscanf_s(file, scanString.c_str(), valueRead, _countof(valueRead)) == 1) - { - std::string valueReadStr = valueRead; - valueReadStr = valueReadStr.substr(0, valueReadStr.length() - 1); - - std::wstring wvalue = Utility::UTF8ToWideString(valueReadStr); - - //if we don't find the string, then leave m_EnumLabes[m_Value] as default - for (int32_t i = 0; i < m_EnumCount; ++i) - { - if (m_EnumLabels[i] == wvalue) - { - m_Value = i; - break; - } - } - } -} - - -CallbackTrigger::CallbackTrigger( const std::string& path, std::function callback, void* args ) - : EngineVar(path) -{ - m_Callback = callback; - m_Arguments = args; - m_BangDisplay = 0; -} - -void CallbackTrigger::DisplayValue( TextContext& Text ) const -{ - static const char s_animation[] = { '-', '\\', '|', '/' }; - Text.DrawFormattedString("[%c]", s_animation[(m_BangDisplay >> 3) & 3]); - - if (m_BangDisplay > 0) - --m_BangDisplay; -} - -void CallbackTrigger::SetValue(FILE* file, const std::string& setting) -{ - //Skip over setting without reading anything - std::string scanString = "\n" + setting + ": %[^\n]"; - char skippedLines[100]; - fscanf_s(file, scanString.c_str(), skippedLines, _countof(skippedLines)); -} - -//===================================================================================================================== -// EngineTuning namespace methods - -void EngineTuning::Initialize( void ) -{ - - for (int32_t i = 0; i < s_UnregisteredCount; ++i) - { - ASSERT(strlen(s_UnregisteredPath[i]) > 0, "Register = %d\n", i); - ASSERT(s_UnregisteredVariable[i] != nullptr); - AddToVariableGraph(s_UnregisteredPath[i], *s_UnregisteredVariable[i]); - } - s_UnregisteredCount = -1; - -} - -void HandleDigitalButtonPress( GameInput::DigitalInput button, float timeDelta, std::function action ) -{ - if (!GameInput::IsPressed(button)) - return; - - float durationHeld = GameInput::GetDurationPressed(button); - - // Tick on the first press - if (durationHeld == 0.0f) - { - action(); - return; - } - - // After ward, tick at fixed intervals - float oldDuration = durationHeld - timeDelta; - - // Before 2 seconds, use slow scale (200ms/tick), afterward use fast scale (50ms/tick). - float timeStretch = durationHeld < 2.0f ? 5.0f : 20.0f; - - if (Floor(durationHeld * timeStretch) > Floor(oldDuration * timeStretch)) - action(); -} - -void EngineTuning::Update( float frameTime ) -{ - if (!ImGuiModule::WantCaptureKeyboard() - && (GameInput::IsFirstPressed( GameInput::kBackButton ) - || GameInput::IsFirstPressed( GameInput::kKey_back ))) - sm_IsVisible = !sm_IsVisible; - - if (!sm_IsVisible) - return; - - if (sm_SelectedVariable == nullptr || sm_SelectedVariable == &VariableGroup::sm_RootGroup) - sm_SelectedVariable = VariableGroup::sm_RootGroup.FirstVariable(); - - if (sm_SelectedVariable == nullptr) - return; - - // Detect a DPad button press - HandleDigitalButtonPress(GameInput::kDPadRight, frameTime, []{ sm_SelectedVariable->Increment(); } ); - HandleDigitalButtonPress(GameInput::kDPadLeft, frameTime, []{ sm_SelectedVariable->Decrement(); } ); - HandleDigitalButtonPress(GameInput::kDPadDown, frameTime, []{ sm_SelectedVariable = sm_SelectedVariable->NextVar(); } ); - HandleDigitalButtonPress(GameInput::kDPadUp, frameTime, []{ sm_SelectedVariable = sm_SelectedVariable->PrevVar(); } ); - - HandleDigitalButtonPress(GameInput::kKey_right, frameTime, []{ sm_SelectedVariable->Increment(); } ); - HandleDigitalButtonPress(GameInput::kKey_left, frameTime, []{ sm_SelectedVariable->Decrement(); } ); - HandleDigitalButtonPress(GameInput::kKey_down, frameTime, []{ sm_SelectedVariable = sm_SelectedVariable->NextVar(); } ); - HandleDigitalButtonPress(GameInput::kKey_up, frameTime, []{ sm_SelectedVariable = sm_SelectedVariable->PrevVar(); } ); - - if (GameInput::IsFirstPressed( GameInput::kAButton ) - || GameInput::IsFirstPressed( GameInput::kKey_return )) - { - sm_SelectedVariable->Bang(); - } -} - -/* -void StartSave(void*) -{ - FILE* settingsFile; - fopen_s(&settingsFile, "engineTuning.txt", "wb"); - if (settingsFile != nullptr) - { - VariableGroup::sm_RootGroup.SaveToFile(settingsFile, 2 ); - fclose(settingsFile); - } -} -std::function StartSaveFunc = StartSave; -static CallbackTrigger Save("Save Settings", StartSaveFunc, nullptr); - -void StartLoad(void*) -{ - FILE* settingsFile; - fopen_s(&settingsFile, "engineTuning.txt", "rb"); - if (settingsFile != nullptr) - { - VariableGroup::sm_RootGroup.LoadSettingsFromFile(settingsFile); - fclose(settingsFile); - } -} -std::function StartLoadFunc = StartLoad; -static CallbackTrigger Load("Load Settings", StartLoadFunc, nullptr); -*/ - -void EngineTuning::Display( GraphicsContext& Context, float x, float y, float w, float h ) -{ - GraphRenderer::RenderGraphs(Context, GraphRenderer::GraphType::Profile); - - TextContext Text(Context, w, h); - Text.Begin(); - - EngineProfiling::DisplayFrameRate(Text); - - Text.ResetCursor( x, y ); - - if (!sm_IsVisible) - { - EngineProfiling::Display(Text, x, y, w, h); - return; - } - - s_ScrollTopTrigger = y + h * 0.2f; - s_ScrollBottomTrigger = y + h * 0.8f; - - /* - float hScale = g_DisplayWidth / 1920.0f; - float vScale = g_DisplayHeight / 1080.0f; - - Context.SetScissor((uint32_t)Floor(x * hScale), (uint32_t)Floor(y * vScale), - (uint32_t)Ceiling((x + w) * hScale), (uint32_t)Ceiling((y + h) * vScale)); - */ - Context.SetScissor((uint32_t)Floor(x), (uint32_t)Floor(y), - (uint32_t)Ceiling(x + w), (uint32_t)Ceiling(y + h)); - - Text.ResetCursor(x, y - s_ScrollOffset ); - Text.SetColor( Color(0.5f, 1.0f, 1.0f) ); - Text.DrawString("Engine Tuning\n"); - Text.SetTextSize(20.0f); - - VariableGroup::sm_RootGroup.Display( Text, x, sm_SelectedVariable ); - - EngineProfiling::DisplayPerfGraph(Context); - - Text.End(); - Context.SetScissor(0, 0, g_DisplayWidth, g_DisplayHeight); -} - -void EngineTuning::AddToVariableGraph( const string& path, EngineVar& var ) -{ - vector separatedPath; - string leafName; - size_t start = 0, end = 0; - - while (1) - { - end = path.find('/', start); - if (end == string::npos) - { - leafName = path.substr(start); - break; - } - else - { - separatedPath.push_back(path.substr(start, end - start)); - start = end + 1; - } - } - - VariableGroup* group = &VariableGroup::sm_RootGroup; - - for (auto iter = separatedPath.begin(); iter != separatedPath.end(); ++iter ) - { - VariableGroup* nextGroup; - EngineVar* node = group->FindChild(*iter); - if (node == nullptr) - { - nextGroup = new VariableGroup(); - group->AddChild(*iter, *nextGroup); - group = nextGroup; - } - else - { - nextGroup = dynamic_cast(node); - ASSERT(nextGroup != nullptr, "Attempted to trash the tweak graph"); - group = nextGroup; - } - } - - group->AddChild(leafName, var); -} - -void EngineTuning::RegisterVariable( const std::string& path, EngineVar& var ) -{ - if (s_UnregisteredCount >= 0) - { - int32_t Idx = s_UnregisteredCount++; - strcpy_s(s_UnregisteredPath[Idx], path.c_str()); - s_UnregisteredVariable[Idx] = &var; - } - else - { - AddToVariableGraph( path, var ); - } -} - -bool EngineTuning::IsFocused( void ) -{ - return sm_IsVisible; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/EngineTuning.h b/xess/samples/xess_demo/MiniEngine/Core/EngineTuning.h deleted file mode 100644 index 11d1714..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/EngineTuning.h +++ /dev/null @@ -1,221 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include -#include -#include -#include -#include - -class VariableGroup; -class TextContext; - -class EngineVar -{ -public: - EngineVar(const EngineVar&) = delete; - EngineVar& operator=(EngineVar const&) = delete; - - virtual ~EngineVar() {} - - virtual void Increment( void ) { m_ActionCallback(ActionType::Increment); } // DPad Right - virtual void Decrement( void ) { m_ActionCallback(ActionType::Decrement); } // DPad Left - virtual void Bang( void ) { m_ActionCallback(ActionType::Bang); } // A Button - - virtual void DisplayValue( TextContext& ) const {} - virtual std::string ToString( void ) const { return ""; } - virtual void SetValue( FILE* file, const std::string& setting) = 0; //set value read from file - - EngineVar* NextVar( void ); - EngineVar* PrevVar( void ); - - enum class ActionType - { - Increment, - Decrement, - Bang - }; - - typedef std::function ActionCallback; - -protected: - - EngineVar( void ); - EngineVar( const std::string& path, ActionCallback pfnCallback = DefaultActionHandler ); - - static void DefaultActionHandler(ActionType) - { - // nothing - } - -private: - friend class VariableGroup; - VariableGroup* m_GroupPtr; - - ActionCallback m_ActionCallback; -}; - -class BoolVar : public EngineVar -{ -public: - BoolVar( const std::string& path, bool val, ActionCallback pfnCallback = EngineVar::DefaultActionHandler ); - BoolVar& operator=( bool val ) { m_Flag = val; return *this; } - operator bool() const { return m_Flag; } - - virtual void Increment( void ) override { m_Flag = true; EngineVar::Increment(); } - virtual void Decrement( void ) override { m_Flag = false; EngineVar::Decrement(); } - virtual void Bang( void ) override { m_Flag = !m_Flag; EngineVar::Bang(); } - - virtual void DisplayValue( TextContext& Text ) const override; - virtual std::string ToString( void ) const override; - virtual void SetValue( FILE* file, const std::string& setting) override; - -private: - bool m_Flag; -}; - -class NumVar : public EngineVar -{ -public: - NumVar( const std::string& path, float val, float minValue = -FLT_MAX, float maxValue = FLT_MAX, float stepSize = 1.0f, ActionCallback pfnCallback = EngineVar::DefaultActionHandler); - NumVar& operator=( float val ) { m_Value = Clamp(val); return *this; } - operator float() const { return m_Value; } - - virtual void Increment( void ) override { m_Value = Clamp(m_Value + m_StepSize); EngineVar::Increment(); } - virtual void Decrement( void ) override { m_Value = Clamp(m_Value - m_StepSize); EngineVar::Decrement(); } - - virtual void DisplayValue( TextContext& Text ) const override; - virtual std::string ToString( void ) const override; - virtual void SetValue( FILE* file, const std::string& setting) override; - -protected: - float Clamp( float val ) { return val > m_MaxValue ? m_MaxValue : val < m_MinValue ? m_MinValue : val; } - - float m_Value; - float m_MinValue; - float m_MaxValue; - float m_StepSize; -}; - -class ExpVar : public NumVar -{ -public: - ExpVar( const std::string& path, float val, float minExp = -FLT_MAX, float maxExp = FLT_MAX, float expStepSize = 1.0f, ActionCallback pfnCallback = EngineVar::DefaultActionHandler); - ExpVar& operator=( float val ); // m_Value = log2(val) - operator float() const; // returns exp2(m_Value) - - virtual void DisplayValue( TextContext& Text ) const override; - virtual std::string ToString( void ) const override; - virtual void SetValue( FILE* file, const std::string& setting ) override; - -}; - -class IntVar : public EngineVar -{ -public: - IntVar( const std::string& path, int32_t val, int32_t minValue = 0, int32_t maxValue = (1 << 24) - 1, int32_t stepSize = 1, ActionCallback pfnCallback = EngineVar::DefaultActionHandler); - IntVar& operator=( int32_t val ) { m_Value = Clamp(val); return *this; } - operator int32_t() const { return m_Value; } - - virtual void Increment( void ) override { m_Value = Clamp(m_Value + m_StepSize); EngineVar::Increment(); } - virtual void Decrement( void ) override { m_Value = Clamp(m_Value - m_StepSize); EngineVar::Decrement(); } - - virtual void DisplayValue( TextContext& Text ) const override; - virtual std::string ToString( void ) const override; - virtual void SetValue( FILE* file, const std::string& setting ) override; - -protected: - int32_t Clamp( int32_t val ) { return val > m_MaxValue ? m_MaxValue : val < m_MinValue ? m_MinValue : val; } - - int32_t m_Value; - int32_t m_MinValue; - int32_t m_MaxValue; - int32_t m_StepSize; -}; - -class EnumVar : public EngineVar -{ -public: - EnumVar( const std::string& path, int32_t initialVal, int32_t listLength, const char** listLabels, ActionCallback pfnCallback = EngineVar::DefaultActionHandler); - EnumVar& operator=( int32_t val ) { m_Value = Clamp(val); return *this; } - operator int32_t() const { return m_Value; } - - virtual void Increment( void ) override { m_Value = (m_Value + 1) % m_EnumLength; EngineVar::Increment(); } - virtual void Decrement( void ) override { m_Value = (m_Value + m_EnumLength - 1) % m_EnumLength; EngineVar::Decrement(); } - - virtual void DisplayValue( TextContext& Text ) const override; - virtual std::string ToString( void ) const override; - virtual void SetValue( FILE* file, const std::string& setting ) override; - - void SetListLength(int32_t listLength) { m_EnumLength = listLength; m_Value = Clamp(m_Value); } - -private: - int32_t Clamp( int32_t val ) { return val < 0 ? 0 : val >= m_EnumLength ? m_EnumLength - 1 : val; } - - int32_t m_Value; - int32_t m_EnumLength; - const char** m_EnumLabels; -}; - -class DynamicEnumVar : public EngineVar -{ -public: - DynamicEnumVar( const std::string& path, ActionCallback pfnCallback = EngineVar::DefaultActionHandler); - DynamicEnumVar& operator=( int32_t val ) { m_Value = Clamp(val); return *this; } - operator int32_t() const { return m_Value; } - - virtual void Increment( void ) override { m_Value = (m_Value + 1) % m_EnumCount; EngineVar::Increment(); } - virtual void Decrement( void ) override { m_Value = (m_Value + m_EnumCount - 1) % m_EnumCount; EngineVar::Decrement(); } - - virtual void DisplayValue( TextContext& Text ) const override; - virtual std::string ToString( void ) const override; - virtual void SetValue( FILE* file, const std::string& setting ) override; - - void AddEnum(const std::wstring& enumLabel) { m_EnumLabels.push_back(enumLabel); m_EnumCount++; } - -private: - int32_t Clamp( int32_t val ) { return val < 0 ? 0 : val >= m_EnumCount ? m_EnumCount - 1 : val; } - - int32_t m_Value; - int32_t m_EnumCount; - std::vector m_EnumLabels; -}; - -class CallbackTrigger : public EngineVar -{ -public: - CallbackTrigger( const std::string& path, std::function callback, void* args = nullptr ); - - virtual void Bang( void ) override { m_Callback(m_Arguments); m_BangDisplay = 64; } - - virtual void DisplayValue( TextContext& Text ) const override; - virtual void SetValue( FILE* file, const std::string& setting ) override; - -private: - std::function m_Callback; - void* m_Arguments; - mutable uint32_t m_BangDisplay; -}; - -class GraphicsContext; - -namespace EngineTuning -{ - void Initialize( void ); - void Update( float frameTime ); - void Display( GraphicsContext& Context, float x, float y, float w, float h ); - bool IsFocused( void ); - -} // namespace EngineTuning diff --git a/xess/samples/xess_demo/MiniEngine/Core/EsramAllocator.h b/xess/samples/xess_demo/MiniEngine/Core/EsramAllocator.h deleted file mode 100644 index 7620426..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/EsramAllocator.h +++ /dev/null @@ -1,37 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "pch.h" - -class EsramAllocator -{ -public: - EsramAllocator() {} - - void PushStack() {} - void PopStack() {} - - D3D12_GPU_VIRTUAL_ADDRESS Alloc( size_t size, size_t align, const std::wstring& bufferName ) - { - (size); (align); (bufferName); - return D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN; - } - - intptr_t SizeOfFreeSpace( void ) const - { - return 0; - } - -}; diff --git a/xess/samples/xess_demo/MiniEngine/Core/FXAA.cpp b/xess/samples/xess_demo/MiniEngine/Core/FXAA.cpp deleted file mode 100644 index df3fa1c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/FXAA.cpp +++ /dev/null @@ -1,222 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "FXAA.h" -#include "GraphicsCore.h" -#include "BufferManager.h" -#include "CommandContext.h" - -#include "CompiledShaders/FXAAPass1_RGB_CS.h" -#include "CompiledShaders/FXAAPass1_Luma_CS.h" -#include "CompiledShaders/FXAAPass2HCS.h" -#include "CompiledShaders/FXAAPass2VCS.h" -#include "CompiledShaders/FXAAPass2HDebugCS.h" -#include "CompiledShaders/FXAAPass2VDebugCS.h" - -// These shaders are when typed UAV loads of complex formats is available -#include "CompiledShaders/FXAAPass1_RGB2_CS.h" -#include "CompiledShaders/FXAAPass1_Luma2_CS.h" -#include "CompiledShaders/FXAAPass2H2CS.h" -#include "CompiledShaders/FXAAPass2V2CS.h" -#include "CompiledShaders/FXAAPass2HDebug2CS.h" -#include "CompiledShaders/FXAAPass2VDebug2CS.h" - -#include "CompiledShaders/FXAAResolveWorkQueueCS.h" - - -using namespace Graphics; - -namespace FXAA -{ - RootSignature RootSig; - ComputePSO Pass1HdrCS(L"FXAA: Pass 1 HDR CS"); - ComputePSO Pass1LdrCS(L"FXAA: Pass 1 LDR CS"); - ComputePSO ResolveWorkCS(L"FXAA: Resolve Work CS"); - ComputePSO Pass2HCS(L"FXAA: Pass 2 H CS"); - ComputePSO Pass2VCS(L"FXAA: Pass 2 V CS"); - ComputePSO Pass2HDebugCS(L"FXAA: Pass 2 H Debug CS"); - ComputePSO Pass2VDebugCS(L"FXAA: Pass 2 V Debug CS"); - IndirectArgsBuffer IndirectParameters; - ByteAddressBuffer WorkCounters; - - BoolVar Enable("Graphics/AA/FXAA/Enable", true); - BoolVar DebugDraw("Graphics/AA/FXAA/Debug", false); - - // With a properly encoded luma buffer, [0.25 = "low", 0.2 = "medium", 0.15 = "high", 0.1 = "ultra"] - NumVar ContrastThreshold("Graphics/AA/FXAA/Contrast Threshold", 0.175f, 0.05f, 0.5f, 0.025f); - - // Controls how much to blur isolated pixels that have little-to-no edge length. - NumVar SubpixelRemoval("Graphics/AA/FXAA/Subpixel Removal", 0.50f, 0.0f, 1.0f, 0.25f); - - // This is for testing the performance of computing luma on the fly rather than reusing - // the luma buffer output of tone mapping. - BoolVar ForceOffPreComputedLuma("Graphics/AA/FXAA/Always Recompute Log-Luma", false); -} - -void FXAA::Initialize( void ) -{ - RootSig.Reset(3, 1); - RootSig.InitStaticSampler(0, SamplerLinearClampDesc); - RootSig[0].InitAsConstants(0, 7); - RootSig[1].InitAsDescriptorRange(D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 0, 5); - RootSig[2].InitAsDescriptorRange(D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 6); - RootSig.Finalize(L"FXAA"); - -#define CreatePSO( ObjName, ShaderByteCode ) \ - ObjName.SetRootSignature(RootSig); \ - ObjName.SetComputeShader(ShaderByteCode, sizeof(ShaderByteCode) ); \ - ObjName.Finalize(); - - CreatePSO(ResolveWorkCS, g_pFXAAResolveWorkQueueCS); - if (g_bTypedUAVLoadSupport_R11G11B10_FLOAT) - { - CreatePSO(Pass1LdrCS, g_pFXAAPass1_RGB2_CS); // Use RGB and recompute log-luma; pre-computed luma is unavailable - CreatePSO(Pass1HdrCS, g_pFXAAPass1_Luma2_CS); // Use pre-computed luma - CreatePSO(Pass2HCS, g_pFXAAPass2H2CS); - CreatePSO(Pass2VCS, g_pFXAAPass2V2CS); - CreatePSO(Pass2HDebugCS, g_pFXAAPass2HDebug2CS); - CreatePSO(Pass2VDebugCS, g_pFXAAPass2VDebug2CS); - } - else - { - CreatePSO(Pass1LdrCS, g_pFXAAPass1_RGB_CS); // Use RGB and recompute log-luma; pre-computed luma is unavailable - CreatePSO(Pass1HdrCS, g_pFXAAPass1_Luma_CS); // Use pre-computed luma - CreatePSO(Pass2HCS, g_pFXAAPass2HCS); - CreatePSO(Pass2VCS, g_pFXAAPass2VCS); - CreatePSO(Pass2HDebugCS, g_pFXAAPass2HDebugCS); - CreatePSO(Pass2VDebugCS, g_pFXAAPass2VDebugCS); - } -#undef CreatePSO - - __declspec(align(16)) const uint32_t initArgs[6] = { 0, 1, 1, 0, 1, 1 }; - IndirectParameters.Create(L"FXAA Indirect Parameters", 2, sizeof(D3D12_DISPATCH_ARGUMENTS), initArgs); - WorkCounters.Create(L"FXAA Work Counters", 2, sizeof(uint32_t)); - - GraphicsContext& InitContext = GraphicsContext::Begin(); - InitContext.TransitionResource(WorkCounters, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - InitContext.ClearUAV(WorkCounters); - InitContext.Finish(); -} - -void FXAA::Shutdown(void) -{ - IndirectParameters.Destroy(); - WorkCounters.Destroy(); -} - -void FXAA::Render( ComputeContext& Context, bool bUsePreComputedLuma ) -{ - ScopedTimer _prof(L"FXAA", Context); - - if (ForceOffPreComputedLuma) - bUsePreComputedLuma = false; - - ColorBuffer& Target = g_bTypedUAVLoadSupport_R11G11B10_FLOAT ? g_SceneColorBuffer : g_PostEffectsBuffer; - - Context.SetRootSignature(RootSig); - Context.SetConstants(0, 1.0f / Target.GetWidth(), 1.0f / Target.GetHeight(), (float)ContrastThreshold, (float)SubpixelRemoval); - Context.SetConstant(0, 4, g_FXAAWorkQueue.GetElementCount() - 1); - - // Apply algorithm to each quarter of the screen separately to reduce maximum size of work buffers. - uint32_t BlockWidth = Target.GetWidth() / 2; - uint32_t BlockHeight = Target.GetHeight() / 2; - - D3D12_CPU_DESCRIPTOR_HANDLE Pass1UAVs[] = - { - WorkCounters.GetUAV(), - g_FXAAWorkQueue.GetUAV(), - g_FXAAColorQueue.GetUAV(), - g_LumaBuffer.GetUAV() - }; - - D3D12_CPU_DESCRIPTOR_HANDLE Pass1SRVs[] = - { - Target.GetSRV(), - g_LumaBuffer.GetSRV() - }; - - for (uint32_t x = 0; x < 2; x++) - { - for (uint32_t y = 0; y < 2; y++) - { - // Pass 1 - Context.SetConstant(0, 5, x*BlockWidth); - Context.SetConstant(0, 6, y*BlockHeight); - - // Begin by analysing the luminance buffer and setting aside high-contrast pixels in - // work queues to be processed later. There are horizontal edge and vertical edge work - // queues so that the shader logic is simpler for each type of edge. - // Counter values do not need to be reset because they are read and cleared at once. - - Context.TransitionResource(Target, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_FXAAWorkQueue, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_FXAAColorQueue, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - - if (bUsePreComputedLuma) - { - Context.SetPipelineState(Pass1HdrCS); - Context.TransitionResource(g_LumaBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.SetDynamicDescriptors(1, 0, _countof(Pass1UAVs) - 1, Pass1UAVs); - Context.SetDynamicDescriptors(2, 0, _countof(Pass1SRVs), Pass1SRVs); - } - else - { - Context.SetPipelineState(Pass1LdrCS); - Context.TransitionResource(g_LumaBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.SetDynamicDescriptors(1, 0, _countof(Pass1UAVs), Pass1UAVs); - Context.SetDynamicDescriptors(2, 0, _countof(Pass1SRVs) - 1, Pass1SRVs); - } - - Context.Dispatch2D(BlockWidth, BlockHeight); - - // Pass 2 - - // The next phase involves converting the work queues to DispatchIndirect parameters. - // The queues are also padded out to 64 elements to simplify the final consume logic. - Context.SetPipelineState(ResolveWorkCS); - Context.TransitionResource(IndirectParameters, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.InsertUAVBarrier(WorkCounters); - - Context.SetDynamicDescriptor(1, 0, IndirectParameters.GetUAV()); - Context.SetDynamicDescriptor(1, 1, g_FXAAWorkQueue.GetUAV()); - Context.SetDynamicDescriptor(1, 2, WorkCounters.GetUAV()); - - Context.Dispatch(1, 1, 1); - - Context.InsertUAVBarrier(WorkCounters); - Context.TransitionResource(IndirectParameters, D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT); - Context.TransitionResource(g_FXAAWorkQueue, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_FXAAColorQueue, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(Target, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_LumaBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - - Context.SetDynamicDescriptor(1, 0, Target.GetUAV()); - Context.SetDynamicDescriptor(2, 0, g_LumaBuffer.GetSRV()); - Context.SetDynamicDescriptor(2, 1, g_FXAAWorkQueue.GetSRV()); - Context.SetDynamicDescriptor(2, 2, g_FXAAColorQueue.GetSRV()); - - // The final phase involves processing pixels on the work queues and writing them - // back into the color buffer. Because the two source pixels required for linearly - // blending are held in the work queue, this does not require also sampling from - // the target color buffer (i.e. no read/modify/write, just write.) - - Context.SetPipelineState(DebugDraw ? Pass2HDebugCS : Pass2HCS); - Context.DispatchIndirect(IndirectParameters, 0); - Context.SetPipelineState(DebugDraw ? Pass2VDebugCS : Pass2VCS); - Context.DispatchIndirect(IndirectParameters, 12); - - Context.InsertUAVBarrier(Target); - } - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/FXAA.h b/xess/samples/xess_demo/MiniEngine/Core/FXAA.h deleted file mode 100644 index 0791146..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/FXAA.h +++ /dev/null @@ -1,32 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -class ColorBuffer; -class BoolVar; -class NumVar; -class ComputeContext; - -namespace FXAA -{ - extern BoolVar Enable; - extern BoolVar DebugDraw; - extern NumVar ContrastThreshold; // Default = 0.20 - extern NumVar SubpixelRemoval; // Default = 0.75 - - void Initialize( void ); - void Shutdown( void ); - void Render( ComputeContext& Context, bool bUsePreComputedLuma ); - -} // namespace FXAA diff --git a/xess/samples/xess_demo/MiniEngine/Core/FileUtility.cpp b/xess/samples/xess_demo/MiniEngine/Core/FileUtility.cpp deleted file mode 100644 index 78334ee..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/FileUtility.cpp +++ /dev/null @@ -1,136 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "FileUtility.h" -#include -#include -#include // From NuGet package - -using namespace std; -using namespace Utility; - -namespace Utility -{ - ByteArray NullFile = make_shared > (vector() ); -} - -ByteArray DecompressZippedFile( wstring& fileName ); - -ByteArray ReadFileHelper(const wstring& fileName) -{ - struct _stat64 fileStat; - int fileExists = _wstat64(fileName.c_str(), &fileStat); - if (fileExists == -1) - return NullFile; - - ifstream file( fileName, ios::in | ios::binary ); - if (!file) - return NullFile; - - Utility::ByteArray byteArray = make_shared >( fileStat.st_size ); - file.read( (char*)byteArray->data(), byteArray->size() ); - file.close(); - - return byteArray; -} - -ByteArray ReadFileHelperEx( shared_ptr fileName) -{ - std::wstring zippedFileName = *fileName + L".gz"; - ByteArray firstTry = DecompressZippedFile(zippedFileName); - if (firstTry != NullFile) - return firstTry; - - return ReadFileHelper(*fileName); -} - -ByteArray Inflate(ByteArray CompressedSource, int& err, uint32_t ChunkSize = 0x100000 ) -{ - // Create a dynamic buffer to hold compressed blocks - vector > blocks; - - z_stream strm = {}; - strm.data_type = Z_BINARY; - strm.total_in = strm.avail_in = (uInt)CompressedSource->size(); - strm.next_in = CompressedSource->data(); - - err = inflateInit2(&strm, (15 + 32)); //15 window bits, and the +32 tells zlib to to detect if using gzip or zlib - - while (err == Z_OK || err == Z_BUF_ERROR) - { - strm.avail_out = ChunkSize; - strm.next_out = (byte*)malloc(ChunkSize); - blocks.emplace_back(strm.next_out); - err = inflate(&strm, Z_NO_FLUSH); - } - - if (err != Z_STREAM_END) - { - inflateEnd(&strm); - return NullFile; - } - - ASSERT(strm.total_out > 0, "Nothing to decompress"); - - Utility::ByteArray byteArray = make_shared >( strm.total_out ); - - // Allocate actual memory for this. - // copy the bits into that RAM. - // Free everything else up!! - void* curDest = byteArray->data(); - size_t remaining = byteArray->size(); - - for (size_t i = 0; i < blocks.size(); ++i) - { - ASSERT(remaining > 0); - - size_t CopySize = remaining < ChunkSize ? remaining : ChunkSize; - - memcpy(curDest, blocks[i].get(), CopySize); - curDest = (byte*)curDest + CopySize; - remaining -= CopySize; - } - - inflateEnd(&strm); - - return byteArray; -} - -ByteArray DecompressZippedFile( wstring& fileName ) -{ - ByteArray CompressedFile = ReadFileHelper(fileName); - if (CompressedFile == NullFile) - return NullFile; - - int error; - ByteArray DecompressedFile = Inflate(CompressedFile, error); - if (DecompressedFile->size() == 0) - { - LOG_ERRORF("Couldn't unzip file %s: Error = %d.", Utility::WideStringToUTF8(fileName).c_str(), error); - return NullFile; - } - - return DecompressedFile; -} - -ByteArray Utility::ReadFileSync( const wstring& fileName) -{ - return ReadFileHelperEx(make_shared(fileName)); -} - -task Utility::ReadFileAsync(const wstring& fileName) -{ - shared_ptr SharedPtr = make_shared(fileName); - return create_task( [=] { return ReadFileHelperEx(SharedPtr); } ); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/FileUtility.h b/xess/samples/xess_demo/MiniEngine/Core/FileUtility.h deleted file mode 100644 index 0fdd5f6..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/FileUtility.h +++ /dev/null @@ -1,37 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "pch.h" -#include -#include -#include - -namespace Utility -{ - using namespace std; - using namespace concurrency; - - typedef shared_ptr > ByteArray; - extern ByteArray NullFile; - - // Reads the entire contents of a binary file. If the file with the same name except with an additional - // ".gz" suffix exists, it will be loaded and decompressed instead. - // This operation blocks until the entire file is read. - ByteArray ReadFileSync(const wstring& fileName); - - // Same as previous except that it does not block but instead returns a task. - task ReadFileAsync(const wstring& fileName); - -} // namespace Utility diff --git a/xess/samples/xess_demo/MiniEngine/Core/Fonts/consola24.h b/xess/samples/xess_demo/MiniEngine/Core/Fonts/consola24.h deleted file mode 100644 index cd3c52b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Fonts/consola24.h +++ /dev/null @@ -1,7091 +0,0 @@ -unsigned char g_pconsola24[113408] = -{ - 0x53,0x44,0x46,0x46,0x4f,0x4e,0x54,0x00,0x01,0x00,0x03,0x00,0x00,0x02,0xd9,0x00, - 0x81,0x01,0xc2,0x01,0xbe,0x00,0x30,0x00,0x20,0x00,0x21,0x00,0x22,0x00,0x23,0x00, - 0x24,0x00,0x25,0x00,0x26,0x00,0x27,0x00,0x28,0x00,0x29,0x00,0x2a,0x00,0x2b,0x00, - 0x2c,0x00,0x2d,0x00,0x2e,0x00,0x2f,0x00,0x30,0x00,0x31,0x00,0x32,0x00,0x33,0x00, - 0x34,0x00,0x35,0x00,0x36,0x00,0x37,0x00,0x38,0x00,0x39,0x00,0x3a,0x00,0x3b,0x00, - 0x3c,0x00,0x3d,0x00,0x3e,0x00,0x3f,0x00,0x40,0x00,0x41,0x00,0x42,0x00,0x43,0x00, - 0x44,0x00,0x45,0x00,0x46,0x00,0x47,0x00,0x48,0x00,0x49,0x00,0x4a,0x00,0x4b,0x00, - 0x4c,0x00,0x4d,0x00,0x4e,0x00,0x4f,0x00,0x50,0x00,0x51,0x00,0x52,0x00,0x53,0x00, - 0x54,0x00,0x55,0x00,0x56,0x00,0x57,0x00,0x58,0x00,0x59,0x00,0x5a,0x00,0x5b,0x00, - 0x5c,0x00,0x5d,0x00,0x5e,0x00,0x5f,0x00,0x60,0x00,0x61,0x00,0x62,0x00,0x63,0x00, - 0x64,0x00,0x65,0x00,0x66,0x00,0x67,0x00,0x68,0x00,0x69,0x00,0x6a,0x00,0x6b,0x00, - 0x6c,0x00,0x6d,0x00,0x6e,0x00,0x6f,0x00,0x70,0x00,0x71,0x00,0x72,0x00,0x73,0x00, - 0x74,0x00,0x75,0x00,0x76,0x00,0x77,0x00,0x78,0x00,0x79,0x00,0x7a,0x00,0x7b,0x00, - 0x7c,0x00,0x7d,0x00,0x7e,0x00,0xa0,0x00,0xa1,0x00,0xa2,0x00,0xa3,0x00,0xa4,0x00, - 0xa5,0x00,0xa6,0x00,0xa7,0x00,0xa8,0x00,0xa9,0x00,0xaa,0x00,0xab,0x00,0xac,0x00, - 0xad,0x00,0xae,0x00,0xaf,0x00,0xb0,0x00,0xb1,0x00,0xb2,0x00,0xb3,0x00,0xb4,0x00, - 0xb5,0x00,0xb6,0x00,0xb7,0x00,0xb8,0x00,0xb9,0x00,0xba,0x00,0xbb,0x00,0xbc,0x00, - 0xbd,0x00,0xbe,0x00,0xbf,0x00,0xc0,0x00,0xc1,0x00,0xc2,0x00,0xc3,0x00,0xc4,0x00, - 0xc5,0x00,0xc6,0x00,0xc7,0x00,0xc8,0x00,0xc9,0x00,0xca,0x00,0xcb,0x00,0xcc,0x00, - 0xcd,0x00,0xce,0x00,0xcf,0x00,0xd0,0x00,0xd1,0x00,0xd2,0x00,0xd3,0x00,0xd4,0x00, - 0xd5,0x00,0xd6,0x00,0xd7,0x00,0xd8,0x00,0xd9,0x00,0xda,0x00,0xdb,0x00,0xdc,0x00, - 0xdd,0x00,0xde,0x00,0xdf,0x00,0xe0,0x00,0xe1,0x00,0xe2,0x00,0xe3,0x00,0xe4,0x00, - 0xe5,0x00,0xe6,0x00,0xe7,0x00,0xe8,0x00,0xe9,0x00,0xea,0x00,0xeb,0x00,0xec,0x00, - 0xed,0x00,0xee,0x00,0xef,0x00,0xf0,0x00,0xf1,0x00,0xf2,0x00,0xf3,0x00,0xf4,0x00, - 0xf5,0x00,0xf6,0x00,0xf7,0x00,0xf8,0x00,0xf9,0x00,0xfa,0x00,0xfb,0x00,0xfc,0x00, - 0xfd,0x00,0xfe,0x00,0x30,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0xd3,0x00,0x90,0x00, - 0x30,0x00,0x32,0x00,0x50,0x00,0xd3,0x00,0x30,0x01,0x30,0x00,0x6d,0x00,0x33,0x00, - 0xd3,0x00,0x00,0x02,0x30,0x00,0xc3,0x00,0x08,0x00,0xd3,0x00,0x30,0x03,0x30,0x00, - 0xa8,0x00,0x15,0x00,0xd3,0x00,0x40,0x04,0x30,0x00,0xcd,0x00,0x03,0x00,0xd3,0x00, - 0x70,0x05,0x30,0x00,0xc9,0x00,0x0b,0x00,0xd3,0x00,0xa0,0x06,0x30,0x00,0x26,0x00, - 0x57,0x00,0xd3,0x00,0x30,0x07,0x30,0x00,0x6a,0x00,0x38,0x00,0xd3,0x00,0x00,0x08, - 0x30,0x00,0x6a,0x00,0x30,0x00,0xd3,0x00,0xd0,0x08,0x30,0x00,0x97,0x00,0x1e,0x00, - 0xd3,0x00,0xd0,0x09,0x30,0x00,0xb4,0x00,0x10,0x00,0xd3,0x00,0xf0,0x0a,0x30,0x00, - 0x5b,0x00,0x2d,0x00,0xd3,0x00,0xb0,0x0b,0x30,0x00,0x70,0x00,0x31,0x00,0xd3,0x00, - 0x80,0x0c,0x30,0x00,0x3e,0x00,0x49,0x00,0xd3,0x00,0x20,0x0d,0x30,0x00,0xa1,0x00, - 0x15,0x00,0xd3,0x00,0x30,0x0e,0x30,0x00,0xb2,0x00,0x10,0x00,0xd3,0x00,0x50,0x0f, - 0x30,0x00,0xa2,0x00,0x19,0x00,0xd3,0x00,0x60,0x10,0x30,0x00,0xa1,0x00,0x1c,0x00, - 0xd3,0x00,0x70,0x11,0x30,0x00,0x9a,0x00,0x1e,0x00,0xd3,0x00,0x70,0x12,0x30,0x00, - 0xc1,0x00,0x08,0x00,0xd3,0x00,0xa0,0x13,0x30,0x00,0x96,0x00,0x21,0x00,0xd3,0x00, - 0xa0,0x14,0x30,0x00,0xa9,0x00,0x17,0x00,0xd3,0x00,0xb0,0x15,0x30,0x00,0xa6,0x00, - 0x16,0x00,0xd3,0x00,0xc0,0x16,0x30,0x00,0xa6,0x00,0x16,0x00,0xd3,0x00,0xd0,0x17, - 0x30,0x00,0xa9,0x00,0x13,0x00,0xd3,0x00,0xe0,0x18,0x30,0x00,0x3a,0x00,0x4d,0x00, - 0xd3,0x00,0x80,0x19,0x30,0x00,0x5b,0x00,0x2f,0x00,0xd3,0x00,0x40,0x1a,0x30,0x00, - 0x94,0x00,0x19,0x00,0xd3,0x00,0x40,0x1b,0x30,0x00,0xa1,0x00,0x19,0x00,0xd3,0x00, - 0x50,0x1c,0x30,0x00,0x93,0x00,0x27,0x00,0xd3,0x00,0x50,0x1d,0x30,0x00,0x74,0x00, - 0x39,0x00,0xd3,0x00,0x30,0x1e,0x30,0x00,0xce,0x00,0x02,0x00,0xd3,0x00,0x30,0x00, - 0x20,0x02,0xd1,0x00,0x01,0x00,0xd3,0x00,0x70,0x01,0x20,0x02,0xa1,0x00,0x1e,0x00, - 0xd3,0x00,0x80,0x02,0x20,0x02,0xaa,0x00,0x11,0x00,0xd3,0x00,0x90,0x03,0x20,0x02, - 0xb1,0x00,0x14,0x00,0xd3,0x00,0xb0,0x04,0x20,0x02,0x8c,0x00,0x26,0x00,0xd3,0x00, - 0xa0,0x05,0x20,0x02,0x8a,0x00,0x26,0x00,0xd3,0x00,0x90,0x06,0x20,0x02,0xb1,0x00, - 0x0c,0x00,0xd3,0x00,0xb0,0x07,0x20,0x02,0xaa,0x00,0x15,0x00,0xd3,0x00,0xc0,0x08, - 0x20,0x02,0x93,0x00,0x20,0x00,0xd3,0x00,0xc0,0x09,0x20,0x02,0x83,0x00,0x22,0x00, - 0xd3,0x00,0xb0,0x0a,0x20,0x02,0xa7,0x00,0x1d,0x00,0xd3,0x00,0xc0,0x0b,0x20,0x02, - 0x8d,0x00,0x2c,0x00,0xd3,0x00,0xb0,0x0c,0x20,0x02,0xb5,0x00,0x0f,0x00,0xd3,0x00, - 0xd0,0x0d,0x20,0x02,0xa7,0x00,0x16,0x00,0xd3,0x00,0xe0,0x0e,0x20,0x02,0xbe,0x00, - 0x0b,0x00,0xd3,0x00,0x00,0x10,0x20,0x02,0xa1,0x00,0x1e,0x00,0xd3,0x00,0x10,0x11, - 0x20,0x02,0xc9,0x00,0x0b,0x00,0xd3,0x00,0x40,0x12,0x20,0x02,0xa6,0x00,0x20,0x00, - 0xd3,0x00,0x50,0x13,0x20,0x02,0xa6,0x00,0x15,0x00,0xd3,0x00,0x60,0x14,0x20,0x02, - 0xb3,0x00,0x10,0x00,0xd3,0x00,0x80,0x15,0x20,0x02,0xaa,0x00,0x14,0x00,0xd3,0x00, - 0x90,0x16,0x20,0x02,0xd3,0x00,0x00,0x00,0xd3,0x00,0xd0,0x17,0x20,0x02,0xb2,0x00, - 0x11,0x00,0xd3,0x00,0xf0,0x18,0x20,0x02,0xcc,0x00,0x03,0x00,0xd3,0x00,0x20,0x1a, - 0x20,0x02,0xd4,0x00,0x00,0x00,0xd3,0x00,0x60,0x1b,0x20,0x02,0xa9,0x00,0x15,0x00, - 0xd3,0x00,0x70,0x1c,0x20,0x02,0x5d,0x00,0x41,0x00,0xd3,0x00,0x30,0x1d,0x20,0x02, - 0xa0,0x00,0x1e,0x00,0xd3,0x00,0x30,0x1e,0x20,0x02,0x5d,0x00,0x36,0x00,0xd3,0x00, - 0xf0,0x1e,0x20,0x02,0xa9,0x00,0x16,0x00,0xd3,0x00,0x30,0x00,0x10,0x04,0xd3,0x00, - 0x00,0x00,0xd3,0x00,0x70,0x01,0x10,0x04,0x7e,0x00,0x00,0x00,0xd3,0x00,0x50,0x02, - 0x10,0x04,0x9b,0x00,0x19,0x00,0xd3,0x00,0x50,0x03,0x10,0x04,0xa1,0x00,0x1e,0x00, - 0xd3,0x00,0x60,0x04,0x10,0x04,0x93,0x00,0x1e,0x00,0xd3,0x00,0x60,0x05,0x10,0x04, - 0xa0,0x00,0x14,0x00,0xd3,0x00,0x60,0x06,0x10,0x04,0xa7,0x00,0x16,0x00,0xd3,0x00, - 0x70,0x07,0x10,0x04,0xc5,0x00,0x00,0x00,0xd3,0x00,0xa0,0x08,0x10,0x04,0xb2,0x00, - 0x12,0x00,0xd3,0x00,0xc0,0x09,0x10,0x04,0x97,0x00,0x1e,0x00,0xd3,0x00,0xc0,0x0a, - 0x10,0x04,0x97,0x00,0x20,0x00,0xd3,0x00,0xc0,0x0b,0x10,0x04,0x8b,0x00,0x18,0x00, - 0xd3,0x00,0xb0,0x0c,0x10,0x04,0xa6,0x00,0x22,0x00,0xd3,0x00,0xc0,0x0d,0x10,0x04, - 0x97,0x00,0x20,0x00,0xd3,0x00,0xc0,0x0e,0x10,0x04,0xb1,0x00,0x11,0x00,0xd3,0x00, - 0xe0,0x0f,0x10,0x04,0x97,0x00,0x1e,0x00,0xd3,0x00,0xe0,0x10,0x10,0x04,0xb0,0x00, - 0x11,0x00,0xd3,0x00,0xf0,0x11,0x10,0x04,0xa1,0x00,0x1e,0x00,0xd3,0x00,0x00,0x13, - 0x10,0x04,0xa0,0x00,0x14,0x00,0xd3,0x00,0x00,0x14,0x10,0x04,0x9b,0x00,0x26,0x00, - 0xd3,0x00,0x00,0x15,0x10,0x04,0x92,0x00,0x22,0x00,0xd3,0x00,0x00,0x16,0x10,0x04, - 0xaa,0x00,0x0c,0x00,0xd3,0x00,0x10,0x17,0x10,0x04,0x97,0x00,0x1e,0x00,0xd3,0x00, - 0x10,0x18,0x10,0x04,0xba,0x00,0x0c,0x00,0xd3,0x00,0x30,0x19,0x10,0x04,0xc7,0x00, - 0x06,0x00,0xd3,0x00,0x60,0x1a,0x10,0x04,0xbb,0x00,0x0d,0x00,0xd3,0x00,0x80,0x1b, - 0x10,0x04,0xbb,0x00,0x0b,0x00,0xd3,0x00,0xa0,0x1c,0x10,0x04,0x98,0x00,0x1f,0x00, - 0xd3,0x00,0xa0,0x1d,0x10,0x04,0x8b,0x00,0x1e,0x00,0xd3,0x00,0x90,0x1e,0x10,0x04, - 0x1f,0x00,0x5a,0x00,0xd3,0x00,0x10,0x1f,0x10,0x04,0x8a,0x00,0x2b,0x00,0xd3,0x00, - 0x30,0x00,0x00,0x06,0xbb,0x00,0x0c,0x00,0xd3,0x00,0x50,0x01,0x00,0x06,0x00,0x00, - 0x00,0x00,0xd3,0x00,0xb0,0x01,0x00,0x06,0x32,0x00,0x51,0x00,0xd3,0x00,0x50,0x02, - 0x00,0x06,0x93,0x00,0x17,0x00,0xd3,0x00,0x50,0x03,0x00,0x06,0xac,0x00,0x11,0x00, - 0xd3,0x00,0x60,0x04,0x00,0x06,0xb3,0x00,0x10,0x00,0xd3,0x00,0x80,0x05,0x00,0x06, - 0xc0,0x00,0x0a,0x00,0xd3,0x00,0xa0,0x06,0x00,0x06,0x1f,0x00,0x5a,0x00,0xd3,0x00, - 0x20,0x07,0x00,0x06,0x9f,0x00,0x1a,0x00,0xd3,0x00,0x20,0x08,0x00,0x06,0xa8,0x00, - 0xff,0xff,0xd3,0x00,0x30,0x09,0x00,0x06,0xcf,0x00,0x02,0x00,0xd3,0x00,0x60,0x0a, - 0x00,0x06,0x7f,0x00,0x2a,0x00,0xd3,0x00,0x40,0x0b,0x00,0x06,0x9d,0x00,0x1a,0x00, - 0xd3,0x00,0x40,0x0c,0x00,0x06,0xa0,0x00,0x16,0x00,0xd3,0x00,0x40,0x0d,0x00,0x06, - 0x70,0x00,0x31,0x00,0xd3,0x00,0x10,0x0e,0x00,0x06,0xac,0x00,0x14,0x00,0xd3,0x00, - 0x20,0x0f,0x00,0x06,0x9b,0x00,0xff,0xff,0xd3,0x00,0x20,0x10,0x00,0x06,0x83,0x00, - 0x28,0x00,0xd3,0x00,0x10,0x11,0x00,0x06,0xac,0x00,0x13,0x00,0xd3,0x00,0x20,0x12, - 0x00,0x06,0x77,0x00,0x2e,0x00,0xd3,0x00,0x00,0x13,0x00,0x06,0x6f,0x00,0x33,0x00, - 0xd3,0x00,0xd0,0x13,0x00,0x06,0xb3,0x00,0x00,0x00,0xd3,0x00,0xf0,0x14,0x00,0x06, - 0xac,0x00,0x1e,0x00,0xd3,0x00,0x00,0x16,0x00,0x06,0xa7,0x00,0x14,0x00,0xd3,0x00, - 0x10,0x17,0x00,0x06,0x3e,0x00,0x4a,0x00,0xd3,0x00,0xb0,0x17,0x00,0x06,0x2e,0x00, - 0x51,0x00,0xd3,0x00,0x40,0x18,0x00,0x06,0x7b,0x00,0x2a,0x00,0xd3,0x00,0x20,0x19, - 0x00,0x06,0x80,0x00,0x29,0x00,0xd3,0x00,0x00,0x1a,0x00,0x06,0x9c,0x00,0x1d,0x00, - 0xd3,0x00,0x00,0x1b,0x00,0x06,0xcd,0x00,0x03,0x00,0xd3,0x00,0x30,0x1c,0x00,0x06, - 0xcd,0x00,0x03,0x00,0xd3,0x00,0x60,0x1d,0x00,0x06,0xcd,0x00,0x03,0x00,0xd3,0x00, - 0x90,0x1e,0x00,0x06,0x74,0x00,0x26,0x00,0xd3,0x00,0x30,0x00,0xf0,0x07,0xd2,0x00, - 0x00,0x00,0xd3,0x00,0x70,0x01,0xf0,0x07,0xd2,0x00,0x00,0x00,0xd3,0x00,0xb0,0x02, - 0xf0,0x07,0xd2,0x00,0x00,0x00,0xd3,0x00,0xf0,0x03,0xf0,0x07,0xd2,0x00,0x00,0x00, - 0xd3,0x00,0x30,0x05,0xf0,0x07,0xd2,0x00,0x00,0x00,0xd3,0x00,0x70,0x06,0xf0,0x07, - 0xd1,0x00,0x00,0x00,0xd3,0x00,0xb0,0x07,0xf0,0x07,0xd4,0x00,0xf7,0xff,0xd3,0x00, - 0xf0,0x08,0xf0,0x07,0xaa,0x00,0x11,0x00,0xd3,0x00,0x00,0x0a,0xf0,0x07,0xb2,0x00, - 0x00,0x00,0xd3,0x00,0x20,0x0b,0xf0,0x07,0xb2,0x00,0x00,0x00,0xd3,0x00,0x40,0x0c, - 0xf0,0x07,0xb2,0x00,0x00,0x00,0xd3,0x00,0x60,0x0d,0xf0,0x07,0xb2,0x00,0x00,0x00, - 0xd3,0x00,0x80,0x0e,0xf0,0x07,0xb4,0x00,0xff,0xff,0xd3,0x00,0xa0,0x0f,0xf0,0x07, - 0xb4,0x00,0xff,0xff,0xd3,0x00,0xc0,0x10,0xf0,0x07,0xb4,0x00,0xff,0xff,0xd3,0x00, - 0xe0,0x11,0xf0,0x07,0xb4,0x00,0xff,0xff,0xd3,0x00,0x00,0x13,0xf0,0x07,0xc5,0x00, - 0x00,0x00,0xd3,0x00,0x30,0x14,0xf0,0x07,0xbe,0x00,0xff,0xff,0xd3,0x00,0x50,0x15, - 0xf0,0x07,0xc9,0x00,0x00,0x00,0xd3,0x00,0x80,0x16,0xf0,0x07,0xc9,0x00,0x00,0x00, - 0xd3,0x00,0xb0,0x17,0xf0,0x07,0xc9,0x00,0x00,0x00,0xd3,0x00,0xe0,0x18,0xf0,0x07, - 0xc9,0x00,0x00,0x00,0xd3,0x00,0x10,0x1a,0xf0,0x07,0xc9,0x00,0x00,0x00,0xd3,0x00, - 0x40,0x1b,0xf0,0x07,0x9d,0x00,0x1b,0x00,0xd3,0x00,0x40,0x1c,0xf0,0x07,0xbe,0x00, - 0x0b,0x00,0xd3,0x00,0x60,0x1d,0xf0,0x07,0xbf,0x00,0xff,0xff,0xd3,0x00,0x80,0x1e, - 0xf0,0x07,0xbf,0x00,0xff,0xff,0xd3,0x00,0x30,0x00,0xe0,0x09,0xbf,0x00,0xff,0xff, - 0xd3,0x00,0x50,0x01,0xe0,0x09,0xbf,0x00,0xff,0xff,0xd3,0x00,0x70,0x02,0xe0,0x09, - 0xd4,0x00,0x00,0x00,0xd3,0x00,0xb0,0x03,0xe0,0x09,0xa1,0x00,0x1e,0x00,0xd3,0x00, - 0xc0,0x04,0xe0,0x09,0xa4,0x00,0x1c,0x00,0xd3,0x00,0xd0,0x05,0xe0,0x09,0xb4,0x00, - 0x00,0x00,0xd3,0x00,0xf0,0x06,0xe0,0x09,0xb4,0x00,0x00,0x00,0xd3,0x00,0x10,0x08, - 0xe0,0x09,0xb4,0x00,0x00,0x00,0xd3,0x00,0x30,0x09,0xe0,0x09,0xb4,0x00,0x00,0x00, - 0xd3,0x00,0x50,0x0a,0xe0,0x09,0xb4,0x00,0x00,0x00,0xd3,0x00,0x70,0x0b,0xe0,0x09, - 0xb4,0x00,0x00,0x00,0xd3,0x00,0x90,0x0c,0xe0,0x09,0xc6,0x00,0x06,0x00,0xd3,0x00, - 0xc0,0x0d,0xe0,0x09,0x93,0x00,0x1e,0x00,0xd3,0x00,0xc0,0x0e,0xe0,0x09,0xbd,0x00, - 0x00,0x00,0xd3,0x00,0xe0,0x0f,0xe0,0x09,0xbd,0x00,0x00,0x00,0xd3,0x00,0x00,0x11, - 0xe0,0x09,0xbd,0x00,0x00,0x00,0xd3,0x00,0x20,0x12,0xe0,0x09,0xbd,0x00,0x00,0x00, - 0xd3,0x00,0x40,0x13,0xe0,0x09,0xb8,0x00,0xff,0xff,0xd3,0x00,0x60,0x14,0xe0,0x09, - 0xb8,0x00,0xff,0xff,0xd3,0x00,0x80,0x15,0xe0,0x09,0xb8,0x00,0xff,0xff,0xd3,0x00, - 0xa0,0x16,0xe0,0x09,0xb8,0x00,0xff,0xff,0xd3,0x00,0xc0,0x17,0xe0,0x09,0xaa,0x00, - 0x13,0x00,0xd3,0x00,0xd0,0x18,0xe0,0x09,0xb5,0x00,0x00,0x00,0xd3,0x00,0xf0,0x19, - 0xe0,0x09,0xc2,0x00,0xff,0xff,0xd3,0x00,0x20,0x1b,0xe0,0x09,0xc2,0x00,0xff,0xff, - 0xd3,0x00,0x50,0x1c,0xe0,0x09,0xc2,0x00,0xff,0xff,0xd3,0x00,0x80,0x1d,0xe0,0x09, - 0xc2,0x00,0xff,0xff,0xd3,0x00,0xb0,0x1e,0xe0,0x09,0xc2,0x00,0xff,0xff,0xd3,0x00, - 0x30,0x00,0xd0,0x0b,0xb4,0x00,0x10,0x00,0xd3,0x00,0x50,0x01,0xd0,0x0b,0xb1,0x00, - 0x11,0x00,0xd3,0x00,0x70,0x02,0xd0,0x0b,0xb5,0x00,0x00,0x00,0xd3,0x00,0x90,0x03, - 0xd0,0x0b,0xb5,0x00,0x00,0x00,0xd3,0x00,0xb0,0x04,0xd0,0x0b,0xb5,0x00,0x00,0x00, - 0xd3,0x00,0xd0,0x05,0xd0,0x0b,0xb5,0x00,0x00,0x00,0xd3,0x00,0xf0,0x06,0xd0,0x0b, - 0xc7,0x00,0xff,0xff,0xd3,0x00,0x20,0x08,0xd0,0x0b,0xa1,0x00,0x1e,0x00,0xd3,0x00, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x88,0x88,0x88,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x83,0x8b,0x8b,0x8b,0x85,0x81,0x81,0x81, - 0x81,0x81,0x86,0x88,0x88,0x88,0x81,0x88,0x88,0x88,0x84,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x87,0xa3,0xb2,0xb2,0xb2,0xa4,0x88,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x84,0x8e,0x90,0x8d,0x84,0x81,0x81,0x81,0x81,0x87,0x88, - 0x88,0x84,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x86,0x88,0x88,0x88,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0xa6,0xad,0xa2,0x89,0x81,0x81,0x81,0x81,0x92, - 0xa8,0xad,0x9e,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x86,0x88,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x88,0x8b,0x8b,0x89,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x89,0x8b,0x8a,0x84,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x87,0x8f,0x90,0x8e,0x87,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0xa9,0xb5,0xb5,0xb5,0xac,0x92,0x81,0x81, - 0x81,0x9b,0xaf,0xb2,0xb2,0xb2,0xa6,0xb2,0xb2,0xb2,0xad,0x96,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x9d,0xc2,0xdc,0xdd,0xdc,0xc4,0x9e,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x99,0xac,0xb7,0xba,0xb7,0xac,0x99,0x81,0x83,0xa0,0xb1,0xb2, - 0xb2,0xac,0x94,0x81,0x81,0x81,0x81,0x81,0x81,0x8c,0x99,0xa1,0xa3,0xa0,0x98,0x89, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9b,0xaf,0xb2,0xb2,0xb2,0xa4,0x88,0x81, - 0x81,0x81,0x81,0x81,0x81,0x8e,0xac,0xca,0xd7,0xc5,0xa7,0x89,0x81,0x81,0x92,0xb0, - 0xcd,0xd6,0xc1,0xa3,0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9b, - 0xaf,0xb2,0xb2,0xa8,0x8e,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9b,0xb1,0xb5,0xb5,0xb2,0x9d,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x86,0x88,0x88,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x82,0x83,0x83,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x86,0x88,0x88,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0x88,0x88,0x85,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x83, - 0x88,0x88,0x86,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x82,0x88,0x88,0x86,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x9d,0xb2,0xb5,0xb4,0xae,0xa4,0x97,0x86,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x8d,0xa0,0xaf,0xb8,0xba,0xb8,0xb0,0xa1,0x8d,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa4,0xca,0xdf,0xdf,0xdf,0xce,0xa9,0x81,0x81, - 0x90,0xb6,0xd6,0xdd,0xdd,0xdb,0xc6,0xdd,0xdd,0xdd,0xd2,0xaf,0x88,0x81,0x81,0x81, - 0x81,0x83,0x9e,0xaa,0xab,0xaa,0x9e,0xa2,0xab,0xab,0xa8,0x96,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x88,0x97,0xa6,0xd0,0xfa,0x09,0xfa,0xd0,0xa5,0x8e,0x81,0x81, - 0x81,0x81,0x81,0x9d,0xbb,0xd2,0xe1,0xe5,0xe1,0xd2,0xbb,0x9d,0x9b,0xbe,0xda,0xdd, - 0xdd,0xd0,0xad,0x85,0x81,0x81,0x81,0x83,0x9e,0xb3,0xc3,0xcb,0xcd,0xca,0xc0,0xaf, - 0x98,0x81,0x81,0x81,0x81,0x81,0x81,0x90,0xb6,0xd6,0xdd,0xdd,0xdc,0xc4,0x9e,0x81, - 0x81,0x81,0x81,0x81,0x8b,0xaa,0xca,0xe8,0xff,0xe3,0xc5,0xa3,0x81,0x89,0xaf,0xce, - 0xec,0xfb,0xdf,0xbf,0xa1,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x82,0x8f,0x90,0xb6, - 0xd6,0xdd,0xdd,0xca,0xa6,0x93,0x8c,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8f,0xb5,0xd7,0xdf,0xdf,0xd9,0xb8,0x90,0x81, - 0x81,0x81,0x81,0x81,0x85,0x99,0xa7,0xb0,0xb2,0xb2,0xaa,0x9d,0x8c,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x87,0x9b,0xab,0xad,0xad,0xa6,0x8e,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x88,0x9b,0xa8,0xb0,0xb2,0xb2,0xab,0x9d,0x8c,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x93,0x9f,0xa9,0xb0,0xb2,0xb2,0xaf,0xa6,0x9a,0x87, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x87,0xa0,0xab,0xab,0xab, - 0xaa,0x9f,0x85,0x81,0x81,0x81,0x81,0x81,0x8a,0xa1,0xa8,0xa8,0xa8,0xa8,0xa8,0xa8, - 0xa8,0xa8,0xa8,0x9f,0x87,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0x9a,0xa4, - 0xa8,0xab,0xab,0xaa,0x9e,0x83,0x81,0x81,0x81,0x93,0xa5,0xa8,0xa8,0xa8,0xa8,0xa8, - 0xa8,0xa8,0xa8,0xa8,0xa8,0xa8,0x9b,0x81,0x81,0x81,0x81,0x81,0x81,0x92,0xa2,0xad, - 0xb2,0xb2,0xb0,0xaa,0x9e,0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0x9f, - 0xab,0xb2,0xb2,0xb0,0xa7,0x99,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x90,0xb8,0xd9,0xdf,0xdd,0xd7,0xcd,0xbe,0xab,0x95,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x98,0xb1,0xc7,0xd7,0xe2,0xe5,0xe2,0xd8,0xc7,0xb0,0x94, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x0b,0x06,0xda,0xb0,0x85,0x81, - 0x95,0xc0,0xea,0x09,0x09,0xf5,0xd2,0xfc,0x09,0x09,0xe2,0xb8,0x8d,0x81,0x81,0x81, - 0x81,0x9b,0xbf,0xd4,0xd5,0xd4,0xbf,0xc6,0xd5,0xd5,0xd1,0xb5,0x8f,0x81,0x81,0x81, - 0x81,0x81,0x81,0x99,0xae,0xbf,0xcc,0xd5,0xff,0x1e,0xf4,0xca,0xc3,0xb3,0x94,0x81, - 0x81,0x81,0x94,0xb9,0xd9,0xf6,0x0a,0x11,0x0a,0xf5,0xd9,0xb7,0xb2,0xd5,0xf9,0x09, - 0x07,0xdf,0xb5,0x8b,0x81,0x81,0x81,0xa1,0xbf,0xd8,0xeb,0xf5,0xf7,0xf4,0xe7,0xd3, - 0xb8,0x99,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x09,0x09,0xfa,0xd0,0xa5,0x81, - 0x81,0x81,0x81,0x84,0xa6,0xc7,0xe6,0x06,0x1f,0xff,0xda,0xb0,0x85,0x93,0xbd,0xe7, - 0x0b,0x1c,0xfb,0xdc,0xbb,0x9b,0x81,0x81,0x81,0x81,0x81,0x88,0xa6,0xb9,0xb6,0xc0, - 0xea,0x09,0x04,0xd7,0xaf,0xbd,0xb3,0x97,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa0,0xc7,0xee,0x0b,0x0b,0xe9,0xbf,0x95,0x81, - 0x81,0x81,0x81,0x8e,0xa9,0xbf,0xcf,0xda,0xdd,0xdc,0xd3,0xc5,0xb0,0x96,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x85,0x99,0xac,0xc0,0xd4,0xd7,0xd7,0xca,0xa8,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x96,0xae,0xc1,0xd1,0xda,0xdd,0xdc,0xd3,0xc5,0xaf,0x96, - 0x81,0x81,0x81,0x81,0x81,0x9a,0xb8,0xc8,0xd2,0xda,0xdd,0xdd,0xd8,0xcf,0xc0,0xab, - 0x92,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa0,0xc3,0xd5,0xd5,0xd5, - 0xd5,0xc1,0x9e,0x81,0x81,0x81,0x81,0x81,0xa6,0xc6,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2, - 0xd2,0xd2,0xd2,0xc3,0xa1,0x81,0x81,0x81,0x81,0x81,0x81,0x8d,0xa2,0xb5,0xc3,0xcd, - 0xd2,0xd5,0xd5,0xd4,0xbf,0x9b,0x81,0x81,0x8c,0xb1,0xcd,0xd2,0xd2,0xd2,0xd2,0xd2, - 0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xbd,0x9a,0x81,0x81,0x81,0x85,0xa1,0xb8,0xca,0xd6, - 0xdd,0xdd,0xda,0xd3,0xc6,0xb2,0x9a,0x81,0x81,0x81,0x81,0x81,0x81,0x9c,0xb3,0xc6, - 0xd4,0xdc,0xdd,0xda,0xcf,0xbf,0xa8,0x8c,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x95,0xc0,0xea,0x0b,0x09,0xff,0xf5,0xe5,0xd0,0xb6,0x9a,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x9a,0xb8,0xd4,0xec,0xff,0x0b,0x11,0x0b,0xff,0xeb,0xd0,0xb2, - 0x91,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0,0x85,0x81, - 0x95,0xc0,0xea,0x16,0x21,0xf5,0xd2,0xfc,0x29,0x0e,0xe2,0xb8,0x8d,0x81,0x81,0x81, - 0x81,0xa5,0xd0,0xfa,0xff,0xfa,0xd0,0xdd,0xff,0xff,0xed,0xc2,0x98,0x81,0x81,0x81, - 0x81,0x81,0x9f,0xbb,0xd4,0xe7,0xf5,0xfa,0x06,0x19,0xfa,0xf5,0xec,0xce,0xa6,0x81, - 0x81,0x81,0xa6,0xcd,0xf3,0x16,0x11,0x06,0x14,0x14,0xf1,0xc9,0xc9,0xec,0x10,0x12, - 0xef,0xcc,0xa8,0x82,0x81,0x81,0x95,0xba,0xdd,0xfb,0x12,0x1f,0x23,0x1e,0x0d,0xf3, - 0xd4,0xaf,0x8a,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x26,0xfa,0xd0,0xa5,0x81, - 0x81,0x81,0x81,0x9c,0xbf,0xe1,0x04,0x23,0x09,0xe8,0xca,0xa7,0x81,0x8d,0xb4,0xd6, - 0xf5,0x15,0x18,0xf7,0xd5,0xb4,0x91,0x81,0x81,0x81,0x81,0x9e,0xc2,0xe1,0xdb,0xc3, - 0xea,0x16,0xff,0xd5,0xd2,0xe7,0xd3,0xae,0x8a,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x89,0xb0,0xd7,0xfc,0x25,0xff,0xd9,0xb2,0x8b,0x81, - 0x81,0x81,0x8d,0xac,0xca,0xe3,0xf6,0x04,0x09,0x06,0xfb,0xeb,0xd2,0xb6,0x96,0x81, - 0x81,0x81,0x81,0x82,0x97,0xab,0xbe,0xd2,0xe6,0xf9,0x04,0x04,0xdd,0xb2,0x88,0x81, - 0x81,0x81,0x81,0x81,0x9a,0xb7,0xd1,0xe7,0xf9,0x04,0x09,0x06,0xfb,0xea,0xd2,0xb4, - 0x93,0x81,0x81,0x81,0x82,0xab,0xd4,0xf1,0xfb,0x04,0x09,0x09,0x04,0xf7,0xe6,0xcd, - 0xaf,0x8e,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x94,0xb7,0xdb,0xff,0xff,0xff, - 0xfc,0xd2,0xa8,0x81,0x81,0x81,0x81,0x88,0xb2,0xdd,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc, - 0xfc,0xfc,0xfc,0xd7,0xad,0x83,0x81,0x81,0x81,0x81,0x94,0xb0,0xc8,0xdb,0xec,0xf6, - 0xfc,0xff,0xff,0xfa,0xd0,0xa5,0x81,0x81,0x95,0xc0,0xea,0xfc,0xfc,0xfc,0xfc,0xfc, - 0xfc,0xfc,0xfc,0xfc,0xfc,0xf9,0xcf,0xa5,0x81,0x81,0x81,0xa3,0xc1,0xdc,0xf1,0xff, - 0x06,0x09,0x06,0xfb,0xec,0xd5,0xb8,0x97,0x81,0x81,0x81,0x81,0x9d,0xbb,0xd7,0xed, - 0xfc,0x06,0x09,0x04,0xf6,0xe3,0xc8,0xaa,0x8a,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8b,0x99,0x98,0x86,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x82,0x95,0x9a,0x8e,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x95,0xc0,0xea,0x16,0x1b,0x24,0x1d,0x0a,0xf1,0xd5,0xb6,0x94,0x81,0x81, - 0x81,0x81,0x81,0x93,0xb5,0xd5,0xf3,0x0f,0x19,0x09,0x04,0x09,0x1a,0x0d,0xee,0xcb, - 0xa7,0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0,0x85,0x81, - 0x95,0xc0,0xea,0x16,0x21,0xf5,0xd2,0xfc,0x29,0x0e,0xe2,0xb8,0x8d,0x81,0x81,0x81, - 0x83,0xaa,0xd5,0xfc,0x21,0xf5,0xcb,0xdf,0x0b,0x14,0xea,0xc0,0x96,0x81,0x81,0x81, - 0x81,0x97,0xba,0xdb,0xf6,0x0d,0x1d,0x24,0x27,0x26,0x24,0x1e,0xfc,0xd2,0xa8,0x81, - 0x81,0x88,0xb2,0xdb,0x04,0x1c,0xf5,0xdc,0xfa,0x23,0xfc,0xd5,0xe0,0x04,0x1f,0xfb, - 0xd9,0xb5,0x91,0x81,0x81,0x81,0xa5,0xcd,0xf4,0x18,0x1c,0xff,0xfa,0x07,0x25,0x0f, - 0xe8,0xc1,0x98,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x26,0xfa,0xd0,0xa5,0x81, - 0x81,0x81,0x8e,0xb3,0xd7,0xfa,0x1c,0x0f,0xed,0xcc,0xac,0x8e,0x81,0x81,0x9b,0xb9, - 0xd9,0xfa,0x1c,0x11,0xee,0xcb,0xa7,0x82,0x81,0x81,0x8e,0xb4,0xd8,0xfc,0xfc,0xe6, - 0xea,0x16,0xfc,0xdd,0xf5,0x0d,0xe8,0xc3,0x9e,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x8f,0x9a,0x9b,0x9b,0x94,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x9a,0xc1,0xe7,0x0f,0x17,0xef,0xc8,0xa1,0x81,0x81, - 0x81,0x81,0xa5,0xc8,0xe8,0x05,0x1d,0x1f,0x19,0x1d,0x23,0x0f,0xf1,0xd1,0xae,0x8a, - 0x81,0x81,0x81,0xa3,0xbc,0xcf,0xe3,0xf7,0x0b,0x1f,0x2e,0x09,0xdd,0xb2,0x88,0x81, - 0x81,0x81,0x81,0x8d,0xb4,0xd5,0xf3,0x0c,0x20,0x1e,0x1b,0x20,0x23,0x0d,0xf0,0xce, - 0xaa,0x84,0x81,0x81,0x83,0xad,0xd7,0x04,0x24,0x1c,0x19,0x19,0x22,0x1f,0x09,0xea, - 0xc8,0xa2,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x86,0xaa,0xce,0xf1,0x15,0x2b,0x29, - 0xfc,0xd2,0xa8,0x81,0x81,0x81,0x81,0x88,0xb2,0xdd,0x09,0x29,0x23,0x23,0x23,0x23, - 0x23,0x23,0x04,0xd7,0xad,0x83,0x81,0x81,0x81,0x90,0xb1,0xd0,0xeb,0xff,0x13,0x20, - 0x23,0x21,0x21,0xfa,0xd0,0xa5,0x81,0x81,0x95,0xc0,0xea,0x16,0x29,0x29,0x29,0x29, - 0x29,0x29,0x29,0x29,0x26,0xfa,0xd0,0xa5,0x81,0x81,0x97,0xbc,0xdf,0xfc,0x17,0x20, - 0x17,0x16,0x1b,0x24,0x10,0xf3,0xd2,0xad,0x86,0x81,0x81,0x94,0xb8,0xd9,0xf7,0x12, - 0x24,0x18,0x16,0x1e,0x1d,0x05,0xe6,0xc5,0xa1,0x81,0x81,0x81,0x81,0x82,0x93,0x9b, - 0x99,0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0x94,0x9b,0x98,0x8b,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x92,0xac,0xc3,0xc0,0xa7,0x89,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x83,0xa1,0xbc,0xc4,0xb2,0x97,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x94,0xbd,0xe3,0xed,0xf2,0xfb,0x0d,0x25,0x12,0xf1,0xcf,0xab,0x85,0x81, - 0x81,0x81,0x86,0xab,0xce,0xf0,0x12,0x12,0xf5,0xe1,0xd7,0xe1,0xf9,0x1a,0x06,0xe1, - 0xba,0x94,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0,0x85,0x81, - 0x95,0xc0,0xea,0x16,0x21,0xf5,0xd2,0xfc,0x29,0x0e,0xe2,0xb8,0x8d,0x81,0x85,0xa0, - 0xad,0xaf,0xd7,0x04,0x1b,0xf1,0xc7,0xe5,0x0f,0x11,0xe5,0xbb,0xac,0x9c,0x81,0x81, - 0x82,0xaa,0xd1,0xf5,0x16,0x1d,0x06,0xfa,0x11,0x0e,0xfa,0x04,0xfc,0xd2,0xa8,0x81, - 0x81,0x8b,0xb5,0xdf,0x0b,0x16,0xea,0xc8,0xf2,0x1e,0x04,0xd7,0xf7,0x1a,0x09,0xe5, - 0xc1,0x9e,0x81,0x81,0x81,0x86,0xb0,0xda,0x04,0x2b,0x04,0xdf,0xd1,0xe9,0x11,0x1e, - 0xf3,0xca,0xa0,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x26,0xfa,0xd0,0xa5,0x81, - 0x81,0x81,0xa2,0xc8,0xed,0x11,0x1a,0xf5,0xd3,0xb2,0x91,0x81,0x81,0x81,0x81,0x9e, - 0xbf,0xe1,0x05,0x28,0x05,0xe0,0xbb,0x95,0x81,0x81,0x95,0xc0,0xea,0x09,0x1b,0x09, - 0xf0,0x16,0xfa,0xff,0x18,0x12,0xfc,0xd2,0xa8,0x81,0x81,0x81,0x81,0x81,0x81,0x94, - 0xb3,0xc5,0xc5,0xc5,0xba,0x9c,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x83,0xaa,0xd1,0xf7,0x1f,0x06,0xdf,0xb8,0x91,0x81,0x81, - 0x81,0x94,0xba,0xdf,0x04,0x25,0x0f,0xf6,0xed,0xf5,0x0b,0x29,0x0c,0xe8,0xc2,0x9c, - 0x81,0x81,0x90,0xb9,0xdf,0xf5,0x0a,0x1d,0x1e,0x0f,0x30,0x09,0xdd,0xb2,0x88,0x81, - 0x81,0x81,0x81,0x92,0xbd,0xe7,0x0b,0x1d,0x05,0xf5,0xef,0xf7,0x10,0x2b,0x09,0xe2, - 0xbb,0x93,0x81,0x81,0x83,0xad,0xd7,0x04,0xfa,0xf2,0xed,0xef,0xfa,0x12,0x26,0xff, - 0xda,0xb2,0x89,0x81,0x81,0x81,0x81,0x81,0x81,0x9d,0xc1,0xe5,0x09,0x20,0x07,0x29, - 0xfc,0xd2,0xa8,0x81,0x81,0x81,0x81,0x88,0xb2,0xdd,0x09,0x21,0xf7,0xf7,0xf7,0xf7, - 0xf7,0xf7,0xf7,0xd6,0xad,0x82,0x81,0x81,0x82,0xa8,0xcb,0xec,0x0b,0x25,0x11,0xff, - 0xf7,0xf5,0xf5,0xf3,0xce,0xa4,0x81,0x81,0x95,0xc0,0xea,0xfc,0xfc,0xfc,0xfc,0xfc, - 0xfc,0xfc,0xfc,0x0b,0x20,0xfa,0xd0,0xa5,0x81,0x81,0xa6,0xce,0xf5,0x1a,0x14,0xf9, - 0xed,0xea,0xf2,0x07,0x27,0x0b,0xe4,0xbb,0x92,0x81,0x81,0xa8,0xce,0xf3,0x15,0x1a, - 0xfc,0xee,0xeb,0xf6,0x0f,0x22,0xff,0xda,0xb4,0x8d,0x81,0x81,0x89,0xa6,0xbb,0xc5, - 0xc3,0xb3,0x9b,0x81,0x81,0x81,0x81,0x81,0x8c,0xa9,0xbd,0xc5,0xc1,0xb1,0x98,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x97,0xb2,0xcd,0xe8,0xe3,0xc5,0xa7,0x87, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x9f,0xbf,0xdd,0xed,0xd2,0xb7,0x9c,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x85,0xa7,0xbe,0xc2,0xc8,0xd4,0xea,0x07,0x2b,0x09,0xe3,0xbc,0x94,0x81, - 0x81,0x81,0x99,0xbf,0xe5,0x09,0x18,0xf5,0xd5,0xbb,0xad,0xbd,0xdf,0x05,0x19,0xf1, - 0xc9,0xa1,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0,0x85,0x81, - 0x95,0xc0,0xea,0x16,0x21,0xf5,0xd2,0xfc,0x29,0x0e,0xe2,0xb8,0x8d,0x81,0x9c,0xc1, - 0xd7,0xd7,0xdd,0x07,0x19,0xed,0xd7,0xe9,0x13,0x0b,0xe1,0xd7,0xd5,0xba,0x95,0x81, - 0x8d,0xb6,0xdf,0x09,0x29,0xff,0xe1,0xed,0x16,0x09,0xdd,0xd9,0xdf,0xc8,0xa2,0x81, - 0x81,0x8a,0xb5,0xde,0x09,0x19,0xef,0xd1,0xf7,0x21,0xff,0xeb,0x0f,0x14,0xf1,0xcd, - 0xaa,0x86,0x81,0x81,0x81,0x88,0xb2,0xdd,0x09,0x29,0xfc,0xd2,0xba,0xe4,0x0e,0x1f, - 0xf5,0xca,0xa0,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x26,0xfa,0xd0,0xa5,0x81, - 0x81,0x8e,0xb4,0xdb,0xff,0x27,0x05,0xe0,0xbc,0x99,0x81,0x81,0x81,0x81,0x81,0x84, - 0xa7,0xca,0xee,0x13,0x1a,0xf4,0xce,0xa7,0x81,0x81,0x8d,0xb2,0xcf,0xe2,0xf5,0x09, - 0x12,0x18,0x0c,0x12,0xff,0xec,0xd9,0xc3,0x9f,0x81,0x81,0x81,0x81,0x81,0x81,0xa4, - 0xcd,0xee,0xef,0xef,0xd6,0xae,0x84,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x94,0xba,0xe1,0x09,0x1d,0xf5,0xce,0xa8,0x81,0x81,0x81, - 0x81,0xa3,0xcb,0xf2,0x19,0x15,0xf1,0xd2,0xc3,0xcf,0xed,0x11,0x21,0xfa,0xd2,0xaa, - 0x82,0x81,0x92,0xbb,0xe4,0x0b,0x21,0x0d,0xf9,0x04,0x2e,0x09,0xdd,0xb2,0x88,0x81, - 0x81,0x81,0x81,0x88,0xad,0xce,0xee,0xfc,0xe1,0xcd,0xc5,0xd4,0xf5,0x1d,0x19,0xef, - 0xc6,0x9d,0x81,0x81,0x81,0xa6,0xca,0xdd,0xd2,0xc8,0xc3,0xc5,0xd6,0xfb,0x24,0x0e, - 0xe4,0xba,0x90,0x81,0x81,0x81,0x81,0x81,0x91,0xb4,0xd8,0xfb,0x1f,0x09,0x06,0x29, - 0xfc,0xd2,0xa8,0x81,0x81,0x81,0x81,0x88,0xb2,0xdd,0x09,0x21,0xf5,0xcd,0xcd,0xcd, - 0xcd,0xcd,0xcd,0xbf,0x9e,0x81,0x81,0x81,0x95,0xbb,0xe1,0x06,0x25,0x05,0xec,0xd9, - 0xcf,0xca,0xca,0xca,0xb7,0x96,0x81,0x81,0x8c,0xb1,0xcd,0xd2,0xd2,0xd2,0xd2,0xd2, - 0xd2,0xd2,0xf6,0x1d,0x0f,0xe8,0xc1,0x9b,0x81,0x85,0xaf,0xd9,0x04,0x29,0xff,0xd8, - 0xc3,0xc1,0xcb,0xee,0x18,0x16,0xed,0xc2,0x98,0x81,0x8d,0xb6,0xde,0x06,0x28,0xff, - 0xde,0xc5,0xc2,0xd3,0xf5,0x1b,0x12,0xeb,0xc3,0x9a,0x81,0x81,0xa5,0xc5,0xe0,0xef, - 0xec,0xd7,0xb9,0x97,0x81,0x81,0x81,0x85,0xa9,0xc8,0xe3,0xef,0xe9,0xd4,0xb5,0x93, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9c,0xb7,0xd2,0xee,0x09,0xff,0xe3,0xc1,0x99, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x8f,0xb8,0xdb,0xfb,0x0f,0xf3,0xd7,0xbd,0xa1,0x86,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x86,0x96,0x98,0x9f,0xaf,0xcc,0xf1,0x19,0x19,0xef,0xc7,0x9d,0x81, - 0x81,0x84,0xab,0xd2,0xf7,0x1e,0xff,0xde,0xba,0xbf,0xc0,0xb8,0xcd,0xf5,0x1e,0xfc, - 0xd4,0xab,0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0,0x85,0x81, - 0x95,0xc0,0xea,0x0e,0x0e,0xf5,0xd2,0xfc,0x0e,0x0e,0xe2,0xb8,0x8d,0x81,0xa5,0xd0, - 0xfa,0x04,0x04,0x0c,0x14,0x04,0x04,0x04,0x19,0x0a,0x04,0x04,0xf2,0xc8,0x9d,0x81, - 0x90,0xba,0xe5,0x11,0x23,0xf7,0xce,0xf2,0x1c,0x04,0xd7,0xb0,0xb5,0xa8,0x8c,0x81, - 0x81,0x84,0xad,0xd5,0xfc,0x22,0x05,0xf7,0x0d,0x18,0xf1,0xff,0x21,0xfc,0xda,0xb6, - 0x93,0x81,0x81,0x81,0x81,0x86,0xb0,0xda,0x04,0x2c,0x06,0xe0,0xd6,0xf5,0x19,0x13, - 0xec,0xc4,0x9b,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x0e,0x0e,0xfa,0xd0,0xa5,0x81, - 0x81,0x9c,0xc4,0xec,0x13,0x19,0xf1,0xcc,0xa6,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x90,0xb5,0xda,0xff,0x28,0x06,0xde,0xb6,0x8f,0x81,0x81,0xa3,0xbb,0xce,0xe1,0xf3, - 0x06,0x27,0x12,0xfb,0xe8,0xd6,0xc4,0xaf,0x91,0x81,0x81,0x81,0x81,0x81,0x81,0xa5, - 0xd0,0xfa,0x1b,0x06,0xda,0xb0,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0xa4,0xcb,0xf1,0x19,0x0c,0xe5,0xbe,0x98,0x81,0x81,0x81, - 0x86,0xaf,0xd8,0xff,0x29,0x04,0xdc,0xb7,0xa9,0xc3,0xdc,0xff,0x29,0x09,0xdf,0xb6, - 0x8d,0x81,0x86,0xad,0xd3,0xfa,0xfb,0xe7,0xd7,0x04,0x2e,0x09,0xdd,0xb2,0x88,0x81, - 0x81,0x81,0x81,0x81,0x93,0xb3,0xd3,0xda,0xc1,0xa7,0x9c,0xc0,0xea,0x13,0x21,0xf5, - 0xca,0xa0,0x81,0x81,0x81,0x8e,0xa8,0xb2,0xa9,0x9f,0x99,0xa1,0xca,0xf5,0x21,0x11, - 0xe5,0xba,0x90,0x81,0x81,0x81,0x81,0x83,0xa7,0xcb,0xee,0x12,0x15,0xf1,0x06,0x29, - 0xfc,0xd2,0xa8,0x81,0x81,0x81,0x81,0x88,0xb2,0xdd,0x09,0x21,0xf5,0xca,0xa5,0xa3, - 0xa3,0xa3,0xa3,0x9a,0x83,0x81,0x81,0x81,0xa4,0xcd,0xf4,0x1a,0x0f,0xea,0xca,0xb2, - 0xad,0xa8,0xa0,0xa0,0x94,0x81,0x81,0x81,0x81,0x93,0xa5,0xa8,0xa8,0xa8,0xa8,0xa8, - 0xbe,0xe3,0x0a,0x22,0xfb,0xd5,0xaf,0x8a,0x81,0x85,0xb0,0xda,0x06,0x29,0xff,0xd8, - 0xb8,0xa9,0xc6,0xed,0x16,0x16,0xec,0xc2,0x98,0x81,0x95,0xbf,0xe7,0x12,0x1d,0xf3, - 0xca,0xa3,0x98,0xbd,0xe6,0x0e,0x1f,0xf6,0xcd,0xa4,0x81,0x90,0xb8,0xdf,0xff,0x19, - 0x12,0xf5,0xd1,0xa9,0x81,0x81,0x81,0x95,0xbd,0xe3,0x05,0x19,0x0f,0xf1,0xcc,0xa4, - 0x81,0x81,0x81,0x81,0x81,0x86,0xa1,0xbd,0xd7,0xf3,0x0f,0x23,0x09,0xee,0xc6,0x9d, - 0x81,0x81,0x93,0xa5,0xa8,0xa8,0xa8,0xa8,0xa8,0xa8,0xa8,0xa8,0xa8,0xa8,0xa6,0x94, - 0x81,0x81,0x92,0xbc,0xe5,0x04,0x1e,0x13,0xf7,0xdd,0xc2,0xa7,0x8c,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x82,0x95,0x9b,0x9b,0xbe,0xe7,0x13,0x21,0xf5,0xca,0xa0,0x81, - 0x81,0x92,0xba,0xe1,0x0a,0x15,0xef,0xc8,0xdc,0xe9,0xea,0xe0,0xe9,0xeb,0x15,0x06, - 0xdd,0xb2,0x89,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0,0x85,0x81, - 0x91,0xb9,0xdb,0xe2,0xe2,0xe0,0xc9,0xe2,0xe2,0xe2,0xd5,0xb2,0x89,0x81,0xa5,0xd0, - 0xfa,0x13,0x13,0x1c,0x18,0x13,0x13,0x13,0x24,0x13,0x13,0x13,0xf2,0xc8,0x9d,0x81, - 0x8f,0xb8,0xe2,0x0b,0x2b,0x05,0xe7,0xf7,0x22,0xfc,0xd2,0xa9,0x8b,0x82,0x81,0x81, - 0x81,0x81,0x9e,0xc4,0xe7,0x05,0x19,0x1e,0x13,0xfb,0xf5,0x19,0x0a,0xe6,0xc2,0x9f, - 0x81,0x81,0x81,0x81,0x81,0x81,0xa6,0xce,0xf5,0x1b,0x1a,0xf7,0xf9,0x12,0x1c,0xfc, - 0xda,0xb4,0x9a,0x8e,0x81,0x81,0x81,0x91,0xb9,0xdb,0xe2,0xe2,0xe1,0xc7,0xa0,0x81, - 0x81,0xa9,0xd2,0xfa,0x22,0x0a,0xe1,0xba,0x93,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0xa2,0xca,0xf1,0x19,0x14,0xec,0xc3,0x9b,0x81,0x90,0xb9,0xdf,0xf4,0x07,0x19, - 0x04,0x16,0xfc,0x10,0x0f,0xfc,0xe9,0xcb,0xa2,0x81,0x81,0x81,0x81,0x81,0x81,0xa5, - 0xd0,0xfa,0x26,0x06,0xda,0xb0,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x8d,0xb4,0xdb,0x04,0x23,0xfc,0xd5,0xae,0x87,0x81,0x81,0x81, - 0x8e,0xb7,0xe1,0x0b,0x21,0xf7,0xcf,0xb2,0xcc,0xe4,0xfc,0x17,0x33,0x11,0xe7,0xbe, - 0x94,0x81,0x81,0x9c,0xc2,0xdd,0xd6,0xc2,0xd7,0x04,0x2e,0x09,0xdd,0xb2,0x88,0x81, - 0x81,0x81,0x81,0x81,0x81,0x98,0xae,0xb1,0xa0,0x85,0x96,0xc0,0xea,0x13,0x1e,0xf4, - 0xca,0xa0,0x81,0x81,0x81,0x81,0x83,0xa3,0xb8,0xba,0xba,0xc0,0xd9,0xfc,0x26,0x06, - 0xde,0xb5,0x8c,0x81,0x81,0x81,0x81,0x9a,0xbe,0xe1,0x05,0x22,0xfc,0xdb,0x06,0x29, - 0xfc,0xd2,0xa8,0x81,0x81,0x81,0x81,0x88,0xb2,0xdd,0x09,0x21,0xf5,0xd0,0xcf,0xca, - 0xc2,0xb5,0xa2,0x8b,0x81,0x81,0x81,0x86,0xb0,0xd9,0xff,0x26,0xfc,0xd6,0xd4,0xd7, - 0xd7,0xd2,0xc5,0xb3,0x9b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x84,0xaa, - 0xd1,0xf6,0x1d,0x0f,0xe9,0xc4,0x9d,0x81,0x81,0x81,0xaa,0xd3,0xfb,0x22,0x12,0xf3, - 0xdb,0xcc,0xe3,0xff,0x25,0x0a,0xe2,0xba,0x91,0x81,0x95,0xc0,0xea,0x16,0x1b,0xef, - 0xc5,0x9c,0x8b,0xb3,0xdd,0x07,0x29,0xfc,0xd4,0xaa,0x81,0x95,0xc0,0xea,0x15,0x3d, - 0x2e,0x06,0xda,0xb0,0x85,0x81,0x81,0x9b,0xc5,0xef,0x1a,0x41,0x29,0xff,0xd5,0xab, - 0x81,0x81,0x81,0x81,0x8c,0xa7,0xc2,0xdd,0xf7,0x14,0x1d,0x04,0xe8,0xcd,0xb2,0x8f, - 0x81,0x8c,0xb1,0xcd,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xce,0xb3, - 0x8e,0x81,0x86,0xaa,0xc8,0xe3,0xfc,0x19,0x18,0xfc,0xe3,0xc7,0xac,0x91,0x81,0x81, - 0x81,0x81,0x81,0x81,0xa0,0xbc,0xc5,0xc5,0xcc,0xed,0x16,0x1c,0xf2,0xc8,0x9e,0x81, - 0x81,0x9f,0xc7,0xef,0x18,0x07,0xdf,0xe6,0xff,0x13,0x13,0x09,0x11,0xe6,0x11,0x0b, - 0xe2,0xb8,0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0,0x85,0x81, - 0x81,0x9f,0xb4,0xb8,0xb8,0xb7,0xaa,0xb8,0xb8,0xb8,0xb2,0x9a,0x81,0x81,0xa2,0xc9, - 0xe7,0xe7,0xea,0x13,0x0b,0xe7,0xe7,0xf5,0x21,0xfc,0xe7,0xe7,0xe3,0xc2,0x9a,0x81, - 0x85,0xae,0xd4,0xf9,0x1a,0x23,0x0b,0xfc,0x21,0xf7,0xcd,0xb9,0xa5,0x8d,0x81,0x81, - 0x81,0x81,0x8a,0xac,0xca,0xe1,0xef,0xf2,0xec,0xe8,0x0d,0x16,0xf3,0xcf,0xac,0x89, - 0x81,0x81,0x81,0x81,0x81,0x81,0x97,0xbc,0xe1,0x05,0x26,0x13,0x1d,0x12,0xfb,0xdf, - 0xc5,0xc5,0xc4,0xb2,0x91,0x81,0x81,0x81,0x9f,0xb4,0xb8,0xb8,0xb7,0xa9,0x8c,0x81, - 0x8a,0xb3,0xdc,0x06,0x26,0xfc,0xd4,0xac,0x84,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x94,0xbc,0xe5,0x0e,0x20,0xf7,0xcd,0xa4,0x81,0x92,0xbb,0xe3,0x09,0x0f,0xf7, - 0xea,0x16,0xfc,0xee,0x06,0x18,0xf3,0xcd,0xa4,0x81,0x81,0x91,0xa2,0xa5,0xa5,0xa5, - 0xd0,0xfa,0x26,0x06,0xda,0xb0,0xa5,0xa5,0xa4,0x96,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xa8,0xab,0xab,0xab,0xab,0xab, - 0xab,0xab,0xa8,0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x9e,0xc5,0xec,0x13,0x13,0xec,0xc5,0x9e,0x81,0x81,0x81,0x81, - 0x93,0xbd,0xe7,0x11,0x1b,0xf1,0xc7,0xd4,0xee,0x07,0x20,0x13,0x18,0x18,0xed,0xc2, - 0x98,0x81,0x81,0x86,0xa4,0xb4,0xb0,0xad,0xd7,0x04,0x2e,0x09,0xdd,0xb2,0x88,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x85,0x87,0x81,0x89,0xaa,0xce,0xf4,0x1c,0x14,0xec, - 0xc3,0x99,0x81,0x81,0x81,0x81,0x94,0xbc,0xde,0xe5,0xe5,0xe9,0xf9,0x14,0x12,0xf1, - 0xce,0xa8,0x81,0x81,0x81,0x81,0x8e,0xb1,0xd5,0xf9,0x1c,0x0b,0xe7,0xda,0x06,0x29, - 0xfc,0xd2,0xa8,0x81,0x81,0x81,0x81,0x88,0xb2,0xdd,0x09,0x21,0xfa,0xfa,0xf9,0xf5, - 0xeb,0xdb,0xc6,0xac,0x8e,0x81,0x81,0x8e,0xb8,0xe2,0x0b,0x1e,0xf5,0xf4,0xfc,0x04, - 0x04,0xfa,0xec,0xd6,0xb9,0x9b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x97,0xbc, - 0xe2,0x09,0x24,0xfc,0xd7,0xb1,0x8b,0x81,0x81,0x81,0x9d,0xc4,0xe8,0x09,0x25,0x15, - 0xff,0xf1,0x07,0x1f,0x10,0xf1,0xd0,0xab,0x84,0x81,0x93,0xbd,0xe7,0x11,0x20,0xf7, - 0xd0,0xb6,0xb5,0xbe,0xd8,0x04,0x2c,0x04,0xd7,0xad,0x83,0x93,0xbc,0xe5,0x0b,0x25, - 0x1d,0xfc,0xd6,0xad,0x83,0x81,0x81,0x98,0xc1,0xe9,0x0f,0x27,0x1a,0xf7,0xd1,0xa8, - 0x81,0x81,0x81,0x91,0xac,0xc7,0xe3,0xfc,0x18,0x18,0xfc,0xe3,0xc8,0xac,0x92,0x81, - 0x81,0x95,0xc0,0xea,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xec,0xc2, - 0x98,0x81,0x81,0x8c,0xa7,0xc2,0xdd,0xf7,0x14,0x1d,0x04,0xe7,0xcc,0xb1,0x96,0x81, - 0x81,0x81,0x81,0x8a,0xb3,0xdb,0xef,0xef,0xf4,0x07,0x26,0x0f,0xe7,0xbf,0x97,0x81, - 0x81,0xa9,0xd2,0xfa,0x23,0xfa,0xde,0xff,0x21,0x05,0x04,0x20,0x09,0xe2,0x0b,0x0f, - 0xe5,0xba,0x90,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0,0x85,0x81, - 0x81,0x81,0x8b,0x8d,0x8d,0x8d,0x84,0x8d,0x8d,0x8d,0x89,0x81,0x81,0x81,0x8f,0xad, - 0xbd,0xc4,0xed,0x19,0x06,0xdd,0xd0,0xfa,0x24,0xfa,0xd0,0xbd,0xbb,0xa8,0x89,0x81, - 0x81,0x9b,0xbe,0xdd,0xfa,0x12,0x24,0x23,0x1f,0xff,0xf1,0xde,0xc8,0xae,0x90,0x81, - 0x81,0x81,0x81,0x8e,0xa8,0xbb,0xc6,0xc8,0xdc,0xff,0x22,0xff,0xdb,0xbd,0xba,0xaf, - 0x9c,0x83,0x81,0x81,0x81,0x8b,0xae,0xcc,0xe9,0x04,0x1f,0x32,0x0e,0xee,0xd9,0xdb, - 0xef,0xef,0xed,0xca,0xa1,0x81,0x81,0x81,0x81,0x8b,0x8d,0x8d,0x8d,0x83,0x81,0x81, - 0x90,0xba,0xe4,0x0e,0x1e,0xf5,0xcc,0xa2,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x89,0xb2,0xdc,0x06,0x29,0xff,0xd5,0xab,0x81,0x85,0xaa,0xcf,0xf4,0xec,0xd4, - 0xea,0x16,0xfc,0xd2,0xe3,0xfb,0xde,0xb9,0x94,0x81,0x8b,0xaf,0xcb,0xd0,0xd0,0xd0, - 0xd0,0xfa,0x26,0x06,0xda,0xd0,0xd0,0xd0,0xce,0xb7,0x94,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8d,0xb2,0xcf,0xd5,0xd5,0xd5,0xd5,0xd5, - 0xd5,0xd5,0xcf,0xb2,0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x87,0xae,0xd5,0xfc,0x23,0x04,0xdb,0xb4,0x8d,0x81,0x81,0x81,0x81, - 0x95,0xc0,0xea,0x16,0x19,0xed,0xdd,0xf6,0x0f,0x23,0x0b,0xf1,0x13,0x1b,0xef,0xc5, - 0x9b,0x81,0x81,0x81,0x81,0x8a,0x88,0xad,0xd7,0x04,0x2e,0x09,0xdd,0xb2,0x88,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x87,0xa5,0xc5,0xe6,0x09,0x26,0x04,0xdc, - 0xb5,0x8e,0x81,0x81,0x81,0x81,0x98,0xc2,0xed,0x11,0x11,0x13,0x1f,0x07,0xf1,0xd5, - 0xbb,0x9d,0x81,0x81,0x81,0x81,0xa4,0xc8,0xec,0x0f,0x17,0xf3,0xd0,0xda,0x06,0x29, - 0xfc,0xd2,0xa8,0x81,0x81,0x81,0x81,0x88,0xb2,0xdd,0x09,0x26,0x26,0x26,0x23,0x1e, - 0x13,0xff,0xe8,0xc9,0xa7,0x83,0x81,0x93,0xbd,0xe7,0x11,0x1c,0x0c,0x1d,0x1b,0x19, - 0x1c,0x23,0x11,0xf5,0xd6,0xb3,0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x84,0xaa,0xcf, - 0xf5,0x1b,0x12,0xeb,0xc5,0x9f,0x81,0x81,0x81,0x81,0x8a,0xad,0xcc,0xea,0x04,0x18, - 0x26,0x19,0x24,0x07,0xf0,0xd4,0xb6,0x95,0x81,0x81,0x8b,0xb4,0xdc,0x04,0x29,0x0b, - 0xee,0xdf,0xdf,0xe7,0xf5,0x0a,0x2e,0x04,0xd7,0xad,0x83,0x86,0xac,0xd0,0xec,0xfc, - 0xf7,0xe1,0xc2,0x9e,0x81,0x81,0x81,0x8b,0xb1,0xd4,0xef,0xfc,0xf6,0xdd,0xbe,0x99, - 0x81,0x81,0x96,0xb1,0xcc,0xe8,0x04,0x1d,0x12,0xf7,0xdd,0xc2,0xa7,0x8c,0x81,0x81, - 0x81,0x95,0xc0,0xea,0x16,0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x19,0xed,0xc2, - 0x98,0x81,0x81,0x81,0x87,0xa1,0xbd,0xd7,0xf3,0x0f,0x23,0x09,0xec,0xd2,0xb7,0x9b, - 0x81,0x81,0x81,0x8b,0xb5,0xdf,0x0b,0x1b,0x1e,0x20,0x0f,0xf5,0xd4,0xaf,0x89,0x81, - 0x87,0xb1,0xda,0x04,0x19,0xf1,0xef,0x16,0x0c,0xe6,0xf5,0x1f,0x04,0xdf,0x0b,0x11, - 0xe5,0xba,0x90,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0,0x85,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x82,0xa3,0xb9, - 0xbd,0xc8,0xf2,0x1c,0x04,0xd7,0xd4,0xfc,0x21,0xf5,0xcc,0xbd,0xb2,0x95,0x81,0x81, - 0x81,0x83,0xa1,0xbf,0xd8,0xec,0xfc,0x10,0x2a,0x28,0x17,0x04,0xea,0xcc,0xac,0x89, - 0x81,0x81,0x81,0x81,0x82,0x93,0xac,0xd0,0xf3,0x17,0x0b,0xe8,0xe3,0xe7,0xe4,0xd5, - 0xbf,0xa1,0x81,0x81,0x81,0xa1,0xc6,0xe8,0x09,0x25,0x0b,0x12,0x25,0x04,0xe3,0xdf, - 0x0b,0x1b,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x95,0xbf,0xe7,0x13,0x1a,0xef,0xc5,0x9b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x82,0xab,0xd5,0xff,0x2b,0x04,0xda,0xb0,0x85,0x81,0x96,0xb9,0xd1,0xc9,0xc0, - 0xea,0x16,0xfc,0xd2,0xc0,0xd2,0xc4,0xa4,0x81,0x81,0x95,0xbf,0xe9,0xfa,0xfa,0xfa, - 0xfa,0xfa,0x26,0x06,0xfa,0xfa,0xfa,0xfa,0xf3,0xca,0xa0,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xea,0xc0,0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x98,0xbe,0xe6,0x0c,0x19,0xf1,0xcb,0xa4,0x81,0x81,0x81,0x81,0x81, - 0x95,0xc0,0xea,0x16,0x19,0xed,0xff,0x18,0x1a,0xff,0xe8,0xe7,0x13,0x1b,0xef,0xc5, - 0x9b,0x81,0x81,0x81,0x81,0x81,0x83,0xad,0xd7,0x04,0x2e,0x09,0xdd,0xb2,0x88,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x87,0xa3,0xc3,0xe1,0xff,0x21,0x0f,0xec,0xc8, - 0xa4,0x81,0x81,0x81,0x81,0x81,0x98,0xc2,0xed,0x0e,0x0e,0x0f,0x16,0x1e,0x0f,0xf7, - 0xd9,0xb8,0x94,0x81,0x81,0x97,0xbb,0xdf,0x04,0x23,0xff,0xdc,0xb9,0xda,0x06,0x29, - 0xfc,0xd2,0xa8,0x9e,0x8e,0x81,0x81,0x88,0xb2,0xdc,0xfa,0xfa,0xfa,0xfa,0xfc,0x09, - 0x1a,0x23,0x05,0xe1,0xbc,0x95,0x81,0x95,0xc0,0xea,0x16,0x25,0x0f,0xfc,0xf2,0xed, - 0xf3,0x06,0x23,0x11,0xec,0xc6,0x9e,0x81,0x81,0x81,0x81,0x81,0x81,0x97,0xbc,0xe2, - 0x09,0x25,0xff,0xd9,0xb3,0x8c,0x81,0x81,0x81,0x81,0x91,0xb2,0xd0,0xec,0x05,0x1a, - 0x19,0x17,0x2a,0x14,0xfc,0xe3,0xc4,0xa2,0x81,0x81,0x81,0xa5,0xcb,0xee,0x0f,0x28, - 0x14,0x09,0x09,0x0f,0x1d,0x16,0x2b,0xff,0xd7,0xad,0x83,0x81,0x94,0xb1,0xc7,0xd2, - 0xcf,0xc0,0xa5,0x87,0x81,0x81,0x81,0x81,0x98,0xb4,0xc9,0xd2,0xce,0xbd,0xa1,0x83, - 0x81,0x8b,0xb2,0xd2,0xec,0x09,0x23,0x0d,0xf1,0xd7,0xbc,0xa1,0x86,0x81,0x81,0x81, - 0x81,0x95,0xbf,0xe7,0xf5,0xf5,0xf5,0xf5,0xf5,0xf5,0xf5,0xf5,0xf5,0xf5,0xe9,0xc1, - 0x97,0x81,0x81,0x81,0x81,0x81,0x9c,0xb7,0xd2,0xed,0x09,0x23,0x0d,0xf1,0xd7,0xb8, - 0x93,0x81,0x81,0x8b,0xb5,0xdf,0x0b,0x1b,0xfc,0xf7,0xeb,0xd5,0xb9,0x99,0x81,0x81, - 0x8d,0xb8,0xe2,0x0b,0x13,0xe8,0xfc,0x24,0xfc,0xd5,0xfb,0x26,0xfc,0xdf,0x0b,0x11, - 0xe5,0xba,0x90,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0,0x85,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x92,0xbb,0xdf, - 0xe7,0xe7,0xf6,0x21,0xfc,0xe7,0xe7,0x04,0x1c,0xf2,0xe7,0xe7,0xd0,0xa9,0x81,0x81, - 0x81,0x81,0x83,0x9d,0xb3,0xc6,0xe4,0x0e,0x0f,0x06,0x19,0x25,0x09,0xe7,0xc2,0x9b, - 0x81,0x81,0x81,0x81,0x81,0xa0,0xc4,0xe7,0x0b,0x18,0xf4,0xf7,0x0b,0x13,0x0d,0xf9, - 0xdd,0xba,0x95,0x81,0x89,0xb2,0xd9,0xff,0x24,0x0b,0xea,0xf7,0x1a,0x1e,0xfc,0xe5, - 0x0e,0x1e,0xf5,0xca,0xa0,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0xa8,0xd2,0xfc,0x29,0x06,0xda,0xb0,0x85,0x81,0x81,0x99,0xa7,0xa3,0xbf, - 0xe7,0xf5,0xf4,0xd1,0xa7,0xa8,0xa0,0x89,0x81,0x81,0x95,0xc0,0xea,0x16,0x26,0x26, - 0x26,0x26,0x36,0x26,0x26,0x26,0x26,0x21,0xf5,0xca,0xa0,0x81,0x81,0x81,0x81,0x81, - 0x81,0x8e,0x93,0x90,0x82,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x29,0x29,0x29,0x29, - 0x29,0x16,0xea,0xc0,0x95,0x81,0x81,0x81,0x85,0x8d,0x8d,0x84,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0xa8,0xcf,0xf5,0x1d,0x09,0xe1,0xba,0x93,0x81,0x81,0x81,0x81,0x81, - 0x95,0xbf,0xe8,0x13,0x19,0x09,0x21,0x12,0xf9,0xdf,0xc6,0xea,0x16,0x19,0xed,0xc3, - 0x9a,0x81,0x81,0x81,0x81,0x81,0x83,0xad,0xd7,0x04,0x2e,0x09,0xdd,0xb2,0x88,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x87,0xa5,0xc3,0xdf,0xff,0x1d,0x12,0xf3,0xd3,0xb1, - 0x8e,0x81,0x81,0x81,0x81,0x81,0x94,0xbb,0xdc,0xe2,0xe2,0xe5,0xee,0xff,0x1c,0x16, - 0xf1,0xcd,0xa5,0x81,0x8a,0xae,0xd2,0xf5,0x19,0x0d,0xe9,0xca,0xca,0xda,0x06,0x29, - 0xfc,0xd2,0xca,0xc7,0xae,0x8b,0x81,0x81,0xa4,0xc4,0xd0,0xd0,0xd0,0xd0,0xd5,0xe1, - 0xf9,0x1d,0x1a,0xf2,0xc9,0xa0,0x81,0x95,0xc0,0xea,0x16,0x1b,0xef,0xd6,0xc9,0xc2, - 0xcc,0xe8,0x0f,0x24,0xfa,0xd2,0xa8,0x81,0x81,0x81,0x81,0x81,0x84,0xaa,0xcf,0xf5, - 0x1b,0x13,0xed,0xc7,0xa0,0x81,0x81,0x81,0x81,0x81,0xa6,0xcb,0xee,0x0d,0x25,0x0b, - 0xf3,0xf1,0x05,0x1d,0x1d,0xff,0xdd,0xb8,0x92,0x81,0x81,0x91,0xb3,0xd2,0xee,0x04, - 0x0e,0x13,0x11,0x0a,0xfc,0x06,0x26,0xfc,0xd2,0xa8,0x81,0x81,0x81,0x8e,0x9f,0xa8, - 0xa6,0x9a,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x91,0xa1,0xa8,0xa5,0x98,0x82,0x81, - 0x81,0x93,0xbd,0xe7,0x0c,0x27,0x0e,0xee,0xd4,0xb9,0x9d,0x83,0x81,0x81,0x81,0x81, - 0x81,0x8a,0xae,0xc8,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xc9,0xb0, - 0x8c,0x81,0x81,0x81,0x81,0x81,0x81,0x97,0xb2,0xcd,0xe8,0x06,0x2c,0x11,0xef,0xc5, - 0x9b,0x81,0x81,0x8b,0xb5,0xdf,0x0b,0x1b,0xef,0xcd,0xc3,0xb2,0x99,0x81,0x81,0x81, - 0x92,0xbd,0xe7,0x11,0x0e,0xe2,0x06,0x1e,0xf5,0xd7,0x04,0x20,0xf5,0xe2,0x0e,0x0e, - 0xe2,0xb8,0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x23,0x06,0xda,0xb0,0x85,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea, - 0x13,0x13,0x13,0x28,0x13,0x13,0x13,0x14,0x22,0x13,0x13,0x04,0xd7,0xad,0x83,0x81, - 0x81,0x81,0x83,0x84,0x96,0xc0,0xea,0x13,0x0b,0xdf,0xf5,0x16,0x20,0xf9,0xd1,0xa7, - 0x81,0x81,0x81,0x81,0x94,0xb7,0xdb,0xfc,0x22,0xff,0xf3,0x16,0x10,0x04,0x11,0x18, - 0xf4,0xcd,0xa5,0x81,0x92,0xbc,0xe6,0x0f,0x1f,0xf7,0xd1,0xde,0xff,0x20,0x18,0xf6, - 0x15,0x16,0xed,0xc4,0x9a,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x95,0xc0,0xea,0x14,0x19,0xef,0xc5,0x9b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0xaa,0xd5,0xfc,0x29,0x04,0xda,0xb0,0x85,0x81,0x81,0x81,0x81,0x88,0xac, - 0xc6,0xca,0xca,0xb9,0x99,0x81,0x81,0x81,0x81,0x81,0x95,0xbf,0xe9,0xfa,0xfa,0xfa, - 0xfa,0xfa,0x26,0x06,0xfa,0xfa,0xfa,0xfa,0xf3,0xca,0xa0,0x81,0x81,0x81,0x81,0x89, - 0xa4,0xb7,0xbd,0xb9,0xa8,0x90,0x81,0x81,0x95,0xc0,0xea,0xfc,0xfc,0xfc,0xfc,0xfc, - 0xfc,0xfc,0xea,0xc0,0x95,0x81,0x81,0x99,0xad,0xb8,0xb7,0xab,0x96,0x81,0x81,0x81, - 0x81,0x81,0x91,0xb8,0xdf,0x06,0x1f,0xf7,0xd1,0xaa,0x83,0x81,0x81,0x81,0x81,0x81, - 0x91,0xba,0xe5,0x0f,0x33,0x22,0x09,0xf0,0xd7,0xbd,0xc6,0xef,0x19,0x13,0xe9,0xbf, - 0x95,0x81,0x81,0x81,0x81,0x81,0x83,0xad,0xd7,0x04,0x2e,0x09,0xdd,0xb2,0x88,0x81, - 0x81,0x81,0x81,0x81,0x81,0x87,0xa5,0xc3,0xe1,0xff,0x1c,0x14,0xf5,0xd6,0xb8,0x97, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa1,0xb5,0xb8,0xb8,0xbb,0xc6,0xe1,0x06,0x2b, - 0x04,0xd8,0xaf,0x85,0x95,0xbf,0xe8,0x0d,0x1a,0xf5,0xf5,0xf5,0xf5,0xf5,0x06,0x29, - 0xfc,0xf5,0xf5,0xe9,0xc1,0x97,0x81,0x81,0x88,0x9e,0xa5,0xa5,0xa5,0xa5,0xab,0xbf, - 0xe6,0x0f,0x24,0xfa,0xd0,0xa5,0x81,0x95,0xbf,0xe8,0x13,0x1e,0xf2,0xc8,0xa0,0x98, - 0xb1,0xda,0x05,0x2c,0x04,0xd7,0xad,0x83,0x81,0x81,0x81,0x81,0x97,0xbc,0xe2,0x09, - 0x27,0xff,0xda,0xb4,0x8e,0x81,0x81,0x81,0x81,0x8d,0xb6,0xde,0x05,0x29,0x09,0xe8, - 0xcf,0xcb,0xe3,0xff,0x20,0x17,0xef,0xc8,0x9f,0x81,0x81,0x81,0x96,0xb3,0xc9,0xdb, - 0xe5,0xe7,0xe7,0xe1,0xe2,0x0b,0x1e,0xf5,0xcc,0xa2,0x81,0x81,0x81,0x90,0xa2,0xab, - 0xa9,0x9b,0x87,0x81,0x81,0x81,0x81,0x81,0x89,0xa4,0xb7,0xbd,0xb8,0xa8,0x90,0x81, - 0x81,0x8a,0xb0,0xd0,0xeb,0x07,0x21,0x0f,0xf3,0xd9,0xbe,0xa3,0x88,0x81,0x81,0x81, - 0x81,0x95,0xbf,0xe8,0xf7,0xf7,0xf7,0xf7,0xf7,0xf7,0xf7,0xf7,0xf7,0xf7,0xeb,0xc2, - 0x98,0x81,0x81,0x81,0x81,0x82,0x9d,0xb8,0xd3,0xee,0x09,0x23,0x0c,0xf0,0xd5,0xb7, - 0x92,0x81,0x81,0x8b,0xb5,0xdf,0x0b,0x1b,0xef,0xc5,0x9b,0x8c,0x81,0x81,0x81,0x81, - 0x95,0xc0,0xea,0x13,0x0a,0xdf,0x0b,0x19,0xef,0xde,0x09,0x19,0xef,0xe7,0x11,0x09, - 0xdf,0xb5,0x8b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xaa,0xd4,0xf7,0xf7,0xf7,0xd9,0xaf,0x85,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea, - 0x04,0x04,0x04,0x21,0x04,0x04,0x04,0x0c,0x14,0x04,0x04,0x04,0xd7,0xad,0x83,0x81, - 0x81,0x99,0xad,0xad,0xa1,0xc5,0xef,0x19,0x05,0xda,0xdf,0x09,0x2b,0xff,0xd5,0xab, - 0x81,0x81,0x81,0x87,0xab,0xce,0xf1,0x15,0x0d,0xe9,0x04,0x1e,0xf5,0xd8,0xf7,0x1f, - 0xff,0xd7,0xad,0x84,0x95,0xc0,0xea,0x16,0x1b,0xef,0xc5,0xc3,0xe4,0x06,0x27,0x12, - 0x21,0x0b,0xe2,0xba,0x91,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x92,0xbc,0xe6,0x11,0x1e,0xf4,0xca,0xa0,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x86,0xaf,0xd9,0x04,0x29,0xff,0xd5,0xab,0x82,0x81,0x81,0x81,0x81,0x81,0x8c, - 0x9d,0xa0,0xa0,0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x8b,0xaf,0xcb,0xd0,0xd0,0xd0, - 0xd0,0xfa,0x26,0x06,0xda,0xd0,0xd0,0xd0,0xce,0xb7,0x94,0x81,0x81,0x81,0x81,0xa5, - 0xc5,0xdf,0xe7,0xe1,0xcc,0xae,0x8c,0x81,0x8c,0xb1,0xcd,0xd2,0xd2,0xd2,0xd2,0xd2, - 0xd2,0xd2,0xcd,0xb1,0x8c,0x81,0x9b,0xb9,0xd3,0xe2,0xe0,0xd1,0xb6,0x97,0x81,0x81, - 0x81,0x81,0xa1,0xc8,0xef,0x17,0x0f,0xe7,0xc1,0x9a,0x81,0x81,0x81,0x81,0x81,0x81, - 0x8b,0xb5,0xde,0x07,0x2b,0xff,0xe7,0xce,0xb5,0xab,0xd2,0xfa,0x23,0x0b,0xe1,0xb8, - 0x8e,0x81,0x81,0x81,0x8d,0x95,0x95,0xad,0xd7,0x04,0x2e,0x09,0xdd,0xb2,0x95,0x94, - 0x86,0x81,0x81,0x81,0x87,0xa5,0xc3,0xe1,0xff,0x1d,0x14,0xf5,0xd7,0xb9,0x9b,0x98, - 0x96,0x87,0x81,0x81,0x81,0x81,0x90,0x92,0x8d,0x8d,0x8d,0x91,0xac,0xd5,0xff,0x2b, - 0x06,0xda,0xb0,0x85,0x95,0xc0,0xea,0x16,0x29,0x21,0x21,0x21,0x21,0x21,0x21,0x34, - 0x21,0x21,0x19,0xed,0xc2,0x98,0x81,0x81,0x83,0x93,0x94,0x8d,0x89,0x8a,0x96,0xbb, - 0xe4,0x0e,0x23,0xfa,0xd0,0xa5,0x81,0x90,0xba,0xe4,0x0e,0x21,0xf7,0xcf,0xa6,0x87, - 0xb0,0xda,0x04,0x2c,0x04,0xd7,0xad,0x83,0x81,0x81,0x81,0x84,0xaa,0xcf,0xf5,0x1b, - 0x14,0xee,0xc8,0xa2,0x81,0x81,0x81,0x81,0x81,0x95,0xbf,0xe8,0x13,0x1f,0xf5,0xce, - 0xad,0xa7,0xc3,0xe7,0x11,0x23,0xfa,0xd0,0xa5,0x81,0x81,0x81,0x81,0x90,0xa4,0xb2, - 0xba,0xbd,0xbd,0xce,0xf1,0x18,0x11,0xe9,0xc1,0x98,0x81,0x81,0x94,0xb2,0xc9,0xd5, - 0xd2,0xc1,0xa7,0x88,0x81,0x81,0x81,0x81,0xa5,0xc5,0xde,0xe7,0xe1,0xcc,0xae,0x8b, - 0x81,0x81,0x94,0xb0,0xcb,0xe6,0xff,0x1c,0x14,0xf9,0xdf,0xc3,0xa8,0x8d,0x81,0x81, - 0x81,0x95,0xc0,0xea,0x16,0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x23,0x19,0xed,0xc2, - 0x98,0x81,0x81,0x81,0x88,0xa3,0xbd,0xd9,0xf3,0x0f,0x21,0x07,0xec,0xd0,0xb5,0x9a, - 0x81,0x81,0x81,0x8b,0xb5,0xdf,0xfa,0xfa,0xee,0xc5,0x9a,0x81,0x81,0x81,0x81,0x81, - 0x95,0xc0,0xea,0x16,0x09,0xe2,0x0e,0x19,0xed,0xe5,0x0e,0x13,0xea,0xee,0x18,0xff, - 0xd7,0xaf,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa6,0xc7,0xe0,0xea,0xe2,0xca,0xaa,0x86,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0xb4,0xd2, - 0xd7,0xd9,0x04,0x1b,0xf2,0xd7,0xe5,0x11,0x11,0xe5,0xd7,0xd7,0xc7,0xa4,0x81,0x81, - 0x8f,0xb5,0xd4,0xd6,0xca,0xca,0xf5,0x1f,0xff,0xd5,0xe6,0x0d,0x25,0xfc,0xd2,0xa9, - 0x81,0x81,0x81,0x9e,0xc2,0xe5,0x09,0x19,0xf5,0xdd,0x09,0x19,0xed,0xc5,0xef,0x1b, - 0x06,0xda,0xb0,0x85,0x95,0xbf,0xe9,0x13,0x1f,0xf6,0xd0,0xb6,0xca,0xec,0x0d,0x2d, - 0x20,0xfb,0xd4,0xad,0x86,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x8c,0xb6,0xdf,0x09,0x25,0xfc,0xd3,0xaa,0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x90,0xb9,0xe1,0x0b,0x21,0xf7,0xcf,0xa5,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x91,0xa2,0xa5,0xa5,0xa5, - 0xd0,0xfa,0x26,0x06,0xda,0xb0,0xa5,0xa5,0xa4,0x96,0x81,0x81,0x81,0x81,0x90,0xb9, - 0xdf,0xff,0x13,0x07,0xea,0xc6,0x9f,0x81,0x81,0x93,0xa5,0xa8,0xa8,0xa8,0xa8,0xa8, - 0xa8,0xa8,0xa5,0x93,0x81,0x8a,0xb1,0xd6,0xf5,0x0b,0x0a,0xf1,0xd2,0xac,0x85,0x81, - 0x81,0x8b,0xb2,0xd9,0xff,0x25,0xfc,0xd7,0xb0,0x89,0x81,0x81,0x81,0x81,0x81,0x81, - 0x82,0xab,0xd3,0xfb,0x23,0x0e,0xe8,0xc5,0xb3,0xc3,0xe4,0x0a,0x25,0xfc,0xd6,0xad, - 0x85,0x81,0x81,0x95,0xb2,0xc0,0xc0,0xc0,0xd7,0x04,0x2e,0x09,0xdd,0xc0,0xc0,0xbd, - 0xa8,0x88,0x81,0x83,0xa5,0xc3,0xe1,0xff,0x1d,0x12,0xf3,0xd7,0xc2,0xc2,0xc2,0xc2, - 0xbf,0xa9,0x87,0x81,0x82,0xa3,0xb9,0xbc,0xb7,0xb3,0xb2,0xb7,0xc5,0xe2,0x09,0x26, - 0xfc,0xd4,0xab,0x82,0x95,0xc0,0xea,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x06,0x29, - 0xff,0xff,0xff,0xed,0xc2,0x98,0x81,0x83,0xa5,0xbc,0xbd,0xb7,0xb3,0xb4,0xbc,0xd1, - 0xf1,0x18,0x18,0xf1,0xc8,0x9f,0x81,0x89,0xb3,0xdc,0x05,0x2b,0x04,0xdc,0xba,0xb1, - 0xc1,0xe5,0x0c,0x22,0xfa,0xd1,0xa8,0x81,0x81,0x81,0x81,0x97,0xbc,0xe2,0x09,0x28, - 0x04,0xdc,0xb6,0x8f,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x1e,0xf5,0xcd, - 0xb6,0xb4,0xc0,0xe4,0x0e,0x23,0xfa,0xd0,0xa5,0x81,0x81,0x83,0xa3,0xb8,0xba,0xba, - 0xbd,0xc5,0xd4,0xeb,0x09,0x22,0xfc,0xd9,0xb2,0x8b,0x81,0x87,0xad,0xd0,0xee,0xff, - 0xfa,0xe3,0xc3,0x9f,0x81,0x81,0x81,0x90,0xb9,0xdf,0xff,0x13,0x07,0xe9,0xc5,0x9f, - 0x81,0x81,0x81,0x8f,0xaa,0xc5,0xe1,0xfb,0x17,0x1a,0xff,0xe4,0xc8,0xae,0x93,0x81, - 0x81,0x95,0xbf,0xe9,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xec,0xc2, - 0x98,0x81,0x81,0x8d,0xa8,0xc3,0xde,0xf9,0x14,0x1c,0xff,0xe6,0xcb,0xb0,0x94,0x81, - 0x81,0x81,0x81,0x8f,0xb3,0xd2,0xe7,0xea,0xda,0xbd,0x9b,0x81,0x81,0x81,0x81,0x81, - 0x95,0xc0,0xea,0x16,0x09,0xe2,0x0b,0x19,0xef,0xf3,0x18,0x13,0xe7,0xfa,0x1f,0xf6, - 0xce,0xa5,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x90,0xb9,0xe0,0x04,0x16,0x07,0xe5,0xbe,0x96,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x97,0xaa, - 0xb3,0xdd,0x09,0x19,0xed,0xc3,0xea,0x13,0x0b,0xe1,0xb7,0xad,0xa4,0x8b,0x81,0x81, - 0x95,0xc0,0xea,0xfc,0xf3,0xed,0xfa,0x23,0xfa,0xf2,0x04,0x21,0x13,0xee,0xc8,0x9f, - 0x81,0x81,0x92,0xb5,0xd9,0xfc,0x20,0x04,0xdf,0xdb,0x06,0x1c,0xf2,0xd3,0xf6,0x1f, - 0xff,0xd7,0xad,0x84,0x8e,0xb8,0xe0,0x07,0x2d,0x0b,0xee,0xdf,0xdf,0xed,0x05,0x28, - 0x24,0x04,0xe2,0xc1,0xa0,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x84,0xad,0xd6,0xfc,0x26,0x09,0xe0,0xb9,0x91,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x9e,0xc5,0xed,0x15,0x16,0xed,0xc5,0x9c,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa5, - 0xd0,0xfa,0x26,0x06,0xda,0xb0,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0, - 0xea,0x15,0x3c,0x24,0xfc,0xd5,0xac,0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x95,0xbf,0xe7,0x0f,0x32,0x2e,0x0b,0xe2,0xb9,0x8f,0x81, - 0x81,0x9b,0xc2,0xe9,0x11,0x14,0xee,0xc7,0xa0,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x9d,0xc5,0xeb,0x11,0x22,0xff,0xe8,0xdd,0xe6,0xff,0x1f,0x10,0xec,0xc6,0x9f, - 0x81,0x81,0x81,0xa8,0xcf,0xea,0xea,0xea,0xea,0x04,0x2e,0x09,0xea,0xea,0xea,0xe4, - 0xc1,0x98,0x81,0x93,0xbc,0xe1,0xff,0x1d,0x12,0xf3,0xed,0xed,0xed,0xed,0xed,0xed, - 0xe4,0xbf,0x96,0x81,0x92,0xbb,0xdf,0xe6,0xe1,0xdd,0xdd,0xe1,0xec,0xff,0x1d,0x12, - 0xed,0xc7,0xa0,0x81,0x8d,0xb2,0xcf,0xd5,0xd5,0xd5,0xd5,0xd5,0xd5,0xda,0x06,0x29, - 0xfc,0xd5,0xd5,0xd1,0xb5,0x8f,0x81,0x93,0xbc,0xe1,0xe7,0xe0,0xdd,0xdd,0xe4,0xf4, - 0x0d,0x25,0x04,0xe0,0xba,0x93,0x81,0x81,0xa7,0xce,0xf5,0x1b,0x16,0xf5,0xe0,0xda, - 0xe5,0xfc,0x1e,0x10,0xeb,0xc4,0x9d,0x81,0x81,0x81,0x84,0xaa,0xcf,0xf5,0x1b,0x17, - 0xef,0xc9,0xa4,0x81,0x81,0x81,0x81,0x81,0x81,0x91,0xbb,0xe4,0x0c,0x2b,0x09,0xed, - 0xdf,0xdd,0xe6,0xfb,0x1d,0x17,0xef,0xc8,0x9f,0x81,0x81,0x94,0xbc,0xde,0xe5,0xe5, - 0xe7,0xee,0xfa,0x0d,0x25,0x09,0xe7,0xc5,0xa0,0x81,0x81,0x94,0xbd,0xe5,0x0c,0x28, - 0x1f,0xfc,0xd6,0xad,0x83,0x81,0x81,0x95,0xc0,0xea,0x16,0x3c,0x24,0xfc,0xd5,0xac, - 0x82,0x81,0x81,0x81,0x8a,0xa5,0xc0,0xdb,0xf6,0x12,0x1f,0x05,0xe9,0xce,0xb2,0x8f, - 0x81,0x8b,0xaf,0xcb,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xcc,0xb1, - 0x8d,0x81,0x88,0xac,0xc8,0xe3,0xff,0x1a,0x18,0xfb,0xe1,0xc5,0xaa,0x8f,0x81,0x81, - 0x81,0x81,0x81,0xa0,0xc8,0xee,0x0d,0x13,0xf9,0xd4,0xad,0x84,0x81,0x81,0x81,0x81, - 0x94,0xbd,0xe7,0x13,0x0b,0xdf,0x05,0x21,0xfc,0x0b,0xff,0x19,0xfa,0x0f,0x0d,0xe7, - 0xc0,0x99,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x3e,0x1b,0xef,0xc5,0x9b,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8d, - 0xb8,0xe2,0x0b,0x13,0xe9,0xc4,0xed,0x19,0x07,0xdd,0xb2,0x88,0x81,0x81,0x81,0x81, - 0x95,0xc0,0xea,0x16,0x1d,0x18,0x16,0x2a,0x16,0x1c,0x25,0x12,0xf7,0xd9,0xb5,0x8f, - 0x81,0x85,0xa9,0xcd,0xf0,0x13,0x0f,0xec,0xc8,0xd2,0xf9,0x1d,0x0b,0xfc,0x0f,0x17, - 0xf1,0xcc,0xa4,0x81,0x82,0xa9,0xcf,0xf3,0x14,0x29,0x14,0x09,0x09,0x14,0x24,0x0c, - 0x1a,0x1d,0xfc,0xdb,0xbb,0x99,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0xa1,0xc8,0xf1,0x18,0x17,0xef,0xc9,0xa4,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x8b,0xaf,0xd5,0xfc,0x24,0x07,0xe0,0xb9,0x90,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa5, - 0xd0,0xfa,0x1e,0x06,0xda,0xb0,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x93,0xbc, - 0xe5,0x0a,0x2b,0x30,0x06,0xda,0xb0,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x13,0x39,0x35,0x0e,0xe5,0xba,0x90,0x81, - 0x85,0xac,0xd3,0xfa,0x21,0x05,0xde,0xb6,0x8f,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x8c,0xb2,0xd6,0xf7,0x17,0x22,0x0f,0x09,0x0e,0x20,0x16,0xf7,0xd5,0xb2,0x8d, - 0x81,0x81,0x81,0xab,0xd5,0xff,0x16,0x16,0x16,0x16,0x33,0x18,0x16,0x16,0x16,0xef, - 0xc5,0x9b,0x81,0x95,0xc0,0xea,0x16,0x39,0x1a,0x19,0x19,0x19,0x19,0x19,0x19,0x19, - 0xed,0xc2,0x98,0x81,0x95,0xc0,0xea,0x11,0x0b,0x09,0x09,0x0b,0x14,0x24,0x11,0xf5, - 0xd6,0xb4,0x8e,0x81,0x81,0x95,0xa8,0xab,0xab,0xab,0xab,0xab,0xb0,0xda,0x06,0x29, - 0xfc,0xd2,0xab,0xa8,0x96,0x81,0x81,0x95,0xc0,0xea,0x11,0x0b,0x09,0x09,0x0e,0x1a, - 0x1d,0x05,0xe8,0xc8,0xa6,0x81,0x81,0x81,0x97,0xbc,0xe1,0x04,0x21,0x18,0x09,0x06, - 0x0c,0x1e,0x14,0xf6,0xd5,0xb2,0x8c,0x81,0x81,0x81,0x97,0xbc,0xe2,0x09,0x2a,0x04, - 0xde,0xb8,0x92,0x81,0x81,0x81,0x81,0x81,0x81,0x86,0xad,0xd3,0xf7,0x16,0x27,0x14, - 0x0b,0x09,0x0e,0x1e,0x1a,0xfc,0xdc,0xb8,0x92,0x81,0x81,0x98,0xc2,0xed,0x11,0x11, - 0x13,0x18,0x23,0x18,0x04,0xea,0xcc,0xac,0x8a,0x81,0x81,0x95,0xc0,0xea,0x14,0x3c, - 0x2e,0x06,0xda,0xb0,0x85,0x81,0x81,0x93,0xbc,0xe5,0x0a,0x2b,0x30,0x06,0xda,0xb1, - 0x87,0x81,0x81,0x81,0x81,0x85,0x9f,0xbb,0xd5,0xf1,0x0d,0x25,0x0b,0xee,0xc6,0x9d, - 0x81,0x81,0x91,0xa2,0xa5,0xa5,0xa5,0xa5,0xa5,0xa5,0xa5,0xa5,0xa5,0xa5,0xa3,0x92, - 0x81,0x81,0x95,0xbf,0xe7,0x05,0x1f,0x12,0xf6,0xdb,0xc0,0xa5,0x8a,0x81,0x81,0x81, - 0x81,0x81,0x81,0xa5,0xd0,0xfa,0x26,0x32,0x09,0xdd,0xb2,0x88,0x81,0x81,0x81,0x81, - 0x90,0xba,0xe5,0x0e,0x0f,0xe5,0xf3,0x11,0x1b,0x0b,0xf1,0x12,0x1b,0x0f,0xf3,0xd3, - 0xae,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x92,0xba,0xe1,0x05,0x19,0x09,0xe6,0xbf,0x97,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x92, - 0xbb,0xe5,0x11,0x0f,0xe5,0xc8,0xf2,0x11,0x04,0xd7,0xaf,0x85,0x81,0x81,0x81,0x81, - 0x95,0xbf,0xe8,0xfc,0x06,0x0b,0x11,0x1c,0x0e,0x09,0xfc,0xed,0xd7,0xbb,0x9d,0x81, - 0x81,0x92,0xbb,0xe3,0x07,0x11,0xf7,0xd4,0xb1,0xc0,0xe3,0xff,0x13,0x19,0x0f,0xf9, - 0xdb,0xb9,0x93,0x81,0x81,0x95,0xb7,0xd7,0xf1,0x07,0x13,0x19,0x16,0x0e,0xff,0xe9, - 0xff,0x11,0x11,0xf5,0xd2,0xa9,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x93,0xb9,0xe0,0x06,0x28,0x04,0xdd,0xb8,0x95,0x81,0x81,0x81,0x81,0x81,0x81, - 0xa0,0xc4,0xe8,0x0f,0x1d,0xf6,0xd0,0xa9,0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa4, - 0xcd,0xf1,0xf2,0xf2,0xd7,0xaf,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x86,0xac, - 0xce,0xf1,0x17,0x2f,0x06,0xda,0xb0,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x8e,0xb5,0xdb,0xfc,0x15,0x13,0xf9,0xd6,0xb1,0x89,0x81, - 0x95,0xbc,0xe3,0x0a,0x1b,0xf4,0xcd,0xa6,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x9b,0xbd,0xdb,0xf5,0x09,0x14,0x19,0x14,0x09,0xf3,0xd9,0xbb,0x9b,0x81, - 0x81,0x81,0x81,0xab,0xd5,0xff,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0xef, - 0xc5,0x9b,0x81,0x95,0xc0,0xea,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11, - 0xed,0xc2,0x98,0x81,0x95,0xc0,0xea,0x11,0x16,0x19,0x19,0x14,0x0c,0xff,0xed,0xd5, - 0xb9,0x9b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x13, - 0xfc,0xd2,0xa8,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x13,0x16,0x19,0x19,0x12,0x07, - 0xf7,0xe3,0xca,0xac,0x8d,0x81,0x81,0x81,0x83,0xa7,0xc7,0xe4,0xfc,0x0e,0x16,0x19, - 0x12,0x05,0xf1,0xd8,0xbb,0x9a,0x81,0x81,0x81,0x81,0xa4,0xce,0xf5,0x11,0x11,0xf1, - 0xcc,0xa5,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x99,0xbb,0xd9,0xf3,0x06,0x12, - 0x18,0x19,0x13,0x09,0xf6,0xdf,0xc3,0xa1,0x81,0x81,0x81,0x98,0xc2,0xed,0x11,0x11, - 0x0e,0x09,0xff,0xf1,0xdf,0xc8,0xae,0x90,0x81,0x81,0x81,0x8f,0xb8,0xde,0xff,0x16, - 0x10,0xf3,0xcf,0xa9,0x81,0x81,0x81,0x86,0xac,0xcf,0xf1,0x16,0x2f,0x06,0xda,0xb0, - 0x86,0x81,0x81,0x81,0x81,0x81,0x81,0x9b,0xb6,0xd0,0xec,0x07,0xff,0xe1,0xc0,0x99, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x91,0xb9,0xdb,0xf9,0x0d,0xf1,0xd5,0xbb,0x9f,0x85,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0xa1,0xc9,0xf0,0x0f,0x15,0xfb,0xd6,0xae,0x85,0x81,0x81,0x81,0x81, - 0x8b,0xb5,0xde,0x09,0x17,0xed,0xd5,0xeb,0xef,0xe6,0xd7,0xeb,0xef,0xe8,0xd4,0xb8, - 0x97,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x82,0xa8,0xc8,0xe2,0xed,0xe5,0xcc,0xac,0x87,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8f, - 0xb8,0xdb,0xe5,0xe5,0xd7,0xc1,0xe1,0xe5,0xe5,0xcd,0xa8,0x81,0x81,0x81,0x81,0x81, - 0x8a,0xae,0xc9,0xd4,0xdc,0xe2,0x0b,0x13,0xe9,0xde,0xd5,0xc7,0xb4,0x9c,0x81,0x81, - 0x81,0x8f,0xb8,0xdb,0xe5,0xe5,0xde,0xbd,0x99,0xa7,0xc5,0xdb,0xea,0xed,0xe7,0xd6, - 0xbd,0x9f,0x81,0x81,0x81,0x81,0x9b,0xb7,0xce,0xdf,0xea,0xed,0xec,0xe4,0xd8,0xc5, - 0xe2,0xe5,0xe5,0xe5,0xcd,0xa6,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0xa8,0xcd,0xf3,0x18,0x17,0xf3,0xd0,0xae,0x8c,0x81,0x81,0x81,0x81,0x97, - 0xb9,0xdb,0xff,0x22,0x09,0xe3,0xbe,0x98,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95, - 0xb5,0xc7,0xc8,0xc8,0xbc,0x9e,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9b,0xaf,0xb5, - 0xc3,0xe7,0x13,0x24,0xfb,0xd3,0xaa,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0xa1,0xc1,0xdc,0xec,0xeb,0xda,0xbd,0x9d,0x81,0x81, - 0xa6,0xcd,0xf3,0x1a,0x0b,0xe3,0xbc,0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x9f,0xba,0xd1,0xe1,0xea,0xed,0xea,0xe0,0xcf,0xb9,0x9d,0x81,0x81, - 0x81,0x81,0x81,0xa6,0xcd,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe0, - 0xbf,0x97,0x81,0x92,0xba,0xdd,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5, - 0xde,0xbc,0x94,0x81,0x92,0xba,0xdd,0xe7,0xea,0xed,0xed,0xea,0xe3,0xd7,0xc7,0xb3, - 0x9b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x83,0xac,0xd3,0xe7,0xe7, - 0xe7,0xcc,0xa4,0x81,0x81,0x81,0x81,0x92,0xba,0xdd,0xe7,0xed,0xed,0xed,0xe8,0xdf, - 0xd2,0xbf,0xa8,0x8e,0x81,0x81,0x81,0x81,0x81,0x8b,0xa9,0xc3,0xd8,0xe5,0xec,0xed, - 0xe8,0xde,0xcd,0xb7,0x9d,0x81,0x81,0x81,0x81,0x81,0xa1,0xc8,0xe4,0xe5,0xe5,0xdb, - 0xb9,0x93,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9d,0xb9,0xce,0xde,0xe7, - 0xed,0xed,0xe9,0xe0,0xd1,0xbd,0xa4,0x87,0x81,0x81,0x81,0x94,0xbc,0xde,0xe5,0xe5, - 0xe2,0xdf,0xd6,0xca,0xba,0xa5,0x8d,0x81,0x81,0x81,0x81,0x81,0xa4,0xc5,0xdf,0xed, - 0xe9,0xd5,0xb8,0x96,0x81,0x81,0x9b,0xaf,0xb5,0xc3,0xe7,0x11,0x24,0xfc,0xd3,0xaa, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xb0,0xcb,0xe6,0xe1,0xc3,0xa5,0x85, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x9f,0xbd,0xdb,0xeb,0xd0,0xb6,0x9b,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x92,0xb5,0xd4,0xe9,0xed,0xdc,0xbf,0x9d,0x81,0x81,0x81,0x81,0x81, - 0x83,0xac,0xd5,0xfc,0x22,0xfa,0xd3,0xc2,0xc5,0xbf,0xb3,0xc2,0xc5,0xc0,0xaf,0x99, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8c,0xa8,0xbc,0xc2,0xbd,0xac,0x90,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x9f,0xb6,0xba,0xba,0xb4,0xa6,0xb9,0xba,0xba,0xae,0x92,0x81,0x81,0x81,0x81,0x81, - 0x81,0x8f,0xa2,0xab,0xbd,0xe7,0x11,0x0e,0xe2,0xb9,0xac,0x9f,0x8e,0x81,0x81,0x81, - 0x81,0x81,0x9f,0xb6,0xba,0xba,0xb8,0xa3,0x83,0x89,0xa2,0xb5,0xc0,0xc2,0xbf,0xb1, - 0x9c,0x81,0x81,0x81,0x81,0x81,0x81,0x94,0xa8,0xb7,0xc0,0xc2,0xc2,0xbb,0xb0,0xa8, - 0xb9,0xba,0xba,0xba,0xae,0x92,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x94,0xb9,0xdd,0xff,0x23,0x0b,0xe8,0xc8,0xa9,0x89,0x81,0x81,0x94,0xb2, - 0xd3,0xf3,0x16,0x14,0xf1,0xce,0xaa,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x92,0x9d,0x9d,0x9d,0x96,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x90,0xb6,0xd6,0xdf, - 0xe8,0xff,0x20,0x0f,0xeb,0xc5,0x9e,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x85,0xa2,0xb6,0xc2,0xc2,0xb4,0x9f,0x81,0x81,0x8e, - 0xb6,0xdc,0x04,0x21,0xfa,0xd3,0xac,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x97,0xab,0xb9,0xc1,0xc2,0xc0,0xb8,0xaa,0x95,0x81,0x81,0x81, - 0x81,0x81,0x81,0x92,0xae,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xb8, - 0xa5,0x85,0x81,0x81,0xa1,0xb7,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba, - 0xb8,0xa3,0x83,0x81,0x81,0xa1,0xb7,0xbd,0xc1,0xc2,0xc2,0xc0,0xba,0xaf,0xa1,0x8e, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x97,0xb3,0xbd,0xbd, - 0xbd,0xaf,0x91,0x81,0x81,0x81,0x81,0x81,0xa1,0xb7,0xbe,0xc2,0xc2,0xc2,0xbf,0xb6, - 0xa9,0x99,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x89,0x9f,0xb0,0xbc,0xc2,0xc2, - 0xbf,0xb6,0xa7,0x94,0x81,0x81,0x81,0x81,0x81,0x81,0x8d,0xab,0xba,0xba,0xba,0xb6, - 0x9f,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xa8,0xb6,0xbf, - 0xc2,0xc2,0xbf,0xb7,0xaa,0x98,0x82,0x81,0x81,0x81,0x81,0x83,0xa3,0xb8,0xba,0xba, - 0xb9,0xb5,0xad,0xa2,0x93,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x89,0xa4,0xb9,0xc2, - 0xc0,0xb2,0x9a,0x81,0x81,0x90,0xb6,0xd6,0xdf,0xe8,0xff,0x1f,0x0f,0xeb,0xc5,0x9e, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x90,0xaa,0xc0,0xbd,0xa5,0x87,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x9f,0xba,0xc2,0xb0,0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x98,0xb1,0xc0,0xc2,0xb6,0xa1,0x83,0x81,0x81,0x81,0x81,0x81, - 0x81,0xa0,0xc8,0xef,0x17,0x0d,0xe9,0xca,0xb6,0xb4,0xbb,0xc8,0xd9,0xd0,0xae,0x87, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x84,0x93,0x98,0x94,0x86,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x8d,0x90,0x90,0x8c,0x82,0x8f,0x90,0x90,0x88,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x98,0xc2,0xed,0x06,0x06,0xdd,0xb4,0x8a,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x8d,0x90,0x90,0x8e,0x81,0x81,0x81,0x81,0x8d,0x97,0x98,0x95,0x8a, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0x95,0x98,0x98,0x92,0x88,0x84, - 0x8f,0x90,0x90,0x90,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0xa2,0xc5,0xe8,0x09,0x25,0x05,0xe4,0xc5,0xa2,0x81,0x8c,0xb1,0xd0, - 0xee,0x0f,0x1c,0xfb,0xd9,0xb7,0x94,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x09, - 0x11,0x21,0x0f,0xf3,0xd4,0xb2,0x8c,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x90,0x98,0x98,0x8e,0x81,0x81,0x81,0x92, - 0xbd,0xe7,0xfa,0xfa,0xe9,0xc3,0x9c,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x83,0x90,0x97,0x98,0x96,0x8f,0x82,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x88,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x8f, - 0x81,0x81,0x81,0x81,0x81,0x8e,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90, - 0x8e,0x81,0x81,0x81,0x81,0x81,0x8e,0x93,0x97,0x98,0x98,0x95,0x90,0x87,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8c,0x93,0x93, - 0x93,0x89,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0x94,0x98,0x98,0x98,0x95,0x8d, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x88,0x92,0x98,0x98, - 0x95,0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x86,0x90,0x90,0x90,0x8d, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8d,0x95, - 0x98,0x98,0x95,0x8e,0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0x90,0x90, - 0x8f,0x8b,0x84,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x90,0x98, - 0x97,0x8b,0x81,0x81,0x81,0x95,0xc0,0xea,0x09,0x11,0x21,0x0f,0xf3,0xd4,0xb2,0x8c, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x88,0x97,0x95,0x84,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x93,0x98,0x8c,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x8b,0x97,0x98,0x90,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x92,0xb8,0xde,0x04,0x25,0x05,0xed,0xdf,0xdd,0xe4,0xef,0xff,0xe2,0xb8,0x8d, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x91,0xb7,0xd5,0xda,0xda,0xcc,0xaa,0x82,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x8b,0xac,0xce,0xee,0x0d,0x21,0xff,0xd7,0xad,0x83,0x95,0xc0,0xea, - 0x0d,0x1f,0xff,0xe1,0xc0,0x9e,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x11, - 0x0b,0xfc,0xec,0xd4,0xb8,0x99,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x88, - 0xad,0xc9,0xd0,0xd0,0xcb,0xaf,0x8b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x11,0x0b,0xfc,0xec,0xd4,0xb8,0x99,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0xa4,0xc8,0xe8,0x07,0x1f,0x13,0x09,0x09,0x0e,0x18,0x0e,0xe2,0xb8,0x8d, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x9b,0xad,0xb0,0xb0,0xa8,0x90,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x92,0xb2,0xd2,0xf0,0x05,0xe6,0xc8,0xa5,0x81,0x8f,0xb5,0xd5, - 0xf3,0xff,0xe3,0xc5,0xa5,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x92,0xba,0xdd,0xe5, - 0xe0,0xd6,0xc6,0xb2,0x99,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x8f,0xa2,0xa5,0xa5,0xa2,0x91,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x92,0xba,0xdd,0xe5,0xe0,0xd6,0xc6,0xb2,0x99,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x8d,0xac,0xca,0xe5,0xf7,0x06,0x0b,0x0b,0x05,0xfa,0xec,0xd7,0xb3,0x8a, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x84,0x85,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x96,0xb4,0xd2,0xdf,0xc8,0xaa,0x8c,0x81,0x81,0x9a,0xb8, - 0xd5,0xe0,0xc5,0xa7,0x89,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa1,0xb7,0xba, - 0xb7,0xae,0xa0,0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0xa1,0xb7,0xba,0xb7,0xae,0xa0,0x8d,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x8e,0xaa,0xc0,0xd1,0xdc,0xdf,0xdf,0xda,0xd2,0xc5,0xb5,0x9b,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x96,0xad,0xb5,0xa8,0x8c,0x81,0x81,0x81,0x81,0x9a, - 0xb2,0xb7,0xa6,0x89,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0x90, - 0x8d,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0x90,0x8d,0x85,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x86,0x9a,0xa9,0xb2,0xb5,0xb5,0xb1,0xa9,0x9d,0x8e,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0x8b,0x82,0x81,0x81,0x81,0x81,0x81,0x81, - 0x89,0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x88,0x8b,0x8b,0x87,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x88,0x98,0x9b,0x9b,0x9b,0x9b,0x9b,0x9b,0x96,0x83,0x81, - 0x81,0x81,0x89,0x8b,0x8b,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x88,0x98,0x9b,0x9b,0x9b,0x9b,0x9b,0x9b,0x96,0x83,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x83,0x85,0x85, - 0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x84,0x88, - 0x88,0x86,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x83,0x88,0x88,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x85,0x85,0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x86,0x88,0x88,0x85,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x86,0xa8,0xc1,0xc5,0xc5,0xc5,0xc5,0xc5,0xc5,0xbe,0xa2,0x81, - 0x81,0x9d,0xb2,0xb5,0xb5,0xb1,0x9b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x86,0xa8,0xc1,0xc5,0xc5,0xc5,0xc5,0xc5,0xc5,0xbe,0xa2,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x92,0xa6,0xab,0xab,0xab,0xa8,0x95,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x93,0xa5,0xa8,0xa8,0xa8,0xa8,0xa8,0xa7,0xa2,0x99,0x8b, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x87,0x99,0xa5,0xad,0xb0,0xb0, - 0xad,0xa5,0x9a,0x8c,0x81,0x81,0x81,0x93,0xa5,0xa8,0xa8,0xa8,0xa8,0xa8,0xa5,0x9f, - 0x95,0x87,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x93,0xa5,0xa8,0xa8,0xa8,0xa8,0xa8, - 0xa8,0xa8,0xa8,0xa8,0xa2,0x8c,0x81,0x81,0x93,0xa5,0xa8,0xa8,0xa8,0xa8,0xa8,0xa8, - 0xa8,0xa8,0xa8,0xa0,0x89,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0x97,0xa4,0xad,0xb2, - 0xb2,0xb0,0xab,0xa1,0x94,0x81,0x81,0x81,0x81,0x93,0xa5,0xa8,0xa8,0xa6,0x94,0x81, - 0x81,0x83,0x9c,0xa8,0xa8,0xa8,0xa0,0x89,0x81,0x81,0x93,0xa5,0xa8,0xa8,0xa8,0xa8, - 0xa8,0xa8,0xa8,0xa8,0xa8,0xa7,0x97,0x81,0x81,0x81,0x8c,0xa2,0xa8,0xa8,0xa8,0xa8, - 0xa8,0xa8,0xa8,0xa8,0xa7,0x97,0x81,0x81,0x81,0x93,0xa5,0xa8,0xa8,0xa6,0x94,0x81, - 0x81,0x9b,0xa8,0xa8,0xa8,0xa6,0x96,0x81,0x81,0x81,0x95,0xa8,0xab,0xab,0xa9,0x98, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x93,0xa5,0xa8,0xa8,0xa8,0xa4,0x8f, - 0x81,0x89,0xa0,0xa8,0xa8,0xa8,0xa7,0x9a,0x81,0x81,0x81,0x93,0xa5,0xa8,0xa8,0xa8, - 0xa1,0x8a,0x81,0x85,0x9e,0xa8,0xa8,0xa8,0x9c,0x83,0x81,0x81,0x81,0x81,0x81,0x81, - 0x93,0xa2,0xad,0xb2,0xb2,0xaf,0xa5,0x95,0x82,0x81,0x81,0x81,0x81,0x81,0x95,0xa8, - 0xab,0xab,0xab,0xab,0xab,0xa8,0xa3,0x99,0x8b,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x91,0x9f,0xaa,0xb0,0xb0,0xac,0xa2,0x94,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x93,0xa5,0xa8,0xa8,0xa8,0xa8,0xa8,0xa5,0x9f,0x93,0x82,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0x9e,0xa9,0xb0,0xb2,0xb2,0xaf,0xa9,0xa1,0x94, - 0x81,0x81,0x81,0x81,0x93,0xa5,0xa8,0xa8,0xa8,0xa8,0xa8,0xa8,0xa8,0xa8,0xa8,0xa8, - 0xa8,0xa7,0x97,0x81,0x81,0x81,0x95,0xa8,0xab,0xab,0xa8,0x96,0x81,0x81,0x85,0x9f, - 0xaa,0xab,0xab,0xa2,0x8b,0x81,0x81,0x93,0xa7,0xab,0xab,0xaa,0x9e,0x83,0x81,0x81, - 0x81,0x81,0x96,0xa8,0xab,0xab,0xa9,0x98,0x81,0x81,0x81,0x93,0xa5,0xa8,0xa8,0xa3, - 0x8e,0x81,0x81,0x81,0x87,0x9f,0xa8,0xa8,0xa6,0x96,0x81,0x81,0x81,0x87,0x9f,0xa8, - 0xa8,0xa8,0xa4,0x91,0x81,0x81,0x81,0x94,0xa6,0xa8,0xa8,0xa7,0x9a,0x81,0x81,0x81, - 0x95,0xa8,0xab,0xab,0xab,0xa1,0x89,0x81,0x81,0x81,0x81,0x99,0xa9,0xab,0xab,0xaa, - 0x9b,0x81,0x81,0x81,0x8e,0xa3,0xa8,0xa8,0xa8,0xa8,0xa8,0xa8,0xa8,0xa8,0xa8,0xa8, - 0xa8,0x9c,0x83,0x81,0x94,0xbd,0xe4,0xef,0xef,0xef,0xef,0xef,0xef,0xde,0xb6,0x8c, - 0x90,0xb8,0xd9,0xdf,0xdf,0xd7,0xb6,0x90,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x94,0xbd,0xe4,0xef,0xef,0xef,0xef,0xef,0xef,0xde,0xb6,0x8c,0x81,0x81,0x81,0x81, - 0x81,0x8c,0xa3,0xab,0xab,0xa8,0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x88,0xae,0xcd,0xd5,0xd5,0xd5,0xcf,0xb2,0x8d,0x81,0x81, - 0x81,0x81,0x81,0x81,0x8c,0xb1,0xcd,0xd2,0xd2,0xd2,0xd2,0xd2,0xd1,0xcc,0xc1,0xb1, - 0x9c,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x96,0xad,0xc0,0xce,0xd7,0xda,0xda, - 0xd6,0xcf,0xc3,0xb2,0x96,0x81,0x8c,0xb1,0xcd,0xd2,0xd2,0xd2,0xd2,0xd2,0xcf,0xc8, - 0xbd,0xad,0x9a,0x82,0x81,0x81,0x81,0x81,0x8c,0xb1,0xcd,0xd2,0xd2,0xd2,0xd2,0xd2, - 0xd2,0xd2,0xd2,0xd2,0xc8,0xa8,0x82,0x8c,0xb1,0xcd,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2, - 0xd2,0xd2,0xd2,0xc4,0xa3,0x81,0x81,0x81,0x81,0x81,0x94,0xab,0xbe,0xcd,0xd7,0xdd, - 0xdd,0xda,0xd4,0xc9,0xba,0xa3,0x82,0x81,0x8c,0xb1,0xcd,0xd2,0xd2,0xce,0xb3,0x8e, - 0x81,0x9c,0xbf,0xd2,0xd2,0xd2,0xc4,0xa3,0x81,0x8c,0xb1,0xcd,0xd2,0xd2,0xd2,0xd2, - 0xd2,0xd2,0xd2,0xd2,0xd2,0xd0,0xb7,0x93,0x81,0x82,0xa8,0xc8,0xd2,0xd2,0xd2,0xd2, - 0xd2,0xd2,0xd2,0xd2,0xd0,0xb7,0x93,0x81,0x8c,0xb1,0xcd,0xd2,0xd2,0xce,0xb3,0x8e, - 0x9c,0xbd,0xd2,0xd2,0xd2,0xcf,0xb5,0x91,0x81,0x8d,0xb2,0xcf,0xd5,0xd5,0xd2,0xb7, - 0x92,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8c,0xb1,0xcd,0xd2,0xd2,0xd2,0xcb,0xac, - 0x87,0xa3,0xc4,0xd2,0xd2,0xd2,0xd1,0xbb,0x98,0x81,0x8c,0xb1,0xcd,0xd2,0xd2,0xd2, - 0xc6,0xa7,0x81,0x9f,0xc1,0xd2,0xd2,0xd2,0xbf,0x9c,0x81,0x81,0x81,0x81,0x88,0xa2, - 0xb9,0xca,0xd6,0xdd,0xdd,0xd7,0xcd,0xbb,0xa6,0x8b,0x81,0x81,0x81,0x8d,0xb2,0xcf, - 0xd5,0xd5,0xd5,0xd5,0xd5,0xd2,0xcc,0xc1,0xb1,0x9c,0x83,0x81,0x81,0x81,0x81,0x81, - 0x81,0x85,0xa0,0xb6,0xc8,0xd4,0xda,0xda,0xd5,0xcb,0xba,0xa4,0x8a,0x81,0x81,0x81, - 0x81,0x8c,0xb1,0xcd,0xd2,0xd2,0xd2,0xd2,0xd2,0xd0,0xc8,0xba,0xa8,0x90,0x81,0x81, - 0x81,0x81,0x81,0x81,0x83,0x9e,0xb4,0xc6,0xd2,0xda,0xdd,0xdd,0xd9,0xd2,0xcb,0xb7, - 0x96,0x81,0x81,0x8c,0xb1,0xcd,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2, - 0xd2,0xd0,0xb7,0x93,0x81,0x8d,0xb2,0xcf,0xd5,0xd5,0xd1,0xb5,0x8f,0x81,0x9e,0xc1, - 0xd5,0xd5,0xd5,0xc6,0xa5,0x81,0x8a,0xb0,0xce,0xd5,0xd5,0xd4,0xbf,0x9c,0x81,0x81, - 0x81,0x91,0xb5,0xd1,0xd5,0xd5,0xd2,0xb7,0x92,0x81,0x8c,0xb1,0xcd,0xd2,0xd2,0xc9, - 0xaa,0x84,0x81,0x81,0xa1,0xc3,0xd2,0xd2,0xcf,0xb5,0x91,0x81,0x81,0xa1,0xc3,0xd2, - 0xd2,0xd2,0xcc,0xaf,0x8b,0x81,0x91,0xb4,0xce,0xd2,0xd2,0xd1,0xbb,0x98,0x81,0x8d, - 0xb2,0xcf,0xd5,0xd5,0xd5,0xc5,0xa2,0x81,0x81,0x81,0x94,0xb9,0xd2,0xd5,0xd5,0xd3, - 0xbb,0x97,0x81,0x84,0xaa,0xc9,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2, - 0xd2,0xbf,0x9c,0x81,0x95,0xc0,0xea,0x16,0x1b,0x1b,0x1b,0x1b,0x0e,0xe2,0xb8,0x8d, - 0x95,0xbf,0xe8,0x0b,0x0b,0xee,0xc8,0xa0,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x95,0xc0,0xea,0x16,0x1b,0x1b,0x1b,0x1b,0x0e,0xe2,0xb8,0x8d,0x81,0x81,0x81,0x81, - 0x83,0xa8,0xc8,0xd5,0xd5,0xcf,0xb3,0x8f,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x96,0xbe,0xe7,0xff,0xff,0xff,0xec,0xc3,0x9b,0x81,0x81, - 0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0xfc,0xfc,0xfc,0xfc,0xfc,0xfa,0xf5,0xe9,0xd6, - 0xbd,0x9f,0x81,0x81,0x81,0x81,0x81,0x81,0x9b,0xb8,0xd1,0xe6,0xf6,0xff,0x06,0x06, - 0xff,0xf7,0xea,0xd1,0xab,0x82,0x95,0xc0,0xea,0xfc,0xfc,0xfc,0xfc,0xfc,0xf9,0xf1, - 0xe5,0xd3,0xbd,0xa3,0x85,0x81,0x81,0x81,0x95,0xc0,0xea,0xfc,0xfc,0xfc,0xfc,0xfc, - 0xfc,0xfc,0xfc,0xfc,0xdf,0xb5,0x8b,0x95,0xc0,0xea,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc, - 0xfc,0xfc,0xfc,0xda,0xb0,0x85,0x81,0x81,0x81,0x98,0xb6,0xcf,0xe3,0xf5,0xff,0x06, - 0x09,0x06,0xfc,0xf1,0xdf,0xbb,0x92,0x81,0x95,0xc0,0xea,0xfc,0xfc,0xec,0xc2,0x98, - 0x81,0xa8,0xd2,0xfb,0xfc,0xfc,0xda,0xb0,0x85,0x95,0xc0,0xea,0xfc,0xfc,0xfc,0xfc, - 0xfc,0xfc,0xfc,0xfc,0xfc,0xf1,0xc7,0x9d,0x81,0x8b,0xb5,0xdf,0xfc,0xfc,0xfc,0xfc, - 0xfc,0xfc,0xfc,0xfc,0xf1,0xc7,0x9d,0x81,0x95,0xc0,0xea,0xfc,0xfc,0xec,0xc2,0x98, - 0xb6,0xd7,0xf9,0xfc,0xfc,0xef,0xc5,0x9b,0x81,0x95,0xc0,0xea,0xff,0xff,0xef,0xc5, - 0x9b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0xfc,0xfc,0xfc,0xe6,0xbd, - 0x96,0xb4,0xdb,0xfc,0xfc,0xfc,0xf6,0xcd,0xa2,0x81,0x95,0xc0,0xea,0xfc,0xfc,0xfc, - 0xe0,0xb9,0x93,0xaa,0xd5,0xfc,0xfc,0xfb,0xd2,0xa8,0x81,0x81,0x81,0x87,0xa7,0xc3, - 0xdd,0xf1,0xff,0x07,0x09,0xff,0xf4,0xe0,0xc7,0xaa,0x8a,0x81,0x81,0x95,0xc0,0xea, - 0xff,0xff,0xff,0xff,0xff,0xfc,0xf5,0xe9,0xd6,0xbe,0xa1,0x81,0x81,0x81,0x81,0x81, - 0x85,0xa3,0xc1,0xdb,0xef,0xfc,0x05,0x06,0xff,0xf2,0xde,0xc5,0xa9,0x88,0x81,0x81, - 0x81,0x95,0xc0,0xea,0xfc,0xfc,0xfc,0xfc,0xfc,0xfa,0xf1,0xe1,0xcc,0xb0,0x91,0x81, - 0x81,0x81,0x81,0x81,0xa1,0xbf,0xd9,0xed,0xfb,0x04,0x09,0x09,0x04,0xfc,0xf3,0xce, - 0xa4,0x81,0x81,0x95,0xc0,0xea,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc, - 0xfc,0xf1,0xc7,0x9d,0x81,0x95,0xc0,0xea,0xff,0xff,0xed,0xc2,0x98,0x81,0xa8,0xd2, - 0xfc,0xff,0xff,0xda,0xb0,0x85,0x93,0xbd,0xe7,0xff,0xff,0xfb,0xd3,0xab,0x83,0x81, - 0x81,0x9e,0xc7,0xef,0xff,0xff,0xef,0xc5,0x9b,0x81,0x95,0xc0,0xea,0xfc,0xfc,0xe2, - 0xb8,0x8d,0x81,0x83,0xad,0xd7,0xfc,0xfc,0xef,0xc5,0x9b,0x81,0x83,0xad,0xd7,0xfc, - 0xfc,0xfc,0xe9,0xc5,0xa1,0x83,0xa7,0xcb,0xef,0xfc,0xfc,0xf6,0xcd,0xa2,0x81,0x95, - 0xc0,0xea,0xff,0xff,0xff,0xdb,0xb6,0x92,0x81,0x82,0xa8,0xcd,0xf3,0xff,0xff,0xf5, - 0xca,0xa0,0x81,0x8d,0xb8,0xe2,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc, - 0xfb,0xd2,0xa8,0x81,0x95,0xc0,0xea,0x16,0x13,0xff,0xff,0xff,0xff,0xe2,0xb8,0x8d, - 0x8a,0xb1,0xd8,0xff,0x26,0xff,0xd8,0xb1,0x8a,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x95,0xc0,0xea,0xff,0xff,0xff,0xff,0x1e,0x0e,0xe2,0xb8,0x8d,0x81,0x81,0x81,0x81, - 0x98,0xbd,0xe1,0xff,0xff,0xee,0xc9,0xa5,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0xa4,0xcc,0xf4,0x1c,0x2b,0x21,0xf9,0xd1,0xa9,0x81,0x81, - 0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x29,0x23,0x23,0x23,0x26,0x1e,0x0f,0xf9, - 0xdb,0xb8,0x92,0x81,0x81,0x81,0x81,0x97,0xb8,0xd7,0xf3,0x0b,0x1e,0x24,0x1e,0x1e, - 0x23,0x20,0x06,0xda,0xb0,0x85,0x95,0xc0,0xea,0x16,0x29,0x23,0x23,0x23,0x23,0x1a, - 0x0c,0xf7,0xde,0xc1,0xa0,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x29,0x23,0x23,0x23, - 0x23,0x23,0x23,0x0b,0xdf,0xb5,0x8b,0x95,0xc0,0xea,0x16,0x29,0x23,0x23,0x23,0x23, - 0x23,0x23,0x06,0xda,0xb0,0x85,0x81,0x81,0x95,0xb6,0xd4,0xf1,0x0a,0x1d,0x27,0x1f, - 0x1e,0x21,0x26,0x16,0xea,0xc0,0x95,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98, - 0x81,0xa8,0xd2,0xfc,0x29,0x06,0xda,0xb0,0x85,0x95,0xc0,0xea,0x16,0x23,0x23,0x23, - 0x29,0x24,0x23,0x23,0x1e,0xf2,0xc8,0x9d,0x81,0x8b,0xb5,0xdf,0x0b,0x26,0x26,0x26, - 0x26,0x26,0x29,0x1e,0xf2,0xc8,0x9d,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0xaf, - 0xd0,0xf1,0x12,0x1d,0xfb,0xdb,0xba,0x94,0x81,0x95,0xc0,0xea,0x16,0x1b,0xef,0xc5, - 0x9b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x29,0x1b,0xf4,0xcc, - 0xa4,0xc2,0xea,0x11,0x29,0x23,0xf7,0xcd,0xa3,0x81,0x95,0xc0,0xea,0x16,0x29,0x18, - 0xf1,0xcc,0xa5,0xab,0xd5,0xff,0x29,0xfc,0xd2,0xa8,0x81,0x81,0x81,0xa0,0xc2,0xe3, - 0xff,0x17,0x25,0x1b,0x1c,0x26,0x1a,0x04,0xe6,0xc5,0xa2,0x81,0x81,0x95,0xc0,0xea, - 0x16,0x29,0x21,0x21,0x21,0x24,0x1f,0x0f,0xf9,0xdd,0xbd,0x9a,0x81,0x81,0x81,0x81, - 0x9e,0xc0,0xdf,0xfc,0x14,0x25,0x1e,0x1e,0x28,0x19,0xff,0xe4,0xc4,0xa1,0x81,0x81, - 0x81,0x95,0xc0,0xea,0x16,0x29,0x23,0x23,0x23,0x23,0x19,0x06,0xec,0xcc,0xa8,0x82, - 0x81,0x81,0x81,0x98,0xbc,0xdd,0xfb,0x13,0x24,0x1e,0x1b,0x1b,0x1f,0x26,0xfa,0xd0, - 0xa5,0x81,0x81,0x95,0xc0,0xea,0x16,0x23,0x23,0x23,0x23,0x29,0x24,0x23,0x23,0x23, - 0x1e,0xf2,0xc8,0x9d,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0x81,0xa8,0xd2, - 0xfc,0x29,0x06,0xda,0xb0,0x85,0x8d,0xb5,0xdd,0x06,0x2b,0x09,0xe1,0xb8,0x90,0x81, - 0x83,0xab,0xd3,0xfb,0x24,0x0d,0xe5,0xbd,0x95,0x81,0x95,0xc0,0xea,0x16,0x0e,0xe2, - 0xb8,0x8d,0x81,0x83,0xad,0xd7,0x04,0x1b,0xef,0xc5,0x9b,0x81,0x81,0xa5,0xc9,0xed, - 0x11,0x23,0xff,0xdb,0xb7,0x99,0xbd,0xe1,0x05,0x29,0x09,0xe5,0xc2,0x9c,0x81,0x8e, - 0xb4,0xd9,0xfc,0x22,0x15,0xf0,0xcb,0xa6,0x81,0x97,0xbb,0xe1,0x07,0x2b,0x07,0xe2, - 0xbd,0x98,0x81,0x8d,0xb8,0xe2,0x0e,0x29,0x29,0x29,0x29,0x29,0x29,0x29,0x29,0x29, - 0xfc,0xd2,0xa8,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xd5,0xd5,0xd5,0xcb,0xac,0x85, - 0x81,0xa1,0xc8,0xee,0x15,0x0f,0xe8,0xc1,0x9a,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x8d,0xb2,0xcf,0xd5,0xd5,0xd5,0xf2,0x1e,0x0e,0xe2,0xb8,0x8d,0x81,0x81,0x81,0x88, - 0xad,0xd2,0xf6,0x1b,0x20,0x04,0xdf,0xbb,0x97,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x89,0xb1,0xd9,0xff,0x27,0xff,0x28,0x06,0xde,0xb6,0x8e,0x81, - 0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xf7,0xf7,0xf7,0xfc,0x0c,0x27,0x16, - 0xf1,0xca,0xa2,0x81,0x81,0x81,0x88,0xae,0xd2,0xf3,0x14,0x25,0x0c,0xfb,0xf2,0xf3, - 0xfa,0x06,0x06,0xda,0xb0,0x85,0x95,0xc0,0xea,0x16,0x19,0xf7,0xf7,0xf7,0xff,0x0b, - 0x20,0x1a,0xfc,0xdb,0xb7,0x92,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xf7,0xf7,0xf7, - 0xf7,0xf7,0xf7,0xf7,0xde,0xb5,0x8a,0x95,0xc0,0xea,0x16,0x1b,0xf7,0xf7,0xf7,0xf7, - 0xf7,0xf7,0xf7,0xd9,0xaf,0x85,0x81,0x87,0xac,0xd0,0xf1,0x10,0x29,0x11,0xff,0xf5, - 0xf2,0xf7,0xff,0x0f,0xea,0xc0,0x95,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98, - 0x81,0xa8,0xd2,0xfc,0x29,0x06,0xda,0xb0,0x85,0x95,0xbf,0xe8,0xf7,0xf7,0xf7,0xff, - 0x2b,0x06,0xf7,0xf7,0xf7,0xef,0xc7,0x9d,0x81,0x8b,0xb5,0xdf,0xfa,0xfa,0xfa,0xfa, - 0xfa,0xfa,0x13,0x1e,0xf2,0xc8,0x9d,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0xca, - 0xea,0x0c,0x22,0xff,0xe1,0xc1,0x9f,0x81,0x81,0x95,0xc0,0xea,0x16,0x1b,0xef,0xc5, - 0x9b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x10,0x20,0x04,0xda, - 0xb3,0xd2,0xf9,0x20,0x0c,0x23,0xf7,0xcd,0xa3,0x81,0x95,0xc0,0xea,0x16,0x28,0x2a, - 0x04,0xde,0xb7,0xab,0xd5,0xff,0x29,0xfc,0xd2,0xa8,0x81,0x81,0x8f,0xb5,0xda,0xfc, - 0x1d,0x18,0xfc,0xf1,0xf2,0xff,0x18,0x21,0xff,0xdc,0xb6,0x91,0x81,0x95,0xc0,0xea, - 0x16,0x19,0xf5,0xf5,0xf5,0xfb,0x0a,0x22,0x1a,0xf7,0xd3,0xad,0x86,0x81,0x81,0x8d, - 0xb3,0xd9,0xfb,0x1c,0x19,0xff,0xf4,0xf5,0xff,0x1a,0x20,0xff,0xdb,0xb5,0x8f,0x81, - 0x81,0x95,0xc0,0xea,0x16,0x19,0xf7,0xf7,0xf7,0xff,0x16,0x28,0x07,0xe1,0xba,0x92, - 0x81,0x81,0x81,0xa9,0xd1,0xf6,0x19,0x1c,0x04,0xf5,0xef,0xf1,0xf5,0xfc,0xfa,0xd0, - 0xa5,0x81,0x81,0x95,0xbf,0xe8,0xf7,0xf7,0xf7,0xf7,0xff,0x2b,0x06,0xf7,0xf7,0xf7, - 0xf7,0xef,0xc7,0x9d,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0x81,0xa8,0xd2, - 0xfc,0x29,0x06,0xda,0xb0,0x85,0x81,0xa8,0xd0,0xf7,0x20,0x15,0xed,0xc5,0x9d,0x81, - 0x90,0xb8,0xe0,0x09,0x28,0xff,0xd7,0xaf,0x87,0x81,0x95,0xc0,0xea,0x16,0x0e,0xe2, - 0xb8,0x8d,0x81,0x83,0xad,0xd7,0x04,0x1b,0xef,0xc5,0x9b,0x81,0x81,0x8f,0xb3,0xd7, - 0xfb,0x1f,0x15,0xf1,0xcd,0xaf,0xd3,0xf7,0x1b,0x16,0xf1,0xce,0xab,0x87,0x81,0x81, - 0x9f,0xc4,0xe8,0x0d,0x2a,0x04,0xdf,0xba,0x94,0xab,0xcf,0xf5,0x1a,0x17,0xf1,0xcd, - 0xa8,0x84,0x81,0x8d,0xb8,0xe2,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0x1e,0x1a, - 0xf6,0xd1,0xa7,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0xab,0xab,0xa5,0x90,0x81, - 0x81,0x90,0xb8,0xde,0x06,0x20,0xf9,0xd2,0xab,0x84,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x95,0xa8,0xab,0xab,0xc8,0xf2,0x1e,0x0e,0xe2,0xb8,0x8d,0x81,0x81,0x81,0x9e, - 0xc2,0xe7,0x0c,0x0f,0x07,0x19,0xf5,0xd1,0xad,0x89,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x95,0xbd,0xe7,0x0f,0x1a,0xf3,0x1b,0x14,0xec,0xc3,0x9a,0x81, - 0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xcd,0xcd,0xd4,0xea,0x0f,0x27, - 0xfc,0xd3,0xaa,0x81,0x81,0x81,0x9b,0xc1,0xe7,0x0c,0x27,0x07,0xe8,0xd3,0xc9,0xca, - 0xd1,0xde,0xef,0xd5,0xad,0x84,0x95,0xc0,0xea,0x16,0x19,0xed,0xcd,0xcf,0xd6,0xe6, - 0xff,0x20,0x15,0xf1,0xcb,0xa4,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xcd,0xcd, - 0xcd,0xcd,0xcd,0xcd,0xc3,0xa5,0x81,0x95,0xc0,0xea,0x16,0x1b,0xef,0xcd,0xcd,0xcd, - 0xcd,0xcd,0xcd,0xc0,0xa1,0x81,0x81,0x9a,0xc0,0xe6,0x0b,0x2b,0x0b,0xee,0xd8,0xcb, - 0xc8,0xcd,0xd9,0xe9,0xe4,0xbd,0x94,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98, - 0x81,0xa8,0xd2,0xfc,0x29,0x06,0xda,0xb0,0x85,0x8a,0xae,0xc8,0xcd,0xcd,0xd5,0xff, - 0x2b,0x06,0xda,0xcd,0xcd,0xcb,0xb4,0x91,0x81,0x81,0xa7,0xc5,0xd0,0xd0,0xd0,0xd0, - 0xd0,0xe7,0x13,0x1e,0xf2,0xc8,0x9d,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc3,0xe3, - 0x05,0x26,0x07,0xe6,0xc6,0xa5,0x85,0x81,0x81,0x95,0xc0,0xea,0x16,0x1b,0xef,0xc5, - 0x9b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x0b,0x14,0x11,0xe8, - 0xc1,0xe0,0x09,0x19,0x04,0x23,0xf7,0xcd,0xa3,0x81,0x95,0xc0,0xea,0x16,0x13,0x12, - 0x15,0xef,0xc9,0xab,0xd5,0xff,0x29,0xfc,0xd2,0xa8,0x81,0x81,0xa0,0xc7,0xee,0x14, - 0x1e,0xfa,0xdb,0xc8,0xc8,0xdd,0xfb,0x20,0x15,0xef,0xc8,0x9f,0x81,0x95,0xc0,0xea, - 0x16,0x19,0xed,0xca,0xcb,0xd2,0xe6,0x06,0x2b,0x0c,0xe4,0xbb,0x92,0x81,0x81,0x9e, - 0xc6,0xec,0x12,0x1f,0xfb,0xdd,0xca,0xcb,0xdf,0xfc,0x21,0x14,0xee,0xc7,0x9f,0x81, - 0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xcd,0xcf,0xdb,0xf7,0x1f,0x17,0xee,0xc5,0x9a, - 0x81,0x81,0x8b,0xb5,0xde,0x07,0x2a,0x04,0xdf,0xcc,0xc5,0xc7,0xcc,0xd4,0xda,0xc2, - 0x9d,0x81,0x81,0x8a,0xae,0xc8,0xcd,0xcd,0xcd,0xd5,0xff,0x2b,0x06,0xda,0xcd,0xcd, - 0xcd,0xcb,0xb4,0x91,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0x81,0xa8,0xd2, - 0xfc,0x29,0x06,0xda,0xb0,0x85,0x81,0x9a,0xc3,0xeb,0x13,0x22,0xfa,0xd2,0xa9,0x81, - 0x9d,0xc5,0xed,0x15,0x19,0xf1,0xc9,0xa2,0x81,0x81,0x95,0xc0,0xea,0x16,0x0e,0xe2, - 0xb8,0x9f,0xa0,0x9f,0xad,0xd7,0x04,0x1b,0xef,0xc5,0x9b,0x81,0x81,0x81,0x9c,0xc0, - 0xe4,0x09,0x2b,0x07,0xe3,0xc5,0xe9,0x0d,0x22,0xff,0xdb,0xb8,0x94,0x81,0x81,0x81, - 0x8b,0xaf,0xd4,0xf9,0x1e,0x18,0xf3,0xce,0xa9,0xbe,0xe3,0x09,0x27,0x04,0xde,0xb9, - 0x94,0x81,0x81,0x84,0xaa,0xc9,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xe8,0x0c,0x25,0x04, - 0xdf,0xbc,0x99,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81, - 0x81,0x81,0xa7,0xce,0xf5,0x1c,0x09,0xe2,0xbb,0x94,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x9d,0xc8,0xf2,0x1e,0x0e,0xe2,0xb8,0x8d,0x81,0x81,0x8e,0xb2, - 0xd7,0xfb,0x1f,0xfa,0xf1,0x17,0x0b,0xe7,0xc2,0x9e,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0xa3,0xcb,0xf3,0x1b,0x0e,0xe6,0x0f,0x20,0xf7,0xd0,0xa8,0x81, - 0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0xa3,0xb3,0xdd,0x09,0x2b, - 0xff,0xd5,0xab,0x81,0x81,0x81,0xa9,0xd2,0xf9,0x20,0x12,0xed,0xca,0xae,0x9f,0xa0, - 0xa8,0xb7,0xc5,0xb8,0x9b,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0xa5,0xad,0xc3, - 0xe6,0x0b,0x2a,0xff,0xd9,0xb1,0x88,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0xa3, - 0xa3,0xa3,0xa3,0xa3,0x9d,0x88,0x81,0x95,0xc0,0xea,0x16,0x1b,0xef,0xc5,0xa3,0xa3, - 0xa3,0xa3,0xa3,0x9b,0x85,0x81,0x81,0xa9,0xd1,0xf7,0x1f,0x15,0xf1,0xce,0xb3,0xa2, - 0x9d,0xa4,0xb2,0xc3,0xc1,0xa8,0x86,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98, - 0x95,0xa8,0xd2,0xfc,0x29,0x06,0xda,0xb0,0x85,0x81,0x8e,0xa0,0xa3,0xab,0xd5,0xff, - 0x2b,0x06,0xda,0xb0,0xa3,0xa1,0x93,0x81,0x81,0x81,0x8a,0x9f,0xa5,0xa5,0xa5,0xa5, - 0xbd,0xe7,0x13,0x1e,0xf2,0xc8,0x9d,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xdd,0xfc, - 0x1f,0x0d,0xec,0xcb,0xaa,0x8a,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x1b,0xef,0xc5, - 0x9b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x0b,0x06,0x1f,0xf6, - 0xcf,0xef,0x17,0x0b,0x04,0x23,0xf7,0xcd,0xa3,0x81,0x95,0xc0,0xea,0x16,0x13,0xff, - 0x28,0xff,0xdb,0xb5,0xd5,0xff,0x29,0xfc,0xd2,0xa8,0x81,0x84,0xad,0xd6,0xfc,0x26, - 0x0c,0xe5,0xc0,0xa0,0xa1,0xc2,0xe7,0x0f,0x25,0xfc,0xd4,0xab,0x82,0x95,0xc0,0xea, - 0x16,0x19,0xed,0xc2,0xa1,0xac,0xcc,0xf5,0x1e,0x16,0xec,0xc2,0x98,0x81,0x83,0xac, - 0xd4,0xfc,0x24,0x0c,0xe5,0xc1,0xa2,0xa4,0xc2,0xe8,0x0f,0x24,0xfc,0xd4,0xab,0x82, - 0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0xa5,0xc2,0xeb,0x16,0x1e,0xf2,0xc8,0x9d, - 0x81,0x81,0x8d,0xb8,0xe2,0x0e,0x26,0xfa,0xd1,0xb0,0x9c,0x9d,0xa2,0xab,0xb0,0xa2, - 0x87,0x81,0x81,0x81,0x8e,0xa0,0xa3,0xa3,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0,0xa3, - 0xa3,0xa1,0x93,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0x81,0xa8,0xd2, - 0xfc,0x29,0x06,0xda,0xb0,0x85,0x81,0x8d,0xb5,0xdd,0x06,0x2e,0x07,0xdf,0xb6,0x8e, - 0xa9,0xd2,0xfa,0x23,0x0c,0xe4,0xbc,0x94,0x81,0x81,0x95,0xc0,0xea,0x16,0x0e,0xe2, - 0xb8,0xc9,0xca,0xc9,0xb4,0xd7,0x04,0x1b,0xef,0xc5,0x9b,0x81,0x81,0x81,0x86,0xaa, - 0xce,0xf1,0x15,0x1d,0xf9,0xdb,0xff,0x23,0x0c,0xe8,0xc5,0xa1,0x81,0x81,0x81,0x81, - 0x81,0x9a,0xbf,0xe3,0x09,0x2d,0x07,0xe2,0xbd,0xd2,0xf7,0x1d,0x12,0xee,0xc8,0xa4, - 0x81,0x81,0x81,0x81,0x8e,0xa3,0xa8,0xa8,0xa8,0xa8,0xba,0xdd,0xff,0x23,0x0f,0xeb, - 0xc8,0xa4,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81, - 0x81,0x81,0x97,0xbe,0xe5,0x0b,0x19,0xf2,0xcc,0xa5,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x9d,0xc8,0xf2,0x1e,0x0e,0xe2,0xb8,0x8d,0x81,0x81,0xa2,0xc7, - 0xec,0x11,0x0b,0xe6,0xdd,0xff,0x21,0xfc,0xd9,0xb4,0x90,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x88,0xb0,0xd8,0xff,0x29,0xff,0xd9,0xff,0x2a,0x06,0xdd,0xb5,0x8d, - 0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0xbf,0xc8,0xe7,0x0e,0x21, - 0xf9,0xd0,0xa7,0x81,0x81,0x8b,0xb4,0xdd,0x06,0x2b,0x04,0xdb,0xb4,0x8f,0x81,0x81, - 0x81,0x92,0x9b,0x93,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0x88,0xac, - 0xd4,0xfc,0x26,0x0e,0xe4,0xba,0x90,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0xbd, - 0xbd,0xbd,0xbd,0xbd,0xaf,0x91,0x81,0x95,0xc0,0xea,0x16,0x1b,0xef,0xc5,0xb2,0xb2, - 0xb2,0xb2,0xb2,0xa3,0x86,0x81,0x8b,0xb4,0xdd,0x06,0x2d,0x05,0xdd,0xb6,0xb1,0xb2, - 0xb2,0xb2,0xb2,0xb2,0xb0,0x9d,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0xc0, - 0xc0,0xc0,0xd2,0xfc,0x29,0x06,0xda,0xb0,0x85,0x81,0x81,0x81,0x81,0xab,0xd5,0xff, - 0x2b,0x06,0xda,0xb0,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x93, - 0xbd,0xe7,0x13,0x1e,0xf2,0xc8,0x9d,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xf7,0x18, - 0x12,0xf1,0xd0,0xb0,0x90,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x1b,0xef,0xc5, - 0x9b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x0b,0xf7,0x20,0x05, - 0xdd,0xfc,0x23,0xfb,0x04,0x23,0xf7,0xcd,0xa3,0x81,0x95,0xc0,0xea,0x16,0x13,0xf1, - 0x18,0x14,0xed,0xc7,0xd5,0xff,0x29,0xfc,0xd2,0xa8,0x81,0x8d,0xb7,0xe0,0x0a,0x29, - 0xff,0xd6,0xae,0x86,0x89,0xb1,0xda,0x04,0x2c,0x06,0xdd,0xb3,0x8a,0x95,0xc0,0xea, - 0x16,0x19,0xed,0xc2,0x98,0x9c,0xc5,0xef,0x1b,0x19,0xed,0xc2,0x98,0x81,0x8c,0xb6, - 0xdf,0x09,0x29,0xff,0xd6,0xae,0x87,0x8a,0xb2,0xda,0x04,0x2d,0x06,0xdd,0xb3,0x8a, - 0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0xb4,0xca,0xef,0x19,0x19,0xef,0xc5,0x9c, - 0x81,0x81,0x8c,0xb5,0xdf,0x09,0x2f,0x0b,0xec,0xd4,0xc2,0xb3,0xa2,0x91,0x85,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0,0x85, - 0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0x81,0xa8,0xd2, - 0xfc,0x29,0x06,0xda,0xb0,0x85,0x81,0x81,0xa8,0xd0,0xf7,0x20,0x14,0xec,0xc3,0x9b, - 0xb6,0xdf,0x07,0x27,0xff,0xd6,0xaf,0x86,0x81,0x81,0x95,0xc0,0xea,0x16,0x0e,0xe2, - 0xc9,0xf0,0xf5,0xf0,0xcb,0xd7,0x04,0x1b,0xef,0xc5,0x9b,0x81,0x81,0x81,0x81,0x94, - 0xb7,0xdb,0xff,0x23,0x0f,0xf1,0x15,0x19,0xf5,0xd2,0xae,0x8b,0x81,0x81,0x81,0x81, - 0x81,0x86,0xab,0xcf,0xf4,0x19,0x1b,0xf6,0xd2,0xe6,0x0b,0x22,0xfc,0xd9,0xb4,0x8f, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8b,0xae,0xd1,0xf4,0x18,0x1a,0xf6,0xd3, - 0xb0,0x8d,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81, - 0x81,0x81,0x86,0xad,0xd4,0xfb,0x22,0x04,0xdc,0xb5,0x8e,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x9d,0xc8,0xf2,0x1e,0x0e,0xe2,0xb8,0x8d,0x81,0x93,0xb8,0xdc, - 0xff,0x1c,0xf6,0xd2,0xc8,0xed,0x12,0x12,0xee,0xca,0xa6,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x95,0xbd,0xe6,0x0e,0x1c,0xf4,0xcd,0xf5,0x1d,0x13,0xeb,0xc2,0x9a, - 0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xe7,0xe7,0xef,0x04,0x22,0x0b, - 0xe8,0xc2,0x9b,0x81,0x81,0x92,0xbb,0xe5,0x0f,0x23,0xf7,0xcf,0xa6,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0x81,0xa1, - 0xca,0xf5,0x1e,0x14,0xea,0xc0,0x95,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xe7,0xe7, - 0xe7,0xe7,0xe7,0xe7,0xcc,0xa4,0x81,0x95,0xc0,0xea,0x16,0x1b,0xef,0xdd,0xdd,0xdd, - 0xdd,0xdd,0xdc,0xc2,0x9c,0x81,0x92,0xbb,0xe5,0x0f,0x23,0xfa,0xd1,0xbb,0xd9,0xdd, - 0xdd,0xdd,0xdd,0xdd,0xd8,0xb9,0x92,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xea,0xea, - 0xea,0xea,0xea,0xfc,0x29,0x06,0xda,0xb0,0x85,0x81,0x81,0x81,0x81,0xab,0xd5,0xff, - 0x2b,0x06,0xda,0xb0,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x93, - 0xbd,0xe7,0x13,0x1e,0xf2,0xc8,0x9d,0x81,0x95,0xc0,0xea,0x16,0x19,0xf0,0x11,0x18, - 0xf7,0xd5,0xb6,0x95,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x1b,0xef,0xc5, - 0x9b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x0b,0xe9,0x11,0x14, - 0xec,0x0d,0x13,0xec,0x04,0x23,0xf7,0xcd,0xa3,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7, - 0x07,0x26,0xff,0xd9,0xd5,0xff,0x29,0xfc,0xd2,0xa8,0x81,0x93,0xbd,0xe7,0x11,0x21, - 0xf7,0xcd,0xa4,0x81,0x81,0xa8,0xd2,0xfc,0x26,0x0d,0xe2,0xb8,0x8d,0x95,0xc0,0xea, - 0x16,0x19,0xed,0xc2,0xa7,0xb2,0xd0,0xf7,0x20,0x11,0xe7,0xbe,0x94,0x81,0x92,0xbc, - 0xe6,0x11,0x21,0xf7,0xcd,0xa4,0x81,0x81,0xa9,0xd2,0xfc,0x26,0x0d,0xe2,0xb8,0x8d, - 0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xda,0xdd,0xeb,0x05,0x27,0x0a,0xe3,0xbc,0x93, - 0x81,0x81,0x82,0xaa,0xd2,0xf6,0x19,0x27,0x0f,0xfa,0xe9,0xda,0xc9,0xb8,0xa3,0x8b, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0,0x85, - 0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0x81,0xa8,0xd2, - 0xfc,0x29,0x06,0xda,0xb0,0x85,0x81,0x81,0x9a,0xc3,0xeb,0x13,0x21,0xf7,0xd0,0xa8, - 0xc3,0xec,0x14,0x19,0xf1,0xc9,0xa1,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x0e,0xe2, - 0xd8,0xff,0x21,0x04,0xdb,0xd7,0x04,0x1b,0xef,0xc5,0x9b,0x81,0x81,0x81,0x81,0x81, - 0xa1,0xc5,0xe8,0x0d,0x25,0x0a,0x26,0x04,0xdf,0xbb,0x97,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x95,0xba,0xdf,0x04,0x29,0x0b,0xe5,0xf9,0x1f,0x0f,0xe9,0xc4,0x9f,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa1,0xc5,0xe8,0x0c,0x25,0x04,0xdf,0xbc, - 0x99,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x9c,0xc4,0xeb,0x12,0x13,0xec,0xc5,0x9e,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x9d,0xc8,0xf2,0x1e,0x0e,0xe2,0xb8,0x8d,0x82,0xa8,0xcd,0xf1, - 0x16,0x09,0xe2,0xbe,0xb3,0xd8,0xfc,0x21,0x04,0xe0,0xbb,0x97,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0xa3,0xcb,0xf3,0x1b,0x0f,0xe7,0xc0,0xe8,0x11,0x1f,0xf7,0xcf,0xa7, - 0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x20,0x13,0x13,0x13,0x19,0x1a,0xff,0xeb, - 0xce,0xae,0x8f,0x81,0x81,0x95,0xc0,0xea,0x14,0x1e,0xf2,0xc9,0x9f,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0x81,0x9d, - 0xc6,0xef,0x1b,0x19,0xed,0xc2,0x98,0x81,0x95,0xc0,0xea,0x16,0x20,0x13,0x13,0x13, - 0x13,0x13,0x13,0xfc,0xd2,0xa8,0x81,0x95,0xc0,0xea,0x16,0x1d,0x09,0x09,0x09,0x09, - 0x09,0x09,0xf7,0xcd,0xa3,0x81,0x95,0xc0,0xea,0x14,0x1e,0xf4,0xca,0xc5,0xef,0x09, - 0x09,0x09,0x09,0x09,0xed,0xc2,0x98,0x81,0x95,0xc0,0xea,0x16,0x21,0x16,0x16,0x16, - 0x16,0x16,0x16,0x16,0x2e,0x06,0xda,0xb0,0x85,0x81,0x81,0x81,0x81,0xab,0xd5,0xff, - 0x2b,0x06,0xda,0xb0,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x93, - 0xbd,0xe7,0x13,0x1e,0xf2,0xc8,0x9d,0x81,0x95,0xc0,0xea,0x16,0x19,0x0b,0x1e,0xfc, - 0xdb,0xbb,0x9b,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x1b,0xef,0xc5, - 0x9b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x0b,0xdf,0xff,0x21, - 0xf9,0x1a,0x04,0xdc,0x04,0x23,0xf7,0xcd,0xa3,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7, - 0xf5,0x1b,0x12,0xec,0xd5,0xff,0x29,0xfc,0xd2,0xa8,0x81,0x95,0xc0,0xea,0x16,0x1e, - 0xf2,0xc8,0x9f,0x81,0x81,0xa4,0xce,0xf7,0x23,0x11,0xe5,0xba,0x90,0x95,0xc0,0xea, - 0x16,0x19,0xed,0xd0,0xd1,0xd9,0xec,0x0b,0x25,0xff,0xda,0xb3,0x8b,0x81,0x95,0xc0, - 0xea,0x14,0x1e,0xf2,0xc8,0x9f,0x81,0x81,0xa5,0xcf,0xf7,0x23,0x11,0xe5,0xba,0x90, - 0x81,0x95,0xc0,0xea,0x16,0x19,0x06,0x06,0x09,0x11,0x24,0x0d,0xf0,0xcf,0xab,0x85, - 0x81,0x81,0x81,0x99,0xbc,0xdd,0xf9,0x12,0x25,0x20,0x11,0xff,0xef,0xdc,0xc6,0xaa, - 0x8c,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0,0x85, - 0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0x81,0xa8,0xd2, - 0xfc,0x29,0x06,0xda,0xb0,0x85,0x81,0x81,0x8d,0xb5,0xdd,0x06,0x2e,0x06,0xdd,0xb4, - 0xd0,0xf7,0x21,0x0b,0xe3,0xbb,0x93,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x0e,0xe2, - 0xe7,0x0f,0x36,0x11,0xea,0xd7,0x04,0x1b,0xef,0xc5,0x9b,0x81,0x81,0x81,0x81,0x81, - 0x8b,0xaf,0xd3,0xf5,0x1a,0x33,0x0f,0xec,0xc8,0xa4,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0xa6,0xcb,0xef,0x14,0x1e,0xf7,0x0c,0x1e,0xf9,0xd4,0xaf,0x8b,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x96,0xb9,0xdc,0xff,0x23,0x0f,0xeb,0xc8,0xa4, - 0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x8c,0xb4,0xda,0xff,0x24,0xfc,0xd5,0xaf,0x88,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x9d,0xc8,0xf2,0x1e,0x0e,0xe2,0xb8,0x8d,0x91,0xba,0xe1,0x06, - 0x16,0xf3,0xce,0xaa,0x9e,0xc2,0xe7,0x0c,0x16,0xf5,0xd1,0xa8,0x81,0x81,0x81,0x81, - 0x81,0x81,0x88,0xb0,0xd8,0xff,0x29,0x04,0xdb,0xb3,0xdc,0x04,0x2c,0x05,0xdc,0xb4, - 0x8c,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x1d,0x0e,0x0e,0x0e,0x12,0x1e,0x1a,0x07, - 0xea,0xcb,0xa6,0x81,0x81,0x95,0xc0,0xea,0x16,0x1e,0xf2,0xc8,0x9d,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0x81,0x9b, - 0xc5,0xef,0x1b,0x19,0xed,0xc2,0x98,0x81,0x95,0xc0,0xea,0x16,0x1d,0x0e,0x0e,0x0e, - 0x0e,0x0e,0x0e,0xfc,0xd2,0xa8,0x81,0x95,0xc0,0xea,0x16,0x25,0x19,0x19,0x19,0x19, - 0x19,0x19,0xf7,0xcd,0xa3,0x81,0x95,0xc0,0xea,0x16,0x1e,0xf2,0xc8,0xc5,0xef,0x16, - 0x16,0x16,0x1f,0x19,0xed,0xc2,0x98,0x81,0x95,0xc0,0xea,0x16,0x1d,0x0e,0x0e,0x0e, - 0x0e,0x0e,0x0e,0x0e,0x2b,0x06,0xda,0xb0,0x85,0x81,0x81,0x81,0x81,0xab,0xd5,0xff, - 0x2b,0x06,0xda,0xb0,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x93, - 0xbd,0xe7,0x13,0x1e,0xf2,0xc8,0x9d,0x81,0x95,0xc0,0xea,0x16,0x19,0x0b,0x25,0x05, - 0xe3,0xc2,0xa0,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x1b,0xef,0xc5, - 0x9b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x0b,0xdf,0xf1,0x19, - 0x0c,0x1b,0xf4,0xd7,0x04,0x23,0xf7,0xcd,0xa3,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7, - 0xe3,0x0a,0x24,0xfc,0xd7,0xff,0x29,0xfc,0xd2,0xa8,0x81,0x95,0xc0,0xea,0x16,0x1e, - 0xf2,0xc8,0x9d,0x81,0x81,0xa3,0xcd,0xf7,0x23,0x11,0xe5,0xba,0x90,0x95,0xc0,0xea, - 0x16,0x19,0xfa,0xfa,0xfa,0xff,0x11,0x26,0x0b,0xea,0xc8,0xa2,0x81,0x81,0x95,0xc0, - 0xea,0x16,0x1e,0xf2,0xc8,0x9d,0x81,0x81,0xa3,0xcd,0xf7,0x23,0x11,0xe5,0xba,0x90, - 0x81,0x95,0xc0,0xea,0x16,0x23,0x19,0x19,0x23,0x14,0xfc,0xea,0xd2,0xb4,0x94,0x81, - 0x81,0x81,0x81,0x81,0xa1,0xbe,0xd8,0xed,0xff,0x0f,0x1f,0x28,0x15,0xff,0xe6,0xc8, - 0xa7,0x84,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0,0x85, - 0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0x81,0xa8,0xd2, - 0xfc,0x29,0x06,0xda,0xb0,0x85,0x81,0x81,0x81,0xa8,0xd0,0xf7,0x21,0x12,0xea,0xc2, - 0xdd,0x06,0x26,0xfc,0xd6,0xae,0x85,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x0e,0xe2, - 0xf5,0x1e,0x0b,0x21,0xfa,0xd7,0x04,0x1b,0xef,0xc5,0x9b,0x81,0x81,0x81,0x81,0x81, - 0x8a,0xae,0xd1,0xf4,0x18,0x35,0x12,0xee,0xcb,0xa7,0x83,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x91,0xb5,0xda,0xff,0x24,0x0b,0x20,0x0a,0xe5,0xc0,0x9b,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x8a,0xad,0xd0,0xf3,0x17,0x1a,0xf6,0xd3,0xb0,0x8d, - 0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0xa3,0xca,0xf1,0x18,0x0d,0xe6,0xbf,0x98,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x9d,0xc8,0xf2,0x1e,0x0e,0xe2,0xb8,0x8d,0x90,0xb9,0xdf,0xea, - 0xea,0xdf,0xba,0x95,0x89,0xad,0xd2,0xea,0xea,0xea,0xcf,0xa8,0x81,0x81,0x81,0x81, - 0x81,0x81,0x95,0xbd,0xe6,0x0e,0x1f,0xf6,0xd0,0xd0,0xd0,0xf7,0x1f,0x12,0xea,0xc2, - 0x99,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xe2,0xe2,0xe8,0xf6,0x10,0x27, - 0x05,0xdf,0xb7,0x8f,0x81,0x95,0xbf,0xe9,0x13,0x21,0xf5,0xcc,0xa2,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0x81,0xa0, - 0xca,0xf3,0x1e,0x14,0xea,0xc0,0x96,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xe2,0xe2, - 0xe2,0xe2,0xe2,0xe2,0xc9,0xa3,0x81,0x95,0xc0,0xea,0x16,0x1b,0xef,0xed,0xed,0xed, - 0xed,0xed,0xeb,0xc9,0xa0,0x81,0x95,0xbf,0xe8,0x13,0x21,0xf5,0xcb,0xc1,0xe4,0xea, - 0xea,0xea,0x16,0x19,0xed,0xc2,0x98,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xe2,0xe2, - 0xe2,0xe2,0xe2,0xfc,0x29,0x06,0xda,0xb0,0x85,0x81,0x81,0x81,0x81,0xab,0xd5,0xff, - 0x2b,0x06,0xda,0xb0,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x93, - 0xbd,0xe7,0x13,0x1e,0xf2,0xc8,0x9d,0x81,0x95,0xc0,0xea,0x16,0x19,0xf1,0x13,0x1e, - 0xfc,0xdb,0xba,0x99,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x1b,0xef,0xc5, - 0x9b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x0b,0xdf,0xe2,0x0a, - 0x31,0x0b,0xe4,0xd7,0x04,0x23,0xf7,0xcd,0xa3,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7, - 0xd1,0xf7,0x1e,0x0f,0xe9,0xff,0x29,0xfc,0xd2,0xa8,0x81,0x95,0xbf,0xe8,0x13,0x21, - 0xf5,0xca,0xa1,0x81,0x81,0xa7,0xd1,0xfa,0x26,0x0e,0xe2,0xb8,0x8e,0x95,0xc0,0xea, - 0x16,0x2d,0x26,0x26,0x25,0x1f,0x14,0x04,0xeb,0xce,0xaf,0x8d,0x81,0x81,0x95,0xc0, - 0xea,0x13,0x21,0xf5,0xca,0xa1,0x81,0x81,0xa7,0xd0,0xfa,0x26,0x0e,0xe2,0xb8,0x8f, - 0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xef,0xfc,0x1a,0x14,0xf1,0xcf,0xaa,0x85,0x81, - 0x81,0x81,0x81,0x81,0x83,0x9d,0xb3,0xc7,0xd8,0xe8,0xf7,0x0a,0x1f,0x23,0x05,0xe2, - 0xbc,0x95,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0,0x85, - 0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0x81,0xa8,0xd2, - 0xfc,0x29,0x06,0xda,0xb0,0x85,0x81,0x81,0x81,0x9b,0xc3,0xec,0x14,0x1f,0xf6,0xce, - 0xea,0x12,0x19,0xf1,0xc8,0xa0,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x0e,0xe2, - 0x05,0x1d,0xf7,0x20,0x09,0xe1,0x04,0x1b,0xef,0xc5,0x9b,0x81,0x81,0x81,0x81,0x81, - 0xa1,0xc5,0xe8,0x0c,0x24,0x0c,0x28,0x05,0xe1,0xbd,0x9a,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0xa1,0xc6,0xeb,0x0f,0x31,0x1a,0xf4,0xd0,0xab,0x86,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0xa1,0xc5,0xe8,0x0b,0x25,0x04,0xdf,0xbc,0x99,0x81, - 0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x93,0xb9,0xe1,0x07,0x1e,0xf6,0xcf,0xa8,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x9d,0xc8,0xf2,0x1e,0x0e,0xe2,0xb8,0x8d,0x81,0xa3,0xbb,0xc0, - 0xc0,0xbb,0xa3,0x81,0x81,0x97,0xb4,0xc0,0xc0,0xc0,0xb2,0x95,0x81,0x81,0x81,0x81, - 0x81,0x81,0xa3,0xcb,0xf3,0x1b,0x13,0xfa,0xfa,0xfa,0xfa,0xfa,0x13,0x1f,0xf6,0xce, - 0xa6,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0xb8,0xc0,0xd4,0xf7,0x1f, - 0x14,0xea,0xc1,0x97,0x81,0x91,0xba,0xe5,0x0e,0x26,0xfc,0xd4,0xab,0x84,0x81,0x81, - 0x81,0x81,0x88,0x82,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0x85,0xab, - 0xd2,0xfb,0x24,0x0e,0xe4,0xba,0x91,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0xb8, - 0xb8,0xb8,0xb8,0xb8,0xaa,0x8e,0x81,0x95,0xc0,0xea,0x16,0x1b,0xef,0xc5,0xc2,0xc2, - 0xc2,0xc2,0xc2,0xb0,0x90,0x81,0x90,0xba,0xe4,0x0e,0x26,0xfc,0xd3,0xaa,0xbd,0xc0, - 0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0xb8, - 0xb8,0xb8,0xd2,0xfc,0x29,0x06,0xda,0xb0,0x85,0x81,0x81,0x81,0x81,0xab,0xd5,0xff, - 0x2b,0x06,0xda,0xb0,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0x8e,0x81,0x81,0x93, - 0xbd,0xe7,0x13,0x1e,0xf2,0xc8,0x9d,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xf9,0x1b, - 0x18,0xf5,0xd5,0xb3,0x92,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x1b,0xef,0xc5, - 0x9b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x0b,0xdf,0xd3,0xfa, - 0x11,0xfc,0xd5,0xd7,0x04,0x23,0xf7,0xcd,0xa3,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7, - 0xbf,0xe6,0x0c,0x21,0xfa,0xff,0x29,0xfc,0xd2,0xa8,0x81,0x91,0xba,0xe5,0x0f,0x24, - 0xfa,0xd1,0xa8,0x81,0x86,0xaf,0xd7,0xff,0x2b,0x09,0xdd,0xb4,0x8a,0x95,0xc0,0xea, - 0x16,0x19,0xfa,0xfa,0xfa,0xf5,0xec,0xdc,0xc8,0xb0,0x92,0x81,0x81,0x81,0x92,0xbb, - 0xe5,0x11,0x24,0xfa,0xd1,0xa8,0x81,0x85,0xae,0xd7,0xff,0x2a,0x09,0xdd,0xb4,0x8a, - 0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc5,0xdf,0x04,0x28,0x09,0xe3,0xbd,0x97,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0xa0,0xb1,0xc1,0xd1,0xe4,0xfc,0x1e,0x1b,0xf4, - 0xcb,0xa1,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0,0x85, - 0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0x81,0xa8,0xd2, - 0xfc,0x29,0x06,0xda,0xb0,0x85,0x81,0x81,0x81,0x8e,0xb6,0xde,0x06,0x2c,0x04,0xdc, - 0xf7,0x1f,0x0b,0xe2,0xbb,0x93,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x0e,0xec, - 0x14,0x11,0xec,0x14,0x19,0xf1,0x04,0x1b,0xef,0xc5,0x9b,0x81,0x81,0x81,0x81,0x95, - 0xb8,0xdc,0xff,0x22,0x0d,0xf3,0x18,0x1b,0xf7,0xd4,0xb1,0x8d,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x8c,0xb1,0xd5,0xfc,0x29,0x09,0xe0,0xbb,0x96,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x95,0xb8,0xdc,0xff,0x22,0x0f,0xeb,0xc8,0xa4,0x81,0x81, - 0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x82,0xa9,0xd0,0xf7,0x1e,0x07,0xe0,0xb9,0x92,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x9d,0xc8,0xf2,0x1e,0x0e,0xe2,0xb8,0x8d,0x81,0x82,0x92,0x95, - 0x95,0x92,0x82,0x81,0x81,0x81,0x8e,0x95,0x95,0x95,0x8d,0x81,0x81,0x81,0x81,0x81, - 0x81,0x88,0xb0,0xd8,0xff,0x29,0x2b,0x26,0x26,0x26,0x26,0x26,0x2b,0x2c,0x04,0xdc, - 0xb4,0x8b,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0x9c,0xc6,0xef,0x1b, - 0x19,0xed,0xc2,0x98,0x81,0x8a,0xb3,0xdc,0x06,0x2e,0x09,0xe2,0xbd,0x9e,0x90,0x90, - 0x98,0xa7,0xb2,0xaa,0x90,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0xa4,0xc0, - 0xe3,0x09,0x2a,0x04,0xda,0xb1,0x88,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98, - 0x90,0x90,0x90,0x90,0x8b,0x81,0x81,0x95,0xc0,0xea,0x16,0x1b,0xef,0xc5,0x9b,0x98, - 0x98,0x98,0x98,0x8c,0x81,0x81,0x89,0xb2,0xdb,0x04,0x2c,0x09,0xe1,0xbc,0x9c,0x95, - 0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98, - 0x8d,0xa8,0xd2,0xfc,0x29,0x06,0xda,0xb0,0x85,0x81,0x81,0x8e,0x90,0xab,0xd5,0xff, - 0x2b,0x06,0xda,0xb0,0x90,0x8f,0x82,0x81,0x81,0x81,0xa1,0xb7,0xb8,0xa5,0x92,0x94, - 0xbe,0xe7,0x13,0x1e,0xf2,0xc8,0x9d,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xe0,0xff, - 0x23,0x10,0xee,0xce,0xac,0x8b,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x1b,0xef,0xc5, - 0x9b,0x90,0x90,0x90,0x90,0x8c,0x81,0x81,0x95,0xc0,0xea,0x16,0x0b,0xdf,0xc4,0xe2, - 0xe5,0xe2,0xc5,0xd7,0x04,0x23,0xf7,0xcd,0xa3,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7, - 0xbd,0xd3,0xfa,0x20,0x0b,0xff,0x29,0xfc,0xd2,0xa8,0x81,0x8b,0xb4,0xdd,0x06,0x2d, - 0x05,0xdc,0xb5,0x91,0x99,0xbc,0xe3,0x0b,0x26,0xfc,0xd5,0xac,0x82,0x95,0xc0,0xea, - 0x16,0x19,0xed,0xd0,0xd0,0xcc,0xc3,0xb6,0xa4,0x8e,0x81,0x81,0x81,0x81,0x8c,0xb5, - 0xdf,0x09,0x2d,0x04,0xdc,0xb4,0x90,0x97,0xbb,0xe2,0x0b,0x26,0xfc,0xd5,0xac,0x83, - 0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0xc9,0xef,0x17,0x1b,0xf5,0xcf,0xaa,0x83, - 0x81,0x81,0x81,0x93,0xa5,0xa6,0x9a,0x92,0x8d,0x9a,0xab,0xc1,0xe5,0x0e,0x26,0xfa, - 0xd0,0xa5,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0,0x85, - 0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x14,0x19,0xef,0xc5,0x9c,0x8a,0xad,0xd6, - 0xff,0x2a,0x04,0xd8,0xaf,0x85,0x81,0x81,0x81,0x81,0xa9,0xd1,0xf9,0x21,0x11,0xe7, - 0x04,0x25,0xfc,0xd5,0xad,0x85,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x0e,0xfa, - 0x22,0x04,0xde,0x06,0x28,0xff,0x04,0x1b,0xef,0xc5,0x9b,0x81,0x81,0x81,0x89,0xac, - 0xd0,0xf3,0x16,0x1c,0xf7,0xde,0xff,0x26,0x0f,0xec,0xc8,0xa4,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0xa8,0xd2,0xfc,0x29,0x09,0xdd,0xb2,0x88,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x89,0xac,0xd0,0xf3,0x17,0x1a,0xf6,0xd3,0xb0,0x98,0x98,0x98, - 0x98,0x90,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x99,0xc0,0xe7,0x0e,0x17,0xf1,0xc9,0xa2,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x9d,0xc8,0xf2,0x1e,0x0e,0xe2,0xb8,0x8d,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x95,0xbd,0xe6,0x0e,0x20,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x21,0x11,0xe9, - 0xc1,0x99,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0xba,0xc1,0xd4,0xf9,0x21, - 0x11,0xe7,0xbf,0x95,0x81,0x81,0xa8,0xd0,0xf7,0x1e,0x1b,0xf7,0xd9,0xc3,0xba,0xba, - 0xc1,0xcd,0xdd,0xcc,0xa8,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0xc0,0xcb,0xdf, - 0xfb,0x1d,0x17,0xf1,0xcc,0xa4,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0xba, - 0xba,0xba,0xba,0xba,0xb3,0x9a,0x81,0x95,0xc0,0xea,0x16,0x1b,0xef,0xc5,0x9b,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa6,0xce,0xf5,0x1b,0x1a,0xf7,0xd7,0xc1,0xb7, - 0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98, - 0x81,0xa8,0xd2,0xfc,0x29,0x06,0xda,0xb0,0x85,0x81,0xa1,0xb7,0xba,0xba,0xd5,0xff, - 0x2b,0x06,0xda,0xba,0xba,0xb9,0xa6,0x87,0x81,0x92,0xba,0xdd,0xdf,0xc9,0xbb,0xb6, - 0xca,0xf1,0x19,0x17,0xed,0xc4,0x9a,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc6,0xe8, - 0x0a,0x2b,0x09,0xe8,0xc6,0xa5,0x84,0x81,0x81,0x95,0xc0,0xea,0x16,0x1b,0xef,0xc5, - 0xba,0xba,0xba,0xba,0xba,0xb4,0x9b,0x81,0x95,0xc0,0xea,0x16,0x0b,0xdf,0xb5,0xb9, - 0xba,0xb9,0xad,0xd7,0x04,0x23,0xf7,0xcd,0xa3,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7, - 0xbd,0xc1,0xe7,0x0f,0x1d,0xff,0x29,0xfc,0xd2,0xa8,0x81,0x81,0xaa,0xd2,0xfa,0x21, - 0x14,0xee,0xcc,0xb8,0xba,0xd4,0xf6,0x1b,0x16,0xef,0xc8,0xa0,0x81,0x95,0xc0,0xea, - 0x16,0x19,0xed,0xc2,0xa5,0xa2,0x9b,0x8f,0x81,0x81,0x81,0x81,0x81,0x81,0x82,0xab, - 0xd4,0xfb,0x24,0x13,0xee,0xcb,0xb6,0xb8,0xd2,0xf5,0x1a,0x17,0xef,0xc8,0xa0,0x81, - 0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0xb8,0xde,0x04,0x2b,0x09,0xe1,0xbb,0x95, - 0x81,0x81,0x8c,0xb1,0xcd,0xcf,0xc3,0xbb,0xb7,0xb5,0xb9,0xc5,0xe7,0x11,0x21,0xf7, - 0xce,0xa4,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0,0x85, - 0x81,0x81,0x81,0x81,0x81,0x91,0xbb,0xe4,0x0e,0x21,0xf7,0xd2,0xb7,0xb3,0xc1,0xe2, - 0x0a,0x23,0xfa,0xd2,0xa8,0x81,0x81,0x81,0x81,0x81,0x9b,0xc3,0xec,0x14,0x1d,0xf5, - 0x11,0x18,0xef,0xc8,0x9f,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x0e,0x09, - 0x1f,0xf6,0xd0,0xf7,0x20,0x11,0x04,0x1b,0xef,0xc5,0x9b,0x81,0x81,0x81,0xa0,0xc3, - 0xe6,0x0a,0x2b,0x06,0xe2,0xc8,0xec,0x10,0x25,0x04,0xde,0xbb,0x97,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0xa8,0xd2,0xfc,0x29,0x09,0xdd,0xb2,0x88,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0xa1,0xc4,0xe7,0x0b,0x25,0x04,0xdf,0xc2,0xc2,0xc2,0xc2,0xc2, - 0xc2,0xb6,0x99,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x88,0xaf,0xd6,0xfc,0x24,0xff,0xda,0xb3,0x8c,0x81,0x81, - 0x81,0x81,0x81,0x81,0x9d,0xc8,0xf2,0x1e,0x0e,0xe2,0xb8,0x8d,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0xa3,0xcb,0xf3,0x1b,0x14,0xeb,0xd5,0xd5,0xd5,0xd5,0xd5,0xec,0x14,0x1e,0xf5, - 0xcd,0xa5,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xe5,0xe5,0xea,0xf6,0x10,0x22, - 0xff,0xda,0xb3,0x8b,0x81,0x81,0x99,0xbf,0xe5,0x09,0x2a,0x16,0xfb,0xeb,0xe3,0xe3, - 0xea,0xf5,0x05,0xda,0xb0,0x85,0x95,0xc0,0xea,0x16,0x19,0xed,0xe7,0xea,0xf2,0x04, - 0x1a,0x1f,0xff,0xdd,0xb9,0x93,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xe5,0xe5, - 0xe5,0xe5,0xe5,0xe5,0xd5,0xb0,0x88,0x95,0xc0,0xea,0x16,0x1b,0xef,0xc5,0x9b,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x97,0xbc,0xe2,0x05,0x27,0x14,0xfa,0xe9,0xe1, - 0xe1,0xea,0x16,0x19,0xed,0xc2,0x98,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98, - 0x81,0xa8,0xd2,0xfc,0x29,0x06,0xda,0xb0,0x85,0x92,0xba,0xdd,0xe5,0xe5,0xe5,0xff, - 0x2b,0x06,0xe5,0xe5,0xe5,0xe1,0xc1,0x99,0x81,0x95,0xc0,0xea,0x04,0xf1,0xe4,0xdf, - 0xea,0x05,0x28,0x0a,0xe2,0xba,0x91,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0xce, - 0xf0,0x12,0x23,0xff,0xe1,0xbf,0x9e,0x81,0x81,0x95,0xc0,0xea,0x16,0x1b,0xef,0xe5, - 0xe5,0xe5,0xe5,0xe5,0xe5,0xd7,0xb3,0x8a,0x95,0xc0,0xea,0x16,0x0b,0xdf,0xb5,0x8f, - 0x90,0x8f,0xad,0xd7,0x04,0x23,0xf7,0xcd,0xa3,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7, - 0xbd,0xaf,0xd5,0xfc,0x22,0x13,0x29,0xfc,0xd2,0xa8,0x81,0x81,0x9c,0xc3,0xe9,0x0f, - 0x29,0x09,0xee,0xe2,0xe2,0xf3,0x10,0x24,0xff,0xdd,0xb8,0x91,0x81,0x95,0xc0,0xea, - 0x16,0x19,0xed,0xc2,0x98,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9e, - 0xc5,0xeb,0x10,0x28,0x07,0xed,0xdf,0xe1,0xf1,0x0f,0x25,0x04,0xde,0xb8,0x92,0x81, - 0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0xa6,0xcc,0xf1,0x19,0x1a,0xf4,0xce,0xa8, - 0x81,0x81,0x95,0xc0,0xea,0xf7,0xed,0xe5,0xe1,0xdf,0xe2,0xec,0xff,0x20,0x12,0xec, - 0xc5,0x9c,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0,0x85, - 0x81,0x81,0x81,0x81,0x81,0x89,0xb1,0xda,0xff,0x27,0x0d,0xf0,0xe1,0xdd,0xe6,0xfb, - 0x1d,0x12,0xec,0xc5,0x9d,0x81,0x81,0x81,0x81,0x81,0x8e,0xb6,0xde,0x06,0x2a,0xff, - 0x1e,0x0b,0xe2,0xba,0x92,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x0e,0x17, - 0x11,0xe9,0xc2,0xea,0x12,0x1f,0x04,0x1b,0xef,0xc5,0x9b,0x81,0x81,0x94,0xb7,0xda, - 0xfc,0x21,0x14,0xf0,0xcc,0xb2,0xd6,0xfa,0x1f,0x19,0xf5,0xd2,0xae,0x8b,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0xa8,0xd2,0xfc,0x29,0x09,0xdd,0xb2,0x88,0x81,0x81,0x81, - 0x81,0x81,0x81,0x90,0xb8,0xdb,0xff,0x22,0x0f,0xed,0xed,0xed,0xed,0xed,0xed,0xed, - 0xed,0xd3,0xab,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x9f,0xc6,0xed,0x14,0x11,0xea,0xc3,0x9c,0x81,0x81, - 0x81,0x81,0x81,0x81,0x9d,0xc8,0xf2,0x1e,0x0e,0xe2,0xb8,0x8d,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x87,0xb0,0xd8,0xff,0x29,0x06,0xde,0xb6,0xab,0xab,0xab,0xb7,0xdf,0x09,0x2b,0x04, - 0xdb,0xb3,0x8b,0x81,0x95,0xc0,0xea,0x16,0x1e,0x11,0x11,0x11,0x13,0x1e,0x1b,0x04, - 0xe6,0xc5,0xa1,0x81,0x81,0x81,0x86,0xab,0xcd,0xee,0x0b,0x22,0x21,0x14,0x0e,0x0e, - 0x13,0x1e,0x06,0xda,0xb0,0x85,0x95,0xc0,0xea,0x16,0x20,0x13,0x13,0x14,0x1c,0x25, - 0x14,0xfc,0xe3,0xc3,0xa2,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x1e,0x11,0x11,0x11, - 0x11,0x11,0x11,0x0b,0xdf,0xb5,0x8b,0x95,0xc0,0xea,0x16,0x1b,0xef,0xc5,0x9b,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x84,0xa8,0xca,0xea,0x09,0x20,0x20,0x12,0x0b, - 0x0b,0x11,0x21,0x19,0xed,0xc2,0x98,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98, - 0x81,0xa8,0xd2,0xfc,0x29,0x06,0xda,0xb0,0x85,0x95,0xc0,0xea,0x11,0x11,0x11,0x11, - 0x2e,0x12,0x11,0x11,0x11,0xf2,0xc8,0x9d,0x81,0x95,0xc0,0xea,0x16,0x18,0x0e,0x0b, - 0x11,0x25,0x14,0xf3,0xd0,0xab,0x84,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0xb5, - 0xd6,0xf7,0x1a,0x1c,0xfb,0xd9,0xb8,0x96,0x81,0x95,0xc0,0xea,0x16,0x20,0x11,0x11, - 0x11,0x11,0x11,0x11,0x0e,0xe2,0xb8,0x8d,0x95,0xc0,0xea,0x16,0x0b,0xdf,0xb5,0x8b, - 0x81,0x83,0xad,0xd7,0x04,0x23,0xf7,0xcd,0xa3,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7, - 0xbd,0x9e,0xc4,0xe9,0x11,0x37,0x29,0xfc,0xd2,0xa8,0x81,0x81,0x8b,0xb0,0xd4,0xf5, - 0x14,0x29,0x15,0x0b,0x0c,0x19,0x22,0x07,0xe8,0xc7,0xa3,0x81,0x81,0x95,0xc0,0xea, - 0x16,0x19,0xed,0xc2,0x98,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8c, - 0xb2,0xd5,0xf7,0x16,0x27,0x13,0x0b,0x0b,0x17,0x24,0x09,0xea,0xc8,0xa5,0x81,0x81, - 0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0xba,0xe0,0x06,0x2d,0x06,0xe0,0xba, - 0x94,0x81,0x95,0xc0,0xea,0x16,0x16,0x0f,0x0b,0x0b,0x0e,0x14,0x24,0x15,0xf9,0xd8, - 0xb4,0x8e,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0,0x85, - 0x81,0x81,0x81,0x81,0x81,0x81,0xa2,0xc8,0xec,0x0d,0x27,0x15,0x0b,0x09,0x0e,0x1e, - 0x17,0xf9,0xd7,0xb3,0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0xa9,0xd1,0xf9,0x21,0x1c, - 0x24,0xfc,0xd4,0xad,0x85,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x24,0x2b, - 0x04,0xdc,0xb4,0xdc,0x04,0x2c,0x21,0x1b,0xef,0xc5,0x9b,0x81,0x86,0xaa,0xcd,0xf1, - 0x14,0x22,0xff,0xda,0xb6,0x9c,0xc0,0xe5,0x09,0x2d,0x0d,0xe8,0xc5,0xa1,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0xa8,0xd2,0xfc,0x29,0x09,0xdd,0xb2,0x88,0x81,0x81,0x81, - 0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x37,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19, - 0x04,0xd7,0xad,0x83,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x8f,0xb5,0xdc,0x04,0x21,0xfa,0xd3,0xad,0x85,0x81, - 0x81,0x81,0x81,0x81,0x9d,0xc8,0xf2,0x1e,0x0e,0xe2,0xb8,0x8d,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x92,0xbc,0xe5,0x0d,0x11,0xfa,0xd1,0xa9,0x81,0x81,0x82,0xaa,0xd2,0xfa,0x11,0x11, - 0xe8,0xbf,0x95,0x81,0x95,0xc0,0xea,0x11,0x11,0x11,0x11,0x11,0x0b,0x04,0xf5,0xe1, - 0xc8,0xaa,0x8a,0x81,0x81,0x81,0x81,0x92,0xb2,0xd0,0xe8,0xfc,0x0b,0x14,0x19,0x16, - 0x11,0x07,0xfa,0xd9,0xaf,0x85,0x95,0xc0,0xea,0x11,0x11,0x11,0x11,0x0e,0x09,0xfc, - 0xee,0xdb,0xc3,0xa7,0x88,0x81,0x81,0x81,0x95,0xc0,0xea,0x11,0x11,0x11,0x11,0x11, - 0x11,0x11,0x11,0x0b,0xdf,0xb5,0x8b,0x95,0xc0,0xea,0x13,0x13,0xef,0xc5,0x9b,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8f,0xae,0xcc,0xe6,0xfb,0x0b,0x13,0x19, - 0x16,0x11,0x09,0xfb,0xe8,0xc1,0x97,0x81,0x95,0xc0,0xea,0x11,0x11,0xed,0xc2,0x98, - 0x81,0xa8,0xd2,0xfc,0x11,0x06,0xda,0xb0,0x85,0x95,0xc0,0xea,0x11,0x11,0x11,0x11, - 0x11,0x11,0x11,0x11,0x11,0xf2,0xc8,0x9d,0x81,0x94,0xbe,0xe6,0xff,0x0d,0x16,0x19, - 0x13,0x07,0xf1,0xd7,0xb8,0x96,0x81,0x81,0x95,0xc0,0xea,0x11,0x11,0xed,0xc2,0x9b, - 0xbd,0xde,0xff,0x11,0x11,0xf3,0xce,0xa4,0x81,0x95,0xc0,0xea,0x11,0x11,0x11,0x11, - 0x11,0x11,0x11,0x11,0x0e,0xe2,0xb8,0x8d,0x95,0xc0,0xea,0x11,0x0b,0xdf,0xb5,0x8b, - 0x81,0x83,0xad,0xd7,0x04,0x11,0xf7,0xcd,0xa3,0x81,0x95,0xc0,0xea,0x11,0x11,0xe7, - 0xbd,0x93,0xb2,0xd8,0xfc,0x11,0x11,0xfc,0xd2,0xa8,0x81,0x81,0x81,0x99,0xb9,0xd7, - 0xf1,0x06,0x13,0x19,0x16,0x0d,0xfc,0xe6,0xca,0xac,0x8c,0x81,0x81,0x95,0xc0,0xea, - 0x11,0x11,0xed,0xc2,0x98,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x9b,0xbb,0xd9,0xf4,0x09,0x16,0x27,0x1b,0x11,0xff,0xe8,0xcc,0xae,0xa0,0x89,0x81, - 0x81,0x95,0xc0,0xea,0x13,0x13,0xed,0xc2,0x98,0xa8,0xce,0xf4,0x13,0x13,0xf3,0xcd, - 0xa4,0x81,0x95,0xc0,0xea,0x07,0x0e,0x13,0x18,0x19,0x16,0x0f,0x04,0xf1,0xd9,0xbd, - 0x9d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x11,0x06,0xda,0xb0,0x85, - 0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0xb1,0xd0,0xed,0x04,0x11,0x16,0x19,0x13,0x07, - 0xf4,0xdb,0xbd,0x9c,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9b,0xc3,0xec,0x11,0x11, - 0x11,0xef,0xc7,0x9f,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x11,0x11,0x11, - 0xf6,0xce,0xa6,0xce,0xf5,0x11,0x11,0x11,0xef,0xc5,0x9b,0x81,0x92,0xbc,0xe5,0x09, - 0x11,0x0d,0xe8,0xc5,0xa0,0x86,0xab,0xce,0xf3,0x11,0x11,0xff,0xdb,0xb2,0x88,0x81, - 0x81,0x81,0x81,0x81,0x81,0xa8,0xd2,0xfc,0x11,0x09,0xdd,0xb2,0x88,0x81,0x81,0x81, - 0x81,0x81,0x81,0x95,0xc0,0xea,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11, - 0x04,0xd7,0xad,0x83,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa5,0xcc,0xf3,0x1a,0x0b,0xe3,0xbd,0x96,0x81, - 0x81,0x81,0x81,0x81,0x9d,0xc8,0xf2,0x1e,0x0e,0xe2,0xb8,0x8d,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x8f,0xb8,0xdb,0xe5,0xe5,0xe2,0xc4,0x9c,0x81,0x81,0x81,0x9d,0xc4,0xe2,0xe5,0xe5, - 0xdd,0xba,0x92,0x81,0x92,0xba,0xdd,0xe5,0xe5,0xe5,0xe5,0xe5,0xe2,0xda,0xcd,0xbc, - 0xa7,0x8c,0x81,0x81,0x81,0x81,0x81,0x81,0x94,0xae,0xc5,0xd6,0xe3,0xea,0xed,0xed, - 0xe7,0xdf,0xd2,0xc0,0xa1,0x81,0x92,0xba,0xdd,0xe5,0xe5,0xe5,0xe5,0xe2,0xde,0xd5, - 0xc8,0xb5,0xa0,0x87,0x81,0x81,0x81,0x81,0x92,0xba,0xdd,0xe5,0xe5,0xe5,0xe5,0xe5, - 0xe5,0xe5,0xe5,0xe5,0xd5,0xb0,0x88,0x92,0xbb,0xdf,0xe7,0xe7,0xe2,0xc0,0x98,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x90,0xab,0xc2,0xd4,0xe1,0xea,0xed, - 0xed,0xe7,0xdf,0xd3,0xc5,0xac,0x8a,0x81,0x92,0xba,0xdd,0xe5,0xe5,0xde,0xbc,0x94, - 0x81,0xa4,0xcb,0xe4,0xe5,0xe5,0xd1,0xab,0x82,0x92,0xba,0xdd,0xe5,0xe5,0xe5,0xe5, - 0xe5,0xe5,0xe5,0xe5,0xe5,0xe1,0xc1,0x99,0x81,0x87,0xaa,0xc6,0xd8,0xe4,0xea,0xed, - 0xea,0xe0,0xce,0xb7,0x9b,0x81,0x81,0x81,0x92,0xba,0xdd,0xe5,0xe5,0xde,0xbc,0x94, - 0xa3,0xc5,0xe2,0xe5,0xe5,0xe4,0xc8,0xa1,0x81,0x92,0xba,0xdd,0xe5,0xe5,0xe5,0xe5, - 0xe5,0xe5,0xe5,0xe5,0xe5,0xd7,0xb3,0x8a,0x92,0xba,0xdd,0xe5,0xe5,0xd5,0xb0,0x88, - 0x81,0x81,0xa9,0xcf,0xe5,0xe5,0xe3,0xc6,0x9f,0x81,0x92,0xba,0xdd,0xe5,0xe5,0xdb, - 0xb8,0x8f,0xa0,0xc6,0xe3,0xe5,0xe5,0xe4,0xcb,0xa4,0x81,0x81,0x81,0x81,0x9b,0xb7, - 0xcd,0xde,0xe9,0xed,0xec,0xe4,0xd6,0xc4,0xac,0x8e,0x81,0x81,0x81,0x92,0xba,0xdd, - 0xe5,0xe5,0xde,0xbc,0x94,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x9d,0xba,0xd0,0xe1,0xef,0x1b,0x0e,0xe7,0xd9,0xc6,0xc1,0xd2,0xc4,0xa4,0x81, - 0x81,0x92,0xbb,0xdf,0xe7,0xe7,0xe0,0xbd,0x95,0x96,0xbc,0xdf,0xe7,0xe7,0xe7,0xc9, - 0xa2,0x81,0x8e,0xb4,0xd2,0xdd,0xe5,0xea,0xed,0xed,0xea,0xe5,0xdb,0xcc,0xb7,0x9e, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa6,0xcd,0xe5,0xe5,0xe5,0xd1,0xab,0x82, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x94,0xb2,0xc9,0xdb,0xe7,0xed,0xed,0xea,0xe0, - 0xcf,0xba,0x9f,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0xb5,0xd9,0xe5,0xe5, - 0xe5,0xdb,0xb9,0x91,0x81,0x81,0x81,0x81,0x81,0x81,0x92,0xba,0xdd,0xe5,0xe5,0xe5, - 0xe0,0xc0,0x99,0xbf,0xe0,0xe5,0xe5,0xe5,0xe0,0xbf,0x97,0x81,0x8f,0xb8,0xdb,0xe5, - 0xe5,0xe5,0xd2,0xaf,0x8b,0x81,0x94,0xb9,0xdb,0xe5,0xe5,0xe5,0xd3,0xae,0x85,0x81, - 0x81,0x81,0x81,0x81,0x81,0xa4,0xcb,0xe4,0xe5,0xe5,0xd3,0xae,0x85,0x81,0x81,0x81, - 0x81,0x81,0x81,0x92,0xba,0xdd,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5, - 0xe5,0xcf,0xa9,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x93,0x8f,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xbc,0xe2,0x0a,0x1b,0xf4,0xcd,0xa6,0x81, - 0x81,0x81,0x90,0x93,0x9d,0xc8,0xf2,0x1e,0x0e,0xe2,0xb8,0x8d,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x9f,0xb6,0xba,0xba,0xb9,0xa8,0x89,0x81,0x81,0x81,0x89,0xa8,0xb9,0xba,0xba, - 0xb7,0xa1,0x81,0x81,0x81,0xa1,0xb7,0xba,0xba,0xba,0xba,0xba,0xb8,0xb1,0xa5,0x97, - 0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8b,0x9f,0xaf,0xba,0xc0,0xc2,0xc2, - 0xbd,0xb6,0xaa,0x9b,0x85,0x81,0x81,0xa1,0xb7,0xba,0xba,0xba,0xba,0xb9,0xb5,0xac, - 0x9f,0x8f,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa1,0xb7,0xba,0xba,0xba,0xba,0xba, - 0xba,0xba,0xba,0xba,0xb3,0x9a,0x81,0x82,0xa3,0xb9,0xbd,0xbd,0xbb,0xa7,0x86,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x88,0x9c,0xad,0xb9,0xc0,0xc2, - 0xc2,0xbe,0xb6,0xab,0x9d,0x8b,0x81,0x81,0x81,0xa1,0xb7,0xba,0xba,0xb8,0xa3,0x83, - 0x81,0x8f,0xac,0xba,0xba,0xba,0xb1,0x96,0x81,0x81,0xa1,0xb7,0xba,0xba,0xba,0xba, - 0xba,0xba,0xba,0xba,0xba,0xb9,0xa6,0x87,0x81,0x81,0x8b,0xa0,0xb0,0xbb,0xc1,0xc2, - 0xc0,0xb8,0xa8,0x94,0x81,0x81,0x81,0x81,0x81,0xa1,0xb7,0xba,0xba,0xb8,0xa3,0x83, - 0x89,0xa8,0xb9,0xba,0xba,0xba,0xab,0x8d,0x81,0x81,0xa1,0xb7,0xba,0xba,0xba,0xba, - 0xba,0xba,0xba,0xba,0xba,0xb4,0x9b,0x81,0x81,0xa1,0xb7,0xba,0xba,0xb3,0x9a,0x81, - 0x81,0x81,0x94,0xaf,0xba,0xba,0xba,0xa9,0x8b,0x81,0x81,0xa1,0xb7,0xba,0xba,0xb6, - 0x9f,0x81,0x8b,0xa9,0xba,0xba,0xba,0xba,0xac,0x8f,0x81,0x81,0x81,0x81,0x81,0x94, - 0xa7,0xb6,0xbf,0xc2,0xc2,0xbb,0xaf,0x9e,0x89,0x81,0x81,0x81,0x81,0x81,0xa1,0xb7, - 0xba,0xba,0xb8,0xa3,0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x96,0xab,0xc1,0xea,0x12,0x1e,0xfb,0xe1,0xda,0xe6,0xfb,0xde,0xbb,0x98, - 0x81,0x82,0xa3,0xb9,0xbd,0xbd,0xba,0xa5,0x84,0x83,0xa3,0xb9,0xbd,0xbd,0xbd,0xad, - 0x8f,0x81,0x81,0x97,0xaa,0xb4,0xba,0xc0,0xc2,0xc2,0xc1,0xbc,0xb3,0xa5,0x93,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x92,0xae,0xba,0xba,0xba,0xb1,0x96,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8f,0xa4,0xb4,0xbd,0xc2,0xc2,0xc0,0xb7, - 0xa9,0x96,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9d,0xb5,0xba,0xba, - 0xba,0xb6,0x9f,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa1,0xb7,0xba,0xba,0xba, - 0xb8,0xa5,0x85,0xa5,0xb8,0xba,0xba,0xba,0xb8,0xa5,0x85,0x81,0x81,0x9f,0xb6,0xba, - 0xba,0xba,0xb1,0x96,0x81,0x81,0x81,0x9f,0xb6,0xba,0xba,0xba,0xb2,0x98,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x8f,0xac,0xba,0xba,0xba,0xb2,0x98,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0xa1,0xb7,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba, - 0xba,0xaf,0x94,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0xbd,0xbd,0xb6,0x9d,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x84,0xac,0xd2,0xf9,0x20,0x05,0xde,0xb6,0x90, - 0x82,0xa3,0xb9,0xbd,0xbd,0xc8,0xf2,0x1e,0x0e,0xe2,0xb8,0x8d,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x8d,0x90,0x90,0x8f,0x84,0x81,0x81,0x81,0x81,0x81,0x84,0x8f,0x90,0x90, - 0x8e,0x81,0x81,0x81,0x81,0x81,0x8e,0x90,0x90,0x90,0x90,0x90,0x8d,0x88,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x86,0x90,0x96,0x98,0x98, - 0x94,0x8d,0x82,0x81,0x81,0x81,0x81,0x81,0x8e,0x90,0x90,0x90,0x90,0x8f,0x8a,0x83, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0x90,0x90,0x90,0x90,0x90, - 0x90,0x90,0x90,0x90,0x8b,0x81,0x81,0x81,0x81,0x90,0x93,0x93,0x91,0x84,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0x8f,0x96,0x98, - 0x98,0x94,0x8d,0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0x90,0x90,0x8e,0x81,0x81, - 0x81,0x81,0x87,0x90,0x90,0x90,0x8a,0x81,0x81,0x81,0x81,0x8e,0x90,0x90,0x90,0x90, - 0x90,0x90,0x90,0x90,0x90,0x8f,0x82,0x81,0x81,0x81,0x81,0x81,0x88,0x91,0x97,0x98, - 0x96,0x8f,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0x90,0x90,0x8e,0x81,0x81, - 0x81,0x84,0x8f,0x90,0x90,0x90,0x86,0x81,0x81,0x81,0x81,0x8e,0x90,0x90,0x90,0x90, - 0x90,0x90,0x90,0x90,0x90,0x8c,0x81,0x81,0x81,0x81,0x8e,0x90,0x90,0x8b,0x81,0x81, - 0x81,0x81,0x81,0x89,0x90,0x90,0x90,0x85,0x81,0x81,0x81,0x81,0x8e,0x90,0x90,0x8d, - 0x81,0x81,0x81,0x85,0x90,0x90,0x90,0x90,0x87,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x8d,0x95,0x98,0x98,0x92,0x87,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8e, - 0x90,0x90,0x8e,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x8c,0xb3,0xd9,0xfc,0x1d,0x1a,0x0a,0x06,0x0d,0x19,0xf5,0xd2,0xa9, - 0x81,0x81,0x81,0x90,0x93,0x93,0x91,0x82,0x81,0x81,0x81,0x90,0x93,0x93,0x92,0x88, - 0x81,0x81,0x81,0x81,0x82,0x8a,0x90,0x95,0x98,0x98,0x97,0x92,0x89,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x88,0x90,0x90,0x90,0x8a,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8b,0x94,0x98,0x98,0x95,0x8e, - 0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8d,0x90,0x90, - 0x90,0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0x90,0x90,0x90, - 0x8f,0x81,0x81,0x81,0x8f,0x90,0x90,0x90,0x8f,0x81,0x81,0x81,0x81,0x81,0x8d,0x90, - 0x90,0x90,0x8a,0x81,0x81,0x81,0x81,0x81,0x8d,0x90,0x90,0x90,0x8b,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x87,0x90,0x90,0x90,0x8b,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x8e,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90, - 0x90,0x89,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xe7,0xe7,0xe7,0xd9,0xb4,0x8b, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9b,0xc2,0xe9,0xfa,0xfa,0xe9,0xbf,0x95, - 0x92,0xbb,0xdf,0xe7,0xe7,0xe7,0xf2,0x1e,0x0e,0xe2,0xb8,0x8d,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0xa0,0xc2,0xe1,0xfc,0x0f,0x19,0x1b,0x14,0x05,0xef,0xcf,0xa8, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x1c,0x13,0x13,0x13,0x0e,0xe2,0xb8,0x8d, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8b,0xaf,0xcb,0xd0,0xd0,0xcb,0xaf,0x8b, - 0x95,0xc0,0xea,0x13,0x13,0x13,0x13,0x24,0x0e,0xe2,0xb8,0x8d,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x87,0xa5,0xc2,0xd8,0xe7,0xef,0xef,0xea,0xde,0xcc,0xb4,0x95, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x09,0x09,0x09,0x09,0x09,0x09,0xe2,0xb8,0x8d, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x91,0xa2,0xa5,0xa5,0xa2,0x91,0x81, - 0x95,0xc0,0xea,0x09,0x09,0x09,0x09,0x09,0x09,0xe2,0xb8,0x8d,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x86,0x9e,0xb1,0xbd,0xc5,0xc5,0xc1,0xb7,0xa6,0x91,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x90,0xb6,0xd6,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xd2,0xaf,0x88, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x90,0xb6,0xd6,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xd2,0xaf,0x88,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x89,0x94,0x9b,0x9b,0x97,0x8e,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x9b,0xaf,0xb2,0xb2,0xb2,0xb2,0xb2,0xb2,0xad,0x96,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x9b,0xaf,0xb2,0xb2,0xb2,0xb2,0xb2,0xb2,0xad,0x96,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x86,0x88,0x88,0x88,0x88,0x88,0x88,0x84,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x86,0x88,0x88,0x88,0x88,0x88,0x88,0x84,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x8b,0xaf,0xcb,0xd0,0xd0,0xc9,0xad,0x88,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x88,0x8b,0x8b,0x8b,0x89,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x89,0x8b,0x8b,0x89,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x89,0x8b,0x8b, - 0x89,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x89,0x8f, - 0x90,0x90,0x8c,0x86,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x86,0x88,0x88,0x86,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x89, - 0x8d,0x8b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x82,0x8d,0x8d,0x85,0x81,0x81,0x81,0x81,0x81,0x86,0x88,0x88,0x86,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0x8b,0x8b,0x8b,0x8b, - 0x8b,0x8b,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x84,0x91, - 0x98,0x9b,0x9b,0x95,0x81,0x81,0x95,0xbf,0xe9,0xfa,0xfa,0xe7,0xbd,0x92,0x81,0x88, - 0x98,0x9b,0x9b,0x96,0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9b,0xb1,0xb5,0xb5,0xb5,0xb2,0x9d,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x9d,0xb2,0xb5,0xb5,0xb2,0x9d,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9f,0xb3,0xb5,0xb5, - 0xb2,0x9d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x93,0xa5,0xb2,0xb8, - 0xba,0xba,0xb6,0xaf,0xa1,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9b,0xaf,0xb2,0xb2,0xaf,0x9b, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0x9f,0xb1, - 0xb8,0xb4,0xa3,0x8a,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x93,0xaa,0xb7,0xb8,0xad,0x97,0x81,0x81,0x81,0x9b,0xaf,0xb2,0xb2,0xb0,0x9d,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x92,0xac,0xb5,0xb5,0xb5,0xb5, - 0xb5,0xb5,0xb1,0x9b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x82,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x96,0xab,0xba, - 0xc2,0xc5,0xc5,0xbb,0x9e,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x86,0xa8, - 0xc1,0xc5,0xc5,0xc0,0xb5,0xa4,0x8e,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0xb5,0xd7,0xdf,0xdf,0xdf,0xd9,0xbb,0x9d,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x90,0xb8,0xd9,0xdf,0xdf,0xd9,0xb8,0x90,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x93,0xba,0xda,0xdf,0xdf, - 0xd9,0xb8,0x90,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9d,0xb8,0xcc,0xdb,0xe2, - 0xe5,0xe4,0xdf,0xd9,0xc0,0x9b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x90,0xb6,0xd6,0xdd,0xdd,0xd6,0xb6, - 0x90,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa1,0xc1,0xd9, - 0xe2,0xdc,0xc6,0xa7,0x84,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x90, - 0xb2,0xce,0xe0,0xe2,0xd3,0xb8,0x96,0x81,0x90,0xb6,0xd6,0xdd,0xdd,0xd8,0xb9,0x92, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa9,0xce,0xdf,0xdf,0xdf,0xdf, - 0xdf,0xdf,0xd7,0xb5,0x8e,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x82,0x95,0xa1,0xab,0xaf,0xa1,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9b,0xb9,0xd1,0xe2, - 0xed,0xef,0xef,0xd9,0xb1,0x87,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x94,0xbd, - 0xe4,0xef,0xef,0xea,0xdc,0xc9,0xae,0x8f,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x92,0xbc,0xe6,0x05,0x0b,0x0b,0xf7,0xd9,0xbb,0x9d, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x95,0xc0,0xea,0x0b,0x0b,0xea,0xc0,0x95,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x98,0xc2,0xed,0x0b,0x0b, - 0xea,0xc0,0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x99,0xbb,0xd9,0xf1,0x04,0x0d, - 0x11,0x0e,0x0a,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x09,0x09,0xea,0xc0, - 0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0xb6,0xdc,0xfc, - 0x0e,0xff,0xe2,0xbd,0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa2, - 0xc9,0xed,0x09,0x0b,0xf3,0xd0,0xa9,0x81,0x95,0xc0,0xea,0x09,0x09,0xed,0xc2,0x98, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x0b,0x0b,0x0b, - 0x0b,0x0b,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0xa0,0xbc,0xca,0xd4,0xd9,0xc0,0x9b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x91,0xb6,0xd7,0xf4,0x0a, - 0x16,0x1b,0x09,0xdd,0xb2,0x88,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x95,0xc0, - 0xea,0x16,0x19,0x13,0x04,0xea,0xcb,0xa8,0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x87,0xac,0xc9,0xe3,0xfc,0x16,0x16,0xf7,0xd9,0xbb, - 0x9d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x95,0xc0,0xea,0x16,0x16,0xea,0xc0,0x95,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x98,0xc2,0xed,0x19,0x16, - 0xea,0xc0,0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x88,0xae,0xd4,0xf7,0x15,0x22,0x13, - 0x0e,0x11,0x15,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x16,0xea,0xc0, - 0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x14, - 0x37,0x1b,0xf2,0xc8,0x9d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xab, - 0xd5,0xff,0x28,0x2e,0x07,0xdd,0xb2,0x88,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x13,0x13,0x13, - 0x22,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x8a,0xb3,0xdb,0xf3,0xfc,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa2,0xc9,0xef,0x13,0x21, - 0x0b,0xff,0xff,0xdd,0xb2,0x88,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x95,0xc0, - 0xea,0xff,0x04,0x12,0x26,0x06,0xe1,0xba,0x93,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0xa8,0xc1,0xdb,0xf3,0x0f,0x16,0xf7,0xd9, - 0xb4,0x8b,0x81,0x81,0x81,0x81,0x88,0x91,0x97,0x9b,0x9b,0x98,0x90,0x84,0x81,0x81, - 0x81,0x81,0x95,0xc0,0xea,0x16,0x16,0xea,0xc0,0x96,0x9b,0x9b,0x94,0x88,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8c,0x95,0x98,0x98,0x95,0x8e,0x84, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x82,0x8e,0x95,0x98,0xc2,0xed,0x19,0x16, - 0xea,0xc0,0x95,0x81,0x81,0x81,0x81,0x81,0x87,0x93,0x9a,0x9b,0x98,0x91,0x84,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xbd,0xe6,0x0d,0x23,0xff,0xea, - 0xe2,0xe5,0xeb,0xed,0xca,0xa1,0x81,0x81,0x81,0x81,0x81,0x81,0x88,0x94,0x9a,0x9b, - 0x98,0x90,0x90,0x90,0x90,0x8f,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x16,0xea,0xc0, - 0x97,0x9b,0x9a,0x93,0x86,0x81,0x81,0x81,0x81,0x81,0x81,0x8c,0x94,0xbd,0xe6,0x0d, - 0x25,0x12,0xed,0xc5,0x9c,0x81,0x81,0x81,0x81,0x81,0x81,0x8a,0x93,0x93,0x93,0xa9, - 0xd2,0xfa,0x1d,0x21,0xff,0xd9,0xb1,0x87,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98, - 0x81,0x8b,0x90,0x90,0x90,0x8e,0x81,0x81,0x81,0x83,0xac,0xd3,0xe7,0xe7,0xe7,0xef, - 0x1b,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0x90,0x90,0x8e,0x99, - 0x9b,0x95,0x86,0x94,0x9b,0x9a,0x90,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0x90,0x90, - 0x8d,0x8d,0x97,0x9b,0x9a,0x93,0x86,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x85,0x91,0x99,0x9b,0x9a,0x94,0x89,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0x90, - 0x90,0x8d,0x8b,0x96,0x9b,0x9b,0x94,0x87,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x82,0x8e,0x95,0x98,0x98,0x92,0x90,0x9a,0x98,0x88,0x81,0x81,0x81,0x8e, - 0x90,0x90,0x8d,0x87,0x94,0x9b,0x9b,0x95,0x89,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x83,0x90,0x98,0x9b,0x9b,0x98,0x95,0x8e,0x83,0x81,0x81,0x81,0x81,0x81,0x8e, - 0x90,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x90,0x90,0x90,0x8a,0x81,0x81,0x81,0x81, - 0x90,0x93,0x93,0x91,0x82,0x81,0x81,0x8c,0x93,0x93,0x93,0x89,0x81,0x81,0x81,0x81, - 0x90,0x93,0x93,0x92,0x88,0x81,0x81,0x81,0x81,0x8c,0x93,0x93,0x93,0x8b,0x81,0x81, - 0x81,0x81,0x8d,0x90,0x90,0x8e,0x81,0x81,0x81,0x81,0x81,0x81,0x8a,0x90,0x90,0x90, - 0x86,0x81,0x81,0x81,0x81,0x8b,0x90,0x90,0x90,0x8d,0x81,0x81,0x81,0x81,0x8e,0x90, - 0x90,0x90,0x87,0x81,0x81,0x81,0x81,0x90,0x93,0x93,0x92,0x88,0x81,0x81,0x81,0x81, - 0x8b,0x93,0x93,0x93,0x8c,0x81,0x81,0x81,0x81,0x8c,0x90,0x90,0x90,0x90,0x90,0x90, - 0x90,0x90,0x90,0x8f,0x81,0x81,0x81,0x81,0x81,0x81,0x83,0xad,0xd6,0xff,0x28,0x06, - 0xe6,0xd7,0xd5,0xc8,0xa7,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x8d,0xb2, - 0xcf,0xd5,0xda,0xf0,0x14,0x19,0xef,0xc7,0x9d,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x86,0x9f,0xb9,0xd3,0xec,0xef,0xef,0xde, - 0xb6,0x8c,0x81,0x81,0x91,0xa4,0xb1,0xba,0xc1,0xc5,0xc5,0xc2,0xb9,0xab,0x96,0x81, - 0x81,0x81,0x95,0xc0,0xea,0x16,0x16,0xea,0xc0,0xbf,0xc5,0xc5,0xbd,0xae,0x99,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x93,0xa6,0xb4,0xbf,0xc2,0xc2,0xbf,0xb8,0xac, - 0x99,0x81,0x81,0x81,0x81,0x81,0x81,0x97,0xa9,0xb7,0xc0,0xc2,0xc2,0xed,0x19,0x16, - 0xea,0xc0,0x95,0x81,0x81,0x81,0x83,0x9b,0xae,0xbc,0xc4,0xc5,0xc2,0xba,0xab,0x97, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9d,0xc7,0xf1,0x1a,0x13,0xeb,0xc5, - 0xb8,0xbb,0xc2,0xc4,0xb2,0x91,0x81,0x81,0x81,0x81,0x85,0x9c,0xaf,0xbd,0xc4,0xc5, - 0xc2,0xba,0xba,0xba,0xba,0xb8,0xa5,0x85,0x81,0x95,0xc0,0xea,0x16,0x16,0xea,0xc0, - 0xc0,0xc5,0xc4,0xbc,0xac,0x96,0x81,0x81,0x81,0x81,0x97,0xb3,0xbd,0xbd,0xd1,0xee, - 0xfa,0xf1,0xd7,0xb5,0x8f,0x81,0x81,0x81,0x81,0x81,0x93,0xb0,0xbd,0xbd,0xbd,0xbd, - 0xc0,0xe1,0xf6,0xf9,0xe6,0xc6,0xa2,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98, - 0x98,0xb2,0xba,0xba,0xba,0xb7,0xa1,0x81,0x81,0x81,0x97,0xb3,0xbd,0xbd,0xc5,0xef, - 0x1b,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x81,0xa1,0xb7,0xba,0xba,0xb4,0xc3, - 0xc5,0xbd,0xaa,0xbb,0xc5,0xc4,0xb6,0xa1,0x83,0x81,0x81,0x81,0xa1,0xb7,0xba,0xba, - 0xb5,0xb4,0xc1,0xc5,0xc4,0xbc,0xac,0x96,0x81,0x81,0x81,0x81,0x81,0x81,0x82,0x99, - 0xad,0xba,0xc2,0xc5,0xc4,0xbd,0xb1,0x9f,0x89,0x81,0x81,0x81,0x81,0xa1,0xb7,0xba, - 0xba,0xb5,0xb3,0xbf,0xc5,0xc5,0xbd,0xad,0x98,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x97,0xaa,0xb8,0xc0,0xc2,0xc2,0xbc,0xb9,0xc3,0xc1,0xa8,0x86,0x81,0xa1,0xb7, - 0xba,0xba,0xb5,0xae,0xbd,0xc5,0xc5,0xbe,0xaf,0x9a,0x81,0x81,0x81,0x81,0x81,0x81, - 0x97,0xaa,0xb9,0xc2,0xc5,0xc5,0xc2,0xbf,0xb8,0xa9,0x8c,0x81,0x81,0x81,0xa1,0xb7, - 0xba,0xba,0xdf,0x0b,0x23,0xf7,0xcd,0xba,0xba,0xba,0xba,0xb1,0x96,0x81,0x82,0xa3, - 0xb9,0xbd,0xbd,0xba,0xa5,0x84,0x97,0xb3,0xbd,0xbd,0xbd,0xaf,0x91,0x81,0x82,0xa3, - 0xb9,0xbd,0xbd,0xbd,0xad,0x8f,0x81,0x81,0x98,0xb3,0xbd,0xbd,0xbd,0xb2,0x95,0x81, - 0x81,0x9f,0xb6,0xba,0xba,0xb8,0xa3,0x83,0x81,0x81,0x81,0x96,0xb1,0xba,0xba,0xba, - 0xab,0x8d,0x81,0x81,0x9a,0xb3,0xba,0xba,0xba,0xb5,0x9d,0x81,0x83,0xa3,0xb8,0xba, - 0xba,0xba,0xac,0x8f,0x81,0x81,0xa1,0xb9,0xbd,0xbd,0xbd,0xad,0x8f,0x81,0x81,0x96, - 0xb2,0xbd,0xbd,0xbd,0xb3,0x97,0x81,0x81,0x9b,0xb4,0xba,0xba,0xba,0xba,0xba,0xba, - 0xba,0xba,0xba,0xb8,0xa5,0x85,0x81,0x81,0x81,0x81,0x88,0xb2,0xdd,0x07,0x21,0xf7, - 0xce,0xad,0xab,0xa3,0x8c,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81,0x95, - 0xa8,0xab,0xb5,0xde,0x09,0x21,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x97,0xb1,0xc4,0xc5,0xc5,0xbe, - 0xa2,0x81,0x81,0x8b,0xaf,0xcb,0xd9,0xe4,0xea,0xef,0xef,0xec,0xe1,0xd1,0xb9,0x9b, - 0x81,0x81,0x95,0xc0,0xea,0x16,0x16,0xea,0xd9,0xe7,0xef,0xef,0xe6,0xd3,0xb9,0x9b, - 0x81,0x81,0x81,0x81,0x81,0x81,0x9d,0xb7,0xcc,0xdc,0xe7,0xed,0xed,0xe9,0xe1,0xd3, - 0xb9,0x94,0x81,0x81,0x81,0x83,0xa1,0xba,0xcf,0xdf,0xea,0xed,0xed,0xed,0x19,0x16, - 0xea,0xc0,0x95,0x81,0x81,0x87,0xa4,0xbe,0xd4,0xe5,0xed,0xef,0xed,0xe2,0xd1,0xba, - 0x9f,0x81,0x81,0x81,0x81,0x81,0x8b,0x9b,0x9d,0xa0,0xca,0xf5,0x21,0x0e,0xe2,0xb8, - 0x9d,0x9d,0x9d,0x9a,0x8e,0x81,0x81,0x81,0x81,0x87,0xa5,0xc0,0xd5,0xe5,0xed,0xef, - 0xeb,0xe5,0xe5,0xe5,0xe5,0xe0,0xbf,0x97,0x81,0x95,0xc0,0xea,0x16,0x16,0xea,0xda, - 0xea,0xef,0xed,0xe4,0xd0,0xb6,0x97,0x81,0x81,0x83,0xac,0xd3,0xe7,0xe7,0xe7,0xe7, - 0xe7,0xe7,0xdd,0xb9,0x90,0x81,0x81,0x81,0x81,0x81,0xa7,0xce,0xe7,0xe7,0xe7,0xe7, - 0xe7,0xe7,0xe7,0xe7,0xe6,0xc7,0x9f,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98, - 0xb6,0xd4,0xe5,0xe5,0xe5,0xdd,0xba,0x92,0x81,0x81,0x81,0x8c,0x93,0x9b,0xc5,0xef, - 0x1b,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x92,0xba,0xdd,0xe5,0xe5,0xd9,0xec, - 0xef,0xe5,0xca,0xe1,0xef,0xed,0xdc,0xbf,0x9d,0x81,0x81,0x92,0xba,0xdd,0xe5,0xe5, - 0xd9,0xdb,0xea,0xef,0xed,0xe4,0xd1,0xb6,0x98,0x81,0x81,0x81,0x81,0x85,0xa3,0xbd, - 0xd3,0xe3,0xed,0xef,0xed,0xe7,0xd8,0xc3,0xaa,0x8c,0x81,0x81,0x92,0xba,0xdd,0xe5, - 0xe5,0xd9,0xda,0xe8,0xef,0xef,0xe6,0xd3,0xb9,0x9b,0x81,0x81,0x81,0x81,0x81,0x83, - 0xa1,0xbb,0xcf,0xe0,0xea,0xed,0xec,0xe6,0xe2,0xec,0xe4,0xbd,0x94,0x92,0xba,0xdd, - 0xe5,0xe5,0xd9,0xd4,0xe6,0xef,0xef,0xe7,0xd5,0xbb,0x9d,0x81,0x81,0x81,0x81,0x9f, - 0xba,0xd1,0xe1,0xeb,0xef,0xef,0xed,0xe7,0xe1,0xc7,0xa0,0x81,0x81,0x92,0xba,0xdd, - 0xe5,0xe5,0xe5,0x0b,0x23,0xf7,0xe5,0xe5,0xe5,0xe5,0xe5,0xd1,0xab,0x82,0x92,0xbb, - 0xdf,0xe7,0xe7,0xe0,0xbd,0x95,0xac,0xd3,0xe7,0xe7,0xe7,0xcc,0xa4,0x81,0x92,0xbb, - 0xdf,0xe7,0xe7,0xe7,0xc9,0xa2,0x81,0x86,0xae,0xd3,0xe7,0xe7,0xe7,0xd0,0xa9,0x81, - 0x8f,0xb8,0xdb,0xe5,0xe5,0xde,0xbc,0x94,0x81,0x81,0x82,0xab,0xd1,0xe5,0xe5,0xe4, - 0xc8,0xa1,0x81,0x88,0xb0,0xd5,0xe5,0xe5,0xe5,0xd9,0xb7,0x94,0x9b,0xbe,0xde,0xe5, - 0xe5,0xe4,0xcb,0xa4,0x81,0x90,0xb9,0xdd,0xe7,0xe7,0xe7,0xcb,0xa4,0x81,0x84,0xac, - 0xd1,0xe7,0xe7,0xe7,0xd3,0xac,0x83,0x8a,0xb3,0xd7,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5, - 0xe5,0xe5,0xe5,0xe0,0xbf,0x97,0x81,0x81,0x81,0x81,0x88,0xb2,0xdd,0x09,0x21,0xf5, - 0xca,0xa0,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81,0x81, - 0x81,0x85,0xb0,0xda,0x06,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8d,0x9a,0x9b,0x9b,0x96, - 0x83,0x81,0x81,0x95,0xbf,0xe9,0xff,0x0d,0x15,0x1a,0x1b,0x15,0x0a,0xf4,0xd7,0xb7, - 0x93,0x81,0x95,0xc0,0xea,0x16,0x16,0xea,0xfc,0x0f,0x19,0x19,0x0d,0xf5,0xd7,0xb5, - 0x91,0x81,0x81,0x81,0x81,0x9c,0xbb,0xd9,0xf1,0x05,0x11,0x19,0x19,0x13,0x0a,0xf2, - 0xc8,0x9d,0x81,0x81,0x81,0xa0,0xbf,0xdd,0xf5,0x07,0x13,0x19,0x16,0x0f,0x1b,0x16, - 0xea,0xc0,0x95,0x81,0x81,0xa1,0xc2,0xdf,0xf9,0x0c,0x18,0x1b,0x16,0x0a,0xf5,0xdb, - 0xbc,0x9a,0x81,0x81,0x81,0x8a,0xac,0xc4,0xc8,0xc8,0xca,0xf5,0x21,0x0e,0xe2,0xc8, - 0xc8,0xc8,0xc8,0xc2,0xa8,0x85,0x81,0x81,0x81,0xa0,0xc2,0xe1,0xfb,0x0d,0x19,0x1b, - 0x14,0x11,0x11,0x11,0x11,0xef,0xc5,0x9b,0x81,0x95,0xc0,0xea,0x16,0x16,0xea,0xff, - 0x12,0x1b,0x19,0x0b,0xf1,0xd3,0xaf,0x8a,0x81,0x85,0xb0,0xda,0x06,0x13,0x13,0x13, - 0x13,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x13,0x13,0x13, - 0x13,0x13,0x13,0x13,0xf7,0xcd,0xa3,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0xb6, - 0xd4,0xf1,0x10,0x11,0x05,0xe6,0xbe,0x94,0x81,0x81,0x81,0x81,0x81,0x9b,0xc5,0xef, - 0x1b,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x11,0x06,0xf7,0x13, - 0x19,0x07,0xe4,0x05,0x19,0x15,0xfb,0xd6,0xb0,0x88,0x81,0x95,0xc0,0xea,0x11,0x11, - 0xe6,0xff,0x13,0x1b,0x19,0x0b,0xf1,0xd3,0xaf,0x8a,0x81,0x81,0x81,0xa1,0xc1,0xdf, - 0xf7,0x0b,0x16,0x1b,0x19,0x0f,0xfc,0xe6,0xc8,0xa8,0x86,0x81,0x95,0xc0,0xea,0x11, - 0x11,0xe6,0xff,0x11,0x19,0x19,0x0c,0xf4,0xd6,0xb5,0x91,0x81,0x81,0x81,0x81,0xa0, - 0xbf,0xdd,0xf5,0x09,0x13,0x19,0x16,0x0f,0x0b,0x15,0xea,0xc0,0x95,0x95,0xc0,0xea, - 0x11,0x11,0xe5,0xf9,0x0d,0x19,0x19,0x0f,0xf7,0xd9,0xb5,0x8f,0x81,0x81,0x99,0xbb, - 0xdb,0xf5,0x09,0x15,0x1b,0x1b,0x19,0x13,0xfa,0xd0,0xa5,0x81,0x81,0x95,0xc0,0xea, - 0x11,0x11,0x11,0x14,0x27,0x11,0x11,0x11,0x11,0x11,0x06,0xda,0xb0,0x85,0x95,0xc0, - 0xea,0x13,0x13,0xed,0xc2,0x98,0xb0,0xda,0x06,0x13,0xfc,0xd2,0xa8,0x81,0x94,0xbd, - 0xe5,0x0d,0x13,0xff,0xd8,0xb1,0x89,0x95,0xbd,0xe4,0x0c,0x13,0xfc,0xd6,0xac,0x82, - 0x92,0xbd,0xe7,0x11,0x11,0xef,0xc5,0x9b,0x93,0x93,0x90,0xb2,0xdd,0x07,0x11,0xfa, - 0xd0,0xa5,0x81,0x8a,0xb4,0xdc,0xff,0x11,0x11,0xf1,0xcf,0xac,0xb2,0xd5,0xf9,0x11, - 0x11,0xf5,0xd1,0xa7,0x81,0x91,0xbb,0xe2,0x0a,0x13,0x04,0xdb,0xb4,0x8c,0x92,0xba, - 0xe1,0x0a,0x13,0xff,0xd8,0xaf,0x85,0x8d,0xb8,0xe2,0x0e,0x11,0x11,0x11,0x11,0x11, - 0x11,0x11,0x11,0xef,0xc5,0x9b,0x81,0x81,0x81,0x81,0x88,0xb2,0xdd,0x09,0x21,0xf5, - 0xca,0xa0,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81,0x81, - 0x81,0x85,0xb0,0xda,0x06,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0x0b,0x06,0x06,0x11,0x27,0x14,0xf1,0xcb, - 0xa4,0x81,0x95,0xc0,0xea,0x16,0x16,0x04,0x20,0x0f,0x06,0x0d,0x25,0x12,0xef,0xcb, - 0xa4,0x81,0x81,0x81,0x91,0xb5,0xd7,0xf7,0x14,0x26,0x13,0x09,0x09,0x0e,0x19,0xf2, - 0xc8,0x9d,0x81,0x81,0x93,0xb8,0xdb,0xfb,0x18,0x1a,0x0b,0x06,0x09,0x11,0x23,0x16, - 0xea,0xc0,0x95,0x81,0x94,0xba,0xdd,0xfc,0x1c,0x14,0x04,0xff,0x09,0x1d,0x18,0xf7, - 0xd5,0xaf,0x8a,0x81,0x81,0x97,0xc1,0xe8,0xf2,0xf2,0xf2,0xf5,0x21,0x0e,0xf2,0xf2, - 0xf2,0xf2,0xf2,0xe3,0xbb,0x92,0x81,0x81,0x8e,0xb4,0xda,0xfc,0x1d,0x14,0xff,0xfa, - 0x05,0x1c,0x23,0x0b,0x0b,0xef,0xc5,0x9b,0x81,0x95,0xc0,0xea,0x16,0x16,0x04,0x20, - 0x0c,0x06,0x0f,0x2b,0x0d,0xe8,0xc1,0x99,0x81,0x85,0xb0,0xda,0x06,0x0b,0x0b,0x0b, - 0x1e,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x0b,0x0b,0x0b, - 0x0b,0x0b,0x10,0x23,0xf7,0xcd,0xa3,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0xd2, - 0xf1,0x10,0x23,0x05,0xe6,0xc8,0xaa,0x87,0x81,0x81,0x81,0x81,0x81,0x9b,0xc5,0xef, - 0x1b,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x06,0x11,0x06, - 0x0d,0x1a,0xfa,0x16,0x04,0x1a,0x0e,0xe6,0xbc,0x92,0x81,0x95,0xc0,0xea,0x16,0x11, - 0x07,0x1f,0x0b,0x06,0x11,0x2b,0x0f,0xe8,0xc2,0x99,0x81,0x81,0x94,0xba,0xdd,0xfc, - 0x1a,0x1b,0x0b,0x06,0x0b,0x1a,0x21,0x05,0xe3,0xc0,0x9a,0x81,0x95,0xc0,0xea,0x16, - 0x11,0x05,0x22,0x0f,0x06,0x0d,0x25,0x12,0xef,0xc9,0xa3,0x81,0x81,0x81,0x93,0xb8, - 0xdb,0xfb,0x18,0x18,0x09,0x04,0x06,0x0f,0x23,0x16,0xea,0xc0,0x95,0x95,0xc0,0xea, - 0x16,0x11,0xfc,0x1a,0x11,0x06,0x0b,0x23,0x13,0xee,0xc8,0xa0,0x81,0x83,0xab,0xd2, - 0xf6,0x17,0x1a,0x0a,0x04,0x04,0x09,0x0e,0xfa,0xd0,0xa5,0x81,0x81,0x95,0xc0,0xea, - 0x0e,0x0e,0x0e,0x12,0x26,0x0e,0x0e,0x0e,0x0e,0x0e,0x06,0xda,0xb0,0x85,0x95,0xc0, - 0xea,0x16,0x19,0xed,0xc2,0x98,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x87,0xaf, - 0xd6,0xfc,0x24,0x0f,0xe7,0xbf,0x98,0xa4,0xcb,0xf3,0x1a,0x15,0xee,0xc7,0x9f,0x81, - 0x8d,0xb7,0xe0,0x0b,0x1e,0xf5,0xca,0xb2,0xbd,0xbd,0xb9,0xb8,0xe2,0x0b,0x1e,0xf3, - 0xca,0xa0,0x81,0x81,0xa3,0xc5,0xe6,0x09,0x2b,0x0a,0xe6,0xc4,0xca,0xed,0x10,0x20, - 0xff,0xdd,0xbb,0x99,0x81,0x84,0xac,0xd3,0xfa,0x22,0x11,0xea,0xc3,0x9b,0xa0,0xc8, - 0xef,0x18,0x18,0xf1,0xc9,0xa2,0x81,0x8d,0xb8,0xe2,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e, - 0x0e,0x29,0x1a,0xef,0xc5,0x9b,0x81,0x81,0x81,0x86,0x88,0xb2,0xdd,0x09,0x21,0xf5, - 0xca,0xa0,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81,0x81, - 0x81,0x85,0xb0,0xda,0x06,0x23,0xf7,0xcd,0xa3,0x88,0x82,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x95,0xc0,0xea,0xf7,0xeb,0xe1,0xda,0xdd,0xec,0x0b,0x2a,0xff,0xd8, - 0xaf,0x85,0x95,0xc0,0xea,0x16,0x21,0x1d,0xff,0xe8,0xda,0xe8,0x09,0x29,0x04,0xda, - 0xb2,0x89,0x81,0x81,0xa3,0xc9,0xef,0x12,0x22,0x04,0xec,0xdf,0xdf,0xe5,0xf2,0xf1, - 0xc7,0x9d,0x81,0x81,0xa5,0xcc,0xf1,0x16,0x16,0xf7,0xe2,0xda,0xdf,0xed,0x19,0x16, - 0xea,0xc0,0x95,0x81,0xa6,0xcd,0xf3,0x18,0x13,0xf1,0xdc,0xd6,0xe2,0xfc,0x1f,0x0f, - 0xe8,0xc0,0x98,0x81,0x81,0x98,0xc2,0xed,0x19,0x1e,0x1e,0x1e,0x2c,0x21,0x1e,0x1e, - 0x1e,0x1e,0x13,0xe7,0xbd,0x93,0x81,0x81,0x9a,0xc3,0xec,0x13,0x1a,0xf5,0xd9,0xd1, - 0xe0,0xff,0x26,0x07,0xdf,0xdb,0xbc,0x95,0x81,0x95,0xc0,0xea,0x16,0x23,0x1d,0xff, - 0xe5,0xda,0xee,0x13,0x1f,0xf5,0xcc,0xa3,0x81,0x81,0xa9,0xce,0xdf,0xdf,0xdf,0xef, - 0x1b,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x81,0xa4,0xca,0xdf,0xdf,0xdf,0xdf, - 0xdf,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xd2,0xf0, - 0x0f,0x21,0x04,0xe6,0xc8,0xaa,0x8c,0x81,0x81,0x81,0x81,0x81,0x81,0x9b,0xc5,0xef, - 0x1b,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x0d,0x0b,0xe8, - 0xfc,0x1f,0x0d,0xfc,0xe5,0x0f,0x16,0xec,0xc2,0x98,0x81,0x95,0xc0,0xea,0x16,0x1e, - 0x1d,0xff,0xe5,0xdb,0xee,0x13,0x1f,0xf5,0xcc,0xa3,0x81,0x81,0xa6,0xcd,0xf3,0x18, - 0x18,0xf9,0xe2,0xda,0xe2,0xf7,0x16,0x1e,0xf9,0xd2,0xaa,0x82,0x95,0xc0,0xea,0x16, - 0x1c,0x1f,0xff,0xe8,0xda,0xe8,0x09,0x28,0xff,0xda,0xb1,0x89,0x81,0x81,0xa5,0xcc, - 0xf1,0x16,0x15,0xf5,0xe0,0xd7,0xdc,0xed,0x19,0x16,0xea,0xc0,0x95,0x95,0xc0,0xea, - 0x16,0x14,0x1b,0x07,0xec,0xdc,0xe6,0x0a,0x26,0xfc,0xd4,0xab,0x82,0x8c,0xb6,0xdf, - 0x09,0x23,0xfb,0xe1,0xd9,0xd8,0xdd,0xe5,0xe9,0xcb,0xa2,0x81,0x81,0x91,0xb9,0xdb, - 0xe2,0xe2,0xe2,0x0b,0x23,0xf7,0xe2,0xe2,0xe2,0xe2,0xe2,0xd0,0xaa,0x82,0x95,0xc0, - 0xea,0x16,0x19,0xed,0xc2,0x98,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x81,0x9f, - 0xc7,0xee,0x15,0x1d,0xf5,0xce,0xa6,0xb2,0xda,0xff,0x2a,0x06,0xdf,0xb7,0x90,0x81, - 0x87,0xb1,0xda,0x04,0x23,0xfa,0xd0,0xd0,0xe7,0xe7,0xdd,0xbd,0xe7,0x11,0x17,0xed, - 0xc4,0x9a,0x81,0x81,0x8a,0xac,0xce,0xf0,0x12,0x22,0xff,0xdb,0xe2,0x05,0x27,0x07, - 0xe5,0xc3,0xa1,0x81,0x81,0x81,0x9c,0xc4,0xeb,0x12,0x20,0xf9,0xd2,0xaa,0xaf,0xd6, - 0xfc,0x26,0x0a,0xe1,0xba,0x93,0x81,0x89,0xb2,0xd5,0xe2,0xe2,0xe2,0xe2,0xe2,0xea, - 0x0d,0x22,0xff,0xdf,0xbc,0x95,0x81,0x81,0x9b,0xaf,0xb2,0xb7,0xdf,0x09,0x1e,0xf5, - 0xca,0xa0,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81,0x81, - 0x81,0x85,0xb0,0xda,0x05,0x23,0xfa,0xd1,0xb5,0xb2,0xaa,0x90,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x8c,0xb1,0xcd,0xd0,0xc2,0xbf,0xc2,0xc2,0xd3,0xfc,0x26,0x09,0xdd, - 0xb2,0x88,0x95,0xc0,0xea,0x16,0x22,0xff,0xe1,0xc5,0xb1,0xcf,0xf7,0x20,0x0e,0xe5, - 0xbb,0x91,0x81,0x89,0xb2,0xda,0xff,0x28,0x0b,0xe6,0xc8,0xb6,0xb5,0xbc,0xcc,0xd0, - 0xb7,0x93,0x81,0x89,0xb3,0xdb,0x04,0x28,0xff,0xdb,0xbd,0xb0,0xc2,0xed,0x19,0x16, - 0xea,0xc0,0x95,0x8a,0xb3,0xdc,0x04,0x27,0xff,0xd9,0xbd,0xbd,0xc1,0xe7,0x0e,0x1e, - 0xf5,0xcc,0xa2,0x81,0x81,0x98,0xc2,0xed,0xff,0xff,0xff,0xff,0x21,0x0e,0xff,0xff, - 0xff,0xff,0xff,0xe7,0xbd,0x93,0x81,0x81,0xa0,0xca,0xf5,0x1e,0x0e,0xe5,0xbc,0xa7, - 0xc8,0xf2,0x1b,0x12,0xe7,0xbd,0xa0,0x82,0x81,0x95,0xc0,0xea,0x16,0x20,0xff,0xe1, - 0xc3,0xb5,0xde,0x09,0x26,0xfc,0xd2,0xa8,0x81,0x81,0x92,0xac,0xb5,0xb5,0xc5,0xef, - 0x1b,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x81,0x8e,0xa9,0xb5,0xb5,0xb5,0xb5, - 0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xf0,0x0f, - 0x21,0x04,0xe4,0xc8,0xaa,0x8c,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9b,0xc5,0xef, - 0x1b,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x1e,0xf7,0xd2, - 0xfa,0x26,0x0f,0xe8,0xe2,0x0e,0x19,0xed,0xc2,0x98,0x81,0x95,0xc0,0xea,0x16,0x21, - 0xff,0xe1,0xc3,0xb5,0xde,0x09,0x26,0xfc,0xd2,0xa8,0x81,0x8a,0xb3,0xdc,0x04,0x29, - 0xff,0xdd,0xbd,0xb0,0xbc,0xdb,0xff,0x28,0x09,0xdf,0xb6,0x8d,0x95,0xc0,0xea,0x16, - 0x23,0xff,0xe3,0xc5,0xb1,0xcf,0xf7,0x20,0x0e,0xe5,0xbb,0x91,0x81,0x89,0xb2,0xdb, - 0x04,0x28,0xff,0xdb,0xba,0xad,0xc2,0xed,0x19,0x16,0xea,0xc0,0x95,0x95,0xc0,0xea, - 0x16,0x27,0x07,0xe8,0xca,0xb3,0xd4,0xfc,0x29,0x06,0xda,0xb1,0x87,0x8d,0xb8,0xe2, - 0x0e,0x21,0xf9,0xda,0xc8,0xbb,0xb4,0xbb,0xbf,0xaf,0x91,0x81,0x81,0x81,0x9f,0xb4, - 0xb8,0xb8,0xdf,0x0b,0x23,0xf7,0xcd,0xb8,0xb8,0xb8,0xb8,0xae,0x94,0x81,0x95,0xc0, - 0xea,0x16,0x19,0xed,0xc2,0x98,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x81,0x90, - 0xb7,0xde,0x06,0x2c,0x04,0xdc,0xb5,0xc1,0xe8,0x11,0x1e,0xf6,0xcf,0xa8,0x81,0x81, - 0x81,0xaa,0xd4,0xfc,0x29,0xff,0xd5,0xdf,0x07,0x13,0xef,0xc8,0xea,0x16,0x11,0xe7, - 0xbd,0x94,0x81,0x81,0x81,0x93,0xb5,0xd6,0xf7,0x1a,0x17,0xf3,0xf9,0x1d,0x0f,0xee, - 0xcc,0xaa,0x88,0x81,0x81,0x81,0x8d,0xb4,0xdb,0x04,0x2a,0x09,0xe1,0xb9,0xbd,0xe4, - 0x0c,0x22,0xfa,0xd3,0xab,0x84,0x81,0x81,0x9a,0xb2,0xb8,0xb8,0xb8,0xc2,0xe3,0x05, - 0x26,0x09,0xe6,0xc5,0xa4,0x82,0x81,0x90,0xb6,0xd6,0xdd,0xe1,0xf1,0x13,0x13,0xec, - 0xc3,0x9a,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81,0x81, - 0x81,0x81,0xa9,0xd2,0xfb,0x22,0x09,0xeb,0xdf,0xdd,0xcc,0xa8,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x9f,0xba,0xcf,0xdf,0xe7,0xed,0xed,0xed,0xfa,0x26,0x09,0xdd, - 0xb2,0x88,0x95,0xc0,0xea,0x16,0x19,0xed,0xc6,0xa6,0x9b,0xc5,0xef,0x19,0x16,0xea, - 0xc0,0x97,0x81,0x91,0xbb,0xe5,0x0e,0x22,0xfa,0xd2,0xac,0x8e,0x8b,0x94,0xa4,0xa7, - 0x97,0x81,0x81,0x92,0xbb,0xe5,0x0e,0x1e,0xf3,0xca,0xa2,0x98,0xc2,0xed,0x19,0x16, - 0xea,0xc0,0x95,0x92,0xbc,0xe5,0x0f,0x1e,0xf3,0xe7,0xe7,0xe7,0xe7,0xe7,0x06,0x26, - 0xfa,0xd2,0xa8,0x81,0x81,0x8f,0xb5,0xd1,0xd5,0xd5,0xd5,0xf5,0x21,0x0e,0xe2,0xd5, - 0xd5,0xd5,0xd5,0xce,0xb0,0x8a,0x81,0x81,0xa0,0xca,0xf5,0x1f,0x0f,0xe6,0xbe,0xac, - 0xcb,0xf2,0x1c,0x11,0xe7,0xbd,0x93,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc5, - 0xa5,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x81,0x81,0x85,0x8b,0x9b,0xc5,0xef, - 0x1b,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x81,0x81,0x83,0x8b,0x8b,0x8b,0x8b, - 0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x95,0xc0,0xea,0x16,0x19,0xf0,0x0f,0x21, - 0x04,0xe4,0xc7,0xa9,0x8c,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9b,0xc5,0xef, - 0x1b,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x11,0xe5,0xd0, - 0xfa,0x26,0xff,0xd6,0xe2,0x0e,0x19,0xed,0xc2,0x98,0x81,0x95,0xc0,0xea,0x16,0x19, - 0xed,0xc5,0xa5,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x92,0xbc,0xe5,0x0f,0x1e, - 0xf5,0xcc,0xa3,0x86,0xa2,0xcb,0xf4,0x1e,0x11,0xe7,0xbd,0x93,0x95,0xc0,0xea,0x16, - 0x19,0xed,0xc6,0xa7,0x9b,0xc5,0xef,0x19,0x16,0xea,0xc0,0x96,0x81,0x91,0xbb,0xe4, - 0x0e,0x1e,0xf4,0xca,0xa2,0x98,0xc2,0xed,0x19,0x16,0xea,0xc0,0x95,0x95,0xc0,0xea, - 0x16,0x19,0xed,0xcb,0xac,0xa5,0xd0,0xfa,0x04,0x04,0xdd,0xb2,0x88,0x89,0xb3,0xdb, - 0x04,0x25,0x14,0xff,0xf1,0xe4,0xd6,0xc7,0xb4,0x9d,0x81,0x81,0x81,0x81,0x81,0x8b, - 0x8d,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x8d,0x8d,0x8d,0x87,0x81,0x81,0x95,0xc0, - 0xea,0x16,0x19,0xed,0xc2,0x98,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x81,0x81, - 0xa8,0xcf,0xf6,0x1e,0x13,0xec,0xc3,0xcf,0xf7,0x1f,0x0f,0xe7,0xc0,0x99,0x81,0x81, - 0x81,0xa4,0xce,0xf7,0x22,0x04,0xda,0xec,0x14,0x25,0xfc,0xd6,0xef,0x1a,0x0b,0xe1, - 0xb7,0x8d,0x81,0x81,0x81,0x81,0x9b,0xbd,0xdf,0xff,0x23,0x0c,0x11,0x18,0xf5,0xd4, - 0xb2,0x91,0x81,0x81,0x81,0x81,0x81,0xa4,0xcc,0xf3,0x1a,0x17,0xef,0xc8,0xcb,0xf2, - 0x1a,0x13,0xec,0xc4,0x9c,0x81,0x81,0x81,0x81,0x89,0x8d,0x99,0xba,0xdb,0xfc,0x1e, - 0x10,0xee,0xcd,0xac,0x8a,0x81,0x81,0x95,0xc0,0xea,0x09,0x0b,0x15,0x12,0xf9,0xd9, - 0xb4,0x8e,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81,0x81, - 0x81,0x81,0x9d,0xc4,0xe7,0x06,0x18,0x12,0x09,0x06,0xda,0xb0,0x85,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x9b,0xbd,0xdb,0xf5,0x07,0x12,0x17,0x19,0x19,0x19,0x2d,0x09,0xdd, - 0xb2,0x88,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0x96,0xc0,0xea,0x16,0x19,0xed, - 0xc2,0x98,0x81,0x95,0xc0,0xea,0x14,0x1b,0xf1,0xc7,0x9d,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x95,0xc0,0xea,0x14,0x19,0xed,0xc4,0x9a,0x98,0xc2,0xed,0x19,0x16, - 0xea,0xc0,0x95,0x95,0xc0,0xea,0x16,0x22,0x13,0x13,0x13,0x13,0x13,0x13,0x14,0x29, - 0xfc,0xd2,0xa8,0x81,0x81,0x81,0x96,0xa8,0xab,0xab,0xca,0xf5,0x21,0x0e,0xe2,0xb8, - 0xab,0xab,0xab,0xa7,0x93,0x81,0x81,0x81,0x9a,0xc3,0xec,0x13,0x1d,0xf7,0xde,0xd5, - 0xe4,0x04,0x29,0x05,0xdd,0xb5,0x8c,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2, - 0x98,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x81,0x81,0x81,0x81,0x9b,0xc5,0xef, - 0x1b,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8b, - 0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x95,0xc0,0xea,0x16,0x19,0x0f,0x2c,0x04, - 0xe4,0xc7,0xa9,0x8b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9b,0xc5,0xef, - 0x1b,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x11,0xe5,0xd0, - 0xfa,0x26,0xff,0xd5,0xe2,0x0e,0x19,0xed,0xc2,0x98,0x81,0x95,0xc0,0xea,0x16,0x19, - 0xed,0xc2,0x98,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x95,0xc0,0xea,0x16,0x19, - 0xed,0xc4,0x9a,0x81,0x9a,0xc4,0xed,0x19,0x16,0xea,0xc0,0x95,0x95,0xc0,0xea,0x16, - 0x19,0xed,0xc2,0x98,0x96,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0x81,0x95,0xc0,0xea, - 0x14,0x19,0xed,0xc4,0x9a,0x98,0xc2,0xed,0x19,0x16,0xea,0xc0,0x95,0x95,0xc0,0xea, - 0x16,0x19,0xed,0xc2,0x98,0x9c,0xc1,0xd7,0xd7,0xd7,0xca,0xa8,0x81,0x81,0xa4,0xc8, - 0xea,0x07,0x1d,0x26,0x19,0x0c,0xff,0xee,0xd8,0xbd,0x9d,0x81,0x81,0x81,0x81,0x81, - 0x8b,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0, - 0xea,0x16,0x19,0xed,0xc2,0x98,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x81,0x81, - 0x98,0xc0,0xe7,0x0f,0x21,0xfa,0xd2,0xde,0x06,0x26,0xff,0xd7,0xb0,0x89,0x81,0x81, - 0x81,0x9e,0xc8,0xf2,0x1c,0x09,0xdf,0xfa,0x1f,0x14,0x0b,0xe4,0xf5,0x1f,0x06,0xdb, - 0xb2,0x88,0x81,0x81,0x81,0x81,0x82,0xa4,0xc6,0xe8,0x0a,0x2a,0x20,0xff,0xdd,0xbb, - 0x99,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xbc,0xe3,0x0b,0x26,0xff,0xd7,0xd9,0xff, - 0x29,0x04,0xdc,0xb4,0x8d,0x81,0x81,0x81,0x81,0x81,0x91,0xb2,0xd4,0xf5,0x17,0x18, - 0xf5,0xd5,0xb3,0x92,0x81,0x81,0x81,0x95,0xc0,0xea,0x13,0x16,0x18,0x09,0xf3,0xd4, - 0xb1,0x8a,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81,0x81, - 0x81,0x81,0x98,0xbd,0xdf,0xfb,0x0c,0x19,0x13,0x06,0xda,0xb0,0x85,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x87,0xae,0xd4,0xf9,0x18,0x1d,0x0a,0xff,0xff,0xff,0xff,0x26,0x09,0xdd, - 0xb2,0x88,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0x98,0xc2,0xec,0x16,0x16,0xed, - 0xc2,0x98,0x81,0x95,0xc0,0xea,0x16,0x1b,0xef,0xc6,0x9c,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0x98,0xc2,0xed,0x19,0x16, - 0xea,0xc0,0x95,0x95,0xc0,0xea,0x16,0x1c,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06, - 0xfc,0xd2,0xa8,0x81,0x81,0x81,0x81,0x81,0x81,0xa0,0xca,0xf5,0x21,0x0e,0xe2,0xb8, - 0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x92,0xb6,0xd9,0xfb,0x23,0x18,0x05,0xff, - 0x0a,0x20,0x10,0xf0,0xcc,0xa7,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2, - 0x98,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x81,0x81,0x81,0x81,0x9b,0xc5,0xef, - 0x1b,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8b, - 0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x95,0xc0,0xea,0x16,0x19,0xf3,0x14,0x1c, - 0xfc,0xdd,0xbf,0x9f,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9b,0xc5,0xef, - 0x1b,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x11,0xe5,0xd0, - 0xfa,0x26,0xff,0xd5,0xe2,0x0e,0x19,0xed,0xc2,0x98,0x81,0x95,0xc0,0xea,0x16,0x19, - 0xed,0xc2,0x98,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x95,0xc0,0xea,0x16,0x19, - 0xed,0xc4,0x9a,0x81,0x9a,0xc4,0xed,0x19,0x14,0xea,0xc0,0x95,0x95,0xc0,0xea,0x16, - 0x19,0xed,0xc2,0x98,0x98,0xc2,0xec,0x16,0x16,0xed,0xc2,0x98,0x81,0x95,0xc0,0xea, - 0x16,0x19,0xed,0xc2,0x99,0x98,0xc2,0xed,0x19,0x16,0xea,0xc0,0x95,0x95,0xc0,0xea, - 0x16,0x19,0xed,0xc2,0x98,0x85,0xa0,0xad,0xad,0xad,0xa6,0x8e,0x81,0x81,0x8d,0xae, - 0xcb,0xe3,0xf6,0x05,0x11,0x1f,0x26,0x13,0xf9,0xd8,0xb3,0x8c,0x81,0x81,0x81,0x81, - 0x8b,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0, - 0xea,0x16,0x19,0xed,0xc2,0x98,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x81,0x81, - 0x89,0xb0,0xd7,0xff,0x26,0x09,0xe1,0xed,0x14,0x17,0xef,0xc8,0xa1,0x81,0x81,0x81, - 0x81,0x98,0xc2,0xec,0x16,0x0e,0xe4,0x06,0x12,0x05,0x19,0xf1,0xfa,0x23,0xff,0xd5, - 0xab,0x81,0x81,0x81,0x81,0x81,0x85,0xa7,0xc8,0xea,0x0b,0x28,0x20,0xfc,0xdd,0xbb, - 0x9a,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0xac,0xd3,0xfa,0x22,0x0e,0xe7,0xe7,0x0f, - 0x1c,0xf5,0xcd,0xa6,0x81,0x81,0x81,0x81,0x81,0x8a,0xab,0xcc,0xee,0x0f,0x1f,0xfc, - 0xdc,0xbb,0x99,0x81,0x81,0x81,0x81,0x92,0xbb,0xdf,0xe7,0xec,0xfc,0x1b,0x0f,0xe8, - 0xc1,0x98,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81,0x81, - 0x81,0x81,0xa7,0xcf,0xf6,0x1b,0x0b,0xf1,0xe9,0xe7,0xd3,0xac,0x83,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x92,0xbb,0xe4,0x0d,0x26,0xff,0xe3,0xd7,0xd5,0xd5,0xfa,0x26,0x09,0xdd, - 0xb2,0x88,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0xa1,0xc9,0xf2,0x1b,0x11,0xe7, - 0xbd,0x94,0x81,0x93,0xbd,0xe7,0x11,0x20,0xf6,0xcd,0xa6,0x8b,0x8a,0x94,0xa4,0xa6, - 0x96,0x81,0x81,0x94,0xbd,0xe7,0x13,0x1b,0xf1,0xc7,0x9e,0xac,0xcd,0xef,0x19,0x16, - 0xea,0xc0,0x95,0x93,0xbd,0xe7,0x11,0x1e,0xf2,0xda,0xda,0xda,0xda,0xda,0xda,0xda, - 0xda,0xc4,0xa0,0x81,0x81,0x81,0x81,0x81,0x81,0xa0,0xca,0xf5,0x21,0x0e,0xe2,0xb8, - 0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa3,0xcb,0xf0,0x14,0x0f,0x09,0x13,0x16, - 0x11,0x04,0xef,0xd4,0xb5,0x92,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2, - 0x98,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x81,0x81,0x8b,0x8d,0x9b,0xc5,0xef, - 0x1b,0x13,0xe7,0xbd,0x93,0x8d,0x84,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8b, - 0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xf9,0x18, - 0x1a,0xfb,0xdb,0xbb,0x9d,0x81,0x81,0x81,0x81,0x81,0x81,0x8b,0x8d,0x9b,0xc5,0xef, - 0x1b,0x13,0xe7,0xbd,0x93,0x8d,0x84,0x81,0x81,0x95,0xc0,0xea,0x16,0x11,0xe5,0xd0, - 0xfa,0x26,0xff,0xd5,0xe2,0x0e,0x19,0xed,0xc2,0x98,0x81,0x95,0xc0,0xea,0x16,0x19, - 0xed,0xc2,0x98,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x93,0xbd,0xe7,0x11,0x1e, - 0xf4,0xcb,0xa2,0x86,0xa4,0xcc,0xf5,0x1e,0x0e,0xe5,0xbb,0x92,0x95,0xc0,0xea,0x16, - 0x19,0xed,0xc2,0x98,0xa1,0xc9,0xf2,0x1b,0x11,0xe7,0xbd,0x94,0x81,0x94,0xbd,0xe7, - 0x13,0x1b,0xf2,0xc8,0x9e,0xac,0xcd,0xef,0x19,0x16,0xea,0xc0,0x95,0x95,0xc0,0xea, - 0x16,0x19,0xed,0xc2,0x98,0x81,0x81,0x83,0x83,0x83,0x81,0x81,0x81,0x81,0x8c,0x9d, - 0xa9,0xbe,0xcf,0xdc,0xe9,0xf7,0x0b,0x27,0x11,0xea,0xc1,0x97,0x81,0x81,0x81,0x81, - 0x8b,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x88,0x8e,0x95,0x8f,0x81,0x81,0x95,0xc0, - 0xea,0x16,0x19,0xed,0xc2,0x99,0xb8,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x81,0x81, - 0x81,0xa1,0xc8,0xef,0x17,0x17,0xef,0xfb,0x23,0x07,0xe0,0xb9,0x91,0x81,0x81,0x81, - 0x81,0x92,0xbc,0xe6,0x11,0x13,0xec,0x14,0x06,0xf7,0x20,0xff,0xfc,0x23,0xf7,0xcf, - 0xa5,0x81,0x81,0x81,0x81,0x81,0x9f,0xc1,0xe3,0x04,0x25,0x07,0x16,0x18,0xf7,0xd5, - 0xb5,0x93,0x81,0x81,0x81,0x81,0x81,0x81,0x9c,0xc4,0xeb,0x12,0x1d,0xf5,0xf5,0x1d, - 0x0d,0xe6,0xbe,0x97,0x81,0x81,0x81,0x81,0x82,0xa3,0xc5,0xe6,0x07,0x27,0x05,0xe4, - 0xc3,0xa1,0x8d,0x8d,0x85,0x81,0x81,0x82,0xa3,0xb9,0xbd,0xc3,0xe2,0x0b,0x1d,0xf2, - 0xc9,0x9f,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81,0x81, - 0x81,0x85,0xaf,0xd9,0x04,0x24,0xfa,0xd2,0xbf,0xbd,0xb3,0x97,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x95,0xc0,0xea,0x16,0x1e,0xf2,0xc9,0xb4,0xc6,0xde,0xfa,0x26,0x09,0xdd, - 0xb2,0x88,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0xb0,0xbb,0xda,0xff,0x26,0x05,0xdc, - 0xb4,0x8b,0x81,0x8d,0xb6,0xdf,0x07,0x2b,0x05,0xe0,0xc3,0xb5,0xb5,0xbc,0xcc,0xcf, - 0xb5,0x92,0x81,0x8f,0xb8,0xe2,0x0b,0x23,0xfa,0xd3,0xb4,0xcb,0xe8,0x09,0x2b,0x16, - 0xea,0xc0,0x95,0x8c,0xb6,0xdf,0x07,0x27,0xff,0xdb,0xbf,0xb2,0xb0,0xb5,0xbb,0xc4, - 0xbe,0xa3,0x89,0x81,0x81,0x81,0x81,0x81,0x81,0xa0,0xca,0xf5,0x21,0x0e,0xe2,0xb8, - 0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x82,0xad,0xd6,0xff,0x26,0xfb,0xe0,0xe8,0xea, - 0xe7,0xdc,0xcb,0xb9,0xa7,0x91,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2, - 0x98,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x81,0x9f,0xb4,0xb8,0xb8,0xc5,0xef, - 0x1b,0x13,0xe7,0xbd,0xb8,0xb8,0xaa,0x8e,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8b, - 0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xdd,0xfc, - 0x1d,0x18,0xf7,0xd9,0xb9,0x9a,0x81,0x81,0x81,0x81,0x9f,0xb4,0xb8,0xb8,0xc5,0xef, - 0x1b,0x13,0xe7,0xbd,0xb8,0xb8,0xaa,0x8e,0x81,0x95,0xc0,0xea,0x16,0x11,0xe5,0xd0, - 0xfa,0x26,0xff,0xd5,0xe2,0x0e,0x19,0xed,0xc2,0x98,0x81,0x95,0xc0,0xea,0x16,0x19, - 0xed,0xc2,0x98,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x8c,0xb6,0xdf,0x07,0x28, - 0xff,0xdb,0xbc,0xb0,0xbd,0xdd,0x04,0x29,0x04,0xdb,0xb3,0x89,0x95,0xc0,0xea,0x16, - 0x19,0xed,0xc2,0xb0,0xbc,0xda,0xff,0x26,0x05,0xdd,0xb4,0x8c,0x81,0x8f,0xb8,0xe2, - 0x0b,0x23,0xfa,0xd3,0xb4,0xca,0xe8,0x09,0x2b,0x16,0xea,0xc0,0x95,0x95,0xc0,0xea, - 0x16,0x19,0xed,0xc2,0x98,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x88,0xac,0xc6, - 0xc7,0xbd,0xb5,0xb4,0xc1,0xd1,0xed,0x16,0x1b,0xef,0xc5,0x9b,0x81,0x81,0x81,0x81, - 0x8b,0xb5,0xdf,0x0b,0x24,0xfa,0xd1,0xb3,0xb2,0xb7,0xc0,0xb5,0x99,0x81,0x95,0xc0, - 0xea,0x13,0x1b,0xf1,0xc7,0xba,0xd4,0xf3,0x14,0x29,0xfc,0xd2,0xa8,0x81,0x81,0x81, - 0x81,0x92,0xb9,0xe0,0x07,0x25,0xfc,0x09,0x1f,0xf7,0xd1,0xa9,0x82,0x81,0x81,0x81, - 0x81,0x8c,0xb6,0xdf,0x0a,0x19,0xf7,0x20,0xf7,0xea,0x12,0x0e,0x04,0x1d,0xf2,0xc9, - 0x9f,0x81,0x81,0x81,0x81,0x98,0xb9,0xdb,0xfc,0x1d,0x12,0xef,0xfc,0x20,0x11,0xf0, - 0xce,0xae,0x8c,0x81,0x81,0x81,0x81,0x81,0x8d,0xb4,0xdb,0x04,0x2a,0x04,0x04,0x26, - 0xfc,0xd6,0xaf,0x87,0x81,0x81,0x81,0x81,0x9c,0xbd,0xdf,0xff,0x21,0x0d,0xec,0xca, - 0xb8,0xb8,0xb8,0xb8,0xac,0x90,0x81,0x81,0x81,0x90,0x93,0xb2,0xdd,0x09,0x21,0xf5, - 0xca,0xa0,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81,0x81, - 0x81,0x85,0xb0,0xda,0x06,0x23,0xf7,0xcd,0xa3,0x93,0x8c,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x95,0xbf,0xe7,0x12,0x23,0xfb,0xdf,0xdd,0xeb,0xff,0x1a,0x2e,0x09,0xdd, - 0xb2,0x88,0x95,0xc0,0xea,0x16,0x19,0xed,0xdf,0xda,0xe2,0xf6,0x15,0x17,0xf3,0xcd, - 0xa6,0x81,0x81,0x81,0xa9,0xd1,0xf7,0x1c,0x1c,0xff,0xe9,0xdf,0xde,0xe5,0xf1,0xf1, - 0xc7,0x9d,0x81,0x86,0xaf,0xd6,0xff,0x26,0x0d,0xec,0xdd,0xed,0x07,0x19,0x13,0x16, - 0xea,0xc0,0x95,0x82,0xaa,0xd2,0xf7,0x1d,0x16,0xf9,0xe5,0xdc,0xda,0xdf,0xe5,0xed, - 0xde,0xb6,0x8c,0x81,0x81,0x81,0x81,0x81,0x81,0xa0,0xca,0xf5,0x21,0x0e,0xe2,0xb8, - 0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x83,0xad,0xd7,0xff,0x2a,0x09,0xf5,0xf2,0xf2, - 0xf2,0xf2,0xec,0xe0,0xcc,0xb2,0x93,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2, - 0x98,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x91,0xb9,0xdb,0xe2,0xe2,0xe2,0xef, - 0x1b,0x13,0xe7,0xe2,0xe2,0xe2,0xc9,0xa3,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8b, - 0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0xe1, - 0xff,0x21,0x14,0xf5,0xd5,0xb8,0x98,0x81,0x81,0x91,0xb9,0xdb,0xe2,0xe2,0xe2,0xef, - 0x1b,0x13,0xe7,0xe2,0xe2,0xe2,0xc9,0xa3,0x81,0x95,0xc0,0xea,0x16,0x11,0xe5,0xd0, - 0xfa,0x26,0xff,0xd5,0xe2,0x0e,0x19,0xed,0xc2,0x98,0x81,0x95,0xc0,0xea,0x16,0x19, - 0xed,0xc2,0x98,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x81,0xa9,0xd1,0xf7,0x1d, - 0x16,0xf7,0xe1,0xda,0xe2,0xf9,0x18,0x16,0xf1,0xcc,0xa5,0x81,0x95,0xc0,0xea,0x16, - 0x19,0xed,0xdf,0xda,0xe1,0xf7,0x16,0x18,0xf3,0xcd,0xa7,0x81,0x81,0x86,0xaf,0xd7, - 0xff,0x26,0x0d,0xec,0xdd,0xec,0x07,0x16,0x19,0x16,0xea,0xc0,0x95,0x95,0xc0,0xea, - 0x16,0x19,0xed,0xc2,0x98,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xbf,0xe7, - 0xef,0xe7,0xdf,0xdb,0xda,0xe1,0xf5,0x1a,0x14,0xec,0xc2,0x99,0x81,0x81,0x81,0x81, - 0x87,0xb1,0xda,0x04,0x2b,0x0a,0xea,0xdd,0xdc,0xe1,0xea,0xd4,0xad,0x83,0x91,0xba, - 0xe4,0x0d,0x25,0xff,0xe2,0xe0,0xf4,0x10,0x16,0x29,0xfc,0xd2,0xa8,0x81,0x81,0x81, - 0x81,0x82,0xa9,0xd1,0xf7,0x1f,0x0b,0x16,0x0f,0xe8,0xc1,0x9a,0x81,0x81,0x81,0x81, - 0x81,0x86,0xb0,0xda,0x04,0x1e,0x06,0x13,0xeb,0xdc,0x05,0x1b,0x09,0x16,0xed,0xc2, - 0x99,0x81,0x81,0x81,0x90,0xb2,0xd3,0xf4,0x16,0x1c,0xf9,0xd7,0xe5,0x07,0x2b,0x0b, - 0xe8,0xc8,0xa6,0x85,0x81,0x81,0x81,0x81,0x81,0xa4,0xcc,0xf3,0x1a,0x11,0x12,0x17, - 0xef,0xc8,0xa0,0x81,0x81,0x81,0x81,0x8f,0xb5,0xd7,0xf9,0x1a,0x15,0xf3,0xe2,0xe2, - 0xe2,0xe2,0xe2,0xe2,0xcb,0xa5,0x81,0x81,0x81,0x81,0x88,0xb2,0xdd,0x09,0x21,0xf5, - 0xca,0xa0,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81,0x81, - 0x81,0x85,0xb0,0xda,0x06,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x8d,0xb5,0xdc,0x04,0x25,0x18,0x09,0x06,0x12,0x1d,0x04,0x1e,0x09,0xdd, - 0xb2,0x88,0x95,0xc0,0xea,0x16,0x25,0x13,0x09,0x06,0x0b,0x1a,0x18,0xfb,0xdb,0xb9, - 0x94,0x81,0x81,0x81,0x99,0xbe,0xe1,0xff,0x1d,0x21,0x11,0x09,0x09,0x0e,0x19,0xf2, - 0xc8,0x9d,0x81,0x81,0xa0,0xc7,0xec,0x0f,0x29,0x11,0x09,0x12,0x1c,0xfc,0x11,0x16, - 0xea,0xc0,0x95,0x81,0x99,0xbf,0xe3,0x04,0x1f,0x1d,0x0e,0x06,0x06,0x09,0x0e,0x0e, - 0xe2,0xb8,0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0xa0,0xca,0xf5,0x21,0x0e,0xe2,0xb8, - 0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa4,0xcc,0xf1,0x0f,0x2b,0x1e,0x1e,0x1e, - 0x1e,0x1d,0x15,0x06,0xee,0xce,0xab,0x85,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2, - 0x98,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x95,0xc0,0xea,0x0e,0x0e,0x0e,0x0e, - 0x1f,0x18,0x0e,0x0e,0x0e,0xfc,0xd2,0xa8,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8b, - 0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0xc5, - 0xe4,0x05,0x25,0x12,0xf3,0xd4,0xb4,0x93,0x81,0x95,0xc0,0xea,0x0e,0x0e,0x0e,0x0e, - 0x1f,0x18,0x0e,0x0e,0x0e,0xfc,0xd2,0xa8,0x81,0x95,0xc0,0xea,0x16,0x11,0xe5,0xd0, - 0xfa,0x26,0xff,0xd5,0xe2,0x0e,0x19,0xed,0xc2,0x98,0x81,0x95,0xc0,0xea,0x16,0x19, - 0xed,0xc2,0x98,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x81,0x99,0xbe,0xe2,0x04, - 0x1f,0x1a,0x0b,0x06,0x0b,0x1b,0x18,0xfb,0xdb,0xb8,0x93,0x81,0x95,0xc0,0xea,0x16, - 0x25,0x13,0x09,0x06,0x0b,0x1a,0x18,0xfb,0xdc,0xba,0x94,0x81,0x81,0x81,0xa1,0xc7, - 0xed,0x10,0x29,0x11,0x09,0x12,0x1a,0xfb,0x16,0x16,0xea,0xc0,0x95,0x95,0xc0,0xea, - 0x16,0x19,0xed,0xc2,0x98,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea, - 0x16,0x11,0x09,0x06,0x06,0x0b,0x18,0x1c,0xff,0xdb,0xb5,0x8f,0x81,0x81,0x81,0x81, - 0x81,0xa5,0xcd,0xf3,0x16,0x25,0x0f,0x06,0x06,0x0b,0x06,0xda,0xb0,0x85,0x87,0xaf, - 0xd6,0xfc,0x20,0x1c,0x0b,0x0a,0x18,0x10,0xfc,0x29,0xfc,0xd2,0xa8,0x81,0x81,0x81, - 0x81,0x81,0x9a,0xc1,0xe9,0x11,0x24,0x28,0xff,0xd9,0xb2,0x8a,0x81,0x81,0x81,0x81, - 0x81,0x81,0xaa,0xd4,0xfc,0x28,0x22,0x05,0xdc,0xce,0xf6,0x1f,0x1f,0x11,0xe7,0xbd, - 0x92,0x81,0x81,0x86,0xaa,0xcc,0xed,0x0f,0x27,0x04,0xe1,0xbf,0xcd,0xef,0x12,0x24, - 0x04,0xe1,0xc1,0x9f,0x81,0x81,0x81,0x81,0x81,0x95,0xbc,0xe3,0x0b,0x28,0x2a,0x07, - 0xe0,0xb9,0x91,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x12,0x33,0x0f,0x0e,0x0e,0x0e, - 0x0e,0x0e,0x0e,0xff,0xd5,0xab,0x81,0x81,0x81,0x81,0x88,0xb2,0xdd,0x09,0x21,0xf5, - 0xca,0xa0,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81,0x81, - 0x81,0x85,0xb0,0xda,0x06,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0xa4,0xc8,0xe8,0xff,0x12,0x19,0x16,0x0b,0xf9,0xf2,0x11,0x09,0xdd, - 0xb2,0x88,0x94,0xbe,0xe6,0xfa,0x07,0x0f,0x14,0x16,0x11,0x06,0xf4,0xdc,0xbf,0xa0, - 0x81,0x81,0x81,0x81,0x83,0xa6,0xc5,0xe2,0xf9,0x0a,0x13,0x19,0x16,0x11,0x09,0xf1, - 0xc7,0x9d,0x81,0x81,0x8e,0xb2,0xd4,0xf1,0x0a,0x16,0x17,0x0d,0xf9,0xe5,0x0e,0x0e, - 0xea,0xc0,0x95,0x81,0x85,0xa7,0xc7,0xe3,0xfa,0x0b,0x14,0x19,0x19,0x13,0x0e,0x06, - 0xe2,0xb8,0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0xa0,0xca,0xf5,0x11,0x0e,0xe2,0xb8, - 0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x84,0xab,0xcf,0xf0,0x0f,0x1d,0x06,0x06,0x06, - 0x06,0x09,0x16,0x29,0x09,0xe3,0xbb,0x92,0x81,0x95,0xc0,0xea,0x11,0x11,0xed,0xc2, - 0x98,0xb0,0xda,0x06,0x11,0xfc,0xd2,0xa8,0x81,0x95,0xc0,0xea,0x11,0x11,0x11,0x11, - 0x11,0x11,0x11,0x11,0x11,0xfc,0xd2,0xa8,0x81,0x81,0x81,0x89,0x89,0x81,0x81,0x8b, - 0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x95,0xc0,0xea,0x11,0x11,0xed,0xc2,0xa9, - 0xc8,0xe8,0x09,0x11,0x10,0xf0,0xcb,0xa1,0x81,0x95,0xc0,0xea,0x11,0x11,0x11,0x11, - 0x11,0x11,0x11,0x11,0x11,0xfc,0xd2,0xa8,0x81,0x95,0xc0,0xea,0x11,0x11,0xe5,0xd0, - 0xfa,0x11,0xff,0xd5,0xe2,0x0e,0x11,0xed,0xc2,0x98,0x81,0x95,0xc0,0xea,0x11,0x11, - 0xed,0xc2,0x98,0xb0,0xda,0x06,0x11,0xfc,0xd2,0xa8,0x81,0x81,0x84,0xa7,0xc7,0xe4, - 0xfb,0x0c,0x16,0x19,0x14,0x09,0xf5,0xdd,0xbf,0xa0,0x81,0x81,0x95,0xc0,0xea,0x16, - 0x1b,0x0e,0x14,0x16,0x11,0x06,0xf4,0xdd,0xbf,0xa1,0x81,0x81,0x81,0x81,0x8e,0xb2, - 0xd4,0xf1,0x0a,0x16,0x16,0x0c,0xf7,0xea,0x16,0x16,0xea,0xc0,0x95,0x95,0xc0,0xea, - 0x11,0x11,0xed,0xc2,0x98,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea, - 0x0a,0x11,0x16,0x19,0x19,0x13,0x09,0xf7,0xe0,0xc3,0xa1,0x81,0x81,0x81,0x81,0x81, - 0x81,0x94,0xb8,0xd9,0xf5,0x0a,0x14,0x19,0x17,0x13,0x06,0xda,0xb0,0x85,0x81,0x9f, - 0xc3,0xe4,0xff,0x12,0x19,0x14,0x07,0xf0,0xfc,0x0e,0xfc,0xd2,0xa8,0x81,0x81,0x81, - 0x81,0x81,0x8b,0xb2,0xd9,0xff,0x11,0x11,0xf1,0xc9,0xa2,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0xa4,0xcd,0xf7,0x11,0x11,0xf7,0xcf,0xc1,0xe8,0x11,0x11,0x0b,0xe0,0xb7, - 0x8d,0x81,0x81,0x92,0xbc,0xe5,0x07,0x11,0x0f,0xec,0xc9,0xa7,0xb5,0xd7,0xf9,0x11, - 0x11,0xfb,0xd8,0xaf,0x85,0x81,0x81,0x81,0x81,0x85,0xac,0xd3,0xfa,0x22,0x1f,0xf7, - 0xd1,0xa9,0x82,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x11,0x11,0x11,0x11,0x11,0x11, - 0x11,0x11,0x11,0xff,0xd5,0xab,0x81,0x81,0x81,0x81,0x88,0xb2,0xdd,0x09,0x21,0xf5, - 0xca,0xa0,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81,0x81, - 0x81,0x85,0xb0,0xda,0x06,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x83,0x93,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95,0x95, - 0x94,0x87,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x8d,0xac,0xc8,0xdc,0xe8,0xed,0xec,0xe3,0xd4,0xe1,0xe5,0xe5,0xd3, - 0xae,0x85,0x87,0xaa,0xc5,0xd2,0xdd,0xe5,0xea,0xea,0xe7,0xde,0xce,0xba,0xa1,0x83, - 0x81,0x81,0x81,0x81,0x81,0x89,0xa7,0xbf,0xd3,0xe1,0xea,0xed,0xed,0xe7,0xdf,0xd2, - 0xb7,0x93,0x81,0x81,0x81,0x98,0xb6,0xcf,0xe2,0xec,0xed,0xe5,0xd5,0xd7,0xe2,0xe2, - 0xdb,0xb9,0x91,0x81,0x81,0x8b,0xa8,0xc1,0xd4,0xe2,0xea,0xed,0xed,0xea,0xe4,0xdc, - 0xcd,0xad,0x86,0x81,0x81,0x81,0x81,0x81,0x81,0x9c,0xc4,0xe2,0xe5,0xe5,0xd7,0xb3, - 0x8a,0x81,0x81,0x81,0x81,0x81,0x81,0x91,0xba,0xe2,0x0a,0x26,0xff,0xe1,0xda,0xda, - 0xda,0xdf,0xf6,0x1e,0x17,0xed,0xc2,0x98,0x81,0x92,0xba,0xdd,0xe5,0xe5,0xde,0xbc, - 0x94,0xab,0xd1,0xe5,0xe5,0xe4,0xcb,0xa4,0x81,0x92,0xba,0xdd,0xe5,0xe5,0xe5,0xe5, - 0xe5,0xe5,0xe5,0xe5,0xe5,0xe4,0xcb,0xa4,0x81,0x81,0x9d,0xb2,0xb3,0xa3,0x97,0x94, - 0xb9,0xe2,0x0e,0x21,0xf5,0xcc,0xa2,0x81,0x92,0xba,0xdd,0xe5,0xe5,0xde,0xbc,0x94, - 0xae,0xcd,0xe5,0xe5,0xe5,0xe3,0xc6,0x9f,0x81,0x92,0xba,0xdd,0xe5,0xe5,0xe5,0xe5, - 0xe5,0xe5,0xe5,0xe5,0xe5,0xe4,0xcb,0xa4,0x81,0x92,0xba,0xdd,0xe5,0xe5,0xd9,0xc8, - 0xe4,0xe5,0xe5,0xcd,0xd7,0xe5,0xe5,0xde,0xbc,0x94,0x81,0x92,0xba,0xdd,0xe5,0xe5, - 0xde,0xbc,0x94,0xab,0xd1,0xe5,0xe5,0xe4,0xcb,0xa4,0x81,0x81,0x81,0x8b,0xa8,0xc2, - 0xd5,0xe4,0xeb,0xed,0xea,0xe1,0xd1,0xbb,0xa1,0x83,0x81,0x81,0x95,0xc0,0xea,0x16, - 0x19,0xed,0xea,0xea,0xe7,0xdd,0xce,0xba,0xa1,0x83,0x81,0x81,0x81,0x81,0x81,0x98, - 0xb6,0xd0,0xe3,0xed,0xed,0xe4,0xd3,0xea,0x16,0x16,0xea,0xc0,0x95,0x92,0xba,0xdd, - 0xe5,0xe5,0xde,0xbc,0x94,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8f,0xb5,0xd4, - 0xe0,0xe7,0xea,0xed,0xed,0xea,0xe0,0xd2,0xbe,0xa5,0x87,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x9d,0xba,0xd2,0xe1,0xea,0xed,0xed,0xe9,0xe2,0xce,0xa9,0x81,0x81,0x88, - 0xa9,0xc5,0xdb,0xe8,0xed,0xea,0xe0,0xcd,0xe2,0xe2,0xe2,0xc9,0xa3,0x81,0x81,0x81, - 0x81,0x81,0x81,0xa3,0xc9,0xe4,0xe5,0xe5,0xdd,0xba,0x93,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x9c,0xc4,0xe2,0xe5,0xe5,0xe1,0xc1,0xb3,0xd7,0xe5,0xe5,0xe5,0xd3,0xae, - 0x85,0x81,0x81,0x8f,0xb8,0xdb,0xe5,0xe5,0xe5,0xd3,0xb1,0x8e,0x9c,0xbf,0xde,0xe5, - 0xe5,0xe5,0xd1,0xab,0x82,0x81,0x88,0x98,0x9b,0x9b,0xb9,0xdc,0xff,0x27,0x0d,0xe6, - 0xc0,0x9a,0x81,0x81,0x81,0x81,0x81,0x92,0xba,0xdd,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5, - 0xe5,0xe5,0xe5,0xe5,0xcd,0xa6,0x81,0x81,0x81,0x81,0x88,0xb2,0xdd,0x09,0x21,0xf5, - 0xca,0xa0,0x93,0x8d,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81,0x81, - 0x90,0x93,0xb0,0xda,0x06,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x83,0xa5,0xbc,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0, - 0xbe,0xaa,0x8a,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x8c,0xa3,0xb4,0xbf,0xc2,0xc2,0xba,0xad,0xb9,0xba,0xba,0xb2, - 0x98,0x81,0x81,0x8b,0x9d,0xaa,0xb4,0xbb,0xc0,0xc0,0xbd,0xb5,0xa8,0x95,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x85,0x9a,0xac,0xb8,0xc0,0xc2,0xc2,0xbe,0xb6,0xaa, - 0x98,0x81,0x81,0x81,0x81,0x81,0x95,0xab,0xba,0xc2,0xc2,0xbc,0xaf,0xb3,0xb8,0xb8, - 0xb4,0x9f,0x81,0x81,0x81,0x81,0x86,0x9b,0xad,0xb9,0xc0,0xc2,0xc2,0xc0,0xba,0xb3, - 0xa8,0x92,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x89,0xa8,0xb9,0xba,0xba,0xb4,0x9b, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x1e,0xf2,0xc9,0xba,0xb8, - 0xbc,0xce,0xf3,0x1c,0x15,0xeb,0xc2,0x98,0x81,0x81,0xa1,0xb7,0xba,0xba,0xb8,0xa3, - 0x83,0x96,0xb1,0xba,0xba,0xba,0xac,0x8f,0x81,0x81,0xa1,0xb7,0xba,0xba,0xba,0xba, - 0xba,0xba,0xba,0xba,0xba,0xba,0xac,0x8f,0x81,0x90,0xb8,0xd9,0xda,0xcb,0xc1,0xbd, - 0xcd,0xef,0x16,0x17,0xef,0xc6,0x9c,0x81,0x81,0xa1,0xb7,0xba,0xba,0xb8,0xa3,0x83, - 0x92,0xae,0xba,0xba,0xba,0xba,0xa9,0x8b,0x81,0x81,0xa1,0xb7,0xba,0xba,0xba,0xba, - 0xba,0xba,0xba,0xba,0xba,0xba,0xac,0x8f,0x81,0x81,0xa1,0xb7,0xba,0xba,0xb5,0xab, - 0xba,0xba,0xba,0xae,0xb4,0xba,0xba,0xb8,0xa3,0x83,0x81,0x81,0xa1,0xb7,0xba,0xba, - 0xb8,0xa3,0x83,0x96,0xb1,0xba,0xba,0xba,0xac,0x8f,0x81,0x81,0x81,0x81,0x87,0x9c, - 0xaf,0xbb,0xc2,0xc2,0xc0,0xb8,0xaa,0x97,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16, - 0x19,0xed,0xc2,0xc0,0xbd,0xb5,0xa8,0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x95,0xab,0xbb,0xc2,0xc2,0xbb,0xc0,0xea,0x16,0x16,0xea,0xc0,0x95,0x81,0xa1,0xb7, - 0xba,0xba,0xb8,0xa3,0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x99,0xae, - 0xb7,0xbd,0xc0,0xc2,0xc2,0xc0,0xb8,0xab,0x99,0x83,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x98,0xab,0xb9,0xc0,0xc2,0xc2,0xbf,0xb9,0xac,0x92,0x81,0x81,0x81, - 0x8a,0xa2,0xb4,0xbf,0xc2,0xc1,0xb8,0xaa,0xb8,0xb8,0xb8,0xaa,0x8e,0x81,0x81,0x81, - 0x81,0x81,0x81,0x8e,0xab,0xba,0xba,0xba,0xb7,0xa1,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x89,0xa8,0xb9,0xba,0xba,0xb9,0xa6,0x9b,0xb4,0xba,0xba,0xba,0xb2,0x98, - 0x81,0x81,0x81,0x81,0x9f,0xb6,0xba,0xba,0xba,0xb2,0x98,0x81,0x83,0xa3,0xb8,0xba, - 0xba,0xba,0xb1,0x96,0x81,0x86,0xa8,0xc1,0xc5,0xc4,0xd5,0xf3,0x17,0x1d,0xf9,0xd3, - 0xae,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0xa1,0xb7,0xba,0xba,0xba,0xba,0xba,0xba, - 0xba,0xba,0xba,0xba,0xae,0x92,0x81,0x81,0x81,0x81,0x87,0xb1,0xda,0x05,0x24,0xfc, - 0xd5,0xc0,0xbd,0xb4,0x99,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x82,0xa3, - 0xb9,0xbd,0xc3,0xe3,0x0b,0x1e,0xf5,0xca,0xa1,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x93,0xbc,0xe1,0xea,0xea,0xea,0xea,0xea,0xea,0xea,0xea,0xea,0xea,0xea,0xea,0xea, - 0xe6,0xc3,0x9b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x8c,0x95,0x98,0x98,0x91,0x85,0x8f,0x90,0x90,0x8b, - 0x81,0x81,0x81,0x81,0x81,0x81,0x8b,0x92,0x95,0x95,0x93,0x8c,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x84,0x8f,0x95,0x98,0x98,0x94,0x8d,0x82, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x84,0x91,0x98,0x98,0x93,0x87,0x8a,0x8d,0x8d, - 0x8b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0x90,0x96,0x98,0x98,0x95,0x90,0x8a, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x84,0x8f,0x90,0x90,0x8c,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x94,0xbe,0xe7,0x11,0x25,0xff,0xed,0xe5,0xe2, - 0xe6,0xf1,0x0b,0x29,0x06,0xe0,0xb8,0x90,0x81,0x81,0x81,0x8e,0x90,0x90,0x8e,0x81, - 0x81,0x81,0x8a,0x90,0x90,0x90,0x87,0x81,0x81,0x81,0x81,0x8e,0x90,0x90,0x90,0x90, - 0x90,0x90,0x90,0x90,0x90,0x90,0x87,0x81,0x81,0x95,0xc0,0xea,0xff,0xf3,0xea,0xe7, - 0xf1,0x09,0x29,0x07,0xe1,0xb9,0x91,0x81,0x81,0x81,0x8e,0x90,0x90,0x8e,0x81,0x81, - 0x81,0x88,0x90,0x90,0x90,0x90,0x85,0x81,0x81,0x81,0x81,0x8e,0x90,0x90,0x90,0x90, - 0x90,0x90,0x90,0x90,0x90,0x90,0x87,0x81,0x81,0x81,0x81,0x8e,0x90,0x90,0x8d,0x86, - 0x90,0x90,0x90,0x88,0x8c,0x90,0x90,0x8e,0x81,0x81,0x81,0x81,0x81,0x8e,0x90,0x90, - 0x8e,0x81,0x81,0x81,0x8a,0x90,0x90,0x90,0x87,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x86,0x91,0x98,0x98,0x96,0x8f,0x83,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16, - 0x19,0xed,0xc2,0x98,0x93,0x8c,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x85,0x92,0x98,0x98,0x95,0xc0,0xea,0x16,0x16,0xea,0xc0,0x95,0x81,0x81,0x8e, - 0x90,0x90,0x8e,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85, - 0x8d,0x93,0x96,0x98,0x98,0x95,0x8e,0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x84,0x90,0x96,0x98,0x98,0x95,0x8f,0x85,0x81,0x81,0x81,0x81, - 0x81,0x81,0x8c,0x95,0x98,0x97,0x8f,0x84,0x8d,0x8d,0x8d,0x84,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x86,0x90,0x90,0x90,0x8e,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x84,0x8f,0x90,0x90,0x8f,0x82,0x81,0x8c,0x90,0x90,0x90,0x8b,0x81, - 0x81,0x81,0x81,0x81,0x81,0x8d,0x90,0x90,0x90,0x8b,0x81,0x81,0x81,0x81,0x8e,0x90, - 0x90,0x90,0x8a,0x81,0x81,0x94,0xbd,0xe4,0xef,0xed,0xf9,0x12,0x25,0x05,0xe2,0xbf, - 0x9a,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0x90,0x90,0x90,0x90,0x90,0x90, - 0x90,0x90,0x90,0x90,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0xa9,0xd2,0xfa,0x20,0x10, - 0xf5,0xea,0xe7,0xd5,0xaf,0x86,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x92,0xbb, - 0xdf,0xe7,0xec,0xfc,0x1d,0x12,0xeb,0xc3,0x99,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x95,0xc0,0xea,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16, - 0xf2,0xc8,0x9d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8b,0xb2,0xd8,0xfb,0x16,0x25,0x16,0x0f,0x0e, - 0x11,0x19,0x1f,0x09,0xec,0xcb,0xa7,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x1c,0x16,0x13, - 0x19,0x24,0x0d,0xee,0xcc,0xa8,0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16, - 0x19,0xed,0xc2,0x98,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x16,0xea,0xc0,0x95,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0x20,0x1d,0x05,0xe8,0xc8,0xa7, - 0x84,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9b,0xc1,0xe6,0x07,0x1f, - 0x1c,0x13,0x09,0xdd,0xb2,0x88,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x95,0xc0, - 0xea,0x13,0x16,0x21,0x18,0xfb,0xd9,0xb4,0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x95,0xc0,0xea,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09, - 0xf2,0xc8,0x9d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9e,0xbf,0xdb,0xf1,0xff,0x09,0x0e,0x0e, - 0x0b,0x04,0xf7,0xe5,0xcd,0xb0,0x91,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x94,0xbe,0xe6,0xfb,0x06,0x0b,0x0e, - 0x09,0xfc,0xea,0xd0,0xb2,0x91,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x09, - 0x09,0xed,0xc2,0x98,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x09,0x09,0xea,0xc0,0x95,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x0b,0x0b,0x05,0xf7,0xe3,0xca,0xac,0x8d, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x88,0xaa,0xca,0xe6,0xf9, - 0x04,0x09,0x09,0xdd,0xb2,0x88,0x95,0xc0,0xea,0x09,0x09,0xe7,0xbd,0x93,0x95,0xc0, - 0xea,0x09,0x09,0xff,0xf3,0xdd,0xbf,0x9e,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x90,0xb6,0xd6,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd, - 0xda,0xbd,0x97,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x83,0xa0,0xb8,0xca,0xd7,0xdf,0xe2,0xe2, - 0xdf,0xda,0xcf,0xc0,0xab,0x92,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x87,0xaa,0xc5,0xd3,0xdd,0xe2,0xe2, - 0xdf,0xd5,0xc5,0xaf,0x94,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x90,0xb6,0xd6,0xdd, - 0xdd,0xd8,0xb9,0x92,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x90,0xb6,0xd6,0xdd,0xdd,0xd6,0xb6,0x90,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x90,0xb6,0xd7,0xdf,0xdf,0xdb,0xd0,0xbf,0xa8,0x8e,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0xaa,0xc0,0xd1, - 0xda,0xdd,0xdd,0xce,0xab,0x83,0x90,0xb6,0xd6,0xdd,0xdd,0xd5,0xb4,0x8d,0x90,0xb6, - 0xd6,0xdd,0xdd,0xd7,0xcc,0xba,0xa1,0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x9b,0xaf,0xb2,0xb2,0xb2,0xb2,0xb2,0xb2,0xb2,0xb2,0xb2,0xb2,0xb2,0xb2,0xb2, - 0xb1,0xa0,0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x92,0xa2,0xad,0xb5,0xb8,0xb8, - 0xb6,0xb1,0xa7,0x99,0x87,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8b,0x9e,0xaa,0xb3,0xb8,0xb8, - 0xb5,0xac,0x9e,0x8c,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9b,0xaf,0xb2, - 0xb2,0xb0,0x9d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x9b,0xaf,0xb2,0xb2,0xaf,0x9b,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x9b,0xb1,0xb5,0xb5,0xb2,0xa8,0x99,0x85,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x87,0x9a,0xa8, - 0xb0,0xb2,0xb2,0xab,0x92,0x81,0x81,0x9b,0xaf,0xb2,0xb2,0xaf,0x99,0x81,0x81,0x9b, - 0xaf,0xb2,0xb2,0xae,0xa4,0x94,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x86,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88, - 0x87,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x84,0x8b,0x8d,0x8d, - 0x8c,0x87,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8a,0x8d,0x8d, - 0x8b,0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x86,0x88, - 0x88,0x86,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x86,0x88,0x88,0x86,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x88,0x8b,0x8b,0x88,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x86,0x88,0x88,0x83,0x81,0x81,0x81,0x81,0x86,0x88,0x88,0x86,0x81,0x81,0x81,0x81, - 0x86,0x88,0x88,0x84,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0x88,0x88,0x85,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8b,0xaf,0xcb,0xd0,0xd0,0xc9,0xad,0x88,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x98,0xae,0xb2,0xb2,0xae,0x98,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xbf,0xe9,0xfa,0xfa,0xe7,0xbd,0x92,0x81, - 0x81,0x81,0x81,0x81,0x81,0x85,0x8d,0x90,0x90,0x8d,0x89,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x85,0x85,0x81,0x81,0x81,0x84,0x85,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x86,0x8c,0x8d,0x8b,0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x89,0x90,0x90,0x8c,0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x89,0x91,0x93,0x90,0x89,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x8a,0x90,0x93,0x93,0x8f,0x86,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x87,0x8b,0x8b,0x8b,0x8a,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x84,0x88,0x88,0x88,0x88,0x88,0x88,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x85,0x90,0x90,0x90,0x85,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x8c,0x8d,0x8d,0x85,0x81,0x81,0x81,0x81,0x87,0x88,0x88,0x84,0x81,0x81, - 0x81,0x81,0x81,0x81,0x82,0x8f,0x90,0x90,0x88,0x81,0x81,0x81,0x81,0x8a,0x8b,0x8b, - 0x86,0x81,0x81,0x81,0x81,0x81,0x86,0x8e,0x90,0x90,0x88,0x81,0x81,0x81,0x81,0x81, - 0x87,0x88,0x88,0x84,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8b,0xb2,0xd3,0xdd,0xdd,0xd3,0xb2,0x8b, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0x88,0x88,0x82,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81, - 0x81,0x81,0x81,0x8d,0xa0,0xae,0xb7,0xba,0xba,0xb8,0xb2,0xa8,0x90,0x81,0x81,0x81, - 0x81,0x81,0x81,0x89,0xa0,0xaf,0xb0,0xa5,0x8f,0x9f,0xae,0xb0,0xa6,0x91,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x84,0x85,0x84,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x83,0x85,0x85,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x8e,0xa1,0xaf,0xb6,0xb8,0xb5,0xab,0x9c,0x8a,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x8e,0x98,0x98,0x98,0x98,0x98,0x98,0x98,0x92,0x81,0x81,0x81, - 0x81,0x81,0x91,0xa5,0xb3,0xba,0xba,0xb6,0xab,0x9a,0x84,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x90,0xa4,0xb3,0xbb,0xbd,0xba,0xb1,0xa1,0x8b,0x81,0x81,0x81,0x81,0x92,0xa9, - 0xb4,0xba,0xbd,0xbd,0xb9,0xaf,0x9e,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x98,0xaf,0xb5,0xb5,0xb5,0xb4,0xa2,0x84,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x8a,0x9a,0xa6,0xae,0xb2,0xb2,0xb2,0xb2,0xb2,0xb2,0xa6,0x8a,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x85,0x98,0xab,0xba,0xba,0xba,0xa9,0x8b,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x85,0x85,0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x91,0xa5,0xb6,0xb8,0xb8,0xac,0x90,0x81,0x83,0xa0,0xb1,0xb2,0xb2,0xac,0x94,0x81, - 0x81,0x81,0x81,0x93,0xa7,0xb9,0xba,0xba,0xae,0x92,0x81,0x84,0xa2,0xb4,0xb5,0xb5, - 0xae,0x96,0x81,0x81,0x81,0x9b,0xaf,0xb8,0xba,0xba,0xb0,0x9f,0x87,0x81,0x83,0xa0, - 0xb1,0xb2,0xb2,0xac,0x94,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x92,0xbb,0xe5,0x09,0x09,0xe5,0xba,0x90, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0x98,0xa6,0xaf,0xb2,0xb2,0xac,0xa0,0x8f, - 0x81,0x81,0x81,0x81,0x81,0x81,0x85,0x90,0x8d,0x81,0x81,0x81,0x81,0x81,0x8a,0x90, - 0x89,0x81,0x81,0x81,0x81,0x81,0x91,0xa4,0xa8,0xa8,0xa8,0x9c,0x83,0x81,0x81,0x81, - 0x9a,0xa7,0xa8,0xa8,0xa4,0x91,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81, - 0x81,0x81,0x96,0xb0,0xc6,0xd6,0xe1,0xe5,0xe5,0xe2,0xdc,0xcc,0xaa,0x82,0x81,0x81, - 0x81,0x81,0x84,0xa7,0xc4,0xd7,0xda,0xca,0xae,0xc3,0xd6,0xda,0xcb,0xb0,0x8f,0x81, - 0x81,0x81,0x81,0x81,0x81,0x8a,0x9b,0xa7,0xae,0xb0,0xae,0xa7,0x9b,0x8a,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x8b,0x9c,0xa7,0xad,0xb0,0xb0,0xaa,0x9d,0x8b,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x9b,0xb3,0xc7,0xd7,0xdf,0xe2,0xdf,0xd3,0xc2,0xad,0x94,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x94,0xb3,0xc2,0xc2,0xc2,0xc2,0xc2,0xc2,0xc2,0xb9,0x9d,0x81,0x81, - 0x81,0x98,0xb5,0xcb,0xdb,0xe4,0xe5,0xdf,0xd3,0xbf,0xa5,0x86,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x98,0xb3,0xc9,0xdb,0xe5,0xe7,0xe4,0xd9,0xc5,0xaa,0x8c,0x81,0x81,0x86,0xad,0xce, - 0xdd,0xe4,0xe7,0xe7,0xe2,0xd6,0xc1,0xa5,0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x98,0xb6,0xd4,0xdf,0xdf,0xdf,0xdc,0xbf,0x98,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x9a,0xaf,0xc2,0xcf,0xd7,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xc6,0xa1,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x84,0x98,0xab,0xbe,0xd1,0xe3,0xe5,0xe3,0xc6,0x9f,0x81,0x81,0x81,0x81, - 0x81,0x81,0x8a,0x9c,0xa9,0xb0,0xb0,0xab,0xa0,0x8f,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8c,0xa2, - 0xb6,0xcb,0xdf,0xe2,0xe2,0xcb,0xa5,0x81,0x9b,0xbe,0xda,0xdd,0xdd,0xd0,0xad,0x85, - 0x81,0x8e,0xa5,0xb9,0xcd,0xe1,0xe5,0xe5,0xcd,0xa6,0x81,0x9c,0xbf,0xdc,0xdf,0xdf, - 0xd2,0xae,0x86,0x81,0x91,0xb7,0xd5,0xe2,0xe5,0xe3,0xd8,0xc3,0xa4,0x81,0x9c,0xbf, - 0xda,0xdd,0xdd,0xd0,0xad,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x97,0xc1,0xea,0x16,0x0b,0xdf,0xb6,0x8c, - 0x81,0x81,0x81,0x81,0x81,0x81,0x8c,0xa8,0xbe,0xce,0xd9,0xdd,0xdd,0xd5,0xc7,0xb5, - 0x9e,0x84,0x81,0x81,0x81,0x94,0xaa,0xba,0xb5,0x9d,0x81,0x81,0x81,0x96,0xb1,0xba, - 0xaf,0x99,0x83,0x81,0x81,0x89,0xaf,0xcc,0xd2,0xd2,0xd2,0xbf,0x9e,0x81,0x81,0x99, - 0xbb,0xd1,0xd2,0xd2,0xcc,0xaf,0x89,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81, - 0x81,0x91,0xb2,0xd2,0xeb,0xfc,0x0b,0x11,0x11,0x0c,0x06,0xdd,0xb2,0x88,0x81,0x81, - 0x81,0x81,0x96,0xbe,0xe2,0xff,0x04,0xea,0xc7,0xe0,0xfc,0x04,0xec,0xc9,0xa3,0x81, - 0x81,0x81,0x81,0x81,0x99,0xaf,0xc2,0xd0,0xd7,0xda,0xd7,0xd0,0xc2,0xaf,0x98,0x81, - 0x81,0x81,0x81,0x81,0x8b,0xac,0xc4,0xd0,0xd7,0xda,0xda,0xd3,0xc5,0xae,0x90,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x9b,0xb9,0xd5,0xed,0xff,0x0b,0x0e,0x09,0xfb,0xe8,0xd0,0xb2,0x94,0x81,0x81,0x81, - 0x81,0x81,0x81,0xa6,0xce,0xec,0xed,0xed,0xed,0xed,0xed,0xed,0xd8,0xb0,0x86,0x81, - 0x94,0xb6,0xd4,0xef,0x04,0x0e,0x11,0x09,0xf9,0xe0,0xc2,0x9f,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x89,0xa0,0xa8,0xa8,0xa8,0x9b,0x81,0x81,0x81,0x81,0x81,0x81,0x8c, - 0xb3,0xd4,0xee,0x04,0x0f,0x13,0x0e,0xff,0xe6,0xc8,0xa4,0x81,0x81,0x8d,0xb8,0xe2, - 0x06,0x0e,0x13,0x13,0x0c,0xfb,0xe0,0xbe,0x98,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x98,0xb6,0xd4,0xf1,0x0b,0x0b,0x0a,0xef,0xc7,0x9d,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9d, - 0xbb,0xd5,0xe8,0xf7,0x04,0x06,0x09,0x09,0x09,0x09,0xfc,0xd2,0xa8,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x82,0xa5,0xbe,0xd1,0xe3,0xf6,0x0a,0x11,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x81, - 0x81,0x92,0xad,0xc2,0xd2,0xda,0xda,0xd5,0xc8,0xb3,0x99,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0xa9,0xc7, - 0xdb,0xef,0x04,0x0e,0xff,0xd5,0xab,0x8e,0xb2,0xd5,0xf9,0x09,0x06,0xdf,0xb5,0x8b, - 0x86,0xab,0xc9,0xde,0xf1,0x06,0x11,0xff,0xd5,0xab,0x8f,0xb2,0xd5,0xf9,0x0b,0x04, - 0xde,0xb5,0x8a,0x81,0x98,0xc2,0xed,0x0b,0x11,0x0e,0xfc,0xdf,0xba,0x93,0xb3,0xd6, - 0xf9,0x09,0x05,0xdf,0xb5,0x8b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x8a,0x9c,0xaa,0xc6,0xef,0x1b,0x05,0xda,0xb1,0x90, - 0x81,0x81,0x81,0x81,0x81,0x8a,0xaa,0xc8,0xe3,0xf6,0x04,0x09,0x06,0xfc,0xee,0xd9, - 0xbf,0xa2,0x81,0x81,0xa1,0xb9,0xce,0xe3,0xd9,0xb7,0x94,0x8b,0x8b,0xaf,0xd2,0xe5, - 0xd3,0xbd,0xa6,0x87,0x81,0x93,0xbd,0xe7,0xfc,0xfc,0xfb,0xd7,0xb2,0x8e,0x89,0xae, - 0xd3,0xf7,0xfc,0xfc,0xe7,0xbd,0x93,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81, - 0x81,0xa5,0xcb,0xee,0x0d,0x25,0x14,0x0e,0x0e,0x12,0x09,0xdd,0xb2,0x88,0x81,0x81, - 0x81,0x81,0x9d,0xc8,0xf2,0x1c,0x25,0xfc,0xd2,0xef,0x19,0x27,0xff,0xd5,0xab,0x81, - 0x81,0x81,0x81,0x9b,0xb9,0xd3,0xe8,0xf9,0x04,0x06,0x04,0xf9,0xe8,0xd3,0xb9,0x9b, - 0x81,0x81,0x81,0x81,0x99,0xc3,0xe8,0xf9,0xff,0x06,0x04,0xfb,0xe9,0xcc,0xab,0x86, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x92, - 0xb6,0xd7,0xf5,0x11,0x0d,0xff,0xfa,0xff,0x12,0x0b,0xee,0xcf,0xac,0x88,0x81,0x81, - 0x81,0x81,0x81,0xa8,0xd2,0xfc,0x19,0x19,0x19,0x19,0x19,0x09,0xdd,0xb2,0x88,0x81, - 0xa8,0xcd,0xf1,0x10,0x1a,0x0b,0x09,0x15,0x1c,0xfc,0xd9,0xb4,0x8c,0x81,0x81,0x81, - 0x81,0x81,0x81,0xa3,0xc4,0xd2,0xd2,0xd2,0xbd,0x9a,0x81,0x81,0x81,0x81,0x81,0x93, - 0xbd,0xe7,0x0b,0x1e,0x11,0x0e,0x1a,0x23,0x04,0xdc,0xb5,0x8c,0x81,0x8d,0xb8,0xe2, - 0x0e,0x0b,0x09,0x0b,0x1f,0x1c,0xf6,0xce,0xa5,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x95,0xb6,0xd4,0xf1,0x10,0x1b,0xff,0xe8,0xce,0xb4,0x91,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x96,0xb9, - 0xd9,0xf7,0x0f,0x20,0x2b,0x2c,0x16,0x16,0x17,0x29,0xfc,0xd2,0xa8,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x91,0xba,0xe0,0xf6,0x0a,0x1d,0x23,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x81, - 0x8e,0xb0,0xce,0xe8,0xfa,0x04,0x06,0xfc,0xee,0xd5,0xb6,0x94,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x90,0xba,0xe3, - 0xff,0x15,0x17,0x2a,0xff,0xd5,0xab,0xa5,0xc9,0xec,0x0f,0x12,0xef,0xcb,0xa8,0x82, - 0x90,0xba,0xe4,0x04,0x18,0x14,0x28,0xff,0xd5,0xab,0xa6,0xc9,0xed,0x10,0x10,0xed, - 0xc9,0xa6,0x81,0x81,0x98,0xc2,0xed,0x04,0xff,0x17,0x19,0xef,0xc5,0xa6,0xca,0xed, - 0x11,0x12,0xee,0xcb,0xa7,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x86,0x96,0x9b,0x97,0x88,0x81, - 0x81,0x81,0x81,0x81,0x81,0x96,0xaf,0xc3,0xd2,0xdd,0xf5,0x20,0xff,0xd5,0xc9,0xb2, - 0x8f,0x81,0x81,0x81,0x81,0xa0,0xc5,0xe6,0x05,0x1d,0x1f,0x19,0x1a,0x24,0x13,0xfb, - 0xdc,0xb4,0x8a,0x92,0xba,0xdd,0xf3,0x09,0xf1,0xce,0xb2,0xb5,0xb5,0xc5,0xe8,0x0d, - 0xf7,0xe1,0xc1,0x99,0x81,0x8d,0xb4,0xd9,0xfc,0x21,0x11,0xec,0xc7,0xa3,0x9e,0xc2, - 0xe7,0x0c,0x22,0xfc,0xd9,0xb4,0x8d,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81, - 0x89,0xb3,0xdb,0x04,0x29,0x05,0xec,0xe3,0xe2,0xe7,0xf1,0xda,0xb1,0x87,0x81,0x81, - 0x81,0x81,0x9b,0xc3,0xeb,0x0d,0x12,0xf4,0xcd,0xe8,0x0b,0x13,0xf6,0xd0,0xa8,0x81, - 0x81,0x81,0x98,0xb9,0xd7,0xf5,0x0d,0x20,0x14,0x11,0x14,0x20,0x0d,0xf3,0xd7,0xb8, - 0x96,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b,0x12,0x0e,0x12,0x23,0x09,0xe5,0xbd,0x95, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa6, - 0xcc,0xf1,0x13,0x05,0x04,0x04,0x04,0xfb,0xef,0x0d,0x0b,0xe7,0xc2,0x9b,0x81,0x81, - 0x81,0x81,0x81,0xa8,0xd2,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0xdd,0xb2,0x88,0x8e, - 0xb7,0xe0,0x07,0x1e,0xfa,0xe1,0xdf,0xf3,0x17,0x12,0xea,0xc1,0x98,0x81,0x81,0x81, - 0x81,0x81,0x85,0xb0,0xda,0xfc,0xfc,0xf9,0xcf,0xa5,0x81,0x81,0x81,0x81,0x81,0x89, - 0xaf,0xd0,0xf0,0xf9,0xe7,0xe4,0xfb,0x23,0x11,0xe7,0xbd,0x93,0x81,0x8c,0xb5,0xdc, - 0xeb,0xe2,0xdd,0xe3,0x09,0x29,0xfc,0xd2,0xa8,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0xa9,0xd0,0xf1,0x10,0x13,0xf9,0xe0,0xc6,0xac,0x93,0x81,0x81,0x81,0x81,0x8e,0x90, - 0x90,0x8e,0x81,0x81,0x81,0x8b,0x90,0x90,0x90,0x85,0x81,0x81,0x81,0x82,0xaa,0xcf, - 0xf4,0x16,0x32,0x47,0x50,0x26,0xfa,0xea,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x91,0xbb,0xe2,0x09,0x18,0x05,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x81, - 0xa4,0xc8,0xec,0x0b,0x21,0x14,0x14,0x22,0x10,0xf1,0xce,0xa8,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8c,0xb4,0xdb, - 0xff,0x06,0xf7,0x23,0xff,0xd5,0xab,0xbd,0xe0,0x04,0x1f,0xfb,0xd8,0xb5,0x91,0x81, - 0x8b,0xb3,0xda,0xff,0x04,0xf7,0x23,0xff,0xd5,0xab,0xbd,0xe0,0x04,0x1d,0xf9,0xd5, - 0xb2,0x8e,0x81,0x81,0x92,0xb9,0xda,0xed,0xee,0x0f,0x15,0xed,0xc4,0xbd,0xe0,0x05, - 0x1e,0xfa,0xd7,0xb4,0x90,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0x9a,0x9b,0x91, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0xaa,0xbe,0xc5,0xbf,0xad,0x92, - 0x81,0x81,0x81,0x81,0x98,0xb6,0xd2,0xe8,0xfa,0x06,0x0b,0x26,0x06,0xfc,0xee,0xc6, - 0x9d,0x81,0x81,0x81,0x8b,0xb2,0xd9,0xff,0x22,0x10,0xf7,0xed,0xef,0xfc,0x14,0xf5, - 0xd5,0xb0,0x88,0x94,0xbe,0xe6,0x07,0x29,0x09,0xe5,0xdc,0xdf,0xde,0xdc,0xff,0x23, - 0x0d,0xec,0xc6,0x9c,0x81,0x81,0x9e,0xc2,0xe7,0x0c,0x26,0xff,0xdc,0xb8,0xb2,0xd6, - 0xfb,0x21,0x0c,0xe8,0xc4,0x9f,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81, - 0x8d,0xb8,0xe2,0x0e,0x23,0xf7,0xcd,0xba,0xb9,0xbf,0xc7,0xbd,0xa0,0x81,0x81,0x81, - 0x81,0x81,0x8c,0xb1,0xd0,0xe7,0xea,0xd7,0xb9,0xce,0xe6,0xea,0xd9,0xbb,0x98,0x81, - 0x81,0x8a,0xaf,0xd3,0xf5,0x14,0x12,0xfa,0xeb,0xe5,0xec,0xfc,0x16,0x14,0xf3,0xd0, - 0xac,0x87,0x81,0x81,0x9b,0xc5,0xef,0xf4,0xe8,0xe2,0xeb,0x0d,0x1b,0xf1,0xc7,0x9d, - 0x81,0x81,0x81,0x81,0x81,0x8b,0x9d,0x9e,0x8f,0x81,0x85,0x99,0x9d,0x8f,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8b,0xb4, - 0xdc,0x04,0x0f,0xe9,0x04,0x06,0xfc,0x13,0xfc,0xf3,0x18,0xfa,0xd2,0xaa,0x81,0x81, - 0x81,0x81,0x81,0x9e,0xc1,0xd5,0xd5,0xd5,0xd5,0xd5,0xd5,0xd5,0xc8,0xa7,0x81,0x95, - 0xbf,0xe9,0x13,0x11,0xe7,0xbf,0xb8,0xe0,0x0a,0x1c,0xf2,0xc8,0x9d,0x81,0x81,0x81, - 0x81,0x81,0x85,0xb0,0xda,0x06,0x26,0xfa,0xd0,0xa5,0x81,0x81,0x81,0x81,0x81,0x81, - 0x94,0xb5,0xd3,0xd6,0xc0,0xd2,0xf7,0x21,0x11,0xe7,0xbd,0x92,0x81,0x81,0xa1,0xbb, - 0xd4,0xea,0xea,0xf3,0x11,0x18,0xf4,0xcd,0xa4,0x81,0x81,0x81,0x81,0x81,0x81,0x82, - 0xab,0xd4,0xef,0xef,0xef,0xd8,0xbe,0xa5,0x8b,0x81,0x81,0x81,0x81,0xa1,0xb7,0xba, - 0xba,0xb8,0xa3,0x83,0x9a,0xb3,0xba,0xba,0xba,0xa9,0x8b,0x81,0x81,0x8e,0xb8,0xe0, - 0x09,0x2e,0x51,0x6d,0x50,0x26,0xfa,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x84,0xab,0xd2,0xf7,0xf1,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x8b, - 0xb4,0xdb,0x04,0x26,0x04,0xec,0xeb,0xff,0x24,0x06,0xdf,0xb6,0x8d,0x81,0x81,0x81, - 0x94,0x9d,0x96,0x81,0x81,0x94,0xa0,0x9a,0x84,0x81,0x81,0x81,0x81,0x81,0xa2,0xc8, - 0xe9,0xe0,0xf7,0x23,0xff,0xd5,0xb0,0xd3,0xf7,0x1a,0x07,0xe4,0xc1,0x9d,0x81,0x81, - 0x81,0xa1,0xc7,0xe7,0xde,0xf7,0x23,0xff,0xd5,0xb1,0xd4,0xf7,0x1b,0x05,0xe2,0xbf, - 0x9b,0x81,0x81,0x81,0x8b,0xb5,0xdf,0x0b,0x19,0x21,0xff,0xec,0xc9,0xd4,0xf7,0x1b, - 0x07,0xe3,0xc0,0x9c,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9b,0xb4,0xc4,0xc5,0xb8, - 0xa1,0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x84,0xa9,0xca,0xe5,0xef,0xe7,0xce,0xae, - 0x88,0x81,0x81,0x8e,0xb1,0xd3,0xf1,0x0d,0x21,0x1d,0x16,0x25,0x19,0x1e,0xf2,0xc8, - 0x9d,0x81,0x81,0x81,0x94,0xbe,0xe7,0x11,0x1e,0xf6,0xd5,0xc4,0xc7,0xd9,0xef,0xd9, - 0xb9,0x9a,0x81,0x87,0xaa,0xcc,0xee,0x0f,0x20,0xfb,0x05,0x0b,0x09,0xfc,0x17,0x15, - 0xf3,0xd2,0xb1,0x8e,0x81,0x81,0x89,0xad,0xd2,0xf5,0x1a,0x17,0xf1,0xcd,0xc7,0xec, - 0x11,0x1b,0xf6,0xd2,0xae,0x8a,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81, - 0x8c,0xb6,0xdf,0x09,0x2c,0x09,0xec,0xd4,0xbf,0xa9,0x9d,0x97,0x82,0x81,0x81,0x81, - 0x81,0x81,0x81,0x94,0xae,0xbe,0xc0,0xb3,0x9b,0xad,0xbd,0xc0,0xb4,0x9d,0x81,0x81, - 0x81,0x9b,0xc2,0xe8,0x0d,0x16,0xf3,0xd7,0xd5,0xdd,0xdd,0xda,0xf7,0x1a,0x0b,0xe6, - 0xc0,0x99,0x81,0x81,0x92,0xb5,0xcf,0xe3,0xef,0xf5,0xf5,0x09,0x1e,0xf2,0xc8,0x9d, - 0x81,0x81,0x81,0x81,0x88,0xaa,0xc5,0xc8,0xb5,0xa2,0xa5,0xc0,0xc6,0xb5,0xa1,0x8a, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x94,0xbd, - 0xe7,0x11,0xff,0xd7,0x04,0x06,0xe8,0x0b,0xff,0xe1,0x0b,0x06,0xdd,0xb3,0x89,0x81, - 0x81,0x81,0x81,0x85,0x9f,0xaa,0xab,0xab,0xab,0xab,0xab,0xab,0xa3,0x8c,0x81,0x95, - 0xc0,0xea,0x15,0x11,0xe7,0xbd,0xb6,0xdf,0x09,0x1b,0xf2,0xc8,0x9d,0x81,0x81,0x81, - 0x8e,0x90,0x90,0xb0,0xda,0x06,0x26,0xfa,0xd0,0xa5,0x90,0x90,0x8b,0x81,0x81,0x81, - 0x81,0x97,0xac,0xba,0xd4,0xf0,0x0f,0x24,0xff,0xdb,0xb4,0x8b,0x81,0x81,0x85,0xb0, - 0xda,0x06,0x16,0x1b,0x19,0xf7,0xe3,0xc7,0xa5,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x9a,0xb8,0xc5,0xc5,0xc5,0xb6,0x9d,0x83,0x81,0x81,0x81,0x81,0x92,0xba,0xdd,0xe5, - 0xe5,0xde,0xbc,0x94,0xb0,0xd5,0xe5,0xe5,0xe3,0xc6,0x9f,0x81,0x81,0x95,0xbf,0xe9, - 0x13,0x3c,0x66,0x7b,0x50,0x26,0xfa,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x99,0xbd,0xd4,0xcd,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x94, - 0xbd,0xe7,0x11,0x17,0xee,0xc8,0xc5,0xed,0x16,0x13,0xe7,0xbe,0x94,0x81,0x91,0xa5, - 0xba,0xc8,0xbc,0x9e,0xa6,0xb9,0xca,0xc0,0xa2,0x81,0x81,0x81,0x81,0x81,0x8e,0xae, - 0xc1,0xcd,0xf7,0x23,0xff,0xd5,0xc7,0xeb,0x0f,0x14,0xf1,0xcd,0xa9,0x86,0x81,0x81, - 0x81,0x8d,0xac,0xbf,0xcd,0xf7,0x23,0xff,0xd5,0xc8,0xec,0x0f,0x12,0xee,0xcb,0xa7, - 0x84,0x81,0x81,0x81,0x92,0xb5,0xdd,0xf5,0xf5,0x05,0x27,0xff,0xd7,0xec,0x0f,0x13, - 0xf0,0xcc,0xa9,0x86,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xb9,0xd7,0xec,0xef,0xdd, - 0xbf,0x9b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x8b,0x94,0x95,0x91,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x92,0xbb,0xe2,0x07,0x1b,0x0b,0xe7,0xc0, - 0x98,0x81,0x81,0xa1,0xc7,0xec,0x0f,0x27,0x0b,0xf5,0x06,0x19,0xef,0xfc,0xf2,0xc8, - 0x9d,0x81,0x81,0x81,0x9b,0xc5,0xef,0x19,0x14,0xea,0xc1,0x9a,0x9f,0xb7,0xc5,0xba, - 0x9d,0x81,0x81,0x81,0x91,0xb2,0xd4,0xf5,0x18,0x21,0x1f,0x16,0x1b,0x26,0x1e,0xfb, - 0xd9,0xb8,0x97,0x81,0x81,0x81,0x81,0x98,0xbc,0xe0,0x05,0x2a,0x07,0xe2,0xdb,0xff, - 0x25,0x05,0xe1,0xbd,0x99,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81, - 0x94,0xb5,0xd4,0xf1,0x14,0x27,0x0f,0xf9,0xe3,0xcd,0xb5,0x9c,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x88,0x94,0x95,0x8c,0x81,0x87,0x94,0x95,0x8d,0x81,0x81,0x81, - 0x81,0xaa,0xd2,0xfa,0x21,0xff,0xdb,0xe8,0xfc,0x07,0x07,0xff,0xe4,0x05,0x1e,0xf7, - 0xcf,0xa7,0x81,0x81,0xa7,0xcd,0xee,0x09,0x19,0x16,0x16,0x18,0x1e,0xf2,0xc8,0x9d, - 0x81,0x81,0x81,0x81,0x9e,0xc2,0xe6,0xee,0xdb,0xc6,0xbd,0xe0,0xee,0xda,0xc5,0xa7, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0, - 0xea,0x16,0xfa,0xd7,0x04,0x12,0x11,0x04,0xea,0xda,0x06,0x0b,0xdf,0xb5,0x8b,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x91, - 0xbb,0xe4,0x0c,0x1b,0xf5,0xdc,0xda,0xf1,0x14,0x11,0xe8,0xc0,0x97,0x81,0x81,0xa1, - 0xb7,0xba,0xba,0xba,0xda,0x06,0x26,0xfa,0xd0,0xba,0xba,0xba,0xb3,0x9a,0x81,0x81, - 0x8e,0xa8,0xc2,0xdb,0xf5,0x10,0x22,0x07,0xe8,0xc7,0xa2,0x81,0x81,0x81,0x8a,0xb0, - 0xda,0xff,0xff,0x04,0x12,0x1e,0x04,0xdf,0xb7,0x8e,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x93,0x9b,0x9b,0x9b,0x91,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x11, - 0x11,0xed,0xc2,0x98,0xb5,0xdf,0x0b,0x11,0xf7,0xcd,0xa3,0x81,0x81,0x95,0xc0,0xea, - 0x16,0x40,0x69,0x7b,0x50,0x26,0xfa,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x81,0x81, - 0x81,0x82,0x8b,0x8a,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x9c,0xaa,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x9a,0x84,0x81,0x95, - 0xc0,0xea,0x16,0x13,0xe7,0xbd,0xbd,0xe7,0x13,0x16,0xea,0xc0,0x95,0x8b,0xaf,0xcb, - 0xdf,0xf2,0xd9,0xb5,0xcc,0xdf,0xf3,0xdd,0xb9,0x96,0x81,0x81,0x81,0x81,0x81,0x8b, - 0xa3,0xcd,0xf7,0x23,0xff,0xd5,0xde,0xff,0x20,0xfc,0xd9,0xb6,0x92,0x81,0x81,0x81, - 0x81,0x81,0x88,0xa3,0xcd,0xf7,0x23,0xff,0xd5,0xdf,0x04,0x1e,0xfb,0xd8,0xb4,0x91, - 0x81,0x81,0x81,0x81,0x9d,0xc7,0xf1,0xf7,0xf5,0x09,0x25,0xff,0xdf,0x04,0x20,0xfc, - 0xd9,0xb5,0x92,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa4,0xcd,0xf3,0x13,0x17,0xfa, - 0xd4,0xac,0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x88,0xa1,0xb4,0xbe,0xc0,0xbb,0xac,0x97,0x81,0x93,0xa1,0xa3,0xa3,0x9c, - 0x86,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x15,0x3c,0x1a,0xef,0xc5, - 0x9b,0x81,0x88,0xb0,0xd8,0xff,0x26,0x0d,0xea,0xe2,0x0b,0x13,0xe8,0xd5,0xda,0xbd, - 0x97,0x81,0x81,0x99,0xad,0xc5,0xef,0x1b,0x13,0xe7,0xbd,0xb0,0xb0,0xb0,0xad,0x9b, - 0x81,0x81,0x81,0x81,0x81,0xa6,0xcd,0xf4,0x19,0x18,0xfa,0xea,0xf4,0x10,0x26,0xff, - 0xd9,0xb1,0x89,0x81,0x81,0x81,0x81,0x82,0xa7,0xcb,0xef,0x14,0x1b,0xf5,0xef,0x14, - 0x14,0xf0,0xcb,0xa7,0x83,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x82, - 0xa8,0xcd,0xf1,0x10,0x1c,0x09,0x1e,0x1d,0x07,0xf0,0xd7,0xbd,0x9f,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x8c,0xb5,0xde,0x07,0x19,0xf1,0xe6,0x09,0x21,0x0e,0x0b,0x11,0xe5,0xf5,0x1d,0x04, - 0xdb,0xb2,0x89,0x8a,0xb4,0xdd,0x06,0x23,0xfc,0xec,0xea,0x09,0x1e,0xf2,0xc8,0x9d, - 0x81,0x81,0x81,0x91,0xb5,0xd9,0xfc,0x14,0xff,0xdd,0xd5,0xf7,0x13,0xff,0xdf,0xb5, - 0x8b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x94,0xbd, - 0xe7,0x11,0xff,0xd7,0x04,0x06,0xfb,0x10,0xeb,0xe1,0x0a,0x07,0xdd,0xb3,0x8a,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x86, - 0xaf,0xd5,0xfa,0x1b,0x14,0x06,0x04,0x11,0x1a,0xfb,0xd7,0xb2,0x8b,0x81,0x92,0xba, - 0xdd,0xe5,0xe5,0xe5,0xe5,0x06,0x26,0xfa,0xe5,0xe5,0xe5,0xe5,0xd5,0xb0,0x88,0x88, - 0xac,0xc9,0xe3,0xfc,0x17,0x1a,0xff,0xe6,0xd0,0xcf,0xbd,0x9b,0x81,0x87,0xaa,0xc3, - 0xc6,0xd5,0xd5,0xda,0xf6,0x21,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16, - 0x19,0xed,0xc2,0x98,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x92,0xbc,0xe6, - 0x0f,0x38,0x60,0x7b,0x50,0x26,0xfa,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x81,0x81, - 0x96,0xaa,0xb5,0xb4,0xa8,0x94,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x9b,0xbb,0xca,0xca,0xdf,0x0b,0x23,0xf7,0xcd,0xca,0xc0,0xa1,0x81,0x94, - 0xbe,0xe7,0x13,0x16,0xed,0xc7,0xc8,0xef,0x17,0x11,0xe7,0xbd,0x93,0x95,0xbf,0xe9, - 0x04,0x13,0xf0,0xcd,0xe7,0x05,0x18,0xf3,0xd0,0xac,0x89,0x81,0x81,0x81,0x81,0x81, - 0xa3,0xcd,0xf7,0x16,0xff,0xd5,0xf5,0x19,0x09,0xe6,0xc2,0x9e,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0xa3,0xcd,0xf7,0x13,0xff,0xd5,0xf5,0x19,0x07,0xe3,0xc0,0x9d,0x81, - 0x81,0x81,0x81,0x81,0x9d,0xc8,0xf2,0x19,0x1b,0x14,0x05,0xea,0xf5,0x19,0x09,0xe5, - 0xc2,0x9e,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa8,0xd2,0xfc,0x28,0x2f,0x06, - 0xda,0xb0,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x86,0xa7,0xc4,0xda,0xe7,0xea,0xe3,0xd2,0xba,0x9f,0xb4,0xcb,0xcd,0xcd,0xc2, - 0xa3,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x90,0xb9,0xdf,0xff,0x13,0x05,0xe3,0xbd, - 0x95,0x81,0x91,0xba,0xe4,0x0d,0x23,0xfa,0xd3,0xe7,0x11,0x0e,0xe2,0xb9,0xb1,0xa0, - 0x82,0x81,0x8f,0xb5,0xd4,0xda,0xef,0x1b,0x13,0xe7,0xda,0xda,0xda,0xda,0xd5,0xb7, - 0x91,0x81,0x81,0x81,0x88,0xb1,0xda,0x04,0x2c,0x04,0xde,0xc1,0xd4,0xfa,0x23,0x0e, - 0xe5,0xbb,0x92,0x81,0x81,0x81,0x81,0x81,0x91,0xb5,0xda,0xff,0x22,0x0a,0x04,0x22, - 0xff,0xda,0xb6,0x92,0x81,0x81,0x81,0x94,0xbd,0xe4,0xef,0xef,0xe2,0xbb,0x91,0x8f, - 0xb8,0xe0,0x07,0x24,0xff,0xe3,0xfa,0x0f,0x26,0x12,0xf7,0xda,0xba,0x96,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x92,0xbc,0xe6,0x11,0x11,0xe7,0xf9,0x20,0x05,0xe7,0xe1,0xed,0xe1,0xea,0x13,0x0d, - 0xe2,0xb9,0x8f,0x8b,0xb5,0xdf,0x0b,0x1e,0xf5,0xe4,0xf5,0x10,0x1e,0xf2,0xc8,0x9d, - 0x81,0x81,0x85,0xa8,0xcc,0xef,0x13,0x15,0xf1,0xce,0xee,0x10,0x17,0xf4,0xd2,0xad, - 0x85,0x81,0x91,0xa2,0xa5,0xa5,0xa5,0xa5,0xa5,0xa5,0xa5,0xa5,0xa5,0xa5,0xa2,0x91, - 0x81,0x81,0x95,0xa8,0xab,0xab,0xab,0xab,0xab,0xab,0xab,0xa8,0x95,0x81,0x8c,0xb5, - 0xdd,0x05,0x0d,0xe8,0x04,0x06,0xe9,0x11,0xfc,0xf1,0x17,0xfb,0xd3,0xab,0x82,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x9c,0xbf,0xdf,0xf9,0x0b,0x14,0x14,0x0b,0xf7,0xdd,0xbf,0x9d,0x81,0x81,0x95,0xc0, - 0xea,0x11,0x11,0x11,0x11,0x12,0x2a,0x11,0x11,0x11,0x11,0x0b,0xdf,0xb5,0x8b,0x95, - 0xbf,0xe7,0x05,0x1f,0x16,0xfa,0xfa,0xfa,0xfa,0xf9,0xd2,0xa8,0x81,0x94,0xbe,0xe6, - 0xef,0xeb,0xea,0xef,0x04,0x27,0x0c,0xe4,0xba,0x91,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16, - 0x19,0xed,0xc2,0x98,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x8a,0xb3,0xdb, - 0xff,0x27,0x47,0x5e,0x50,0x26,0xfa,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x81,0x99, - 0xb8,0xd1,0xdf,0xdd,0xce,0xb4,0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0xaa,0xd3,0xf5,0xf5,0xf5,0x0b,0x23,0xf7,0xf5,0xf5,0xdb,0xb2,0x88,0x8d, - 0xb6,0xdf,0x06,0x25,0x04,0xeb,0xeb,0x04,0x26,0xff,0xdb,0xb3,0x8b,0x90,0xb6,0xda, - 0xfc,0x1f,0x09,0xe5,0xd6,0xf9,0x1d,0x0b,0xe7,0xc3,0x9f,0x81,0x81,0x81,0x81,0x81, - 0xa0,0xc8,0xe8,0xea,0xea,0xe8,0x0d,0x15,0xf1,0xce,0xab,0x8b,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x9f,0xc7,0xe6,0xe7,0xe7,0xe9,0x0d,0x14,0xf0,0xcd,0xa9,0x8b,0x81, - 0x81,0x81,0x81,0x81,0x9b,0xc3,0xe6,0xee,0xef,0xec,0xdf,0xe9,0x0d,0x14,0xf1,0xce, - 0xaa,0x8d,0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa2,0xc9,0xef,0x0c,0x0f,0xf5, - 0xd1,0xa9,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x9e,0xc2,0xe3,0xff,0x11,0x16,0x0b,0xf5,0xdb,0xbd,0xc7,0xef,0xf7,0xf7,0xdc, - 0xb2,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa4,0xc5,0xde,0xe7,0xe0,0xc8,0xa9, - 0x85,0x81,0x95,0xc0,0xea,0x14,0x1b,0xf2,0xc8,0xed,0x17,0x09,0xdd,0xb4,0x8a,0x81, - 0x81,0x81,0x95,0xc0,0xea,0x06,0x06,0x1c,0x14,0x06,0x06,0x06,0x06,0x06,0xed,0xc2, - 0x98,0x81,0x81,0x81,0x8d,0xb8,0xe2,0x0b,0x23,0xfa,0xd0,0xa7,0xc7,0xf1,0x1b,0x14, - 0xea,0xc0,0x95,0x81,0x81,0x81,0x81,0x96,0xaf,0xb8,0xc5,0xe8,0x0d,0x1f,0x1a,0x0d, - 0xe8,0xc5,0xb8,0xae,0x94,0x81,0x81,0x86,0xa8,0xc1,0xc5,0xc5,0xc0,0xa7,0x84,0x95, - 0xc0,0xea,0x13,0x16,0xed,0xc5,0xd5,0xec,0x04,0x1f,0x16,0xf4,0xd1,0xab,0x83,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x95,0xc0,0xea,0x15,0x0b,0xe1,0x04,0x1f,0xf5,0xcd,0xb8,0xc6,0xc1,0xe4,0x0e,0x12, - 0xe7,0xbd,0x93,0x86,0xb0,0xd8,0xff,0x21,0x14,0x0e,0x18,0xff,0x1e,0xf2,0xc8,0x9d, - 0x81,0x81,0x9c,0xbf,0xe3,0x06,0x21,0xfc,0xdb,0xe3,0x05,0x20,0xfc,0xdb,0xb9,0x97, - 0x81,0x8b,0xaf,0xcb,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xcb,0xaf, - 0x8b,0x8d,0xb2,0xcf,0xd5,0xd5,0xd5,0xd5,0xd5,0xd5,0xd5,0xcf,0xb2,0x8d,0x81,0xa6, - 0xcd,0xf1,0x14,0x04,0x04,0x04,0xda,0xff,0x04,0x0b,0x0c,0xe8,0xc2,0x9c,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x83,0xa3,0xbf,0xd4,0xe3,0xea,0xea,0xe2,0xd3,0xbd,0xa1,0x83,0x81,0x81,0x95,0xc0, - 0xea,0x0e,0x0e,0x0e,0x0e,0x0f,0x29,0x0e,0x0e,0x0e,0x0e,0x0b,0xdf,0xb5,0x8b,0x95, - 0xc0,0xea,0x16,0x29,0x29,0x26,0x26,0x26,0x26,0xfc,0xd2,0xa8,0x81,0x95,0xc0,0xea, - 0x16,0x16,0x16,0x19,0x23,0x11,0xf5,0xd3,0xad,0x86,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16, - 0x19,0xed,0xc2,0x98,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0xa3,0xc8, - 0xec,0x0b,0x25,0x36,0x41,0x26,0xfa,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x89,0xaf, - 0xd4,0xf3,0x09,0x06,0xf0,0xd0,0xab,0x84,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0xab,0xd5,0xff,0x21,0x21,0x23,0x29,0x21,0x21,0x09,0xdd,0xb2,0x88,0x81, - 0xa8,0xce,0xf1,0x10,0x23,0x14,0x14,0x21,0x0a,0xeb,0xc8,0xa2,0x81,0x81,0x9f,0xc1, - 0xe3,0x06,0x20,0xfc,0xda,0xe3,0x06,0x21,0xfc,0xda,0xb6,0x93,0x81,0x81,0x81,0x81, - 0x8e,0xae,0xbf,0xc0,0xdc,0xff,0x22,0xfc,0xdb,0xb7,0xb5,0xb5,0xa7,0x8a,0x81,0x81, - 0x81,0x81,0x81,0x8d,0xac,0xbc,0xbd,0xdd,0xff,0x20,0xfc,0xd9,0xc0,0xbd,0xb3,0xa0, - 0x85,0x81,0x81,0x81,0x8a,0xaa,0xbe,0xc5,0xc5,0xc2,0xdd,0xff,0x21,0xfc,0xda,0xb8, - 0xb8,0xb7,0xa9,0x8c,0x81,0x81,0x81,0x81,0x81,0x81,0x91,0xb4,0xd2,0xe5,0xe7,0xd6, - 0xb9,0x98,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x86,0xaf,0xd6,0xfb,0x1f,0x14,0x0e,0x1f,0x16,0xf7,0xdb,0xcb,0xf5,0x1f,0x06,0xdc, - 0xb2,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xaa,0xd4,0xfa,0xfa,0xfa,0xda,0xb0, - 0x85,0x81,0x95,0xc0,0xea,0x16,0x1b,0xef,0xc9,0xf2,0x1d,0x04,0xd7,0xad,0x84,0x81, - 0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0x25,0x20,0x19,0x19,0x19,0x19,0x19,0xed,0xc2, - 0x98,0x81,0x81,0x81,0x8d,0xb8,0xe2,0x0e,0x23,0xf7,0xcd,0xa4,0xc7,0xf1,0x1b,0x15, - 0xea,0xc0,0x95,0x81,0x81,0x81,0x84,0xad,0xd2,0xe2,0xe2,0xe2,0xf7,0x1d,0x1d,0xf7, - 0xe2,0xe2,0xe2,0xd0,0xaa,0x82,0x81,0x81,0x88,0x98,0x9b,0x9b,0x98,0x86,0x81,0x95, - 0xc0,0xea,0x13,0x19,0xf1,0xcd,0xb1,0xc8,0xe3,0x04,0x26,0x09,0xe1,0xb8,0x8f,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x95,0xc0,0xea,0x16,0x0b,0xdf,0x06,0x1e,0xf2,0xc8,0xa5,0xb4,0xb8,0xe2,0x0e,0x13, - 0xe7,0xbd,0x93,0x81,0xa1,0xc5,0xe4,0xfc,0x06,0x04,0xf4,0xf9,0xfc,0xf1,0xc7,0x9f, - 0x81,0x8b,0xb2,0xd5,0xf9,0x1d,0x0b,0xe7,0xd8,0xfa,0x1d,0x09,0xe6,0xc3,0xa1,0x81, - 0x81,0x95,0xbf,0xe9,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xe9,0xbf, - 0x95,0x95,0xc0,0xea,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xea,0xc0,0x95,0x81,0x93, - 0xb7,0xd9,0xf7,0x13,0x0b,0xfc,0xf7,0xff,0x10,0x0d,0xf0,0xd0,0xae,0x8a,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x83,0x9b,0xae,0xba,0xc0,0xc0,0xb9,0xad,0x9a,0x82,0x81,0x81,0x81,0x91,0xb9, - 0xdb,0xe2,0xe2,0xe2,0xe2,0x06,0x26,0xfa,0xe2,0xe2,0xe2,0xe2,0xd4,0xaf,0x87,0x95, - 0xc0,0xea,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfb,0xd2,0xa8,0x81,0x95,0xc0,0xea, - 0x04,0x06,0x06,0x04,0xfa,0xec,0xd6,0xb9,0x99,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16, - 0x19,0xed,0xc2,0x98,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x8e,0xb0, - 0xce,0xea,0xff,0x0e,0x19,0x1d,0xfa,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x94,0xbd, - 0xe7,0x0f,0x2f,0x2c,0x0a,0xe1,0xb8,0x8f,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0xaa,0xd5,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xdd,0xb2,0x88,0x81, - 0x9f,0xb6,0xd4,0xed,0xfc,0x06,0x04,0xfa,0xe7,0xce,0xb7,0xa1,0x81,0x81,0x86,0xa9, - 0xcb,0xee,0x10,0x15,0xf1,0xcf,0xef,0x13,0x14,0xf1,0xcd,0xa8,0x81,0x81,0x81,0x81, - 0x81,0x8a,0xac,0xd0,0xf3,0x17,0x0b,0xe7,0xdf,0xdf,0xdf,0xdf,0xc5,0x9f,0x81,0x81, - 0x81,0x81,0x81,0x81,0x8a,0xad,0xd1,0xf4,0x18,0x09,0xe6,0xe4,0xea,0xe7,0xd9,0xc1, - 0xa3,0x81,0x81,0x81,0x81,0x87,0x95,0x9a,0xad,0xd0,0xf3,0x18,0x0b,0xe6,0xe1,0xe2, - 0xe2,0xe1,0xc7,0xa0,0x81,0x81,0x81,0x81,0x81,0x81,0x90,0xba,0xe4,0xfc,0xfc,0xea, - 0xc0,0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x90,0xba,0xe3,0x0c,0x19,0xf3,0xe5,0xfc,0x1c,0x16,0xfb,0xea,0xff,0x25,0xfc,0xd4, - 0xab,0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x26,0x06,0xda,0xb0, - 0x85,0x81,0x93,0xbd,0xe7,0x11,0x20,0xf7,0xcf,0xf7,0x23,0xfc,0xd2,0xa8,0xa9,0x99, - 0x81,0x81,0x94,0xbd,0xe3,0xed,0xef,0x1b,0x13,0xed,0xed,0xed,0xed,0xed,0xe4,0xbf, - 0x96,0x81,0x81,0x81,0x8b,0xb5,0xdf,0x09,0x28,0xff,0xd6,0xb6,0xd2,0xf9,0x22,0x0e, - 0xe4,0xbb,0x91,0x81,0x81,0x81,0x88,0xb2,0xdd,0x09,0x0e,0x0e,0x0e,0x1d,0x1d,0x0e, - 0x0e,0x0e,0x06,0xda,0xb0,0x85,0x81,0x86,0xa8,0xc1,0xc5,0xc5,0xc0,0xa7,0x84,0x8f, - 0xb7,0xdf,0x05,0x29,0x09,0xeb,0xd2,0xba,0xc8,0xef,0x19,0x13,0xe7,0xbd,0x93,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x94,0xbd,0xe7,0x13,0x0e,0xe4,0xff,0x23,0xfa,0xd6,0xcf,0xdc,0xd5,0xe7,0x11,0x11, - 0xe5,0xbb,0x91,0x92,0xba,0xdd,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xdb,0xb8, - 0x8f,0x93,0xbd,0xe7,0x10,0x1e,0xf3,0xd0,0xea,0x12,0x19,0xef,0xcd,0xaa,0x88,0x81, - 0x81,0x95,0xc0,0xea,0x16,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x16,0xea,0xc0, - 0x95,0x95,0xc0,0xea,0x16,0x29,0x29,0x29,0x29,0x29,0x16,0xea,0xc0,0x95,0x81,0x81, - 0x9d,0xbb,0xd8,0xef,0x04,0x0d,0x11,0x0b,0xfc,0xea,0xd2,0xb4,0x95,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x85,0x90,0x95,0x95,0x90,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x9f, - 0xb4,0xb8,0xb8,0xb8,0xda,0x06,0x26,0xfa,0xd0,0xb8,0xb8,0xb8,0xb1,0x98,0x81,0x8c, - 0xb1,0xcd,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xbf,0x9c,0x81,0x8c,0xb1,0xce, - 0xd7,0xda,0xda,0xd7,0xd2,0xc5,0xb3,0x9b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16, - 0x19,0xed,0xc2,0x98,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x81,0x92, - 0xaf,0xc6,0xd8,0xe6,0xed,0xf2,0xf1,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x95,0xc0, - 0xea,0x14,0x3c,0x38,0x0f,0xe5,0xba,0x90,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x9f,0xc1,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xc6,0xa6,0x81,0x8f, - 0xb8,0xdb,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xdd,0xba,0x92,0x81,0x81,0x90, - 0xb3,0xd5,0xf7,0x21,0x0b,0xdf,0xd9,0xfb,0x26,0x07,0xdd,0xb2,0x88,0x81,0x81,0x81, - 0x81,0xa0,0xc4,0xe7,0x0b,0x17,0xf3,0xde,0x04,0x0b,0x0b,0xfa,0xd0,0xa5,0x81,0x81, - 0x81,0x81,0x81,0x81,0xa1,0xc5,0xe8,0x0b,0x15,0xf1,0xf9,0x0d,0x16,0x11,0xfc,0xde, - 0xba,0x94,0x81,0x81,0x81,0x81,0x81,0xa1,0xc4,0xe7,0x0b,0x17,0xf3,0xdf,0x04,0x0e, - 0x0e,0xfa,0xd0,0xa5,0x81,0x81,0x81,0x81,0x81,0x88,0x9a,0xba,0xe5,0x11,0x16,0xea, - 0xc0,0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x95,0xc0,0xea,0x13,0x11,0xe7,0xc2,0xdf,0xfc,0x19,0x1f,0x16,0x20,0x10,0xed,0xc7, - 0x9f,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0, - 0x85,0x81,0x8d,0xb6,0xdf,0x07,0x2c,0x06,0xe3,0xfc,0x21,0xf5,0xcc,0xce,0xd2,0xb9, - 0x94,0x81,0x85,0xa7,0xbe,0xc5,0xef,0x1b,0x13,0xe7,0xc2,0xc2,0xc2,0xc2,0xbf,0xa9, - 0x87,0x81,0x81,0x81,0x84,0xad,0xd5,0xfc,0x24,0x0f,0xf0,0xdf,0xed,0x0c,0x25,0xff, - 0xd8,0xb1,0x88,0x81,0x81,0x81,0x88,0xb2,0xdd,0x09,0x0b,0x0b,0x0b,0x1b,0x1b,0x0b, - 0x0b,0x0b,0x06,0xda,0xb0,0x85,0x81,0x94,0xbd,0xe4,0xef,0xef,0xe2,0xbb,0x91,0x81, - 0xa6,0xcb,0xee,0x0f,0x27,0x0d,0xf4,0xdf,0xce,0xf3,0x1c,0x0e,0xe5,0xbb,0x92,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x8f,0xb8,0xe2,0x0b,0x15,0xec,0xf4,0x1a,0x12,0xfc,0xf7,0x04,0xe5,0xee,0x17,0x09, - 0xdf,0xb6,0x8c,0x95,0xc0,0xea,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0xe7,0xbd, - 0x93,0x8b,0xb2,0xd5,0xf9,0x1d,0x0b,0xe6,0xd8,0xfa,0x1d,0x09,0xe5,0xc3,0xa0,0x81, - 0x81,0x95,0xbf,0xe9,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0x16,0x16,0xea,0xc0, - 0x95,0x95,0xc0,0xea,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xea,0xc0,0x95,0x81,0x81, - 0x81,0x9d,0xb5,0xc9,0xda,0xe2,0xe5,0xe1,0xd6,0xc5,0xaf,0x96,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x8b,0x8d,0x8d,0xb0,0xda,0x06,0x26,0xfa,0xd0,0xa5,0x8d,0x8d,0x89,0x81,0x81,0x81, - 0x93,0xa5,0xa8,0xa8,0xa8,0xa8,0xa8,0xa8,0xa8,0xa8,0x9c,0x83,0x81,0x81,0x93,0xa7, - 0xad,0xb0,0xb0,0xaf,0xa8,0x9e,0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16, - 0x19,0xed,0xc2,0x98,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x81,0x81, - 0x8c,0xa0,0xb1,0xbd,0xc4,0xc8,0xc7,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x8f,0xb7, - 0xde,0xff,0x1a,0x18,0xfc,0xd9,0xb2,0x89,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x85,0x9e,0xa8,0xa8,0xa8,0xa8,0xa8,0xa8,0xa8,0xa8,0xa1,0x8a,0x81,0x93, - 0xbd,0xe7,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0xea,0xc0,0x95,0x81,0x86,0xa9, - 0xcb,0xee,0x10,0x15,0xf1,0xd0,0xef,0x13,0x14,0xf1,0xcd,0xa8,0x81,0x81,0x81,0x81, - 0x94,0xb7,0xdb,0xfc,0x22,0xff,0xdc,0xf5,0x19,0x04,0x26,0xfa,0xd0,0xa5,0x81,0x81, - 0x81,0x81,0x81,0x94,0xb8,0xdb,0xff,0x22,0xff,0xdb,0xff,0x0a,0xfc,0x0f,0x19,0xf1, - 0xc8,0x9e,0x81,0x81,0x81,0x81,0x94,0xb7,0xdb,0xff,0x22,0xff,0xdc,0xf5,0x1a,0x04, - 0x26,0xfa,0xd0,0xa5,0x81,0x81,0x81,0x81,0x94,0xad,0xc1,0xcd,0xe5,0x11,0x16,0xea, - 0xc0,0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x94,0xbe,0xe6,0xf2,0xf2,0xe1,0xb9,0xc1,0xdd,0xf6,0x09,0x0e,0x06,0xf1,0xd4,0xb2, - 0x8e,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0, - 0x85,0x81,0x81,0xa9,0xd1,0xf6,0x1a,0x1e,0xff,0x04,0x1b,0xef,0xea,0xf5,0xf2,0xc8, - 0x9d,0x81,0x81,0x86,0x9b,0xc5,0xef,0x1b,0x13,0xe7,0xbd,0x98,0x98,0x98,0x96,0x90, - 0x8a,0x81,0x81,0x81,0x8a,0xac,0xcd,0xee,0x13,0x2b,0x14,0x0b,0x12,0x29,0x19,0xf5, - 0xd4,0xb2,0x91,0x81,0x81,0x81,0x84,0xac,0xd0,0xdf,0xdf,0xdf,0xed,0x19,0x19,0xed, - 0xdf,0xdf,0xdf,0xce,0xa9,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81, - 0x91,0xb2,0xd2,0xee,0x07,0x1f,0x19,0x04,0xed,0x0a,0x21,0xfc,0xd8,0xb1,0x89,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x86,0xaf,0xd7,0xff,0x21,0xfa,0xdf,0xfc,0x12,0x1b,0x19,0x0f,0xe5,0xfb,0x23,0xfc, - 0xd5,0xad,0x84,0x95,0xc0,0xea,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0xe7,0xbd, - 0x93,0x81,0x9c,0xbf,0xe3,0x07,0x21,0xfc,0xda,0xe3,0x05,0x20,0xfc,0xdb,0xb9,0x96, - 0x81,0x8b,0xaf,0xcb,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xd0,0xea,0x16,0x16,0xea,0xc0, - 0x95,0x8c,0xb1,0xcd,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xcd,0xb1,0x8c,0x81,0x81, - 0x81,0x81,0x91,0xa4,0xb1,0xb9,0xba,0xb7,0xaf,0x9f,0x8c,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x87,0x8d,0x8d,0xb0,0xda,0x06,0x26,0xfa,0xd0,0xa5,0x8d,0x8d,0x84,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x84,0x85,0x85,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16, - 0x19,0xed,0xc2,0x9a,0xba,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x89,0x94,0x9a,0x9d,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x81,0xa4, - 0xc5,0xe0,0xf1,0xef,0xde,0xc1,0x9f,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x93, - 0xbd,0xe7,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0xea,0xc0,0x95,0x81,0x9e,0xc1, - 0xe3,0x06,0x20,0xfc,0xdb,0xe3,0x06,0x22,0xfc,0xda,0xb7,0x93,0x81,0x81,0x81,0x87, - 0xab,0xce,0xf1,0x15,0x0c,0xe8,0xe8,0x0d,0x0f,0xfc,0x26,0xfa,0xd0,0xaa,0x8e,0x81, - 0x81,0x81,0x88,0xac,0xcf,0xf1,0x16,0x0b,0xe7,0xc4,0xe6,0xe6,0xdb,0x04,0x1f,0xf5, - 0xca,0xa0,0x81,0x81,0x81,0x88,0xab,0xce,0xf1,0x15,0x0c,0xe8,0xe9,0x0d,0x0f,0xfc, - 0x26,0xfa,0xd0,0xaa,0x8e,0x81,0x81,0x91,0xb2,0xd0,0xe7,0xf6,0xfc,0x11,0x16,0xea, - 0xc0,0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x87,0xaa,0xc3,0xc8,0xc8,0xc1,0xa6,0xa2,0xbc,0xd1,0xdf,0xe2,0xdd,0xcd,0xb5,0x98, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0, - 0x85,0x81,0x81,0x98,0xbc,0xdf,0xfc,0x18,0x25,0x19,0x1d,0x0e,0x13,0x1e,0xf2,0xc8, - 0x9d,0x81,0x81,0xa1,0xb7,0xc5,0xef,0x1b,0x13,0xe7,0xbd,0xba,0xba,0xba,0xba,0xba, - 0xb1,0x96,0x81,0x82,0xa4,0xc5,0xe6,0x09,0x23,0x04,0x11,0x16,0x11,0x04,0x1f,0x0f, - 0xee,0xcc,0xaa,0x89,0x81,0x81,0x88,0xb2,0xdc,0xf7,0xf7,0xf7,0xf7,0x19,0x19,0xf7, - 0xf7,0xf7,0xf7,0xd9,0xaf,0x85,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81, - 0x81,0x96,0xb2,0xcd,0xe4,0xfb,0x10,0x25,0x16,0x1d,0x05,0xe6,0xc4,0xa0,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0xa2,0xca,0xf1,0x17,0x0d,0xea,0xda,0xea,0xef,0xef,0xe7,0xea,0x0f,0x14,0xee, - 0xc7,0xa0,0x81,0x90,0xb6,0xd6,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xd5,0xb4, - 0x8d,0x81,0x85,0xa8,0xcc,0xf0,0x14,0x14,0xf1,0xcd,0xee,0x10,0x16,0xf3,0xd2,0xad, - 0x85,0x81,0x91,0xa2,0xa5,0xa5,0xa5,0xa5,0xa5,0xa5,0xc0,0xea,0x16,0x16,0xea,0xc0, - 0x95,0x81,0x93,0xa5,0xa8,0xa8,0xa8,0xa8,0xa8,0xa8,0xa8,0xa5,0x93,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x88,0x8f,0x90,0x8d,0x86,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x94, - 0xae,0xb8,0xb8,0xb8,0xda,0xfa,0xfa,0xf7,0xcf,0xb8,0xb8,0xb8,0xaa,0x8e,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16, - 0x1b,0xf1,0xc8,0xb9,0xd5,0xf5,0x18,0x23,0xf7,0xcd,0xae,0x96,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x81,0x89, - 0xa6,0xbb,0xc7,0xc6,0xb9,0xa2,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8d, - 0xb4,0xd5,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xdd,0xd6,0xb6,0x90,0x90,0xb6,0xd9, - 0xfb,0x1f,0x09,0xe6,0xd6,0xf9,0x1d,0x0b,0xe7,0xc4,0xa0,0x81,0x81,0x81,0x81,0x9e, - 0xc2,0xe6,0x09,0x18,0xf5,0xdc,0xff,0x1d,0xf9,0xfc,0x26,0xfa,0xe2,0xc9,0xa3,0x81, - 0x81,0x81,0x9f,0xc2,0xe6,0x0a,0x18,0xf3,0xd0,0xad,0xc6,0xe0,0xfa,0x17,0x0b,0xe8, - 0xc2,0x99,0x81,0x81,0x81,0x9e,0xc2,0xe6,0x09,0x18,0xf4,0xdc,0xff,0x1d,0xf9,0xfc, - 0x26,0xfa,0xe2,0xc9,0xa3,0x81,0x81,0xa6,0xcc,0xee,0x0b,0x1f,0x1d,0x19,0x16,0xea, - 0xc0,0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x8a,0x9b,0x9d,0x9d,0x99,0x87,0x81,0x98,0xaa,0xb6,0xb8,0xb4,0xa7,0x94,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0, - 0x85,0x81,0x81,0x81,0xa3,0xc1,0xde,0xf3,0x04,0x14,0x16,0x0f,0x0b,0xff,0xef,0xc7, - 0x9d,0x81,0x92,0xba,0xdd,0xe5,0xef,0x1b,0x13,0xe7,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5, - 0xd1,0xab,0x82,0x92,0xbb,0xdf,0xff,0x22,0x0d,0xe8,0xe7,0xea,0xe7,0xe4,0x07,0x29, - 0x07,0xe6,0xc2,0x9a,0x81,0x81,0x88,0xb2,0xdd,0x09,0x21,0x21,0x21,0x29,0x29,0x21, - 0x21,0x21,0x06,0xda,0xb0,0x85,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81, - 0x81,0x81,0x92,0xa9,0xc1,0xd6,0xec,0x04,0x1c,0x18,0xf9,0xd4,0xae,0x89,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x92,0xb8,0xde,0xff,0x22,0x07,0xec,0xd9,0xd2,0xda,0xec,0x07,0x1f,0xfc,0xdb, - 0xb5,0x8f,0x81,0x81,0x9b,0xaf,0xb2,0xb2,0xb2,0xb2,0xb2,0xb2,0xb2,0xb2,0xaf,0x99, - 0x81,0x81,0x81,0x92,0xb5,0xd9,0xfc,0x15,0xff,0xdd,0xd5,0xf9,0x14,0xff,0xdf,0xb5, - 0x8b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x11,0x11,0xea,0xc0, - 0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x82,0xaa, - 0xd0,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xc9,0xa3,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16, - 0x25,0xff,0xe2,0xe0,0xf4,0x12,0x11,0x26,0xfc,0xdf,0xd2,0xae,0x86,0x81,0x81,0x81, - 0x85,0x9b,0xa3,0x99,0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x81,0x81,0x81, - 0x82,0x95,0x9d,0x9d,0x92,0x81,0x81,0x81,0x81,0x81,0x8c,0x9a,0x9b,0x9b,0x96,0x83, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x99,0xaf,0xb2,0xb2,0xb2,0xb2,0xb2,0xb2,0xb2,0xb2,0xaf,0x9b,0x81,0x95,0xbf,0xe9, - 0x05,0x13,0xf1,0xcd,0xe5,0x06,0x18,0xf4,0xd1,0xad,0x89,0x81,0x81,0x81,0x92,0xb5, - 0xd9,0xfc,0x20,0xff,0xde,0xe7,0x13,0x16,0x0e,0x0e,0x29,0x0e,0xfc,0xd2,0xa8,0x81, - 0x81,0x93,0xb6,0xda,0xfc,0x20,0xff,0xdd,0xb9,0xcc,0xe7,0xff,0x1c,0x09,0xee,0xd7, - 0xc3,0x9f,0x81,0x81,0x92,0xb5,0xd9,0xfc,0x20,0xff,0xde,0xe7,0x13,0x16,0x0e,0x0e, - 0x29,0x0e,0xfc,0xd2,0xa8,0x81,0x8d,0xb6,0xde,0x05,0x2a,0x0d,0xf5,0xed,0xed,0xe3, - 0xbd,0x94,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x82,0x8c,0x8d,0x8a,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0, - 0x85,0x81,0x81,0x81,0x85,0xa2,0xba,0xcd,0xea,0x14,0x0b,0xe5,0xe0,0xd8,0xcc,0xb4, - 0x91,0x81,0x95,0xc0,0xea,0x11,0x11,0x20,0x1a,0x11,0x11,0x11,0x11,0x11,0x11,0x06, - 0xda,0xb0,0x85,0x94,0xbd,0xe4,0xfc,0x12,0xf5,0xd2,0xbd,0xc0,0xbd,0xcd,0xf1,0x14, - 0xff,0xea,0xc5,0x9c,0x81,0x81,0x88,0xb2,0xdb,0xf5,0xf5,0xf5,0xf5,0x19,0x19,0xf5, - 0xf5,0xf5,0xf5,0xd8,0xaf,0x85,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81, - 0x8e,0xa7,0xb0,0xa7,0x9d,0xb2,0xc8,0xe0,0xff,0x26,0x0b,0xe2,0xb8,0x8d,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0xa3,0xc5,0xe6,0x05,0x1e,0x11,0x04,0xfc,0x04,0x11,0x1c,0xff,0xe3,0xc3, - 0xa0,0x81,0x81,0x81,0x81,0x86,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x86,0x81, - 0x81,0x81,0x81,0x81,0x9f,0xc2,0xe6,0xef,0xdb,0xc6,0xbd,0xe0,0xee,0xda,0xc5,0xa7, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x92,0xba,0xdd,0xe5,0xe5,0xdd,0xba, - 0x92,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0xb0, - 0xda,0x06,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0xfc,0xd2,0xa8,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16, - 0x22,0x1c,0x0b,0x0a,0x18,0x0f,0xf9,0x20,0x16,0x0b,0xdf,0xb5,0x8b,0x81,0x81,0x81, - 0xa2,0xc0,0xcd,0xbd,0xa6,0x9b,0xb6,0xdf,0x09,0x24,0xfa,0xd0,0xa7,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8d,0xae,0xc3,0xc5,0xc5,0xbe,0xa2, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x86,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x88,0x86,0x81,0x81,0x8b,0xaf,0xcb, - 0xdf,0xf2,0xd9,0xb5,0xcd,0xe0,0xf4,0xde,0xba,0x96,0x81,0x81,0x81,0x85,0xa9,0xcd, - 0xf0,0x13,0x0d,0xea,0xc7,0xe7,0x06,0x06,0x06,0x06,0x26,0x06,0xfc,0xd2,0xa8,0x81, - 0x85,0xaa,0xcd,0xf1,0x14,0x0d,0xe9,0xc6,0xb5,0xdf,0x09,0x23,0x05,0x04,0x04,0xfc, - 0xd2,0xa8,0x81,0x85,0xa9,0xcd,0xf0,0x14,0x0d,0xea,0xc7,0xe7,0x06,0x06,0x06,0x06, - 0x26,0x06,0xfc,0xd2,0xa8,0x81,0x95,0xbf,0xe7,0x12,0x21,0xf6,0xd0,0xc3,0xc2,0xbe, - 0xa7,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0, - 0x85,0x81,0x81,0x81,0x81,0x81,0x9c,0xc6,0xef,0x1a,0x05,0xda,0xb7,0xaf,0xa4,0x93, - 0x81,0x81,0x95,0xc0,0xea,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x06, - 0xda,0xb0,0x85,0x86,0xa8,0xc2,0xd9,0xee,0xdf,0xbb,0x98,0x95,0x94,0xb6,0xd9,0xef, - 0xdc,0xc6,0xae,0x8d,0x81,0x81,0x81,0xa1,0xc0,0xca,0xca,0xca,0xed,0x13,0x13,0xed, - 0xca,0xca,0xca,0xbe,0x9f,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81, - 0xa7,0xca,0xda,0xd0,0xc7,0xc5,0xc8,0xd5,0xfa,0x24,0x0b,0xe1,0xb7,0x8d,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x8a,0xaa,0xc8,0xe3,0xfa,0x0b,0x15,0x19,0x14,0x0a,0xf7,0xe1,0xc6,0xa8, - 0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x88,0xaa,0xc5,0xc8,0xb6,0xa2,0xa5,0xc0,0xc6,0xb5,0xa1,0x8a, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa1,0xb7,0xba,0xba,0xb7,0xa1, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0xb0, - 0xda,0x06,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0xfc,0xd2,0xa8,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16, - 0x13,0x07,0x16,0x16,0x07,0xf0,0xe6,0x05,0x13,0x0b,0xdf,0xb5,0x8b,0x81,0x81,0x97, - 0xba,0xdd,0xf7,0xdf,0xcd,0xc5,0xd0,0xee,0x14,0x1a,0xf2,0xc9,0xa0,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9d,0xc5,0xea,0xef,0xef,0xde,0xb6, - 0x8c,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x91,0xa6, - 0xba,0xc8,0xbc,0x9e,0xa7,0xba,0xca,0xc0,0xa2,0x81,0x81,0x81,0x81,0x92,0xbb,0xe3, - 0x07,0x13,0xf6,0xd3,0xb3,0xd3,0xda,0xda,0xda,0xfc,0x13,0xfa,0xda,0xc4,0xa0,0x81, - 0x92,0xbb,0xe3,0x09,0x11,0xf5,0xd2,0xaf,0xb5,0xdf,0x0b,0x11,0x11,0x11,0x11,0xfc, - 0xd2,0xa8,0x81,0x92,0xbb,0xe3,0x07,0x13,0xf6,0xd3,0xb3,0xd3,0xda,0xda,0xda,0xfc, - 0x13,0xfa,0xda,0xc4,0xa0,0x81,0x95,0xc0,0xea,0x16,0x1e,0xf2,0xc9,0x9f,0x98,0x96, - 0x86,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0, - 0x85,0x81,0x81,0x81,0x81,0x81,0xa2,0xcc,0xf5,0x20,0xff,0xd5,0xab,0x86,0x81,0x81, - 0x81,0x81,0x92,0xba,0xdd,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5, - 0xd1,0xab,0x82,0x81,0x88,0x9e,0xb4,0xc6,0xc0,0xa4,0x81,0x81,0x81,0x9e,0xbb,0xc5, - 0xb8,0xa2,0x8c,0x81,0x81,0x81,0x81,0x84,0x9a,0xa0,0xa0,0xbd,0xe0,0xe7,0xe7,0xe0, - 0xbd,0xa0,0xa0,0x99,0x83,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x85, - 0xb0,0xda,0x05,0xf7,0xef,0xef,0xf2,0xfa,0x12,0x1f,0xfc,0xd6,0xaf,0x86,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x8c,0xa8,0xc0,0xd4,0xe2,0xea,0xed,0xea,0xe1,0xd2,0xbe,0xa6,0x8b, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x8b,0x9d,0x9f,0x91,0x81,0x85,0x99,0x9d,0x8f,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0x90,0x90,0x8e,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x82,0xab, - 0xd1,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe4,0xcb,0xa4,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16, - 0x16,0xea,0xed,0xec,0xe1,0xcd,0xca,0xe0,0xea,0xe8,0xd5,0xb0,0x88,0x81,0x82,0xab, - 0xd2,0xf4,0x18,0x05,0xf5,0xef,0xf6,0x0b,0x29,0x07,0xe2,0xbc,0x95,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa6,0xcf,0xf7,0x1b,0x06,0xdd,0xb5, - 0x8c,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x94,0x9d,0x96,0x81,0x81,0x95,0xa0,0x9a,0x84,0x81,0x81,0x81,0x81,0x90,0xb9,0xdd, - 0xe7,0xe7,0xdd,0xbc,0x99,0xac,0xb0,0xb0,0xcc,0xe7,0xe7,0xe7,0xc9,0xa3,0x89,0x81, - 0x8f,0xb8,0xdb,0xe5,0xe5,0xdd,0xbb,0x98,0xb0,0xd5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe4, - 0xcb,0xa4,0x81,0x90,0xb9,0xdd,0xe7,0xe7,0xdd,0xbc,0x99,0xac,0xb0,0xb0,0xcc,0xe7, - 0xe7,0xe7,0xc9,0xa3,0x89,0x81,0x92,0xbc,0xe6,0x0f,0x24,0xfc,0xd7,0xb7,0xa4,0x9d, - 0x9a,0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0, - 0x85,0x81,0x81,0x81,0x81,0x81,0xa7,0xd1,0xfa,0x23,0xf7,0xcf,0xa5,0x81,0x81,0x81, - 0x81,0x81,0x81,0xa1,0xb7,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba, - 0xb1,0x96,0x81,0x81,0x81,0x81,0x8f,0x9d,0x99,0x85,0x81,0x81,0x81,0x81,0x95,0x9b, - 0x92,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x84,0xa5,0xba,0xbd,0xbd,0xba, - 0xa5,0x84,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x85, - 0xb0,0xda,0x06,0x21,0x1b,0x1b,0x1b,0x23,0x15,0xff,0xe3,0xc2,0x9e,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x86,0x9b,0xad,0xb9,0xc1,0xc2,0xc0,0xb8,0xab,0x99,0x83,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x96, - 0xb1,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xac,0x8f,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16, - 0x19,0xed,0xc2,0xc2,0xb9,0xa8,0xa7,0xb8,0xc0,0xbf,0xb4,0x9a,0x81,0x81,0x85,0xaf, - 0xd8,0xf9,0x10,0x22,0x1f,0x1b,0x1f,0x1f,0x0a,0xee,0xcd,0xa9,0x84,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x86,0xaf,0xd9,0x04,0x23,0xfa,0xd2,0xa9, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa1,0xb9, - 0xbd,0xbd,0xb9,0xa1,0x81,0x83,0x85,0x91,0xaf,0xbd,0xbd,0xbd,0xad,0x8f,0x81,0x81, - 0x81,0x9f,0xb6,0xba,0xba,0xb7,0xa1,0x81,0x9a,0xb3,0xba,0xba,0xba,0xba,0xba,0xba, - 0xac,0x8f,0x81,0x81,0xa1,0xb9,0xbd,0xbd,0xb9,0xa1,0x81,0x83,0x85,0x91,0xaf,0xbd, - 0xbd,0xbd,0xad,0x8f,0x81,0x81,0x89,0xb1,0xd9,0xff,0x23,0x12,0xf3,0xdb,0xcd,0xc6, - 0xc4,0xb0,0x8f,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0, - 0x85,0x81,0x81,0x81,0x81,0x83,0xad,0xd7,0xff,0x0e,0xf2,0xc9,0x9f,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x8e,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90, - 0x8a,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x82,0x91,0x93,0x93,0x91, - 0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x85, - 0xaf,0xd7,0xf5,0xfc,0x04,0x04,0xff,0xfa,0xef,0xdc,0xc4,0xa7,0x86,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x85,0x90,0x97,0x98,0x97,0x8f,0x84,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x8a,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x87,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16, - 0x19,0xed,0xc2,0x98,0x90,0x82,0x81,0x8f,0x95,0x95,0x8d,0x81,0x81,0x81,0x81,0x9f, - 0xbf,0xd6,0xeb,0xfa,0x04,0x06,0x04,0xf7,0xe6,0xce,0xb2,0x92,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8f,0xb9,0xe2,0x0b,0x17,0xef,0xc6,0x9d, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x90, - 0x93,0x93,0x90,0x81,0x81,0x81,0x81,0x81,0x89,0x93,0x93,0x92,0x88,0x81,0x81,0x81, - 0x81,0x81,0x8d,0x90,0x90,0x8e,0x81,0x81,0x81,0x8b,0x90,0x90,0x90,0x90,0x90,0x90, - 0x87,0x81,0x81,0x81,0x81,0x90,0x93,0x93,0x90,0x81,0x81,0x81,0x81,0x81,0x89,0x93, - 0x93,0x92,0x88,0x81,0x81,0x81,0x81,0xa0,0xc5,0xe8,0x09,0x25,0x15,0x04,0xf5,0xef, - 0xec,0xc8,0x9e,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x2b,0x06,0xda,0xb0, - 0x85,0x81,0x81,0x81,0x81,0x81,0xa8,0xcd,0xe2,0xe2,0xde,0xbf,0x98,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xbd,0x93,0x81, - 0x9e,0xbc,0xcc,0xd4,0xd7,0xd7,0xd7,0xd2,0xc7,0xb6,0xa1,0x88,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16, - 0x19,0xed,0xc2,0x98,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x83, - 0x9c,0xb2,0xc4,0xd1,0xd8,0xda,0xd7,0xcf,0xc0,0xac,0x93,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x92,0xbc,0xe6,0xf7,0xf7,0xe2,0xba,0x91, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8b,0xac,0xcc,0xe9,0x04,0x16,0x24,0x20,0x1b, - 0xf5,0xca,0xa0,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x09,0x06,0xda,0xb0, - 0x85,0x81,0x81,0x81,0x81,0x81,0x92,0xad,0xb8,0xb8,0xb6,0xa2,0x84,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x09,0x09,0xe7,0xbd,0x93,0x81, - 0x81,0x97,0xa3,0xaa,0xad,0xad,0xad,0xa8,0x9f,0x91,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x09, - 0x09,0xed,0xc2,0x98,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x8c,0x9c,0xa8,0xaf,0xb0,0xad,0xa6,0x9a,0x87,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x87,0xac,0xc7,0xcd,0xcd,0xc5,0xa8,0x84, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x90,0xae,0xc8,0xde,0xef,0xfb,0x04,0x09, - 0xf5,0xca,0xa0,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa3,0xc8,0xdd,0xdd,0xdd,0xcc,0xa8, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x86,0x8d,0x8d,0x8c,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x90,0xb6,0xd6,0xdd,0xdd,0xd5,0xb4,0x8d,0x81, - 0x81,0x81,0x81,0x81,0x83,0x83,0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x90,0xb6,0xd6,0xdd, - 0xdd,0xd8,0xb9,0x92,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x85,0x85,0x84,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8d,0x9f,0xa3,0xa3,0x9e,0x8a,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8d,0xa4,0xb8,0xc7,0xd2,0xda,0xdd, - 0xdb,0xc0,0x9a,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8c,0xa7,0xb2,0xb2,0xb2,0xaa,0x90, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9b,0xaf,0xb2,0xb2,0xaf,0x99,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9b,0xaf,0xb2, - 0xb2,0xb0,0x9d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x91,0x9f,0xa9,0xb0,0xb2, - 0xb2,0xa1,0x84,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x88,0x88,0x88,0x82,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x86,0x88,0x88,0x86,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x86,0x88, - 0x88,0x86,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x86,0x88, - 0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0xa5,0xc8,0xda,0xda,0xda,0xda,0xc3,0xa5,0x87,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9f,0xbd,0xd7,0xda, - 0xda,0xda,0xce,0xac,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8b,0xa8,0xc5, - 0xda,0xda,0xda,0xca,0xae,0x91,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x84, - 0xa3,0xbf,0xd4,0xdf,0xdf,0xd4,0xc2,0xbd,0xd7,0xd1,0xb6,0x98,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x86,0xa8,0xc5,0xd8,0xd9,0xc8,0xac,0xc2,0xd6,0xda,0xcb,0xb0,0x8e, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9f,0xc3,0xe3,0xfa,0x04,0xfc,0xe8, - 0xca,0xa6,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0xa5,0xc8,0xda,0xda,0xda,0xda,0xc3,0xa5,0x87,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9d,0xbb,0xd6,0xda,0xda,0xda,0xd0,0xae,0x87, - 0x81,0x81,0x81,0x81,0x81,0x81,0x8b,0xa7,0xc4,0xda,0xda,0xda,0xca,0xac,0x90,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x86,0xa8,0xc5,0xd8,0xd9,0xc8,0xac,0xc2,0xd6,0xda, - 0xcb,0xb0,0x8e,0x81,0x81,0x81,0x81,0x81,0xa5,0xc8,0xda,0xda,0xda,0xda,0xc3,0xa5, - 0x87,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9d, - 0xbb,0xd6,0xda,0xda,0xda,0xd1,0xb1,0x8a,0x81,0x81,0x81,0x81,0x81,0x81,0x89,0xa7, - 0xc3,0xda,0xda,0xda,0xca,0xae,0x92,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x86,0xa8, - 0xc5,0xd8,0xd9,0xc8,0xac,0xc2,0xd6,0xda,0xcb,0xb0,0x8e,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x83,0xa1,0xbe,0xd3,0xdf,0xdf,0xd5,0xc2,0xba,0xd6,0xd3,0xb8,0x9a, - 0x81,0x81,0x81,0x81,0x81,0xa2,0xc6,0xda,0xda,0xda,0xda,0xc5,0xa5,0x87,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9f,0xbd,0xd7, - 0xda,0xda,0xda,0xce,0xac,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8b,0xa7,0xc5, - 0xda,0xda,0xda,0xca,0xae,0x91,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x83,0xa3, - 0xbf,0xd4,0xdf,0xdf,0xd5,0xc2,0xbd,0xd7,0xd1,0xb5,0x98,0x81,0x81,0x81,0x81,0x81, - 0x81,0x86,0xa8,0xc5,0xd8,0xd9,0xc8,0xac,0xc2,0xd6,0xda,0xcb,0xb0,0x8e,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x83,0x94,0x98,0x98,0x94,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0xa5,0xc8,0xda,0xda,0xda,0xda,0xc3,0xa5,0x87,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9d,0xbb,0xd6, - 0xda,0xda,0xda,0xd0,0xae,0x87,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x83,0xad,0xd7,0xff,0x06,0x06,0xff,0xe1,0xc3,0xa5,0x87,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9f,0xbd,0xdb,0xf9,0x06, - 0x06,0x04,0xdf,0xb5,0x8b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0xaa,0xc7,0xe4, - 0xff,0x06,0x06,0xea,0xcc,0xb0,0x94,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9d, - 0xc0,0xdf,0xfa,0x09,0x09,0xfb,0xe6,0xd8,0xf7,0xf1,0xd4,0xb1,0x89,0x81,0x81,0x81, - 0x81,0x81,0x81,0x97,0xbf,0xe3,0xff,0xff,0xe8,0xc4,0xdf,0xfc,0x04,0xec,0xc8,0xa1, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x86,0xaf,0xd7,0xfc,0x16,0x06,0x11,0x05, - 0xdf,0xb7,0x8e,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x83, - 0xad,0xd7,0xff,0x06,0x06,0xff,0xe1,0xc2,0xa3,0x85,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x9d,0xbb,0xd9,0xf7,0x06,0x06,0x05,0xe2,0xb8,0x8d, - 0x81,0x81,0x81,0x81,0x81,0x8c,0xa9,0xc7,0xe3,0xff,0x06,0x05,0xe8,0xcc,0xb0,0x92, - 0x81,0x81,0x81,0x81,0x81,0x81,0x97,0xbf,0xe3,0xff,0xff,0xe8,0xc4,0xdf,0xfc,0x04, - 0xec,0xc8,0xa1,0x81,0x81,0x81,0x81,0x83,0xad,0xd7,0xff,0x06,0x06,0xff,0xe1,0xc3, - 0xa5,0x87,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9d,0xbb, - 0xd9,0xf7,0x06,0x06,0x06,0xe4,0xba,0x90,0x81,0x81,0x81,0x81,0x81,0x8c,0xa9,0xc5, - 0xe3,0xff,0x06,0x06,0xea,0xcd,0xb0,0x94,0x81,0x81,0x81,0x81,0x81,0x81,0x97,0xbf, - 0xe3,0xff,0xff,0xe8,0xc4,0xdf,0xfc,0x04,0xec,0xc8,0xa1,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x9c,0xbf,0xdd,0xf9,0x09,0x09,0xfc,0xe7,0xd6,0xf5,0xf3,0xd5,0xb3, - 0x8b,0x81,0x81,0x81,0x81,0xaa,0xd5,0xfc,0x06,0x06,0xff,0xe1,0xc3,0xa5,0x87,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9d,0xbb,0xdb,0xf9, - 0x06,0x06,0x04,0xdf,0xb5,0x8b,0x81,0x81,0x81,0x81,0x81,0x81,0x8c,0xa9,0xc7,0xe3, - 0xff,0x06,0x06,0xea,0xcc,0xb0,0x94,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9c,0xbf, - 0xdf,0xf9,0x09,0x09,0xfb,0xe6,0xd8,0xf7,0xf1,0xd4,0xb1,0x89,0x81,0x81,0x81,0x81, - 0x81,0x97,0xbf,0xe3,0xff,0xff,0xe8,0xc4,0xdf,0xfc,0x04,0xec,0xc8,0xa1,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa3,0xbc,0xc2,0xc2,0xbb,0xa1, - 0x81,0x81,0x81,0x81,0x81,0x83,0xad,0xd7,0xfc,0x06,0x06,0xff,0xe1,0xc3,0xa5,0x87, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9d,0xbb,0xd9,0xf7, - 0x06,0x06,0x05,0xe2,0xb8,0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0xa1,0xc3,0xdd,0xf5,0x0f,0x1d,0xff,0xe1,0xc3,0xa4,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9c,0xbd,0xdb,0xf9,0x18,0x14, - 0xfb,0xe2,0xc8,0xa8,0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x8a,0xac,0xca,0xe6,0x04, - 0x1f,0x09,0x1d,0x09,0xec,0xd0,0xb2,0x90,0x81,0x81,0x81,0x81,0x81,0x81,0x84,0xae, - 0xd6,0xfb,0x1c,0x0d,0x0f,0x20,0x0a,0xff,0x14,0x09,0xe2,0xb8,0x8d,0x81,0x81,0x81, - 0x81,0x81,0x81,0x9d,0xc8,0xf2,0x1d,0x21,0xf7,0xcd,0xed,0x18,0x26,0xfc,0xd2,0xa8, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8b,0xb5,0xdf,0x0b,0x04,0xdc,0xfa,0x13, - 0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x83,0x85,0x85,0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0xa1,0xc3,0xdd,0xf6,0x10,0x1d,0xfc,0xdf,0xc1,0xa2,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x9c,0xbb,0xd9,0xf7,0x16,0x16,0xfc,0xe3,0xca,0xaa,0x84, - 0x81,0x81,0x81,0x81,0x88,0xaa,0xc8,0xe4,0x04,0x1f,0x0b,0x1f,0x09,0xeb,0xce,0xb2, - 0x91,0x81,0x81,0x81,0x81,0x81,0x9d,0xc8,0xf2,0x1d,0x21,0xf7,0xcd,0xed,0x18,0x26, - 0xfc,0xd2,0xa8,0x81,0x81,0x81,0x81,0x81,0xa1,0xc3,0xdd,0xf5,0x0f,0x1d,0xff,0xe1, - 0xc3,0xa5,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9c,0xbb,0xd9, - 0xf7,0x16,0x17,0xfc,0xe4,0xcb,0xac,0x87,0x81,0x81,0x81,0x81,0x88,0xaa,0xc7,0xe4, - 0xff,0x1e,0x0a,0x1e,0x09,0xec,0xd0,0xb4,0x94,0x81,0x81,0x81,0x81,0x81,0x9d,0xc8, - 0xf2,0x1d,0x21,0xf7,0xcd,0xed,0x18,0x26,0xfc,0xd2,0xa8,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x82,0xac,0xd5,0xf9,0x1a,0x0d,0x0f,0x21,0x0b,0xff,0x12,0x0b,0xe4,0xba, - 0x90,0x81,0x81,0x81,0x81,0x9f,0xc1,0xdb,0xf5,0x0f,0x1d,0xff,0xe1,0xc3,0xa4,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9c,0xbb,0xd9,0xf7,0x18, - 0x14,0xfb,0xe2,0xc8,0xa8,0x82,0x81,0x81,0x81,0x81,0x81,0x87,0xaa,0xc8,0xe4,0x04, - 0x1f,0x0a,0x1d,0x09,0xec,0xd0,0xb2,0x90,0x81,0x81,0x81,0x81,0x81,0x82,0xac,0xd5, - 0xfa,0x1b,0x0d,0x0f,0x20,0x0a,0xff,0x14,0x09,0xe2,0xb8,0x8d,0x81,0x81,0x81,0x81, - 0x81,0x9d,0xc8,0xf2,0x1d,0x21,0xf7,0xcd,0xed,0x18,0x26,0xfc,0xd2,0xa8,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x83,0x90,0xb8,0xde,0xed,0xed,0xdc,0xb5, - 0x8c,0x81,0x81,0x81,0x81,0x81,0xa1,0xc3,0xdc,0xf5,0x0f,0x1d,0xff,0xe1,0xc3,0xa4, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9c,0xbb,0xd9,0xf7,0x16, - 0x15,0xfb,0xe3,0xc9,0xaa,0x84,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x87,0xa1,0xbb,0xd4,0xee,0x07,0x11,0xff,0xdf,0xb6,0x8c,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x82,0xac,0xd5,0xf9,0x11,0x0c,0xf1, - 0xd9,0xc0,0xa7,0x8c,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x97,0xc1,0xe8,0x05,0x11, - 0xff,0xe6,0xfb,0x11,0x0b,0xee,0xc8,0x9f,0x81,0x81,0x81,0x81,0x81,0x81,0x83,0xad, - 0xd4,0xf1,0x05,0xe6,0xea,0xff,0x11,0x15,0x07,0xec,0xcd,0xaa,0x84,0x81,0x81,0x81, - 0x81,0x81,0x81,0x9a,0xc3,0xe9,0x0a,0x0b,0xee,0xc8,0xe5,0x07,0x0e,0xf1,0xcd,0xa4, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x89,0xb3,0xdc,0x04,0x0f,0xf7,0x09,0x0b, - 0xe3,0xba,0x91,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8c, - 0xa2,0xa8,0xa8,0xa8,0xa8,0xa8,0xa8,0xa8,0xa6,0x96,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x87,0x99,0xa5,0xad,0xb0,0xb0,0xad,0xa5,0x9a,0x8c,0x81,0x81,0x81,0x81,0x81, - 0x89,0xa2,0xbb,0xd5,0xee,0x09,0x13,0xfc,0xde,0xb6,0xa8,0xa6,0x96,0x81,0x81,0x81, - 0x81,0x81,0x89,0xa0,0xa8,0xae,0xd6,0xf7,0x13,0x0d,0xf3,0xdb,0xc1,0xa8,0x96,0x81, - 0x81,0x81,0x81,0x81,0x97,0xc0,0xe6,0x05,0x13,0xff,0xe7,0xfc,0x13,0x0b,0xee,0xca, - 0xa1,0x81,0x81,0x81,0x81,0x81,0x9a,0xc3,0xe9,0x0a,0x0b,0xee,0xc8,0xe5,0x07,0x0e, - 0xf1,0xcd,0xa4,0x81,0x81,0x81,0x81,0x81,0x91,0xa4,0xbb,0xd4,0xee,0x07,0x13,0xff, - 0xe0,0xb8,0xa8,0xa7,0x99,0x81,0x81,0x81,0x81,0x81,0x91,0xa4,0xa8,0xae,0xd6,0xf7, - 0x13,0x0f,0xf4,0xdb,0xc2,0xa9,0x99,0x81,0x81,0x81,0x81,0x81,0x97,0xc0,0xe6,0x04, - 0x13,0xff,0xe8,0xfc,0x13,0x0d,0xf0,0xcd,0xa4,0x81,0x81,0x81,0x81,0x81,0x9a,0xc3, - 0xe9,0x0a,0x0b,0xee,0xc8,0xe5,0x07,0x0e,0xf1,0xcd,0xa4,0x81,0x81,0x81,0x81,0x81, - 0x9b,0xa8,0xa8,0xa8,0xa8,0xa8,0xa7,0xa2,0x99,0x8c,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x87,0xaa,0xd2,0xf1,0x06,0xe6,0xe9,0xff,0x11,0x16,0x09,0xee,0xd0,0xac, - 0x8f,0x81,0x81,0x81,0x81,0x85,0xa0,0xba,0xd3,0xed,0x07,0x11,0xff,0xdf,0xb6,0x8f, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x86,0xac,0xd5,0xf7,0x11,0x0d, - 0xf3,0xd9,0xc0,0xa7,0x8c,0x81,0x81,0x81,0x81,0x81,0x81,0x94,0xbe,0xe6,0x05,0x11, - 0xff,0xe6,0xfb,0x11,0x0b,0xee,0xc8,0x9f,0x81,0x81,0x81,0x81,0x81,0x81,0xaa,0xd2, - 0xf1,0x06,0xe6,0xe9,0xff,0x11,0x15,0x07,0xec,0xcd,0xaa,0x84,0x81,0x81,0x81,0x81, - 0x81,0x9a,0xc3,0xe9,0x0a,0x0b,0xee,0xc8,0xe5,0x07,0x0e,0xf1,0xcd,0xa4,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x93,0xa2,0xad,0xb2,0xc4,0xed,0x15,0x07,0xdf,0xb6, - 0x8c,0x81,0x81,0x81,0x81,0x8c,0xa3,0xab,0xba,0xd4,0xed,0x07,0x11,0xff,0xdf,0xb6, - 0xab,0xab,0xa7,0x93,0x81,0x81,0x81,0x8c,0xa3,0xab,0xab,0xac,0xd5,0xf7,0x11,0x0d, - 0xf3,0xda,0xc1,0xab,0xa7,0x93,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x99,0xb2,0xcc,0xe3,0xe5,0xe5,0xd7,0xb5,0x8f,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x86,0xac,0xcf,0xe5,0xe5,0xe5,0xd1, - 0xb7,0x9e,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x94,0xbc,0xde,0xe5,0xe5, - 0xde,0xd5,0xda,0xe5,0xe5,0xe2,0xc4,0x9c,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x99, - 0xb7,0xd4,0xe4,0xcb,0xd5,0xdb,0xe7,0xea,0xe1,0xcd,0xb0,0x92,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x8b,0xaf,0xce,0xe2,0xe3,0xd5,0xd5,0xd5,0xe1,0xe4,0xd4,0xb7,0x94, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa5,0xcb,0xec,0x05,0x11,0x09,0xf1, - 0xd1,0xac,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x82,0xa8, - 0xc8,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xcf,0xb5,0x91,0x81,0x81,0x81,0x81,0x81, - 0x96,0xad,0xc0,0xce,0xd7,0xda,0xda,0xd6,0xcf,0xc3,0xb2,0x96,0x81,0x81,0x81,0x81, - 0xa3,0xc4,0xd2,0xd2,0xd2,0xe5,0xe7,0xe7,0xd9,0xd2,0xd2,0xcf,0xb5,0x91,0x81,0x81, - 0x81,0x81,0xa3,0xc4,0xd2,0xd2,0xd3,0xe7,0xe7,0xe7,0xd2,0xd2,0xd2,0xcf,0xb5,0x91, - 0x81,0x81,0x81,0x81,0xa3,0xc4,0xe0,0xe7,0xe7,0xdf,0xd2,0xdb,0xe7,0xe7,0xe6,0xcf, - 0xb5,0x91,0x81,0x81,0x81,0x81,0xa3,0xc4,0xd2,0xe2,0xe3,0xd2,0xd2,0xd2,0xe1,0xe4, - 0xd4,0xcf,0xb5,0x91,0x81,0x81,0x81,0x89,0xaf,0xcc,0xd2,0xd2,0xd2,0xe5,0xe7,0xe7, - 0xdb,0xd2,0xd2,0xd1,0xb9,0x95,0x81,0x81,0x81,0x89,0xaf,0xcc,0xd2,0xd2,0xd3,0xe7, - 0xe7,0xe7,0xd3,0xd2,0xd2,0xd1,0xb9,0x95,0x81,0x81,0x81,0x89,0xaf,0xcc,0xe0,0xe7, - 0xe7,0xe0,0xd2,0xdb,0xe7,0xe7,0xe7,0xd1,0xb9,0x95,0x81,0x81,0x81,0x89,0xaf,0xcc, - 0xd2,0xe2,0xe3,0xd2,0xd2,0xd2,0xe1,0xe4,0xd4,0xd1,0xb9,0x95,0x81,0x81,0x81,0x9a, - 0xbd,0xd2,0xd2,0xd2,0xd2,0xd2,0xd1,0xcc,0xc2,0xb4,0xa1,0x8a,0x81,0x81,0x81,0x81, - 0x81,0x81,0xa1,0xc3,0xd2,0xd3,0xe4,0xcf,0xc5,0xda,0xe7,0xea,0xe2,0xd2,0xd2,0xcb, - 0xac,0x87,0x81,0x81,0x81,0x81,0x90,0xa9,0xbf,0xce,0xe3,0xe5,0xe5,0xd7,0xc8,0xb5, - 0x9e,0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x90,0xa9,0xbf,0xcf,0xe5,0xe5,0xe5, - 0xd5,0xc8,0xb5,0x9e,0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x92,0xba,0xdd,0xe5,0xe5, - 0xde,0xdd,0xdc,0xe5,0xe5,0xe2,0xc4,0x9c,0x81,0x81,0x81,0x81,0x81,0x81,0x97,0xb6, - 0xd3,0xe4,0xce,0xd9,0xdd,0xe7,0xea,0xe1,0xcd,0xb0,0x92,0x81,0x81,0x81,0x81,0x81, - 0x81,0x8b,0xaf,0xce,0xe2,0xe3,0xd9,0xdd,0xdc,0xe1,0xe4,0xd4,0xb7,0x94,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x88,0xa2,0xb9,0xca,0xd6,0xdd,0xdd,0xf9,0x21,0xfa,0xd2,0xaa, - 0x81,0x81,0x81,0x81,0x81,0xa7,0xc8,0xd5,0xd5,0xd4,0xcb,0xe3,0xe5,0xe5,0xd7,0xd2, - 0xd5,0xd5,0xce,0xb0,0x8a,0x81,0x81,0xa7,0xc8,0xd5,0xd5,0xd4,0xcf,0xe5,0xe5,0xe5, - 0xd2,0xd2,0xd5,0xd5,0xce,0xb0,0x8a,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x94,0xbc,0xe4,0xff,0xff,0xff,0xee,0xc6,0x9e,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x94,0xbc,0xe4,0xff,0xff,0xff,0xee, - 0xc6,0x9e,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x83,0xa3,0xb8,0xbc,0xe4, - 0xff,0xff,0xff,0xee,0xc6,0xb9,0xa8,0x89,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x98,0xb2,0xbc,0xe4,0xff,0xff,0xff,0xef,0xc6,0xa8,0x92,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x92,0xab,0xba,0xe2,0xff,0xff,0xff,0xef,0xc7,0xaf,0x99,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x93,0xbb,0xe3,0xff,0xff,0xff,0xee, - 0xc6,0x9e,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x93,0xba, - 0xe1,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xef,0xc5,0x9b,0x81,0x81,0x81,0x81,0x9b, - 0xb8,0xd1,0xe6,0xf6,0xff,0x06,0x06,0xff,0xf7,0xea,0xd1,0xab,0x82,0x81,0x81,0x85, - 0xb0,0xda,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xef,0xc5,0x9b,0x81,0x81, - 0x81,0x85,0xb0,0xda,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xef,0xc5,0x9b, - 0x81,0x81,0x81,0x85,0xb0,0xda,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xef, - 0xc5,0x9b,0x81,0x81,0x81,0x85,0xb0,0xda,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc, - 0xfc,0xef,0xc5,0x9b,0x81,0x81,0x81,0x93,0xbd,0xe7,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc, - 0xfc,0xfc,0xfc,0xf4,0xca,0xa0,0x81,0x81,0x81,0x93,0xbd,0xe7,0xfc,0xfc,0xfc,0xfc, - 0xfc,0xfc,0xfc,0xfc,0xfc,0xf4,0xca,0xa0,0x81,0x81,0x81,0x93,0xbd,0xe7,0xfc,0xfc, - 0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xf4,0xca,0xa0,0x81,0x81,0x81,0x93,0xbd,0xe7, - 0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,0xf4,0xca,0xa0,0x81,0x81,0x81,0xa5, - 0xcf,0xf9,0xfc,0xfc,0xfc,0xfc,0xfa,0xf5,0xea,0xda,0xc5,0xac,0x8e,0x81,0x81,0x81, - 0x81,0x83,0xad,0xd7,0xfc,0xfc,0xfc,0xf1,0xc9,0xb3,0xbe,0xc2,0xec,0xfc,0xfc,0xe4, - 0xba,0x90,0x81,0x81,0x81,0x90,0xb0,0xcc,0xe3,0xf6,0x04,0x09,0x06,0xfc,0xee,0xd9, - 0xbf,0xa0,0x81,0x81,0x81,0x81,0x81,0x81,0x90,0xb0,0xcc,0xe3,0xf6,0x04,0x09,0x06, - 0xfc,0xee,0xd9,0xbf,0xa0,0x81,0x81,0x81,0x81,0x81,0x81,0x90,0xb0,0xcc,0xe3,0xf6, - 0x04,0x09,0x06,0xfc,0xee,0xd9,0xbf,0xa0,0x81,0x81,0x81,0x81,0x81,0x81,0x90,0xb0, - 0xcc,0xe3,0xf6,0x04,0x09,0x06,0xfc,0xee,0xd9,0xbf,0xa0,0x81,0x81,0x81,0x81,0x81, - 0x81,0x90,0xb0,0xcc,0xe3,0xf6,0x04,0x09,0x06,0xfc,0xee,0xd9,0xbf,0xa0,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x87,0xa7,0xc3,0xdd,0xf1,0xff,0x07,0x09,0x07,0x17,0xef,0xc7,0xa9, - 0x8a,0x81,0x81,0x81,0x88,0xb2,0xdd,0xff,0xff,0xfa,0xd0,0xba,0xba,0xba,0xc5,0xef, - 0xff,0xff,0xe7,0xbd,0x93,0x81,0x88,0xb2,0xdd,0xff,0xff,0xfa,0xd0,0xba,0xba,0xba, - 0xc5,0xef,0xff,0xff,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0xa1,0xc9,0xf1,0x19,0x2b,0x24,0xfb,0xd3,0xab,0x83,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa1,0xc9,0xf1,0x19,0x2b,0x24,0xfb, - 0xd3,0xab,0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa1,0xc9,0xf1, - 0x19,0x2b,0x24,0xfb,0xd3,0xab,0x84,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0xa1,0xc9,0xf1,0x19,0x2b,0x24,0xfb,0xd3,0xab,0x83,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x9f,0xc8,0xef,0x18,0x2b,0x24,0xfc,0xd4,0xac,0x84,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa0,0xc8,0xf1,0x19,0x29,0x23,0xfa, - 0xd2,0xaa,0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa3,0xca, - 0xf1,0x19,0x21,0x29,0x1e,0x1e,0x1e,0x1b,0xef,0xc5,0x9b,0x81,0x81,0x81,0x97,0xb8, - 0xd7,0xf3,0x0b,0x1e,0x24,0x1e,0x1e,0x23,0x20,0x06,0xda,0xb0,0x85,0x81,0x81,0x85, - 0xb0,0xda,0x06,0x29,0x23,0x23,0x23,0x23,0x23,0x23,0x1b,0xef,0xc5,0x9b,0x81,0x81, - 0x81,0x85,0xb0,0xda,0x06,0x29,0x23,0x23,0x23,0x23,0x23,0x23,0x1b,0xef,0xc5,0x9b, - 0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x29,0x23,0x23,0x23,0x23,0x23,0x23,0x1b,0xef, - 0xc5,0x9b,0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x29,0x23,0x23,0x23,0x23,0x23,0x23, - 0x1b,0xef,0xc5,0x9b,0x81,0x81,0x81,0x93,0xbd,0xe7,0x13,0x23,0x23,0x23,0x29,0x24, - 0x23,0x23,0x21,0xf5,0xca,0xa0,0x81,0x81,0x81,0x93,0xbd,0xe7,0x13,0x23,0x23,0x23, - 0x29,0x24,0x23,0x23,0x21,0xf5,0xca,0xa0,0x81,0x81,0x81,0x93,0xbd,0xe7,0x13,0x23, - 0x23,0x23,0x29,0x24,0x23,0x23,0x21,0xf5,0xca,0xa0,0x81,0x81,0x81,0x93,0xbd,0xe7, - 0x13,0x23,0x23,0x23,0x29,0x24,0x23,0x23,0x21,0xf5,0xca,0xa0,0x81,0x81,0x81,0xa5, - 0xd0,0xfa,0x26,0x24,0x23,0x23,0x26,0x1e,0x12,0xff,0xe7,0xca,0xaa,0x88,0x81,0x81, - 0x81,0x83,0xad,0xd7,0x04,0x29,0x28,0x04,0xdc,0xb5,0x98,0xc2,0xed,0x19,0x11,0xe5, - 0xba,0x90,0x81,0x81,0x87,0xab,0xcc,0xec,0x07,0x1e,0x21,0x1b,0x1e,0x26,0x14,0xf9, - 0xdb,0xba,0x97,0x81,0x81,0x81,0x81,0x87,0xab,0xcc,0xec,0x07,0x1e,0x21,0x1b,0x1e, - 0x26,0x14,0xf9,0xdb,0xba,0x97,0x81,0x81,0x81,0x81,0x87,0xab,0xcc,0xec,0x07,0x1e, - 0x21,0x1b,0x1e,0x26,0x14,0xf9,0xdb,0xba,0x97,0x81,0x81,0x81,0x81,0x87,0xab,0xcc, - 0xec,0x07,0x1e,0x21,0x1b,0x1e,0x26,0x14,0xf9,0xdb,0xba,0x97,0x81,0x81,0x81,0x81, - 0x87,0xab,0xcc,0xec,0x07,0x1e,0x21,0x1b,0x1e,0x26,0x14,0xf9,0xdb,0xba,0x97,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0xa0,0xc2,0xe3,0xff,0x17,0x25,0x1b,0x1c,0x2b,0x1c,0x04,0xe4,0xc5, - 0xa2,0x81,0x81,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x90,0x9b,0xc5,0xef, - 0x1b,0x13,0xe7,0xbd,0x93,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x90,0x9b, - 0xc5,0xef,0x1b,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x86,0xaf,0xd6,0xff,0x27,0xff,0x25,0x09,0xe1,0xb9,0x90,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x86,0xaf,0xd6,0xff,0x27,0xff,0x25,0x09, - 0xe1,0xb9,0x90,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x86,0xaf,0xd6,0xff, - 0x27,0xff,0x25,0x09,0xe1,0xb9,0x90,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x86,0xaf,0xd6,0xff,0x27,0xff,0x25,0x09,0xe1,0xb9,0x90,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x85,0xad,0xd5,0xfc,0x25,0x04,0x24,0x0a,0xe1,0xb9,0x90,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0xae,0xd6,0xfc,0x26,0xff,0x25,0x09, - 0xe0,0xb8,0x90,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8c,0xb3,0xda, - 0xff,0x1e,0x06,0x23,0xf7,0xf2,0xf2,0xf2,0xea,0xc3,0x9a,0x81,0x81,0x88,0xae,0xd2, - 0xf3,0x14,0x25,0x0c,0xfb,0xf2,0xf3,0xfa,0x06,0x06,0xda,0xb0,0x85,0x81,0x81,0x85, - 0xb0,0xda,0x06,0x29,0xfc,0xf7,0xf7,0xf7,0xf7,0xf7,0xf7,0xed,0xc4,0x9a,0x81,0x81, - 0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xf7,0xf7,0xf7,0xf7,0xf7,0xf7,0xed,0xc4,0x9a, - 0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xf7,0xf7,0xf7,0xf7,0xf7,0xf7,0xed, - 0xc4,0x9a,0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xf7,0xf7,0xf7,0xf7,0xf7, - 0xf7,0xed,0xc4,0x9a,0x81,0x81,0x81,0x92,0xbc,0xe6,0xf7,0xf7,0xf7,0xfc,0x29,0x09, - 0xf7,0xf7,0xf7,0xf1,0xc9,0x9f,0x81,0x81,0x81,0x92,0xbc,0xe6,0xf7,0xf7,0xf7,0xfc, - 0x29,0x09,0xf7,0xf7,0xf7,0xf1,0xc9,0x9f,0x81,0x81,0x81,0x92,0xbc,0xe6,0xf7,0xf7, - 0xf7,0xfc,0x29,0x09,0xf7,0xf7,0xf7,0xf1,0xc9,0x9f,0x81,0x81,0x81,0x92,0xbc,0xe6, - 0xf7,0xf7,0xf7,0xfc,0x29,0x09,0xf7,0xf7,0xf7,0xf1,0xc9,0x9f,0x81,0x81,0x81,0xa5, - 0xd0,0xfa,0x26,0x09,0xf7,0xf7,0xfc,0x06,0x18,0x22,0x07,0xe5,0xc2,0x9c,0x81,0x81, - 0x81,0x83,0xad,0xd7,0x04,0x2e,0x23,0x14,0xee,0xc8,0xa1,0xc2,0xed,0x19,0x11,0xe5, - 0xba,0x90,0x81,0x81,0x9b,0xc1,0xe6,0x09,0x27,0x0f,0xf9,0xef,0xf5,0x07,0x21,0x18, - 0xf5,0xd1,0xab,0x84,0x81,0x81,0x81,0x9b,0xc1,0xe6,0x09,0x27,0x0f,0xf9,0xef,0xf5, - 0x07,0x21,0x18,0xf5,0xd1,0xab,0x84,0x81,0x81,0x81,0x9b,0xc1,0xe6,0x09,0x27,0x0f, - 0xf9,0xef,0xf5,0x07,0x21,0x18,0xf5,0xd1,0xab,0x84,0x81,0x81,0x81,0x9b,0xc1,0xe6, - 0x09,0x27,0x0f,0xf9,0xef,0xf5,0x07,0x21,0x18,0xf5,0xd1,0xab,0x84,0x81,0x81,0x81, - 0x9b,0xc1,0xe6,0x09,0x27,0x0f,0xf9,0xef,0xf5,0x07,0x21,0x18,0xf5,0xd1,0xab,0x84, - 0x81,0x81,0x81,0x89,0xa0,0xa8,0x9c,0x83,0x81,0x81,0x83,0x9a,0xa3,0x9a,0x83,0x81, - 0x81,0x81,0x8f,0xb5,0xda,0xfc,0x1d,0x18,0xff,0xf1,0xf4,0x1c,0x1f,0x21,0xff,0xdc, - 0xb6,0x91,0x81,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b,0xc5,0xef, - 0x1b,0x13,0xe7,0xbd,0x93,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b, - 0xc5,0xef,0x1b,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x93,0xbb,0xe4,0x0c,0x1d,0xf5,0x19,0x16,0xee,0xc5,0x9d,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x93,0xbb,0xe4,0x0c,0x1d,0xf5,0x19,0x16, - 0xee,0xc5,0x9d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x93,0xbb,0xe4,0x0c, - 0x1d,0xf5,0x19,0x16,0xee,0xc5,0x9d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x94,0xbc,0xe4,0x0c,0x1d,0xf5,0x19,0x16,0xee,0xc6,0x9d,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x92,0xba,0xe2,0x0b,0x1e,0xf5,0x18,0x16,0xee,0xc6,0x9e,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x93,0xbb,0xe3,0x0b,0x1d,0xf4,0x19,0x15, - 0xed,0xc5,0x9d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9b,0xc3,0xea, - 0x11,0x0f,0x06,0x23,0xf7,0xcd,0xc8,0xc8,0xc5,0xae,0x8c,0x81,0x81,0x9b,0xc1,0xe7, - 0x0c,0x27,0x07,0xe8,0xd3,0xc9,0xca,0xd1,0xde,0xef,0xd5,0xad,0x84,0x81,0x81,0x85, - 0xb0,0xda,0x06,0x29,0xfc,0xd2,0xcd,0xcd,0xcd,0xcd,0xcd,0xca,0xb2,0x8e,0x81,0x81, - 0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xcd,0xcd,0xcd,0xcd,0xcd,0xca,0xb2,0x8e, - 0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xcd,0xcd,0xcd,0xcd,0xcd,0xca, - 0xb2,0x8e,0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xcd,0xcd,0xcd,0xcd, - 0xcd,0xca,0xb2,0x8e,0x81,0x81,0x81,0x87,0xac,0xc7,0xcd,0xcd,0xd2,0xfc,0x29,0x09, - 0xdd,0xcd,0xcd,0xcc,0xb6,0x93,0x81,0x81,0x81,0x87,0xac,0xc7,0xcd,0xcd,0xd2,0xfc, - 0x29,0x09,0xdd,0xcd,0xcd,0xcc,0xb6,0x93,0x81,0x81,0x81,0x87,0xac,0xc7,0xcd,0xcd, - 0xd2,0xfc,0x29,0x09,0xdd,0xcd,0xcd,0xcc,0xb6,0x93,0x81,0x81,0x81,0x87,0xac,0xc7, - 0xcd,0xcd,0xd2,0xfc,0x29,0x09,0xdd,0xcd,0xcd,0xcc,0xb6,0x93,0x81,0x81,0x81,0xa5, - 0xd0,0xfa,0x26,0x09,0xdd,0xcd,0xd2,0xdf,0xf5,0x16,0x20,0xfb,0xd5,0xaf,0x86,0x81, - 0x81,0x83,0xad,0xd7,0x04,0x26,0xff,0x26,0xff,0xda,0xb4,0xc2,0xed,0x19,0x11,0xe5, - 0xba,0x90,0x81,0x85,0xad,0xd3,0xfa,0x20,0x12,0xf0,0xd3,0xc5,0xcd,0xe5,0x07,0x2c, - 0x0a,0xe2,0xbb,0x93,0x81,0x81,0x85,0xad,0xd3,0xfa,0x20,0x12,0xf0,0xd3,0xc5,0xcd, - 0xe5,0x07,0x2c,0x0a,0xe2,0xbb,0x93,0x81,0x81,0x85,0xad,0xd3,0xfa,0x20,0x12,0xf0, - 0xd3,0xc5,0xcd,0xe5,0x07,0x2c,0x0a,0xe2,0xbb,0x93,0x81,0x81,0x85,0xad,0xd3,0xfa, - 0x20,0x12,0xf0,0xd3,0xc5,0xcd,0xe5,0x07,0x2c,0x0a,0xe2,0xbb,0x93,0x81,0x81,0x85, - 0xad,0xd3,0xfa,0x20,0x12,0xf0,0xd3,0xc5,0xcd,0xe5,0x07,0x2c,0x0a,0xe2,0xbb,0x93, - 0x81,0x81,0x89,0xa7,0xc4,0xd2,0xbf,0x9f,0x81,0x83,0xa1,0xbf,0xcd,0xbf,0xa1,0x83, - 0x81,0x81,0xa0,0xc7,0xee,0x14,0x1e,0xfa,0xdb,0xd7,0xff,0x1c,0xfc,0x20,0x15,0xef, - 0xc8,0x9f,0x81,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b,0xc5,0xef, - 0x1b,0x13,0xe7,0xbd,0x93,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b, - 0xc5,0xef,0x1b,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0xa0,0xc8,0xf1,0x19,0x11,0xe7,0x0c,0x23,0xfa,0xd2,0xaa,0x82, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa0,0xc8,0xf1,0x19,0x11,0xe7,0x0c,0x23, - 0xfa,0xd2,0xaa,0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa0,0xc8,0xf1,0x19, - 0x11,0xe7,0x0c,0x23,0xfa,0xd2,0xaa,0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0xa0,0xc9,0xf1,0x19,0x11,0xe7,0x0c,0x23,0xfa,0xd2,0xaa,0x82,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x9f,0xc8,0xef,0x18,0x11,0xe9,0x0b,0x24,0xfb,0xd3,0xab,0x83, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa0,0xc8,0xf1,0x19,0x0f,0xe7,0x0c,0x23, - 0xfa,0xd2,0xa9,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x84,0xac,0xd3,0xfa, - 0x21,0xff,0x06,0x23,0xf7,0xcd,0xa3,0x9d,0x9c,0x8d,0x81,0x81,0x81,0xa9,0xd2,0xf9, - 0x20,0x12,0xed,0xca,0xae,0x9f,0xa0,0xa8,0xb7,0xc5,0xb8,0x9b,0x81,0x81,0x81,0x85, - 0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0xa3,0xa3,0xa3,0xa3,0xa1,0x91,0x81,0x81,0x81, - 0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0xa3,0xa3,0xa3,0xa3,0xa1,0x91,0x81, - 0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0xa3,0xa3,0xa3,0xa3,0xa1, - 0x91,0x81,0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0xa3,0xa3,0xa3, - 0xa3,0xa1,0x91,0x81,0x81,0x81,0x81,0x81,0x8d,0x9f,0xa3,0xa8,0xd2,0xfc,0x29,0x09, - 0xdd,0xb2,0xa3,0xa2,0x94,0x81,0x81,0x81,0x81,0x81,0x8d,0x9f,0xa3,0xa8,0xd2,0xfc, - 0x29,0x09,0xdd,0xb2,0xa3,0xa2,0x94,0x81,0x81,0x81,0x81,0x81,0x8d,0x9f,0xa3,0xa8, - 0xd2,0xfc,0x29,0x09,0xdd,0xb2,0xa3,0xa2,0x94,0x81,0x81,0x81,0x81,0x81,0x8d,0x9f, - 0xa3,0xa8,0xd2,0xfc,0x29,0x09,0xdd,0xb2,0xa3,0xa2,0x94,0x81,0x81,0x81,0x81,0xa5, - 0xd0,0xfa,0x26,0x09,0xdd,0xb2,0xa9,0xbb,0xdb,0xff,0x27,0x0c,0xe4,0xbb,0x92,0x81, - 0x81,0x83,0xad,0xd7,0x04,0x26,0xfa,0x18,0x12,0xec,0xc6,0xc2,0xed,0x19,0x11,0xe5, - 0xba,0x90,0x81,0x91,0xba,0xe2,0x0b,0x27,0xff,0xd9,0xb5,0x9c,0xaa,0xcd,0xf3,0x1b, - 0x19,0xf1,0xc8,0x9e,0x81,0x81,0x91,0xba,0xe2,0x0b,0x27,0xff,0xd9,0xb5,0x9c,0xaa, - 0xcd,0xf3,0x1b,0x19,0xf1,0xc8,0x9e,0x81,0x81,0x91,0xba,0xe2,0x0b,0x27,0xff,0xd9, - 0xb5,0x9c,0xaa,0xcd,0xf3,0x1b,0x19,0xf1,0xc8,0x9e,0x81,0x81,0x91,0xba,0xe2,0x0b, - 0x27,0xff,0xd9,0xb5,0x9c,0xaa,0xcd,0xf3,0x1b,0x19,0xf1,0xc8,0x9e,0x81,0x81,0x91, - 0xba,0xe2,0x0b,0x27,0xff,0xd9,0xb5,0x9c,0xaa,0xcd,0xf3,0x1b,0x19,0xf1,0xc8,0x9e, - 0x81,0x84,0xa7,0xc5,0xe3,0xfb,0xdb,0xbd,0x9f,0xa1,0xbf,0xdd,0xf7,0xdd,0xbf,0xa0, - 0x81,0x84,0xad,0xd6,0xfc,0x26,0x0c,0xe5,0xc0,0xe4,0x0c,0x0f,0xe7,0x0f,0x25,0xfc, - 0xd4,0xab,0x82,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b,0xc5,0xef, - 0x1b,0x13,0xe7,0xbd,0x93,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b, - 0xc5,0xef,0x1b,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x85,0xae,0xd6,0xfc,0x26,0x04,0xdb,0xff,0x28,0x09,0xe0,0xb8,0x90, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0xae,0xd6,0xfc,0x26,0x04,0xdb,0xff,0x28, - 0x09,0xe0,0xb8,0x90,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0xae,0xd6,0xfc,0x26, - 0x04,0xdb,0xff,0x28,0x09,0xe0,0xb8,0x90,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85, - 0xae,0xd6,0xfc,0x26,0x04,0xdb,0xff,0x28,0x09,0xe0,0xb8,0x90,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x85,0xad,0xd5,0xfc,0x25,0x05,0xdc,0xff,0x27,0x09,0xe1,0xb8,0x90, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0xae,0xd6,0xfc,0x26,0x04,0xdb,0xff,0x28, - 0x07,0xdf,0xb7,0x8f,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x94,0xbb,0xe2,0x0a, - 0x17,0xef,0x06,0x23,0xf7,0xcd,0xba,0xba,0xb6,0x9f,0x81,0x81,0x8b,0xb4,0xdd,0x06, - 0x2b,0x04,0xdb,0xb4,0x8f,0x81,0x81,0x81,0x92,0x9b,0x93,0x81,0x81,0x81,0x81,0x85, - 0xb0,0xda,0x06,0x29,0xfc,0xd2,0xbd,0xbd,0xbd,0xbd,0xbd,0xb6,0x9d,0x81,0x81,0x81, - 0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xbd,0xbd,0xbd,0xbd,0xbd,0xb6,0x9d,0x81, - 0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xbd,0xbd,0xbd,0xbd,0xbd,0xb6, - 0x9d,0x81,0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xbd,0xbd,0xbd,0xbd, - 0xbd,0xb6,0x9d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa8,0xd2,0xfc,0x29,0x09, - 0xdd,0xb2,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa8,0xd2,0xfc, - 0x29,0x09,0xdd,0xb2,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa8, - 0xd2,0xfc,0x29,0x09,0xdd,0xb2,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0xa8,0xd2,0xfc,0x29,0x09,0xdd,0xb2,0x88,0x81,0x81,0x81,0x81,0x82,0xa3,0xb9, - 0xd0,0xfa,0x26,0x09,0xdd,0xbd,0xbd,0xad,0xc9,0xf1,0x1b,0x18,0xef,0xc5,0x9b,0x81, - 0x81,0x83,0xad,0xd7,0x04,0x26,0xfa,0x07,0x25,0xfc,0xd8,0xc2,0xed,0x19,0x11,0xe5, - 0xba,0x90,0x81,0x9a,0xc4,0xed,0x16,0x1b,0xf2,0xc9,0xa1,0x81,0x95,0xbd,0xe7,0x11, - 0x23,0xfa,0xd0,0xa6,0x81,0x81,0x9a,0xc4,0xed,0x16,0x1b,0xf2,0xc9,0xa1,0x81,0x95, - 0xbd,0xe7,0x11,0x23,0xfa,0xd0,0xa6,0x81,0x81,0x9a,0xc4,0xed,0x16,0x1b,0xf2,0xc9, - 0xa1,0x81,0x95,0xbd,0xe7,0x11,0x23,0xfa,0xd0,0xa6,0x81,0x81,0x9a,0xc4,0xed,0x16, - 0x1b,0xf2,0xc9,0xa1,0x81,0x95,0xbd,0xe7,0x11,0x23,0xfa,0xd0,0xa6,0x81,0x81,0x9a, - 0xc4,0xed,0x16,0x1b,0xf2,0xc9,0xa1,0x81,0x95,0xbd,0xe7,0x11,0x23,0xfa,0xd0,0xa6, - 0x81,0x91,0xbb,0xe2,0xff,0x18,0xf9,0xdb,0xbd,0xbf,0xdd,0xfb,0x1a,0xfb,0xdb,0xb3, - 0x8a,0x8d,0xb7,0xe0,0x0a,0x29,0xff,0xd6,0xc8,0xef,0x19,0x04,0xdb,0x04,0x2c,0x06, - 0xdd,0xb3,0x8a,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b,0xc5,0xef, - 0x1b,0x13,0xe7,0xbd,0x93,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b, - 0xc5,0xef,0x1b,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x93,0xbb,0xe3,0x0b,0x1f,0xf6,0xce,0xf2,0x1a,0x15,0xed,0xc5,0x9c, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x93,0xbb,0xe3,0x0b,0x1f,0xf6,0xce,0xf2,0x1a, - 0x15,0xed,0xc5,0x9c,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x93,0xbb,0xe3,0x0b,0x1f, - 0xf6,0xce,0xf2,0x1a,0x15,0xed,0xc5,0x9c,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x93, - 0xbb,0xe3,0x0b,0x1f,0xf6,0xce,0xf2,0x1a,0x15,0xed,0xc5,0x9d,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x92,0xba,0xe2,0x0b,0x20,0xf7,0xcf,0xf1,0x19,0x15,0xed,0xc5,0x9d, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x93,0xbb,0xe3,0x0b,0x1f,0xf6,0xce,0xf2,0x1b, - 0x14,0xec,0xc4,0x9c,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa4,0xcc,0xf3,0x19, - 0x09,0xe1,0x06,0x23,0xf7,0xe5,0xe5,0xe5,0xdb,0xb8,0x8f,0x81,0x92,0xbb,0xe5,0x0f, - 0x23,0xf7,0xcf,0xa6,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85, - 0xb0,0xda,0x06,0x29,0xfc,0xe7,0xe7,0xe7,0xe7,0xe7,0xe7,0xd9,0xb4,0x8b,0x81,0x81, - 0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xe7,0xe7,0xe7,0xe7,0xe7,0xe7,0xd9,0xb4,0x8b, - 0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xe7,0xe7,0xe7,0xe7,0xe7,0xe7,0xd9, - 0xb4,0x8b,0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xe7,0xe7,0xe7,0xe7,0xe7, - 0xe7,0xd9,0xb4,0x8b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa8,0xd2,0xfc,0x29,0x09, - 0xdd,0xb2,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa8,0xd2,0xfc, - 0x29,0x09,0xdd,0xb2,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa8, - 0xd2,0xfc,0x29,0x09,0xdd,0xb2,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0xa8,0xd2,0xfc,0x29,0x09,0xdd,0xb2,0x88,0x81,0x81,0x81,0x81,0x92,0xbb,0xdf, - 0xe7,0xfa,0x26,0x09,0xe7,0xe7,0xe7,0xc9,0xc0,0xea,0x13,0x1f,0xf5,0xca,0xa0,0x81, - 0x81,0x83,0xad,0xd7,0x04,0x26,0xfa,0xf6,0x1d,0x11,0xea,0xc4,0xed,0x19,0x11,0xe5, - 0xba,0x90,0x81,0xa0,0xca,0xf4,0x1e,0x14,0xea,0xc0,0x97,0x81,0x8c,0xb5,0xdf,0x09, - 0x29,0xff,0xd5,0xab,0x81,0x81,0xa0,0xca,0xf4,0x1e,0x14,0xea,0xc0,0x97,0x81,0x8c, - 0xb5,0xdf,0x09,0x29,0xff,0xd5,0xab,0x81,0x81,0xa0,0xca,0xf4,0x1e,0x14,0xea,0xc0, - 0x97,0x81,0x8c,0xb5,0xdf,0x09,0x29,0xff,0xd5,0xab,0x81,0x81,0xa0,0xca,0xf4,0x1e, - 0x14,0xea,0xc0,0x97,0x81,0x8c,0xb5,0xdf,0x09,0x29,0xff,0xd5,0xab,0x81,0x81,0xa0, - 0xca,0xf4,0x1e,0x14,0xea,0xc0,0x97,0x81,0x8c,0xb5,0xdf,0x09,0x29,0xff,0xd5,0xab, - 0x81,0x90,0xb9,0xdf,0xfc,0x1c,0x18,0xf9,0xdb,0xdd,0xfb,0x1a,0x14,0xf5,0xd7,0xb1, - 0x88,0x93,0xbd,0xe7,0x11,0x21,0xf7,0xcd,0xd3,0xfc,0x20,0xf7,0xd2,0xfc,0x26,0x0d, - 0xe2,0xb8,0x8d,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b,0xc5,0xef, - 0x1b,0x13,0xe7,0xbd,0x93,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b, - 0xc5,0xef,0x1b,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0xa0,0xc8,0xf1,0x19,0x12,0xea,0xc2,0xe6,0x0e,0x22,0xfa,0xd2,0xa9, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa0,0xc8,0xf1,0x19,0x12,0xea,0xc2,0xe6,0x0e, - 0x22,0xfa,0xd2,0xa9,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa0,0xc8,0xf1,0x19,0x12, - 0xea,0xc2,0xe6,0x0e,0x22,0xfa,0xd2,0xa9,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa0, - 0xc8,0xf1,0x19,0x12,0xea,0xc2,0xe6,0x0e,0x22,0xfa,0xd2,0xa9,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x9f,0xc8,0xef,0x18,0x13,0xeb,0xc3,0xe5,0x0d,0x23,0xfa,0xd2,0xaa, - 0x82,0x81,0x81,0x81,0x81,0x81,0x81,0xa0,0xc8,0xf1,0x19,0x12,0xea,0xc2,0xe6,0x0f, - 0x22,0xfa,0xd1,0xa9,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8d,0xb4,0xdb,0x04,0x20, - 0xf9,0xda,0x06,0x27,0x11,0x11,0x11,0x11,0xe7,0xbd,0x93,0x81,0x95,0xc0,0xea,0x14, - 0x1e,0xf2,0xc9,0x9f,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85, - 0xb0,0xda,0x06,0x2d,0x13,0x13,0x13,0x13,0x13,0x13,0x0e,0xe2,0xb8,0x8d,0x81,0x81, - 0x81,0x85,0xb0,0xda,0x06,0x2d,0x13,0x13,0x13,0x13,0x13,0x13,0x0e,0xe2,0xb8,0x8d, - 0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x2d,0x13,0x13,0x13,0x13,0x13,0x13,0x0e,0xe2, - 0xb8,0x8d,0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x2d,0x13,0x13,0x13,0x13,0x13,0x13, - 0x0e,0xe2,0xb8,0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa8,0xd2,0xfc,0x29,0x09, - 0xdd,0xb2,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa8,0xd2,0xfc, - 0x29,0x09,0xdd,0xb2,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa8, - 0xd2,0xfc,0x29,0x09,0xdd,0xb2,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0xa8,0xd2,0xfc,0x29,0x09,0xdd,0xb2,0x88,0x81,0x81,0x81,0x81,0x95,0xc0,0xea, - 0x13,0x13,0x2b,0x15,0x13,0x13,0xfa,0xd0,0xbb,0xe5,0x11,0x23,0xf7,0xcd,0xa3,0x81, - 0x81,0x83,0xad,0xd7,0x04,0x26,0xfa,0xe5,0x0b,0x22,0xfc,0xd5,0xed,0x19,0x11,0xe5, - 0xba,0x90,0x81,0xa3,0xcd,0xf7,0x23,0x11,0xe5,0xbb,0x92,0x81,0x88,0xb2,0xdb,0x06, - 0x2e,0x04,0xd7,0xad,0x83,0x81,0xa3,0xcd,0xf7,0x23,0x11,0xe5,0xbb,0x92,0x81,0x88, - 0xb2,0xdb,0x06,0x2e,0x04,0xd7,0xad,0x83,0x81,0xa3,0xcd,0xf7,0x23,0x11,0xe5,0xbb, - 0x92,0x81,0x88,0xb2,0xdb,0x06,0x2e,0x04,0xd7,0xad,0x83,0x81,0xa3,0xcd,0xf7,0x23, - 0x11,0xe5,0xbb,0x92,0x81,0x88,0xb2,0xdb,0x06,0x2e,0x04,0xd7,0xad,0x83,0x81,0xa3, - 0xcd,0xf7,0x23,0x11,0xe5,0xbb,0x92,0x81,0x88,0xb2,0xdb,0x06,0x2e,0x04,0xd7,0xad, - 0x83,0x81,0xa3,0xc1,0xdf,0xfc,0x1c,0x18,0xf9,0xfb,0x1a,0x14,0xf5,0xd7,0xb9,0x9b, - 0x81,0x95,0xc0,0xea,0x16,0x1e,0xf2,0xc8,0xe0,0x09,0x14,0xec,0xce,0xf7,0x23,0x11, - 0xe5,0xba,0x90,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b,0xc5,0xef, - 0x1b,0x13,0xe7,0xbd,0x93,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b, - 0xc5,0xef,0x1b,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x85,0xae,0xd6,0xfc,0x26,0x06,0xdd,0xb4,0xd9,0xff,0x2a,0x07,0xdf,0xb7, - 0x8f,0x81,0x81,0x81,0x81,0x81,0x85,0xae,0xd6,0xfc,0x26,0x06,0xdd,0xb4,0xd9,0xff, - 0x2a,0x07,0xdf,0xb7,0x8f,0x81,0x81,0x81,0x81,0x81,0x85,0xae,0xd6,0xfc,0x26,0x06, - 0xdd,0xb4,0xd9,0xff,0x2a,0x07,0xdf,0xb7,0x8f,0x81,0x81,0x81,0x81,0x81,0x85,0xae, - 0xd6,0xfc,0x26,0x06,0xdd,0xb4,0xd9,0xff,0x2a,0x07,0xdf,0xb7,0x8f,0x81,0x81,0x81, - 0x81,0x81,0x85,0xad,0xd5,0xfc,0x25,0x06,0xde,0xb6,0xd8,0xff,0x29,0x09,0xe0,0xb8, - 0x90,0x81,0x81,0x81,0x81,0x81,0x85,0xae,0xd6,0xfc,0x26,0x06,0xdd,0xb5,0xd9,0x04, - 0x2a,0x06,0xde,0xb6,0x8e,0x81,0x81,0x81,0x81,0x81,0x81,0x9d,0xc4,0xec,0x13,0x11, - 0xe9,0xda,0x06,0x25,0x0b,0x0b,0x0b,0x0b,0xe7,0xbd,0x93,0x81,0x95,0xc0,0xea,0x16, - 0x1e,0xf2,0xc8,0x9d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85, - 0xb0,0xda,0x06,0x2b,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0xe2,0xb8,0x8d,0x81,0x81, - 0x81,0x85,0xb0,0xda,0x06,0x2b,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0xe2,0xb8,0x8d, - 0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x2b,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e,0xe2, - 0xb8,0x8d,0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x2b,0x0e,0x0e,0x0e,0x0e,0x0e,0x0e, - 0x0e,0xe2,0xb8,0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa8,0xd2,0xfc,0x29,0x09, - 0xdd,0xb2,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa8,0xd2,0xfc, - 0x29,0x09,0xdd,0xb2,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa8, - 0xd2,0xfc,0x29,0x09,0xdd,0xb2,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0xa8,0xd2,0xfc,0x29,0x09,0xdd,0xb2,0x88,0x81,0x81,0x81,0x81,0x95,0xc0,0xea, - 0x0e,0x0e,0x29,0x11,0x0e,0x0e,0xfa,0xd0,0xba,0xe5,0x11,0x23,0xf7,0xcd,0xa3,0x81, - 0x81,0x83,0xad,0xd7,0x04,0x26,0xfa,0xd2,0xf9,0x1f,0x0f,0xe8,0xed,0x19,0x11,0xe5, - 0xba,0x90,0x81,0xa3,0xcd,0xf7,0x23,0x11,0xe5,0xba,0x90,0x81,0x85,0xb0,0xda,0x06, - 0x2e,0x04,0xd7,0xad,0x83,0x81,0xa3,0xcd,0xf7,0x23,0x11,0xe5,0xba,0x90,0x81,0x85, - 0xb0,0xda,0x06,0x2e,0x04,0xd7,0xad,0x83,0x81,0xa3,0xcd,0xf7,0x23,0x11,0xe5,0xba, - 0x90,0x81,0x85,0xb0,0xda,0x06,0x2e,0x04,0xd7,0xad,0x83,0x81,0xa3,0xcd,0xf7,0x23, - 0x11,0xe5,0xba,0x90,0x81,0x85,0xb0,0xda,0x06,0x2e,0x04,0xd7,0xad,0x83,0x81,0xa3, - 0xcd,0xf7,0x23,0x11,0xe5,0xba,0x90,0x81,0x85,0xb0,0xda,0x06,0x2e,0x04,0xd7,0xad, - 0x83,0x81,0x85,0xa3,0xc1,0xdf,0xfc,0x1c,0x18,0x1a,0x14,0xf5,0xd7,0xb9,0x9b,0x81, - 0x81,0x95,0xc0,0xea,0x16,0x1e,0xf2,0xc8,0xec,0x14,0x09,0xdf,0xcd,0xf7,0x23,0x11, - 0xe5,0xba,0x90,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b,0xc5,0xef, - 0x1b,0x13,0xe7,0xbd,0x93,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b, - 0xc5,0xef,0x1b,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x93,0xbb,0xe3,0x0b,0x21,0xf9,0xd0,0xd0,0xd0,0xf5,0x1d,0x14,0xec,0xc4, - 0x9b,0x81,0x81,0x81,0x81,0x81,0x93,0xbb,0xe3,0x0b,0x21,0xf9,0xd0,0xd0,0xd0,0xf5, - 0x1d,0x14,0xec,0xc4,0x9b,0x81,0x81,0x81,0x81,0x81,0x93,0xbb,0xe3,0x0b,0x21,0xf9, - 0xd0,0xd0,0xd0,0xf5,0x1d,0x14,0xec,0xc4,0x9b,0x81,0x81,0x81,0x81,0x81,0x93,0xbb, - 0xe3,0x0b,0x21,0xf9,0xd0,0xd0,0xd0,0xf5,0x1d,0x14,0xec,0xc4,0x9c,0x81,0x81,0x81, - 0x81,0x81,0x92,0xba,0xe2,0x0b,0x22,0xfa,0xd2,0xd0,0xd0,0xf4,0x1c,0x15,0xed,0xc4, - 0x9c,0x81,0x81,0x81,0x81,0x81,0x93,0xbb,0xe3,0x0b,0x21,0xf9,0xd1,0xd0,0xd0,0xf5, - 0x1e,0x14,0xec,0xc3,0x9b,0x81,0x81,0x81,0x81,0x81,0x86,0xad,0xd4,0xfb,0x22,0x04, - 0xda,0xda,0x06,0x23,0xf7,0xdf,0xdf,0xdf,0xd7,0xb5,0x8e,0x81,0x95,0xbf,0xe9,0x13, - 0x21,0xf5,0xcc,0xa2,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85, - 0xb0,0xda,0x06,0x29,0xfc,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xd5,0xb2,0x89,0x81,0x81, - 0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xd5,0xb2,0x89, - 0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xe2,0xe2,0xe2,0xe2,0xe2,0xe2,0xd5, - 0xb2,0x89,0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xe2,0xe2,0xe2,0xe2,0xe2, - 0xe2,0xd5,0xb2,0x89,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa8,0xd2,0xfc,0x29,0x09, - 0xdd,0xb2,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa8,0xd2,0xfc, - 0x29,0x09,0xdd,0xb2,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa8, - 0xd2,0xfc,0x29,0x09,0xdd,0xb2,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0xa8,0xd2,0xfc,0x29,0x09,0xdd,0xb2,0x88,0x81,0x81,0x81,0x81,0x91,0xb9,0xdb, - 0xe2,0xfa,0x26,0x09,0xe2,0xe2,0xe1,0xc7,0xbf,0xe8,0x13,0x1f,0xf5,0xca,0xa0,0x81, - 0x81,0x83,0xad,0xd7,0x04,0x26,0xfa,0xd0,0xe7,0x0d,0x20,0xfa,0xed,0x19,0x11,0xe5, - 0xba,0x90,0x81,0xa2,0xcc,0xf5,0x21,0x13,0xe7,0xbd,0x94,0x81,0x8a,0xb4,0xdd,0x09, - 0x2b,0xff,0xd5,0xab,0x81,0x81,0xa2,0xcc,0xf5,0x21,0x13,0xe7,0xbd,0x94,0x81,0x8a, - 0xb4,0xdd,0x09,0x2b,0xff,0xd5,0xab,0x81,0x81,0xa2,0xcc,0xf5,0x21,0x13,0xe7,0xbd, - 0x94,0x81,0x8a,0xb4,0xdd,0x09,0x2b,0xff,0xd5,0xab,0x81,0x81,0xa2,0xcc,0xf5,0x21, - 0x13,0xe7,0xbd,0x94,0x81,0x8a,0xb4,0xdd,0x09,0x2b,0xff,0xd5,0xab,0x81,0x81,0xa2, - 0xcc,0xf5,0x21,0x13,0xe7,0xbd,0x94,0x81,0x8a,0xb4,0xdd,0x09,0x2b,0xff,0xd5,0xab, - 0x81,0x81,0x81,0x85,0xa3,0xc1,0xdf,0xfc,0x26,0x21,0xf9,0xdb,0xbd,0x9f,0x81,0x81, - 0x81,0x95,0xbf,0xe8,0x13,0x21,0xf5,0xcf,0xf7,0x20,0xfb,0xd3,0xd1,0xfa,0x26,0x0e, - 0xe2,0xb8,0x8f,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b,0xc5,0xef, - 0x1b,0x13,0xe7,0xbd,0x93,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b, - 0xc5,0xef,0x1b,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0xa0,0xc8,0xf1,0x19,0x16,0xfa,0xfa,0xfa,0xfa,0xfa,0x11,0x21,0xf9,0xd1, - 0xa9,0x81,0x81,0x81,0x81,0x81,0xa0,0xc8,0xf1,0x19,0x16,0xfa,0xfa,0xfa,0xfa,0xfa, - 0x11,0x21,0xf9,0xd1,0xa9,0x81,0x81,0x81,0x81,0x81,0xa0,0xc8,0xf1,0x19,0x16,0xfa, - 0xfa,0xfa,0xfa,0xfa,0x11,0x21,0xf9,0xd1,0xa9,0x81,0x81,0x81,0x81,0x81,0xa0,0xc8, - 0xf1,0x19,0x16,0xfa,0xfa,0xfa,0xfa,0xfa,0x11,0x21,0xf9,0xd1,0xa9,0x81,0x81,0x81, - 0x81,0x81,0x9f,0xc8,0xef,0x18,0x16,0xfa,0xfa,0xfa,0xfa,0xfa,0x11,0x22,0xfa,0xd2, - 0xa9,0x81,0x81,0x81,0x81,0x81,0x9f,0xc8,0xf1,0x19,0x16,0xfa,0xfa,0xfa,0xfa,0xfa, - 0x11,0x21,0xf9,0xd1,0xa8,0x81,0x81,0x81,0x81,0x81,0x95,0xbd,0xe4,0x0b,0x1a,0xf2, - 0xef,0xef,0x06,0x23,0xf7,0xcd,0xb5,0xb5,0xb1,0x9b,0x81,0x81,0x91,0xba,0xe5,0x0e, - 0x26,0xfc,0xd4,0xab,0x84,0x81,0x81,0x81,0x81,0x88,0x82,0x81,0x81,0x81,0x81,0x85, - 0xb0,0xda,0x06,0x29,0xfc,0xd2,0xb8,0xb8,0xb8,0xb8,0xb8,0xb2,0x9a,0x81,0x81,0x81, - 0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xb8,0xb8,0xb8,0xb8,0xb8,0xb2,0x9a,0x81, - 0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xb8,0xb8,0xb8,0xb8,0xb8,0xb2, - 0x9a,0x81,0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xb8,0xb8,0xb8,0xb8, - 0xb8,0xb2,0x9a,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa8,0xd2,0xfc,0x29,0x09, - 0xdd,0xb2,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa8,0xd2,0xfc, - 0x29,0x09,0xdd,0xb2,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa8, - 0xd2,0xfc,0x29,0x09,0xdd,0xb2,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0xa8,0xd2,0xfc,0x29,0x09,0xdd,0xb2,0x88,0x81,0x81,0x81,0x81,0x81,0x9f,0xb4, - 0xd0,0xfa,0x26,0x09,0xdd,0xb8,0xb7,0xa9,0xc8,0xf1,0x19,0x19,0xef,0xc5,0x9c,0x81, - 0x81,0x83,0xad,0xd7,0x04,0x26,0xfa,0xd0,0xd4,0xfb,0x21,0x0b,0xed,0x19,0x11,0xe5, - 0xba,0x90,0x81,0x9e,0xc8,0xf2,0x1c,0x18,0xed,0xc4,0x9b,0x81,0x92,0xbb,0xe4,0x0e, - 0x24,0xfa,0xd1,0xa7,0x81,0x81,0x9e,0xc8,0xf2,0x1c,0x18,0xed,0xc4,0x9b,0x81,0x92, - 0xbb,0xe4,0x0e,0x24,0xfa,0xd1,0xa7,0x81,0x81,0x9e,0xc8,0xf2,0x1c,0x18,0xed,0xc4, - 0x9b,0x81,0x92,0xbb,0xe4,0x0e,0x24,0xfa,0xd1,0xa7,0x81,0x81,0x9e,0xc8,0xf2,0x1c, - 0x18,0xed,0xc4,0x9b,0x81,0x92,0xbb,0xe4,0x0e,0x24,0xfa,0xd1,0xa7,0x81,0x81,0x9e, - 0xc8,0xf2,0x1c,0x18,0xed,0xc4,0x9b,0x81,0x92,0xbb,0xe4,0x0e,0x24,0xfa,0xd1,0xa7, - 0x81,0x81,0x83,0xa1,0xbf,0xdd,0xfb,0x1a,0x14,0x1c,0x18,0xf9,0xdb,0xbd,0x9f,0x81, - 0x81,0x91,0xba,0xe5,0x0f,0x24,0xfa,0xdc,0x04,0x19,0xef,0xc8,0xd7,0xff,0x2b,0x09, - 0xdd,0xb4,0x8a,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b,0xc5,0xef, - 0x1b,0x13,0xe7,0xbd,0x93,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b, - 0xc5,0xef,0x1b,0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x85,0xae,0xd6,0xfc,0x26,0x2b,0x26,0x26,0x26,0x26,0x26,0x2a,0x2e,0x06,0xde, - 0xb6,0x8e,0x81,0x81,0x81,0x85,0xae,0xd6,0xfc,0x26,0x2b,0x26,0x26,0x26,0x26,0x26, - 0x2a,0x2e,0x06,0xde,0xb6,0x8e,0x81,0x81,0x81,0x85,0xae,0xd6,0xfc,0x26,0x2b,0x26, - 0x26,0x26,0x26,0x26,0x2a,0x2e,0x06,0xde,0xb6,0x8e,0x81,0x81,0x81,0x85,0xae,0xd6, - 0xfc,0x26,0x2b,0x26,0x26,0x26,0x26,0x26,0x2a,0x2e,0x06,0xde,0xb6,0x8e,0x81,0x81, - 0x81,0x85,0xad,0xd5,0xfc,0x25,0x2b,0x26,0x26,0x26,0x26,0x26,0x2a,0x2f,0x07,0xdf, - 0xb7,0x8f,0x81,0x81,0x81,0x85,0xad,0xd5,0xfc,0x25,0x2b,0x26,0x26,0x26,0x26,0x26, - 0x2a,0x2e,0x06,0xdd,0xb5,0x8d,0x81,0x81,0x81,0x81,0xa6,0xcd,0xf4,0x1b,0x23,0x1b, - 0x1b,0x1b,0x1c,0x23,0xf7,0xcd,0xa3,0x8d,0x8d,0x81,0x81,0x81,0x8a,0xb3,0xdc,0x06, - 0x2e,0x09,0xe2,0xbd,0x9e,0x90,0x90,0x98,0xa7,0xb2,0xaa,0x90,0x81,0x81,0x81,0x85, - 0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x90,0x90,0x90,0x90,0x8f,0x81,0x81,0x81,0x81, - 0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x90,0x90,0x90,0x90,0x8f,0x81,0x81, - 0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x90,0x90,0x90,0x90,0x8f, - 0x81,0x81,0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xa8,0x90,0x90,0x90, - 0x90,0x8f,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8d,0x90,0xa8,0xd2,0xfc,0x29,0x09, - 0xdd,0xb2,0x90,0x8f,0x84,0x81,0x81,0x81,0x81,0x81,0x81,0x8d,0x90,0xa8,0xd2,0xfc, - 0x29,0x09,0xdd,0xb2,0x90,0x8f,0x84,0x81,0x81,0x81,0x81,0x81,0x81,0x8d,0x90,0xa8, - 0xd2,0xfc,0x29,0x09,0xdd,0xb2,0x90,0x8f,0x84,0x81,0x81,0x81,0x81,0x81,0x81,0x8d, - 0x90,0xa8,0xd2,0xfc,0x29,0x09,0xdd,0xb2,0x90,0x8f,0x84,0x81,0x81,0x81,0x81,0xa5, - 0xd0,0xfa,0x26,0x09,0xdd,0xb2,0x9e,0xb6,0xd9,0xfc,0x25,0x0d,0xe5,0xbd,0x94,0x81, - 0x81,0x83,0xad,0xd7,0x04,0x26,0xfa,0xd0,0xc2,0xe9,0x0f,0x1d,0xf5,0x19,0x11,0xe5, - 0xba,0x90,0x81,0x98,0xc1,0xea,0x13,0x20,0xf7,0xd0,0xaa,0x8c,0xa3,0xc8,0xef,0x18, - 0x19,0xf1,0xc8,0x9f,0x81,0x81,0x98,0xc1,0xea,0x13,0x20,0xf7,0xd0,0xaa,0x8c,0xa3, - 0xc8,0xef,0x18,0x19,0xf1,0xc8,0x9f,0x81,0x81,0x98,0xc1,0xea,0x13,0x20,0xf7,0xd0, - 0xaa,0x8c,0xa3,0xc8,0xef,0x18,0x19,0xf1,0xc8,0x9f,0x81,0x81,0x98,0xc1,0xea,0x13, - 0x20,0xf7,0xd0,0xaa,0x8c,0xa3,0xc8,0xef,0x18,0x19,0xf1,0xc8,0x9f,0x81,0x81,0x98, - 0xc1,0xea,0x13,0x20,0xf7,0xd0,0xaa,0x8c,0xa3,0xc8,0xef,0x18,0x19,0xf1,0xc8,0x9f, - 0x81,0x81,0xa1,0xbf,0xdd,0xfb,0x1a,0x14,0xf5,0xfc,0x1c,0x18,0xf9,0xdb,0xbd,0x9f, - 0x81,0x8b,0xb4,0xdd,0x06,0x2c,0x04,0xe7,0x11,0x0c,0xe4,0xbc,0xe3,0x0b,0x26,0xfc, - 0xd5,0xac,0x83,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfc,0xd2,0xa9,0x89,0xa0,0xc9,0xf2, - 0x1e,0x11,0xe5,0xbc,0x92,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfc,0xd2,0xa9,0x89,0xa0, - 0xc9,0xf2,0x1e,0x11,0xe5,0xbc,0x92,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x93,0xbb,0xe3,0x0b,0x23,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x14,0xec, - 0xc3,0x9b,0x81,0x81,0x81,0x93,0xbb,0xe3,0x0b,0x23,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0x1f,0x14,0xec,0xc3,0x9b,0x81,0x81,0x81,0x93,0xbb,0xe3,0x0b,0x23,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0x1f,0x14,0xec,0xc3,0x9b,0x81,0x81,0x81,0x93,0xbb,0xe3, - 0x0b,0x23,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1f,0x14,0xec,0xc3,0x9b,0x81,0x81, - 0x81,0x91,0xba,0xe2,0x0b,0x24,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1e,0x14,0xec, - 0xc4,0x9b,0x81,0x81,0x81,0x92,0xba,0xe2,0x0b,0x23,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0x1f,0x13,0xeb,0xc3,0x9a,0x81,0x81,0x81,0x8e,0xb5,0xdc,0x04,0x24,0x04,0x04, - 0x04,0x04,0x07,0x23,0xf7,0xcd,0xb8,0xb8,0xb7,0xa6,0x88,0x81,0x81,0xa8,0xd0,0xf7, - 0x1e,0x1b,0xf9,0xd9,0xc3,0xba,0xba,0xc1,0xcd,0xdd,0xcc,0xa8,0x81,0x81,0x81,0x85, - 0xb0,0xda,0x06,0x29,0xfc,0xd2,0xba,0xba,0xba,0xba,0xba,0xb8,0xa5,0x85,0x81,0x81, - 0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xba,0xba,0xba,0xba,0xba,0xb8,0xa5,0x85, - 0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xba,0xba,0xba,0xba,0xba,0xb8, - 0xa5,0x85,0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xd2,0xba,0xba,0xba,0xba, - 0xba,0xb8,0xa5,0x85,0x81,0x81,0x81,0x81,0x9f,0xb6,0xba,0xba,0xd2,0xfc,0x29,0x09, - 0xdd,0xba,0xba,0xb9,0xa8,0x89,0x81,0x81,0x81,0x81,0x9f,0xb6,0xba,0xba,0xd2,0xfc, - 0x29,0x09,0xdd,0xba,0xba,0xb9,0xa8,0x89,0x81,0x81,0x81,0x81,0x9f,0xb6,0xba,0xba, - 0xd2,0xfc,0x29,0x09,0xdd,0xba,0xba,0xb9,0xa8,0x89,0x81,0x81,0x81,0x81,0x9f,0xb6, - 0xba,0xba,0xd2,0xfc,0x29,0x09,0xdd,0xba,0xba,0xb9,0xa8,0x89,0x81,0x81,0x81,0xa5, - 0xd0,0xfa,0x26,0x09,0xdd,0xbf,0xc6,0xd6,0xf1,0x12,0x22,0xfc,0xd6,0xaf,0x87,0x81, - 0x81,0x83,0xad,0xd7,0x04,0x26,0xfa,0xd0,0xb1,0xd6,0xfc,0x24,0x06,0x19,0x11,0xe5, - 0xba,0x90,0x81,0x8e,0xb7,0xdf,0x07,0x2e,0x09,0xe3,0xc4,0xb6,0xc1,0xde,0xff,0x27, - 0x0a,0xe3,0xbb,0x94,0x81,0x81,0x8e,0xb7,0xdf,0x07,0x2e,0x09,0xe3,0xc4,0xb6,0xc1, - 0xde,0xff,0x27,0x0a,0xe3,0xbb,0x94,0x81,0x81,0x8e,0xb7,0xdf,0x07,0x2e,0x09,0xe3, - 0xc4,0xb6,0xc1,0xde,0xff,0x27,0x0a,0xe3,0xbb,0x94,0x81,0x81,0x8e,0xb7,0xdf,0x07, - 0x2e,0x09,0xe3,0xc4,0xb6,0xc1,0xde,0xff,0x27,0x0a,0xe3,0xbb,0x94,0x81,0x81,0x8e, - 0xb7,0xdf,0x07,0x2e,0x09,0xe3,0xc4,0xb6,0xc1,0xde,0xff,0x27,0x0a,0xe3,0xbb,0x94, - 0x81,0x8e,0xb7,0xdd,0xfb,0x1a,0x14,0xf5,0xd7,0xdf,0xfc,0x1c,0x18,0xf9,0xda,0xb3, - 0x89,0x81,0xa9,0xd2,0xfa,0x21,0x13,0xf4,0x1c,0xff,0xd7,0xd4,0xf6,0x1b,0x17,0xef, - 0xc8,0xa0,0x81,0x81,0x84,0xae,0xd7,0xff,0x2a,0x05,0xde,0xbd,0xb2,0xb9,0xd7,0xfc, - 0x25,0x07,0xdf,0xb5,0x8c,0x81,0x84,0xae,0xd7,0xff,0x2a,0x05,0xde,0xbd,0xb2,0xb9, - 0xd7,0xfc,0x25,0x07,0xdf,0xb5,0x8c,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0xa0,0xc8,0xf1,0x19,0x16,0xed,0xd5,0xd5,0xd5,0xd5,0xd5,0xea,0x12,0x21,0xf7, - 0xd0,0xa8,0x81,0x81,0x81,0xa0,0xc8,0xf1,0x19,0x16,0xed,0xd5,0xd5,0xd5,0xd5,0xd5, - 0xea,0x12,0x21,0xf7,0xd0,0xa8,0x81,0x81,0x81,0xa0,0xc8,0xf1,0x19,0x16,0xed,0xd5, - 0xd5,0xd5,0xd5,0xd5,0xea,0x12,0x21,0xf7,0xd0,0xa8,0x81,0x81,0x81,0xa0,0xc8,0xf1, - 0x19,0x16,0xed,0xd5,0xd5,0xd5,0xd5,0xd5,0xea,0x12,0x21,0xf7,0xd0,0xa8,0x81,0x81, - 0x81,0x9f,0xc7,0xef,0x17,0x17,0xef,0xd5,0xd5,0xd5,0xd5,0xd5,0xe9,0x11,0x21,0xf9, - 0xd1,0xa9,0x81,0x81,0x81,0x9f,0xc8,0xef,0x18,0x16,0xee,0xd5,0xd5,0xd5,0xd5,0xd5, - 0xea,0x13,0x20,0xf7,0xd0,0xa8,0x81,0x81,0x81,0x9e,0xc6,0xed,0x14,0x14,0xec,0xd7, - 0xd7,0xda,0x06,0x23,0xf7,0xe2,0xe2,0xe2,0xe0,0xc2,0x9b,0x81,0x81,0x99,0xbf,0xe5, - 0x09,0x2b,0x16,0xfc,0xeb,0xe3,0xe3,0xea,0xf5,0x05,0xda,0xb0,0x85,0x81,0x81,0x85, - 0xb0,0xda,0x06,0x29,0xfc,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe0,0xbf,0x97,0x81,0x81, - 0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe0,0xbf,0x97, - 0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe0, - 0xbf,0x97,0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x29,0xfc,0xe5,0xe5,0xe5,0xe5,0xe5, - 0xe5,0xe0,0xbf,0x97,0x81,0x81,0x81,0x8f,0xb8,0xdb,0xe5,0xe5,0xe5,0xfc,0x29,0x09, - 0xe5,0xe5,0xe5,0xe2,0xc4,0x9c,0x81,0x81,0x81,0x8f,0xb8,0xdb,0xe5,0xe5,0xe5,0xfc, - 0x29,0x09,0xe5,0xe5,0xe5,0xe2,0xc4,0x9c,0x81,0x81,0x81,0x8f,0xb8,0xdb,0xe5,0xe5, - 0xe5,0xfc,0x29,0x09,0xe5,0xe5,0xe5,0xe2,0xc4,0x9c,0x81,0x81,0x81,0x8f,0xb8,0xdb, - 0xe5,0xe5,0xe5,0xfc,0x29,0x09,0xe5,0xe5,0xe5,0xe2,0xc4,0x9c,0x81,0x81,0x81,0xa5, - 0xd0,0xfa,0x26,0x09,0xe7,0xe7,0xef,0xfc,0x12,0x27,0x09,0xe7,0xc4,0x9e,0x81,0x81, - 0x81,0x83,0xad,0xd7,0x04,0x26,0xfa,0xd0,0xa5,0xc5,0xeb,0x12,0x1a,0x20,0x11,0xe5, - 0xba,0x90,0x81,0x81,0xa8,0xcf,0xf5,0x1a,0x1f,0xff,0xe9,0xdf,0xe7,0xfb,0x1a,0x1a, - 0xf6,0xd2,0xac,0x85,0x81,0x81,0x81,0xa8,0xcf,0xf5,0x1a,0x1f,0xff,0xe9,0xdf,0xe7, - 0xfb,0x1a,0x1a,0xf6,0xd2,0xac,0x85,0x81,0x81,0x81,0xa8,0xcf,0xf5,0x1a,0x1f,0xff, - 0xe9,0xdf,0xe7,0xfb,0x1a,0x1a,0xf6,0xd2,0xac,0x85,0x81,0x81,0x81,0xa8,0xcf,0xf5, - 0x1a,0x1f,0xff,0xe9,0xdf,0xe7,0xfb,0x1a,0x1a,0xf6,0xd2,0xac,0x85,0x81,0x81,0x81, - 0xa8,0xcf,0xf5,0x1a,0x1f,0xff,0xe9,0xdf,0xe7,0xfb,0x1a,0x1a,0xf6,0xd2,0xac,0x85, - 0x81,0x8f,0xb8,0xe0,0xff,0x14,0xf5,0xd7,0xb9,0xc1,0xdf,0xff,0x18,0xf9,0xda,0xb3, - 0x89,0x81,0x9c,0xc3,0xe9,0x0f,0x28,0x0b,0x1d,0xf4,0xe2,0xf3,0x10,0x25,0xff,0xde, - 0xb8,0x91,0x81,0x81,0x81,0xa4,0xcd,0xf5,0x1b,0x18,0xf7,0xe3,0xdd,0xe2,0xf3,0x12, - 0x1d,0xf7,0xd2,0xa9,0x81,0x81,0x81,0xa4,0xcd,0xf5,0x1b,0x18,0xf7,0xe3,0xdd,0xe2, - 0xf3,0x12,0x1d,0xf7,0xd2,0xa9,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x85,0xad,0xd6,0xfc,0x26,0x09,0xe1,0xb9,0xab,0xab,0xab,0xb4,0xdc,0x06,0x2e,0x06, - 0xdd,0xb5,0x8d,0x81,0x85,0xad,0xd6,0xfc,0x26,0x09,0xe1,0xb9,0xab,0xab,0xab,0xb4, - 0xdc,0x06,0x2e,0x06,0xdd,0xb5,0x8d,0x81,0x85,0xad,0xd6,0xfc,0x26,0x09,0xe1,0xb9, - 0xab,0xab,0xab,0xb4,0xdc,0x06,0x2e,0x06,0xdd,0xb5,0x8d,0x81,0x85,0xad,0xd6,0xfc, - 0x26,0x09,0xe1,0xb9,0xab,0xab,0xab,0xb4,0xdc,0x06,0x2e,0x06,0xdd,0xb5,0x8d,0x81, - 0x84,0xac,0xd4,0xfc,0x24,0x0a,0xe1,0xb9,0xab,0xab,0xab,0xb4,0xdc,0x05,0x2d,0x06, - 0xde,0xb6,0x8e,0x81,0x85,0xad,0xd5,0xfc,0x25,0x09,0xe1,0xb9,0xab,0xab,0xab,0xb5, - 0xdd,0x06,0x2d,0x05,0xdc,0xb4,0x8c,0x81,0x87,0xae,0xd5,0xfc,0x24,0x05,0xdd,0xb6, - 0xb0,0xda,0x06,0x26,0x0e,0x0e,0x0e,0x0e,0xf5,0xca,0xa0,0x81,0x81,0x86,0xaa,0xcd, - 0xee,0x0b,0x24,0x21,0x14,0x0e,0x0e,0x13,0x1e,0x06,0xda,0xb0,0x85,0x81,0x81,0x85, - 0xb0,0xda,0x06,0x2c,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0xef,0xc5,0x9b,0x81,0x81, - 0x81,0x85,0xb0,0xda,0x06,0x2c,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0xef,0xc5,0x9b, - 0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x2c,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0xef, - 0xc5,0x9b,0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x2c,0x11,0x11,0x11,0x11,0x11,0x11, - 0x11,0xef,0xc5,0x9b,0x81,0x81,0x81,0x93,0xbd,0xe7,0x11,0x11,0x11,0x11,0x2c,0x13, - 0x11,0x11,0x11,0xf5,0xca,0xa0,0x81,0x81,0x81,0x93,0xbd,0xe7,0x11,0x11,0x11,0x11, - 0x2c,0x13,0x11,0x11,0x11,0xf5,0xca,0xa0,0x81,0x81,0x81,0x93,0xbd,0xe7,0x11,0x11, - 0x11,0x11,0x2c,0x13,0x11,0x11,0x11,0xf5,0xca,0xa0,0x81,0x81,0x81,0x93,0xbd,0xe7, - 0x11,0x11,0x11,0x11,0x2c,0x13,0x11,0x11,0x11,0xf5,0xca,0xa0,0x81,0x81,0x81,0xa5, - 0xd0,0xfa,0x26,0x15,0x13,0x13,0x19,0x23,0x1b,0x06,0xec,0xcd,0xac,0x89,0x81,0x81, - 0x81,0x83,0xad,0xd7,0x04,0x26,0xfa,0xd0,0xa5,0xb3,0xd9,0xff,0x26,0x3b,0x11,0xe5, - 0xba,0x90,0x81,0x81,0x97,0xbb,0xde,0xff,0x1c,0x22,0x11,0x0b,0x0f,0x1f,0x1a,0xfc, - 0xde,0xbc,0x98,0x81,0x81,0x81,0x81,0x97,0xbb,0xde,0xff,0x1c,0x22,0x11,0x0b,0x0f, - 0x1f,0x1a,0xfc,0xde,0xbc,0x98,0x81,0x81,0x81,0x81,0x97,0xbb,0xde,0xff,0x1c,0x22, - 0x11,0x0b,0x0f,0x1f,0x1a,0xfc,0xde,0xbc,0x98,0x81,0x81,0x81,0x81,0x97,0xbb,0xde, - 0xff,0x1c,0x22,0x11,0x0b,0x0f,0x1f,0x1a,0xfc,0xde,0xbc,0x98,0x81,0x81,0x81,0x81, - 0x97,0xbb,0xde,0xff,0x1c,0x22,0x11,0x0b,0x0f,0x1f,0x1a,0xfc,0xde,0xbc,0x98,0x81, - 0x81,0x81,0xa5,0xc3,0xe1,0xf5,0xd7,0xb9,0x9b,0xa3,0xc3,0xe1,0xf9,0xdb,0xbd,0x9f, - 0x81,0x81,0x8b,0xb0,0xd4,0xf5,0x14,0x2c,0x1a,0x0b,0x0c,0x19,0x22,0x07,0xe8,0xc7, - 0xa4,0x81,0x81,0x81,0x81,0x97,0xbc,0xe1,0x04,0x20,0x1b,0x0d,0x09,0x0b,0x18,0x1f, - 0x04,0xe2,0xbf,0x99,0x81,0x81,0x81,0x97,0xbc,0xe1,0x04,0x20,0x1b,0x0d,0x09,0x0b, - 0x18,0x1f,0x04,0xe2,0xbf,0x99,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x8f,0xb9,0xe2,0x0b,0x11,0xfc,0xd3,0xab,0x83,0x81,0x81,0xa8,0xd0,0xf7,0x11,0x11, - 0xeb,0xc2,0x98,0x81,0x8f,0xb9,0xe2,0x0b,0x11,0xfc,0xd3,0xab,0x83,0x81,0x81,0xa8, - 0xd0,0xf7,0x11,0x11,0xeb,0xc2,0x98,0x81,0x8f,0xb9,0xe2,0x0b,0x11,0xfc,0xd3,0xab, - 0x83,0x81,0x81,0xa8,0xd0,0xf7,0x11,0x11,0xeb,0xc2,0x98,0x81,0x8f,0xb9,0xe2,0x0b, - 0x11,0xfc,0xd3,0xab,0x83,0x81,0x81,0xa8,0xd0,0xf7,0x11,0x11,0xeb,0xc2,0x98,0x81, - 0x8f,0xb9,0xe1,0x0a,0x11,0xfc,0xd5,0xac,0x84,0x81,0x81,0xa7,0xcf,0xf7,0x11,0x11, - 0xec,0xc3,0x9a,0x81,0x8f,0xb9,0xe2,0x0b,0x11,0xfc,0xd4,0xac,0x84,0x81,0x81,0xa8, - 0xd1,0xf9,0x11,0x11,0xea,0xc1,0x97,0x81,0x92,0xbc,0xe6,0x0d,0x11,0xf5,0xce,0xa7, - 0xb0,0xda,0x06,0x11,0x11,0x11,0x11,0x11,0xf5,0xca,0xa0,0x81,0x81,0x81,0x92,0xb2, - 0xd0,0xe9,0xfc,0x0c,0x20,0x1d,0x17,0x11,0x07,0xfa,0xd9,0xaf,0x85,0x81,0x81,0x85, - 0xb0,0xda,0x06,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0xef,0xc5,0x9b,0x81,0x81, - 0x81,0x85,0xb0,0xda,0x06,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0xef,0xc5,0x9b, - 0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0xef, - 0xc5,0x9b,0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x11,0x11,0x11,0x11,0x11,0x11,0x11, - 0x11,0xef,0xc5,0x9b,0x81,0x81,0x81,0x93,0xbd,0xe7,0x11,0x11,0x11,0x11,0x11,0x11, - 0x11,0x11,0x11,0xf5,0xca,0xa0,0x81,0x81,0x81,0x93,0xbd,0xe7,0x11,0x11,0x11,0x11, - 0x11,0x11,0x11,0x11,0x11,0xf5,0xca,0xa0,0x81,0x81,0x81,0x93,0xbd,0xe7,0x11,0x11, - 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0xf5,0xca,0xa0,0x81,0x81,0x81,0x93,0xbd,0xe7, - 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0xf5,0xca,0xa0,0x81,0x81,0x81,0xa5, - 0xd0,0xfa,0x11,0x11,0x11,0x0f,0x0b,0x04,0xf4,0xe2,0xcb,0xb0,0x92,0x81,0x81,0x81, - 0x81,0x83,0xad,0xd7,0x04,0x11,0xfa,0xd0,0xa5,0xa1,0xc7,0xed,0x11,0x11,0x11,0xe5, - 0xba,0x90,0x81,0x81,0x81,0xa3,0xc3,0xe0,0xf9,0x0b,0x15,0x19,0x14,0x09,0xf6,0xdf, - 0xc1,0xa3,0x81,0x81,0x81,0x81,0x81,0x81,0xa3,0xc3,0xe0,0xf9,0x0b,0x15,0x19,0x14, - 0x09,0xf6,0xdf,0xc1,0xa3,0x81,0x81,0x81,0x81,0x81,0x81,0xa3,0xc3,0xe0,0xf9,0x0b, - 0x15,0x19,0x14,0x09,0xf6,0xdf,0xc1,0xa3,0x81,0x81,0x81,0x81,0x81,0x81,0xa3,0xc3, - 0xe0,0xf9,0x0b,0x15,0x19,0x14,0x09,0xf6,0xdf,0xc1,0xa3,0x81,0x81,0x81,0x81,0x81, - 0x81,0xa3,0xc3,0xe0,0xf9,0x0b,0x15,0x19,0x14,0x09,0xf6,0xdf,0xc1,0xa3,0x81,0x81, - 0x81,0x81,0x87,0xa5,0xc2,0xcc,0xb9,0x9b,0x81,0x87,0xa5,0xc2,0xcf,0xbd,0x9f,0x81, - 0x81,0x81,0x81,0x99,0xb9,0xd7,0xf1,0x19,0x13,0x19,0x16,0x0d,0xfc,0xe6,0xcc,0xac, - 0x8c,0x81,0x81,0x81,0x81,0x83,0xa7,0xc7,0xe4,0xfc,0x0d,0x16,0x19,0x16,0x0c,0xfb, - 0xe3,0xc7,0xa7,0x84,0x81,0x81,0x81,0x83,0xa7,0xc7,0xe4,0xfc,0x0d,0x16,0x19,0x16, - 0x0c,0xfb,0xe3,0xc7,0xa7,0x84,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x8d,0xb5,0xd9,0xe5,0xe5,0xe3,0xc6,0x9f,0x81,0x81,0x81,0x9a,0xc1,0xe1,0xe5,0xe5, - 0xde,0xbc,0x94,0x81,0x8d,0xb5,0xd9,0xe5,0xe5,0xe3,0xc6,0x9f,0x81,0x81,0x81,0x9a, - 0xc1,0xe1,0xe5,0xe5,0xde,0xbc,0x94,0x81,0x8d,0xb5,0xd9,0xe5,0xe5,0xe3,0xc6,0x9f, - 0x81,0x81,0x81,0x9a,0xc1,0xe1,0xe5,0xe5,0xde,0xbc,0x94,0x81,0x8d,0xb5,0xd9,0xe5, - 0xe5,0xe3,0xc6,0x9f,0x81,0x81,0x81,0x9a,0xc1,0xe1,0xe5,0xe5,0xde,0xbc,0x94,0x81, - 0x8d,0xb5,0xd9,0xe5,0xe5,0xe3,0xc6,0x9f,0x81,0x81,0x81,0x9a,0xc1,0xe1,0xe5,0xe5, - 0xe0,0xbf,0x97,0x81,0x8d,0xb5,0xd9,0xe5,0xe5,0xe3,0xc6,0x9f,0x81,0x81,0x81,0x9b, - 0xc2,0xe1,0xe5,0xe5,0xde,0xbc,0x94,0x81,0x8f,0xb8,0xdb,0xe5,0xe5,0xe0,0xbf,0x98, - 0xab,0xd1,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe2,0xc4,0x9c,0x81,0x81,0x81,0x81,0x94, - 0xaf,0xc5,0xd6,0xf7,0x20,0x09,0xed,0xe7,0xdf,0xd2,0xc0,0xa1,0x81,0x81,0x81,0x82, - 0xab,0xd1,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe0,0xbf,0x97,0x81,0x81, - 0x81,0x82,0xab,0xd1,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe0,0xbf,0x97, - 0x81,0x81,0x81,0x82,0xab,0xd1,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe0, - 0xbf,0x97,0x81,0x81,0x81,0x82,0xab,0xd1,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5, - 0xe5,0xe0,0xbf,0x97,0x81,0x81,0x81,0x8f,0xb8,0xdb,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5, - 0xe5,0xe5,0xe5,0xe2,0xc4,0x9c,0x81,0x81,0x81,0x8f,0xb8,0xdb,0xe5,0xe5,0xe5,0xe5, - 0xe5,0xe5,0xe5,0xe5,0xe5,0xe2,0xc4,0x9c,0x81,0x81,0x81,0x8f,0xb8,0xdb,0xe5,0xe5, - 0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe2,0xc4,0x9c,0x81,0x81,0x81,0x8f,0xb8,0xdb, - 0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe2,0xc4,0x9c,0x81,0x81,0x81,0xa1, - 0xc8,0xe4,0xe5,0xe5,0xe5,0xe5,0xe0,0xd9,0xcd,0xbc,0xa8,0x90,0x81,0x81,0x81,0x81, - 0x81,0x81,0xa9,0xcf,0xe5,0xe5,0xe4,0xc8,0xa1,0x8f,0xb5,0xd9,0xe5,0xe5,0xe5,0xd9, - 0xb5,0x8d,0x81,0x81,0x81,0x87,0xa5,0xbe,0xd3,0xe2,0xea,0xed,0xea,0xe1,0xd1,0xbd, - 0xa3,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x87,0xa5,0xbe,0xd3,0xe2,0xea,0xed,0xea, - 0xe1,0xd1,0xbd,0xa3,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x87,0xa5,0xbe,0xd3,0xe2, - 0xea,0xed,0xea,0xe1,0xd1,0xbd,0xa3,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x87,0xa5, - 0xbe,0xd3,0xe2,0xea,0xed,0xea,0xe1,0xd1,0xbd,0xa3,0x85,0x81,0x81,0x81,0x81,0x81, - 0x81,0x87,0xa5,0xbe,0xd3,0xe2,0xea,0xed,0xea,0xe1,0xd1,0xbd,0xa3,0x85,0x81,0x81, - 0x81,0x81,0x81,0x86,0x9c,0xa2,0x97,0x81,0x81,0x81,0x87,0x9d,0xa5,0x9a,0x81,0x81, - 0x81,0x81,0x81,0x82,0xaa,0xd3,0xfb,0x21,0xf7,0xed,0xec,0xe4,0xd6,0xc4,0xac,0x90, - 0x81,0x81,0x81,0x81,0x81,0x81,0x8b,0xa9,0xc2,0xd6,0xe4,0xea,0xed,0xea,0xe3,0xd5, - 0xc1,0xa8,0x8b,0x81,0x81,0x81,0x81,0x81,0x8b,0xa9,0xc2,0xd6,0xe4,0xea,0xed,0xea, - 0xe3,0xd5,0xc1,0xa8,0x8b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x9d,0xb5,0xba,0xba,0xba,0xa9,0x8b,0x81,0x81,0x81,0x87,0xa6,0xb9,0xba,0xba, - 0xb8,0xa3,0x83,0x81,0x81,0x9d,0xb5,0xba,0xba,0xba,0xa9,0x8b,0x81,0x81,0x81,0x87, - 0xa6,0xb9,0xba,0xba,0xb8,0xa3,0x83,0x81,0x81,0x9d,0xb5,0xba,0xba,0xba,0xa9,0x8b, - 0x81,0x81,0x81,0x87,0xa6,0xb9,0xba,0xba,0xb8,0xa3,0x83,0x81,0x81,0x9d,0xb5,0xba, - 0xba,0xba,0xa9,0x8b,0x81,0x81,0x81,0x87,0xa6,0xb9,0xba,0xba,0xb8,0xa3,0x83,0x81, - 0x81,0x9d,0xb5,0xba,0xba,0xba,0xa9,0x8b,0x81,0x81,0x81,0x87,0xa6,0xb9,0xba,0xba, - 0xb8,0xa5,0x85,0x81,0x81,0x9d,0xb5,0xba,0xba,0xba,0xa9,0x8b,0x81,0x81,0x81,0x88, - 0xa6,0xb9,0xba,0xba,0xb8,0xa3,0x83,0x81,0x81,0x9f,0xb6,0xba,0xba,0xb8,0xa5,0x85, - 0x96,0xb1,0xba,0xba,0xba,0xba,0xba,0xba,0xb9,0xa8,0x89,0x81,0x81,0x81,0x81,0x81, - 0x8b,0xae,0xd7,0xff,0x25,0xfc,0xd4,0xbe,0xb6,0xaa,0x9b,0x85,0x81,0x81,0x81,0x81, - 0x96,0xb1,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xb8,0xa5,0x85,0x81,0x81, - 0x81,0x81,0x96,0xb1,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xb8,0xa5,0x85, - 0x81,0x81,0x81,0x81,0x96,0xb1,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xb8, - 0xa5,0x85,0x81,0x81,0x81,0x81,0x96,0xb1,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba, - 0xba,0xb8,0xa5,0x85,0x81,0x81,0x81,0x81,0x9f,0xb6,0xba,0xba,0xba,0xba,0xba,0xba, - 0xba,0xba,0xba,0xb9,0xa8,0x89,0x81,0x81,0x81,0x81,0x9f,0xb6,0xba,0xba,0xba,0xba, - 0xba,0xba,0xba,0xba,0xba,0xb9,0xa8,0x89,0x81,0x81,0x81,0x81,0x9f,0xb6,0xba,0xba, - 0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xb9,0xa8,0x89,0x81,0x81,0x81,0x81,0x9f,0xb6, - 0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xb9,0xa8,0x89,0x81,0x81,0x81,0x8d, - 0xab,0xba,0xba,0xba,0xba,0xba,0xb7,0xaf,0xa4,0x96,0x84,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x94,0xaf,0xba,0xba,0xba,0xab,0x8d,0x81,0x9d,0xb5,0xba,0xba,0xba,0xb5, - 0x9d,0x81,0x81,0x81,0x81,0x81,0x83,0x9a,0xad,0xb9,0xc1,0xc2,0xc0,0xb8,0xab,0x98, - 0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x83,0x9a,0xad,0xb9,0xc1,0xc2,0xc0, - 0xb8,0xab,0x98,0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x83,0x9a,0xad,0xb9, - 0xc1,0xc2,0xc0,0xb8,0xab,0x98,0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x83, - 0x9a,0xad,0xb9,0xc1,0xc2,0xc0,0xb8,0xab,0x98,0x82,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x83,0x9a,0xad,0xb9,0xc1,0xc2,0xc0,0xb8,0xab,0x98,0x82,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x8e,0xb6,0xdf,0x09,0x15,0xec,0xc4,0xc2,0xbb,0xaf,0x9f,0x89,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x88,0x9e,0xaf,0xbb,0xc1,0xc2,0xc1,0xba,0xae, - 0x9c,0x86,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x88,0x9e,0xaf,0xbb,0xc1,0xc2,0xc1, - 0xba,0xae,0x9c,0x86,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x8d,0x90,0x90,0x90,0x85,0x81,0x81,0x81,0x81,0x81,0x82,0x8f,0x90,0x90, - 0x8e,0x81,0x81,0x81,0x81,0x81,0x8d,0x90,0x90,0x90,0x85,0x81,0x81,0x81,0x81,0x81, - 0x82,0x8f,0x90,0x90,0x8e,0x81,0x81,0x81,0x81,0x81,0x8d,0x90,0x90,0x90,0x85,0x81, - 0x81,0x81,0x81,0x81,0x82,0x8f,0x90,0x90,0x8e,0x81,0x81,0x81,0x81,0x81,0x8d,0x90, - 0x90,0x90,0x85,0x81,0x81,0x81,0x81,0x81,0x82,0x8f,0x90,0x90,0x8e,0x81,0x81,0x81, - 0x81,0x81,0x8d,0x90,0x90,0x90,0x85,0x81,0x81,0x81,0x81,0x81,0x82,0x8f,0x90,0x90, - 0x8f,0x81,0x81,0x81,0x81,0x81,0x8d,0x90,0x90,0x90,0x85,0x81,0x81,0x81,0x81,0x81, - 0x82,0x8f,0x90,0x90,0x8e,0x81,0x81,0x81,0x81,0x81,0x8d,0x90,0x90,0x8f,0x81,0x81, - 0x81,0x8a,0x90,0x90,0x90,0x90,0x90,0x90,0x8f,0x84,0x81,0x81,0x81,0x81,0x81,0x81, - 0x8e,0xb7,0xe0,0x0a,0x19,0xf1,0xc8,0x9f,0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x8a,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x8f,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x8a,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x8f,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x8a,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x8f, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8a,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90, - 0x90,0x8f,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8d,0x90,0x90,0x90,0x90,0x90,0x90, - 0x90,0x90,0x90,0x8f,0x84,0x81,0x81,0x81,0x81,0x81,0x81,0x8d,0x90,0x90,0x90,0x90, - 0x90,0x90,0x90,0x90,0x90,0x8f,0x84,0x81,0x81,0x81,0x81,0x81,0x81,0x8d,0x90,0x90, - 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x8f,0x84,0x81,0x81,0x81,0x81,0x81,0x81,0x8d, - 0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x8f,0x84,0x81,0x81,0x81,0x81,0x81, - 0x86,0x90,0x90,0x90,0x90,0x90,0x8d,0x86,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x89,0x90,0x90,0x90,0x86,0x81,0x81,0x81,0x8d,0x90,0x90,0x90,0x8d, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0x90,0x97,0x98,0x97,0x8f,0x83,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0x90,0x97,0x98,0x97, - 0x8f,0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0x90, - 0x97,0x98,0x97,0x8f,0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x85,0x90,0x97,0x98,0x97,0x8f,0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x85,0x90,0x97,0x98,0x97,0x8f,0x83,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x92,0xbd,0xe7,0xfa,0xfa,0xe1,0xb8,0x98,0x92,0x87,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x87,0x91,0x97,0x98,0x97,0x91,0x86, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x87,0x91,0x97,0x98,0x97, - 0x91,0x86,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x92,0xbd,0xe7,0xfa,0xfa,0xe5,0xbc,0x94,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x88,0xad,0xc9,0xd0,0xd0,0xc5,0xa7,0x82,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x88,0xad,0xc9,0xd0,0xd0,0xc8,0xab,0x86,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x8f,0xa2,0xa5,0xa5,0x9f,0x8a,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x8f,0xa2,0xa5,0xa5,0xa1,0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x8b,0xa7,0xc5,0xda,0xda,0xda,0xcb,0xae,0x92,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x86,0xa8,0xc5,0xd8,0xd9,0xc8,0xac,0xc2,0xd6,0xda,0xcb, - 0xb0,0x8e,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9d,0xbb,0xd6,0xda, - 0xda,0xda,0xd0,0xae,0x87,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x87,0x8b,0x89,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x8d,0xaa,0xc7,0xe3,0xff,0x06,0x06,0xea,0xce,0xb1,0x94,0x81, - 0x81,0x81,0x81,0x81,0x81,0x97,0xbf,0xe3,0xff,0xff,0xe8,0xc4,0xdf,0xfc,0x04,0xec, - 0xc8,0xa1,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9d,0xbb,0xd9,0xf7,0x06, - 0x06,0x05,0xe2,0xb8,0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x84,0x8c, - 0x90,0x90,0x8c,0x84,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x88,0x8b, - 0x8b,0x8b,0x89,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x88,0x8b,0x8b,0x8b,0x8a,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x8a,0x8b,0x8b,0x82,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x84,0x8b,0x8b,0x84,0x81,0x81,0x85,0x82,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0x85,0x81,0x81,0x81,0x85,0x85,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8d,0xa2,0xb1,0xb5,0xb2,0xa5, - 0x91,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x88,0x8b,0x8b, - 0x8b,0x89,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x87,0x8b,0x8b,0x8b,0x8a,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x8a,0x8b,0x8b,0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x85,0x85,0x81,0x81,0x81,0x85,0x85,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x88,0x8b,0x8b,0x8b,0x89,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x86,0x8b,0x8b, - 0x8b,0x8a,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8a,0x8b,0x8b, - 0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0x85,0x81, - 0x81,0x81,0x84,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x83,0x8b,0x8b, - 0x8b,0x89,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x88,0x88,0x81,0x81,0x81,0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x88,0x8b,0x8b,0x8b,0x89,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x87,0x8b,0x8b,0x8b,0x8a,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8a,0x8b,0x8b,0x83,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x84,0x8b,0x8b,0x84,0x81, - 0x81,0x84,0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0x85, - 0x81,0x81,0x81,0x84,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x8a,0xac,0xc8,0xe6,0x04,0x1f,0x0a,0x1d,0x0a,0xec,0xd0,0xb4,0x93, - 0x81,0x81,0x81,0x81,0x81,0x9d,0xc8,0xf2,0x1d,0x21,0xf7,0xcd,0xed,0x18,0x26,0xfc, - 0xd2,0xa8,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9c,0xbb,0xd9,0xf7,0x16,0x16, - 0xfc,0xe3,0xca,0xaa,0x84,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x89,0x9d,0xac,0xb6, - 0xba,0xba,0xb6,0xac,0x9b,0x86,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9b,0xb1,0xb5, - 0xb5,0xb5,0xb3,0x9f,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x9a,0xb0,0xb5,0xb5,0xb5,0xb3,0xa0,0x82,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x87,0xa4,0xb4,0xb5,0xb5,0xa8,0x8c,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x83,0x9b,0xac,0xb5,0xb5,0xad,0x9c,0x9e,0xaf,0xab,0x96,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x8a,0xa1,0xaf,0xaf,0xa4,0x8d,0xa0,0xaf,0xb0,0xa5, - 0x8f,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0xac,0xc7,0xd9,0xdf,0xdc,0xcb, - 0xb2,0x94,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9b,0xb1,0xb5,0xb5, - 0xb5,0xb3,0x9f,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x98,0xaf,0xb5,0xb5,0xb5,0xb3,0xa0,0x82,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x87,0xa4,0xb4,0xb5,0xb5,0xa9,0x8e,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x8a,0xa1,0xaf,0xaf,0xa4,0x8d,0xa0,0xaf,0xb0,0xa5,0x8f,0x81,0x81, - 0x81,0x81,0x81,0x81,0x9b,0xb1,0xb5,0xb5,0xb5,0xb3,0x9f,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x96,0xae,0xb5,0xb5, - 0xb5,0xb4,0xa2,0x84,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0xa2,0xb4,0xb5,0xb5, - 0xa9,0x8e,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x89,0xa0,0xaf,0xb0,0xa5, - 0x8f,0x9f,0xae,0xb0,0xa6,0x91,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0xa9,0xb5,0xb5, - 0xb5,0xb3,0x9f,0x91,0x9a,0xa0,0x97,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x82,0x99, - 0xaa,0xb2,0xb2,0xaa,0x99,0x9d,0xac,0xa9,0x94,0x81,0x81,0x81,0x81,0x81,0x81,0x9a, - 0xb0,0xb5,0xb5,0xb5,0xb3,0x9f,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x98,0xaf,0xb5,0xb5,0xb5,0xb3,0xa0,0x82, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x87,0xa4,0xb4,0xb5,0xb5,0xa9,0x8e,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x83,0x9b,0xac,0xb5,0xb5,0xad,0x9c, - 0x9c,0xae,0xac,0x97,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x89,0xa0,0xaf,0xb0, - 0xa5,0x8f,0x9f,0xae,0xb0,0xa6,0x91,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x8c,0xa3,0xc1,0xe8,0x05,0x11,0xff,0xe6,0xfb,0x11,0x0d,0xf0,0xcb,0xa7, - 0x93,0x81,0x81,0x81,0x8c,0xa3,0xc3,0xe9,0x0a,0x0b,0xee,0xc8,0xe5,0x07,0x0e,0xf1, - 0xcd,0xa7,0x93,0x81,0x81,0x95,0xa8,0xab,0xab,0xab,0xae,0xd6,0xf7,0x13,0x0f,0xf4, - 0xdb,0xc2,0xab,0xab,0xaa,0x9b,0x81,0x81,0x81,0x93,0xa5,0xa8,0xa8,0xa6,0x94,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x90,0xac,0xc3,0xd4,0xdf, - 0xe5,0xe5,0xdf,0xd4,0xc1,0xa8,0x8b,0x81,0x81,0x81,0x81,0x81,0x8e,0xb5,0xd7,0xdf, - 0xdf,0xdf,0xda,0xbd,0x9f,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x98,0xb6,0xd5,0xdf,0xdf,0xdf,0xdb,0xbc,0x95,0x81,0x81,0x81, - 0x81,0x81,0x81,0x87,0xa5,0xc3,0xdd,0xdf,0xdf,0xc8,0xaa,0x8c,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x84,0xa3,0xbf,0xd4,0xdf,0xdf,0xd4,0xc1,0xbd,0xd7,0xd1,0xb4,0x96, - 0x81,0x81,0x81,0x81,0x81,0x86,0xa8,0xc6,0xd8,0xd9,0xc8,0xac,0xc4,0xd7,0xda,0xca, - 0xae,0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa6,0xca,0xe8,0xff,0x0b,0x04,0xee, - 0xd0,0xad,0x87,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0xb5,0xd7,0xdf,0xdf, - 0xdf,0xda,0xbd,0x9f,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x98,0xb6,0xd4,0xdf,0xdf,0xdf,0xdb,0xbc,0x95,0x81,0x81,0x81,0x81, - 0x81,0x81,0x87,0xa5,0xc3,0xdd,0xdf,0xdf,0xca,0xac,0x8e,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x86,0xa8,0xc6,0xd8,0xd9,0xc8,0xac,0xc4,0xd7,0xda,0xca,0xae,0x8d,0x81, - 0x81,0x81,0x81,0x8e,0xb5,0xd7,0xdf,0xdf,0xdf,0xda,0xbd,0x9f,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x96,0xb4,0xd2,0xdf,0xdf, - 0xdf,0xdc,0xbf,0x98,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0xa3,0xc1,0xdc,0xdf,0xdf, - 0xca,0xac,0x8e,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x84,0xa7,0xc4,0xd7,0xda,0xca, - 0xae,0xc3,0xd6,0xda,0xcb,0xb0,0x8f,0x81,0x81,0x81,0x81,0x81,0xa4,0xca,0xdf,0xdf, - 0xdf,0xda,0xbc,0xbb,0xc4,0xca,0xbb,0x9b,0x81,0x81,0x81,0x81,0x81,0x83,0xa1,0xbd, - 0xd2,0xdd,0xdd,0xd2,0xbf,0xbd,0xd6,0xcf,0xb2,0x94,0x81,0x81,0x81,0x81,0x8b,0xb3, - 0xd5,0xdf,0xdf,0xdf,0xda,0xbd,0x9f,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x98,0xb6,0xd4,0xdf,0xdf,0xdf,0xdb,0xbc,0x95, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x87,0xa5,0xc3,0xdd,0xdf,0xdf,0xca,0xac,0x8e, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x83,0xa1,0xbe,0xd3,0xdf,0xdf,0xd5,0xc2, - 0xbb,0xd6,0xd3,0xb6,0x98,0x81,0x81,0x81,0x81,0x81,0x81,0x84,0xa7,0xc4,0xd7,0xda, - 0xca,0xae,0xc3,0xd6,0xda,0xcb,0xb0,0x8f,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0xa7,0xc8,0xd5,0xde,0xe5,0xe5,0xde,0xc5,0xd9,0xe5,0xe5,0xe3,0xd5,0xce, - 0xb0,0x8a,0x81,0x81,0xa7,0xc8,0xd5,0xd5,0xe2,0xe3,0xd1,0xb3,0xca,0xe1,0xe4,0xd5, - 0xd5,0xce,0xb0,0x8a,0x8d,0xb2,0xcf,0xd5,0xd5,0xd5,0xc5,0xd3,0xe7,0xe7,0xe7,0xd3, - 0xb9,0xd2,0xd5,0xd5,0xd3,0xbb,0x97,0x81,0x8c,0xb1,0xcd,0xd2,0xd2,0xce,0xb3,0x8e, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8b,0xad,0xcc,0xe7,0xfb,0x09, - 0x11,0x11,0x09,0xfa,0xe4,0xc7,0xa4,0x81,0x81,0x81,0x81,0x81,0x92,0xbc,0xe6,0x04, - 0x0b,0x0b,0xf9,0xdb,0xbb,0x9d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x98,0xb6,0xd4,0xf1,0x0b,0x0b,0x09,0xed,0xc4,0x9a,0x81,0x81,0x81, - 0x81,0x81,0x87,0xa5,0xc3,0xe1,0xff,0x0b,0x05,0xe6,0xc8,0xaa,0x8c,0x81,0x81,0x81, - 0x81,0x81,0x81,0x9c,0xbf,0xdf,0xf9,0x09,0x09,0xfa,0xe5,0xd9,0xf9,0xf0,0xd2,0xaf, - 0x88,0x81,0x81,0x81,0x81,0x99,0xc0,0xe4,0xff,0x04,0xe8,0xc5,0xe2,0xff,0x04,0xea, - 0xc7,0xa0,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0xb7,0xdf,0x05,0x12,0xff,0x0f,0x0b, - 0xe6,0xbe,0x96,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x92,0xbc,0xe6,0x04,0x0b, - 0x0b,0xf9,0xdb,0xbd,0x9f,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x98,0xb6,0xd4,0xf1,0x0b,0x0b,0x09,0xed,0xc4,0x9a,0x81,0x81,0x81,0x81, - 0x81,0x87,0xa5,0xc3,0xe1,0xff,0x0b,0x07,0xe8,0xca,0xac,0x8e,0x81,0x81,0x81,0x81, - 0x81,0x81,0x99,0xc0,0xe4,0xff,0x04,0xe8,0xc5,0xe2,0xff,0x04,0xea,0xc7,0xa0,0x81, - 0x81,0x81,0x81,0x92,0xbc,0xe6,0x04,0x0b,0x0b,0xf9,0xdb,0xbd,0x9f,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x96,0xb4,0xd2,0xf0,0x0b,0x0b, - 0x0b,0xef,0xc7,0x9d,0x81,0x81,0x81,0x81,0x81,0x85,0xa3,0xc1,0xdf,0xfc,0x0b,0x07, - 0xe8,0xca,0xac,0x8e,0x81,0x81,0x81,0x81,0x81,0x81,0x96,0xbe,0xe2,0xff,0x04,0xea, - 0xc7,0xe0,0xfc,0x04,0xec,0xc9,0xa3,0x81,0x81,0x81,0x81,0x85,0xaa,0xd4,0xfb,0x0b, - 0x0b,0xf7,0xdc,0xe4,0xed,0xf5,0xd3,0xaa,0x81,0x81,0x81,0x81,0x81,0x9c,0xbe,0xdd, - 0xf7,0x06,0x06,0xf7,0xe3,0xd7,0xf7,0xee,0xd0,0xae,0x87,0x81,0x81,0x81,0x90,0xba, - 0xe3,0x04,0x0b,0x0b,0xf9,0xdb,0xbd,0x9f,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x98,0xb6,0xd4,0xf1,0x0b,0x0b,0x09,0xed,0xc4,0x9a, - 0x81,0x81,0x81,0x81,0x81,0x81,0x87,0xa5,0xc3,0xe1,0xff,0x0b,0x07,0xe8,0xca,0xac, - 0x8e,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9c,0xbf,0xdd,0xf9,0x09,0x09,0xfb,0xe6, - 0xd8,0xf6,0xf1,0xd4,0xb2,0x8b,0x81,0x81,0x81,0x81,0x81,0x96,0xbe,0xe2,0xff,0x04, - 0xea,0xc7,0xe0,0xfc,0x04,0xec,0xc9,0xa3,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x88,0xb2,0xdd,0xff,0xff,0xfa,0xd0,0xb8,0xa3,0xb5,0xc5,0xef,0xff,0xff,0xe7, - 0xbd,0x93,0x81,0x88,0xb2,0xdd,0xff,0xff,0xfa,0xd0,0xad,0x96,0xa8,0xc5,0xef,0xff, - 0xff,0xe7,0xbd,0x93,0x95,0xc0,0xea,0xff,0xff,0xff,0xdb,0xb6,0xbd,0xbd,0xbd,0xb0, - 0xcd,0xf3,0xff,0xff,0xf5,0xca,0xa0,0x81,0x95,0xc0,0xea,0xfc,0xfc,0xec,0xc2,0x9d, - 0x9b,0x96,0x8b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa0,0xc5,0xe8,0x09,0x21,0x14, - 0x0b,0x0d,0x19,0x1f,0x04,0xdf,0xb9,0x91,0x81,0x81,0x81,0x81,0x87,0xac,0xc8,0xe1, - 0xfb,0x14,0x16,0xf7,0xd9,0xbb,0x9d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x97,0xb6,0xd4,0xf1,0x10,0x1a,0xff,0xe6,0xcd,0xb2,0x8e,0x81,0x81,0x81, - 0x81,0x84,0xa5,0xc3,0xe1,0xff,0x1d,0x09,0x1f,0x05,0xe6,0xc8,0xaa,0x8b,0x81,0x81, - 0x81,0x81,0x84,0xae,0xd6,0xfa,0x1c,0x0f,0x12,0x20,0x0a,0xff,0x14,0x09,0xe2,0xb8, - 0x8d,0x81,0x81,0x81,0x81,0xa0,0xca,0xf5,0x1f,0x23,0xfa,0xd0,0xf2,0x1c,0x25,0xfc, - 0xd2,0xa8,0x81,0x81,0x81,0x81,0x81,0x81,0x93,0xbd,0xe7,0x13,0xfc,0xd7,0xf5,0x1a, - 0xef,0xc5,0x9b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x87,0xac,0xc8,0xe1,0xfb, - 0x14,0x18,0xf9,0xdb,0xbd,0x9f,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x97,0xb6,0xd4,0xf1,0x10,0x1a,0xff,0xe7,0xce,0xb2,0x8e,0x81,0x81,0x81,0x81, - 0x86,0xa7,0xc3,0xe1,0xff,0x1d,0x0a,0x1f,0x07,0xe8,0xca,0xac,0x8d,0x81,0x81,0x81, - 0x81,0x81,0xa0,0xca,0xf5,0x1f,0x23,0xfa,0xd0,0xf2,0x1c,0x25,0xfc,0xd2,0xa8,0x81, - 0x81,0x81,0x81,0x87,0xac,0xc8,0xe1,0xfb,0x14,0x18,0xf9,0xdb,0xbd,0x9f,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xb4,0xd2,0xf0,0x0f,0x1d,0x04, - 0xe9,0xd0,0xb4,0x91,0x81,0x81,0x81,0x81,0x82,0xa3,0xc1,0xdf,0xfc,0x1c,0x0c,0x1f, - 0x07,0xe8,0xca,0xac,0x8d,0x81,0x81,0x81,0x81,0x81,0x9d,0xc8,0xf2,0x1c,0x25,0xfc, - 0xd2,0xef,0x19,0x27,0xff,0xd5,0xab,0x81,0x81,0x81,0x81,0x9c,0xc1,0xd9,0xe2,0xff, - 0x22,0x12,0x06,0x0e,0x16,0xff,0xd5,0xab,0x81,0x81,0x81,0x81,0x84,0xad,0xd5,0xf9, - 0x1a,0x12,0x14,0x1d,0x07,0xfc,0x12,0x0b,0xe2,0xb8,0x8d,0x81,0x81,0x81,0x85,0xa9, - 0xc8,0xe1,0xfa,0x14,0x18,0xf9,0xdb,0xbd,0x9f,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x97,0xb6,0xd4,0xf1,0x10,0x1a,0xff,0xe7,0xce,0xb2,0x8e, - 0x81,0x81,0x81,0x81,0x81,0x84,0xa5,0xc3,0xe1,0xff,0x1d,0x0a,0x1f,0x07,0xe8,0xca, - 0xac,0x8d,0x81,0x81,0x81,0x81,0x81,0x84,0xad,0xd5,0xf9,0x1a,0x0f,0x12,0x20,0x0b, - 0xff,0x13,0x0b,0xe4,0xba,0x90,0x81,0x81,0x81,0x81,0x81,0x9d,0xc8,0xf2,0x1c,0x25, - 0xfc,0xd2,0xef,0x19,0x27,0xff,0xd5,0xab,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7, - 0xbd,0x93,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b,0xc5,0xef,0x1b, - 0x13,0xe7,0xbd,0x93,0x8e,0xb4,0xd9,0xfc,0x22,0x15,0xf0,0xcb,0xa6,0x93,0x97,0xbb, - 0xe1,0x07,0x2b,0x07,0xe2,0xbd,0x98,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc8,0xc8, - 0xc5,0xbf,0xb4,0xa4,0x8f,0x81,0x81,0x81,0x81,0x88,0xb1,0xd8,0xff,0x23,0x0a,0xed, - 0xe1,0xe2,0xf5,0x19,0x17,0xee,0xc5,0x9b,0x81,0x81,0x81,0x81,0x81,0x8d,0xa6,0xc0, - 0xd9,0xf3,0x0d,0x16,0xf7,0xd9,0xb4,0x8b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x83,0xac,0xd3,0xf1,0x10,0x12,0xf7,0xdf,0xc5,0xac,0x92,0x81,0x81,0x81,0x81, - 0x81,0x95,0xbd,0xe1,0xff,0x1b,0x04,0xe8,0xff,0x1b,0x05,0xe6,0xc5,0x9d,0x81,0x81, - 0x81,0x81,0x83,0xad,0xd4,0xf3,0x07,0xe8,0xec,0x04,0x14,0x18,0x0a,0xee,0xce,0xab, - 0x84,0x81,0x81,0x81,0x81,0x9d,0xc6,0xed,0x0f,0x10,0xf1,0xcb,0xeb,0x0d,0x12,0xf4, - 0xcd,0xa5,0x81,0x81,0x81,0x81,0x81,0x81,0x91,0xba,0xe3,0x0b,0x09,0xf2,0x04,0x12, - 0xeb,0xc2,0x99,0x81,0x81,0x81,0x81,0x81,0x81,0x83,0x90,0x98,0x9b,0x9a,0x92,0x85, - 0x94,0x9b,0x9b,0x94,0x86,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8c, - 0x95,0x98,0x98,0x95,0x8e,0x84,0x81,0x81,0x81,0x81,0x81,0x81,0x8d,0xa6,0xc0,0xd9, - 0xf3,0x0d,0x18,0xf9,0xdb,0xb6,0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x83,0xac,0xd3,0xf1,0x10,0x12,0xf9,0xdf,0xc6,0xac,0x93,0x81,0x81,0x81,0x81,0x81, - 0x98,0xc0,0xe3,0xff,0x1b,0x04,0xe8,0xff,0x1a,0x07,0xe8,0xc7,0x9f,0x81,0x81,0x81, - 0x81,0x81,0x9d,0xc6,0xed,0x0f,0x10,0xf1,0xcb,0xeb,0x0d,0x12,0xf4,0xcd,0xa5,0x81, - 0x81,0x81,0x81,0x81,0x8d,0xa6,0xc0,0xd9,0xf3,0x0d,0x18,0xf9,0xdb,0xb6,0x8d,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8b,0x93,0xa9,0xd0,0xf0,0x0f,0x14,0xfb,0xe1, - 0xc8,0xae,0x94,0x81,0x81,0x81,0x81,0x81,0x92,0xbb,0xdf,0xfc,0x1b,0x06,0xea,0xff, - 0x1a,0x07,0xe8,0xc7,0x9f,0x81,0x81,0x81,0x81,0x81,0x9b,0xc3,0xeb,0x0d,0x12,0xf4, - 0xcd,0xe8,0x0b,0x13,0xf6,0xd0,0xa8,0x81,0x81,0x81,0x81,0xa5,0xd0,0xfa,0x0b,0x14, - 0x27,0x2e,0x22,0x0f,0x06,0xfc,0xd5,0xaa,0x81,0x81,0x81,0x81,0x84,0xad,0xd5,0xf5, - 0x09,0xea,0xee,0x05,0x17,0x1a,0x0b,0xf0,0xcf,0xac,0x85,0x81,0x81,0x81,0x81,0x8c, - 0xa6,0xbf,0xd9,0xf1,0x0d,0x18,0xf9,0xdb,0xb6,0x8d,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x83,0xac,0xd3,0xf1,0x10,0x12,0xf9,0xdf,0xc6,0xac,0x93,0x81, - 0x81,0x81,0x81,0x81,0x81,0x95,0xbd,0xe1,0xff,0x1b,0x04,0xe8,0xff,0x1a,0x07,0xe8, - 0xc7,0x9f,0x81,0x81,0x81,0x81,0x81,0x83,0xad,0xd4,0xf1,0x07,0xe8,0xec,0x04,0x14, - 0x18,0x0b,0xf0,0xcf,0xac,0x87,0x81,0x81,0x81,0x81,0x81,0x9b,0xc3,0xeb,0x0d,0x12, - 0xf4,0xcd,0xe8,0x0b,0x13,0xf6,0xd0,0xa8,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7, - 0xbd,0x93,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b,0xc5,0xef,0x1b, - 0x13,0xe7,0xbd,0x93,0x81,0x9f,0xc4,0xe8,0x0d,0x2a,0x04,0xdf,0xba,0x94,0xab,0xcf, - 0xf5,0x1a,0x17,0xf1,0xcd,0xa8,0x84,0x81,0x95,0xc0,0xea,0x16,0x19,0xf2,0xf2,0xf2, - 0xef,0xe7,0xdb,0xc9,0xb2,0x96,0x81,0x81,0x81,0x92,0xbb,0xe5,0x0e,0x1e,0xf5,0xcf, - 0xb7,0xbb,0xe5,0x11,0x1e,0xf2,0xc8,0x9d,0x81,0x81,0x81,0x81,0x81,0x81,0x9a,0xa9, - 0xb7,0xd1,0xeb,0xef,0xef,0xde,0xb6,0xa2,0x8c,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x9a,0xa9,0xb5,0xd6,0xef,0xef,0xef,0xd6,0xbd,0xa3,0x8c,0x81,0x81,0x81,0x81,0x81, - 0x81,0x97,0xc0,0xe6,0xef,0xef,0xe3,0xc8,0xdf,0xef,0xef,0xec,0xc8,0x9e,0x81,0x81, - 0x81,0x81,0x81,0x99,0xb8,0xd4,0xe7,0xcc,0xc8,0xde,0xea,0xed,0xe3,0xce,0xb2,0x93, - 0x81,0x81,0x81,0x81,0x81,0x8e,0xb3,0xd2,0xe7,0xe9,0xd5,0xc5,0xd0,0xe7,0xea,0xd7, - 0xb9,0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x9a,0xac,0xd2,0xf3,0x0d,0x19,0x11,0xf7, - 0xd8,0xb3,0x8d,0x81,0x81,0x81,0x81,0x81,0x9a,0xab,0xb9,0xc2,0xc5,0xc3,0xba,0xab, - 0xbc,0xc5,0xc5,0xbd,0xac,0x94,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x93,0xa6,0xb4, - 0xbf,0xc2,0xc2,0xbf,0xb8,0xac,0x99,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0x9e,0xb7, - 0xd1,0xea,0xef,0xef,0xe0,0xb8,0x9f,0x89,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x92,0xae,0xd6,0xef,0xef,0xef,0xd7,0xbe,0xa4,0x8b,0x81,0x81,0x81,0x81,0x81,0x81, - 0x99,0xc3,0xe8,0xef,0xef,0xe3,0xc8,0xde,0xef,0xef,0xed,0xca,0xa1,0x81,0x81,0x81, - 0x81,0x81,0x8e,0xb3,0xd2,0xe7,0xe9,0xd5,0xc5,0xd0,0xe7,0xea,0xd7,0xb9,0x95,0x81, - 0x81,0x81,0x81,0x81,0x95,0xb2,0xbd,0xbd,0xd1,0xea,0xef,0xef,0xe0,0xb8,0x8f,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xb2,0xbd,0xbd,0xd4,0xef,0xef,0xef,0xd9,0xc0, - 0xa6,0x8c,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xbd,0xe4,0xef,0xef,0xe6,0xca,0xdf, - 0xef,0xef,0xed,0xca,0xa1,0x81,0x81,0x81,0x81,0x81,0x95,0xb2,0xd0,0xe7,0xea,0xd7, - 0xbd,0xce,0xe6,0xea,0xd9,0xbb,0x98,0x81,0x81,0x81,0x81,0xa5,0xd0,0xfa,0x13,0x0a, - 0xff,0x11,0x23,0xff,0xde,0xd5,0xc1,0x9f,0x81,0x81,0x81,0x81,0x85,0xa5,0xb9,0xd7, - 0xea,0xcd,0xcb,0xe0,0xed,0xef,0xe6,0xd0,0xb4,0x94,0x81,0x81,0x81,0x81,0x81,0x81, - 0x84,0x9e,0xb7,0xd0,0xea,0xef,0xef,0xe0,0xb8,0xa1,0x8b,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x97,0xae,0xd6,0xef,0xef,0xef,0xd7,0xbe,0xa4,0x8b,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x97,0xc0,0xe6,0xef,0xef,0xe4,0xc8,0xde,0xef,0xef,0xed, - 0xca,0xa1,0x81,0x81,0x81,0x81,0x81,0x81,0x99,0xb7,0xd4,0xe7,0xcc,0xc8,0xdc,0xea, - 0xed,0xe4,0xd0,0xb4,0x94,0x81,0x81,0x81,0x81,0x81,0x81,0x8c,0xb1,0xd0,0xe7,0xea, - 0xd7,0xc5,0xce,0xe6,0xea,0xd9,0xbb,0x98,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7, - 0xbd,0x93,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b,0xc5,0xef,0x1b, - 0x13,0xe7,0xbd,0x93,0x81,0x8b,0xaf,0xd4,0xf9,0x1e,0x18,0xf3,0xce,0xa9,0xbe,0xe3, - 0x09,0x27,0x04,0xde,0xb9,0x94,0x81,0x81,0x95,0xc0,0xea,0x16,0x27,0x1e,0x1e,0x1e, - 0x19,0x11,0x04,0xed,0xd2,0xb3,0x91,0x81,0x81,0x95,0xc0,0xea,0x15,0x19,0xed,0xc4, - 0xc0,0xd9,0xf5,0x19,0x14,0xed,0xc4,0x9a,0x81,0x81,0x81,0x81,0x81,0x9b,0xbd,0xd2, - 0xde,0xe7,0xed,0xef,0xef,0xe7,0xdb,0xc7,0xac,0x8e,0x81,0x81,0x81,0x81,0x81,0x9b, - 0xbd,0xd2,0xde,0xe7,0xed,0xef,0xef,0xe7,0xdb,0xc7,0xac,0x8e,0x81,0x81,0x81,0x81, - 0x81,0x9b,0xbd,0xd2,0xde,0xe7,0xed,0xef,0xef,0xe7,0xdb,0xc7,0xb0,0x8f,0x81,0x81, - 0x81,0x81,0x81,0x9b,0xbd,0xd2,0xde,0xe7,0xed,0xef,0xef,0xe7,0xdb,0xc7,0xac,0x8e, - 0x81,0x81,0x81,0x81,0x81,0x9e,0xbf,0xd2,0xde,0xe7,0xed,0xef,0xee,0xe7,0xdb,0xc7, - 0xac,0x8e,0x81,0x81,0x81,0x81,0x81,0x9b,0xbd,0xd2,0xde,0xe7,0xed,0xef,0xef,0xe7, - 0xdb,0xc7,0xac,0x8e,0x81,0x81,0x81,0x99,0xbb,0xd2,0xe1,0xec,0xef,0xed,0xe2,0xce, - 0xe3,0xef,0xef,0xe5,0xd0,0xb2,0x93,0x81,0x81,0x81,0x81,0x81,0x9d,0xb7,0xcc,0xdc, - 0xe7,0xed,0xed,0xe9,0xe1,0xd3,0xb9,0x94,0x81,0x81,0x81,0x81,0x81,0x9a,0xb5,0xcd, - 0xdf,0xeb,0xef,0xee,0xe7,0xd8,0xc3,0xaa,0x8c,0x81,0x81,0x81,0x81,0x81,0x81,0x9a, - 0xb5,0xcd,0xdf,0xeb,0xef,0xee,0xe7,0xd8,0xc3,0xaa,0x8c,0x81,0x81,0x81,0x81,0x81, - 0x8b,0xac,0xc3,0xcd,0xdf,0xeb,0xef,0xee,0xe7,0xd8,0xc4,0xb2,0x91,0x81,0x81,0x81, - 0x81,0x81,0x81,0x9a,0xb5,0xcd,0xdf,0xeb,0xef,0xee,0xe7,0xd8,0xc3,0xaa,0x8c,0x81, - 0x81,0x81,0x81,0x81,0xa9,0xd0,0xe7,0xe7,0xe7,0xe7,0xe7,0xe7,0xdf,0xbb,0x92,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0xa9,0xd0,0xe7,0xe7,0xe7,0xe7,0xe7,0xe7,0xdf,0xbb, - 0x92,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa9,0xd0,0xe7,0xe7,0xe7,0xe7,0xe7,0xe7, - 0xdf,0xc5,0xc4,0xb2,0x91,0x81,0x81,0x81,0x81,0x81,0xa9,0xd0,0xe7,0xe7,0xe7,0xe7, - 0xe7,0xe7,0xdf,0xc0,0xb4,0x9d,0x81,0x81,0x81,0x81,0x81,0xa4,0xcd,0xee,0xe9,0xe1, - 0xea,0xf9,0x1b,0x18,0xf4,0xd1,0xac,0x88,0x81,0x81,0x81,0x81,0x97,0xbf,0xe0,0xe5, - 0xe5,0xd5,0xde,0xeb,0xef,0xed,0xe2,0xce,0xb2,0x94,0x81,0x81,0x81,0x81,0x81,0x81, - 0x9f,0xba,0xd1,0xe1,0xec,0xef,0xef,0xe7,0xda,0xc6,0xae,0x90,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x9f,0xba,0xd1,0xe1,0xec,0xef,0xef,0xe7,0xda,0xc6,0xae,0x90,0x81, - 0x81,0x81,0x81,0x81,0x81,0x88,0xaa,0xc2,0xd1,0xe1,0xec,0xef,0xef,0xe7,0xda,0xc6, - 0xb2,0x91,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9f,0xba,0xd1,0xe1,0xec,0xef,0xef, - 0xe7,0xda,0xc6,0xae,0x90,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9f,0xba,0xd1,0xe1, - 0xec,0xef,0xef,0xe7,0xda,0xc6,0xae,0x90,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7, - 0xbd,0x93,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b,0xc5,0xef,0x1b, - 0x13,0xe7,0xbd,0x93,0x81,0x81,0x9a,0xbf,0xe3,0x09,0x2d,0x07,0xe2,0xbd,0xd2,0xf7, - 0x1d,0x12,0xee,0xc8,0xa4,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xff,0xff,0xff, - 0x06,0x15,0x27,0x0f,0xee,0xcb,0xa6,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2, - 0xdf,0xfb,0x14,0x1a,0xfc,0xdb,0xb5,0x8f,0x81,0x81,0x81,0x81,0x81,0xa8,0xd2,0xf9, - 0x07,0x11,0x18,0x1b,0x19,0x11,0xff,0xe8,0xca,0xa7,0x82,0x81,0x81,0x81,0x81,0xa8, - 0xd2,0xf9,0x07,0x11,0x18,0x1b,0x19,0x11,0xff,0xe8,0xca,0xa7,0x82,0x81,0x81,0x81, - 0x81,0xa8,0xd2,0xf9,0x07,0x11,0x18,0x1b,0x19,0x11,0xff,0xe8,0xca,0xa7,0x82,0x81, - 0x81,0x81,0x81,0xa8,0xd2,0xf9,0x07,0x11,0x18,0x1b,0x19,0x11,0xff,0xe8,0xca,0xa7, - 0x82,0x81,0x81,0x81,0x81,0xaa,0xd4,0xfa,0x07,0x11,0x19,0x1b,0x19,0x11,0xff,0xe8, - 0xca,0xa7,0x81,0x81,0x81,0x81,0x81,0xa8,0xd2,0xf9,0x07,0x11,0x18,0x1b,0x19,0x11, - 0xff,0xe8,0xca,0xa7,0x82,0x81,0x81,0xa5,0xcf,0xf7,0x09,0x15,0x1b,0x17,0x09,0xee, - 0x09,0x19,0x19,0x0b,0xee,0xcd,0xa8,0x82,0x81,0x81,0x81,0x9c,0xbb,0xd9,0xf1,0x05, - 0x11,0x19,0x19,0x13,0x0a,0xf2,0xc8,0x9d,0x81,0x81,0x81,0x81,0x95,0xb6,0xd5,0xf0, - 0x06,0x14,0x1b,0x19,0x0f,0xfc,0xe6,0xc8,0xa7,0x84,0x81,0x81,0x81,0x81,0x95,0xb6, - 0xd5,0xf0,0x06,0x14,0x1b,0x19,0x0f,0xfc,0xe6,0xc8,0xa7,0x84,0x81,0x81,0x81,0x81, - 0x95,0xb6,0xd5,0xf0,0x06,0x14,0x1b,0x19,0x0f,0xfc,0xe6,0xc8,0xa7,0x84,0x81,0x81, - 0x81,0x81,0x95,0xb6,0xd5,0xf0,0x06,0x14,0x1b,0x19,0x0f,0xfc,0xe6,0xc8,0xa7,0x84, - 0x81,0x81,0x81,0x83,0xad,0xd7,0x04,0x13,0x13,0x13,0x13,0x13,0xea,0xc0,0x95,0x81, - 0x81,0x81,0x81,0x81,0x81,0x83,0xad,0xd7,0x04,0x13,0x13,0x13,0x13,0x13,0xea,0xc0, - 0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x83,0xad,0xd7,0x04,0x13,0x13,0x13,0x13,0x13, - 0xea,0xc0,0x9a,0x8e,0x81,0x81,0x81,0x81,0x81,0x83,0xad,0xd7,0x04,0x13,0x13,0x13, - 0x13,0x13,0xea,0xc0,0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x9e,0xbd,0xdb,0xf4,0x09, - 0x14,0x19,0x1d,0x2f,0x0b,0xe6,0xc1,0x9b,0x81,0x81,0x81,0x81,0x9b,0xc5,0xef,0x11, - 0x0b,0xea,0x04,0x14,0x1b,0x17,0x09,0xee,0xcf,0xab,0x85,0x81,0x81,0x81,0x81,0x9d, - 0xbd,0xdb,0xf5,0x09,0x15,0x1b,0x19,0x11,0xff,0xe8,0xcc,0xac,0x8a,0x81,0x81,0x81, - 0x81,0x81,0x9d,0xbd,0xdb,0xf5,0x09,0x15,0x1b,0x19,0x11,0xff,0xe8,0xcc,0xac,0x8a, - 0x81,0x81,0x81,0x81,0x81,0x9d,0xbd,0xdb,0xf5,0x09,0x15,0x1b,0x19,0x11,0xff,0xe8, - 0xcc,0xac,0x8a,0x81,0x81,0x81,0x81,0x81,0x9d,0xbd,0xdb,0xf5,0x09,0x15,0x1b,0x19, - 0x11,0xff,0xe8,0xcc,0xac,0x8a,0x81,0x81,0x81,0x81,0x81,0x9d,0xbd,0xdb,0xf5,0x09, - 0x15,0x1b,0x19,0x11,0xff,0xe8,0xcc,0xac,0x8a,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7, - 0xbd,0x93,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b,0xc5,0xef,0x1b, - 0x13,0xe7,0xbd,0x93,0x81,0x81,0x86,0xab,0xcf,0xf4,0x19,0x1b,0xf6,0xd2,0xe6,0x0b, - 0x22,0xfc,0xd9,0xb4,0x8f,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xd5,0xd5, - 0xdd,0xf1,0x0f,0x29,0x05,0xde,0xb6,0x8e,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xd8, - 0xfc,0x1c,0x12,0xf7,0xdf,0xc1,0xa0,0x81,0x81,0x81,0x81,0x81,0x81,0xa8,0xd2,0xfc, - 0x19,0x0f,0x09,0x06,0x0a,0x19,0x25,0x05,0xe1,0xba,0x92,0x81,0x81,0x81,0x81,0xa8, - 0xd2,0xfc,0x19,0x0f,0x09,0x06,0x0a,0x19,0x25,0x05,0xe1,0xba,0x92,0x81,0x81,0x81, - 0x81,0xa8,0xd2,0xfc,0x19,0x0f,0x09,0x06,0x0a,0x19,0x25,0x05,0xe1,0xba,0x92,0x81, - 0x81,0x81,0x81,0xa8,0xd2,0xfc,0x19,0x0f,0x09,0x06,0x0a,0x19,0x25,0x05,0xe1,0xba, - 0x92,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0x19,0x0f,0x09,0x06,0x0a,0x19,0x24,0x05, - 0xe0,0xba,0x92,0x81,0x81,0x81,0x81,0xa8,0xd2,0xfc,0x19,0x0f,0x09,0x06,0x0a,0x19, - 0x25,0x05,0xe1,0xba,0x92,0x81,0x81,0xa5,0xd0,0xfa,0x12,0x06,0xff,0x0a,0x25,0x0b, - 0x1c,0x04,0x06,0x21,0x07,0xe1,0xba,0x92,0x81,0x81,0x91,0xb5,0xd7,0xf7,0x14,0x26, - 0x13,0x09,0x09,0x0e,0x19,0xf2,0xc8,0x9d,0x81,0x81,0x81,0x86,0xac,0xd0,0xf1,0x10, - 0x1d,0x09,0xff,0x04,0x14,0x21,0x04,0xe2,0xbe,0x98,0x81,0x81,0x81,0x86,0xac,0xd0, - 0xf1,0x10,0x1d,0x09,0xff,0x04,0x14,0x21,0x04,0xe2,0xbe,0x98,0x81,0x81,0x81,0x86, - 0xac,0xd0,0xf1,0x10,0x1d,0x09,0xff,0x04,0x14,0x21,0x04,0xe2,0xbe,0x98,0x81,0x81, - 0x81,0x86,0xac,0xd0,0xf1,0x10,0x1d,0x09,0xff,0x04,0x14,0x21,0x04,0xe2,0xbe,0x98, - 0x81,0x81,0x81,0x83,0xad,0xd7,0x04,0x0b,0x0b,0x0b,0x1b,0x16,0xea,0xc0,0x95,0x81, - 0x81,0x81,0x81,0x81,0x81,0x83,0xad,0xd7,0x04,0x0b,0x0b,0x0b,0x1b,0x16,0xea,0xc0, - 0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x83,0xad,0xd7,0x04,0x0b,0x0b,0x0b,0x1b,0x16, - 0xea,0xc0,0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x83,0xad,0xd7,0x04,0x0b,0x0b,0x0b, - 0x1b,0x16,0xea,0xc0,0x95,0x81,0x81,0x81,0x81,0x81,0x91,0xb5,0xd9,0xf9,0x17,0x1c, - 0x0b,0x06,0x09,0x12,0x20,0xfa,0xd4,0xae,0x87,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b, - 0x0b,0x0b,0x1c,0x0a,0x06,0x13,0x2b,0x0a,0xe3,0xbd,0x94,0x81,0x81,0x81,0x8f,0xb5, - 0xd9,0xf9,0x18,0x1e,0x0c,0x06,0x09,0x18,0x24,0x09,0xe8,0xc4,0x9f,0x81,0x81,0x81, - 0x81,0x8f,0xb5,0xd9,0xf9,0x18,0x1e,0x0c,0x06,0x09,0x18,0x24,0x09,0xe8,0xc4,0x9f, - 0x81,0x81,0x81,0x81,0x8f,0xb5,0xd9,0xf9,0x18,0x1e,0x0c,0x06,0x09,0x18,0x24,0x09, - 0xe8,0xc4,0x9f,0x81,0x81,0x81,0x81,0x8f,0xb5,0xd9,0xf9,0x18,0x1e,0x0c,0x06,0x09, - 0x18,0x24,0x09,0xe8,0xc4,0x9f,0x81,0x81,0x81,0x81,0x8f,0xb5,0xd9,0xf9,0x18,0x1e, - 0x0c,0x06,0x09,0x18,0x24,0x09,0xe8,0xc4,0x9f,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7, - 0xbd,0x93,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b,0xc5,0xef,0x1b, - 0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x95,0xba,0xdf,0x04,0x29,0x0b,0xe5,0xf9,0x1f, - 0x0f,0xe9,0xc4,0x9f,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0xac, - 0xb6,0xd3,0xf9,0x21,0x13,0xea,0xc0,0x96,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xe6, - 0x0f,0x1e,0xf6,0xd7,0xbd,0xa3,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0xa8,0xd2,0xfb, - 0xf1,0xe6,0xdd,0xda,0xe1,0xf7,0x1b,0x18,0xef,0xc6,0x9d,0x81,0x81,0x81,0x81,0xa8, - 0xd2,0xfb,0xf1,0xe6,0xdd,0xda,0xe1,0xf7,0x1b,0x18,0xef,0xc6,0x9d,0x81,0x81,0x81, - 0x81,0xa8,0xd2,0xfb,0xf1,0xe6,0xdd,0xda,0xe1,0xf7,0x1b,0x18,0xef,0xc6,0x9d,0x81, - 0x81,0x81,0x81,0xa8,0xd2,0xfb,0xf1,0xe6,0xdd,0xda,0xe1,0xf7,0x1b,0x18,0xef,0xc6, - 0x9d,0x81,0x81,0x81,0x81,0xab,0xd5,0xff,0xf1,0xe5,0xdd,0xda,0xe1,0xf7,0x1b,0x18, - 0xef,0xc6,0x9d,0x81,0x81,0x81,0x81,0xa8,0xd2,0xfb,0xf1,0xe6,0xdd,0xda,0xe1,0xf7, - 0x1a,0x18,0xef,0xc6,0x9d,0x81,0x81,0xa5,0xcf,0xf7,0xeb,0xdc,0xd5,0xe9,0x11,0x2a, - 0x04,0xdf,0xe7,0x0e,0x18,0xef,0xc6,0x9c,0x81,0x81,0xa3,0xc9,0xef,0x12,0x22,0x04, - 0xec,0xdf,0xdf,0xe5,0xf2,0xf1,0xc7,0x9d,0x81,0x81,0x81,0x97,0xbe,0xe5,0x0b,0x20, - 0xff,0xe3,0xd5,0xdc,0xf1,0x12,0x1d,0xf6,0xcf,0xa7,0x81,0x81,0x81,0x97,0xbe,0xe5, - 0x0b,0x20,0xff,0xe3,0xd5,0xdc,0xf1,0x12,0x1d,0xf6,0xcf,0xa7,0x81,0x81,0x81,0x97, - 0xbe,0xe5,0x0b,0x20,0xff,0xe3,0xd5,0xdc,0xf1,0x12,0x1d,0xf6,0xcf,0xa7,0x81,0x81, - 0x81,0x97,0xbe,0xe5,0x0b,0x20,0xff,0xe3,0xd5,0xdc,0xf1,0x12,0x1d,0xf6,0xcf,0xa7, - 0x81,0x81,0x81,0x81,0xa7,0xcc,0xdf,0xdf,0xdf,0xed,0x19,0x16,0xea,0xc0,0x95,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0xa7,0xcc,0xdf,0xdf,0xdf,0xed,0x19,0x16,0xea,0xc0, - 0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa7,0xcc,0xdf,0xdf,0xdf,0xed,0x19,0x16, - 0xea,0xc0,0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa7,0xcc,0xdf,0xdf,0xdf,0xed, - 0x19,0x16,0xea,0xc0,0x95,0x81,0x81,0x81,0x81,0x81,0xa3,0xc9,0xef,0x14,0x18,0xf9, - 0xe3,0xda,0xdd,0xfb,0x21,0x0c,0xe6,0xbe,0x96,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b, - 0x1b,0x18,0xfb,0xe2,0xdc,0xf3,0x18,0x19,0xf1,0xc7,0x9e,0x81,0x81,0x81,0xa1,0xc8, - 0xee,0x13,0x1c,0xfb,0xe4,0xda,0xe0,0xf3,0x12,0x22,0xfc,0xd6,0xaf,0x87,0x81,0x81, - 0x81,0xa1,0xc8,0xee,0x13,0x1c,0xfb,0xe4,0xda,0xe0,0xf3,0x12,0x22,0xfc,0xd6,0xaf, - 0x87,0x81,0x81,0x81,0xa1,0xc8,0xee,0x13,0x1c,0xfb,0xe4,0xda,0xe0,0xf3,0x12,0x22, - 0xfc,0xd6,0xaf,0x87,0x81,0x81,0x81,0xa1,0xc8,0xee,0x13,0x1c,0xfb,0xe4,0xda,0xe0, - 0xf3,0x12,0x22,0xfc,0xd6,0xaf,0x87,0x81,0x81,0x81,0xa1,0xc8,0xee,0x13,0x1c,0xfb, - 0xe4,0xda,0xe0,0xf3,0x12,0x22,0xfc,0xd6,0xaf,0x87,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7, - 0xbd,0x93,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b,0xc5,0xef,0x1b, - 0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0xa6,0xcb,0xef,0x14,0x1e,0xf7,0x0c,0x1e, - 0xf9,0xd4,0xaf,0x8b,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98, - 0x9c,0xc6,0xef,0x1b,0x19,0xed,0xc2,0x98,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xe7, - 0x12,0x1c,0xf4,0xd4,0xb9,0xa0,0x86,0x81,0x81,0x81,0x81,0x81,0x81,0x9c,0xbf,0xd2, - 0xc9,0xbd,0xc0,0xc2,0xc2,0xe5,0x0f,0x21,0xf5,0xca,0xa0,0x81,0x81,0x81,0x81,0x9c, - 0xbf,0xd2,0xc9,0xbd,0xc0,0xc2,0xc2,0xe5,0x0f,0x21,0xf5,0xca,0xa0,0x81,0x81,0x81, - 0x81,0x9c,0xbf,0xd2,0xc9,0xbd,0xc0,0xc2,0xc2,0xe5,0x0f,0x21,0xf5,0xca,0xa0,0x81, - 0x81,0x81,0x81,0x9c,0xbf,0xd2,0xc9,0xbd,0xc0,0xc2,0xc2,0xe5,0x0f,0x21,0xf5,0xca, - 0xa0,0x81,0x81,0x81,0x81,0xa0,0xc3,0xd5,0xc9,0xbd,0xc0,0xc2,0xc2,0xe5,0x0f,0x21, - 0xf5,0xca,0xa0,0x81,0x81,0x81,0x81,0x9c,0xbf,0xd2,0xc9,0xbd,0xc0,0xc2,0xc2,0xe4, - 0x0e,0x21,0xf5,0xca,0xa0,0x81,0x81,0x99,0xbb,0xcf,0xc5,0xbc,0xc0,0xdf,0x09,0x20, - 0xf5,0xcd,0xda,0x04,0x21,0xf7,0xcd,0xa3,0x81,0x89,0xb2,0xda,0xff,0x28,0x0b,0xe6, - 0xc8,0xb6,0xb5,0xbc,0xcc,0xd0,0xb7,0x93,0x81,0x81,0x81,0xa4,0xcd,0xf5,0x1d,0x0e, - 0xe7,0xc3,0xbd,0xbd,0xd8,0xff,0x28,0x04,0xdb,0xb2,0x88,0x81,0x81,0xa4,0xcd,0xf5, - 0x1d,0x0e,0xe7,0xc3,0xbd,0xbd,0xd8,0xff,0x28,0x04,0xdb,0xb2,0x88,0x81,0x81,0xa4, - 0xcd,0xf5,0x1d,0x0e,0xe7,0xc3,0xbd,0xbd,0xd8,0xff,0x28,0x04,0xdb,0xb2,0x88,0x81, - 0x81,0xa4,0xcd,0xf5,0x1d,0x0e,0xe7,0xc3,0xbd,0xbd,0xd8,0xff,0x28,0x04,0xdb,0xb2, - 0x88,0x81,0x81,0x81,0x90,0xab,0xb5,0xb5,0xc2,0xed,0x19,0x16,0xea,0xc0,0x95,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x90,0xab,0xb5,0xb5,0xc2,0xed,0x19,0x16,0xea,0xc0, - 0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x90,0xab,0xb5,0xb5,0xc2,0xed,0x19,0x16, - 0xea,0xc0,0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x90,0xab,0xb5,0xb5,0xc2,0xed, - 0x19,0x16,0xea,0xc0,0x95,0x81,0x81,0x81,0x81,0x88,0xb1,0xd9,0xff,0x28,0x04,0xde, - 0xbe,0xb1,0xc3,0xea,0x11,0x1c,0xf4,0xcc,0xa2,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b, - 0x1d,0xfc,0xdd,0xbf,0xba,0xe3,0x0e,0x21,0xf7,0xcd,0xa3,0x81,0x81,0x85,0xae,0xd6, - 0xff,0x27,0x06,0xe1,0xc1,0xb1,0xb9,0xd7,0xfc,0x23,0x0d,0xe4,0xbb,0x92,0x81,0x81, - 0x85,0xae,0xd6,0xff,0x27,0x06,0xe1,0xc1,0xb1,0xb9,0xd7,0xfc,0x23,0x0d,0xe4,0xbb, - 0x92,0x81,0x81,0x85,0xae,0xd6,0xff,0x27,0x06,0xe1,0xc1,0xb1,0xb9,0xd7,0xfc,0x23, - 0x0d,0xe4,0xbb,0x92,0x81,0x81,0x85,0xae,0xd6,0xff,0x27,0x06,0xe1,0xc1,0xb1,0xb9, - 0xd7,0xfc,0x23,0x0d,0xe4,0xbb,0x92,0x81,0x81,0x85,0xae,0xd6,0xff,0x27,0x06,0xe1, - 0xc1,0xb1,0xb9,0xd7,0xfc,0x23,0x0d,0xe4,0xbb,0x92,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7, - 0xbd,0x93,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b,0xc5,0xef,0x1b, - 0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x91,0xb5,0xda,0xff,0x24,0x0b,0x20,0x0a, - 0xe5,0xc0,0x9b,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98, - 0xa3,0xca,0xf3,0x1e,0x14,0xea,0xc1,0x97,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xdf, - 0x05,0x27,0x10,0xf3,0xdb,0xc2,0xa5,0x87,0x81,0x81,0x81,0x81,0x81,0x8e,0xac,0xc5, - 0xd7,0xe4,0xea,0xed,0xed,0xed,0x0e,0x21,0xf5,0xca,0xa0,0x81,0x81,0x81,0x81,0x8e, - 0xac,0xc5,0xd7,0xe4,0xea,0xed,0xed,0xed,0x0e,0x21,0xf5,0xca,0xa0,0x81,0x81,0x81, - 0x81,0x8e,0xac,0xc5,0xd7,0xe4,0xea,0xed,0xed,0xed,0x0e,0x21,0xf5,0xca,0xa0,0x81, - 0x81,0x81,0x81,0x8e,0xac,0xc5,0xd7,0xe4,0xea,0xed,0xed,0xed,0x0e,0x21,0xf5,0xca, - 0xa0,0x81,0x81,0x81,0x81,0x8e,0xac,0xc5,0xd7,0xe4,0xea,0xed,0xed,0xed,0x0e,0x21, - 0xf5,0xca,0xa0,0x81,0x81,0x81,0x81,0x8e,0xac,0xc5,0xd7,0xe4,0xea,0xed,0xed,0xed, - 0x0e,0x21,0xf5,0xca,0xa0,0x81,0x81,0x8a,0xa9,0xc4,0xd9,0xe5,0xea,0xea,0x09,0x1b, - 0xef,0xea,0xea,0xff,0x26,0xfa,0xd0,0xa5,0x81,0x91,0xbb,0xe5,0x0e,0x22,0xfa,0xd2, - 0xac,0x8e,0x8b,0x94,0xa4,0xa7,0x97,0x81,0x81,0x81,0x82,0xac,0xd6,0xff,0x29,0x04, - 0xe7,0xe7,0xe7,0xe7,0xe7,0xf7,0x21,0x0b,0xe1,0xb7,0x8d,0x81,0x82,0xac,0xd6,0xff, - 0x29,0x04,0xe7,0xe7,0xe7,0xe7,0xe7,0xf7,0x21,0x0b,0xe1,0xb7,0x8d,0x81,0x82,0xac, - 0xd6,0xff,0x29,0x04,0xe7,0xe7,0xe7,0xe7,0xe7,0xf7,0x21,0x0b,0xe1,0xb7,0x8d,0x81, - 0x82,0xac,0xd6,0xff,0x29,0x04,0xe7,0xe7,0xe7,0xe7,0xe7,0xf7,0x21,0x0b,0xe1,0xb7, - 0x8d,0x81,0x81,0x81,0x81,0x84,0x8b,0x98,0xc2,0xed,0x19,0x16,0xea,0xc0,0x95,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x84,0x8b,0x98,0xc2,0xed,0x19,0x16,0xea,0xc0, - 0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x84,0x8b,0x98,0xc2,0xed,0x19,0x16, - 0xea,0xc0,0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x84,0x8b,0x98,0xc2,0xed, - 0x19,0x16,0xea,0xc0,0x95,0x81,0x81,0x81,0x81,0x90,0xba,0xe4,0x0e,0x1e,0xf5,0xcc, - 0xa4,0x8c,0xb4,0xdc,0x06,0x28,0xff,0xd5,0xac,0x82,0x81,0x81,0x9b,0xc5,0xef,0x1b, - 0x13,0xe7,0xc1,0xa1,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x8d,0xb7,0xe0, - 0x0b,0x23,0xfa,0xd1,0xa8,0x87,0x9e,0xc6,0xef,0x19,0x16,0xed,0xc2,0x98,0x81,0x81, - 0x8d,0xb7,0xe0,0x0b,0x23,0xfa,0xd1,0xa8,0x87,0x9e,0xc6,0xef,0x19,0x16,0xed,0xc2, - 0x98,0x81,0x81,0x8d,0xb7,0xe0,0x0b,0x23,0xfa,0xd1,0xa8,0x87,0x9e,0xc6,0xef,0x19, - 0x16,0xed,0xc2,0x98,0x81,0x81,0x8d,0xb7,0xe0,0x0b,0x23,0xfa,0xd1,0xa8,0x87,0x9e, - 0xc6,0xef,0x19,0x16,0xed,0xc2,0x98,0x81,0x81,0x8d,0xb7,0xe0,0x0b,0x23,0xfa,0xd1, - 0xa8,0x87,0x9e,0xc6,0xef,0x19,0x16,0xed,0xc2,0x98,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7, - 0xbd,0x93,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b,0xc5,0xef,0x1b, - 0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x81,0xa1,0xc6,0xeb,0x0f,0x31,0x1a,0xf4, - 0xd0,0xab,0x86,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0xbc, - 0xc6,0xdf,0xff,0x28,0x09,0xe1,0xb8,0x8f,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xcb, - 0xec,0x0b,0x25,0x16,0xfc,0xe1,0xc3,0xa1,0x81,0x81,0x81,0x81,0x86,0xaa,0xca,0xe8, - 0xfc,0x0d,0x15,0x19,0x19,0x19,0x1d,0x21,0xf5,0xca,0xa0,0x81,0x81,0x81,0x86,0xaa, - 0xca,0xe8,0xfc,0x0d,0x15,0x19,0x19,0x19,0x1d,0x21,0xf5,0xca,0xa0,0x81,0x81,0x81, - 0x86,0xaa,0xca,0xe8,0xfc,0x0d,0x15,0x19,0x19,0x19,0x1d,0x21,0xf5,0xca,0xa0,0x81, - 0x81,0x81,0x86,0xaa,0xca,0xe8,0xfc,0x0d,0x15,0x19,0x19,0x19,0x1d,0x21,0xf5,0xca, - 0xa0,0x81,0x81,0x81,0x86,0xaa,0xca,0xe8,0xfc,0x0d,0x15,0x19,0x19,0x19,0x1d,0x21, - 0xf5,0xca,0xa0,0x81,0x81,0x81,0x86,0xaa,0xca,0xe8,0xfc,0x0d,0x15,0x19,0x19,0x19, - 0x1d,0x21,0xf5,0xca,0xa0,0x81,0x81,0xa1,0xc5,0xe4,0xff,0x0e,0x16,0x16,0x18,0x23, - 0x16,0x16,0x16,0x16,0x26,0xfa,0xd0,0xa5,0x81,0x95,0xc0,0xea,0x14,0x1b,0xf1,0xc7, - 0x9d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x2f,0x13, - 0x13,0x13,0x13,0x13,0x13,0x13,0x26,0x0e,0xe2,0xb8,0x8d,0x81,0x85,0xb0,0xda,0x06, - 0x2f,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x26,0x0e,0xe2,0xb8,0x8d,0x81,0x85,0xb0, - 0xda,0x06,0x2f,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x26,0x0e,0xe2,0xb8,0x8d,0x81, - 0x85,0xb0,0xda,0x06,0x2f,0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x26,0x0e,0xe2,0xb8, - 0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x98,0xc2,0xed,0x19,0x16,0xea,0xc0,0x95,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x98,0xc2,0xed,0x19,0x16,0xea,0xc0, - 0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x98,0xc2,0xed,0x19,0x16, - 0xea,0xc0,0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x98,0xc2,0xed, - 0x19,0x16,0xea,0xc0,0x95,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x13,0x19,0xef,0xc5, - 0x9b,0x81,0xaa,0xd5,0xfc,0x29,0x06,0xda,0xb0,0x85,0x81,0x81,0x9b,0xc5,0xef,0x1b, - 0x13,0xe7,0xbd,0x93,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x90,0xba,0xe5, - 0x11,0x1e,0xf2,0xc9,0x9f,0x81,0x95,0xbf,0xe7,0x13,0x1b,0xef,0xc5,0x9b,0x81,0x81, - 0x90,0xba,0xe5,0x11,0x1e,0xf2,0xc9,0x9f,0x81,0x95,0xbf,0xe7,0x13,0x1b,0xef,0xc5, - 0x9b,0x81,0x81,0x90,0xba,0xe5,0x11,0x1e,0xf2,0xc9,0x9f,0x81,0x95,0xbf,0xe7,0x13, - 0x1b,0xef,0xc5,0x9b,0x81,0x81,0x90,0xba,0xe5,0x11,0x1e,0xf2,0xc9,0x9f,0x81,0x95, - 0xbf,0xe7,0x13,0x1b,0xef,0xc5,0x9b,0x81,0x81,0x90,0xba,0xe5,0x11,0x1e,0xf2,0xc9, - 0x9f,0x81,0x95,0xbf,0xe7,0x13,0x1b,0xef,0xc5,0x9b,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7, - 0xbd,0x93,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfa,0xd0,0xa5,0x81,0x9b,0xc5,0xef,0x1b, - 0x13,0xe7,0xbd,0x93,0x81,0x81,0x81,0x81,0x81,0x8c,0xb1,0xd5,0xfc,0x29,0x09,0xe0, - 0xbb,0x96,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xe5,0xe6, - 0xee,0xff,0x1a,0x18,0xf5,0xd1,0xaa,0x83,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2, - 0xce,0xea,0x04,0x1d,0x1d,0xff,0xdc,0xb6,0x90,0x81,0x81,0x81,0x99,0xbf,0xe5,0x07, - 0x22,0x13,0x05,0xff,0xff,0xff,0x0e,0x21,0xf5,0xca,0xa0,0x81,0x81,0x81,0x99,0xbf, - 0xe5,0x07,0x22,0x13,0x05,0xff,0xff,0xff,0x0e,0x21,0xf5,0xca,0xa0,0x81,0x81,0x81, - 0x99,0xbf,0xe5,0x07,0x22,0x13,0x05,0xff,0xff,0xff,0x0e,0x21,0xf5,0xca,0xa0,0x81, - 0x81,0x81,0x99,0xbf,0xe5,0x07,0x22,0x13,0x05,0xff,0xff,0xff,0x0e,0x21,0xf5,0xca, - 0xa0,0x81,0x81,0x81,0x99,0xbf,0xe5,0x07,0x22,0x13,0x05,0xff,0xff,0xff,0x0e,0x21, - 0xf5,0xca,0xa0,0x81,0x81,0x81,0x99,0xbf,0xe5,0x07,0x22,0x13,0x05,0xff,0xff,0xff, - 0x0e,0x21,0xf5,0xca,0xa0,0x81,0x8a,0xb2,0xda,0xff,0x21,0x0f,0xff,0xff,0x09,0x1b, - 0xff,0xff,0xff,0xff,0xff,0xfa,0xd0,0xa5,0x81,0x95,0xc0,0xea,0x16,0x1b,0xef,0xc6, - 0x9c,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0xb0,0xda,0x06,0x2c,0x06, - 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0xe2,0xb8,0x8d,0x81,0x85,0xb0,0xda,0x06, - 0x2c,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0xe2,0xb8,0x8d,0x81,0x85,0xb0, - 0xda,0x06,0x2c,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0xe2,0xb8,0x8d,0x81, - 0x85,0xb0,0xda,0x06,0x2c,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0xe2,0xb8, - 0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x98,0xc2,0xed,0x19,0x16,0xea,0xc0,0x95,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x98,0xc2,0xed,0x19,0x16,0xea,0xc0, - 0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x98,0xc2,0xed,0x19,0x16, - 0xea,0xc0,0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x98,0xc2,0xed, - 0x19,0x16,0xea,0xc0,0x95,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc3, - 0x99,0x81,0xaa,0xd3,0xfc,0x29,0x06,0xda,0xb0,0x85,0x81,0x81,0x9b,0xc5,0xef,0x1b, - 0x13,0xe7,0xbd,0x93,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x90,0xba,0xe5, - 0x11,0x1e,0xf2,0xc9,0x9f,0x81,0x95,0xbf,0xe8,0x13,0x19,0xef,0xc5,0x9b,0x81,0x81, - 0x90,0xba,0xe5,0x11,0x1e,0xf2,0xc9,0x9f,0x81,0x95,0xbf,0xe8,0x13,0x19,0xef,0xc5, - 0x9b,0x81,0x81,0x90,0xba,0xe5,0x11,0x1e,0xf2,0xc9,0x9f,0x81,0x95,0xbf,0xe8,0x13, - 0x19,0xef,0xc5,0x9b,0x81,0x81,0x90,0xba,0xe5,0x11,0x1e,0xf2,0xc9,0x9f,0x81,0x95, - 0xbf,0xe8,0x13,0x19,0xef,0xc5,0x9b,0x81,0x81,0x90,0xba,0xe5,0x11,0x1e,0xf2,0xc9, - 0x9f,0x81,0x95,0xbf,0xe8,0x13,0x19,0xef,0xc5,0x9b,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x88,0xb2,0xdd,0x09,0x26,0xfc,0xd2,0xa9,0x89,0xa0,0xc9,0xf2,0x1e,0x11,0xe5, - 0xbc,0x92,0x81,0x88,0xb2,0xdd,0x09,0x26,0xfc,0xd2,0xa9,0x89,0xa0,0xc9,0xf2,0x1e, - 0x11,0xe5,0xbc,0x92,0x81,0x81,0x81,0x81,0x81,0x81,0xa8,0xd2,0xfc,0x29,0x09,0xdd, - 0xb2,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x1e,0x11,0x11,0x11, - 0x16,0x25,0x13,0xf9,0xdb,0xba,0x97,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2, - 0xae,0xc8,0xe1,0xfc,0x1e,0x15,0xee,0xc6,0x9c,0x81,0x81,0x81,0xa4,0xcd,0xf6,0x1e, - 0x14,0xf1,0xdc,0xd5,0xd5,0xe2,0x0e,0x21,0xf5,0xca,0xa0,0x81,0x81,0x81,0xa4,0xcd, - 0xf6,0x1e,0x14,0xf1,0xdc,0xd5,0xd5,0xe2,0x0e,0x21,0xf5,0xca,0xa0,0x81,0x81,0x81, - 0xa4,0xcd,0xf6,0x1e,0x14,0xf1,0xdc,0xd5,0xd5,0xe2,0x0e,0x21,0xf5,0xca,0xa0,0x81, - 0x81,0x81,0xa4,0xcd,0xf6,0x1e,0x14,0xf1,0xdc,0xd5,0xd5,0xe2,0x0e,0x21,0xf5,0xca, - 0xa0,0x81,0x81,0x81,0xa4,0xcd,0xf6,0x1e,0x14,0xf1,0xdc,0xd5,0xd5,0xe2,0x0e,0x21, - 0xf5,0xca,0xa0,0x81,0x81,0x81,0xa4,0xcd,0xf6,0x1e,0x14,0xf1,0xdc,0xd5,0xd5,0xe2, - 0x0e,0x21,0xf5,0xca,0xa0,0x81,0x92,0xbc,0xe6,0x0f,0x19,0xf3,0xd7,0xdd,0x09,0x1c, - 0xf2,0xd5,0xd5,0xd5,0xd5,0xd4,0xbf,0x9b,0x81,0x93,0xbd,0xe7,0x11,0x20,0xf6,0xcd, - 0xa6,0x8b,0x8a,0x94,0xa4,0xa6,0x96,0x81,0x81,0x81,0x83,0xad,0xd7,0xff,0x2b,0x04, - 0xda,0xda,0xda,0xda,0xda,0xda,0xda,0xda,0xd0,0xae,0x87,0x81,0x83,0xad,0xd7,0xff, - 0x2b,0x04,0xda,0xda,0xda,0xda,0xda,0xda,0xda,0xda,0xd0,0xae,0x87,0x81,0x83,0xad, - 0xd7,0xff,0x2b,0x04,0xda,0xda,0xda,0xda,0xda,0xda,0xda,0xda,0xd0,0xae,0x87,0x81, - 0x83,0xad,0xd7,0xff,0x2b,0x04,0xda,0xda,0xda,0xda,0xda,0xda,0xda,0xda,0xd0,0xae, - 0x87,0x81,0x81,0x81,0x81,0x8b,0x8d,0x98,0xc2,0xed,0x19,0x16,0xea,0xc0,0x95,0x8d, - 0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x8b,0x8d,0x98,0xc2,0xed,0x19,0x16,0xea,0xc0, - 0x95,0x8d,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x8b,0x8d,0x98,0xc2,0xed,0x19,0x16, - 0xea,0xc0,0x95,0x8d,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x8b,0x8d,0x98,0xc2,0xed, - 0x19,0x16,0xea,0xc0,0x95,0x8d,0x85,0x81,0x81,0x93,0xbd,0xe7,0x11,0x1d,0xf3,0xca, - 0xa2,0x89,0xb1,0xda,0x04,0x29,0xff,0xd6,0xac,0x82,0x81,0x81,0x9b,0xc5,0xef,0x1b, - 0x13,0xe7,0xbd,0x93,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x8d,0xb8,0xe2, - 0x0b,0x23,0xf9,0xd0,0xa7,0x87,0x9f,0xc6,0xef,0x19,0x13,0xea,0xc1,0x97,0x81,0x81, - 0x8d,0xb8,0xe2,0x0b,0x23,0xf9,0xd0,0xa7,0x87,0x9f,0xc6,0xef,0x19,0x13,0xea,0xc1, - 0x97,0x81,0x81,0x8d,0xb8,0xe2,0x0b,0x23,0xf9,0xd0,0xa7,0x87,0x9f,0xc6,0xef,0x19, - 0x13,0xea,0xc1,0x97,0x81,0x81,0x8d,0xb8,0xe2,0x0b,0x23,0xf9,0xd0,0xa7,0x87,0x9f, - 0xc6,0xef,0x19,0x13,0xea,0xc1,0x97,0x81,0x81,0x8d,0xb8,0xe2,0x0b,0x23,0xf9,0xd0, - 0xa7,0x87,0x9f,0xc6,0xef,0x19,0x13,0xea,0xc1,0x97,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x84,0xae,0xd7,0xff,0x2a,0x05,0xde,0xbd,0xb2,0xb9,0xd7,0xfc,0x25,0x07,0xdf, - 0xb5,0x8c,0x81,0x84,0xae,0xd7,0xff,0x2a,0x05,0xde,0xbd,0xb2,0xb9,0xd7,0xfc,0x25, - 0x07,0xdf,0xb5,0x8c,0x81,0x81,0x81,0x81,0x81,0x81,0xa8,0xd2,0xfc,0x29,0x09,0xdd, - 0xb2,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x1e,0x11,0x11,0x11, - 0x0b,0xff,0xee,0xd9,0xbd,0x9f,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2, - 0xba,0xb2,0xc1,0xe5,0x0e,0x21,0xf5,0xca,0xa0,0x81,0x81,0x81,0xa8,0xd2,0xfc,0x29, - 0x0b,0xe0,0xb7,0xba,0xd0,0xea,0x0e,0x21,0xf5,0xca,0xa0,0x81,0x81,0x81,0xa8,0xd2, - 0xfc,0x29,0x0b,0xe0,0xb7,0xba,0xd0,0xea,0x0e,0x21,0xf5,0xca,0xa0,0x81,0x81,0x81, - 0xa8,0xd2,0xfc,0x29,0x0b,0xe0,0xb7,0xba,0xd0,0xea,0x0e,0x21,0xf5,0xca,0xa0,0x81, - 0x81,0x81,0xa8,0xd2,0xfc,0x29,0x0b,0xe0,0xb7,0xba,0xd0,0xea,0x0e,0x21,0xf5,0xca, - 0xa0,0x81,0x81,0x81,0xa8,0xd2,0xfc,0x29,0x0b,0xe0,0xb7,0xba,0xd0,0xea,0x0e,0x21, - 0xf5,0xca,0xa0,0x81,0x81,0x81,0xa8,0xd2,0xfc,0x29,0x0b,0xe0,0xb7,0xba,0xd0,0xe9, - 0x0e,0x21,0xf5,0xca,0xa0,0x81,0x95,0xc0,0xea,0x16,0x13,0xe7,0xc0,0xe2,0x09,0x23, - 0xf9,0xd1,0xb0,0xb6,0xc2,0xc1,0xa8,0x86,0x81,0x8d,0xb6,0xdf,0x07,0x2b,0x05,0xe0, - 0xc3,0xb5,0xb5,0xbc,0xcc,0xcf,0xb5,0x92,0x81,0x81,0x81,0xa6,0xcf,0xf7,0x21,0x0f, - 0xe8,0xc8,0xb5,0xb0,0xb2,0xb8,0xc1,0xc3,0xae,0x94,0x81,0x81,0x81,0xa6,0xcf,0xf7, - 0x21,0x0f,0xe8,0xc8,0xb5,0xb0,0xb2,0xb8,0xc1,0xc3,0xae,0x94,0x81,0x81,0x81,0xa6, - 0xcf,0xf7,0x21,0x0f,0xe8,0xc8,0xb5,0xb0,0xb2,0xb8,0xc1,0xc3,0xae,0x94,0x81,0x81, - 0x81,0xa6,0xcf,0xf7,0x21,0x0f,0xe8,0xc8,0xb5,0xb0,0xb2,0xb8,0xc1,0xc3,0xae,0x94, - 0x81,0x81,0x81,0x81,0x9d,0xb4,0xb8,0xb8,0xc2,0xed,0x19,0x16,0xea,0xc0,0xb8,0xb8, - 0xac,0x90,0x81,0x81,0x81,0x81,0x9d,0xb4,0xb8,0xb8,0xc2,0xed,0x19,0x16,0xea,0xc0, - 0xb8,0xb8,0xac,0x90,0x81,0x81,0x81,0x81,0x9d,0xb4,0xb8,0xb8,0xc2,0xed,0x19,0x16, - 0xea,0xc0,0xb8,0xb8,0xac,0x90,0x81,0x81,0x81,0x81,0x9d,0xb4,0xb8,0xb8,0xc2,0xed, - 0x19,0x16,0xea,0xc0,0xb8,0xb8,0xac,0x90,0x81,0x8d,0xb6,0xdf,0x09,0x28,0xff,0xdb, - 0xbb,0xb1,0xc5,0xe7,0x0f,0x1e,0xf5,0xcd,0xa4,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b, - 0x13,0xe7,0xbd,0x93,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x87,0xb1,0xda, - 0x04,0x2a,0x06,0xe0,0xbf,0xb1,0xba,0xd9,0xfc,0x24,0x09,0xe0,0xb8,0x8f,0x81,0x81, - 0x87,0xb1,0xda,0x04,0x2a,0x06,0xe0,0xbf,0xb1,0xba,0xd9,0xfc,0x24,0x09,0xe0,0xb8, - 0x8f,0x81,0x81,0x87,0xb1,0xda,0x04,0x2a,0x06,0xe0,0xbf,0xb1,0xba,0xd9,0xfc,0x24, - 0x09,0xe0,0xb8,0x8f,0x81,0x81,0x87,0xb1,0xda,0x04,0x2a,0x06,0xe0,0xbf,0xb1,0xba, - 0xd9,0xfc,0x24,0x09,0xe0,0xb8,0x8f,0x81,0x81,0x87,0xb1,0xda,0x04,0x2a,0x06,0xe0, - 0xbf,0xb1,0xba,0xd9,0xfc,0x24,0x09,0xe0,0xb8,0x8f,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0xa4,0xcd,0xf5,0x1b,0x18,0xf7,0xe3,0xdd,0xe2,0xf3,0x12,0x1d,0xf7,0xd2, - 0xa9,0x81,0x81,0x81,0xa4,0xcd,0xf5,0x1b,0x18,0xf7,0xe3,0xdd,0xe2,0xf3,0x12,0x1d, - 0xf7,0xd2,0xa9,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa8,0xd2,0xfc,0x29,0x09,0xdd, - 0xb2,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xe5,0xe5, - 0xe1,0xd7,0xc8,0xb5,0x9e,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xdf, - 0xe2,0xdd,0xdf,0xf0,0x13,0x19,0xf1,0xc7,0x9e,0x81,0x81,0x81,0xa7,0xd1,0xfa,0x24, - 0x11,0xec,0xdb,0xe1,0xf3,0x0b,0x24,0x21,0xf5,0xca,0xa0,0x81,0x81,0x81,0xa7,0xd1, - 0xfa,0x24,0x11,0xec,0xdb,0xe1,0xf3,0x0b,0x24,0x21,0xf5,0xca,0xa0,0x81,0x81,0x81, - 0xa7,0xd1,0xfa,0x24,0x11,0xec,0xdb,0xe1,0xf3,0x0b,0x24,0x21,0xf5,0xca,0xa0,0x81, - 0x81,0x81,0xa7,0xd1,0xfa,0x24,0x11,0xec,0xdb,0xe1,0xf3,0x0b,0x24,0x21,0xf5,0xca, - 0xa0,0x81,0x81,0x81,0xa7,0xd1,0xfa,0x24,0x11,0xec,0xdb,0xe1,0xf3,0x0b,0x24,0x21, - 0xf5,0xca,0xa0,0x81,0x81,0x81,0xa7,0xd1,0xfa,0x24,0x11,0xec,0xdb,0xe1,0xf3,0x0b, - 0x24,0x21,0xf5,0xca,0xa0,0x81,0x95,0xbf,0xe9,0x13,0x16,0xed,0xe0,0xfb,0x1c,0x21, - 0x09,0xe8,0xda,0xdf,0xe9,0xe4,0xbd,0x94,0x81,0x81,0xa9,0xd1,0xf6,0x1c,0x1c,0xff, - 0xe9,0xdf,0xde,0xe5,0xf1,0xf1,0xc7,0x9d,0x81,0x81,0x81,0x9b,0xc3,0xe9,0x0f,0x23, - 0x04,0xeb,0xde,0xda,0xdd,0xe2,0xea,0xea,0xc5,0x9c,0x81,0x81,0x81,0x9b,0xc3,0xe9, - 0x0f,0x23,0x04,0xeb,0xde,0xda,0xdd,0xe2,0xea,0xea,0xc5,0x9c,0x81,0x81,0x81,0x9b, - 0xc3,0xe9,0x0f,0x23,0x04,0xeb,0xde,0xda,0xdd,0xe2,0xea,0xea,0xc5,0x9c,0x81,0x81, - 0x81,0x9b,0xc3,0xe9,0x0f,0x23,0x04,0xeb,0xde,0xda,0xdd,0xe2,0xea,0xea,0xc5,0x9c, - 0x81,0x81,0x81,0x8f,0xb6,0xd9,0xe2,0xe2,0xe2,0xed,0x19,0x16,0xea,0xe2,0xe2,0xe2, - 0xcb,0xa5,0x81,0x81,0x81,0x8f,0xb6,0xd9,0xe2,0xe2,0xe2,0xed,0x19,0x16,0xea,0xe2, - 0xe2,0xe2,0xcb,0xa5,0x81,0x81,0x81,0x8f,0xb6,0xd9,0xe2,0xe2,0xe2,0xed,0x19,0x16, - 0xea,0xe2,0xe2,0xe2,0xcb,0xa5,0x81,0x81,0x81,0x8f,0xb6,0xd9,0xe2,0xe2,0xe2,0xed, - 0x19,0x16,0xea,0xe2,0xe2,0xe2,0xcb,0xa5,0x81,0x82,0xaa,0xd2,0xf9,0x1e,0x16,0xf5, - 0xe1,0xda,0xe6,0xff,0x22,0x0c,0xe6,0xc0,0x98,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b, - 0x13,0xe7,0xbd,0x93,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0xa4,0xcc, - 0xf3,0x18,0x1a,0xfb,0xe3,0xda,0xe0,0xf5,0x14,0x1a,0xf6,0xd1,0xaa,0x82,0x81,0x81, - 0x81,0xa4,0xcc,0xf3,0x18,0x1a,0xfb,0xe3,0xda,0xe0,0xf5,0x14,0x1a,0xf6,0xd1,0xaa, - 0x82,0x81,0x81,0x81,0xa4,0xcc,0xf3,0x18,0x1a,0xfb,0xe3,0xda,0xe0,0xf5,0x14,0x1a, - 0xf6,0xd1,0xaa,0x82,0x81,0x81,0x81,0xa4,0xcc,0xf3,0x18,0x1a,0xfb,0xe3,0xda,0xe0, - 0xf5,0x14,0x1a,0xf6,0xd1,0xaa,0x82,0x81,0x81,0x81,0xa4,0xcc,0xf3,0x18,0x1a,0xfb, - 0xe3,0xda,0xe0,0xf5,0x14,0x1a,0xf6,0xd1,0xaa,0x82,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x97,0xbc,0xe1,0x04,0x20,0x1b,0x0d,0x09,0x0b,0x18,0x1f,0x04,0xe2,0xbf, - 0x99,0x81,0x81,0x81,0x97,0xbc,0xe1,0x04,0x20,0x1b,0x0d,0x09,0x0b,0x18,0x1f,0x04, - 0xe2,0xbf,0x99,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa8,0xd2,0xfc,0x29,0x09,0xdd, - 0xb2,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xc2,0xba, - 0xb7,0xaf,0xa2,0x8f,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xea, - 0x0b,0x09,0x0b,0x14,0x22,0x05,0xe1,0xbb,0x94,0x81,0x81,0x81,0x9f,0xc7,0xed,0x12, - 0x29,0x0f,0x06,0x0b,0x19,0x12,0x06,0x21,0xf5,0xca,0xa0,0x81,0x81,0x81,0x9f,0xc7, - 0xed,0x12,0x29,0x0f,0x06,0x0b,0x19,0x12,0x06,0x21,0xf5,0xca,0xa0,0x81,0x81,0x81, - 0x9f,0xc7,0xed,0x12,0x29,0x0f,0x06,0x0b,0x19,0x12,0x06,0x21,0xf5,0xca,0xa0,0x81, - 0x81,0x81,0x9f,0xc7,0xed,0x12,0x29,0x0f,0x06,0x0b,0x19,0x12,0x06,0x21,0xf5,0xca, - 0xa0,0x81,0x81,0x81,0x9f,0xc7,0xed,0x12,0x29,0x0f,0x06,0x0b,0x19,0x12,0x06,0x21, - 0xf5,0xca,0xa0,0x81,0x81,0x81,0x9f,0xc7,0xed,0x12,0x29,0x0f,0x06,0x0b,0x19,0x12, - 0x06,0x21,0xf5,0xca,0xa0,0x81,0x8f,0xb8,0xe1,0x09,0x27,0x0b,0x09,0x1b,0x04,0x0d, - 0x23,0x0d,0x06,0x09,0x12,0xea,0xc0,0x95,0x81,0x81,0x98,0xbe,0xe1,0xff,0x1d,0x21, - 0x11,0x09,0x09,0x0e,0x19,0xf2,0xc8,0x9d,0x81,0x81,0x81,0x8b,0xb1,0xd5,0xf7,0x15, - 0x25,0x12,0x09,0x06,0x09,0x0b,0x13,0xf2,0xc8,0x9d,0x81,0x81,0x81,0x8b,0xb1,0xd5, - 0xf7,0x15,0x25,0x12,0x09,0x06,0x09,0x0b,0x13,0xf2,0xc8,0x9d,0x81,0x81,0x81,0x8b, - 0xb1,0xd5,0xf7,0x15,0x25,0x12,0x09,0x06,0x09,0x0b,0x13,0xf2,0xc8,0x9d,0x81,0x81, - 0x81,0x8b,0xb1,0xd5,0xf7,0x16,0x25,0x12,0x09,0x06,0x09,0x0b,0x13,0xf2,0xc8,0x9d, - 0x81,0x81,0x81,0x93,0xbd,0xe7,0x0e,0x0e,0x0e,0x0e,0x1d,0x1a,0x0e,0x0e,0x0e,0xff, - 0xd5,0xab,0x81,0x81,0x81,0x93,0xbd,0xe7,0x0e,0x0e,0x0e,0x0e,0x1d,0x1a,0x0e,0x0e, - 0x0e,0xff,0xd5,0xab,0x81,0x81,0x81,0x93,0xbd,0xe7,0x0e,0x0e,0x0e,0x0e,0x1d,0x1a, - 0x0e,0x0e,0x0e,0xff,0xd5,0xab,0x81,0x81,0x81,0x93,0xbd,0xe7,0x0e,0x0e,0x0e,0x0e, - 0x1d,0x1a,0x0e,0x0e,0x0e,0xff,0xd5,0xab,0x81,0x81,0x9a,0xc0,0xe3,0x05,0x21,0x19, - 0x09,0x06,0x0d,0x20,0x12,0xf3,0xd2,0xad,0x87,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b, - 0x13,0xe7,0xbd,0x93,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x94,0xba, - 0xde,0xff,0x1c,0x1d,0x0b,0x06,0x09,0x18,0x1c,0xff,0xdf,0xbd,0x98,0x81,0x81,0x81, - 0x81,0x94,0xba,0xde,0xff,0x1c,0x1d,0x0b,0x06,0x09,0x18,0x1c,0xff,0xdf,0xbd,0x98, - 0x81,0x81,0x81,0x81,0x94,0xba,0xde,0xff,0x1c,0x1d,0x0b,0x06,0x09,0x18,0x1c,0xff, - 0xdf,0xbd,0x98,0x81,0x81,0x81,0x81,0x94,0xba,0xde,0xff,0x1c,0x1d,0x0b,0x06,0x09, - 0x18,0x1c,0xff,0xdf,0xbd,0x98,0x81,0x81,0x81,0x81,0x94,0xba,0xde,0xff,0x1c,0x1d, - 0x0b,0x06,0x09,0x18,0x1c,0xff,0xdf,0xbd,0x98,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x83,0xa7,0xc7,0xe4,0xfc,0x0d,0x16,0x19,0x16,0x0c,0xfb,0xe3,0xc7,0xa7, - 0x84,0x81,0x81,0x81,0x83,0xa7,0xc7,0xe4,0xfc,0x0d,0x16,0x19,0x16,0x0c,0xfb,0xe3, - 0xc7,0xa7,0x84,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa8,0xd2,0xfc,0x11,0x09,0xdd, - 0xb2,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x11,0x11,0xed,0xc2,0x98, - 0x8d,0x86,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x11,0x11,0xed,0xea, - 0x11,0x16,0x14,0x0e,0xfc,0xe6,0xc9,0xa7,0x82,0x81,0x81,0x81,0x8e,0xb4,0xd7,0xf4, - 0x0a,0x16,0x19,0x12,0x05,0xf0,0x06,0x11,0xf5,0xca,0xa0,0x81,0x81,0x81,0x8e,0xb4, - 0xd7,0xf4,0x0a,0x16,0x19,0x12,0x05,0xf0,0x06,0x11,0xf5,0xca,0xa0,0x81,0x81,0x81, - 0x8e,0xb4,0xd7,0xf4,0x0a,0x16,0x19,0x12,0x05,0xf0,0x06,0x11,0xf5,0xca,0xa0,0x81, - 0x81,0x81,0x8e,0xb4,0xd7,0xf4,0x0a,0x16,0x19,0x12,0x05,0xf0,0x06,0x11,0xf5,0xca, - 0xa0,0x81,0x81,0x81,0x8e,0xb4,0xd7,0xf4,0x0a,0x16,0x19,0x12,0x05,0xf0,0x06,0x11, - 0xf5,0xca,0xa0,0x81,0x81,0x81,0x8e,0xb4,0xd7,0xf4,0x0a,0x16,0x19,0x12,0x05,0xf0, - 0x06,0x11,0xf5,0xca,0xa0,0x81,0x82,0xaa,0xce,0xf0,0x0b,0x17,0x14,0xff,0xe6,0xf1, - 0x0a,0x16,0x19,0x13,0x09,0xea,0xc0,0x95,0x81,0x81,0x83,0xa6,0xc5,0xe1,0xf9,0x0a, - 0x18,0x23,0x19,0x12,0x09,0xf1,0xc7,0x9d,0x81,0x81,0x81,0x81,0x9b,0xbb,0xd9,0xf3, - 0x06,0x11,0x18,0x19,0x16,0x11,0x09,0xf2,0xc8,0x9d,0x81,0x81,0x81,0x81,0x9b,0xbb, - 0xd9,0xf3,0x06,0x11,0x18,0x19,0x16,0x11,0x09,0xf2,0xc8,0x9d,0x81,0x81,0x81,0x81, - 0x9b,0xbb,0xd9,0xf3,0x06,0x11,0x18,0x19,0x16,0x11,0x09,0xf2,0xc8,0x9d,0x81,0x81, - 0x81,0x81,0x9b,0xbb,0xd9,0xf3,0x06,0x11,0x18,0x19,0x16,0x11,0x09,0xf2,0xc8,0x9d, - 0x81,0x81,0x81,0x93,0xbd,0xe7,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0xff, - 0xd5,0xab,0x81,0x81,0x81,0x93,0xbd,0xe7,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11, - 0x11,0xff,0xd5,0xab,0x81,0x81,0x81,0x93,0xbd,0xe7,0x11,0x11,0x11,0x11,0x11,0x11, - 0x11,0x11,0x11,0xff,0xd5,0xab,0x81,0x81,0x81,0x93,0xbd,0xe7,0x11,0x11,0x11,0x11, - 0x11,0x11,0x11,0x11,0x11,0xff,0xd5,0xab,0x81,0x81,0x86,0xa8,0xc8,0xe6,0xfc,0x0e, - 0x16,0x19,0x13,0x06,0xf1,0xd7,0xb8,0x97,0x81,0x81,0x81,0x81,0x9b,0xc5,0xef,0x11, - 0x11,0xe7,0xbd,0x93,0xb5,0xdf,0x0b,0x11,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x81,0xa2, - 0xc3,0xe1,0xf9,0x0b,0x15,0x19,0x15,0x0b,0xf7,0xe0,0xc3,0xa4,0x82,0x81,0x81,0x81, - 0x81,0x81,0xa2,0xc3,0xe1,0xf9,0x0b,0x15,0x19,0x15,0x0b,0xf7,0xe0,0xc3,0xa4,0x82, - 0x81,0x81,0x81,0x81,0x81,0xa2,0xc3,0xe1,0xf9,0x0b,0x15,0x19,0x15,0x0b,0xf7,0xe0, - 0xc3,0xa4,0x82,0x81,0x81,0x81,0x81,0x81,0xa2,0xc3,0xe1,0xf9,0x0b,0x15,0x19,0x15, - 0x0b,0xf7,0xe0,0xc3,0xa4,0x82,0x81,0x81,0x81,0x81,0x81,0xa2,0xc3,0xe1,0xf9,0x0b, - 0x15,0x19,0x15,0x0b,0xf7,0xe0,0xc3,0xa4,0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x8b,0xa9,0xc2,0xd6,0xe4,0xea,0xed,0xea,0xe3,0xd5,0xc1,0xa8,0x8b, - 0x81,0x81,0x81,0x81,0x81,0x8b,0xa9,0xc2,0xd6,0xe4,0xea,0xed,0xea,0xe3,0xd5,0xc1, - 0xa8,0x8b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa4,0xcb,0xe4,0xe5,0xe5,0xd3, - 0xae,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x92,0xba,0xdd,0xe5,0xe5,0xde,0xbc,0x94, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x92,0xba,0xdd,0xe5,0xe5,0xde,0xdd, - 0xe7,0xea,0xea,0xe4,0xd8,0xc5,0xab,0x8e,0x81,0x81,0x81,0x81,0x81,0x9b,0xb9,0xd1, - 0xe2,0xeb,0xed,0xe9,0xdd,0xd1,0xe5,0xe5,0xe2,0xc4,0x9c,0x81,0x81,0x81,0x81,0x9b, - 0xb9,0xd1,0xe2,0xeb,0xed,0xe9,0xdd,0xd1,0xe5,0xe5,0xe2,0xc4,0x9c,0x81,0x81,0x81, - 0x81,0x9b,0xb9,0xd1,0xe2,0xeb,0xed,0xe9,0xdd,0xd1,0xe5,0xe5,0xe2,0xc4,0x9c,0x81, - 0x81,0x81,0x81,0x9b,0xb9,0xd1,0xe2,0xeb,0xed,0xe9,0xdd,0xd1,0xe5,0xe5,0xe2,0xc4, - 0x9c,0x81,0x81,0x81,0x81,0x9b,0xb9,0xd1,0xe2,0xeb,0xed,0xe9,0xdd,0xd1,0xe5,0xe5, - 0xe2,0xc4,0x9c,0x81,0x81,0x81,0x81,0x9b,0xb9,0xd1,0xe2,0xeb,0xed,0xe9,0xdd,0xd1, - 0xe5,0xe5,0xe2,0xc4,0x9c,0x81,0x81,0x94,0xb4,0xd1,0xe4,0xed,0xeb,0xdc,0xc6,0xd0, - 0xe3,0xed,0xed,0xe8,0xe0,0xd2,0xb4,0x8e,0x81,0x81,0x81,0x89,0xa6,0xbf,0xd3,0xed, - 0x16,0x12,0xed,0xe7,0xdf,0xd2,0xb7,0x93,0x81,0x81,0x81,0x81,0x81,0x9d,0xb8,0xcd, - 0xde,0xe7,0xed,0xed,0xea,0xe7,0xdf,0xd5,0xba,0x95,0x81,0x81,0x81,0x81,0x81,0x9d, - 0xb8,0xcd,0xde,0xe7,0xed,0xed,0xea,0xe7,0xdf,0xd5,0xba,0x95,0x81,0x81,0x81,0x81, - 0x81,0x9d,0xb8,0xcd,0xde,0xe7,0xed,0xed,0xea,0xe7,0xdf,0xd5,0xba,0x95,0x81,0x81, - 0x81,0x81,0x81,0x9d,0xb8,0xce,0xde,0xe7,0xed,0xed,0xea,0xe7,0xdf,0xd5,0xba,0x95, - 0x81,0x81,0x81,0x8f,0xb8,0xdb,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5, - 0xcd,0xa6,0x81,0x81,0x81,0x8f,0xb8,0xdb,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5, - 0xe5,0xe5,0xcd,0xa6,0x81,0x81,0x81,0x8f,0xb8,0xdb,0xe5,0xe5,0xe5,0xe5,0xe5,0xe5, - 0xe5,0xe5,0xe5,0xe5,0xcd,0xa6,0x81,0x81,0x81,0x8f,0xb8,0xdb,0xe5,0xe5,0xe5,0xe5, - 0xe5,0xe5,0xe5,0xe5,0xe5,0xe5,0xcd,0xa6,0x81,0x81,0x81,0x8c,0xaa,0xc3,0xd8,0xe5, - 0xed,0xed,0xe9,0xde,0xcd,0xb6,0x9b,0x81,0x81,0x81,0x81,0x81,0x97,0xbf,0xe0,0xe5, - 0xe5,0xdb,0xb8,0x8f,0xb0,0xd5,0xe5,0xe5,0xe3,0xc6,0x9f,0x81,0x81,0x81,0x81,0x87, - 0xa5,0xbf,0xd3,0xe2,0xea,0xed,0xea,0xe2,0xd3,0xbe,0xa5,0x87,0x81,0x81,0x81,0x81, - 0x81,0x81,0x87,0xa5,0xbf,0xd3,0xe2,0xea,0xed,0xea,0xe2,0xd3,0xbe,0xa5,0x87,0x81, - 0x81,0x81,0x81,0x81,0x81,0x87,0xa5,0xbf,0xd3,0xe2,0xea,0xed,0xea,0xe2,0xd3,0xbe, - 0xa5,0x87,0x81,0x81,0x81,0x81,0x81,0x81,0x87,0xa5,0xbf,0xd3,0xe2,0xea,0xed,0xea, - 0xe2,0xd3,0xbe,0xa5,0x87,0x81,0x81,0x81,0x81,0x81,0x81,0x87,0xa5,0xbf,0xd3,0xe2, - 0xea,0xed,0xea,0xe2,0xd3,0xbe,0xa5,0x87,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x88,0x9e,0xaf,0xbb,0xc1,0xc2,0xc1,0xba,0xae,0x9c,0x86,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x88,0x9e,0xaf,0xbb,0xc1,0xc2,0xc1,0xba,0xae,0x9c, - 0x86,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8f,0xac,0xba,0xba,0xba,0xb2, - 0x98,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa1,0xb7,0xba,0xba,0xb8,0xa3,0x83, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa1,0xb7,0xba,0xba,0xb8,0xb7, - 0xbd,0xc0,0xc0,0xbb,0xb0,0x9f,0x8a,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x97,0xac, - 0xba,0xc2,0xc2,0xbf,0xb5,0xb1,0xba,0xba,0xb9,0xa8,0x89,0x81,0x81,0x81,0x81,0x81, - 0x97,0xac,0xba,0xc2,0xc2,0xbf,0xb5,0xb1,0xba,0xba,0xb9,0xa8,0x89,0x81,0x81,0x81, - 0x81,0x81,0x97,0xac,0xba,0xc2,0xc2,0xbf,0xb5,0xb1,0xba,0xba,0xb9,0xa8,0x89,0x81, - 0x81,0x81,0x81,0x81,0x97,0xac,0xba,0xc2,0xc2,0xbf,0xb5,0xb1,0xba,0xba,0xb9,0xa8, - 0x89,0x81,0x81,0x81,0x81,0x81,0x97,0xac,0xba,0xc2,0xc2,0xbf,0xb5,0xb1,0xba,0xba, - 0xb9,0xa8,0x89,0x81,0x81,0x81,0x81,0x81,0x97,0xac,0xba,0xc2,0xc2,0xbf,0xb5,0xb1, - 0xba,0xba,0xb9,0xa8,0x89,0x81,0x81,0x81,0x96,0xac,0xbc,0xc2,0xc2,0xb6,0xa3,0xab, - 0xbb,0xc2,0xc2,0xbf,0xb7,0xaa,0x97,0x81,0x81,0x81,0x81,0x81,0x84,0xa3,0xcc,0xf5, - 0x1f,0x06,0xde,0xbf,0xb6,0xaa,0x98,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x94,0xa7, - 0xb5,0xbe,0xc2,0xc2,0xc0,0xbd,0xb6,0xad,0x9c,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x94,0xa7,0xb5,0xbe,0xc2,0xc2,0xc0,0xbd,0xb6,0xad,0x9c,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x94,0xa7,0xb5,0xbe,0xc2,0xc2,0xc0,0xbd,0xb6,0xad,0x9c,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x94,0xa7,0xb5,0xbf,0xc2,0xc2,0xc0,0xbd,0xb6,0xad,0x9c,0x81, - 0x81,0x81,0x81,0x81,0x9f,0xb6,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba, - 0xae,0x92,0x81,0x81,0x81,0x81,0x9f,0xb6,0xba,0xba,0xba,0xba,0xba,0xba,0xba,0xba, - 0xba,0xba,0xae,0x92,0x81,0x81,0x81,0x81,0x9f,0xb6,0xba,0xba,0xba,0xba,0xba,0xba, - 0xba,0xba,0xba,0xba,0xae,0x92,0x81,0x81,0x81,0x81,0x9f,0xb6,0xba,0xba,0xba,0xba, - 0xba,0xba,0xba,0xba,0xba,0xba,0xae,0x92,0x81,0x81,0x81,0x81,0x89,0x9f,0xb0,0xbc, - 0xc2,0xc2,0xbf,0xb6,0xa7,0x93,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0xa5,0xb8,0xba, - 0xba,0xb6,0x9f,0x81,0x9a,0xb3,0xba,0xba,0xba,0xa9,0x8b,0x81,0x81,0x81,0x81,0x81, - 0x84,0x9a,0xad,0xb9,0xc1,0xc2,0xc1,0xb9,0xac,0x9a,0x83,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x84,0x9a,0xad,0xb9,0xc1,0xc2,0xc1,0xb9,0xac,0x9a,0x83,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x84,0x9a,0xad,0xb9,0xc1,0xc2,0xc1,0xb9,0xac,0x9a, - 0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x84,0x9a,0xad,0xb9,0xc1,0xc2,0xc1, - 0xb9,0xac,0x9a,0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x84,0x9a,0xad,0xb9, - 0xc1,0xc2,0xc1,0xb9,0xac,0x9a,0x83,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x87,0x91,0x97,0x98,0x97,0x91,0x86,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x87,0x91,0x97,0x98,0x97,0x91,0x86,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x87,0x90,0x90,0x90,0x8b, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0x90,0x90,0x8e,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0x90,0x90,0x8e,0x8e, - 0x93,0x95,0x95,0x91,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x84, - 0x91,0x98,0x98,0x95,0x8d,0x8a,0x90,0x90,0x8f,0x84,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x84,0x91,0x98,0x98,0x95,0x8d,0x8a,0x90,0x90,0x8f,0x84,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x84,0x91,0x98,0x98,0x95,0x8d,0x8a,0x90,0x90,0x8f,0x84,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x84,0x91,0x98,0x98,0x95,0x8d,0x8a,0x90,0x90,0x8f,0x84, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x84,0x91,0x98,0x98,0x95,0x8d,0x8a,0x90,0x90, - 0x8f,0x84,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x84,0x91,0x98,0x98,0x95,0x8d,0x8a, - 0x90,0x90,0x8f,0x84,0x81,0x81,0x81,0x81,0x81,0x86,0x93,0x98,0x98,0x8f,0x81,0x85, - 0x92,0x98,0x98,0x95,0x8e,0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x83,0xac,0xd6,0xff, - 0x23,0xfa,0xd2,0xa9,0x8d,0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x8d,0x94,0x98,0x98,0x97,0x92,0x8c,0x84,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x8d,0x94,0x98,0x98,0x97,0x92,0x8c,0x84,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x8d,0x94,0x98,0x98,0x97,0x92,0x8c,0x84,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x8d,0x95,0x98,0x98,0x97,0x92,0x8c,0x84,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x8d,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90, - 0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x8d,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90, - 0x90,0x90,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x8d,0x90,0x90,0x90,0x90,0x90,0x90, - 0x90,0x90,0x90,0x90,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x8d,0x90,0x90,0x90,0x90, - 0x90,0x90,0x90,0x90,0x90,0x90,0x88,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x88,0x93, - 0x98,0x98,0x95,0x8d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8f,0x90, - 0x90,0x8d,0x81,0x81,0x81,0x8b,0x90,0x90,0x90,0x85,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x85,0x90,0x97,0x98,0x97,0x90,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x85,0x90,0x97,0x98,0x97,0x90,0x85,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0x90,0x97,0x98,0x97,0x90,0x85,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0x90,0x97,0x98,0x97, - 0x90,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0x90, - 0x97,0x98,0x97,0x90,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x88,0xb2,0xdc,0xfa, - 0xfa,0xee,0xc6,0x9e,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa4,0xc4,0xd0, - 0xd0,0xcd,0xb3,0x8f,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x88,0x9e,0xa5, - 0xa5,0xa4,0x94,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x88,0x8b,0x8b,0x8b,0x89,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x88,0x8b,0x8b,0x8b,0x8a,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x8a,0x8b,0x8b,0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x85,0x85,0x81,0x81,0x81,0x85,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x86,0x8b,0x8b,0x8b,0x8a,0x81,0x81,0x81,0x81,0x81, - 0x81,0x86,0x88,0x88,0x86,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9b,0xb1,0xb5,0xb5,0xb5,0xb3,0x9f,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9a, - 0xb0,0xb5,0xb5,0xb5,0xb3,0xa0,0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x87,0xa4, - 0xb4,0xb5,0xb5,0xa8,0x8c,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8a,0xa1, - 0xaf,0xaf,0xa4,0x8d,0xa0,0xaf,0xb0,0xa5,0x8f,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x96,0xae,0xb5,0xb5,0xb5,0xb4,0xa2,0x84,0x81,0x81,0x81, - 0x9b,0xaf,0xb2,0xb2,0xaf,0x9b,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0xb5,0xd7,0xdf,0xdf,0xdf,0xda,0xbc,0x9d,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x99,0xb8, - 0xd5,0xdf,0xdf,0xdf,0xdb,0xbc,0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x87,0xa5,0xc3, - 0xdd,0xdf,0xdf,0xc8,0xaa,0x8c,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x86,0xa8,0xc6, - 0xd8,0xd9,0xc8,0xac,0xc4,0xd7,0xda,0xca,0xae,0x8d,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x96,0xb4,0xd2,0xdf,0xdf,0xdf,0xdc,0xbf,0x98,0x81,0x81,0x90, - 0xb6,0xd6,0xdd,0xdd,0xd6,0xb6,0x90,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x87,0xa0,0xab,0xab,0xa9,0x99, - 0x81,0x81,0x81,0x81,0x81,0x81,0x92,0xbc,0xe6,0x04,0x0b,0x0b,0xf7,0xd9,0xbb,0x9d, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x98,0xb6,0xd4, - 0xf3,0x0b,0x0b,0x09,0xed,0xc4,0x9a,0x81,0x81,0x81,0x81,0x81,0x87,0xa5,0xc3,0xe1, - 0xff,0x0b,0x05,0xe6,0xc8,0xaa,0x8c,0x81,0x81,0x81,0x81,0x81,0x81,0x99,0xc0,0xe4, - 0xff,0x04,0xe8,0xc5,0xe2,0xff,0x04,0xea,0xc7,0xa0,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x96,0xb4,0xd2,0xf0,0x0b,0x0b,0x0b,0xef,0xc7,0x9d,0x81,0x81,0x95, - 0xc0,0xea,0x09,0x09,0xea,0xc0,0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0x82,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa0,0xc3,0xd5,0xd5,0xd2,0xb9, - 0x94,0x81,0x81,0x81,0x81,0x81,0x87,0xac,0xc8,0xe2,0xfb,0x14,0x16,0xf7,0xd9,0xbb, - 0x9d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x97,0xb6,0xd4,0xf1, - 0x10,0x1a,0xff,0xe6,0xcd,0xb2,0x8e,0x81,0x81,0x81,0x81,0x84,0xa5,0xc3,0xe1,0xff, - 0x1d,0x09,0x1f,0x05,0xe6,0xc8,0xaa,0x8b,0x81,0x81,0x81,0x81,0x81,0xa0,0xca,0xf5, - 0x1f,0x23,0xfa,0xd0,0xf2,0x1c,0x25,0xfc,0xd2,0xa8,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x95,0xb4,0xd2,0xf0,0x0f,0x1d,0x04,0xe9,0xd0,0xb4,0x91,0x81,0x81,0x95, - 0xc0,0xea,0x16,0x16,0xea,0xc0,0x95,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x99,0xaa,0xb0,0xab,0x9b,0x83,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0x92,0x99,0xaf,0xd7,0xff,0xff,0xf2,0xc8, - 0x9d,0x81,0x81,0x81,0x81,0x81,0x81,0x8d,0xa7,0xc0,0xd9,0xf3,0x0d,0x16,0xf7,0xd9, - 0xb4,0x93,0x92,0x87,0x81,0x81,0x81,0x81,0x81,0x84,0x91,0x93,0xac,0xd3,0xf1,0x10, - 0x12,0xf7,0xde,0xc5,0xab,0x92,0x81,0x81,0x81,0x81,0x81,0x95,0xbd,0xe1,0xff,0x1b, - 0x04,0xe7,0xff,0x1b,0x05,0xe6,0xc5,0x9d,0x81,0x81,0x81,0x81,0x81,0x9d,0xc6,0xed, - 0x0f,0x10,0xf1,0xcb,0xeb,0x0d,0x12,0xf4,0xcd,0xa5,0x81,0x81,0x81,0x81,0x85,0x92, - 0x93,0x93,0xa9,0xd0,0xf0,0x0f,0x14,0xfb,0xe1,0xc8,0xae,0x95,0x88,0x81,0x81,0x95, - 0xc0,0xea,0x16,0x16,0xea,0xc0,0x96,0x9b,0x9b,0x94,0x88,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x9d,0xbb,0xd2,0xda,0xd4,0xbf,0xa1,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x83,0x9a,0xad,0xbb,0xc2,0xc5,0xe5,0x0d,0x0f,0xe7,0xbf, - 0x97,0x81,0x81,0x81,0x81,0x81,0x86,0xa7,0xbb,0xbd,0xbd,0xd2,0xeb,0xef,0xef,0xde, - 0xbd,0xbd,0xbc,0xac,0x8d,0x81,0x81,0x81,0x86,0xa7,0xbb,0xbd,0xbd,0xd6,0xef,0xef, - 0xee,0xd6,0xbd,0xbd,0xbc,0xac,0x8d,0x81,0x81,0x81,0x86,0xa7,0xc0,0xe6,0xef,0xef, - 0xe3,0xc8,0xdf,0xef,0xef,0xec,0xc8,0xac,0x8d,0x81,0x81,0x81,0x86,0xa7,0xbb,0xd2, - 0xe7,0xe9,0xd5,0xb7,0xd0,0xe7,0xea,0xd7,0xbc,0xac,0x8d,0x81,0x81,0x89,0xa8,0xbb, - 0xbd,0xbd,0xbb,0xd4,0xef,0xef,0xef,0xd9,0xc0,0xbd,0xbd,0xbd,0xad,0x8f,0x81,0x95, - 0xc0,0xea,0x16,0x16,0xea,0xc0,0xbf,0xc5,0xc5,0xbd,0xae,0x99,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x8c,0xb3,0xd9,0xf6,0x06,0xf9,0xdd,0xb8,0x91,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x87,0xa5,0xbe,0xd3,0xe3,0xed,0xef,0xf2,0x1a,0x04,0xda,0xb2, - 0x8e,0x81,0x81,0x81,0x81,0x81,0x98,0xc0,0xe2,0xe7,0xe7,0xdd,0xc3,0xc5,0xc5,0xd7, - 0xe7,0xe7,0xe6,0xc7,0x9f,0x81,0x81,0x81,0x98,0xc0,0xe2,0xe7,0xe7,0xdd,0xc5,0xc5, - 0xc5,0xd7,0xe7,0xe7,0xe6,0xc7,0x9f,0x81,0x81,0x81,0x98,0xc0,0xe2,0xe7,0xe7,0xdd, - 0xc0,0xa8,0xbe,0xd7,0xe7,0xe7,0xe6,0xc7,0x9f,0x81,0x81,0x81,0x98,0xc0,0xe2,0xe7, - 0xe7,0xdd,0xb9,0x9a,0xb1,0xd7,0xe7,0xe7,0xe6,0xc7,0x9f,0x81,0x81,0x9a,0xc2,0xe3, - 0xe7,0xe7,0xe2,0xc1,0xc5,0xc5,0xc5,0xb7,0xd9,0xe7,0xe7,0xe7,0xc9,0xa2,0x81,0x95, - 0xc0,0xea,0x16,0x16,0xea,0xd9,0xe7,0xef,0xef,0xe6,0xd3,0xb9,0x9b,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x12,0x2f,0x17,0xef,0xc5,0x9b,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0xa3,0xc3,0xe0,0xf9,0x0b,0x16,0x1b,0x19,0x21,0xfc,0xe6,0xca, - 0xaa,0x87,0x81,0x81,0x81,0x81,0x9b,0xc5,0xef,0x13,0x13,0xe7,0xbd,0x9b,0xb5,0xdf, - 0x0b,0x13,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x9b,0xc5,0xef,0x13,0x13,0xe7,0xbd,0x9b, - 0xb5,0xdf,0x0b,0x13,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x9b,0xc5,0xef,0x13,0x13,0xe7, - 0xbd,0x93,0xb5,0xdf,0x0b,0x13,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x9b,0xc5,0xef,0x13, - 0x13,0xe7,0xbd,0x93,0xb5,0xdf,0x0b,0x13,0xf7,0xcd,0xa3,0x81,0x81,0x9c,0xc5,0xec, - 0x13,0x13,0xf7,0xd1,0xa9,0x9b,0x9c,0xc4,0xec,0x13,0x13,0xf5,0xce,0xa4,0x81,0x95, - 0xc0,0xea,0x16,0x16,0xea,0xfc,0x0f,0x19,0x19,0x0d,0xf5,0xd7,0xb5,0x91,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x94,0xbe,0xe7,0x0f,0x28,0x12,0xec,0xc3,0x9a,0x81,0x81,0x81, - 0x81,0x81,0x81,0x95,0xbb,0xde,0xff,0x1c,0x18,0x09,0x04,0x12,0x21,0x22,0x05,0xe5, - 0xc1,0x9b,0x81,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7,0xbd,0x93,0xb5,0xdf, - 0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7,0xbd,0x93, - 0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7, - 0xbd,0x93,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b, - 0x13,0xe7,0xbd,0x93,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x8e,0xb5,0xdd, - 0x05,0x2c,0x07,0xe0,0xb9,0x91,0xaa,0xd2,0xfa,0x22,0x0f,0xe7,0xbf,0x98,0x81,0x95, - 0xc0,0xea,0x16,0x16,0x04,0x20,0x0f,0x06,0x0d,0x25,0x12,0xef,0xcb,0xa4,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x91,0xa2,0xa5,0xa5,0xaf,0xd3,0xf0,0xfc,0xf3,0xd7,0xb4,0xa5,0xa5,0xa4,0x96, - 0x81,0x81,0x81,0xa7,0xce,0xf4,0x19,0x16,0xf5,0xdf,0xf2,0x1a,0x04,0x13,0x20,0xfa, - 0xd4,0xad,0x85,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7,0xbd,0x93,0xb5,0xdf, - 0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7,0xbd,0x93, - 0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7, - 0xbd,0x93,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b, - 0x13,0xe7,0xbd,0x93,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0xa6,0xcd, - 0xf5,0x1c,0x17,0xef,0xc8,0xa0,0xb9,0xe0,0x09,0x27,0xff,0xd8,0xb0,0x89,0x81,0x95, - 0xc0,0xea,0x16,0x21,0x1d,0xff,0xe8,0xda,0xe8,0x09,0x29,0x04,0xda,0xb2,0x89,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x8b,0xaf,0xcb,0xd0,0xd0,0xd0,0xd0,0xd0,0xd2,0xd0,0xd0,0xd0,0xd0,0xd0,0xce,0xb7, - 0x94,0x81,0x8b,0xb4,0xdd,0x06,0x28,0xff,0xdb,0xd7,0xff,0x1d,0xf5,0xfc,0x25,0x0b, - 0xe2,0xb9,0x8f,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7,0xbd,0x93,0xb5,0xdf, - 0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7,0xbd,0x93, - 0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7, - 0xbd,0x93,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b, - 0x13,0xe7,0xbd,0x93,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x97,0xbe, - 0xe5,0x0c,0x26,0xfc,0xd6,0xaf,0xc7,0xee,0x16,0x18,0xf1,0xc9,0xa1,0x81,0x81,0x95, - 0xc0,0xea,0x16,0x22,0xff,0xe1,0xc5,0xb1,0xcf,0xf7,0x20,0x0e,0xe5,0xbb,0x91,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x95,0xbf,0xe9,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xf3,0xca, - 0xa0,0x81,0x92,0xbc,0xe6,0x11,0x1e,0xf4,0xcb,0xe5,0x0d,0x0f,0xe7,0xf1,0x1b,0x13, - 0xea,0xc0,0x95,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7,0xbd,0x93,0xb5,0xdf, - 0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7,0xbd,0x93, - 0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7, - 0xbd,0x93,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b, - 0x13,0xe7,0xbd,0x93,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x87,0xae, - 0xd5,0xfc,0x24,0x0d,0xe6,0xbe,0xd5,0xfc,0x24,0x09,0xe1,0xba,0x92,0x81,0x81,0x95, - 0xc0,0xea,0x16,0x19,0xed,0xc6,0xa6,0x9b,0xc5,0xef,0x19,0x16,0xea,0xc0,0x97,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x95,0xc0,0xea,0x16,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x26,0x21,0xf5,0xca, - 0xa0,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xca,0xf2,0x1a,0x04,0xda,0xea,0x16,0x19, - 0xed,0xc2,0x98,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7,0xbd,0x93,0xb5,0xdf, - 0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7,0xbd,0x93, - 0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7, - 0xbd,0x93,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b, - 0x13,0xe7,0xbd,0x93,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x81,0x9e, - 0xc6,0xed,0x14,0x1d,0xf5,0xcd,0xe2,0x0b,0x21,0xfa,0xd2,0xab,0x83,0x81,0x81,0x95, - 0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0x96,0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x95,0xbf,0xe9,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xfa,0xf3,0xca, - 0xa0,0x81,0x95,0xc0,0xea,0x16,0x19,0xed,0xd7,0xff,0x1d,0xf5,0xcd,0xec,0x16,0x18, - 0xed,0xc2,0x98,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7,0xbd,0x93,0xb5,0xdf, - 0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7,0xbd,0x93, - 0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7, - 0xbd,0x93,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b, - 0x13,0xe7,0xbd,0x93,0xb5,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x81,0x8f, - 0xb6,0xdd,0x05,0x2c,0x04,0xdc,0xf1,0x19,0x12,0xeb,0xc3,0x9c,0x81,0x81,0x81,0x95, - 0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0x98,0xc2,0xec,0x16,0x16,0xed,0xc2,0x98,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x8b,0xaf,0xcb,0xd0,0xd0,0xd0,0xd0,0xd0,0xd2,0xd0,0xd0,0xd0,0xd0,0xd0,0xce,0xb7, - 0x94,0x81,0x93,0xbd,0xe7,0x11,0x1e,0xf4,0xe5,0x0d,0x11,0xe7,0xc9,0xf2,0x1b,0x11, - 0xe7,0xbf,0x95,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7,0xbd,0x9d,0xbd,0xdf, - 0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7,0xbd,0x9d, - 0xbd,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b,0x13,0xe7, - 0xbd,0x9d,0xbd,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x9b,0xc5,0xef,0x1b, - 0x13,0xe7,0xbd,0x9d,0xbd,0xdf,0x0b,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x81,0x81, - 0xa6,0xcd,0xf5,0x1c,0x13,0xec,0xff,0x27,0x04,0xdc,0xb4,0x8d,0x81,0x81,0x81,0x95, - 0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0xa1,0xc9,0xf2,0x1b,0x11,0xe7,0xbd,0x94,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x91,0xa2,0xa5,0xa5,0xaf,0xd3,0xf0,0xfc,0xf3,0xd7,0xb4,0xa5,0xa5,0xa4,0x96, - 0x81,0x81,0x8c,0xb6,0xde,0x07,0x28,0xff,0xf2,0x1a,0x04,0xdb,0xda,0xff,0x26,0x06, - 0xde,0xb6,0x8d,0x81,0x81,0x81,0x9b,0xc5,0xef,0x19,0x16,0xec,0xc2,0xbd,0xd8,0xf7, - 0x18,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x9b,0xc5,0xef,0x19,0x16,0xec,0xc2,0xbd, - 0xd8,0xf7,0x18,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x9b,0xc5,0xef,0x19,0x16,0xec, - 0xc2,0xbd,0xd8,0xf7,0x18,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x9b,0xc5,0xef,0x19, - 0x16,0xec,0xc2,0xbd,0xd8,0xf7,0x18,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x81,0x81, - 0x97,0xbe,0xe5,0x0c,0x21,0xf9,0x0d,0x1b,0xf4,0xcd,0xa5,0x81,0x81,0x81,0x81,0x95, - 0xc0,0xea,0x16,0x19,0xed,0xc2,0xb0,0xbb,0xda,0xff,0x26,0x05,0xdc,0xb4,0x8b,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x94,0xbe,0xe7,0x0f,0x28,0x12,0xec,0xc3,0x9a,0x81,0x81,0x81, - 0x81,0x81,0x81,0xa9,0xd1,0xf6,0x1b,0x16,0xff,0x1e,0xf5,0xe1,0xf5,0x14,0x1a,0xf5, - 0xcf,0xa9,0x81,0x81,0x81,0x81,0x96,0xbf,0xe9,0x12,0x20,0xfb,0xe0,0xe1,0xf7,0x14, - 0x16,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x96,0xbf,0xe9,0x12,0x20,0xfb,0xe0,0xe1, - 0xf7,0x14,0x16,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x96,0xbf,0xe9,0x12,0x20,0xfb, - 0xe0,0xe1,0xf7,0x14,0x16,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x96,0xbf,0xe9,0x12, - 0x20,0xfb,0xe0,0xe1,0xf7,0x14,0x16,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x81,0x81, - 0x87,0xae,0xd5,0xfc,0x24,0x06,0x1c,0x0d,0xe5,0xbd,0x96,0x81,0x81,0x81,0x81,0x95, - 0xc0,0xea,0x16,0x19,0xed,0xdf,0xda,0xe2,0xf6,0x15,0x17,0xf3,0xcd,0xa6,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x95,0xc0,0xea,0x12,0x2f,0x17,0xef,0xc5,0x9b,0x81,0x81,0x81, - 0x81,0x81,0x81,0x98,0xbd,0xe0,0xff,0x1d,0x23,0x14,0x06,0x0a,0x19,0x1c,0xff,0xdf, - 0xbc,0x97,0x81,0x81,0x81,0x81,0x8c,0xb4,0xdc,0xff,0x25,0x19,0x0a,0x0b,0x1a,0x0d, - 0x04,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x8c,0xb4,0xdc,0xff,0x25,0x19,0x0a,0x0b, - 0x1a,0x0d,0x04,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x8c,0xb4,0xdc,0xff,0x25,0x19, - 0x0a,0x0b,0x1a,0x0d,0x04,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x8c,0xb4,0xdc,0xff, - 0x25,0x19,0x0a,0x0b,0x1a,0x0d,0x04,0x23,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x81,0x81, - 0x81,0x9e,0xc6,0xed,0x14,0x24,0x25,0xfc,0xd6,0xaf,0x87,0x81,0x81,0x81,0x81,0x95, - 0xc0,0xea,0x16,0x25,0x13,0x09,0x06,0x0b,0x1a,0x18,0xfb,0xdb,0xb9,0x94,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x8c,0xb3,0xd9,0xf6,0x06,0xfa,0xdd,0xb8,0x91,0x81,0x81,0x81, - 0x81,0x81,0x81,0x83,0xa5,0xc5,0xe2,0xfa,0x1b,0x16,0x19,0x14,0x0a,0xf7,0xe0,0xc3, - 0xa4,0x81,0x81,0x81,0x81,0x81,0x81,0xa3,0xc8,0xe8,0x04,0x13,0x19,0x13,0x04,0xec, - 0x04,0x0e,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x81,0xa3,0xc8,0xe8,0x04,0x13,0x19,0x13, - 0x04,0xec,0x04,0x0e,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x81,0xa3,0xc8,0xe8,0x04,0x13, - 0x19,0x13,0x04,0xec,0x04,0x0e,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x81,0xa3,0xc8,0xe8, - 0x04,0x13,0x19,0x13,0x05,0xec,0x04,0x0e,0xf7,0xcd,0xa3,0x81,0x81,0x81,0x81,0x81, - 0x81,0x8f,0xb6,0xdd,0x05,0x2c,0x15,0xee,0xc7,0x9f,0x81,0x81,0x81,0x81,0x81,0x95, - 0xc0,0xea,0x16,0x1b,0x0e,0x14,0x16,0x11,0x06,0xf4,0xdc,0xbf,0xa0,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x9d,0xbb,0xd2,0xda,0xd4,0xbf,0xa1,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x89,0xaf,0xd6,0xff,0x1d,0xf5,0xed,0xea,0xe1,0xd3,0xbe,0xa5, - 0x87,0x81,0x81,0x81,0x81,0x81,0x81,0x8c,0xac,0xc8,0xdd,0xea,0xed,0xea,0xde,0xcd, - 0xe2,0xe2,0xe1,0xc5,0x9e,0x81,0x81,0x81,0x81,0x8c,0xac,0xc8,0xdd,0xea,0xed,0xea, - 0xde,0xcd,0xe2,0xe2,0xe1,0xc5,0x9e,0x81,0x81,0x81,0x81,0x8c,0xac,0xc8,0xdd,0xea, - 0xed,0xea,0xde,0xcd,0xe2,0xe2,0xe1,0xc5,0x9e,0x81,0x81,0x81,0x81,0x8c,0xac,0xc8, - 0xdd,0xea,0xed,0xea,0xde,0xcd,0xe2,0xe2,0xe1,0xc5,0x9e,0x81,0x81,0x81,0x8d,0x9a, - 0x9a,0xa1,0xc2,0xe5,0x0b,0x28,0x04,0xdc,0xb6,0x90,0x81,0x81,0x81,0x81,0x81,0x95, - 0xc0,0xea,0x16,0x19,0xed,0xea,0xea,0xe7,0xde,0xce,0xba,0xa1,0x83,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x99,0xaa,0xb0,0xab,0x9b,0x83,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x94,0xbc,0xe4,0x0c,0x0f,0xe7,0xc2,0xc0,0xb9,0xac,0x9a,0x83, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8d,0xa5,0xb6,0xc0,0xc2,0xc0,0xb6,0xad, - 0xb8,0xb8,0xb7,0xa7,0x8a,0x81,0x81,0x81,0x81,0x81,0x8d,0xa5,0xb6,0xc0,0xc2,0xc0, - 0xb6,0xad,0xb8,0xb8,0xb7,0xa7,0x8a,0x81,0x81,0x81,0x81,0x81,0x8d,0xa5,0xb6,0xc0, - 0xc2,0xc0,0xb6,0xad,0xb8,0xb8,0xb7,0xa7,0x8a,0x81,0x81,0x81,0x81,0x81,0x8d,0xa5, - 0xb6,0xc0,0xc2,0xc0,0xb7,0xad,0xb8,0xb8,0xb7,0xa7,0x8a,0x81,0x81,0x8f,0xb0,0xc4, - 0xc4,0xc6,0xdd,0xfc,0x20,0x14,0xef,0xcb,0xa5,0x81,0x81,0x81,0x81,0x81,0x81,0x95, - 0xc0,0xea,0x16,0x19,0xed,0xc2,0xc0,0xbd,0xb5,0xa8,0x95,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x85,0x82,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x98,0xc2,0xec,0xfa,0xfa,0xda,0xb2,0x97,0x90,0x84,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0x96,0x98,0x97,0x8e,0x86, - 0x8d,0x8d,0x8d,0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0x96,0x98,0x97, - 0x8e,0x86,0x8d,0x8d,0x8d,0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8e,0x96, - 0x98,0x97,0x8e,0x86,0x8d,0x8d,0x8d,0x82,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x8e,0x96,0x98,0x97,0x8e,0x86,0x8d,0x8d,0x8d,0x82,0x81,0x81,0x81,0x9e,0xc8,0xec, - 0xed,0xef,0xff,0x1a,0x1d,0xfb,0xd9,0xb5,0x91,0x81,0x81,0x81,0x81,0x81,0x81,0x95, - 0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0x93,0x8c,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x8d,0xb1,0xcc,0xd0,0xd0,0xc2,0xa2,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa0,0xca,0xf5, - 0x19,0x19,0x24,0x18,0xff,0xe1,0xc1,0x9e,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95, - 0xc0,0xea,0x16,0x19,0xed,0xc2,0x98,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x92,0xa3,0xa5,0xa5,0x9d,0x87,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0xa0,0xca,0xf5, - 0x0b,0x09,0x04,0xf3,0xdd,0xc3,0xa5,0x85,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x95, - 0xc0,0xea,0x09,0x09,0xed,0xc2,0x98,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x9a,0xc0,0xdc, - 0xdf,0xdf,0xd9,0xcc,0xba,0xa2,0x87,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x90, - 0xb6,0xd6,0xdd,0xdd,0xd8,0xb9,0x92,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x84,0xa2,0xb4, - 0xb5,0xb5,0xaf,0xa4,0x94,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x9b,0xaf,0xb2,0xb2,0xb0,0x9d,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x8a, - 0x8b,0x8b,0x86,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x86,0x88,0x88,0x86,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81, - 0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81 -}; diff --git a/xess/samples/xess_demo/MiniEngine/Core/GameCore.cpp b/xess/samples/xess_demo/MiniEngine/Core/GameCore.cpp deleted file mode 100644 index 829ba5f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/GameCore.cpp +++ /dev/null @@ -1,232 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -// Modified 2022, Intel Corporation. -// Supported DPI awareness, fullscreen toggle and ImGui message forward. - -#include "pch.h" -#include "GameCore.h" -#include "GraphicsCore.h" -#include "SystemTime.h" -#include "GameInput.h" -#include "BufferManager.h" -#include "CommandContext.h" -#include "PostEffects.h" -#include "Display.h" -#include "Util/CommandLineArg.h" -#include "ImGuiModule.h" -#include -#include -#include - -#pragma comment(lib, "runtimeobject.lib") - -namespace GameCore -{ - using namespace Graphics; - - bool gQuit = false; - bool gIsSupending = false; - - void InitializeApplication( IGameApp& game ) - { - int argc = 0; - LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc); - CommandLineArgs::Initialize(argc, argv); - - Graphics::Initialize(); - SystemTime::Initialize(); - GameInput::Initialize(); - EngineTuning::Initialize(); - - game.Startup(); - } - - void TerminateApplication( IGameApp& game ) - { - g_CommandManager.IdleGPU(); - - game.Cleanup(); - - GameInput::Shutdown(); - } - - bool UpdateApplication( IGameApp& game ) - { - EngineProfiling::Update(); - - float DeltaTime = Graphics::GetFrameTime(); - - GameInput::Update(DeltaTime); - EngineTuning::Update(DeltaTime); - - game.Update(DeltaTime); - game.RenderScene(); - - PostEffects::Render(); - GraphicsContext& UiContext = GraphicsContext::Begin(L"Render UI"); - UiContext.TransitionResource(g_OverlayBuffer, D3D12_RESOURCE_STATE_RENDER_TARGET, true); - UiContext.ClearColor(g_OverlayBuffer); - UiContext.SetRenderTarget(g_OverlayBuffer.GetRTV()); - UiContext.SetViewportAndScissor(0, 0, g_OverlayBuffer.GetWidth(), g_OverlayBuffer.GetHeight()); - game.RenderUI(UiContext); - - UiContext.SetRenderTarget(g_OverlayBuffer.GetRTV()); - UiContext.SetViewportAndScissor(0, 0, g_OverlayBuffer.GetWidth(), g_OverlayBuffer.GetHeight()); - EngineTuning::Display( UiContext, 10.0f, 40.0f, (float)g_DisplayWidth, (float)g_DisplayHeight); - - UiContext.Finish(); - - Display::Present(); - - return !game.IsDone(); - } - - // Default implementation to be overridden by the application - bool IGameApp::IsDone( void ) - { - return GameInput::IsFirstPressed(GameInput::kKey_escape); - } - - HWND g_hWnd = nullptr; - - LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM ); - - void SetDPIAwareness() - { - // https://docs.microsoft.com/en-us/windows/win32/hidpi/setting-the-default-dpi-awareness-for-a-process - // https://docs.microsoft.com/en-us/windows/win32/hidpi/dpi-awareness-context - - OSVERSIONINFOEX osvi = { sizeof(osvi), 10, 0, 15063, 0, {0}, 0, 0 }; - DWORDLONG const dwlConditionMask = VerSetConditionMask( - VerSetConditionMask( - VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL), - VER_MINORVERSION, VER_GREATER_EQUAL), - VER_BUILDNUMBER, VER_GREATER_EQUAL); - - BOOL ret = VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_BUILDNUMBER, dwlConditionMask); - if (ret) // Creators Update of Windows 10 or later - { - SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); - } - else if (IsWindows8Point1OrGreater()) - { - SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE); - } - else - { - SetProcessDPIAware(); - } - } - - int RunApplication(IGameApp& app, const wchar_t* className, HINSTANCE hInst, int nCmdShow) - { - if (!XMVerifyCPUSupport()) - return 1; - - Microsoft::WRL::Wrappers::RoInitializeWrapper InitializeWinRT(RO_INIT_MULTITHREADED); - ASSERT_SUCCEEDED(InitializeWinRT); - - // Make our application DPI aware - SetDPIAwareness(); - - // Register class - WNDCLASSEX wcex; - wcex.cbSize = sizeof(WNDCLASSEX); - wcex.style = CS_HREDRAW | CS_VREDRAW; - wcex.lpfnWndProc = WndProc; - wcex.cbClsExtra = 0; - wcex.cbWndExtra = 0; - wcex.hInstance = hInst; - wcex.hIcon = LoadIcon(hInst, IDI_APPLICATION); - wcex.hCursor = LoadCursor(nullptr, IDC_ARROW); - wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); - wcex.lpszMenuName = nullptr; - wcex.lpszClassName = className; - wcex.hIconSm = LoadIcon(hInst, IDI_APPLICATION); - ASSERT(0 != RegisterClassEx(&wcex), "Unable to register a window"); - - // Create window - RECT rc = { 0, 0, (LONG)g_DisplayWidth, (LONG)g_DisplayHeight }; - AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, FALSE); - - g_hWnd = CreateWindow(className, className, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, - rc.right - rc.left, rc.bottom - rc.top, nullptr, nullptr, hInst, nullptr); - - ASSERT(g_hWnd != 0); - - InitializeApplication(app); - - ShowWindow( g_hWnd, nCmdShow/*SW_SHOWDEFAULT*/ ); - - do - { - MSG msg = {}; - while (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - if (msg.message == WM_QUIT) - gQuit = true; - } - - if (gQuit) - break; - } - while (UpdateApplication(app)); // Returns false to quit loop - - TerminateApplication(app); - Graphics::Shutdown(); - return 0; - } - - //-------------------------------------------------------------------------------------- - // Called every time the application receives a message - //-------------------------------------------------------------------------------------- - LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) - { - // ImGuiModule handles windows messages first. - if (ImGuiModule::WinProcHandler(hWnd, message, wParam, lParam)) - return 0; - - switch( message ) - { - case WM_DPICHANGED: - { - Display::UpdateDPIScale(); - break; - } - // Subclass of IGameApp will handle the size change. - //case WM_SIZE: - // Display::Resize((UINT)(UINT64)lParam & 0xFFFF, (UINT)(UINT64)lParam >> 16); - // break; - case WM_SYSKEYDOWN: - // Handle ALT+ENTER: - if ((wParam == VK_RETURN) && (lParam & (1 << 29))) - { - bool fullscreen = Display::IsFullscreen(); - Display::SetFullscreen(!fullscreen); - } - // Send all other WM_SYSKEYDOWN messages to the default WndProc. - break; - case WM_DESTROY: - PostQuitMessage(0); - break; - - default: - return DefWindowProc( hWnd, message, wParam, lParam ); - } - - return 0; - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/GameCore.h b/xess/samples/xess_demo/MiniEngine/Core/GameCore.h deleted file mode 100644 index 2387c92..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/GameCore.h +++ /dev/null @@ -1,55 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "pch.h" - -namespace GameCore -{ - extern bool gIsSupending; - - class IGameApp - { - public: - // This function can be used to initialize application state and will run after essential - // hardware resources are allocated. Some state that does not depend on these resources - // should still be initialized in the constructor such as pointers and flags. - virtual void Startup( void ) = 0; - virtual void Cleanup( void ) = 0; - - // Decide if you want the app to exit. By default, app continues until the 'ESC' key is pressed. - virtual bool IsDone( void ); - - // The update method will be invoked once per frame. Both state updating and scene - // rendering should be handled by this method. - virtual void Update( float deltaT ) = 0; - - // Official rendering pass - virtual void RenderScene( void ) = 0; - - // Optional UI (overlay) rendering pass. This is LDR. The buffer is already cleared. - virtual void RenderUI( class GraphicsContext& ) {}; - }; -} - -namespace GameCore -{ - int RunApplication( IGameApp& app, const wchar_t* className, HINSTANCE hInst, int nCmdShow ); -} - -#define CREATE_APPLICATION( app_class ) \ - int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE /*hPrevInstance*/, _In_ LPWSTR /*lpCmdLine*/, _In_ int nCmdShow) \ - { \ - return GameCore::RunApplication( app_class(), L#app_class, hInstance, nCmdShow ); \ - } diff --git a/xess/samples/xess_demo/MiniEngine/Core/GameInput.cpp b/xess/samples/xess_demo/MiniEngine/Core/GameInput.cpp deleted file mode 100644 index 2eeee9b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/GameInput.cpp +++ /dev/null @@ -1,593 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -// Modified 2022, Intel Corporation. -// Added g_bMouseExclusive variable to control if exclusive mode should be used for mouse input. - -#include "pch.h" -#include "GameCore.h" -#include "GameInput.h" - -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) - -#define USE_XINPUT -#include -#pragma comment(lib, "xinput9_1_0.lib") - -#define USE_KEYBOARD_MOUSE -#define DIRECTINPUT_VERSION 0x0800 -#include -#pragma comment(lib, "dinput8.lib") -#pragma comment(lib, "dxguid.lib") - -namespace GameCore -{ - extern HWND g_hWnd; -} - -#else - -using namespace Windows::Gaming::Input; -using namespace Windows::Foundation::Collections; - -#define USE_KEYBOARD_MOUSE - -struct DIMOUSESTATE2 -{ - LONG lX, lY, lZ; - BYTE rgbButtons[8]; -}; - -#endif - -namespace -{ - bool s_Buttons[2][GameInput::kNumDigitalInputs]; - float s_HoldDuration[GameInput::kNumDigitalInputs] = { 0.0f }; - float s_Analogs[GameInput::kNumAnalogInputs]; - float s_AnalogsTC[GameInput::kNumAnalogInputs]; - -#ifdef USE_KEYBOARD_MOUSE - -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) - IDirectInput8A* s_DI; - IDirectInputDevice8A* s_Keyboard; - IDirectInputDevice8A* s_Mouse; -#endif - - DIMOUSESTATE2 s_MouseState; - unsigned char s_Keybuffer[256]; - unsigned char s_DXKeyMapping[GameInput::kNumKeys]; // map DigitalInput enum to DX key codes - -#endif - -#ifdef USE_XINPUT - float FilterAnalogInput( int val, int deadZone ) - { - if (val < 0) - { - if (val > -deadZone) - return 0.0f; - else - return (val + deadZone) / (32768.0f - deadZone); - } - else - { - if (val < deadZone) - return 0.0f; - else - return (val - deadZone) / (32767.0f - deadZone); - } - } -#else - float FilterAnalogInput( float val, float deadZone ) - { - if (val < -deadZone) - return (val + deadZone) / (1.0f - deadZone); - else if (val > deadZone) - return (val - deadZone) / (1.0f - deadZone); - else - return 0.0f; - } -#endif - -#ifdef USE_KEYBOARD_MOUSE - void KbmBuildKeyMapping() - { -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) - s_DXKeyMapping[GameInput::kKey_escape] = 1; - s_DXKeyMapping[GameInput::kKey_1] = 2; - s_DXKeyMapping[GameInput::kKey_2] = 3; - s_DXKeyMapping[GameInput::kKey_3] = 4; - s_DXKeyMapping[GameInput::kKey_4] = 5; - s_DXKeyMapping[GameInput::kKey_5] = 6; - s_DXKeyMapping[GameInput::kKey_6] = 7; - s_DXKeyMapping[GameInput::kKey_7] = 8; - s_DXKeyMapping[GameInput::kKey_8] = 9; - s_DXKeyMapping[GameInput::kKey_9] = 10; - s_DXKeyMapping[GameInput::kKey_0] = 11; - s_DXKeyMapping[GameInput::kKey_minus] = 12; - s_DXKeyMapping[GameInput::kKey_equals] = 13; - s_DXKeyMapping[GameInput::kKey_back] = 14; - s_DXKeyMapping[GameInput::kKey_tab] = 15; - s_DXKeyMapping[GameInput::kKey_q] = 16; - s_DXKeyMapping[GameInput::kKey_w] = 17; - s_DXKeyMapping[GameInput::kKey_e] = 18; - s_DXKeyMapping[GameInput::kKey_r] = 19; - s_DXKeyMapping[GameInput::kKey_t] = 20; - s_DXKeyMapping[GameInput::kKey_y] = 21; - s_DXKeyMapping[GameInput::kKey_u] = 22; - s_DXKeyMapping[GameInput::kKey_i] = 23; - s_DXKeyMapping[GameInput::kKey_o] = 24; - s_DXKeyMapping[GameInput::kKey_p] = 25; - s_DXKeyMapping[GameInput::kKey_lbracket] = 26; - s_DXKeyMapping[GameInput::kKey_rbracket] = 27; - s_DXKeyMapping[GameInput::kKey_return] = 28; - s_DXKeyMapping[GameInput::kKey_lcontrol] = 29; - s_DXKeyMapping[GameInput::kKey_a] = 30; - s_DXKeyMapping[GameInput::kKey_s] = 31; - s_DXKeyMapping[GameInput::kKey_d] = 32; - s_DXKeyMapping[GameInput::kKey_f] = 33; - s_DXKeyMapping[GameInput::kKey_g] = 34; - s_DXKeyMapping[GameInput::kKey_h] = 35; - s_DXKeyMapping[GameInput::kKey_j] = 36; - s_DXKeyMapping[GameInput::kKey_k] = 37; - s_DXKeyMapping[GameInput::kKey_l] = 38; - s_DXKeyMapping[GameInput::kKey_semicolon] = 39; - s_DXKeyMapping[GameInput::kKey_apostrophe] = 40; - s_DXKeyMapping[GameInput::kKey_grave] = 41; - s_DXKeyMapping[GameInput::kKey_lshift] = 42; - s_DXKeyMapping[GameInput::kKey_backslash] = 43; - s_DXKeyMapping[GameInput::kKey_z] = 44; - s_DXKeyMapping[GameInput::kKey_x] = 45; - s_DXKeyMapping[GameInput::kKey_c] = 46; - s_DXKeyMapping[GameInput::kKey_v] = 47; - s_DXKeyMapping[GameInput::kKey_b] = 48; - s_DXKeyMapping[GameInput::kKey_n] = 49; - s_DXKeyMapping[GameInput::kKey_m] = 50; - s_DXKeyMapping[GameInput::kKey_comma] = 51; - s_DXKeyMapping[GameInput::kKey_period] = 52; - s_DXKeyMapping[GameInput::kKey_slash] = 53; - s_DXKeyMapping[GameInput::kKey_rshift] = 54; - s_DXKeyMapping[GameInput::kKey_multiply] = 55; - s_DXKeyMapping[GameInput::kKey_lalt] = 56; - s_DXKeyMapping[GameInput::kKey_space] = 57; - s_DXKeyMapping[GameInput::kKey_capital] = 58; - s_DXKeyMapping[GameInput::kKey_f1] = 59; - s_DXKeyMapping[GameInput::kKey_f2] = 60; - s_DXKeyMapping[GameInput::kKey_f3] = 61; - s_DXKeyMapping[GameInput::kKey_f4] = 62; - s_DXKeyMapping[GameInput::kKey_f5] = 63; - s_DXKeyMapping[GameInput::kKey_f6] = 64; - s_DXKeyMapping[GameInput::kKey_f7] = 65; - s_DXKeyMapping[GameInput::kKey_f8] = 66; - s_DXKeyMapping[GameInput::kKey_f9] = 67; - s_DXKeyMapping[GameInput::kKey_f10] = 68; - s_DXKeyMapping[GameInput::kKey_numlock] = 69; - s_DXKeyMapping[GameInput::kKey_scroll] = 70; - s_DXKeyMapping[GameInput::kKey_numpad7] = 71; - s_DXKeyMapping[GameInput::kKey_numpad8] = 72; - s_DXKeyMapping[GameInput::kKey_numpad9] = 73; - s_DXKeyMapping[GameInput::kKey_subtract] = 74; - s_DXKeyMapping[GameInput::kKey_numpad4] = 75; - s_DXKeyMapping[GameInput::kKey_numpad5] = 76; - s_DXKeyMapping[GameInput::kKey_numpad6] = 77; - s_DXKeyMapping[GameInput::kKey_add] = 78; - s_DXKeyMapping[GameInput::kKey_numpad1] = 79; - s_DXKeyMapping[GameInput::kKey_numpad2] = 80; - s_DXKeyMapping[GameInput::kKey_numpad3] = 81; - s_DXKeyMapping[GameInput::kKey_numpad0] = 82; - s_DXKeyMapping[GameInput::kKey_decimal] = 83; - s_DXKeyMapping[GameInput::kKey_f11] = 87; - s_DXKeyMapping[GameInput::kKey_f12] = 88; - s_DXKeyMapping[GameInput::kKey_numpadenter] = 156; - s_DXKeyMapping[GameInput::kKey_rcontrol] = 157; - s_DXKeyMapping[GameInput::kKey_divide] = 181; - s_DXKeyMapping[GameInput::kKey_sysrq] = 183; - s_DXKeyMapping[GameInput::kKey_ralt] = 184; - s_DXKeyMapping[GameInput::kKey_pause] = 197; - s_DXKeyMapping[GameInput::kKey_home] = 199; - s_DXKeyMapping[GameInput::kKey_up] = 200; - s_DXKeyMapping[GameInput::kKey_pgup] = 201; - s_DXKeyMapping[GameInput::kKey_left] = 203; - s_DXKeyMapping[GameInput::kKey_right] = 205; - s_DXKeyMapping[GameInput::kKey_end] = 207; - s_DXKeyMapping[GameInput::kKey_down] = 208; - s_DXKeyMapping[GameInput::kKey_pgdn] = 209; - s_DXKeyMapping[GameInput::kKey_insert] = 210; - s_DXKeyMapping[GameInput::kKey_delete] = 211; - s_DXKeyMapping[GameInput::kKey_lwin] = 219; - s_DXKeyMapping[GameInput::kKey_rwin] = 220; - s_DXKeyMapping[GameInput::kKey_apps] = 221; -#else -#define WinRTKey(name) (unsigned char)Windows::System::VirtualKey::name - s_DXKeyMapping[GameInput::kKey_escape] = WinRTKey(Escape); - s_DXKeyMapping[GameInput::kKey_1] = WinRTKey(Number1); - s_DXKeyMapping[GameInput::kKey_2] = WinRTKey(Number2); - s_DXKeyMapping[GameInput::kKey_3] = WinRTKey(Number3); - s_DXKeyMapping[GameInput::kKey_4] = WinRTKey(Number4); - s_DXKeyMapping[GameInput::kKey_5] = WinRTKey(Number5); - s_DXKeyMapping[GameInput::kKey_6] = WinRTKey(Number6); - s_DXKeyMapping[GameInput::kKey_7] = WinRTKey(Number7); - s_DXKeyMapping[GameInput::kKey_8] = WinRTKey(Number8); - s_DXKeyMapping[GameInput::kKey_9] = WinRTKey(Number9); - s_DXKeyMapping[GameInput::kKey_0] = WinRTKey(Number0); - s_DXKeyMapping[GameInput::kKey_minus] = WinRTKey(Subtract); - s_DXKeyMapping[GameInput::kKey_equals] = WinRTKey(Add); - s_DXKeyMapping[GameInput::kKey_back] = WinRTKey(Back); - s_DXKeyMapping[GameInput::kKey_tab] = WinRTKey(Tab); - s_DXKeyMapping[GameInput::kKey_q] = WinRTKey(Q); - s_DXKeyMapping[GameInput::kKey_w] = WinRTKey(W); - s_DXKeyMapping[GameInput::kKey_e] = WinRTKey(E); - s_DXKeyMapping[GameInput::kKey_r] = WinRTKey(R); - s_DXKeyMapping[GameInput::kKey_t] = WinRTKey(T); - s_DXKeyMapping[GameInput::kKey_y] = WinRTKey(Y); - s_DXKeyMapping[GameInput::kKey_u] = WinRTKey(U); - s_DXKeyMapping[GameInput::kKey_i] = WinRTKey(I); - s_DXKeyMapping[GameInput::kKey_o] = WinRTKey(O); - s_DXKeyMapping[GameInput::kKey_p] = WinRTKey(P); - s_DXKeyMapping[GameInput::kKey_lbracket] = 219; - s_DXKeyMapping[GameInput::kKey_rbracket] = 221; - s_DXKeyMapping[GameInput::kKey_return] = WinRTKey(Enter); - s_DXKeyMapping[GameInput::kKey_lcontrol] = WinRTKey(Control); // No L/R - s_DXKeyMapping[GameInput::kKey_a] = WinRTKey(A); - s_DXKeyMapping[GameInput::kKey_s] = WinRTKey(S); - s_DXKeyMapping[GameInput::kKey_d] = WinRTKey(D); - s_DXKeyMapping[GameInput::kKey_f] = WinRTKey(F); - s_DXKeyMapping[GameInput::kKey_g] = WinRTKey(G); - s_DXKeyMapping[GameInput::kKey_h] = WinRTKey(H); - s_DXKeyMapping[GameInput::kKey_j] = WinRTKey(J); - s_DXKeyMapping[GameInput::kKey_k] = WinRTKey(K); - s_DXKeyMapping[GameInput::kKey_l] = WinRTKey(L); - s_DXKeyMapping[GameInput::kKey_semicolon] = 186; - s_DXKeyMapping[GameInput::kKey_apostrophe] = 222; - s_DXKeyMapping[GameInput::kKey_grave] = 192; // ` or ~ - s_DXKeyMapping[GameInput::kKey_lshift] = WinRTKey(LeftShift); - s_DXKeyMapping[GameInput::kKey_backslash] = 220; - s_DXKeyMapping[GameInput::kKey_z] = WinRTKey(Z); - s_DXKeyMapping[GameInput::kKey_x] = WinRTKey(X); - s_DXKeyMapping[GameInput::kKey_c] = WinRTKey(C); - s_DXKeyMapping[GameInput::kKey_v] = WinRTKey(V); - s_DXKeyMapping[GameInput::kKey_b] = WinRTKey(B); - s_DXKeyMapping[GameInput::kKey_n] = WinRTKey(N); - s_DXKeyMapping[GameInput::kKey_m] = WinRTKey(M); - s_DXKeyMapping[GameInput::kKey_comma] = 188; - s_DXKeyMapping[GameInput::kKey_period] = 190; - s_DXKeyMapping[GameInput::kKey_slash] = 191; - s_DXKeyMapping[GameInput::kKey_rshift] = WinRTKey(RightShift); - s_DXKeyMapping[GameInput::kKey_multiply] = WinRTKey(Multiply); - s_DXKeyMapping[GameInput::kKey_lalt] = 255; // Only a modifier - s_DXKeyMapping[GameInput::kKey_space] = WinRTKey(Space); - s_DXKeyMapping[GameInput::kKey_capital] = WinRTKey(CapitalLock); - s_DXKeyMapping[GameInput::kKey_f1] = WinRTKey(F1); - s_DXKeyMapping[GameInput::kKey_f2] = WinRTKey(F2); - s_DXKeyMapping[GameInput::kKey_f3] = WinRTKey(F3); - s_DXKeyMapping[GameInput::kKey_f4] = WinRTKey(F4); - s_DXKeyMapping[GameInput::kKey_f5] = WinRTKey(F5); - s_DXKeyMapping[GameInput::kKey_f6] = WinRTKey(F6); - s_DXKeyMapping[GameInput::kKey_f7] = WinRTKey(F7); - s_DXKeyMapping[GameInput::kKey_f8] = WinRTKey(F8); - s_DXKeyMapping[GameInput::kKey_f9] = WinRTKey(F9); - s_DXKeyMapping[GameInput::kKey_f10] = WinRTKey(F10); - s_DXKeyMapping[GameInput::kKey_numlock] = WinRTKey(NumberKeyLock); - s_DXKeyMapping[GameInput::kKey_scroll] = WinRTKey(Scroll); - s_DXKeyMapping[GameInput::kKey_numpad7] = WinRTKey(NumberPad7); - s_DXKeyMapping[GameInput::kKey_numpad8] = WinRTKey(NumberPad8); - s_DXKeyMapping[GameInput::kKey_numpad9] = WinRTKey(NumberPad9); - s_DXKeyMapping[GameInput::kKey_subtract] = WinRTKey(Subtract); - s_DXKeyMapping[GameInput::kKey_numpad4] = WinRTKey(NumberPad4); - s_DXKeyMapping[GameInput::kKey_numpad5] = WinRTKey(NumberPad5); - s_DXKeyMapping[GameInput::kKey_numpad6] = WinRTKey(NumberPad6); - s_DXKeyMapping[GameInput::kKey_add] = WinRTKey(Add); - s_DXKeyMapping[GameInput::kKey_numpad1] = WinRTKey(NumberPad1); - s_DXKeyMapping[GameInput::kKey_numpad2] = WinRTKey(NumberPad2); - s_DXKeyMapping[GameInput::kKey_numpad3] = WinRTKey(NumberPad3); - s_DXKeyMapping[GameInput::kKey_numpad0] = WinRTKey(NumberPad0); - s_DXKeyMapping[GameInput::kKey_decimal] = WinRTKey(Decimal); - s_DXKeyMapping[GameInput::kKey_f11] = WinRTKey(F11); - s_DXKeyMapping[GameInput::kKey_f12] = WinRTKey(F12); - s_DXKeyMapping[GameInput::kKey_numpadenter] = WinRTKey(Enter); // No distinction - s_DXKeyMapping[GameInput::kKey_rcontrol] = WinRTKey(Control); // No L/R - s_DXKeyMapping[GameInput::kKey_divide] = WinRTKey(Divide); - s_DXKeyMapping[GameInput::kKey_sysrq] = 255; // Ignored - s_DXKeyMapping[GameInput::kKey_ralt] = 255; // Only a modifier - s_DXKeyMapping[GameInput::kKey_pause] = WinRTKey(Pause); - s_DXKeyMapping[GameInput::kKey_home] = WinRTKey(Home); - s_DXKeyMapping[GameInput::kKey_up] = WinRTKey(Up); - s_DXKeyMapping[GameInput::kKey_pgup] = WinRTKey(PageUp); - s_DXKeyMapping[GameInput::kKey_left] = WinRTKey(Left); - s_DXKeyMapping[GameInput::kKey_right] = WinRTKey(Right); - s_DXKeyMapping[GameInput::kKey_end] = WinRTKey(End); - s_DXKeyMapping[GameInput::kKey_down] = WinRTKey(Down); - s_DXKeyMapping[GameInput::kKey_pgdn] = WinRTKey(PageDown); - s_DXKeyMapping[GameInput::kKey_insert] = WinRTKey(Insert); - s_DXKeyMapping[GameInput::kKey_delete] = WinRTKey(Delete); - s_DXKeyMapping[GameInput::kKey_lwin] = WinRTKey(LeftWindows); - s_DXKeyMapping[GameInput::kKey_rwin] = WinRTKey(RightWindows); - s_DXKeyMapping[GameInput::kKey_apps] = WinRTKey(Application); -#endif - } - - void KbmZeroInputs() - { - memset(&s_MouseState, 0, sizeof(DIMOUSESTATE2)); - memset(s_Keybuffer, 0, sizeof(s_Keybuffer)); - } - - void KbmInitialize() - { - KbmBuildKeyMapping(); - -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) - if (FAILED(DirectInput8Create(GetModuleHandle(nullptr), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&s_DI, nullptr))) - ASSERT(false, "DirectInput8 initialization failed."); - - if (FAILED(s_DI->CreateDevice(GUID_SysKeyboard, &s_Keyboard, nullptr))) - ASSERT(false, "Keyboard CreateDevice failed."); - if (FAILED(s_Keyboard->SetDataFormat(&c_dfDIKeyboard))) - ASSERT(false, "Keyboard SetDataFormat failed."); - if (FAILED(s_Keyboard->SetCooperativeLevel(GameCore::g_hWnd, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE))) - ASSERT(false, "Keyboard SetCooperativeLevel failed."); - - DIPROPDWORD dipdw; - dipdw.diph.dwSize = sizeof(DIPROPDWORD); - dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); - dipdw.diph.dwObj = 0; - dipdw.diph.dwHow = DIPH_DEVICE; - dipdw.dwData = 10; - if (FAILED(s_Keyboard->SetProperty(DIPROP_BUFFERSIZE, &dipdw.diph))) - ASSERT(false, "Keyboard set buffer size failed."); - - if (FAILED(s_DI->CreateDevice(GUID_SysMouse, &s_Mouse, nullptr))) - ASSERT(false, "Mouse CreateDevice failed."); - if (FAILED(s_Mouse->SetDataFormat(&c_dfDIMouse2))) - ASSERT(false, "Mouse SetDataFormat failed."); - - if (GameInput::g_bMouseExclusive) - { - if (FAILED(s_Mouse->SetCooperativeLevel(GameCore::g_hWnd, DISCL_FOREGROUND | DISCL_EXCLUSIVE))) - ASSERT(false, "Mouse SetCooperativeLevel failed."); - } - else - { - if (FAILED(s_Mouse->SetCooperativeLevel(GameCore::g_hWnd, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE))) - ASSERT(false, "Mouse SetCooperativeLevel failed."); - } -#endif - - KbmZeroInputs(); - } - - void KbmShutdown() - { -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) - if (s_Keyboard) - { - s_Keyboard->Unacquire(); - s_Keyboard->Release(); - s_Keyboard = nullptr; - } - if (s_Mouse) - { - s_Mouse->Unacquire(); - s_Mouse->Release(); - s_Mouse = nullptr; - } - if (s_DI) - { - s_DI->Release(); - s_DI = nullptr; - } -#endif - } - - void KbmUpdate() - { -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) - HWND foreground = GetForegroundWindow(); - bool visible = IsWindowVisible(foreground) != 0; - - if (foreground != GameCore::g_hWnd // wouldn't be able to acquire - || !visible) - { - KbmZeroInputs(); - } - else - { - s_Mouse->Acquire(); - s_Mouse->GetDeviceState(sizeof(DIMOUSESTATE2), &s_MouseState); - s_Keyboard->Acquire(); - s_Keyboard->GetDeviceState(sizeof(s_Keybuffer), s_Keybuffer); - } -#endif - } - -#endif - -} - -#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_TV_TITLE) -void GameInput::SetKeyState(Windows::System::VirtualKey key, bool IsDown) -{ - s_Keybuffer[(unsigned char)key] = IsDown ? 0x80 : 0x00; - //DEBUGPRINT("%d key is %s", (unsigned int)key, IsDown ? "down" : "up"); -} -#endif - -void GameInput::Initialize() -{ - // For Windows 8 - // XInputEnable(TRUE); - - ZeroMemory( s_Buttons, sizeof(s_Buttons) ); - ZeroMemory( s_Analogs, sizeof(s_Analogs) ); - -#ifdef USE_KEYBOARD_MOUSE - KbmInitialize(); -#endif -} - -void GameInput::Shutdown() -{ -#ifdef USE_KEYBOARD_MOUSE - KbmShutdown(); -#endif -} - -void GameInput::Update( float frameDelta ) -{ - memcpy(s_Buttons[1], s_Buttons[0], sizeof(s_Buttons[0])); - memset(s_Buttons[0], 0, sizeof(s_Buttons[0])); - memset(s_Analogs, 0, sizeof(s_Analogs)); - -#ifdef USE_XINPUT - XINPUT_STATE newInputState; - if (ERROR_SUCCESS == XInputGetState( 0, &newInputState )) - { - if (newInputState.Gamepad.wButtons & (1 << 0)) s_Buttons[0][kDPadUp] = true; - if (newInputState.Gamepad.wButtons & (1 << 1)) s_Buttons[0][kDPadDown] = true; - if (newInputState.Gamepad.wButtons & (1 << 2)) s_Buttons[0][kDPadLeft] = true; - if (newInputState.Gamepad.wButtons & (1 << 3)) s_Buttons[0][kDPadRight] = true; - if (newInputState.Gamepad.wButtons & (1 << 4)) s_Buttons[0][kStartButton] = true; - if (newInputState.Gamepad.wButtons & (1 << 5)) s_Buttons[0][kBackButton] = true; - if (newInputState.Gamepad.wButtons & (1 << 6)) s_Buttons[0][kLThumbClick] = true; - if (newInputState.Gamepad.wButtons & (1 << 7)) s_Buttons[0][kRThumbClick] = true; - if (newInputState.Gamepad.wButtons & (1 << 8)) s_Buttons[0][kLShoulder] = true; - if (newInputState.Gamepad.wButtons & (1 << 9)) s_Buttons[0][kRShoulder] = true; - if (newInputState.Gamepad.wButtons & (1 << 12)) s_Buttons[0][kAButton] = true; - if (newInputState.Gamepad.wButtons & (1 << 13)) s_Buttons[0][kBButton] = true; - if (newInputState.Gamepad.wButtons & (1 << 14)) s_Buttons[0][kXButton] = true; - if (newInputState.Gamepad.wButtons & (1 << 15)) s_Buttons[0][kYButton] = true; - - s_Analogs[ kAnalogLeftTrigger ] = newInputState.Gamepad.bLeftTrigger / 255.0f; - s_Analogs[ kAnalogRightTrigger ] = newInputState.Gamepad.bRightTrigger / 255.0f; - s_Analogs[ kAnalogLeftStickX ] = FilterAnalogInput(newInputState.Gamepad.sThumbLX, XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE ); - s_Analogs[ kAnalogLeftStickY ] = FilterAnalogInput(newInputState.Gamepad.sThumbLY, XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE ); - s_Analogs[ kAnalogRightStickX ] = FilterAnalogInput(newInputState.Gamepad.sThumbRX, XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE ); - s_Analogs[ kAnalogRightStickY ] = FilterAnalogInput(newInputState.Gamepad.sThumbRY, XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE ); - } -#else - - IVectorView^ gamepads = Gamepad::Gamepads; - if (gamepads->Size != 0) - { - IGamepad^ gamepad = gamepads->GetAt(0); - GamepadReading reading = gamepad->GetCurrentReading(); - uint32_t Buttons = (uint32_t)reading.Buttons; - if (Buttons & (uint32_t)GamepadButtons::DPadUp) s_Buttons[0][kDPadUp] = true; - if (Buttons & (uint32_t)GamepadButtons::DPadDown) s_Buttons[0][kDPadDown] = true; - if (Buttons & (uint32_t)GamepadButtons::DPadLeft) s_Buttons[0][kDPadLeft] = true; - if (Buttons & (uint32_t)GamepadButtons::DPadRight) s_Buttons[0][kDPadRight] = true; - if (Buttons & (uint32_t)GamepadButtons::Menu) s_Buttons[0][kStartButton] = true; - if (Buttons & (uint32_t)GamepadButtons::View) s_Buttons[0][kBackButton] = true; - if (Buttons & (uint32_t)GamepadButtons::LeftThumbstick) s_Buttons[0][kLThumbClick] = true; - if (Buttons & (uint32_t)GamepadButtons::RightThumbstick) s_Buttons[0][kRThumbClick] = true; - if (Buttons & (uint32_t)GamepadButtons::LeftShoulder) s_Buttons[0][kLShoulder] = true; - if (Buttons & (uint32_t)GamepadButtons::RightShoulder) s_Buttons[0][kRShoulder] = true; - if (Buttons & (uint32_t)GamepadButtons::A) s_Buttons[0][kAButton] = true; - if (Buttons & (uint32_t)GamepadButtons::B) s_Buttons[0][kBButton] = true; - if (Buttons & (uint32_t)GamepadButtons::X) s_Buttons[0][kXButton] = true; - if (Buttons & (uint32_t)GamepadButtons::Y) s_Buttons[0][kYButton] = true; - - static const float kAnalogStickDeadZone = 0.18f; - - s_Analogs[ kAnalogLeftTrigger ] = (float)reading.LeftTrigger; - s_Analogs[ kAnalogRightTrigger ] = (float)reading.RightTrigger; - s_Analogs[ kAnalogLeftStickX ] = FilterAnalogInput((float)reading.LeftThumbstickX, kAnalogStickDeadZone ); - s_Analogs[ kAnalogLeftStickY ] = FilterAnalogInput((float)reading.LeftThumbstickY, kAnalogStickDeadZone ); - s_Analogs[ kAnalogRightStickX ] = FilterAnalogInput((float)reading.RightThumbstickX, kAnalogStickDeadZone ); - s_Analogs[ kAnalogRightStickY ] = FilterAnalogInput((float)reading.RightThumbstickY, kAnalogStickDeadZone ); - } - -#endif - -#ifdef USE_KEYBOARD_MOUSE - KbmUpdate(); - - for (uint32_t i = 0; i < kNumKeys; ++i) - { - s_Buttons[0][i] = (s_Keybuffer[s_DXKeyMapping[i]] & 0x80) != 0; - } - - for (uint32_t i = 0; i < 8; ++i) - { - if (s_MouseState.rgbButtons[i] > 0) s_Buttons[0][kMouse0 + i] = true; - } - - s_Analogs[kAnalogMouseX] = (float)s_MouseState.lX * .0018f; - s_Analogs[kAnalogMouseY] = (float)s_MouseState.lY * -.0018f; - - if (s_MouseState.lZ > 0) - s_Analogs[kAnalogMouseScroll] = 1.0f; - else if (s_MouseState.lZ < 0) - s_Analogs[kAnalogMouseScroll] = -1.0f; -#endif - - // Update time duration for buttons pressed - for (uint32_t i = 0; i < kNumDigitalInputs; ++i) - { - if (s_Buttons[0][i]) - { - if (!s_Buttons[1][i]) - s_HoldDuration[i] = 0.0f; - else - s_HoldDuration[i] += frameDelta; - } - } - - for (uint32_t i = 0; i < kNumAnalogInputs; ++i) - { - s_AnalogsTC[i] = s_Analogs[i] * frameDelta; - } - -} - -bool GameInput::IsAnyPressed( void ) -{ - return s_Buttons[0] != 0; -} - -bool GameInput::IsPressed( DigitalInput di ) -{ - return s_Buttons[0][di]; -} - -bool GameInput::IsFirstPressed( DigitalInput di ) -{ - return s_Buttons[0][di] && !s_Buttons[1][di]; -} - -bool GameInput::IsReleased( DigitalInput di ) -{ - return !s_Buttons[0][di]; -} - -bool GameInput::IsFirstReleased( DigitalInput di ) -{ - return !s_Buttons[0][di] && s_Buttons[1][di]; -} - -float GameInput::GetDurationPressed( DigitalInput di ) -{ - return s_HoldDuration[di]; -} - -float GameInput::GetAnalogInput( AnalogInput ai ) -{ - return s_Analogs[ai]; -} - -float GameInput::GetTimeCorrectedAnalogInput( AnalogInput ai ) -{ - return s_AnalogsTC[ai]; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/GameInput.h b/xess/samples/xess_demo/MiniEngine/Core/GameInput.h deleted file mode 100644 index 4b51bd4..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/GameInput.h +++ /dev/null @@ -1,200 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -// Modified 2022, Intel Corporation. -// Added g_bMouseExclusive variable to control if exclusive mode should be used for mouse input. - -#pragma once - -namespace GameInput -{ - void Initialize(); - void Shutdown(); - void Update( float frameDelta ); - - enum DigitalInput - { - // keyboard - // kKey must start at zero, see s_DXKeyMapping - kKey_escape = 0, - kKey_1, - kKey_2, - kKey_3, - kKey_4, - kKey_5, - kKey_6, - kKey_7, - kKey_8, - kKey_9, - kKey_0, - kKey_minus, - kKey_equals, - kKey_back, - kKey_tab, - kKey_q, - kKey_w, - kKey_e, - kKey_r, - kKey_t, - kKey_y, - kKey_u, - kKey_i, - kKey_o, - kKey_p, - kKey_lbracket, - kKey_rbracket, - kKey_return, - kKey_lcontrol, - kKey_a, - kKey_s, - kKey_d, - kKey_f, - kKey_g, - kKey_h, - kKey_j, - kKey_k, - kKey_l, - kKey_semicolon, - kKey_apostrophe, - kKey_grave, - kKey_lshift, - kKey_backslash, - kKey_z, - kKey_x, - kKey_c, - kKey_v, - kKey_b, - kKey_n, - kKey_m, - kKey_comma, - kKey_period, - kKey_slash, - kKey_rshift, - kKey_multiply, - kKey_lalt, - kKey_space, - kKey_capital, - kKey_f1, - kKey_f2, - kKey_f3, - kKey_f4, - kKey_f5, - kKey_f6, - kKey_f7, - kKey_f8, - kKey_f9, - kKey_f10, - kKey_numlock, - kKey_scroll, - kKey_numpad7, - kKey_numpad8, - kKey_numpad9, - kKey_subtract, - kKey_numpad4, - kKey_numpad5, - kKey_numpad6, - kKey_add, - kKey_numpad1, - kKey_numpad2, - kKey_numpad3, - kKey_numpad0, - kKey_decimal, - kKey_f11, - kKey_f12, - kKey_numpadenter, - kKey_rcontrol, - kKey_divide, - kKey_sysrq, - kKey_ralt, - kKey_pause, - kKey_home, - kKey_up, - kKey_pgup, - kKey_left, - kKey_right, - kKey_end, - kKey_down, - kKey_pgdn, - kKey_insert, - kKey_delete, - kKey_lwin, - kKey_rwin, - kKey_apps, - - kNumKeys, - - // gamepad - kDPadUp = kNumKeys, - kDPadDown, - kDPadLeft, - kDPadRight, - kStartButton, - kBackButton, - kLThumbClick, - kRThumbClick, - kLShoulder, - kRShoulder, - kAButton, - kBButton, - kXButton, - kYButton, - - // mouse - kMouse0, - kMouse1, - kMouse2, - kMouse3, - kMouse4, - kMouse5, - kMouse6, - kMouse7, - - kNumDigitalInputs - }; - - enum AnalogInput - { - // gamepad - kAnalogLeftTrigger, - kAnalogRightTrigger, - kAnalogLeftStickX, - kAnalogLeftStickY, - kAnalogRightStickX, - kAnalogRightStickY, - - // mouse - kAnalogMouseX, - kAnalogMouseY, - kAnalogMouseScroll, - - kNumAnalogInputs - }; - - bool IsAnyPressed( void ); - - bool IsPressed( DigitalInput di ); - bool IsFirstPressed( DigitalInput di ); - bool IsReleased( DigitalInput di ); - bool IsFirstReleased( DigitalInput di ); - - float GetDurationPressed( DigitalInput di ); - - float GetAnalogInput( AnalogInput ai ); - float GetTimeCorrectedAnalogInput( AnalogInput ai ); - -#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_TV_TITLE | WINAPI_PARTITION_DESKTOP) - void SetKeyState(Windows::System::VirtualKey key, bool IsDown); -#endif - - extern bool g_bMouseExclusive; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/GpuBuffer.cpp b/xess/samples/xess_demo/MiniEngine/Core/GpuBuffer.cpp deleted file mode 100644 index 5212d23..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/GpuBuffer.cpp +++ /dev/null @@ -1,253 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "GpuBuffer.h" -#include "GraphicsCore.h" -#include "EsramAllocator.h" -#include "CommandContext.h" -#include "BufferManager.h" -#include "UploadBuffer.h" - -using namespace Graphics; - -void GpuBuffer::Create( const std::wstring& name, uint32_t NumElements, uint32_t ElementSize, const void* initialData ) -{ - Destroy(); - - m_ElementCount = NumElements; - m_ElementSize = ElementSize; - m_BufferSize = NumElements * ElementSize; - - D3D12_RESOURCE_DESC ResourceDesc = DescribeBuffer(); - - m_UsageState = D3D12_RESOURCE_STATE_COMMON; - - D3D12_HEAP_PROPERTIES HeapProps; - HeapProps.Type = D3D12_HEAP_TYPE_DEFAULT; - HeapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; - HeapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; - HeapProps.CreationNodeMask = 1; - HeapProps.VisibleNodeMask = 1; - - ASSERT_SUCCEEDED( g_Device->CreateCommittedResource( &HeapProps, D3D12_HEAP_FLAG_NONE, - &ResourceDesc, m_UsageState, nullptr, MY_IID_PPV_ARGS(&m_pResource)) ); - - m_GpuVirtualAddress = m_pResource->GetGPUVirtualAddress(); - - if (initialData) - CommandContext::InitializeBuffer(*this, initialData, m_BufferSize); - -#ifdef RELEASE - (name); -#else - m_pResource->SetName(name.c_str()); -#endif - - CreateDerivedViews(); -} - -void GpuBuffer::Create( const std::wstring& name, uint32_t NumElements, uint32_t ElementSize, const UploadBuffer& srcData, uint32_t srcOffset ) -{ - Destroy(); - - m_ElementCount = NumElements; - m_ElementSize = ElementSize; - m_BufferSize = NumElements * ElementSize; - - D3D12_RESOURCE_DESC ResourceDesc = DescribeBuffer(); - - m_UsageState = D3D12_RESOURCE_STATE_COMMON; - - D3D12_HEAP_PROPERTIES HeapProps; - HeapProps.Type = D3D12_HEAP_TYPE_DEFAULT; - HeapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; - HeapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; - HeapProps.CreationNodeMask = 1; - HeapProps.VisibleNodeMask = 1; - - ASSERT_SUCCEEDED( - g_Device->CreateCommittedResource( &HeapProps, D3D12_HEAP_FLAG_NONE, - &ResourceDesc, m_UsageState, nullptr, MY_IID_PPV_ARGS(&m_pResource)) ); - - m_GpuVirtualAddress = m_pResource->GetGPUVirtualAddress(); - - CommandContext::InitializeBuffer(*this, srcData, srcOffset); - -#ifdef RELEASE - (name); -#else - m_pResource->SetName(name.c_str()); -#endif - - CreateDerivedViews(); -} - -// Sub-Allocate a buffer out of a pre-allocated heap. If initial data is provided, it will be copied into the buffer using the default command context. -void GpuBuffer::CreatePlaced(const std::wstring& name, ID3D12Heap* pBackingHeap, uint32_t HeapOffset, uint32_t NumElements, uint32_t ElementSize, - const void* initialData) -{ - m_ElementCount = NumElements; - m_ElementSize = ElementSize; - m_BufferSize = NumElements * ElementSize; - - D3D12_RESOURCE_DESC ResourceDesc = DescribeBuffer(); - - m_UsageState = D3D12_RESOURCE_STATE_COMMON; - - ASSERT_SUCCEEDED(g_Device->CreatePlacedResource(pBackingHeap, HeapOffset, &ResourceDesc, m_UsageState, nullptr, MY_IID_PPV_ARGS(&m_pResource))); - - m_GpuVirtualAddress = m_pResource->GetGPUVirtualAddress(); - - if (initialData) - CommandContext::InitializeBuffer(*this, initialData, m_BufferSize); - -#ifdef RELEASE - (name); -#else - m_pResource->SetName(name.c_str()); -#endif - - CreateDerivedViews(); - -} - -void GpuBuffer::Create(const std::wstring& name, uint32_t NumElements, uint32_t ElementSize, EsramAllocator& Allocator, const void* initialData) -{ - (void)Allocator; - Create(name, NumElements, ElementSize, initialData); -} - -D3D12_CPU_DESCRIPTOR_HANDLE GpuBuffer::CreateConstantBufferView(uint32_t Offset, uint32_t Size) const -{ - ASSERT(Offset + Size <= m_BufferSize); - - Size = Math::AlignUp(Size, 16); - - D3D12_CONSTANT_BUFFER_VIEW_DESC CBVDesc; - CBVDesc.BufferLocation = m_GpuVirtualAddress + (size_t)Offset; - CBVDesc.SizeInBytes = Size; - - D3D12_CPU_DESCRIPTOR_HANDLE hCBV = AllocateDescriptor(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - g_Device->CreateConstantBufferView(&CBVDesc, hCBV); - return hCBV; -} - -D3D12_RESOURCE_DESC GpuBuffer::DescribeBuffer(void) -{ - ASSERT(m_BufferSize != 0); - - D3D12_RESOURCE_DESC Desc = {}; - Desc.Alignment = 0; - Desc.DepthOrArraySize = 1; - Desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; - Desc.Flags = m_ResourceFlags; - Desc.Format = DXGI_FORMAT_UNKNOWN; - Desc.Height = 1; - Desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; - Desc.MipLevels = 1; - Desc.SampleDesc.Count = 1; - Desc.SampleDesc.Quality = 0; - Desc.Width = (UINT64)m_BufferSize; - return Desc; -} - -void ByteAddressBuffer::CreateDerivedViews(void) -{ - D3D12_SHADER_RESOURCE_VIEW_DESC SRVDesc = {}; - SRVDesc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER; - SRVDesc.Format = DXGI_FORMAT_R32_TYPELESS; - SRVDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; - SRVDesc.Buffer.NumElements = (UINT)m_BufferSize / 4; - SRVDesc.Buffer.Flags = D3D12_BUFFER_SRV_FLAG_RAW; - - if (m_SRV.ptr == D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN) - m_SRV = AllocateDescriptor(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - g_Device->CreateShaderResourceView(m_pResource.Get(), &SRVDesc, m_SRV); - - D3D12_UNORDERED_ACCESS_VIEW_DESC UAVDesc = {}; - UAVDesc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER; - UAVDesc.Format = DXGI_FORMAT_R32_TYPELESS; - UAVDesc.Buffer.NumElements = (UINT)m_BufferSize / 4; - UAVDesc.Buffer.Flags = D3D12_BUFFER_UAV_FLAG_RAW; - - if (m_UAV.ptr == D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN) - m_UAV = AllocateDescriptor(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - g_Device->CreateUnorderedAccessView( m_pResource.Get(), nullptr, &UAVDesc, m_UAV ); -} - -void StructuredBuffer::CreateDerivedViews(void) -{ - D3D12_SHADER_RESOURCE_VIEW_DESC SRVDesc = {}; - SRVDesc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER; - SRVDesc.Format = DXGI_FORMAT_UNKNOWN; - SRVDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; - SRVDesc.Buffer.NumElements = m_ElementCount; - SRVDesc.Buffer.StructureByteStride = m_ElementSize; - SRVDesc.Buffer.Flags = D3D12_BUFFER_SRV_FLAG_NONE; - - if (m_SRV.ptr == D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN) - m_SRV = AllocateDescriptor(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - g_Device->CreateShaderResourceView(m_pResource.Get(), &SRVDesc, m_SRV); - - D3D12_UNORDERED_ACCESS_VIEW_DESC UAVDesc = {}; - UAVDesc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER; - UAVDesc.Format = DXGI_FORMAT_UNKNOWN; - UAVDesc.Buffer.CounterOffsetInBytes = 0; - UAVDesc.Buffer.NumElements = m_ElementCount; - UAVDesc.Buffer.StructureByteStride = m_ElementSize; - UAVDesc.Buffer.Flags = D3D12_BUFFER_UAV_FLAG_NONE; - - m_CounterBuffer.Create(L"StructuredBuffer::Counter", 1, 4); - - if (m_UAV.ptr == D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN) - m_UAV = AllocateDescriptor(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - g_Device->CreateUnorderedAccessView(m_pResource.Get(), m_CounterBuffer.GetResource(), &UAVDesc, m_UAV); -} - -void TypedBuffer::CreateDerivedViews(void) -{ - D3D12_SHADER_RESOURCE_VIEW_DESC SRVDesc = {}; - SRVDesc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER; - SRVDesc.Format = m_DataFormat; - SRVDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; - SRVDesc.Buffer.NumElements = m_ElementCount; - SRVDesc.Buffer.Flags = D3D12_BUFFER_SRV_FLAG_NONE; - - if (m_SRV.ptr == D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN) - m_SRV = AllocateDescriptor(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - g_Device->CreateShaderResourceView(m_pResource.Get(), &SRVDesc, m_SRV); - - D3D12_UNORDERED_ACCESS_VIEW_DESC UAVDesc = {}; - UAVDesc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER; - UAVDesc.Format = m_DataFormat; - UAVDesc.Buffer.NumElements = m_ElementCount; - UAVDesc.Buffer.Flags = D3D12_BUFFER_UAV_FLAG_NONE; - - if (m_UAV.ptr == D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN) - m_UAV = AllocateDescriptor(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - g_Device->CreateUnorderedAccessView(m_pResource.Get(), nullptr, &UAVDesc, m_UAV); -} - -const D3D12_CPU_DESCRIPTOR_HANDLE& StructuredBuffer::GetCounterSRV(CommandContext& Context) -{ - Context.TransitionResource(m_CounterBuffer, D3D12_RESOURCE_STATE_GENERIC_READ); - return m_CounterBuffer.GetSRV(); -} - -const D3D12_CPU_DESCRIPTOR_HANDLE& StructuredBuffer::GetCounterUAV(CommandContext& Context) -{ - Context.TransitionResource(m_CounterBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - return m_CounterBuffer.GetUAV(); -} - diff --git a/xess/samples/xess_demo/MiniEngine/Core/GpuBuffer.h b/xess/samples/xess_demo/MiniEngine/Core/GpuBuffer.h deleted file mode 100644 index c268f00..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/GpuBuffer.h +++ /dev/null @@ -1,150 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "pch.h" -#include "GpuResource.h" - -class CommandContext; -class EsramAllocator; -class UploadBuffer; - -class GpuBuffer : public GpuResource -{ -public: - virtual ~GpuBuffer() { Destroy(); } - - // Create a buffer. If initial data is provided, it will be copied into the buffer using the default command context. - void Create( const std::wstring& name, uint32_t NumElements, uint32_t ElementSize, - const void* initialData = nullptr ); - - void Create( const std::wstring& name, uint32_t NumElements, uint32_t ElementSize, - const UploadBuffer& srcData, uint32_t srcOffset = 0 ); - - // Create a buffer in ESRAM. On Windows, ESRAM is not used. - void Create( const std::wstring& name, uint32_t NumElements, uint32_t ElementSize, - EsramAllocator& Allocator, const void* initialData = nullptr); - - // Sub-Allocate a buffer out of a pre-allocated heap. If initial data is provided, it will be copied into the buffer using the default command context. - void CreatePlaced(const std::wstring& name, ID3D12Heap* pBackingHeap, uint32_t HeapOffset, uint32_t NumElements, uint32_t ElementSize, - const void* initialData = nullptr); - - const D3D12_CPU_DESCRIPTOR_HANDLE& GetUAV(void) const { return m_UAV; } - const D3D12_CPU_DESCRIPTOR_HANDLE& GetSRV(void) const { return m_SRV; } - - D3D12_GPU_VIRTUAL_ADDRESS RootConstantBufferView(void) const { return m_GpuVirtualAddress; } - - D3D12_CPU_DESCRIPTOR_HANDLE CreateConstantBufferView( uint32_t Offset, uint32_t Size ) const; - - D3D12_VERTEX_BUFFER_VIEW VertexBufferView(size_t Offset, uint32_t Size, uint32_t Stride) const; - D3D12_VERTEX_BUFFER_VIEW VertexBufferView(size_t BaseVertexIndex = 0) const - { - size_t Offset = BaseVertexIndex * m_ElementSize; - return VertexBufferView(Offset, (uint32_t)(m_BufferSize - Offset), m_ElementSize); - } - - D3D12_INDEX_BUFFER_VIEW IndexBufferView(size_t Offset, uint32_t Size, bool b32Bit = false) const; - D3D12_INDEX_BUFFER_VIEW IndexBufferView(size_t StartIndex = 0) const - { - size_t Offset = StartIndex * m_ElementSize; - return IndexBufferView(Offset, (uint32_t)(m_BufferSize - Offset), m_ElementSize == 4); - } - - size_t GetBufferSize() const { return m_BufferSize; } - uint32_t GetElementCount() const { return m_ElementCount; } - uint32_t GetElementSize() const { return m_ElementSize; } - -protected: - - GpuBuffer(void) : m_BufferSize(0), m_ElementCount(0), m_ElementSize(0) - { - m_ResourceFlags = D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; - m_UAV.ptr = D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN; - m_SRV.ptr = D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN; - } - - D3D12_RESOURCE_DESC DescribeBuffer(void); - virtual void CreateDerivedViews(void) = 0; - - D3D12_CPU_DESCRIPTOR_HANDLE m_UAV; - D3D12_CPU_DESCRIPTOR_HANDLE m_SRV; - - size_t m_BufferSize; - uint32_t m_ElementCount; - uint32_t m_ElementSize; - D3D12_RESOURCE_FLAGS m_ResourceFlags; -}; - -inline D3D12_VERTEX_BUFFER_VIEW GpuBuffer::VertexBufferView(size_t Offset, uint32_t Size, uint32_t Stride) const -{ - D3D12_VERTEX_BUFFER_VIEW VBView; - VBView.BufferLocation = m_GpuVirtualAddress + Offset; - VBView.SizeInBytes = Size; - VBView.StrideInBytes = Stride; - return VBView; -} - -inline D3D12_INDEX_BUFFER_VIEW GpuBuffer::IndexBufferView(size_t Offset, uint32_t Size, bool b32Bit) const -{ - D3D12_INDEX_BUFFER_VIEW IBView; - IBView.BufferLocation = m_GpuVirtualAddress + Offset; - IBView.Format = b32Bit ? DXGI_FORMAT_R32_UINT : DXGI_FORMAT_R16_UINT; - IBView.SizeInBytes = Size; - return IBView; -} - -class ByteAddressBuffer : public GpuBuffer -{ -public: - virtual void CreateDerivedViews(void) override; -}; - -class IndirectArgsBuffer : public ByteAddressBuffer -{ -public: - IndirectArgsBuffer(void) - { - } -}; - -class StructuredBuffer : public GpuBuffer -{ -public: - virtual void Destroy(void) override - { - m_CounterBuffer.Destroy(); - GpuBuffer::Destroy(); - } - - virtual void CreateDerivedViews(void) override; - - ByteAddressBuffer& GetCounterBuffer(void) { return m_CounterBuffer; } - - const D3D12_CPU_DESCRIPTOR_HANDLE& GetCounterSRV(CommandContext& Context); - const D3D12_CPU_DESCRIPTOR_HANDLE& GetCounterUAV(CommandContext& Context); - -private: - ByteAddressBuffer m_CounterBuffer; -}; - -class TypedBuffer : public GpuBuffer -{ -public: - TypedBuffer( DXGI_FORMAT Format ) : m_DataFormat(Format) {} - virtual void CreateDerivedViews(void) override; - -protected: - DXGI_FORMAT m_DataFormat; -}; - diff --git a/xess/samples/xess_demo/MiniEngine/Core/GpuResource.h b/xess/samples/xess_demo/MiniEngine/Core/GpuResource.h deleted file mode 100644 index 6991c3b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/GpuResource.h +++ /dev/null @@ -1,68 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -class GpuResource -{ - friend class CommandContext; - friend class GraphicsContext; - friend class ComputeContext; - -public: - GpuResource() : - m_GpuVirtualAddress(D3D12_GPU_VIRTUAL_ADDRESS_NULL), - m_UsageState(D3D12_RESOURCE_STATE_COMMON), - m_TransitioningState((D3D12_RESOURCE_STATES)-1) - { - } - - GpuResource(ID3D12Resource* pResource, D3D12_RESOURCE_STATES CurrentState) : - m_GpuVirtualAddress(D3D12_GPU_VIRTUAL_ADDRESS_NULL), - m_pResource(pResource), - m_UsageState(CurrentState), - m_TransitioningState((D3D12_RESOURCE_STATES)-1) - { - } - - ~GpuResource() { Destroy(); } - - virtual void Destroy() - { - m_pResource = nullptr; - m_GpuVirtualAddress = D3D12_GPU_VIRTUAL_ADDRESS_NULL; - ++m_VersionID; - } - - ID3D12Resource* operator->() { return m_pResource.Get(); } - const ID3D12Resource* operator->() const { return m_pResource.Get(); } - - ID3D12Resource* GetResource() { return m_pResource.Get(); } - const ID3D12Resource* GetResource() const { return m_pResource.Get(); } - - ID3D12Resource** GetAddressOf() { return m_pResource.GetAddressOf(); } - - D3D12_GPU_VIRTUAL_ADDRESS GetGpuVirtualAddress() const { return m_GpuVirtualAddress; } - - uint32_t GetVersionID() const { return m_VersionID; } - -protected: - - Microsoft::WRL::ComPtr m_pResource; - D3D12_RESOURCE_STATES m_UsageState; - D3D12_RESOURCE_STATES m_TransitioningState; - D3D12_GPU_VIRTUAL_ADDRESS m_GpuVirtualAddress; - - // Used to identify when a resource changes so descriptors can be copied etc. - uint32_t m_VersionID = 0; -}; diff --git a/xess/samples/xess_demo/MiniEngine/Core/GpuTimeManager.cpp b/xess/samples/xess_demo/MiniEngine/Core/GpuTimeManager.cpp deleted file mode 100644 index 24326f1..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/GpuTimeManager.cpp +++ /dev/null @@ -1,184 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "GpuTimeManager.h" -#include "GraphicsCore.h" -#include "CommandContext.h" -#include "CommandListManager.h" - -/* - Resolving incomplete or uninitialized queries is undefined behavior because the driver might internally store GPUVAs or other data within unresolved queries. - And so attempting to resolve these queries on uninitialized data could cause a page fault or device hang. - Older versions of the debug layer didn't validate this behavior. - https://docs.microsoft.com/zh-tw/windows/win32/api/d3d12/nf-d3d12-id3d12graphicscommandlist-resolvequerydata - - xing: So manual patch here to prevent this behavior which causes a debuger layer error below in WIN11 - "D3D12 ERROR: ID3D12CommandQueue::ExecuteCommandLists: Cannot Resolve query that has never been performed for Index [*] in QueryHeap (0x00000207E7A19160:'GpuTimeStamp QueryHeap') in command list (0x00000207E76812A0:'CommandList'). [ EXECUTION ERROR #1319: RESOLVE_QUERY_INVALID_QUERY_STATE]" - */ -#define PATCH_UNINITIALIZED_QUERIES - -namespace -{ - ID3D12QueryHeap* sm_QueryHeap = nullptr; - ID3D12Resource* sm_ReadBackBuffer = nullptr; - uint64_t* sm_TimeStampBuffer = nullptr; - uint64_t sm_Fence = 0; - uint32_t sm_MaxNumTimers = 0; - uint32_t sm_NumTimers = 1; - uint64_t sm_ValidTimeStart = 0; - uint64_t sm_ValidTimeEnd = 0; - double sm_GpuTickDelta = 0.0; -#ifdef PATCH_UNINITIALIZED_QUERIES - uint32_t m_LastTimerIdx = UINT32_MAX; -#endif -} - -void GpuTimeManager::Initialize(uint32_t MaxNumTimers) -{ - uint64_t GpuFrequency; - Graphics::g_CommandManager.GetCommandQueue()->GetTimestampFrequency(&GpuFrequency); - sm_GpuTickDelta = 1.0 / static_cast(GpuFrequency); - - D3D12_HEAP_PROPERTIES HeapProps; - HeapProps.Type = D3D12_HEAP_TYPE_READBACK; - HeapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; - HeapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; - HeapProps.CreationNodeMask = 1; - HeapProps.VisibleNodeMask = 1; - - D3D12_RESOURCE_DESC BufferDesc; - BufferDesc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; - BufferDesc.Alignment = 0; - BufferDesc.Width = sizeof(uint64_t) * MaxNumTimers * 2; - BufferDesc.Height = 1; - BufferDesc.DepthOrArraySize = 1; - BufferDesc.MipLevels = 1; - BufferDesc.Format = DXGI_FORMAT_UNKNOWN; - BufferDesc.SampleDesc.Count = 1; - BufferDesc.SampleDesc.Quality = 0; - BufferDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; - BufferDesc.Flags = D3D12_RESOURCE_FLAG_NONE; - - ASSERT_SUCCEEDED(Graphics::g_Device->CreateCommittedResource( &HeapProps, D3D12_HEAP_FLAG_NONE, &BufferDesc, - D3D12_RESOURCE_STATE_COPY_DEST, nullptr, MY_IID_PPV_ARGS(&sm_ReadBackBuffer) )); - sm_ReadBackBuffer->SetName(L"GpuTimeStamp Buffer"); - - D3D12_QUERY_HEAP_DESC QueryHeapDesc; - QueryHeapDesc.Count = MaxNumTimers * 2; - QueryHeapDesc.NodeMask = 1; - QueryHeapDesc.Type = D3D12_QUERY_HEAP_TYPE_TIMESTAMP; - ASSERT_SUCCEEDED(Graphics::g_Device->CreateQueryHeap(&QueryHeapDesc, MY_IID_PPV_ARGS(&sm_QueryHeap))); - sm_QueryHeap->SetName(L"GpuTimeStamp QueryHeap"); - - sm_MaxNumTimers = (uint32_t)MaxNumTimers; -} - -void GpuTimeManager::Shutdown() -{ - if (sm_ReadBackBuffer != nullptr) - sm_ReadBackBuffer->Release(); - - if (sm_QueryHeap != nullptr) - sm_QueryHeap->Release(); -} - -uint32_t GpuTimeManager::NewTimer(void) -{ - return sm_NumTimers++; -} - -void GpuTimeManager::StartTimer(CommandContext& Context, uint32_t TimerIdx) -{ -#ifdef PATCH_UNINITIALIZED_QUERIES - if (m_LastTimerIdx + 1 < TimerIdx) - { - for (uint32_t i = m_LastTimerIdx + 1; i < TimerIdx; i++) - { - Context.InsertTimeStamp(sm_QueryHeap, i * 2); - Context.InsertTimeStamp(sm_QueryHeap, i * 2 + 1); - } - } - m_LastTimerIdx = TimerIdx; -#endif - Context.InsertTimeStamp(sm_QueryHeap, TimerIdx * 2); -} - -void GpuTimeManager::StopTimer(CommandContext& Context, uint32_t TimerIdx) -{ - Context.InsertTimeStamp(sm_QueryHeap, TimerIdx * 2 + 1); -#ifdef PATCH_UNINITIALIZED_QUERIES - if (TimerIdx > m_LastTimerIdx) - { - m_LastTimerIdx = TimerIdx; - } -#endif -} - -void GpuTimeManager::BeginReadBack(void) -{ - Graphics::g_CommandManager.WaitForFence(sm_Fence); - - D3D12_RANGE Range; - Range.Begin = 0; - Range.End = (sm_NumTimers * 2) * sizeof(uint64_t); - ASSERT_SUCCEEDED(sm_ReadBackBuffer->Map(0, &Range, reinterpret_cast(&sm_TimeStampBuffer))); - - sm_ValidTimeStart = sm_TimeStampBuffer[0]; - sm_ValidTimeEnd = sm_TimeStampBuffer[1]; - - // On the first frame, with random values in the timestamp query heap, we can avoid a misstart. - if (sm_ValidTimeEnd < sm_ValidTimeStart) - { - sm_ValidTimeStart = 0ull; - sm_ValidTimeEnd = 0ull; - } -} - -void GpuTimeManager::EndReadBack(void) -{ - // Unmap with an empty range to indicate nothing was written by the CPU - D3D12_RANGE EmptyRange = {}; - sm_ReadBackBuffer->Unmap(0, &EmptyRange); - sm_TimeStampBuffer = nullptr; - - CommandContext& Context = CommandContext::Begin(); -#ifdef PATCH_UNINITIALIZED_QUERIES - if (m_LastTimerIdx != UINT32_MAX) - { -#endif - Context.InsertTimeStamp(sm_QueryHeap, 1); - Context.ResolveTimeStamps(sm_ReadBackBuffer, sm_QueryHeap, sm_NumTimers * 2); -#ifdef PATCH_UNINITIALIZED_QUERIES - } -#endif - Context.InsertTimeStamp(sm_QueryHeap, 0); - sm_Fence = Context.Finish(); -#ifdef PATCH_UNINITIALIZED_QUERIES - m_LastTimerIdx = 0; -#endif -} - -float GpuTimeManager::GetTime(uint32_t TimerIdx) -{ - ASSERT(sm_TimeStampBuffer != nullptr, "Time stamp readback buffer is not mapped"); - ASSERT(TimerIdx < sm_NumTimers, "Invalid GPU timer index"); - - uint64_t TimeStamp1 = sm_TimeStampBuffer[TimerIdx * 2]; - uint64_t TimeStamp2 = sm_TimeStampBuffer[TimerIdx * 2 + 1]; - - if (TimeStamp1 < sm_ValidTimeStart || TimeStamp2 > sm_ValidTimeEnd || TimeStamp2 <= TimeStamp1 ) - return 0.0f; - - return static_cast(sm_GpuTickDelta * (TimeStamp2 - TimeStamp1)); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/GpuTimeManager.h b/xess/samples/xess_demo/MiniEngine/Core/GpuTimeManager.h deleted file mode 100644 index 4260277..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/GpuTimeManager.h +++ /dev/null @@ -1,39 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "GameCore.h" - -class CommandContext; - -namespace GpuTimeManager -{ - void Initialize( uint32_t MaxNumTimers = 4096 ); - void Shutdown(); - - // Reserve a unique timer index - uint32_t NewTimer(void); - - // Write start and stop time stamps on the GPU timeline - void StartTimer(CommandContext& Context, uint32_t TimerIdx); - void StopTimer(CommandContext& Context, uint32_t TimerIdx); - - // Bookend all calls to GetTime() with Begin/End which correspond to Map/Unmap. This - // needs to happen either at the very start or very end of a frame. - void BeginReadBack(void); - void EndReadBack(void); - - // Returns the time in milliseconds between start and stop queries - float GetTime(uint32_t TimerIdx); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/GraphRenderer.cpp b/xess/samples/xess_demo/MiniEngine/Core/GraphRenderer.cpp deleted file mode 100644 index c1d6835..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/GraphRenderer.cpp +++ /dev/null @@ -1,588 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: Julia Careaga -// - -#include "pch.h" -#include "GraphRenderer.h" -#include "CommandContext.h" -#include "PipelineState.h" -#include "RootSignature.h" -#include "BufferManager.h" -#include "GameInput.h" -#include "SystemTime.h" -#include "EngineProfiling.h" - -#include "CompiledShaders/PerfGraphBackgroundVS.h" -#include "CompiledShaders/PerfGraphVS.h" -#include "CompiledShaders/PerfGraphPS.h" - -#define PERF_GRAPH_ERROR uint32_t(0xFFFFFFFF) -#define MAX_GLOBAL_GRAPHS 2 -#define MAX_PROFILE_GRAPHS 32 -#define MAX_ACTIVE_PROFILE_GRAPHS 4 -#define PROFILE_NODE_COUNT 256 -#define GLOBAL_NODE_COUNT 512 -#define PROFILE_DEBUG_VAR_COUNT 2 - -using namespace Graphics; -using namespace std; -using namespace GraphRenderer; -using namespace Math; - -__declspec(align(16)) struct CBGraph -{ - float RGB[3]; - float RcpXScale; - uint32_t NodeCount; - uint32_t FrameID; -}; - -class GraphVector; - -class PerfGraph -{ -friend GraphVector; -public: - PerfGraph( uint32_t NodeCount, uint32_t debugVarCount, Color color = Color(1.0f, 0.0f, 0.5f), bool IsGraphed = false ) : m_IsGraphed(IsGraphed), - m_NodeCount(NodeCount), m_Color(color), m_DebugVarCount(debugVarCount) - { - for (uint32_t i = 0; i < debugVarCount; ++i) - m_PerfTimesCPUBuffer.emplace_back(new float[NodeCount]); - } - - ~PerfGraph() - { - Clear(); - } - - void Clear(){ m_PerfTimesCPUBuffer.clear();} - bool IsGraphed(){ return m_IsGraphed; } - Color GetColor(){ return m_Color; } - void SetColor(Color color){m_Color = color;} - void UpdateGraph( float* timeStamps, uint32_t frameID ) - { - for(uint32_t i = 0; i < m_DebugVarCount; i++) - m_PerfTimesCPUBuffer[i][frameID % m_NodeCount] = timeStamps[i]; - } - - //RenderGraph renders both graph backgrounds and line graphs - // - //To render backgrounds, set s_GraphBackgroundPSO, set primitive topology to triangle strip, - //call RenderGraph without an object and with MaxArray = nullptr. - // - //To render line graph, set s_RenderPerfGraphPSO, set primitive topology to line strip, - //call RenderGraph on an associated PerfGraph object, and pass in MaxArray - static void RenderGraph( GraphicsContext& Context, uint32_t vertexCount, D3D12_VIEWPORT& viewport, - uint32_t debugVarCount, float topMargin); - - void RenderGraph(GraphicsContext& Context, uint32_t vertexCount, D3D12_VIEWPORT& viewport, - uint32_t debugVarCount, float topMargin, float MaxValue, uint32_t frameID); - - void RenderGraph(GraphicsContext& Context, uint32_t vertexCount, D3D12_VIEWPORT& viewport, - uint32_t debugVarCount, float topMargin, const float* MaxArray, uint32_t frameID); - -private: - std::vector> m_PerfTimesCPUBuffer; - uint32_t m_NodeCount; - bool m_IsGraphed; - Color m_Color; - uint32_t m_ColorKey; - uint32_t m_DebugVarCount; -}; - - -class GraphVector -{ -public: - GraphVector(uint32_t MaxActiveGraphs, uint32_t DebugVarCount) : m_MaxActiveGraphs(MaxActiveGraphs), - m_ActiveGraphs(0), m_DebugVarCount(DebugVarCount), m_MinAbs((float)PERF_GRAPH_ERROR), - m_MaxAbs(0.0f), m_FrameOfMinAbs(0), m_FrameOfMaxAbs(0) - { - // Fill color array with set of possible graph colors (up to 8 different colors) - m_ColorArray.reset(new Color[MaxActiveGraphs]); - for (uint32_t i = 0; i < m_MaxActiveGraphs; ++i) - { - m_ColorKeyStack.push_back(i); - uint32_t colorKey = i + 1; - float R = (float)(colorKey & 1); - float G = (float)((colorKey >> 1) & 1) + 0.3f; - float B = (float)((colorKey >> 2) & 1) + 0.3f; - m_ColorArray[i] = Color(R, G, B); - } - - m_Max.reset(new float[DebugVarCount]); - m_Min.reset(new float[DebugVarCount]); - m_FrameOfMax.reset(new uint32_t[DebugVarCount]); - m_FrameOfMin.reset(new uint32_t[DebugVarCount]); - m_PresetMax.reset(new float[DebugVarCount]); - - for (uint32_t i = 0; i < DebugVarCount; ++i) - { - m_Max[i] = 0.0f; - m_Min[i] = (float)PERF_GRAPH_ERROR; - m_FrameOfMax[i] = m_FrameOfMin[i] = 0; - m_PresetMax[i] = 30.0f; - } - - } - - void Clear() - { - m_Graphs.clear(); - } - - GraphHandle AddGraph(PerfGraph* graph) - { - GraphHandle ret = (GraphHandle)m_Graphs.size(); - m_Graphs.emplace_back(graph); - return ret; - } - - bool Toggle(GraphHandle GraphID) - { - if (m_ActiveGraphs < m_MaxActiveGraphs && !m_Graphs[GraphID]->m_IsGraphed) - { - //add to active list - m_Graphs[GraphID]->m_IsGraphed = true; - ++m_ActiveGraphs; - //set color - m_Graphs[GraphID]->m_ColorKey = m_ColorKeyStack.back(); - m_ColorKeyStack.pop_back(); - m_Graphs[GraphID]->m_Color = m_ColorArray[m_Graphs[GraphID]->m_ColorKey]; - } - else if (m_Graphs[GraphID]->m_IsGraphed) - { - //take it off of active list - m_ColorKeyStack.push_back(m_Graphs[GraphID]->m_ColorKey); - m_Graphs[GraphID]->m_IsGraphed = false; - --m_ActiveGraphs; - } - return m_Graphs[GraphID]->m_IsGraphed; - } - - - Color GetColor(GraphHandle GraphID){ return m_Graphs[GraphID]->m_Color;} - uint32_t Size(){return (uint32_t)m_Graphs.size();} - uint32_t GetActiveGraphCount(){return m_ActiveGraphs;} - - float* GetPresetMax(){return m_PresetMax.get();} - float GetGlobalPresetMax() - { - float max = 0.0f; - for (uint32_t i = 0; i < m_DebugVarCount; ++i) - { - if (m_PresetMax[i] > max) - max = m_PresetMax[i]; - } - return max; - } - float* GetMaxAbs(){return &m_MaxAbs;} - float* GetMinAbs(){return &m_MinAbs;} - float* GetMax(){return m_Max.get();} - float* GetMin(){return m_Min.get();} - - void PresetMax(const float* maxArray) - { - for (uint32_t i = 0; i < m_DebugVarCount; ++i) - m_PresetMax[i] = maxArray[i]; - } - - void ManageMax(float* InputNode, uint32_t nodeCount, uint32_t FrameID) - { - for (uint32_t i = 0; i < m_DebugVarCount; ++i) - { - //Absolute min max - if (FrameID - m_FrameOfMinAbs > nodeCount) - m_MinAbs = (float)PERF_GRAPH_ERROR; - - if (FrameID - m_FrameOfMaxAbs > nodeCount) - m_MaxAbs = 0.0f; - - if (InputNode[i] > m_MaxAbs) - { - m_MaxAbs = InputNode[i]; - m_FrameOfMaxAbs = FrameID; - } - - if (InputNode[i] < m_MinAbs) - { - m_MinAbs = InputNode[i]; - m_FrameOfMinAbs = FrameID; - } - - //Relative min max - if (FrameID - m_FrameOfMax[i] > nodeCount) - m_Max[i] = 0.0f; - - if (FrameID - m_FrameOfMin[i] > nodeCount) - m_Min[i] = (float)PERF_GRAPH_ERROR; - - if (InputNode[i] > m_Max[i]) - { - m_Max[i] = InputNode[i]; - m_FrameOfMax[i] = FrameID; - } - if (InputNode[i] < m_Min[i]) - { - m_Min[i] = InputNode[i]; - m_FrameOfMin[i] = FrameID; - } - } - - } - - std::vector> m_Graphs; // this should be private - -private: - - uint32_t m_ActiveGraphs; - uint32_t m_MaxActiveGraphs; - uint32_t m_DebugVarCount; - std::unique_ptr m_ColorArray; - std::vector m_ColorKeyStack; - - float m_MaxAbs; - float m_MinAbs; - uint32_t m_FrameOfMaxAbs; - uint32_t m_FrameOfMinAbs; - - std::unique_ptr m_PresetMax; - std::unique_ptr m_Max; - std::unique_ptr m_Min; - std::unique_ptr m_FrameOfMax; - std::unique_ptr m_FrameOfMin; -}; - -namespace -{ - RootSignature s_RootSignature; - GraphicsPSO s_RenderPerfGraphPSO(L"Graph Renderer: Render Perf Graph PSO"); - GraphicsPSO s_GraphBackgroundPSO(L"Graph Renderer: Render Graph Background PSO"); - uint32_t s_FrameID; - GraphVector GlobalGraphs = GraphVector(2, 1); - GraphVector ProfileGraphs = GraphVector(MAX_ACTIVE_PROFILE_GRAPHS, PROFILE_DEBUG_VAR_COUNT); - uint32_t s_NumStamps = 0; - uint32_t s_SelectedTimerIndex; -} // {anonymous} namespace - - - -//--------------------------------------------------------------------- -// -// GraphRenderer Methods -// -//--------------------------------------------------------------------- - -static void DrawGraphHeaders(TextContext& Text, float leftMargin, float topMargin, float offsetY, float graphHeight, float* MinArray, - float* MaxArray, float* PresetMaxArray, bool GlobalScale, uint32_t numDebugVar, std::string graphTitles[]); - - -void GraphRenderer::Initialize( void ) -{ - s_RootSignature.Reset(4); - s_RootSignature[0].InitAsConstantBuffer(0); - s_RootSignature[1].InitAsDescriptorRange(D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 0, 2); - s_RootSignature[2].InitAsBufferSRV(0, D3D12_SHADER_VISIBILITY_VERTEX); - s_RootSignature[3].InitAsConstants(1, 3); - s_RootSignature.Finalize(L"Graph Renderer"); - - s_RenderPerfGraphPSO.SetRootSignature(s_RootSignature); - s_RenderPerfGraphPSO.SetRasterizerState(RasterizerDefault); - s_RenderPerfGraphPSO.SetBlendState(BlendTraditional); - s_RenderPerfGraphPSO.SetDepthStencilState(Graphics::DepthStateReadOnly); - s_RenderPerfGraphPSO.SetPrimitiveTopologyType(D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE); - s_RenderPerfGraphPSO.SetRenderTargetFormats(1, &g_OverlayBuffer.GetFormat(), g_OverlayBuffer.GetFormat()); - s_RenderPerfGraphPSO.SetVertexShader(g_pPerfGraphVS, sizeof(g_pPerfGraphVS)); - s_RenderPerfGraphPSO.SetPixelShader(g_pPerfGraphPS, sizeof(g_pPerfGraphPS)); - s_RenderPerfGraphPSO.Finalize(); - - s_GraphBackgroundPSO = s_RenderPerfGraphPSO; - s_GraphBackgroundPSO.SetPrimitiveTopologyType(D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE); - s_GraphBackgroundPSO.SetVertexShader(g_pPerfGraphBackgroundVS, sizeof(g_pPerfGraphBackgroundVS)); - s_GraphBackgroundPSO.Finalize(); - - s_FrameID = 0; - - // Preset max for global and profile graphs - float profilePresetMax[PROFILE_DEBUG_VAR_COUNT] = {15.0f, 1.0f}; //improve this - ProfileGraphs.PresetMax(profilePresetMax); - - // Create global CPU and GPU graphs - for (uint32_t i = 0; i < 2; ++i) - { - InitGraph( GraphType::Global ); - GlobalGraphs.m_Graphs[i]->SetColor(Color((float)i, 0.5, 0.5)); - } - - float globalPresetMax[1] = {15.0f}; - GlobalGraphs.PresetMax(globalPresetMax); -} - -void GraphRenderer::Shutdown(void) -{ - ProfileGraphs.Clear(); - GlobalGraphs.Clear(); -} - -GraphHandle GraphRenderer::InitGraph( GraphType type) -{ - if (type == GraphType::Profile) - return ProfileGraphs.AddGraph(new PerfGraph(PROFILE_NODE_COUNT, 2)); - else if (type == GraphType::Global) - return GlobalGraphs.AddGraph(new PerfGraph(GLOBAL_NODE_COUNT, 1)); - else - return PERF_GRAPH_ERROR; -} - -bool GraphRenderer::ManageGraphs( GraphHandle GraphID, GraphType Type) -{ - if (GraphID == PERF_GRAPH_ERROR) - return false; - - if (Type == GraphType::Profile) - return ProfileGraphs.Toggle(GraphID); - else // Type == GraphType::Global - return GlobalGraphs.Toggle(GraphID); -} - -//This is used to set the text color -Color GraphRenderer::GetGraphColor( GraphHandle GraphID, GraphType Type) -{ - if (Type == GraphType::Profile) - return ProfileGraphs.GetColor(GraphID); - else // Type == GraphType::Global - return GlobalGraphs.GetColor(GraphID); -} - -void GraphRenderer::Update( XMFLOAT2 InputNode, GraphHandle GraphID, GraphType Type) -{ - if (GraphID == PERF_GRAPH_ERROR) - return; - - if (Type == GraphType::Profile) - { - float input[2] = {InputNode.x, InputNode.y}; - ProfileGraphs.m_Graphs[GraphID]->UpdateGraph(input, s_FrameID); - if (ProfileGraphs.m_Graphs[GraphID]->IsGraphed()) - { - float times[4] = {InputNode.x, InputNode.y}; - ProfileGraphs.ManageMax(times, PROFILE_NODE_COUNT, s_FrameID); - } - } - else // Type == PerfGraph::Global - { - GlobalGraphs.m_Graphs[0]->UpdateGraph(&InputNode.x, s_FrameID); - GlobalGraphs.m_Graphs[1]->UpdateGraph(&InputNode.y, s_FrameID); - GlobalGraphs.ManageMax(&InputNode.x, GLOBAL_NODE_COUNT, s_FrameID); - //GlobalGraphs.ManageMax(&InputNode.y, GLOBAL_NODE_COUNT, s_FrameID); - } -} - -void DrawGraphHeaders(TextContext& Text, float leftMargin, float topMargin, float offsetY, float graphHeight, float* MinArray, - float* MaxArray, float* PresetMaxArray, bool GlobalScale, uint32_t numDebugVar, std::string graphTitles[]) -{ - XMFLOAT2 textSpaceY = XMFLOAT2(0.02f * graphHeight, 0.067f * graphHeight); //top and bottom text space - textSpaceY.y = graphHeight - topMargin - textSpaceY.x * 3.0f; // make this better - float textSpaceX = 45.f; - Text.SetColor(Color(1.0f, 1.0f, 1.0f)); - Text.SetTextSize(12.0f); - - float min = MinArray[0]; - float max = MaxArray[0]; - float presetMax = PresetMaxArray[0]; - - for (uint32_t i = 0; i < numDebugVar; i++) - { - if (!GlobalScale) - { - min = MinArray[i]; - max = MaxArray[i]; - presetMax = PresetMaxArray[i]; - } - - Text.SetCursorY(topMargin / 2.0f + (i * graphHeight) + offsetY); // division needs to be a factor - Text.SetCursorX(leftMargin + (0.4f * textSpaceX)); - Text.DrawString(graphTitles[i]); - Text.DrawFormattedString("Min:%3.3f Max:%3.3f", min, max); - - Text.SetCursorX(leftMargin - textSpaceX); - float topText = topMargin + (i * graphHeight); - Text.SetCursorY(topText + textSpaceY.x + offsetY); - Text.DrawFormattedString("%3.3f", presetMax); - - Text.SetCursorX(leftMargin - textSpaceX); - Text.SetCursorY(topText + textSpaceY.y + offsetY); - Text.DrawString("0.000"); - } -} - -void GraphRenderer::RenderGraphs(GraphicsContext& Context, GraphType Type) -{ - if (Type == GraphType::Global && GlobalGraphs.Size() == 0 || - Type == GraphType::Profile && ProfileGraphs.Size() == 0) - { - s_FrameID++; // probably need to reset this after time = uint32_t max val - return; - } - - TextContext Text(Context); - Text.Begin(); - - if (Type == GraphType::Profile && ProfileGraphs.GetActiveGraphCount() > 0) - { - D3D12_VIEWPORT viewport; - viewport.TopLeftX = (float)g_OverlayBuffer.GetWidth() / 1.3525f; - viewport.TopLeftY = 0.0f; - viewport.Width = (float)g_OverlayBuffer.GetWidth() / 4.0f; - viewport.Height = (float)g_OverlayBuffer.GetHeight() / (PROFILE_DEBUG_VAR_COUNT + 1); - viewport.MinDepth = 0.0; - viewport.MaxDepth = 1.0; - - std::string graphTitles[PROFILE_DEBUG_VAR_COUNT] = {"Inclusive CPU ", "Inclusive GPU "}; - float blankSpace = viewport.Height / (PROFILE_DEBUG_VAR_COUNT + 1); - XMFLOAT2 textSpace = XMFLOAT2(45.0f, 5.0f); - DrawGraphHeaders(Text, (viewport.TopLeftX), blankSpace, 0.0f, (viewport.Height + blankSpace), ProfileGraphs.GetMin(), - ProfileGraphs.GetMax(), ProfileGraphs.GetPresetMax(), false, PROFILE_DEBUG_VAR_COUNT, graphTitles); - - Context.SetRootSignature(s_RootSignature); - Context.TransitionResource(g_OverlayBuffer, D3D12_RESOURCE_STATE_RENDER_TARGET); - Context.SetRenderTarget(g_OverlayBuffer.GetRTV()); - Context.SetPipelineState(s_GraphBackgroundPSO); - Context.SetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); - - // Render backgrounds - PerfGraph::RenderGraph(Context, 4, viewport, PROFILE_DEBUG_VAR_COUNT, blankSpace); - Context.SetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_LINESTRIP); - viewport.TopLeftY = 0.0f; - - for (auto iter = ProfileGraphs.m_Graphs.begin(); iter != ProfileGraphs.m_Graphs.end(); ++iter) - { - if ((*iter)->IsGraphed()) - { - (*iter)->RenderGraph(Context, 256, viewport, PROFILE_DEBUG_VAR_COUNT, blankSpace, ProfileGraphs.GetPresetMax(), s_FrameID); - viewport.TopLeftY = 0.0f; - } - } - } - else if (Type == GraphType::Global) - { - D3D12_VIEWPORT viewport; - viewport.TopLeftX = (float)g_OverlayBuffer.GetWidth() / 4.0f; - viewport.TopLeftY = (float)g_OverlayBuffer.GetHeight() / 1.3f; - viewport.Width = (float)g_OverlayBuffer.GetWidth() / 2.0f; - viewport.Height = (float)g_OverlayBuffer.GetHeight() / 8.0f; - viewport.MinDepth = 0.0f; - viewport.MaxDepth = 1.0f; - - float blankSpace = viewport.Height / 8.0f; - XMFLOAT2 textSpace = XMFLOAT2(45.0f, 5.0f); - std::string graphTitles[] = { "CPU - GPU " }; - DrawGraphHeaders( Text, (viewport.TopLeftX), blankSpace, (viewport.TopLeftY - blankSpace - textSpace.y), (viewport.Height + blankSpace), - GlobalGraphs.GetMinAbs(), GlobalGraphs.GetMaxAbs(), GlobalGraphs.GetPresetMax(), true, 1, graphTitles); - - Context.SetRootSignature(s_RootSignature); - Context.TransitionResource(g_OverlayBuffer, D3D12_RESOURCE_STATE_RENDER_TARGET); - Context.SetRenderTarget(g_OverlayBuffer.GetRTV()); - Context.SetPipelineState(s_GraphBackgroundPSO); - Context.SetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); - - // Render background - PerfGraph::RenderGraph(Context, 4, viewport, 1, 0.0f); - - // Render graphs - Context.SetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_LINESTRIP); - for (auto iter = GlobalGraphs.m_Graphs.begin(); iter != GlobalGraphs.m_Graphs.end(); ++iter) - { - (*iter)->RenderGraph(Context, 512, viewport, 1, 0.0f, GlobalGraphs.GetPresetMax(), s_FrameID); - } - } - s_FrameID++; - Text.End(); - Context.SetViewport(0, 0, 1920, 1080); -} - -void GraphRenderer::SetSelectedIndex(uint32_t selectedIndex) -{ - s_SelectedTimerIndex = selectedIndex; -} - -//--------------------------------------------------------------------- -// -// PerfGraph Methods -// -//--------------------------------------------------------------------- - -void PerfGraph::RenderGraph(GraphicsContext& Context, uint32_t vertexCount, D3D12_VIEWPORT& viewport, uint32_t debugVarCount, float topMargin) -{ - viewport.TopLeftY += topMargin; - - Context.SetConstants(3, 0, 20.0f); - - for (uint32_t i = 0; i < debugVarCount; ++i) - { - Context.SetViewport(viewport); - Context.Draw(vertexCount); - if (debugVarCount > 1) - viewport.TopLeftY += viewport.Height + topMargin; - } -} - -void PerfGraph::RenderGraph(GraphicsContext& Context, uint32_t vertexCount, D3D12_VIEWPORT& viewport, uint32_t debugVarCount, float topMargin, float YScale, uint32_t frameID) -{ - viewport.TopLeftY += topMargin; - - CBGraph graphConstants; - graphConstants.RGB[0] = m_Color.R(); - graphConstants.RGB[1] = m_Color.G(); - graphConstants.RGB[2] = m_Color.B(); - graphConstants.RcpXScale = 2.0f / m_NodeCount; - graphConstants.NodeCount = m_NodeCount; - graphConstants.FrameID = frameID; - Context.SetDynamicConstantBufferView(0, sizeof(CBGraph), &graphConstants); - Context.SetPipelineState(s_RenderPerfGraphPSO); - - for (uint32_t i = 0; i < debugVarCount; ++i) - { - Context.SetDynamicSRV(2, sizeof(float) * m_NodeCount, m_PerfTimesCPUBuffer[i].get()); - Context.SetConstants(3, i, 1.0f / YScale); - Context.SetViewport(viewport); - Context.Draw(vertexCount); - if (debugVarCount > 1) - viewport.TopLeftY += viewport.Height + topMargin; - } -} - -void PerfGraph::RenderGraph( GraphicsContext& Context, uint32_t vertexCount, D3D12_VIEWPORT& viewport, uint32_t debugVarCount, float topMargin, const float* MaxArray, uint32_t frameID) -{ - ASSERT(MaxArray != nullptr); - viewport.TopLeftY += topMargin; - - CBGraph graphConstants; - graphConstants.RGB[0] = m_Color.R(); - graphConstants.RGB[1] = m_Color.G(); - graphConstants.RGB[2] = m_Color.B(); - graphConstants.RcpXScale = 2.0f / m_NodeCount; - graphConstants.NodeCount = m_NodeCount; - graphConstants.FrameID = frameID; - Context.SetDynamicConstantBufferView(0, sizeof(CBGraph), &graphConstants); - Context.SetPipelineState(s_RenderPerfGraphPSO); - - for (uint32_t i = 0; i < debugVarCount; ++i) - { - Context.SetDynamicSRV(2, sizeof(float) * m_NodeCount, m_PerfTimesCPUBuffer[i].get()); - Context.SetConstants(3, i, 1.0f / MaxArray[i]); - Context.SetViewport(viewport); - Context.Draw(vertexCount); - if (debugVarCount > 1) - viewport.TopLeftY += viewport.Height + topMargin; - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/GraphRenderer.h b/xess/samples/xess_demo/MiniEngine/Core/GraphRenderer.h deleted file mode 100644 index c8509be..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/GraphRenderer.h +++ /dev/null @@ -1,33 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: Julia Careaga -// - -#include "GraphicsCore.h" - -namespace GraphRenderer -{ - void Initialize(); - void Shutdown(); - - enum class GraphType { Global, Profile }; - typedef uint32_t GraphHandle; - - bool ManageGraphs( GraphHandle graphID, GraphType Type ); - GraphHandle InitGraph( GraphType Type ); - Color GetGraphColor( GraphHandle GraphID, GraphType Type); - XMFLOAT4 GetMaxAvg( GraphType Type ); - void Update( XMFLOAT2 InputNode, GraphHandle GraphID, GraphType Type); - void RenderGraphs( GraphicsContext& Context, GraphType Type ); - - void SetSelectedIndex(uint32_t selectedIndex); - -} // namespace GraphRenderer diff --git a/xess/samples/xess_demo/MiniEngine/Core/GraphicsCommon.cpp b/xess/samples/xess_demo/MiniEngine/Core/GraphicsCommon.cpp deleted file mode 100644 index 6c213e0..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/GraphicsCommon.cpp +++ /dev/null @@ -1,313 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "GraphicsCommon.h" -#include "SamplerManager.h" -#include "CommandSignature.h" -#include "BitonicSort.h" -#include "Texture.h" -#include "PipelineState.h" -#include "RootSignature.h" -#include "BufferManager.h" - -#include "CompiledShaders/GenerateMipsLinearCS.h" -#include "CompiledShaders/GenerateMipsLinearOddCS.h" -#include "CompiledShaders/GenerateMipsLinearOddXCS.h" -#include "CompiledShaders/GenerateMipsLinearOddYCS.h" -#include "CompiledShaders/GenerateMipsGammaCS.h" -#include "CompiledShaders/GenerateMipsGammaOddCS.h" -#include "CompiledShaders/GenerateMipsGammaOddXCS.h" -#include "CompiledShaders/GenerateMipsGammaOddYCS.h" - -#include "CompiledShaders/ScreenQuadCommonVS.h" -#include "CompiledShaders/DownsampleDepthPS.h" - -namespace Graphics -{ - SamplerDesc SamplerLinearWrapDesc; - SamplerDesc SamplerAnisoWrapDesc; - SamplerDesc SamplerShadowDesc; - SamplerDesc SamplerLinearClampDesc; - SamplerDesc SamplerVolumeWrapDesc; - SamplerDesc SamplerPointClampDesc; - SamplerDesc SamplerPointBorderDesc; - SamplerDesc SamplerLinearBorderDesc; - - D3D12_CPU_DESCRIPTOR_HANDLE SamplerLinearWrap; - D3D12_CPU_DESCRIPTOR_HANDLE SamplerAnisoWrap; - D3D12_CPU_DESCRIPTOR_HANDLE SamplerShadow; - D3D12_CPU_DESCRIPTOR_HANDLE SamplerLinearClamp; - D3D12_CPU_DESCRIPTOR_HANDLE SamplerVolumeWrap; - D3D12_CPU_DESCRIPTOR_HANDLE SamplerPointClamp; - D3D12_CPU_DESCRIPTOR_HANDLE SamplerPointBorder; - D3D12_CPU_DESCRIPTOR_HANDLE SamplerLinearBorder; - - Texture DefaultTextures[kNumDefaultTextures]; - D3D12_CPU_DESCRIPTOR_HANDLE GetDefaultTexture( eDefaultTexture texID ) - { - ASSERT(texID < kNumDefaultTextures); - return DefaultTextures[texID].GetSRV(); - } - - D3D12_RASTERIZER_DESC RasterizerDefault; // Counter-clockwise - D3D12_RASTERIZER_DESC RasterizerDefaultMsaa; - D3D12_RASTERIZER_DESC RasterizerDefaultCw; // Clockwise winding - D3D12_RASTERIZER_DESC RasterizerDefaultCwMsaa; - D3D12_RASTERIZER_DESC RasterizerTwoSided; - D3D12_RASTERIZER_DESC RasterizerTwoSidedMsaa; - D3D12_RASTERIZER_DESC RasterizerShadow; - D3D12_RASTERIZER_DESC RasterizerShadowCW; - D3D12_RASTERIZER_DESC RasterizerShadowTwoSided; - - D3D12_BLEND_DESC BlendNoColorWrite; - D3D12_BLEND_DESC BlendDisable; - D3D12_BLEND_DESC BlendPreMultiplied; - D3D12_BLEND_DESC BlendTraditional; - D3D12_BLEND_DESC BlendAdditive; - D3D12_BLEND_DESC BlendTraditionalAdditive; - - D3D12_DEPTH_STENCIL_DESC DepthStateDisabled; - D3D12_DEPTH_STENCIL_DESC DepthStateReadWrite; - D3D12_DEPTH_STENCIL_DESC DepthStateReadOnly; - D3D12_DEPTH_STENCIL_DESC DepthStateReadOnlyReversed; - D3D12_DEPTH_STENCIL_DESC DepthStateTestEqual; - - CommandSignature DispatchIndirectCommandSignature(1); - CommandSignature DrawIndirectCommandSignature(1); - - RootSignature g_CommonRS; - ComputePSO g_GenerateMipsLinearPSO[4] = - { - {L"Generate Mips Linear CS"}, - {L"Generate Mips Linear Odd X CS"}, - {L"Generate Mips Linear Odd Y CS"}, - {L"Generate Mips Linear Odd CS"}, - }; - - ComputePSO g_GenerateMipsGammaPSO[4] = - { - { L"Generate Mips Gamma CS" }, - { L"Generate Mips Gamma Odd X CS" }, - { L"Generate Mips Gamma Odd Y CS" }, - { L"Generate Mips Gamma Odd CS" }, - }; - - GraphicsPSO g_DownsampleDepthPSO(L"DownsampleDepth PSO"); -} - -namespace BitonicSort -{ - void Initialize(void); - void Shutdown(void); -} - -void Graphics::InitializeCommonState(void) -{ - SamplerLinearWrapDesc.Filter = D3D12_FILTER_MIN_MAG_MIP_LINEAR; - SamplerLinearWrap = SamplerLinearWrapDesc.CreateDescriptor(); - - SamplerAnisoWrapDesc.MaxAnisotropy = 4; - SamplerAnisoWrap = SamplerAnisoWrapDesc.CreateDescriptor(); - - SamplerShadowDesc.Filter = D3D12_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT; - SamplerShadowDesc.ComparisonFunc = D3D12_COMPARISON_FUNC_GREATER_EQUAL; - SamplerShadowDesc.SetTextureAddressMode(D3D12_TEXTURE_ADDRESS_MODE_CLAMP); - SamplerShadow = SamplerShadowDesc.CreateDescriptor(); - - SamplerLinearClampDesc.Filter = D3D12_FILTER_MIN_MAG_MIP_LINEAR; - SamplerLinearClampDesc.SetTextureAddressMode(D3D12_TEXTURE_ADDRESS_MODE_CLAMP); - SamplerLinearClamp = SamplerLinearClampDesc.CreateDescriptor(); - - SamplerVolumeWrapDesc.Filter = D3D12_FILTER_MIN_MAG_MIP_POINT; - SamplerVolumeWrap = SamplerVolumeWrapDesc.CreateDescriptor(); - - SamplerPointClampDesc.Filter = D3D12_FILTER_MIN_MAG_MIP_POINT; - SamplerPointClampDesc.SetTextureAddressMode(D3D12_TEXTURE_ADDRESS_MODE_CLAMP); - SamplerPointClamp = SamplerPointClampDesc.CreateDescriptor(); - - SamplerLinearBorderDesc.Filter = D3D12_FILTER_MIN_MAG_MIP_LINEAR; - SamplerLinearBorderDesc.SetTextureAddressMode(D3D12_TEXTURE_ADDRESS_MODE_BORDER); - SamplerLinearBorderDesc.SetBorderColor(Color(0.0f, 0.0f, 0.0f, 0.0f)); - SamplerLinearBorder = SamplerLinearBorderDesc.CreateDescriptor(); - - SamplerPointBorderDesc.Filter = D3D12_FILTER_MIN_MAG_MIP_POINT; - SamplerPointBorderDesc.SetTextureAddressMode(D3D12_TEXTURE_ADDRESS_MODE_BORDER); - SamplerPointBorderDesc.SetBorderColor(Color(0.0f, 0.0f, 0.0f, 0.0f)); - SamplerPointBorder = SamplerPointBorderDesc.CreateDescriptor(); - - uint32_t MagentaPixel = 0xFFFF00FF; - DefaultTextures[kMagenta2D].Create2D(4, 1, 1, DXGI_FORMAT_R8G8B8A8_UNORM, &MagentaPixel); - uint32_t BlackOpaqueTexel = 0xFF000000; - DefaultTextures[kBlackOpaque2D].Create2D(4, 1, 1, DXGI_FORMAT_R8G8B8A8_UNORM, &BlackOpaqueTexel); - uint32_t BlackTransparentTexel = 0x00000000; - DefaultTextures[kBlackTransparent2D].Create2D(4, 1, 1, DXGI_FORMAT_R8G8B8A8_UNORM, &BlackTransparentTexel); - uint32_t WhiteOpaqueTexel = 0xFFFFFFFF; - DefaultTextures[kWhiteOpaque2D].Create2D(4, 1, 1, DXGI_FORMAT_R8G8B8A8_UNORM, &WhiteOpaqueTexel); - uint32_t WhiteTransparentTexel = 0x00FFFFFF; - DefaultTextures[kWhiteTransparent2D].Create2D(4, 1, 1, DXGI_FORMAT_R8G8B8A8_UNORM, &WhiteTransparentTexel); - uint32_t FlatNormalTexel = 0x00FF8080; - DefaultTextures[kDefaultNormalMap].Create2D(4, 1, 1, DXGI_FORMAT_R8G8B8A8_UNORM, &FlatNormalTexel); - uint32_t BlackCubeTexels[6] = {}; - DefaultTextures[kBlackCubeMap].CreateCube(4, 1, 1, DXGI_FORMAT_R8G8B8A8_UNORM, BlackCubeTexels); - - // Default rasterizer states - RasterizerDefault.FillMode = D3D12_FILL_MODE_SOLID; - RasterizerDefault.CullMode = D3D12_CULL_MODE_BACK; - RasterizerDefault.FrontCounterClockwise = TRUE; - RasterizerDefault.DepthBias = D3D12_DEFAULT_DEPTH_BIAS; - RasterizerDefault.DepthBiasClamp = D3D12_DEFAULT_DEPTH_BIAS_CLAMP; - RasterizerDefault.SlopeScaledDepthBias = D3D12_DEFAULT_SLOPE_SCALED_DEPTH_BIAS; - RasterizerDefault.DepthClipEnable = TRUE; - RasterizerDefault.MultisampleEnable = FALSE; - RasterizerDefault.AntialiasedLineEnable = FALSE; - RasterizerDefault.ForcedSampleCount = 0; - RasterizerDefault.ConservativeRaster = D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF; - - RasterizerDefaultMsaa = RasterizerDefault; - RasterizerDefaultMsaa.MultisampleEnable = TRUE; - - RasterizerDefaultCw = RasterizerDefault; - RasterizerDefaultCw.FrontCounterClockwise = FALSE; - - RasterizerDefaultCwMsaa = RasterizerDefaultCw; - RasterizerDefaultCwMsaa.MultisampleEnable = TRUE; - - RasterizerTwoSided = RasterizerDefault; - RasterizerTwoSided.CullMode = D3D12_CULL_MODE_NONE; - - RasterizerTwoSidedMsaa = RasterizerTwoSided; - RasterizerTwoSidedMsaa.MultisampleEnable = TRUE; - - // Shadows need their own rasterizer state so we can reverse the winding of faces - RasterizerShadow = RasterizerDefault; - //RasterizerShadow.CullMode = D3D12_CULL_FRONT; // Hacked here rather than fixing the content - RasterizerShadow.SlopeScaledDepthBias = -1.5f; - RasterizerShadow.DepthBias = -100; - - RasterizerShadowTwoSided = RasterizerShadow; - RasterizerShadowTwoSided.CullMode = D3D12_CULL_MODE_NONE; - - RasterizerShadowCW = RasterizerShadow; - RasterizerShadowCW.FrontCounterClockwise = FALSE; - - DepthStateDisabled.DepthEnable = FALSE; - DepthStateDisabled.DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ZERO; - DepthStateDisabled.DepthFunc = D3D12_COMPARISON_FUNC_ALWAYS; - DepthStateDisabled.StencilEnable = FALSE; - DepthStateDisabled.StencilReadMask = D3D12_DEFAULT_STENCIL_READ_MASK; - DepthStateDisabled.StencilWriteMask = D3D12_DEFAULT_STENCIL_WRITE_MASK; - DepthStateDisabled.FrontFace.StencilFunc = D3D12_COMPARISON_FUNC_ALWAYS; - DepthStateDisabled.FrontFace.StencilPassOp = D3D12_STENCIL_OP_KEEP; - DepthStateDisabled.FrontFace.StencilFailOp = D3D12_STENCIL_OP_KEEP; - DepthStateDisabled.FrontFace.StencilDepthFailOp = D3D12_STENCIL_OP_KEEP; - DepthStateDisabled.BackFace = DepthStateDisabled.FrontFace; - - DepthStateReadWrite = DepthStateDisabled; - DepthStateReadWrite.DepthEnable = TRUE; - DepthStateReadWrite.DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ALL; - DepthStateReadWrite.DepthFunc = D3D12_COMPARISON_FUNC_GREATER_EQUAL; - - DepthStateReadOnly = DepthStateReadWrite; - DepthStateReadOnly.DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ZERO; - - DepthStateReadOnlyReversed = DepthStateReadOnly; - DepthStateReadOnlyReversed.DepthFunc = D3D12_COMPARISON_FUNC_LESS; - - DepthStateTestEqual = DepthStateReadOnly; - DepthStateTestEqual.DepthFunc = D3D12_COMPARISON_FUNC_EQUAL; - - D3D12_BLEND_DESC alphaBlend = {}; - alphaBlend.IndependentBlendEnable = FALSE; - alphaBlend.RenderTarget[0].BlendEnable = FALSE; - alphaBlend.RenderTarget[0].SrcBlend = D3D12_BLEND_SRC_ALPHA; - alphaBlend.RenderTarget[0].DestBlend = D3D12_BLEND_INV_SRC_ALPHA; - alphaBlend.RenderTarget[0].BlendOp = D3D12_BLEND_OP_ADD; - alphaBlend.RenderTarget[0].SrcBlendAlpha = D3D12_BLEND_ONE; - alphaBlend.RenderTarget[0].DestBlendAlpha = D3D12_BLEND_INV_SRC_ALPHA; - alphaBlend.RenderTarget[0].BlendOpAlpha = D3D12_BLEND_OP_ADD; - alphaBlend.RenderTarget[0].RenderTargetWriteMask = 0; - BlendNoColorWrite = alphaBlend; - - alphaBlend.RenderTarget[0].RenderTargetWriteMask = D3D12_COLOR_WRITE_ENABLE_ALL; - BlendDisable = alphaBlend; - - alphaBlend.RenderTarget[0].BlendEnable = TRUE; - BlendTraditional = alphaBlend; - - alphaBlend.RenderTarget[0].SrcBlend = D3D12_BLEND_ONE; - BlendPreMultiplied = alphaBlend; - - alphaBlend.RenderTarget[0].DestBlend = D3D12_BLEND_ONE; - BlendAdditive = alphaBlend; - - alphaBlend.RenderTarget[0].SrcBlend = D3D12_BLEND_SRC_ALPHA; - BlendTraditionalAdditive = alphaBlend; - - DispatchIndirectCommandSignature[0].Dispatch(); - DispatchIndirectCommandSignature.Finalize(); - - DrawIndirectCommandSignature[0].Draw(); - DrawIndirectCommandSignature.Finalize(); - - BitonicSort::Initialize(); - - g_CommonRS.Reset(4, 4); - g_CommonRS[0].InitAsConstants(0, 4); - g_CommonRS[1].InitAsDescriptorRange(D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 10); - g_CommonRS[2].InitAsDescriptorRange(D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 0, 10); - g_CommonRS[3].InitAsConstantBuffer(1); - g_CommonRS.InitStaticSampler(0, SamplerLinearClampDesc); - g_CommonRS.InitStaticSampler(1, SamplerPointBorderDesc); - g_CommonRS.InitStaticSampler(2, SamplerLinearBorderDesc); - g_CommonRS.InitStaticSampler(3, SamplerPointClampDesc); - - g_CommonRS.Finalize(L"GraphicsCommonRS"); - -#define CreatePSO(ObjName, ShaderByteCode ) \ - ObjName.SetRootSignature(g_CommonRS); \ - ObjName.SetComputeShader(ShaderByteCode, sizeof(ShaderByteCode) ); \ - ObjName.Finalize(); - - CreatePSO(g_GenerateMipsLinearPSO[0], g_pGenerateMipsLinearCS); - CreatePSO(g_GenerateMipsLinearPSO[1], g_pGenerateMipsLinearOddXCS); - CreatePSO(g_GenerateMipsLinearPSO[2], g_pGenerateMipsLinearOddYCS); - CreatePSO(g_GenerateMipsLinearPSO[3], g_pGenerateMipsLinearOddCS); - CreatePSO(g_GenerateMipsGammaPSO[0], g_pGenerateMipsGammaCS); - CreatePSO(g_GenerateMipsGammaPSO[1], g_pGenerateMipsGammaOddXCS); - CreatePSO(g_GenerateMipsGammaPSO[2], g_pGenerateMipsGammaOddYCS); - CreatePSO(g_GenerateMipsGammaPSO[3], g_pGenerateMipsGammaOddCS); - - g_DownsampleDepthPSO.SetRootSignature(g_CommonRS); - g_DownsampleDepthPSO.SetRasterizerState(RasterizerTwoSided); - g_DownsampleDepthPSO.SetBlendState(BlendDisable); - g_DownsampleDepthPSO.SetDepthStencilState(DepthStateReadWrite); - g_DownsampleDepthPSO.SetSampleMask(0xFFFFFFFF); - g_DownsampleDepthPSO.SetInputLayout(0, nullptr); - g_DownsampleDepthPSO.SetPrimitiveTopologyType(D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE); - g_DownsampleDepthPSO.SetVertexShader(g_pScreenQuadCommonVS, sizeof(g_pScreenQuadCommonVS)); - g_DownsampleDepthPSO.SetPixelShader(g_pDownsampleDepthPS, sizeof(g_pDownsampleDepthPS)); - g_DownsampleDepthPSO.SetDepthTargetFormat(DXGI_FORMAT_D32_FLOAT); - g_DownsampleDepthPSO.Finalize(); -} - -void Graphics::DestroyCommonState(void) -{ - for (uint32_t i = 0; i < kNumDefaultTextures; ++i) - DefaultTextures[i].Destroy(); - - DispatchIndirectCommandSignature.Destroy(); - DrawIndirectCommandSignature.Destroy(); - - BitonicSort::Shutdown(); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/GraphicsCommon.h b/xess/samples/xess_demo/MiniEngine/Core/GraphicsCommon.h deleted file mode 100644 index b7de6bf..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/GraphicsCommon.h +++ /dev/null @@ -1,91 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "SamplerManager.h" - -class SamplerDesc; -class CommandSignature; -class RootSignature; -class ComputePSO; -class GraphicsPSO; - -namespace Graphics -{ - void InitializeCommonState(void); - void DestroyCommonState(void); - - extern SamplerDesc SamplerLinearWrapDesc; - extern SamplerDesc SamplerAnisoWrapDesc; - extern SamplerDesc SamplerShadowDesc; - extern SamplerDesc SamplerLinearClampDesc; - extern SamplerDesc SamplerVolumeWrapDesc; - extern SamplerDesc SamplerPointClampDesc; - extern SamplerDesc SamplerPointBorderDesc; - extern SamplerDesc SamplerLinearBorderDesc; - - extern D3D12_CPU_DESCRIPTOR_HANDLE SamplerLinearWrap; - extern D3D12_CPU_DESCRIPTOR_HANDLE SamplerAnisoWrap; - extern D3D12_CPU_DESCRIPTOR_HANDLE SamplerShadow; - extern D3D12_CPU_DESCRIPTOR_HANDLE SamplerLinearClamp; - extern D3D12_CPU_DESCRIPTOR_HANDLE SamplerVolumeWrap; - extern D3D12_CPU_DESCRIPTOR_HANDLE SamplerPointClamp; - extern D3D12_CPU_DESCRIPTOR_HANDLE SamplerPointBorder; - extern D3D12_CPU_DESCRIPTOR_HANDLE SamplerLinearBorder; - - extern D3D12_RASTERIZER_DESC RasterizerDefault; - extern D3D12_RASTERIZER_DESC RasterizerDefaultMsaa; - extern D3D12_RASTERIZER_DESC RasterizerDefaultCw; - extern D3D12_RASTERIZER_DESC RasterizerDefaultCwMsaa; - extern D3D12_RASTERIZER_DESC RasterizerTwoSided; - extern D3D12_RASTERIZER_DESC RasterizerTwoSidedMsaa; - extern D3D12_RASTERIZER_DESC RasterizerShadow; - extern D3D12_RASTERIZER_DESC RasterizerShadowCW; - extern D3D12_RASTERIZER_DESC RasterizerShadowTwoSided; - - extern D3D12_BLEND_DESC BlendNoColorWrite; // XXX - extern D3D12_BLEND_DESC BlendDisable; // 1, 0 - extern D3D12_BLEND_DESC BlendPreMultiplied; // 1, 1-SrcA - extern D3D12_BLEND_DESC BlendTraditional; // SrcA, 1-SrcA - extern D3D12_BLEND_DESC BlendAdditive; // 1, 1 - extern D3D12_BLEND_DESC BlendTraditionalAdditive;// SrcA, 1 - - extern D3D12_DEPTH_STENCIL_DESC DepthStateDisabled; - extern D3D12_DEPTH_STENCIL_DESC DepthStateReadWrite; - extern D3D12_DEPTH_STENCIL_DESC DepthStateReadOnly; - extern D3D12_DEPTH_STENCIL_DESC DepthStateReadOnlyReversed; - extern D3D12_DEPTH_STENCIL_DESC DepthStateTestEqual; - - extern CommandSignature DispatchIndirectCommandSignature; - extern CommandSignature DrawIndirectCommandSignature; - - enum eDefaultTexture - { - kMagenta2D, // Useful for indicating missing textures - kBlackOpaque2D, - kBlackTransparent2D, - kWhiteOpaque2D, - kWhiteTransparent2D, - kDefaultNormalMap, - kBlackCubeMap, - - kNumDefaultTextures - }; - D3D12_CPU_DESCRIPTOR_HANDLE GetDefaultTexture( eDefaultTexture texID ); - - extern RootSignature g_CommonRS; - extern ComputePSO g_GenerateMipsLinearPSO[4]; - extern ComputePSO g_GenerateMipsGammaPSO[4]; - extern GraphicsPSO g_DownsampleDepthPSO; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/GraphicsCore.cpp b/xess/samples/xess_demo/MiniEngine/Core/GraphicsCore.cpp deleted file mode 100644 index 5d7bcca..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/GraphicsCore.cpp +++ /dev/null @@ -1,434 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -// Modified 2022, Intel Corporation. -// Used EnumAdapterByGpuPreference to enumerate high performance GPU. Added g_AdapterName to store adapter name. - -#include "pch.h" -#include "GraphicsCore.h" -#include "GameCore.h" -#include "BufferManager.h" -#include "GpuTimeManager.h" -#include "PostEffects.h" -#include "SSAO.h" -#include "TextRenderer.h" -#include "ColorBuffer.h" -#include "SystemTime.h" -#include "SamplerManager.h" -#include "DescriptorHeap.h" -#include "CommandContext.h" -#include "CommandListManager.h" -#include "RootSignature.h" -#include "CommandSignature.h" -#include "ParticleEffectManager.h" -#include "GraphRenderer.h" -#include "TemporalEffects.h" -#include "Display.h" -#include "Utility.h" - -#pragma comment(lib, "d3d12.lib") - -#ifdef _GAMING_DESKTOP - #include // To read the registry -#endif - -using namespace Math; - -namespace Graphics -{ -#ifndef RELEASE - const GUID WKPDID_D3DDebugObjectName = { 0x429b8c22,0x9188,0x4b0c, { 0x87,0x42,0xac,0xb0,0xbf,0x85,0xc2,0x00 }}; -#endif - - std::string g_AdapterName; - - bool g_bTypedUAVLoadSupport_R11G11B10_FLOAT = false; - bool g_bTypedUAVLoadSupport_R16G16B16A16_FLOAT = false; - - ID3D12Device* g_Device = nullptr; - CommandListManager g_CommandManager; - ContextManager g_ContextManager; - - D3D_FEATURE_LEVEL g_D3DFeatureLevel = D3D_FEATURE_LEVEL_11_0; - - DescriptorAllocator g_DescriptorAllocator[D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES] = - { - D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, - D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER, - D3D12_DESCRIPTOR_HEAP_TYPE_RTV, - D3D12_DESCRIPTOR_HEAP_TYPE_DSV - }; - - static const uint32_t vendorID_Nvidia = 0x10DE; - static const uint32_t vendorID_AMD = 0x1002; - static const uint32_t vendorID_Intel = 0x8086; - - uint32_t GetDesiredGPUVendor() - { - uint32_t desiredVendor = 0; - - std::wstring vendorVal; - if (CommandLineArgs::GetString(L"vendor", vendorVal)) - { - // Convert to lower case - std::transform(vendorVal.begin(), vendorVal.end(), vendorVal.begin(), std::towlower); - - if (vendorVal.find(L"amd") != std::wstring::npos) - { - desiredVendor = vendorID_AMD; - } - else if (vendorVal.find(L"nvidia") != std::wstring::npos || vendorVal.find(L"nvd") != std::wstring::npos || - vendorVal.find(L"nvda") != std::wstring::npos || vendorVal.find(L"nv") != std::wstring::npos) - { - desiredVendor = vendorID_Nvidia; - } - else if (vendorVal.find(L"intel") != std::wstring::npos || vendorVal.find(L"intc") != std::wstring::npos) - { - desiredVendor = vendorID_Intel; - } - } - - return desiredVendor; - } - - const wchar_t* GPUVendorToString(uint32_t vendorID) - { - switch (vendorID) - { - case vendorID_Nvidia: - return L"Nvidia"; - case vendorID_AMD: - return L"AMD"; - case vendorID_Intel: - return L"Intel"; - default: - return L"Unknown"; - break; - } - } - - uint32_t GetVendorIdFromDevice(ID3D12Device* pDevice) - { - LUID luid = pDevice->GetAdapterLuid(); - - // Obtain the DXGI factory - Microsoft::WRL::ComPtr dxgiFactory; - ASSERT_SUCCEEDED(CreateDXGIFactory2(0, MY_IID_PPV_ARGS(&dxgiFactory))); - - Microsoft::WRL::ComPtr pAdapter; - - if (SUCCEEDED(dxgiFactory->EnumAdapterByLuid(luid, MY_IID_PPV_ARGS(&pAdapter)))) - { - DXGI_ADAPTER_DESC1 desc; - if(SUCCEEDED(pAdapter->GetDesc1(&desc))) - { - return desc.VendorId; - } - } - - return 0; - } - - bool IsDeviceNvidia(ID3D12Device* pDevice) - { - return GetVendorIdFromDevice(pDevice) == vendorID_Nvidia; - } - - bool IsDeviceAMD(ID3D12Device* pDevice) - { - return GetVendorIdFromDevice(pDevice) == vendorID_AMD; - } - - bool IsDeviceIntel(ID3D12Device* pDevice) - { - return GetVendorIdFromDevice(pDevice) == vendorID_Intel; - } -} - -// Initialize the DirectX resources required to run. -void Graphics::Initialize(void) -{ - Microsoft::WRL::ComPtr pDevice; - - uint32_t useDebugLayers = 0; - CommandLineArgs::GetInteger(L"debug", useDebugLayers); -#if _DEBUG - // Default to true for debug builds - useDebugLayers = 1; -#endif - - DWORD dxgiFactoryFlags = 0; - - if (useDebugLayers) - { - Microsoft::WRL::ComPtr debugInterface; - if (SUCCEEDED(D3D12GetDebugInterface(MY_IID_PPV_ARGS(&debugInterface)))) - { - debugInterface->EnableDebugLayer(); - - uint32_t useGPUBasedValidation = 0; - CommandLineArgs::GetInteger(L"gpu_debug", useGPUBasedValidation); - if (useGPUBasedValidation) - { - Microsoft::WRL::ComPtr debugInterface1; - if (SUCCEEDED((debugInterface->QueryInterface(MY_IID_PPV_ARGS(&debugInterface1))))) - { - debugInterface1->SetEnableGPUBasedValidation(true); - } - } - } - else - { - LOG_WARN("WARNING: Unable to enable D3D12 debug validation layer."); - } - -#if _DEBUG - ComPtr dxgiInfoQueue; - if (SUCCEEDED(DXGIGetDebugInterface1(0, IID_PPV_ARGS(dxgiInfoQueue.GetAddressOf())))) - { - dxgiFactoryFlags = DXGI_CREATE_FACTORY_DEBUG; - - dxgiInfoQueue->SetBreakOnSeverity(DXGI_DEBUG_ALL, DXGI_INFO_QUEUE_MESSAGE_SEVERITY_ERROR, true); - dxgiInfoQueue->SetBreakOnSeverity(DXGI_DEBUG_ALL, DXGI_INFO_QUEUE_MESSAGE_SEVERITY_CORRUPTION, true); - - DXGI_INFO_QUEUE_MESSAGE_ID hide[] = - { - 80 /* IDXGISwapChain::GetContainingOutput: The swapchain's adapter does not control the output on which the swapchain's window resides. */, - }; - DXGI_INFO_QUEUE_FILTER filter = {}; - filter.DenyList.NumIDs = _countof(hide); - filter.DenyList.pIDList = hide; - dxgiInfoQueue->AddStorageFilterEntries(DXGI_DEBUG_DXGI, &filter); - } -#endif - } - - // Obtain the DXGI factory - Microsoft::WRL::ComPtr dxgiFactory; - ASSERT_SUCCEEDED(CreateDXGIFactory2(dxgiFactoryFlags, MY_IID_PPV_ARGS(&dxgiFactory))); - - // Create the D3D graphics device - Microsoft::WRL::ComPtr pAdapter; - - uint32_t bUseWarpDriver = false; - CommandLineArgs::GetInteger(L"warp", bUseWarpDriver); - - uint32_t desiredVendor = GetDesiredGPUVendor(); - - if (desiredVendor) - { - LOG_INFOF("Looking for a %s GPU.", Utility::WideStringToUTF8(GPUVendorToString(desiredVendor)).c_str()); - } - - // Temporary workaround because SetStablePowerState() is crashing - D3D12EnableExperimentalFeatures(0, nullptr, nullptr, nullptr); - - if (!bUseWarpDriver) - { - SIZE_T MaxSize = 0; - - for (uint32_t Idx = 0; DXGI_ERROR_NOT_FOUND != dxgiFactory->EnumAdapterByGpuPreference(Idx, - DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE, IID_PPV_ARGS(pAdapter.ReleaseAndGetAddressOf())); ++Idx) - { - DXGI_ADAPTER_DESC1 desc; - pAdapter->GetDesc1(&desc); - if (desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE) - continue; - - if ((desc.DedicatedVideoMemory > MaxSize || (desc.VendorId == desiredVendor)) && - SUCCEEDED(D3D12CreateDevice(pAdapter.Get(), D3D_FEATURE_LEVEL_11_0, MY_IID_PPV_ARGS(&pDevice)))) - { - pAdapter->GetDesc1(&desc); - LOG_INFOF("D3D12-capable hardware found: %s (%u MB).", Utility::WideStringToUTF8(desc.Description).c_str(), desc.DedicatedVideoMemory >> 20); - MaxSize = desc.DedicatedVideoMemory; - - g_AdapterName = Utility::WideStringToUTF8(desc.Description); - - if (desc.VendorId == desiredVendor) - { - LOG_INFO("Choosing this device based on user request."); - break; - } - } - } - - if (MaxSize > 0) - g_Device = pDevice.Detach(); - } - - if (g_Device == nullptr) - { - if (bUseWarpDriver) - LOG_INFO("WARP software adapter requested. Initializing..."); - else - LOG_INFO("Failed to find a hardware adapter. Falling back to WARP."); - ASSERT_SUCCEEDED(dxgiFactory->EnumWarpAdapter(MY_IID_PPV_ARGS(&pAdapter))); - ASSERT_SUCCEEDED(D3D12CreateDevice(pAdapter.Get(), D3D_FEATURE_LEVEL_11_0, MY_IID_PPV_ARGS(&pDevice))); - g_Device = pDevice.Detach(); - } -#ifndef RELEASE - else - { - bool DeveloperModeEnabled = false; - - // Look in the Windows Registry to determine if Developer Mode is enabled - HKEY hKey; - LSTATUS result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\AppModelUnlock", 0, KEY_READ, &hKey); - if (result == ERROR_SUCCESS) - { - DWORD keyValue, keySize = sizeof(DWORD); - result = RegQueryValueEx(hKey, L"AllowDevelopmentWithoutDevLicense", 0, NULL, (byte*)&keyValue, &keySize); - if (result == ERROR_SUCCESS && keyValue == 1) - DeveloperModeEnabled = true; - RegCloseKey(hKey); - } - - WARN_ONCE_IF_NOT(DeveloperModeEnabled, "Enable Developer Mode on Windows 10 to get consistent profiling results"); - - // Prevent the GPU from overclocking or underclocking to get consistent timings - if (DeveloperModeEnabled) - g_Device->SetStablePowerState(TRUE); - } -#endif - -#if _DEBUG - ID3D12InfoQueue* pInfoQueue = nullptr; - if (SUCCEEDED(g_Device->QueryInterface(MY_IID_PPV_ARGS(&pInfoQueue)))) - { - // Suppress whole categories of messages - //D3D12_MESSAGE_CATEGORY Categories[] = {}; - - // Suppress messages based on their severity level - D3D12_MESSAGE_SEVERITY Severities[] = - { - D3D12_MESSAGE_SEVERITY_INFO - }; - - // Suppress individual messages by their ID - D3D12_MESSAGE_ID DenyIds[] = - { - // This occurs when there are uninitialized descriptors in a descriptor table, even when a - // shader does not access the missing descriptors. I find this is common when switching - // shader permutations and not wanting to change much code to reorder resources. - D3D12_MESSAGE_ID_INVALID_DESCRIPTOR_HANDLE, - - // Triggered when a shader does not export all color components of a render target, such as - // when only writing RGB to an R10G10B10A2 buffer, ignoring alpha. - D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_PS_OUTPUT_RT_OUTPUT_MISMATCH, - - // This occurs when a descriptor table is unbound even when a shader does not access the missing - // descriptors. This is common with a root signature shared between disparate shaders that - // don't all need the same types of resources. - D3D12_MESSAGE_ID_COMMAND_LIST_DESCRIPTOR_TABLE_NOT_SET, - - // RESOURCE_BARRIER_DUPLICATE_SUBRESOURCE_TRANSITIONS - (D3D12_MESSAGE_ID)1008, - }; - - D3D12_INFO_QUEUE_FILTER NewFilter = {}; - //NewFilter.DenyList.NumCategories = _countof(Categories); - //NewFilter.DenyList.pCategoryList = Categories; - NewFilter.DenyList.NumSeverities = _countof(Severities); - NewFilter.DenyList.pSeverityList = Severities; - NewFilter.DenyList.NumIDs = _countof(DenyIds); - NewFilter.DenyList.pIDList = DenyIds; - - pInfoQueue->PushStorageFilter(&NewFilter); - pInfoQueue->Release(); - } -#endif - - // We like to do read-modify-write operations on UAVs during post processing. To support that, we - // need to either have the hardware do typed UAV loads of R11G11B10_FLOAT or we need to manually - // decode an R32_UINT representation of the same buffer. This code determines if we get the hardware - // load support. - D3D12_FEATURE_DATA_D3D12_OPTIONS FeatureData = {}; - if (SUCCEEDED(g_Device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS, &FeatureData, sizeof(FeatureData)))) - { - if (FeatureData.TypedUAVLoadAdditionalFormats) - { - D3D12_FEATURE_DATA_FORMAT_SUPPORT Support = - { - DXGI_FORMAT_R11G11B10_FLOAT, D3D12_FORMAT_SUPPORT1_NONE, D3D12_FORMAT_SUPPORT2_NONE - }; - - if (SUCCEEDED(g_Device->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT, &Support, sizeof(Support))) && - (Support.Support2 & D3D12_FORMAT_SUPPORT2_UAV_TYPED_LOAD) != 0) - { - g_bTypedUAVLoadSupport_R11G11B10_FLOAT = true; - } - - Support.Format = DXGI_FORMAT_R16G16B16A16_FLOAT; - - if (SUCCEEDED(g_Device->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT, &Support, sizeof(Support))) && - (Support.Support2 & D3D12_FORMAT_SUPPORT2_UAV_TYPED_LOAD) != 0) - { - g_bTypedUAVLoadSupport_R16G16B16A16_FLOAT = true; - } - } - } - - g_CommandManager.Create(g_Device); - - // Common state was moved to GraphicsCommon.* - InitializeCommonState(); - - Display::Initialize(); - - GpuTimeManager::Initialize(4096); - - TemporalEffects::Initialize(); - PostEffects::Initialize(); - SSAO::Initialize(); - TextRenderer::Initialize(); - GraphRenderer::Initialize(); - ParticleEffectManager::Initialize(3840, 2160); -} - -void Graphics::Shutdown( void ) -{ - g_CommandManager.IdleGPU(); - - CommandContext::DestroyAllContexts(); - g_CommandManager.Shutdown(); - GpuTimeManager::Shutdown(); - PSO::DestroyAll(); - RootSignature::DestroyAll(); - DescriptorAllocator::DestroyAll(); - - DestroyCommonState(); - DestroyRenderingBuffers(); - - TemporalEffects::Shutdown(); - PostEffects::Shutdown(); - SSAO::Shutdown(); - TextRenderer::Shutdown(); - GraphRenderer::Shutdown(); - ParticleEffectManager::Shutdown(); - Display::Shutdown(); - -#if defined(_GAMING_DESKTOP) && defined(_DEBUG) - ID3D12DebugDevice* debugInterface; - if (SUCCEEDED(g_Device->QueryInterface(&debugInterface))) - { - debugInterface->ReportLiveDeviceObjects(D3D12_RLDO_DETAIL | D3D12_RLDO_IGNORE_INTERNAL); - debugInterface->Release(); - } -#endif - - if (g_Device != nullptr) - { - g_Device->Release(); - g_Device = nullptr; - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/GraphicsCore.h b/xess/samples/xess_demo/MiniEngine/Core/GraphicsCore.h deleted file mode 100644 index 90d00ba..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/GraphicsCore.h +++ /dev/null @@ -1,57 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -// Modified 2022, Intel Corporation. -// Added g_AdapterName to store adapter name. - -#pragma once - -#include "PipelineState.h" -#include "DescriptorHeap.h" -#include "RootSignature.h" -#include "GraphicsCommon.h" - -class CommandListManager; -class ContextManager; - -namespace Graphics -{ -#ifndef RELEASE - extern const GUID WKPDID_D3DDebugObjectName; -#endif - - extern std::string g_AdapterName; - - using namespace Microsoft::WRL; - - void Initialize(void); - void Shutdown(void); - - bool IsDeviceNvidia(ID3D12Device* pDevice); - bool IsDeviceAMD(ID3D12Device* pDevice); - bool IsDeviceIntel(ID3D12Device* pDevice); - - extern ID3D12Device* g_Device; - extern CommandListManager g_CommandManager; - extern ContextManager g_ContextManager; - - extern D3D_FEATURE_LEVEL g_D3DFeatureLevel; - extern bool g_bTypedUAVLoadSupport_R11G11B10_FLOAT; - extern bool g_bTypedUAVLoadSupport_R16G16B16A16_FLOAT; - - extern DescriptorAllocator g_DescriptorAllocator[]; - inline D3D12_CPU_DESCRIPTOR_HANDLE AllocateDescriptor( D3D12_DESCRIPTOR_HEAP_TYPE Type, UINT Count = 1 ) - { - return g_DescriptorAllocator[Type].Allocate(Count); - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Hash.h b/xess/samples/xess_demo/MiniEngine/Core/Hash.h deleted file mode 100644 index 11adf02..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Hash.h +++ /dev/null @@ -1,66 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard - -#pragma once - -#include "Math/Common.h" - -// This requires SSE4.2 which is present on Intel Nehalem (Nov. 2008) -// and AMD Bulldozer (Oct. 2011) processors. I could put a runtime -// check for this, but I'm just going to assume people playing with -// DirectX 12 on Windows 10 have fairly recent machines. -#ifdef _M_X64 -#define ENABLE_SSE_CRC32 1 -#else -#define ENABLE_SSE_CRC32 0 -#endif - -#if ENABLE_SSE_CRC32 -#pragma intrinsic(_mm_crc32_u32) -#pragma intrinsic(_mm_crc32_u64) -#endif - -namespace Utility -{ - inline size_t HashRange(const uint32_t* const Begin, const uint32_t* const End, size_t Hash) - { -#if ENABLE_SSE_CRC32 - const uint64_t* Iter64 = (const uint64_t*)Math::AlignUp(Begin, 8); - const uint64_t* const End64 = (const uint64_t* const)Math::AlignDown(End, 8); - - // If not 64-bit aligned, start with a single u32 - if ((uint32_t*)Iter64 > Begin) - Hash = _mm_crc32_u32((uint32_t)Hash, *Begin); - - // Iterate over consecutive u64 values - while (Iter64 < End64) - Hash = _mm_crc32_u64((uint64_t)Hash, *Iter64++); - - // If there is a 32-bit remainder, accumulate that - if ((uint32_t*)Iter64 < End) - Hash = _mm_crc32_u32((uint32_t)Hash, *(uint32_t*)Iter64); -#else - // An inexpensive hash for CPUs lacking SSE4.2 - for (const uint32_t* Iter = Begin; Iter < End; ++Iter) - Hash = 16777619U * Hash ^ *Iter; -#endif - - return Hash; - } - - template inline size_t HashState( const T* StateDesc, size_t Count = 1, size_t Hash = 2166136261U ) - { - static_assert((sizeof(T) & 3) == 0 && alignof(T) >= 4, "State object is not word-aligned"); - return HashRange((uint32_t*)StateDesc, (uint32_t*)(StateDesc + Count), Hash); - } - -} // namespace Utility diff --git a/xess/samples/xess_demo/MiniEngine/Core/IExtraRenderingBuffers.cpp b/xess/samples/xess_demo/MiniEngine/Core/IExtraRenderingBuffers.cpp deleted file mode 100644 index 93545e6..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/IExtraRenderingBuffers.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright 2021 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files(the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions : - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ - -#include "pch.h" -#include "IExtraRenderingBuffers.h" - -namespace Graphics -{ - IExtraRenderingBuffersHandler* g_RenderingCallback = nullptr; - - void SetExtraRenderingBuffersHandler(IExtraRenderingBuffersHandler* handler) - { - g_RenderingCallback = handler; - } - - Graphics::IExtraRenderingBuffersHandler* GetExtraRenderingBuffersHandler() - { - return g_RenderingCallback; - } - -} // namespace GameCore diff --git a/xess/samples/xess_demo/MiniEngine/Core/IExtraRenderingBuffers.h b/xess/samples/xess_demo/MiniEngine/Core/IExtraRenderingBuffers.h deleted file mode 100644 index b20b805..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/IExtraRenderingBuffers.h +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright 2021 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files(the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions : - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ - -#pragma once - -namespace Graphics -{ - class IExtraRenderingBuffersHandler - { - public: - virtual void InitializeBuffers(uint32_t NativeWidth, uint32_t NativeHeight, uint32_t UpscaledWidth, uint32_t UpscaledHeight) = 0; - virtual void DestroyRenderingBuffers() = 0; - }; - - void SetExtraRenderingBuffersHandler(IExtraRenderingBuffersHandler* handler); - - IExtraRenderingBuffersHandler* GetExtraRenderingBuffersHandler(); -} // namespace GameCore diff --git a/xess/samples/xess_demo/MiniEngine/Core/ImGuiModule.cpp b/xess/samples/xess_demo/MiniEngine/Core/ImGuiModule.cpp deleted file mode 100644 index 916045d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/ImGuiModule.cpp +++ /dev/null @@ -1,467 +0,0 @@ -/******************************************************************************* - * Copyright 2021 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files(the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions : - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ - -#include "pch.h" - -#include "ImGuiModule.h" -#include "ColorBuffer.h" -#include "BufferManager.h" -#include "CommandContext.h" -#include "GraphicsCore.h" -#include "Utility.h" -#include "Display.h" -#include "PipelineState.h" -#include "Math/Matrix4.h" -#include "CompiledShaders/ImGuiVS.h" -#include "CompiledShaders/ImGuiPS.h" - -#include "backends/imgui_impl_dx12.h" -#include "backends/imgui_impl_win32.h" -#include "imgui.h" - -namespace GameCore -{ - extern HWND g_hWnd; -} - -using namespace Math; -using namespace Graphics; -using namespace GameCore; - -// Forward declare message handler from imgui_impl_win32.cpp -extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); - -namespace ImGuiModule -{ - bool g_Initialized = false; - - // Image type to display in ImGui - enum ImImageType - { - ImImage_Texture = 0, - ImImage_ColorBuffer - }; - - struct FontInfo - { - std::string Path; - float Size; - bool Merge; - ImFont* Font; - }; - - // This lookup table is used to tell which type of GpuResource the image is. - std::map g_AllImageLUT; - - SamplerDesc s_SamplerDesc; - RootSignature s_RootSignature; - GraphicsPSO s_PSO(L"ImGui PSO"); - Texture g_FontTexture; - ByteAddressBuffer g_VertexBuffer; - ByteAddressBuffer g_IndexBuffer; - - const uint32_t VERTEX_BUFFER_INCREMENT = 5000 * sizeof(ImDrawVert); - const uint32_t INDEX_BUFFER_INCREMENT = 10000 * sizeof(ImDrawIdx); - - std::vector g_VertexBufferShadowData; - std::vector g_IndexBufferShadowData; - - Matrix4 g_ProjMatrix; - - std::vector g_AllFont; - - bool g_FontsDirty = false; - float g_DPIScale = 1.0f; - - void CreatePipeline(); - void PrepareFontTexture(); - void PrepareProjection(const ImDrawData& DrawData); - void PrepareGeometry(GraphicsContext& Context, const ImDrawData& DrawData); - void ApplyFontsChange(); -} // namespace ImGuiModule - -bool ImGuiModule::Initialize() -{ - ASSERT(g_hWnd); - if (!g_hWnd) - return false; - - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); - - io.ConfigFlags |= ImGuiConfigFlags_NavEnableSetMousePos; - - // Setup Dear ImGui style - ImGui::StyleColorsDark(); - - if (!ImGui_ImplWin32_Init(g_hWnd)) - { - LOG_ERROR("Could not initialize ImGui Renderer."); - return false; - } - - CreatePipeline(); - - LOG_INFO("ImGui Renderer Initialized."); - - g_Initialized = true; - - return true; -} - -bool ImGuiModule::IsIntialized() -{ - return g_Initialized; -} - -void ImGuiModule::Shutdown() -{ - if (!g_Initialized) - return; - - ImGui_ImplWin32_Shutdown(); - ImGui::DestroyContext(); - - g_FontTexture.Destroy(); - g_VertexBuffer.Destroy(); - g_IndexBuffer.Destroy(); - - g_Initialized = false; - - LOG_INFO("ImGui Renderer Shutdown."); -} - -uint32_t ImGuiModule::AddFont(const std::wstring& FontPath, float Size, bool Merge) -{ - std::string utf8Path = Utility::WideStringToUTF8(FontPath); - - FontInfo info = { utf8Path, Size, Merge, nullptr }; - g_AllFont.push_back(info); - - g_FontsDirty = true; - - return static_cast(g_AllFont.size() - 1); -} - -ImFont* ImGuiModule::GetFont(uint32_t Index) -{ - ASSERT(Index < g_AllFont.size()); - if (Index >= g_AllFont.size()) - return nullptr; - - return g_AllFont[Index].Font; -} - -void ImGuiModule::PrepareFontTexture() -{ - ImGuiIO& io = ImGui::GetIO(); - unsigned char* pixels; - int width, height; - io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); - - UINT pitchBytes = (width * 4 + D3D12_TEXTURE_DATA_PITCH_ALIGNMENT - 1u) & ~(D3D12_TEXTURE_DATA_PITCH_ALIGNMENT - 1u); - - g_FontTexture.Create2D(pitchBytes, width, height, DXGI_FORMAT_R8G8B8A8_UNORM, pixels); - - io.Fonts->SetTexID(&g_FontTexture); - io.Fonts->ClearTexData(); -} - -void ImGuiModule::PrepareGeometry(GraphicsContext& Context, const ImDrawData& DrawData) -{ - ScopedTimer _prof(L"ImGui Prepare Geometry", Context); - - const size_t totalVertexSize = Math::AlignUp(DrawData.TotalVtxCount * sizeof(ImDrawVert), 16); - const size_t totalIndexSize = Math::AlignUp(DrawData.TotalIdxCount * sizeof(ImDrawIdx), 16); - - if (g_VertexBuffer.GetBufferSize() < totalVertexSize - || g_IndexBuffer.GetBufferSize() < totalIndexSize) - { - g_CommandManager.IdleGPU(); - } - - if (g_VertexBuffer.GetBufferSize() < totalVertexSize) - { - g_VertexBuffer.Create(L"ImGui Vertex Buffer", - static_cast(Math::AlignUp(totalVertexSize + VERTEX_BUFFER_INCREMENT, 16)), 1); - } - - if (g_IndexBuffer.GetBufferSize() < totalIndexSize) - { - g_IndexBuffer.Create(L"ImGui Index Buffer", - static_cast(Math::AlignUp(totalIndexSize + INDEX_BUFFER_INCREMENT, 16)), 1); - } - - g_VertexBufferShadowData.resize(totalVertexSize); - g_IndexBufferShadowData.resize(totalIndexSize); - - ImDrawVert* vbPtr = reinterpret_cast(g_VertexBufferShadowData.data()); - ImDrawIdx* ibPtr = reinterpret_cast(g_IndexBufferShadowData.data()); - - for (int i = 0; i < DrawData.CmdListsCount; i++) - { - const ImDrawList* drawList = DrawData.CmdLists[i]; - - memcpy(vbPtr, drawList->VtxBuffer.Data, drawList->VtxBuffer.Size * sizeof(ImDrawVert)); - memcpy(ibPtr, drawList->IdxBuffer.Data, drawList->IdxBuffer.Size * sizeof(ImDrawIdx)); - - vbPtr += drawList->VtxBuffer.Size; - ibPtr += drawList->IdxBuffer.Size; - } - - Context.WriteBuffer(g_VertexBuffer, 0, g_VertexBufferShadowData.data(), totalVertexSize); - Context.WriteBuffer(g_IndexBuffer, 0, g_IndexBufferShadowData.data(), totalIndexSize); -} - -void ImGuiModule::CreatePipeline() -{ - // ImGui should be extended to support different texture samplings. - //s_SamplerDesc.Filter = D3D12_FILTER_MIN_MAG_MIP_LINEAR; - s_SamplerDesc.Filter = D3D12_FILTER_MIN_MAG_MIP_POINT; - s_SamplerDesc.MaxAnisotropy = 0; - s_SamplerDesc.ComparisonFunc = D3D12_COMPARISON_FUNC_ALWAYS; - s_SamplerDesc.SetBorderColor(Color(0.0f, 0.0f, 0.0f, 0.0f)); - s_SamplerDesc.MaxLOD = 0.0f; - - s_RootSignature.Reset(2, 1); - s_RootSignature.InitStaticSampler(0, s_SamplerDesc, D3D12_SHADER_VISIBILITY_PIXEL); - s_RootSignature[0].InitAsConstantBuffer(0, D3D12_SHADER_VISIBILITY_VERTEX); - s_RootSignature[1].InitAsDescriptorRange(D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 1, D3D12_SHADER_VISIBILITY_PIXEL); - s_RootSignature.Finalize(L"ImGui Renderer", D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT); - - D3D12_INPUT_ELEMENT_DESC vertElem[] = { - { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, pos), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, - { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, uv), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, - { "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (UINT)IM_OFFSETOF(ImDrawVert, col), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 } - }; - - s_PSO.SetRootSignature(s_RootSignature); - s_PSO.SetRasterizerState(Graphics::RasterizerTwoSided); - s_PSO.SetBlendState(Graphics::BlendTraditional); - s_PSO.SetDepthStencilState(Graphics::DepthStateDisabled); - s_PSO.SetInputLayout(_countof(vertElem), vertElem); - s_PSO.SetPrimitiveTopologyType(D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE); - s_PSO.SetVertexShader(g_pImGuiVS, sizeof(g_pImGuiVS)); - s_PSO.SetPixelShader(g_pImGuiPS, sizeof(g_pImGuiPS)); - s_PSO.SetRenderTargetFormats(1, &g_OverlayBuffer.GetFormat(), DXGI_FORMAT_UNKNOWN); - s_PSO.Finalize(); -} - -void ImGuiModule::ApplyFontsChange() -{ - float scale = Display::GetDPIScale(); - LOG_DEBUGF("ImGuiModule: Update font, DPI scale=%f", scale); - - ImGuiStyle& style = ImGui::GetStyle(); - style.ScaleAllSizes(scale / g_DPIScale); - - ImGuiIO& io = ImGui::GetIO(); - io.Fonts->Clear(); - - for (unsigned i = 0; i < g_AllFont.size(); ++i) - { - FontInfo& fontInfo = g_AllFont[i]; - - ImFontConfig config; - config.MergeMode = fontInfo.Merge; - config.FontDataOwnedByAtlas = false; - - ImFont* font = io.Fonts->AddFontFromFileTTF(fontInfo.Path.c_str(), fontInfo.Size * scale, &config, nullptr); - ASSERT(font); - if (!font) - continue; - - g_AllFont[i].Font = font; - } - - io.Fonts->Build(); - - PrepareFontTexture(); - g_DPIScale = scale; - g_FontsDirty = false; -} - -void ImGuiModule::PrepareProjection(const ImDrawData& DrawData) -{ - float L = DrawData.DisplayPos.x; - float R = DrawData.DisplayPos.x + DrawData.DisplaySize.x; - float T = DrawData.DisplayPos.y; - float B = DrawData.DisplayPos.y + DrawData.DisplaySize.y; - - g_ProjMatrix = Matrix4( - Vector4(2.0f / (R - L), 0.0f, 0.0f, 0.0f), - Vector4(0.0f, 2.0f / (T - B), 0.0f, 0.0f), - Vector4(0.0f, 0.0f, 0.5f, 0.0f), - Vector4((R + L) / (L - R), (T + B) / (B - T), 0.5f, 1.0f)); -} - -void ImGuiModule::PreGUI() -{ - if (!g_Initialized) - return; - - if (g_DPIScale != Display::GetDPIScale()) - { - g_FontsDirty = true; // if display DPI changed, mark font dirty. - } - - if (g_FontsDirty) - { - ApplyFontsChange(); - } - - ImGui_ImplWin32_NewFrame(); - - g_AllImageLUT.clear(); - g_AllImageLUT[&g_FontTexture] = ImImage_Texture; - - ImGui::NewFrame(); -} - -void ImGuiModule::PostGUI() -{ - if (!g_Initialized) - return; - - ImGui::Render(); -} - -void ImGuiModule::Render(GraphicsContext& Context) -{ - if (!g_Initialized) - return; - - ScopedTimer _prof(L"ImGui Render", Context); - - ImDrawData* drawData = ImGui::GetDrawData(); - if (!drawData || !drawData->CmdListsCount) - return; - - if (drawData->DisplaySize.x <= 0.0f || drawData->DisplaySize.y <= 0.0f) - return; - - PrepareGeometry(Context, *drawData); - - PrepareProjection(*drawData); - - { - ScopedTimer _prof_draw(L"ImGui Draw", Context); - - Context.SetRootSignature(s_RootSignature); - Context.SetPipelineState(s_PSO); - Context.TransitionResource(g_VertexBuffer, D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER); - Context.TransitionResource(g_IndexBuffer, D3D12_RESOURCE_STATE_INDEX_BUFFER); - Context.SetVertexBuffer(0, g_VertexBuffer.VertexBufferView(0, drawData->TotalVtxCount * sizeof(ImDrawVert), sizeof(ImDrawVert))); - Context.SetIndexBuffer(g_IndexBuffer.IndexBufferView()); - - Context.SetDynamicConstantBufferView(0, sizeof(g_ProjMatrix), &g_ProjMatrix); - Context.SetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - - int vertexOffset = 0; - int indexOffset = 0; - ImVec2 clip_off = drawData->DisplayPos; - for (int i = 0; i < drawData->CmdListsCount; i++) - { - const ImDrawList* drawList = drawData->CmdLists[i]; - for (int j = 0; j < drawList->CmdBuffer.Size; j++) - { - const ImDrawCmd* cmd = &drawList->CmdBuffer[j]; - if (cmd->UserCallback) - { - cmd->UserCallback(drawList, cmd); - } - else - { - ImVec2 minClip(cmd->ClipRect.x - clip_off.x, cmd->ClipRect.y - clip_off.y); - ImVec2 maxClip(cmd->ClipRect.z - clip_off.x, cmd->ClipRect.w - clip_off.y); - if (maxClip.x <= minClip.x || maxClip.y <= minClip.y) - continue; - - const D3D12_RECT r = { (LONG)minClip.x, (LONG)minClip.y, (LONG)maxClip.x, (LONG)maxClip.y }; - Context.SetScissor(r); - - ImTextureID texId = cmd->GetTexID(); - GpuResource* resource = static_cast(texId); - ASSERT(resource); - if (resource) - { - // Texture and ColorBuffer need a common GetSRV interface. - // Here, a lookup table is used to to tell the type of the resource. - auto iter = g_AllImageLUT.find(resource); - if (iter == g_AllImageLUT.end()) - continue; - - if (iter->second == ImImage_Texture) - { - Context.SetDynamicDescriptor(1, 0, static_cast(resource)->GetSRV()); - } - else - { - Context.SetDynamicDescriptor(1, 0, static_cast(resource)->GetSRV()); - } - - Context.TransitionResource(*resource, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - Context.DrawIndexedInstanced(cmd->ElemCount, 1, cmd->IdxOffset + indexOffset, cmd->VtxOffset + vertexOffset, 0); - } - } - } - - indexOffset += drawList->IdxBuffer.Size; - vertexOffset += drawList->VtxBuffer.Size; - } - } -} - -void ImGuiModule::RegisterImage(ColorBuffer& image) -{ - g_AllImageLUT[&image] = ImImage_ColorBuffer; -} - -bool ImGuiModule::WantCaptureKeyboard() -{ - if (!g_Initialized) - return false; - - return ImGui::GetIO().WantCaptureKeyboard; -} - -bool ImGuiModule::WantCaptureMouse() -{ - if (!g_Initialized) - return false; - - return ImGui::GetIO().WantCaptureMouse; -} - -void ImGuiModule::RegisterImage(Texture& image) -{ - g_AllImageLUT[&image] = ImImage_Texture; -} - -LRESULT ImGuiModule::WinProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - if (!g_Initialized) - return 0; - - return ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/ImGuiModule.h b/xess/samples/xess_demo/MiniEngine/Core/ImGuiModule.h deleted file mode 100644 index df2c134..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/ImGuiModule.h +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright 2021 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files(the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions : - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ - -#pragma once -class ColorBuffer; -class GraphicsContext; -class Texture; -struct ImFont; - -namespace ImGuiModule -{ - extern LRESULT WinProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); - - bool Initialize(); - - bool IsIntialized(); - - void Shutdown(); - - void PreGUI(); - - void PostGUI(); - - void Render(GraphicsContext& Context); - - /// Add a new font, returns an index for looking up the ImFont pointer later. - uint32_t AddFont(const std::wstring& FontPath, float Size, bool Merge); - - /// Get font by index. - ImFont* GetFont(uint32_t Index); - - /// Register ColorBuffer used as image before it is referenced by ImGui - void RegisterImage(ColorBuffer& image); - - /// Register Texture used as image before it is referenced by ImGui - void RegisterImage(Texture& image); - - /// Return if ImGui wants to capture keyboard. - bool WantCaptureKeyboard(); - - /// Return if ImGui wants to capture mouse. - bool WantCaptureMouse(); - -} // namespace ImGuiModule diff --git a/xess/samples/xess_demo/MiniEngine/Core/ImageScaling.cpp b/xess/samples/xess_demo/MiniEngine/Core/ImageScaling.cpp deleted file mode 100644 index a6c8718..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/ImageScaling.cpp +++ /dev/null @@ -1,332 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "ImageScaling.h" -#include "BufferManager.h" -#include "CommandContext.h" - -#include "CompiledShaders/ScreenQuadPresentVS.h" - -#include "CompiledShaders/BilinearUpsamplePS.h" -#include "CompiledShaders/BicubicHorizontalUpsamplePS.h" -#include "CompiledShaders/BicubicVerticalUpsamplePS.h" -#include "CompiledShaders/BicubicUpsampleCS.h" -#include "CompiledShaders/BicubicUpsampleFast16CS.h" -#include "CompiledShaders/BicubicUpsampleFast24CS.h" -#include "CompiledShaders/BicubicUpsampleFast32CS.h" -#include "CompiledShaders/SharpeningUpsamplePS.h" - -#include "CompiledShaders/LanczosHorizontalPS.h" -#include "CompiledShaders/LanczosVerticalPS.h" -#include "CompiledShaders/LanczosCS.h" -#include "CompiledShaders/LanczosFast16CS.h" -#include "CompiledShaders/LanczosFast24CS.h" -#include "CompiledShaders/LanczosFast32CS.h" - -using namespace Graphics; - -namespace Graphics -{ - extern RootSignature s_PresentRS; -} - -namespace ImageScaling -{ - GraphicsPSO SharpeningUpsamplePS(L"Image Scaling: Sharpen Upsample PSO"); - GraphicsPSO BicubicHorizontalUpsamplePS(L"Image Scaling: Bicubic Horizontal Upsample PSO"); - GraphicsPSO BicubicVerticalUpsamplePS(L"Image Scaling: Bicubic Vertical Upsample PSO"); - GraphicsPSO BilinearUpsamplePS(L"Image Scaling: Bilinear Upsample PSO"); - GraphicsPSO LanczosHorizontalPS(L"Image Scaling: Lanczos Horizontal PSO"); - GraphicsPSO LanczosVerticalPS(L"Image Scaling: Lanczos Vertical PSO"); - - enum { kDefaultCS, kFast16CS, kFast24CS, kFast32CS, kNumCSModes }; - ComputePSO LanczosCS[kNumCSModes]; - ComputePSO BicubicCS[kNumCSModes]; - - NumVar BicubicUpsampleWeight("Graphics/Display/Image Scaling/Bicubic Filter Weight", -0.5f, -1.0f, -0.25f, 0.25f); - NumVar SharpeningSpread("Graphics/Display/Image Scaling/Sharpness Sample Spread", 1.0f, 0.7f, 2.0f, 0.1f); - NumVar SharpeningRotation("Graphics/Display/Image Scaling/Sharpness Sample Rotation", 45.0f, 0.0f, 90.0f, 15.0f); - NumVar SharpeningStrength("Graphics/Display/Image Scaling/Sharpness Strength", 0.10f, 0.0f, 1.0f, 0.01f); - BoolVar ForcePixelShader("Graphics/Display/Image Scaling/Prefer Pixel Shader", false); - - void BilinearScale(GraphicsContext& Context, ColorBuffer& dest, ColorBuffer& source) - { - Context.SetPipelineState(BilinearUpsamplePS); - Context.TransitionResource(dest, D3D12_RESOURCE_STATE_RENDER_TARGET); - Context.TransitionResource(source, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - Context.SetRenderTarget(dest.GetRTV()); - Context.SetViewportAndScissor(0, 0, dest.GetWidth(), dest.GetHeight()); - Context.SetDynamicDescriptor(0, 0, source.GetSRV()); - Context.Draw(3); - } - - void BicubicScale(GraphicsContext& Context, ColorBuffer& dest, ColorBuffer& source) - { - // On Windows it is illegal to have a UAV of a swap chain buffer. In that case we - // must fall back to the slower, two-pass pixel shader. - bool bDestinationUAV = dest.GetUAV().ptr != D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN; - - // Draw or dispatch - if (bDestinationUAV && !ForcePixelShader) - { - ComputeContext& cmpCtx = Context.GetComputeContext(); - cmpCtx.SetRootSignature(s_PresentRS); - - const float scaleX = (float)source.GetWidth() / (float)dest.GetWidth(); - const float scaleY = (float)source.GetHeight() / (float)dest.GetHeight(); - cmpCtx.SetConstants(1, scaleX, scaleY, (float)BicubicUpsampleWeight); - - uint32_t tileWidth, tileHeight, shaderMode; - - if (source.GetWidth() * 16 <= dest.GetWidth() * 13 && - source.GetHeight() * 16 <= dest.GetHeight() * 13) - { - tileWidth = 16; - tileHeight = 16; - shaderMode = kFast16CS; - } - else if (source.GetWidth() * 24 <= dest.GetWidth() * 21 && - source.GetHeight() * 24 <= dest.GetHeight() * 21) - { - tileWidth = 32; // For some reason, occupancy drops with 24x24, reducing perf - tileHeight = 24; - shaderMode = kFast24CS; - } - else if (source.GetWidth() * 32 <= dest.GetWidth() * 29 && - source.GetHeight() * 32 <= dest.GetHeight() * 29) - { - tileWidth = 32; - tileHeight = 32; - shaderMode = kFast32CS; - } - else - { - tileWidth = 16; - tileHeight = 16; - shaderMode = kDefaultCS; - } - - cmpCtx.SetPipelineState(BicubicCS[shaderMode]); - cmpCtx.TransitionResource(source, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - cmpCtx.TransitionResource(dest, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - - cmpCtx.SetDynamicDescriptor(0, 0, source.GetSRV()); - cmpCtx.SetDynamicDescriptor(3, 0, dest.GetUAV()); - - cmpCtx.Dispatch2D(dest.GetWidth(), dest.GetHeight(), tileWidth, tileHeight); - } - else - { - Context.TransitionResource(g_HorizontalBuffer, D3D12_RESOURCE_STATE_RENDER_TARGET); - Context.SetRenderTarget(g_HorizontalBuffer.GetRTV()); - Context.SetViewportAndScissor(0, 0, dest.GetWidth(), source.GetHeight()); - Context.SetPipelineState(BicubicHorizontalUpsamplePS); - Context.SetConstants(1, source.GetWidth(), source.GetHeight(), (float)BicubicUpsampleWeight); - Context.Draw(3); - - Context.TransitionResource(g_HorizontalBuffer, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(dest, D3D12_RESOURCE_STATE_RENDER_TARGET); - Context.SetRenderTarget(dest.GetRTV()); - Context.SetViewportAndScissor(0, 0, dest.GetWidth(), dest.GetHeight()); - Context.SetPipelineState(BicubicVerticalUpsamplePS); - Context.SetConstants(1, dest.GetWidth(), source.GetHeight(), (float)BicubicUpsampleWeight); - Context.SetDynamicDescriptor(0, 0, g_HorizontalBuffer.GetSRV()); - Context.Draw(3); - } - } - - void BilinearSharpeningScale(GraphicsContext& Context, ColorBuffer& dest, ColorBuffer& source) - { - Context.SetPipelineState(SharpeningUpsamplePS); - Context.TransitionResource(dest, D3D12_RESOURCE_STATE_RENDER_TARGET); - Context.SetRenderTarget(dest.GetRTV()); - Context.SetViewportAndScissor(0, 0, dest.GetWidth(), dest.GetHeight()); - float TexelWidth = 1.0f / source.GetWidth(); - float TexelHeight = 1.0f / source.GetHeight(); - float X = Math::Cos((float)SharpeningRotation / 180.0f * 3.14159f) * (float)SharpeningSpread; - float Y = Math::Sin((float)SharpeningRotation / 180.0f * 3.14159f) * (float)SharpeningSpread; - const float WA = (float)SharpeningStrength; - const float WB = 1.0f + 4.0f * WA; - float Constants[] = { X * TexelWidth, Y * TexelHeight, Y * TexelWidth, -X * TexelHeight, WA, WB }; - Context.SetConstantArray(1, _countof(Constants), Constants); - Context.Draw(3); - } - - void LanczosScale(GraphicsContext& Context, ColorBuffer& dest, ColorBuffer& source) - { - // Constants - const float srcWidth = (float)source.GetWidth(); - const float srcHeight = (float)source.GetHeight(); - - // On Windows it is illegal to have a UAV of a swap chain buffer. In that case we - // must fall back to the slower, two-pass pixel shader. - bool bDestinationUAV = dest.GetUAV().ptr != D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN; - - // Draw or dispatch - if (bDestinationUAV && !ForcePixelShader) - { - ComputeContext& cmpCtx = Context.GetComputeContext(); - cmpCtx.SetRootSignature(s_PresentRS); - - const float scaleX = srcWidth / (float)dest.GetWidth(); - const float scaleY = srcHeight / (float)dest.GetHeight(); - cmpCtx.SetConstants(1, scaleX, scaleY); - - uint32_t tileWidth, tileHeight, shaderMode; - - if (source.GetWidth() * 16 <= dest.GetWidth() * 13 && - source.GetHeight() * 16 <= dest.GetHeight() * 13) - { - tileWidth = 16; - tileHeight = 16; - shaderMode = kFast16CS; - } - else if (source.GetWidth() * 24 <= dest.GetWidth() * 21 && - source.GetHeight() * 24 <= dest.GetHeight() * 21) - { - tileWidth = 32; // For some reason, occupancy drops with 24x24, reducing perf - tileHeight = 24; - shaderMode = kFast24CS; - } - else if (source.GetWidth() * 32 <= dest.GetWidth() * 29 && - source.GetHeight() * 32 <= dest.GetHeight() * 29) - { - tileWidth = 32; - tileHeight = 32; - shaderMode = kFast32CS; - } - else - { - tileWidth = 16; - tileHeight = 16; - shaderMode = kDefaultCS; - } - - cmpCtx.SetPipelineState(LanczosCS[shaderMode]); - cmpCtx.TransitionResource(source, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - cmpCtx.TransitionResource(dest, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - - cmpCtx.SetDynamicDescriptor(0, 0, source.GetSRV()); - cmpCtx.SetDynamicDescriptor(3, 0, dest.GetUAV()); - - cmpCtx.Dispatch2D(dest.GetWidth(), dest.GetHeight(), tileWidth, tileHeight); - } - else - { - Context.SetRootSignature(s_PresentRS); - Context.SetConstants(1, srcWidth, srcHeight); - Context.SetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - Context.TransitionResource(source, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(dest, D3D12_RESOURCE_STATE_RENDER_TARGET); - - Context.SetDynamicDescriptor(0, 0, source.GetSRV()); - - Context.TransitionResource(g_HorizontalBuffer, D3D12_RESOURCE_STATE_RENDER_TARGET); - Context.SetPipelineState(LanczosHorizontalPS); - Context.SetRenderTarget(g_HorizontalBuffer.GetRTV()); - Context.SetViewportAndScissor(0, 0, g_HorizontalBuffer.GetWidth(), source.GetHeight()); - Context.Draw(3); - - Context.TransitionResource(g_HorizontalBuffer, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - Context.SetPipelineState(LanczosVerticalPS); - Context.SetRenderTarget(dest.GetRTV()); - Context.SetViewportAndScissor(0, 0, dest.GetWidth(), dest.GetHeight()); - Context.SetDynamicDescriptor(0, 0, g_HorizontalBuffer.GetSRV()); - Context.Draw(3); - } - } -} - -void ImageScaling::Initialize(DXGI_FORMAT DestFormat ) -{ - BilinearUpsamplePS.SetRootSignature(s_PresentRS); - BilinearUpsamplePS.SetRasterizerState( RasterizerTwoSided ); - BilinearUpsamplePS.SetBlendState( BlendDisable ); - BilinearUpsamplePS.SetDepthStencilState( DepthStateDisabled ); - BilinearUpsamplePS.SetSampleMask(0xFFFFFFFF); - BilinearUpsamplePS.SetInputLayout(0, nullptr); - BilinearUpsamplePS.SetPrimitiveTopologyType(D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE); - BilinearUpsamplePS.SetVertexShader( g_pScreenQuadPresentVS, sizeof(g_pScreenQuadPresentVS) ); - BilinearUpsamplePS.SetPixelShader( g_pBilinearUpsamplePS, sizeof(g_pBilinearUpsamplePS) ); - BilinearUpsamplePS.SetRenderTargetFormat(DestFormat, DXGI_FORMAT_UNKNOWN); - BilinearUpsamplePS.Finalize(); - - BicubicHorizontalUpsamplePS = BilinearUpsamplePS; - BicubicHorizontalUpsamplePS.SetPixelShader(g_pBicubicHorizontalUpsamplePS, sizeof(g_pBicubicHorizontalUpsamplePS) ); - BicubicHorizontalUpsamplePS.SetRenderTargetFormat(g_HorizontalBuffer.GetFormat(), DXGI_FORMAT_UNKNOWN); - BicubicHorizontalUpsamplePS.Finalize(); - - BicubicVerticalUpsamplePS = BilinearUpsamplePS; - BicubicVerticalUpsamplePS.SetPixelShader(g_pBicubicVerticalUpsamplePS, sizeof(g_pBicubicVerticalUpsamplePS) ); - BicubicVerticalUpsamplePS.Finalize(); - - BicubicCS[kDefaultCS].SetRootSignature(s_PresentRS); - BicubicCS[kDefaultCS].SetComputeShader(g_pBicubicUpsampleCS, sizeof(g_pBicubicUpsampleCS)); - BicubicCS[kDefaultCS].Finalize(); - BicubicCS[kFast16CS].SetRootSignature(s_PresentRS); - BicubicCS[kFast16CS].SetComputeShader(g_pBicubicUpsampleFast16CS, sizeof(g_pBicubicUpsampleFast16CS)); - BicubicCS[kFast16CS].Finalize(); - BicubicCS[kFast24CS].SetRootSignature(s_PresentRS); - BicubicCS[kFast24CS].SetComputeShader(g_pBicubicUpsampleFast24CS, sizeof(g_pBicubicUpsampleFast24CS)); - BicubicCS[kFast24CS].Finalize(); - BicubicCS[kFast32CS].SetRootSignature(s_PresentRS); - BicubicCS[kFast32CS].SetComputeShader(g_pBicubicUpsampleFast32CS, sizeof(g_pBicubicUpsampleFast32CS)); - BicubicCS[kFast32CS].Finalize(); - - SharpeningUpsamplePS = BilinearUpsamplePS; - SharpeningUpsamplePS.SetPixelShader(g_pSharpeningUpsamplePS, sizeof(g_pSharpeningUpsamplePS) ); - SharpeningUpsamplePS.Finalize(); - - LanczosHorizontalPS = BicubicHorizontalUpsamplePS; - LanczosHorizontalPS.SetPixelShader(g_pLanczosHorizontalPS, sizeof(g_pLanczosHorizontalPS) ); - LanczosHorizontalPS.Finalize(); - - LanczosVerticalPS = BilinearUpsamplePS; - LanczosVerticalPS.SetPixelShader(g_pLanczosVerticalPS, sizeof(g_pLanczosVerticalPS) ); - LanczosVerticalPS.Finalize(); - - LanczosCS[kDefaultCS].SetRootSignature(s_PresentRS); - LanczosCS[kDefaultCS].SetComputeShader(g_pLanczosCS, sizeof(g_pLanczosCS)); - LanczosCS[kDefaultCS].Finalize(); - - LanczosCS[kFast16CS].SetRootSignature(s_PresentRS); - LanczosCS[kFast16CS].SetComputeShader(g_pLanczosFast16CS, sizeof(g_pLanczosFast16CS)); - LanczosCS[kFast16CS].Finalize(); - - LanczosCS[kFast24CS].SetRootSignature(s_PresentRS); - LanczosCS[kFast24CS].SetComputeShader(g_pLanczosFast24CS, sizeof(g_pLanczosFast24CS)); - LanczosCS[kFast24CS].Finalize(); - - LanczosCS[kFast32CS].SetRootSignature(s_PresentRS); - LanczosCS[kFast32CS].SetComputeShader(g_pLanczosFast32CS, sizeof(g_pLanczosFast32CS)); - LanczosCS[kFast32CS].Finalize(); -} - -void ImageScaling::Upscale(GraphicsContext& Context, ColorBuffer& dest, ColorBuffer& source, eScalingFilter tech) -{ - ScopedTimer _prof(L"Image Upscale", Context); - - Context.SetRootSignature(s_PresentRS); - Context.SetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - Context.TransitionResource(source, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - Context.SetDynamicDescriptor(0, 0, source.GetSRV()); - - switch (tech) - { - case kBicubic: return BicubicScale(Context, dest, source); - case kSharpening: return BilinearSharpeningScale(Context, dest, source); - case kBilinear: return BilinearScale(Context, dest, source); - case kLanczos: return LanczosScale(Context, dest, source); - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/ImageScaling.h b/xess/samples/xess_demo/MiniEngine/Core/ImageScaling.h deleted file mode 100644 index 1575c13..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/ImageScaling.h +++ /dev/null @@ -1,25 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// - -#pragma once - -class GraphicsContext; -class ColorBuffer; -enum DXGI_FORMAT; - -namespace ImageScaling -{ - void Initialize(DXGI_FORMAT DestFormat); - - enum eScalingFilter { kBilinear, kSharpening, kBicubic, kLanczos, kFilterCount }; - - void Upscale(GraphicsContext& Context, ColorBuffer& dest, ColorBuffer& source, eScalingFilter tech = kLanczos); -} \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Core/Input.cpp b/xess/samples/xess_demo/MiniEngine/Core/Input.cpp deleted file mode 100644 index eb65dbd..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Input.cpp +++ /dev/null @@ -1,460 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "GameCore.h" -#include "GameInput.h" - -#ifdef _GAMING_DESKTOP - -// I can't find the GameInput.h header in the GDK for Desktop yet -#include -#pragma comment(lib, "xinput9_1_0.lib") - -#define USE_KEYBOARD_MOUSE -#define DIRECTINPUT_VERSION 0x0800 -#include -#pragma comment(lib, "dinput8.lib") -#pragma comment(lib, "dxguid.lib") - -#else - -// This is what we should use on *all* platforms, but see previous comment -#include - -// This should be handled by GameInput.h, but we'll borrow values from XINPUT. -#define XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE (7849.0f / 32768.0f) -#define XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE (8689.0f / 32768.0f) - -#endif - -namespace GameCore -{ - extern HWND g_hWnd; -} - -namespace GameInput -{ - bool g_bMouseExclusive = true; -} - -namespace -{ - bool s_Buttons[2][GameInput::kNumDigitalInputs]; - float s_HoldDuration[GameInput::kNumDigitalInputs] = { 0.0f }; - float s_Analogs[GameInput::kNumAnalogInputs]; - float s_AnalogsTC[GameInput::kNumAnalogInputs]; - -#ifdef USE_KEYBOARD_MOUSE - - IDirectInput8A* s_DI; - IDirectInputDevice8A* s_Keyboard; - IDirectInputDevice8A* s_Mouse; - - DIMOUSESTATE2 s_MouseState; - unsigned char s_Keybuffer[256]; - unsigned char s_DXKeyMapping[GameInput::kNumKeys]; // map DigitalInput enum to DX key codes - -#endif - - inline float FilterAnalogInput( int val, int deadZone ) - { - if (val < 0) - { - if (val > -deadZone) - return 0.0f; - else - return (val + deadZone) / (32768.0f - deadZone); - } - else - { - if (val < deadZone) - return 0.0f; - else - return (val - deadZone) / (32767.0f - deadZone); - } - } - -#ifdef USE_KEYBOARD_MOUSE - void KbmBuildKeyMapping() - { - s_DXKeyMapping[GameInput::kKey_escape] = 1; - s_DXKeyMapping[GameInput::kKey_1] = 2; - s_DXKeyMapping[GameInput::kKey_2] = 3; - s_DXKeyMapping[GameInput::kKey_3] = 4; - s_DXKeyMapping[GameInput::kKey_4] = 5; - s_DXKeyMapping[GameInput::kKey_5] = 6; - s_DXKeyMapping[GameInput::kKey_6] = 7; - s_DXKeyMapping[GameInput::kKey_7] = 8; - s_DXKeyMapping[GameInput::kKey_8] = 9; - s_DXKeyMapping[GameInput::kKey_9] = 10; - s_DXKeyMapping[GameInput::kKey_0] = 11; - s_DXKeyMapping[GameInput::kKey_minus] = 12; - s_DXKeyMapping[GameInput::kKey_equals] = 13; - s_DXKeyMapping[GameInput::kKey_back] = 14; - s_DXKeyMapping[GameInput::kKey_tab] = 15; - s_DXKeyMapping[GameInput::kKey_q] = 16; - s_DXKeyMapping[GameInput::kKey_w] = 17; - s_DXKeyMapping[GameInput::kKey_e] = 18; - s_DXKeyMapping[GameInput::kKey_r] = 19; - s_DXKeyMapping[GameInput::kKey_t] = 20; - s_DXKeyMapping[GameInput::kKey_y] = 21; - s_DXKeyMapping[GameInput::kKey_u] = 22; - s_DXKeyMapping[GameInput::kKey_i] = 23; - s_DXKeyMapping[GameInput::kKey_o] = 24; - s_DXKeyMapping[GameInput::kKey_p] = 25; - s_DXKeyMapping[GameInput::kKey_lbracket] = 26; - s_DXKeyMapping[GameInput::kKey_rbracket] = 27; - s_DXKeyMapping[GameInput::kKey_return] = 28; - s_DXKeyMapping[GameInput::kKey_lcontrol] = 29; - s_DXKeyMapping[GameInput::kKey_a] = 30; - s_DXKeyMapping[GameInput::kKey_s] = 31; - s_DXKeyMapping[GameInput::kKey_d] = 32; - s_DXKeyMapping[GameInput::kKey_f] = 33; - s_DXKeyMapping[GameInput::kKey_g] = 34; - s_DXKeyMapping[GameInput::kKey_h] = 35; - s_DXKeyMapping[GameInput::kKey_j] = 36; - s_DXKeyMapping[GameInput::kKey_k] = 37; - s_DXKeyMapping[GameInput::kKey_l] = 38; - s_DXKeyMapping[GameInput::kKey_semicolon] = 39; - s_DXKeyMapping[GameInput::kKey_apostrophe] = 40; - s_DXKeyMapping[GameInput::kKey_grave] = 41; - s_DXKeyMapping[GameInput::kKey_lshift] = 42; - s_DXKeyMapping[GameInput::kKey_backslash] = 43; - s_DXKeyMapping[GameInput::kKey_z] = 44; - s_DXKeyMapping[GameInput::kKey_x] = 45; - s_DXKeyMapping[GameInput::kKey_c] = 46; - s_DXKeyMapping[GameInput::kKey_v] = 47; - s_DXKeyMapping[GameInput::kKey_b] = 48; - s_DXKeyMapping[GameInput::kKey_n] = 49; - s_DXKeyMapping[GameInput::kKey_m] = 50; - s_DXKeyMapping[GameInput::kKey_comma] = 51; - s_DXKeyMapping[GameInput::kKey_period] = 52; - s_DXKeyMapping[GameInput::kKey_slash] = 53; - s_DXKeyMapping[GameInput::kKey_rshift] = 54; - s_DXKeyMapping[GameInput::kKey_multiply] = 55; - s_DXKeyMapping[GameInput::kKey_lalt] = 56; - s_DXKeyMapping[GameInput::kKey_space] = 57; - s_DXKeyMapping[GameInput::kKey_capital] = 58; - s_DXKeyMapping[GameInput::kKey_f1] = 59; - s_DXKeyMapping[GameInput::kKey_f2] = 60; - s_DXKeyMapping[GameInput::kKey_f3] = 61; - s_DXKeyMapping[GameInput::kKey_f4] = 62; - s_DXKeyMapping[GameInput::kKey_f5] = 63; - s_DXKeyMapping[GameInput::kKey_f6] = 64; - s_DXKeyMapping[GameInput::kKey_f7] = 65; - s_DXKeyMapping[GameInput::kKey_f8] = 66; - s_DXKeyMapping[GameInput::kKey_f9] = 67; - s_DXKeyMapping[GameInput::kKey_f10] = 68; - s_DXKeyMapping[GameInput::kKey_numlock] = 69; - s_DXKeyMapping[GameInput::kKey_scroll] = 70; - s_DXKeyMapping[GameInput::kKey_numpad7] = 71; - s_DXKeyMapping[GameInput::kKey_numpad8] = 72; - s_DXKeyMapping[GameInput::kKey_numpad9] = 73; - s_DXKeyMapping[GameInput::kKey_subtract] = 74; - s_DXKeyMapping[GameInput::kKey_numpad4] = 75; - s_DXKeyMapping[GameInput::kKey_numpad5] = 76; - s_DXKeyMapping[GameInput::kKey_numpad6] = 77; - s_DXKeyMapping[GameInput::kKey_add] = 78; - s_DXKeyMapping[GameInput::kKey_numpad1] = 79; - s_DXKeyMapping[GameInput::kKey_numpad2] = 80; - s_DXKeyMapping[GameInput::kKey_numpad3] = 81; - s_DXKeyMapping[GameInput::kKey_numpad0] = 82; - s_DXKeyMapping[GameInput::kKey_decimal] = 83; - s_DXKeyMapping[GameInput::kKey_f11] = 87; - s_DXKeyMapping[GameInput::kKey_f12] = 88; - s_DXKeyMapping[GameInput::kKey_numpadenter] = 156; - s_DXKeyMapping[GameInput::kKey_rcontrol] = 157; - s_DXKeyMapping[GameInput::kKey_divide] = 181; - s_DXKeyMapping[GameInput::kKey_sysrq] = 183; - s_DXKeyMapping[GameInput::kKey_ralt] = 184; - s_DXKeyMapping[GameInput::kKey_pause] = 197; - s_DXKeyMapping[GameInput::kKey_home] = 199; - s_DXKeyMapping[GameInput::kKey_up] = 200; - s_DXKeyMapping[GameInput::kKey_pgup] = 201; - s_DXKeyMapping[GameInput::kKey_left] = 203; - s_DXKeyMapping[GameInput::kKey_right] = 205; - s_DXKeyMapping[GameInput::kKey_end] = 207; - s_DXKeyMapping[GameInput::kKey_down] = 208; - s_DXKeyMapping[GameInput::kKey_pgdn] = 209; - s_DXKeyMapping[GameInput::kKey_insert] = 210; - s_DXKeyMapping[GameInput::kKey_delete] = 211; - s_DXKeyMapping[GameInput::kKey_lwin] = 219; - s_DXKeyMapping[GameInput::kKey_rwin] = 220; - s_DXKeyMapping[GameInput::kKey_apps] = 221; - } - - void KbmZeroInputs() - { - memset(&s_MouseState, 0, sizeof(DIMOUSESTATE2)); - memset(s_Keybuffer, 0, sizeof(s_Keybuffer)); - } - - void KbmInitialize() - { - KbmBuildKeyMapping(); - - if (FAILED(DirectInput8Create(GetModuleHandle(nullptr), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&s_DI, nullptr))) - ASSERT(false, "DirectInput8 initialization failed."); - - if (FAILED(s_DI->CreateDevice(GUID_SysKeyboard, &s_Keyboard, nullptr))) - ASSERT(false, "Keyboard CreateDevice failed."); - if (FAILED(s_Keyboard->SetDataFormat(&c_dfDIKeyboard))) - ASSERT(false, "Keyboard SetDataFormat failed."); - if (FAILED(s_Keyboard->SetCooperativeLevel(GameCore::g_hWnd, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE))) - ASSERT(false, "Keyboard SetCooperativeLevel failed."); - - DIPROPDWORD dipdw; - dipdw.diph.dwSize = sizeof(DIPROPDWORD); - dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); - dipdw.diph.dwObj = 0; - dipdw.diph.dwHow = DIPH_DEVICE; - dipdw.dwData = 10; - if (FAILED(s_Keyboard->SetProperty(DIPROP_BUFFERSIZE, &dipdw.diph))) - ASSERT(false, "Keyboard set buffer size failed."); - - if (FAILED(s_DI->CreateDevice(GUID_SysMouse, &s_Mouse, nullptr))) - ASSERT(false, "Mouse CreateDevice failed."); - if (FAILED(s_Mouse->SetDataFormat(&c_dfDIMouse2))) - ASSERT(false, "Mouse SetDataFormat failed."); - - if (GameInput::g_bMouseExclusive) - { - if (FAILED(s_Mouse->SetCooperativeLevel(GameCore::g_hWnd, DISCL_FOREGROUND | DISCL_EXCLUSIVE))) - ASSERT(false, "Mouse SetCooperativeLevel failed."); - } - else - { - if (FAILED(s_Mouse->SetCooperativeLevel(GameCore::g_hWnd, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE))) - ASSERT(false, "Mouse SetCooperativeLevel failed."); - } - - KbmZeroInputs(); - } - - void KbmShutdown() - { - if (s_Keyboard) - { - s_Keyboard->Unacquire(); - s_Keyboard->Release(); - s_Keyboard = nullptr; - } - if (s_Mouse) - { - s_Mouse->Unacquire(); - s_Mouse->Release(); - s_Mouse = nullptr; - } - if (s_DI) - { - s_DI->Release(); - s_DI = nullptr; - } - } - - void KbmUpdate() - { - HWND foreground = GetForegroundWindow(); - bool visible = IsWindowVisible(foreground) != 0; - - if (foreground != GameCore::g_hWnd // wouldn't be able to acquire - || !visible) - { - KbmZeroInputs(); - } - else - { - s_Mouse->Acquire(); - s_Mouse->GetDeviceState(sizeof(DIMOUSESTATE2), &s_MouseState); - s_Keyboard->Acquire(); - s_Keyboard->GetDeviceState(sizeof(s_Keybuffer), s_Keybuffer); - } - } - -#endif - -} - -void GameInput::Initialize() -{ - ZeroMemory(s_Buttons, sizeof(s_Buttons) ); - ZeroMemory(s_Analogs, sizeof(s_Analogs) ); - -#ifdef USE_KEYBOARD_MOUSE - KbmInitialize(); -#endif -} - -void GameInput::Shutdown() -{ -#ifdef USE_KEYBOARD_MOUSE - KbmShutdown(); -#endif -} - -void GameInput::Update( float frameDelta ) -{ - memcpy(s_Buttons[1], s_Buttons[0], sizeof(s_Buttons[0])); - memset(s_Buttons[0], 0, sizeof(s_Buttons[0])); - memset(s_Analogs, 0, sizeof(s_Analogs)); - -#ifdef _GAMING_DESKTOP - -#define SET_BUTTON_VALUE(InputEnum, GameInputMask) \ - s_Buttons[0][InputEnum] = !!(newInputState.Gamepad.wButtons & GameInputMask); - - XINPUT_STATE newInputState; - if (ERROR_SUCCESS == XInputGetState(0, &newInputState)) - { - SET_BUTTON_VALUE(kDPadUp, XINPUT_GAMEPAD_DPAD_UP); - SET_BUTTON_VALUE(kDPadDown, XINPUT_GAMEPAD_DPAD_DOWN); - SET_BUTTON_VALUE(kDPadLeft, XINPUT_GAMEPAD_DPAD_LEFT); - SET_BUTTON_VALUE(kDPadRight, XINPUT_GAMEPAD_DPAD_RIGHT); - SET_BUTTON_VALUE(kStartButton, XINPUT_GAMEPAD_START); - SET_BUTTON_VALUE(kBackButton, XINPUT_GAMEPAD_BACK); - SET_BUTTON_VALUE(kLThumbClick, XINPUT_GAMEPAD_LEFT_THUMB); - SET_BUTTON_VALUE(kRThumbClick, XINPUT_GAMEPAD_RIGHT_THUMB); - SET_BUTTON_VALUE(kLShoulder, XINPUT_GAMEPAD_LEFT_SHOULDER); - SET_BUTTON_VALUE(kRShoulder, XINPUT_GAMEPAD_RIGHT_SHOULDER); - SET_BUTTON_VALUE(kAButton, XINPUT_GAMEPAD_A); - SET_BUTTON_VALUE(kBButton, XINPUT_GAMEPAD_B); - SET_BUTTON_VALUE(kXButton, XINPUT_GAMEPAD_X); - SET_BUTTON_VALUE(kYButton, XINPUT_GAMEPAD_Y); - - s_Analogs[kAnalogLeftTrigger] = newInputState.Gamepad.bLeftTrigger / 255.0f; - s_Analogs[kAnalogRightTrigger] = newInputState.Gamepad.bRightTrigger / 255.0f; - s_Analogs[kAnalogLeftStickX] = FilterAnalogInput(newInputState.Gamepad.sThumbLX, XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE ); - s_Analogs[kAnalogLeftStickY] = FilterAnalogInput(newInputState.Gamepad.sThumbLY, XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE ); - s_Analogs[kAnalogRightStickX] = FilterAnalogInput(newInputState.Gamepad.sThumbRX, XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE ); - s_Analogs[kAnalogRightStickY] = FilterAnalogInput(newInputState.Gamepad.sThumbRY, XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE ); - } -#else - IGameInputReading* pGIR = nullptr; - if (s_pGameInput != nullptr) - s_pGameInput->GetCurrentReading(GameInputKindGamepad, nullptr, &pGIR); - bool IsGamepadPresent = (pGIR != nullptr); - - if (IsGamepadPresent) - { - GameInputGamepadState newInputState; - pGIR->GetGamepadState(&newInputState); - pGIR->Release(); - -#define SET_BUTTON_VALUE(InputEnum, GameInputMask) \ - s_Buttons[0][InputEnum] = !!(newInputState.buttons & GameInputMask); - - SET_BUTTON_VALUE(kDPadUp, GameInputGamepadDPadUp); - SET_BUTTON_VALUE(kDPadDown, GameInputGamepadDPadDown); - SET_BUTTON_VALUE(kDPadLeft, GameInputGamepadDPadLeft); - SET_BUTTON_VALUE(kDPadRight, GameInputGamepadDPadRight); - SET_BUTTON_VALUE(kStartButton, GameInputGamepadMenu); - SET_BUTTON_VALUE(kBackButton, GameInputGamepadView); - SET_BUTTON_VALUE(kLThumbClick, GameInputGamepadLeftThumbstick); - SET_BUTTON_VALUE(kRThumbClick, GameInputGamepadRightThumbstick); - SET_BUTTON_VALUE(kLShoulder, GameInputGamepadLeftShoulder); - SET_BUTTON_VALUE(kRShoulder, GameInputGamepadRightShoulder); - SET_BUTTON_VALUE(kAButton, GameInputGamepadA); - SET_BUTTON_VALUE(kBButton, GameInputGamepadB); - SET_BUTTON_VALUE(kXButton, GameInputGamepadX); - SET_BUTTON_VALUE(kYButton, GameInputGamepadY); - - s_Analogs[kAnalogLeftTrigger] = newInputState.leftTrigger; - s_Analogs[kAnalogRightTrigger] = newInputState.rightTrigger; - s_Analogs[kAnalogLeftStickX] = FilterAnalogInput(newInputState.leftThumbstickX, XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE); - s_Analogs[kAnalogLeftStickY] = FilterAnalogInput(newInputState.leftThumbstickY, XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE); - s_Analogs[kAnalogRightStickX] = FilterAnalogInput(newInputState.rightThumbstickX, XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE); - s_Analogs[kAnalogRightStickY] = FilterAnalogInput(newInputState.rightThumbstickY, XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE); - } -#endif - -#ifdef USE_KEYBOARD_MOUSE - KbmUpdate(); - - for (uint32_t i = 0; i < kNumKeys; ++i) - { - s_Buttons[0][i] = (s_Keybuffer[s_DXKeyMapping[i]] & 0x80) != 0; - } - - for (uint32_t i = 0; i < 8; ++i) - { - if (s_MouseState.rgbButtons[i] > 0) s_Buttons[0][kMouse0 + i] = true; - } - - s_Analogs[kAnalogMouseX] = (float)s_MouseState.lX * .0018f; - s_Analogs[kAnalogMouseY] = (float)s_MouseState.lY * -.0018f; - - if (s_MouseState.lZ > 0) - s_Analogs[kAnalogMouseScroll] = 1.0f; - else if (s_MouseState.lZ < 0) - s_Analogs[kAnalogMouseScroll] = -1.0f; -#endif - - // Update time duration for buttons pressed - for (uint32_t i = 0; i < kNumDigitalInputs; ++i) - { - if (s_Buttons[0][i]) - { - if (!s_Buttons[1][i]) - s_HoldDuration[i] = 0.0f; - else - s_HoldDuration[i] += frameDelta; - } - } - - for (uint32_t i = 0; i < kNumAnalogInputs; ++i) - { - s_AnalogsTC[i] = s_Analogs[i] * frameDelta; - } - -} - -bool GameInput::IsAnyPressed( void ) -{ - return s_Buttons[0] != 0; -} - -bool GameInput::IsPressed( DigitalInput di ) -{ - return s_Buttons[0][di]; -} - -bool GameInput::IsFirstPressed( DigitalInput di ) -{ - return s_Buttons[0][di] && !s_Buttons[1][di]; -} - -bool GameInput::IsReleased( DigitalInput di ) -{ - return !s_Buttons[0][di]; -} - -bool GameInput::IsFirstReleased( DigitalInput di ) -{ - return !s_Buttons[0][di] && s_Buttons[1][di]; -} - -float GameInput::GetDurationPressed( DigitalInput di ) -{ - return s_HoldDuration[di]; -} - -float GameInput::GetAnalogInput( AnalogInput ai ) -{ - return s_Analogs[ai]; -} - -float GameInput::GetTimeCorrectedAnalogInput( AnalogInput ai ) -{ - return s_AnalogsTC[ai]; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/LinearAllocator.cpp b/xess/samples/xess_demo/MiniEngine/Core/LinearAllocator.cpp deleted file mode 100644 index cf8e846..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/LinearAllocator.cpp +++ /dev/null @@ -1,193 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// Alex Nankervis -// - -#include "pch.h" -#include "LinearAllocator.h" -#include "GraphicsCore.h" -#include "CommandListManager.h" -#include - -using namespace Graphics; -using namespace std; - -LinearAllocatorType LinearAllocatorPageManager::sm_AutoType = kGpuExclusive; - -LinearAllocatorPageManager::LinearAllocatorPageManager() -{ - m_AllocationType = sm_AutoType; - sm_AutoType = (LinearAllocatorType)(sm_AutoType + 1); - ASSERT(sm_AutoType <= kNumAllocatorTypes); -} - -LinearAllocatorPageManager LinearAllocator::sm_PageManager[2]; - -LinearAllocationPage* LinearAllocatorPageManager::RequestPage() -{ - lock_guard LockGuard(m_Mutex); - - while (!m_RetiredPages.empty() && g_CommandManager.IsFenceComplete(m_RetiredPages.front().first)) - { - m_AvailablePages.push(m_RetiredPages.front().second); - m_RetiredPages.pop(); - } - - LinearAllocationPage* PagePtr = nullptr; - - if (!m_AvailablePages.empty()) - { - PagePtr = m_AvailablePages.front(); - m_AvailablePages.pop(); - } - else - { - PagePtr = CreateNewPage(); - m_PagePool.emplace_back(PagePtr); - } - - return PagePtr; -} - -void LinearAllocatorPageManager::DiscardPages( uint64_t FenceValue, const vector& UsedPages ) -{ - lock_guard LockGuard(m_Mutex); - for (auto iter = UsedPages.begin(); iter != UsedPages.end(); ++iter) - m_RetiredPages.push(make_pair(FenceValue, *iter)); -} - -void LinearAllocatorPageManager::FreeLargePages( uint64_t FenceValue, const vector& LargePages ) -{ - lock_guard LockGuard(m_Mutex); - - while (!m_DeletionQueue.empty() && g_CommandManager.IsFenceComplete(m_DeletionQueue.front().first)) - { - delete m_DeletionQueue.front().second; - m_DeletionQueue.pop(); - } - - for (auto iter = LargePages.begin(); iter != LargePages.end(); ++iter) - { - (*iter)->Unmap(); - m_DeletionQueue.push(make_pair(FenceValue, *iter)); - } -} - -LinearAllocationPage* LinearAllocatorPageManager::CreateNewPage( size_t PageSize ) -{ - D3D12_HEAP_PROPERTIES HeapProps; - HeapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; - HeapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; - HeapProps.CreationNodeMask = 1; - HeapProps.VisibleNodeMask = 1; - - D3D12_RESOURCE_DESC ResourceDesc; - ResourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; - ResourceDesc.Alignment = 0; - ResourceDesc.Height = 1; - ResourceDesc.DepthOrArraySize = 1; - ResourceDesc.MipLevels = 1; - ResourceDesc.Format = DXGI_FORMAT_UNKNOWN; - ResourceDesc.SampleDesc.Count = 1; - ResourceDesc.SampleDesc.Quality = 0; - ResourceDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; - - D3D12_RESOURCE_STATES DefaultUsage; - - if (m_AllocationType == kGpuExclusive) - { - HeapProps.Type = D3D12_HEAP_TYPE_DEFAULT; - ResourceDesc.Width = PageSize == 0 ? kGpuAllocatorPageSize : PageSize; - ResourceDesc.Flags = D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; - DefaultUsage = D3D12_RESOURCE_STATE_UNORDERED_ACCESS; - } - else - { - HeapProps.Type = D3D12_HEAP_TYPE_UPLOAD; - ResourceDesc.Width = PageSize == 0 ? kCpuAllocatorPageSize : PageSize; - ResourceDesc.Flags = D3D12_RESOURCE_FLAG_NONE; - DefaultUsage = D3D12_RESOURCE_STATE_GENERIC_READ; - } - - ID3D12Resource* pBuffer; - ASSERT_SUCCEEDED( g_Device->CreateCommittedResource(&HeapProps, D3D12_HEAP_FLAG_NONE, - &ResourceDesc, DefaultUsage, nullptr, MY_IID_PPV_ARGS(&pBuffer)) ); - - pBuffer->SetName(L"LinearAllocator Page"); - - return new LinearAllocationPage(pBuffer, DefaultUsage); -} - -void LinearAllocator::CleanupUsedPages( uint64_t FenceID ) -{ - if (m_CurPage == nullptr) - return; - - m_RetiredPages.push_back(m_CurPage); - m_CurPage = nullptr; - m_CurOffset = 0; - - sm_PageManager[m_AllocationType].DiscardPages(FenceID, m_RetiredPages); - m_RetiredPages.clear(); - - sm_PageManager[m_AllocationType].FreeLargePages(FenceID, m_LargePageList); - m_LargePageList.clear(); -} - -DynAlloc LinearAllocator::AllocateLargePage(size_t SizeInBytes) -{ - LinearAllocationPage* OneOff = sm_PageManager[m_AllocationType].CreateNewPage(SizeInBytes); - m_LargePageList.push_back(OneOff); - - DynAlloc ret(*OneOff, 0, SizeInBytes); - ret.DataPtr = OneOff->m_CpuVirtualAddress; - ret.GpuAddress = OneOff->m_GpuVirtualAddress; - - return ret; -} - -DynAlloc LinearAllocator::Allocate(size_t SizeInBytes, size_t Alignment) -{ - const size_t AlignmentMask = Alignment - 1; - - // Assert that it's a power of two. - ASSERT((AlignmentMask & Alignment) == 0); - - // Align the allocation - const size_t AlignedSize = Math::AlignUpWithMask(SizeInBytes, AlignmentMask); - - if (AlignedSize > m_PageSize) - return AllocateLargePage(AlignedSize); - - m_CurOffset = Math::AlignUp(m_CurOffset, Alignment); - - if (m_CurOffset + AlignedSize > m_PageSize) - { - ASSERT(m_CurPage != nullptr); - m_RetiredPages.push_back(m_CurPage); - m_CurPage = nullptr; - } - - if (m_CurPage == nullptr) - { - m_CurPage = sm_PageManager[m_AllocationType].RequestPage(); - m_CurOffset = 0; - } - - DynAlloc ret(*m_CurPage, m_CurOffset, AlignedSize); - ret.DataPtr = (uint8_t*)m_CurPage->m_CpuVirtualAddress + m_CurOffset; - ret.GpuAddress = m_CurPage->m_GpuVirtualAddress + m_CurOffset; - - m_CurOffset += AlignedSize; - - return ret; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/LinearAllocator.h b/xess/samples/xess_demo/MiniEngine/Core/LinearAllocator.h deleted file mode 100644 index 2578688..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/LinearAllocator.h +++ /dev/null @@ -1,160 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// -// Description: This is a dynamic graphics memory allocator for DX12. It's designed to work in concert -// with the CommandContext class and to do so in a thread-safe manner. There may be many command contexts, -// each with its own linear allocators. They act as windows into a global memory pool by reserving a -// context-local memory page. Requesting a new page is done in a thread-safe manner by guarding accesses -// with a mutex lock. -// -// When a command context is finished, it will receive a fence ID that indicates when it's safe to reclaim -// used resources. The CleanupUsedPages() method must be invoked at this time so that the used pages can be -// scheduled for reuse after the fence has cleared. - -#pragma once - -#include "GpuResource.h" -#include -#include -#include - -// Constant blocks must be multiples of 16 constants @ 16 bytes each -#define DEFAULT_ALIGN 256 - -// Various types of allocations may contain NULL pointers. Check before dereferencing if you are unsure. -struct DynAlloc -{ - DynAlloc(GpuResource& BaseResource, size_t ThisOffset, size_t ThisSize) - : Buffer(BaseResource), Offset(ThisOffset), Size(ThisSize) {} - - GpuResource& Buffer; // The D3D buffer associated with this memory. - size_t Offset; // Offset from start of buffer resource - size_t Size; // Reserved size of this allocation - void* DataPtr; // The CPU-writeable address - D3D12_GPU_VIRTUAL_ADDRESS GpuAddress; // The GPU-visible address -}; - -class LinearAllocationPage : public GpuResource -{ -public: - LinearAllocationPage(ID3D12Resource* pResource, D3D12_RESOURCE_STATES Usage) : GpuResource() - { - m_pResource.Attach(pResource); - m_UsageState = Usage; - m_GpuVirtualAddress = m_pResource->GetGPUVirtualAddress(); - m_pResource->Map(0, nullptr, &m_CpuVirtualAddress); - } - - ~LinearAllocationPage() - { - Unmap(); - } - - void Map(void) - { - if (m_CpuVirtualAddress == nullptr) - { - m_pResource->Map(0, nullptr, &m_CpuVirtualAddress); - } - } - - void Unmap(void) - { - if (m_CpuVirtualAddress != nullptr) - { - m_pResource->Unmap(0, nullptr); - m_CpuVirtualAddress = nullptr; - } - } - - void* m_CpuVirtualAddress; - D3D12_GPU_VIRTUAL_ADDRESS m_GpuVirtualAddress; -}; - -enum LinearAllocatorType -{ - kInvalidAllocator = -1, - - kGpuExclusive = 0, // DEFAULT GPU-writeable (via UAV) - kCpuWritable = 1, // UPLOAD CPU-writeable (but write combined) - - kNumAllocatorTypes -}; - -enum -{ - kGpuAllocatorPageSize = 0x10000, // 64K - kCpuAllocatorPageSize = 0x200000 // 2MB -}; - -class LinearAllocatorPageManager -{ -public: - - LinearAllocatorPageManager(); - LinearAllocationPage* RequestPage( void ); - LinearAllocationPage* CreateNewPage( size_t PageSize = 0 ); - - // Discarded pages will get recycled. This is for fixed size pages. - void DiscardPages( uint64_t FenceID, const std::vector& Pages ); - - // Freed pages will be destroyed once their fence has passed. This is for single-use, - // "large" pages. - void FreeLargePages( uint64_t FenceID, const std::vector& Pages ); - - void Destroy( void ) { m_PagePool.clear(); } - -private: - - static LinearAllocatorType sm_AutoType; - - LinearAllocatorType m_AllocationType; - std::vector > m_PagePool; - std::queue > m_RetiredPages; - std::queue > m_DeletionQueue; - std::queue m_AvailablePages; - std::mutex m_Mutex; -}; - -class LinearAllocator -{ -public: - - LinearAllocator(LinearAllocatorType Type) : m_AllocationType(Type), m_PageSize(0), m_CurOffset(~(size_t)0), m_CurPage(nullptr) - { - ASSERT(Type > kInvalidAllocator && Type < kNumAllocatorTypes); - m_PageSize = (Type == kGpuExclusive ? kGpuAllocatorPageSize : kCpuAllocatorPageSize); - } - - DynAlloc Allocate( size_t SizeInBytes, size_t Alignment = DEFAULT_ALIGN ); - - void CleanupUsedPages( uint64_t FenceID ); - - static void DestroyAll( void ) - { - sm_PageManager[0].Destroy(); - sm_PageManager[1].Destroy(); - } - -private: - - DynAlloc AllocateLargePage( size_t SizeInBytes ); - - static LinearAllocatorPageManager sm_PageManager[2]; - - LinearAllocatorType m_AllocationType; - size_t m_PageSize; - size_t m_CurOffset; - LinearAllocationPage* m_CurPage; - std::vector m_RetiredPages; - std::vector m_LargePageList; -}; diff --git a/xess/samples/xess_demo/MiniEngine/Core/Log.cpp b/xess/samples/xess_demo/MiniEngine/Core/Log.cpp deleted file mode 100644 index 8e29692..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Log.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * Copyright 2021 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files(the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions : - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ - -#include "pch.h" -#include "Log.h" -#include - -static Log* gInstance = nullptr; -static uint32_t gMainThreadId = 0; - -Log::Log() - : m_Level(LevelInfo) -{ - gInstance = this; // Initialize instance pointer. - - // It is required to call the Log constructor in main thread. - gMainThreadId = Utility::GetThreadId(); -} - -Log::~Log() -{ -} - -void Log::SetLevel(LogLevel Level) -{ - m_Level = Level; -} - -void Log::WriteFormat(LogLevel Level, const char* Format, ...) -{ - char buffer[256]; - va_list args; - va_start(args, Format); - vsprintf_s(buffer, 256, Format, args); - Write(Level, buffer); - va_end(args); -} - -void Log::Write(LogLevel Level, const char* Message) -{ - assert(gInstance); - std::lock_guard lockGuard(gInstance->m_Mutex); - - if (gInstance->m_Level > Level) - return; - - if (Utility::GetThreadId() == gMainThreadId) - { - // direct output if it's main thread. - gInstance->HandleOutput(Level, Message); - } - else - { - // store messages for later process. - gInstance->m_ThreadedMessages.push(LogMessage(Level, Message)); - } -} - -void Log::HandleOutput(LogLevel Level, const std::string& Message) -{ - assert(Utility::GetThreadId() == gMainThreadId); - - static const char* PREFIX_NAMES[] = { "[DEBUG]", "[INFO]", "[WARN]", "[ERROR]" }; - - Utility::Printf("%s %s\n", PREFIX_NAMES[Level], Message.c_str()); -} - -void Log::Flush() -{ - assert(Utility::GetThreadId() == gMainThreadId); - - std::lock_guard lockGuard(m_Mutex); - - while (!m_ThreadedMessages.empty()) - { - const LogMessage& message = m_ThreadedMessages.front(); - - // Output the message - HandleOutput(message.m_Level, message.m_Message); - - m_ThreadedMessages.pop(); - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Log.h b/xess/samples/xess_demo/MiniEngine/Core/Log.h deleted file mode 100644 index bd2c9db..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Log.h +++ /dev/null @@ -1,108 +0,0 @@ -/******************************************************************************* - * Copyright 2021 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files(the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions : - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ - -#pragma once -#include - -//#define _NO_LOG_ 1 - -#ifdef _NO_LOG_ -#define LOG_DEBUG(Message) ((void)0) -#define LOG_INFO(Message) ((void)0) -#define LOG_WARN(Message) ((void)0) -#define LOG_ERROR(Message) ((void)0) - -#define LOG_DEBUGF(Format, ...) ((void)0) -#define LOG_INFOF(Format, ...) ((void)0) -#define LOG_WARNF(Format, ...) ((void)0) -#define LOG_ERRORF(Format, ...) ((void)0) -#else -#define LOG_DEBUG(Message) Log::Write(Log::LevelDebug, Message) -#define LOG_INFO(Message) Log::Write(Log::LevelInfo, Message) -#define LOG_WARN(Message) Log::Write(Log::LevelWarning, Message) -#define LOG_ERROR(Message) Log::Write(Log::LevelError, Message) - -#define LOG_DEBUGF(Format, ...) Log::WriteFormat(Log::LevelDebug, Format, ##__VA_ARGS__) -#define LOG_INFOF(Format, ...) Log::WriteFormat(Log::LevelInfo, Format, ##__VA_ARGS__) -#define LOG_WARNF(Format, ...) Log::WriteFormat(Log::LevelWarning, Format, ##__VA_ARGS__) -#define LOG_ERRORF(Format, ...) Log::WriteFormat(Log::LevelError, Format, ##__VA_ARGS__) -#endif - -/// A simple log class. -class Log -{ -public: - enum LogLevel - { - LevelDebug = 0, - LevelInfo, - LevelWarning, - LevelError - }; - - struct LogMessage - { - /// Constructor. - LogMessage() = delete; - - /// Constructor. - LogMessage(LogLevel Level, const char* Message) - : m_Level(Level) - , m_Message(Message) { - - }; - - /// Constructor. - LogMessage(LogLevel Level, const std::string& Message) - : m_Level(Level) - , m_Message(Message) { - - }; - - /// Message level. - LogLevel m_Level; - /// Message content. - std::string m_Message; - }; - - static void Write(LogLevel Level, const char* Message); - static void WriteFormat(LogLevel Level, const char* Format, ...); - - /// Constructor. - explicit Log(); - /// Destructor. - ~Log(); - - void SetLevel(LogLevel Level); - void Flush(); - -protected: - // Handle the message output. Can be overridden in subclass. - virtual void HandleOutput(LogLevel Level, const std::string& Message); - - /// Log messages from other threads. - std::queue m_ThreadedMessages; - /// Level of log. - LogLevel m_Level; - /// Mutex for threading. - std::mutex m_Mutex; -}; diff --git a/xess/samples/xess_demo/MiniEngine/Core/Math/BoundingBox.h b/xess/samples/xess_demo/MiniEngine/Core/Math/BoundingBox.h deleted file mode 100644 index d5cc0b5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Math/BoundingBox.h +++ /dev/null @@ -1,89 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "VectorMath.h" -#include "Transform.h" - -namespace Math -{ - class AxisAlignedBox - { - public: - AxisAlignedBox() : m_min(FLT_MAX, FLT_MAX, FLT_MAX), m_max(-FLT_MAX, -FLT_MAX, -FLT_MAX) {} - AxisAlignedBox(EZeroTag) : m_min(FLT_MAX, FLT_MAX, FLT_MAX), m_max(-FLT_MAX, -FLT_MAX, -FLT_MAX) {} - AxisAlignedBox( Vector3 min, Vector3 max ) : m_min(min), m_max(max) {} - - void AddPoint( Vector3 point ) - { - m_min = Min(point, m_min); - m_max = Max(point, m_max); - } - - void AddBoundingBox( const AxisAlignedBox& box ) - { - AddPoint(box.m_min); - AddPoint(box.m_max); - } - - AxisAlignedBox Union( const AxisAlignedBox& box ) - { - return AxisAlignedBox(Min(m_min, box.m_min), Max(m_max, box.m_max)); - } - - Vector3 GetMin() const { return m_min; } - Vector3 GetMax() const { return m_max; } - Vector3 GetCenter() const { return (m_min + m_max) * 0.5f; } - Vector3 GetDimensions() const { return Max(m_max - m_min, Vector3(kZero)); } - - private: - - Vector3 m_min; - Vector3 m_max; - }; - - class OrientedBox - { - public: - OrientedBox() {} - - OrientedBox( const AxisAlignedBox& box ) - { - m_repr.SetBasis(Matrix3::MakeScale(box.GetMax() - box.GetMin())); - m_repr.SetTranslation(box.GetMin()); - } - - friend OrientedBox operator* (const AffineTransform& xform, const OrientedBox& obb ) - { - return (OrientedBox&)(xform * obb.m_repr); - } - - Vector3 GetDimensions() const { return m_repr.GetX() + m_repr.GetY() + m_repr.GetZ(); } - Vector3 GetCenter() const { return m_repr.GetTranslation() + GetDimensions() * 0.5f; } - - private: - AffineTransform m_repr; - }; - - INLINE OrientedBox operator* (const UniformTransform& xform, const OrientedBox& obb ) - { - return AffineTransform(xform) * obb; - } - - INLINE OrientedBox operator* (const UniformTransform& xform, const AxisAlignedBox& aabb ) - { - return AffineTransform(xform) * OrientedBox(aabb); - } - -} // namespace Math diff --git a/xess/samples/xess_demo/MiniEngine/Core/Math/BoundingPlane.h b/xess/samples/xess_demo/MiniEngine/Core/Math/BoundingPlane.h deleted file mode 100644 index 9f1e774..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Math/BoundingPlane.h +++ /dev/null @@ -1,89 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "VectorMath.h" - -namespace Math -{ - class BoundingPlane - { - public: - - BoundingPlane() {} - BoundingPlane( Vector3 normalToPlane, float distanceFromOrigin ) : m_repr(normalToPlane, distanceFromOrigin) {} - BoundingPlane( Vector3 pointOnPlane, Vector3 normalToPlane ); - BoundingPlane( float A, float B, float C, float D ) : m_repr(A, B, C, D) {} - BoundingPlane( const BoundingPlane& plane ) : m_repr(plane.m_repr) {} - explicit BoundingPlane( Vector4 plane ) : m_repr(plane) {} - - INLINE operator Vector4() const { return m_repr; } - - // Returns the direction the plane is facing. (Warning: might not be normalized.) - Vector3 GetNormal( void ) const { return Vector3(XMVECTOR(m_repr)); } - - // Returns the point on the plane closest to the origin - Vector3 GetPointOnPlane( void ) const { return -GetNormal() * m_repr.GetW(); } - - // Distance from 3D point - Scalar DistanceFromPoint( Vector3 point ) const - { - return Dot(point, GetNormal()) + m_repr.GetW(); - } - - // Distance from homogeneous point - Scalar DistanceFromPoint(Vector4 point) const - { - return Dot(point, m_repr); - } - - // Most efficient way to transform a plane. (Involves one quaternion-vector rotation and one dot product.) - friend BoundingPlane operator* ( const OrthogonalTransform& xform, BoundingPlane plane ) - { - Vector3 normalToPlane = xform.GetRotation() * plane.GetNormal(); - float distanceFromOrigin = plane.m_repr.GetW() - Dot(normalToPlane, xform.GetTranslation()); - return BoundingPlane(normalToPlane, distanceFromOrigin); - } - - // Less efficient way to transform a plane (but handles affine transformations.) - friend BoundingPlane operator* ( const Matrix4& mat, BoundingPlane plane ) - { - return BoundingPlane( Transpose(Invert(mat)) * plane.m_repr ); - } - - private: - - Vector4 m_repr; - }; - - //======================================================================================================= - // Inline implementations - // - inline BoundingPlane::BoundingPlane( Vector3 pointOnPlane, Vector3 normalToPlane ) - { - // Guarantee a normal. This constructor isn't meant to be called frequently, but if it is, we can change this. - normalToPlane = Normalize(normalToPlane); - m_repr = Vector4(normalToPlane, -Dot(pointOnPlane, normalToPlane)); - } - - //======================================================================================================= - // Functions operating on planes - // - inline BoundingPlane PlaneFromPointsCCW( Vector3 A, Vector3 B, Vector3 C ) - { - return BoundingPlane( A, Cross(B - A, C - A) ); - } - - -} // namespace Math diff --git a/xess/samples/xess_demo/MiniEngine/Core/Math/BoundingSphere.cpp b/xess/samples/xess_demo/MiniEngine/Core/Math/BoundingSphere.cpp deleted file mode 100644 index bd7eaad..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Math/BoundingSphere.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "BoundingSphere.h" - -using namespace Math; - -BoundingSphere BoundingSphere::Union( const BoundingSphere& rhs ) -{ - float radA = GetRadius(); - if (radA == 0.0f) - return rhs; - - float radB = rhs.GetRadius(); - if (radB == 0.0f) - return *this; - - Vector3 diff = GetCenter() - rhs.GetCenter(); - float dist = Length(diff); - - // Safe normalize vector between sphere centers - diff = dist < 1e-6f ? Vector3(kXUnitVector) : diff * Recip(dist); - - Vector3 extremeA = GetCenter() + diff * Max(radA, radB - dist); - Vector3 extremeB = rhs.GetCenter() - diff * Max(radB, radA - dist); - - return BoundingSphere((extremeA + extremeB) * 0.5f, Length(extremeA - extremeB) * 0.5f); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Math/BoundingSphere.h b/xess/samples/xess_demo/MiniEngine/Core/Math/BoundingSphere.h deleted file mode 100644 index d63c88a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Math/BoundingSphere.h +++ /dev/null @@ -1,53 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "VectorMath.h" - -namespace Math -{ - class BoundingSphere - { - public: - BoundingSphere() {} - BoundingSphere( float x, float y, float z, float r ) : m_repr(x, y, z, r) {} - BoundingSphere( const XMFLOAT4* unaligned_array ) : m_repr(*unaligned_array) {} - BoundingSphere( Vector3 center, Scalar radius ); - BoundingSphere( EZeroTag ) : m_repr(kZero) {} - explicit BoundingSphere (const XMVECTOR& v) : m_repr(v) {} - explicit BoundingSphere( const XMFLOAT4& f4 ) : m_repr(f4) {} - explicit BoundingSphere( Vector4 sphere ) : m_repr(sphere) {} - explicit operator Vector4() const { return Vector4(m_repr); } - - Vector3 GetCenter( void ) const { return Vector3(m_repr); } - Scalar GetRadius( void ) const { return m_repr.GetW(); } - - BoundingSphere Union( const BoundingSphere& rhs ); - - private: - - Vector4 m_repr; - }; - - //======================================================================================================= - // Inline implementations - // - - inline BoundingSphere::BoundingSphere( Vector3 center, Scalar radius ) - { - m_repr = Vector4(center); - m_repr.SetW(radius); - } - -} // namespace Math diff --git a/xess/samples/xess_demo/MiniEngine/Core/Math/Common.h b/xess/samples/xess_demo/MiniEngine/Core/Math/Common.h deleted file mode 100644 index 9dd85e1..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Math/Common.h +++ /dev/null @@ -1,171 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include -#include - -#define INLINE __forceinline - -namespace Math -{ - template __forceinline T AlignUpWithMask( T value, size_t mask ) - { - return (T)(((size_t)value + mask) & ~mask); - } - - template __forceinline T AlignDownWithMask( T value, size_t mask ) - { - return (T)((size_t)value & ~mask); - } - - template __forceinline T AlignUp( T value, size_t alignment ) - { - return AlignUpWithMask(value, alignment - 1); - } - - template __forceinline T AlignDown( T value, size_t alignment ) - { - return AlignDownWithMask(value, alignment - 1); - } - - template __forceinline bool IsAligned( T value, size_t alignment ) - { - return 0 == ((size_t)value & (alignment - 1)); - } - - template __forceinline T DivideByMultiple( T value, size_t alignment ) - { - return (T)((value + alignment - 1) / alignment); - } - - template __forceinline bool IsPowerOfTwo(T value) - { - return 0 == (value & (value - 1)); - } - - template __forceinline bool IsDivisible(T value, T divisor) - { - return (value / divisor) * divisor == value; - } - - __forceinline uint8_t Log2(uint64_t value) - { - unsigned long mssb; // most significant set bit - unsigned long lssb; // least significant set bit - - // If perfect power of two (only one set bit), return index of bit. Otherwise round up - // fractional log by adding 1 to most signicant set bit's index. - if (_BitScanReverse64(&mssb, value) > 0 && _BitScanForward64(&lssb, value) > 0) - return uint8_t(mssb + (mssb == lssb ? 0 : 1)); - else - return 0; - } - - template __forceinline T AlignPowerOfTwo(T value) - { - return value == 0 ? 0 : 1 << Log2(value); - } - - using namespace DirectX; - - INLINE XMVECTOR SplatZero() - { - return XMVectorZero(); - } - -#if !defined(_XM_NO_INTRINSICS_) && defined(_XM_SSE_INTRINSICS_) - - INLINE XMVECTOR SplatOne( XMVECTOR zero = SplatZero() ) - { - __m128i AllBits = _mm_castps_si128(_mm_cmpeq_ps(zero, zero)); - return _mm_castsi128_ps(_mm_slli_epi32(_mm_srli_epi32(AllBits, 25), 23)); // return 0x3F800000 - //return _mm_cvtepi32_ps(_mm_srli_epi32(SetAllBits(zero), 31)); // return (float)1; (alternate method) - } - -#if defined(_XM_SSE4_INTRINSICS_) - INLINE XMVECTOR CreateXUnitVector( XMVECTOR one = SplatOne() ) - { - return _mm_insert_ps(one, one, 0x0E); - } - INLINE XMVECTOR CreateYUnitVector( XMVECTOR one = SplatOne() ) - { - return _mm_insert_ps(one, one, 0x0D); - } - INLINE XMVECTOR CreateZUnitVector( XMVECTOR one = SplatOne() ) - { - return _mm_insert_ps(one, one, 0x0B); - } - INLINE XMVECTOR CreateWUnitVector( XMVECTOR one = SplatOne() ) - { - return _mm_insert_ps(one, one, 0x07); - } - INLINE XMVECTOR SetWToZero( FXMVECTOR vec ) - { - return _mm_insert_ps(vec, vec, 0x08); - } - INLINE XMVECTOR SetWToOne( FXMVECTOR vec ) - { - return _mm_blend_ps(vec, SplatOne(), 0x8); - } -#else - INLINE XMVECTOR CreateXUnitVector( XMVECTOR one = SplatOne() ) - { - return _mm_castsi128_ps(_mm_srli_si128(_mm_castps_si128(one), 12)); - } - INLINE XMVECTOR CreateYUnitVector( XMVECTOR one = SplatOne() ) - { - XMVECTOR unitx = CreateXUnitVector(one); - return _mm_castsi128_ps(_mm_slli_si128(_mm_castps_si128(unitx), 4)); - } - INLINE XMVECTOR CreateZUnitVector( XMVECTOR one = SplatOne() ) - { - XMVECTOR unitx = CreateXUnitVector(one); - return _mm_castsi128_ps(_mm_slli_si128(_mm_castps_si128(unitx), 8)); - } - INLINE XMVECTOR CreateWUnitVector( XMVECTOR one = SplatOne() ) - { - return _mm_castsi128_ps(_mm_slli_si128(_mm_castps_si128(one), 12)); - } - INLINE XMVECTOR SetWToZero( FXMVECTOR vec ) - { - __m128i MaskOffW = _mm_srli_si128(_mm_castps_si128(_mm_cmpeq_ps(vec, vec)), 4); - return _mm_and_ps(vec, _mm_castsi128_ps(MaskOffW)); - } - INLINE XMVECTOR SetWToOne( FXMVECTOR vec ) - { - return _mm_movelh_ps(vec, _mm_unpackhi_ps(vec, SplatOne())); - } -#endif - -#else // !_XM_SSE_INTRINSICS_ - - INLINE XMVECTOR SplatOne() { return XMVectorSplatOne(); } - INLINE XMVECTOR CreateXUnitVector() { return g_XMIdentityR0; } - INLINE XMVECTOR CreateYUnitVector() { return g_XMIdentityR1; } - INLINE XMVECTOR CreateZUnitVector() { return g_XMIdentityR2; } - INLINE XMVECTOR CreateWUnitVector() { return g_XMIdentityR3; } - INLINE XMVECTOR SetWToZero( FXMVECTOR vec ) { return XMVectorAndInt( vec, g_XMMask3 ); } - INLINE XMVECTOR SetWToOne( FXMVECTOR vec ) { return XMVectorSelect( g_XMIdentityR3, vec, g_XMMask3 ); } - -#endif - - enum EZeroTag { kZero, kOrigin }; - enum EIdentityTag { kOne, kIdentity }; - enum EXUnitVector { kXUnitVector }; - enum EYUnitVector { kYUnitVector }; - enum EZUnitVector { kZUnitVector }; - enum EWUnitVector { kWUnitVector }; - -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Math/Frustum.cpp b/xess/samples/xess_demo/MiniEngine/Core/Math/Frustum.cpp deleted file mode 100644 index ec1d448..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Math/Frustum.cpp +++ /dev/null @@ -1,116 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "Frustum.h" -#include "Camera.h" - -using namespace Math; - -void Frustum::ConstructPerspectiveFrustum( float HTan, float VTan, float NearClip, float FarClip ) -{ - const float NearX = HTan * NearClip; - const float NearY = VTan * NearClip; - const float FarX = HTan * FarClip; - const float FarY = VTan * FarClip; - - // Define the frustum corners - m_FrustumCorners[ kNearLowerLeft ] = Vector3(-NearX, -NearY, -NearClip); // Near lower left - m_FrustumCorners[ kNearUpperLeft ] = Vector3(-NearX, NearY, -NearClip); // Near upper left - m_FrustumCorners[ kNearLowerRight ] = Vector3( NearX, -NearY, -NearClip); // Near lower right - m_FrustumCorners[ kNearUpperRight ] = Vector3( NearX, NearY, -NearClip); // Near upper right - m_FrustumCorners[ kFarLowerLeft ] = Vector3( -FarX, -FarY, -FarClip); // Far lower left - m_FrustumCorners[ kFarUpperLeft ] = Vector3( -FarX, FarY, -FarClip); // Far upper left - m_FrustumCorners[ kFarLowerRight ] = Vector3( FarX, -FarY, -FarClip); // Far lower right - m_FrustumCorners[ kFarUpperRight ] = Vector3( FarX, FarY, -FarClip); // Far upper right - - const float NHx = RecipSqrt( 1.0f + HTan * HTan ); - const float NHz = -NHx * HTan; - const float NVy = RecipSqrt( 1.0f + VTan * VTan ); - const float NVz = -NVy * VTan; - - // Define the bounding planes - m_FrustumPlanes[kNearPlane] = BoundingPlane( 0.0f, 0.0f, -1.0f, -NearClip ); - m_FrustumPlanes[kFarPlane] = BoundingPlane( 0.0f, 0.0f, 1.0f, FarClip ); - m_FrustumPlanes[kLeftPlane] = BoundingPlane( NHx, 0.0f, NHz, 0.0f ); - m_FrustumPlanes[kRightPlane] = BoundingPlane( -NHx, 0.0f, NHz, 0.0f ); - m_FrustumPlanes[kTopPlane] = BoundingPlane( 0.0f, -NVy, NVz, 0.0f ); - m_FrustumPlanes[kBottomPlane] = BoundingPlane( 0.0f, NVy, NVz, 0.0f ); -} - -void Frustum::ConstructOrthographicFrustum( float Left, float Right, float Top, float Bottom, float Front, float Back ) -{ - // Define the frustum corners - m_FrustumCorners[ kNearLowerLeft ] = Vector3(Left, Bottom, -Front); // Near lower left - m_FrustumCorners[ kNearUpperLeft ] = Vector3(Left, Top, -Front); // Near upper left - m_FrustumCorners[ kNearLowerRight ] = Vector3(Right, Bottom, -Front); // Near lower right - m_FrustumCorners[ kNearUpperRight ] = Vector3(Right, Top, -Front); // Near upper right - m_FrustumCorners[ kFarLowerLeft ] = Vector3(Left, Bottom, -Back); // Far lower left - m_FrustumCorners[ kFarUpperLeft ] = Vector3(Left, Top, -Back); // Far upper left - m_FrustumCorners[ kFarLowerRight ] = Vector3(Right, Bottom, -Back); // Far lower right - m_FrustumCorners[ kFarUpperRight ] = Vector3(Right, Top, -Back); // Far upper right - - // Define the bounding planes - m_FrustumPlanes[kNearPlane] = BoundingPlane( 0.0f, 0.0f, -1.0f, -Front ); - m_FrustumPlanes[kFarPlane] = BoundingPlane( 0.0f, 0.0f, 1.0f, Back ); - m_FrustumPlanes[kLeftPlane] = BoundingPlane( 1.0f, 0.0f, 0.0f, -Left ); - m_FrustumPlanes[kRightPlane] = BoundingPlane( -1.0f, 0.0f, 0.0f, Right ); - m_FrustumPlanes[kTopPlane] = BoundingPlane( 0.0f, -1.0f, 0.0f, Bottom ); - m_FrustumPlanes[kBottomPlane] = BoundingPlane( 0.0f, 1.0f, 0.0f, -Top ); -} - - -Frustum::Frustum( const Matrix4& ProjMat ) -{ - const float* ProjMatF = (const float*)&ProjMat; - - const float RcpXX = 1.0f / ProjMatF[ 0]; - const float RcpYY = 1.0f / ProjMatF[ 5]; - const float RcpZZ = 1.0f / ProjMatF[10]; - - // Identify if the projection is perspective or orthographic by looking at the 4th row. - if (ProjMatF[3] == 0.0f && ProjMatF[7] == 0.0f && ProjMatF[11] == 0.0f && ProjMatF[15] == 1.0f) - { - // Orthographic - float Left = (-1.0f - ProjMatF[12]) * RcpXX; - float Right = ( 1.0f - ProjMatF[12]) * RcpXX; - float Top = ( 1.0f - ProjMatF[13]) * RcpYY; - float Bottom = (-1.0f - ProjMatF[13]) * RcpYY; - float Front = ( 0.0f - ProjMatF[14]) * RcpZZ; - float Back = ( 1.0f - ProjMatF[14]) * RcpZZ; - - // Check for reverse Z here. The bounding planes need to point into the frustum. - if (Front < Back) - ConstructOrthographicFrustum( Left, Right, Top, Bottom, Front, Back ); - else - ConstructOrthographicFrustum( Left, Right, Top, Bottom, Back, Front ); - } - else - { - // Perspective - float NearClip, FarClip; - - if (RcpZZ > 0.0f) // Reverse Z - { - FarClip = ProjMatF[14] * RcpZZ; - NearClip = FarClip / (RcpZZ + 1.0f); - } - else - { - NearClip = ProjMatF[14] * RcpZZ; - FarClip = NearClip / (RcpZZ + 1.0f); - } - - ConstructPerspectiveFrustum( RcpXX, RcpYY, NearClip, FarClip ); - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Math/Frustum.h b/xess/samples/xess_demo/MiniEngine/Core/Math/Frustum.h deleted file mode 100644 index 80ed1e6..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Math/Frustum.h +++ /dev/null @@ -1,138 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "BoundingPlane.h" -#include "BoundingSphere.h" -#include "BoundingBox.h" - -namespace Math -{ - class Frustum - { - public: - Frustum() {} - - Frustum( const Matrix4& ProjectionMatrix ); - - enum CornerID - { - kNearLowerLeft, kNearUpperLeft, kNearLowerRight, kNearUpperRight, - kFarLowerLeft, kFarUpperLeft, kFarLowerRight, kFarUpperRight - }; - - enum PlaneID - { - kNearPlane, kFarPlane, kLeftPlane, kRightPlane, kTopPlane, kBottomPlane - }; - - Vector3 GetFrustumCorner( CornerID id ) const { return m_FrustumCorners[id]; } - BoundingPlane GetFrustumPlane( PlaneID id ) const { return m_FrustumPlanes[id]; } - - // Test whether the bounding sphere intersects the frustum. Intersection is defined as either being - // fully contained in the frustum, or by intersecting one or more of the planes. - bool IntersectSphere( BoundingSphere sphere ) const; - - // We don't officially have a AxisAlignedBox class yet, but let's assume it's forthcoming. (There is a - // simple struct in the Model project.) - bool IntersectBoundingBox(const AxisAlignedBox& aabb) const; - - friend Frustum operator* ( const OrthogonalTransform& xform, const Frustum& frustum ); // Fast - friend Frustum operator* ( const AffineTransform& xform, const Frustum& frustum ); // Slow - friend Frustum operator* ( const Matrix4& xform, const Frustum& frustum ); // Slowest (and most general) - - private: - - // Perspective frustum constructor (for pyramid-shaped frusta) - void ConstructPerspectiveFrustum( float HTan, float VTan, float NearClip, float FarClip ); - - // Orthographic frustum constructor (for box-shaped frusta) - void ConstructOrthographicFrustum( float Left, float Right, float Top, float Bottom, float NearClip, float FarClip ); - - Vector3 m_FrustumCorners[8]; // the corners of the frustum - BoundingPlane m_FrustumPlanes[6]; // the bounding planes - }; - - //======================================================================================================= - // Inline implementations - // - - inline bool Frustum::IntersectSphere( BoundingSphere sphere ) const - { - float radius = sphere.GetRadius(); - for (int i = 0; i < 6; ++i) - { - if (m_FrustumPlanes[i].DistanceFromPoint(sphere.GetCenter()) + radius < 0.0f) - return false; - } - return true; - } - - inline bool Frustum::IntersectBoundingBox(const AxisAlignedBox& aabb) const - { - for (int i = 0; i < 6; ++i) - { - BoundingPlane p = m_FrustumPlanes[i]; - Vector3 farCorner = Select(aabb.GetMin(), aabb.GetMax(), p.GetNormal() > Vector3(kZero)); - if (p.DistanceFromPoint(farCorner) < 0.0f) - return false; - } - - return true; - } - - inline Frustum operator* ( const OrthogonalTransform& xform, const Frustum& frustum ) - { - Frustum result; - - for (int i = 0; i < 8; ++i) - result.m_FrustumCorners[i] = xform * frustum.m_FrustumCorners[i]; - - for (int i = 0; i < 6; ++i) - result.m_FrustumPlanes[i] = xform * frustum.m_FrustumPlanes[i]; - - return result; - } - - inline Frustum operator* ( const AffineTransform& xform, const Frustum& frustum ) - { - Frustum result; - - for (int i = 0; i < 8; ++i) - result.m_FrustumCorners[i] = xform * frustum.m_FrustumCorners[i]; - - Matrix4 XForm = Transpose(Invert(Matrix4(xform))); - - for (int i = 0; i < 6; ++i) - result.m_FrustumPlanes[i] = BoundingPlane(XForm * Vector4(frustum.m_FrustumPlanes[i])); - - return result; - } - - inline Frustum operator* ( const Matrix4& mtx, const Frustum& frustum ) - { - Frustum result; - - for (int i = 0; i < 8; ++i) - result.m_FrustumCorners[i] = Vector3( mtx * frustum.m_FrustumCorners[i] ); - - Matrix4 XForm = Transpose(Invert(mtx)); - - for (int i = 0; i < 6; ++i) - result.m_FrustumPlanes[i] = BoundingPlane(XForm * Vector4(frustum.m_FrustumPlanes[i])); - - return result; - } - -} // namespace Math diff --git a/xess/samples/xess_demo/MiniEngine/Core/Math/Functions.inl b/xess/samples/xess_demo/MiniEngine/Core/Math/Functions.inl deleted file mode 100644 index 0eb1d0d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Math/Functions.inl +++ /dev/null @@ -1,137 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -namespace Math -{ - // To allow floats to implicitly construct Scalars, we need to clarify these operators and suppress - // upconversion. - INLINE bool operator< ( Scalar lhs, float rhs ) { return (float)lhs < rhs; } - INLINE bool operator<= ( Scalar lhs, float rhs ) { return (float)lhs <= rhs; } - INLINE bool operator> ( Scalar lhs, float rhs ) { return (float)lhs > rhs; } - INLINE bool operator>= ( Scalar lhs, float rhs ) { return (float)lhs >= rhs; } - INLINE bool operator== ( Scalar lhs, float rhs ) { return (float)lhs == rhs; } - INLINE bool operator< ( float lhs, Scalar rhs ) { return lhs < (float)rhs; } - INLINE bool operator<= ( float lhs, Scalar rhs ) { return lhs <= (float)rhs; } - INLINE bool operator> ( float lhs, Scalar rhs ) { return lhs > (float)rhs; } - INLINE bool operator>= ( float lhs, Scalar rhs ) { return lhs >= (float)rhs; } - INLINE bool operator== ( float lhs, Scalar rhs ) { return lhs == (float)rhs; } - -#define CREATE_SIMD_FUNCTIONS( TYPE ) \ - INLINE TYPE Sqrt( TYPE s ) { return TYPE(XMVectorSqrt(s)); } \ - INLINE TYPE Recip( TYPE s ) { return TYPE(XMVectorReciprocal(s)); } \ - INLINE TYPE RecipSqrt( TYPE s ) { return TYPE(XMVectorReciprocalSqrt(s)); } \ - INLINE TYPE Floor( TYPE s ) { return TYPE(XMVectorFloor(s)); } \ - INLINE TYPE Ceiling( TYPE s ) { return TYPE(XMVectorCeiling(s)); } \ - INLINE TYPE Round( TYPE s ) { return TYPE(XMVectorRound(s)); } \ - INLINE TYPE Abs( TYPE s ) { return TYPE(XMVectorAbs(s)); } \ - INLINE TYPE Exp( TYPE s ) { return TYPE(XMVectorExp(s)); } \ - INLINE TYPE Pow( TYPE b, TYPE e ) { return TYPE(XMVectorPow(b, e)); } \ - INLINE TYPE Log( TYPE s ) { return TYPE(XMVectorLog(s)); } \ - INLINE TYPE Sin( TYPE s ) { return TYPE(XMVectorSin(s)); } \ - INLINE TYPE Cos( TYPE s ) { return TYPE(XMVectorCos(s)); } \ - INLINE TYPE Tan( TYPE s ) { return TYPE(XMVectorTan(s)); } \ - INLINE TYPE ASin( TYPE s ) { return TYPE(XMVectorASin(s)); } \ - INLINE TYPE ACos( TYPE s ) { return TYPE(XMVectorACos(s)); } \ - INLINE TYPE ATan( TYPE s ) { return TYPE(XMVectorATan(s)); } \ - INLINE TYPE ATan2( TYPE y, TYPE x ) { return TYPE(XMVectorATan2(y, x)); } \ - INLINE TYPE Lerp( TYPE a, TYPE b, TYPE t ) { return TYPE(XMVectorLerpV(a, b, t)); } \ - INLINE TYPE Lerp( TYPE a, TYPE b, float t ) { return TYPE(XMVectorLerp(a, b, t)); } \ - INLINE TYPE Max( TYPE a, TYPE b ) { return TYPE(XMVectorMax(a, b)); } \ - INLINE TYPE Min( TYPE a, TYPE b ) { return TYPE(XMVectorMin(a, b)); } \ - INLINE TYPE Clamp( TYPE v, TYPE a, TYPE b ) { return Min(Max(v, a), b); } \ - INLINE BoolVector operator< ( TYPE lhs, TYPE rhs ) { return XMVectorLess(lhs, rhs); } \ - INLINE BoolVector operator<= ( TYPE lhs, TYPE rhs ) { return XMVectorLessOrEqual(lhs, rhs); } \ - INLINE BoolVector operator> ( TYPE lhs, TYPE rhs ) { return XMVectorGreater(lhs, rhs); } \ - INLINE BoolVector operator>= ( TYPE lhs, TYPE rhs ) { return XMVectorGreaterOrEqual(lhs, rhs); } \ - INLINE BoolVector operator== ( TYPE lhs, TYPE rhs ) { return XMVectorEqual(lhs, rhs); } \ - INLINE TYPE Select( TYPE lhs, TYPE rhs, BoolVector mask ) { return TYPE(XMVectorSelect(lhs, rhs, mask)); } - - - CREATE_SIMD_FUNCTIONS(Scalar) - CREATE_SIMD_FUNCTIONS(Vector3) - CREATE_SIMD_FUNCTIONS(Vector4) - -#undef CREATE_SIMD_FUNCTIONS - - INLINE float Sqrt( float s ) { return Sqrt(Scalar(s)); } - INLINE float Recip( float s ) { return Recip(Scalar(s)); } - INLINE float RecipSqrt( float s ) { return RecipSqrt(Scalar(s)); } - INLINE float Floor( float s ) { return Floor(Scalar(s)); } - INLINE float Ceiling( float s ) { return Ceiling(Scalar(s)); } - INLINE float Round( float s ) { return Round(Scalar(s)); } - INLINE float Abs( float s ) { return s < 0.0f ? -s : s; } - INLINE float Exp( float s ) { return Exp(Scalar(s)); } - INLINE float Pow( float b, float e ) { return Pow(Scalar(b), Scalar(e)); } - INLINE float Log( float s ) { return Log(Scalar(s)); } - INLINE float Sin( float s ) { return Sin(Scalar(s)); } - INLINE float Cos( float s ) { return Cos(Scalar(s)); } - INLINE float Tan( float s ) { return Tan(Scalar(s)); } - INLINE float ASin( float s ) { return ASin(Scalar(s)); } - INLINE float ACos( float s ) { return ACos(Scalar(s)); } - INLINE float ATan( float s ) { return ATan(Scalar(s)); } - INLINE float ATan2( float y, float x ) { return ATan2(Scalar(y), Scalar(x)); } - INLINE float Lerp( float a, float b, float t ) { return a + (b - a) * t; } - INLINE float Max( float a, float b ) { return a > b ? a : b; } - INLINE float Min( float a, float b ) { return a < b ? a : b; } - INLINE float Clamp( float v, float a, float b ) { return Min(Max(v, a), b); } - - INLINE Scalar Length( Vector3 v ) { return Scalar(XMVector3Length(v)); } - INLINE Scalar LengthSquare( Vector3 v ) { return Scalar(XMVector3LengthSq(v)); } - INLINE Scalar LengthRecip( Vector3 v ) { return Scalar(XMVector3ReciprocalLength(v)); } - INLINE Scalar Dot( Vector3 v1, Vector3 v2 ) { return Scalar(XMVector3Dot(v1, v2)); } - INLINE Scalar Dot( Vector4 v1, Vector4 v2 ) { return Scalar(XMVector4Dot(v1, v2)); } - INLINE Vector3 Cross( Vector3 v1, Vector3 v2 ) { return Vector3(XMVector3Cross(v1, v2)); } - INLINE Vector3 Normalize( Vector3 v ) { return Vector3(XMVector3Normalize(v)); } - INLINE Vector4 Normalize( Vector4 v ) { return Vector4(XMVector4Normalize(v)); } - - INLINE Matrix3 Transpose( const Matrix3& mat ) { return Matrix3(XMMatrixTranspose(mat)); } - INLINE Matrix3 InverseTranspose( const Matrix3& mat ) - { - const Vector3 x = mat.GetX(); - const Vector3 y = mat.GetY(); - const Vector3 z = mat.GetZ(); - - const Vector3 inv0 = Cross(y, z); - const Vector3 inv1 = Cross(z, x); - const Vector3 inv2 = Cross(x, y); - const Scalar rDet = Recip(Dot(z, inv2)); - - // Return the adjoint / determinant - return Matrix3(inv0, inv1, inv2) * rDet; - } - - // inline Matrix3 Inverse( const Matrix3& mat ) { TBD } - // inline Transform Inverse( const Transform& mat ) { TBD } - - // This specialized matrix invert assumes that the 3x3 matrix is orthogonal (and normalized). - INLINE AffineTransform OrthoInvert( const AffineTransform& xform ) - { - Matrix3 basis = Transpose(xform.GetBasis()); - return AffineTransform( basis, basis * -xform.GetTranslation() ); - } - - INLINE OrthogonalTransform Invert( const OrthogonalTransform& xform ) { return ~xform; } - - INLINE Matrix4 Transpose( const Matrix4& mat ) { return Matrix4(XMMatrixTranspose(mat)); } - INLINE Matrix4 Invert( const Matrix4& mat ) { return Matrix4(XMMatrixInverse(nullptr, mat)); } - - INLINE Matrix4 OrthoInvert( const Matrix4& xform ) - { - Matrix3 basis = Transpose(xform.Get3x3()); - Vector3 translate = basis * -Vector3(xform.GetW()); - return Matrix4( basis, translate ); - } - -} \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Core/Math/Matrix3.h b/xess/samples/xess_demo/MiniEngine/Core/Math/Matrix3.h deleted file mode 100644 index 97be5d9..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Math/Matrix3.h +++ /dev/null @@ -1,60 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "Quaternion.h" - -namespace Math -{ - // Represents a 3x3 matrix while occuping a 3x4 memory footprint. The unused row and column are undefined but implicitly - // (0, 0, 0, 1). Constructing a Matrix4 will make those values explicit. - __declspec(align(16)) class Matrix3 - { - public: - INLINE Matrix3() {} - INLINE Matrix3( Vector3 x, Vector3 y, Vector3 z ) { m_mat[0] = x; m_mat[1] = y; m_mat[2] = z; } - INLINE Matrix3( const Matrix3& m ) { m_mat[0] = m.m_mat[0]; m_mat[1] = m.m_mat[1]; m_mat[2] = m.m_mat[2]; } - INLINE Matrix3( Quaternion q ) { *this = Matrix3(XMMatrixRotationQuaternion(q)); } - INLINE explicit Matrix3( const XMMATRIX& m ) { m_mat[0] = Vector3(m.r[0]); m_mat[1] = Vector3(m.r[1]); m_mat[2] = Vector3(m.r[2]); } - INLINE explicit Matrix3( EIdentityTag ) { m_mat[0] = Vector3(kXUnitVector); m_mat[1] = Vector3(kYUnitVector); m_mat[2] = Vector3(kZUnitVector); } - INLINE explicit Matrix3( EZeroTag ) { m_mat[0] = m_mat[1] = m_mat[2] = Vector3(kZero); } - - INLINE void SetX(Vector3 x) { m_mat[0] = x; } - INLINE void SetY(Vector3 y) { m_mat[1] = y; } - INLINE void SetZ(Vector3 z) { m_mat[2] = z; } - - INLINE Vector3 GetX() const { return m_mat[0]; } - INLINE Vector3 GetY() const { return m_mat[1]; } - INLINE Vector3 GetZ() const { return m_mat[2]; } - - static INLINE Matrix3 MakeXRotation( float angle ) { return Matrix3(XMMatrixRotationX(angle)); } - static INLINE Matrix3 MakeYRotation( float angle ) { return Matrix3(XMMatrixRotationY(angle)); } - static INLINE Matrix3 MakeZRotation( float angle ) { return Matrix3(XMMatrixRotationZ(angle)); } - static INLINE Matrix3 MakeScale( float scale ) { return Matrix3(XMMatrixScaling(scale, scale, scale)); } - static INLINE Matrix3 MakeScale( float sx, float sy, float sz ) { return Matrix3(XMMatrixScaling(sx, sy, sz)); } - static INLINE Matrix3 MakeScale( const XMFLOAT3& scale) { return Matrix3(XMMatrixScaling(scale.x, scale.y, scale.z)); } - static INLINE Matrix3 MakeScale( Vector3 scale ) { return Matrix3(XMMatrixScalingFromVector(scale)); } - - // Useful for DirectXMath interaction. WARNING: Only the 3x3 elements are defined. - INLINE operator XMMATRIX() const { return XMMATRIX(m_mat[0], m_mat[1], m_mat[2], XMVectorZero()); } - - INLINE Matrix3 operator* ( Scalar scl ) const { return Matrix3( scl * GetX(), scl * GetY(), scl * GetZ() ); } - INLINE Vector3 operator* ( Vector3 vec ) const { return Vector3( XMVector3TransformNormal(vec, *this) ); } - INLINE Matrix3 operator* ( const Matrix3& mat ) const { return Matrix3( *this * mat.GetX(), *this * mat.GetY(), *this * mat.GetZ() ); } - - private: - Vector3 m_mat[3]; - }; - -} // namespace Math diff --git a/xess/samples/xess_demo/MiniEngine/Core/Math/Matrix4.h b/xess/samples/xess_demo/MiniEngine/Core/Math/Matrix4.h deleted file mode 100644 index 0982a87..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Math/Matrix4.h +++ /dev/null @@ -1,87 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "Transform.h" - -namespace Math -{ - __declspec(align(16)) class Matrix4 - { - public: - INLINE Matrix4() {} - INLINE Matrix4( Vector3 x, Vector3 y, Vector3 z, Vector3 w ) - { - m_mat.r[0] = SetWToZero(x); m_mat.r[1] = SetWToZero(y); - m_mat.r[2] = SetWToZero(z); m_mat.r[3] = SetWToOne(w); - } - - INLINE Matrix4(const float* data) - { - m_mat = XMLoadFloat4x4((XMFLOAT4X4*)data); - } - - INLINE Matrix4( Vector4 x, Vector4 y, Vector4 z, Vector4 w ) { m_mat.r[0] = x; m_mat.r[1] = y; m_mat.r[2] = z; m_mat.r[3] = w; } - INLINE Matrix4( const Matrix4& mat ) { m_mat = mat.m_mat; } - INLINE Matrix4( const Matrix3& mat ) - { - m_mat.r[0] = SetWToZero(mat.GetX()); - m_mat.r[1] = SetWToZero(mat.GetY()); - m_mat.r[2] = SetWToZero(mat.GetZ()); - m_mat.r[3] = CreateWUnitVector(); - } - INLINE Matrix4( const Matrix3& xyz, Vector3 w ) - { - m_mat.r[0] = SetWToZero(xyz.GetX()); - m_mat.r[1] = SetWToZero(xyz.GetY()); - m_mat.r[2] = SetWToZero(xyz.GetZ()); - m_mat.r[3] = SetWToOne(w); - } - INLINE Matrix4( const AffineTransform& xform ) { *this = Matrix4( xform.GetBasis(), xform.GetTranslation()); } - INLINE Matrix4( const OrthogonalTransform& xform ) { *this = Matrix4( Matrix3(xform.GetRotation()), xform.GetTranslation() ); } - INLINE explicit Matrix4( const XMMATRIX& mat ) { m_mat = mat; } - INLINE explicit Matrix4( EIdentityTag ) { m_mat = XMMatrixIdentity(); } - INLINE explicit Matrix4( EZeroTag ) { m_mat.r[0] = m_mat.r[1] = m_mat.r[2] = m_mat.r[3] = SplatZero(); } - - INLINE const Matrix3& Get3x3() const { return (const Matrix3&)*this; } - INLINE void Set3x3(const Matrix3& xyz) - { - m_mat.r[0] = SetWToZero(xyz.GetX()); - m_mat.r[1] = SetWToZero(xyz.GetY()); - m_mat.r[2] = SetWToZero(xyz.GetZ()); - } - - INLINE Vector4 GetX() const { return Vector4(m_mat.r[0]); } - INLINE Vector4 GetY() const { return Vector4(m_mat.r[1]); } - INLINE Vector4 GetZ() const { return Vector4(m_mat.r[2]); } - INLINE Vector4 GetW() const { return Vector4(m_mat.r[3]); } - - INLINE void SetX(Vector4 x) { m_mat.r[0] = x; } - INLINE void SetY(Vector4 y) { m_mat.r[1] = y; } - INLINE void SetZ(Vector4 z) { m_mat.r[2] = z; } - INLINE void SetW(Vector4 w) { m_mat.r[3] = w; } - - INLINE operator XMMATRIX() const { return m_mat; } - - INLINE Vector4 operator* ( Vector3 vec ) const { return Vector4(XMVector3Transform(vec, m_mat)); } - INLINE Vector4 operator* ( Vector4 vec ) const { return Vector4(XMVector4Transform(vec, m_mat)); } - INLINE Matrix4 operator* ( const Matrix4& mat ) const { return Matrix4(XMMatrixMultiply(mat, m_mat)); } - - static INLINE Matrix4 MakeScale( float scale ) { return Matrix4(XMMatrixScaling(scale, scale, scale)); } - static INLINE Matrix4 MakeScale( Vector3 scale ) { return Matrix4(XMMatrixScalingFromVector(scale)); } - - private: - XMMATRIX m_mat; - }; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Math/Quaternion.h b/xess/samples/xess_demo/MiniEngine/Core/Math/Quaternion.h deleted file mode 100644 index 19ee1c3..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Math/Quaternion.h +++ /dev/null @@ -1,48 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "Vector.h" - -namespace Math -{ - class Quaternion - { - public: - INLINE Quaternion() { m_vec = XMQuaternionIdentity(); } - INLINE Quaternion( const Vector3& axis, const Scalar& angle ) { m_vec = XMQuaternionRotationAxis( axis, angle ); } - INLINE Quaternion( float pitch, float yaw, float roll) { m_vec = XMQuaternionRotationRollPitchYaw(pitch, yaw, roll); } - INLINE explicit Quaternion( const XMMATRIX& matrix ) { m_vec = XMQuaternionRotationMatrix( matrix ); } - INLINE explicit Quaternion( FXMVECTOR vec ) { m_vec = vec; } - INLINE explicit Quaternion( EIdentityTag ) { m_vec = XMQuaternionIdentity(); } - - INLINE operator XMVECTOR() const { return m_vec; } - - INLINE Quaternion operator~ ( void ) const { return Quaternion(XMQuaternionConjugate(m_vec)); } - INLINE Quaternion operator- ( void ) const { return Quaternion(XMVectorNegate(m_vec)); } - - INLINE Quaternion operator* ( Quaternion rhs ) const { return Quaternion(XMQuaternionMultiply(rhs, m_vec)); } - INLINE Vector3 operator* ( Vector3 rhs ) const { return Vector3(XMVector3Rotate(rhs, m_vec)); } - - INLINE Quaternion& operator= ( Quaternion rhs ) { m_vec = rhs; return *this; } - INLINE Quaternion& operator*= ( Quaternion rhs ) { *this = *this * rhs; return *this; } - - protected: - XMVECTOR m_vec; - }; - - INLINE Quaternion Normalize(Quaternion q) { return Quaternion(XMQuaternionNormalize(q)); } - INLINE Quaternion Slerp(Quaternion a, Quaternion b, float t) { return Normalize(Quaternion(XMQuaternionSlerp(a, b, t))); } - INLINE Quaternion Lerp(Quaternion a, Quaternion b, float t) { return Normalize(Quaternion(XMVectorLerp(a, b, t))); } -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Math/Random.cpp b/xess/samples/xess_demo/MiniEngine/Core/Math/Random.cpp deleted file mode 100644 index 2ddabf8..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Math/Random.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "Random.h" - -namespace Math -{ - RandomNumberGenerator g_RNG; -} - -#ifndef USE_STL - -inline uint32_t Twiddle(uint32_t u, uint32_t v) -{ - return (((u & 0x80000000ul) | (v & 0x7FFFFFFFul)) >> 1) ^ ((v & 1ul) * 0x9908B0DFul); -} - -uint32_t Math::RandomNumberGenerator::Rand() -{ - if (m_Pos == n) - { - for (uint32_t i = 0; i < n - m; ++i) - m_State[i] = m_State[i + m] ^ Twiddle(m_State[i], m_State[i + 1]); - for (uint32_t i = n - m; i < n - 1; ++i) - m_State[i] = m_State[i + m - n] ^ Twiddle(m_State[i], m_State[i + 1]); - m_State[n - 1] = m_State[m - 1] ^ Twiddle(m_State[n - 1], m_State[0]); - - m_Pos = 0; - } - - uint32_t x = m_State[m_Pos++]; - x ^= (x >> 11); - x ^= (x << 7) & 0x9D2C5680ul; - x ^= (x << 15) & 0xEFC60000ul; - return x ^ (x >> 18); -} - -void Math::RandomNumberGenerator::SetSeed(uint32_t s) -{ - m_State[0] = s; - - for (int i = 1; i < n; ++i) - m_State[i] = 1812433253ul * (m_State[i - 1] ^ (m_State[i - 1] >> 30)) + i; - - m_Pos = n; -} - -#endif diff --git a/xess/samples/xess_demo/MiniEngine/Core/Math/Random.h b/xess/samples/xess_demo/MiniEngine/Core/Math/Random.h deleted file mode 100644 index 347c133..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Math/Random.h +++ /dev/null @@ -1,124 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#define USE_STL - -#include "Common.h" -#ifdef USE_STL - #include -#endif - -namespace Math -{ -#ifdef USE_STL - class RandomNumberGenerator - { - public: - RandomNumberGenerator(uint32_t s = 0) : m_gen(m_rd()) - { - if (s != 0) - SetSeed(s); - } - - // Default int range is [MIN_INT, MAX_INT]. Max value is included. - int32_t NextInt(void) - { - return std::uniform_int_distribution(0x80000000, 0x7FFFFFFF)(m_gen); - } - - int32_t NextInt(int32_t MaxVal) - { - return std::uniform_int_distribution(0, MaxVal)(m_gen); - } - - int32_t NextInt(int32_t MinVal, int32_t MaxVal) - { - return std::uniform_int_distribution(MinVal, MaxVal)(m_gen); - } - - // Default float range is [0.0f, 1.0f). Max value is excluded. - float NextFloat(float MaxVal = 1.0f) - { - return std::uniform_real_distribution(0.0f, MaxVal)(m_gen); - } - - float NextFloat(float MinVal, float MaxVal) - { - return std::uniform_real_distribution(MinVal, MaxVal)(m_gen); - } - - void SetSeed(uint32_t s) - { - m_gen.seed(s); - } - - private: - - std::random_device m_rd; - std::minstd_rand m_gen; - }; -#else - class RandomNumberGenerator - { - public: - RandomNumberGenerator( uint32_t s = 0xFEA4BEE5 ) - { - SetSeed(s); - } - - // Default int range is [MIN_INT, MAX_INT]. Max value is included. - int32_t NextInt( void ) - { - return (int32_t)Rand(); - } - - uint32_t NextInt( uint32_t MaxVal ) - { - return Rand() % (MaxVal + 1); - } - - int32_t NextInt( int32_t MinVal, int32_t MaxVal ) - { - return MinVal + NextInt(MaxVal - MinVal); - } - - // Default float range is [0.0f, 1.0f). Max value is excluded. - float NextFloat( float MaxVal = 1.0f ) - { - union { uint32_t intRep; float fltRep; }; - intRep = 0x3f800000 | (NextInt() & 0x7FFFFF); - return (fltRep - 1.0f) * MaxVal; - } - - float NextFloat( float MinVal, float MaxVal ) - { - return MinVal + NextFloat(MaxVal - MinVal); - } - - void SetSeed( uint32_t s ); - - private: - - static const int n = 624, m = 397; - - uint32_t m_State[n]; - uint32_t m_Pos; - - uint32_t Rand(); - }; -#endif - - extern RandomNumberGenerator g_RNG; -} // namespace Math diff --git a/xess/samples/xess_demo/MiniEngine/Core/Math/Scalar.h b/xess/samples/xess_demo/MiniEngine/Core/Math/Scalar.h deleted file mode 100644 index d34b843..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Math/Scalar.h +++ /dev/null @@ -1,51 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "Common.h" - -namespace Math -{ - class Scalar - { - public: - INLINE Scalar() {} - INLINE Scalar( const Scalar& s ) { m_vec = s; } - INLINE Scalar( float f ) { m_vec = XMVectorReplicate(f); } - INLINE explicit Scalar( FXMVECTOR vec ) { m_vec = vec; } - INLINE explicit Scalar( EZeroTag ) { m_vec = SplatZero(); } - INLINE explicit Scalar( EIdentityTag ) { m_vec = SplatOne(); } - - INLINE operator XMVECTOR() const { return m_vec; } - INLINE operator float() const { return XMVectorGetX(m_vec); } - - private: - XMVECTOR m_vec; - }; - - INLINE Scalar operator- ( Scalar s ) { return Scalar(XMVectorNegate(s)); } - INLINE Scalar operator+ ( Scalar s1, Scalar s2 ) { return Scalar(XMVectorAdd(s1, s2)); } - INLINE Scalar operator- ( Scalar s1, Scalar s2 ) { return Scalar(XMVectorSubtract(s1, s2)); } - INLINE Scalar operator* ( Scalar s1, Scalar s2 ) { return Scalar(XMVectorMultiply(s1, s2)); } - INLINE Scalar operator/ ( Scalar s1, Scalar s2 ) { return Scalar(XMVectorDivide(s1, s2)); } - INLINE Scalar operator+ ( Scalar s1, float s2 ) { return s1 + Scalar(s2); } - INLINE Scalar operator- ( Scalar s1, float s2 ) { return s1 - Scalar(s2); } - INLINE Scalar operator* ( Scalar s1, float s2 ) { return s1 * Scalar(s2); } - INLINE Scalar operator/ ( Scalar s1, float s2 ) { return s1 / Scalar(s2); } - INLINE Scalar operator+ ( float s1, Scalar s2 ) { return Scalar(s1) + s2; } - INLINE Scalar operator- ( float s1, Scalar s2 ) { return Scalar(s1) - s2; } - INLINE Scalar operator* ( float s1, Scalar s2 ) { return Scalar(s1) * s2; } - INLINE Scalar operator/ ( float s1, Scalar s2 ) { return Scalar(s1) / s2; } - -} // namespace Math diff --git a/xess/samples/xess_demo/MiniEngine/Core/Math/Transform.h b/xess/samples/xess_demo/MiniEngine/Core/Math/Transform.h deleted file mode 100644 index 03fdf39..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Math/Transform.h +++ /dev/null @@ -1,216 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "Matrix3.h" -#include "BoundingSphere.h" - -namespace Math -{ - // Orthonormal basis (just rotation via quaternion) and translation - class OrthogonalTransform; - - // A 3x4 matrix that allows for asymmetric skew and scale - class AffineTransform; - - // Uniform scale and translation that can be compactly represented in a vec4 - class ScaleAndTranslation; - - // Uniform scale, rotation (quaternion), and translation that fits in two vec4s - class UniformTransform; - - // This transform strictly prohibits non-uniform scale. Scale itself is barely tolerated. - class OrthogonalTransform - { - public: - INLINE OrthogonalTransform() : m_rotation(kIdentity), m_translation(kZero) {} - INLINE OrthogonalTransform( Quaternion rotate ) : m_rotation(rotate), m_translation(kZero) {} - INLINE OrthogonalTransform( Vector3 translate ) : m_rotation(kIdentity), m_translation(translate) {} - INLINE OrthogonalTransform( Quaternion rotate, Vector3 translate ) : m_rotation(rotate), m_translation(translate) {} - INLINE OrthogonalTransform( const Matrix3& mat ) : m_rotation(mat), m_translation(kZero) {} - INLINE OrthogonalTransform( const Matrix3& mat, Vector3 translate ) : m_rotation(mat), m_translation(translate) {} - INLINE OrthogonalTransform( EIdentityTag ) : m_rotation(kIdentity), m_translation(kZero) {} - INLINE explicit OrthogonalTransform( const XMMATRIX& mat ) { *this = OrthogonalTransform( Matrix3(mat), Vector3(mat.r[3]) ); } - - INLINE void SetRotation( Quaternion q ) { m_rotation = q; } - INLINE void SetTranslation( Vector3 v ) { m_translation = v; } - - INLINE Quaternion GetRotation() const { return m_rotation; } - INLINE Vector3 GetTranslation() const { return m_translation; } - - static INLINE OrthogonalTransform MakeXRotation( float angle ) { return OrthogonalTransform(Quaternion(Vector3(kXUnitVector), angle)); } - static INLINE OrthogonalTransform MakeYRotation( float angle ) { return OrthogonalTransform(Quaternion(Vector3(kYUnitVector), angle)); } - static INLINE OrthogonalTransform MakeZRotation( float angle ) { return OrthogonalTransform(Quaternion(Vector3(kZUnitVector), angle)); } - static INLINE OrthogonalTransform MakeTranslation( Vector3 translate ) { return OrthogonalTransform(translate); } - - INLINE Vector3 operator* ( Vector3 vec ) const { return m_rotation * vec + m_translation; } - INLINE Vector4 operator* ( Vector4 vec ) const { return - Vector4(SetWToZero(m_rotation * Vector3((XMVECTOR)vec))) + - Vector4(SetWToOne(m_translation)) * vec.GetW(); - } - INLINE BoundingSphere operator* ( BoundingSphere sphere ) const { - return BoundingSphere(*this * sphere.GetCenter(), sphere.GetRadius()); - } - - INLINE OrthogonalTransform operator* ( const OrthogonalTransform& xform ) const { - return OrthogonalTransform( m_rotation * xform.m_rotation, m_rotation * xform.m_translation + m_translation ); - } - - INLINE OrthogonalTransform operator~ () const { Quaternion invertedRotation = ~m_rotation; - return OrthogonalTransform( invertedRotation, invertedRotation * -m_translation ); - } - - private: - - Quaternion m_rotation; - Vector3 m_translation; - }; - - // - // A transform that lacks rotation and has only uniform scale. - // - class ScaleAndTranslation - { - public: - INLINE ScaleAndTranslation() - {} - INLINE ScaleAndTranslation( EIdentityTag ) - : m_repr(kWUnitVector) {} - INLINE ScaleAndTranslation(float tx, float ty, float tz, float scale) - : m_repr(tx, ty, tz, scale) {} - INLINE ScaleAndTranslation(Vector3 translate, Scalar scale) - { - m_repr = Vector4(translate); - m_repr.SetW(scale); - } - INLINE explicit ScaleAndTranslation(const XMVECTOR& v) - : m_repr(v) {} - - INLINE void SetScale(Scalar s) { m_repr.SetW(s); } - INLINE void SetTranslation(Vector3 t) { m_repr.SetXYZ(t); } - - INLINE Scalar GetScale() const { return m_repr.GetW(); } - INLINE Vector3 GetTranslation() const { return (Vector3)m_repr; } - - INLINE BoundingSphere operator*(const BoundingSphere& sphere) const - { - Vector4 scaledSphere = (Vector4)sphere * GetScale(); - Vector4 translation = Vector4(SetWToZero(m_repr)); - return BoundingSphere(scaledSphere + translation); - } - - private: - Vector4 m_repr; - }; - - // - // This transform allows for rotation, translation, and uniform scale - // - class UniformTransform - { - public: - INLINE UniformTransform() - {} - INLINE UniformTransform( EIdentityTag ) - : m_rotation(kIdentity), m_translationScale(kIdentity) {} - INLINE UniformTransform(Quaternion rotation, ScaleAndTranslation transScale) - : m_rotation(rotation), m_translationScale(transScale) - {} - INLINE UniformTransform(Quaternion rotation, Scalar scale, Vector3 translation) - : m_rotation(rotation), m_translationScale(translation, scale) - {} - - INLINE void SetRotation(Quaternion r) { m_rotation = r; } - INLINE void SetScale(Scalar s) { m_translationScale.SetScale(s); } - INLINE void SetTranslation(Vector3 t) { m_translationScale.SetTranslation(t); } - - - INLINE Quaternion GetRotation() const { return m_rotation; } - INLINE Scalar GetScale() const { return m_translationScale.GetScale(); } - INLINE Vector3 GetTranslation() const { return m_translationScale.GetTranslation(); } - - - INLINE Vector3 operator*( Vector3 vec ) const - { - return m_rotation * (vec * m_translationScale.GetScale()) + m_translationScale.GetTranslation(); - } - - INLINE BoundingSphere operator*( BoundingSphere sphere ) const - { - return BoundingSphere(*this * sphere.GetCenter(), GetScale() * sphere.GetRadius() ); - } - - private: - Quaternion m_rotation; - ScaleAndTranslation m_translationScale; - }; - - // A AffineTransform is a 3x4 matrix with an implicit 4th row = [0,0,0,1]. This is used to perform a change of - // basis on 3D points. An affine transformation does not have to have orthonormal basis vectors. - class AffineTransform - { - public: - INLINE AffineTransform() - {} - INLINE AffineTransform( Vector3 x, Vector3 y, Vector3 z, Vector3 w ) - : m_basis(x, y, z), m_translation(w) {} - INLINE AffineTransform( Vector3 translate ) - : m_basis(kIdentity), m_translation(translate) {} - INLINE AffineTransform( const Matrix3& mat, Vector3 translate = Vector3(kZero) ) - : m_basis(mat), m_translation(translate) {} - INLINE AffineTransform( Quaternion rot, Vector3 translate = Vector3(kZero) ) - : m_basis(rot), m_translation(translate) {} - INLINE AffineTransform( const OrthogonalTransform& xform ) - : m_basis(xform.GetRotation()), m_translation(xform.GetTranslation()) {} - INLINE AffineTransform( const UniformTransform& xform ) - { - m_basis = Matrix3(xform.GetRotation()) * xform.GetScale(); - m_translation = xform.GetTranslation(); - } - INLINE AffineTransform( EIdentityTag ) - : m_basis(kIdentity), m_translation(kZero) {} - INLINE explicit AffineTransform( const XMMATRIX& mat ) - : m_basis(mat), m_translation(mat.r[3]) {} - - INLINE operator XMMATRIX() const { return (XMMATRIX&)*this; } - - INLINE void SetX(Vector3 x) { m_basis.SetX(x); } - INLINE void SetY(Vector3 y) { m_basis.SetY(y); } - INLINE void SetZ(Vector3 z) { m_basis.SetZ(z); } - INLINE void SetTranslation(Vector3 w) { m_translation = w; } - INLINE void SetBasis(const Matrix3& basis) { m_basis = basis; } - - INLINE Vector3 GetX() const { return m_basis.GetX(); } - INLINE Vector3 GetY() const { return m_basis.GetY(); } - INLINE Vector3 GetZ() const { return m_basis.GetZ(); } - INLINE Vector3 GetTranslation() const { return m_translation; } - INLINE const Matrix3& GetBasis() const { return (const Matrix3&)*this; } - - static INLINE AffineTransform MakeXRotation( float angle ) { return AffineTransform(Matrix3::MakeXRotation(angle)); } - static INLINE AffineTransform MakeYRotation( float angle ) { return AffineTransform(Matrix3::MakeYRotation(angle)); } - static INLINE AffineTransform MakeZRotation( float angle ) { return AffineTransform(Matrix3::MakeZRotation(angle)); } - static INLINE AffineTransform MakeScale( float scale ) { return AffineTransform(Matrix3::MakeScale(scale)); } - static INLINE AffineTransform MakeScale( Vector3 scale ) { return AffineTransform(Matrix3::MakeScale(scale)); } - static INLINE AffineTransform MakeTranslation( Vector3 translate ) { return AffineTransform(translate); } - - INLINE Vector3 operator* ( Vector3 vec ) const { return m_basis * vec + m_translation; } - INLINE AffineTransform operator* ( const AffineTransform& mat ) const { - return AffineTransform( m_basis * mat.m_basis, *this * mat.GetTranslation() ); - } - - private: - Matrix3 m_basis; - Vector3 m_translation; - }; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Math/Vector.h b/xess/samples/xess_demo/MiniEngine/Core/Math/Vector.h deleted file mode 100644 index c888e1a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Math/Vector.h +++ /dev/null @@ -1,148 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "Scalar.h" - -namespace Math -{ - class Vector4; - - // A 3-vector with an unspecified fourth component. Depending on the context, the W can be 0 or 1, but both are implicit. - // The actual value of the fourth component is undefined for performance reasons. - class Vector3 - { - public: - - INLINE Vector3() {} - INLINE Vector3( float x, float y, float z ) { m_vec = XMVectorSet(x, y, z, z); } - INLINE Vector3( const XMFLOAT3& v ) { m_vec = XMLoadFloat3(&v); } - INLINE Vector3( const Vector3& v ) { m_vec = v; } - INLINE Vector3( Scalar s ) { m_vec = s; } - INLINE explicit Vector3( Vector4 vec ); - INLINE explicit Vector3( FXMVECTOR vec ) { m_vec = vec; } - INLINE explicit Vector3( EZeroTag ) { m_vec = SplatZero(); } - INLINE explicit Vector3( EIdentityTag ) { m_vec = SplatOne(); } - INLINE explicit Vector3( EXUnitVector ) { m_vec = CreateXUnitVector(); } - INLINE explicit Vector3( EYUnitVector ) { m_vec = CreateYUnitVector(); } - INLINE explicit Vector3( EZUnitVector ) { m_vec = CreateZUnitVector(); } - - INLINE operator XMVECTOR() const { return m_vec; } - - INLINE Scalar GetX() const { return Scalar(XMVectorSplatX(m_vec)); } - INLINE Scalar GetY() const { return Scalar(XMVectorSplatY(m_vec)); } - INLINE Scalar GetZ() const { return Scalar(XMVectorSplatZ(m_vec)); } - INLINE void SetX( Scalar x ) { m_vec = XMVectorPermute<4,1,2,3>(m_vec, x); } - INLINE void SetY( Scalar y ) { m_vec = XMVectorPermute<0,5,2,3>(m_vec, y); } - INLINE void SetZ( Scalar z ) { m_vec = XMVectorPermute<0,1,6,3>(m_vec, z); } - - INLINE Vector3 operator- () const { return Vector3(XMVectorNegate(m_vec)); } - INLINE Vector3 operator+ ( Vector3 v2 ) const { return Vector3(XMVectorAdd(m_vec, v2)); } - INLINE Vector3 operator- ( Vector3 v2 ) const { return Vector3(XMVectorSubtract(m_vec, v2)); } - INLINE Vector3 operator* ( Vector3 v2 ) const { return Vector3(XMVectorMultiply(m_vec, v2)); } - INLINE Vector3 operator/ ( Vector3 v2 ) const { return Vector3(XMVectorDivide(m_vec, v2)); } - INLINE Vector3 operator* ( Scalar v2 ) const { return *this * Vector3(v2); } - INLINE Vector3 operator/ ( Scalar v2 ) const { return *this / Vector3(v2); } - INLINE Vector3 operator* ( float v2 ) const { return *this * Scalar(v2); } - INLINE Vector3 operator/ ( float v2 ) const { return *this / Scalar(v2); } - - INLINE Vector3& operator += ( Vector3 v ) { *this = *this + v; return *this; } - INLINE Vector3& operator -= ( Vector3 v ) { *this = *this - v; return *this; } - INLINE Vector3& operator *= ( Vector3 v ) { *this = *this * v; return *this; } - INLINE Vector3& operator /= ( Vector3 v ) { *this = *this / v; return *this; } - - INLINE friend Vector3 operator* ( Scalar v1, Vector3 v2 ) { return Vector3(v1) * v2; } - INLINE friend Vector3 operator/ ( Scalar v1, Vector3 v2 ) { return Vector3(v1) / v2; } - INLINE friend Vector3 operator* ( float v1, Vector3 v2 ) { return Scalar(v1) * v2; } - INLINE friend Vector3 operator/ ( float v1, Vector3 v2 ) { return Scalar(v1) / v2; } - - protected: - XMVECTOR m_vec; - }; - - // A 4-vector, completely defined. - class Vector4 - { - public: - INLINE Vector4() {} - INLINE Vector4( float x, float y, float z, float w ) { m_vec = XMVectorSet(x, y, z, w); } - INLINE Vector4( const XMFLOAT4& v ) { m_vec = XMLoadFloat4(&v); } - INLINE Vector4( Vector3 xyz, float w ) { m_vec = XMVectorSetW(xyz, w); } - INLINE Vector4( const Vector4& v ) { m_vec = v; } - INLINE Vector4( const Scalar& s ) { m_vec = s; } - INLINE explicit Vector4( Vector3 xyz ) { m_vec = SetWToOne(xyz); } - INLINE explicit Vector4( FXMVECTOR vec ) { m_vec = vec; } - INLINE explicit Vector4( EZeroTag ) { m_vec = SplatZero(); } - INLINE explicit Vector4( EIdentityTag ) { m_vec = SplatOne(); } - INLINE explicit Vector4( EXUnitVector ) { m_vec = CreateXUnitVector(); } - INLINE explicit Vector4( EYUnitVector ) { m_vec = CreateYUnitVector(); } - INLINE explicit Vector4( EZUnitVector ) { m_vec = CreateZUnitVector(); } - INLINE explicit Vector4( EWUnitVector ) { m_vec = CreateWUnitVector(); } - - INLINE operator XMVECTOR() const { return m_vec; } - - INLINE Scalar GetX() const { return Scalar(XMVectorSplatX(m_vec)); } - INLINE Scalar GetY() const { return Scalar(XMVectorSplatY(m_vec)); } - INLINE Scalar GetZ() const { return Scalar(XMVectorSplatZ(m_vec)); } - INLINE Scalar GetW() const { return Scalar(XMVectorSplatW(m_vec)); } - INLINE void SetX( Scalar x ) { m_vec = XMVectorPermute<4,1,2,3>(m_vec, x); } - INLINE void SetY( Scalar y ) { m_vec = XMVectorPermute<0,5,2,3>(m_vec, y); } - INLINE void SetZ( Scalar z ) { m_vec = XMVectorPermute<0,1,6,3>(m_vec, z); } - INLINE void SetW( Scalar w ) { m_vec = XMVectorPermute<0,1,2,7>(m_vec, w); } - INLINE void SetXYZ( Vector3 xyz ) { m_vec = XMVectorPermute<0,1,2,7>(xyz, m_vec); } - - INLINE Vector4 operator- () const { return Vector4(XMVectorNegate(m_vec)); } - INLINE Vector4 operator+ ( Vector4 v2 ) const { return Vector4(XMVectorAdd(m_vec, v2)); } - INLINE Vector4 operator- ( Vector4 v2 ) const { return Vector4(XMVectorSubtract(m_vec, v2)); } - INLINE Vector4 operator* ( Vector4 v2 ) const { return Vector4(XMVectorMultiply(m_vec, v2)); } - INLINE Vector4 operator/ ( Vector4 v2 ) const { return Vector4(XMVectorDivide(m_vec, v2)); } - INLINE Vector4 operator* ( Scalar v2 ) const { return *this * Vector4(v2); } - INLINE Vector4 operator/ ( Scalar v2 ) const { return *this / Vector4(v2); } - INLINE Vector4 operator* ( float v2 ) const { return *this * Scalar(v2); } - INLINE Vector4 operator/ ( float v2 ) const { return *this / Scalar(v2); } - - INLINE void operator*= ( float v2 ) { *this = *this * Scalar(v2); } - INLINE void operator/= ( float v2 ) { *this = *this / Scalar(v2); } - - INLINE friend Vector4 operator* ( Scalar v1, Vector4 v2 ) { return Vector4(v1) * v2; } - INLINE friend Vector4 operator/ ( Scalar v1, Vector4 v2 ) { return Vector4(v1) / v2; } - INLINE friend Vector4 operator* ( float v1, Vector4 v2 ) { return Scalar(v1) * v2; } - INLINE friend Vector4 operator/ ( float v1, Vector4 v2 ) { return Scalar(v1) / v2; } - - protected: - XMVECTOR m_vec; - }; - - // Defined after Vector4 methods are declared - INLINE Vector3::Vector3( Vector4 vec ) : m_vec((XMVECTOR)vec) - { - } - - // For W != 1, divide XYZ by W. If W == 0, do nothing - INLINE Vector3 MakeHomogeneous( Vector4 v ) - { - Scalar W = v.GetW(); - return Vector3(XMVectorSelect( XMVectorDivide(v, W), v, XMVectorEqual(W, SplatZero()) )); - } - - class BoolVector - { - public: - INLINE BoolVector( FXMVECTOR vec ) { m_vec = vec; } - INLINE operator XMVECTOR() const { return m_vec; } - protected: - XMVECTOR m_vec; - }; - -} // namespace Math diff --git a/xess/samples/xess_demo/MiniEngine/Core/MotionBlur.cpp b/xess/samples/xess_demo/MiniEngine/Core/MotionBlur.cpp deleted file mode 100644 index 0b3a8b5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/MotionBlur.cpp +++ /dev/null @@ -1,396 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -// Modified 2022, Intel Corporation. -// Added support for super sampling. - -#include "pch.h" -#include "MotionBlur.h" -#include "Camera.h" -#include "BufferManager.h" -#include "GraphicsCore.h" -#include "GraphicsCommon.h" -#include "CommandContext.h" -#include "Camera.h" -#include "TemporalEffects.h" -#include "PostEffects.h" -#include "SystemTime.h" -#include "Display.h" - -#include "CompiledShaders/ScreenQuadCommonVS.h" -#include "CompiledShaders/CameraMotionBlurPrePassCS.h" -#include "CompiledShaders/CameraMotionBlurPrePassLinearZCS.h" -#include "CompiledShaders/MotionBlurPrePassCS.h" -#include "CompiledShaders/MotionBlurFinalPassCS.h" -#include "CompiledShaders/MotionBlurFinalPassPS.h" - -#include "CompiledShaders/MotionBlurPrePassUnpackedVelocityCS.h" -#include "CompiledShaders/MotionBlurFinalPassUnpackedVelocityCS.h" -#include "CompiledShaders/MotionBlurFinalPassUnpackedVelocityPS.h" - -#include "CompiledShaders/CameraVelocityCS.h" -#include "CompiledShaders/TemporalBlendCS.h" -#include "CompiledShaders/BoundNeighborhoodCS.h" - -using namespace Graphics; -using namespace Math; - -namespace MotionBlur -{ - BoolVar Enable("Graphics/Motion Blur/Enable", false); - - ComputePSO s_CameraMotionBlurPrePassCS[2] = { {L"Motion Blur: Camera Motion Blur Pre-Pass CS"}, { L"Motion Blur: Camera Motion Blur Pre-Pass Linear Z CS" } }; - ComputePSO s_MotionBlurPrePassCS(L"Motion Blur: Motion Blur Pre-Pass CS"); - ComputePSO s_MotionBlurFinalPassCS(L"Motion Blur: Motion Blur Final Pass CS"); - GraphicsPSO s_MotionBlurFinalPassPS(L"Motion Blur: Motion Blur Final Pass PS"); - - ComputePSO s_MotionBlurPrePassCS_UnpackedVelocity(L"Motion Blur: Motion Blur Pre-Pass CS - Unpacked Velocity"); - ComputePSO s_MotionBlurFinalPassCS_UnpackedVelocity(L"Motion Blur: Motion Blur Final Pass CS - Unpacked Velocity"); - GraphicsPSO s_MotionBlurFinalPassPS_UnpackedVelocity(L"Motion Blur: Motion Blur Final Pass PS - Unpacked Velocity"); - - ComputePSO s_CameraVelocityCS[2] = { { L"Motion Blur: Camera Velocity CS" },{ L"Motion Blur: Camera Velocity Linear Z CS" } }; -} - -void MotionBlur::Initialize( void ) -{ -#define CreatePSO( ObjName, ShaderByteCode ) \ - ObjName.SetRootSignature(g_CommonRS); \ - ObjName.SetComputeShader(ShaderByteCode, sizeof(ShaderByteCode) ); \ - ObjName.Finalize(); - - if (g_bTypedUAVLoadSupport_R11G11B10_FLOAT) - { - CreatePSO(s_MotionBlurFinalPassCS, g_pMotionBlurFinalPassCS); - CreatePSO(s_MotionBlurFinalPassCS_UnpackedVelocity, g_pMotionBlurFinalPassUnpackedVelocityCS); - } - else - { - s_MotionBlurFinalPassPS.SetRootSignature(g_CommonRS); - s_MotionBlurFinalPassPS.SetRasterizerState( RasterizerTwoSided ); - s_MotionBlurFinalPassPS.SetBlendState( BlendPreMultiplied ); - s_MotionBlurFinalPassPS.SetDepthStencilState( DepthStateDisabled ); - s_MotionBlurFinalPassPS.SetSampleMask(0xFFFFFFFF); - s_MotionBlurFinalPassPS.SetInputLayout(0, nullptr); - s_MotionBlurFinalPassPS.SetPrimitiveTopologyType(D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE); - s_MotionBlurFinalPassPS.SetVertexShader( g_pScreenQuadCommonVS, sizeof(g_pScreenQuadCommonVS) ); - s_MotionBlurFinalPassPS.SetPixelShader( g_pMotionBlurFinalPassPS, sizeof(g_pMotionBlurFinalPassPS) ); - s_MotionBlurFinalPassPS.SetRenderTargetFormat(g_SceneColorBuffer.GetFormat(), DXGI_FORMAT_UNKNOWN); - s_MotionBlurFinalPassPS.Finalize(); - - s_MotionBlurFinalPassPS_UnpackedVelocity.SetRootSignature(g_CommonRS); - s_MotionBlurFinalPassPS_UnpackedVelocity.SetRasterizerState(RasterizerTwoSided); - s_MotionBlurFinalPassPS_UnpackedVelocity.SetBlendState(BlendPreMultiplied); - s_MotionBlurFinalPassPS_UnpackedVelocity.SetDepthStencilState(DepthStateDisabled); - s_MotionBlurFinalPassPS_UnpackedVelocity.SetSampleMask(0xFFFFFFFF); - s_MotionBlurFinalPassPS_UnpackedVelocity.SetInputLayout(0, nullptr); - s_MotionBlurFinalPassPS_UnpackedVelocity.SetPrimitiveTopologyType(D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE); - s_MotionBlurFinalPassPS_UnpackedVelocity.SetVertexShader(g_pScreenQuadCommonVS, sizeof(g_pScreenQuadCommonVS)); - s_MotionBlurFinalPassPS_UnpackedVelocity.SetPixelShader(g_pMotionBlurFinalPassUnpackedVelocityPS, sizeof(g_pMotionBlurFinalPassUnpackedVelocityPS)); - s_MotionBlurFinalPassPS_UnpackedVelocity.SetRenderTargetFormat(g_SceneColorBuffer.GetFormat(), DXGI_FORMAT_UNKNOWN); - s_MotionBlurFinalPassPS_UnpackedVelocity.Finalize(); - } - CreatePSO( s_CameraMotionBlurPrePassCS[0], g_pCameraMotionBlurPrePassCS ); - CreatePSO( s_CameraMotionBlurPrePassCS[1], g_pCameraMotionBlurPrePassLinearZCS ); - CreatePSO(s_MotionBlurPrePassCS, g_pMotionBlurPrePassCS); - CreatePSO(s_MotionBlurPrePassCS_UnpackedVelocity, g_pMotionBlurPrePassUnpackedVelocityCS); - CreatePSO( s_CameraVelocityCS[0], g_pCameraVelocityCS ); - CreatePSO( s_CameraVelocityCS[1], g_pCameraVelocityCS ); - -#undef CreatePSO -} - -void MotionBlur::Shutdown( void ) -{ -} - -// Linear Z ends up being faster since we haven't officially decompressed the depth buffer. You -// would think that it might be slower to use linear Z because we have to convert it back to -// hyperbolic Z for the reprojection. Nevertheless, the reduced bandwidth and decompress eliminate -// make Linear Z the better choice. (The choice also lets you evict the depth buffer from ESRAM.) - -void MotionBlur::GenerateCameraVelocityBuffer( CommandContext& BaseContext, const Camera& camera, bool UseLinearZ ) -{ - GenerateCameraVelocityBuffer(BaseContext, camera.GetReprojectionMatrix(), camera.GetNearClip(), camera.GetFarClip(), UseLinearZ); -} - -void MotionBlur::GenerateCameraVelocityBuffer( CommandContext& BaseContext, const Matrix4& reprojectionMatrix, float nearClip, float farClip, bool UseLinearZ) -{ - ScopedTimer _prof(L"Generate Camera Velocity", BaseContext); - - ComputeContext& Context = BaseContext.GetComputeContext(); - - Context.SetRootSignature(g_CommonRS); - - uint32_t Width = g_SceneColorBuffer.GetWidth(); - uint32_t Height = g_SceneColorBuffer.GetHeight(); - - float RcpHalfDimX = 2.0f / Width; - float RcpHalfDimY = 2.0f / Height; - float RcpZMagic = nearClip / (farClip - nearClip); - - Matrix4 preMult = Matrix4( - Vector4( RcpHalfDimX, 0.0f, 0.0f, 0.0f ), - Vector4( 0.0f, -RcpHalfDimY, 0.0f, 0.0f), - Vector4( 0.0f, 0.0f, UseLinearZ ? RcpZMagic : 1.0f, 0.0f ), - Vector4( -1.0f, 1.0f, UseLinearZ ? -RcpZMagic : 0.0f, 1.0f ) - ); - - Matrix4 postMult = Matrix4( - Vector4( 1.0f / RcpHalfDimX, 0.0f, 0.0f, 0.0f ), - Vector4( 0.0f, -1.0f / RcpHalfDimY, 0.0f, 0.0f ), - Vector4( 0.0f, 0.0f, 1.0f, 0.0f ), - Vector4( 1.0f / RcpHalfDimX, 1.0f / RcpHalfDimY, 0.0f, 1.0f ) ); - - - Matrix4 CurToPrevXForm = postMult * reprojectionMatrix * preMult; - - Context.SetDynamicConstantBufferView(3, sizeof(CurToPrevXForm), &CurToPrevXForm); - Context.TransitionResource(g_VelocityBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - - ColorBuffer& LinearDepth = g_LinearDepth[ TemporalEffects::GetFrameIndexMod2() ]; - if (UseLinearZ) - Context.TransitionResource(LinearDepth, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - else - Context.TransitionResource(g_SceneDepthBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - - Context.SetPipelineState(s_CameraVelocityCS[UseLinearZ ? 1 : 0]); - Context.SetDynamicDescriptor(1, 0, UseLinearZ ? LinearDepth.GetSRV() : g_SceneDepthBuffer.GetDepthSRV()); - Context.SetDynamicDescriptor(2, 0, g_VelocityBuffer.GetUAV()); - Context.Dispatch2D(Width, Height); -} - - -void MotionBlur::RenderCameraBlur( CommandContext& BaseContext, const Camera& camera, bool UseLinearZ ) -{ - RenderCameraBlur(BaseContext, camera.GetReprojectionMatrix(), camera.GetNearClip(), camera.GetFarClip(), UseLinearZ); -} - -void MotionBlur::RenderCameraBlur( CommandContext& BaseContext, const Matrix4& reprojectionMatrix, float nearClip, float farClip, bool UseLinearZ) -{ - ScopedTimer _prof(L"MotionBlur", BaseContext); - - if (!Enable) - return; - - ComputeContext& Context = BaseContext.GetComputeContext(); - - Context.SetRootSignature(g_CommonRS); - - uint32_t Width = g_SceneColorBuffer.GetWidth(); - uint32_t Height = g_SceneColorBuffer.GetHeight(); - - float RcpHalfDimX = 2.0f / Width; - float RcpHalfDimY = 2.0f / Height; - float RcpZMagic = nearClip / (farClip - nearClip); - - Matrix4 preMult = Matrix4( - Vector4( RcpHalfDimX, 0.0f, 0.0f, 0.0f ), - Vector4( 0.0f, -RcpHalfDimY, 0.0f, 0.0f), - Vector4( 0.0f, 0.0f, UseLinearZ ? RcpZMagic : 1.0f, 0.0f ), - Vector4( -1.0f, 1.0f, UseLinearZ ? -RcpZMagic : 0.0f, 1.0f ) - ); - - Matrix4 postMult = Matrix4( - Vector4( 1.0f / RcpHalfDimX, 0.0f, 0.0f, 0.0f ), - Vector4( 0.0f, -1.0f / RcpHalfDimY, 0.0f, 0.0f ), - Vector4( 0.0f, 0.0f, 1.0f, 0.0f ), - Vector4( 1.0f / RcpHalfDimX, 1.0f / RcpHalfDimY, 0.0f, 1.0f ) ); - - Matrix4 CurToPrevXForm = postMult * reprojectionMatrix * preMult; - - Context.SetDynamicConstantBufferView(3, sizeof(CurToPrevXForm), &CurToPrevXForm); - - ColorBuffer& LinearDepth = g_LinearDepth[ TemporalEffects::GetFrameIndexMod2() ]; - if (UseLinearZ) - Context.TransitionResource(LinearDepth, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - else - Context.TransitionResource(g_SceneDepthBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - - if (Enable) - { - Context.TransitionResource(g_VelocityBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_MotionPrepBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_SceneColorBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - - Context.SetPipelineState(s_CameraMotionBlurPrePassCS[UseLinearZ ? 1 : 0]); - Context.SetDynamicDescriptor(1, 0, g_SceneColorBuffer.GetSRV()); - Context.SetDynamicDescriptor(1, 1, UseLinearZ ? LinearDepth.GetSRV() : g_SceneDepthBuffer.GetDepthSRV()); - Context.SetDynamicDescriptor(2, 0, g_MotionPrepBuffer.GetUAV()); - Context.SetDynamicDescriptor(2, 1, g_VelocityBuffer.GetUAV()); - Context.Dispatch2D(g_MotionPrepBuffer.GetWidth(), g_MotionPrepBuffer.GetHeight()); - - if (g_bTypedUAVLoadSupport_R11G11B10_FLOAT) - { - Context.SetPipelineState(s_MotionBlurFinalPassCS); - Context.SetConstants(0, 1.0f / Width, 1.0f / Height); - - Context.TransitionResource(g_SceneColorBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_VelocityBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_MotionPrepBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.SetDynamicDescriptor(2, 0, g_SceneColorBuffer.GetUAV()); - Context.SetDynamicDescriptor(1, 0, g_VelocityBuffer.GetSRV()); - Context.SetDynamicDescriptor(1, 1, g_MotionPrepBuffer.GetSRV()); - - Context.Dispatch2D(Width, Height); - - Context.InsertUAVBarrier(g_SceneColorBuffer); - } - else - { - GraphicsContext& GrContext = BaseContext.GetGraphicsContext(); - GrContext.SetRootSignature(g_CommonRS); - GrContext.SetPipelineState(s_MotionBlurFinalPassPS); - GrContext.TransitionResource(g_SceneColorBuffer, D3D12_RESOURCE_STATE_RENDER_TARGET); - GrContext.TransitionResource(g_VelocityBuffer, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - GrContext.TransitionResource(g_MotionPrepBuffer, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - GrContext.SetDynamicDescriptor(1, 0, g_VelocityBuffer.GetSRV()); - GrContext.SetDynamicDescriptor(1, 1, g_MotionPrepBuffer.GetSRV()); - GrContext.SetConstants(0, 1.0f / Width, 1.0f / Height); - GrContext.SetRenderTarget(g_SceneColorBuffer.GetRTV()); - GrContext.SetViewportAndScissor(0, 0, Width, Height); - GrContext.Draw(3); - } - } - else - { - Context.SetPipelineState(s_CameraVelocityCS[UseLinearZ ? 1 : 0]); - Context.SetDynamicDescriptor(1, 0, UseLinearZ ? LinearDepth.GetSRV() : g_SceneDepthBuffer.GetDepthSRV()); - Context.SetDynamicDescriptor(2, 0, g_VelocityBuffer.GetUAV()); - Context.Dispatch2D(Width, Height); - } -} - -void MotionBlur::RenderObjectBlur( CommandContext& BaseContext, ColorBuffer& velocityBuffer ) -{ - ScopedTimer _prof(L"MotionBlur", BaseContext); - - if (!Enable) - return; - - bool isUpscalingMode = Graphics::IsUpscalingEnabled(); - - if (isUpscalingMode) - { - uint32_t Width = g_UpscaledSceneColorBuffer.GetWidth(); - uint32_t Height = g_UpscaledSceneColorBuffer.GetHeight(); - - ComputeContext& Context = BaseContext.GetComputeContext(); - - Context.SetRootSignature(g_CommonRS); - - Context.TransitionResource(g_MotionPrepBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_UpscaledSceneColorBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_UpscaledVelocityBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - - Context.SetDynamicDescriptor(2, 0, g_MotionPrepBuffer.GetUAV()); - Context.SetDynamicDescriptor(1, 0, g_UpscaledSceneColorBuffer.GetSRV()); - Context.SetDynamicDescriptor(1, 1, g_UpscaledVelocityBuffer.GetSRV()); - - Context.SetPipelineState(s_MotionBlurPrePassCS_UnpackedVelocity); - Context.Dispatch2D(g_MotionPrepBuffer.GetWidth(), g_MotionPrepBuffer.GetHeight()); - - if (g_bTypedUAVLoadSupport_R11G11B10_FLOAT) - { - Context.SetPipelineState(s_MotionBlurFinalPassCS_UnpackedVelocity); - - Context.TransitionResource(g_UpscaledSceneColorBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_UpscaledVelocityBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_MotionPrepBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - - Context.SetDynamicDescriptor(2, 0, g_UpscaledSceneColorBuffer.GetUAV()); - Context.SetDynamicDescriptor(1, 0, g_UpscaledVelocityBuffer.GetSRV()); - Context.SetDynamicDescriptor(1, 1, g_MotionPrepBuffer.GetSRV()); - Context.SetConstants(0, 1.0f / Width, 1.0f / Height); - - Context.Dispatch2D(Width, Height); - - Context.InsertUAVBarrier(g_UpscaledSceneColorBuffer); - } - else - { - GraphicsContext& GrContext = BaseContext.GetGraphicsContext(); - GrContext.SetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - GrContext.SetRootSignature(g_CommonRS); - GrContext.SetPipelineState(s_MotionBlurFinalPassPS_UnpackedVelocity); - - GrContext.TransitionResource(g_UpscaledSceneColorBuffer, D3D12_RESOURCE_STATE_RENDER_TARGET); - GrContext.TransitionResource(g_UpscaledVelocityBuffer, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - GrContext.TransitionResource(g_MotionPrepBuffer, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - - GrContext.SetDynamicDescriptor(1, 0, g_UpscaledVelocityBuffer.GetSRV()); - GrContext.SetDynamicDescriptor(1, 1, g_MotionPrepBuffer.GetSRV()); - GrContext.SetConstants(0, 1.0f / Width, 1.0f / Height); - GrContext.SetRenderTarget(g_UpscaledSceneColorBuffer.GetRTV()); - GrContext.SetViewportAndScissor(0, 0, Width, Height); - - GrContext.Draw(3); - } - } - else - { - uint32_t Width = g_SceneColorBuffer.GetWidth(); - uint32_t Height = g_SceneColorBuffer.GetHeight(); - - ComputeContext& Context = BaseContext.GetComputeContext(); - - Context.SetRootSignature(g_CommonRS); - - Context.TransitionResource(g_MotionPrepBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_SceneColorBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(velocityBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - - Context.SetDynamicDescriptor(2, 0, g_MotionPrepBuffer.GetUAV()); - Context.SetDynamicDescriptor(1, 0, g_SceneColorBuffer.GetSRV()); - Context.SetDynamicDescriptor(1, 1, velocityBuffer.GetSRV()); - - Context.SetPipelineState(s_MotionBlurPrePassCS); - Context.Dispatch2D(g_MotionPrepBuffer.GetWidth(), g_MotionPrepBuffer.GetHeight()); - - if (g_bTypedUAVLoadSupport_R11G11B10_FLOAT) - { - Context.SetPipelineState(s_MotionBlurFinalPassCS); - - Context.TransitionResource(g_SceneColorBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(velocityBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_MotionPrepBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - - Context.SetDynamicDescriptor(2, 0, g_SceneColorBuffer.GetUAV()); - Context.SetDynamicDescriptor(1, 0, velocityBuffer.GetSRV()); - Context.SetDynamicDescriptor(1, 1, g_MotionPrepBuffer.GetSRV()); - Context.SetConstants(0, 1.0f / Width, 1.0f / Height); - - Context.Dispatch2D(Width, Height); - - Context.InsertUAVBarrier(g_SceneColorBuffer); - } - else - { - GraphicsContext& GrContext = BaseContext.GetGraphicsContext(); - GrContext.SetRootSignature(g_CommonRS); - GrContext.SetPipelineState(s_MotionBlurFinalPassPS); - - GrContext.TransitionResource(g_SceneColorBuffer, D3D12_RESOURCE_STATE_RENDER_TARGET); - GrContext.TransitionResource(velocityBuffer, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - GrContext.TransitionResource(g_MotionPrepBuffer, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - - GrContext.SetDynamicDescriptor(1, 0, velocityBuffer.GetSRV()); - GrContext.SetDynamicDescriptor(1, 1, g_MotionPrepBuffer.GetSRV()); - GrContext.SetConstants(0, 1.0f / Width, 1.0f / Height); - GrContext.SetRenderTarget(g_SceneColorBuffer.GetRTV()); - GrContext.SetViewportAndScissor(0, 0, Width, Height); - - GrContext.Draw(3); - } - } -} - diff --git a/xess/samples/xess_demo/MiniEngine/Core/MotionBlur.h b/xess/samples/xess_demo/MiniEngine/Core/MotionBlur.h deleted file mode 100644 index 01971ef..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/MotionBlur.h +++ /dev/null @@ -1,41 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "EngineTuning.h" - -// Forward declarations -namespace Math { class Matrix4; class Camera; } -class ColorBuffer; -class CommandContext; - -namespace MotionBlur -{ - extern BoolVar Enable; - - void Initialize( void ); - void Shutdown( void ); - - void GenerateCameraVelocityBuffer( CommandContext& Context, const Math::Camera& camera, bool UseLinearZ = true ); - void GenerateCameraVelocityBuffer( CommandContext& Context, const Math::Matrix4& reprojectionMatrix, float nearClip, float farClip, bool UseLinearZ = true); - - // Generate motion blur only associated with the camera. Does not handle fast-moving objects well, but - // does not require a full screen velocity buffer. - void RenderCameraBlur( CommandContext& Context, const Math::Camera& camera, bool UseLinearZ = true ); - void RenderCameraBlur( CommandContext& Context, const Math::Matrix4& reprojectionMatrix, float nearClip, float farClip, bool UseLinearZ = true); - - // Generate proper motion blur that takes into account the velocity of each pixel. Requires a pre-generated - // velocity buffer (R16G16_FLOAT preferred.) - void RenderObjectBlur( CommandContext& Context, ColorBuffer& velocityBuffer ); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/ParticleEffect.cpp b/xess/samples/xess_demo/MiniEngine/Core/ParticleEffect.cpp deleted file mode 100644 index 0f38d46..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/ParticleEffect.cpp +++ /dev/null @@ -1,166 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): Julia Careaga -// James Stanard -// - -#include "pch.h" -#include "ParticleEffect.h" -#include "CommandContext.h" -#include "GraphicsCore.h" -#include "BufferManager.h" -#include "ParticleEffectManager.h" -#include "GameInput.h" -#include "Math/Random.h" - -using namespace Math; -using namespace ParticleEffectManager; - -namespace ParticleEffectManager -{ - extern ComputePSO s_ParticleSpawnCS; - extern ComputePSO s_ParticleUpdateCS; - extern ComputePSO s_ParticleDispatchIndirectArgsCS; - extern StructuredBuffer SpriteVertexBuffer; - extern RandomNumberGenerator s_RNG; -} - -ParticleEffect::ParticleEffect(ParticleEffectProperties& effectProperties) -{ - m_ElapsedTime = 0.0; - m_EffectProperties = effectProperties; -} - -inline static Color RandColor( Color c0, Color c1 ) -{ - // We might want to find min and max of each channel rather than assuming c0 <= c1 - return Color( - s_RNG.NextFloat( c0.R(), c1.R()), - s_RNG.NextFloat( c0.G(), c1.G()), - s_RNG.NextFloat( c0.B(), c1.B()), - s_RNG.NextFloat( c0.A(), c1.A()) - ); -} - -inline static XMFLOAT3 RandSpread( const XMFLOAT3& s ) -{ - // We might want to find min and max of each channel rather than assuming c0 <= c1 - return XMFLOAT3( - s_RNG.NextFloat(-s.x, s.x), - s_RNG.NextFloat(-s.y, s.y), - s_RNG.NextFloat(-s.z, s.z) - ); -} - -void ParticleEffect::LoadDeviceResources(ID3D12Device* device) -{ - (device); // Currently unused. May be useful with multi-adapter support. - - m_OriginalEffectProperties = m_EffectProperties; //In case we want to reset - - //Fill particle spawn data buffer - ParticleSpawnData* pSpawnData = (ParticleSpawnData*)_malloca(m_EffectProperties.EmitProperties.MaxParticles * sizeof(ParticleSpawnData)); - - for (UINT i = 0; i < m_EffectProperties.EmitProperties.MaxParticles; i++) - { - ParticleSpawnData& SpawnData = pSpawnData[i]; - SpawnData.AgeRate = 1.0f / s_RNG.NextFloat( m_EffectProperties.LifeMinMax.x, m_EffectProperties.LifeMinMax.y ); - float horizontalAngle = s_RNG.NextFloat(XM_2PI); - float horizontalVelocity = s_RNG.NextFloat( m_EffectProperties.Velocity.GetX(), m_EffectProperties.Velocity.GetY() ); - SpawnData.Velocity.x = horizontalVelocity * cos(horizontalAngle); - SpawnData.Velocity.y = s_RNG.NextFloat( m_EffectProperties.Velocity.GetZ(), m_EffectProperties.Velocity.GetW() ); - SpawnData.Velocity.z = horizontalVelocity * sin(horizontalAngle); - - SpawnData.SpreadOffset = RandSpread(m_EffectProperties.Spread ) ; - - SpawnData.StartSize = s_RNG.NextFloat( m_EffectProperties.Size.GetX(), m_EffectProperties.Size.GetY() ); - SpawnData.EndSize = s_RNG.NextFloat( m_EffectProperties.Size.GetZ(), m_EffectProperties.Size.GetW() ); - SpawnData.StartColor = RandColor( m_EffectProperties.MinStartColor, m_EffectProperties.MaxStartColor ); - SpawnData.EndColor = RandColor( m_EffectProperties.MinEndColor, m_EffectProperties.MaxEndColor ); - SpawnData.Mass = s_RNG.NextFloat( m_EffectProperties.MassMinMax.x, m_EffectProperties.MassMinMax.y ); - SpawnData.RotationSpeed = s_RNG.NextFloat(); //todo - SpawnData.Random = s_RNG.NextFloat(); - } - - m_RandomStateBuffer.Create(L"ParticleSystem::SpawnDataBuffer", m_EffectProperties.EmitProperties.MaxParticles, sizeof(ParticleSpawnData), pSpawnData); - _freea(pSpawnData); - - m_StateBuffers[0].Create(L"ParticleSystem::Buffer0", m_EffectProperties.EmitProperties.MaxParticles, sizeof(ParticleMotion)); - m_StateBuffers[1].Create(L"ParticleSystem::Buffer1", m_EffectProperties.EmitProperties.MaxParticles, sizeof(ParticleMotion)); - m_CurrentStateBuffer = 0; - - //DispatchIndirect args buffer / number of thread groups - __declspec(align(16)) UINT DispatchIndirectData[3] = { 0, 1, 1 }; - m_DispatchIndirectArgs.Create(L"ParticleSystem::DispatchIndirectArgs", 1, sizeof(D3D12_DISPATCH_ARGUMENTS), DispatchIndirectData); - -} - -void ParticleEffect::Update(ComputeContext& CompContext, float timeDelta) -{ - if (timeDelta == 0.0f) - return; - - m_ElapsedTime += timeDelta; - m_EffectProperties.EmitProperties.LastEmitPosW = m_EffectProperties.EmitProperties.EmitPosW; - - //m_EffectProperties.EmitProperties.EmitPosW = XMFLOAT3(ComputeConstants.EmitPosW.x + 1.0f * float(GameInput::IsPressed(GameInput::kBButton)), ComputeConstants.EmitPosW.y + 1.0f * float(GameInput::IsPressed(GameInput::kYButton)), ComputeConstants.EmitPosW.z - 1.0f * float(GameInput::IsPressed(GameInput::kAButton)));// - //m_EffectProperties.EmitProperties.EmitPosW.x += m_EffectProperties.DirectionIncrement.x; - //m_EffectProperties.EmitProperties.EmitPosW.y += m_EffectProperties.DirectionIncrement.y; - //m_EffectProperties.EmitProperties.EmitPosW.z += m_EffectProperties.DirectionIncrement.z; - - - //CPU side random num gen - for (uint32_t i = 0; i < 64; i++) - { - UINT random = (UINT)s_RNG.NextInt(m_EffectProperties.EmitProperties.MaxParticles - 1); - m_EffectProperties.EmitProperties.RandIndex[i].x = random; - } - CompContext.SetDynamicConstantBufferView(2, sizeof(EmissionProperties), &m_EffectProperties.EmitProperties); - - CompContext.TransitionResource(m_StateBuffers[m_CurrentStateBuffer], D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - CompContext.SetDynamicDescriptor(4, 0, m_RandomStateBuffer.GetSRV()); - CompContext.SetDynamicDescriptor(4, 1, m_StateBuffers[m_CurrentStateBuffer].GetSRV()); - - m_CurrentStateBuffer ^= 1; - - CompContext.ResetCounter(m_StateBuffers[m_CurrentStateBuffer]); - - CompContext.SetPipelineState(s_ParticleUpdateCS); - CompContext.TransitionResource(m_StateBuffers[m_CurrentStateBuffer], D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - CompContext.TransitionResource(m_DispatchIndirectArgs, D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT); - CompContext.SetDynamicDescriptor(3, 2, m_StateBuffers[m_CurrentStateBuffer].GetUAV()); - CompContext.DispatchIndirect(m_DispatchIndirectArgs, 0); - - // Why need a barrier here so long as we are artificially clamping particle count. This allows living - // particles to take precedence over new particles. The current system always spawns a multiple of 64 - // particles (To Be Fixed) until the total particle count reaches maximum. - CompContext.InsertUAVBarrier(m_StateBuffers[m_CurrentStateBuffer]); - - // Spawn to replace dead ones - CompContext.SetPipelineState(s_ParticleSpawnCS); - CompContext.SetDynamicDescriptor(4, 0, m_RandomStateBuffer.GetSRV()); - UINT NumSpawnThreads = (UINT)(m_EffectProperties.EmitRate * timeDelta); - CompContext.Dispatch((NumSpawnThreads + 64) / 64, 1, 1); - - // Output number of thread groups into m_DispatchIndirectArgs - CompContext.SetPipelineState(s_ParticleDispatchIndirectArgsCS); - CompContext.TransitionResource(m_DispatchIndirectArgs, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - CompContext.TransitionResource(m_StateBuffers[m_CurrentStateBuffer], D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - CompContext.SetDynamicDescriptor(4, 0, m_StateBuffers[m_CurrentStateBuffer].GetCounterSRV(CompContext)); - CompContext.SetDynamicDescriptor(3, 1, m_DispatchIndirectArgs.GetUAV()); - CompContext.Dispatch(1, 1, 1); -} - - -void ParticleEffect::Reset() -{ - m_EffectProperties = m_OriginalEffectProperties; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/ParticleEffect.h b/xess/samples/xess_demo/MiniEngine/Core/ParticleEffect.h deleted file mode 100644 index 62ab0eb..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/ParticleEffect.h +++ /dev/null @@ -1,44 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): Julia Careaga -// James Stanard - -#pragma once -#include "pch.h" -#include "GpuBuffer.h" -#include "ParticleEffectProperties.h" -#include "ParticleShaderStructs.h" - -class ParticleEffect -{ -public: - ParticleEffect(ParticleEffectProperties& effectProperties); - void LoadDeviceResources(ID3D12Device* device); - void Update(ComputeContext& CompContext, float timeDelta); - float GetLifetime(){ return m_EffectProperties.TotalActiveLifetime; } - float GetElapsedTime(){ return m_ElapsedTime; } - void Reset(); - -private: - - StructuredBuffer m_StateBuffers[2]; - uint32_t m_CurrentStateBuffer; - StructuredBuffer m_RandomStateBuffer; - IndirectArgsBuffer m_DispatchIndirectArgs; - IndirectArgsBuffer m_DrawIndirectArgs; - - ParticleEffectProperties m_EffectProperties; - ParticleEffectProperties m_OriginalEffectProperties; - float m_ElapsedTime; - UINT m_effectID; - - -}; diff --git a/xess/samples/xess_demo/MiniEngine/Core/ParticleEffectManager.cpp b/xess/samples/xess_demo/MiniEngine/Core/ParticleEffectManager.cpp deleted file mode 100644 index 37e8f5d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/ParticleEffectManager.cpp +++ /dev/null @@ -1,780 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): Julia Careaga -// James Stanard -// - -// Modified 2022, Intel Corporation. -// Added support for super sampling. - -#include "pch.h" -#include "BufferManager.h" -#include "BitonicSort.h" -#include "Camera.h" -#include "ColorBuffer.h" -#include "CommandContext.h" -#include "GameCore.h" -#include "GraphicsCore.h" -#include "Math/Random.h" -#include "ParticleEffectManager.h" -#include "ParticleEffect.h" -#include "ParticleEffectProperties.h" -#include - -#include "CompiledShaders/ParticleSpawnCS.h" -#include "CompiledShaders/ParticleUpdateCS.h" -#include "CompiledShaders/ParticleDispatchIndirectArgsCS.h" -#include "CompiledShaders/ParticleFinalDispatchIndirectArgsCS.h" -#include "CompiledShaders/ParticleLargeBinCullingCS.h" -#include "CompiledShaders/ParticleBinCullingCS.h" - -#include "CompiledShaders/ParticleTileRenderCS.h" -#include "CompiledShaders/ParticleTileRenderFastCS.h" -#include "CompiledShaders/ParticleTileRenderSlowDynamicCS.h" -#include "CompiledShaders/ParticleTileRenderFastDynamicCS.h" -#include "CompiledShaders/ParticleTileRenderSlowLowResCS.h" -#include "CompiledShaders/ParticleTileRenderFastLowResCS.h" - -#include "CompiledShaders/ParticleTileRender2CS.h" -#include "CompiledShaders/ParticleTileRenderFast2CS.h" -#include "CompiledShaders/ParticleTileRenderSlowDynamic2CS.h" -#include "CompiledShaders/ParticleTileRenderFastDynamic2CS.h" -#include "CompiledShaders/ParticleTileRenderSlowLowRes2CS.h" -#include "CompiledShaders/ParticleTileRenderFastLowRes2CS.h" - -#include "CompiledShaders/ParticleTileRender3CS.h" -#include "CompiledShaders/ParticleTileRenderFast3CS.h" -#include "CompiledShaders/ParticleTileRenderSlowDynamic3CS.h" -#include "CompiledShaders/ParticleTileRenderFastDynamic3CS.h" -#include "CompiledShaders/ParticleTileRenderSlowLowRes3CS.h" -#include "CompiledShaders/ParticleTileRenderFastLowRes3CS.h" - -#include "CompiledShaders/ParticleTileCullingCS.h" -#include "CompiledShaders/ParticleDepthBoundsCS.h" - -#include "CompiledShaders/ParticleSortIndirectArgsCS.h" -#include "CompiledShaders/ParticlePreSortCS.h" -#include "CompiledShaders/ParticlePS.h" -#include "CompiledShaders/ParticleEnableMaskPS.h" -#include "CompiledShaders/ParticleVS.h" -#include "CompiledShaders/ParticleNoSortVS.h" - -#define EFFECTS_ERROR uint32_t(0xFFFFFFFF) - -#define MAX_TOTAL_PARTICLES 0x40000 // 256k (18-bit indices) -#define MAX_PARTICLES_PER_BIN 1024 -#define BIN_SIZE_X 128 -#define BIN_SIZE_Y 64 -#define TILE_SIZE 16 - -// It's good to have 32 tiles per bin to maximize the tile culling phase -#define TILES_PER_BIN_X (BIN_SIZE_X / TILE_SIZE) -#define TILES_PER_BIN_Y (BIN_SIZE_Y / TILE_SIZE) -#define TILES_PER_BIN (TILES_PER_BIN_X * TILES_PER_BIN_Y) - -using namespace Graphics; -using namespace Math; -using namespace ParticleEffectManager; - -namespace ParticleEffectManager -{ - BoolVar Enable("Graphics/Particle Effects/Enable", true); - BoolVar EnableSpriteSort("Graphics/Particle Effects/Sort Sprites", true); - BoolVar EnableTiledRendering("Graphics/Particle Effects/Tiled Rendering", true); - BoolVar PauseSim("Graphics/Particle Effects/Pause Simulation", false); - const char* ResolutionLabels[] = { "High-Res", "Low-Res", "Dynamic" }; - EnumVar TiledRes("Graphics/Particle Effects/Tiled Sample Rate", 2, 3, ResolutionLabels); - NumVar DynamicResLevel("Graphics/Particle Effects/Dynamic Resolution Cutoff", 0.0f, -4.0f, 4.0f, 0.5f); - NumVar MipBias("Graphics/Particle Effects/Mip Bias", 0.0f, -4.0f, 4.0f, 0.5f); - - ComputePSO s_ParticleSpawnCS(L"Particles: Particle Spawn CS"); - ComputePSO s_ParticleUpdateCS(L"Particles: Particle Update CS"); - ComputePSO s_ParticleDispatchIndirectArgsCS(L"Particles: Particle Dispatch Indirect Args CS"); - - StructuredBuffer SpriteVertexBuffer; - - UINT s_ReproFrame = 0;//201; - RandomNumberGenerator s_RNG; -} - -struct CBChangesPerView -{ - Matrix4 gInvView; - Matrix4 gViewProj; - - float gVertCotangent; - float gAspectRatio; - float gRcpFarZ; - float gInvertZ; - - float gBufferWidth; - float gBufferHeight; - float gRcpBufferWidth; - float gRcpBufferHeight; - - uint32_t gBinsPerRow; - uint32_t gTileRowPitch; - uint32_t gTilesPerRow; - uint32_t gTilesPerCol; -}; - -namespace -{ - ComputePSO s_ParticleFinalDispatchIndirectArgsCS(L"Particles: Particle Final Dispatch Indirect Args CS"); - ComputePSO s_ParticleLargeBinCullingCS(L"Particles: Particle Large Bin Culling CS"); - ComputePSO s_ParticleBinCullingCS(L"Particles: Particle Bin Culling CS"); - ComputePSO s_ParticleTileCullingCS(L"Particles: Particle Tile Culling CS"); - ComputePSO s_ParticleTileRenderSlowCS[3][2]; // High-Res, Low-Res, Dynamic-Res / No mask buffer, mask buffer - ComputePSO s_ParticleTileRenderFastCS[3][2]; // High-Res, Low-Res, Dynamic-Res (disable depth tests) / No mask buffer, mask buffer - ComputePSO s_ParticleDepthBoundsCS(L"Particles: Particle Depth Bounds CS"); - GraphicsPSO s_NoTileRasterizationPSO[4]; - ComputePSO s_ParticleSortIndirectArgsCS(L"Particles: Particle Sort Indirect Args CS"); - ComputePSO s_ParticlePreSortCS(L"Particles: Particle Pre Sort CS"); - - RootSignature RootSig; - - StructuredBuffer SpriteIndexBuffer; - IndirectArgsBuffer SortIndirectArgs; - - IndirectArgsBuffer DrawIndirectArgs; - IndirectArgsBuffer FinalDispatchIndirectArgs; - StructuredBuffer VisibleParticleBuffer; - StructuredBuffer BinParticles[2]; - ByteAddressBuffer BinCounters[2]; - StructuredBuffer TileCounters; - ByteAddressBuffer TileHitMasks; - - StructuredBuffer TileDrawPackets; - StructuredBuffer TileFastDrawPackets; - IndirectArgsBuffer TileDrawDispatchIndirectArgs; - - CBChangesPerView s_ChangesPerView; - - GpuResource TextureArray; - D3D12_CPU_DESCRIPTOR_HANDLE TextureArraySRV; - std::vector TextureNameArray; - - std::vector> ParticleEffectsPool; - std::vector ParticleEffectsActive; - - static bool s_InitComplete = false; - UINT TotalElapsedFrames; - - void SetFinalBuffers(ComputeContext& CompContext) - { - CompContext.SetPipelineState(s_ParticleFinalDispatchIndirectArgsCS); - - CompContext.TransitionResource(SpriteVertexBuffer, D3D12_RESOURCE_STATE_GENERIC_READ); - CompContext.TransitionResource(FinalDispatchIndirectArgs, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - CompContext.TransitionResource(DrawIndirectArgs, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - CompContext.SetDynamicDescriptor(3, 0, FinalDispatchIndirectArgs.GetUAV()); - CompContext.SetDynamicDescriptor(3, 1, DrawIndirectArgs.GetUAV()); - CompContext.SetDynamicDescriptor(4, 0, SpriteVertexBuffer.GetCounterSRV(CompContext)); - - CompContext.Dispatch( 1, 1, 1 ); - } - - void RenderTiles(ComputeContext& CompContext, ColorBuffer& ColorTarget, ColorBuffer& ResponsiveMaskTarget, ColorBuffer& LinearDepth, bool isUpdateResponsiveMask) - { - size_t ScreenWidth = ColorTarget.GetWidth(); - size_t ScreenHeight = ColorTarget.GetHeight(); - - ASSERT(ColorTarget.GetFormat() == DXGI_FORMAT_R32_UINT || g_bTypedUAVLoadSupport_R11G11B10_FLOAT, - "Without typed UAV loads, tiled particles must render to a R32_UINT buffer"); - - { - ScopedTimer _p(L"Compute Depth Bounds", CompContext); - - CompContext.SetPipelineState(s_ParticleDepthBoundsCS); - - CompContext.TransitionResource(LinearDepth, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - CompContext.TransitionResource(g_MinMaxDepth8, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - CompContext.TransitionResource(g_MinMaxDepth16, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - CompContext.TransitionResource(g_MinMaxDepth32, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - CompContext.SetDynamicDescriptor(3, 0, g_MinMaxDepth8.GetUAV()); - CompContext.SetDynamicDescriptor(3, 1, g_MinMaxDepth16.GetUAV()); - CompContext.SetDynamicDescriptor(3, 2, g_MinMaxDepth32.GetUAV()); - CompContext.SetDynamicDescriptor(4, 0, LinearDepth.GetSRV()); - - CompContext.Dispatch2D(ScreenWidth, ScreenHeight, 32, 32); - } - - { - ScopedTimer _p(L"Culling & Sorting", CompContext); - - CompContext.ResetCounter(VisibleParticleBuffer); - - // The first step inserts each particle into all of the large bins it intersects. Large bins - // are 512x256. - CompContext.SetPipelineState(s_ParticleLargeBinCullingCS); - CompContext.SetConstants(0, 5, 4); - - CompContext.TransitionResource(SpriteVertexBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - CompContext.TransitionResource(FinalDispatchIndirectArgs, D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT); - CompContext.TransitionResource(BinParticles[0], D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - CompContext.TransitionResource(BinCounters[0], D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - CompContext.TransitionResource(VisibleParticleBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - - CompContext.SetDynamicDescriptor(3, 0, BinParticles[0].GetUAV()); - CompContext.SetDynamicDescriptor(3, 1, BinCounters[0].GetUAV()); - CompContext.SetDynamicDescriptor(3, 2, VisibleParticleBuffer.GetUAV()); - CompContext.SetDynamicDescriptor(4, 0, SpriteVertexBuffer.GetSRV()); - CompContext.SetDynamicDescriptor(4, 1, SpriteVertexBuffer.GetCounterSRV(CompContext)); - - CompContext.DispatchIndirect(FinalDispatchIndirectArgs); - - // The second step refines the binning by inserting particles into the appropriate small bins. - // Small bins are 128x64. - CompContext.SetPipelineState(s_ParticleBinCullingCS); - CompContext.SetConstants(0, 3, 2); - - CompContext.TransitionResource(VisibleParticleBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - CompContext.TransitionResource(BinParticles[0], D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - CompContext.TransitionResource(BinCounters[0], D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - CompContext.TransitionResource(BinParticles[1], D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - CompContext.TransitionResource(BinCounters[1], D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - - CompContext.SetDynamicDescriptor(3, 0, BinParticles[1].GetUAV()); - CompContext.SetDynamicDescriptor(3, 1, BinCounters[1].GetUAV()); - CompContext.SetDynamicDescriptor(4, 0, VisibleParticleBuffer.GetSRV()); - CompContext.SetDynamicDescriptor(4, 1, BinParticles[0].GetSRV()); - CompContext.SetDynamicDescriptor(4, 2, BinCounters[0].GetSRV()); - - CompContext.Dispatch2D(ScreenWidth, ScreenHeight, 4 * BIN_SIZE_X, 4 * BIN_SIZE_Y); - - // The final sorting step will perform a bitonic sort on each bin's particles (front to - // back). Afterward, it will generate a bitmap for each tile indicating which of the bin's - // particles occupy the tile. This allows each tile to iterate over a sorted list of particles - // ignoring the ones that do not intersect. - CompContext.SetPipelineState(s_ParticleTileCullingCS); - - CompContext.FillBuffer(TileDrawDispatchIndirectArgs, 0, 0, sizeof(uint32_t)); - CompContext.FillBuffer(TileDrawDispatchIndirectArgs, 12, 0, sizeof(uint32_t)); - - CompContext.TransitionResource(BinParticles[0], D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - CompContext.TransitionResource(TileHitMasks, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - CompContext.TransitionResource(TileDrawPackets, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - CompContext.TransitionResource(TileFastDrawPackets, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - CompContext.TransitionResource(TileDrawDispatchIndirectArgs, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - CompContext.TransitionResource(BinParticles[1], D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - CompContext.TransitionResource(BinCounters[1], D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - CompContext.TransitionResource(g_MinMaxDepth8, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - CompContext.TransitionResource(g_MinMaxDepth16, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - CompContext.TransitionResource(g_MinMaxDepth32, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - - CompContext.SetDynamicDescriptor(3, 0, BinParticles[0].GetUAV()); - CompContext.SetDynamicDescriptor(3, 1, TileHitMasks.GetUAV()); - CompContext.SetDynamicDescriptor(3, 2, TileDrawPackets.GetUAV()); - CompContext.SetDynamicDescriptor(3, 3, TileFastDrawPackets.GetUAV()); - CompContext.SetDynamicDescriptor(3, 4, TileDrawDispatchIndirectArgs.GetUAV()); - - CompContext.SetDynamicDescriptor(4, 0, BinParticles[1].GetSRV()); - CompContext.SetDynamicDescriptor(4, 1, BinCounters[1].GetSRV()); - CompContext.SetDynamicDescriptor(4, 2, TILE_SIZE == 16 ? g_MinMaxDepth16.GetSRV() : g_MinMaxDepth32.GetSRV()); - CompContext.SetDynamicDescriptor(4, 3, VisibleParticleBuffer.GetSRV()); - - CompContext.Dispatch2D(ScreenWidth, ScreenHeight, BIN_SIZE_X, BIN_SIZE_Y); - } - - { - ScopedTimer _p(L"Tiled Rendering", CompContext); - - CompContext.TransitionResource(TileDrawDispatchIndirectArgs, D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT); - CompContext.TransitionResource(ColorTarget, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - if (isUpdateResponsiveMask) - { - CompContext.TransitionResource(ResponsiveMaskTarget, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - } - CompContext.TransitionResource(LinearDepth, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - CompContext.TransitionResource(BinParticles[0], D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - CompContext.TransitionResource(TileHitMasks, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - CompContext.TransitionResource(TileDrawPackets, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - CompContext.TransitionResource(TileFastDrawPackets, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - CompContext.TransitionResource(TextureArray, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - - CompContext.SetDynamicDescriptor(3, 0, ColorTarget.GetUAV()); - if (isUpdateResponsiveMask) - { - CompContext.SetDynamicDescriptor(3, 1, ResponsiveMaskTarget.GetUAV()); - } - - D3D12_CPU_DESCRIPTOR_HANDLE SRVs[] = - { - VisibleParticleBuffer.GetSRV(), - TileHitMasks.GetSRV(), - TextureArraySRV, - LinearDepth.GetSRV(), - BinParticles[0].GetSRV(), - TileDrawPackets.GetSRV(), - TileFastDrawPackets.GetSRV(), - (TILE_SIZE == 16 ? g_MinMaxDepth16.GetSRV() : g_MinMaxDepth32.GetSRV()), - }; - CompContext.SetDynamicDescriptors(4, 0, _countof(SRVs), SRVs); - - CompContext.SetConstants(0, (float)DynamicResLevel, (float)MipBias); - - CompContext.SetPipelineState(s_ParticleTileRenderSlowCS[TiledRes][isUpdateResponsiveMask ? 1 : 0]); - CompContext.DispatchIndirect(TileDrawDispatchIndirectArgs, 0); - - CompContext.SetPipelineState(s_ParticleTileRenderFastCS[TiledRes][isUpdateResponsiveMask ? 1 : 0]); - CompContext.DispatchIndirect(TileDrawDispatchIndirectArgs, 12); - } - } - - void RenderSprites(GraphicsContext& GrContext, ColorBuffer& ColorTarget, DepthBuffer& DepthTarget, ColorBuffer& ResponsiveMaskTarget, ColorBuffer& LinearDepth, bool isUpdateResponsiveMask) - { - if (EnableSpriteSort) - { - ScopedTimer _p(L"Sort Particles", GrContext); - ComputeContext& CompContext = GrContext.GetComputeContext(); - CompContext.SetRootSignature(RootSig); - - CompContext.SetDynamicConstantBufferView(1, sizeof(CBChangesPerView), &s_ChangesPerView); - - CompContext.SetPipelineState(s_ParticleSortIndirectArgsCS); - CompContext.TransitionResource(SpriteVertexBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - CompContext.TransitionResource(SortIndirectArgs, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - CompContext.TransitionResource(DrawIndirectArgs, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - CompContext.InsertUAVBarrier(DrawIndirectArgs); - CompContext.SetDynamicDescriptor(3, 0, SortIndirectArgs.GetUAV()); - CompContext.SetDynamicDescriptor(3, 1, DrawIndirectArgs.GetUAV()); - CompContext.Dispatch(1, 1, 1); - - CompContext.SetPipelineState(s_ParticlePreSortCS); - CompContext.TransitionResource(SortIndirectArgs, D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT); - CompContext.TransitionResource(SpriteIndexBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - CompContext.InsertUAVBarrier(DrawIndirectArgs); - CompContext.SetDynamicDescriptor(3, 0, SpriteIndexBuffer.GetUAV()); - CompContext.SetDynamicDescriptor(3, 1, DrawIndirectArgs.GetUAV()); - CompContext.SetDynamicDescriptor(4, 0, SpriteVertexBuffer.GetSRV()); - CompContext.SetDynamicDescriptor(4, 1, SpriteVertexBuffer.GetCounterSRV(CompContext)); - CompContext.DispatchIndirect(SortIndirectArgs, 0); - - CompContext.InsertUAVBarrier(SpriteIndexBuffer); - - BitonicSort::Sort(CompContext, SpriteIndexBuffer, SpriteVertexBuffer.GetCounterBuffer(), 0, true, false); - } - - D3D12_RECT scissor; - scissor.left = 0; - scissor.top = 0; - scissor.right = (LONG)ColorTarget.GetWidth(); - scissor.bottom = (LONG)ColorTarget.GetHeight(); - - D3D12_VIEWPORT viewport; - viewport.TopLeftX = 0.0; - viewport.TopLeftY = 0.0; - viewport.Width = (float)ColorTarget.GetWidth(); - viewport.Height = (float)ColorTarget.GetHeight(); - viewport.MinDepth = 0.0; - viewport.MaxDepth = 1.0; - - GrContext.SetRootSignature(RootSig); - GrContext.SetPipelineState(s_NoTileRasterizationPSO[(EnableSpriteSort ? 0 : 1) + (isUpdateResponsiveMask ? 2 : 0)]); - GrContext.TransitionResource(SpriteVertexBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - GrContext.TransitionResource(DrawIndirectArgs, D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT); - GrContext.TransitionResource(TextureArray, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - GrContext.TransitionResource(LinearDepth, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - GrContext.TransitionResource(SpriteIndexBuffer, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - GrContext.SetDynamicDescriptor(4, 0, SpriteVertexBuffer.GetSRV() ); - GrContext.SetDynamicDescriptor(4, 1, TextureArraySRV); - GrContext.SetDynamicDescriptor(4, 2, LinearDepth.GetSRV()); - GrContext.SetDynamicDescriptor(4, 3, SpriteIndexBuffer.GetSRV()); - GrContext.SetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); - GrContext.TransitionResource(ColorTarget, D3D12_RESOURCE_STATE_RENDER_TARGET); - GrContext.TransitionResource(DepthTarget, D3D12_RESOURCE_STATE_DEPTH_READ); - if (isUpdateResponsiveMask) - { - GrContext.TransitionResource(ResponsiveMaskTarget, D3D12_RESOURCE_STATE_RENDER_TARGET); - D3D12_CPU_DESCRIPTOR_HANDLE rtvs[] { ColorTarget.GetRTV(), ResponsiveMaskTarget.GetRTV() }; - GrContext.SetRenderTargets(ARRAYSIZE(rtvs), rtvs, DepthTarget.GetDSV_DepthReadOnly()); - } - else - { - GrContext.SetRenderTarget(ColorTarget.GetRTV(), DepthTarget.GetDSV_DepthReadOnly()); - } - GrContext.SetViewportAndScissor(viewport, scissor); - GrContext.DrawIndirect(DrawIndirectArgs); - } - -} // {anonymous} namespace - -//--------------------------------------------------------------------- -// -// Initialize -// -//--------------------------------------------------------------------- - -void ParticleEffectManager::Initialize( uint32_t MaxDisplayWidth, uint32_t MaxDisplayHeight ) -{ - D3D12_SAMPLER_DESC SamplerBilinearBorderDesc = SamplerPointBorderDesc; - SamplerBilinearBorderDesc.Filter = D3D12_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT; - - RootSig.Reset(5, 3); - RootSig.InitStaticSampler(0, SamplerBilinearBorderDesc); - RootSig.InitStaticSampler(1, SamplerPointBorderDesc); - RootSig.InitStaticSampler(2, SamplerPointClampDesc); - RootSig[0].InitAsConstants(0, 3); - RootSig[1].InitAsConstantBuffer(1); - RootSig[2].InitAsConstantBuffer(2); - RootSig[3].InitAsDescriptorRange(D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 0, 8); - RootSig[4].InitAsDescriptorRange(D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 10); - RootSig.Finalize(L"Particle Effects"); - -#define CreatePSO( ObjName, ShaderByteCode ) \ - ObjName.SetRootSignature(RootSig); \ - ObjName.SetComputeShader(ShaderByteCode, sizeof(ShaderByteCode) ); \ - ObjName.Finalize(); - CreatePSO(s_ParticleSpawnCS, g_pParticleSpawnCS); - CreatePSO(s_ParticleUpdateCS, g_pParticleUpdateCS); - CreatePSO(s_ParticleDispatchIndirectArgsCS, g_pParticleDispatchIndirectArgsCS); - CreatePSO(s_ParticleFinalDispatchIndirectArgsCS, g_pParticleFinalDispatchIndirectArgsCS); - - CreatePSO(s_ParticleLargeBinCullingCS, g_pParticleLargeBinCullingCS); - CreatePSO(s_ParticleBinCullingCS, g_pParticleBinCullingCS); - CreatePSO(s_ParticleTileCullingCS, g_pParticleTileCullingCS); - if (g_bTypedUAVLoadSupport_R11G11B10_FLOAT) - { - CreatePSO(s_ParticleTileRenderSlowCS[0][0], g_pParticleTileRender2CS); - CreatePSO(s_ParticleTileRenderFastCS[0][0], g_pParticleTileRenderFast2CS); - CreatePSO(s_ParticleTileRenderSlowCS[1][0], g_pParticleTileRenderSlowLowRes2CS); - CreatePSO(s_ParticleTileRenderFastCS[1][0], g_pParticleTileRenderFastLowRes2CS); - CreatePSO(s_ParticleTileRenderSlowCS[2][0], g_pParticleTileRenderSlowDynamic2CS); - CreatePSO(s_ParticleTileRenderFastCS[2][0], g_pParticleTileRenderFastDynamic2CS); - - // Update mask pipeline, - // Since the sample doesn't use the RenderTiles() in particles rendering for those devices which don't support g_bTypedUAVLoadSupport_R11G11B10_FLOAT, - // so only add the responsive mask update in the g_bTypedUAVLoadSupport_R11G11B10_FLOAT particles rendering pass. - CreatePSO(s_ParticleTileRenderSlowCS[0][1], g_pParticleTileRender3CS); - CreatePSO(s_ParticleTileRenderFastCS[0][1], g_pParticleTileRenderFast3CS); - CreatePSO(s_ParticleTileRenderSlowCS[1][1], g_pParticleTileRenderSlowLowRes3CS); - CreatePSO(s_ParticleTileRenderFastCS[1][1], g_pParticleTileRenderFastLowRes3CS); - CreatePSO(s_ParticleTileRenderSlowCS[2][1], g_pParticleTileRenderSlowDynamic3CS); - CreatePSO(s_ParticleTileRenderFastCS[2][1], g_pParticleTileRenderFastDynamic3CS); - } - else - { - CreatePSO(s_ParticleTileRenderSlowCS[0][0], g_pParticleTileRenderCS); - CreatePSO(s_ParticleTileRenderFastCS[0][0], g_pParticleTileRenderFastCS); - CreatePSO(s_ParticleTileRenderSlowCS[1][0], g_pParticleTileRenderSlowLowResCS); - CreatePSO(s_ParticleTileRenderFastCS[1][0], g_pParticleTileRenderFastLowResCS); - CreatePSO(s_ParticleTileRenderSlowCS[2][0], g_pParticleTileRenderSlowDynamicCS); - CreatePSO(s_ParticleTileRenderFastCS[2][0], g_pParticleTileRenderFastDynamicCS); - } - CreatePSO(s_ParticleDepthBoundsCS, g_pParticleDepthBoundsCS); - CreatePSO(s_ParticleSortIndirectArgsCS, g_pParticleSortIndirectArgsCS); - CreatePSO(s_ParticlePreSortCS, g_pParticlePreSortCS); - -#undef CreatePSO - - //VSPS Render, no tiles. - s_NoTileRasterizationPSO[0].SetRootSignature(RootSig); - s_NoTileRasterizationPSO[0].SetRasterizerState(RasterizerTwoSided); - s_NoTileRasterizationPSO[0].SetDepthStencilState(DepthStateReadOnly); - s_NoTileRasterizationPSO[0].SetBlendState(BlendPreMultiplied); - s_NoTileRasterizationPSO[0].SetInputLayout(0, nullptr); - s_NoTileRasterizationPSO[0].SetPrimitiveTopologyType(D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE); - s_NoTileRasterizationPSO[0].SetRenderTargetFormat(g_SceneColorBuffer.GetFormat(), g_SceneDepthBuffer.GetFormat()); - s_NoTileRasterizationPSO[0].SetVertexShader(g_pParticleVS, sizeof(g_pParticleVS)); - s_NoTileRasterizationPSO[0].SetPixelShader(g_pParticlePS, sizeof(g_pParticlePS)); - s_NoTileRasterizationPSO[0].Finalize(); - - s_NoTileRasterizationPSO[1] = s_NoTileRasterizationPSO[0]; - s_NoTileRasterizationPSO[1].SetVertexShader(g_pParticleNoSortVS, sizeof(g_pParticleNoSortVS)); - s_NoTileRasterizationPSO[1].Finalize(); - - DXGI_FORMAT rtv_formats[2] = { g_SceneColorBuffer.GetFormat(), g_ResponsiveMaskBuffer.GetFormat() }; - s_NoTileRasterizationPSO[2] = s_NoTileRasterizationPSO[0]; - s_NoTileRasterizationPSO[2].SetRenderTargetFormats(2, rtv_formats, g_SceneDepthBuffer.GetFormat()); - s_NoTileRasterizationPSO[2].SetPixelShader(g_pParticleEnableMaskPS, sizeof(g_pParticleEnableMaskPS)); - s_NoTileRasterizationPSO[2].Finalize(); - - s_NoTileRasterizationPSO[3] = s_NoTileRasterizationPSO[2]; - s_NoTileRasterizationPSO[3].SetVertexShader(g_pParticleNoSortVS, sizeof(g_pParticleNoSortVS)); - s_NoTileRasterizationPSO[3].Finalize(); - - __declspec(align(16)) UINT InitialDrawIndirectArgs[4] = { 4, 0, 0, 0 }; - DrawIndirectArgs.Create(L"ParticleEffectManager::DrawIndirectArgs", 1, sizeof(D3D12_DRAW_ARGUMENTS), InitialDrawIndirectArgs); - __declspec(align(16)) UINT InitialDispatchIndirectArgs[6] = { 0, 1, 1, 0, 1, 1 }; - FinalDispatchIndirectArgs.Create(L"ParticleEffectManager::FinalDispatchIndirectArgs", 1, sizeof(D3D12_DISPATCH_ARGUMENTS), InitialDispatchIndirectArgs); - SpriteVertexBuffer.Create(L"ParticleEffectManager::SpriteVertexBuffer", MAX_TOTAL_PARTICLES, sizeof(ParticleVertex)); - VisibleParticleBuffer.Create(L"ParticleEffectManager::VisibleParticleBuffer", MAX_TOTAL_PARTICLES, sizeof(ParticleScreenData)); - SpriteIndexBuffer.Create(L"ParticleEffectManager::SpriteIndexBuffer", MAX_TOTAL_PARTICLES, sizeof(UINT)); - SortIndirectArgs.Create(L"ParticleEffectManager::SortIndirectArgs", 1, sizeof(D3D12_DISPATCH_ARGUMENTS)); - TileDrawDispatchIndirectArgs.Create(L"ParticleEffectManager::DrawPackets_IArgs", 2, sizeof(D3D12_DISPATCH_ARGUMENTS), InitialDispatchIndirectArgs); - - const uint32_t LargeBinsPerRow = DivideByMultiple(MaxDisplayWidth, 4 * BIN_SIZE_X); - const uint32_t LargeBinsPerCol = DivideByMultiple(MaxDisplayHeight, 4 * BIN_SIZE_Y); - const uint32_t BinsPerRow = LargeBinsPerRow * 4; - const uint32_t BinsPerCol = LargeBinsPerCol * 4; - const uint32_t MaxParticlesPerLargeBin = MAX_PARTICLES_PER_BIN * 16; - const uint32_t ParticleBinCapacity = LargeBinsPerRow * LargeBinsPerCol * MaxParticlesPerLargeBin; - const uint32_t TilesPerRow = DivideByMultiple(MaxDisplayWidth, TILE_SIZE); - const uint32_t TilesPerCol = DivideByMultiple(MaxDisplayHeight, TILE_SIZE); - - // Padding is necessary to eliminate bounds checking when outputting data to bins or tiles. - const uint32_t PaddedTilesPerRow = AlignUp(TilesPerRow, TILES_PER_BIN_X * 4); - const uint32_t PaddedTilesPerCol = AlignUp(TilesPerCol, TILES_PER_BIN_Y * 4); - - BinParticles[0].Create(L"ParticleEffectManager::BinParticles[0]", ParticleBinCapacity, sizeof(UINT)); - BinParticles[1].Create(L"ParticleEffectManager::BinParticles[1]", ParticleBinCapacity, sizeof(UINT)); - BinCounters[0].Create(L"ParticleEffectManager::LargeBinCounters", LargeBinsPerRow * LargeBinsPerCol, sizeof(UINT)); - BinCounters[1].Create(L"ParticleEffectManager::BinCounters", BinsPerRow * BinsPerCol, sizeof(UINT)); - TileCounters.Create(L"ParticleEffectManager::TileCounters", PaddedTilesPerRow * PaddedTilesPerCol, sizeof(UINT)); - TileHitMasks.Create(L"ParticleEffectManager::TileHitMasks", PaddedTilesPerRow * PaddedTilesPerCol, MAX_PARTICLES_PER_BIN / 8); - TileDrawPackets.Create(L"ParticleEffectManager::DrawPackets", TilesPerRow * TilesPerCol, sizeof(UINT)); - TileFastDrawPackets.Create(L"ParticleEffectManager::FastDrawPackets", TilesPerRow * TilesPerCol, sizeof(UINT)); - - D3D12_RESOURCE_DESC TexDesc = {}; - TexDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; - TexDesc.Format = DXGI_FORMAT_BC3_UNORM_SRGB; - TexDesc.Width = 64; - TexDesc.Height = 64; - TexDesc.DepthOrArraySize = 16; - TexDesc.MipLevels = 4; - TexDesc.SampleDesc.Count = 1; - TexDesc.Alignment = 0x10000; - - D3D12_HEAP_PROPERTIES HeapProps = {}; - HeapProps.Type = D3D12_HEAP_TYPE_DEFAULT; - HeapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; - HeapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; - HeapProps.CreationNodeMask = 1; - HeapProps.VisibleNodeMask = 1; - - ID3D12Resource* tex = nullptr; - ASSERT_SUCCEEDED( g_Device->CreateCommittedResource( &HeapProps, D3D12_HEAP_FLAG_NONE, - &TexDesc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr, MY_IID_PPV_ARGS(&tex)) ); - tex->SetName(L"Particle TexArray"); - TextureArray = GpuResource(tex, D3D12_RESOURCE_STATE_COPY_DEST); - tex->Release(); - - D3D12_SHADER_RESOURCE_VIEW_DESC SRVDesc = {}; - SRVDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; - SRVDesc.Format = DXGI_FORMAT_BC3_UNORM_SRGB; - SRVDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DARRAY; - SRVDesc.Texture2DArray.MipLevels = 4; - SRVDesc.Texture2DArray.ArraySize = 16; - - TextureArraySRV = AllocateDescriptor(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - g_Device->CreateShaderResourceView(TextureArray.GetResource(), &SRVDesc, TextureArraySRV); - - if (s_ReproFrame > 0) - s_RNG.SetSeed(1); - - TotalElapsedFrames = 0; - s_InitComplete = true; -} - -void ParticleEffectManager::RegisterTexture(uint32_t index, const Texture& texture) -{ - CommandContext::InitializeTextureArraySlice(TextureArray, index, (GpuResource&)texture); -} - -void ParticleEffectManager::Shutdown( void ) -{ - ClearAll(); - - SpriteVertexBuffer.Destroy(); - DrawIndirectArgs.Destroy(); - FinalDispatchIndirectArgs.Destroy(); - SpriteVertexBuffer.Destroy(); - VisibleParticleBuffer.Destroy(); - SpriteIndexBuffer.Destroy(); - SortIndirectArgs.Destroy(); - TileDrawDispatchIndirectArgs.Destroy(); - - BinParticles[0].Destroy(); - BinParticles[1].Destroy(); - BinCounters[0].Destroy(); - BinCounters[1].Destroy(); - TileCounters.Destroy(); - TileHitMasks.Destroy(); - TileDrawPackets.Destroy(); - TileFastDrawPackets.Destroy(); - TextureArray.Destroy(); -} - -//Returns index into Active -EffectHandle ParticleEffectManager::InstantiateEffect( ParticleEffectProperties& effectProperties ) -{ - if (!s_InitComplete) - return EFFECTS_ERROR; - - static std::mutex s_InstantiateNewEffectMutex; - s_InstantiateNewEffectMutex.lock(); - ParticleEffect* newEffect = new ParticleEffect(effectProperties); - ParticleEffectsPool.emplace_back(newEffect); - ParticleEffectsActive.push_back(newEffect); - s_InstantiateNewEffectMutex.unlock(); - - EffectHandle index = (EffectHandle)ParticleEffectsActive.size() - 1; - ParticleEffectsActive[index]->LoadDeviceResources(Graphics::g_Device); - return index; -} - -//--------------------------------------------------------------------- -// -// Update -// -//--------------------------------------------------------------------- - -void ParticleEffectManager::Update(ComputeContext& Context, float timeDelta ) -{ - if (!Enable || !s_InitComplete || ParticleEffectsActive.size() == 0) - return; - - ScopedTimer _prof(L"Particle Update", Context); - - if (++TotalElapsedFrames == s_ReproFrame) - PauseSim = true; - - if (PauseSim) - return; - - if (timeDelta > 0.5f) // prevent time elapse too long - { - timeDelta = 0.0167f; - } - - Context.ResetCounter(SpriteVertexBuffer); - - if (ParticleEffectsActive.size() == 0) - return; - - Context.SetRootSignature(RootSig); - Context.SetConstants(0, timeDelta); - Context.TransitionResource(SpriteVertexBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.SetDynamicDescriptor(3, 0, SpriteVertexBuffer.GetUAV()); - - for (UINT i = 0; i < ParticleEffectsActive.size(); ++i) - { - ParticleEffectsActive[i]->Update(Context, timeDelta); - - if (ParticleEffectsActive[i]->GetLifetime() <= ParticleEffectsActive[i]->GetElapsedTime()) - { - //Erase from vector - auto iter = ParticleEffectsActive.begin() + i; - static std::mutex s_EraseEffectMutex; - s_EraseEffectMutex.lock(); - ParticleEffectsActive.erase(iter); - s_EraseEffectMutex.unlock(); - } - } - - SetFinalBuffers(Context); -} - - -//--------------------------------------------------------------------- -// -// Render -// -//--------------------------------------------------------------------- - -void ParticleEffectManager::Render(CommandContext& Context, const Camera& Camera, ColorBuffer& ColorTarget, DepthBuffer& DepthTarget, ColorBuffer& ResponsiveMaskTarget, ColorBuffer& LinearDepth, bool isUpdateResponsiveMask) -{ - if (!Enable || !s_InitComplete || ParticleEffectsActive.size() == 0) - return; - - uint32_t Width = (uint32_t)ColorTarget.GetWidth(); - uint32_t Height = (uint32_t)ColorTarget.GetHeight(); - - ASSERT( - Width == DepthTarget.GetWidth() && - Height == DepthTarget.GetHeight() && - Width == LinearDepth.GetWidth() && - Height == LinearDepth.GetHeight(), - "There is a mismatch in buffer dimensions for rendering particles" - ); - - ScopedTimer _prof(L"Particle Render", Context); - - uint32_t BinsPerRow = 4 * DivideByMultiple(Width, 4 * BIN_SIZE_X); - - s_ChangesPerView.gViewProj = Camera.GetViewProjMatrix(); - s_ChangesPerView.gInvView = Invert(Camera.GetViewMatrix()); - float HCot = Camera.GetProjMatrix().GetX().GetX(); - float VCot = Camera.GetProjMatrix().GetY().GetY(); - s_ChangesPerView.gVertCotangent = VCot; - s_ChangesPerView.gAspectRatio = HCot / VCot; - s_ChangesPerView.gRcpFarZ = 1.0f / Camera.GetFarClip(); - s_ChangesPerView.gInvertZ = Camera.GetNearClip() / (Camera.GetFarClip() - Camera.GetNearClip()); - s_ChangesPerView.gBufferWidth = (float)Width; - s_ChangesPerView.gBufferHeight = (float)Height; - s_ChangesPerView.gRcpBufferWidth = 1.0f / Width; - s_ChangesPerView.gRcpBufferHeight = 1.0f / Height; - s_ChangesPerView.gBinsPerRow = BinsPerRow; - s_ChangesPerView.gTileRowPitch = BinsPerRow * TILES_PER_BIN_X; - s_ChangesPerView.gTilesPerRow = DivideByMultiple(Width, TILE_SIZE); - s_ChangesPerView.gTilesPerCol = DivideByMultiple(Height, TILE_SIZE); - - // For now, UAV load support for R11G11B10 is required to read-modify-write the color buffer, but - // the compositing could be deferred. - WARN_ONCE_IF(EnableTiledRendering && !g_bTypedUAVLoadSupport_R11G11B10_FLOAT, - "Unable to composite tiled particles without support for R11G11B10F UAV loads"); - EnableTiledRendering = EnableTiledRendering&& g_bTypedUAVLoadSupport_R11G11B10_FLOAT; - - if (EnableTiledRendering) - { - ComputeContext& CompContext = Context.GetComputeContext(); - CompContext.TransitionResource(ColorTarget, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - CompContext.TransitionResource(BinCounters[0], D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - CompContext.TransitionResource(BinCounters[1], D3D12_RESOURCE_STATE_UNORDERED_ACCESS, true); - - CompContext.ClearUAV(BinCounters[0]); - CompContext.ClearUAV(BinCounters[1]); - CompContext.SetRootSignature(RootSig); - CompContext.SetDynamicConstantBufferView(1, sizeof(CBChangesPerView), &s_ChangesPerView); - - RenderTiles(CompContext, ColorTarget, ResponsiveMaskTarget, LinearDepth, isUpdateResponsiveMask); - - CompContext.InsertUAVBarrier(ColorTarget); - } - else - { - GraphicsContext& GrContext = Context.GetGraphicsContext(); - GrContext.SetRootSignature(RootSig); - GrContext.SetDynamicConstantBufferView(1, sizeof(CBChangesPerView), &s_ChangesPerView); - RenderSprites(GrContext, ColorTarget, DepthTarget, ResponsiveMaskTarget, LinearDepth, isUpdateResponsiveMask); - } - -} - -//--------------------------------------------------------------------- -// -// Clean up -// -//--------------------------------------------------------------------- - -void ParticleEffectManager::ClearAll() -{ - ParticleEffectsActive.clear(); - ParticleEffectsPool.clear(); - TextureNameArray.clear(); -} - -void ParticleEffectManager::ResetEffect(EffectHandle EffectID) -{ - if (!s_InitComplete || ParticleEffectsActive.size() == 0 || PauseSim || EffectID >= ParticleEffectsActive.size()) - return; - - ParticleEffectsActive[EffectID]->Reset(); -} - - -float ParticleEffectManager::GetCurrentLife(EffectHandle EffectID) -{ - if (!s_InitComplete || ParticleEffectsActive.size() == 0 || PauseSim || EffectID >= ParticleEffectsActive.size()) - return -1.0; - - return ParticleEffectsActive[EffectID]->GetElapsedTime(); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/ParticleEffectManager.h b/xess/samples/xess_demo/MiniEngine/Core/ParticleEffectManager.h deleted file mode 100644 index 7588306..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/ParticleEffectManager.h +++ /dev/null @@ -1,51 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): Julia Careaga -// James Stanard -// - -// Modified 2022, Intel Corporation. -// Added support for super sampling. - -#pragma once - -#include "ParticleEffectProperties.h" -#include "ParticleEffect.h" -#include "CommandContext.h" -#include "Math/Random.h" - -namespace Math -{ - class Camera; -} - -namespace ParticleEffectManager -{ - void Initialize( uint32_t MaxDisplayWidth, uint32_t MaxDisplayHeight ); - void Shutdown(); - void ClearAll(); - - void Update(ComputeContext& Context, float timeDelta ); - - typedef uint32_t EffectHandle; - EffectHandle InstantiateEffect( ParticleEffectProperties& effectProperties ); - void Update(ComputeContext& Context, float timeDelta ); - void Render(CommandContext& Context, const Math::Camera& Camera, ColorBuffer& ColorTarget, DepthBuffer& DepthTarget, ColorBuffer& ResponsiveMaskTarget, ColorBuffer& LinearDepth, bool isUpdateResponsiveMask = false); - void ResetEffect(EffectHandle EffectID); - float GetCurrentLife(EffectHandle EffectID); - void RegisterTexture(uint32_t index, const Texture& texture); - - extern BoolVar Enable; - extern BoolVar PauseSim; - extern BoolVar EnableTiledRendering; - extern bool Reproducible; //If you want to repro set to true. When true, effect uses the same set of random numbers each run - extern UINT ReproFrame; -} // namespace ParticleEffectManager diff --git a/xess/samples/xess_demo/MiniEngine/Core/ParticleEffectProperties.h b/xess/samples/xess_demo/MiniEngine/Core/ParticleEffectProperties.h deleted file mode 100644 index e98f169..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/ParticleEffectProperties.h +++ /dev/null @@ -1,54 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): Julia Careaga -// James Stanard -// - -#pragma once -#include "ParticleShaderStructs.h" -#include "Color.h" -#include - -struct ParticleEffectProperties -{ - ParticleEffectProperties() - { - MinStartColor = Color(0.8f, 0.8f, 1.0f); - MaxStartColor = Color(0.9f, 0.9f, 1.0f); - MinEndColor = Color(1.0f, 1.0f, 1.0f); - MaxEndColor = Color(1.0f, 1.0f, 1.0f); - EmitProperties = *CreateEmissionProperties(); //Properties passed to the shader - EmitRate = 200; - LifeMinMax = XMFLOAT2(1.0f, 2.0f); - MassMinMax = XMFLOAT2(0.5f, 1.0f); - Size = Math::Vector4(0.07f, 0.7f, 0.8f, 0.8f); // (Start size min, Start size max, End size min, End size max) - Spread = XMFLOAT3(0.5f, 1.5f, 0.1f); - TexturePath = L"Resources/Textures/sparkTex.dds"; - TotalActiveLifetime = 20.0; - Velocity = Math::Vector4(0.5, 3.0, -0.5, 3.0 ); // (X velocity min, X velocity max, Y velocity min, Y velocity max) - }; - - - Color MinStartColor; - Color MaxStartColor; - Color MinEndColor; - Color MaxEndColor; - EmissionProperties EmitProperties; - float EmitRate; - XMFLOAT2 LifeMinMax; - XMFLOAT2 MassMinMax; - Math::Vector4 Size; - XMFLOAT3 Spread; - std::wstring TexturePath; - float TotalActiveLifetime; - Math::Vector4 Velocity; - -}; diff --git a/xess/samples/xess_demo/MiniEngine/Core/ParticleEmissionProperties.cpp b/xess/samples/xess_demo/MiniEngine/Core/ParticleEmissionProperties.cpp deleted file mode 100644 index f588fe5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/ParticleEmissionProperties.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: Julia Careaga - -#pragma once -#include "pch.h" -#include "ParticleShaderStructs.h" - -EmissionProperties* CreateEmissionProperties() -{ - EmissionProperties* emitProps = new EmissionProperties; - ZeroMemory(emitProps, sizeof(*emitProps)); - emitProps->EmitPosW = emitProps->LastEmitPosW = XMFLOAT3(0.0,0.0,0.0); - emitProps->EmitDirW = XMFLOAT3(0.0,0.0,1.0); - emitProps->EmitRightW = XMFLOAT3(1.0,0.0,0.0); - emitProps->EmitUpW = XMFLOAT3(0.0,1.0,0.0); - emitProps->Restitution = 0.6f; - emitProps->FloorHeight = -0.7f; - emitProps->EmitSpeed = 1.0f; - emitProps->Gravity = XMFLOAT3(0, -5, 0); - emitProps->MaxParticles = 500; - return emitProps; -}; diff --git a/xess/samples/xess_demo/MiniEngine/Core/ParticleShaderStructs.h b/xess/samples/xess_demo/MiniEngine/Core/ParticleShaderStructs.h deleted file mode 100644 index 1a4569c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/ParticleShaderStructs.h +++ /dev/null @@ -1,87 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): Julia Careaga -// James Stanard -// - -#pragma once - -#include "VectorMath.h" -#include "Color.h" -#include - -// Emission Properties and other particle structs - -__declspec(align(16)) struct EmissionProperties -{ - XMFLOAT3 LastEmitPosW; - float EmitSpeed; - XMFLOAT3 EmitPosW; - float FloorHeight; - XMFLOAT3 EmitDirW; - float Restitution; - XMFLOAT3 EmitRightW; - float EmitterVelocitySensitivity; - XMFLOAT3 EmitUpW; - std::uint32_t MaxParticles; - XMFLOAT3 Gravity; - std::uint32_t TextureID; - XMFLOAT3 EmissiveColor; - float pad1; - XMUINT4 RandIndex[64]; -}; - -EmissionProperties* CreateEmissionProperties(); - -struct ParticleSpawnData -{ - float AgeRate; - float RotationSpeed; - float StartSize; - float EndSize; - XMFLOAT3 Velocity; float Mass; - XMFLOAT3 SpreadOffset; float Random; - Color StartColor; - Color EndColor; -}; - - -struct ParticleMotion -{ - XMFLOAT3 Position; - float Mass; - XMFLOAT3 Velocity; - float Age; - float Rotation; - std::uint32_t ResetDataIndex; -}; - -struct ParticleVertex -{ - XMFLOAT3 Position; - XMFLOAT4 Color; - float Size; - std::uint32_t TextureID; -}; - -struct ParticleScreenData -{ - float Corner[2]; - float RcpSize[2]; - float Color[4]; - float Depth; - float TextureIndex; - float TextureLevel; - std::uint32_t Bounds; -}; - - - diff --git a/xess/samples/xess_demo/MiniEngine/Core/PipelineState.cpp b/xess/samples/xess_demo/MiniEngine/Core/PipelineState.cpp deleted file mode 100644 index da05e96..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/PipelineState.cpp +++ /dev/null @@ -1,205 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard - -#include "pch.h" -#include "GraphicsCore.h" -#include "PipelineState.h" -#include "RootSignature.h" -#include "Hash.h" -#include -#include -#include - -using Math::IsAligned; -using namespace Graphics; -using Microsoft::WRL::ComPtr; -using namespace std; - -static map< size_t, ComPtr > s_GraphicsPSOHashMap; -static map< size_t, ComPtr > s_ComputePSOHashMap; - -void PSO::DestroyAll(void) -{ - s_GraphicsPSOHashMap.clear(); - s_ComputePSOHashMap.clear(); -} - - -GraphicsPSO::GraphicsPSO(const wchar_t* Name) - : PSO(Name) -{ - ZeroMemory(&m_PSODesc, sizeof(m_PSODesc)); - m_PSODesc.NodeMask = 1; - m_PSODesc.SampleMask = 0xFFFFFFFFu; - m_PSODesc.SampleDesc.Count = 1; - m_PSODesc.InputLayout.NumElements = 0; -} - -void GraphicsPSO::SetBlendState( const D3D12_BLEND_DESC& BlendDesc ) -{ - m_PSODesc.BlendState = BlendDesc; -} - -void GraphicsPSO::SetRasterizerState( const D3D12_RASTERIZER_DESC& RasterizerDesc ) -{ - m_PSODesc.RasterizerState = RasterizerDesc; -} - -void GraphicsPSO::SetDepthStencilState( const D3D12_DEPTH_STENCIL_DESC& DepthStencilDesc ) -{ - m_PSODesc.DepthStencilState = DepthStencilDesc; -} - -void GraphicsPSO::SetSampleMask( UINT SampleMask ) -{ - m_PSODesc.SampleMask = SampleMask; -} - -void GraphicsPSO::SetPrimitiveTopologyType( D3D12_PRIMITIVE_TOPOLOGY_TYPE TopologyType ) -{ - ASSERT(TopologyType != D3D12_PRIMITIVE_TOPOLOGY_TYPE_UNDEFINED, "Can't draw with undefined topology"); - m_PSODesc.PrimitiveTopologyType = TopologyType; -} - -void GraphicsPSO::SetPrimitiveRestart( D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBProps ) -{ - m_PSODesc.IBStripCutValue = IBProps; -} - -void GraphicsPSO::SetDepthTargetFormat(DXGI_FORMAT DSVFormat, UINT MsaaCount, UINT MsaaQuality ) -{ - SetRenderTargetFormats(0, nullptr, DSVFormat, MsaaCount, MsaaQuality ); -} - -void GraphicsPSO::SetRenderTargetFormat( DXGI_FORMAT RTVFormat, DXGI_FORMAT DSVFormat, UINT MsaaCount, UINT MsaaQuality ) -{ - SetRenderTargetFormats(1, &RTVFormat, DSVFormat, MsaaCount, MsaaQuality ); -} - -void GraphicsPSO::SetRenderTargetFormats( UINT NumRTVs, const DXGI_FORMAT* RTVFormats, DXGI_FORMAT DSVFormat, UINT MsaaCount, UINT MsaaQuality ) -{ - ASSERT(NumRTVs == 0 || RTVFormats != nullptr, "Null format array conflicts with non-zero length"); - for (UINT i = 0; i < NumRTVs; ++i) - { - ASSERT(RTVFormats[i] != DXGI_FORMAT_UNKNOWN); - m_PSODesc.RTVFormats[i] = RTVFormats[i]; - } - for (UINT i = NumRTVs; i < m_PSODesc.NumRenderTargets; ++i) - m_PSODesc.RTVFormats[i] = DXGI_FORMAT_UNKNOWN; - m_PSODesc.NumRenderTargets = NumRTVs; - m_PSODesc.DSVFormat = DSVFormat; - m_PSODesc.SampleDesc.Count = MsaaCount; - m_PSODesc.SampleDesc.Quality = MsaaQuality; -} - -void GraphicsPSO::SetInputLayout( UINT NumElements, const D3D12_INPUT_ELEMENT_DESC* pInputElementDescs ) -{ - m_PSODesc.InputLayout.NumElements = NumElements; - - if (NumElements > 0) - { - D3D12_INPUT_ELEMENT_DESC* NewElements = (D3D12_INPUT_ELEMENT_DESC*)malloc(sizeof(D3D12_INPUT_ELEMENT_DESC) * NumElements); - memcpy(NewElements, pInputElementDescs, NumElements * sizeof(D3D12_INPUT_ELEMENT_DESC)); - m_InputLayouts.reset((const D3D12_INPUT_ELEMENT_DESC*)NewElements); - } - else - m_InputLayouts = nullptr; -} - -void GraphicsPSO::Finalize() -{ - // Make sure the root signature is finalized first - m_PSODesc.pRootSignature = m_RootSignature->GetSignature(); - ASSERT(m_PSODesc.pRootSignature != nullptr); - - m_PSODesc.InputLayout.pInputElementDescs = nullptr; - size_t HashCode = Utility::HashState(&m_PSODesc); - HashCode = Utility::HashState(m_InputLayouts.get(), m_PSODesc.InputLayout.NumElements, HashCode); - m_PSODesc.InputLayout.pInputElementDescs = m_InputLayouts.get(); - - ID3D12PipelineState** PSORef = nullptr; - bool firstCompile = false; - { - static mutex s_HashMapMutex; - lock_guard CS(s_HashMapMutex); - auto iter = s_GraphicsPSOHashMap.find(HashCode); - - // Reserve space so the next inquiry will find that someone got here first. - if (iter == s_GraphicsPSOHashMap.end()) - { - firstCompile = true; - PSORef = s_GraphicsPSOHashMap[HashCode].GetAddressOf(); - } - else - PSORef = iter->second.GetAddressOf(); - } - - if (firstCompile) - { - ASSERT(m_PSODesc.DepthStencilState.DepthEnable != (m_PSODesc.DSVFormat == DXGI_FORMAT_UNKNOWN)); - ASSERT_SUCCEEDED( g_Device->CreateGraphicsPipelineState(&m_PSODesc, MY_IID_PPV_ARGS(&m_PSO)) ); - s_GraphicsPSOHashMap[HashCode].Attach(m_PSO); - m_PSO->SetName(m_Name); - } - else - { - while (*PSORef == nullptr) - this_thread::yield(); - m_PSO = *PSORef; - } -} - -void ComputePSO::Finalize() -{ - // Make sure the root signature is finalized first - m_PSODesc.pRootSignature = m_RootSignature->GetSignature(); - ASSERT(m_PSODesc.pRootSignature != nullptr); - - size_t HashCode = Utility::HashState(&m_PSODesc); - - ID3D12PipelineState** PSORef = nullptr; - bool firstCompile = false; - { - static mutex s_HashMapMutex; - lock_guard CS(s_HashMapMutex); - auto iter = s_ComputePSOHashMap.find(HashCode); - - // Reserve space so the next inquiry will find that someone got here first. - if (iter == s_ComputePSOHashMap.end()) - { - firstCompile = true; - PSORef = s_ComputePSOHashMap[HashCode].GetAddressOf(); - } - else - PSORef = iter->second.GetAddressOf(); - } - - if (firstCompile) - { - ASSERT_SUCCEEDED( g_Device->CreateComputePipelineState(&m_PSODesc, MY_IID_PPV_ARGS(&m_PSO)) ); - s_ComputePSOHashMap[HashCode].Attach(m_PSO); - m_PSO->SetName(m_Name); - } - else - { - while (*PSORef == nullptr) - this_thread::yield(); - m_PSO = *PSORef; - } -} - -ComputePSO::ComputePSO(const wchar_t* Name) - : PSO(Name) -{ - ZeroMemory(&m_PSODesc, sizeof(m_PSODesc)); - m_PSODesc.NodeMask = 1; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/PipelineState.h b/xess/samples/xess_demo/MiniEngine/Core/PipelineState.h deleted file mode 100644 index a73bcd0..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/PipelineState.h +++ /dev/null @@ -1,115 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "pch.h" - -class CommandContext; -class RootSignature; -class VertexShader; -class GeometryShader; -class HullShader; -class DomainShader; -class PixelShader; -class ComputeShader; - -class PSO -{ -public: - - PSO(const wchar_t* Name) : m_Name(Name), m_RootSignature(nullptr), m_PSO(nullptr) {} - - static void DestroyAll( void ); - - void SetRootSignature( const RootSignature& BindMappings ) - { - m_RootSignature = &BindMappings; - } - - const RootSignature& GetRootSignature( void ) const - { - ASSERT(m_RootSignature != nullptr); - return *m_RootSignature; - } - - ID3D12PipelineState* GetPipelineStateObject( void ) const { return m_PSO; } - -protected: - - const wchar_t* m_Name; - - const RootSignature* m_RootSignature; - - ID3D12PipelineState* m_PSO; -}; - -class GraphicsPSO : public PSO -{ - friend class CommandContext; - -public: - - // Start with empty state - GraphicsPSO(const wchar_t* Name = L"Unnamed Graphics PSO"); - - void SetBlendState( const D3D12_BLEND_DESC& BlendDesc ); - void SetRasterizerState( const D3D12_RASTERIZER_DESC& RasterizerDesc ); - void SetDepthStencilState( const D3D12_DEPTH_STENCIL_DESC& DepthStencilDesc ); - void SetSampleMask( UINT SampleMask ); - void SetPrimitiveTopologyType( D3D12_PRIMITIVE_TOPOLOGY_TYPE TopologyType ); - void SetDepthTargetFormat( DXGI_FORMAT DSVFormat, UINT MsaaCount = 1, UINT MsaaQuality = 0 ); - void SetRenderTargetFormat( DXGI_FORMAT RTVFormat, DXGI_FORMAT DSVFormat, UINT MsaaCount = 1, UINT MsaaQuality = 0 ); - void SetRenderTargetFormats( UINT NumRTVs, const DXGI_FORMAT* RTVFormats, DXGI_FORMAT DSVFormat, UINT MsaaCount = 1, UINT MsaaQuality = 0 ); - void SetInputLayout( UINT NumElements, const D3D12_INPUT_ELEMENT_DESC* pInputElementDescs ); - void SetPrimitiveRestart( D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBProps ); - - // These const_casts shouldn't be necessary, but we need to fix the API to accept "const void* pShaderBytecode" - void SetVertexShader( const void* Binary, size_t Size ) { m_PSODesc.VS = CD3DX12_SHADER_BYTECODE(const_cast(Binary), Size); } - void SetPixelShader( const void* Binary, size_t Size ) { m_PSODesc.PS = CD3DX12_SHADER_BYTECODE(const_cast(Binary), Size); } - void SetGeometryShader( const void* Binary, size_t Size ) { m_PSODesc.GS = CD3DX12_SHADER_BYTECODE(const_cast(Binary), Size); } - void SetHullShader( const void* Binary, size_t Size ) { m_PSODesc.HS = CD3DX12_SHADER_BYTECODE(const_cast(Binary), Size); } - void SetDomainShader( const void* Binary, size_t Size ) { m_PSODesc.DS = CD3DX12_SHADER_BYTECODE(const_cast(Binary), Size); } - - void SetVertexShader( const D3D12_SHADER_BYTECODE& Binary ) { m_PSODesc.VS = Binary; } - void SetPixelShader( const D3D12_SHADER_BYTECODE& Binary ) { m_PSODesc.PS = Binary; } - void SetGeometryShader( const D3D12_SHADER_BYTECODE& Binary ) { m_PSODesc.GS = Binary; } - void SetHullShader( const D3D12_SHADER_BYTECODE& Binary ) { m_PSODesc.HS = Binary; } - void SetDomainShader( const D3D12_SHADER_BYTECODE& Binary ) { m_PSODesc.DS = Binary; } - - // Perform validation and compute a hash value for fast state block comparisons - void Finalize(); - -private: - - D3D12_GRAPHICS_PIPELINE_STATE_DESC m_PSODesc; - std::shared_ptr m_InputLayouts; -}; - - -class ComputePSO : public PSO -{ - friend class CommandContext; - -public: - ComputePSO(const wchar_t* Name = L"Unnamed Compute PSO"); - - void SetComputeShader( const void* Binary, size_t Size ) { m_PSODesc.CS = CD3DX12_SHADER_BYTECODE(const_cast(Binary), Size); } - void SetComputeShader( const D3D12_SHADER_BYTECODE& Binary ) { m_PSODesc.CS = Binary; } - - void Finalize(); - -private: - - D3D12_COMPUTE_PIPELINE_STATE_DESC m_PSODesc; -}; diff --git a/xess/samples/xess_demo/MiniEngine/Core/PixelBuffer.cpp b/xess/samples/xess_demo/MiniEngine/Core/PixelBuffer.cpp deleted file mode 100644 index d21f7c3..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/PixelBuffer.cpp +++ /dev/null @@ -1,410 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "PixelBuffer.h" -#include "EsramAllocator.h" -#include "GraphicsCore.h" -#include "BufferManager.h" -#include "CommandContext.h" -#include "ReadbackBuffer.h" -#include - -using namespace Graphics; - -DXGI_FORMAT PixelBuffer::GetBaseFormat( DXGI_FORMAT defaultFormat ) -{ - switch (defaultFormat) - { - case DXGI_FORMAT_R8G8B8A8_UNORM: - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - return DXGI_FORMAT_R8G8B8A8_TYPELESS; - - case DXGI_FORMAT_B8G8R8A8_UNORM: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - return DXGI_FORMAT_B8G8R8A8_TYPELESS; - - case DXGI_FORMAT_B8G8R8X8_UNORM: - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - return DXGI_FORMAT_B8G8R8X8_TYPELESS; - - // 32-bit Z w/ Stencil - case DXGI_FORMAT_R32G8X24_TYPELESS: - case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: - case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: - case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: - return DXGI_FORMAT_R32G8X24_TYPELESS; - - // No Stencil - case DXGI_FORMAT_R32_TYPELESS: - case DXGI_FORMAT_D32_FLOAT: - case DXGI_FORMAT_R32_FLOAT: - return DXGI_FORMAT_R32_TYPELESS; - - // 24-bit Z - case DXGI_FORMAT_R24G8_TYPELESS: - case DXGI_FORMAT_D24_UNORM_S8_UINT: - case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: - case DXGI_FORMAT_X24_TYPELESS_G8_UINT: - return DXGI_FORMAT_R24G8_TYPELESS; - - // 16-bit Z w/o Stencil - case DXGI_FORMAT_R16_TYPELESS: - case DXGI_FORMAT_D16_UNORM: - case DXGI_FORMAT_R16_UNORM: - return DXGI_FORMAT_R16_TYPELESS; - - default: - return defaultFormat; - } -} - -DXGI_FORMAT PixelBuffer::GetUAVFormat( DXGI_FORMAT defaultFormat ) -{ - switch (defaultFormat) - { - case DXGI_FORMAT_R8G8B8A8_TYPELESS: - case DXGI_FORMAT_R8G8B8A8_UNORM: - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - return DXGI_FORMAT_R8G8B8A8_UNORM; - - case DXGI_FORMAT_B8G8R8A8_TYPELESS: - case DXGI_FORMAT_B8G8R8A8_UNORM: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - return DXGI_FORMAT_B8G8R8A8_UNORM; - - case DXGI_FORMAT_B8G8R8X8_TYPELESS: - case DXGI_FORMAT_B8G8R8X8_UNORM: - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - return DXGI_FORMAT_B8G8R8X8_UNORM; - - case DXGI_FORMAT_R32_TYPELESS: - case DXGI_FORMAT_R32_FLOAT: - return DXGI_FORMAT_R32_FLOAT; - -#ifdef _DEBUG - case DXGI_FORMAT_R32G8X24_TYPELESS: - case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: - case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: - case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: - case DXGI_FORMAT_D32_FLOAT: - case DXGI_FORMAT_R24G8_TYPELESS: - case DXGI_FORMAT_D24_UNORM_S8_UINT: - case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: - case DXGI_FORMAT_X24_TYPELESS_G8_UINT: - case DXGI_FORMAT_D16_UNORM: - - ASSERT(false, "Requested a UAV Format for a depth stencil Format."); -#endif - - default: - return defaultFormat; - } -} - -DXGI_FORMAT PixelBuffer::GetDSVFormat( DXGI_FORMAT defaultFormat ) -{ - switch (defaultFormat) - { - // 32-bit Z w/ Stencil - case DXGI_FORMAT_R32G8X24_TYPELESS: - case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: - case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: - case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: - return DXGI_FORMAT_D32_FLOAT_S8X24_UINT; - - // No Stencil - case DXGI_FORMAT_R32_TYPELESS: - case DXGI_FORMAT_D32_FLOAT: - case DXGI_FORMAT_R32_FLOAT: - return DXGI_FORMAT_D32_FLOAT; - - // 24-bit Z - case DXGI_FORMAT_R24G8_TYPELESS: - case DXGI_FORMAT_D24_UNORM_S8_UINT: - case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: - case DXGI_FORMAT_X24_TYPELESS_G8_UINT: - return DXGI_FORMAT_D24_UNORM_S8_UINT; - - // 16-bit Z w/o Stencil - case DXGI_FORMAT_R16_TYPELESS: - case DXGI_FORMAT_D16_UNORM: - case DXGI_FORMAT_R16_UNORM: - return DXGI_FORMAT_D16_UNORM; - - default: - return defaultFormat; - } -} - -DXGI_FORMAT PixelBuffer::GetDepthFormat( DXGI_FORMAT defaultFormat ) -{ - switch (defaultFormat) - { - // 32-bit Z w/ Stencil - case DXGI_FORMAT_R32G8X24_TYPELESS: - case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: - case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: - case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: - return DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS; - - // No Stencil - case DXGI_FORMAT_R32_TYPELESS: - case DXGI_FORMAT_D32_FLOAT: - case DXGI_FORMAT_R32_FLOAT: - return DXGI_FORMAT_R32_FLOAT; - - // 24-bit Z - case DXGI_FORMAT_R24G8_TYPELESS: - case DXGI_FORMAT_D24_UNORM_S8_UINT: - case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: - case DXGI_FORMAT_X24_TYPELESS_G8_UINT: - return DXGI_FORMAT_R24_UNORM_X8_TYPELESS; - - // 16-bit Z w/o Stencil - case DXGI_FORMAT_R16_TYPELESS: - case DXGI_FORMAT_D16_UNORM: - case DXGI_FORMAT_R16_UNORM: - return DXGI_FORMAT_R16_UNORM; - - default: - return DXGI_FORMAT_UNKNOWN; - } -} - -DXGI_FORMAT PixelBuffer::GetStencilFormat( DXGI_FORMAT defaultFormat ) -{ - switch (defaultFormat) - { - // 32-bit Z w/ Stencil - case DXGI_FORMAT_R32G8X24_TYPELESS: - case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: - case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: - case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: - return DXGI_FORMAT_X32_TYPELESS_G8X24_UINT; - - // 24-bit Z - case DXGI_FORMAT_R24G8_TYPELESS: - case DXGI_FORMAT_D24_UNORM_S8_UINT: - case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: - case DXGI_FORMAT_X24_TYPELESS_G8_UINT: - return DXGI_FORMAT_X24_TYPELESS_G8_UINT; - - default: - return DXGI_FORMAT_UNKNOWN; - } -} - -//-------------------------------------------------------------------------------------- -// Return the BPP for a particular format -//-------------------------------------------------------------------------------------- -size_t PixelBuffer::BytesPerPixel( DXGI_FORMAT Format ) -{ - switch( Format ) - { - case DXGI_FORMAT_R32G32B32A32_TYPELESS: - case DXGI_FORMAT_R32G32B32A32_FLOAT: - case DXGI_FORMAT_R32G32B32A32_UINT: - case DXGI_FORMAT_R32G32B32A32_SINT: - return 16; - - case DXGI_FORMAT_R32G32B32_TYPELESS: - case DXGI_FORMAT_R32G32B32_FLOAT: - case DXGI_FORMAT_R32G32B32_UINT: - case DXGI_FORMAT_R32G32B32_SINT: - return 12; - - case DXGI_FORMAT_R16G16B16A16_TYPELESS: - case DXGI_FORMAT_R16G16B16A16_FLOAT: - case DXGI_FORMAT_R16G16B16A16_UNORM: - case DXGI_FORMAT_R16G16B16A16_UINT: - case DXGI_FORMAT_R16G16B16A16_SNORM: - case DXGI_FORMAT_R16G16B16A16_SINT: - case DXGI_FORMAT_R32G32_TYPELESS: - case DXGI_FORMAT_R32G32_FLOAT: - case DXGI_FORMAT_R32G32_UINT: - case DXGI_FORMAT_R32G32_SINT: - case DXGI_FORMAT_R32G8X24_TYPELESS: - case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: - case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: - case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: - return 8; - - case DXGI_FORMAT_R10G10B10A2_TYPELESS: - case DXGI_FORMAT_R10G10B10A2_UNORM: - case DXGI_FORMAT_R10G10B10A2_UINT: - case DXGI_FORMAT_R11G11B10_FLOAT: - case DXGI_FORMAT_R8G8B8A8_TYPELESS: - case DXGI_FORMAT_R8G8B8A8_UNORM: - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - case DXGI_FORMAT_R8G8B8A8_UINT: - case DXGI_FORMAT_R8G8B8A8_SNORM: - case DXGI_FORMAT_R8G8B8A8_SINT: - case DXGI_FORMAT_R16G16_TYPELESS: - case DXGI_FORMAT_R16G16_FLOAT: - case DXGI_FORMAT_R16G16_UNORM: - case DXGI_FORMAT_R16G16_UINT: - case DXGI_FORMAT_R16G16_SNORM: - case DXGI_FORMAT_R16G16_SINT: - case DXGI_FORMAT_R32_TYPELESS: - case DXGI_FORMAT_D32_FLOAT: - case DXGI_FORMAT_R32_FLOAT: - case DXGI_FORMAT_R32_UINT: - case DXGI_FORMAT_R32_SINT: - case DXGI_FORMAT_R24G8_TYPELESS: - case DXGI_FORMAT_D24_UNORM_S8_UINT: - case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: - case DXGI_FORMAT_X24_TYPELESS_G8_UINT: - case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: - case DXGI_FORMAT_R8G8_B8G8_UNORM: - case DXGI_FORMAT_G8R8_G8B8_UNORM: - case DXGI_FORMAT_B8G8R8A8_UNORM: - case DXGI_FORMAT_B8G8R8X8_UNORM: - case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: - case DXGI_FORMAT_B8G8R8A8_TYPELESS: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8X8_TYPELESS: - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - return 4; - - case DXGI_FORMAT_R8G8_TYPELESS: - case DXGI_FORMAT_R8G8_UNORM: - case DXGI_FORMAT_R8G8_UINT: - case DXGI_FORMAT_R8G8_SNORM: - case DXGI_FORMAT_R8G8_SINT: - case DXGI_FORMAT_R16_TYPELESS: - case DXGI_FORMAT_R16_FLOAT: - case DXGI_FORMAT_D16_UNORM: - case DXGI_FORMAT_R16_UNORM: - case DXGI_FORMAT_R16_UINT: - case DXGI_FORMAT_R16_SNORM: - case DXGI_FORMAT_R16_SINT: - case DXGI_FORMAT_B5G6R5_UNORM: - case DXGI_FORMAT_B5G5R5A1_UNORM: - case DXGI_FORMAT_A8P8: - case DXGI_FORMAT_B4G4R4A4_UNORM: - return 2; - - case DXGI_FORMAT_R8_TYPELESS: - case DXGI_FORMAT_R8_UNORM: - case DXGI_FORMAT_R8_UINT: - case DXGI_FORMAT_R8_SNORM: - case DXGI_FORMAT_R8_SINT: - case DXGI_FORMAT_A8_UNORM: - case DXGI_FORMAT_P8: - return 1; - - default: - return 0; - } -} - -void PixelBuffer::AssociateWithResource( ID3D12Device* Device, const std::wstring& Name, ID3D12Resource* Resource, D3D12_RESOURCE_STATES CurrentState ) -{ - (Device); // Unused until we support multiple adapters - - ASSERT(Resource != nullptr); - D3D12_RESOURCE_DESC ResourceDesc = Resource->GetDesc(); - - m_pResource.Attach(Resource); - m_UsageState = CurrentState; - - m_Width = (uint32_t)ResourceDesc.Width; // We don't care about large virtual textures yet - m_Height = ResourceDesc.Height; - m_ArraySize = ResourceDesc.DepthOrArraySize; - m_Format = ResourceDesc.Format; - -#ifndef RELEASE - m_pResource->SetName(Name.c_str()); -#else - (Name); -#endif -} - -D3D12_RESOURCE_DESC PixelBuffer::DescribeTex2D( uint32_t Width, uint32_t Height, uint32_t DepthOrArraySize, - uint32_t NumMips, DXGI_FORMAT Format, UINT Flags) -{ - m_Width = Width; - m_Height = Height; - m_ArraySize = DepthOrArraySize; - m_Format = Format; - - D3D12_RESOURCE_DESC Desc = {}; - Desc.Alignment = 0; - Desc.DepthOrArraySize = (UINT16)DepthOrArraySize; - Desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; - Desc.Flags = (D3D12_RESOURCE_FLAGS)Flags; - Desc.Format = GetBaseFormat(Format); - Desc.Height = (UINT)Height; - Desc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN; - Desc.MipLevels = (UINT16)NumMips; - Desc.SampleDesc.Count = 1; - Desc.SampleDesc.Quality = 0; - Desc.Width = (UINT64)Width; - return Desc; -} - -void PixelBuffer::CreateTextureResource( ID3D12Device* Device, const std::wstring& Name, - const D3D12_RESOURCE_DESC& ResourceDesc, D3D12_CLEAR_VALUE ClearValue, D3D12_GPU_VIRTUAL_ADDRESS VidMemPtr ) -{ - Destroy(); - - (void)VidMemPtr; - - { - CD3DX12_HEAP_PROPERTIES HeapProps(D3D12_HEAP_TYPE_DEFAULT); - ASSERT_SUCCEEDED( Device->CreateCommittedResource( &HeapProps, D3D12_HEAP_FLAG_NONE, - &ResourceDesc, D3D12_RESOURCE_STATE_COMMON, &ClearValue, MY_IID_PPV_ARGS(&m_pResource) )); - } - - m_UsageState = D3D12_RESOURCE_STATE_COMMON; - m_GpuVirtualAddress = D3D12_GPU_VIRTUAL_ADDRESS_NULL; - -#ifndef RELEASE - m_pResource->SetName(Name.c_str()); -#else - (Name); -#endif -} - -void PixelBuffer::CreateTextureResource( ID3D12Device* Device, const std::wstring& Name, - const D3D12_RESOURCE_DESC& ResourceDesc, D3D12_CLEAR_VALUE ClearValue, EsramAllocator& Allocator ) -{ - (Allocator); - CreateTextureResource(Device, Name, ResourceDesc, ClearValue); -} - -void PixelBuffer::ExportToFile( const std::wstring& FilePath ) -{ - // This very short command list only issues one API call and will be synchronized so we can immediately read - // the buffer contents. - ReadbackBuffer TempBuffer; - CommandContext& Context = CommandContext::Begin(L"Copy texture to memory"); - uint32_t RowPitch = Context.ReadbackTexture(TempBuffer, *this); - Context.Finish(true); - - // Retrieve a CPU-visible pointer to the buffer memory. Map the whole range for reading. - void* Memory = TempBuffer.Map(); - - // Open the file and write the header followed by the texel data. - std::ofstream OutFile(FilePath, std::ios::out | std::ios::binary); - OutFile.write((const char*)&m_Format, 4); - OutFile.write((const char*)&RowPitch, 4); - OutFile.write((const char*)&m_Width, 4); - OutFile.write((const char*)&m_Height, 4); - OutFile.write((const char*)Memory, TempBuffer.GetBufferSize()); - OutFile.close(); - - // No values were written to the buffer, so use a null range when unmapping. - TempBuffer.Unmap(); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/PixelBuffer.h b/xess/samples/xess_demo/MiniEngine/Core/PixelBuffer.h deleted file mode 100644 index de678a5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/PixelBuffer.h +++ /dev/null @@ -1,66 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "GpuResource.h" - -class EsramAllocator; - -class PixelBuffer : public GpuResource -{ -public: - static DXGI_FORMAT GetBaseFormat(DXGI_FORMAT Format); - static DXGI_FORMAT GetUAVFormat(DXGI_FORMAT Format); - static DXGI_FORMAT GetDSVFormat(DXGI_FORMAT Format); - static DXGI_FORMAT GetDepthFormat(DXGI_FORMAT Format); - static DXGI_FORMAT GetStencilFormat(DXGI_FORMAT Format); - static size_t BytesPerPixel(DXGI_FORMAT Format); - -public: - PixelBuffer() : m_Width(0), m_Height(0), m_ArraySize(0), m_Format(DXGI_FORMAT_UNKNOWN), m_BankRotation(0) {} - - uint32_t GetWidth(void) const { return m_Width; } - uint32_t GetHeight(void) const { return m_Height; } - uint32_t GetDepth(void) const { return m_ArraySize; } - const DXGI_FORMAT& GetFormat(void) const { return m_Format; } - - // Has no effect on Desktop - void SetBankRotation( uint32_t RotationAmount ) - { - (RotationAmount); - } - - // Write the raw pixel buffer contents to a file - // Note that data is preceded by a 16-byte header: { DXGI_FORMAT, Pitch (in pixels), Width (in pixels), Height } - void ExportToFile( const std::wstring& FilePath ); - -protected: - - D3D12_RESOURCE_DESC DescribeTex2D(uint32_t Width, uint32_t Height, uint32_t DepthOrArraySize, uint32_t NumMips, DXGI_FORMAT Format, UINT Flags); - - void AssociateWithResource( ID3D12Device* Device, const std::wstring& Name, ID3D12Resource* Resource, D3D12_RESOURCE_STATES CurrentState ); - - void CreateTextureResource( ID3D12Device* Device, const std::wstring& Name, const D3D12_RESOURCE_DESC& ResourceDesc, - D3D12_CLEAR_VALUE ClearValue, D3D12_GPU_VIRTUAL_ADDRESS VidMemPtr = D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN ); - - void CreateTextureResource( ID3D12Device* Device, const std::wstring& Name, const D3D12_RESOURCE_DESC& ResourceDesc, - D3D12_CLEAR_VALUE ClearValue, EsramAllocator& Allocator ); - -protected: - uint32_t m_Width; - uint32_t m_Height; - uint32_t m_ArraySize; - DXGI_FORMAT m_Format; - uint32_t m_BankRotation; -}; diff --git a/xess/samples/xess_demo/MiniEngine/Core/PostEffects.cpp b/xess/samples/xess_demo/MiniEngine/Core/PostEffects.cpp deleted file mode 100644 index aba8bd4..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/PostEffects.cpp +++ /dev/null @@ -1,665 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -// Modified 2022, Intel Corporation. -// Added support for super sampling. - -#include "pch.h" - -#include "PostEffects.h" -#include "GameCore.h" -#include "CommandContext.h" -#include "RootSignature.h" -#include "PipelineState.h" -#include "Display.h" -#include "BufferManager.h" -#include "MotionBlur.h" -#include "DepthOfField.h" -#include "FXAA.h" -#include "Math/Random.h" - -#include "CompiledShaders/ToneMapCS.h" -#include "CompiledShaders/ToneMap2CS.h" -#include "CompiledShaders/ToneMapHDRCS.h" -#include "CompiledShaders/ToneMapHDR2CS.h" -#include "CompiledShaders/ApplyBloomCS.h" -#include "CompiledShaders/ApplyBloom2CS.h" -#include "CompiledShaders/DebugLuminanceHdrCS.h" -#include "CompiledShaders/DebugLuminanceHdr2CS.h" -#include "CompiledShaders/DebugLuminanceLdrCS.h" -#include "CompiledShaders/DebugLuminanceLdr2CS.h" -#include "CompiledShaders/GenerateHistogramCS.h" -#include "CompiledShaders/DebugDrawHistogramCS.h" -#include "CompiledShaders/AdaptExposureCS.h" -#include "CompiledShaders/DownsampleBloomCS.h" -#include "CompiledShaders/DownsampleBloomAllCS.h" -#include "CompiledShaders/UpsampleAndBlurCS.h" -#include "CompiledShaders/BlurCS.h" -#include "CompiledShaders/BloomExtractAndDownsampleHdrCS.h" -#include "CompiledShaders/BloomExtractAndDownsampleLdrCS.h" -#include "CompiledShaders/ExtractLumaCS.h" -#include "CompiledShaders/AverageLumaCS.h" -#include "CompiledShaders/CopyBackPostBufferCS.h" - -using namespace Graphics; - -namespace SSAO -{ - extern BoolVar DebugDraw; -} - -namespace FXAA -{ - extern BoolVar DebugDraw; -} - -namespace DepthOfField -{ - extern BoolVar Enable; - extern EnumVar DebugMode; -} - -namespace Graphics -{ - extern NumVar g_HDRPaperWhite; - extern NumVar g_MaxDisplayLuminance; -} - -namespace PostEffects -{ - const float kInitialMinLog = -12.0f; - const float kInitialMaxLog = 4.0f; - - BoolVar EnableHDR("Graphics/HDR/Enable", true); - BoolVar EnableAdaptation("Graphics/HDR/Adaptive Exposure", true); - ExpVar MinExposure("Graphics/HDR/Min Exposure", 1.0f / 64.0f, -8.0f, 0.0f, 0.25f); - ExpVar MaxExposure("Graphics/HDR/Max Exposure", 64.0f, 0.0f, 8.0f, 0.25f); - NumVar TargetLuminance("Graphics/HDR/Key", 0.08f, 0.01f, 0.99f, 0.01f); - NumVar AdaptationRate("Graphics/HDR/Adaptation Rate", 0.05f, 0.01f, 1.0f, 0.01f); - ExpVar Exposure("Graphics/HDR/Exposure", 2.0f, -8.0f, 8.0f, 0.25f); - BoolVar DrawHistogram("Graphics/HDR/Draw Histogram", false); - - BoolVar BloomEnable("Graphics/Bloom/Enable", true); - NumVar BloomThreshold("Graphics/Bloom/Threshold", 4.0f, 0.0f, 8.0f, 0.1f); // The threshold luminance above which a pixel will start to bloom - NumVar BloomStrength("Graphics/Bloom/Strength", 0.1f, 0.0f, 2.0f, 0.05f); // A modulator controlling how much bloom is added back into the image - NumVar BloomUpsampleFactor("Graphics/Bloom/Scatter", 0.65f, 0.0f, 1.0f, 0.05f); // Controls the "focus" of the blur. High values spread out more causing a haze. - BoolVar HighQualityBloom("Graphics/Bloom/High Quality", true); // High quality blurs 5 octaves of bloom; low quality only blurs 3. - - RootSignature PostEffectsRS; - ComputePSO ToneMapCS(L"Post Effects: Tone Map CS"); - ComputePSO ToneMapHDRCS(L"Post Effects: Tone Map HDR CS"); - ComputePSO ApplyBloomCS(L"Post Effects: Apply Bloom CS"); - ComputePSO DebugLuminanceHdrCS(L"Post Effects: Debug Luminance HDR CS"); - ComputePSO DebugLuminanceLdrCS(L"Post Effects: Debug Luminance LDR CS"); - ComputePSO GenerateHistogramCS(L"Post Effects: Generate Histogram CS"); - ComputePSO DrawHistogramCS(L"Post Effects: Draw Histogram CS"); - ComputePSO AdaptExposureCS(L"Post Effects: Adapt Exposure CS"); - ComputePSO DownsampleBloom2CS(L"Post Effects: Downsample Bloom 2 CS"); - ComputePSO DownsampleBloom4CS(L"Post Effects: Downsample Bloom 4 CS"); - ComputePSO UpsampleAndBlurCS(L"Post Effects: Upsample and Blur CS"); - ComputePSO BlurCS(L"Post Effects: Blur CS"); - ComputePSO BloomExtractAndDownsampleHdrCS(L"Post Effects: Bloom Extract and Downsample HDR CS"); - ComputePSO BloomExtractAndDownsampleLdrCS(L"Post Effects: Bloom Extract and Downsample LDR CS"); - ComputePSO ExtractLumaCS(L"Post Effects: Extract Luma CS"); - ComputePSO AverageLumaCS(L"Post Effects: Average Luma CS"); - ComputePSO CopyBackPostBufferCS(L"Post Effects: Copy Back Post Buffer CS"); - - StructuredBuffer g_Exposure; - - void UpdateExposure(ComputeContext&); - void BlurBuffer(ComputeContext&, ColorBuffer buffer[2], const ColorBuffer& lowerResBuf, float upsampleBlendFactor ); - void GenerateBloom(ComputeContext&); - void ExtractLuma(ComputeContext&); - void ProcessHDR(ComputeContext&); - void ProcessLDR(CommandContext&); -} - -void PostEffects::Initialize( void ) -{ - PostEffectsRS.Reset(4, 2); - PostEffectsRS.InitStaticSampler(0, SamplerLinearClampDesc); - PostEffectsRS.InitStaticSampler(1, SamplerLinearBorderDesc); - PostEffectsRS[0].InitAsConstants(0, 5); - PostEffectsRS[1].InitAsDescriptorRange(D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 0, 4); - PostEffectsRS[2].InitAsDescriptorRange(D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 4); - PostEffectsRS[3].InitAsConstantBuffer(1); - PostEffectsRS.Finalize(L"Post Effects"); - -#define CreatePSO( ObjName, ShaderByteCode ) \ - ObjName.SetRootSignature(PostEffectsRS); \ - ObjName.SetComputeShader(ShaderByteCode, sizeof(ShaderByteCode) ); \ - ObjName.Finalize(); - - if (g_bTypedUAVLoadSupport_R11G11B10_FLOAT) - { - CreatePSO(ToneMapCS, g_pToneMap2CS); - CreatePSO(ToneMapHDRCS, g_pToneMapHDR2CS); - CreatePSO(ApplyBloomCS, g_pApplyBloom2CS); - CreatePSO(DebugLuminanceHdrCS, g_pDebugLuminanceHdr2CS); - CreatePSO(DebugLuminanceLdrCS, g_pDebugLuminanceLdr2CS); - } - else - { - CreatePSO(ToneMapCS, g_pToneMapCS); - CreatePSO(ToneMapHDRCS, g_pToneMapHDRCS); - CreatePSO(ApplyBloomCS, g_pApplyBloomCS); - CreatePSO(DebugLuminanceHdrCS, g_pDebugLuminanceHdrCS); - CreatePSO(DebugLuminanceLdrCS, g_pDebugLuminanceLdrCS); - } - CreatePSO( GenerateHistogramCS, g_pGenerateHistogramCS ); - CreatePSO( DrawHistogramCS, g_pDebugDrawHistogramCS ); - CreatePSO( AdaptExposureCS, g_pAdaptExposureCS ); - CreatePSO( DownsampleBloom2CS, g_pDownsampleBloomCS ); - CreatePSO( DownsampleBloom4CS, g_pDownsampleBloomAllCS ); - CreatePSO( UpsampleAndBlurCS, g_pUpsampleAndBlurCS ); - CreatePSO( BlurCS, g_pBlurCS ); - CreatePSO( BloomExtractAndDownsampleHdrCS, g_pBloomExtractAndDownsampleHdrCS ); - CreatePSO( BloomExtractAndDownsampleLdrCS, g_pBloomExtractAndDownsampleLdrCS ); - CreatePSO( ExtractLumaCS, g_pExtractLumaCS ); - CreatePSO( AverageLumaCS, g_pAverageLumaCS ); - CreatePSO( CopyBackPostBufferCS, g_pCopyBackPostBufferCS ); - - -#undef CreatePSO - - __declspec(align(16)) float initExposure[] = - { - Exposure, 1.0f / Exposure, Exposure, 0.0f, - kInitialMinLog, kInitialMaxLog, kInitialMaxLog - kInitialMinLog, 1.0f / (kInitialMaxLog - kInitialMinLog) - }; - g_Exposure.Create(L"Exposure", 8, 4, initExposure); - - FXAA::Initialize(); - MotionBlur::Initialize(); - DepthOfField::Initialize(); -} - -void PostEffects::Shutdown( void ) -{ - g_Exposure.Destroy(); - - FXAA::Shutdown(); - MotionBlur::Shutdown(); - DepthOfField::Shutdown(); -} - -void PostEffects::BlurBuffer( ComputeContext& Context, ColorBuffer buffer[2], const ColorBuffer& lowerResBuf, float upsampleBlendFactor ) -{ - // Set the shader constants - uint32_t bufferWidth = buffer[0].GetWidth(); - uint32_t bufferHeight = buffer[0].GetHeight(); - Context.SetConstants(0, 1.0f / bufferWidth, 1.0f / bufferHeight, upsampleBlendFactor); - - // Set the input textures and output UAV - Context.TransitionResource( buffer[1], D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.SetDynamicDescriptor(1, 0, buffer[1].GetUAV()); - D3D12_CPU_DESCRIPTOR_HANDLE SRVs[2] = { buffer[0].GetSRV(), lowerResBuf.GetSRV() }; - Context.SetDynamicDescriptors(2, 0, 2, SRVs); - - // Set the shader: upsample and blur or just blur - Context.SetPipelineState(&buffer[0] == &lowerResBuf ? BlurCS : UpsampleAndBlurCS); - - // Dispatch the compute shader with default 8x8 thread groups - Context.Dispatch2D(bufferWidth, bufferHeight); - - Context.TransitionResource( buffer[1], D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); -} - -//-------------------------------------------------------------------------------------- -// Bloom effect in CS path -//-------------------------------------------------------------------------------------- -void PostEffects::GenerateBloom( ComputeContext& Context ) -{ - ScopedTimer _prof(L"Generate Bloom", Context); - - // We can generate a bloom buffer up to 1/4 smaller in each dimension without undersampling. If only downsizing by 1/2 or less, a faster - // shader can be used which only does one bilinear sample. - - uint32_t kBloomWidth = g_LumaLR.GetWidth(); - uint32_t kBloomHeight = g_LumaLR.GetHeight(); - - // These bloom buffer dimensions were chosen for their impressive divisibility by 128 and because they are roughly 16:9. - // The blurring algorithm is exactly 9 pixels by 9 pixels, so if the aspect ratio of each pixel is not square, the blur - // will be oval in appearance rather than circular. Coincidentally, they are close to 1/2 of a 720p buffer and 1/3 of - // 1080p. This is a common size for a bloom buffer on consoles. - ASSERT(kBloomWidth % 16 == 0 && kBloomHeight % 16 == 0, "Bloom buffer dimensions must be multiples of 16"); - - - Context.SetConstants(0, 1.0f / kBloomWidth, 1.0f / kBloomHeight, (float)BloomThreshold ); - Context.TransitionResource(g_aBloomUAV1[0], D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_LumaLR, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - - bool isUpscalingMode = Graphics::IsUpscalingEnabled(); - - if (isUpscalingMode) - { - Context.TransitionResource(g_UpscaledSceneColorBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - } - else - { - Context.TransitionResource(g_SceneColorBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - } - - Context.TransitionResource(g_Exposure, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - - { - - Context.SetDynamicDescriptor(1, 0, g_aBloomUAV1[0].GetUAV()); - Context.SetDynamicDescriptor(1, 1, g_LumaLR.GetUAV()); - - if (isUpscalingMode) - { - Context.SetDynamicDescriptor(2, 0, g_UpscaledSceneColorBuffer.GetSRV()); - } - else - { - Context.SetDynamicDescriptor(2, 0, g_SceneColorBuffer.GetSRV()); - } - - Context.SetDynamicDescriptor(2, 1, g_Exposure.GetSRV()); - - Context.SetPipelineState(EnableHDR ? BloomExtractAndDownsampleHdrCS : BloomExtractAndDownsampleLdrCS); - Context.Dispatch2D(kBloomWidth, kBloomHeight); - } - - Context.TransitionResource(g_aBloomUAV1[0], D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.SetDynamicDescriptor(2, 0, g_aBloomUAV1[0].GetSRV()); - - // The difference between high and low quality bloom is that high quality sums 5 octaves with a 2x frequency scale, and the low quality - // sums 3 octaves with a 4x frequency scale. - if (HighQualityBloom) - { - Context.TransitionResource(g_aBloomUAV2[0], D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_aBloomUAV3[0], D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_aBloomUAV4[0], D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_aBloomUAV5[0], D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - - // Set the UAVs - D3D12_CPU_DESCRIPTOR_HANDLE UAVs[4] = { - g_aBloomUAV2[0].GetUAV(), g_aBloomUAV3[0].GetUAV(), g_aBloomUAV4[0].GetUAV(), g_aBloomUAV5[0].GetUAV() }; - Context.SetDynamicDescriptors(1, 0, 4, UAVs); - - // Each dispatch group is 8x8 threads, but each thread reads in 2x2 source texels (bilinear filter). - Context.SetPipelineState(DownsampleBloom4CS); - Context.Dispatch2D(kBloomWidth / 2, kBloomHeight / 2); - - Context.TransitionResource(g_aBloomUAV2[0], D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_aBloomUAV3[0], D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_aBloomUAV4[0], D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_aBloomUAV5[0], D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - - float upsampleBlendFactor = BloomUpsampleFactor; - - // Blur then upsample and blur four times - BlurBuffer( Context, g_aBloomUAV5, g_aBloomUAV5[0], 1.0f ); - BlurBuffer( Context, g_aBloomUAV4, g_aBloomUAV5[1], upsampleBlendFactor ); - BlurBuffer( Context, g_aBloomUAV3, g_aBloomUAV4[1], upsampleBlendFactor ); - BlurBuffer( Context, g_aBloomUAV2, g_aBloomUAV3[1], upsampleBlendFactor ); - BlurBuffer( Context, g_aBloomUAV1, g_aBloomUAV2[1], upsampleBlendFactor ); - } - else - { - // Set the UAVs - D3D12_CPU_DESCRIPTOR_HANDLE UAVs[2] = { g_aBloomUAV3[0].GetUAV(), g_aBloomUAV5[0].GetUAV() }; - Context.SetDynamicDescriptors(1, 0, 2, UAVs); - - Context.TransitionResource(g_aBloomUAV3[0], D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_aBloomUAV5[0], D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - - // Each dispatch group is 8x8 threads, but each thread reads in 2x2 source texels (bilinear filter). - Context.SetPipelineState(DownsampleBloom2CS); - Context.Dispatch2D(kBloomWidth / 2, kBloomHeight / 2); - - Context.TransitionResource(g_aBloomUAV3[0], D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_aBloomUAV5[0], D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - - float upsampleBlendFactor = BloomUpsampleFactor * 2.0f / 3.0f; - - // Blur then upsample and blur two times - BlurBuffer( Context, g_aBloomUAV5, g_aBloomUAV5[0], 1.0f ); - BlurBuffer( Context, g_aBloomUAV3, g_aBloomUAV5[1], upsampleBlendFactor ); - BlurBuffer( Context, g_aBloomUAV1, g_aBloomUAV3[1], upsampleBlendFactor ); - } -} - -void PostEffects::ExtractLuma( ComputeContext& Context ) -{ - ScopedTimer _prof(L"Extract Luma", Context); - - Context.TransitionResource(g_LumaLR, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_Exposure, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.SetConstants(0, 1.0f / g_LumaLR.GetWidth(), 1.0f / g_LumaLR.GetHeight()); - Context.SetDynamicDescriptor(1, 0, g_LumaLR.GetUAV()); - - bool isUpscalingMode = Graphics::IsUpscalingEnabled(); - - if (isUpscalingMode) - { - Context.SetDynamicDescriptor(2, 0, g_UpscaledSceneColorBuffer.GetSRV()); - } - else - { - Context.SetDynamicDescriptor(2, 0, g_SceneColorBuffer.GetSRV()); - } - - Context.SetDynamicDescriptor(2, 1, g_Exposure.GetSRV()); - Context.SetPipelineState(ExtractLumaCS); - Context.Dispatch2D(g_LumaLR.GetWidth(), g_LumaLR.GetHeight()); -} - -void PostEffects::UpdateExposure( ComputeContext& Context ) -{ - ScopedTimer _prof(L"Update Exposure", Context); - - if (!EnableAdaptation) - { - __declspec(align(16)) float initExposure[] = - { - Exposure, 1.0f / Exposure, Exposure, 0.0f, - kInitialMinLog, kInitialMaxLog, kInitialMaxLog - kInitialMinLog, 1.0f / (kInitialMaxLog - kInitialMinLog) - }; - Context.WriteBuffer(g_Exposure, 0, initExposure, sizeof(initExposure)); - Context.TransitionResource(g_Exposure, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - - return; - } - - // Generate an HDR histogram - Context.TransitionResource(g_Histogram, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, true); - Context.ClearUAV(g_Histogram); - Context.TransitionResource(g_LumaLR, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.SetDynamicDescriptor(1, 0, g_Histogram.GetUAV() ); - Context.SetDynamicDescriptor(2, 0, g_LumaLR.GetSRV() ); - Context.SetPipelineState(GenerateHistogramCS); - Context.SetConstants(0, g_LumaLR.GetHeight()); - Context.Dispatch2D(g_LumaLR.GetWidth(), g_LumaLR.GetHeight(), 16, g_LumaLR.GetHeight()); - - __declspec(align(16)) struct - { - float TargetLuminance; - float AdaptationRate; - float MinExposure; - float MaxExposure; - uint32_t PixelCount; - } constants = - { - TargetLuminance, AdaptationRate, MinExposure, MaxExposure, - g_LumaLR.GetWidth() * g_LumaLR.GetHeight() - }; - Context.TransitionResource(g_Histogram, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_Exposure, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.SetDynamicDescriptor(1, 0, g_Exposure.GetUAV()); - Context.SetDynamicDescriptor(2, 0, g_Histogram.GetSRV()); - Context.SetDynamicConstantBufferView(3, sizeof(constants), &constants); - Context.SetPipelineState(AdaptExposureCS); - Context.Dispatch(); - Context.TransitionResource(g_Exposure, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); -} - -void PostEffects::ProcessHDR( ComputeContext& Context ) -{ - ScopedTimer _prof(L"HDR Tone Mapping", Context); - - if (BloomEnable) - { - GenerateBloom(Context); - Context.TransitionResource(g_aBloomUAV1[1], D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - } - else if (EnableAdaptation) - ExtractLuma(Context); - - if (Graphics::IsUpscalingEnabled()) - { - if (g_bTypedUAVLoadSupport_R11G11B10_FLOAT) - Context.TransitionResource(g_UpscaledSceneColorBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - else - Context.TransitionResource(g_PostEffectsBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - - Context.TransitionResource(g_LumaBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_Exposure, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - - Context.SetPipelineState(FXAA::DebugDraw ? DebugLuminanceHdrCS : (g_bEnableHDROutput ? ToneMapHDRCS : ToneMapCS)); - - // Set constants - Context.SetConstants(0, 1.0f / g_UpscaledSceneColorBuffer.GetWidth(), 1.0f / g_UpscaledSceneColorBuffer.GetHeight(), - (float)BloomStrength); - Context.SetConstant(0, 3, (float)g_HDRPaperWhite / (float)g_MaxDisplayLuminance); - Context.SetConstant(0, 4, (float)g_MaxDisplayLuminance); - - // Separate out SDR result from its perceived luminance - if (g_bTypedUAVLoadSupport_R11G11B10_FLOAT) - Context.SetDynamicDescriptor(1, 0, g_UpscaledSceneColorBuffer.GetUAV()); - else - { - Context.SetDynamicDescriptor(1, 0, g_PostEffectsBuffer.GetUAV()); - Context.SetDynamicDescriptor(2, 2, g_UpscaledSceneColorBuffer.GetSRV()); - } - Context.SetDynamicDescriptor(1, 1, g_LumaBuffer.GetUAV()); - - // Read in original HDR value and blurred bloom buffer - Context.SetDynamicDescriptor(2, 0, g_Exposure.GetSRV()); - Context.SetDynamicDescriptor(2, 1, BloomEnable ? g_aBloomUAV1[1].GetSRV() : GetDefaultTexture(kBlackOpaque2D)); - - Context.Dispatch2D(g_UpscaledSceneColorBuffer.GetWidth(), g_UpscaledSceneColorBuffer.GetHeight()); - } - else - { - if (g_bTypedUAVLoadSupport_R11G11B10_FLOAT) - Context.TransitionResource(g_SceneColorBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - else - Context.TransitionResource(g_PostEffectsBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - - Context.TransitionResource(g_LumaBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_Exposure, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - - Context.SetPipelineState(FXAA::DebugDraw ? DebugLuminanceHdrCS : (g_bEnableHDROutput ? ToneMapHDRCS : ToneMapCS)); - - // Set constants - Context.SetConstants(0, 1.0f / g_SceneColorBuffer.GetWidth(), 1.0f / g_SceneColorBuffer.GetHeight(), - (float)BloomStrength); - Context.SetConstant(0, 3, (float)g_HDRPaperWhite / (float)g_MaxDisplayLuminance); - Context.SetConstant(0, 4, (float)g_MaxDisplayLuminance); - - // Separate out SDR result from its perceived luminance - if (g_bTypedUAVLoadSupport_R11G11B10_FLOAT) - Context.SetDynamicDescriptor(1, 0, g_SceneColorBuffer.GetUAV()); - else - { - Context.SetDynamicDescriptor(1, 0, g_PostEffectsBuffer.GetUAV()); - Context.SetDynamicDescriptor(2, 2, g_SceneColorBuffer.GetSRV()); - } - Context.SetDynamicDescriptor(1, 1, g_LumaBuffer.GetUAV()); - - // Read in original HDR value and blurred bloom buffer - Context.SetDynamicDescriptor(2, 0, g_Exposure.GetSRV()); - Context.SetDynamicDescriptor(2, 1, BloomEnable ? g_aBloomUAV1[1].GetSRV() : GetDefaultTexture(kBlackOpaque2D)); - - Context.Dispatch2D(g_SceneColorBuffer.GetWidth(), g_SceneColorBuffer.GetHeight()); - } - - // Do this last so that the bright pass uses the same exposure as tone mapping - UpdateExposure(Context); -} - -void PostEffects::ProcessLDR(CommandContext& BaseContext) -{ - ScopedTimer _prof(L"SDR Processing", BaseContext); - - ComputeContext& Context = BaseContext.GetComputeContext(); - - bool bGenerateBloom = BloomEnable && !SSAO::DebugDraw; - if (bGenerateBloom) - GenerateBloom(Context); - - if (bGenerateBloom || FXAA::DebugDraw || SSAO::DebugDraw || !g_bTypedUAVLoadSupport_R11G11B10_FLOAT) - { - if (Graphics::IsUpscalingEnabled()) - { - if (g_bTypedUAVLoadSupport_R11G11B10_FLOAT) - Context.TransitionResource(g_UpscaledSceneColorBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - else - Context.TransitionResource(g_PostEffectsBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - - Context.TransitionResource(g_aBloomUAV1[1], D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_LumaBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - - // Set constants - Context.SetConstants(0, 1.0f / g_UpscaledSceneColorBuffer.GetWidth(), 1.0f / g_UpscaledSceneColorBuffer.GetHeight(), - (float)BloomStrength); - - // Separate out SDR result from its perceived luminance - if (g_bTypedUAVLoadSupport_R11G11B10_FLOAT) - Context.SetDynamicDescriptor(1, 0, g_UpscaledSceneColorBuffer.GetUAV()); - else - { - Context.SetDynamicDescriptor(1, 0, g_PostEffectsBuffer.GetUAV()); - Context.SetDynamicDescriptor(2, 2, g_UpscaledSceneColorBuffer.GetSRV()); - } - Context.SetDynamicDescriptor(1, 1, g_LumaBuffer.GetUAV()); - - // Read in original SDR value and blurred bloom buffer - Context.SetDynamicDescriptor(2, 0, bGenerateBloom ? g_aBloomUAV1[1].GetSRV() : GetDefaultTexture(kBlackOpaque2D)); - - Context.SetPipelineState(FXAA::DebugDraw ? DebugLuminanceLdrCS : ApplyBloomCS); - Context.Dispatch2D(g_UpscaledSceneColorBuffer.GetWidth(), g_UpscaledSceneColorBuffer.GetHeight()); - - Context.TransitionResource(g_LumaBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - } - else - { - if (g_bTypedUAVLoadSupport_R11G11B10_FLOAT) - Context.TransitionResource(g_SceneColorBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - else - Context.TransitionResource(g_PostEffectsBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - - Context.TransitionResource(g_aBloomUAV1[1], D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_LumaBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - - // Set constants - Context.SetConstants(0, 1.0f / g_SceneColorBuffer.GetWidth(), 1.0f / g_SceneColorBuffer.GetHeight(), - (float)BloomStrength); - - // Separate out SDR result from its perceived luminance - if (g_bTypedUAVLoadSupport_R11G11B10_FLOAT) - Context.SetDynamicDescriptor(1, 0, g_SceneColorBuffer.GetUAV()); - else - { - Context.SetDynamicDescriptor(1, 0, g_PostEffectsBuffer.GetUAV()); - Context.SetDynamicDescriptor(2, 2, g_SceneColorBuffer.GetSRV()); - } - Context.SetDynamicDescriptor(1, 1, g_LumaBuffer.GetUAV()); - - // Read in original SDR value and blurred bloom buffer - Context.SetDynamicDescriptor(2, 0, bGenerateBloom ? g_aBloomUAV1[1].GetSRV() : GetDefaultTexture(kBlackOpaque2D)); - - Context.SetPipelineState(FXAA::DebugDraw ? DebugLuminanceLdrCS : ApplyBloomCS); - Context.Dispatch2D(g_SceneColorBuffer.GetWidth(), g_SceneColorBuffer.GetHeight()); - - Context.TransitionResource(g_LumaBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - } - } -} - -void PostEffects::CopyBackPostBuffer( ComputeContext& Context ) -{ - ScopedTimer _prof(L"Copy Post back to Scene", Context); - - if (Graphics::IsUpscalingEnabled()) - { - Context.SetRootSignature(PostEffectsRS); - Context.SetPipelineState(CopyBackPostBufferCS); - Context.TransitionResource(g_UpscaledSceneColorBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_PostEffectsBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.SetDynamicDescriptor(1, 0, g_UpscaledSceneColorBuffer.GetUAV()); - Context.SetDynamicDescriptor(2, 0, g_PostEffectsBuffer.GetSRV()); - Context.Dispatch2D(g_UpscaledSceneColorBuffer.GetWidth(), g_UpscaledSceneColorBuffer.GetHeight()); - } - else - { - Context.SetRootSignature(PostEffectsRS); - Context.SetPipelineState(CopyBackPostBufferCS); - Context.TransitionResource(g_SceneColorBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_PostEffectsBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.SetDynamicDescriptor(1, 0, g_SceneColorBuffer.GetUAV()); - Context.SetDynamicDescriptor(2, 0, g_PostEffectsBuffer.GetSRV()); - Context.Dispatch2D(g_SceneColorBuffer.GetWidth(), g_SceneColorBuffer.GetHeight()); - } -} - -void PostEffects::Render( void ) -{ - ComputeContext& Context = ComputeContext::Begin(L"Post Effects"); - - Context.SetRootSignature(PostEffectsRS); - - if (Graphics::IsUpscalingEnabled()) - { - Context.TransitionResource(g_UpscaledSceneColorBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - } - else - { - Context.TransitionResource(g_SceneColorBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - } - - if (EnableHDR && !SSAO::DebugDraw && !(DepthOfField::Enable && DepthOfField::DebugMode >= 3)) - ProcessHDR(Context); - else - ProcessLDR(Context); - - bool bGeneratedLumaBuffer = EnableHDR || FXAA::DebugDraw || BloomEnable; - if (FXAA::Enable) - FXAA::Render(Context, bGeneratedLumaBuffer); - - // In the case where we've been doing post processing in a separate buffer, we need to copy it - // back to the original buffer. It is possible to skip this step if the next shader knows to - // do the manual format decode from UINT, but there are several code paths that need to be - // changed, and some of them rely on texture filtering, which won't work with UINT. Since this - // is only to support legacy hardware and a single buffer copy isn't that big of a deal, this - // is the most economical solution. - if (!g_bTypedUAVLoadSupport_R11G11B10_FLOAT) - CopyBackPostBuffer(Context); - - if (DrawHistogram) - { - ScopedTimer _prof(L"Draw Debug Histogram", Context); - - if (Graphics::IsUpscalingEnabled()) - { - Context.SetRootSignature(PostEffectsRS); - Context.SetPipelineState(DrawHistogramCS); - Context.InsertUAVBarrier(g_UpscaledSceneColorBuffer); - Context.TransitionResource(g_Histogram, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_Exposure, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.SetDynamicDescriptor(1, 0, g_UpscaledSceneColorBuffer.GetUAV()); - D3D12_CPU_DESCRIPTOR_HANDLE SRVs[2] = { g_Histogram.GetSRV(), g_Exposure.GetSRV() }; - Context.SetDynamicDescriptors(2, 0, 2, SRVs); - Context.Dispatch(1, 32); - Context.TransitionResource(g_UpscaledSceneColorBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - } - else - { - Context.SetRootSignature(PostEffectsRS); - Context.SetPipelineState(DrawHistogramCS); - Context.InsertUAVBarrier(g_SceneColorBuffer); - Context.TransitionResource(g_Histogram, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_Exposure, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.SetDynamicDescriptor(1, 0, g_SceneColorBuffer.GetUAV()); - D3D12_CPU_DESCRIPTOR_HANDLE SRVs[2] = { g_Histogram.GetSRV(), g_Exposure.GetSRV() }; - Context.SetDynamicDescriptors(2, 0, 2, SRVs); - Context.Dispatch(1, 32); - Context.TransitionResource(g_SceneColorBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - } - } - - Context.Finish(); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/PostEffects.h b/xess/samples/xess_demo/MiniEngine/Core/PostEffects.h deleted file mode 100644 index 222cb03..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/PostEffects.h +++ /dev/null @@ -1,46 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "pch.h" -#include "EngineTuning.h" - -class ComputeContext; - -namespace PostEffects -{ - extern BoolVar EnableHDR; // Turn on tone mapping features - - // Tone mapping parameters - extern ExpVar Exposure; // Brightness scaler when adapative exposure is disabled - extern BoolVar EnableAdaptation; // Automatically adjust brightness based on perceived luminance - - // Adapation parameters - extern ExpVar MinExposure; - extern ExpVar MaxExposure; - extern NumVar TargetLuminance; - extern NumVar AdaptationRate; - - // Bloom parameters - extern BoolVar BloomEnable; - extern NumVar BloomThreshold; - extern NumVar BloomStrength; - - void Initialize( void ); - void Shutdown( void ); - void Render( void ); - - // Copy the contents of the post effects buffer onto the main scene buffer - void CopyBackPostBuffer( ComputeContext& Context ); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/ReadbackBuffer.cpp b/xess/samples/xess_demo/MiniEngine/Core/ReadbackBuffer.cpp deleted file mode 100644 index c23c35b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/ReadbackBuffer.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "ReadbackBuffer.h" -#include "GraphicsCore.h" - -using namespace Graphics; - -void ReadbackBuffer::Create( const std::wstring& name, uint32_t NumElements, uint32_t ElementSize ) -{ - Destroy(); - - m_ElementCount = NumElements; - m_ElementSize = ElementSize; - m_BufferSize = NumElements * ElementSize; - m_UsageState = D3D12_RESOURCE_STATE_COPY_DEST; - - // Create a readback buffer large enough to hold all texel data - D3D12_HEAP_PROPERTIES HeapProps; - HeapProps.Type = D3D12_HEAP_TYPE_READBACK; - HeapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; - HeapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; - HeapProps.CreationNodeMask = 1; - HeapProps.VisibleNodeMask = 1; - - // Readback buffers must be 1-dimensional, i.e. "buffer" not "texture2d" - D3D12_RESOURCE_DESC ResourceDesc = {}; - ResourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; - ResourceDesc.Width = m_BufferSize; - ResourceDesc.Height = 1; - ResourceDesc.DepthOrArraySize = 1; - ResourceDesc.MipLevels = 1; - ResourceDesc.Format = DXGI_FORMAT_UNKNOWN; - ResourceDesc.SampleDesc.Count = 1; - ResourceDesc.SampleDesc.Quality = 0; - ResourceDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; - ResourceDesc.Flags = D3D12_RESOURCE_FLAG_NONE; - - ASSERT_SUCCEEDED( g_Device->CreateCommittedResource(&HeapProps, D3D12_HEAP_FLAG_NONE, &ResourceDesc, - D3D12_RESOURCE_STATE_COPY_DEST, nullptr, MY_IID_PPV_ARGS(&m_pResource)) ); - - m_GpuVirtualAddress = m_pResource->GetGPUVirtualAddress(); - -#ifdef RELEASE - (name); -#else - m_pResource->SetName(name.c_str()); -#endif -} - - -void* ReadbackBuffer::Map(void) -{ - void* Memory; - m_pResource->Map(0, &CD3DX12_RANGE(0, m_BufferSize), &Memory); - return Memory; -} - -void ReadbackBuffer::Unmap(void) -{ - m_pResource->Unmap(0, &CD3DX12_RANGE(0, 0)); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/ReadbackBuffer.h b/xess/samples/xess_demo/MiniEngine/Core/ReadbackBuffer.h deleted file mode 100644 index 81f3aa6..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/ReadbackBuffer.h +++ /dev/null @@ -1,32 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "GpuBuffer.h" - -class ReadbackBuffer : public GpuBuffer -{ -public: - virtual ~ReadbackBuffer() { Destroy(); } - - void Create( const std::wstring& name, uint32_t NumElements, uint32_t ElementSize ); - - void* Map(void); - void Unmap(void); - -protected: - - void CreateDerivedViews(void) {} - -}; diff --git a/xess/samples/xess_demo/MiniEngine/Core/RootSignature.cpp b/xess/samples/xess_demo/MiniEngine/Core/RootSignature.cpp deleted file mode 100644 index d9160da..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/RootSignature.cpp +++ /dev/null @@ -1,174 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "RootSignature.h" -#include "GraphicsCore.h" -#include "Hash.h" -#include -#include -#include - -using namespace Graphics; -using namespace std; -using Microsoft::WRL::ComPtr; - -static std::map< size_t, ComPtr > s_RootSignatureHashMap; - -void RootSignature::DestroyAll(void) -{ - s_RootSignatureHashMap.clear(); -} - -void RootSignature::InitStaticSampler( - UINT Register, - const D3D12_SAMPLER_DESC& NonStaticSamplerDesc, - D3D12_SHADER_VISIBILITY Visibility ) -{ - ASSERT(m_NumInitializedStaticSamplers < m_NumSamplers); - D3D12_STATIC_SAMPLER_DESC& StaticSamplerDesc = m_SamplerArray[m_NumInitializedStaticSamplers++]; - - StaticSamplerDesc.Filter = NonStaticSamplerDesc.Filter; - StaticSamplerDesc.AddressU = NonStaticSamplerDesc.AddressU; - StaticSamplerDesc.AddressV = NonStaticSamplerDesc.AddressV; - StaticSamplerDesc.AddressW = NonStaticSamplerDesc.AddressW; - StaticSamplerDesc.MipLODBias = NonStaticSamplerDesc.MipLODBias; - StaticSamplerDesc.MaxAnisotropy = NonStaticSamplerDesc.MaxAnisotropy; - StaticSamplerDesc.ComparisonFunc = NonStaticSamplerDesc.ComparisonFunc; - StaticSamplerDesc.BorderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE; - StaticSamplerDesc.MinLOD = NonStaticSamplerDesc.MinLOD; - StaticSamplerDesc.MaxLOD = NonStaticSamplerDesc.MaxLOD; - StaticSamplerDesc.ShaderRegister = Register; - StaticSamplerDesc.RegisterSpace = 0; - StaticSamplerDesc.ShaderVisibility = Visibility; - - if (StaticSamplerDesc.AddressU == D3D12_TEXTURE_ADDRESS_MODE_BORDER || - StaticSamplerDesc.AddressV == D3D12_TEXTURE_ADDRESS_MODE_BORDER || - StaticSamplerDesc.AddressW == D3D12_TEXTURE_ADDRESS_MODE_BORDER) - { - WARN_ONCE_IF_NOT( - // Transparent Black - NonStaticSamplerDesc.BorderColor[0] == 0.0f && - NonStaticSamplerDesc.BorderColor[1] == 0.0f && - NonStaticSamplerDesc.BorderColor[2] == 0.0f && - NonStaticSamplerDesc.BorderColor[3] == 0.0f || - // Opaque Black - NonStaticSamplerDesc.BorderColor[0] == 0.0f && - NonStaticSamplerDesc.BorderColor[1] == 0.0f && - NonStaticSamplerDesc.BorderColor[2] == 0.0f && - NonStaticSamplerDesc.BorderColor[3] == 1.0f || - // Opaque White - NonStaticSamplerDesc.BorderColor[0] == 1.0f && - NonStaticSamplerDesc.BorderColor[1] == 1.0f && - NonStaticSamplerDesc.BorderColor[2] == 1.0f && - NonStaticSamplerDesc.BorderColor[3] == 1.0f, - "Sampler border color does not match static sampler limitations"); - - if (NonStaticSamplerDesc.BorderColor[3] == 1.0f) - { - if (NonStaticSamplerDesc.BorderColor[0] == 1.0f) - StaticSamplerDesc.BorderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE; - else - StaticSamplerDesc.BorderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_BLACK; - } - else - StaticSamplerDesc.BorderColor = D3D12_STATIC_BORDER_COLOR_TRANSPARENT_BLACK; - } -} - -void RootSignature::Finalize(const std::wstring& name, D3D12_ROOT_SIGNATURE_FLAGS Flags) -{ - if (m_Finalized) - return; - - ASSERT(m_NumInitializedStaticSamplers == m_NumSamplers); - - D3D12_ROOT_SIGNATURE_DESC RootDesc; - RootDesc.NumParameters = m_NumParameters; - RootDesc.pParameters = (const D3D12_ROOT_PARAMETER*)m_ParamArray.get(); - RootDesc.NumStaticSamplers = m_NumSamplers; - RootDesc.pStaticSamplers = (const D3D12_STATIC_SAMPLER_DESC*)m_SamplerArray.get(); - RootDesc.Flags = Flags; - - m_DescriptorTableBitMap = 0; - m_SamplerTableBitMap = 0; - - size_t HashCode = Utility::HashState(&RootDesc.Flags); - HashCode = Utility::HashState( RootDesc.pStaticSamplers, m_NumSamplers, HashCode ); - - for (UINT Param = 0; Param < m_NumParameters; ++Param) - { - const D3D12_ROOT_PARAMETER& RootParam = RootDesc.pParameters[Param]; - m_DescriptorTableSize[Param] = 0; - - if (RootParam.ParameterType == D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE) - { - ASSERT(RootParam.DescriptorTable.pDescriptorRanges != nullptr); - - HashCode = Utility::HashState( RootParam.DescriptorTable.pDescriptorRanges, - RootParam.DescriptorTable.NumDescriptorRanges, HashCode ); - - // We keep track of sampler descriptor tables separately from CBV_SRV_UAV descriptor tables - if (RootParam.DescriptorTable.pDescriptorRanges->RangeType == D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER) - m_SamplerTableBitMap |= (1 << Param); - else - m_DescriptorTableBitMap |= (1 << Param); - - for (UINT TableRange = 0; TableRange < RootParam.DescriptorTable.NumDescriptorRanges; ++TableRange) - m_DescriptorTableSize[Param] += RootParam.DescriptorTable.pDescriptorRanges[TableRange].NumDescriptors; - } - else - HashCode = Utility::HashState( &RootParam, 1, HashCode ); - } - - ID3D12RootSignature** RSRef = nullptr; - bool firstCompile = false; - { - static mutex s_HashMapMutex; - lock_guard CS(s_HashMapMutex); - auto iter = s_RootSignatureHashMap.find(HashCode); - - // Reserve space so the next inquiry will find that someone got here first. - if (iter == s_RootSignatureHashMap.end()) - { - RSRef = s_RootSignatureHashMap[HashCode].GetAddressOf(); - firstCompile = true; - } - else - RSRef = iter->second.GetAddressOf(); - } - - if (firstCompile) - { - ComPtr pOutBlob, pErrorBlob; - - ASSERT_SUCCEEDED( D3D12SerializeRootSignature(&RootDesc, D3D_ROOT_SIGNATURE_VERSION_1, - pOutBlob.GetAddressOf(), pErrorBlob.GetAddressOf())); - - ASSERT_SUCCEEDED( g_Device->CreateRootSignature(1, pOutBlob->GetBufferPointer(), pOutBlob->GetBufferSize(), - MY_IID_PPV_ARGS(&m_Signature)) ); - - m_Signature->SetName(name.c_str()); - - s_RootSignatureHashMap[HashCode].Attach(m_Signature); - ASSERT(*RSRef == m_Signature); - } - else - { - while (*RSRef == nullptr) - this_thread::yield(); - m_Signature = *RSRef; - } - - m_Finalized = TRUE; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/RootSignature.h b/xess/samples/xess_demo/MiniEngine/Core/RootSignature.h deleted file mode 100644 index 61f456b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/RootSignature.h +++ /dev/null @@ -1,177 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "pch.h" - -class DescriptorCache; - -class RootParameter -{ - friend class RootSignature; -public: - - RootParameter() - { - m_RootParam.ParameterType = (D3D12_ROOT_PARAMETER_TYPE)0xFFFFFFFF; - } - - ~RootParameter() - { - Clear(); - } - - void Clear() - { - if (m_RootParam.ParameterType == D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE) - delete [] m_RootParam.DescriptorTable.pDescriptorRanges; - - m_RootParam.ParameterType = (D3D12_ROOT_PARAMETER_TYPE)0xFFFFFFFF; - } - - void InitAsConstants( UINT Register, UINT NumDwords, D3D12_SHADER_VISIBILITY Visibility = D3D12_SHADER_VISIBILITY_ALL, UINT Space = 0 ) - { - m_RootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS; - m_RootParam.ShaderVisibility = Visibility; - m_RootParam.Constants.Num32BitValues = NumDwords; - m_RootParam.Constants.ShaderRegister = Register; - m_RootParam.Constants.RegisterSpace = Space; - } - - void InitAsConstantBuffer( UINT Register, D3D12_SHADER_VISIBILITY Visibility = D3D12_SHADER_VISIBILITY_ALL, UINT Space = 0 ) - { - m_RootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; - m_RootParam.ShaderVisibility = Visibility; - m_RootParam.Descriptor.ShaderRegister = Register; - m_RootParam.Descriptor.RegisterSpace = Space; - } - - void InitAsBufferSRV( UINT Register, D3D12_SHADER_VISIBILITY Visibility = D3D12_SHADER_VISIBILITY_ALL, UINT Space = 0 ) - { - m_RootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_SRV; - m_RootParam.ShaderVisibility = Visibility; - m_RootParam.Descriptor.ShaderRegister = Register; - m_RootParam.Descriptor.RegisterSpace = Space; - } - - void InitAsBufferUAV( UINT Register, D3D12_SHADER_VISIBILITY Visibility = D3D12_SHADER_VISIBILITY_ALL, UINT Space = 0 ) - { - m_RootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_UAV; - m_RootParam.ShaderVisibility = Visibility; - m_RootParam.Descriptor.ShaderRegister = Register; - m_RootParam.Descriptor.RegisterSpace = Space; - } - - void InitAsDescriptorRange( D3D12_DESCRIPTOR_RANGE_TYPE Type, UINT Register, UINT Count, D3D12_SHADER_VISIBILITY Visibility = D3D12_SHADER_VISIBILITY_ALL, UINT Space = 0 ) - { - InitAsDescriptorTable(1, Visibility); - SetTableRange(0, Type, Register, Count, Space); - } - - void InitAsDescriptorTable( UINT RangeCount, D3D12_SHADER_VISIBILITY Visibility = D3D12_SHADER_VISIBILITY_ALL ) - { - m_RootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; - m_RootParam.ShaderVisibility = Visibility; - m_RootParam.DescriptorTable.NumDescriptorRanges = RangeCount; - m_RootParam.DescriptorTable.pDescriptorRanges = new D3D12_DESCRIPTOR_RANGE[RangeCount]; - } - - void SetTableRange( UINT RangeIndex, D3D12_DESCRIPTOR_RANGE_TYPE Type, UINT Register, UINT Count, UINT Space = 0 ) - { - D3D12_DESCRIPTOR_RANGE* range = const_cast(m_RootParam.DescriptorTable.pDescriptorRanges + RangeIndex); - range->RangeType = Type; - range->NumDescriptors = Count; - range->BaseShaderRegister = Register; - range->RegisterSpace = Space; - range->OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND; - } - - const D3D12_ROOT_PARAMETER& operator() ( void ) const { return m_RootParam; } - - -protected: - - D3D12_ROOT_PARAMETER m_RootParam; -}; - -// Maximum 64 DWORDS divied up amongst all root parameters. -// Root constants = 1 DWORD * NumConstants -// Root descriptor (CBV, SRV, or UAV) = 2 DWORDs each -// Descriptor table pointer = 1 DWORD -// Static samplers = 0 DWORDS (compiled into shader) -class RootSignature -{ - friend class DynamicDescriptorHeap; - -public: - - RootSignature( UINT NumRootParams = 0, UINT NumStaticSamplers = 0 ) : m_Finalized(FALSE), m_NumParameters(NumRootParams) - { - Reset(NumRootParams, NumStaticSamplers); - } - - ~RootSignature() - { - } - - static void DestroyAll(void); - - void Reset( UINT NumRootParams, UINT NumStaticSamplers = 0 ) - { - if (NumRootParams > 0) - m_ParamArray.reset(new RootParameter[NumRootParams]); - else - m_ParamArray = nullptr; - m_NumParameters = NumRootParams; - - if (NumStaticSamplers > 0) - m_SamplerArray.reset(new D3D12_STATIC_SAMPLER_DESC[NumStaticSamplers]); - else - m_SamplerArray = nullptr; - m_NumSamplers = NumStaticSamplers; - m_NumInitializedStaticSamplers = 0; - } - - RootParameter& operator[] ( size_t EntryIndex ) - { - ASSERT(EntryIndex < m_NumParameters); - return m_ParamArray.get()[EntryIndex]; - } - - const RootParameter& operator[] ( size_t EntryIndex ) const - { - ASSERT(EntryIndex < m_NumParameters); - return m_ParamArray.get()[EntryIndex]; - } - - void InitStaticSampler( UINT Register, const D3D12_SAMPLER_DESC& NonStaticSamplerDesc, - D3D12_SHADER_VISIBILITY Visibility = D3D12_SHADER_VISIBILITY_ALL ); - - void Finalize(const std::wstring& name, D3D12_ROOT_SIGNATURE_FLAGS Flags = D3D12_ROOT_SIGNATURE_FLAG_NONE); - - ID3D12RootSignature* GetSignature() const { return m_Signature; } - -protected: - - BOOL m_Finalized; - UINT m_NumParameters; - UINT m_NumSamplers; - UINT m_NumInitializedStaticSamplers; - uint32_t m_DescriptorTableBitMap; // One bit is set for root parameters that are non-sampler descriptor tables - uint32_t m_SamplerTableBitMap; // One bit is set for root parameters that are sampler descriptor tables - uint32_t m_DescriptorTableSize[16]; // Non-sampler descriptor tables need to know their descriptor count - std::unique_ptr m_ParamArray; - std::unique_ptr m_SamplerArray; - ID3D12RootSignature* m_Signature; -}; diff --git a/xess/samples/xess_demo/MiniEngine/Core/SSAO.cpp b/xess/samples/xess_demo/MiniEngine/Core/SSAO.cpp deleted file mode 100644 index d0436d3..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/SSAO.cpp +++ /dev/null @@ -1,541 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "SSAO.h" -#include "BufferManager.h" -#include "GraphicsCore.h" -#include "CommandContext.h" -#include "Camera.h" -#include "TemporalEffects.h" - -#include "CompiledShaders/AoPrepareDepthBuffers1CS.h" -#include "CompiledShaders/AoPrepareDepthBuffers2CS.h" -#include "CompiledShaders/LinearizeDepthCS.h" -#include "CompiledShaders/DebugSSAOCS.h" -#include "CompiledShaders/AoRender1CS.h" -#include "CompiledShaders/AoRender2CS.h" -#include "CompiledShaders/AoBlurUpsampleBlendOutCS.h" -#include "CompiledShaders/AoBlurUpsamplePreMinBlendOutCS.h" -#include "CompiledShaders/AoBlurUpsampleCS.h" -#include "CompiledShaders/AoBlurUpsamplePreMinCS.h" - -using namespace Graphics; -using namespace Math; - -namespace SSAO -{ - BoolVar Enable("Graphics/SSAO/Enable", true); - BoolVar DebugDraw("Graphics/SSAO/Debug Draw", false); - BoolVar AsyncCompute("Graphics/SSAO/Async Compute", false); - BoolVar ComputeLinearZ("Graphics/SSAO/Always Linearize Z", true); - - // High quality (and better) is barely a noticeable improvement when modulated properly with ambient light. - // However, in the debug view the quality improvement is very apparent. - const char* QualityLabels[kNumSsaoQualitySettings] = { "Very Low", "Low", "Medium", "High", "Very High" }; - EnumVar g_QualityLevel("Graphics/SSAO/Quality Level", kSsaoQualityHigh, kNumSsaoQualitySettings, QualityLabels); - - // This is necessary to filter out pixel shimmer due to bilateral upsampling with too much lost resolution. High - // frequency detail can sometimes not be reconstructed, and the noise filter fills in the missing pixels with the - // result of the higher resolution SSAO. - NumVar g_NoiseFilterTolerance("Graphics/SSAO/Noise Filter Threshold (log10)", -3.0f, -8.0f, 0.0f, 0.25f); - NumVar g_BlurTolerance("Graphics/SSAO/Blur Tolerance (log10)", -5.0f, -8.0f, -1.0f, 0.25f); - NumVar g_UpsampleTolerance("Graphics/SSAO/Upsample Tolerance (log10)", -7.0f, -12.0f, -1.0f, 0.5f); - - // Controls how aggressive to fade off samples that occlude spheres but by so much as to be unreliable. - // This is what gives objects a dark halo around them when placed in front of a wall. If you want to - // fade off the halo, boost your rejection falloff. The tradeoff is that it reduces overall AO. - NumVar RejectionFalloff("Graphics/SSAO/Rejection Falloff (rcp)", 2.5f, 1.0f, 10.0f, 0.5f); - - // The effect normally marks anything that's 50% occluded or less as "fully unoccluded". This throws away - // half of our result. Accentuation gives more range to the effect, but it will darken all AO values in the - // process. It will also cause "under occluded" geometry to appear to be highlighted. If your ambient light - // is determined by the surface normal (such as with IBL), you might not want this side effect. - NumVar Accentuation("Graphics/SSAO/Accentuation", 0.1f, 0.0f, 1.0f, 0.1f); - - IntVar HierarchyDepth("Graphics/SSAO/Hierarchy Depth", 3, 1, 4); - - void LinearizeZ(ComputeContext& Context, DepthBuffer& Depth, ColorBuffer& LinearDepth, float zMagic); -} - -namespace -{ - RootSignature s_RootSignature; - ComputePSO s_DepthPrepare1CS(L"SSAO: Depth Prepare 1 CS"); - ComputePSO s_DepthPrepare2CS(L"SSAO: Depth Prepare 2 CS"); - ComputePSO s_Render1CS(L"SSAO: Render 1 CS"); - ComputePSO s_Render2CS(L"SSAO: Render 2 CS"); - ComputePSO s_BlurUpsampleBlend[2] = { { L"SSAO: Blur Upsample Blend Low Q. CS" }, { L"SSAO: Blur Upsample Blend High Q. CS" } }; // Blend the upsampled result with the next higher resolution - ComputePSO s_BlurUpsampleFinal[2] = { { L"SSAO: Blur Upsample Final Low Q. CS" }, { L"SSAO: Blur Upsample Final High Q. CS" } }; // Don't blend the result, just upsample it - ComputePSO s_LinearizeDepthCS(L"SSAO: Linearize Depth CS"); - ComputePSO s_DebugSSAOCS(L"SSAO: Debug CS"); - - float SampleThickness[12]; // Pre-computed sample thicknesses -} - -void SSAO::Initialize( void ) -{ - s_RootSignature.Reset(5, 2); - s_RootSignature.InitStaticSampler(0, SamplerLinearClampDesc); - s_RootSignature.InitStaticSampler(1, SamplerLinearBorderDesc); - s_RootSignature[0].InitAsConstants(0, 4); - s_RootSignature[1].InitAsConstantBuffer(1); - s_RootSignature[2].InitAsDescriptorRange(D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 0, 5); - s_RootSignature[3].InitAsDescriptorRange(D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 5); - s_RootSignature[4].InitAsBufferSRV(5); - s_RootSignature.Finalize(L"SSAO"); - -#define CreatePSO( ObjName, ShaderByteCode ) \ - ObjName.SetRootSignature(s_RootSignature); \ - ObjName.SetComputeShader(ShaderByteCode, sizeof(ShaderByteCode) ); \ - ObjName.Finalize(); - - CreatePSO( s_DepthPrepare1CS, g_pAoPrepareDepthBuffers1CS ); - CreatePSO( s_DepthPrepare2CS, g_pAoPrepareDepthBuffers2CS ); - CreatePSO( s_LinearizeDepthCS, g_pLinearizeDepthCS ); - CreatePSO( s_DebugSSAOCS, g_pDebugSSAOCS ); - CreatePSO( s_Render1CS, g_pAoRender1CS ); - CreatePSO( s_Render2CS, g_pAoRender2CS ); - - CreatePSO( s_BlurUpsampleBlend[0], g_pAoBlurUpsampleBlendOutCS ); - CreatePSO( s_BlurUpsampleBlend[1], g_pAoBlurUpsamplePreMinBlendOutCS ); - CreatePSO( s_BlurUpsampleFinal[0], g_pAoBlurUpsampleCS ); - CreatePSO( s_BlurUpsampleFinal[1], g_pAoBlurUpsamplePreMinCS ); - - SampleThickness[ 0] = sqrtf(1.0f - 0.2f * 0.2f); - SampleThickness[ 1] = sqrtf(1.0f - 0.4f * 0.4f); - SampleThickness[ 2] = sqrtf(1.0f - 0.6f * 0.6f); - SampleThickness[ 3] = sqrtf(1.0f - 0.8f * 0.8f); - SampleThickness[ 4] = sqrtf(1.0f - 0.2f * 0.2f - 0.2f * 0.2f); - SampleThickness[ 5] = sqrtf(1.0f - 0.2f * 0.2f - 0.4f * 0.4f); - SampleThickness[ 6] = sqrtf(1.0f - 0.2f * 0.2f - 0.6f * 0.6f); - SampleThickness[ 7] = sqrtf(1.0f - 0.2f * 0.2f - 0.8f * 0.8f); - SampleThickness[ 8] = sqrtf(1.0f - 0.4f * 0.4f - 0.4f * 0.4f); - SampleThickness[ 9] = sqrtf(1.0f - 0.4f * 0.4f - 0.6f * 0.6f); - SampleThickness[10] = sqrtf(1.0f - 0.4f * 0.4f - 0.8f * 0.8f); - SampleThickness[11] = sqrtf(1.0f - 0.6f * 0.6f - 0.6f * 0.6f); -} - -void SSAO::Shutdown(void) -{ -} - -namespace SSAO -{ - void ComputeAO( ComputeContext& Context, ColorBuffer& Destination, ColorBuffer& DepthBuffer, const float TanHalfFovH ) - { - size_t BufferWidth = DepthBuffer.GetWidth(); - size_t BufferHeight = DepthBuffer.GetHeight(); - size_t ArrayCount = DepthBuffer.GetDepth(); - - // Here we compute multipliers that convert the center depth value into (the reciprocal of) - // sphere thicknesses at each sample location. This assumes a maximum sample radius of 5 - // units, but since a sphere has no thickness at its extent, we don't need to sample that far - // out. Only samples whole integer offsets with distance less than 25 are used. This means - // that there is no sample at (3, 4) because its distance is exactly 25 (and has a thickness of 0.) - - // The shaders are set up to sample a circular region within a 5-pixel radius. - const float ScreenspaceDiameter = 10.0f; - - // SphereDiameter = CenterDepth * ThicknessMultiplier. This will compute the thickness of a sphere centered - // at a specific depth. The ellipsoid scale can stretch a sphere into an ellipsoid, which changes the - // characteristics of the AO. - // TanHalfFovH: Radius of sphere in depth units if its center lies at Z = 1 - // ScreenspaceDiameter: Diameter of sample sphere in pixel units - // ScreenspaceDiameter / BufferWidth: Ratio of the screen width that the sphere actually covers - // Note about the "2.0f * ": Diameter = 2 * Radius - float ThicknessMultiplier = 2.0f * TanHalfFovH * ScreenspaceDiameter / BufferWidth; - - if (ArrayCount == 1) - ThicknessMultiplier *= 2.0f; - - // This will transform a depth value from [0, thickness] to [0, 1]. - float InverseRangeFactor = 1.0f / ThicknessMultiplier; - - __declspec(align(16)) float SsaoCB[28]; - - // The thicknesses are smaller for all off-center samples of the sphere. Compute thicknesses relative - // to the center sample. - SsaoCB[ 0] = InverseRangeFactor / SampleThickness[ 0]; - SsaoCB[ 1] = InverseRangeFactor / SampleThickness[ 1]; - SsaoCB[ 2] = InverseRangeFactor / SampleThickness[ 2]; - SsaoCB[ 3] = InverseRangeFactor / SampleThickness[ 3]; - SsaoCB[ 4] = InverseRangeFactor / SampleThickness[ 4]; - SsaoCB[ 5] = InverseRangeFactor / SampleThickness[ 5]; - SsaoCB[ 6] = InverseRangeFactor / SampleThickness[ 6]; - SsaoCB[ 7] = InverseRangeFactor / SampleThickness[ 7]; - SsaoCB[ 8] = InverseRangeFactor / SampleThickness[ 8]; - SsaoCB[ 9] = InverseRangeFactor / SampleThickness[ 9]; - SsaoCB[10] = InverseRangeFactor / SampleThickness[10]; - SsaoCB[11] = InverseRangeFactor / SampleThickness[11]; - - // These are the weights that are multiplied against the samples because not all samples are - // equally important. The farther the sample is from the center location, the less they matter. - // We use the thickness of the sphere to determine the weight. The scalars in front are the number - // of samples with this weight because we sum the samples together before multiplying by the weight, - // so as an aggregate all of those samples matter more. After generating this table, the weights - // are normalized. - SsaoCB[12] = 4.0f * SampleThickness[ 0]; // Axial - SsaoCB[13] = 4.0f * SampleThickness[ 1]; // Axial - SsaoCB[14] = 4.0f * SampleThickness[ 2]; // Axial - SsaoCB[15] = 4.0f * SampleThickness[ 3]; // Axial - SsaoCB[16] = 4.0f * SampleThickness[ 4]; // Diagonal - SsaoCB[17] = 8.0f * SampleThickness[ 5]; // L-shaped - SsaoCB[18] = 8.0f * SampleThickness[ 6]; // L-shaped - SsaoCB[19] = 8.0f * SampleThickness[ 7]; // L-shaped - SsaoCB[20] = 4.0f * SampleThickness[ 8]; // Diagonal - SsaoCB[21] = 8.0f * SampleThickness[ 9]; // L-shaped - SsaoCB[22] = 8.0f * SampleThickness[10]; // L-shaped - SsaoCB[23] = 4.0f * SampleThickness[11]; // Diagonal - -//#define SAMPLE_EXHAUSTIVELY - - // If we aren't using all of the samples, delete their weights before we normalize. - #ifndef SAMPLE_EXHAUSTIVELY - SsaoCB[12] = 0.0f; - SsaoCB[14] = 0.0f; - SsaoCB[17] = 0.0f; - SsaoCB[19] = 0.0f; - SsaoCB[21] = 0.0f; - #endif - - // Normalize the weights by dividing by the sum of all weights - float totalWeight = 0.0f; - for (int i = 12; i < 24; ++i) - totalWeight += SsaoCB[i]; - for (int i = 12; i < 24; ++i) - SsaoCB[i] /= totalWeight; - - SsaoCB[24] = 1.0f / BufferWidth; - SsaoCB[25] = 1.0f / BufferHeight; - SsaoCB[26] = 1.0f / -RejectionFalloff; - SsaoCB[27] = 1.0f / (1.0f + Accentuation); - - Context.SetDynamicConstantBufferView(1, sizeof(SsaoCB), SsaoCB); - Context.SetDynamicDescriptor(2, 0, Destination.GetUAV()); - Context.SetDynamicDescriptor(3, 0, DepthBuffer.GetSRV() ); - - if (ArrayCount == 1) - Context.Dispatch2D(BufferWidth, BufferHeight, 16, 16); - else - Context.Dispatch3D(BufferWidth, BufferHeight, ArrayCount, 8, 8, 1); - } - - void BlurAndUpsample( ComputeContext& Context, - ColorBuffer& Destination, ColorBuffer& HiResDepth, ColorBuffer& LoResDepth, - ColorBuffer* InterleavedAO, ColorBuffer* HighQualityAO, ColorBuffer* HiResAO - ) - { - size_t LoWidth = LoResDepth.GetWidth(); - size_t LoHeight = LoResDepth.GetHeight(); - size_t HiWidth = HiResDepth.GetWidth(); - size_t HiHeight = HiResDepth.GetHeight(); - - ComputePSO* shader = nullptr; - if (HiResAO == nullptr) - { - shader = &s_BlurUpsampleFinal[HighQualityAO == nullptr ? 0 : 1]; - } - else - { - shader = &s_BlurUpsampleBlend[HighQualityAO == nullptr ? 0 : 1]; - } - Context.SetPipelineState(*shader); - - float kBlurTolerance = 1.0f - powf(10.0f, g_BlurTolerance) * 1920.0f / (float)LoWidth; - kBlurTolerance *= kBlurTolerance; - float kUpsampleTolerance = powf(10.0f, g_UpsampleTolerance); - float kNoiseFilterWeight = 1.0f / (powf(10.0f, g_NoiseFilterTolerance) + kUpsampleTolerance); - - __declspec(align(16)) float cbData[] = { - 1.0f / LoWidth, 1.0f / LoHeight, 1.0f / HiWidth, 1.0f / HiHeight, - kNoiseFilterWeight, 1920.0f / (float)LoWidth, kBlurTolerance, kUpsampleTolerance - }; - Context.SetDynamicConstantBufferView(1, sizeof(cbData), cbData); - - Context.TransitionResource(Destination, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(LoResDepth, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(HiResDepth, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.SetDynamicDescriptor(2, 0, Destination.GetUAV()); - Context.SetDynamicDescriptor(3, 0, LoResDepth.GetSRV()); - Context.SetDynamicDescriptor(3, 1, HiResDepth.GetSRV()); - if (InterleavedAO != nullptr) - { - Context.TransitionResource(*InterleavedAO, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.SetDynamicDescriptor(3, 2, InterleavedAO->GetSRV()); - } - if (HighQualityAO != nullptr) - { - Context.TransitionResource(*HighQualityAO, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.SetDynamicDescriptor(3, 3, HighQualityAO->GetSRV()); - } - if (HiResAO != nullptr) - { - Context.TransitionResource(*HiResAO, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.SetDynamicDescriptor(3, 4, HiResAO->GetSRV()); - } - - Context.Dispatch2D(HiWidth+2, HiHeight+2, 16, 16); - } -} - -void SSAO::LinearizeZ(ComputeContext& Context, const Camera& camera, uint32_t FrameIndex) -{ - DepthBuffer& Depth = g_SceneDepthBuffer; - ColorBuffer& LinearDepth = g_LinearDepth[FrameIndex]; - const float NearClipDist = camera.GetNearClip(); - const float FarClipDist = camera.GetFarClip(); - const float zMagic = (FarClipDist - NearClipDist) / NearClipDist; - - LinearizeZ(Context, Depth, LinearDepth, zMagic); -} - -void SSAO::LinearizeZ(ComputeContext& Context, DepthBuffer& Depth, ColorBuffer& LinearDepth, float zMagic) -{ - Context.SetRootSignature(s_RootSignature); - Context.TransitionResource(Depth, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.SetConstants(0, zMagic); - Context.SetDynamicDescriptor(3, 0, Depth.GetDepthSRV()); - Context.TransitionResource(LinearDepth, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.SetDynamicDescriptors(2, 0, 1, &LinearDepth.GetUAV()); - Context.SetPipelineState(s_LinearizeDepthCS); - Context.Dispatch2D(LinearDepth.GetWidth(), LinearDepth.GetHeight(), 16, 16); -} - -void SSAO::Render( GraphicsContext& GfxContext, const Camera& camera ) -{ - const float* pProjMat = reinterpret_cast(&camera.GetProjMatrix()); - Render(GfxContext, pProjMat, camera.GetNearClip(), camera.GetFarClip() ); -} - -void SSAO::Render( GraphicsContext& GfxContext, const float* ProjMat, float NearClipDist, float FarClipDist ) -{ - uint32_t FrameIndex = TemporalEffects::GetFrameIndexMod2(); - - DepthBuffer& Depth = g_SceneDepthBuffer; - ColorBuffer& LinearDepth = g_LinearDepth[ FrameIndex ]; - - const float zMagic = (FarClipDist - NearClipDist) / NearClipDist; - - if (!Enable) - { - ScopedTimer _prof(L"Generate SSAO", GfxContext); - - // Clear the SSAO buffer - GfxContext.TransitionResource(g_SSAOFullScreen, D3D12_RESOURCE_STATE_RENDER_TARGET, true); - GfxContext.ClearColor(g_SSAOFullScreen); - GfxContext.TransitionResource(g_SSAOFullScreen, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - - ComputeContext& Context = GfxContext.GetComputeContext(); - - if (ComputeLinearZ) - LinearizeZ(Context, Depth, LinearDepth, zMagic); - - if (DebugDraw) - { - Context.SetRootSignature(s_RootSignature); - Context.TransitionResource(g_SceneColorBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(LinearDepth, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.SetDynamicDescriptors(2, 0, 1, &g_SceneColorBuffer.GetUAV()); - Context.SetDynamicDescriptors(3, 0, 1, &LinearDepth.GetSRV() ); - Context.SetPipelineState(s_DebugSSAOCS); - Context.Dispatch2D(g_SSAOFullScreen.GetWidth(), g_SSAOFullScreen.GetHeight()); - } - - return; - } - - GfxContext.TransitionResource(Depth, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - GfxContext.TransitionResource(g_SSAOFullScreen, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - - if (AsyncCompute) - { - // Flush the ZPrePass and wait for it on the compute queue - g_CommandManager.GetComputeQueue().StallForFence(GfxContext.Flush()); - } - else - { - EngineProfiling::BeginBlock(L"Generate SSAO", &GfxContext); - } - - ComputeContext& Context = AsyncCompute ? ComputeContext::Begin(L"Async SSAO", true) : GfxContext.GetComputeContext(); - Context.SetRootSignature(s_RootSignature); - - { ScopedTimer _prof(L"Decompress and downsample", Context); - - // Phase 1: Decompress, linearize, downsample, and deinterleave the depth buffer - Context.SetConstants(0, zMagic); - Context.SetDynamicDescriptor(3, 0, Depth.GetDepthSRV() ); - Context.TransitionResource(LinearDepth, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_DepthDownsize1, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_DepthTiled1, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_DepthDownsize2, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_DepthTiled2, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - - D3D12_CPU_DESCRIPTOR_HANDLE DownsizeUAVs[5] = { LinearDepth.GetUAV(), g_DepthDownsize1.GetUAV(), g_DepthTiled1.GetUAV(), - g_DepthDownsize2.GetUAV(), g_DepthTiled2.GetUAV() }; - Context.SetDynamicDescriptors(2, 0, 5, DownsizeUAVs); - - Context.SetPipelineState(s_DepthPrepare1CS); - Context.Dispatch2D(g_DepthTiled2.GetWidth() * 8, g_DepthTiled2.GetHeight() * 8); - - if (HierarchyDepth > 2) - { - Context.SetConstants(0, 1.0f / g_DepthDownsize2.GetWidth(), 1.0f / g_DepthDownsize2.GetHeight()); - Context.TransitionResource(g_DepthDownsize2, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_DepthDownsize3, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_DepthTiled3, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_DepthDownsize4, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_DepthTiled4, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - D3D12_CPU_DESCRIPTOR_HANDLE DownsizeAgainUAVs[4] = { g_DepthDownsize3.GetUAV(), g_DepthTiled3.GetUAV(), g_DepthDownsize4.GetUAV(), g_DepthTiled4.GetUAV() }; - Context.SetDynamicDescriptors(2, 0, 4, DownsizeAgainUAVs); - Context.SetDynamicDescriptors(3, 0, 1, &g_DepthDownsize2.GetSRV() ); - Context.SetPipelineState(s_DepthPrepare2CS); - Context.Dispatch2D(g_DepthTiled4.GetWidth() * 8, g_DepthTiled4.GetHeight() * 8); - } - - } // End decompress - { ScopedTimer _prof(L"Analyze depth volumes", Context); - - // Load first element of projection matrix which is the cotangent of the horizontal FOV divided by 2. - const float FovTangent = 1.0f / ProjMat[0]; - - Context.TransitionResource(g_AOMerged1, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_AOMerged2, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_AOMerged3, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_AOMerged4, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_AOHighQuality1, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_AOHighQuality2, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_AOHighQuality3, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_AOHighQuality4, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_DepthTiled1, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_DepthTiled2, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_DepthTiled3, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_DepthTiled4, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_DepthDownsize1, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_DepthDownsize2, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_DepthDownsize3, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_DepthDownsize4, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - - // Phase 2: Render SSAO for each sub-tile - if (HierarchyDepth > 3) - { - Context.SetPipelineState( s_Render1CS ); - ComputeAO( Context, g_AOMerged4, g_DepthTiled4, FovTangent ); - if (g_QualityLevel >= kSsaoQualityLow) - { - Context.SetPipelineState( s_Render2CS ); - ComputeAO( Context, g_AOHighQuality4, g_DepthDownsize4, FovTangent ); - } - } - if (HierarchyDepth > 2) - { - Context.SetPipelineState( s_Render1CS ); - ComputeAO( Context, g_AOMerged3, g_DepthTiled3, FovTangent ); - if (g_QualityLevel >= kSsaoQualityMedium) - { - Context.SetPipelineState( s_Render2CS ); - ComputeAO( Context, g_AOHighQuality3, g_DepthDownsize3, FovTangent ); - } - } - if (HierarchyDepth > 1) - { - Context.SetPipelineState( s_Render1CS ); - ComputeAO( Context, g_AOMerged2, g_DepthTiled2, FovTangent ); - if (g_QualityLevel >= kSsaoQualityHigh) - { - Context.SetPipelineState( s_Render2CS ); - ComputeAO( Context, g_AOHighQuality2, g_DepthDownsize2, FovTangent ); - } - } - { - Context.SetPipelineState( s_Render1CS ); - ComputeAO( Context, g_AOMerged1, g_DepthTiled1, FovTangent ); - if (g_QualityLevel >= kSsaoQualityVeryHigh) - { - Context.SetPipelineState( s_Render2CS ); - ComputeAO( Context, g_AOHighQuality1, g_DepthDownsize1, FovTangent ); - } - } - - } // End analyze - { ScopedTimer _prof(L"Blur and upsample", Context); - - // Phase 4: Iteratively blur and upsample, combining each result - - ColorBuffer* NextSRV = &g_AOMerged4; - - - // 120 x 68 -> 240 x 135 - if (HierarchyDepth > 3) - { - BlurAndUpsample( Context, g_AOSmooth3, g_DepthDownsize3, g_DepthDownsize4, NextSRV, - g_QualityLevel >= kSsaoQualityLow ? &g_AOHighQuality4 : nullptr, &g_AOMerged3 ); - - NextSRV = &g_AOSmooth3; - } - else - NextSRV = &g_AOMerged3; - - - // 240 x 135 -> 480 x 270 - if (HierarchyDepth > 2) - { - BlurAndUpsample( Context, g_AOSmooth2, g_DepthDownsize2, g_DepthDownsize3, NextSRV, - g_QualityLevel >= kSsaoQualityMedium ? &g_AOHighQuality3 : nullptr, &g_AOMerged2 ); - - NextSRV = &g_AOSmooth2; - } - else - NextSRV = &g_AOMerged2; - - // 480 x 270 -> 960 x 540 - if (HierarchyDepth > 1) - { - BlurAndUpsample( Context, g_AOSmooth1, g_DepthDownsize1, g_DepthDownsize2, NextSRV, - g_QualityLevel >= kSsaoQualityHigh ? &g_AOHighQuality2 : nullptr, &g_AOMerged1 ); - - NextSRV = &g_AOSmooth1; - } - else - NextSRV = &g_AOMerged1; - - // 960 x 540 -> 1920 x 1080 - BlurAndUpsample( Context, g_SSAOFullScreen, LinearDepth, g_DepthDownsize1, NextSRV, - g_QualityLevel >= kSsaoQualityVeryHigh ? &g_AOHighQuality1 : nullptr, nullptr ); - - } // End blur and upsample - - if (AsyncCompute) - Context.Finish(); - else - EngineProfiling::EndBlock(&GfxContext); - - if (DebugDraw) - { - if (AsyncCompute) - { - g_CommandManager.GetGraphicsQueue().StallForProducer( - g_CommandManager.GetComputeQueue()); - } - - ComputeContext& CC = GfxContext.GetComputeContext(); - CC.TransitionResource(g_SceneColorBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - CC.TransitionResource(g_SSAOFullScreen, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - CC.SetRootSignature(s_RootSignature); - CC.SetPipelineState(s_DebugSSAOCS); - CC.SetDynamicDescriptors(2, 0, 1, &g_SceneColorBuffer.GetUAV()); - CC.SetDynamicDescriptors(3, 0, 1, &g_SSAOFullScreen.GetSRV()); - CC.Dispatch2D(g_SSAOFullScreen.GetWidth(), g_SSAOFullScreen.GetHeight()); - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/SSAO.h b/xess/samples/xess_demo/MiniEngine/Core/SSAO.h deleted file mode 100644 index 1b80d52..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/SSAO.h +++ /dev/null @@ -1,36 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -namespace Math { class Camera; } -class GraphicsContext; -class ComputeContext; -class BoolVar; - -namespace SSAO -{ - void Initialize( void ); - void Shutdown( void ); - void Render(GraphicsContext& Context, const float* ProjMat, float NearClipDist, float FarClipDist ); - void Render(GraphicsContext& Context, const Math::Camera& camera ); - void LinearizeZ(ComputeContext& Context, const Math::Camera& camera, uint32_t FrameIndex); - - extern BoolVar Enable; - extern BoolVar DebugDraw; - extern BoolVar AsyncCompute; - extern BoolVar ComputeLinearZ; - extern EnumVar g_QualityLevel; - - enum QualityLevel { kSsaoQualityVeryLow, kSsaoQualityLow, kSsaoQualityMedium, kSsaoQualityHigh, kSsaoQualityVeryHigh, kNumSsaoQualitySettings }; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/SamplerManager.cpp b/xess/samples/xess_demo/MiniEngine/Core/SamplerManager.cpp deleted file mode 100644 index 29a9963..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/SamplerManager.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// Alex Nankervis -// - -#include "pch.h" -#include "SamplerManager.h" -#include "GraphicsCore.h" -#include "Hash.h" -#include - -using namespace std; -using namespace Graphics; - -namespace -{ - map< size_t, D3D12_CPU_DESCRIPTOR_HANDLE > s_SamplerCache; -} - -D3D12_CPU_DESCRIPTOR_HANDLE SamplerDesc::CreateDescriptor() -{ - size_t hashValue = Utility::HashState(this); - auto iter = s_SamplerCache.find(hashValue); - if (iter != s_SamplerCache.end()) - { - return iter->second; - } - - D3D12_CPU_DESCRIPTOR_HANDLE Handle = AllocateDescriptor(D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER); - g_Device->CreateSampler(this, Handle); - return Handle; -} - -void SamplerDesc::CreateDescriptor( D3D12_CPU_DESCRIPTOR_HANDLE Handle ) -{ - ASSERT(Handle.ptr != 0 && Handle.ptr != -1); - g_Device->CreateSampler(this, Handle); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/SamplerManager.h b/xess/samples/xess_demo/MiniEngine/Core/SamplerManager.h deleted file mode 100644 index 983707f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/SamplerManager.h +++ /dev/null @@ -1,62 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "pch.h" -#include "Color.h" - -class SamplerDesc : public D3D12_SAMPLER_DESC -{ -public: - // These defaults match the default values for HLSL-defined root - // signature static samplers. So not overriding them here means - // you can safely not define them in HLSL. - SamplerDesc() - { - Filter = D3D12_FILTER_ANISOTROPIC; - AddressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP; - AddressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP; - AddressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP; - MipLODBias = 0.0f; - MaxAnisotropy = 16; - ComparisonFunc = D3D12_COMPARISON_FUNC_LESS_EQUAL; - BorderColor[0] = 1.0f; - BorderColor[1] = 1.0f; - BorderColor[2] = 1.0f; - BorderColor[3] = 1.0f; - MinLOD = 0.0f; - MaxLOD = D3D12_FLOAT32_MAX; - } - - void SetTextureAddressMode( D3D12_TEXTURE_ADDRESS_MODE AddressMode ) - { - AddressU = AddressMode; - AddressV = AddressMode; - AddressW = AddressMode; - } - - void SetBorderColor( Color Border ) - { - BorderColor[0] = Border.R(); - BorderColor[1] = Border.G(); - BorderColor[2] = Border.B(); - BorderColor[3] = Border.A(); - } - - // Allocate new descriptor as needed; return handle to existing descriptor when possible - D3D12_CPU_DESCRIPTOR_HANDLE CreateDescriptor( void ); - - // Create descriptor in place (no deduplication). Handle must be preallocated - void CreateDescriptor( D3D12_CPU_DESCRIPTOR_HANDLE Handle ); -}; diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/AdaptExposureCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/AdaptExposureCS.hlsl deleted file mode 100644 index 392f0f4..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/AdaptExposureCS.hlsl +++ /dev/null @@ -1,95 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// -// The group size is 16x16, but one group iterates over an entire 16-wide column of pixels (384 pixels tall) -// Assuming the total workspace is 640x384, there will be 40 thread groups computing the histogram in parallel. -// The histogram measures logarithmic luminance ranging from 2^-12 up to 2^4. This should provide a nice window -// where the exposure would range from 2^-4 up to 2^4. - -#include "PostEffectsRS.hlsli" -#include "ShaderUtility.hlsli" - -ByteAddressBuffer Histogram : register(t0); -RWStructuredBuffer Exposure : register(u0); - -cbuffer cb0 : register(b1) -{ - float TargetLuminance; - float AdaptationRate; - float MinExposure; - float MaxExposure; - uint PixelCount; -} - -groupshared float gs_Accum[256]; - -[RootSignature(PostEffects_RootSig)] -[numthreads( 256, 1, 1 )] -void main( uint GI : SV_GroupIndex ) -{ - float WeightedSum = (float)GI * (float)Histogram.Load(GI * 4); - - [unroll] - for (uint i = 1; i < 256; i *= 2) - { - gs_Accum[GI] = WeightedSum; // Write - GroupMemoryBarrierWithGroupSync(); // Sync - WeightedSum += gs_Accum[(GI + i) % 256]; // Read - GroupMemoryBarrierWithGroupSync(); // Sync - } - - // If the entire image is black, don't adjust exposure - if (WeightedSum == 0.0) - return; - - float MinLog = Exposure[4]; - float MaxLog = Exposure[5]; - float LogRange = Exposure[6]; - float RcpLogRange = Exposure[7]; - - // Average histogram value is the weighted sum of all pixels divided by the total number of pixels - // minus those pixels which provided no weight (i.e. black pixels.) - float weightedHistAvg = WeightedSum / (max(1, PixelCount - Histogram.Load(0))) - 1.0; - float logAvgLuminance = exp2(weightedHistAvg / 254.0 * LogRange + MinLog); - float targetExposure = TargetLuminance / logAvgLuminance; - //float targetExposure = -log2(1 - TargetLuminance) / logAvgLuminance; - - float exposure = Exposure[0]; - exposure = lerp(exposure, targetExposure, AdaptationRate); - exposure = clamp(exposure, MinExposure, MaxExposure); - - if (GI == 0) - { - Exposure[0] = exposure; - Exposure[1] = 1.0 / exposure; - Exposure[2] = exposure; - Exposure[3] = weightedHistAvg; - - // First attempt to recenter our histogram around the log-average. - float biasToCenter = (floor(weightedHistAvg) - 128.0) / 255.0; - if (abs(biasToCenter) > 0.1) - { - MinLog += biasToCenter * RcpLogRange; - MaxLog += biasToCenter * RcpLogRange; - } - - // TODO: Increase or decrease the log range to better fit the range of values. - // (Idea) Look at intermediate log-weighted sums for under- or over-represented - // extreme bounds. I.e. break the for loop into two pieces to compute the sum of - // groups of 16, check the groups on each end, then finish the recursive summation. - - Exposure[4] = MinLog; - Exposure[5] = MaxLog; - Exposure[6] = LogRange; - Exposure[7] = 1.0 / LogRange; - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/AoBlurAndUpsampleCS.hlsli b/xess/samples/xess_demo/MiniEngine/Core/Shaders/AoBlurAndUpsampleCS.hlsli deleted file mode 100644 index 47c4cd0..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/AoBlurAndUpsampleCS.hlsli +++ /dev/null @@ -1,224 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "SSAORS.hlsli" - -Texture2D LoResDB : register(t0); -Texture2D HiResDB : register(t1); -Texture2D LoResAO1 : register(t2); -#ifdef COMBINE_LOWER_RESOLUTIONS -Texture2D LoResAO2 : register(t3); -#endif -#ifdef BLEND_WITH_HIGHER_RESOLUTION -Texture2D HiResAO : register(t4); -#endif - -RWTexture2D AoResult : register(u0); - -SamplerState LinearSampler : register(s0); - -cbuffer CB1 : register(b1) -{ - float2 InvLowResolution; - float2 InvHighResolution; - float NoiseFilterStrength; - float StepSize; - float kBlurTolerance; - float kUpsampleTolerance; -} - -groupshared float DepthCache[256]; -groupshared float AOCache1[256]; -groupshared float AOCache2[256]; - -void PrefetchData( uint index, float2 uv ) -{ - float4 AO1 = LoResAO1.Gather( LinearSampler, uv ); - -#ifdef COMBINE_LOWER_RESOLUTIONS - AO1 = min(AO1, LoResAO2.Gather( LinearSampler, uv )); -#endif - - AOCache1[index ] = AO1.w; - AOCache1[index+ 1] = AO1.z; - AOCache1[index+16] = AO1.x; - AOCache1[index+17] = AO1.y; - - float4 ID = 1.0 / LoResDB.Gather( LinearSampler, uv ); - DepthCache[index ] = ID.w; - DepthCache[index+ 1] = ID.z; - DepthCache[index+16] = ID.x; - DepthCache[index+17] = ID.y; -} - -float SmartBlur( float a, float b, float c, float d, float e, bool Left, bool Middle, bool Right ) -{ - b = Left | Middle ? b : c; - a = Left ? a : b; - d = Right | Middle ? d : c; - e = Right ? e : d; - return ((a + e) / 2.0 + b + c + d) / 4.0; -} - -bool CompareDeltas( float d1, float d2, float l1, float l2 ) -{ - float temp = d1 * d2 + StepSize; - return temp * temp > l1 * l2 * kBlurTolerance; -} - -void BlurHorizontally( uint leftMostIndex ) -{ - float a0 = AOCache1[leftMostIndex ]; - float a1 = AOCache1[leftMostIndex+1]; - float a2 = AOCache1[leftMostIndex+2]; - float a3 = AOCache1[leftMostIndex+3]; - float a4 = AOCache1[leftMostIndex+4]; - float a5 = AOCache1[leftMostIndex+5]; - float a6 = AOCache1[leftMostIndex+6]; - - float d0 = DepthCache[leftMostIndex ]; - float d1 = DepthCache[leftMostIndex+1]; - float d2 = DepthCache[leftMostIndex+2]; - float d3 = DepthCache[leftMostIndex+3]; - float d4 = DepthCache[leftMostIndex+4]; - float d5 = DepthCache[leftMostIndex+5]; - float d6 = DepthCache[leftMostIndex+6]; - - float d01 = d1 - d0; - float d12 = d2 - d1; - float d23 = d3 - d2; - float d34 = d4 - d3; - float d45 = d5 - d4; - float d56 = d6 - d5; - - float l01 = d01 * d01 + StepSize; - float l12 = d12 * d12 + StepSize; - float l23 = d23 * d23 + StepSize; - float l34 = d34 * d34 + StepSize; - float l45 = d45 * d45 + StepSize; - float l56 = d56 * d56 + StepSize; - - bool c02 = CompareDeltas( d01, d12, l01, l12 ); - bool c13 = CompareDeltas( d12, d23, l12, l23 ); - bool c24 = CompareDeltas( d23, d34, l23, l34 ); - bool c35 = CompareDeltas( d34, d45, l34, l45 ); - bool c46 = CompareDeltas( d45, d56, l45, l56 ); - - AOCache2[leftMostIndex ] = SmartBlur( a0, a1, a2, a3, a4, c02, c13, c24 ); - AOCache2[leftMostIndex+1] = SmartBlur( a1, a2, a3, a4, a5, c13, c24, c35 ); - AOCache2[leftMostIndex+2] = SmartBlur( a2, a3, a4, a5, a6, c24, c35, c46 ); -} - -void BlurVertically( uint topMostIndex ) -{ - float a0 = AOCache2[topMostIndex ]; - float a1 = AOCache2[topMostIndex+16]; - float a2 = AOCache2[topMostIndex+32]; - float a3 = AOCache2[topMostIndex+48]; - float a4 = AOCache2[topMostIndex+64]; - float a5 = AOCache2[topMostIndex+80]; - - float d0 = DepthCache[topMostIndex+ 2]; - float d1 = DepthCache[topMostIndex+18]; - float d2 = DepthCache[topMostIndex+34]; - float d3 = DepthCache[topMostIndex+50]; - float d4 = DepthCache[topMostIndex+66]; - float d5 = DepthCache[topMostIndex+82]; - - float d01 = d1 - d0; - float d12 = d2 - d1; - float d23 = d3 - d2; - float d34 = d4 - d3; - float d45 = d5 - d4; - - float l01 = d01 * d01 + StepSize; - float l12 = d12 * d12 + StepSize; - float l23 = d23 * d23 + StepSize; - float l34 = d34 * d34 + StepSize; - float l45 = d45 * d45 + StepSize; - - bool c02 = CompareDeltas( d01, d12, l01, l12 ); - bool c13 = CompareDeltas( d12, d23, l12, l23 ); - bool c24 = CompareDeltas( d23, d34, l23, l34 ); - bool c35 = CompareDeltas( d34, d45, l34, l45 ); - - float aoResult1 = SmartBlur( a0, a1, a2, a3, a4, c02, c13, c24 ); - float aoResult2 = SmartBlur( a1, a2, a3, a4, a5, c13, c24, c35 ); - - AOCache1[topMostIndex ] = aoResult1; - AOCache1[topMostIndex+16] = aoResult2; -} - -// We essentially want 5 weights: 4 for each low-res pixel and 1 to blend in when none of the 4 really -// match. The filter strength is 1 / DeltaZTolerance. So a tolerance of 0.01 would yield a strength of 100. -// Note that a perfect match of low to high depths would yield a weight of 10^6, completely superceding any -// noise filtering. The noise filter is intended to soften the effects of shimmering when the high-res depth -// buffer has a lot of small holes in it causing the low-res depth buffer to inaccurately represent it. -float BilateralUpsample( float HiDepth, float HiAO, float4 LowDepths, float4 LowAO ) -{ - float4 weights = float4(9, 3, 1, 3) / ( abs(HiDepth - LowDepths) + kUpsampleTolerance ); - float TotalWeight = dot(weights, 1) + NoiseFilterStrength; - float WeightedSum = dot(LowAO, weights) + NoiseFilterStrength;// * HiAO; - return HiAO * WeightedSum / TotalWeight; -} - -[RootSignature(SSAO_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID ) -{ - // - // Load 4 pixels per thread into LDS to fill the 16x16 LDS cache with depth and AO - // - PrefetchData( GTid.x << 1 | GTid.y << 5, int2(DTid.xy + GTid.xy - 2) * InvLowResolution ); - GroupMemoryBarrierWithGroupSync(); - - // Goal: End up with a 9x9 patch that is blurred so we can upsample. Blur radius is 2 pixels, so start with 13x13 area. - - // - // Horizontally blur the pixels. 13x13 -> 9x13 - // - if (GI < 39) - BlurHorizontally((GI / 3) * 16 + (GI % 3) * 3); - GroupMemoryBarrierWithGroupSync(); - - // - // Vertically blur the pixels. 9x13 -> 9x9 - // - if (GI < 45) - BlurVertically((GI / 9) * 32 + GI % 9); - GroupMemoryBarrierWithGroupSync(); - - // - // Bilateral upsample - // - uint Idx0 = GTid.x + GTid.y * 16; - float4 LoSSAOs = float4( AOCache1[Idx0+16], AOCache1[Idx0+17], AOCache1[Idx0+1], AOCache1[Idx0] ); - - // We work on a quad of pixels at once because then we can gather 4 each of high and low-res depth values - float2 UV0 = DTid.xy * InvLowResolution; - float2 UV1 = DTid.xy * 2 * InvHighResolution; - -#ifdef BLEND_WITH_HIGHER_RESOLUTION - float4 HiSSAOs = HiResAO.Gather(LinearSampler, UV1); -#else - float4 HiSSAOs = 1.0; -#endif - float4 LoDepths = LoResDB.Gather(LinearSampler, UV0); - float4 HiDepths = HiResDB.Gather(LinearSampler, UV1); - - int2 OutST = DTid.xy << 1; - AoResult[OutST + int2(-1, 0)] = BilateralUpsample( HiDepths.x, HiSSAOs.x, LoDepths.xyzw, LoSSAOs.xyzw ); - AoResult[OutST + int2( 0, 0)] = BilateralUpsample( HiDepths.y, HiSSAOs.y, LoDepths.yzwx, LoSSAOs.yzwx ); - AoResult[OutST + int2( 0, -1)] = BilateralUpsample( HiDepths.z, HiSSAOs.z, LoDepths.zwxy, LoSSAOs.zwxy ); - AoResult[OutST + int2(-1, -1)] = BilateralUpsample( HiDepths.w, HiSSAOs.w, LoDepths.wxyz, LoSSAOs.wxyz ); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/AoBlurUpsampleBlendOutCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/AoBlurUpsampleBlendOutCS.hlsl deleted file mode 100644 index c711049..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/AoBlurUpsampleBlendOutCS.hlsl +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define BLEND_WITH_HIGHER_RESOLUTION - -#include "AoBlurAndUpsampleCS.hlsli" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/AoBlurUpsampleCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/AoBlurUpsampleCS.hlsl deleted file mode 100644 index 5629c14..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/AoBlurUpsampleCS.hlsl +++ /dev/null @@ -1,14 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "AoBlurAndUpsampleCS.hlsli" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/AoBlurUpsamplePreMinBlendOutCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/AoBlurUpsamplePreMinBlendOutCS.hlsl deleted file mode 100644 index e4fa497..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/AoBlurUpsamplePreMinBlendOutCS.hlsl +++ /dev/null @@ -1,17 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define COMBINE_LOWER_RESOLUTIONS -#define BLEND_WITH_HIGHER_RESOLUTION - -#include "AoBlurAndUpsampleCS.hlsli" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/AoBlurUpsamplePreMinCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/AoBlurUpsamplePreMinCS.hlsl deleted file mode 100644 index 0d0642c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/AoBlurUpsamplePreMinCS.hlsl +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define COMBINE_LOWER_RESOLUTIONS - -#include "AoBlurAndUpsampleCS.hlsli" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/AoPrepareDepthBuffers1CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/AoPrepareDepthBuffers1CS.hlsl deleted file mode 100644 index c330810..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/AoPrepareDepthBuffers1CS.hlsl +++ /dev/null @@ -1,68 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "SSAORS.hlsli" - -RWTexture2D LinearZ : register(u0); -RWTexture2D DS2x : register(u1); -RWTexture2DArray DS2xAtlas : register(u2); -RWTexture2D DS4x : register(u3); -RWTexture2DArray DS4xAtlas : register(u4); -cbuffer CB0 : register(b0) -{ - float ZMagic; -} - -Texture2D Depth : register(t0); - -float Linearize( uint2 st ) -{ - float depth = Depth[st]; - float dist = 1.0 / (ZMagic * depth + 1.0); - LinearZ[st] = dist; - return dist; -} - -groupshared float g_CacheW[256]; - -[RootSignature(SSAO_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID ) -{ - uint2 startST = Gid.xy << 4 | GTid.xy; - uint destIdx = GTid.y << 4 | GTid.x; - g_CacheW[ destIdx + 0 ] = Linearize(startST | uint2(0, 0)); - g_CacheW[ destIdx + 8 ] = Linearize(startST | uint2(8, 0)); - g_CacheW[ destIdx + 128 ] = Linearize(startST | uint2(0, 8)); - g_CacheW[ destIdx + 136 ] = Linearize(startST | uint2(8, 8)); - - GroupMemoryBarrierWithGroupSync(); - - uint ldsIndex = (GTid.x << 1) | (GTid.y << 5); - - float w1 = g_CacheW[ldsIndex]; - - uint2 st = DTid.xy; - uint slice = (st.x & 3) | ((st.y & 3) << 2); - DS2x[st] = w1; - DS2xAtlas[uint3(st >> 2, slice)] = w1; - - if ((GI & 011) == 0) - { - st = DTid.xy >> 1; - slice = (st.x & 3) | ((st.y & 3) << 2); - DS4x[st] = w1; - DS4xAtlas[uint3(st >> 2, slice)] = w1; - } - -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/AoPrepareDepthBuffers2CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/AoPrepareDepthBuffers2CS.hlsl deleted file mode 100644 index 0f381ba..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/AoPrepareDepthBuffers2CS.hlsl +++ /dev/null @@ -1,47 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "SSAORS.hlsli" - -Texture2D DS4x : register(t0); -RWTexture2D DS8x : register(u0); -RWTexture2DArray DS8xAtlas : register(u1); -RWTexture2D DS16x : register(u2); -RWTexture2DArray DS16xAtlas : register(u3); - -cbuffer CB0 : register(b0) -{ - float2 InvSourceDimension; -} - -[RootSignature(SSAO_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID ) -{ - float m1 = DS4x[DTid.xy << 1]; - - uint2 st = DTid.xy; - uint2 stAtlas = st >> 2; - uint stSlice = (st.x & 3) | ((st.y & 3) << 2); - DS8x[st] = m1; - DS8xAtlas[uint3(stAtlas, stSlice)] = m1; - - if ((GI & 011) == 0) - { - uint2 st = DTid.xy >> 1; - uint2 stAtlas = st >> 2; - uint stSlice = (st.x & 3) | ((st.y & 3) << 2); - DS16x[st] = m1; - DS16xAtlas[uint3(stAtlas, stSlice)] = m1; - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/AoRender1CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/AoRender1CS.hlsl deleted file mode 100644 index 65ca2aa..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/AoRender1CS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define INTERLEAVE_RESULT -#include "AoRenderCS.hlsli" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/AoRender2CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/AoRender2CS.hlsl deleted file mode 100644 index 8377ae2..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/AoRender2CS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - - -#include "AoRenderCS.hlsli" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/AoRenderCS.hlsli b/xess/samples/xess_demo/MiniEngine/Core/Shaders/AoRenderCS.hlsli deleted file mode 100644 index e790a08..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/AoRenderCS.hlsli +++ /dev/null @@ -1,172 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "SSAORS.hlsli" - -#ifndef INTERLEAVE_RESULT -#define WIDE_SAMPLING 1 -#endif - -#ifdef INTERLEAVE_RESULT -Texture2DArray DepthTex : register(t0); -#else -Texture2D DepthTex : register(t0); -#endif -RWTexture2D Occlusion : register(u0); -SamplerState LinearBorderSampler : register(s1); -cbuffer CB1 : register(b1) -{ - float4 gInvThicknessTable[3]; - float4 gSampleWeightTable[3]; - float2 gInvSliceDimension; - float gRejectFadeoff; - float gRcpAccentuation; -} - -#if WIDE_SAMPLING - // 32x32 cache size: the 16x16 in the center forms the area of focus with the 8-pixel perimeter used for wide gathering. - #define TILE_DIM 32 - #define THREAD_COUNT_X 16 - #define THREAD_COUNT_Y 16 -#else - // 16x16 cache size: the 8x8 in the center forms the area of focus with the 4-pixel perimeter used for gathering. - #define TILE_DIM 16 - #define THREAD_COUNT_X 8 - #define THREAD_COUNT_Y 8 -#endif - -groupshared float DepthSamples[TILE_DIM * TILE_DIM]; - -float TestSamplePair( float frontDepth, float invRange, uint base, int offset ) -{ - // "Disocclusion" measures the penetration distance of the depth sample within the sphere. - // Disocclusion < 0 (full occlusion) -> the sample fell in front of the sphere - // Disocclusion > 1 (no occlusion) -> the sample fell behind the sphere - float disocclusion1 = DepthSamples[base + offset] * invRange - frontDepth; - float disocclusion2 = DepthSamples[base - offset] * invRange - frontDepth; - - float pseudoDisocclusion1 = saturate(gRejectFadeoff * disocclusion1); - float pseudoDisocclusion2 = saturate(gRejectFadeoff * disocclusion2); - - return - clamp(disocclusion1, pseudoDisocclusion2, 1.0) + - clamp(disocclusion2, pseudoDisocclusion1, 1.0) - - pseudoDisocclusion1 * pseudoDisocclusion2; -} - -float TestSamples( uint centerIdx, uint x, uint y, float invDepth, float invThickness ) -{ -#if WIDE_SAMPLING - x <<= 1; - y <<= 1; -#endif - - float invRange = invThickness * invDepth; - float frontDepth = invThickness - 0.5; - - if (y == 0) - { - // Axial - return 0.5 * ( - TestSamplePair(frontDepth, invRange, centerIdx, x) + - TestSamplePair(frontDepth, invRange, centerIdx, x * TILE_DIM)); - } - else if (x == y) - { - // Diagonal - return 0.5 * ( - TestSamplePair(frontDepth, invRange, centerIdx, x * TILE_DIM - x) + - TestSamplePair(frontDepth, invRange, centerIdx, x * TILE_DIM + x)); - } - else - { - // L-Shaped - return 0.25 * ( - TestSamplePair(frontDepth, invRange, centerIdx, y * TILE_DIM + x) + - TestSamplePair(frontDepth, invRange, centerIdx, y * TILE_DIM - x) + - TestSamplePair(frontDepth, invRange, centerIdx, x * TILE_DIM + y) + - TestSamplePair(frontDepth, invRange, centerIdx, x * TILE_DIM - y)); - } -} - -[RootSignature(SSAO_RootSig)] -#if WIDE_SAMPLING -[numthreads( 16, 16, 1 )] -#else -[numthreads( 8, 8, 1 )] -#endif -void main( uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID ) -{ -#if WIDE_SAMPLING - float2 QuadCenterUV = int2(DTid.xy + GTid.xy - 7) * gInvSliceDimension; -#else - float2 QuadCenterUV = int2(DTid.xy + GTid.xy - 3) * gInvSliceDimension; -#endif - - // Fetch four depths and store them in LDS -#ifdef INTERLEAVE_RESULT - float4 depths = DepthTex.Gather(LinearBorderSampler, float3(QuadCenterUV, DTid.z)); -#else - float4 depths = DepthTex.Gather(LinearBorderSampler, QuadCenterUV); -#endif - int destIdx = GTid.x * 2 + GTid.y * 2 * TILE_DIM; - DepthSamples[destIdx] = depths.w; - DepthSamples[destIdx + 1] = depths.z; - DepthSamples[destIdx + TILE_DIM] = depths.x; - DepthSamples[destIdx + TILE_DIM + 1] = depths.y; - - GroupMemoryBarrierWithGroupSync(); - -#if WIDE_SAMPLING - uint thisIdx = GTid.x + GTid.y * TILE_DIM + 8 * TILE_DIM + 8; -#else - uint thisIdx = GTid.x + GTid.y * TILE_DIM + 4 * TILE_DIM + 4; -#endif - const float invThisDepth = 1.0 / DepthSamples[thisIdx]; - - float ao = 0.0; - -//#define SAMPLE_EXHAUSTIVELY - -#ifdef SAMPLE_EXHAUSTIVELY - // 68 samples: sample all cells in *within* a circular radius of 5 - ao += gSampleWeightTable[0].x * TestSamples(thisIdx, 1, 0, invThisDepth, gInvThicknessTable[0].x); - ao += gSampleWeightTable[0].y * TestSamples(thisIdx, 2, 0, invThisDepth, gInvThicknessTable[0].y); - ao += gSampleWeightTable[0].z * TestSamples(thisIdx, 3, 0, invThisDepth, gInvThicknessTable[0].z); - ao += gSampleWeightTable[0].w * TestSamples(thisIdx, 4, 0, invThisDepth, gInvThicknessTable[0].w); - ao += gSampleWeightTable[1].x * TestSamples(thisIdx, 1, 1, invThisDepth, gInvThicknessTable[1].x); - ao += gSampleWeightTable[2].x * TestSamples(thisIdx, 2, 2, invThisDepth, gInvThicknessTable[2].x); - ao += gSampleWeightTable[2].w * TestSamples(thisIdx, 3, 3, invThisDepth, gInvThicknessTable[2].w); - ao += gSampleWeightTable[1].y * TestSamples(thisIdx, 1, 2, invThisDepth, gInvThicknessTable[1].y); - ao += gSampleWeightTable[1].z * TestSamples(thisIdx, 1, 3, invThisDepth, gInvThicknessTable[1].z); - ao += gSampleWeightTable[1].w * TestSamples(thisIdx, 1, 4, invThisDepth, gInvThicknessTable[1].w); - ao += gSampleWeightTable[2].y * TestSamples(thisIdx, 2, 3, invThisDepth, gInvThicknessTable[2].y); - ao += gSampleWeightTable[2].z * TestSamples(thisIdx, 2, 4, invThisDepth, gInvThicknessTable[2].z); -#else // SAMPLE_CHECKER - // 36 samples: sample every-other cell in a checker board pattern - ao += gSampleWeightTable[0].y * TestSamples(thisIdx, 2, 0, invThisDepth, gInvThicknessTable[0].y); - ao += gSampleWeightTable[0].w * TestSamples(thisIdx, 4, 0, invThisDepth, gInvThicknessTable[0].w); - ao += gSampleWeightTable[1].x * TestSamples(thisIdx, 1, 1, invThisDepth, gInvThicknessTable[1].x); - ao += gSampleWeightTable[2].x * TestSamples(thisIdx, 2, 2, invThisDepth, gInvThicknessTable[2].x); - ao += gSampleWeightTable[2].w * TestSamples(thisIdx, 3, 3, invThisDepth, gInvThicknessTable[2].w); - ao += gSampleWeightTable[1].z * TestSamples(thisIdx, 1, 3, invThisDepth, gInvThicknessTable[1].z); - ao += gSampleWeightTable[2].z * TestSamples(thisIdx, 2, 4, invThisDepth, gInvThicknessTable[2].z); -#endif - -#ifdef INTERLEAVE_RESULT - uint2 OutPixel = DTid.xy << 2 | uint2(DTid.z & 3, DTid.z >> 2); -#else - uint2 OutPixel = DTid.xy; -#endif - Occlusion[OutPixel] = ao * gRcpAccentuation; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ApplyBloom2CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ApplyBloom2CS.hlsl deleted file mode 100644 index 9cfe97b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ApplyBloom2CS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define SUPPORT_TYPED_UAV_LOADS 1 -#include "ApplyBloomCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ApplyBloomCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ApplyBloomCS.hlsl deleted file mode 100644 index bcecd8c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ApplyBloomCS.hlsl +++ /dev/null @@ -1,49 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "ShaderUtility.hlsli" -#include "PostEffectsRS.hlsli" -#include "PixelPacking.hlsli" - -Texture2D Bloom : register( t0 ); -#if SUPPORT_TYPED_UAV_LOADS -RWTexture2D SrcColor : register( u0 ); -#else -RWTexture2D DstColor : register(u0); -Texture2D SrcColor : register(t2); -#endif -RWTexture2D OutLuma : register( u1 ); -SamplerState LinearSampler : register( s0 ); - -cbuffer CB0 : register(b0) -{ - float2 g_RcpBufferDim; - float g_BloomStrength; -}; - -[RootSignature(PostEffects_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID ) -{ - float2 TexCoord = (DTid.xy + 0.5) * g_RcpBufferDim; - - // Load LDR and bloom - float3 ldrColor = SrcColor[DTid.xy] + g_BloomStrength * Bloom.SampleLevel(LinearSampler, TexCoord, 0); - -#if SUPPORT_TYPED_UAV_LOADS - SrcColor[DTid.xy] = ldrColor; -#else - DstColor[DTid.xy] = Pack_R11G11B10_FLOAT(ldrColor); -#endif - OutLuma[DTid.xy] = RGBToLogLuminance(ldrColor); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/AverageLumaCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/AverageLumaCS.hlsl deleted file mode 100644 index 8cadcef..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/AverageLumaCS.hlsl +++ /dev/null @@ -1,53 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "PostEffectsRS.hlsli" - -Texture2D InputBuf : register( t0 ); -RWStructuredBuffer Result : register( u0 ); - -groupshared float buffer[64]; - -[RootSignature(PostEffects_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID ) -{ - float sumThisThread = InputBuf[DTid.xy]; - buffer[GI] = sumThisThread; - GroupMemoryBarrierWithGroupSync(); - - sumThisThread += buffer[GI + 32]; - buffer[GI] = sumThisThread; - GroupMemoryBarrierWithGroupSync(); - - sumThisThread += buffer[GI + 16]; - buffer[GI] = sumThisThread; - GroupMemoryBarrierWithGroupSync(); - - sumThisThread += buffer[GI + 8]; - buffer[GI] = sumThisThread; - GroupMemoryBarrierWithGroupSync(); - - sumThisThread += buffer[GI + 4]; - buffer[GI] = sumThisThread; - GroupMemoryBarrierWithGroupSync(); - - sumThisThread += buffer[GI + 2]; - buffer[GI] = sumThisThread; - GroupMemoryBarrierWithGroupSync(); - - sumThisThread += buffer[GI + 1]; - - if (GI == 0) - Result[Gid.x + Gid.y * 5] = sumThisThread / 64.0f; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BicubicFilterFunctions.hlsli b/xess/samples/xess_demo/MiniEngine/Core/Shaders/BicubicFilterFunctions.hlsli deleted file mode 100644 index cebf26a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BicubicFilterFunctions.hlsli +++ /dev/null @@ -1,55 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -float W1(float x, float A) -{ - return x * x * ((A + 2) * x - (A + 3)) + 1.0; -} - -float W2(float x, float A) -{ - return A * (x * (x * (x - 5) + 8) - 4); -} - -float4 ComputeWeights(float d1, float A) -{ - return float4(W2(1.0 + d1, A), W1(d1, A), W1(1.0 - d1, A), W2(2.0 - d1, A)); -} - -float4 GetBicubicFilterWeights(float offset, float A) -{ - //return ComputeWeights(offset, A); - - // Precompute weights for 16 discrete offsets - static const float4 FilterWeights[16] = - { - ComputeWeights( 0.5 / 16.0, -0.5), - ComputeWeights( 1.5 / 16.0, -0.5), - ComputeWeights( 2.5 / 16.0, -0.5), - ComputeWeights( 3.5 / 16.0, -0.5), - ComputeWeights( 4.5 / 16.0, -0.5), - ComputeWeights( 5.5 / 16.0, -0.5), - ComputeWeights( 6.5 / 16.0, -0.5), - ComputeWeights( 7.5 / 16.0, -0.5), - ComputeWeights( 8.5 / 16.0, -0.5), - ComputeWeights( 9.5 / 16.0, -0.5), - ComputeWeights(10.5 / 16.0, -0.5), - ComputeWeights(11.5 / 16.0, -0.5), - ComputeWeights(12.5 / 16.0, -0.5), - ComputeWeights(13.5 / 16.0, -0.5), - ComputeWeights(14.5 / 16.0, -0.5), - ComputeWeights(15.5 / 16.0, -0.5) - }; - - return FilterWeights[(uint)(offset * 16.0)]; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BicubicHorizontalUpsamplePS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/BicubicHorizontalUpsamplePS.hlsl deleted file mode 100644 index d66000c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BicubicHorizontalUpsamplePS.hlsl +++ /dev/null @@ -1,65 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -//-------------------------------------------------------------------------------------- -// Simple bicubic filter -// -// http://en.wikipedia.org/wiki/Bicubic_interpolation -// http://http.developer.nvidia.com/GPUGems/gpugems_ch24.html -// -//-------------------------------------------------------------------------------------- - -#include "BicubicFilterFunctions.hlsli" -#include "ShaderUtility.hlsli" -#include "PresentRS.hlsli" - -Texture2D ColorTex : register(t0); - -cbuffer Constants : register(b0) -{ - uint2 TextureSize; - float kA; -} - -float3 GetColor(uint s, uint t) -{ -#ifdef GAMMA_SPACE - return ApplyDisplayProfile(ColorTex[uint2(s, t)], DISPLAY_PLANE_FORMAT); -#else - return ColorTex[uint2(s, t)]; -#endif -} - -[RootSignature(Present_RootSig)] -float3 main(float4 position : SV_Position, float2 uv : TexCoord0) : SV_Target0 -{ - float2 t = uv * TextureSize + 0.5; - float2 f = frac(t); - int2 st = int2(t.x, position.y); - - uint MaxWidth = TextureSize.x - 1; - - uint s0 = max(st.x - 2, 0); - uint s1 = max(st.x - 1, 0); - uint s2 = min(st.x + 0, MaxWidth); - uint s3 = min(st.x + 1, MaxWidth); - - float4 W = GetBicubicFilterWeights(f.x, kA); - float3 Color = - W.x * GetColor(s0, st.y) + - W.y * GetColor(s1, st.y) + - W.z * GetColor(s2, st.y) + - W.w * GetColor(s3, st.y); - - return Color; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BicubicUpsampleCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/BicubicUpsampleCS.hlsl deleted file mode 100644 index 3c3d6af..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BicubicUpsampleCS.hlsl +++ /dev/null @@ -1,134 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// - -#include "BicubicFilterFunctions.hlsli" -#include "PresentRS.hlsli" -#include "ShaderUtility.hlsli" - -Texture2D Source : register(t0); -RWTexture2D Dest : register(u0); - -cbuffer CB0 : register(b0) -{ - float2 kRcpScale; - float kA; // Controls sharpness -}; - -#ifndef ENABLE_FAST_PATH - #define TILE_DIM_X 16 - #define TILE_DIM_Y 16 -#endif -#define GROUP_COUNT (TILE_DIM_X * TILE_DIM_Y) - -// The fast path can be enabled when the source tile plus the extra border pixels fit -// within the destination tile size. For 16x16 destination tiles and 4 taps, you can -// upsample 13x13 tiles and smaller using the fast path. Src/Dest <= 13/16 --> FAST -#ifdef ENABLE_FAST_PATH - #define SAMPLES_X TILE_DIM_X - #define SAMPLES_Y TILE_DIM_Y -#else - #define SAMPLES_X (TILE_DIM_X + 3) - #define SAMPLES_Y (TILE_DIM_Y + 3) -#endif - -#define TOTAL_SAMPLES (SAMPLES_X * SAMPLES_Y) - -// De-interleaved to avoid LDS bank conflicts -groupshared float g_R[TOTAL_SAMPLES]; -groupshared float g_G[TOTAL_SAMPLES]; -groupshared float g_B[TOTAL_SAMPLES]; - -// Store pixel to LDS (local data store) -void StoreLDS(uint LdsIdx, float3 rgb) -{ - g_R[LdsIdx] = rgb.r; - g_G[LdsIdx] = rgb.g; - g_B[LdsIdx] = rgb.b; -} - -// Load four pixel samples from LDS. Stride determines horizontal or vertical groups. -float3x4 LoadSamples(uint idx, uint Stride) -{ - uint i0 = idx, i1 = idx+Stride, i2 = idx+2*Stride, i3=idx+3*Stride; - return float3x4( - g_R[i0], g_R[i1], g_R[i2], g_R[i3], - g_G[i0], g_G[i1], g_G[i2], g_G[i3], - g_B[i0], g_B[i1], g_B[i2], g_B[i3]); -} - -[RootSignature(Present_RootSig)] -[numthreads(TILE_DIM_X, TILE_DIM_Y, 1)] -void main( - uint3 DTid : SV_DispatchThreadID, - uint3 GTid : SV_GroupThreadID, - uint3 Gid : SV_GroupID, - uint GI : SV_GroupIndex) -{ - // Number of samples needed from the source buffer to generate the output tile dimensions. - const uint2 SampleSpace = ceil(float2(TILE_DIM_X, TILE_DIM_Y) * kRcpScale + 3.0); - - // Pre-Load source pixels - int2 UpperLeft = floor((Gid.xy * uint2(TILE_DIM_X, TILE_DIM_Y) + 0.5) * kRcpScale - 1.5); -#ifdef ENABLE_FAST_PATH - // NOTE: If bandwidth is more of a factor than ALU, uncomment this condition. - //if (all(GTid.xy < SampleSpace)) - StoreLDS(GI, Source[UpperLeft + GTid.xy]); -#else - for (uint i = GI; i < TOTAL_SAMPLES; i += GROUP_COUNT) - StoreLDS(i, Source[UpperLeft + int2(i % SAMPLES_X, i / SAMPLES_Y)]); -#endif - - GroupMemoryBarrierWithGroupSync(); - - // The coordinate of the top-left sample from the 4x4 kernel (offset by -0.5 - // so that whole numbers land on a pixel center.) This is in source texture space. - float2 TopLeftSample = (DTid.xy + 0.5) * kRcpScale - 1.5; - - // Position of samples relative to pixels used to evaluate the Sinc function. - float2 Phase = frac(TopLeftSample); - - // LDS tile coordinate for the top-left sample (for this thread) - uint2 TileST = int2(floor(TopLeftSample)) - UpperLeft; - - // Convolution weights, one per sample (in each dimension) - float4 xWeights = GetBicubicFilterWeights(Phase.x, kA); - float4 yWeights = GetBicubicFilterWeights(Phase.y, kA); - - // Horizontally convolve the first N rows - uint ReadIdx = TileST.x + GTid.y * SAMPLES_X; -#ifdef ENABLE_FAST_PATH - StoreLDS(GI, mul(LoadSamples(ReadIdx, 1), xWeights)); -#else - uint WriteIdx = GTid.x + GTid.y * SAMPLES_X; - StoreLDS(WriteIdx, mul(LoadSamples(ReadIdx, 1), xWeights)); - - // If the source tile plus border is larger than the destination tile, we - // have to convolve a few more rows. - if (GI + GROUP_COUNT < SampleSpace.y * TILE_DIM_X) - { - ReadIdx += TILE_DIM_Y * SAMPLES_X; - WriteIdx += TILE_DIM_Y * SAMPLES_X; - StoreLDS(WriteIdx, mul(LoadSamples(ReadIdx, 1), xWeights)); - } -#endif - - GroupMemoryBarrierWithGroupSync(); - - // Convolve vertically N columns - ReadIdx = GTid.x + TileST.y * SAMPLES_X; - float3 Result = mul(LoadSamples(ReadIdx, SAMPLES_X), yWeights); - - // Transform to display settings - Result = RemoveDisplayProfile(Result, LDR_COLOR_FORMAT); - Dest[DTid.xy] = ApplyDisplayProfile(Result, DISPLAY_PLANE_FORMAT); -} \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BicubicUpsampleFast16CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/BicubicUpsampleFast16CS.hlsl deleted file mode 100644 index faef007..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BicubicUpsampleFast16CS.hlsl +++ /dev/null @@ -1,21 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// The "fast path" Lanczos filter can be used when the source tile dimensions -// plus the border pixels (3) fit inside 16x16. This reduces bandwidth and -// uses more efficient Math. To determine this case, use the following logic: -// -// bool EnableFastPath = all(srcDim.xy / dstDim.xy <= 13.0 / 16.0); -// - -#define TILE_DIM_X 16 -#define TILE_DIM_Y 16 -#define ENABLE_FAST_PATH 1 -#include "BicubicUpsampleCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BicubicUpsampleFast24CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/BicubicUpsampleFast24CS.hlsl deleted file mode 100644 index b432cf5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BicubicUpsampleFast24CS.hlsl +++ /dev/null @@ -1,21 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// The "fast path" Lanczos filter can be used when the source tile dimensions -// plus the border pixels (3) fit inside 16x16. This reduces bandwidth and -// uses more efficient Math. To determine this case, use the following logic: -// -// bool EnableFastPath = all(srcDim.xy / dstDim.xy <= 21.0 / 24.0); -// - -#define TILE_DIM_X 32 -#define TILE_DIM_Y 24 -#define ENABLE_FAST_PATH 1 -#include "BicubicUpsampleCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BicubicUpsampleFast32CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/BicubicUpsampleFast32CS.hlsl deleted file mode 100644 index 9725065..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BicubicUpsampleFast32CS.hlsl +++ /dev/null @@ -1,21 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// The "fast path" Lanczos filter can be used when the source tile dimensions -// plus the border pixels (3) fit inside 16x16. This reduces bandwidth and -// uses more efficient Math. To determine this case, use the following logic: -// -// bool EnableFastPath = all(srcDim.xy / dstDim.xy <= 29.0 / 32.0); -// - -#define TILE_DIM_X 32 -#define TILE_DIM_Y 32 -#define ENABLE_FAST_PATH 1 -#include "BicubicUpsampleCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BicubicUpsampleGammaPS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/BicubicUpsampleGammaPS.hlsl deleted file mode 100644 index 0accb95..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BicubicUpsampleGammaPS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define GAMMA_SPACE -#include "BicubicUpsamplePS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BicubicUpsamplePS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/BicubicUpsamplePS.hlsl deleted file mode 100644 index b973f5e..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BicubicUpsamplePS.hlsl +++ /dev/null @@ -1,95 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -//-------------------------------------------------------------------------------------- -// Simple bicubic filter -// -// http://en.wikipedia.org/wiki/Bicubic_interpolation -// http://http.developer.nvidia.com/GPUGems/gpugems_ch24.html -// -//-------------------------------------------------------------------------------------- - -#include "ShaderUtility.hlsli" -#include "PresentRS.hlsli" - -Texture2D ColorTex : register(t0); -SamplerState BilinearClamp : register(s0); - -cbuffer Constants : register(b0) -{ - uint2 TextureSize; - float A; -} - -float W1(float x) -{ - return x * x * ((A + 2) * x - (A + 3)) + 1.0; -} - -float W2(float x) -{ - return A * (x * (x * (x - 5) + 8) - 4); -} - -float4 GetWeights(float d1) -{ - return float4(W2(1.0 + d1), W1(d1), W1(1.0 - d1), W2(2.0 - d1)); -} - -float3 Cubic(float4 w, float3 c0, float3 c1, float3 c2, float3 c3) -{ - return c0 * w.x + c1 * w.y + c2 * w.z + c3 * w.w; -} - -float3 GetColor(uint s, uint t) -{ -#ifdef GAMMA_SPACE - return ApplyDisplayProfile(ColorTex[uint2(s, t)], DISPLAY_PLANE_FORMAT); -#else - return ColorTex[uint2(s, t)]; -#endif -} - -[RootSignature(Present_RootSig)] -float3 main(float4 position : SV_Position, float2 uv : TexCoord0) : SV_Target0 -{ - float2 t = uv * TextureSize + 0.5; - float2 f = frac(t); - int2 st = int2(t); - - uint MaxWidth = TextureSize.x - 1; - uint MaxHeight = TextureSize.y - 1; - - uint s0 = max(st.x - 2, 0); - uint s1 = max(st.x - 1, 0); - uint s2 = min(st.x + 0, MaxWidth); - uint s3 = min(st.x + 1, MaxWidth); - - uint t0 = max(st.y - 2, 0); - uint t1 = max(st.y - 1, 0); - uint t2 = min(st.y + 0, MaxHeight); - uint t3 = min(st.y + 1, MaxHeight); - - float4 Weights = GetWeights(f.x); - float3 c0 = Cubic(Weights, GetColor(s0, t0), GetColor(s1, t0), GetColor(s2, t0), GetColor(s3, t0)); - float3 c1 = Cubic(Weights, GetColor(s0, t1), GetColor(s1, t1), GetColor(s2, t1), GetColor(s3, t1)); - float3 c2 = Cubic(Weights, GetColor(s0, t2), GetColor(s1, t2), GetColor(s2, t2), GetColor(s3, t2)); - float3 c3 = Cubic(Weights, GetColor(s0, t3), GetColor(s1, t3), GetColor(s2, t3), GetColor(s3, t3)); - float3 Color = Cubic(GetWeights(f.y), c0, c1, c2, c3); - -#ifdef GAMMA_SPACE - return Color; -#else - return ApplyDisplayProfile(Color, DISPLAY_PLANE_FORMAT); -#endif -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BicubicVerticalUpsamplePS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/BicubicVerticalUpsamplePS.hlsl deleted file mode 100644 index 9fa86e3..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BicubicVerticalUpsamplePS.hlsl +++ /dev/null @@ -1,65 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -//-------------------------------------------------------------------------------------- -// Simple bicubic filter -// -// http://en.wikipedia.org/wiki/Bicubic_interpolation -// http://http.developer.nvidia.com/GPUGems/gpugems_ch24.html -// -//-------------------------------------------------------------------------------------- - -#include "BicubicFilterFunctions.hlsli" -#include "ShaderUtility.hlsli" -#include "PresentRS.hlsli" - -Texture2D ColorTex : register(t0); - -cbuffer Constants : register(b0) -{ - uint2 TextureSize; - float kA; -} - -float3 GetColor(uint s, uint t) -{ - return ColorTex[uint2(s, t)]; -} - -[RootSignature(Present_RootSig)] -float3 main(float4 position : SV_Position, float2 uv : TexCoord0) : SV_Target0 -{ - float2 t = uv * TextureSize + 0.5; - float2 f = frac(t); - int2 st = int2(position.x, t.y); - - uint MaxHeight = TextureSize.y - 1; - - uint t0 = max(st.y - 2, 0); - uint t1 = max(st.y - 1, 0); - uint t2 = min(st.y + 0, MaxHeight); - uint t3 = min(st.y + 1, MaxHeight); - - float4 W = GetBicubicFilterWeights(f.y, kA); - float3 Color = - W.x * GetColor(st.x, t0) + - W.y * GetColor(st.x, t1) + - W.z * GetColor(st.x, t2) + - W.w * GetColor(st.x, t3); - -#ifdef GAMMA_SPACE - return Color; -#else - return ApplyDisplayProfile(Color, DISPLAY_PLANE_FORMAT); -#endif -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BilinearUpsamplePS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/BilinearUpsamplePS.hlsl deleted file mode 100644 index b154adc..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BilinearUpsamplePS.hlsl +++ /dev/null @@ -1,25 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard - -#include "ShaderUtility.hlsli" -#include "PresentRS.hlsli" - -Texture2D ColorTex : register(t0); - -SamplerState BilinearFilter : register(s0); - -[RootSignature(Present_RootSig)] -float3 main( float4 position : SV_Position, float2 uv : TexCoord0 ) : SV_Target0 -{ - float3 LinearRGB = RemoveDisplayProfile(ColorTex.SampleLevel(BilinearFilter, uv, 0), LDR_COLOR_FORMAT); - return ApplyDisplayProfile(LinearRGB, DISPLAY_PLANE_FORMAT); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/Bitonic32InnerSortCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/Bitonic32InnerSortCS.hlsl deleted file mode 100644 index 0bbd98f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/Bitonic32InnerSortCS.hlsl +++ /dev/null @@ -1,114 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// -// Description: The bitonic sort works by sorting groups of size k, -// starting with k=2 and doubling until k>=NumItems. To sort the -// group, keys are compared with a distance of j, which starts at half -// of k and continues halving down to 1. When j is 1024 and less, the -// compare and swap can happen in LDS, and these iterations form the -// "inner sort". Inner sorting happens in LDS and loops. Outer sorting -// happens in memory and does not loop. (Looping happens on the CPU by -// issuing sequential dispatches and barriers.) - - -#include "BitonicSortCommon.hlsli" - -RWByteAddressBuffer g_SortBuffer : register(u0); - -cbuffer Constants : register(b0) -{ - uint k; // k >= 4096 -}; - -#ifdef BITONICSORT_64BIT - -groupshared uint gs_SortKeys[2048]; -groupshared uint gs_SortIndices[2048]; - -void LoadKeyIndexPair( uint Element, uint ListCount ) -{ - uint2 KeyIndex = Element < ListCount ? g_SortBuffer.Load2(Element * 8) : NullItem; - gs_SortIndices[Element & 2047] = KeyIndex.x; - gs_SortKeys[Element & 2047] = KeyIndex.y; -} - -void StoreKeyIndexPair( uint Element, uint ListCount ) -{ - if (Element < ListCount) - g_SortBuffer.Store2(Element * 8, uint2(gs_SortIndices[Element & 2047], gs_SortKeys[Element & 2047])); -} - -#else // 32-bit packed key/index pairs - -groupshared uint gs_SortKeys[2048]; - -void LoadKeyIndexPair( uint Element, uint ListCount ) -{ - gs_SortKeys[Element & 2047] = Element < ListCount ? g_SortBuffer.Load(Element * 4) : NullItem; -} - -void StoreKeyIndexPair( uint Element, uint ListCount ) -{ - if (Element < ListCount) - g_SortBuffer.Store(Element * 4, gs_SortKeys[Element & 2047]); -} - -#endif - -[RootSignature(BitonicSort_RootSig)] -[numthreads(1024, 1, 1)] -void main( uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex ) -{ - const uint ListCount = g_CounterBuffer.Load(CounterOffset); - - // Item index of the start of this group - const uint GroupStart = Gid.x * 2048; - - // Load from memory into LDS to prepare sort - LoadKeyIndexPair(GroupStart + GI, ListCount); - LoadKeyIndexPair(GroupStart + GI + 1024, ListCount); - - GroupMemoryBarrierWithGroupSync(); - - // This is better unrolled because it reduces ALU and because some - // architectures can load/store two LDS items in a single instruction - // as long as their separation is a compile-time constant. - [unroll] - for (uint j = 1024; j > 0; j /= 2) - { - uint Index2 = InsertOneBit(GI, j); - uint Index1 = Index2 ^ j; - - uint A = gs_SortKeys[Index1]; - uint B = gs_SortKeys[Index2]; - - if (ShouldSwap(A, B)) - { - // Swap the keys - gs_SortKeys[Index1] = B; - gs_SortKeys[Index2] = A; - -#ifdef BITONICSORT_64BIT - // Then swap the indices (for 64-bit sorts) - A = gs_SortIndices[Index1]; - B = gs_SortIndices[Index2]; - gs_SortIndices[Index1] = B; - gs_SortIndices[Index2] = A; -#endif - } - - GroupMemoryBarrierWithGroupSync(); - } - - StoreKeyIndexPair(GroupStart + GI, ListCount); - StoreKeyIndexPair(GroupStart + GI + 1024, ListCount); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/Bitonic32OuterSortCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/Bitonic32OuterSortCS.hlsl deleted file mode 100644 index 4723533..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/Bitonic32OuterSortCS.hlsl +++ /dev/null @@ -1,55 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "BitonicSortCommon.hlsli" - -RWByteAddressBuffer g_SortBuffer : register(u0); - -cbuffer Constants : register(b0) -{ - uint k; // k >= 4096 - uint j; // j >= 2048 && j < k -}; - -#ifdef BITONICSORT_64BIT - #define Element uint2 - #define LoadElement(idx) g_SortBuffer.Load2(idx * 8) - #define StoreElement(idx, elem) g_SortBuffer.Store2(idx * 8, elem) -#else - #define Element uint - #define LoadElement(idx) g_SortBuffer.Load(idx * 4) - #define StoreElement(idx, elem) g_SortBuffer.Store(idx * 4, elem) -#endif - -[RootSignature(BitonicSort_RootSig)] -[numthreads(1024, 1, 1)] -void main( uint3 DTid : SV_DispatchThreadID ) -{ - const uint ListCount = g_CounterBuffer.Load(CounterOffset); - - // Form unique index pair from dispatch thread ID - uint Index2 = InsertOneBit(DTid.x, j); - uint Index1 = Index2 ^ (k == 2 * j ? k - 1 : j); - - if (Index2 >= ListCount) - return; - - Element A = LoadElement(Index1); - Element B = LoadElement(Index2); - - if (ShouldSwap(A, B)) - { - StoreElement(Index1, B); - StoreElement(Index2, A); - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/Bitonic32PreSortCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/Bitonic32PreSortCS.hlsl deleted file mode 100644 index 9a07926..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/Bitonic32PreSortCS.hlsl +++ /dev/null @@ -1,128 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// -// Description: A bitonic sort must eventually sort the power-of-two -// ceiling of items. E.g. 391 items -> 512 items. Because of this -// "null items" must be used as padding at the end of the list so that -// they can participate in the sort but remain at the end of the list. -// -// The pre-sort does two things. It appends null items as need, and -// it does the initial sort for k values up to 2048. This is because -// we can run 1024 threads, each of of which can compare and swap two -// elements without contention. And because we can always fit 2048 -// keys & indices in LDS with occupancy greater than one. (A single -// thread group can use as much as 32KB of LDS.) - - -#include "BitonicSortCommon.hlsli" - -RWByteAddressBuffer g_SortBuffer : register(u0); - -#ifdef BITONICSORT_64BIT - -groupshared uint gs_SortIndices[2048]; -groupshared uint gs_SortKeys[2048]; - -void FillSortKey( uint Element, uint ListCount ) -{ - // Unused elements must sort to the end - if (Element < ListCount) - { - uint2 KeyIndexPair = g_SortBuffer.Load2(Element * 8); - gs_SortKeys[Element & 2047] = KeyIndexPair.y; - gs_SortIndices[Element & 2047] = KeyIndexPair.x; - } - else - { - gs_SortKeys[Element & 2047] = NullItem; - } -} - -void StoreKeyIndexPair( uint Element, uint ListCount) -{ - if (Element < ListCount) - g_SortBuffer.Store2(Element * 8, uint2(gs_SortIndices[Element & 2047], gs_SortKeys[Element & 2047])); -} - -#else // 32-bit packed key/index pairs - -groupshared uint gs_SortKeys[2048]; - -void FillSortKey( uint Element, uint ListCount ) -{ - // Unused elements must sort to the end - gs_SortKeys[Element & 2047] = (Element < ListCount ? g_SortBuffer.Load(Element * 4) : NullItem); -} - -void StoreKeyIndexPair( uint Element, uint ListCount ) -{ - if (Element < ListCount) - g_SortBuffer.Store(Element * 4, gs_SortKeys[Element & 2047]); -} - -#endif - -[RootSignature(BitonicSort_RootSig)] -[numthreads(1024, 1, 1)] -void main( uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex ) -{ - // Item index of the start of this group - const uint GroupStart = Gid.x * 2048; - - // Actual number of items that need sorting - const uint ListCount = g_CounterBuffer.Load(CounterOffset); - - FillSortKey(GroupStart + GI, ListCount); - FillSortKey(GroupStart + GI + 1024, ListCount); - - GroupMemoryBarrierWithGroupSync(); - - uint k; - - // This is better unrolled because it reduces ALU and because some - // architectures can load/store two LDS items in a single instruction - // as long as their separation is a compile-time constant. - [unroll] - for (k = 2; k <= 2048; k <<= 1) - { - //[unroll] - for (uint j = k / 2; j > 0; j /= 2) - { - uint Index2 = InsertOneBit(GI, j); - uint Index1 = Index2 ^ (k == 2 * j ? k - 1 : j); - - uint A = gs_SortKeys[Index1]; - uint B = gs_SortKeys[Index2]; - - if (ShouldSwap(A, B)) - { - // Swap the keys - gs_SortKeys[Index1] = B; - gs_SortKeys[Index2] = A; - -#ifdef BITONICSORT_64BIT - // Then swap the indices (for 64-bit sorts) - A = gs_SortIndices[Index1]; - B = gs_SortIndices[Index2]; - gs_SortIndices[Index1] = B; - gs_SortIndices[Index2] = A; -#endif - } - - GroupMemoryBarrierWithGroupSync(); - } - } - - // Write sorted results to memory - StoreKeyIndexPair(GroupStart + GI, ListCount); - StoreKeyIndexPair(GroupStart + GI + 1024, ListCount); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/Bitonic64InnerSortCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/Bitonic64InnerSortCS.hlsl deleted file mode 100644 index c181966..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/Bitonic64InnerSortCS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define BITONICSORT_64BIT -#include "Bitonic32InnerSortCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/Bitonic64OuterSortCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/Bitonic64OuterSortCS.hlsl deleted file mode 100644 index 7289898..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/Bitonic64OuterSortCS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define BITONICSORT_64BIT -#include "Bitonic32OuterSortCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/Bitonic64PreSortCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/Bitonic64PreSortCS.hlsl deleted file mode 100644 index 3396e7f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/Bitonic64PreSortCS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define BITONICSORT_64BIT -#include "Bitonic32PreSortCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BitonicIndirectArgsCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/BitonicIndirectArgsCS.hlsl deleted file mode 100644 index abb8da0..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BitonicIndirectArgsCS.hlsl +++ /dev/null @@ -1,62 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "BitonicSortCommon.hlsli" - -RWByteAddressBuffer g_IndirectArgsBuffer : register(u0); - -cbuffer Constants : register(b0) -{ - uint MaxIterations; -} - -uint NextPow2( uint Val ) -{ - uint Mask = (1 << firstbithigh(Val)) - 1; - return (Val + Mask) & ~Mask; -} - -[RootSignature(BitonicSort_RootSig)] -[numthreads(22, 1, 1)] -void main( uint GI : SV_GroupIndex ) -{ - if (GI >= MaxIterations) - return; - - uint ListCount = g_CounterBuffer.Load(CounterOffset); - uint k = 2048 << GI; - - // We need one more iteration every time the number of thread groups doubles - if (k > NextPow2((ListCount + 2047) & ~2047)) - ListCount = 0; - - uint PrevDispatches = GI * (GI + 1) / 2; - uint Offset = 12 * PrevDispatches; - - // Generate outer sort dispatch arguments - for (uint j = k / 2; j > 1024; j /= 2) - { - // All of the groups of size 2j that are full - uint CompleteGroups = (ListCount & ~(2 * j - 1)) / 2048; - - // Remaining items must only be sorted if there are more than j of them - uint PartialGroups = ((uint)max(int(ListCount - CompleteGroups * 2048 - j), 0) + 1023) / 1024; - - g_IndirectArgsBuffer.Store3(Offset, uint3(CompleteGroups + PartialGroups, 1, 1)); - - Offset += 12; - } - - // The inner sort always sorts all groups (rounded up to multiples of 2048) - g_IndirectArgsBuffer.Store3(Offset, uint3((ListCount + 2047) / 2048, 1, 1)); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BitonicSortCommon.hlsli b/xess/samples/xess_demo/MiniEngine/Core/Shaders/BitonicSortCommon.hlsli deleted file mode 100644 index d7a93aa..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BitonicSortCommon.hlsli +++ /dev/null @@ -1,59 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define BitonicSort_RootSig \ - "RootFlags(0), " \ - "RootConstants(b0, num32BitConstants = 2)," \ - "DescriptorTable(SRV(t0, numDescriptors = 1))," \ - "DescriptorTable(UAV(u0, numDescriptors = 1))," \ - "RootConstants(b1, num32BitConstants = 2)" - -ByteAddressBuffer g_CounterBuffer : register(t0); - -cbuffer CB1 : register(b1) -{ - // Offset into counter buffer where this list's item count is stored - uint CounterOffset; - - // A sort key that will end up at the end of the list; to be used to pad - // lists in LDS (always 2048 items). - // Descending: 0x00000000 - // Ascending: 0xffffffff - // Also used by the ShouldSwap() function to invert ordering. - uint NullItem; -} - -// Takes Value and widens it by one bit at the location of the bit -// in the mask. A one is inserted in the space. OneBitMask must -// have one and only one bit set. -uint InsertOneBit( uint Value, uint OneBitMask ) -{ - uint Mask = OneBitMask - 1; - return (Value & ~Mask) << 1 | (Value & Mask) | OneBitMask; -} - -// Determines if two sort keys should be swapped in the list. NullItem is -// either 0 or 0xffffffff. XOR with the NullItem will either invert the bits -// (effectively a negation) or leave the bits alone. When the the NullItem is -// 0, we are sorting descending, so when A < B, they should swap. For an -// ascending sort, ~A < ~B should swap. -bool ShouldSwap(uint A, uint B) -{ - return (A ^ NullItem) < (B ^ NullItem); -} - -// Same as above, but only compares the upper 32-bit word. -bool ShouldSwap(uint2 A, uint2 B) -{ - return (A.y ^ NullItem) < (B.y ^ NullItem); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BlendUIHDRPS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/BlendUIHDRPS.hlsl deleted file mode 100644 index e786144..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BlendUIHDRPS.hlsl +++ /dev/null @@ -1,33 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "PresentRS.hlsli" -#include "ColorSpaceUtility.hlsli" - -Texture2D Overlay : register(t0); - -cbuffer CB0 : register(b0) -{ - float PaperWhiteRatio; // PaperWhite / 10000.0 - float MaxBrightness; -} - -[RootSignature(Present_RootSig)] -float4 main( float4 position : SV_Position ) : SV_Target0 -{ - float4 UI = Overlay[(int2)position.xy]; - UI.rgb = RemoveSRGBCurve(UI.rgb); - UI.rgb = REC709toREC2020(UI.rgb / (UI.a == 0.0 ? 1.0 : UI.a)); - UI.rgb = ApplyREC2084Curve(UI.rgb * PaperWhiteRatio); - return float4(UI.rgb, 1) * UI.a; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BloomExtractAndDownsampleHdrCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/BloomExtractAndDownsampleHdrCS.hlsl deleted file mode 100644 index d2a30b3..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BloomExtractAndDownsampleHdrCS.hlsl +++ /dev/null @@ -1,87 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// -// The CS for extracting bright pixels and downsampling them to an unblurred bloom buffer. - -#include "ShaderUtility.hlsli" -#include "PostEffectsRS.hlsli" - -SamplerState BiLinearClamp : register( s0 ); -Texture2D SourceTex : register( t0 ); -StructuredBuffer Exposure : register( t1 ); -RWTexture2D BloomResult : register( u0 ); -RWTexture2D LumaResult : register( u1 ); - -cbuffer cb0 -{ - float2 g_inverseOutputSize; - float g_bloomThreshold; -} - -[RootSignature(PostEffects_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 DTid : SV_DispatchThreadID ) -{ - // We need the scale factor and the size of one pixel so that our four samples are right in the middle - // of the quadrant they are covering. - float2 uv = (DTid.xy + 0.5) * g_inverseOutputSize; - float2 offset = g_inverseOutputSize * 0.25; - - // Use 4 bilinear samples to guarantee we don't undersample when downsizing by more than 2x - float3 color1 = SourceTex.SampleLevel( BiLinearClamp, uv + float2(-offset.x, -offset.y), 0 ); - float3 color2 = SourceTex.SampleLevel( BiLinearClamp, uv + float2( offset.x, -offset.y), 0 ); - float3 color3 = SourceTex.SampleLevel( BiLinearClamp, uv + float2(-offset.x, offset.y), 0 ); - float3 color4 = SourceTex.SampleLevel( BiLinearClamp, uv + float2( offset.x, offset.y), 0 ); - - float luma1 = RGBToLuminance(color1); - float luma2 = RGBToLuminance(color2); - float luma3 = RGBToLuminance(color3); - float luma4 = RGBToLuminance(color4); - - const float kSmallEpsilon = 0.0001; - - float ScaledThreshold = g_bloomThreshold * Exposure[1]; // BloomThreshold / Exposure - - // We perform a brightness filter pass, where lone bright pixels will contribute less. - color1 *= max(kSmallEpsilon, luma1 - ScaledThreshold) / (luma1 + kSmallEpsilon); - color2 *= max(kSmallEpsilon, luma2 - ScaledThreshold) / (luma2 + kSmallEpsilon); - color3 *= max(kSmallEpsilon, luma3 - ScaledThreshold) / (luma3 + kSmallEpsilon); - color4 *= max(kSmallEpsilon, luma4 - ScaledThreshold) / (luma4 + kSmallEpsilon); - - // The shimmer filter helps remove stray bright pixels from the bloom buffer by inversely weighting - // them by their luminance. The overall effect is to shrink bright pixel regions around the border. - // Lone pixels are likely to dissolve completely. This effect can be tuned by adjusting the shimmer - // filter inverse strength. The bigger it is, the less a pixel's luminance will matter. - const float kShimmerFilterInverseStrength = 1.0f; - float weight1 = 1.0f / (luma1 + kShimmerFilterInverseStrength); - float weight2 = 1.0f / (luma2 + kShimmerFilterInverseStrength); - float weight3 = 1.0f / (luma3 + kShimmerFilterInverseStrength); - float weight4 = 1.0f / (luma4 + kShimmerFilterInverseStrength); - float weightSum = weight1 + weight2 + weight3 + weight4; - - BloomResult[DTid.xy] = (color1 * weight1 + color2 * weight2 + color3 * weight3 + color4 * weight4) / weightSum; - - float luma = (luma1 + luma2 + luma3 + luma4) * 0.25; - - // Prevent log(0) and put only pure black pixels in Histogram[0] - if (luma == 0.0) - { - LumaResult[DTid.xy] = 0; - } - else - { - const float MinLog = Exposure[4]; - const float RcpLogRange = Exposure[7]; - float logLuma = saturate((log2(luma) - MinLog) * RcpLogRange); // Rescale to [0.0, 1.0] - LumaResult[DTid.xy] = logLuma * 254.0 + 1.0; // Rescale to [1, 255] - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BloomExtractAndDownsampleLdrCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/BloomExtractAndDownsampleLdrCS.hlsl deleted file mode 100644 index 3c0714e..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BloomExtractAndDownsampleLdrCS.hlsl +++ /dev/null @@ -1,70 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// -// The CS for extracting bright pixels and downsampling them to an unblurred bloom buffer. - -#include "ShaderUtility.hlsli" -#include "PostEffectsRS.hlsli" - -SamplerState BiLinearClamp : register( s0 ); -Texture2D SourceTex : register( t0 ); -RWTexture2D BloomResult : register( u0 ); - -cbuffer cb0 -{ - float2 g_inverseOutputSize; - float g_bloomThreshold; -} - -[RootSignature(PostEffects_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 DTid : SV_DispatchThreadID ) -{ - // We need the scale factor and the size of one pixel so that our four samples are right in the middle - // of the quadrant they are covering. - float2 uv = (DTid.xy + 0.5) * g_inverseOutputSize; - float2 offset = g_inverseOutputSize * 0.25; - - // Use 4 bilinear samples to guarantee we don't undersample when downsizing by more than 2x - float3 color1 = SourceTex.SampleLevel( BiLinearClamp, uv + float2(-offset.x, -offset.y), 0 ); - float3 color2 = SourceTex.SampleLevel( BiLinearClamp, uv + float2( offset.x, -offset.y), 0 ); - float3 color3 = SourceTex.SampleLevel( BiLinearClamp, uv + float2(-offset.x, offset.y), 0 ); - float3 color4 = SourceTex.SampleLevel( BiLinearClamp, uv + float2( offset.x, offset.y), 0 ); - - float luma1 = RGBToLuminance(color1); - float luma2 = RGBToLuminance(color2); - float luma3 = RGBToLuminance(color3); - float luma4 = RGBToLuminance(color4); - - const float kSmallEpsilon = 0.0001; - - float ScaledThreshold = g_bloomThreshold; - - // We perform a brightness filter pass, where lone bright pixels will contribute less. - color1 *= max(kSmallEpsilon, luma1 - ScaledThreshold) / (luma1 + kSmallEpsilon); - color2 *= max(kSmallEpsilon, luma2 - ScaledThreshold) / (luma2 + kSmallEpsilon); - color3 *= max(kSmallEpsilon, luma3 - ScaledThreshold) / (luma3 + kSmallEpsilon); - color4 *= max(kSmallEpsilon, luma4 - ScaledThreshold) / (luma4 + kSmallEpsilon); - - // The shimmer filter helps remove stray bright pixels from the bloom buffer by inversely weighting - // them by their luminance. The overall effect is to shrink bright pixel regions around the border. - // Lone pixels are likely to dissolve completely. This effect can be tuned by adjusting the shimmer - // filter inverse strength. The bigger it is, the less a pixel's luminance will matter. - const float kShimmerFilterInverseStrength = 1.0f; - float weight1 = 1.0f / (luma1 + kShimmerFilterInverseStrength); - float weight2 = 1.0f / (luma2 + kShimmerFilterInverseStrength); - float weight3 = 1.0f / (luma3 + kShimmerFilterInverseStrength); - float weight4 = 1.0f / (luma4 + kShimmerFilterInverseStrength); - float weightSum = weight1 + weight2 + weight3 + weight4; - - BloomResult[DTid.xy] = (color1 * weight1 + color2 * weight2 + color3 * weight3 + color4 * weight4) / weightSum; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BlurCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/BlurCS.hlsl deleted file mode 100644 index 863a851..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BlurCS.hlsl +++ /dev/null @@ -1,131 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// -// The CS for guassian blurring a single RGB buffer. -// -// For the intended bloom blurring algorithm, this shader is expected to be used only on -// the lowest resolution bloom buffer before starting the series of upsample-and-blur -// passes. - -#include "PostEffectsRS.hlsli" - -Texture2D InputBuf : register( t0 ); -RWTexture2D Result : register( u0 ); - -cbuffer cb0 : register(b0) -{ - float2 g_inverseDimensions; -} - -// The guassian blur weights (derived from Pascal's triangle) -static const float Weights[5] = { 70.0f / 256.0f, 56.0f / 256.0f, 28.0f / 256.0f, 8.0f / 256.0f, 1.0f / 256.0f }; - -float3 BlurPixels( float3 a, float3 b, float3 c, float3 d, float3 e, float3 f, float3 g, float3 h, float3 i ) -{ - return Weights[0]*e + Weights[1]*(d+f) + Weights[2]*(c+g) + Weights[3]*(b+h) + Weights[4]*(a+i); -} - -// 16x16 pixels with an 8x8 center that we will be blurring writing out. Each uint is two color channels packed together -groupshared uint CacheR[128]; -groupshared uint CacheG[128]; -groupshared uint CacheB[128]; - -void Store2Pixels( uint index, float3 pixel1, float3 pixel2 ) -{ - CacheR[index] = f32tof16(pixel1.r) | f32tof16(pixel2.r) << 16; - CacheG[index] = f32tof16(pixel1.g) | f32tof16(pixel2.g) << 16; - CacheB[index] = f32tof16(pixel1.b) | f32tof16(pixel2.b) << 16; -} - -void Load2Pixels( uint index, out float3 pixel1, out float3 pixel2 ) -{ - uint rr = CacheR[index]; - uint gg = CacheG[index]; - uint bb = CacheB[index]; - pixel1 = float3( f16tof32(rr ), f16tof32(gg ), f16tof32(bb ) ); - pixel2 = float3( f16tof32(rr >> 16), f16tof32(gg >> 16), f16tof32(bb >> 16) ); -} - -void Store1Pixel( uint index, float3 pixel ) -{ - CacheR[index] = asuint(pixel.r); - CacheG[index] = asuint(pixel.g); - CacheB[index] = asuint(pixel.b); -} - -void Load1Pixel( uint index, out float3 pixel ) -{ - pixel = asfloat( uint3(CacheR[index], CacheG[index], CacheB[index]) ); -} - -// Blur two pixels horizontally. This reduces LDS reads and pixel unpacking. -void BlurHorizontally( uint outIndex, uint leftMostIndex ) -{ - float3 s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - Load2Pixels( leftMostIndex + 0, s0, s1 ); - Load2Pixels( leftMostIndex + 1, s2, s3 ); - Load2Pixels( leftMostIndex + 2, s4, s5 ); - Load2Pixels( leftMostIndex + 3, s6, s7 ); - Load2Pixels( leftMostIndex + 4, s8, s9 ); - - Store1Pixel(outIndex , BlurPixels(s0, s1, s2, s3, s4, s5, s6, s7, s8)); - Store1Pixel(outIndex+1, BlurPixels(s1, s2, s3, s4, s5, s6, s7, s8, s9)); -} - -void BlurVertically( uint2 pixelCoord, uint topMostIndex ) -{ - float3 s0, s1, s2, s3, s4, s5, s6, s7, s8; - Load1Pixel( topMostIndex , s0 ); - Load1Pixel( topMostIndex+ 8, s1 ); - Load1Pixel( topMostIndex+16, s2 ); - Load1Pixel( topMostIndex+24, s3 ); - Load1Pixel( topMostIndex+32, s4 ); - Load1Pixel( topMostIndex+40, s5 ); - Load1Pixel( topMostIndex+48, s6 ); - Load1Pixel( topMostIndex+56, s7 ); - Load1Pixel( topMostIndex+64, s8 ); - - Result[pixelCoord] = BlurPixels(s0, s1, s2, s3, s4, s5, s6, s7, s8); -} - -[RootSignature(PostEffects_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID ) -{ - // - // Load 4 pixels per thread into LDS - // - int2 GroupUL = (Gid.xy << 3) - 4; // Upper-left pixel coordinate of group read location - int2 ThreadUL = (GTid.xy << 1) + GroupUL; // Upper-left pixel coordinate of quad that this thread will read - - // - // Store 4 unblurred pixels in LDS - // - int destIdx = GTid.x + (GTid.y << 4); - Store2Pixels(destIdx+0, InputBuf[ThreadUL + uint2(0, 0)], InputBuf[ThreadUL + uint2(1, 0)]); - Store2Pixels(destIdx+8, InputBuf[ThreadUL + uint2(0, 1)], InputBuf[ThreadUL + uint2(1, 1)]); - - GroupMemoryBarrierWithGroupSync(); - - // - // Horizontally blur the pixels in Cache - // - uint row = GTid.y << 4; - BlurHorizontally(row + (GTid.x << 1), row + GTid.x + (GTid.x & 4)); - - GroupMemoryBarrierWithGroupSync(); - - // - // Vertically blur the pixels and write the result to memory - // - BlurVertically(DTid.xy, (GTid.y << 3) + GTid.x); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BoundNeighborhoodCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/BoundNeighborhoodCS.hlsl deleted file mode 100644 index 024382c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BoundNeighborhoodCS.hlsl +++ /dev/null @@ -1,91 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "CommonRS.hlsli" - -Texture2D InputColor : register(t0); -RWTexture2D OutMin : register(u0); -RWTexture2D OutMax : register(u1); - -#define BORDER_SIZE 1 -#define GROUP_SIZE_X 8 -#define GROUP_SIZE_Y 8 -#define GROUP_SIZE (GROUP_SIZE_X * GROUP_SIZE_Y) -#define TILE_SIZE_X (GROUP_SIZE_X + 2 * BORDER_SIZE) -#define TILE_SIZE_Y (GROUP_SIZE_Y + 2 * BORDER_SIZE) -#define TILE_PIXEL_COUNT (TILE_SIZE_X * TILE_SIZE_Y) - -groupshared float gs_MinR[TILE_PIXEL_COUNT]; -groupshared float gs_MinG[TILE_PIXEL_COUNT]; -groupshared float gs_MinB[TILE_PIXEL_COUNT]; -groupshared float gs_MaxR[TILE_PIXEL_COUNT]; -groupshared float gs_MaxG[TILE_PIXEL_COUNT]; -groupshared float gs_MaxB[TILE_PIXEL_COUNT]; - -void ConvolveH( uint Idx ) -{ - gs_MinR[Idx] = min(min(gs_MinR[Idx - 1], gs_MinR[Idx]), gs_MinR[Idx + 1]); - gs_MinG[Idx] = min(min(gs_MinG[Idx - 1], gs_MinG[Idx]), gs_MinG[Idx + 1]); - gs_MinB[Idx] = min(min(gs_MinB[Idx - 1], gs_MinB[Idx]), gs_MinB[Idx + 1]); - gs_MaxR[Idx] = max(max(gs_MaxR[Idx - 1], gs_MaxR[Idx]), gs_MaxR[Idx + 1]); - gs_MaxG[Idx] = max(max(gs_MaxG[Idx - 1], gs_MaxG[Idx]), gs_MaxG[Idx + 1]); - gs_MaxB[Idx] = max(max(gs_MaxB[Idx - 1], gs_MaxB[Idx]), gs_MaxB[Idx + 1]); -} - -void ConvolveV( uint Idx, uint2 st ) -{ - float minR = min(min(gs_MinR[Idx - TILE_SIZE_X], gs_MinR[Idx]), gs_MinR[Idx + TILE_SIZE_X]); - float minG = min(min(gs_MinG[Idx - TILE_SIZE_X], gs_MinG[Idx]), gs_MinG[Idx + TILE_SIZE_X]); - float minB = min(min(gs_MinB[Idx - TILE_SIZE_X], gs_MinB[Idx]), gs_MinB[Idx + TILE_SIZE_X]); - OutMin[st] = float3(minR, minG, minB); - - float maxR = max(max(gs_MaxR[Idx - TILE_SIZE_X], gs_MaxR[Idx]), gs_MaxR[Idx + TILE_SIZE_X]); - float maxG = max(max(gs_MaxG[Idx - TILE_SIZE_X], gs_MaxG[Idx]), gs_MaxG[Idx + TILE_SIZE_X]); - float maxB = max(max(gs_MaxB[Idx - TILE_SIZE_X], gs_MaxB[Idx]), gs_MaxB[Idx + TILE_SIZE_X]); - OutMax[st] = float3(maxR, maxG, maxB); -} - -[RootSignature(Common_RootSig)] -[numthreads( GROUP_SIZE_X, GROUP_SIZE_Y, 1 )] -void main( uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID, uint GI : SV_GroupIndex ) -{ - // Load tile pixels - - int2 GroupUL = Gid.xy * uint2(GROUP_SIZE_X, GROUP_SIZE_Y) - BORDER_SIZE; - for (uint i = GI; i < TILE_PIXEL_COUNT; i += GROUP_SIZE) - { - float3 Color = InputColor[GroupUL + uint2(i % TILE_SIZE_X, i / TILE_SIZE_X)]; - gs_MinR[i] = gs_MaxR[i] = Color.r; - gs_MinG[i] = gs_MaxG[i] = Color.g; - gs_MinB[i] = gs_MaxB[i] = Color.b; - } - - GroupMemoryBarrierWithGroupSync(); - - uint Idx = (GTid.x + BORDER_SIZE) + (GTid.y + BORDER_SIZE) * TILE_SIZE_X; - - float R0 = gs_MinR[Idx], R1 = gs_MinR[Idx - 1], R2 = gs_MinR[Idx + 1], R3 = gs_MinR[Idx - TILE_SIZE_X], R4 = gs_MinR[Idx + TILE_SIZE_X]; - float minR = min(min(R0, R1), min(min(R2, R3), R4)); - float maxR = max(max(R0, R1), max(max(R2, R3), R4)); - - float G0 = gs_MinG[Idx], G1 = gs_MinG[Idx - 1], G2 = gs_MinG[Idx + 1], G3 = gs_MinG[Idx - TILE_SIZE_X], G4 = gs_MinG[Idx + TILE_SIZE_X]; - float minG = min(min(G0, G1), min(min(G2, G3), G4)); - float maxG = max(max(G0, G1), max(max(G2, G3), G4)); - - float B0 = gs_MinB[Idx], B1 = gs_MinB[Idx - 1], B2 = gs_MinB[Idx + 1], B3 = gs_MinB[Idx - TILE_SIZE_X], B4 = gs_MinB[Idx + TILE_SIZE_X]; - float minB = min(min(B0, B1), min(min(B2, B3), B4)); - float maxB = max(max(B0, B1), max(max(B2, B3), B4)); - - OutMin[DTid.xy] = float3(minR, minG, minB); - OutMax[DTid.xy] = float3(maxR, maxG, maxB); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BufferCopyPS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/BufferCopyPS.hlsl deleted file mode 100644 index 2fe00f1..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/BufferCopyPS.hlsl +++ /dev/null @@ -1,30 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "PresentRS.hlsli" - -Texture2D ColorTex : register(t0); -SamplerState BilinearSampler : register(s0); - -cbuffer Constants : register(b0) -{ - float2 RcpDestDim; -} - -[RootSignature(Present_RootSig)] -float4 main( float4 position : SV_Position ) : SV_Target0 -{ - //float2 UV = saturate(RcpDestDim * position.xy); - //return ColorTex.SampleLevel(BilinearSampler, UV, 0); - return ColorTex[(int2)position.xy]; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/CameraMotionBlurPrePassCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/CameraMotionBlurPrePassCS.hlsl deleted file mode 100644 index cb19f31..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/CameraMotionBlurPrePassCS.hlsl +++ /dev/null @@ -1,72 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "CommonRS.hlsli" -#include "PixelPacking_Velocity.hlsli" - -// We can use the original depth buffer or a linearized one. In this case, we use linear Z because -// we have discarded the 32-bit depth buffer but still retain a 16-bit linear buffer (previously -// used by SSAO.) Note that hyperbolic Z is reversed by default (TBD) for increased precision, so -// its Z=0 maps to the far plane. With linear Z, Z=0 maps to the eye position. Both extend to Z=1. - -//#define USE_LINEAR_Z - -Texture2D ColorBuffer : register(t0); -Texture2D DepthBuffer : register(t1); -RWTexture2D PrepBuffer : register(u0); -RWTexture2D VelocityBuffer : register(u1); - -cbuffer CB1 : register(b1) -{ - matrix CurToPrevXForm; -} - -float4 GetSampleData( uint2 st ) -{ - float2 CurPixel = st + 0.5; - float Depth = DepthBuffer[st]; -#ifdef USE_LINEAR_Z - float4 HPos = float4( CurPixel * Depth, 1.0, Depth ); -#else - float4 HPos = float4( CurPixel, Depth, 1.0 ); -#endif - float4 PrevHPos = mul( CurToPrevXForm, HPos ); - - PrevHPos.xyz /= PrevHPos.w; - -#ifdef USE_LINEAR_Z - PrevHPos.z = PrevHPos.w; -#endif - - float3 Velocity = PrevHPos.xyz - float3(CurPixel, Depth); - - VelocityBuffer[st] = PackVelocity(Velocity); - - // Clamp speed at 4 pixels and normalize it. - return float4(ColorBuffer[st], 1.0) * saturate(length(Velocity.xy) / 4); -} - -[RootSignature(Common_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID ) -{ - uint2 corner = DTid.xy << 1; - float4 sample0 = GetSampleData( corner + uint2(0, 0) ); - float4 sample1 = GetSampleData( corner + uint2(1, 0) ); - float4 sample2 = GetSampleData( corner + uint2(0, 1) ); - float4 sample3 = GetSampleData( corner + uint2(1, 1) ); - - float combinedMotionWeight = sample0.a + sample1.a + sample2.a + sample3.a; - PrepBuffer[DTid.xy] = floor(0.25 * combinedMotionWeight * 3.0) / 3.0 * float4( - (sample0.rgb + sample1.rgb + sample2.rgb + sample3.rgb) / combinedMotionWeight, 1.0 ); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/CameraMotionBlurPrePassLinearZCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/CameraMotionBlurPrePassLinearZCS.hlsl deleted file mode 100644 index 6f51751..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/CameraMotionBlurPrePassLinearZCS.hlsl +++ /dev/null @@ -1,14 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard - -#define USE_LINEAR_Z -#include "CameraMotionBlurPrePassCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/CameraVelocityCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/CameraVelocityCS.hlsl deleted file mode 100644 index 444145d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/CameraVelocityCS.hlsl +++ /dev/null @@ -1,52 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "CommonRS.hlsli" -#include "PixelPacking_Velocity.hlsli" - -// We can use the original depth buffer or a linearized one. In this case, we use linear Z because -// we have discarded the 32-bit depth buffer but still retain a 16-bit linear buffer (previously -// used by SSAO.) Note that hyperbolic Z is reversed by default (TBD) for increased precision, so -// its Z=0 maps to the far plane. With linear Z, Z=0 maps to the eye position. Both extend to Z=1. -#define USE_LINEAR_Z - -Texture2D DepthBuffer : register(t0); -RWTexture2D VelocityBuffer : register(u0); - -cbuffer CBuffer : register(b1) -{ - matrix CurToPrevXForm; -} - -[RootSignature(Common_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 DTid : SV_DispatchThreadID ) -{ - uint2 st = DTid.xy; - float2 CurPixel = st + 0.5; - float Depth = DepthBuffer[st]; -#ifdef USE_LINEAR_Z - float4 HPos = float4( CurPixel * Depth, 1.0, Depth ); -#else - float4 HPos = float4( CurPixel, Depth, 1.0 ); -#endif - float4 PrevHPos = mul( CurToPrevXForm, HPos ); - - PrevHPos.xyz /= PrevHPos.w; - -#ifdef USE_LINEAR_Z - PrevHPos.z = PrevHPos.w; -#endif - - VelocityBuffer[st] = PackVelocity(PrevHPos.xyz - float3(CurPixel, Depth)); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ColorSpaceUtility.hlsli b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ColorSpaceUtility.hlsli deleted file mode 100644 index 3024a9d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ColorSpaceUtility.hlsli +++ /dev/null @@ -1,164 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma warning( disable : 3571 ) - -#ifndef __COLOR_SPACE_UTILITY_HLSLI__ -#define __COLOR_SPACE_UTILITY_HLSLI__ - -// -// Gamma ramps and encoding transfer functions -// -// Orthogonal to color space though usually tightly coupled. For instance, sRGB is both a -// color space (defined by three basis vectors and a white point) and a gamma ramp. Gamma -// ramps are designed to reduce perceptual error when quantizing floats to integers with a -// limited number of bits. More variation is needed in darker colors because our eyes are -// more sensitive in the dark. The way the curve helps is that it spreads out dark values -// across more code words allowing for more variation. Likewise, bright values are merged -// together into fewer code words allowing for less variation. -// -// The sRGB curve is not a true gamma ramp but rather a piecewise function comprising a linear -// section and a power function. When sRGB-encoded colors are passed to an LCD monitor, they -// look correct on screen because the monitor expects the colors to be encoded with sRGB, and it -// removes the sRGB curve to linearize the values. When textures are encoded with sRGB--as many -// are--the sRGB curve needs to be removed before involving the colors in linear mathematics such -// as physically based lighting. - -float3 ApplySRGBCurve( float3 x ) -{ - // Approximately pow(x, 1.0 / 2.2) - return x < 0.0031308 ? 12.92 * x : 1.055 * pow(x, 1.0 / 2.4) - 0.055; -} - -float3 RemoveSRGBCurve( float3 x ) -{ - // Approximately pow(x, 2.2) - return x < 0.04045 ? x / 12.92 : pow( (x + 0.055) / 1.055, 2.4 ); -} - -// These functions avoid pow() to efficiently approximate sRGB with an error < 0.4%. -float3 ApplySRGBCurve_Fast( float3 x ) -{ - return x < 0.0031308 ? 12.92 * x : 1.13005 * sqrt(x - 0.00228) - 0.13448 * x + 0.005719; -} - -float3 RemoveSRGBCurve_Fast( float3 x ) -{ - return x < 0.04045 ? x / 12.92 : -7.43605 * x - 31.24297 * sqrt(-0.53792 * x + 1.279924) + 35.34864; -} - -// The OETF recommended for content shown on HDTVs. This "gamma ramp" may increase contrast as -// appropriate for viewing in a dark environment. Always use this curve with Limited RGB as it is -// used in conjunction with HDTVs. -float3 ApplyREC709Curve( float3 x ) -{ - return x < 0.0181 ? 4.5 * x : 1.0993 * pow(x, 0.45) - 0.0993; -} - -float3 RemoveREC709Curve( float3 x ) -{ - return x < 0.08145 ? x / 4.5 : pow((x + 0.0993) / 1.0993, 1.0 / 0.45); -} - -// This is the new HDR transfer function, also called "PQ" for perceptual quantizer. Note that REC2084 -// does not also refer to a color space. REC2084 is typically used with the REC2020 color space. -float3 ApplyREC2084Curve(float3 L) -{ - float m1 = 2610.0 / 4096.0 / 4; - float m2 = 2523.0 / 4096.0 * 128; - float c1 = 3424.0 / 4096.0; - float c2 = 2413.0 / 4096.0 * 32; - float c3 = 2392.0 / 4096.0 * 32; - float3 Lp = pow(L, m1); - return pow((c1 + c2 * Lp) / (1 + c3 * Lp), m2); -} - -float3 RemoveREC2084Curve(float3 N) -{ - float m1 = 2610.0 / 4096.0 / 4; - float m2 = 2523.0 / 4096.0 * 128; - float c1 = 3424.0 / 4096.0; - float c2 = 2413.0 / 4096.0 * 32; - float c3 = 2392.0 / 4096.0 * 32; - float3 Np = pow(N, 1 / m2); - return pow(max(Np - c1, 0) / (c2 - c3 * Np), 1 / m1); -} - -// -// Color space conversions -// -// These assume linear (not gamma-encoded) values. A color space conversion is a change -// of basis (like in Linear Algebra). Since a color space is defined by three vectors-- -// the basis vectors--changing space involves a matrix-vector multiplication. Note that -// changing the color space may result in colors that are "out of bounds" because some -// color spaces have larger gamuts than others. When converting some colors from a wide -// gamut to small gamut, negative values may result, which are inexpressible in that new -// color space. -// -// It would be ideal to build a color pipeline which never throws away inexpressible (but -// perceivable) colors. This means using a color space that is as wide as possible. The -// XYZ color space is the neutral, all-encompassing color space, but it has the unfortunate -// property of having negative values (specifically in X and Z). To correct this, a further -// transformation can be made to X and Z to make them always positive. They can have their -// precision needs reduced by dividing by Y, allowing X and Z to be packed into two UNORM8s. -// This color space is called YUV for lack of a better name. -// - -// Note: Rec.709 and sRGB share the same color primaries and white point. Their only difference -// is the transfer curve used. - -float3 REC709toREC2020( float3 RGB709 ) -{ - static const float3x3 ConvMat = - { - 0.627402, 0.329292, 0.043306, - 0.069095, 0.919544, 0.011360, - 0.016394, 0.088028, 0.895578 - }; - return mul(ConvMat, RGB709); -} - -float3 REC2020toREC709(float3 RGB2020) -{ - static const float3x3 ConvMat = - { - 1.660496, -0.587656, -0.072840, - -0.124547, 1.132895, -0.008348, - -0.018154, -0.100597, 1.118751 - }; - return mul(ConvMat, RGB2020); -} - -float3 REC709toDCIP3( float3 RGB709 ) -{ - static const float3x3 ConvMat = - { - 0.822458, 0.177542, 0.000000, - 0.033193, 0.966807, 0.000000, - 0.017085, 0.072410, 0.910505 - }; - return mul(ConvMat, RGB709); -} - -float3 DCIP3toREC709( float3 RGBP3 ) -{ - static const float3x3 ConvMat = - { - 1.224947, -0.224947, 0.000000, - -0.042056, 1.042056, 0.000000, - -0.019641, -0.078651, 1.098291 - }; - return mul(ConvMat, RGBP3); -} - -#endif // __COLOR_SPACE_UTILITY_HLSLI__ diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/CommonRS.hlsli b/xess/samples/xess_demo/MiniEngine/Core/Shaders/CommonRS.hlsli deleted file mode 100644 index 1764a79..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/CommonRS.hlsli +++ /dev/null @@ -1,41 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define Common_RootSig \ - "RootFlags(0), " \ - "RootConstants(b0, num32BitConstants = 4)," \ - "DescriptorTable(SRV(t0, numDescriptors = 10))," \ - "DescriptorTable(UAV(u0, numDescriptors = 10))," \ - "CBV(b1), " \ - "StaticSampler(s0," \ - "addressU = TEXTURE_ADDRESS_CLAMP," \ - "addressV = TEXTURE_ADDRESS_CLAMP," \ - "addressW = TEXTURE_ADDRESS_CLAMP," \ - "filter = FILTER_MIN_MAG_MIP_LINEAR)," \ - "StaticSampler(s1," \ - "addressU = TEXTURE_ADDRESS_BORDER," \ - "addressV = TEXTURE_ADDRESS_BORDER," \ - "addressW = TEXTURE_ADDRESS_BORDER," \ - "borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK," \ - "filter = FILTER_MIN_MAG_MIP_POINT)," \ - "StaticSampler(s2," \ - "addressU = TEXTURE_ADDRESS_BORDER," \ - "addressV = TEXTURE_ADDRESS_BORDER," \ - "addressW = TEXTURE_ADDRESS_BORDER," \ - "borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK," \ - "filter = FILTER_MIN_MAG_MIP_LINEAR)," \ - "StaticSampler(s3," \ - "addressU = TEXTURE_ADDRESS_CLAMP," \ - "addressV = TEXTURE_ADDRESS_CLAMP," \ - "addressW = TEXTURE_ADDRESS_CLAMP," \ - "filter = FILTER_MIN_MAG_MIP_POINT)" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/CompositeHDRPS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/CompositeHDRPS.hlsl deleted file mode 100644 index 64eb92b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/CompositeHDRPS.hlsl +++ /dev/null @@ -1,40 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "ToneMappingUtility.hlsli" -#include "PresentRS.hlsli" - -Texture2D MainBuffer : register(t0); -Texture2D OverlayBuffer : register(t1); - -cbuffer CB0 : register(b0) -{ - float PaperWhiteRatio; // PaperWhite / 10000.0 - float MaxBrightness; -} - -[RootSignature(Present_RootSig)] -float3 main( float4 position : SV_Position, float2 uv : TexCoord0 ) : SV_Target0 -{ - int2 ST = (int2)position.xy; - - float3 MainColor = ApplyREC2084Curve(MainBuffer[ST] / 10000.0); - - float4 OverlayColor = OverlayBuffer[ST]; - - OverlayColor.rgb = RemoveSRGBCurve(OverlayColor.rgb); - OverlayColor.rgb = REC709toREC2020(OverlayColor.rgb / (OverlayColor.a == 0.0 ? 1.0 : OverlayColor.a)); - OverlayColor.rgb = ApplyREC2084Curve(OverlayColor.rgb * PaperWhiteRatio); - - return lerp(MainColor, OverlayColor.rgb, OverlayColor.a); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/CompositeSDRPS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/CompositeSDRPS.hlsl deleted file mode 100644 index af53390..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/CompositeSDRPS.hlsl +++ /dev/null @@ -1,26 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "ShaderUtility.hlsli" -#include "PresentRS.hlsli" - -Texture2D MainBuffer : register(t0); -Texture2D OverlayBuffer : register(t1); - -[RootSignature(Present_RootSig)] -float3 main( float4 position : SV_Position ) : SV_Target0 -{ - float3 MainColor = ApplyDisplayProfile(MainBuffer[(int2)position.xy], DISPLAY_PLANE_FORMAT); - float4 OverlayColor = OverlayBuffer[(int2)position.xy]; - return OverlayColor.rgb + MainColor.rgb * (1.0 - OverlayColor.a); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/CopyBackPostBufferCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/CopyBackPostBufferCS.hlsl deleted file mode 100644 index 7480afe..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/CopyBackPostBufferCS.hlsl +++ /dev/null @@ -1,25 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "PostEffectsRS.hlsli" -#include "PixelPacking.hlsli" - -RWTexture2D SceneColor : register( u0 ); -Texture2D PostBuffer : register( t0 ); - -[RootSignature(PostEffects_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 DTid : SV_DispatchThreadID ) -{ - SceneColor[DTid.xy] = Unpack_R11G11B10_FLOAT(PostBuffer[DTid.xy]); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DebugDrawHistogramCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DebugDrawHistogramCS.hlsl deleted file mode 100644 index a9813fa..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DebugDrawHistogramCS.hlsl +++ /dev/null @@ -1,71 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "PostEffectsRS.hlsli" - -ByteAddressBuffer Histogram : register( t0 ); -StructuredBuffer Exposure : register( t1 ); -RWTexture2D ColorBuffer : register( u0 ); - -groupshared uint gs_hist[256]; - -[RootSignature(PostEffects_RootSig)] -[numthreads( 256, 1, 1 )] -void main( uint GI : SV_GroupIndex, uint3 DTid : SV_DispatchThreadID ) -{ - uint histValue = Histogram.Load(GI * 4); - - // Compute the maximum histogram value, but don't include the black pixel - gs_hist[GI] = GI == 0 ? 0 : histValue; - GroupMemoryBarrierWithGroupSync(); - gs_hist[GI] = max(gs_hist[GI], gs_hist[(GI + 128) % 256]); - GroupMemoryBarrierWithGroupSync(); - gs_hist[GI] = max(gs_hist[GI], gs_hist[(GI + 64) % 256]); - GroupMemoryBarrierWithGroupSync(); - gs_hist[GI] = max(gs_hist[GI], gs_hist[(GI + 32) % 256]); - GroupMemoryBarrierWithGroupSync(); - gs_hist[GI] = max(gs_hist[GI], gs_hist[(GI + 16) % 256]); - GroupMemoryBarrierWithGroupSync(); - gs_hist[GI] = max(gs_hist[GI], gs_hist[(GI + 8) % 256]); - GroupMemoryBarrierWithGroupSync(); - gs_hist[GI] = max(gs_hist[GI], gs_hist[(GI + 4) % 256]); - GroupMemoryBarrierWithGroupSync(); - gs_hist[GI] = max(gs_hist[GI], gs_hist[(GI + 2) % 256]); - GroupMemoryBarrierWithGroupSync(); - gs_hist[GI] = max(gs_hist[GI], gs_hist[(GI + 1) % 256]); - GroupMemoryBarrierWithGroupSync(); - - uint maxHistValue = gs_hist[GI]; - - uint2 BufferDim; - ColorBuffer.GetDimensions(BufferDim.x, BufferDim.y); - - const uint2 RectCorner = uint2(BufferDim.x / 2 - 512, BufferDim.y - 256); - const uint2 GroupCorner = RectCorner + DTid.xy * 4; - - uint height = 127 - DTid.y * 4; - uint threshold = histValue * 128 / max(1, maxHistValue); - - float3 OutColor = (GI == (uint)Exposure[3]) ? float3(1.0, 1.0, 0.0) : float3(0.5, 0.5, 0.5); - - for (uint i = 0; i < 4; ++i) - { - float3 MaskedColor = (height - i) < threshold ? OutColor : float3(0, 0, 0); - - // 4-wide column with 2 pixels for the histogram bar and 2 for black spacing - ColorBuffer[GroupCorner + uint2(0, i)] = MaskedColor; - ColorBuffer[GroupCorner + uint2(1, i)] = MaskedColor; - ColorBuffer[GroupCorner + uint2(2, i)] = float3(0, 0, 0); - ColorBuffer[GroupCorner + uint2(3, i)] = float3(0, 0, 0); - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DebugLuminanceHdr2CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DebugLuminanceHdr2CS.hlsl deleted file mode 100644 index 98f5679..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DebugLuminanceHdr2CS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define SUPPORT_TYPED_UAV_LOADS 1 -#include "DebugLuminanceHdrCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DebugLuminanceHdrCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DebugLuminanceHdrCS.hlsl deleted file mode 100644 index 182961a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DebugLuminanceHdrCS.hlsl +++ /dev/null @@ -1,55 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "ToneMappingUtility.hlsli" -#include "PostEffectsRS.hlsli" -#include "PixelPacking.hlsli" - -StructuredBuffer Exposure : register(t0); -Texture2D Bloom : register(t1); -#if SUPPORT_TYPED_UAV_LOADS -RWTexture2D SrcColor : register(u0); -#else -RWTexture2D DstColor : register(u0); -Texture2D SrcColor : register(t2); -#endif -RWTexture2D OutLuma : register(u1); -SamplerState LinearSampler : register( s0 ); - -cbuffer CB0 : register(b0) -{ - float2 g_RcpBufferDim; - float g_BloomStrength; -}; - -[RootSignature(PostEffects_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 DTid : SV_DispatchThreadID ) -{ - float2 TexCoord = (DTid.xy + 0.5) * g_RcpBufferDim; - - // Load HDR and bloom - float3 hdrColor = SrcColor[DTid.xy] + g_BloomStrength * Bloom.SampleLevel(LinearSampler, TexCoord, 0); - - // Tone map to LDR and convert to greyscale - float luma = ToneMapLuma(RGBToLuminance(hdrColor) * Exposure[0]); - - float logLuma = LinearToLogLuminance(luma); - -#if SUPPORT_TYPED_UAV_LOADS - SrcColor[DTid.xy] = luma.xxx; -#else - DstColor[DTid.xy] = Pack_R11G11B10_FLOAT(luma.xxx); -#endif - OutLuma[DTid.xy] = logLuma; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DebugLuminanceLdr2CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DebugLuminanceLdr2CS.hlsl deleted file mode 100644 index de910e0..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DebugLuminanceLdr2CS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define SUPPORT_TYPED_UAV_LOADS 1 -#include "DebugLuminanceLdrCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DebugLuminanceLdrCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DebugLuminanceLdrCS.hlsl deleted file mode 100644 index 9701288..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DebugLuminanceLdrCS.hlsl +++ /dev/null @@ -1,56 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "ShaderUtility.hlsli" -#include "PostEffectsRS.hlsli" -#include "PixelPacking.hlsli" - -Texture2D Bloom : register( t0 ); -#if SUPPORT_TYPED_UAV_LOADS -RWTexture2D SrcColor : register(u0); -#else -RWTexture2D DstColor : register(u0); -Texture2D SrcColor : register(t2); -#endif -RWTexture2D OutLuma : register(u1); -SamplerState LinearSampler : register( s0 ); - -cbuffer CB0 : register(b0) -{ - float2 g_RcpBufferDim; - float g_BloomStrength; -}; - -[RootSignature(PostEffects_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 DTid : SV_DispatchThreadID ) -{ - float2 TexCoord = (DTid.xy + 0.5) * g_RcpBufferDim; - - // Load LDR and bloom - float3 ldrColor = SrcColor[DTid.xy]; - - ldrColor += g_BloomStrength * Bloom.SampleLevel(LinearSampler, TexCoord, 0); - - // Load LDR value from HDR buffer - float luma = RGBToLuminance( ldrColor ); - - float logLuma = LinearToLogLuminance(luma); - -#if SUPPORT_TYPED_UAV_LOADS - SrcColor[DTid.xy] = luma.xxx; -#else - DstColor[DTid.xy] = Pack_R11G11B10_FLOAT(luma.xxx); -#endif - OutLuma[DTid.xy] = logLuma; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DebugSSAOCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DebugSSAOCS.hlsl deleted file mode 100644 index 8d4c8cb..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DebugSSAOCS.hlsl +++ /dev/null @@ -1,24 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "SSAORS.hlsli" - -Texture2D SsaoBuffer : register( t0 ); -RWTexture2D OutColor : register( u0 ); - -[RootSignature(SSAO_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 DTid : SV_DispatchThreadID ) -{ - OutColor[DTid.xy] = SsaoBuffer[DTid.xy].xxx; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFCombine2CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFCombine2CS.hlsl deleted file mode 100644 index 2fc6354..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFCombine2CS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define SUPPORT_TYPED_UAV_LOADS 1 -#include "DoFCombineCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFCombineCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFCombineCS.hlsl deleted file mode 100644 index 322084a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFCombineCS.hlsl +++ /dev/null @@ -1,51 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "DoFCommon.hlsli" -#include "PixelPacking.hlsli" - -Texture2D DoFColorBuffer : register(t0); -Texture2D DoFAlphaBuffer : register(t1); -Texture2D TileClass : register(t2); -Texture2D LNFullDepth : register(t3); -StructuredBuffer WorkQueue : register(t4); -#if SUPPORT_TYPED_UAV_LOADS - RWTexture2D DstColor : register(u0); -#else - RWTexture2D DstColor : register(u0); -#endif - -[RootSignature(DoF_RootSig)] -[numthreads( 16, 16, 1 )] -void main( uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID ) -{ - uint TileCoord = WorkQueue[Gid.x]; - uint2 Tile = uint2(TileCoord & 0xFFFF, TileCoord >> 16); - uint2 st = Tile * 16 + GTid.xy; - - float2 UV = (st + 0.5) * RcpBufferDim; - float Depth = LNFullDepth[st]; - float3 DoFColor = DoFColorBuffer.SampleLevel(BilinearSampler, UV, 0); - float FgAlpha = DoFAlphaBuffer.SampleLevel(BilinearSampler, UV, 0); - - float TileMinDepth = TileClass[Tile].y; - float BgPercent = BackgroundPercent(Depth, TileMinDepth); - float PixelBlurriness = saturate((ComputeCoC(Depth) - 1.0) / 1.5); - float CombinedFactor = lerp(PixelBlurriness, lerp(FgAlpha, 1.0, PixelBlurriness), BgPercent); - -#if SUPPORT_TYPED_UAV_LOADS - DstColor[st] = lerp(DstColor[st], DoFColor, CombinedFactor); -#else - DstColor[st] = Pack_R11G11B10_FLOAT(lerp(Unpack_R11G11B10_FLOAT(DstColor[st]), DoFColor, CombinedFactor)); -#endif -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFCombineFast2CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFCombineFast2CS.hlsl deleted file mode 100644 index 50744bd..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFCombineFast2CS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define SUPPORT_TYPED_UAV_LOADS 1 -#include "DoFCombineFastCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFCombineFastCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFCombineFastCS.hlsl deleted file mode 100644 index 322084a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFCombineFastCS.hlsl +++ /dev/null @@ -1,51 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "DoFCommon.hlsli" -#include "PixelPacking.hlsli" - -Texture2D DoFColorBuffer : register(t0); -Texture2D DoFAlphaBuffer : register(t1); -Texture2D TileClass : register(t2); -Texture2D LNFullDepth : register(t3); -StructuredBuffer WorkQueue : register(t4); -#if SUPPORT_TYPED_UAV_LOADS - RWTexture2D DstColor : register(u0); -#else - RWTexture2D DstColor : register(u0); -#endif - -[RootSignature(DoF_RootSig)] -[numthreads( 16, 16, 1 )] -void main( uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID ) -{ - uint TileCoord = WorkQueue[Gid.x]; - uint2 Tile = uint2(TileCoord & 0xFFFF, TileCoord >> 16); - uint2 st = Tile * 16 + GTid.xy; - - float2 UV = (st + 0.5) * RcpBufferDim; - float Depth = LNFullDepth[st]; - float3 DoFColor = DoFColorBuffer.SampleLevel(BilinearSampler, UV, 0); - float FgAlpha = DoFAlphaBuffer.SampleLevel(BilinearSampler, UV, 0); - - float TileMinDepth = TileClass[Tile].y; - float BgPercent = BackgroundPercent(Depth, TileMinDepth); - float PixelBlurriness = saturate((ComputeCoC(Depth) - 1.0) / 1.5); - float CombinedFactor = lerp(PixelBlurriness, lerp(FgAlpha, 1.0, PixelBlurriness), BgPercent); - -#if SUPPORT_TYPED_UAV_LOADS - DstColor[st] = lerp(DstColor[st], DoFColor, CombinedFactor); -#else - DstColor[st] = Pack_R11G11B10_FLOAT(lerp(Unpack_R11G11B10_FLOAT(DstColor[st]), DoFColor, CombinedFactor)); -#endif -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFCommon.hlsli b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFCommon.hlsli deleted file mode 100644 index f8ee046..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFCommon.hlsli +++ /dev/null @@ -1,164 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "DoFRS.hlsli" - -#define USE_LINEAR_Z 1 - -SamplerState PointSampler : register(s0); -SamplerState ClampSampler : register(s1); -SamplerState BilinearSampler: register(s2); - -cbuffer CB0 : register(b0) -{ - float FocusCenter; - float FocalSpread; - float FocalMinDist; // Closer than this is max blurriness - float FocalMaxDist; // Farther than this is also max blurriness - float2 RcpBufferDim; - uint2 FullDimension; - int2 HalfDimensionMinusOne; - uint2 TiledDimension; - float2 InvTiledDimension; - uint DebugMode; - uint DisablePreFilter; - float ForegroundRange; - float RcpForegroundRange; - float AntiSparkleFilterStrength; -} - -#define DEPTH_FOREGROUND_RANGE 0.01 -#define MATH_CONST_PI 3.1415926535897 -#define MAX_COC_RADIUS 16.0 -#define RING1_THRESHOLD 1.0 -#define RING2_THRESHOLD 6.0 -#define RING3_THRESHOLD 11.0 - -float Max3( float a, float b, float c) { return max(max(a, b), c); } -float Min3( float a, float b, float c) { return min(min(a, b), c); } -float Med3( float a, float b, float c) { return clamp(a, min(b, c), max(b, c)); } -float Max4( float a, float b, float c, float d) { return Max3(a, b, max(c, d)); } -float Min4( float a, float b, float c, float d) { return Min3(a, b, min(c, d)); } -float Max4( float4 vec ) { return Max4( vec.x, vec.y, vec.z, vec.w ); } -float Min4( float4 vec ) { return Min4( vec.x, vec.y, vec.z, vec.w ); } - -float ComputeCoC( float Depth ) -{ - return max(1.0 / sqrt(MATH_CONST_PI), MAX_COC_RADIUS * saturate( abs(Depth - FocusCenter) * FocalSpread )); -} - -float ComputeSignedCoC( float Depth ) -{ - return ComputeCoC(Depth) * sign(Depth - FocusCenter); -} - -float BackgroundPercent( float Depth, float TileMinDepth ) -{ - return saturate((Depth - TileMinDepth) * RcpForegroundRange - 1.0); -} - -float ForegroundPercent( float Depth, float TileMinDepth ) -{ - return 1.0 - BackgroundPercent(Depth, TileMinDepth); -} - -float2 DepthCmp2( float Depth, float TileMinDepth ) -{ - float depthCmp = BackgroundPercent(Depth, TileMinDepth); - return float2(depthCmp, 1.0 - depthCmp); -} - -float SampleAlpha( float CoC ) -{ - return rcp(MATH_CONST_PI * CoC * CoC); -} - -float ComputeRenormalizationFactor( float ForegroundDepth, float MaxCoC ) -{ - float FgCoC = ComputeCoC(ForegroundDepth); - float Rings = (FgCoC - 1) / 5; - float NumSamples = 1 + saturate(Rings) * 8 + saturate(Rings - 1) * 16 + saturate(Rings - 2) * 24; - return 2.0 * MATH_CONST_PI * FgCoC * FgCoC / NumSamples; -} - -static const float2 s_Ring1[8] = -{ - { 6.000000, 0.000000 }, { -6.000000, -0.000000 }, - { 4.242641, 4.242641 }, { -4.242641, -4.242641 }, - { 0.000000, 6.000000 }, { -0.000000, -6.000000 }, - { -4.242641, 4.242641 }, { 4.242641, -4.242641 }, -}; // s_Ring1 - -static const float2 s_Ring2[16] = -{ - { 11.000000, 0.000000 }, { -11.000000, -0.000000 }, - { 10.162675, 4.209518 }, { -10.162675, -4.209518 }, - { 7.778175, 7.778175 }, { -7.778175, -7.778175 }, - { 4.209518, 10.162675 }, { -4.209518, -10.162675 }, - { 0.000000, 11.000000 }, { -0.000000, -11.000000 }, - { -4.209518, 10.162675 }, { 4.209518, -10.162675 }, - { -7.778175, 7.778175 }, { 7.778175, -7.778175 }, - { -10.162675, 4.209518 }, { 10.162675, -4.209518 }, -}; // s_Ring2 - -static const float2 s_Ring3[24] = -{ - { 16.000000, 0.000000 }, { -16.000000, -0.000000 }, - { 15.454813, 4.141105 }, { -15.454813, -4.141105 }, - { 13.856406, 8.000000 }, { -13.856406, -8.000000 }, - { 11.313708, 11.313708 }, { -11.313708, -11.313708 }, - { 8.000000, 13.856406 }, { -8.000000, -13.856406 }, - { 4.141105, 15.454813 }, { -4.141105, -15.454813 }, - { 0.000000, 16.000000 }, { -0.000000, -16.000000 }, - { -4.141105, 15.454813 }, { 4.141105, -15.454813 }, - { -8.000000, 13.856406 }, { 8.000000, -13.856406 }, - { -11.313708, 11.313708 }, { 11.313708, -11.313708 }, - { -13.856406, 8.000000 }, { 13.856406, -8.000000 }, - { -15.454813, 4.141105 }, { 15.454813, -4.141105 }, -}; // s_Ring3 - -static const int s_Ring1Q[8] = -{ - 3, -3, - 50, -50, - 72, -72, - 46, -46, -}; // s_Ring1Q - -static const int s_Ring2Q[16] = -{ - 6, -6, - 53, -53, - 100, -100, - 122, -122, - 144, -144, - 118, -118, - 92, -92, - 43, -43, -}; // s_Ring2Q - -static const int s_Ring3Q[24] = -{ - 8, -8, - 56, -56, - 103, -103, - 150, -150, - 172, -172, - 194, -194, - 192, -192, - 190, -190, - 164, -164, - 138, -138, - 89, -89, - 40, -40, -}; // s_Ring3Q diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFDebugBlueCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFDebugBlueCS.hlsl deleted file mode 100644 index 4977549..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFDebugBlueCS.hlsl +++ /dev/null @@ -1,28 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "DoFCommon.hlsli" - -StructuredBuffer WorkQueue : register(t5); -RWTexture2D DstColor : register(u0); - -[RootSignature(DoF_RootSig)] -[numthreads( 16, 16, 1 )] -void main( uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID ) -{ - uint TileCoord = WorkQueue[Gid.x]; - uint2 Tile = uint2(TileCoord & 0xFFFF, TileCoord >> 16); - uint2 st = Tile * 16 + GTid.xy; - - DstColor[st] = float3(0, 0, 1); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFDebugGreenCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFDebugGreenCS.hlsl deleted file mode 100644 index 609ca8a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFDebugGreenCS.hlsl +++ /dev/null @@ -1,28 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "DoFCommon.hlsli" - -StructuredBuffer WorkQueue : register(t5); -RWTexture2D DstColor : register(u0); - -[RootSignature(DoF_RootSig)] -[numthreads( 16, 16, 1 )] -void main( uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID ) -{ - uint TileCoord = WorkQueue[Gid.x]; - uint2 Tile = uint2(TileCoord & 0xFFFF, TileCoord >> 16); - uint2 st = Tile * 16 + GTid.xy; - - DstColor[st] = float3(0, 1, 0); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFDebugRedCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFDebugRedCS.hlsl deleted file mode 100644 index 201694d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFDebugRedCS.hlsl +++ /dev/null @@ -1,28 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "DoFCommon.hlsli" - -StructuredBuffer WorkQueue : register(t5); -RWTexture2D DstColor : register(u0); - -[RootSignature(DoF_RootSig)] -[numthreads( 16, 16, 1 )] -void main( uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID ) -{ - uint TileCoord = WorkQueue[Gid.x]; - uint2 Tile = uint2(TileCoord & 0xFFFF, TileCoord >> 16); - uint2 st = Tile * 16 + GTid.xy; - - DstColor[st] = float3(1, 0, 0); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFMedianFilterCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFMedianFilterCS.hlsl deleted file mode 100644 index d5ca9eb..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFMedianFilterCS.hlsl +++ /dev/null @@ -1,120 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "DoFCommon.hlsli" - -Texture2D InputColor : register(t0); -Texture2D InputAlpha : register(t1); -StructuredBuffer WorkQueue : register(t2); -RWTexture2D OutputColor : register(u0); -RWTexture2D OutputAlpha : register(u1); - -// This define will run a 3x3 median filter an all four channels separately. This is -// the slowest and probably not the most correct way to do things. -//#define PER_CHANNEL_MEDIAN - -// This enables separate 3x3 median filters on the luminance of the color and the alpha -// buffer. The color brightness is rescaled to the median luminance. This is faster -// than doing a median four separate channels, and it's potentially more correct because -// filtering R, G, and B separately will cause color shifts. -//#define LUMA_ALPHA_MEDIAN - -// The fastest and default option is to filter only the luminance. The four components -// will be selected from the pixel that had the median luminance. Luminance is not -// rescaled. The other code paths have been left in until it has been fully decided -// that they are unnecessary or wrong. - -groupshared uint gs_RG[100]; -groupshared float gs_L[100]; -#ifdef SEPARATE_ALPHA_MEDIAN -groupshared float gs_B[100]; -groupshared float gs_A[100]; -#else -groupshared uint gs_BA[100]; -#endif - -float Med9( float x0, float x1, float x2, - float x3, float x4, float x5, - float x6, float x7, float x8 ) -{ - float A = Max3(Min3(x0, x1, x2), Min3(x3, x4, x5), Min3(x6, x7, x8)); - float B = Min3(Max3(x0, x1, x2), Max3(x3, x4, x5), Max3(x6, x7, x8)); - float C = Med3(Med3(x0, x1, x2), Med3(x3, x4, x5), Med3(x6, x7, x8)); - return Med3(A, B, C); -} - -void StoreColor( uint idx, float R, float G, float B, float A ) -{ - gs_RG[idx] = f32tof16(R) << 16 | f32tof16(G); -#ifdef SEPARATE_ALPHA_MEDIAN - gs_A[idx] = A; - gs_B[idx] = B; -#else - gs_BA[idx] = f32tof16(B) << 16 | f32tof16(A); -#endif - - float Luma = dot(float3(R, G, B), float3(0.212671, 0.715160, 0.072169)) + 1.0; - gs_L[idx] = asfloat((asuint(Luma) & ~0xFF) | idx); -} - -[RootSignature(DoF_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID ) -{ - uint TileCoord = WorkQueue[Gid.x]; - uint2 Tile = uint2(TileCoord & 0xFFFF, TileCoord >> 16); - uint2 st = Tile * 8 + GTid.xy; - - - if (GTid.x < 5 && GTid.y < 5) - { - float2 PrefetchUV = 2 * (st + GTid.xy) * RcpBufferDim; - float4 R = InputColor.GatherRed( ClampSampler, PrefetchUV); - float4 G = InputColor.GatherGreen(ClampSampler, PrefetchUV); - float4 B = InputColor.GatherBlue( ClampSampler, PrefetchUV); - float4 A = InputAlpha.GatherRed( ClampSampler, PrefetchUV); - uint destIdx = GTid.x * 2 + GTid.y * 2 * 10; - StoreColor(destIdx , R.w, G.w, B.w, A.w); - StoreColor(destIdx+ 1, R.z, G.z, B.z, A.z); - StoreColor(destIdx+10, R.x, G.x, B.x, A.x); - StoreColor(destIdx+11, R.y, G.y, B.y, A.y); - } - - GroupMemoryBarrierWithGroupSync(); - - uint ulIdx = GTid.x + GTid.y * 10; - - float MedL = Med9( - gs_L[ulIdx ], gs_L[ulIdx+ 1], gs_L[ulIdx+ 2], - gs_L[ulIdx+10], gs_L[ulIdx+11], gs_L[ulIdx+12], - gs_L[ulIdx+20], gs_L[ulIdx+21], gs_L[ulIdx+22]); - - uint cIdx = asuint(MedL) & 0xFF; - uint RG = gs_RG[cIdx]; -#ifdef SEPARATE_ALPHA_MEDIAN - float Blue = gs_B[cIdx]; -#else - uint BA = gs_BA[cIdx]; - float Blue = f16tof32(BA >> 16); -#endif - OutputColor[st] = float3( f16tof32(RG >> 16), f16tof32(RG), Blue ); - -#ifdef SEPARATE_ALPHA_MEDIAN - OutputAlpha[st] = Med9( - gs_A[ulIdx ], gs_A[ulIdx+ 1], gs_A[ulIdx+ 2], - gs_A[ulIdx+10], gs_A[ulIdx+11], gs_A[ulIdx+12], - gs_A[ulIdx+20], gs_A[ulIdx+21], gs_A[ulIdx+22]); -#else - OutputAlpha[st] = f16tof32(BA); -#endif -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFMedianFilterFixupCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFMedianFilterFixupCS.hlsl deleted file mode 100644 index d1e44bf..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFMedianFilterFixupCS.hlsl +++ /dev/null @@ -1,32 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "DoFCommon.hlsli" - -Texture2D InputColor : register(t0); -Texture2D InputAlpha : register(t1); -StructuredBuffer WorkQueue : register(t2); -RWTexture2D OutputColor : register(u0); -RWTexture2D OutputAlpha : register(u1); - -[RootSignature(DoF_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID ) -{ - uint TileCoord = WorkQueue[Gid.x]; - uint2 Tile = uint2(TileCoord & 0xFFFF, TileCoord >> 16); - uint2 st = Tile * 8 + GTid.xy; - - OutputColor[st] = InputColor[st]; - OutputAlpha[st] = InputAlpha[st]; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFMedianFilterSepAlphaCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFMedianFilterSepAlphaCS.hlsl deleted file mode 100644 index 0330043..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFMedianFilterSepAlphaCS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define SEPARATE_ALPHA_MEDIAN -#include "DoFMedianFilterCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFPass1CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFPass1CS.hlsl deleted file mode 100644 index 5979201..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFPass1CS.hlsl +++ /dev/null @@ -1,60 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "DoFCommon.hlsli" - -Texture2D LNDepthBuffer : register(t0); // Linear/normalized depth buffer -RWTexture2D TileClass : register(u0); - -groupshared float gs_ClosestDepthSearch[64]; -groupshared float gs_FarthestDepthSearch[64]; -groupshared float gs_MaximumCoC[64]; - -float MaxCoC( float4 Depths ) -{ - float MaxDepthRelativeToFocus = Max4(abs(Depths - FocusCenter.xxxx)); - return max(1.0 / sqrt(MATH_CONST_PI), MAX_COC_RADIUS * saturate( MaxDepthRelativeToFocus * FocalSpread )); -} - -[RootSignature(DoF_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID ) -{ - float2 uv = (DTid.xy * 2 + 1) * RcpBufferDim; - float4 Depths = LNDepthBuffer.Gather(ClampSampler, uv); - - float TileMinDepth = Min4(Depths); - float TileMaxDepth = Max4(Depths); - float TileMaxCoC = MaxCoC(Depths); - - // Write and sync - gs_ClosestDepthSearch[GI] = TileMinDepth; - gs_FarthestDepthSearch[GI] = TileMaxDepth; - gs_MaximumCoC[GI] = TileMaxCoC; - GroupMemoryBarrierWithGroupSync(); - - for (uint i = 32; i > 0; i >>= 1) - { - // Read and sync - if (GI < i) - { - gs_ClosestDepthSearch[i] = min(gs_ClosestDepthSearch[i], gs_ClosestDepthSearch[GI + i]); - gs_FarthestDepthSearch[i] = max(gs_FarthestDepthSearch[i], gs_FarthestDepthSearch[GI + i]); - gs_MaximumCoC[i] = max(gs_MaximumCoC[i], gs_MaximumCoC[GI + i]); - } - GroupMemoryBarrierWithGroupSync(); - } - - if (GI == 0) - TileClass[Gid.xy] = float3(gs_MaximumCoC[0], gs_FarthestDepthSearch[0], gs_FarthestDepthSearch[0]); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFPass2CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFPass2CS.hlsl deleted file mode 100644 index 9192376..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFPass2CS.hlsl +++ /dev/null @@ -1,156 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "DoFCommon.hlsli" - -Texture2D ColorBuffer : register(t0); -Texture2D PresortBuffer : register(t1); -Texture2D TileClass : register(t2); -StructuredBuffer WorkQueue : register(t3); -RWTexture2D OutputColor : register(u0); -RWTexture2D OutputAlpha : register(u1); - -groupshared uint gs_RG[24 * 24]; // Red, Green -groupshared uint gs_BW[24 * 24]; // Blue, Weight -groupshared uint gs_CF[24 * 24]; // CoC, FG Weight - -void PrefetchPixel(int2 Corner, uint2 Offset, float FgRenormFactor, float TileMinDepth) -{ - uint ldsIdx = Offset.x + Offset.y * 24; - uint2 st = clamp(Corner + Offset, 0, HalfDimensionMinusOne); - float3 PreSortData = PresortBuffer[st]; - float SampleAlpha = PreSortData.y; - float4 Color = float4(ColorBuffer[st], 1) * SampleAlpha * FgRenormFactor; - gs_RG[ldsIdx] = f32tof16(Color.r) | f32tof16(Color.g) << 16; - gs_BW[ldsIdx] = f32tof16(Color.b) | f32tof16(Color.w) << 16; - float NumRings = PreSortData.x; - float FgPercent = ForegroundPercent(PreSortData.z, TileMinDepth); - gs_CF[ldsIdx] = f32tof16(NumRings) | f32tof16(FgPercent) << 16; -} - -void AccumulateSample( uint ldsIdx, float SampleRadius, inout float4 BackgroundAccum, inout float4 ForegroundAccum ) -{ - uint RG = gs_RG[ldsIdx]; - uint BW = gs_BW[ldsIdx]; - float4 SampleColor = float4(f16tof32(RG), f16tof32(RG >> 16), f16tof32(BW), f16tof32(BW >> 16)); - uint CF = gs_CF[ldsIdx]; - float CoC = f16tof32(CF); - float Fg = f16tof32(CF >> 16); - - float Weight = saturate(1.0 - (SampleRadius - CoC)); - BackgroundAccum += SampleColor * (1 - Fg) * Weight; - ForegroundAccum += SampleColor * Fg * Weight; -} - -void AccumulateOneRing( uint ldsIdx, inout float4 Background, inout float4 Foreground ) -{ - [unroll] - for (uint i = 0; i < 8; ++i) - AccumulateSample(ldsIdx + s_Ring1Q[i], 1, Background, Foreground); -} - -void AccumulateTwoRings( uint ldsIdx, inout float4 Background, inout float4 Foreground ) -{ - [unroll] - for (uint i = 0; i < 16; ++i) - AccumulateSample(ldsIdx + s_Ring2Q[i], 2, Background, Foreground); -} - -void AccumulateThreeRings( uint ldsIdx, inout float4 Background, inout float4 Foreground ) -{ - [unroll] - for (uint i = 0; i < 24; ++i) - AccumulateSample(ldsIdx + s_Ring3Q[i], 3, Background, Foreground); -} - -[RootSignature(DoF_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID ) -{ - uint TileCoord = WorkQueue[Gid.x]; - uint2 Tile = uint2(TileCoord & 0xFFFF, TileCoord >> 16); - - float TileMinDepth = TileClass[Tile].y; - float FgRenormFactor = TileClass[Tile].z; - - int2 TileUL = Tile * 8 - 8; - PrefetchPixel(TileUL, GTid.xy + uint2( 0, 0), FgRenormFactor, TileMinDepth); - PrefetchPixel(TileUL, GTid.xy + uint2( 0, 8), FgRenormFactor, TileMinDepth); - PrefetchPixel(TileUL, GTid.xy + uint2( 0, 16), FgRenormFactor, TileMinDepth); - PrefetchPixel(TileUL, GTid.xy + uint2( 8, 0), FgRenormFactor, TileMinDepth); - PrefetchPixel(TileUL, GTid.xy + uint2( 8, 8), FgRenormFactor, TileMinDepth); - PrefetchPixel(TileUL, GTid.xy + uint2( 8, 16), FgRenormFactor, TileMinDepth); - PrefetchPixel(TileUL, GTid.xy + uint2(16, 0), FgRenormFactor, TileMinDepth); - PrefetchPixel(TileUL, GTid.xy + uint2(16, 8), FgRenormFactor, TileMinDepth); - PrefetchPixel(TileUL, GTid.xy + uint2(16, 16), FgRenormFactor, TileMinDepth); - GroupMemoryBarrierWithGroupSync(); - - uint2 st = Tile * 8 + GTid.xy; - uint ldsIdx = GTid.x + GTid.y * 24 + 25 * 8; - - float RingCount = (TileClass[Tile].x - 1.0) / 5.0; - - uint RG = gs_RG[ldsIdx]; - uint BW = gs_BW[ldsIdx]; - float4 CenterColor = float4(f16tof32(RG), f16tof32(RG >> 16), f16tof32(BW), f16tof32(BW >> 16)); - float Fg = f16tof32(gs_CF[ldsIdx] >> 16); - - float4 Background = CenterColor * (1.01 - Fg); - float4 Foreground = CenterColor * Fg; - -#ifdef SUPPORT_DEBUGGING - if (DebugMode == 4) - { - float Rings = clamp(RingCount, 0.0, 2.99999); - OutputColor[st] = frac(float3(saturate(Rings), saturate(Rings - 1.0), saturate(Rings - 2.0))); - OutputAlpha[st] = 1.0; - return; - } -#endif - - AccumulateOneRing(ldsIdx, Background, Foreground); - - if (RingCount > 1.0) - AccumulateTwoRings(ldsIdx, Background, Foreground); - - if (RingCount > 2.0) - AccumulateThreeRings(ldsIdx, Background, Foreground); - - Background.rgb /= (Background.a + 0.00001); - Foreground.rgb /= (Foreground.a + 0.00001); - - float Alpha = saturate(Foreground.a); - -#ifdef SUPPORT_DEBUGGING - if (DebugMode == 1) - { - OutputColor[st] = Foreground.rgb; - OutputAlpha[st] = 1.0; - } - else if (DebugMode == 2) - { - OutputColor[st] = Background.rgb; - OutputAlpha[st] = 1.0; - } - else if (DebugMode == 3) - { - OutputColor[st] = Alpha.xxx; - OutputAlpha[st] = 1.0; - } - else -#endif - { - OutputColor[st] = lerp(Background.rgb, Foreground.rgb, Alpha); - OutputAlpha[st] = lerp(Alpha, 1.0, 0.5); - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFPass2DebugCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFPass2DebugCS.hlsl deleted file mode 100644 index ffc1245..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFPass2DebugCS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define SUPPORT_DEBUGGING -#include "DoFPass2CS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFPass2FastCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFPass2FastCS.hlsl deleted file mode 100644 index 0a84a8f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFPass2FastCS.hlsl +++ /dev/null @@ -1,105 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "DoFCommon.hlsli" - -Texture2D ColorBuffer : register(t0); -Texture2D TileClass : register(t2); -StructuredBuffer WorkQueue : register(t3); -RWTexture2D OutputColor : register(u0); -RWTexture2D OutputAlpha : register(u1); - -groupshared uint gs_RB[24 * 24]; -groupshared float gs_Gr[24 * 24]; - -void PrefetchPixel(int2 Corner, uint2 Offset) -{ - uint ldsIdx = Offset.x + Offset.y * 24; - uint2 st = clamp(Corner + Offset, 0, HalfDimensionMinusOne); - float3 Color = ColorBuffer[st]; - gs_RB[ldsIdx] = f32tof16(Color.r) | f32tof16(Color.b) << 16; - gs_Gr[ldsIdx] = Color.g; -} - -float3 LoadColor( uint ldsIdx ) -{ - uint RB = gs_RB[ldsIdx]; - return float3( f16tof32(RB), gs_Gr[ldsIdx], f16tof32(RB >> 16) ); -} - -float4 AccumulateOneRing( uint ldsIdx ) -{ - float3 RingSamples = 0; - [unroll] - for (uint i = 0; i < 8; i++) - RingSamples += LoadColor(ldsIdx + s_Ring1Q[i]); - return float4(RingSamples, 8); -} - -float4 AccumulateTwoRings( uint ldsIdx ) -{ - float3 RingSamples = 0; - [unroll] - for (uint i = 0; i < 16; i++) - RingSamples += LoadColor(ldsIdx + s_Ring2Q[i]); - return float4(RingSamples, 16); -} - -float4 AccumulateThreeRings( uint ldsIdx ) -{ - float3 RingSamples = 0; - [unroll] - for (uint i = 0; i < 24; i++) - RingSamples += LoadColor(ldsIdx + s_Ring3Q[i]); - return float4(RingSamples, 24); -} - -[RootSignature(DoF_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID ) -{ - uint TileCoord = WorkQueue[Gid.x]; - uint2 Tile = uint2(TileCoord & 0xFFFF, TileCoord >> 16); - - int2 TileUL = Tile * 8 - 8; - PrefetchPixel(TileUL, GTid.xy + uint2( 0, 0)); - PrefetchPixel(TileUL, GTid.xy + uint2( 0, 8)); - PrefetchPixel(TileUL, GTid.xy + uint2( 0, 16)); - PrefetchPixel(TileUL, GTid.xy + uint2( 8, 0)); - PrefetchPixel(TileUL, GTid.xy + uint2( 8, 8)); - PrefetchPixel(TileUL, GTid.xy + uint2( 8, 16)); - PrefetchPixel(TileUL, GTid.xy + uint2(16, 0)); - PrefetchPixel(TileUL, GTid.xy + uint2(16, 8)); - PrefetchPixel(TileUL, GTid.xy + uint2(16, 16)); - GroupMemoryBarrierWithGroupSync(); - - uint2 st = Tile * 8 + GTid.xy; - uint ldsIdx = GTid.x + GTid.y * 24 + 25 * 8; - - float3 CenterColor = LoadColor(ldsIdx); - float TileCoC = TileClass[Tile].x; - float RingCount = (TileCoC - 1.0) / 5.0; - - float4 Foreground = float4(CenterColor, 1); - - Foreground += saturate(RingCount) * AccumulateOneRing(ldsIdx); - - if (RingCount > 1.0) - Foreground += saturate(RingCount - 1.0) * AccumulateTwoRings(ldsIdx); - - if (RingCount > 2.0) - Foreground += saturate(RingCount - 2.0) * AccumulateThreeRings(ldsIdx); - - OutputColor[st] = Foreground.rgb / Foreground.w; - OutputAlpha[st] = 1.0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFPass2FixupCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFPass2FixupCS.hlsl deleted file mode 100644 index 30d5e14..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFPass2FixupCS.hlsl +++ /dev/null @@ -1,35 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "DoFCommon.hlsli" - -Texture2D ColorBuffer : register(t0); -Texture2D PresortBuffer : register(t1); -StructuredBuffer WorkQueue : register(t3); -RWTexture2D OutputColor : register(u0); -RWTexture2D OutputAlpha : register(u1); - -[RootSignature(DoF_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID ) -{ - uint TileCoord = WorkQueue[Gid.x]; - uint2 Tile = uint2(TileCoord & 0xFFFF, TileCoord >> 16); - - uint2 st = Tile * 8 + GTid.xy; - - float Alpha = saturate(PresortBuffer[st].z); - - OutputColor[st] = ColorBuffer[st]; - OutputAlpha[st] = 1.0;//lerp(Alpha, 1.0, 0.75); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFPreFilterCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFPreFilterCS.hlsl deleted file mode 100644 index 5c148d9..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFPreFilterCS.hlsl +++ /dev/null @@ -1,136 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "DoFCommon.hlsli" - -Texture2D LNDepthBuffer : register(t0); -Texture2D TileClass : register(t1); -Texture2D ColorBuffer : register(t2); -StructuredBuffer WorkQueue : register(t3); - -// Half res -RWTexture2D PresortBuffer : register(u0); -RWTexture2D OutputBuffer : register(u1); - -groupshared uint RGBuffer[100]; -groupshared uint BWBuffer[100]; -groupshared float DepthBuffer[100]; - -void LoadSample( out float4 Color, out float Depth, uint LsIdx ) -{ - uint RG = RGBuffer[LsIdx]; - uint BW = BWBuffer[LsIdx]; - Color.r = f16tof32(RG >> 16); - Color.g = f16tof32(RG); - Color.b = f16tof32(BW >> 16); - Color.w = f16tof32(BW); - Depth = DepthBuffer[LsIdx]; -} - -float4 WeightByInverseLuminance( float3 Color ) -{ - float Luminance = dot(Color, float3(0.212671, 0.715160, 0.072169)); - return float4(Color, 1) * rcp(Luminance * AntiSparkleFilterStrength + 1.0); -} - -float ComputeSampleWeight( float SampleDepth, float CmpDepth ) -{ - return 1.0 - saturate(abs(CmpDepth - SampleDepth) * RcpForegroundRange - 1.0); -} - -float4 GetWeightedSample( uint LsIdx, float CenterDepth ) -{ - float4 Color; float SampleDepth; - LoadSample(Color, SampleDepth, LsIdx); - return Color * ComputeSampleWeight(SampleDepth, CenterDepth); -} - -float4 AccumulateOneRing( uint LsIdx, float CenterDepth ) -{ - float4 AccumColor = - GetWeightedSample(LsIdx - 1, CenterDepth) + - GetWeightedSample(LsIdx + 1, CenterDepth) + - GetWeightedSample(LsIdx - 10, CenterDepth) + - GetWeightedSample(LsIdx + 10, CenterDepth); - - AccumColor += 0.75 * ( - GetWeightedSample(LsIdx - 9, CenterDepth) + - GetWeightedSample(LsIdx - 11, CenterDepth) + - GetWeightedSample(LsIdx + 9, CenterDepth) + - GetWeightedSample(LsIdx + 11, CenterDepth) - ); - - return AccumColor; -} - -void LoadBlurriestSample( uint lsIdx, int2 st ) -{ - float2 uv = st * RcpBufferDim; - - float4 Depths = LNDepthBuffer.Gather(ClampSampler, uv); - float4 Reds = ColorBuffer.GatherRed(ClampSampler, uv); - float4 Greens = ColorBuffer.GatherGreen(ClampSampler, uv); - float4 Blues = ColorBuffer.GatherBlue(ClampSampler, uv); - - Depths = clamp(Depths, FocalMinDist, FocalMaxDist); - float MaxDepth = Max4(Depths); - DepthBuffer[lsIdx] = MaxDepth; - - float WeightX = ComputeSampleWeight(Depths.x, MaxDepth); - float WeightY = ComputeSampleWeight(Depths.y, MaxDepth); - float WeightZ = ComputeSampleWeight(Depths.z, MaxDepth); - float WeightW = ComputeSampleWeight(Depths.w, MaxDepth); - - float3 Color = ( - WeightX * float3(Reds.x, Greens.x, Blues.x) + - WeightY * float3(Reds.y, Greens.y, Blues.y) + - WeightZ * float3(Reds.z, Greens.z, Blues.z) + - WeightW * float3(Reds.w, Greens.w, Blues.w) - ) / (WeightX + WeightY + WeightZ + WeightW); - - float4 WeightedColor = WeightByInverseLuminance(Color); - RGBuffer[lsIdx] = f32tof16(WeightedColor.r) << 16 | f32tof16(WeightedColor.g); - BWBuffer[lsIdx] = f32tof16(WeightedColor.b) << 16 | f32tof16(WeightedColor.w); -} - -[RootSignature(DoF_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID ) -{ - uint TileCoord = WorkQueue[Gid.x]; - uint2 Tile = uint2(TileCoord & 0xFFFF, TileCoord >> 16); - uint2 st = Tile * 8 + GTid.xy; - - int2 TileCorner = Tile * 16 - 1; - - LoadBlurriestSample(GI, TileCorner + uint2((GI % 10) * 2, (GI / 10) * 2)); - if (GI < 36) - { - uint idx = GI + 64; - LoadBlurriestSample(idx, TileCorner + uint2((idx % 10) * 2, (idx / 10) * 2)); - } - GroupMemoryBarrierWithGroupSync(); - - uint LsIdx = GTid.x + GTid.y * 10 + 11; - float4 Color; float Depth; - LoadSample(Color, Depth, LsIdx); - - float CoC = ComputeCoC(Depth); - - PresortBuffer[st] = float3(max(0, (CoC - 1.0) / 5.0), SampleAlpha(CoC), Depth); - - if (CoC >= 1.0 && DisablePreFilter == 0) - Color += saturate(CoC - 1.0) * AccumulateOneRing(LsIdx, Depth); - - OutputBuffer[st] = Color.rgb / Color.w; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFPreFilterFastCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFPreFilterFastCS.hlsl deleted file mode 100644 index 2469ae8..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFPreFilterFastCS.hlsl +++ /dev/null @@ -1,115 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "DoFCommon.hlsli" - -Texture2D LNDepthBuffer : register(t0); -Texture2D TileClass : register(t1); -Texture2D ColorBuffer : register(t2); -StructuredBuffer WorkQueue : register(t3); - -// Half res -RWTexture2D PresortBuffer : register(u0); -RWTexture2D OutputBuffer : register(u1); - -groupshared uint RGBuffer[100]; -groupshared uint BWBuffer[100]; -groupshared float DepthBuffer[100]; - -void LoadSample( out float4 Color, out float Depth, uint LsIdx ) -{ - uint RG = RGBuffer[LsIdx]; - uint BW = BWBuffer[LsIdx]; - Color.r = f16tof32(RG >> 16); - Color.g = f16tof32(RG); - Color.b = f16tof32(BW >> 16); - Color.w = f16tof32(BW); - Depth = DepthBuffer[LsIdx]; -} - -float4 WeightByInverseLuminance( float3 Color ) -{ - float Luminance = dot(Color, float3(0.212671, 0.715160, 0.072169)); - return float4(Color, 1) * rcp(Luminance * AntiSparkleFilterStrength + 1.0); -} - -float4 GetSample( uint LsIdx ) -{ - uint RG = RGBuffer[LsIdx]; - uint BW = BWBuffer[LsIdx]; - return float4(f16tof32(RG >> 16), f16tof32(RG), f16tof32(BW >> 16), f16tof32(BW)); -} - -float4 AccumulateOneRing( uint LsIdx, float CenterDepth ) -{ - float4 AccumColor = - GetSample(LsIdx - 1) + - GetSample(LsIdx + 1) + - GetSample(LsIdx - 10) + - GetSample(LsIdx + 10); - - AccumColor += 0.75 * ( - GetSample(LsIdx - 9) + - GetSample(LsIdx - 11) + - GetSample(LsIdx + 9) + - GetSample(LsIdx + 11) - ); - - return AccumColor; -} - -void LoadBlurriestSample( uint lsIdx, int2 st ) -{ - float2 uv = st * RcpBufferDim; - - float4 Color = WeightByInverseLuminance(ColorBuffer.SampleLevel(BilinearSampler, uv, 0)); - RGBuffer[lsIdx] = f32tof16(Color.r) << 16 | f32tof16(Color.g); - BWBuffer[lsIdx] = f32tof16(Color.b) << 16 | f32tof16(Color.a); - - float4 Depths = LNDepthBuffer.Gather(ClampSampler, uv); - Depths = clamp(Depths, FocalMinDist, FocalMaxDist); - float MaxDepth = Max4(Depths); - DepthBuffer[lsIdx] = MaxDepth; -} - -[RootSignature(DoF_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID ) -{ - uint TileCoord = WorkQueue[Gid.x]; - uint2 Tile = uint2(TileCoord & 0xFFFF, TileCoord >> 16); - uint2 st = Tile * 8 + GTid.xy; - - int2 TileCorner = Tile * 16 - 1; - - LoadBlurriestSample(GI, TileCorner + uint2((GI % 10) * 2, (GI / 10) * 2)); - if (GI < 36) - { - uint idx = GI + 64; - LoadBlurriestSample(idx, TileCorner + uint2((idx % 10) * 2, (idx / 10) * 2)); - } - GroupMemoryBarrierWithGroupSync(); - - uint LsIdx = GTid.x + GTid.y * 10 + 11; - float4 Color; float Depth; - LoadSample(Color, Depth, LsIdx); - - float CoC = ComputeCoC(Depth); - - PresortBuffer[st] = float3((CoC - 1.0) / 5.0, SampleAlpha(CoC), Depth); - - if (CoC >= 1.0 && DisablePreFilter == 0) - Color += saturate(CoC - 1.0) * AccumulateOneRing(LsIdx, Depth); - - OutputBuffer[st] = Color.rgb / Color.w; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFPreFilterFixupCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFPreFilterFixupCS.hlsl deleted file mode 100644 index 26f6b49..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFPreFilterFixupCS.hlsl +++ /dev/null @@ -1,39 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "DoFCommon.hlsli" - -Texture2D LNDepthBuffer : register(t0); -Texture2D TileClass : register(t1); -Texture2D ColorBuffer : register(t2); -StructuredBuffer WorkQueue : register(t3); - -// Half res -RWTexture2D PresortBuffer : register(u0); -RWTexture2D OutputBuffer : register(u1); - -[RootSignature(DoF_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID ) -{ - uint TileCoord = WorkQueue[Gid.x]; - uint2 Tile = uint2(TileCoord & 0xFFFF, TileCoord >> 16); - uint2 st = Tile * 8 + GTid.xy; - - float2 uv = (2 * st + 1) * RcpBufferDim; - - OutputBuffer[st] = ColorBuffer.SampleLevel(BilinearSampler, uv, 0); - float Depth = LNDepthBuffer.SampleLevel(PointSampler, uv, 0); - PresortBuffer[st] = float3(0.0, 1.0, Depth); - -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFRS.hlsli b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFRS.hlsli deleted file mode 100644 index 963cd45..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFRS.hlsli +++ /dev/null @@ -1,35 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define DoF_RootSig \ - "RootFlags(0), " \ - "CBV(b0), " \ - "DescriptorTable(SRV(t0, numDescriptors = 6))," \ - "DescriptorTable(UAV(u0, numDescriptors = 3))," \ - "RootConstants(b1, num32BitConstants = 1), " \ - "StaticSampler(s0," \ - "addressU = TEXTURE_ADDRESS_BORDER," \ - "addressV = TEXTURE_ADDRESS_BORDER," \ - "addressW = TEXTURE_ADDRESS_BORDER," \ - "borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK," \ - "filter = FILTER_MIN_MAG_MIP_POINT)," \ - "StaticSampler(s1," \ - "addressU = TEXTURE_ADDRESS_CLAMP," \ - "addressV = TEXTURE_ADDRESS_CLAMP," \ - "addressW = TEXTURE_ADDRESS_CLAMP," \ - "filter = FILTER_MIN_MAG_MIP_POINT)," \ - "StaticSampler(s2," \ - "addressU = TEXTURE_ADDRESS_CLAMP," \ - "addressV = TEXTURE_ADDRESS_CLAMP," \ - "addressW = TEXTURE_ADDRESS_CLAMP," \ - "filter = FILTER_MIN_MAG_MIP_LINEAR)" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFTilePassCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFTilePassCS.hlsl deleted file mode 100644 index 21694f7..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFTilePassCS.hlsl +++ /dev/null @@ -1,85 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "DoFCommon.hlsli" - -Texture2D InputClass : register(t0); -RWTexture2D TileClass : register(u0); -RWStructuredBuffer WorkQueue : register(u1); -RWStructuredBuffer FastQueue : register(u2); - -groupshared float gs_MaxCoC[100]; -groupshared float gs_MinDepth[100]; -groupshared float gs_MaxDepth[100]; - -[RootSignature(DoF_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID ) -{ - if (GTid.x < 5 && GTid.y < 5) - { - float2 PrefetchUV = (DTid.xy + GTid.xy) * InvTiledDimension; - float4 MaxCoCs = InputClass.GatherRed(ClampSampler, PrefetchUV); - float4 MinDepths = InputClass.GatherGreen(ClampSampler, PrefetchUV); - float4 MaxDepths = InputClass.GatherBlue(ClampSampler, PrefetchUV); - int destIdx = GTid.x * 2 + GTid.y * 2 * 10; - gs_MaxCoC[destIdx ] = MaxCoCs.w; - gs_MaxCoC[destIdx+ 1] = MaxCoCs.z; - gs_MaxCoC[destIdx+10] = MaxCoCs.x; - gs_MaxCoC[destIdx+11] = MaxCoCs.y; - gs_MinDepth[destIdx ] = MinDepths.w; - gs_MinDepth[destIdx+ 1] = MinDepths.z; - gs_MinDepth[destIdx+10] = MinDepths.x; - gs_MinDepth[destIdx+11] = MinDepths.y; - gs_MaxDepth[destIdx ] = MaxDepths.w; - gs_MaxDepth[destIdx+ 1] = MaxDepths.z; - gs_MaxDepth[destIdx+10] = MaxDepths.x; - gs_MaxDepth[destIdx+11] = MaxDepths.y; - } - - GroupMemoryBarrierWithGroupSync(); - - if (any(DTid.xy >= TiledDimension)) - return; - - uint ulIdx = GTid.x + GTid.y * 10; - - float MaxCoC0 = Max3(gs_MaxCoC[ulIdx ], gs_MaxCoC[ulIdx+ 1], gs_MaxCoC[ulIdx+ 2]); - float MaxCoC1 = Max3(gs_MaxCoC[ulIdx+10], gs_MaxCoC[ulIdx+11], gs_MaxCoC[ulIdx+12]); - float MaxCoC2 = Max3(gs_MaxCoC[ulIdx+20], gs_MaxCoC[ulIdx+21], gs_MaxCoC[ulIdx+22]); - float FinalMaxCoC = Max3(MaxCoC0, MaxCoC1, MaxCoC2); - - float MinDepth0 = Min3(gs_MinDepth[ulIdx ], gs_MinDepth[ulIdx+ 1], gs_MinDepth[ulIdx+ 2]); - float MinDepth1 = Min3(gs_MinDepth[ulIdx+10], gs_MinDepth[ulIdx+11], gs_MinDepth[ulIdx+12]); - float MinDepth2 = Min3(gs_MinDepth[ulIdx+20], gs_MinDepth[ulIdx+21], gs_MinDepth[ulIdx+22]); - float FinalMinDepth = Min3(MinDepth0, MinDepth1, MinDepth2); - FinalMinDepth = clamp(FinalMinDepth, FocalMinDist, FocalMaxDist); - - float MaxDepth0 = Max3(gs_MaxDepth[ulIdx ], gs_MaxDepth[ulIdx+ 1], gs_MaxDepth[ulIdx+ 2]); - float MaxDepth1 = Max3(gs_MaxDepth[ulIdx+10], gs_MaxDepth[ulIdx+11], gs_MaxDepth[ulIdx+12]); - float MaxDepth2 = Max3(gs_MaxDepth[ulIdx+20], gs_MaxDepth[ulIdx+21], gs_MaxDepth[ulIdx+22]); - float FinalMaxDepth = Max3(MaxDepth0, MaxDepth1, MaxDepth2); - FinalMaxDepth = clamp(FinalMaxDepth, FocalMinDist, FocalMaxDist); - - float FgAlphaNormalizationTerm = ComputeRenormalizationFactor( FinalMinDepth, FinalMaxCoC ); - - TileClass[DTid.xy] = float3(FinalMaxCoC, FinalMinDepth, FgAlphaNormalizationTerm); - - if (FinalMaxCoC >= 1.0) - { - if (FinalMaxDepth - FinalMinDepth > ForegroundRange) - WorkQueue[WorkQueue.IncrementCounter()] = DTid.x | DTid.y << 16; - else - FastQueue[FastQueue.IncrementCounter()] = DTid.x | DTid.y << 16; - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFTilePassFixupCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFTilePassFixupCS.hlsl deleted file mode 100644 index ea97142..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DoFTilePassFixupCS.hlsl +++ /dev/null @@ -1,52 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "DoFCommon.hlsli" - -Texture2D InputClass : register(t0); -RWStructuredBuffer FixupQueue : register(u0); - -groupshared float gs_MaxCoC[100]; - -[RootSignature(DoF_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID ) -{ - if (GTid.x < 5 && GTid.y < 5) - { - float2 PrefetchUV = (DTid.xy + GTid.xy) * InvTiledDimension; - float4 MaxCoCs = InputClass.GatherRed(ClampSampler, PrefetchUV); - int destIdx = GTid.x * 2 + GTid.y * 2 * 10; - gs_MaxCoC[destIdx ] = MaxCoCs.w; - gs_MaxCoC[destIdx+ 1] = MaxCoCs.z; - gs_MaxCoC[destIdx+10] = MaxCoCs.x; - gs_MaxCoC[destIdx+11] = MaxCoCs.y; - } - - GroupMemoryBarrierWithGroupSync(); - - if (any(DTid.xy >= TiledDimension)) - return; - - uint ulIdx = GTid.x + GTid.y * 10; - - float TileMaxCoC = gs_MaxCoC[ulIdx+11]; - - float MaxCoC0 = Max3(gs_MaxCoC[ulIdx ], gs_MaxCoC[ulIdx+ 1], gs_MaxCoC[ulIdx+ 2]); - float MaxCoC1 = max(gs_MaxCoC[ulIdx+10], gs_MaxCoC[ulIdx+12]); - float MaxCoC2 = Max3(gs_MaxCoC[ulIdx+20], gs_MaxCoC[ulIdx+21], gs_MaxCoC[ulIdx+22]); - float MaxNeighborCoC = Max3(MaxCoC0, MaxCoC1, MaxCoC2); - - if (TileMaxCoC < 1.0 && MaxNeighborCoC >= 1.0) - FixupQueue[FixupQueue.IncrementCounter()] = DTid.x | DTid.y << 16; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DownsampleBloomAllCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DownsampleBloomAllCS.hlsl deleted file mode 100644 index 5687006..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DownsampleBloomAllCS.hlsl +++ /dev/null @@ -1,72 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// -// The CS for downsampling 16x16 blocks of pixels down to 8x8, 4x4, 2x2, and 1x1 blocks. - -#include "PostEffectsRS.hlsli" - -Texture2D BloomBuf : register( t0 ); -RWTexture2D Result1 : register( u0 ); -RWTexture2D Result2 : register( u1 ); -RWTexture2D Result3 : register( u2 ); -RWTexture2D Result4 : register( u3 ); -SamplerState BiLinearClamp : register( s0 ); - -cbuffer cb0 : register(b0) -{ - float2 g_inverseDimensions; -} - -groupshared float3 g_Tile[64]; // 8x8 input pixels - -[RootSignature(PostEffects_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint GI : SV_GroupIndex, uint3 DTid : SV_DispatchThreadID ) -{ - // You can tell if both x and y are divisible by a power of two with this value - uint parity = DTid.x | DTid.y; - - // Downsample and store the 8x8 block - float2 centerUV = (float2(DTid.xy) * 2.0f + 1.0f) * g_inverseDimensions; - float3 avgPixel = BloomBuf.SampleLevel(BiLinearClamp, centerUV, 0.0f); - g_Tile[GI] = avgPixel; - Result1[DTid.xy] = avgPixel; - - GroupMemoryBarrierWithGroupSync(); - - // Downsample and store the 4x4 block - if ((parity & 1) == 0) - { - avgPixel = 0.25f * (avgPixel + g_Tile[GI+1] + g_Tile[GI+8] + g_Tile[GI+9]); - g_Tile[GI] = avgPixel; - Result2[DTid.xy >> 1] = avgPixel; - } - - GroupMemoryBarrierWithGroupSync(); - - // Downsample and store the 2x2 block - if ((parity & 3) == 0) - { - avgPixel = 0.25f * (avgPixel + g_Tile[GI+2] + g_Tile[GI+16] + g_Tile[GI+18]); - g_Tile[GI] = avgPixel; - Result3[DTid.xy >> 2] = avgPixel; - } - - GroupMemoryBarrierWithGroupSync(); - - // Downsample and store the 1x1 block - if ((parity & 7) == 0) - { - avgPixel = 0.25f * (avgPixel + g_Tile[GI+4] + g_Tile[GI+32] + g_Tile[GI+36]); - Result4[DTid.xy >> 3] = avgPixel; - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DownsampleBloomCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DownsampleBloomCS.hlsl deleted file mode 100644 index 0d6a90f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DownsampleBloomCS.hlsl +++ /dev/null @@ -1,65 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// -// The CS for downsampling 16x16 blocks of pixels down to 4x4 and 1x1 blocks. - -#include "PostEffectsRS.hlsli" - -Texture2D BloomBuf : register( t0 ); -RWTexture2D Result1 : register( u0 ); -RWTexture2D Result2 : register( u1 ); -SamplerState BiLinearClamp : register( s0 ); - -cbuffer cb0 : register(b0) -{ - float2 g_inverseDimensions; -} - -groupshared float3 g_Tile[64]; // 8x8 input pixels - -[RootSignature(PostEffects_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint GI : SV_GroupIndex, uint3 Did : SV_DispatchThreadID ) -{ - // You can tell if both x and y are divisible by a power of two with this value - uint parity = Did.x | Did.y; - - // Store the first downsampled quad per thread - float2 centerUV = (float2(Did.xy) * 2.0f + 1.0f) * g_inverseDimensions; - float3 avgPixel = BloomBuf.SampleLevel(BiLinearClamp, centerUV, 0.0f); - g_Tile[GI] = avgPixel; - - GroupMemoryBarrierWithGroupSync(); - - if ((parity & 1) == 0) - { - avgPixel = 0.25f * (avgPixel + g_Tile[GI+1] + g_Tile[GI+8] + g_Tile[GI+9]); - g_Tile[GI] = avgPixel; - Result1[Did.xy >> 1] = avgPixel; - } - - GroupMemoryBarrierWithGroupSync(); - - if ((parity & 3) == 0) - { - avgPixel = avgPixel + g_Tile[GI+2] + g_Tile[GI+16] + g_Tile[GI+18]; - g_Tile[GI] = avgPixel; - } - - GroupMemoryBarrierWithGroupSync(); - - if ((parity & 7) == 0) - { - avgPixel = 0.0625f * (avgPixel + g_Tile[GI+4] + g_Tile[GI+32] + g_Tile[GI+36]); - Result2[Did.xy >> 3] = avgPixel; - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DownsampleDepthPS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/DownsampleDepthPS.hlsl deleted file mode 100644 index 87bc1c7..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/DownsampleDepthPS.hlsl +++ /dev/null @@ -1,22 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "CommonRS.hlsli" - -Texture2DMS DepthBuffer : register(t0); - -[RootSignature(Common_RootSig)] -float main( float4 position : SV_Position ) : SV_Depth -{ - return DepthBuffer.Load((int2)position.xy, 0); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ExtractLumaCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ExtractLumaCS.hlsl deleted file mode 100644 index 05f2960..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ExtractLumaCS.hlsl +++ /dev/null @@ -1,59 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// -// The CS for extracting bright pixels and saving a log-luminance map (quantized to 8 bits). This -// is then used to generate an 8-bit histogram. - -#include "ShaderUtility.hlsli" -#include "PostEffectsRS.hlsli" - -SamplerState BiLinearClamp : register( s0 ); -Texture2D SourceTex : register( t0 ); -StructuredBuffer Exposure : register( t1 ); -RWTexture2D LumaResult : register( u0 ); - -cbuffer cb0 -{ - float2 g_inverseOutputSize; -} - -[RootSignature(PostEffects_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 DTid : SV_DispatchThreadID ) -{ - // We need the scale factor and the size of one pixel so that our four samples are right in the middle - // of the quadrant they are covering. - float2 uv = DTid.xy * g_inverseOutputSize; - float2 offset = g_inverseOutputSize * 0.25f; - - // Use 4 bilinear samples to guarantee we don't undersample when downsizing by more than 2x - float3 color1 = SourceTex.SampleLevel( BiLinearClamp, uv + float2(-offset.x, -offset.y), 0 ); - float3 color2 = SourceTex.SampleLevel( BiLinearClamp, uv + float2( offset.x, -offset.y), 0 ); - float3 color3 = SourceTex.SampleLevel( BiLinearClamp, uv + float2(-offset.x, offset.y), 0 ); - float3 color4 = SourceTex.SampleLevel( BiLinearClamp, uv + float2( offset.x, offset.y), 0 ); - - // Compute average luminance - float luma = RGBToLuminance(color1 + color2 + color3 + color4) * 0.25; - - // Prevent log(0) and put only pure black pixels in Histogram[0] - if (luma == 0.0) - { - LumaResult[DTid.xy] = 0; - } - else - { - const float MinLog = Exposure[4]; - const float RcpLogRange = Exposure[7]; - float logLuma = saturate((log2(luma) - MinLog) * RcpLogRange); // Rescale to [0.0, 1.0] - LumaResult[DTid.xy] = logLuma * 254.0 + 1.0; // Rescale to [1, 255] - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass1CS.hlsli b/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass1CS.hlsli deleted file mode 100644 index 3f396c2..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass1CS.hlsli +++ /dev/null @@ -1,195 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// -// Description: A Compute-optimized implementation of FXAA 3.11 (PC Quality). The -// improvements take advantage of work queues (RWStructuredBuffer with atomic counters) -// for these benefits: -// -// 1) Split horizontal and vertical edge searches into separate dispatches to reduce -// shader complexity and incoherent branching. -// 2) Delay writing new pixel colors until after the source buffer has been fully -// analyzed. This avoids the write-after-scattered-read hazard. -// 3) Modify source buffer in-place rather than ping-ponging buffers, which reduces -// bandwidth and memory demands. -// -// In addition to the above-mentioned benefits of using UAVs, the first pass also -// takes advantage of groupshared memory for storing luma values, further reducing -// fetches and bandwidth. -// -// Another optimization is in the generation of perceived brightness (luma) of pixels. -// The original implementation used sRGB as a good approximation of log-luminance. A -// more precise representation of log-luminance allows the algorithm to operate with a -// higher threshold value while still finding perceivable edges across the full range -// of brightness. The approximation used here is (1 - 2^(-4L)) * 16/15, where L = -// dot( LinearRGB, float3(0.212671, 0.715160, 0.072169) ). A threshold of 0.2 is -// recommended with log-luminance computed this way. -// - -// Original Boilerplate: -// -/*============================================================================ - - - NVIDIA FXAA 3.11 by TIMOTHY LOTTES - - ------------------------------------------------------------------------------- -COPYRIGHT (C) 2010, 2011 NVIDIA CORPORATION. ALL RIGHTS RESERVED. ------------------------------------------------------------------------------- -TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED -*AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA -OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR -CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR -LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, -OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE -THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. -*/ - - -#include "FXAARootSignature.hlsli" - -RWByteAddressBuffer WorkCount : register(u0); -RWByteAddressBuffer WorkQueue : register(u1); -RWBuffer ColorQueue : register(u2); -#if SUPPORT_TYPED_UAV_LOADS - Texture2D Color : register(t0); - float3 FetchColor( int2 st ) { return Color[st]; } -#else - #include "PixelPacking_R11G11B10.hlsli" - Texture2D Color : register(t0); - float3 FetchColor( int2 st ) { return Unpack_R11G11B10_FLOAT(Color[st]); } -#endif -SamplerState LinearSampler : register(s0); - -#define BOUNDARY_SIZE 1 -#define ROW_WIDTH (8 + BOUNDARY_SIZE * 2) -groupshared float gs_LumaCache[ROW_WIDTH * ROW_WIDTH]; - -// If pre-computed, source luminance as a texture, otherwise write it out for Pass2 -#ifdef USE_LUMA_INPUT_BUFFER - Texture2D Luma : register(t1); -#else - RWTexture2D Luma : register(u3); -#endif - -// -// Helper functions -// -float RGBToLogLuminance( float3 LinearRGB ) -{ - float Luma = dot( LinearRGB, float3(0.212671, 0.715160, 0.072169) ); - return log2(1 + Luma * 15) / 4; -} - -[RootSignature(FXAA_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID ) -{ - uint2 PixelCoord = DTid.xy + StartPixel; - -#ifdef USE_LUMA_INPUT_BUFFER - // Load 4 lumas per thread into LDS (but only those needed to fill our pixel cache) - if (max(GTid.x, GTid.y) < ROW_WIDTH / 2) - { - int2 ThreadUL = PixelCoord + GTid.xy - (BOUNDARY_SIZE - 1); - float4 Luma4 = Luma.Gather(LinearSampler, ThreadUL * RcpTextureSize); - uint LoadIndex = (GTid.x + GTid.y * ROW_WIDTH) * 2; - gs_LumaCache[LoadIndex ] = Luma4.w; - gs_LumaCache[LoadIndex + 1 ] = Luma4.z; - gs_LumaCache[LoadIndex + ROW_WIDTH ] = Luma4.x; - gs_LumaCache[LoadIndex + ROW_WIDTH + 1] = Luma4.y; - } -#else - // Because we can't use Gather() on RGB, we make each thread read two pixels (but only those needed). - if (GI < ROW_WIDTH * ROW_WIDTH / 2) - { - uint LdsCoord = GI; - int2 UavCoord = StartPixel + uint2(GI % ROW_WIDTH, GI / ROW_WIDTH) + Gid.xy * 8 - BOUNDARY_SIZE; - float Luma1 = RGBToLogLuminance(FetchColor(UavCoord)); - Luma[UavCoord] = Luma1; - gs_LumaCache[LdsCoord] = Luma1; - - LdsCoord += ROW_WIDTH * ROW_WIDTH / 2; - UavCoord += int2(0, ROW_WIDTH / 2); - float Luma2 = RGBToLogLuminance(FetchColor(UavCoord)); - Luma[UavCoord] = Luma2; - gs_LumaCache[LdsCoord] = Luma2; - } -#endif - - GroupMemoryBarrierWithGroupSync(); - - uint CenterIdx = (GTid.x + BOUNDARY_SIZE) + (GTid.y + BOUNDARY_SIZE) * ROW_WIDTH; - - // Load the ordinal and center luminances - float lumaN = gs_LumaCache[CenterIdx - ROW_WIDTH]; - float lumaW = gs_LumaCache[CenterIdx - 1]; - float lumaM = gs_LumaCache[CenterIdx]; - float lumaE = gs_LumaCache[CenterIdx + 1]; - float lumaS = gs_LumaCache[CenterIdx + ROW_WIDTH]; - - // Contrast threshold test - float rangeMax = max(max(lumaN, lumaW), max(lumaE, max(lumaS, lumaM))); - float rangeMin = min(min(lumaN, lumaW), min(lumaE, min(lumaS, lumaM))); - float range = rangeMax - rangeMin; - if (range < ContrastThreshold) - return; - - // Load the corner luminances - float lumaNW = gs_LumaCache[CenterIdx - ROW_WIDTH - 1]; - float lumaNE = gs_LumaCache[CenterIdx - ROW_WIDTH + 1]; - float lumaSW = gs_LumaCache[CenterIdx + ROW_WIDTH - 1]; - float lumaSE = gs_LumaCache[CenterIdx + ROW_WIDTH + 1]; - - // Pre-sum a few terms so the results can be reused - float lumaNS = lumaN + lumaS; - float lumaWE = lumaW + lumaE; - float lumaNWSW = lumaNW + lumaSW; - float lumaNESE = lumaNE + lumaSE; - float lumaSWSE = lumaSW + lumaSE; - float lumaNWNE = lumaNW + lumaNE; - - // Compute horizontal and vertical contrast; see which is bigger - float edgeHorz = abs(lumaNWSW - 2.0 * lumaW) + abs(lumaNS - 2.0 * lumaM) * 2.0 + abs(lumaNESE - 2.0 * lumaE); - float edgeVert = abs(lumaSWSE - 2.0 * lumaS) + abs(lumaWE - 2.0 * lumaM) * 2.0 + abs(lumaNWNE - 2.0 * lumaN); - - // Also compute local contrast in the 3x3 region. This can identify standalone pixels that alias. - float avgNeighborLuma = ((lumaNS + lumaWE) * 2.0 + lumaNWSW + lumaNESE) / 12.0; - float subpixelShift = saturate(pow(smoothstep(0, 1, abs(avgNeighborLuma - lumaM) / range), 2) * SubpixelRemoval * 2); - - float NegGrad = (edgeHorz >= edgeVert ? lumaN : lumaW) - lumaM; - float PosGrad = (edgeHorz >= edgeVert ? lumaS : lumaE) - lumaM; - uint GradientDir = abs(PosGrad) >= abs(NegGrad) ? 1 : 0; - uint Subpix = uint(subpixelShift * 254.0) & 0xFE; - - // Packet header: [ 12 bits Y | 12 bits X | 7 bit Subpix | 1 bit dir(Grad) ] - uint WorkHeader = DTid.y << 20 | DTid.x << 8 | Subpix | GradientDir; - - if (edgeHorz >= edgeVert) - { - uint WorkIdx; - WorkCount.InterlockedAdd(0, 1, WorkIdx); - WorkQueue.Store(WorkIdx*4, WorkHeader); - ColorQueue[WorkIdx] = FetchColor(PixelCoord + uint2(0, 2 * GradientDir - 1)); - } - else - { - uint WorkIdx; - WorkCount.InterlockedAdd(4, 1, WorkIdx); - WorkIdx = LastQueueIndex - WorkIdx; - WorkQueue.Store(WorkIdx*4, WorkHeader); - ColorQueue[WorkIdx] = FetchColor(PixelCoord + uint2(2 * GradientDir - 1, 0)); - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass1_Luma2_CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass1_Luma2_CS.hlsl deleted file mode 100644 index 10e0f1a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass1_Luma2_CS.hlsl +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define USE_LUMA_INPUT_BUFFER -#define SUPPORT_TYPED_UAV_LOADS 1 -#include "FXAAPass1CS.hlsli" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass1_Luma_CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass1_Luma_CS.hlsl deleted file mode 100644 index 33b4c82..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass1_Luma_CS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define USE_LUMA_INPUT_BUFFER -#include "FXAAPass1CS.hlsli" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass1_RGB2_CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass1_RGB2_CS.hlsl deleted file mode 100644 index 9b0567e..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass1_RGB2_CS.hlsl +++ /dev/null @@ -1,14 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard - -#define SUPPORT_TYPED_UAV_LOADS 1 -#include "FXAAPass1CS.hlsli" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass1_RGB_CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass1_RGB_CS.hlsl deleted file mode 100644 index b69ac82..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass1_RGB_CS.hlsl +++ /dev/null @@ -1,13 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard - -#include "FXAAPass1CS.hlsli" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass2CS.hlsli b/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass2CS.hlsli deleted file mode 100644 index e24d780..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass2CS.hlsli +++ /dev/null @@ -1,136 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "FXAARootSignature.hlsli" - -Texture2D Luma : register(t0); -ByteAddressBuffer WorkQueue : register(t1); -Buffer ColorQueue : register(t2); -#if SUPPORT_TYPED_UAV_LOADS -RWTexture2D DstColor : register(u0); -#else -#include "PixelPacking_R11G11B10.hlsli" -RWTexture2D DstColor : register(u0); -#endif -SamplerState LinearSampler : register(s0); - - -// Note that the number of samples in each direction is one less than the number of sample distances. The last -// is the maximum distance that should be used, but whether that sample is "good" or "bad" doesn't affect the result, -// so we don't need to load it. -#ifdef FXAA_EXTREME_QUALITY - #define NUM_SAMPLES 11 - static const float s_SampleDistances[12] = // FXAA_QUALITY__PRESET == 39 - { - 1.0, 2.0, 3.0, 4.0, 5.0, 6.5, 8.5, 10.5, 12.5, 14.5, 18.5, 36.5, - }; -#else - #define NUM_SAMPLES 7 - static const float s_SampleDistances[8] = // FXAA_QUALITY__PRESET == 25 - { - 1.0, 2.5, 4.5, 6.5, 8.5, 10.5, 14.5, 22.5 - }; -#endif - -[RootSignature(FXAA_RootSig)] -[numthreads(64, 1, 1)] -void main( uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID ) -{ -#ifdef VERTICAL_ORIENTATION - uint ItemIdx = LastQueueIndex - DTid.x; -#else - uint ItemIdx = DTid.x; -#endif - uint WorkHeader = WorkQueue.Load(ItemIdx * 4); - uint2 ST = StartPixel + (uint2(WorkHeader >> 8, WorkHeader >> 20) & 0xFFF); - uint GradientDir = WorkHeader & 1; // Determines which side of the pixel has the highest contrast - float Subpix = (WorkHeader & 0xFE) / 254.0 * 0.5; // 7-bits to encode [0, 0.5] - -#ifdef VERTICAL_ORIENTATION - float NextLuma = Luma[ST + int2(GradientDir * 2 - 1, 0)]; - float2 StartUV = (ST + float2(GradientDir, 0.5)) * RcpTextureSize; -#else - float NextLuma = Luma[ST + int2(0, GradientDir * 2 - 1)]; - float2 StartUV = (ST + float2(0.5, GradientDir)) * RcpTextureSize; -#endif - float ThisLuma = Luma[ST]; - float CenterLuma = (NextLuma + ThisLuma) * 0.5; // Halfway between this and next; center of the contrasting edge - float GradientSgn = sign(NextLuma - ThisLuma); // Going down in brightness or up? - float GradientMag = abs(NextLuma - ThisLuma) * 0.25; // How much contrast? When can we stop looking? - - float NegDist = s_SampleDistances[NUM_SAMPLES]; - float PosDist = s_SampleDistances[NUM_SAMPLES]; - bool NegGood = false; - bool PosGood = false; - - for (uint iter = 0; iter < NUM_SAMPLES; ++iter) - { - const float Distance = s_SampleDistances[iter]; - -#ifdef VERTICAL_ORIENTATION - float2 NegUV = StartUV - float2(0, RcpTextureSize.y) * Distance; - float2 PosUV = StartUV + float2(0, RcpTextureSize.y) * Distance; -#else - float2 NegUV = StartUV - float2(RcpTextureSize.x, 0) * Distance; - float2 PosUV = StartUV + float2(RcpTextureSize.x, 0) * Distance; -#endif - - // Check for a negative endpoint - float NegGrad = Luma.SampleLevel(LinearSampler, NegUV, 0) - CenterLuma; - if (abs(NegGrad) >= GradientMag && Distance < NegDist) - { - NegDist = Distance; - NegGood = sign(NegGrad) == GradientSgn; - } - - // Check for a positive endpoint - float PosGrad = Luma.SampleLevel(LinearSampler, PosUV, 0) - CenterLuma; - if (abs(PosGrad) >= GradientMag && Distance < PosDist) - { - PosDist = Distance; - PosGood = sign(PosGrad) == GradientSgn; - } - } - - // Ranges from 0.0 to 0.5 - float PixelShift = 0.5 - min(NegDist, PosDist) / (PosDist + NegDist); - bool GoodSpan = NegDist < PosDist ? NegGood : PosGood; - PixelShift = max(Subpix, GoodSpan ? PixelShift : 0.0); - - if (PixelShift > 0.01) - { -#ifdef DEBUG_OUTPUT - #if SUPPORT_TYPED_UAV_LOADS - DstColor[ST] = float3(2.0 * PixelShift, 1.0 - 2.0 * PixelShift, 0); - #else - DstColor[ST] = Pack_R11G11B10_FLOAT(float3(2.0 * PixelShift, 1.0 - 2.0 * PixelShift, 0)); - #endif -#else - #if SUPPORT_TYPED_UAV_LOADS - DstColor[ST] = lerp(DstColor[ST], ColorQueue[ItemIdx], PixelShift); - #else - DstColor[ST] = Pack_R11G11B10_FLOAT(lerp(Unpack_R11G11B10_FLOAT(DstColor[ST]), ColorQueue[ItemIdx], PixelShift)); - #endif -#endif - } -#ifdef DEBUG_OUTPUT - else - { - #if SUPPORT_TYPED_UAV_LOADS - DstColor[ST] = float3(0, 0, 0.25); - #else - DstColor[ST] = Pack_R11G11B10_FLOAT(float3(0, 0, 0.25)); - #endif - } -#endif -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass2H2CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass2H2CS.hlsl deleted file mode 100644 index ffc4bf2..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass2H2CS.hlsl +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define SUPPORT_TYPED_UAV_LOADS 1 - -#include "FXAAPass2CS.hlsli" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass2HCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass2HCS.hlsl deleted file mode 100644 index d12eb12..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass2HCS.hlsl +++ /dev/null @@ -1,14 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "FXAAPass2CS.hlsli" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass2HDebug2CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass2HDebug2CS.hlsl deleted file mode 100644 index 1726b02..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass2HDebug2CS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define SUPPORT_TYPED_UAV_LOADS 1 -#include "FXAAPass2HDebugCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass2HDebugCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass2HDebugCS.hlsl deleted file mode 100644 index 45b2452..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass2HDebugCS.hlsl +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define DEBUG_OUTPUT - -#include "FXAAPass2CS.hlsli" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass2V2CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass2V2CS.hlsl deleted file mode 100644 index 0c1f117..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass2V2CS.hlsl +++ /dev/null @@ -1,17 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define VERTICAL_ORIENTATION -#define SUPPORT_TYPED_UAV_LOADS 1 - -#include "FXAAPass2CS.hlsli" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass2VCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass2VCS.hlsl deleted file mode 100644 index cb47a88..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass2VCS.hlsl +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define VERTICAL_ORIENTATION - -#include "FXAAPass2CS.hlsli" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass2VDebug2CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass2VDebug2CS.hlsl deleted file mode 100644 index 26101ea..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass2VDebug2CS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define SUPPORT_TYPED_UAV_LOADS 1 -#include "FXAAPass2VDebugCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass2VDebugCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass2VDebugCS.hlsl deleted file mode 100644 index e3d664d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAPass2VDebugCS.hlsl +++ /dev/null @@ -1,17 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define VERTICAL_ORIENTATION -#define DEBUG_OUTPUT - -#include "FXAAPass2CS.hlsli" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAResolveWorkQueueCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAResolveWorkQueueCS.hlsl deleted file mode 100644 index 77cc8c3..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAAResolveWorkQueueCS.hlsl +++ /dev/null @@ -1,49 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// -// Used with FXAA to resolve the lengths of the two work queues and to generate DispatchIndirect parameters. -// The work queues are also padded out to a multiple of 64 with dummy work items. -// - -#include "FXAARootSignature.hlsli" - -RWByteAddressBuffer IndirectParams : register(u0); -RWByteAddressBuffer WorkQueue : register(u1); -RWByteAddressBuffer WorkCounts : register(u2); - -[RootSignature(FXAA_RootSig)] -[numthreads( 64, 1, 1 )] -void main( uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID ) -{ - uint2 PixelCounts = WorkCounts.Load2(0); - - // Write out padding to the buffer - uint PixelCountH = PixelCounts.x; - uint PaddedCountH = (PixelCountH + 63) & ~63; - if (GI + PixelCountH < PaddedCountH) - WorkQueue.Store((PixelCountH + GI) * 4, 0xffffffff); - - // Write out padding to the buffer - uint PixelCountV = PixelCounts.y; - uint PaddedCountV = (PixelCountV + 63) & ~63; - if (GI + PixelCountV < PaddedCountV) - WorkQueue.Store((LastQueueIndex - PixelCountV - GI) * 4, 0xffffffff); - - DeviceMemoryBarrierWithGroupSync(); - - if (GI == 0) - { - IndirectParams.Store(0 , PaddedCountH >> 6); - IndirectParams.Store(12, PaddedCountV >> 6); - WorkCounts.Store2(0, 0); - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAARootSignature.hlsli b/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAARootSignature.hlsli deleted file mode 100644 index 837d86c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/FXAARootSignature.hlsli +++ /dev/null @@ -1,32 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define FXAA_RootSig \ - "RootFlags(0), " \ - "RootConstants(b0, num32BitConstants=7), " \ - "DescriptorTable(UAV(u0, numDescriptors = 5))," \ - "DescriptorTable(SRV(t0, numDescriptors = 6))," \ - "StaticSampler(s0," \ - "addressU = TEXTURE_ADDRESS_CLAMP," \ - "addressV = TEXTURE_ADDRESS_CLAMP," \ - "addressW = TEXTURE_ADDRESS_CLAMP," \ - "filter = FILTER_MIN_MAG_MIP_LINEAR)" - -cbuffer CB0 : register(b0) -{ - float2 RcpTextureSize; - float ContrastThreshold; // default = 0.2, lower is more expensive - float SubpixelRemoval; // default = 0.75, lower blurs less - uint LastQueueIndex; - uint2 StartPixel; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/GenerateHistogramCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/GenerateHistogramCS.hlsl deleted file mode 100644 index f8d09d5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/GenerateHistogramCS.hlsl +++ /dev/null @@ -1,48 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// -// The group size is 16x16, but one group iterates over an entire 16-wide column of pixels (384 pixels tall) -// Assuming the total workspace is 640x384, there will be 40 thread groups computing the histogram in parallel. -// The histogram measures logarithmic luminance ranging from 2^-12 up to 2^4. This should provide a nice window -// where the exposure would range from 2^-4 up to 2^4. - -#include "PostEffectsRS.hlsli" - -Texture2D LumaBuf : register( t0 ); -RWByteAddressBuffer Histogram : register( u0 ); - -groupshared uint g_TileHistogram[256]; - -cbuffer CB0 : register(b0) -{ - uint kBufferHeight; -} - -[RootSignature(PostEffects_RootSig)] -[numthreads( 16, 16, 1 )] -void main( uint GI : SV_GroupIndex, uint3 DTid : SV_DispatchThreadID ) -{ - g_TileHistogram[GI] = 0; - - GroupMemoryBarrierWithGroupSync(); - - // Loop until the entire column has been processed - for (uint2 ST = DTid.xy; ST.y < kBufferHeight; ST.y += 16) - { - uint QuantizedLogLuma = LumaBuf[ST]; - InterlockedAdd( g_TileHistogram[QuantizedLogLuma], 1 ); - } - - GroupMemoryBarrierWithGroupSync(); - - Histogram.InterlockedAdd( GI * 4, g_TileHistogram[GI] ); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/GenerateMipsCS.hlsli b/xess/samples/xess_demo/MiniEngine/Core/Shaders/GenerateMipsCS.hlsli deleted file mode 100644 index 40587de..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/GenerateMipsCS.hlsli +++ /dev/null @@ -1,176 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "CommonRS.hlsli" - -#ifndef NON_POWER_OF_TWO -#define NON_POWER_OF_TWO 0 -#endif - -RWTexture2D OutMip1 : register(u0); -RWTexture2D OutMip2 : register(u1); -RWTexture2D OutMip3 : register(u2); -RWTexture2D OutMip4 : register(u3); -Texture2D SrcMip : register(t0); -SamplerState BilinearClamp : register(s0); - -cbuffer CB0 : register(b0) -{ - uint SrcMipLevel; // Texture level of source mip - uint NumMipLevels; // Number of OutMips to write: [1, 4] - float2 TexelSize; // 1.0 / OutMip1.Dimensions -} - -// The reason for separating channels is to reduce bank conflicts in the -// local data memory controller. A large stride will cause more threads -// to collide on the same memory bank. -groupshared float gs_R[64]; -groupshared float gs_G[64]; -groupshared float gs_B[64]; -groupshared float gs_A[64]; - -void StoreColor( uint Index, float4 Color ) -{ - gs_R[Index] = Color.r; - gs_G[Index] = Color.g; - gs_B[Index] = Color.b; - gs_A[Index] = Color.a; -} - -float4 LoadColor( uint Index ) -{ - return float4( gs_R[Index], gs_G[Index], gs_B[Index], gs_A[Index]); -} - -float3 ApplySRGBCurve(float3 x) -{ - // This is exactly the sRGB curve - //return x < 0.0031308 ? 12.92 * x : 1.055 * pow(abs(x), 1.0 / 2.4) - 0.055; - - // This is cheaper but nearly equivalent - return x < 0.0031308 ? 12.92 * x : 1.13005 * sqrt(abs(x - 0.00228)) - 0.13448 * x + 0.005719; -} - -float4 PackColor(float4 Linear) -{ -#ifdef CONVERT_TO_SRGB - return float4(ApplySRGBCurve(Linear.rgb), Linear.a); -#else - return Linear; -#endif -} - -[RootSignature(Common_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint GI : SV_GroupIndex, uint3 DTid : SV_DispatchThreadID ) -{ - // One bilinear sample is insufficient when scaling down by more than 2x. - // You will slightly undersample in the case where the source dimension - // is odd. This is why it's a really good idea to only generate mips on - // power-of-two sized textures. Trying to handle the undersampling case - // will force this shader to be slower and more complicated as it will - // have to take more source texture samples. -#if NON_POWER_OF_TWO == 0 - float2 UV = TexelSize * (DTid.xy + 0.5); - float4 Src1 = SrcMip.SampleLevel(BilinearClamp, UV, SrcMipLevel); -#elif NON_POWER_OF_TWO == 1 - // > 2:1 in X dimension - // Use 2 bilinear samples to guarantee we don't undersample when downsizing by more than 2x - // horizontally. - float2 UV1 = TexelSize * (DTid.xy + float2(0.25, 0.5)); - float2 Off = TexelSize * float2(0.5, 0.0); - float4 Src1 = 0.5 * (SrcMip.SampleLevel(BilinearClamp, UV1, SrcMipLevel) + - SrcMip.SampleLevel(BilinearClamp, UV1 + Off, SrcMipLevel)); -#elif NON_POWER_OF_TWO == 2 - // > 2:1 in Y dimension - // Use 2 bilinear samples to guarantee we don't undersample when downsizing by more than 2x - // vertically. - float2 UV1 = TexelSize * (DTid.xy + float2(0.5, 0.25)); - float2 Off = TexelSize * float2(0.0, 0.5); - float4 Src1 = 0.5 * (SrcMip.SampleLevel(BilinearClamp, UV1, SrcMipLevel) + - SrcMip.SampleLevel(BilinearClamp, UV1 + Off, SrcMipLevel)); -#elif NON_POWER_OF_TWO == 3 - // > 2:1 in in both dimensions - // Use 4 bilinear samples to guarantee we don't undersample when downsizing by more than 2x - // in both directions. - float2 UV1 = TexelSize * (DTid.xy + float2(0.25, 0.25)); - float2 O = TexelSize * 0.5; - float4 Src1 = SrcMip.SampleLevel(BilinearClamp, UV1, SrcMipLevel); - Src1 += SrcMip.SampleLevel(BilinearClamp, UV1 + float2(O.x, 0.0), SrcMipLevel); - Src1 += SrcMip.SampleLevel(BilinearClamp, UV1 + float2(0.0, O.y), SrcMipLevel); - Src1 += SrcMip.SampleLevel(BilinearClamp, UV1 + float2(O.x, O.y), SrcMipLevel); - Src1 *= 0.25; -#endif - - OutMip1[DTid.xy] = PackColor(Src1); - - // A scalar (constant) branch can exit all threads coherently. - if (NumMipLevels == 1) - return; - - // Without lane swizzle operations, the only way to share data with other - // threads is through LDS. - StoreColor(GI, Src1); - - // This guarantees all LDS writes are complete and that all threads have - // executed all instructions so far (and therefore have issued their LDS - // write instructions.) - GroupMemoryBarrierWithGroupSync(); - - // With low three bits for X and high three bits for Y, this bit mask - // (binary: 001001) checks that X and Y are even. - if ((GI & 0x9) == 0) - { - float4 Src2 = LoadColor(GI + 0x01); - float4 Src3 = LoadColor(GI + 0x08); - float4 Src4 = LoadColor(GI + 0x09); - Src1 = 0.25 * (Src1 + Src2 + Src3 + Src4); - - OutMip2[DTid.xy / 2] = PackColor(Src1); - StoreColor(GI, Src1); - } - - if (NumMipLevels == 2) - return; - - GroupMemoryBarrierWithGroupSync(); - - // This bit mask (binary: 011011) checks that X and Y are multiples of four. - if ((GI & 0x1B) == 0) - { - float4 Src2 = LoadColor(GI + 0x02); - float4 Src3 = LoadColor(GI + 0x10); - float4 Src4 = LoadColor(GI + 0x12); - Src1 = 0.25 * (Src1 + Src2 + Src3 + Src4); - - OutMip3[DTid.xy / 4] = PackColor(Src1); - StoreColor(GI, Src1); - } - - if (NumMipLevels == 3) - return; - - GroupMemoryBarrierWithGroupSync(); - - // This bit mask would be 111111 (X & Y multiples of 8), but only one - // thread fits that criteria. - if (GI == 0) - { - float4 Src2 = LoadColor(GI + 0x04); - float4 Src3 = LoadColor(GI + 0x20); - float4 Src4 = LoadColor(GI + 0x24); - Src1 = 0.25 * (Src1 + Src2 + Src3 + Src4); - - OutMip4[DTid.xy / 8] = PackColor(Src1); - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/GenerateMipsGammaCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/GenerateMipsGammaCS.hlsl deleted file mode 100644 index 3ed1ca5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/GenerateMipsGammaCS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define CONVERT_TO_SRGB -#include "GenerateMipsCS.hlsli" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/GenerateMipsGammaOddCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/GenerateMipsGammaOddCS.hlsl deleted file mode 100644 index 4545115..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/GenerateMipsGammaOddCS.hlsl +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define CONVERT_TO_SRGB -#define NON_POWER_OF_TWO 3 -#include "GenerateMipsCS.hlsli" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/GenerateMipsGammaOddXCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/GenerateMipsGammaOddXCS.hlsl deleted file mode 100644 index 010e98d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/GenerateMipsGammaOddXCS.hlsl +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define CONVERT_TO_SRGB -#define NON_POWER_OF_TWO 1 -#include "GenerateMipsCS.hlsli" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/GenerateMipsGammaOddYCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/GenerateMipsGammaOddYCS.hlsl deleted file mode 100644 index 6bc0d7d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/GenerateMipsGammaOddYCS.hlsl +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define CONVERT_TO_SRGB -#define NON_POWER_OF_TWO 2 -#include "GenerateMipsCS.hlsli" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/GenerateMipsLinearCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/GenerateMipsLinearCS.hlsl deleted file mode 100644 index 19d1d90..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/GenerateMipsLinearCS.hlsl +++ /dev/null @@ -1,14 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "GenerateMipsCS.hlsli" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/GenerateMipsLinearOddCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/GenerateMipsLinearOddCS.hlsl deleted file mode 100644 index 8641651..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/GenerateMipsLinearOddCS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define NON_POWER_OF_TWO 3 -#include "GenerateMipsCS.hlsli" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/GenerateMipsLinearOddXCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/GenerateMipsLinearOddXCS.hlsl deleted file mode 100644 index ede7b44..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/GenerateMipsLinearOddXCS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define NON_POWER_OF_TWO 1 -#include "GenerateMipsCS.hlsli" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/GenerateMipsLinearOddYCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/GenerateMipsLinearOddYCS.hlsl deleted file mode 100644 index afd17ad..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/GenerateMipsLinearOddYCS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define NON_POWER_OF_TWO 2 -#include "GenerateMipsCS.hlsli" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ImGuiPS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ImGuiPS.hlsl deleted file mode 100644 index 668df1c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ImGuiPS.hlsl +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright 2021 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files(the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions : - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ - -struct PS_INPUT -{ - float4 pos : SV_POSITION; - float4 col : COLOR0; - float2 uv : TEXCOORD0; -}; - -Texture2D UITexture : register(t0); -SamplerState LinearSampler : register(s0); - -float4 main(PS_INPUT Input) : SV_Target -{ - float4 out_col = Input.col * UITexture.Sample(LinearSampler, Input.uv); - return out_col; -} \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ImGuiVS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ImGuiVS.hlsl deleted file mode 100644 index 64bd5c6..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ImGuiVS.hlsl +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * Copyright 2021 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files(the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions : - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ - -cbuffer vertexBuffer : register(b0) -{ - matrix ProjectionMatrix; -}; - -struct VS_INPUT -{ - float2 pos : POSITION; - float4 col : COLOR0; - float2 uv : TEXCOORD0; -}; - -struct VS_OUTPUT -{ - float4 pos : SV_POSITION; - float4 col : COLOR0; - float2 uv : TEXCOORD0; -}; - -VS_OUTPUT main(VS_INPUT input) -{ - VS_OUTPUT output; - output.pos = mul(ProjectionMatrix, float4(input.pos.xy, 0.f, 1.f)); - output.col = input.col; - output.uv = input.uv; - return output; -} \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/LanczosCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/LanczosCS.hlsl deleted file mode 100644 index 31a2c89..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/LanczosCS.hlsl +++ /dev/null @@ -1,134 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// Jack Elliott -// - -#include "LanczosFunctions.hlsli" -#include "PresentRS.hlsli" -#include "ShaderUtility.hlsli" - -Texture2D Source : register(t0); -RWTexture2D Dest : register(u0); - -cbuffer CB0 : register(b0) -{ - float2 kRcpScale; -}; - -#ifndef ENABLE_FAST_PATH - #define TILE_DIM_X 16 - #define TILE_DIM_Y 16 -#endif -#define GROUP_COUNT (TILE_DIM_X * TILE_DIM_Y) - -// The fast path can be enabled when the source tile plus the extra border pixels fit -// within the destination tile size. For 16x16 destination tiles and 4 taps, you can -// upsample 13x13 tiles and smaller using the fast path. Src/Dest <= 13/16 --> FAST -#ifdef ENABLE_FAST_PATH - #define SAMPLES_X TILE_DIM_X - #define SAMPLES_Y TILE_DIM_Y -#else - #define SAMPLES_X (TILE_DIM_X + 3) - #define SAMPLES_Y (TILE_DIM_Y + 3) -#endif - -#define TOTAL_SAMPLES (SAMPLES_X * SAMPLES_Y) - -// De-interleaved to avoid LDS bank conflicts -groupshared float g_R[TOTAL_SAMPLES]; -groupshared float g_G[TOTAL_SAMPLES]; -groupshared float g_B[TOTAL_SAMPLES]; - -// Store pixel to LDS (local data store) -void StoreLDS(uint LdsIdx, float3 rgb) -{ - g_R[LdsIdx] = rgb.r; - g_G[LdsIdx] = rgb.g; - g_B[LdsIdx] = rgb.b; -} - -// Load four pixel samples from LDS. Stride determines horizontal or vertical groups. -float3x4 LoadSamples(uint idx, uint Stride) -{ - uint i0 = idx, i1 = idx+Stride, i2 = idx+2*Stride, i3=idx+3*Stride; - return float3x4( - g_R[i0], g_R[i1], g_R[i2], g_R[i3], - g_G[i0], g_G[i1], g_G[i2], g_G[i3], - g_B[i0], g_B[i1], g_B[i2], g_B[i3]); -} - -[RootSignature(Present_RootSig)] -[numthreads(TILE_DIM_X, TILE_DIM_Y, 1)] -void main( - uint3 DTid : SV_DispatchThreadID, - uint3 GTid : SV_GroupThreadID, - uint3 Gid : SV_GroupID, - uint GI : SV_GroupIndex) -{ - // Number of samples needed from the source buffer to generate the output tile dimensions. - const uint2 SampleSpace = ceil(float2(TILE_DIM_X, TILE_DIM_Y) * kRcpScale + 3.0); - - // Pre-Load source pixels - int2 UpperLeft = floor((Gid.xy * uint2(TILE_DIM_X, TILE_DIM_Y) + 0.5) * kRcpScale - 1.5); -#ifdef ENABLE_FAST_PATH - // NOTE: If bandwidth is more of a factor than ALU, uncomment this condition. - //if (all(GTid.xy < SampleSpace)) - StoreLDS(GI, Source[UpperLeft + GTid.xy]); -#else - for (uint i = GI; i < TOTAL_SAMPLES; i += GROUP_COUNT) - StoreLDS(i, Source[UpperLeft + int2(i % SAMPLES_X, i / SAMPLES_Y)]); -#endif - - GroupMemoryBarrierWithGroupSync(); - - // The coordinate of the top-left sample from the 4x4 kernel (offset by -0.5 - // so that whole numbers land on a pixel center.) This is in source texture space. - float2 TopLeftSample = (DTid.xy + 0.5) * kRcpScale - 1.5; - - // Position of samples relative to pixels used to evaluate the Sinc function. - float2 Phase = frac(TopLeftSample); - - // LDS tile coordinate for the top-left sample (for this thread) - uint2 TileST = int2(floor(TopLeftSample)) - UpperLeft; - - // Convolution weights, one per sample (in each dimension) - float4 xWeights = GetUpscaleFilterWeights(Phase.x); - float4 yWeights = GetUpscaleFilterWeights(Phase.y); - - // Horizontally convolve the first N rows - uint ReadIdx = TileST.x + GTid.y * SAMPLES_X; -#ifdef ENABLE_FAST_PATH - StoreLDS(GI, mul(LoadSamples(ReadIdx, 1), xWeights)); -#else - uint WriteIdx = GTid.x + GTid.y * SAMPLES_X; - StoreLDS(WriteIdx, mul(LoadSamples(ReadIdx, 1), xWeights)); - - // If the source tile plus border is larger than the destination tile, we - // have to convolve a few more rows. - if (GI + GROUP_COUNT < SampleSpace.y * TILE_DIM_X) - { - ReadIdx += TILE_DIM_Y * SAMPLES_X; - WriteIdx += TILE_DIM_Y * SAMPLES_X; - StoreLDS(WriteIdx, mul(LoadSamples(ReadIdx, 1), xWeights)); - } -#endif - - GroupMemoryBarrierWithGroupSync(); - - // Convolve vertically N columns - ReadIdx = GTid.x + TileST.y * SAMPLES_X; - float3 Result = mul(LoadSamples(ReadIdx, SAMPLES_X), yWeights); - - // Transform to display settings - Result = RemoveDisplayProfile(Result, LDR_COLOR_FORMAT); - Dest[DTid.xy] = ApplyDisplayProfile(Result, DISPLAY_PLANE_FORMAT); -} \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/LanczosFast16CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/LanczosFast16CS.hlsl deleted file mode 100644 index f63b372..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/LanczosFast16CS.hlsl +++ /dev/null @@ -1,21 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// The "fast path" Lanczos filter can be used when the source tile dimensions -// plus the border pixels (3) fit inside 16x16. This reduces bandwidth and -// uses more efficient Math. To determine this case, use the following logic: -// -// bool EnableFastPath = all(srcDim.xy / dstDim.xy <= 13.0 / 16.0); -// - -#define TILE_DIM_X 16 -#define TILE_DIM_Y 16 -#define ENABLE_FAST_PATH 1 -#include "LanczosCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/LanczosFast24CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/LanczosFast24CS.hlsl deleted file mode 100644 index 2b4e4dc..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/LanczosFast24CS.hlsl +++ /dev/null @@ -1,21 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// The "fast path" Lanczos filter can be used when the source tile dimensions -// plus the border pixels (3) fit inside 16x16. This reduces bandwidth and -// uses more efficient Math. To determine this case, use the following logic: -// -// bool EnableFastPath = all(srcDim.xy / dstDim.xy <= 21.0 / 24.0); -// - -#define TILE_DIM_X 32 -#define TILE_DIM_Y 24 -#define ENABLE_FAST_PATH 1 -#include "LanczosCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/LanczosFast32CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/LanczosFast32CS.hlsl deleted file mode 100644 index 94c716a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/LanczosFast32CS.hlsl +++ /dev/null @@ -1,21 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// The "fast path" Lanczos filter can be used when the source tile dimensions -// plus the border pixels (3) fit inside 16x16. This reduces bandwidth and -// uses more efficient Math. To determine this case, use the following logic: -// -// bool EnableFastPath = all(srcDim.xy / dstDim.xy <= 29.0 / 32.0); -// - -#define TILE_DIM_X 32 -#define TILE_DIM_Y 32 -#define ENABLE_FAST_PATH 1 -#include "LanczosCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/LanczosFunctions.hlsli b/xess/samples/xess_demo/MiniEngine/Core/Shaders/LanczosFunctions.hlsli deleted file mode 100644 index d5ac54b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/LanczosFunctions.hlsli +++ /dev/null @@ -1,64 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// Jack Elliott -// - -float Sinc(float x) -{ - if (x == 0.0) - return 1.0; - else - return sin(x) / x; -} - -float Lanczos(float x, float a) -{ - static const float M_PI = 3.1415926535897932384626433832795; - return abs(x) < a ? Sinc(x*M_PI) * Sinc(x/a*M_PI) : 0.0; -} - -float4 ComputeWeights(float fracPart) -{ - float4 weights; - weights.x = Lanczos(-1.0 - fracPart, 2.0); - weights.y = Lanczos( 0.0 - fracPart, 2.0); - weights.z = Lanczos( 1.0 - fracPart, 2.0); - weights.w = Lanczos( 2.0 - fracPart, 2.0); - return weights / dot(weights, 1); -} - -float4 GetUpscaleFilterWeights(float offset) -{ - //return ComputeWeights(offset); - - // Precompute weights for 16 discrete offsets - static const float4 FilterWeights[16] = - { - ComputeWeights( 0.5 / 16.0), - ComputeWeights( 1.5 / 16.0), - ComputeWeights( 2.5 / 16.0), - ComputeWeights( 3.5 / 16.0), - ComputeWeights( 4.5 / 16.0), - ComputeWeights( 5.5 / 16.0), - ComputeWeights( 6.5 / 16.0), - ComputeWeights( 7.5 / 16.0), - ComputeWeights( 8.5 / 16.0), - ComputeWeights( 9.5 / 16.0), - ComputeWeights(10.5 / 16.0), - ComputeWeights(11.5 / 16.0), - ComputeWeights(12.5 / 16.0), - ComputeWeights(13.5 / 16.0), - ComputeWeights(14.5 / 16.0), - ComputeWeights(15.5 / 16.0) - }; - return FilterWeights[(uint)(offset * 16.0)]; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/LanczosHorizontalPS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/LanczosHorizontalPS.hlsl deleted file mode 100644 index 64d0f0d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/LanczosHorizontalPS.hlsl +++ /dev/null @@ -1,57 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// Jack Elliott -// - -#include "LanczosFunctions.hlsli" -#include "PresentRS.hlsli" -#include "ShaderUtility.hlsli" - -Texture2D Source : register(t0); - -cbuffer CB0 : register(b0) -{ - float2 kSrcResolution; -}; - -float4x3 LoadSamples(int2 ST, uint2 Stride) -{ - int2 st0 = ST, st1 = ST+Stride, st2 = ST+2*Stride, st3 = ST+3*Stride; - return float4x3(Source[st0], Source[st1], Source[st2], Source[st3]); -} - -[RootSignature(Present_RootSig)] -float3 main(float4 Pos : SV_Position, float2 UV : TexCoord0) : SV_Target0 -{ - // We subtract 0.5 because that represents the center of the pixel. We need to know where - // we lie between two pixel centers, and we will use frac() for that. We subtract another - // 1.0 so that our start index is one pixel to the left. - float2 TopLeft = UV * kSrcResolution - 1.5; - -#ifdef LANCZOS_VERTICAL - float4 Weights = GetUpscaleFilterWeights(frac(TopLeft.y)); - float4x3 Samples = LoadSamples(int2(floor(Pos.x), TopLeft.y), uint2(0, 1)); -#else - float4 Weights = GetUpscaleFilterWeights(frac(TopLeft.x)); - float4x3 Samples = LoadSamples(int2(TopLeft.x, floor(Pos.y)), uint2(1, 0)); -#endif - - float3 Result = mul(Weights, Samples); - -#ifdef LANCZOS_VERTICAL - // Transform to display settings - Result = RemoveDisplayProfile(Result, LDR_COLOR_FORMAT); - Result = ApplyDisplayProfile(Result, DISPLAY_PLANE_FORMAT); -#endif - - return Result; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/LanczosVerticalPS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/LanczosVerticalPS.hlsl deleted file mode 100644 index 18b6cb4..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/LanczosVerticalPS.hlsl +++ /dev/null @@ -1,13 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// - -#define LANCZOS_VERTICAL 1 -#include "LanczosHorizontalPS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/LinearizeDepthCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/LinearizeDepthCS.hlsl deleted file mode 100644 index 0dfdc93..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/LinearizeDepthCS.hlsl +++ /dev/null @@ -1,29 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "SSAORS.hlsli" - -RWTexture2D LinearZ : register(u0); -Texture2D Depth : register(t0); - -cbuffer CB0 : register(b0) -{ - float ZMagic; // (zFar - zNear) / zNear -} - -[RootSignature(SSAO_RootSig)] -[numthreads( 16, 16, 1 )] -void main( uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID ) -{ - LinearZ[DTid.xy] = 1.0 / (ZMagic * Depth[DTid.xy] + 1.0); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/MagnifyPixelsPS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/MagnifyPixelsPS.hlsl deleted file mode 100644 index 8ac34ff..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/MagnifyPixelsPS.hlsl +++ /dev/null @@ -1,30 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "ShaderUtility.hlsli" -#include "PresentRS.hlsli" - -Texture2D ColorTex : register(t0); -SamplerState PointSampler : register(s1); - -cbuffer Constants : register(b0) -{ - float ScaleFactor; -} - -[RootSignature(Present_RootSig)] -float3 main( float4 position : SV_Position, float2 uv : TexCoord0 ) : SV_Target0 -{ - float2 ScaledUV = ScaleFactor * (uv - 0.5) + 0.5; - return ColorTex.SampleLevel(PointSampler, ScaledUV, 0); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/MotionBlurFinalPassCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/MotionBlurFinalPassCS.hlsl deleted file mode 100644 index 5784a9e..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/MotionBlurFinalPassCS.hlsl +++ /dev/null @@ -1,94 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "CommonRS.hlsli" -#include "PixelPacking_Velocity.hlsli" - -//#define _VELOCITY_UNPACKED_ - -#define MAX_SAMPLE_COUNT 10 -#define STEP_SIZE 3.0 - -#ifdef _VELOCITY_UNPACKED_ -Texture2D VelocityBuffer : register(t0); // full resolution motion vectors -#else -Texture2D VelocityBuffer : register(t0); // full resolution motion vectors -#endif - -Texture2D PrepBuffer : register(t1); // 1/4 resolution pre-weighted blurred color samples -RWTexture2D DstColor : register(u0); // final output color (blurred and temporally blended) -SamplerState LinearSampler : register(s2); // Bilinear w/ black border - -cbuffer c0 : register(b0) -{ - float2 RcpBufferDim; // 1 / width, 1 / height -} - -[RootSignature(Common_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID ) -{ - uint2 st = DTid.xy; - float2 position = st + 0.5; - float2 uv = position * RcpBufferDim; - -#ifdef _VELOCITY_UNPACKED_ - float2 Velocity = VelocityBuffer[st].xy; -#else - float2 Velocity = UnpackVelocity(VelocityBuffer[st]).xy; -#endif - - float3 thisColor = DstColor[st]; - - // Computing speed in this way will set the step size to two-pixel increments in the dominant - // direction. - float Speed = length(Velocity); - - [branch] - if (Speed >= 4.0) - { - float4 accum = float4(thisColor, 1); - - // Half of the speed goes in each direction - float halfSampleCount = min(MAX_SAMPLE_COUNT * 0.5, Speed * 0.5 / STEP_SIZE); - - // Accumulate low-res, pre-weighted samples, summing their weights in alpha. - // The center sample is skipped because we are alpha blending onto it in the - // destination buffer. Only its weight is considered. Accumulating low-res - // samples is not so egregious because the center weight is still high res. - // Also, each of the low res samples is comprised of four pre-weighted high- - // res samples, so they are effectively masked at full resolution. - float2 deltaUV = Velocity / Speed * RcpBufferDim * STEP_SIZE; - float2 uv1 = uv; - float2 uv2 = uv; - - // First accumulate the whole samples - for (float i = halfSampleCount - 1.0; i > 0.0; i -= 1.0) - { - accum += PrepBuffer.SampleLevel(LinearSampler, uv1 += deltaUV, 0); - accum += PrepBuffer.SampleLevel(LinearSampler, uv2 -= deltaUV, 0); - } - - // This is almost the same as 'frac(halfSampleCount)' replaces 0 with 1. - float remainder = 1 + halfSampleCount - ceil(halfSampleCount); - - // Then accumulate the fractional samples - deltaUV *= remainder; - accum += PrepBuffer.SampleLevel(LinearSampler, uv1 + deltaUV, 0) * remainder; - accum += PrepBuffer.SampleLevel(LinearSampler, uv2 - deltaUV, 0) * remainder; - - thisColor = lerp(thisColor, accum.rgb / accum.a, saturate(Speed / 32.0)); - } - - DstColor[st] = thisColor; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/MotionBlurFinalPassPS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/MotionBlurFinalPassPS.hlsl deleted file mode 100644 index 2470d56..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/MotionBlurFinalPassPS.hlsl +++ /dev/null @@ -1,86 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "CommonRS.hlsli" -#include "PixelPacking_Velocity.hlsli" - -//#define _VELOCITY_UNPACKED_ - -#define MAX_SAMPLE_COUNT 10 -#define STEP_SIZE 3.0 - -#ifdef _VELOCITY_UNPACKED_ -Texture2D VelocityBuffer : register(t0); // full resolution motion vectors -#else -Texture2D VelocityBuffer : register(t0); // full resolution motion vectors -#endif - -Texture2D PrepBuffer : register(t1); // 1/4 resolution pre-weighted blurred color samples -SamplerState LinearSampler : register(s2); // Bilinear w/ black border - -cbuffer c0 : register(b0) -{ - float2 RcpBufferDim; // 1 / width, 1 / height -} - -[RootSignature(Common_RootSig)] -float4 main( float4 position : SV_Position ) : SV_Target0 -{ - uint2 st = uint2(position.xy); - float2 uv = position.xy * RcpBufferDim; - -#ifdef _VELOCITY_UNPACKED_ - float2 Velocity = VelocityBuffer[st].xy; -#else - float2 Velocity = UnpackVelocity(VelocityBuffer[st]).xy; -#endif - - // Computing speed in this way will set the step size to two-pixel increments in the dominant - // direction. - float Speed = length(Velocity); - - if (Speed < 4.0) - discard; - - float4 accum = 0; - - // Half of the speed goes in each direction - float halfSampleCount = min(MAX_SAMPLE_COUNT * 0.5, Speed * 0.5 / STEP_SIZE); - - // Accumulate low-res, pre-weighted samples, summing their weights in alpha. - // The center sample is skipped because we are alpha blending onto it in the - // destination buffer. Only its weight is considered. Accumulating low-res - // samples is not so egregious because the center weight is still high res. - // Also, each of the low res samples is comprised of four pre-weighted high- - // res samples, so they are effectively masked at full resolution. - float2 deltaUV = Velocity / Speed * RcpBufferDim * STEP_SIZE; - float2 uv1 = uv; - float2 uv2 = uv; - - // First accumulate the whole samples - for (float i = halfSampleCount - 1.0; i > 0.0; i -= 1.0) - { - accum += PrepBuffer.SampleLevel(LinearSampler, uv1 += deltaUV, 0); - accum += PrepBuffer.SampleLevel(LinearSampler, uv2 -= deltaUV, 0); - } - - // This is almost the same as 'frac(halfSampleCount)' replaces 0 with 1. - float remainder = 1 + halfSampleCount - ceil(halfSampleCount); - - // Then accumulate the fractional samples - deltaUV *= remainder; - accum += PrepBuffer.SampleLevel(LinearSampler, uv1 + deltaUV, 0) * remainder; - accum += PrepBuffer.SampleLevel(LinearSampler, uv2 - deltaUV, 0) * remainder; - - return accum * (saturate(Speed / 32.0) / (accum.a + 1.0)); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/MotionBlurFinalPassUnpackedVelocityCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/MotionBlurFinalPassUnpackedVelocityCS.hlsl deleted file mode 100644 index 89cb012..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/MotionBlurFinalPassUnpackedVelocityCS.hlsl +++ /dev/null @@ -1,94 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "CommonRS.hlsli" -#include "PixelPacking_Velocity.hlsli" - -#define _VELOCITY_UNPACKED_ - -#define MAX_SAMPLE_COUNT 10 -#define STEP_SIZE 3.0 - -#ifdef _VELOCITY_UNPACKED_ -Texture2D VelocityBuffer : register(t0); // full resolution motion vectors -#else -Texture2D VelocityBuffer : register(t0); // full resolution motion vectors -#endif - -Texture2D PrepBuffer : register(t1); // 1/4 resolution pre-weighted blurred color samples -RWTexture2D DstColor : register(u0); // final output color (blurred and temporally blended) -SamplerState LinearSampler : register(s2); // Bilinear w/ black border - -cbuffer c0 : register(b0) -{ - float2 RcpBufferDim; // 1 / width, 1 / height -} - -[RootSignature(Common_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID ) -{ - uint2 st = DTid.xy; - float2 position = st + 0.5; - float2 uv = position * RcpBufferDim; - -#ifdef _VELOCITY_UNPACKED_ - float2 Velocity = VelocityBuffer[st].xy; -#else - float2 Velocity = UnpackVelocity(VelocityBuffer[st]).xy; -#endif - - float3 thisColor = DstColor[st]; - - // Computing speed in this way will set the step size to two-pixel increments in the dominant - // direction. - float Speed = length(Velocity); - - [branch] - if (Speed >= 4.0) - { - float4 accum = float4(thisColor, 1); - - // Half of the speed goes in each direction - float halfSampleCount = min(MAX_SAMPLE_COUNT * 0.5, Speed * 0.5 / STEP_SIZE); - - // Accumulate low-res, pre-weighted samples, summing their weights in alpha. - // The center sample is skipped because we are alpha blending onto it in the - // destination buffer. Only its weight is considered. Accumulating low-res - // samples is not so egregious because the center weight is still high res. - // Also, each of the low res samples is comprised of four pre-weighted high- - // res samples, so they are effectively masked at full resolution. - float2 deltaUV = Velocity / Speed * RcpBufferDim * STEP_SIZE; - float2 uv1 = uv; - float2 uv2 = uv; - - // First accumulate the whole samples - for (float i = halfSampleCount - 1.0; i > 0.0; i -= 1.0) - { - accum += PrepBuffer.SampleLevel(LinearSampler, uv1 += deltaUV, 0); - accum += PrepBuffer.SampleLevel(LinearSampler, uv2 -= deltaUV, 0); - } - - // This is almost the same as 'frac(halfSampleCount)' replaces 0 with 1. - float remainder = 1 + halfSampleCount - ceil(halfSampleCount); - - // Then accumulate the fractional samples - deltaUV *= remainder; - accum += PrepBuffer.SampleLevel(LinearSampler, uv1 + deltaUV, 0) * remainder; - accum += PrepBuffer.SampleLevel(LinearSampler, uv2 - deltaUV, 0) * remainder; - - thisColor = lerp(thisColor, accum.rgb / accum.a, saturate(Speed / 32.0)); - } - - DstColor[st] = thisColor; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/MotionBlurFinalPassUnpackedVelocityPS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/MotionBlurFinalPassUnpackedVelocityPS.hlsl deleted file mode 100644 index c3071f9..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/MotionBlurFinalPassUnpackedVelocityPS.hlsl +++ /dev/null @@ -1,86 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "CommonRS.hlsli" -#include "PixelPacking_Velocity.hlsli" - -#define _VELOCITY_UNPACKED_ - -#define MAX_SAMPLE_COUNT 10 -#define STEP_SIZE 3.0 - -#ifdef _VELOCITY_UNPACKED_ -Texture2D VelocityBuffer : register(t0); // full resolution motion vectors -#else -Texture2D VelocityBuffer : register(t0); // full resolution motion vectors -#endif - -Texture2D PrepBuffer : register(t1); // 1/4 resolution pre-weighted blurred color samples -SamplerState LinearSampler : register(s2); // Bilinear w/ black border - -cbuffer c0 : register(b0) -{ - float2 RcpBufferDim; // 1 / width, 1 / height -} - -[RootSignature(Common_RootSig)] -float4 main( float4 position : SV_Position ) : SV_Target0 -{ - uint2 st = uint2(position.xy); - float2 uv = position.xy * RcpBufferDim; - -#ifdef _VELOCITY_UNPACKED_ - float2 Velocity = VelocityBuffer[st].xy; -#else - float2 Velocity = UnpackVelocity(VelocityBuffer[st]).xy; -#endif - - // Computing speed in this way will set the step size to two-pixel increments in the dominant - // direction. - float Speed = length(Velocity); - - if (Speed < 4.0) - discard; - - float4 accum = 0; - - // Half of the speed goes in each direction - float halfSampleCount = min(MAX_SAMPLE_COUNT * 0.5, Speed * 0.5 / STEP_SIZE); - - // Accumulate low-res, pre-weighted samples, summing their weights in alpha. - // The center sample is skipped because we are alpha blending onto it in the - // destination buffer. Only its weight is considered. Accumulating low-res - // samples is not so egregious because the center weight is still high res. - // Also, each of the low res samples is comprised of four pre-weighted high- - // res samples, so they are effectively masked at full resolution. - float2 deltaUV = Velocity / Speed * RcpBufferDim * STEP_SIZE; - float2 uv1 = uv; - float2 uv2 = uv; - - // First accumulate the whole samples - for (float i = halfSampleCount - 1.0; i > 0.0; i -= 1.0) - { - accum += PrepBuffer.SampleLevel(LinearSampler, uv1 += deltaUV, 0); - accum += PrepBuffer.SampleLevel(LinearSampler, uv2 -= deltaUV, 0); - } - - // This is almost the same as 'frac(halfSampleCount)' replaces 0 with 1. - float remainder = 1 + halfSampleCount - ceil(halfSampleCount); - - // Then accumulate the fractional samples - deltaUV *= remainder; - accum += PrepBuffer.SampleLevel(LinearSampler, uv1 + deltaUV, 0) * remainder; - accum += PrepBuffer.SampleLevel(LinearSampler, uv2 - deltaUV, 0) * remainder; - - return accum * (saturate(Speed / 32.0) / (accum.a + 1.0)); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/MotionBlurPrePassCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/MotionBlurPrePassCS.hlsl deleted file mode 100644 index fc25734..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/MotionBlurPrePassCS.hlsl +++ /dev/null @@ -1,52 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "CommonRS.hlsli" -#include "PixelPacking_Velocity.hlsli" - -//#define _VELOCITY_UNPACKED_ - -Texture2D ColorBuffer : register(t0); - -#ifdef _VELOCITY_UNPACKED_ -Texture2D VelocityBuffer : register(t1); -#else -Texture2D VelocityBuffer : register(t1); -#endif - -RWTexture2D PrepBuffer : register(u0); - -float4 GetSampleData( uint2 st ) -{ -#ifdef _VELOCITY_UNPACKED_ - float Speed = length(VelocityBuffer[st].xy); -#else - float Speed = length(UnpackVelocity(VelocityBuffer[st]).xy); -#endif - return float4(ColorBuffer[st], 1.0) * saturate(Speed * 32.0 / 4.0); -} - -[RootSignature(Common_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID ) -{ - uint2 corner = DTid.xy << 1; - float4 sample0 = GetSampleData( corner + uint2(0, 0) ); - float4 sample1 = GetSampleData( corner + uint2(1, 0) ); - float4 sample2 = GetSampleData( corner + uint2(0, 1) ); - float4 sample3 = GetSampleData( corner + uint2(1, 1) ); - - float combinedMotionWeight = sample0.a + sample1.a + sample2.a + sample3.a + 0.0001; - PrepBuffer[DTid.xy] = floor(0.25 * combinedMotionWeight * 3.0) / 3.0 * float4( - (sample0.rgb + sample1.rgb + sample2.rgb + sample3.rgb) / combinedMotionWeight, 1.0 ); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/MotionBlurPrePassUnpackedVelocityCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/MotionBlurPrePassUnpackedVelocityCS.hlsl deleted file mode 100644 index da7b2ec..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/MotionBlurPrePassUnpackedVelocityCS.hlsl +++ /dev/null @@ -1,52 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "CommonRS.hlsli" -#include "PixelPacking_Velocity.hlsli" - -#define _VELOCITY_UNPACKED_ - -Texture2D ColorBuffer : register(t0); - -#ifdef _VELOCITY_UNPACKED_ -Texture2D VelocityBuffer : register(t1); -#else -Texture2D VelocityBuffer : register(t1); -#endif - -RWTexture2D PrepBuffer : register(u0); - -float4 GetSampleData( uint2 st ) -{ -#ifdef _VELOCITY_UNPACKED_ - float Speed = length(VelocityBuffer[st].xy); -#else - float Speed = length(UnpackVelocity(VelocityBuffer[st]).xy); -#endif - return float4(ColorBuffer[st], 1.0) * saturate(Speed * 32.0 / 4.0); -} - -[RootSignature(Common_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID ) -{ - uint2 corner = DTid.xy << 1; - float4 sample0 = GetSampleData( corner + uint2(0, 0) ); - float4 sample1 = GetSampleData( corner + uint2(1, 0) ); - float4 sample2 = GetSampleData( corner + uint2(0, 1) ); - float4 sample3 = GetSampleData( corner + uint2(1, 1) ); - - float combinedMotionWeight = sample0.a + sample1.a + sample2.a + sample3.a + 0.0001; - PrepBuffer[DTid.xy] = floor(0.25 * combinedMotionWeight * 3.0) / 3.0 * float4( - (sample0.rgb + sample1.rgb + sample2.rgb + sample3.rgb) / combinedMotionWeight, 1.0 ); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/MotionBlurRS.hlsli b/xess/samples/xess_demo/MiniEngine/Core/Shaders/MotionBlurRS.hlsli deleted file mode 100644 index 7e79dd5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/MotionBlurRS.hlsli +++ /dev/null @@ -1,25 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define MotionBlur_RootSig \ - "RootFlags(0), " \ - "RootConstants(b0, num32BitConstants = 4), " \ - "CBV(b1)," \ - "DescriptorTable(UAV(u0, numDescriptors = 8))," \ - "DescriptorTable(SRV(t0, numDescriptors = 8))," \ - "StaticSampler(s0," \ - "addressU = TEXTURE_ADDRESS_BORDER," \ - "addressV = TEXTURE_ADDRESS_BORDER," \ - "addressW = TEXTURE_ADDRESS_BORDER," \ - "borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK," \ - "filter = FILTER_MIN_MAG_MIP_LINEAR)" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleBinCullingCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleBinCullingCS.hlsl deleted file mode 100644 index a08ec99..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleBinCullingCS.hlsl +++ /dev/null @@ -1,83 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// Julia Careaga -// - -#include "ParticleUtility.hlsli" - -#define THREAD_GROUP_SIZE 256 - -StructuredBuffer g_VisibleParticles : register( t0 ); -StructuredBuffer g_LargeBinParticles : register( t1 ); -ByteAddressBuffer g_LargeBinCounters : register( t2 ); -RWStructuredBuffer g_BinParticles : register( u0 ); -RWByteAddressBuffer g_BinCounters : register( u1 ); - -groupshared uint gs_BinCounters[16]; - -cbuffer CB0 : register(b0) -{ - uint2 LogTilesPerBin; -}; - -[RootSignature(Particle_RootSig)] -[numthreads(4, THREAD_GROUP_SIZE / 4, 1)] -void main( uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID ) -{ - uint LargeBinsPerRow = (gBinsPerRow + 3) / 4; - uint ParticlesPerLargeBin = MAX_PARTICLES_PER_BIN * 16; - - uint LargeBinIndex = Gid.y * LargeBinsPerRow + Gid.x; - uint ParticleCountInLargeBin = min(g_LargeBinCounters.Load(LargeBinIndex * 4), ParticlesPerLargeBin); - - // Get the start location for particles in this bin - uint LargeBinStart = LargeBinIndex * ParticlesPerLargeBin; - uint2 FirstBin = Gid.xy * 4; - - if (GI < 16) - gs_BinCounters[GI] = 0; - - GroupMemoryBarrierWithGroupSync(); - - for (uint idx = GI; idx < ParticleCountInLargeBin; idx += THREAD_GROUP_SIZE) - { - uint SortKey = g_LargeBinParticles[LargeBinStart + idx]; - uint GlobalIdx = SortKey & 0x3FFFF; - - uint Bounds = g_VisibleParticles[GlobalIdx].Bounds; - uint2 MinTile = uint2(Bounds >> 0, Bounds >> 8) & 0xFF; - uint2 MaxTile = uint2(Bounds >> 16, Bounds >> 24) & 0xFF; - uint2 MinBin = max(MinTile >> LogTilesPerBin, FirstBin); - uint2 MaxBin = min(MaxTile >> LogTilesPerBin, FirstBin + 3); - - for (uint y = MinBin.y; y <= MaxBin.y; ++y) - { - for (uint x = MinBin.x; x <= MaxBin.x; ++x) - { - uint CounterIdx = (x & 3) | (y & 3) << 2; - uint BinOffset = (x + y * gBinsPerRow) * MAX_PARTICLES_PER_BIN; - uint AllocIdx; - InterlockedAdd(gs_BinCounters[CounterIdx], 1, AllocIdx); - AllocIdx = min(AllocIdx, MAX_PARTICLES_PER_BIN - 1); - g_BinParticles[BinOffset + AllocIdx] = SortKey; - } - } - } - - GroupMemoryBarrierWithGroupSync(); - - if (GI < 16) - { - uint2 OutBin = FirstBin + GTid.xy; - g_BinCounters.Store((OutBin.x + OutBin.y * gBinsPerRow) * 4, gs_BinCounters[GI]); - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleDepthBoundsCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleDepthBoundsCS.hlsl deleted file mode 100644 index 4894ace..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleDepthBoundsCS.hlsl +++ /dev/null @@ -1,101 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// Alex Nankervis -// - -#include "ParticleUtility.hlsli" - -Texture2D g_Input : register(t0); -RWTexture2D g_Output8 : register(u0); -RWTexture2D g_Output16 : register(u1); -RWTexture2D g_Output32 : register(u2); - -groupshared uint gs_Buffer[128]; - -void Max4( uint This, uint Dx ) -{ - uint MM1 = gs_Buffer[This + 1 * Dx]; - uint MM2 = gs_Buffer[This + 8 * Dx]; - uint MM3 = gs_Buffer[This + 9 * Dx]; - GroupMemoryBarrierWithGroupSync(); - InterlockedMax(gs_Buffer[This], max(MM1, max(MM2, MM3))); - GroupMemoryBarrierWithGroupSync(); -} - -uint PackMinMax( uint This ) -{ - float Min = asfloat(~gs_Buffer[This + 64]); - float Max = asfloat(gs_Buffer[This]); - return f32tof16(Max) << 16 | f32tof16(saturate(Min - 0.001)); -} - -[RootSignature(Particle_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 DTid : SV_DispatchThreadID ) -{ - // Load 4x4 depth values (per thread) and compute the min and max of each - float2 UV1 = (DTid.xy * 4 + 1) * gRcpBufferDim; - float2 UV2 = UV1 + float2(2, 0) * gRcpBufferDim; - float2 UV3 = UV1 + float2(0, 2) * gRcpBufferDim; - float2 UV4 = UV1 + float2(2, 2) * gRcpBufferDim; - - float4 ZQuad1 = g_Input.Gather(gSampPointClamp, UV1); - float4 ZQuad2 = g_Input.Gather(gSampPointClamp, UV2); - float4 ZQuad3 = g_Input.Gather(gSampPointClamp, UV3); - float4 ZQuad4 = g_Input.Gather(gSampPointClamp, UV4); - - float4 MaxQuad = max(max(ZQuad1, ZQuad2), max(ZQuad3, ZQuad4)); - float4 MinQuad = min(min(ZQuad1, ZQuad2), min(ZQuad3, ZQuad4)); - - float maxZ = max(max(MaxQuad.x, MaxQuad.y), max(MaxQuad.z, MaxQuad.w)); - float minZ = min(min(MinQuad.x, MinQuad.y), min(MinQuad.z, MinQuad.w)); - - // Parallel reduction will reduce 4:1 per iteration. This reduces LDS loads and stores - // and can take advantage of min3 and max3 instructions when available. - - // Because each iteration puts 3/4 of active threads to sleep, threads are quickly wasted. - // Rather than have each active thread compute both a min and a max, it would be nice if - // we could wake up sleeping threads to share the burden. It turns out this is possible! - // We can have all threads performing Max4() reductions, and by applying it to negative - // min values, we can find the min depth. E.g. min(a, b) = -max(-a, -b) - - // Max values to first 64, Min values to last 64 - gs_Buffer[GI] = asuint(maxZ); - gs_Buffer[GI + 64] = ~asuint(minZ); - GroupMemoryBarrierWithGroupSync(); - - // We don't need odd numbered threads, but we could utilize more threads - const uint This = GI * 2; - - Max4(This, 1); - - // if (X % 2 == 0 && Y % 2 == 0 && Y < 8) - if ((This & 0x49) == 0) - { - uint2 SubTile = uint2(This >> 1, This >> 4) & 3; - g_Output8[Gid.xy * 4 + SubTile] = PackMinMax(This); - } - - Max4(This, 2); - - // if (X % 4 == 0 && Y % 4 == 0 && Y < 8) - if ((This & 0x5B) == 0) - { - uint2 SubTile = uint2(This >> 2, This >> 5) & 1; - g_Output16[Gid.xy * 2 + SubTile] = PackMinMax(This); - } - - Max4(This, 4); - - if (This == 0) - g_Output32[Gid.xy] = PackMinMax(This); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleDispatchIndirectArgsCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleDispatchIndirectArgsCS.hlsl deleted file mode 100644 index be78ba9..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleDispatchIndirectArgsCS.hlsl +++ /dev/null @@ -1,25 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: Julia Careaga -// - -#include "ParticleRS.hlsli" - -ByteAddressBuffer g_ParticleInstance : register( t0 ); -RWByteAddressBuffer g_NumThreadGroups : register( u1 ); - -[RootSignature(Particle_RootSig)] -[numthreads(1, 1, 1)] -void main( uint3 DTid : SV_DispatchThreadID ) -{ - g_NumThreadGroups.Store(0, ( g_ParticleInstance.Load(0) + 63) / 64); - -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleEnableMaskPS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleEnableMaskPS.hlsl deleted file mode 100644 index fa9add0..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleEnableMaskPS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// Julia Careaga -// -#define ENABLE_PARTICLE_RESPONSIVE_MASK -#include "ParticlePS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleFinalDispatchIndirectArgsCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleFinalDispatchIndirectArgsCS.hlsl deleted file mode 100644 index 862e717..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleFinalDispatchIndirectArgsCS.hlsl +++ /dev/null @@ -1,27 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: Julia Careaga -// - -#include "ParticleUtility.hlsli" - -ByteAddressBuffer g_FinalInstanceCounter : register( t0 ); -RWByteAddressBuffer g_NumThreadGroups : register( u0 ); -RWByteAddressBuffer g_DrawIndirectArgs : register ( u1 ); - -[RootSignature(Particle_RootSig)] -[numthreads(1, 1, 1)] -void main( uint3 DTid : SV_DispatchThreadID ) -{ - uint particleCount = g_FinalInstanceCounter.Load(0); - g_NumThreadGroups.Store3(0, uint3((particleCount + 63) / 64, 1, 1)); - g_DrawIndirectArgs.Store(4, particleCount); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleLargeBinCullingCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleLargeBinCullingCS.hlsl deleted file mode 100644 index a436952..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleLargeBinCullingCS.hlsl +++ /dev/null @@ -1,106 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// Julia Careaga -// - -#include "ParticleUtility.hlsli" - -#define MAX_PARTICLES_PER_LARGE_BIN (16 * MAX_PARTICLES_PER_BIN) - -StructuredBuffer g_VertexBuffer : register(t0); -ByteAddressBuffer g_VertexCount : register(t1); -RWStructuredBuffer g_LargeBinParticles : register(u0); -RWByteAddressBuffer g_LargeBinCounters : register(u1); -RWStructuredBuffer g_VisibleParticles : register( u2 ); - -cbuffer CB0 : register(b0) -{ - uint2 LogTilesPerLargeBin; -}; - -[RootSignature(Particle_RootSig)] -[numthreads(64, 1, 1)] -void main( uint3 DTid : SV_DispatchThreadID ) -{ - uint VertexIdx = DTid.x; - - if (VertexIdx >= g_VertexCount.Load(0)) - return; - - // - // Transform and cull the sprite - // - ParticleVertex Sprite = g_VertexBuffer[VertexIdx]; - - // Frustum cull before adding this particle to list of visible particles (for rendering) - float4 HPos = mul( gViewProj, float4(Sprite.Position, 1) ); - float Height = Sprite.Size * gVertCotangent; - float Width = Height * gAspectRatio; - float3 Extent = abs(HPos.xyz) - float3(Width, Height, 0); - - // Technically, we should check for HPos.z > 0 because this is D3D. But there is only a tiny - // window of space between the eye and the near plane where this could be true. - if (max(max(0.0, Extent.x), max(Extent.y, Extent.z)) > HPos.w) - return; - - // - // Generate tile-relevant draw data - // - - ParticleScreenData Particle; - - float RcpW = 1.0 / HPos.w; - - // Compute texture LOD for this sprite - float ScreenSize = Height * RcpW * gBufferDim.y; - float TextureLevel = (float)firstbithigh(MaxTextureSize) - log2(ScreenSize); - - Particle.Corner = float2(HPos.x - Width, -HPos.y - Height) * RcpW * 0.5 + 0.5; - Particle.RcpSize = HPos.w / float2(Width, Height); - Particle.Depth = saturate(HPos.w * gRcpFarZ); - Particle.Color = Sprite.Color; - Particle.TextureIndex = (float)Sprite.TextureID; - Particle.TextureLevel = TextureLevel; - - float2 TopLeft = max(Particle.Corner * gBufferDim, 0.0); - float2 BottomRight = max(TopLeft + gBufferDim / Particle.RcpSize, 0.0); - uint2 EdgeTile = uint2(gTilesPerRow, gTilesPerCol) - 1; - uint2 MinTile = uint2(TopLeft) / TILE_SIZE; - uint2 MaxTile = min(EdgeTile, uint2(BottomRight) / TILE_SIZE); - Particle.Bounds = MinTile.x | MinTile.y << 8 | MaxTile.x << 16 | MaxTile.y << 24; - - uint GlobalIdx = g_VisibleParticles.IncrementCounter(); - - g_VisibleParticles[GlobalIdx] = Particle; - - // - // Insert the particle into all large bins it occupies - // - - uint LargeBinsPerRow = (gBinsPerRow + 3) / 4; - uint2 MinLargeBin = MinTile >> LogTilesPerLargeBin; - uint2 MaxLargeBin = MaxTile >> LogTilesPerLargeBin; - - uint SortKey = f32tof16(Particle.Depth) << 18 | GlobalIdx; - - for (uint y = MinLargeBin.y; y <= MaxLargeBin.y; y++) - { - for (uint x = MinLargeBin.x; x <= MaxLargeBin.x; x++) - { - uint LargeBinIndex = y * LargeBinsPerRow + x; - uint AllocIdx; - g_LargeBinCounters.InterlockedAdd(LargeBinIndex * 4, 1, AllocIdx); - AllocIdx = min(AllocIdx, MAX_PARTICLES_PER_LARGE_BIN - 1); - g_LargeBinParticles[LargeBinIndex * MAX_PARTICLES_PER_LARGE_BIN + AllocIdx] = SortKey; - } - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleNoSortVS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleNoSortVS.hlsl deleted file mode 100644 index 33f83f4..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleNoSortVS.hlsl +++ /dev/null @@ -1,14 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard - -#define DISABLE_PARTICLE_SORT 1 -#include "ParticleVS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticlePS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticlePS.hlsl deleted file mode 100644 index 5bfa2ab..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticlePS.hlsl +++ /dev/null @@ -1,49 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// Julia Careaga -// - -#include "ParticleUpdateCommon.hlsli" -#include "ParticleUtility.hlsli" - -Texture2DArray ColorTex : register(t1); -Texture2D LinearDepthTex : register(t2); - -#ifdef ENABLE_PARTICLE_RESPONSIVE_MASK -struct MRT -{ - float4 Color : SV_Target0; - float ResponsiveMask : SV_Target1; -}; -#endif - -[RootSignature(Particle_RootSig)] -#ifdef ENABLE_PARTICLE_RESPONSIVE_MASK -MRT main(ParticleVertexOutput input) -#else -float4 main(ParticleVertexOutput input ) : SV_Target0 -#endif -{ - float3 uv = float3(input.TexCoord.xy, input.TexID); - float4 TextureColor = ColorTex.Sample( gSampLinearBorder, uv ); - TextureColor.a *= saturate(1000.0 * (LinearDepthTex[(uint2)input.Pos.xy] - input.LinearZ)); - TextureColor.rgb *= TextureColor.a; -#ifdef ENABLE_PARTICLE_RESPONSIVE_MASK - MRT mrt; - mrt.Color = TextureColor * input.Color; - float3 responsiveColor = ceil(mrt.Color.rgb); - mrt.ResponsiveMask = max(responsiveColor.r, max(responsiveColor.g, responsiveColor.b)); - return mrt; -#else - return TextureColor * input.Color; -#endif -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticlePreSortCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticlePreSortCS.hlsl deleted file mode 100644 index a8887c4..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticlePreSortCS.hlsl +++ /dev/null @@ -1,104 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "ParticleUtility.hlsli" - -StructuredBuffer g_VertexBuffer : register( t0 ); -ByteAddressBuffer g_VertexCount : register(t1); -RWStructuredBuffer g_SortBuffer : register(u0); -RWByteAddressBuffer g_DrawIndirectArgs : register(u1); - -groupshared uint gs_SortKeys[2048]; - -void FillSortKey( uint GroupStart, uint Offset, uint VertexCount ) -{ - if (GroupStart + Offset >= VertexCount) - { - gs_SortKeys[Offset] = 0; // Z = 0 will sort to the end of the list (back to front) - return; - } - - uint VertexIdx = GroupStart + Offset; - ParticleVertex Sprite = g_VertexBuffer[VertexIdx]; - - // Frustum cull before adding this particle to list of visible particles (for rendering) - float4 HPos = mul( gViewProj, float4(Sprite.Position, 1) ); - float Height = Sprite.Size * gVertCotangent; - float Width = Height * gAspectRatio; - float3 Extent = abs(HPos.xyz) - float3(Width, Height, 0); - - // Frustum cull rather than sorting and rendering every particle - if (max(max(0.0, Extent.x), max(Extent.y, Extent.z)) <= HPos.w) - { - // Encode depth as 14 bits because we only need [0, 1] at half precision. - // This gives us 18-bit indices--up to 256k particles. - float Depth = saturate(HPos.w * gRcpFarZ); - gs_SortKeys[Offset] = f32tof16(Depth) << 18 | VertexIdx; - - // Increment the visible instance counter - g_DrawIndirectArgs.InterlockedAdd(4, 1); - } - else - { - // Cull particle index by sorting it to the end and not incrementing the visible instance counter - gs_SortKeys[Offset] = 0; - } -} - -[RootSignature(Particle_RootSig)] -[numthreads(1024, 1, 1)] -void main( uint3 DTid : SV_DispatchThreadID, uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex ) -{ - uint VisibleParticles = g_VertexCount.Load(0); - - uint GroupStart = Gid.x * 2048; - - if (GroupStart > VisibleParticles) - { - g_SortBuffer[GroupStart + GI] = 0; - g_SortBuffer[GroupStart + GI + 1024] = 0; - return; - } - - FillSortKey(GroupStart, GI, VisibleParticles); - FillSortKey(GroupStart, GI + 1024, VisibleParticles); - - GroupMemoryBarrierWithGroupSync(); - - uint k; - - [unroll] - for (k = 2; k <= 2048; k *= 2) - { - //[unroll] - for (uint j = k / 2; j > 0; j /= 2) - { - uint Index1 = InsertZeroBit(GI, j); - uint Index2 = Index1 ^ (k == j * 2 ? k - 1 : j); - - uint A = gs_SortKeys[Index1]; - uint B = gs_SortKeys[Index2]; - - if (A < B) - { - gs_SortKeys[Index1] = B; - gs_SortKeys[Index2] = A; - } - - GroupMemoryBarrierWithGroupSync(); - } - } - - g_SortBuffer[GroupStart + GI] = gs_SortKeys[GI]; - g_SortBuffer[GroupStart + GI + 1024] = gs_SortKeys[GI + 1024]; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleRS.hlsli b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleRS.hlsli deleted file mode 100644 index cb0b7fa..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleRS.hlsli +++ /dev/null @@ -1,37 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define Particle_RootSig \ - "RootFlags(0), " \ - "RootConstants(b0, num32BitConstants = 3)," \ - "CBV(b1)," \ - "CBV(b2)," \ - "DescriptorTable(UAV(u0, numDescriptors = 8))," \ - "DescriptorTable(SRV(t0, numDescriptors = 10))," \ - "StaticSampler(s0," \ - "addressU = TEXTURE_ADDRESS_BORDER," \ - "addressV = TEXTURE_ADDRESS_BORDER," \ - "addressW = TEXTURE_ADDRESS_BORDER," \ - "borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK," \ - "filter = FILTER_MIN_MAG_LINEAR_MIP_POINT)," \ - "StaticSampler(s1," \ - "addressU = TEXTURE_ADDRESS_BORDER," \ - "addressV = TEXTURE_ADDRESS_BORDER," \ - "addressW = TEXTURE_ADDRESS_BORDER," \ - "borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK," \ - "filter = FILTER_MIN_MAG_MIP_POINT), " \ - "StaticSampler(s2," \ - "addressU = TEXTURE_ADDRESS_CLAMP," \ - "addressV = TEXTURE_ADDRESS_CLAMP," \ - "addressW = TEXTURE_ADDRESS_CLAMP," \ - "filter = FILTER_MIN_MAG_MIP_POINT)" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleSortIndirectArgsCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleSortIndirectArgsCS.hlsl deleted file mode 100644 index 4a1c5d3..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleSortIndirectArgsCS.hlsl +++ /dev/null @@ -1,30 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "ParticleUtility.hlsli" - -RWByteAddressBuffer g_DispatchIndirectArgs : register(u0); -RWByteAddressBuffer g_DrawIndirectArgs : register(u1); - -[RootSignature(Particle_RootSig)] -[numthreads(1, 1, 1)] -void main( uint GI : SV_GroupIndex ) -{ - uint InstanceCount = g_DrawIndirectArgs.Load(4); - uint ThreadGroupCount = (InstanceCount + 2047) / 2048; - - g_DispatchIndirectArgs.Store3(0, uint3(ThreadGroupCount, 1, 1)); - - // Reset instance count so we can cull and determine how many we need to actually draw - g_DrawIndirectArgs.Store(4, 0); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleSpawnCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleSpawnCS.hlsl deleted file mode 100644 index 147b996..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleSpawnCS.hlsl +++ /dev/null @@ -1,45 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: Julia Careaga -// James Stanard -// - -#include "ParticleUpdateCommon.hlsli" -#include "ParticleUtility.hlsli" - -StructuredBuffer< ParticleSpawnData > g_ResetData : register( t0 ); -RWStructuredBuffer< ParticleMotion > g_OutputBuffer : register( u2 ); - -[RootSignature(Particle_RootSig)] -[numthreads(64, 1, 1)] -void main( uint3 DTid : SV_DispatchThreadID ) -{ - uint index = g_OutputBuffer.IncrementCounter(); - if (index >= MaxParticles) - return; - - uint ResetDataIndex = RandIndex[DTid.x].x; - ParticleSpawnData rd = g_ResetData[ResetDataIndex]; - - float3 emitterVelocity = EmitPosW - LastEmitPosW; - float3 randDir = rd.Velocity.x * EmitRightW + rd.Velocity.y * EmitUpW + rd.Velocity.z * EmitDirW; - float3 newVelocity = emitterVelocity * EmitterVelocitySensitivity + randDir; - float3 adjustedPosition = EmitPosW - emitterVelocity * rd.Random + rd.SpreadOffset; - - ParticleMotion newParticle; - newParticle.Position = adjustedPosition; - newParticle.Rotation = 0.0; - newParticle.Velocity = newVelocity + EmitDirW * EmitSpeed; - newParticle.Mass = rd.Mass; - newParticle.Age = 0.0; - newParticle.ResetDataIndex = ResetDataIndex; - g_OutputBuffer[index] = newParticle; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileCullingCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileCullingCS.hlsl deleted file mode 100644 index d5bf809..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileCullingCS.hlsl +++ /dev/null @@ -1,225 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// Julia Careaga -// - -#include "ParticleUtility.hlsli" - -StructuredBuffer g_BinParticles : register(t0); -ByteAddressBuffer g_BinCounters : register(t1); -Texture2D g_DepthBounds : register(t2); -StructuredBuffer g_VisibleParticles : register(t3); - -RWStructuredBuffer g_SortedParticles : register(u0); -RWByteAddressBuffer g_TileHitMasks : register(u1); -RWStructuredBuffer g_DrawPackets : register(u2); -RWStructuredBuffer g_FastDrawPackets : register(u3); -RWByteAddressBuffer g_DrawPacketCount : register(u4); - -#if TILES_PER_BIN < 64 -#define GROUP_THREAD_COUNT 64 -#else -#define GROUP_THREAD_COUNT TILES_PER_BIN -#endif -#define GROUP_SIZE_X TILES_PER_BIN_X -#define GROUP_SIZE_Y (GROUP_THREAD_COUNT / GROUP_SIZE_X) -#define MASK_WORDS_PER_ITER (GROUP_THREAD_COUNT / 32) - -groupshared uint gs_SortKeys[MAX_PARTICLES_PER_BIN]; -groupshared uint gs_IntersectionMasks[TILES_PER_BIN * MASK_WORDS_PER_ITER]; -groupshared uint gs_TileParticleCounts[TILES_PER_BIN]; -groupshared uint gs_SlowTileParticleCounts[TILES_PER_BIN]; -groupshared uint gs_MinMaxDepth[TILES_PER_BIN]; - -void BitonicSort(uint GI, uint NumElements, uint NextPow2, uint NumThreads) -{ - for (uint k = 2; k <= NextPow2; k *= 2) - { - // Align NumElements to the next multiple of k - NumElements = (NumElements + k - 1) & ~(k - 1); - - for (uint j = k / 2; j > 0; j /= 2) - { - // Loop over all N/2 unique element pairs - for (uint i = GI; i < NumElements / 2; i += NumThreads) - { - uint Index1 = InsertZeroBit(i, j); - uint Index2 = Index1 | j; - - uint A = gs_SortKeys[Index1]; - uint B = gs_SortKeys[Index2]; - - if ((A < B) != ((Index1 & k) == 0)) - { - gs_SortKeys[Index1] = B; - gs_SortKeys[Index2] = A; - } - } - - GroupMemoryBarrierWithGroupSync(); - } - } -} - -uint ComputeMaskOffset( uint2 Gid, uint2 GTid ) -{ - // Sometimes we have more threads than tiles per bin. - uint2 OutTileCoord = Gid.xy * uint2(TILES_PER_BIN_X, TILES_PER_BIN_Y) + uint2(GTid.x, GTid.y % TILES_PER_BIN_Y); - uint OutTileIdx = OutTileCoord.x + OutTileCoord.y * gTileRowPitch; - return OutTileIdx * MAX_PARTICLES_PER_BIN / 8 + GTid.y / TILES_PER_BIN_Y * 4; -} - -[RootSignature(Particle_RootSig)] -[numthreads(GROUP_SIZE_X, GROUP_SIZE_Y, 1)] -void main( uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID ) -{ - // Each group is assigned a bin - uint BinIndex = Gid.y * gBinsPerRow + Gid.x; - - uint ParticleCountInBin = g_BinCounters.Load(BinIndex * 4); - if (ParticleCountInBin == 0) - return; - - // Get the start location for particles in this bin - uint BinStart = BinIndex * MAX_PARTICLES_PER_BIN; - - // Each thread is assigned a tile - uint2 TileCoord = Gid.xy * uint2(TILES_PER_BIN_X, TILES_PER_BIN_Y) + GTid.xy; - - if (GI < TILES_PER_BIN) - { - gs_TileParticleCounts[GI] = 0; - gs_SlowTileParticleCounts[GI] = 0; - gs_MinMaxDepth[GI] = g_DepthBounds[TileCoord] << 2; - } - - // Sometimes the counter value exceeds the actual storage size - ParticleCountInBin = min(MAX_PARTICLES_PER_BIN, ParticleCountInBin); - - // Compute the next power of two for the bitonic sort - uint NextPow2 = countbits(ParticleCountInBin) <= 1 ? ParticleCountInBin : (2 << firstbithigh(ParticleCountInBin)); - - // Fill in the sort key array. Each sort key has passenger data (in the least signficant - // bits, so that as the sort keys are moved around, they retain a pointer to the particle - // they refer to. - for (uint k = GI; k < NextPow2; k += GROUP_THREAD_COUNT) - gs_SortKeys[k] = k < ParticleCountInBin ? g_BinParticles[BinStart + k] : 0xffffffff; - - GroupMemoryBarrierWithGroupSync(); - - // Sort the particles from front to back. - BitonicSort(GI, ParticleCountInBin, NextPow2, GROUP_THREAD_COUNT); - - // Upper-left tile coord and lower-right coord, clamped to the screen - const int2 StartTile = Gid.xy * uint2(TILES_PER_BIN_X, TILES_PER_BIN_Y); - - // Each thread writes the hit mask for one tile - uint OutOffsetInBytes = ComputeMaskOffset(Gid.xy, GTid.xy); - - // Loop over all sorted particles, group-size count at a time - for (uint Iter = 0; Iter < ParticleCountInBin; Iter += GROUP_THREAD_COUNT) - { - // Reset temporary particle intersection masks. There are two words (64-bits) per thread. - //[unroll] - for (uint C = GI; C < TILES_PER_BIN * MASK_WORDS_PER_ITER; C += GROUP_THREAD_COUNT) - gs_IntersectionMasks[C] = 0; - - GroupMemoryBarrierWithGroupSync(); - - // The array index of the particle this thread will test - uint SortIdx = Iter + GI; - - // Compute word and bit to set (from thread index) - uint WordOffset = GI >> 5; - uint BitOffset = GI & 31; - - // Only do the loads and stores if this is a valid index (see constant number of iterations comment above) - if (SortIdx < ParticleCountInBin) - { - uint SortKey = gs_SortKeys[SortIdx]; - uint GlobalIdx = SortKey & 0x3FFFF; - - // After this phase, all we care about is its global index - g_SortedParticles[BinStart + SortIdx] = SortKey; - - uint Bounds = g_VisibleParticles[GlobalIdx].Bounds; - int2 MinTile = uint2(Bounds >> 0, Bounds >> 8) & 0xFF; - int2 MaxTile = uint2(Bounds >> 16, Bounds >> 24) & 0xFF; - MinTile = max(MinTile - StartTile, 0); - MaxTile = min(MaxTile - StartTile, int2(TILES_PER_BIN_X, TILES_PER_BIN_Y) - 1); - - for (int y = MinTile.y; y <= MaxTile.y; y++) - { - for (int x = MinTile.x; x <= MaxTile.x; x++) - { - uint TileIndex = y * TILES_PER_BIN_X + x; - uint TileMaxZ = gs_MinMaxDepth[TileIndex]; - uint Inside = SortKey < TileMaxZ ? 1 : 0; - uint SlowPath = SortKey > (TileMaxZ << 16) ? Inside : 0; - InterlockedAdd(gs_SlowTileParticleCounts[TileIndex], SlowPath); - InterlockedOr(gs_IntersectionMasks[TileIndex * MASK_WORDS_PER_ITER + WordOffset], Inside << BitOffset); - } - } - } - - GroupMemoryBarrierWithGroupSync(); - -#if TILES_PER_BIN < GROUP_THREAD_COUNT - // Copy the hit masks from LDS to the output buffer. Here, each thread copies a single word - if (GI < TILES_PER_BIN * MASK_WORDS_PER_ITER) - { - uint TileIndex = GI % TILES_PER_BIN; - uint Offset = TileIndex * MASK_WORDS_PER_ITER + (GI / TILES_PER_BIN); - uint Mask = gs_IntersectionMasks[Offset]; - InterlockedAdd(gs_TileParticleCounts[TileIndex], countbits(Mask)); - g_TileHitMasks.Store(OutOffsetInBytes, Mask); - OutOffsetInBytes += 8; - } -#else - // Copy the hit masks from LDS to the output buffer. Here, each thread is assigned a tile. - uint Offset = GI * MASK_WORDS_PER_ITER; - [unroll] - for (uint O = 0; O < MASK_WORDS_PER_ITER; O += 2) - { - uint Mask0 = gs_IntersectionMasks[Offset+O]; - uint Mask1 = gs_IntersectionMasks[Offset+O+1]; - InterlockedAdd(gs_TileParticleCounts[GI], countbits(Mask0) + countbits(Mask1)); - g_TileHitMasks.Store2( OutOffsetInBytes, uint2(Mask0, Mask1) ); - OutOffsetInBytes += 8; - } -#endif - - GroupMemoryBarrierWithGroupSync(); - } - - if (GI >= TILES_PER_BIN) - return; - - uint ParticleCountInThisThreadsTile = gs_TileParticleCounts[GI]; - if (ParticleCountInThisThreadsTile > 0) - { - uint SlowParticlesInThisThreadsTile = gs_SlowTileParticleCounts[GI]; - uint Packet = TileCoord.x << 16 | TileCoord.y << 24 | ParticleCountInThisThreadsTile; - - uint NewPacketIndex; - if (SlowParticlesInThisThreadsTile > 0) - { - g_DrawPacketCount.InterlockedAdd(0, 1, NewPacketIndex); - g_DrawPackets[NewPacketIndex] = Packet; - } - else - { - g_DrawPacketCount.InterlockedAdd(12, 1, NewPacketIndex); - g_FastDrawPackets[NewPacketIndex] = Packet; - } - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRender2CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRender2CS.hlsl deleted file mode 100644 index 7f86e85..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRender2CS.hlsl +++ /dev/null @@ -1,14 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard - -#define SUPPORT_TYPED_UAV_LOADS 1 -#include "ParticleTileRenderCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRender3CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRender3CS.hlsl deleted file mode 100644 index 539f36c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRender3CS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard - -#define SUPPORT_TYPED_UAV_LOADS 1 -#define ENABLE_PARTICLE_RESPONSIVE_MASK -#include "ParticleTileRenderCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderCS.hlsl deleted file mode 100644 index 3da45cb..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderCS.hlsl +++ /dev/null @@ -1,226 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// Alex Nankervis -// Julia Careaga -// - -#include "ParticleUtility.hlsli" -#include "PixelPacking.hlsli" - -//#define DEBUG_LOW_RES - -#define ALPHA_THRESHOLD (252.0 / 255.0) - -cbuffer CB0 : register(b0) -{ - float gDynamicResLevel; - float gMipBias; -}; - -#if SUPPORT_TYPED_UAV_LOADS -RWTexture2D g_OutputColorBuffer : register(u0); -#ifdef ENABLE_PARTICLE_RESPONSIVE_MASK -RWTexture2D g_ResponsiveMaskBuffer : register(u1); -#endif -#else -RWTexture2D g_OutputColorBuffer : register(u0); -#endif - -StructuredBuffer g_VisibleParticles : register(t0); -ByteAddressBuffer g_HitMask : register(t1); -Texture2DArray g_TexArray : register(t2); -StructuredBuffer g_SortedParticles : register(t4); -#ifndef DISABLE_DEPTH_TESTS -Texture2D g_InputDepthBuffer : register(t3); -StructuredBuffer g_DrawPackets : register(t5); -Texture2D g_TileDepthBounds : register(t7); -#else -StructuredBuffer g_DrawPackets : register(t6); -#endif - -float4 SampleParticleColor( ParticleScreenData Particle, SamplerState Sampler, float2 UV, float LevelBias ) -{ - float LOD = Particle.TextureLevel + LevelBias; - - float4 Color = g_TexArray.SampleLevel( Sampler, float3(UV, Particle.TextureIndex), LOD); - - // Multiply texture RGB with alpha. Pre-multiplied alpha blending also permits additive blending. - Color.rgb *= Color.a; - - return Color * Particle.Color; -} - -void BlendPixel( inout float4 Dst, float4 Src, float Mask ) -{ - Dst += Src * (1.0 - Dst.a) * Mask; -} - -void BlendHighRes( inout float4x4 Quad, ParticleScreenData Particle, float2 PixelCoord, float4 Mask = 1 ) -{ - float2 UV = (PixelCoord - Particle.Corner) * Particle.RcpSize; - float2 dUV = 0.5 * gRcpBufferDim * Particle.RcpSize; - float2 UV1 = UV - dUV; - float2 UV2 = UV + dUV; - -#if defined(DYNAMIC_RESOLUTION) - // Use point sampling for high-res rendering because this implies we're not rendering - // with the most detailed mip level anyway. - SamplerState Sampler = gSampPointBorder; - float LevelBias = gMipBias; -#else - SamplerState Sampler = gSampLinearBorder; - float LevelBias = 0.0; -#endif - - BlendPixel(Quad[0], SampleParticleColor(Particle, Sampler, float2(UV1.x, UV2.y), LevelBias), Mask.x); - BlendPixel(Quad[1], SampleParticleColor(Particle, Sampler, float2(UV2.x, UV2.y), LevelBias), Mask.y); - BlendPixel(Quad[2], SampleParticleColor(Particle, Sampler, float2(UV2.x, UV1.y), LevelBias), Mask.z); - BlendPixel(Quad[3], SampleParticleColor(Particle, Sampler, float2(UV1.x, UV1.y), LevelBias), Mask.w); -} - -void BlendLowRes( inout float4x4 Quad, ParticleScreenData Particle, float2 PixelCoord, float4 Mask = 1 ) -{ - float2 UV = (PixelCoord - Particle.Corner) * Particle.RcpSize; - float4 Color = SampleParticleColor(Particle, gSampLinearBorder, UV, 1.0); -#ifdef DEBUG_LOW_RES - Color.g *= 0.5; -#endif - BlendPixel(Quad[0], Color, Mask.x); - BlendPixel(Quad[1], Color, Mask.y); - BlendPixel(Quad[2], Color, Mask.z); - BlendPixel(Quad[3], Color, Mask.w); -} - -void WriteBlendedColor( uint2 ST, float4 Color ) -{ -#if SUPPORT_TYPED_UAV_LOADS - float3 DestColor = g_OutputColorBuffer[ST]; - g_OutputColorBuffer[ST] = Color.rgb + DestColor * (1.0 - Color.a); -#ifdef ENABLE_PARTICLE_RESPONSIVE_MASK - float3 responsiveColor = ceil(Color.rgb); - g_ResponsiveMaskBuffer[ST] = max(responsiveColor.r, max(responsiveColor.g, responsiveColor.b)); -#endif -#else - float3 DestColor = Unpack_R11G11B10_FLOAT(g_OutputColorBuffer[ST]); - g_OutputColorBuffer[ST] = Pack_R11G11B10_FLOAT(Color.rgb + DestColor * (1.0 - Color.a)); -#endif -} - -void WriteBlendedQuad( uint2 ST, float4x4 Quad ) -{ - WriteBlendedColor(ST + uint2(0, 0), Quad[3]); - WriteBlendedColor(ST + uint2(1, 0), Quad[2]); - WriteBlendedColor(ST + uint2(1, 1), Quad[1]); - WriteBlendedColor(ST + uint2(0, 1), Quad[0]); -} - -float4x4 RenderParticles( uint2 TileCoord, uint2 ST, uint NumParticles, uint HitMaskStart, uint BinStart ) -{ -#ifndef DISABLE_DEPTH_TESTS - const uint TileNearZ = g_TileDepthBounds[TileCoord] << 18; - float4 Depths = g_InputDepthBuffer.Gather(gSampPointClamp, (ST + 1) * gRcpBufferDim); -#endif - - // VGPR - float4x4 Quad = 0.0; - const float2 PixelCoord = (ST + 1) * gRcpBufferDim; - - uint BlendedParticles = 0; - - while (BlendedParticles < NumParticles) - { - for (uint ParticleMask = g_HitMask.Load(HitMaskStart); ParticleMask != 0; ++BlendedParticles) - { - // Get the next bit and then clear it - uint SubIdx = firstbitlow(ParticleMask); - ParticleMask ^= 1 << SubIdx; - - // Get global particle index from sorted buffer and then load the particle - uint SortKey = g_SortedParticles[BinStart + SubIdx]; - uint ParticleIdx = SortKey & 0x3FFFF; - ParticleScreenData Particle = g_VisibleParticles[ParticleIdx]; - -#if defined(DYNAMIC_RESOLUTION) - bool DoFullRes = (Particle.TextureLevel > gDynamicResLevel); -#elif defined(LOW_RESOLUTION) - static const bool DoFullRes = false; -#else - static const bool DoFullRes = true; -#endif - - if (DoFullRes) - { -#ifndef DISABLE_DEPTH_TESTS - if (SortKey > TileNearZ) - { - float4 DepthMask = saturate(1000.0 * (Depths - Particle.Depth)); - BlendHighRes(Quad, Particle, PixelCoord, DepthMask); - } - else -#endif - { - BlendHighRes(Quad, Particle, PixelCoord); - } - } - else - { -#ifndef DISABLE_DEPTH_TESTS - if (SortKey > TileNearZ) - { - float4 DepthMask = saturate(1000.0 * (Depths - Particle.Depth)); - BlendLowRes(Quad, Particle, PixelCoord, DepthMask); - } - else -#endif - { - BlendLowRes(Quad, Particle, PixelCoord); - } - } - - //if (all(float4(Quad[0].a, Quad[1].a, Quad[2].a, Quad[3].a) > ALPHA_THRESHOLD)) - //{ - // Quad[0].a = Quad[1].a = Quad[2].a = Quad[3].a = 1.0; - // return Quad; - //} - - } // for - - // Every outer loop iteration traverses 32 entries in the sorted particle list - HitMaskStart += 4; - BinStart += 32; - - } // while - - return Quad; -} - -[RootSignature(Particle_RootSig)] -[numthreads(TILE_SIZE / 2, TILE_SIZE / 2, 1)] -void main( uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID ) -{ - const uint DrawPacket = g_DrawPackets[Gid.x]; - uint2 TileCoord = uint2(DrawPacket >> 16, DrawPacket >> 24) & 0xFF; - const uint ParticleCount = DrawPacket & 0xFFFF; - - const uint HitMaskSizeInBytes = MAX_PARTICLES_PER_BIN / 8; - const uint TileIndex = TileCoord.x + TileCoord.y * gTileRowPitch; - const uint HitMaskStart = TileIndex * HitMaskSizeInBytes; - const uint2 BinCoord = TileCoord / uint2(TILES_PER_BIN_X, TILES_PER_BIN_Y); - const uint BinIndex = BinCoord.x + BinCoord.y * gBinsPerRow; - const uint BinStart = BinIndex * MAX_PARTICLES_PER_BIN; - - const uint2 ST = TileCoord * TILE_SIZE + 2 * GTid.xy; - - float4x4 Quad = RenderParticles( TileCoord, ST, ParticleCount, HitMaskStart, BinStart ); - - WriteBlendedQuad(ST, Quad); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderFast2CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderFast2CS.hlsl deleted file mode 100644 index ec9767e..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderFast2CS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard - -#define DISABLE_DEPTH_TESTS -#define SUPPORT_TYPED_UAV_LOADS 1 -#include "ParticleTileRenderCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderFast3CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderFast3CS.hlsl deleted file mode 100644 index 7f0e56f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderFast3CS.hlsl +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard - -#define DISABLE_DEPTH_TESTS -#define SUPPORT_TYPED_UAV_LOADS 1 -#define ENABLE_PARTICLE_RESPONSIVE_MASK -#include "ParticleTileRenderCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderFastCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderFastCS.hlsl deleted file mode 100644 index 5443133..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderFastCS.hlsl +++ /dev/null @@ -1,14 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard - -#define DISABLE_DEPTH_TESTS -#include "ParticleTileRenderCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderFastDynamic2CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderFastDynamic2CS.hlsl deleted file mode 100644 index 46590c5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderFastDynamic2CS.hlsl +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard - -#define DYNAMIC_RESOLUTION -#define DISABLE_DEPTH_TESTS -#define SUPPORT_TYPED_UAV_LOADS 1 -#include "ParticleTileRenderCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderFastDynamic3CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderFastDynamic3CS.hlsl deleted file mode 100644 index accb7b5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderFastDynamic3CS.hlsl +++ /dev/null @@ -1,17 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard - -#define DYNAMIC_RESOLUTION -#define DISABLE_DEPTH_TESTS -#define SUPPORT_TYPED_UAV_LOADS 1 -#define ENABLE_PARTICLE_RESPONSIVE_MASK -#include "ParticleTileRenderCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderFastDynamicCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderFastDynamicCS.hlsl deleted file mode 100644 index 7677754..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderFastDynamicCS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard - -#define DYNAMIC_RESOLUTION -#define DISABLE_DEPTH_TESTS -#include "ParticleTileRenderCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderFastLowRes2CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderFastLowRes2CS.hlsl deleted file mode 100644 index ceeb45f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderFastLowRes2CS.hlsl +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard - -#define LOW_RESOLUTION -#define DISABLE_DEPTH_TESTS -#define SUPPORT_TYPED_UAV_LOADS 1 -#include "ParticleTileRenderCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderFastLowRes3CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderFastLowRes3CS.hlsl deleted file mode 100644 index b627f90..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderFastLowRes3CS.hlsl +++ /dev/null @@ -1,17 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard - -#define LOW_RESOLUTION -#define DISABLE_DEPTH_TESTS -#define SUPPORT_TYPED_UAV_LOADS 1 -#define ENABLE_PARTICLE_RESPONSIVE_MASK -#include "ParticleTileRenderCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderFastLowResCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderFastLowResCS.hlsl deleted file mode 100644 index 3372807..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderFastLowResCS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard - -#define LOW_RESOLUTION -#define DISABLE_DEPTH_TESTS -#include "ParticleTileRenderCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderSlowDynamic2CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderSlowDynamic2CS.hlsl deleted file mode 100644 index c458a4e..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderSlowDynamic2CS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard - -#define DYNAMIC_RESOLUTION -#define SUPPORT_TYPED_UAV_LOADS 1 -#include "ParticleTileRenderCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderSlowDynamic3CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderSlowDynamic3CS.hlsl deleted file mode 100644 index 08bb5c6..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderSlowDynamic3CS.hlsl +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard - -#define DYNAMIC_RESOLUTION -#define SUPPORT_TYPED_UAV_LOADS 1 -#define ENABLE_PARTICLE_RESPONSIVE_MASK -#include "ParticleTileRenderCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderSlowDynamicCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderSlowDynamicCS.hlsl deleted file mode 100644 index 4e4532a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderSlowDynamicCS.hlsl +++ /dev/null @@ -1,14 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard - -#define DYNAMIC_RESOLUTION -#include "ParticleTileRenderCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderSlowLowRes2CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderSlowLowRes2CS.hlsl deleted file mode 100644 index 99eb99b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderSlowLowRes2CS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard - -#define LOW_RESOLUTION -#define SUPPORT_TYPED_UAV_LOADS 1 -#include "ParticleTileRenderCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderSlowLowRes3CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderSlowLowRes3CS.hlsl deleted file mode 100644 index 6718295..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderSlowLowRes3CS.hlsl +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard - -#define LOW_RESOLUTION -#define SUPPORT_TYPED_UAV_LOADS 1 -#define ENABLE_PARTICLE_RESPONSIVE_MASK -#include "ParticleTileRenderCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderSlowLowResCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderSlowLowResCS.hlsl deleted file mode 100644 index 59562ec..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleTileRenderSlowLowResCS.hlsl +++ /dev/null @@ -1,14 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard - -#define LOW_RESOLUTION -#include "ParticleTileRenderCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleUpdateCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleUpdateCS.hlsl deleted file mode 100644 index 9d5b342..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleUpdateCS.hlsl +++ /dev/null @@ -1,84 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// Julia Careaga -// - -#include "ParticleUpdateCommon.hlsli" -#include "ParticleUtility.hlsli" - -cbuffer CB0 : register(b0) -{ - float gElapsedTime; -}; - -StructuredBuffer< ParticleSpawnData > g_ResetData : register( t0 ); -StructuredBuffer< ParticleMotion > g_InputBuffer : register( t1 ); -RWStructuredBuffer< ParticleVertex > g_VertexBuffer : register( u0 ); -RWStructuredBuffer< ParticleMotion > g_OutputBuffer : register( u2 ); - -[RootSignature(Particle_RootSig)] -[numthreads(64, 1, 1)] -void main( uint3 DTid : SV_DispatchThreadID ) -{ - if (DTid.x >= MaxParticles) - return; - - ParticleMotion ParticleState = g_InputBuffer[ DTid.x ]; - ParticleSpawnData rd = g_ResetData[ ParticleState.ResetDataIndex ]; - - // Update age. If normalized age exceeds 1, the particle does not renew its lease on life. - ParticleState.Age += gElapsedTime * rd.AgeRate; - if (ParticleState.Age >= 1.0) - return; - - // Update position. Compute two deltas to support rebounding off the ground plane. - float StepSize = (ParticleState.Position.y > 0.0 && ParticleState.Velocity.y < 0.0) ? - min(gElapsedTime, ParticleState.Position.y / -ParticleState.Velocity.y) : gElapsedTime; - - ParticleState.Position += ParticleState.Velocity * StepSize; - ParticleState.Velocity += Gravity * ParticleState.Mass * StepSize; - - // Rebound off the ground if we didn't consume all of the elapsed time - StepSize = gElapsedTime - StepSize; - if (StepSize > 0.0) - { - ParticleState.Velocity = reflect(ParticleState.Velocity, float3(0, 1, 0)) * Restitution; - ParticleState.Position += ParticleState.Velocity * StepSize; - ParticleState.Velocity += Gravity * ParticleState.Mass * StepSize; - } - - // The spawn dispatch will be simultaneously adding particles as well. It's possible to overflow. - uint index = g_OutputBuffer.IncrementCounter(); - if (index >= MaxParticles) - return; - - g_OutputBuffer[index] = ParticleState; - - // - // Generate a sprite vertex - // - - ParticleVertex Sprite; - - Sprite.Position = ParticleState.Position; - Sprite.TextureID = TextureID; - - // Update size and color - Sprite.Size = lerp(rd.StartSize, rd.EndSize, ParticleState.Age); - Sprite.Color = lerp(rd.StartColor, rd.EndColor, ParticleState.Age); - - // ...Originally from Reflex... - // Use a trinomial to smoothly fade in a particle at birth and fade it out at death. - Sprite.Color *= ParticleState.Age * (1.0 - ParticleState.Age) * (1.0 - ParticleState.Age) * 6.7; - - g_VertexBuffer[ g_VertexBuffer.IncrementCounter() ] = Sprite; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleUpdateCommon.hlsli b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleUpdateCommon.hlsli deleted file mode 100644 index 658a1fa..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleUpdateCommon.hlsli +++ /dev/null @@ -1,65 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): Julia Careaga -// James Stanard -// - -cbuffer EmissionProperties : register(b2) -{ - float3 LastEmitPosW; - float EmitSpeed; - float3 EmitPosW; - float FloorHeight; - float3 EmitDirW; - float Restitution; - float3 EmitRightW; - float EmitterVelocitySensitivity; - float3 EmitUpW; - uint MaxParticles; - float3 Gravity; - uint TextureID; - float3 EmissiveColor; - float pad; - uint4 RandIndex[64]; -}; - -struct ParticleSpawnData -{ - float AgeRate; - float RotationSpeed; - float StartSize; - float EndSize; - float3 Velocity; - float Mass; - float3 SpreadOffset; - float Random; - float4 StartColor; - float4 EndColor; -}; - -struct ParticleMotion -{ - float3 Position; - float Mass; - float3 Velocity; - float Age; - float Rotation; - uint ResetDataIndex; -}; - -struct ParticleVertexOutput -{ - float4 Pos : SV_POSITION; - float2 TexCoord : TEXCOORD0; - nointerpolation uint TexID : TEXCOORD1; - nointerpolation float4 Color : TEXCOORD2; - nointerpolation float LinearZ : TEXCOORD3; -}; diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleUtility.hlsli b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleUtility.hlsli deleted file mode 100644 index 236ed1f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleUtility.hlsli +++ /dev/null @@ -1,75 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): Julia Careaga -// James Stanard -// - -#include "ParticleRS.hlsli" - -#define MAX_PARTICLES_PER_BIN 1024 -#define BIN_SIZE_X 128 -#define BIN_SIZE_Y 64 -#define TILE_SIZE 16 - -#define TILES_PER_BIN_X (BIN_SIZE_X / TILE_SIZE) -#define TILES_PER_BIN_Y (BIN_SIZE_Y / TILE_SIZE) -#define TILES_PER_BIN (TILES_PER_BIN_X * TILES_PER_BIN_Y) - -#define MaxTextureSize 64 - -SamplerState gSampLinearBorder : register(s0); -SamplerState gSampPointBorder : register(s1); -SamplerState gSampPointClamp : register(s2); - -cbuffer CBChangesPerView : register(b1) -{ - float4x4 gInvView; - float4x4 gViewProj; - - float gVertCotangent; - float gAspectRatio; - float gRcpFarZ; - float gInvertZ; - - float2 gBufferDim; - float2 gRcpBufferDim; - - uint gBinsPerRow; - uint gTileRowPitch; - uint gTilesPerRow; - uint gTilesPerCol; -}; - -struct ParticleVertex -{ - float3 Position; - float4 Color; - float Size; - uint TextureID; -}; - -// Intentionally left unpacked to allow scalar register loads and ops -struct ParticleScreenData -{ - float2 Corner; // Top-left location - float2 RcpSize; // 1/width, 1/height - float4 Color; - float Depth; - float TextureIndex; - float TextureLevel; - uint Bounds; -}; - -uint InsertZeroBit( uint Value, uint BitIdx ) -{ - uint Mask = BitIdx - 1; - return (Value & ~Mask) << 1 | (Value & Mask); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleVS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleVS.hlsl deleted file mode 100644 index 75e383b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ParticleVS.hlsl +++ /dev/null @@ -1,40 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard - -#include "ParticleUpdateCommon.hlsli" -#include "ParticleUtility.hlsli" - -StructuredBuffer g_VertexBuffer : register( t0 ); -StructuredBuffer g_IndexBuffer : register( t3 ); - -[RootSignature(Particle_RootSig)] -ParticleVertexOutput main( uint BillboardVertex : SV_VertexID, uint InstanceId : SV_InstanceID ) -{ -#ifdef DISABLE_PARTICLE_SORT - ParticleVertex In = g_VertexBuffer[ InstanceId ]; -#else - ParticleVertex In = g_VertexBuffer[ g_IndexBuffer[InstanceId] & 0x3FFFF ]; -#endif - ParticleVertexOutput Out; - - Out.TexCoord = float2((BillboardVertex >> 1) & 1, BillboardVertex & 1); - Out.Color = In.Color; - Out.TexID = In.TextureID; - - float2 Corner = lerp( float2(-1, 1), float2(1, -1), Out.TexCoord ); - float3 Position = mul( (float3x3)gInvView, float3(Corner * In.Size, 0) ) + In.Position; - - Out.Pos = mul( gViewProj, float4(Position, 1) ); - Out.LinearZ = Out.Pos.w * gRcpFarZ; - - return Out; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/PerfGraphBackgroundVS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/PerfGraphBackgroundVS.hlsl deleted file mode 100644 index d6f0c11..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/PerfGraphBackgroundVS.hlsl +++ /dev/null @@ -1,46 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: Julia Careaga -// - -#include "PerfGraphRS.hlsli" - -struct VSOutput -{ - float4 pos : SV_POSITION; - float3 col : COLOR; -}; - -cbuffer CB1 : register(b1) -{ - float RecSize; -} - -[RootSignature(PerfGraph_RootSig)] -VSOutput main( uint vertexID : SV_VertexID, uint instanceID : SV_InstanceID ) -{ - //VSOutput Output; - //float2 uv = float2( (vertexID >> 1) & 1, vertexID & 1 ); - //float2 Corner = lerp( float2(-1.0f, 1.0f), float2(1.0f, RecSize), uv ); - //Corner.y -= 0.45f * instanceID; - //Output.pos = float4(Corner.xy, 1.0,1); - //Output.col = float3(0.0, 0.0, 0.0); - //return Output; - - VSOutput Output; - float2 uv = float2( (vertexID >> 1) & 1, vertexID & 1 ); - float2 Corner = lerp( float2(-1.0f, 1.0f), float2(1.0f, -1), uv ); - Output.pos = float4(Corner.xy, 1.0,1); - Output.col = float3(0.0, 0.0, 0.0); - return Output; - -} - diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/PerfGraphPS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/PerfGraphPS.hlsl deleted file mode 100644 index 3dd5f5c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/PerfGraphPS.hlsl +++ /dev/null @@ -1,26 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: Julia Careaga -// - -#include "PerfGraphRS.hlsli" - -struct VSOutput -{ - float4 pos : SV_POSITION; - float3 col : COLOR; -}; - -[RootSignature(PerfGraph_RootSig)] -float4 main( VSOutput input ) : SV_TARGET -{ - return float4(input.col, 0.75); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/PerfGraphRS.hlsli b/xess/samples/xess_demo/MiniEngine/Core/Shaders/PerfGraphRS.hlsli deleted file mode 100644 index ae42d71..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/PerfGraphRS.hlsli +++ /dev/null @@ -1,19 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define PerfGraph_RootSig \ - "RootFlags(0), " \ - "CBV(b0)," \ - "DescriptorTable(UAV(u0, numDescriptors = 2))," \ - "SRV(t0, visibility = SHADER_VISIBILITY_VERTEX)," \ - "RootConstants(b1, num32BitConstants = 3)" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/PerfGraphVS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/PerfGraphVS.hlsl deleted file mode 100644 index 3e0c7ae..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/PerfGraphVS.hlsl +++ /dev/null @@ -1,53 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: Julia Careaga -// - -#include "PerfGraphRS.hlsli" - -cbuffer CBGraphColor : register(b0) -{ - float3 Color; - float RcpXScale; - uint NodeCount; - uint FrameID; -}; - -cbuffer constants : register(b1) -{ - uint Instance; - float RcpYScale; -} - -struct VSOutput -{ - float4 pos : SV_POSITION; - float3 col : COLOR; -}; - -StructuredBuffer PerfTimes : register(t0); - -[RootSignature(PerfGraph_RootSig)] -VSOutput main( uint VertexID : SV_VertexID ) -{ - // Assume NodeCount is a power of 2 - uint offset = (FrameID + VertexID) & (NodeCount - 1); - - // TODO: Stop interleaving data - float perfTime = saturate(PerfTimes[offset] * RcpYScale) * 2.0 - 1.0; - float frame = VertexID * RcpXScale - 1.0; - - VSOutput output; - output.pos = float4(frame, perfTime, 1, 1); - output.col = Color; - return output; - -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/PixelPacking.hlsli b/xess/samples/xess_demo/MiniEngine/Core/Shaders/PixelPacking.hlsli deleted file mode 100644 index 86cd26e..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/PixelPacking.hlsli +++ /dev/null @@ -1,22 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#ifndef __PIXEL_PACKING_HLSLI__ -#define __PIXEL_PACKING_HLSLI__ - -#include "ColorSpaceUtility.hlsli" -#include "PixelPacking_RGBE.hlsli" -#include "PixelPacking_RGBM.hlsli" -#include "PixelPacking_R11G11B10.hlsli" - -#endif // __PIXEL_PACKING_HLSLI__ diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/PixelPacking_R11G11B10.hlsli b/xess/samples/xess_demo/MiniEngine/Core/Shaders/PixelPacking_R11G11B10.hlsli deleted file mode 100644 index 2493e29..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/PixelPacking_R11G11B10.hlsli +++ /dev/null @@ -1,127 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#ifndef __PIXEL_PACKING_R11G11B10_HLSLI__ -#define __PIXEL_PACKING_R11G11B10_HLSLI__ - -#include "ColorSpaceUtility.hlsli" - -// The standard 32-bit HDR color format. Each float has a 5-bit exponent and no sign bit. -uint Pack_R11G11B10_FLOAT( float3 rgb ) -{ - // Clamp upper bound so that it doesn't accidentally round up to INF - // Exponent=15, Mantissa=1.11111 - rgb = min(rgb, asfloat(0x477C0000)); - uint r = ((f32tof16(rgb.x) + 8) >> 4) & 0x000007FF; - uint g = ((f32tof16(rgb.y) + 8) << 7) & 0x003FF800; - uint b = ((f32tof16(rgb.z) + 16) << 17) & 0xFFC00000; - return r | g | b; -} - -float3 Unpack_R11G11B10_FLOAT( uint rgb ) -{ - float r = f16tof32((rgb << 4 ) & 0x7FF0); - float g = f16tof32((rgb >> 7 ) & 0x7FF0); - float b = f16tof32((rgb >> 17) & 0x7FE0); - return float3(r, g, b); -} - -// An improvement to float is to store the mantissa in logarithmic form. This causes a -// smooth and continuous change in precision rather than having jumps in precision every -// time the exponent increases by whole amounts. -uint Pack_R11G11B10_FLOAT_LOG( float3 rgb ) -{ - float3 flat_mantissa = asfloat((asuint(rgb) & 0x7FFFFF) | 0x3F800000); - float3 curved_mantissa = min(log2(flat_mantissa) + 1.0, asfloat(0x3FFFFFFF)); - rgb = asfloat((asuint(rgb) & 0xFF800000) | (asuint(curved_mantissa) & 0x7FFFFF)); - - uint r = ((f32tof16(rgb.x) + 8) >> 4) & 0x000007FF; - uint g = ((f32tof16(rgb.y) + 8) << 7) & 0x003FF800; - uint b = ((f32tof16(rgb.z) + 16) << 17) & 0xFFC00000; - return r | g | b; -} - -float3 Unpack_R11G11B10_FLOAT_LOG( uint p ) -{ - float3 rgb = f16tof32(uint3(p << 4, p >> 7, p >> 17) & uint3(0x7FF0, 0x7FF0, 0x7FE0)); - float3 curved_mantissa = asfloat((asuint(rgb) & 0x7FFFFF) | 0x3F800000); - float3 flat_mantissa = exp2(curved_mantissa - 1.0); - return asfloat((asuint(rgb) & 0xFF800000) | (asuint(flat_mantissa) & 0x7FFFFF)); -} - -// As an alternative to floating point, we can store the log2 of a value in fixed point notation. -// The 11-bit fields store 5.6 fixed point notation for log2(x) with an exponent bias of 15. The -// 10-bit field uses 5.5 fixed point. The disadvantage here is we don't handle underflow. Instead -// we use the extra two exponent values to extend the range down through two more exponents. -// Range = [2^-16, 2^16) -uint Pack_R11G11B10_FIXED_LOG(float3 rgb) -{ - uint3 p = clamp((log2(rgb) + 16.0) * float3(64, 64, 32) + 0.5, 0.0, float3(2047, 2047, 1023)); - return p.b << 22 | p.g << 11 | p.r; -} - -float3 Unpack_R11G11B10_FIXED_LOG(uint p) -{ - return exp2((uint3(p, p >> 11, p >> 21) & uint3(2047, 2047, 2046)) / 64.0 - 16.0); -} - -// These next two encodings are great for LDR data. By knowing that our values are [0.0, 1.0] -// (or [0.0, 2.0), incidentally), we can reduce how many bits we need in the exponent. We can -// immediately eliminate all postive exponents. By giving more bits to the mantissa, we can -// improve precision at the expense of range. The 8E3 format goes one bit further, quadrupling -// mantissa precision but increasing smallest exponent from -14 to -6. The smallest value of 8E3 -// is 2^-14, while the smallest value of 7E4 is 2^-21. Both are smaller than the smallest 8-bit -// sRGB value, which is close to 2^-12. - -// This is like R11G11B10_FLOAT except that it moves one bit from each exponent to each mantissa. -uint Pack_R11G11B10_E4_FLOAT( float3 rgb ) -{ - // Clamp to [0.0, 2.0). The magic number is 1.FFFFF x 2^0. (We can't represent hex floats in HLSL.) - // This trick works because clamping your exponent to 0 reduces the number of bits needed by 1. - rgb = clamp( rgb, 0.0, asfloat(0x3FFFFFFF) ); - uint r = ((f32tof16(rgb.r) + 4) >> 3 ) & 0x000007FF; - uint g = ((f32tof16(rgb.g) + 4) << 8 ) & 0x003FF800; - uint b = ((f32tof16(rgb.b) + 8) << 18) & 0xFFC00000; - return r | g | b; -} - -float3 Unpack_R11G11B10_E4_FLOAT( uint rgb ) -{ - float r = f16tof32((rgb << 3 ) & 0x3FF8); - float g = f16tof32((rgb >> 8 ) & 0x3FF8); - float b = f16tof32((rgb >> 18) & 0x3FF0); - return float3(r, g, b); -} - -// This is like R11G11B10_FLOAT except that it moves two bits from each exponent to each mantissa. -uint Pack_R11G11B10_E3_FLOAT( float3 rgb ) -{ - // Clamp to [0.0, 2.0). Divide by 256 to bias the exponent by -8. This shifts it down to use one - // fewer bit while still taking advantage of the denormalization hardware. In half precision, - // the exponent of 0 is 0xF. Dividing by 256 makes the max exponent 0x7--one fewer bit. - rgb = clamp( rgb, 0.0, asfloat(0x3FFFFFFF) ) / 256.0; - uint r = ((f32tof16(rgb.r) + 2) >> 2 ) & 0x000007FF; - uint g = ((f32tof16(rgb.g) + 2) << 9 ) & 0x003FF800; - uint b = ((f32tof16(rgb.b) + 4) << 19) & 0xFFC00000; - return r | g | b; -} - -float3 Unpack_R11G11B10_E3_FLOAT( uint rgb ) -{ - float r = f16tof32((rgb << 2 ) & 0x1FFC); - float g = f16tof32((rgb >> 9 ) & 0x1FFC); - float b = f16tof32((rgb >> 19) & 0x1FF8); - return float3(r, g, b) * 256.0; -} - -#endif // __PIXEL_PACKING_R11G11B10_HLSLI__ diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/PixelPacking_RGBE.hlsli b/xess/samples/xess_demo/MiniEngine/Core/Shaders/PixelPacking_RGBE.hlsli deleted file mode 100644 index d38d0c9..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/PixelPacking_RGBE.hlsli +++ /dev/null @@ -1,82 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#ifndef __PIXEL_PACKING_RGBE_HLSLI__ -#define __PIXEL_PACKING_RGBE_HLSLI__ - -#include "ColorSpaceUtility.hlsli" - -// RGBE, aka R9G9B9E5_SHAREDEXP, is an unsigned float HDR pixel format where red, green, -// and blue all share the same exponent. The color channels store a 9-bit value ranging -// from [0/512, 511/512] which multiplies by 2^Exp and Exp ranges from [-15, 16]. -// Floating point specials are not encoded. -uint PackRGBE(float3 rgb) -{ - // To determine the shared exponent, we must clamp the channels to an expressible range - const float kMaxVal = asfloat(0x477F8000); // 1.FF x 2^+15 - const float kMinVal = asfloat(0x37800000); // 1.00 x 2^-16 - - // Non-negative and <= kMaxVal - rgb = clamp(rgb, 0, kMaxVal); - - // From the maximum channel we will determine the exponent. We clamp to a min value - // so that the exponent is within the valid 5-bit range. - float MaxChannel = max(max(kMinVal, rgb.r), max(rgb.g, rgb.b)); - - // 'Bias' has to have the biggest exponent plus 15 (and nothing in the mantissa). When - // added to the three channels, it shifts the explicit '1' and the 8 most significant - // mantissa bits into the low 9 bits. IEEE rules of float addition will round rather - // than truncate the discarded bits. Channels with smaller natural exponents will be - // shifted further to the right (discarding more bits). - float Bias = asfloat((asuint(MaxChannel) + 0x07804000) & 0x7F800000); - - // Shift bits into the right places - uint3 RGB = asuint(rgb + Bias); - uint E = (asuint(Bias) << 4) + 0x10000000; - return E | RGB.b << 18 | RGB.g << 9 | (RGB.r & 0x1FF); -} - -float3 UnpackRGBE(uint p) -{ - float3 rgb = uint3(p, p >> 9, p >> 18) & 0x1FF; - return ldexp(rgb, (int)(p >> 27) - 24); -} - -// This non-standard variant applies a non-linear ramp to the mantissa to get better precision -// with bright and saturated colors. These colors tend to have one or two channels that prop -// up the shared exponent, leaving little to no information in the dark channels. -uint PackRGBE_sqrt(float3 rgb) -{ - // To determine the shared exponent, we must clamp the channels to an expressible range - const float kMaxVal = asfloat(0x477FFFFF); // 1.FFFFFF x 2^+15 - const float kMinVal = asfloat(0x37800000); // 1.000000 x 2^-16 - - rgb = clamp(rgb, 0, kMaxVal); - - float MaxChannel = max(max(kMinVal, rgb.r), max(rgb.g, rgb.b)); - - // Scaling the maximum channel puts it into the range [0, 1). It does this by negating - // and subtracting one from the max exponent. - float Scale = asfloat((0x7EFFFFFF - asuint(MaxChannel)) & 0x7F800000); - uint3 RGB = sqrt(rgb * Scale) * 511.0 + 0.5; - uint E = (0x47000000 - asuint(Scale)) << 4; - return E | RGB.b << 18 | RGB.g << 9 | RGB.r; -} - -float3 UnpackRGBE_sqrt(uint p) -{ - float3 rgb = (uint3(p, p >> 9, p >> 18) & 0x1FF) / 511.0; - return ldexp(rgb * rgb, (int)(p >> 27) - 15); -} - -#endif // __PIXEL_PACKING_RGBE_HLSLI__ diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/PixelPacking_RGBM.hlsli b/xess/samples/xess_demo/MiniEngine/Core/Shaders/PixelPacking_RGBM.hlsli deleted file mode 100644 index a5c7f29..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/PixelPacking_RGBM.hlsli +++ /dev/null @@ -1,50 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#ifndef __PIXEL_PACKING_RGBM_HLSLI__ -#define __PIXEL_PACKING_RGBM_HLSLI__ - -#include "ColorSpaceUtility.hlsli" - -float4 ToRGBM( float3 rgb, float PeakValue = 255.0 / 16.0 ) -{ - rgb = saturate(rgb / PeakValue); - float maxVal = max(max(1e-6, rgb.x), max(rgb.y, rgb.z)); - maxVal = ceil(maxVal * 255.0) / 255.0; - return float4(rgb / maxVal, maxVal); -} - -float3 FromRGBM(float4 rgbm, float PeakValue = 255.0 / 16.0 ) -{ - return rgbm.rgb * rgbm.a * PeakValue; -} - -// RGBM is a good way to pack HDR values into R8G8B8A8_UNORM -uint PackRGBM( float4 rgbm, bool sRGB = true ) -{ - if (sRGB) - rgbm.rgb = ApplySRGBCurve(rgbm.rgb); - rgbm = rgbm * 255.0 + 0.5; - return (uint)rgbm.a << 24 | (uint)rgbm.b << 16 | (uint)rgbm.g << 8 | (uint)rgbm.r; -} - -float4 UnpackRGBM( uint p, bool sRGB = true ) -{ - float4 rgbm = float4(uint4(p, p >> 8, p >> 16, p >> 24) & 0xFF); - rgbm /= 255.0; - if (sRGB) - rgbm.rgb = RemoveSRGBCurve(rgbm.rgb); - return rgbm; -} - -#endif // __PIXEL_PACKING_RGBM_HLSLI__ diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/PixelPacking_Velocity.hlsli b/xess/samples/xess_demo/MiniEngine/Core/Shaders/PixelPacking_Velocity.hlsli deleted file mode 100644 index d28c020..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/PixelPacking_Velocity.hlsli +++ /dev/null @@ -1,95 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#ifndef __PIXEL_PACKING_VELOCITY_HLSLI__ -#define __PIXEL_PACKING_VELOCITY_HLSLI__ - -#if 1 -// This is a custom packing that devotes 10 bits each to X and Y velocity but 12 bits to Z velocity. Floats -// are used instead of SNORM to increase precision around small deltas, which are the majority of deltas. -// With TAA and Motion Blur, velocities are clamped, giving little reason to express them precisely in terms -// of the size of the screen. -#define packed_velocity_t uint - -// Designed to compress (-256.0, +256.0) with a signed 6e3 float -uint PackXY( float x ) -{ - uint signbit = asuint(x) >> 31; - x = clamp(abs(x / 32768.0), 0, asfloat(0x3BFFE000)); - return (f32tof16(x) + 8) >> 4 | signbit << 9; -} - -float UnpackXY( uint x ) -{ - return f16tof32((x & 0x1FF) << 4 | (x >> 9) << 15) * 32768.0; -} - -// Designed to compress (-1.0, 1.0) with a signed 8e3 float -uint PackZ( float x ) -{ - uint signbit = asuint(x) >> 31; - x = clamp(abs(x / 128.0), 0, asfloat(0x3BFFE000)); - return (f32tof16(x) + 2) >> 2 | signbit << 11; -} - -float UnpackZ( uint x ) -{ - return f16tof32((x & 0x7FF) << 2 | (x >> 11) << 15) * 128.0; -} - -// Pack the velocity to write to R10G10B10A2_UNORM -packed_velocity_t PackVelocity( float3 Velocity ) -{ - return PackXY(Velocity.x) | PackXY(Velocity.y) << 10 | PackZ(Velocity.z) << 20; -} - -// Unpack the velocity from R10G10B10A2_UNORM -float3 UnpackVelocity( packed_velocity_t Velocity ) -{ - return float3(UnpackXY(Velocity & 0x3FF), UnpackXY((Velocity >> 10) & 0x3FF), UnpackZ(Velocity >> 20)); -} - -#elif 1 -#define packed_velocity_t float4 - -// Pack the velocity to write to R10G10B10A2_UNORM -packed_velocity_t PackVelocity( float3 Velocity ) -{ - // Stretch dx,dy from [-64, 63.875] to [-512, 511] to [-0.5, 0.5) to [0, 1) - // Velocity.xy = (0,0) must be representable. - return float4(Velocity * float3(8, 8, 4096) / 1024.0 + 512 / 1023.0, 0); -} - -// Unpack the velocity from R10G10B10A2_UNORM -float3 UnpackVelocity( packed_velocity_t Velocity ) -{ - return (Velocity.xyz - 512.0 / 1023.0) * float3(1024, 1024, 2) / 8.0; -} -#else -#define packed_velocity_t float4 - -// Pack the velocity to write to R16G16B16A16_FLOAT -packed_velocity_t PackVelocity( float3 Velocity ) -{ - return float4(Velocity * float3(16, 16, 32*1024), 0); -} - -// Unpack the velocity from R10G10B10A2_UNORM -float3 UnpackVelocity( packed_velocity_t Velocity ) -{ - return Velocity.xyz / float3(16, 16, 32*1024); -} - -#endif - -#endif // __PIXEL_PACKING_HLSLI__ diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/PostEffectsRS.hlsli b/xess/samples/xess_demo/MiniEngine/Core/Shaders/PostEffectsRS.hlsli deleted file mode 100644 index a40b087..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/PostEffectsRS.hlsli +++ /dev/null @@ -1,30 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define PostEffects_RootSig \ - "RootFlags(0), " \ - "RootConstants(b0, num32BitConstants = 5), " \ - "DescriptorTable(UAV(u0, numDescriptors = 4))," \ - "DescriptorTable(SRV(t0, numDescriptors = 4))," \ - "CBV(b1)," \ - "StaticSampler(s0," \ - "addressU = TEXTURE_ADDRESS_CLAMP," \ - "addressV = TEXTURE_ADDRESS_CLAMP," \ - "addressW = TEXTURE_ADDRESS_CLAMP," \ - "filter = FILTER_MIN_MAG_MIP_LINEAR)," \ - "StaticSampler(s1," \ - "addressU = TEXTURE_ADDRESS_BORDER," \ - "addressV = TEXTURE_ADDRESS_BORDER," \ - "addressW = TEXTURE_ADDRESS_BORDER," \ - "borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK," \ - "filter = FILTER_MIN_MAG_MIP_LINEAR)" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/PresentHDRPS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/PresentHDRPS.hlsl deleted file mode 100644 index 9fdc098..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/PresentHDRPS.hlsl +++ /dev/null @@ -1,23 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "PresentRS.hlsli" -#include "ColorSpaceUtility.hlsli" - -Texture2D MainBuffer : register(t0); - -[RootSignature(Present_RootSig)] -float3 main( float4 position : SV_Position, float2 uv : TexCoord0 ) : SV_Target0 -{ - return ApplyREC2084Curve(MainBuffer[(int2)position.xy] / 10000.0); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/PresentRS.hlsli b/xess/samples/xess_demo/MiniEngine/Core/Shaders/PresentRS.hlsli deleted file mode 100644 index e3e9382..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/PresentRS.hlsli +++ /dev/null @@ -1,30 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define Present_RootSig \ - "RootFlags(0), " \ - "DescriptorTable(SRV(t0, numDescriptors = 2))," \ - "RootConstants(b0, num32BitConstants = 6), " \ - "SRV(t2, visibility = SHADER_VISIBILITY_PIXEL)," \ - "DescriptorTable(UAV(u0, numDescriptors = 2)), " \ - "StaticSampler(s0," \ - "addressU = TEXTURE_ADDRESS_CLAMP," \ - "addressV = TEXTURE_ADDRESS_CLAMP," \ - "addressW = TEXTURE_ADDRESS_CLAMP," \ - "filter = FILTER_MIN_MAG_MIP_LINEAR)," \ - "StaticSampler(s1," \ - "addressU = TEXTURE_ADDRESS_CLAMP," \ - "addressV = TEXTURE_ADDRESS_CLAMP," \ - "addressW = TEXTURE_ADDRESS_CLAMP," \ - "filter = FILTER_MIN_MAG_MIP_POINT)" - diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/PresentSDRPS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/PresentSDRPS.hlsl deleted file mode 100644 index 424d7cd..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/PresentSDRPS.hlsl +++ /dev/null @@ -1,24 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "ShaderUtility.hlsli" -#include "PresentRS.hlsli" - -Texture2D ColorTex : register(t0); - -[RootSignature(Present_RootSig)] -float3 main( float4 position : SV_Position ) : SV_Target0 -{ - float3 LinearRGB = ColorTex[(int2)position.xy]; - return ApplyDisplayProfile(LinearRGB, DISPLAY_PLANE_FORMAT); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ResolveTAACS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ResolveTAACS.hlsl deleted file mode 100644 index 6cbb0f7..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ResolveTAACS.hlsl +++ /dev/null @@ -1,25 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard - -#include "ShaderUtility.hlsli" -#include "CommonRS.hlsli" - -Texture2D TemporalColor : register(t0); -RWTexture2D OutColor : register(u0); - -[RootSignature(Common_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 DTid : SV_DispatchThreadID ) -{ - float4 Color = TemporalColor[DTid.xy]; - OutColor[DTid.xy] = Color.rgb / max(Color.w, 1e-6); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/SSAORS.hlsli b/xess/samples/xess_demo/MiniEngine/Core/Shaders/SSAORS.hlsli deleted file mode 100644 index 13151e2..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/SSAORS.hlsli +++ /dev/null @@ -1,30 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define SSAO_RootSig \ - "RootFlags(0), " \ - "RootConstants(b0, num32BitConstants = 4), " \ - "CBV(b1), " \ - "DescriptorTable(UAV(u0, numDescriptors = 5))," \ - "DescriptorTable(SRV(t0, numDescriptors = 5))," \ - "StaticSampler(s0," \ - "addressU = TEXTURE_ADDRESS_CLAMP," \ - "addressV = TEXTURE_ADDRESS_CLAMP," \ - "addressW = TEXTURE_ADDRESS_CLAMP," \ - "filter = FILTER_MIN_MAG_MIP_LINEAR)," \ - "StaticSampler(s1," \ - "addressU = TEXTURE_ADDRESS_BORDER," \ - "addressV = TEXTURE_ADDRESS_BORDER," \ - "addressW = TEXTURE_ADDRESS_BORDER," \ - "borderColor = STATIC_BORDER_COLOR_TRANSPARENT_BLACK," \ - "filter = FILTER_MIN_MAG_MIP_LINEAR)" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ScaleAndCompositeHDRPS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ScaleAndCompositeHDRPS.hlsl deleted file mode 100644 index 223e685..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ScaleAndCompositeHDRPS.hlsl +++ /dev/null @@ -1,55 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "ShaderUtility.hlsli" -#include "PresentRS.hlsli" - -Texture2D MainBuffer : register(t0); -Texture2D OverlayBuffer : register(t1); - -SamplerState BilinearFilter : register(s0); - -cbuffer Constants : register(b0) -{ - float PaperWhiteRatio; // PaperWhite / 10000.0 - float MaxBrightness; - float2 UVOffset; -} - -float3 SampleColor(float2 uv) -{ - return MainBuffer.SampleLevel(BilinearFilter, uv, 0); -} - -float3 ScaleBuffer(float2 uv) -{ - return max(1.4 * SampleColor(uv) - 0.1 * ( - SampleColor(uv + float2(+UVOffset.x, +UVOffset.y)) + - SampleColor(uv + float2(+UVOffset.x, -UVOffset.y)) + - SampleColor(uv + float2(-UVOffset.x, +UVOffset.y)) + - SampleColor(uv + float2(-UVOffset.x, -UVOffset.y)) - ), 0); -} - -[RootSignature(Present_RootSig)] -float3 main( float4 position : SV_Position, float2 uv : TexCoord0 ) : SV_Target0 -{ - float3 MainColor = ApplyREC2084Curve(ScaleBuffer(uv) / 10000.0); - - float4 OverlayColor = OverlayBuffer[(int2)position.xy]; - OverlayColor.rgb = RemoveSRGBCurve(OverlayColor.rgb); - OverlayColor.rgb = REC709toREC2020(OverlayColor.rgb / (OverlayColor.a == 0.0 ? 1.0 : OverlayColor.a)); - OverlayColor.rgb = ApplyREC2084Curve(OverlayColor.rgb * PaperWhiteRatio); - - return lerp(MainColor, OverlayColor.rgb, OverlayColor.a); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ScaleAndCompositeSDRPS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ScaleAndCompositeSDRPS.hlsl deleted file mode 100644 index 2472c46..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ScaleAndCompositeSDRPS.hlsl +++ /dev/null @@ -1,48 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "ShaderUtility.hlsli" -#include "PresentRS.hlsli" - -Texture2D MainBuffer : register(t0); -Texture2D OverlayBuffer : register(t1); - -SamplerState BilinearFilter : register(s0); - -cbuffer Constants : register(b0) -{ - float2 UVOffset; -} - -float3 SampleColor(float2 uv) -{ - return MainBuffer.SampleLevel(BilinearFilter, uv, 0); -} - -float3 ScaleBuffer(float2 uv) -{ - return 1.4 * SampleColor(uv) - 0.1 * ( - SampleColor(uv + float2(+UVOffset.x, +UVOffset.y)) + - SampleColor(uv + float2(+UVOffset.x, -UVOffset.y)) + - SampleColor(uv + float2(-UVOffset.x, +UVOffset.y)) + - SampleColor(uv + float2(-UVOffset.x, -UVOffset.y)) - ); -} - -[RootSignature(Present_RootSig)] -float3 main( float4 position : SV_Position, float2 uv : TexCoord0 ) : SV_Target0 -{ - float3 MainColor = ApplyDisplayProfile(ScaleBuffer(uv), DISPLAY_PLANE_FORMAT); - float4 OverlayColor = OverlayBuffer[(int2)position.xy]; - return OverlayColor.rgb + MainColor.rgb * (1.0 - OverlayColor.a); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ScreenQuadCommonVS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ScreenQuadCommonVS.hlsl deleted file mode 100644 index 742bf71..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ScreenQuadCommonVS.hlsl +++ /dev/null @@ -1,33 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// -// A vertex shader for full-screen effects without a vertex buffer. The -// intent is to output an over-sized triangle that encompasses the entire -// screen. By doing so, we avoid rasterization inefficiency that could -// result from drawing two triangles with a shared edge. -// -// Use null input layout -// Draw(3) - -#include "CommonRS.hlsli" - -[RootSignature(Common_RootSig)] -void main( - in uint VertID : SV_VertexID, - out float4 Pos : SV_Position, - out float2 Tex : TexCoord0 -) -{ - // Texture coordinates range [0, 2], but only [0, 1] appears on screen. - Tex = float2(uint2(VertID, VertID << 1) & 2); - Pos = float4(lerp(float2(-1, 1), float2(1, -1), Tex), 0, 1); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ScreenQuadPresentVS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ScreenQuadPresentVS.hlsl deleted file mode 100644 index aadbec6..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ScreenQuadPresentVS.hlsl +++ /dev/null @@ -1,33 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// -// A vertex shader for full-screen effects without a vertex buffer. The -// intent is to output an over-sized triangle that encompasses the entire -// screen. By doing so, we avoid rasterization inefficiency that could -// result from drawing two triangles with a shared edge. -// -// Use null input layout -// Draw(3) - -#include "PresentRS.hlsli" - -[RootSignature(Present_RootSig)] -void main( - in uint VertID : SV_VertexID, - out float4 Pos : SV_Position, - out float2 Tex : TexCoord0 -) -{ - // Texture coordinates range [0, 2], but only [0, 1] appears on screen. - Tex = float2(uint2(VertID, VertID << 1) & 2); - Pos = float4(lerp(float2(-1, 1), float2(1, -1), Tex), 0, 1); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ShaderUtility.hlsli b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ShaderUtility.hlsli deleted file mode 100644 index 4d3f68e..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ShaderUtility.hlsli +++ /dev/null @@ -1,142 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#ifndef __SHADER_UTILITY_HLSLI__ -#define __SHADER_UTILITY_HLSLI__ - -#pragma warning( disable : 3571 ) - -#include "ColorSpaceUtility.hlsli" -#include "PixelPacking.hlsli" - -// Encodes a smooth logarithmic gradient for even distribution of precision natural to vision -float LinearToLogLuminance( float x, float gamma = 4.0 ) -{ - return log2(lerp(1, exp2(gamma), x)) / gamma; -} - -// This assumes the default color gamut found in sRGB and REC709. The color primaries determine these -// coefficients. Note that this operates on linear values, not gamma space. -float RGBToLuminance( float3 x ) -{ - return dot( x, float3(0.212671, 0.715160, 0.072169) ); // Defined by sRGB/Rec.709 gamut -} - -float MaxChannel(float3 x) -{ - return max(x.x, max(x.y, x.z)); -} - -// This is the same as above, but converts the linear luminance value to a more subjective "perceived luminance", -// which could be called the Log-Luminance. -float RGBToLogLuminance( float3 x, float gamma = 4.0 ) -{ - return LinearToLogLuminance( RGBToLuminance(x), gamma ); -} - -// A fast invertible tone map that preserves color (Reinhard) -float3 TM( float3 rgb ) -{ - return rgb / (1 + RGBToLuminance(rgb)); -} - -// Inverse of preceding function -float3 ITM( float3 rgb ) -{ - return rgb / (1 - RGBToLuminance(rgb)); -} - -// 8-bit should range from 16 to 235 -float3 RGBFullToLimited8bit( float3 x ) -{ - return saturate(x) * 219.0 / 255.0 + 16.0 / 255.0; -} - -float3 RGBLimitedToFull8bit( float3 x ) -{ - return saturate((x - 16.0 / 255.0) * 255.0 / 219.0); -} - -// 10-bit should range from 64 to 940 -float3 RGBFullToLimited10bit( float3 x ) -{ - return saturate(x) * 876.0 / 1023.0 + 64.0 / 1023.0; -} - -float3 RGBLimitedToFull10bit( float3 x ) -{ - return saturate((x - 64.0 / 1023.0) * 1023.0 / 876.0); -} - -#define COLOR_FORMAT_LINEAR 0 -#define COLOR_FORMAT_sRGB_FULL 1 -#define COLOR_FORMAT_sRGB_LIMITED 2 -#define COLOR_FORMAT_Rec709_FULL 3 -#define COLOR_FORMAT_Rec709_LIMITED 4 -#define COLOR_FORMAT_HDR10 5 -#define COLOR_FORMAT_TV_DEFAULT COLOR_FORMAT_Rec709_LIMITED -#define COLOR_FORMAT_PC_DEFAULT COLOR_FORMAT_sRGB_FULL - -#define HDR_COLOR_FORMAT COLOR_FORMAT_LINEAR -#define LDR_COLOR_FORMAT COLOR_FORMAT_LINEAR -#define DISPLAY_PLANE_FORMAT COLOR_FORMAT_PC_DEFAULT - -float3 ApplyDisplayProfile( float3 x, int DisplayFormat ) -{ - switch (DisplayFormat) - { - default: - case COLOR_FORMAT_LINEAR: - return x; - case COLOR_FORMAT_sRGB_FULL: - return ApplySRGBCurve(x); - case COLOR_FORMAT_sRGB_LIMITED: - return RGBFullToLimited10bit(ApplySRGBCurve(x)); - case COLOR_FORMAT_Rec709_FULL: - return ApplyREC709Curve(x); - case COLOR_FORMAT_Rec709_LIMITED: - return RGBFullToLimited10bit(ApplyREC709Curve(x)); - case COLOR_FORMAT_HDR10: - return ApplyREC2084Curve(REC709toREC2020(x)); - }; -} - -float3 RemoveDisplayProfile( float3 x, int DisplayFormat ) -{ - switch (DisplayFormat) - { - default: - case COLOR_FORMAT_LINEAR: - return x; - case COLOR_FORMAT_sRGB_FULL: - return RemoveSRGBCurve(x); - case COLOR_FORMAT_sRGB_LIMITED: - return RemoveSRGBCurve(RGBLimitedToFull10bit(x)); - case COLOR_FORMAT_Rec709_FULL: - return RemoveREC709Curve(x); - case COLOR_FORMAT_Rec709_LIMITED: - return RemoveREC709Curve(RGBLimitedToFull10bit(x)); - case COLOR_FORMAT_HDR10: - return REC2020toREC709(RemoveREC2084Curve(x)); - }; -} - -float3 ConvertColor( float3 x, int FromFormat, int ToFormat ) -{ - if (FromFormat == ToFormat) - return x; - - return ApplyDisplayProfile(RemoveDisplayProfile(x, FromFormat), ToFormat); -} - -#endif // __SHADER_UTILITY_HLSLI__ diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/SharpenCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/SharpenCS.hlsl deleted file mode 100644 index 664c26a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/SharpenCS.hlsl +++ /dev/null @@ -1,14 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard - -#define NO_TEMPORAL_WEIGHT -#include "SharpenTAACS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/SharpenTAACS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/SharpenTAACS.hlsl deleted file mode 100644 index 6545c0b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/SharpenTAACS.hlsl +++ /dev/null @@ -1,84 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard - -#include "ShaderUtility.hlsli" -#include "CommonRS.hlsli" - -Texture2D TemporalColor : register(t0); -RWTexture2D OutColor : register(u0); - -SamplerState LinearSampler : register(s0); -SamplerState PointSampler : register(s1); - -cbuffer InlineConstants : register(b0) -{ - float WA, WB; -} - -#define BORDER_SIZE 1 -#define GROUP_SIZE_X 8 -#define GROUP_SIZE_Y 8 -#define GROUP_SIZE (GROUP_SIZE_X * GROUP_SIZE_Y) -#define TILE_SIZE_X (GROUP_SIZE_X + 2 * BORDER_SIZE) -#define TILE_SIZE_Y (GROUP_SIZE_Y + 2 * BORDER_SIZE) -#define TILE_PIXEL_COUNT (TILE_SIZE_X * TILE_SIZE_Y) - -groupshared float gs_R[TILE_PIXEL_COUNT]; -groupshared float gs_G[TILE_PIXEL_COUNT]; -groupshared float gs_B[TILE_PIXEL_COUNT]; -groupshared float gs_W[TILE_PIXEL_COUNT]; - -float3 LoadSample(uint ldsIndex) -{ - return float3(gs_R[ldsIndex], gs_G[ldsIndex], gs_B[ldsIndex]); -} - -[RootSignature(Common_RootSig)] -[numthreads( GROUP_SIZE_X, GROUP_SIZE_Y, 1 )] -void main( uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID, uint GI : SV_GroupIndex ) -{ - int2 GroupUL = Gid.xy * uint2(GROUP_SIZE_X, GROUP_SIZE_Y) - BORDER_SIZE; - for (uint i = GI; i < TILE_PIXEL_COUNT; i += GROUP_SIZE) - { - int2 ST = GroupUL + int2(i % TILE_SIZE_X, i / TILE_SIZE_X); - float4 Color = TemporalColor[ST]; -#ifdef NO_TEMPORAL_WEIGHT - Color.rgb = log2(1.0 + Color.rgb); -#else - Color.rgb = log2(1.0 + Color.rgb / max(Color.w, 1e-6)); -#endif - gs_R[i] = Color.r; - gs_G[i] = Color.g; - gs_B[i] = Color.b; - -#ifndef NO_TEMPORAL_WEIGHT - gs_W[i] = Color.w; -#endif - } - - GroupMemoryBarrierWithGroupSync(); - - uint ldsIndex = (GTid.x + BORDER_SIZE) + (GTid.y + BORDER_SIZE) * TILE_SIZE_X; - - float3 Center = LoadSample(ldsIndex); - float3 Neighbors = LoadSample(ldsIndex - 1) + LoadSample(ldsIndex + 1) + - LoadSample(ldsIndex - TILE_SIZE_X) + LoadSample(ldsIndex + TILE_SIZE_X); - - // If the temporal weight is less than 0.5, it might be a brand new pixel. Brand new pixels - // have not been antialiased at all and can be jarring. Here we change the weights to actually - // blur rather than sharpen those pixels. - float TemporalWeight = gs_W[ldsIndex]; - float CenterWeight = TemporalWeight <= 0.5 ? 0.5 : WA; - float LateralWeight = TemporalWeight <= 0.5 ? 0.125 : WB; - - OutColor[DTid.xy] = exp2(max(0, WA * Center - WB * Neighbors)) - 1.0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/SharpeningUpsampleGammaPS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/SharpeningUpsampleGammaPS.hlsl deleted file mode 100644 index 220a4c5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/SharpeningUpsampleGammaPS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define GAMMA_SPACE -#include "SharpeningUpsamplePS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/SharpeningUpsamplePS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/SharpeningUpsamplePS.hlsl deleted file mode 100644 index 0c18222..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/SharpeningUpsamplePS.hlsl +++ /dev/null @@ -1,51 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// -// This is a bilinear filter coupled with a sharpening pass flattened into one pass. -// - -#include "ShaderUtility.hlsli" -#include "PresentRS.hlsli" - -Texture2D ColorTex : register(t0); -SamplerState BilinearClamp : register(s0); - -cbuffer Constants : register(b0) -{ - float2 UVOffset0; // Four UV offsets to determine the sharpening tap locations - float2 UVOffset1; // We get two more offsets by negating these two. - float WA, WB; // Sharpness strength: WB = 1.0 + Sharpness; 4*WA + WB = 1 -} - -float3 GetColor(float2 UV) -{ - float3 Color = ColorTex.SampleLevel(BilinearClamp, UV, 0); -#ifdef GAMMA_SPACE - return ApplyDisplayProfile(Color, DISPLAY_PLANE_FORMAT); -#else - return Color; -#endif -} - -[RootSignature(Present_RootSig)] -float3 main(float4 position : SV_Position, float2 uv : TexCoord0) : SV_Target0 -{ - float3 Color = WB * GetColor(uv) - WA * ( - GetColor(uv + UVOffset0) + GetColor(uv - UVOffset0) + - GetColor(uv + UVOffset1) + GetColor(uv - UVOffset1)); - -#ifdef GAMMA_SPACE - return Color; -#else - return ApplyDisplayProfile(Color, DISPLAY_PLANE_FORMAT); -#endif -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/TemporalBlendCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/TemporalBlendCS.hlsl deleted file mode 100644 index cf79eb6..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/TemporalBlendCS.hlsl +++ /dev/null @@ -1,207 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "CommonRS.hlsli" -#include "ShaderUtility.hlsli" -#include "PixelPacking_Velocity.hlsli" - -static const uint kLdsPitch = 18; -static const uint kLdsRows = 10; - -RWTexture2D OutTemporal : register(u0); - -Texture2D VelocityBuffer : register(t0); -Texture2D InColor : register(t1); -Texture2D InTemporal : register(t2); -Texture2D CurDepth : register(t3); -Texture2D PreDepth : register(t4); - -SamplerState LinearSampler : register(s0); -SamplerState PointSampler : register(s1); - -groupshared float ldsDepth[kLdsPitch * kLdsRows]; -groupshared float ldsR[kLdsPitch * kLdsRows]; -groupshared float ldsG[kLdsPitch * kLdsRows]; -groupshared float ldsB[kLdsPitch * kLdsRows]; - - -cbuffer CB1 : register(b1) -{ - float2 RcpBufferDim; // 1 / width, 1 / height - float TemporalBlendFactor; - float RcpSpeedLimiter; - float2 ViewportJitter; -} - -void StoreRGB(uint ldsIdx, float3 RGB) -{ - ldsR[ldsIdx] = RGB.r; - ldsG[ldsIdx] = RGB.g; - ldsB[ldsIdx] = RGB.b; -} - -float3 LoadRGB(uint ldsIdx) -{ - return float3(ldsR[ldsIdx], ldsG[ldsIdx], ldsB[ldsIdx]); -} - -float2 STtoUV(float2 ST) -{ - return (ST + 0.5) * RcpBufferDim; -} - -float3 ClipColor(float3 Color, float3 BoxMin, float3 BoxMax, float Dilation = 1.0) -{ - float3 BoxCenter = (BoxMax + BoxMin) * 0.5; - float3 HalfDim = (BoxMax - BoxMin) * 0.5 * Dilation + 0.001; - float3 Displacement = Color - BoxCenter; - float3 Units = abs(Displacement / HalfDim); - float MaxUnit = max(max(Units.x, Units.y), max(Units.z, 1.0)); - return BoxCenter + Displacement / MaxUnit; -} - -void GetBBoxForPair(uint fillIdx, uint holeIdx, out float3 boxMin, out float3 boxMax) -{ - boxMin = boxMax = LoadRGB(fillIdx); - float3 a = LoadRGB(fillIdx - kLdsPitch - 1); - float3 b = LoadRGB(fillIdx - kLdsPitch + 1); - boxMin = min(boxMin, min(a, b)); - boxMax = max(boxMax, max(a, b)); - a = LoadRGB(fillIdx + kLdsPitch - 1); - b = LoadRGB(fillIdx + kLdsPitch + 1); - boxMin = min(boxMin, min(a, b)); - boxMax = max(boxMax, max(a, b)); - a = LoadRGB(holeIdx); - b = LoadRGB(holeIdx - fillIdx + holeIdx); - boxMin = min(boxMin, min(a, b)); - boxMax = max(boxMax, max(a, b)); -} - -float MaxOf(float4 Depths) { return max(max(Depths.x, Depths.y), max(Depths.z, Depths.w)); } - -int2 GetClosestPixel(uint Idx, out float ClosestDepth) -{ - float DepthO = ldsDepth[Idx]; - float DepthW = ldsDepth[Idx - 1]; - float DepthE = ldsDepth[Idx + 1]; - float DepthN = ldsDepth[Idx - kLdsPitch]; - float DepthS = ldsDepth[Idx + kLdsPitch]; - - ClosestDepth = min(DepthO, min(min(DepthW, DepthE), min(DepthN, DepthS))); - - if (DepthN == ClosestDepth) - return int2(0, -1); - else if (DepthS == ClosestDepth) - return int2(0, +1); - else if (DepthW == ClosestDepth) - return int2(-1, 0); - else if (DepthE == ClosestDepth) - return int2(+1, 0); - - return int2(0, 0); -} - -void ApplyTemporalBlend(uint2 ST, uint ldsIdx, float3 BoxMin, float3 BoxMax) -{ - float3 CurrentColor = LoadRGB(ldsIdx); - - float CompareDepth; - - // Get the velocity of the closest pixel in the '+' formation - float3 Velocity = UnpackVelocity(VelocityBuffer[ST + GetClosestPixel(ldsIdx, CompareDepth)]); - - CompareDepth += Velocity.z; - - // The temporal depth is the actual depth of the pixel found at the same reprojected location. - float TemporalDepth = MaxOf(PreDepth.Gather(LinearSampler, STtoUV(ST + Velocity.xy + ViewportJitter))) + 1e-3; - - // Fast-moving pixels cause motion blur and probably don't need TAA - float SpeedFactor = saturate(1.0 - length(Velocity.xy) * RcpSpeedLimiter); - - // Fetch temporal color. Its "confidence" weight is stored in alpha. - float4 Temp = InTemporal.SampleLevel(LinearSampler, STtoUV(ST + Velocity.xy), 0); - float3 TemporalColor = Temp.rgb; - float TemporalWeight = Temp.w; - - // Pixel colors are pre-multiplied by their weight to enable bilinear filtering. Divide by weight to recover color. - TemporalColor /= max(TemporalWeight, 1e-6); - - // Clip the temporal color to the current neighborhood's bounding box. Increase the size of the bounding box for - // stationary pixels to avoid rejecting noisy specular highlights. - TemporalColor = ClipColor(TemporalColor, BoxMin, BoxMax, lerp(1.0, 4.0, SpeedFactor * SpeedFactor)); - - // Update the confidence term based on speed and disocclusion - TemporalWeight *= SpeedFactor * step(CompareDepth, TemporalDepth); - - // Blend previous color with new color based on confidence. Confidence steadily grows with each iteration - // until it is broken by movement such as through disocclusion, color changes, or moving beyond the resolution - // of the velocity buffer. - TemporalColor = ITM(lerp(TM(CurrentColor), TM(TemporalColor), TemporalWeight)); - - // Update weight - TemporalWeight = saturate(rcp(2.0 - TemporalWeight)); - - // Quantize weight to what is representable - TemporalWeight = f16tof32(f32tof16(TemporalWeight)); - - // Breaking this up into two buffers means it can be 40 bits instead of 64. - OutTemporal[ST] = float4(TemporalColor, 1) * TemporalWeight; -} - -[RootSignature(Common_RootSig)] -[numthreads(8, 8, 1)] -void main(uint3 DTid : SV_DispatchThreadID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 Gid : SV_GroupID) -{ - const uint ldsHalfPitch = kLdsPitch / 2; - - // Prefetch an 16x8 tile of pixels (8x8 colors) including a 1 pixel border - // 10x18 IDs with 4 IDs per thread = 45 threads - for (uint i = GI; i < 45; i += 64) - { - uint X = (i % ldsHalfPitch) * 2; - uint Y = (i / ldsHalfPitch) * 2; - uint TopLeftIdx = X + Y * kLdsPitch; - int2 TopLeftST = Gid.xy * uint2(8, 8) - 1 + uint2(X / 2, Y); - float2 UV = RcpBufferDim * (TopLeftST * float2(2, 1) + float2(2, 1)); - - float4 Depths = CurDepth.Gather(LinearSampler, UV); - ldsDepth[TopLeftIdx + 0] = Depths.w; - ldsDepth[TopLeftIdx + 1] = Depths.z; - ldsDepth[TopLeftIdx + kLdsPitch] = Depths.x; - ldsDepth[TopLeftIdx + 1 + kLdsPitch] = Depths.y; - - float4 R4 = InColor.GatherRed(LinearSampler, UV); - float4 G4 = InColor.GatherGreen(LinearSampler, UV); - float4 B4 = InColor.GatherBlue(LinearSampler, UV); - StoreRGB(TopLeftIdx, float3(R4.w, G4.w, B4.w)); - StoreRGB(TopLeftIdx + 1, float3(R4.z, G4.z, B4.z)); - StoreRGB(TopLeftIdx + kLdsPitch, float3(R4.x, G4.x, B4.x)); - StoreRGB(TopLeftIdx + 1 + kLdsPitch, float3(R4.y, G4.y, B4.y)); - } - - GroupMemoryBarrierWithGroupSync(); - - uint Idx0 = GTid.x * 2 + GTid.y * kLdsPitch + kLdsPitch + 1; - uint Idx1 = Idx0 + 1; - - GroupMemoryBarrierWithGroupSync(); - - float3 BoxMin, BoxMax; - GetBBoxForPair(Idx0, Idx1, BoxMin, BoxMax); - - uint2 ST0 = DTid.xy * uint2(2, 1); - ApplyTemporalBlend(ST0, Idx0, BoxMin, BoxMax); - - uint2 ST1 = ST0 + uint2(1, 0); - ApplyTemporalBlend(ST1, Idx1, BoxMin, BoxMax); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/TextAntialiasPS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/TextAntialiasPS.hlsl deleted file mode 100644 index b346a1e..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/TextAntialiasPS.hlsl +++ /dev/null @@ -1,43 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "TextRS.hlsli" - -cbuffer cbFontParams : register(b0) -{ - float4 Color; - float2 ShadowOffset; - float ShadowHardness; - float ShadowOpacity; - float HeightRange; // The range of the signed distance field. -} - -Texture2D SignedDistanceFieldTex : register( t0 ); -SamplerState LinearSampler : register( s0 ); - -struct PS_INPUT -{ - float4 pos : SV_POSITION; - float2 uv : TEXCOORD0; -}; - -float GetAlpha( float2 uv ) -{ - return saturate(SignedDistanceFieldTex.Sample(LinearSampler, uv) * HeightRange + 0.5); -} - -[RootSignature(Text_RootSig)] -float4 main( PS_INPUT Input ) : SV_Target -{ - return float4(Color.rgb, 1) * GetAlpha(Input.uv) * Color.a; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/TextRS.hlsli b/xess/samples/xess_demo/MiniEngine/Core/Shaders/TextRS.hlsli deleted file mode 100644 index e02f042..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/TextRS.hlsli +++ /dev/null @@ -1,23 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define Text_RootSig \ - "RootFlags(ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT), " \ - "CBV(b0, visibility = SHADER_VISIBILITY_VERTEX)," \ - "CBV(b0, visibility = SHADER_VISIBILITY_PIXEL)," \ - "DescriptorTable(SRV(t0, numDescriptors = 1), visibility = SHADER_VISIBILITY_PIXEL)," \ - "StaticSampler(s0, visibility = SHADER_VISIBILITY_PIXEL," \ - "addressU = TEXTURE_ADDRESS_CLAMP," \ - "addressV = TEXTURE_ADDRESS_CLAMP," \ - "addressW = TEXTURE_ADDRESS_CLAMP," \ - "filter = FILTER_MIN_MAG_MIP_LINEAR)" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/TextShadowPS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/TextShadowPS.hlsl deleted file mode 100644 index 4226362..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/TextShadowPS.hlsl +++ /dev/null @@ -1,45 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "TextRS.hlsli" - -cbuffer cbFontParams : register(b0) -{ - float4 Color; - float2 ShadowOffset; - float ShadowHardness; - float ShadowOpacity; - float HeightRange; // The range of the signed distance field. -} - -Texture2D SignedDistanceFieldTex : register( t0 ); -SamplerState LinearSampler : register( s0 ); - -struct PS_INPUT -{ - float4 pos : SV_POSITION; - float2 uv : TEXCOORD0; -}; - -float GetAlpha( float2 uv, float range ) -{ - return saturate(SignedDistanceFieldTex.Sample(LinearSampler, uv) * range + 0.5); -} - -[RootSignature(Text_RootSig)] -float4 main( PS_INPUT Input ) : SV_Target -{ - float alpha1 = GetAlpha(Input.uv, HeightRange) * Color.a; - float alpha2 = GetAlpha(Input.uv - ShadowOffset, HeightRange * ShadowHardness) * ShadowOpacity * Color.a; - return float4( Color.rgb * alpha1, lerp(alpha2, 1, alpha1) ); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/TextVS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/TextVS.hlsl deleted file mode 100644 index e43bc3a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/TextVS.hlsl +++ /dev/null @@ -1,53 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "TextRS.hlsli" - -cbuffer cbFontParams : register(b0) -{ - float2 Scale; // Scale and offset for transforming coordinates - float2 Offset; - float2 InvTexDim; // Normalizes texture coordinates - float TextSize; // Height of text in destination pixels - float TextScale; // TextSize / FontHeight - float DstBorder; // Extra space around a glyph measured in screen space coordinates - uint SrcBorder; // Extra spacing around glyphs to avoid sampling neighboring glyphs -} - -struct VS_INPUT -{ - float2 ScreenPos : POSITION; // Upper-left position in screen pixel coordinates - uint4 Glyph : TEXCOORD; // X, Y, Width, Height in texel space -}; - -struct VS_OUTPUT -{ - float4 Pos : SV_POSITION; // Upper-left and lower-right coordinates in clip space - float2 Tex : TEXCOORD0; // Upper-left and lower-right normalized UVs -}; - -[RootSignature(Text_RootSig)] -VS_OUTPUT main( VS_INPUT input, uint VertID : SV_VertexID ) -{ - const float2 xy0 = input.ScreenPos - DstBorder; - const float2 xy1 = input.ScreenPos + DstBorder + float2(TextScale * input.Glyph.z, TextSize); - const uint2 uv0 = input.Glyph.xy - SrcBorder; - const uint2 uv1 = input.Glyph.xy + SrcBorder + input.Glyph.zw; - - float2 uv = float2( VertID & 1, (VertID >> 1) & 1 ); - - VS_OUTPUT output; - output.Pos = float4( lerp(xy0, xy1, uv) * Scale + Offset, 0, 1 ); - output.Tex = lerp(uv0, uv1, uv) * InvTexDim; - return output; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ToneMap2CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ToneMap2CS.hlsl deleted file mode 100644 index ea10d02..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ToneMap2CS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define SUPPORT_TYPED_UAV_LOADS 1 -#include "ToneMapCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ToneMapCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ToneMapCS.hlsl deleted file mode 100644 index 7c3919f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ToneMapCS.hlsl +++ /dev/null @@ -1,78 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "ToneMappingUtility.hlsli" -#include "PostEffectsRS.hlsli" -#include "PixelPacking.hlsli" - -StructuredBuffer Exposure : register( t0 ); -Texture2D Bloom : register( t1 ); -#if SUPPORT_TYPED_UAV_LOADS -RWTexture2D ColorRW : register( u0 ); -#else -RWTexture2D DstColor : register( u0 ); -Texture2D SrcColor : register( t2 ); -#endif -RWTexture2D OutLuma : register( u1 ); -SamplerState LinearSampler : register( s0 ); - -cbuffer CB0 : register(b0) -{ - float2 g_RcpBufferDim; - float g_BloomStrength; - float PaperWhiteRatio; // PaperWhite / MaxBrightness - float MaxBrightness; -}; - -[RootSignature(PostEffects_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 DTid : SV_DispatchThreadID ) -{ - float2 TexCoord = (DTid.xy + 0.5) * g_RcpBufferDim; - - // Load HDR and bloom -#if SUPPORT_TYPED_UAV_LOADS - float3 hdrColor = ColorRW[DTid.xy]; -#else - float3 hdrColor = SrcColor[DTid.xy]; -#endif - - hdrColor += g_BloomStrength * Bloom.SampleLevel(LinearSampler, TexCoord, 0); - hdrColor *= Exposure[0]; - -#if ENABLE_HDR_DISPLAY_MAPPING - - hdrColor = TM_Stanard(REC709toREC2020(hdrColor) * PaperWhiteRatio) * MaxBrightness; - // Write the HDR color as-is and defer display mapping until we composite with UI -#if SUPPORT_TYPED_UAV_LOADS - ColorRW[DTid.xy] = hdrColor; -#else - DstColor[DTid.xy] = Pack_R11G11B10_FLOAT(hdrColor); -#endif - OutLuma[DTid.xy] = RGBToLogLuminance(hdrColor); - -#else - - // Tone map to SDR - float3 sdrColor = TM_Stanard(hdrColor); - -#if SUPPORT_TYPED_UAV_LOADS - ColorRW[DTid.xy] = sdrColor; -#else - DstColor[DTid.xy] = Pack_R11G11B10_FLOAT(sdrColor); -#endif - - OutLuma[DTid.xy] = RGBToLogLuminance(sdrColor); - -#endif -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ToneMapHDR2CS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ToneMapHDR2CS.hlsl deleted file mode 100644 index df502ce..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ToneMapHDR2CS.hlsl +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define ENABLE_HDR_DISPLAY_MAPPING 1 -#define SUPPORT_TYPED_UAV_LOADS 1 -#include "ToneMapCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ToneMapHDRCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ToneMapHDRCS.hlsl deleted file mode 100644 index bd4cb27..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ToneMapHDRCS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#define ENABLE_HDR_DISPLAY_MAPPING 1 -#include "ToneMapCS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ToneMappingUtility.hlsli b/xess/samples/xess_demo/MiniEngine/Core/Shaders/ToneMappingUtility.hlsli deleted file mode 100644 index e193236..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/ToneMappingUtility.hlsli +++ /dev/null @@ -1,130 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#ifndef __TONE_MAPPING_UTILITY_HLSLI__ -#define __TONE_MAPPING_UTILITY_HLSLI__ - -#include "ShaderUtility.hlsli" - -// -// Reinhard -// - -// The Reinhard tone operator. Typically, the value of k is 1.0, but you can adjust exposure by 1/k. -// I.e. TM_Reinhard(x, 0.5) == TM_Reinhard(x * 2.0, 1.0) -float3 TM_Reinhard(float3 hdr, float k = 1.0) -{ - return hdr / (hdr + k); -} - -// The inverse of Reinhard -float3 ITM_Reinhard(float3 sdr, float k = 1.0) -{ - return k * sdr / (k - sdr); -} - -// -// Reinhard-Squared -// - -// This has some nice properties that improve on basic Reinhard. Firstly, it has a "toe"--that nice, -// parabolic upswing that enhances contrast and color saturation in darks. Secondly, it has a long -// shoulder giving greater detail in highlights and taking longer to desaturate. It's invertible, scales -// to HDR displays, and is easy to control. -// -// The default constant of 0.25 was chosen for two reasons. It maps closely to the effect of Reinhard -// with a constant of 1.0. And with a constant of 0.25, there is an inflection point at 0.25 where the -// curve touches the line y=x and then begins the shoulder. -// -// Note: If you are currently using ACES and you pre-scale by 0.6, then k=0.30 looks nice as an alternative -// without any other adjustments. - -float3 TM_ReinhardSq(float3 hdr, float k = 0.25) -{ - float3 reinhard = hdr / (hdr + k); - return reinhard * reinhard; -} - -float3 ITM_ReinhardSq(float3 sdr, float k = 0.25) -{ - return k * (sdr + sqrt(sdr)) / (1.0 - sdr); -} - -// -// Stanard (New) -// - -// This is the new tone operator. It resembles ACES in many ways, but it is simpler to evaluate with ALU. One -// advantage it has over Reinhard-Squared is that the shoulder goes to white more quickly and gives more overall -// brightness and contrast to the image. - -float3 TM_Stanard(float3 hdr) -{ - return TM_Reinhard(hdr * sqrt(hdr), sqrt(4.0 / 27.0)); -} - -float3 ITM_Stanard(float3 sdr) -{ - return pow(ITM_Reinhard(sdr, sqrt(4.0 / 27.0)), 2.0 / 3.0); -} - -// -// Stanard (Old) -// - -// This is the old tone operator first used in HemiEngine and then MiniEngine. It's simplistic, efficient, -// invertible, and gives nice results, but it has no toe, and the shoulder goes to white fairly quickly. -// -// Note that I removed the distinction between tone mapping RGB and tone mapping Luma. Philosophically, I -// agree with the idea of trying to remap brightness to displayable values while preserving hue. But you -// run into problems where one or more color channels end up brighter than 1.0 and get clipped. - -float3 ToneMap( float3 hdr ) -{ - return 1 - exp2(-hdr); -} - -float3 InverseToneMap(float3 sdr) -{ - return -log2(max(1e-6, 1 - sdr)); -} - -float ToneMapLuma( float luma ) -{ - return 1 - exp2(-luma); -} - -float InverseToneMapLuma(float luma) -{ - return -log2(max(1e-6, 1 - luma)); -} - -// -// ACES -// - -// The next generation of filmic tone operators. - -float3 ToneMapACES( float3 hdr ) -{ - const float A = 2.51, B = 0.03, C = 2.43, D = 0.59, E = 0.14; - return saturate((hdr * (A * hdr + B)) / (hdr * (C * hdr + D) + E)); -} - -float3 InverseToneMapACES( float3 sdr ) -{ - const float A = 2.51, B = 0.03, C = 2.43, D = 0.59, E = 0.14; - return 0.5 * (D * sdr - sqrt(((D*D - 4*C*E) * sdr + 4*A*E-2*B*D) * sdr + B*B) - B) / (A - C * sdr); -} - -#endif // __TONE_MAPPING_UTILITY_HLSLI__ diff --git a/xess/samples/xess_demo/MiniEngine/Core/Shaders/UpsampleAndBlurCS.hlsl b/xess/samples/xess_demo/MiniEngine/Core/Shaders/UpsampleAndBlurCS.hlsl deleted file mode 100644 index 07402aa..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Shaders/UpsampleAndBlurCS.hlsl +++ /dev/null @@ -1,158 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// -// The CS for combining a lower resolution bloom buffer with a higher resolution buffer -// (via bilinear upsampling) and then guassian blurring the resultant buffer. -// -// For the intended bloom blurring algorithm, it is expected that this shader will be -// used repeatedly to upsample and blur successively higher resolutions until the final -// bloom buffer is the destination. -// - -#include "PostEffectsRS.hlsli" - -Texture2D HigherResBuf : register( t0 ); -Texture2D LowerResBuf : register( t1 ); -SamplerState LinearBorder : register( s1 ); -RWTexture2D Result : register( u0 ); - -cbuffer cb0 : register(b0) -{ - float2 g_inverseDimensions; - float g_upsampleBlendFactor; -} - -// The guassian blur weights (derived from Pascal's triangle) -static const float Weights5[3] = { 6.0f / 16.0f, 4.0f / 16.0f, 1.0f / 16.0f }; -static const float Weights7[4] = { 20.0f / 64.0f, 15.0f / 64.0f, 6.0f / 64.0f, 1.0f / 64.0f }; -static const float Weights9[5] = { 70.0f / 256.0f, 56.0f / 256.0f, 28.0f / 256.0f, 8.0f / 256.0f, 1.0f / 256.0f }; - -float3 Blur5( float3 a, float3 b, float3 c, float3 d, float3 e, float3 f, float3 g, float3 h, float3 i ) -{ - return Weights5[0]*e + Weights5[1]*(d+f) + Weights5[2]*(c+g); -} - -float3 Blur7( float3 a, float3 b, float3 c, float3 d, float3 e, float3 f, float3 g, float3 h, float3 i ) -{ - return Weights7[0]*e + Weights7[1]*(d+f) + Weights7[2]*(c+g) + Weights7[3]*(b+h); -} - -float3 Blur9( float3 a, float3 b, float3 c, float3 d, float3 e, float3 f, float3 g, float3 h, float3 i ) -{ - return Weights9[0]*e + Weights9[1]*(d+f) + Weights9[2]*(c+g) + Weights9[3]*(b+h) + Weights9[4]*(a+i); -} - -#define BlurPixels Blur9 - -// 16x16 pixels with an 8x8 center that we will be blurring writing out. Each uint is two color channels packed together -groupshared uint CacheR[128]; -groupshared uint CacheG[128]; -groupshared uint CacheB[128]; - -void Store2Pixels( uint index, float3 pixel1, float3 pixel2 ) -{ - CacheR[index] = f32tof16(pixel1.r) | f32tof16(pixel2.r) << 16; - CacheG[index] = f32tof16(pixel1.g) | f32tof16(pixel2.g) << 16; - CacheB[index] = f32tof16(pixel1.b) | f32tof16(pixel2.b) << 16; -} - -void Load2Pixels( uint index, out float3 pixel1, out float3 pixel2 ) -{ - uint3 RGB = uint3(CacheR[index], CacheG[index], CacheB[index]); - pixel1 = f16tof32(RGB); - pixel2 = f16tof32(RGB >> 16); -} - -void Store1Pixel( uint index, float3 pixel ) -{ - CacheR[index] = asuint(pixel.r); - CacheG[index] = asuint(pixel.g); - CacheB[index] = asuint(pixel.b); -} - -void Load1Pixel( uint index, out float3 pixel ) -{ - pixel = asfloat( uint3(CacheR[index], CacheG[index], CacheB[index]) ); -} - -// Blur two pixels horizontally. This reduces LDS reads and pixel unpacking. -void BlurHorizontally( uint outIndex, uint leftMostIndex ) -{ - float3 s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - Load2Pixels( leftMostIndex + 0, s0, s1 ); - Load2Pixels( leftMostIndex + 1, s2, s3 ); - Load2Pixels( leftMostIndex + 2, s4, s5 ); - Load2Pixels( leftMostIndex + 3, s6, s7 ); - Load2Pixels( leftMostIndex + 4, s8, s9 ); - - Store1Pixel(outIndex , BlurPixels(s0, s1, s2, s3, s4, s5, s6, s7, s8)); - Store1Pixel(outIndex+1, BlurPixels(s1, s2, s3, s4, s5, s6, s7, s8, s9)); -} - -void BlurVertically( uint2 pixelCoord, uint topMostIndex ) -{ - float3 s0, s1, s2, s3, s4, s5, s6, s7, s8; - Load1Pixel( topMostIndex , s0 ); - Load1Pixel( topMostIndex+ 8, s1 ); - Load1Pixel( topMostIndex+16, s2 ); - Load1Pixel( topMostIndex+24, s3 ); - Load1Pixel( topMostIndex+32, s4 ); - Load1Pixel( topMostIndex+40, s5 ); - Load1Pixel( topMostIndex+48, s6 ); - Load1Pixel( topMostIndex+56, s7 ); - Load1Pixel( topMostIndex+64, s8 ); - - Result[pixelCoord] = BlurPixels(s0, s1, s2, s3, s4, s5, s6, s7, s8); -} - -[RootSignature(PostEffects_RootSig)] -[numthreads( 8, 8, 1 )] -void main( uint3 Gid : SV_GroupID, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID ) -{ - // - // Load 4 pixels per thread into LDS - // - int2 GroupUL = (Gid.xy << 3) - 4; // Upper-left pixel coordinate of group read location - int2 ThreadUL = (GTid.xy << 1) + GroupUL; // Upper-left pixel coordinate of quad that this thread will read - - // - // Store 4 blended-but-unblurred pixels in LDS - // - float2 uvUL = (float2(ThreadUL) + 0.5) * g_inverseDimensions; - float2 uvLR = uvUL + g_inverseDimensions; - float2 uvUR = float2(uvLR.x, uvUL.y); - float2 uvLL = float2(uvUL.x, uvLR.y); - int destIdx = GTid.x + (GTid.y << 4); - - float3 pixel1a = lerp(HigherResBuf[ThreadUL + uint2(0, 0)], LowerResBuf.SampleLevel(LinearBorder, uvUL, 0.0f), g_upsampleBlendFactor); - float3 pixel1b = lerp(HigherResBuf[ThreadUL + uint2(1, 0)], LowerResBuf.SampleLevel(LinearBorder, uvUR, 0.0f), g_upsampleBlendFactor); - Store2Pixels(destIdx+0, pixel1a, pixel1b); - - float3 pixel2a = lerp(HigherResBuf[ThreadUL + uint2(0, 1)], LowerResBuf.SampleLevel(LinearBorder, uvLL, 0.0f), g_upsampleBlendFactor); - float3 pixel2b = lerp(HigherResBuf[ThreadUL + uint2(1, 1)], LowerResBuf.SampleLevel(LinearBorder, uvLR, 0.0f), g_upsampleBlendFactor); - Store2Pixels(destIdx+8, pixel2a, pixel2b); - - GroupMemoryBarrierWithGroupSync(); - - // - // Horizontally blur the pixels in Cache - // - uint row = GTid.y << 4; - BlurHorizontally(row + (GTid.x << 1), row + GTid.x + (GTid.x & 4)); - - GroupMemoryBarrierWithGroupSync(); - - // - // Vertically blur the pixels and write the result to memory - // - BlurVertically(DTid.xy, (GTid.y << 3) + GTid.x); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/ShadowBuffer.cpp b/xess/samples/xess_demo/MiniEngine/Core/ShadowBuffer.cpp deleted file mode 100644 index 033dbef..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/ShadowBuffer.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "ShadowBuffer.h" -#include "EsramAllocator.h" -#include "CommandContext.h" - -void ShadowBuffer::Create( const std::wstring& Name, uint32_t Width, uint32_t Height, D3D12_GPU_VIRTUAL_ADDRESS VidMemPtr ) -{ - DepthBuffer::Create( Name, Width, Height, DXGI_FORMAT_D16_UNORM, VidMemPtr ); - - m_Viewport.TopLeftX = 0.0f; - m_Viewport.TopLeftY = 0.0f; - m_Viewport.Width = (float)Width; - m_Viewport.Height = (float)Height; - m_Viewport.MinDepth = 0.0f; - m_Viewport.MaxDepth = 1.0f; - - // Prevent drawing to the boundary pixels so that we don't have to worry about shadows stretching - m_Scissor.left = 1; - m_Scissor.top = 1; - m_Scissor.right = (LONG)Width - 2; - m_Scissor.bottom = (LONG)Height - 2; -} - -void ShadowBuffer::Create( const std::wstring& Name, uint32_t Width, uint32_t Height, EsramAllocator& Allocator ) -{ - DepthBuffer::Create( Name, Width, Height, DXGI_FORMAT_D16_UNORM, Allocator ); - - m_Viewport.TopLeftX = 0.0f; - m_Viewport.TopLeftY = 0.0f; - m_Viewport.Width = (float)Width; - m_Viewport.Height = (float)Height; - m_Viewport.MinDepth = 0.0f; - m_Viewport.MaxDepth = 1.0f; - - // Prevent drawing to the boundary pixels so that we don't have to worry about shadows stretching - m_Scissor.left = 1; - m_Scissor.top = 1; - m_Scissor.right = (LONG)Width - 2; - m_Scissor.bottom = (LONG)Height - 2; -} - -void ShadowBuffer::BeginRendering( GraphicsContext& Context ) -{ - Context.TransitionResource(*this, D3D12_RESOURCE_STATE_DEPTH_WRITE, true); - Context.ClearDepth(*this); - Context.SetDepthStencilTarget(GetDSV()); - Context.SetViewportAndScissor(m_Viewport, m_Scissor); -} - -void ShadowBuffer::EndRendering( GraphicsContext& Context ) -{ - Context.TransitionResource(*this, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/ShadowBuffer.h b/xess/samples/xess_demo/MiniEngine/Core/ShadowBuffer.h deleted file mode 100644 index 43c906d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/ShadowBuffer.h +++ /dev/null @@ -1,39 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "DepthBuffer.h" - -class EsramAllocator; - -class GraphicsContext; - -class ShadowBuffer : public DepthBuffer -{ -public: - ShadowBuffer() {} - - void Create( const std::wstring& Name, uint32_t Width, uint32_t Height, - D3D12_GPU_VIRTUAL_ADDRESS VidMemPtr = D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN ); - void Create( const std::wstring& Name, uint32_t Width, uint32_t Height, EsramAllocator& Allocator ); - - D3D12_CPU_DESCRIPTOR_HANDLE GetSRV() const { return GetDepthSRV(); } - - void BeginRendering( GraphicsContext& context ); - void EndRendering( GraphicsContext& context ); - -private: - D3D12_VIEWPORT m_Viewport; - D3D12_RECT m_Scissor; -}; diff --git a/xess/samples/xess_demo/MiniEngine/Core/ShadowCamera.cpp b/xess/samples/xess_demo/MiniEngine/Core/ShadowCamera.cpp deleted file mode 100644 index a432e83..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/ShadowCamera.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "ShadowCamera.h" - -using namespace Math; - -void ShadowCamera::UpdateMatrix( - Vector3 LightDirection, Vector3 ShadowCenter, Vector3 ShadowBounds, - uint32_t BufferWidth, uint32_t BufferHeight, uint32_t BufferPrecision) -{ - SetLookDirection( LightDirection, Vector3(kYUnitVector) ); - - // Converts world units to texel units so we can quantize the camera position to whole texel units - Vector3 RcpDimensions = Recip(ShadowBounds); - Vector3 QuantizeScale = Vector3((float)BufferWidth, (float)BufferHeight, (float)((1 << BufferPrecision) - 1)) * RcpDimensions; - - // - // Recenter the camera at the quantized position - // - // Transform to view space - ShadowCenter = ~GetRotation() * ShadowCenter; - // Scale to texel units, truncate fractional part, and scale back to world units - ShadowCenter = Floor( ShadowCenter * QuantizeScale ) / QuantizeScale; - // Transform back into world space - ShadowCenter = GetRotation() * ShadowCenter; - - SetPosition( ShadowCenter ); - - XMMATRIX projMat = XMMatrixOrthographicOffCenterRH(-ShadowBounds.GetX(), ShadowBounds.GetX(), - -ShadowBounds.GetY(), ShadowBounds.GetY(), - ShadowBounds.GetZ(), -ShadowBounds.GetZ()); // invert Z - - SetProjMatrix( Matrix4(projMat) ); - - Update(); - - // Transform from clip space to texture space - m_ShadowMatrix = Matrix4( AffineTransform( Matrix3::MakeScale( 0.5f, -0.5f, 1.0f ), Vector3(0.5f, 0.5f, 0.0f) ) ) * m_ViewProjMatrix; -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/ShadowCamera.h b/xess/samples/xess_demo/MiniEngine/Core/ShadowCamera.h deleted file mode 100644 index f8ebe80..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/ShadowCamera.h +++ /dev/null @@ -1,43 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "Camera.h" -#include "VectorMath.h" - -class ShadowCamera : public Math::BaseCamera -{ -public: - - ShadowCamera() {} - - void UpdateMatrix( - Math::Vector3 LightDirection, // Direction parallel to light, in direction of travel - Math::Vector3 ShadowCenter, // Center location on far bounding plane of shadowed region - Math::Vector3 ShadowBounds, // Width, height, and depth in world space represented by the shadow buffer - uint32_t BufferWidth, // Shadow buffer width - uint32_t BufferHeight, // Shadow buffer height--usually same as width - uint32_t BufferPrecision // Bit depth of shadow buffer--usually 16 or 24 - ); - - // Set View-Projection matrix. - void SetViewProjMatrix(const Math::Matrix4& matrix) { m_ViewProjMatrix = matrix; }; - - // Used to transform world space to texture space for shadow sampling - const Math::Matrix4& GetShadowMatrix() const { return m_ShadowMatrix; } - -private: - - Math::Matrix4 m_ShadowMatrix; -}; diff --git a/xess/samples/xess_demo/MiniEngine/Core/SystemTime.cpp b/xess/samples/xess_demo/MiniEngine/Core/SystemTime.cpp deleted file mode 100644 index 3379c91..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/SystemTime.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "SystemTime.h" - -double SystemTime::sm_CpuTickDelta = 0.0; - -// Query the performance counter frequency -void SystemTime::Initialize( void ) -{ - LARGE_INTEGER frequency; - ASSERT(TRUE == QueryPerformanceFrequency(&frequency), "Unable to query performance counter frequency"); - sm_CpuTickDelta = 1.0 / static_cast(frequency.QuadPart); -} - -// Query the current value of the performance counter -int64_t SystemTime::GetCurrentTick( void ) -{ - LARGE_INTEGER currentTick; - ASSERT(TRUE == QueryPerformanceCounter(¤tTick), "Unable to query performance counter value"); - return static_cast(currentTick.QuadPart); -} - -void SystemTime::BusyLoopSleep( float SleepTime ) -{ - int64_t finalTick = (int64_t)((double)SleepTime / sm_CpuTickDelta) + GetCurrentTick(); - while (GetCurrentTick() < finalTick); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/SystemTime.h b/xess/samples/xess_demo/MiniEngine/Core/SystemTime.h deleted file mode 100644 index 18b35e7..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/SystemTime.h +++ /dev/null @@ -1,92 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// -// Contains classes needed to time executing code. -// - -#pragma once - -class SystemTime -{ -public: - - // Query the performance counter frequency - static void Initialize( void ); - - // Query the current value of the performance counter - static int64_t GetCurrentTick( void ); - - static void BusyLoopSleep( float SleepTime ); - - static inline double TicksToSeconds( int64_t TickCount ) - { - return TickCount * sm_CpuTickDelta; - } - - static inline double TicksToMillisecs( int64_t TickCount ) - { - return TickCount * sm_CpuTickDelta * 1000.0; - } - - static inline double TimeBetweenTicks( int64_t tick1, int64_t tick2 ) - { - return TicksToSeconds(tick2 - tick1); - } - -private: - - // The amount of time that elapses between ticks of the performance counter - static double sm_CpuTickDelta; -}; - - -class CpuTimer -{ -public: - - CpuTimer() - { - m_StartTick = 0ll; - m_ElapsedTicks = 0ll; - } - - void Start() - { - if (m_StartTick == 0ll) - m_StartTick = SystemTime::GetCurrentTick(); - } - - void Stop() - { - if (m_StartTick != 0ll) - { - m_ElapsedTicks += SystemTime::GetCurrentTick() - m_StartTick; - m_StartTick = 0ll; - } - } - - void Reset() - { - m_ElapsedTicks = 0ll; - m_StartTick = 0ll; - } - - double GetTime() const - { - return SystemTime::TicksToSeconds(m_ElapsedTicks); - } - -private: - - int64_t m_StartTick; - int64_t m_ElapsedTicks; -}; diff --git a/xess/samples/xess_demo/MiniEngine/Core/TemporalEffects.cpp b/xess/samples/xess_demo/MiniEngine/Core/TemporalEffects.cpp deleted file mode 100644 index 0e7cf50..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/TemporalEffects.cpp +++ /dev/null @@ -1,224 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "TemporalEffects.h" -#include "BufferManager.h" -#include "GraphicsCore.h" -#include "GraphicsCommon.h" -#include "CommandContext.h" -#include "SystemTime.h" -#include "PostEffects.h" - -#include "CompiledShaders/TemporalBlendCS.h" -#include "CompiledShaders/BoundNeighborhoodCS.h" -#include "CompiledShaders/ResolveTAACS.h" -#include "CompiledShaders/SharpenTAACS.h" - -using namespace Graphics; -using namespace Math; -using namespace TemporalEffects; - -namespace TemporalEffects -{ - BoolVar EnableTAA("Graphics/AA/TAA/Enable", false); - NumVar Sharpness("Graphics/AA/TAA/Sharpness", 0.5f, 0.0f, 1.0f, 0.25f); - NumVar TemporalMaxLerp("Graphics/AA/TAA/Blend Factor", 1.0f, 0.0f, 1.0f, 0.01f); - ExpVar TemporalSpeedLimit("Graphics/AA/TAA/Speed Limit", 64.0f, 1.0f, 1024.0f, 1.0f); - BoolVar TriggerReset("Graphics/AA/TAA/Reset", false); - BoolVar EnableCBR("Graphics/CBR/Enable", false); - - ComputePSO s_TemporalBlendCS(L"TAA: Temporal Blend CS"); - ComputePSO s_BoundNeighborhoodCS(L"TAA: Bound Neighborhood CS"); - ComputePSO s_SharpenTAACS(L"TAA: Sharpen TAA CS"); - ComputePSO s_ResolveTAACS(L"TAA: Resolve TAA CS"); - - uint32_t s_FrameIndex = 0; - uint32_t s_FrameIndexMod2 = 0; - float s_JitterX = 0.5f; - float s_JitterY = 0.5f; - float s_JitterDeltaX = 0.0f; - float s_JitterDeltaY = 0.0f; - - void ApplyTemporalAA(ComputeContext& Context); - void SharpenImage(ComputeContext& Context, ColorBuffer& TemporalColor); -} - -void TemporalEffects::Initialize( void ) -{ -#define CreatePSO( ObjName, ShaderByteCode ) \ - ObjName.SetRootSignature(g_CommonRS); \ - ObjName.SetComputeShader(ShaderByteCode, sizeof(ShaderByteCode) ); \ - ObjName.Finalize(); - - CreatePSO( s_TemporalBlendCS, g_pTemporalBlendCS ); - CreatePSO( s_BoundNeighborhoodCS, g_pBoundNeighborhoodCS ); - CreatePSO( s_SharpenTAACS, g_pSharpenTAACS ); - CreatePSO( s_ResolveTAACS, g_pResolveTAACS ); - -#undef CreatePSO -} - -void TemporalEffects::Shutdown( void ) -{ -} - -void TemporalEffects::Update( uint64_t FrameIndex ) -{ - // Not implemented on Desktop yet - EnableCBR = false; - - s_FrameIndex = (uint32_t)FrameIndex; - s_FrameIndexMod2 = s_FrameIndex % 2; - - if (EnableTAA)// && !DepthOfField::Enable) - { - static const float Halton23[8][2] = - { - { 0.0f / 8.0f, 0.0f / 9.0f }, { 4.0f / 8.0f, 3.0f / 9.0f }, - { 2.0f / 8.0f, 6.0f / 9.0f }, { 6.0f / 8.0f, 1.0f / 9.0f }, - { 1.0f / 8.0f, 4.0f / 9.0f }, { 5.0f / 8.0f, 7.0f / 9.0f }, - { 3.0f / 8.0f, 2.0f / 9.0f }, { 7.0f / 8.0f, 5.0f / 9.0f } - }; - - const float* Offset = nullptr; - - // With CBR, having an odd number of jitter positions is good because odd and even - // frames can both explore all sample positions. (Also, the least useful sample is - // the first one, which is exactly centered between four pixels.) - if (EnableCBR) - Offset = Halton23[s_FrameIndex % 7 + 1]; - else - Offset = Halton23[s_FrameIndex % 8]; - - s_JitterDeltaX = s_JitterX - Offset[0]; - s_JitterDeltaY = s_JitterY - Offset[1]; - s_JitterX = Offset[0]; - s_JitterY = Offset[1]; - } - else - { - s_JitterDeltaX = s_JitterX - 0.5f; - s_JitterDeltaY = s_JitterY - 0.5f; - s_JitterX = 0.5f; - s_JitterY = 0.5f; - } - -} - -uint32_t TemporalEffects::GetFrameIndexMod2( void ) -{ - return s_FrameIndexMod2; -} - -void TemporalEffects::GetJitterOffset( float& JitterX, float& JitterY ) -{ - JitterX = s_JitterX; - JitterY = s_JitterY; -} - -void TemporalEffects::ClearHistory( CommandContext& Context ) -{ - GraphicsContext& gfxContext = Context.GetGraphicsContext(); - - if (EnableTAA) - { - gfxContext.TransitionResource(g_TemporalColor[0], D3D12_RESOURCE_STATE_RENDER_TARGET); - gfxContext.TransitionResource(g_TemporalColor[1], D3D12_RESOURCE_STATE_RENDER_TARGET, true); - gfxContext.ClearColor(g_TemporalColor[0]); - gfxContext.ClearColor(g_TemporalColor[1]); - } -} - -void TemporalEffects::ResolveImage( CommandContext& BaseContext ) -{ - ScopedTimer _prof(L"Temporal Resolve", BaseContext); - - ComputeContext& Context = BaseContext.GetComputeContext(); - - static bool s_EnableTAA = false; - static bool s_EnableCBR = false; - - if (EnableTAA != s_EnableTAA || EnableCBR && !s_EnableCBR || TriggerReset) - { - ClearHistory(Context); - s_EnableTAA = EnableTAA; - s_EnableCBR = EnableCBR; - TriggerReset = false; - } - - // TAA passes called here. - if (EnableTAA) - { - uint32_t Src = s_FrameIndexMod2; - uint32_t Dst = Src ^ 1; - - ApplyTemporalAA(Context); - SharpenImage(Context, g_TemporalColor[Dst]); - } -} - -void TemporalEffects::ApplyTemporalAA(ComputeContext& Context) -{ - ScopedTimer _prof(L"Resolve Image", Context); - - uint32_t Src = s_FrameIndexMod2; - uint32_t Dst = Src ^ 1; - - Context.SetRootSignature(g_CommonRS); - Context.SetPipelineState(s_TemporalBlendCS); - - __declspec(align(16)) struct ConstantBuffer - { - float RcpBufferDim[2]; - float TemporalBlendFactor; - float RcpSeedLimiter; - float CombinedJitter[2]; - }; - ConstantBuffer cbv = { - 1.0f / g_SceneColorBuffer.GetWidth(), 1.0f / g_SceneColorBuffer.GetHeight(), - (float)TemporalMaxLerp, 1.0f / TemporalSpeedLimit, - s_JitterDeltaX, s_JitterDeltaY - }; - - Context.SetDynamicConstantBufferView(3, sizeof(cbv), &cbv); - - Context.TransitionResource(g_VelocityBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_SceneColorBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_TemporalColor[Src], D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_TemporalColor[Dst], D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(g_LinearDepth[Src], D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_LinearDepth[Dst], D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.SetDynamicDescriptor(1, 0, g_VelocityBuffer.GetSRV()); - Context.SetDynamicDescriptor(1, 1, g_SceneColorBuffer.GetSRV()); - Context.SetDynamicDescriptor(1, 2, g_TemporalColor[Src].GetSRV()); - Context.SetDynamicDescriptor(1, 3, g_LinearDepth[Src].GetSRV()); - Context.SetDynamicDescriptor(1, 4, g_LinearDepth[Dst].GetSRV()); - Context.SetDynamicDescriptor(2, 0, g_TemporalColor[Dst].GetUAV()); - - Context.Dispatch2D(g_SceneColorBuffer.GetWidth(), g_SceneColorBuffer.GetHeight(), 16, 8); -} - -void TemporalEffects::SharpenImage(ComputeContext& Context, ColorBuffer& TemporalColor) -{ - ScopedTimer _prof(L"Sharpen or Copy Image", Context); - - Context.TransitionResource(g_SceneColorBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(TemporalColor, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - - Context.SetPipelineState(Sharpness >= 0.001f ? s_SharpenTAACS : s_ResolveTAACS); - Context.SetConstants(0, 1.0f + Sharpness, 0.25f * Sharpness); - Context.SetDynamicDescriptor(1, 0, TemporalColor.GetSRV()); - Context.SetDynamicDescriptor(2, 0, g_SceneColorBuffer.GetUAV()); - Context.Dispatch2D(g_SceneColorBuffer.GetWidth(), g_SceneColorBuffer.GetHeight()); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/TemporalEffects.h b/xess/samples/xess_demo/MiniEngine/Core/TemporalEffects.h deleted file mode 100644 index 0dffbc2..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/TemporalEffects.h +++ /dev/null @@ -1,47 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "EngineTuning.h" - -class CommandContext; - -namespace TemporalEffects -{ - extern NumVar Sharpness; - - // Temporal antialiasing involves jittering sample positions and accumulating color over time to - // effectively supersample the image. - extern BoolVar EnableTAA; - - void Initialize( void ); - - void Shutdown( void ); - - // Call once per frame to increment the internal frame counter and, in the case of TAA, choosing the next - // jittered sample position. - void Update( uint64_t FrameIndex ); - - // Returns whether the frame is odd or even, relevant to checkerboard rendering. - uint32_t GetFrameIndexMod2( void ); - - // Jitter values are neutral at 0.5 and vary from [0, 1). Jittering only occurs when temporal antialiasing - // is enabled. You can use these values to jitter your viewport or projection matrix. - void GetJitterOffset( float& JitterX, float& JitterY ); - - void ClearHistory(CommandContext& Context); - - void ResolveImage(CommandContext& Context); - -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/TextRenderer.cpp b/xess/samples/xess_demo/MiniEngine/Core/TextRenderer.cpp deleted file mode 100644 index 0f8f657..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/TextRenderer.cpp +++ /dev/null @@ -1,551 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -// Modified 2022, Intel Corporation. -// Added support for DPI change. - -#include "pch.h" -#include "TextRenderer.h" -#include "FileUtility.h" -#include "Texture.h" -#include "SystemTime.h" -#include "GraphicsCore.h" -#include "CommandContext.h" -#include "PipelineState.h" -#include "RootSignature.h" -#include "BufferManager.h" -#include "Display.h" -#include "CompiledShaders/TextVS.h" -#include "CompiledShaders/TextAntialiasPS.h" -#include "CompiledShaders/TextShadowPS.h" -#include "Fonts/consola24.h" -#include -#include -#include -#include -#include - -using namespace Graphics; -using namespace Math; -using namespace std; - -namespace TextRenderer -{ - class Font - { - public: - Font() - { - m_NormalizeXCoord = 0.0f; - m_NormalizeYCoord = 0.0f; - m_FontLineSpacing = 0.0f; - m_AntialiasRange = 0.0f; - m_FontHeight = 0; - m_BorderSize = 0; - m_TextureWidth = 0; - m_TextureHeight = 0; - } - - ~Font() - { - m_Dictionary.clear(); - } - - void LoadFromBinary( const wchar_t* fontName, const uint8_t* pBinary, const size_t binarySize ) - { - (fontName); - - // We should at least use this to assert that we have a complete file - (binarySize); - - struct FontHeader - { - char FileDescriptor[8]; // "SDFFONT\0" - uint8_t majorVersion; // '1' - uint8_t minorVersion; // '0' - uint16_t borderSize; // Pixel empty space border width - uint16_t textureWidth; // Width of texture buffer - uint16_t textureHeight; // Height of texture buffer - uint16_t fontHeight; // Font height in 12.4 - uint16_t advanceY; // Line height in 12.4 - uint16_t numGlyphs; // Glyph count in texture - uint16_t searchDist; // Range of search space 12.4 - }; - - FontHeader* header = (FontHeader*)pBinary; - m_NormalizeXCoord = 1.0f / (header->textureWidth * 16); - m_NormalizeYCoord = 1.0f / (header->textureHeight * 16); - m_FontHeight = header->fontHeight; - m_FontLineSpacing = (float)header->advanceY / (float)header->fontHeight; - m_BorderSize = header->borderSize * 16; - m_AntialiasRange = (float)header->searchDist / header->fontHeight; - uint16_t textureWidth = header->textureWidth; - uint16_t textureHeight = header->textureHeight; - uint16_t NumGlyphs = header->numGlyphs; - - const wchar_t* wcharList = (wchar_t*)(pBinary + sizeof(FontHeader)); - const Glyph* glyphData = (Glyph*)(wcharList + NumGlyphs); - const void* texelData = glyphData + NumGlyphs; - - for (uint16_t i = 0; i < NumGlyphs; ++i) - m_Dictionary[wcharList[i]] = glyphData[i]; - - m_Texture.Create2D( textureWidth, textureWidth, textureHeight, DXGI_FORMAT_R8_SNORM, texelData ); - - LOG_DEBUGF( "Loaded SDF font: %ls (ver. %d.%d)", fontName, header->majorVersion, header->minorVersion); - } - - bool Load( const wstring& fileName ) - { - Utility::ByteArray ba = Utility::ReadFileSync( fileName ); - - if (ba->size() == 0) - { - ERROR( "Cannot open file %ls", fileName.c_str() ); - return false; - } - - LoadFromBinary( fileName.c_str(), ba->data(), ba->size() ); - - return true; - } - - // Each character has an XY start offset, a width, and they all share the same height - struct Glyph - { - uint16_t x, y, w; - int16_t bearing; - uint16_t advance; - }; - - const Glyph* GetGlyph( wchar_t ch ) const - { - auto it = m_Dictionary.find( ch ); - return it == m_Dictionary.end() ? nullptr : &it->second; - } - - // Get the texel height of the font in 12.4 fixed point - uint16_t GetHeight( void ) const { return m_FontHeight; } - - // Get the size of the border in 12.4 fixed point - uint16_t GetBorderSize( void ) const { return m_BorderSize; } - - // Get the line advance height given a certain font size - float GetVerticalSpacing( float size ) const { return size * m_FontLineSpacing; } - - // Get the texture object - const Texture& GetTexture( void ) const { return m_Texture; } - - float GetXNormalizationFactor() const { return m_NormalizeXCoord; } - float GetYNormalizationFactor() const { return m_NormalizeYCoord; } - - // Get the range in terms of height values centered on the midline that represents a pixel - // in screen space (according to the specified font size.) - // The pixel alpha should range from 0 to 1 over the height range 0.5 +/- 0.5 * aaRange. - float GetAntialiasRange( float size ) const { return Max( 1.0f, size * m_AntialiasRange ); } - - private: - float m_NormalizeXCoord; - float m_NormalizeYCoord; - float m_FontLineSpacing; - float m_AntialiasRange; - uint16_t m_FontHeight; - uint16_t m_BorderSize; - uint16_t m_TextureWidth; - uint16_t m_TextureHeight; - Texture m_Texture; - map m_Dictionary; - }; - - map< wstring, unique_ptr > LoadedFonts; - - const Font* GetOrLoadFont(const wstring& filename) - { - auto fontIter = LoadedFonts.find( filename ); - if (fontIter != LoadedFonts.end()) - return fontIter->second.get(); - - Font* newFont = new Font(); - if (filename == L"default") - newFont->LoadFromBinary(L"default", g_pconsola24, sizeof(g_pconsola24)); - else - newFont->Load(L"Fonts/" + filename + L".fnt"); - LoadedFonts[filename].reset(newFont); - return newFont; - } - - RootSignature s_RootSignature; - GraphicsPSO s_TextPSO[2] = { {L"Text Render: Text R8G8B8A8_UNORM PSO"}, { L"Text Render: Text R11G11B10_FLOAT PSO" } }; // 0: R8G8B8A8_UNORM 1: R11G11B10_FLOAT - GraphicsPSO s_ShadowPSO[2] = { { L"Text Render: Shadow R8G8B8A8_UNORM PSO" },{ L"Text Render: Shadow R11G11B10_FLOAT PSO" } }; // 0: R8G8B8A8_UNORM 1: R11G11B10_FLOAT - - -} // namespace TextRenderer - -void TextRenderer::Initialize( void ) -{ - s_RootSignature.Reset(3, 1); - s_RootSignature.InitStaticSampler(0, SamplerLinearClampDesc, D3D12_SHADER_VISIBILITY_PIXEL); - s_RootSignature[0].InitAsConstantBuffer(0, D3D12_SHADER_VISIBILITY_VERTEX); - s_RootSignature[1].InitAsConstantBuffer(0, D3D12_SHADER_VISIBILITY_PIXEL); - s_RootSignature[2].InitAsDescriptorRange(D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 1, D3D12_SHADER_VISIBILITY_PIXEL); - s_RootSignature.Finalize(L"TextRenderer", D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT); - - // The glyph vertex description. One vertex will correspond to a single character. - D3D12_INPUT_ELEMENT_DESC vertElem[] = - { - { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT , 0, 0, D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA, 1 }, - { "TEXCOORD", 0, DXGI_FORMAT_R16G16B16A16_UINT, 0, 8, D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA, 1 } - }; - - s_TextPSO[0].SetRootSignature(s_RootSignature); - s_TextPSO[0].SetRasterizerState( Graphics::RasterizerTwoSided ); - s_TextPSO[0].SetBlendState( Graphics::BlendPreMultiplied ); - s_TextPSO[0].SetDepthStencilState( Graphics::DepthStateDisabled ); - s_TextPSO[0].SetInputLayout(_countof(vertElem), vertElem); - s_TextPSO[0].SetPrimitiveTopologyType(D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE); - s_TextPSO[0].SetVertexShader( g_pTextVS, sizeof(g_pTextVS) ); - s_TextPSO[0].SetPixelShader( g_pTextAntialiasPS, sizeof(g_pTextAntialiasPS) ); - s_TextPSO[0].SetRenderTargetFormats(1, &g_OverlayBuffer.GetFormat(), DXGI_FORMAT_UNKNOWN); - s_TextPSO[0].Finalize(); - - s_TextPSO[1] = s_TextPSO[0]; - s_TextPSO[1].SetRenderTargetFormats(1, &g_SceneColorBuffer.GetFormat(), DXGI_FORMAT_UNKNOWN); - s_TextPSO[1].Finalize(); - - s_ShadowPSO[0] = s_TextPSO[0]; - s_ShadowPSO[0].SetPixelShader(g_pTextShadowPS, sizeof(g_pTextShadowPS) ); - s_ShadowPSO[0].Finalize(); - - s_ShadowPSO[1] = s_ShadowPSO[0]; - s_ShadowPSO[1].SetRenderTargetFormats(1, &g_SceneColorBuffer.GetFormat(), DXGI_FORMAT_UNKNOWN); - s_ShadowPSO[1].Finalize(); -} - -void TextRenderer::Shutdown( void ) -{ - LoadedFonts.clear(); -} - -TextContext::TextContext( GraphicsContext& CmdContext, float ViewWidth, float ViewHeight ) - : m_Context(CmdContext) -{ - m_HDR = FALSE; - m_CurrentFont = nullptr; - m_ViewWidth = ViewWidth; - m_ViewHeight = ViewHeight; - - // Transform from text view space to clip space. - const float vpX = 0.0f; - const float vpY = 0.0f; - const float twoDivW = 2.0f / ViewWidth; - const float twoDivH = 2.0f / ViewHeight; - m_VSParams.ViewportTransform = Vector4(twoDivW, -twoDivH, -vpX * twoDivW - 1.0f, vpY * twoDivH + 1.0f); - - // The font texture dimensions are still unknown - m_VSParams.NormalizeX = 1.0f; - m_VSParams.NormalizeY = 1.0f; - - ResetSettings(); -} - -void TextContext::ResetSettings( void ) -{ - m_EnableShadow = true; - ResetCursor(0.0f, 0.0f); - m_ShadowOffsetX = 0.05f; - m_ShadowOffsetY = 0.05f; - m_PSParams.ShadowHardness = 0.5f; - m_PSParams.ShadowOpacity = 1.0f; - m_PSParams.TextColor = Color(1.0f, 1.0f, 1.0f, 1.0f); - - m_VSConstantBufferIsStale = true; - m_PSConstantBufferIsStale = true; - m_TextureIsStale = true; - - SetFont( L"default", 24.0f ); -} - -void TextContext::SetLeftMargin( float x ) { m_LeftMargin = x; } -void TextContext::SetCursorX( float x ) { m_TextPosX = x; } -void TextContext::SetCursorY( float y ) { m_TextPosY = y; } -void TextContext::NewLine( void ) { m_TextPosX = m_LeftMargin; m_TextPosY += m_LineHeight; } -float TextContext::GetLeftMargin( void ) { return m_LeftMargin; } -float TextContext::GetCursorX( void ) { return m_TextPosX; } -float TextContext::GetCursorY( void ) { return m_TextPosY; } - - -void TextContext::ResetCursor(float x, float y) -{ - m_LeftMargin = x; - m_TextPosX = x; - m_TextPosY = y; -} - -void TextContext::EnableDropShadow(bool enable) -{ - if (m_EnableShadow == enable) - return; - - m_EnableShadow = enable; - - m_Context.SetPipelineState( m_EnableShadow ? TextRenderer::s_ShadowPSO[m_HDR] : TextRenderer::s_TextPSO[m_HDR] ); -} - -void TextContext::SetShadowOffset(float xPercent, float yPercent) -{ - m_ShadowOffsetX = xPercent; - m_ShadowOffsetY = yPercent; - m_PSParams.ShadowOffsetX = m_CurrentFont->GetHeight() * m_ShadowOffsetX * m_VSParams.NormalizeX; - m_PSParams.ShadowOffsetY = m_CurrentFont->GetHeight() * m_ShadowOffsetY * m_VSParams.NormalizeY; - m_PSConstantBufferIsStale = true; -} - -void TextContext::SetShadowParams(float opacity, float width) -{ - m_PSParams.ShadowHardness = 1.0f / width; - m_PSParams.ShadowOpacity = opacity; - m_PSConstantBufferIsStale = true; -} - -void TextContext::SetColor( Color c ) -{ - m_PSParams.TextColor = c; - m_PSConstantBufferIsStale = true; -} - -float TextContext::GetVerticalSpacing( void ) -{ - return m_LineHeight; -} - -void TextContext::Begin( bool EnableHDR ) -{ - ResetSettings(); - - m_HDR = (BOOL)EnableHDR; - - m_Context.SetRootSignature(TextRenderer::s_RootSignature); - m_Context.SetPipelineState(TextRenderer::s_ShadowPSO[m_HDR]); - m_Context.SetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); -} - -void TextContext::SetFont( const wstring& fontName, float size ) -{ - // If that font is already set or doesn't exist, return. - const TextRenderer::Font* NextFont = TextRenderer::GetOrLoadFont( fontName ); - if (NextFont == m_CurrentFont || NextFont == nullptr) - { - if (size > 0.0f) - SetTextSize(size); - - return; - } - - m_CurrentFont = NextFont; - - // Check to see if a new size was specified - if (size > 0.0f) - m_VSParams.TextSize = size; - - // Update constants directly tied to the font or the font size - m_LineHeight = NextFont->GetVerticalSpacing( m_VSParams.TextSize ); - m_VSParams.NormalizeX = m_CurrentFont->GetXNormalizationFactor(); - m_VSParams.NormalizeY = m_CurrentFont->GetYNormalizationFactor(); - m_VSParams.Scale = m_VSParams.TextSize / m_CurrentFont->GetHeight(); - m_VSParams.DstBorder = m_CurrentFont->GetBorderSize() * m_VSParams.Scale; - m_VSParams.SrcBorder = m_CurrentFont->GetBorderSize(); - m_PSParams.ShadowOffsetX = m_CurrentFont->GetHeight() * m_ShadowOffsetX * m_VSParams.NormalizeX; - m_PSParams.ShadowOffsetY = m_CurrentFont->GetHeight() * m_ShadowOffsetY * m_VSParams.NormalizeY; - m_PSParams.HeightRange = m_CurrentFont->GetAntialiasRange( m_VSParams.TextSize ); - m_VSConstantBufferIsStale = true; - m_PSConstantBufferIsStale = true; - m_TextureIsStale = true; -} - -void TextContext::SetTextSize( float size ) -{ - float fontScale = Display::GetDPIScale(); - - size *= fontScale; - - if (m_VSParams.TextSize == size) - return; - - m_VSParams.TextSize = size; - m_VSConstantBufferIsStale = true; - - if (m_CurrentFont != nullptr) - { - m_PSParams.HeightRange = m_CurrentFont->GetAntialiasRange( m_VSParams.TextSize ); - m_VSParams.Scale = m_VSParams.TextSize / m_CurrentFont->GetHeight(); - m_VSParams.DstBorder = m_CurrentFont->GetBorderSize() * m_VSParams.Scale; - m_PSConstantBufferIsStale = true; - m_LineHeight = m_CurrentFont->GetVerticalSpacing( size ); - } - else - m_LineHeight = 0.0f; -} - -void TextContext::SetViewSize( float ViewWidth, float ViewHeight ) -{ - m_ViewWidth = ViewWidth; - m_ViewHeight = ViewHeight; - - const float vpX = 0.0f; - const float vpY = 0.0f; - const float twoDivW = 2.0f / ViewWidth; - const float twoDivH = 2.0f / ViewHeight; - - // Essentially transform from screen coordinates to to clip space with W = 1. - m_VSParams.ViewportTransform = Vector4(twoDivW, -twoDivH, -vpX * twoDivW - 1.0f, vpY * twoDivH + 1.0f); - m_VSConstantBufferIsStale = true; -} - -void TextContext::End( void ) -{ - m_VSConstantBufferIsStale = true; - m_PSConstantBufferIsStale = true; - m_TextureIsStale = true; -} - -void TextContext::SetRenderState( void ) -{ - WARN_ONCE_IF(nullptr == m_CurrentFont, "Attempted to draw text without a font"); - - if (m_VSConstantBufferIsStale) - { - m_Context.SetDynamicConstantBufferView(0, sizeof(m_VSParams), &m_VSParams); - m_VSConstantBufferIsStale = false; - } - - if (m_PSConstantBufferIsStale) - { - m_Context.SetDynamicConstantBufferView(1, sizeof(m_PSParams), &m_PSParams); - m_PSConstantBufferIsStale = false; - } - - if (m_TextureIsStale) - { - m_Context.SetDynamicDescriptors(2, 0, 1, &m_CurrentFont->GetTexture().GetSRV()); - m_TextureIsStale = false; - } -} - -// These are made with templates to handle char and wchar_t simultaneously. -UINT TextContext::FillVertexBuffer( TextVert volatile* verts, const char* str, size_t stride, size_t slen ) -{ - UINT charsDrawn = 0; - - const float UVtoPixel = m_VSParams.Scale; - - float curX = m_TextPosX; - float curY = m_TextPosY; - - const uint16_t texelHeight = m_CurrentFont->GetHeight(); - - const char* iter = str; - for (size_t i = 0; i < slen; ++i) - { - wchar_t wc = (stride == 2 ? *(wchar_t*)iter : *iter); - iter += stride; - - // Terminate on null character (this really shouldn't happen with string or wstring) - if (wc == L'\0') - break; - - // Handle newlines by inserting a carriage return and line feed - if (wc == L'\n') - { - curX = m_LeftMargin; - curY += m_LineHeight; - continue; - } - - const TextRenderer::Font::Glyph* gi = m_CurrentFont->GetGlyph(wc); - - // Ignore missing characters - if (nullptr == gi) - continue; - - verts->X = curX + (float)gi->bearing * UVtoPixel; - verts->Y = curY; - verts->U = gi->x; - verts->V = gi->y; - verts->W = gi->w; - verts->H = texelHeight; - ++verts; - - // Advance the cursor position - curX += (float)gi->advance * UVtoPixel; - ++charsDrawn; - } - - m_TextPosX = curX; - m_TextPosY = curY; - - return charsDrawn; -} - -void TextContext::DrawString( const std::wstring& str ) -{ - SetRenderState(); - - void* stackMem = _malloca((str.size() + 1) * 16); - TextVert* vbPtr = Math::AlignUp((TextVert*)stackMem, 16); - UINT primCount = FillVertexBuffer(vbPtr, (char*)str.c_str(), 2, str.size()); - - if (primCount > 0) - { - m_Context.SetDynamicVB(0, primCount, sizeof(TextVert), vbPtr); - m_Context.DrawInstanced( 4, primCount ); - } - - _freea(stackMem); -} - -void TextContext::DrawString( const std::string& str ) -{ - SetRenderState(); - - void* stackMem = _malloca((str.size() + 1) * 16); - TextVert* vbPtr = Math::AlignUp((TextVert*)stackMem, 16); - UINT primCount = FillVertexBuffer(vbPtr, (char*)str.c_str(), 1, str.size()); - - if (primCount > 0) - { - m_Context.SetDynamicVB(0, primCount, sizeof(TextVert), vbPtr); - m_Context.DrawInstanced( 4, primCount ); - } - - _freea(stackMem); -} - -void TextContext::DrawFormattedString( const wchar_t* format, ... ) -{ - wchar_t buffer[256]; - va_list ap; - va_start(ap, format); - vswprintf( buffer, 256, format, ap ); - va_end(ap); - DrawString( wstring(buffer) ); -} - -void TextContext::DrawFormattedString( const char* format, ... ) -{ - char buffer[256]; - va_list ap; - va_start(ap, format); - vsprintf_s( buffer, 256, format, ap ); - va_end(ap); - DrawString( string(buffer) ); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/TextRenderer.h b/xess/samples/xess_demo/MiniEngine/Core/TextRenderer.h deleted file mode 100644 index 39d0fb4..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/TextRenderer.h +++ /dev/null @@ -1,151 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "Color.h" -#include "Math/Vector.h" -#include - -class Color; -class GraphicsContext; - -namespace TextRenderer -{ - // Initialize the text renderer's resources and designate the dimensions of the drawable - // view space. These dimensions do not have to match the actual pixel width and height of - // the viewport. Instead they create a coordinate space for placing text within the - // viewport. For instance, if you specify a ViewWidth of 2.0f, then CursorX = 1.0f marks - // the middle of the viewport. - void Initialize( void ); - void Shutdown( void ); - - class Font; -} - -class TextContext -{ -public: - TextContext( GraphicsContext& CmdContext, float CanvasWidth = 1920.0f, float CanvasHeight = 1080.0f ); - - GraphicsContext& GetCommandContext() const { return m_Context; } - - // Put settings back to the defaults. - void ResetSettings( void ); - - // - // Control various text properties - // - - // Choose a font from the Fonts folder. Previously loaded fonts are cached in memory. - void SetFont( const std::wstring& fontName, float TextSize = 0.0f ); - - // Resize the view space. This determines the coordinate space of the cursor position and font size. You can always - // set the view size to the same dimensions regardless of actual display resolution. It is assumed, however, that the - // aspect ratio of this virtual coordinate system matches the actual display aspect ratio. - void SetViewSize( float ViewWidth, float ViewHeight ); - - // Set the size of the text relative to the ViewHeight. The aspect of the text is preserved from - // the TTF as long as the aspect ratio of the view space is the same as the actual viewport. - void SetTextSize( float PixelHeight ); - - // Move the cursor position--the upper-left anchor for the text. - void ResetCursor( float x, float y ); - void SetLeftMargin( float x ); - void SetCursorX( float x ); - void SetCursorY( float y ); - void NewLine( void ); - float GetLeftMargin( void ); - float GetCursorX( void ); - float GetCursorY( void ); - - // Turn on or off drop shadow. - void EnableDropShadow( bool enable ); - - // Adjust shadow parameters. - void SetShadowOffset( float xPercent, float yPercent ); - void SetShadowParams( float opacity, float width ); - - // Set the color and transparency of text. - void SetColor( Color color ); - - // Get the amount to advance the Y position to begin a new line - float GetVerticalSpacing( void ); - - // - // Rendering commands - // - - // Begin and end drawing commands - void Begin( bool EnableHDR = false ); - void End( void ); - - // Draw a string - void DrawString( const std::wstring& str ); - void DrawString( const std::string& str ); - - // A more powerful function which formats text like printf(). Very slow by comparison, so use it - // only if you're going to format text anyway. - void DrawFormattedString( const wchar_t* format, ... ); - void DrawFormattedString( const char* format, ... ); - -private: - - __declspec(align(16)) struct VertexShaderParams - { - Math::Vector4 ViewportTransform; - float NormalizeX, NormalizeY, TextSize; - float Scale, DstBorder; - uint32_t SrcBorder; - }; - - __declspec(align(16)) struct PixelShaderParams - { - Color TextColor; - float ShadowOffsetX, ShadowOffsetY; - float ShadowHardness; // More than 1 will cause aliasing - float ShadowOpacity; // Should make less opaque when making softer - float HeightRange; - }; - - void SetRenderState(void); - - // 16 Byte structure to represent an entire glyph in the text vertex buffer - __declspec(align(16)) struct TextVert - { - float X, Y; // Upper-left glyph position in screen space - uint16_t U, V, W, H; // Upper-left glyph UV and the width in texture space - }; - - UINT FillVertexBuffer( TextVert volatile* verts, const char* str, size_t stride, size_t slen ); - void DrawStringInternal( const std::string& str ); - void DrawStringInternal( const std::wstring& str ); - - GraphicsContext& m_Context; - const TextRenderer::Font* m_CurrentFont; - VertexShaderParams m_VSParams; - PixelShaderParams m_PSParams; - bool m_VSConstantBufferIsStale; // Tracks when the CB needs updating - bool m_PSConstantBufferIsStale; // Tracks when the CB needs updating - bool m_TextureIsStale; - bool m_EnableShadow; - float m_LeftMargin; - float m_TextPosX; - float m_TextPosY; - float m_LineHeight; - float m_ViewWidth; // Width of the drawable area - float m_ViewHeight; // Height of the drawable area - float m_ShadowOffsetX; // Percentage of the font's TextSize should the shadow be offset - float m_ShadowOffsetY; // Percentage of the font's TextSize should the shadow be offset - BOOL m_HDR; -}; diff --git a/xess/samples/xess_demo/MiniEngine/Core/Texture.cpp b/xess/samples/xess_demo/MiniEngine/Core/Texture.cpp deleted file mode 100644 index b66d861..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Texture.cpp +++ /dev/null @@ -1,215 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// - -#include "pch.h" -#include "Texture.h" -#include "DDSTextureLoader.h" -#include "FileUtility.h" -#include "GraphicsCore.h" -#include "CommandContext.h" -#include -#include - -using namespace std; -using namespace Graphics; - -//-------------------------------------------------------------------------------------- -// Return the BPP for a particular format -//-------------------------------------------------------------------------------------- -size_t BitsPerPixel( _In_ DXGI_FORMAT fmt ); - -static UINT BytesPerPixel( DXGI_FORMAT Format ) -{ - return (UINT)BitsPerPixel(Format) / 8; -}; - -void Texture::Create2D( size_t RowPitchBytes, size_t Width, size_t Height, DXGI_FORMAT Format, const void* InitialData ) -{ - Destroy(); - - m_UsageState = D3D12_RESOURCE_STATE_COPY_DEST; - - m_Width = (uint32_t)Width; - m_Height = (uint32_t)Height; - m_Depth = 1; - - D3D12_RESOURCE_DESC texDesc = {}; - texDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; - texDesc.Width = Width; - texDesc.Height = (UINT)Height; - texDesc.DepthOrArraySize = 1; - texDesc.MipLevels = 1; - texDesc.Format = Format; - texDesc.SampleDesc.Count = 1; - texDesc.SampleDesc.Quality = 0; - texDesc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN; - texDesc.Flags = D3D12_RESOURCE_FLAG_NONE; - - D3D12_HEAP_PROPERTIES HeapProps; - HeapProps.Type = D3D12_HEAP_TYPE_DEFAULT; - HeapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; - HeapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; - HeapProps.CreationNodeMask = 1; - HeapProps.VisibleNodeMask = 1; - - ASSERT_SUCCEEDED(g_Device->CreateCommittedResource(&HeapProps, D3D12_HEAP_FLAG_NONE, &texDesc, - m_UsageState, nullptr, MY_IID_PPV_ARGS(m_pResource.ReleaseAndGetAddressOf()))); - - m_pResource->SetName(L"Texture"); - - D3D12_SUBRESOURCE_DATA texResource; - texResource.pData = InitialData; - texResource.RowPitch = RowPitchBytes; - texResource.SlicePitch = RowPitchBytes * Height; - - CommandContext::InitializeTexture(*this, 1, &texResource); - - if (m_hCpuDescriptorHandle.ptr == D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN) - m_hCpuDescriptorHandle = AllocateDescriptor(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - g_Device->CreateShaderResourceView(m_pResource.Get(), nullptr, m_hCpuDescriptorHandle); -} - -void Texture::CreateCube( size_t RowPitchBytes, size_t Width, size_t Height, DXGI_FORMAT Format, const void* InitialData ) -{ - Destroy(); - - m_UsageState = D3D12_RESOURCE_STATE_COPY_DEST; - - m_Width = (uint32_t)Width; - m_Height = (uint32_t)Height; - m_Depth = 6; - - D3D12_RESOURCE_DESC texDesc = {}; - texDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; - texDesc.Width = Width; - texDesc.Height = (UINT)Height; - texDesc.DepthOrArraySize = 6; - texDesc.MipLevels = 1; - texDesc.Format = Format; - texDesc.SampleDesc.Count = 1; - texDesc.SampleDesc.Quality = 0; - texDesc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN; - texDesc.Flags = D3D12_RESOURCE_FLAG_NONE; - - D3D12_HEAP_PROPERTIES HeapProps; - HeapProps.Type = D3D12_HEAP_TYPE_DEFAULT; - HeapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; - HeapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; - HeapProps.CreationNodeMask = 1; - HeapProps.VisibleNodeMask = 1; - - ASSERT_SUCCEEDED(g_Device->CreateCommittedResource(&HeapProps, D3D12_HEAP_FLAG_NONE, &texDesc, - m_UsageState, nullptr, MY_IID_PPV_ARGS(m_pResource.ReleaseAndGetAddressOf()))); - - m_pResource->SetName(L"Texture"); - - D3D12_SUBRESOURCE_DATA texResource; - texResource.pData = InitialData; - texResource.RowPitch = RowPitchBytes; - texResource.SlicePitch = texResource.RowPitch * Height; - - CommandContext::InitializeTexture(*this, 1, &texResource); - - if (m_hCpuDescriptorHandle.ptr == D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN) - m_hCpuDescriptorHandle = AllocateDescriptor(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - - D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc; - srvDesc.Format = Format; - srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; - srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBE; - srvDesc.TextureCube.MipLevels = 1; - srvDesc.TextureCube.MostDetailedMip = 0; - srvDesc.TextureCube.ResourceMinLODClamp = 0.0f; - g_Device->CreateShaderResourceView(m_pResource.Get(), &srvDesc, m_hCpuDescriptorHandle); -} - - -void Texture::CreateTGAFromMemory( const void* _filePtr, size_t, bool sRGB ) -{ - const uint8_t* filePtr = (const uint8_t*)_filePtr; - - // Skip first two bytes - filePtr += 2; - - /*uint8_t imageTypeCode =*/ *filePtr++; - - // Ignore another 9 bytes - filePtr += 9; - - uint16_t imageWidth = *(uint16_t*)filePtr; - filePtr += sizeof(uint16_t); - uint16_t imageHeight = *(uint16_t*)filePtr; - filePtr += sizeof(uint16_t); - uint8_t bitCount = *filePtr++; - - // Ignore another byte - filePtr++; - - uint32_t* formattedData = new uint32_t[imageWidth * imageHeight]; - uint32_t* iter = formattedData; - - uint8_t numChannels = bitCount / 8; - uint32_t numBytes = imageWidth * imageHeight * numChannels; - - switch (numChannels) - { - default: - break; - case 3: - for (uint32_t byteIdx = 0; byteIdx < numBytes; byteIdx += 3) - { - *iter++ = 0xff000000 | filePtr[0] << 16 | filePtr[1] << 8 | filePtr[2]; - filePtr += 3; - } - break; - case 4: - for (uint32_t byteIdx = 0; byteIdx < numBytes; byteIdx += 4) - { - *iter++ = filePtr[3] << 24 | filePtr[0] << 16 | filePtr[1] << 8 | filePtr[2]; - filePtr += 4; - } - break; - } - - Create2D( 4 * imageWidth, imageWidth, imageHeight, sRGB ? DXGI_FORMAT_R8G8B8A8_UNORM_SRGB : DXGI_FORMAT_R8G8B8A8_UNORM, formattedData ); - - delete [] formattedData; -} - -bool Texture::CreateDDSFromMemory( const void* filePtr, size_t fileSize, bool sRGB ) -{ - if (m_hCpuDescriptorHandle.ptr == D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN) - m_hCpuDescriptorHandle = AllocateDescriptor(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - - HRESULT hr = CreateDDSTextureFromMemory( Graphics::g_Device, - (const uint8_t*)filePtr, fileSize, 0, sRGB, &m_pResource, m_hCpuDescriptorHandle ); - - return SUCCEEDED(hr); -} - -void Texture::CreatePIXImageFromMemory( const void* memBuffer, size_t fileSize ) -{ - struct Header - { - DXGI_FORMAT Format; - uint32_t Pitch; - uint32_t Width; - uint32_t Height; - }; - const Header& header = *(Header*)memBuffer; - - ASSERT(fileSize >= header.Pitch * BytesPerPixel(header.Format) * header.Height + sizeof(Header), - "Raw PIX image dump has an invalid file size"); - - Create2D(header.Pitch, header.Width, header.Height, header.Format, (uint8_t*)memBuffer + sizeof(Header)); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Texture.h b/xess/samples/xess_demo/MiniEngine/Core/Texture.h deleted file mode 100644 index cd40191..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Texture.h +++ /dev/null @@ -1,55 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// - -#pragma once - -#include "pch.h" -#include "GpuResource.h" - -class Texture : public GpuResource -{ - friend class CommandContext; - -public: - - Texture() { m_hCpuDescriptorHandle.ptr = D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN; } - Texture(D3D12_CPU_DESCRIPTOR_HANDLE Handle) : m_hCpuDescriptorHandle(Handle) {} - - // Create a 1-level textures - void Create2D(size_t RowPitchBytes, size_t Width, size_t Height, DXGI_FORMAT Format, const void* InitData ); - void CreateCube(size_t RowPitchBytes, size_t Width, size_t Height, DXGI_FORMAT Format, const void* InitialData); - - void CreateTGAFromMemory( const void* memBuffer, size_t fileSize, bool sRGB ); - bool CreateDDSFromMemory( const void* memBuffer, size_t fileSize, bool sRGB ); - void CreatePIXImageFromMemory( const void* memBuffer, size_t fileSize ); - - virtual void Destroy() override - { - GpuResource::Destroy(); - m_hCpuDescriptorHandle.ptr = D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN; - } - - const D3D12_CPU_DESCRIPTOR_HANDLE& GetSRV() const { return m_hCpuDescriptorHandle; } - - uint32_t GetWidth() const { return m_Width; } - uint32_t GetHeight() const { return m_Height; } - uint32_t GetDepth() const { return m_Depth; } - -protected: - - uint32_t m_Width; - uint32_t m_Height; - uint32_t m_Depth; - - D3D12_CPU_DESCRIPTOR_HANDLE m_hCpuDescriptorHandle; -}; diff --git a/xess/samples/xess_demo/MiniEngine/Core/TextureManager.cpp b/xess/samples/xess_demo/MiniEngine/Core/TextureManager.cpp deleted file mode 100644 index 19c0c93..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/TextureManager.cpp +++ /dev/null @@ -1,238 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// - -#include "pch.h" -#include "TextureManager.h" -#include "DDSTextureLoader.h" -#include "Texture.h" -#include "Utility.h" -#include "FileUtility.h" -#include "GraphicsCommon.h" -#include "CommandContext.h" -#include -#include - -using namespace std; -using namespace Graphics; -using Utility::ByteArray; - -// -// A ManagedTexture allows for multiple threads to request a Texture load of the same -// file. It also contains a reference count of the Texture so that it can be freed -// when it is no longer referenced. -// -// Raw ManagedTexture pointers are not exposed to clients. -// -class ManagedTexture : public Texture -{ - friend class TextureRef; - -public: - ManagedTexture( const wstring& FileName ); - - void WaitForLoad(void) const; - void CreateFromMemory(ByteArray memory, eDefaultTexture fallback, bool sRGB); - -private: - - bool IsValid(void) const { return m_IsValid; } - void Unload(); - - std::wstring m_MapKey; // For deleting from the map later - bool m_IsValid; - bool m_IsLoading; - size_t m_ReferenceCount; -}; - -namespace TextureManager -{ - wstring s_RootPath = L""; - map> s_TextureCache; - - void Initialize( const wstring& TextureLibRoot ) - { - s_RootPath = TextureLibRoot; - } - - void Shutdown( void ) - { - s_TextureCache.clear(); - } - - mutex s_Mutex; - - ManagedTexture* FindOrLoadTexture( const wstring& fileName, eDefaultTexture fallback, bool forceSRGB ) - { - ManagedTexture* tex = nullptr; - - { - lock_guard Guard(s_Mutex); - - wstring key = fileName; - if (forceSRGB) - key += L"_sRGB"; - - // Search for an existing managed texture - auto iter = s_TextureCache.find(key); - if (iter != s_TextureCache.end()) - { - // If a texture was already created make sure it has finished loading before - // returning a point to it. - tex = iter->second.get(); - tex->WaitForLoad(); - return tex; - } - else - { - // If it's not found, create a new managed texture and start loading it - tex = new ManagedTexture(key); - s_TextureCache[key].reset(tex); - } - } - - Utility::ByteArray ba = Utility::ReadFileSync( s_RootPath + fileName ); - tex->CreateFromMemory(ba, fallback, forceSRGB); - - // This was the first time it was requested, so indicate that the caller must read the file - return tex; - } - - void DestroyTexture(const wstring& key) - { - lock_guard Guard(s_Mutex); - - auto iter = s_TextureCache.find(key); - if (iter != s_TextureCache.end()) - s_TextureCache.erase(iter); - } - -} // namespace TextureManager - -ManagedTexture::ManagedTexture( const wstring& FileName ) - : m_MapKey(FileName), m_IsValid(false), m_IsLoading(true), m_ReferenceCount(0) -{ - m_hCpuDescriptorHandle.ptr = D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN; -} - -void ManagedTexture::CreateFromMemory(ByteArray ba, eDefaultTexture fallback, bool forceSRGB) -{ - if (ba->size() == 0) - { - m_hCpuDescriptorHandle = GetDefaultTexture(fallback); - } - else - { - // We probably have a texture to load, so let's allocate a new descriptor - m_hCpuDescriptorHandle = AllocateDescriptor(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - - if ( SUCCEEDED( CreateDDSTextureFromMemory( g_Device, (const uint8_t*)ba->data(), ba->size(), - 0, forceSRGB, m_pResource.GetAddressOf(), m_hCpuDescriptorHandle) ) ) - { - m_IsValid = true; - D3D12_RESOURCE_DESC desc = GetResource()->GetDesc(); - m_Width = (uint32_t)desc.Width; - m_Height = desc.Height; - m_Depth = desc.DepthOrArraySize; - } - else - { - g_Device->CopyDescriptorsSimple(1, m_hCpuDescriptorHandle, GetDefaultTexture(fallback), - D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - } - } - - m_IsLoading = false; -} - -void ManagedTexture::WaitForLoad( void ) const -{ - while ((volatile bool&)m_IsLoading) - this_thread::yield(); -} - -void ManagedTexture::Unload() -{ - TextureManager::DestroyTexture(m_MapKey); -} - -TextureRef::TextureRef( const TextureRef& ref ) : m_ref(ref.m_ref) -{ - if (m_ref != nullptr) - ++m_ref->m_ReferenceCount; -} - -TextureRef::TextureRef( ManagedTexture* tex ) : m_ref(tex) -{ - if (m_ref != nullptr) - ++m_ref->m_ReferenceCount; -} - -TextureRef::~TextureRef() -{ - if (m_ref != nullptr && --m_ref->m_ReferenceCount == 0) - m_ref->Unload(); -} - -void TextureRef::operator= (std::nullptr_t) -{ - if (m_ref != nullptr) - --m_ref->m_ReferenceCount; - - m_ref = nullptr; -} - -void TextureRef::operator= (TextureRef& rhs) -{ - if (m_ref != nullptr) - --m_ref->m_ReferenceCount; - - m_ref = rhs.m_ref; - - if (m_ref != nullptr) - ++m_ref->m_ReferenceCount; -} - -bool TextureRef::IsValid() const -{ - return m_ref && m_ref->IsValid(); -} - -const Texture* TextureRef::Get( void ) const -{ - return m_ref; -} - -const Texture* TextureRef::operator->( void ) const -{ - ASSERT(m_ref != nullptr); - return m_ref; -} - -D3D12_CPU_DESCRIPTOR_HANDLE TextureRef::GetSRV() const -{ - if (m_ref != nullptr) - return m_ref->GetSRV(); - else - return GetDefaultTexture(kMagenta2D); -} - - -TextureRef TextureManager::LoadDDSFromFile( const wstring& filePath, eDefaultTexture fallback, bool forceSRGB ) -{ - return FindOrLoadTexture(filePath, fallback, forceSRGB); -} - -TextureRef TextureManager::LoadDDSFromFile( const string& filePath, eDefaultTexture fallback, bool forceSRGB ) -{ - return LoadDDSFromFile(Utility::UTF8ToWideString(filePath), fallback, forceSRGB); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/TextureManager.h b/xess/samples/xess_demo/MiniEngine/Core/TextureManager.h deleted file mode 100644 index 40da346..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/TextureManager.h +++ /dev/null @@ -1,79 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// - -#pragma once - -#include "pch.h" -#include "GpuResource.h" -#include "Utility.h" -#include "Texture.h" -#include "GraphicsCommon.h" - -// A referenced-counted pointer to a Texture. See methods below. -class TextureRef; - -// -// Texture file loading system. -// -// References to textures are passed around so that a texture may be shared. When -// all references to a texture expire, the texture memory is reclaimed. -// -namespace TextureManager -{ - using Graphics::eDefaultTexture; - using Graphics::kMagenta2D; - - void Initialize( const std::wstring& RootPath ); - void Shutdown(void); - - // Load a texture from a DDS file. Never returns null references, but if a - // texture cannot be found, ref->IsValid() will return false. - TextureRef LoadDDSFromFile( const std::wstring& filePath, eDefaultTexture fallback = kMagenta2D, bool sRGB = false ); - TextureRef LoadDDSFromFile( const std::string& filePath, eDefaultTexture fallback = kMagenta2D, bool sRGB = false ); -} - -// Forward declaration; private implementation -class ManagedTexture; - -// -// A handle to a ManagedTexture. Constructors and destructors modify the reference -// count. When the last reference is destroyed, the TextureManager is informed that -// the texture should be deleted. -// -class TextureRef -{ -public: - - TextureRef( const TextureRef& ref ); - TextureRef( ManagedTexture* tex = nullptr ); - ~TextureRef(); - - void operator= (std::nullptr_t); - void operator= (TextureRef& rhs); - - // Check that this points to a valid texture (which loaded successfully) - bool IsValid() const; - - // Gets the SRV descriptor handle. If the reference is invalid, - // returns a valid descriptor handle (specified by the fallback) - D3D12_CPU_DESCRIPTOR_HANDLE GetSRV() const; - - // Get the texture pointer. Client is responsible to not dereference - // null pointers. - const Texture* Get( void ) const; - - const Texture* operator->( void ) const; - -private: - ManagedTexture* m_ref; -}; diff --git a/xess/samples/xess_demo/MiniEngine/Core/UploadBuffer.cpp b/xess/samples/xess_demo/MiniEngine/Core/UploadBuffer.cpp deleted file mode 100644 index d94fb15..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/UploadBuffer.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "UploadBuffer.h" -#include "GraphicsCore.h" - -using namespace Graphics; - -void UploadBuffer::Create( const std::wstring& name, size_t BufferSize ) -{ - Destroy(); - - m_BufferSize = BufferSize; - - // Create an upload buffer. This is CPU-visible, but it's write combined memory, so - // avoid reading back from it. - D3D12_HEAP_PROPERTIES HeapProps; - HeapProps.Type = D3D12_HEAP_TYPE_UPLOAD; - HeapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; - HeapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; - HeapProps.CreationNodeMask = 1; - HeapProps.VisibleNodeMask = 1; - - // Upload buffers must be 1-dimensional - D3D12_RESOURCE_DESC ResourceDesc = {}; - ResourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; - ResourceDesc.Width = m_BufferSize; - ResourceDesc.Height = 1; - ResourceDesc.DepthOrArraySize = 1; - ResourceDesc.MipLevels = 1; - ResourceDesc.Format = DXGI_FORMAT_UNKNOWN; - ResourceDesc.SampleDesc.Count = 1; - ResourceDesc.SampleDesc.Quality = 0; - ResourceDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; - ResourceDesc.Flags = D3D12_RESOURCE_FLAG_NONE; - - ASSERT_SUCCEEDED( g_Device->CreateCommittedResource(&HeapProps, D3D12_HEAP_FLAG_NONE, &ResourceDesc, - D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, MY_IID_PPV_ARGS(&m_pResource)) ); - - m_GpuVirtualAddress = m_pResource->GetGPUVirtualAddress(); - -#ifdef RELEASE - (name); -#else - m_pResource->SetName(name.c_str()); -#endif -} - - -void* UploadBuffer::Map(void) -{ - void* Memory; - m_pResource->Map(0, &CD3DX12_RANGE(0, m_BufferSize), &Memory); - return Memory; -} - -void UploadBuffer::Unmap(size_t begin, size_t end) -{ - m_pResource->Unmap(0, &CD3DX12_RANGE(begin, std::min(end, m_BufferSize))); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/UploadBuffer.h b/xess/samples/xess_demo/MiniEngine/Core/UploadBuffer.h deleted file mode 100644 index 40969a7..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/UploadBuffer.h +++ /dev/null @@ -1,38 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// -// Description: An upload buffer is visible to both the CPU and the GPU, but -// because the memory is write combined, you should avoid reading data with the CPU. -// An upload buffer is intended for moving data to a default GPU buffer. You can -// read from a file directly into an upload buffer, rather than reading into regular -// cached memory, copying that to an upload buffer, and copying that to the GPU. - -#pragma once - -#include "GpuResource.h" - -class UploadBuffer : public GpuResource -{ -public: - virtual ~UploadBuffer() { Destroy(); } - - void Create( const std::wstring& name, size_t BufferSize ); - - void* Map(void); - void Unmap(size_t begin = 0, size_t end = -1); - - size_t GetBufferSize() const { return m_BufferSize; } - -protected: - - size_t m_BufferSize; -}; diff --git a/xess/samples/xess_demo/MiniEngine/Core/Util/CommandLineArg.cpp b/xess/samples/xess_demo/MiniEngine/Core/Util/CommandLineArg.cpp deleted file mode 100644 index b233de7..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Util/CommandLineArg.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: Jack Elliott -// - -#include "pch.h" -#include -#include -#include - -namespace CommandLineArgs -{ - std::unordered_map m_argumentMap; - - template - void GatherArgs(size_t numArgs, const GetStringFunc& pfnGet) - { - // the first arg is always the exe name and we are looing for key/value pairs - if (numArgs > 1) - { - size_t i = 0; - - while (i < numArgs) - { - const wchar_t* key = pfnGet(i); - i++; - if (i < numArgs && key[0] == '-') - { - const wchar_t* strippedKey = key + 1; - m_argumentMap[strippedKey] = pfnGet(i); - i++; - } - } - } - } - - void Initialize(int argc, wchar_t ** argv) - { - GatherArgs(size_t(argc), [argv](size_t i) -> const wchar_t* { return argv[i]; }); - } - - template - bool Lookup(const wchar_t* key, const FunctionType& pfnFunction) - { - const auto found = m_argumentMap.find(key); - if (found != m_argumentMap.end()) - { - pfnFunction(found->second); - return true; - } - - return false; - } - - bool GetInteger(const wchar_t* key, uint32_t& value) - { - return Lookup(key, [&value](std::wstring& val) - { - value = std::stoi(val); - }); - } - - bool GetFloat(const wchar_t* key, float& value) - { - return Lookup(key, [&value](std::wstring& val) - { - value = (float)_wtof(val.c_str()); - }); - } - - bool GetString(const wchar_t* key, std::wstring& value) - { - return Lookup(key, [&value](std::wstring& val) - { - value = val; - }); - } -} \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Core/Util/CommandLineArg.h b/xess/samples/xess_demo/MiniEngine/Core/Util/CommandLineArg.h deleted file mode 100644 index 023fb2b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Util/CommandLineArg.h +++ /dev/null @@ -1,22 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: Jack Elliott -// - -#pragma once - -namespace CommandLineArgs -{ - void Initialize(int argc, wchar_t** argv); - bool GetInteger(const wchar_t* key, uint32_t& value); - bool GetFloat(const wchar_t* key, float& value); - bool GetString(const wchar_t* key, std::wstring& value); -} \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Core/Utility.cpp b/xess/samples/xess_demo/MiniEngine/Core/Utility.cpp deleted file mode 100644 index 82405a2..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Utility.cpp +++ /dev/null @@ -1,311 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "pch.h" -#include "Utility.h" -#include -#include - -// A faster version of memcopy that uses SSE instructions. TODO: Write an ARM variant if necessary. -void SIMDMemCopy( void* __restrict _Dest, const void* __restrict _Source, size_t NumQuadwords ) -{ - ASSERT(Math::IsAligned(_Dest, 16)); - ASSERT(Math::IsAligned(_Source, 16)); - - __m128i* __restrict Dest = (__m128i* __restrict)_Dest; - const __m128i* __restrict Source = (const __m128i* __restrict)_Source; - - // Discover how many quadwords precede a cache line boundary. Copy them separately. - size_t InitialQuadwordCount = (4 - ((size_t)Source >> 4) & 3) & 3; - if (InitialQuadwordCount > NumQuadwords) - InitialQuadwordCount = NumQuadwords; - - switch (InitialQuadwordCount) - { - case 3: _mm_stream_si128(Dest + 2, _mm_load_si128(Source + 2)); // Fall through - case 2: _mm_stream_si128(Dest + 1, _mm_load_si128(Source + 1)); // Fall through - case 1: _mm_stream_si128(Dest + 0, _mm_load_si128(Source + 0)); // Fall through - default: - break; - } - - if (NumQuadwords == InitialQuadwordCount) - return; - - Dest += InitialQuadwordCount; - Source += InitialQuadwordCount; - NumQuadwords -= InitialQuadwordCount; - - size_t CacheLines = NumQuadwords >> 2; - - switch (CacheLines) - { - default: - case 10: _mm_prefetch((char*)(Source + 36), _MM_HINT_NTA); // Fall through - case 9: _mm_prefetch((char*)(Source + 32), _MM_HINT_NTA); // Fall through - case 8: _mm_prefetch((char*)(Source + 28), _MM_HINT_NTA); // Fall through - case 7: _mm_prefetch((char*)(Source + 24), _MM_HINT_NTA); // Fall through - case 6: _mm_prefetch((char*)(Source + 20), _MM_HINT_NTA); // Fall through - case 5: _mm_prefetch((char*)(Source + 16), _MM_HINT_NTA); // Fall through - case 4: _mm_prefetch((char*)(Source + 12), _MM_HINT_NTA); // Fall through - case 3: _mm_prefetch((char*)(Source + 8 ), _MM_HINT_NTA); // Fall through - case 2: _mm_prefetch((char*)(Source + 4 ), _MM_HINT_NTA); // Fall through - case 1: _mm_prefetch((char*)(Source + 0 ), _MM_HINT_NTA); // Fall through - - // Do four quadwords per loop to minimize stalls. - for (size_t i = CacheLines; i > 0; --i) - { - // If this is a large copy, start prefetching future cache lines. This also prefetches the - // trailing quadwords that are not part of a whole cache line. - if (i >= 10) - _mm_prefetch((char*)(Source + 40), _MM_HINT_NTA); - - _mm_stream_si128(Dest + 0, _mm_load_si128(Source + 0)); - _mm_stream_si128(Dest + 1, _mm_load_si128(Source + 1)); - _mm_stream_si128(Dest + 2, _mm_load_si128(Source + 2)); - _mm_stream_si128(Dest + 3, _mm_load_si128(Source + 3)); - - Dest += 4; - Source += 4; - } - - case 0: // No whole cache lines to read - break; - } - - // Copy the remaining quadwords - switch (NumQuadwords & 3) - { - case 3: _mm_stream_si128(Dest + 2, _mm_load_si128(Source + 2)); // Fall through - case 2: _mm_stream_si128(Dest + 1, _mm_load_si128(Source + 1)); // Fall through - case 1: _mm_stream_si128(Dest + 0, _mm_load_si128(Source + 0)); // Fall through - default: - break; - } - - _mm_sfence(); -} - -void SIMDMemFill( void* __restrict _Dest, __m128 FillVector, size_t NumQuadwords ) -{ - ASSERT(Math::IsAligned(_Dest, 16)); - - register const __m128i Source = _mm_castps_si128(FillVector); - __m128i* __restrict Dest = (__m128i* __restrict)_Dest; - - switch (((size_t)Dest >> 4) & 3) - { - case 1: _mm_stream_si128(Dest++, Source); --NumQuadwords; // Fall through - case 2: _mm_stream_si128(Dest++, Source); --NumQuadwords; // Fall through - case 3: _mm_stream_si128(Dest++, Source); --NumQuadwords; // Fall through - default: - break; - } - - size_t WholeCacheLines = NumQuadwords >> 2; - - // Do four quadwords per loop to minimize stalls. - while (WholeCacheLines--) - { - _mm_stream_si128(Dest++, Source); - _mm_stream_si128(Dest++, Source); - _mm_stream_si128(Dest++, Source); - _mm_stream_si128(Dest++, Source); - } - - // Copy the remaining quadwords - switch (NumQuadwords & 3) - { - case 3: _mm_stream_si128(Dest++, Source); // Fall through - case 2: _mm_stream_si128(Dest++, Source); // Fall through - case 1: _mm_stream_si128(Dest++, Source); // Fall through - default: - break; - } - - _mm_sfence(); -} - -std::wstring Utility::AnsiToWideString(const std::string& str) -{ - if (!str.length()) - return L""; - - int ansiLength = static_cast(str.length()); - int wideLength = MultiByteToWideChar(CP_ACP, 0, str.c_str(), ansiLength, nullptr, 0); - - std::unique_ptr ptr(new wchar_t[wideLength]); - MultiByteToWideChar(CP_ACP, 0, str.c_str(), ansiLength, ptr.get(), wideLength); - - return std::wstring(ptr.get(), wideLength); -} - -std::string Utility::WideStringToAnsi(const std::wstring& wstr) -{ - if (!wstr.length()) - return ""; - - int wideLength = static_cast(wstr.length()); - int ansiLength = WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), wideLength, nullptr, 0, nullptr, nullptr); - - std::unique_ptr ptr(new char[ansiLength]); - WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), wideLength, ptr.get(), ansiLength, nullptr, nullptr); - - return std::string(ptr.get(), ansiLength); -} - -std::wstring Utility::UTF8ToWideString( const std::string& str ) -{ - if (!str.length()) - return L""; - - int ansiLength = static_cast(str.length()); - int wideLength = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), ansiLength, nullptr, 0); - - std::unique_ptr ptr(new wchar_t[wideLength]); - MultiByteToWideChar(CP_UTF8, 0, str.c_str(), ansiLength, ptr.get(), wideLength); - - return std::wstring(ptr.get(), wideLength); -} - -std::string Utility::WideStringToUTF8( const std::wstring& wstr ) -{ - if (!wstr.length()) - return ""; - - int wideLength = static_cast(wstr.length()); - int ansiLength = WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), wideLength, nullptr, 0, nullptr, nullptr); - - std::unique_ptr ptr(new char[ansiLength]); - WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), wideLength, ptr.get(), ansiLength, nullptr, nullptr); - - return std::string(ptr.get(), ansiLength); -} - -std::string Utility::ToLower(const std::string& str) -{ - std::string lower_case = str; - std::locale loc; - for (char& s : lower_case) - s = std::tolower(s, loc); - return lower_case; -} - -std::wstring Utility::ToLower(const std::wstring& str) -{ - std::wstring lower_case = str; - std::locale loc; - for (wchar_t& s : lower_case) - s = std::tolower(s, loc); - return lower_case; -} - -std::string Utility::GetBasePath(const std::string& filePath) -{ - size_t lastSlash; - if ((lastSlash = filePath.rfind('/')) != std::string::npos) - return filePath.substr(0, lastSlash + 1); - else if ((lastSlash = filePath.rfind('\\')) != std::string::npos) - return filePath.substr(0, lastSlash + 1); - else - return ""; -} - -std::wstring Utility::GetBasePath(const std::wstring& filePath) -{ - size_t lastSlash; - if ((lastSlash = filePath.rfind(L'/')) != std::wstring::npos) - return filePath.substr(0, lastSlash + 1); - else if ((lastSlash = filePath.rfind(L'\\')) != std::wstring::npos) - return filePath.substr(0, lastSlash + 1); - else - return L""; -} - -std::string Utility::RemoveBasePath(const std::string& filePath) -{ - size_t lastSlash; - if ((lastSlash = filePath.rfind('/')) != std::string::npos) - return filePath.substr(lastSlash + 1, std::string::npos); - else if ((lastSlash = filePath.rfind('\\')) != std::string::npos) - return filePath.substr(lastSlash + 1, std::string::npos); - else - return filePath; -} - -std::wstring Utility::RemoveBasePath(const std::wstring& filePath) -{ - size_t lastSlash; - if ((lastSlash = filePath.rfind(L'/')) != std::string::npos) - return filePath.substr(lastSlash + 1, std::string::npos); - else if ((lastSlash = filePath.rfind(L'\\')) != std::string::npos) - return filePath.substr(lastSlash + 1, std::string::npos); - else - return filePath; -} - -std::string Utility::GetFileExtension(const std::string& filePath) -{ - std::string fileName = RemoveBasePath(filePath); - size_t extOffset = fileName.rfind('.'); - if (extOffset == std::wstring::npos) - return ""; - - return fileName.substr(extOffset + 1); -} - -std::wstring Utility::GetFileExtension(const std::wstring& filePath) -{ - std::wstring fileName = RemoveBasePath(filePath); - size_t extOffset = fileName.rfind(L'.'); - if (extOffset == std::wstring::npos) - return L""; - - return fileName.substr(extOffset + 1); -} - -std::string Utility::RemoveExtension(const std::string& filePath) -{ - return filePath.substr(0, filePath.rfind(".")); -} - -std::wstring Utility::GetProgramDirectory() -{ - wchar_t modulePath[MAX_PATH]; - modulePath[0] = 0; - GetModuleFileNameW(nullptr, modulePath, MAX_PATH); - return GetBasePath(modulePath); -} - -std::wstring Utility::GetWorkingDirectory() -{ - TCHAR currentDir[MAX_PATH]; - GetCurrentDirectory(MAX_PATH, currentDir); - - return currentDir; -} - -void Utility::SetWorkingDirectory(const std::wstring& dir) -{ - SetCurrentDirectory(dir.c_str()); -} - -uint32_t Utility::GetThreadId() -{ - return ::GetCurrentThreadId(); -} - -std::wstring Utility::RemoveExtension(const std::wstring& filePath) -{ - return filePath.substr(0, filePath.rfind(L".")); -} diff --git a/xess/samples/xess_demo/MiniEngine/Core/Utility.h b/xess/samples/xess_demo/MiniEngine/Core/Utility.h deleted file mode 100644 index 0565f30..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/Utility.h +++ /dev/null @@ -1,191 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "pch.h" - -namespace Utility -{ -#ifdef _CONSOLE - inline void Print( const char* msg ) { printf("%s", msg); } - inline void Print( const wchar_t* msg ) { wprintf(L"%ws", msg); } -#else - inline void Print( const char* msg ) { OutputDebugStringA(msg); } - inline void Print( const wchar_t* msg ) { OutputDebugString(msg); } -#endif - - inline void Printf( const char* format, ... ) - { - char buffer[256]; - va_list ap; - va_start(ap, format); - vsprintf_s(buffer, 256, format, ap); - va_end(ap); - Print(buffer); - } - - inline void Printf( const wchar_t* format, ... ) - { - wchar_t buffer[256]; - va_list ap; - va_start(ap, format); - vswprintf(buffer, 256, format, ap); - va_end(ap); - Print(buffer); - } - -#ifndef RELEASE - inline void PrintSubMessage( const char* format, ... ) - { - Print("--> "); - char buffer[256]; - va_list ap; - va_start(ap, format); - vsprintf_s(buffer, 256, format, ap); - va_end(ap); - Print(buffer); - Print("\n"); - } - inline void PrintSubMessage( const wchar_t* format, ... ) - { - Print("--> "); - wchar_t buffer[256]; - va_list ap; - va_start(ap, format); - vswprintf(buffer, 256, format, ap); - va_end(ap); - Print(buffer); - Print("\n"); - } - inline void PrintSubMessage( void ) - { - } -#endif - - std::wstring AnsiToWideString(const std::string& str); - std::string WideStringToAnsi(const std::wstring& wstr); - std::wstring UTF8ToWideString( const std::string& str ); - std::string WideStringToUTF8( const std::wstring& wstr ); - std::string ToLower(const std::string& str); - std::wstring ToLower(const std::wstring& str); - std::string GetBasePath(const std::string& str); - std::wstring GetBasePath(const std::wstring& str); - std::string RemoveBasePath(const std::string& str); - std::wstring RemoveBasePath(const std::wstring& str); - std::string GetFileExtension(const std::string& str); - std::wstring GetFileExtension(const std::wstring& str); - std::string RemoveExtension(const std::string& str); - std::wstring RemoveExtension(const std::wstring& str); - std::wstring GetProgramDirectory(); - std::wstring GetWorkingDirectory(); - void SetWorkingDirectory(const std::wstring& dir); - uint32_t GetThreadId(); -} // namespace Utility - -#ifdef ERROR -#undef ERROR -#endif -#ifdef ASSERT -#undef ASSERT -#endif -#ifdef HALT -#undef HALT -#endif - -#define HALT( ... ) ERROR( __VA_ARGS__ ) __debugbreak(); - -#ifdef RELEASE - - #define ASSERT( isTrue, ... ) (void)(isTrue) - #define WARN_ONCE_IF( isTrue, ... ) (void)(isTrue) - #define WARN_ONCE_IF_NOT( isTrue, ... ) (void)(isTrue) - #define ERROR( msg, ... ) - #define DEBUGPRINT( msg, ... ) do {} while(0) - #define ASSERT_SUCCEEDED( hr, ... ) (void)(hr) - -#else // !RELEASE - - inline void LOG_ERROR_SUB(const char* format, ...) - { - char buffer[256]; - va_list ap; - va_start(ap, format); - vsprintf_s(buffer, 256, format, ap); - va_end(ap); - LOG_ERRORF("--> %s", buffer); - } - - inline void LOG_ERROR_SUB() - { - } - - inline void LOG_WARN_SUB(const char* format, ...) - { - char buffer[256]; - va_list ap; - va_start(ap, format); - vsprintf_s(buffer, 256, format, ap); - va_end(ap); - LOG_WARNF("--> %s", buffer); - } - - inline void LOG_WARN_SUB() - { - } - - #define STRINGIFY(x) #x - #define STRINGIFY_BUILTIN(x) STRINGIFY(x) - #define ASSERT( isFalse, ... ) \ - if (!(bool)(isFalse)) { \ - Utility::Print(__FILE__ "(" STRINGIFY_BUILTIN(__LINE__) ")\n"); \ - LOG_ERROR("Assertion failed in " STRINGIFY_BUILTIN(__FILE__) " @ " STRINGIFY_BUILTIN(__LINE__)); \ - LOG_ERROR("--> \'" #isFalse "\' is false"); \ - LOG_ERROR_SUB(__VA_ARGS__); \ - __debugbreak(); \ - } - - #define ASSERT_SUCCEEDED( hr, ... ) \ - if (FAILED(hr)) { \ - Utility::Print(__FILE__ "(" STRINGIFY_BUILTIN(__LINE__) ")\n"); \ - LOG_ERROR("HRESULT failed in " STRINGIFY_BUILTIN(__FILE__) " @ " STRINGIFY_BUILTIN(__LINE__)); \ - LOG_ERRORF("--> hr = 0x%08X", hr); \ - LOG_ERROR_SUB(__VA_ARGS__); \ - __debugbreak(); \ - } - - #define WARN_ONCE_IF( isTrue, ... ) \ - { \ - static bool s_TriggeredWarning = false; \ - if ((bool)(isTrue) && !s_TriggeredWarning) { \ - s_TriggeredWarning = true; \ - Utility::Print(__FILE__ "(" STRINGIFY_BUILTIN(__LINE__) ")\n"); \ - LOG_WARN("Warning issued in " STRINGIFY_BUILTIN(__FILE__) " @ " STRINGIFY_BUILTIN(__LINE__)); \ - LOG_WARN("\'" #isTrue "\' is true"); \ - LOG_WARN_SUB(__VA_ARGS__); \ - } \ - } - - #define WARN_ONCE_IF_NOT( isTrue, ... ) WARN_ONCE_IF(!(isTrue), __VA_ARGS__) - - #define ERROR( ... ) \ - Utility::Print(__FILE__ "(" STRINGIFY_BUILTIN(__LINE__) ")\n"); \ - LOG_ERROR("Error reported in " STRINGIFY_BUILTIN(__FILE__) " @ " STRINGIFY_BUILTIN(__LINE__)); \ - LOG_ERROR_SUB(__VA_ARGS__); - -#endif - -#define BreakIfFailed( hr ) if (FAILED(hr)) __debugbreak() - -void SIMDMemCopy( void* __restrict Dest, const void* __restrict Source, size_t NumQuadwords ); -void SIMDMemFill( void* __restrict Dest, __m128 FillVector, size_t NumQuadwords ); diff --git a/xess/samples/xess_demo/MiniEngine/Core/VectorMath.h b/xess/samples/xess_demo/MiniEngine/Core/VectorMath.h deleted file mode 100644 index e0d59af..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/VectorMath.h +++ /dev/null @@ -1,60 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// -// This is a system of classes that wrap DirectXMath in a more object-oriented and concise (readable) way. While these -// classes are not designed to maximize throughput on the instruction level, they are designed to be easily understood. -// I believe that the source of most math library inefficiency is in their being too confusing and not making the preferred -// way of doing things obvious. This leaves programmers constantly finding usage patterns that "work for them" but are -// ultimately inefficient and don't use the API the "way it was intended". The goal of this wrapper is to be cogent and -// familiar. -// -// Note that DirectXMath treats vectors like [1x4] matrices (rows) rather than [4x1] matrices (columns). Likewise, it -// treats matrices like they are transposed, so that you would multiply a vector and a matrix like so: -// -// Vector [1x4] = Vector [1x4] * Matrix [4x4] -// -// Applying multiple transforms to a vector involves concatenating on the outside, or right of the previous transform: -// -// ProjectedPosition = ModelPosition * ModelToWorld * WorldToView * ViewToProj -// -// This is *not* how this API works because it is needlessly contrary to Math textbooks. It's not "wrong", per se, -// but it's a paradigm I'd like to see changed. A vector is four floats. A matrix is four consecutive vectors. Whether -// you think of them as row or column vectors of a matrix is just a matter of perspective. In this library, you will see: -// -// Vector [4x1] = Matrix4 [4x4] * Vector [4x1] -// -// and -// -// ProjectedPosition = ViewToProj * WorldToView * ModelToWorld * ModelPosition -// -// One very happy result of this is that you can stop transposing every matrix you set in a shader constant buffer. They -// were always in the right format, you were just multiplying them backwards. In the shader you should have been calling -// mul( matrix, vector ) rather than mul( vector, matrix ). Then you wouldn't have needed to transpose the matrix. -// -// It's possible to work in a transposed space: (B*A*x)ᵀ = xᵀ*Aᵀ*Bᵀ but why would you want to? -// -// Oh, and we use right-handed coordinate systems because that's what you learned in your Linear Algebra, Calculus, and -// Physics classes. -// -// Peace, -// James - - -#pragma once - -#include "Math/Scalar.h" -#include "Math/Vector.h" -#include "Math/Quaternion.h" -#include "Math/Matrix3.h" -#include "Math/Transform.h" -#include "Math/Matrix4.h" -#include "Math/Functions.inl" diff --git a/xess/samples/xess_demo/MiniEngine/Core/d3dx12.h b/xess/samples/xess_demo/MiniEngine/Core/d3dx12.h deleted file mode 100644 index f40e767..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/d3dx12.h +++ /dev/null @@ -1,4052 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -#ifndef __D3DX12_H__ -#define __D3DX12_H__ - -#include "d3d12.h" - -#if defined( __cplusplus ) - -struct CD3DX12_DEFAULT {}; -extern const DECLSPEC_SELECTANY CD3DX12_DEFAULT D3D12_DEFAULT; - -//------------------------------------------------------------------------------------------------ -inline bool operator==( const D3D12_VIEWPORT& l, const D3D12_VIEWPORT& r ) noexcept -{ - return l.TopLeftX == r.TopLeftX && l.TopLeftY == r.TopLeftY && l.Width == r.Width && - l.Height == r.Height && l.MinDepth == r.MinDepth && l.MaxDepth == r.MaxDepth; -} - -//------------------------------------------------------------------------------------------------ -inline bool operator!=( const D3D12_VIEWPORT& l, const D3D12_VIEWPORT& r ) noexcept -{ return !( l == r ); } - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_RECT : public D3D12_RECT -{ - CD3DX12_RECT() = default; - explicit CD3DX12_RECT( const D3D12_RECT& o ) noexcept : - D3D12_RECT( o ) - {} - explicit CD3DX12_RECT( - LONG Left, - LONG Top, - LONG Right, - LONG Bottom ) noexcept - { - left = Left; - top = Top; - right = Right; - bottom = Bottom; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_VIEWPORT : public D3D12_VIEWPORT -{ - CD3DX12_VIEWPORT() = default; - explicit CD3DX12_VIEWPORT( const D3D12_VIEWPORT& o ) noexcept : - D3D12_VIEWPORT( o ) - {} - explicit CD3DX12_VIEWPORT( - FLOAT topLeftX, - FLOAT topLeftY, - FLOAT width, - FLOAT height, - FLOAT minDepth = D3D12_MIN_DEPTH, - FLOAT maxDepth = D3D12_MAX_DEPTH ) noexcept - { - TopLeftX = topLeftX; - TopLeftY = topLeftY; - Width = width; - Height = height; - MinDepth = minDepth; - MaxDepth = maxDepth; - } - explicit CD3DX12_VIEWPORT( - _In_ ID3D12Resource* pResource, - UINT mipSlice = 0, - FLOAT topLeftX = 0.0f, - FLOAT topLeftY = 0.0f, - FLOAT minDepth = D3D12_MIN_DEPTH, - FLOAT maxDepth = D3D12_MAX_DEPTH ) noexcept - { - auto Desc = pResource->GetDesc(); - const UINT64 SubresourceWidth = Desc.Width >> mipSlice; - const UINT64 SubresourceHeight = Desc.Height >> mipSlice; - switch (Desc.Dimension) - { - case D3D12_RESOURCE_DIMENSION_BUFFER: - TopLeftX = topLeftX; - TopLeftY = 0.0f; - Width = float(Desc.Width) - topLeftX; - Height = 1.0f; - break; - case D3D12_RESOURCE_DIMENSION_TEXTURE1D: - TopLeftX = topLeftX; - TopLeftY = 0.0f; - Width = (SubresourceWidth ? float(SubresourceWidth) : 1.0f) - topLeftX; - Height = 1.0f; - break; - case D3D12_RESOURCE_DIMENSION_TEXTURE2D: - case D3D12_RESOURCE_DIMENSION_TEXTURE3D: - TopLeftX = topLeftX; - TopLeftY = topLeftY; - Width = (SubresourceWidth ? float(SubresourceWidth) : 1.0f) - topLeftX; - Height = (SubresourceHeight ? float(SubresourceHeight) : 1.0f) - topLeftY; - break; - default: break; - } - - MinDepth = minDepth; - MaxDepth = maxDepth; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_BOX : public D3D12_BOX -{ - CD3DX12_BOX() = default; - explicit CD3DX12_BOX( const D3D12_BOX& o ) noexcept : - D3D12_BOX( o ) - {} - explicit CD3DX12_BOX( - LONG Left, - LONG Right ) noexcept - { - left = static_cast(Left); - top = 0; - front = 0; - right = static_cast(Right); - bottom = 1; - back = 1; - } - explicit CD3DX12_BOX( - LONG Left, - LONG Top, - LONG Right, - LONG Bottom ) noexcept - { - left = static_cast(Left); - top = static_cast(Top); - front = 0; - right = static_cast(Right); - bottom = static_cast(Bottom); - back = 1; - } - explicit CD3DX12_BOX( - LONG Left, - LONG Top, - LONG Front, - LONG Right, - LONG Bottom, - LONG Back ) noexcept - { - left = static_cast(Left); - top = static_cast(Top); - front = static_cast(Front); - right = static_cast(Right); - bottom = static_cast(Bottom); - back = static_cast(Back); - } -}; -inline bool operator==( const D3D12_BOX& l, const D3D12_BOX& r ) noexcept -{ - return l.left == r.left && l.top == r.top && l.front == r.front && - l.right == r.right && l.bottom == r.bottom && l.back == r.back; -} -inline bool operator!=( const D3D12_BOX& l, const D3D12_BOX& r ) noexcept -{ return !( l == r ); } - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_DEPTH_STENCIL_DESC : public D3D12_DEPTH_STENCIL_DESC -{ - CD3DX12_DEPTH_STENCIL_DESC() = default; - explicit CD3DX12_DEPTH_STENCIL_DESC( const D3D12_DEPTH_STENCIL_DESC& o ) noexcept : - D3D12_DEPTH_STENCIL_DESC( o ) - {} - explicit CD3DX12_DEPTH_STENCIL_DESC( CD3DX12_DEFAULT ) noexcept - { - DepthEnable = TRUE; - DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ALL; - DepthFunc = D3D12_COMPARISON_FUNC_LESS; - StencilEnable = FALSE; - StencilReadMask = D3D12_DEFAULT_STENCIL_READ_MASK; - StencilWriteMask = D3D12_DEFAULT_STENCIL_WRITE_MASK; - const D3D12_DEPTH_STENCILOP_DESC defaultStencilOp = - { D3D12_STENCIL_OP_KEEP, D3D12_STENCIL_OP_KEEP, D3D12_STENCIL_OP_KEEP, D3D12_COMPARISON_FUNC_ALWAYS }; - FrontFace = defaultStencilOp; - BackFace = defaultStencilOp; - } - explicit CD3DX12_DEPTH_STENCIL_DESC( - BOOL depthEnable, - D3D12_DEPTH_WRITE_MASK depthWriteMask, - D3D12_COMPARISON_FUNC depthFunc, - BOOL stencilEnable, - UINT8 stencilReadMask, - UINT8 stencilWriteMask, - D3D12_STENCIL_OP frontStencilFailOp, - D3D12_STENCIL_OP frontStencilDepthFailOp, - D3D12_STENCIL_OP frontStencilPassOp, - D3D12_COMPARISON_FUNC frontStencilFunc, - D3D12_STENCIL_OP backStencilFailOp, - D3D12_STENCIL_OP backStencilDepthFailOp, - D3D12_STENCIL_OP backStencilPassOp, - D3D12_COMPARISON_FUNC backStencilFunc ) noexcept - { - DepthEnable = depthEnable; - DepthWriteMask = depthWriteMask; - DepthFunc = depthFunc; - StencilEnable = stencilEnable; - StencilReadMask = stencilReadMask; - StencilWriteMask = stencilWriteMask; - FrontFace.StencilFailOp = frontStencilFailOp; - FrontFace.StencilDepthFailOp = frontStencilDepthFailOp; - FrontFace.StencilPassOp = frontStencilPassOp; - FrontFace.StencilFunc = frontStencilFunc; - BackFace.StencilFailOp = backStencilFailOp; - BackFace.StencilDepthFailOp = backStencilDepthFailOp; - BackFace.StencilPassOp = backStencilPassOp; - BackFace.StencilFunc = backStencilFunc; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_DEPTH_STENCIL_DESC1 : public D3D12_DEPTH_STENCIL_DESC1 -{ - CD3DX12_DEPTH_STENCIL_DESC1() = default; - explicit CD3DX12_DEPTH_STENCIL_DESC1( const D3D12_DEPTH_STENCIL_DESC1& o ) noexcept : - D3D12_DEPTH_STENCIL_DESC1( o ) - {} - explicit CD3DX12_DEPTH_STENCIL_DESC1( const D3D12_DEPTH_STENCIL_DESC& o ) noexcept - { - DepthEnable = o.DepthEnable; - DepthWriteMask = o.DepthWriteMask; - DepthFunc = o.DepthFunc; - StencilEnable = o.StencilEnable; - StencilReadMask = o.StencilReadMask; - StencilWriteMask = o.StencilWriteMask; - FrontFace.StencilFailOp = o.FrontFace.StencilFailOp; - FrontFace.StencilDepthFailOp = o.FrontFace.StencilDepthFailOp; - FrontFace.StencilPassOp = o.FrontFace.StencilPassOp; - FrontFace.StencilFunc = o.FrontFace.StencilFunc; - BackFace.StencilFailOp = o.BackFace.StencilFailOp; - BackFace.StencilDepthFailOp = o.BackFace.StencilDepthFailOp; - BackFace.StencilPassOp = o.BackFace.StencilPassOp; - BackFace.StencilFunc = o.BackFace.StencilFunc; - DepthBoundsTestEnable = FALSE; - } - explicit CD3DX12_DEPTH_STENCIL_DESC1( CD3DX12_DEFAULT ) noexcept - { - DepthEnable = TRUE; - DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ALL; - DepthFunc = D3D12_COMPARISON_FUNC_LESS; - StencilEnable = FALSE; - StencilReadMask = D3D12_DEFAULT_STENCIL_READ_MASK; - StencilWriteMask = D3D12_DEFAULT_STENCIL_WRITE_MASK; - const D3D12_DEPTH_STENCILOP_DESC defaultStencilOp = - { D3D12_STENCIL_OP_KEEP, D3D12_STENCIL_OP_KEEP, D3D12_STENCIL_OP_KEEP, D3D12_COMPARISON_FUNC_ALWAYS }; - FrontFace = defaultStencilOp; - BackFace = defaultStencilOp; - DepthBoundsTestEnable = FALSE; - } - explicit CD3DX12_DEPTH_STENCIL_DESC1( - BOOL depthEnable, - D3D12_DEPTH_WRITE_MASK depthWriteMask, - D3D12_COMPARISON_FUNC depthFunc, - BOOL stencilEnable, - UINT8 stencilReadMask, - UINT8 stencilWriteMask, - D3D12_STENCIL_OP frontStencilFailOp, - D3D12_STENCIL_OP frontStencilDepthFailOp, - D3D12_STENCIL_OP frontStencilPassOp, - D3D12_COMPARISON_FUNC frontStencilFunc, - D3D12_STENCIL_OP backStencilFailOp, - D3D12_STENCIL_OP backStencilDepthFailOp, - D3D12_STENCIL_OP backStencilPassOp, - D3D12_COMPARISON_FUNC backStencilFunc, - BOOL depthBoundsTestEnable ) noexcept - { - DepthEnable = depthEnable; - DepthWriteMask = depthWriteMask; - DepthFunc = depthFunc; - StencilEnable = stencilEnable; - StencilReadMask = stencilReadMask; - StencilWriteMask = stencilWriteMask; - FrontFace.StencilFailOp = frontStencilFailOp; - FrontFace.StencilDepthFailOp = frontStencilDepthFailOp; - FrontFace.StencilPassOp = frontStencilPassOp; - FrontFace.StencilFunc = frontStencilFunc; - BackFace.StencilFailOp = backStencilFailOp; - BackFace.StencilDepthFailOp = backStencilDepthFailOp; - BackFace.StencilPassOp = backStencilPassOp; - BackFace.StencilFunc = backStencilFunc; - DepthBoundsTestEnable = depthBoundsTestEnable; - } - operator D3D12_DEPTH_STENCIL_DESC() const noexcept - { - D3D12_DEPTH_STENCIL_DESC D; - D.DepthEnable = DepthEnable; - D.DepthWriteMask = DepthWriteMask; - D.DepthFunc = DepthFunc; - D.StencilEnable = StencilEnable; - D.StencilReadMask = StencilReadMask; - D.StencilWriteMask = StencilWriteMask; - D.FrontFace.StencilFailOp = FrontFace.StencilFailOp; - D.FrontFace.StencilDepthFailOp = FrontFace.StencilDepthFailOp; - D.FrontFace.StencilPassOp = FrontFace.StencilPassOp; - D.FrontFace.StencilFunc = FrontFace.StencilFunc; - D.BackFace.StencilFailOp = BackFace.StencilFailOp; - D.BackFace.StencilDepthFailOp = BackFace.StencilDepthFailOp; - D.BackFace.StencilPassOp = BackFace.StencilPassOp; - D.BackFace.StencilFunc = BackFace.StencilFunc; - return D; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_BLEND_DESC : public D3D12_BLEND_DESC -{ - CD3DX12_BLEND_DESC() = default; - explicit CD3DX12_BLEND_DESC( const D3D12_BLEND_DESC& o ) noexcept : - D3D12_BLEND_DESC( o ) - {} - explicit CD3DX12_BLEND_DESC( CD3DX12_DEFAULT ) noexcept - { - AlphaToCoverageEnable = FALSE; - IndependentBlendEnable = FALSE; - const D3D12_RENDER_TARGET_BLEND_DESC defaultRenderTargetBlendDesc = - { - FALSE,FALSE, - D3D12_BLEND_ONE, D3D12_BLEND_ZERO, D3D12_BLEND_OP_ADD, - D3D12_BLEND_ONE, D3D12_BLEND_ZERO, D3D12_BLEND_OP_ADD, - D3D12_LOGIC_OP_NOOP, - D3D12_COLOR_WRITE_ENABLE_ALL, - }; - for (UINT i = 0; i < D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i) - RenderTarget[ i ] = defaultRenderTargetBlendDesc; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_RASTERIZER_DESC : public D3D12_RASTERIZER_DESC -{ - CD3DX12_RASTERIZER_DESC() = default; - explicit CD3DX12_RASTERIZER_DESC( const D3D12_RASTERIZER_DESC& o ) noexcept : - D3D12_RASTERIZER_DESC( o ) - {} - explicit CD3DX12_RASTERIZER_DESC( CD3DX12_DEFAULT ) noexcept - { - FillMode = D3D12_FILL_MODE_SOLID; - CullMode = D3D12_CULL_MODE_BACK; - FrontCounterClockwise = FALSE; - DepthBias = D3D12_DEFAULT_DEPTH_BIAS; - DepthBiasClamp = D3D12_DEFAULT_DEPTH_BIAS_CLAMP; - SlopeScaledDepthBias = D3D12_DEFAULT_SLOPE_SCALED_DEPTH_BIAS; - DepthClipEnable = TRUE; - MultisampleEnable = FALSE; - AntialiasedLineEnable = FALSE; - ForcedSampleCount = 0; - ConservativeRaster = D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF; - } - explicit CD3DX12_RASTERIZER_DESC( - D3D12_FILL_MODE fillMode, - D3D12_CULL_MODE cullMode, - BOOL frontCounterClockwise, - INT depthBias, - FLOAT depthBiasClamp, - FLOAT slopeScaledDepthBias, - BOOL depthClipEnable, - BOOL multisampleEnable, - BOOL antialiasedLineEnable, - UINT forcedSampleCount, - D3D12_CONSERVATIVE_RASTERIZATION_MODE conservativeRaster) noexcept - { - FillMode = fillMode; - CullMode = cullMode; - FrontCounterClockwise = frontCounterClockwise; - DepthBias = depthBias; - DepthBiasClamp = depthBiasClamp; - SlopeScaledDepthBias = slopeScaledDepthBias; - DepthClipEnable = depthClipEnable; - MultisampleEnable = multisampleEnable; - AntialiasedLineEnable = antialiasedLineEnable; - ForcedSampleCount = forcedSampleCount; - ConservativeRaster = conservativeRaster; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_RESOURCE_ALLOCATION_INFO : public D3D12_RESOURCE_ALLOCATION_INFO -{ - CD3DX12_RESOURCE_ALLOCATION_INFO() = default; - explicit CD3DX12_RESOURCE_ALLOCATION_INFO( const D3D12_RESOURCE_ALLOCATION_INFO& o ) noexcept : - D3D12_RESOURCE_ALLOCATION_INFO( o ) - {} - CD3DX12_RESOURCE_ALLOCATION_INFO( - UINT64 size, - UINT64 alignment ) noexcept - { - SizeInBytes = size; - Alignment = alignment; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_HEAP_PROPERTIES : public D3D12_HEAP_PROPERTIES -{ - CD3DX12_HEAP_PROPERTIES() = default; - explicit CD3DX12_HEAP_PROPERTIES(const D3D12_HEAP_PROPERTIES &o) noexcept : - D3D12_HEAP_PROPERTIES(o) - {} - CD3DX12_HEAP_PROPERTIES( - D3D12_CPU_PAGE_PROPERTY cpuPageProperty, - D3D12_MEMORY_POOL memoryPoolPreference, - UINT creationNodeMask = 1, - UINT nodeMask = 1 ) noexcept - { - Type = D3D12_HEAP_TYPE_CUSTOM; - CPUPageProperty = cpuPageProperty; - MemoryPoolPreference = memoryPoolPreference; - CreationNodeMask = creationNodeMask; - VisibleNodeMask = nodeMask; - } - explicit CD3DX12_HEAP_PROPERTIES( - D3D12_HEAP_TYPE type, - UINT creationNodeMask = 1, - UINT nodeMask = 1 ) noexcept - { - Type = type; - CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; - MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; - CreationNodeMask = creationNodeMask; - VisibleNodeMask = nodeMask; - } - bool IsCPUAccessible() const noexcept - { - return Type == D3D12_HEAP_TYPE_UPLOAD || Type == D3D12_HEAP_TYPE_READBACK || (Type == D3D12_HEAP_TYPE_CUSTOM && - (CPUPageProperty == D3D12_CPU_PAGE_PROPERTY_WRITE_COMBINE || CPUPageProperty == D3D12_CPU_PAGE_PROPERTY_WRITE_BACK)); - } -}; -inline bool operator==( const D3D12_HEAP_PROPERTIES& l, const D3D12_HEAP_PROPERTIES& r ) noexcept -{ - return l.Type == r.Type && l.CPUPageProperty == r.CPUPageProperty && - l.MemoryPoolPreference == r.MemoryPoolPreference && - l.CreationNodeMask == r.CreationNodeMask && - l.VisibleNodeMask == r.VisibleNodeMask; -} -inline bool operator!=( const D3D12_HEAP_PROPERTIES& l, const D3D12_HEAP_PROPERTIES& r ) noexcept -{ return !( l == r ); } - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_HEAP_DESC : public D3D12_HEAP_DESC -{ - CD3DX12_HEAP_DESC() = default; - explicit CD3DX12_HEAP_DESC(const D3D12_HEAP_DESC &o) noexcept : - D3D12_HEAP_DESC(o) - {} - CD3DX12_HEAP_DESC( - UINT64 size, - D3D12_HEAP_PROPERTIES properties, - UINT64 alignment = 0, - D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE ) noexcept - { - SizeInBytes = size; - Properties = properties; - Alignment = alignment; - Flags = flags; - } - CD3DX12_HEAP_DESC( - UINT64 size, - D3D12_HEAP_TYPE type, - UINT64 alignment = 0, - D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE ) noexcept - { - SizeInBytes = size; - Properties = CD3DX12_HEAP_PROPERTIES( type ); - Alignment = alignment; - Flags = flags; - } - CD3DX12_HEAP_DESC( - UINT64 size, - D3D12_CPU_PAGE_PROPERTY cpuPageProperty, - D3D12_MEMORY_POOL memoryPoolPreference, - UINT64 alignment = 0, - D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE ) noexcept - { - SizeInBytes = size; - Properties = CD3DX12_HEAP_PROPERTIES( cpuPageProperty, memoryPoolPreference ); - Alignment = alignment; - Flags = flags; - } - CD3DX12_HEAP_DESC( - const D3D12_RESOURCE_ALLOCATION_INFO& resAllocInfo, - D3D12_HEAP_PROPERTIES properties, - D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE ) noexcept - { - SizeInBytes = resAllocInfo.SizeInBytes; - Properties = properties; - Alignment = resAllocInfo.Alignment; - Flags = flags; - } - CD3DX12_HEAP_DESC( - const D3D12_RESOURCE_ALLOCATION_INFO& resAllocInfo, - D3D12_HEAP_TYPE type, - D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE ) noexcept - { - SizeInBytes = resAllocInfo.SizeInBytes; - Properties = CD3DX12_HEAP_PROPERTIES( type ); - Alignment = resAllocInfo.Alignment; - Flags = flags; - } - CD3DX12_HEAP_DESC( - const D3D12_RESOURCE_ALLOCATION_INFO& resAllocInfo, - D3D12_CPU_PAGE_PROPERTY cpuPageProperty, - D3D12_MEMORY_POOL memoryPoolPreference, - D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE ) noexcept - { - SizeInBytes = resAllocInfo.SizeInBytes; - Properties = CD3DX12_HEAP_PROPERTIES( cpuPageProperty, memoryPoolPreference ); - Alignment = resAllocInfo.Alignment; - Flags = flags; - } - bool IsCPUAccessible() const noexcept - { return static_cast< const CD3DX12_HEAP_PROPERTIES* >( &Properties )->IsCPUAccessible(); } -}; -inline bool operator==( const D3D12_HEAP_DESC& l, const D3D12_HEAP_DESC& r ) noexcept -{ - return l.SizeInBytes == r.SizeInBytes && - l.Properties == r.Properties && - l.Alignment == r.Alignment && - l.Flags == r.Flags; -} -inline bool operator!=( const D3D12_HEAP_DESC& l, const D3D12_HEAP_DESC& r ) noexcept -{ return !( l == r ); } - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_CLEAR_VALUE : public D3D12_CLEAR_VALUE -{ - CD3DX12_CLEAR_VALUE() = default; - explicit CD3DX12_CLEAR_VALUE(const D3D12_CLEAR_VALUE &o) noexcept : - D3D12_CLEAR_VALUE(o) - {} - CD3DX12_CLEAR_VALUE( - DXGI_FORMAT format, - const FLOAT color[4] ) noexcept - { - Format = format; - memcpy( Color, color, sizeof( Color ) ); - } - CD3DX12_CLEAR_VALUE( - DXGI_FORMAT format, - FLOAT depth, - UINT8 stencil ) noexcept - { - Format = format; - memset( &Color, 0, sizeof( Color ) ); - /* Use memcpy to preserve NAN values */ - memcpy( &DepthStencil.Depth, &depth, sizeof( depth ) ); - DepthStencil.Stencil = stencil; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_RANGE : public D3D12_RANGE -{ - CD3DX12_RANGE() = default; - explicit CD3DX12_RANGE(const D3D12_RANGE &o) noexcept : - D3D12_RANGE(o) - {} - CD3DX12_RANGE( - SIZE_T begin, - SIZE_T end ) noexcept - { - Begin = begin; - End = end; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_RANGE_UINT64 : public D3D12_RANGE_UINT64 -{ - CD3DX12_RANGE_UINT64() = default; - explicit CD3DX12_RANGE_UINT64(const D3D12_RANGE_UINT64 &o) noexcept : - D3D12_RANGE_UINT64(o) - {} - CD3DX12_RANGE_UINT64( - UINT64 begin, - UINT64 end ) noexcept - { - Begin = begin; - End = end; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_SUBRESOURCE_RANGE_UINT64 : public D3D12_SUBRESOURCE_RANGE_UINT64 -{ - CD3DX12_SUBRESOURCE_RANGE_UINT64() = default; - explicit CD3DX12_SUBRESOURCE_RANGE_UINT64(const D3D12_SUBRESOURCE_RANGE_UINT64 &o) noexcept : - D3D12_SUBRESOURCE_RANGE_UINT64(o) - {} - CD3DX12_SUBRESOURCE_RANGE_UINT64( - UINT subresource, - const D3D12_RANGE_UINT64& range ) noexcept - { - Subresource = subresource; - Range = range; - } - CD3DX12_SUBRESOURCE_RANGE_UINT64( - UINT subresource, - UINT64 begin, - UINT64 end ) noexcept - { - Subresource = subresource; - Range.Begin = begin; - Range.End = end; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_SHADER_BYTECODE : public D3D12_SHADER_BYTECODE -{ - CD3DX12_SHADER_BYTECODE() = default; - explicit CD3DX12_SHADER_BYTECODE(const D3D12_SHADER_BYTECODE &o) noexcept : - D3D12_SHADER_BYTECODE(o) - {} - CD3DX12_SHADER_BYTECODE( - _In_ ID3DBlob* pShaderBlob ) noexcept - { - pShaderBytecode = pShaderBlob->GetBufferPointer(); - BytecodeLength = pShaderBlob->GetBufferSize(); - } - CD3DX12_SHADER_BYTECODE( - const void* _pShaderBytecode, - SIZE_T bytecodeLength ) noexcept - { - pShaderBytecode = _pShaderBytecode; - BytecodeLength = bytecodeLength; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_TILED_RESOURCE_COORDINATE : public D3D12_TILED_RESOURCE_COORDINATE -{ - CD3DX12_TILED_RESOURCE_COORDINATE() = default; - explicit CD3DX12_TILED_RESOURCE_COORDINATE(const D3D12_TILED_RESOURCE_COORDINATE &o) noexcept : - D3D12_TILED_RESOURCE_COORDINATE(o) - {} - CD3DX12_TILED_RESOURCE_COORDINATE( - UINT x, - UINT y, - UINT z, - UINT subresource ) noexcept - { - X = x; - Y = y; - Z = z; - Subresource = subresource; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_TILE_REGION_SIZE : public D3D12_TILE_REGION_SIZE -{ - CD3DX12_TILE_REGION_SIZE() = default; - explicit CD3DX12_TILE_REGION_SIZE(const D3D12_TILE_REGION_SIZE &o) noexcept : - D3D12_TILE_REGION_SIZE(o) - {} - CD3DX12_TILE_REGION_SIZE( - UINT numTiles, - BOOL useBox, - UINT width, - UINT16 height, - UINT16 depth ) noexcept - { - NumTiles = numTiles; - UseBox = useBox; - Width = width; - Height = height; - Depth = depth; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_SUBRESOURCE_TILING : public D3D12_SUBRESOURCE_TILING -{ - CD3DX12_SUBRESOURCE_TILING() = default; - explicit CD3DX12_SUBRESOURCE_TILING(const D3D12_SUBRESOURCE_TILING &o) noexcept : - D3D12_SUBRESOURCE_TILING(o) - {} - CD3DX12_SUBRESOURCE_TILING( - UINT widthInTiles, - UINT16 heightInTiles, - UINT16 depthInTiles, - UINT startTileIndexInOverallResource ) noexcept - { - WidthInTiles = widthInTiles; - HeightInTiles = heightInTiles; - DepthInTiles = depthInTiles; - StartTileIndexInOverallResource = startTileIndexInOverallResource; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_TILE_SHAPE : public D3D12_TILE_SHAPE -{ - CD3DX12_TILE_SHAPE() = default; - explicit CD3DX12_TILE_SHAPE(const D3D12_TILE_SHAPE &o) noexcept : - D3D12_TILE_SHAPE(o) - {} - CD3DX12_TILE_SHAPE( - UINT widthInTexels, - UINT heightInTexels, - UINT depthInTexels ) noexcept - { - WidthInTexels = widthInTexels; - HeightInTexels = heightInTexels; - DepthInTexels = depthInTexels; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_RESOURCE_BARRIER : public D3D12_RESOURCE_BARRIER -{ - CD3DX12_RESOURCE_BARRIER() = default; - explicit CD3DX12_RESOURCE_BARRIER(const D3D12_RESOURCE_BARRIER &o) noexcept : - D3D12_RESOURCE_BARRIER(o) - {} - static inline CD3DX12_RESOURCE_BARRIER Transition( - _In_ ID3D12Resource* pResource, - D3D12_RESOURCE_STATES stateBefore, - D3D12_RESOURCE_STATES stateAfter, - UINT subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES, - D3D12_RESOURCE_BARRIER_FLAGS flags = D3D12_RESOURCE_BARRIER_FLAG_NONE) noexcept - { - CD3DX12_RESOURCE_BARRIER result = {}; - D3D12_RESOURCE_BARRIER &barrier = result; - result.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; - result.Flags = flags; - barrier.Transition.pResource = pResource; - barrier.Transition.StateBefore = stateBefore; - barrier.Transition.StateAfter = stateAfter; - barrier.Transition.Subresource = subresource; - return result; - } - static inline CD3DX12_RESOURCE_BARRIER Aliasing( - _In_ ID3D12Resource* pResourceBefore, - _In_ ID3D12Resource* pResourceAfter) noexcept - { - CD3DX12_RESOURCE_BARRIER result = {}; - D3D12_RESOURCE_BARRIER &barrier = result; - result.Type = D3D12_RESOURCE_BARRIER_TYPE_ALIASING; - barrier.Aliasing.pResourceBefore = pResourceBefore; - barrier.Aliasing.pResourceAfter = pResourceAfter; - return result; - } - static inline CD3DX12_RESOURCE_BARRIER UAV( - _In_ ID3D12Resource* pResource) noexcept - { - CD3DX12_RESOURCE_BARRIER result = {}; - D3D12_RESOURCE_BARRIER &barrier = result; - result.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV; - barrier.UAV.pResource = pResource; - return result; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_PACKED_MIP_INFO : public D3D12_PACKED_MIP_INFO -{ - CD3DX12_PACKED_MIP_INFO() = default; - explicit CD3DX12_PACKED_MIP_INFO(const D3D12_PACKED_MIP_INFO &o) noexcept : - D3D12_PACKED_MIP_INFO(o) - {} - CD3DX12_PACKED_MIP_INFO( - UINT8 numStandardMips, - UINT8 numPackedMips, - UINT numTilesForPackedMips, - UINT startTileIndexInOverallResource ) noexcept - { - NumStandardMips = numStandardMips; - NumPackedMips = numPackedMips; - NumTilesForPackedMips = numTilesForPackedMips; - StartTileIndexInOverallResource = startTileIndexInOverallResource; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_SUBRESOURCE_FOOTPRINT : public D3D12_SUBRESOURCE_FOOTPRINT -{ - CD3DX12_SUBRESOURCE_FOOTPRINT() = default; - explicit CD3DX12_SUBRESOURCE_FOOTPRINT(const D3D12_SUBRESOURCE_FOOTPRINT &o) noexcept : - D3D12_SUBRESOURCE_FOOTPRINT(o) - {} - CD3DX12_SUBRESOURCE_FOOTPRINT( - DXGI_FORMAT format, - UINT width, - UINT height, - UINT depth, - UINT rowPitch ) noexcept - { - Format = format; - Width = width; - Height = height; - Depth = depth; - RowPitch = rowPitch; - } - explicit CD3DX12_SUBRESOURCE_FOOTPRINT( - const D3D12_RESOURCE_DESC& resDesc, - UINT rowPitch ) noexcept - { - Format = resDesc.Format; - Width = UINT( resDesc.Width ); - Height = resDesc.Height; - Depth = (resDesc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D ? resDesc.DepthOrArraySize : 1); - RowPitch = rowPitch; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_TEXTURE_COPY_LOCATION : public D3D12_TEXTURE_COPY_LOCATION -{ - CD3DX12_TEXTURE_COPY_LOCATION() = default; - explicit CD3DX12_TEXTURE_COPY_LOCATION(const D3D12_TEXTURE_COPY_LOCATION &o) noexcept : - D3D12_TEXTURE_COPY_LOCATION(o) - {} - CD3DX12_TEXTURE_COPY_LOCATION(_In_ ID3D12Resource* pRes) noexcept - { - pResource = pRes; - Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX; - PlacedFootprint = {}; - } - CD3DX12_TEXTURE_COPY_LOCATION(_In_ ID3D12Resource* pRes, D3D12_PLACED_SUBRESOURCE_FOOTPRINT const& Footprint) noexcept - { - pResource = pRes; - Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT; - PlacedFootprint = Footprint; - } - CD3DX12_TEXTURE_COPY_LOCATION(_In_ ID3D12Resource* pRes, UINT Sub) noexcept - { - pResource = pRes; - Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX; - PlacedFootprint = {}; - SubresourceIndex = Sub; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_DESCRIPTOR_RANGE : public D3D12_DESCRIPTOR_RANGE -{ - CD3DX12_DESCRIPTOR_RANGE() = default; - explicit CD3DX12_DESCRIPTOR_RANGE(const D3D12_DESCRIPTOR_RANGE &o) noexcept : - D3D12_DESCRIPTOR_RANGE(o) - {} - CD3DX12_DESCRIPTOR_RANGE( - D3D12_DESCRIPTOR_RANGE_TYPE rangeType, - UINT numDescriptors, - UINT baseShaderRegister, - UINT registerSpace = 0, - UINT offsetInDescriptorsFromTableStart = - D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) noexcept - { - Init(rangeType, numDescriptors, baseShaderRegister, registerSpace, offsetInDescriptorsFromTableStart); - } - - inline void Init( - D3D12_DESCRIPTOR_RANGE_TYPE rangeType, - UINT numDescriptors, - UINT baseShaderRegister, - UINT registerSpace = 0, - UINT offsetInDescriptorsFromTableStart = - D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) noexcept - { - Init(*this, rangeType, numDescriptors, baseShaderRegister, registerSpace, offsetInDescriptorsFromTableStart); - } - - static inline void Init( - _Out_ D3D12_DESCRIPTOR_RANGE &range, - D3D12_DESCRIPTOR_RANGE_TYPE rangeType, - UINT numDescriptors, - UINT baseShaderRegister, - UINT registerSpace = 0, - UINT offsetInDescriptorsFromTableStart = - D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) noexcept - { - range.RangeType = rangeType; - range.NumDescriptors = numDescriptors; - range.BaseShaderRegister = baseShaderRegister; - range.RegisterSpace = registerSpace; - range.OffsetInDescriptorsFromTableStart = offsetInDescriptorsFromTableStart; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_ROOT_DESCRIPTOR_TABLE : public D3D12_ROOT_DESCRIPTOR_TABLE -{ - CD3DX12_ROOT_DESCRIPTOR_TABLE() = default; - explicit CD3DX12_ROOT_DESCRIPTOR_TABLE(const D3D12_ROOT_DESCRIPTOR_TABLE &o) noexcept : - D3D12_ROOT_DESCRIPTOR_TABLE(o) - {} - CD3DX12_ROOT_DESCRIPTOR_TABLE( - UINT numDescriptorRanges, - _In_reads_opt_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE* _pDescriptorRanges) noexcept - { - Init(numDescriptorRanges, _pDescriptorRanges); - } - - inline void Init( - UINT numDescriptorRanges, - _In_reads_opt_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE* _pDescriptorRanges) noexcept - { - Init(*this, numDescriptorRanges, _pDescriptorRanges); - } - - static inline void Init( - _Out_ D3D12_ROOT_DESCRIPTOR_TABLE &rootDescriptorTable, - UINT numDescriptorRanges, - _In_reads_opt_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE* _pDescriptorRanges) noexcept - { - rootDescriptorTable.NumDescriptorRanges = numDescriptorRanges; - rootDescriptorTable.pDescriptorRanges = _pDescriptorRanges; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_ROOT_CONSTANTS : public D3D12_ROOT_CONSTANTS -{ - CD3DX12_ROOT_CONSTANTS() = default; - explicit CD3DX12_ROOT_CONSTANTS(const D3D12_ROOT_CONSTANTS &o) noexcept : - D3D12_ROOT_CONSTANTS(o) - {} - CD3DX12_ROOT_CONSTANTS( - UINT num32BitValues, - UINT shaderRegister, - UINT registerSpace = 0) noexcept - { - Init(num32BitValues, shaderRegister, registerSpace); - } - - inline void Init( - UINT num32BitValues, - UINT shaderRegister, - UINT registerSpace = 0) noexcept - { - Init(*this, num32BitValues, shaderRegister, registerSpace); - } - - static inline void Init( - _Out_ D3D12_ROOT_CONSTANTS &rootConstants, - UINT num32BitValues, - UINT shaderRegister, - UINT registerSpace = 0) noexcept - { - rootConstants.Num32BitValues = num32BitValues; - rootConstants.ShaderRegister = shaderRegister; - rootConstants.RegisterSpace = registerSpace; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_ROOT_DESCRIPTOR : public D3D12_ROOT_DESCRIPTOR -{ - CD3DX12_ROOT_DESCRIPTOR() = default; - explicit CD3DX12_ROOT_DESCRIPTOR(const D3D12_ROOT_DESCRIPTOR &o) noexcept : - D3D12_ROOT_DESCRIPTOR(o) - {} - CD3DX12_ROOT_DESCRIPTOR( - UINT shaderRegister, - UINT registerSpace = 0) noexcept - { - Init(shaderRegister, registerSpace); - } - - inline void Init( - UINT shaderRegister, - UINT registerSpace = 0) noexcept - { - Init(*this, shaderRegister, registerSpace); - } - - static inline void Init(_Out_ D3D12_ROOT_DESCRIPTOR &table, UINT shaderRegister, UINT registerSpace = 0) noexcept - { - table.ShaderRegister = shaderRegister; - table.RegisterSpace = registerSpace; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_ROOT_PARAMETER : public D3D12_ROOT_PARAMETER -{ - CD3DX12_ROOT_PARAMETER() = default; - explicit CD3DX12_ROOT_PARAMETER(const D3D12_ROOT_PARAMETER &o) noexcept : - D3D12_ROOT_PARAMETER(o) - {} - - static inline void InitAsDescriptorTable( - _Out_ D3D12_ROOT_PARAMETER &rootParam, - UINT numDescriptorRanges, - _In_reads_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE* pDescriptorRanges, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; - rootParam.ShaderVisibility = visibility; - CD3DX12_ROOT_DESCRIPTOR_TABLE::Init(rootParam.DescriptorTable, numDescriptorRanges, pDescriptorRanges); - } - - static inline void InitAsConstants( - _Out_ D3D12_ROOT_PARAMETER &rootParam, - UINT num32BitValues, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS; - rootParam.ShaderVisibility = visibility; - CD3DX12_ROOT_CONSTANTS::Init(rootParam.Constants, num32BitValues, shaderRegister, registerSpace); - } - - static inline void InitAsConstantBufferView( - _Out_ D3D12_ROOT_PARAMETER &rootParam, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; - rootParam.ShaderVisibility = visibility; - CD3DX12_ROOT_DESCRIPTOR::Init(rootParam.Descriptor, shaderRegister, registerSpace); - } - - static inline void InitAsShaderResourceView( - _Out_ D3D12_ROOT_PARAMETER &rootParam, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_SRV; - rootParam.ShaderVisibility = visibility; - CD3DX12_ROOT_DESCRIPTOR::Init(rootParam.Descriptor, shaderRegister, registerSpace); - } - - static inline void InitAsUnorderedAccessView( - _Out_ D3D12_ROOT_PARAMETER &rootParam, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_UAV; - rootParam.ShaderVisibility = visibility; - CD3DX12_ROOT_DESCRIPTOR::Init(rootParam.Descriptor, shaderRegister, registerSpace); - } - - inline void InitAsDescriptorTable( - UINT numDescriptorRanges, - _In_reads_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE* pDescriptorRanges, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - InitAsDescriptorTable(*this, numDescriptorRanges, pDescriptorRanges, visibility); - } - - inline void InitAsConstants( - UINT num32BitValues, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - InitAsConstants(*this, num32BitValues, shaderRegister, registerSpace, visibility); - } - - inline void InitAsConstantBufferView( - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - InitAsConstantBufferView(*this, shaderRegister, registerSpace, visibility); - } - - inline void InitAsShaderResourceView( - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - InitAsShaderResourceView(*this, shaderRegister, registerSpace, visibility); - } - - inline void InitAsUnorderedAccessView( - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - InitAsUnorderedAccessView(*this, shaderRegister, registerSpace, visibility); - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_STATIC_SAMPLER_DESC : public D3D12_STATIC_SAMPLER_DESC -{ - CD3DX12_STATIC_SAMPLER_DESC() = default; - explicit CD3DX12_STATIC_SAMPLER_DESC(const D3D12_STATIC_SAMPLER_DESC &o) noexcept : - D3D12_STATIC_SAMPLER_DESC(o) - {} - CD3DX12_STATIC_SAMPLER_DESC( - UINT shaderRegister, - D3D12_FILTER filter = D3D12_FILTER_ANISOTROPIC, - D3D12_TEXTURE_ADDRESS_MODE addressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP, - D3D12_TEXTURE_ADDRESS_MODE addressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP, - D3D12_TEXTURE_ADDRESS_MODE addressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP, - FLOAT mipLODBias = 0, - UINT maxAnisotropy = 16, - D3D12_COMPARISON_FUNC comparisonFunc = D3D12_COMPARISON_FUNC_LESS_EQUAL, - D3D12_STATIC_BORDER_COLOR borderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE, - FLOAT minLOD = 0.f, - FLOAT maxLOD = D3D12_FLOAT32_MAX, - D3D12_SHADER_VISIBILITY shaderVisibility = D3D12_SHADER_VISIBILITY_ALL, - UINT registerSpace = 0) noexcept - { - Init( - shaderRegister, - filter, - addressU, - addressV, - addressW, - mipLODBias, - maxAnisotropy, - comparisonFunc, - borderColor, - minLOD, - maxLOD, - shaderVisibility, - registerSpace); - } - - static inline void Init( - _Out_ D3D12_STATIC_SAMPLER_DESC &samplerDesc, - UINT shaderRegister, - D3D12_FILTER filter = D3D12_FILTER_ANISOTROPIC, - D3D12_TEXTURE_ADDRESS_MODE addressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP, - D3D12_TEXTURE_ADDRESS_MODE addressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP, - D3D12_TEXTURE_ADDRESS_MODE addressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP, - FLOAT mipLODBias = 0, - UINT maxAnisotropy = 16, - D3D12_COMPARISON_FUNC comparisonFunc = D3D12_COMPARISON_FUNC_LESS_EQUAL, - D3D12_STATIC_BORDER_COLOR borderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE, - FLOAT minLOD = 0.f, - FLOAT maxLOD = D3D12_FLOAT32_MAX, - D3D12_SHADER_VISIBILITY shaderVisibility = D3D12_SHADER_VISIBILITY_ALL, - UINT registerSpace = 0) noexcept - { - samplerDesc.ShaderRegister = shaderRegister; - samplerDesc.Filter = filter; - samplerDesc.AddressU = addressU; - samplerDesc.AddressV = addressV; - samplerDesc.AddressW = addressW; - samplerDesc.MipLODBias = mipLODBias; - samplerDesc.MaxAnisotropy = maxAnisotropy; - samplerDesc.ComparisonFunc = comparisonFunc; - samplerDesc.BorderColor = borderColor; - samplerDesc.MinLOD = minLOD; - samplerDesc.MaxLOD = maxLOD; - samplerDesc.ShaderVisibility = shaderVisibility; - samplerDesc.RegisterSpace = registerSpace; - } - inline void Init( - UINT shaderRegister, - D3D12_FILTER filter = D3D12_FILTER_ANISOTROPIC, - D3D12_TEXTURE_ADDRESS_MODE addressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP, - D3D12_TEXTURE_ADDRESS_MODE addressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP, - D3D12_TEXTURE_ADDRESS_MODE addressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP, - FLOAT mipLODBias = 0, - UINT maxAnisotropy = 16, - D3D12_COMPARISON_FUNC comparisonFunc = D3D12_COMPARISON_FUNC_LESS_EQUAL, - D3D12_STATIC_BORDER_COLOR borderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE, - FLOAT minLOD = 0.f, - FLOAT maxLOD = D3D12_FLOAT32_MAX, - D3D12_SHADER_VISIBILITY shaderVisibility = D3D12_SHADER_VISIBILITY_ALL, - UINT registerSpace = 0) noexcept - { - Init( - *this, - shaderRegister, - filter, - addressU, - addressV, - addressW, - mipLODBias, - maxAnisotropy, - comparisonFunc, - borderColor, - minLOD, - maxLOD, - shaderVisibility, - registerSpace); - } - -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_ROOT_SIGNATURE_DESC : public D3D12_ROOT_SIGNATURE_DESC -{ - CD3DX12_ROOT_SIGNATURE_DESC() = default; - explicit CD3DX12_ROOT_SIGNATURE_DESC(const D3D12_ROOT_SIGNATURE_DESC &o) noexcept : - D3D12_ROOT_SIGNATURE_DESC(o) - {} - CD3DX12_ROOT_SIGNATURE_DESC( - UINT numParameters, - _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters, - UINT numStaticSamplers = 0, - _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, - D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept - { - Init(numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags); - } - CD3DX12_ROOT_SIGNATURE_DESC(CD3DX12_DEFAULT) noexcept - { - Init(0, nullptr, 0, nullptr, D3D12_ROOT_SIGNATURE_FLAG_NONE); - } - - inline void Init( - UINT numParameters, - _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters, - UINT numStaticSamplers = 0, - _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, - D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept - { - Init(*this, numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags); - } - - static inline void Init( - _Out_ D3D12_ROOT_SIGNATURE_DESC &desc, - UINT numParameters, - _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters, - UINT numStaticSamplers = 0, - _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, - D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept - { - desc.NumParameters = numParameters; - desc.pParameters = _pParameters; - desc.NumStaticSamplers = numStaticSamplers; - desc.pStaticSamplers = _pStaticSamplers; - desc.Flags = flags; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_DESCRIPTOR_RANGE1 : public D3D12_DESCRIPTOR_RANGE1 -{ - CD3DX12_DESCRIPTOR_RANGE1() = default; - explicit CD3DX12_DESCRIPTOR_RANGE1(const D3D12_DESCRIPTOR_RANGE1 &o) noexcept : - D3D12_DESCRIPTOR_RANGE1(o) - {} - CD3DX12_DESCRIPTOR_RANGE1( - D3D12_DESCRIPTOR_RANGE_TYPE rangeType, - UINT numDescriptors, - UINT baseShaderRegister, - UINT registerSpace = 0, - D3D12_DESCRIPTOR_RANGE_FLAGS flags = D3D12_DESCRIPTOR_RANGE_FLAG_NONE, - UINT offsetInDescriptorsFromTableStart = - D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) noexcept - { - Init(rangeType, numDescriptors, baseShaderRegister, registerSpace, flags, offsetInDescriptorsFromTableStart); - } - - inline void Init( - D3D12_DESCRIPTOR_RANGE_TYPE rangeType, - UINT numDescriptors, - UINT baseShaderRegister, - UINT registerSpace = 0, - D3D12_DESCRIPTOR_RANGE_FLAGS flags = D3D12_DESCRIPTOR_RANGE_FLAG_NONE, - UINT offsetInDescriptorsFromTableStart = - D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) noexcept - { - Init(*this, rangeType, numDescriptors, baseShaderRegister, registerSpace, flags, offsetInDescriptorsFromTableStart); - } - - static inline void Init( - _Out_ D3D12_DESCRIPTOR_RANGE1 &range, - D3D12_DESCRIPTOR_RANGE_TYPE rangeType, - UINT numDescriptors, - UINT baseShaderRegister, - UINT registerSpace = 0, - D3D12_DESCRIPTOR_RANGE_FLAGS flags = D3D12_DESCRIPTOR_RANGE_FLAG_NONE, - UINT offsetInDescriptorsFromTableStart = - D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) noexcept - { - range.RangeType = rangeType; - range.NumDescriptors = numDescriptors; - range.BaseShaderRegister = baseShaderRegister; - range.RegisterSpace = registerSpace; - range.Flags = flags; - range.OffsetInDescriptorsFromTableStart = offsetInDescriptorsFromTableStart; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_ROOT_DESCRIPTOR_TABLE1 : public D3D12_ROOT_DESCRIPTOR_TABLE1 -{ - CD3DX12_ROOT_DESCRIPTOR_TABLE1() = default; - explicit CD3DX12_ROOT_DESCRIPTOR_TABLE1(const D3D12_ROOT_DESCRIPTOR_TABLE1 &o) noexcept : - D3D12_ROOT_DESCRIPTOR_TABLE1(o) - {} - CD3DX12_ROOT_DESCRIPTOR_TABLE1( - UINT numDescriptorRanges, - _In_reads_opt_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE1* _pDescriptorRanges) noexcept - { - Init(numDescriptorRanges, _pDescriptorRanges); - } - - inline void Init( - UINT numDescriptorRanges, - _In_reads_opt_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE1* _pDescriptorRanges) noexcept - { - Init(*this, numDescriptorRanges, _pDescriptorRanges); - } - - static inline void Init( - _Out_ D3D12_ROOT_DESCRIPTOR_TABLE1 &rootDescriptorTable, - UINT numDescriptorRanges, - _In_reads_opt_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE1* _pDescriptorRanges) noexcept - { - rootDescriptorTable.NumDescriptorRanges = numDescriptorRanges; - rootDescriptorTable.pDescriptorRanges = _pDescriptorRanges; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_ROOT_DESCRIPTOR1 : public D3D12_ROOT_DESCRIPTOR1 -{ - CD3DX12_ROOT_DESCRIPTOR1() = default; - explicit CD3DX12_ROOT_DESCRIPTOR1(const D3D12_ROOT_DESCRIPTOR1 &o) noexcept : - D3D12_ROOT_DESCRIPTOR1(o) - {} - CD3DX12_ROOT_DESCRIPTOR1( - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE) noexcept - { - Init(shaderRegister, registerSpace, flags); - } - - inline void Init( - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE) noexcept - { - Init(*this, shaderRegister, registerSpace, flags); - } - - static inline void Init( - _Out_ D3D12_ROOT_DESCRIPTOR1 &table, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE) noexcept - { - table.ShaderRegister = shaderRegister; - table.RegisterSpace = registerSpace; - table.Flags = flags; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_ROOT_PARAMETER1 : public D3D12_ROOT_PARAMETER1 -{ - CD3DX12_ROOT_PARAMETER1() = default; - explicit CD3DX12_ROOT_PARAMETER1(const D3D12_ROOT_PARAMETER1 &o) noexcept : - D3D12_ROOT_PARAMETER1(o) - {} - - static inline void InitAsDescriptorTable( - _Out_ D3D12_ROOT_PARAMETER1 &rootParam, - UINT numDescriptorRanges, - _In_reads_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE1* pDescriptorRanges, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; - rootParam.ShaderVisibility = visibility; - CD3DX12_ROOT_DESCRIPTOR_TABLE1::Init(rootParam.DescriptorTable, numDescriptorRanges, pDescriptorRanges); - } - - static inline void InitAsConstants( - _Out_ D3D12_ROOT_PARAMETER1 &rootParam, - UINT num32BitValues, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS; - rootParam.ShaderVisibility = visibility; - CD3DX12_ROOT_CONSTANTS::Init(rootParam.Constants, num32BitValues, shaderRegister, registerSpace); - } - - static inline void InitAsConstantBufferView( - _Out_ D3D12_ROOT_PARAMETER1 &rootParam, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; - rootParam.ShaderVisibility = visibility; - CD3DX12_ROOT_DESCRIPTOR1::Init(rootParam.Descriptor, shaderRegister, registerSpace, flags); - } - - static inline void InitAsShaderResourceView( - _Out_ D3D12_ROOT_PARAMETER1 &rootParam, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_SRV; - rootParam.ShaderVisibility = visibility; - CD3DX12_ROOT_DESCRIPTOR1::Init(rootParam.Descriptor, shaderRegister, registerSpace, flags); - } - - static inline void InitAsUnorderedAccessView( - _Out_ D3D12_ROOT_PARAMETER1 &rootParam, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_UAV; - rootParam.ShaderVisibility = visibility; - CD3DX12_ROOT_DESCRIPTOR1::Init(rootParam.Descriptor, shaderRegister, registerSpace, flags); - } - - inline void InitAsDescriptorTable( - UINT numDescriptorRanges, - _In_reads_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE1* pDescriptorRanges, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - InitAsDescriptorTable(*this, numDescriptorRanges, pDescriptorRanges, visibility); - } - - inline void InitAsConstants( - UINT num32BitValues, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - InitAsConstants(*this, num32BitValues, shaderRegister, registerSpace, visibility); - } - - inline void InitAsConstantBufferView( - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - InitAsConstantBufferView(*this, shaderRegister, registerSpace, flags, visibility); - } - - inline void InitAsShaderResourceView( - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - InitAsShaderResourceView(*this, shaderRegister, registerSpace, flags, visibility); - } - - inline void InitAsUnorderedAccessView( - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - InitAsUnorderedAccessView(*this, shaderRegister, registerSpace, flags, visibility); - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC : public D3D12_VERSIONED_ROOT_SIGNATURE_DESC -{ - CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC() = default; - explicit CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC &o) noexcept : - D3D12_VERSIONED_ROOT_SIGNATURE_DESC(o) - {} - explicit CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC(const D3D12_ROOT_SIGNATURE_DESC &o) noexcept - { - Version = D3D_ROOT_SIGNATURE_VERSION_1_0; - Desc_1_0 = o; - } - explicit CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC(const D3D12_ROOT_SIGNATURE_DESC1 &o) noexcept - { - Version = D3D_ROOT_SIGNATURE_VERSION_1_1; - Desc_1_1 = o; - } - CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC( - UINT numParameters, - _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters, - UINT numStaticSamplers = 0, - _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, - D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept - { - Init_1_0(numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags); - } - CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC( - UINT numParameters, - _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER1* _pParameters, - UINT numStaticSamplers = 0, - _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, - D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept - { - Init_1_1(numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags); - } - CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC(CD3DX12_DEFAULT) noexcept - { - Init_1_1(0, nullptr, 0, nullptr, D3D12_ROOT_SIGNATURE_FLAG_NONE); - } - - inline void Init_1_0( - UINT numParameters, - _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters, - UINT numStaticSamplers = 0, - _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, - D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept - { - Init_1_0(*this, numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags); - } - - static inline void Init_1_0( - _Out_ D3D12_VERSIONED_ROOT_SIGNATURE_DESC &desc, - UINT numParameters, - _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters, - UINT numStaticSamplers = 0, - _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, - D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept - { - desc.Version = D3D_ROOT_SIGNATURE_VERSION_1_0; - desc.Desc_1_0.NumParameters = numParameters; - desc.Desc_1_0.pParameters = _pParameters; - desc.Desc_1_0.NumStaticSamplers = numStaticSamplers; - desc.Desc_1_0.pStaticSamplers = _pStaticSamplers; - desc.Desc_1_0.Flags = flags; - } - - inline void Init_1_1( - UINT numParameters, - _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER1* _pParameters, - UINT numStaticSamplers = 0, - _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, - D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept - { - Init_1_1(*this, numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags); - } - - static inline void Init_1_1( - _Out_ D3D12_VERSIONED_ROOT_SIGNATURE_DESC &desc, - UINT numParameters, - _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER1* _pParameters, - UINT numStaticSamplers = 0, - _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, - D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept - { - desc.Version = D3D_ROOT_SIGNATURE_VERSION_1_1; - desc.Desc_1_1.NumParameters = numParameters; - desc.Desc_1_1.pParameters = _pParameters; - desc.Desc_1_1.NumStaticSamplers = numStaticSamplers; - desc.Desc_1_1.pStaticSamplers = _pStaticSamplers; - desc.Desc_1_1.Flags = flags; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_CPU_DESCRIPTOR_HANDLE : public D3D12_CPU_DESCRIPTOR_HANDLE -{ - CD3DX12_CPU_DESCRIPTOR_HANDLE() = default; - explicit CD3DX12_CPU_DESCRIPTOR_HANDLE(const D3D12_CPU_DESCRIPTOR_HANDLE &o) noexcept : - D3D12_CPU_DESCRIPTOR_HANDLE(o) - {} - CD3DX12_CPU_DESCRIPTOR_HANDLE(CD3DX12_DEFAULT) noexcept { ptr = 0; } - CD3DX12_CPU_DESCRIPTOR_HANDLE(_In_ const D3D12_CPU_DESCRIPTOR_HANDLE &other, INT offsetScaledByIncrementSize) noexcept - { - InitOffsetted(other, offsetScaledByIncrementSize); - } - CD3DX12_CPU_DESCRIPTOR_HANDLE(_In_ const D3D12_CPU_DESCRIPTOR_HANDLE &other, INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept - { - InitOffsetted(other, offsetInDescriptors, descriptorIncrementSize); - } - CD3DX12_CPU_DESCRIPTOR_HANDLE& Offset(INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept - { - ptr = SIZE_T(INT64(ptr) + INT64(offsetInDescriptors) * INT64(descriptorIncrementSize)); - return *this; - } - CD3DX12_CPU_DESCRIPTOR_HANDLE& Offset(INT offsetScaledByIncrementSize) noexcept - { - ptr = SIZE_T(INT64(ptr) + INT64(offsetScaledByIncrementSize)); - return *this; - } - bool operator==(_In_ const D3D12_CPU_DESCRIPTOR_HANDLE& other) const noexcept - { - return (ptr == other.ptr); - } - bool operator!=(_In_ const D3D12_CPU_DESCRIPTOR_HANDLE& other) const noexcept - { - return (ptr != other.ptr); - } - CD3DX12_CPU_DESCRIPTOR_HANDLE &operator=(const D3D12_CPU_DESCRIPTOR_HANDLE &other) noexcept - { - ptr = other.ptr; - return *this; - } - - inline void InitOffsetted(_In_ const D3D12_CPU_DESCRIPTOR_HANDLE &base, INT offsetScaledByIncrementSize) noexcept - { - InitOffsetted(*this, base, offsetScaledByIncrementSize); - } - - inline void InitOffsetted(_In_ const D3D12_CPU_DESCRIPTOR_HANDLE &base, INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept - { - InitOffsetted(*this, base, offsetInDescriptors, descriptorIncrementSize); - } - - static inline void InitOffsetted(_Out_ D3D12_CPU_DESCRIPTOR_HANDLE &handle, _In_ const D3D12_CPU_DESCRIPTOR_HANDLE &base, INT offsetScaledByIncrementSize) noexcept - { - handle.ptr = SIZE_T(INT64(base.ptr) + INT64(offsetScaledByIncrementSize)); - } - - static inline void InitOffsetted(_Out_ D3D12_CPU_DESCRIPTOR_HANDLE &handle, _In_ const D3D12_CPU_DESCRIPTOR_HANDLE &base, INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept - { - handle.ptr = SIZE_T(INT64(base.ptr) + INT64(offsetInDescriptors) * INT64(descriptorIncrementSize)); - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_GPU_DESCRIPTOR_HANDLE : public D3D12_GPU_DESCRIPTOR_HANDLE -{ - CD3DX12_GPU_DESCRIPTOR_HANDLE() = default; - explicit CD3DX12_GPU_DESCRIPTOR_HANDLE(const D3D12_GPU_DESCRIPTOR_HANDLE &o) noexcept : - D3D12_GPU_DESCRIPTOR_HANDLE(o) - {} - CD3DX12_GPU_DESCRIPTOR_HANDLE(CD3DX12_DEFAULT) noexcept { ptr = 0; } - CD3DX12_GPU_DESCRIPTOR_HANDLE(_In_ const D3D12_GPU_DESCRIPTOR_HANDLE &other, INT offsetScaledByIncrementSize) noexcept - { - InitOffsetted(other, offsetScaledByIncrementSize); - } - CD3DX12_GPU_DESCRIPTOR_HANDLE(_In_ const D3D12_GPU_DESCRIPTOR_HANDLE &other, INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept - { - InitOffsetted(other, offsetInDescriptors, descriptorIncrementSize); - } - CD3DX12_GPU_DESCRIPTOR_HANDLE& Offset(INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept - { - ptr = UINT64(INT64(ptr) + INT64(offsetInDescriptors) * INT64(descriptorIncrementSize)); - return *this; - } - CD3DX12_GPU_DESCRIPTOR_HANDLE& Offset(INT offsetScaledByIncrementSize) noexcept - { - ptr = UINT64(INT64(ptr) + INT64(offsetScaledByIncrementSize)); - return *this; - } - inline bool operator==(_In_ const D3D12_GPU_DESCRIPTOR_HANDLE& other) const noexcept - { - return (ptr == other.ptr); - } - inline bool operator!=(_In_ const D3D12_GPU_DESCRIPTOR_HANDLE& other) const noexcept - { - return (ptr != other.ptr); - } - CD3DX12_GPU_DESCRIPTOR_HANDLE &operator=(const D3D12_GPU_DESCRIPTOR_HANDLE &other) noexcept - { - ptr = other.ptr; - return *this; - } - - inline void InitOffsetted(_In_ const D3D12_GPU_DESCRIPTOR_HANDLE &base, INT offsetScaledByIncrementSize) noexcept - { - InitOffsetted(*this, base, offsetScaledByIncrementSize); - } - - inline void InitOffsetted(_In_ const D3D12_GPU_DESCRIPTOR_HANDLE &base, INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept - { - InitOffsetted(*this, base, offsetInDescriptors, descriptorIncrementSize); - } - - static inline void InitOffsetted(_Out_ D3D12_GPU_DESCRIPTOR_HANDLE &handle, _In_ const D3D12_GPU_DESCRIPTOR_HANDLE &base, INT offsetScaledByIncrementSize) noexcept - { - handle.ptr = UINT64(INT64(base.ptr) + INT64(offsetScaledByIncrementSize)); - } - - static inline void InitOffsetted(_Out_ D3D12_GPU_DESCRIPTOR_HANDLE &handle, _In_ const D3D12_GPU_DESCRIPTOR_HANDLE &base, INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept - { - handle.ptr = UINT64(INT64(base.ptr) + INT64(offsetInDescriptors) * INT64(descriptorIncrementSize)); - } -}; - -//------------------------------------------------------------------------------------------------ -inline constexpr UINT D3D12CalcSubresource( UINT MipSlice, UINT ArraySlice, UINT PlaneSlice, UINT MipLevels, UINT ArraySize ) noexcept -{ - return MipSlice + ArraySlice * MipLevels + PlaneSlice * MipLevels * ArraySize; -} - -//------------------------------------------------------------------------------------------------ -template -inline void D3D12DecomposeSubresource( UINT Subresource, UINT MipLevels, UINT ArraySize, _Out_ T& MipSlice, _Out_ U& ArraySlice, _Out_ V& PlaneSlice ) noexcept -{ - MipSlice = static_cast(Subresource % MipLevels); - ArraySlice = static_cast((Subresource / MipLevels) % ArraySize); - PlaneSlice = static_cast(Subresource / (MipLevels * ArraySize)); -} - -//------------------------------------------------------------------------------------------------ -inline UINT8 D3D12GetFormatPlaneCount( - _In_ ID3D12Device* pDevice, - DXGI_FORMAT Format - ) noexcept -{ - D3D12_FEATURE_DATA_FORMAT_INFO formatInfo = { Format, 0 }; - if (FAILED(pDevice->CheckFeatureSupport(D3D12_FEATURE_FORMAT_INFO, &formatInfo, sizeof(formatInfo)))) - { - return 0; - } - return formatInfo.PlaneCount; -} - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_RESOURCE_DESC : public D3D12_RESOURCE_DESC -{ - CD3DX12_RESOURCE_DESC() = default; - explicit CD3DX12_RESOURCE_DESC( const D3D12_RESOURCE_DESC& o ) noexcept : - D3D12_RESOURCE_DESC( o ) - {} - CD3DX12_RESOURCE_DESC( - D3D12_RESOURCE_DIMENSION dimension, - UINT64 alignment, - UINT64 width, - UINT height, - UINT16 depthOrArraySize, - UINT16 mipLevels, - DXGI_FORMAT format, - UINT sampleCount, - UINT sampleQuality, - D3D12_TEXTURE_LAYOUT layout, - D3D12_RESOURCE_FLAGS flags ) noexcept - { - Dimension = dimension; - Alignment = alignment; - Width = width; - Height = height; - DepthOrArraySize = depthOrArraySize; - MipLevels = mipLevels; - Format = format; - SampleDesc.Count = sampleCount; - SampleDesc.Quality = sampleQuality; - Layout = layout; - Flags = flags; - } - static inline CD3DX12_RESOURCE_DESC Buffer( - const D3D12_RESOURCE_ALLOCATION_INFO& resAllocInfo, - D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE ) noexcept - { - return CD3DX12_RESOURCE_DESC( D3D12_RESOURCE_DIMENSION_BUFFER, resAllocInfo.Alignment, resAllocInfo.SizeInBytes, - 1, 1, 1, DXGI_FORMAT_UNKNOWN, 1, 0, D3D12_TEXTURE_LAYOUT_ROW_MAJOR, flags ); - } - static inline CD3DX12_RESOURCE_DESC Buffer( - UINT64 width, - D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, - UINT64 alignment = 0 ) noexcept - { - return CD3DX12_RESOURCE_DESC( D3D12_RESOURCE_DIMENSION_BUFFER, alignment, width, 1, 1, 1, - DXGI_FORMAT_UNKNOWN, 1, 0, D3D12_TEXTURE_LAYOUT_ROW_MAJOR, flags ); - } - static inline CD3DX12_RESOURCE_DESC Tex1D( - DXGI_FORMAT format, - UINT64 width, - UINT16 arraySize = 1, - UINT16 mipLevels = 0, - D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, - D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, - UINT64 alignment = 0 ) noexcept - { - return CD3DX12_RESOURCE_DESC( D3D12_RESOURCE_DIMENSION_TEXTURE1D, alignment, width, 1, arraySize, - mipLevels, format, 1, 0, layout, flags ); - } - static inline CD3DX12_RESOURCE_DESC Tex2D( - DXGI_FORMAT format, - UINT64 width, - UINT height, - UINT16 arraySize = 1, - UINT16 mipLevels = 0, - UINT sampleCount = 1, - UINT sampleQuality = 0, - D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, - D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, - UINT64 alignment = 0 ) noexcept - { - return CD3DX12_RESOURCE_DESC( D3D12_RESOURCE_DIMENSION_TEXTURE2D, alignment, width, height, arraySize, - mipLevels, format, sampleCount, sampleQuality, layout, flags ); - } - static inline CD3DX12_RESOURCE_DESC Tex3D( - DXGI_FORMAT format, - UINT64 width, - UINT height, - UINT16 depth, - UINT16 mipLevels = 0, - D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, - D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, - UINT64 alignment = 0 ) noexcept - { - return CD3DX12_RESOURCE_DESC( D3D12_RESOURCE_DIMENSION_TEXTURE3D, alignment, width, height, depth, - mipLevels, format, 1, 0, layout, flags ); - } - inline UINT16 Depth() const noexcept - { return (Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D ? DepthOrArraySize : 1); } - inline UINT16 ArraySize() const noexcept - { return (Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE3D ? DepthOrArraySize : 1); } - inline UINT8 PlaneCount(_In_ ID3D12Device* pDevice) const noexcept - { return D3D12GetFormatPlaneCount(pDevice, Format); } - inline UINT Subresources(_In_ ID3D12Device* pDevice) const noexcept - { return MipLevels * ArraySize() * PlaneCount(pDevice); } - inline UINT CalcSubresource(UINT MipSlice, UINT ArraySlice, UINT PlaneSlice) noexcept - { return D3D12CalcSubresource(MipSlice, ArraySlice, PlaneSlice, MipLevels, ArraySize()); } -}; -inline bool operator==( const D3D12_RESOURCE_DESC& l, const D3D12_RESOURCE_DESC& r ) noexcept -{ - return l.Dimension == r.Dimension && - l.Alignment == r.Alignment && - l.Width == r.Width && - l.Height == r.Height && - l.DepthOrArraySize == r.DepthOrArraySize && - l.MipLevels == r.MipLevels && - l.Format == r.Format && - l.SampleDesc.Count == r.SampleDesc.Count && - l.SampleDesc.Quality == r.SampleDesc.Quality && - l.Layout == r.Layout && - l.Flags == r.Flags; -} -inline bool operator!=( const D3D12_RESOURCE_DESC& l, const D3D12_RESOURCE_DESC& r ) noexcept -{ return !( l == r ); } - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_RESOURCE_DESC1 : public D3D12_RESOURCE_DESC1 -{ - CD3DX12_RESOURCE_DESC1() = default; - explicit CD3DX12_RESOURCE_DESC1( const D3D12_RESOURCE_DESC1& o ) noexcept : - D3D12_RESOURCE_DESC1( o ) - {} - CD3DX12_RESOURCE_DESC1( - D3D12_RESOURCE_DIMENSION dimension, - UINT64 alignment, - UINT64 width, - UINT height, - UINT16 depthOrArraySize, - UINT16 mipLevels, - DXGI_FORMAT format, - UINT sampleCount, - UINT sampleQuality, - D3D12_TEXTURE_LAYOUT layout, - D3D12_RESOURCE_FLAGS flags, - UINT samplerFeedbackMipRegionWidth = 0, - UINT samplerFeedbackMipRegionHeight = 0, - UINT samplerFeedbackMipRegionDepth = 0) noexcept - { - Dimension = dimension; - Alignment = alignment; - Width = width; - Height = height; - DepthOrArraySize = depthOrArraySize; - MipLevels = mipLevels; - Format = format; - SampleDesc.Count = sampleCount; - SampleDesc.Quality = sampleQuality; - Layout = layout; - Flags = flags; - SamplerFeedbackMipRegion.Width = samplerFeedbackMipRegionWidth; - SamplerFeedbackMipRegion.Height = samplerFeedbackMipRegionHeight; - SamplerFeedbackMipRegion.Depth = samplerFeedbackMipRegionDepth; - } - static inline CD3DX12_RESOURCE_DESC1 Buffer( - const D3D12_RESOURCE_ALLOCATION_INFO& resAllocInfo, - D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE ) noexcept - { - return CD3DX12_RESOURCE_DESC1( D3D12_RESOURCE_DIMENSION_BUFFER, resAllocInfo.Alignment, resAllocInfo.SizeInBytes, - 1, 1, 1, DXGI_FORMAT_UNKNOWN, 1, 0, D3D12_TEXTURE_LAYOUT_ROW_MAJOR, flags, 0, 0, 0 ); - } - static inline CD3DX12_RESOURCE_DESC1 Buffer( - UINT64 width, - D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, - UINT64 alignment = 0 ) noexcept - { - return CD3DX12_RESOURCE_DESC1( D3D12_RESOURCE_DIMENSION_BUFFER, alignment, width, 1, 1, 1, - DXGI_FORMAT_UNKNOWN, 1, 0, D3D12_TEXTURE_LAYOUT_ROW_MAJOR, flags, 0, 0, 0 ); - } - static inline CD3DX12_RESOURCE_DESC1 Tex1D( - DXGI_FORMAT format, - UINT64 width, - UINT16 arraySize = 1, - UINT16 mipLevels = 0, - D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, - D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, - UINT64 alignment = 0 ) noexcept - { - return CD3DX12_RESOURCE_DESC1( D3D12_RESOURCE_DIMENSION_TEXTURE1D, alignment, width, 1, arraySize, - mipLevels, format, 1, 0, layout, flags, 0, 0, 0 ); - } - static inline CD3DX12_RESOURCE_DESC1 Tex2D( - DXGI_FORMAT format, - UINT64 width, - UINT height, - UINT16 arraySize = 1, - UINT16 mipLevels = 0, - UINT sampleCount = 1, - UINT sampleQuality = 0, - D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, - D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, - UINT64 alignment = 0, - UINT samplerFeedbackMipRegionWidth = 0, - UINT samplerFeedbackMipRegionHeight = 0, - UINT samplerFeedbackMipRegionDepth = 0) noexcept - { - return CD3DX12_RESOURCE_DESC1( D3D12_RESOURCE_DIMENSION_TEXTURE2D, alignment, width, height, arraySize, - mipLevels, format, sampleCount, sampleQuality, layout, flags, samplerFeedbackMipRegionWidth, - samplerFeedbackMipRegionHeight, samplerFeedbackMipRegionDepth ); - } - static inline CD3DX12_RESOURCE_DESC1 Tex3D( - DXGI_FORMAT format, - UINT64 width, - UINT height, - UINT16 depth, - UINT16 mipLevels = 0, - D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, - D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, - UINT64 alignment = 0 ) noexcept - { - return CD3DX12_RESOURCE_DESC1( D3D12_RESOURCE_DIMENSION_TEXTURE3D, alignment, width, height, depth, - mipLevels, format, 1, 0, layout, flags, 0, 0, 0 ); - } - inline UINT16 Depth() const noexcept - { return (Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D ? DepthOrArraySize : 1); } - inline UINT16 ArraySize() const noexcept - { return (Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE3D ? DepthOrArraySize : 1); } - inline UINT8 PlaneCount(_In_ ID3D12Device* pDevice) const noexcept - { return D3D12GetFormatPlaneCount(pDevice, Format); } - inline UINT Subresources(_In_ ID3D12Device* pDevice) const noexcept - { return MipLevels * ArraySize() * PlaneCount(pDevice); } - inline UINT CalcSubresource(UINT MipSlice, UINT ArraySlice, UINT PlaneSlice) noexcept - { return D3D12CalcSubresource(MipSlice, ArraySlice, PlaneSlice, MipLevels, ArraySize()); } -}; -inline bool operator==( const D3D12_RESOURCE_DESC1& l, const D3D12_RESOURCE_DESC1& r ) noexcept -{ - return l.Dimension == r.Dimension && - l.Alignment == r.Alignment && - l.Width == r.Width && - l.Height == r.Height && - l.DepthOrArraySize == r.DepthOrArraySize && - l.MipLevels == r.MipLevels && - l.Format == r.Format && - l.SampleDesc.Count == r.SampleDesc.Count && - l.SampleDesc.Quality == r.SampleDesc.Quality && - l.Layout == r.Layout && - l.Flags == r.Flags && - l.SamplerFeedbackMipRegion.Width == r.SamplerFeedbackMipRegion.Width && - l.SamplerFeedbackMipRegion.Height == r.SamplerFeedbackMipRegion.Height && - l.SamplerFeedbackMipRegion.Depth == r.SamplerFeedbackMipRegion.Depth; -} -inline bool operator!=( const D3D12_RESOURCE_DESC1& l, const D3D12_RESOURCE_DESC1& r ) noexcept -{ return !( l == r ); } - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_VIEW_INSTANCING_DESC : public D3D12_VIEW_INSTANCING_DESC -{ - CD3DX12_VIEW_INSTANCING_DESC() = default; - explicit CD3DX12_VIEW_INSTANCING_DESC( const D3D12_VIEW_INSTANCING_DESC& o ) noexcept : - D3D12_VIEW_INSTANCING_DESC( o ) - {} - explicit CD3DX12_VIEW_INSTANCING_DESC( CD3DX12_DEFAULT ) noexcept - { - ViewInstanceCount = 0; - pViewInstanceLocations = nullptr; - Flags = D3D12_VIEW_INSTANCING_FLAG_NONE; - } - explicit CD3DX12_VIEW_INSTANCING_DESC( - UINT InViewInstanceCount, - const D3D12_VIEW_INSTANCE_LOCATION* InViewInstanceLocations, - D3D12_VIEW_INSTANCING_FLAGS InFlags) noexcept - { - ViewInstanceCount = InViewInstanceCount; - pViewInstanceLocations = InViewInstanceLocations; - Flags = InFlags; - } -}; - -//------------------------------------------------------------------------------------------------ -// Row-by-row memcpy -inline void MemcpySubresource( - _In_ const D3D12_MEMCPY_DEST* pDest, - _In_ const D3D12_SUBRESOURCE_DATA* pSrc, - SIZE_T RowSizeInBytes, - UINT NumRows, - UINT NumSlices) noexcept -{ - for (UINT z = 0; z < NumSlices; ++z) - { - auto pDestSlice = static_cast(pDest->pData) + pDest->SlicePitch * z; - auto pSrcSlice = static_cast(pSrc->pData) + pSrc->SlicePitch * LONG_PTR(z); - for (UINT y = 0; y < NumRows; ++y) - { - memcpy(pDestSlice + pDest->RowPitch * y, - pSrcSlice + pSrc->RowPitch * LONG_PTR(y), - RowSizeInBytes); - } - } -} - -//------------------------------------------------------------------------------------------------ -// Row-by-row memcpy -inline void MemcpySubresource( - _In_ const D3D12_MEMCPY_DEST* pDest, - _In_ const void* pResourceData, - _In_ const D3D12_SUBRESOURCE_INFO* pSrc, - SIZE_T RowSizeInBytes, - UINT NumRows, - UINT NumSlices) noexcept -{ - for (UINT z = 0; z < NumSlices; ++z) - { - auto pDestSlice = static_cast(pDest->pData) + pDest->SlicePitch * z; - auto pSrcSlice = (static_cast(pResourceData) + pSrc->Offset) + pSrc->DepthPitch * ULONG_PTR(z); - for (UINT y = 0; y < NumRows; ++y) - { - memcpy(pDestSlice + pDest->RowPitch * y, - pSrcSlice + pSrc->RowPitch * ULONG_PTR(y), - RowSizeInBytes); - } - } -} - -//------------------------------------------------------------------------------------------------ -// Returns required size of a buffer to be used for data upload -inline UINT64 GetRequiredIntermediateSize( - _In_ ID3D12Resource* pDestinationResource, - _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, - _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources) noexcept -{ - auto Desc = pDestinationResource->GetDesc(); - UINT64 RequiredSize = 0; - - ID3D12Device* pDevice = nullptr; - pDestinationResource->GetDevice(IID_ID3D12Device, reinterpret_cast(&pDevice)); - pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, 0, nullptr, nullptr, nullptr, &RequiredSize); - pDevice->Release(); - - return RequiredSize; -} - -//------------------------------------------------------------------------------------------------ -// All arrays must be populated (e.g. by calling GetCopyableFootprints) -inline UINT64 UpdateSubresources( - _In_ ID3D12GraphicsCommandList* pCmdList, - _In_ ID3D12Resource* pDestinationResource, - _In_ ID3D12Resource* pIntermediate, - _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, - _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, - UINT64 RequiredSize, - _In_reads_(NumSubresources) const D3D12_PLACED_SUBRESOURCE_FOOTPRINT* pLayouts, - _In_reads_(NumSubresources) const UINT* pNumRows, - _In_reads_(NumSubresources) const UINT64* pRowSizesInBytes, - _In_reads_(NumSubresources) const D3D12_SUBRESOURCE_DATA* pSrcData) noexcept -{ - // Minor validation - auto IntermediateDesc = pIntermediate->GetDesc(); - auto DestinationDesc = pDestinationResource->GetDesc(); - if (IntermediateDesc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER || - IntermediateDesc.Width < RequiredSize + pLayouts[0].Offset || - RequiredSize > SIZE_T(-1) || - (DestinationDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER && - (FirstSubresource != 0 || NumSubresources != 1))) - { - return 0; - } - - BYTE* pData; - HRESULT hr = pIntermediate->Map(0, nullptr, reinterpret_cast(&pData)); - if (FAILED(hr)) - { - return 0; - } - - for (UINT i = 0; i < NumSubresources; ++i) - { - if (pRowSizesInBytes[i] > SIZE_T(-1)) return 0; - D3D12_MEMCPY_DEST DestData = { pData + pLayouts[i].Offset, pLayouts[i].Footprint.RowPitch, SIZE_T(pLayouts[i].Footprint.RowPitch) * SIZE_T(pNumRows[i]) }; - MemcpySubresource(&DestData, &pSrcData[i], static_cast(pRowSizesInBytes[i]), pNumRows[i], pLayouts[i].Footprint.Depth); - } - pIntermediate->Unmap(0, nullptr); - - if (DestinationDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER) - { - pCmdList->CopyBufferRegion( - pDestinationResource, 0, pIntermediate, pLayouts[0].Offset, pLayouts[0].Footprint.Width); - } - else - { - for (UINT i = 0; i < NumSubresources; ++i) - { - CD3DX12_TEXTURE_COPY_LOCATION Dst(pDestinationResource, i + FirstSubresource); - CD3DX12_TEXTURE_COPY_LOCATION Src(pIntermediate, pLayouts[i]); - pCmdList->CopyTextureRegion(&Dst, 0, 0, 0, &Src, nullptr); - } - } - return RequiredSize; -} - -//------------------------------------------------------------------------------------------------ -// All arrays must be populated (e.g. by calling GetCopyableFootprints) -inline UINT64 UpdateSubresources( - _In_ ID3D12GraphicsCommandList* pCmdList, - _In_ ID3D12Resource* pDestinationResource, - _In_ ID3D12Resource* pIntermediate, - _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, - _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, - UINT64 RequiredSize, - _In_reads_(NumSubresources) const D3D12_PLACED_SUBRESOURCE_FOOTPRINT* pLayouts, - _In_reads_(NumSubresources) const UINT* pNumRows, - _In_reads_(NumSubresources) const UINT64* pRowSizesInBytes, - _In_ const void* pResourceData, - _In_reads_(NumSubresources) const D3D12_SUBRESOURCE_INFO* pSrcData) noexcept -{ - // Minor validation - auto IntermediateDesc = pIntermediate->GetDesc(); - auto DestinationDesc = pDestinationResource->GetDesc(); - if (IntermediateDesc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER || - IntermediateDesc.Width < RequiredSize + pLayouts[0].Offset || - RequiredSize > SIZE_T(-1) || - (DestinationDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER && - (FirstSubresource != 0 || NumSubresources != 1))) - { - return 0; - } - - BYTE* pData; - HRESULT hr = pIntermediate->Map(0, nullptr, reinterpret_cast(&pData)); - if (FAILED(hr)) - { - return 0; - } - - for (UINT i = 0; i < NumSubresources; ++i) - { - if (pRowSizesInBytes[i] > SIZE_T(-1)) return 0; - D3D12_MEMCPY_DEST DestData = { pData + pLayouts[i].Offset, pLayouts[i].Footprint.RowPitch, SIZE_T(pLayouts[i].Footprint.RowPitch) * SIZE_T(pNumRows[i]) }; - MemcpySubresource(&DestData, pResourceData, &pSrcData[i], static_cast(pRowSizesInBytes[i]), pNumRows[i], pLayouts[i].Footprint.Depth); - } - pIntermediate->Unmap(0, nullptr); - - if (DestinationDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER) - { - pCmdList->CopyBufferRegion( - pDestinationResource, 0, pIntermediate, pLayouts[0].Offset, pLayouts[0].Footprint.Width); - } - else - { - for (UINT i = 0; i < NumSubresources; ++i) - { - CD3DX12_TEXTURE_COPY_LOCATION Dst(pDestinationResource, i + FirstSubresource); - CD3DX12_TEXTURE_COPY_LOCATION Src(pIntermediate, pLayouts[i]); - pCmdList->CopyTextureRegion(&Dst, 0, 0, 0, &Src, nullptr); - } - } - return RequiredSize; -} - -//------------------------------------------------------------------------------------------------ -// Heap-allocating UpdateSubresources implementation -inline UINT64 UpdateSubresources( - _In_ ID3D12GraphicsCommandList* pCmdList, - _In_ ID3D12Resource* pDestinationResource, - _In_ ID3D12Resource* pIntermediate, - UINT64 IntermediateOffset, - _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, - _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, - _In_reads_(NumSubresources) const D3D12_SUBRESOURCE_DATA* pSrcData) noexcept -{ - UINT64 RequiredSize = 0; - auto MemToAlloc = static_cast(sizeof(D3D12_PLACED_SUBRESOURCE_FOOTPRINT) + sizeof(UINT) + sizeof(UINT64)) * NumSubresources; - if (MemToAlloc > SIZE_MAX) - { - return 0; - } - void* pMem = HeapAlloc(GetProcessHeap(), 0, static_cast(MemToAlloc)); - if (pMem == nullptr) - { - return 0; - } - auto pLayouts = static_cast(pMem); - auto pRowSizesInBytes = reinterpret_cast(pLayouts + NumSubresources); - auto pNumRows = reinterpret_cast(pRowSizesInBytes + NumSubresources); - - auto Desc = pDestinationResource->GetDesc(); - ID3D12Device* pDevice = nullptr; - pDestinationResource->GetDevice(IID_ID3D12Device, reinterpret_cast(&pDevice)); - pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, IntermediateOffset, pLayouts, pNumRows, pRowSizesInBytes, &RequiredSize); - pDevice->Release(); - - UINT64 Result = UpdateSubresources(pCmdList, pDestinationResource, pIntermediate, FirstSubresource, NumSubresources, RequiredSize, pLayouts, pNumRows, pRowSizesInBytes, pSrcData); - HeapFree(GetProcessHeap(), 0, pMem); - return Result; -} - -//------------------------------------------------------------------------------------------------ -// Heap-allocating UpdateSubresources implementation -inline UINT64 UpdateSubresources( - _In_ ID3D12GraphicsCommandList* pCmdList, - _In_ ID3D12Resource* pDestinationResource, - _In_ ID3D12Resource* pIntermediate, - UINT64 IntermediateOffset, - _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, - _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, - _In_ const void* pResourceData, - _In_reads_(NumSubresources) D3D12_SUBRESOURCE_INFO* pSrcData) noexcept -{ - UINT64 RequiredSize = 0; - auto MemToAlloc = static_cast(sizeof(D3D12_PLACED_SUBRESOURCE_FOOTPRINT) + sizeof(UINT) + sizeof(UINT64)) * NumSubresources; - if (MemToAlloc > SIZE_MAX) - { - return 0; - } - void* pMem = HeapAlloc(GetProcessHeap(), 0, static_cast(MemToAlloc)); - if (pMem == nullptr) - { - return 0; - } - auto pLayouts = reinterpret_cast(pMem); - auto pRowSizesInBytes = reinterpret_cast(pLayouts + NumSubresources); - auto pNumRows = reinterpret_cast(pRowSizesInBytes + NumSubresources); - - auto Desc = pDestinationResource->GetDesc(); - ID3D12Device* pDevice = nullptr; - pDestinationResource->GetDevice(IID_ID3D12Device, reinterpret_cast(&pDevice)); - pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, IntermediateOffset, pLayouts, pNumRows, pRowSizesInBytes, &RequiredSize); - pDevice->Release(); - - UINT64 Result = UpdateSubresources(pCmdList, pDestinationResource, pIntermediate, FirstSubresource, NumSubresources, RequiredSize, pLayouts, pNumRows, pRowSizesInBytes, pResourceData, pSrcData); - HeapFree(GetProcessHeap(), 0, pMem); - return Result; -} - -//------------------------------------------------------------------------------------------------ -// Stack-allocating UpdateSubresources implementation -template -inline UINT64 UpdateSubresources( - _In_ ID3D12GraphicsCommandList* pCmdList, - _In_ ID3D12Resource* pDestinationResource, - _In_ ID3D12Resource* pIntermediate, - UINT64 IntermediateOffset, - _In_range_(0,MaxSubresources) UINT FirstSubresource, - _In_range_(1,MaxSubresources-FirstSubresource) UINT NumSubresources, - _In_reads_(NumSubresources) const D3D12_SUBRESOURCE_DATA* pSrcData) noexcept -{ - UINT64 RequiredSize = 0; - D3D12_PLACED_SUBRESOURCE_FOOTPRINT Layouts[MaxSubresources]; - UINT NumRows[MaxSubresources]; - UINT64 RowSizesInBytes[MaxSubresources]; - - auto Desc = pDestinationResource->GetDesc(); - ID3D12Device* pDevice = nullptr; - pDestinationResource->GetDevice(IID_ID3D12Device, reinterpret_cast(&pDevice)); - pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, IntermediateOffset, Layouts, NumRows, RowSizesInBytes, &RequiredSize); - pDevice->Release(); - - return UpdateSubresources(pCmdList, pDestinationResource, pIntermediate, FirstSubresource, NumSubresources, RequiredSize, Layouts, NumRows, RowSizesInBytes, pSrcData); -} - -//------------------------------------------------------------------------------------------------ -// Stack-allocating UpdateSubresources implementation -template -inline UINT64 UpdateSubresources( - _In_ ID3D12GraphicsCommandList* pCmdList, - _In_ ID3D12Resource* pDestinationResource, - _In_ ID3D12Resource* pIntermediate, - UINT64 IntermediateOffset, - _In_range_(0,MaxSubresources) UINT FirstSubresource, - _In_range_(1,MaxSubresources-FirstSubresource) UINT NumSubresources, - _In_ const void* pResourceData, - _In_reads_(NumSubresources) D3D12_SUBRESOURCE_INFO* pSrcData) noexcept -{ - UINT64 RequiredSize = 0; - D3D12_PLACED_SUBRESOURCE_FOOTPRINT Layouts[MaxSubresources]; - UINT NumRows[MaxSubresources]; - UINT64 RowSizesInBytes[MaxSubresources]; - - auto Desc = pDestinationResource->GetDesc(); - ID3D12Device* pDevice = nullptr; - pDestinationResource->GetDevice(IID_ID3D12Device, reinterpret_cast(&pDevice)); - pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, IntermediateOffset, Layouts, NumRows, RowSizesInBytes, &RequiredSize); - pDevice->Release(); - - return UpdateSubresources(pCmdList, pDestinationResource, pIntermediate, FirstSubresource, NumSubresources, RequiredSize, Layouts, NumRows, RowSizesInBytes, pResourceData, pSrcData); -} - -//------------------------------------------------------------------------------------------------ -inline constexpr bool D3D12IsLayoutOpaque( D3D12_TEXTURE_LAYOUT Layout ) noexcept -{ return Layout == D3D12_TEXTURE_LAYOUT_UNKNOWN || Layout == D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE; } - -//------------------------------------------------------------------------------------------------ -template -inline ID3D12CommandList * const * CommandListCast(t_CommandListType * const * pp) noexcept -{ - // This cast is useful for passing strongly typed command list pointers into - // ExecuteCommandLists. - // This cast is valid as long as the const-ness is respected. D3D12 APIs do - // respect the const-ness of their arguments. - return reinterpret_cast(pp); -} - -//------------------------------------------------------------------------------------------------ -// D3D12 exports a new method for serializing root signatures in the Windows 10 Anniversary Update. -// To help enable root signature 1.1 features when they are available and not require maintaining -// two code paths for building root signatures, this helper method reconstructs a 1.0 signature when -// 1.1 is not supported. -inline HRESULT D3DX12SerializeVersionedRootSignature( - _In_ const D3D12_VERSIONED_ROOT_SIGNATURE_DESC* pRootSignatureDesc, - D3D_ROOT_SIGNATURE_VERSION MaxVersion, - _Outptr_ ID3DBlob** ppBlob, - _Always_(_Outptr_opt_result_maybenull_) ID3DBlob** ppErrorBlob) noexcept -{ - if (ppErrorBlob != nullptr) - { - *ppErrorBlob = nullptr; - } - - switch (MaxVersion) - { - case D3D_ROOT_SIGNATURE_VERSION_1_0: - switch (pRootSignatureDesc->Version) - { - case D3D_ROOT_SIGNATURE_VERSION_1_0: - return D3D12SerializeRootSignature(&pRootSignatureDesc->Desc_1_0, D3D_ROOT_SIGNATURE_VERSION_1, ppBlob, ppErrorBlob); - - case D3D_ROOT_SIGNATURE_VERSION_1_1: - { - HRESULT hr = S_OK; - const D3D12_ROOT_SIGNATURE_DESC1& desc_1_1 = pRootSignatureDesc->Desc_1_1; - - const SIZE_T ParametersSize = sizeof(D3D12_ROOT_PARAMETER) * desc_1_1.NumParameters; - void* pParameters = (ParametersSize > 0) ? HeapAlloc(GetProcessHeap(), 0, ParametersSize) : nullptr; - if (ParametersSize > 0 && pParameters == nullptr) - { - hr = E_OUTOFMEMORY; - } - auto pParameters_1_0 = static_cast(pParameters); - - if (SUCCEEDED(hr)) - { - for (UINT n = 0; n < desc_1_1.NumParameters; n++) - { - __analysis_assume(ParametersSize == sizeof(D3D12_ROOT_PARAMETER) * desc_1_1.NumParameters); - pParameters_1_0[n].ParameterType = desc_1_1.pParameters[n].ParameterType; - pParameters_1_0[n].ShaderVisibility = desc_1_1.pParameters[n].ShaderVisibility; - - switch (desc_1_1.pParameters[n].ParameterType) - { - case D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS: - pParameters_1_0[n].Constants.Num32BitValues = desc_1_1.pParameters[n].Constants.Num32BitValues; - pParameters_1_0[n].Constants.RegisterSpace = desc_1_1.pParameters[n].Constants.RegisterSpace; - pParameters_1_0[n].Constants.ShaderRegister = desc_1_1.pParameters[n].Constants.ShaderRegister; - break; - - case D3D12_ROOT_PARAMETER_TYPE_CBV: - case D3D12_ROOT_PARAMETER_TYPE_SRV: - case D3D12_ROOT_PARAMETER_TYPE_UAV: - pParameters_1_0[n].Descriptor.RegisterSpace = desc_1_1.pParameters[n].Descriptor.RegisterSpace; - pParameters_1_0[n].Descriptor.ShaderRegister = desc_1_1.pParameters[n].Descriptor.ShaderRegister; - break; - - case D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE: - const D3D12_ROOT_DESCRIPTOR_TABLE1& table_1_1 = desc_1_1.pParameters[n].DescriptorTable; - - const SIZE_T DescriptorRangesSize = sizeof(D3D12_DESCRIPTOR_RANGE) * table_1_1.NumDescriptorRanges; - void* pDescriptorRanges = (DescriptorRangesSize > 0 && SUCCEEDED(hr)) ? HeapAlloc(GetProcessHeap(), 0, DescriptorRangesSize) : nullptr; - if (DescriptorRangesSize > 0 && pDescriptorRanges == nullptr) - { - hr = E_OUTOFMEMORY; - } - auto pDescriptorRanges_1_0 = static_cast(pDescriptorRanges); - - if (SUCCEEDED(hr)) - { - for (UINT x = 0; x < table_1_1.NumDescriptorRanges; x++) - { - __analysis_assume(DescriptorRangesSize == sizeof(D3D12_DESCRIPTOR_RANGE) * table_1_1.NumDescriptorRanges); - pDescriptorRanges_1_0[x].BaseShaderRegister = table_1_1.pDescriptorRanges[x].BaseShaderRegister; - pDescriptorRanges_1_0[x].NumDescriptors = table_1_1.pDescriptorRanges[x].NumDescriptors; - pDescriptorRanges_1_0[x].OffsetInDescriptorsFromTableStart = table_1_1.pDescriptorRanges[x].OffsetInDescriptorsFromTableStart; - pDescriptorRanges_1_0[x].RangeType = table_1_1.pDescriptorRanges[x].RangeType; - pDescriptorRanges_1_0[x].RegisterSpace = table_1_1.pDescriptorRanges[x].RegisterSpace; - } - } - - D3D12_ROOT_DESCRIPTOR_TABLE& table_1_0 = pParameters_1_0[n].DescriptorTable; - table_1_0.NumDescriptorRanges = table_1_1.NumDescriptorRanges; - table_1_0.pDescriptorRanges = pDescriptorRanges_1_0; - } - } - } - - if (SUCCEEDED(hr)) - { - CD3DX12_ROOT_SIGNATURE_DESC desc_1_0(desc_1_1.NumParameters, pParameters_1_0, desc_1_1.NumStaticSamplers, desc_1_1.pStaticSamplers, desc_1_1.Flags); - hr = D3D12SerializeRootSignature(&desc_1_0, D3D_ROOT_SIGNATURE_VERSION_1, ppBlob, ppErrorBlob); - } - - if (pParameters) - { - for (UINT n = 0; n < desc_1_1.NumParameters; n++) - { - if (desc_1_1.pParameters[n].ParameterType == D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE) - { - HeapFree(GetProcessHeap(), 0, reinterpret_cast(const_cast(pParameters_1_0[n].DescriptorTable.pDescriptorRanges))); - } - } - HeapFree(GetProcessHeap(), 0, pParameters); - } - return hr; - } - } - break; - - case D3D_ROOT_SIGNATURE_VERSION_1_1: - return D3D12SerializeVersionedRootSignature(pRootSignatureDesc, ppBlob, ppErrorBlob); - } - - return E_INVALIDARG; -} - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_RT_FORMAT_ARRAY : public D3D12_RT_FORMAT_ARRAY -{ - CD3DX12_RT_FORMAT_ARRAY() = default; - explicit CD3DX12_RT_FORMAT_ARRAY(const D3D12_RT_FORMAT_ARRAY& o) noexcept - : D3D12_RT_FORMAT_ARRAY(o) - {} - explicit CD3DX12_RT_FORMAT_ARRAY(_In_reads_(NumFormats) const DXGI_FORMAT* pFormats, UINT NumFormats) noexcept - { - NumRenderTargets = NumFormats; - memcpy(RTFormats, pFormats, sizeof(RTFormats)); - // assumes ARRAY_SIZE(pFormats) == ARRAY_SIZE(RTFormats) - } -}; - -//------------------------------------------------------------------------------------------------ -// Pipeline State Stream Helpers -//------------------------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------------------------ -// Stream Subobjects, i.e. elements of a stream - -struct DefaultSampleMask { operator UINT() noexcept { return UINT_MAX; } }; -struct DefaultSampleDesc { operator DXGI_SAMPLE_DESC() noexcept { return DXGI_SAMPLE_DESC{1, 0}; } }; - -#pragma warning(push) -#pragma warning(disable : 4324) -template -class alignas(void*) CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT -{ -private: - D3D12_PIPELINE_STATE_SUBOBJECT_TYPE _Type; - InnerStructType _Inner; -public: - CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT() noexcept : _Type(Type), _Inner(DefaultArg()) {} - CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT(InnerStructType const& i) noexcept : _Type(Type), _Inner(i) {} - CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT& operator=(InnerStructType const& i) noexcept { _Type = Type; _Inner = i; return *this; } - operator InnerStructType const&() const noexcept { return _Inner; } - operator InnerStructType&() noexcept { return _Inner; } - InnerStructType* operator&() noexcept { return &_Inner; } - InnerStructType const* operator&() const noexcept { return &_Inner; } -}; -#pragma warning(pop) -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_PIPELINE_STATE_FLAGS, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_FLAGS> CD3DX12_PIPELINE_STATE_STREAM_FLAGS; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< UINT, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_NODE_MASK> CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< ID3D12RootSignature*, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_ROOT_SIGNATURE> CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_INPUT_LAYOUT_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_INPUT_LAYOUT> CD3DX12_PIPELINE_STATE_STREAM_INPUT_LAYOUT; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_INDEX_BUFFER_STRIP_CUT_VALUE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_IB_STRIP_CUT_VALUE> CD3DX12_PIPELINE_STATE_STREAM_IB_STRIP_CUT_VALUE; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_PRIMITIVE_TOPOLOGY_TYPE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PRIMITIVE_TOPOLOGY> CD3DX12_PIPELINE_STATE_STREAM_PRIMITIVE_TOPOLOGY; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VS> CD3DX12_PIPELINE_STATE_STREAM_VS; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_GS> CD3DX12_PIPELINE_STATE_STREAM_GS; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_STREAM_OUTPUT_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_STREAM_OUTPUT> CD3DX12_PIPELINE_STATE_STREAM_STREAM_OUTPUT; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_HS> CD3DX12_PIPELINE_STATE_STREAM_HS; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DS> CD3DX12_PIPELINE_STATE_STREAM_DS; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PS> CD3DX12_PIPELINE_STATE_STREAM_PS; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_AS> CD3DX12_PIPELINE_STATE_STREAM_AS; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MS> CD3DX12_PIPELINE_STATE_STREAM_MS; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CS> CD3DX12_PIPELINE_STATE_STREAM_CS; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_BLEND_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_BLEND, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_DEPTH_STENCIL_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_DEPTH_STENCIL_DESC1, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL1; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< DXGI_FORMAT, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL_FORMAT> CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL_FORMAT; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_RASTERIZER_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_RT_FORMAT_ARRAY, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RENDER_TARGET_FORMATS> CD3DX12_PIPELINE_STATE_STREAM_RENDER_TARGET_FORMATS; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< DXGI_SAMPLE_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_DESC, DefaultSampleDesc> CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_DESC; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< UINT, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_MASK, DefaultSampleMask> CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_MASK; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_CACHED_PIPELINE_STATE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CACHED_PSO> CD3DX12_PIPELINE_STATE_STREAM_CACHED_PSO; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_VIEW_INSTANCING_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VIEW_INSTANCING, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_VIEW_INSTANCING; - -//------------------------------------------------------------------------------------------------ -// Stream Parser Helpers - -struct ID3DX12PipelineParserCallbacks -{ - // Subobject Callbacks - virtual void FlagsCb(D3D12_PIPELINE_STATE_FLAGS) {} - virtual void NodeMaskCb(UINT) {} - virtual void RootSignatureCb(ID3D12RootSignature*) {} - virtual void InputLayoutCb(const D3D12_INPUT_LAYOUT_DESC&) {} - virtual void IBStripCutValueCb(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE) {} - virtual void PrimitiveTopologyTypeCb(D3D12_PRIMITIVE_TOPOLOGY_TYPE) {} - virtual void VSCb(const D3D12_SHADER_BYTECODE&) {} - virtual void GSCb(const D3D12_SHADER_BYTECODE&) {} - virtual void StreamOutputCb(const D3D12_STREAM_OUTPUT_DESC&) {} - virtual void HSCb(const D3D12_SHADER_BYTECODE&) {} - virtual void DSCb(const D3D12_SHADER_BYTECODE&) {} - virtual void PSCb(const D3D12_SHADER_BYTECODE&) {} - virtual void CSCb(const D3D12_SHADER_BYTECODE&) {} - virtual void ASCb(const D3D12_SHADER_BYTECODE&) {} - virtual void MSCb(const D3D12_SHADER_BYTECODE&) {} - virtual void BlendStateCb(const D3D12_BLEND_DESC&) {} - virtual void DepthStencilStateCb(const D3D12_DEPTH_STENCIL_DESC&) {} - virtual void DepthStencilState1Cb(const D3D12_DEPTH_STENCIL_DESC1&) {} - virtual void DSVFormatCb(DXGI_FORMAT) {} - virtual void RasterizerStateCb(const D3D12_RASTERIZER_DESC&) {} - virtual void RTVFormatsCb(const D3D12_RT_FORMAT_ARRAY&) {} - virtual void SampleDescCb(const DXGI_SAMPLE_DESC&) {} - virtual void SampleMaskCb(UINT) {} - virtual void ViewInstancingCb(const D3D12_VIEW_INSTANCING_DESC&) {} - virtual void CachedPSOCb(const D3D12_CACHED_PIPELINE_STATE&) {} - - // Error Callbacks - virtual void ErrorBadInputParameter(UINT /*ParameterIndex*/) {} - virtual void ErrorDuplicateSubobject(D3D12_PIPELINE_STATE_SUBOBJECT_TYPE /*DuplicateType*/) {} - virtual void ErrorUnknownSubobject(UINT /*UnknownTypeValue*/) {} - - virtual ~ID3DX12PipelineParserCallbacks() = default; -}; - -struct D3DX12_MESH_SHADER_PIPELINE_STATE_DESC -{ - ID3D12RootSignature* pRootSignature; - D3D12_SHADER_BYTECODE AS; - D3D12_SHADER_BYTECODE MS; - D3D12_SHADER_BYTECODE PS; - D3D12_BLEND_DESC BlendState; - UINT SampleMask; - D3D12_RASTERIZER_DESC RasterizerState; - D3D12_DEPTH_STENCIL_DESC DepthStencilState; - D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType; - UINT NumRenderTargets; - DXGI_FORMAT RTVFormats[ D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT ]; - DXGI_FORMAT DSVFormat; - DXGI_SAMPLE_DESC SampleDesc; - UINT NodeMask; - D3D12_CACHED_PIPELINE_STATE CachedPSO; - D3D12_PIPELINE_STATE_FLAGS Flags; -}; - -// CD3DX12_PIPELINE_STATE_STREAM2 Works on OS Build 19041+ (where there is a new mesh shader pipeline). -// Use CD3DX12_PIPELINE_STATE_STREAM1 for OS Build 16299+ (where there is a new view instancing subobject). -// Use CD3DX12_PIPELINE_STATE_STREAM for OS Build 15063+ support. -struct CD3DX12_PIPELINE_STATE_STREAM2 -{ - CD3DX12_PIPELINE_STATE_STREAM2() = default; - // Mesh and amplification shaders must be set manually, since they do not have representation in D3D12_GRAPHICS_PIPELINE_STATE_DESC - CD3DX12_PIPELINE_STATE_STREAM2(const D3D12_GRAPHICS_PIPELINE_STATE_DESC& Desc) noexcept - : Flags(Desc.Flags) - , NodeMask(Desc.NodeMask) - , pRootSignature(Desc.pRootSignature) - , InputLayout(Desc.InputLayout) - , IBStripCutValue(Desc.IBStripCutValue) - , PrimitiveTopologyType(Desc.PrimitiveTopologyType) - , VS(Desc.VS) - , GS(Desc.GS) - , StreamOutput(Desc.StreamOutput) - , HS(Desc.HS) - , DS(Desc.DS) - , PS(Desc.PS) - , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) - , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC1(Desc.DepthStencilState)) - , DSVFormat(Desc.DSVFormat) - , RasterizerState(CD3DX12_RASTERIZER_DESC(Desc.RasterizerState)) - , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) - , SampleDesc(Desc.SampleDesc) - , SampleMask(Desc.SampleMask) - , CachedPSO(Desc.CachedPSO) - , ViewInstancingDesc(CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT())) - {} - CD3DX12_PIPELINE_STATE_STREAM2(const D3DX12_MESH_SHADER_PIPELINE_STATE_DESC& Desc) noexcept - : Flags(Desc.Flags) - , NodeMask(Desc.NodeMask) - , pRootSignature(Desc.pRootSignature) - , PrimitiveTopologyType(Desc.PrimitiveTopologyType) - , PS(Desc.PS) - , AS(Desc.AS) - , MS(Desc.MS) - , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) - , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC1(Desc.DepthStencilState)) - , DSVFormat(Desc.DSVFormat) - , RasterizerState(CD3DX12_RASTERIZER_DESC(Desc.RasterizerState)) - , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) - , SampleDesc(Desc.SampleDesc) - , SampleMask(Desc.SampleMask) - , CachedPSO(Desc.CachedPSO) - , ViewInstancingDesc(CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT())) - {} - CD3DX12_PIPELINE_STATE_STREAM2(const D3D12_COMPUTE_PIPELINE_STATE_DESC& Desc) noexcept - : Flags(Desc.Flags) - , NodeMask(Desc.NodeMask) - , pRootSignature(Desc.pRootSignature) - , CS(CD3DX12_SHADER_BYTECODE(Desc.CS)) - , CachedPSO(Desc.CachedPSO) - { - static_cast(DepthStencilState).DepthEnable = false; - } - CD3DX12_PIPELINE_STATE_STREAM_FLAGS Flags; - CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK NodeMask; - CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE pRootSignature; - CD3DX12_PIPELINE_STATE_STREAM_INPUT_LAYOUT InputLayout; - CD3DX12_PIPELINE_STATE_STREAM_IB_STRIP_CUT_VALUE IBStripCutValue; - CD3DX12_PIPELINE_STATE_STREAM_PRIMITIVE_TOPOLOGY PrimitiveTopologyType; - CD3DX12_PIPELINE_STATE_STREAM_VS VS; - CD3DX12_PIPELINE_STATE_STREAM_GS GS; - CD3DX12_PIPELINE_STATE_STREAM_STREAM_OUTPUT StreamOutput; - CD3DX12_PIPELINE_STATE_STREAM_HS HS; - CD3DX12_PIPELINE_STATE_STREAM_DS DS; - CD3DX12_PIPELINE_STATE_STREAM_PS PS; - CD3DX12_PIPELINE_STATE_STREAM_AS AS; - CD3DX12_PIPELINE_STATE_STREAM_MS MS; - CD3DX12_PIPELINE_STATE_STREAM_CS CS; - CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC BlendState; - CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL1 DepthStencilState; - CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL_FORMAT DSVFormat; - CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER RasterizerState; - CD3DX12_PIPELINE_STATE_STREAM_RENDER_TARGET_FORMATS RTVFormats; - CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_DESC SampleDesc; - CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_MASK SampleMask; - CD3DX12_PIPELINE_STATE_STREAM_CACHED_PSO CachedPSO; - CD3DX12_PIPELINE_STATE_STREAM_VIEW_INSTANCING ViewInstancingDesc; - D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDescV0() const noexcept - { - D3D12_GRAPHICS_PIPELINE_STATE_DESC D; - D.Flags = this->Flags; - D.NodeMask = this->NodeMask; - D.pRootSignature = this->pRootSignature; - D.InputLayout = this->InputLayout; - D.IBStripCutValue = this->IBStripCutValue; - D.PrimitiveTopologyType = this->PrimitiveTopologyType; - D.VS = this->VS; - D.GS = this->GS; - D.StreamOutput = this->StreamOutput; - D.HS = this->HS; - D.DS = this->DS; - D.PS = this->PS; - D.BlendState = this->BlendState; - D.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(D3D12_DEPTH_STENCIL_DESC1(this->DepthStencilState)); - D.DSVFormat = this->DSVFormat; - D.RasterizerState = this->RasterizerState; - D.NumRenderTargets = D3D12_RT_FORMAT_ARRAY(this->RTVFormats).NumRenderTargets; - memcpy(D.RTVFormats, D3D12_RT_FORMAT_ARRAY(this->RTVFormats).RTFormats, sizeof(D.RTVFormats)); - D.SampleDesc = this->SampleDesc; - D.SampleMask = this->SampleMask; - D.CachedPSO = this->CachedPSO; - return D; - } - D3D12_COMPUTE_PIPELINE_STATE_DESC ComputeDescV0() const noexcept - { - D3D12_COMPUTE_PIPELINE_STATE_DESC D; - D.Flags = this->Flags; - D.NodeMask = this->NodeMask; - D.pRootSignature = this->pRootSignature; - D.CS = this->CS; - D.CachedPSO = this->CachedPSO; - return D; - } -}; - -// CD3DX12_PIPELINE_STATE_STREAM1 Works on OS Build 16299+ (where there is a new view instancing subobject). -// Use CD3DX12_PIPELINE_STATE_STREAM for OS Build 15063+ support. -struct CD3DX12_PIPELINE_STATE_STREAM1 -{ - CD3DX12_PIPELINE_STATE_STREAM1() = default; - // Mesh and amplification shaders must be set manually, since they do not have representation in D3D12_GRAPHICS_PIPELINE_STATE_DESC - CD3DX12_PIPELINE_STATE_STREAM1(const D3D12_GRAPHICS_PIPELINE_STATE_DESC& Desc) noexcept - : Flags(Desc.Flags) - , NodeMask(Desc.NodeMask) - , pRootSignature(Desc.pRootSignature) - , InputLayout(Desc.InputLayout) - , IBStripCutValue(Desc.IBStripCutValue) - , PrimitiveTopologyType(Desc.PrimitiveTopologyType) - , VS(Desc.VS) - , GS(Desc.GS) - , StreamOutput(Desc.StreamOutput) - , HS(Desc.HS) - , DS(Desc.DS) - , PS(Desc.PS) - , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) - , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC1(Desc.DepthStencilState)) - , DSVFormat(Desc.DSVFormat) - , RasterizerState(CD3DX12_RASTERIZER_DESC(Desc.RasterizerState)) - , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) - , SampleDesc(Desc.SampleDesc) - , SampleMask(Desc.SampleMask) - , CachedPSO(Desc.CachedPSO) - , ViewInstancingDesc(CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT())) - {} - CD3DX12_PIPELINE_STATE_STREAM1(const D3DX12_MESH_SHADER_PIPELINE_STATE_DESC& Desc) noexcept - : Flags(Desc.Flags) - , NodeMask(Desc.NodeMask) - , pRootSignature(Desc.pRootSignature) - , PrimitiveTopologyType(Desc.PrimitiveTopologyType) - , PS(Desc.PS) - , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) - , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC1(Desc.DepthStencilState)) - , DSVFormat(Desc.DSVFormat) - , RasterizerState(CD3DX12_RASTERIZER_DESC(Desc.RasterizerState)) - , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) - , SampleDesc(Desc.SampleDesc) - , SampleMask(Desc.SampleMask) - , CachedPSO(Desc.CachedPSO) - , ViewInstancingDesc(CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT())) - {} - CD3DX12_PIPELINE_STATE_STREAM1(const D3D12_COMPUTE_PIPELINE_STATE_DESC& Desc) noexcept - : Flags(Desc.Flags) - , NodeMask(Desc.NodeMask) - , pRootSignature(Desc.pRootSignature) - , CS(CD3DX12_SHADER_BYTECODE(Desc.CS)) - , CachedPSO(Desc.CachedPSO) - { - static_cast(DepthStencilState).DepthEnable = false; - } - CD3DX12_PIPELINE_STATE_STREAM_FLAGS Flags; - CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK NodeMask; - CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE pRootSignature; - CD3DX12_PIPELINE_STATE_STREAM_INPUT_LAYOUT InputLayout; - CD3DX12_PIPELINE_STATE_STREAM_IB_STRIP_CUT_VALUE IBStripCutValue; - CD3DX12_PIPELINE_STATE_STREAM_PRIMITIVE_TOPOLOGY PrimitiveTopologyType; - CD3DX12_PIPELINE_STATE_STREAM_VS VS; - CD3DX12_PIPELINE_STATE_STREAM_GS GS; - CD3DX12_PIPELINE_STATE_STREAM_STREAM_OUTPUT StreamOutput; - CD3DX12_PIPELINE_STATE_STREAM_HS HS; - CD3DX12_PIPELINE_STATE_STREAM_DS DS; - CD3DX12_PIPELINE_STATE_STREAM_PS PS; - CD3DX12_PIPELINE_STATE_STREAM_CS CS; - CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC BlendState; - CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL1 DepthStencilState; - CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL_FORMAT DSVFormat; - CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER RasterizerState; - CD3DX12_PIPELINE_STATE_STREAM_RENDER_TARGET_FORMATS RTVFormats; - CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_DESC SampleDesc; - CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_MASK SampleMask; - CD3DX12_PIPELINE_STATE_STREAM_CACHED_PSO CachedPSO; - CD3DX12_PIPELINE_STATE_STREAM_VIEW_INSTANCING ViewInstancingDesc; - D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDescV0() const noexcept - { - D3D12_GRAPHICS_PIPELINE_STATE_DESC D; - D.Flags = this->Flags; - D.NodeMask = this->NodeMask; - D.pRootSignature = this->pRootSignature; - D.InputLayout = this->InputLayout; - D.IBStripCutValue = this->IBStripCutValue; - D.PrimitiveTopologyType = this->PrimitiveTopologyType; - D.VS = this->VS; - D.GS = this->GS; - D.StreamOutput = this->StreamOutput; - D.HS = this->HS; - D.DS = this->DS; - D.PS = this->PS; - D.BlendState = this->BlendState; - D.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(D3D12_DEPTH_STENCIL_DESC1(this->DepthStencilState)); - D.DSVFormat = this->DSVFormat; - D.RasterizerState = this->RasterizerState; - D.NumRenderTargets = D3D12_RT_FORMAT_ARRAY(this->RTVFormats).NumRenderTargets; - memcpy(D.RTVFormats, D3D12_RT_FORMAT_ARRAY(this->RTVFormats).RTFormats, sizeof(D.RTVFormats)); - D.SampleDesc = this->SampleDesc; - D.SampleMask = this->SampleMask; - D.CachedPSO = this->CachedPSO; - return D; - } - D3D12_COMPUTE_PIPELINE_STATE_DESC ComputeDescV0() const noexcept - { - D3D12_COMPUTE_PIPELINE_STATE_DESC D; - D.Flags = this->Flags; - D.NodeMask = this->NodeMask; - D.pRootSignature = this->pRootSignature; - D.CS = this->CS; - D.CachedPSO = this->CachedPSO; - return D; - } -}; - - -struct CD3DX12_PIPELINE_MESH_STATE_STREAM -{ - CD3DX12_PIPELINE_MESH_STATE_STREAM() = default; - CD3DX12_PIPELINE_MESH_STATE_STREAM(const D3DX12_MESH_SHADER_PIPELINE_STATE_DESC& Desc) noexcept - : Flags(Desc.Flags) - , NodeMask(Desc.NodeMask) - , pRootSignature(Desc.pRootSignature) - , PS(Desc.PS) - , AS(Desc.AS) - , MS(Desc.MS) - , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) - , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC1(Desc.DepthStencilState)) - , DSVFormat(Desc.DSVFormat) - , RasterizerState(CD3DX12_RASTERIZER_DESC(Desc.RasterizerState)) - , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) - , SampleDesc(Desc.SampleDesc) - , SampleMask(Desc.SampleMask) - , CachedPSO(Desc.CachedPSO) - , ViewInstancingDesc(CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT())) - {} - CD3DX12_PIPELINE_STATE_STREAM_FLAGS Flags; - CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK NodeMask; - CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE pRootSignature; - CD3DX12_PIPELINE_STATE_STREAM_PS PS; - CD3DX12_PIPELINE_STATE_STREAM_AS AS; - CD3DX12_PIPELINE_STATE_STREAM_MS MS; - CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC BlendState; - CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL1 DepthStencilState; - CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL_FORMAT DSVFormat; - CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER RasterizerState; - CD3DX12_PIPELINE_STATE_STREAM_RENDER_TARGET_FORMATS RTVFormats; - CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_DESC SampleDesc; - CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_MASK SampleMask; - CD3DX12_PIPELINE_STATE_STREAM_CACHED_PSO CachedPSO; - CD3DX12_PIPELINE_STATE_STREAM_VIEW_INSTANCING ViewInstancingDesc; - D3DX12_MESH_SHADER_PIPELINE_STATE_DESC MeshShaderDescV0() const noexcept - { - D3DX12_MESH_SHADER_PIPELINE_STATE_DESC D; - D.Flags = this->Flags; - D.NodeMask = this->NodeMask; - D.pRootSignature = this->pRootSignature; - D.PS = this->PS; - D.AS = this->AS; - D.MS = this->MS; - D.BlendState = this->BlendState; - D.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(D3D12_DEPTH_STENCIL_DESC1(this->DepthStencilState)); - D.DSVFormat = this->DSVFormat; - D.RasterizerState = this->RasterizerState; - D.NumRenderTargets = D3D12_RT_FORMAT_ARRAY(this->RTVFormats).NumRenderTargets; - memcpy(D.RTVFormats, D3D12_RT_FORMAT_ARRAY(this->RTVFormats).RTFormats, sizeof(D.RTVFormats)); - D.SampleDesc = this->SampleDesc; - D.SampleMask = this->SampleMask; - D.CachedPSO = this->CachedPSO; - return D; - } -}; - -// CD3DX12_PIPELINE_STATE_STREAM works on OS Build 15063+ but does not support new subobject(s) added in OS Build 16299+. -// See CD3DX12_PIPELINE_STATE_STREAM1 for instance. -struct CD3DX12_PIPELINE_STATE_STREAM -{ - CD3DX12_PIPELINE_STATE_STREAM() = default; - CD3DX12_PIPELINE_STATE_STREAM(const D3D12_GRAPHICS_PIPELINE_STATE_DESC& Desc) noexcept - : Flags(Desc.Flags) - , NodeMask(Desc.NodeMask) - , pRootSignature(Desc.pRootSignature) - , InputLayout(Desc.InputLayout) - , IBStripCutValue(Desc.IBStripCutValue) - , PrimitiveTopologyType(Desc.PrimitiveTopologyType) - , VS(Desc.VS) - , GS(Desc.GS) - , StreamOutput(Desc.StreamOutput) - , HS(Desc.HS) - , DS(Desc.DS) - , PS(Desc.PS) - , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) - , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC1(Desc.DepthStencilState)) - , DSVFormat(Desc.DSVFormat) - , RasterizerState(CD3DX12_RASTERIZER_DESC(Desc.RasterizerState)) - , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) - , SampleDesc(Desc.SampleDesc) - , SampleMask(Desc.SampleMask) - , CachedPSO(Desc.CachedPSO) - {} - CD3DX12_PIPELINE_STATE_STREAM(const D3D12_COMPUTE_PIPELINE_STATE_DESC& Desc) noexcept - : Flags(Desc.Flags) - , NodeMask(Desc.NodeMask) - , pRootSignature(Desc.pRootSignature) - , CS(CD3DX12_SHADER_BYTECODE(Desc.CS)) - , CachedPSO(Desc.CachedPSO) - {} - CD3DX12_PIPELINE_STATE_STREAM_FLAGS Flags; - CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK NodeMask; - CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE pRootSignature; - CD3DX12_PIPELINE_STATE_STREAM_INPUT_LAYOUT InputLayout; - CD3DX12_PIPELINE_STATE_STREAM_IB_STRIP_CUT_VALUE IBStripCutValue; - CD3DX12_PIPELINE_STATE_STREAM_PRIMITIVE_TOPOLOGY PrimitiveTopologyType; - CD3DX12_PIPELINE_STATE_STREAM_VS VS; - CD3DX12_PIPELINE_STATE_STREAM_GS GS; - CD3DX12_PIPELINE_STATE_STREAM_STREAM_OUTPUT StreamOutput; - CD3DX12_PIPELINE_STATE_STREAM_HS HS; - CD3DX12_PIPELINE_STATE_STREAM_DS DS; - CD3DX12_PIPELINE_STATE_STREAM_PS PS; - CD3DX12_PIPELINE_STATE_STREAM_CS CS; - CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC BlendState; - CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL1 DepthStencilState; - CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL_FORMAT DSVFormat; - CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER RasterizerState; - CD3DX12_PIPELINE_STATE_STREAM_RENDER_TARGET_FORMATS RTVFormats; - CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_DESC SampleDesc; - CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_MASK SampleMask; - CD3DX12_PIPELINE_STATE_STREAM_CACHED_PSO CachedPSO; - D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDescV0() const noexcept - { - D3D12_GRAPHICS_PIPELINE_STATE_DESC D; - D.Flags = this->Flags; - D.NodeMask = this->NodeMask; - D.pRootSignature = this->pRootSignature; - D.InputLayout = this->InputLayout; - D.IBStripCutValue = this->IBStripCutValue; - D.PrimitiveTopologyType = this->PrimitiveTopologyType; - D.VS = this->VS; - D.GS = this->GS; - D.StreamOutput = this->StreamOutput; - D.HS = this->HS; - D.DS = this->DS; - D.PS = this->PS; - D.BlendState = this->BlendState; - D.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(D3D12_DEPTH_STENCIL_DESC1(this->DepthStencilState)); - D.DSVFormat = this->DSVFormat; - D.RasterizerState = this->RasterizerState; - D.NumRenderTargets = D3D12_RT_FORMAT_ARRAY(this->RTVFormats).NumRenderTargets; - memcpy(D.RTVFormats, D3D12_RT_FORMAT_ARRAY(this->RTVFormats).RTFormats, sizeof(D.RTVFormats)); - D.SampleDesc = this->SampleDesc; - D.SampleMask = this->SampleMask; - D.CachedPSO = this->CachedPSO; - return D; - } - D3D12_COMPUTE_PIPELINE_STATE_DESC ComputeDescV0() const noexcept - { - D3D12_COMPUTE_PIPELINE_STATE_DESC D; - D.Flags = this->Flags; - D.NodeMask = this->NodeMask; - D.pRootSignature = this->pRootSignature; - D.CS = this->CS; - D.CachedPSO = this->CachedPSO; - return D; - } -}; - -struct CD3DX12_PIPELINE_STATE_STREAM2_PARSE_HELPER : public ID3DX12PipelineParserCallbacks -{ - CD3DX12_PIPELINE_STATE_STREAM2 PipelineStream; - CD3DX12_PIPELINE_STATE_STREAM2_PARSE_HELPER() noexcept - : SeenDSS(false) - { - // Adjust defaults to account for absent members. - PipelineStream.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; - - // Depth disabled if no DSV format specified. - static_cast(PipelineStream.DepthStencilState).DepthEnable = false; - } - - // ID3DX12PipelineParserCallbacks - void FlagsCb(D3D12_PIPELINE_STATE_FLAGS Flags) override {PipelineStream.Flags = Flags;} - void NodeMaskCb(UINT NodeMask) override {PipelineStream.NodeMask = NodeMask;} - void RootSignatureCb(ID3D12RootSignature* pRootSignature) override {PipelineStream.pRootSignature = pRootSignature;} - void InputLayoutCb(const D3D12_INPUT_LAYOUT_DESC& InputLayout) override {PipelineStream.InputLayout = InputLayout;} - void IBStripCutValueCb(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue) override {PipelineStream.IBStripCutValue = IBStripCutValue;} - void PrimitiveTopologyTypeCb(D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType) override {PipelineStream.PrimitiveTopologyType = PrimitiveTopologyType;} - void VSCb(const D3D12_SHADER_BYTECODE& VS) override {PipelineStream.VS = VS;} - void GSCb(const D3D12_SHADER_BYTECODE& GS) override {PipelineStream.GS = GS;} - void StreamOutputCb(const D3D12_STREAM_OUTPUT_DESC& StreamOutput) override {PipelineStream.StreamOutput = StreamOutput;} - void HSCb(const D3D12_SHADER_BYTECODE& HS) override {PipelineStream.HS = HS;} - void DSCb(const D3D12_SHADER_BYTECODE& DS) override {PipelineStream.DS = DS;} - void PSCb(const D3D12_SHADER_BYTECODE& PS) override {PipelineStream.PS = PS;} - void CSCb(const D3D12_SHADER_BYTECODE& CS) override {PipelineStream.CS = CS;} - void ASCb(const D3D12_SHADER_BYTECODE& AS) override {PipelineStream.AS = AS;} - void MSCb(const D3D12_SHADER_BYTECODE& MS) override {PipelineStream.MS = MS;} - void BlendStateCb(const D3D12_BLEND_DESC& BlendState) override {PipelineStream.BlendState = CD3DX12_BLEND_DESC(BlendState);} - void DepthStencilStateCb(const D3D12_DEPTH_STENCIL_DESC& DepthStencilState) override - { - PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(DepthStencilState); - SeenDSS = true; - } - void DepthStencilState1Cb(const D3D12_DEPTH_STENCIL_DESC1& DepthStencilState) override - { - PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(DepthStencilState); - SeenDSS = true; - } - void DSVFormatCb(DXGI_FORMAT DSVFormat) override - { - PipelineStream.DSVFormat = DSVFormat; - if (!SeenDSS && DSVFormat != DXGI_FORMAT_UNKNOWN) - { - // Re-enable depth for the default state. - static_cast(PipelineStream.DepthStencilState).DepthEnable = true; - } - } - void RasterizerStateCb(const D3D12_RASTERIZER_DESC& RasterizerState) override {PipelineStream.RasterizerState = CD3DX12_RASTERIZER_DESC(RasterizerState);} - void RTVFormatsCb(const D3D12_RT_FORMAT_ARRAY& RTVFormats) override {PipelineStream.RTVFormats = RTVFormats;} - void SampleDescCb(const DXGI_SAMPLE_DESC& SampleDesc) override {PipelineStream.SampleDesc = SampleDesc;} - void SampleMaskCb(UINT SampleMask) override {PipelineStream.SampleMask = SampleMask;} - void ViewInstancingCb(const D3D12_VIEW_INSTANCING_DESC& ViewInstancingDesc) override {PipelineStream.ViewInstancingDesc = CD3DX12_VIEW_INSTANCING_DESC(ViewInstancingDesc);} - void CachedPSOCb(const D3D12_CACHED_PIPELINE_STATE& CachedPSO) override {PipelineStream.CachedPSO = CachedPSO;} - -private: - bool SeenDSS; -}; - - -struct CD3DX12_PIPELINE_STATE_STREAM_PARSE_HELPER : public ID3DX12PipelineParserCallbacks -{ - CD3DX12_PIPELINE_STATE_STREAM1 PipelineStream; - CD3DX12_PIPELINE_STATE_STREAM_PARSE_HELPER() noexcept - : SeenDSS(false) - { - // Adjust defaults to account for absent members. - PipelineStream.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; - - // Depth disabled if no DSV format specified. - static_cast(PipelineStream.DepthStencilState).DepthEnable = false; - } - - // ID3DX12PipelineParserCallbacks - void FlagsCb(D3D12_PIPELINE_STATE_FLAGS Flags) override {PipelineStream.Flags = Flags;} - void NodeMaskCb(UINT NodeMask) override {PipelineStream.NodeMask = NodeMask;} - void RootSignatureCb(ID3D12RootSignature* pRootSignature) override {PipelineStream.pRootSignature = pRootSignature;} - void InputLayoutCb(const D3D12_INPUT_LAYOUT_DESC& InputLayout) override {PipelineStream.InputLayout = InputLayout;} - void IBStripCutValueCb(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue) override {PipelineStream.IBStripCutValue = IBStripCutValue;} - void PrimitiveTopologyTypeCb(D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType) override {PipelineStream.PrimitiveTopologyType = PrimitiveTopologyType;} - void VSCb(const D3D12_SHADER_BYTECODE& VS) override {PipelineStream.VS = VS;} - void GSCb(const D3D12_SHADER_BYTECODE& GS) override {PipelineStream.GS = GS;} - void StreamOutputCb(const D3D12_STREAM_OUTPUT_DESC& StreamOutput) override {PipelineStream.StreamOutput = StreamOutput;} - void HSCb(const D3D12_SHADER_BYTECODE& HS) override {PipelineStream.HS = HS;} - void DSCb(const D3D12_SHADER_BYTECODE& DS) override {PipelineStream.DS = DS;} - void PSCb(const D3D12_SHADER_BYTECODE& PS) override {PipelineStream.PS = PS;} - void CSCb(const D3D12_SHADER_BYTECODE& CS) override {PipelineStream.CS = CS;} - void BlendStateCb(const D3D12_BLEND_DESC& BlendState) override {PipelineStream.BlendState = CD3DX12_BLEND_DESC(BlendState);} - void DepthStencilStateCb(const D3D12_DEPTH_STENCIL_DESC& DepthStencilState) override - { - PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(DepthStencilState); - SeenDSS = true; - } - void DepthStencilState1Cb(const D3D12_DEPTH_STENCIL_DESC1& DepthStencilState) override - { - PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(DepthStencilState); - SeenDSS = true; - } - void DSVFormatCb(DXGI_FORMAT DSVFormat) override - { - PipelineStream.DSVFormat = DSVFormat; - if (!SeenDSS && DSVFormat != DXGI_FORMAT_UNKNOWN) - { - // Re-enable depth for the default state. - static_cast(PipelineStream.DepthStencilState).DepthEnable = true; - } - } - void RasterizerStateCb(const D3D12_RASTERIZER_DESC& RasterizerState) override {PipelineStream.RasterizerState = CD3DX12_RASTERIZER_DESC(RasterizerState);} - void RTVFormatsCb(const D3D12_RT_FORMAT_ARRAY& RTVFormats) override {PipelineStream.RTVFormats = RTVFormats;} - void SampleDescCb(const DXGI_SAMPLE_DESC& SampleDesc) override {PipelineStream.SampleDesc = SampleDesc;} - void SampleMaskCb(UINT SampleMask) override {PipelineStream.SampleMask = SampleMask;} - void ViewInstancingCb(const D3D12_VIEW_INSTANCING_DESC& ViewInstancingDesc) override {PipelineStream.ViewInstancingDesc = CD3DX12_VIEW_INSTANCING_DESC(ViewInstancingDesc);} - void CachedPSOCb(const D3D12_CACHED_PIPELINE_STATE& CachedPSO) override {PipelineStream.CachedPSO = CachedPSO;} - -private: - bool SeenDSS; -}; - -inline D3D12_PIPELINE_STATE_SUBOBJECT_TYPE D3DX12GetBaseSubobjectType(D3D12_PIPELINE_STATE_SUBOBJECT_TYPE SubobjectType) noexcept -{ - switch (SubobjectType) - { - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1: - return D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL; - default: - return SubobjectType; - } -} - -inline HRESULT D3DX12ParsePipelineStream(const D3D12_PIPELINE_STATE_STREAM_DESC& Desc, ID3DX12PipelineParserCallbacks* pCallbacks) -{ - if (pCallbacks == nullptr) - { - return E_INVALIDARG; - } - - if (Desc.SizeInBytes == 0 || Desc.pPipelineStateSubobjectStream == nullptr) - { - pCallbacks->ErrorBadInputParameter(1); // first parameter issue - return E_INVALIDARG; - } - - bool SubobjectSeen[D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MAX_VALID] = {}; - for (SIZE_T CurOffset = 0, SizeOfSubobject = 0; CurOffset < Desc.SizeInBytes; CurOffset += SizeOfSubobject) - { - BYTE* pStream = static_cast(Desc.pPipelineStateSubobjectStream)+CurOffset; - auto SubobjectType = *reinterpret_cast(pStream); - if (SubobjectType < 0 || SubobjectType >= D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MAX_VALID) - { - pCallbacks->ErrorUnknownSubobject(SubobjectType); - return E_INVALIDARG; - } - if (SubobjectSeen[D3DX12GetBaseSubobjectType(SubobjectType)]) - { - pCallbacks->ErrorDuplicateSubobject(SubobjectType); - return E_INVALIDARG; // disallow subobject duplicates in a stream - } - SubobjectSeen[SubobjectType] = true; - switch (SubobjectType) - { - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_ROOT_SIGNATURE: - pCallbacks->RootSignatureCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::pRootSignature); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VS: - pCallbacks->VSCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::VS); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PS: - pCallbacks->PSCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::PS); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DS: - pCallbacks->DSCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::DS); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_HS: - pCallbacks->HSCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::HS); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_GS: - pCallbacks->GSCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::GS); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CS: - pCallbacks->CSCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::CS); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_AS: - pCallbacks->ASCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM2::AS); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MS: - pCallbacks->MSCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM2::MS); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_STREAM_OUTPUT: - pCallbacks->StreamOutputCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::StreamOutput); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_BLEND: - pCallbacks->BlendStateCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::BlendState); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_MASK: - pCallbacks->SampleMaskCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::SampleMask); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER: - pCallbacks->RasterizerStateCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::RasterizerState); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL: - pCallbacks->DepthStencilStateCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1: - pCallbacks->DepthStencilState1Cb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::DepthStencilState); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_INPUT_LAYOUT: - pCallbacks->InputLayoutCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::InputLayout); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_IB_STRIP_CUT_VALUE: - pCallbacks->IBStripCutValueCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::IBStripCutValue); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PRIMITIVE_TOPOLOGY: - pCallbacks->PrimitiveTopologyTypeCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::PrimitiveTopologyType); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RENDER_TARGET_FORMATS: - pCallbacks->RTVFormatsCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::RTVFormats); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL_FORMAT: - pCallbacks->DSVFormatCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::DSVFormat); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_DESC: - pCallbacks->SampleDescCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::SampleDesc); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_NODE_MASK: - pCallbacks->NodeMaskCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::NodeMask); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CACHED_PSO: - pCallbacks->CachedPSOCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::CachedPSO); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_FLAGS: - pCallbacks->FlagsCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::Flags); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VIEW_INSTANCING: - pCallbacks->ViewInstancingCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM1::ViewInstancingDesc); - break; - default: - pCallbacks->ErrorUnknownSubobject(SubobjectType); - return E_INVALIDARG; - } - } - - return S_OK; -} - -//------------------------------------------------------------------------------------------------ -inline bool operator==( const D3D12_CLEAR_VALUE &a, const D3D12_CLEAR_VALUE &b) noexcept -{ - if (a.Format != b.Format) return false; - if (a.Format == DXGI_FORMAT_D24_UNORM_S8_UINT - || a.Format == DXGI_FORMAT_D16_UNORM - || a.Format == DXGI_FORMAT_D32_FLOAT - || a.Format == DXGI_FORMAT_D32_FLOAT_S8X24_UINT) - { - return (a.DepthStencil.Depth == b.DepthStencil.Depth) && - (a.DepthStencil.Stencil == b.DepthStencil.Stencil); - } else { - return (a.Color[0] == b.Color[0]) && - (a.Color[1] == b.Color[1]) && - (a.Color[2] == b.Color[2]) && - (a.Color[3] == b.Color[3]); - } -} -inline bool operator==( const D3D12_RENDER_PASS_BEGINNING_ACCESS_CLEAR_PARAMETERS &a, const D3D12_RENDER_PASS_BEGINNING_ACCESS_CLEAR_PARAMETERS &b) noexcept -{ - return a.ClearValue == b.ClearValue; -} -inline bool operator==( const D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_PARAMETERS &a, const D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_PARAMETERS &b) noexcept -{ - if (a.pSrcResource != b.pSrcResource) return false; - if (a.pDstResource != b.pDstResource) return false; - if (a.SubresourceCount != b.SubresourceCount) return false; - if (a.Format != b.Format) return false; - if (a.ResolveMode != b.ResolveMode) return false; - if (a.PreserveResolveSource != b.PreserveResolveSource) return false; - return true; -} -inline bool operator==( const D3D12_RENDER_PASS_BEGINNING_ACCESS &a, const D3D12_RENDER_PASS_BEGINNING_ACCESS &b) noexcept -{ - if (a.Type != b.Type) return false; - if (a.Type == D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_CLEAR && !(a.Clear == b.Clear)) return false; - return true; -} -inline bool operator==( const D3D12_RENDER_PASS_ENDING_ACCESS &a, const D3D12_RENDER_PASS_ENDING_ACCESS &b) noexcept -{ - if (a.Type != b.Type) return false; - if (a.Type == D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_RESOLVE && !(a.Resolve == b.Resolve)) return false; - return true; -} -inline bool operator==( const D3D12_RENDER_PASS_RENDER_TARGET_DESC &a, const D3D12_RENDER_PASS_RENDER_TARGET_DESC &b) noexcept -{ - if (a.cpuDescriptor.ptr != b.cpuDescriptor.ptr) return false; - if (!(a.BeginningAccess == b.BeginningAccess)) return false; - if (!(a.EndingAccess == b.EndingAccess)) return false; - return true; -} -inline bool operator==( const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC &a, const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC &b) noexcept -{ - if (a.cpuDescriptor.ptr != b.cpuDescriptor.ptr) return false; - if (!(a.DepthBeginningAccess == b.DepthBeginningAccess)) return false; - if (!(a.StencilBeginningAccess == b.StencilBeginningAccess)) return false; - if (!(a.DepthEndingAccess == b.DepthEndingAccess)) return false; - if (!(a.StencilEndingAccess == b.StencilEndingAccess)) return false; - return true; -} - - -#ifndef D3DX12_NO_STATE_OBJECT_HELPERS - -//================================================================================================ -// D3DX12 State Object Creation Helpers -// -// Helper classes for creating new style state objects out of an arbitrary set of subobjects. -// Uses STL -// -// Start by instantiating CD3DX12_STATE_OBJECT_DESC (see it's public methods). -// One of its methods is CreateSubobject(), which has a comment showing a couple of options for -// defining subobjects using the helper classes for each subobject (CD3DX12_DXIL_LIBRARY_SUBOBJECT -// etc.). The subobject helpers each have methods specific to the subobject for configuring it's -// contents. -// -//================================================================================================ -#include -#include -#include -#include -#ifndef D3DX12_USE_ATL -#include -#define D3DX12_COM_PTR Microsoft::WRL::ComPtr -#define D3DX12_COM_PTR_GET(x) x.Get() -#define D3DX12_COM_PTR_ADDRESSOF(x) x.GetAddressOf() -#else -#include -#define D3DX12_COM_PTR ATL::CComPtr -#define D3DX12_COM_PTR_GET(x) x.p -#define D3DX12_COM_PTR_ADDRESSOF(x) &x.p -#endif - -//------------------------------------------------------------------------------------------------ -class CD3DX12_STATE_OBJECT_DESC -{ -public: - CD3DX12_STATE_OBJECT_DESC() noexcept - { - Init(D3D12_STATE_OBJECT_TYPE_COLLECTION); - } - CD3DX12_STATE_OBJECT_DESC(D3D12_STATE_OBJECT_TYPE Type) noexcept - { - Init(Type); - } - void SetStateObjectType(D3D12_STATE_OBJECT_TYPE Type) noexcept { m_Desc.Type = Type; } - operator const D3D12_STATE_OBJECT_DESC&() - { - // Do final preparation work - m_RepointedAssociations.clear(); - m_SubobjectArray.clear(); - m_SubobjectArray.reserve(m_Desc.NumSubobjects); - // Flatten subobjects into an array (each flattened subobject still has a - // member that's a pointer to it's desc that's not flattened) - for (auto Iter = m_SubobjectList.begin(); - Iter != m_SubobjectList.end(); Iter++) - { - m_SubobjectArray.push_back(*Iter); - // Store new location in array so we can redirect pointers contained in subobjects - Iter->pSubobjectArrayLocation = &m_SubobjectArray.back(); - } - // For subobjects with pointer fields, create a new copy of those subobject definitions - // with fixed pointers - for (UINT i = 0; i < m_Desc.NumSubobjects; i++) - { - if (m_SubobjectArray[i].Type == D3D12_STATE_SUBOBJECT_TYPE_SUBOBJECT_TO_EXPORTS_ASSOCIATION) - { - auto pOriginalSubobjectAssociation = - static_cast(m_SubobjectArray[i].pDesc); - D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION Repointed = *pOriginalSubobjectAssociation; - auto pWrapper = - static_cast(pOriginalSubobjectAssociation->pSubobjectToAssociate); - Repointed.pSubobjectToAssociate = pWrapper->pSubobjectArrayLocation; - m_RepointedAssociations.push_back(Repointed); - m_SubobjectArray[i].pDesc = &m_RepointedAssociations.back(); - } - } - // Below: using ugly way to get pointer in case .data() is not defined - m_Desc.pSubobjects = m_Desc.NumSubobjects ? &m_SubobjectArray[0] : nullptr; - return m_Desc; - } - operator const D3D12_STATE_OBJECT_DESC*() - { - // Cast calls the above final preparation work - return &static_cast(*this); - } - - // CreateSubobject creates a sububject helper (e.g. CD3DX12_HIT_GROUP_SUBOBJECT) - // whose lifetime is owned by this class. - // e.g. - // - // CD3DX12_STATE_OBJECT_DESC Collection1(D3D12_STATE_OBJECT_TYPE_COLLECTION); - // auto Lib0 = Collection1.CreateSubobject(); - // Lib0->SetDXILLibrary(&pMyAppDxilLibs[0]); - // Lib0->DefineExport(L"rayGenShader0"); // in practice these export listings might be - // // data/engine driven - // etc. - // - // Alternatively, users can instantiate sububject helpers explicitly, such as via local - // variables instead, passing the state object desc that should point to it into the helper - // constructor (or call mySubobjectHelper.AddToStateObject(Collection1)). - // In this alternative scenario, the user must keep the subobject alive as long as the state - // object it is associated with is alive, else it's pointer references will be stale. - // e.g. - // - // CD3DX12_STATE_OBJECT_DESC RaytracingState2(D3D12_STATE_OBJECT_TYPE_RAYTRACING_PIPELINE); - // CD3DX12_DXIL_LIBRARY_SUBOBJECT LibA(RaytracingState2); - // LibA.SetDXILLibrary(&pMyAppDxilLibs[4]); // not manually specifying exports - // // - meaning all exports in the libraries - // // are exported - // etc. - - template - T* CreateSubobject() - { - T* pSubobject = new T(*this); - m_OwnedSubobjectHelpers.emplace_back(pSubobject); - return pSubobject; - } - -private: - D3D12_STATE_SUBOBJECT* TrackSubobject(D3D12_STATE_SUBOBJECT_TYPE Type, void* pDesc) - { - SUBOBJECT_WRAPPER Subobject; - Subobject.pSubobjectArrayLocation = nullptr; - Subobject.Type = Type; - Subobject.pDesc = pDesc; - m_SubobjectList.push_back(Subobject); - m_Desc.NumSubobjects++; - return &m_SubobjectList.back(); - } - void Init(D3D12_STATE_OBJECT_TYPE Type) noexcept - { - SetStateObjectType(Type); - m_Desc.pSubobjects = nullptr; - m_Desc.NumSubobjects = 0; - m_SubobjectList.clear(); - m_SubobjectArray.clear(); - m_RepointedAssociations.clear(); - } - typedef struct SUBOBJECT_WRAPPER : public D3D12_STATE_SUBOBJECT - { - D3D12_STATE_SUBOBJECT* pSubobjectArrayLocation; // new location when flattened into array - // for repointing pointers in subobjects - } SUBOBJECT_WRAPPER; - D3D12_STATE_OBJECT_DESC m_Desc; - std::list m_SubobjectList; // Pointers to list nodes handed out so - // these can be edited live - std::vector m_SubobjectArray; // Built at the end, copying list contents - - std::list - m_RepointedAssociations; // subobject type that contains pointers to other subobjects, - // repointed to flattened array - - class StringContainer - { - public: - LPCWSTR LocalCopy(LPCWSTR string, bool bSingleString = false) - { - if (string) - { - if (bSingleString) - { - m_Strings.clear(); - m_Strings.push_back(string); - } - else - { - m_Strings.push_back(string); - } - return m_Strings.back().c_str(); - } - else - { - return nullptr; - } - } - void clear() noexcept { m_Strings.clear(); } - private: - std::list m_Strings; - }; - - class SUBOBJECT_HELPER_BASE - { - public: - SUBOBJECT_HELPER_BASE() noexcept { Init(); } - virtual ~SUBOBJECT_HELPER_BASE() = default; - virtual D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept = 0; - void AddToStateObject(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - m_pSubobject = ContainingStateObject.TrackSubobject(Type(), Data()); - } - protected: - virtual void* Data() noexcept = 0; - void Init() noexcept { m_pSubobject = nullptr; } - D3D12_STATE_SUBOBJECT* m_pSubobject; - }; - -#if(__cplusplus >= 201103L) - std::list> m_OwnedSubobjectHelpers; -#else - class OWNED_HELPER - { - public: - OWNED_HELPER(const SUBOBJECT_HELPER_BASE* pHelper) noexcept { m_pHelper = pHelper; } - ~OWNED_HELPER() { delete m_pHelper; } - const SUBOBJECT_HELPER_BASE* m_pHelper; - }; - - std::list m_OwnedSubobjectHelpers; -#endif - - friend class CD3DX12_DXIL_LIBRARY_SUBOBJECT; - friend class CD3DX12_EXISTING_COLLECTION_SUBOBJECT; - friend class CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT; - friend class CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION; - friend class CD3DX12_HIT_GROUP_SUBOBJECT; - friend class CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT; - friend class CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT; - friend class CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT; - friend class CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT; - friend class CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT; - friend class CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT; - friend class CD3DX12_NODE_MASK_SUBOBJECT; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_DXIL_LIBRARY_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_DXIL_LIBRARY_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_DXIL_LIBRARY_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void SetDXILLibrary(const D3D12_SHADER_BYTECODE* pCode) noexcept - { - static const D3D12_SHADER_BYTECODE Default = {}; - m_Desc.DXILLibrary = pCode ? *pCode : Default; - } - void DefineExport( - LPCWSTR Name, - LPCWSTR ExportToRename = nullptr, - D3D12_EXPORT_FLAGS Flags = D3D12_EXPORT_FLAG_NONE) - { - D3D12_EXPORT_DESC Export; - Export.Name = m_Strings.LocalCopy(Name); - Export.ExportToRename = m_Strings.LocalCopy(ExportToRename); - Export.Flags = Flags; - m_Exports.push_back(Export); - m_Desc.pExports = &m_Exports[0]; // using ugly way to get pointer in case .data() is not defined - m_Desc.NumExports = static_cast(m_Exports.size()); - } - template - void DefineExports(LPCWSTR(&Exports)[N]) - { - for (UINT i = 0; i < N; i++) - { - DefineExport(Exports[i]); - } - } - void DefineExports(const LPCWSTR* Exports, UINT N) - { - for (UINT i = 0; i < N; i++) - { - DefineExport(Exports[i]); - } - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_DXIL_LIBRARY; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator const D3D12_DXIL_LIBRARY_DESC&() const noexcept { return m_Desc; } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_Desc = {}; - m_Strings.clear(); - m_Exports.clear(); - } - void* Data() noexcept override { return &m_Desc; } - D3D12_DXIL_LIBRARY_DESC m_Desc; - CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings; - std::vector m_Exports; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_EXISTING_COLLECTION_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_EXISTING_COLLECTION_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_EXISTING_COLLECTION_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void SetExistingCollection(ID3D12StateObject*pExistingCollection) noexcept - { - m_Desc.pExistingCollection = pExistingCollection; - m_CollectionRef = pExistingCollection; - } - void DefineExport( - LPCWSTR Name, - LPCWSTR ExportToRename = nullptr, - D3D12_EXPORT_FLAGS Flags = D3D12_EXPORT_FLAG_NONE) - { - D3D12_EXPORT_DESC Export; - Export.Name = m_Strings.LocalCopy(Name); - Export.ExportToRename = m_Strings.LocalCopy(ExportToRename); - Export.Flags = Flags; - m_Exports.push_back(Export); - m_Desc.pExports = &m_Exports[0]; // using ugly way to get pointer in case .data() is not defined - m_Desc.NumExports = static_cast(m_Exports.size()); - } - template - void DefineExports(LPCWSTR(&Exports)[N]) - { - for (UINT i = 0; i < N; i++) - { - DefineExport(Exports[i]); - } - } - void DefineExports(const LPCWSTR* Exports, UINT N) - { - for (UINT i = 0; i < N; i++) - { - DefineExport(Exports[i]); - } - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_EXISTING_COLLECTION; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator const D3D12_EXISTING_COLLECTION_DESC&() const noexcept { return m_Desc; } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_Desc = {}; - m_CollectionRef = nullptr; - m_Strings.clear(); - m_Exports.clear(); - } - void* Data() noexcept override { return &m_Desc; } - D3D12_EXISTING_COLLECTION_DESC m_Desc; - D3DX12_COM_PTR m_CollectionRef; - CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings; - std::vector m_Exports; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void SetSubobjectToAssociate(const D3D12_STATE_SUBOBJECT& SubobjectToAssociate) noexcept - { - m_Desc.pSubobjectToAssociate = &SubobjectToAssociate; - } - void AddExport(LPCWSTR Export) - { - m_Desc.NumExports++; - m_Exports.push_back(m_Strings.LocalCopy(Export)); - m_Desc.pExports = &m_Exports[0]; // using ugly way to get pointer in case .data() is not defined - } - template - void AddExports(LPCWSTR (&Exports)[N]) - { - for (UINT i = 0; i < N; i++) - { - AddExport(Exports[i]); - } - } - void AddExports(const LPCWSTR* Exports, UINT N) - { - for (UINT i = 0; i < N; i++) - { - AddExport(Exports[i]); - } - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_SUBOBJECT_TO_EXPORTS_ASSOCIATION; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator const D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION&() const noexcept { return m_Desc; } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_Desc = {}; - m_Strings.clear(); - m_Exports.clear(); - } - void* Data() noexcept override { return &m_Desc; } - D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION m_Desc; - CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings; - std::vector m_Exports; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION() noexcept - { - Init(); - } - CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void SetSubobjectNameToAssociate(LPCWSTR SubobjectToAssociate) - { - m_Desc.SubobjectToAssociate = m_SubobjectName.LocalCopy(SubobjectToAssociate, true); - } - void AddExport(LPCWSTR Export) - { - m_Desc.NumExports++; - m_Exports.push_back(m_Strings.LocalCopy(Export)); - m_Desc.pExports = &m_Exports[0]; // using ugly way to get pointer in case .data() is not defined - } - template - void AddExports(LPCWSTR (&Exports)[N]) - { - for (UINT i = 0; i < N; i++) - { - AddExport(Exports[i]); - } - } - void AddExports(const LPCWSTR* Exports, UINT N) - { - for (UINT i = 0; i < N; i++) - { - AddExport(Exports[i]); - } - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator const D3D12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION&() const noexcept { return m_Desc; } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_Desc = {}; - m_Strings.clear(); - m_SubobjectName.clear(); - m_Exports.clear(); - } - void* Data() noexcept override { return &m_Desc; } - D3D12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION m_Desc; - CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings; - CD3DX12_STATE_OBJECT_DESC::StringContainer m_SubobjectName; - std::vector m_Exports; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_HIT_GROUP_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_HIT_GROUP_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_HIT_GROUP_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void SetHitGroupExport(LPCWSTR exportName) - { - m_Desc.HitGroupExport = m_Strings[0].LocalCopy(exportName, true); - } - void SetHitGroupType(D3D12_HIT_GROUP_TYPE Type) noexcept { m_Desc.Type = Type; } - void SetAnyHitShaderImport(LPCWSTR importName) - { - m_Desc.AnyHitShaderImport = m_Strings[1].LocalCopy(importName, true); - } - void SetClosestHitShaderImport(LPCWSTR importName) - { - m_Desc.ClosestHitShaderImport = m_Strings[2].LocalCopy(importName, true); - } - void SetIntersectionShaderImport(LPCWSTR importName) - { - m_Desc.IntersectionShaderImport = m_Strings[3].LocalCopy(importName, true); - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_HIT_GROUP; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator const D3D12_HIT_GROUP_DESC&() const noexcept { return m_Desc; } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_Desc = {}; - for (UINT i = 0; i < m_NumStrings; i++) - { - m_Strings[i].clear(); - } - } - void* Data() noexcept override { return &m_Desc; } - D3D12_HIT_GROUP_DESC m_Desc; - static const UINT m_NumStrings = 4; - CD3DX12_STATE_OBJECT_DESC::StringContainer - m_Strings[m_NumStrings]; // one string for every entrypoint name -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void Config(UINT MaxPayloadSizeInBytes, UINT MaxAttributeSizeInBytes) noexcept - { - m_Desc.MaxPayloadSizeInBytes = MaxPayloadSizeInBytes; - m_Desc.MaxAttributeSizeInBytes = MaxAttributeSizeInBytes; - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_SHADER_CONFIG; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator const D3D12_RAYTRACING_SHADER_CONFIG&() const noexcept { return m_Desc; } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_Desc = {}; - } - void* Data() noexcept override { return &m_Desc; } - D3D12_RAYTRACING_SHADER_CONFIG m_Desc; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void Config(UINT MaxTraceRecursionDepth) noexcept - { - m_Desc.MaxTraceRecursionDepth = MaxTraceRecursionDepth; - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_PIPELINE_CONFIG; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator const D3D12_RAYTRACING_PIPELINE_CONFIG&() const noexcept { return m_Desc; } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_Desc = {}; - } - void* Data() noexcept override { return &m_Desc; } - D3D12_RAYTRACING_PIPELINE_CONFIG m_Desc; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void Config(UINT MaxTraceRecursionDepth, D3D12_RAYTRACING_PIPELINE_FLAGS Flags) noexcept - { - m_Desc.MaxTraceRecursionDepth = MaxTraceRecursionDepth; - m_Desc.Flags = Flags; - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_PIPELINE_CONFIG1; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator const D3D12_RAYTRACING_PIPELINE_CONFIG1&() const noexcept { return m_Desc; } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_Desc = {}; - } - void* Data() noexcept override { return &m_Desc; } - D3D12_RAYTRACING_PIPELINE_CONFIG1 m_Desc; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void SetRootSignature(ID3D12RootSignature* pRootSig) noexcept - { - m_pRootSig = pRootSig; - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_GLOBAL_ROOT_SIGNATURE; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator ID3D12RootSignature*() const noexcept { return D3DX12_COM_PTR_GET(m_pRootSig); } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_pRootSig = nullptr; - } - void* Data() noexcept override { return D3DX12_COM_PTR_ADDRESSOF(m_pRootSig); } - D3DX12_COM_PTR m_pRootSig; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void SetRootSignature(ID3D12RootSignature* pRootSig) noexcept - { - m_pRootSig = pRootSig; - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_LOCAL_ROOT_SIGNATURE; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator ID3D12RootSignature*() const noexcept { return D3DX12_COM_PTR_GET(m_pRootSig); } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_pRootSig = nullptr; - } - void* Data() noexcept override { return D3DX12_COM_PTR_ADDRESSOF(m_pRootSig); } - D3DX12_COM_PTR m_pRootSig; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void SetFlags(D3D12_STATE_OBJECT_FLAGS Flags) noexcept - { - m_Desc.Flags = Flags; - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_STATE_OBJECT_CONFIG; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator const D3D12_STATE_OBJECT_CONFIG&() const noexcept { return m_Desc; } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_Desc = {}; - } - void* Data() noexcept override { return &m_Desc; } - D3D12_STATE_OBJECT_CONFIG m_Desc; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_NODE_MASK_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_NODE_MASK_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_NODE_MASK_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void SetNodeMask(UINT NodeMask) noexcept - { - m_Desc.NodeMask = NodeMask; - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_NODE_MASK; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator const D3D12_NODE_MASK&() const noexcept { return m_Desc; } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_Desc = {}; - } - void* Data() noexcept override { return &m_Desc; } - D3D12_NODE_MASK m_Desc; -}; - -#undef D3DX12_COM_PTR -#undef D3DX12_COM_PTR_GET -#undef D3DX12_COM_PTR_ADDRESSOF -#endif // #ifndef D3DX12_NO_STATE_OBJECT_HELPERS - -#endif // defined( __cplusplus ) - -#endif //__D3DX12_H__ - - diff --git a/xess/samples/xess_demo/MiniEngine/Core/dds.h b/xess/samples/xess_demo/MiniEngine/Core/dds.h deleted file mode 100644 index 54b17f6..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/dds.h +++ /dev/null @@ -1,223 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// This header defines constants and structures that are useful when parsing -// DDS files. DDS files were originally designed to use several structures -// and constants that are native to DirectDraw and are defined in ddraw.h, -// such as DDSURFACEDESC2 and DDSCAPS2. This file defines similar -// (compatible) constants and structures so that one can use DDS files -// without needing to include ddraw.h. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -// http://go.microsoft.com/fwlink/?LinkId=248929 -//-------------------------------------------------------------------------------------- - -#if defined(_MSC_VER) -#pragma once -#endif - -// VS 2010's stdint.h conflicts with intsafe.h -#pragma warning(push) -#pragma warning(disable : 4005) -#include -#pragma warning(pop) - -namespace DirectX -{ - -#pragma pack(push,1) - -const uint32_t DDS_MAGIC = 0x20534444; // "DDS " - -struct DDS_PIXELFORMAT -{ - uint32_t size; - uint32_t flags; - uint32_t fourCC; - uint32_t RGBBitCount; - uint32_t RBitMask; - uint32_t GBitMask; - uint32_t BBitMask; - uint32_t ABitMask; -}; - -#define DDS_FOURCC 0x00000004 // DDPF_FOURCC -#define DDS_RGB 0x00000040 // DDPF_RGB -#define DDS_RGBA 0x00000041 // DDPF_RGB | DDPF_ALPHAPIXELS -#define DDS_LUMINANCE 0x00020000 // DDPF_LUMINANCE -#define DDS_LUMINANCEA 0x00020001 // DDPF_LUMINANCE | DDPF_ALPHAPIXELS -#define DDS_ALPHA 0x00000002 // DDPF_ALPHA -#define DDS_PAL8 0x00000020 // DDPF_PALETTEINDEXED8 - -#ifndef MAKEFOURCC - #define MAKEFOURCC(ch0, ch1, ch2, ch3) \ - ((uint32_t)(uint8_t)(ch0) | ((uint32_t)(uint8_t)(ch1) << 8) | \ - ((uint32_t)(uint8_t)(ch2) << 16) | ((uint32_t)(uint8_t)(ch3) << 24 )) -#endif /* defined(MAKEFOURCC) */ - -extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_DXT1 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','1'), 0, 0, 0, 0, 0 }; - -extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_DXT2 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','2'), 0, 0, 0, 0, 0 }; - -extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_DXT3 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','3'), 0, 0, 0, 0, 0 }; - -extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_DXT4 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','4'), 0, 0, 0, 0, 0 }; - -extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_DXT5 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','5'), 0, 0, 0, 0, 0 }; - -extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_BC4_UNORM = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','4','U'), 0, 0, 0, 0, 0 }; - -extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_BC4_SNORM = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','4','S'), 0, 0, 0, 0, 0 }; - -extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_BC5_UNORM = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','5','U'), 0, 0, 0, 0, 0 }; - -extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_BC5_SNORM = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','5','S'), 0, 0, 0, 0, 0 }; - -extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_R8G8_B8G8 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('R','G','B','G'), 0, 0, 0, 0, 0 }; - -extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_G8R8_G8B8 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('G','R','G','B'), 0, 0, 0, 0, 0 }; - -extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_YUY2 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('Y','U','Y','2'), 0, 0, 0, 0, 0 }; - -extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_A8R8G8B8 = - { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 }; - -extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_X8R8G8B8 = - { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000 }; - -extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_A8B8G8R8 = - { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 }; - -extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_X8B8G8R8 = - { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0x00000000 }; - -extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_G16R16 = - { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x0000ffff, 0xffff0000, 0x00000000, 0x00000000 }; - -extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_R5G6B5 = - { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0x0000f800, 0x000007e0, 0x0000001f, 0x00000000 }; - -extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_A1R5G5B5 = - { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x00007c00, 0x000003e0, 0x0000001f, 0x00008000 }; - -extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_A4R4G4B4 = - { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x00000f00, 0x000000f0, 0x0000000f, 0x0000f000 }; - -extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_R8G8B8 = - { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 24, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000 }; - -extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_L8 = - { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCE, 0, 8, 0xff, 0x00, 0x00, 0x00 }; - -extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_L16 = - { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCE, 0, 16, 0xffff, 0x0000, 0x0000, 0x0000 }; - -extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_A8L8 = - { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCEA, 0, 16, 0x00ff, 0x0000, 0x0000, 0xff00 }; - -extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_A8 = - { sizeof(DDS_PIXELFORMAT), DDS_ALPHA, 0, 8, 0x00, 0x00, 0x00, 0xff }; - -// D3DFMT_A2R10G10B10/D3DFMT_A2B10G10R10 should be written using DX10 extension to avoid D3DX 10:10:10:2 reversal issue - -// This indicates the DDS_HEADER_DXT10 extension is present (the format is in dxgiFormat) -extern __declspec(selectany) const DDS_PIXELFORMAT DDSPF_DX10 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','1','0'), 0, 0, 0, 0, 0 }; - -#define DDS_HEADER_FLAGS_TEXTURE 0x00001007 // DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT -#define DDS_HEADER_FLAGS_MIPMAP 0x00020000 // DDSD_MIPMAPCOUNT -#define DDS_HEADER_FLAGS_VOLUME 0x00800000 // DDSD_DEPTH -#define DDS_HEADER_FLAGS_PITCH 0x00000008 // DDSD_PITCH -#define DDS_HEADER_FLAGS_LINEARSIZE 0x00080000 // DDSD_LINEARSIZE - -#define DDS_HEIGHT 0x00000002 // DDSD_HEIGHT -#define DDS_WIDTH 0x00000004 // DDSD_WIDTH - -#define DDS_SURFACE_FLAGS_TEXTURE 0x00001000 // DDSCAPS_TEXTURE -#define DDS_SURFACE_FLAGS_MIPMAP 0x00400008 // DDSCAPS_COMPLEX | DDSCAPS_MIPMAP -#define DDS_SURFACE_FLAGS_CUBEMAP 0x00000008 // DDSCAPS_COMPLEX - -#define DDS_CUBEMAP_POSITIVEX 0x00000600 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEX -#define DDS_CUBEMAP_NEGATIVEX 0x00000a00 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEX -#define DDS_CUBEMAP_POSITIVEY 0x00001200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEY -#define DDS_CUBEMAP_NEGATIVEY 0x00002200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEY -#define DDS_CUBEMAP_POSITIVEZ 0x00004200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEZ -#define DDS_CUBEMAP_NEGATIVEZ 0x00008200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEZ - -#define DDS_CUBEMAP_ALLFACES ( DDS_CUBEMAP_POSITIVEX | DDS_CUBEMAP_NEGATIVEX |\ - DDS_CUBEMAP_POSITIVEY | DDS_CUBEMAP_NEGATIVEY |\ - DDS_CUBEMAP_POSITIVEZ | DDS_CUBEMAP_NEGATIVEZ ) - -#define DDS_CUBEMAP 0x00000200 // DDSCAPS2_CUBEMAP - -#define DDS_FLAGS_VOLUME 0x00200000 // DDSCAPS2_VOLUME - -// Subset here matches D3D10_RESOURCE_DIMENSION and D3D11_RESOURCE_DIMENSION -enum DDS_RESOURCE_DIMENSION -{ - DDS_DIMENSION_TEXTURE1D = 2, - DDS_DIMENSION_TEXTURE2D = 3, - DDS_DIMENSION_TEXTURE3D = 4, -}; - -// Subset here matches D3D10_RESOURCE_MISC_FLAG and D3D11_RESOURCE_MISC_FLAG -enum DDS_RESOURCE_MISC_FLAG -{ - DDS_RESOURCE_MISC_TEXTURECUBE = 0x4L, -}; - -enum DDS_MISC_FLAGS2 -{ - DDS_MISC_FLAGS2_ALPHA_MODE_MASK = 0x7L, -}; - -struct DDS_HEADER -{ - uint32_t size; - uint32_t flags; - uint32_t height; - uint32_t width; - uint32_t pitchOrLinearSize; - uint32_t depth; // only if DDS_HEADER_FLAGS_VOLUME is set in flags - uint32_t mipMapCount; - uint32_t reserved1[11]; - DDS_PIXELFORMAT ddspf; - uint32_t caps; - uint32_t caps2; - uint32_t caps3; - uint32_t caps4; - uint32_t reserved2; -}; - -struct DDS_HEADER_DXT10 -{ - DXGI_FORMAT dxgiFormat; - uint32_t resourceDimension; - uint32_t miscFlag; // see D3D11_RESOURCE_MISC_FLAG - uint32_t arraySize; - uint32_t miscFlags2; // see DDS_MISC_FLAGS2 -} ; - -#pragma pack(pop) - -static_assert( sizeof(DDS_HEADER) == 124, "DDS Header size mismatch" ); -static_assert( sizeof(DDS_HEADER_DXT10) == 20, "DDS DX10 Extended Header size mismatch"); - -}; // namespace diff --git a/xess/samples/xess_demo/MiniEngine/Core/packages.config b/xess/samples/xess_demo/MiniEngine/Core/packages.config deleted file mode 100644 index 5f811ea..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/packages.config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Core/pch.cpp b/xess/samples/xess_demo/MiniEngine/Core/pch.cpp deleted file mode 100644 index 97b544e..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/pch.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.cpp -// Include the standard header and generate the precompiled header. -// - -#include "pch.h" diff --git a/xess/samples/xess_demo/MiniEngine/Core/pch.h b/xess/samples/xess_demo/MiniEngine/Core/pch.h deleted file mode 100644 index 21c2ecf..0000000 --- a/xess/samples/xess_demo/MiniEngine/Core/pch.h +++ /dev/null @@ -1,78 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#pragma warning(disable:4201) // nonstandard extension used : nameless struct/union -#pragma warning(disable:4238) // nonstandard extension used : class rvalue used as lvalue -#pragma warning(disable:4239) // A non-const reference may only be bound to an lvalue; assignment operator takes a reference to non-const -#pragma warning(disable:4324) // structure was padded due to __declspec(align()) - -#include -#define _WIN32_WINNT 0x0A00 -#include - -// Use the C++ standard templated min/max -#define NOMINMAX - -// DirectX apps don't need GDI -#define NODRAWTEXT -#define NOGDI -#define NOBITMAP - -// Include if you need this -#define NOMCX - -// Include if you need this -#define NOSERVICE - -// WinHelp is deprecated -#define NOHELP - -#define WIN32_LEAN_AND_MEAN - -#include -#include -#include - -#include -#include -#include "d3dx12.h" -#ifdef _DEBUG - #include -#endif - -#define D3D12_GPU_VIRTUAL_ADDRESS_NULL ((D3D12_GPU_VIRTUAL_ADDRESS)0) -#define D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN ((D3D12_GPU_VIRTUAL_ADDRESS)-1) -#define MY_IID_PPV_ARGS IID_PPV_ARGS - - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "Log.h" -#include "Utility.h" -#include "VectorMath.h" -#include "EngineTuning.h" -#include "EngineProfiling.h" -#include "Util/CommandLineArg.h" diff --git a/xess/samples/xess_demo/MiniEngine/CreateNewLibrary.bat b/xess/samples/xess_demo/MiniEngine/CreateNewLibrary.bat deleted file mode 100644 index 1facca1..0000000 --- a/xess/samples/xess_demo/MiniEngine/CreateNewLibrary.bat +++ /dev/null @@ -1,5 +0,0 @@ -@ECHO OFF -REM This batch file generates a new MiniEngine library project for Visual Studio -REM 2015 and 2017. It is expected that python.exe is on your path and is version -REM 3.0 or above. If not, we recommend installing the latest version of Anaconda. -python.exe Tools\Scripts\CreateNewProject.py LIB %1 \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/CreateNewSolution.bat b/xess/samples/xess_demo/MiniEngine/CreateNewSolution.bat deleted file mode 100644 index 72aafc9..0000000 --- a/xess/samples/xess_demo/MiniEngine/CreateNewSolution.bat +++ /dev/null @@ -1,5 +0,0 @@ -@ECHO OFF -REM This batch file generates a new MiniEngine solution project for Visual Studio -REM 2015 and 2017. It is expected that python.exe is on your path and is version -REM 3.0 or above. If not, we recommend installing the latest version of Anaconda. -python.exe Tools\Scripts\CreateNewProject.py APP %1 \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.bwoi/Directory.Build.props b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.bwoi/Directory.Build.props deleted file mode 100644 index 980aa0f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.bwoi/Directory.Build.props +++ /dev/null @@ -1,90 +0,0 @@ - - - - - C:\xtracted\ - $(ExtractedFolder)\ - - <_AlternativeVCTargetsPath170>$(ExtractedFolder)VCTargets170\ - <_AlternativeVCTargetsPath160>$(ExtractedFolder)VCTargets160\ - <_AlternativeVCTargetsPath150>$(ExtractedFolder)VCTargets150\ - - - 15.0 - - - - - - - - - - - - - - - - - - - - - $(_AlternativeVCTargetsPath160) - true - $(_AlternativeVCTargetsPath150) - $(_AlternativeVCTargetsPath160) - - - - $(_AlternativeVCTargetsPath160) - true - $(_AlternativeVCTargetsPath150) - $(_AlternativeVCTargetsPath160) - - - - $(_AlternativeVCTargetsPath160) - true - $(_AlternativeVCTargetsPath150) - $(_AlternativeVCTargetsPath160) - - - - - true - $(_AlternativeVCTargetsPath150) - $(_AlternativeVCTargetsPath160) - $(_AlternativeVCTargetsPath170) - - - - true - $(_AlternativeVCTargetsPath150) - $(_AlternativeVCTargetsPath160) - $(_AlternativeVCTargetsPath170) - - - - true - $(_AlternativeVCTargetsPath150) - $(_AlternativeVCTargetsPath160) - $(_AlternativeVCTargetsPath170) - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.bwoi/SetupBWOI.targets b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.bwoi/SetupBWOI.targets deleted file mode 100644 index 501a4fa..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.bwoi/SetupBWOI.targets +++ /dev/null @@ -1,138 +0,0 @@ - - - - - C:\xtracted\ - $(ExtractedFolder)\ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_BWOIFolder>%(BWOIVCFolders.Identity) - - - - <_MissingBWOIVCFolders Condition="'$(ForceVCTargetsBWOIRefresh)'=='true' or !Exists($(_BWOIFolder))" Include="$(_BWOIFolder)" /> - - - - <_ExtractedOutOfDate Condition="'@(_MissingBWOIVCFolders)' != ''">true - <_BWOIFolder /> - - - - - - - - - - <_VSFolder Condition="'$(VisualStudioVersion)' == '17.0'">VS2022 - <_VSFolder Condition="'$(VisualStudioVersion)' == '16.0'">VS2019 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.editorconfig b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.editorconfig deleted file mode 100644 index 174669d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.editorconfig +++ /dev/null @@ -1,74 +0,0 @@ -root = true - -[*.{fx,fxh,hlsl,hlsli}] -indent_size = 4 -indent_style = space -trim_trailing_whitespace = true -insert_final_newline = true -end_of_line = crlf -charset = latin1 -cpp_space_before_function_open_parenthesis = remove -cpp_space_around_binary_operator = ignore -cpp_space_pointer_reference_alignment = ignore - -[*.{cpp,h,hpp,inl}] -indent_size = 4 -indent_style = space -trim_trailing_whitespace = true -insert_final_newline = true -end_of_line = crlf -charset = latin1 -cpp_indent_braces = false -cpp_indent_multi_line_relative_to = innermost_parenthesis -cpp_indent_within_parentheses = indent -cpp_indent_preserve_within_parentheses = false -cpp_indent_case_contents = true -cpp_indent_case_labels = false -cpp_indent_case_contents_when_block = true -cpp_indent_lambda_braces_when_parameter = true -cpp_indent_preprocessor = one_left -cpp_indent_access_specifiers = false -cpp_indent_namespace_contents = true -cpp_indent_preserve_comments = true -cpp_new_line_before_open_brace_namespace = new_line -cpp_new_line_before_open_brace_type = new_line -cpp_new_line_before_open_brace_function = new_line -cpp_new_line_before_open_brace_block = new_line -cpp_new_line_before_open_brace_lambda = new_line -cpp_new_line_scope_braces_on_separate_lines = true -cpp_new_line_close_brace_same_line_empty_type = true -cpp_new_line_close_brace_same_line_empty_function = true -cpp_new_line_before_catch = true -cpp_new_line_before_else = true -cpp_new_line_before_while_in_do_while = true -cpp_space_before_function_open_parenthesis = remove -cpp_space_within_parameter_list_parentheses = false -cpp_space_between_empty_parameter_list_parentheses = false -cpp_space_after_keywords_in_control_flow_statements = true -cpp_space_within_control_flow_statement_parentheses = false -cpp_space_before_lambda_open_parenthesis = false -cpp_space_within_cast_parentheses = false -cpp_space_after_cast_close_parenthesis = false -cpp_space_within_expression_parentheses = false -cpp_space_before_initializer_list_open_brace = false -cpp_space_within_initializer_list_braces = true -cpp_space_before_open_square_bracket = false -cpp_space_within_square_brackets = false -cpp_space_before_empty_square_brackets = false -cpp_space_between_empty_square_brackets = false -cpp_space_group_square_brackets = true -cpp_space_within_lambda_brackets = false -cpp_space_between_empty_lambda_brackets = false -cpp_space_before_comma = false -cpp_space_after_comma = true -cpp_space_remove_around_member_operators = true -cpp_space_before_inheritance_colon = true -cpp_space_before_constructor_colon = true -cpp_space_remove_before_semicolon = true -cpp_space_after_semicolon = false -cpp_space_remove_around_unary_operator = false -cpp_space_around_binary_operator = ignore -cpp_space_around_assignment_operator = insert -cpp_space_pointer_reference_alignment = ignore -cpp_space_around_ternary_operator = insert -cpp_wrap_preserve_blocks = one_liners diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.gitattributes b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.gitattributes deleted file mode 100644 index 4d19b72..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.gitattributes +++ /dev/null @@ -1,18 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto - -# Explicitly declare code/VS files as CRLF -*.cpp eol=crlf -*.h eol=crlf -*.hlsl eol=crlf -*.hlsli eol=crlf -*.fx eol=crlf -*.fxh eol=crlf -*.inc eol=crlf -*.inl eol=crlf -*.vcxproj eol=crlf -*.filters eol=crlf -*.sln eol=crlf - -# Explicitly declare resource files as binary -*.pdb binary diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.gitignore b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.gitignore deleted file mode 100644 index 764451c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.gitignore +++ /dev/null @@ -1,30 +0,0 @@ -*.psess -*.vsp -*.log -*.err -*.wrn -*.suo -*.sdf -*.user -*.i -*.vspscc -*.opensdf -*.opendb -*.ipch -*.cache -*.tlog -*.lastbuildstate -*.ilk -*.VC.db -*.nupkg -.vs -[Bb]in -/ipch -Debug -Profile -Release -x64 -/Tests -/wiki -/out -/CMakeUserPresets.json diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.nuget/DirectXMesh-config.cmake.in b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.nuget/DirectXMesh-config.cmake.in deleted file mode 100644 index 2884041..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.nuget/DirectXMesh-config.cmake.in +++ /dev/null @@ -1,18 +0,0 @@ -@PACKAGE_INIT@ - -if ((NOT directxmesh_FIND_COMPONENTS) OR ("library" IN_LIST directxmesh_FIND_COMPONENTS)) - include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake) -endif() - -if ("utils" IN_LIST directxmesh_FIND_COMPONENTS) - include(${CMAKE_CURRENT_LIST_DIR}/Utilities-targets.cmake) -endif() - -include(CMakeFindDependencyMacro) - -if(MINGW OR (NOT WIN32) OR VCPKG_TOOLCHAIN) - find_dependency(directx-headers CONFIG) - find_dependency(directxmath CONFIG) -endif() - -check_required_components("@PROJECT_NAME@") diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.nuget/directxmesh_desktop_2019.nuspec b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.nuget/directxmesh_desktop_2019.nuspec deleted file mode 100644 index a4637bb..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.nuget/directxmesh_desktop_2019.nuspec +++ /dev/null @@ -1,50 +0,0 @@ - - - - directxmesh_desktop_2019 - 0.0.0-SpecifyVersionOnCommandline - DirectXMesh Library (VS 2019/2022 Win32) - Microsoft - microsoft,directxtk - DirectXMesh geometry processing library - This version is for Windows desktop applications using Visual Studio 2019 or Visual Studio 2022 and supports Windows 7 / DirectX 11. - -DirectXMesh, a shared source library for performing various geometry content processing operations including generating normals and tangent frames, triangle adjacency computations, vertex cache optimization, and meshlet generation. - Matches the May 9, 2022 release on GitHub. - http://go.microsoft.com/fwlink/?LinkID=324981 - - images\icon.jpg - docs\README.md - MIT - false - © Microsoft Corporation. All rights reserved. - DirectX DirectXMesh native nativepackage - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.nuget/directxmesh_desktop_2019.targets b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.nuget/directxmesh_desktop_2019.targets deleted file mode 100644 index c3c6abd..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.nuget/directxmesh_desktop_2019.targets +++ /dev/null @@ -1,29 +0,0 @@ - - - - - Debug - - - Release - - - - $(MSBuildThisFileDirectory)..\..\native\lib\$(Platform)\$(NuGetConfiguration) - - - - - $(directxmesh-LibPath);%(AdditionalLibraryDirectories) - DirectXMesh.lib;%(AdditionalDependencies) - - - - - - HAS_DIRECTXMESH;%(PreprocessorDefinitions) - $(MSBuildThisFileDirectory)..\..\include;%(AdditionalIncludeDirectories) - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.nuget/directxmesh_desktop_win10.nuspec b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.nuget/directxmesh_desktop_win10.nuspec deleted file mode 100644 index 060ec32..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.nuget/directxmesh_desktop_win10.nuspec +++ /dev/null @@ -1,56 +0,0 @@ - - - - directxmesh_desktop_win10 - 0.0.0-SpecifyVersionOnCommandline - DirectXMesh Library (VS 2019/2022 Win32 for Windows 10/11) - Microsoft - microsoft,directxtk - DirectXMesh geometry processing library - This version is for Windows desktop applications using Visual Studio 2019 or Visual Studio 2022 and supports Windows 10 / Windows 11 including both DirectX 11 and DirectX 12. - -DirectXMesh, a shared source library for performing various geometry content processing operations including generating normals and tangent frames, triangle adjacency computations, vertex cache optimization, and meshlet generation. - Matches the May 9, 2022 release on GitHub. - http://go.microsoft.com/fwlink/?LinkID=324981 - - images\icon.jpg - docs\README.md - MIT - false - © Microsoft Corporation. All rights reserved. - DirectX DirectXMesh native nativepackage - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.nuget/directxmesh_desktop_win10.targets b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.nuget/directxmesh_desktop_win10.targets deleted file mode 100644 index 4e322d8..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.nuget/directxmesh_desktop_win10.targets +++ /dev/null @@ -1,41 +0,0 @@ - - - - - <_NuGetConfiguration>Debug - - - <_NuGetConfiguration>Release - - - - <_NuGetPlatform>x64 - - - <_NuGetPlatform>$(Platform) - - - - $(MSBuildThisFileDirectory)..\..\native\lib\$(_NuGetPlatform)\$(_NuGetConfiguration) - - - - - $(directxmesh-LibPath);%(AdditionalLibraryDirectories) - DirectXMesh.lib;%(AdditionalDependencies) - - - - - - HAS_DIRECTXMESH;%(PreprocessorDefinitions) - $(MSBuildThisFileDirectory)..\..\include;%(AdditionalIncludeDirectories) - - - - - <_NuGetConfiguration> - <_NuGetPlatform> - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.nuget/directxmesh_uwp.nuspec b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.nuget/directxmesh_uwp.nuspec deleted file mode 100644 index d973b51..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.nuget/directxmesh_uwp.nuspec +++ /dev/null @@ -1,62 +0,0 @@ - - - - directxmesh_uwp - 0.0.0-SpecifyVersionOnCommandline - DirectXMesh Library (UWP) - Microsoft - microsoft,directxtk - DirectXMesh geometry processing library - This version is for Universal Windows Platform apps on Windows 10 / Windows 11 using Visual Studio 2019 or Visual Studio 2022. - -DirectXMesh, a shared source library for performing various geometry content processing operations including generating normals and tangent frames, triangle adjacency computations, vertex cache optimization, and meshlet generation. - Matches the May 9, 2022 release on GitHub. - http://go.microsoft.com/fwlink/?LinkID=324981 - - images\icon.jpg - docs\README.md - MIT - false - © Microsoft Corporation. All rights reserved. - DirectX DirectXMesh native nativepackage - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.nuget/directxmesh_uwp.targets b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.nuget/directxmesh_uwp.targets deleted file mode 100644 index c3c6abd..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.nuget/directxmesh_uwp.targets +++ /dev/null @@ -1,29 +0,0 @@ - - - - - Debug - - - Release - - - - $(MSBuildThisFileDirectory)..\..\native\lib\$(Platform)\$(NuGetConfiguration) - - - - - $(directxmesh-LibPath);%(AdditionalLibraryDirectories) - DirectXMesh.lib;%(AdditionalDependencies) - - - - - - HAS_DIRECTXMESH;%(PreprocessorDefinitions) - $(MSBuildThisFileDirectory)..\..\include;%(AdditionalIncludeDirectories) - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.nuget/icon.jpg b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.nuget/icon.jpg deleted file mode 100644 index 08fe1fa..0000000 Binary files a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.nuget/icon.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.nuget/versioninfo.ps1 b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.nuget/versioninfo.ps1 deleted file mode 100644 index 1ca4155..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/.nuget/versioninfo.ps1 +++ /dev/null @@ -1,7 +0,0 @@ -param( -[string]$version -) -$file = 'Meshconvert\meshconvert.rc' -$versionComma = $version.Replace(".", ",") -(Get-Content $file).replace('1,0,0,0', $versionComma).replace('1.0.0.0', $version) | Set-Content $file -(Get-Content $file) \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/CMakeLists.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/CMakeLists.txt deleted file mode 100644 index a021be8..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/CMakeLists.txt +++ /dev/null @@ -1,231 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. - -cmake_minimum_required (VERSION 3.13) - -set(DIRECTXMESH_VERSION 1.6.3) - -project(DirectXMesh - VERSION ${DIRECTXMESH_VERSION} - DESCRIPTION "DirectXMesh geometry Library" - HOMEPAGE_URL "https://go.microsoft.com/fwlink/?LinkID=324981" - LANGUAGES CXX) - -option(BUILD_TOOLS "Build meshconvert" ON) - -# Includes the support for DirectX 12 input layouts -option(BUILD_DX12 "Build with DirectX12 Runtime support" ON) - -option(ENABLE_CODE_ANALYSIS "Use Static Code Analysis on build" OFF) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) - -#set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/CMake") -#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/CMake") -#set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/CMake") - -if (DEFINED VCPKG_TARGET_ARCHITECTURE) - set(DIRECTX_ARCH ${VCPKG_TARGET_ARCHITECTURE}) -elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Ww][Ii][Nn]32$") - set(DIRECTX_ARCH x86) -elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Xx]64$") - set(DIRECTX_ARCH x64) -elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]$") - set(DIRECTX_ARCH arm) -elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]64$") - set(DIRECTX_ARCH arm64) -endif() - -include(GNUInstallDirs) - -#--- Library -set(LIBRARY_HEADERS - DirectXMesh/DirectXMesh.h - DirectXMesh/DirectXMesh.inl) - -set(LIBRARY_SOURCES - DirectXMesh/DirectXMeshP.h - DirectXMesh/scoped.h - DirectXMesh/DirectXMeshAdjacency.cpp - DirectXMesh/DirectXMeshClean.cpp - DirectXMesh/DirectXMeshGSAdjacency.cpp - DirectXMesh/DirectXMeshletGenerator.cpp - DirectXMesh/DirectXMeshNormals.cpp - DirectXMesh/DirectXMeshOptimize.cpp - DirectXMesh/DirectXMeshOptimizeLRU.cpp - DirectXMesh/DirectXMeshOptimizeTVC.cpp - DirectXMesh/DirectXMeshRemap.cpp - DirectXMesh/DirectXMeshTangentFrame.cpp - DirectXMesh/DirectXMeshUtil.cpp - DirectXMesh/DirectXMeshValidate.cpp - DirectXMesh/DirectXMeshVBReader.cpp - DirectXMesh/DirectXMeshVBWriter.cpp - DirectXMesh/DirectXMeshWeldVertices.cpp) - -add_library(${PROJECT_NAME} STATIC ${LIBRARY_SOURCES} ${LIBRARY_HEADERS}) - -source_group(${PROJECT_NAME} REGULAR_EXPRESSION DirectXMesh/*.*) - -target_include_directories(${PROJECT_NAME} PUBLIC - $ - $) - -if ((${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16") AND (NOT MINGW)) - target_precompile_headers(${PROJECT_NAME} PRIVATE DirectXMesh/DirectXMeshP.h) -endif() - -if(MSVC) - # Use max Warning Level - string(REPLACE "/W3 " "/Wall " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) - string(REPLACE "/W3 " "/Wall " CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) - string(REPLACE "/W3 " "/Wall " CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}) - - # Not using typeid or dynamic_cast, so disable RTTI to save binary size - string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) - string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) - string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}) -endif() - -if (MINGW OR (NOT WIN32) OR VCPKG_TOOLCHAIN) - message("INFO: Using VCPKG for DirectX-Headers and DirectXMath.") - find_package(directx-headers CONFIG REQUIRED) - find_package(directxmath CONFIG REQUIRED) - target_link_libraries(${PROJECT_NAME} PRIVATE Microsoft::DirectX-Headers Microsoft::DirectXMath) - target_compile_definitions(${PROJECT_NAME} PRIVATE USING_DIRECTX_HEADERS) -endif() - -#--- Utilities -set(UTILS_HEADERS - Utilities/FlexibleVertexFormat.h - Utilities/WaveFrontReader.h) - -add_library(Utilities INTERFACE) - -source_group(Utilities REGULAR_EXPRESSION Utilities/*.*) - -target_include_directories(Utilities INTERFACE - $ - $) - -#--- Command-line tool -if(BUILD_TOOLS AND WIN32 AND (NOT WINDOWS_STORE)) - set(TOOL_EXES meshconvert) - - add_executable(meshconvert - Meshconvert/Meshconvert.cpp - Meshconvert/MeshOBJ.cpp - Meshconvert/Mesh.h - Meshconvert/Mesh.cpp - Meshconvert/SDKMesh.h) - target_include_directories(meshconvert PUBLIC MeshConvert Utilities) - target_link_libraries(meshconvert ${PROJECT_NAME} version.lib) - source_group(meshconvert REGULAR_EXPRESSION meshconvert/*.*) - - if (MINGW OR VCPKG_TOOLCHAIN) - target_link_libraries(meshconvert Microsoft::DirectXMath) - endif() -endif() - -if(MSVC) - foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME}) - target_compile_options(${t} PRIVATE /fp:fast "$<$>:/guard:cf>") - target_link_options(${t} PRIVATE /DYNAMICBASE /NXCOMPAT) - endforeach() - - if((${CMAKE_SIZEOF_VOID_P} EQUAL 4) AND (NOT ${DIRECTX_ARCH} MATCHES "^arm")) - foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME}) - target_link_options(${t} PRIVATE /SAFESEH) - endforeach() - endif() -endif() - -if(NOT ${DIRECTX_ARCH} MATCHES "^arm") - if (${CMAKE_SIZEOF_VOID_P} EQUAL "4") - set(ARCH_SSE2 $<$:/arch:SSE2> $<$>:-msse2>) - else() - set(ARCH_SSE2 $<$>:-msse2>) - endif() - - foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME}) - target_compile_options(${t} PRIVATE ${ARCH_SSE2}) - endforeach() -endif() - -if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - set(WarningsLib "-Wpedantic" "-Wextra") - target_compile_options(${PROJECT_NAME} PRIVATE ${WarningsLib}) - - set(WarningsEXE ${WarningsLib} "-Wno-c++98-compat" "-Wno-c++98-compat-pedantic" "-Wno-switch" "-Wno-switch-enum" "-Wno-double-promotion" "-Wno-exit-time-destructors" "-Wno-missing-prototypes") - foreach(t IN LISTS TOOL_EXES) - target_compile_options(${t} PRIVATE ${WarningsEXE}) - endforeach() -endif() -if(MINGW) - foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME}) - target_compile_options(${t} PRIVATE -Wno-ignored-attributes) - target_link_options(${t} PRIVATE -municode) - endforeach() -endif() -if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") - foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME}) - target_compile_options(${t} PRIVATE /sdl /permissive- /JMC- /Zc:__cplusplus) - endforeach() - - if(ENABLE_CODE_ANALYSIS) - foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME}) - target_compile_options(${t} PRIVATE /analyze) - endforeach() - endif() - - if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.24) - foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME}) - target_compile_options(${t} PRIVATE /ZH:SHA_256) - endforeach() - endif() - - if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.26) - foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME}) - target_compile_options(${t} PRIVATE /Zc:preprocessor /wd5105) - endforeach() - endif() - - if ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.27) AND (NOT (${DIRECTX_ARCH} MATCHES "^arm"))) - foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME}) - target_link_options(${t} PRIVATE /CETCOMPAT) - endforeach() - endif() - - set(WarningsEXE "/wd4061" "/wd4365" "/wd4514" "/wd4625" "/wd4626" "/wd4627" "/wd4668" "/wd4710" "/wd4751" "/wd4820" "/wd5026" "/wd5027" "/wd5039" "/wd5045" "/wd5219") - foreach(t IN LISTS TOOL_EXES) - target_compile_options(${t} PRIVATE ${WarningsEXE}) - endforeach() -endif() - -if(WIN32) - foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME}) - target_compile_definitions(${t} PRIVATE _UNICODE UNICODE) - endforeach() - - if(WINDOWS_STORE) - target_compile_definitions(${PROJECT_NAME} PRIVATE WINAPI_FAMILY=WINAPI_FAMILY_APP) - endif() - - if(BUILD_DX12 OR WINDOWS_STORE) - if(BUILD_DX12) - message("INFO: Building with DirectX 12 Runtime support") - endif() - target_compile_definitions(${PROJECT_NAME} PRIVATE _WIN32_WINNT=0x0A00) - else() - message("INFO: Building with Windows 7 compatibility") - target_compile_definitions(${PROJECT_NAME} PRIVATE _WIN32_WINNT=0x0601) - endif() - foreach(t IN LISTS TOOL_EXES) - target_compile_definitions(${t} PRIVATE _WIN32_WINNT=0x0601) - endforeach() -endif() - -if(BUILD_TOOLS AND WIN32 AND (NOT WINDOWS_STORE)) - set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT meshconvert) -endif() diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/CMakePresets.json b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/CMakePresets.json deleted file mode 100644 index f380f7b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/CMakePresets.json +++ /dev/null @@ -1,175 +0,0 @@ -{ - "version": 2, - "configurePresets": [ - { - "name": "base", - "displayName": "Basic Config", - "description": "Basic build using Ninja generator", - "generator": "Ninja", - "hidden": true, - "binaryDir": "${sourceDir}/out/build/${presetName}", - "cacheVariables": { "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}" } - }, - - { - "name": "x64", - "architecture": { - "value": "x64", - "strategy": "external" - }, - "cacheVariables": { "DIRECTX_ARCH": "x64" }, - "hidden": true - }, - { - "name": "x86", - "architecture": { - "value": "x86", - "strategy": "external" - }, - "cacheVariables": { "DIRECTX_ARCH": "x86" }, - "hidden": true - }, - { - "name": "ARM", - "architecture": { - "value": "arm", - "strategy": "external" - }, - "cacheVariables": { "DIRECTX_ARCH": "arm" }, - "hidden": true - }, - { - "name": "ARM64", - "architecture": { - "value": "arm64", - "strategy": "external" - }, - "cacheVariables": { "DIRECTX_ARCH": "arm64" }, - "hidden": true - }, - - { - "name": "Debug", - "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" }, - "hidden": true - }, - { - "name": "Release", - "cacheVariables": { "CMAKE_BUILD_TYPE": "RelWithDebInfo" }, - "hidden": true - }, - - { - "name": "MSVC", - "hidden": true, - "cacheVariables": { - "CMAKE_CXX_COMPILER": "cl.exe" - }, - "toolset": { - "value": "host=x64", - "strategy": "external" - } - }, - { - "name": "Clang", - "hidden": true, - "cacheVariables": { - "CMAKE_CXX_COMPILER": "clang-cl.exe" - }, - "toolset": { - "value": "host=x64", - "strategy": "external" - } - }, - { - "name": "GNUC", - "hidden": true, - "cacheVariables": { - "CMAKE_CXX_COMPILER": "g++.exe" - }, - "toolset": { - "value": "host=x64", - "strategy": "external" - } - }, - - { - "name": "Win7", - "cacheVariables": { - "BUILD_DX12": false - }, - "hidden": true - }, - { - "name": "UWP", - "cacheVariables": { - "CMAKE_SYSTEM_NAME": "WindowsStore", - "CMAKE_SYSTEM_VERSION": "10.0", - "BUILD_DX12": true - }, - "hidden": true - }, - { - "name": "VCPKG", - "cacheVariables": { - "CMAKE_TOOLCHAIN_FILE": { - "value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", - "type": "FILEPATH" - } - }, - "hidden": true - }, - - { "name": "x64-Debug" , "description": "MSVC for x64 (Debug) with DX12", "inherits": [ "base", "x64", "Debug", "MSVC" ] }, - { "name": "x64-Release" , "description": "MSVC for x64 (Release) with DX12", "inherits": [ "base", "x64", "Release", "MSVC" ] }, - { "name": "x86-Debug" , "description": "MSVC for x86 (Debug) with DX12", "inherits": [ "base", "x86", "Debug", "MSVC" ] }, - { "name": "x86-Release" , "description": "MSVC for x86 (Release) with DX12", "inherits": [ "base", "x86", "Release", "MSVC" ] }, - { "name": "arm64-Debug" , "description": "MSVC for ARM64 (Debug) with DX12", "inherits": [ "base", "ARM64", "Debug", "MSVC" ] }, - { "name": "arm64-Release", "description": "MSVC for ARM64 (Release) with DX12", "inherits": [ "base", "ARM64", "Release", "MSVC" ] }, - - { "name": "x64-Debug-UWP" , "description": "MSVC for x64 (Debug) for UWP", "inherits": [ "base", "x64", "Debug", "MSVC", "UWP" ] }, - { "name": "x64-Release-UWP" , "description": "MSVC for x64 (Release) for UWP", "inherits": [ "base", "x64", "Release", "MSVC", "UWP" ] }, - { "name": "x86-Debug-UWP" , "description": "MSVC for x86 (Debug) for UWP", "inherits": [ "base", "x86", "Debug", "MSVC", "UWP" ] }, - { "name": "x86-Release-UWP" , "description": "MSVC for x86 (Release) for UWP", "inherits": [ "base", "x86", "Release", "MSVC", "UWP" ] }, - { "name": "arm-Debug-UWP" , "description": "MSVC for ARM (Debug) for UWP", "inherits": [ "base", "ARM", "Debug", "MSVC", "UWP" ] }, - { "name": "arm-Release-UWP" , "description": "MSVC for ARM (Release) for UWP", "inherits": [ "base", "ARM", "Release", "MSVC", "UWP" ] }, - { "name": "arm64-Debug-UWP" , "description": "MSVC for ARM64 (Debug) for UWP", "inherits": [ "base", "ARM64", "Debug", "MSVC", "UWP" ] }, - { "name": "arm64-Release-UWP", "description": "MSVC for ARM64 (Release) for UWP", "inherits": [ "base", "ARM64", "Release", "MSVC", "UWP" ] }, - - { "name": "x64-Debug-Win7" , "description": "MSVC for x64 (Debug) for Windows 7", "inherits": [ "base", "x64", "Debug", "MSVC", "Win7" ] }, - { "name": "x64-Release-Win7" , "description": "MSVC for x64 (Release) for Windows 7", "inherits": [ "base", "x64", "Release", "MSVC", "Win7" ] }, - { "name": "x86-Debug-Win7" , "description": "MSVC for x86 (Debug) for Windows 7", "inherits": [ "base", "x86", "Debug", "MSVC", "Win7" ] }, - { "name": "x86-Release-Win7" , "description": "MSVC for x86 (Release) for Windows 7", "inherits": [ "base", "x86", "Release", "MSVC", "Win7" ] }, - - { "name": "x64-Debug-VCPKG" , "description": "MSVC for x64 (Debug) using VCPKG", "inherits": [ "base", "x64", "Debug", "MSVC", "VCPKG" ] }, - { "name": "x64-Release-VCPKG" , "description": "MSVC for x64 (Release) using VCPKG", "inherits": [ "base", "x64", "Release", "MSVC", "VCPKG" ] }, - { "name": "x86-Debug-VCPKG" , "description": "MSVC for x86 (Debug) using VCPKG", "inherits": [ "base", "x86", "Debug", "MSVC", "VCPKG" ] }, - { "name": "x86-Release-VCPKG" , "description": "MSVC for x86 (Release) using VCPKG", "inherits": [ "base", "x86", "Release", "MSVC", "VCPKG" ] }, - { "name": "arm64-Debug-VCPKG" , "description": "MSVC for ARM64 (Debug) using VCPKG", "inherits": [ "base", "ARM64", "Debug", "MSVC", "VCPKG" ] }, - { "name": "arm64-Release-VCPKG", "description": "MSVC for ARM64 (Release) using VCPKG", "inherits": [ "base", "ARM64", "Release", "MSVC", "VCPKG" ] }, - - { "name": "x64-Debug-Clang" , "description": "Clang/LLVM for x64 (Debug) with DX12", "inherits": [ "base", "x64", "Debug", "Clang" ] }, - { "name": "x64-Release-Clang" , "description": "Clang/LLVM for x64 (Release) with DX12", "inherits": [ "base", "x64", "Release", "Clang" ] }, - { "name": "x86-Debug-Clang" , "description": "Clang/LLVM for x86 (Debug) with DX12", "inherits": [ "base", "x86", "Debug", "Clang" ], "environment": { "CXXFLAGS": "-m32" } }, - { "name": "x86-Release-Clang" , "description": "Clang/LLVM for x86 (Release) with DX12", "inherits": [ "base", "x86", "Release", "Clang" ], "environment": { "CXXFLAGS": "-m32" } }, - { "name": "arm64-Debug-Clang" , "description": "Clang/LLVM for AArch64 (Debug) with DX12", "inherits": [ "base", "ARM64", "Debug", "Clang" ], "environment": { "CXXFLAGS": "--target=arm64-pc-windows-msvc" } }, - { "name": "arm64-Release-Clang", "description": "Clang/LLVM for AArch64 (Release) with DX12", "inherits": [ "base", "ARM64", "Release", "Clang" ], "environment": { "CXXFLAGS": "--target=arm64-pc-windows-msvc" } }, - - { "name": "x64-Debug-UWP-Clang" , "description": "Clang/LLVM for x64 (Debug) for UWP", "inherits": [ "base", "x64", "Debug", "Clang", "UWP" ] }, - { "name": "x64-Release-UWP-Clang" , "description": "Clang/LLVM for x64 (Release) for UWP", "inherits": [ "base", "x64", "Release", "Clang", "UWP" ] }, - { "name": "x86-Debug-UWP-Clang" , "description": "Clang/LLVM for x86 (Debug) for UWP", "inherits": [ "base", "x86", "Debug", "Clang", "UWP" ], "environment": { "CXXFLAGS": "-m32" } }, - { "name": "x86-Release-UWP-Clang" , "description": "Clang/LLVM for x86 (Release) for UWP", "inherits": [ "base", "x86", "Release", "Clang", "UWP" ], "environment": { "CXXFLAGS": "-m32" } }, - { "name": "arm64-Debug-UWP-Clang" , "description": "Clang/LLVM for AArch64 (Debug) for UWP", "inherits": [ "base", "ARM64", "Debug", "Clang", "UWP" ], "environment": { "CXXFLAGS": "--target=arm64-pc-windows-msvc" } }, - { "name": "arm64-Release-UWP-Clang", "description": "Clang/LLVM for AArch64 (Release) for UWP", "inherits": [ "base", "ARM64", "Release", "Clang", "UWP" ], "environment": { "CXXFLAGS": "--target=arm64-pc-windows-msvc" } }, - - { "name": "x64-Debug-Win7-Clang" , "description": "Clang/LLVM for x64 (Debug) for Windows 7", "inherits": [ "base", "x64", "Debug", "Clang", "Win7" ] }, - { "name": "x64-Release-Win7-Clang" , "description": "Clang/LLVM for x64 (Release) for Windows 7", "inherits": [ "base", "x64", "Release", "Clang", "Win7" ] }, - { "name": "x86-Debug-Win7-Clang" , "description": "Clang/LLVM for x86 (Debug) for Windows 7", "inherits": [ "base", "x86", "Debug", "Clang", "Win7" ], "environment": { "CXXFLAGS": "-m32" } }, - { "name": "x86-Release-Win7-Clang" , "description": "Clang/LLVM for x86 (Release) for Windows 7", "inherits": [ "base", "x86", "Release", "Clang", "Win7" ], "environment": { "CXXFLAGS": "-m32" } }, - - { "name": "x64-Debug-MinGW" , "description": "MinG-W64 (Debug)", "inherits": [ "base", "x64", "Debug", "GNUC", "VCPKG" ], "environment": { "PATH": "$penv{PATH};c:/mingw64/bin" } }, - { "name": "x64-Release-MinGW", "description": "MinG-W64 (Release)", "inherits": [ "base", "x64", "Release", "GNUC", "VCPKG" ], "environment": { "PATH": "$penv{PATH};c:/mingw64/bin" } }, - { "name": "x86-Debug-MinGW" , "description": "MinG-W32 (Debug)", "inherits": [ "base", "x86", "Debug", "GNUC", "VCPKG" ], "environment": { "PATH": "$penv{PATH};c:/mingw32/bin" } }, - { "name": "x86-Release-MinGW", "description": "MinG-W32 (Release)", "inherits": [ "base", "x86", "Release", "GNUC", "VCPKG" ], "environment": { "PATH": "$penv{PATH};c:/mingw32/bin" } } - ] -} \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh.h b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh.h deleted file mode 100644 index 6cfecde..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh.h +++ /dev/null @@ -1,650 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXMesh.h -// -// DirectX Mesh Geometry Library -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkID=324981 -//------------------------------------------------------------------------------------- - -#pragma once - -#include -#include -#include -#include -#include -#include -#include - -#ifdef _WIN32 -#if !defined(__d3d11_h__) && !defined(__d3d11_x_h__) && !defined(__d3d12_h__) && !defined(__d3d12_x_h__) && !defined(__XBOX_D3D12_X__) -#ifdef _GAMING_XBOX_SCARLETT -#include -#elif defined(_GAMING_XBOX) -#include -#elif defined(_XBOX_ONE) && defined(_TITLE) -#include -#else -#include -#endif -#endif -#else // !WIN32 -#include -#include -#endif - -#include -#include -#include - -#define DIRECTX_MESH_VERSION 163 - - -namespace DirectX -{ - //--------------------------------------------------------------------------------- - // DXGI Format Utilities - bool __cdecl IsValidVB(_In_ DXGI_FORMAT fmt) noexcept; - constexpr bool __cdecl IsValidIB(_In_ DXGI_FORMAT fmt) noexcept; - size_t __cdecl BytesPerElement(_In_ DXGI_FORMAT fmt) noexcept; - - - //--------------------------------------------------------------------------------- - // Input Layout Descriptor Utilities -#if defined(__d3d11_h__) || defined(__d3d11_x_h__) - bool __cdecl IsValid(_In_reads_(nDecl) const D3D11_INPUT_ELEMENT_DESC* vbDecl, _In_ size_t nDecl) noexcept; - void __cdecl ComputeInputLayout( - _In_reads_(nDecl) const D3D11_INPUT_ELEMENT_DESC* vbDecl, _In_ size_t nDecl, - _Out_writes_opt_(nDecl) uint32_t* offsets, - _Out_writes_opt_(D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT) uint32_t* strides) noexcept; -#endif - -#if defined(__d3d12_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__) - bool __cdecl IsValid(const D3D12_INPUT_LAYOUT_DESC& vbDecl) noexcept; - void __cdecl ComputeInputLayout( - const D3D12_INPUT_LAYOUT_DESC& vbDecl, - _Out_writes_opt_(vbDecl.NumElements) uint32_t* offsets, - _Out_writes_opt_(D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT) uint32_t* strides) noexcept; -#endif - - //--------------------------------------------------------------------------------- - // Attribute Utilities - std::vector> __cdecl ComputeSubsets(_In_reads_opt_(nFaces) const uint32_t* attributes, _In_ size_t nFaces); - // Returns a list of face offset,counts for attribute groups - - //--------------------------------------------------------------------------------- - // Mesh Optimization Utilities - void __cdecl ComputeVertexCacheMissRate( - _In_reads_(nFaces * 3) const uint16_t* indices, _In_ size_t nFaces, _In_ size_t nVerts, - _In_ size_t cacheSize, _Out_ float& acmr, _Out_ float& atvr); - void __cdecl ComputeVertexCacheMissRate( - _In_reads_(nFaces * 3) const uint32_t* indices, _In_ size_t nFaces, _In_ size_t nVerts, - _In_ size_t cacheSize, _Out_ float& acmr, _Out_ float& atvr); - // Compute the average cache miss ratio and average triangle vertex reuse for the post-transform vertex cache - - //--------------------------------------------------------------------------------- - // Vertex Buffer Reader/Writer - - class VBReader - { - public: - VBReader() noexcept(false); - VBReader(VBReader&&) noexcept; - VBReader& operator= (VBReader&&) noexcept; - - VBReader(VBReader const&) = delete; - VBReader& operator= (VBReader const&) = delete; - - ~VBReader(); - - #if defined(__d3d11_h__) || defined(__d3d11_x_h__) - HRESULT __cdecl Initialize(_In_reads_(nDecl) const D3D11_INPUT_ELEMENT_DESC* vbDecl, _In_ size_t nDecl); - // Does not support VB decls with D3D11_INPUT_PER_INSTANCE_DATA - #endif - - #if defined(__d3d12_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__) - HRESULT __cdecl Initialize(const D3D12_INPUT_LAYOUT_DESC& vbDecl); - // Does not support VB decls with D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA - #endif - - HRESULT __cdecl AddStream(_In_reads_bytes_(stride*nVerts) const void* vb, _In_ size_t nVerts, _In_ size_t inputSlot, _In_ size_t stride = 0) noexcept; - // Add vertex buffer to reader - - HRESULT __cdecl Read(_Out_writes_(count) XMVECTOR* buffer, _In_z_ const char* semanticName, _In_ unsigned int semanticIndex, _In_ size_t count, bool x2bias = false) const; - // Extracts data elements from vertex buffer - - HRESULT __cdecl Read(_Out_writes_(count) float* buffer, _In_z_ const char* semanticName, _In_ unsigned int semanticIndex, _In_ size_t count, bool x2bias = false) const; - HRESULT __cdecl Read(_Out_writes_(count) XMFLOAT2* buffer, _In_z_ const char* semanticName, _In_ unsigned int semanticIndex, _In_ size_t count, bool x2bias = false) const; - HRESULT __cdecl Read(_Out_writes_(count) XMFLOAT3* buffer, _In_z_ const char* semanticName, _In_ unsigned int semanticIndex, _In_ size_t count, bool x2bias = false) const; - HRESULT __cdecl Read(_Out_writes_(count) XMFLOAT4* buffer, _In_z_ const char* semanticName, _In_ unsigned int semanticIndex, _In_ size_t count, bool x2bias = false) const; - // Helpers for data extraction - - void __cdecl Release() noexcept; - - #if defined(__d3d11_h__) || defined(__d3d11_x_h__) - const D3D11_INPUT_ELEMENT_DESC* GetElement(_In_z_ const char* semanticName, _In_ unsigned int semanticIndex) const - { - return GetElement11(semanticName, semanticIndex); - } - - const D3D11_INPUT_ELEMENT_DESC* __cdecl GetElement11(_In_z_ const char* semanticName, _In_ unsigned int semanticIndex) const; - #endif - - #if defined(__d3d12_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__) - const D3D12_INPUT_ELEMENT_DESC* __cdecl GetElement12(_In_z_ const char* semanticName, _In_ unsigned int semanticIndex) const; - #endif - - private: - // Private implementation. - class Impl; - - std::unique_ptr pImpl; - }; - - class VBWriter - { - public: - VBWriter() noexcept(false); - VBWriter(VBWriter&&) noexcept; - VBWriter& operator= (VBWriter&&) noexcept; - - VBWriter(VBWriter const&) = delete; - VBWriter& operator= (VBWriter const&) = delete; - - ~VBWriter(); - - #if defined(__d3d11_h__) || defined(__d3d11_x_h__) - HRESULT __cdecl Initialize(_In_reads_(nDecl) const D3D11_INPUT_ELEMENT_DESC* vbDecl, _In_ size_t nDecl); - // Does not support VB decls with D3D11_INPUT_PER_INSTANCE_DATA - #endif - - #if defined(__d3d12_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__) - HRESULT __cdecl Initialize(const D3D12_INPUT_LAYOUT_DESC& vbDecl); - // Does not support VB decls with D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA - #endif - - HRESULT __cdecl AddStream(_Out_writes_bytes_(stride*nVerts) void* vb, _In_ size_t nVerts, _In_ size_t inputSlot, _In_ size_t stride = 0) noexcept; - // Add vertex buffer to writer - - HRESULT __cdecl Write(_In_reads_(count) const XMVECTOR* buffer, _In_z_ const char* semanticName, _In_ unsigned int semanticIndex, _In_ size_t count, bool x2bias = false) const; - // Inserts data elements into vertex buffer - - HRESULT __cdecl Write(_In_reads_(count) const float* buffer, _In_z_ const char* semanticName, _In_ unsigned int semanticIndex, _In_ size_t count, bool x2bias = false) const; - HRESULT __cdecl Write(_In_reads_(count) const XMFLOAT2* buffer, _In_z_ const char* semanticName, _In_ unsigned int semanticIndex, _In_ size_t count, bool x2bias = false) const; - HRESULT __cdecl Write(_In_reads_(count) const XMFLOAT3* buffer, _In_z_ const char* semanticName, _In_ unsigned int semanticIndex, _In_ size_t count, bool x2bias = false) const; - HRESULT __cdecl Write(_In_reads_(count) const XMFLOAT4* buffer, _In_z_ const char* semanticName, _In_ unsigned int semanticIndex, _In_ size_t count, bool x2bias = false) const; - // Helpers for data insertion - - void __cdecl Release() noexcept; - - #if defined(__d3d11_h__) || defined(__d3d11_x_h__) - const D3D11_INPUT_ELEMENT_DESC* __cdecl GetElement(_In_z_ const char* semanticName, _In_ unsigned int semanticIndex) const - { - return GetElement11(semanticName, semanticIndex); - } - - const D3D11_INPUT_ELEMENT_DESC* __cdecl GetElement11(_In_z_ const char* semanticName, _In_ unsigned int semanticIndex) const; - #endif - - #if defined(__d3d12_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__) - const D3D12_INPUT_ELEMENT_DESC* __cdecl GetElement12(_In_z_ const char* semanticName, _In_ unsigned int semanticIndex) const; - #endif - - private: - // Private implementation. - class Impl; - - std::unique_ptr pImpl; - }; - - //--------------------------------------------------------------------------------- - // Adjacency Computation - - HRESULT __cdecl GenerateAdjacencyAndPointReps( - _In_reads_(nFaces * 3) const uint16_t* indices, _In_ size_t nFaces, - _In_reads_(nVerts) const XMFLOAT3* positions, _In_ size_t nVerts, - _In_ float epsilon, - _Out_writes_opt_(nVerts) uint32_t* pointRep, - _Out_writes_opt_(nFaces * 3) uint32_t* adjacency); - HRESULT __cdecl GenerateAdjacencyAndPointReps( - _In_reads_(nFaces * 3) const uint32_t* indices, _In_ size_t nFaces, - _In_reads_(nVerts) const XMFLOAT3* positions, _In_ size_t nVerts, - _In_ float epsilon, - _Out_writes_opt_(nVerts) uint32_t* pointRep, - _Out_writes_opt_(nFaces * 3) uint32_t* adjacency); - // If pointRep is null, it still generates them internally as they are needed for the final adjacency computation - - HRESULT __cdecl ConvertPointRepsToAdjacency( - _In_reads_(nFaces * 3) const uint16_t* indices, _In_ size_t nFaces, - _In_reads_(nVerts) const XMFLOAT3* positions, _In_ size_t nVerts, - _In_reads_opt_(nVerts) const uint32_t* pointRep, - _Out_writes_(nFaces * 3) uint32_t* adjacency); - HRESULT __cdecl ConvertPointRepsToAdjacency( - _In_reads_(nFaces * 3) const uint32_t* indices, _In_ size_t nFaces, - _In_reads_(nVerts) const XMFLOAT3* positions, _In_ size_t nVerts, - _In_reads_opt_(nVerts) const uint32_t* pointRep, - _Out_writes_(nFaces * 3) uint32_t* adjacency); - // If pointRep is null, assumes an identity - - HRESULT __cdecl GenerateGSAdjacency( - _In_reads_(nFaces * 3) const uint16_t* indices, _In_ size_t nFaces, - _In_reads_(nVerts) const uint32_t* pointRep, - _In_reads_(nFaces * 3) const uint32_t* adjacency, _In_ size_t nVerts, - _Out_writes_(nFaces * 6) uint16_t* indicesAdj) noexcept; - HRESULT __cdecl GenerateGSAdjacency( - _In_reads_(nFaces * 3) const uint32_t* indices, _In_ size_t nFaces, - _In_reads_(nVerts) const uint32_t* pointRep, - _In_reads_(nFaces * 3) const uint32_t* adjacency, _In_ size_t nVerts, - _Out_writes_(nFaces * 6) uint32_t* indicesAdj) noexcept; - // Generates an IB suitable for Geometry Shader using D3D1x_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ - - //--------------------------------------------------------------------------------- - // Normals, Tangents, and Bi-Tangents Computation - - enum CNORM_FLAGS : unsigned long - { - CNORM_DEFAULT = 0x0, - // Default is to compute normals using weight-by-angle - - CNORM_WEIGHT_BY_AREA = 0x1, - // Computes normals using weight-by-area - - CNORM_WEIGHT_EQUAL = 0x2, - // Compute normals with equal weights - - CNORM_WIND_CW = 0x4, - // Vertices are clock-wise (defaults to CCW) - }; - - HRESULT __cdecl ComputeNormals( - _In_reads_(nFaces * 3) const uint16_t* indices, _In_ size_t nFaces, - _In_reads_(nVerts) const XMFLOAT3* positions, _In_ size_t nVerts, - _In_ CNORM_FLAGS flags, - _Out_writes_(nVerts) XMFLOAT3* normals) noexcept; - HRESULT __cdecl ComputeNormals( - _In_reads_(nFaces * 3) const uint32_t* indices, _In_ size_t nFaces, - _In_reads_(nVerts) const XMFLOAT3* positions, _In_ size_t nVerts, - _In_ CNORM_FLAGS flags, - _Out_writes_(nVerts) XMFLOAT3* normals) noexcept; - // Computes vertex normals - - HRESULT __cdecl ComputeTangentFrame( - _In_reads_(nFaces * 3) const uint16_t* indices, _In_ size_t nFaces, - _In_reads_(nVerts) const XMFLOAT3* positions, - _In_reads_(nVerts) const XMFLOAT3* normals, - _In_reads_(nVerts) const XMFLOAT2* texcoords, _In_ size_t nVerts, - _Out_writes_opt_(nVerts) XMFLOAT3* tangents, - _Out_writes_opt_(nVerts) XMFLOAT3* bitangents) noexcept; - HRESULT __cdecl ComputeTangentFrame( - _In_reads_(nFaces * 3) const uint32_t* indices, _In_ size_t nFaces, - _In_reads_(nVerts) const XMFLOAT3* positions, - _In_reads_(nVerts) const XMFLOAT3* normals, - _In_reads_(nVerts) const XMFLOAT2* texcoords, _In_ size_t nVerts, - _Out_writes_opt_(nVerts) XMFLOAT3* tangents, - _Out_writes_opt_(nVerts) XMFLOAT3* bitangents) noexcept; - HRESULT __cdecl ComputeTangentFrame( - _In_reads_(nFaces * 3) const uint16_t* indices, _In_ size_t nFaces, - _In_reads_(nVerts) const XMFLOAT3* positions, - _In_reads_(nVerts) const XMFLOAT3* normals, - _In_reads_(nVerts) const XMFLOAT2* texcoords, _In_ size_t nVerts, - _Out_writes_opt_(nVerts) XMFLOAT4* tangents, - _Out_writes_opt_(nVerts) XMFLOAT3* bitangents) noexcept; - HRESULT __cdecl ComputeTangentFrame( - _In_reads_(nFaces * 3) const uint32_t* indices, _In_ size_t nFaces, - _In_reads_(nVerts) const XMFLOAT3* positions, - _In_reads_(nVerts) const XMFLOAT3* normals, - _In_reads_(nVerts) const XMFLOAT2* texcoords, _In_ size_t nVerts, - _Out_writes_opt_(nVerts) XMFLOAT4* tangents, - _Out_writes_opt_(nVerts) XMFLOAT3* bitangents) noexcept; - HRESULT __cdecl ComputeTangentFrame( - _In_reads_(nFaces * 3) const uint16_t* indices, _In_ size_t nFaces, - _In_reads_(nVerts) const XMFLOAT3* positions, - _In_reads_(nVerts) const XMFLOAT3* normals, - _In_reads_(nVerts) const XMFLOAT2* texcoords, _In_ size_t nVerts, - _Out_writes_(nVerts) XMFLOAT4* tangents) noexcept; - HRESULT __cdecl ComputeTangentFrame( - _In_reads_(nFaces * 3) const uint32_t* indices, _In_ size_t nFaces, - _In_reads_(nVerts) const XMFLOAT3* positions, - _In_reads_(nVerts) const XMFLOAT3* normals, - _In_reads_(nVerts) const XMFLOAT2* texcoords, _In_ size_t nVerts, - _Out_writes_(nVerts) XMFLOAT4* tangents) noexcept; - // Computes tangents and/or bi-tangents (optionally with handedness stored in .w) - - //--------------------------------------------------------------------------------- - // Mesh clean-up and validation - - enum VALIDATE_FLAGS : unsigned long - { - VALIDATE_DEFAULT = 0x0, - - VALIDATE_BACKFACING = 0x1, - // Check for duplicate neighbor from triangle (requires adjacency) - - VALIDATE_BOWTIES = 0x2, - // Check for two fans of triangles using the same vertex (requires adjacency) - - VALIDATE_DEGENERATE = 0x4, - // Check for degenerate triangles - - VALIDATE_UNUSED = 0x8, - // Check for issues with 'unused' triangles - - VALIDATE_ASYMMETRIC_ADJ = 0x10, - // Checks that neighbors are symmetric (requires adjacency) - }; - - HRESULT __cdecl Validate( - _In_reads_(nFaces * 3) const uint16_t* indices, _In_ size_t nFaces, - _In_ size_t nVerts, _In_reads_opt_(nFaces * 3) const uint32_t* adjacency, - _In_ VALIDATE_FLAGS flags, _In_opt_ std::wstring* msgs = nullptr); - HRESULT __cdecl Validate( - _In_reads_(nFaces * 3) const uint32_t* indices, _In_ size_t nFaces, - _In_ size_t nVerts, _In_reads_opt_(nFaces * 3) const uint32_t* adjacency, - _In_ VALIDATE_FLAGS flags, _In_opt_ std::wstring* msgs = nullptr); - // Checks the mesh for common problems, return 'S_OK' if no problems were found - - HRESULT __cdecl Clean( - _Inout_updates_all_(nFaces * 3) uint16_t* indices, _In_ size_t nFaces, - _In_ size_t nVerts, _Inout_updates_all_opt_(nFaces * 3) uint32_t* adjacency, - _In_reads_opt_(nFaces) const uint32_t* attributes, - _Inout_ std::vector& dupVerts, _In_ bool breakBowties = false); - HRESULT __cdecl Clean( - _Inout_updates_all_(nFaces * 3) uint32_t* indices, _In_ size_t nFaces, - _In_ size_t nVerts, _Inout_updates_all_opt_(nFaces * 3) uint32_t* adjacency, - _In_reads_opt_(nFaces) const uint32_t* attributes, - _Inout_ std::vector& dupVerts, _In_ bool breakBowties = false); - // Cleans the mesh, splitting vertices if needed - - //--------------------------------------------------------------------------------- - // Mesh utilities - - HRESULT __cdecl WeldVertices( - _Inout_updates_all_(nFaces * 3) uint16_t* indices, _In_ size_t nFaces, - _In_ size_t nVerts, _In_reads_(nVerts) const uint32_t* pointRep, - _Out_writes_opt_(nVerts) uint32_t* vertexRemap, - _In_ std::function weldTest); - HRESULT __cdecl WeldVertices( - _Inout_updates_all_(nFaces * 3) uint32_t* indices, _In_ size_t nFaces, - _In_ size_t nVerts, _In_reads_(nVerts) const uint32_t* pointRep, - _Out_writes_opt_(nVerts) uint32_t* vertexRemap, - _In_ std::function weldTest); - // Welds vertices together based on a test function - - HRESULT __cdecl ConcatenateMesh( - _In_ size_t nFaces, - _In_ size_t nVerts, - _Out_writes_(nFaces) uint32_t* faceDestMap, - _Out_writes_(nVerts) uint32_t* vertexDestMap, - _Inout_ size_t& totalFaces, - _Inout_ size_t& totalVerts) noexcept; - // Merge meshes together - - //--------------------------------------------------------------------------------- - // Mesh Optimization - - HRESULT __cdecl AttributeSort( - _In_ size_t nFaces, _Inout_updates_all_(nFaces) uint32_t* attributes, - _Out_writes_(nFaces) uint32_t* faceRemap); - // Reorders faces by attribute id - - enum OPTFACES : uint32_t - { - OPTFACES_V_DEFAULT = 12, - OPTFACES_R_DEFAULT = 7, - // Default vertex cache size and restart threshold which is considered 'device independent' - - OPTFACES_LRU_DEFAULT = 32, - // Default vertex cache size for the LRU algorithm - - OPTFACES_V_STRIPORDER = 0, - // Indicates no vertex cache optimization, only reordering into strips - }; - - HRESULT __cdecl OptimizeFaces( - _In_reads_(nFaces * 3) const uint16_t* indices, _In_ size_t nFaces, - _In_reads_(nFaces * 3) const uint32_t* adjacency, - _Out_writes_(nFaces) uint32_t* faceRemap, - _In_ uint32_t vertexCache = OPTFACES_V_DEFAULT, - _In_ uint32_t restart = OPTFACES_R_DEFAULT); - HRESULT __cdecl OptimizeFaces( - _In_reads_(nFaces * 3) const uint32_t* indices, _In_ size_t nFaces, - _In_reads_(nFaces * 3) const uint32_t* adjacency, - _Out_writes_(nFaces) uint32_t* faceRemap, - _In_ uint32_t vertexCache = OPTFACES_V_DEFAULT, - _In_ uint32_t restart = OPTFACES_R_DEFAULT); - HRESULT __cdecl OptimizeFacesLRU( - _In_reads_(nFaces * 3) const uint16_t* indices, _In_ size_t nFaces, - _Out_writes_(nFaces) uint32_t* faceRemap, - _In_ uint32_t lruCacheSize = OPTFACES_LRU_DEFAULT); - HRESULT __cdecl OptimizeFacesLRU( - _In_reads_(nFaces * 3) const uint32_t* indices, _In_ size_t nFaces, - _Out_writes_(nFaces) uint32_t* faceRemap, - _In_ uint32_t lruCacheSize = OPTFACES_LRU_DEFAULT); - // Reorders faces to increase hit rate of vertex caches - - HRESULT __cdecl OptimizeFacesEx( - _In_reads_(nFaces * 3) const uint16_t* indices, _In_ size_t nFaces, - _In_reads_(nFaces * 3) const uint32_t* adjacency, - _In_reads_(nFaces) const uint32_t* attributes, - _Out_writes_(nFaces) uint32_t* faceRemap, - _In_ uint32_t vertexCache = OPTFACES_V_DEFAULT, - _In_ uint32_t restart = OPTFACES_R_DEFAULT); - HRESULT __cdecl OptimizeFacesEx( - _In_reads_(nFaces * 3) const uint32_t* indices, _In_ size_t nFaces, - _In_reads_(nFaces * 3) const uint32_t* adjacency, - _In_reads_(nFaces) const uint32_t* attributes, - _Out_writes_(nFaces) uint32_t* faceRemap, - _In_ uint32_t vertexCache = OPTFACES_V_DEFAULT, - _In_ uint32_t restart = OPTFACES_R_DEFAULT); - HRESULT __cdecl OptimizeFacesLRUEx( - _In_reads_(nFaces * 3) const uint16_t* indices, _In_ size_t nFaces, - _In_reads_(nFaces) const uint32_t* attributes, - _Out_writes_(nFaces) uint32_t* faceRemap, - _In_ uint32_t lruCacheSize = OPTFACES_LRU_DEFAULT); - HRESULT __cdecl OptimizeFacesLRUEx( - _In_reads_(nFaces * 3) const uint32_t* indices, _In_ size_t nFaces, - _In_reads_(nFaces) const uint32_t* attributes, - _Out_writes_(nFaces) uint32_t* faceRemap, - _In_ uint32_t lruCacheSize = OPTFACES_LRU_DEFAULT); - // Attribute group version of OptimizeFaces - - HRESULT __cdecl OptimizeVertices( - _In_reads_(nFaces * 3) const uint16_t* indices, _In_ size_t nFaces, _In_ size_t nVerts, - _Out_writes_(nVerts) uint32_t* vertexRemap, _Out_opt_ size_t* trailingUnused = nullptr) noexcept; - HRESULT __cdecl OptimizeVertices( - _In_reads_(nFaces * 3) const uint32_t* indices, _In_ size_t nFaces, _In_ size_t nVerts, - _Out_writes_(nVerts) uint32_t* vertexRemap, _Out_opt_ size_t* trailingUnused = nullptr) noexcept; - // Reorders vertices in order of use - - //--------------------------------------------------------------------------------- - // Remap functions - - HRESULT __cdecl ReorderIB( - _In_reads_(nFaces * 3) const uint16_t* ibin, _In_ size_t nFaces, - _In_reads_(nFaces) const uint32_t* faceRemap, - _Out_writes_(nFaces * 3) uint16_t* ibout) noexcept; - HRESULT __cdecl ReorderIB( - _Inout_updates_all_(nFaces * 3) uint16_t* ib, _In_ size_t nFaces, - _In_reads_(nFaces) const uint32_t* faceRemap) noexcept; - HRESULT __cdecl ReorderIB( - _In_reads_(nFaces * 3) const uint32_t* ibin, _In_ size_t nFaces, - _In_reads_(nFaces) const uint32_t* faceRemap, - _Out_writes_(nFaces * 3) uint32_t* ibout) noexcept; - HRESULT __cdecl ReorderIB( - _Inout_updates_all_(nFaces * 3) uint32_t* ib, _In_ size_t nFaces, - _In_reads_(nFaces) const uint32_t* faceRemap) noexcept; - // Applies a face remap reordering to an index buffer - - HRESULT __cdecl ReorderIBAndAdjacency( - _In_reads_(nFaces * 3) const uint16_t* ibin, _In_ size_t nFaces, _In_reads_(nFaces * 3) const uint32_t* adjin, - _In_reads_(nFaces) const uint32_t* faceRemap, - _Out_writes_(nFaces * 3) uint16_t* ibout, _Out_writes_(nFaces * 3) uint32_t* adjout) noexcept; - HRESULT __cdecl ReorderIBAndAdjacency( - _Inout_updates_all_(nFaces * 3) uint16_t* ib, _In_ size_t nFaces, _Inout_updates_all_(nFaces * 3) uint32_t* adj, - _In_reads_(nFaces) const uint32_t* faceRemap) noexcept; - HRESULT __cdecl ReorderIBAndAdjacency( - _In_reads_(nFaces * 3) const uint32_t* ibin, _In_ size_t nFaces, _In_reads_(nFaces * 3) const uint32_t* adjin, - _In_reads_(nFaces) const uint32_t* faceRemap, - _Out_writes_(nFaces * 3) uint32_t* ibout, _Out_writes_(nFaces * 3) uint32_t* adjout) noexcept; - HRESULT __cdecl ReorderIBAndAdjacency( - _Inout_updates_all_(nFaces * 3) uint32_t* ib, _In_ size_t nFaces, _Inout_updates_all_(nFaces * 3) uint32_t* adj, - _In_reads_(nFaces) const uint32_t* faceRemap) noexcept; - // Applies a face remap reordering to an index buffer and adjacency - - HRESULT __cdecl FinalizeIB( - _In_reads_(nFaces * 3) const uint16_t* ibin, _In_ size_t nFaces, - _In_reads_(nVerts) const uint32_t* vertexRemap, _In_ size_t nVerts, - _Out_writes_(nFaces * 3) uint16_t* ibout) noexcept; - HRESULT __cdecl FinalizeIB( - _Inout_updates_all_(nFaces * 3) uint16_t* ib, _In_ size_t nFaces, - _In_reads_(nVerts) const uint32_t* vertexRemap, _In_ size_t nVerts) noexcept; - HRESULT __cdecl FinalizeIB( - _In_reads_(nFaces * 3) const uint32_t* ibin, _In_ size_t nFaces, - _In_reads_(nVerts) const uint32_t* vertexRemap, _In_ size_t nVerts, - _Out_writes_(nFaces * 3) uint32_t* ibout) noexcept; - HRESULT __cdecl FinalizeIB( - _Inout_updates_all_(nFaces * 3) uint32_t* ib, _In_ size_t nFaces, - _In_reads_(nVerts) const uint32_t* vertexRemap, _In_ size_t nVerts) noexcept; - // Applies a vertex remap reordering to an index buffer - - HRESULT __cdecl FinalizeVB( - _In_reads_bytes_(nVerts*stride) const void* vbin, _In_ size_t stride, _In_ size_t nVerts, - _In_reads_opt_(nDupVerts) const uint32_t* dupVerts, _In_ size_t nDupVerts, - _In_reads_opt_(nVerts + nDupVerts) const uint32_t* vertexRemap, - _Out_writes_bytes_((nVerts + nDupVerts)*stride) void* vbout) noexcept; - HRESULT __cdecl FinalizeVB( - _Inout_updates_bytes_all_(nVerts*stride) void* vb, _In_ size_t stride, _In_ size_t nVerts, - _In_reads_(nVerts) const uint32_t* vertexRemap) noexcept; - // Applies a vertex remap and/or a vertex duplication set to a vertex buffer - - HRESULT __cdecl FinalizeVBAndPointReps( - _In_reads_bytes_(nVerts*stride) const void* vbin, _In_ size_t stride, _In_ size_t nVerts, - _In_reads_(nVerts) const uint32_t* prin, - _In_reads_opt_(nDupVerts) const uint32_t* dupVerts, _In_ size_t nDupVerts, - _In_reads_opt_(nVerts + nDupVerts) const uint32_t* vertexRemap, - _Out_writes_bytes_((nVerts + nDupVerts)*stride) void* vbout, - _Out_writes_(nVerts + nDupVerts) uint32_t* prout) noexcept; - HRESULT __cdecl FinalizeVBAndPointReps( - _Inout_updates_bytes_all_(nVerts*stride) void* vb, _In_ size_t stride, _In_ size_t nVerts, - _Inout_updates_all_(nVerts) uint32_t* pointRep, - _In_reads_(nVerts) const uint32_t* vertexRemap) noexcept; - // Applies a vertex remap and/or a vertex duplication set to a vertex buffer and point representatives - - HRESULT __cdecl CompactVB( - _In_reads_bytes_(nVerts*stride) const void* vbin, _In_ size_t stride, _In_ size_t nVerts, - _In_ size_t trailingUnused, - _In_reads_opt_(nVerts) const uint32_t* vertexRemap, - _Out_writes_bytes_((nVerts - trailingUnused)*stride) void* vbout) noexcept; - // Applies a vertex remap which contains a known number of unused entries at the end - - //--------------------------------------------------------------------------------- - // Meshlet Generation - - constexpr size_t MESHLET_DEFAULT_MAX_VERTS = 128u; - constexpr size_t MESHLET_DEFAULT_MAX_PRIMS = 128u; - - constexpr size_t MESHLET_MINIMUM_SIZE = 32u; - constexpr size_t MESHLET_MAXIMUM_SIZE = 256u; - - enum MESHLET_FLAGS : unsigned long - { - MESHLET_DEFAULT = 0x0, - - MESHLET_WIND_CW = 0x1, - // Vertices are clock-wise (defaults to CCW) - }; - - struct Meshlet - { - uint32_t VertCount; - uint32_t VertOffset; - uint32_t PrimCount; - uint32_t PrimOffset; - }; - - struct MeshletTriangle - { - uint32_t i0 : 10; - uint32_t i1 : 10; - uint32_t i2 : 10; - }; - - struct CullData - { - DirectX::BoundingSphere BoundingSphere; // xyz = center, w = radius - DirectX::PackedVector::XMUBYTEN4 NormalCone; // xyz = axis, w = -cos(a + 90) - float ApexOffset; // apex = center - axis * offset - }; - - HRESULT __cdecl ComputeMeshlets( - _In_reads_(nFaces * 3) const uint16_t* indices, _In_ size_t nFaces, - _In_reads_(nVerts) const XMFLOAT3* positions, _In_ size_t nVerts, - _In_reads_opt_(nFaces * 3) const uint32_t* adjacency, - _Inout_ std::vector& meshlets, - _Inout_ std::vector& uniqueVertexIB, - _Inout_ std::vector& primitiveIndices, - _In_ size_t maxVerts = MESHLET_DEFAULT_MAX_VERTS, _In_ size_t maxPrims = MESHLET_DEFAULT_MAX_PRIMS); - HRESULT __cdecl ComputeMeshlets( - _In_reads_(nFaces * 3) const uint32_t* indices, _In_ size_t nFaces, - _In_reads_(nVerts) const XMFLOAT3* positions, _In_ size_t nVerts, - _In_reads_opt_(nFaces * 3) const uint32_t* adjacency, - _Inout_ std::vector& meshlets, - _Inout_ std::vector& uniqueVertexIB, - _Inout_ std::vector& primitiveIndices, - _In_ size_t maxVerts = MESHLET_DEFAULT_MAX_VERTS, _In_ size_t maxPrims = MESHLET_DEFAULT_MAX_PRIMS); - // Generates meshlets for a single subset mesh - - HRESULT __cdecl ComputeMeshlets( - _In_reads_(nFaces * 3) const uint16_t* indices, _In_ size_t nFaces, - _In_reads_(nVerts) const XMFLOAT3* positions, _In_ size_t nVerts, - _In_reads_(nSubsets) const std::pair* subsets, _In_ size_t nSubsets, - _In_reads_opt_(nFaces * 3) const uint32_t* adjacency, - _Inout_ std::vector& meshlets, - _Inout_ std::vector& uniqueVertexIB, - _Inout_ std::vector& primitiveIndices, - _Out_writes_(nSubsets) std::pair* meshletSubsets, - _In_ size_t maxVerts = MESHLET_DEFAULT_MAX_VERTS, _In_ size_t maxPrims = MESHLET_DEFAULT_MAX_PRIMS); - HRESULT __cdecl ComputeMeshlets( - _In_reads_(nFaces * 3) const uint32_t* indices, _In_ size_t nFaces, - _In_reads_(nVerts) const XMFLOAT3* positions, _In_ size_t nVerts, - _In_reads_(nSubsets) const std::pair* subsets, _In_ size_t nSubsets, - _In_reads_opt_(nFaces * 3) const uint32_t* adjacency, - _Inout_ std::vector& meshlets, - _Inout_ std::vector& uniqueVertexIB, - _Inout_ std::vector& primitiveIndices, - _Out_writes_(nSubsets) std::pair* meshletSubsets, - _In_ size_t maxVerts = MESHLET_DEFAULT_MAX_VERTS, _In_ size_t maxPrims = MESHLET_DEFAULT_MAX_PRIMS); - // Generates meshlets for a mesh with several face subsets - - HRESULT __cdecl ComputeCullData( - _In_reads_(nVerts) const XMFLOAT3* positions, _In_ size_t nVerts, - _In_reads_(nMeshlets) const Meshlet* meshlets, _In_ size_t nMeshlets, - _In_reads_(nVertIndices) const uint16_t* uniqueVertexIndices, _In_ size_t nVertIndices, - _In_reads_(nPrimIndices) const MeshletTriangle* primitiveIndices, _In_ size_t nPrimIndices, - _Out_writes_(nMeshlets) CullData* cullData, - _In_ MESHLET_FLAGS flags = MESHLET_DEFAULT) noexcept; - HRESULT __cdecl ComputeCullData( - _In_reads_(nVerts) const XMFLOAT3* positions, _In_ size_t nVerts, - _In_reads_(nMeshlets) const Meshlet* meshlets, _In_ size_t nMeshlets, - _In_reads_(nVertIndices) const uint32_t* uniqueVertexIndices, _In_ size_t nVertIndices, - _In_reads_(nPrimIndices) const MeshletTriangle* primitiveIndices, _In_ size_t nPrimIndices, - _Out_writes_(nMeshlets) CullData* cullData, - _In_ MESHLET_FLAGS flags = MESHLET_DEFAULT) noexcept; - // Computes culling data for each input meshlet - - //--------------------------------------------------------------------------------- -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-dynamic-exception-spec" -#endif - -#include "DirectXMesh.inl" - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -} // namespace diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh.inl b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh.inl deleted file mode 100644 index 7f9cbb3..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh.inl +++ /dev/null @@ -1,35 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXMesh.inl -// -// DirectX Mesh Geometry Library -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkID=324981 -//------------------------------------------------------------------------------------- - -#pragma once - -//===================================================================================== -// Bitmask flags enumerator operators -//===================================================================================== -DEFINE_ENUM_FLAG_OPERATORS(CNORM_FLAGS); -DEFINE_ENUM_FLAG_OPERATORS(VALIDATE_FLAGS); -DEFINE_ENUM_FLAG_OPERATORS(MESHLET_FLAGS); - - -//===================================================================================== -// DXGI Format Utilities -//===================================================================================== -_Use_decl_annotations_ -inline bool __cdecl IsValidVB(DXGI_FORMAT fmt) noexcept -{ - return BytesPerElement(fmt) != 0; -} - -_Use_decl_annotations_ -constexpr bool __cdecl IsValidIB(DXGI_FORMAT fmt) noexcept -{ - return (fmt == DXGI_FORMAT_R32_UINT || fmt == DXGI_FORMAT_R16_UINT) != 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshAdjacency.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshAdjacency.cpp deleted file mode 100644 index 9ab953d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshAdjacency.cpp +++ /dev/null @@ -1,784 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXMeshAdjacency.cpp -// -// DirectX Mesh Geometry Library - Adjacency computation -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkID=324981 -//------------------------------------------------------------------------------------- - -#include "DirectXMeshP.h" - -using namespace DirectX; - -namespace -{ - //--------------------------------------------------------------------------------- - // Utilities - //--------------------------------------------------------------------------------- - struct vertexHashEntry - { - XMFLOAT3 v; - uint32_t index; - vertexHashEntry * next; - }; - - struct edgeHashEntry - { - uint32_t v1; - uint32_t v2; - uint32_t vOther; - uint32_t face; - edgeHashEntry * next; - }; - - // std::make_heap doesn't match D3DX10 so we use the same algorithm here - void MakeXHeap( - _Out_writes_(nVerts) uint32_t *index, - _In_reads_(nVerts) const XMFLOAT3* positions, size_t nVerts) noexcept - { - for (uint32_t vert = 0; vert < nVerts; ++vert) - { - index[vert] = vert; - } - - if (nVerts > 1) - { - // Create the heap - uint32_t iulLim = uint32_t(nVerts); - - for (uint32_t vert = uint32_t(nVerts >> 1); --vert != uint32_t(-1); ) - { - // Percolate down - uint32_t iulI = vert; - uint32_t iulJ = vert + vert + 1; - const uint32_t ulT = index[iulI]; - - while (iulJ < iulLim) - { - uint32_t ulJ = index[iulJ]; - - if (iulJ + 1 < iulLim) - { - const uint32_t ulJ1 = index[iulJ + 1]; - if (positions[ulJ1].x <= positions[ulJ].x) - { - iulJ++; - ulJ = ulJ1; - } - } - - if (positions[ulJ].x > positions[ulT].x) - break; - - index[iulI] = index[iulJ]; - iulI = iulJ; - iulJ += iulJ + 1; - } - - index[iulI] = ulT; - } - - // Sort the heap - while (--iulLim != uint32_t(-1)) - { - const uint32_t ulT = index[iulLim]; - index[iulLim] = index[0]; - - // Percolate down - uint32_t iulI = 0; - uint32_t iulJ = 1; - - while (iulJ < iulLim) - { - _Analysis_assume_(iulJ < nVerts); - uint32_t ulJ = index[iulJ]; - - if (iulJ + 1 < iulLim) - { - const uint32_t ulJ1 = index[iulJ + 1]; - if (positions[ulJ1].x <= positions[ulJ].x) - { - iulJ++; - ulJ = ulJ1; - } - } - - if (positions[ulJ].x > positions[ulT].x) - break; - - index[iulI] = index[iulJ]; - iulI = iulJ; - iulJ += iulJ + 1; - } - - assert(iulI < nVerts); - _Analysis_assume_(iulI < nVerts); - index[iulI] = ulT; - } - } - } - - - //--------------------------------------------------------------------------------- - // PointRep computation - //--------------------------------------------------------------------------------- - template - HRESULT GeneratePointReps( - _In_reads_(nFaces * 3) const index_t* indices, size_t nFaces, - _In_reads_(nVerts) const XMFLOAT3* positions, size_t nVerts, - float epsilon, - _Out_writes_(nVerts) uint32_t* pointRep) noexcept - { - std::unique_ptr temp(new (std::nothrow) uint32_t[nVerts + nFaces * 3]); - if (!temp) - return E_OUTOFMEMORY; - - uint32_t* vertexToCorner = temp.get(); - uint32_t* vertexCornerList = temp.get() + nVerts; - - memset(vertexToCorner, 0xff, sizeof(uint32_t) * nVerts); - memset(vertexCornerList, 0xff, sizeof(uint32_t) * nFaces * 3); - - // build initial lists and validate indices - for (size_t j = 0; j < (nFaces * 3); ++j) - { - index_t k = indices[j]; - if (k == index_t(-1)) - continue; - - if (k >= nVerts) - return E_UNEXPECTED; - - vertexCornerList[j] = vertexToCorner[k]; - vertexToCorner[k] = uint32_t(j); - } - - if (epsilon == 0.f) - { - auto hashSize = std::max(nVerts / 3, 1); - - std::unique_ptr hashTable(new (std::nothrow) vertexHashEntry*[hashSize]); - if (!hashTable) - return E_OUTOFMEMORY; - - memset(hashTable.get(), 0, sizeof(vertexHashEntry*) * hashSize); - - std::unique_ptr hashEntries(new (std::nothrow) vertexHashEntry[nVerts]); - if (!hashEntries) - return E_OUTOFMEMORY; - - uint32_t freeEntry = 0; - - for (size_t vert = 0; vert < nVerts; ++vert) - { - auto px = reinterpret_cast(&positions[vert].x); - auto py = reinterpret_cast(&positions[vert].y); - auto pz = reinterpret_cast(&positions[vert].z); - const uint32_t hashKey = (*px + *py + *pz) % uint32_t(hashSize); - - uint32_t found = UNUSED32; - - for (auto current = hashTable[hashKey]; current != nullptr; current = current->next) - { - if (current->v.x == positions[vert].x - && current->v.y == positions[vert].y - && current->v.z == positions[vert].z) - { - uint32_t head = vertexToCorner[vert]; - - bool ispresent = false; - - while (head != UNUSED32) - { - const uint32_t face = head / 3; - assert(face < nFaces); - _Analysis_assume_(face < nFaces); - - assert((indices[face * 3] == vert) || (indices[face * 3 + 1] == vert) || (indices[face * 3 + 2] == vert)); - - if ((indices[face * 3] == current->index) || (indices[face * 3 + 1] == current->index) || (indices[face * 3 + 2] == current->index)) - { - ispresent = true; - break; - } - - head = vertexCornerList[head]; - } - - if (!ispresent) - { - found = current->index; - break; - } - } - } - - if (found != UNUSED32) - { - pointRep[vert] = found; - } - else - { - assert(freeEntry < nVerts); - _Analysis_assume_(freeEntry < nVerts); - - auto newEntry = &hashEntries[freeEntry]; - ++freeEntry; - - newEntry->v = positions[vert]; - newEntry->index = uint32_t(vert); - newEntry->next = hashTable[hashKey]; - hashTable[hashKey] = newEntry; - - pointRep[vert] = uint32_t(vert); - } - } - - assert(freeEntry <= nVerts); - - return S_OK; - } - else - { - std::unique_ptr xorder(new (std::nothrow) uint32_t[nVerts]); - if (!xorder) - return E_OUTOFMEMORY; - - // order in descending order - MakeXHeap(xorder.get(), positions, nVerts); - - memset(pointRep, 0xff, sizeof(uint32_t) * nVerts); - - const XMVECTOR vepsilon = XMVectorReplicate(epsilon * epsilon); - - uint32_t head = 0; - uint32_t tail = 0; - - while (tail < nVerts) - { - // move head until just out of epsilon - while ((head < nVerts) - && ((positions[tail].x - positions[head].x) <= epsilon)) - { - ++head; - } - - // check new tail against all points up to the head - uint32_t tailIndex = xorder[tail]; - assert(tailIndex < nVerts); - _Analysis_assume_(tailIndex < nVerts); - if (pointRep[tailIndex] == UNUSED32) - { - pointRep[tailIndex] = tailIndex; - - const XMVECTOR outer = XMLoadFloat3(&positions[tailIndex]); - - for (uint32_t current = tail + 1; current < head; ++current) - { - uint32_t curIndex = xorder[current]; - assert(curIndex < nVerts); - _Analysis_assume_(curIndex < nVerts); - - // if the point is already assigned, ignore it - if (pointRep[curIndex] == UNUSED32) - { - const XMVECTOR inner = XMLoadFloat3(&positions[curIndex]); - - const XMVECTOR diff = XMVector3LengthSq(XMVectorSubtract(inner, outer)); - - if (XMVector2Less(diff, vepsilon)) - { - uint32_t headvc = vertexToCorner[tailIndex]; - - bool ispresent = false; - - while (headvc != UNUSED32) - { - const uint32_t face = headvc / 3; - assert(face < nFaces); - _Analysis_assume_(face < nFaces); - - assert((indices[face * 3] == tailIndex) || (indices[face * 3 + 1] == tailIndex) || (indices[face * 3 + 2] == tailIndex)); - - if ((indices[face * 3] == curIndex) || (indices[face * 3 + 1] == curIndex) || (indices[face * 3 + 2] == curIndex)) - { - ispresent = true; - break; - } - - headvc = vertexCornerList[headvc]; - } - - if (!ispresent) - { - pointRep[curIndex] = tailIndex; - } - } - } - } - } - - ++tail; - } - - return S_OK; - } - } - - - //--------------------------------------------------------------------------------- - // Convert PointRep to Adjacency - //--------------------------------------------------------------------------------- - template - HRESULT ConvertPointRepsToAdjacencyImpl( - _In_reads_(nFaces * 3) const index_t* indices, size_t nFaces, - _In_reads_(nVerts) const XMFLOAT3* positions, size_t nVerts, - _In_reads_(nVerts) const uint32_t* pointRep, - _Out_writes_(nFaces * 3) uint32_t* adjacency) noexcept - { - auto hashSize = std::max(nVerts / 3, 1); - - std::unique_ptr hashTable(new (std::nothrow) edgeHashEntry*[hashSize]); - if (!hashTable) - return E_OUTOFMEMORY; - - memset(hashTable.get(), 0, sizeof(edgeHashEntry*) * hashSize); - - std::unique_ptr hashEntries(new (std::nothrow) edgeHashEntry[3 * nFaces]); - if (!hashEntries) - return E_OUTOFMEMORY; - - uint32_t freeEntry = 0; - - // add face edges to hash table and validate indices - for (size_t face = 0; face < nFaces; ++face) - { - index_t i0 = indices[face * 3]; - index_t i1 = indices[face * 3 + 1]; - index_t i2 = indices[face * 3 + 2]; - - if (i0 == index_t(-1) - || i1 == index_t(-1) - || i2 == index_t(-1)) - continue; - - if (i0 >= nVerts - || i1 >= nVerts - || i2 >= nVerts) - return E_UNEXPECTED; - - const uint32_t v1 = pointRep[i0]; - const uint32_t v2 = pointRep[i1]; - const uint32_t v3 = pointRep[i2]; - - // filter out degenerate triangles - if (v1 == v2 || v1 == v3 || v2 == v3) - continue; - - for (uint32_t point = 0; point < 3; ++point) - { - const uint32_t va = pointRep[indices[face * 3 + point]]; - const uint32_t vb = pointRep[indices[face * 3 + ((point + 1) % 3)]]; - const uint32_t vOther = pointRep[indices[face * 3 + ((point + 2) % 3)]]; - - const uint32_t hashKey = va % hashSize; - - assert(freeEntry < (3 * nFaces)); - _Analysis_assume_(freeEntry < (3 * nFaces)); - - auto newEntry = &hashEntries[freeEntry]; - ++freeEntry; - - newEntry->v1 = va; - newEntry->v2 = vb; - newEntry->vOther = vOther; - newEntry->face = uint32_t(face); - newEntry->next = hashTable[hashKey]; - hashTable[hashKey] = newEntry; - } - } - - assert(freeEntry <= (3 * nFaces)); - - memset(adjacency, 0xff, sizeof(uint32_t) * nFaces * 3); - - for (size_t face = 0; face < nFaces; ++face) - { - index_t i0 = indices[face * 3]; - index_t i1 = indices[face * 3 + 1]; - index_t i2 = indices[face * 3 + 2]; - - // filter out unused triangles - if (i0 == index_t(-1) - || i1 == index_t(-1) - || i2 == index_t(-1)) - continue; - - assert(i0 < nVerts); - assert(i1 < nVerts); - assert(i2 < nVerts); - - _Analysis_assume_(i0 < nVerts); - _Analysis_assume_(i1 < nVerts); - _Analysis_assume_(i2 < nVerts); - - const uint32_t v1 = pointRep[i0]; - const uint32_t v2 = pointRep[i1]; - const uint32_t v3 = pointRep[i2]; - - // filter out degenerate triangles - if (v1 == v2 || v1 == v3 || v2 == v3) - continue; - - for (uint32_t point = 0; point < 3; ++point) - { - if (adjacency[face * 3 + point] != UNUSED32) - continue; - - // see if edge already entered, if not then enter it - const uint32_t va = pointRep[indices[face * 3 + ((point + 1) % 3)]]; - const uint32_t vb = pointRep[indices[face * 3 + point]]; - const uint32_t vOther = pointRep[indices[face * 3 + ((point + 2) % 3)]]; - - const uint32_t hashKey = va % hashSize; - - edgeHashEntry* current = hashTable[hashKey]; - edgeHashEntry* prev = nullptr; - - uint32_t foundFace = UNUSED32; - - while (current != nullptr) - { - if ((current->v2 == vb) && (current->v1 == va)) - { - foundFace = current->face; - break; - } - - prev = current; - current = current->next; - } - - edgeHashEntry* found = current; - edgeHashEntry* foundPrev = prev; - - float bestDiff = -2.f; - - // Scan for additional matches - if (current) - { - prev = current; - current = current->next; - - // find 'better' match - while (current != nullptr) - { - if ((current->v2 == vb) && (current->v1 == va)) - { - const XMVECTOR pB1 = XMLoadFloat3(&positions[vb]); - const XMVECTOR pB2 = XMLoadFloat3(&positions[va]); - const XMVECTOR pB3 = XMLoadFloat3(&positions[vOther]); - - XMVECTOR v12 = XMVectorSubtract(pB1, pB2); - XMVECTOR v13 = XMVectorSubtract(pB1, pB3); - - const XMVECTOR bnormal = XMVector3Normalize(XMVector3Cross(v12, v13)); - - if (bestDiff == -2.f) - { - const XMVECTOR pA1 = XMLoadFloat3(&positions[found->v1]); - const XMVECTOR pA2 = XMLoadFloat3(&positions[found->v2]); - const XMVECTOR pA3 = XMLoadFloat3(&positions[found->vOther]); - - v12 = XMVectorSubtract(pA1, pA2); - v13 = XMVectorSubtract(pA1, pA3); - - const XMVECTOR anormal = XMVector3Normalize(XMVector3Cross(v12, v13)); - - bestDiff = XMVectorGetX(XMVector3Dot(anormal, bnormal)); - } - - const XMVECTOR pA1 = XMLoadFloat3(&positions[current->v1]); - const XMVECTOR pA2 = XMLoadFloat3(&positions[current->v2]); - const XMVECTOR pA3 = XMLoadFloat3(&positions[current->vOther]); - - v12 = XMVectorSubtract(pA1, pA2); - v13 = XMVectorSubtract(pA1, pA3); - - const XMVECTOR anormal = XMVector3Normalize(XMVector3Cross(v12, v13)); - - const float diff = XMVectorGetX(XMVector3Dot(anormal, bnormal)); - - // if face normals are closer, use new match - if (diff > bestDiff) - { - found = current; - foundPrev = prev; - foundFace = current->face; - bestDiff = diff; - } - } - - prev = current; - current = current->next; - } - } - - if (foundFace != UNUSED32) - { - assert(found != nullptr); - - // remove found face from hash table - if (foundPrev != nullptr) - { - foundPrev->next = found->next; - } - else - { - hashTable[hashKey] = found->next; - } - - assert(adjacency[face * 3 + point] == UNUSED32); - adjacency[face * 3 + point] = foundFace; - - // Check for other edge - const uint32_t hashKey2 = vb % hashSize; - - current = hashTable[hashKey2]; - prev = nullptr; - - while (current != nullptr) - { - if ((current->face == uint32_t(face)) && (current->v2 == va) && (current->v1 == vb)) - { - // trim edge from hash table - if (prev != nullptr) - { - prev->next = current->next; - } - else - { - hashTable[hashKey2] = current->next; - } - break; - } - - prev = current; - current = current->next; - } - - // mark neighbor to point back - bool linked = false; - - for (uint32_t point2 = 0; point2 < point; ++point2) - { - if (foundFace == adjacency[face * 3 + point2]) - { - linked = true; - adjacency[face * 3 + point] = UNUSED32; - break; - } - } - - if (!linked) - { - uint32_t point2 = 0; - for (; point2 < 3; ++point2) - { - index_t k = indices[foundFace * 3 + point2]; - if (k == index_t(-1)) - continue; - - assert(k < nVerts); - _Analysis_assume_(k < nVerts); - - if (pointRep[k] == va) - break; - } - - if (point2 < 3) - { - #ifndef NDEBUG - uint32_t testPoint = indices[foundFace * 3 + ((point2 + 1) % 3)]; - testPoint = pointRep[testPoint]; - assert(testPoint == vb); - #endif - assert(adjacency[foundFace * 3 + point2] == UNUSED32); - - // update neighbor to point back to this face match edge - adjacency[foundFace * 3 + point2] = uint32_t(face); - } - } - } - } - } - - return S_OK; - } -} - -//===================================================================================== -// Entry-points -//===================================================================================== - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::GenerateAdjacencyAndPointReps( - const uint16_t* indices, - size_t nFaces, - const XMFLOAT3* positions, - size_t nVerts, - float epsilon, - uint32_t* pointRep, - uint32_t* adjacency) -{ - if (!indices || !nFaces || !positions || !nVerts) - return E_INVALIDARG; - - if (!pointRep && !adjacency) - return E_INVALIDARG; - - if (nVerts >= UINT16_MAX) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - std::unique_ptr temp; - if (!pointRep) - { - temp.reset(new (std::nothrow) uint32_t[nVerts]); - if (!temp) - return E_OUTOFMEMORY; - - pointRep = temp.get(); - } - - HRESULT hr = GeneratePointReps(indices, nFaces, positions, nVerts, epsilon, pointRep); - if (FAILED(hr)) - return hr; - - if (!adjacency) - return S_OK; - - return ConvertPointRepsToAdjacencyImpl(indices, nFaces, positions, nVerts, pointRep, adjacency); -} - -_Use_decl_annotations_ -HRESULT DirectX::GenerateAdjacencyAndPointReps( - const uint32_t* indices, - size_t nFaces, - const XMFLOAT3* positions, - size_t nVerts, - float epsilon, - uint32_t* pointRep, - uint32_t* adjacency) -{ - if (!indices || !nFaces || !positions || !nVerts) - return E_INVALIDARG; - - if (!pointRep && !adjacency) - return E_INVALIDARG; - - if (nVerts >= UINT32_MAX) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - std::unique_ptr temp; - if (!pointRep) - { - temp.reset(new (std::nothrow) uint32_t[nVerts]); - if (!temp) - return E_OUTOFMEMORY; - - pointRep = temp.get(); - } - - HRESULT hr = GeneratePointReps(indices, nFaces, positions, nVerts, epsilon, pointRep); - if (FAILED(hr)) - return hr; - - if (!adjacency) - return S_OK; - - return ConvertPointRepsToAdjacencyImpl(indices, nFaces, positions, nVerts, pointRep, adjacency); -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::ConvertPointRepsToAdjacency( - const uint16_t* indices, - size_t nFaces, - const XMFLOAT3* positions, - size_t nVerts, - const uint32_t* pointRep, - uint32_t* adjacency) -{ - if (!indices || !nFaces || !positions || !nVerts || !adjacency) - return E_INVALIDARG; - - if (nVerts >= UINT16_MAX) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - std::unique_ptr temp; - if (!pointRep) - { - temp.reset(new (std::nothrow) uint32_t[nVerts]); - if (!temp) - return E_OUTOFMEMORY; - - for (size_t j = 0; j < nVerts; ++j) - { - temp[j] = uint32_t(j); - } - - pointRep = temp.get(); - } - - return ConvertPointRepsToAdjacencyImpl(indices, nFaces, positions, nVerts, pointRep, adjacency); -} - -_Use_decl_annotations_ -HRESULT DirectX::ConvertPointRepsToAdjacency( - const uint32_t* indices, - size_t nFaces, - const XMFLOAT3* positions, - size_t nVerts, - const uint32_t* pointRep, - uint32_t* adjacency) -{ - if (!indices || !nFaces || !positions || !nVerts || !adjacency) - return E_INVALIDARG; - - if (nVerts >= UINT32_MAX) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - std::unique_ptr temp; - if (!pointRep) - { - temp.reset(new (std::nothrow) uint32_t[nVerts]); - if (!temp) - return E_OUTOFMEMORY; - - for (size_t j = 0; j < nVerts; ++j) - { - temp[j] = uint32_t(j); - } - - pointRep = temp.get(); - } - - return ConvertPointRepsToAdjacencyImpl(indices, nFaces, positions, nVerts, pointRep, adjacency); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshClean.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshClean.cpp deleted file mode 100644 index 80e16ea..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshClean.cpp +++ /dev/null @@ -1,443 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXMeshClean.cpp -// -// DirectX Mesh Geometry Library - Mesh clean-up -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkID=324981 -//------------------------------------------------------------------------------------- - -#include "DirectXMeshP.h" - -using namespace DirectX; - -namespace -{ - template - HRESULT CleanImpl( - _Inout_updates_all_(nFaces * 3) index_t* indices, - size_t nFaces, size_t nVerts, - _Inout_updates_all_opt_(nFaces * 3) uint32_t* adjacency, - _In_reads_opt_(nFaces) const uint32_t* attributes, - _Inout_ std::vector& dupVerts, bool breakBowties) - { - if (!adjacency && !attributes) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - dupVerts.clear(); - size_t curNewVert = nVerts; - - const size_t tsize = (sizeof(bool) * nFaces * 3) + (sizeof(uint32_t) * nVerts) + (sizeof(index_t) * nFaces * 3); - std::unique_ptr temp(new (std::nothrow) uint8_t[tsize]); - if (!temp) - return E_OUTOFMEMORY; - - auto faceSeen = reinterpret_cast(temp.get()); - auto ids = reinterpret_cast(temp.get() + sizeof(bool) * nFaces * 3); - - // UNUSED/DEGENERATE cleanup - for (uint32_t face = 0; face < nFaces; ++face) - { - index_t i0 = indices[face * 3]; - index_t i1 = indices[face * 3 + 1]; - index_t i2 = indices[face * 3 + 2]; - - if (i0 == index_t(-1) - || i1 == index_t(-1) - || i2 == index_t(-1)) - { - // ensure all index entries in the unused face are 'unused' - indices[face * 3] = - indices[face * 3 + 1] = - indices[face * 3 + 2] = index_t(-1); - - // ensure no neighbor references the unused face - if (adjacency) - { - for (uint32_t point = 0; point < 3; ++point) - { - uint32_t k = adjacency[face * 3 + point]; - if (k != UNUSED32) - { - assert(k < nFaces); - _Analysis_assume_(k < nFaces); - - if (adjacency[k * 3] == face) - adjacency[k * 3] = UNUSED32; - - if (adjacency[k * 3 + 1] == face) - adjacency[k * 3 + 1] = UNUSED32; - - if (adjacency[k * 3 + 2] == face) - adjacency[k * 3 + 2] = UNUSED32; - - adjacency[face * 3 + point] = UNUSED32; - } - } - } - } - else if (i0 == i1 - || i0 == i2 - || i1 == i2) - { - // Clean doesn't trim out degenerates as most other functions ignore them - - // ensure no neighbor references the degenerate face - if (adjacency) - { - for (uint32_t point = 0; point < 3; ++point) - { - uint32_t k = adjacency[face * 3 + point]; - if (k != UNUSED32) - { - assert(k < nFaces); - _Analysis_assume_(k < nFaces); - - if (adjacency[k * 3] == face) - adjacency[k * 3] = UNUSED32; - - if (adjacency[k * 3 + 1] == face) - adjacency[k * 3 + 1] = UNUSED32; - - if (adjacency[k * 3 + 2] == face) - adjacency[k * 3 + 2] = UNUSED32; - - adjacency[face * 3 + point] = UNUSED32; - } - } - } - } - } - - // ASYMMETRIC ADJ cleanup - if (adjacency) - { - for (;;) - { - bool unlinked = false; - - for (uint32_t face = 0; face < nFaces; ++face) - { - for (uint32_t point = 0; point < 3; ++point) - { - const uint32_t k = adjacency[face * 3 + point]; - if (k != UNUSED32) - { - assert(k < nFaces); - _Analysis_assume_(k < nFaces); - - const uint32_t edge = find_edge(&adjacency[k * 3], face); - if (edge >= 3) - { - unlinked = true; - adjacency[face * 3 + point] = UNUSED32; - } - } - } - } - - if (!unlinked) - break; - } - } - - // BACKFACING cleanup - if (adjacency) - { - for (size_t face = 0; face < nFaces; ++face) - { - index_t i0 = indices[face * 3]; - index_t i1 = indices[face * 3 + 1]; - index_t i2 = indices[face * 3 + 2]; - - if (i0 == index_t(-1) - || i1 == index_t(-1) - || i2 == index_t(-1)) - { - // ignore unused faces - continue; - } - - assert(i0 < nVerts); - assert(i1 < nVerts); - assert(i2 < nVerts); - - if (i0 == i1 - || i0 == i2 - || i1 == i2) - { - // ignore degenerate faces - continue; - } - - const uint32_t j0 = adjacency[face * 3]; - const uint32_t j1 = adjacency[face * 3 + 1]; - const uint32_t j2 = adjacency[face * 3 + 2]; - - if ((j0 == j1 && j0 != UNUSED32) - || (j0 == j2 && j0 != UNUSED32) - || (j1 == j2 && j1 != UNUSED32)) - { - uint32_t neighbor = (j0 == j1 || j0 == j2) ? j0 : j1; - - // remove links then break bowties will clean up any remaining issues - for (uint32_t edge = 0; edge < 3; ++edge) - { - if (adjacency[face * 3 + edge] == neighbor) - { - adjacency[face * 3 + edge] = UNUSED32; - } - - if (adjacency[neighbor * 3 + edge] == face) - { - adjacency[neighbor * 3 + edge] = UNUSED32; - } - } - } - } - } - - auto indicesNew = reinterpret_cast(reinterpret_cast(ids) + sizeof(uint32_t) * nVerts); - memcpy(indicesNew, indices, sizeof(index_t) * nFaces * 3); - - // BOWTIES cleanup - if (adjacency && breakBowties) - { - memset(faceSeen, 0, sizeof(bool) * nFaces * 3); - memset(ids, 0xFF, sizeof(uint32_t) * nVerts); - - orbit_iterator ovi(adjacency, indices, nFaces); - - for (uint32_t face = 0; face < nFaces; ++face) - { - index_t i0 = indices[face * 3]; - index_t i1 = indices[face * 3 + 1]; - index_t i2 = indices[face * 3 + 2]; - - if (i0 == index_t(-1) - || i1 == index_t(-1) - || i2 == index_t(-1)) - { - // ignore unused faces - faceSeen[face * 3] = true; - faceSeen[face * 3 + 1] = true; - faceSeen[face * 3 + 2] = true; - continue; - } - - assert(i0 < nVerts); - assert(i1 < nVerts); - assert(i2 < nVerts); - - if (i0 == i1 - || i0 == i2 - || i1 == i2) - { - // ignore degenerate faces - faceSeen[face * 3] = true; - faceSeen[face * 3 + 1] = true; - faceSeen[face * 3 + 2] = true; - continue; - } - - for (uint32_t point = 0; point < 3; ++point) - { - if (faceSeen[face * 3 + point]) - continue; - - faceSeen[face * 3 + point] = true; - - index_t i = indices[face * 3 + point]; - if (i == index_t(-1)) - continue; - - assert(i < nVerts); - - ovi.initialize(face, i, orbit_iterator::ALL); - ovi.moveToCCW(); - - index_t replaceVertex = index_t(-1); - index_t replaceValue = index_t(-1); - - while (!ovi.done()) - { - uint32_t curFace = ovi.nextFace(); - if (curFace >= nFaces) - return E_FAIL; - - uint32_t curPoint = ovi.getpoint(); - if (curPoint > 2) - return E_FAIL; - - faceSeen[curFace * 3 + curPoint] = true; - - index_t j = indices[curFace * 3 + curPoint]; - if (j == index_t(-1)) - continue; - - assert(j < nVerts); - - if (j == replaceVertex) - { - indicesNew[curFace * 3 + curPoint] = replaceValue; - } - else if (ids[j] == UNUSED32) - { - ids[j] = face; - } - else if (ids[j] != face) - { - // We found a bowtie, duplicate a vert - replaceVertex = j; - replaceValue = index_t(curNewVert); - indicesNew[curFace * 3 + curPoint] = replaceValue; - ++curNewVert; - - dupVerts.push_back(j); - } - } - } - } - - assert((nVerts + dupVerts.size()) == curNewVert); - } - - // Ensure no vertex is used by more than one attribute - if (attributes) - { - memset(ids, 0xFF, sizeof(uint32_t) * nVerts); - - std::vector dupAttr; - dupAttr.reserve(dupVerts.size()); - for (size_t j = 0; j < dupVerts.size(); ++j) - { - dupAttr.push_back(UNUSED32); - } - - std::unordered_multimap dups; - - for (size_t face = 0; face < nFaces; ++face) - { - uint32_t a = attributes[face]; - - for (size_t point = 0; point < 3; ++point) - { - uint32_t j = indicesNew[face * 3 + point]; - - const uint32_t k = (j >= nVerts) ? dupAttr[j - nVerts] : ids[j]; - - if (k == UNUSED32) - { - if (j >= nVerts) - dupAttr[j - nVerts] = a; - else - ids[j] = a; - } - else if (k != a) - { - // Look for a dup with the correct attribute - auto range = dups.equal_range(j); - auto it = range.first; - for (; it != range.second; ++it) - { - const uint32_t m = (it->second >= nVerts) ? dupAttr[it->second - nVerts] : ids[it->second]; - if (m == a) - { - indicesNew[face * 3 + point] = index_t(it->second); - break; - } - } - - if (it == range.second) - { - // Duplicate the vert - auto dv = std::pair(j, curNewVert); - dups.insert(dv); - - indicesNew[face * 3 + point] = index_t(curNewVert); - ++curNewVert; - - if (j >= nVerts) - { - dupVerts.push_back(dupVerts[j - nVerts]); - } - else - { - dupVerts.push_back(j); - } - - dupAttr.push_back(a); - - assert(dupVerts.size() == dupAttr.size()); - } - } - } - } - - assert((nVerts + dupVerts.size()) == curNewVert); - - #ifndef NDEBUG - for (const auto it : dupVerts) - { - assert(it < nVerts); - } - #endif - } - - if ((uint64_t(nVerts) + uint64_t(dupVerts.size())) >= index_t(-1)) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - if (!dupVerts.empty()) - { - memcpy(indices, indicesNew, sizeof(index_t) * nFaces * 3); - } - - return S_OK; - } -} - -//===================================================================================== -// Entry-points -//===================================================================================== - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::Clean( - uint16_t* indices, - size_t nFaces, - size_t nVerts, - uint32_t* adjacency, - const uint32_t* attributes, - std::vector& dupVerts, - bool breakBowties) -{ - HRESULT hr = Validate(indices, nFaces, nVerts, adjacency, VALIDATE_DEFAULT); - if (FAILED(hr)) - return hr; - - return CleanImpl(indices, nFaces, nVerts, adjacency, attributes, dupVerts, breakBowties); -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::Clean( - uint32_t* indices, - size_t nFaces, - size_t nVerts, - uint32_t* adjacency, - const uint32_t* attributes, - std::vector& dupVerts, - bool breakBowties) -{ - HRESULT hr = Validate(indices, nFaces, nVerts, adjacency, VALIDATE_DEFAULT); - if (FAILED(hr)) - return hr; - - return CleanImpl(indices, nFaces, nVerts, adjacency, attributes, dupVerts, breakBowties); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshConcat.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshConcat.cpp deleted file mode 100644 index 55cc4a2..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshConcat.cpp +++ /dev/null @@ -1,60 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXMeshConcat.cpp -// -// DirectX Mesh Geometry Library - Concatenate mesh -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkID=324981 -//------------------------------------------------------------------------------------- - -#include "DirectXMeshP.h" - -using namespace DirectX; - -//===================================================================================== -// Entry-points -//===================================================================================== - -_Use_decl_annotations_ -HRESULT __cdecl DirectX::ConcatenateMesh( - size_t nFaces, - size_t nVerts, - uint32_t* faceDestMap, - uint32_t* vertexDestMap, - size_t& totalFaces, - size_t& totalVerts) noexcept -{ - if (!nFaces || !nVerts || !faceDestMap || !vertexDestMap) - return E_INVALIDARG; - - if (nVerts >= UINT32_MAX) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - uint64_t newFaceCount = uint64_t(totalFaces) + nFaces; - uint64_t newVertCount = uint64_t(totalVerts) + nVerts; - - if (newFaceCount >= UINT32_MAX || newVertCount >= UINT32_MAX) - return E_FAIL; - - auto const baseFace = static_cast(totalFaces); - for (uint32_t j = 0; j < nFaces; ++j) - { - faceDestMap[j] = baseFace + j; - } - - auto const baseVert = static_cast(totalVerts); - for (uint32_t j = 0; j < nVerts; ++j) - { - vertexDestMap[j] = baseVert + j; - } - - totalFaces = static_cast(newFaceCount); - totalVerts = static_cast(newVertCount); - - return S_OK; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshGSAdjacency.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshGSAdjacency.cpp deleted file mode 100644 index 84bf504..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshGSAdjacency.cpp +++ /dev/null @@ -1,159 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXMeshGSAdjacency.cpp -// -// DirectX Mesh Geometry Library - Geometry Shader adjacency computation -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkID=324981 -//------------------------------------------------------------------------------------- - -#include "DirectXMeshP.h" - -using namespace DirectX; - -// -// Generates an IB triangle list with adjacency (D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST_ADJ) -// http://msdn.microsoft.com/en-us/library/windows/desktop/bb205124.aspx -// - -namespace -{ - template - HRESULT GenerateGSAdjacencyImpl( - _In_reads_(nFaces * 3) const index_t* indices, _In_ size_t nFaces, - _In_reads_(nVerts) const uint32_t* pointRep, - _In_reads_(nFaces * 3) const uint32_t* adjacency, _In_ size_t nVerts, - _Out_writes_(nFaces * 6) index_t* indicesAdj) noexcept - { - if (!indices || !nFaces || !pointRep || !adjacency || !nVerts || !indicesAdj) - return E_INVALIDARG; - - if (nVerts >= index_t(-1)) - return E_INVALIDARG; - - if (indices == indicesAdj) - { - // Does not support in-place conversion of the index buffer - return HRESULT_E_NOT_SUPPORTED; - } - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - size_t inputi = 0; - size_t outputi = 0; - - for (size_t face = 0; face < nFaces; ++face) - { - for (uint32_t point = 0; point < 3; ++point) - { - assert(outputi < (nFaces * 6)); - _Analysis_assume_(outputi < (nFaces * 6)); - - indicesAdj[outputi] = indices[inputi]; - ++outputi; - ++inputi; - - assert(outputi < (nFaces * 6)); - _Analysis_assume_(outputi < (nFaces * 6)); - - const uint32_t a = adjacency[face * 3 + point]; - if (a == UNUSED32) - { - indicesAdj[outputi] = indices[face * 3 + ((point + 2) % 3)]; - } - else - { - uint32_t v1 = indices[face * 3 + point]; - uint32_t v2 = indices[face * 3 + ((point + 1) % 3)]; - - if (v1 == index_t(-1) || v2 == index_t(-1)) - { - indicesAdj[outputi] = index_t(-1); - } - else - { - if (v1 >= nVerts - || v2 >= nVerts) - return E_UNEXPECTED; - - v1 = pointRep[v1]; - v2 = pointRep[v2]; - - uint32_t vOther = UNUSED32; - - // find other vertex - for (uint32_t k = 0; k < 3; ++k) - { - assert(a < nFaces); - _Analysis_assume_(a < nFaces); - const uint32_t ak = indices[a * 3 + k]; - if (ak == index_t(-1)) - break; - - if (ak >= nVerts) - return E_UNEXPECTED; - - if (pointRep[ak] == v1) - continue; - - if (pointRep[ak] == v2) - continue; - - vOther = ak; - } - - if (vOther == UNUSED32) - { - indicesAdj[outputi] = indices[face * 3 + ((point + 2) % 3)]; - - } - else - { - indicesAdj[outputi] = index_t(vOther); - } - } - } - ++outputi; - } - } - - assert(inputi == (nFaces * 3)); - assert(outputi == (nFaces * 6)); - - return S_OK; - } -} - -//===================================================================================== -// Entry-points -//===================================================================================== - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::GenerateGSAdjacency( - const uint16_t* indices, - size_t nFaces, - const uint32_t* pointRep, - const uint32_t* adjacency, - size_t nVerts, - uint16_t* indicesAdj) noexcept -{ - return GenerateGSAdjacencyImpl(indices, nFaces, pointRep, adjacency, nVerts, indicesAdj); -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::GenerateGSAdjacency( - const uint32_t* indices, - size_t nFaces, - const uint32_t* pointRep, - const uint32_t* adjacency, - size_t nVerts, - uint32_t* indicesAdj) noexcept -{ - return GenerateGSAdjacencyImpl(indices, nFaces, pointRep, adjacency, nVerts, indicesAdj); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshNormals.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshNormals.cpp deleted file mode 100644 index 31c8a9a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshNormals.cpp +++ /dev/null @@ -1,333 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXMeshNormals.cpp -// -// DirectX Mesh Geometry Library - Normal computation -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkID=324981 -//------------------------------------------------------------------------------------- - -#include "DirectXMeshP.h" - -using namespace DirectX; - -namespace -{ - //--------------------------------------------------------------------------------- - // Compute normals with equal weighting - //--------------------------------------------------------------------------------- - template - HRESULT ComputeNormalsEqualWeight( - _In_reads_(nFaces * 3) const index_t* indices, size_t nFaces, - _In_reads_(nVerts) const XMFLOAT3* positions, size_t nVerts, - bool cw, _Out_writes_(nVerts) XMFLOAT3* normals) noexcept - { - auto temp = make_AlignedArrayXMVECTOR(nVerts); - if (!temp) - return E_OUTOFMEMORY; - - XMVECTOR* vertNormals = temp.get(); - memset(vertNormals, 0, sizeof(XMVECTOR) * nVerts); - - for (size_t face = 0; face < nFaces; ++face) - { - index_t i0 = indices[face * 3]; - index_t i1 = indices[face * 3 + 1]; - index_t i2 = indices[face * 3 + 2]; - - if (i0 == index_t(-1) - || i1 == index_t(-1) - || i2 == index_t(-1)) - continue; - - if (i0 >= nVerts - || i1 >= nVerts - || i2 >= nVerts) - return E_UNEXPECTED; - - const XMVECTOR p1 = XMLoadFloat3(&positions[i0]); - const XMVECTOR p2 = XMLoadFloat3(&positions[i1]); - const XMVECTOR p3 = XMLoadFloat3(&positions[i2]); - - const XMVECTOR u = XMVectorSubtract(p2, p1); - const XMVECTOR v = XMVectorSubtract(p3, p1); - - const XMVECTOR faceNormal = XMVector3Normalize(XMVector3Cross(u, v)); - - vertNormals[i0] = XMVectorAdd(vertNormals[i0], faceNormal); - vertNormals[i1] = XMVectorAdd(vertNormals[i1], faceNormal); - vertNormals[i2] = XMVectorAdd(vertNormals[i2], faceNormal); - } - - // Store results - if (cw) - { - for (size_t vert = 0; vert < nVerts; ++vert) - { - XMVECTOR n = XMVector3Normalize(vertNormals[vert]); - n = XMVectorNegate(n); - XMStoreFloat3(&normals[vert], n); - } - } - else - { - for (size_t vert = 0; vert < nVerts; ++vert) - { - const XMVECTOR n = XMVector3Normalize(vertNormals[vert]); - XMStoreFloat3(&normals[vert], n); - } - } - - return S_OK; - } - - - //--------------------------------------------------------------------------------- - // Compute normals with weighting by angle - //--------------------------------------------------------------------------------- - template - HRESULT ComputeNormalsWeightedByAngle( - _In_reads_(nFaces * 3) const index_t* indices, size_t nFaces, - _In_reads_(nVerts) const XMFLOAT3* positions, size_t nVerts, - bool cw, _Out_writes_(nVerts) XMFLOAT3* normals) noexcept - { - auto temp = make_AlignedArrayXMVECTOR(nVerts); - if (!temp) - return E_OUTOFMEMORY; - - XMVECTOR* vertNormals = temp.get(); - memset(vertNormals, 0, sizeof(XMVECTOR) * nVerts); - - for (size_t face = 0; face < nFaces; ++face) - { - index_t i0 = indices[face * 3]; - index_t i1 = indices[face * 3 + 1]; - index_t i2 = indices[face * 3 + 2]; - - if (i0 == index_t(-1) - || i1 == index_t(-1) - || i2 == index_t(-1)) - continue; - - if (i0 >= nVerts - || i1 >= nVerts - || i2 >= nVerts) - return E_UNEXPECTED; - - const XMVECTOR p0 = XMLoadFloat3(&positions[i0]); - const XMVECTOR p1 = XMLoadFloat3(&positions[i1]); - const XMVECTOR p2 = XMLoadFloat3(&positions[i2]); - - const XMVECTOR u = XMVectorSubtract(p1, p0); - const XMVECTOR v = XMVectorSubtract(p2, p0); - - const XMVECTOR faceNormal = XMVector3Normalize(XMVector3Cross(u, v)); - - // Corner 0 -> 1 - 0, 2 - 0 - const XMVECTOR a = XMVector3Normalize(u); - const XMVECTOR b = XMVector3Normalize(v); - XMVECTOR w0 = XMVector3Dot(a, b); - w0 = XMVectorClamp(w0, g_XMNegativeOne, g_XMOne); - w0 = XMVectorACos(w0); - - // Corner 1 -> 2 - 1, 0 - 1 - const XMVECTOR c = XMVector3Normalize(XMVectorSubtract(p2, p1)); - const XMVECTOR d = XMVector3Normalize(XMVectorSubtract(p0, p1)); - XMVECTOR w1 = XMVector3Dot(c, d); - w1 = XMVectorClamp(w1, g_XMNegativeOne, g_XMOne); - w1 = XMVectorACos(w1); - - // Corner 2 -> 0 - 2, 1 - 2 - const XMVECTOR e = XMVector3Normalize(XMVectorSubtract(p0, p2)); - const XMVECTOR f = XMVector3Normalize(XMVectorSubtract(p1, p2)); - XMVECTOR w2 = XMVector3Dot(e, f); - w2 = XMVectorClamp(w2, g_XMNegativeOne, g_XMOne); - w2 = XMVectorACos(w2); - - vertNormals[i0] = XMVectorMultiplyAdd(faceNormal, w0, vertNormals[i0]); - vertNormals[i1] = XMVectorMultiplyAdd(faceNormal, w1, vertNormals[i1]); - vertNormals[i2] = XMVectorMultiplyAdd(faceNormal, w2, vertNormals[i2]); - } - - // Store results - if (cw) - { - for (size_t vert = 0; vert < nVerts; ++vert) - { - XMVECTOR n = XMVector3Normalize(vertNormals[vert]); - n = XMVectorNegate(n); - XMStoreFloat3(&normals[vert], n); - } - } - else - { - for (size_t vert = 0; vert < nVerts; ++vert) - { - const XMVECTOR n = XMVector3Normalize(vertNormals[vert]); - XMStoreFloat3(&normals[vert], n); - } - } - - return S_OK; - } - - - //--------------------------------------------------------------------------------- - // Compute normals with weighting by face area - //--------------------------------------------------------------------------------- - template - HRESULT ComputeNormalsWeightedByArea( - _In_reads_(nFaces * 3) const index_t* indices, size_t nFaces, - _In_reads_(nVerts) const XMFLOAT3* positions, size_t nVerts, - bool cw, _Out_writes_(nVerts) XMFLOAT3* normals) noexcept - { - auto temp = make_AlignedArrayXMVECTOR(nVerts); - if (!temp) - return E_OUTOFMEMORY; - - XMVECTOR* vertNormals = temp.get(); - memset(vertNormals, 0, sizeof(XMVECTOR) * nVerts); - - for (size_t face = 0; face < nFaces; ++face) - { - index_t i0 = indices[face * 3]; - index_t i1 = indices[face * 3 + 1]; - index_t i2 = indices[face * 3 + 2]; - - if (i0 == index_t(-1) - || i1 == index_t(-1) - || i2 == index_t(-1)) - continue; - - if (i0 >= nVerts - || i1 >= nVerts - || i2 >= nVerts) - return E_UNEXPECTED; - - const XMVECTOR p0 = XMLoadFloat3(&positions[i0]); - const XMVECTOR p1 = XMLoadFloat3(&positions[i1]); - const XMVECTOR p2 = XMLoadFloat3(&positions[i2]); - - const XMVECTOR u = XMVectorSubtract(p1, p0); - const XMVECTOR v = XMVectorSubtract(p2, p0); - - const XMVECTOR faceNormal = XMVector3Normalize(XMVector3Cross(u, v)); - - // Corner 0 -> 1 - 0, 2 - 0 - XMVECTOR w0 = XMVector3Cross(u, v); - w0 = XMVector3Length(w0); - - // Corner 1 -> 2 - 1, 0 - 1 - const XMVECTOR c = XMVectorSubtract(p2, p1); - const XMVECTOR d = XMVectorSubtract(p0, p1); - XMVECTOR w1 = XMVector3Cross(c, d); - w1 = XMVector3Length(w1); - - // Corner 2 -> 0 - 2, 1 - 2 - const XMVECTOR e = XMVectorSubtract(p0, p2); - const XMVECTOR f = XMVectorSubtract(p1, p2); - XMVECTOR w2 = XMVector3Cross(e, f); - w2 = XMVector3Length(w2); - - vertNormals[i0] = XMVectorMultiplyAdd(faceNormal, w0, vertNormals[i0]); - vertNormals[i1] = XMVectorMultiplyAdd(faceNormal, w1, vertNormals[i1]); - vertNormals[i2] = XMVectorMultiplyAdd(faceNormal, w2, vertNormals[i2]); - } - - // Store results - if (cw) - { - for (size_t vert = 0; vert < nVerts; ++vert) - { - XMVECTOR n = XMVector3Normalize(vertNormals[vert]); - n = XMVectorNegate(n); - XMStoreFloat3(&normals[vert], n); - } - } - else - { - for (size_t vert = 0; vert < nVerts; ++vert) - { - const XMVECTOR n = XMVector3Normalize(vertNormals[vert]); - XMStoreFloat3(&normals[vert], n); - } - } - - return S_OK; - } -} - -//===================================================================================== -// Entry-points -//===================================================================================== - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::ComputeNormals( - const uint16_t* indices, - size_t nFaces, - const XMFLOAT3* positions, - size_t nVerts, - CNORM_FLAGS flags, - XMFLOAT3* normals) noexcept -{ - if (!indices || !positions || !nFaces || !nVerts || !normals) - return E_INVALIDARG; - - if (nVerts >= UINT16_MAX) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - const bool cw = (flags & CNORM_WIND_CW) ? true : false; - - if (flags & CNORM_WEIGHT_BY_AREA) - { - return ComputeNormalsWeightedByArea(indices, nFaces, positions, nVerts, cw, normals); - } - else if (flags & CNORM_WEIGHT_EQUAL) - { - return ComputeNormalsEqualWeight(indices, nFaces, positions, nVerts, cw, normals); - } - else - { - return ComputeNormalsWeightedByAngle(indices, nFaces, positions, nVerts, cw, normals); - } -} - -_Use_decl_annotations_ -HRESULT DirectX::ComputeNormals( - const uint32_t* indices, - size_t nFaces, - const XMFLOAT3* positions, - size_t nVerts, - CNORM_FLAGS flags, - XMFLOAT3* normals) noexcept -{ - if (!indices || !positions || !nFaces || !nVerts || !normals) - return E_INVALIDARG; - - if (nVerts >= UINT32_MAX) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - const bool cw = (flags & CNORM_WIND_CW) ? true : false; - - if (flags & CNORM_WEIGHT_BY_AREA) - { - return ComputeNormalsWeightedByArea(indices, nFaces, positions, nVerts, cw, normals); - } - else if (flags & CNORM_WEIGHT_EQUAL) - { - return ComputeNormalsEqualWeight(indices, nFaces, positions, nVerts, cw, normals); - } - else - { - return ComputeNormalsWeightedByAngle(indices, nFaces, positions, nVerts, cw, normals); - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshOptimize.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshOptimize.cpp deleted file mode 100644 index fddbb2c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshOptimize.cpp +++ /dev/null @@ -1,153 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXMeshOptimize.cpp -// -// DirectX Mesh Geometry Library - Mesh optimization -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkID=324981 -//------------------------------------------------------------------------------------- - -#include "DirectXMeshP.h" - -using namespace DirectX; - -namespace -{ - template - HRESULT OptimizeVerticesImpl( - _In_reads_(nFaces * 3) const index_t* indices, size_t nFaces, - size_t nVerts, _Out_writes_(nVerts) uint32_t* vertexRemap, - _Out_opt_ size_t* trailingUnused) noexcept - { - if (!indices || !nFaces || !nVerts || !vertexRemap) - return E_INVALIDARG; - - if (nVerts >= index_t(-1)) - return E_INVALIDARG; - - if (trailingUnused) - { - *trailingUnused = 0; - } - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - std::unique_ptr tempRemap(new (std::nothrow) uint32_t[nVerts]); - if (!tempRemap) - return E_OUTOFMEMORY; - - memset(tempRemap.get(), 0xff, sizeof(uint32_t) * nVerts); - - uint32_t curvertex = 0; - for (size_t j = 0; j < (nFaces * 3); ++j) - { - index_t curindex = indices[j]; - if (curindex == index_t(-1)) - continue; - - if (curindex >= nVerts) - return E_UNEXPECTED; - - if (tempRemap[curindex] == UNUSED32) - { - tempRemap[curindex] = curvertex; - ++curvertex; - } - } - - // inverse lookup - memset(vertexRemap, 0xff, sizeof(uint32_t) * nVerts); - - size_t unused = 0; - - for (uint32_t j = 0; j < nVerts; ++j) - { - uint32_t vertindex = tempRemap[j]; - if (vertindex == UNUSED32) - { - ++unused; - } - else - { - if (vertindex >= nVerts) - return E_UNEXPECTED; - - vertexRemap[vertindex] = j; - } - } - - if (trailingUnused) - { - *trailingUnused = unused; - } - - return S_OK; - } -} - -//===================================================================================== -// Entry-points -//===================================================================================== - -_Use_decl_annotations_ -HRESULT DirectX::AttributeSort( - size_t nFaces, - uint32_t* attributes, - uint32_t* faceRemap) -{ - if (!nFaces || !attributes || !faceRemap) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - using intpair_t = std::pair; - - std::vector list; - list.reserve(nFaces); - for (uint32_t j = 0; j < nFaces; ++j) - { - list.emplace_back(intpair_t(attributes[j], j)); - } - - std::stable_sort(list.begin(), list.end(), [](const intpair_t& a, const intpair_t& b) noexcept -> bool - { - return (a.first < b.first); - }); - - auto it = list.begin(); - for (uint32_t j = 0; j < nFaces; ++j, ++it) - { - attributes[j] = it->first; - faceRemap[j] = it->second; - } - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::OptimizeVertices( - const uint16_t* indices, - size_t nFaces, - size_t nVerts, - uint32_t* vertexRemap, - size_t* trailingUnused) noexcept -{ - return OptimizeVerticesImpl(indices, nFaces, nVerts, vertexRemap, trailingUnused); -} - -_Use_decl_annotations_ -HRESULT DirectX::OptimizeVertices( - const uint32_t* indices, - size_t nFaces, - size_t nVerts, - uint32_t* vertexRemap, - size_t* trailingUnused) noexcept -{ - return OptimizeVerticesImpl(indices, nFaces, nVerts, vertexRemap, trailingUnused); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshOptimizeLRU.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshOptimizeLRU.cpp deleted file mode 100644 index 62fd683..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshOptimizeLRU.cpp +++ /dev/null @@ -1,661 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXMeshOptimizeLRU.cpp -// -// DirectX Mesh Geometry Library - Mesh optimization -// -// Forsyth "Linear-Speed Vertex Cache Optimisation" -// https://tomforsyth1000.github.io/papers/fast_vert_cache_opt.html -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkID=324981 -//------------------------------------------------------------------------------------- - -#include "DirectXMeshP.h" - -using namespace DirectX; - -namespace -{ - // This code was authored and released into the public domain by Adrian Stone (stone@gameangst.com). - - // code for computing vertex score was taken, as much as possible - // directly from the original publication. - float ComputeVertexCacheScore(uint32_t cachePosition, uint32_t vertexCacheSize) noexcept - { - constexpr float FindVertexScore_CacheDecayPower = 1.5f; - constexpr float FindVertexScore_LastTriScore = 0.75f; - - float score = 0.0f; - if (cachePosition >= vertexCacheSize) - { - // Vertex is not in FIFO cache - no score. - } - else - { - if (cachePosition < 3) - { - // This vertex was used in the last triangle, - // so it has a fixed score, whichever of the three - // it's in. Otherwise, you can get very different - // answers depending on whether you add - // the triangle 1,2,3 or 3,1,2 - which is silly. - - score = FindVertexScore_LastTriScore; - } - else - { - // Points for being high in the cache. - const float scaler = 1.0f / float(vertexCacheSize - 3u); - score = 1.0f - float(cachePosition - 3u) * scaler; - score = powf(score, FindVertexScore_CacheDecayPower); - } - } - - return score; - } - - float ComputeVertexValenceScore(uint32_t numActiveFaces) noexcept - { - constexpr float FindVertexScore_ValenceBoostScale = 2.0f; - constexpr float FindVertexScore_ValenceBoostPower = 0.5f; - - float score = 0.f; - - // Bonus points for having a low number of tris still to - // use the vert, so we get rid of lone verts quickly. - const float valenceBoost = powf(static_cast(numActiveFaces), - -FindVertexScore_ValenceBoostPower); - - score += FindVertexScore_ValenceBoostScale * valenceBoost; - return score; - } - - enum { kMaxVertexCacheSize = 64 }; - enum { kMaxPrecomputedVertexValenceScores = 64 }; - - float s_vertexCacheScores[kMaxVertexCacheSize + 1][kMaxVertexCacheSize]; - float s_vertexValenceScores[kMaxPrecomputedVertexValenceScores]; - -#ifdef _WIN32 - static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT; - - BOOL WINAPI ComputeVertexScores(PINIT_ONCE, PVOID, PVOID*) noexcept - #else - std::once_flag s_initOnce; - - void ComputeVertexScores() noexcept - #endif - { - for (uint32_t cacheSize = 0; cacheSize <= kMaxVertexCacheSize; ++cacheSize) - { - for (uint32_t cachePos = 0; cachePos < cacheSize; ++cachePos) - { - s_vertexCacheScores[cacheSize][cachePos] = ComputeVertexCacheScore(cachePos, cacheSize); - } - } - - for (uint32_t valence = 0; valence < kMaxPrecomputedVertexValenceScores; ++valence) - { - s_vertexValenceScores[valence] = ComputeVertexValenceScore(valence); - } - - #ifdef _WIN32 - return TRUE; - #endif - } - - float FindVertexScore(uint32_t numActiveFaces, uint32_t cachePosition, uint32_t vertexCacheSize) noexcept - { - if (numActiveFaces == 0) - { - // No tri needs this vertex! - - return -1.0f; - } - - float score = 0.f; - - if (cachePosition < vertexCacheSize) - { - score += s_vertexCacheScores[vertexCacheSize][cachePosition]; - } - - if (numActiveFaces < kMaxPrecomputedVertexValenceScores) - { - score += s_vertexValenceScores[numActiveFaces]; - } - else - { - score += ComputeVertexValenceScore(numActiveFaces); - } - - return score; - } - - template - struct OptimizeVertexData - { - float score; - uint32_t activeFaceListStart; - uint32_t activeFaceListSize; - IndexType cachePos0; - IndexType cachePos1; - - OptimizeVertexData() noexcept : score(0.f), activeFaceListStart(0), activeFaceListSize(0), cachePos0(0), cachePos1(0) {} - }; - - template - - struct IndexSortCompareIndexed - { - const IndexType *_indexData; - - IndexSortCompareIndexed(const IndexType *indexData) noexcept : _indexData(indexData) {} - - bool operator()(T a, T b) const noexcept - { - IndexType indexA = _indexData[a]; - IndexType indexB = _indexData[b]; - - if (indexA < indexB) - return true; - - return false; - } - }; - - template - struct FaceValenceSort - { - const OptimizeVertexData *_vertexData; - - FaceValenceSort(const OptimizeVertexData *vertexData) noexcept : _vertexData(vertexData) {} - - bool operator()(T a, T b) const noexcept - { - const OptimizeVertexData *vA = _vertexData + size_t(a) * 3; - const OptimizeVertexData *vB = _vertexData + size_t(b) * 3; - - const uint32_t aValence = vA[0].activeFaceListSize + vA[1].activeFaceListSize + vA[2].activeFaceListSize; - const uint32_t bValence = vB[0].activeFaceListSize + vB[1].activeFaceListSize + vB[2].activeFaceListSize; - - // higher scoring faces are those with lower valence totals - - // reverse sort (reverse of reverse) - - if (aValence < bValence) - return true; - - return false; - } - }; - - template - HRESULT OptimizeFacesImpl( - _In_reads_(indexCount) const IndexType* indexList, uint32_t indexCount, - _Out_writes_(indexCount / 3) uint32_t* faceRemap, uint32_t lruCacheSize, uint32_t offset) - { - std::unique_ptr[]> vertexDataList(new (std::nothrow) OptimizeVertexData[indexCount]); - if (!vertexDataList) - return E_OUTOFMEMORY; - - std::unique_ptr vertexRemap(new (std::nothrow) uint32_t[indexCount]); - std::unique_ptr activeFaceList(new (std::nothrow) uint32_t[indexCount]); - if (!vertexRemap || !activeFaceList) - return E_OUTOFMEMORY; - - const uint32_t faceCount = indexCount / 3; - - std::unique_ptr processedFaceList(new (std::nothrow) uint8_t[faceCount]); - std::unique_ptr faceSorted(new (std::nothrow) uint32_t[faceCount]); - std::unique_ptr faceReverseLookup(new (std::nothrow) uint32_t[faceCount]); - if (!processedFaceList || !faceSorted || !faceReverseLookup) - return E_OUTOFMEMORY; - - memset(processedFaceList.get(), 0, sizeof(uint8_t) * faceCount); - - // build the vertex remap table - uint32_t uniqueVertexCount = 0; - uint32_t unused = 0; - { - using indexSorter = IndexSortCompareIndexed; - - std::unique_ptr indexSorted(new (std::nothrow) uint32_t[indexCount]); - if (!indexSorted) - return E_OUTOFMEMORY; - - for (uint32_t i = 0; i < indexCount; i++) - { - indexSorted[i] = i; - } - - const indexSorter sortFunc(indexList); - std::sort(indexSorted.get(), indexSorted.get() + indexCount, sortFunc); - - bool first = false; - for (uint32_t i = 0; i < indexCount; i++) - { - const uint32_t idx = indexSorted[i]; - if (indexList[idx] == IndexType(-1)) - { - unused++; - vertexRemap[idx] = UNUSED32; - continue; - } - - if (!i || first || sortFunc(indexSorted[i - 1], idx)) - { - // it's not a duplicate - vertexRemap[idx] = uniqueVertexCount; - uniqueVertexCount++; - first = false; - } - else - { - vertexRemap[indexSorted[i]] = vertexRemap[indexSorted[i - 1]]; - } - } - } - - // compute face count per vertex - for (uint32_t i = 0; i < indexCount; ++i) - { - if (vertexRemap[i] == UNUSED32) - continue; - - OptimizeVertexData& vertexData = vertexDataList[vertexRemap[i]]; - vertexData.activeFaceListSize++; - } - - constexpr IndexType kEvictedCacheIndex = std::numeric_limits::max(); - { - // allocate face list per vertex - uint32_t curActiveFaceListPos = 0; - for (uint32_t i = 0; i < uniqueVertexCount; ++i) - { - OptimizeVertexData& vertexData = vertexDataList[i]; - vertexData.cachePos0 = kEvictedCacheIndex; - vertexData.cachePos1 = kEvictedCacheIndex; - vertexData.activeFaceListStart = curActiveFaceListPos; - curActiveFaceListPos += vertexData.activeFaceListSize; - vertexData.score = FindVertexScore(vertexData.activeFaceListSize, vertexData.cachePos0, lruCacheSize); - - vertexData.activeFaceListSize = 0; - } - - assert(curActiveFaceListPos == (indexCount - unused)); - } - - // sort unprocessed faces by highest score - for (uint32_t f = 0; f < faceCount; f++) - { - faceSorted[f] = f; - } - - const FaceValenceSort faceValenceSort(vertexDataList.get()); - std::sort(faceSorted.get(), faceSorted.get() + faceCount, faceValenceSort); - - for (uint32_t f = 0; f < faceCount; f++) - { - faceReverseLookup[faceSorted[f]] = f; - } - - // fill out face list per vertex - for (uint32_t i = 0; i < indexCount; i += 3) - { - for (uint32_t j = 0; j < 3; ++j) - { - const uint32_t v = vertexRemap[size_t(i) + size_t(j)]; - if (v == UNUSED32) - continue; - - OptimizeVertexData& vertexData = vertexDataList[v]; - activeFaceList[size_t(vertexData.activeFaceListStart) + vertexData.activeFaceListSize] = i; - vertexData.activeFaceListSize++; - } - } - - uint32_t vertexCacheBuffer[(kMaxVertexCacheSize + 3) * 2] = {}; - uint32_t *cache0 = vertexCacheBuffer; - uint32_t *cache1 = vertexCacheBuffer + (kMaxVertexCacheSize + 3); - uint32_t entriesInCache0 = 0; - - uint32_t bestFace = 0; - for (size_t i = 0; i < indexCount; i += 3) - { - if (vertexRemap[i] == UNUSED32 - || vertexRemap[i + 1] == UNUSED32 - || vertexRemap[i + 2] == UNUSED32) - { - ++bestFace; - continue; - } - else - break; - } - - float bestScore = -1.f; - - uint32_t nextBestFace = 0; - - uint32_t curFace = 0; - for (size_t i = 0; i < indexCount; i += 3) - { - if (vertexRemap[i] == UNUSED32 - || vertexRemap[i + 1] == UNUSED32 - || vertexRemap[i + 2] == UNUSED32) - { - continue; - } - - if (bestScore < 0.f) - { - // no verts in the cache are used by any unprocessed faces so - // search all unprocessed faces for a new starting point - while (nextBestFace < faceCount) - { - const uint32_t faceIndex = faceSorted[nextBestFace++]; - if (processedFaceList[faceIndex] == 0) - { - const uint32_t face = faceIndex * 3; - const uint32_t i0 = vertexRemap[face]; - const uint32_t i1 = vertexRemap[size_t(face) + 1]; - const uint32_t i2 = vertexRemap[size_t(face) + 2]; - if (i0 != UNUSED32 && i1 != UNUSED32 && i2 != UNUSED32) - { - // we're searching a pre-sorted list, first one we find will be the best - bestFace = face; - bestScore = vertexDataList[i0].score - + vertexDataList[i1].score - + vertexDataList[i2].score; - break; - } - } - } - assert(bestScore >= 0.f); - } - - processedFaceList[bestFace / 3] = 1; - uint16_t entriesInCache1 = 0; - - faceRemap[curFace] = (bestFace / 3) + offset; - curFace++; - - // add bestFace to LRU cache - assert(vertexRemap[bestFace] != UNUSED32); - assert(vertexRemap[size_t(bestFace) + 1] != UNUSED32); - assert(vertexRemap[size_t(bestFace) + 2] != UNUSED32); - - for (size_t v = 0; v < 3; ++v) - { - OptimizeVertexData& vertexData = vertexDataList[vertexRemap[bestFace + v]]; - - if (vertexData.cachePos1 >= entriesInCache1) - { - vertexData.cachePos1 = entriesInCache1; - cache1[entriesInCache1++] = vertexRemap[bestFace + v]; - - if (vertexData.activeFaceListSize == 1) - { - --vertexData.activeFaceListSize; - continue; - } - } - - assert(vertexData.activeFaceListSize > 0); - uint32_t* begin = activeFaceList.get() + vertexData.activeFaceListStart; - uint32_t* end = activeFaceList.get() + (size_t(vertexData.activeFaceListStart) + vertexData.activeFaceListSize); - uint32_t* it = std::find(begin, end, bestFace); - - assert(it != end); - - std::swap(*it, *(end - 1)); - - --vertexData.activeFaceListSize; - vertexData.score = FindVertexScore(vertexData.activeFaceListSize, vertexData.cachePos1, lruCacheSize); - - // need to re-sort the faces that use this vertex, as their score will change due to activeFaceListSize shrinking - for (const uint32_t *fi = begin; fi != end - 1; ++fi) - { - const uint32_t faceIndex = *fi / 3; - uint32_t n = faceReverseLookup[faceIndex]; - assert(faceSorted[n] == faceIndex); - - // found it, now move it up - while (n > 0) - { - if (faceValenceSort(n, n - 1)) - { - faceReverseLookup[faceSorted[n]] = n - 1; - faceReverseLookup[faceSorted[n - 1]] = n; - std::swap(faceSorted[n], faceSorted[n - 1]); - n--; - } - else - { - break; - } - } - } - } - - // move the rest of the old verts in the cache down and compute their new scores - for (uint32_t c0 = 0; c0 < entriesInCache0; ++c0) - { - OptimizeVertexData& vertexData = vertexDataList[cache0[c0]]; - - if (vertexData.cachePos1 >= entriesInCache1) - { - vertexData.cachePos1 = entriesInCache1; - cache1[entriesInCache1++] = cache0[c0]; - vertexData.score = FindVertexScore(vertexData.activeFaceListSize, vertexData.cachePos1, lruCacheSize); - - // don't need to re-sort this vertex... once it gets out of the cache, it'll have its original score - } - } - - // find the best scoring triangle in the current cache (including up to 3 that were just evicted) - bestScore = -1.f; - - for (uint32_t c1 = 0; c1 < entriesInCache1; ++c1) - { - OptimizeVertexData& vertexData = vertexDataList[cache1[c1]]; - vertexData.cachePos0 = vertexData.cachePos1; - vertexData.cachePos1 = kEvictedCacheIndex; - - for (uint32_t j = 0; j < vertexData.activeFaceListSize; ++j) - { - const uint32_t face = activeFaceList[size_t(vertexData.activeFaceListStart) + j]; - float faceScore = 0.f; - - for (uint32_t v = 0; v < 3; v++) - { - const OptimizeVertexData& faceVertexData = vertexDataList[vertexRemap[size_t(face) + v]]; - faceScore += faceVertexData.score; - } - - if (faceScore > bestScore) - { - bestScore = faceScore; - bestFace = face; - } - } - } - - std::swap(cache0, cache1); - - entriesInCache0 = std::min(entriesInCache1, lruCacheSize); - } - - for (; curFace < faceCount; ++curFace) - { - faceRemap[curFace] = UNUSED32; - } - - return S_OK; - } -} - -//===================================================================================== -// Entry-points -//===================================================================================== - -_Use_decl_annotations_ -HRESULT DirectX::OptimizeFacesLRU( - const uint16_t* indices, - size_t nFaces, - uint32_t* faceRemap, - uint32_t lruCacheSize) -{ - if (!indices || !nFaces || !faceRemap) - return E_INVALIDARG; - - if (!lruCacheSize || lruCacheSize > kMaxVertexCacheSize) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - -#ifdef _WIN32 - InitOnceExecuteOnce(&s_initOnce, ComputeVertexScores, nullptr, nullptr); -#else - std::call_once(s_initOnce, ComputeVertexScores); -#endif - - return OptimizeFacesImpl(indices, static_cast(nFaces * 3), faceRemap, lruCacheSize, 0); -} - -_Use_decl_annotations_ -HRESULT DirectX::OptimizeFacesLRU( - const uint32_t* indices, - size_t nFaces, - uint32_t* faceRemap, - uint32_t lruCacheSize) -{ - if (!indices || !nFaces || !faceRemap) - return E_INVALIDARG; - - if (!lruCacheSize || lruCacheSize > kMaxVertexCacheSize) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - -#ifdef _WIN32 - InitOnceExecuteOnce(&s_initOnce, ComputeVertexScores, nullptr, nullptr); -#else - std::call_once(s_initOnce, ComputeVertexScores); -#endif - - return OptimizeFacesImpl(indices, static_cast(nFaces * 3), faceRemap, lruCacheSize, 0); -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::OptimizeFacesLRUEx( - const uint16_t* indices, - size_t nFaces, - const uint32_t* attributes, - uint32_t* faceRemap, - uint32_t lruCacheSize) -{ - if (!indices || !nFaces || !attributes || !faceRemap) - return E_INVALIDARG; - - if (!lruCacheSize || lruCacheSize > kMaxVertexCacheSize) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - -#ifdef _WIN32 - InitOnceExecuteOnce(&s_initOnce, ComputeVertexScores, nullptr, nullptr); -#else - std::call_once(s_initOnce, ComputeVertexScores); -#endif - - auto subsets = ComputeSubsets(attributes, nFaces); - - if (subsets.empty()) - return E_UNEXPECTED; - - memset(faceRemap, 0, sizeof(uint32_t) * nFaces); - - for (const auto& it : subsets) - { - if (it.first >= nFaces) - return E_UNEXPECTED; - - if ((uint64_t(it.first) + uint64_t(it.second)) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - const uint32_t faceMax = uint32_t(it.first + it.second); - - if (faceMax > nFaces) - return E_UNEXPECTED; - - HRESULT hr = OptimizeFacesImpl( - &indices[it.first * 3], static_cast(it.second * 3), - &faceRemap[it.first], lruCacheSize, uint32_t(it.first)); - if (FAILED(hr)) - return hr; - } - - return S_OK; -} - -_Use_decl_annotations_ -HRESULT DirectX::OptimizeFacesLRUEx( - const uint32_t* indices, - size_t nFaces, - const uint32_t* attributes, - uint32_t* faceRemap, - uint32_t lruCacheSize) -{ - if (!indices || !nFaces || !attributes || !faceRemap) - return E_INVALIDARG; - - if (!lruCacheSize || lruCacheSize > kMaxVertexCacheSize) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - -#ifdef _WIN32 - InitOnceExecuteOnce(&s_initOnce, ComputeVertexScores, nullptr, nullptr); -#else - std::call_once(s_initOnce, ComputeVertexScores); -#endif - - auto subsets = ComputeSubsets(attributes, nFaces); - - if (subsets.empty()) - return E_UNEXPECTED; - - memset(faceRemap, 0, sizeof(uint32_t) * nFaces); - - for (const auto& it : subsets) - { - if (it.first >= nFaces) - return E_UNEXPECTED; - - if ((uint64_t(it.first) + uint64_t(it.second)) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - const uint32_t faceMax = uint32_t(it.first + it.second); - - if (faceMax > nFaces) - return E_UNEXPECTED; - - HRESULT hr = OptimizeFacesImpl( - &indices[it.first * 3], static_cast(it.second * 3), - &faceRemap[it.first], lruCacheSize, uint32_t(it.first)); - if (FAILED(hr)) - return hr; - } - - return S_OK; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshOptimizeTVC.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshOptimizeTVC.cpp deleted file mode 100644 index 02a7414..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshOptimizeTVC.cpp +++ /dev/null @@ -1,885 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXMeshOptimizeTVC.cpp -// -// DirectX Mesh Geometry Library - Mesh optimization -// -// Hoppe "Optimization of mesh locality for transparent vertex caching" -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkID=324981 -//------------------------------------------------------------------------------------- - -#include "DirectXMeshP.h" - -using namespace DirectX; - -namespace -{ - //--------------------------------------------------------------------------------- - template - class mesh_status - { - public: - mesh_status() noexcept : - mUnprocessed{}, - mFaceOffset(0), - mFaceCount(0), - mMaxSubset(0), - mTotalFaces(0) - { - } - - HRESULT initialize( - _In_reads_(nFaces * 3) const index_t* indices, size_t nFaces, - _In_reads_(nFaces * 3) const uint32_t* adjacency, - const std::vector>& subsets) - { - if (!indices || !nFaces || !adjacency || subsets.empty()) - return E_INVALIDARG; - - // Convert adjacency to 'physical' adjacency - mPhysicalNeighbors.reset(new (std::nothrow) neighborInfo[nFaces]); - if (!mPhysicalNeighbors) - return E_OUTOFMEMORY; - - #ifdef _DEBUG - memset(mPhysicalNeighbors.get(), 0xcd, sizeof(neighborInfo) * nFaces); - #endif - - mFaceOffset = 0; - mFaceCount = 0; - mMaxSubset = 0; - mTotalFaces = nFaces; - - for (const auto& it : subsets) - { - if ((uint64_t(it.first) + uint64_t(it.second)) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - if (it.second > mMaxSubset) - { - mMaxSubset = it.second; - } - - const uint32_t faceOffset = uint32_t(it.first); - const uint32_t faceMax = uint32_t(it.first + it.second); - - for (uint32_t face = faceOffset; face < faceMax; ++face) - { - if (face >= nFaces) - return E_UNEXPECTED; - - index_t i0 = indices[face * 3]; - index_t i1 = indices[face * 3 + 1]; - index_t i2 = indices[face * 3 + 2]; - - if (i0 == index_t(-1) - || i1 == index_t(-1) - || i2 == index_t(-1) - || i0 == i1 - || i0 == i2 - || i1 == i2) - { - // unused and degenerate faces should not have neighbors - for (uint32_t point = 0; point < 3; ++point) - { - const uint32_t k = adjacency[face * 3 + point]; - - if (k != UNUSED32) - { - if (k >= nFaces) - return E_UNEXPECTED; - - if (adjacency[k * 3] == face) - mPhysicalNeighbors[k].neighbors[0] = UNUSED32; - - if (adjacency[k * 3 + 1] == face) - mPhysicalNeighbors[k].neighbors[1] = UNUSED32; - - if (adjacency[k * 3 + 2] == face) - mPhysicalNeighbors[k].neighbors[2] = UNUSED32; - } - - mPhysicalNeighbors[face].neighbors[point] = UNUSED32; - } - } - else - { - for (uint32_t n = 0; n < 3; ++n) - { - uint32_t neighbor = adjacency[face * 3 + n]; - - if (neighbor != UNUSED32) - { - if ((neighbor < faceOffset) || (neighbor >= faceMax) - || (neighbor == adjacency[face * 3 + ((n + 1) % 3)]) - || (neighbor == adjacency[face * 3 + ((n + 2) % 3)])) - { - // Break links for any neighbors outside of our attribute set, and remove duplicate neighbors - neighbor = UNUSED32; - } - else - { - const uint32_t edgeBack = find_edge(&adjacency[neighbor * 3], face); - if (edgeBack < 3) - { - index_t p1 = indices[face * 3 + n]; - index_t p2 = indices[face * 3 + ((n + 1) % 3)]; - - index_t pn1 = indices[neighbor * 3 + edgeBack]; - index_t pn2 = indices[neighbor * 3 + ((edgeBack + 1) % 3)]; - - // if wedge not identical on shared edge, drop link - if ((p1 != pn2) || (p2 != pn1)) - { - neighbor = UNUSED32; - } - } - else - { - neighbor = UNUSED32; - } - } - } - - mPhysicalNeighbors[face].neighbors[n] = neighbor; - } - } - } - } - - if (!mMaxSubset) - return E_FAIL; - - mListElements.reset(new (std::nothrow) listElement[mMaxSubset]); - if (!mListElements) - return E_OUTOFMEMORY; - - return S_OK; - } - - HRESULT setSubset( - _In_reads_(nFaces * 3) const index_t* indices, size_t nFaces, - size_t faceOffset, size_t faceCount) noexcept - { - if (!faceCount || !indices || !nFaces) - return E_INVALIDARG; - - if (faceCount > mMaxSubset) - return E_UNEXPECTED; - - if (!mListElements) - return E_POINTER; - - if ((uint64_t(faceOffset) + uint64_t(faceCount)) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - const uint32_t faceMax = uint32_t(faceOffset + faceCount); - - if (faceMax > nFaces) - return E_UNEXPECTED; - - mFaceOffset = faceOffset; - mFaceCount = faceCount; - - mUnprocessed[0] = UNUSED32; - mUnprocessed[1] = UNUSED32; - mUnprocessed[2] = UNUSED32; - mUnprocessed[3] = UNUSED32; - - for (uint32_t face = uint32_t(faceOffset); face < faceMax; ++face) - { - index_t i0 = indices[face * 3]; - index_t i1 = indices[face * 3 + 1]; - index_t i2 = indices[face * 3 + 2]; - - if (i0 == index_t(-1) - || i1 == index_t(-1) - || i2 == index_t(-1)) - { - // filter out unused triangles - continue; - } - - uint32_t unprocessed = 0; - - for (uint32_t n = 0; n < 3; ++n) - { - if (mPhysicalNeighbors[face].neighbors[n] != UNUSED32) - { - unprocessed += 1; - - assert(mPhysicalNeighbors[face].neighbors[n] >= mFaceOffset); - assert(mPhysicalNeighbors[face].neighbors[n] < faceMax); - } - } - - const uint32_t faceIndex = uint32_t(face - faceOffset); - mListElements[faceIndex].processed = false; - mListElements[faceIndex].unprocessed = unprocessed; - - push_front(faceIndex); - } - - return S_OK; - } - - bool isprocessed(uint32_t face) const noexcept - { - assert(face < mTotalFaces); - assert((face >= mFaceOffset) || (face < (mFaceOffset + mFaceCount))); - return mListElements[face - mFaceOffset].processed; - } - - uint32_t unprocessed_count(uint32_t face) const noexcept - { - assert(face < mTotalFaces); - assert((face >= mFaceOffset) || (face < (mFaceOffset + mFaceCount))); - return mListElements[face - mFaceOffset].unprocessed; - } - - uint32_t find_initial() const noexcept - { - for (size_t j = 0; j < 4; ++j) - { - if (mUnprocessed[j] != UNUSED32) - return uint32_t(mUnprocessed[j] + mFaceOffset); - } - - return UNUSED32; - } - - void mark(uint32_t face) noexcept - { - assert(face < mTotalFaces); - assert((face >= mFaceOffset) || (face < (mFaceOffset + mFaceCount))); - - const uint32_t faceIndex = uint32_t(face - mFaceOffset); - - assert(!mListElements[faceIndex].processed); - mListElements[faceIndex].processed = true; - - remove(faceIndex); - - for (uint32_t n = 0; n < 3; ++n) - { - const uint32_t neighbor = mPhysicalNeighbors[face].neighbors[n]; - if ((neighbor != UNUSED32) && !isprocessed(neighbor)) - { - decrement(neighbor); - } - } - } - - uint32_t find_next(uint32_t face) const noexcept - { - assert(face < mTotalFaces); - assert((face >= mFaceOffset) || (face < (mFaceOffset + mFaceCount))); - - uint32_t iret = 3; - uint32_t minNeighbor = UNUSED32; - uint32_t minNextNeighbor = 0; - - for (uint32_t n = 0; n < 3; ++n) - { - const uint32_t neighbor = mPhysicalNeighbors[face].neighbors[n]; - - if ((neighbor == UNUSED32) || isprocessed(neighbor)) - continue; - - const uint32_t unprocessed = unprocessed_count(neighbor); - assert(unprocessed < 3); - - uint32_t mintemp = UNUSED32; - - for (uint32_t nt = 0; nt < 3; ++nt) - { - const uint32_t neighborTemp = mPhysicalNeighbors[neighbor].neighbors[nt]; - - if ((neighborTemp == UNUSED32) || isprocessed(neighborTemp)) - continue; - - const uint32_t next_count = unprocessed_count(neighborTemp); - if (next_count < mintemp) - mintemp = next_count; - } - - if (mintemp == UNUSED32) - mintemp = 0; - - if (unprocessed < minNeighbor) - { - iret = n; - minNeighbor = unprocessed; - minNextNeighbor = mintemp; - } - else if ((unprocessed == minNeighbor) && (mintemp < minNextNeighbor)) - { - iret = n; - minNextNeighbor = mintemp; - } - } - - return iret; - } - - uint32_t get_neighbors(uint32_t face, uint32_t n) const noexcept - { - assert(face < mTotalFaces); - assert(n < 3); - _Analysis_assume_(face < mTotalFaces); - _Analysis_assume_(n < 3); - return mPhysicalNeighbors[face].neighbors[n]; - } - - const uint32_t* get_neighborsPtr(uint32_t face) const noexcept - { - assert(face < mTotalFaces); - return &mPhysicalNeighbors[face].neighbors[0]; - } - - private: - void push_front(uint32_t faceIndex) noexcept - { - assert(faceIndex < mFaceCount); - - uint32_t unprocessed = mListElements[faceIndex].unprocessed; - - const uint32_t head = mUnprocessed[unprocessed]; - mListElements[faceIndex].next = head; - - if (head != UNUSED32) - mListElements[head].prev = faceIndex; - - mUnprocessed[unprocessed] = faceIndex; - - mListElements[faceIndex].prev = UNUSED32; - } - - void remove(uint32_t faceIndex) noexcept - { - assert(faceIndex < mFaceCount); - - if (mListElements[faceIndex].prev != UNUSED32) - { - assert(mUnprocessed[mListElements[faceIndex].unprocessed] != faceIndex); - - const uint32_t prev = mListElements[faceIndex].prev; - const uint32_t next = mListElements[faceIndex].next; - - mListElements[prev].next = next; - - if (next != UNUSED32) - { - mListElements[next].prev = prev; - } - } - else - { - // remove head of the list - assert(mUnprocessed[mListElements[faceIndex].unprocessed] == faceIndex); - - uint32_t unprocessed = mListElements[faceIndex].unprocessed; - - mUnprocessed[unprocessed] = mListElements[faceIndex].next; - - if (mUnprocessed[unprocessed] != UNUSED32) - { - mListElements[mUnprocessed[unprocessed]].prev = UNUSED32; - } - } - - mListElements[faceIndex].prev = - mListElements[faceIndex].next = UNUSED32; - } - - void decrement(uint32_t face) noexcept - { - assert(face < mTotalFaces); - assert((face >= mFaceOffset) || (face < (mFaceOffset + mFaceCount))); - assert(!isprocessed(face)); - - const uint32_t faceIndex = uint32_t(face - mFaceOffset); - - assert((mListElements[faceIndex].unprocessed >= 1) && (mListElements[faceIndex].unprocessed <= 3)); - - remove(faceIndex); - - mListElements[faceIndex].unprocessed -= 1; - - push_front(faceIndex); - } - - struct neighborInfo - { - uint32_t neighbors[3]; - }; - - struct listElement - { - bool processed; - uint32_t unprocessed; - uint32_t prev; - uint32_t next; - }; - - uint32_t mUnprocessed[4]; - size_t mFaceOffset; - size_t mFaceCount; - size_t mMaxSubset; - size_t mTotalFaces; - std::unique_ptr mListElements; - std::unique_ptr mPhysicalNeighbors; - }; - - - //--------------------------------------------------------------------------------- - using facecorner_t = std::pair; - - template - inline facecorner_t counterclockwise_corner(facecorner_t corner, const mesh_status& status) noexcept - { - assert(corner.second != UNUSED32); - const uint32_t edge = (corner.second + 2) % 3; - uint32_t neighbor = status.get_neighbors(corner.first, edge); - uint32_t point = (neighbor == UNUSED32) ? UNUSED32 : find_edge(status.get_neighborsPtr(neighbor), corner.first); - return facecorner_t(neighbor, point); - } - - - //--------------------------------------------------------------------------------- - class sim_vcache - { - public: - sim_vcache() noexcept : mTail(0), mCacheSize(0) {} - - HRESULT initialize(uint32_t cacheSize) noexcept - { - if (!cacheSize) - return E_INVALIDARG; - - mFIFO.reset(new (std::nothrow) uint32_t[cacheSize]); - if (!mFIFO) - return E_OUTOFMEMORY; - - mCacheSize = cacheSize; - - clear(); - - return S_OK; - } - - void clear() noexcept - { - assert(mFIFO != nullptr); - mTail = 0; - memset(mFIFO.get(), 0xff, sizeof(uint32_t) * mCacheSize); - } - - bool access(uint32_t vertex) noexcept - { - assert(vertex != UNUSED32); - assert(mFIFO != nullptr); - - for (size_t ptr = 0; ptr < mCacheSize; ++ptr) - { - if (mFIFO[ptr] == vertex) - { - return true; - } - } - - mFIFO[mTail] = vertex; - mTail += 1; - if (mTail == mCacheSize) - mTail = 0; - - return false; - } - - private: - uint32_t mTail; - uint32_t mCacheSize; - std::unique_ptr mFIFO; - }; - - - //--------------------------------------------------------------------------------- - template - HRESULT StripReorderImpl( - _In_reads_(nFaces * 3) const index_t* indices, _In_ size_t nFaces, - _In_reads_(nFaces * 3) const uint32_t* adjacency, - _In_reads_opt_(nFaces) const uint32_t* attributes, - _Out_writes_(nFaces) uint32_t* faceRemap) - { - auto subsets = ComputeSubsets(attributes, nFaces); - - assert(!subsets.empty()); - - mesh_status status; - HRESULT hr = status.initialize(indices, nFaces, adjacency, subsets); - if (FAILED(hr)) - return hr; - - std::unique_ptr faceRemapInverse(new (std::nothrow) uint32_t[nFaces]); - if (!faceRemapInverse) - return E_OUTOFMEMORY; - - memset(faceRemapInverse.get(), 0xff, sizeof(uint32_t) * nFaces); - - for (const auto& it : subsets) - { - hr = status.setSubset(indices, nFaces, it.first, it.second); - if (FAILED(hr)) - return hr; - - uint32_t curface = 0; - - for (;;) - { - uint32_t face = status.find_initial(); - if (face == UNUSED32) - break; - - status.mark(face); - - uint32_t next = status.find_next(face); - - for (;;) - { - assert(face != UNUSED32); - faceRemapInverse[face] = uint32_t(curface + it.first); - curface += 1; - - // if at end of strip, break out - if (next >= 3) - break; - - face = status.get_neighbors(face, next); - assert(face != UNUSED32); - - status.mark(face); - - next = status.find_next(face); - } - } - } - - // inverse remap - memset(faceRemap, 0xff, sizeof(uint32_t) * nFaces); - - for (uint32_t j = 0; j < nFaces; ++j) - { - uint32_t f = faceRemapInverse[j]; - if (f < nFaces) - { - faceRemap[f] = j; - } - } - - return S_OK; - } - - - //--------------------------------------------------------------------------------- - template - HRESULT VertexCacheStripReorderImpl( - _In_reads_(nFaces * 3) const index_t* indices, _In_ size_t nFaces, - _In_reads_(nFaces * 3) const uint32_t* adjacency, - _In_reads_opt_(nFaces) const uint32_t* attributes, - _Out_writes_(nFaces) uint32_t* faceRemap, - uint32_t vertexCache, uint32_t restart) - { - auto subsets = ComputeSubsets(attributes, nFaces); - - assert(!subsets.empty()); - - mesh_status status; - HRESULT hr = status.initialize(indices, nFaces, adjacency, subsets); - if (FAILED(hr)) - return hr; - - sim_vcache vcache; - hr = vcache.initialize(vertexCache); - if (FAILED(hr)) - return hr; - - std::unique_ptr faceRemapInverse(new (std::nothrow) uint32_t[nFaces]); - if (!faceRemapInverse) - return E_OUTOFMEMORY; - - memset(faceRemapInverse.get(), 0xff, sizeof(uint32_t) * nFaces); - - assert(vertexCache >= restart); - const uint32_t desired = vertexCache - restart; - - for (const auto& it : subsets) - { - hr = status.setSubset(indices, nFaces, it.first, it.second); - if (FAILED(hr)) - return hr; - - vcache.clear(); - - uint32_t locnext = 0; - facecorner_t nextCorner(UNUSED32, UNUSED32); - facecorner_t curCorner(UNUSED32, UNUSED32); - - uint32_t curface = 0; - - for (;;) - { - assert(nextCorner.first == UNUSED32); - - curCorner.first = status.find_initial(); - if (curCorner.first == UNUSED32) - break; - - const uint32_t n0 = status.get_neighbors(curCorner.first, 0); - if ((n0 != UNUSED32) && !status.isprocessed(n0)) - { - curCorner.second = 1; - } - else - { - const uint32_t n1 = status.get_neighbors(curCorner.first, 1); - if ((n1 != UNUSED32) && !status.isprocessed(n1)) - { - curCorner.second = 2; - } - else - { - curCorner.second = 0; - } - } - - bool striprestart = false; - for (;;) - { - assert(curCorner.first != UNUSED32); - assert(!status.isprocessed(curCorner.first)); - - // Decision: either add a ring of faces or restart strip - if (nextCorner.first != UNUSED32) - { - uint32_t nf = 0; - for (facecorner_t temp = curCorner; ; ) - { - const facecorner_t next = counterclockwise_corner(temp, status); - if ((next.first == UNUSED32) || status.isprocessed(next.first)) - break; - ++nf; - temp = next; - } - - if (locnext + nf > desired) - { - // restart - if (!status.isprocessed(nextCorner.first)) - { - curCorner = nextCorner; - } - - nextCorner.first = UNUSED32; - } - } - - for (;;) - { - assert(curCorner.first != UNUSED32); - status.mark(curCorner.first); - - faceRemapInverse[curCorner.first] = uint32_t(curface + it.first); - curface += 1; - - assert(indices[curCorner.first * 3] != index_t(-1)); - if (!vcache.access(indices[curCorner.first * 3])) - locnext += 1; - - assert(indices[curCorner.first * 3 + 1] != index_t(-1)); - if (!vcache.access(indices[curCorner.first * 3 + 1])) - locnext += 1; - - assert(indices[curCorner.first * 3 + 2] != index_t(-1)); - if (!vcache.access(indices[curCorner.first * 3 + 2])) - locnext += 1; - - const facecorner_t intCorner = counterclockwise_corner(curCorner, status); - const bool interiornei = (intCorner.first != UNUSED32) && !status.isprocessed(intCorner.first); - - const facecorner_t extCorner = counterclockwise_corner(facecorner_t(curCorner.first, (curCorner.second + 2) % 3), status); - const bool exteriornei = (extCorner.first != UNUSED32) && !status.isprocessed(extCorner.first); - - if (interiornei) - { - if (exteriornei) - { - if (nextCorner.first == UNUSED32) - { - nextCorner = extCorner; - locnext = 0; - } - } - curCorner = intCorner; - } - else if (exteriornei) - { - curCorner = extCorner; - break; - } - else - { - curCorner = nextCorner; - nextCorner.first = UNUSED32; - - if ((curCorner.first == UNUSED32) || status.isprocessed(curCorner.first)) - { - striprestart = true; - break; - } - } - } - - if (striprestart) - break; - } - } - } - - // inverse remap - memset(faceRemap, 0xff, sizeof(uint32_t) * nFaces); - - for (uint32_t j = 0; j < nFaces; ++j) - { - uint32_t f = faceRemapInverse[j]; - if (f < nFaces) - { - faceRemap[f] = j; - } - } - - return S_OK; - } -} - -//===================================================================================== -// Entry-points -//===================================================================================== - -_Use_decl_annotations_ -HRESULT DirectX::OptimizeFaces( - const uint16_t* indices, - size_t nFaces, - const uint32_t* adjacency, - uint32_t* faceRemap, - uint32_t vertexCache, - uint32_t restart) -{ - if (!indices || !nFaces || !adjacency || !faceRemap) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - if (vertexCache == OPTFACES_V_STRIPORDER) - { - return StripReorderImpl(indices, nFaces, adjacency, nullptr, faceRemap); - } - else - { - if (restart > vertexCache) - return E_INVALIDARG; - - return VertexCacheStripReorderImpl(indices, nFaces, adjacency, nullptr, faceRemap, vertexCache, restart); - } -} - -_Use_decl_annotations_ -HRESULT DirectX::OptimizeFaces( - const uint32_t* indices, - size_t nFaces, - const uint32_t* adjacency, - uint32_t* faceRemap, - uint32_t vertexCache, - uint32_t restart) -{ - if (!indices || !nFaces || !adjacency || !faceRemap) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - if (vertexCache == OPTFACES_V_STRIPORDER) - { - return StripReorderImpl(indices, nFaces, adjacency, nullptr, faceRemap); - } - else - { - if (restart > vertexCache) - return E_INVALIDARG; - - return VertexCacheStripReorderImpl(indices, nFaces, adjacency, nullptr, faceRemap, vertexCache, restart); - } -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::OptimizeFacesEx( - const uint16_t* indices, - size_t nFaces, - const uint32_t* adjacency, - const uint32_t* attributes, - uint32_t* faceRemap, - uint32_t vertexCache, - uint32_t restart) -{ - if (!indices || !nFaces || !adjacency || !attributes || !faceRemap) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - if (vertexCache == OPTFACES_V_STRIPORDER) - { - return StripReorderImpl(indices, nFaces, adjacency, attributes, faceRemap); - } - else - { - if (restart > vertexCache) - return E_INVALIDARG; - - return VertexCacheStripReorderImpl(indices, nFaces, adjacency, attributes, faceRemap, vertexCache, restart); - } -} - -_Use_decl_annotations_ -HRESULT DirectX::OptimizeFacesEx( - const uint32_t* indices, - size_t nFaces, - const uint32_t* adjacency, - const uint32_t* attributes, - uint32_t* faceRemap, - uint32_t vertexCache, - uint32_t restart) -{ - if (!indices || !nFaces || !adjacency || !attributes || !faceRemap) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - if (vertexCache == OPTFACES_V_STRIPORDER) - { - return StripReorderImpl(indices, nFaces, adjacency, attributes, faceRemap); - } - else - { - if (restart > vertexCache) - return E_INVALIDARG; - - return VertexCacheStripReorderImpl(indices, nFaces, adjacency, attributes, faceRemap, vertexCache, restart); - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshP.h b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshP.h deleted file mode 100644 index cc1e114..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshP.h +++ /dev/null @@ -1,410 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXMeshP.h -// -// DirectX Mesh Geometry Library -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkID=324981 -//------------------------------------------------------------------------------------- - -#pragma once - -// Off by default warnings -#pragma warning(disable : 4619 4616 4061 4365 4514 4571 4623 4625 4626 4628 4668 4710 4711 4746 4774 4820 4987 5026 5027 5031 5032 5039 5045 5219 5246 26812) -// C4619/4616 #pragma warning warnings -// C4061 enumerator 'X' in switch of enum 'X' is not explicitly handled by a case label -// C4365 signed/unsigned mismatch -// C4514 unreferenced inline function has been removed -// C4571 behavior change -// C4623 default constructor was implicitly defined as deleted -// C4625 copy constructor was implicitly defined as deleted -// C4626 assignment operator was implicitly defined as deleted -// C4628 digraphs not supported -// C4668 not defined as a preprocessor macro -// C4710 function not inlined -// C4711 selected for automatic inline expansion -// C4746 volatile access of '' is subject to /volatile: setting -// C4774 format string expected in argument 3 is not a string literal -// C4820 padding added after data member -// C4987 nonstandard extension used -// C5026 move constructor was implicitly defined as deleted -// C5027 move assignment operator was implicitly defined as deleted -// C5031/5032 push/pop mismatches in windows headers -// C5039 pointer or reference to potentially throwing function passed to extern C function under - EHc -// C5045 Spectre mitigation warning -// C5219 implicit conversion from 'int' to 'float', possible loss of data -// C5246 the initialization of a subobject should be wrapped in braces -// 26812: The enum type 'x' is unscoped. Prefer 'enum class' over 'enum' (Enum.3). - -// Windows 8.1 SDK related Off by default warnings -#pragma warning(disable : 4471 4917 4986 5029) -// C4471 forward declaration of an unscoped enumeration must have an underlying type -// C4917 a GUID can only be associated with a class, interface or namespace -// C4986 exception specification does not match previous declaration -// C5029 nonstandard extension used - -// Xbox One XDK related Off by default warnings -#pragma warning(disable : 4643) -// C4643 Forward declaring in namespace std is not permitted by the C++ Standard - -#ifdef __clang__ -#pragma clang diagnostic ignored "-Wc++98-compat" -#pragma clang diagnostic ignored "-Wc++98-compat-pedantic" -#pragma clang diagnostic ignored "-Wc++98-compat-local-type-template-args" -#pragma clang diagnostic ignored "-Wcovered-switch-default" -#pragma clang diagnostic ignored "-Wfloat-equal" -#pragma clang diagnostic ignored "-Wreserved-id-macro" -#endif - -#ifdef _WIN32 -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif - -#pragma warning(push) -#pragma warning(disable : 4005) -#define NOMINMAX 1 -#define NODRAWTEXT -#define NOGDI -#define NOBITMAP -#define NOMCX -#define NOSERVICE -#define NOHELP -#pragma warning(pop) - -#include - -#ifdef __MINGW32__ -#include -#endif - -#ifndef _WIN32_WINNT_WIN10 -#define _WIN32_WINNT_WIN10 0x0A00 -#endif - -#ifdef _GAMING_XBOX_SCARLETT -#pragma warning(push) -#pragma warning(disable: 5204 5249) -#include -#pragma warning(pop) -#elif defined(_GAMING_XBOX) -#pragma warning(push) -#pragma warning(disable: 5204) -#include -#pragma warning(pop) -#elif defined(_XBOX_ONE) && defined(_TITLE) -#include -#include -#elif (_WIN32_WINNT >= _WIN32_WINNT_WIN10) -#ifdef USING_DIRECTX_HEADERS -#include -#include -#else -#include -#endif -#include -#else -#include -#endif -#else // !WIN32 -#include -#include -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef _WIN32 -#include -#endif - -#define _XM_NO_XMVECTOR_OVERLOADS_ - -#include "DirectXMesh.h" - -#include - -#include "scoped.h" - -#ifndef XBOX_DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM -#define XBOX_DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM DXGI_FORMAT(189) -#endif - -// HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW) -#define HRESULT_E_ARITHMETIC_OVERFLOW static_cast(0x80070216L) - -// HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED) -#define HRESULT_E_NOT_SUPPORTED static_cast(0x80070032L) - -// HRESULT_FROM_WIN32(ERROR_INVALID_NAME) -#define HRESULT_E_INVALID_NAME static_cast(0x8007007BL) - -// E_BOUNDS -#ifndef E_BOUNDS -#define E_BOUNDS static_cast(0x8000000BL) -#endif - -namespace DirectX -{ - //--------------------------------------------------------------------------------- - constexpr uint32_t UNUSED32 = uint32_t(-1); - -#if (defined(__d3d11_h__) || defined(__d3d11_x_h__)) && !defined(__MINGW32__) - static_assert(D3D11_16BIT_INDEX_STRIP_CUT_VALUE == uint16_t(-1), "Mismatch with Direct3D11"); - static_assert(D3D11_16BIT_INDEX_STRIP_CUT_VALUE == UINT16_MAX, "Mismatch with Direct3D11"); - - static_assert(D3D11_32BIT_INDEX_STRIP_CUT_VALUE == uint32_t(-1), "Mismatch with Direct3D11"); - static_assert(D3D11_32BIT_INDEX_STRIP_CUT_VALUE == UINT32_MAX, "Mismatch with Direct3D11"); -#endif - -#if defined(__d3d12_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__) - static_assert(D3D12_16BIT_INDEX_STRIP_CUT_VALUE == uint16_t(-1), "Mismatch with Direct3D12"); - static_assert(D3D12_16BIT_INDEX_STRIP_CUT_VALUE == UINT16_MAX, "Mismatch with Direct3D12"); - - static_assert(D3D12_32BIT_INDEX_STRIP_CUT_VALUE == uint32_t(-1), "Mismatch with Direct3D12"); - static_assert(D3D12_32BIT_INDEX_STRIP_CUT_VALUE == UINT32_MAX, "Mismatch with Direct3D12"); -#endif - - //--------------------------------------------------------------------------------- - // Utility for walking adjacency - //--------------------------------------------------------------------------------- - template - class orbit_iterator - { - public: - enum WalkType - { - ALL = 0, - CW, - CCW - }; - - orbit_iterator(_In_reads_(nFaces * 3) const uint32_t* adjacency, _In_reads_(nFaces * 3) const index_t* indices, size_t nFaces) noexcept : - m_face(UNUSED32), - m_pointIndex(UNUSED32), - m_currentFace(UNUSED32), - m_currentEdge(UNUSED32), - m_nextEdge(UNUSED32), - m_adjacency(adjacency), - m_indices(indices), - m_nFaces(nFaces), - m_clockWise(false), - m_stopOnBoundary(false) - { - } - - void initialize(uint32_t face, uint32_t point, WalkType wtype) noexcept - { - m_face = m_currentFace = face; - m_pointIndex = point; - m_clockWise = (wtype != CCW); - m_stopOnBoundary = (wtype != ALL); - - m_nextEdge = find(face, point); - assert(m_nextEdge < 3); - _Analysis_assume_(m_nextEdge < 3); - - if (!m_clockWise) - { - m_nextEdge = (m_nextEdge + 2) % 3; - } - - m_currentEdge = m_nextEdge; - } - - uint32_t find(uint32_t face, uint32_t point) noexcept - { - assert(face < m_nFaces); - _Analysis_assume_(face < m_nFaces); - - if (m_indices[face * 3] == point) - return 0; - else if (m_indices[face * 3 + 1] == point) - return 1; - else - { - assert(m_indices[face * 3 + 2] == point); - return 2; - } - } - - uint32_t nextFace() noexcept - { - assert(!done()); - - const uint32_t ret = m_currentFace; - m_currentEdge = m_nextEdge; - - for (;;) - { - const uint32_t prevFace = m_currentFace; - - assert((size_t(m_currentFace) * 3 + m_nextEdge) < (m_nFaces * 3)); - _Analysis_assume_((size_t(m_currentFace) * 3 + m_nextEdge) < (m_nFaces * 3)); - - m_currentFace = m_adjacency[m_currentFace * 3 + m_nextEdge]; - - if (m_currentFace == m_face) - { - // wrapped around after a full orbit, so finished - m_currentFace = UNUSED32; - break; - } - else if (m_currentFace != UNUSED32) - { - assert((size_t(m_currentFace) * 3 + 2) < (m_nFaces * 3)); - _Analysis_assume_((size_t(m_currentFace) * 3 + 2) < (m_nFaces * 3)); - - if (m_adjacency[m_currentFace * 3] == prevFace) - m_nextEdge = 0; - else if (m_adjacency[m_currentFace * 3 + 1] == prevFace) - m_nextEdge = 1; - else - { - assert(m_adjacency[m_currentFace * 3 + 2] == prevFace); - m_nextEdge = 2; - } - - if (m_clockWise) - { - m_nextEdge = (m_nextEdge + 1) % 3; - } - else - { - m_nextEdge = (m_nextEdge + 2) % 3; - } - - break; - } - else if (m_clockWise && !m_stopOnBoundary) - { - // hit boundary and need to restart to go counter-clockwise - m_clockWise = false; - m_currentFace = m_face; - - m_nextEdge = find(m_face, m_pointIndex); - assert(m_nextEdge < 3); - _Analysis_assume_(m_nextEdge < 3); - - m_nextEdge = (m_nextEdge + 2) % 3; - m_currentEdge = (m_currentEdge + 2) % 3; - - // Don't break out of loop so we can go the other way - } - else - { - // hit boundary and should stop - break; - } - } - - return ret; - } - - bool moveToCCW() noexcept - { - m_currentFace = m_face; - - m_nextEdge = find(m_currentFace, m_pointIndex); - const uint32_t initialNextEdge = m_nextEdge; - assert(m_nextEdge < 3); - _Analysis_assume_(m_nextEdge < 3); - - m_nextEdge = (m_nextEdge + 2) % 3; - - bool ret = false; - - uint32_t prevFace; - do - { - prevFace = m_currentFace; - m_currentFace = m_adjacency[m_currentFace * 3 + m_nextEdge]; - - if (m_currentFace != UNUSED32) - { - if (m_adjacency[m_currentFace * 3] == prevFace) - m_nextEdge = 0; - else if (m_adjacency[m_currentFace * 3 + 1] == prevFace) - m_nextEdge = 1; - else - { - assert(m_adjacency[m_currentFace * 3 + 2] == prevFace); - m_nextEdge = 2; - } - - m_nextEdge = (m_nextEdge + 2) % 3; - } - } - while ((m_currentFace != m_face) && (m_currentFace != UNUSED32)); - - if (m_currentFace == UNUSED32) - { - m_currentFace = prevFace; - m_nextEdge = (m_nextEdge + 1) % 3; - - m_pointIndex = m_indices[m_currentFace * 3 + m_nextEdge]; - - ret = true; - } - else - { - m_nextEdge = initialNextEdge; - } - - m_clockWise = true; - m_currentEdge = m_nextEdge; - m_face = m_currentFace; - return ret; - } - - bool done() const noexcept { return (m_currentFace == UNUSED32); } - uint32_t getpoint() const noexcept { return m_clockWise ? m_currentEdge : ((m_currentEdge + 1) % 3); } - - private: - uint32_t m_face; - uint32_t m_pointIndex; - uint32_t m_currentFace; - uint32_t m_currentEdge; - uint32_t m_nextEdge; - - const uint32_t* m_adjacency; - const index_t* m_indices; - size_t m_nFaces; - - bool m_clockWise; - bool m_stopOnBoundary; - }; - - - //------------------------------------------------------------------------------------- - template - inline uint32_t find_edge(_In_reads_(3) const index_t* indices, index_t search) noexcept - { - assert(indices != nullptr); - - uint32_t edge = 0; - - for (; edge < 3; ++edge) - { - if (indices[edge] == search) - break; - } - - return edge; - } - -} // namespace diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshRemap.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshRemap.cpp deleted file mode 100644 index a369a29..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshRemap.cpp +++ /dev/null @@ -1,923 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXMeshRemap.cpp -// -// DirectX Mesh Geometry Library - Remap functions for applying face/vertex mappings -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkID=324981 -//------------------------------------------------------------------------------------- - -#include "DirectXMeshP.h" - -using namespace DirectX; - -namespace -{ - constexpr size_t c_MaxStride = 2048; - -#if defined(__d3d11_h__) || defined(__d3d11_x_h__) - static_assert(c_MaxStride == D3D11_REQ_MULTI_ELEMENT_STRUCTURE_SIZE_IN_BYTES, "D3D11 mismatch"); -#endif - -#if defined(__d3d12_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__) - static_assert(c_MaxStride == D3D12_REQ_MULTI_ELEMENT_STRUCTURE_SIZE_IN_BYTES, "D3D12 mismatch"); -#endif - - //--------------------------------------------------------------------------------- -#pragma warning(push) -#pragma warning( disable : 6101 ) - - template - HRESULT ReorderFaces( - _In_reads_(nFaces * 3) const index_t* ibin, _In_ size_t nFaces, - _In_reads_opt_(nFaces * 3) const uint32_t* adjin, - _In_reads_(nFaces) const uint32_t* faceRemap, - _Out_writes_(nFaces * 3) index_t* ibout, - _Out_writes_opt_(nFaces * 3) uint32_t* adjout) noexcept - { - assert(ibin != nullptr && faceRemap != nullptr && ibout != nullptr && ibin != ibout); - _Analysis_assume_(ibin != nullptr && faceRemap != nullptr && ibout != nullptr && ibin != ibout); - - assert((!adjin && !adjout) || ((adjin && adjout) && adjin != adjout)); - _Analysis_assume_((!adjin && !adjout) || ((adjin && adjout) && adjin != adjout)); - - for (size_t j = 0; j < nFaces; ++j) - { - const uint32_t src = faceRemap[j]; - - if (src == UNUSED32) - continue; - - if (src < nFaces) - { - ibout[j * 3] = ibin[src * 3]; - ibout[j * 3 + 1] = ibin[src * 3 + 1]; - ibout[j * 3 + 2] = ibin[src * 3 + 2]; - - if (adjin && adjout) - { - adjout[j * 3] = adjin[src * 3]; - adjout[j * 3 + 1] = adjin[src * 3 + 1]; - adjout[j * 3 + 2] = adjin[src * 3 + 2]; - } - } - else - return E_FAIL; - } - - return S_OK; - } - -#pragma warning(pop) - - - //--------------------------------------------------------------------------------- - template - HRESULT SwapFaces( - _Inout_updates_all_(nFaces * 3) index_t* ib, _In_ size_t nFaces, - _Inout_updates_all_opt_(nFaces * 3) uint32_t* adj, - _In_reads_(nFaces) const uint32_t* faceRemap) noexcept - { - assert(ib != nullptr && faceRemap != nullptr); - _Analysis_assume_(ib != nullptr && faceRemap != nullptr); - - std::unique_ptr temp(new (std::nothrow) uint8_t[(sizeof(bool) + sizeof(uint32_t)) * nFaces]); - if (!temp) - return E_OUTOFMEMORY; - - auto faceRemapInverse = reinterpret_cast(temp.get()); - - memset(faceRemapInverse, 0xff, sizeof(uint32_t) * nFaces); - - for (uint32_t j = 0; j < nFaces; ++j) - { - if (faceRemap[j] != UNUSED32) - { - if (faceRemap[j] >= nFaces) - return E_UNEXPECTED; - - faceRemapInverse[faceRemap[j]] = j; - } - } - - auto moved = reinterpret_cast(temp.get() + sizeof(uint32_t) * nFaces); - - memset(moved, 0, sizeof(bool) * nFaces); - - for (size_t j = 0; j < nFaces; ++j) - { - if (moved[j]) - continue; - - uint32_t dest = faceRemapInverse[j]; - - if (dest == UNUSED32) - continue; - - if (dest >= nFaces) - return E_FAIL; - - while (dest != j) - { - // Swap face - index_t i0 = ib[dest * 3]; - index_t i1 = ib[dest * 3 + 1]; - index_t i2 = ib[dest * 3 + 2]; - - ib[dest * 3] = ib[j * 3]; - ib[dest * 3 + 1] = ib[j * 3 + 1]; - ib[dest * 3 + 2] = ib[j * 3 + 2]; - - ib[j * 3] = i0; - ib[j * 3 + 1] = i1; - ib[j * 3 + 2] = i2; - - if (adj) - { - const uint32_t a0 = adj[dest * 3]; - const uint32_t a1 = adj[dest * 3 + 1]; - const uint32_t a2 = adj[dest * 3 + 2]; - - adj[dest * 3] = adj[j * 3]; - adj[dest * 3 + 1] = adj[j * 3 + 1]; - adj[dest * 3 + 2] = adj[j * 3 + 2]; - - adj[j * 3] = a0; - adj[j * 3 + 1] = a1; - adj[j * 3 + 2] = a2; - } - - moved[dest] = true; - - dest = faceRemapInverse[dest]; - - if (dest == UNUSED32 || moved[dest]) - break; - - if (dest >= nFaces) - return E_FAIL; - } - } - - return S_OK; - } - - - //--------------------------------------------------------------------------------- - HRESULT SwapVertices( - _Inout_updates_bytes_all_(nVerts*stride) void* vb, size_t stride, size_t nVerts, - _Inout_updates_all_opt_(nVerts) uint32_t* pointRep, _In_reads_(nVerts) const uint32_t* vertexRemap) noexcept - { - if (!vb || !stride || !nVerts || !vertexRemap) - return E_INVALIDARG; - - if (stride > c_MaxStride) - return E_INVALIDARG; - - std::unique_ptr temp(new (std::nothrow) uint8_t[((sizeof(bool) + sizeof(uint32_t)) * nVerts) + stride]); - if (!temp) - return E_OUTOFMEMORY; - - auto vertexRemapInverse = reinterpret_cast(temp.get()); - - memset(vertexRemapInverse, 0xff, sizeof(uint32_t) * nVerts); - - for (uint32_t j = 0; j < nVerts; ++j) - { - if (vertexRemap[j] != UNUSED32) - { - if (vertexRemap[j] >= nVerts) - return E_UNEXPECTED; - - vertexRemapInverse[vertexRemap[j]] = j; - } - } - - auto moved = reinterpret_cast(temp.get() + sizeof(uint32_t) * nVerts); - memset(moved, 0, sizeof(bool) * nVerts); - - auto vbtemp = temp.get() + ((sizeof(bool) + sizeof(uint32_t)) * nVerts); - - auto ptr = static_cast(vb); - - for (size_t j = 0; j < nVerts; ++j) - { - if (moved[j]) - continue; - - uint32_t dest = vertexRemapInverse[j]; - - if (dest == UNUSED32) - continue; - - if (dest >= nVerts) - return E_UNEXPECTED; - - bool next = false; - - while (dest != j) - { - // Swap vertex - #ifdef _PREFAST_ - #pragma prefast(push) - #pragma prefast(disable : 26019, "PREfast noise: Esp:1307") - #endif - memcpy(vbtemp, ptr + dest*stride, stride); - memcpy(ptr + dest*stride, ptr + j*stride, stride); - memcpy(ptr + j*stride, vbtemp, stride); - #ifdef _PREFAST_ - #pragma prefast(pop) - #endif - - if (pointRep) - { - std::swap(pointRep[dest], pointRep[j]); - // Remap - const uint32_t pr = pointRep[dest]; - if (pr < nVerts) - { - pointRep[dest] = vertexRemapInverse[pr]; - } - } - - moved[dest] = true; - - dest = vertexRemapInverse[dest]; - - if (dest == UNUSED32 || moved[dest]) - { - next = true; - break; - } - - if (dest >= nVerts) - return E_FAIL; - } - - if (next) - continue; - - if (pointRep) - { - // Remap - const uint32_t pr = pointRep[j]; - if (pr < nVerts) - { - pointRep[j] = vertexRemapInverse[pr]; - } - } - } - - return S_OK; - } - - - //--------------------------------------------------------------------------------- - template - HRESULT FinalizeIBImpl( - _In_reads_(nFaces * 3) const index_t* ibin, size_t nFaces, - _In_reads_(nVerts) const uint32_t* vertexRemap, size_t nVerts, - _Out_writes_(nFaces * 3) index_t* ibout) noexcept - { - if (!ibin || !nFaces || !vertexRemap || !nVerts || !ibout) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - if (nVerts >= index_t(-1)) - return E_INVALIDARG; - - std::unique_ptr vertexRemapInverse(new (std::nothrow) uint32_t[nVerts]); - if (!vertexRemapInverse) - return E_OUTOFMEMORY; - - memset(vertexRemapInverse.get(), 0xff, sizeof(uint32_t) * nVerts); - - for (uint32_t j = 0; j < nVerts; ++j) - { - if (vertexRemap[j] != UNUSED32) - { - if (vertexRemap[j] >= nVerts) - return E_UNEXPECTED; - - vertexRemapInverse[vertexRemap[j]] = j; - } - } - - for (size_t j = 0; j < (nFaces * 3); ++j) - { - index_t i = ibin[j]; - if (i == index_t(-1)) - { - ibout[j] = index_t(-1); - continue; - } - - if (i >= nVerts) - return E_UNEXPECTED; - - const uint32_t dest = vertexRemapInverse[i]; - if (dest == UNUSED32) - { - ibout[j] = i; - continue; - } - - if (dest < nVerts) - { - ibout[j] = index_t(dest); - } - else - return E_FAIL; - } - - return S_OK; - } - - - //--------------------------------------------------------------------------------- - template - HRESULT FinalizeIBImpl( - _Inout_updates_all_(nFaces * 3) index_t* ib, size_t nFaces, - _In_reads_(nVerts) const uint32_t* vertexRemap, size_t nVerts) noexcept - { - if (!ib || !nFaces || !vertexRemap || !nVerts) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - if (nVerts >= index_t(-1)) - return E_INVALIDARG; - - std::unique_ptr vertexRemapInverse(new (std::nothrow) uint32_t[nVerts]); - if (!vertexRemapInverse) - return E_OUTOFMEMORY; - - memset(vertexRemapInverse.get(), 0xff, sizeof(uint32_t) * nVerts); - - for (uint32_t j = 0; j < nVerts; ++j) - { - if (vertexRemap[j] != UNUSED32) - { - if (vertexRemap[j] >= nVerts) - return E_UNEXPECTED; - - vertexRemapInverse[vertexRemap[j]] = j; - } - } - - for (size_t j = 0; j < (nFaces * 3); ++j) - { - index_t i = ib[j]; - if (i == index_t(-1)) - continue; - - if (i >= nVerts) - return E_UNEXPECTED; - - const uint32_t dest = vertexRemapInverse[i]; - if (dest == UNUSED32) - continue; - - if (dest < nVerts) - { - ib[j] = index_t(dest); - } - else - return E_FAIL; - } - - return S_OK; - } -} - -//===================================================================================== -// Entry-points -//===================================================================================== - -//------------------------------------------------------------------------------------- -// Applies a face remap reordering to an index buffer -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::ReorderIB( - const uint16_t* ibin, - size_t nFaces, - const uint32_t* faceRemap, - uint16_t* ibout) noexcept -{ - if (!ibin || !nFaces || !faceRemap || !ibout) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - if (ibin == ibout) - return HRESULT_E_NOT_SUPPORTED; - - return ReorderFaces(ibin, nFaces, nullptr, faceRemap, ibout, nullptr); -} - -_Use_decl_annotations_ -HRESULT DirectX::ReorderIB( - uint16_t* ib, - size_t nFaces, - const uint32_t* faceRemap) noexcept -{ - if (!ib || !nFaces || !faceRemap) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - return SwapFaces(ib, nFaces, nullptr, faceRemap); -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::ReorderIB( - const uint32_t* ibin, - size_t nFaces, - const uint32_t* faceRemap, - uint32_t* ibout) noexcept -{ - if (!ibin || !nFaces || !faceRemap || !ibout) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - if (ibin == ibout) - return HRESULT_E_NOT_SUPPORTED; - - return ReorderFaces(ibin, nFaces, nullptr, faceRemap, ibout, nullptr); -} - -_Use_decl_annotations_ -HRESULT DirectX::ReorderIB( - uint32_t* ib, - size_t nFaces, - const uint32_t* faceRemap) noexcept -{ - if (!ib || !nFaces || !faceRemap) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - return SwapFaces(ib, nFaces, nullptr, faceRemap); -} - - -//------------------------------------------------------------------------------------- -// Applies a face remap reordering to an index buffer and adjacency -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::ReorderIBAndAdjacency( - const uint16_t* ibin, - size_t nFaces, - const uint32_t* adjin, - const uint32_t* faceRemap, - uint16_t* ibout, - uint32_t* adjout) noexcept -{ - if (!ibin || !nFaces || !adjin || !faceRemap || !ibout || !adjout) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - if ((ibin == ibout) || (adjin == adjout)) - return HRESULT_E_NOT_SUPPORTED; - - return ReorderFaces(ibin, nFaces, adjin, faceRemap, ibout, adjout); -} - -_Use_decl_annotations_ -HRESULT DirectX::ReorderIBAndAdjacency( - uint16_t* ib, - size_t nFaces, - uint32_t* adj, - const uint32_t* faceRemap) noexcept -{ - if (!ib || !nFaces || !adj || !faceRemap) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - return SwapFaces(ib, nFaces, adj, faceRemap); -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::ReorderIBAndAdjacency( - const uint32_t* ibin, - size_t nFaces, - const uint32_t* adjin, - const uint32_t* faceRemap, - uint32_t* ibout, - uint32_t* adjout) noexcept -{ - if (!ibin || !nFaces || !adjin || !faceRemap || !ibout || !adjout) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - if ((ibin == ibout) || (adjin == adjout)) - return HRESULT_E_NOT_SUPPORTED; - - return ReorderFaces(ibin, nFaces, adjin, faceRemap, ibout, adjout); -} - -_Use_decl_annotations_ -HRESULT DirectX::ReorderIBAndAdjacency( - uint32_t* ib, - size_t nFaces, - uint32_t* adj, - const uint32_t* faceRemap) noexcept -{ - if (!ib || !nFaces || !adj || !faceRemap) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - return SwapFaces(ib, nFaces, adj, faceRemap); -} - - -//------------------------------------------------------------------------------------- -// Applies a vertex remap, filling out a new index buffer -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::FinalizeIB( - const uint16_t* ibin, - size_t nFaces, - const uint32_t* vertexRemap, - size_t nVerts, - uint16_t* ibout) noexcept -{ - return FinalizeIBImpl(ibin, nFaces, vertexRemap, nVerts, ibout); -} - -_Use_decl_annotations_ -HRESULT DirectX::FinalizeIB( - uint16_t* ib, - size_t nFaces, - const uint32_t* vertexRemap, - size_t nVerts) noexcept -{ - return FinalizeIBImpl(ib, nFaces, vertexRemap, nVerts); -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::FinalizeIB( - const uint32_t* ibin, - size_t nFaces, - const uint32_t* vertexRemap, - size_t nVerts, - uint32_t* ibout) noexcept -{ - return FinalizeIBImpl(ibin, nFaces, vertexRemap, nVerts, ibout); -} - -_Use_decl_annotations_ -HRESULT DirectX::FinalizeIB( - uint32_t* ib, - size_t nFaces, - const uint32_t* vertexRemap, - size_t nVerts) noexcept -{ - return FinalizeIBImpl(ib, nFaces, vertexRemap, nVerts); -} - - -//------------------------------------------------------------------------------------- -// Applies a vertex remap and/or a vertex duplication set to a vertex buffer -//------------------------------------------------------------------------------------- -#pragma warning(push) -#pragma warning( disable : 6101 ) - -_Use_decl_annotations_ -HRESULT DirectX::FinalizeVB( - const void* vbin, - size_t stride, - size_t nVerts, - const uint32_t* dupVerts, - size_t nDupVerts, - const uint32_t* vertexRemap, - void* vbout) noexcept -{ - if (!vbin || !stride || !nVerts || !vbout) - return E_INVALIDARG; - - if (!dupVerts && !vertexRemap) - return E_INVALIDARG; - - if (dupVerts && !nDupVerts) - return E_INVALIDARG; - - if (!dupVerts && nDupVerts > 0) - return E_INVALIDARG; - - if (nVerts >= UINT32_MAX) - return E_INVALIDARG; - - if (stride > c_MaxStride) - return E_INVALIDARG; - - if ((uint64_t(nVerts) + uint64_t(nDupVerts)) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - if (vbin == vbout) - return HRESULT_E_NOT_SUPPORTED; - - const size_t newVerts = nVerts + nDupVerts; - - auto sptr = static_cast(vbin); - auto dptr = static_cast(vbout); - -#ifdef _DEBUG - memset(vbout, 0, newVerts * stride); -#endif - - for (size_t j = 0; j < newVerts; ++j) - { - const uint32_t src = (vertexRemap) ? vertexRemap[j] : uint32_t(j); - - if (src == UNUSED32) - { - // remap entry is unused - } - else if (src >= newVerts) - { - return E_FAIL; - } - else if (src < nVerts) - { - memcpy(dptr, sptr + src * stride, stride); - } - else if (dupVerts) - { - const uint32_t dup = dupVerts[src - nVerts]; - memcpy(dptr, sptr + dup * stride, stride); - } - else - return E_FAIL; - - dptr += stride; - } - - return S_OK; -} - -#pragma warning(pop) - -_Use_decl_annotations_ -HRESULT DirectX::FinalizeVB( - void* vb, - size_t stride, - size_t nVerts, - const uint32_t* vertexRemap) noexcept -{ - if (nVerts >= UINT32_MAX) - return E_INVALIDARG; - - return SwapVertices(vb, stride, nVerts, nullptr, vertexRemap); -} - - -//------------------------------------------------------------------------------------- -// Applies a vertex remap and/or a vertex duplication set to a vertex buffer and -// point representatives -//------------------------------------------------------------------------------------- -#pragma warning(push) -#pragma warning( disable : 6101 ) - -_Use_decl_annotations_ -HRESULT DirectX::FinalizeVBAndPointReps( - const void* vbin, - size_t stride, - size_t nVerts, - const uint32_t* prin, - const uint32_t* dupVerts, - size_t nDupVerts, - const uint32_t* vertexRemap, - void* vbout, - uint32_t* prout) noexcept -{ - if (!vbin || !stride || !nVerts || !prin || !vbout || !prout) - return E_INVALIDARG; - - if (!dupVerts && !vertexRemap) - return E_INVALIDARG; - - if (dupVerts && !nDupVerts) - return E_INVALIDARG; - - if (!dupVerts && nDupVerts > 0) - return E_INVALIDARG; - - if (nVerts >= UINT32_MAX) - return E_INVALIDARG; - - if (stride > c_MaxStride) - return E_INVALIDARG; - - if ((uint64_t(nVerts) + uint64_t(nDupVerts)) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - if (vbin == vbout) - return HRESULT_E_NOT_SUPPORTED; - - const size_t newVerts = nVerts + nDupVerts; - - std::unique_ptr vertexRemapInverse; - if (vertexRemap) - { - vertexRemapInverse.reset(new (std::nothrow) uint32_t[newVerts]); - if (!vertexRemapInverse) - return E_OUTOFMEMORY; - - memset(vertexRemapInverse.get(), 0xff, sizeof(uint32_t) * newVerts); - - for (uint32_t j = 0; j < newVerts; ++j) - { - if (vertexRemap[j] != UNUSED32) - { - if (vertexRemap[j] >= newVerts) - return E_INVALIDARG; - - vertexRemapInverse[vertexRemap[j]] = j; - } - } - } - - auto sptr = static_cast(vbin); - auto dptr = static_cast(vbout); - -#ifdef _DEBUG - memset(vbout, 0, newVerts * stride); -#endif - - std::unique_ptr pointRep(new (std::nothrow) uint32_t[nVerts + nDupVerts]); - if (!pointRep) - return E_OUTOFMEMORY; - - memcpy(pointRep.get(), prin, sizeof(uint32_t) * nVerts); - - for (size_t i = 0; i < nDupVerts; ++i) - { - pointRep[i + nVerts] = prin[dupVerts[i]]; - } - - for (size_t j = 0; j < newVerts; ++j) - { - const uint32_t src = (vertexRemap) ? vertexRemap[j] : uint32_t(j); - - if (src == UNUSED32) - { - // remap entry is unused - } - else if (src >= newVerts) - { - return E_FAIL; - } - else if (src < nVerts) - { - memcpy(dptr, sptr + src * stride, stride); - - const uint32_t pr = pointRep[src]; - if (pr < newVerts) - { - prout[j] = (vertexRemapInverse) ? vertexRemapInverse[pr] : pr; - } - } - else if (dupVerts) - { - const uint32_t dup = dupVerts[src - nVerts]; - memcpy(dptr, sptr + dup * stride, stride); - - const uint32_t pr = pointRep[src]; - if (pr < newVerts) - { - prout[j] = (vertexRemapInverse) ? vertexRemapInverse[pr] : pr; - } - } - else - return E_FAIL; - - dptr += stride; - } - - if (vertexRemap) - { - // clean up point reps for any removed vertices - for (uint32_t i = 0; i < newVerts; ++i) - { - if (vertexRemap[i] == UNUSED32) - { - pointRep[i] = UNUSED32; - } - } - } - - return S_OK; -} - -#pragma warning(pop) - -_Use_decl_annotations_ -HRESULT DirectX::FinalizeVBAndPointReps( - void* vb, - size_t stride, - size_t nVerts, - uint32_t* pointRep, - const uint32_t* vertexRemap) noexcept -{ - if (nVerts >= UINT32_MAX) - return E_INVALIDARG; - - if (!pointRep || !vertexRemap) - return E_INVALIDARG; - - HRESULT hr = SwapVertices(vb, stride, nVerts, pointRep, vertexRemap); - - // clean up point reps for any removed vertices - for (uint32_t i = 0; i < nVerts; ++i) - { - if (vertexRemap[i] == UNUSED32) - { - pointRep[i] = UNUSED32; - } - } - - return hr; -} - - -//------------------------------------------------------------------------------------- -// Applies a vertex remap which contains a known number of unused entries at the end -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::CompactVB( - const void* vbin, - size_t stride, - size_t nVerts, - size_t trailingUnused, - const uint32_t* vertexRemap, - void* vbout) noexcept -{ - if (!vbin || !stride || !nVerts || !vbout || !vertexRemap) - return E_INVALIDARG; - - if (nVerts >= UINT32_MAX || trailingUnused >= UINT32_MAX) - return E_INVALIDARG; - - if (stride > c_MaxStride) - return E_INVALIDARG; - - if (trailingUnused >= nVerts) - return E_INVALIDARG; - - if (vbin == vbout) - return HRESULT_E_NOT_SUPPORTED; - - const size_t newVerts = nVerts - trailingUnused; - - auto sptr = static_cast(vbin); - auto dptr = static_cast(vbout); - -#ifdef _DEBUG - memset(vbout, 0, newVerts * stride); -#endif - - for (size_t j = 0; j < newVerts; ++j) - { - const uint32_t src = vertexRemap[j]; - - if (src == UNUSED32) - { - // remap entry is unused - } - else if (src < nVerts) - { - memcpy(dptr, sptr + src * stride, stride); - } - else - return E_FAIL; - - dptr += stride; - } - - return S_OK; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshTangentFrame.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshTangentFrame.cpp deleted file mode 100644 index a438d95..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshTangentFrame.cpp +++ /dev/null @@ -1,300 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXMeshTangentFrame.cpp -// -// DirectX Mesh Geometry Library - Normals, Tangents, and Bi-Tangents Computation -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkID=324981 -//------------------------------------------------------------------------------------- - -#include "DirectXMeshP.h" - -using namespace DirectX; - -namespace -{ - //--------------------------------------------------------------------------------- - // Compute tangent and bi-tangent for each vertex - //--------------------------------------------------------------------------------- - template - HRESULT ComputeTangentFrameImpl( - _In_reads_(nFaces * 3) const index_t* indices, size_t nFaces, - _In_reads_(nVerts) const XMFLOAT3* positions, - _In_reads_(nVerts) const XMFLOAT3* normals, - _In_reads_(nVerts) const XMFLOAT2* texcoords, - size_t nVerts, - _Out_writes_opt_(nVerts) XMFLOAT3* tangents3, - _Out_writes_opt_(nVerts) XMFLOAT4* tangents4, - _Out_writes_opt_(nVerts) XMFLOAT3* bitangents) noexcept - { - if (!indices || !nFaces || !positions || !normals || !texcoords || !nVerts) - return E_INVALIDARG; - - if (nVerts >= index_t(-1)) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - static constexpr float EPSILON = 0.0001f; - static const XMVECTORF32 s_flips = { { { 1.f, -1.f, -1.f, 1.f } } }; - - auto temp = make_AlignedArrayXMVECTOR(uint64_t(nVerts) * 2); - if (!temp) - return E_OUTOFMEMORY; - - memset(temp.get(), 0, sizeof(XMVECTOR) * nVerts * 2); - - XMVECTOR* tangent1 = temp.get(); - XMVECTOR* tangent2 = temp.get() + nVerts; - - for (size_t face = 0; face < nFaces; ++face) - { - index_t i0 = indices[face * 3]; - index_t i1 = indices[face * 3 + 1]; - index_t i2 = indices[face * 3 + 2]; - - if (i0 == index_t(-1) - || i1 == index_t(-1) - || i2 == index_t(-1)) - continue; - - if (i0 >= nVerts - || i1 >= nVerts - || i2 >= nVerts) - return E_UNEXPECTED; - - const XMVECTOR t0 = XMLoadFloat2(&texcoords[i0]); - const XMVECTOR t1 = XMLoadFloat2(&texcoords[i1]); - const XMVECTOR t2 = XMLoadFloat2(&texcoords[i2]); - - XMVECTOR s = XMVectorMergeXY(XMVectorSubtract(t1, t0), XMVectorSubtract(t2, t0)); - - XMFLOAT4A tmp; - XMStoreFloat4A(&tmp, s); - - float d = tmp.x * tmp.w - tmp.z * tmp.y; - d = (fabsf(d) <= EPSILON) ? 1.f : (1.f / d); - s = XMVectorScale(s, d); - s = XMVectorMultiply(s, s_flips); - - XMMATRIX m0; - m0.r[0] = XMVectorPermute<3, 2, 6, 7>(s, g_XMZero); - m0.r[1] = XMVectorPermute<1, 0, 4, 5>(s, g_XMZero); - m0.r[2] = m0.r[3] = g_XMZero; - - const XMVECTOR p0 = XMLoadFloat3(&positions[i0]); - const XMVECTOR p1 = XMLoadFloat3(&positions[i1]); - XMVECTOR p2 = XMLoadFloat3(&positions[i2]); - - XMMATRIX m1; - m1.r[0] = XMVectorSubtract(p1, p0); - m1.r[1] = XMVectorSubtract(p2, p0); - m1.r[2] = m1.r[3] = g_XMZero; - - const XMMATRIX uv = XMMatrixMultiply(m0, m1); - - tangent1[i0] = XMVectorAdd(tangent1[i0], uv.r[0]); - tangent1[i1] = XMVectorAdd(tangent1[i1], uv.r[0]); - tangent1[i2] = XMVectorAdd(tangent1[i2], uv.r[0]); - - tangent2[i0] = XMVectorAdd(tangent2[i0], uv.r[1]); - tangent2[i1] = XMVectorAdd(tangent2[i1], uv.r[1]); - tangent2[i2] = XMVectorAdd(tangent2[i2], uv.r[1]); - } - - for (size_t j = 0; j < nVerts; ++j) - { - // Gram-Schmidt orthonormalization - XMVECTOR b0 = XMLoadFloat3(&normals[j]); - b0 = XMVector3Normalize(b0); - - const XMVECTOR tan1 = tangent1[j]; - XMVECTOR b1 = XMVectorSubtract(tan1, XMVectorMultiply(XMVector3Dot(b0, tan1), b0)); - b1 = XMVector3Normalize(b1); - - const XMVECTOR tan2 = tangent2[j]; - XMVECTOR b2 = XMVectorSubtract(XMVectorSubtract(tan2, XMVectorMultiply(XMVector3Dot(b0, tan2), b0)), XMVectorMultiply(XMVector3Dot(b1, tan2), b1)); - b2 = XMVector3Normalize(b2); - - // handle degenerate vectors - const float len1 = XMVectorGetX(XMVector3Length(b1)); - const float len2 = XMVectorGetY(XMVector3Length(b2)); - - if ((len1 <= EPSILON) || (len2 <= EPSILON)) - { - if (len1 > 0.5f) - { - // Reset bi-tangent from tangent and normal - b2 = XMVector3Cross(b0, b1); - } - else if (len2 > 0.5f) - { - // Reset tangent from bi-tangent and normal - b1 = XMVector3Cross(b2, b0); - } - else - { - // Reset both tangent and bi-tangent from normal - XMVECTOR axis; - - const float d0 = fabsf(XMVectorGetX(XMVector3Dot(g_XMIdentityR0, b0))); - const float d1 = fabsf(XMVectorGetX(XMVector3Dot(g_XMIdentityR1, b0))); - const float d2 = fabsf(XMVectorGetX(XMVector3Dot(g_XMIdentityR2, b0))); - if (d0 < d1) - { - axis = (d0 < d2) ? g_XMIdentityR0 : g_XMIdentityR2; - } - else if (d1 < d2) - { - axis = g_XMIdentityR1; - } - else - { - axis = g_XMIdentityR2; - } - - b1 = XMVector3Cross(b0, axis); - b2 = XMVector3Cross(b0, b1); - } - } - - if (tangents3) - { - XMStoreFloat3(&tangents3[j], b1); - } - - if (tangents4) - { - XMVECTOR bi = XMVector3Cross(b0, tan1); - const float w = XMVector3Less(XMVector3Dot(bi, tan2), g_XMZero) ? -1.f : 1.f; - - bi = XMVectorSetW(b1, w); - XMStoreFloat4(&tangents4[j], bi); - } - - if (bitangents) - { - XMStoreFloat3(&bitangents[j], b2); - } - } - - return S_OK; - } -} - -//===================================================================================== -// Entry-points -//===================================================================================== - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::ComputeTangentFrame( - const uint16_t* indices, - size_t nFaces, - const XMFLOAT3* positions, - const XMFLOAT3* normals, - const XMFLOAT2* texcoords, - size_t nVerts, - XMFLOAT3* tangents, - XMFLOAT3* bitangents) noexcept -{ - if (!tangents && !bitangents) - return E_INVALIDARG; - - return ComputeTangentFrameImpl(indices, nFaces, positions, normals, texcoords, nVerts, tangents, nullptr, bitangents); -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::ComputeTangentFrame( - const uint32_t* indices, - size_t nFaces, - const XMFLOAT3* positions, - const XMFLOAT3* normals, const XMFLOAT2* texcoords, - size_t nVerts, - XMFLOAT3* tangents, - XMFLOAT3* bitangents) noexcept -{ - if (!tangents && !bitangents) - return E_INVALIDARG; - - return ComputeTangentFrameImpl(indices, nFaces, positions, normals, texcoords, nVerts, tangents, nullptr, bitangents); -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::ComputeTangentFrame( - const uint16_t* indices, - size_t nFaces, - const XMFLOAT3* positions, - const XMFLOAT3* normals, - const XMFLOAT2* texcoords, - size_t nVerts, - XMFLOAT4* tangents, - XMFLOAT3* bitangents) noexcept -{ - if (!tangents && !bitangents) - return E_INVALIDARG; - - return ComputeTangentFrameImpl(indices, nFaces, positions, normals, texcoords, nVerts, nullptr, tangents, bitangents); -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::ComputeTangentFrame( - const uint32_t* indices, - size_t nFaces, - const XMFLOAT3* positions, - const XMFLOAT3* normals, - const XMFLOAT2* texcoords, - size_t nVerts, - XMFLOAT4* tangents, - XMFLOAT3* bitangents) noexcept -{ - if (!tangents && !bitangents) - return E_INVALIDARG; - - return ComputeTangentFrameImpl(indices, nFaces, positions, normals, texcoords, nVerts, nullptr, tangents, bitangents); -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::ComputeTangentFrame( - const uint16_t* indices, - size_t nFaces, - const XMFLOAT3* positions, - const XMFLOAT3* normals, - const XMFLOAT2* texcoords, - size_t nVerts, - XMFLOAT4* tangents) noexcept -{ - if (!tangents) - return E_INVALIDARG; - - return ComputeTangentFrameImpl(indices, nFaces, positions, normals, texcoords, nVerts, nullptr, tangents, nullptr); -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::ComputeTangentFrame( - const uint32_t* indices, - size_t nFaces, - const XMFLOAT3* positions, - const XMFLOAT3* normals, - const XMFLOAT2* texcoords, - size_t nVerts, - XMFLOAT4* tangents) noexcept -{ - if (!tangents) - return E_INVALIDARG; - - return ComputeTangentFrameImpl(indices, nFaces, positions, normals, texcoords, nVerts, nullptr, tangents, nullptr); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshUtil.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshUtil.cpp deleted file mode 100644 index 83890b4..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshUtil.cpp +++ /dev/null @@ -1,518 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXMeshUtil.cpp -// -// DirectX Mesh Geometry Library - Utilities -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkID=324981 -//------------------------------------------------------------------------------------- - -#include "DirectXMeshP.h" - -using namespace DirectX; - -#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX) -static_assert(XBOX_DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM == DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM, "Xbox mismatch detected"); -#endif - -//===================================================================================== -// DXGI Format Utilities -//===================================================================================== - -//------------------------------------------------------------------------------------- -// Returns bytes-per-element for a given DXGI format, or 0 on failure -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -size_t DirectX::BytesPerElement(DXGI_FORMAT fmt) noexcept -{ - // This list only includes those formats that are valid for use by IB or VB - - switch (static_cast(fmt)) - { - case DXGI_FORMAT_R32G32B32A32_FLOAT: - case DXGI_FORMAT_R32G32B32A32_UINT: - case DXGI_FORMAT_R32G32B32A32_SINT: - return 16; - - case DXGI_FORMAT_R32G32B32_FLOAT: - case DXGI_FORMAT_R32G32B32_UINT: - case DXGI_FORMAT_R32G32B32_SINT: - return 12; - - case DXGI_FORMAT_R16G16B16A16_FLOAT: - case DXGI_FORMAT_R16G16B16A16_UNORM: - case DXGI_FORMAT_R16G16B16A16_UINT: - case DXGI_FORMAT_R16G16B16A16_SNORM: - case DXGI_FORMAT_R16G16B16A16_SINT: - case DXGI_FORMAT_R32G32_FLOAT: - case DXGI_FORMAT_R32G32_UINT: - case DXGI_FORMAT_R32G32_SINT: - return 8; - - case DXGI_FORMAT_R10G10B10A2_UNORM: - case DXGI_FORMAT_R10G10B10A2_UINT: - case DXGI_FORMAT_R11G11B10_FLOAT: - case DXGI_FORMAT_R8G8B8A8_UNORM: - case DXGI_FORMAT_R8G8B8A8_UINT: - case DXGI_FORMAT_R8G8B8A8_SNORM: - case DXGI_FORMAT_R8G8B8A8_SINT: - case DXGI_FORMAT_R16G16_FLOAT: - case DXGI_FORMAT_R16G16_UNORM: - case DXGI_FORMAT_R16G16_UINT: - case DXGI_FORMAT_R16G16_SNORM: - case DXGI_FORMAT_R16G16_SINT: - case DXGI_FORMAT_R32_FLOAT: - case DXGI_FORMAT_R32_UINT: - case DXGI_FORMAT_R32_SINT: - case DXGI_FORMAT_B8G8R8A8_UNORM: - case DXGI_FORMAT_B8G8R8X8_UNORM: - case XBOX_DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM: - return 4; - - case DXGI_FORMAT_R8G8_UNORM: - case DXGI_FORMAT_R8G8_UINT: - case DXGI_FORMAT_R8G8_SNORM: - case DXGI_FORMAT_R8G8_SINT: - case DXGI_FORMAT_R16_FLOAT: - case DXGI_FORMAT_R16_UNORM: - case DXGI_FORMAT_R16_UINT: - case DXGI_FORMAT_R16_SNORM: - case DXGI_FORMAT_R16_SINT: - case DXGI_FORMAT_B5G6R5_UNORM: - case DXGI_FORMAT_B5G5R5A1_UNORM: - return 2; - - case DXGI_FORMAT_R8_UNORM: - case DXGI_FORMAT_R8_UINT: - case DXGI_FORMAT_R8_SNORM: - case DXGI_FORMAT_R8_SINT: - return 1; - - case DXGI_FORMAT_B4G4R4A4_UNORM: - return 2; - - default: - // No BC, sRGB, XRBias, SharedExp, Typeless, Depth, or Video formats - return 0; - } -} - - -//===================================================================================== -// Input Layout Descriptor Utilities -//===================================================================================== - -//------------------------------------------------------------------------------------- -// Validates a Direct3D Input Layout -//------------------------------------------------------------------------------------- - -#if defined(__d3d11_h__) || defined(__d3d11_x_h__) -_Use_decl_annotations_ -bool DirectX::IsValid(const D3D11_INPUT_ELEMENT_DESC* vbDecl, size_t nDecl) noexcept -{ - if (!vbDecl || !nDecl) - { - // Note that 0 is allowed by the runtime for degenerate cases, but is not defined for DirectXMesh - return false; - } - - if (nDecl > 32 /* D3D11_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT */) - { - // The upper-limit depends on feature level, so we assume highest value here - return false; - } - - for (size_t j = 0; j < nDecl; ++j) - { - const size_t bpe = BytesPerElement(vbDecl[j].Format); - if (!bpe) - { - // Not a valid DXGI format or it's not valid for VB usage - return false; - } - - uint32_t alignment; - - if (bpe == 1) - alignment = 1; - else if (bpe == 2) - alignment = 2; - else - alignment = 4; - - if ((vbDecl[j].AlignedByteOffset != D3D11_APPEND_ALIGNED_ELEMENT) - && (vbDecl[j].AlignedByteOffset % alignment) != 0) - { - // Invalid alignment for element - return false; - } - - if (vbDecl[j].InputSlot >= D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT) - { - // The upper-limit depends on feature level, so we assume highest value here - return false; - } - - switch (vbDecl[j].InputSlotClass) - { - case D3D11_INPUT_PER_VERTEX_DATA: - if (vbDecl[j].InstanceDataStepRate != 0) - { - return false; - } - break; - - case D3D11_INPUT_PER_INSTANCE_DATA: - break; - - default: - return false; - } - - if (!vbDecl[j].SemanticName) - { - return false; - } - - // Debug layer also checks for trailing digit in the semantic name, and checks - // for inconsistent semantic name/slot assignment. - } - - return true; -} -#endif - -#if defined(__d3d12_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__) -bool DirectX::IsValid(const D3D12_INPUT_LAYOUT_DESC& vbDecl) noexcept -{ - if (!vbDecl.pInputElementDescs || !vbDecl.NumElements) - { - // Note that 0 is allowed by the runtime for degenerate cases, but is not defined for DirectXMesh - return false; - } - - if (vbDecl.NumElements > D3D12_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT) - { - return false; - } - - for (size_t j = 0; j < vbDecl.NumElements; ++j) - { - size_t bpe = BytesPerElement(vbDecl.pInputElementDescs[j].Format); - if (!bpe) - { - // Not a valid DXGI format or it's not valid for VB usage - return false; - } - - uint32_t alignment; - - if (bpe == 1) - alignment = 1; - else if (bpe == 2) - alignment = 2; - else - alignment = 4; - - if ((vbDecl.pInputElementDescs[j].AlignedByteOffset != D3D12_APPEND_ALIGNED_ELEMENT) - && (vbDecl.pInputElementDescs[j].AlignedByteOffset % alignment) != 0) - { - // Invalid alignment for element - return false; - } - - if (vbDecl.pInputElementDescs[j].InputSlot >= D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT) - { - // The upper-limit depends on feature level, so we assume highest value here - return false; - } - - switch (vbDecl.pInputElementDescs[j].InputSlotClass) - { - case D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA: - if (vbDecl.pInputElementDescs[j].InstanceDataStepRate != 0) - { - return false; - } - break; - - case D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA: - break; - - default: - return false; - } - - if (!vbDecl.pInputElementDescs[j].SemanticName) - { - return false; - } - - // Debug layer also checks for trailing digit in the semantic name, and checks - // for inconsistent semantic name/slot assignment. - } - - return true; -} -#endif - -//------------------------------------------------------------------------------------- -// Compute the offsets to each element, and total stride of each slot -//------------------------------------------------------------------------------------- - -#if defined(__d3d11_h__) || defined(__d3d11_x_h__) -_Use_decl_annotations_ -void DirectX::ComputeInputLayout( - const D3D11_INPUT_ELEMENT_DESC* vbDecl, size_t nDecl, - uint32_t* offsets, uint32_t* strides) noexcept -{ - assert(IsValid(vbDecl, nDecl)); - - if (offsets) - memset(offsets, 0, sizeof(uint32_t) * nDecl); - - if (strides) - memset(strides, 0, sizeof(uint32_t) * D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT); - - uint32_t prevABO[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT]; - memset(prevABO, 0, sizeof(uint32_t) * D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT); - - for (size_t j = 0; j < nDecl; ++j) - { - uint32_t slot = vbDecl[j].InputSlot; - if (slot >= D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT) - { - // ignore bad input slots - continue; - } - - const size_t bpe = BytesPerElement(vbDecl[j].Format); - if (!bpe) - { - // ignore invalid format - continue; - } - - uint32_t alignment; - - if (bpe == 1) - alignment = 1; - else if (bpe == 2) - alignment = 2; - else - alignment = 4; - - uint32_t alignedByteOffset = vbDecl[j].AlignedByteOffset; - - if (alignedByteOffset == D3D11_APPEND_ALIGNED_ELEMENT) - { - alignedByteOffset = prevABO[slot]; - } - - if (offsets) - { - offsets[j] = alignedByteOffset; - } - - if (strides) - { - const uint32_t istride = uint32_t(alignedByteOffset + bpe); - strides[slot] = std::max(strides[slot], istride); - } - - prevABO[slot] = uint32_t(alignedByteOffset + bpe + (bpe % alignment)); - } -} -#endif - -#if defined(__d3d12_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__) -_Use_decl_annotations_ -void DirectX::ComputeInputLayout(const D3D12_INPUT_LAYOUT_DESC& vbDecl, - uint32_t* offsets, uint32_t* strides) noexcept -{ - assert(IsValid(vbDecl)); - - if (offsets) - memset(offsets, 0, sizeof(uint32_t) * vbDecl.NumElements); - - if (strides) - memset(strides, 0, sizeof(uint32_t) * D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT); - - uint32_t prevABO[D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT] = {}; - - for (size_t j = 0; j < vbDecl.NumElements; ++j) - { - uint32_t slot = vbDecl.pInputElementDescs[j].InputSlot; - if (slot >= D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT) - { - // ignore bad input slots - continue; - } - - size_t bpe = BytesPerElement(vbDecl.pInputElementDescs[j].Format); - if (!bpe) - { - // ignore invalid format - continue; - } - - uint32_t alignment; - - if (bpe == 1) - alignment = 1; - else if (bpe == 2) - alignment = 2; - else - alignment = 4; - - uint32_t alignedByteOffset = vbDecl.pInputElementDescs[j].AlignedByteOffset; - - if (alignedByteOffset == D3D12_APPEND_ALIGNED_ELEMENT) - { - alignedByteOffset = prevABO[slot]; - } - - if (offsets) - { - offsets[j] = alignedByteOffset; - } - - if (strides) - { - uint32_t istride = uint32_t(alignedByteOffset + bpe); - strides[slot] = std::max(strides[slot], istride); - } - - prevABO[slot] = uint32_t(alignedByteOffset + bpe + (bpe % alignment)); - } -} -#endif - -//===================================================================================== -// Attribute Utilities -//===================================================================================== -_Use_decl_annotations_ -std::vector> DirectX::ComputeSubsets(const uint32_t* attributes, size_t nFaces) -{ - std::vector> subsets; - - if (!nFaces) - return subsets; - - if (!attributes) - { - subsets.emplace_back(std::pair(0u, nFaces)); - return subsets; - } - - uint32_t lastAttr = attributes[0]; - size_t offset = 0; - size_t count = 1; - - for (size_t j = 1; j < nFaces; ++j) - { - if (attributes[j] != lastAttr) - { - subsets.emplace_back(std::pair(offset, count)); - lastAttr = attributes[j]; - offset = j; - count = 1; - } - else - { - count += 1; - } - } - - if (count > 0) - { - subsets.emplace_back(std::pair(offset, count)); - } - - return subsets; -} - -//===================================================================================== -// Mesh Optimization Utilities -//===================================================================================== - -namespace -{ - template - void ComputeVertexCacheMissRateImpl( - _In_reads_(nFaces * 3) const index_t* indices, size_t nFaces, size_t nVerts, size_t cacheSize, - float& acmr, float& atvr) noexcept - { - acmr = -1.f; - atvr = -1.f; - - if (!indices || !nFaces || !nVerts || !cacheSize) - return; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return; - - if (nVerts >= index_t(-1)) - return; - - size_t misses = 0; - - std::unique_ptr fifo(new (std::nothrow) uint32_t[cacheSize]); - if (!fifo) - return; - - size_t tail = 0; - - memset(fifo.get(), 0xff, sizeof(uint32_t) * cacheSize); - - for (size_t j = 0; j < (nFaces * 3); ++j) - { - if (indices[j] == index_t(-1)) - continue; - - bool found = false; - - for (size_t ptr = 0; ptr < cacheSize; ++ptr) - { - if (fifo[ptr] == indices[j]) - { - found = true; - break; - } - } - - if (!found) - { - ++misses; - fifo[tail] = indices[j]; - ++tail; - if (tail == cacheSize) tail = 0; - } - } - - // ideal is 0.5, individual tris have 3.0 - acmr = float(misses) / float(nFaces); - - // ideal is 1.0, worst case is 6.0 - atvr = float(misses) / float(nVerts); - } -} - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -void DirectX::ComputeVertexCacheMissRate( - const uint16_t* indices, size_t nFaces, size_t nVerts, size_t cacheSize, - float& acmr, float& atvr) -{ - ComputeVertexCacheMissRateImpl(indices, nFaces, nVerts, cacheSize, acmr, atvr); -} - -_Use_decl_annotations_ -void DirectX::ComputeVertexCacheMissRate( - const uint32_t* indices, size_t nFaces, size_t nVerts, size_t cacheSize, - float& acmr, float& atvr) -{ - ComputeVertexCacheMissRateImpl(indices, nFaces, nVerts, cacheSize, acmr, atvr); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshVBReader.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshVBReader.cpp deleted file mode 100644 index 9111791..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshVBReader.cpp +++ /dev/null @@ -1,802 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXMeshVBReader.cpp -// -// DirectX Mesh Geometry Library - Vertex Buffer Reader -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkID=324981 -//------------------------------------------------------------------------------------- - -#include "DirectXMeshP.h" - -using namespace DirectX; -using namespace DirectX::PackedVector; - -#ifndef _WIN32 -#define _stricmp strcasecmp -#endif - -namespace -{ - constexpr size_t c_MaxSlot = 32; - constexpr size_t c_MaxStride = 2048; - - enum INPUT_CLASSIFICATION - { - PER_VERTEX_DATA = 0, - PER_INSTANCE_DATA = 1 - }; - - struct InputElementDesc - { - const char* SemanticName; - unsigned int SemanticIndex; - DXGI_FORMAT Format; - unsigned int InputSlot; - unsigned int AlignedByteOffset; - INPUT_CLASSIFICATION InputSlotClass; - unsigned int InstanceDataStepRate; - }; - -#if defined(__d3d11_h__) || defined(__d3d11_x_h__) - static_assert(sizeof(InputElementDesc) == sizeof(D3D11_INPUT_ELEMENT_DESC), "D3D11 mismatch"); - static_assert(static_cast(PER_VERTEX_DATA) == static_cast(D3D11_INPUT_PER_VERTEX_DATA), "D3D11 mismatch"); - static_assert(static_cast(PER_INSTANCE_DATA) == static_cast(D3D11_INPUT_PER_INSTANCE_DATA), "D3D11 mismatch"); - static_assert(c_MaxSlot == D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT, "D3D11 mismatch"); - static_assert(c_MaxStride == D3D11_REQ_MULTI_ELEMENT_STRUCTURE_SIZE_IN_BYTES, "D3D11 mismatch"); -#endif - -#if defined(__d3d12_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__) - static_assert(sizeof(InputElementDesc) == sizeof(D3D12_INPUT_ELEMENT_DESC), "D3D12 mismatch"); - static_assert(static_cast(PER_VERTEX_DATA) == static_cast(D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA), "D3D12 mismatch"); - static_assert(static_cast(PER_INSTANCE_DATA) == static_cast(D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA), "D3D12 mismatch"); - static_assert(c_MaxSlot == D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT, "D3D12 mismatch"); - static_assert(c_MaxStride == D3D12_REQ_MULTI_ELEMENT_STRUCTURE_SIZE_IN_BYTES, "D3D12 mismatch"); -#endif -} - -class VBReader::Impl -{ -public: - Impl() noexcept : - mStrides{}, - mBuffers{}, - mVerts{}, - mDefaultStrides{}, - mTempSize(0) {} - - HRESULT Initialize(_In_reads_(nDecl) const InputElementDesc* vbDecl, size_t nDecl); - HRESULT AddStream(_In_reads_bytes_(stride*nVerts) const void* vb, size_t nVerts, size_t inputSlot, size_t stride) noexcept; - HRESULT Read(_Out_writes_(count) XMVECTOR* buffer, _In_z_ const char* semanticName, unsigned int semanticIndex, size_t count, bool x2bias) const; - - void Release() noexcept - { - mInputDesc.clear(); - mSemantics.clear(); - memset(mStrides, 0, sizeof(mStrides)); - memset(mBuffers, 0, sizeof(mBuffers)); - memset(mVerts, 0, sizeof(mVerts)); - memset(mDefaultStrides, 0, sizeof(mDefaultStrides)); - mTempBuffer.reset(); - } - - const InputElementDesc* GetElement(_In_z_ const char* semanticName, _In_ unsigned int semanticIndex) const - { - auto range = mSemantics.equal_range(semanticName); - - auto it = range.first; - for (; it != range.second; ++it) - { - if (mInputDesc[it->second].SemanticIndex == semanticIndex) - break; - } - - if (it == range.second) - return nullptr; - - return &mInputDesc[it->second]; - } - - XMVECTOR* GetTemporaryBuffer(size_t count) const noexcept - { - if (!mTempBuffer || (mTempSize < count)) - { - mTempSize = count; - - for (size_t j = 0; j < c_MaxSlot; ++j) - { - if (mVerts[j] > mTempSize) - mTempSize = mVerts[j]; - } - - auto temp = make_AlignedArrayXMVECTOR(mTempSize); - if (!temp) - mTempSize = 0; - - mTempBuffer.swap(temp); - } - - return mTempBuffer.get(); - } - -private: - using SemanticMap = std::multimap; - - std::vector mInputDesc; - SemanticMap mSemantics; - uint32_t mStrides[c_MaxSlot]; - const void* mBuffers[c_MaxSlot]; - size_t mVerts[c_MaxSlot]; - uint32_t mDefaultStrides[c_MaxSlot]; - mutable size_t mTempSize; - mutable ScopedAlignedArrayXMVECTOR mTempBuffer; -}; - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT VBReader::Impl::Initialize(const InputElementDesc* vbDecl, size_t nDecl) -{ - Release(); - - uint32_t offsets[c_MaxSlot] = {}; - -#if defined(__d3d12_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__) - { - if (nDecl > D3D12_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT) - return E_INVALIDARG; - - D3D12_INPUT_LAYOUT_DESC desc = { reinterpret_cast(vbDecl), UINT(nDecl) }; - if (!IsValid(desc)) - return E_INVALIDARG; - - ComputeInputLayout(desc, offsets, mDefaultStrides); - } -#else - if (!IsValid(reinterpret_cast(vbDecl), nDecl)) - return E_INVALIDARG; - - assert(nDecl <= 32 /*D3D11_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT*/); - _Analysis_assume_(nDecl <= 32 /*D3D11_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT*/); - - ComputeInputLayout(reinterpret_cast(vbDecl), nDecl, offsets, mDefaultStrides); -#endif - - for (uint32_t j = 0; j < nDecl; ++j) - { - if (vbDecl[j].InputSlotClass == PER_INSTANCE_DATA) - { - // Does not currently support instance data layouts - Release(); - return HRESULT_E_NOT_SUPPORTED; - } - - mInputDesc.push_back(vbDecl[j]); - - mInputDesc[j].AlignedByteOffset = offsets[j]; - - auto decl = SemanticMap::value_type(vbDecl[j].SemanticName, j); - mSemantics.insert(decl); - - // Add common aliases - if (_stricmp(vbDecl[j].SemanticName, "POSITION") == 0) - { - auto decl2 = SemanticMap::value_type("SV_Position", j); - mSemantics.insert(decl2); - } - else if (_stricmp(vbDecl[j].SemanticName, "SV_Position") == 0) - { - auto decl2 = SemanticMap::value_type("POSITION", j); - mSemantics.insert(decl2); - } - } - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT VBReader::Impl::AddStream(const void* vb, size_t nVerts, size_t inputSlot, size_t stride) noexcept -{ - if (!vb || !nVerts) - return E_INVALIDARG; - - if (nVerts >= UINT32_MAX) - return E_INVALIDARG; - - if (inputSlot >= c_MaxSlot) - return E_INVALIDARG; - - if (stride > c_MaxStride) - return E_INVALIDARG; - - mStrides[inputSlot] = (stride > 0) ? uint32_t(stride) : mDefaultStrides[inputSlot]; - mBuffers[inputSlot] = vb; - mVerts[inputSlot] = nVerts; - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -#define LOAD_VERTS( type, func )\ - for(size_t icount = 0; icount < count; ++icount)\ - {\ - if ((ptr + sizeof(type)) > eptr)\ - return E_UNEXPECTED;\ - *buffer++ = func(reinterpret_cast(ptr));\ - ptr += stride;\ - }\ - break; - -#define LOAD_VERTS4_X2( type, func, x2bias )\ - for(size_t icount = 0; icount < count; ++icount)\ - {\ - if ((ptr + sizeof(type)) > eptr)\ - return E_UNEXPECTED;\ - XMVECTOR v = func(reinterpret_cast(ptr));\ - if (x2bias)\ - {\ - v = XMVectorMultiplyAdd(v, g_XMTwo, g_XMNegativeOne);\ - }\ - *buffer++ = v;\ - ptr += stride;\ - }\ - break; - -#define LOAD_VERTS3_X2( type, func, x2bias )\ - for(size_t icount = 0; icount < count; ++icount)\ - {\ - if ((ptr + sizeof(type)) > eptr)\ - return E_UNEXPECTED;\ - XMVECTOR v = func(reinterpret_cast(ptr));\ - if (x2bias)\ - {\ - const XMVECTOR v2 = XMVectorMultiplyAdd(v, g_XMTwo, g_XMNegativeOne);\ - v = XMVectorSelect(v, v2, g_XMSelect1110);\ - }\ - *buffer++ = v;\ - ptr += stride;\ - }\ - break; - -#define LOAD_VERTS2_X2( type, func, x2bias )\ - for(size_t icount = 0; icount < count; ++icount)\ - {\ - if ((ptr + sizeof(type)) > eptr)\ - return E_UNEXPECTED;\ - XMVECTOR v = func(reinterpret_cast(ptr));\ - if (x2bias)\ - {\ - const XMVECTOR v2 = XMVectorMultiplyAdd(v, g_XMTwo, g_XMNegativeOne);\ - v = XMVectorSelect(v, v2, g_XMSelect1100);\ - }\ - *buffer++ = v;\ - ptr += stride;\ - }\ - break; - -_Use_decl_annotations_ -HRESULT VBReader::Impl::Read(XMVECTOR* buffer, const char* semanticName, unsigned int semanticIndex, size_t count, bool x2bias) const -{ - if (!buffer || !semanticName || !count) - return E_INVALIDARG; - - auto range = mSemantics.equal_range(semanticName); - - auto it = range.first; - for (; it != range.second; ++it) - { - if (mInputDesc[it->second].SemanticIndex == semanticIndex) - break; - } - - if (it == range.second) - return HRESULT_E_INVALID_NAME; - - const uint32_t inputSlot = mInputDesc[it->second].InputSlot; - - auto vb = static_cast(mBuffers[inputSlot]); - if (!vb) - return E_FAIL; - - if (count > mVerts[inputSlot]) - return E_BOUNDS; - - const uint32_t stride = mStrides[inputSlot]; - if (!stride) - return E_UNEXPECTED; - - const uint8_t* eptr = vb + stride * mVerts[inputSlot]; - const uint8_t* ptr = vb + mInputDesc[it->second].AlignedByteOffset; - - switch (static_cast(mInputDesc[it->second].Format)) - { - case DXGI_FORMAT_R32G32B32A32_FLOAT: - LOAD_VERTS(XMFLOAT4, XMLoadFloat4) - - case DXGI_FORMAT_R32G32B32A32_UINT: - LOAD_VERTS(XMUINT4, XMLoadUInt4) - - case DXGI_FORMAT_R32G32B32A32_SINT: - LOAD_VERTS(XMINT4, XMLoadSInt4) - - case DXGI_FORMAT_R32G32B32_FLOAT: - LOAD_VERTS(XMFLOAT3, XMLoadFloat3) - - case DXGI_FORMAT_R32G32B32_UINT: - LOAD_VERTS(XMUINT3, XMLoadUInt3) - - case DXGI_FORMAT_R32G32B32_SINT: - LOAD_VERTS(XMINT3, XMLoadSInt3) - - case DXGI_FORMAT_R16G16B16A16_FLOAT: - LOAD_VERTS(XMHALF4, XMLoadHalf4) - - case DXGI_FORMAT_R16G16B16A16_UNORM: - LOAD_VERTS4_X2(XMUSHORTN4, XMLoadUShortN4, x2bias) - - case DXGI_FORMAT_R16G16B16A16_UINT: - LOAD_VERTS(XMUSHORT4, XMLoadUShort4) - - case DXGI_FORMAT_R16G16B16A16_SNORM: - LOAD_VERTS(XMSHORTN4, XMLoadShortN4) - - case DXGI_FORMAT_R16G16B16A16_SINT: - LOAD_VERTS(XMSHORT4, XMLoadShort4) - - case DXGI_FORMAT_R32G32_FLOAT: - LOAD_VERTS(XMFLOAT2, XMLoadFloat2) - - case DXGI_FORMAT_R32G32_UINT: - LOAD_VERTS(XMUINT2, XMLoadUInt2) - - case DXGI_FORMAT_R32G32_SINT: - LOAD_VERTS(XMINT2, XMLoadSInt2) - - case DXGI_FORMAT_R10G10B10A2_UNORM: - LOAD_VERTS3_X2(XMUDECN4, XMLoadUDecN4, x2bias) - - case DXGI_FORMAT_R10G10B10A2_UINT: - LOAD_VERTS(XMUDEC4, XMLoadUDec4) - - case DXGI_FORMAT_R11G11B10_FLOAT: - LOAD_VERTS3_X2(XMFLOAT3PK, XMLoadFloat3PK, x2bias) - - case DXGI_FORMAT_R8G8B8A8_UNORM: - LOAD_VERTS4_X2(XMUBYTEN4, XMLoadUByteN4, x2bias) - - case DXGI_FORMAT_R8G8B8A8_UINT: - LOAD_VERTS(XMUBYTE4, XMLoadUByte4) - - case DXGI_FORMAT_R8G8B8A8_SNORM: - LOAD_VERTS(XMBYTEN4, XMLoadByteN4) - - case DXGI_FORMAT_R8G8B8A8_SINT: - LOAD_VERTS(XMBYTE4, XMLoadByte4) - - case DXGI_FORMAT_R16G16_FLOAT: - LOAD_VERTS(XMHALF2, XMLoadHalf2) - - case DXGI_FORMAT_R16G16_UNORM: - LOAD_VERTS2_X2(XMUSHORTN2, XMLoadUShortN2, x2bias) - - case DXGI_FORMAT_R16G16_UINT: - LOAD_VERTS(XMUSHORT2, XMLoadUShort2) - - case DXGI_FORMAT_R16G16_SNORM: - LOAD_VERTS(XMSHORTN2, XMLoadShortN2) - - case DXGI_FORMAT_R16G16_SINT: - LOAD_VERTS(XMSHORT2, XMLoadShort2) - - case DXGI_FORMAT_R32_FLOAT: - LOAD_VERTS(float, XMLoadFloat) - - case DXGI_FORMAT_R32_UINT: - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(uint32_t)) > eptr) - return E_UNEXPECTED; - const XMVECTOR v = XMLoadInt(reinterpret_cast(ptr)); - *buffer++ = XMConvertVectorUIntToFloat(v, 0); - ptr += stride; - } - break; - - case DXGI_FORMAT_R32_SINT: - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(int32_t)) > eptr) - return E_UNEXPECTED; - const XMVECTOR v = XMLoadInt(reinterpret_cast(ptr)); - *buffer++ = XMConvertVectorIntToFloat(v, 0); - ptr += stride; - } - break; - - case DXGI_FORMAT_R8G8_UNORM: - LOAD_VERTS2_X2(XMUBYTEN2, XMLoadUByteN2, x2bias) - - case DXGI_FORMAT_R8G8_UINT: - LOAD_VERTS(XMUBYTE2, XMLoadUByte2) - - case DXGI_FORMAT_R8G8_SNORM: - LOAD_VERTS(XMBYTEN2, XMLoadByteN2) - - case DXGI_FORMAT_R8G8_SINT: - LOAD_VERTS(XMBYTE2, XMLoadByte2) - - case DXGI_FORMAT_R16_FLOAT: - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(HALF)) > eptr) - return E_UNEXPECTED; - const float v = XMConvertHalfToFloat(*reinterpret_cast(ptr)); - *buffer++ = XMVectorSet(v, 0.f, 0.f, 0.f); - ptr += stride; - } - break; - - case DXGI_FORMAT_R16_UNORM: - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(uint16_t)) > eptr) - return E_UNEXPECTED; - auto const i = *reinterpret_cast(ptr); - float f = static_cast(i) / 65535.f; - if (x2bias) - { - f = f*2.f - 1.f; - } - XMVECTOR v = XMVectorSet(f, 0.f, 0.f, 0.f); - *buffer++ = v; - ptr += stride; - } - break; - - case DXGI_FORMAT_R16_UINT: - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(uint16_t)) > eptr) - return E_UNEXPECTED; - auto const i = *reinterpret_cast(ptr); - *buffer++ = XMVectorSet(static_cast(i), 0.f, 0.f, 0.f); - ptr += stride; - } - break; - - case DXGI_FORMAT_R16_SNORM: - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(int16_t)) > eptr) - return E_UNEXPECTED; - auto const i = *reinterpret_cast(ptr); - *buffer++ = XMVectorSet(static_cast(i) / 32767.f, 0.f, 0.f, 0.f); - ptr += stride; - } - break; - - case DXGI_FORMAT_R16_SINT: - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(int16_t)) > eptr) - return E_UNEXPECTED; - auto const i = *reinterpret_cast(ptr); - *buffer++ = XMVectorSet(static_cast(i), 0.f, 0.f, 0.f); - ptr += stride; - } - break; - - case DXGI_FORMAT_R8_UNORM: - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(uint8_t)) > eptr) - return E_UNEXPECTED; - const uint8_t i = *ptr; - float f = static_cast(i) / 255.f; - if (x2bias) - { - f = f*2.f - 1.f; - } - XMVECTOR v = XMVectorSet(f, 0.f, 0.f, 0.f); - *buffer++ = v; - ptr += stride; - } - break; - - case DXGI_FORMAT_R8_UINT: - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(uint8_t)) > eptr) - return E_UNEXPECTED; - const uint8_t i = *ptr; - *buffer++ = XMVectorSet(static_cast(i), 0.f, 0.f, 0.f); - ptr += stride; - } - break; - - case DXGI_FORMAT_R8_SNORM: - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(int8_t)) > eptr) - return E_UNEXPECTED; - auto const i = *reinterpret_cast(ptr); - *buffer++ = XMVectorSet(static_cast(i) / 127.f, 0.f, 0.f, 0.f); - ptr += stride; - } - break; - - case DXGI_FORMAT_R8_SINT: - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(int8_t)) > eptr) - return E_UNEXPECTED; - auto const i = *reinterpret_cast(ptr); - *buffer++ = XMVectorSet(static_cast(i), 0.f, 0.f, 0.f); - ptr += stride; - } - break; - - case DXGI_FORMAT_B5G6R5_UNORM: - { - static const XMVECTORF32 s_Scale = { { { 1.f / 31.f, 1.f / 63.f, 1.f / 31.f, 1.f } } }; - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(XMU565)) > eptr) - return E_UNEXPECTED; - XMVECTOR v = XMLoadU565(reinterpret_cast(ptr)); - v = XMVectorMultiply(v, s_Scale); - if (x2bias) - { - const XMVECTOR v2 = XMVectorMultiplyAdd(v, g_XMTwo, g_XMNegativeOne); - v = XMVectorSelect(v, v2, g_XMSelect1110); - } - *buffer++ = XMVectorSwizzle<2, 1, 0, 3>(v); - ptr += stride; - } - } - break; - - case DXGI_FORMAT_B5G5R5A1_UNORM: - { - static const XMVECTORF32 s_Scale = { { { 1.f / 31.f, 1.f / 31.f, 1.f / 31.f, 1.f } } }; - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(XMU555)) > eptr) - return E_UNEXPECTED; - XMVECTOR v = XMLoadU555(reinterpret_cast(ptr)); - v = XMVectorMultiply(v, s_Scale); - if (x2bias) - { - const XMVECTOR v2 = XMVectorMultiplyAdd(v, g_XMTwo, g_XMNegativeOne); - v = XMVectorSelect(v, v2, g_XMSelect1110); - } - *buffer++ = XMVectorSwizzle<2, 1, 0, 3>(v); - ptr += stride; - } - } - break; - - case DXGI_FORMAT_B8G8R8A8_UNORM: - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(XMUBYTEN4)) > eptr) - return E_UNEXPECTED; - XMVECTOR v = XMLoadUByteN4(reinterpret_cast(ptr)); - if (x2bias) - { - v = XMVectorMultiplyAdd(v, g_XMTwo, g_XMNegativeOne); - } - *buffer++ = XMVectorSwizzle<2, 1, 0, 3>(v); - ptr += stride; - } - break; - - case DXGI_FORMAT_B8G8R8X8_UNORM: - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(XMUBYTEN4)) > eptr) - return E_UNEXPECTED; - XMVECTOR v = XMLoadUByteN4(reinterpret_cast(ptr)); - if (x2bias) - { - const XMVECTOR v2 = XMVectorMultiplyAdd(v, g_XMTwo, g_XMNegativeOne); - v = XMVectorSelect(v, v2, g_XMSelect1110); - } - v = XMVectorSwizzle<2, 1, 0, 3>(v); - *buffer++ = XMVectorSelect(g_XMZero, v, g_XMSelect1110); - ptr += stride; - } - break; - - case DXGI_FORMAT_B4G4R4A4_UNORM: - { - static const XMVECTORF32 s_Scale = { { { 1.f / 15.f, 1.f / 15.f, 1.f / 15.f, 1.f / 15.f } } }; - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(XMUNIBBLE4)) > eptr) - return E_UNEXPECTED; - XMVECTOR v = XMLoadUNibble4(reinterpret_cast(ptr)); - v = XMVectorMultiply(v, s_Scale); - if (x2bias) - { - v = XMVectorMultiplyAdd(v, g_XMTwo, g_XMNegativeOne); - } - *buffer++ = XMVectorSwizzle<2, 1, 0, 3>(v); - ptr += stride; - } - } - break; - - case XBOX_DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM: - // Xbox One specific format - LOAD_VERTS(XMXDECN4, XMLoadXDecN4) - - default: - return E_FAIL; - } - - return S_OK; -} - - -//===================================================================================== -// Entry-points -//===================================================================================== - -// Public constructor. -VBReader::VBReader() noexcept(false) - : pImpl(std::make_unique()) -{ -} - -VBReader::VBReader(VBReader&&) noexcept = default; -VBReader& VBReader::operator= (VBReader&&) noexcept = default; -VBReader::~VBReader() = default; - -//------------------------------------------------------------------------------------- -#if defined(__d3d11_h__) || defined(__d3d11_x_h__) -_Use_decl_annotations_ -HRESULT VBReader::Initialize(const D3D11_INPUT_ELEMENT_DESC* vbDecl, size_t nDecl) -{ - return pImpl->Initialize(reinterpret_cast(vbDecl), nDecl); -} -#endif - -#if defined(__d3d12_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__) -HRESULT VBReader::Initialize(const D3D12_INPUT_LAYOUT_DESC& vbDecl) -{ - return pImpl->Initialize(reinterpret_cast(vbDecl.pInputElementDescs), vbDecl.NumElements); -} -#endif - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT VBReader::AddStream(const void* vb, size_t nVerts, size_t inputSlot, size_t stride) noexcept -{ - return pImpl->AddStream(vb, nVerts, inputSlot, stride); -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT VBReader::Read(XMVECTOR* buffer, const char* semanticName, unsigned int semanticIndex, size_t count, bool x2bias) const -{ - return pImpl->Read(buffer, semanticName, semanticIndex, count, x2bias); -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT VBReader::Read(float* buffer, const char* semanticName, unsigned int semanticIndex, size_t count, bool x2bias) const -{ - XMVECTOR* temp = pImpl->GetTemporaryBuffer(count); - if (!temp) - return E_OUTOFMEMORY; - - HRESULT hr = pImpl->Read(temp, semanticName, semanticIndex, count, x2bias); - if (FAILED(hr)) - return hr; - - float* dptr = buffer; - for (size_t j = 0; j < count; ++j) - { - const XMVECTOR v = *(temp)++; - XMStoreFloat(dptr++, v); - } - - return S_OK; -} - -_Use_decl_annotations_ -HRESULT VBReader::Read(XMFLOAT2* buffer, const char* semanticName, unsigned int semanticIndex, size_t count, bool x2bias) const -{ - XMVECTOR* temp = pImpl->GetTemporaryBuffer(count); - if (!temp) - return E_OUTOFMEMORY; - - HRESULT hr = pImpl->Read(temp, semanticName, semanticIndex, count, x2bias); - if (FAILED(hr)) - return hr; - - XMFLOAT2* dptr = buffer; - for (size_t j = 0; j < count; ++j) - { - const XMVECTOR v = *(temp)++; - XMStoreFloat2(dptr++, v); - } - - return S_OK; -} - -_Use_decl_annotations_ -HRESULT VBReader::Read(XMFLOAT3* buffer, const char* semanticName, unsigned int semanticIndex, size_t count, bool x2bias) const -{ - XMVECTOR* temp = pImpl->GetTemporaryBuffer(count); - if (!temp) - return E_OUTOFMEMORY; - - HRESULT hr = pImpl->Read(temp, semanticName, semanticIndex, count, x2bias); - if (FAILED(hr)) - return hr; - - XMFLOAT3* dptr = buffer; - for (size_t j = 0; j < count; ++j) - { - const XMVECTOR v = *(temp)++; - XMStoreFloat3(dptr++, v); - } - - return S_OK; -} - -_Use_decl_annotations_ -HRESULT VBReader::Read(XMFLOAT4* buffer, const char* semanticName, unsigned int semanticIndex, size_t count, bool x2bias) const -{ - XMVECTOR* temp = pImpl->GetTemporaryBuffer(count); - if (!temp) - return E_OUTOFMEMORY; - - HRESULT hr = pImpl->Read(temp, semanticName, semanticIndex, count, x2bias); - if (FAILED(hr)) - return hr; - - XMFLOAT4* dptr = buffer; - for (size_t j = 0; j < count; ++j) - { - const XMVECTOR v = *(temp)++; - XMStoreFloat4(dptr++, v); - } - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -void VBReader::Release() noexcept -{ - pImpl->Release(); -} - - -//------------------------------------------------------------------------------------- -#if defined(__d3d11_h__) || defined(__d3d11_x_h__) -_Use_decl_annotations_ -const D3D11_INPUT_ELEMENT_DESC* VBReader::GetElement11(const char* semanticName, unsigned int semanticIndex) const -{ - return reinterpret_cast(pImpl->GetElement(semanticName, semanticIndex)); -} -#endif - -#if defined(__d3d12_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__) -_Use_decl_annotations_ -const D3D12_INPUT_ELEMENT_DESC* VBReader::GetElement12(const char* semanticName, unsigned int semanticIndex) const -{ - return reinterpret_cast(pImpl->GetElement(semanticName, semanticIndex)); -} -#endif diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshVBWriter.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshVBWriter.cpp deleted file mode 100644 index a17dd3f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshVBWriter.cpp +++ /dev/null @@ -1,789 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXMeshVBWriter.cpp -// -// DirectX Mesh Geometry Library - Vertex Buffer Writer -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkID=324981 -//------------------------------------------------------------------------------------- - -#include "DirectXMeshP.h" - -using namespace DirectX; -using namespace DirectX::PackedVector; - -#ifndef _WIN32 -#define _stricmp strcasecmp -#endif - -namespace -{ - constexpr size_t c_MaxSlot = 32; - constexpr size_t c_MaxStride = 2048; - - enum INPUT_CLASSIFICATION - { - PER_VERTEX_DATA = 0, - PER_INSTANCE_DATA = 1 - }; - - struct InputElementDesc - { - const char* SemanticName; - unsigned int SemanticIndex; - DXGI_FORMAT Format; - unsigned int InputSlot; - unsigned int AlignedByteOffset; - INPUT_CLASSIFICATION InputSlotClass; - unsigned int InstanceDataStepRate; - }; - -#if defined(__d3d11_h__) || defined(__d3d11_x_h__) - static_assert(sizeof(InputElementDesc) == sizeof(D3D11_INPUT_ELEMENT_DESC), "D3D11 mismatch"); - static_assert(static_cast(PER_VERTEX_DATA) == static_cast(D3D11_INPUT_PER_VERTEX_DATA), "D3D11 mismatch"); - static_assert(static_cast(PER_INSTANCE_DATA) == static_cast(D3D11_INPUT_PER_INSTANCE_DATA), "D3D11 mismatch"); - static_assert(c_MaxSlot == D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT, "D3D11 mismatch"); - static_assert(c_MaxStride == D3D11_REQ_MULTI_ELEMENT_STRUCTURE_SIZE_IN_BYTES, "D3D11 mismatch"); -#endif - -#if defined(__d3d12_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__) - static_assert(sizeof(InputElementDesc) == sizeof(D3D12_INPUT_ELEMENT_DESC), "D3D12 mismatch"); - static_assert(static_cast(PER_VERTEX_DATA) == static_cast(D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA), "D3D12 mismatch"); - static_assert(static_cast(PER_INSTANCE_DATA) == static_cast(D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA), "D3D12 mismatch"); - static_assert(c_MaxSlot == D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT, "D3D12 mismatch"); - static_assert(c_MaxStride == D3D12_REQ_MULTI_ELEMENT_STRUCTURE_SIZE_IN_BYTES, "D3D12 mismatch"); -#endif -} - -class VBWriter::Impl -{ -public: - Impl() noexcept : - mStrides{}, - mBuffers{}, - mVerts{}, - mDefaultStrides{}, - mTempSize(0) {} - - HRESULT Initialize(_In_reads_(nDecl) const InputElementDesc* vbDecl, size_t nDecl); - HRESULT AddStream(_Out_writes_bytes_(stride*nVerts) void* vb, size_t nVerts, size_t inputSlot, size_t stride) noexcept; - HRESULT Write(_In_reads_(count) const XMVECTOR* buffer, _In_z_ const char* semanticName, unsigned int semanticIndex, size_t count, bool x2bias) const; - - void Release() noexcept - { - mInputDesc.clear(); - mSemantics.clear(); - memset(mStrides, 0, sizeof(mStrides)); - memset(mBuffers, 0, sizeof(mBuffers)); - memset(mVerts, 0, sizeof(mVerts)); - memset(mDefaultStrides, 0, sizeof(mDefaultStrides)); - mTempBuffer.reset(); - } - - const InputElementDesc* GetElement(_In_z_ const char* semanticName, _In_ unsigned int semanticIndex) const - { - auto range = mSemantics.equal_range(semanticName); - - auto it = range.first; - for (; it != range.second; ++it) - { - if (mInputDesc[it->second].SemanticIndex == semanticIndex) - break; - } - - if (it == range.second) - return nullptr; - - return &mInputDesc[it->second]; - } - - XMVECTOR* GetTemporaryBuffer(size_t count) const noexcept - { - if (!mTempBuffer || (mTempSize < count)) - { - mTempSize = count; - - for (size_t j = 0; j < c_MaxSlot; ++j) - { - if (mVerts[j] > mTempSize) - mTempSize = mVerts[j]; - } - - auto temp = make_AlignedArrayXMVECTOR(mTempSize); - if (!temp) - mTempSize = 0; - - mTempBuffer.swap(temp); - } - - return mTempBuffer.get(); - } - -private: - using SemanticMap = std::multimap; - - std::vector mInputDesc; - SemanticMap mSemantics; - uint32_t mStrides[c_MaxSlot]; - void* mBuffers[c_MaxSlot]; - size_t mVerts[c_MaxSlot]; - uint32_t mDefaultStrides[c_MaxSlot]; - mutable size_t mTempSize; - mutable ScopedAlignedArrayXMVECTOR mTempBuffer; -}; - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT VBWriter::Impl::Initialize(const InputElementDesc* vbDecl, size_t nDecl) -{ - Release(); - - uint32_t offsets[c_MaxSlot] = {}; - -#if defined(__d3d12_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__) - { - if (nDecl > D3D12_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT) - return E_INVALIDARG; - - D3D12_INPUT_LAYOUT_DESC desc = { reinterpret_cast(vbDecl), UINT(nDecl) }; - if (!IsValid(desc)) - return E_INVALIDARG; - - ComputeInputLayout(desc, offsets, mDefaultStrides); - } -#else - if (!IsValid(reinterpret_cast(vbDecl), nDecl)) - return E_INVALIDARG; - - assert(nDecl <= 32 /*D3D11_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT*/); - _Analysis_assume_(nDecl <= 32 /*D3D11_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT*/); - - ComputeInputLayout(reinterpret_cast(vbDecl), nDecl, offsets, mDefaultStrides); -#endif - - for (uint32_t j = 0; j < nDecl; ++j) - { - if (vbDecl[j].InputSlotClass == PER_INSTANCE_DATA) - { - // Does not currently support instance data layouts - Release(); - return HRESULT_E_NOT_SUPPORTED; - } - - mInputDesc.push_back(vbDecl[j]); - - mInputDesc[j].AlignedByteOffset = offsets[j]; - - auto decl = SemanticMap::value_type(vbDecl[j].SemanticName, j); - mSemantics.insert(decl); - - // Add common aliases - if (_stricmp(vbDecl[j].SemanticName, "POSITION") == 0) - { - auto decl2 = SemanticMap::value_type("SV_Position", j); - mSemantics.insert(decl2); - } - else if (_stricmp(vbDecl[j].SemanticName, "SV_Position") == 0) - { - auto decl2 = SemanticMap::value_type("POSITION", j); - mSemantics.insert(decl2); - } - } - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT VBWriter::Impl::AddStream(void* vb, size_t nVerts, size_t inputSlot, size_t stride) noexcept -{ - if (!vb || !nVerts) - return E_INVALIDARG; - - if (nVerts >= UINT32_MAX) - return E_INVALIDARG; - - if (inputSlot >= c_MaxSlot) - return E_INVALIDARG; - - if (stride > c_MaxStride) - return E_INVALIDARG; - - mStrides[inputSlot] = (stride > 0) ? uint32_t(stride) : mDefaultStrides[inputSlot]; - mBuffers[inputSlot] = vb; - mVerts[inputSlot] = nVerts; - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -#define STORE_VERTS( type, func )\ - for(size_t icount = 0; icount < count; ++icount)\ - {\ - if ((ptr + sizeof(type)) > eptr)\ - return E_UNEXPECTED;\ - func(reinterpret_cast(ptr), *buffer++);\ - ptr += stride;\ - }\ - break; - -#define STORE_VERTS_X2( type, func, x2bias )\ - for(size_t icount = 0; icount < count; ++icount)\ - {\ - if ((ptr + sizeof(type)) > eptr)\ - return E_UNEXPECTED;\ - XMVECTOR v = *buffer++;\ - if (x2bias)\ - {\ - v = XMVectorClamp(v, g_XMNegativeOne, g_XMOne);\ - v = XMVectorMultiplyAdd(v, g_XMOneHalf, g_XMOneHalf);\ - }\ - func(reinterpret_cast(ptr), v);\ - ptr += stride;\ - }\ - break; - -_Use_decl_annotations_ -HRESULT VBWriter::Impl::Write(const XMVECTOR* buffer, const char* semanticName, unsigned int semanticIndex, size_t count, bool x2bias) const -{ - if (!buffer || !semanticName || !count) - return E_INVALIDARG; - - auto range = mSemantics.equal_range(semanticName); - - auto it = range.first; - for (; it != range.second; ++it) - { - if (mInputDesc[it->second].SemanticIndex == semanticIndex) - break; - } - - if (it == range.second) - return HRESULT_E_INVALID_NAME; - - uint32_t inputSlot = mInputDesc[it->second].InputSlot; - - auto vb = static_cast(mBuffers[inputSlot]); - if (!vb) - return E_FAIL; - - if (count > mVerts[inputSlot]) - return E_BOUNDS; - - uint32_t stride = mStrides[inputSlot]; - if (!stride) - return E_UNEXPECTED; - - const uint8_t* eptr = vb + stride * mVerts[inputSlot]; - uint8_t* ptr = vb + mInputDesc[it->second].AlignedByteOffset; - - switch (static_cast(mInputDesc[it->second].Format)) - { - case DXGI_FORMAT_R32G32B32A32_FLOAT: - STORE_VERTS(XMFLOAT4, XMStoreFloat4) - - case DXGI_FORMAT_R32G32B32A32_UINT: - STORE_VERTS(XMUINT4, XMStoreUInt4) - - case DXGI_FORMAT_R32G32B32A32_SINT: - STORE_VERTS(XMINT4, XMStoreSInt4) - - case DXGI_FORMAT_R32G32B32_FLOAT: - STORE_VERTS(XMFLOAT3, XMStoreFloat3) - - case DXGI_FORMAT_R32G32B32_UINT: - STORE_VERTS(XMUINT3, XMStoreUInt3) - - case DXGI_FORMAT_R32G32B32_SINT: - STORE_VERTS(XMINT3, XMStoreSInt3) - - case DXGI_FORMAT_R16G16B16A16_FLOAT: - STORE_VERTS(XMHALF4, XMStoreHalf4) - - case DXGI_FORMAT_R16G16B16A16_UNORM: - STORE_VERTS_X2(XMUSHORTN4, XMStoreUShortN4, x2bias) - - case DXGI_FORMAT_R16G16B16A16_UINT: - STORE_VERTS(XMUSHORT4, XMStoreUShort4) - - case DXGI_FORMAT_R16G16B16A16_SNORM: - STORE_VERTS(XMSHORTN4, XMStoreShortN4) - - case DXGI_FORMAT_R16G16B16A16_SINT: - STORE_VERTS(XMSHORT4, XMStoreShort4) - - case DXGI_FORMAT_R32G32_FLOAT: - STORE_VERTS(XMFLOAT2, XMStoreFloat2) - - case DXGI_FORMAT_R32G32_UINT: - STORE_VERTS(XMUINT2, XMStoreUInt2) - - case DXGI_FORMAT_R32G32_SINT: - STORE_VERTS(XMINT2, XMStoreSInt2) - - case DXGI_FORMAT_R10G10B10A2_UNORM: - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(XMUDECN4)) > eptr) - return E_UNEXPECTED; - XMVECTOR v = *buffer++; - if (x2bias) - { - XMVECTOR v2 = XMVectorClamp(v, g_XMNegativeOne, g_XMOne); - v2 = XMVectorMultiplyAdd(v2, g_XMOneHalf, g_XMOneHalf); - v = XMVectorSelect(v, v2, g_XMSelect1110); - } - XMStoreUDecN4(reinterpret_cast(ptr), v); - ptr += stride; - } - break; - - case DXGI_FORMAT_R10G10B10A2_UINT: - STORE_VERTS(XMUDEC4, XMStoreUDec4) - - case DXGI_FORMAT_R11G11B10_FLOAT: - STORE_VERTS_X2(XMFLOAT3PK, XMStoreFloat3PK, x2bias) - - case DXGI_FORMAT_R8G8B8A8_UNORM: - STORE_VERTS_X2(XMUBYTEN4, XMStoreUByteN4, x2bias) - - case DXGI_FORMAT_R8G8B8A8_UINT: - STORE_VERTS(XMUBYTE4, XMStoreUByte4) - - case DXGI_FORMAT_R8G8B8A8_SNORM: - STORE_VERTS(XMBYTEN4, XMStoreByteN4) - - case DXGI_FORMAT_R8G8B8A8_SINT: - STORE_VERTS(XMBYTE4, XMStoreByte4) - - case DXGI_FORMAT_R16G16_FLOAT: - STORE_VERTS(XMHALF2, XMStoreHalf2) - - case DXGI_FORMAT_R16G16_UNORM: - STORE_VERTS_X2(XMUSHORTN2, XMStoreUShortN2, x2bias) - - case DXGI_FORMAT_R16G16_UINT: - STORE_VERTS(XMUSHORT2, XMStoreUShort2) - - case DXGI_FORMAT_R16G16_SNORM: - STORE_VERTS(XMSHORTN2, XMStoreShortN2) - - case DXGI_FORMAT_R16G16_SINT: - STORE_VERTS(XMSHORT2, XMStoreShort2) - - case DXGI_FORMAT_R32_FLOAT: - STORE_VERTS(float, XMStoreFloat) - - case DXGI_FORMAT_R32_UINT: - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(uint32_t)) > eptr) - return E_UNEXPECTED; - const XMVECTOR v = XMConvertVectorFloatToUInt(*buffer++, 0); - XMStoreInt(reinterpret_cast(ptr), v); - ptr += stride; - } - break; - - case DXGI_FORMAT_R32_SINT: - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(int32_t)) > eptr) - return E_UNEXPECTED; - const XMVECTOR v = XMConvertVectorFloatToInt(*buffer++, 0); - XMStoreInt(reinterpret_cast(ptr), v); - ptr += stride; - } - break; - - case DXGI_FORMAT_R8G8_UNORM: - STORE_VERTS_X2(XMUBYTEN2, XMStoreUByteN2, x2bias) - - case DXGI_FORMAT_R8G8_UINT: - STORE_VERTS(XMUBYTE2, XMStoreUByte2) - - case DXGI_FORMAT_R8G8_SNORM: - STORE_VERTS(XMBYTEN2, XMStoreByteN2) - - case DXGI_FORMAT_R8G8_SINT: - STORE_VERTS(XMBYTE2, XMStoreByte2) - - case DXGI_FORMAT_R16_FLOAT: - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(HALF)) > eptr) - return E_UNEXPECTED; - const float f = XMVectorGetX(*buffer++); - *reinterpret_cast(ptr) = XMConvertFloatToHalf(f); - ptr += stride; - } - break; - - case DXGI_FORMAT_R16_UNORM: - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(uint16_t)) > eptr) - return E_UNEXPECTED; - float f = XMVectorGetX(*buffer++); - if (x2bias) - { - f = std::max(std::min(f, 1.f), -1.f); - f = f * 0.5f + 0.5f; - } - else - { - f = std::max(std::min(f, 1.f), 0.f); - } - *reinterpret_cast(ptr) = static_cast(f*65535.f + 0.5f); - ptr += stride; - } - break; - - case DXGI_FORMAT_R16_UINT: - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(uint16_t)) > eptr) - return E_UNEXPECTED; - float f = XMVectorGetX(*buffer++); - f = std::max(std::min(f, 65535.f), 0.f); - *reinterpret_cast(ptr) = static_cast(f); - ptr += stride; - } - break; - - case DXGI_FORMAT_R16_SNORM: - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(int16_t)) > eptr) - return E_UNEXPECTED; - float f = XMVectorGetX(*buffer++); - f = std::max(std::min(f, 1.f), -1.f); - *reinterpret_cast(ptr) = static_cast(f * 32767.f); - ptr += stride; - } - break; - - case DXGI_FORMAT_R16_SINT: - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(int16_t)) > eptr) - return E_UNEXPECTED; - float f = XMVectorGetX(*buffer++); - f = std::max(std::min(f, 32767.f), -32767.f); - *reinterpret_cast(ptr) = static_cast(f); - ptr += stride; - } - break; - - case DXGI_FORMAT_R8_UNORM: - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(uint8_t)) > eptr) - return E_UNEXPECTED; - float f = XMVectorGetX(*buffer++); - if (x2bias) - { - f = std::max(std::min(f, 1.f), -1.f); - f = f * 0.5f + 0.5f; - } - else - { - f = std::max(std::min(f, 1.f), 0.f); - } - *ptr = static_cast(f * 255.f); - ptr += stride; - } - break; - - case DXGI_FORMAT_R8_UINT: - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(uint8_t)) > eptr) - return E_UNEXPECTED; - float f = XMVectorGetX(*buffer++); - f = std::max(std::min(f, 255.f), 0.f); - *ptr = static_cast(f); - ptr += stride; - } - break; - - case DXGI_FORMAT_R8_SNORM: - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(int8_t)) > eptr) - return E_UNEXPECTED; - float f = XMVectorGetX(*buffer++); - f = std::max(std::min(f, 1.f), -1.f); - *reinterpret_cast(ptr) = static_cast(f * 127.f); - ptr += stride; - } - break; - - case DXGI_FORMAT_R8_SINT: - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(int8_t)) > eptr) - return E_UNEXPECTED; - float f = XMVectorGetX(*buffer++); - f = std::max(std::min(f, 127.f), -127.f); - *reinterpret_cast(ptr) = static_cast(f); - ptr += stride; - } - break; - - case DXGI_FORMAT_B5G6R5_UNORM: - { - static const XMVECTORF32 s_Scale = { { { 31.f, 63.f, 31.f, 1.f } } }; - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(XMU565)) > eptr) - return E_UNEXPECTED; - XMVECTOR v = XMVectorSwizzle<2, 1, 0, 3>(*buffer++); - if (x2bias) - { - v = XMVectorClamp(v, g_XMNegativeOne, g_XMOne); - v = XMVectorMultiplyAdd(v, g_XMOneHalf, g_XMOneHalf); - } - v = XMVectorMultiply(v, s_Scale); - XMStoreU565(reinterpret_cast(ptr), v); - ptr += stride; - } - } - break; - - case DXGI_FORMAT_B5G5R5A1_UNORM: - { - static const XMVECTORF32 s_Scale = { { { 31.f, 31.f, 31.f, 1.f } } }; - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(XMU555)) > eptr) - return E_UNEXPECTED; - XMVECTOR v = XMVectorSwizzle<2, 1, 0, 3>(*buffer++); - if (x2bias) - { - XMVECTOR v2 = XMVectorClamp(v, g_XMNegativeOne, g_XMOne); - v2 = XMVectorMultiplyAdd(v2, g_XMOneHalf, g_XMOneHalf); - v = XMVectorSelect(v, v2, g_XMSelect1110); - } - v = XMVectorMultiply(v, s_Scale); - XMStoreU555(reinterpret_cast(ptr), v); - reinterpret_cast(ptr)->w = (XMVectorGetW(v) > 0.5f) ? 1u : 0u; - ptr += stride; - } - } - break; - - case DXGI_FORMAT_B8G8R8A8_UNORM: - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(XMUBYTEN4)) > eptr) - return E_UNEXPECTED; - XMVECTOR v = XMVectorSwizzle<2, 1, 0, 3>(*buffer++); - if (x2bias) - { - v = XMVectorClamp(v, g_XMNegativeOne, g_XMOne); - v = XMVectorMultiplyAdd(v, g_XMOneHalf, g_XMOneHalf); - } - XMStoreUByteN4(reinterpret_cast(ptr), v); - ptr += stride; - } - break; - - case DXGI_FORMAT_B8G8R8X8_UNORM: - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(XMUBYTEN4)) > eptr) - return E_UNEXPECTED; - XMVECTOR v = XMVectorSwizzle<2, 1, 0, 3>(*buffer++); - if (x2bias) - { - v = XMVectorClamp(v, g_XMNegativeOne, g_XMOne); - v = XMVectorMultiplyAdd(v, g_XMOneHalf, g_XMOneHalf); - } - v = XMVectorSelect(g_XMZero, v, g_XMSelect1110); - XMStoreUByteN4(reinterpret_cast(ptr), v); - ptr += stride; - } - break; - - case DXGI_FORMAT_B4G4R4A4_UNORM: - { - static const XMVECTORF32 s_Scale = { { { 15.f, 15.f, 15.f, 15.f } } }; - for (size_t icount = 0; icount < count; ++icount) - { - if ((ptr + sizeof(XMUNIBBLE4)) > eptr) - return E_UNEXPECTED; - XMVECTOR v = XMVectorSwizzle<2, 1, 0, 3>(*buffer++); - if (x2bias) - { - v = XMVectorClamp(v, g_XMNegativeOne, g_XMOne); - v = XMVectorMultiplyAdd(v, g_XMOneHalf, g_XMOneHalf); - } - v = XMVectorMultiply(v, s_Scale); - XMStoreUNibble4(reinterpret_cast(ptr), v); - ptr += stride; - } - } - break; - - case XBOX_DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM: - // Xbox One specific format - STORE_VERTS(XMXDECN4, XMStoreXDecN4) - - default: - return E_FAIL; - } - - return S_OK; -} - - -//===================================================================================== -// Entry-points -//===================================================================================== - -// Public constructor. -VBWriter::VBWriter() noexcept(false) - : pImpl(std::make_unique()) -{ -} - - -VBWriter::VBWriter(VBWriter&&) noexcept = default; -VBWriter& VBWriter::operator= (VBWriter&&) noexcept = default; -VBWriter::~VBWriter() = default; - -//------------------------------------------------------------------------------------- -#if defined(__d3d11_h__) || defined(__d3d11_x_h__) -_Use_decl_annotations_ -HRESULT VBWriter::Initialize(const D3D11_INPUT_ELEMENT_DESC* vbDecl, size_t nDecl) -{ - return pImpl->Initialize(reinterpret_cast(vbDecl), nDecl); -} -#endif - -#if defined(__d3d12_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__) -HRESULT VBWriter::Initialize(const D3D12_INPUT_LAYOUT_DESC& vbDecl) -{ - return pImpl->Initialize(reinterpret_cast(vbDecl.pInputElementDescs), vbDecl.NumElements); -} -#endif - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT VBWriter::AddStream(void* vb, size_t nVerts, size_t inputSlot, size_t stride) noexcept -{ - return pImpl->AddStream(vb, nVerts, inputSlot, stride); -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT VBWriter::Write(const XMVECTOR* buffer, const char* semanticName, unsigned int semanticIndex, size_t count, bool x2bias) const -{ - return pImpl->Write(buffer, semanticName, semanticIndex, count, x2bias); -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT VBWriter::Write(const float* buffer, const char* semanticName, unsigned int semanticIndex, size_t count, bool x2bias) const -{ - XMVECTOR* temp = pImpl->GetTemporaryBuffer(count); - if (!temp) - return E_OUTOFMEMORY; - - XMVECTOR* dptr = temp; - const float* sptr = buffer; - for (size_t j = 0; j < count; ++j) - { - XMVECTOR v = XMLoadFloat(sptr++); - *(dptr)++ = v; - } - - return pImpl->Write(temp, semanticName, semanticIndex, count, x2bias); -} - -_Use_decl_annotations_ -HRESULT VBWriter::Write(const XMFLOAT2* buffer, const char* semanticName, unsigned int semanticIndex, size_t count, bool x2bias) const -{ - XMVECTOR* temp = pImpl->GetTemporaryBuffer(count); - if (!temp) - return E_OUTOFMEMORY; - - XMVECTOR* dptr = temp; - const XMFLOAT2* sptr = buffer; - for (size_t j = 0; j < count; ++j) - { - XMVECTOR v = XMLoadFloat2(sptr++); - *(dptr)++ = v; - } - - return pImpl->Write(temp, semanticName, semanticIndex, count, x2bias); -} - -_Use_decl_annotations_ -HRESULT VBWriter::Write(const XMFLOAT3* buffer, const char* semanticName, unsigned int semanticIndex, size_t count, bool x2bias) const -{ - XMVECTOR* temp = pImpl->GetTemporaryBuffer(count); - if (!temp) - return E_OUTOFMEMORY; - - XMVECTOR* dptr = temp; - const XMFLOAT3* sptr = buffer; - for (size_t j = 0; j < count; ++j) - { - XMVECTOR v = XMLoadFloat3(sptr++); - *(dptr)++ = v; - } - - return pImpl->Write(temp, semanticName, semanticIndex, count, x2bias); -} - -_Use_decl_annotations_ -HRESULT VBWriter::Write(const XMFLOAT4* buffer, const char* semanticName, unsigned int semanticIndex, size_t count, bool x2bias) const -{ - XMVECTOR* temp = pImpl->GetTemporaryBuffer(count); - if (!temp) - return E_OUTOFMEMORY; - - XMVECTOR* dptr = temp; - const XMFLOAT4* sptr = buffer; - for (size_t j = 0; j < count; ++j) - { - XMVECTOR v = XMLoadFloat4(sptr++); - *(dptr)++ = v; - } - - return pImpl->Write(temp, semanticName, semanticIndex, count, x2bias); -} - - -//------------------------------------------------------------------------------------- -void VBWriter::Release() noexcept -{ - pImpl->Release(); -} - - -//------------------------------------------------------------------------------------- -#if defined(__d3d11_h__) || defined(__d3d11_x_h__) -_Use_decl_annotations_ -const D3D11_INPUT_ELEMENT_DESC* VBWriter::GetElement11(const char* semanticName, unsigned int semanticIndex) const -{ - return reinterpret_cast(pImpl->GetElement(semanticName, semanticIndex)); -} -#endif - -#if defined(__d3d12_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__) -_Use_decl_annotations_ -const D3D12_INPUT_ELEMENT_DESC* VBWriter::GetElement12(const char* semanticName, unsigned int semanticIndex) const -{ - return reinterpret_cast(pImpl->GetElement(semanticName, semanticIndex)); -} -#endif diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshValidate.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshValidate.cpp deleted file mode 100644 index 5769ffe..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshValidate.cpp +++ /dev/null @@ -1,445 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXMeshValidate.cpp -// -// DirectX Mesh Geometry Library - Mesh validation -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkID=324981 -//------------------------------------------------------------------------------------- - -#include "DirectXMeshP.h" - -using namespace DirectX; - -#ifndef _WIN32 -#include -#endif - -namespace -{ -#ifndef _WIN32 - template - inline int swprintf_s(wchar_t(&buffer)[sizeOfBuffer], const wchar_t* format, ...) - { - // This is adapter code. It is not a full implementation of swprintf_s! - va_list ap; - va_start(ap, format); - int result = vswprintf(buffer, sizeOfBuffer, format, ap); - va_end(ap); - return result; - } -#endif - - //--------------------------------------------------------------------------------- - // Validates indices and optionally the adjacency information - //--------------------------------------------------------------------------------- - template - HRESULT ValidateIndices( - _In_reads_(nFaces * 3) const index_t* indices, _In_ size_t nFaces, - _In_ size_t nVerts, _In_reads_opt_(nFaces * 3) const uint32_t* adjacency, - _In_ VALIDATE_FLAGS flags, _In_opt_ std::wstring* msgs) - { - bool result = true; - - if (!adjacency) - { - if (flags & VALIDATE_BACKFACING) - { - if (msgs) - *msgs += L"Missing adjacency information required to check for BACKFACING\n"; - - result = false; - } - - if (flags & VALIDATE_ASYMMETRIC_ADJ) - { - if (msgs) - *msgs += L"Missing adjacency information required to check for ASYMMETRIC_ADJ\n"; - - result = false; - } - - if (!result) - return E_INVALIDARG; - } - - for (size_t face = 0; face < nFaces; ++face) - { - // Check for values in-range - for (size_t point = 0; point < 3; ++point) - { - index_t i = indices[face * 3 + point]; - if (i >= nVerts && i != index_t(-1)) - { - if (!msgs) - return E_FAIL; - - result = false; - - wchar_t buff[128] = {}; - swprintf_s(buff, L"An invalid index value (%u) was found on face %zu\n", i, face); - *msgs += buff; - } - - if (adjacency) - { - const uint32_t j = adjacency[face * 3 + point]; - if (j >= nFaces && j != UNUSED32) - { - if (!msgs) - return E_FAIL; - - result = false; - - wchar_t buff[128] = {}; - swprintf_s(buff, L"An invalid neighbor index value (%u) was found on face %zu\n", j, face); - *msgs += buff; - } - } - } - - // Check for unused faces - index_t i0 = indices[face * 3]; - index_t i1 = indices[face * 3 + 1]; - index_t i2 = indices[face * 3 + 2]; - if (i0 == index_t(-1) - || i1 == index_t(-1) - || i2 == index_t(-1)) - { - if (flags & VALIDATE_UNUSED) - { - if (i0 != i1 - || i0 != i2 - || i1 != i2) - { - if (!msgs) - return E_FAIL; - - result = false; - - wchar_t buff[128] = {}; - swprintf_s(buff, L"An unused face (%zu) contains 'valid' but ignored vertices (%u,%u,%u)\n", face, i0, i1, i2); - *msgs += buff; - } - - if (adjacency) - { - for (size_t point = 0; point < 3; ++point) - { - const uint32_t k = adjacency[face * 3 + point]; - if (k != UNUSED32) - { - if (!msgs) - return E_FAIL; - - result = false; - - wchar_t buff[128] = {}; - swprintf_s(buff, L"An unused face (%zu) has a neighbor %u\n", face, k); - *msgs += buff; - } - } - } - } - - // ignore unused triangles for remaining tests - continue; - } - - // Check for degenerate triangles - if (i0 == i1 - || i0 == i2 - || i1 == i2) - { - if (flags & VALIDATE_DEGENERATE) - { - if (!msgs) - return E_FAIL; - - result = false; - - index_t bad; - if (i0 == i1) - bad = i0; - else if (i1 == i2) - bad = i2; - else - bad = i0; - - wchar_t buff[128] = {}; - swprintf_s(buff, L"A point (%u) was found more than once in triangle %zu\n", bad, face); - *msgs += buff; - - if (adjacency) - { - for (size_t point = 0; point < 3; ++point) - { - const uint32_t k = adjacency[face * 3 + point]; - if (k != UNUSED32) - { - result = false; - - swprintf_s(buff, L"A degenerate face (%zu) has a neighbor %u\n", face, k); - *msgs += buff; - } - } - } - } - - // ignore degenerate triangles for remaining tests - continue; - } - - // Check for symmetric neighbors - if ((flags & VALIDATE_ASYMMETRIC_ADJ) && adjacency) - { - for (size_t point = 0; point < 3; ++point) - { - const uint32_t k = adjacency[face * 3 + point]; - if (k == UNUSED32) - continue; - - assert(k < nFaces); - - const uint32_t edge = find_edge(&adjacency[k * 3], uint32_t(face)); - if (edge >= 3) - { - if (!msgs) - return E_FAIL; - - result = false; - - wchar_t buff[256] = {}; - swprintf_s(buff, L"A neighbor triangle (%u) does not reference back to this face (%zu) as expected\n", k, face); - *msgs += buff; - } - } - } - - // Check for duplicate neighbor - if ((flags & VALIDATE_BACKFACING) && adjacency) - { - const uint32_t j0 = adjacency[face * 3]; - const uint32_t j1 = adjacency[face * 3 + 1]; - const uint32_t j2 = adjacency[face * 3 + 2]; - - if ((j0 == j1 && j0 != UNUSED32) - || (j0 == j2 && j0 != UNUSED32) - || (j1 == j2 && j1 != UNUSED32)) - { - if (!msgs) - return E_FAIL; - - result = false; - - uint32_t bad; - if (j0 == j1 && j0 != UNUSED32) - bad = j0; - else if (j0 == j2 && j0 != UNUSED32) - bad = j0; - else - bad = j1; - - wchar_t buff[256] = {}; - swprintf_s(buff, L"A neighbor triangle (%u) was found more than once on triangle %zu\n" - L"\t(likley problem is that two triangles share same points with opposite direction)\n", bad, face); - *msgs += buff; - } - } - } - - return result ? S_OK : E_FAIL; - } - - - //--------------------------------------------------------------------------------- - // Validates mesh contains no bowties - // (i.e. a vertex is the apex of two separate triangle fans) - //--------------------------------------------------------------------------------- - template - HRESULT ValidateNoBowties( - _In_reads_(nFaces * 3) const index_t* indices, _In_ size_t nFaces, - _In_ size_t nVerts, _In_reads_opt_(nFaces * 3) const uint32_t* adjacency, - _In_opt_ std::wstring* msgs) - { - if (!adjacency) - { - if (msgs) - *msgs += L"Missing adjacency information required to check for BOWTIES\n"; - - return E_INVALIDARG; - } - - const size_t tsize = (sizeof(bool) * nFaces * 3) + (sizeof(index_t) * nVerts * 2) + (sizeof(bool) * nVerts); - std::unique_ptr temp(new (std::nothrow) uint8_t[tsize]); - if (!temp) - return E_OUTOFMEMORY; - - auto faceSeen = reinterpret_cast(temp.get()); - auto faceIds = reinterpret_cast(temp.get() + sizeof(bool) * nFaces * 3); - auto faceUsing = reinterpret_cast(reinterpret_cast(faceIds) + sizeof(index_t) * nVerts); - auto vertexBowtie = reinterpret_cast(reinterpret_cast(faceUsing) + sizeof(index_t) * nVerts); - - memset(faceSeen, 0, sizeof(bool) * nFaces * 3); - memset(faceIds, 0xFF, sizeof(index_t) * nVerts); - memset(faceUsing, 0, sizeof(index_t) * nVerts); - memset(vertexBowtie, 0, sizeof(bool) * nVerts); - - orbit_iterator ovi(adjacency, indices, nFaces); - - bool result = true; - - for (uint32_t face = 0; face < nFaces; ++face) - { - index_t i0 = indices[face * 3]; - index_t i1 = indices[face * 3 + 1]; - index_t i2 = indices[face * 3 + 2]; - - if (i0 == i1 - || i0 == i2 - || i1 == i2) - { - // ignore degenerate faces - faceSeen[face * 3] = true; - faceSeen[face * 3 + 1] = true; - faceSeen[face * 3 + 2] = true; - continue; - } - - for (uint32_t point = 0; point < 3; ++point) - { - if (faceSeen[face * 3 + point]) - continue; - - faceSeen[face * 3 + point] = true; - - index_t i = indices[face * 3 + point]; - ovi.initialize(face, i, orbit_iterator::ALL); - ovi.moveToCCW(); - while (!ovi.done()) - { - uint32_t curFace = ovi.nextFace(); - if (curFace >= nFaces) - return E_FAIL; - - uint32_t curPoint = ovi.getpoint(); - if (curPoint > 2) - return E_FAIL; - - faceSeen[curFace * 3 + curPoint] = true; - - uint32_t j = indices[curFace * 3 + curPoint]; - - if (faceIds[j] == index_t(-1)) - { - faceIds[j] = index_t(face); - faceUsing[j] = index_t(curFace); - } - else if ((faceIds[j] != index_t(face)) && !vertexBowtie[j]) - { - // We found a (unique) bowtie! - - if (!msgs) - return E_FAIL; - - if (result) - { - // If this is the first bowtie found, add a quick explanation - *msgs += L"A bowtie was found. Bowties can be fixed by calling Clean\n" - L" A bowtie is the usage of a single vertex by two separate fans of triangles.\n" - L" The fix is to duplicate the vertex so that each fan has its own vertex.\n"; - result = false; - } - - vertexBowtie[j] = true; - - wchar_t buff[256] = {}; - swprintf_s(buff, L"\nBowtie found around vertex %u shared by faces %u and %u\n", j, curFace, faceUsing[j]); - *msgs += buff; - } - } - } - } - - return result ? S_OK : E_FAIL; - } -} - -//===================================================================================== -// Entry-points -//===================================================================================== - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::Validate( - const uint16_t* indices, - size_t nFaces, - size_t nVerts, - const uint32_t* adjacency, - VALIDATE_FLAGS flags, - std::wstring* msgs) -{ - if (!indices || !nFaces || !nVerts) - return E_INVALIDARG; - - if (nVerts >= UINT16_MAX) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - if (msgs) - msgs->clear(); - - HRESULT hr = ValidateIndices(indices, nFaces, nVerts, adjacency, flags, msgs); - if (FAILED(hr)) - return hr; - - if (flags & VALIDATE_BOWTIES) - { - hr = ValidateNoBowties(indices, nFaces, nVerts, adjacency, msgs); - if (FAILED(hr)) - return hr; - } - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::Validate( - const uint32_t* indices, - size_t nFaces, - size_t nVerts, - const uint32_t* adjacency, - VALIDATE_FLAGS flags, - std::wstring* msgs) -{ - if (!indices || !nFaces || !nVerts) - return E_INVALIDARG; - - if (nVerts >= UINT32_MAX) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - if (msgs) - msgs->clear(); - - HRESULT hr = ValidateIndices(indices, nFaces, nVerts, adjacency, flags, msgs); - if (FAILED(hr)) - return hr; - - if (flags & VALIDATE_BOWTIES) - { - hr = ValidateNoBowties(indices, nFaces, nVerts, adjacency, msgs); - if (FAILED(hr)) - return hr; - } - - return S_OK; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshWeldVertices.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshWeldVertices.cpp deleted file mode 100644 index d34059f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshWeldVertices.cpp +++ /dev/null @@ -1,186 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXMeshWeldVertices.cpp -// -// DirectX Mesh Geometry Library - Vertex welding -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkID=324981 -//------------------------------------------------------------------------------------- - -#include "DirectXMeshP.h" - -using namespace DirectX; - -namespace -{ - template - HRESULT WeldVerticesImpl( - _Inout_updates_all_(nFaces * 3) index_t* indices, size_t nFaces, - size_t nVerts, _In_reads_(nVerts) const uint32_t* pointRep, - _Out_writes_opt_(nVerts) uint32_t* vertexRemap, - const std::function& weldTest) - { - std::unique_ptr temp(new (std::nothrow) uint32_t[nVerts * 2]); - if (!temp) - return E_OUTOFMEMORY; - - auto vertexRemapInverse = temp.get(); - - auto wedgeList = temp.get() + nVerts; - - for (uint32_t j = 0; j < nVerts; ++j) - { - vertexRemapInverse[j] = j; - wedgeList[j] = j; - - if (vertexRemap) - vertexRemap[j] = j; - } - - // Generate wedge list - bool identity = true; - - for (uint32_t j = 0; j < nVerts; ++j) - { - uint32_t pr = pointRep[j]; - if (pr == UNUSED32) - continue; - - if (pr >= nVerts) - return E_UNEXPECTED; - - if (pr != j) - { - identity = false; - - wedgeList[j] = wedgeList[pr]; - wedgeList[pr] = j; - } - } - - if (identity) - { - // No candidates for welding, so return now - return S_FALSE; - } - - bool weld = false; - - for (uint32_t vert = 0; vert < nVerts; ++vert) - { - if (pointRep[vert] == vert && wedgeList[vert] != vert) - { - uint32_t curOuter = vert; - do - { - // if a remapping for the vertex hasn't been found, check to see if it matches any other vertices - assert(curOuter < nVerts); - _Analysis_assume_(curOuter < nVerts); - if (vertexRemapInverse[curOuter] == curOuter) - { - uint32_t curInner = wedgeList[vert]; - assert(curInner < nVerts); - _Analysis_assume_(curInner < nVerts); - do - { - // don't check for equalivalence if indices the same (had better be equal then) - // and/or if the one being checked is already being remapped - if ((curInner != curOuter) && (vertexRemapInverse[curInner] == curInner)) - { - // if the two vertices are equal, then remap one to the other - if (weldTest(curOuter, curInner)) - { - // remap the inner vertices to the outer... - vertexRemapInverse[curInner] = curOuter; - - weld = true; - } - } - - curInner = wedgeList[curInner]; - } - while (curInner != vert); - } - - curOuter = wedgeList[curOuter]; - } - while (curOuter != vert); - } - } - - if (!weld) - return S_FALSE; - - // Apply map to indices - for (uint32_t j = 0; j < nFaces * 3; ++j) - { - index_t i = indices[j]; - if (i == index_t(-1)) - continue; - - indices[j] = index_t(vertexRemapInverse[i]); - } - - // Generate inverse map if requested - if (vertexRemap) - { - memset(vertexRemap, 0xff, sizeof(uint32_t) * nVerts); - - for (uint32_t j = 0; j < nVerts; ++j) - { - if (vertexRemapInverse[j] != UNUSED32) - { - vertexRemap[vertexRemapInverse[j]] = j; - } - } - } - - return S_OK; - } -} - -//===================================================================================== -// Entry-points -//===================================================================================== - -_Use_decl_annotations_ -HRESULT DirectX::WeldVertices( - uint16_t* indices, - size_t nFaces, - size_t nVerts, - const uint32_t* pointRep, - uint32_t* vertexRemap, - std::function weldTest) -{ - if (!indices || !nFaces || !nVerts || !pointRep) - return E_INVALIDARG; - - if (nVerts >= UINT16_MAX) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - return WeldVerticesImpl(indices, nFaces, nVerts, pointRep, vertexRemap, weldTest); -} - -_Use_decl_annotations_ -HRESULT DirectX::WeldVertices( - uint32_t* indices, size_t nFaces, - size_t nVerts, const uint32_t* pointRep, - uint32_t* vertexRemap, - std::function weldTest) -{ - if (!indices || !nFaces || !nVerts || !pointRep) - return E_INVALIDARG; - - if (nVerts >= UINT32_MAX) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - return WeldVerticesImpl(indices, nFaces, nVerts, pointRep, vertexRemap, weldTest); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Desktop_2019.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Desktop_2019.vcxproj deleted file mode 100644 index a1cc39c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Desktop_2019.vcxproj +++ /dev/null @@ -1,311 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Profile - Win32 - - - Profile - x64 - - - Release - Win32 - - - Release - x64 - - - - DirectXMesh - {6857F086-F6FE-4150-9ED7-7446F1C1C220} - DirectXMesh - Win32Proj - 10.0 - x64 - - - - StaticLibrary - true - Unicode - v142 - - - StaticLibrary - true - Unicode - v142 - - - StaticLibrary - Unicode - v142 - - - StaticLibrary - Unicode - v142 - - - StaticLibrary - Unicode - v142 - - - StaticLibrary - Unicode - v142 - - - - - - - - - - - - - - - - - - - - - - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - DirectXMesh - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - DirectXMesh - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - DirectXMesh - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - DirectXMesh - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - DirectXMesh - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - DirectXMesh - true - - - - EnableAllWarnings - Disabled - MultiThreadedDebugDLL - true - Fast - StreamingSIMDExtensions2 - true - WIN32;_DEBUG;DEBUG;PROFILE;_WINDOWS;_LIB;_WIN32_WINNT=0x0601;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXMeshP.h - $(IntDir)$(TargetName).pdb - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Level4 - ProgramDatabase - false - - - Windows - true - - - false - - - - - EnableAllWarnings - Disabled - MultiThreadedDebugDLL - true - Fast - true - WIN32;_DEBUG;DEBUG;PROFILE;_WINDOWS;_LIB;_WIN32_WINNT=0x0601;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXMeshP.h - $(IntDir)$(TargetName).pdb - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Level4 - ProgramDatabase - false - - - Windows - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - StreamingSIMDExtensions2 - true - WIN32;NDEBUG;_WINDOWS;_LIB;_WIN32_WINNT=0x0601;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXMeshP.h - $(IntDir)$(TargetName).pdb - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - true - WIN32;NDEBUG;_WINDOWS;_LIB;_WIN32_WINNT=0x0601;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXMeshP.h - $(IntDir)$(TargetName).pdb - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - StreamingSIMDExtensions2 - true - WIN32;NDEBUG;PROFILE;_WINDOWS;_LIB;_WIN32_WINNT=0x0601;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXMeshP.h - $(IntDir)$(TargetName).pdb - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - true - WIN32;NDEBUG;PROFILE;_WINDOWS;_LIB;_WIN32_WINNT=0x0601;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXMeshP.h - $(IntDir)$(TargetName).pdb - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Level4 - - - true - Windows - true - true - - - false - - - - - - - - - - - - - - - - - - - - - Create - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Desktop_2019.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Desktop_2019.vcxproj.filters deleted file mode 100644 index 62163bc..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Desktop_2019.vcxproj.filters +++ /dev/null @@ -1,79 +0,0 @@ - - - - - {d76fe36f-16db-490a-9ba9-13d02e13a65b} - - - {d4f97b15-a8e2-4223-a242-ca68b901e1fb} - - - - - Header Files - - - Header Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Desktop_2019_Win10.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Desktop_2019_Win10.vcxproj deleted file mode 100644 index db75f01..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Desktop_2019_Win10.vcxproj +++ /dev/null @@ -1,439 +0,0 @@ - - - - - Debug - ARM64 - - - Debug - Win32 - - - Debug - x64 - - - Profile - ARM64 - - - Profile - Win32 - - - Profile - x64 - - - Release - ARM64 - - - Release - Win32 - - - Release - x64 - - - - DirectXMesh - {6857F086-F6FE-4150-9ED7-7446F1C1C220} - DirectXMesh - Win32Proj - 10.0 - x64 - - - - StaticLibrary - true - Unicode - v142 - - - StaticLibrary - true - Unicode - v142 - - - StaticLibrary - true - Unicode - v142 - - - StaticLibrary - Unicode - v142 - - - StaticLibrary - Unicode - v142 - - - StaticLibrary - Unicode - v142 - - - StaticLibrary - Unicode - v142 - - - StaticLibrary - Unicode - v142 - - - StaticLibrary - Unicode - v142 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - DirectXMesh - true - - - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - DirectXMesh - true - - - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - DirectXMesh - true - - - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - DirectXMesh - true - - - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - DirectXMesh - true - - - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - DirectXMesh - true - - - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - DirectXMesh - true - - - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - DirectXMesh - true - - - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - DirectXMesh - true - - - - EnableAllWarnings - Disabled - MultiThreadedDebugDLL - true - Fast - StreamingSIMDExtensions2 - true - WIN32;_DEBUG;DEBUG;PROFILE;_WINDOWS;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXMeshP.h - $(IntDir)$(TargetName).pdb - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Level4 - ProgramDatabase - false - - - Windows - true - - - false - - - - - EnableAllWarnings - Disabled - MultiThreadedDebugDLL - true - Fast - true - WIN32;_DEBUG;DEBUG;PROFILE;_WINDOWS;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXMeshP.h - $(IntDir)$(TargetName).pdb - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Level4 - ProgramDatabase - false - - - Windows - true - - - false - - - - - EnableAllWarnings - Disabled - MultiThreadedDebugDLL - true - Fast - true - WIN32;_DEBUG;DEBUG;PROFILE;_WINDOWS;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXMeshP.h - $(IntDir)$(TargetName).pdb - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Level4 - ProgramDatabase - false - - - Windows - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - StreamingSIMDExtensions2 - true - WIN32;NDEBUG;_WINDOWS;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXMeshP.h - $(IntDir)$(TargetName).pdb - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - true - WIN32;NDEBUG;_WINDOWS;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXMeshP.h - $(IntDir)$(TargetName).pdb - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - true - WIN32;NDEBUG;_WINDOWS;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXMeshP.h - $(IntDir)$(TargetName).pdb - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - StreamingSIMDExtensions2 - true - WIN32;NDEBUG;PROFILE;_WINDOWS;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXMeshP.h - $(IntDir)$(TargetName).pdb - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - true - WIN32;NDEBUG;PROFILE;_WINDOWS;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXMeshP.h - $(IntDir)$(TargetName).pdb - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - true - WIN32;NDEBUG;PROFILE;_WINDOWS;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXMeshP.h - $(IntDir)$(TargetName).pdb - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Level4 - - - true - Windows - true - true - - - false - - - - - - - - - - - - - - - - - - - - - Create - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Desktop_2019_Win10.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Desktop_2019_Win10.vcxproj.filters deleted file mode 100644 index 62163bc..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Desktop_2019_Win10.vcxproj.filters +++ /dev/null @@ -1,79 +0,0 @@ - - - - - {d76fe36f-16db-490a-9ba9-13d02e13a65b} - - - {d4f97b15-a8e2-4223-a242-ca68b901e1fb} - - - - - Header Files - - - Header Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Desktop_2022.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Desktop_2022.vcxproj deleted file mode 100644 index 6c02cec..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Desktop_2022.vcxproj +++ /dev/null @@ -1,311 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Profile - Win32 - - - Profile - x64 - - - Release - Win32 - - - Release - x64 - - - - DirectXMesh - {6857F086-F6FE-4150-9ED7-7446F1C1C220} - DirectXMesh - Win32Proj - 10.0 - x64 - - - - StaticLibrary - true - Unicode - v143 - - - StaticLibrary - true - Unicode - v143 - - - StaticLibrary - Unicode - v143 - - - StaticLibrary - Unicode - v143 - - - StaticLibrary - Unicode - v143 - - - StaticLibrary - Unicode - v143 - - - - - - - - - - - - - - - - - - - - - - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - DirectXMesh - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - DirectXMesh - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - DirectXMesh - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - DirectXMesh - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - DirectXMesh - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - DirectXMesh - true - - - - EnableAllWarnings - Disabled - MultiThreadedDebugDLL - true - Fast - StreamingSIMDExtensions2 - true - WIN32;_DEBUG;DEBUG;PROFILE;_WINDOWS;_LIB;_WIN32_WINNT=0x0601;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXMeshP.h - $(IntDir)$(TargetName).pdb - /Zc:__cplusplus %(AdditionalOptions) - Level4 - ProgramDatabase - false - - - Windows - true - - - false - - - - - EnableAllWarnings - Disabled - MultiThreadedDebugDLL - true - Fast - true - WIN32;_DEBUG;DEBUG;PROFILE;_WINDOWS;_LIB;_WIN32_WINNT=0x0601;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXMeshP.h - $(IntDir)$(TargetName).pdb - /Zc:__cplusplus %(AdditionalOptions) - Level4 - ProgramDatabase - false - - - Windows - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - StreamingSIMDExtensions2 - true - WIN32;NDEBUG;_WINDOWS;_LIB;_WIN32_WINNT=0x0601;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXMeshP.h - $(IntDir)$(TargetName).pdb - /Zc:__cplusplus %(AdditionalOptions) - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - true - WIN32;NDEBUG;_WINDOWS;_LIB;_WIN32_WINNT=0x0601;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXMeshP.h - $(IntDir)$(TargetName).pdb - /Zc:__cplusplus %(AdditionalOptions) - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - StreamingSIMDExtensions2 - true - WIN32;NDEBUG;PROFILE;_WINDOWS;_LIB;_WIN32_WINNT=0x0601;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXMeshP.h - $(IntDir)$(TargetName).pdb - /Zc:__cplusplus %(AdditionalOptions) - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - true - WIN32;NDEBUG;PROFILE;_WINDOWS;_LIB;_WIN32_WINNT=0x0601;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXMeshP.h - $(IntDir)$(TargetName).pdb - /Zc:__cplusplus %(AdditionalOptions) - Level4 - - - true - Windows - true - true - - - false - - - - - - - - - - - - - - - - - - - - - Create - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Desktop_2022.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Desktop_2022.vcxproj.filters deleted file mode 100644 index 62163bc..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Desktop_2022.vcxproj.filters +++ /dev/null @@ -1,79 +0,0 @@ - - - - - {d76fe36f-16db-490a-9ba9-13d02e13a65b} - - - {d4f97b15-a8e2-4223-a242-ca68b901e1fb} - - - - - Header Files - - - Header Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Desktop_2022_Win10.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Desktop_2022_Win10.vcxproj deleted file mode 100644 index 7a2f333..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Desktop_2022_Win10.vcxproj +++ /dev/null @@ -1,439 +0,0 @@ - - - - - Debug - ARM64 - - - Debug - Win32 - - - Debug - x64 - - - Profile - ARM64 - - - Profile - Win32 - - - Profile - x64 - - - Release - ARM64 - - - Release - Win32 - - - Release - x64 - - - - DirectXMesh - {6857F086-F6FE-4150-9ED7-7446F1C1C220} - DirectXMesh - Win32Proj - 10.0 - x64 - - - - StaticLibrary - true - Unicode - v143 - - - StaticLibrary - true - Unicode - v143 - - - StaticLibrary - true - Unicode - v143 - - - StaticLibrary - Unicode - v143 - - - StaticLibrary - Unicode - v143 - - - StaticLibrary - Unicode - v143 - - - StaticLibrary - Unicode - v143 - - - StaticLibrary - Unicode - v143 - - - StaticLibrary - Unicode - v143 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - DirectXMesh - true - - - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - DirectXMesh - true - - - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - DirectXMesh - true - - - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - DirectXMesh - true - - - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - DirectXMesh - true - - - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - DirectXMesh - true - - - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - DirectXMesh - true - - - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - DirectXMesh - true - - - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - DirectXMesh - true - - - - EnableAllWarnings - Disabled - MultiThreadedDebugDLL - true - Fast - StreamingSIMDExtensions2 - true - WIN32;_DEBUG;DEBUG;PROFILE;_WINDOWS;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXMeshP.h - $(IntDir)$(TargetName).pdb - /Zc:__cplusplus %(AdditionalOptions) - Level4 - ProgramDatabase - false - - - Windows - true - - - false - - - - - EnableAllWarnings - Disabled - MultiThreadedDebugDLL - true - Fast - true - WIN32;_DEBUG;DEBUG;PROFILE;_WINDOWS;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXMeshP.h - $(IntDir)$(TargetName).pdb - /Zc:__cplusplus %(AdditionalOptions) - Level4 - ProgramDatabase - false - - - Windows - true - - - false - - - - - EnableAllWarnings - Disabled - MultiThreadedDebugDLL - true - Fast - true - WIN32;_DEBUG;DEBUG;PROFILE;_WINDOWS;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXMeshP.h - $(IntDir)$(TargetName).pdb - /Zc:__cplusplus %(AdditionalOptions) - Level4 - ProgramDatabase - false - - - Windows - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - StreamingSIMDExtensions2 - true - WIN32;NDEBUG;_WINDOWS;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXMeshP.h - $(IntDir)$(TargetName).pdb - /Zc:__cplusplus %(AdditionalOptions) - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - true - WIN32;NDEBUG;_WINDOWS;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXMeshP.h - $(IntDir)$(TargetName).pdb - /Zc:__cplusplus %(AdditionalOptions) - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - true - WIN32;NDEBUG;_WINDOWS;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXMeshP.h - $(IntDir)$(TargetName).pdb - /Zc:__cplusplus %(AdditionalOptions) - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - StreamingSIMDExtensions2 - true - WIN32;NDEBUG;PROFILE;_WINDOWS;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXMeshP.h - $(IntDir)$(TargetName).pdb - /Zc:__cplusplus %(AdditionalOptions) - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - true - WIN32;NDEBUG;PROFILE;_WINDOWS;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXMeshP.h - $(IntDir)$(TargetName).pdb - /Zc:__cplusplus %(AdditionalOptions) - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - true - WIN32;NDEBUG;PROFILE;_WINDOWS;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXMeshP.h - $(IntDir)$(TargetName).pdb - /Zc:__cplusplus %(AdditionalOptions) - Level4 - - - true - Windows - true - true - - - false - - - - - - - - - - - - - - - - - - - - - Create - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Desktop_2022_Win10.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Desktop_2022_Win10.vcxproj.filters deleted file mode 100644 index 62163bc..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Desktop_2022_Win10.vcxproj.filters +++ /dev/null @@ -1,79 +0,0 @@ - - - - - {d76fe36f-16db-490a-9ba9-13d02e13a65b} - - - {d4f97b15-a8e2-4223-a242-ca68b901e1fb} - - - - - Header Files - - - Header Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_GDK_2019.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_GDK_2019.vcxproj deleted file mode 100644 index ace9108..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_GDK_2019.vcxproj +++ /dev/null @@ -1,478 +0,0 @@ - - - - - Debug - Gaming.Desktop.x64 - - - Debug - Gaming.Xbox.Scarlett.x64 - - - Profile - Gaming.Desktop.x64 - - - Profile - Gaming.Xbox.Scarlett.x64 - - - Release - Gaming.Desktop.x64 - - - Release - Gaming.Xbox.Scarlett.x64 - - - Release - Gaming.Xbox.XboxOne.x64 - - - Profile - Gaming.Xbox.XboxOne.x64 - - - Debug - Gaming.Xbox.XboxOne.x64 - - - - DirectXMesh - {0b019afb-d02b-430a-9331-b2a9d6d9c0c3} - en-US - Win32Proj - - 15.0 - Native - x64 - - - - - StaticLibrary - v142 - false - Unicode - false - false - - - StaticLibrary - v142 - false - Unicode - - - StaticLibrary - v142 - false - Unicode - - - StaticLibrary - v142 - false - Unicode - false - false - - - StaticLibrary - v142 - false - Unicode - - - StaticLibrary - v142 - false - Unicode - - - StaticLibrary - v142 - true - Unicode - false - false - - - StaticLibrary - v142 - true - Unicode - - - StaticLibrary - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkLibPath) - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkIncludeRoot) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - false - Bin\GDK_2019\$(Platform)\$(Configuration)\ - Bin\GDK_2019\$(Platform)\$(Configuration)\ - DirectXMesh - - - $(Console_SdkLibPath);$(LibraryPath) - $(Console_SdkIncludeRoot);$(IncludePath) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - false - Bin\GDK_2019\$(Platform)\$(Configuration)\ - Bin\GDK_2019\$(Platform)\$(Configuration)\ - DirectXMesh - - - $(Console_SdkLibPath);$(LibraryPath) - $(Console_SdkIncludeRoot);$(IncludePath) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - false - Bin\GDK_2019\$(Platform)\$(Configuration)\ - Bin\GDK_2019\$(Platform)\$(Configuration)\ - DirectXMesh - - - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkLibPath) - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkIncludeRoot) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - false - Bin\GDK_2019\$(Platform)\$(Configuration)\ - Bin\GDK_2019\$(Platform)\$(Configuration)\ - DirectXMesh - - - $(Console_SdkLibPath);$(LibraryPath) - $(Console_SdkIncludeRoot);$(IncludePath) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - false - Bin\GDK_2019\$(Platform)\$(Configuration)\ - Bin\GDK_2019\$(Platform)\$(Configuration)\ - DirectXMesh - - - $(Console_SdkLibPath);$(LibraryPath) - $(Console_SdkIncludeRoot);$(IncludePath) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - false - Bin\GDK_2019\$(Platform)\$(Configuration)\ - Bin\GDK_2019\$(Platform)\$(Configuration)\ - DirectXMesh - - - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkLibPath) - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkIncludeRoot) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - true - Bin\GDK_2019\$(Platform)\$(Configuration)\ - Bin\GDK_2019\$(Platform)\$(Configuration)\ - DirectXMesh - - - $(Console_SdkLibPath);$(LibraryPath) - $(Console_SdkIncludeRoot);$(IncludePath) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - true - Bin\GDK_2019\$(Platform)\$(Configuration)\ - Bin\GDK_2019\$(Platform)\$(Configuration)\ - DirectXMesh - - - $(Console_SdkLibPath);$(LibraryPath) - $(Console_SdkIncludeRoot);$(IncludePath) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - true - Bin\GDK_2019\$(Platform)\$(Configuration)\ - Bin\GDK_2019\$(Platform)\$(Configuration)\ - DirectXMesh - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - true - Windows - true - true - - - Use - DirectXMeshP.h - MaxSpeed - NDEBUG;_LIB;%(PreprocessorDefinitions) - EnableAllWarnings - true - true - true - Level4 - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - true - Windows - true - true - - - Use - DirectXMeshP.h - MaxSpeed - NDEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;%(PreprocessorDefinitions) - EnableAllWarnings - true - true - true - Level4 - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - true - Windows - true - true - - - Use - DirectXMeshP.h - MaxSpeed - NDEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;%(PreprocessorDefinitions) - EnableAllWarnings - true - true - true - Level4 - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - true - Windows - true - true - - - Use - DirectXMeshP.h - MaxSpeed - NDEBUG;_LIB;PROFILE;%(PreprocessorDefinitions) - EnableAllWarnings - true - true - true - Level4 - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - true - Windows - true - true - - - Use - DirectXMeshP.h - MaxSpeed - NDEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;PROFILE;%(PreprocessorDefinitions) - EnableAllWarnings - true - true - true - Level4 - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - true - Windows - true - true - - - Use - DirectXMeshP.h - MaxSpeed - NDEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;PROFILE;%(PreprocessorDefinitions) - EnableAllWarnings - true - true - true - Level4 - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - Windows - true - - - DirectXMeshP.h - Use - false - EnableAllWarnings - Disabled - _DEBUG;_LIB;%(PreprocessorDefinitions) - true - Level4 - ProgramDatabase - false - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - Windows - true - - - DirectXMeshP.h - Use - false - EnableAllWarnings - Disabled - _DEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;%(PreprocessorDefinitions) - true - Level4 - ProgramDatabase - false - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - Windows - true - - - DirectXMeshP.h - Use - false - EnableAllWarnings - Disabled - _DEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;%(PreprocessorDefinitions) - true - Level4 - ProgramDatabase - false - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - - - 6.0 - - - - - - - - - - - - - - - - - - - - - - - - - Create - Create - Create - Create - Create - Create - Create - Create - Create - DirectXMeshP.h - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_GDK_2019.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_GDK_2019.vcxproj.filters deleted file mode 100644 index 6b59513..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_GDK_2019.vcxproj.filters +++ /dev/null @@ -1,80 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - - - Header Files - - - Source Files - - - Header Files - - - Source Files - - - - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_GDK_2022.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_GDK_2022.vcxproj deleted file mode 100644 index a9b1a6a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_GDK_2022.vcxproj +++ /dev/null @@ -1,478 +0,0 @@ - - - - - Debug - Gaming.Desktop.x64 - - - Debug - Gaming.Xbox.Scarlett.x64 - - - Profile - Gaming.Desktop.x64 - - - Profile - Gaming.Xbox.Scarlett.x64 - - - Release - Gaming.Desktop.x64 - - - Release - Gaming.Xbox.Scarlett.x64 - - - Release - Gaming.Xbox.XboxOne.x64 - - - Profile - Gaming.Xbox.XboxOne.x64 - - - Debug - Gaming.Xbox.XboxOne.x64 - - - - DirectXMesh - {0b019afb-d02b-430a-9331-b2a9d6d9c0c3} - en-US - Win32Proj - - 15.0 - Native - x64 - - - - - StaticLibrary - v143 - false - Unicode - false - false - - - StaticLibrary - v143 - false - Unicode - - - StaticLibrary - v143 - false - Unicode - - - StaticLibrary - v143 - false - Unicode - false - false - - - StaticLibrary - v143 - false - Unicode - - - StaticLibrary - v143 - false - Unicode - - - StaticLibrary - v143 - true - Unicode - false - false - - - StaticLibrary - v143 - true - Unicode - - - StaticLibrary - v143 - true - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkLibPath) - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkIncludeRoot) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - false - Bin\GDK_2022\$(Platform)\$(Configuration)\ - Bin\GDK_2022\$(Platform)\$(Configuration)\ - DirectXMesh - - - $(Console_SdkLibPath);$(LibraryPath) - $(Console_SdkIncludeRoot);$(IncludePath) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - false - Bin\GDK_2022\$(Platform)\$(Configuration)\ - Bin\GDK_2022\$(Platform)\$(Configuration)\ - DirectXMesh - - - $(Console_SdkLibPath);$(LibraryPath) - $(Console_SdkIncludeRoot);$(IncludePath) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - false - Bin\GDK_2022\$(Platform)\$(Configuration)\ - Bin\GDK_2022\$(Platform)\$(Configuration)\ - DirectXMesh - - - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkLibPath) - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkIncludeRoot) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - false - Bin\GDK_2022\$(Platform)\$(Configuration)\ - Bin\GDK_2022\$(Platform)\$(Configuration)\ - DirectXMesh - - - $(Console_SdkLibPath);$(LibraryPath) - $(Console_SdkIncludeRoot);$(IncludePath) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - false - Bin\GDK_2022\$(Platform)\$(Configuration)\ - Bin\GDK_2022\$(Platform)\$(Configuration)\ - DirectXMesh - - - $(Console_SdkLibPath);$(LibraryPath) - $(Console_SdkIncludeRoot);$(IncludePath) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - false - Bin\GDK_2022\$(Platform)\$(Configuration)\ - Bin\GDK_2022\$(Platform)\$(Configuration)\ - DirectXMesh - - - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkLibPath) - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkIncludeRoot) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - true - Bin\GDK_2022\$(Platform)\$(Configuration)\ - Bin\GDK_2022\$(Platform)\$(Configuration)\ - DirectXMesh - - - $(Console_SdkLibPath);$(LibraryPath) - $(Console_SdkIncludeRoot);$(IncludePath) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - true - Bin\GDK_2022\$(Platform)\$(Configuration)\ - Bin\GDK_2022\$(Platform)\$(Configuration)\ - DirectXMesh - - - $(Console_SdkLibPath);$(LibraryPath) - $(Console_SdkIncludeRoot);$(IncludePath) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - true - Bin\GDK_2022\$(Platform)\$(Configuration)\ - Bin\GDK_2022\$(Platform)\$(Configuration)\ - DirectXMesh - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - true - Windows - true - true - - - Use - DirectXMeshP.h - MaxSpeed - NDEBUG;_LIB;%(PreprocessorDefinitions) - EnableAllWarnings - true - true - true - Level4 - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - true - Windows - true - true - - - Use - DirectXMeshP.h - MaxSpeed - NDEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;%(PreprocessorDefinitions) - EnableAllWarnings - true - true - true - Level4 - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - true - Windows - true - true - - - Use - DirectXMeshP.h - MaxSpeed - NDEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;%(PreprocessorDefinitions) - EnableAllWarnings - true - true - true - Level4 - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - true - Windows - true - true - - - Use - DirectXMeshP.h - MaxSpeed - NDEBUG;_LIB;PROFILE;%(PreprocessorDefinitions) - EnableAllWarnings - true - true - true - Level4 - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - true - Windows - true - true - - - Use - DirectXMeshP.h - MaxSpeed - NDEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;PROFILE;%(PreprocessorDefinitions) - EnableAllWarnings - true - true - true - Level4 - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - true - Windows - true - true - - - Use - DirectXMeshP.h - MaxSpeed - NDEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;PROFILE;%(PreprocessorDefinitions) - EnableAllWarnings - true - true - true - Level4 - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - Windows - true - - - DirectXMeshP.h - Use - false - EnableAllWarnings - Disabled - _DEBUG;_LIB;%(PreprocessorDefinitions) - true - Level4 - ProgramDatabase - false - /Zc:__cplusplus %(AdditionalOptions) - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - Windows - true - - - DirectXMeshP.h - Use - false - EnableAllWarnings - Disabled - _DEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;%(PreprocessorDefinitions) - true - Level4 - ProgramDatabase - false - /Zc:__cplusplus %(AdditionalOptions) - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - Windows - true - - - DirectXMeshP.h - Use - false - EnableAllWarnings - Disabled - _DEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;%(PreprocessorDefinitions) - true - Level4 - ProgramDatabase - false - /Zc:__cplusplus %(AdditionalOptions) - - - 6.0 - - - - - - - - - - - - - - - - - - - - - - - - - Create - Create - Create - Create - Create - Create - Create - Create - Create - DirectXMeshP.h - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_GDK_2022.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_GDK_2022.vcxproj.filters deleted file mode 100644 index 6b59513..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_GDK_2022.vcxproj.filters +++ /dev/null @@ -1,80 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - - - Header Files - - - Source Files - - - Header Files - - - Source Files - - - - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Windows10_2019.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Windows10_2019.vcxproj deleted file mode 100644 index c4af32f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Windows10_2019.vcxproj +++ /dev/null @@ -1,389 +0,0 @@ - - - - - Debug - ARM - - - Debug - ARM64 - - - Debug - Win32 - - - Debug - x64 - - - Release - ARM - - - Release - ARM64 - - - Release - Win32 - - - Release - x64 - - - - - - - - - - - - - - - - Create - Create - Create - Create - Create - Create - Create - Create - - - - - - - - - - - - - - - - {107a408e-c148-4594-b469-075fe0adb7a5} - StaticLibrary - DirectXMesh - DirectXMesh - en-US - 14.0 - true - Windows Store - 10.0 - 10.0.14393.0 - 10.0 - x64 - - - - StaticLibrary - true - v142 - - - StaticLibrary - true - v142 - - - StaticLibrary - true - v142 - - - StaticLibrary - true - v142 - - - StaticLibrary - false - v142 - - - StaticLibrary - false - v142 - - - StaticLibrary - false - v142 - - - StaticLibrary - false - v142 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - DirectXMesh - false - - - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - DirectXMesh - false - - - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - DirectXMesh - false - - - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - DirectXMesh - false - - - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - DirectXMesh - false - - - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - DirectXMesh - false - - - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - DirectXMesh - false - - - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - DirectXMesh - false - - - - Use - - false - true - Fast - StreamingSIMDExtensions2 - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXMeshP.h - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - ProgramDatabase - false - Level4 - - - Console - false - false - - - - - Use - - false - true - Fast - StreamingSIMDExtensions2 - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXMeshP.h - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Level4 - - - Console - false - false - - - - - Use - - false - true - Fast - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXMeshP.h - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - ProgramDatabase - false - Level4 - - - Console - false - false - - - - - Use - - - false - true - Fast - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXMeshP.h - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - ProgramDatabase - false - Level4 - - - Console - false - false - - - - - Use - - false - true - Fast - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXMeshP.h - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Level4 - - - Console - false - false - - - - - Use - - - false - true - Fast - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXMeshP.h - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Level4 - - - Console - false - false - - - - - Use - - false - true - Fast - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXMeshP.h - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - ProgramDatabase - false - Level4 - - - Console - false - false - - - - - Use - - false - true - Fast - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXMeshP.h - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Level4 - - - Console - false - false - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Windows10_2019.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Windows10_2019.vcxproj.filters deleted file mode 100644 index 25ef8b9..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Windows10_2019.vcxproj.filters +++ /dev/null @@ -1,77 +0,0 @@ - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Source Files - - - Source Files - - - - - {0e8a37a4-6364-45e5-bc79-c24c97b7107c} - - - {019eb570-a575-464f-9fa4-eae2fa7ff34c} - - - - - Header Files - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Windows10_2022.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Windows10_2022.vcxproj deleted file mode 100644 index c39d1c8..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Windows10_2022.vcxproj +++ /dev/null @@ -1,389 +0,0 @@ - - - - - Debug - ARM - - - Debug - ARM64 - - - Debug - Win32 - - - Debug - x64 - - - Release - ARM - - - Release - ARM64 - - - Release - Win32 - - - Release - x64 - - - - - - - - - - - - - - - - Create - Create - Create - Create - Create - Create - Create - Create - - - - - - - - - - - - - - - - {107a408e-c148-4594-b469-075fe0adb7a5} - StaticLibrary - DirectXMesh - DirectXMesh - en-US - 14.0 - true - Windows Store - 10.0 - 10.0.17763.0 - 10.0 - x64 - - - - StaticLibrary - true - v143 - - - StaticLibrary - true - v143 - - - StaticLibrary - true - v143 - - - StaticLibrary - true - v143 - - - StaticLibrary - false - v143 - - - StaticLibrary - false - v143 - - - StaticLibrary - false - v143 - - - StaticLibrary - false - v143 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - DirectXMesh - false - - - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - DirectXMesh - false - - - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - DirectXMesh - false - - - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - DirectXMesh - false - - - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - DirectXMesh - false - - - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - DirectXMesh - false - - - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - DirectXMesh - false - - - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - DirectXMesh - false - - - - Use - - false - true - Fast - StreamingSIMDExtensions2 - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXMeshP.h - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:__cplusplus %(AdditionalOptions) - ProgramDatabase - false - Level4 - - - Console - false - false - - - - - Use - - false - true - Fast - StreamingSIMDExtensions2 - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXMeshP.h - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:__cplusplus %(AdditionalOptions) - Level4 - - - Console - false - false - - - - - Use - - false - true - Fast - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXMeshP.h - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:__cplusplus %(AdditionalOptions) - ProgramDatabase - false - Level4 - - - Console - false - false - - - - - Use - - - false - true - Fast - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXMeshP.h - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:__cplusplus %(AdditionalOptions) - ProgramDatabase - false - Level4 - - - Console - false - false - - - - - Use - - false - true - Fast - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXMeshP.h - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:__cplusplus %(AdditionalOptions) - Level4 - - - Console - false - false - - - - - Use - - - false - true - Fast - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXMeshP.h - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:__cplusplus %(AdditionalOptions) - Level4 - - - Console - false - false - - - - - Use - - false - true - Fast - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXMeshP.h - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:__cplusplus %(AdditionalOptions) - ProgramDatabase - false - Level4 - - - Console - false - false - - - - - Use - - false - true - Fast - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXMeshP.h - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:__cplusplus %(AdditionalOptions) - Level4 - - - Console - false - false - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Windows10_2022.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Windows10_2022.vcxproj.filters deleted file mode 100644 index 25ef8b9..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_Windows10_2022.vcxproj.filters +++ /dev/null @@ -1,77 +0,0 @@ - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Source Files - - - Source Files - - - - - {0e8a37a4-6364-45e5-bc79-c24c97b7107c} - - - {019eb570-a575-464f-9fa4-eae2fa7ff34c} - - - - - Header Files - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_XboxOneXDK_2017.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_XboxOneXDK_2017.vcxproj deleted file mode 100644 index 04203c6..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_XboxOneXDK_2017.vcxproj +++ /dev/null @@ -1,204 +0,0 @@ - - - - - Release - Durango - - - Profile - Durango - - - Debug - Durango - - - - - - - - - - - - - - - - - - - - - - - - Create - Create - Create - - - - - - - - DirectXMesh - {1a920ef0-11d7-4a11-9ab7-63c4424ad096} - en-US - Win32Proj - title - - v141 - 14.0 - Native - - - - StaticLibrary - v141 - false - Unicode - false - false - - - StaticLibrary - v141 - false - Unicode - false - false - - - StaticLibrary - v141 - true - Unicode - false - false - - - - - - - - - - - - - - - - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkLibPath) - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkIncludeRoot) - $(Console_SdkRoot)bin;$(VCInstallDir)bin\x86_amd64;$(VCInstallDir)bin;$(WindowsSDK_ExecutablePath_x86);$(VSInstallDir)Common7\Tools\bin;$(VSInstallDir)Common7\tools;$(VSInstallDir)Common7\ide;$(ProgramFiles)\HTML Help Workshop;$(MSBuildToolsPath32);$(FxCopDir);$(PATH); - Bin\XboxOneXDK_2017\$(Platform)\$(Configuration)\ - Bin\XboxOneXDK_2017\$(Platform)\$(Configuration)\ - DirectXMesh - - - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkLibPath) - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkIncludeRoot) - $(Console_SdkRoot)bin;$(VCInstallDir)bin\x86_amd64;$(VCInstallDir)bin;$(WindowsSDK_ExecutablePath_x86);$(VSInstallDir)Common7\Tools\bin;$(VSInstallDir)Common7\tools;$(VSInstallDir)Common7\ide;$(ProgramFiles)\HTML Help Workshop;$(MSBuildToolsPath32);$(FxCopDir);$(PATH); - Bin\XboxOneXDK_2017\$(Platform)\$(Configuration)\ - Bin\XboxOneXDK_2017\$(Platform)\$(Configuration)\ - DirectXMesh - - - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkLibPath) - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkIncludeRoot) - $(Console_SdkRoot)bin;$(VCInstallDir)bin\x86_amd64;$(VCInstallDir)bin;$(WindowsSDK_ExecutablePath_x86);$(VSInstallDir)Common7\Tools\bin;$(VSInstallDir)Common7\tools;$(VSInstallDir)Common7\ide;$(ProgramFiles)\HTML Help Workshop;$(MSBuildToolsPath32);$(FxCopDir);$(PATH); - Bin\XboxOneXDK_2017\$(Platform)\$(Configuration)\ - Bin\XboxOneXDK_2017\$(Platform)\$(Configuration)\ - DirectXMesh - - - - d3d11_x.lib;combase.lib;kernelx.lib;toolhelpx.lib;uuid.lib; - - - true - Windows - true - true - false - - - Use - DirectXMeshP.h - - - MaxSpeed - true - NDEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;%(PreprocessorDefinitions) - EnableAllWarnings - true - true - false - $(IntDir)$(TargetName).pdb - - - - - pixEvt.lib;d3d11_x.lib;combase.lib;kernelx.lib;toolhelpx.lib;uuid.lib; - - - true - Windows - true - true - false - - - Use - DirectXMeshP.h - - - MaxSpeed - true - NDEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;PROFILE;%(PreprocessorDefinitions) - EnableAllWarnings - true - true - false - $(IntDir)$(TargetName).pdb - - - - - d3d11_x.lib;combase.lib;kernelx.lib;toolhelpx.lib;uuid.lib; - Windows - true - false - - - Use - DirectXMeshP.h - false - - - EnableAllWarnings - Disabled - true - _DEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;%(PreprocessorDefinitions) - false - $(IntDir)$(TargetName).pdb - ProgramDatabase - false - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_XboxOneXDK_2017.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_XboxOneXDK_2017.vcxproj.filters deleted file mode 100644 index 79584ba..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMesh_XboxOneXDK_2017.vcxproj.filters +++ /dev/null @@ -1,79 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - - - Header Files - - - Source Files - - - Source Files - - - - - Header Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshletGenerator.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshletGenerator.cpp deleted file mode 100644 index df2f7bb..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/DirectXMeshletGenerator.cpp +++ /dev/null @@ -1,886 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXMeshletGenerator.cpp -// -// DirectX Mesh Geometry Library - Meshlet Computation -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkID=324981 -//------------------------------------------------------------------------------------- - -#include "DirectXMeshP.h" - -using namespace DirectX; -using namespace DirectX::PackedVector; - -static_assert(sizeof(MeshletTriangle) == sizeof(uint32_t), "MeshletTriangle packing is incorrect"); - -namespace -{ - //--------------------------------------------------------------------------------- - // Helper class which manages a fixed-size array like a vector. - //--------------------------------------------------------------------------------- - template - class StaticVector - { - public: - StaticVector() noexcept - : m_data{}, m_size(0) - { } - ~StaticVector() = default; - - StaticVector(StaticVector&&) = default; - StaticVector& operator= (StaticVector&&) = default; - - StaticVector(StaticVector const&) = default; - StaticVector& operator= (StaticVector const&) = default; - - void push_back(const T& value) noexcept - { - assert(m_size < N); - m_data[m_size++] = value; - } - - void push_back(T&& value) noexcept - { - assert(m_size < N); - m_data[m_size++] = std::move(value); - } - - template - void emplace_back(Args&&... args) noexcept - { - assert(m_size < N); - m_data[m_size++] = T(std::forward(args)...); - } - - size_t size() const noexcept { return m_size; } - bool empty() const noexcept { return m_size == 0; } - - T* data() noexcept { return m_data.data(); } - const T* data() const noexcept { return m_data.data(); } - - T& operator[](size_t index) noexcept { assert(index < m_size); return m_data[index]; } - const T& operator[](size_t index) const noexcept { assert(index < m_size); return m_data[index]; } - - private: - std::array m_data; - size_t m_size; - }; - - //--------------------------------------------------------------------------------- - // Helper struct which maintains the working state of a new meshlet - //--------------------------------------------------------------------------------- - template - struct InlineMeshlet - { - StaticVector UniqueVertexIndices; - StaticVector PrimitiveIndices; - }; - - //--------------------------------------------------------------------------------- - // Computes normal vector from the points of a triangle - //--------------------------------------------------------------------------------- - inline XMVECTOR XM_CALLCONV ComputeNormal(_In_reads_(3) const XMFLOAT3* tri) noexcept - { - const XMVECTOR p0 = XMLoadFloat3(&tri[0]); - const XMVECTOR p1 = XMLoadFloat3(&tri[1]); - const XMVECTOR p2 = XMLoadFloat3(&tri[2]); - - const XMVECTOR v01 = XMVectorSubtract(p0, p1); - const XMVECTOR v02 = XMVectorSubtract(p0, p2); - - return XMVector3Normalize(XMVector3Cross(v01, v02)); - } - - //--------------------------------------------------------------------------------- - // Computes number of triangle vertices already exist in the meshlet - //--------------------------------------------------------------------------------- - template - uint8_t ComputeReuse(const InlineMeshlet& meshlet, _In_reads_(3) const T* triIndices) noexcept - { - uint8_t count = 0; - for (size_t i = 0; i < meshlet.UniqueVertexIndices.size(); ++i) - { - for (size_t j = 0; j < 3u; ++j) - { - if (meshlet.UniqueVertexIndices[i] == triIndices[j]) - { - assert(count < 255); - _Analysis_assume_(count < 255); - ++count; - } - } - } - - return count; - } - - //--------------------------------------------------------------------------------- - // Computes a candidacy score based on spatial locality, orientational coherence, - // and vertex re-use within a meshlet. - //--------------------------------------------------------------------------------- - template - float XM_CALLCONV ComputeScore( - const InlineMeshlet& meshlet, - FXMVECTOR sphere, - FXMVECTOR normal, - _In_reads_(3) const T* triIndices, - _In_reads_(3) const XMFLOAT3* triVerts) noexcept - { - // Configurable weighted sum parameters - constexpr float c_wtReuse = 0.334f; - constexpr float c_wtLocation = 0.333f; - constexpr float c_wtOrientation = 1.0f - (c_wtReuse + c_wtLocation); - - // Vertex reuse - - const uint8_t reuse = ComputeReuse(meshlet, triIndices); - const float scrReuse = 1.0f - (float(reuse) / 3.0f); - - // Distance from center point - log falloff to preserve normalization where it needs it - float maxSq = 0; - for (size_t i = 0; i < 3u; ++i) - { - const XMVECTOR pos = XMLoadFloat3(&triVerts[i]); - const XMVECTOR v = XMVectorSubtract(sphere, pos); - - const float distSq = XMVectorGetX(XMVector3Dot(v, v)); - maxSq = std::max(maxSq, distSq); - } - - const float r = XMVectorGetW(sphere); - const float r2 = r * r; - const float scrLocation = std::max(0.0f, log2f(maxSq / (r2 + FLT_EPSILON) + FLT_EPSILON)); - - // Angle between normal and meshlet cone axis - cosine falloff - const XMVECTOR n = ComputeNormal(triVerts); - const float d = XMVectorGetX(XMVector3Dot(n, normal)); - const float scrOrientation = (1.0f - d) * 0.5f; - - // Weighted sum of scores - return c_wtReuse * scrReuse + c_wtLocation * scrLocation + c_wtOrientation * scrOrientation; - } - - //--------------------------------------------------------------------------------- - // Attempts to add a candidate triangle to a meshlet - //--------------------------------------------------------------------------------- - template - bool TryAddToMeshlet( - size_t maxVerts, - size_t maxPrims, - _In_reads_(3) const T* tri, - InlineMeshlet& meshlet) - { - // Cull degenerate triangle and return success - // newCount calculation will break if such triangle is passed - if (tri[0] == tri[1] || tri[1] == tri[2] || tri[0] == tri[2]) - return true; - - // Are we already full of vertices? - if (meshlet.UniqueVertexIndices.size() >= maxVerts) - return false; - - // Are we full, or can we store an additional primitive? - if (meshlet.PrimitiveIndices.size() >= maxPrims) - return false; - - uint32_t indices[3] = { uint32_t(-1), uint32_t(-1), uint32_t(-1) }; - uint8_t newCount = 3; - - for (size_t i = 0; i < meshlet.UniqueVertexIndices.size(); ++i) - { - for (size_t j = 0; j < 3; ++j) - { - if (meshlet.UniqueVertexIndices[i] == tri[j]) - { - indices[j] = static_cast(i); - --newCount; - } - } - } - - // Will this triangle fit? - if (meshlet.UniqueVertexIndices.size() + newCount > maxVerts) - return false; - - // Add unique vertex indices to unique vertex index list - for (size_t j = 0; j < 3; ++j) - { - if (indices[j] == uint32_t(-1)) - { - indices[j] = static_cast(meshlet.UniqueVertexIndices.size()); - meshlet.UniqueVertexIndices.push_back(tri[j]); - } - } - - // Add the new primitive - MeshletTriangle mtri = { indices[0], indices[1], indices[2] }; - meshlet.PrimitiveIndices.emplace_back(mtri); - - return true; - } - - //--------------------------------------------------------------------------------- - // Determines whether a meshlet contains the maximum number of vertices/primitives - //--------------------------------------------------------------------------------- - template - inline bool IsMeshletFull(size_t maxVerts, size_t maxPrims, const InlineMeshlet& meshlet) noexcept - { - assert(meshlet.UniqueVertexIndices.size() <= maxVerts); - assert(meshlet.PrimitiveIndices.size() <= maxPrims); - - return meshlet.UniqueVertexIndices.size() >= maxVerts || meshlet.PrimitiveIndices.size() >= maxPrims; - } - - //--------------------------------------------------------------------------------- - // Meshletize a contiguous list of primitives - //--------------------------------------------------------------------------------- - template - HRESULT Meshletize( - size_t maxVerts, - size_t maxPrims, - _In_reads_(nFaces * 3) const T* indices, - size_t nFaces, - _In_reads_(nVerts) const XMFLOAT3* positions, - size_t nVerts, - const std::pair& subset, - _In_reads_(nFaces * 3) const uint32_t* adjacency, - std::vector>& meshlets) - { - if (!indices || !positions || !adjacency) - return E_INVALIDARG; - - if (subset.first + subset.second > nFaces) - return E_UNEXPECTED; - - meshlets.clear(); - - // Bitmask of all triangles in mesh to determine whether a specific one has been added - std::vector checklist; - checklist.resize(subset.second); - - // Cache to maintain scores for each candidate triangle - std::vector> candidates; - std::unordered_set candidateCheck; - - // Positions and normals of the current primitive - std::vector vertices; - std::vector normals; - - // Seed the candidate list with the first triangle of the subset - const uint32_t startIndex = static_cast(subset.first); - const uint32_t endIndex = static_cast(subset.first + subset.second); - - uint32_t triIndex = static_cast(subset.first); - - candidates.push_back(std::make_pair(triIndex, 0.0f)); - candidateCheck.insert(triIndex); - - // Continue adding triangles until triangle list is exhausted. - InlineMeshlet* curr = nullptr; - - while (!candidates.empty()) - { - uint32_t index = candidates.back().first; - candidates.pop_back(); - - T tri[3] = - { - indices[index * 3], - indices[index * 3 + 1], - indices[index * 3 + 2], - }; - - if (tri[0] >= nVerts || - tri[1] >= nVerts || - tri[2] >= nVerts) - { - return E_UNEXPECTED; - } - - // Create a new meshlet if necessary - if (curr == nullptr) - { - vertices.clear(); - normals.clear(); - - meshlets.emplace_back(); - curr = &meshlets.back(); - } - - // Try to add triangle to meshlet - if (TryAddToMeshlet(maxVerts, maxPrims, tri, *curr)) - { - // Success! Mark as added. - checklist[index - startIndex] = true; - - // Add positions & normal to list - const XMFLOAT3 points[3] = - { - positions[tri[0]], - positions[tri[1]], - positions[tri[2]], - }; - - vertices.push_back(points[0]); - vertices.push_back(points[1]); - vertices.push_back(points[2]); - - normals.emplace_back(); - XMStoreFloat3(&normals.back(), ComputeNormal(points)); - - // Compute new bounding sphere & normal axis - BoundingSphere positionBounds, normalBounds; - BoundingSphere::CreateFromPoints(positionBounds, vertices.size(), vertices.data(), sizeof(XMFLOAT3)); - BoundingSphere::CreateFromPoints(normalBounds, normals.size(), normals.data(), sizeof(XMFLOAT3)); - - const XMVECTOR psphere = XMLoadFloat4(reinterpret_cast(&positionBounds)); - const XMVECTOR normal = XMVector3Normalize(XMLoadFloat4(reinterpret_cast(&normalBounds))); - - // Find and add all applicable adjacent triangles to candidate list - const uint32_t adjIndex = index * 3; - - uint32_t adj[3] = - { - adjacency[adjIndex], - adjacency[adjIndex + 1], - adjacency[adjIndex + 2], - }; - - for (size_t i = 0; i < 3u; ++i) - { - // Invalid triangle in adjacency slot - if (adj[i] == uint32_t(-1)) - continue; - - // Primitive is outside the subset - if (adj[i] < subset.first || adj[i] > endIndex) - continue; - - // Already processed triangle - if (checklist[adj[i] - startIndex]) - continue; - - // Triangle already in the candidate list - if (candidateCheck.count(adj[i])) - continue; - - candidates.push_back(std::make_pair(adj[i], FLT_MAX)); - candidateCheck.insert(adj[i]); - } - - // Re-score remaining candidate triangles - for (size_t i = 0; i < candidates.size(); ++i) - { - uint32_t candidate = candidates[i].first; - - T triIndices[3] = - { - indices[candidate * 3], - indices[candidate * 3 + 1], - indices[candidate * 3 + 2], - }; - - if (triIndices[0] >= nVerts || - triIndices[1] >= nVerts || - triIndices[2] >= nVerts) - { - return E_UNEXPECTED; - } - - const XMFLOAT3 triVerts[3] = - { - positions[triIndices[0]], - positions[triIndices[1]], - positions[triIndices[2]], - }; - - candidates[i].second = ComputeScore(*curr, psphere, normal, triIndices, triVerts); - } - - // Determine whether we need to move to the next meshlet. - if (IsMeshletFull(maxVerts, maxPrims, *curr)) - { - candidateCheck.clear(); - curr = nullptr; - - // Discard candidates - one of our existing candidates as the next meshlet seed. - if (!candidates.empty()) - { - candidates[0] = candidates.back(); - candidates.resize(1); - candidateCheck.insert(candidates[0].first); - } - } - else - { - // Sort in reverse order to use vector as a queue with pop_back - std::stable_sort(candidates.begin(), candidates.end(), [](auto& a, auto& b) { return a.second > b.second; }); - } - } - else - { - // Ran out of candidates while attempting to fill the last bits of a meshlet. - if (candidates.empty()) - { - candidateCheck.clear(); - curr = nullptr; - - } - } - - // Ran out of candidates; add a new seed candidate to start the next meshlet. - if (candidates.empty()) - { - while (triIndex < endIndex && checklist[triIndex - startIndex]) - ++triIndex; - - if (triIndex == endIndex) - break; - - candidates.push_back(std::make_pair(triIndex, 0.0f)); - candidateCheck.insert(triIndex); - } - } - - return S_OK; - } - - //--------------------------------------------------------------------------------- - // Builds meshlets for a list of index subsets and organizes their data into - // corresponding output buffers. - //--------------------------------------------------------------------------------- - template - HRESULT ComputeMeshletsInternal( - _In_reads_(nFaces * 3) const T* indices, - size_t nFaces, - _In_reads_(nVerts) const XMFLOAT3* positions, - size_t nVerts, - _In_reads_(nSubsets) const std::pair* subsets, - size_t nSubsets, - _In_reads_opt_(nFaces * 3) const uint32_t* adjacency, - std::vector& meshlets, - std::vector& uniqueVertexIB, - std::vector& primitiveIndices, - _Out_writes_(nSubsets) std::pair* meshletSubsets, - size_t maxVerts, - size_t maxPrims) - { - if (!indices || !positions || !subsets || !meshletSubsets) - return E_INVALIDARG; - - // Validate the meshlet vertex & primitive sizes - if (maxVerts < MESHLET_MINIMUM_SIZE || maxVerts > MESHLET_MAXIMUM_SIZE) - return E_INVALIDARG; - - if (maxPrims < MESHLET_MINIMUM_SIZE || maxPrims > MESHLET_MAXIMUM_SIZE) - return E_INVALIDARG; - - if (nFaces == 0 || nVerts == 0 || nSubsets == 0) - return E_INVALIDARG; - - // Auto-generate adjacency data if not provided. - std::unique_ptr generatedAdj; - if (!adjacency) - { - generatedAdj.reset(new (std::nothrow) uint32_t[nFaces * 3]); - if (!generatedAdj) - return E_OUTOFMEMORY; - - HRESULT hr = GenerateAdjacencyAndPointReps(indices, nFaces, positions, nVerts, 0.0f, nullptr, generatedAdj.get()); - if (FAILED(hr)) - { - return hr; - } - - adjacency = generatedAdj.get(); - } - - // Now start generating meshlets - for (size_t i = 0; i < nSubsets; ++i) - { - auto& s = subsets[i]; - - if ((s.first + s.second) > nFaces) - { - return E_UNEXPECTED; - } - - std::vector> newMeshlets; - HRESULT hr = Meshletize(maxVerts, maxPrims, indices, nFaces, positions, nVerts, s, adjacency, newMeshlets); - if (FAILED(hr)) - { - return hr; - } - - meshletSubsets[i] = std::make_pair(meshlets.size(), newMeshlets.size()); - - // Determine final unique vertex index and primitive index counts & offsets. - size_t startVertCount = uniqueVertexIB.size() / sizeof(T); - size_t startPrimCount = primitiveIndices.size(); - - size_t uniqueVertexIndexCount = startVertCount; - size_t primitiveIndexCount = startPrimCount; - - // Resize the meshlet output array to hold the newly formed meshlets. - const size_t meshletCount = meshlets.size(); - meshlets.resize(meshletCount + newMeshlets.size()); - - Meshlet* dest = &meshlets[meshletCount]; - for (auto& m : newMeshlets) - { - dest->VertOffset = static_cast(uniqueVertexIndexCount); - dest->VertCount = static_cast(m.UniqueVertexIndices.size()); - - dest->PrimOffset = static_cast(primitiveIndexCount); - dest->PrimCount = static_cast(m.PrimitiveIndices.size()); - - uniqueVertexIndexCount += m.UniqueVertexIndices.size(); - primitiveIndexCount += m.PrimitiveIndices.size(); - - ++dest; - } - - // Allocate space for the new data. - uniqueVertexIB.resize(uniqueVertexIndexCount * sizeof(T)); - primitiveIndices.resize(primitiveIndexCount); - - // Copy data from the freshly built meshlets into the output buffers. - auto vertDest = reinterpret_cast(uniqueVertexIB.data()) + startVertCount; - auto primDest = reinterpret_cast(primitiveIndices.data()) + startPrimCount; - - for (auto& m : newMeshlets) - { - memcpy(vertDest, m.UniqueVertexIndices.data(), m.UniqueVertexIndices.size() * sizeof(T)); - memcpy(primDest, m.PrimitiveIndices.data(), m.PrimitiveIndices.size() * sizeof(uint32_t)); - - vertDest += m.UniqueVertexIndices.size(); - primDest += m.PrimitiveIndices.size(); - } - } - - return S_OK; - } - - - //--------------------------------------------------------------------------------- - // Generates culling data for a contiguous list of meshlets. - // Influenced by implementation in https://github.com/zeux/meshoptimizer - //--------------------------------------------------------------------------------- - template - HRESULT ComputeCullDataInternal( - _In_reads_(nVerts) const XMFLOAT3* positions, - size_t nVerts, - _In_reads_(nMeshlets) const Meshlet* meshlets, - size_t nMeshlets, - _In_reads_(nVertIndices) const T* uniqueVertexIndices, - size_t nVertIndices, - _In_reads_(nPrimIndices) const MeshletTriangle* primitiveIndices, - size_t nPrimIndices, - _Out_writes_(nMeshlets) CullData* cullData, - MESHLET_FLAGS flags) noexcept - { - // Input validation - if (!positions || !meshlets || !uniqueVertexIndices || !primitiveIndices || !cullData) - return E_INVALIDARG; - - if (nVerts == 0 || nMeshlets == 0 || nVertIndices == 0 || nPrimIndices == 0) - return E_INVALIDARG; - - // Cache for meshlet vertices & normals - XMFLOAT3 vertices[MESHLET_MAXIMUM_SIZE] = {}; - XMFLOAT3 normals[MESHLET_MAXIMUM_SIZE] = {}; - - for (size_t mi = 0; mi < nMeshlets; ++mi) - { - auto& m = meshlets[mi]; - auto& c = cullData[mi]; - - // Cache vertices - for (size_t i = 0; i < m.VertCount; ++i) - { - if (m.VertOffset + i >= nVertIndices) - { - return E_UNEXPECTED; - } - - const uint32_t vIndex = uniqueVertexIndices[m.VertOffset + i]; - - if (vIndex >= nVerts) - { - return E_UNEXPECTED; - } - - vertices[i] = positions[vIndex]; - } - - // Generate primitive normals & cache - for (size_t i = 0; i < m.PrimCount; ++i) - { - if (m.PrimOffset + i >= nPrimIndices) - { - return E_UNEXPECTED; - } - - auto primitive = primitiveIndices[m.PrimOffset + i]; - - const XMFLOAT3 triangle[3] - { - vertices[primitive.i0], - vertices[primitive.i1], - vertices[primitive.i2], - }; - - XMVECTOR n = ComputeNormal(triangle); - n = (flags & MESHLET_WIND_CW) != 0 ? XMVectorNegate(n) : n; - - XMStoreFloat3(&normals[i], n); - } - - // Calculate spatial bounds - BoundingSphere::CreateFromPoints(c.BoundingSphere, m.VertCount, vertices, sizeof(XMFLOAT3)); - const XMVECTOR positionBounds = XMLoadFloat4(reinterpret_cast(&c.BoundingSphere)); - - // Calculate the normal cone - // 1. Normalized center point of minimum bounding sphere of unit normals == conic axis - BoundingSphere nsphere; - BoundingSphere::CreateFromPoints(nsphere, m.PrimCount, normals, sizeof(XMFLOAT3)); - - // 2. Calculate dot product of all normals to conic axis, selecting minimum - const XMVECTOR normalBounds = XMLoadFloat4(reinterpret_cast(&nsphere)); - const XMVECTOR axis = XMVectorSetW(XMVector3Normalize(normalBounds), 0); - - XMVECTOR minDot = g_XMOne; - for (size_t i = 0; i < m.PrimCount; ++i) - { - const XMVECTOR dot = XMVector3Dot(axis, XMLoadFloat3(&normals[i])); - minDot = XMVectorMin(minDot, dot); - } - - if (XMVector4Less(minDot, XMVectorReplicate(0.1f))) - { - XMStoreUByteN4(&c.NormalCone, XMVectorSet(0, 0, 0, 1)); // Degenerate cone - continue; - } - - // Find the point on center-t*axis ray that lies in negative half-space of all triangles - float maxt = 0; - - for (size_t i = 0; i < m.PrimCount; ++i) - { - if (m.PrimOffset + i >= nPrimIndices) - { - return E_UNEXPECTED; - } - - auto const primitive = primitiveIndices[m.PrimOffset + i]; - - const XMVECTOR p0 = XMLoadFloat3(&vertices[primitive.i0]); - - const XMVECTOR center = XMVectorSubtract(positionBounds, p0); - const XMVECTOR normal = XMLoadFloat3(&normals[i]); - - const float dc = XMVectorGetX(XMVector3Dot(center, normal)); - const float dn = XMVectorGetX(XMVector3Dot(axis, normal)); - - // dn should be larger than mindp cutoff above - if (dn <= 0.0f) - { - return E_UNEXPECTED; - } - - const float t = dc / dn; - maxt = (t > maxt) ? t : maxt; - } - - // cone apex should be in the negative half-space of all cluster triangles by construction - c.ApexOffset = maxt; - - // cos(a) for normal cone is minDot; we need to add 90 degrees on both sides and invert the cone - // which gives us -cos(a+90) = -(-sin(a)) = sin(a) = sqrt(1 - cos^2(a)) - const XMVECTOR minDotSq = XMVectorMultiply(minDot, minDot); - XMVECTOR coneCutoff = XMVectorSqrt(XMVectorSubtract(g_XMOne, minDotSq)); - - // Quantize normal vector to uint8 - XMBYTEN4 snquant; - XMStoreByteN4(&snquant, axis); - - c.NormalCone.x = uint8_t(int16_t(snquant.x) + 128); - c.NormalCone.y = uint8_t(int16_t(snquant.y) + 128); - c.NormalCone.z = uint8_t(int16_t(snquant.z) + 128); - - // Calculate error bias from quantization - const XMVECTOR dequant = XMLoadByteN4(&snquant); - const XMVECTOR error = XMVectorSum(XMVectorAbs(XMVectorSubtract(dequant, axis))); - - // Add error bias to cone cutoff - coneCutoff = XMVectorAdd(coneCutoff, error); - - // Quantize normal cone spread to uint8 and bias upward - XMUBYTEN4 nquant; - XMStoreUByteN4(&nquant, coneCutoff); - - c.NormalCone.w = nquant.x; - } - - return S_OK; - } -} - - -//===================================================================================== -// Entry-points -//===================================================================================== - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::ComputeMeshlets( - const uint16_t* indices, - size_t nFaces, - const XMFLOAT3* positions, - size_t nVerts, - const uint32_t* adjacency, - std::vector& meshlets, - std::vector& uniqueVertexIB, - std::vector& primitiveIndices, - size_t maxVerts, - size_t maxPrims) -{ - const std::pair s = { 0, nFaces }; - std::pair subset; - - return ComputeMeshletsInternal( - indices, nFaces, - positions, nVerts, - &s, 1u, - adjacency, - meshlets, - uniqueVertexIB, primitiveIndices, - &subset, - maxVerts, maxPrims); -} - -_Use_decl_annotations_ -HRESULT DirectX::ComputeMeshlets( - const uint32_t* indices, - size_t nFaces, - const XMFLOAT3* positions, - size_t nVerts, - const uint32_t* adjacency, - std::vector& meshlets, - std::vector& uniqueVertexIB, - std::vector& primitiveIndices, - size_t maxVerts, - size_t maxPrims) -{ - const std::pair s = { 0, nFaces }; - std::pair subset; - - return ComputeMeshletsInternal( - indices, nFaces, - positions, nVerts, - &s, 1u, - adjacency, - meshlets, - uniqueVertexIB, primitiveIndices, - &subset, - maxVerts, maxPrims); -} - -_Use_decl_annotations_ -HRESULT DirectX::ComputeMeshlets( - const uint16_t* indices, - size_t nFaces, - const XMFLOAT3* positions, - size_t nVerts, - const std::pair* subsets, - size_t nSubsets, - const uint32_t* adjacency, - std::vector& meshlets, - std::vector& uniqueVertexIB, - std::vector& primitiveIndices, - std::pair* meshletSubsets, - size_t maxVerts, - size_t maxPrims) -{ - return ComputeMeshletsInternal( - indices, nFaces, - positions, nVerts, - subsets, nSubsets, - adjacency, - meshlets, - uniqueVertexIB, primitiveIndices, meshletSubsets, - maxVerts, maxPrims); -} - -_Use_decl_annotations_ -HRESULT DirectX::ComputeMeshlets( - const uint32_t* indices, - size_t nFaces, - const XMFLOAT3* positions, - size_t nVerts, - const std::pair* subsets, - size_t nSubsets, - const uint32_t* adjacency, - std::vector& meshlets, - std::vector& uniqueVertexIB, - std::vector& primitiveIndices, - std::pair* meshletSubsets, - size_t maxVerts, - size_t maxPrims) -{ - return ComputeMeshletsInternal( - indices, nFaces, - positions, nVerts, - subsets, nSubsets, - adjacency, - meshlets, - uniqueVertexIB, - primitiveIndices, - meshletSubsets, - maxVerts, maxPrims); -} - -_Use_decl_annotations_ -HRESULT DirectX::ComputeCullData( - const XMFLOAT3* positions, - size_t nVerts, - const Meshlet* meshlets, - size_t nMeshlets, - const uint16_t* uniqueVertexIndices, - size_t nVertIndices, - const MeshletTriangle* primitiveIndices, - size_t nPrimIndices, - CullData* cullData, - MESHLET_FLAGS flags) noexcept -{ - return ComputeCullDataInternal( - positions, nVerts, - meshlets, nMeshlets, - uniqueVertexIndices, nVertIndices, - primitiveIndices, nPrimIndices, - cullData, flags); -} - -_Use_decl_annotations_ -HRESULT DirectX::ComputeCullData( - const XMFLOAT3* positions, - size_t nVerts, - const Meshlet* meshlets, - size_t nMeshlets, - const uint32_t* uniqueVertexIndices, - size_t nVertIndices, - const MeshletTriangle* primitiveIndices, - size_t nPrimIndices, - CullData* cullData, - MESHLET_FLAGS flags) noexcept -{ - return ComputeCullDataInternal( - positions, nVerts, - meshlets, nMeshlets, - uniqueVertexIndices, nVertIndices, - primitiveIndices, nPrimIndices, - cullData, - flags); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/scoped.h b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/scoped.h deleted file mode 100644 index 363c393..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh/scoped.h +++ /dev/null @@ -1,112 +0,0 @@ -//------------------------------------------------------------------------------------- -// scoped.h -// -// Utility header with helper classes for exception-safe handling of resources -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -//------------------------------------------------------------------------------------- - -#pragma once - -#include -#include -#include -#include -#include - -#ifndef _WIN32 -#include - -struct aligned_deleter { void operator()(void* p) noexcept { free(p); } }; - -using ScopedAlignedArrayFloat = std::unique_ptr; - -inline ScopedAlignedArrayFloat make_AlignedArrayFloat(uint64_t count) -{ - uint64_t size = sizeof(float) * count; - size = (size + 15u) & ~0xF; - if (size > static_cast(UINT32_MAX)) - return nullptr; - - auto ptr = aligned_alloc(16, static_cast(size)); - return ScopedAlignedArrayFloat(static_cast(ptr)); -} - -using ScopedAlignedArrayXMVECTOR = std::unique_ptr; - -inline ScopedAlignedArrayXMVECTOR make_AlignedArrayXMVECTOR(uint64_t count) -{ - uint64_t size = sizeof(DirectX::XMVECTOR) * count; - if (size > static_cast(UINT32_MAX)) - return nullptr; - auto ptr = aligned_alloc(16, static_cast(size)); - return ScopedAlignedArrayXMVECTOR(static_cast(ptr)); -} - -#else // WIN32 -//--------------------------------------------------------------------------------- -#include - -struct aligned_deleter { void operator()(void* p) noexcept { _aligned_free(p); } }; - -using ScopedAlignedArrayFloat = std::unique_ptr; - -inline ScopedAlignedArrayFloat make_AlignedArrayFloat(uint64_t count) -{ - const uint64_t size = sizeof(float) * count; - if (size > static_cast(UINT32_MAX)) - return nullptr; - auto ptr = _aligned_malloc(static_cast(size), 16); - return ScopedAlignedArrayFloat(static_cast(ptr)); -} - -using ScopedAlignedArrayXMVECTOR = std::unique_ptr; - -inline ScopedAlignedArrayXMVECTOR make_AlignedArrayXMVECTOR(uint64_t count) -{ - const uint64_t size = sizeof(DirectX::XMVECTOR) * count; - if (size > static_cast(UINT32_MAX)) - return nullptr; - auto ptr = _aligned_malloc(static_cast(size), 16); - return ScopedAlignedArrayXMVECTOR(static_cast(ptr)); -} - -//--------------------------------------------------------------------------------- -struct handle_closer { void operator()(HANDLE h) noexcept { assert(h != INVALID_HANDLE_VALUE); if (h) CloseHandle(h); } }; - -using ScopedHandle = std::unique_ptr; - -inline HANDLE safe_handle(HANDLE h) noexcept { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; } - -//--------------------------------------------------------------------------------- -struct find_closer { void operator()(HANDLE h) noexcept { assert(h != INVALID_HANDLE_VALUE); if (h) FindClose(h); } }; - -using ScopedFindHandle = std::unique_ptr; - -//--------------------------------------------------------------------------------- -class auto_delete_file -{ -public: - auto_delete_file(HANDLE hFile) noexcept : m_handle(hFile) {} - - auto_delete_file(const auto_delete_file&) = delete; - auto_delete_file& operator=(const auto_delete_file&) = delete; - - ~auto_delete_file() - { - if (m_handle) - { - FILE_DISPOSITION_INFO info = {}; - info.DeleteFile = TRUE; - std::ignore = SetFileInformationByHandle(m_handle, FileDispositionInfo, &info, sizeof(info)); - } - } - - void clear() noexcept { m_handle = nullptr; } - -private: - HANDLE m_handle; -}; - -#endif // WIN32 diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh_Desktop_2019.sln b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh_Desktop_2019.sln deleted file mode 100644 index c805054..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh_Desktop_2019.sln +++ /dev/null @@ -1,55 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.28621.142 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXMesh", "DirectXMesh\DirectXMesh_Desktop_2019.vcxproj", "{6857F086-F6FE-4150-9ED7-7446F1C1C220}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "meshconvert", "Meshconvert\Meshconvert_Desktop_2019.vcxproj", "{6D4CFD0E-8772-462A-9AC1-7DBAD9C16880}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D7B83B71-AA03-4455-8959-C90D06581953}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x86 = Debug|x86 - Debug|x64 = Debug|x64 - Profile|x86 = Profile|x86 - Profile|x64 = Profile|x64 - Release|x86 = Release|x86 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Debug|x86.ActiveCfg = Debug|Win32 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Debug|x86.Build.0 = Debug|Win32 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Debug|x64.ActiveCfg = Debug|x64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Debug|x64.Build.0 = Debug|x64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Profile|x86.ActiveCfg = Profile|Win32 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Profile|x86.Build.0 = Profile|Win32 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Profile|x64.ActiveCfg = Profile|x64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Profile|x64.Build.0 = Profile|x64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Release|x86.ActiveCfg = Release|Win32 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Release|x86.Build.0 = Release|Win32 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Release|x64.ActiveCfg = Release|x64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Release|x64.Build.0 = Release|x64 - {6D4CFD0E-8772-462A-9AC1-7DBAD9C16880}.Debug|x86.ActiveCfg = Debug|Win32 - {6D4CFD0E-8772-462A-9AC1-7DBAD9C16880}.Debug|x86.Build.0 = Debug|Win32 - {6D4CFD0E-8772-462A-9AC1-7DBAD9C16880}.Debug|x64.ActiveCfg = Debug|x64 - {6D4CFD0E-8772-462A-9AC1-7DBAD9C16880}.Debug|x64.Build.0 = Debug|x64 - {6D4CFD0E-8772-462A-9AC1-7DBAD9C16880}.Profile|x86.ActiveCfg = Profile|Win32 - {6D4CFD0E-8772-462A-9AC1-7DBAD9C16880}.Profile|x86.Build.0 = Profile|Win32 - {6D4CFD0E-8772-462A-9AC1-7DBAD9C16880}.Profile|x64.ActiveCfg = Profile|x64 - {6D4CFD0E-8772-462A-9AC1-7DBAD9C16880}.Profile|x64.Build.0 = Profile|x64 - {6D4CFD0E-8772-462A-9AC1-7DBAD9C16880}.Release|x86.ActiveCfg = Release|Win32 - {6D4CFD0E-8772-462A-9AC1-7DBAD9C16880}.Release|x86.Build.0 = Release|Win32 - {6D4CFD0E-8772-462A-9AC1-7DBAD9C16880}.Release|x64.ActiveCfg = Release|x64 - {6D4CFD0E-8772-462A-9AC1-7DBAD9C16880}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {5C389688-21F3-4661-9802-2A73B2AD857F} - EndGlobalSection -EndGlobal diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh_Desktop_2019_Win10.sln b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh_Desktop_2019_Win10.sln deleted file mode 100644 index 538361f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh_Desktop_2019_Win10.sln +++ /dev/null @@ -1,50 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29609.76 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXMesh", "DirectXMesh\DirectXMesh_Desktop_2019_Win10.vcxproj", "{6857F086-F6FE-4150-9ED7-7446F1C1C220}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C688B690-29CD-47AA-BF43-EF1BA44BC5AC}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|ARM64 = Debug|ARM64 - Debug|x86 = Debug|x86 - Debug|x64 = Debug|x64 - Profile|ARM64 = Profile|ARM64 - Profile|x86 = Profile|x86 - Profile|x64 = Profile|x64 - Release|ARM64 = Release|ARM64 - Release|x86 = Release|x86 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Debug|ARM64.Build.0 = Debug|ARM64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Debug|x86.ActiveCfg = Debug|Win32 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Debug|x86.Build.0 = Debug|Win32 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Debug|x64.ActiveCfg = Debug|x64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Debug|x64.Build.0 = Debug|x64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Profile|ARM64.ActiveCfg = Profile|ARM64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Profile|ARM64.Build.0 = Profile|ARM64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Profile|x86.ActiveCfg = Profile|Win32 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Profile|x86.Build.0 = Profile|Win32 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Profile|x64.ActiveCfg = Profile|x64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Profile|x64.Build.0 = Profile|x64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Release|ARM64.ActiveCfg = Release|ARM64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Release|ARM64.Build.0 = Release|ARM64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Release|x86.ActiveCfg = Release|Win32 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Release|x86.Build.0 = Release|Win32 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Release|x64.ActiveCfg = Release|x64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {D04D9571-DDE4-4F6F-A7E1-0EBB08CFC482} - EndGlobalSection -EndGlobal diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh_Desktop_2022.sln b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh_Desktop_2022.sln deleted file mode 100644 index d3c9db3..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh_Desktop_2022.sln +++ /dev/null @@ -1,55 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 16.0.28621.142 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXMesh", "DirectXMesh\DirectXMesh_Desktop_2022.vcxproj", "{6857F086-F6FE-4150-9ED7-7446F1C1C220}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "meshconvert", "Meshconvert\Meshconvert_Desktop_2022.vcxproj", "{6D4CFD0E-8772-462A-9AC1-7DBAD9C16880}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D7B83B71-AA03-4455-8959-C90D06581953}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x86 = Debug|x86 - Debug|x64 = Debug|x64 - Profile|x86 = Profile|x86 - Profile|x64 = Profile|x64 - Release|x86 = Release|x86 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Debug|x86.ActiveCfg = Debug|Win32 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Debug|x86.Build.0 = Debug|Win32 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Debug|x64.ActiveCfg = Debug|x64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Debug|x64.Build.0 = Debug|x64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Profile|x86.ActiveCfg = Profile|Win32 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Profile|x86.Build.0 = Profile|Win32 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Profile|x64.ActiveCfg = Profile|x64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Profile|x64.Build.0 = Profile|x64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Release|x86.ActiveCfg = Release|Win32 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Release|x86.Build.0 = Release|Win32 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Release|x64.ActiveCfg = Release|x64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Release|x64.Build.0 = Release|x64 - {6D4CFD0E-8772-462A-9AC1-7DBAD9C16880}.Debug|x86.ActiveCfg = Debug|Win32 - {6D4CFD0E-8772-462A-9AC1-7DBAD9C16880}.Debug|x86.Build.0 = Debug|Win32 - {6D4CFD0E-8772-462A-9AC1-7DBAD9C16880}.Debug|x64.ActiveCfg = Debug|x64 - {6D4CFD0E-8772-462A-9AC1-7DBAD9C16880}.Debug|x64.Build.0 = Debug|x64 - {6D4CFD0E-8772-462A-9AC1-7DBAD9C16880}.Profile|x86.ActiveCfg = Profile|Win32 - {6D4CFD0E-8772-462A-9AC1-7DBAD9C16880}.Profile|x86.Build.0 = Profile|Win32 - {6D4CFD0E-8772-462A-9AC1-7DBAD9C16880}.Profile|x64.ActiveCfg = Profile|x64 - {6D4CFD0E-8772-462A-9AC1-7DBAD9C16880}.Profile|x64.Build.0 = Profile|x64 - {6D4CFD0E-8772-462A-9AC1-7DBAD9C16880}.Release|x86.ActiveCfg = Release|Win32 - {6D4CFD0E-8772-462A-9AC1-7DBAD9C16880}.Release|x86.Build.0 = Release|Win32 - {6D4CFD0E-8772-462A-9AC1-7DBAD9C16880}.Release|x64.ActiveCfg = Release|x64 - {6D4CFD0E-8772-462A-9AC1-7DBAD9C16880}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {5C389688-21F3-4661-9802-2A73B2AD857F} - EndGlobalSection -EndGlobal diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh_Desktop_2022_Win10.sln b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh_Desktop_2022_Win10.sln deleted file mode 100644 index d566277..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh_Desktop_2022_Win10.sln +++ /dev/null @@ -1,50 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 16.0.29609.76 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXMesh", "DirectXMesh\DirectXMesh_Desktop_2022_Win10.vcxproj", "{6857F086-F6FE-4150-9ED7-7446F1C1C220}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C688B690-29CD-47AA-BF43-EF1BA44BC5AC}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|ARM64 = Debug|ARM64 - Debug|x86 = Debug|x86 - Debug|x64 = Debug|x64 - Profile|ARM64 = Profile|ARM64 - Profile|x86 = Profile|x86 - Profile|x64 = Profile|x64 - Release|ARM64 = Release|ARM64 - Release|x86 = Release|x86 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Debug|ARM64.Build.0 = Debug|ARM64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Debug|x86.ActiveCfg = Debug|Win32 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Debug|x86.Build.0 = Debug|Win32 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Debug|x64.ActiveCfg = Debug|x64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Debug|x64.Build.0 = Debug|x64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Profile|ARM64.ActiveCfg = Profile|ARM64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Profile|ARM64.Build.0 = Profile|ARM64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Profile|x86.ActiveCfg = Profile|Win32 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Profile|x86.Build.0 = Profile|Win32 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Profile|x64.ActiveCfg = Profile|x64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Profile|x64.Build.0 = Profile|x64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Release|ARM64.ActiveCfg = Release|ARM64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Release|ARM64.Build.0 = Release|ARM64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Release|x86.ActiveCfg = Release|Win32 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Release|x86.Build.0 = Release|Win32 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Release|x64.ActiveCfg = Release|x64 - {6857F086-F6FE-4150-9ED7-7446F1C1C220}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {D04D9571-DDE4-4F6F-A7E1-0EBB08CFC482} - EndGlobalSection -EndGlobal diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh_GDK_2019.sln b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh_GDK_2019.sln deleted file mode 100644 index 5694f2e..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh_GDK_2019.sln +++ /dev/null @@ -1,51 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30404.54 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXMesh_GDK_2019", "DirectXMesh\DirectXMesh_GDK_2019.vcxproj", "{0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DBC86AB6-3D3C-4879-8DD7-3CFC505ABAC4}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Gaming.Desktop.x64 = Debug|Gaming.Desktop.x64 - Debug|Gaming.Xbox.Scarlett.x64 = Debug|Gaming.Xbox.Scarlett.x64 - Debug|Gaming.Xbox.XboxOne.x64 = Debug|Gaming.Xbox.XboxOne.x64 - Profile|Gaming.Desktop.x64 = Profile|Gaming.Desktop.x64 - Profile|Gaming.Xbox.Scarlett.x64 = Profile|Gaming.Xbox.Scarlett.x64 - Profile|Gaming.Xbox.XboxOne.x64 = Profile|Gaming.Xbox.XboxOne.x64 - Release|Gaming.Desktop.x64 = Release|Gaming.Desktop.x64 - Release|Gaming.Xbox.Scarlett.x64 = Release|Gaming.Xbox.Scarlett.x64 - Release|Gaming.Xbox.XboxOne.x64 = Release|Gaming.Xbox.XboxOne.x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Debug|Gaming.Desktop.x64.ActiveCfg = Debug|Gaming.Desktop.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Debug|Gaming.Desktop.x64.Build.0 = Debug|Gaming.Desktop.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Debug|Gaming.Xbox.Scarlett.x64.ActiveCfg = Debug|Gaming.Xbox.Scarlett.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Debug|Gaming.Xbox.Scarlett.x64.Build.0 = Debug|Gaming.Xbox.Scarlett.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Debug|Gaming.Xbox.XboxOne.x64.ActiveCfg = Debug|Gaming.Xbox.XboxOne.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Debug|Gaming.Xbox.XboxOne.x64.Build.0 = Debug|Gaming.Xbox.XboxOne.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Profile|Gaming.Desktop.x64.ActiveCfg = Profile|Gaming.Desktop.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Profile|Gaming.Desktop.x64.Build.0 = Profile|Gaming.Desktop.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Profile|Gaming.Xbox.Scarlett.x64.ActiveCfg = Profile|Gaming.Xbox.Scarlett.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Profile|Gaming.Xbox.Scarlett.x64.Build.0 = Profile|Gaming.Xbox.Scarlett.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Profile|Gaming.Xbox.XboxOne.x64.ActiveCfg = Profile|Gaming.Xbox.XboxOne.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Profile|Gaming.Xbox.XboxOne.x64.Build.0 = Profile|Gaming.Xbox.XboxOne.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Release|Gaming.Desktop.x64.ActiveCfg = Release|Gaming.Desktop.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Release|Gaming.Desktop.x64.Build.0 = Release|Gaming.Desktop.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Release|Gaming.Xbox.Scarlett.x64.ActiveCfg = Release|Gaming.Xbox.Scarlett.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Release|Gaming.Xbox.Scarlett.x64.Build.0 = Release|Gaming.Xbox.Scarlett.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Release|Gaming.Xbox.XboxOne.x64.ActiveCfg = Release|Gaming.Xbox.XboxOne.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Release|Gaming.Xbox.XboxOne.x64.Build.0 = Release|Gaming.Xbox.XboxOne.x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {7C261958-9DC2-41CC-A677-D8507C24FCDF} - EndGlobalSection -EndGlobal diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh_GDK_2022.sln b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh_GDK_2022.sln deleted file mode 100644 index 2806175..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh_GDK_2022.sln +++ /dev/null @@ -1,51 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 16.0.30404.54 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXMesh_GDK_2022", "DirectXMesh\DirectXMesh_GDK_2022.vcxproj", "{0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DBC86AB6-3D3C-4879-8DD7-3CFC505ABAC4}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Gaming.Desktop.x64 = Debug|Gaming.Desktop.x64 - Debug|Gaming.Xbox.Scarlett.x64 = Debug|Gaming.Xbox.Scarlett.x64 - Debug|Gaming.Xbox.XboxOne.x64 = Debug|Gaming.Xbox.XboxOne.x64 - Profile|Gaming.Desktop.x64 = Profile|Gaming.Desktop.x64 - Profile|Gaming.Xbox.Scarlett.x64 = Profile|Gaming.Xbox.Scarlett.x64 - Profile|Gaming.Xbox.XboxOne.x64 = Profile|Gaming.Xbox.XboxOne.x64 - Release|Gaming.Desktop.x64 = Release|Gaming.Desktop.x64 - Release|Gaming.Xbox.Scarlett.x64 = Release|Gaming.Xbox.Scarlett.x64 - Release|Gaming.Xbox.XboxOne.x64 = Release|Gaming.Xbox.XboxOne.x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Debug|Gaming.Desktop.x64.ActiveCfg = Debug|Gaming.Desktop.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Debug|Gaming.Desktop.x64.Build.0 = Debug|Gaming.Desktop.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Debug|Gaming.Xbox.Scarlett.x64.ActiveCfg = Debug|Gaming.Xbox.Scarlett.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Debug|Gaming.Xbox.Scarlett.x64.Build.0 = Debug|Gaming.Xbox.Scarlett.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Debug|Gaming.Xbox.XboxOne.x64.ActiveCfg = Debug|Gaming.Xbox.XboxOne.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Debug|Gaming.Xbox.XboxOne.x64.Build.0 = Debug|Gaming.Xbox.XboxOne.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Profile|Gaming.Desktop.x64.ActiveCfg = Profile|Gaming.Desktop.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Profile|Gaming.Desktop.x64.Build.0 = Profile|Gaming.Desktop.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Profile|Gaming.Xbox.Scarlett.x64.ActiveCfg = Profile|Gaming.Xbox.Scarlett.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Profile|Gaming.Xbox.Scarlett.x64.Build.0 = Profile|Gaming.Xbox.Scarlett.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Profile|Gaming.Xbox.XboxOne.x64.ActiveCfg = Profile|Gaming.Xbox.XboxOne.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Profile|Gaming.Xbox.XboxOne.x64.Build.0 = Profile|Gaming.Xbox.XboxOne.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Release|Gaming.Desktop.x64.ActiveCfg = Release|Gaming.Desktop.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Release|Gaming.Desktop.x64.Build.0 = Release|Gaming.Desktop.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Release|Gaming.Xbox.Scarlett.x64.ActiveCfg = Release|Gaming.Xbox.Scarlett.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Release|Gaming.Xbox.Scarlett.x64.Build.0 = Release|Gaming.Xbox.Scarlett.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Release|Gaming.Xbox.XboxOne.x64.ActiveCfg = Release|Gaming.Xbox.XboxOne.x64 - {0B019AFB-D02B-430A-9331-B2A9D6D9C0C3}.Release|Gaming.Xbox.XboxOne.x64.Build.0 = Release|Gaming.Xbox.XboxOne.x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {7C261958-9DC2-41CC-A677-D8507C24FCDF} - EndGlobalSection -EndGlobal diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh_Windows10_2019.sln b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh_Windows10_2019.sln deleted file mode 100644 index 4fab423..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh_Windows10_2019.sln +++ /dev/null @@ -1,48 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27703.2000 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXMesh", "DirectXMesh\DirectXMesh_Windows10_2019.vcxproj", "{107A408E-C148-4594-B469-075FE0ADB7A5}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2562D7DA-2CF1-432C-9CC8-DAF8C477CF14}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|ARM = Debug|ARM - Debug|ARM64 = Debug|ARM64 - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|ARM = Release|ARM - Release|ARM64 = Release|ARM64 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {107A408E-C148-4594-B469-075FE0ADB7A5}.Debug|ARM.ActiveCfg = Debug|ARM - {107A408E-C148-4594-B469-075FE0ADB7A5}.Debug|ARM.Build.0 = Debug|ARM - {107A408E-C148-4594-B469-075FE0ADB7A5}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {107A408E-C148-4594-B469-075FE0ADB7A5}.Debug|ARM64.Build.0 = Debug|ARM64 - {107A408E-C148-4594-B469-075FE0ADB7A5}.Debug|x64.ActiveCfg = Debug|x64 - {107A408E-C148-4594-B469-075FE0ADB7A5}.Debug|x64.Build.0 = Debug|x64 - {107A408E-C148-4594-B469-075FE0ADB7A5}.Debug|x86.ActiveCfg = Debug|Win32 - {107A408E-C148-4594-B469-075FE0ADB7A5}.Debug|x86.Build.0 = Debug|Win32 - {107A408E-C148-4594-B469-075FE0ADB7A5}.Release|ARM.ActiveCfg = Release|ARM - {107A408E-C148-4594-B469-075FE0ADB7A5}.Release|ARM.Build.0 = Release|ARM - {107A408E-C148-4594-B469-075FE0ADB7A5}.Release|ARM64.ActiveCfg = Release|ARM64 - {107A408E-C148-4594-B469-075FE0ADB7A5}.Release|ARM64.Build.0 = Release|ARM64 - {107A408E-C148-4594-B469-075FE0ADB7A5}.Release|x64.ActiveCfg = Release|x64 - {107A408E-C148-4594-B469-075FE0ADB7A5}.Release|x64.Build.0 = Release|x64 - {107A408E-C148-4594-B469-075FE0ADB7A5}.Release|x86.ActiveCfg = Release|Win32 - {107A408E-C148-4594-B469-075FE0ADB7A5}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {FDDF6E4C-931A-428D-B05C-23AE1228CFF6} - EndGlobalSection -EndGlobal diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh_Windows10_2022.sln b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh_Windows10_2022.sln deleted file mode 100644 index 527f3a5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh_Windows10_2022.sln +++ /dev/null @@ -1,48 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 15.0.27703.2000 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXMesh", "DirectXMesh\DirectXMesh_Windows10_2022.vcxproj", "{107A408E-C148-4594-B469-075FE0ADB7A5}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2562D7DA-2CF1-432C-9CC8-DAF8C477CF14}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|ARM = Debug|ARM - Debug|ARM64 = Debug|ARM64 - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|ARM = Release|ARM - Release|ARM64 = Release|ARM64 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {107A408E-C148-4594-B469-075FE0ADB7A5}.Debug|ARM.ActiveCfg = Debug|ARM - {107A408E-C148-4594-B469-075FE0ADB7A5}.Debug|ARM.Build.0 = Debug|ARM - {107A408E-C148-4594-B469-075FE0ADB7A5}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {107A408E-C148-4594-B469-075FE0ADB7A5}.Debug|ARM64.Build.0 = Debug|ARM64 - {107A408E-C148-4594-B469-075FE0ADB7A5}.Debug|x64.ActiveCfg = Debug|x64 - {107A408E-C148-4594-B469-075FE0ADB7A5}.Debug|x64.Build.0 = Debug|x64 - {107A408E-C148-4594-B469-075FE0ADB7A5}.Debug|x86.ActiveCfg = Debug|Win32 - {107A408E-C148-4594-B469-075FE0ADB7A5}.Debug|x86.Build.0 = Debug|Win32 - {107A408E-C148-4594-B469-075FE0ADB7A5}.Release|ARM.ActiveCfg = Release|ARM - {107A408E-C148-4594-B469-075FE0ADB7A5}.Release|ARM.Build.0 = Release|ARM - {107A408E-C148-4594-B469-075FE0ADB7A5}.Release|ARM64.ActiveCfg = Release|ARM64 - {107A408E-C148-4594-B469-075FE0ADB7A5}.Release|ARM64.Build.0 = Release|ARM64 - {107A408E-C148-4594-B469-075FE0ADB7A5}.Release|x64.ActiveCfg = Release|x64 - {107A408E-C148-4594-B469-075FE0ADB7A5}.Release|x64.Build.0 = Release|x64 - {107A408E-C148-4594-B469-075FE0ADB7A5}.Release|x86.ActiveCfg = Release|Win32 - {107A408E-C148-4594-B469-075FE0ADB7A5}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {FDDF6E4C-931A-428D-B05C-23AE1228CFF6} - EndGlobalSection -EndGlobal diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh_XboxOneXDK_2017.sln b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh_XboxOneXDK_2017.sln deleted file mode 100644 index b236e85..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/DirectXMesh_XboxOneXDK_2017.sln +++ /dev/null @@ -1,33 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27703.2000 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXMesh_XboxOneXDK_2017", "DirectXMesh\DirectXMesh_XboxOneXDK_2017.vcxproj", "{1A920EF0-11D7-4A11-9AB7-63C4424AD096}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7DA88FAE-49D7-4C30-8808-5E5642768C8B}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Durango = Debug|Durango - Profile|Durango = Profile|Durango - Release|Durango = Release|Durango - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1A920EF0-11D7-4A11-9AB7-63C4424AD096}.Debug|Durango.ActiveCfg = Debug|Durango - {1A920EF0-11D7-4A11-9AB7-63C4424AD096}.Debug|Durango.Build.0 = Debug|Durango - {1A920EF0-11D7-4A11-9AB7-63C4424AD096}.Profile|Durango.ActiveCfg = Profile|Durango - {1A920EF0-11D7-4A11-9AB7-63C4424AD096}.Profile|Durango.Build.0 = Profile|Durango - {1A920EF0-11D7-4A11-9AB7-63C4424AD096}.Release|Durango.ActiveCfg = Release|Durango - {1A920EF0-11D7-4A11-9AB7-63C4424AD096}.Release|Durango.Build.0 = Release|Durango - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {A49A6001-B714-4D90-AE67-3ED65B947A1F} - EndGlobalSection -EndGlobal diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/HISTORY.md b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/HISTORY.md deleted file mode 100644 index 84a5e72..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/HISTORY.md +++ /dev/null @@ -1,231 +0,0 @@ -# DirectXMesh geometry processing library - -http://go.microsoft.com/fwlink/?LinkID=324981 - -Releases available for download on [GitHub](https://github.com/microsoft/DirectXMesh/releases) - -## Release History - -### May 9, 2022 -* Minor updates for VS 2022 (17.2) -* CMake project updates (now supports MSVC, clang/LLVM, and MinGW) -* Retired VS 2017 projects -* Reformat source using updated .editorconfig settings - -### March 24, 2022 -* Update build switches for SDL recommendations -* CMake project updates and UWP platform CMakePresets -* Code cleaup for meshconvert tool -* Optional C++17 usage in WaveFrontReader.h - -### February 28, 2022 -* Code and project review -* Added CMakePresets.json - -### November 8, 2021 -* VS 2022 support -* Fixed locale issue with WaveFront OBJ reading/writing -* Minor code and project review -* VS 2017 projects updated to require the Windows 10 SDK (19401) -* meshconvert: Fixed potential locale issue with ``-flist`` - -### September 28, 2021 -* Fixed overflow case in meshlet generation with degenerate triangles -* Minor code review and project cleanup - -### June 9, 2021 -* meshconvert: improved ``-flist`` switch to support wildcards and file exclusions -* FlexibleVertexFormat.h header added to Utilities folder -* Code cleanup for meshconvert - -### April 6, 2021 -* New function **ConcatenateMesh** -* Minor code and project cleanup -* meshconvert: Updated with descriptions for HRESULT failure codes - -### January 9, 2021 -* Windows Subsystem for Linux support -* Code review for improved conformance -* CMake updated to support package install - -### November 11, 2020 -* Code review and project updates - -### August 15, 2020 -* Added GDK projects -* Code review and project updates -* meshconvert: Added ``-fn``, ``-fuc``, and ``-fc`` switches to control vertex format - -### July 2, 2020 -* Minor warning fixes for VS 2019 (16.7) - -### June 1, 2020 -* New functions **ComputeMeshlets** and **ComputeCullData** for use with Direct3D 12 Mesh Shaders -* Converted to typed enum bitmask flags (see release notes for details on this potential *breaking change*) - + **ComputeNormals**, **Validate** -* Minor fix for degenerate cases in point-reps generation -* CMake project updates - -### May 10, 2020 -* Minor code review -* meshconvert: Updated with ``-l`` switch for case-sensitive file systems - -### April 3, 2020 -* Code review (``constexpr`` / ``noexcept`` usage) -* CMake updated for PCH usage with 3.16 or later - -### February 14, 2020 -* meshconvert: now supports exporting to WaveFront Object (OBJ) files -* Retired VS 2015 projects - -### December 17, 2019 -* Added ARM64 platform to VS 2019 Win32 desktop Win10 project -* CMake project -* Code cleaup - -### August 21, 2019 -* Added ``meshconvert`` to CMake project -* Code cleanup - -### June 30, 2019 -* Clang/LLVM warning cleanup -* Renamed ``DirectXMesh_Windows10.vcxproj`` to ``_Windows10_2017.vcxproj`` -* Added VS 2019 UWP project - -### May 30, 2019 -* Added CMake project files -* Code cleanup - -### April 26, 2019 -* Added VS 2019 desktop projects -* Officially dropped Windows Vista support -* WaveFrontReader utility header updated for RMA texture in MTL - -### February 7, 2019 -* meshconvert: added ``-sdkmesh2`` switch for PBR materials -* WaveFrontReader utility header updated for some extended material textures - -### November 16, 2018 -* VS 2017 updated for Windows 10 October 2018 Update SDK (17763) -* ARM64 platform configurations added to UWP projects - -### October 25, 2018 -* Use UTF-8 instead of ANSI for narrow strings -* Minor project fix - -### August 17, 2018 -* Updated for VS 2017 15.8 -* Code cleanup - -### July 3, 2018 -* Code and project cleanup -* meshconvert: added ``-ib32`` switch - -### May 31, 2018 -* VS 2017 updated for Windows 10 April 2018 Update SDK (17134) - -### May 11, 2018 -* Updated for VS 2017 15.7 update warnings -* Code and project cleanup -* Retired VS 2013 projects - -### April 23, 2018 -* Code and project cleanup - -### February 7, 2018 -* New functions: **WeldVertices**, **CompactVB**, **OptimizeFacesLRU** -* Added new optional parameter to **OptimizeVertices** -* Fixed bug in remap functions which were applying vertex remaps backwards - + **FinalizeIB**, **FinalizeVB**, and **FinalizeVBAndPointReps** -* meshconvert: added ``-oplru`` switch -* WaveFrontReader utility header made more robust -* Minor code cleanup - -### December 13, 2017 -* Updated for VS 2017 15.5 update warnings -* Support building library with ``_XM_NO_XMVECTOR_OVERLOADS_`` -* Added support for relative face indices to ``WaveFrontReader.h`` utility header - -### November 1, 2017 -* VS 2017 updated for Windows 10 Fall Creators Update SDK (16299) -* Code reformat and cleanup - -### September 22, 2017 -* Updated for VS 2017 15.3 update ``/permissive-`` changes -* meshconvert: added ``-flist`` option -* Minor code cleanup - -### July 28, 2017 -* Code cleanup - -### April 24, 2017 -* VS 2017 project updates - -### April 7, 2017 -* VS 2017 updated for Windows Creators Update SDK (15063) -* VBReader/VBWriter **GetElement** adapter for ``GetElement11`` - -### January 31, 2017 -* DirectX 12 support for **VBReader**, **VBWriter**, **IsValid**, and **ComputeInputLayout** -* *breaking change*: VBReader/VBWriter method **GetElement** method now named ``GetElement11`` for DirectX 11 - -### October 27, 2016 -* x2bias optional parameter for VB reader/writer -* Code cleanup - -### September 14, 2016 -* meshconvert: added wildcard support for input filename and optional ``-r`` switch for recursive search -* Code cleanup - -### August 2, 2016 -* Updated for VS 2015 Update 3 and Windows 10 SDK (14393) - -### July 19, 2016 -* meshconvert command-line tool updated with ``-flipu`` switch - -### June 27, 2016 -* Code cleanup - -### April 26, 2016 -* Retired VS 2012 projects and obsolete adapter code -* Minor code and project file cleanup - -### November 30, 2015 -* meshconvert command-line tool updated with ``-flipv`` and ``-flipz`` switches; removed ``-fliptc`` -* Updated for VS 2015 Update 1 and Windows 10 SDK (10586) - -### October 30, 2015 -* Minor code cleanup - -### August 18, 2015 -* Xbox One platform updates - -### July 29, 2015 -* Updated for VS 2015 and Windows 10 SDK RTM -* Retired VS 2010 projects -* WaveFrontReader: updated utility to minimize debug output - -### July 8, 2015 -* Minor SAL fix and project cleanup - -### March 27, 2015 -* Added projects for Windows apps Technical Preview -* Fixed attributes usage for **OptimizeFacesEx** -* meshconvert: fix when importing from .vbo -* Minor code cleanup - -### November 14, 2014 -* meshconvert: sample improvements and fixes -* Added workarounds for potential compiler bug when using -* VB reader/writer - -### October 28, 2014 -* meshconvert command-line sample -* Added **VBReader/VBWriter::GetElement** method -* Added more **ComputeTangentFrame** overloads -* Explicit calling-convention annotation for public headers -* Windows phone 8.1 platform support -* Minor code and project cleanup - -### June 27, 2014 -* Original release diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/LICENSE b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/LICENSE deleted file mode 100644 index 9066e2f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ - The MIT License (MIT) - -Copyright (c) 2014-2022 Microsoft Corp - -Permission is hereby granted, free of charge, to any person obtaining a copy of this -software and associated documentation files (the "Software"), to deal in the Software -without restriction, including without limitation the rights to use, copy, modify, -merge, publish, distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE -OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/Mesh.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/Mesh.cpp deleted file mode 100644 index 535ccb6..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/Mesh.cpp +++ /dev/null @@ -1,2435 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: Mesh.cpp -// -// Mesh processing helper class -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkID=324981 -// http://go.microsoft.com/fwlink/?LinkID=512686 -//-------------------------------------------------------------------------------------- - -#pragma warning(push) -#pragma warning(disable : 4005) -#define WIN32_LEAN_AND_MEAN -#define NOMINMAX -#define NODRAWTEXT -#define NOGDI -#define NOMCX -#define NOSERVICE -#define NOHELP -#pragma warning(pop) - -#include "Mesh.h" - -#include -#include -#include -#include -#include -#include - -#include "SDKMesh.h" - -#include -#include - -using namespace DirectX; - -namespace -{ - struct handle_closer { void operator()(HANDLE h) noexcept { if (h) CloseHandle(h); } }; - - using ScopedHandle = std::unique_ptr; - - inline HANDLE safe_handle(HANDLE h) noexcept { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; } - - template inline HRESULT write_file(HANDLE hFile, const T& value) - { - DWORD bytesWritten; - if (!WriteFile(hFile, &value, static_cast(sizeof(T)), &bytesWritten, nullptr)) - return HRESULT_FROM_WIN32(GetLastError()); - - if (bytesWritten != sizeof(T)) - return E_FAIL; - - return S_OK; - } - - inline HRESULT write_file_string(HANDLE hFile, const wchar_t* value) - { - const UINT length = (value) ? static_cast(wcslen(value) + 1) : 1; - - DWORD bytesWritten; - if (!WriteFile(hFile, &length, static_cast(sizeof(UINT)), &bytesWritten, nullptr)) - return HRESULT_FROM_WIN32(GetLastError()); - - if (bytesWritten != sizeof(UINT)) - return E_FAIL; - - if (length > 0) - { - auto const bytes = static_cast(sizeof(wchar_t) * length); - - if (!WriteFile(hFile, value, bytes, &bytesWritten, nullptr)) - return HRESULT_FROM_WIN32(GetLastError()); - - if (bytesWritten != bytes) - return E_FAIL; - } - else - { - constexpr wchar_t nul = 0; - if (!WriteFile(hFile, &nul, sizeof(wchar_t), &bytesWritten, nullptr)) - return HRESULT_FROM_WIN32(GetLastError()); - - if (bytesWritten != sizeof(wchar_t)) - return E_FAIL; - } - - return S_OK; - } - - constexpr UINT64 roundup4k(UINT64 value) - { - return ((value + 4095) / 4096) * 4096; - } - - static const uint8_t g_padding[4096] = {}; -} - -// Move constructor -Mesh::Mesh(Mesh&& moveFrom) noexcept : mnFaces(0), mnVerts(0) -{ - *this = std::move(moveFrom); -} - -// Move operator -Mesh& Mesh::operator= (Mesh&& moveFrom) noexcept -{ - if (this != &moveFrom) - { - mnFaces = moveFrom.mnFaces; - mnVerts = moveFrom.mnVerts; - mIndices.swap(moveFrom.mIndices); - mAttributes.swap(moveFrom.mAttributes); - mAdjacency.swap(moveFrom.mAdjacency); - mPositions.swap(moveFrom.mPositions); - mNormals.swap(moveFrom.mNormals); - mTangents.swap(moveFrom.mTangents); - mBiTangents.swap(moveFrom.mBiTangents); - mTexCoords.swap(moveFrom.mTexCoords); - mColors.swap(moveFrom.mColors); - mBlendIndices.swap(moveFrom.mBlendIndices); - mBlendWeights.swap(moveFrom.mBlendWeights); - } - return *this; -} - - -//-------------------------------------------------------------------------------------- -void Mesh::Clear() noexcept -{ - mnFaces = mnVerts = 0; - - // Release face data - mIndices.reset(); - mAttributes.reset(); - mAdjacency.reset(); - - // Release vertex data - mPositions.reset(); - mNormals.reset(); - mTangents.reset(); - mBiTangents.reset(); - mTexCoords.reset(); - mColors.reset(); - mBlendIndices.reset(); - mBlendWeights.reset(); -} - - -//-------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT Mesh::SetIndexData(size_t nFaces, const uint16_t* indices, const uint32_t* attributes) noexcept -{ - if (!nFaces || !indices) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); - - // Release face data - mnFaces = 0; - mIndices.reset(); - mAttributes.reset(); - - std::unique_ptr ib(new (std::nothrow) uint32_t[nFaces * 3]); - if (!ib) - return E_OUTOFMEMORY; - - for (size_t j = 0; j < (nFaces * 3); ++j) - { - if (indices[j] == uint16_t(-1)) - { - ib[j] = uint32_t(-1); - } - else - { - ib[j] = indices[j]; - } - } - - std::unique_ptr attr; - if (attributes) - { - attr.reset(new (std::nothrow) uint32_t[nFaces]); - if (!attr) - return E_OUTOFMEMORY; - - memcpy(attr.get(), attributes, sizeof(uint32_t) * nFaces); - } - - mIndices.swap(ib); - mAttributes.swap(attr); - mnFaces = nFaces; - - return S_OK; -} - -_Use_decl_annotations_ -HRESULT Mesh::SetIndexData(size_t nFaces, const uint32_t* indices, const uint32_t* attributes) noexcept -{ - if (!nFaces || !indices) - return E_INVALIDARG; - - if ((uint64_t(nFaces) * 3) >= UINT32_MAX) - return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); - - mnFaces = 0; - mIndices.reset(); - mAttributes.reset(); - - std::unique_ptr ib(new (std::nothrow) uint32_t[nFaces * 3]); - if (!ib) - return E_OUTOFMEMORY; - - memcpy(ib.get(), indices, sizeof(uint32_t) * nFaces * 3); - - std::unique_ptr attr; - if (attributes) - { - attr.reset(new (std::nothrow) uint32_t[nFaces]); - if (!attr) - return E_OUTOFMEMORY; - - memcpy(attr.get(), attributes, sizeof(uint32_t) * nFaces); - } - - mIndices.swap(ib); - mAttributes.swap(attr); - mnFaces = nFaces; - - return S_OK; -} - - -//-------------------------------------------------------------------------------------- -HRESULT Mesh::SetVertexData(const DirectX::VBReader& reader, _In_ size_t nVerts) noexcept -{ - if (!nVerts) - return E_INVALIDARG; - - // Release vertex data - mnVerts = 0; - mPositions.reset(); - mNormals.reset(); - mTangents.reset(); - mBiTangents.reset(); - mTexCoords.reset(); - mColors.reset(); - mBlendIndices.reset(); - mBlendWeights.reset(); - - // Load positions (required) - std::unique_ptr pos(new (std::nothrow) XMFLOAT3[nVerts]); - if (!pos) - return E_OUTOFMEMORY; - - HRESULT hr = reader.Read(pos.get(), "SV_Position", 0, nVerts); - if (FAILED(hr)) - return hr; - - // Load normals - std::unique_ptr norms; - auto e = reader.GetElement11("NORMAL", 0); - if (e) - { - norms.reset(new (std::nothrow) XMFLOAT3[nVerts]); - if (!norms) - return E_OUTOFMEMORY; - - hr = reader.Read(norms.get(), "NORMAL", 0, nVerts); - if (FAILED(hr)) - return hr; - } - - // Load tangents - std::unique_ptr tans1; - e = reader.GetElement11("TANGENT", 0); - if (e) - { - tans1.reset(new (std::nothrow) XMFLOAT4[nVerts]); - if (!tans1) - return E_OUTOFMEMORY; - - hr = reader.Read(tans1.get(), "TANGENT", 0, nVerts); - if (FAILED(hr)) - return hr; - } - - // Load bi-tangents - std::unique_ptr tans2; - e = reader.GetElement11("BINORMAL", 0); - if (e) - { - tans2.reset(new (std::nothrow) XMFLOAT3[nVerts]); - if (!tans2) - return E_OUTOFMEMORY; - - hr = reader.Read(tans2.get(), "BINORMAL", 0, nVerts); - if (FAILED(hr)) - return hr; - } - - // Load texture coordinates - std::unique_ptr texcoord; - e = reader.GetElement11("TEXCOORD", 0); - if (e) - { - texcoord.reset(new (std::nothrow) XMFLOAT2[nVerts]); - if (!texcoord) - return E_OUTOFMEMORY; - - hr = reader.Read(texcoord.get(), "TEXCOORD", 0, nVerts); - if (FAILED(hr)) - return hr; - } - - // Load vertex colors - std::unique_ptr colors; - e = reader.GetElement11("COLOR", 0); - if (e) - { - colors.reset(new (std::nothrow) XMFLOAT4[nVerts]); - if (!colors) - return E_OUTOFMEMORY; - - hr = reader.Read(colors.get(), "COLOR", 0, nVerts); - if (FAILED(hr)) - return hr; - } - - // Load skinning bone indices - std::unique_ptr blendIndices; - e = reader.GetElement11("BLENDINDICES", 0); - if (e) - { - blendIndices.reset(new (std::nothrow) XMFLOAT4[nVerts]); - if (!blendIndices) - return E_OUTOFMEMORY; - - hr = reader.Read(blendIndices.get(), "BLENDINDICES", 0, nVerts); - if (FAILED(hr)) - return hr; - } - - // Load skinning bone weights - std::unique_ptr blendWeights; - e = reader.GetElement11("BLENDWEIGHT", 0); - if (e) - { - blendWeights.reset(new (std::nothrow) XMFLOAT4[nVerts]); - if (!blendWeights) - return E_OUTOFMEMORY; - - hr = reader.Read(blendWeights.get(), "BLENDWEIGHT", 0, nVerts); - if (FAILED(hr)) - return hr; - } - - // Return values - mPositions.swap(pos); - mNormals.swap(norms); - mTangents.swap(tans1); - mBiTangents.swap(tans2); - mTexCoords.swap(texcoord); - mColors.swap(colors); - mBlendIndices.swap(blendIndices); - mBlendWeights.swap(blendWeights); - mnVerts = nVerts; - - return S_OK; -} - - -//-------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT Mesh::Validate(DirectX::VALIDATE_FLAGS flags, std::wstring* msgs) const noexcept -{ - if (!mnFaces || !mIndices || !mnVerts) - return E_UNEXPECTED; - - return DirectX::Validate(mIndices.get(), mnFaces, mnVerts, mAdjacency.get(), flags, msgs); -} - - -//-------------------------------------------------------------------------------------- -HRESULT Mesh::Clean() noexcept -{ - if (!mnFaces || !mIndices || !mnVerts || !mPositions) - return E_UNEXPECTED; - - std::vector dups; - HRESULT hr = DirectX::Clean(mIndices.get(), mnFaces, mnVerts, mAdjacency.get(), mAttributes.get(), dups); - if (FAILED(hr)) - return hr; - - if (dups.empty()) - { - // No vertex duplication is needed for mesh clean - return S_OK; - } - - const size_t nNewVerts = mnVerts + dups.size(); - - std::unique_ptr pos(new (std::nothrow) XMFLOAT3[nNewVerts]); - if (!pos) - return E_OUTOFMEMORY; - - memcpy(pos.get(), mPositions.get(), sizeof(XMFLOAT3) * mnVerts); - - std::unique_ptr norms; - if (mNormals) - { - norms.reset(new (std::nothrow) XMFLOAT3[nNewVerts]); - if (!norms) - return E_OUTOFMEMORY; - - memcpy(norms.get(), mNormals.get(), sizeof(XMFLOAT3) * mnVerts); - } - - std::unique_ptr tans1; - if (mTangents) - { - tans1.reset(new (std::nothrow) XMFLOAT4[nNewVerts]); - if (!tans1) - return E_OUTOFMEMORY; - - memcpy(tans1.get(), mTangents.get(), sizeof(XMFLOAT4) * mnVerts); - } - - std::unique_ptr tans2; - if (mBiTangents) - { - tans2.reset(new (std::nothrow) XMFLOAT3[nNewVerts]); - if (!tans2) - return E_OUTOFMEMORY; - - memcpy(tans2.get(), mBiTangents.get(), sizeof(XMFLOAT3) * mnVerts); - } - - std::unique_ptr texcoord; - if (mTexCoords) - { - texcoord.reset(new (std::nothrow) XMFLOAT2[nNewVerts]); - if (!texcoord) - return E_OUTOFMEMORY; - - memcpy(texcoord.get(), mTexCoords.get(), sizeof(XMFLOAT2) * mnVerts); - } - - std::unique_ptr colors; - if (mColors) - { - colors.reset(new (std::nothrow) XMFLOAT4[nNewVerts]); - if (!colors) - return E_OUTOFMEMORY; - - memcpy(colors.get(), mColors.get(), sizeof(XMFLOAT4) * mnVerts); - } - - std::unique_ptr blendIndices; - if (mBlendIndices) - { - blendIndices.reset(new (std::nothrow) XMFLOAT4[nNewVerts]); - if (!blendIndices) - return E_OUTOFMEMORY; - - memcpy(blendIndices.get(), mBlendIndices.get(), sizeof(XMFLOAT4) * mnVerts); - } - - std::unique_ptr blendWeights; - if (mBlendWeights) - { - blendWeights.reset(new (std::nothrow) XMFLOAT4[nNewVerts]); - if (!blendWeights) - return E_OUTOFMEMORY; - - memcpy(blendWeights.get(), mBlendWeights.get(), sizeof(XMFLOAT4) * mnVerts); - } - - size_t j = mnVerts; - for (auto it = dups.begin(); it != dups.end() && (j < nNewVerts); ++it, ++j) - { - assert(*it < mnVerts); - - pos[j] = mPositions[*it]; - - if (norms) - { - norms[j] = mNormals[*it]; - } - - if (tans1) - { - tans1[j] = mTangents[*it]; - } - - if (tans2) - { - tans2[j] = mBiTangents[*it]; - } - - if (texcoord) - { - texcoord.get()[j] = mTexCoords[*it]; - } - - if (colors) - { - colors[j] = mColors[*it]; - } - - if (blendIndices) - { - blendIndices[j] = mBlendIndices[*it]; - } - - if (blendWeights) - { - blendWeights[j] = mBlendWeights[*it]; - } - } - - mPositions.swap(pos); - mNormals.swap(norms); - mTangents.swap(tans1); - mBiTangents.swap(tans2); - mTexCoords.swap(texcoord); - mColors.swap(colors); - mBlendIndices.swap(blendIndices); - mBlendWeights.swap(blendWeights); - mnVerts = nNewVerts; - - return S_OK; -} - - -//-------------------------------------------------------------------------------------- -HRESULT Mesh::GenerateAdjacency(_In_ float epsilon) noexcept -{ - if (!mnFaces || !mIndices || !mnVerts || !mPositions) - return E_UNEXPECTED; - - if ((uint64_t(mnFaces) * 3) >= UINT32_MAX) - return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); - - mAdjacency.reset(new (std::nothrow) uint32_t[mnFaces * 3]); - if (!mAdjacency) - return E_OUTOFMEMORY; - - return DirectX::GenerateAdjacencyAndPointReps(mIndices.get(), mnFaces, mPositions.get(), mnVerts, epsilon, nullptr, mAdjacency.get()); -} - - -//-------------------------------------------------------------------------------------- -HRESULT Mesh::ComputeNormals(_In_ DirectX::CNORM_FLAGS flags) noexcept -{ - if (!mnFaces || !mIndices || !mnVerts || !mPositions) - return E_UNEXPECTED; - - mNormals.reset(new (std::nothrow) XMFLOAT3[mnVerts]); - if (!mNormals) - return E_OUTOFMEMORY; - - return DirectX::ComputeNormals(mIndices.get(), mnFaces, mPositions.get(), mnVerts, flags, mNormals.get()); -} - - -//-------------------------------------------------------------------------------------- -HRESULT Mesh::ComputeTangentFrame(_In_ bool bitangents) noexcept -{ - if (!mnFaces || !mIndices || !mnVerts || !mPositions || !mNormals || !mTexCoords) - return E_UNEXPECTED; - - mTangents.reset(); - mBiTangents.reset(); - - std::unique_ptr tan1(new (std::nothrow) XMFLOAT4[mnVerts]); - if (!tan1) - return E_OUTOFMEMORY; - - std::unique_ptr tan2; - if (bitangents) - { - tan2.reset(new (std::nothrow) XMFLOAT3[mnVerts]); - if (!tan2) - return E_OUTOFMEMORY; - - HRESULT hr = DirectX::ComputeTangentFrame(mIndices.get(), mnFaces, mPositions.get(), mNormals.get(), mTexCoords.get(), mnVerts, - tan1.get(), tan2.get()); - if (FAILED(hr)) - return hr; - } - else - { - mBiTangents.reset(); - - HRESULT hr = DirectX::ComputeTangentFrame(mIndices.get(), mnFaces, mPositions.get(), mNormals.get(), mTexCoords.get(), mnVerts, - tan1.get()); - if (FAILED(hr)) - return hr; - } - - mTangents.swap(tan1); - mBiTangents.swap(tan2); - - return S_OK; -} - - -//-------------------------------------------------------------------------------------- -HRESULT Mesh::Optimize(bool lru) noexcept -{ - if (!mnFaces || !mIndices || !mnVerts || !mPositions) - return E_UNEXPECTED; - - if (!lru && !mAdjacency) - return E_UNEXPECTED; - - HRESULT hr = S_OK; - - { - std::unique_ptr remap(new (std::nothrow) uint32_t[mnFaces]); - if (!remap) - return E_OUTOFMEMORY; - - if (mAttributes) - { - // Note that Clean handles vertex splits due to reuse between attributes - - hr = AttributeSort(mnFaces, mAttributes.get(), remap.get()); - if (FAILED(hr)) - return hr; - - if (mAdjacency) - { - hr = ReorderIBAndAdjacency(mIndices.get(), mnFaces, mAdjacency.get(), remap.get()); - } - else - { - hr = ReorderIB(mIndices.get(), mnFaces, remap.get()); - } - if (FAILED(hr)) - return hr; - - // Optimize faces for pre-transform vertex cache - if (lru) - { - hr = OptimizeFacesLRUEx(mIndices.get(), mnFaces, mAttributes.get(), remap.get()); - } - else - { - hr = OptimizeFacesEx(mIndices.get(), mnFaces, mAdjacency.get(), mAttributes.get(), remap.get()); - } - } - else if (lru) - { - hr = OptimizeFacesLRU(mIndices.get(), mnFaces, remap.get()); - } - else - { - hr = OptimizeFaces(mIndices.get(), mnFaces, mAdjacency.get(), remap.get()); - } - if (FAILED(hr)) - return hr; - - if (mAdjacency) - { - hr = ReorderIBAndAdjacency(mIndices.get(), mnFaces, mAdjacency.get(), remap.get()); - } - else - { - hr = ReorderIB(mIndices.get(), mnFaces, remap.get()); - } - if (FAILED(hr)) - return hr; - } - - // Optimize vertices for post-transform vertex cache - std::unique_ptr remap(new (std::nothrow) uint32_t[mnVerts]); - if (!remap) - return E_OUTOFMEMORY; - - hr = OptimizeVertices(mIndices.get(), mnFaces, mnVerts, remap.get()); - if (FAILED(hr)) - return hr; - - hr = FinalizeIB(mIndices.get(), mnFaces, remap.get(), mnVerts); - if (FAILED(hr)) - return hr; - - hr = FinalizeVB(mPositions.get(), sizeof(XMFLOAT3), mnVerts, remap.get()); - if (FAILED(hr)) - return hr; - - if (mNormals) - { - hr = FinalizeVB(mNormals.get(), sizeof(XMFLOAT3), mnVerts, remap.get()); - if (FAILED(hr)) - return hr; - } - - if (mTangents) - { - hr = FinalizeVB(mTangents.get(), sizeof(XMFLOAT4), mnVerts, remap.get()); - if (FAILED(hr)) - return hr; - } - - if (mBiTangents) - { - hr = FinalizeVB(mBiTangents.get(), sizeof(XMFLOAT3), mnVerts, remap.get()); - if (FAILED(hr)) - return hr; - } - - if (mTexCoords) - { - hr = FinalizeVB(mTexCoords.get(), sizeof(XMFLOAT2), mnVerts, remap.get()); - if (FAILED(hr)) - return hr; - } - - if (mColors) - { - hr = FinalizeVB(mColors.get(), sizeof(XMFLOAT4), mnVerts, remap.get()); - if (FAILED(hr)) - return hr; - } - - if (mBlendIndices) - { - hr = FinalizeVB(mBlendIndices.get(), sizeof(XMFLOAT4), mnVerts, remap.get()); - if (FAILED(hr)) - return hr; - - } - - if (mBlendWeights) - { - hr = FinalizeVB(mBlendWeights.get(), sizeof(XMFLOAT4), mnVerts, remap.get()); - if (FAILED(hr)) - return hr; - } - - return S_OK; -} - - -//-------------------------------------------------------------------------------------- -HRESULT Mesh::ReverseWinding() noexcept -{ - if (!mIndices || !mnFaces) - return E_UNEXPECTED; - - auto iptr = mIndices.get(); - for (size_t j = 0; j < mnFaces; ++j) - { - std::swap(*iptr, *(iptr + 2)); - iptr += 3; - } - - return S_OK; -} - - -//-------------------------------------------------------------------------------------- -HRESULT Mesh::InvertUTexCoord() noexcept -{ - if (!mTexCoords) - return E_UNEXPECTED; - - auto tptr = mTexCoords.get(); - for (size_t j = 0; j < mnVerts; ++j, ++tptr) - { - tptr->x = 1.f - tptr->x; - } - - return S_OK; -} - - -//-------------------------------------------------------------------------------------- -HRESULT Mesh::InvertVTexCoord() noexcept -{ - if (!mTexCoords) - return E_UNEXPECTED; - - auto tptr = mTexCoords.get(); - for (size_t j = 0; j < mnVerts; ++j, ++tptr) - { - tptr->y = 1.f - tptr->y; - } - - return S_OK; -} - - -//-------------------------------------------------------------------------------------- -HRESULT Mesh::ReverseHandedness() noexcept -{ - if (!mPositions) - return E_UNEXPECTED; - - auto ptr = mPositions.get(); - for (size_t j = 0; j < mnVerts; ++j, ++ptr) - { - ptr->z = -ptr->z; - } - - if (mNormals) - { - auto nptr = mNormals.get(); - for (size_t j = 0; j < mnVerts; ++j, ++nptr) - { - nptr->z = -nptr->z; - } - } - - return S_OK; -} - - -//-------------------------------------------------------------------------------------- -bool Mesh::Is16BitIndexBuffer() const noexcept -{ - if (!mIndices || !mnFaces) - return false; - - if ((uint64_t(mnFaces) * 3) >= UINT32_MAX) - return false; - - const uint32_t* iptr = mIndices.get(); - for (size_t j = 0; j < (mnFaces * 3); ++j) - { - const uint32_t index = *(iptr++); - if (index != uint32_t(-1) - && (index >= UINT16_MAX)) - { - return false; - } - } - - return true; -} - - -//-------------------------------------------------------------------------------------- -std::unique_ptr Mesh::GetIndexBuffer16() const noexcept -{ - std::unique_ptr ib; - - if (!mIndices || !mnFaces) - return ib; - - if ((uint64_t(mnFaces) * 3) >= UINT32_MAX) - return ib; - - const size_t count = mnFaces * 3; - - ib.reset(new (std::nothrow) uint16_t[count]); - if (!ib) - return ib; - - const uint32_t* iptr = mIndices.get(); - for (size_t j = 0; j < count; ++j) - { - uint32_t index = *(iptr++); - if (index == uint32_t(-1)) - { - ib[j] = uint16_t(-1); - } - else if (index >= UINT16_MAX) - { - ib.reset(); - return ib; - } - else - { - ib[j] = static_cast(index); - } - } - - return ib; -} - - -//-------------------------------------------------------------------------------------- -HRESULT Mesh::GetVertexBuffer(const DirectX::VBWriter& writer) const noexcept -{ - if (!mnVerts || !mPositions) - return E_UNEXPECTED; - - HRESULT hr = writer.Write(mPositions.get(), "SV_Position", 0, mnVerts); - if (FAILED(hr)) - return hr; - - if (mNormals) - { - auto e = writer.GetElement11("NORMAL", 0); - if (e) - { - const bool x2bias = (e->Format == DXGI_FORMAT_R11G11B10_FLOAT); - hr = writer.Write(mNormals.get(), "NORMAL", 0, mnVerts, x2bias); - if (FAILED(hr)) - return hr; - } - } - - if (mTangents) - { - auto e = writer.GetElement11("TANGENT", 0); - if (e) - { - const bool x2bias = (e->Format == DXGI_FORMAT_R11G11B10_FLOAT); - hr = writer.Write(mTangents.get(), "TANGENT", 0, mnVerts, x2bias); - if (FAILED(hr)) - return hr; - } - } - - if (mBiTangents) - { - auto e = writer.GetElement11("BINORMAL", 0); - if (e) - { - const bool x2bias = (e->Format == DXGI_FORMAT_R11G11B10_FLOAT); - hr = writer.Write(mBiTangents.get(), "BINORMAL", 0, mnVerts, x2bias); - if (FAILED(hr)) - return hr; - } - } - - if (mTexCoords) - { - auto e = writer.GetElement11("TEXCOORD", 0); - if (e) - { - hr = writer.Write(mTexCoords.get(), "TEXCOORD", 0, mnVerts); - if (FAILED(hr)) - return hr; - } - } - - if (mColors) - { - auto e = writer.GetElement11("COLOR", 0); - if (e) - { - hr = writer.Write(mColors.get(), "COLOR", 0, mnVerts); - if (FAILED(hr)) - return hr; - } - } - - if (mBlendIndices) - { - auto e = writer.GetElement11("BLENDINDICES", 0); - if (e) - { - hr = writer.Write(mBlendIndices.get(), "BLENDINDICES", 0, mnVerts); - if (FAILED(hr)) - return hr; - } - } - - if (mBlendWeights) - { - auto e = writer.GetElement11("BLENDWEIGHT", 0); - if (e) - { - hr = writer.Write(mBlendWeights.get(), "BLENDWEIGHT", 0, mnVerts); - if (FAILED(hr)) - return hr; - } - } - - return S_OK; -} - - -//====================================================================================== -// VBO -//====================================================================================== - -namespace VBO -{ - -#pragma pack(push,1) - - struct header_t - { - uint32_t numVertices; - uint32_t numIndices; - }; - - struct vertex_t - { - DirectX::XMFLOAT3 position; - DirectX::XMFLOAT3 normal; - DirectX::XMFLOAT2 textureCoordinate; - }; - -#pragma pack(pop) - - static_assert(sizeof(header_t) == 8, "VBO header size mismatch"); - static_assert(sizeof(vertex_t) == 32, "VBO vertex size mismatch"); -} // namespace - - -//-------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT Mesh::ExportToVBO(const wchar_t* szFileName) const noexcept -{ - using namespace VBO; - - if (!szFileName) - return E_INVALIDARG; - - if (!mnFaces || !mIndices || !mnVerts || !mPositions || !mNormals || !mTexCoords) - return E_UNEXPECTED; - - if ((uint64_t(mnFaces) * 3) >= UINT32_MAX) - return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); - - if (mnVerts >= UINT16_MAX) - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - - // Setup VBO header - header_t header; - header.numVertices = static_cast(mnVerts); - header.numIndices = static_cast(mnFaces * 3); - - // Setup vertices/indices for VBO - - std::unique_ptr vb(new (std::nothrow) vertex_t[mnVerts]); - std::unique_ptr ib(new (std::nothrow) uint16_t[header.numIndices]); - if (!vb || !ib) - return E_OUTOFMEMORY; - - // Copy to VB - auto vptr = vb.get(); - for (size_t j = 0; j < mnVerts; ++j, ++vptr) - { - vptr->position = mPositions[j]; - vptr->normal = mNormals[j]; - vptr->textureCoordinate = mTexCoords[j]; - } - - // Copy to IB - auto iptr = ib.get(); - for (size_t j = 0; j < header.numIndices; ++j, ++iptr) - { - uint32_t index = mIndices[j]; - if (index == uint32_t(-1)) - { - *iptr = uint16_t(-1); - } - else if (index >= UINT16_MAX) - { - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - else - { - *iptr = static_cast(index); - } - } - - // Write header and data -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFileName, - GENERIC_WRITE, 0, CREATE_ALWAYS, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(szFileName, - GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr))); -#endif - if (!hFile) - return HRESULT_FROM_WIN32(GetLastError()); - - HRESULT hr = write_file(hFile.get(), header); - if (FAILED(hr)) - return hr; - - auto const vertSize = static_cast(sizeof(vertex_t) * header.numVertices); - - DWORD bytesWritten; - if (!WriteFile(hFile.get(), vb.get(), vertSize, &bytesWritten, nullptr)) - return HRESULT_FROM_WIN32(GetLastError()); - - if (bytesWritten != vertSize) - return E_FAIL; - - auto const indexSize = static_cast(sizeof(uint16_t) * header.numIndices); - - if (!WriteFile(hFile.get(), ib.get(), indexSize, &bytesWritten, nullptr)) - return HRESULT_FROM_WIN32(GetLastError()); - - if (bytesWritten != indexSize) - return E_FAIL; - - return S_OK; -} - - -//-------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT Mesh::CreateFromVBO(const wchar_t* szFileName, std::unique_ptr& result) noexcept -{ - using namespace VBO; - - if (!szFileName) - return E_INVALIDARG; - - result.reset(); - -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFileName, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(szFileName, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr))); -#endif - if (!hFile) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - // Get the file size - FILE_STANDARD_INFO fileInfo; - if (!GetFileInformationByHandleEx(hFile.get(), FileStandardInfo, &fileInfo, sizeof(fileInfo))) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - // File is too big for 32-bit allocation, so reject read - if (fileInfo.EndOfFile.HighPart > 0) - return E_FAIL; - - // Need at least enough data to read the header - if (fileInfo.EndOfFile.LowPart < sizeof(header_t)) - return E_FAIL; - - // Read VBO header - DWORD bytesRead = 0; - - header_t header; - if (!ReadFile(hFile.get(), &header, sizeof(header_t), &bytesRead, nullptr)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesRead != sizeof(header)) - return E_FAIL; - - if (!header.numVertices || !header.numIndices) - return E_FAIL; - - result.reset(new (std::nothrow) Mesh); - if (!result) - return E_OUTOFMEMORY; - - // Read vertices/indices from VBO - std::unique_ptr vb(new (std::nothrow) vertex_t[header.numVertices]); - std::unique_ptr ib(new (std::nothrow) uint16_t[header.numIndices]); - if (!vb || !ib) - return E_OUTOFMEMORY; - - auto const vertSize = static_cast(sizeof(vertex_t) * header.numVertices); - - if (!ReadFile(hFile.get(), vb.get(), vertSize, &bytesRead, nullptr)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesRead != vertSize) - return E_FAIL; - - auto const indexSize = static_cast(sizeof(uint16_t) * header.numIndices); - - if (!ReadFile(hFile.get(), ib.get(), indexSize, &bytesRead, nullptr)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesRead != indexSize) - return E_FAIL; - - // Copy VB to result - std::unique_ptr pos(new (std::nothrow) XMFLOAT3[header.numVertices]); - std::unique_ptr norm(new (std::nothrow) XMFLOAT3[header.numVertices]); - std::unique_ptr texcoord(new (std::nothrow) XMFLOAT2[header.numVertices]); - if (!pos || !norm || !texcoord) - return E_OUTOFMEMORY; - - auto vptr = vb.get(); - for (size_t j = 0; j < header.numVertices; ++j, ++vptr) - { - pos[j] = vptr->position; - norm[j] = vptr->normal; - texcoord[j] = vptr->textureCoordinate; - } - - // Copy IB to result - std::unique_ptr indices(new (std::nothrow) uint32_t[header.numIndices]); - if (!indices) - return E_OUTOFMEMORY; - - auto iptr = ib.get(); - for (size_t j = 0; j < header.numIndices; ++j, ++iptr) - { - uint16_t index = *iptr; - if (index == uint16_t(-1)) - indices[j] = uint32_t(-1); - else - indices[j] = index; - } - - result->mPositions.swap(pos); - result->mNormals.swap(norm); - result->mTexCoords.swap(texcoord); - result->mIndices.swap(indices); - result->mnVerts = header.numVertices; - result->mnFaces = header.numIndices / 3; - - return S_OK; -} - - -//====================================================================================== -// Visual Studio CMO -//====================================================================================== - -//-------------------------------------------------------------------------------------- -// .CMO files are built by Visual Studio 2012 and an example renderer is provided -// in the VS Direct3D Starter Kit -// http://code.msdn.microsoft.com/Visual-Studio-3D-Starter-455a15f1 -//-------------------------------------------------------------------------------------- - -namespace VSD3DStarter -{ - // .CMO files - - // UINT - Mesh count - // { [Mesh count] - // UINT - Length of name - // wchar_t[] - Name of mesh (if length > 0) - // UINT - Material count - // { [Material count] - // UINT - Length of material name - // wchar_t[] - Name of material (if length > 0) - // Material structure - // UINT - Length of pixel shader name - // wchar_t[] - Name of pixel shader (if length > 0) - // { [8] - // UINT - Length of texture name - // wchar_t[] - Name of texture (if length > 0) - // } - // } - // BYTE - 1 if there is skeletal animation data present - // UINT - SubMesh count - // { [SubMesh count] - // SubMesh structure - // } - // UINT - IB Count - // { [IB Count] - // UINT - Number of USHORTs in IB - // USHORT[] - Array of indices - // } - // UINT - VB Count - // { [VB Count] - // UINT - Number of verts in VB - // Vertex[] - Array of vertices - // } - // UINT - Skinning VB Count - // { [Skinning VB Count] - // UINT - Number of verts in Skinning VB - // SkinningVertex[] - Array of skinning verts - // } - // MeshExtents structure - // [If skeleton animation data is not present, file ends here] - // UINT - Bone count - // { [Bone count] - // UINT - Length of bone name - // wchar_t[] - Bone name (if length > 0) - // Bone structure - // } - // UINT - Animation clip count - // { [Animation clip count] - // UINT - Length of clip name - // wchar_t[] - Clip name (if length > 0) - // float - Start time - // float - End time - // UINT - Keyframe count - // { [Keyframe count] - // Keyframe structure - // } - // } - // } - -#pragma pack(push,1) - - struct Material - { - DirectX::XMFLOAT4 Ambient; - DirectX::XMFLOAT4 Diffuse; - DirectX::XMFLOAT4 Specular; - float SpecularPower; - DirectX::XMFLOAT4 Emissive; - DirectX::XMFLOAT4X4 UVTransform; - }; - - constexpr uint32_t MAX_TEXTURE = 8; - - struct SubMesh - { - UINT MaterialIndex; - UINT IndexBufferIndex; - UINT VertexBufferIndex; - UINT StartIndex; - UINT PrimCount; - }; - - constexpr uint32_t NUM_BONE_INFLUENCES = 4; - - struct Vertex - { - DirectX::XMFLOAT3 Position; - DirectX::XMFLOAT3 Normal; - DirectX::XMFLOAT4 Tangent; - UINT color; - DirectX::XMFLOAT2 TextureCoordinates; - }; - - struct SkinningVertex - { - UINT boneIndex[NUM_BONE_INFLUENCES]; - float boneWeight[NUM_BONE_INFLUENCES]; - }; - - struct MeshExtents - { - float CenterX, CenterY, CenterZ; - float Radius; - - float MinX, MinY, MinZ; - float MaxX, MaxY, MaxZ; - }; - - struct Bone - { - INT ParentIndex; - DirectX::XMFLOAT4X4 InvBindPos; - DirectX::XMFLOAT4X4 BindPos; - DirectX::XMFLOAT4X4 LocalTransform; - }; - - struct Clip - { - float StartTime; - float EndTime; - UINT keys; - }; - - struct Keyframe - { - UINT BoneIndex; - float Time; - DirectX::XMFLOAT4X4 Transform; - }; - -#pragma pack(pop) - -} // namespace - -static_assert(sizeof(VSD3DStarter::Material) == 132, "CMO Mesh structure size incorrect"); -static_assert(sizeof(VSD3DStarter::SubMesh) == 20, "CMO Mesh structure size incorrect"); -static_assert(sizeof(VSD3DStarter::Vertex) == 52, "CMO Mesh structure size incorrect"); -static_assert(sizeof(VSD3DStarter::SkinningVertex) == 32, "CMO Mesh structure size incorrect"); -static_assert(sizeof(VSD3DStarter::MeshExtents) == 40, "CMO Mesh structure size incorrect"); -static_assert(sizeof(VSD3DStarter::Bone) == 196, "CMO Mesh structure size incorrect"); -static_assert(sizeof(VSD3DStarter::Clip) == 12, "CMO Mesh structure size incorrect"); -static_assert(sizeof(VSD3DStarter::Keyframe) == 72, "CMO Mesh structure size incorrect"); - - -//-------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT Mesh::ExportToCMO(const wchar_t* szFileName, size_t nMaterials, const Material* materials) const noexcept -{ - using namespace VSD3DStarter; - - if (!szFileName) - return E_INVALIDARG; - - if (nMaterials > 0 && !materials) - return E_INVALIDARG; - - if (!mnFaces || !mIndices || !mnVerts || !mPositions || !mNormals || !mTexCoords || !mTangents) - return E_UNEXPECTED; - - if ((uint64_t(mnFaces) * 3) >= UINT32_MAX) - return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); - - if (mnVerts >= UINT16_MAX) - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - - const UINT nIndices = static_cast(mnFaces * 3); - - // Setup vertices/indices for CMO - std::unique_ptr vb(new (std::nothrow) Vertex[mnVerts]); - std::unique_ptr ib(new (std::nothrow) uint16_t[nIndices]); - if (!vb || !ib) - return E_OUTOFMEMORY; - - std::unique_ptr vbSkin; - if (mBlendIndices && mBlendWeights) - { - vbSkin.reset(new (std::nothrow) SkinningVertex[mnVerts]); - if (!vbSkin) - return E_OUTOFMEMORY; - } - - // Copy to VB - auto vptr = vb.get(); - for (size_t j = 0; j < mnVerts; ++j, ++vptr) - { - vptr->Position = mPositions[j]; - vptr->Normal = mNormals[j]; - vptr->Tangent = mTangents[j]; - vptr->TextureCoordinates = mTexCoords[j]; - - if (mColors) - { - const XMVECTOR icolor = XMLoadFloat4(&mColors[j]); - PackedVector::XMUBYTEN4 rgba; - PackedVector::XMStoreUByteN4(&rgba, icolor); - vptr->color = rgba.v; - } - else - vptr->color = 0xFFFFFFFF; - } - - // Copy to SkinVB - auto sptr = vbSkin.get(); - if (sptr) - { - for (size_t j = 0; j < mnVerts; ++j, ++sptr) - { - const XMVECTOR v = XMLoadFloat4(&mBlendIndices[j]); - XMStoreUInt4(reinterpret_cast(&sptr->boneIndex[0]), v); - - const XMFLOAT4* w = &mBlendWeights[j]; - sptr->boneWeight[0] = w->x; - sptr->boneWeight[1] = w->y; - sptr->boneWeight[2] = w->z; - sptr->boneWeight[3] = w->w; - } - } - - // Copy to IB - auto iptr = ib.get(); - for (size_t j = 0; j < nIndices; ++j, ++iptr) - { - uint32_t index = mIndices[j]; - if (index == uint32_t(-1)) - { - *iptr = uint16_t(-1); - } - else if (index >= UINT16_MAX) - { - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - else - { - *iptr = static_cast(index); - } - } - - // Create CMO file -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFileName, - GENERIC_WRITE, 0, CREATE_ALWAYS, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(szFileName, - GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr))); -#endif - if (!hFile) - return HRESULT_FROM_WIN32(GetLastError()); - - // Write 1 mesh, name based on the filename - UINT n = 1; - HRESULT hr = write_file(hFile.get(), n); - if (FAILED(hr)) - return hr; - - { - wchar_t fname[_MAX_FNAME]; - _wsplitpath_s(szFileName, nullptr, 0, nullptr, 0, fname, _MAX_FNAME, nullptr, 0); - - hr = write_file_string(hFile.get(), fname); - if (FAILED(hr)) - return hr; - } - - // Write materials - static const Mesh::Material s_defMaterial = { L"default", false, 1.f, 1.f, - XMFLOAT3(0.2f, 0.2f, 0.2f), XMFLOAT3(0.8f, 0.8f, 0.8f), - XMFLOAT3(0.f, 0.f, 0.f), XMFLOAT3(0.f, 0.f, 0.f), L"" }; - - UINT materialCount = 1; - if (nMaterials > 0) - { - materialCount = static_cast(nMaterials); - } - else - { - nMaterials = 1; - materials = &s_defMaterial; - } - - hr = write_file(hFile.get(), materialCount); - if (FAILED(hr)) - return hr; - - for (UINT j = 0; j < materialCount; ++j) - { - auto& m = materials[j]; - - if (!m.name.empty()) - { - hr = write_file_string(hFile.get(), m.name.c_str()); - } - else - { - wchar_t name[64]; - swprintf_s(name, L"material%03u\n", j); - hr = write_file_string(hFile.get(), name); - } - if (FAILED(hr)) - return hr; - - VSD3DStarter::Material mdata = {}; - - mdata.Ambient.x = m.ambientColor.x; - mdata.Ambient.y = m.ambientColor.y; - mdata.Ambient.z = m.ambientColor.z; - mdata.Ambient.w = 1.f; - - mdata.Diffuse.x = m.diffuseColor.x; - mdata.Diffuse.y = m.diffuseColor.y; - mdata.Diffuse.z = m.diffuseColor.z; - mdata.Diffuse.w = m.alpha; - - if (m.specularColor.x > 0.f || m.specularColor.y > 0.f || m.specularColor.z > 0.f) - { - mdata.Specular.x = m.specularColor.x; - mdata.Specular.y = m.specularColor.y; - mdata.Specular.z = m.specularColor.z; - mdata.SpecularPower = (m.specularPower <= 0.f) ? 16.f : m.specularPower; - } - else - { - mdata.SpecularPower = 1.f; - } - mdata.Specular.w = 1.f; - - mdata.Emissive.x = m.emissiveColor.x; - mdata.Emissive.y = m.emissiveColor.y; - mdata.Emissive.z = m.emissiveColor.z; - mdata.Emissive.w = 1.f; - - const XMMATRIX id = XMMatrixIdentity(); - XMStoreFloat4x4(&mdata.UVTransform, id); - - hr = write_file(hFile.get(), mdata); - if (FAILED(hr)) - return hr; - - if (m.specularColor.x > 0.f || m.specularColor.y > 0.f || m.specularColor.z > 0.f) - { - hr = write_file_string(hFile.get(), L"phong.dgsl"); - } - else - { - hr = write_file_string(hFile.get(), L"lambert.dgsl"); - } - if (FAILED(hr)) - return hr; - - hr = write_file_string(hFile.get(), m.texture.c_str()); - if (FAILED(hr)) - return hr; - - for (size_t k = 1; k < MAX_TEXTURE; ++k) - { - hr = write_file_string(hFile.get(), L""); - if (FAILED(hr)) - return hr; - } - } - - constexpr BYTE sd = 0; // No skeleton/animation data - hr = write_file(hFile.get(), sd); - if (FAILED(hr)) - return hr; - - if (mAttributes) - { - auto subsets = ComputeSubsets(mAttributes.get(), mnFaces); - - n = static_cast(subsets.size()); - hr = write_file(hFile.get(), n); - if (FAILED(hr)) - return hr; - - size_t startIndex = 0; - for (const auto& it : subsets) - { - SubMesh smesh; - smesh.MaterialIndex = mAttributes[it.first]; - if (smesh.MaterialIndex >= nMaterials) - smesh.MaterialIndex = 0; - - smesh.IndexBufferIndex = 0; - smesh.VertexBufferIndex = 0; - smesh.StartIndex = static_cast(startIndex); - smesh.PrimCount = static_cast(it.second); - hr = write_file(hFile.get(), smesh); - if (FAILED(hr)) - return hr; - - if ((startIndex + (it.second * 3)) > mnFaces * 3) - return E_FAIL; - - startIndex += static_cast(uint64_t(smesh.PrimCount) * 3); - } - } - else - { - n = 1; - hr = write_file(hFile.get(), n); - if (FAILED(hr)) - return hr; - - SubMesh smesh; - smesh.MaterialIndex = 0; - smesh.IndexBufferIndex = 0; - smesh.VertexBufferIndex = 0; - smesh.StartIndex = 0; - smesh.PrimCount = static_cast(mnFaces); - - hr = write_file(hFile.get(), smesh); - if (FAILED(hr)) - return hr; - } - - // Write indices (one IB shared across submeshes) - n = 1; - hr = write_file(hFile.get(), n); - if (FAILED(hr)) - return hr; - - hr = write_file(hFile.get(), nIndices); - if (FAILED(hr)) - return hr; - - auto const indexSize = static_cast(sizeof(uint16_t) * nIndices); - - DWORD bytesWritten; - if (!WriteFile(hFile.get(), ib.get(), indexSize, &bytesWritten, nullptr)) - return HRESULT_FROM_WIN32(GetLastError()); - - if (bytesWritten != indexSize) - return E_FAIL; - - // Write vertices (one VB shared across submeshes) - n = 1; - hr = write_file(hFile.get(), n); - if (FAILED(hr)) - return hr; - - n = static_cast(mnVerts); - hr = write_file(hFile.get(), n); - if (FAILED(hr)) - return hr; - - auto const vertSize = static_cast(sizeof(Vertex) * mnVerts); - - if (!WriteFile(hFile.get(), vb.get(), vertSize, &bytesWritten, nullptr)) - return HRESULT_FROM_WIN32(GetLastError()); - - if (bytesWritten != vertSize) - return E_FAIL; - - // Write skinning vertices (one SkinVB shared across submeshes) - if (vbSkin) - { - n = 1; - hr = write_file(hFile.get(), n); - if (FAILED(hr)) - return hr; - - n = static_cast(mnVerts); - hr = write_file(hFile.get(), n); - if (FAILED(hr)) - return hr; - - auto const skinVertSize = static_cast(sizeof(SkinningVertex) * mnVerts); - - if (!WriteFile(hFile.get(), vbSkin.get(), skinVertSize, &bytesWritten, nullptr)) - return HRESULT_FROM_WIN32(GetLastError()); - - if (bytesWritten != skinVertSize) - return E_FAIL; - } - else - { - n = 0; - hr = write_file(hFile.get(), n); - if (FAILED(hr)) - return hr; - } - - // Write extents - { - BoundingSphere sphere; - BoundingSphere::CreateFromPoints(sphere, mnVerts, mPositions.get(), sizeof(XMFLOAT3)); - - BoundingBox box; - BoundingBox::CreateFromPoints(box, mnVerts, mPositions.get(), sizeof(XMFLOAT3)); - - MeshExtents extents; - extents.CenterX = sphere.Center.x; - extents.CenterY = sphere.Center.y; - extents.CenterZ = sphere.Center.z; - extents.Radius = sphere.Radius; - - extents.MinX = box.Center.x - box.Extents.x; - extents.MinY = box.Center.y - box.Extents.y; - extents.MinZ = box.Center.z - box.Extents.z; - - extents.MaxX = box.Center.x + box.Extents.x; - extents.MaxY = box.Center.y + box.Extents.y; - extents.MaxZ = box.Center.z + box.Extents.z; - - hr = write_file(hFile.get(), extents); - if (FAILED(hr)) - return hr; - } - - // No skeleton data, so no animations - - return S_OK; -} - - - -//====================================================================================== -// SDKMESH -//====================================================================================== - -_Use_decl_annotations_ -HRESULT Mesh::ExportToSDKMESH(const wchar_t* szFileName, - size_t nMaterials, const Material* materials, - bool force32bit, - bool version2, - DXGI_FORMAT normalFormat, - DXGI_FORMAT uvFormat, - DXGI_FORMAT colorFormat) const noexcept -{ - using namespace DXUT; - - if (!szFileName) - return E_INVALIDARG; - - if (nMaterials > 0 && !materials) - return E_INVALIDARG; - - if (!mnFaces || !mIndices || !mnVerts || !mPositions) - return E_UNEXPECTED; - - if ((uint64_t(mnFaces) * 3) >= UINT32_MAX) - return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); - - // Build input layout/vertex decalaration - static const D3D11_INPUT_ELEMENT_DESC s_elements[] = - { - { "SV_Position", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, // 0 - { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, // 1 - { "COLOR", 0, DXGI_FORMAT_B8G8R8A8_UNORM, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, // 2 - { "TANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, // 3 - { "BINORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, // 4 - { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, // 5 - { "BLENDINDICES", 0, DXGI_FORMAT_R8G8B8A8_UINT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, // 6 - { "BLENDWEIGHT", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }, // 7 - }; - - static const D3DVERTEXELEMENT9 s_decls[] = - { - { 0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_POSITION, 0 }, // 0 - { 0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_NORMAL, 0 }, // 1 - { 0, 0, D3DDECLTYPE_D3DCOLOR, 0, D3DDECLUSAGE_COLOR, 0 }, // 2 - { 0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_TANGENT, 0 }, // 3 - { 0, 0, D3DDECLTYPE_FLOAT3, 0, D3DDECLUSAGE_BINORMAL, 0 }, // 4 - { 0, 0, D3DDECLTYPE_FLOAT2, 0, D3DDECLUSAGE_TEXCOORD, 0 }, // 5 - { 0, 0, D3DDECLTYPE_UBYTE4, 0, D3DDECLUSAGE_BLENDINDICES, 0 }, // 6 - { 0, 0, D3DDECLTYPE_UBYTE4N, 0, D3DDECLUSAGE_BLENDWEIGHT, 0 }, // 7 - { 0xFF, 0, D3DDECLTYPE_UNUSED, 0, 0, 0 }, - }; - - static_assert((std::size(s_elements) + 1) == std::size(s_decls), "InputLayouts and Vertex Decls disagree"); - - uint8_t normalType; - size_t normalStride; - switch (normalFormat) - { - case DXGI_FORMAT_R16G16B16A16_FLOAT: - normalType = D3DDECLTYPE_FLOAT16_4; normalStride = sizeof(PackedVector::XMHALF4); - break; - - case DXGI_FORMAT_R11G11B10_FLOAT: // Biased in GetVertexBuffer - normalType = D3DDECLTYPE_DXGI_R11G11B10_FLOAT; normalStride = sizeof(UINT); - break; - - default: - normalFormat = DXGI_FORMAT_R32G32B32_FLOAT; normalType = D3DDECLTYPE_FLOAT3; normalStride = sizeof(XMFLOAT3); - break; - } - - uint8_t uvType; - size_t uvStride; - switch (uvFormat) - { - case DXGI_FORMAT_R16G16_FLOAT: - uvType = D3DDECLTYPE_FLOAT16_2; uvStride = sizeof(PackedVector::XMHALF2); - break; - - default: - uvFormat = DXGI_FORMAT_R32G32_FLOAT; uvType = D3DDECLTYPE_FLOAT2; uvStride = sizeof(XMFLOAT2); - break; - } - - uint8_t colorType; - size_t colorStride; - switch (colorFormat) - { - case DXGI_FORMAT_R32G32B32A32_FLOAT: - colorType = D3DDECLTYPE_FLOAT4; colorStride = sizeof(XMFLOAT4); - break; - - case DXGI_FORMAT_R16G16B16A16_FLOAT: - colorType = D3DDECLTYPE_FLOAT16_4; colorStride = sizeof(PackedVector::XMHALF4); - break; - - case DXGI_FORMAT_R11G11B10_FLOAT: - colorType = D3DDECLTYPE_DXGI_R11G11B10_FLOAT; colorStride = sizeof(UINT); - break; - - case DXGI_FORMAT_R10G10B10A2_UNORM: - colorType = D3DDECLTYPE_DXGI_R10G10B10A2_UNORM; colorStride = sizeof(UINT); - break; - - case DXGI_FORMAT_R8G8B8A8_UNORM: - colorType = D3DDECLTYPE_UBYTE4N; colorStride = sizeof(UINT); - break; - - default: - colorFormat = DXGI_FORMAT_B8G8R8A8_UNORM; colorType = D3DDECLTYPE_D3DCOLOR; colorStride = sizeof(UINT); - break; - } - - SDKMESH_VERTEX_BUFFER_HEADER vbHeader = {}; - vbHeader.NumVertices = mnVerts; - vbHeader.Decl[0] = s_decls[0]; - - D3D11_INPUT_ELEMENT_DESC inputLayout[MAX_VERTEX_ELEMENTS] = {}; - inputLayout[0] = s_elements[0]; - - size_t nDecl = 1; - size_t stride = sizeof(XMFLOAT3); - - if (mBlendIndices && mBlendWeights) - { - // BLENDWEIGHT - vbHeader.Decl[nDecl] = s_decls[7]; - vbHeader.Decl[nDecl].Offset = static_cast(stride); - inputLayout[nDecl] = s_elements[7]; - ++nDecl; - stride += sizeof(UINT); - - // BLENDINDICES - vbHeader.Decl[nDecl] = s_decls[6]; - vbHeader.Decl[nDecl].Offset = static_cast(stride); - inputLayout[nDecl] = s_elements[6]; - ++nDecl; - stride += sizeof(UINT); - } - - if (mNormals) - { - vbHeader.Decl[nDecl] = s_decls[1]; - vbHeader.Decl[nDecl].Type = normalType; - vbHeader.Decl[nDecl].Offset = static_cast(stride); - inputLayout[nDecl] = s_elements[1]; - inputLayout[nDecl].Format = normalFormat; - ++nDecl; - stride += normalStride; - } - - if (mColors) - { - vbHeader.Decl[nDecl] = s_decls[2]; - vbHeader.Decl[nDecl].Type = colorType; - vbHeader.Decl[nDecl].Offset = static_cast(stride); - inputLayout[nDecl] = s_elements[2]; - inputLayout[nDecl].Format = colorFormat; - ++nDecl; - stride += colorStride; - } - - if (mTexCoords) - { - vbHeader.Decl[nDecl] = s_decls[5]; - vbHeader.Decl[nDecl].Type = uvType; - vbHeader.Decl[nDecl].Offset = static_cast(stride); - inputLayout[nDecl] = s_elements[5]; - inputLayout[nDecl].Format = uvFormat; - ++nDecl; - stride += uvStride; - } - - if (mTangents) - { - vbHeader.Decl[nDecl] = s_decls[3]; - vbHeader.Decl[nDecl].Type = normalType; - vbHeader.Decl[nDecl].Offset = static_cast(stride); - inputLayout[nDecl] = s_elements[3]; - inputLayout[nDecl].Format = normalFormat; - ++nDecl; - stride += normalStride; - } - - if (mBiTangents) - { - vbHeader.Decl[nDecl] = s_decls[4]; - vbHeader.Decl[nDecl].Type = normalType; - vbHeader.Decl[nDecl].Offset = static_cast(stride); - inputLayout[nDecl] = s_elements[4]; - inputLayout[nDecl].Format = normalFormat; - ++nDecl; - stride += normalStride; - } - - assert(nDecl < MAX_VERTEX_ELEMENTS); - vbHeader.Decl[nDecl] = s_decls[std::size(s_decls) - 1]; - - // Build vertex buffer - std::unique_ptr vb(new (std::nothrow) uint8_t[mnVerts * stride]); - if (!vb) - return E_OUTOFMEMORY; - - vbHeader.SizeBytes = uint64_t(mnVerts) * uint64_t(stride); - vbHeader.StrideBytes = stride; - - { - VBWriter writer; - - HRESULT hr = writer.Initialize(inputLayout, nDecl); - if (FAILED(hr)) - return hr; - - hr = writer.AddStream(vb.get(), mnVerts, 0, stride); - if (FAILED(hr)) - return hr; - - hr = GetVertexBuffer(writer); - if (FAILED(hr)) - return hr; - } - - // Build index buffer - SDKMESH_INDEX_BUFFER_HEADER ibHeader = {}; - ibHeader.NumIndices = uint64_t(mnFaces) * 3; - - std::unique_ptr ib16; - if (!force32bit && Is16BitIndexBuffer()) - { - ibHeader.SizeBytes = uint64_t(mnFaces) * 3 * sizeof(uint16_t); - ibHeader.IndexType = IT_16BIT; - - ib16 = GetIndexBuffer16(); - if (!ib16) - return E_OUTOFMEMORY; - } - else - { - ibHeader.SizeBytes = uint64_t(mnFaces) * 3 * sizeof(uint32_t); - ibHeader.IndexType = IT_32BIT; - } - - // Build materials buffer - std::unique_ptr mats; - if (version2) - { - if (!nMaterials) - { - mats.reset(new (std::nothrow) SDKMESH_MATERIAL[1]); - if (!mats) - return E_OUTOFMEMORY; - - auto mat2 = reinterpret_cast(mats.get()); - memset(mat2, 0, sizeof(SDKMESH_MATERIAL_V2)); - - strcpy_s(mat2->Name, "default"); - mat2->Alpha = 1.f; - } - else - { - mats.reset(new (std::nothrow) SDKMESH_MATERIAL[nMaterials]); - if (!mats) - return E_OUTOFMEMORY; - - for (size_t j = 0; j < nMaterials; ++j) - { - auto m0 = &materials[j]; - auto m2 = reinterpret_cast(&mats[j]); - - memset(m2, 0, sizeof(SDKMESH_MATERIAL_V2)); - - if (!m0->name.empty()) - { - const int result = WideCharToMultiByte(CP_UTF8, WC_NO_BEST_FIT_CHARS, - m0->name.c_str(), -1, - m2->Name, MAX_MATERIAL_NAME, nullptr, FALSE); - if (!result) - { - *m2->Name = 0; - } - } - - m2->Alpha = m0->alpha; - - if (!m0->texture.empty()) - { - const int result = WideCharToMultiByte(CP_UTF8, WC_NO_BEST_FIT_CHARS, - m0->texture.c_str(), -1, - m2->AlbedoTexture, MAX_TEXTURE_NAME, nullptr, FALSE); - if (!result) - { - *m2->AlbedoTexture = 0; - } - } - - // Derive other PBR texture names from base texture - { - char drive[_MAX_DRIVE] = {}; - char dir[MAX_PATH] = {}; - char fname[_MAX_FNAME] = {}; - char ext[_MAX_EXT] = {}; - _splitpath_s(m2->AlbedoTexture, drive, dir, fname, ext); - - std::string basename = fname; - const size_t pos = basename.find_last_of('_'); - if (pos != std::string::npos) - { - basename = basename.substr(0, pos); - } - - if (!basename.empty()) - { - strcpy_s(fname, basename.c_str()); - strcat_s(fname, "_normal"); - _makepath_s(m2->NormalTexture, MAX_TEXTURE_NAME, drive, dir, fname, ext); - - strcpy_s(fname, basename.c_str()); - strcat_s(fname, "_occlusionRoughnessMetallic"); - _makepath_s(m2->RMATexture, MAX_TEXTURE_NAME, drive, dir, fname, ext); - - if (m0->emissiveColor.x > 0 || m0->emissiveColor.y > 0 || m0->emissiveColor.z > 0) - { - strcpy_s(fname, basename.c_str()); - strcat_s(fname, "_emissive"); - _makepath_s(m2->EmissiveTexture, MAX_TEXTURE_NAME, drive, dir, fname, ext); - } - } - } - - // Allow normal texture material property to override derived name - if (!m0->normalTexture.empty()) - { - const int result = WideCharToMultiByte(CP_UTF8, WC_NO_BEST_FIT_CHARS, - m0->normalTexture.c_str(), -1, - m2->NormalTexture, MAX_TEXTURE_NAME, nullptr, FALSE); - if (!result) - { - *m2->NormalTexture = 0; - } - } - - // Allow emissive texture material property to override drived name - if (!m0->emissiveTexture.empty()) - { - const int result = WideCharToMultiByte(CP_UTF8, WC_NO_BEST_FIT_CHARS, - m0->emissiveTexture.c_str(), -1, - m2->EmissiveTexture, MAX_TEXTURE_NAME, nullptr, FALSE); - if (!result) - { - *m2->EmissiveTexture = 0; - } - } - - // Allow RMA texture material property to override drived name - if (!m0->rmaTexture.empty()) - { - const int result = WideCharToMultiByte(CP_UTF8, WC_NO_BEST_FIT_CHARS, - m0->rmaTexture.c_str(), -1, - m2->RMATexture, MAX_TEXTURE_NAME, nullptr, FALSE); - if (!result) - { - *m2->RMATexture = 0; - } - } - } - } - } - else if (!nMaterials) - { - mats.reset(new (std::nothrow) SDKMESH_MATERIAL[1]); - if (!mats) - return E_OUTOFMEMORY; - - memset(mats.get(), 0, sizeof(SDKMESH_MATERIAL)); - - strcpy_s(mats[0].Name, "default"); - mats[0].Diffuse = XMFLOAT4(0.8f, 0.8f, 0.8f, 1.f); - mats[0].Ambient = XMFLOAT4(0.2f, 02.f, 0.2f, 1.f); - mats[0].Power = 1.f; - } - else - { - mats.reset(new (std::nothrow) SDKMESH_MATERIAL[nMaterials]); - if (!mats) - return E_OUTOFMEMORY; - - for (size_t j = 0; j < nMaterials; ++j) - { - auto m0 = &materials[j]; - auto m = &mats[j]; - - memset(m, 0, sizeof(SDKMESH_MATERIAL)); - - if (!m0->name.empty()) - { - const int result = WideCharToMultiByte(CP_UTF8, WC_NO_BEST_FIT_CHARS, - m0->name.c_str(), -1, - m->Name, MAX_MATERIAL_NAME, nullptr, FALSE); - if (!result) - { - *m->Name = 0; - } - } - - if (!m0->texture.empty()) - { - const int result = WideCharToMultiByte(CP_UTF8, WC_NO_BEST_FIT_CHARS, - m0->texture.c_str(), -1, - m->DiffuseTexture, MAX_TEXTURE_NAME, nullptr, FALSE); - if (!result) - { - *m->DiffuseTexture = 0; - } - } - - if (!m0->normalTexture.empty()) - { - const int result = WideCharToMultiByte(CP_UTF8, WC_NO_BEST_FIT_CHARS, - m0->normalTexture.c_str(), -1, - m->NormalTexture, MAX_TEXTURE_NAME, nullptr, FALSE); - if (!result) - { - *m->NormalTexture = 0; - } - } - - if (!m0->specularTexture.empty()) - { - const int result = WideCharToMultiByte(CP_UTF8, WC_NO_BEST_FIT_CHARS, - m0->specularTexture.c_str(), -1, - m->SpecularTexture, MAX_TEXTURE_NAME, nullptr, FALSE); - if (!result) - { - *m->SpecularTexture = 0; - } - } - - m->Diffuse.x = m0->diffuseColor.x; - m->Diffuse.y = m0->diffuseColor.y; - m->Diffuse.z = m0->diffuseColor.z; - m->Diffuse.w = m0->alpha; - - m->Ambient.x = m0->ambientColor.x; - m->Ambient.y = m0->ambientColor.y; - m->Ambient.z = m0->ambientColor.z; - m->Ambient.w = 1.f; - - if (m0->specularColor.x > 0.f || m0->specularColor.y > 0.f || m0->specularColor.z > 0.f) - { - m->Specular.x = m0->specularColor.x; - m->Specular.y = m0->specularColor.y; - m->Specular.z = m0->specularColor.z; - m->Power = (m0->specularPower <= 0.f) ? 16.f : m0->specularPower; - } - else - { - m->Power = 1.f; - } - - m->Emissive.x = m0->emissiveColor.x; - m->Emissive.y = m0->emissiveColor.y; - m->Emissive.z = m0->emissiveColor.z; - } - } - - // Build subsets - std::vector submeshes; - std::vector subsetArray; - if (mAttributes) - { - auto subsets = ComputeSubsets(mAttributes.get(), mnFaces); - - UINT64 startIndex = 0; - for (const auto& it : subsets) - { - subsetArray.push_back(static_cast(submeshes.size())); - - SDKMESH_SUBSET s = {}; - s.MaterialID = mAttributes[it.first]; - if (s.MaterialID >= nMaterials) - s.MaterialID = 0; - - s.PrimitiveType = PT_TRIANGLE_LIST; - s.IndexStart = startIndex; - s.IndexCount = uint64_t(it.second) * 3; - s.VertexCount = mnVerts; - submeshes.push_back(s); - - if ((startIndex + s.IndexCount) > uint64_t(mnFaces) * 3) - return E_FAIL; - - startIndex += s.IndexCount; - } - } - else - { - SDKMESH_SUBSET s = {}; - s.PrimitiveType = PT_TRIANGLE_LIST; - s.IndexCount = uint64_t(mnFaces) * 3; - s.VertexCount = mnVerts; - subsetArray.push_back(0); - submeshes.push_back(s); - } - - // Create file -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFileName, - GENERIC_WRITE, 0, CREATE_ALWAYS, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(szFileName, - GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr))); -#endif - if (!hFile) - return HRESULT_FROM_WIN32(GetLastError()); - - // Write file header - SDKMESH_HEADER header = {}; - header.Version = (version2) ? SDKMESH_FILE_VERSION_V2 : SDKMESH_FILE_VERSION; - header.IsBigEndian = 0; - - header.NumVertexBuffers = 1; - header.NumIndexBuffers = 1; - header.NumMeshes = 1; - header.NumTotalSubsets = static_cast(submeshes.size()); - header.NumFrames = 1; - header.NumMaterials = (nMaterials > 0) ? static_cast(nMaterials) : 1; - - header.HeaderSize = sizeof(SDKMESH_HEADER) + sizeof(SDKMESH_VERTEX_BUFFER_HEADER) + sizeof(SDKMESH_INDEX_BUFFER_HEADER); - - const size_t staticDataSize = sizeof(SDKMESH_MESH) - + header.NumTotalSubsets * sizeof(SDKMESH_SUBSET) - + sizeof(SDKMESH_FRAME) - + header.NumMaterials * sizeof(SDKMESH_MATERIAL); - - header.NonBufferDataSize = uint64_t(staticDataSize) + uint64_t(subsetArray.size()) * sizeof(UINT) + sizeof(UINT); - - header.BufferDataSize = roundup4k(vbHeader.SizeBytes) + roundup4k(ibHeader.SizeBytes); - - header.VertexStreamHeadersOffset = sizeof(SDKMESH_HEADER); - header.IndexStreamHeadersOffset = header.VertexStreamHeadersOffset + sizeof(SDKMESH_VERTEX_BUFFER_HEADER); - header.MeshDataOffset = header.IndexStreamHeadersOffset + sizeof(SDKMESH_INDEX_BUFFER_HEADER); - header.SubsetDataOffset = header.MeshDataOffset + sizeof(SDKMESH_MESH); - header.FrameDataOffset = header.SubsetDataOffset + uint64_t(header.NumTotalSubsets) * sizeof(SDKMESH_SUBSET); - header.MaterialDataOffset = header.FrameDataOffset + sizeof(SDKMESH_FRAME); - - HRESULT hr = write_file(hFile.get(), header); - if (FAILED(hr)) - return hr; - - // Write buffer headers - UINT64 offset = header.HeaderSize + header.NonBufferDataSize; - - vbHeader.DataOffset = offset; - offset += roundup4k(vbHeader.SizeBytes); - - hr = write_file(hFile.get(), vbHeader); - if (FAILED(hr)) - return hr; - - ibHeader.DataOffset = offset; - offset += roundup4k(ibHeader.SizeBytes); - - hr = write_file(hFile.get(), ibHeader); - if (FAILED(hr)) - return hr; - - // Write mesh headers - assert(header.NumMeshes == 1); - offset = header.HeaderSize + staticDataSize; - - SDKMESH_MESH meshHeader = {}; - meshHeader.NumVertexBuffers = 1; - meshHeader.NumFrameInfluences = 1; - - { - BoundingBox box; - BoundingBox::CreateFromPoints(box, mnVerts, mPositions.get(), sizeof(XMFLOAT3)); - - meshHeader.BoundingBoxCenter = box.Center; - meshHeader.BoundingBoxExtents = box.Extents; - } - - meshHeader.NumSubsets = static_cast(submeshes.size()); - meshHeader.SubsetOffset = offset; - offset += uint64_t(meshHeader.NumSubsets) * sizeof(UINT); - meshHeader.FrameInfluenceOffset = offset; - offset += sizeof(UINT); - - hr = write_file(hFile.get(), meshHeader); - if (FAILED(hr)) - return hr; - - // Write subsets - auto bytesToWrite = static_cast(sizeof(SDKMESH_SUBSET) * submeshes.size()); - DWORD bytesWritten; - if (!WriteFile(hFile.get(), submeshes.data(), bytesToWrite, &bytesWritten, nullptr)) - return HRESULT_FROM_WIN32(GetLastError()); - - if (bytesWritten != bytesToWrite) - return E_FAIL; - - // Write frames - SDKMESH_FRAME frame = {}; - strcpy_s(frame.Name, "root"); - frame.ParentFrame = frame.ChildFrame = frame.SiblingFrame = DWORD(-1); - frame.AnimationDataIndex = INVALID_ANIMATION_DATA; - const XMMATRIX id = XMMatrixIdentity(); - XMStoreFloat4x4(&frame.Matrix, id); - - hr = write_file(hFile.get(), frame); - if (FAILED(hr)) - return hr; - - // Write materials - bytesToWrite = static_cast(sizeof(SDKMESH_MATERIAL) * ((nMaterials > 0) ? nMaterials : 1)); - if (!WriteFile(hFile.get(), mats.get(), bytesToWrite, &bytesWritten, nullptr)) - return HRESULT_FROM_WIN32(GetLastError()); - - if (bytesWritten != bytesToWrite) - return E_FAIL; - - // Write subset index list - assert(meshHeader.NumSubsets == subsetArray.size()); - bytesToWrite = meshHeader.NumSubsets * sizeof(UINT); - if (!WriteFile(hFile.get(), subsetArray.data(), bytesToWrite, &bytesWritten, nullptr)) - return HRESULT_FROM_WIN32(GetLastError()); - - if (bytesWritten != bytesToWrite) - return E_FAIL; - - // Write frame influence list - assert(meshHeader.NumFrameInfluences == 1); - constexpr UINT frameIndex = 0; - hr = write_file(hFile.get(), frameIndex); - if (FAILED(hr)) - return hr; - - // Write VB data - bytesToWrite = static_cast(vbHeader.SizeBytes); - if (!WriteFile(hFile.get(), vb.get(), bytesToWrite, &bytesWritten, nullptr)) - return HRESULT_FROM_WIN32(GetLastError()); - - if (bytesWritten != bytesToWrite) - return E_FAIL; - - bytesToWrite = static_cast(roundup4k(vbHeader.SizeBytes) - vbHeader.SizeBytes); - if (bytesToWrite > 0) - { - assert(bytesToWrite < sizeof(g_padding)); - if (!WriteFile(hFile.get(), g_padding, bytesToWrite, &bytesWritten, nullptr)) - return HRESULT_FROM_WIN32(GetLastError()); - - if (bytesWritten != bytesToWrite) - return E_FAIL; - } - - // Write IB data - bytesToWrite = static_cast(ibHeader.SizeBytes); - if (!WriteFile(hFile.get(), (ib16) ? static_cast(ib16.get()) : static_cast(mIndices.get()), - bytesToWrite, &bytesWritten, nullptr)) - return HRESULT_FROM_WIN32(GetLastError()); - - if (bytesWritten != bytesToWrite) - return E_FAIL; - - bytesToWrite = static_cast(roundup4k(ibHeader.SizeBytes) - ibHeader.SizeBytes); - if (bytesToWrite > 0) - { - assert(bytesToWrite < sizeof(g_padding)); - if (!WriteFile(hFile.get(), g_padding, bytesToWrite, &bytesWritten, nullptr)) - return HRESULT_FROM_WIN32(GetLastError()); - - if (bytesWritten != bytesToWrite) - return E_FAIL; - } - - return S_OK; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/Mesh.h b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/Mesh.h deleted file mode 100644 index 373a4f0..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/Mesh.h +++ /dev/null @@ -1,173 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: Mesh.h -// -// Mesh processing helper class -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkID=324981 -// http://go.microsoft.com/fwlink/?LinkID=512686 -//-------------------------------------------------------------------------------------- - -#include - -#include -#include -#include -#include -#include - - -#if defined(_XBOX_ONE) && defined(_TITLE) -#include -#else -#include -#endif - -#include - -#include "DirectXMesh.h" - -class Mesh -{ -public: - Mesh() noexcept : mnFaces(0), mnVerts(0) {} - Mesh(Mesh&& moveFrom) noexcept; - Mesh& operator= (Mesh&& moveFrom) noexcept; - - Mesh(Mesh const&) = delete; - Mesh& operator= (Mesh const&) = delete; - - // Methods - void Clear() noexcept; - - void SetMTLFileName(const std::wstring& name) noexcept { mtlFileName = name; } - - HRESULT SetIndexData(_In_ size_t nFaces, _In_reads_(nFaces * 3) const uint16_t* indices, _In_reads_opt_(nFaces) const uint32_t* attributes = nullptr) noexcept; - HRESULT SetIndexData(_In_ size_t nFaces, _In_reads_(nFaces * 3) const uint32_t* indices, _In_reads_opt_(nFaces) const uint32_t* attributes = nullptr) noexcept; - - HRESULT SetVertexData(const DirectX::VBReader& reader, _In_ size_t nVerts) noexcept; - - HRESULT Validate(_In_ DirectX::VALIDATE_FLAGS flags, _In_opt_ std::wstring* msgs) const noexcept; - - HRESULT Clean() noexcept; - - HRESULT GenerateAdjacency(_In_ float epsilon) noexcept; - - HRESULT ComputeNormals(_In_ DirectX::CNORM_FLAGS flags) noexcept; - - HRESULT ComputeTangentFrame(_In_ bool bitangents) noexcept; - - HRESULT Optimize(bool lru) noexcept; - - HRESULT ReverseWinding() noexcept; - - HRESULT InvertUTexCoord() noexcept; - HRESULT InvertVTexCoord() noexcept; - - HRESULT ReverseHandedness() noexcept; - - // Accessors - const uint32_t* GetAttributeBuffer() const noexcept { return mAttributes.get(); } - const uint32_t* GetAdjacencyBuffer() const noexcept { return mAdjacency.get(); } - const DirectX::XMFLOAT3* GetPositionBuffer() const noexcept { return mPositions.get(); } - const DirectX::XMFLOAT3* GetNormalBuffer() const noexcept { return mNormals.get(); } - const DirectX::XMFLOAT2* GetTexCoordBuffer() const noexcept { return mTexCoords.get(); } - const DirectX::XMFLOAT4* GetTangentBuffer() const noexcept { return mTangents.get(); } - const DirectX::XMFLOAT4* GetColorBuffer() const noexcept { return mColors.get(); } - - size_t GetFaceCount() const noexcept { return mnFaces; } - size_t GetVertexCount() const noexcept { return mnVerts; } - - bool Is16BitIndexBuffer() const noexcept; - - const uint32_t* GetIndexBuffer() const noexcept { return mIndices.get(); } - std::unique_ptr GetIndexBuffer16() const noexcept; - - HRESULT GetVertexBuffer(const DirectX::VBWriter& writer) const noexcept; - - // Save mesh to file - struct Material - { - std::wstring name; - bool perVertexColor; - float specularPower; - float alpha; - DirectX::XMFLOAT3 ambientColor; - DirectX::XMFLOAT3 diffuseColor; - DirectX::XMFLOAT3 specularColor; - DirectX::XMFLOAT3 emissiveColor; - std::wstring texture; - std::wstring normalTexture; - std::wstring specularTexture; - std::wstring emissiveTexture; - std::wstring rmaTexture; - - Material() noexcept : - perVertexColor(false), - specularPower(1.f), - alpha(1.f), - ambientColor{}, - diffuseColor{}, - specularColor{}, - emissiveColor{} - { - } - - Material( - const wchar_t* iname, - bool pvc, - float power, - float ialpha, - const DirectX::XMFLOAT3& ambient, - const DirectX::XMFLOAT3 diffuse, - const DirectX::XMFLOAT3& specular, - const DirectX::XMFLOAT3& emissive, - const wchar_t* txtname) : - name(iname), - perVertexColor(pvc), - specularPower(power), - alpha(ialpha), - ambientColor(ambient), - diffuseColor(diffuse), - specularColor(specular), - emissiveColor(emissive), - texture(txtname) - { - } - }; - - HRESULT ExportToOBJ(const wchar_t* szFileName, _In_ size_t nMaterials, _In_reads_opt_(nMaterials) const Material* materials) const; - HRESULT ExportToVBO(_In_z_ const wchar_t* szFileName) const noexcept; - HRESULT ExportToCMO(_In_z_ const wchar_t* szFileName, _In_ size_t nMaterials, _In_reads_opt_(nMaterials) const Material* materials) const noexcept; - HRESULT ExportToSDKMESH(_In_z_ const wchar_t* szFileName, - _In_ size_t nMaterials, _In_reads_opt_(nMaterials) const Material* materials, - bool force32bit = false, - bool version2 = false, - DXGI_FORMAT normalFormat = DXGI_FORMAT_R32G32B32_FLOAT, - DXGI_FORMAT uvFormat = DXGI_FORMAT_R32G32_FLOAT, - DXGI_FORMAT colorFormat = DXGI_FORMAT_B8G8R8A8_UNORM) const noexcept; - - // Create mesh from file - static HRESULT CreateFromVBO(_In_z_ const wchar_t* szFileName, _Inout_ std::unique_ptr& result) noexcept; - -private: - size_t mnFaces; - size_t mnVerts; - std::unique_ptr mIndices; - std::unique_ptr mAttributes; - std::unique_ptr mAdjacency; - std::unique_ptr mPositions; - std::unique_ptr mNormals; - std::unique_ptr mTangents; - std::unique_ptr mBiTangents; - std::unique_ptr mTexCoords; - std::unique_ptr mColors; - std::unique_ptr mBlendIndices; - std::unique_ptr mBlendWeights; - - std::wstring mtlFileName; - - void ExportToOBJ(std::wostream& os, _In_ size_t nMaterials, _In_reads_opt_(nMaterials) const Material* materials) const; -}; diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/MeshOBJ.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/MeshOBJ.cpp deleted file mode 100644 index d664ffc..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/MeshOBJ.cpp +++ /dev/null @@ -1,252 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: MeshOBJ.cpp -// -// Helper code for loading Mesh data from Wavefront OBJ -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkID=324981 -// http://go.microsoft.com/fwlink/?LinkID=512686 -//-------------------------------------------------------------------------------------- - -#pragma warning(push) -#pragma warning(disable : 4005) -#define WIN32_LEAN_AND_MEAN -#define NOMINMAX 1 -#define NODRAWTEXT -#define NOGDI -#define NOMCX -#define NOSERVICE -#define NOHELP -#pragma warning(pop) - -#include "Mesh.h" -#include "WaveFrontReader.h" - -#include -#include -#include -#include - -using namespace DirectX; - -namespace -{ - std::wstring ProcessTextureFileName(const wchar_t* inName, bool dds) - { - if (!inName || !*inName) - return std::wstring(); - - wchar_t txext[_MAX_EXT] = {}; - wchar_t txfname[_MAX_FNAME] = {}; - _wsplitpath_s(inName, nullptr, 0, nullptr, 0, txfname, _MAX_FNAME, txext, _MAX_EXT); - - if (dds) - { - wcscpy_s(txext, L".dds"); - } - - wchar_t texture[_MAX_PATH] = {}; - _wmakepath_s(texture, nullptr, nullptr, txfname, txext); - return std::wstring(texture); - } -} - -//-------------------------------------------------------------------------------------- -HRESULT LoadFromOBJ( - const wchar_t* szFilename, - std::unique_ptr& inMesh, - std::vector& inMaterial, - bool ccw, - bool dds) -{ - WaveFrontReader wfReader; - HRESULT hr = wfReader.Load(szFilename, ccw); - if (FAILED(hr)) - return hr; - - inMesh.reset(new (std::nothrow) Mesh); - if (!inMesh) - return E_OUTOFMEMORY; - - if (wfReader.indices.empty() || wfReader.vertices.empty()) - return E_FAIL; - - hr = inMesh->SetIndexData(wfReader.indices.size() / 3, wfReader.indices.data(), - wfReader.attributes.empty() ? nullptr : wfReader.attributes.data()); - if (FAILED(hr)) - return hr; - - static const D3D11_INPUT_ELEMENT_DESC s_vboLayout[] = - { - { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - }; - - static const D3D11_INPUT_ELEMENT_DESC s_vboLayoutAlt[] = - { - { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - }; - - const D3D11_INPUT_ELEMENT_DESC* layout = s_vboLayout; - size_t nDecl = std::size(s_vboLayout); - - if (!wfReader.hasNormals && !wfReader.hasTexcoords) - { - nDecl = 1; - } - else if (wfReader.hasNormals && !wfReader.hasTexcoords) - { - nDecl = 2; - } - else if (!wfReader.hasNormals && wfReader.hasTexcoords) - { - layout = s_vboLayoutAlt; - nDecl = std::size(s_vboLayoutAlt); - } - - VBReader vbr; - hr = vbr.Initialize(layout, nDecl); - if (FAILED(hr)) - return hr; - - hr = vbr.AddStream(wfReader.vertices.data(), wfReader.vertices.size(), 0, sizeof(WaveFrontReader::Vertex)); - if (FAILED(hr)) - return hr; - - hr = inMesh->SetVertexData(vbr, wfReader.vertices.size()); - if (FAILED(hr)) - return hr; - - if (!wfReader.materials.empty()) - { - inMaterial.clear(); - inMaterial.reserve(wfReader.materials.size()); - - for (const auto& it : wfReader.materials) - { - Mesh::Material mtl = {}; - - mtl.name = it.strName; - mtl.specularPower = (it.bSpecular) ? float(it.nShininess) : 1.f; - mtl.alpha = it.fAlpha; - mtl.ambientColor = it.vAmbient; - mtl.diffuseColor = it.vDiffuse; - mtl.specularColor = (it.bSpecular) ? it.vSpecular : XMFLOAT3(0.f, 0.f, 0.f); - mtl.emissiveColor = (it.bEmissive) ? it.vEmissive : XMFLOAT3(0.f, 0.f, 0.f); - - mtl.texture = ProcessTextureFileName(it.strTexture, dds); - mtl.normalTexture = ProcessTextureFileName(it.strNormalTexture, dds); - mtl.specularTexture = ProcessTextureFileName(it.strSpecularTexture, dds); - if (it.bEmissive) - { - mtl.emissiveTexture = ProcessTextureFileName(it.strEmissiveTexture, dds); - } - mtl.rmaTexture = ProcessTextureFileName(it.strRMATexture, dds); - - inMaterial.push_back(mtl); - } - } - - if (wfReader.materials.size() > 1) - { - inMesh->SetMTLFileName(wfReader.name); - } - - return S_OK; -} - -//-------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT Mesh::ExportToOBJ(const wchar_t* szFileName, size_t nMaterials, const Material* materials) const -{ - if (!szFileName) - return E_INVALIDARG; - - if (nMaterials > 0 && !materials) - return E_INVALIDARG; - - std::wofstream os; - os.open(szFileName); - if (!os) - return E_FAIL; - - os << L"# " << szFileName << std::endl << L"#" << std::endl << std::endl; - - ExportToOBJ(os, nMaterials, materials); - - os.close(); - - return (os.bad()) ? E_FAIL : S_OK; -} - -_Use_decl_annotations_ -void Mesh::ExportToOBJ(std::wostream& os, size_t nMaterials, const Material* materials) const -{ - os.imbue(std::locale::classic()); - - if (!mtlFileName.empty()) - os << L"mtllib ./" << mtlFileName << L".mtl" << std::endl; - - for (size_t vert = 0; vert < mnVerts; ++vert) - { - os << L"v " << mPositions[vert].x << L" " << mPositions[vert].y << L" " << mPositions[vert].z << std::endl; - } - os << std::endl; - - if (mTexCoords) - { - for (size_t vert = 0; vert < mnVerts; ++vert) - { - os << L"vt " << mTexCoords[vert].x << L" " << mTexCoords[vert].y << std::endl; - } - os << std::endl; - } - - if (mNormals) - { - for (size_t vert = 0; vert < mnVerts; ++vert) - { - os << L"vn " << mNormals[vert].x << L" " << mNormals[vert].y << L" " << mNormals[vert].z << std::endl; - } - os << std::endl; - } - - // Using the first material entry as they are all the same for our use cases - if (!materials || !mAttributes) - { - os << L"usemtl default" << std::endl; - } - - /// Now the faces, a face is the first 3 indexes in indexes on the faces vertex - uint32_t lastAttribute = uint32_t(-1); - for (size_t face = 0; face < mnFaces; ++face) - { - if (mAttributes && mAttributes[face] != lastAttribute) - { - lastAttribute = mAttributes[face]; - if (lastAttribute < nMaterials) - { - os << L"usemtl " << materials[lastAttribute].name << std::endl; - } - } - - os << L"f "; - for (size_t point = 0; point < 3; ++point) - { - const uint32_t i = mIndices[face * 3 + point] + 1; - - os << i << L"/"; - if (mTexCoords) - os << i; - os << L"/"; - if (mNormals) - os << i; - os << L" "; - } - os << std::endl; - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/Meshconvert.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/Meshconvert.cpp deleted file mode 100644 index 674c5ba..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/Meshconvert.cpp +++ /dev/null @@ -1,1081 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: Meshconvert.cpp -// -// Meshconvert command-line tool (sample for DirectXMesh library) -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkID=324981 -//-------------------------------------------------------------------------------------- - -#pragma warning(push) -#pragma warning(disable : 4005) -#define WIN32_LEAN_AND_MEAN -#define NOMINMAX -#define NODRAWTEXT -#define NOGDI -#define NOMCX -#define NOSERVICE -#define NOHELP -#pragma warning(pop) - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Mesh.h" - -using namespace DirectX; - -namespace -{ - enum OPTIONS : uint32_t - { - OPT_RECURSIVE = 1, - OPT_TOPOLOGICAL_ADJ, - OPT_GEOMETRIC_ADJ, - OPT_NORMALS, - OPT_WEIGHT_BY_AREA, - OPT_WEIGHT_BY_EQUAL, - OPT_TANGENTS, - OPT_CTF, - OPT_OPTIMIZE, - OPT_OPTIMIZE_LRU, - OPT_CLEAN, - OPT_OUTPUTFILE, - OPT_TOLOWER, - OPT_SDKMESH, - OPT_SDKMESH_V2, - OPT_CMO, - OPT_VBO, - OPT_WAVEFRONT_OBJ, - OPT_CLOCKWISE, - OPT_FORCE_32BIT_IB, - OPT_OVERWRITE, - OPT_NODDS, - OPT_FLIP, - OPT_FLIPU, - OPT_FLIPV, - OPT_FLIPZ, - OPT_VERT_NORMAL_FORMAT, - OPT_VERT_UV_FORMAT, - OPT_VERT_COLOR_FORMAT, - OPT_NOLOGO, - OPT_FILELIST, - OPT_MAX - }; - - static_assert(OPT_MAX <= 32, "dwOptions is a unsigned int bitfield"); - - struct SConversion - { - wchar_t szSrc[MAX_PATH]; - }; - - struct SValue - { - const wchar_t* name; - uint32_t value; - }; - - ////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////// - - const SValue g_pOptions[] = - { - { L"r", OPT_RECURSIVE }, - { L"ta", OPT_TOPOLOGICAL_ADJ }, - { L"ga", OPT_GEOMETRIC_ADJ }, - { L"n", OPT_NORMALS }, - { L"na", OPT_WEIGHT_BY_AREA }, - { L"ne", OPT_WEIGHT_BY_EQUAL }, - { L"t", OPT_TANGENTS }, - { L"tb", OPT_CTF }, - { L"op", OPT_OPTIMIZE }, - { L"oplru", OPT_OPTIMIZE_LRU }, - { L"c", OPT_CLEAN }, - { L"o", OPT_OUTPUTFILE }, - { L"l", OPT_TOLOWER }, - { L"sdkmesh", OPT_SDKMESH }, - { L"sdkmesh2", OPT_SDKMESH_V2 }, - { L"cmo", OPT_CMO }, - { L"vbo", OPT_VBO }, - { L"wf", OPT_WAVEFRONT_OBJ }, - { L"cw", OPT_CLOCKWISE }, - { L"ib32", OPT_FORCE_32BIT_IB }, - { L"y", OPT_OVERWRITE }, - { L"nodds", OPT_NODDS }, - { L"flip", OPT_FLIP }, - { L"flipu", OPT_FLIPU }, - { L"flipv", OPT_FLIPV }, - { L"flipz", OPT_FLIPZ }, - { L"fn", OPT_VERT_NORMAL_FORMAT }, - { L"fuv", OPT_VERT_UV_FORMAT }, - { L"fc", OPT_VERT_COLOR_FORMAT }, - { L"nologo", OPT_NOLOGO }, - { L"flist", OPT_FILELIST }, - { nullptr, 0 } - }; - - const SValue g_vertexNormalFormats[] = - { - { L"float3", DXGI_FORMAT_R32G32B32_FLOAT }, - { L"float16_4", DXGI_FORMAT_R16G16B16A16_FLOAT }, - { L"r11g11b10", DXGI_FORMAT_R11G11B10_FLOAT }, - { nullptr, 0 } - }; - - const SValue g_vertexUVFormats[] = - { - { L"float2", DXGI_FORMAT_R32G32_FLOAT }, - { L"float16_2", DXGI_FORMAT_R16G16_FLOAT }, - { nullptr, 0 } - }; - - const SValue g_vertexColorFormats[] = - { - { L"bgra", DXGI_FORMAT_B8G8R8A8_UNORM }, - { L"rgba", DXGI_FORMAT_R8G8B8A8_UNORM }, - { L"float4", DXGI_FORMAT_R32G32B32A32_FLOAT }, - { L"float16_4", DXGI_FORMAT_R16G16B16A16_FLOAT }, - { L"rgba_10", DXGI_FORMAT_R10G10B10A2_UNORM }, - { L"r11g11b10", DXGI_FORMAT_R11G11B10_FLOAT }, - { nullptr, 0 } - }; -} - -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -HRESULT LoadFromOBJ(const wchar_t* szFilename, - std::unique_ptr& inMesh, std::vector& inMaterial, - bool ccw, bool dds); - -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -namespace -{ - inline HANDLE safe_handle(HANDLE h) noexcept { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; } - - struct find_closer { void operator()(HANDLE h) noexcept { assert(h != INVALID_HANDLE_VALUE); if (h) FindClose(h); } }; - - using ScopedFindHandle = std::unique_ptr; - -#ifdef __PREFAST__ -#pragma prefast(disable : 26018, "Only used with static internal arrays") -#endif - - uint32_t LookupByName(const wchar_t* pName, const SValue* pArray) - { - while (pArray->name) - { - if (!_wcsicmp(pName, pArray->name)) - return pArray->value; - - pArray++; - } - - return 0; - } - - void SearchForFiles(const wchar_t* path, std::list& files, bool recursive) - { - // Process files - WIN32_FIND_DATAW findData = {}; - ScopedFindHandle hFile(safe_handle(FindFirstFileExW(path, - FindExInfoBasic, &findData, - FindExSearchNameMatch, nullptr, - FIND_FIRST_EX_LARGE_FETCH))); - if (hFile) - { - for (;;) - { - if (!(findData.dwFileAttributes & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_DIRECTORY))) - { - wchar_t drive[_MAX_DRIVE] = {}; - wchar_t dir[_MAX_DIR] = {}; - _wsplitpath_s(path, drive, _MAX_DRIVE, dir, _MAX_DIR, nullptr, 0, nullptr, 0); - - SConversion conv = {}; - _wmakepath_s(conv.szSrc, drive, dir, findData.cFileName, nullptr); - files.push_back(conv); - } - - if (!FindNextFileW(hFile.get(), &findData)) - break; - } - } - - // Process directories - if (recursive) - { - wchar_t searchDir[MAX_PATH] = {}; - { - wchar_t drive[_MAX_DRIVE] = {}; - wchar_t dir[_MAX_DIR] = {}; - _wsplitpath_s(path, drive, _MAX_DRIVE, dir, _MAX_DIR, nullptr, 0, nullptr, 0); - _wmakepath_s(searchDir, drive, dir, L"*", nullptr); - } - - hFile.reset(safe_handle(FindFirstFileExW(searchDir, - FindExInfoBasic, &findData, - FindExSearchLimitToDirectories, nullptr, - FIND_FIRST_EX_LARGE_FETCH))); - if (!hFile) - return; - - for (;;) - { - if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - { - if (findData.cFileName[0] != L'.') - { - wchar_t subdir[MAX_PATH] = {}; - - { - wchar_t drive[_MAX_DRIVE] = {}; - wchar_t dir[_MAX_DIR] = {}; - wchar_t fname[_MAX_FNAME] = {}; - wchar_t ext[_MAX_FNAME] = {}; - _wsplitpath_s(path, drive, dir, fname, ext); - wcscat_s(dir, findData.cFileName); - _wmakepath_s(subdir, drive, dir, fname, ext); - } - - SearchForFiles(subdir, files, recursive); - } - } - - if (!FindNextFileW(hFile.get(), &findData)) - break; - } - } - } - - void ProcessFileList(std::wifstream& inFile, std::list& files) - { - std::list flist; - std::set excludes; - wchar_t fname[1024] = {}; - for (;;) - { - inFile >> fname; - if (!inFile) - break; - - if (*fname == L'#') - { - // Comment - } - else if (*fname == L'-') - { - if (flist.empty()) - { - wprintf(L"WARNING: Ignoring the line '%ls' in -flist\n", fname); - } - else - { - if (wcspbrk(fname, L"?*") != nullptr) - { - std::list removeFiles; - SearchForFiles(&fname[1], removeFiles, false); - - for (auto it : removeFiles) - { - _wcslwr_s(it.szSrc); - excludes.insert(it.szSrc); - } - } - else - { - std::wstring name = (fname + 1); - std::transform(name.begin(), name.end(), name.begin(), towlower); - excludes.insert(name); - } - } - } - else if (wcspbrk(fname, L"?*") != nullptr) - { - SearchForFiles(fname, flist, false); - } - else - { - SConversion conv = {}; - wcscpy_s(conv.szSrc, MAX_PATH, fname); - flist.push_back(conv); - } - - inFile.ignore(1000, '\n'); - } - - inFile.close(); - - if (!excludes.empty()) - { - // Remove any excluded files - for (auto it = flist.begin(); it != flist.end();) - { - std::wstring name = it->szSrc; - std::transform(name.begin(), name.end(), name.begin(), towlower); - auto item = it; - ++it; - if (excludes.find(name) != excludes.end()) - { - flist.erase(item); - } - } - } - - if (flist.empty()) - { - wprintf(L"WARNING: No file names found in -flist\n"); - } - else - { - files.splice(files.end(), flist); - } - } - - void PrintList(size_t cch, const SValue* pValue) - { - while (pValue->name) - { - const size_t cchName = wcslen(pValue->name); - - if (cch + cchName + 2 >= 80) - { - wprintf(L"\n "); - cch = 6; - } - - wprintf(L"%ls ", pValue->name); - cch += cchName + 2; - pValue++; - } - - wprintf(L"\n"); - } - - void PrintLogo() - { - wchar_t version[32] = {}; - - wchar_t appName[_MAX_PATH] = {}; - if (GetModuleFileNameW(nullptr, appName, static_cast(std::size(appName)))) - { - const DWORD size = GetFileVersionInfoSizeW(appName, nullptr); - if (size > 0) - { - auto verInfo = std::make_unique(size); - if (GetFileVersionInfoW(appName, 0, size, verInfo.get())) - { - LPVOID lpstr = nullptr; - UINT strLen = 0; - if (VerQueryValueW(verInfo.get(), L"\\StringFileInfo\\040904B0\\ProductVersion", &lpstr, &strLen)) - { - wcsncpy_s(version, reinterpret_cast(lpstr), strLen); - } - } - } - } - - if (!*version || wcscmp(version, L"1.0.0.0") == 0) - { - swprintf_s(version, L"%03d (library)", DIRECTX_MESH_VERSION); - } - - wprintf(L"Microsoft (R) MeshConvert Command-line Tool Version %ls\n", version); - wprintf(L"Copyright (C) Microsoft Corp.\n"); -#ifdef _DEBUG - wprintf(L"*** Debug build ***\n"); -#endif - wprintf(L"\n"); - } - - void PrintUsage() - { - PrintLogo(); - - wprintf(L"Usage: meshconvert \n"); - wprintf(L"\n"); - wprintf(L" Input file type must be Wavefront Object (.obj)\n\n"); - wprintf(L" Output file type:\n"); - wprintf(L" -sdkmesh DirectX SDK .sdkmesh format (default)\n"); - wprintf(L" -sdkmesh2 .sdkmesh format version 2 (PBR materials)\n"); - wprintf(L" -cmo Visual Studio Content Pipeline .cmo format\n"); - wprintf(L" -vbo Vertex Buffer Object (.vbo) format\n"); - wprintf(L" -wf WaveFront Object (.obj) format\n\n"); - wprintf(L" -r wildcard filename search is recursive\n"); - wprintf(L" -n | -na | -ne generate normals weighted by angle/area/equal\n"); - wprintf(L" -t generate tangents\n"); - wprintf(L" -tb generate tangents & bi-tangents\n"); - wprintf(L" -cw faces are clockwise (defaults to counter-clockwise)\n"); - wprintf(L" -op | -oplru vertex cache optimize the mesh (implies -c)\n"); - wprintf(L" -c mesh cleaning including vertex dups for atttribute sets\n"); - wprintf(L" -ta | -ga generate topological vs. geometric adjancecy (def: ta)\n"); - wprintf(L" -nodds prevents extension renaming in exported materials\n"); - wprintf(L" -flip reverse winding of faces\n"); - wprintf(L" -flipu inverts the u texcoords\n"); - wprintf(L" -flipv inverts the v texcoords\n"); - wprintf(L" -flipz flips the handedness of the positions/normals\n"); - wprintf(L" -o output filename\n"); - wprintf(L" -l force output filename to lower case\n"); - wprintf(L" -y overwrite existing output file (if any)\n"); - wprintf(L" -nologo suppress copyright message\n"); - wprintf(L" -flist use text file with a list of input files (one per line)\n"); - wprintf(L"\n (sdkmesh/sdkmesh2 only)\n"); - wprintf(L" -ib32 use 32-bit index buffer\n"); - wprintf(L" -fn format to use for writing normals/tangents/normals\n"); - wprintf(L" -fuv format to use for texture coordinates\n"); - wprintf(L" -fc format to use for writing colors\n"); - - wprintf(L"\n : "); - PrintList(13, g_vertexNormalFormats); - - wprintf(L"\n : "); - PrintList(13, g_vertexUVFormats); - - wprintf(L"\n : "); - PrintList(13, g_vertexColorFormats); - } - - const wchar_t* GetErrorDesc(HRESULT hr) - { - static wchar_t desc[1024] = {}; - - LPWSTR errorText = nullptr; - - const DWORD result = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_ALLOCATE_BUFFER, - nullptr, static_cast(hr), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast(&errorText), 0, nullptr); - - *desc = 0; - - if (result > 0 && errorText) - { - swprintf_s(desc, L": %ls", errorText); - - size_t len = wcslen(desc); - if (len >= 1) - { - desc[len - 1] = 0; - } - - if (errorText) - LocalFree(errorText); - } - - return desc; - } -} - -//-------------------------------------------------------------------------------------- -// Entry-point -//-------------------------------------------------------------------------------------- -#ifdef __PREFAST__ -#pragma prefast(disable : 28198, "Command-line tool, frees all memory on exit") -#endif - -int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[]) -{ - // Parameters and defaults - DXGI_FORMAT normalFormat = DXGI_FORMAT_R32G32B32_FLOAT; - DXGI_FORMAT uvFormat = DXGI_FORMAT_R32G32_FLOAT; - DXGI_FORMAT colorFormat = DXGI_FORMAT_B8G8R8A8_UNORM; - - wchar_t szOutputFile[MAX_PATH] = {}; - - // Set locale for output since GetErrorDesc can get localized strings. - std::locale::global(std::locale("")); - - // Process command line - uint32_t dwOptions = 0; - std::list conversion; - - for (int iArg = 1; iArg < argc; iArg++) - { - PWSTR pArg = argv[iArg]; - - if (('-' == pArg[0]) || ('/' == pArg[0])) - { - pArg++; - PWSTR pValue; - - for (pValue = pArg; *pValue && (':' != *pValue); pValue++); - - if (*pValue) - *pValue++ = 0; - - const uint32_t dwOption = LookupByName(pArg, g_pOptions); - - if (!dwOption || (dwOptions & (1 << dwOption))) - { - wprintf(L"ERROR: unknown command-line option '%ls'\n\n", pArg); - PrintUsage(); - return 1; - } - - dwOptions |= (1 << dwOption); - - // Handle options with additional value parameter - switch (dwOption) - { - case OPT_OUTPUTFILE: - case OPT_VERT_NORMAL_FORMAT: - case OPT_VERT_UV_FORMAT: - case OPT_VERT_COLOR_FORMAT: - case OPT_FILELIST: - if (!*pValue) - { - if ((iArg + 1 >= argc)) - { - wprintf(L"ERROR: missing value for command-line option '%ls'\n\n", pArg); - PrintUsage(); - return 1; - } - - iArg++; - pValue = argv[iArg]; - } - break; - } - - switch (dwOption) - { - case OPT_OPTIMIZE_LRU: - dwOptions |= (1 << OPT_OPTIMIZE); - break; - - case OPT_WEIGHT_BY_AREA: - if (dwOptions & (1 << OPT_WEIGHT_BY_EQUAL)) - { - wprintf(L"Cannot use both na and ne at the same time\n"); - return 1; - } - dwOptions |= (1 << OPT_NORMALS); - break; - - case OPT_WEIGHT_BY_EQUAL: - if (dwOptions & (1 << OPT_WEIGHT_BY_AREA)) - { - wprintf(L"Cannot use both na and ne at the same time\n"); - return 1; - } - dwOptions |= (1 << OPT_NORMALS); - break; - - case OPT_OUTPUTFILE: - wcscpy_s(szOutputFile, MAX_PATH, pValue); - break; - - case OPT_TOPOLOGICAL_ADJ: - if (dwOptions & (1 << OPT_GEOMETRIC_ADJ)) - { - wprintf(L"Cannot use both ta and ga at the same time\n"); - return 1; - } - break; - - case OPT_GEOMETRIC_ADJ: - if (dwOptions & (1 << OPT_TOPOLOGICAL_ADJ)) - { - wprintf(L"Cannot use both ta and ga at the same time\n"); - return 1; - } - break; - - case OPT_SDKMESH: - case OPT_SDKMESH_V2: - if (dwOptions & ((1 << OPT_VBO) | (1 << OPT_CMO) | (1 << OPT_WAVEFRONT_OBJ))) - { - wprintf(L"Can only use one of sdkmesh, cmo, vbo, or wf\n"); - return 1; - } - if (dwOption == OPT_SDKMESH_V2) - { - dwOptions |= (1 << OPT_SDKMESH); - } - break; - - case OPT_CMO: - if (dwOptions & ((1 << OPT_VBO) | (1 << OPT_SDKMESH) | (1 << OPT_WAVEFRONT_OBJ))) - { - wprintf(L"Can only use one of sdkmesh, cmo, vbo, or wf\n"); - return 1; - } - break; - - case OPT_VBO: - if (dwOptions & ((1 << OPT_SDKMESH) | (1 << OPT_CMO) | (1 << OPT_WAVEFRONT_OBJ))) - { - wprintf(L"Can only use one of sdkmesh, cmo, vbo, or wf\n"); - return 1; - } - break; - - case OPT_WAVEFRONT_OBJ: - if (dwOptions & ((1 << OPT_VBO) | (1 << OPT_SDKMESH) | (1 << OPT_CMO))) - { - wprintf(L"Can only use one of sdkmesh, cmo, vbo, or wf\n"); - return 1; - } - break; - - case OPT_VERT_NORMAL_FORMAT: - normalFormat = static_cast(LookupByName(pValue, g_vertexNormalFormats)); - if (!normalFormat) - { - wprintf(L"Invalid value specified with -fn (%ls)\n", pValue); - wprintf(L"\n"); - PrintUsage(); - return 1; - } - break; - - case OPT_VERT_UV_FORMAT: - uvFormat = static_cast(LookupByName(pValue, g_vertexUVFormats)); - if (!uvFormat) - { - wprintf(L"Invalid value specified with -fuv (%ls)\n", pValue); - wprintf(L"\n"); - PrintUsage(); - return 1; - } - break; - - case OPT_VERT_COLOR_FORMAT: - colorFormat = static_cast(LookupByName(pValue, g_vertexColorFormats)); - if (!colorFormat) - { - wprintf(L"Invalid value specified with -fc (%ls)\n", pValue); - wprintf(L"\n"); - PrintUsage(); - return 1; - } - break; - - case OPT_FILELIST: - { - std::wifstream inFile(pValue); - if (!inFile) - { - wprintf(L"Error opening -flist file %ls\n", pValue); - return 1; - } - - inFile.imbue(std::locale::classic()); - - ProcessFileList(inFile, conversion); - } - break; - } - } - else if (wcspbrk(pArg, L"?*") != nullptr) - { - const size_t count = conversion.size(); - SearchForFiles(pArg, conversion, (dwOptions & (1 << OPT_RECURSIVE)) != 0); - if (conversion.size() <= count) - { - wprintf(L"No matching files found for %ls\n", pArg); - return 1; - } - } - else - { - SConversion conv = {}; - wcscpy_s(conv.szSrc, MAX_PATH, pArg); - - conversion.push_back(conv); - } - } - - if (conversion.empty()) - { - PrintUsage(); - return 0; - } - - if (*szOutputFile && conversion.size() > 1) - { - wprintf(L"Cannot use -o with multiple input files\n"); - return 1; - } - - if (~dwOptions & (1 << OPT_NOLOGO)) - PrintLogo(); - - // Process files - for (auto pConv = conversion.begin(); pConv != conversion.end(); ++pConv) - { - wchar_t ext[_MAX_EXT] = {}; - wchar_t fname[_MAX_FNAME] = {}; - _wsplitpath_s(pConv->szSrc, nullptr, 0, nullptr, 0, fname, _MAX_FNAME, ext, _MAX_EXT); - - if (pConv != conversion.begin()) - wprintf(L"\n"); - - wprintf(L"reading %ls", pConv->szSrc); - fflush(stdout); - - std::unique_ptr inMesh; - std::vector inMaterial; - HRESULT hr = E_NOTIMPL; - if (_wcsicmp(ext, L".vbo") == 0) - { - hr = Mesh::CreateFromVBO(pConv->szSrc, inMesh); - } - else if (_wcsicmp(ext, L".sdkmesh") == 0) - { - wprintf(L"\nERROR: Importing SDKMESH files not supported\n"); - return 1; - } - else if (_wcsicmp(ext, L".cmo") == 0) - { - wprintf(L"\nERROR: Importing Visual Studio CMO files not supported\n"); - return 1; - } - else if (_wcsicmp(ext, L".x") == 0) - { - wprintf(L"\nERROR: Legacy Microsoft X files not supported\n"); - return 1; - } - else if (_wcsicmp(ext, L".fbx") == 0) - { - wprintf(L"\nERROR: Autodesk FBX files not supported\n"); - return 1; - } - else - { - hr = LoadFromOBJ(pConv->szSrc, inMesh, inMaterial, - (dwOptions & (1 << OPT_CLOCKWISE)) ? false : true, - (dwOptions & (1 << OPT_NODDS)) ? false : true); - } - if (FAILED(hr)) - { - wprintf(L" FAILED (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - size_t nVerts = inMesh->GetVertexCount(); - const size_t nFaces = inMesh->GetFaceCount(); - - if (!nVerts || !nFaces) - { - wprintf(L"\nERROR: Invalid mesh\n"); - return 1; - } - - assert(inMesh->GetPositionBuffer() != nullptr); - assert(inMesh->GetIndexBuffer() != nullptr); - - wprintf(L"\n%zu vertices, %zu faces", nVerts, nFaces); - - if (dwOptions & (1 << OPT_FLIPU)) - { - hr = inMesh->InvertUTexCoord(); - if (FAILED(hr)) - { - wprintf(L"\nERROR: Failed inverting u texcoord (%08X%ls)\n", - static_cast(hr), GetErrorDesc(hr)); - return 1; - } - } - - if (dwOptions & (1 << OPT_FLIPV)) - { - hr = inMesh->InvertVTexCoord(); - if (FAILED(hr)) - { - wprintf(L"\nERROR: Failed inverting v texcoord (%08X%ls)\n", - static_cast(hr), GetErrorDesc(hr)); - return 1; - } - } - - if (dwOptions & (1 << OPT_FLIPZ)) - { - hr = inMesh->ReverseHandedness(); - if (FAILED(hr)) - { - wprintf(L"\nERROR: Failed reversing handedness (%08X%ls)\n", - static_cast(hr), GetErrorDesc(hr)); - return 1; - } - } - - // Prepare mesh for processing - if (dwOptions & ((1 << OPT_OPTIMIZE) | (1 << OPT_CLEAN))) - { - // Adjacency - const float epsilon = (dwOptions & (1 << OPT_GEOMETRIC_ADJ)) ? 1e-5f : 0.f; - - hr = inMesh->GenerateAdjacency(epsilon); - if (FAILED(hr)) - { - wprintf(L"\nERROR: Failed generating adjacency (%08X%ls)\n", - static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - // Validation - std::wstring msgs; - hr = inMesh->Validate(VALIDATE_BACKFACING, &msgs); - if (!msgs.empty()) - { - wprintf(L"\nWARNING: \n"); - wprintf(L"%ls", msgs.c_str()); - } - - // Clean (also handles attribute reuse split if needed) - hr = inMesh->Clean(); - if (FAILED(hr)) - { - wprintf(L"\nERROR: Failed mesh clean (%08X%ls)\n", - static_cast(hr), GetErrorDesc(hr)); - return 1; - } - else - { - const size_t nNewVerts = inMesh->GetVertexCount(); - if (nVerts != nNewVerts) - { - wprintf(L" [%zu vertex dups] ", nNewVerts - nVerts); - nVerts = nNewVerts; - } - } - } - - if (!inMesh->GetNormalBuffer()) - { - dwOptions |= 1 << OPT_NORMALS; - } - - if (!inMesh->GetTangentBuffer() && (dwOptions & (1 << OPT_CMO))) - { - dwOptions |= 1 << OPT_TANGENTS; - } - - // Compute vertex normals from faces - if ((dwOptions & (1 << OPT_NORMALS)) - || ((dwOptions & ((1 << OPT_TANGENTS) | (1 << OPT_CTF))) && !inMesh->GetNormalBuffer())) - { - CNORM_FLAGS flags = CNORM_DEFAULT; - - if (dwOptions & (1 << OPT_WEIGHT_BY_EQUAL)) - { - flags |= CNORM_WEIGHT_EQUAL; - } - else if (dwOptions & (1 << OPT_WEIGHT_BY_AREA)) - { - flags |= CNORM_WEIGHT_BY_AREA; - } - - if (dwOptions & (1 << OPT_CLOCKWISE)) - { - flags |= CNORM_WIND_CW; - } - - hr = inMesh->ComputeNormals(flags); - if (FAILED(hr)) - { - wprintf(L"\nERROR: Failed computing normals (flags:%lX, %08X%ls)\n", - flags, static_cast(hr), GetErrorDesc(hr)); - return 1; - } - } - - // Compute tangents and bitangents - if (dwOptions & ((1 << OPT_TANGENTS) | (1 << OPT_CTF))) - { - if (!inMesh->GetTexCoordBuffer()) - { - wprintf(L"\nERROR: Computing tangents/bi-tangents requires texture coordinates\n"); - return 1; - } - - hr = inMesh->ComputeTangentFrame((dwOptions & (1 << OPT_CTF)) ? true : false); - if (FAILED(hr)) - { - wprintf(L"\nERROR: Failed computing tangent frame (%08X%ls)\n", - static_cast(hr), GetErrorDesc(hr)); - return 1; - } - } - - // Perform attribute and vertex-cache optimization - if (dwOptions & (1 << OPT_OPTIMIZE)) - { - assert(inMesh->GetAdjacencyBuffer() != nullptr); - - float acmr, atvr; - ComputeVertexCacheMissRate(inMesh->GetIndexBuffer(), nFaces, nVerts, OPTFACES_V_DEFAULT, acmr, atvr); - - wprintf(L" [ACMR %f, ATVR %f] ", acmr, atvr); - - hr = inMesh->Optimize((dwOptions & (1 << OPT_OPTIMIZE_LRU)) ? true : false); - if (FAILED(hr)) - { - wprintf(L"\nERROR: Failed vertex-cache optimization (%08X%ls)\n", - static_cast(hr), GetErrorDesc(hr)); - return 1; - } - } - - if (dwOptions & (1 << OPT_FLIP)) - { - hr = inMesh->ReverseWinding(); - if (FAILED(hr)) - { - wprintf(L"\nERROR: Failed reversing winding (%08X%ls)\n", - static_cast(hr), GetErrorDesc(hr)); - return 1; - } - } - - // Write results - wprintf(L"\n\t->\n"); - - if (dwOptions & (1 << OPT_OPTIMIZE)) - { - float acmr, atvr; - ComputeVertexCacheMissRate(inMesh->GetIndexBuffer(), nFaces, nVerts, OPTFACES_V_DEFAULT, acmr, atvr); - - wprintf(L" [ACMR %f, ATVR %f] ", acmr, atvr); - } - - wchar_t outputPath[MAX_PATH] = {}; - wchar_t outputExt[_MAX_EXT] = {}; - - if (*szOutputFile) - { - wcscpy_s(outputPath, szOutputFile); - - _wsplitpath_s(szOutputFile, nullptr, 0, nullptr, 0, nullptr, 0, outputExt, _MAX_EXT); - } - else - { - if (dwOptions & (1 << OPT_VBO)) - { - wcscpy_s(outputExt, L".vbo"); - } - else if (dwOptions & (1 << OPT_CMO)) - { - wcscpy_s(outputExt, L".cmo"); - } - else if (dwOptions & (1 << OPT_WAVEFRONT_OBJ)) - { - wcscpy_s(outputExt, L".obj"); - } - else - { - wcscpy_s(outputExt, L".sdkmesh"); - } - - wchar_t outFilename[_MAX_FNAME] = {}; - wcscpy_s(outFilename, fname); - - _wmakepath_s(outputPath, nullptr, nullptr, outFilename, outputExt); - } - - if (dwOptions & (1 << OPT_TOLOWER)) - { - std::ignore = _wcslwr_s(outputPath); - } - - if (~dwOptions & (1 << OPT_OVERWRITE)) - { - if (GetFileAttributesW(outputPath) != INVALID_FILE_ATTRIBUTES) - { - wprintf(L"\nERROR: Output file already exists, use -y to overwrite:\n'%ls'\n", outputPath); - return 1; - } - } - - if (!_wcsicmp(outputExt, L".vbo")) - { - if (!inMesh->GetNormalBuffer() || !inMesh->GetTexCoordBuffer()) - { - wprintf(L"\nERROR: VBO requires position, normal, and texcoord\n"); - return 1; - } - - if (!inMesh->Is16BitIndexBuffer() || (dwOptions & (1 << OPT_FORCE_32BIT_IB))) - { - wprintf(L"\nERROR: VBO only supports 16-bit indices\n"); - return 1; - } - - hr = inMesh->ExportToVBO(outputPath); - } - else if (!_wcsicmp(outputExt, L".sdkmesh")) - { - hr = inMesh->ExportToSDKMESH( - outputPath, - inMaterial.size(), inMaterial.empty() ? nullptr : inMaterial.data(), - (dwOptions & (1 << OPT_FORCE_32BIT_IB)) ? true : false, - (dwOptions & (1 << OPT_SDKMESH_V2)) ? true : false, - normalFormat, - uvFormat, - colorFormat); - } - else if (!_wcsicmp(outputExt, L".cmo")) - { - if (!inMesh->GetNormalBuffer() || !inMesh->GetTexCoordBuffer() || !inMesh->GetTangentBuffer()) - { - wprintf(L"\nERROR: Visual Studio CMO requires position, normal, tangents, and texcoord\n"); - return 1; - } - - if (!inMesh->Is16BitIndexBuffer() || (dwOptions & (1 << OPT_FORCE_32BIT_IB))) - { - wprintf(L"\nERROR: Visual Studio CMO only supports 16-bit indices\n"); - return 1; - } - - hr = inMesh->ExportToCMO(outputPath, inMaterial.size(), inMaterial.empty() ? nullptr : inMaterial.data()); - } - else if (!_wcsicmp(outputExt, L".obj") || !_wcsicmp(outputExt, L"._obj")) - { - hr = inMesh->ExportToOBJ(outputPath, inMaterial.size(), inMaterial.empty() ? nullptr : inMaterial.data()); - } - else if (!_wcsicmp(outputExt, L".x")) - { - wprintf(L"\nERROR: Legacy Microsoft X files not supported\n"); - return 1; - } - else - { - wprintf(L"\nERROR: Unknown output file type '%ls'\n", outputExt); - return 1; - } - - if (FAILED(hr)) - { - wprintf(L"\nERROR: Failed write (%08X%ls):-> '%ls'\n", - static_cast(hr), GetErrorDesc(hr), outputPath); - return 1; - } - - wprintf(L" %zu vertices, %zu faces written:\n'%ls'\n", nVerts, nFaces, outputPath); - } - - return 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/Meshconvert_Desktop_2019.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/Meshconvert_Desktop_2019.vcxproj deleted file mode 100644 index 92d69c5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/Meshconvert_Desktop_2019.vcxproj +++ /dev/null @@ -1,300 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Profile - Win32 - - - Profile - x64 - - - Release - Win32 - - - Release - x64 - - - - meshconvert - {6D4CFD0E-8772-462A-9AC1-7DBAD9C16880} - meshconvert - Win32Proj - 10.0 - - - - Application - true - Unicode - v142 - - - Application - true - Unicode - v142 - - - Application - true - Unicode - v142 - - - Application - true - Unicode - v142 - - - Application - true - Unicode - v142 - - - Application - true - Unicode - v142 - - - - - - - - - - - - - - - - - - - - - - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - meshconvert - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - meshconvert - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - meshconvert - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - meshconvert - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - meshconvert - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - meshconvert - true - - - - Level4 - Disabled - MultiThreadedDebugDLL - Fast - StreamingSIMDExtensions2 - ..\DirectXMesh;..\Utilities;%(AdditionalIncludeDirectories) - true - WIN32;_DEBUG;DEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - Console - true - true - - - false - - - - - Level4 - Disabled - MultiThreadedDebugDLL - Fast - ..\DirectXMesh;..\Utilities;%(AdditionalIncludeDirectories) - true - WIN32;_DEBUG;DEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - Console - true - - - false - - - - - Level4 - MaxSpeed - Fast - StreamingSIMDExtensions2 - ..\DirectXMesh;..\Utilities;%(AdditionalIncludeDirectories) - true - WIN32;NDEBUG;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - Guard - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - 26812 - - - ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - true - - - false - - - - - Level4 - MaxSpeed - Fast - ..\DirectXMesh;..\Utilities;%(AdditionalIncludeDirectories) - true - WIN32;NDEBUG;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - Guard - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - 26812 - - - ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - - - false - - - - - Level4 - MaxSpeed - Fast - StreamingSIMDExtensions2 - ..\DirectXMesh;..\Utilities;%(AdditionalIncludeDirectories) - true - WIN32;NDEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - Guard - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - 26812 - - - ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - true - - - false - - - - - Level4 - MaxSpeed - Fast - ..\DirectXMesh;..\Utilities;%(AdditionalIncludeDirectories) - true - WIN32;NDEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - Guard - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - 26812 - - - ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - - - false - - - - - {6857f086-f6fe-4150-9ed7-7446f1c1c220} - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/Meshconvert_Desktop_2019.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/Meshconvert_Desktop_2019.vcxproj.filters deleted file mode 100644 index 41f44e5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/Meshconvert_Desktop_2019.vcxproj.filters +++ /dev/null @@ -1,33 +0,0 @@ - - - - - {8e114980-c1a3-4ada-ad7c-83caadf5daeb} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - {a500efbf-87f7-4c3b-b7c4-a3505a25d342} - - - - - - - - Wavefront OBJ - - - - - Wavefront OBJ - - - - - - Resource Files - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/Meshconvert_Desktop_2022.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/Meshconvert_Desktop_2022.vcxproj deleted file mode 100644 index 20cb338..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/Meshconvert_Desktop_2022.vcxproj +++ /dev/null @@ -1,306 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Profile - Win32 - - - Profile - x64 - - - Release - Win32 - - - Release - x64 - - - - meshconvert - {6D4CFD0E-8772-462A-9AC1-7DBAD9C16880} - meshconvert - Win32Proj - 10.0 - - - - Application - true - Unicode - v143 - - - Application - true - Unicode - v143 - - - Application - true - Unicode - v143 - - - Application - true - Unicode - v143 - - - Application - true - Unicode - v143 - - - Application - true - Unicode - v143 - - - - - - - - - - - - - - - - - - - - - - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - meshconvert - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - meshconvert - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - meshconvert - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - meshconvert - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - meshconvert - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - meshconvert - true - - - - Level4 - Disabled - MultiThreadedDebugDLL - Fast - StreamingSIMDExtensions2 - ..\DirectXMesh;..\Utilities;%(AdditionalIncludeDirectories) - true - WIN32;_DEBUG;DEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - /Zc:__cplusplus %(AdditionalOptions) - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - Console - true - true - true - - - false - - - - - Level4 - Disabled - MultiThreadedDebugDLL - Fast - ..\DirectXMesh;..\Utilities;%(AdditionalIncludeDirectories) - true - WIN32;_DEBUG;DEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - /Zc:__cplusplus %(AdditionalOptions) - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - Console - true - true - - - false - - - - - Level4 - MaxSpeed - Fast - StreamingSIMDExtensions2 - ..\DirectXMesh;..\Utilities;%(AdditionalIncludeDirectories) - true - WIN32;NDEBUG;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - Guard - true - /Zc:__cplusplus %(AdditionalOptions) - 26812 - - - ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - true - true - - - false - - - - - Level4 - MaxSpeed - Fast - ..\DirectXMesh;..\Utilities;%(AdditionalIncludeDirectories) - true - WIN32;NDEBUG;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - Guard - true - /Zc:__cplusplus %(AdditionalOptions) - 26812 - - - ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - true - - - false - - - - - Level4 - MaxSpeed - Fast - StreamingSIMDExtensions2 - ..\DirectXMesh;..\Utilities;%(AdditionalIncludeDirectories) - true - WIN32;NDEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - Guard - true - /Zc:__cplusplus %(AdditionalOptions) - 26812 - - - ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - true - true - - - false - - - - - Level4 - MaxSpeed - Fast - ..\DirectXMesh;..\Utilities;%(AdditionalIncludeDirectories) - true - WIN32;NDEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - Guard - true - /Zc:__cplusplus %(AdditionalOptions) - 26812 - - - ole32.lib;oleaut32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - true - - - false - - - - - {6857f086-f6fe-4150-9ed7-7446f1c1c220} - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/Meshconvert_Desktop_2022.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/Meshconvert_Desktop_2022.vcxproj.filters deleted file mode 100644 index 41f44e5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/Meshconvert_Desktop_2022.vcxproj.filters +++ /dev/null @@ -1,33 +0,0 @@ - - - - - {8e114980-c1a3-4ada-ad7c-83caadf5daeb} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - {a500efbf-87f7-4c3b-b7c4-a3505a25d342} - - - - - - - - Wavefront OBJ - - - - - Wavefront OBJ - - - - - - Resource Files - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/SDKMesh.h b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/SDKMesh.h deleted file mode 100644 index ca505af..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/SDKMesh.h +++ /dev/null @@ -1,338 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: SDKMesh.h -// -// SDKMESH format is generated by the legacy DirectX SDK's Content Exporter and -// originally rendered by the DXUT helper class SDKMesh -// -// http://go.microsoft.com/fwlink/?LinkId=226208 -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248929 -// http://go.microsoft.com/fwlink/?LinkID=615561 -//-------------------------------------------------------------------------------------- - -#pragma once - -#include - -namespace DXUT -{ - // .SDKMESH files - - // SDKMESH_HEADER - // SDKMESH_VERTEX_BUFFER_HEADER header->VertexStreamHeadersOffset - // SDKMESH_INDEX_BUFFER_HEADER header->IndexStreamHeadersOffset - // SDKMESH_MESH header->MeshDataOffset - // SDKMESH_SUBSET header->SubsetDataOffset - // SDKMESH_FRAME header->FrameDataOffset - // SDKMESH_MATERIAL header->MaterialDataOffset - // [header->NonBufferDataSize] - // { [ header->NumVertexBuffers] - // VB data - // } - // { [ header->NumIndexBuffers] - // IB data - // } - - - // .SDDKANIM files - - // SDKANIMATION_FILE_HEADER - // uint8_t[] - Length of fileheader->AnimationDataSize - - // .SDKMESH uses Direct3D 9 decls, but only a subset of these is ever generated by the legacy DirectX SDK Content Exporter - - // D3DDECLUSAGE_POSITION / D3DDECLTYPE_FLOAT3 - // (D3DDECLUSAGE_BLENDWEIGHT / D3DDECLTYPE_UBYTE4N - // D3DDECLUSAGE_BLENDINDICES / D3DDECLTYPE_UBYTE4)? - // (D3DDECLUSAGE_NORMAL / D3DDECLTYPE_FLOAT3, D3DDECLTYPE_FLOAT16_4, D3DDECLTYPE_SHORT4N, D3DDECLTYPE_UBYTE4N, or D3DDECLTYPE_DEC3N)? - // (D3DDECLUSAGE_COLOR / D3DDECLTYPE_D3DCOLOR)? - // (D3DDECLUSAGE_TEXCOORD / D3DDECLTYPE_FLOAT1, D3DDECLTYPE_FLOAT2 or D3DDECLTYPE_FLOAT16_2, D3DDECLTYPE_FLOAT3 or D3DDECLTYPE_FLOAT16_4, D3DDECLTYPE_FLOAT4 or D3DDECLTYPE_FLOAT16_4)* - // (D3DDECLUSAGE_TANGENT / same as D3DDECLUSAGE_NORMAL)? - // (D3DDECLUSAGE_BINORMAL / same as D3DDECLUSAGE_NORMAL)? - - enum D3DDECLUSAGE - { - D3DDECLUSAGE_POSITION = 0, - D3DDECLUSAGE_BLENDWEIGHT =1, - D3DDECLUSAGE_BLENDINDICES =2, - D3DDECLUSAGE_NORMAL =3, - D3DDECLUSAGE_TEXCOORD = 5, - D3DDECLUSAGE_TANGENT = 6, - D3DDECLUSAGE_BINORMAL = 7, - D3DDECLUSAGE_COLOR = 10, - }; - - enum D3DDECLTYPE - { - D3DDECLTYPE_FLOAT1 = 0, // 1D float expanded to (value, 0., 0., 1.) - D3DDECLTYPE_FLOAT2 = 1, // 2D float expanded to (value, value, 0., 1.) - D3DDECLTYPE_FLOAT3 = 2, // 3D float expanded to (value, value, value, 1.) - D3DDECLTYPE_FLOAT4 = 3, // 4D float - D3DDECLTYPE_D3DCOLOR = 4, // 4D packed unsigned bytes mapped to 0. to 1. range - // Input is in D3DCOLOR format (ARGB) expanded to (R, G, B, A) - D3DDECLTYPE_UBYTE4 = 5, // 4D unsigned uint8_t - D3DDECLTYPE_UBYTE4N = 8, // Each of 4 bytes is normalized by dividing to 255.0 - D3DDECLTYPE_SHORT4N = 10, // 4D signed short normalized (v[0]/32767.0,v[1]/32767.0,v[2]/32767.0,v[3]/32767.0) - D3DDECLTYPE_DEC3N = 14, // 3D signed normalized (v[0]/511.0, v[1]/511.0, v[2]/511.0, 1.) - // Note: There is no equivalent to D3DDECLTYPE_DEC3N (14) as a DXGI_FORMAT - D3DDECLTYPE_FLOAT16_2 = 15, // Two 16-bit floating point values, expanded to (value, value, 0, 1) - D3DDECLTYPE_FLOAT16_4 = 16, // Four 16-bit floating point values - - D3DDECLTYPE_UNUSED = 17, // When the type field in a decl is unused. - - // These are extensions for DXGI-based versions of Direct3D - D3DDECLTYPE_DXGI_R10G10B10A2_UNORM = 32 + DXGI_FORMAT_R10G10B10A2_UNORM, - D3DDECLTYPE_DXGI_R11G11B10_FLOAT = 32 + DXGI_FORMAT_R11G11B10_FLOAT, - D3DDECLTYPE_DXGI_R8G8B8A8_SNORM = 32 + DXGI_FORMAT_R8G8B8A8_SNORM, - }; - - #pragma pack(push,4) - - struct D3DVERTEXELEMENT9 - { - uint16_t Stream; // Stream index - uint16_t Offset; // Offset in the stream in bytes - uint8_t Type; // Data type - uint8_t Method; // Processing method - uint8_t Usage; // Semantics - uint8_t UsageIndex; // Semantic index - }; - - #pragma pack(pop) - - //-------------------------------------------------------------------------------------- - // Hard Defines for the various structures - //-------------------------------------------------------------------------------------- - constexpr uint32_t SDKMESH_FILE_VERSION = 101; - constexpr uint32_t SDKMESH_FILE_VERSION_V2 = 200; - - constexpr uint32_t MAX_VERTEX_ELEMENTS = 32; - constexpr uint32_t MAX_VERTEX_STREAMS = 16; - constexpr uint32_t MAX_FRAME_NAME = 100; - constexpr uint32_t MAX_MESH_NAME = 100; - constexpr uint32_t MAX_SUBSET_NAME = 100; - constexpr uint32_t MAX_MATERIAL_NAME = 100; - constexpr uint32_t MAX_TEXTURE_NAME = MAX_PATH; - constexpr uint32_t MAX_MATERIAL_PATH = MAX_PATH; - constexpr uint32_t INVALID_FRAME = uint32_t(-1); - constexpr uint32_t INVALID_MESH = uint32_t(-1); - constexpr uint32_t INVALID_MATERIAL = uint32_t(-1); - constexpr uint32_t INVALID_SUBSET = uint32_t(-1); - constexpr uint32_t INVALID_ANIMATION_DATA = uint32_t(-1); - - //-------------------------------------------------------------------------------------- - // Enumerated Types. - //-------------------------------------------------------------------------------------- - enum SDKMESH_PRIMITIVE_TYPE - { - PT_TRIANGLE_LIST = 0, - PT_TRIANGLE_STRIP, - PT_LINE_LIST, - PT_LINE_STRIP, - PT_POINT_LIST, - PT_TRIANGLE_LIST_ADJ, - PT_TRIANGLE_STRIP_ADJ, - PT_LINE_LIST_ADJ, - PT_LINE_STRIP_ADJ, - PT_QUAD_PATCH_LIST, - PT_TRIANGLE_PATCH_LIST, - }; - - enum SDKMESH_INDEX_TYPE - { - IT_16BIT = 0, - IT_32BIT, - }; - - enum FRAME_TRANSFORM_TYPE - { - FTT_RELATIVE = 0, - FTT_ABSOLUTE, // This is not currently used but is here to support absolute transformations in the future - }; - - //-------------------------------------------------------------------------------------- - // Structures. - //-------------------------------------------------------------------------------------- - #pragma pack(push,8) - - struct SDKMESH_HEADER - { - //Basic Info and sizes - uint32_t Version; - uint8_t IsBigEndian; - uint64_t HeaderSize; - uint64_t NonBufferDataSize; - uint64_t BufferDataSize; - - //Stats - uint32_t NumVertexBuffers; - uint32_t NumIndexBuffers; - uint32_t NumMeshes; - uint32_t NumTotalSubsets; - uint32_t NumFrames; - uint32_t NumMaterials; - - //Offsets to Data - uint64_t VertexStreamHeadersOffset; - uint64_t IndexStreamHeadersOffset; - uint64_t MeshDataOffset; - uint64_t SubsetDataOffset; - uint64_t FrameDataOffset; - uint64_t MaterialDataOffset; - }; - - struct SDKMESH_VERTEX_BUFFER_HEADER - { - uint64_t NumVertices; - uint64_t SizeBytes; - uint64_t StrideBytes; - D3DVERTEXELEMENT9 Decl[MAX_VERTEX_ELEMENTS]; - uint64_t DataOffset; - }; - - struct SDKMESH_INDEX_BUFFER_HEADER - { - uint64_t NumIndices; - uint64_t SizeBytes; - uint32_t IndexType; - uint64_t DataOffset; - }; - - struct SDKMESH_MESH - { - char Name[MAX_MESH_NAME]; - uint8_t NumVertexBuffers; - uint32_t VertexBuffers[MAX_VERTEX_STREAMS]; - uint32_t IndexBuffer; - uint32_t NumSubsets; - uint32_t NumFrameInfluences; //aka bones - - DirectX::XMFLOAT3 BoundingBoxCenter; - DirectX::XMFLOAT3 BoundingBoxExtents; - - union - { - uint64_t SubsetOffset; - INT* pSubsets; - }; - union - { - uint64_t FrameInfluenceOffset; - uint32_t* pFrameInfluences; - }; - }; - - struct SDKMESH_SUBSET - { - char Name[MAX_SUBSET_NAME]; - uint32_t MaterialID; - uint32_t PrimitiveType; - uint64_t IndexStart; - uint64_t IndexCount; - uint64_t VertexStart; - uint64_t VertexCount; - }; - - struct SDKMESH_FRAME - { - char Name[MAX_FRAME_NAME]; - uint32_t Mesh; - uint32_t ParentFrame; - uint32_t ChildFrame; - uint32_t SiblingFrame; - DirectX::XMFLOAT4X4 Matrix; - uint32_t AnimationDataIndex; //Used to index which set of keyframes transforms this frame - }; - - struct SDKMESH_MATERIAL - { - char Name[MAX_MATERIAL_NAME]; - - // Use MaterialInstancePath - char MaterialInstancePath[MAX_MATERIAL_PATH]; - - // Or fall back to d3d8-type materials - char DiffuseTexture[MAX_TEXTURE_NAME]; - char NormalTexture[MAX_TEXTURE_NAME]; - char SpecularTexture[MAX_TEXTURE_NAME]; - - DirectX::XMFLOAT4 Diffuse; - DirectX::XMFLOAT4 Ambient; - DirectX::XMFLOAT4 Specular; - DirectX::XMFLOAT4 Emissive; - float Power; - - uint64_t Force64_1; - uint64_t Force64_2; - uint64_t Force64_3; - uint64_t Force64_4; - uint64_t Force64_5; - uint64_t Force64_6; - }; - - struct SDKMESH_MATERIAL_V2 - { - char Name[MAX_MATERIAL_NAME]; - - // PBR materials - char RMATexture[MAX_TEXTURE_NAME]; - char AlbedoTexture[MAX_TEXTURE_NAME]; - char NormalTexture[MAX_TEXTURE_NAME]; - char EmissiveTexture[MAX_TEXTURE_NAME]; - - float Alpha; - - char Reserved[60]; - - uint64_t Force64_1; - uint64_t Force64_2; - uint64_t Force64_3; - uint64_t Force64_4; - uint64_t Force64_5; - uint64_t Force64_6; - }; - - struct SDKANIMATION_FILE_HEADER - { - uint32_t Version; - uint8_t IsBigEndian; - uint32_t FrameTransformType; - uint32_t NumFrames; - uint32_t NumAnimationKeys; - uint32_t AnimationFPS; - uint64_t AnimationDataSize; - uint64_t AnimationDataOffset; - }; - - struct SDKANIMATION_DATA - { - DirectX::XMFLOAT3 Translation; - DirectX::XMFLOAT4 Orientation; - DirectX::XMFLOAT3 Scaling; - }; - - struct SDKANIMATION_FRAME_DATA - { - char FrameName[MAX_FRAME_NAME]; - uint64_t DataOffset; - }; - - #pragma pack(pop) - -} // namespace - -static_assert( sizeof(DXUT::D3DVERTEXELEMENT9) == 8, "Direct3D9 Decl structure size incorrect" ); -static_assert( sizeof(DXUT::SDKMESH_HEADER)== 104, "SDK Mesh structure size incorrect" ); -static_assert( sizeof(DXUT::SDKMESH_VERTEX_BUFFER_HEADER) == 288, "SDK Mesh structure size incorrect" ); -static_assert( sizeof(DXUT::SDKMESH_INDEX_BUFFER_HEADER) == 32, "SDK Mesh structure size incorrect" ); -static_assert( sizeof(DXUT::SDKMESH_MESH) == 224, "SDK Mesh structure size incorrect" ); -static_assert( sizeof(DXUT::SDKMESH_SUBSET) == 144, "SDK Mesh structure size incorrect" ); -static_assert( sizeof(DXUT::SDKMESH_FRAME) == 184, "SDK Mesh structure size incorrect" ); -static_assert( sizeof(DXUT::SDKMESH_MATERIAL) == 1256, "SDK Mesh structure size incorrect" ); -static_assert( sizeof(DXUT::SDKMESH_MATERIAL_V2) == sizeof(DXUT::SDKMESH_MATERIAL), "SDK Mesh structure size incorrect" ); -static_assert( sizeof(DXUT::SDKANIMATION_FILE_HEADER) == 40, "SDK Mesh structure size incorrect" ); -static_assert( sizeof(DXUT::SDKANIMATION_DATA) == 40, "SDK Mesh structure size incorrect" ); -static_assert( sizeof(DXUT::SDKANIMATION_FRAME_DATA) == 112, "SDK Mesh structure size incorrect" ); diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/directx.ico b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/directx.ico deleted file mode 100644 index bc43c1b..0000000 Binary files a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/directx.ico and /dev/null differ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/meshconvert.rc b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/meshconvert.rc deleted file mode 100644 index 6daf044..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Meshconvert/meshconvert.rc +++ /dev/null @@ -1,115 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#define IDC_STATIC -1 -#include - - - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (United States) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_MAIN_ICON ICON "directx.ico" - - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#define IDC_STATIC -1\r\n" - "#include \r\n" - "\r\n" - "\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,0 - PRODUCTVERSION 1,0,0,0 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "CompanyName", "Microsoft Corp" - VALUE "FileDescription", "Mesh conversion command-line tool" - VALUE "FileVersion", "1.0.0.0" - VALUE "InternalName", "meshconvert.exe" - VALUE "LegalCopyright", "Copyright (c) Microsoft Corp." - VALUE "OriginalFilename", "meshconvert.exe" - VALUE "ProductName", "DirectXMesh" - VALUE "ProductVersion", "1.0.0.0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // English (United States) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/NuGet.Config b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/NuGet.Config deleted file mode 100644 index 7e49cd0..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/NuGet.Config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/README.md b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/README.md deleted file mode 100644 index 79dd182..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/README.md +++ /dev/null @@ -1,82 +0,0 @@ -![DirectX Logo](https://raw.githubusercontent.com/wiki/Microsoft/DirectXMesh/X_jpg.jpg) - -# DirectXMesh geometry processing library - -http://go.microsoft.com/fwlink/?LinkID=324981 - -Copyright (c) Microsoft Corporation. - -**May 9, 2022** - -This package contains DirectXMesh, a shared source library for performing various geometry content processing operations including generating normals and tangent frames, triangle adjacency computations, vertex cache optimization, and meshlet generation. - -This code is designed to build with Visual Studio 2019 (16.7 or later), Visual Studio 2022, or clang for Windows v11 or later. Use of the Windows 10 May 2020 Update SDK ([19041](https://walbourn.github.io/windows-10-may-2020-update-sdk/)) or later is required. - -These components are designed to work without requiring any content from the legacy DirectX SDK. For details, see [Where is the DirectX SDK?](https://aka.ms/dxsdk). - -## Directory Layout - -* ``DirectXMesh\`` - - + This contains the DirectXMesh library. - -> The majority of the header files here are intended for implementation the library only (``DirectXMeshP.h``, ``scoped.h``, etc.). Only ``DirectXMesh.h`` and ``DirectXMesh.inl`` are meant as a 'public' headers for the library. - -* ``Utilities\`` - - + This contains helper code related to mesh processing that is not general enough to be part of the DirectXMesh library. - * ``WaveFrontReader.h``: Contains a simple C++ class for reading mesh data from a WaveFront OBJ file. - -* ``Meshconvert\`` - - + This DirectXMesh sample is an implementation of the ``meshconvert`` command-line texture utility from the legacy DirectX SDK utilizing DirectXMesh rather than D3DX. - -> This tool does not support legacy ``.X`` files, but can export ``CMO``, ``SDKMESH``, and ``VBO`` files. - -## Documentation - -Documentation is available on the [GitHub wiki](https://github.com/Microsoft/DirectXMesh/wiki). - -## Notices - -All content and source code for this package are subject to the terms of the [MIT License](https://github.com/microsoft/DirectXMesh/blob/main/LICENSE). - -For the latest version of DirectXMesh, bug reports, etc. please visit the project site on [GitHub](https://github.com/microsoft/DirectXMesh). - -## Release Notes - -* Starting with the June 2020 release, this library makes use of typed enum bitmask flags per the recommendation of the _C++ Standard_ section *17.5.2.1.3 Bitmask types*. This is consistent with Direct3D 12's use of the ``DEFINE_ENUM_FLAG_OPERATORS`` macro. This may have *breaking change* impacts to client code: - - * You cannot pass the ``0`` literal as your flags value. Instead you must make use of the appropriate default enum value: ``CNORM_DEFAULT``, ``VALIDATE_DEFAULT``, or ``MESHLET_DEFAULT``. - - * Use the enum type instead of ``DWORD`` if building up flags values locally with bitmask operations. For example, ```CNORM_FLAGS flags = CNORM_DEFAULT; if (...) flags |= CNORM_WIND_CW;``` - -* The UWP projects and the Win10 classic desktop project include configurations for the ARM64 platform. Building these requires installing the ARM64 toolset. - -* When using clang/LLVM for the ARM64 platform, the Windows 11 SDK ([22000](https://walbourn.github.io/windows-sdk-for-windows-11/)) is required. - -## Support - -For questions, consider using [Stack Overflow](https://stackoverflow.com/questions/tagged/directxtk) with the *directxtk* tag, or the [DirectX Discord Server](https://discord.gg/directx) in the *dx12-developers* or *dx9-dx11-developers* channel. - -For bug reports and feature requests, please use GitHub [issues](https://github.com/microsoft/DirectXMesh/issues) for this project. - -## Contributing - -This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com. - -When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA. - -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. - -## Trademarks - -This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow [Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general). Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies. - -## Credits - -The DirectXMesh library is the work of Chuck Walbourn, with contributions from Dr. Hugues Hoppe, Alex Nankervis, James Stanard, Craig Peeper, and the numerous other Microsoft engineers who developed the D3DX utility library over the years. - -Thanks to Matt Hurliman for his contribution of the meshlet generation functions. - -Thanks to Adrian Stone (Game Angst) for the public domain implementation of Tom Forsyth's linear-speed vertex cache optimization, and thanks to Tom Forsyth for his contribution. diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/SECURITY.md b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/SECURITY.md deleted file mode 100644 index f7b8998..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/SECURITY.md +++ /dev/null @@ -1,41 +0,0 @@ - - -## Security - -Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). - -If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)), please report it to us as described below. - -## Reporting Security Issues - -**Please do not report security vulnerabilities through public GitHub issues.** - -Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report). - -If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc). - -You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc). - -Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: - - * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) - * Full paths of source file(s) related to the manifestation of the issue - * The location of the affected source code (tag/branch/commit or direct URL) - * Any special configuration required to reproduce the issue - * Step-by-step instructions to reproduce the issue - * Proof-of-concept or exploit code (if possible) - * Impact of the issue, including how an attacker might exploit the issue - -This information will help us triage your report more quickly. - -If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs. - -## Preferred Languages - -We prefer all communications to be in English. - -## Policy - -Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd). - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Utilities/FlexibleVertexFormat.h b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Utilities/FlexibleVertexFormat.h deleted file mode 100644 index a70d298..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Utilities/FlexibleVertexFormat.h +++ /dev/null @@ -1,1062 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: FlexibleVertexFormat.h -// -// Helpers for legacy Direct3D 9 era FVF codes and vertex decls -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkID=324981 -//-------------------------------------------------------------------------------------- - -#pragma once - -#include - -#include -#include -#include - -namespace FVF -{ - constexpr uint8_t g_declTypeSizes[] = - { - 4, // D3DDECLTYPE_FLOAT1 - 8, // D3DDECLTYPE_FLOAT2 - 12, // D3DDECLTYPE_FLOAT3 - 16, // D3DDECLTYPE_FLOAT4 - 4, // D3DDECLTYPE_D3DCOLOR - 4, // D3DDECLTYPE_UBYTE4 - 4, // D3DDECLTYPE_SHORT2 - 8, // D3DDECLTYPE_SHORT4 - 4, // D3DDECLTYPE_UBYTE4N - 4, // D3DDECLTYPE_SHORT2N - 8, // D3DDECLTYPE_SHORT4N - 4, // D3DDECLTYPE_USHORT2N - 8, // D3DDECLTYPE_USHORT4N - 4, // D3DDECLTYPE_UDEC3 - 4, // D3DDECLTYPE_DEC3N - 4, // D3DDECLTYPE_FLOAT16_2 - 8, // D3DDECLTYPE_FLOAT16_4 - }; - - static_assert(std::size(g_declTypeSizes) == D3DDECLTYPE_UNUSED, "Mismatch of array size"); - - inline size_t ComputeVertexSize(uint32_t fvfCode) - { - if ((fvfCode & ((D3DFVF_RESERVED0 | D3DFVF_RESERVED2) & ~D3DFVF_POSITION_MASK)) != 0) - return 0; - - const size_t numCoords = (fvfCode & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT; - if (numCoords > 8) - return 0; - - size_t vertexSize = 0; - - switch (fvfCode & D3DFVF_POSITION_MASK) - { - case 0: break; - case D3DFVF_XYZ: vertexSize = 3 * sizeof(float); break; - - case D3DFVF_XYZRHW: - case D3DFVF_XYZB1: - case D3DFVF_XYZW: - vertexSize = 4 * sizeof(float); - break; - - case D3DFVF_XYZB2: vertexSize = 5 * sizeof(float); break; - case D3DFVF_XYZB3: vertexSize = 6 * sizeof(float); break; - case D3DFVF_XYZB4: vertexSize = 7 * sizeof(float); break; - case D3DFVF_XYZB5: vertexSize = 8 * sizeof(float); break; - default: return 0; - } - - if (fvfCode & D3DFVF_NORMAL) - vertexSize += 3 * sizeof(float); - - if (fvfCode & D3DFVF_PSIZE) - vertexSize += sizeof(uint32_t); - - if (fvfCode & D3DFVF_DIFFUSE) - vertexSize += sizeof(uint32_t); - - if (fvfCode & D3DFVF_SPECULAR) - vertexSize += sizeof(uint32_t); - - // Texture coordinates - uint32_t textureFormats = fvfCode >> 16u; - - if (textureFormats) - { - for (size_t i = 0; i < numCoords; i++) - { - switch (textureFormats & 3) - { - case 0: vertexSize += 2 * sizeof(float); break; - case 1: vertexSize += 3 * sizeof(float); break; - case 2: vertexSize += 4 * sizeof(float); break; - case 3: vertexSize += 1 * sizeof(float); break; - } - - textureFormats >>= 2; - } - } - else - { - vertexSize += numCoords * (2 * sizeof(float)); - } - - return vertexSize; - } - - inline size_t ComputeVertexSize(const D3DVERTEXELEMENT9* pDecl, uint32_t stream) - { - if (!pDecl || stream >= 16u /*D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT*/) - return 0; - - size_t currentSize = 0; - size_t count = 0; - - //search for the max offset in the stream, - //(min)vertex size = max offset + type size - while (pDecl->Stream != 0xFF) - { - ++count; - if (count > MAXD3DDECLLENGTH) - return 0; - - // only look at items of this stream and vertex elements actually in the data stream (not generated) - // UV is phantom data. - if ((pDecl->Stream == stream) && (pDecl->Method != D3DDECLMETHOD_UV)) - { - if (pDecl->Type >= std::size(g_declTypeSizes)) - return 0; - - const size_t slotSize = g_declTypeSizes[pDecl->Type]; - if (currentSize < slotSize + pDecl->Offset) - currentSize = slotSize + pDecl->Offset; - } - - ++pDecl; - } - - return currentSize; - } - - // More secure version - inline size_t ComputeVertexSize( - _In_reads_(maxDeclLength) const D3DVERTEXELEMENT9* pDecl, size_t maxDeclLength, uint32_t stream) - { - if (!pDecl || stream >= 16u /*D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT*/) - return 0; - - if (maxDeclLength > MAXD3DDECLLENGTH + 1) - return 0; - - size_t currentSize = 0; - size_t count = 0; - - //search for the max offset in the stream, - //(min)vertex size = max offset + type size - while (pDecl->Stream != 0xFF) - { - ++count; - if (count > maxDeclLength) - return 0; - - // only look at items of this stream and vertex elements actually in the data stream (not generated) - // UV is phantom data. - if ((pDecl->Stream == stream) && (pDecl->Method != D3DDECLMETHOD_UV)) - { - if (pDecl->Type >= std::size(g_declTypeSizes)) - return 0; - - const size_t slotSize = g_declTypeSizes[pDecl->Type]; - if (currentSize < slotSize + pDecl->Offset) - currentSize = slotSize + pDecl->Offset; - } - - ++pDecl; - } - - return currentSize; - } - - inline size_t GetDeclLength(const D3DVERTEXELEMENT9* pDecl) - { - if (!pDecl) - return 0; - - size_t length = 0; - while (pDecl->Stream != 0xFF) - { - if (length >= MAXD3DDECLLENGTH) - return 0; - - ++pDecl; - ++length; - } - return length; - } - - _Success_(return) - inline bool CreateDeclFromFVF(uint32_t fvfCode, std::vector& decl) - { - static constexpr size_t s_texCoordSizes[] = - { - 2 * sizeof(float), - 3 * sizeof(float), - 4 * sizeof(float), - sizeof(float) - }; - - decl.clear(); - - if ((fvfCode & ((D3DFVF_RESERVED0 | D3DFVF_RESERVED2) & ~D3DFVF_POSITION_MASK)) != 0) - return false; - - const uint32_t nTexCoords = (fvfCode & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT; - if (nTexCoords > 8) - return false; - - size_t offset = 0; - - switch (fvfCode & D3DFVF_POSITION_MASK) - { - case 0: - break; - - case D3DFVF_XYZRHW: - decl.emplace_back( - D3DVERTEXELEMENT9{ 0, 0, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITIONT, 0 } - ); - offset = sizeof(float) * 4; - break; - - case D3DFVF_XYZW: - decl.emplace_back( - D3DVERTEXELEMENT9{ 0, 0, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 } - ); - offset = sizeof(float) * 4; - break; - - default: - decl.emplace_back( - D3DVERTEXELEMENT9{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 } - ); - offset = sizeof(float) * 3; - break; - } - - size_t weights = 0; - switch (fvfCode & D3DFVF_POSITION_MASK) - { - case D3DFVF_XYZB1: weights = 1; break; - case D3DFVF_XYZB2: weights = 2; break; - case D3DFVF_XYZB3: weights = 3; break; - case D3DFVF_XYZB4: weights = 4; break; - case D3DFVF_XYZB5: weights = 5; break; - } - - if (weights > 0) - { - if (fvfCode & (D3DFVF_LASTBETA_UBYTE4 | D3DFVF_LASTBETA_D3DCOLOR)) - { - // subtract one to convert to D3DDECLTYPE_FLOAT* and another for where the indices were - if (weights > 1) - { - decl.emplace_back( - D3DVERTEXELEMENT9{ 0, static_cast(offset), static_cast(weights - 2), - D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDWEIGHT, 0 } - ); - offset += sizeof(float) * (weights - 1); - } - - decl.emplace_back( - D3DVERTEXELEMENT9{ 0, static_cast(offset), - static_cast((fvfCode & D3DFVF_LASTBETA_UBYTE4) ? D3DDECLTYPE_UBYTE4 : D3DDECLTYPE_D3DCOLOR), - D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDINDICES, 0 } - ); - offset += sizeof(uint32_t); - } - else if (weights == 5) - { - // D3DFVF_XYZB5 is only supported when the 5th beta is D3DFVF_LASTBETA_UBYTE4/D3DCOLOR - decl.clear(); - return false; - } - else - { - // subtract one to convert to D3DDECLTYPE_FLOAT* - decl.emplace_back( - D3DVERTEXELEMENT9{ 0, static_cast(offset), static_cast(weights - 1), - D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BLENDWEIGHT, 0 } - ); - offset += sizeof(float) * (weights - 1); - } - } - - if (fvfCode & D3DFVF_NORMAL) - { - decl.emplace_back( - D3DVERTEXELEMENT9{ 0, static_cast(offset), D3DDECLTYPE_FLOAT3, - D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 } - ); - offset += sizeof(float) * 3; - } - - if (fvfCode & D3DFVF_PSIZE) - { - decl.emplace_back( - D3DVERTEXELEMENT9{ 0, static_cast(offset), D3DDECLTYPE_FLOAT1, - D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_PSIZE, 0 } - ); - offset += sizeof(float); - } - - if (fvfCode & D3DFVF_DIFFUSE) - { - decl.emplace_back( - D3DVERTEXELEMENT9{ 0, static_cast(offset), D3DDECLTYPE_D3DCOLOR, - D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0 } - ); - offset += sizeof(uint32_t); - } - - if (fvfCode & D3DFVF_SPECULAR) - { - decl.emplace_back( - D3DVERTEXELEMENT9{ 0, static_cast(offset), D3DDECLTYPE_D3DCOLOR, - D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 1 } - ); - offset += sizeof(uint32_t); - } - - if (nTexCoords > 0) - { - for (uint32_t t = 0; t < nTexCoords; ++t) - { - const size_t texCoordSize = s_texCoordSizes[(fvfCode >> (16 + t * 2)) & 0x3]; - - // D3DDECLTYPE_FLOAT1 = 0, D3DDECLTYPE_FLOAT4 = 3 - decl.emplace_back( - D3DVERTEXELEMENT9{ 0, static_cast(offset), - static_cast(texCoordSize / sizeof(float) - 1), - D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, static_cast(t) } - ); - offset += texCoordSize; - } - } - - decl.emplace_back(D3DVERTEXELEMENT9{ 0xFF, 0, D3DDECLTYPE_UNUSED, 0, 0, 0 }); - - return true; - } - -#ifdef __d3d11_h__ - _Success_(return) - inline bool CreateInputLayoutFromFVF(uint32_t fvfCode, std::vector& il) - { - static constexpr DXGI_FORMAT s_blendFormats[] = - { - DXGI_FORMAT_R32_FLOAT, - DXGI_FORMAT_R32G32_FLOAT, - DXGI_FORMAT_R32G32B32_FLOAT, - DXGI_FORMAT_R32G32B32A32_FLOAT, - }; - - static constexpr DXGI_FORMAT s_texCoordFormats[] = - { - DXGI_FORMAT_R32G32_FLOAT, - DXGI_FORMAT_R32G32B32_FLOAT, - DXGI_FORMAT_R32G32B32A32_FLOAT, - DXGI_FORMAT_R32_FLOAT - }; - - il.clear(); - - if ((fvfCode & ((D3DFVF_RESERVED0 | D3DFVF_RESERVED2) & ~D3DFVF_POSITION_MASK)) != 0) - return false; - - const uint32_t nTexCoords = (fvfCode & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT; - if (nTexCoords > 8) - return false; - - switch (fvfCode & D3DFVF_POSITION_MASK) - { - case 0: - break; - - case D3DFVF_XYZRHW: - case D3DFVF_XYZW: - il.emplace_back( - D3D11_INPUT_ELEMENT_DESC{ "SV_Position", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, - 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 } - ); - break; - - default: - il.emplace_back( - D3D11_INPUT_ELEMENT_DESC{ "SV_Position", 0, DXGI_FORMAT_R32G32B32_FLOAT, - 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 } - ); - break; - } - - size_t weights = 0; - switch (fvfCode & D3DFVF_POSITION_MASK) - { - case D3DFVF_XYZB1: weights = 1; break; - case D3DFVF_XYZB2: weights = 2; break; - case D3DFVF_XYZB3: weights = 3; break; - case D3DFVF_XYZB4: weights = 4; break; - case D3DFVF_XYZB5: weights = 5; break; - } - - if (weights > 0) - { - if (fvfCode & (D3DFVF_LASTBETA_UBYTE4 | D3DFVF_LASTBETA_D3DCOLOR)) - { - // subtract one for where the blendindices were - if (weights > 1) - { - il.emplace_back( - D3D11_INPUT_ELEMENT_DESC{ "BLENDWEIGHT", 0, s_blendFormats[weights - 2], - 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 } - ); - } - - il.emplace_back( - D3D11_INPUT_ELEMENT_DESC{ "BLENDINDICES", 0, - (fvfCode & D3DFVF_LASTBETA_UBYTE4) ? DXGI_FORMAT_R8G8B8A8_UNORM : DXGI_FORMAT_B8G8R8A8_UNORM, - 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 } - ); - } - else if (weights == 5) - { - // D3DFVF_XYZB5 is only supported when the 5th beta is D3DFVF_LASTBETA_UBYTE4/D3DCOLOR - il.clear(); - return false; - } - else - { - il.emplace_back( - D3D11_INPUT_ELEMENT_DESC{ "BLENDWEIGHT", 0, s_blendFormats[weights - 1], - 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 } - ); - } - } - - if (fvfCode & D3DFVF_NORMAL) - { - il.emplace_back( - D3D11_INPUT_ELEMENT_DESC{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, - 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 } - ); - } - - if (fvfCode & D3DFVF_PSIZE) - { - il.emplace_back( - D3D11_INPUT_ELEMENT_DESC{ "PSIZE", 0, DXGI_FORMAT_R32_FLOAT, - 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 } - ); - } - - if (fvfCode & D3DFVF_DIFFUSE) - { - il.emplace_back( - D3D11_INPUT_ELEMENT_DESC{ "COLOR", 0, DXGI_FORMAT_B8G8R8A8_UNORM, - 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 } - ); - } - - if (fvfCode & D3DFVF_SPECULAR) - { - il.emplace_back( - D3D11_INPUT_ELEMENT_DESC{ "COLOR", 1, DXGI_FORMAT_B8G8R8A8_UNORM, - 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 } - ); - } - - if (nTexCoords > 0) - { - for (uint32_t t = 0; t < nTexCoords; ++t) - { - const size_t index = (fvfCode >> (16 + t * 2)) & 0x3; - il.emplace_back( - D3D11_INPUT_ELEMENT_DESC{ "TEXCOORD", static_cast(t), - s_texCoordFormats[index], - 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 } - ); - } - } - - return true; - } -#endif // __d3d11_h__ - -#ifdef __d3d12_h__ - _Success_(return) - inline bool CreateInputLayoutFromFVF(uint32_t fvfCode, std::vector& il) - { - static constexpr DXGI_FORMAT s_blendFormats[] = - { - DXGI_FORMAT_R32_FLOAT, - DXGI_FORMAT_R32G32_FLOAT, - DXGI_FORMAT_R32G32B32_FLOAT, - DXGI_FORMAT_R32G32B32A32_FLOAT, - }; - - static constexpr DXGI_FORMAT s_texCoordFormats[] = - { - DXGI_FORMAT_R32G32_FLOAT, - DXGI_FORMAT_R32G32B32_FLOAT, - DXGI_FORMAT_R32G32B32A32_FLOAT, - DXGI_FORMAT_R32_FLOAT - }; - - il.clear(); - - if ((fvfCode & ((D3DFVF_RESERVED0 | D3DFVF_RESERVED2) & ~D3DFVF_POSITION_MASK)) != 0) - return false; - - uint32_t nTexCoords = (fvfCode & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT; - if (nTexCoords > 8) - return false; - - switch (fvfCode & D3DFVF_POSITION_MASK) - { - case 0: - break; - - case D3DFVF_XYZRHW: - case D3DFVF_XYZW: - il.emplace_back( - D3D12_INPUT_ELEMENT_DESC{ "SV_Position", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, - 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 } - ); - break; - - default: - il.emplace_back( - D3D12_INPUT_ELEMENT_DESC{ "SV_Position", 0, DXGI_FORMAT_R32G32B32_FLOAT, - 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 } - ); - break; - } - - size_t weights = 0; - switch (fvfCode & D3DFVF_POSITION_MASK) - { - case D3DFVF_XYZB1: weights = 1; break; - case D3DFVF_XYZB2: weights = 2; break; - case D3DFVF_XYZB3: weights = 3; break; - case D3DFVF_XYZB4: weights = 4; break; - case D3DFVF_XYZB5: weights = 5; break; - } - - if (weights > 0) - { - if (fvfCode & (D3DFVF_LASTBETA_UBYTE4 | D3DFVF_LASTBETA_D3DCOLOR)) - { - // subtract one for where the blendindices were - if (weights > 1) - { - il.emplace_back( - D3D12_INPUT_ELEMENT_DESC{ "BLENDWEIGHT", 0, s_blendFormats[weights - 2], - 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 } - ); - } - - il.emplace_back( - D3D12_INPUT_ELEMENT_DESC{ "BLENDINDICES", 0, - (fvfCode & D3DFVF_LASTBETA_UBYTE4) ? DXGI_FORMAT_R8G8B8A8_UNORM : DXGI_FORMAT_B8G8R8A8_UNORM, - 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 } - ); - } - else if (weights == 5) - { - // D3DFVF_XYZB5 is only supported when the 5th beta is D3DFVF_LASTBETA_UBYTE4/D3DCOLOR - il.clear(); - return false; - } - else - { - il.emplace_back( - D3D12_INPUT_ELEMENT_DESC{ "BLENDWEIGHT", 0, s_blendFormats[weights - 1], - 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 } - ); - } - } - - if (fvfCode & D3DFVF_NORMAL) - { - il.emplace_back( - D3D12_INPUT_ELEMENT_DESC{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, - 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 } - ); - } - - if (fvfCode & D3DFVF_PSIZE) - { - il.emplace_back( - D3D12_INPUT_ELEMENT_DESC{ "PSIZE", 0, DXGI_FORMAT_R32_FLOAT, - 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 } - ); - } - - if (fvfCode & D3DFVF_DIFFUSE) - { - il.emplace_back( - D3D12_INPUT_ELEMENT_DESC{ "COLOR", 0, DXGI_FORMAT_B8G8R8A8_UNORM, - 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 } - ); - } - - if (fvfCode & D3DFVF_SPECULAR) - { - il.emplace_back( - D3D12_INPUT_ELEMENT_DESC{ "COLOR", 1, DXGI_FORMAT_B8G8R8A8_UNORM, - 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 } - ); - } - - if (nTexCoords > 0) - { - for (uint32_t t = 0; t < nTexCoords; ++t) - { - size_t index = (fvfCode >> (16 + t * 2)) & 0x3; - il.emplace_back( - D3D12_INPUT_ELEMENT_DESC{ "TEXCOORD", static_cast(t), - s_texCoordFormats[index], - 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 } - ); - } - } - - return true; - } -#endif // __d3d12_h__ - - inline uint32_t ComputeFVF(const D3DVERTEXELEMENT9* pDecl) - { - if (!pDecl) - return 0; - - // validate vertex declaration - auto pCurrent = pDecl; - size_t count = 0; - size_t offset = 0; - while (pCurrent->Stream != 0xFF) - { - ++count; - if (count > MAXD3DDECLLENGTH) - return 0; - - if (pCurrent->Stream != 0) - return 0; - - if (pCurrent->Type > D3DDECLTYPE_SHORT4) - return 0; - - if (offset != pCurrent->Offset) - return 0; - - if (pCurrent->Method > D3DDECLMETHOD_LOOKUP) - return 0; - - if (((pCurrent->Usage > D3DDECLUSAGE_TEXCOORD) - && (pCurrent->Usage != D3DDECLUSAGE_POSITIONT) - && (pCurrent->Usage != D3DDECLUSAGE_COLOR))) - { - return 0; - } - - if ((pCurrent->Usage == D3DDECLUSAGE_COLOR) && (pCurrent->UsageIndex > 1)) - { - return 0; - } - - offset += g_declTypeSizes[pCurrent->Type]; - - ++pCurrent; - } - - // Build FVF code - pCurrent = pDecl; - uint32_t fvfCode = 0; - if (pCurrent->Usage == D3DDECLUSAGE_POSITION) - { - if (pCurrent->Type == D3DDECLTYPE_FLOAT3) - { - size_t weights = 0; - ++pCurrent; - - if (pCurrent->Usage == D3DDECLUSAGE_BLENDWEIGHT) - { - if ((pCurrent->Type >= D3DDECLTYPE_FLOAT1) && (pCurrent->Type <= D3DDECLTYPE_FLOAT4)) - { - weights = pCurrent->Type - D3DDECLTYPE_FLOAT1 + 1; - ++pCurrent; - } - else - { - return 0; - } - } - - if (pCurrent->Usage == D3DDECLUSAGE_BLENDINDICES) - { - if (pCurrent->Type == D3DDECLTYPE_UBYTE4) - { - fvfCode |= D3DFVF_LASTBETA_UBYTE4; - - ++weights; - ++pCurrent; - } - else if (pCurrent->Type == D3DDECLTYPE_D3DCOLOR) - { - fvfCode |= D3DFVF_LASTBETA_D3DCOLOR; - - ++weights; - ++pCurrent; - } - else - { - return 0; - } - } - - switch (weights) - { - case 0: fvfCode |= D3DFVF_XYZ; break; - case 1: fvfCode |= D3DFVF_XYZB1; break; - case 2: fvfCode |= D3DFVF_XYZB2; break; - case 3: fvfCode |= D3DFVF_XYZB3; break; - case 4: fvfCode |= D3DFVF_XYZB4; break; - case 5: fvfCode |= D3DFVF_XYZB5; break; - } - } - else if (pCurrent->Type == D3DDECLTYPE_FLOAT4) - { - fvfCode |= D3DFVF_XYZW; - ++pCurrent; - } - } - else if ((pCurrent->Usage == D3DDECLUSAGE_POSITIONT) - && (pCurrent->Type == D3DDECLTYPE_FLOAT4)) - { - fvfCode |= D3DFVF_XYZRHW; - ++pCurrent; - } - - // Normal - if ((pCurrent->Usage == D3DDECLUSAGE_NORMAL) - && (pCurrent->Type == D3DDECLTYPE_FLOAT3)) - { - fvfCode |= D3DFVF_NORMAL; - ++pCurrent; - } - - // Point size - if ((pCurrent->Usage == D3DDECLUSAGE_PSIZE) - && (pCurrent->Type == D3DDECLTYPE_FLOAT1)) - { - fvfCode |= D3DFVF_PSIZE; - ++pCurrent; - } - - // Diffuse - if ((pCurrent->Usage == D3DDECLUSAGE_COLOR) - && (pCurrent->UsageIndex == 0) - && (pCurrent->Type == D3DDECLTYPE_D3DCOLOR)) - { - fvfCode |= D3DFVF_DIFFUSE; - ++pCurrent; - } - - // Specular - if ((pCurrent->Usage == D3DDECLUSAGE_COLOR) - && (pCurrent->UsageIndex == 1) - && (pCurrent->Type == D3DDECLTYPE_D3DCOLOR)) - { - fvfCode |= D3DFVF_SPECULAR; - ++pCurrent; - } - - // Texture coordinates - size_t i; - - for (i = 0; i < 8; ++i) - { - if ((pCurrent->Usage == D3DDECLUSAGE_TEXCOORD) - && (pCurrent->Type == D3DDECLTYPE_FLOAT1) - && (pCurrent->UsageIndex == i)) - { - fvfCode |= static_cast(D3DFVF_TEXCOORDSIZE1(i)); - } - else if ((pCurrent->Usage == D3DDECLUSAGE_TEXCOORD) - && (pCurrent->Type == D3DDECLTYPE_FLOAT2) - && (pCurrent->UsageIndex == i)) - { - fvfCode |= static_cast(D3DFVF_TEXCOORDSIZE2(i)); - } - else if ((pCurrent->Usage == D3DDECLUSAGE_TEXCOORD) - && (pCurrent->Type == D3DDECLTYPE_FLOAT3) - && (pCurrent->UsageIndex == i)) - { - fvfCode |= static_cast(D3DFVF_TEXCOORDSIZE3(i)); - } - else if ((pCurrent->Usage == D3DDECLUSAGE_TEXCOORD) - && (pCurrent->Type == D3DDECLTYPE_FLOAT4) - && (pCurrent->UsageIndex == i)) - { - fvfCode |= static_cast(D3DFVF_TEXCOORDSIZE4(i)); - } - else - break; - - ++pCurrent; - } - - fvfCode |= static_cast(i << D3DFVF_TEXCOUNT_SHIFT); - - if (pCurrent->Stream != 0xff) - { - return 0; - } - - return fvfCode; - } - - // More secure version - inline uint32_t ComputeFVF( - _In_reads_(maxDeclLength) const D3DVERTEXELEMENT9* pDecl, size_t maxDeclLength) - { - if (!pDecl) - return 0; - - if (maxDeclLength > MAXD3DDECLLENGTH + 1) - return 0; - - // validate vertex declaration - auto pCurrent = pDecl; - size_t count = 0; - size_t offset = 0; - while (pCurrent->Stream != 0xFF) - { - ++count; - if (count > maxDeclLength) - return 0; - - if (pCurrent->Stream != 0) - return 0; - - if (pCurrent->Type > D3DDECLTYPE_SHORT4) - return 0; - - if (offset != pCurrent->Offset) - return 0; - - if (pCurrent->Method > D3DDECLMETHOD_LOOKUP) - return 0; - - if (((pCurrent->Usage > D3DDECLUSAGE_TEXCOORD) - && (pCurrent->Usage != D3DDECLUSAGE_POSITIONT) - && (pCurrent->Usage != D3DDECLUSAGE_COLOR))) - { - return 0; - } - - if ((pCurrent->Usage == D3DDECLUSAGE_COLOR) && (pCurrent->UsageIndex > 1)) - { - return 0; - } - - offset += g_declTypeSizes[pCurrent->Type]; - - ++pCurrent; - } - - // Build FVF code - pCurrent = pDecl; - count = 0; - uint32_t fvfCode = 0; - if (pCurrent->Usage == D3DDECLUSAGE_POSITION) - { - if (pCurrent->Type == D3DDECLTYPE_FLOAT3) - { - size_t weights = 0; - ++count; - if (count > maxDeclLength) - return 0; - ++pCurrent; - - if (pCurrent->Usage == D3DDECLUSAGE_BLENDWEIGHT) - { - if ((pCurrent->Type >= D3DDECLTYPE_FLOAT1) && (pCurrent->Type <= D3DDECLTYPE_FLOAT4)) - { - weights = pCurrent->Type - D3DDECLTYPE_FLOAT1 + 1; - ++count; - if (count > maxDeclLength) - return 0; - ++pCurrent; - } - else - { - return 0; - } - } - - if (pCurrent->Usage == D3DDECLUSAGE_BLENDINDICES) - { - if (pCurrent->Type == D3DDECLTYPE_UBYTE4) - { - fvfCode |= D3DFVF_LASTBETA_UBYTE4; - - ++weights; - ++count; - if (count > maxDeclLength) - return 0; - ++pCurrent; - } - else if (pCurrent->Type == D3DDECLTYPE_D3DCOLOR) - { - fvfCode |= D3DFVF_LASTBETA_D3DCOLOR; - - ++weights; - ++count; - if (count > maxDeclLength) - return 0; - ++pCurrent; - } - else - { - return 0; - } - } - - switch (weights) - { - case 0: fvfCode |= D3DFVF_XYZ; break; - case 1: fvfCode |= D3DFVF_XYZB1; break; - case 2: fvfCode |= D3DFVF_XYZB2; break; - case 3: fvfCode |= D3DFVF_XYZB3; break; - case 4: fvfCode |= D3DFVF_XYZB4; break; - case 5: fvfCode |= D3DFVF_XYZB5; break; - } - } - else if (pCurrent->Type == D3DDECLTYPE_FLOAT4) - { - fvfCode |= D3DFVF_XYZW; - ++count; - if (count > maxDeclLength) - return 0; - ++pCurrent; - } - } - else if ((pCurrent->Usage == D3DDECLUSAGE_POSITIONT) - && (pCurrent->Type == D3DDECLTYPE_FLOAT4)) - { - fvfCode |= D3DFVF_XYZRHW; - ++count; - if (count > maxDeclLength) - return 0; - ++pCurrent; - } - - // Normal - if ((pCurrent->Usage == D3DDECLUSAGE_NORMAL) - && (pCurrent->Type == D3DDECLTYPE_FLOAT3)) - { - fvfCode |= D3DFVF_NORMAL; - ++count; - if (count > maxDeclLength) - return 0; - ++pCurrent; - } - - // Point size - if ((pCurrent->Usage == D3DDECLUSAGE_PSIZE) - && (pCurrent->Type == D3DDECLTYPE_FLOAT1)) - { - fvfCode |= D3DFVF_PSIZE; - ++count; - if (count > maxDeclLength) - return 0; - ++pCurrent; - } - - // Diffuse - if ((pCurrent->Usage == D3DDECLUSAGE_COLOR) - && (pCurrent->UsageIndex == 0) - && (pCurrent->Type == D3DDECLTYPE_D3DCOLOR)) - { - fvfCode |= D3DFVF_DIFFUSE; - ++count; - if (count > maxDeclLength) - return 0; - ++pCurrent; - } - - // Specular - if ((pCurrent->Usage == D3DDECLUSAGE_COLOR) - && (pCurrent->UsageIndex == 1) - && (pCurrent->Type == D3DDECLTYPE_D3DCOLOR)) - { - fvfCode |= D3DFVF_SPECULAR; - ++count; - if (count > maxDeclLength) - return 0; - ++pCurrent; - } - - // Texture coordinates - size_t i; - - for (i = 0; i < 8; ++i) - { - if ((pCurrent->Usage == D3DDECLUSAGE_TEXCOORD) - && (pCurrent->Type == D3DDECLTYPE_FLOAT1) - && (pCurrent->UsageIndex == i)) - { - fvfCode |= static_cast(D3DFVF_TEXCOORDSIZE1(i)); - } - else if ((pCurrent->Usage == D3DDECLUSAGE_TEXCOORD) - && (pCurrent->Type == D3DDECLTYPE_FLOAT2) - && (pCurrent->UsageIndex == i)) - { - fvfCode |= static_cast(D3DFVF_TEXCOORDSIZE2(i)); - } - else if ((pCurrent->Usage == D3DDECLUSAGE_TEXCOORD) - && (pCurrent->Type == D3DDECLTYPE_FLOAT3) - && (pCurrent->UsageIndex == i)) - { - fvfCode |= static_cast(D3DFVF_TEXCOORDSIZE3(i)); - } - else if ((pCurrent->Usage == D3DDECLUSAGE_TEXCOORD) - && (pCurrent->Type == D3DDECLTYPE_FLOAT4) - && (pCurrent->UsageIndex == i)) - { - fvfCode |= static_cast(D3DFVF_TEXCOORDSIZE4(i)); - } - else - break; - - ++count; - if (count > maxDeclLength) - return 0; - ++pCurrent; - } - - fvfCode |= static_cast(i << D3DFVF_TEXCOUNT_SHIFT); - - if (pCurrent->Stream != 0xff) - { - return 0; - } - - return fvfCode; - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Utilities/WaveFrontReader.h b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Utilities/WaveFrontReader.h deleted file mode 100644 index 7f9bcc0..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXMesh/Utilities/WaveFrontReader.h +++ /dev/null @@ -1,750 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: WaveFrontReader.h -// -// Code for loading basic mesh data from a WaveFront OBJ file -// -// http://en.wikipedia.org/wiki/Wavefront_.obj_file -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkID=324981 -//-------------------------------------------------------------------------------------- - -#pragma once - -#ifdef _WIN32 -#pragma warning(push) -#pragma warning(disable : 4005) -#define WIN32_LEAN_AND_MEAN -#define NOMINMAX 1 -#define NODRAWTEXT -#define NOGDI -#define NOMCX -#define NOSERVICE -#define NOHELP -#pragma warning(pop) - -#include -#else // !WIN32 -#include -#include - -#ifndef MAX_PATH -#define MAX_PATH 4096 -#endif -#endif - -#include -#include -#include -#include -#include -#include -#include - -#ifndef _WIN32 -#include -#endif - -#include -#include - -template -class WaveFrontReader -{ -public: - struct Vertex - { - DirectX::XMFLOAT3 position; - DirectX::XMFLOAT3 normal; - DirectX::XMFLOAT2 textureCoordinate; - }; - - WaveFrontReader() noexcept : hasNormals(false), hasTexcoords(false) {} - - HRESULT Load(_In_z_ const wchar_t* szFileName, bool ccw = true) - { - Clear(); - - constexpr size_t MAX_POLY = 64; - - using namespace DirectX; - - std::wifstream InFile(szFileName); - if (!InFile) - return /* HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) */ static_cast(0x80070002L); - - InFile.imbue(std::locale::classic()); - -#ifdef _WIN32 - wchar_t fname[_MAX_FNAME] = {}; - _wsplitpath_s(szFileName, nullptr, 0, nullptr, 0, fname, _MAX_FNAME, nullptr, 0); - name = fname; -#else - auto path = std::filesystem::path(szFileName); - name = path.filename().c_str(); -#endif - - std::vector positions; - std::vector normals; - std::vector texCoords; - - VertexCache vertexCache; - - Material defmat; - - wcscpy_s(defmat.strName, L"default"); - materials.emplace_back(defmat); - - uint32_t curSubset = 0; - - wchar_t strMaterialFilename[MAX_PATH] = {}; - for (;; ) - { - std::wstring strCommand; - InFile >> strCommand; - if (!InFile) - break; - - if (*strCommand.c_str() == L'#') - { - // Comment - } - else if (0 == wcscmp(strCommand.c_str(), L"o")) - { - // Object name ignored - } - else if (0 == wcscmp(strCommand.c_str(), L"g")) - { - // Group name ignored - } - else if (0 == wcscmp(strCommand.c_str(), L"s")) - { - // Smoothing group ignored - } - else if (0 == wcscmp(strCommand.c_str(), L"v")) - { - // Vertex Position - float x, y, z; - InFile >> x >> y >> z; - positions.emplace_back(XMFLOAT3(x, y, z)); - } - else if (0 == wcscmp(strCommand.c_str(), L"vt")) - { - // Vertex TexCoord - float u, v; - InFile >> u >> v; - texCoords.emplace_back(XMFLOAT2(u, v)); - - hasTexcoords = true; - } - else if (0 == wcscmp(strCommand.c_str(), L"vn")) - { - // Vertex Normal - float x, y, z; - InFile >> x >> y >> z; - normals.emplace_back(XMFLOAT3(x, y, z)); - - hasNormals = true; - } - else if (0 == wcscmp(strCommand.c_str(), L"f")) - { - // Face - INT iPosition, iTexCoord, iNormal; - Vertex vertex; - - uint32_t faceIndex[MAX_POLY]; - size_t iFace = 0; - for (;;) - { - if (iFace >= MAX_POLY) - { - // Too many polygon verts for the reader - return E_FAIL; - } - - memset(&vertex, 0, sizeof(vertex)); - - InFile >> iPosition; - - uint32_t vertexIndex = 0; - if (!iPosition) - { - // 0 is not allowed for index - return E_UNEXPECTED; - } - else if (iPosition < 0) - { - // Negative values are relative indices - vertexIndex = uint32_t(ptrdiff_t(positions.size()) + iPosition); - } - else - { - // OBJ format uses 1-based arrays - vertexIndex = uint32_t(iPosition - 1); - } - - if (vertexIndex >= positions.size()) - return E_FAIL; - - vertex.position = positions[vertexIndex]; - - if ('/' == InFile.peek()) - { - InFile.ignore(); - - if ('/' != InFile.peek()) - { - // Optional texture coordinate - InFile >> iTexCoord; - - uint32_t coordIndex = 0; - if (!iTexCoord) - { - // 0 is not allowed for index - return E_UNEXPECTED; - } - else if (iTexCoord < 0) - { - // Negative values are relative indices - coordIndex = uint32_t(ptrdiff_t(texCoords.size()) + iTexCoord); - } - else - { - // OBJ format uses 1-based arrays - coordIndex = uint32_t(iTexCoord - 1); - } - - if (coordIndex >= texCoords.size()) - return E_FAIL; - - vertex.textureCoordinate = texCoords[coordIndex]; - } - - if ('/' == InFile.peek()) - { - InFile.ignore(); - - // Optional vertex normal - InFile >> iNormal; - - uint32_t normIndex = 0; - if (!iNormal) - { - // 0 is not allowed for index - return E_UNEXPECTED; - } - else if (iNormal < 0) - { - // Negative values are relative indices - normIndex = uint32_t(ptrdiff_t(normals.size()) + iNormal); - } - else - { - // OBJ format uses 1-based arrays - normIndex = uint32_t(iNormal - 1); - } - - if (normIndex >= normals.size()) - return E_FAIL; - - vertex.normal = normals[normIndex]; - } - } - - // If a duplicate vertex doesn't exist, add this vertex to the Vertices - // list. Store the index in the Indices array. The Vertices and Indices - // lists will eventually become the Vertex Buffer and Index Buffer for - // the mesh. - const uint32_t index = AddVertex(vertexIndex, &vertex, vertexCache); - if (index == uint32_t(-1)) - return E_OUTOFMEMORY; - - constexpr uint32_t maxIndex = (sizeof(index_t) == 2) ? UINT16_MAX : UINT32_MAX; - if (index >= maxIndex) - { - // Too many indices for IB! - return E_FAIL; - } - - faceIndex[iFace] = index; - ++iFace; - - // Check for more face data or end of the face statement - bool faceEnd = false; - for (;;) - { - const wchar_t p = InFile.peek(); - - if ('\n' == p || !InFile) - { - faceEnd = true; - break; - } - else if (isdigit(p) || p == '-' || p == '+') - break; - - InFile.ignore(); - } - - if (faceEnd) - break; - } - - if (iFace < 3) - { - // Need at least 3 points to form a triangle - return E_FAIL; - } - - // Convert polygons to triangles - const uint32_t i0 = faceIndex[0]; - uint32_t i1 = faceIndex[1]; - - for (size_t j = 2; j < iFace; ++j) - { - const uint32_t index = faceIndex[j]; - indices.emplace_back(static_cast(i0)); - if (ccw) - { - indices.emplace_back(static_cast(i1)); - indices.emplace_back(static_cast(index)); - } - else - { - indices.emplace_back(static_cast(index)); - indices.emplace_back(static_cast(i1)); - } - - attributes.emplace_back(curSubset); - - i1 = index; - } - - assert(attributes.size() * 3 == indices.size()); - } - else if (0 == wcscmp(strCommand.c_str(), L"mtllib")) - { - // Material library - InFile >> strMaterialFilename; - } - else if (0 == wcscmp(strCommand.c_str(), L"usemtl")) - { - // Material - wchar_t strName[MAX_PATH] = {}; - InFile >> strName; - - bool bFound = false; - uint32_t count = 0; - for (auto it = materials.cbegin(); it != materials.cend(); ++it, ++count) - { - if (0 == wcscmp(it->strName, strName)) - { - bFound = true; - curSubset = count; - break; - } - } - - if (!bFound) - { - Material mat; - curSubset = static_cast(materials.size()); - wcscpy_s(mat.strName, MAX_PATH - 1, strName); - materials.emplace_back(mat); - } - } - else - { -#ifdef _DEBUG - // Unimplemented or unrecognized command - OutputDebugStringW(strCommand.c_str()); -#endif - } - - InFile.ignore(1000, L'\n'); - } - - if (positions.empty()) - return E_FAIL; - - // Cleanup - InFile.close(); - - BoundingBox::CreateFromPoints(bounds, positions.size(), positions.data(), sizeof(XMFLOAT3)); - - // If an associated material file was found, read that in as well. - if (*strMaterialFilename) - { -#ifdef _WIN32 - wchar_t ext[_MAX_EXT] = {}; - _wsplitpath_s(strMaterialFilename, nullptr, 0, nullptr, 0, fname, _MAX_FNAME, ext, _MAX_EXT); - - wchar_t drive[_MAX_DRIVE] = {}; - wchar_t dir[_MAX_DIR] = {}; - _wsplitpath_s(szFileName, drive, _MAX_DRIVE, dir, _MAX_DIR, nullptr, 0, nullptr, 0); - - wchar_t szPath[MAX_PATH] = {}; - _wmakepath_s(szPath, MAX_PATH, drive, dir, fname, ext); - HRESULT hr = LoadMTL(szPath); - if (FAILED(hr)) - return hr; -#else - auto path = std::filesystem::path(szFileName); - auto mtlpath = std::filesystem::path(strMaterialFilename); - path.replace_filename(mtlpath.filename()); - path.replace_extension(mtlpath.extension()); - - HRESULT hr = LoadMTL(path.c_str()); - if (FAILED(hr)) - return hr; -#endif - } - - return S_OK; - } - - HRESULT LoadMTL(_In_z_ const wchar_t* szFileName) - { - using namespace DirectX; - - // Assumes MTL is in CWD along with OBJ - std::wifstream InFile(szFileName); - if (!InFile) - return /* HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) */ static_cast(0x80070002L); - - InFile.imbue(std::locale::classic()); - - auto curMaterial = materials.end(); - - for (;; ) - { - std::wstring strCommand; - InFile >> strCommand; - if (!InFile) - break; - - if (0 == wcscmp(strCommand.c_str(), L"newmtl")) - { - // Switching active materials - wchar_t strName[MAX_PATH] = {}; - InFile >> strName; - - curMaterial = materials.end(); - for (auto it = materials.begin(); it != materials.end(); ++it) - { - if (0 == wcscmp(it->strName, strName)) - { - curMaterial = it; - break; - } - } - } - - // The rest of the commands rely on an active material - if (curMaterial == materials.end()) - continue; - - if (0 == wcscmp(strCommand.c_str(), L"#")) - { - // Comment - } - else if (0 == wcscmp(strCommand.c_str(), L"Ka")) - { - // Ambient color - float r, g, b; - InFile >> r >> g >> b; - curMaterial->vAmbient = XMFLOAT3(r, g, b); - } - else if (0 == wcscmp(strCommand.c_str(), L"Kd")) - { - // Diffuse color - float r, g, b; - InFile >> r >> g >> b; - curMaterial->vDiffuse = XMFLOAT3(r, g, b); - } - else if (0 == wcscmp(strCommand.c_str(), L"Ks")) - { - // Specular color - float r, g, b; - InFile >> r >> g >> b; - curMaterial->vSpecular = XMFLOAT3(r, g, b); - } - else if (0 == wcscmp(strCommand.c_str(), L"Ke")) - { - // Emissive color - float r, g, b; - InFile >> r >> g >> b; - curMaterial->vEmissive = XMFLOAT3(r, g, b); - if (r > 0.f || g > 0.f || b > 0.f) - { - curMaterial->bEmissive = true; - } - } - else if (0 == wcscmp(strCommand.c_str(), L"d")) - { - // Alpha - float alpha; - InFile >> alpha; - curMaterial->fAlpha = std::min(1.f, std::max(0.f, alpha)); - } - else if (0 == wcscmp(strCommand.c_str(), L"Tr")) - { - // Transparency (inverse of alpha) - float invAlpha; - InFile >> invAlpha; - curMaterial->fAlpha = std::min(1.f, std::max(0.f, 1.f - invAlpha)); - } - else if (0 == wcscmp(strCommand.c_str(), L"Ns")) - { - // Shininess - int nShininess; - InFile >> nShininess; - curMaterial->nShininess = uint32_t(nShininess); - } - else if (0 == wcscmp(strCommand.c_str(), L"illum")) - { - // Specular on/off - int illumination; - InFile >> illumination; - curMaterial->bSpecular = (illumination == 2); - } - else if (0 == wcscmp(strCommand.c_str(), L"map_Kd")) - { - // Diffuse texture - LoadTexturePath(InFile, curMaterial->strTexture, MAX_PATH); - } - else if (0 == wcscmp(strCommand.c_str(), L"map_Ks")) - { - // Specular texture - LoadTexturePath(InFile, curMaterial->strSpecularTexture, MAX_PATH); - } - else if (0 == wcscmp(strCommand.c_str(), L"map_Kn") - || 0 == wcscmp(strCommand.c_str(), L"norm")) - { - // Normal texture - LoadTexturePath(InFile, curMaterial->strNormalTexture, MAX_PATH); - } - else if (0 == wcscmp(strCommand.c_str(), L"map_Ke") - || 0 == wcscmp(strCommand.c_str(), L"map_emissive")) - { - // Emissive texture - LoadTexturePath(InFile, curMaterial->strEmissiveTexture, MAX_PATH); - curMaterial->bEmissive = true; - } - else if (0 == wcscmp(strCommand.c_str(), L"map_RMA") - || 0 == wcscmp(strCommand.c_str(), L"map_ORM")) - { - // RMA texture - LoadTexturePath(InFile, curMaterial->strRMATexture, MAX_PATH); - } - else - { - // Unimplemented or unrecognized command - } - - InFile.ignore(1000, L'\n'); - } - - InFile.close(); - - return S_OK; - } - - void Clear() - { - vertices.clear(); - indices.clear(); - attributes.clear(); - materials.clear(); - name.clear(); - hasNormals = false; - hasTexcoords = false; - - bounds.Center.x = bounds.Center.y = bounds.Center.z = 0.f; - bounds.Extents.x = bounds.Extents.y = bounds.Extents.z = 0.f; - } - - HRESULT LoadVBO(_In_z_ const wchar_t* szFileName) - { - using namespace DirectX; - - Clear(); - -#ifdef _WIN32 - wchar_t fname[_MAX_FNAME] = {}; - _wsplitpath_s(szFileName, nullptr, 0, nullptr, 0, fname, _MAX_FNAME, nullptr, 0); - name = fname; -#else - auto path = std::filesystem::path(szFileName); - name = path.filename().c_str(); -#endif - - Material defmat; - wcscpy_s(defmat.strName, L"default"); - materials.emplace_back(defmat); - - std::ifstream vboFile(szFileName, std::ifstream::in | std::ifstream::binary); - if (!vboFile.is_open()) - return /* HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) */ static_cast(0x80070002L); - - hasNormals = hasTexcoords = true; - - uint32_t numVertices = 0; - uint32_t numIndices = 0; - - vboFile.read(reinterpret_cast(&numVertices), sizeof(uint32_t)); - if (!numVertices) - return E_FAIL; - - vboFile.read(reinterpret_cast(&numIndices), sizeof(uint32_t)); - if (!numIndices) - return E_FAIL; - - vertices.resize(numVertices); - vboFile.read(reinterpret_cast(vertices.data()), sizeof(Vertex) * numVertices); - -#if (__cplusplus >= 201703L) - if constexpr (sizeof(index_t) == 2) -#else -#pragma warning( suppress : 4127 ) - if (sizeof(index_t) == 2) -#endif - { - indices.resize(numIndices); - vboFile.read(reinterpret_cast(indices.data()), sizeof(uint16_t) * numIndices); - } - else - { - std::vector tmp; - tmp.resize(numIndices); - vboFile.read(reinterpret_cast(tmp.data()), sizeof(uint16_t) * numIndices); - - indices.reserve(numIndices); - for (const auto it : tmp) - { - indices.emplace_back(it); - } - } - - BoundingBox::CreateFromPoints(bounds, vertices.size(), reinterpret_cast(vertices.data()), sizeof(Vertex)); - - vboFile.close(); - - return S_OK; - } - - struct Material - { - DirectX::XMFLOAT3 vAmbient; - DirectX::XMFLOAT3 vDiffuse; - DirectX::XMFLOAT3 vSpecular; - DirectX::XMFLOAT3 vEmissive; - uint32_t nShininess; - float fAlpha; - - bool bSpecular; - bool bEmissive; - - wchar_t strName[MAX_PATH]; - wchar_t strTexture[MAX_PATH]; - wchar_t strNormalTexture[MAX_PATH]; - wchar_t strSpecularTexture[MAX_PATH]; - wchar_t strEmissiveTexture[MAX_PATH]; - wchar_t strRMATexture[MAX_PATH]; - - Material() noexcept : - vAmbient(0.2f, 0.2f, 0.2f), - vDiffuse(0.8f, 0.8f, 0.8f), - vSpecular(1.0f, 1.0f, 1.0f), - vEmissive(0.f, 0.f, 0.f), - nShininess(0), - fAlpha(1.f), - bSpecular(false), - bEmissive(false), - strName{}, - strTexture{}, - strNormalTexture{}, - strSpecularTexture{}, - strEmissiveTexture{}, - strRMATexture{} - { - } - }; - - std::vector vertices; - std::vector indices; - std::vector attributes; - std::vector materials; - - std::wstring name; - bool hasNormals; - bool hasTexcoords; - - DirectX::BoundingBox bounds; - -private: - using VertexCache = std::unordered_multimap; - - uint32_t AddVertex(uint32_t hash, const Vertex* pVertex, VertexCache& cache) - { - auto f = cache.equal_range(hash); - - for (auto it = f.first; it != f.second; ++it) - { - auto& tv = vertices[it->second]; - - if (0 == memcmp(pVertex, &tv, sizeof(Vertex))) - { - return it->second; - } - } - - auto index = static_cast(vertices.size()); - vertices.emplace_back(*pVertex); - - VertexCache::value_type entry(hash, index); - cache.insert(entry); - return index; - } - - void LoadTexturePath(std::wifstream& InFile, _Out_writes_(maxChar) wchar_t* texture, size_t maxChar) - { - wchar_t buff[1024] = {}; - InFile.getline(buff, 1024, L'\n'); - InFile.putback(L'\n'); - - std::wstring path = buff; - - // Ignore any end-of-line comment - size_t pos = path.find_first_of(L'#'); - if (pos != std::wstring::npos) - { - path = path.substr(0, pos); - } - - // Trim any trailing whitespace - pos = path.find_last_not_of(L" \t"); - if (pos != std::wstring::npos) - { - path = path.substr(0, pos + 1); - } - - // Texture path should be last element in line - pos = path.find_last_of(' '); - if (pos != std::wstring::npos) - { - path = path.substr(pos + 1); - } - - if (!path.empty()) - { -#ifdef _WIN32 - wcscpy_s(texture, maxChar, path.c_str()); -#else - wcscpy(texture, path.c_str()); -#endif - } - } -}; diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.editorconfig b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.editorconfig deleted file mode 100644 index 174669d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.editorconfig +++ /dev/null @@ -1,74 +0,0 @@ -root = true - -[*.{fx,fxh,hlsl,hlsli}] -indent_size = 4 -indent_style = space -trim_trailing_whitespace = true -insert_final_newline = true -end_of_line = crlf -charset = latin1 -cpp_space_before_function_open_parenthesis = remove -cpp_space_around_binary_operator = ignore -cpp_space_pointer_reference_alignment = ignore - -[*.{cpp,h,hpp,inl}] -indent_size = 4 -indent_style = space -trim_trailing_whitespace = true -insert_final_newline = true -end_of_line = crlf -charset = latin1 -cpp_indent_braces = false -cpp_indent_multi_line_relative_to = innermost_parenthesis -cpp_indent_within_parentheses = indent -cpp_indent_preserve_within_parentheses = false -cpp_indent_case_contents = true -cpp_indent_case_labels = false -cpp_indent_case_contents_when_block = true -cpp_indent_lambda_braces_when_parameter = true -cpp_indent_preprocessor = one_left -cpp_indent_access_specifiers = false -cpp_indent_namespace_contents = true -cpp_indent_preserve_comments = true -cpp_new_line_before_open_brace_namespace = new_line -cpp_new_line_before_open_brace_type = new_line -cpp_new_line_before_open_brace_function = new_line -cpp_new_line_before_open_brace_block = new_line -cpp_new_line_before_open_brace_lambda = new_line -cpp_new_line_scope_braces_on_separate_lines = true -cpp_new_line_close_brace_same_line_empty_type = true -cpp_new_line_close_brace_same_line_empty_function = true -cpp_new_line_before_catch = true -cpp_new_line_before_else = true -cpp_new_line_before_while_in_do_while = true -cpp_space_before_function_open_parenthesis = remove -cpp_space_within_parameter_list_parentheses = false -cpp_space_between_empty_parameter_list_parentheses = false -cpp_space_after_keywords_in_control_flow_statements = true -cpp_space_within_control_flow_statement_parentheses = false -cpp_space_before_lambda_open_parenthesis = false -cpp_space_within_cast_parentheses = false -cpp_space_after_cast_close_parenthesis = false -cpp_space_within_expression_parentheses = false -cpp_space_before_initializer_list_open_brace = false -cpp_space_within_initializer_list_braces = true -cpp_space_before_open_square_bracket = false -cpp_space_within_square_brackets = false -cpp_space_before_empty_square_brackets = false -cpp_space_between_empty_square_brackets = false -cpp_space_group_square_brackets = true -cpp_space_within_lambda_brackets = false -cpp_space_between_empty_lambda_brackets = false -cpp_space_before_comma = false -cpp_space_after_comma = true -cpp_space_remove_around_member_operators = true -cpp_space_before_inheritance_colon = true -cpp_space_before_constructor_colon = true -cpp_space_remove_before_semicolon = true -cpp_space_after_semicolon = false -cpp_space_remove_around_unary_operator = false -cpp_space_around_binary_operator = ignore -cpp_space_around_assignment_operator = insert -cpp_space_pointer_reference_alignment = ignore -cpp_space_around_ternary_operator = insert -cpp_wrap_preserve_blocks = one_liners diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.gitattributes b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.gitattributes deleted file mode 100644 index a2d10b7..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.gitattributes +++ /dev/null @@ -1,19 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto - -# Explicitly declare code/VS files as CRLF -*.cpp eol=crlf -*.cmd eol=crlf -*.h eol=crlf -*.hlsl eol=crlf -*.hlsli eol=crlf -*.fx eol=crlf -*.fxh eol=crlf -*.inc eol=crlf -*.inl eol=crlf -*.vcxproj eol=crlf -*.filters eol=crlf -*.sln eol=crlf - -# Explicitly declare resource files as binary -*.pdb binary diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.gitignore b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.gitignore deleted file mode 100644 index 56c7697..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.gitignore +++ /dev/null @@ -1,39 +0,0 @@ -*.psess -*.vsp -*.log -*.err -*.wrn -*.suo -*.sdf -*.user -*.i -*.vspscc -*.opensdf -*.opendb -*.ipch -*.cache -*.tlog -*.lastbuildstate -*.ilk -*.VC.db -*.nupkg -.vs -[Bb]in -packages -/DDSView/Shaders/*.inc -/DDSView/Shaders/*.pdb -/DirectXTex/Shaders/Compiled/*.inc -/DirectXTex/Shaders/Compiled/*.pdb -/ipch -Debug -Durango -Gaming.Xbox.XboxOne.x64 -Gaming.Xbox.Scarlett.x64 -Gaming.Desktop.x64 -Profile -Release -x64 -/Tests -/wiki -/out -/CMakeUserPresets.json diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.nuget/DirectXTex-config.cmake.in b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.nuget/DirectXTex-config.cmake.in deleted file mode 100644 index 2538e16..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.nuget/DirectXTex-config.cmake.in +++ /dev/null @@ -1,16 +0,0 @@ -@PACKAGE_INIT@ - -include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake) -include(CMakeFindDependencyMacro) - -set(ENABLE_OPENEXR_SUPPORT @ENABLE_OPENEXR_SUPPORT@) -if(ENABLE_OPENEXR_SUPPORT) - find_dependency(OpenEXR) -endif() - -if(MINGW OR (NOT WIN32) OR VCPKG_TOOLCHAIN) - find_dependency(directx-headers CONFIG) - find_dependency(directxmath CONFIG) -endif() - -check_required_components("@PROJECT_NAME@") diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.nuget/directxtex_desktop_2019.nuspec b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.nuget/directxtex_desktop_2019.nuspec deleted file mode 100644 index 60f8a79..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.nuget/directxtex_desktop_2019.nuspec +++ /dev/null @@ -1,48 +0,0 @@ - - - - directxtex_desktop_2019 - 0.0.0-SpecifyVersionOnCommandline - DirectXTex Library (VS 2019/2022 Win32) - Microsoft - microsoft,directxtk - DirectXTex texture processing library - This version is for Windows desktop applications using Visual Studio 2019 or Visual Studio 2022 and supports Windows 7 / DirectX 11. - -DirectXTex, a shared source library for reading and writing .DDS files, and performing various texture content processing operations including resizing, format conversion, mip-map generation, block compression for Direct3D runtime texture resources, and height-map to normal-map conversion. This library makes use of the Windows Image Component (WIC) APIs. It also includes simple .TGA and .HDR readers and writers since these image file format are commonly used for texture content processing pipelines, but are not currently supported by a built-in WIC codec. - Matches the May 9, 2022 release on GitHub. - http://go.microsoft.com/fwlink/?LinkId=248926 - - images\icon.jpg - docs\README.md - MIT - false - © Microsoft Corporation. All rights reserved. - DirectX DirectXTex native nativepackage - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.nuget/directxtex_desktop_2019.targets b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.nuget/directxtex_desktop_2019.targets deleted file mode 100644 index de43df5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.nuget/directxtex_desktop_2019.targets +++ /dev/null @@ -1,29 +0,0 @@ - - - - - Debug - - - Release - - - - $(MSBuildThisFileDirectory)..\..\native\lib\$(Platform)\$(NuGetConfiguration) - - - - - $(directxtex-LibPath);%(AdditionalLibraryDirectories) - DirectXTex.lib;%(AdditionalDependencies) - - - - - - HAS_DIRECTXTEX;%(PreprocessorDefinitions) - $(MSBuildThisFileDirectory)..\..\include;%(AdditionalIncludeDirectories) - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.nuget/directxtex_desktop_win10.nuspec b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.nuget/directxtex_desktop_win10.nuspec deleted file mode 100644 index 9a56617..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.nuget/directxtex_desktop_win10.nuspec +++ /dev/null @@ -1,54 +0,0 @@ - - - - directxtex_desktop_win10 - 0.0.0-SpecifyVersionOnCommandline - DirectXTex Library (VS 2019/2022 Win32 for Windows 10/11) - Microsoft - microsoft,directxtk - DirectXTex texture processing library - This version is for Windows desktop applications using Visual Studio 2019 or Visual Studio 2022 and supports Windows 10 / Windows 11 including both DirectX 11 and DirectX 12. - -DirectXTex, a shared source library for reading and writing .DDS files, and performing various texture content processing operations including resizing, format conversion, mip-map generation, block compression for Direct3D runtime texture resources, and height-map to normal-map conversion. This library makes use of the Windows Image Component (WIC) APIs. It also includes simple .TGA and .HDR readers and writers since these image file format are commonly used for texture content processing pipelines, but are not currently supported by a built-in WIC codec. - Matches the May 9, 2022 release on GitHub. - http://go.microsoft.com/fwlink/?LinkId=248926 - - images\icon.jpg - docs\README.md - MIT - false - © Microsoft Corporation. All rights reserved. - DirectX DirectXTex native nativepackage - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.nuget/directxtex_desktop_win10.targets b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.nuget/directxtex_desktop_win10.targets deleted file mode 100644 index 92f38b8..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.nuget/directxtex_desktop_win10.targets +++ /dev/null @@ -1,41 +0,0 @@ - - - - - <_NuGetConfiguration>Debug - - - <_NuGetConfiguration>Release - - - - <_NuGetPlatform>x64 - - - <_NuGetPlatform>$(Platform) - - - - $(MSBuildThisFileDirectory)..\..\native\lib\$(_NuGetPlatform)\$(_NuGetConfiguration) - - - - - $(directxtex-LibPath);%(AdditionalLibraryDirectories) - DirectXTex.lib;%(AdditionalDependencies) - - - - - - HAS_DIRECTXTEX;%(PreprocessorDefinitions) - $(MSBuildThisFileDirectory)..\..\include;%(AdditionalIncludeDirectories) - - - - - <_NuGetConfiguration> - <_NuGetPlatform> - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.nuget/directxtex_uwp.nuspec b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.nuget/directxtex_uwp.nuspec deleted file mode 100644 index 1ef2685..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.nuget/directxtex_uwp.nuspec +++ /dev/null @@ -1,60 +0,0 @@ - - - - directxtex_uwp - 0.0.0-SpecifyVersionOnCommandline - DirectXTex Library (UWP) - Microsoft - microsoft,directxtk - DirectXTex texture processing library - This version is for Universal Windows Platform apps on Windows 10 / Windows 11 using Visual Studio 2019 or Visual Studio 2022. - -DirectXTex, a shared source library for reading and writing .DDS files, and performing various texture content processing operations including resizing, format conversion, mip-map generation, block compression for Direct3D runtime texture resources, and height-map to normal-map conversion. This library makes use of the Windows Image Component (WIC) APIs. It also includes simple .TGA and .HDR readers and writers since these image file format are commonly used for texture content processing pipelines, but are not currently supported by a built-in WIC codec. - Matches the May 9, 2022 release on GitHub. - http://go.microsoft.com/fwlink/?LinkId=248926 - - images\icon.jpg - docs\README.md - MIT - false - © Microsoft Corporation. All rights reserved. - DirectX DirectXTex native nativepackage - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.nuget/directxtex_uwp.targets b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.nuget/directxtex_uwp.targets deleted file mode 100644 index de43df5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.nuget/directxtex_uwp.targets +++ /dev/null @@ -1,29 +0,0 @@ - - - - - Debug - - - Release - - - - $(MSBuildThisFileDirectory)..\..\native\lib\$(Platform)\$(NuGetConfiguration) - - - - - $(directxtex-LibPath);%(AdditionalLibraryDirectories) - DirectXTex.lib;%(AdditionalDependencies) - - - - - - HAS_DIRECTXTEX;%(PreprocessorDefinitions) - $(MSBuildThisFileDirectory)..\..\include;%(AdditionalIncludeDirectories) - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.nuget/icon.jpg b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.nuget/icon.jpg deleted file mode 100644 index 08fe1fa..0000000 Binary files a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.nuget/icon.jpg and /dev/null differ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.nuget/versioninfo.ps1 b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.nuget/versioninfo.ps1 deleted file mode 100644 index 545abd7..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/.nuget/versioninfo.ps1 +++ /dev/null @@ -1,6 +0,0 @@ -param( -[string]$version -) -$versionComma = $version.Replace(".", ",") -$files = 'Texassemble\texassemble.rc', 'Texconv\Texconv.rc', 'Texdiag\texdiag.rc' -foreach ($file in $files) { (Get-Content $file).replace('1,0,0,0', $versionComma).replace('1.0.0.0', $version) | Set-Content $file } diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/CMakeLists.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/CMakeLists.txt deleted file mode 100644 index 240b7f0..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/CMakeLists.txt +++ /dev/null @@ -1,363 +0,0 @@ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. - -cmake_minimum_required (VERSION 3.13) - -set(DIRECTXTEX_VERSION 1.9.6) - -project (DirectXTex - VERSION ${DIRECTXTEX_VERSION} - DESCRIPTION "DirectX Texture Library" - HOMEPAGE_URL "https://go.microsoft.com/fwlink/?LinkId=248926" - LANGUAGES CXX) - -option(BUILD_TOOLS "Build tex command-line tools" ON) - -option(BUILD_SAMPLE "Build DDSView sample" ON) - -# Includes the functions for Direct3D 11 resources and DirectCompute compression -option(BUILD_DX11 "Build with DirectX11 Runtime support" ON) - -# Includes the functions for creating Direct3D 12 resources at runtime -option(BUILD_DX12 "Build with DirectX12 Runtime support" ON) - -# Enable the use of OpenMP for software BC6H/BC7 compression -option(BC_USE_OPENMP "Build with OpenMP support" ON) - -option(ENABLE_CODE_ANALYSIS "Use Static Code Analysis on build" OFF) - -option(USE_PREBUILT_SHADERS "Use externally built HLSL shaders" OFF) - -# Includes the functions for loading/saving OpenEXR files at runtime -# NOTE requires adding DirectXTexEXR.h/.cpp source files (vcpkg does this automatically) -option(ENABLE_OPENEXR_SUPPORT "Build with OpenEXR support" OFF) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) - -#set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/CMake") -#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/CMake") -#set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/CMake") - -if (DEFINED VCPKG_TARGET_ARCHITECTURE) - set(DIRECTX_ARCH ${VCPKG_TARGET_ARCHITECTURE}) -elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Ww][Ii][Nn]32$") - set(DIRECTX_ARCH x86) -elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Xx]64$") - set(DIRECTX_ARCH x64) -elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]$") - set(DIRECTX_ARCH arm) -elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]64$") - set(DIRECTX_ARCH arm64) -endif() - -include(GNUInstallDirs) - -#--- Library -set(LIBRARY_HEADERS - DirectXTex/DirectXTex.h - DirectXTex/DirectXTex.inl) - -set(LIBRARY_SOURCES - DirectXTex/BC.h - DirectXTex/DDS.h - DirectXTex/DirectXTexP.h - DirectXTex/filters.h - DirectXTex/scoped.h - DirectXTex/BC.cpp - DirectXTex/BC4BC5.cpp - DirectXTex/BC6HBC7.cpp - DirectXTex/DirectXTexCompress.cpp - DirectXTex/DirectXTexConvert.cpp - DirectXTex/DirectXTexDDS.cpp - DirectXTex/DirectXTexHDR.cpp - DirectXTex/DirectXTexImage.cpp - DirectXTex/DirectXTexMipmaps.cpp - DirectXTex/DirectXTexMisc.cpp - DirectXTex/DirectXTexNormalMaps.cpp - DirectXTex/DirectXTexPMAlpha.cpp - DirectXTex/DirectXTexResize.cpp - DirectXTex/DirectXTexTGA.cpp - DirectXTex/DirectXTexUtil.cpp) - -if(WIN32) - set(LIBRARY_SOURCES ${LIBRARY_SOURCES} - DirectXTex/DirectXTexFlipRotate.cpp - DirectXTex/DirectXTexWIC.cpp) -endif() - -set(SHADER_SOURCES - DirectXTex/Shaders/BC6HEncode.hlsl - DirectXTex/Shaders/BC7Encode.hlsl) - -if(BUILD_DX11 AND WIN32) - set(LIBRARY_SOURCES ${LIBRARY_SOURCES} - DirectXTex/BCDirectCompute.h - DirectXTex/BCDirectCompute.cpp - DirectXTex/DirectXTexCompressGPU.cpp - DirectXTex/DirectXTexD3D11.cpp) -endif() - -if(BUILD_DX12) - set(LIBRARY_SOURCES ${LIBRARY_SOURCES} - DirectXTex/d3dx12.h - DirectXTex/DirectXTexD3D12.cpp) -endif() - -if(ENABLE_OPENEXR_SUPPORT) - set(LIBRARY_HEADERS ${LIBRARY_HEADERS} - DirectXTex/DirectXTexEXR.h) - - set(LIBRARY_SOURCES ${LIBRARY_SOURCES} - DirectXTex/DirectXTexEXR.h - DirectXTex/DirectXTexEXR.cpp) -endif() - -if(BUILD_DX11 AND WIN32) - if (NOT COMPILED_SHADERS) - if (USE_PREBUILT_SHADERS) - message(FATAL_ERROR "ERROR: Using prebuilt shaders requires the COMPILED_SHADERS variable is set") - endif() - set(COMPILED_SHADERS ${CMAKE_CURRENT_BINARY_DIR}/Shaders/Compiled) - file(MAKE_DIRECTORY ${COMPILED_SHADERS}) - else() - file(TO_CMAKE_PATH ${COMPILED_SHADERS} COMPILED_SHADERS) - endif() - - set(LIBRARY_SOURCES ${LIBRARY_SOURCES} - ${COMPILED_SHADERS}/BC6HEncode_EncodeBlockCS.inc) - - if (NOT USE_PREBUILT_SHADERS) - add_custom_command( - OUTPUT "${COMPILED_SHADERS}/BC6HEncode_EncodeBlockCS.inc" - MAIN_DEPENDENCY "${PROJECT_SOURCE_DIR}/DirectXTex/Shaders/CompileShaders.cmd" - DEPENDS ${SHADER_SOURCES} - COMMENT "Generating HLSL shaders..." - COMMAND ${CMAKE_COMMAND} -E env CompileShadersOutput="${COMPILED_SHADERS}" CompileShaders.cmd > "${COMPILED_SHADERS}/compileshaders.log" - WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/DirectXTex/Shaders" - USES_TERMINAL) - endif() -endif() - -add_library(${PROJECT_NAME} STATIC ${LIBRARY_SOURCES} ${LIBRARY_HEADERS}) - -if(BUILD_DX11 AND WIN32) - target_include_directories(${PROJECT_NAME} PRIVATE ${COMPILED_SHADERS}) -endif() - -source_group(${PROJECT_NAME} REGULAR_EXPRESSION DirectXTex/*.*) - -target_include_directories(${PROJECT_NAME} PUBLIC - $ - $) - -if(ENABLE_OPENEXR_SUPPORT) - find_package(OpenEXR REQUIRED) - target_include_directories(${PROJECT_NAME} PRIVATE ${OPENEXR_INCLUDE_DIRS}/OpenEXR) -endif() - -if ((${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16") AND (NOT MINGW)) - target_precompile_headers(${PROJECT_NAME} PRIVATE DirectXTex/DirectXTexP.h) -endif() - -if(MSVC) - # Use max Warning Level - string(REPLACE "/W3 " "/Wall " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) - string(REPLACE "/W3 " "/Wall " CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) - string(REPLACE "/W3 " "/Wall " CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}) - - # Not using typeid or dynamic_cast, so disable RTTI to save binary size - string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) - string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) - string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}) -endif() - -if (MINGW OR (NOT WIN32) OR VCPKG_TOOLCHAIN) - message("INFO: Using VCPKG for DirectX-Headers and DirectXMath.") - find_package(directx-headers CONFIG REQUIRED) - find_package(directxmath CONFIG REQUIRED) - target_link_libraries(${PROJECT_NAME} PRIVATE Microsoft::DirectX-Headers Microsoft::DirectXMath) - target_compile_definitions(${PROJECT_NAME} PRIVATE USING_DIRECTX_HEADERS) -endif() - -#--- Command-line tools -if(BUILD_TOOLS AND WIN32 AND (NOT WINDOWS_STORE)) - set(TOOL_EXES texassemble texconv texdiag) - - add_executable(texassemble - Texassemble/texassemble.cpp - Texassemble/AnimatedGif.cpp) - target_link_libraries(texassemble ${PROJECT_NAME} ole32.lib version.lib) - source_group(texassemble REGULAR_EXPRESSION Texassemble/*.*) - - add_executable(texconv - Texconv/texconv.cpp - Texconv/ExtendedBMP.cpp - Texconv/PortablePixMap.cpp) - target_link_libraries(texconv ${PROJECT_NAME} ole32.lib shell32.lib version.lib) - source_group(texconv REGULAR_EXPRESSION Texconv/*.*) - - add_executable(texdiag Texdiag/texdiag.cpp) - target_link_libraries(texdiag ${PROJECT_NAME} ole32.lib version.lib) - source_group(texdiag REGULAR_EXPRESSION Texdiag/*.*) - - if(ENABLE_OPENEXR_SUPPORT) - foreach(t IN LISTS TOOL_EXES) - target_link_libraries(${t} ${OPENEXR_ILMIMF_LIBRARY}) - target_compile_options(${t} PRIVATE -DUSE_OPENEXR) - endforeach() - endif() -endif() - -#--- DDSView sample -if(BUILD_SAMPLE AND BUILD_DX11 AND WIN32 AND (NOT WINDOWS_STORE)) - list(APPEND TOOL_EXES ddsview) - - if (NOT COMPILED_DDSVIEW_SHADERS) - if (USE_PREBUILT_SHADERS) - message(FATAL_ERROR "ERROR: Using prebuilt shaders requires the COMPILED_DDSVIEW_SHADERS variable is set") - endif() - set(COMPILED_DDSVIEW_SHADERS ${CMAKE_CURRENT_BINARY_DIR}/Shaders/Compiled) - file(MAKE_DIRECTORY ${COMPILED_DDSVIEW_SHADERS}) - else() - file(TO_CMAKE_PATH ${COMPILED_DDSVIEW_SHADERS} COMPILED_DDSVIEW_SHADERS) - endif() - - add_executable(ddsview WIN32 - DDSView/ddsview.cpp - DDSView/ddsview.rc - ${COMPILED_DDSVIEW_SHADERS}/ddsview_ps1D.inc) - target_link_libraries(ddsview ${PROJECT_NAME} d3d11.lib) - source_group(ddsview REGULAR_EXPRESSION DDSView/*.*) - - target_include_directories(ddsview PRIVATE ${COMPILED_DDSVIEW_SHADERS}) - - if (NOT USE_PREBUILT_SHADERS) - add_custom_command( - OUTPUT "${COMPILED_DDSVIEW_SHADERS}/ddsview_ps1D.inc" - MAIN_DEPENDENCY "${PROJECT_SOURCE_DIR}/DDSView/hlsl.cmd" - DEPENDS "${PROJECT_SOURCE_DIR}/DDSView/ddsview.fx" - COMMENT "Generating HLSL shaders for DDSView..." - COMMAND COMMAND ${CMAKE_COMMAND} -E env CompileShadersOutput="${COMPILED_DDSVIEW_SHADERS}" hlsl.cmd > "${COMPILED_DDSVIEW_SHADERS}/hlsl.log" - WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/DDSView" - USES_TERMINAL) - endif() -endif() - -if (MINGW OR (NOT WIN32) OR VCPKG_TOOLCHAIN) - foreach(t IN LISTS TOOL_EXES) - target_link_libraries(${t} Microsoft::DirectXMath) - endforeach() -endif() - -if(MSVC) - foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME}) - target_compile_options(${t} PRIVATE /fp:fast "$<$>:/guard:cf>") - target_link_options(${t} PRIVATE /DYNAMICBASE /NXCOMPAT) - endforeach() - - if((${CMAKE_SIZEOF_VOID_P} EQUAL 4) AND (NOT ${DIRECTX_ARCH} MATCHES "^arm")) - foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME}) - target_link_options(${t} PRIVATE /SAFESEH) - endforeach() - endif() -endif() - -if(NOT ${DIRECTX_ARCH} MATCHES "^arm") - if (${CMAKE_SIZEOF_VOID_P} EQUAL "4") - set(ARCH_SSE2 $<$:/arch:SSE2> $<$>:-msse2>) - else() - set(ARCH_SSE2 $<$>:-msse2>) - endif() - - foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME}) - target_compile_options(${t} PRIVATE ${ARCH_SSE2}) - endforeach() -endif() - -if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - set(WarningsLib "-Wpedantic" "-Wextra") - target_compile_options(${PROJECT_NAME} PRIVATE ${WarningsLib}) - - # OpenMP is not supported for clang for Windows by default - - set(WarningsEXE ${WarningsLib} "-Wno-c++98-compat" "-Wno-c++98-compat-pedantic" "-Wno-switch" "-Wno-switch-enum" "-Wno-covered-switch-default" "-Wno-language-extension-token" "-Wno-missing-prototypes" "-Wno-global-constructors" "-Wno-double-promotion") - foreach(t IN LISTS TOOL_EXES) - target_compile_options(${t} PRIVATE ${WarningsEXE}) - endforeach() -endif() -if(MINGW) - foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME}) - target_compile_options(${t} PRIVATE -Wno-ignored-attributes) - target_link_options(${t} PRIVATE -municode) - endforeach() -endif() -if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") - foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME}) - target_compile_options(${t} PRIVATE /sdl /permissive- /JMC- /Zc:__cplusplus) - endforeach() - - if(ENABLE_CODE_ANALYSIS) - foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME}) - target_compile_options(${t} PRIVATE /analyze) - endforeach() - endif() - - if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.24) - foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME}) - target_compile_options(${t} PRIVATE /ZH:SHA_256) - endforeach() - endif() - - if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.26) - foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME}) - target_compile_options(${t} PRIVATE /Zc:preprocessor /wd5105) - endforeach() - endif() - - if ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.27) AND (NOT (${DIRECTX_ARCH} MATCHES "^arm"))) - foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME}) - target_link_options(${t} PRIVATE /CETCOMPAT) - endforeach() - endif() - - if(BC_USE_OPENMP) - target_compile_options(${PROJECT_NAME} PRIVATE /openmp /Zc:twoPhase-) - if(BUILD_TOOLS AND WIN32 AND (NOT WINDOWS_STORE)) - target_compile_options(texconv PRIVATE /openmp /Zc:twoPhase-) - endif() - endif() - - set(WarningsEXE "/wd4061" "/wd4062" "/wd4365" "/wd4514" "/wd4625" "/wd4626" "/wd4627" "/wd4668" "/wd4710" "/wd4751" "/wd4820" "/wd5026" "/wd5027" "/wd5039" "/wd5045" "/wd5219") - foreach(t IN LISTS TOOL_EXES) - target_compile_options(${t} PRIVATE ${WarningsEXE}) - endforeach() -endif() - -if(WIN32) - foreach(t IN LISTS TOOL_EXES ITEMS ${PROJECT_NAME}) - target_compile_definitions(${t} PRIVATE _UNICODE UNICODE) - endforeach() - - if(WINDOWS_STORE) - target_compile_definitions(${PROJECT_NAME} PRIVATE WINAPI_FAMILY=WINAPI_FAMILY_APP) - endif() - - if(BUILD_DX12 OR WINDOWS_STORE) - if(BUILD_DX12) - message("INFO: Building with DirectX 12 Runtime support") - endif() - target_compile_definitions(${PROJECT_NAME} PRIVATE _WIN32_WINNT=0x0A00) - else() - message("INFO: Building with Windows 7 compatibility") - target_compile_definitions(${PROJECT_NAME} PRIVATE _WIN32_WINNT=0x0601 _WIN7_PLATFORM_UPDATE) - endif() - foreach(t IN LISTS TOOL_EXES) - target_compile_definitions(${t} PRIVATE _WIN32_WINNT=0x0601) - endforeach() -endif() - -if(BUILD_TOOLS AND WIN32 AND (NOT WINDOWS_STORE)) - set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT texconv) -endif() diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/CMakePresets.json b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/CMakePresets.json deleted file mode 100644 index 16e821e..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/CMakePresets.json +++ /dev/null @@ -1,175 +0,0 @@ -{ - "version": 2, - "configurePresets": [ - { - "name": "base", - "displayName": "Basic Config", - "description": "Basic build using Ninja generator", - "generator": "Ninja", - "hidden": true, - "binaryDir": "${sourceDir}/out/build/${presetName}", - "cacheVariables": { "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}" } - }, - - { - "name": "x64", - "architecture": { - "value": "x64", - "strategy": "external" - }, - "cacheVariables": { "DIRECTX_ARCH": "x64" }, - "hidden": true - }, - { - "name": "x86", - "architecture": { - "value": "x86", - "strategy": "external" - }, - "cacheVariables": { "DIRECTX_ARCH": "x86" }, - "hidden": true - }, - { - "name": "ARM", - "architecture": { - "value": "arm", - "strategy": "external" - }, - "cacheVariables": { "DIRECTX_ARCH": "arm" }, - "hidden": true - }, - { - "name": "ARM64", - "architecture": { - "value": "arm64", - "strategy": "external" - }, - "cacheVariables": { "DIRECTX_ARCH": "arm64" }, - "hidden": true - }, - - { - "name": "Debug", - "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" }, - "hidden": true - }, - { - "name": "Release", - "cacheVariables": { "CMAKE_BUILD_TYPE": "RelWithDebInfo" }, - "hidden": true - }, - - { - "name": "MSVC", - "hidden": true, - "cacheVariables": { - "CMAKE_CXX_COMPILER": "cl.exe" - }, - "toolset": { - "value": "host=x64", - "strategy": "external" - } - }, - { - "name": "Clang", - "hidden": true, - "cacheVariables": { - "CMAKE_CXX_COMPILER": "clang-cl.exe" - }, - "toolset": { - "value": "host=x64", - "strategy": "external" - } - }, - { - "name": "GNUC", - "hidden": true, - "cacheVariables": { - "CMAKE_CXX_COMPILER": "g++.exe" - }, - "toolset": { - "value": "host=x64", - "strategy": "external" - } - }, - - { - "name": "Win7", - "cacheVariables": { - "BUILD_DX12": false - }, - "hidden": true - }, - { - "name": "UWP", - "cacheVariables": { - "CMAKE_SYSTEM_NAME": "WindowsStore", - "CMAKE_SYSTEM_VERSION": "10.0", - "BUILD_DX12": true - }, - "hidden": true - }, - { - "name": "VCPKG", - "cacheVariables": { - "CMAKE_TOOLCHAIN_FILE": { - "value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", - "type": "FILEPATH" - } - }, - "hidden": true - }, - - { "name": "x64-Debug" , "description": "MSVC for x64 (Debug) with DX12", "inherits": [ "base", "x64", "Debug", "MSVC" ] }, - { "name": "x64-Release" , "description": "MSVC for x64 (Release) with DX12", "inherits": [ "base", "x64", "Release", "MSVC" ] }, - { "name": "x86-Debug" , "description": "MSVC for x86 (Debug) with DX12", "inherits": [ "base", "x86", "Debug", "MSVC" ] }, - { "name": "x86-Release" , "description": "MSVC for x86 (Release) with DX12", "inherits": [ "base", "x86", "Release", "MSVC" ] }, - { "name": "arm64-Debug" , "description": "MSVC for ARM64 (Debug) with DX12", "inherits": [ "base", "ARM64", "Debug", "MSVC" ] }, - { "name": "arm64-Release", "description": "MSVC for ARM64 (Release) with DX12", "inherits": [ "base", "ARM64", "Release", "MSVC" ] }, - - { "name": "x64-Debug-UWP" , "description": "MSVC for x64 (Debug) for UWP", "inherits": [ "base", "x64", "Debug", "MSVC", "UWP" ] }, - { "name": "x64-Release-UWP" , "description": "MSVC for x64 (Release) for UWP", "inherits": [ "base", "x64", "Release", "MSVC", "UWP" ] }, - { "name": "x86-Debug-UWP" , "description": "MSVC for x86 (Debug) for UWP", "inherits": [ "base", "x86", "Debug", "MSVC", "UWP" ] }, - { "name": "x86-Release-UWP" , "description": "MSVC for x86 (Release) for UWP", "inherits": [ "base", "x86", "Release", "MSVC", "UWP" ] }, - { "name": "arm-Debug-UWP" , "description": "MSVC for ARM (Debug) for UWP", "inherits": [ "base", "ARM", "Debug", "MSVC", "UWP" ] }, - { "name": "arm-Release-UWP" , "description": "MSVC for ARM (Release) for UWP", "inherits": [ "base", "ARM", "Release", "MSVC", "UWP" ] }, - { "name": "arm64-Debug-UWP" , "description": "MSVC for ARM64 (Debug) for UWP", "inherits": [ "base", "ARM64", "Debug", "MSVC", "UWP" ] }, - { "name": "arm64-Release-UWP", "description": "MSVC for ARM64 (Release) for UWP", "inherits": [ "base", "ARM64", "Release", "MSVC", "UWP" ] }, - - { "name": "x64-Debug-Win7" , "description": "MSVC for x64 (Debug) for Windows 7", "inherits": [ "base", "x64", "Debug", "MSVC", "Win7" ] }, - { "name": "x64-Release-Win7" , "description": "MSVC for x64 (Release) for Windows 7", "inherits": [ "base", "x64", "Release", "MSVC", "Win7" ] }, - { "name": "x86-Debug-Win7" , "description": "MSVC for x86 (Debug) for Windows 7", "inherits": [ "base", "x86", "Debug", "MSVC", "Win7" ] }, - { "name": "x86-Release-Win7" , "description": "MSVC for x86 (Release) for Windows 7", "inherits": [ "base", "x86", "Release", "MSVC", "Win7" ] }, - - { "name": "x64-Debug-VCPKG" , "description": "MSVC for x64 (Debug) using VCPKG", "inherits": [ "base", "x64", "Debug", "MSVC", "VCPKG" ] }, - { "name": "x64-Release-VCPKG" , "description": "MSVC for x64 (Release) using VCPKG", "inherits": [ "base", "x64", "Release", "MSVC", "VCPKG" ] }, - { "name": "x86-Debug-VCPKG" , "description": "MSVC for x86 (Debug) using VCPKG", "inherits": [ "base", "x86", "Debug", "MSVC", "VCPKG" ] }, - { "name": "x86-Release-VCPKG" , "description": "MSVC for x86 (Release) using VCPKG", "inherits": [ "base", "x86", "Release", "MSVC", "VCPKG" ] }, - { "name": "arm64-Debug-VCPKG" , "description": "MSVC for ARM64 (Debug) using VCPKG", "inherits": [ "base", "ARM64", "Debug", "MSVC", "VCPKG" ] }, - { "name": "arm64-Release-VCPKG", "description": "MSVC for ARM64 (Release) using VCPKG", "inherits": [ "base", "ARM64", "Release", "MSVC", "VCPKG" ] }, - - { "name": "x64-Debug-Clang" , "description": "Clang/LLVM for x64 (Debug) with DX12", "inherits": [ "base", "x64", "Debug", "Clang" ] }, - { "name": "x64-Release-Clang" , "description": "Clang/LLVM for x64 (Release) with DX12", "inherits": [ "base", "x64", "Release", "Clang" ] }, - { "name": "x86-Debug-Clang" , "description": "Clang/LLVM for x86 (Debug) with DX12", "inherits": [ "base", "x86", "Debug", "Clang" ], "environment": { "CXXFLAGS": "-m32" } }, - { "name": "x86-Release-Clang" , "description": "Clang/LLVM for x86 (Release) with DX12", "inherits": [ "base", "x86", "Release", "Clang" ], "environment": { "CXXFLAGS": "-m32" } }, - { "name": "arm64-Debug-Clang" , "description": "Clang/LLVM for AArch64 (Debug) with DX12", "inherits": [ "base", "ARM64", "Debug", "Clang" ], "environment": { "CXXFLAGS": "--target=arm64-pc-windows-msvc" } }, - { "name": "arm64-Release-Clang", "description": "Clang/LLVM for AArch64 (Release) with DX12", "inherits": [ "base", "ARM64", "Release", "Clang" ], "environment": { "CXXFLAGS": "--target=arm64-pc-windows-msvc" } }, - - { "name": "x64-Debug-UWP-Clang" , "description": "Clang/LLVM for x64 (Debug) for UWP", "inherits": [ "base", "x64", "Debug", "Clang", "UWP" ] }, - { "name": "x64-Release-UWP-Clang" , "description": "Clang/LLVM for x64 (Release) for UWP", "inherits": [ "base", "x64", "Release", "Clang", "UWP" ] }, - { "name": "x86-Debug-UWP-Clang" , "description": "Clang/LLVM for x86 (Debug) for UWP", "inherits": [ "base", "x86", "Debug", "Clang", "UWP" ], "environment": { "CXXFLAGS": "-m32" } }, - { "name": "x86-Release-UWP-Clang" , "description": "Clang/LLVM for x86 (Release) for UWP", "inherits": [ "base", "x86", "Release", "Clang", "UWP" ], "environment": { "CXXFLAGS": "-m32" } }, - { "name": "arm64-Debug-UWP-Clang" , "description": "Clang/LLVM for AArch64 (Debug) for UWP", "inherits": [ "base", "ARM64", "Debug", "Clang", "UWP" ], "environment": { "CXXFLAGS": "--target=arm64-pc-windows-msvc" } }, - { "name": "arm64-Release-UWP-Clang", "description": "Clang/LLVM for AArch64 (Release) for UWP", "inherits": [ "base", "ARM64", "Release", "Clang", "UWP" ], "environment": { "CXXFLAGS": "--target=arm64-pc-windows-msvc" } }, - - { "name": "x64-Debug-Win7-Clang" , "description": "Clang/LLVM for x64 (Debug) for Windows 7", "inherits": [ "base", "x64", "Debug", "Clang", "Win7" ] }, - { "name": "x64-Release-Win7-Clang", "description": "Clang/LLVM for x64 (Release) for Windows 7", "inherits": [ "base", "x64", "Release", "Clang", "Win7" ] }, - { "name": "x86-Debug-Win7-Clang" , "description": "Clang/LLVM for x86 (Debug) for Windows 7", "inherits": [ "base", "x86", "Debug", "Clang", "Win7" ], "environment": { "CXXFLAGS": "-m32" } }, - { "name": "x86-Release-Win7-Clang", "description": "Clang/LLVM for x86 (Release) for Windows 7", "inherits": [ "base", "x86", "Release", "Clang", "Win7" ], "environment": { "CXXFLAGS": "-m32" } }, - - { "name": "x64-Debug-MinGW" , "description": "MinG-W64 (Debug)", "inherits": [ "base", "x64", "Debug", "GNUC", "VCPKG" ], "environment": { "PATH": "$penv{PATH};c:/mingw64/bin" } }, - { "name": "x64-Release-MinGW", "description": "MinG-W64 (Release)", "inherits": [ "base", "x64", "Release", "GNUC", "VCPKG" ], "environment": { "PATH": "$penv{PATH};c:/mingw64/bin" } }, - { "name": "x86-Debug-MinGW" , "description": "MinG-W32 (Debug)", "inherits": [ "base", "x86", "Debug", "GNUC", "VCPKG" ], "environment": { "PATH": "$penv{PATH};c:/mingw32/bin" } }, - { "name": "x86-Release-MinGW", "description": "MinG-W32 (Release)", "inherits": [ "base", "x86", "Release", "GNUC", "VCPKG" ], "environment": { "PATH": "$penv{PATH};c:/mingw32/bin" } } - ] -} \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSTextureLoader/DDSTextureLoader11.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSTextureLoader/DDSTextureLoader11.cpp deleted file mode 100644 index 3bff94a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSTextureLoader/DDSTextureLoader11.cpp +++ /dev/null @@ -1,2004 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: DDSTextureLoader11.cpp -// -// Functions for loading a DDS texture and creating a Direct3D runtime resource for it -// -// Note these functions are useful as a light-weight runtime loader for DDS files. For -// a full-featured DDS file reader, writer, and texture processing pipeline see -// the 'Texconv' sample and the 'DirectXTex' library. -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -// http://go.microsoft.com/fwlink/?LinkId=248929 -//-------------------------------------------------------------------------------------- - -#include "DDSTextureLoader11.h" - -#include -#include -#include -#include - -#ifdef _MSC_VER -// Off by default warnings -#pragma warning(disable : 4619 4616 4061 4062 4623 4626 5027) -// C4619/4616 #pragma warning warnings -// C4061 enumerator 'x' in switch of enum 'y' is not explicitly handled by a case label -// C4062 enumerator 'x' in switch of enum 'y' is not handled -// C4623 default constructor was implicitly defined as deleted -// C4626 assignment operator was implicitly defined as deleted -// C5027 move assignment operator was implicitly defined as deleted -#endif - -#ifdef __clang__ -#pragma clang diagnostic ignored "-Wcovered-switch-default" -#pragma clang diagnostic ignored "-Wswitch-enum" -#endif - -using namespace DirectX; - -//-------------------------------------------------------------------------------------- -// Macros -//-------------------------------------------------------------------------------------- -#ifndef MAKEFOURCC -#define MAKEFOURCC(ch0, ch1, ch2, ch3) \ - ((uint32_t)(uint8_t)(ch0) | ((uint32_t)(uint8_t)(ch1) << 8) | \ - ((uint32_t)(uint8_t)(ch2) << 16) | ((uint32_t)(uint8_t)(ch3) << 24 )) -#endif /* defined(MAKEFOURCC) */ - -//-------------------------------------------------------------------------------------- -// DDS file structure definitions -// -// See DDS.h in the 'Texconv' sample and the 'DirectXTex' library -//-------------------------------------------------------------------------------------- -#pragma pack(push,1) - -constexpr uint32_t DDS_MAGIC = 0x20534444; // "DDS " - -struct DDS_PIXELFORMAT -{ - uint32_t size; - uint32_t flags; - uint32_t fourCC; - uint32_t RGBBitCount; - uint32_t RBitMask; - uint32_t GBitMask; - uint32_t BBitMask; - uint32_t ABitMask; -}; - -#define DDS_FOURCC 0x00000004 // DDPF_FOURCC -#define DDS_RGB 0x00000040 // DDPF_RGB -#define DDS_LUMINANCE 0x00020000 // DDPF_LUMINANCE -#define DDS_ALPHA 0x00000002 // DDPF_ALPHA -#define DDS_BUMPDUDV 0x00080000 // DDPF_BUMPDUDV - -#define DDS_HEADER_FLAGS_VOLUME 0x00800000 // DDSD_DEPTH - -#define DDS_HEIGHT 0x00000002 // DDSD_HEIGHT - -#define DDS_CUBEMAP_POSITIVEX 0x00000600 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEX -#define DDS_CUBEMAP_NEGATIVEX 0x00000a00 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEX -#define DDS_CUBEMAP_POSITIVEY 0x00001200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEY -#define DDS_CUBEMAP_NEGATIVEY 0x00002200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEY -#define DDS_CUBEMAP_POSITIVEZ 0x00004200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEZ -#define DDS_CUBEMAP_NEGATIVEZ 0x00008200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEZ - -#define DDS_CUBEMAP_ALLFACES ( DDS_CUBEMAP_POSITIVEX | DDS_CUBEMAP_NEGATIVEX |\ - DDS_CUBEMAP_POSITIVEY | DDS_CUBEMAP_NEGATIVEY |\ - DDS_CUBEMAP_POSITIVEZ | DDS_CUBEMAP_NEGATIVEZ ) - -#define DDS_CUBEMAP 0x00000200 // DDSCAPS2_CUBEMAP - -enum DDS_MISC_FLAGS2 -{ - DDS_MISC_FLAGS2_ALPHA_MODE_MASK = 0x7L, -}; - -struct DDS_HEADER -{ - uint32_t size; - uint32_t flags; - uint32_t height; - uint32_t width; - uint32_t pitchOrLinearSize; - uint32_t depth; // only if DDS_HEADER_FLAGS_VOLUME is set in flags - uint32_t mipMapCount; - uint32_t reserved1[11]; - DDS_PIXELFORMAT ddspf; - uint32_t caps; - uint32_t caps2; - uint32_t caps3; - uint32_t caps4; - uint32_t reserved2; -}; - -struct DDS_HEADER_DXT10 -{ - DXGI_FORMAT dxgiFormat; - uint32_t resourceDimension; - uint32_t miscFlag; // see D3D11_RESOURCE_MISC_FLAG - uint32_t arraySize; - uint32_t miscFlags2; -}; - -#pragma pack(pop) - -//-------------------------------------------------------------------------------------- -namespace -{ - struct handle_closer { void operator()(HANDLE h) noexcept { if (h) CloseHandle(h); } }; - - using ScopedHandle = std::unique_ptr; - - inline HANDLE safe_handle(HANDLE h) noexcept { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; } - - #if defined(_DEBUG) || defined(PROFILE) - template - inline void SetDebugObjectName(_In_ ID3D11DeviceChild* resource, _In_ const char(&name)[TNameLength]) noexcept - { - resource->SetPrivateData(WKPDID_D3DDebugObjectName, TNameLength - 1, name); - } - #else - template - inline void SetDebugObjectName(_In_ ID3D11DeviceChild*, _In_ const char(&)[TNameLength]) noexcept - { - } - #endif - - //-------------------------------------------------------------------------------------- - HRESULT LoadTextureDataFromMemory( - _In_reads_(ddsDataSize) const uint8_t* ddsData, - size_t ddsDataSize, - const DDS_HEADER** header, - const uint8_t** bitData, - size_t* bitSize) noexcept - { - if (!header || !bitData || !bitSize) - { - return E_POINTER; - } - - *bitSize = 0; - - if (ddsDataSize > UINT32_MAX) - { - return E_FAIL; - } - - if (ddsDataSize < (sizeof(uint32_t) + sizeof(DDS_HEADER))) - { - return E_FAIL; - } - - // DDS files always start with the same magic number ("DDS ") - auto const dwMagicNumber = *reinterpret_cast(ddsData); - if (dwMagicNumber != DDS_MAGIC) - { - return E_FAIL; - } - - auto hdr = reinterpret_cast(ddsData + sizeof(uint32_t)); - - // Verify header to validate DDS file - if (hdr->size != sizeof(DDS_HEADER) || - hdr->ddspf.size != sizeof(DDS_PIXELFORMAT)) - { - return E_FAIL; - } - - // Check for DX10 extension - bool bDXT10Header = false; - if ((hdr->ddspf.flags & DDS_FOURCC) && - (MAKEFOURCC('D', 'X', '1', '0') == hdr->ddspf.fourCC)) - { - // Must be long enough for both headers and magic value - if (ddsDataSize < (sizeof(uint32_t) + sizeof(DDS_HEADER) + sizeof(DDS_HEADER_DXT10))) - { - return E_FAIL; - } - - bDXT10Header = true; - } - - // setup the pointers in the process request - *header = hdr; - auto offset = sizeof(uint32_t) - + sizeof(DDS_HEADER) - + (bDXT10Header ? sizeof(DDS_HEADER_DXT10) : 0); - *bitData = ddsData + offset; - *bitSize = ddsDataSize - offset; - - return S_OK; - } - - - //-------------------------------------------------------------------------------------- - HRESULT LoadTextureDataFromFile( - _In_z_ const wchar_t* fileName, - std::unique_ptr& ddsData, - const DDS_HEADER** header, - const uint8_t** bitData, - size_t* bitSize) noexcept - { - if (!header || !bitData || !bitSize) - { - return E_POINTER; - } - - *bitSize = 0; - - // open the file - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(fileName, - GENERIC_READ, - FILE_SHARE_READ, - OPEN_EXISTING, - nullptr))); - #else - ScopedHandle hFile(safe_handle(CreateFileW(fileName, - GENERIC_READ, - FILE_SHARE_READ, - nullptr, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - nullptr))); - #endif - - if (!hFile) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - // Get the file size - FILE_STANDARD_INFO fileInfo; - if (!GetFileInformationByHandleEx(hFile.get(), FileStandardInfo, &fileInfo, sizeof(fileInfo))) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - // File is too big for 32-bit allocation, so reject read - if (fileInfo.EndOfFile.HighPart > 0) - { - return E_FAIL; - } - - // Need at least enough data to fill the header and magic number to be a valid DDS - if (fileInfo.EndOfFile.LowPart < (sizeof(uint32_t) + sizeof(DDS_HEADER))) - { - return E_FAIL; - } - - // create enough space for the file data - ddsData.reset(new (std::nothrow) uint8_t[fileInfo.EndOfFile.LowPart]); - if (!ddsData) - { - return E_OUTOFMEMORY; - } - - // read the data in - DWORD bytesRead = 0; - if (!ReadFile(hFile.get(), - ddsData.get(), - fileInfo.EndOfFile.LowPart, - &bytesRead, - nullptr - )) - { - ddsData.reset(); - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesRead < fileInfo.EndOfFile.LowPart) - { - ddsData.reset(); - return E_FAIL; - } - - // DDS files always start with the same magic number ("DDS ") - auto const dwMagicNumber = *reinterpret_cast(ddsData.get()); - if (dwMagicNumber != DDS_MAGIC) - { - ddsData.reset(); - return E_FAIL; - } - - auto hdr = reinterpret_cast(ddsData.get() + sizeof(uint32_t)); - - // Verify header to validate DDS file - if (hdr->size != sizeof(DDS_HEADER) || - hdr->ddspf.size != sizeof(DDS_PIXELFORMAT)) - { - ddsData.reset(); - return E_FAIL; - } - - // Check for DX10 extension - bool bDXT10Header = false; - if ((hdr->ddspf.flags & DDS_FOURCC) && - (MAKEFOURCC('D', 'X', '1', '0') == hdr->ddspf.fourCC)) - { - // Must be long enough for both headers and magic value - if (fileInfo.EndOfFile.LowPart < (sizeof(uint32_t) + sizeof(DDS_HEADER) + sizeof(DDS_HEADER_DXT10))) - { - ddsData.reset(); - return E_FAIL; - } - - bDXT10Header = true; - } - - // setup the pointers in the process request - *header = hdr; - auto offset = sizeof(uint32_t) + sizeof(DDS_HEADER) - + (bDXT10Header ? sizeof(DDS_HEADER_DXT10) : 0); - *bitData = ddsData.get() + offset; - *bitSize = fileInfo.EndOfFile.LowPart - offset; - - return S_OK; - } - - - //-------------------------------------------------------------------------------------- - // Return the BPP for a particular format - //-------------------------------------------------------------------------------------- - size_t BitsPerPixel(_In_ DXGI_FORMAT fmt) noexcept - { - switch (fmt) - { - case DXGI_FORMAT_R32G32B32A32_TYPELESS: - case DXGI_FORMAT_R32G32B32A32_FLOAT: - case DXGI_FORMAT_R32G32B32A32_UINT: - case DXGI_FORMAT_R32G32B32A32_SINT: - return 128; - - case DXGI_FORMAT_R32G32B32_TYPELESS: - case DXGI_FORMAT_R32G32B32_FLOAT: - case DXGI_FORMAT_R32G32B32_UINT: - case DXGI_FORMAT_R32G32B32_SINT: - return 96; - - case DXGI_FORMAT_R16G16B16A16_TYPELESS: - case DXGI_FORMAT_R16G16B16A16_FLOAT: - case DXGI_FORMAT_R16G16B16A16_UNORM: - case DXGI_FORMAT_R16G16B16A16_UINT: - case DXGI_FORMAT_R16G16B16A16_SNORM: - case DXGI_FORMAT_R16G16B16A16_SINT: - case DXGI_FORMAT_R32G32_TYPELESS: - case DXGI_FORMAT_R32G32_FLOAT: - case DXGI_FORMAT_R32G32_UINT: - case DXGI_FORMAT_R32G32_SINT: - case DXGI_FORMAT_R32G8X24_TYPELESS: - case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: - case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: - case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: - case DXGI_FORMAT_Y416: - case DXGI_FORMAT_Y210: - case DXGI_FORMAT_Y216: - return 64; - - case DXGI_FORMAT_R10G10B10A2_TYPELESS: - case DXGI_FORMAT_R10G10B10A2_UNORM: - case DXGI_FORMAT_R10G10B10A2_UINT: - case DXGI_FORMAT_R11G11B10_FLOAT: - case DXGI_FORMAT_R8G8B8A8_TYPELESS: - case DXGI_FORMAT_R8G8B8A8_UNORM: - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - case DXGI_FORMAT_R8G8B8A8_UINT: - case DXGI_FORMAT_R8G8B8A8_SNORM: - case DXGI_FORMAT_R8G8B8A8_SINT: - case DXGI_FORMAT_R16G16_TYPELESS: - case DXGI_FORMAT_R16G16_FLOAT: - case DXGI_FORMAT_R16G16_UNORM: - case DXGI_FORMAT_R16G16_UINT: - case DXGI_FORMAT_R16G16_SNORM: - case DXGI_FORMAT_R16G16_SINT: - case DXGI_FORMAT_R32_TYPELESS: - case DXGI_FORMAT_D32_FLOAT: - case DXGI_FORMAT_R32_FLOAT: - case DXGI_FORMAT_R32_UINT: - case DXGI_FORMAT_R32_SINT: - case DXGI_FORMAT_R24G8_TYPELESS: - case DXGI_FORMAT_D24_UNORM_S8_UINT: - case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: - case DXGI_FORMAT_X24_TYPELESS_G8_UINT: - case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: - case DXGI_FORMAT_R8G8_B8G8_UNORM: - case DXGI_FORMAT_G8R8_G8B8_UNORM: - case DXGI_FORMAT_B8G8R8A8_UNORM: - case DXGI_FORMAT_B8G8R8X8_UNORM: - case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: - case DXGI_FORMAT_B8G8R8A8_TYPELESS: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8X8_TYPELESS: - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - case DXGI_FORMAT_AYUV: - case DXGI_FORMAT_Y410: - case DXGI_FORMAT_YUY2: - return 32; - - case DXGI_FORMAT_P010: - case DXGI_FORMAT_P016: - return 24; - - case DXGI_FORMAT_R8G8_TYPELESS: - case DXGI_FORMAT_R8G8_UNORM: - case DXGI_FORMAT_R8G8_UINT: - case DXGI_FORMAT_R8G8_SNORM: - case DXGI_FORMAT_R8G8_SINT: - case DXGI_FORMAT_R16_TYPELESS: - case DXGI_FORMAT_R16_FLOAT: - case DXGI_FORMAT_D16_UNORM: - case DXGI_FORMAT_R16_UNORM: - case DXGI_FORMAT_R16_UINT: - case DXGI_FORMAT_R16_SNORM: - case DXGI_FORMAT_R16_SINT: - case DXGI_FORMAT_B5G6R5_UNORM: - case DXGI_FORMAT_B5G5R5A1_UNORM: - case DXGI_FORMAT_A8P8: - case DXGI_FORMAT_B4G4R4A4_UNORM: - return 16; - - case DXGI_FORMAT_NV12: - case DXGI_FORMAT_420_OPAQUE: - case DXGI_FORMAT_NV11: - return 12; - - case DXGI_FORMAT_R8_TYPELESS: - case DXGI_FORMAT_R8_UNORM: - case DXGI_FORMAT_R8_UINT: - case DXGI_FORMAT_R8_SNORM: - case DXGI_FORMAT_R8_SINT: - case DXGI_FORMAT_A8_UNORM: - case DXGI_FORMAT_BC2_TYPELESS: - case DXGI_FORMAT_BC2_UNORM: - case DXGI_FORMAT_BC2_UNORM_SRGB: - case DXGI_FORMAT_BC3_TYPELESS: - case DXGI_FORMAT_BC3_UNORM: - case DXGI_FORMAT_BC3_UNORM_SRGB: - case DXGI_FORMAT_BC5_TYPELESS: - case DXGI_FORMAT_BC5_UNORM: - case DXGI_FORMAT_BC5_SNORM: - case DXGI_FORMAT_BC6H_TYPELESS: - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - case DXGI_FORMAT_BC7_TYPELESS: - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: - case DXGI_FORMAT_AI44: - case DXGI_FORMAT_IA44: - case DXGI_FORMAT_P8: - return 8; - - case DXGI_FORMAT_R1_UNORM: - return 1; - - case DXGI_FORMAT_BC1_TYPELESS: - case DXGI_FORMAT_BC1_UNORM: - case DXGI_FORMAT_BC1_UNORM_SRGB: - case DXGI_FORMAT_BC4_TYPELESS: - case DXGI_FORMAT_BC4_UNORM: - case DXGI_FORMAT_BC4_SNORM: - return 4; - - default: - return 0; - } - } - - - //-------------------------------------------------------------------------------------- - // Get surface information for a particular format - //-------------------------------------------------------------------------------------- - HRESULT GetSurfaceInfo( - _In_ size_t width, - _In_ size_t height, - _In_ DXGI_FORMAT fmt, - size_t* outNumBytes, - _Out_opt_ size_t* outRowBytes, - _Out_opt_ size_t* outNumRows) noexcept - { - uint64_t numBytes = 0; - uint64_t rowBytes = 0; - uint64_t numRows = 0; - - bool bc = false; - bool packed = false; - bool planar = false; - size_t bpe = 0; - switch (fmt) - { - case DXGI_FORMAT_BC1_TYPELESS: - case DXGI_FORMAT_BC1_UNORM: - case DXGI_FORMAT_BC1_UNORM_SRGB: - case DXGI_FORMAT_BC4_TYPELESS: - case DXGI_FORMAT_BC4_UNORM: - case DXGI_FORMAT_BC4_SNORM: - bc = true; - bpe = 8; - break; - - case DXGI_FORMAT_BC2_TYPELESS: - case DXGI_FORMAT_BC2_UNORM: - case DXGI_FORMAT_BC2_UNORM_SRGB: - case DXGI_FORMAT_BC3_TYPELESS: - case DXGI_FORMAT_BC3_UNORM: - case DXGI_FORMAT_BC3_UNORM_SRGB: - case DXGI_FORMAT_BC5_TYPELESS: - case DXGI_FORMAT_BC5_UNORM: - case DXGI_FORMAT_BC5_SNORM: - case DXGI_FORMAT_BC6H_TYPELESS: - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - case DXGI_FORMAT_BC7_TYPELESS: - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: - bc = true; - bpe = 16; - break; - - case DXGI_FORMAT_R8G8_B8G8_UNORM: - case DXGI_FORMAT_G8R8_G8B8_UNORM: - case DXGI_FORMAT_YUY2: - packed = true; - bpe = 4; - break; - - case DXGI_FORMAT_Y210: - case DXGI_FORMAT_Y216: - packed = true; - bpe = 8; - break; - - case DXGI_FORMAT_NV12: - case DXGI_FORMAT_420_OPAQUE: - planar = true; - bpe = 2; - break; - - case DXGI_FORMAT_P010: - case DXGI_FORMAT_P016: - planar = true; - bpe = 4; - break; - - default: - break; - } - - if (bc) - { - uint64_t numBlocksWide = 0; - if (width > 0) - { - numBlocksWide = std::max(1u, (uint64_t(width) + 3u) / 4u); - } - uint64_t numBlocksHigh = 0; - if (height > 0) - { - numBlocksHigh = std::max(1u, (uint64_t(height) + 3u) / 4u); - } - rowBytes = numBlocksWide * bpe; - numRows = numBlocksHigh; - numBytes = rowBytes * numBlocksHigh; - } - else if (packed) - { - rowBytes = ((uint64_t(width) + 1u) >> 1) * bpe; - numRows = uint64_t(height); - numBytes = rowBytes * height; - } - else if (fmt == DXGI_FORMAT_NV11) - { - rowBytes = ((uint64_t(width) + 3u) >> 2) * 4u; - numRows = uint64_t(height) * 2u; // Direct3D makes this simplifying assumption, although it is larger than the 4:1:1 data - numBytes = rowBytes * numRows; - } - else if (planar) - { - rowBytes = ((uint64_t(width) + 1u) >> 1) * bpe; - numBytes = (rowBytes * uint64_t(height)) + ((rowBytes * uint64_t(height) + 1u) >> 1); - numRows = height + ((uint64_t(height) + 1u) >> 1); - } - else - { - const size_t bpp = BitsPerPixel(fmt); - if (!bpp) - return E_INVALIDARG; - - rowBytes = (uint64_t(width) * bpp + 7u) / 8u; // round up to nearest byte - numRows = uint64_t(height); - numBytes = rowBytes * height; - } - - #if defined(_M_IX86) || defined(_M_ARM) || defined(_M_HYBRID_X86_ARM64) - static_assert(sizeof(size_t) == 4, "Not a 32-bit platform!"); - if (numBytes > UINT32_MAX || rowBytes > UINT32_MAX || numRows > UINT32_MAX) - return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); - #else - static_assert(sizeof(size_t) == 8, "Not a 64-bit platform!"); - #endif - - if (outNumBytes) - { - *outNumBytes = static_cast(numBytes); - } - if (outRowBytes) - { - *outRowBytes = static_cast(rowBytes); - } - if (outNumRows) - { - *outNumRows = static_cast(numRows); - } - - return S_OK; - } - - - //-------------------------------------------------------------------------------------- -#define ISBITMASK( r,g,b,a ) ( ddpf.RBitMask == r && ddpf.GBitMask == g && ddpf.BBitMask == b && ddpf.ABitMask == a ) - - DXGI_FORMAT GetDXGIFormat(const DDS_PIXELFORMAT& ddpf) noexcept - { - if (ddpf.flags & DDS_RGB) - { - // Note that sRGB formats are written using the "DX10" extended header - - switch (ddpf.RGBBitCount) - { - case 32: - if (ISBITMASK(0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000)) - { - return DXGI_FORMAT_R8G8B8A8_UNORM; - } - - if (ISBITMASK(0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000)) - { - return DXGI_FORMAT_B8G8R8A8_UNORM; - } - - if (ISBITMASK(0x00ff0000, 0x0000ff00, 0x000000ff, 0)) - { - return DXGI_FORMAT_B8G8R8X8_UNORM; - } - - // No DXGI format maps to ISBITMASK(0x000000ff,0x0000ff00,0x00ff0000,0) aka D3DFMT_X8B8G8R8 - - // Note that many common DDS reader/writers (including D3DX) swap the - // the RED/BLUE masks for 10:10:10:2 formats. We assume - // below that the 'backwards' header mask is being used since it is most - // likely written by D3DX. The more robust solution is to use the 'DX10' - // header extension and specify the DXGI_FORMAT_R10G10B10A2_UNORM format directly - - // For 'correct' writers, this should be 0x000003ff,0x000ffc00,0x3ff00000 for RGB data - if (ISBITMASK(0x3ff00000, 0x000ffc00, 0x000003ff, 0xc0000000)) - { - return DXGI_FORMAT_R10G10B10A2_UNORM; - } - - // No DXGI format maps to ISBITMASK(0x000003ff,0x000ffc00,0x3ff00000,0xc0000000) aka D3DFMT_A2R10G10B10 - - if (ISBITMASK(0x0000ffff, 0xffff0000, 0, 0)) - { - return DXGI_FORMAT_R16G16_UNORM; - } - - if (ISBITMASK(0xffffffff, 0, 0, 0)) - { - // Only 32-bit color channel format in D3D9 was R32F - return DXGI_FORMAT_R32_FLOAT; // D3DX writes this out as a FourCC of 114 - } - break; - - case 24: - // No 24bpp DXGI formats aka D3DFMT_R8G8B8 - break; - - case 16: - if (ISBITMASK(0x7c00, 0x03e0, 0x001f, 0x8000)) - { - return DXGI_FORMAT_B5G5R5A1_UNORM; - } - if (ISBITMASK(0xf800, 0x07e0, 0x001f, 0)) - { - return DXGI_FORMAT_B5G6R5_UNORM; - } - - // No DXGI format maps to ISBITMASK(0x7c00,0x03e0,0x001f,0) aka D3DFMT_X1R5G5B5 - - if (ISBITMASK(0x0f00, 0x00f0, 0x000f, 0xf000)) - { - return DXGI_FORMAT_B4G4R4A4_UNORM; - } - - // NVTT versions 1.x wrote this as RGB instead of LUMINANCE - if (ISBITMASK(0x00ff, 0, 0, 0xff00)) - { - return DXGI_FORMAT_R8G8_UNORM; - } - if (ISBITMASK(0xffff, 0, 0, 0)) - { - return DXGI_FORMAT_R16_UNORM; - } - - // No DXGI format maps to ISBITMASK(0x0f00,0x00f0,0x000f,0) aka D3DFMT_X4R4G4B4 - - // No 3:3:2:8 or paletted DXGI formats aka D3DFMT_A8R3G3B2, D3DFMT_A8P8, etc. - break; - - case 8: - // NVTT versions 1.x wrote this as RGB instead of LUMINANCE - if (ISBITMASK(0xff, 0, 0, 0)) - { - return DXGI_FORMAT_R8_UNORM; - } - - // No 3:3:2 or paletted DXGI formats aka D3DFMT_R3G3B2, D3DFMT_P8 - break; - } - } - else if (ddpf.flags & DDS_LUMINANCE) - { - switch (ddpf.RGBBitCount) - { - case 16: - if (ISBITMASK(0xffff, 0, 0, 0)) - { - return DXGI_FORMAT_R16_UNORM; // D3DX10/11 writes this out as DX10 extension - } - if (ISBITMASK(0x00ff, 0, 0, 0xff00)) - { - return DXGI_FORMAT_R8G8_UNORM; // D3DX10/11 writes this out as DX10 extension - } - break; - - case 8: - if (ISBITMASK(0xff, 0, 0, 0)) - { - return DXGI_FORMAT_R8_UNORM; // D3DX10/11 writes this out as DX10 extension - } - - // No DXGI format maps to ISBITMASK(0x0f,0,0,0xf0) aka D3DFMT_A4L4 - - if (ISBITMASK(0x00ff, 0, 0, 0xff00)) - { - return DXGI_FORMAT_R8G8_UNORM; // Some DDS writers assume the bitcount should be 8 instead of 16 - } - break; - } - } - else if (ddpf.flags & DDS_ALPHA) - { - if (8 == ddpf.RGBBitCount) - { - return DXGI_FORMAT_A8_UNORM; - } - } - else if (ddpf.flags & DDS_BUMPDUDV) - { - switch (ddpf.RGBBitCount) - { - case 32: - if (ISBITMASK(0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000)) - { - return DXGI_FORMAT_R8G8B8A8_SNORM; // D3DX10/11 writes this out as DX10 extension - } - if (ISBITMASK(0x0000ffff, 0xffff0000, 0, 0)) - { - return DXGI_FORMAT_R16G16_SNORM; // D3DX10/11 writes this out as DX10 extension - } - - // No DXGI format maps to ISBITMASK(0x3ff00000, 0x000ffc00, 0x000003ff, 0xc0000000) aka D3DFMT_A2W10V10U10 - break; - - case 16: - if (ISBITMASK(0x00ff, 0xff00, 0, 0)) - { - return DXGI_FORMAT_R8G8_SNORM; // D3DX10/11 writes this out as DX10 extension - } - break; - } - - // No DXGI format maps to DDPF_BUMPLUMINANCE aka D3DFMT_L6V5U5, D3DFMT_X8L8V8U8 - } - else if (ddpf.flags & DDS_FOURCC) - { - if (MAKEFOURCC('D', 'X', 'T', '1') == ddpf.fourCC) - { - return DXGI_FORMAT_BC1_UNORM; - } - if (MAKEFOURCC('D', 'X', 'T', '3') == ddpf.fourCC) - { - return DXGI_FORMAT_BC2_UNORM; - } - if (MAKEFOURCC('D', 'X', 'T', '5') == ddpf.fourCC) - { - return DXGI_FORMAT_BC3_UNORM; - } - - // While pre-multiplied alpha isn't directly supported by the DXGI formats, - // they are basically the same as these BC formats so they can be mapped - if (MAKEFOURCC('D', 'X', 'T', '2') == ddpf.fourCC) - { - return DXGI_FORMAT_BC2_UNORM; - } - if (MAKEFOURCC('D', 'X', 'T', '4') == ddpf.fourCC) - { - return DXGI_FORMAT_BC3_UNORM; - } - - if (MAKEFOURCC('A', 'T', 'I', '1') == ddpf.fourCC) - { - return DXGI_FORMAT_BC4_UNORM; - } - if (MAKEFOURCC('B', 'C', '4', 'U') == ddpf.fourCC) - { - return DXGI_FORMAT_BC4_UNORM; - } - if (MAKEFOURCC('B', 'C', '4', 'S') == ddpf.fourCC) - { - return DXGI_FORMAT_BC4_SNORM; - } - - if (MAKEFOURCC('A', 'T', 'I', '2') == ddpf.fourCC) - { - return DXGI_FORMAT_BC5_UNORM; - } - if (MAKEFOURCC('B', 'C', '5', 'U') == ddpf.fourCC) - { - return DXGI_FORMAT_BC5_UNORM; - } - if (MAKEFOURCC('B', 'C', '5', 'S') == ddpf.fourCC) - { - return DXGI_FORMAT_BC5_SNORM; - } - - // BC6H and BC7 are written using the "DX10" extended header - - if (MAKEFOURCC('R', 'G', 'B', 'G') == ddpf.fourCC) - { - return DXGI_FORMAT_R8G8_B8G8_UNORM; - } - if (MAKEFOURCC('G', 'R', 'G', 'B') == ddpf.fourCC) - { - return DXGI_FORMAT_G8R8_G8B8_UNORM; - } - - if (MAKEFOURCC('Y', 'U', 'Y', '2') == ddpf.fourCC) - { - return DXGI_FORMAT_YUY2; - } - - // Check for D3DFORMAT enums being set here - switch (ddpf.fourCC) - { - case 36: // D3DFMT_A16B16G16R16 - return DXGI_FORMAT_R16G16B16A16_UNORM; - - case 110: // D3DFMT_Q16W16V16U16 - return DXGI_FORMAT_R16G16B16A16_SNORM; - - case 111: // D3DFMT_R16F - return DXGI_FORMAT_R16_FLOAT; - - case 112: // D3DFMT_G16R16F - return DXGI_FORMAT_R16G16_FLOAT; - - case 113: // D3DFMT_A16B16G16R16F - return DXGI_FORMAT_R16G16B16A16_FLOAT; - - case 114: // D3DFMT_R32F - return DXGI_FORMAT_R32_FLOAT; - - case 115: // D3DFMT_G32R32F - return DXGI_FORMAT_R32G32_FLOAT; - - case 116: // D3DFMT_A32B32G32R32F - return DXGI_FORMAT_R32G32B32A32_FLOAT; - - // No DXGI format maps to D3DFMT_CxV8U8 - } - } - - return DXGI_FORMAT_UNKNOWN; - } - -#undef ISBITMASK - - -//-------------------------------------------------------------------------------------- - DXGI_FORMAT MakeSRGB(_In_ DXGI_FORMAT format) noexcept - { - switch (format) - { - case DXGI_FORMAT_R8G8B8A8_UNORM: - return DXGI_FORMAT_R8G8B8A8_UNORM_SRGB; - - case DXGI_FORMAT_BC1_UNORM: - return DXGI_FORMAT_BC1_UNORM_SRGB; - - case DXGI_FORMAT_BC2_UNORM: - return DXGI_FORMAT_BC2_UNORM_SRGB; - - case DXGI_FORMAT_BC3_UNORM: - return DXGI_FORMAT_BC3_UNORM_SRGB; - - case DXGI_FORMAT_B8G8R8A8_UNORM: - return DXGI_FORMAT_B8G8R8A8_UNORM_SRGB; - - case DXGI_FORMAT_B8G8R8X8_UNORM: - return DXGI_FORMAT_B8G8R8X8_UNORM_SRGB; - - case DXGI_FORMAT_BC7_UNORM: - return DXGI_FORMAT_BC7_UNORM_SRGB; - - default: - return format; - } - } - - - //-------------------------------------------------------------------------------------- - HRESULT FillInitData( - _In_ size_t width, - _In_ size_t height, - _In_ size_t depth, - _In_ size_t mipCount, - _In_ size_t arraySize, - _In_ DXGI_FORMAT format, - _In_ size_t maxsize, - _In_ size_t bitSize, - _In_reads_bytes_(bitSize) const uint8_t* bitData, - _Out_ size_t& twidth, - _Out_ size_t& theight, - _Out_ size_t& tdepth, - _Out_ size_t& skipMip, - _Out_writes_(mipCount*arraySize) D3D11_SUBRESOURCE_DATA* initData) noexcept - { - if (!bitData || !initData) - { - return E_POINTER; - } - - skipMip = 0; - twidth = 0; - theight = 0; - tdepth = 0; - - size_t NumBytes = 0; - size_t RowBytes = 0; - const uint8_t* pSrcBits = bitData; - const uint8_t* pEndBits = bitData + bitSize; - - size_t index = 0; - for (size_t j = 0; j < arraySize; j++) - { - size_t w = width; - size_t h = height; - size_t d = depth; - for (size_t i = 0; i < mipCount; i++) - { - HRESULT hr = GetSurfaceInfo(w, h, format, &NumBytes, &RowBytes, nullptr); - if (FAILED(hr)) - return hr; - - if (NumBytes > UINT32_MAX || RowBytes > UINT32_MAX) - return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); - - if ((mipCount <= 1) || !maxsize || (w <= maxsize && h <= maxsize && d <= maxsize)) - { - if (!twidth) - { - twidth = w; - theight = h; - tdepth = d; - } - - assert(index < mipCount * arraySize); - _Analysis_assume_(index < mipCount * arraySize); - initData[index].pSysMem = pSrcBits; - initData[index].SysMemPitch = static_cast(RowBytes); - initData[index].SysMemSlicePitch = static_cast(NumBytes); - ++index; - } - else if (!j) - { - // Count number of skipped mipmaps (first item only) - ++skipMip; - } - - if (pSrcBits + (NumBytes*d) > pEndBits) - { - return HRESULT_FROM_WIN32(ERROR_HANDLE_EOF); - } - - pSrcBits += NumBytes * d; - - w = w >> 1; - h = h >> 1; - d = d >> 1; - if (w == 0) - { - w = 1; - } - if (h == 0) - { - h = 1; - } - if (d == 0) - { - d = 1; - } - } - } - - return (index > 0) ? S_OK : E_FAIL; - } - - - //-------------------------------------------------------------------------------------- - HRESULT CreateD3DResources( - _In_ ID3D11Device* d3dDevice, - _In_ uint32_t resDim, - _In_ size_t width, - _In_ size_t height, - _In_ size_t depth, - _In_ size_t mipCount, - _In_ size_t arraySize, - _In_ DXGI_FORMAT format, - _In_ D3D11_USAGE usage, - _In_ unsigned int bindFlags, - _In_ unsigned int cpuAccessFlags, - _In_ unsigned int miscFlags, - _In_ bool forceSRGB, - _In_ bool isCubeMap, - _In_reads_opt_(mipCount*arraySize) const D3D11_SUBRESOURCE_DATA* initData, - _Outptr_opt_ ID3D11Resource** texture, - _Outptr_opt_ ID3D11ShaderResourceView** textureView) noexcept - { - if (!d3dDevice) - return E_POINTER; - - HRESULT hr = E_FAIL; - - if (forceSRGB) - { - format = MakeSRGB(format); - } - - switch (resDim) - { - case D3D11_RESOURCE_DIMENSION_TEXTURE1D: - { - D3D11_TEXTURE1D_DESC desc; - desc.Width = static_cast(width); - desc.MipLevels = static_cast(mipCount); - desc.ArraySize = static_cast(arraySize); - desc.Format = format; - desc.Usage = usage; - desc.BindFlags = bindFlags; - desc.CPUAccessFlags = cpuAccessFlags; - desc.MiscFlags = miscFlags & ~static_cast(D3D11_RESOURCE_MISC_TEXTURECUBE); - - ID3D11Texture1D* tex = nullptr; - hr = d3dDevice->CreateTexture1D(&desc, - initData, - &tex - ); - if (SUCCEEDED(hr) && tex) - { - if (textureView) - { - D3D11_SHADER_RESOURCE_VIEW_DESC SRVDesc = {}; - SRVDesc.Format = format; - - if (arraySize > 1) - { - SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1DARRAY; - SRVDesc.Texture1DArray.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels; - SRVDesc.Texture1DArray.ArraySize = static_cast(arraySize); - } - else - { - SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1D; - SRVDesc.Texture1D.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels; - } - - hr = d3dDevice->CreateShaderResourceView(tex, - &SRVDesc, - textureView - ); - if (FAILED(hr)) - { - tex->Release(); - return hr; - } - } - - if (texture) - { - *texture = tex; - } - else - { - SetDebugObjectName(tex, "DDSTextureLoader"); - tex->Release(); - } - } - } - break; - - case D3D11_RESOURCE_DIMENSION_TEXTURE2D: - { - D3D11_TEXTURE2D_DESC desc; - desc.Width = static_cast(width); - desc.Height = static_cast(height); - desc.MipLevels = static_cast(mipCount); - desc.ArraySize = static_cast(arraySize); - desc.Format = format; - desc.SampleDesc.Count = 1; - desc.SampleDesc.Quality = 0; - desc.Usage = usage; - desc.BindFlags = bindFlags; - desc.CPUAccessFlags = cpuAccessFlags; - if (isCubeMap) - { - desc.MiscFlags = miscFlags | D3D11_RESOURCE_MISC_TEXTURECUBE; - } - else - { - desc.MiscFlags = miscFlags & ~static_cast(D3D11_RESOURCE_MISC_TEXTURECUBE); - } - - ID3D11Texture2D* tex = nullptr; - hr = d3dDevice->CreateTexture2D(&desc, - initData, - &tex - ); - if (SUCCEEDED(hr) && tex) - { - if (textureView) - { - D3D11_SHADER_RESOURCE_VIEW_DESC SRVDesc = {}; - SRVDesc.Format = format; - - if (isCubeMap) - { - if (arraySize > 6) - { - SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBEARRAY; - SRVDesc.TextureCubeArray.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels; - - // Earlier we set arraySize to (NumCubes * 6) - SRVDesc.TextureCubeArray.NumCubes = static_cast(arraySize / 6); - } - else - { - SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE; - SRVDesc.TextureCube.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels; - } - } - else if (arraySize > 1) - { - SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY; - SRVDesc.Texture2DArray.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels; - SRVDesc.Texture2DArray.ArraySize = static_cast(arraySize); - } - else - { - SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; - SRVDesc.Texture2D.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels; - } - - hr = d3dDevice->CreateShaderResourceView(tex, - &SRVDesc, - textureView - ); - if (FAILED(hr)) - { - tex->Release(); - return hr; - } - } - - if (texture) - { - *texture = tex; - } - else - { - SetDebugObjectName(tex, "DDSTextureLoader"); - tex->Release(); - } - } - } - break; - - case D3D11_RESOURCE_DIMENSION_TEXTURE3D: - { - D3D11_TEXTURE3D_DESC desc; - desc.Width = static_cast(width); - desc.Height = static_cast(height); - desc.Depth = static_cast(depth); - desc.MipLevels = static_cast(mipCount); - desc.Format = format; - desc.Usage = usage; - desc.BindFlags = bindFlags; - desc.CPUAccessFlags = cpuAccessFlags; - desc.MiscFlags = miscFlags & ~static_cast(D3D11_RESOURCE_MISC_TEXTURECUBE); - - ID3D11Texture3D* tex = nullptr; - hr = d3dDevice->CreateTexture3D(&desc, - initData, - &tex - ); - if (SUCCEEDED(hr) && tex) - { - if (textureView) - { - D3D11_SHADER_RESOURCE_VIEW_DESC SRVDesc = {}; - SRVDesc.Format = format; - - SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D; - SRVDesc.Texture3D.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels; - - hr = d3dDevice->CreateShaderResourceView(tex, - &SRVDesc, - textureView - ); - if (FAILED(hr)) - { - tex->Release(); - return hr; - } - } - - if (texture) - { - *texture = tex; - } - else - { - SetDebugObjectName(tex, "DDSTextureLoader"); - tex->Release(); - } - } - } - break; - } - - return hr; - } - - //-------------------------------------------------------------------------------------- - HRESULT CreateTextureFromDDS( - _In_ ID3D11Device* d3dDevice, - _In_opt_ ID3D11DeviceContext* d3dContext, - _In_ const DDS_HEADER* header, - _In_reads_bytes_(bitSize) const uint8_t* bitData, - _In_ size_t bitSize, - _In_ size_t maxsize, - _In_ D3D11_USAGE usage, - _In_ unsigned int bindFlags, - _In_ unsigned int cpuAccessFlags, - _In_ unsigned int miscFlags, - _In_ bool forceSRGB, - _Outptr_opt_ ID3D11Resource** texture, - _Outptr_opt_ ID3D11ShaderResourceView** textureView) noexcept - { - HRESULT hr = S_OK; - - const UINT width = header->width; - UINT height = header->height; - UINT depth = header->depth; - - uint32_t resDim = D3D11_RESOURCE_DIMENSION_UNKNOWN; - UINT arraySize = 1; - DXGI_FORMAT format = DXGI_FORMAT_UNKNOWN; - bool isCubeMap = false; - - size_t mipCount = header->mipMapCount; - if (0 == mipCount) - { - mipCount = 1; - } - - if ((header->ddspf.flags & DDS_FOURCC) && - (MAKEFOURCC('D', 'X', '1', '0') == header->ddspf.fourCC)) - { - auto d3d10ext = reinterpret_cast(reinterpret_cast(header) + sizeof(DDS_HEADER)); - - arraySize = d3d10ext->arraySize; - if (arraySize == 0) - { - return HRESULT_FROM_WIN32(ERROR_INVALID_DATA); - } - - switch (d3d10ext->dxgiFormat) - { - case DXGI_FORMAT_AI44: - case DXGI_FORMAT_IA44: - case DXGI_FORMAT_P8: - case DXGI_FORMAT_A8P8: - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - - default: - if (BitsPerPixel(d3d10ext->dxgiFormat) == 0) - { - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - } - - format = d3d10ext->dxgiFormat; - - switch (d3d10ext->resourceDimension) - { - case D3D11_RESOURCE_DIMENSION_TEXTURE1D: - // D3DX writes 1D textures with a fixed Height of 1 - if ((header->flags & DDS_HEIGHT) && height != 1) - { - return HRESULT_FROM_WIN32(ERROR_INVALID_DATA); - } - height = depth = 1; - break; - - case D3D11_RESOURCE_DIMENSION_TEXTURE2D: - if (d3d10ext->miscFlag & D3D11_RESOURCE_MISC_TEXTURECUBE) - { - arraySize *= 6; - isCubeMap = true; - } - depth = 1; - break; - - case D3D11_RESOURCE_DIMENSION_TEXTURE3D: - if (!(header->flags & DDS_HEADER_FLAGS_VOLUME)) - { - return HRESULT_FROM_WIN32(ERROR_INVALID_DATA); - } - - if (arraySize > 1) - { - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - break; - - default: - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - - resDim = d3d10ext->resourceDimension; - } - else - { - format = GetDXGIFormat(header->ddspf); - - if (format == DXGI_FORMAT_UNKNOWN) - { - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - - if (header->flags & DDS_HEADER_FLAGS_VOLUME) - { - resDim = D3D11_RESOURCE_DIMENSION_TEXTURE3D; - } - else - { - if (header->caps2 & DDS_CUBEMAP) - { - // We require all six faces to be defined - if ((header->caps2 & DDS_CUBEMAP_ALLFACES) != DDS_CUBEMAP_ALLFACES) - { - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - - arraySize = 6; - isCubeMap = true; - } - - depth = 1; - resDim = D3D11_RESOURCE_DIMENSION_TEXTURE2D; - - // Note there's no way for a legacy Direct3D 9 DDS to express a '1D' texture - } - - assert(BitsPerPixel(format) != 0); - } - - // Bound sizes (for security purposes we don't trust DDS file metadata larger than the D3D 11.x hardware requirements) - if (mipCount > D3D11_REQ_MIP_LEVELS) - { - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - - switch (resDim) - { - case D3D11_RESOURCE_DIMENSION_TEXTURE1D: - if ((arraySize > D3D11_REQ_TEXTURE1D_ARRAY_AXIS_DIMENSION) || - (width > D3D11_REQ_TEXTURE1D_U_DIMENSION)) - { - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - break; - - case D3D11_RESOURCE_DIMENSION_TEXTURE2D: - if (isCubeMap) - { - // This is the right bound because we set arraySize to (NumCubes*6) above - if ((arraySize > D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION) || - (width > D3D11_REQ_TEXTURECUBE_DIMENSION) || - (height > D3D11_REQ_TEXTURECUBE_DIMENSION)) - { - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - } - else if ((arraySize > D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION) || - (width > D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION) || - (height > D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION)) - { - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - break; - - case D3D11_RESOURCE_DIMENSION_TEXTURE3D: - if ((arraySize > 1) || - (width > D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION) || - (height > D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION) || - (depth > D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION)) - { - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - break; - - default: - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - - bool autogen = false; - if (mipCount == 1 && d3dContext && textureView) // Must have context and shader-view to auto generate mipmaps - { - // See if format is supported for auto-gen mipmaps (varies by feature level) - UINT fmtSupport = 0; - hr = d3dDevice->CheckFormatSupport(format, &fmtSupport); - if (SUCCEEDED(hr) && (fmtSupport & D3D11_FORMAT_SUPPORT_MIP_AUTOGEN)) - { - // 10level9 feature levels do not support auto-gen mipgen for volume textures - if ((resDim != D3D11_RESOURCE_DIMENSION_TEXTURE3D) - || (d3dDevice->GetFeatureLevel() >= D3D_FEATURE_LEVEL_10_0)) - { - autogen = true; - } - } - } - - if (autogen) - { - // Create texture with auto-generated mipmaps - ID3D11Resource* tex = nullptr; - hr = CreateD3DResources(d3dDevice, - resDim, width, height, depth, 0, arraySize, - format, - usage, - bindFlags | D3D11_BIND_RENDER_TARGET, - cpuAccessFlags, - miscFlags | D3D11_RESOURCE_MISC_GENERATE_MIPS, - forceSRGB, - isCubeMap, - nullptr, - &tex, textureView); - if (SUCCEEDED(hr)) - { - size_t numBytes = 0; - size_t rowBytes = 0; - hr = GetSurfaceInfo(width, height, format, &numBytes, &rowBytes, nullptr); - if (FAILED(hr)) - return hr; - - if (numBytes > bitSize) - { - (*textureView)->Release(); - *textureView = nullptr; - tex->Release(); - return HRESULT_FROM_WIN32(ERROR_HANDLE_EOF); - } - - if (numBytes > UINT32_MAX || rowBytes > UINT32_MAX) - return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); - - D3D11_SHADER_RESOURCE_VIEW_DESC desc; - (*textureView)->GetDesc(&desc); - - UINT mipLevels = 1; - - switch (desc.ViewDimension) - { - case D3D_SRV_DIMENSION_TEXTURE1D: mipLevels = desc.Texture1D.MipLevels; break; - case D3D_SRV_DIMENSION_TEXTURE1DARRAY: mipLevels = desc.Texture1DArray.MipLevels; break; - case D3D_SRV_DIMENSION_TEXTURE2D: mipLevels = desc.Texture2D.MipLevels; break; - case D3D_SRV_DIMENSION_TEXTURE2DARRAY: mipLevels = desc.Texture2DArray.MipLevels; break; - case D3D_SRV_DIMENSION_TEXTURECUBE: mipLevels = desc.TextureCube.MipLevels; break; - case D3D_SRV_DIMENSION_TEXTURECUBEARRAY:mipLevels = desc.TextureCubeArray.MipLevels; break; - case D3D_SRV_DIMENSION_TEXTURE3D: mipLevels = desc.Texture3D.MipLevels; break; - default: - (*textureView)->Release(); - *textureView = nullptr; - tex->Release(); - return E_UNEXPECTED; - } - - if (arraySize > 1) - { - const uint8_t* pSrcBits = bitData; - const uint8_t* pEndBits = bitData + bitSize; - for (UINT item = 0; item < arraySize; ++item) - { - if ((pSrcBits + numBytes) > pEndBits) - { - (*textureView)->Release(); - *textureView = nullptr; - tex->Release(); - return HRESULT_FROM_WIN32(ERROR_HANDLE_EOF); - } - - const UINT res = D3D11CalcSubresource(0, item, mipLevels); - d3dContext->UpdateSubresource(tex, res, nullptr, pSrcBits, static_cast(rowBytes), static_cast(numBytes)); - pSrcBits += numBytes; - } - } - else - { - d3dContext->UpdateSubresource(tex, 0, nullptr, bitData, static_cast(rowBytes), static_cast(numBytes)); - } - - d3dContext->GenerateMips(*textureView); - - if (texture) - { - *texture = tex; - } - else - { - tex->Release(); - } - } - } - else - { - // Create the texture - std::unique_ptr initData(new (std::nothrow) D3D11_SUBRESOURCE_DATA[mipCount * arraySize]); - if (!initData) - { - return E_OUTOFMEMORY; - } - - size_t skipMip = 0; - size_t twidth = 0; - size_t theight = 0; - size_t tdepth = 0; - hr = FillInitData(width, height, depth, mipCount, arraySize, - format, maxsize, bitSize, bitData, - twidth, theight, tdepth, skipMip, initData.get()); - - if (SUCCEEDED(hr)) - { - hr = CreateD3DResources(d3dDevice, - resDim, twidth, theight, tdepth, mipCount - skipMip, arraySize, - format, - usage, bindFlags, cpuAccessFlags, miscFlags, - forceSRGB, - isCubeMap, - initData.get(), - texture, textureView); - - if (FAILED(hr) && !maxsize && (mipCount > 1)) - { - // Retry with a maxsize determined by feature level - switch (d3dDevice->GetFeatureLevel()) - { - case D3D_FEATURE_LEVEL_9_1: - case D3D_FEATURE_LEVEL_9_2: - if (isCubeMap) - { - maxsize = 512u /*D3D_FL9_1_REQ_TEXTURECUBE_DIMENSION*/; - } - else - { - maxsize = (resDim == D3D11_RESOURCE_DIMENSION_TEXTURE3D) - ? 256u /*D3D_FL9_1_REQ_TEXTURE3D_U_V_OR_W_DIMENSION*/ - : 2048u /*D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION*/; - } - break; - - case D3D_FEATURE_LEVEL_9_3: - maxsize = (resDim == D3D11_RESOURCE_DIMENSION_TEXTURE3D) - ? 256u /*D3D_FL9_1_REQ_TEXTURE3D_U_V_OR_W_DIMENSION*/ - : 4096u /*D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION*/; - break; - - default: // D3D_FEATURE_LEVEL_10_0 & D3D_FEATURE_LEVEL_10_1 - maxsize = (resDim == D3D11_RESOURCE_DIMENSION_TEXTURE3D) - ? 2048u /*D3D10_REQ_TEXTURE3D_U_V_OR_W_DIMENSION*/ - : 8192u /*D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION*/; - break; - } - - hr = FillInitData(width, height, depth, mipCount, arraySize, format, maxsize, bitSize, bitData, - twidth, theight, tdepth, skipMip, initData.get()); - if (SUCCEEDED(hr)) - { - hr = CreateD3DResources(d3dDevice, - resDim, twidth, theight, tdepth, mipCount - skipMip, arraySize, - format, - usage, bindFlags, cpuAccessFlags, miscFlags, - forceSRGB, - isCubeMap, - initData.get(), - texture, textureView); - } - } - } - } - - return hr; - } - - - //-------------------------------------------------------------------------------------- - DDS_ALPHA_MODE GetAlphaMode(_In_ const DDS_HEADER* header) noexcept - { - if (header->ddspf.flags & DDS_FOURCC) - { - if (MAKEFOURCC('D', 'X', '1', '0') == header->ddspf.fourCC) - { - auto d3d10ext = reinterpret_cast(reinterpret_cast(header) + sizeof(DDS_HEADER)); - auto const mode = static_cast(d3d10ext->miscFlags2 & DDS_MISC_FLAGS2_ALPHA_MODE_MASK); - switch (mode) - { - case DDS_ALPHA_MODE_STRAIGHT: - case DDS_ALPHA_MODE_PREMULTIPLIED: - case DDS_ALPHA_MODE_OPAQUE: - case DDS_ALPHA_MODE_CUSTOM: - return mode; - - case DDS_ALPHA_MODE_UNKNOWN: - default: - break; - } - } - else if ((MAKEFOURCC('D', 'X', 'T', '2') == header->ddspf.fourCC) - || (MAKEFOURCC('D', 'X', 'T', '4') == header->ddspf.fourCC)) - { - return DDS_ALPHA_MODE_PREMULTIPLIED; - } - } - - return DDS_ALPHA_MODE_UNKNOWN; - } - - //-------------------------------------------------------------------------------------- - void SetDebugTextureInfo( - _In_z_ const wchar_t* fileName, - _In_opt_ ID3D11Resource** texture, - _In_opt_ ID3D11ShaderResourceView** textureView) noexcept - { - #if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) ) - if (texture || textureView) - { - CHAR strFileA[MAX_PATH]; - const int result = WideCharToMultiByte(CP_UTF8, - WC_NO_BEST_FIT_CHARS, - fileName, - -1, - strFileA, - MAX_PATH, - nullptr, - nullptr - ); - if (result > 0) - { - const char* pstrName = strrchr(strFileA, '\\'); - if (!pstrName) - { - pstrName = strFileA; - } - else - { - pstrName++; - } - - if (texture && *texture) - { - (*texture)->SetPrivateData(WKPDID_D3DDebugObjectName, - static_cast(strnlen_s(pstrName, MAX_PATH)), - pstrName - ); - } - - if (textureView && *textureView) - { - (*textureView)->SetPrivateData(WKPDID_D3DDebugObjectName, - static_cast(strnlen_s(pstrName, MAX_PATH)), - pstrName - ); - } - } - } - #else - UNREFERENCED_PARAMETER(fileName); - UNREFERENCED_PARAMETER(texture); - UNREFERENCED_PARAMETER(textureView); - #endif - } -} // anonymous namespace - -//-------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::CreateDDSTextureFromMemory( - ID3D11Device* d3dDevice, - const uint8_t* ddsData, - size_t ddsDataSize, - ID3D11Resource** texture, - ID3D11ShaderResourceView** textureView, - size_t maxsize, - DDS_ALPHA_MODE* alphaMode) noexcept -{ - return CreateDDSTextureFromMemoryEx(d3dDevice, nullptr, - ddsData, ddsDataSize, - maxsize, - D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, - false, - texture, textureView, alphaMode); -} - -_Use_decl_annotations_ -HRESULT DirectX::CreateDDSTextureFromMemory( - ID3D11Device* d3dDevice, - ID3D11DeviceContext* d3dContext, - const uint8_t* ddsData, - size_t ddsDataSize, - ID3D11Resource** texture, - ID3D11ShaderResourceView** textureView, - size_t maxsize, - DDS_ALPHA_MODE* alphaMode) noexcept -{ - return CreateDDSTextureFromMemoryEx(d3dDevice, d3dContext, - ddsData, ddsDataSize, - maxsize, - D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, - false, - texture, textureView, alphaMode); -} - -_Use_decl_annotations_ -HRESULT DirectX::CreateDDSTextureFromMemoryEx( - ID3D11Device* d3dDevice, - const uint8_t* ddsData, - size_t ddsDataSize, - size_t maxsize, - D3D11_USAGE usage, - unsigned int bindFlags, - unsigned int cpuAccessFlags, - unsigned int miscFlags, - bool forceSRGB, - ID3D11Resource** texture, - ID3D11ShaderResourceView** textureView, - DDS_ALPHA_MODE* alphaMode) noexcept -{ - return CreateDDSTextureFromMemoryEx(d3dDevice, nullptr, - ddsData, ddsDataSize, - maxsize, - usage, bindFlags, cpuAccessFlags, miscFlags, - forceSRGB, - texture, textureView, alphaMode); -} - -_Use_decl_annotations_ -HRESULT DirectX::CreateDDSTextureFromMemoryEx( - ID3D11Device* d3dDevice, - ID3D11DeviceContext* d3dContext, - const uint8_t* ddsData, - size_t ddsDataSize, - size_t maxsize, - D3D11_USAGE usage, - unsigned int bindFlags, - unsigned int cpuAccessFlags, - unsigned int miscFlags, - bool forceSRGB, - ID3D11Resource** texture, - ID3D11ShaderResourceView** textureView, - DDS_ALPHA_MODE* alphaMode) noexcept -{ - if (texture) - { - *texture = nullptr; - } - if (textureView) - { - *textureView = nullptr; - } - if (alphaMode) - { - *alphaMode = DDS_ALPHA_MODE_UNKNOWN; - } - - if (!d3dDevice || !ddsData || (!texture && !textureView)) - { - return E_INVALIDARG; - } - - if (textureView && !(bindFlags & D3D11_BIND_SHADER_RESOURCE)) - { - return E_INVALIDARG; - } - - // Validate DDS file in memory - const DDS_HEADER* header = nullptr; - const uint8_t* bitData = nullptr; - size_t bitSize = 0; - - HRESULT hr = LoadTextureDataFromMemory(ddsData, ddsDataSize, - &header, - &bitData, - &bitSize - ); - if (FAILED(hr)) - { - return hr; - } - - hr = CreateTextureFromDDS(d3dDevice, d3dContext, - header, bitData, bitSize, - maxsize, - usage, bindFlags, cpuAccessFlags, miscFlags, - forceSRGB, - texture, textureView); - if (SUCCEEDED(hr)) - { - if (texture && *texture) - { - SetDebugObjectName(*texture, "DDSTextureLoader"); - } - - if (textureView && *textureView) - { - SetDebugObjectName(*textureView, "DDSTextureLoader"); - } - - if (alphaMode) - *alphaMode = GetAlphaMode(header); - } - - return hr; -} - -//-------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::CreateDDSTextureFromFile( - ID3D11Device* d3dDevice, - const wchar_t* fileName, - ID3D11Resource** texture, - ID3D11ShaderResourceView** textureView, - size_t maxsize, - DDS_ALPHA_MODE* alphaMode) noexcept -{ - return CreateDDSTextureFromFileEx(d3dDevice, nullptr, - fileName, maxsize, - D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, - false, - texture, textureView, alphaMode); -} - -_Use_decl_annotations_ -HRESULT DirectX::CreateDDSTextureFromFile( - ID3D11Device* d3dDevice, - ID3D11DeviceContext* d3dContext, - const wchar_t* fileName, - ID3D11Resource** texture, - ID3D11ShaderResourceView** textureView, - size_t maxsize, - DDS_ALPHA_MODE* alphaMode) noexcept -{ - return CreateDDSTextureFromFileEx(d3dDevice, d3dContext, - fileName, - maxsize, - D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, - false, - texture, textureView, alphaMode); -} - -_Use_decl_annotations_ -HRESULT DirectX::CreateDDSTextureFromFileEx( - ID3D11Device* d3dDevice, - const wchar_t* fileName, - size_t maxsize, - D3D11_USAGE usage, - unsigned int bindFlags, - unsigned int cpuAccessFlags, - unsigned int miscFlags, - bool forceSRGB, - ID3D11Resource** texture, - ID3D11ShaderResourceView** textureView, - DDS_ALPHA_MODE* alphaMode) noexcept -{ - return CreateDDSTextureFromFileEx(d3dDevice, nullptr, - fileName, - maxsize, - usage, bindFlags, cpuAccessFlags, miscFlags, - forceSRGB, - texture, textureView, alphaMode); -} - -_Use_decl_annotations_ -HRESULT DirectX::CreateDDSTextureFromFileEx( - ID3D11Device* d3dDevice, - ID3D11DeviceContext* d3dContext, - const wchar_t* fileName, - size_t maxsize, - D3D11_USAGE usage, - unsigned int bindFlags, - unsigned int cpuAccessFlags, - unsigned int miscFlags, - bool forceSRGB, - ID3D11Resource** texture, - ID3D11ShaderResourceView** textureView, - DDS_ALPHA_MODE* alphaMode) noexcept -{ - if (texture) - { - *texture = nullptr; - } - if (textureView) - { - *textureView = nullptr; - } - if (alphaMode) - { - *alphaMode = DDS_ALPHA_MODE_UNKNOWN; - } - - if (!d3dDevice || !fileName || (!texture && !textureView)) - { - return E_INVALIDARG; - } - - if (textureView && !(bindFlags & D3D11_BIND_SHADER_RESOURCE)) - { - return E_INVALIDARG; - } - - const DDS_HEADER* header = nullptr; - const uint8_t* bitData = nullptr; - size_t bitSize = 0; - - std::unique_ptr ddsData; - HRESULT hr = LoadTextureDataFromFile(fileName, - ddsData, - &header, - &bitData, - &bitSize - ); - if (FAILED(hr)) - { - return hr; - } - - hr = CreateTextureFromDDS(d3dDevice, d3dContext, - header, bitData, bitSize, - maxsize, - usage, bindFlags, cpuAccessFlags, miscFlags, - forceSRGB, - texture, textureView); - - if (SUCCEEDED(hr)) - { - SetDebugTextureInfo(fileName, texture, textureView); - - if (alphaMode) - *alphaMode = GetAlphaMode(header); - } - - return hr; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSTextureLoader/DDSTextureLoader11.h b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSTextureLoader/DDSTextureLoader11.h deleted file mode 100644 index f81d9a7..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSTextureLoader/DDSTextureLoader11.h +++ /dev/null @@ -1,136 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: DDSTextureLoader11.h -// -// Functions for loading a DDS texture and creating a Direct3D runtime resource for it -// -// Note these functions are useful as a light-weight runtime loader for DDS files. For -// a full-featured DDS file reader, writer, and texture processing pipeline see -// the 'Texconv' sample and the 'DirectXTex' library. -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -// http://go.microsoft.com/fwlink/?LinkId=248929 -//-------------------------------------------------------------------------------------- - -#pragma once - -#include - -#pragma comment(lib,"dxguid.lib") - -#include -#include - - -namespace DirectX -{ -#ifndef DDS_ALPHA_MODE_DEFINED -#define DDS_ALPHA_MODE_DEFINED - enum DDS_ALPHA_MODE : uint32_t - { - DDS_ALPHA_MODE_UNKNOWN = 0, - DDS_ALPHA_MODE_STRAIGHT = 1, - DDS_ALPHA_MODE_PREMULTIPLIED = 2, - DDS_ALPHA_MODE_OPAQUE = 3, - DDS_ALPHA_MODE_CUSTOM = 4, - }; -#endif - - // Standard version - HRESULT CreateDDSTextureFromMemory( - _In_ ID3D11Device* d3dDevice, - _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, - _In_ size_t ddsDataSize, - _Outptr_opt_ ID3D11Resource** texture, - _Outptr_opt_ ID3D11ShaderResourceView** textureView, - _In_ size_t maxsize = 0, - _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr) noexcept; - - HRESULT CreateDDSTextureFromFile( - _In_ ID3D11Device* d3dDevice, - _In_z_ const wchar_t* szFileName, - _Outptr_opt_ ID3D11Resource** texture, - _Outptr_opt_ ID3D11ShaderResourceView** textureView, - _In_ size_t maxsize = 0, - _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr) noexcept; - - // Standard version with optional auto-gen mipmap support - HRESULT CreateDDSTextureFromMemory( - _In_ ID3D11Device* d3dDevice, - _In_opt_ ID3D11DeviceContext* d3dContext, - _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, - _In_ size_t ddsDataSize, - _Outptr_opt_ ID3D11Resource** texture, - _Outptr_opt_ ID3D11ShaderResourceView** textureView, - _In_ size_t maxsize = 0, - _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr) noexcept; - - HRESULT CreateDDSTextureFromFile( - _In_ ID3D11Device* d3dDevice, - _In_opt_ ID3D11DeviceContext* d3dContext, - _In_z_ const wchar_t* szFileName, - _Outptr_opt_ ID3D11Resource** texture, - _Outptr_opt_ ID3D11ShaderResourceView** textureView, - _In_ size_t maxsize = 0, - _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr) noexcept; - - // Extended version - HRESULT CreateDDSTextureFromMemoryEx( - _In_ ID3D11Device* d3dDevice, - _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, - _In_ size_t ddsDataSize, - _In_ size_t maxsize, - _In_ D3D11_USAGE usage, - _In_ unsigned int bindFlags, - _In_ unsigned int cpuAccessFlags, - _In_ unsigned int miscFlags, - _In_ bool forceSRGB, - _Outptr_opt_ ID3D11Resource** texture, - _Outptr_opt_ ID3D11ShaderResourceView** textureView, - _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr) noexcept; - - HRESULT CreateDDSTextureFromFileEx( - _In_ ID3D11Device* d3dDevice, - _In_z_ const wchar_t* szFileName, - _In_ size_t maxsize, - _In_ D3D11_USAGE usage, - _In_ unsigned int bindFlags, - _In_ unsigned int cpuAccessFlags, - _In_ unsigned int miscFlags, - _In_ bool forceSRGB, - _Outptr_opt_ ID3D11Resource** texture, - _Outptr_opt_ ID3D11ShaderResourceView** textureView, - _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr) noexcept; - - // Extended version with optional auto-gen mipmap support - HRESULT CreateDDSTextureFromMemoryEx( - _In_ ID3D11Device* d3dDevice, - _In_opt_ ID3D11DeviceContext* d3dContext, - _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, - _In_ size_t ddsDataSize, - _In_ size_t maxsize, - _In_ D3D11_USAGE usage, - _In_ unsigned int bindFlags, - _In_ unsigned int cpuAccessFlags, - _In_ unsigned int miscFlags, - _In_ bool forceSRGB, - _Outptr_opt_ ID3D11Resource** texture, - _Outptr_opt_ ID3D11ShaderResourceView** textureView, - _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr) noexcept; - - HRESULT CreateDDSTextureFromFileEx( - _In_ ID3D11Device* d3dDevice, - _In_opt_ ID3D11DeviceContext* d3dContext, - _In_z_ const wchar_t* szFileName, - _In_ size_t maxsize, - _In_ D3D11_USAGE usage, - _In_ unsigned int bindFlags, - _In_ unsigned int cpuAccessFlags, - _In_ unsigned int miscFlags, - _In_ bool forceSRGB, - _Outptr_opt_ ID3D11Resource** texture, - _Outptr_opt_ ID3D11ShaderResourceView** textureView, - _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr) noexcept; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSTextureLoader/DDSTextureLoader12.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSTextureLoader/DDSTextureLoader12.cpp deleted file mode 100644 index f7af781..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSTextureLoader/DDSTextureLoader12.cpp +++ /dev/null @@ -1,1744 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: DDSTextureLoader12.cpp -// -// Functions for loading a DDS texture and creating a Direct3D runtime resource for it -// -// Note these functions are useful as a light-weight runtime loader for DDS files. For -// a full-featured DDS file reader, writer, and texture processing pipeline see -// the 'Texconv' sample and the 'DirectXTex' library. -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -// http://go.microsoft.com/fwlink/?LinkID=615561 -//-------------------------------------------------------------------------------------- - -#include "DDSTextureLoader12.h" - -#include -#include -#include -#include - -#ifndef _WIN32 -#include -#include -#endif - -#ifdef _MSC_VER -// Off by default warnings -#pragma warning(disable : 4619 4616 4061 4062 4623 4626 5027) -// C4619/4616 #pragma warning warnings -// C4061 enumerator 'x' in switch of enum 'y' is not explicitly handled by a case label -// C4062 enumerator 'x' in switch of enum 'y' is not handled -// C4623 default constructor was implicitly defined as deleted -// C4626 assignment operator was implicitly defined as deleted -// C5027 move assignment operator was implicitly defined as deleted -#endif - -#ifdef __clang__ -#pragma clang diagnostic ignored "-Wtautological-type-limit-compare" -#pragma clang diagnostic ignored "-Wcovered-switch-default" -#pragma clang diagnostic ignored "-Wswitch" -#pragma clang diagnostic ignored "-Wswitch-enum" -#pragma clang diagnostic ignored "-Wunused-macros" -#endif - -#define D3DX12_NO_STATE_OBJECT_HELPERS -#define D3DX12_NO_CHECK_FEATURE_SUPPORT_CLASS -#if !defined(_WIN32) || defined(USING_DIRECTX_HEADERS) -#include "directx/d3dx12.h" -#else -#include "d3dx12.h" -#endif - -using namespace DirectX; - -//-------------------------------------------------------------------------------------- -// Macros -//-------------------------------------------------------------------------------------- -#ifndef MAKEFOURCC -#define MAKEFOURCC(ch0, ch1, ch2, ch3) \ - ((uint32_t)(uint8_t)(ch0) | ((uint32_t)(uint8_t)(ch1) << 8) | \ - ((uint32_t)(uint8_t)(ch2) << 16) | ((uint32_t)(uint8_t)(ch3) << 24 )) -#endif /* defined(MAKEFOURCC) */ - -// HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW) -#define HRESULT_E_ARITHMETIC_OVERFLOW static_cast(0x80070216L) - -// HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED) -#define HRESULT_E_NOT_SUPPORTED static_cast(0x80070032L) - -// HRESULT_FROM_WIN32(ERROR_HANDLE_EOF) -#define HRESULT_E_HANDLE_EOF static_cast(0x80070026L) - -// HRESULT_FROM_WIN32(ERROR_INVALID_DATA) -#define HRESULT_E_INVALID_DATA static_cast(0x8007000DL) - -//-------------------------------------------------------------------------------------- -// DDS file structure definitions -// -// See DDS.h in the 'Texconv' sample and the 'DirectXTex' library -//-------------------------------------------------------------------------------------- -#pragma pack(push,1) - -constexpr uint32_t DDS_MAGIC = 0x20534444; // "DDS " - -struct DDS_PIXELFORMAT -{ - uint32_t size; - uint32_t flags; - uint32_t fourCC; - uint32_t RGBBitCount; - uint32_t RBitMask; - uint32_t GBitMask; - uint32_t BBitMask; - uint32_t ABitMask; -}; - -#define DDS_FOURCC 0x00000004 // DDPF_FOURCC -#define DDS_RGB 0x00000040 // DDPF_RGB -#define DDS_LUMINANCE 0x00020000 // DDPF_LUMINANCE -#define DDS_ALPHA 0x00000002 // DDPF_ALPHA -#define DDS_BUMPDUDV 0x00080000 // DDPF_BUMPDUDV - -#define DDS_HEADER_FLAGS_VOLUME 0x00800000 // DDSD_DEPTH - -#define DDS_HEIGHT 0x00000002 // DDSD_HEIGHT - -#define DDS_CUBEMAP_POSITIVEX 0x00000600 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEX -#define DDS_CUBEMAP_NEGATIVEX 0x00000a00 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEX -#define DDS_CUBEMAP_POSITIVEY 0x00001200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEY -#define DDS_CUBEMAP_NEGATIVEY 0x00002200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEY -#define DDS_CUBEMAP_POSITIVEZ 0x00004200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEZ -#define DDS_CUBEMAP_NEGATIVEZ 0x00008200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEZ - -#define DDS_CUBEMAP_ALLFACES ( DDS_CUBEMAP_POSITIVEX | DDS_CUBEMAP_NEGATIVEX |\ - DDS_CUBEMAP_POSITIVEY | DDS_CUBEMAP_NEGATIVEY |\ - DDS_CUBEMAP_POSITIVEZ | DDS_CUBEMAP_NEGATIVEZ ) - -#define DDS_CUBEMAP 0x00000200 // DDSCAPS2_CUBEMAP - -enum DDS_MISC_FLAGS2 -{ - DDS_MISC_FLAGS2_ALPHA_MODE_MASK = 0x7L, -}; - -struct DDS_HEADER -{ - uint32_t size; - uint32_t flags; - uint32_t height; - uint32_t width; - uint32_t pitchOrLinearSize; - uint32_t depth; // only if DDS_HEADER_FLAGS_VOLUME is set in flags - uint32_t mipMapCount; - uint32_t reserved1[11]; - DDS_PIXELFORMAT ddspf; - uint32_t caps; - uint32_t caps2; - uint32_t caps3; - uint32_t caps4; - uint32_t reserved2; -}; - -struct DDS_HEADER_DXT10 -{ - DXGI_FORMAT dxgiFormat; - uint32_t resourceDimension; - uint32_t miscFlag; // see D3D11_RESOURCE_MISC_FLAG - uint32_t arraySize; - uint32_t miscFlags2; -}; - -#pragma pack(pop) - -//-------------------------------------------------------------------------------------- -namespace -{ -#ifdef _WIN32 - struct handle_closer { void operator()(HANDLE h) noexcept { if (h) CloseHandle(h); } }; - - using ScopedHandle = std::unique_ptr; - - inline HANDLE safe_handle(HANDLE h) noexcept { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; } -#endif - - #if !defined(NO_D3D12_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) ) - template - inline void SetDebugObjectName(_In_ ID3D12DeviceChild* resource, _In_z_ const wchar_t(&name)[TNameLength]) noexcept - { - resource->SetName(name); - } - #else - template - inline void SetDebugObjectName(_In_ ID3D12DeviceChild*, _In_z_ const wchar_t(&)[TNameLength]) noexcept - { - } - #endif - - inline uint32_t CountMips(uint32_t width, uint32_t height) noexcept - { - if (width == 0 || height == 0) - return 0; - - uint32_t count = 1; - while (width > 1 || height > 1) - { - width >>= 1; - height >>= 1; - count++; - } - return count; - } - - - //-------------------------------------------------------------------------------------- - HRESULT LoadTextureDataFromMemory( - _In_reads_(ddsDataSize) const uint8_t* ddsData, - size_t ddsDataSize, - const DDS_HEADER** header, - const uint8_t** bitData, - size_t* bitSize) noexcept - { - if (!header || !bitData || !bitSize) - { - return E_POINTER; - } - - *bitSize = 0; - - if (ddsDataSize > UINT32_MAX) - { - return E_FAIL; - } - - if (ddsDataSize < (sizeof(uint32_t) + sizeof(DDS_HEADER))) - { - return E_FAIL; - } - - // DDS files always start with the same magic number ("DDS ") - auto const dwMagicNumber = *reinterpret_cast(ddsData); - if (dwMagicNumber != DDS_MAGIC) - { - return E_FAIL; - } - - auto hdr = reinterpret_cast(ddsData + sizeof(uint32_t)); - - // Verify header to validate DDS file - if (hdr->size != sizeof(DDS_HEADER) || - hdr->ddspf.size != sizeof(DDS_PIXELFORMAT)) - { - return E_FAIL; - } - - // Check for DX10 extension - bool bDXT10Header = false; - if ((hdr->ddspf.flags & DDS_FOURCC) && - (MAKEFOURCC('D', 'X', '1', '0') == hdr->ddspf.fourCC)) - { - // Must be long enough for both headers and magic value - if (ddsDataSize < (sizeof(uint32_t) + sizeof(DDS_HEADER) + sizeof(DDS_HEADER_DXT10))) - { - return E_FAIL; - } - - bDXT10Header = true; - } - - // setup the pointers in the process request - *header = hdr; - auto offset = sizeof(uint32_t) - + sizeof(DDS_HEADER) - + (bDXT10Header ? sizeof(DDS_HEADER_DXT10) : 0); - *bitData = ddsData + offset; - *bitSize = ddsDataSize - offset; - - return S_OK; - } - - - //-------------------------------------------------------------------------------------- - HRESULT LoadTextureDataFromFile( - _In_z_ const wchar_t* fileName, - std::unique_ptr& ddsData, - const DDS_HEADER** header, - const uint8_t** bitData, - size_t* bitSize) noexcept - { - if (!header || !bitData || !bitSize) - { - return E_POINTER; - } - - *bitSize = 0; - - #ifdef _WIN32 - // open the file - ScopedHandle hFile(safe_handle(CreateFile2(fileName, - GENERIC_READ, - FILE_SHARE_READ, - OPEN_EXISTING, - nullptr))); - - if (!hFile) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - // Get the file size - FILE_STANDARD_INFO fileInfo; - if (!GetFileInformationByHandleEx(hFile.get(), FileStandardInfo, &fileInfo, sizeof(fileInfo))) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - // File is too big for 32-bit allocation, so reject read - if (fileInfo.EndOfFile.HighPart > 0) - { - return E_FAIL; - } - - // Need at least enough data to fill the header and magic number to be a valid DDS - if (fileInfo.EndOfFile.LowPart < (sizeof(uint32_t) + sizeof(DDS_HEADER))) - { - return E_FAIL; - } - - // create enough space for the file data - ddsData.reset(new (std::nothrow) uint8_t[fileInfo.EndOfFile.LowPart]); - if (!ddsData) - { - return E_OUTOFMEMORY; - } - - // read the data in - DWORD bytesRead = 0; - if (!ReadFile(hFile.get(), - ddsData.get(), - fileInfo.EndOfFile.LowPart, - &bytesRead, - nullptr - )) - { - ddsData.reset(); - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesRead < fileInfo.EndOfFile.LowPart) - { - ddsData.reset(); - return E_FAIL; - } - - size_t len = fileInfo.EndOfFile.LowPart; - - #else // !WIN32 - std::ifstream inFile(std::filesystem::path(fileName), std::ios::in | std::ios::binary | std::ios::ate); - if (!inFile) - return E_FAIL; - - std::streampos fileLen = inFile.tellg(); - if (!inFile) - return E_FAIL; - - // Need at least enough data to fill the header and magic number to be a valid DDS - if (fileLen < (sizeof(uint32_t) + sizeof(DDS_HEADER))) - return E_FAIL; - - ddsData.reset(new (std::nothrow) uint8_t[size_t(fileLen)]); - if (!ddsData) - return E_OUTOFMEMORY; - - inFile.seekg(0, std::ios::beg); - if (!inFile) - { - ddsData.reset(); - return E_FAIL; - } - - inFile.read(reinterpret_cast(ddsData.get()), fileLen); - if (!inFile) - { - ddsData.reset(); - return E_FAIL; - } - - inFile.close(); - - size_t len = fileLen; - #endif - - // DDS files always start with the same magic number ("DDS ") - auto const dwMagicNumber = *reinterpret_cast(ddsData.get()); - if (dwMagicNumber != DDS_MAGIC) - { - ddsData.reset(); - return E_FAIL; - } - - auto hdr = reinterpret_cast(ddsData.get() + sizeof(uint32_t)); - - // Verify header to validate DDS file - if (hdr->size != sizeof(DDS_HEADER) || - hdr->ddspf.size != sizeof(DDS_PIXELFORMAT)) - { - ddsData.reset(); - return E_FAIL; - } - - // Check for DX10 extension - bool bDXT10Header = false; - if ((hdr->ddspf.flags & DDS_FOURCC) && - (MAKEFOURCC('D', 'X', '1', '0') == hdr->ddspf.fourCC)) - { - // Must be long enough for both headers and magic value - if (len < (sizeof(uint32_t) + sizeof(DDS_HEADER) + sizeof(DDS_HEADER_DXT10))) - { - ddsData.reset(); - return E_FAIL; - } - - bDXT10Header = true; - } - - // setup the pointers in the process request - *header = hdr; - auto offset = sizeof(uint32_t) + sizeof(DDS_HEADER) - + (bDXT10Header ? sizeof(DDS_HEADER_DXT10) : 0); - *bitData = ddsData.get() + offset; - *bitSize = len - offset; - - return S_OK; - } - - - //-------------------------------------------------------------------------------------- - // Return the BPP for a particular format - //-------------------------------------------------------------------------------------- - size_t BitsPerPixel(_In_ DXGI_FORMAT fmt) noexcept - { - switch (fmt) - { - case DXGI_FORMAT_R32G32B32A32_TYPELESS: - case DXGI_FORMAT_R32G32B32A32_FLOAT: - case DXGI_FORMAT_R32G32B32A32_UINT: - case DXGI_FORMAT_R32G32B32A32_SINT: - return 128; - - case DXGI_FORMAT_R32G32B32_TYPELESS: - case DXGI_FORMAT_R32G32B32_FLOAT: - case DXGI_FORMAT_R32G32B32_UINT: - case DXGI_FORMAT_R32G32B32_SINT: - return 96; - - case DXGI_FORMAT_R16G16B16A16_TYPELESS: - case DXGI_FORMAT_R16G16B16A16_FLOAT: - case DXGI_FORMAT_R16G16B16A16_UNORM: - case DXGI_FORMAT_R16G16B16A16_UINT: - case DXGI_FORMAT_R16G16B16A16_SNORM: - case DXGI_FORMAT_R16G16B16A16_SINT: - case DXGI_FORMAT_R32G32_TYPELESS: - case DXGI_FORMAT_R32G32_FLOAT: - case DXGI_FORMAT_R32G32_UINT: - case DXGI_FORMAT_R32G32_SINT: - case DXGI_FORMAT_R32G8X24_TYPELESS: - case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: - case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: - case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: - case DXGI_FORMAT_Y416: - case DXGI_FORMAT_Y210: - case DXGI_FORMAT_Y216: - return 64; - - case DXGI_FORMAT_R10G10B10A2_TYPELESS: - case DXGI_FORMAT_R10G10B10A2_UNORM: - case DXGI_FORMAT_R10G10B10A2_UINT: - case DXGI_FORMAT_R11G11B10_FLOAT: - case DXGI_FORMAT_R8G8B8A8_TYPELESS: - case DXGI_FORMAT_R8G8B8A8_UNORM: - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - case DXGI_FORMAT_R8G8B8A8_UINT: - case DXGI_FORMAT_R8G8B8A8_SNORM: - case DXGI_FORMAT_R8G8B8A8_SINT: - case DXGI_FORMAT_R16G16_TYPELESS: - case DXGI_FORMAT_R16G16_FLOAT: - case DXGI_FORMAT_R16G16_UNORM: - case DXGI_FORMAT_R16G16_UINT: - case DXGI_FORMAT_R16G16_SNORM: - case DXGI_FORMAT_R16G16_SINT: - case DXGI_FORMAT_R32_TYPELESS: - case DXGI_FORMAT_D32_FLOAT: - case DXGI_FORMAT_R32_FLOAT: - case DXGI_FORMAT_R32_UINT: - case DXGI_FORMAT_R32_SINT: - case DXGI_FORMAT_R24G8_TYPELESS: - case DXGI_FORMAT_D24_UNORM_S8_UINT: - case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: - case DXGI_FORMAT_X24_TYPELESS_G8_UINT: - case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: - case DXGI_FORMAT_R8G8_B8G8_UNORM: - case DXGI_FORMAT_G8R8_G8B8_UNORM: - case DXGI_FORMAT_B8G8R8A8_UNORM: - case DXGI_FORMAT_B8G8R8X8_UNORM: - case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: - case DXGI_FORMAT_B8G8R8A8_TYPELESS: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8X8_TYPELESS: - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - case DXGI_FORMAT_AYUV: - case DXGI_FORMAT_Y410: - case DXGI_FORMAT_YUY2: - return 32; - - case DXGI_FORMAT_P010: - case DXGI_FORMAT_P016: - case DXGI_FORMAT_V408: - return 24; - - case DXGI_FORMAT_R8G8_TYPELESS: - case DXGI_FORMAT_R8G8_UNORM: - case DXGI_FORMAT_R8G8_UINT: - case DXGI_FORMAT_R8G8_SNORM: - case DXGI_FORMAT_R8G8_SINT: - case DXGI_FORMAT_R16_TYPELESS: - case DXGI_FORMAT_R16_FLOAT: - case DXGI_FORMAT_D16_UNORM: - case DXGI_FORMAT_R16_UNORM: - case DXGI_FORMAT_R16_UINT: - case DXGI_FORMAT_R16_SNORM: - case DXGI_FORMAT_R16_SINT: - case DXGI_FORMAT_B5G6R5_UNORM: - case DXGI_FORMAT_B5G5R5A1_UNORM: - case DXGI_FORMAT_A8P8: - case DXGI_FORMAT_B4G4R4A4_UNORM: - case DXGI_FORMAT_P208: - case DXGI_FORMAT_V208: - return 16; - - case DXGI_FORMAT_NV12: - case DXGI_FORMAT_420_OPAQUE: - case DXGI_FORMAT_NV11: - return 12; - - case DXGI_FORMAT_R8_TYPELESS: - case DXGI_FORMAT_R8_UNORM: - case DXGI_FORMAT_R8_UINT: - case DXGI_FORMAT_R8_SNORM: - case DXGI_FORMAT_R8_SINT: - case DXGI_FORMAT_A8_UNORM: - case DXGI_FORMAT_BC2_TYPELESS: - case DXGI_FORMAT_BC2_UNORM: - case DXGI_FORMAT_BC2_UNORM_SRGB: - case DXGI_FORMAT_BC3_TYPELESS: - case DXGI_FORMAT_BC3_UNORM: - case DXGI_FORMAT_BC3_UNORM_SRGB: - case DXGI_FORMAT_BC5_TYPELESS: - case DXGI_FORMAT_BC5_UNORM: - case DXGI_FORMAT_BC5_SNORM: - case DXGI_FORMAT_BC6H_TYPELESS: - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - case DXGI_FORMAT_BC7_TYPELESS: - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: - case DXGI_FORMAT_AI44: - case DXGI_FORMAT_IA44: - case DXGI_FORMAT_P8: - return 8; - - case DXGI_FORMAT_R1_UNORM: - return 1; - - case DXGI_FORMAT_BC1_TYPELESS: - case DXGI_FORMAT_BC1_UNORM: - case DXGI_FORMAT_BC1_UNORM_SRGB: - case DXGI_FORMAT_BC4_TYPELESS: - case DXGI_FORMAT_BC4_UNORM: - case DXGI_FORMAT_BC4_SNORM: - return 4; - - default: - return 0; - } - } - - - //-------------------------------------------------------------------------------------- - // Get surface information for a particular format - //-------------------------------------------------------------------------------------- - HRESULT GetSurfaceInfo( - _In_ size_t width, - _In_ size_t height, - _In_ DXGI_FORMAT fmt, - size_t* outNumBytes, - _Out_opt_ size_t* outRowBytes, - _Out_opt_ size_t* outNumRows) noexcept - { - uint64_t numBytes = 0; - uint64_t rowBytes = 0; - uint64_t numRows = 0; - - bool bc = false; - bool packed = false; - bool planar = false; - size_t bpe = 0; - switch (fmt) - { - case DXGI_FORMAT_BC1_TYPELESS: - case DXGI_FORMAT_BC1_UNORM: - case DXGI_FORMAT_BC1_UNORM_SRGB: - case DXGI_FORMAT_BC4_TYPELESS: - case DXGI_FORMAT_BC4_UNORM: - case DXGI_FORMAT_BC4_SNORM: - bc = true; - bpe = 8; - break; - - case DXGI_FORMAT_BC2_TYPELESS: - case DXGI_FORMAT_BC2_UNORM: - case DXGI_FORMAT_BC2_UNORM_SRGB: - case DXGI_FORMAT_BC3_TYPELESS: - case DXGI_FORMAT_BC3_UNORM: - case DXGI_FORMAT_BC3_UNORM_SRGB: - case DXGI_FORMAT_BC5_TYPELESS: - case DXGI_FORMAT_BC5_UNORM: - case DXGI_FORMAT_BC5_SNORM: - case DXGI_FORMAT_BC6H_TYPELESS: - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - case DXGI_FORMAT_BC7_TYPELESS: - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: - bc = true; - bpe = 16; - break; - - case DXGI_FORMAT_R8G8_B8G8_UNORM: - case DXGI_FORMAT_G8R8_G8B8_UNORM: - case DXGI_FORMAT_YUY2: - packed = true; - bpe = 4; - break; - - case DXGI_FORMAT_Y210: - case DXGI_FORMAT_Y216: - packed = true; - bpe = 8; - break; - - case DXGI_FORMAT_NV12: - case DXGI_FORMAT_420_OPAQUE: - case DXGI_FORMAT_P208: - planar = true; - bpe = 2; - break; - - case DXGI_FORMAT_P010: - case DXGI_FORMAT_P016: - planar = true; - bpe = 4; - break; - - default: - break; - } - - if (bc) - { - uint64_t numBlocksWide = 0; - if (width > 0) - { - numBlocksWide = std::max(1u, (uint64_t(width) + 3u) / 4u); - } - uint64_t numBlocksHigh = 0; - if (height > 0) - { - numBlocksHigh = std::max(1u, (uint64_t(height) + 3u) / 4u); - } - rowBytes = numBlocksWide * bpe; - numRows = numBlocksHigh; - numBytes = rowBytes * numBlocksHigh; - } - else if (packed) - { - rowBytes = ((uint64_t(width) + 1u) >> 1) * bpe; - numRows = uint64_t(height); - numBytes = rowBytes * height; - } - else if (fmt == DXGI_FORMAT_NV11) - { - rowBytes = ((uint64_t(width) + 3u) >> 2) * 4u; - numRows = uint64_t(height) * 2u; // Direct3D makes this simplifying assumption, although it is larger than the 4:1:1 data - numBytes = rowBytes * numRows; - } - else if (planar) - { - rowBytes = ((uint64_t(width) + 1u) >> 1) * bpe; - numBytes = (rowBytes * uint64_t(height)) + ((rowBytes * uint64_t(height) + 1u) >> 1); - numRows = height + ((uint64_t(height) + 1u) >> 1); - } - else - { - const size_t bpp = BitsPerPixel(fmt); - if (!bpp) - return E_INVALIDARG; - - rowBytes = (uint64_t(width) * bpp + 7u) / 8u; // round up to nearest byte - numRows = uint64_t(height); - numBytes = rowBytes * height; - } - - #if defined(_M_IX86) || defined(_M_ARM) || defined(_M_HYBRID_X86_ARM64) - static_assert(sizeof(size_t) == 4, "Not a 32-bit platform!"); - if (numBytes > UINT32_MAX || rowBytes > UINT32_MAX || numRows > UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - #else - static_assert(sizeof(size_t) == 8, "Not a 64-bit platform!"); - #endif - - if (outNumBytes) - { - *outNumBytes = static_cast(numBytes); - } - if (outRowBytes) - { - *outRowBytes = static_cast(rowBytes); - } - if (outNumRows) - { - *outNumRows = static_cast(numRows); - } - - return S_OK; - } - - - //-------------------------------------------------------------------------------------- -#define ISBITMASK( r,g,b,a ) ( ddpf.RBitMask == r && ddpf.GBitMask == g && ddpf.BBitMask == b && ddpf.ABitMask == a ) - - DXGI_FORMAT GetDXGIFormat(const DDS_PIXELFORMAT& ddpf) noexcept - { - if (ddpf.flags & DDS_RGB) - { - // Note that sRGB formats are written using the "DX10" extended header - - switch (ddpf.RGBBitCount) - { - case 32: - if (ISBITMASK(0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000)) - { - return DXGI_FORMAT_R8G8B8A8_UNORM; - } - - if (ISBITMASK(0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000)) - { - return DXGI_FORMAT_B8G8R8A8_UNORM; - } - - if (ISBITMASK(0x00ff0000, 0x0000ff00, 0x000000ff, 0)) - { - return DXGI_FORMAT_B8G8R8X8_UNORM; - } - - // No DXGI format maps to ISBITMASK(0x000000ff,0x0000ff00,0x00ff0000,0) aka D3DFMT_X8B8G8R8 - - // Note that many common DDS reader/writers (including D3DX) swap the - // the RED/BLUE masks for 10:10:10:2 formats. We assume - // below that the 'backwards' header mask is being used since it is most - // likely written by D3DX. The more robust solution is to use the 'DX10' - // header extension and specify the DXGI_FORMAT_R10G10B10A2_UNORM format directly - - // For 'correct' writers, this should be 0x000003ff,0x000ffc00,0x3ff00000 for RGB data - if (ISBITMASK(0x3ff00000, 0x000ffc00, 0x000003ff, 0xc0000000)) - { - return DXGI_FORMAT_R10G10B10A2_UNORM; - } - - // No DXGI format maps to ISBITMASK(0x000003ff,0x000ffc00,0x3ff00000,0xc0000000) aka D3DFMT_A2R10G10B10 - - if (ISBITMASK(0x0000ffff, 0xffff0000, 0, 0)) - { - return DXGI_FORMAT_R16G16_UNORM; - } - - if (ISBITMASK(0xffffffff, 0, 0, 0)) - { - // Only 32-bit color channel format in D3D9 was R32F - return DXGI_FORMAT_R32_FLOAT; // D3DX writes this out as a FourCC of 114 - } - break; - - case 24: - // No 24bpp DXGI formats aka D3DFMT_R8G8B8 - break; - - case 16: - if (ISBITMASK(0x7c00, 0x03e0, 0x001f, 0x8000)) - { - return DXGI_FORMAT_B5G5R5A1_UNORM; - } - if (ISBITMASK(0xf800, 0x07e0, 0x001f, 0)) - { - return DXGI_FORMAT_B5G6R5_UNORM; - } - - // No DXGI format maps to ISBITMASK(0x7c00,0x03e0,0x001f,0) aka D3DFMT_X1R5G5B5 - - if (ISBITMASK(0x0f00, 0x00f0, 0x000f, 0xf000)) - { - return DXGI_FORMAT_B4G4R4A4_UNORM; - } - - // NVTT versions 1.x wrote this as RGB instead of LUMINANCE - if (ISBITMASK(0x00ff, 0, 0, 0xff00)) - { - return DXGI_FORMAT_R8G8_UNORM; - } - if (ISBITMASK(0xffff, 0, 0, 0)) - { - return DXGI_FORMAT_R16_UNORM; - } - - // No DXGI format maps to ISBITMASK(0x0f00,0x00f0,0x000f,0) aka D3DFMT_X4R4G4B4 - - // No 3:3:2:8 or paletted DXGI formats aka D3DFMT_A8R3G3B2, D3DFMT_A8P8, etc. - break; - - case 8: - // NVTT versions 1.x wrote this as RGB instead of LUMINANCE - if (ISBITMASK(0xff, 0, 0, 0)) - { - return DXGI_FORMAT_R8_UNORM; - } - - // No 3:3:2 or paletted DXGI formats aka D3DFMT_R3G3B2, D3DFMT_P8 - break; - } - } - else if (ddpf.flags & DDS_LUMINANCE) - { - switch (ddpf.RGBBitCount) - { - case 16: - if (ISBITMASK(0xffff, 0, 0, 0)) - { - return DXGI_FORMAT_R16_UNORM; // D3DX10/11 writes this out as DX10 extension - } - if (ISBITMASK(0x00ff, 0, 0, 0xff00)) - { - return DXGI_FORMAT_R8G8_UNORM; // D3DX10/11 writes this out as DX10 extension - } - break; - - case 8: - if (ISBITMASK(0xff, 0, 0, 0)) - { - return DXGI_FORMAT_R8_UNORM; // D3DX10/11 writes this out as DX10 extension - } - - // No DXGI format maps to ISBITMASK(0x0f,0,0,0xf0) aka D3DFMT_A4L4 - - if (ISBITMASK(0x00ff, 0, 0, 0xff00)) - { - return DXGI_FORMAT_R8G8_UNORM; // Some DDS writers assume the bitcount should be 8 instead of 16 - } - break; - } - } - else if (ddpf.flags & DDS_ALPHA) - { - if (8 == ddpf.RGBBitCount) - { - return DXGI_FORMAT_A8_UNORM; - } - } - else if (ddpf.flags & DDS_BUMPDUDV) - { - switch (ddpf.RGBBitCount) - { - case 32: - if (ISBITMASK(0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000)) - { - return DXGI_FORMAT_R8G8B8A8_SNORM; // D3DX10/11 writes this out as DX10 extension - } - if (ISBITMASK(0x0000ffff, 0xffff0000, 0, 0)) - { - return DXGI_FORMAT_R16G16_SNORM; // D3DX10/11 writes this out as DX10 extension - } - - // No DXGI format maps to ISBITMASK(0x3ff00000, 0x000ffc00, 0x000003ff, 0xc0000000) aka D3DFMT_A2W10V10U10 - break; - - case 16: - if (ISBITMASK(0x00ff, 0xff00, 0, 0)) - { - return DXGI_FORMAT_R8G8_SNORM; // D3DX10/11 writes this out as DX10 extension - } - break; - } - - // No DXGI format maps to DDPF_BUMPLUMINANCE aka D3DFMT_L6V5U5, D3DFMT_X8L8V8U8 - } - else if (ddpf.flags & DDS_FOURCC) - { - if (MAKEFOURCC('D', 'X', 'T', '1') == ddpf.fourCC) - { - return DXGI_FORMAT_BC1_UNORM; - } - if (MAKEFOURCC('D', 'X', 'T', '3') == ddpf.fourCC) - { - return DXGI_FORMAT_BC2_UNORM; - } - if (MAKEFOURCC('D', 'X', 'T', '5') == ddpf.fourCC) - { - return DXGI_FORMAT_BC3_UNORM; - } - - // While pre-multiplied alpha isn't directly supported by the DXGI formats, - // they are basically the same as these BC formats so they can be mapped - if (MAKEFOURCC('D', 'X', 'T', '2') == ddpf.fourCC) - { - return DXGI_FORMAT_BC2_UNORM; - } - if (MAKEFOURCC('D', 'X', 'T', '4') == ddpf.fourCC) - { - return DXGI_FORMAT_BC3_UNORM; - } - - if (MAKEFOURCC('A', 'T', 'I', '1') == ddpf.fourCC) - { - return DXGI_FORMAT_BC4_UNORM; - } - if (MAKEFOURCC('B', 'C', '4', 'U') == ddpf.fourCC) - { - return DXGI_FORMAT_BC4_UNORM; - } - if (MAKEFOURCC('B', 'C', '4', 'S') == ddpf.fourCC) - { - return DXGI_FORMAT_BC4_SNORM; - } - - if (MAKEFOURCC('A', 'T', 'I', '2') == ddpf.fourCC) - { - return DXGI_FORMAT_BC5_UNORM; - } - if (MAKEFOURCC('B', 'C', '5', 'U') == ddpf.fourCC) - { - return DXGI_FORMAT_BC5_UNORM; - } - if (MAKEFOURCC('B', 'C', '5', 'S') == ddpf.fourCC) - { - return DXGI_FORMAT_BC5_SNORM; - } - - // BC6H and BC7 are written using the "DX10" extended header - - if (MAKEFOURCC('R', 'G', 'B', 'G') == ddpf.fourCC) - { - return DXGI_FORMAT_R8G8_B8G8_UNORM; - } - if (MAKEFOURCC('G', 'R', 'G', 'B') == ddpf.fourCC) - { - return DXGI_FORMAT_G8R8_G8B8_UNORM; - } - - if (MAKEFOURCC('Y', 'U', 'Y', '2') == ddpf.fourCC) - { - return DXGI_FORMAT_YUY2; - } - - // Check for D3DFORMAT enums being set here - switch (ddpf.fourCC) - { - case 36: // D3DFMT_A16B16G16R16 - return DXGI_FORMAT_R16G16B16A16_UNORM; - - case 110: // D3DFMT_Q16W16V16U16 - return DXGI_FORMAT_R16G16B16A16_SNORM; - - case 111: // D3DFMT_R16F - return DXGI_FORMAT_R16_FLOAT; - - case 112: // D3DFMT_G16R16F - return DXGI_FORMAT_R16G16_FLOAT; - - case 113: // D3DFMT_A16B16G16R16F - return DXGI_FORMAT_R16G16B16A16_FLOAT; - - case 114: // D3DFMT_R32F - return DXGI_FORMAT_R32_FLOAT; - - case 115: // D3DFMT_G32R32F - return DXGI_FORMAT_R32G32_FLOAT; - - case 116: // D3DFMT_A32B32G32R32F - return DXGI_FORMAT_R32G32B32A32_FLOAT; - - // No DXGI format maps to D3DFMT_CxV8U8 - } - } - - return DXGI_FORMAT_UNKNOWN; - } - -#undef ISBITMASK - - -//-------------------------------------------------------------------------------------- - DXGI_FORMAT MakeSRGB(_In_ DXGI_FORMAT format) noexcept - { - switch (format) - { - case DXGI_FORMAT_R8G8B8A8_UNORM: - return DXGI_FORMAT_R8G8B8A8_UNORM_SRGB; - - case DXGI_FORMAT_BC1_UNORM: - return DXGI_FORMAT_BC1_UNORM_SRGB; - - case DXGI_FORMAT_BC2_UNORM: - return DXGI_FORMAT_BC2_UNORM_SRGB; - - case DXGI_FORMAT_BC3_UNORM: - return DXGI_FORMAT_BC3_UNORM_SRGB; - - case DXGI_FORMAT_B8G8R8A8_UNORM: - return DXGI_FORMAT_B8G8R8A8_UNORM_SRGB; - - case DXGI_FORMAT_B8G8R8X8_UNORM: - return DXGI_FORMAT_B8G8R8X8_UNORM_SRGB; - - case DXGI_FORMAT_BC7_UNORM: - return DXGI_FORMAT_BC7_UNORM_SRGB; - - default: - return format; - } - } - - - //-------------------------------------------------------------------------------------- - inline bool IsDepthStencil(DXGI_FORMAT fmt) noexcept - { - switch (fmt) - { - case DXGI_FORMAT_R32G8X24_TYPELESS: - case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: - case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: - case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: - case DXGI_FORMAT_D32_FLOAT: - case DXGI_FORMAT_R24G8_TYPELESS: - case DXGI_FORMAT_D24_UNORM_S8_UINT: - case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: - case DXGI_FORMAT_X24_TYPELESS_G8_UINT: - case DXGI_FORMAT_D16_UNORM: - return true; - - default: - return false; - } - } - - - //-------------------------------------------------------------------------------------- - inline void AdjustPlaneResource( - _In_ DXGI_FORMAT fmt, - _In_ size_t height, - _In_ size_t slicePlane, - _Inout_ D3D12_SUBRESOURCE_DATA& res) noexcept - { - switch (fmt) - { - case DXGI_FORMAT_NV12: - case DXGI_FORMAT_P010: - case DXGI_FORMAT_P016: - if (!slicePlane) - { - // Plane 0 - res.SlicePitch = res.RowPitch * static_cast(height); - } - else - { - // Plane 1 - res.pData = reinterpret_cast(res.pData) + uintptr_t(res.RowPitch) * height; - res.SlicePitch = res.RowPitch * ((static_cast(height) + 1) >> 1); - } - break; - - case DXGI_FORMAT_NV11: - if (!slicePlane) - { - // Plane 0 - res.SlicePitch = res.RowPitch * static_cast(height); - } - else - { - // Plane 1 - res.pData = reinterpret_cast(res.pData) + uintptr_t(res.RowPitch) * height; - res.RowPitch = (res.RowPitch >> 1); - res.SlicePitch = res.RowPitch * static_cast(height); - } - break; - } - } - - - //-------------------------------------------------------------------------------------- - HRESULT FillInitData(_In_ size_t width, - _In_ size_t height, - _In_ size_t depth, - _In_ size_t mipCount, - _In_ size_t arraySize, - _In_ size_t numberOfPlanes, - _In_ DXGI_FORMAT format, - _In_ size_t maxsize, - _In_ size_t bitSize, - _In_reads_bytes_(bitSize) const uint8_t* bitData, - _Out_ size_t& twidth, - _Out_ size_t& theight, - _Out_ size_t& tdepth, - _Out_ size_t& skipMip, - std::vector& initData) - { - if (!bitData) - { - return E_POINTER; - } - - skipMip = 0; - twidth = 0; - theight = 0; - tdepth = 0; - - size_t NumBytes = 0; - size_t RowBytes = 0; - const uint8_t* pEndBits = bitData + bitSize; - - initData.clear(); - - for (size_t p = 0; p < numberOfPlanes; ++p) - { - const uint8_t* pSrcBits = bitData; - - for (size_t j = 0; j < arraySize; j++) - { - size_t w = width; - size_t h = height; - size_t d = depth; - for (size_t i = 0; i < mipCount; i++) - { - HRESULT hr = GetSurfaceInfo(w, h, format, &NumBytes, &RowBytes, nullptr); - if (FAILED(hr)) - return hr; - - if (NumBytes > UINT32_MAX || RowBytes > UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - if ((mipCount <= 1) || !maxsize || (w <= maxsize && h <= maxsize && d <= maxsize)) - { - if (!twidth) - { - twidth = w; - theight = h; - tdepth = d; - } - - D3D12_SUBRESOURCE_DATA res = - { - pSrcBits, - static_cast(RowBytes), - static_cast(NumBytes) - }; - - AdjustPlaneResource(format, h, p, res); - - initData.emplace_back(res); - } - else if (!j) - { - // Count number of skipped mipmaps (first item only) - ++skipMip; - } - - if (pSrcBits + (NumBytes*d) > pEndBits) - { - return HRESULT_E_HANDLE_EOF; - } - - pSrcBits += NumBytes * d; - - w = w >> 1; - h = h >> 1; - d = d >> 1; - if (w == 0) - { - w = 1; - } - if (h == 0) - { - h = 1; - } - if (d == 0) - { - d = 1; - } - } - } - } - - return initData.empty() ? E_FAIL : S_OK; - } - - - //-------------------------------------------------------------------------------------- - HRESULT CreateTextureResource( - _In_ ID3D12Device* d3dDevice, - D3D12_RESOURCE_DIMENSION resDim, - size_t width, - size_t height, - size_t depth, - size_t mipCount, - size_t arraySize, - DXGI_FORMAT format, - D3D12_RESOURCE_FLAGS resFlags, - DDS_LOADER_FLAGS loadFlags, - _Outptr_ ID3D12Resource** texture) noexcept - { - if (!d3dDevice) - return E_POINTER; - - HRESULT hr = E_FAIL; - - if (loadFlags & DDS_LOADER_FORCE_SRGB) - { - format = MakeSRGB(format); - } - - D3D12_RESOURCE_DESC desc = {}; - desc.Width = static_cast(width); - desc.Height = static_cast(height); - desc.MipLevels = static_cast(mipCount); - desc.DepthOrArraySize = (resDim == D3D12_RESOURCE_DIMENSION_TEXTURE3D) ? static_cast(depth) : static_cast(arraySize); - desc.Format = format; - desc.Flags = resFlags; - desc.SampleDesc.Count = 1; - desc.SampleDesc.Quality = 0; - desc.Dimension = resDim; - - const CD3DX12_HEAP_PROPERTIES defaultHeapProperties(D3D12_HEAP_TYPE_DEFAULT); - - hr = d3dDevice->CreateCommittedResource( - &defaultHeapProperties, - D3D12_HEAP_FLAG_NONE, - &desc, - D3D12_RESOURCE_STATE_COPY_DEST, - nullptr, - IID_ID3D12Resource, reinterpret_cast(texture)); - if (SUCCEEDED(hr)) - { - assert(texture != nullptr && *texture != nullptr); - _Analysis_assume_(texture != nullptr && *texture != nullptr); - - SetDebugObjectName(*texture, L"DDSTextureLoader"); - } - - return hr; - } - - //-------------------------------------------------------------------------------------- - HRESULT CreateTextureFromDDS(_In_ ID3D12Device* d3dDevice, - _In_ const DDS_HEADER* header, - _In_reads_bytes_(bitSize) const uint8_t* bitData, - size_t bitSize, - size_t maxsize, - D3D12_RESOURCE_FLAGS resFlags, - DDS_LOADER_FLAGS loadFlags, - _Outptr_ ID3D12Resource** texture, - std::vector& subresources, - _Out_opt_ bool* outIsCubeMap) noexcept(false) - { - HRESULT hr = S_OK; - - const UINT width = header->width; - UINT height = header->height; - UINT depth = header->depth; - - D3D12_RESOURCE_DIMENSION resDim = D3D12_RESOURCE_DIMENSION_UNKNOWN; - UINT arraySize = 1; - DXGI_FORMAT format = DXGI_FORMAT_UNKNOWN; - bool isCubeMap = false; - - size_t mipCount = header->mipMapCount; - if (0 == mipCount) - { - mipCount = 1; - } - - if ((header->ddspf.flags & DDS_FOURCC) && - (MAKEFOURCC('D', 'X', '1', '0') == header->ddspf.fourCC)) - { - auto d3d10ext = reinterpret_cast(reinterpret_cast(header) + sizeof(DDS_HEADER)); - - arraySize = d3d10ext->arraySize; - if (arraySize == 0) - { - return HRESULT_E_INVALID_DATA; - } - - switch (d3d10ext->dxgiFormat) - { - case DXGI_FORMAT_AI44: - case DXGI_FORMAT_IA44: - case DXGI_FORMAT_P8: - case DXGI_FORMAT_A8P8: - return HRESULT_E_NOT_SUPPORTED; - - default: - if (BitsPerPixel(d3d10ext->dxgiFormat) == 0) - { - return HRESULT_E_NOT_SUPPORTED; - } - } - - format = d3d10ext->dxgiFormat; - - switch (d3d10ext->resourceDimension) - { - case D3D12_RESOURCE_DIMENSION_TEXTURE1D: - // D3DX writes 1D textures with a fixed Height of 1 - if ((header->flags & DDS_HEIGHT) && height != 1) - { - return HRESULT_E_INVALID_DATA; - } - height = depth = 1; - break; - - case D3D12_RESOURCE_DIMENSION_TEXTURE2D: - if (d3d10ext->miscFlag & 0x4 /* RESOURCE_MISC_TEXTURECUBE */) - { - arraySize *= 6; - isCubeMap = true; - } - depth = 1; - break; - - case D3D12_RESOURCE_DIMENSION_TEXTURE3D: - if (!(header->flags & DDS_HEADER_FLAGS_VOLUME)) - { - return HRESULT_E_INVALID_DATA; - } - - if (arraySize > 1) - { - return HRESULT_E_NOT_SUPPORTED; - } - break; - - default: - return HRESULT_E_NOT_SUPPORTED; - } - - resDim = static_cast(d3d10ext->resourceDimension); - } - else - { - format = GetDXGIFormat(header->ddspf); - - if (format == DXGI_FORMAT_UNKNOWN) - { - return HRESULT_E_NOT_SUPPORTED; - } - - if (header->flags & DDS_HEADER_FLAGS_VOLUME) - { - resDim = D3D12_RESOURCE_DIMENSION_TEXTURE3D; - } - else - { - if (header->caps2 & DDS_CUBEMAP) - { - // We require all six faces to be defined - if ((header->caps2 & DDS_CUBEMAP_ALLFACES) != DDS_CUBEMAP_ALLFACES) - { - return HRESULT_E_NOT_SUPPORTED; - } - - arraySize = 6; - isCubeMap = true; - } - - depth = 1; - resDim = D3D12_RESOURCE_DIMENSION_TEXTURE2D; - - // Note there's no way for a legacy Direct3D 9 DDS to express a '1D' texture - } - - assert(BitsPerPixel(format) != 0); - } - - // Bound sizes (for security purposes we don't trust DDS file metadata larger than the Direct3D hardware requirements) - if (mipCount > D3D12_REQ_MIP_LEVELS) - { - return HRESULT_E_NOT_SUPPORTED; - } - - switch (resDim) - { - case D3D12_RESOURCE_DIMENSION_TEXTURE1D: - if ((arraySize > D3D12_REQ_TEXTURE1D_ARRAY_AXIS_DIMENSION) || - (width > D3D12_REQ_TEXTURE1D_U_DIMENSION)) - { - return HRESULT_E_NOT_SUPPORTED; - } - break; - - case D3D12_RESOURCE_DIMENSION_TEXTURE2D: - if (isCubeMap) - { - // This is the right bound because we set arraySize to (NumCubes*6) above - if ((arraySize > D3D12_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION) || - (width > D3D12_REQ_TEXTURECUBE_DIMENSION) || - (height > D3D12_REQ_TEXTURECUBE_DIMENSION)) - { - return HRESULT_E_NOT_SUPPORTED; - } - } - else if ((arraySize > D3D12_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION) || - (width > D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION) || - (height > D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION)) - { - return HRESULT_E_NOT_SUPPORTED; - } - break; - - case D3D12_RESOURCE_DIMENSION_TEXTURE3D: - if ((arraySize > 1) || - (width > D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION) || - (height > D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION) || - (depth > D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION)) - { - return HRESULT_E_NOT_SUPPORTED; - } - break; - - default: - return HRESULT_E_NOT_SUPPORTED; - } - - const UINT numberOfPlanes = D3D12GetFormatPlaneCount(d3dDevice, format); - if (!numberOfPlanes) - return E_INVALIDARG; - - if ((numberOfPlanes > 1) && IsDepthStencil(format)) - { - // DirectX 12 uses planes for stencil, DirectX 11 does not - return HRESULT_E_NOT_SUPPORTED; - } - - if (outIsCubeMap != nullptr) - { - *outIsCubeMap = isCubeMap; - } - - // Create the texture - size_t numberOfResources = (resDim == D3D12_RESOURCE_DIMENSION_TEXTURE3D) - ? 1 : arraySize; - numberOfResources *= mipCount; - numberOfResources *= numberOfPlanes; - - if (numberOfResources > D3D12_REQ_SUBRESOURCES) - return E_INVALIDARG; - - subresources.reserve(numberOfResources); - - size_t skipMip = 0; - size_t twidth = 0; - size_t theight = 0; - size_t tdepth = 0; - hr = FillInitData(width, height, depth, mipCount, arraySize, - numberOfPlanes, format, - maxsize, bitSize, bitData, - twidth, theight, tdepth, skipMip, subresources); - - if (SUCCEEDED(hr)) - { - size_t reservedMips = mipCount; - if (loadFlags & DDS_LOADER_MIP_RESERVE) - { - reservedMips = std::min(D3D12_REQ_MIP_LEVELS, - CountMips(width, height)); - } - - hr = CreateTextureResource(d3dDevice, resDim, twidth, theight, tdepth, reservedMips - skipMip, arraySize, - format, resFlags, loadFlags, texture); - - if (FAILED(hr) && !maxsize && (mipCount > 1)) - { - subresources.clear(); - - maxsize = static_cast( - (resDim == D3D12_RESOURCE_DIMENSION_TEXTURE3D) - ? D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION - : D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION); - - hr = FillInitData(width, height, depth, mipCount, arraySize, - numberOfPlanes, format, - maxsize, bitSize, bitData, - twidth, theight, tdepth, skipMip, subresources); - if (SUCCEEDED(hr)) - { - hr = CreateTextureResource(d3dDevice, resDim, twidth, theight, tdepth, mipCount - skipMip, arraySize, - format, resFlags, loadFlags, texture); - } - } - } - - if (FAILED(hr)) - { - subresources.clear(); - } - - return hr; - } - - //-------------------------------------------------------------------------------------- - DDS_ALPHA_MODE GetAlphaMode(_In_ const DDS_HEADER* header) noexcept - { - if (header->ddspf.flags & DDS_FOURCC) - { - if (MAKEFOURCC('D', 'X', '1', '0') == header->ddspf.fourCC) - { - auto d3d10ext = reinterpret_cast(reinterpret_cast(header) + sizeof(DDS_HEADER)); - auto const mode = static_cast(d3d10ext->miscFlags2 & DDS_MISC_FLAGS2_ALPHA_MODE_MASK); - switch (mode) - { - case DDS_ALPHA_MODE_STRAIGHT: - case DDS_ALPHA_MODE_PREMULTIPLIED: - case DDS_ALPHA_MODE_OPAQUE: - case DDS_ALPHA_MODE_CUSTOM: - return mode; - - case DDS_ALPHA_MODE_UNKNOWN: - default: - break; - } - } - else if ((MAKEFOURCC('D', 'X', 'T', '2') == header->ddspf.fourCC) - || (MAKEFOURCC('D', 'X', 'T', '4') == header->ddspf.fourCC)) - { - return DDS_ALPHA_MODE_PREMULTIPLIED; - } - } - - return DDS_ALPHA_MODE_UNKNOWN; - } - - //-------------------------------------------------------------------------------------- - void SetDebugTextureInfo( - _In_z_ const wchar_t* fileName, - _In_ ID3D12Resource** texture) noexcept - { - #if !defined(NO_D3D12_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) ) - if (texture && *texture) - { - const wchar_t* pstrName = wcsrchr(fileName, '\\'); - if (!pstrName) - { - pstrName = fileName; - } - else - { - pstrName++; - } - - (*texture)->SetName(pstrName); - } - #else - UNREFERENCED_PARAMETER(fileName); - UNREFERENCED_PARAMETER(texture); - #endif - } -} // anonymous namespace - - -//-------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::LoadDDSTextureFromMemory( - ID3D12Device* d3dDevice, - const uint8_t* ddsData, - size_t ddsDataSize, - ID3D12Resource** texture, - std::vector& subresources, - size_t maxsize, - DDS_ALPHA_MODE* alphaMode, - bool* isCubeMap) -{ - return LoadDDSTextureFromMemoryEx( - d3dDevice, - ddsData, - ddsDataSize, - maxsize, - D3D12_RESOURCE_FLAG_NONE, - DDS_LOADER_DEFAULT, - texture, - subresources, - alphaMode, - isCubeMap); -} - - -_Use_decl_annotations_ -HRESULT DirectX::LoadDDSTextureFromMemoryEx( - ID3D12Device* d3dDevice, - const uint8_t* ddsData, - size_t ddsDataSize, - size_t maxsize, - D3D12_RESOURCE_FLAGS resFlags, - DDS_LOADER_FLAGS loadFlags, - ID3D12Resource** texture, - std::vector& subresources, - DDS_ALPHA_MODE* alphaMode, - bool* isCubeMap) -{ - if (texture) - { - *texture = nullptr; - } - if (alphaMode) - { - *alphaMode = DDS_ALPHA_MODE_UNKNOWN; - } - if (isCubeMap) - { - *isCubeMap = false; - } - - if (!d3dDevice || !ddsData || !texture) - { - return E_INVALIDARG; - } - - // Validate DDS file in memory - const DDS_HEADER* header = nullptr; - const uint8_t* bitData = nullptr; - size_t bitSize = 0; - - HRESULT hr = LoadTextureDataFromMemory(ddsData, - ddsDataSize, - &header, - &bitData, - &bitSize - ); - if (FAILED(hr)) - { - return hr; - } - - hr = CreateTextureFromDDS(d3dDevice, - header, bitData, bitSize, maxsize, - resFlags, loadFlags, - texture, subresources, isCubeMap); - if (SUCCEEDED(hr)) - { - if (texture && *texture) - { - SetDebugObjectName(*texture, L"DDSTextureLoader"); - } - - if (alphaMode) - *alphaMode = GetAlphaMode(header); - } - - return hr; -} - - -//-------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::LoadDDSTextureFromFile( - ID3D12Device* d3dDevice, - const wchar_t* fileName, - ID3D12Resource** texture, - std::unique_ptr& ddsData, - std::vector& subresources, - size_t maxsize, - DDS_ALPHA_MODE* alphaMode, - bool* isCubeMap) -{ - return LoadDDSTextureFromFileEx( - d3dDevice, - fileName, - maxsize, - D3D12_RESOURCE_FLAG_NONE, - DDS_LOADER_DEFAULT, - texture, - ddsData, - subresources, - alphaMode, - isCubeMap); -} - -_Use_decl_annotations_ -HRESULT DirectX::LoadDDSTextureFromFileEx( - ID3D12Device* d3dDevice, - const wchar_t* fileName, - size_t maxsize, - D3D12_RESOURCE_FLAGS resFlags, - DDS_LOADER_FLAGS loadFlags, - ID3D12Resource** texture, - std::unique_ptr& ddsData, - std::vector& subresources, - DDS_ALPHA_MODE* alphaMode, - bool* isCubeMap) -{ - if (texture) - { - *texture = nullptr; - } - if (alphaMode) - { - *alphaMode = DDS_ALPHA_MODE_UNKNOWN; - } - if (isCubeMap) - { - *isCubeMap = false; - } - - if (!d3dDevice || !fileName || !texture) - { - return E_INVALIDARG; - } - - const DDS_HEADER* header = nullptr; - const uint8_t* bitData = nullptr; - size_t bitSize = 0; - - HRESULT hr = LoadTextureDataFromFile(fileName, - ddsData, - &header, - &bitData, - &bitSize - ); - if (FAILED(hr)) - { - return hr; - } - - hr = CreateTextureFromDDS(d3dDevice, - header, bitData, bitSize, maxsize, - resFlags, loadFlags, - texture, subresources, isCubeMap); - - if (SUCCEEDED(hr)) - { - SetDebugTextureInfo(fileName, texture); - - if (alphaMode) - *alphaMode = GetAlphaMode(header); - } - - return hr; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSTextureLoader/DDSTextureLoader12.h b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSTextureLoader/DDSTextureLoader12.h deleted file mode 100644 index d6c5dc9..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSTextureLoader/DDSTextureLoader12.h +++ /dev/null @@ -1,124 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: DDSTextureLoader12.h -// -// Functions for loading a DDS texture and creating a Direct3D runtime resource for it -// -// Note these functions are useful as a light-weight runtime loader for DDS files. For -// a full-featured DDS file reader, writer, and texture processing pipeline see -// the 'Texconv' sample and the 'DirectXTex' library. -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -// http://go.microsoft.com/fwlink/?LinkID=615561 -//-------------------------------------------------------------------------------------- - -#pragma once - -#ifdef __MINGW32__ -#include -#endif - -#ifndef _WIN32 -#include -#include -#endif - -#if !defined(_WIN32) || defined(USING_DIRECTX_HEADERS) -#include -#include -#else -#include -#pragma comment(lib,"dxguid.lib") -#endif - -#include -#include -#include -#include - - -namespace DirectX -{ -#ifndef DDS_ALPHA_MODE_DEFINED -#define DDS_ALPHA_MODE_DEFINED - enum DDS_ALPHA_MODE : uint32_t - { - DDS_ALPHA_MODE_UNKNOWN = 0, - DDS_ALPHA_MODE_STRAIGHT = 1, - DDS_ALPHA_MODE_PREMULTIPLIED = 2, - DDS_ALPHA_MODE_OPAQUE = 3, - DDS_ALPHA_MODE_CUSTOM = 4, - }; - -#endif - -#ifndef DDS_LOADER_FLAGS_DEFINED -#define DDS_LOADER_FLAGS_DEFINED - - enum DDS_LOADER_FLAGS : uint32_t - { - DDS_LOADER_DEFAULT = 0, - DDS_LOADER_FORCE_SRGB = 0x1, - DDS_LOADER_MIP_RESERVE = 0x8, - }; - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-dynamic-exception-spec" -#endif - - DEFINE_ENUM_FLAG_OPERATORS(DDS_LOADER_FLAGS); - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif -#endif - - // Standard version - HRESULT __cdecl LoadDDSTextureFromMemory( - _In_ ID3D12Device* d3dDevice, - _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, - size_t ddsDataSize, - _Outptr_ ID3D12Resource** texture, - std::vector& subresources, - size_t maxsize = 0, - _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr, - _Out_opt_ bool* isCubeMap = nullptr); - - HRESULT __cdecl LoadDDSTextureFromFile( - _In_ ID3D12Device* d3dDevice, - _In_z_ const wchar_t* szFileName, - _Outptr_ ID3D12Resource** texture, - std::unique_ptr& ddsData, - std::vector& subresources, - size_t maxsize = 0, - _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr, - _Out_opt_ bool* isCubeMap = nullptr); - - // Extended version - HRESULT __cdecl LoadDDSTextureFromMemoryEx( - _In_ ID3D12Device* d3dDevice, - _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, - size_t ddsDataSize, - size_t maxsize, - D3D12_RESOURCE_FLAGS resFlags, - DDS_LOADER_FLAGS loadFlags, - _Outptr_ ID3D12Resource** texture, - std::vector& subresources, - _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr, - _Out_opt_ bool* isCubeMap = nullptr); - - HRESULT __cdecl LoadDDSTextureFromFileEx( - _In_ ID3D12Device* d3dDevice, - _In_z_ const wchar_t* szFileName, - size_t maxsize, - D3D12_RESOURCE_FLAGS resFlags, - DDS_LOADER_FLAGS loadFlags, - _Outptr_ ID3D12Resource** texture, - std::unique_ptr& ddsData, - std::vector& subresources, - _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr, - _Out_opt_ bool* isCubeMap = nullptr); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSTextureLoader/DDSTextureLoader9.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSTextureLoader/DDSTextureLoader9.cpp deleted file mode 100644 index 2d532ee..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSTextureLoader/DDSTextureLoader9.cpp +++ /dev/null @@ -1,1572 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: DDSTextureLoader9.cpp -// -// Functions for loading a DDS texture and creating a Direct3D runtime resource for it -// -// Note these functions are useful as a light-weight runtime loader for DDS files. For -// a full-featured DDS file reader, writer, and texture processing pipeline see -// the 'Texconv' sample and the 'DirectXTex' library. -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -// http://go.microsoft.com/fwlink/?LinkId=248929 -//-------------------------------------------------------------------------------------- - -#include "DDSTextureLoader9.h" - -#include - -#include -#include -#include -#include -#include - -#include - -#ifdef _MSC_VER -// Off by default warnings -#pragma warning(disable : 4619 4616 4623 4626 5027) -// C4619/4616 #pragma warning warnings -// C4623 default constructor was implicitly defined as deleted -// C4626 assignment operator was implicitly defined as deleted -// C5027 move assignment operator was implicitly defined as deleted -#endif - -#ifdef __clang__ -#pragma clang diagnostic ignored "-Wcovered-switch-default" -#pragma clang diagnostic ignored "-Wswitch-enum" -#endif - -using namespace DirectX; -using Microsoft::WRL::ComPtr; - -//-------------------------------------------------------------------------------------- -// Macros -//-------------------------------------------------------------------------------------- -#ifndef MAKEFOURCC -#define MAKEFOURCC(ch0, ch1, ch2, ch3) \ - ((uint32_t)(uint8_t)(ch0) | ((uint32_t)(uint8_t)(ch1) << 8) | \ - ((uint32_t)(uint8_t)(ch2) << 16) | ((uint32_t)(uint8_t)(ch3) << 24 )) -#endif /* defined(MAKEFOURCC) */ - -//-------------------------------------------------------------------------------------- -// DDS file structure definitions -// -// See DDS.h in the 'Texconv' sample and the 'DirectXTex' library -//-------------------------------------------------------------------------------------- -#pragma pack(push,1) - -constexpr uint32_t DDS_MAGIC = 0x20534444; // "DDS " - -struct DDS_PIXELFORMAT -{ - uint32_t size; - uint32_t flags; - uint32_t fourCC; - uint32_t RGBBitCount; - uint32_t RBitMask; - uint32_t GBitMask; - uint32_t BBitMask; - uint32_t ABitMask; -}; - -#define DDS_FOURCC 0x00000004 // DDPF_FOURCC -#define DDS_RGB 0x00000040 // DDPF_RGB -#define DDS_LUMINANCE 0x00020000 // DDPF_LUMINANCE -#define DDS_ALPHA 0x00000002 // DDPF_ALPHA -#define DDS_BUMPDUDV 0x00080000 // DDPF_BUMPDUDV -#define DDS_BUMPLUMINANCE 0x00040000 // DDPF_BUMPLUMINANCE - -#define DDS_HEADER_FLAGS_VOLUME 0x00800000 // DDSD_DEPTH - -#define DDS_CUBEMAP_POSITIVEX 0x00000600 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEX -#define DDS_CUBEMAP_NEGATIVEX 0x00000a00 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEX -#define DDS_CUBEMAP_POSITIVEY 0x00001200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEY -#define DDS_CUBEMAP_NEGATIVEY 0x00002200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEY -#define DDS_CUBEMAP_POSITIVEZ 0x00004200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEZ -#define DDS_CUBEMAP_NEGATIVEZ 0x00008200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEZ - -#define DDS_CUBEMAP_ALLFACES ( DDS_CUBEMAP_POSITIVEX | DDS_CUBEMAP_NEGATIVEX |\ - DDS_CUBEMAP_POSITIVEY | DDS_CUBEMAP_NEGATIVEY |\ - DDS_CUBEMAP_POSITIVEZ | DDS_CUBEMAP_NEGATIVEZ ) - -#define DDS_CUBEMAP 0x00000200 // DDSCAPS2_CUBEMAP - -struct DDS_HEADER -{ - uint32_t size; - uint32_t flags; - uint32_t height; - uint32_t width; - uint32_t pitchOrLinearSize; - uint32_t depth; // only if DDS_HEADER_FLAGS_VOLUME is set in flags - uint32_t mipMapCount; - uint32_t reserved1[11]; - DDS_PIXELFORMAT ddspf; - uint32_t caps; - uint32_t caps2; - uint32_t caps3; - uint32_t caps4; - uint32_t reserved2; -}; - -#pragma pack(pop) - -//-------------------------------------------------------------------------------------- -namespace -{ - struct handle_closer { void operator()(HANDLE h) noexcept { if (h) CloseHandle(h); } }; - - using ScopedHandle = std::unique_ptr; - - inline HANDLE safe_handle(HANDLE h) noexcept { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; } - - //-------------------------------------------------------------------------------------- - HRESULT LoadTextureDataFromMemory( - _In_reads_(ddsDataSize) const uint8_t* ddsData, - size_t ddsDataSize, - const DDS_HEADER** header, - const uint8_t** bitData, - size_t* bitSize) noexcept - { - if (!header || !bitData || !bitSize) - { - return E_POINTER; - } - - *bitSize = 0; - - if (ddsDataSize > UINT32_MAX) - { - return E_FAIL; - } - - if (ddsDataSize < (sizeof(uint32_t) + sizeof(DDS_HEADER))) - { - return E_FAIL; - } - - // DDS files always start with the same magic number ("DDS ") - auto const dwMagicNumber = *reinterpret_cast(ddsData); - if (dwMagicNumber != DDS_MAGIC) - { - return E_FAIL; - } - - auto hdr = reinterpret_cast(ddsData + sizeof(uint32_t)); - - // Verify header to validate DDS file - if (hdr->size != sizeof(DDS_HEADER) || - hdr->ddspf.size != sizeof(DDS_PIXELFORMAT)) - { - return E_FAIL; - } - - // Check for DX10 extension - if ((hdr->ddspf.flags & DDS_FOURCC) && - (MAKEFOURCC('D', 'X', '1', '0') == hdr->ddspf.fourCC)) - { - // We don't support the new DX10 header for Direct3D 9 - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - - // setup the pointers in the process request - *header = hdr; - auto offset = sizeof(uint32_t) + sizeof(DDS_HEADER); - *bitData = ddsData + offset; - *bitSize = ddsDataSize - offset; - - return S_OK; - } - - - //-------------------------------------------------------------------------------------- - HRESULT LoadTextureDataFromFile( - _In_z_ const wchar_t* fileName, - std::unique_ptr& ddsData, - const DDS_HEADER** header, - const uint8_t** bitData, - size_t* bitSize) noexcept - { - if (!header || !bitData || !bitSize) - { - return E_POINTER; - } - - *bitSize = 0; - - // open the file - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(fileName, - GENERIC_READ, - FILE_SHARE_READ, - OPEN_EXISTING, - nullptr))); - #else - ScopedHandle hFile(safe_handle(CreateFileW(fileName, - GENERIC_READ, - FILE_SHARE_READ, - nullptr, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - nullptr))); - #endif - - if (!hFile) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - // Get the file size - FILE_STANDARD_INFO fileInfo; - if (!GetFileInformationByHandleEx(hFile.get(), FileStandardInfo, &fileInfo, sizeof(fileInfo))) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - // File is too big for 32-bit allocation, so reject read - if (fileInfo.EndOfFile.HighPart > 0) - { - return E_FAIL; - } - - // Need at least enough data to fill the header and magic number to be a valid DDS - if (fileInfo.EndOfFile.LowPart < (sizeof(uint32_t) + sizeof(DDS_HEADER))) - { - return E_FAIL; - } - - // create enough space for the file data - ddsData.reset(new (std::nothrow) uint8_t[fileInfo.EndOfFile.LowPart]); - if (!ddsData) - { - return E_OUTOFMEMORY; - } - - // read the data in - DWORD bytesRead = 0; - if (!ReadFile(hFile.get(), - ddsData.get(), - fileInfo.EndOfFile.LowPart, - &bytesRead, - nullptr - )) - { - ddsData.reset(); - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesRead < fileInfo.EndOfFile.LowPart) - { - ddsData.reset(); - return E_FAIL; - } - - // DDS files always start with the same magic number ("DDS ") - auto const dwMagicNumber = *reinterpret_cast(ddsData.get()); - if (dwMagicNumber != DDS_MAGIC) - { - ddsData.reset(); - return E_FAIL; - } - - auto hdr = reinterpret_cast(ddsData.get() + sizeof(uint32_t)); - - // Verify header to validate DDS file - if (hdr->size != sizeof(DDS_HEADER) || - hdr->ddspf.size != sizeof(DDS_PIXELFORMAT)) - { - ddsData.reset(); - return E_FAIL; - } - - // Check for DX10 extension - if ((hdr->ddspf.flags & DDS_FOURCC) && - (MAKEFOURCC('D', 'X', '1', '0') == hdr->ddspf.fourCC)) - { - // We don't support the new DX10 header for Direct3D 9 - ddsData.reset(); - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - - // setup the pointers in the process request - *header = hdr; - auto offset = sizeof(uint32_t) + sizeof(DDS_HEADER); - *bitData = ddsData.get() + offset; - *bitSize = fileInfo.EndOfFile.LowPart - offset; - - return S_OK; - } - - - //-------------------------------------------------------------------------------------- - // Return the BPP for a particular format - //-------------------------------------------------------------------------------------- - size_t BitsPerPixel(_In_ D3DFORMAT fmt) noexcept - { - switch (static_cast(fmt)) - { - case D3DFMT_A32B32G32R32F: - return 128; - - case D3DFMT_A16B16G16R16: - case D3DFMT_Q16W16V16U16: - case D3DFMT_A16B16G16R16F: - case D3DFMT_G32R32F: - return 64; - - case D3DFMT_A8R8G8B8: - case D3DFMT_X8R8G8B8: - case D3DFMT_A2B10G10R10: - case D3DFMT_A8B8G8R8: - case D3DFMT_X8B8G8R8: - case D3DFMT_G16R16: - case D3DFMT_A2R10G10B10: - case D3DFMT_Q8W8V8U8: - case D3DFMT_V16U16: - case D3DFMT_X8L8V8U8: - case D3DFMT_A2W10V10U10: - case D3DFMT_D32: - case D3DFMT_D24S8: - case D3DFMT_D24X8: - case D3DFMT_D24X4S4: - case D3DFMT_D32F_LOCKABLE: - case D3DFMT_D24FS8: - case D3DFMT_INDEX32: - case D3DFMT_G16R16F: - case D3DFMT_R32F: - #if !defined(D3D_DISABLE_9EX) - case D3DFMT_D32_LOCKABLE: - #endif - return 32; - - case D3DFMT_R8G8B8: - return 24; - - case D3DFMT_A4R4G4B4: - case D3DFMT_X4R4G4B4: - case D3DFMT_R5G6B5: - case D3DFMT_L16: - case D3DFMT_A8L8: - case D3DFMT_X1R5G5B5: - case D3DFMT_A1R5G5B5: - case D3DFMT_A8R3G3B2: - case D3DFMT_V8U8: - case D3DFMT_CxV8U8: - case D3DFMT_L6V5U5: - case D3DFMT_G8R8_G8B8: - case D3DFMT_R8G8_B8G8: - case D3DFMT_D16_LOCKABLE: - case D3DFMT_D15S1: - case D3DFMT_D16: - case D3DFMT_INDEX16: - case D3DFMT_R16F: - case D3DFMT_YUY2: - // From DX docs, reference/d3d/enums/d3dformat.asp - // (note how it says that D3DFMT_R8G8_B8G8 is "A 16-bit packed RGB format analogous to UYVY (U0Y0, V0Y1, U2Y2, and so on)") - case D3DFMT_UYVY: - return 16; - - case D3DFMT_R3G3B2: - case D3DFMT_A8: - case D3DFMT_A8P8: - case D3DFMT_P8: - case D3DFMT_L8: - case D3DFMT_A4L4: - case D3DFMT_DXT2: - case D3DFMT_DXT3: - case D3DFMT_DXT4: - case D3DFMT_DXT5: - // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directshow/htm/directxvideoaccelerationdxvavideosubtypes.asp - case MAKEFOURCC('A', 'I', '4', '4'): - case MAKEFOURCC('I', 'A', '4', '4'): - #if !defined(D3D_DISABLE_9EX) - case D3DFMT_S8_LOCKABLE: - #endif - return 8; - - case D3DFMT_DXT1: - return 4; - - case MAKEFOURCC('Y', 'V', '1', '2'): - return 12; - - #if !defined(D3D_DISABLE_9EX) - case D3DFMT_A1: - return 1; - #endif - - default: - return 0; - } - } - - - //-------------------------------------------------------------------------------------- - // Get surface information for a particular format - //-------------------------------------------------------------------------------------- - HRESULT GetSurfaceInfo( - _In_ size_t width, - _In_ size_t height, - _In_ D3DFORMAT fmt, - size_t* outNumBytes, - _Out_opt_ size_t* outRowBytes, - _Out_opt_ size_t* outNumRows) noexcept - { - uint64_t numBytes = 0; - uint64_t rowBytes = 0; - uint64_t numRows = 0; - - bool bc = false; - bool packed = false; - size_t bpe = 0; - switch (static_cast(fmt)) - { - case D3DFMT_DXT1: - bc = true; - bpe = 8; - break; - - case D3DFMT_DXT2: - case D3DFMT_DXT3: - case D3DFMT_DXT4: - case D3DFMT_DXT5: - bc = true; - bpe = 16; - break; - - case D3DFMT_R8G8_B8G8: - case D3DFMT_G8R8_G8B8: - case D3DFMT_UYVY: - case D3DFMT_YUY2: - packed = true; - bpe = 4; - break; - - default: - break; - } - - if (bc) - { - uint64_t numBlocksWide = 0; - if (width > 0) - { - numBlocksWide = std::max(1u, (uint64_t(width) + 3u) / 4u); - } - uint64_t numBlocksHigh = 0; - if (height > 0) - { - numBlocksHigh = std::max(1u, (uint64_t(height) + 3u) / 4u); - } - rowBytes = numBlocksWide * bpe; - numRows = numBlocksHigh; - numBytes = rowBytes * numBlocksHigh; - } - else if (packed) - { - rowBytes = ((uint64_t(width) + 1u) >> 1) * bpe; - numRows = uint64_t(height); - numBytes = rowBytes * height; - } - else - { - const size_t bpp = BitsPerPixel(fmt); - if (!bpp) - return E_INVALIDARG; - - rowBytes = (uint64_t(width) * bpp + 7u) / 8u; // round up to nearest byte - numRows = uint64_t(height); - numBytes = rowBytes * height; - } - - #if defined(_M_IX86) || defined(_M_ARM) || defined(_M_HYBRID_X86_ARM64) - static_assert(sizeof(size_t) == 4, "Not a 32-bit platform!"); - if (numBytes > UINT32_MAX || rowBytes > UINT32_MAX || numRows > UINT32_MAX) - return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); - #else - static_assert(sizeof(size_t) == 8, "Not a 64-bit platform!"); - #endif - - if (outNumBytes) - { - *outNumBytes = static_cast(numBytes); - } - if (outRowBytes) - { - *outRowBytes = static_cast(rowBytes); - } - if (outNumRows) - { - *outNumRows = static_cast(numRows); - } - - return S_OK; - } - - - //-------------------------------------------------------------------------------------- -#define ISBITMASK( r,g,b,a ) ( ddpf.RBitMask == r && ddpf.GBitMask == g && ddpf.BBitMask == b && ddpf.ABitMask == a ) - - D3DFORMAT GetD3D9Format(const DDS_PIXELFORMAT& ddpf) noexcept - { - if (ddpf.flags & DDS_RGB) - { - switch (ddpf.RGBBitCount) - { - case 32: - if (ISBITMASK(0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000)) - { - return D3DFMT_A8R8G8B8; - } - if (ISBITMASK(0x00ff0000, 0x0000ff00, 0x000000ff, 0)) - { - return D3DFMT_X8R8G8B8; - } - if (ISBITMASK(0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000)) - { - return D3DFMT_A8B8G8R8; - } - if (ISBITMASK(0x000000ff, 0x0000ff00, 0x00ff0000, 0)) - { - return D3DFMT_X8B8G8R8; - } - - // Note that many common DDS reader/writers (including D3DX) swap the - // the RED/BLUE masks for 10:10:10:2 formats. We assume - // below that the 'backwards' header mask is being used since it is most - // likely written by D3DX. - - // For 'correct' writers this should be 0x3ff00000,0x000ffc00,0x000003ff for BGR data - if (ISBITMASK(0x000003ff, 0x000ffc00, 0x3ff00000, 0xc0000000)) - { - return D3DFMT_A2R10G10B10; - } - - // For 'correct' writers this should be 0x000003ff,0x000ffc00,0x3ff00000 for RGB data - if (ISBITMASK(0x3ff00000, 0x000ffc00, 0x000003ff, 0xc0000000)) - { - return D3DFMT_A2B10G10R10; - } - - if (ISBITMASK(0x0000ffff, 0xffff0000, 0x00000000, 0x00000000)) - { - return D3DFMT_G16R16; - } - if (ISBITMASK(0xffffffff, 0x00000000, 0x00000000, 0x00000000)) - { - return D3DFMT_R32F; // D3DX writes this out as a FourCC of 114 - } - break; - - case 24: - if (ISBITMASK(0xff0000, 0x00ff00, 0x0000ff, 0)) - { - return D3DFMT_R8G8B8; - } - break; - - case 16: - if (ISBITMASK(0xf800, 0x07e0, 0x001f, 0x0000)) - { - return D3DFMT_R5G6B5; - } - if (ISBITMASK(0x7c00, 0x03e0, 0x001f, 0x8000)) - { - return D3DFMT_A1R5G5B5; - } - if (ISBITMASK(0x7c00, 0x03e0, 0x001f, 0)) - { - return D3DFMT_X1R5G5B5; - } - if (ISBITMASK(0x0f00, 0x00f0, 0x000f, 0xf000)) - { - return D3DFMT_A4R4G4B4; - } - if (ISBITMASK(0x0f00, 0x00f0, 0x000f, 0)) - { - return D3DFMT_X4R4G4B4; - } - if (ISBITMASK(0x00e0, 0x001c, 0x0003, 0xff00)) - { - return D3DFMT_A8R3G3B2; - } - - // NVTT versions 1.x wrote these as RGB instead of LUMINANCE - if (ISBITMASK(0xffff, 0, 0, 0)) - { - return D3DFMT_L16; - } - if (ISBITMASK(0x00ff, 0, 0, 0xff00)) - { - return D3DFMT_A8L8; - } - break; - - case 8: - if (ISBITMASK(0xe0, 0x1c, 0x03, 0)) - { - return D3DFMT_R3G3B2; - } - - // NVTT versions 1.x wrote these as RGB instead of LUMINANCE - if (ISBITMASK(0xff, 0, 0, 0)) - { - return D3DFMT_L8; - } - - // Paletted texture formats are typically not supported on modern video cards aka D3DFMT_P8, D3DFMT_A8P8 - break; - } - } - else if (ddpf.flags & DDS_LUMINANCE) - { - switch (ddpf.RGBBitCount) - { - case 16: - if (ISBITMASK(0xffff, 0, 0, 0)) - { - return D3DFMT_L16; - } - if (ISBITMASK(0x00ff, 0, 0, 0xff00)) - { - return D3DFMT_A8L8; - } - break; - - case 8: - if (ISBITMASK(0x0f, 0, 0, 0xf0)) - { - return D3DFMT_A4L4; - } - if (ISBITMASK(0xff, 0, 0, 0)) - { - return D3DFMT_L8; - } - if (ISBITMASK(0x00ff, 0, 0, 0xff00)) - { - return D3DFMT_A8L8; // Some DDS writers assume the bitcount should be 8 instead of 16 - } - break; - } - } - else if (ddpf.flags & DDS_ALPHA) - { - if (8 == ddpf.RGBBitCount) - { - return D3DFMT_A8; - } - } - else if (ddpf.flags & DDS_BUMPDUDV) - { - switch (ddpf.RGBBitCount) - { - case 32: - if (ISBITMASK(0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000)) - { - return D3DFMT_Q8W8V8U8; - } - if (ISBITMASK(0x0000ffff, 0xffff0000, 0x00000000, 0x00000000)) - { - return D3DFMT_V16U16; - } - if (ISBITMASK(0x3ff00000, 0x000ffc00, 0x000003ff, 0xc0000000)) - { - return D3DFMT_A2W10V10U10; - } - break; - - case 16: - if (ISBITMASK(0x00ff, 0xff00, 0, 0)) - { - return D3DFMT_V8U8; - } - break; - } - } - else if (ddpf.flags & DDS_BUMPLUMINANCE) - { - switch (ddpf.RGBBitCount) - { - case 32: - if (ISBITMASK(0x000000ff, 0x0000ff00, 0x00ff0000, 0)) - { - return D3DFMT_X8L8V8U8; - } - break; - - case 16: - if (ISBITMASK(0x001f, 0x03e0, 0xfc00, 0)) - { - return D3DFMT_L6V5U5; - } - break; - } - } - else if (ddpf.flags & DDS_FOURCC) - { - if (MAKEFOURCC('D', 'X', 'T', '1') == ddpf.fourCC) - { - return D3DFMT_DXT1; - } - if (MAKEFOURCC('D', 'X', 'T', '2') == ddpf.fourCC) - { - return D3DFMT_DXT2; - } - if (MAKEFOURCC('D', 'X', 'T', '3') == ddpf.fourCC) - { - return D3DFMT_DXT3; - } - if (MAKEFOURCC('D', 'X', 'T', '4') == ddpf.fourCC) - { - return D3DFMT_DXT4; - } - if (MAKEFOURCC('D', 'X', 'T', '5') == ddpf.fourCC) - { - return D3DFMT_DXT5; - } - - if (MAKEFOURCC('R', 'G', 'B', 'G') == ddpf.fourCC) - { - return D3DFMT_R8G8_B8G8; - } - if (MAKEFOURCC('G', 'R', 'G', 'B') == ddpf.fourCC) - { - return D3DFMT_G8R8_G8B8; - } - - if (MAKEFOURCC('U', 'Y', 'V', 'Y') == ddpf.fourCC) - { - return D3DFMT_UYVY; - } - if (MAKEFOURCC('Y', 'U', 'Y', '2') == ddpf.fourCC) - { - return D3DFMT_YUY2; - } - - // Check for D3DFORMAT enums being set here - switch (ddpf.fourCC) - { - case D3DFMT_A16B16G16R16: - case D3DFMT_Q16W16V16U16: - case D3DFMT_R16F: - case D3DFMT_G16R16F: - case D3DFMT_A16B16G16R16F: - case D3DFMT_R32F: - case D3DFMT_G32R32F: - case D3DFMT_A32B32G32R32F: - case D3DFMT_CxV8U8: - return static_cast(ddpf.fourCC); - } - } - - return D3DFMT_UNKNOWN; - } - -#undef ISBITMASK - - -//-------------------------------------------------------------------------------------- - HRESULT CreateTextureFromDDS( - _In_ LPDIRECT3DDEVICE9 device, - _In_ const DDS_HEADER* header, - _In_reads_bytes_(bitSize) const uint8_t* bitData, - _In_ size_t bitSize, - _In_ DWORD usage, - _In_ D3DPOOL pool, - _Outptr_ LPDIRECT3DBASETEXTURE9* texture, - bool generateMipsIfMissing) noexcept - { - HRESULT hr = S_OK; - - UINT iWidth = header->width; - UINT iHeight = header->height; - - UINT iMipCount = header->mipMapCount; - if (0 == iMipCount) - { - iMipCount = 1; - } - - // Bound sizes (for security purposes we don't trust DDS file metadata larger than the D3D 10 hardware requirements) - if (iMipCount > 14u /*D3D10_REQ_MIP_LEVELS*/) - { - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - - // We could support a subset of 'DX10' extended header DDS files, but we'll assume here we are only - // supporting legacy DDS files for a Direct3D9 device - - const D3DFORMAT fmt = GetD3D9Format(header->ddspf); - if (fmt == D3DFMT_UNKNOWN || BitsPerPixel(fmt) == 0) - { - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - - if (header->flags & DDS_HEADER_FLAGS_VOLUME) - { - UINT iDepth = header->depth; - - if ((iWidth > 2048u /*D3D10_REQ_TEXTURE3D_U_V_OR_W_DIMENSION*/) - || (iHeight > 2048u /*D3D10_REQ_TEXTURE3D_U_V_OR_W_DIMENSION*/) - || (iDepth > 2048u /*D3D10_REQ_TEXTURE3D_U_V_OR_W_DIMENSION*/)) - { - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - - // Create the volume texture (let the runtime do the validation) - ComPtr pTexture; - hr = device->CreateVolumeTexture(iWidth, iHeight, iDepth, iMipCount, - usage, fmt, pool, pTexture.GetAddressOf(), nullptr); - if (FAILED(hr)) - return hr; - - ComPtr pStagingTexture; - if (pool == D3DPOOL_DEFAULT) - { - hr = device->CreateVolumeTexture(iWidth, iHeight, iDepth, iMipCount, - 0u, fmt, D3DPOOL_SYSTEMMEM, pStagingTexture.GetAddressOf(), nullptr); - if (FAILED(hr)) - return hr; - } - else - { - pStagingTexture = pTexture; - } - - // Lock, fill, unlock - size_t NumBytes = 0; - size_t RowBytes = 0; - size_t NumRows = 0; - const uint8_t* pSrcBits = bitData; - const uint8_t* pEndBits = bitData + bitSize; - D3DLOCKED_BOX LockedBox = {}; - - for (UINT i = 0; i < iMipCount; ++i) - { - GetSurfaceInfo(iWidth, iHeight, fmt, &NumBytes, &RowBytes, &NumRows); - - if (NumBytes > UINT32_MAX || RowBytes > UINT32_MAX) - return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); - - if ((pSrcBits + (NumBytes * iDepth)) > pEndBits) - { - return HRESULT_FROM_WIN32(ERROR_HANDLE_EOF); - } - - if (SUCCEEDED(pStagingTexture->LockBox(i, &LockedBox, nullptr, 0))) - { - auto pDestBits = static_cast(LockedBox.pBits); - - for (UINT j = 0; j < iDepth; ++j) - { - uint8_t* dptr = pDestBits; - const uint8_t* sptr = pSrcBits; - - // Copy stride line by line - for (size_t h = 0; h < NumRows; h++) - { - memcpy_s(dptr, static_cast(LockedBox.RowPitch), sptr, RowBytes); - dptr += LockedBox.RowPitch; - sptr += RowBytes; - } - - pDestBits += LockedBox.SlicePitch; - pSrcBits += NumBytes; - } - - pStagingTexture->UnlockBox(i); - } - - iWidth = iWidth >> 1; - iHeight = iHeight >> 1; - iDepth = iDepth >> 1; - if (iWidth == 0) - iWidth = 1; - if (iHeight == 0) - iHeight = 1; - if (iDepth == 0) - iDepth = 1; - } - - if (pool == D3DPOOL_DEFAULT) - { - hr = device->UpdateTexture(pStagingTexture.Get(), pTexture.Get()); - if (FAILED(hr)) - return hr; - } - - *texture = pTexture.Detach(); - } - else if (header->caps2 & DDS_CUBEMAP) - { - if ((iWidth > 8192u /*D3D10_REQ_TEXTURECUBE_DIMENSION*/) - || (iHeight > 8192u /*D3D10_REQ_TEXTURECUBE_DIMENSION*/)) - { - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - - // We require at least one face to be defined, and the faces must be square - if ((header->caps2 & DDS_CUBEMAP_ALLFACES) == 0 || iHeight != iWidth) - { - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - - // Create the cubemap (let the runtime do the validation) - ComPtr pTexture; - hr = device->CreateCubeTexture(iWidth, iMipCount, - usage, fmt, pool, pTexture.GetAddressOf(), nullptr); - if (FAILED(hr)) - return hr; - - ComPtr pStagingTexture; - if (pool == D3DPOOL_DEFAULT) - { - hr = device->CreateCubeTexture(iWidth, iMipCount, - 0u, fmt, D3DPOOL_SYSTEMMEM, pStagingTexture.GetAddressOf(), nullptr); - if (FAILED(hr)) - return hr; - } - else - { - pStagingTexture = pTexture; - } - - // Lock, fill, unlock - size_t NumBytes = 0; - size_t RowBytes = 0; - size_t NumRows = 0; - const uint8_t* pSrcBits = bitData; - const uint8_t* pEndBits = bitData + bitSize; - D3DLOCKED_RECT LockedRect = {}; - - UINT mask = DDS_CUBEMAP_POSITIVEX & ~DDS_CUBEMAP; - for (UINT f = 0; f < 6; ++f, mask <<= 1) - { - if (!(header->caps2 & mask)) - continue; - - UINT w = iWidth; - UINT h = iHeight; - for (UINT i = 0; i < iMipCount; ++i) - { - GetSurfaceInfo(w, h, fmt, &NumBytes, &RowBytes, &NumRows); - - if (NumBytes > UINT32_MAX || RowBytes > UINT32_MAX) - return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); - - if ((pSrcBits + NumBytes) > pEndBits) - { - return HRESULT_FROM_WIN32(ERROR_HANDLE_EOF); - } - - if (SUCCEEDED(pStagingTexture->LockRect(static_cast(f), i, &LockedRect, nullptr, 0))) - { - auto pDestBits = static_cast(LockedRect.pBits); - - // Copy stride line by line - for (size_t r = 0; r < NumRows; r++) - { - memcpy_s(pDestBits, static_cast(LockedRect.Pitch), pSrcBits, RowBytes); - pDestBits += LockedRect.Pitch; - pSrcBits += RowBytes; - } - - pStagingTexture->UnlockRect(static_cast(f), i); - } - - w = w >> 1; - h = h >> 1; - if (w == 0) - w = 1; - if (h == 0) - h = 1; - } - } - - if (pool == D3DPOOL_DEFAULT) - { - hr = device->UpdateTexture(pStagingTexture.Get(), pTexture.Get()); - if (FAILED(hr)) - return hr; - } - - *texture = pTexture.Detach(); - } - else - { - if ((iWidth > 8192u /*D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION*/) - || (iHeight > 8192u /*D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION*/)) - { - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - - // Create the texture (let the runtime do the validation) - if (generateMipsIfMissing) - usage |= D3DUSAGE_AUTOGENMIPMAP; - - ComPtr pTexture; - hr = device->CreateTexture(iWidth, iHeight, iMipCount, - usage, fmt, pool, - pTexture.GetAddressOf(), nullptr); - if (FAILED(hr)) - return hr; - - ComPtr pStagingTexture; - if (pool == D3DPOOL_DEFAULT) - { - hr = device->CreateTexture(iWidth, iHeight, iMipCount, - 0u, fmt, D3DPOOL_SYSTEMMEM, pStagingTexture.GetAddressOf(), nullptr); - if (FAILED(hr)) - return hr; - } - else - { - pStagingTexture = pTexture; - } - - // Lock, fill, unlock - size_t NumBytes = 0; - size_t RowBytes = 0; - size_t NumRows = 0; - const uint8_t* pSrcBits = bitData; - const uint8_t* pEndBits = bitData + bitSize; - D3DLOCKED_RECT LockedRect = {}; - - for (UINT i = 0; i < iMipCount; ++i) - { - GetSurfaceInfo(iWidth, iHeight, fmt, &NumBytes, &RowBytes, &NumRows); - - if (NumBytes > UINT32_MAX || RowBytes > UINT32_MAX) - return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); - - if ((pSrcBits + NumBytes) > pEndBits) - { - return HRESULT_FROM_WIN32(ERROR_HANDLE_EOF); - } - - if (SUCCEEDED(pStagingTexture->LockRect(i, &LockedRect, nullptr, 0))) - { - auto pDestBits = static_cast(LockedRect.pBits); - - // Copy stride line by line - for (UINT h = 0; h < NumRows; h++) - { - memcpy_s(pDestBits, static_cast(LockedRect.Pitch), pSrcBits, RowBytes); - pDestBits += LockedRect.Pitch; - pSrcBits += RowBytes; - } - - pStagingTexture->UnlockRect(i); - } - - iWidth = iWidth >> 1; - iHeight = iHeight >> 1; - if (iWidth == 0) - iWidth = 1; - if (iHeight == 0) - iHeight = 1; - } - - if (pool == D3DPOOL_DEFAULT) - { - hr = device->UpdateTexture(pStagingTexture.Get(), pTexture.Get()); - if (FAILED(hr)) - return hr; - } - - *texture = pTexture.Detach(); - } - - return hr; - } -} // anonymous namespace - -//-------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::CreateDDSTextureFromMemory( - LPDIRECT3DDEVICE9 d3dDevice, - const uint8_t* ddsData, - size_t ddsDataSize, - LPDIRECT3DBASETEXTURE9* texture, - bool generateMipsIfMissing) noexcept -{ - return CreateDDSTextureFromMemoryEx(d3dDevice, ddsData, ddsDataSize, 0u, D3DPOOL_DEFAULT, generateMipsIfMissing, texture); -} - -_Use_decl_annotations_ -HRESULT DirectX::CreateDDSTextureFromMemoryEx( - LPDIRECT3DDEVICE9 d3dDevice, - const uint8_t* ddsData, - size_t ddsDataSize, - _In_ DWORD usage, - _In_ D3DPOOL pool, - bool generateMipsIfMissing, - LPDIRECT3DBASETEXTURE9* texture) noexcept -{ - if (texture) - { - *texture = nullptr; - } - - if (!d3dDevice || !ddsData || !texture) - { - return E_INVALIDARG; - } - - // Validate DDS file in memory - const DDS_HEADER* header = nullptr; - const uint8_t* bitData = nullptr; - size_t bitSize = 0; - - HRESULT hr = LoadTextureDataFromMemory(ddsData, ddsDataSize, - &header, - &bitData, - &bitSize - ); - if (FAILED(hr)) - return hr; - - return CreateTextureFromDDS( - d3dDevice, - header, - bitData, - bitSize, - usage, - pool, - texture, - generateMipsIfMissing); -} - -// Type-specific standard versions -_Use_decl_annotations_ -HRESULT DirectX::CreateDDSTextureFromMemory( - LPDIRECT3DDEVICE9 d3dDevice, - const uint8_t* ddsData, - size_t ddsDataSize, - LPDIRECT3DTEXTURE9* texture, - bool generateMipsIfMissing) noexcept -{ - if (texture) - { - *texture = nullptr; - } - - if (!d3dDevice || !ddsData || !ddsDataSize || !texture) - return E_INVALIDARG; - - ComPtr tex; - HRESULT hr = CreateDDSTextureFromMemoryEx(d3dDevice, ddsData, ddsDataSize, 0u, D3DPOOL_DEFAULT, generateMipsIfMissing, tex.GetAddressOf()); - if (SUCCEEDED(hr)) - { - hr = E_FAIL; - if (tex->GetType() == D3DRTYPE_TEXTURE) - { - *texture = static_cast(tex.Detach()); - return S_OK; - } - } - - return hr; -} - -_Use_decl_annotations_ -HRESULT DirectX::CreateDDSTextureFromMemory( - LPDIRECT3DDEVICE9 d3dDevice, - const uint8_t* ddsData, - size_t ddsDataSize, - LPDIRECT3DCUBETEXTURE9* texture) noexcept -{ - if (texture) - { - *texture = nullptr; - } - - if (!d3dDevice || !ddsData || !ddsDataSize || !texture) - return E_INVALIDARG; - - ComPtr tex; - HRESULT hr = CreateDDSTextureFromMemoryEx(d3dDevice, ddsData, ddsDataSize, 0u, D3DPOOL_DEFAULT, false, tex.GetAddressOf()); - if (SUCCEEDED(hr)) - { - hr = E_FAIL; - if (tex->GetType() == D3DRTYPE_CUBETEXTURE) - { - *texture = static_cast(tex.Detach()); - return S_OK; - } - } - - return hr; -} - -_Use_decl_annotations_ -HRESULT DirectX::CreateDDSTextureFromMemory( - LPDIRECT3DDEVICE9 d3dDevice, - const uint8_t* ddsData, - size_t ddsDataSize, - LPDIRECT3DVOLUMETEXTURE9* texture) noexcept -{ - if (texture) - { - *texture = nullptr; - } - - if (!d3dDevice || !ddsData || !ddsDataSize || !texture) - return E_INVALIDARG; - - ComPtr tex; - HRESULT hr = CreateDDSTextureFromMemoryEx(d3dDevice, ddsData, ddsDataSize, 0u, D3DPOOL_DEFAULT, false, tex.GetAddressOf()); - if (SUCCEEDED(hr)) - { - hr = E_FAIL; - if (tex->GetType() == D3DRTYPE_VOLUMETEXTURE) - { - *texture = static_cast(tex.Detach()); - return S_OK; - } - } - - return hr; -} - -// Type-specific extended versions -_Use_decl_annotations_ -HRESULT DirectX::CreateDDSTextureFromMemoryEx( - LPDIRECT3DDEVICE9 d3dDevice, - const uint8_t* ddsData, - size_t ddsDataSize, - DWORD usage, - D3DPOOL pool, - bool generateMipsIfMissing, - LPDIRECT3DTEXTURE9* texture) noexcept -{ - if (texture) - { - *texture = nullptr; - } - - if (!d3dDevice || !ddsData || !ddsDataSize || !texture) - return E_INVALIDARG; - - ComPtr tex; - HRESULT hr = CreateDDSTextureFromMemoryEx(d3dDevice, ddsData, ddsDataSize, usage, pool, generateMipsIfMissing, tex.GetAddressOf()); - if (SUCCEEDED(hr)) - { - hr = E_FAIL; - if (tex->GetType() == D3DRTYPE_TEXTURE) - { - *texture = static_cast(tex.Detach()); - return S_OK; - } - } - - return hr; -} - -_Use_decl_annotations_ -HRESULT DirectX::CreateDDSTextureFromMemoryEx( - LPDIRECT3DDEVICE9 d3dDevice, - const uint8_t* ddsData, - size_t ddsDataSize, - DWORD usage, - D3DPOOL pool, - LPDIRECT3DCUBETEXTURE9* texture) noexcept -{ - if (texture) - { - *texture = nullptr; - } - - if (!d3dDevice || !ddsData || !ddsDataSize || !texture) - return E_INVALIDARG; - - ComPtr tex; - HRESULT hr = CreateDDSTextureFromMemoryEx(d3dDevice, ddsData, ddsDataSize, usage, pool, false, tex.GetAddressOf()); - if (SUCCEEDED(hr)) - { - hr = E_FAIL; - if (tex->GetType() == D3DRTYPE_CUBETEXTURE) - { - *texture = static_cast(tex.Detach()); - return S_OK; - } - } - - return hr; -} - -_Use_decl_annotations_ -HRESULT DirectX::CreateDDSTextureFromMemoryEx( - LPDIRECT3DDEVICE9 d3dDevice, - const uint8_t* ddsData, - size_t ddsDataSize, - DWORD usage, - D3DPOOL pool, - LPDIRECT3DVOLUMETEXTURE9* texture) noexcept -{ - if (texture) - { - *texture = nullptr; - } - - if (!d3dDevice || !ddsData || !ddsDataSize || !texture) - return E_INVALIDARG; - - ComPtr tex; - HRESULT hr = CreateDDSTextureFromMemoryEx(d3dDevice, ddsData, ddsDataSize, usage, pool, false, tex.GetAddressOf()); - if (SUCCEEDED(hr)) - { - hr = E_FAIL; - if (tex->GetType() == D3DRTYPE_VOLUMETEXTURE) - { - *texture = static_cast(tex.Detach()); - return S_OK; - } - } - - return hr; -} - - -//-------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::CreateDDSTextureFromFile( - LPDIRECT3DDEVICE9 d3dDevice, - const wchar_t* fileName, - LPDIRECT3DBASETEXTURE9* texture, - bool generateMipsIfMissing) noexcept -{ - return CreateDDSTextureFromFileEx(d3dDevice, fileName, 0u, D3DPOOL_DEFAULT, generateMipsIfMissing, texture); -} - -_Use_decl_annotations_ -HRESULT DirectX::CreateDDSTextureFromFileEx( - LPDIRECT3DDEVICE9 d3dDevice, - const wchar_t* fileName, - _In_ DWORD usage, - _In_ D3DPOOL pool, - bool generateMipsIfMissing, - LPDIRECT3DBASETEXTURE9* texture) noexcept -{ - if (texture) - { - *texture = nullptr; - } - - if (!d3dDevice || !fileName || !texture) - return E_INVALIDARG; - - const DDS_HEADER* header = nullptr; - const uint8_t* bitData = nullptr; - size_t bitSize = 0; - - std::unique_ptr ddsData; - HRESULT hr = LoadTextureDataFromFile(fileName, - ddsData, - &header, - &bitData, - &bitSize - ); - if (FAILED(hr)) - { - return hr; - } - - return CreateTextureFromDDS( - d3dDevice, - header, - bitData, - bitSize, - usage, - pool, - texture, - generateMipsIfMissing); -} - -// Type-specific standard versions -_Use_decl_annotations_ -HRESULT DirectX::CreateDDSTextureFromFile( - LPDIRECT3DDEVICE9 d3dDevice, - const wchar_t* fileName, - LPDIRECT3DTEXTURE9* texture, - bool generateMipsIfMissing) noexcept -{ - if (texture) - { - *texture = nullptr; - } - - if (!d3dDevice || !fileName || !texture) - return E_INVALIDARG; - - ComPtr tex; - HRESULT hr = CreateDDSTextureFromFileEx(d3dDevice, fileName, 0u, D3DPOOL_DEFAULT, generateMipsIfMissing, tex.GetAddressOf()); - if (SUCCEEDED(hr)) - { - hr = E_FAIL; - if (tex->GetType() == D3DRTYPE_TEXTURE) - { - *texture = static_cast(tex.Detach()); - return S_OK; - } - } - - return hr; -} - -_Use_decl_annotations_ -HRESULT DirectX::CreateDDSTextureFromFile( - LPDIRECT3DDEVICE9 d3dDevice, - const wchar_t* fileName, - LPDIRECT3DCUBETEXTURE9* texture) noexcept -{ - if (texture) - { - *texture = nullptr; - } - - if (!d3dDevice || !fileName || !texture) - return E_INVALIDARG; - - ComPtr tex; - HRESULT hr = CreateDDSTextureFromFileEx(d3dDevice, fileName, 0u, D3DPOOL_DEFAULT, false, tex.GetAddressOf()); - if (SUCCEEDED(hr)) - { - hr = E_FAIL; - if (tex->GetType() == D3DRTYPE_CUBETEXTURE) - { - *texture = static_cast(tex.Detach()); - return S_OK; - } - } - - return hr; -} - -_Use_decl_annotations_ -HRESULT DirectX::CreateDDSTextureFromFile( - LPDIRECT3DDEVICE9 d3dDevice, - const wchar_t* szFileName, - LPDIRECT3DVOLUMETEXTURE9* texture) noexcept -{ - if (texture) - { - *texture = nullptr; - } - - if (!d3dDevice || !szFileName || !texture) - return E_INVALIDARG; - - ComPtr tex; - HRESULT hr = CreateDDSTextureFromFileEx(d3dDevice, szFileName, 0u, D3DPOOL_DEFAULT, false, tex.GetAddressOf()); - if (SUCCEEDED(hr)) - { - hr = E_FAIL; - if (tex->GetType() == D3DRTYPE_VOLUMETEXTURE) - { - *texture = static_cast(tex.Detach()); - return S_OK; - } - } - - return hr; -} - -// Type-specific extended versions -_Use_decl_annotations_ -HRESULT DirectX::CreateDDSTextureFromFileEx( - LPDIRECT3DDEVICE9 d3dDevice, - const wchar_t* fileName, - DWORD usage, - D3DPOOL pool, - bool generateMipsIfMissing, - LPDIRECT3DTEXTURE9* texture) noexcept -{ - if (texture) - { - *texture = nullptr; - } - - if (!d3dDevice || !fileName || !texture) - return E_INVALIDARG; - - ComPtr tex; - HRESULT hr = CreateDDSTextureFromFileEx(d3dDevice, fileName, usage, pool, generateMipsIfMissing, tex.GetAddressOf()); - if (SUCCEEDED(hr)) - { - hr = E_FAIL; - if (tex->GetType() == D3DRTYPE_TEXTURE) - { - *texture = static_cast(tex.Detach()); - return S_OK; - } - } - - return hr; -} - -_Use_decl_annotations_ -HRESULT DirectX::CreateDDSTextureFromFileEx( - LPDIRECT3DDEVICE9 d3dDevice, - const wchar_t* fileName, - DWORD usage, - D3DPOOL pool, - LPDIRECT3DCUBETEXTURE9* texture) noexcept -{ - if (texture) - { - *texture = nullptr; - } - - if (!d3dDevice || !fileName || !texture) - return E_INVALIDARG; - - ComPtr tex; - HRESULT hr = CreateDDSTextureFromFileEx(d3dDevice, fileName, usage, pool, false, tex.GetAddressOf()); - if (SUCCEEDED(hr)) - { - hr = E_FAIL; - if (tex->GetType() == D3DRTYPE_CUBETEXTURE) - { - *texture = static_cast(tex.Detach()); - return S_OK; - } - } - - return hr; -} - -_Use_decl_annotations_ -HRESULT DirectX::CreateDDSTextureFromFileEx( - LPDIRECT3DDEVICE9 d3dDevice, - const wchar_t* szFileName, - DWORD usage, - D3DPOOL pool, - LPDIRECT3DVOLUMETEXTURE9* texture) noexcept -{ - if (texture) - { - *texture = nullptr; - } - - if (!d3dDevice || !szFileName || !texture) - return E_INVALIDARG; - - ComPtr tex; - HRESULT hr = CreateDDSTextureFromFileEx(d3dDevice, szFileName, usage, pool, false, tex.GetAddressOf()); - if (SUCCEEDED(hr)) - { - hr = E_FAIL; - if (tex->GetType() == D3DRTYPE_VOLUMETEXTURE) - { - *texture = static_cast(tex.Detach()); - return S_OK; - } - } - - return hr; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSTextureLoader/DDSTextureLoader9.h b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSTextureLoader/DDSTextureLoader9.h deleted file mode 100644 index 3e1c7ca..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSTextureLoader/DDSTextureLoader9.h +++ /dev/null @@ -1,145 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: DDSTextureLoader9.h -// -// Functions for loading a DDS texture and creating a Direct3D runtime resource for it -// -// Note these functions are useful as a light-weight runtime loader for DDS files. For -// a full-featured DDS file reader, writer, and texture processing pipeline see -// the 'Texconv' sample and the 'DirectXTex' library. -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//-------------------------------------------------------------------------------------- - -#pragma once - -#ifndef DIRECT3D_VERSION -#define DIRECT3D_VERSION 0x900 -#endif - -#include - -#include -#include - - -namespace DirectX -{ - // Standard version - HRESULT CreateDDSTextureFromMemory( - _In_ LPDIRECT3DDEVICE9 d3dDevice, - _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, - _In_ size_t ddsDataSize, - _Outptr_ LPDIRECT3DBASETEXTURE9* texture, - bool generateMipsIfMissing = false) noexcept; - - HRESULT CreateDDSTextureFromFile( - _In_ LPDIRECT3DDEVICE9 d3dDevice, - _In_z_ const wchar_t* fileName, - _Outptr_ LPDIRECT3DBASETEXTURE9* texture, - bool generateMipsIfMissing = false) noexcept; - - // Extended version - HRESULT CreateDDSTextureFromMemoryEx( - _In_ LPDIRECT3DDEVICE9 d3dDevice, - _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, - _In_ size_t ddsDataSize, - _In_ DWORD usage, - _In_ D3DPOOL pool, - bool generateMipsIfMissing, - _Outptr_ LPDIRECT3DBASETEXTURE9* texture) noexcept; - - HRESULT CreateDDSTextureFromFileEx( - _In_ LPDIRECT3DDEVICE9 d3dDevice, - _In_z_ const wchar_t* fileName, - _In_ DWORD usage, - _In_ D3DPOOL pool, - bool generateMipsIfMissing, - _Outptr_ LPDIRECT3DBASETEXTURE9* texture) noexcept; - - // Type-specific standard versions - HRESULT CreateDDSTextureFromMemory( - _In_ LPDIRECT3DDEVICE9 d3dDevice, - _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, - _In_ size_t ddsDataSize, - _Outptr_ LPDIRECT3DTEXTURE9* texture, - bool generateMipsIfMissing = false) noexcept; - - HRESULT CreateDDSTextureFromFile( - _In_ LPDIRECT3DDEVICE9 d3dDevice, - _In_z_ const wchar_t* fileName, - _Outptr_ LPDIRECT3DTEXTURE9* texture, - bool generateMipsIfMissing = false) noexcept; - - HRESULT CreateDDSTextureFromMemory( - _In_ LPDIRECT3DDEVICE9 d3dDevice, - _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, - _In_ size_t ddsDataSize, - _Outptr_ LPDIRECT3DCUBETEXTURE9* texture) noexcept; - - HRESULT CreateDDSTextureFromFile( - _In_ LPDIRECT3DDEVICE9 d3dDevice, - _In_z_ const wchar_t* fileName, - _Outptr_ LPDIRECT3DCUBETEXTURE9* texture) noexcept; - - HRESULT CreateDDSTextureFromMemory( - _In_ LPDIRECT3DDEVICE9 d3dDevice, - _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, - _In_ size_t ddsDataSize, - _Outptr_ LPDIRECT3DVOLUMETEXTURE9* texture) noexcept; - - HRESULT CreateDDSTextureFromFile( - _In_ LPDIRECT3DDEVICE9 d3dDevice, - _In_z_ const wchar_t* fileName, - _Outptr_ LPDIRECT3DVOLUMETEXTURE9* texture) noexcept; - - // Type-specific extended versions - HRESULT CreateDDSTextureFromMemoryEx( - _In_ LPDIRECT3DDEVICE9 d3dDevice, - _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, - _In_ size_t ddsDataSize, - _In_ DWORD usage, - _In_ D3DPOOL pool, - bool generateMipsIfMissing, - _Outptr_ LPDIRECT3DTEXTURE9* texture) noexcept; - - HRESULT CreateDDSTextureFromFileEx( - _In_ LPDIRECT3DDEVICE9 d3dDevice, - _In_z_ const wchar_t* fileName, - _In_ DWORD usage, - _In_ D3DPOOL pool, - bool generateMipsIfMissing, - _Outptr_ LPDIRECT3DTEXTURE9* texture) noexcept; - - HRESULT CreateDDSTextureFromMemoryEx( - _In_ LPDIRECT3DDEVICE9 d3dDevice, - _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, - _In_ size_t ddsDataSize, - _In_ DWORD usage, - _In_ D3DPOOL pool, - _Outptr_ LPDIRECT3DCUBETEXTURE9* texture) noexcept; - - HRESULT CreateDDSTextureFromFileEx( - _In_ LPDIRECT3DDEVICE9 d3dDevice, - _In_z_ const wchar_t* fileName, - _In_ DWORD usage, - _In_ D3DPOOL pool, - _Outptr_ LPDIRECT3DCUBETEXTURE9* texture) noexcept; - - HRESULT CreateDDSTextureFromMemoryEx( - _In_ LPDIRECT3DDEVICE9 d3dDevice, - _In_reads_bytes_(ddsDataSize) const uint8_t* ddsData, - _In_ size_t ddsDataSize, - _In_ DWORD usage, - _In_ D3DPOOL pool, - _Outptr_ LPDIRECT3DVOLUMETEXTURE9* texture) noexcept; - - HRESULT CreateDDSTextureFromFileEx( - _In_ LPDIRECT3DDEVICE9 d3dDevice, - _In_z_ const wchar_t* fileName, - _In_ DWORD usage, - _In_ D3DPOOL pool, - _Outptr_ LPDIRECT3DVOLUMETEXTURE9* texture) noexcept; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSView/DDSView.rc b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSView/DDSView.rc deleted file mode 100644 index 49efb34..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSView/DDSView.rc +++ /dev/null @@ -1,75 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#define IDC_STATIC -1 -#define IDI_MAIN_ICON 100 -#include - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_MAIN_ICON ICON "directx.ico" - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#define IDC_STATIC -1\r\n" - "#include \r\n" - "\r\n" - "\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSView/DDSView_Desktop_2019.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSView/DDSView_Desktop_2019.vcxproj deleted file mode 100644 index d97aa06..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSView/DDSView_Desktop_2019.vcxproj +++ /dev/null @@ -1,309 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Profile - Win32 - - - Profile - x64 - - - Release - Win32 - - - Release - x64 - - - - DDSView - {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84} - DDSView - Win32Proj - 10.0 - - - - Application - true - Unicode - v142 - - - Application - true - Unicode - v142 - - - Application - true - Unicode - v142 - - - Application - true - Unicode - v142 - - - Application - true - Unicode - v142 - - - Application - true - Unicode - v142 - - - - - - - - - - - - - - - - - - - - - - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - DDSView - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - DDSView - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - DDSView - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - DDSView - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - DDSView - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - DDSView - true - - - - Level4 - Disabled - MultiThreadedDebugDLL - Fast - StreamingSIMDExtensions2 - ..\DirectXTex;$(ProjectDir)Shaders;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;DEBUG;PROFILE;_WINDOWS;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - 26812 - - - d3d11.lib;ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - Windows - true - true - - - false - - - - - Level4 - Disabled - MultiThreadedDebugDLL - Fast - ..\DirectXTex;$(ProjectDir)Shaders;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;DEBUG;PROFILE;_WINDOWS;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - 26812 - - - d3d11.lib;ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - Windows - true - - - false - - - - - Level4 - MaxSpeed - Fast - StreamingSIMDExtensions2 - ..\DirectXTex;$(ProjectDir)Shaders;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - Guard - true - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - 26812 - - - d3d11.lib;ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - true - Windows - true - true - true - - - false - - - - - Level4 - MaxSpeed - Fast - ..\DirectXTex;$(ProjectDir)Shaders;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - Guard - true - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - 26812 - - - d3d11.lib;ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - true - Windows - true - true - - - false - - - - - Level4 - MaxSpeed - Fast - StreamingSIMDExtensions2 - ..\DirectXTex;$(ProjectDir)Shaders;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;PROFILE;_WINDOWS;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - Guard - true - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - 26812 - - - d3d11.lib;ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - true - Windows - true - true - true - - - false - - - - - Level4 - MaxSpeed - Fast - ..\DirectXTex;$(ProjectDir)Shaders;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;PROFILE;_WINDOWS;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - Guard - true - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - 26812 - - - d3d11.lib;ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - true - Windows - true - true - - - false - - - - - - - - - - - {371b9fa9-4c90-4ac6-a123-aced756d6c77} - - - - - - - - - - <_ATGFXCPath>$(WindowsSDK_ExecutablePath_x64.Split(';')[0]) - <_ATGFXCPath>$(_ATGFXCPath.Replace("x64","")) - <_ATGFXCPath Condition="'$(_ATGFXCPath)' != '' and !HasTrailingSlash('$(_ATGFXCPath)')">$(_ATGFXCPath)\ - - - - <_ATGFXCPath /> - - - - - <_ATGShaderHeaders Include="$(ProjectDir)Shaders/*.inc" /> - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSView/DDSView_Desktop_2019.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSView/DDSView_Desktop_2019.vcxproj.filters deleted file mode 100644 index ab6eee7..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSView/DDSView_Desktop_2019.vcxproj.filters +++ /dev/null @@ -1,20 +0,0 @@ - - - - - {8e114980-c1a3-4ada-ad7c-83caadf5daeb} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - - - - - - Resource Files - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSView/DDSView_Desktop_2022.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSView/DDSView_Desktop_2022.vcxproj deleted file mode 100644 index 43d0fa8..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSView/DDSView_Desktop_2022.vcxproj +++ /dev/null @@ -1,315 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Profile - Win32 - - - Profile - x64 - - - Release - Win32 - - - Release - x64 - - - - DDSView - {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84} - DDSView - Win32Proj - 10.0 - - - - Application - true - Unicode - v143 - - - Application - true - Unicode - v143 - - - Application - true - Unicode - v143 - - - Application - true - Unicode - v143 - - - Application - true - Unicode - v143 - - - Application - true - Unicode - v143 - - - - - - - - - - - - - - - - - - - - - - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - DDSView - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - DDSView - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - DDSView - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - DDSView - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - DDSView - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - DDSView - true - - - - Level4 - Disabled - MultiThreadedDebugDLL - Fast - StreamingSIMDExtensions2 - ..\DirectXTex;$(ProjectDir)Shaders;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;DEBUG;PROFILE;_WINDOWS;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - true - /Zc:__cplusplus %(AdditionalOptions) - 26812 - - - d3d11.lib;ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - Windows - true - true - true - - - false - - - - - Level4 - Disabled - MultiThreadedDebugDLL - Fast - ..\DirectXTex;$(ProjectDir)Shaders;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;DEBUG;PROFILE;_WINDOWS;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - true - /Zc:__cplusplus %(AdditionalOptions) - 26812 - - - d3d11.lib;ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - Windows - true - true - - - false - - - - - Level4 - MaxSpeed - Fast - StreamingSIMDExtensions2 - ..\DirectXTex;$(ProjectDir)Shaders;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - Guard - true - true - /Zc:__cplusplus %(AdditionalOptions) - 26812 - - - d3d11.lib;ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - true - Windows - true - true - true - true - - - false - - - - - Level4 - MaxSpeed - Fast - ..\DirectXTex;$(ProjectDir)Shaders;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - Guard - true - true - /Zc:__cplusplus %(AdditionalOptions) - 26812 - - - d3d11.lib;ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - true - Windows - true - true - true - - - false - - - - - Level4 - MaxSpeed - Fast - StreamingSIMDExtensions2 - ..\DirectXTex;$(ProjectDir)Shaders;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;PROFILE;_WINDOWS;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - Guard - true - true - /Zc:__cplusplus %(AdditionalOptions) - 26812 - - - d3d11.lib;ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - true - Windows - true - true - true - true - - - false - - - - - Level4 - MaxSpeed - Fast - ..\DirectXTex;$(ProjectDir)Shaders;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;PROFILE;_WINDOWS;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - Guard - true - true - /Zc:__cplusplus %(AdditionalOptions) - 26812 - - - d3d11.lib;ole32.lib;windowscodecs.lib;uuid.lib;%(AdditionalDependencies) - true - Windows - true - true - true - - - false - - - - - - - - - - - {371b9fa9-4c90-4ac6-a123-aced756d6c77} - - - - - - - - - - <_ATGFXCPath>$(WindowsSDK_ExecutablePath_x64.Split(';')[0]) - <_ATGFXCPath>$(_ATGFXCPath.Replace("x64","")) - <_ATGFXCPath Condition="'$(_ATGFXCPath)' != '' and !HasTrailingSlash('$(_ATGFXCPath)')">$(_ATGFXCPath)\ - - - - <_ATGFXCPath /> - - - - - <_ATGShaderHeaders Include="$(ProjectDir)Shaders/*.inc" /> - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSView/DDSView_Desktop_2022.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSView/DDSView_Desktop_2022.vcxproj.filters deleted file mode 100644 index ab6eee7..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSView/DDSView_Desktop_2022.vcxproj.filters +++ /dev/null @@ -1,20 +0,0 @@ - - - - - {8e114980-c1a3-4ada-ad7c-83caadf5daeb} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - - - - - - Resource Files - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSView/ddsview.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSView/ddsview.cpp deleted file mode 100644 index 7a1755b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSView/ddsview.cpp +++ /dev/null @@ -1,764 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: DDSView.cpp -// -// DirectX 11 DDS File Viewer sample for DirectXTex -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -//-------------------------------------------------------------------------------------- - -#define WIN32_LEAN_AND_MEAN -#define NOMINMAX -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#pragma warning(disable : 4619 4616 26812) - -#include "DirectXTex.h" - -using namespace DirectX; - -//-------------------------------------------------------------------------------------- -#define IDI_MAIN_ICON 100 - -//-------------------------------------------------------------------------------------- -#pragma pack(push,1) -struct SimpleVertex -{ - XMFLOAT4 Pos; - XMFLOAT4 Tex; -}; - -struct CBArrayControl -{ - float Index; - float pad[3]; -}; -#pragma pack(pop) - -//-------------------------------------------------------------------------------------- - -namespace -{ -#include "ddsview_vs.inc" -#include "ddsview_ps1D.inc" -#include "ddsview_ps1Darray.inc" -#include "ddsview_ps2D.inc" -#include "ddsview_ps2Darray.inc" -#include "ddsview_ps3D.inc" -#include "ddsview_psCube.inc" -} - -//-------------------------------------------------------------------------------------- -namespace -{ - HINSTANCE g_hInst = nullptr; - HWND g_hWnd = nullptr; - D3D_DRIVER_TYPE g_driverType = D3D_DRIVER_TYPE_NULL; - D3D_FEATURE_LEVEL g_featureLevel = D3D_FEATURE_LEVEL_11_0; - ID3D11Device* g_pd3dDevice = nullptr; - ID3D11DeviceContext* g_pImmediateContext = nullptr; - IDXGISwapChain* g_pSwapChain = nullptr; - ID3D11RenderTargetView* g_pRenderTargetView = nullptr; - ID3D11Texture2D* g_pDepthStencil = nullptr; - ID3D11DepthStencilView* g_pDepthStencilView = nullptr; - ID3D11VertexShader* g_pVertexShader = nullptr; - ID3D11PixelShader* g_pPixelShader = nullptr; - ID3D11InputLayout* g_pVertexLayout = nullptr; - ID3D11Buffer* g_pVertexBuffer = nullptr; - ID3D11Buffer* g_pIndexBuffer = nullptr; - ID3D11Buffer* g_pCBArrayControl = nullptr; - ID3D11ShaderResourceView* g_pSRV = nullptr; - ID3D11BlendState* g_AlphaBlendState = nullptr; - ID3D11SamplerState* g_pSamplerLinear = nullptr; - - UINT g_iCurrentIndex = 0; - UINT g_iMaxIndex = 1; - - UINT g_iIndices = 0; - - LPCWSTR g_szAppName = L"DDSView"; -} - -//-------------------------------------------------------------------------------------- -HRESULT InitWindow(HINSTANCE hInstance, int nCmdShow, const TexMetadata& mdata); -HRESULT InitDevice(const TexMetadata& mdata); -void CleanupDevice(); -LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); -void Render(); - -//-------------------------------------------------------------------------------------- -#pragma warning( suppress : 6262 ) -int WINAPI wWinMain( - _In_ HINSTANCE hInstance, - _In_opt_ HINSTANCE /*hPrevInstance*/, - _In_ LPWSTR lpCmdLine, - _In_ int nCmdShow) -{ - if (!*lpCmdLine) - { - MessageBoxW(nullptr, L"Usage: ddsview ", g_szAppName, MB_OK | MB_ICONEXCLAMATION); - return 0; - } - - TexMetadata mdata; - HRESULT hr = GetMetadataFromDDSFile(lpCmdLine, DDS_FLAGS_NONE, mdata); - if (FAILED(hr)) - { - wchar_t buff[2048] = {}; - swprintf_s(buff, L"Failed to open texture file\n\nFilename = %ls\nHRESULT %08X", lpCmdLine, static_cast(hr)); - MessageBoxW(nullptr, buff, g_szAppName, MB_OK | MB_ICONEXCLAMATION); - return 0; - } - - if (FAILED(InitWindow(hInstance, nCmdShow, mdata))) - return 0; - - SetWindowTextW(g_hWnd, lpCmdLine); - - if (FAILED(InitDevice(mdata))) - { - CleanupDevice(); - return 0; - } - - if (mdata.dimension == TEX_DIMENSION_TEXTURE3D) - { - if (mdata.arraySize > 1) - { - wchar_t buff[2048] = {}; - swprintf_s(buff, L"Arrays of volume textures are not supported\n\nFilename = %ls\nArray size %zu", lpCmdLine, mdata.arraySize); - MessageBoxW(nullptr, buff, g_szAppName, MB_OK | MB_ICONEXCLAMATION); - return 0; - } - - g_iMaxIndex = static_cast(mdata.depth); - } - else if (mdata.arraySize > 1) - { - if (g_featureLevel < D3D_FEATURE_LEVEL_10_0) - { - wchar_t buff[2048] = {}; - swprintf_s(buff, L"Texture arrays require DirectX 10 hardware or later\n\nFilename = %ls\nArray size %zu", lpCmdLine, mdata.arraySize); - MessageBoxW(nullptr, buff, g_szAppName, MB_OK | MB_ICONEXCLAMATION); - return 0; - } - - g_iMaxIndex = static_cast(mdata.arraySize); - } - - switch (mdata.format) - { - case DXGI_FORMAT_BC4_TYPELESS: - case DXGI_FORMAT_BC4_SNORM: - case DXGI_FORMAT_BC4_UNORM: - case DXGI_FORMAT_BC5_TYPELESS: - case DXGI_FORMAT_BC5_SNORM: - case DXGI_FORMAT_BC5_UNORM: - if (g_featureLevel < D3D_FEATURE_LEVEL_10_0) - { - wchar_t buff[2048] = {}; - swprintf_s(buff, L"BC4/BC5 requires DirectX 10 hardware or later\n\nFilename = %ls\nDXGI Format %d\nFeature Level %d", lpCmdLine, mdata.format, g_featureLevel); - MessageBoxW(nullptr, buff, g_szAppName, MB_OK | MB_ICONEXCLAMATION); - return 0; - } - break; - - case DXGI_FORMAT_BC6H_TYPELESS: - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - case DXGI_FORMAT_BC7_TYPELESS: - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: - if (g_featureLevel < D3D_FEATURE_LEVEL_11_0) - { - wchar_t buff[2048] = {}; - swprintf_s(buff, L"BC6H/BC7 requires DirectX 11 hardware or later\n\nFilename = %ls\nDXGI Format %d\nFeature Level %d", lpCmdLine, mdata.format, g_featureLevel); - MessageBoxW(nullptr, buff, g_szAppName, MB_OK | MB_ICONEXCLAMATION); - return 0; - } - break; - - default: - { - UINT flags = 0; - hr = g_pd3dDevice->CheckFormatSupport(mdata.format, &flags); - constexpr UINT required = D3D11_FORMAT_SUPPORT_TEXTURE1D | D3D11_FORMAT_SUPPORT_TEXTURE2D | D3D11_FORMAT_SUPPORT_TEXTURE3D; - if (FAILED(hr) || !(flags & required)) - { - wchar_t buff[2048] = {}; - swprintf_s(buff, L"Format not supported by this DirectX hardware\n\nFilename = %ls\nDXGI Format %d\nFeature Level %d\nHRESULT = %08X", lpCmdLine, mdata.format, g_featureLevel, static_cast(hr)); - MessageBoxW(nullptr, buff, g_szAppName, MB_OK | MB_ICONEXCLAMATION); - return 0; - } - } - break; - } - - ScratchImage image; - hr = LoadFromDDSFile(lpCmdLine, DDS_FLAGS_NONE, &mdata, image); - if (FAILED(hr)) - { - wchar_t buff[2048] = {}; - swprintf_s(buff, L"Failed to load texture file\n\nFilename = %ls\nHRESULT %08X", lpCmdLine, static_cast(hr)); - MessageBoxW(nullptr, buff, g_szAppName, MB_OK | MB_ICONEXCLAMATION); - return 0; - } - - // Special case to make sure Texture cubes remain arrays - mdata.miscFlags &= ~TEX_MISC_TEXTURECUBE; - - hr = CreateShaderResourceView(g_pd3dDevice, image.GetImages(), image.GetImageCount(), mdata, &g_pSRV); - if (FAILED(hr)) - { - wchar_t buff[2048] = {}; - swprintf_s(buff, L"Failed creating texture from file\n\nFilename = %ls\nHRESULT = %08X", lpCmdLine, static_cast(hr)); - MessageBoxW(nullptr, buff, g_szAppName, MB_OK | MB_ICONEXCLAMATION); - return 0; - } - - // Main message loop - MSG msg = {}; - while (WM_QUIT != msg.message) - { - if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - else - { - Render(); - } - } - - CleanupDevice(); - - return static_cast(msg.wParam); -} - -//-------------------------------------------------------------------------------------- -HRESULT InitWindow( - HINSTANCE hInstance, - int nCmdShow, - const TexMetadata& mdata) -{ - // Register class - WNDCLASSEXW wcex = {}; - wcex.cbSize = sizeof(WNDCLASSEXW); - wcex.style = CS_HREDRAW | CS_VREDRAW; - wcex.lpfnWndProc = WndProc; - wcex.hInstance = hInstance; - wcex.hIcon = LoadIconW(hInstance, reinterpret_cast(IDI_MAIN_ICON)); - wcex.hCursor = LoadCursor(nullptr, IDC_ARROW); - wcex.hbrBackground = reinterpret_cast(COLOR_WINDOW + 1); - wcex.lpszClassName = L"DDSViewWindowClass"; - wcex.hIconSm = LoadIconW(wcex.hInstance, reinterpret_cast(IDI_MAIN_ICON)); - if (!RegisterClassExW(&wcex)) - return E_FAIL; - - // Create window - g_hInst = hInstance; - RECT rc = { 0, 0, 640, 480 }; - - int cxborder = GetSystemMetrics(SM_CXBORDER); - int cxedge = GetSystemMetrics(SM_CXEDGE); - int screenX = GetSystemMetrics(SM_CXSCREEN) - std::max(cxborder, cxedge); - if (rc.right < static_cast(mdata.width)) - rc.right = static_cast(mdata.width); - if (rc.right > screenX) - rc.right = screenX; - - int cyborder = GetSystemMetrics(SM_CYBORDER); - int cyedge = GetSystemMetrics(SM_CYEDGE); - int screenY = GetSystemMetrics(SM_CYSCREEN) - std::max(cyborder, cyedge); - if (rc.bottom < static_cast(mdata.height)) - rc.bottom = static_cast(mdata.height); - if (rc.bottom > screenY) - rc.bottom = screenY; - - AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, FALSE); - g_hWnd = CreateWindowW(L"DDSViewWindowClass", g_szAppName, WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, CW_USEDEFAULT, rc.right - rc.left, rc.bottom - rc.top, nullptr, nullptr, hInstance, - nullptr); - if (!g_hWnd) - return E_FAIL; - - ShowWindow(g_hWnd, nCmdShow); - - return S_OK; -} - - -//-------------------------------------------------------------------------------------- -LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_PAINT: - { - PAINTSTRUCT ps; - std::ignore = BeginPaint(hWnd, &ps); - EndPaint(hWnd, &ps); - } - break; - - case WM_DESTROY: - PostQuitMessage(0); - break; - - case WM_KEYDOWN: - if (wParam == VK_RIGHT) - { - if (g_iCurrentIndex < g_iMaxIndex - 1) - ++g_iCurrentIndex; - } - else if (wParam == VK_LEFT) - { - if (g_iCurrentIndex > 0) - { - --g_iCurrentIndex; - } - } - else if (wParam >= '0' && wParam <= '9') - { - UINT index = (wParam == '0') ? 10u : static_cast(wParam - '1'); - if (index < g_iMaxIndex) - g_iCurrentIndex = index; - } - InvalidateRect(hWnd, nullptr, FALSE); - break; - - default: - return DefWindowProc(hWnd, message, wParam, lParam); - } - - return 0; -} - - -//-------------------------------------------------------------------------------------- -HRESULT InitDevice(const TexMetadata& mdata) -{ - HRESULT hr = S_OK; - - RECT rc; - GetClientRect(g_hWnd, &rc); - auto width = static_cast(rc.right - rc.left); - auto height = static_cast(rc.bottom - rc.top); - - UINT createDeviceFlags = 0; -#if defined( DEBUG ) || defined( _DEBUG ) - createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG; -#endif - - D3D_DRIVER_TYPE driverTypes[] = - { - D3D_DRIVER_TYPE_HARDWARE, - D3D_DRIVER_TYPE_WARP, - D3D_DRIVER_TYPE_REFERENCE, - }; - constexpr UINT numDriverTypes = static_cast(std::size(driverTypes)); - - D3D_FEATURE_LEVEL featureLevels[] = - { - D3D_FEATURE_LEVEL_11_0, - D3D_FEATURE_LEVEL_10_1, - D3D_FEATURE_LEVEL_10_0, - }; - constexpr UINT numFeatureLevels = static_cast(std::size(featureLevels)); - - DXGI_SWAP_CHAIN_DESC sd = {}; - sd.BufferCount = 1; - sd.BufferDesc.Width = width; - sd.BufferDesc.Height = height; - sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; - sd.BufferDesc.RefreshRate.Numerator = 60; - sd.BufferDesc.RefreshRate.Denominator = 1; - sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; - sd.OutputWindow = g_hWnd; - sd.SampleDesc.Count = 1; - sd.Windowed = TRUE; - - for (UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++) - { - g_driverType = driverTypes[driverTypeIndex]; - - // See https://walbourn.github.io/anatomy-of-direct3d-11-create-device/ - hr = D3D11CreateDeviceAndSwapChain(nullptr, g_driverType, nullptr, - createDeviceFlags, featureLevels, numFeatureLevels, - D3D11_SDK_VERSION, &sd, - &g_pSwapChain, &g_pd3dDevice, &g_featureLevel, &g_pImmediateContext); - if (SUCCEEDED(hr)) - break; - } - if (FAILED(hr)) - return hr; - - // Create a render target view - ID3D11Texture2D* pBackBuffer = nullptr; - hr = g_pSwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer)); - if (FAILED(hr)) - return hr; - - D3D11_RENDER_TARGET_VIEW_DESC vd = {}; - vd.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; - vd.Format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB; - hr = g_pd3dDevice->CreateRenderTargetView(pBackBuffer, &vd, &g_pRenderTargetView); - pBackBuffer->Release(); - if (FAILED(hr)) - return hr; - - // Create depth stencil texture - D3D11_TEXTURE2D_DESC descDepth = {}; - descDepth.Width = width; - descDepth.Height = height; - descDepth.MipLevels = 1; - descDepth.ArraySize = 1; - descDepth.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; - descDepth.SampleDesc.Count = 1; - descDepth.Usage = D3D11_USAGE_DEFAULT; - descDepth.BindFlags = D3D11_BIND_DEPTH_STENCIL; - hr = g_pd3dDevice->CreateTexture2D(&descDepth, nullptr, &g_pDepthStencil); - if (FAILED(hr)) - return hr; - - // Create the depth stencil view - D3D11_DEPTH_STENCIL_VIEW_DESC descDSV = {}; - descDSV.Format = descDepth.Format; - descDSV.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D; - descDSV.Texture2D.MipSlice = 0; - hr = g_pd3dDevice->CreateDepthStencilView(g_pDepthStencil, &descDSV, &g_pDepthStencilView); - if (FAILED(hr)) - return hr; - - g_pImmediateContext->OMSetRenderTargets(1, &g_pRenderTargetView, g_pDepthStencilView); - - // Setup the viewport - const D3D11_VIEWPORT vp = { 0.f, 0.f, static_cast(width), static_cast(height), 0.f, 1.f }; - g_pImmediateContext->RSSetViewports(1, &vp); - - // Create the vertex shader - hr = g_pd3dDevice->CreateVertexShader(g_VS, sizeof(g_VS), nullptr, &g_pVertexShader); - if (FAILED(hr)) - return hr; - - // Define the input layout - D3D11_INPUT_ELEMENT_DESC layout[] = - { - { "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "TEXCOORD", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, sizeof(XMFLOAT4), D3D11_INPUT_PER_VERTEX_DATA, 0 }, - }; - constexpr UINT numElements = static_cast(std::size(layout)); - - // Create the input layout - hr = g_pd3dDevice->CreateInputLayout(layout, numElements, g_VS, sizeof(g_VS), &g_pVertexLayout); - if (FAILED(hr)) - return hr; - - // Set the input layout - g_pImmediateContext->IASetInputLayout(g_pVertexLayout); - - // Select the pixel shader - bool isCubeMap = false; - bool is1D = false; - const BYTE* pshader = nullptr; - size_t pshader_size = 0; - - switch (mdata.dimension) - { - case TEX_DIMENSION_TEXTURE1D: - if (mdata.arraySize > 1) - { - pshader = g_PS_1DArray; - pshader_size = sizeof(g_PS_1DArray); - } - else - { - pshader = g_PS_1D; - pshader_size = sizeof(g_PS_1D); - } - is1D = true; - break; - - case TEX_DIMENSION_TEXTURE2D: - if (mdata.miscFlags & TEX_MISC_TEXTURECUBE) - { - pshader = g_PS_Cube; - pshader_size = sizeof(g_PS_Cube); - isCubeMap = true; - } - else if (mdata.arraySize > 1) - { - pshader = g_PS_2DArray; - pshader_size = sizeof(g_PS_2DArray); - } - else - { - pshader = g_PS_2D; - pshader_size = sizeof(g_PS_2D); - } - break; - - case TEX_DIMENSION_TEXTURE3D: - pshader = g_PS_3D; - pshader_size = sizeof(g_PS_3D); - break; - - default: - return E_FAIL; - } - - assert(pshader && pshader_size > 0); - - // Create the pixel shader - hr = g_pd3dDevice->CreatePixelShader(pshader, pshader_size, nullptr, &g_pPixelShader); - if (FAILED(hr)) - return hr; - - // Create vertex buffer - UINT nverts; - D3D11_SUBRESOURCE_DATA InitData = {}; - - static const SimpleVertex verticesCube[] = - { - // Render cubemaps as horizontal cross - - // XPOS - { XMFLOAT4(.5f, .25f, 0.f, 1.f), XMFLOAT4(0.f, 0.f, 0.f, 0.f) }, - { XMFLOAT4(1.f, .25f, 0.f, 1.f), XMFLOAT4(1.f, 0.f, 0.f, 0.f) }, - { XMFLOAT4(.5f, -.25f, 0.f, 1.f), XMFLOAT4(0.f, 1.f, 0.f, 0.f) }, - { XMFLOAT4(1.f, -.25f, 0.f, 1.f), XMFLOAT4(1.f, 1.f, 0.f, 0.f) }, - - // XNEG - { XMFLOAT4(-.5f, .25f, 0.f, 1.f), XMFLOAT4(0.f, 0.f, 1.f, 0.f) }, - { XMFLOAT4(0.f, .25f, 0.f, 1.f), XMFLOAT4(1.f, 0.f, 1.f, 0.f) }, - { XMFLOAT4(-.5f, -.25f, 0.f, 1.f), XMFLOAT4(0.f, 1.f, 1.f, 0.f) }, - { XMFLOAT4(0.f, -.25f, 0.f, 1.f), XMFLOAT4(1.f, 1.f, 1.f, 0.f) }, - - // YPOS - { XMFLOAT4(-.5f, .75f, 0.f, 1.f), XMFLOAT4(0.f, 0.f, 2.f, 0.f) }, - { XMFLOAT4(0.f, .75f, 0.f, 1.f), XMFLOAT4(1.f, 0.f, 2.f, 0.f) }, - { XMFLOAT4(-.5f, .25f, 0.f, 1.f), XMFLOAT4(0.f, 1.f, 2.f, 0.f) }, - { XMFLOAT4(0.f, .25f, 0.f, 1.f), XMFLOAT4(1.f, 1.f, 2.f, 0.f) }, - - // YNEG - { XMFLOAT4(-.5f, -.25f, 0.f, 1.f), XMFLOAT4(0.f, 0.f, 3.f, 0.f) }, - { XMFLOAT4(0.f, -.25f, 0.f, 1.f), XMFLOAT4(1.f, 0.f, 3.f, 0.f) }, - { XMFLOAT4(-.5f, -.75f, 0.f, 1.f), XMFLOAT4(0.f, 1.f, 3.f, 0.f) }, - { XMFLOAT4(0.f, -.75f, 0.f, 1.f), XMFLOAT4(1.f, 1.f, 3.f, 0.f) }, - - // ZPOS - { XMFLOAT4(0.f, .25f, 0.f, 1.f), XMFLOAT4(0.f, 0.f, 4.f, 0.f) }, - { XMFLOAT4(.5f, .25f, 0.f, 1.f), XMFLOAT4(1.f, 0.f, 4.f, 0.f) }, - { XMFLOAT4(0.f, -.25f, 0.f, 1.f), XMFLOAT4(0.f, 1.f, 4.f, 0.f) }, - { XMFLOAT4(.5f, -.25f, 0.f, 1.f), XMFLOAT4(1.f, 1.f, 4.f, 0.f) }, - - // ZNEG - { XMFLOAT4(-1.f, .25f, 0.f, 1.f), XMFLOAT4(0.f, 0.f, 5.f, 0.f) }, - { XMFLOAT4(-.5f, .25f, 0.f, 1.f), XMFLOAT4(1.f, 0.f, 5.f, 0.f) }, - { XMFLOAT4(-1.f, -.25f, 0.f, 1.f), XMFLOAT4(0.f, 1.f, 5.f, 0.f) }, - { XMFLOAT4(-.5f, -.25f, 0.f, 1.f), XMFLOAT4(1.f, 1.f, 5.f, 0.f) }, - }; - - static const SimpleVertex vertices[] = - { - { XMFLOAT4(-1.f, 1.f, 0.f, 1.f), XMFLOAT4(0.f, 0.f, 0.f, 0.f) }, - { XMFLOAT4(1.f, 1.f, 0.f, 1.f), XMFLOAT4(1.f, 0.f, 0.f, 0.f) }, - { XMFLOAT4(-1.f, -1.f, 0.f, 1.f), XMFLOAT4(0.f, 1.f, 0.f, 0.f) }, - { XMFLOAT4(1.f, -1.f, 0.f, 1.f), XMFLOAT4(1.f, 1.f, 0.f, 0.f) }, - }; - - static const SimpleVertex vertices1D[] = - { - { XMFLOAT4(-1.f, .05f, 0.f, 1.f), XMFLOAT4(0.f, 0.f, 0.f, 0.f) }, - { XMFLOAT4(1.f, .05f, 0.f, 1.f), XMFLOAT4(1.f, 0.f, 0.f, 0.f) }, - { XMFLOAT4(-1.f, -.05f, 0.f, 1.f), XMFLOAT4(0.f, 0.f, 0.f, 0.f) }, - { XMFLOAT4(1.f, -.05f, 0.f, 1.f), XMFLOAT4(1.f, 0.f, 0.f, 0.f) }, - }; - - if (isCubeMap) - { - nverts = static_cast(std::size(verticesCube)); - InitData.pSysMem = verticesCube; - } - else if (is1D) - { - nverts = static_cast(std::size(vertices1D)); - InitData.pSysMem = vertices1D; - } - else - { - nverts = static_cast(std::size(vertices)); - InitData.pSysMem = vertices; - } - - D3D11_BUFFER_DESC bd = {}; - bd.Usage = D3D11_USAGE_DEFAULT; - bd.ByteWidth = sizeof(SimpleVertex) * nverts; - bd.BindFlags = D3D11_BIND_VERTEX_BUFFER; - bd.CPUAccessFlags = 0; - hr = g_pd3dDevice->CreateBuffer(&bd, &InitData, &g_pVertexBuffer); - if (FAILED(hr)) - return hr; - - // Set vertex buffer - UINT stride = sizeof(SimpleVertex); - UINT offset = 0; - g_pImmediateContext->IASetVertexBuffers(0, 1, &g_pVertexBuffer, &stride, &offset); - - // Create index buffer - static const WORD indicesCube[] = - { - 0, 1, 2, - 2, 1, 3, - 4, 5, 6, - 6, 5, 7, - 8, 9, 10, - 10, 9, 11, - 12, 13, 14, - 14, 13, 15, - 16, 17, 18, - 18, 17, 19, - 20, 21, 22, - 22, 21, 23 - }; - - static const WORD indices[] = - { - 0, 1, 2, - 2, 1, 3 - }; - - if (isCubeMap) - { - g_iIndices = static_cast(std::size(indicesCube)); - InitData.pSysMem = indicesCube; - } - else - { - g_iIndices = static_cast(std::size(indices)); - InitData.pSysMem = indices; - } - - bd.Usage = D3D11_USAGE_DEFAULT; - bd.ByteWidth = g_iIndices * sizeof(WORD); - bd.BindFlags = D3D11_BIND_INDEX_BUFFER; - bd.CPUAccessFlags = 0; - hr = g_pd3dDevice->CreateBuffer(&bd, &InitData, &g_pIndexBuffer); - if (FAILED(hr)) - return hr; - - // Set index buffer - g_pImmediateContext->IASetIndexBuffer(g_pIndexBuffer, DXGI_FORMAT_R16_UINT, 0); - - // Set primitive topology - g_pImmediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - - // Create the constant buffers - bd.Usage = D3D11_USAGE_DEFAULT; - bd.ByteWidth = sizeof(CBArrayControl); - bd.BindFlags = D3D11_BIND_CONSTANT_BUFFER; - bd.CPUAccessFlags = 0; - hr = g_pd3dDevice->CreateBuffer(&bd, nullptr, &g_pCBArrayControl); - if (FAILED(hr)) - return hr; - - // Create the state objects - D3D11_SAMPLER_DESC sampDesc = {}; - sampDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT; - sampDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP; - sampDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP; - sampDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP; - sampDesc.ComparisonFunc = D3D11_COMPARISON_NEVER; - sampDesc.MinLOD = 0; - sampDesc.MaxLOD = D3D11_FLOAT32_MAX; - hr = g_pd3dDevice->CreateSamplerState(&sampDesc, &g_pSamplerLinear); - if (FAILED(hr)) - return hr; - - D3D11_BLEND_DESC dsc = - { - false, - false, - { - { - true, - D3D11_BLEND_SRC_ALPHA, - D3D11_BLEND_INV_SRC_ALPHA, - D3D11_BLEND_OP_ADD, - D3D11_BLEND_ZERO, - D3D11_BLEND_ZERO, - D3D11_BLEND_OP_ADD, - D3D11_COLOR_WRITE_ENABLE_ALL - }, - // ... - } - }; - hr = g_pd3dDevice->CreateBlendState(&dsc, &g_AlphaBlendState); - if (FAILED(hr)) - return hr; - - return S_OK; -} - - -//-------------------------------------------------------------------------------------- -void Render() -{ - float ClearColor[4] = { 0.f, 1.f, 1.f, 1.0f }; //red,green,blue,alpha - g_pImmediateContext->ClearRenderTargetView(g_pRenderTargetView, ClearColor); - g_pImmediateContext->ClearDepthStencilView(g_pDepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0); - - float bf[4] = { 1.0f, 1.0f, 1.0f, 1.0f }; - g_pImmediateContext->OMSetBlendState(g_AlphaBlendState, bf, 0xffffffff); - - CBArrayControl cb = {}; - cb.Index = static_cast(g_iCurrentIndex); - g_pImmediateContext->UpdateSubresource(g_pCBArrayControl, 0, nullptr, &cb, 0, 0); - - g_pImmediateContext->VSSetShader(g_pVertexShader, nullptr, 0); - g_pImmediateContext->PSSetShader(g_pPixelShader, nullptr, 0); - g_pImmediateContext->PSSetConstantBuffers(0, 1, &g_pCBArrayControl); - g_pImmediateContext->PSSetShaderResources(0, 1, &g_pSRV); - g_pImmediateContext->PSSetSamplers(0, 1, &g_pSamplerLinear); - g_pImmediateContext->DrawIndexed(g_iIndices, 0, 0); - - g_pSwapChain->Present(0, 0); -} - - -//-------------------------------------------------------------------------------------- -void CleanupDevice() -{ - if (g_pImmediateContext) g_pImmediateContext->ClearState(); - - if (g_pSamplerLinear) g_pSamplerLinear->Release(); - if (g_AlphaBlendState) g_AlphaBlendState->Release(); - if (g_pSRV) g_pSRV->Release(); - if (g_pVertexBuffer) g_pVertexBuffer->Release(); - if (g_pIndexBuffer) g_pIndexBuffer->Release(); - if (g_pCBArrayControl) g_pCBArrayControl->Release(); - if (g_pVertexLayout) g_pVertexLayout->Release(); - if (g_pVertexShader) g_pVertexShader->Release(); - if (g_pPixelShader) g_pPixelShader->Release(); - if (g_pDepthStencil) g_pDepthStencil->Release(); - if (g_pDepthStencilView) g_pDepthStencilView->Release(); - if (g_pRenderTargetView) g_pRenderTargetView->Release(); - if (g_pSwapChain) g_pSwapChain->Release(); - if (g_pImmediateContext) g_pImmediateContext->Release(); - if (g_pd3dDevice) g_pd3dDevice->Release(); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSView/ddsview.fx b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSView/ddsview.fx deleted file mode 100644 index ba876d2..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSView/ddsview.fx +++ /dev/null @@ -1,86 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: ddsview.fx -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -//-------------------------------------------------------------------------------------- - -//-------------------------------------------------------------------------------------- -// Constant Buffer Variables -//-------------------------------------------------------------------------------------- -Texture1D tx1D : register(t0); -Texture1DArray tx1DArray : register(t0); - -Texture2D tx2D : register(t0); -Texture2DArray tx2DArray : register(t0); - -Texture3D tx3D : register(t0); - -SamplerState samLinear : register(s0); - -cbuffer cbArrayControl : register(b0) -{ - float Index; -}; - -//-------------------------------------------------------------------------------------- -struct VS_INPUT -{ - float4 Pos : POSITION; - float4 Tex : TEXCOORD0; -}; - -struct PS_INPUT -{ - float4 Pos : SV_POSITION; - float4 Tex : TEXCOORD0; -}; - - -//-------------------------------------------------------------------------------------- -// Vertex Shader -//-------------------------------------------------------------------------------------- -PS_INPUT VS(VS_INPUT input) -{ - PS_INPUT output = (PS_INPUT)0; - output.Pos = input.Pos; - output.Tex = input.Tex; - return output; -} - - -//-------------------------------------------------------------------------------------- -// Pixel Shader -//-------------------------------------------------------------------------------------- -float4 PS_1D(PS_INPUT input) : SV_Target -{ - return tx1D.Sample(samLinear, input.Tex.x); -} - -float4 PS_1DArray(PS_INPUT input) : SV_Target -{ - return tx1DArray.Sample(samLinear, float2(input.Tex.x, Index)); -} - -float4 PS_2D(PS_INPUT input) : SV_Target -{ - return tx2D.Sample(samLinear, input.Tex.xy); -} - -float4 PS_2DArray(PS_INPUT input) : SV_Target -{ - return tx2DArray.Sample(samLinear, float3(input.Tex.xy, Index)); -} - -float4 PS_3D(PS_INPUT input) : SV_Target -{ - int Width, Height, Depth; - tx3D.GetDimensions(Width, Height, Depth); - - return tx3D.Sample(samLinear, float3(input.Tex.xy, Index / Depth)); -} - -float4 PS_Cube(PS_INPUT input) : SV_Target -{ - return tx2DArray.Sample(samLinear, float3(input.Tex.xy, input.Tex.z + (6*Index))); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSView/directx.ico b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSView/directx.ico deleted file mode 100644 index bc43c1b..0000000 Binary files a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSView/directx.ico and /dev/null differ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSView/hlsl.cmd b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSView/hlsl.cmd deleted file mode 100644 index aefdc0f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DDSView/hlsl.cmd +++ /dev/null @@ -1,67 +0,0 @@ -@echo off -rem Copyright (c) Microsoft Corporation. -rem Licensed under the MIT License. - -setlocal -set error=0 - -set FXCOPTS=/nologo /WX /Ges /Qstrip_reflect /Qstrip_debug - -set PCFXC="%WindowsSdkVerBinPath%x86\fxc.exe" -if exist %PCFXC% goto continue -set PCFXC="%WindowsSdkBinPath%%WindowsSDKVersion%\x86\fxc.exe" -if exist %PCFXC% goto continue -set PCFXC="%WindowsSdkDir%bin\%WindowsSDKVersion%\x86\fxc.exe" -if exist %PCFXC% goto continue - -set PCFXC=fxc.exe - -:continue -if not defined CompileShadersOutput set CompileShadersOutput=Shaders -set StrTrim=%CompileShadersOutput%## -set StrTrim=%StrTrim: ##=% -set CompileShadersOutput=%StrTrim:##=% -@if not exist "%CompileShadersOutput%" mkdir "%CompileShadersOutput%" - - -set FXC=%PCFXC% ddsview.fx %FXCOPTS% /EVS /Tvs_4_1 /Fh%CompileShadersOutput%\ddsview_vs.inc -echo %FXC% -%FXC% -@if ERRORLEVEL 1 goto error - -set FXC=%PCFXC% ddsview.fx %FXCOPTS% /EPS_1D /Tps_4_1 /Fh%CompileShadersOutput%\ddsview_ps1D.inc -echo %FXC% -%FXC% -@if ERRORLEVEL 1 goto error - -set FXC=%PCFXC% ddsview.fx %FXCOPTS% /EPS_1DArray /Tps_4_1 /Fh%CompileShadersOutput%\ddsview_ps1Darray.inc -echo %FXC% -%FXC% -@if ERRORLEVEL 1 goto error - -set FXC=%PCFXC% ddsview.fx %FXCOPTS% /EPS_2D /Tps_4_1 /Fh%CompileShadersOutput%\ddsview_ps2D.inc -echo %FXC% -%FXC% -@if ERRORLEVEL 1 goto error - -set FXC=%PCFXC% ddsview.fx %FXCOPTS% /EPS_2DArray /Tps_4_1 /Fh%CompileShadersOutput%\ddsview_ps2Darray.inc -echo %FXC% -%FXC% -@if ERRORLEVEL 1 goto error - -set FXC=%PCFXC% ddsview.fx %FXCOPTS% /EPS_3D /Tps_4_1 /Fh%CompileShadersOutput%\ddsview_ps3D.inc -echo %FXC% -%FXC% -@if ERRORLEVEL 1 goto error - -set FXC=%PCFXC% ddsview.fx %FXCOPTS% /EPS_Cube /Tps_4_1 /Fh%CompileShadersOutput%\ddsview_psCube.inc -echo %FXC% -%FXC% -@if ERRORLEVEL 1 goto error - -@echo --- Shaders built ok --- -@goto end -:error -@echo --- ERROR: Shader build failed --- -exit /b 1 -:end \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/BC.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/BC.cpp deleted file mode 100644 index e730550..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/BC.cpp +++ /dev/null @@ -1,1141 +0,0 @@ -//------------------------------------------------------------------------------------- -// BC.cpp -// -// Block-compression (BC) functionality for BC1, BC2, BC3 (orginal DXTn formats) -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//------------------------------------------------------------------------------------- - -#include "DirectXTexP.h" - -// Experiemental encoding variants, not enabled by default -//#define COLOR_WEIGHTS -//#define COLOR_AVG_0WEIGHTS - -#include "BC.h" - -using namespace DirectX; -using namespace DirectX::PackedVector; - -namespace -{ - //------------------------------------------------------------------------------------- - // Constants - //------------------------------------------------------------------------------------- - - // Perceptual weightings for the importance of each channel. - const HDRColorA g_Luminance(0.2125f / 0.7154f, 1.0f, 0.0721f / 0.7154f, 1.0f); - const HDRColorA g_LuminanceInv(0.7154f / 0.2125f, 1.0f, 0.7154f / 0.0721f, 1.0f); - - //------------------------------------------------------------------------------------- - // Decode/Encode RGB 5/6/5 colors - //------------------------------------------------------------------------------------- - inline void Decode565(_Out_ HDRColorA *pColor, _In_ const uint16_t w565) noexcept - { - pColor->r = static_cast((w565 >> 11) & 31) * (1.0f / 31.0f); - pColor->g = static_cast((w565 >> 5) & 63) * (1.0f / 63.0f); - pColor->b = static_cast((w565 >> 0) & 31) * (1.0f / 31.0f); - pColor->a = 1.0f; - } - - inline uint16_t Encode565(_In_ const HDRColorA *pColor) noexcept - { - HDRColorA Color; - - Color.r = (pColor->r < 0.0f) ? 0.0f : (pColor->r > 1.0f) ? 1.0f : pColor->r; - Color.g = (pColor->g < 0.0f) ? 0.0f : (pColor->g > 1.0f) ? 1.0f : pColor->g; - Color.b = (pColor->b < 0.0f) ? 0.0f : (pColor->b > 1.0f) ? 1.0f : pColor->b; - Color.a = pColor->a; - - uint16_t w; - - w = static_cast( - (static_cast(Color.r * 31.0f + 0.5f) << 11) - | (static_cast(Color.g * 63.0f + 0.5f) << 5) - | (static_cast(Color.b * 31.0f + 0.5f) << 0)); - - return w; - } - - - //------------------------------------------------------------------------------------- - void OptimizeRGB( - _Out_ HDRColorA *pX, - _Out_ HDRColorA *pY, - _In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA *pPoints, - uint32_t cSteps, - uint32_t flags) noexcept - { - constexpr float fEpsilon = (0.25f / 64.0f) * (0.25f / 64.0f); - static const float pC3[] = { 2.0f / 2.0f, 1.0f / 2.0f, 0.0f / 2.0f }; - static const float pD3[] = { 0.0f / 2.0f, 1.0f / 2.0f, 2.0f / 2.0f }; - static const float pC4[] = { 3.0f / 3.0f, 2.0f / 3.0f, 1.0f / 3.0f, 0.0f / 3.0f }; - static const float pD4[] = { 0.0f / 3.0f, 1.0f / 3.0f, 2.0f / 3.0f, 3.0f / 3.0f }; - - const float *pC = (3 == cSteps) ? pC3 : pC4; - const float *pD = (3 == cSteps) ? pD3 : pD4; - - // Find Min and Max points, as starting point - HDRColorA X = (flags & BC_FLAGS_UNIFORM) ? HDRColorA(1.f, 1.f, 1.f, 1.f) : g_Luminance; - HDRColorA Y = HDRColorA(0.0f, 0.0f, 0.0f, 1.0f); - - for (size_t iPoint = 0; iPoint < NUM_PIXELS_PER_BLOCK; iPoint++) - { - #ifdef COLOR_WEIGHTS - if (pPoints[iPoint].a > 0.0f) - #endif // COLOR_WEIGHTS - { - if (pPoints[iPoint].r < X.r) - X.r = pPoints[iPoint].r; - - if (pPoints[iPoint].g < X.g) - X.g = pPoints[iPoint].g; - - if (pPoints[iPoint].b < X.b) - X.b = pPoints[iPoint].b; - - if (pPoints[iPoint].r > Y.r) - Y.r = pPoints[iPoint].r; - - if (pPoints[iPoint].g > Y.g) - Y.g = pPoints[iPoint].g; - - if (pPoints[iPoint].b > Y.b) - Y.b = pPoints[iPoint].b; - } - } - - // Diagonal axis - const HDRColorA AB(Y.r - X.r, Y.g - X.g, Y.b - X.b, 0.0f); - - const float fAB = AB.r * AB.r + AB.g * AB.g + AB.b * AB.b; - - // Single color block.. no need to root-find - if (fAB < FLT_MIN) - { - pX->r = X.r; pX->g = X.g; pX->b = X.b; pX->a = 1.0f; - pY->r = Y.r; pY->g = Y.g; pY->b = Y.b; pY->a = 1.0f; - return; - } - - // Try all four axis directions, to determine which diagonal best fits data - const float fABInv = 1.0f / fAB; - - HDRColorA Dir(AB.r * fABInv, AB.g * fABInv, AB.b * fABInv, 0.0f); - - const HDRColorA Mid( - (X.r + Y.r) * 0.5f, - (X.g + Y.g) * 0.5f, - (X.b + Y.b) * 0.5f, - 0.0f); - - float fDir[4] = {}; - - for (size_t iPoint = 0; iPoint < NUM_PIXELS_PER_BLOCK; iPoint++) - { - HDRColorA Pt; - Pt.r = (pPoints[iPoint].r - Mid.r) * Dir.r; - Pt.g = (pPoints[iPoint].g - Mid.g) * Dir.g; - Pt.b = (pPoints[iPoint].b - Mid.b) * Dir.b; - Pt.a = 0.0f; - - float f; - - #ifdef COLOR_WEIGHTS - f = Pt.r + Pt.g + Pt.b; - fDir[0] += pPoints[iPoint].a * f * f; - - f = Pt.r + Pt.g - Pt.b; - fDir[1] += pPoints[iPoint].a * f * f; - - f = Pt.r - Pt.g + Pt.b; - fDir[2] += pPoints[iPoint].a * f * f; - - f = Pt.r - Pt.g - Pt.b; - fDir[3] += pPoints[iPoint].a * f * f; - #else - f = Pt.r + Pt.g + Pt.b; - fDir[0] += f * f; - - f = Pt.r + Pt.g - Pt.b; - fDir[1] += f * f; - - f = Pt.r - Pt.g + Pt.b; - fDir[2] += f * f; - - f = Pt.r - Pt.g - Pt.b; - fDir[3] += f * f; - #endif // COLOR_WEIGHTS - } - - float fDirMax = fDir[0]; - size_t iDirMax = 0; - - for (size_t iDir = 1; iDir < 4; iDir++) - { - if (fDir[iDir] > fDirMax) - { - fDirMax = fDir[iDir]; - iDirMax = iDir; - } - } - - if (iDirMax & 2) - { - const float f = X.g; X.g = Y.g; Y.g = f; - } - - if (iDirMax & 1) - { - const float f = X.b; X.b = Y.b; Y.b = f; - } - - - // Two color block.. no need to root-find - if (fAB < 1.0f / 4096.0f) - { - pX->r = X.r; pX->g = X.g; pX->b = X.b; pX->a = 1.0f; - pY->r = Y.r; pY->g = Y.g; pY->b = Y.b; pY->a = 1.0f; - return; - } - - // Use Newton's Method to find local minima of sum-of-squares error. - auto const fSteps = static_cast(cSteps - 1); - - for (size_t iIteration = 0; iIteration < 8; iIteration++) - { - // Calculate new steps - HDRColorA pSteps[4]; - - for (size_t iStep = 0; iStep < cSteps; iStep++) - { - pSteps[iStep].r = X.r * pC[iStep] + Y.r * pD[iStep]; - pSteps[iStep].g = X.g * pC[iStep] + Y.g * pD[iStep]; - pSteps[iStep].b = X.b * pC[iStep] + Y.b * pD[iStep]; - pSteps[iStep].a = 1.0f; - } - - - // Calculate color direction - Dir.r = Y.r - X.r; - Dir.g = Y.g - X.g; - Dir.b = Y.b - X.b; - - const float fLen = (Dir.r * Dir.r + Dir.g * Dir.g + Dir.b * Dir.b); - - if (fLen < (1.0f / 4096.0f)) - break; - - const float fScale = fSteps / fLen; - - Dir.r *= fScale; - Dir.g *= fScale; - Dir.b *= fScale; - - - // Evaluate function, and derivatives - float d2X = 0.f; - float d2Y = 0.f; - HDRColorA dX = {}; - HDRColorA dY = {}; - - for (size_t iPoint = 0; iPoint < NUM_PIXELS_PER_BLOCK; iPoint++) - { - const float fDot = (pPoints[iPoint].r - X.r) * Dir.r + - (pPoints[iPoint].g - X.g) * Dir.g + - (pPoints[iPoint].b - X.b) * Dir.b; - - - uint32_t iStep; - if (fDot <= 0.0f) - iStep = 0; - else if (fDot >= fSteps) - iStep = cSteps - 1; - else - iStep = uint32_t(fDot + 0.5f); - - - HDRColorA Diff; - Diff.r = pSteps[iStep].r - pPoints[iPoint].r; - Diff.g = pSteps[iStep].g - pPoints[iPoint].g; - Diff.b = pSteps[iStep].b - pPoints[iPoint].b; - Diff.a = 0.0f; - - #ifdef COLOR_WEIGHTS - const float fC = pC[iStep] * pPoints[iPoint].a * (1.0f / 8.0f); - const float fD = pD[iStep] * pPoints[iPoint].a * (1.0f / 8.0f); - #else - const float fC = pC[iStep] * (1.0f / 8.0f); - const float fD = pD[iStep] * (1.0f / 8.0f); - #endif // COLOR_WEIGHTS - - d2X += fC * pC[iStep]; - dX.r += fC * Diff.r; - dX.g += fC * Diff.g; - dX.b += fC * Diff.b; - - d2Y += fD * pD[iStep]; - dY.r += fD * Diff.r; - dY.g += fD * Diff.g; - dY.b += fD * Diff.b; - } - - // Move endpoints - if (d2X > 0.0f) - { - const float f = -1.0f / d2X; - - X.r += dX.r * f; - X.g += dX.g * f; - X.b += dX.b * f; - } - - if (d2Y > 0.0f) - { - const float f = -1.0f / d2Y; - - Y.r += dY.r * f; - Y.g += dY.g * f; - Y.b += dY.b * f; - } - - if ((dX.r * dX.r < fEpsilon) && (dX.g * dX.g < fEpsilon) && (dX.b * dX.b < fEpsilon) && - (dY.r * dY.r < fEpsilon) && (dY.g * dY.g < fEpsilon) && (dY.b * dY.b < fEpsilon)) - { - break; - } - } - - pX->r = X.r; pX->g = X.g; pX->b = X.b; pX->a = 1.0f; - pY->r = Y.r; pY->g = Y.g; pY->b = Y.b; pY->a = 1.0f; - } - - - //------------------------------------------------------------------------------------- - inline void DecodeBC1( - _Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, - _In_ const D3DX_BC1 *pBC, - bool isbc1) noexcept - { - assert(pColor && pBC); - static_assert(sizeof(D3DX_BC1) == 8, "D3DX_BC1 should be 8 bytes"); - - static XMVECTORF32 s_Scale = { { { 1.f / 31.f, 1.f / 63.f, 1.f / 31.f, 1.f } } }; - - XMVECTOR clr0 = XMLoadU565(reinterpret_cast(&pBC->rgb[0])); - XMVECTOR clr1 = XMLoadU565(reinterpret_cast(&pBC->rgb[1])); - - clr0 = XMVectorMultiply(clr0, s_Scale); - clr1 = XMVectorMultiply(clr1, s_Scale); - - clr0 = XMVectorSwizzle<2, 1, 0, 3>(clr0); - clr1 = XMVectorSwizzle<2, 1, 0, 3>(clr1); - - clr0 = XMVectorSelect(g_XMIdentityR3, clr0, g_XMSelect1110); - clr1 = XMVectorSelect(g_XMIdentityR3, clr1, g_XMSelect1110); - - XMVECTOR clr2, clr3; - if (isbc1 && (pBC->rgb[0] <= pBC->rgb[1])) - { - clr2 = XMVectorLerp(clr0, clr1, 0.5f); - clr3 = XMVectorZero(); // Alpha of 0 - } - else - { - clr2 = XMVectorLerp(clr0, clr1, 1.f / 3.f); - clr3 = XMVectorLerp(clr0, clr1, 2.f / 3.f); - } - - uint32_t dw = pBC->bitmap; - - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i, dw >>= 2) - { - switch (dw & 3) - { - case 0: pColor[i] = clr0; break; - case 1: pColor[i] = clr1; break; - case 2: pColor[i] = clr2; break; - - case 3: - default: pColor[i] = clr3; break; - } - } - } - - - //------------------------------------------------------------------------------------- - void EncodeBC1( - _Out_ D3DX_BC1 *pBC, - _In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA *pColor, - bool bColorKey, - float threshold, - uint32_t flags) noexcept - { - assert(pBC && pColor); - static_assert(sizeof(D3DX_BC1) == 8, "D3DX_BC1 should be 8 bytes"); - - // Determine if we need to colorkey this block - uint32_t uSteps; - - if (bColorKey) - { - size_t uColorKey = 0; - - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - { - if (pColor[i].a < threshold) - uColorKey++; - } - - if (NUM_PIXELS_PER_BLOCK == uColorKey) - { - pBC->rgb[0] = 0x0000; - pBC->rgb[1] = 0xffff; - pBC->bitmap = 0xffffffff; - return; - } - - uSteps = (uColorKey > 0) ? 3u : 4u; - } - else - { - uSteps = 4u; - } - - // Quantize block to R56B5, using Floyd Stienberg error diffusion. This - // increases the chance that colors will map directly to the quantized - // axis endpoints. - HDRColorA Color[NUM_PIXELS_PER_BLOCK]; - HDRColorA Error[NUM_PIXELS_PER_BLOCK]; - - if (flags & BC_FLAGS_DITHER_RGB) - memset(Error, 0x00, NUM_PIXELS_PER_BLOCK * sizeof(HDRColorA)); - - size_t i; - for (i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - { - HDRColorA Clr; - Clr.r = pColor[i].r; - Clr.g = pColor[i].g; - Clr.b = pColor[i].b; - Clr.a = 1.0f; - - if (flags & BC_FLAGS_DITHER_RGB) - { - Clr.r += Error[i].r; - Clr.g += Error[i].g; - Clr.b += Error[i].b; - } - - Color[i].r = static_cast(static_cast(Clr.r * 31.0f + 0.5f)) * (1.0f / 31.0f); - Color[i].g = static_cast(static_cast(Clr.g * 63.0f + 0.5f)) * (1.0f / 63.0f); - Color[i].b = static_cast(static_cast(Clr.b * 31.0f + 0.5f)) * (1.0f / 31.0f); - - #ifdef COLOR_WEIGHTS - Color[i].a = pColor[i].a; - #else - Color[i].a = 1.0f; - #endif // COLOR_WEIGHTS - - if (flags & BC_FLAGS_DITHER_RGB) - { - HDRColorA Diff; - Diff.r = Color[i].a * (Clr.r - Color[i].r); - Diff.g = Color[i].a * (Clr.g - Color[i].g); - Diff.b = Color[i].a * (Clr.b - Color[i].b); - Diff.a = 0.0f; - - if (3 != (i & 3)) - { - assert(i < 15); - _Analysis_assume_(i < 15); - Error[i + 1].r += Diff.r * (7.0f / 16.0f); - Error[i + 1].g += Diff.g * (7.0f / 16.0f); - Error[i + 1].b += Diff.b * (7.0f / 16.0f); - } - - if (i < 12) - { - if (i & 3) - { - Error[i + 3].r += Diff.r * (3.0f / 16.0f); - Error[i + 3].g += Diff.g * (3.0f / 16.0f); - Error[i + 3].b += Diff.b * (3.0f / 16.0f); - } - - Error[i + 4].r += Diff.r * (5.0f / 16.0f); - Error[i + 4].g += Diff.g * (5.0f / 16.0f); - Error[i + 4].b += Diff.b * (5.0f / 16.0f); - - if (3 != (i & 3)) - { - assert(i < 11); - _Analysis_assume_(i < 11); - Error[i + 5].r += Diff.r * (1.0f / 16.0f); - Error[i + 5].g += Diff.g * (1.0f / 16.0f); - Error[i + 5].b += Diff.b * (1.0f / 16.0f); - } - } - } - - if (!(flags & BC_FLAGS_UNIFORM)) - { - Color[i].r *= g_Luminance.r; - Color[i].g *= g_Luminance.g; - Color[i].b *= g_Luminance.b; - } - } - - // Perform 6D root finding function to find two endpoints of color axis. - // Then quantize and sort the endpoints depending on mode. - HDRColorA ColorA, ColorB, ColorC, ColorD; - - OptimizeRGB(&ColorA, &ColorB, Color, uSteps, flags); - - if (flags & BC_FLAGS_UNIFORM) - { - ColorC = ColorA; - ColorD = ColorB; - } - else - { - ColorC.r = ColorA.r * g_LuminanceInv.r; - ColorC.g = ColorA.g * g_LuminanceInv.g; - ColorC.b = ColorA.b * g_LuminanceInv.b; - ColorC.a = ColorA.a; - - ColorD.r = ColorB.r * g_LuminanceInv.r; - ColorD.g = ColorB.g * g_LuminanceInv.g; - ColorD.b = ColorB.b * g_LuminanceInv.b; - ColorD.a = ColorB.a; - } - - const uint16_t wColorA = Encode565(&ColorC); - const uint16_t wColorB = Encode565(&ColorD); - - if ((uSteps == 4) && (wColorA == wColorB)) - { - pBC->rgb[0] = wColorA; - pBC->rgb[1] = wColorB; - pBC->bitmap = 0x00000000; - return; - } - - Decode565(&ColorC, wColorA); - Decode565(&ColorD, wColorB); - - if (flags & BC_FLAGS_UNIFORM) - { - ColorA = ColorC; - ColorB = ColorD; - } - else - { - ColorA.r = ColorC.r * g_Luminance.r; - ColorA.g = ColorC.g * g_Luminance.g; - ColorA.b = ColorC.b * g_Luminance.b; - - ColorB.r = ColorD.r * g_Luminance.r; - ColorB.g = ColorD.g * g_Luminance.g; - ColorB.b = ColorD.b * g_Luminance.b; - } - - // Calculate color steps - HDRColorA Step[4]; - - if ((3 == uSteps) == (wColorA <= wColorB)) - { - pBC->rgb[0] = wColorA; - pBC->rgb[1] = wColorB; - - Step[0] = ColorA; - Step[1] = ColorB; - } - else - { - pBC->rgb[0] = wColorB; - pBC->rgb[1] = wColorA; - - Step[0] = ColorB; - Step[1] = ColorA; - } - - static const size_t pSteps3[] = { 0, 2, 1 }; - static const size_t pSteps4[] = { 0, 2, 3, 1 }; - const size_t *pSteps; - - if (3 == uSteps) - { - pSteps = pSteps3; - - HDRColorALerp(&Step[2], &Step[0], &Step[1], 0.5f); - } - else - { - pSteps = pSteps4; - - HDRColorALerp(&Step[2], &Step[0], &Step[1], 1.0f / 3.0f); - HDRColorALerp(&Step[3], &Step[0], &Step[1], 2.0f / 3.0f); - } - - // Calculate color direction - HDRColorA Dir; - Dir.r = Step[1].r - Step[0].r; - Dir.g = Step[1].g - Step[0].g; - Dir.b = Step[1].b - Step[0].b; - Dir.a = 0.0f; - - const auto fSteps = static_cast(uSteps - 1); - const float fScale = (wColorA != wColorB) ? (fSteps / (Dir.r * Dir.r + Dir.g * Dir.g + Dir.b * Dir.b)) : 0.0f; - - Dir.r *= fScale; - Dir.g *= fScale; - Dir.b *= fScale; - - // Encode colors - uint32_t dw = 0; - if (flags & BC_FLAGS_DITHER_RGB) - memset(Error, 0x00, NUM_PIXELS_PER_BLOCK * sizeof(HDRColorA)); - - for (i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - { - if ((3 == uSteps) && (pColor[i].a < threshold)) - { - dw = (3u << 30) | (dw >> 2); - } - else - { - HDRColorA Clr; - if (flags & BC_FLAGS_UNIFORM) - { - Clr.r = pColor[i].r; - Clr.g = pColor[i].g; - Clr.b = pColor[i].b; - } - else - { - Clr.r = pColor[i].r * g_Luminance.r; - Clr.g = pColor[i].g * g_Luminance.g; - Clr.b = pColor[i].b * g_Luminance.b; - } - Clr.a = 1.0f; - - if (flags & BC_FLAGS_DITHER_RGB) - { - Clr.r += Error[i].r; - Clr.g += Error[i].g; - Clr.b += Error[i].b; - } - - const float fDot = (Clr.r - Step[0].r) * Dir.r + (Clr.g - Step[0].g) * Dir.g + (Clr.b - Step[0].b) * Dir.b; - - uint32_t iStep; - if (fDot <= 0.0f) - iStep = 0; - else if (fDot >= fSteps) - iStep = 1; - else - iStep = uint32_t(pSteps[uint32_t(fDot + 0.5f)]); - - dw = (iStep << 30) | (dw >> 2); - - if (flags & BC_FLAGS_DITHER_RGB) - { - HDRColorA Diff; - Diff.r = Color[i].a * (Clr.r - Step[iStep].r); - Diff.g = Color[i].a * (Clr.g - Step[iStep].g); - Diff.b = Color[i].a * (Clr.b - Step[iStep].b); - Diff.a = 0.0f; - - if (3 != (i & 3)) - { - Error[i + 1].r += Diff.r * (7.0f / 16.0f); - Error[i + 1].g += Diff.g * (7.0f / 16.0f); - Error[i + 1].b += Diff.b * (7.0f / 16.0f); - } - - if (i < 12) - { - if (i & 3) - { - Error[i + 3].r += Diff.r * (3.0f / 16.0f); - Error[i + 3].g += Diff.g * (3.0f / 16.0f); - Error[i + 3].b += Diff.b * (3.0f / 16.0f); - } - - Error[i + 4].r += Diff.r * (5.0f / 16.0f); - Error[i + 4].g += Diff.g * (5.0f / 16.0f); - Error[i + 4].b += Diff.b * (5.0f / 16.0f); - - if (3 != (i & 3)) - { - Error[i + 5].r += Diff.r * (1.0f / 16.0f); - Error[i + 5].g += Diff.g * (1.0f / 16.0f); - Error[i + 5].b += Diff.b * (1.0f / 16.0f); - } - } - } - } - } - - pBC->bitmap = dw; - } - - //------------------------------------------------------------------------------------- -#ifdef COLOR_WEIGHTS - void EncodeSolidBC1(_Out_ D3DX_BC1 *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA *pColor) - { - #ifdef COLOR_AVG_0WEIGHTS - // Compute avg color - HDRColorA Color; - Color.r = pColor[0].r; - Color.g = pColor[0].g; - Color.b = pColor[0].b; - - for (size_t i = 1; i < NUM_PIXELS_PER_BLOCK; ++i) - { - Color.r += pColor[i].r; - Color.g += pColor[i].g; - Color.b += pColor[i].b; - } - - Color.r *= 1.0f / 16.0f; - Color.g *= 1.0f / 16.0f; - Color.b *= 1.0f / 16.0f; - - const uint16_t wColor = Encode565(&Color); - #else - const uint16_t wColor = 0x0000; - #endif // COLOR_AVG_0WEIGHTS - - // Encode solid block - pBC->rgb[0] = wColor; - pBC->rgb[1] = wColor; - pBC->bitmap = 0x00000000; - } -#endif // COLOR_WEIGHTS -} - - -//===================================================================================== -// Entry points -//===================================================================================== - -//------------------------------------------------------------------------------------- -// BC1 Compression -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -void DirectX::D3DXDecodeBC1(XMVECTOR *pColor, const uint8_t *pBC) noexcept -{ - auto pBC1 = reinterpret_cast(pBC); - DecodeBC1(pColor, pBC1, true); -} - -_Use_decl_annotations_ -void DirectX::D3DXEncodeBC1(uint8_t *pBC, const XMVECTOR *pColor, float threshold, uint32_t flags) noexcept -{ - assert(pBC && pColor); - - HDRColorA Color[NUM_PIXELS_PER_BLOCK]; - - if (flags & BC_FLAGS_DITHER_A) - { - float fError[NUM_PIXELS_PER_BLOCK] = {}; - - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - { - HDRColorA clr; - XMStoreFloat4(reinterpret_cast(&clr), pColor[i]); - - const float fAlph = clr.a + fError[i]; - - Color[i].r = clr.r; - Color[i].g = clr.g; - Color[i].b = clr.b; - Color[i].a = static_cast(static_cast(clr.a + fError[i] + 0.5f)); - - const float fDiff = fAlph - Color[i].a; - - if (3 != (i & 3)) - { - assert(i < 15); - _Analysis_assume_(i < 15); - fError[i + 1] += fDiff * (7.0f / 16.0f); - } - - if (i < 12) - { - if (i & 3) - fError[i + 3] += fDiff * (3.0f / 16.0f); - - fError[i + 4] += fDiff * (5.0f / 16.0f); - - if (3 != (i & 3)) - { - assert(i < 11); - _Analysis_assume_(i < 11); - fError[i + 5] += fDiff * (1.0f / 16.0f); - } - } - } - } - else - { - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - { - XMStoreFloat4(reinterpret_cast(&Color[i]), pColor[i]); - } - } - - auto pBC1 = reinterpret_cast(pBC); - EncodeBC1(pBC1, Color, true, threshold, flags); -} - - -//------------------------------------------------------------------------------------- -// BC2 Compression -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -void DirectX::D3DXDecodeBC2(XMVECTOR *pColor, const uint8_t *pBC) noexcept -{ - assert(pColor && pBC); - static_assert(sizeof(D3DX_BC2) == 16, "D3DX_BC2 should be 16 bytes"); - - auto pBC2 = reinterpret_cast(pBC); - - // RGB part - DecodeBC1(pColor, &pBC2->bc1, false); - - // 4-bit alpha part - uint32_t dw = pBC2->bitmap[0]; - - for (size_t i = 0; i < 8; ++i, dw >>= 4) - { - #pragma prefast(suppress:22103, "writing blocks in two halves confuses tool") - pColor[i] = XMVectorSetW(pColor[i], static_cast(dw & 0xf) * (1.0f / 15.0f)); - } - - dw = pBC2->bitmap[1]; - - for (size_t i = 8; i < NUM_PIXELS_PER_BLOCK; ++i, dw >>= 4) - pColor[i] = XMVectorSetW(pColor[i], static_cast(dw & 0xf) * (1.0f / 15.0f)); -} - -_Use_decl_annotations_ -void DirectX::D3DXEncodeBC2(uint8_t *pBC, const XMVECTOR *pColor, uint32_t flags) noexcept -{ - assert(pBC && pColor); - static_assert(sizeof(D3DX_BC2) == 16, "D3DX_BC2 should be 16 bytes"); - - HDRColorA Color[NUM_PIXELS_PER_BLOCK]; - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - { - XMStoreFloat4(reinterpret_cast(&Color[i]), pColor[i]); - } - - auto pBC2 = reinterpret_cast(pBC); - - // 4-bit alpha part. Dithered using Floyd Stienberg error diffusion. - pBC2->bitmap[0] = 0; - pBC2->bitmap[1] = 0; - - float fError[NUM_PIXELS_PER_BLOCK] = {}; - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - { - float fAlph = Color[i].a; - if (flags & BC_FLAGS_DITHER_A) - fAlph += fError[i]; - - const auto u = static_cast(fAlph * 15.0f + 0.5f); - - pBC2->bitmap[i >> 3] >>= 4; - pBC2->bitmap[i >> 3] |= (u << 28); - - if (flags & BC_FLAGS_DITHER_A) - { - const float fDiff = fAlph - float(u) * (1.0f / 15.0f); - - if (3 != (i & 3)) - { - assert(i < 15); - _Analysis_assume_(i < 15); - fError[i + 1] += fDiff * (7.0f / 16.0f); - } - - if (i < 12) - { - if (i & 3) - fError[i + 3] += fDiff * (3.0f / 16.0f); - - fError[i + 4] += fDiff * (5.0f / 16.0f); - - if (3 != (i & 3)) - { - assert(i < 11); - _Analysis_assume_(i < 11); - fError[i + 5] += fDiff * (1.0f / 16.0f); - } - } - } - } - - // RGB part -#ifdef COLOR_WEIGHTS - if (!pBC2->bitmap[0] && !pBC2->bitmap[1]) - { - EncodeSolidBC1(pBC2->dxt1, Color); - return; - } -#endif // COLOR_WEIGHTS - - EncodeBC1(&pBC2->bc1, Color, false, 0.f, flags); -} - - -//------------------------------------------------------------------------------------- -// BC3 Compression -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -void DirectX::D3DXDecodeBC3(XMVECTOR *pColor, const uint8_t *pBC) noexcept -{ - assert(pColor && pBC); - static_assert(sizeof(D3DX_BC3) == 16, "D3DX_BC3 should be 16 bytes"); - - auto pBC3 = reinterpret_cast(pBC); - - // RGB part - DecodeBC1(pColor, &pBC3->bc1, false); - - // Adaptive 3-bit alpha part - float fAlpha[8]; - - fAlpha[0] = static_cast(pBC3->alpha[0]) * (1.0f / 255.0f); - fAlpha[1] = static_cast(pBC3->alpha[1]) * (1.0f / 255.0f); - - if (pBC3->alpha[0] > pBC3->alpha[1]) - { - for (size_t i = 1; i < 7; ++i) - fAlpha[i + 1] = (fAlpha[0] * float(7u - i) + fAlpha[1] * float(i)) * (1.0f / 7.0f); - } - else - { - for (size_t i = 1; i < 5; ++i) - fAlpha[i + 1] = (fAlpha[0] * float(5u - i) + fAlpha[1] * float(i)) * (1.0f / 5.0f); - - fAlpha[6] = 0.0f; - fAlpha[7] = 1.0f; - } - - uint32_t dw = uint32_t(pBC3->bitmap[0]) | uint32_t(pBC3->bitmap[1] << 8) | uint32_t(pBC3->bitmap[2] << 16); - - for (size_t i = 0; i < 8; ++i, dw >>= 3) - pColor[i] = XMVectorSetW(pColor[i], fAlpha[dw & 0x7]); - - dw = uint32_t(pBC3->bitmap[3]) | uint32_t(pBC3->bitmap[4] << 8) | uint32_t(pBC3->bitmap[5] << 16); - - for (size_t i = 8; i < NUM_PIXELS_PER_BLOCK; ++i, dw >>= 3) - pColor[i] = XMVectorSetW(pColor[i], fAlpha[dw & 0x7]); -} - -_Use_decl_annotations_ -void DirectX::D3DXEncodeBC3(uint8_t *pBC, const XMVECTOR *pColor, uint32_t flags) noexcept -{ - assert(pBC && pColor); - static_assert(sizeof(D3DX_BC3) == 16, "D3DX_BC3 should be 16 bytes"); - - HDRColorA Color[NUM_PIXELS_PER_BLOCK]; - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - { - XMStoreFloat4(reinterpret_cast(&Color[i]), pColor[i]); - } - - auto pBC3 = reinterpret_cast(pBC); - - // Quantize block to A8, using Floyd Stienberg error diffusion. This - // increases the chance that colors will map directly to the quantized - // axis endpoints. - float fAlpha[NUM_PIXELS_PER_BLOCK] = {}; - float fError[NUM_PIXELS_PER_BLOCK] = {}; - - float fMinAlpha = Color[0].a; - float fMaxAlpha = Color[0].a; - - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - { - float fAlph = Color[i].a; - if (flags & BC_FLAGS_DITHER_A) - fAlph += fError[i]; - - fAlpha[i] = static_cast(static_cast(fAlph * 255.0f + 0.5f)) * (1.0f / 255.0f); - - if (fAlpha[i] < fMinAlpha) - fMinAlpha = fAlpha[i]; - else if (fAlpha[i] > fMaxAlpha) - fMaxAlpha = fAlpha[i]; - - if (flags & BC_FLAGS_DITHER_A) - { - const float fDiff = fAlph - fAlpha[i]; - - if (3 != (i & 3)) - { - assert(i < 15); - _Analysis_assume_(i < 15); - fError[i + 1] += fDiff * (7.0f / 16.0f); - } - - if (i < 12) - { - if (i & 3) - fError[i + 3] += fDiff * (3.0f / 16.0f); - - fError[i + 4] += fDiff * (5.0f / 16.0f); - - if (3 != (i & 3)) - { - assert(i < 11); - _Analysis_assume_(i < 11); - fError[i + 5] += fDiff * (1.0f / 16.0f); - } - } - } - } - -#ifdef COLOR_WEIGHTS - if (0.0f == fMaxAlpha) - { - EncodeSolidBC1(&pBC3->dxt1, Color); - pBC3->alpha[0] = 0x00; - pBC3->alpha[1] = 0x00; - memset(pBC3->bitmap, 0x00, 6); - } -#endif - - // RGB part - EncodeBC1(&pBC3->bc1, Color, false, 0.f, flags); - - // Alpha part - if (1.0f == fMinAlpha) - { - pBC3->alpha[0] = 0xff; - pBC3->alpha[1] = 0xff; - memset(pBC3->bitmap, 0x00, 6); - return; - } - - // Optimize and Quantize Min and Max values - const uint32_t uSteps = ((0.0f == fMinAlpha) || (1.0f == fMaxAlpha)) ? 6u : 8u; - - float fAlphaA, fAlphaB; - OptimizeAlpha(&fAlphaA, &fAlphaB, fAlpha, uSteps); - - auto const bAlphaA = static_cast(static_cast(fAlphaA * 255.0f + 0.5f)); - auto const bAlphaB = static_cast(static_cast(fAlphaB * 255.0f + 0.5f)); - - fAlphaA = static_cast(bAlphaA) * (1.0f / 255.0f); - fAlphaB = static_cast(bAlphaB) * (1.0f / 255.0f); - - // Setup block - if ((8 == uSteps) && (bAlphaA == bAlphaB)) - { - pBC3->alpha[0] = bAlphaA; - pBC3->alpha[1] = bAlphaB; - memset(pBC3->bitmap, 0x00, 6); - return; - } - - static const size_t pSteps6[] = { 0, 2, 3, 4, 5, 1 }; - static const size_t pSteps8[] = { 0, 2, 3, 4, 5, 6, 7, 1 }; - - const size_t *pSteps; - float fStep[8] = {}; - - if (6 == uSteps) - { - pBC3->alpha[0] = bAlphaA; - pBC3->alpha[1] = bAlphaB; - - fStep[0] = fAlphaA; - fStep[1] = fAlphaB; - - for (size_t i = 1; i < 5; ++i) - fStep[i + 1] = (fStep[0] * float(5u - i) + fStep[1] * float(i)) * (1.0f / 5.0f); - - fStep[6] = 0.0f; - fStep[7] = 1.0f; - - pSteps = pSteps6; - } - else - { - pBC3->alpha[0] = bAlphaB; - pBC3->alpha[1] = bAlphaA; - - fStep[0] = fAlphaB; - fStep[1] = fAlphaA; - - for (size_t i = 1; i < 7; ++i) - fStep[i + 1] = (fStep[0] * float(7u - i) + fStep[1] * float(i)) * (1.0f / 7.0f); - - pSteps = pSteps8; - } - - // Encode alpha bitmap - auto const fSteps = static_cast(uSteps - 1); - const float fScale = (fStep[0] != fStep[1]) ? (fSteps / (fStep[1] - fStep[0])) : 0.0f; - - if (flags & BC_FLAGS_DITHER_A) - memset(fError, 0x00, NUM_PIXELS_PER_BLOCK * sizeof(float)); - - for (size_t iSet = 0; iSet < 2; iSet++) - { - uint32_t dw = 0; - - const size_t iMin = iSet * 8; - const size_t iLim = iMin + 8; - - for (size_t i = iMin; i < iLim; ++i) - { - float fAlph = Color[i].a; - if (flags & BC_FLAGS_DITHER_A) - fAlph += fError[i]; - const float fDot = (fAlph - fStep[0]) * fScale; - - uint32_t iStep; - if (fDot <= 0.0f) - iStep = ((6 == uSteps) && (fAlph <= fStep[0] * 0.5f)) ? 6u : 0u; - else if (fDot >= fSteps) - iStep = ((6 == uSteps) && (fAlph >= (fStep[1] + 1.0f) * 0.5f)) ? 7u : 1u; - else - iStep = uint32_t(pSteps[uint32_t(fDot + 0.5f)]); - - dw = (iStep << 21) | (dw >> 3); - - if (flags & BC_FLAGS_DITHER_A) - { - const float fDiff = (fAlph - fStep[iStep]); - - if (3 != (i & 3)) - fError[i + 1] += fDiff * (7.0f / 16.0f); - - if (i < 12) - { - if (i & 3) - fError[i + 3] += fDiff * (3.0f / 16.0f); - - fError[i + 4] += fDiff * (5.0f / 16.0f); - - if (3 != (i & 3)) - fError[i + 5] += fDiff * (1.0f / 16.0f); - } - } - } - - pBC3->bitmap[0 + iSet * 3] = reinterpret_cast(&dw)[0]; - pBC3->bitmap[1 + iSet * 3] = reinterpret_cast(&dw)[1]; - pBC3->bitmap[2 + iSet * 3] = reinterpret_cast(&dw)[2]; - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/BC.h b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/BC.h deleted file mode 100644 index 44482b4..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/BC.h +++ /dev/null @@ -1,340 +0,0 @@ -//------------------------------------------------------------------------------------- -// BC.h -// -// Block-compression (BC) functionality -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//------------------------------------------------------------------------------------- - -#pragma once - -#include -#include - -namespace DirectX -{ -//------------------------------------------------------------------------------------- -// Macros -//------------------------------------------------------------------------------------- - -// Because these are used in SAL annotations, they need to remain macros rather than const values -#define NUM_PIXELS_PER_BLOCK 16 - -//------------------------------------------------------------------------------------- -// Constants -//------------------------------------------------------------------------------------- - - enum BC_FLAGS : uint32_t - { - BC_FLAGS_NONE = 0x0, - - BC_FLAGS_DITHER_RGB = 0x10000, - // Enables dithering for RGB colors for BC1-3 - - BC_FLAGS_DITHER_A = 0x20000, - // Enables dithering for Alpha channel for BC1-3 - - BC_FLAGS_UNIFORM = 0x40000, - // By default, uses perceptual weighting for BC1-3; this flag makes it a uniform weighting - - BC_FLAGS_USE_3SUBSETS = 0x80000, - // By default, BC7 skips mode 0 & 2; this flag adds those modes back - - BC_FLAGS_FORCE_BC7_MODE6 = 0x100000, - // BC7 should only use mode 6; skip other modes - }; - - //------------------------------------------------------------------------------------- - // Structures - //------------------------------------------------------------------------------------- - class LDRColorA; - - class HDRColorA - { - public: - float r, g, b, a; - - public: - HDRColorA() = default; - HDRColorA(float _r, float _g, float _b, float _a) noexcept : r(_r), g(_g), b(_b), a(_a) {} - HDRColorA(const HDRColorA& c) noexcept : r(c.r), g(c.g), b(c.b), a(c.a) {} - - // binary operators - HDRColorA operator + (const HDRColorA& c) const noexcept - { - return HDRColorA(r + c.r, g + c.g, b + c.b, a + c.a); - } - - HDRColorA operator - (const HDRColorA& c) const noexcept - { - return HDRColorA(r - c.r, g - c.g, b - c.b, a - c.a); - } - - HDRColorA operator * (float f) const noexcept - { - return HDRColorA(r * f, g * f, b * f, a * f); - } - - HDRColorA operator / (float f) const noexcept - { - const float fInv = 1.0f / f; - return HDRColorA(r * fInv, g * fInv, b * fInv, a * fInv); - } - - float operator * (const HDRColorA& c) const noexcept - { - return r * c.r + g * c.g + b * c.b + a * c.a; - } - - // assignment operators - HDRColorA& operator += (const HDRColorA& c) noexcept - { - r += c.r; - g += c.g; - b += c.b; - a += c.a; - return *this; - } - - HDRColorA& operator -= (const HDRColorA& c) noexcept - { - r -= c.r; - g -= c.g; - b -= c.b; - a -= c.a; - return *this; - } - - HDRColorA& operator *= (float f) noexcept - { - r *= f; - g *= f; - b *= f; - a *= f; - return *this; - } - - HDRColorA& operator /= (float f) noexcept - { - const float fInv = 1.0f / f; - r *= fInv; - g *= fInv; - b *= fInv; - a *= fInv; - return *this; - } - - HDRColorA& Clamp(_In_ float fMin, _In_ float fMax) noexcept - { - r = std::min(fMax, std::max(fMin, r)); - g = std::min(fMax, std::max(fMin, g)); - b = std::min(fMax, std::max(fMin, b)); - a = std::min(fMax, std::max(fMin, a)); - return *this; - } - - HDRColorA(const LDRColorA& c) noexcept; - HDRColorA& operator = (const LDRColorA& c) noexcept; - LDRColorA ToLDRColorA() const noexcept; - }; - - inline HDRColorA* HDRColorALerp(_Out_ HDRColorA *pOut, _In_ const HDRColorA *pC1, _In_ const HDRColorA *pC2, _In_ float s) noexcept - { - pOut->r = pC1->r + s * (pC2->r - pC1->r); - pOut->g = pC1->g + s * (pC2->g - pC1->g); - pOut->b = pC1->b + s * (pC2->b - pC1->b); - pOut->a = pC1->a + s * (pC2->a - pC1->a); - return pOut; - } - -#pragma pack(push,1) -// BC1/DXT1 compression (4 bits per texel) - struct D3DX_BC1 - { - uint16_t rgb[2]; // 565 colors - uint32_t bitmap; // 2bpp rgb bitmap - }; - - // BC2/DXT2/3 compression (8 bits per texel) - struct D3DX_BC2 - { - uint32_t bitmap[2]; // 4bpp alpha bitmap - D3DX_BC1 bc1; // BC1 rgb data - }; - - // BC3/DXT4/5 compression (8 bits per texel) - struct D3DX_BC3 - { - uint8_t alpha[2]; // alpha values - uint8_t bitmap[6]; // 3bpp alpha bitmap - D3DX_BC1 bc1; // BC1 rgb data - }; -#pragma pack(pop) - -//------------------------------------------------------------------------------------- -// Templates -//------------------------------------------------------------------------------------- -#pragma warning(push) -#pragma warning(disable : 4127) - template void OptimizeAlpha(float *pX, float *pY, const float *pPoints, uint32_t cSteps) noexcept - { - static const float pC6[] = { 5.0f / 5.0f, 4.0f / 5.0f, 3.0f / 5.0f, 2.0f / 5.0f, 1.0f / 5.0f, 0.0f / 5.0f }; - static const float pD6[] = { 0.0f / 5.0f, 1.0f / 5.0f, 2.0f / 5.0f, 3.0f / 5.0f, 4.0f / 5.0f, 5.0f / 5.0f }; - static const float pC8[] = { 7.0f / 7.0f, 6.0f / 7.0f, 5.0f / 7.0f, 4.0f / 7.0f, 3.0f / 7.0f, 2.0f / 7.0f, 1.0f / 7.0f, 0.0f / 7.0f }; - static const float pD8[] = { 0.0f / 7.0f, 1.0f / 7.0f, 2.0f / 7.0f, 3.0f / 7.0f, 4.0f / 7.0f, 5.0f / 7.0f, 6.0f / 7.0f, 7.0f / 7.0f }; - - const float *pC = (6 == cSteps) ? pC6 : pC8; - const float *pD = (6 == cSteps) ? pD6 : pD8; - - constexpr float MAX_VALUE = 1.0f; - constexpr float MIN_VALUE = (bRange) ? -1.0f : 0.0f; - - // Find Min and Max points, as starting point - float fX = MAX_VALUE; - float fY = MIN_VALUE; - - if (8 == cSteps) - { - for (size_t iPoint = 0; iPoint < NUM_PIXELS_PER_BLOCK; iPoint++) - { - if (pPoints[iPoint] < fX) - fX = pPoints[iPoint]; - - if (pPoints[iPoint] > fY) - fY = pPoints[iPoint]; - } - } - else - { - for (size_t iPoint = 0; iPoint < NUM_PIXELS_PER_BLOCK; iPoint++) - { - if (pPoints[iPoint] < fX && pPoints[iPoint] > MIN_VALUE) - fX = pPoints[iPoint]; - - if (pPoints[iPoint] > fY && pPoints[iPoint] < MAX_VALUE) - fY = pPoints[iPoint]; - } - - if (fX == fY) - { - fY = MAX_VALUE; - } - } - - // Use Newton's Method to find local minima of sum-of-squares error. - auto const fSteps = static_cast(cSteps - 1); - - for (size_t iIteration = 0; iIteration < 8; iIteration++) - { - if ((fY - fX) < (1.0f / 256.0f)) - break; - - float const fScale = fSteps / (fY - fX); - - // Calculate new steps - float pSteps[8]; - - for (size_t iStep = 0; iStep < cSteps; iStep++) - pSteps[iStep] = pC[iStep] * fX + pD[iStep] * fY; - - if (6 == cSteps) - { - pSteps[6] = MIN_VALUE; - pSteps[7] = MAX_VALUE; - } - - // Evaluate function, and derivatives - float dX = 0.0f; - float dY = 0.0f; - float d2X = 0.0f; - float d2Y = 0.0f; - - for (size_t iPoint = 0; iPoint < NUM_PIXELS_PER_BLOCK; iPoint++) - { - const float fDot = (pPoints[iPoint] - fX) * fScale; - - uint32_t iStep; - if (fDot <= 0.0f) - { - // D3DX10 / D3DX11 didn't take into account the proper minimum value for the bRange (BC4S/BC5S) case - iStep = ((6 == cSteps) && (pPoints[iPoint] <= (fX + MIN_VALUE) * 0.5f)) ? 6u : 0u; - } - else if (fDot >= fSteps) - { - iStep = ((6 == cSteps) && (pPoints[iPoint] >= (fY + MAX_VALUE) * 0.5f)) ? 7u : (cSteps - 1); - } - else - { - iStep = uint32_t(fDot + 0.5f); - } - - if (iStep < cSteps) - { - // D3DX had this computation backwards (pPoints[iPoint] - pSteps[iStep]) - // this fix improves RMS of the alpha component - const float fDiff = pSteps[iStep] - pPoints[iPoint]; - - dX += pC[iStep] * fDiff; - d2X += pC[iStep] * pC[iStep]; - - dY += pD[iStep] * fDiff; - d2Y += pD[iStep] * pD[iStep]; - } - } - - // Move endpoints - if (d2X > 0.0f) - fX -= dX / d2X; - - if (d2Y > 0.0f) - fY -= dY / d2Y; - - if (fX > fY) - { - const float f = fX; fX = fY; fY = f; - } - - if ((dX * dX < (1.0f / 64.0f)) && (dY * dY < (1.0f / 64.0f))) - break; - } - - *pX = (fX < MIN_VALUE) ? MIN_VALUE : (fX > MAX_VALUE) ? MAX_VALUE : fX; - *pY = (fY < MIN_VALUE) ? MIN_VALUE : (fY > MAX_VALUE) ? MAX_VALUE : fY; - } -#pragma warning(pop) - -//------------------------------------------------------------------------------------- -// Functions -//------------------------------------------------------------------------------------- - - typedef void (*BC_DECODE)(XMVECTOR *pColor, const uint8_t *pBC); - typedef void (*BC_ENCODE)(uint8_t *pDXT, const XMVECTOR *pColor, uint32_t flags); - - void D3DXDecodeBC1(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(8) const uint8_t *pBC) noexcept; - void D3DXDecodeBC2(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept; - void D3DXDecodeBC3(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept; - void D3DXDecodeBC4U(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(8) const uint8_t *pBC) noexcept; - void D3DXDecodeBC4S(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(8) const uint8_t *pBC) noexcept; - void D3DXDecodeBC5U(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept; - void D3DXDecodeBC5S(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept; - void D3DXDecodeBC6HU(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept; - void D3DXDecodeBC6HS(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept; - void D3DXDecodeBC7(_Out_writes_(NUM_PIXELS_PER_BLOCK) XMVECTOR *pColor, _In_reads_(16) const uint8_t *pBC) noexcept; - - void D3DXEncodeBC1(_Out_writes_(8) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ float threshold, _In_ uint32_t flags) noexcept; - // BC1 requires one additional parameter, so it doesn't match signature of BC_ENCODE above - - void D3DXEncodeBC2(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept; - void D3DXEncodeBC3(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept; - void D3DXEncodeBC4U(_Out_writes_(8) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept; - void D3DXEncodeBC4S(_Out_writes_(8) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept; - void D3DXEncodeBC5U(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept; - void D3DXEncodeBC5S(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept; - void D3DXEncodeBC6HU(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept; - void D3DXEncodeBC6HS(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept; - void D3DXEncodeBC7(_Out_writes_(16) uint8_t *pBC, _In_reads_(NUM_PIXELS_PER_BLOCK) const XMVECTOR *pColor, _In_ uint32_t flags) noexcept; - -} // namespace diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/BC4BC5.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/BC4BC5.cpp deleted file mode 100644 index 263db98..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/BC4BC5.cpp +++ /dev/null @@ -1,562 +0,0 @@ -//------------------------------------------------------------------------------------- -// BC4BC5.cpp -// -// Block-compression (BC) functionality for BC4 and BC5 (DirectX 10 texture compression) -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//------------------------------------------------------------------------------------- - -#include "DirectXTexP.h" - -#include "BC.h" - -using namespace DirectX; - -//------------------------------------------------------------------------------------ -// Constants -//------------------------------------------------------------------------------------ - -// Because these are used in SAL annotations, they need to remain macros rather than const values -#define BLOCK_LEN 4 -// length of each block in texel - -#define BLOCK_SIZE (BLOCK_LEN * BLOCK_LEN) -// total texels in a 4x4 block. - -namespace -{ - //------------------------------------------------------------------------------------ - // Structures - //------------------------------------------------------------------------------------- - -#pragma warning(push) -#pragma warning(disable : 4201) - - // BC4U/BC5U - struct BC4_UNORM - { - float R(size_t uOffset) const noexcept - { - const size_t uIndex = GetIndex(uOffset); - return DecodeFromIndex(uIndex); - } - - float DecodeFromIndex(size_t uIndex) const noexcept - { - if (uIndex == 0) - return float(red_0) / 255.0f; - if (uIndex == 1) - return float(red_1) / 255.0f; - const float fred_0 = float(red_0) / 255.0f; - const float fred_1 = float(red_1) / 255.0f; - if (red_0 > red_1) - { - uIndex -= 1; - return (fred_0 * float(7u - uIndex) + fred_1 * float(uIndex)) / 7.0f; - } - else - { - if (uIndex == 6) - return 0.0f; - if (uIndex == 7) - return 1.0f; - uIndex -= 1; - return (fred_0 * float(5u - uIndex) + fred_1 * float(uIndex)) / 5.0f; - } - } - - size_t GetIndex(size_t uOffset) const noexcept - { - return static_cast((data >> (3 * uOffset + 16)) & 0x07); - } - - void SetIndex(size_t uOffset, size_t uIndex) noexcept - { - data &= ~(uint64_t(0x07) << (3 * uOffset + 16)); - data |= (uint64_t(uIndex) << (3 * uOffset + 16)); - } - - union - { - struct - { - uint8_t red_0; - uint8_t red_1; - uint8_t indices[6]; - }; - uint64_t data; - }; - }; - - // BC4S/BC5S - struct BC4_SNORM - { - float R(size_t uOffset) const noexcept - { - const size_t uIndex = GetIndex(uOffset); - return DecodeFromIndex(uIndex); - } - - float DecodeFromIndex(size_t uIndex) const noexcept - { - const int8_t sred_0 = (red_0 == -128) ? -127 : red_0; - const int8_t sred_1 = (red_1 == -128) ? -127 : red_1; - - if (uIndex == 0) - return float(sred_0) / 127.0f; - if (uIndex == 1) - return float(sred_1) / 127.0f; - const float fred_0 = float(sred_0) / 127.0f; - const float fred_1 = float(sred_1) / 127.0f; - if (red_0 > red_1) - { - uIndex -= 1; - return (fred_0 * float(7u - uIndex) + fred_1 * float(uIndex)) / 7.0f; - } - else - { - if (uIndex == 6) - return -1.0f; - if (uIndex == 7) - return 1.0f; - uIndex -= 1; - return (fred_0 * float(5u - uIndex) + fred_1 * float(uIndex)) / 5.0f; - } - } - - size_t GetIndex(size_t uOffset) const noexcept - { - return static_cast((data >> (3 * uOffset + 16)) & 0x07); - } - - void SetIndex(size_t uOffset, size_t uIndex) noexcept - { - data &= ~(uint64_t(0x07) << (3 * uOffset + 16)); - data |= (uint64_t(uIndex) << (3 * uOffset + 16)); - } - - union - { - struct - { - int8_t red_0; - int8_t red_1; - uint8_t indices[6]; - }; - uint64_t data; - }; - }; - -#pragma warning(pop) - - //------------------------------------------------------------------------------------- - // Convert a floating point value to an 8-bit SNORM - //------------------------------------------------------------------------------------- - void inline FloatToSNorm(_In_ float fVal, _Out_ int8_t *piSNorm) noexcept - { - constexpr uint32_t dwMostNeg = (1 << (8 * sizeof(int8_t) - 1)); - - if (isnan(fVal)) - fVal = 0; - else - if (fVal > 1) - fVal = 1; // Clamp to 1 - else - if (fVal < -1) - fVal = -1; // Clamp to -1 - - fVal = fVal * static_cast(dwMostNeg - 1); - - if (fVal >= 0) - fVal += .5f; - else - fVal -= .5f; - - *piSNorm = static_cast(fVal); - } - - - //------------------------------------------------------------------------------ - void FindEndPointsBC4U( - _In_reads_(BLOCK_SIZE) const float theTexelsU[], - _Out_ uint8_t &endpointU_0, - _Out_ uint8_t &endpointU_1) noexcept - { - // The boundary of codec for signed/unsigned format - constexpr float MIN_NORM = 0.f; - constexpr float MAX_NORM = 1.f; - - // Find max/min of input texels - float fBlockMax = theTexelsU[0]; - float fBlockMin = theTexelsU[0]; - for (size_t i = 0; i < BLOCK_SIZE; ++i) - { - if (theTexelsU[i] < fBlockMin) - { - fBlockMin = theTexelsU[i]; - } - else if (theTexelsU[i] > fBlockMax) - { - fBlockMax = theTexelsU[i]; - } - } - - // If there are boundary values in input texels, should use 4 interpolated color values to guarantee - // the exact code of the boundary values. - const bool bUsing4BlockCodec = (MIN_NORM == fBlockMin || MAX_NORM == fBlockMax); - - // Using Optimize - float fStart, fEnd; - - if (!bUsing4BlockCodec) - { - // 6 interpolated color values - OptimizeAlpha(&fStart, &fEnd, theTexelsU, 8); - - auto iStart = static_cast(fStart * 255.0f); - auto iEnd = static_cast(fEnd * 255.0f); - - endpointU_0 = iEnd; - endpointU_1 = iStart; - } - else - { - // 4 interpolated color values - OptimizeAlpha(&fStart, &fEnd, theTexelsU, 6); - - auto iStart = static_cast(fStart * 255.0f); - auto iEnd = static_cast(fEnd * 255.0f); - - endpointU_1 = iEnd; - endpointU_0 = iStart; - } - } - - void FindEndPointsBC4S( - _In_reads_(BLOCK_SIZE) const float theTexelsU[], - _Out_ int8_t &endpointU_0, - _Out_ int8_t &endpointU_1) noexcept - { - // The boundary of codec for signed/unsigned format - constexpr float MIN_NORM = -1.f; - constexpr float MAX_NORM = 1.f; - - // Find max/min of input texels - float fBlockMax = theTexelsU[0]; - float fBlockMin = theTexelsU[0]; - for (size_t i = 0; i < BLOCK_SIZE; ++i) - { - if (theTexelsU[i] < fBlockMin) - { - fBlockMin = theTexelsU[i]; - } - else if (theTexelsU[i] > fBlockMax) - { - fBlockMax = theTexelsU[i]; - } - } - - // If there are boundary values in input texels, should use 4 interpolated color values to guarantee - // the exact code of the boundary values. - const bool bUsing4BlockCodec = (MIN_NORM == fBlockMin || MAX_NORM == fBlockMax); - - // Using Optimize - float fStart, fEnd; - - if (!bUsing4BlockCodec) - { - // 6 interpolated color values - OptimizeAlpha(&fStart, &fEnd, theTexelsU, 8); - - int8_t iStart, iEnd; - FloatToSNorm(fStart, &iStart); - FloatToSNorm(fEnd, &iEnd); - - endpointU_0 = iEnd; - endpointU_1 = iStart; - } - else - { - // 4 interpolated color values - OptimizeAlpha(&fStart, &fEnd, theTexelsU, 6); - - int8_t iStart, iEnd; - FloatToSNorm(fStart, &iStart); - FloatToSNorm(fEnd, &iEnd); - - endpointU_1 = iEnd; - endpointU_0 = iStart; - } - } - - - //------------------------------------------------------------------------------ - inline void FindEndPointsBC5U( - _In_reads_(BLOCK_SIZE) const float theTexelsU[], - _In_reads_(BLOCK_SIZE) const float theTexelsV[], - _Out_ uint8_t &endpointU_0, - _Out_ uint8_t &endpointU_1, - _Out_ uint8_t &endpointV_0, - _Out_ uint8_t &endpointV_1) noexcept - { - //Encoding the U and V channel by BC4 codec separately. - FindEndPointsBC4U(theTexelsU, endpointU_0, endpointU_1); - FindEndPointsBC4U(theTexelsV, endpointV_0, endpointV_1); - } - - inline void FindEndPointsBC5S( - _In_reads_(BLOCK_SIZE) const float theTexelsU[], - _In_reads_(BLOCK_SIZE) const float theTexelsV[], - _Out_ int8_t &endpointU_0, - _Out_ int8_t &endpointU_1, - _Out_ int8_t &endpointV_0, - _Out_ int8_t &endpointV_1) noexcept - { - //Encoding the U and V channel by BC4 codec separately. - FindEndPointsBC4S(theTexelsU, endpointU_0, endpointU_1); - FindEndPointsBC4S(theTexelsV, endpointV_0, endpointV_1); - } - - - //------------------------------------------------------------------------------ - void FindClosestUNORM( - _Inout_ BC4_UNORM* pBC, - _In_reads_(NUM_PIXELS_PER_BLOCK) const float theTexelsU[]) noexcept - { - float rGradient[8]; - for (size_t i = 0; i < 8; ++i) - { - rGradient[i] = pBC->DecodeFromIndex(i); - } - - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - { - size_t uBestIndex = 0; - float fBestDelta = 100000; - for (size_t uIndex = 0; uIndex < 8; uIndex++) - { - const float fCurrentDelta = fabsf(rGradient[uIndex] - theTexelsU[i]); - if (fCurrentDelta < fBestDelta) - { - uBestIndex = uIndex; - fBestDelta = fCurrentDelta; - } - } - pBC->SetIndex(i, uBestIndex); - } - } - - void FindClosestSNORM( - _Inout_ BC4_SNORM* pBC, - _In_reads_(NUM_PIXELS_PER_BLOCK) const float theTexelsU[]) noexcept - { - float rGradient[8]; - for (size_t i = 0; i < 8; ++i) - { - rGradient[i] = pBC->DecodeFromIndex(i); - } - - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - { - size_t uBestIndex = 0; - float fBestDelta = 100000; - for (size_t uIndex = 0; uIndex < 8; uIndex++) - { - const float fCurrentDelta = fabsf(rGradient[uIndex] - theTexelsU[i]); - if (fCurrentDelta < fBestDelta) - { - uBestIndex = uIndex; - fBestDelta = fCurrentDelta; - } - } - pBC->SetIndex(i, uBestIndex); - } - } -} - - -//===================================================================================== -// Entry points -//===================================================================================== - -//------------------------------------------------------------------------------------- -// BC4 Compression -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -void DirectX::D3DXDecodeBC4U(XMVECTOR *pColor, const uint8_t *pBC) noexcept -{ - assert(pColor && pBC); - static_assert(sizeof(BC4_UNORM) == 8, "BC4_UNORM should be 8 bytes"); - - auto pBC4 = reinterpret_cast(pBC); - - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - { - #pragma prefast(suppress:22103, "writing blocks in two halves confuses tool") - pColor[i] = XMVectorSet(pBC4->R(i), 0, 0, 1.0f); - } -} - -_Use_decl_annotations_ -void DirectX::D3DXDecodeBC4S(XMVECTOR *pColor, const uint8_t *pBC) noexcept -{ - assert(pColor && pBC); - static_assert(sizeof(BC4_SNORM) == 8, "BC4_SNORM should be 8 bytes"); - - auto pBC4 = reinterpret_cast(pBC); - - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - { - #pragma prefast(suppress:22103, "writing blocks in two halves confuses tool") - pColor[i] = XMVectorSet(pBC4->R(i), 0, 0, 1.0f); - } -} - -_Use_decl_annotations_ -void DirectX::D3DXEncodeBC4U(uint8_t *pBC, const XMVECTOR *pColor, uint32_t flags) noexcept -{ - UNREFERENCED_PARAMETER(flags); - - assert(pBC && pColor); - static_assert(sizeof(BC4_UNORM) == 8, "BC4_UNORM should be 8 bytes"); - - memset(pBC, 0, sizeof(BC4_UNORM)); - auto pBC4 = reinterpret_cast(pBC); - float theTexelsU[NUM_PIXELS_PER_BLOCK]; - - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - { - theTexelsU[i] = XMVectorGetX(pColor[i]); - } - - FindEndPointsBC4U(theTexelsU, pBC4->red_0, pBC4->red_1); - FindClosestUNORM(pBC4, theTexelsU); -} - -_Use_decl_annotations_ -void DirectX::D3DXEncodeBC4S(uint8_t *pBC, const XMVECTOR *pColor, uint32_t flags) noexcept -{ - UNREFERENCED_PARAMETER(flags); - - assert(pBC && pColor); - static_assert(sizeof(BC4_SNORM) == 8, "BC4_SNORM should be 8 bytes"); - - memset(pBC, 0, sizeof(BC4_UNORM)); - auto pBC4 = reinterpret_cast(pBC); - float theTexelsU[NUM_PIXELS_PER_BLOCK]; - - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - { - theTexelsU[i] = XMVectorGetX(pColor[i]); - } - - FindEndPointsBC4S(theTexelsU, pBC4->red_0, pBC4->red_1); - FindClosestSNORM(pBC4, theTexelsU); -} - - -//------------------------------------------------------------------------------------- -// BC5 Compression -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -void DirectX::D3DXDecodeBC5U(XMVECTOR *pColor, const uint8_t *pBC) noexcept -{ - assert(pColor && pBC); - static_assert(sizeof(BC4_UNORM) == 8, "BC4_UNORM should be 8 bytes"); - - auto pBCR = reinterpret_cast(pBC); - auto pBCG = reinterpret_cast(pBC + sizeof(BC4_UNORM)); - - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - { - #pragma prefast(suppress:22103, "writing blocks in two halves confuses tool") - pColor[i] = XMVectorSet(pBCR->R(i), pBCG->R(i), 0, 1.0f); - } -} - -_Use_decl_annotations_ -void DirectX::D3DXDecodeBC5S(XMVECTOR *pColor, const uint8_t *pBC) noexcept -{ - assert(pColor && pBC); - static_assert(sizeof(BC4_SNORM) == 8, "BC4_SNORM should be 8 bytes"); - - auto pBCR = reinterpret_cast(pBC); - auto pBCG = reinterpret_cast(pBC + sizeof(BC4_SNORM)); - - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - { - #pragma prefast(suppress:22103, "writing blocks in two halves confuses tool") - pColor[i] = XMVectorSet(pBCR->R(i), pBCG->R(i), 0, 1.0f); - } -} - -_Use_decl_annotations_ -void DirectX::D3DXEncodeBC5U(uint8_t *pBC, const XMVECTOR *pColor, uint32_t flags) noexcept -{ - UNREFERENCED_PARAMETER(flags); - - assert(pBC && pColor); - static_assert(sizeof(BC4_UNORM) == 8, "BC4_UNORM should be 8 bytes"); - - memset(pBC, 0, sizeof(BC4_UNORM) * 2); - auto pBCR = reinterpret_cast(pBC); - auto pBCG = reinterpret_cast(pBC + sizeof(BC4_UNORM)); - float theTexelsU[NUM_PIXELS_PER_BLOCK]; - float theTexelsV[NUM_PIXELS_PER_BLOCK]; - - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - { - XMFLOAT4A clr; - XMStoreFloat4A(&clr, pColor[i]); - theTexelsU[i] = clr.x; - theTexelsV[i] = clr.y; - } - - FindEndPointsBC5U( - theTexelsU, - theTexelsV, - pBCR->red_0, - pBCR->red_1, - pBCG->red_0, - pBCG->red_1); - - FindClosestUNORM(pBCR, theTexelsU); - FindClosestUNORM(pBCG, theTexelsV); -} - -_Use_decl_annotations_ -void DirectX::D3DXEncodeBC5S(uint8_t *pBC, const XMVECTOR *pColor, uint32_t flags) noexcept -{ - UNREFERENCED_PARAMETER(flags); - - assert(pBC && pColor); - static_assert(sizeof(BC4_SNORM) == 8, "BC4_SNORM should be 8 bytes"); - - memset(pBC, 0, sizeof(BC4_UNORM) * 2); - auto pBCR = reinterpret_cast(pBC); - auto pBCG = reinterpret_cast(pBC + sizeof(BC4_SNORM)); - float theTexelsU[NUM_PIXELS_PER_BLOCK]; - float theTexelsV[NUM_PIXELS_PER_BLOCK]; - - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - { - XMFLOAT4A clr; - XMStoreFloat4A(&clr, pColor[i]); - theTexelsU[i] = clr.x; - theTexelsV[i] = clr.y; - } - - FindEndPointsBC5S( - theTexelsU, - theTexelsV, - pBCR->red_0, - pBCR->red_1, - pBCG->red_0, - pBCG->red_1); - - FindClosestSNORM(pBCR, theTexelsU); - FindClosestSNORM(pBCG, theTexelsV); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/BC6HBC7.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/BC6HBC7.cpp deleted file mode 100644 index 2a889d8..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/BC6HBC7.cpp +++ /dev/null @@ -1,3566 +0,0 @@ -//------------------------------------------------------------------------------------- -// BC6HBC7.cpp -// -// Block-compression (BC) functionality for BC6H and BC7 (DirectX 11 texture compression) -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//------------------------------------------------------------------------------------- - -#include "DirectXTexP.h" - -#include "BC.h" - -using namespace DirectX; -using namespace DirectX::PackedVector; - -//------------------------------------------------------------------------------------- -// Macros -//------------------------------------------------------------------------------------- - -#define SIGN_EXTEND(x,nb) ((((x)&(1<<((nb)-1)))?((~0)^((1<<(nb))-1)):0)|(x)) - -// Because these are used in SAL annotations, they need to remain macros rather than const values -#define BC6H_MAX_REGIONS 2 -#define BC6H_MAX_INDICES 16 -#define BC7_MAX_REGIONS 3 -#define BC7_MAX_INDICES 16 - -namespace -{ - //------------------------------------------------------------------------------------- - // Constants - //------------------------------------------------------------------------------------- - - constexpr uint16_t F16S_MASK = 0x8000; // f16 sign mask - constexpr uint16_t F16EM_MASK = 0x7fff; // f16 exp & mantissa mask - constexpr uint16_t F16MAX = 0x7bff; // MAXFLT bit pattern for XMHALF - - constexpr size_t BC6H_NUM_CHANNELS = 3; - constexpr size_t BC6H_MAX_SHAPES = 32; - - constexpr size_t BC7_NUM_CHANNELS = 4; - constexpr size_t BC7_MAX_SHAPES = 64; - - constexpr int32_t BC67_WEIGHT_MAX = 64; - constexpr uint32_t BC67_WEIGHT_SHIFT = 6; - constexpr int32_t BC67_WEIGHT_ROUND = 32; - - constexpr float fEpsilon = (0.25f / 64.0f) * (0.25f / 64.0f); - constexpr float pC3[] = { 2.0f / 2.0f, 1.0f / 2.0f, 0.0f / 2.0f }; - constexpr float pD3[] = { 0.0f / 2.0f, 1.0f / 2.0f, 2.0f / 2.0f }; - constexpr float pC4[] = { 3.0f / 3.0f, 2.0f / 3.0f, 1.0f / 3.0f, 0.0f / 3.0f }; - constexpr float pD4[] = { 0.0f / 3.0f, 1.0f / 3.0f, 2.0f / 3.0f, 3.0f / 3.0f }; - - // Partition, Shape, Pixel (index into 4x4 block) - const uint8_t g_aPartitionTable[3][64][16] = - { - { // 1 Region case has no subsets (all 0) - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } - }, - - { // BC6H/BC7 Partition Set for 2 Subsets - { 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1 }, // Shape 0 - { 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1 }, // Shape 1 - { 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1 }, // Shape 2 - { 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1 }, // Shape 3 - { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1 }, // Shape 4 - { 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1 }, // Shape 5 - { 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1 }, // Shape 6 - { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1 }, // Shape 7 - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1 }, // Shape 8 - { 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // Shape 9 - { 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1 }, // Shape 10 - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1 }, // Shape 11 - { 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // Shape 12 - { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1 }, // Shape 13 - { 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, // Shape 14 - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1 }, // Shape 15 - { 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1 }, // Shape 16 - { 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 }, // Shape 17 - { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0 }, // Shape 18 - { 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0 }, // Shape 19 - { 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 }, // Shape 20 - { 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0 }, // Shape 21 - { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0 }, // Shape 22 - { 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1 }, // Shape 23 - { 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0 }, // Shape 24 - { 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0 }, // Shape 25 - { 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0 }, // Shape 26 - { 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0 }, // Shape 27 - { 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0 }, // Shape 28 - { 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 }, // Shape 29 - { 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0 }, // Shape 30 - { 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0 }, // Shape 31 - - // BC7 Partition Set for 2 Subsets (second-half) - { 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 }, // Shape 32 - { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1 }, // Shape 33 - { 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0 }, // Shape 34 - { 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0 }, // Shape 35 - { 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0 }, // Shape 36 - { 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0 }, // Shape 37 - { 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1 }, // Shape 38 - { 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1 }, // Shape 39 - { 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0 }, // Shape 40 - { 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0 }, // Shape 41 - { 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0 }, // Shape 42 - { 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0 }, // Shape 43 - { 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0 }, // Shape 44 - { 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1 }, // Shape 45 - { 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1 }, // Shape 46 - { 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0 }, // Shape 47 - { 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0 }, // Shape 48 - { 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0 }, // Shape 49 - { 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0 }, // Shape 50 - { 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0 }, // Shape 51 - { 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1 }, // Shape 52 - { 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1 }, // Shape 53 - { 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0 }, // Shape 54 - { 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0 }, // Shape 55 - { 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1 }, // Shape 56 - { 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1 }, // Shape 57 - { 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1 }, // Shape 58 - { 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1 }, // Shape 59 - { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1 }, // Shape 60 - { 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 }, // Shape 61 - { 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0 }, // Shape 62 - { 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1 } // Shape 63 - }, - - { // BC7 Partition Set for 3 Subsets - { 0, 0, 1, 1, 0, 0, 1, 1, 0, 2, 2, 1, 2, 2, 2, 2 }, // Shape 0 - { 0, 0, 0, 1, 0, 0, 1, 1, 2, 2, 1, 1, 2, 2, 2, 1 }, // Shape 1 - { 0, 0, 0, 0, 2, 0, 0, 1, 2, 2, 1, 1, 2, 2, 1, 1 }, // Shape 2 - { 0, 2, 2, 2, 0, 0, 2, 2, 0, 0, 1, 1, 0, 1, 1, 1 }, // Shape 3 - { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 1, 1, 2, 2 }, // Shape 4 - { 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 2, 2, 0, 0, 2, 2 }, // Shape 5 - { 0, 0, 2, 2, 0, 0, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1 }, // Shape 6 - { 0, 0, 1, 1, 0, 0, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1 }, // Shape 7 - { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2 }, // Shape 8 - { 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2 }, // Shape 9 - { 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2 }, // Shape 10 - { 0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2 }, // Shape 11 - { 0, 1, 1, 2, 0, 1, 1, 2, 0, 1, 1, 2, 0, 1, 1, 2 }, // Shape 12 - { 0, 1, 2, 2, 0, 1, 2, 2, 0, 1, 2, 2, 0, 1, 2, 2 }, // Shape 13 - { 0, 0, 1, 1, 0, 1, 1, 2, 1, 1, 2, 2, 1, 2, 2, 2 }, // Shape 14 - { 0, 0, 1, 1, 2, 0, 0, 1, 2, 2, 0, 0, 2, 2, 2, 0 }, // Shape 15 - { 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 2, 1, 1, 2, 2 }, // Shape 16 - { 0, 1, 1, 1, 0, 0, 1, 1, 2, 0, 0, 1, 2, 2, 0, 0 }, // Shape 17 - { 0, 0, 0, 0, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2 }, // Shape 18 - { 0, 0, 2, 2, 0, 0, 2, 2, 0, 0, 2, 2, 1, 1, 1, 1 }, // Shape 19 - { 0, 1, 1, 1, 0, 1, 1, 1, 0, 2, 2, 2, 0, 2, 2, 2 }, // Shape 20 - { 0, 0, 0, 1, 0, 0, 0, 1, 2, 2, 2, 1, 2, 2, 2, 1 }, // Shape 21 - { 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 2, 2, 0, 1, 2, 2 }, // Shape 22 - { 0, 0, 0, 0, 1, 1, 0, 0, 2, 2, 1, 0, 2, 2, 1, 0 }, // Shape 23 - { 0, 1, 2, 2, 0, 1, 2, 2, 0, 0, 1, 1, 0, 0, 0, 0 }, // Shape 24 - { 0, 0, 1, 2, 0, 0, 1, 2, 1, 1, 2, 2, 2, 2, 2, 2 }, // Shape 25 - { 0, 1, 1, 0, 1, 2, 2, 1, 1, 2, 2, 1, 0, 1, 1, 0 }, // Shape 26 - { 0, 0, 0, 0, 0, 1, 1, 0, 1, 2, 2, 1, 1, 2, 2, 1 }, // Shape 27 - { 0, 0, 2, 2, 1, 1, 0, 2, 1, 1, 0, 2, 0, 0, 2, 2 }, // Shape 28 - { 0, 1, 1, 0, 0, 1, 1, 0, 2, 0, 0, 2, 2, 2, 2, 2 }, // Shape 29 - { 0, 0, 1, 1, 0, 1, 2, 2, 0, 1, 2, 2, 0, 0, 1, 1 }, // Shape 30 - { 0, 0, 0, 0, 2, 0, 0, 0, 2, 2, 1, 1, 2, 2, 2, 1 }, // Shape 31 - { 0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 2, 2, 1, 2, 2, 2 }, // Shape 32 - { 0, 2, 2, 2, 0, 0, 2, 2, 0, 0, 1, 2, 0, 0, 1, 1 }, // Shape 33 - { 0, 0, 1, 1, 0, 0, 1, 2, 0, 0, 2, 2, 0, 2, 2, 2 }, // Shape 34 - { 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 0, 0, 1, 2, 0 }, // Shape 35 - { 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 0, 0, 0, 0 }, // Shape 36 - { 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0 }, // Shape 37 - { 0, 1, 2, 0, 2, 0, 1, 2, 1, 2, 0, 1, 0, 1, 2, 0 }, // Shape 38 - { 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1 }, // Shape 39 - { 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 0, 0, 0, 0, 1, 1 }, // Shape 40 - { 0, 1, 0, 1, 0, 1, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2 }, // Shape 41 - { 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 2, 1, 2, 1, 2, 1 }, // Shape 42 - { 0, 0, 2, 2, 1, 1, 2, 2, 0, 0, 2, 2, 1, 1, 2, 2 }, // Shape 43 - { 0, 0, 2, 2, 0, 0, 1, 1, 0, 0, 2, 2, 0, 0, 1, 1 }, // Shape 44 - { 0, 2, 2, 0, 1, 2, 2, 1, 0, 2, 2, 0, 1, 2, 2, 1 }, // Shape 45 - { 0, 1, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 1 }, // Shape 46 - { 0, 0, 0, 0, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1 }, // Shape 47 - { 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 2, 2, 2 }, // Shape 48 - { 0, 2, 2, 2, 0, 1, 1, 1, 0, 2, 2, 2, 0, 1, 1, 1 }, // Shape 49 - { 0, 0, 0, 2, 1, 1, 1, 2, 0, 0, 0, 2, 1, 1, 1, 2 }, // Shape 50 - { 0, 0, 0, 0, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2 }, // Shape 51 - { 0, 2, 2, 2, 0, 1, 1, 1, 0, 1, 1, 1, 0, 2, 2, 2 }, // Shape 52 - { 0, 0, 0, 2, 1, 1, 1, 2, 1, 1, 1, 2, 0, 0, 0, 2 }, // Shape 53 - { 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 2, 2, 2, 2 }, // Shape 54 - { 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 2, 2, 1, 1, 2 }, // Shape 55 - { 0, 1, 1, 0, 0, 1, 1, 0, 2, 2, 2, 2, 2, 2, 2, 2 }, // Shape 56 - { 0, 0, 2, 2, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 2, 2 }, // Shape 57 - { 0, 0, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 0, 0, 2, 2 }, // Shape 58 - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 1, 2 }, // Shape 59 - { 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 1 }, // Shape 60 - { 0, 2, 2, 2, 1, 2, 2, 2, 0, 2, 2, 2, 1, 2, 2, 2 }, // Shape 61 - { 0, 1, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }, // Shape 62 - { 0, 1, 1, 1, 2, 0, 1, 1, 2, 2, 0, 1, 2, 2, 2, 0 } // Shape 63 - } - }; - - // Partition, Shape, Fixup - const uint8_t g_aFixUp[3][64][3] = - { - { // No fix-ups for 1st subset for BC6H or BC7 - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 }, - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 }, - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 }, - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 }, - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 }, - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 }, - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 }, - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 }, - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 }, - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 }, - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 }, - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 }, - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 }, - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 }, - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 }, - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 } - }, - - { // BC6H/BC7 Partition Set Fixups for 2 Subsets - { 0,15, 0 },{ 0,15, 0 },{ 0,15, 0 },{ 0,15, 0 }, - { 0,15, 0 },{ 0,15, 0 },{ 0,15, 0 },{ 0,15, 0 }, - { 0,15, 0 },{ 0,15, 0 },{ 0,15, 0 },{ 0,15, 0 }, - { 0,15, 0 },{ 0,15, 0 },{ 0,15, 0 },{ 0,15, 0 }, - { 0,15, 0 },{ 0, 2, 0 },{ 0, 8, 0 },{ 0, 2, 0 }, - { 0, 2, 0 },{ 0, 8, 0 },{ 0, 8, 0 },{ 0,15, 0 }, - { 0, 2, 0 },{ 0, 8, 0 },{ 0, 2, 0 },{ 0, 2, 0 }, - { 0, 8, 0 },{ 0, 8, 0 },{ 0, 2, 0 },{ 0, 2, 0 }, - - // BC7 Partition Set Fixups for 2 Subsets (second-half) - { 0,15, 0 },{ 0,15, 0 },{ 0, 6, 0 },{ 0, 8, 0 }, - { 0, 2, 0 },{ 0, 8, 0 },{ 0,15, 0 },{ 0,15, 0 }, - { 0, 2, 0 },{ 0, 8, 0 },{ 0, 2, 0 },{ 0, 2, 0 }, - { 0, 2, 0 },{ 0,15, 0 },{ 0,15, 0 },{ 0, 6, 0 }, - { 0, 6, 0 },{ 0, 2, 0 },{ 0, 6, 0 },{ 0, 8, 0 }, - { 0,15, 0 },{ 0,15, 0 },{ 0, 2, 0 },{ 0, 2, 0 }, - { 0,15, 0 },{ 0,15, 0 },{ 0,15, 0 },{ 0,15, 0 }, - { 0,15, 0 },{ 0, 2, 0 },{ 0, 2, 0 },{ 0,15, 0 } - }, - - { // BC7 Partition Set Fixups for 3 Subsets - { 0, 3,15 },{ 0, 3, 8 },{ 0,15, 8 },{ 0,15, 3 }, - { 0, 8,15 },{ 0, 3,15 },{ 0,15, 3 },{ 0,15, 8 }, - { 0, 8,15 },{ 0, 8,15 },{ 0, 6,15 },{ 0, 6,15 }, - { 0, 6,15 },{ 0, 5,15 },{ 0, 3,15 },{ 0, 3, 8 }, - { 0, 3,15 },{ 0, 3, 8 },{ 0, 8,15 },{ 0,15, 3 }, - { 0, 3,15 },{ 0, 3, 8 },{ 0, 6,15 },{ 0,10, 8 }, - { 0, 5, 3 },{ 0, 8,15 },{ 0, 8, 6 },{ 0, 6,10 }, - { 0, 8,15 },{ 0, 5,15 },{ 0,15,10 },{ 0,15, 8 }, - { 0, 8,15 },{ 0,15, 3 },{ 0, 3,15 },{ 0, 5,10 }, - { 0, 6,10 },{ 0,10, 8 },{ 0, 8, 9 },{ 0,15,10 }, - { 0,15, 6 },{ 0, 3,15 },{ 0,15, 8 },{ 0, 5,15 }, - { 0,15, 3 },{ 0,15, 6 },{ 0,15, 6 },{ 0,15, 8 }, - { 0, 3,15 },{ 0,15, 3 },{ 0, 5,15 },{ 0, 5,15 }, - { 0, 5,15 },{ 0, 8,15 },{ 0, 5,15 },{ 0,10,15 }, - { 0, 5,15 },{ 0,10,15 },{ 0, 8,15 },{ 0,13,15 }, - { 0,15, 3 },{ 0,12,15 },{ 0, 3,15 },{ 0, 3, 8 } - } - }; - - const int g_aWeights2[] = { 0, 21, 43, 64 }; - const int g_aWeights3[] = { 0, 9, 18, 27, 37, 46, 55, 64 }; - const int g_aWeights4[] = { 0, 4, 9, 13, 17, 21, 26, 30, 34, 38, 43, 47, 51, 55, 60, 64 }; -} - -namespace DirectX -{ - class LDRColorA - { - public: - uint8_t r, g, b, a; - - LDRColorA() = default; - LDRColorA(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a) noexcept : r(_r), g(_g), b(_b), a(_a) {} - - const uint8_t& operator [] (_In_range_(0, 3) size_t uElement) const noexcept - { - switch (uElement) - { - case 0: return r; - case 1: return g; - case 2: return b; - case 3: return a; - default: assert(false); return r; - } - } - - uint8_t& operator [] (_In_range_(0, 3) size_t uElement) noexcept - { - switch (uElement) - { - case 0: return r; - case 1: return g; - case 2: return b; - case 3: return a; - default: assert(false); return r; - } - } - - LDRColorA operator = (_In_ const HDRColorA& c) noexcept - { - LDRColorA ret; - HDRColorA tmp(c); - tmp = tmp.Clamp(0.0f, 1.0f) * 255.0f; - ret.r = uint8_t(tmp.r + 0.001f); - ret.g = uint8_t(tmp.g + 0.001f); - ret.b = uint8_t(tmp.b + 0.001f); - ret.a = uint8_t(tmp.a + 0.001f); - return ret; - } - - static void InterpolateRGB(_In_ const LDRColorA& c0, _In_ const LDRColorA& c1, _In_ size_t wc, _In_ _In_range_(2, 4) size_t wcprec, _Out_ LDRColorA& out) noexcept - { - const int* aWeights = nullptr; - switch (wcprec) - { - case 2: aWeights = g_aWeights2; assert(wc < 4); _Analysis_assume_(wc < 4); break; - case 3: aWeights = g_aWeights3; assert(wc < 8); _Analysis_assume_(wc < 8); break; - case 4: aWeights = g_aWeights4; assert(wc < 16); _Analysis_assume_(wc < 16); break; - default: assert(false); out.r = out.g = out.b = 0; return; - } - out.r = uint8_t((uint32_t(c0.r) * uint32_t(BC67_WEIGHT_MAX - aWeights[wc]) + uint32_t(c1.r) * uint32_t(aWeights[wc]) + BC67_WEIGHT_ROUND) >> BC67_WEIGHT_SHIFT); - out.g = uint8_t((uint32_t(c0.g) * uint32_t(BC67_WEIGHT_MAX - aWeights[wc]) + uint32_t(c1.g) * uint32_t(aWeights[wc]) + BC67_WEIGHT_ROUND) >> BC67_WEIGHT_SHIFT); - out.b = uint8_t((uint32_t(c0.b) * uint32_t(BC67_WEIGHT_MAX - aWeights[wc]) + uint32_t(c1.b) * uint32_t(aWeights[wc]) + BC67_WEIGHT_ROUND) >> BC67_WEIGHT_SHIFT); - } - - static void InterpolateA(_In_ const LDRColorA& c0, _In_ const LDRColorA& c1, _In_ size_t wa, _In_range_(2, 4) _In_ size_t waprec, _Out_ LDRColorA& out) noexcept - { - const int* aWeights = nullptr; - switch (waprec) - { - case 2: aWeights = g_aWeights2; assert(wa < 4); _Analysis_assume_(wa < 4); break; - case 3: aWeights = g_aWeights3; assert(wa < 8); _Analysis_assume_(wa < 8); break; - case 4: aWeights = g_aWeights4; assert(wa < 16); _Analysis_assume_(wa < 16); break; - default: assert(false); out.a = 0; return; - } - out.a = uint8_t((uint32_t(c0.a) * uint32_t(BC67_WEIGHT_MAX - aWeights[wa]) + uint32_t(c1.a) * uint32_t(aWeights[wa]) + BC67_WEIGHT_ROUND) >> BC67_WEIGHT_SHIFT); - } - - static void Interpolate(_In_ const LDRColorA& c0, _In_ const LDRColorA& c1, _In_ size_t wc, _In_ size_t wa, _In_ _In_range_(2, 4) size_t wcprec, _In_ _In_range_(2, 4) size_t waprec, _Out_ LDRColorA& out) noexcept - { - InterpolateRGB(c0, c1, wc, wcprec, out); - InterpolateA(c0, c1, wa, waprec, out); - } - }; - - static_assert(sizeof(LDRColorA) == 4, "Unexpected packing"); - - struct LDREndPntPair - { - LDRColorA A; - LDRColorA B; - }; - - inline HDRColorA::HDRColorA(const LDRColorA& c) noexcept - { - r = float(c.r) * (1.0f / 255.0f); - g = float(c.g) * (1.0f / 255.0f); - b = float(c.b) * (1.0f / 255.0f); - a = float(c.a) * (1.0f / 255.0f); - } - - inline HDRColorA& HDRColorA::operator = (const LDRColorA& c) noexcept - { - r = static_cast(c.r); - g = static_cast(c.g); - b = static_cast(c.b); - a = static_cast(c.a); - return *this; - } - - inline LDRColorA HDRColorA::ToLDRColorA() const noexcept - { - return LDRColorA(static_cast(r + 0.01f), static_cast(g + 0.01f), static_cast(b + 0.01f), static_cast(a + 0.01f)); - } -} - -namespace -{ - class INTColor - { - public: - int r, g, b; - int pad; - - public: - INTColor() = default; - INTColor(int nr, int ng, int nb) noexcept : r(nr), g(ng), b(nb), pad(0) {} - INTColor(const INTColor& c) noexcept : r(c.r), g(c.g), b(c.b), pad(0) {} - - INTColor& operator += (_In_ const INTColor& c) noexcept - { - r += c.r; - g += c.g; - b += c.b; - return *this; - } - - INTColor& operator -= (_In_ const INTColor& c) noexcept - { - r -= c.r; - g -= c.g; - b -= c.b; - return *this; - } - - INTColor& operator &= (_In_ const INTColor& c) noexcept - { - r &= c.r; - g &= c.g; - b &= c.b; - return *this; - } - - int& operator [] (_In_ uint8_t i) noexcept - { - assert(i < sizeof(INTColor) / sizeof(int)); - _Analysis_assume_(i < sizeof(INTColor) / sizeof(int)); - return reinterpret_cast(this)[i]; - } - - void Set(_In_ const HDRColorA& c, _In_ bool bSigned) noexcept - { - PackedVector::XMHALF4 aF16; - - const XMVECTOR v = XMLoadFloat4(reinterpret_cast(&c)); - XMStoreHalf4(&aF16, v); - - r = F16ToINT(aF16.x, bSigned); - g = F16ToINT(aF16.y, bSigned); - b = F16ToINT(aF16.z, bSigned); - } - - INTColor& Clamp(_In_ int iMin, _In_ int iMax) noexcept - { - r = std::min(iMax, std::max(iMin, r)); - g = std::min(iMax, std::max(iMin, g)); - b = std::min(iMax, std::max(iMin, b)); - return *this; - } - - INTColor& SignExtend(_In_ const LDRColorA& Prec) noexcept - { - r = SIGN_EXTEND(r, int(Prec.r)); - g = SIGN_EXTEND(g, int(Prec.g)); - b = SIGN_EXTEND(b, int(Prec.b)); - return *this; - } - - void ToF16(_Out_writes_(3) PackedVector::HALF aF16[3], _In_ bool bSigned) const noexcept - { - aF16[0] = INT2F16(r, bSigned); - aF16[1] = INT2F16(g, bSigned); - aF16[2] = INT2F16(b, bSigned); - } - - private: - static int F16ToINT(_In_ const PackedVector::HALF& f, _In_ bool bSigned) noexcept - { - uint16_t input = *reinterpret_cast(&f); - int out, s; - if (bSigned) - { - s = input & F16S_MASK; - input &= F16EM_MASK; - if (input > F16MAX) out = F16MAX; - else out = input; - out = s ? -out : out; - } - else - { - if (input & F16S_MASK) out = 0; - else out = input; - } - return out; - } - - static PackedVector::HALF INT2F16(_In_ int input, _In_ bool bSigned) noexcept - { - PackedVector::HALF h; - uint16_t out; - if (bSigned) - { - int s = 0; - if (input < 0) - { - s = F16S_MASK; - input = -input; - } - out = uint16_t(s | input); - } - else - { - assert(input >= 0 && input <= F16MAX); - out = static_cast(input); - } - - *reinterpret_cast(&h) = out; - return h; - } - }; - - static_assert(sizeof(INTColor) == 16, "Unexpected packing"); - - struct INTEndPntPair - { - INTColor A; - INTColor B; - }; - - template< size_t SizeInBytes > - class CBits - { - public: - uint8_t GetBit(_Inout_ size_t& uStartBit) const noexcept - { - assert(uStartBit < 128); - _Analysis_assume_(uStartBit < 128); - const size_t uIndex = uStartBit >> 3; - auto const ret = static_cast((m_uBits[uIndex] >> (uStartBit - (uIndex << 3))) & 0x01); - uStartBit++; - return ret; - } - - uint8_t GetBits(_Inout_ size_t& uStartBit, _In_ size_t uNumBits) const noexcept - { - if (uNumBits == 0) return 0; - assert(uStartBit + uNumBits <= 128 && uNumBits <= 8); - _Analysis_assume_(uStartBit + uNumBits <= 128 && uNumBits <= 8); - uint8_t ret; - const size_t uIndex = uStartBit >> 3; - const size_t uBase = uStartBit - (uIndex << 3); - if (uBase + uNumBits > 8) - { - const size_t uFirstIndexBits = 8 - uBase; - const size_t uNextIndexBits = uNumBits - uFirstIndexBits; - ret = static_cast((unsigned(m_uBits[uIndex]) >> uBase) | ((unsigned(m_uBits[uIndex + 1]) & ((1u << uNextIndexBits) - 1)) << uFirstIndexBits)); - } - else - { - ret = static_cast((m_uBits[uIndex] >> uBase) & ((1 << uNumBits) - 1)); - } - assert(ret < (1 << uNumBits)); - uStartBit += uNumBits; - return ret; - } - - void SetBit(_Inout_ size_t& uStartBit, _In_ uint8_t uValue) noexcept - { - assert(uStartBit < 128 && uValue < 2); - _Analysis_assume_(uStartBit < 128 && uValue < 2); - size_t uIndex = uStartBit >> 3; - const size_t uBase = uStartBit - (uIndex << 3); - m_uBits[uIndex] &= ~(1 << uBase); - m_uBits[uIndex] |= uValue << uBase; - uStartBit++; - } - - void SetBits(_Inout_ size_t& uStartBit, _In_ size_t uNumBits, _In_ uint8_t uValue) noexcept - { - if (uNumBits == 0) - return; - assert(uStartBit + uNumBits <= 128 && uNumBits <= 8); - _Analysis_assume_(uStartBit + uNumBits <= 128 && uNumBits <= 8); - assert(uValue < (1 << uNumBits)); - size_t uIndex = uStartBit >> 3; - const size_t uBase = uStartBit - (uIndex << 3); - if (uBase + uNumBits > 8) - { - const size_t uFirstIndexBits = 8 - uBase; - const size_t uNextIndexBits = uNumBits - uFirstIndexBits; - m_uBits[uIndex] &= ~(((1 << uFirstIndexBits) - 1) << uBase); - m_uBits[uIndex] |= uValue << uBase; - m_uBits[uIndex + 1] &= ~((1 << uNextIndexBits) - 1); - m_uBits[uIndex + 1] |= uValue >> uFirstIndexBits; - } - else - { - m_uBits[uIndex] &= ~(((1 << uNumBits) - 1) << uBase); - m_uBits[uIndex] |= uValue << uBase; - } - uStartBit += uNumBits; - } - - private: - uint8_t m_uBits[SizeInBytes]; - }; - - // BC6H compression (16 bits per texel) - class D3DX_BC6H : private CBits< 16 > - { - public: - void Decode(_In_ bool bSigned, _Out_writes_(NUM_PIXELS_PER_BLOCK) HDRColorA* pOut) const noexcept; - void Encode(_In_ bool bSigned, _In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA* const pIn) noexcept; - - private: - #pragma warning(push) - #pragma warning(disable : 4480) - enum EField : uint8_t - { - NA, // N/A - M, // Mode - D, // Shape - RW, - RX, - RY, - RZ, - GW, - GX, - GY, - GZ, - BW, - BX, - BY, - BZ, - }; - #pragma warning(pop) - - struct ModeDescriptor - { - EField m_eField; - uint8_t m_uBit; - }; - - struct ModeInfo - { - uint8_t uMode; - uint8_t uPartitions; - bool bTransformed; - uint8_t uIndexPrec; - LDRColorA RGBAPrec[BC6H_MAX_REGIONS][2]; - }; - - #pragma warning(push) - #pragma warning(disable : 4512) - struct EncodeParams - { - float fBestErr; - const bool bSigned; - uint8_t uMode; - uint8_t uShape; - const HDRColorA* const aHDRPixels; - INTEndPntPair aUnqEndPts[BC6H_MAX_SHAPES][BC6H_MAX_REGIONS]; - INTColor aIPixels[NUM_PIXELS_PER_BLOCK]; - - EncodeParams(const HDRColorA* const aOriginal, bool bSignedFormat) noexcept : - fBestErr(FLT_MAX), bSigned(bSignedFormat), uMode(0), uShape(0), aHDRPixels(aOriginal), aUnqEndPts{}, aIPixels{} - { - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - { - aIPixels[i].Set(aOriginal[i], bSigned); - } - } - }; - #pragma warning(pop) - - static int Quantize(_In_ int iValue, _In_ int prec, _In_ bool bSigned) noexcept; - static int Unquantize(_In_ int comp, _In_ uint8_t uBitsPerComp, _In_ bool bSigned) noexcept; - static int FinishUnquantize(_In_ int comp, _In_ bool bSigned) noexcept; - - static bool EndPointsFit(_In_ const EncodeParams* pEP, _In_reads_(BC6H_MAX_REGIONS) const INTEndPntPair aEndPts[]) noexcept; - - void GeneratePaletteQuantized(_In_ const EncodeParams* pEP, _In_ const INTEndPntPair& endPts, - _Out_writes_(BC6H_MAX_INDICES) INTColor aPalette[]) const noexcept; - float MapColorsQuantized(_In_ const EncodeParams* pEP, _In_reads_(np) const INTColor aColors[], _In_ size_t np, _In_ const INTEndPntPair &endPts) const noexcept; - float PerturbOne(_In_ const EncodeParams* pEP, _In_reads_(np) const INTColor aColors[], _In_ size_t np, _In_ uint8_t ch, - _In_ const INTEndPntPair& oldEndPts, _Out_ INTEndPntPair& newEndPts, _In_ float fOldErr, _In_ int do_b) const noexcept; - void OptimizeOne(_In_ const EncodeParams* pEP, _In_reads_(np) const INTColor aColors[], _In_ size_t np, _In_ float aOrgErr, - _In_ const INTEndPntPair &aOrgEndPts, _Out_ INTEndPntPair &aOptEndPts) const noexcept; - void OptimizeEndPoints(_In_ const EncodeParams* pEP, _In_reads_(BC6H_MAX_REGIONS) const float aOrgErr[], - _In_reads_(BC6H_MAX_REGIONS) const INTEndPntPair aOrgEndPts[], - _Out_writes_all_(BC6H_MAX_REGIONS) INTEndPntPair aOptEndPts[]) const noexcept; - static void SwapIndices(_In_ const EncodeParams* pEP, _Inout_updates_all_(BC6H_MAX_REGIONS) INTEndPntPair aEndPts[], - _In_reads_(NUM_PIXELS_PER_BLOCK) size_t aIndices[]) noexcept; - void AssignIndices(_In_ const EncodeParams* pEP, _In_reads_(BC6H_MAX_REGIONS) const INTEndPntPair aEndPts[], - _Out_writes_(NUM_PIXELS_PER_BLOCK) size_t aIndices[], - _Out_writes_(BC6H_MAX_REGIONS) float aTotErr[]) const noexcept; - void QuantizeEndPts(_In_ const EncodeParams* pEP, _Out_writes_(BC6H_MAX_REGIONS) INTEndPntPair* qQntEndPts) const noexcept; - void EmitBlock(_In_ const EncodeParams* pEP, _In_reads_(BC6H_MAX_REGIONS) const INTEndPntPair aEndPts[], - _In_reads_(NUM_PIXELS_PER_BLOCK) const size_t aIndices[]) noexcept; - void Refine(_Inout_ EncodeParams* pEP) noexcept; - - static void GeneratePaletteUnquantized(_In_ const EncodeParams* pEP, _In_ size_t uRegion, _Out_writes_(BC6H_MAX_INDICES) INTColor aPalette[]) noexcept; - float MapColors(_In_ const EncodeParams* pEP, _In_ size_t uRegion, _In_ size_t np, _In_reads_(np) const size_t* auIndex) const noexcept; - float RoughMSE(_Inout_ EncodeParams* pEP) const noexcept; - - private: - static const ModeDescriptor ms_aDesc[][82]; - static const ModeInfo ms_aInfo[]; - static const int ms_aModeToInfo[]; - }; - - // BC67 compression (16b bits per texel) - class D3DX_BC7 : private CBits< 16 > - { - public: - void Decode(_Out_writes_(NUM_PIXELS_PER_BLOCK) HDRColorA* pOut) const noexcept; - void Encode(uint32_t flags, _In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA* const pIn) noexcept; - - private: - struct ModeInfo - { - uint8_t uPartitions; - uint8_t uPartitionBits; - uint8_t uPBits; - uint8_t uRotationBits; - uint8_t uIndexModeBits; - uint8_t uIndexPrec; - uint8_t uIndexPrec2; - LDRColorA RGBAPrec; - LDRColorA RGBAPrecWithP; - }; - - #pragma warning(push) - #pragma warning(disable : 4512) - struct EncodeParams - { - uint8_t uMode; - LDREndPntPair aEndPts[BC7_MAX_SHAPES][BC7_MAX_REGIONS]; - LDRColorA aLDRPixels[NUM_PIXELS_PER_BLOCK]; - const HDRColorA* const aHDRPixels; - - EncodeParams(const HDRColorA* const aOriginal) noexcept : uMode(0), aEndPts{}, aLDRPixels{}, aHDRPixels(aOriginal) {} - }; - #pragma warning(pop) - - static uint8_t Quantize(_In_ uint8_t comp, _In_ uint8_t uPrec) noexcept - { - assert(0 < uPrec && uPrec <= 8); - const uint8_t rnd = std::min(255u, static_cast(unsigned(comp) + (1u << (7 - uPrec)))); - return uint8_t(rnd >> (8u - uPrec)); - } - - static LDRColorA Quantize(_In_ const LDRColorA& c, _In_ const LDRColorA& RGBAPrec) noexcept - { - LDRColorA q; - q.r = Quantize(c.r, RGBAPrec.r); - q.g = Quantize(c.g, RGBAPrec.g); - q.b = Quantize(c.b, RGBAPrec.b); - if (RGBAPrec.a) - q.a = Quantize(c.a, RGBAPrec.a); - else - q.a = 255; - return q; - } - - static uint8_t Unquantize(_In_ uint8_t comp, _In_ size_t uPrec) noexcept - { - assert(0 < uPrec && uPrec <= 8); - comp = static_cast(unsigned(comp) << (8 - uPrec)); - return uint8_t(comp | (comp >> uPrec)); - } - - static LDRColorA Unquantize(_In_ const LDRColorA& c, _In_ const LDRColorA& RGBAPrec) noexcept - { - LDRColorA q; - q.r = Unquantize(c.r, RGBAPrec.r); - q.g = Unquantize(c.g, RGBAPrec.g); - q.b = Unquantize(c.b, RGBAPrec.b); - q.a = RGBAPrec.a > 0 ? Unquantize(c.a, RGBAPrec.a) : 255u; - return q; - } - - void GeneratePaletteQuantized(_In_ const EncodeParams* pEP, _In_ size_t uIndexMode, _In_ const LDREndPntPair& endpts, - _Out_writes_(BC7_MAX_INDICES) LDRColorA aPalette[]) const noexcept; - float PerturbOne(_In_ const EncodeParams* pEP, _In_reads_(np) const LDRColorA colors[], _In_ size_t np, _In_ size_t uIndexMode, - _In_ size_t ch, _In_ const LDREndPntPair &old_endpts, - _Out_ LDREndPntPair &new_endpts, _In_ float old_err, _In_ uint8_t do_b) const noexcept; - void Exhaustive(_In_ const EncodeParams* pEP, _In_reads_(np) const LDRColorA aColors[], _In_ size_t np, _In_ size_t uIndexMode, - _In_ size_t ch, _Inout_ float& fOrgErr, _Inout_ LDREndPntPair& optEndPt) const noexcept; - void OptimizeOne(_In_ const EncodeParams* pEP, _In_reads_(np) const LDRColorA colors[], _In_ size_t np, _In_ size_t uIndexMode, - _In_ float orig_err, _In_ const LDREndPntPair &orig_endpts, _Out_ LDREndPntPair &opt_endpts) const noexcept; - void OptimizeEndPoints(_In_ const EncodeParams* pEP, _In_ size_t uShape, _In_ size_t uIndexMode, - _In_reads_(BC7_MAX_REGIONS) const float orig_err[], - _In_reads_(BC7_MAX_REGIONS) const LDREndPntPair orig_endpts[], - _Out_writes_(BC7_MAX_REGIONS) LDREndPntPair opt_endpts[]) const noexcept; - void AssignIndices(_In_ const EncodeParams* pEP, _In_ size_t uShape, _In_ size_t uIndexMode, - _In_reads_(BC7_MAX_REGIONS) LDREndPntPair endpts[], - _Out_writes_(NUM_PIXELS_PER_BLOCK) size_t aIndices[], _Out_writes_(NUM_PIXELS_PER_BLOCK) size_t aIndices2[], - _Out_writes_(BC7_MAX_REGIONS) float afTotErr[]) const noexcept; - void EmitBlock(_In_ const EncodeParams* pEP, _In_ size_t uShape, _In_ size_t uRotation, _In_ size_t uIndexMode, - _In_reads_(BC7_MAX_REGIONS) const LDREndPntPair aEndPts[], - _In_reads_(NUM_PIXELS_PER_BLOCK) const size_t aIndex[], - _In_reads_(NUM_PIXELS_PER_BLOCK) const size_t aIndex2[]) noexcept; - void FixEndpointPBits(_In_ const EncodeParams* pEP, _In_reads_(BC7_MAX_REGIONS) const LDREndPntPair *pOrigEndpoints, _Out_writes_(BC7_MAX_REGIONS) LDREndPntPair *pFixedEndpoints) noexcept; - float Refine(_In_ const EncodeParams* pEP, _In_ size_t uShape, _In_ size_t uRotation, _In_ size_t uIndexMode) noexcept; - - float MapColors(_In_ const EncodeParams* pEP, _In_reads_(np) const LDRColorA aColors[], _In_ size_t np, _In_ size_t uIndexMode, - _In_ const LDREndPntPair& endPts, _In_ float fMinErr) const noexcept; - static float RoughMSE(_Inout_ EncodeParams* pEP, _In_ size_t uShape, _In_ size_t uIndexMode) noexcept; - - private: - static const ModeInfo ms_aInfo[]; - }; -} - -// BC6H Compression -const D3DX_BC6H::ModeDescriptor D3DX_BC6H::ms_aDesc[14][82] = -{ - { // Mode 1 (0x00) - 10 5 5 5 - { M, 0}, { M, 1}, {GY, 4}, {BY, 4}, {BZ, 4}, {RW, 0}, {RW, 1}, {RW, 2}, {RW, 3}, {RW, 4}, - {RW, 5}, {RW, 6}, {RW, 7}, {RW, 8}, {RW, 9}, {GW, 0}, {GW, 1}, {GW, 2}, {GW, 3}, {GW, 4}, - {GW, 5}, {GW, 6}, {GW, 7}, {GW, 8}, {GW, 9}, {BW, 0}, {BW, 1}, {BW, 2}, {BW, 3}, {BW, 4}, - {BW, 5}, {BW, 6}, {BW, 7}, {BW, 8}, {BW, 9}, {RX, 0}, {RX, 1}, {RX, 2}, {RX, 3}, {RX, 4}, - {GZ, 4}, {GY, 0}, {GY, 1}, {GY, 2}, {GY, 3}, {GX, 0}, {GX, 1}, {GX, 2}, {GX, 3}, {GX, 4}, - {BZ, 0}, {GZ, 0}, {GZ, 1}, {GZ, 2}, {GZ, 3}, {BX, 0}, {BX, 1}, {BX, 2}, {BX, 3}, {BX, 4}, - {BZ, 1}, {BY, 0}, {BY, 1}, {BY, 2}, {BY, 3}, {RY, 0}, {RY, 1}, {RY, 2}, {RY, 3}, {RY, 4}, - {BZ, 2}, {RZ, 0}, {RZ, 1}, {RZ, 2}, {RZ, 3}, {RZ, 4}, {BZ, 3}, { D, 0}, { D, 1}, { D, 2}, - { D, 3}, { D, 4}, - }, - - { // Mode 2 (0x01) - 7 6 6 6 - { M, 0}, { M, 1}, {GY, 5}, {GZ, 4}, {GZ, 5}, {RW, 0}, {RW, 1}, {RW, 2}, {RW, 3}, {RW, 4}, - {RW, 5}, {RW, 6}, {BZ, 0}, {BZ, 1}, {BY, 4}, {GW, 0}, {GW, 1}, {GW, 2}, {GW, 3}, {GW, 4}, - {GW, 5}, {GW, 6}, {BY, 5}, {BZ, 2}, {GY, 4}, {BW, 0}, {BW, 1}, {BW, 2}, {BW, 3}, {BW, 4}, - {BW, 5}, {BW, 6}, {BZ, 3}, {BZ, 5}, {BZ, 4}, {RX, 0}, {RX, 1}, {RX, 2}, {RX, 3}, {RX, 4}, - {RX, 5}, {GY, 0}, {GY, 1}, {GY, 2}, {GY, 3}, {GX, 0}, {GX, 1}, {GX, 2}, {GX, 3}, {GX, 4}, - {GX, 5}, {GZ, 0}, {GZ, 1}, {GZ, 2}, {GZ, 3}, {BX, 0}, {BX, 1}, {BX, 2}, {BX, 3}, {BX, 4}, - {BX, 5}, {BY, 0}, {BY, 1}, {BY, 2}, {BY, 3}, {RY, 0}, {RY, 1}, {RY, 2}, {RY, 3}, {RY, 4}, - {RY, 5}, {RZ, 0}, {RZ, 1}, {RZ, 2}, {RZ, 3}, {RZ, 4}, {RZ, 5}, { D, 0}, { D, 1}, { D, 2}, - { D, 3}, { D, 4}, - }, - - { // Mode 3 (0x02) - 11 5 4 4 - { M, 0}, { M, 1}, { M, 2}, { M, 3}, { M, 4}, {RW, 0}, {RW, 1}, {RW, 2}, {RW, 3}, {RW, 4}, - {RW, 5}, {RW, 6}, {RW, 7}, {RW, 8}, {RW, 9}, {GW, 0}, {GW, 1}, {GW, 2}, {GW, 3}, {GW, 4}, - {GW, 5}, {GW, 6}, {GW, 7}, {GW, 8}, {GW, 9}, {BW, 0}, {BW, 1}, {BW, 2}, {BW, 3}, {BW, 4}, - {BW, 5}, {BW, 6}, {BW, 7}, {BW, 8}, {BW, 9}, {RX, 0}, {RX, 1}, {RX, 2}, {RX, 3}, {RX, 4}, - {RW,10}, {GY, 0}, {GY, 1}, {GY, 2}, {GY, 3}, {GX, 0}, {GX, 1}, {GX, 2}, {GX, 3}, {GW,10}, - {BZ, 0}, {GZ, 0}, {GZ, 1}, {GZ, 2}, {GZ, 3}, {BX, 0}, {BX, 1}, {BX, 2}, {BX, 3}, {BW,10}, - {BZ, 1}, {BY, 0}, {BY, 1}, {BY, 2}, {BY, 3}, {RY, 0}, {RY, 1}, {RY, 2}, {RY, 3}, {RY, 4}, - {BZ, 2}, {RZ, 0}, {RZ, 1}, {RZ, 2}, {RZ, 3}, {RZ, 4}, {BZ, 3}, { D, 0}, { D, 1}, { D, 2}, - { D, 3}, { D, 4}, - }, - - { // Mode 4 (0x06) - 11 4 5 4 - { M, 0}, { M, 1}, { M, 2}, { M, 3}, { M, 4}, {RW, 0}, {RW, 1}, {RW, 2}, {RW, 3}, {RW, 4}, - {RW, 5}, {RW, 6}, {RW, 7}, {RW, 8}, {RW, 9}, {GW, 0}, {GW, 1}, {GW, 2}, {GW, 3}, {GW, 4}, - {GW, 5}, {GW, 6}, {GW, 7}, {GW, 8}, {GW, 9}, {BW, 0}, {BW, 1}, {BW, 2}, {BW, 3}, {BW, 4}, - {BW, 5}, {BW, 6}, {BW, 7}, {BW, 8}, {BW, 9}, {RX, 0}, {RX, 1}, {RX, 2}, {RX, 3}, {RW,10}, - {GZ, 4}, {GY, 0}, {GY, 1}, {GY, 2}, {GY, 3}, {GX, 0}, {GX, 1}, {GX, 2}, {GX, 3}, {GX, 4}, - {GW,10}, {GZ, 0}, {GZ, 1}, {GZ, 2}, {GZ, 3}, {BX, 0}, {BX, 1}, {BX, 2}, {BX, 3}, {BW,10}, - {BZ, 1}, {BY, 0}, {BY, 1}, {BY, 2}, {BY, 3}, {RY, 0}, {RY, 1}, {RY, 2}, {RY, 3}, {BZ, 0}, - {BZ, 2}, {RZ, 0}, {RZ, 1}, {RZ, 2}, {RZ, 3}, {GY, 4}, {BZ, 3}, { D, 0}, { D, 1}, { D, 2}, - { D, 3}, { D, 4}, - }, - - { // Mode 5 (0x0a) - 11 4 4 5 - { M, 0}, { M, 1}, { M, 2}, { M, 3}, { M, 4}, {RW, 0}, {RW, 1}, {RW, 2}, {RW, 3}, {RW, 4}, - {RW, 5}, {RW, 6}, {RW, 7}, {RW, 8}, {RW, 9}, {GW, 0}, {GW, 1}, {GW, 2}, {GW, 3}, {GW, 4}, - {GW, 5}, {GW, 6}, {GW, 7}, {GW, 8}, {GW, 9}, {BW, 0}, {BW, 1}, {BW, 2}, {BW, 3}, {BW, 4}, - {BW, 5}, {BW, 6}, {BW, 7}, {BW, 8}, {BW, 9}, {RX, 0}, {RX, 1}, {RX, 2}, {RX, 3}, {RW,10}, - {BY, 4}, {GY, 0}, {GY, 1}, {GY, 2}, {GY, 3}, {GX, 0}, {GX, 1}, {GX, 2}, {GX, 3}, {GW,10}, - {BZ, 0}, {GZ, 0}, {GZ, 1}, {GZ, 2}, {GZ, 3}, {BX, 0}, {BX, 1}, {BX, 2}, {BX, 3}, {BX, 4}, - {BW,10}, {BY, 0}, {BY, 1}, {BY, 2}, {BY, 3}, {RY, 0}, {RY, 1}, {RY, 2}, {RY, 3}, {BZ, 1}, - {BZ, 2}, {RZ, 0}, {RZ, 1}, {RZ, 2}, {RZ, 3}, {BZ, 4}, {BZ, 3}, { D, 0}, { D, 1}, { D, 2}, - { D, 3}, { D, 4}, - }, - - { // Mode 6 (0x0e) - 9 5 5 5 - { M, 0}, { M, 1}, { M, 2}, { M, 3}, { M, 4}, {RW, 0}, {RW, 1}, {RW, 2}, {RW, 3}, {RW, 4}, - {RW, 5}, {RW, 6}, {RW, 7}, {RW, 8}, {BY, 4}, {GW, 0}, {GW, 1}, {GW, 2}, {GW, 3}, {GW, 4}, - {GW, 5}, {GW, 6}, {GW, 7}, {GW, 8}, {GY, 4}, {BW, 0}, {BW, 1}, {BW, 2}, {BW, 3}, {BW, 4}, - {BW, 5}, {BW, 6}, {BW, 7}, {BW, 8}, {BZ, 4}, {RX, 0}, {RX, 1}, {RX, 2}, {RX, 3}, {RX, 4}, - {GZ, 4}, {GY, 0}, {GY, 1}, {GY, 2}, {GY, 3}, {GX, 0}, {GX, 1}, {GX, 2}, {GX, 3}, {GX, 4}, - {BZ, 0}, {GZ, 0}, {GZ, 1}, {GZ, 2}, {GZ, 3}, {BX, 0}, {BX, 1}, {BX, 2}, {BX, 3}, {BX, 4}, - {BZ, 1}, {BY, 0}, {BY, 1}, {BY, 2}, {BY, 3}, {RY, 0}, {RY, 1}, {RY, 2}, {RY, 3}, {RY, 4}, - {BZ, 2}, {RZ, 0}, {RZ, 1}, {RZ, 2}, {RZ, 3}, {RZ, 4}, {BZ, 3}, { D, 0}, { D, 1}, { D, 2}, - { D, 3}, { D, 4}, - }, - - { // Mode 7 (0x12) - 8 6 5 5 - { M, 0}, { M, 1}, { M, 2}, { M, 3}, { M, 4}, {RW, 0}, {RW, 1}, {RW, 2}, {RW, 3}, {RW, 4}, - {RW, 5}, {RW, 6}, {RW, 7}, {GZ, 4}, {BY, 4}, {GW, 0}, {GW, 1}, {GW, 2}, {GW, 3}, {GW, 4}, - {GW, 5}, {GW, 6}, {GW, 7}, {BZ, 2}, {GY, 4}, {BW, 0}, {BW, 1}, {BW, 2}, {BW, 3}, {BW, 4}, - {BW, 5}, {BW, 6}, {BW, 7}, {BZ, 3}, {BZ, 4}, {RX, 0}, {RX, 1}, {RX, 2}, {RX, 3}, {RX, 4}, - {RX, 5}, {GY, 0}, {GY, 1}, {GY, 2}, {GY, 3}, {GX, 0}, {GX, 1}, {GX, 2}, {GX, 3}, {GX, 4}, - {BZ, 0}, {GZ, 0}, {GZ, 1}, {GZ, 2}, {GZ, 3}, {BX, 0}, {BX, 1}, {BX, 2}, {BX, 3}, {BX, 4}, - {BZ, 1}, {BY, 0}, {BY, 1}, {BY, 2}, {BY, 3}, {RY, 0}, {RY, 1}, {RY, 2}, {RY, 3}, {RY, 4}, - {RY, 5}, {RZ, 0}, {RZ, 1}, {RZ, 2}, {RZ, 3}, {RZ, 4}, {RZ, 5}, { D, 0}, { D, 1}, { D, 2}, - { D, 3}, { D, 4}, - }, - - { // Mode 8 (0x16) - 8 5 6 5 - { M, 0}, { M, 1}, { M, 2}, { M, 3}, { M, 4}, {RW, 0}, {RW, 1}, {RW, 2}, {RW, 3}, {RW, 4}, - {RW, 5}, {RW, 6}, {RW, 7}, {BZ, 0}, {BY, 4}, {GW, 0}, {GW, 1}, {GW, 2}, {GW, 3}, {GW, 4}, - {GW, 5}, {GW, 6}, {GW, 7}, {GY, 5}, {GY, 4}, {BW, 0}, {BW, 1}, {BW, 2}, {BW, 3}, {BW, 4}, - {BW, 5}, {BW, 6}, {BW, 7}, {GZ, 5}, {BZ, 4}, {RX, 0}, {RX, 1}, {RX, 2}, {RX, 3}, {RX, 4}, - {GZ, 4}, {GY, 0}, {GY, 1}, {GY, 2}, {GY, 3}, {GX, 0}, {GX, 1}, {GX, 2}, {GX, 3}, {GX, 4}, - {GX, 5}, {GZ, 0}, {GZ, 1}, {GZ, 2}, {GZ, 3}, {BX, 0}, {BX, 1}, {BX, 2}, {BX, 3}, {BX, 4}, - {BZ, 1}, {BY, 0}, {BY, 1}, {BY, 2}, {BY, 3}, {RY, 0}, {RY, 1}, {RY, 2}, {RY, 3}, {RY, 4}, - {BZ, 2}, {RZ, 0}, {RZ, 1}, {RZ, 2}, {RZ, 3}, {RZ, 4}, {BZ, 3}, { D, 0}, { D, 1}, { D, 2}, - { D, 3}, { D, 4}, - }, - - { // Mode 9 (0x1a) - 8 5 5 6 - { M, 0}, { M, 1}, { M, 2}, { M, 3}, { M, 4}, {RW, 0}, {RW, 1}, {RW, 2}, {RW, 3}, {RW, 4}, - {RW, 5}, {RW, 6}, {RW, 7}, {BZ, 1}, {BY, 4}, {GW, 0}, {GW, 1}, {GW, 2}, {GW, 3}, {GW, 4}, - {GW, 5}, {GW, 6}, {GW, 7}, {BY, 5}, {GY, 4}, {BW, 0}, {BW, 1}, {BW, 2}, {BW, 3}, {BW, 4}, - {BW, 5}, {BW, 6}, {BW, 7}, {BZ, 5}, {BZ, 4}, {RX, 0}, {RX, 1}, {RX, 2}, {RX, 3}, {RX, 4}, - {GZ, 4}, {GY, 0}, {GY, 1}, {GY, 2}, {GY, 3}, {GX, 0}, {GX, 1}, {GX, 2}, {GX, 3}, {GX, 4}, - {BZ, 0}, {GZ, 0}, {GZ, 1}, {GZ, 2}, {GZ, 3}, {BX, 0}, {BX, 1}, {BX, 2}, {BX, 3}, {BX, 4}, - {BX, 5}, {BY, 0}, {BY, 1}, {BY, 2}, {BY, 3}, {RY, 0}, {RY, 1}, {RY, 2}, {RY, 3}, {RY, 4}, - {BZ, 2}, {RZ, 0}, {RZ, 1}, {RZ, 2}, {RZ, 3}, {RZ, 4}, {BZ, 3}, { D, 0}, { D, 1}, { D, 2}, - { D, 3}, { D, 4}, - }, - - { // Mode 10 (0x1e) - 6 6 6 6 - { M, 0}, { M, 1}, { M, 2}, { M, 3}, { M, 4}, {RW, 0}, {RW, 1}, {RW, 2}, {RW, 3}, {RW, 4}, - {RW, 5}, {GZ, 4}, {BZ, 0}, {BZ, 1}, {BY, 4}, {GW, 0}, {GW, 1}, {GW, 2}, {GW, 3}, {GW, 4}, - {GW, 5}, {GY, 5}, {BY, 5}, {BZ, 2}, {GY, 4}, {BW, 0}, {BW, 1}, {BW, 2}, {BW, 3}, {BW, 4}, - {BW, 5}, {GZ, 5}, {BZ, 3}, {BZ, 5}, {BZ, 4}, {RX, 0}, {RX, 1}, {RX, 2}, {RX, 3}, {RX, 4}, - {RX, 5}, {GY, 0}, {GY, 1}, {GY, 2}, {GY, 3}, {GX, 0}, {GX, 1}, {GX, 2}, {GX, 3}, {GX, 4}, - {GX, 5}, {GZ, 0}, {GZ, 1}, {GZ, 2}, {GZ, 3}, {BX, 0}, {BX, 1}, {BX, 2}, {BX, 3}, {BX, 4}, - {BX, 5}, {BY, 0}, {BY, 1}, {BY, 2}, {BY, 3}, {RY, 0}, {RY, 1}, {RY, 2}, {RY, 3}, {RY, 4}, - {RY, 5}, {RZ, 0}, {RZ, 1}, {RZ, 2}, {RZ, 3}, {RZ, 4}, {RZ, 5}, { D, 0}, { D, 1}, { D, 2}, - { D, 3}, { D, 4}, - }, - - { // Mode 11 (0x03) - 10 10 - { M, 0}, { M, 1}, { M, 2}, { M, 3}, { M, 4}, {RW, 0}, {RW, 1}, {RW, 2}, {RW, 3}, {RW, 4}, - {RW, 5}, {RW, 6}, {RW, 7}, {RW, 8}, {RW, 9}, {GW, 0}, {GW, 1}, {GW, 2}, {GW, 3}, {GW, 4}, - {GW, 5}, {GW, 6}, {GW, 7}, {GW, 8}, {GW, 9}, {BW, 0}, {BW, 1}, {BW, 2}, {BW, 3}, {BW, 4}, - {BW, 5}, {BW, 6}, {BW, 7}, {BW, 8}, {BW, 9}, {RX, 0}, {RX, 1}, {RX, 2}, {RX, 3}, {RX, 4}, - {RX, 5}, {RX, 6}, {RX, 7}, {RX, 8}, {RX, 9}, {GX, 0}, {GX, 1}, {GX, 2}, {GX, 3}, {GX, 4}, - {GX, 5}, {GX, 6}, {GX, 7}, {GX, 8}, {GX, 9}, {BX, 0}, {BX, 1}, {BX, 2}, {BX, 3}, {BX, 4}, - {BX, 5}, {BX, 6}, {BX, 7}, {BX, 8}, {BX, 9}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, - {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, - {NA, 0}, {NA, 0}, - }, - - { // Mode 12 (0x07) - 11 9 - { M, 0}, { M, 1}, { M, 2}, { M, 3}, { M, 4}, {RW, 0}, {RW, 1}, {RW, 2}, {RW, 3}, {RW, 4}, - {RW, 5}, {RW, 6}, {RW, 7}, {RW, 8}, {RW, 9}, {GW, 0}, {GW, 1}, {GW, 2}, {GW, 3}, {GW, 4}, - {GW, 5}, {GW, 6}, {GW, 7}, {GW, 8}, {GW, 9}, {BW, 0}, {BW, 1}, {BW, 2}, {BW, 3}, {BW, 4}, - {BW, 5}, {BW, 6}, {BW, 7}, {BW, 8}, {BW, 9}, {RX, 0}, {RX, 1}, {RX, 2}, {RX, 3}, {RX, 4}, - {RX, 5}, {RX, 6}, {RX, 7}, {RX, 8}, {RW,10}, {GX, 0}, {GX, 1}, {GX, 2}, {GX, 3}, {GX, 4}, - {GX, 5}, {GX, 6}, {GX, 7}, {GX, 8}, {GW,10}, {BX, 0}, {BX, 1}, {BX, 2}, {BX, 3}, {BX, 4}, - {BX, 5}, {BX, 6}, {BX, 7}, {BX, 8}, {BW,10}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, - {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, - {NA, 0}, {NA, 0}, - }, - - { // Mode 13 (0x0b) - 12 8 - { M, 0}, { M, 1}, { M, 2}, { M, 3}, { M, 4}, {RW, 0}, {RW, 1}, {RW, 2}, {RW, 3}, {RW, 4}, - {RW, 5}, {RW, 6}, {RW, 7}, {RW, 8}, {RW, 9}, {GW, 0}, {GW, 1}, {GW, 2}, {GW, 3}, {GW, 4}, - {GW, 5}, {GW, 6}, {GW, 7}, {GW, 8}, {GW, 9}, {BW, 0}, {BW, 1}, {BW, 2}, {BW, 3}, {BW, 4}, - {BW, 5}, {BW, 6}, {BW, 7}, {BW, 8}, {BW, 9}, {RX, 0}, {RX, 1}, {RX, 2}, {RX, 3}, {RX, 4}, - {RX, 5}, {RX, 6}, {RX, 7}, {RW,11}, {RW,10}, {GX, 0}, {GX, 1}, {GX, 2}, {GX, 3}, {GX, 4}, - {GX, 5}, {GX, 6}, {GX, 7}, {GW,11}, {GW,10}, {BX, 0}, {BX, 1}, {BX, 2}, {BX, 3}, {BX, 4}, - {BX, 5}, {BX, 6}, {BX, 7}, {BW,11}, {BW,10}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, - {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, - {NA, 0}, {NA, 0}, - }, - - { // Mode 14 (0x0f) - 16 4 - { M, 0}, { M, 1}, { M, 2}, { M, 3}, { M, 4}, {RW, 0}, {RW, 1}, {RW, 2}, {RW, 3}, {RW, 4}, - {RW, 5}, {RW, 6}, {RW, 7}, {RW, 8}, {RW, 9}, {GW, 0}, {GW, 1}, {GW, 2}, {GW, 3}, {GW, 4}, - {GW, 5}, {GW, 6}, {GW, 7}, {GW, 8}, {GW, 9}, {BW, 0}, {BW, 1}, {BW, 2}, {BW, 3}, {BW, 4}, - {BW, 5}, {BW, 6}, {BW, 7}, {BW, 8}, {BW, 9}, {RX, 0}, {RX, 1}, {RX, 2}, {RX, 3}, {RW,15}, - {RW,14}, {RW,13}, {RW,12}, {RW,11}, {RW,10}, {GX, 0}, {GX, 1}, {GX, 2}, {GX, 3}, {GW,15}, - {GW,14}, {GW,13}, {GW,12}, {GW,11}, {GW,10}, {BX, 0}, {BX, 1}, {BX, 2}, {BX, 3}, {BW,15}, - {BW,14}, {BW,13}, {BW,12}, {BW,11}, {BW,10}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, - {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, {NA, 0}, - {NA, 0}, {NA, 0}, - }, -}; - -// Mode, Partitions, Transformed, IndexPrec, RGBAPrec -const D3DX_BC6H::ModeInfo D3DX_BC6H::ms_aInfo[] = -{ - {0x00, 1, true, 3, { { LDRColorA(10,10,10,0), LDRColorA(5, 5, 5,0) }, { LDRColorA(5,5,5,0), LDRColorA(5,5,5,0) } } }, // Mode 1 - {0x01, 1, true, 3, { { LDRColorA(7, 7, 7,0), LDRColorA(6, 6, 6,0) }, { LDRColorA(6,6,6,0), LDRColorA(6,6,6,0) } } }, // Mode 2 - {0x02, 1, true, 3, { { LDRColorA(11,11,11,0), LDRColorA(5, 4, 4,0) }, { LDRColorA(5,4,4,0), LDRColorA(5,4,4,0) } } }, // Mode 3 - {0x06, 1, true, 3, { { LDRColorA(11,11,11,0), LDRColorA(4, 5, 4,0) }, { LDRColorA(4,5,4,0), LDRColorA(4,5,4,0) } } }, // Mode 4 - {0x0a, 1, true, 3, { { LDRColorA(11,11,11,0), LDRColorA(4, 4, 5,0) }, { LDRColorA(4,4,5,0), LDRColorA(4,4,5,0) } } }, // Mode 5 - {0x0e, 1, true, 3, { { LDRColorA(9, 9, 9,0), LDRColorA(5, 5, 5,0) }, { LDRColorA(5,5,5,0), LDRColorA(5,5,5,0) } } }, // Mode 6 - {0x12, 1, true, 3, { { LDRColorA(8, 8, 8,0), LDRColorA(6, 5, 5,0) }, { LDRColorA(6,5,5,0), LDRColorA(6,5,5,0) } } }, // Mode 7 - {0x16, 1, true, 3, { { LDRColorA(8, 8, 8,0), LDRColorA(5, 6, 5,0) }, { LDRColorA(5,6,5,0), LDRColorA(5,6,5,0) } } }, // Mode 8 - {0x1a, 1, true, 3, { { LDRColorA(8, 8, 8,0), LDRColorA(5, 5, 6,0) }, { LDRColorA(5,5,6,0), LDRColorA(5,5,6,0) } } }, // Mode 9 - {0x1e, 1, false, 3, { { LDRColorA(6, 6, 6,0), LDRColorA(6, 6, 6,0) }, { LDRColorA(6,6,6,0), LDRColorA(6,6,6,0) } } }, // Mode 10 - {0x03, 0, false, 4, { { LDRColorA(10,10,10,0), LDRColorA(10,10,10,0) }, { LDRColorA(0,0,0,0), LDRColorA(0,0,0,0) } } }, // Mode 11 - {0x07, 0, true, 4, { { LDRColorA(11,11,11,0), LDRColorA(9, 9, 9,0) }, { LDRColorA(0,0,0,0), LDRColorA(0,0,0,0) } } }, // Mode 12 - {0x0b, 0, true, 4, { { LDRColorA(12,12,12,0), LDRColorA(8, 8, 8,0) }, { LDRColorA(0,0,0,0), LDRColorA(0,0,0,0) } } }, // Mode 13 - {0x0f, 0, true, 4, { { LDRColorA(16,16,16,0), LDRColorA(4, 4, 4,0) }, { LDRColorA(0,0,0,0), LDRColorA(0,0,0,0) } } }, // Mode 14 -}; - -const int D3DX_BC6H::ms_aModeToInfo[] = -{ - 0, // Mode 1 - 0x00 - 1, // Mode 2 - 0x01 - 2, // Mode 3 - 0x02 - 10, // Mode 11 - 0x03 - -1, // Invalid - 0x04 - -1, // Invalid - 0x05 - 3, // Mode 4 - 0x06 - 11, // Mode 12 - 0x07 - -1, // Invalid - 0x08 - -1, // Invalid - 0x09 - 4, // Mode 5 - 0x0a - 12, // Mode 13 - 0x0b - -1, // Invalid - 0x0c - -1, // Invalid - 0x0d - 5, // Mode 6 - 0x0e - 13, // Mode 14 - 0x0f - -1, // Invalid - 0x10 - -1, // Invalid - 0x11 - 6, // Mode 7 - 0x12 - -1, // Reserved - 0x13 - -1, // Invalid - 0x14 - -1, // Invalid - 0x15 - 7, // Mode 8 - 0x16 - -1, // Reserved - 0x17 - -1, // Invalid - 0x18 - -1, // Invalid - 0x19 - 8, // Mode 9 - 0x1a - -1, // Reserved - 0x1b - -1, // Invalid - 0x1c - -1, // Invalid - 0x1d - 9, // Mode 10 - 0x1e - -1, // Resreved - 0x1f -}; - -// BC7 compression: uPartitions, uPartitionBits, uPBits, uRotationBits, uIndexModeBits, uIndexPrec, uIndexPrec2, RGBAPrec, RGBAPrecWithP -const D3DX_BC7::ModeInfo D3DX_BC7::ms_aInfo[] = -{ - {2, 4, 6, 0, 0, 3, 0, LDRColorA(4,4,4,0), LDRColorA(5,5,5,0)}, - // Mode 0: Color only, 3 Subsets, RGBP 4441 (unique P-bit), 3-bit indecies, 16 partitions - {1, 6, 2, 0, 0, 3, 0, LDRColorA(6,6,6,0), LDRColorA(7,7,7,0)}, - // Mode 1: Color only, 2 Subsets, RGBP 6661 (shared P-bit), 3-bit indecies, 64 partitions - {2, 6, 0, 0, 0, 2, 0, LDRColorA(5,5,5,0), LDRColorA(5,5,5,0)}, - // Mode 2: Color only, 3 Subsets, RGB 555, 2-bit indecies, 64 partitions - {1, 6, 4, 0, 0, 2, 0, LDRColorA(7,7,7,0), LDRColorA(8,8,8,0)}, - // Mode 3: Color only, 2 Subsets, RGBP 7771 (unique P-bit), 2-bits indecies, 64 partitions - {0, 0, 0, 2, 1, 2, 3, LDRColorA(5,5,5,6), LDRColorA(5,5,5,6)}, - // Mode 4: Color w/ Separate Alpha, 1 Subset, RGB 555, A6, 16x2/16x3-bit indices, 2-bit rotation, 1-bit index selector - {0, 0, 0, 2, 0, 2, 2, LDRColorA(7,7,7,8), LDRColorA(7,7,7,8)}, - // Mode 5: Color w/ Separate Alpha, 1 Subset, RGB 777, A8, 16x2/16x2-bit indices, 2-bit rotation - {0, 0, 2, 0, 0, 4, 0, LDRColorA(7,7,7,7), LDRColorA(8,8,8,8)}, - // Mode 6: Color+Alpha, 1 Subset, RGBAP 77771 (unique P-bit), 16x4-bit indecies - {1, 6, 4, 0, 0, 2, 0, LDRColorA(5,5,5,5), LDRColorA(6,6,6,6)} - // Mode 7: Color+Alpha, 2 Subsets, RGBAP 55551 (unique P-bit), 2-bit indices, 64 partitions -}; - - -namespace -{ - //------------------------------------------------------------------------------------- - // Helper functions - //------------------------------------------------------------------------------------- - inline bool IsFixUpOffset(_In_range_(0, 2) size_t uPartitions, _In_range_(0, 63) size_t uShape, _In_range_(0, 15) size_t uOffset) noexcept - { - assert(uPartitions < 3 && uShape < 64 && uOffset < 16); - _Analysis_assume_(uPartitions < 3 && uShape < 64 && uOffset < 16); - for (size_t p = 0; p <= uPartitions; p++) - { - if (uOffset == g_aFixUp[uPartitions][uShape][p]) - { - return true; - } - } - return false; - } - - inline void TransformForward(_Inout_updates_all_(BC6H_MAX_REGIONS) INTEndPntPair aEndPts[]) noexcept - { - aEndPts[0].B -= aEndPts[0].A; - aEndPts[1].A -= aEndPts[0].A; - aEndPts[1].B -= aEndPts[0].A; - } - - inline void TransformInverse(_Inout_updates_all_(BC6H_MAX_REGIONS) INTEndPntPair aEndPts[], _In_ const LDRColorA& Prec, _In_ bool bSigned) noexcept - { - const INTColor WrapMask((1 << Prec.r) - 1, (1 << Prec.g) - 1, (1 << Prec.b) - 1); - aEndPts[0].B += aEndPts[0].A; aEndPts[0].B &= WrapMask; - aEndPts[1].A += aEndPts[0].A; aEndPts[1].A &= WrapMask; - aEndPts[1].B += aEndPts[0].A; aEndPts[1].B &= WrapMask; - if (bSigned) - { - aEndPts[0].B.SignExtend(Prec); - aEndPts[1].A.SignExtend(Prec); - aEndPts[1].B.SignExtend(Prec); - } - } - - inline float Norm(_In_ const INTColor& a, _In_ const INTColor& b) noexcept - { - const float dr = float(a.r) - float(b.r); - const float dg = float(a.g) - float(b.g); - const float db = float(a.b) - float(b.b); - return dr * dr + dg * dg + db * db; - } - - // return # of bits needed to store n. handle signed or unsigned cases properly - inline int NBits(_In_ int n, _In_ bool bIsSigned) noexcept - { - int nb; - if (n == 0) - { - return 0; // no bits needed for 0, signed or not - } - else if (n > 0) - { - for (nb = 0; n; ++nb, n >>= 1); - return nb + (bIsSigned ? 1 : 0); - } - else - { - assert(bIsSigned); - for (nb = 0; n < -1; ++nb, n >>= 1); - return nb + 1; - } - } - - - //------------------------------------------------------------------------------------- - float OptimizeRGB( - _In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA* const pPoints, - _Out_ HDRColorA* pX, - _Out_ HDRColorA* pY, - _In_range_(3, 4) uint32_t cSteps, - size_t cPixels, - _In_reads_(cPixels) const size_t* pIndex) noexcept - { - constexpr float fError = FLT_MAX; - const float *pC = (3 == cSteps) ? pC3 : pC4; - const float *pD = (3 == cSteps) ? pD3 : pD4; - - // Find Min and Max points, as starting point - HDRColorA X(FLT_MAX, FLT_MAX, FLT_MAX, 0.0f); - HDRColorA Y(-FLT_MAX, -FLT_MAX, -FLT_MAX, 0.0f); - - for (size_t iPoint = 0; iPoint < cPixels; iPoint++) - { - if (pPoints[pIndex[iPoint]].r < X.r) X.r = pPoints[pIndex[iPoint]].r; - if (pPoints[pIndex[iPoint]].g < X.g) X.g = pPoints[pIndex[iPoint]].g; - if (pPoints[pIndex[iPoint]].b < X.b) X.b = pPoints[pIndex[iPoint]].b; - if (pPoints[pIndex[iPoint]].r > Y.r) Y.r = pPoints[pIndex[iPoint]].r; - if (pPoints[pIndex[iPoint]].g > Y.g) Y.g = pPoints[pIndex[iPoint]].g; - if (pPoints[pIndex[iPoint]].b > Y.b) Y.b = pPoints[pIndex[iPoint]].b; - } - - // Diagonal axis - HDRColorA AB; - AB.r = Y.r - X.r; - AB.g = Y.g - X.g; - AB.b = Y.b - X.b; - - const float fAB = AB.r * AB.r + AB.g * AB.g + AB.b * AB.b; - - // Single color block.. no need to root-find - if (fAB < FLT_MIN) - { - pX->r = X.r; pX->g = X.g; pX->b = X.b; - pY->r = Y.r; pY->g = Y.g; pY->b = Y.b; - return 0.0f; - } - - // Try all four axis directions, to determine which diagonal best fits data - const float fABInv = 1.0f / fAB; - - HDRColorA Dir; - Dir.r = AB.r * fABInv; - Dir.g = AB.g * fABInv; - Dir.b = AB.b * fABInv; - - HDRColorA Mid; - Mid.r = (X.r + Y.r) * 0.5f; - Mid.g = (X.g + Y.g) * 0.5f; - Mid.b = (X.b + Y.b) * 0.5f; - - float fDir[4]; - fDir[0] = fDir[1] = fDir[2] = fDir[3] = 0.0f; - - for (size_t iPoint = 0; iPoint < cPixels; iPoint++) - { - HDRColorA Pt; - Pt.r = (pPoints[pIndex[iPoint]].r - Mid.r) * Dir.r; - Pt.g = (pPoints[pIndex[iPoint]].g - Mid.g) * Dir.g; - Pt.b = (pPoints[pIndex[iPoint]].b - Mid.b) * Dir.b; - - float f; - f = Pt.r + Pt.g + Pt.b; fDir[0] += f * f; - f = Pt.r + Pt.g - Pt.b; fDir[1] += f * f; - f = Pt.r - Pt.g + Pt.b; fDir[2] += f * f; - f = Pt.r - Pt.g - Pt.b; fDir[3] += f * f; - } - - float fDirMax = fDir[0]; - size_t iDirMax = 0; - - for (size_t iDir = 1; iDir < 4; iDir++) - { - if (fDir[iDir] > fDirMax) - { - fDirMax = fDir[iDir]; - iDirMax = iDir; - } - } - - if (iDirMax & 2) std::swap(X.g, Y.g); - if (iDirMax & 1) std::swap(X.b, Y.b); - - // Two color block.. no need to root-find - if (fAB < 1.0f / 4096.0f) - { - pX->r = X.r; pX->g = X.g; pX->b = X.b; - pY->r = Y.r; pY->g = Y.g; pY->b = Y.b; - return 0.0f; - } - - // Use Newton's Method to find local minima of sum-of-squares error. - auto const fSteps = static_cast(cSteps - 1); - - for (size_t iIteration = 0; iIteration < 8; iIteration++) - { - // Calculate new steps - HDRColorA pSteps[4] = {}; - - for (size_t iStep = 0; iStep < cSteps; iStep++) - { - pSteps[iStep].r = X.r * pC[iStep] + Y.r * pD[iStep]; - pSteps[iStep].g = X.g * pC[iStep] + Y.g * pD[iStep]; - pSteps[iStep].b = X.b * pC[iStep] + Y.b * pD[iStep]; - } - - // Calculate color direction - Dir.r = Y.r - X.r; - Dir.g = Y.g - X.g; - Dir.b = Y.b - X.b; - - const float fLen = (Dir.r * Dir.r + Dir.g * Dir.g + Dir.b * Dir.b); - - if (fLen < (1.0f / 4096.0f)) - break; - - const float fScale = fSteps / fLen; - - Dir.r *= fScale; - Dir.g *= fScale; - Dir.b *= fScale; - - // Evaluate function, and derivatives - float d2X = 0.0f, d2Y = 0.0f; - HDRColorA dX(0.0f, 0.0f, 0.0f, 0.0f), dY(0.0f, 0.0f, 0.0f, 0.0f); - - for (size_t iPoint = 0; iPoint < cPixels; iPoint++) - { - const float fDot = (pPoints[pIndex[iPoint]].r - X.r) * Dir.r + - (pPoints[pIndex[iPoint]].g - X.g) * Dir.g + - (pPoints[pIndex[iPoint]].b - X.b) * Dir.b; - - uint32_t iStep; - if (fDot <= 0.0f) - iStep = 0; - else if (fDot >= fSteps) - iStep = cSteps - 1; - else - iStep = uint32_t(fDot + 0.5f); - - HDRColorA Diff; - Diff.r = pSteps[iStep].r - pPoints[pIndex[iPoint]].r; - Diff.g = pSteps[iStep].g - pPoints[pIndex[iPoint]].g; - Diff.b = pSteps[iStep].b - pPoints[pIndex[iPoint]].b; - - const float fC = pC[iStep] * (1.0f / 8.0f); - const float fD = pD[iStep] * (1.0f / 8.0f); - - d2X += fC * pC[iStep]; - dX.r += fC * Diff.r; - dX.g += fC * Diff.g; - dX.b += fC * Diff.b; - - d2Y += fD * pD[iStep]; - dY.r += fD * Diff.r; - dY.g += fD * Diff.g; - dY.b += fD * Diff.b; - } - - // Move endpoints - if (d2X > 0.0f) - { - const float f = -1.0f / d2X; - - X.r += dX.r * f; - X.g += dX.g * f; - X.b += dX.b * f; - } - - if (d2Y > 0.0f) - { - const float f = -1.0f / d2Y; - - Y.r += dY.r * f; - Y.g += dY.g * f; - Y.b += dY.b * f; - } - - if ((dX.r * dX.r < fEpsilon) && (dX.g * dX.g < fEpsilon) && (dX.b * dX.b < fEpsilon) && - (dY.r * dY.r < fEpsilon) && (dY.g * dY.g < fEpsilon) && (dY.b * dY.b < fEpsilon)) - { - break; - } - } - - pX->r = X.r; pX->g = X.g; pX->b = X.b; - pY->r = Y.r; pY->g = Y.g; pY->b = Y.b; - return fError; - } - - - //------------------------------------------------------------------------------------- - float OptimizeRGBA( - _In_reads_(NUM_PIXELS_PER_BLOCK) const HDRColorA* const pPoints, - _Out_ HDRColorA* pX, - _Out_ HDRColorA* pY, - _In_range_(3, 4) uint32_t cSteps, - size_t cPixels, - _In_reads_(cPixels) const size_t* pIndex) noexcept - { - constexpr float fError = FLT_MAX; - const float *pC = (3 == cSteps) ? pC3 : pC4; - const float *pD = (3 == cSteps) ? pD3 : pD4; - - // Find Min and Max points, as starting point - HDRColorA X(1.0f, 1.0f, 1.0f, 1.0f); - HDRColorA Y(0.0f, 0.0f, 0.0f, 0.0f); - - for (size_t iPoint = 0; iPoint < cPixels; iPoint++) - { - if (pPoints[pIndex[iPoint]].r < X.r) X.r = pPoints[pIndex[iPoint]].r; - if (pPoints[pIndex[iPoint]].g < X.g) X.g = pPoints[pIndex[iPoint]].g; - if (pPoints[pIndex[iPoint]].b < X.b) X.b = pPoints[pIndex[iPoint]].b; - if (pPoints[pIndex[iPoint]].a < X.a) X.a = pPoints[pIndex[iPoint]].a; - if (pPoints[pIndex[iPoint]].r > Y.r) Y.r = pPoints[pIndex[iPoint]].r; - if (pPoints[pIndex[iPoint]].g > Y.g) Y.g = pPoints[pIndex[iPoint]].g; - if (pPoints[pIndex[iPoint]].b > Y.b) Y.b = pPoints[pIndex[iPoint]].b; - if (pPoints[pIndex[iPoint]].a > Y.a) Y.a = pPoints[pIndex[iPoint]].a; - } - - // Diagonal axis - const HDRColorA AB = Y - X; - const float fAB = AB * AB; - - // Single color block.. no need to root-find - if (fAB < FLT_MIN) - { - *pX = X; - *pY = Y; - return 0.0f; - } - - // Try all four axis directions, to determine which diagonal best fits data - const float fABInv = 1.0f / fAB; - HDRColorA Dir = AB * fABInv; - const HDRColorA Mid = (X + Y) * 0.5f; - - float fDir[8]; - fDir[0] = fDir[1] = fDir[2] = fDir[3] = fDir[4] = fDir[5] = fDir[6] = fDir[7] = 0.0f; - - for (size_t iPoint = 0; iPoint < cPixels; iPoint++) - { - HDRColorA Pt; - Pt.r = (pPoints[pIndex[iPoint]].r - Mid.r) * Dir.r; - Pt.g = (pPoints[pIndex[iPoint]].g - Mid.g) * Dir.g; - Pt.b = (pPoints[pIndex[iPoint]].b - Mid.b) * Dir.b; - Pt.a = (pPoints[pIndex[iPoint]].a - Mid.a) * Dir.a; - - float f; - f = Pt.r + Pt.g + Pt.b + Pt.a; fDir[0] += f * f; - f = Pt.r + Pt.g + Pt.b - Pt.a; fDir[1] += f * f; - f = Pt.r + Pt.g - Pt.b + Pt.a; fDir[2] += f * f; - f = Pt.r + Pt.g - Pt.b - Pt.a; fDir[3] += f * f; - f = Pt.r - Pt.g + Pt.b + Pt.a; fDir[4] += f * f; - f = Pt.r - Pt.g + Pt.b - Pt.a; fDir[5] += f * f; - f = Pt.r - Pt.g - Pt.b + Pt.a; fDir[6] += f * f; - f = Pt.r - Pt.g - Pt.b - Pt.a; fDir[7] += f * f; - } - - float fDirMax = fDir[0]; - size_t iDirMax = 0; - - for (size_t iDir = 1; iDir < 8; iDir++) - { - if (fDir[iDir] > fDirMax) - { - fDirMax = fDir[iDir]; - iDirMax = iDir; - } - } - - if (iDirMax & 4) std::swap(X.g, Y.g); - if (iDirMax & 2) std::swap(X.b, Y.b); - if (iDirMax & 1) std::swap(X.a, Y.a); - - // Two color block.. no need to root-find - if (fAB < 1.0f / 4096.0f) - { - *pX = X; - *pY = Y; - return 0.0f; - } - - // Use Newton's Method to find local minima of sum-of-squares error. - const auto fSteps = static_cast(cSteps - 1u); - - for (size_t iIteration = 0; iIteration < 8 && fError > 0.0f; iIteration++) - { - // Calculate new steps - HDRColorA pSteps[BC7_MAX_INDICES]; - - LDRColorA lX, lY; - lX = (X * 255.0f).ToLDRColorA(); - lY = (Y * 255.0f).ToLDRColorA(); - - for (size_t iStep = 0; iStep < cSteps; iStep++) - { - pSteps[iStep] = X * pC[iStep] + Y * pD[iStep]; - //LDRColorA::Interpolate(lX, lY, i, i, wcprec, waprec, aSteps[i]); - } - - // Calculate color direction - Dir = Y - X; - const float fLen = Dir * Dir; - if (fLen < (1.0f / 4096.0f)) - break; - - const float fScale = fSteps / fLen; - Dir *= fScale; - - // Evaluate function, and derivatives - float d2X = 0.0f, d2Y = 0.0f; - HDRColorA dX(0.0f, 0.0f, 0.0f, 0.0f), dY(0.0f, 0.0f, 0.0f, 0.0f); - - for (size_t iPoint = 0; iPoint < cPixels; ++iPoint) - { - const float fDot = (pPoints[pIndex[iPoint]] - X) * Dir; - - uint32_t iStep; - if (fDot <= 0.0f) - iStep = 0; - else if (fDot >= fSteps) - iStep = cSteps - 1; - else - iStep = uint32_t(fDot + 0.5f); - - const HDRColorA Diff = pSteps[iStep] - pPoints[pIndex[iPoint]]; - const float fC = pC[iStep] * (1.0f / 8.0f); - const float fD = pD[iStep] * (1.0f / 8.0f); - - d2X += fC * pC[iStep]; - dX += Diff * fC; - - d2Y += fD * pD[iStep]; - dY += Diff * fD; - } - - // Move endpoints - if (d2X > 0.0f) - { - const float f = -1.0f / d2X; - X += dX * f; - } - - if (d2Y > 0.0f) - { - const float f = -1.0f / d2Y; - Y += dY * f; - } - - if ((dX * dX < fEpsilon) && (dY * dY < fEpsilon)) - break; - } - - *pX = X; - *pY = Y; - return fError; - } - - - //------------------------------------------------------------------------------------- - float ComputeError( - _Inout_ const LDRColorA& pixel, - _In_reads_(1 << uIndexPrec) const LDRColorA aPalette[], - uint8_t uIndexPrec, - uint8_t uIndexPrec2, - _Out_opt_ size_t* pBestIndex = nullptr, - _Out_opt_ size_t* pBestIndex2 = nullptr) noexcept - { - const size_t uNumIndices = size_t(1) << uIndexPrec; - const size_t uNumIndices2 = size_t(1) << uIndexPrec2; - float fTotalErr = 0; - float fBestErr = FLT_MAX; - - if (pBestIndex) - *pBestIndex = 0; - if (pBestIndex2) - *pBestIndex2 = 0; - - const XMVECTOR vpixel = XMLoadUByte4(reinterpret_cast(&pixel)); - - if (uIndexPrec2 == 0) - { - for (size_t i = 0; i < uNumIndices && fBestErr > 0; i++) - { - XMVECTOR tpixel = XMLoadUByte4(reinterpret_cast(&aPalette[i])); - // Compute ErrorMetric - tpixel = XMVectorSubtract(vpixel, tpixel); - const float fErr = XMVectorGetX(XMVector4Dot(tpixel, tpixel)); - if (fErr > fBestErr) // error increased, so we're done searching - break; - if (fErr < fBestErr) - { - fBestErr = fErr; - if (pBestIndex) - *pBestIndex = i; - } - } - fTotalErr += fBestErr; - } - else - { - for (size_t i = 0; i < uNumIndices && fBestErr > 0; i++) - { - XMVECTOR tpixel = XMLoadUByte4(reinterpret_cast(&aPalette[i])); - // Compute ErrorMetricRGB - tpixel = XMVectorSubtract(vpixel, tpixel); - const float fErr = XMVectorGetX(XMVector3Dot(tpixel, tpixel)); - if (fErr > fBestErr) // error increased, so we're done searching - break; - if (fErr < fBestErr) - { - fBestErr = fErr; - if (pBestIndex) - *pBestIndex = i; - } - } - fTotalErr += fBestErr; - fBestErr = FLT_MAX; - for (size_t i = 0; i < uNumIndices2 && fBestErr > 0; i++) - { - // Compute ErrorMetricAlpha - const float ea = float(pixel.a) - float(aPalette[i].a); - const float fErr = ea*ea; - if (fErr > fBestErr) // error increased, so we're done searching - break; - if (fErr < fBestErr) - { - fBestErr = fErr; - if (pBestIndex2) - *pBestIndex2 = i; - } - } - fTotalErr += fBestErr; - } - - return fTotalErr; - } - - - void FillWithErrorColors(_Out_writes_(NUM_PIXELS_PER_BLOCK) HDRColorA* pOut) noexcept - { - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - { - #ifdef _DEBUG - // Use Magenta in debug as a highly-visible error color - pOut[i] = HDRColorA(1.0f, 0.0f, 1.0f, 1.0f); - #else - // In production use, default to black - pOut[i] = HDRColorA(0.0f, 0.0f, 0.0f, 1.0f); - #endif - } - } -} - - -//------------------------------------------------------------------------------------- -// BC6H Compression -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -void D3DX_BC6H::Decode(bool bSigned, HDRColorA* pOut) const noexcept -{ - assert(pOut); - - size_t uStartBit = 0; - uint8_t uMode = GetBits(uStartBit, 2u); - if (uMode != 0x00 && uMode != 0x01) - { - uMode = static_cast((unsigned(GetBits(uStartBit, 3)) << 2) | uMode); - } - - assert(uMode < 32); - _Analysis_assume_(uMode < 32); - - if (ms_aModeToInfo[uMode] >= 0) - { - assert(static_cast(ms_aModeToInfo[uMode]) < std::size(ms_aInfo)); - _Analysis_assume_(ms_aModeToInfo[uMode] < std::size(ms_aInfo)); - const ModeDescriptor* desc = ms_aDesc[ms_aModeToInfo[uMode]]; - - assert(static_cast(ms_aModeToInfo[uMode]) < std::size(ms_aDesc)); - _Analysis_assume_(ms_aModeToInfo[uMode] < std::size(ms_aDesc)); - const ModeInfo& info = ms_aInfo[ms_aModeToInfo[uMode]]; - - INTEndPntPair aEndPts[BC6H_MAX_REGIONS] = {}; - uint32_t uShape = 0; - - // Read header - const size_t uHeaderBits = info.uPartitions > 0 ? 82u : 65u; - while (uStartBit < uHeaderBits) - { - const size_t uCurBit = uStartBit; - if (GetBit(uStartBit)) - { - switch (desc[uCurBit].m_eField) - { - case D: uShape |= 1 << uint32_t(desc[uCurBit].m_uBit); break; - case RW: aEndPts[0].A.r |= 1 << uint32_t(desc[uCurBit].m_uBit); break; - case RX: aEndPts[0].B.r |= 1 << uint32_t(desc[uCurBit].m_uBit); break; - case RY: aEndPts[1].A.r |= 1 << uint32_t(desc[uCurBit].m_uBit); break; - case RZ: aEndPts[1].B.r |= 1 << uint32_t(desc[uCurBit].m_uBit); break; - case GW: aEndPts[0].A.g |= 1 << uint32_t(desc[uCurBit].m_uBit); break; - case GX: aEndPts[0].B.g |= 1 << uint32_t(desc[uCurBit].m_uBit); break; - case GY: aEndPts[1].A.g |= 1 << uint32_t(desc[uCurBit].m_uBit); break; - case GZ: aEndPts[1].B.g |= 1 << uint32_t(desc[uCurBit].m_uBit); break; - case BW: aEndPts[0].A.b |= 1 << uint32_t(desc[uCurBit].m_uBit); break; - case BX: aEndPts[0].B.b |= 1 << uint32_t(desc[uCurBit].m_uBit); break; - case BY: aEndPts[1].A.b |= 1 << uint32_t(desc[uCurBit].m_uBit); break; - case BZ: aEndPts[1].B.b |= 1 << uint32_t(desc[uCurBit].m_uBit); break; - default: - { - #ifdef _DEBUG - OutputDebugStringA("BC6H: Invalid header bits encountered during decoding\n"); - #endif - FillWithErrorColors(pOut); - return; - } - } - } - } - - assert(uShape < 64); - _Analysis_assume_(uShape < 64); - - // Sign extend necessary end points - if (bSigned) - { - aEndPts[0].A.SignExtend(info.RGBAPrec[0][0]); - } - if (bSigned || info.bTransformed) - { - assert(info.uPartitions < BC6H_MAX_REGIONS); - _Analysis_assume_(info.uPartitions < BC6H_MAX_REGIONS); - for (size_t p = 0; p <= info.uPartitions; ++p) - { - if (p != 0) - { - aEndPts[p].A.SignExtend(info.RGBAPrec[p][0]); - } - aEndPts[p].B.SignExtend(info.RGBAPrec[p][1]); - } - } - - // Inverse transform the end points - if (info.bTransformed) - { - TransformInverse(aEndPts, info.RGBAPrec[0][0], bSigned); - } - - // Read indices - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - { - const size_t uNumBits = IsFixUpOffset(info.uPartitions, uShape, i) ? info.uIndexPrec - 1u : info.uIndexPrec; - if (uStartBit + uNumBits > 128) - { - #ifdef _DEBUG - OutputDebugStringA("BC6H: Invalid block encountered during decoding\n"); - #endif - FillWithErrorColors(pOut); - return; - } - const uint8_t uIndex = GetBits(uStartBit, uNumBits); - - if (uIndex >= ((info.uPartitions > 0) ? 8 : 16)) - { - #ifdef _DEBUG - OutputDebugStringA("BC6H: Invalid index encountered during decoding\n"); - #endif - FillWithErrorColors(pOut); - return; - } - - const size_t uRegion = g_aPartitionTable[info.uPartitions][uShape][i]; - assert(uRegion < BC6H_MAX_REGIONS); - _Analysis_assume_(uRegion < BC6H_MAX_REGIONS); - - // Unquantize endpoints and interpolate - const int r1 = Unquantize(aEndPts[uRegion].A.r, info.RGBAPrec[0][0].r, bSigned); - const int g1 = Unquantize(aEndPts[uRegion].A.g, info.RGBAPrec[0][0].g, bSigned); - const int b1 = Unquantize(aEndPts[uRegion].A.b, info.RGBAPrec[0][0].b, bSigned); - const int r2 = Unquantize(aEndPts[uRegion].B.r, info.RGBAPrec[0][0].r, bSigned); - const int g2 = Unquantize(aEndPts[uRegion].B.g, info.RGBAPrec[0][0].g, bSigned); - const int b2 = Unquantize(aEndPts[uRegion].B.b, info.RGBAPrec[0][0].b, bSigned); - const int* aWeights = info.uPartitions > 0 ? g_aWeights3 : g_aWeights4; - INTColor fc; - fc.r = FinishUnquantize((r1 * (BC67_WEIGHT_MAX - aWeights[uIndex]) + r2 * aWeights[uIndex] + BC67_WEIGHT_ROUND) >> BC67_WEIGHT_SHIFT, bSigned); - fc.g = FinishUnquantize((g1 * (BC67_WEIGHT_MAX - aWeights[uIndex]) + g2 * aWeights[uIndex] + BC67_WEIGHT_ROUND) >> BC67_WEIGHT_SHIFT, bSigned); - fc.b = FinishUnquantize((b1 * (BC67_WEIGHT_MAX - aWeights[uIndex]) + b2 * aWeights[uIndex] + BC67_WEIGHT_ROUND) >> BC67_WEIGHT_SHIFT, bSigned); - - HALF rgb[3]; - fc.ToF16(rgb, bSigned); - - pOut[i].r = XMConvertHalfToFloat(rgb[0]); - pOut[i].g = XMConvertHalfToFloat(rgb[1]); - pOut[i].b = XMConvertHalfToFloat(rgb[2]); - pOut[i].a = 1.0f; - } - } - else - { - #ifdef _DEBUG - const char* warnstr = "BC6H: Invalid mode encountered during decoding\n"; - switch (uMode) - { - case 0x13: warnstr = "BC6H: Reserved mode 10011 encountered during decoding\n"; break; - case 0x17: warnstr = "BC6H: Reserved mode 10111 encountered during decoding\n"; break; - case 0x1B: warnstr = "BC6H: Reserved mode 11011 encountered during decoding\n"; break; - case 0x1F: warnstr = "BC6H: Reserved mode 11111 encountered during decoding\n"; break; - } - OutputDebugStringA(warnstr); - #endif - // Per the BC6H format spec, we must return opaque black - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - { - pOut[i] = HDRColorA(0.0f, 0.0f, 0.0f, 1.0f); - } - } -} - - -_Use_decl_annotations_ -void D3DX_BC6H::Encode(bool bSigned, const HDRColorA* const pIn) noexcept -{ - assert(pIn); - - EncodeParams EP(pIn, bSigned); - - for (EP.uMode = 0; EP.uMode < std::size(ms_aInfo) && EP.fBestErr > 0; ++EP.uMode) - { - const uint8_t uShapes = ms_aInfo[EP.uMode].uPartitions ? 32u : 1u; - // Number of rough cases to look at. reasonable values of this are 1, uShapes/4, and uShapes - // uShapes/4 gets nearly all the cases; you can increase that a bit (say by 3 or 4) if you really want to squeeze the last bit out - const size_t uItems = std::max(1u, size_t(uShapes >> 2)); - float afRoughMSE[BC6H_MAX_SHAPES]; - uint8_t auShape[BC6H_MAX_SHAPES]; - - // pick the best uItems shapes and refine these. - for (EP.uShape = 0; EP.uShape < uShapes; ++EP.uShape) - { - size_t uShape = EP.uShape; - afRoughMSE[uShape] = RoughMSE(&EP); - auShape[uShape] = static_cast(uShape); - } - - // Bubble up the first uItems items - for (size_t i = 0; i < uItems; i++) - { - for (size_t j = i + 1; j < uShapes; j++) - { - if (afRoughMSE[i] > afRoughMSE[j]) - { - std::swap(afRoughMSE[i], afRoughMSE[j]); - std::swap(auShape[i], auShape[j]); - } - } - } - - for (size_t i = 0; i < uItems && EP.fBestErr > 0; i++) - { - EP.uShape = auShape[i]; - Refine(&EP); - } - } -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -int D3DX_BC6H::Quantize(int iValue, int prec, bool bSigned) noexcept -{ - assert(prec > 1); // didn't bother to make it work for 1 - int q, s = 0; - if (bSigned) - { - assert(iValue >= -F16MAX && iValue <= F16MAX); - if (iValue < 0) - { - s = 1; - iValue = -iValue; - } - q = (prec >= 16) ? iValue : (iValue << (prec - 1)) / (F16MAX + 1); - if (s) - q = -q; - assert(q > -(1 << (prec - 1)) && q < (1 << (prec - 1))); - } - else - { - assert(iValue >= 0 && iValue <= F16MAX); - q = (prec >= 15) ? iValue : (iValue << prec) / (F16MAX + 1); - assert(q >= 0 && q < (1 << prec)); - } - - return q; -} - - -_Use_decl_annotations_ -int D3DX_BC6H::Unquantize(int comp, uint8_t uBitsPerComp, bool bSigned) noexcept -{ - int unq = 0, s = 0; - if (bSigned) - { - if (uBitsPerComp >= 16) - { - unq = comp; - } - else - { - if (comp < 0) - { - s = 1; - comp = -comp; - } - - if (comp == 0) unq = 0; - else if (comp >= ((1 << (uBitsPerComp - 1)) - 1)) unq = 0x7FFF; - else unq = ((comp << 15) + 0x4000) >> (uBitsPerComp - 1); - - if (s) unq = -unq; - } - } - else - { - if (uBitsPerComp >= 15) unq = comp; - else if (comp == 0) unq = 0; - else if (comp == ((1 << uBitsPerComp) - 1)) unq = 0xFFFF; - else unq = ((comp << 16) + 0x8000) >> uBitsPerComp; - } - - return unq; -} - - -_Use_decl_annotations_ -int D3DX_BC6H::FinishUnquantize(int comp, bool bSigned) noexcept -{ - if (bSigned) - { - return (comp < 0) ? -(((-comp) * 31) >> 5) : (comp * 31) >> 5; // scale the magnitude by 31/32 - } - else - { - return (comp * 31) >> 6; // scale the magnitude by 31/64 - } -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -bool D3DX_BC6H::EndPointsFit(const EncodeParams* pEP, const INTEndPntPair aEndPts[]) noexcept -{ - assert(pEP); - const bool bTransformed = ms_aInfo[pEP->uMode].bTransformed; - const bool bIsSigned = pEP->bSigned; - const LDRColorA& Prec0 = ms_aInfo[pEP->uMode].RGBAPrec[0][0]; - const LDRColorA& Prec1 = ms_aInfo[pEP->uMode].RGBAPrec[0][1]; - const LDRColorA& Prec2 = ms_aInfo[pEP->uMode].RGBAPrec[1][0]; - const LDRColorA& Prec3 = ms_aInfo[pEP->uMode].RGBAPrec[1][1]; - - INTColor aBits[4]; - aBits[0].r = NBits(aEndPts[0].A.r, bIsSigned); - aBits[0].g = NBits(aEndPts[0].A.g, bIsSigned); - aBits[0].b = NBits(aEndPts[0].A.b, bIsSigned); - aBits[1].r = NBits(aEndPts[0].B.r, bTransformed || bIsSigned); - aBits[1].g = NBits(aEndPts[0].B.g, bTransformed || bIsSigned); - aBits[1].b = NBits(aEndPts[0].B.b, bTransformed || bIsSigned); - if (aBits[0].r > Prec0.r || aBits[1].r > Prec1.r || - aBits[0].g > Prec0.g || aBits[1].g > Prec1.g || - aBits[0].b > Prec0.b || aBits[1].b > Prec1.b) - return false; - - if (ms_aInfo[pEP->uMode].uPartitions) - { - aBits[2].r = NBits(aEndPts[1].A.r, bTransformed || bIsSigned); - aBits[2].g = NBits(aEndPts[1].A.g, bTransformed || bIsSigned); - aBits[2].b = NBits(aEndPts[1].A.b, bTransformed || bIsSigned); - aBits[3].r = NBits(aEndPts[1].B.r, bTransformed || bIsSigned); - aBits[3].g = NBits(aEndPts[1].B.g, bTransformed || bIsSigned); - aBits[3].b = NBits(aEndPts[1].B.b, bTransformed || bIsSigned); - - if (aBits[2].r > Prec2.r || aBits[3].r > Prec3.r || - aBits[2].g > Prec2.g || aBits[3].g > Prec3.g || - aBits[2].b > Prec2.b || aBits[3].b > Prec3.b) - return false; - } - - return true; -} - - -_Use_decl_annotations_ -void D3DX_BC6H::GeneratePaletteQuantized(const EncodeParams* pEP, const INTEndPntPair& endPts, INTColor aPalette[]) const noexcept -{ - assert(pEP); - const size_t uIndexPrec = ms_aInfo[pEP->uMode].uIndexPrec; - const size_t uNumIndices = size_t(1) << uIndexPrec; - assert(uNumIndices > 0); - _Analysis_assume_(uNumIndices > 0); - const LDRColorA& Prec = ms_aInfo[pEP->uMode].RGBAPrec[0][0]; - - // scale endpoints - INTEndPntPair unqEndPts; - unqEndPts.A.r = Unquantize(endPts.A.r, Prec.r, pEP->bSigned); - unqEndPts.A.g = Unquantize(endPts.A.g, Prec.g, pEP->bSigned); - unqEndPts.A.b = Unquantize(endPts.A.b, Prec.b, pEP->bSigned); - unqEndPts.B.r = Unquantize(endPts.B.r, Prec.r, pEP->bSigned); - unqEndPts.B.g = Unquantize(endPts.B.g, Prec.g, pEP->bSigned); - unqEndPts.B.b = Unquantize(endPts.B.b, Prec.b, pEP->bSigned); - - // interpolate - const int* aWeights = nullptr; - switch (uIndexPrec) - { - case 3: aWeights = g_aWeights3; assert(uNumIndices <= 8); _Analysis_assume_(uNumIndices <= 8); break; - case 4: aWeights = g_aWeights4; assert(uNumIndices <= 16); _Analysis_assume_(uNumIndices <= 16); break; - default: - assert(false); - for (size_t i = 0; i < uNumIndices; ++i) - { - #pragma prefast(suppress:22102 22103, "writing blocks in two halves confuses tool") - aPalette[i] = INTColor(0, 0, 0); - } - return; - } - - for (size_t i = 0; i < uNumIndices; ++i) - { - aPalette[i].r = FinishUnquantize( - (unqEndPts.A.r * (BC67_WEIGHT_MAX - aWeights[i]) + unqEndPts.B.r * aWeights[i] + BC67_WEIGHT_ROUND) >> BC67_WEIGHT_SHIFT, - pEP->bSigned); - aPalette[i].g = FinishUnquantize( - (unqEndPts.A.g * (BC67_WEIGHT_MAX - aWeights[i]) + unqEndPts.B.g * aWeights[i] + BC67_WEIGHT_ROUND) >> BC67_WEIGHT_SHIFT, - pEP->bSigned); - aPalette[i].b = FinishUnquantize( - (unqEndPts.A.b * (BC67_WEIGHT_MAX - aWeights[i]) + unqEndPts.B.b * aWeights[i] + BC67_WEIGHT_ROUND) >> BC67_WEIGHT_SHIFT, - pEP->bSigned); - } -} - - -// given a collection of colors and quantized endpoints, generate a palette, choose best entries, and return a single toterr -_Use_decl_annotations_ -float D3DX_BC6H::MapColorsQuantized(const EncodeParams* pEP, const INTColor aColors[], size_t np, const INTEndPntPair &endPts) const noexcept -{ - assert(pEP); - - const uint8_t uIndexPrec = ms_aInfo[pEP->uMode].uIndexPrec; - auto const uNumIndices = static_cast(1u << uIndexPrec); - INTColor aPalette[BC6H_MAX_INDICES]; - GeneratePaletteQuantized(pEP, endPts, aPalette); - - float fTotErr = 0; - for (size_t i = 0; i < np; ++i) - { - const XMVECTOR vcolors = XMLoadSInt4(reinterpret_cast(&aColors[i])); - - // Compute ErrorMetricRGB - XMVECTOR tpal = XMLoadSInt4(reinterpret_cast(&aPalette[0])); - tpal = XMVectorSubtract(vcolors, tpal); - float fBestErr = XMVectorGetX(XMVector3Dot(tpal, tpal)); - - for (int j = 1; j < uNumIndices && fBestErr > 0; ++j) - { - // Compute ErrorMetricRGB - tpal = XMLoadSInt4(reinterpret_cast(&aPalette[j])); - tpal = XMVectorSubtract(vcolors, tpal); - const float fErr = XMVectorGetX(XMVector3Dot(tpal, tpal)); - if (fErr > fBestErr) break; // error increased, so we're done searching - if (fErr < fBestErr) fBestErr = fErr; - } - fTotErr += fBestErr; - } - return fTotErr; -} - - -_Use_decl_annotations_ -float D3DX_BC6H::PerturbOne(const EncodeParams* pEP, const INTColor aColors[], size_t np, uint8_t ch, - const INTEndPntPair& oldEndPts, INTEndPntPair& newEndPts, float fOldErr, int do_b) const noexcept -{ - assert(pEP); - uint8_t uPrec; - switch (ch) - { - case 0: uPrec = ms_aInfo[pEP->uMode].RGBAPrec[0][0].r; break; - case 1: uPrec = ms_aInfo[pEP->uMode].RGBAPrec[0][0].g; break; - case 2: uPrec = ms_aInfo[pEP->uMode].RGBAPrec[0][0].b; break; - default: assert(false); newEndPts = oldEndPts; return FLT_MAX; - } - INTEndPntPair tmpEndPts; - float fMinErr = fOldErr; - int beststep = 0; - - // copy real endpoints so we can perturb them - tmpEndPts = newEndPts = oldEndPts; - - // do a logarithmic search for the best error for this endpoint (which) - for (int step = 1 << (uPrec - 1); step; step >>= 1) - { - bool bImproved = false; - for (int sign = -1; sign <= 1; sign += 2) - { - if (do_b == 0) - { - tmpEndPts.A[ch] = newEndPts.A[ch] + sign * step; - if (tmpEndPts.A[ch] < 0 || tmpEndPts.A[ch] >= (1 << uPrec)) - continue; - } - else - { - tmpEndPts.B[ch] = newEndPts.B[ch] + sign * step; - if (tmpEndPts.B[ch] < 0 || tmpEndPts.B[ch] >= (1 << uPrec)) - continue; - } - - const float fErr = MapColorsQuantized(pEP, aColors, np, tmpEndPts); - - if (fErr < fMinErr) - { - bImproved = true; - fMinErr = fErr; - beststep = sign * step; - } - } - // if this was an improvement, move the endpoint and continue search from there - if (bImproved) - { - if (do_b == 0) - newEndPts.A[ch] += beststep; - else - newEndPts.B[ch] += beststep; - } - } - return fMinErr; -} - - -_Use_decl_annotations_ -void D3DX_BC6H::OptimizeOne(const EncodeParams* pEP, const INTColor aColors[], size_t np, float aOrgErr, - const INTEndPntPair &aOrgEndPts, INTEndPntPair &aOptEndPts) const noexcept -{ - assert(pEP); - float aOptErr = aOrgErr; - aOptEndPts.A = aOrgEndPts.A; - aOptEndPts.B = aOrgEndPts.B; - - INTEndPntPair new_a, new_b; - INTEndPntPair newEndPts; - int do_b; - - // now optimize each channel separately - for (uint8_t ch = 0; ch < BC6H_NUM_CHANNELS; ++ch) - { - // figure out which endpoint when perturbed gives the most improvement and start there - // if we just alternate, we can easily end up in a local minima - const float fErr0 = PerturbOne(pEP, aColors, np, ch, aOptEndPts, new_a, aOptErr, 0); // perturb endpt A - const float fErr1 = PerturbOne(pEP, aColors, np, ch, aOptEndPts, new_b, aOptErr, 1); // perturb endpt B - - if (fErr0 < fErr1) - { - if (fErr0 >= aOptErr) continue; - aOptEndPts.A[ch] = new_a.A[ch]; - aOptErr = fErr0; - do_b = 1; // do B next - } - else - { - if (fErr1 >= aOptErr) continue; - aOptEndPts.B[ch] = new_b.B[ch]; - aOptErr = fErr1; - do_b = 0; // do A next - } - - // now alternate endpoints and keep trying until there is no improvement - for (;;) - { - const float fErr = PerturbOne(pEP, aColors, np, ch, aOptEndPts, newEndPts, aOptErr, do_b); - if (fErr >= aOptErr) - break; - if (do_b == 0) - aOptEndPts.A[ch] = newEndPts.A[ch]; - else - aOptEndPts.B[ch] = newEndPts.B[ch]; - aOptErr = fErr; - do_b = 1 - do_b; // now move the other endpoint - } - } -} - - -_Use_decl_annotations_ -void D3DX_BC6H::OptimizeEndPoints(const EncodeParams* pEP, const float aOrgErr[], const INTEndPntPair aOrgEndPts[], INTEndPntPair aOptEndPts[]) const noexcept -{ - assert(pEP); - const uint8_t uPartitions = ms_aInfo[pEP->uMode].uPartitions; - assert(uPartitions < BC6H_MAX_REGIONS); - _Analysis_assume_(uPartitions < BC6H_MAX_REGIONS); - INTColor aPixels[NUM_PIXELS_PER_BLOCK]; - - for (size_t p = 0; p <= uPartitions; ++p) - { - // collect the pixels in the region - size_t np = 0; - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - { - if (g_aPartitionTable[p][pEP->uShape][i] == p) - { - aPixels[np++] = pEP->aIPixels[i]; - } - } - - OptimizeOne(pEP, aPixels, np, aOrgErr[p], aOrgEndPts[p], aOptEndPts[p]); - } -} - - -// Swap endpoints as needed to ensure that the indices at fix up have a 0 high-order bit -_Use_decl_annotations_ -void D3DX_BC6H::SwapIndices(const EncodeParams* pEP, INTEndPntPair aEndPts[], size_t aIndices[]) noexcept -{ - assert(pEP); - const size_t uPartitions = ms_aInfo[pEP->uMode].uPartitions; - const size_t uNumIndices = size_t(1) << ms_aInfo[pEP->uMode].uIndexPrec; - const size_t uHighIndexBit = uNumIndices >> 1; - - assert(uPartitions < BC6H_MAX_REGIONS && pEP->uShape < BC6H_MAX_SHAPES); - _Analysis_assume_(uPartitions < BC6H_MAX_REGIONS && pEP->uShape < BC6H_MAX_SHAPES); - - for (size_t p = 0; p <= uPartitions; ++p) - { - const size_t i = g_aFixUp[uPartitions][pEP->uShape][p]; - assert(g_aPartitionTable[uPartitions][pEP->uShape][i] == p); - if (aIndices[i] & uHighIndexBit) - { - // high bit is set, swap the aEndPts and indices for this region - std::swap(aEndPts[p].A, aEndPts[p].B); - - for (size_t j = 0; j < NUM_PIXELS_PER_BLOCK; ++j) - if (g_aPartitionTable[uPartitions][pEP->uShape][j] == p) - aIndices[j] = uNumIndices - 1 - aIndices[j]; - } - } -} - - -// assign indices given a tile, shape, and quantized endpoints, return toterr for each region -_Use_decl_annotations_ -void D3DX_BC6H::AssignIndices(const EncodeParams* pEP, const INTEndPntPair aEndPts[], size_t aIndices[], float aTotErr[]) const noexcept -{ - assert(pEP); - const uint8_t uPartitions = ms_aInfo[pEP->uMode].uPartitions; - auto const uNumIndices = static_cast(1u << ms_aInfo[pEP->uMode].uIndexPrec); - - assert(uPartitions < BC6H_MAX_REGIONS && pEP->uShape < BC6H_MAX_SHAPES); - _Analysis_assume_(uPartitions < BC6H_MAX_REGIONS && pEP->uShape < BC6H_MAX_SHAPES); - - // build list of possibles - INTColor aPalette[BC6H_MAX_REGIONS][BC6H_MAX_INDICES]; - - for (size_t p = 0; p <= uPartitions; ++p) - { - GeneratePaletteQuantized(pEP, aEndPts[p], aPalette[p]); - aTotErr[p] = 0; - } - - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - { - const uint8_t uRegion = g_aPartitionTable[uPartitions][pEP->uShape][i]; - assert(uRegion < BC6H_MAX_REGIONS); - _Analysis_assume_(uRegion < BC6H_MAX_REGIONS); - float fBestErr = Norm(pEP->aIPixels[i], aPalette[uRegion][0]); - aIndices[i] = 0; - - for (uint8_t j = 1; j < uNumIndices && fBestErr > 0; ++j) - { - const float fErr = Norm(pEP->aIPixels[i], aPalette[uRegion][j]); - if (fErr > fBestErr) break; // error increased, so we're done searching - if (fErr < fBestErr) - { - fBestErr = fErr; - aIndices[i] = j; - } - } - aTotErr[uRegion] += fBestErr; - } -} - - -_Use_decl_annotations_ -void D3DX_BC6H::QuantizeEndPts(const EncodeParams* pEP, INTEndPntPair* aQntEndPts) const noexcept -{ - assert(pEP && aQntEndPts); - const INTEndPntPair* aUnqEndPts = pEP->aUnqEndPts[pEP->uShape]; - const LDRColorA& Prec = ms_aInfo[pEP->uMode].RGBAPrec[0][0]; - const uint8_t uPartitions = ms_aInfo[pEP->uMode].uPartitions; - assert(uPartitions < BC6H_MAX_REGIONS); - _Analysis_assume_(uPartitions < BC6H_MAX_REGIONS); - - for (size_t p = 0; p <= uPartitions; ++p) - { - aQntEndPts[p].A.r = Quantize(aUnqEndPts[p].A.r, Prec.r, pEP->bSigned); - aQntEndPts[p].A.g = Quantize(aUnqEndPts[p].A.g, Prec.g, pEP->bSigned); - aQntEndPts[p].A.b = Quantize(aUnqEndPts[p].A.b, Prec.b, pEP->bSigned); - aQntEndPts[p].B.r = Quantize(aUnqEndPts[p].B.r, Prec.r, pEP->bSigned); - aQntEndPts[p].B.g = Quantize(aUnqEndPts[p].B.g, Prec.g, pEP->bSigned); - aQntEndPts[p].B.b = Quantize(aUnqEndPts[p].B.b, Prec.b, pEP->bSigned); - } -} - - -_Use_decl_annotations_ -void D3DX_BC6H::EmitBlock(const EncodeParams* pEP, const INTEndPntPair aEndPts[], const size_t aIndices[]) noexcept -{ - assert(pEP); - const uint8_t uRealMode = ms_aInfo[pEP->uMode].uMode; - const uint8_t uPartitions = ms_aInfo[pEP->uMode].uPartitions; - const uint8_t uIndexPrec = ms_aInfo[pEP->uMode].uIndexPrec; - const size_t uHeaderBits = uPartitions > 0 ? 82u : 65u; - const ModeDescriptor* desc = ms_aDesc[pEP->uMode]; - size_t uStartBit = 0; - - while (uStartBit < uHeaderBits) - { - switch (desc[uStartBit].m_eField) - { - case M: SetBit(uStartBit, uint8_t(uRealMode >> desc[uStartBit].m_uBit) & 0x01u); break; - case D: SetBit(uStartBit, uint8_t(pEP->uShape >> desc[uStartBit].m_uBit) & 0x01u); break; - case RW: SetBit(uStartBit, uint8_t(aEndPts[0].A.r >> desc[uStartBit].m_uBit) & 0x01u); break; - case RX: SetBit(uStartBit, uint8_t(aEndPts[0].B.r >> desc[uStartBit].m_uBit) & 0x01u); break; - case RY: SetBit(uStartBit, uint8_t(aEndPts[1].A.r >> desc[uStartBit].m_uBit) & 0x01u); break; - case RZ: SetBit(uStartBit, uint8_t(aEndPts[1].B.r >> desc[uStartBit].m_uBit) & 0x01u); break; - case GW: SetBit(uStartBit, uint8_t(aEndPts[0].A.g >> desc[uStartBit].m_uBit) & 0x01u); break; - case GX: SetBit(uStartBit, uint8_t(aEndPts[0].B.g >> desc[uStartBit].m_uBit) & 0x01u); break; - case GY: SetBit(uStartBit, uint8_t(aEndPts[1].A.g >> desc[uStartBit].m_uBit) & 0x01u); break; - case GZ: SetBit(uStartBit, uint8_t(aEndPts[1].B.g >> desc[uStartBit].m_uBit) & 0x01u); break; - case BW: SetBit(uStartBit, uint8_t(aEndPts[0].A.b >> desc[uStartBit].m_uBit) & 0x01u); break; - case BX: SetBit(uStartBit, uint8_t(aEndPts[0].B.b >> desc[uStartBit].m_uBit) & 0x01u); break; - case BY: SetBit(uStartBit, uint8_t(aEndPts[1].A.b >> desc[uStartBit].m_uBit) & 0x01u); break; - case BZ: SetBit(uStartBit, uint8_t(aEndPts[1].B.b >> desc[uStartBit].m_uBit) & 0x01u); break; - default: assert(false); - } - } - - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - { - if (IsFixUpOffset(ms_aInfo[pEP->uMode].uPartitions, pEP->uShape, i)) - SetBits(uStartBit, uIndexPrec - 1u, static_cast(aIndices[i])); - else - SetBits(uStartBit, uIndexPrec, static_cast(aIndices[i])); - } - assert(uStartBit == 128); -} - - -_Use_decl_annotations_ -void D3DX_BC6H::Refine(EncodeParams* pEP) noexcept -{ - assert(pEP); - const uint8_t uPartitions = ms_aInfo[pEP->uMode].uPartitions; - assert(uPartitions < BC6H_MAX_REGIONS); - _Analysis_assume_(uPartitions < BC6H_MAX_REGIONS); - - const bool bTransformed = ms_aInfo[pEP->uMode].bTransformed; - float aOrgErr[BC6H_MAX_REGIONS], aOptErr[BC6H_MAX_REGIONS]; - INTEndPntPair aOrgEndPts[BC6H_MAX_REGIONS], aOptEndPts[BC6H_MAX_REGIONS]; - size_t aOrgIdx[NUM_PIXELS_PER_BLOCK], aOptIdx[NUM_PIXELS_PER_BLOCK]; - - QuantizeEndPts(pEP, aOrgEndPts); - AssignIndices(pEP, aOrgEndPts, aOrgIdx, aOrgErr); - SwapIndices(pEP, aOrgEndPts, aOrgIdx); - - if (bTransformed) TransformForward(aOrgEndPts); - if (EndPointsFit(pEP, aOrgEndPts)) - { - if (bTransformed) TransformInverse(aOrgEndPts, ms_aInfo[pEP->uMode].RGBAPrec[0][0], pEP->bSigned); - OptimizeEndPoints(pEP, aOrgErr, aOrgEndPts, aOptEndPts); - AssignIndices(pEP, aOptEndPts, aOptIdx, aOptErr); - SwapIndices(pEP, aOptEndPts, aOptIdx); - - float fOrgTotErr = 0.0f, fOptTotErr = 0.0f; - for (size_t p = 0; p <= uPartitions; ++p) - { - fOrgTotErr += aOrgErr[p]; - fOptTotErr += aOptErr[p]; - } - - if (bTransformed) TransformForward(aOptEndPts); - if (EndPointsFit(pEP, aOptEndPts) && fOptTotErr < fOrgTotErr && fOptTotErr < pEP->fBestErr) - { - pEP->fBestErr = fOptTotErr; - EmitBlock(pEP, aOptEndPts, aOptIdx); - } - else if (fOrgTotErr < pEP->fBestErr) - { - // either it stopped fitting when we optimized it, or there was no improvement - // so go back to the unoptimized endpoints which we know will fit - if (bTransformed) TransformForward(aOrgEndPts); - pEP->fBestErr = fOrgTotErr; - EmitBlock(pEP, aOrgEndPts, aOrgIdx); - } - } -} - - -_Use_decl_annotations_ -void D3DX_BC6H::GeneratePaletteUnquantized(const EncodeParams* pEP, size_t uRegion, INTColor aPalette[]) noexcept -{ - assert(pEP); - assert(uRegion < BC6H_MAX_REGIONS && pEP->uShape < BC6H_MAX_SHAPES); - _Analysis_assume_(uRegion < BC6H_MAX_REGIONS && pEP->uShape < BC6H_MAX_SHAPES); - const INTEndPntPair& endPts = pEP->aUnqEndPts[pEP->uShape][uRegion]; - const uint8_t uIndexPrec = ms_aInfo[pEP->uMode].uIndexPrec; - auto const uNumIndices = static_cast(1u << uIndexPrec); - assert(uNumIndices > 0); - _Analysis_assume_(uNumIndices > 0); - - const int* aWeights = nullptr; - switch (uIndexPrec) - { - case 3: aWeights = g_aWeights3; assert(uNumIndices <= 8); _Analysis_assume_(uNumIndices <= 8); break; - case 4: aWeights = g_aWeights4; assert(uNumIndices <= 16); _Analysis_assume_(uNumIndices <= 16); break; - default: - assert(false); - for (size_t i = 0; i < uNumIndices; ++i) - { - #pragma prefast(suppress:22102 22103, "writing blocks in two halves confuses tool") - aPalette[i] = INTColor(0, 0, 0); - } - return; - } - - for (size_t i = 0; i < uNumIndices; ++i) - { - aPalette[i].r = (endPts.A.r * (BC67_WEIGHT_MAX - aWeights[i]) + endPts.B.r * aWeights[i] + BC67_WEIGHT_ROUND) >> BC67_WEIGHT_SHIFT; - aPalette[i].g = (endPts.A.g * (BC67_WEIGHT_MAX - aWeights[i]) + endPts.B.g * aWeights[i] + BC67_WEIGHT_ROUND) >> BC67_WEIGHT_SHIFT; - aPalette[i].b = (endPts.A.b * (BC67_WEIGHT_MAX - aWeights[i]) + endPts.B.b * aWeights[i] + BC67_WEIGHT_ROUND) >> BC67_WEIGHT_SHIFT; - } -} - - -_Use_decl_annotations_ -float D3DX_BC6H::MapColors(const EncodeParams* pEP, size_t uRegion, size_t np, const size_t* auIndex) const noexcept -{ - assert(pEP); - const uint8_t uIndexPrec = ms_aInfo[pEP->uMode].uIndexPrec; - auto const uNumIndices = static_cast(1u << uIndexPrec); - INTColor aPalette[BC6H_MAX_INDICES]; - GeneratePaletteUnquantized(pEP, uRegion, aPalette); - - float fTotalErr = 0.0f; - for (size_t i = 0; i < np; ++i) - { - float fBestErr = Norm(pEP->aIPixels[auIndex[i]], aPalette[0]); - for (uint8_t j = 1; j < uNumIndices && fBestErr > 0.0f; ++j) - { - const float fErr = Norm(pEP->aIPixels[auIndex[i]], aPalette[j]); - if (fErr > fBestErr) break; // error increased, so we're done searching - if (fErr < fBestErr) fBestErr = fErr; - } - fTotalErr += fBestErr; - } - - return fTotalErr; -} - -_Use_decl_annotations_ -float D3DX_BC6H::RoughMSE(EncodeParams* pEP) const noexcept -{ - assert(pEP); - assert(pEP->uShape < BC6H_MAX_SHAPES); - _Analysis_assume_(pEP->uShape < BC6H_MAX_SHAPES); - - INTEndPntPair* aEndPts = pEP->aUnqEndPts[pEP->uShape]; - - const uint8_t uPartitions = ms_aInfo[pEP->uMode].uPartitions; - assert(uPartitions < BC6H_MAX_REGIONS); - _Analysis_assume_(uPartitions < BC6H_MAX_REGIONS); - - size_t auPixIdx[NUM_PIXELS_PER_BLOCK]; - - float fError = 0.0f; - for (size_t p = 0; p <= uPartitions; ++p) - { - size_t np = 0; - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - { - if (g_aPartitionTable[uPartitions][pEP->uShape][i] == p) - { - auPixIdx[np++] = i; - } - } - - // handle simple cases - assert(np > 0); - if (np == 1) - { - aEndPts[p].A = pEP->aIPixels[auPixIdx[0]]; - aEndPts[p].B = pEP->aIPixels[auPixIdx[0]]; - continue; - } - else if (np == 2) - { - aEndPts[p].A = pEP->aIPixels[auPixIdx[0]]; - aEndPts[p].B = pEP->aIPixels[auPixIdx[1]]; - continue; - } - - HDRColorA epA, epB; - OptimizeRGB(pEP->aHDRPixels, &epA, &epB, 4, np, auPixIdx); - aEndPts[p].A.Set(epA, pEP->bSigned); - aEndPts[p].B.Set(epB, pEP->bSigned); - if (pEP->bSigned) - { - aEndPts[p].A.Clamp(-F16MAX, F16MAX); - aEndPts[p].B.Clamp(-F16MAX, F16MAX); - } - else - { - aEndPts[p].A.Clamp(0, F16MAX); - aEndPts[p].B.Clamp(0, F16MAX); - } - - fError += MapColors(pEP, p, np, auPixIdx); - } - - return fError; -} - - -//------------------------------------------------------------------------------------- -// BC7 Compression -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -void D3DX_BC7::Decode(HDRColorA* pOut) const noexcept -{ - assert(pOut); - - size_t uFirst = 0; - while (uFirst < 128 && !GetBit(uFirst)) {} - const uint8_t uMode = uint8_t(uFirst - 1); - - if (uMode < 8) - { - const uint8_t uPartitions = ms_aInfo[uMode].uPartitions; - assert(uPartitions < BC7_MAX_REGIONS); - _Analysis_assume_(uPartitions < BC7_MAX_REGIONS); - - auto const uNumEndPts = static_cast((unsigned(uPartitions) + 1u) << 1); - const uint8_t uIndexPrec = ms_aInfo[uMode].uIndexPrec; - const uint8_t uIndexPrec2 = ms_aInfo[uMode].uIndexPrec2; - size_t i; - size_t uStartBit = size_t(uMode) + 1; - uint8_t P[6]; - const uint8_t uShape = GetBits(uStartBit, ms_aInfo[uMode].uPartitionBits); - assert(uShape < BC7_MAX_SHAPES); - _Analysis_assume_(uShape < BC7_MAX_SHAPES); - - const uint8_t uRotation = GetBits(uStartBit, ms_aInfo[uMode].uRotationBits); - assert(uRotation < 4); - - const uint8_t uIndexMode = GetBits(uStartBit, ms_aInfo[uMode].uIndexModeBits); - assert(uIndexMode < 2); - - LDRColorA c[BC7_MAX_REGIONS << 1]; - const LDRColorA RGBAPrec = ms_aInfo[uMode].RGBAPrec; - const LDRColorA RGBAPrecWithP = ms_aInfo[uMode].RGBAPrecWithP; - - assert(uNumEndPts <= (BC7_MAX_REGIONS << 1)); - - // Red channel - for (i = 0; i < uNumEndPts; i++) - { - if (uStartBit + RGBAPrec.r > 128) - { - #ifdef _DEBUG - OutputDebugStringA("BC7: Invalid block encountered during decoding\n"); - #endif - FillWithErrorColors(pOut); - return; - } - - c[i].r = GetBits(uStartBit, RGBAPrec.r); - } - - // Green channel - for (i = 0; i < uNumEndPts; i++) - { - if (uStartBit + RGBAPrec.g > 128) - { - #ifdef _DEBUG - OutputDebugStringA("BC7: Invalid block encountered during decoding\n"); - #endif - FillWithErrorColors(pOut); - return; - } - - c[i].g = GetBits(uStartBit, RGBAPrec.g); - } - - // Blue channel - for (i = 0; i < uNumEndPts; i++) - { - if (uStartBit + RGBAPrec.b > 128) - { - #ifdef _DEBUG - OutputDebugStringA("BC7: Invalid block encountered during decoding\n"); - #endif - FillWithErrorColors(pOut); - return; - } - - c[i].b = GetBits(uStartBit, RGBAPrec.b); - } - - // Alpha channel - for (i = 0; i < uNumEndPts; i++) - { - if (uStartBit + RGBAPrec.a > 128) - { - #ifdef _DEBUG - OutputDebugStringA("BC7: Invalid block encountered during decoding\n"); - #endif - FillWithErrorColors(pOut); - return; - } - - c[i].a = RGBAPrec.a ? GetBits(uStartBit, RGBAPrec.a) : 255u; - } - - // P-bits - assert(ms_aInfo[uMode].uPBits <= 6); - _Analysis_assume_(ms_aInfo[uMode].uPBits <= 6); - for (i = 0; i < ms_aInfo[uMode].uPBits; i++) - { - if (uStartBit > 127) - { - #ifdef _DEBUG - OutputDebugStringA("BC7: Invalid block encountered during decoding\n"); - #endif - FillWithErrorColors(pOut); - return; - } - - P[i] = GetBit(uStartBit); - } - - if (ms_aInfo[uMode].uPBits) - { - for (i = 0; i < uNumEndPts; i++) - { - size_t pi = i * ms_aInfo[uMode].uPBits / uNumEndPts; - for (uint8_t ch = 0; ch < BC7_NUM_CHANNELS; ch++) - { - if (RGBAPrec[ch] != RGBAPrecWithP[ch]) - { - c[i][ch] = static_cast((unsigned(c[i][ch]) << 1) | P[pi]); - } - } - } - } - - for (i = 0; i < uNumEndPts; i++) - { - c[i] = Unquantize(c[i], RGBAPrecWithP); - } - - uint8_t w1[NUM_PIXELS_PER_BLOCK], w2[NUM_PIXELS_PER_BLOCK]; - - // read color indices - for (i = 0; i < NUM_PIXELS_PER_BLOCK; i++) - { - const size_t uNumBits = IsFixUpOffset(ms_aInfo[uMode].uPartitions, uShape, i) ? uIndexPrec - 1u : uIndexPrec; - if (uStartBit + uNumBits > 128) - { - #ifdef _DEBUG - OutputDebugStringA("BC7: Invalid block encountered during decoding\n"); - #endif - FillWithErrorColors(pOut); - return; - } - w1[i] = GetBits(uStartBit, uNumBits); - } - - // read alpha indices - if (uIndexPrec2) - { - for (i = 0; i < NUM_PIXELS_PER_BLOCK; i++) - { - const size_t uNumBits = i ? uIndexPrec2 : uIndexPrec2 - 1u; - if (uStartBit + uNumBits > 128) - { - #ifdef _DEBUG - OutputDebugStringA("BC7: Invalid block encountered during decoding\n"); - #endif - FillWithErrorColors(pOut); - return; - } - w2[i] = GetBits(uStartBit, uNumBits); - } - } - - for (i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - { - const uint8_t uRegion = g_aPartitionTable[uPartitions][uShape][i]; - LDRColorA outPixel; - if (uIndexPrec2 == 0) - { - LDRColorA::Interpolate(c[uRegion << 1], c[(uRegion << 1) + 1], w1[i], w1[i], uIndexPrec, uIndexPrec, outPixel); - } - else - { - if (uIndexMode == 0) - { - LDRColorA::Interpolate(c[uRegion << 1], c[(uRegion << 1) + 1], w1[i], w2[i], uIndexPrec, uIndexPrec2, outPixel); - } - else - { - LDRColorA::Interpolate(c[uRegion << 1], c[(uRegion << 1) + 1], w2[i], w1[i], uIndexPrec2, uIndexPrec, outPixel); - } - } - - switch (uRotation) - { - case 1: std::swap(outPixel.r, outPixel.a); break; - case 2: std::swap(outPixel.g, outPixel.a); break; - case 3: std::swap(outPixel.b, outPixel.a); break; - } - - pOut[i] = HDRColorA(outPixel); - } - } - else - { - #ifdef _DEBUG - OutputDebugStringA("BC7: Reserved mode 8 encountered during decoding\n"); - #endif - // Per the BC7 format spec, we must return transparent black - memset(pOut, 0, sizeof(HDRColorA) * NUM_PIXELS_PER_BLOCK); - } -} - -_Use_decl_annotations_ -void D3DX_BC7::Encode(uint32_t flags, const HDRColorA* const pIn) noexcept -{ - assert(pIn); - - D3DX_BC7 final = *this; - EncodeParams EP(pIn); - float fMSEBest = FLT_MAX; - uint32_t alphaMask = 0xFF; - - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - { - EP.aLDRPixels[i].r = uint8_t(std::max(0.0f, std::min(255.0f, pIn[i].r * 255.0f + 0.01f))); - EP.aLDRPixels[i].g = uint8_t(std::max(0.0f, std::min(255.0f, pIn[i].g * 255.0f + 0.01f))); - EP.aLDRPixels[i].b = uint8_t(std::max(0.0f, std::min(255.0f, pIn[i].b * 255.0f + 0.01f))); - EP.aLDRPixels[i].a = uint8_t(std::max(0.0f, std::min(255.0f, pIn[i].a * 255.0f + 0.01f))); - alphaMask &= EP.aLDRPixels[i].a; - } - - const bool bHasAlpha = (alphaMask != 0xFF); - - for (EP.uMode = 0; EP.uMode < 8 && fMSEBest > 0; ++EP.uMode) - { - if (!(flags & BC_FLAGS_USE_3SUBSETS) && (EP.uMode == 0 || EP.uMode == 2)) - { - // 3 subset modes tend to be used rarely and add significant compression time - continue; - } - - if ((flags & TEX_COMPRESS_BC7_QUICK) && (EP.uMode != 6)) - { - // Use only mode 6 - continue; - } - - if ((!bHasAlpha) && (EP.uMode == 7)) - { - // There is no value in using mode 7 for completely opaque blocks (the other 2 subset modes handle this case for opaque blocks), so skip it for a small perf win. - continue; - } - - const size_t uShapes = size_t(1) << ms_aInfo[EP.uMode].uPartitionBits; - assert(uShapes <= BC7_MAX_SHAPES); - _Analysis_assume_(uShapes <= BC7_MAX_SHAPES); - - const size_t uNumRots = size_t(1) << ms_aInfo[EP.uMode].uRotationBits; - const size_t uNumIdxMode = size_t(1) << ms_aInfo[EP.uMode].uIndexModeBits; - // Number of rough cases to look at. reasonable values of this are 1, uShapes/4, and uShapes - // uShapes/4 gets nearly all the cases; you can increase that a bit (say by 3 or 4) if you really want to squeeze the last bit out - const size_t uItems = std::max(1, uShapes >> 2); - float afRoughMSE[BC7_MAX_SHAPES]; - size_t auShape[BC7_MAX_SHAPES]; - - for (size_t r = 0; r < uNumRots && fMSEBest > 0; ++r) - { - switch (r) - { - case 1: for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) std::swap(EP.aLDRPixels[i].r, EP.aLDRPixels[i].a); break; - case 2: for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) std::swap(EP.aLDRPixels[i].g, EP.aLDRPixels[i].a); break; - case 3: for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) std::swap(EP.aLDRPixels[i].b, EP.aLDRPixels[i].a); break; - } - - for (size_t im = 0; im < uNumIdxMode && fMSEBest > 0; ++im) - { - // pick the best uItems shapes and refine these. - for (size_t s = 0; s < uShapes; s++) - { - afRoughMSE[s] = RoughMSE(&EP, s, im); - auShape[s] = s; - } - - // Bubble up the first uItems items - for (size_t i = 0; i < uItems; i++) - { - for (size_t j = i + 1; j < uShapes; j++) - { - if (afRoughMSE[i] > afRoughMSE[j]) - { - std::swap(afRoughMSE[i], afRoughMSE[j]); - std::swap(auShape[i], auShape[j]); - } - } - } - - for (size_t i = 0; i < uItems && fMSEBest > 0; i++) - { - const float fMSE = Refine(&EP, auShape[i], r, im); - if (fMSE < fMSEBest) - { - final = *this; - fMSEBest = fMSE; - } - } - } - - switch (r) - { - case 1: for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) std::swap(EP.aLDRPixels[i].r, EP.aLDRPixels[i].a); break; - case 2: for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) std::swap(EP.aLDRPixels[i].g, EP.aLDRPixels[i].a); break; - case 3: for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) std::swap(EP.aLDRPixels[i].b, EP.aLDRPixels[i].a); break; - } - } - } - - *this = final; -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -void D3DX_BC7::GeneratePaletteQuantized(const EncodeParams* pEP, size_t uIndexMode, const LDREndPntPair& endPts, LDRColorA aPalette[]) const noexcept -{ - assert(pEP); - const size_t uIndexPrec = uIndexMode ? ms_aInfo[pEP->uMode].uIndexPrec2 : ms_aInfo[pEP->uMode].uIndexPrec; - const size_t uIndexPrec2 = uIndexMode ? ms_aInfo[pEP->uMode].uIndexPrec : ms_aInfo[pEP->uMode].uIndexPrec2; - const size_t uNumIndices = size_t(1) << uIndexPrec; - const size_t uNumIndices2 = size_t(1) << uIndexPrec2; - assert(uNumIndices > 0 && uNumIndices2 > 0); - _Analysis_assume_(uNumIndices > 0 && uNumIndices2 > 0); - assert((uNumIndices <= BC7_MAX_INDICES) && (uNumIndices2 <= BC7_MAX_INDICES)); - _Analysis_assume_((uNumIndices <= BC7_MAX_INDICES) && (uNumIndices2 <= BC7_MAX_INDICES)); - - const LDRColorA a = Unquantize(endPts.A, ms_aInfo[pEP->uMode].RGBAPrecWithP); - const LDRColorA b = Unquantize(endPts.B, ms_aInfo[pEP->uMode].RGBAPrecWithP); - if (uIndexPrec2 == 0) - { - for (size_t i = 0; i < uNumIndices; i++) - LDRColorA::Interpolate(a, b, i, i, uIndexPrec, uIndexPrec, aPalette[i]); - } - else - { - for (size_t i = 0; i < uNumIndices; i++) - LDRColorA::InterpolateRGB(a, b, i, uIndexPrec, aPalette[i]); - for (size_t i = 0; i < uNumIndices2; i++) - LDRColorA::InterpolateA(a, b, i, uIndexPrec2, aPalette[i]); - } -} - -_Use_decl_annotations_ -float D3DX_BC7::PerturbOne(const EncodeParams* pEP, const LDRColorA aColors[], size_t np, size_t uIndexMode, size_t ch, - const LDREndPntPair &oldEndPts, LDREndPntPair &newEndPts, float fOldErr, uint8_t do_b) const noexcept -{ - assert(pEP); - const int prec = ms_aInfo[pEP->uMode].RGBAPrecWithP[ch]; - LDREndPntPair tmp_endPts = newEndPts = oldEndPts; - float fMinErr = fOldErr; - uint8_t* pnew_c = (do_b ? &newEndPts.B[ch] : &newEndPts.A[ch]); - uint8_t* ptmp_c = (do_b ? &tmp_endPts.B[ch] : &tmp_endPts.A[ch]); - - // do a logarithmic search for the best error for this endpoint (which) - for (int step = 1 << (prec - 1); step; step >>= 1) - { - bool bImproved = false; - int beststep = 0; - for (int sign = -1; sign <= 1; sign += 2) - { - int tmp = int(*pnew_c) + sign * step; - if (tmp < 0 || tmp >= (1 << prec)) - continue; - else - *ptmp_c = static_cast(tmp); - - const float fTotalErr = MapColors(pEP, aColors, np, uIndexMode, tmp_endPts, fMinErr); - if (fTotalErr < fMinErr) - { - bImproved = true; - fMinErr = fTotalErr; - beststep = sign * step; - } - } - - // if this was an improvement, move the endpoint and continue search from there - if (bImproved) - *pnew_c = uint8_t(int(*pnew_c) + beststep); - } - return fMinErr; -} - -// perturb the endpoints at least -3 to 3. -// always ensure endpoint ordering is preserved (no need to overlap the scan) -_Use_decl_annotations_ -void D3DX_BC7::Exhaustive(const EncodeParams* pEP, const LDRColorA aColors[], size_t np, size_t uIndexMode, size_t ch, - float& fOrgErr, LDREndPntPair& optEndPt) const noexcept -{ - assert(pEP); - const uint8_t uPrec = ms_aInfo[pEP->uMode].RGBAPrecWithP[ch]; - LDREndPntPair tmpEndPt; - if (fOrgErr == 0) - return; - - constexpr int delta = 5; - - // ok figure out the range of A and B - tmpEndPt = optEndPt; - const int alow = std::max(0, int(optEndPt.A[ch]) - delta); - const int ahigh = std::min((1 << uPrec) - 1, int(optEndPt.A[ch]) + delta); - const int blow = std::max(0, int(optEndPt.B[ch]) - delta); - const int bhigh = std::min((1 << uPrec) - 1, int(optEndPt.B[ch]) + delta); - int amin = 0; - int bmin = 0; - - float fBestErr = fOrgErr; - if (optEndPt.A[ch] <= optEndPt.B[ch]) - { - // keep a <= b - for (int a = alow; a <= ahigh; ++a) - { - for (int b = std::max(a, blow); b < bhigh; ++b) - { - tmpEndPt.A[ch] = static_cast(a); - tmpEndPt.B[ch] = static_cast(b); - - const float fErr = MapColors(pEP, aColors, np, uIndexMode, tmpEndPt, fBestErr); - if (fErr < fBestErr) - { - amin = a; - bmin = b; - fBestErr = fErr; - } - } - } - } - else - { - // keep b <= a - for (int b = blow; b < bhigh; ++b) - { - for (int a = std::max(b, alow); a <= ahigh; ++a) - { - tmpEndPt.A[ch] = static_cast(a); - tmpEndPt.B[ch] = static_cast(b); - - const float fErr = MapColors(pEP, aColors, np, uIndexMode, tmpEndPt, fBestErr); - if (fErr < fBestErr) - { - amin = a; - bmin = b; - fBestErr = fErr; - } - } - } - } - - if (fBestErr < fOrgErr) - { - optEndPt.A[ch] = static_cast(amin); - optEndPt.B[ch] = static_cast(bmin); - fOrgErr = fBestErr; - } -} - -_Use_decl_annotations_ -void D3DX_BC7::OptimizeOne(const EncodeParams* pEP, const LDRColorA aColors[], size_t np, size_t uIndexMode, - float fOrgErr, const LDREndPntPair& org, LDREndPntPair& opt) const noexcept -{ - assert(pEP); - - float fOptErr = fOrgErr; - opt = org; - - LDREndPntPair new_a, new_b; - LDREndPntPair newEndPts; - uint8_t do_b; - - // now optimize each channel separately - for (size_t ch = 0; ch < BC7_NUM_CHANNELS; ++ch) - { - if (ms_aInfo[pEP->uMode].RGBAPrecWithP[ch] == 0) - continue; - - // figure out which endpoint when perturbed gives the most improvement and start there - // if we just alternate, we can easily end up in a local minima - const float fErr0 = PerturbOne(pEP, aColors, np, uIndexMode, ch, opt, new_a, fOptErr, 0); // perturb endpt A - const float fErr1 = PerturbOne(pEP, aColors, np, uIndexMode, ch, opt, new_b, fOptErr, 1); // perturb endpt B - - uint8_t& copt_a = opt.A[ch]; - uint8_t& copt_b = opt.B[ch]; - uint8_t& cnew_a = new_a.A[ch]; - uint8_t& cnew_b = new_a.B[ch]; - - if (fErr0 < fErr1) - { - if (fErr0 >= fOptErr) - continue; - copt_a = cnew_a; - fOptErr = fErr0; - do_b = 1; // do B next - } - else - { - if (fErr1 >= fOptErr) - continue; - copt_b = cnew_b; - fOptErr = fErr1; - do_b = 0; // do A next - } - - // now alternate endpoints and keep trying until there is no improvement - for (; ; ) - { - const float fErr = PerturbOne(pEP, aColors, np, uIndexMode, ch, opt, newEndPts, fOptErr, do_b); - if (fErr >= fOptErr) - break; - if (do_b == 0) - copt_a = cnew_a; - else - copt_b = cnew_b; - fOptErr = fErr; - do_b = 1u - do_b; // now move the other endpoint - } - } - - // finally, do a small exhaustive search around what we think is the global minima to be sure - for (size_t ch = 0; ch < BC7_NUM_CHANNELS; ch++) - Exhaustive(pEP, aColors, np, uIndexMode, ch, fOptErr, opt); -} - -_Use_decl_annotations_ -void D3DX_BC7::OptimizeEndPoints(const EncodeParams* pEP, size_t uShape, size_t uIndexMode, const float afOrgErr[], - const LDREndPntPair aOrgEndPts[], LDREndPntPair aOptEndPts[]) const noexcept -{ - assert(pEP); - const uint8_t uPartitions = ms_aInfo[pEP->uMode].uPartitions; - assert(uPartitions < BC7_MAX_REGIONS && uShape < BC7_MAX_SHAPES); - _Analysis_assume_(uPartitions < BC7_MAX_REGIONS && uShape < BC7_MAX_SHAPES); - - LDRColorA aPixels[NUM_PIXELS_PER_BLOCK]; - - for (size_t p = 0; p <= uPartitions; ++p) - { - // collect the pixels in the region - size_t np = 0; - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - if (g_aPartitionTable[uPartitions][uShape][i] == p) - aPixels[np++] = pEP->aLDRPixels[i]; - - OptimizeOne(pEP, aPixels, np, uIndexMode, afOrgErr[p], aOrgEndPts[p], aOptEndPts[p]); - } -} - -_Use_decl_annotations_ -void D3DX_BC7::AssignIndices(const EncodeParams* pEP, size_t uShape, size_t uIndexMode, LDREndPntPair endPts[], size_t aIndices[], size_t aIndices2[], - float afTotErr[]) const noexcept -{ - assert(pEP); - assert(uShape < BC7_MAX_SHAPES); - _Analysis_assume_(uShape < BC7_MAX_SHAPES); - - const uint8_t uPartitions = ms_aInfo[pEP->uMode].uPartitions; - assert(uPartitions < BC7_MAX_REGIONS); - _Analysis_assume_(uPartitions < BC7_MAX_REGIONS); - - const uint8_t uIndexPrec = uIndexMode ? ms_aInfo[pEP->uMode].uIndexPrec2 : ms_aInfo[pEP->uMode].uIndexPrec; - const uint8_t uIndexPrec2 = uIndexMode ? ms_aInfo[pEP->uMode].uIndexPrec : ms_aInfo[pEP->uMode].uIndexPrec2; - auto const uNumIndices = static_cast(1u << uIndexPrec); - auto const uNumIndices2 = static_cast(1u << uIndexPrec2); - - assert((uNumIndices <= BC7_MAX_INDICES) && (uNumIndices2 <= BC7_MAX_INDICES)); - _Analysis_assume_((uNumIndices <= BC7_MAX_INDICES) && (uNumIndices2 <= BC7_MAX_INDICES)); - - const uint8_t uHighestIndexBit = uint8_t(uNumIndices >> 1); - const uint8_t uHighestIndexBit2 = uint8_t(uNumIndices2 >> 1); - LDRColorA aPalette[BC7_MAX_REGIONS][BC7_MAX_INDICES]; - - // build list of possibles - for (size_t p = 0; p <= uPartitions; p++) - { - GeneratePaletteQuantized(pEP, uIndexMode, endPts[p], aPalette[p]); - afTotErr[p] = 0; - } - - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) - { - uint8_t uRegion = g_aPartitionTable[uPartitions][uShape][i]; - assert(uRegion < BC7_MAX_REGIONS); - _Analysis_assume_(uRegion < BC7_MAX_REGIONS); - afTotErr[uRegion] += ComputeError(pEP->aLDRPixels[i], aPalette[uRegion], uIndexPrec, uIndexPrec2, &(aIndices[i]), &(aIndices2[i])); - } - - // swap endpoints as needed to ensure that the indices at index_positions have a 0 high-order bit - if (uIndexPrec2 == 0) - { - for (size_t p = 0; p <= uPartitions; p++) - { - if (aIndices[g_aFixUp[uPartitions][uShape][p]] & uHighestIndexBit) - { - std::swap(endPts[p].A, endPts[p].B); - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) - if (g_aPartitionTable[uPartitions][uShape][i] == p) - aIndices[i] = uNumIndices - 1 - aIndices[i]; - } - assert((aIndices[g_aFixUp[uPartitions][uShape][p]] & uHighestIndexBit) == 0); - } - } - else - { - for (size_t p = 0; p <= uPartitions; p++) - { - if (aIndices[g_aFixUp[uPartitions][uShape][p]] & uHighestIndexBit) - { - std::swap(endPts[p].A.r, endPts[p].B.r); - std::swap(endPts[p].A.g, endPts[p].B.g); - std::swap(endPts[p].A.b, endPts[p].B.b); - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) - if (g_aPartitionTable[uPartitions][uShape][i] == p) - aIndices[i] = uNumIndices - 1 - aIndices[i]; - } - assert((aIndices[g_aFixUp[uPartitions][uShape][p]] & uHighestIndexBit) == 0); - - if (aIndices2[0] & uHighestIndexBit2) - { - std::swap(endPts[p].A.a, endPts[p].B.a); - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) - aIndices2[i] = uNumIndices2 - 1 - aIndices2[i]; - } - assert((aIndices2[0] & uHighestIndexBit2) == 0); - } - } -} - -_Use_decl_annotations_ -void D3DX_BC7::EmitBlock(const EncodeParams* pEP, size_t uShape, size_t uRotation, size_t uIndexMode, const LDREndPntPair aEndPts[], const size_t aIndex[], const size_t aIndex2[]) noexcept -{ - assert(pEP); - const uint8_t uPartitions = ms_aInfo[pEP->uMode].uPartitions; - assert(uPartitions < BC7_MAX_REGIONS); - _Analysis_assume_(uPartitions < BC7_MAX_REGIONS); - - const size_t uPBits = ms_aInfo[pEP->uMode].uPBits; - const size_t uIndexPrec = ms_aInfo[pEP->uMode].uIndexPrec; - const size_t uIndexPrec2 = ms_aInfo[pEP->uMode].uIndexPrec2; - const LDRColorA RGBAPrec = ms_aInfo[pEP->uMode].RGBAPrec; - const LDRColorA RGBAPrecWithP = ms_aInfo[pEP->uMode].RGBAPrecWithP; - size_t i; - size_t uStartBit = 0; - SetBits(uStartBit, pEP->uMode, 0); - SetBits(uStartBit, 1, 1); - SetBits(uStartBit, ms_aInfo[pEP->uMode].uRotationBits, static_cast(uRotation)); - SetBits(uStartBit, ms_aInfo[pEP->uMode].uIndexModeBits, static_cast(uIndexMode)); - SetBits(uStartBit, ms_aInfo[pEP->uMode].uPartitionBits, static_cast(uShape)); - - if (uPBits) - { - const size_t uNumEP = (size_t(uPartitions) + 1) << 1; - uint8_t aPVote[BC7_MAX_REGIONS << 1] = { 0,0,0,0,0,0 }; - uint8_t aCount[BC7_MAX_REGIONS << 1] = { 0,0,0,0,0,0 }; - for (uint8_t ch = 0; ch < BC7_NUM_CHANNELS; ch++) - { - uint8_t ep = 0; - for (i = 0; i <= uPartitions; i++) - { - if (RGBAPrec[ch] == RGBAPrecWithP[ch]) - { - SetBits(uStartBit, RGBAPrec[ch], aEndPts[i].A[ch]); - SetBits(uStartBit, RGBAPrec[ch], aEndPts[i].B[ch]); - } - else - { - SetBits(uStartBit, RGBAPrec[ch], uint8_t(aEndPts[i].A[ch] >> 1)); - SetBits(uStartBit, RGBAPrec[ch], uint8_t(aEndPts[i].B[ch] >> 1)); - size_t idx = ep++ * uPBits / uNumEP; - assert(idx < (BC7_MAX_REGIONS << 1)); - _Analysis_assume_(idx < (BC7_MAX_REGIONS << 1)); - aPVote[idx] += aEndPts[i].A[ch] & 0x01; - aCount[idx]++; - idx = ep++ * uPBits / uNumEP; - assert(idx < (BC7_MAX_REGIONS << 1)); - _Analysis_assume_(idx < (BC7_MAX_REGIONS << 1)); - aPVote[idx] += aEndPts[i].B[ch] & 0x01; - aCount[idx]++; - } - } - } - - for (i = 0; i < uPBits; i++) - { - SetBits(uStartBit, 1, (aPVote[i] >(aCount[i] >> 1)) ? 1u : 0u); - } - } - else - { - for (size_t ch = 0; ch < BC7_NUM_CHANNELS; ch++) - { - for (i = 0; i <= uPartitions; i++) - { - SetBits(uStartBit, RGBAPrec[ch], aEndPts[i].A[ch]); - SetBits(uStartBit, RGBAPrec[ch], aEndPts[i].B[ch]); - } - } - } - - const size_t* aI1 = uIndexMode ? aIndex2 : aIndex; - const size_t* aI2 = uIndexMode ? aIndex : aIndex2; - for (i = 0; i < NUM_PIXELS_PER_BLOCK; i++) - { - if (IsFixUpOffset(ms_aInfo[pEP->uMode].uPartitions, uShape, i)) - SetBits(uStartBit, uIndexPrec - 1, static_cast(aI1[i])); - else - SetBits(uStartBit, uIndexPrec, static_cast(aI1[i])); - } - if (uIndexPrec2) - for (i = 0; i < NUM_PIXELS_PER_BLOCK; i++) - SetBits(uStartBit, i ? uIndexPrec2 : uIndexPrec2 - 1, static_cast(aI2[i])); - - assert(uStartBit == 128); -} - -_Use_decl_annotations_ -void D3DX_BC7::FixEndpointPBits(const EncodeParams* pEP, const LDREndPntPair *pOrigEndpoints, LDREndPntPair *pFixedEndpoints) noexcept -{ - assert(pEP); - const size_t uPartitions = ms_aInfo[pEP->uMode].uPartitions; - assert(uPartitions < BC7_MAX_REGIONS); - _Analysis_assume_(uPartitions < BC7_MAX_REGIONS); - - pFixedEndpoints[0] = pOrigEndpoints[0]; - pFixedEndpoints[1] = pOrigEndpoints[1]; - pFixedEndpoints[2] = pOrigEndpoints[2]; - - const size_t uPBits = ms_aInfo[pEP->uMode].uPBits; - - if (uPBits) - { - const size_t uNumEP = size_t(1 + uPartitions) << 1; - uint8_t aPVote[BC7_MAX_REGIONS << 1] = { 0,0,0,0,0,0 }; - uint8_t aCount[BC7_MAX_REGIONS << 1] = { 0,0,0,0,0,0 }; - - const LDRColorA RGBAPrec = ms_aInfo[pEP->uMode].RGBAPrec; - const LDRColorA RGBAPrecWithP = ms_aInfo[pEP->uMode].RGBAPrecWithP; - - for (uint8_t ch = 0; ch < BC7_NUM_CHANNELS; ch++) - { - uint8_t ep = 0; - for (size_t i = 0; i <= uPartitions; i++) - { - if (RGBAPrec[ch] == RGBAPrecWithP[ch]) - { - pFixedEndpoints[i].A[ch] = pOrigEndpoints[i].A[ch]; - pFixedEndpoints[i].B[ch] = pOrigEndpoints[i].B[ch]; - } - else - { - pFixedEndpoints[i].A[ch] = uint8_t(pOrigEndpoints[i].A[ch] >> 1); - pFixedEndpoints[i].B[ch] = uint8_t(pOrigEndpoints[i].B[ch] >> 1); - - size_t idx = ep++ * uPBits / uNumEP; - assert(idx < (BC7_MAX_REGIONS << 1)); - _Analysis_assume_(idx < (BC7_MAX_REGIONS << 1)); - aPVote[idx] += pOrigEndpoints[i].A[ch] & 0x01; - aCount[idx]++; - idx = ep++ * uPBits / uNumEP; - assert(idx < (BC7_MAX_REGIONS << 1)); - _Analysis_assume_(idx < (BC7_MAX_REGIONS << 1)); - aPVote[idx] += pOrigEndpoints[i].B[ch] & 0x01; - aCount[idx]++; - } - } - } - - // Compute the actual pbits we'll use when we encode block. Note this is not - // rounding the component indices correctly in cases the pbits != a component's LSB. - int pbits[BC7_MAX_REGIONS << 1]; - for (size_t i = 0; i < uPBits; i++) - pbits[i] = aPVote[i] >(aCount[i] >> 1) ? 1 : 0; - - // Now calculate the actual endpoints with proper pbits, so error calculations are accurate. - if (pEP->uMode == 1) - { - // shared pbits - for (uint8_t ch = 0; ch < BC7_NUM_CHANNELS; ch++) - { - for (size_t i = 0; i <= uPartitions; i++) - { - pFixedEndpoints[i].A[ch] = static_cast((pFixedEndpoints[i].A[ch] << 1) | pbits[i]); - pFixedEndpoints[i].B[ch] = static_cast((pFixedEndpoints[i].B[ch] << 1) | pbits[i]); - } - } - } - else - { - for (uint8_t ch = 0; ch < BC7_NUM_CHANNELS; ch++) - { - for (size_t i = 0; i <= uPartitions; i++) - { - pFixedEndpoints[i].A[ch] = static_cast((pFixedEndpoints[i].A[ch] << 1) | pbits[i * 2 + 0]); - pFixedEndpoints[i].B[ch] = static_cast((pFixedEndpoints[i].B[ch] << 1) | pbits[i * 2 + 1]); - } - } - } - } -} - -_Use_decl_annotations_ -float D3DX_BC7::Refine(const EncodeParams* pEP, size_t uShape, size_t uRotation, size_t uIndexMode) noexcept -{ - assert(pEP); - assert(uShape < BC7_MAX_SHAPES); - _Analysis_assume_(uShape < BC7_MAX_SHAPES); - - const size_t uPartitions = ms_aInfo[pEP->uMode].uPartitions; - assert(uPartitions < BC7_MAX_REGIONS); - _Analysis_assume_(uPartitions < BC7_MAX_REGIONS); - - LDREndPntPair aOrgEndPts[BC7_MAX_REGIONS]; - LDREndPntPair aOptEndPts[BC7_MAX_REGIONS]; - size_t aOrgIdx[NUM_PIXELS_PER_BLOCK]; - size_t aOrgIdx2[NUM_PIXELS_PER_BLOCK]; - size_t aOptIdx[NUM_PIXELS_PER_BLOCK]; - size_t aOptIdx2[NUM_PIXELS_PER_BLOCK]; - float aOrgErr[BC7_MAX_REGIONS]; - float aOptErr[BC7_MAX_REGIONS]; - - const LDREndPntPair* aEndPts = &pEP->aEndPts[uShape][0]; - - for (size_t p = 0; p <= uPartitions; p++) - { - aOrgEndPts[p].A = Quantize(aEndPts[p].A, ms_aInfo[pEP->uMode].RGBAPrecWithP); - aOrgEndPts[p].B = Quantize(aEndPts[p].B, ms_aInfo[pEP->uMode].RGBAPrecWithP); - } - - LDREndPntPair newEndPts1[BC7_MAX_REGIONS]; - FixEndpointPBits(pEP, aOrgEndPts, newEndPts1); - - AssignIndices(pEP, uShape, uIndexMode, newEndPts1, aOrgIdx, aOrgIdx2, aOrgErr); - - OptimizeEndPoints(pEP, uShape, uIndexMode, aOrgErr, newEndPts1, aOptEndPts); - - LDREndPntPair newEndPts2[BC7_MAX_REGIONS]; - FixEndpointPBits(pEP, aOptEndPts, newEndPts2); - - AssignIndices(pEP, uShape, uIndexMode, newEndPts2, aOptIdx, aOptIdx2, aOptErr); - - float fOrgTotErr = 0, fOptTotErr = 0; - for (size_t p = 0; p <= uPartitions; p++) - { - fOrgTotErr += aOrgErr[p]; - fOptTotErr += aOptErr[p]; - } - if (fOptTotErr < fOrgTotErr) - { - EmitBlock(pEP, uShape, uRotation, uIndexMode, newEndPts2, aOptIdx, aOptIdx2); - return fOptTotErr; - } - else - { - EmitBlock(pEP, uShape, uRotation, uIndexMode, newEndPts1, aOrgIdx, aOrgIdx2); - return fOrgTotErr; - } -} - -_Use_decl_annotations_ -float D3DX_BC7::MapColors(const EncodeParams* pEP, const LDRColorA aColors[], size_t np, size_t uIndexMode, const LDREndPntPair& endPts, float fMinErr) const noexcept -{ - assert(pEP); - const uint8_t uIndexPrec = uIndexMode ? ms_aInfo[pEP->uMode].uIndexPrec2 : ms_aInfo[pEP->uMode].uIndexPrec; - const uint8_t uIndexPrec2 = uIndexMode ? ms_aInfo[pEP->uMode].uIndexPrec : ms_aInfo[pEP->uMode].uIndexPrec2; - LDRColorA aPalette[BC7_MAX_INDICES]; - float fTotalErr = 0; - - GeneratePaletteQuantized(pEP, uIndexMode, endPts, aPalette); - for (size_t i = 0; i < np; ++i) - { - fTotalErr += ComputeError(aColors[i], aPalette, uIndexPrec, uIndexPrec2); - if (fTotalErr > fMinErr) // check for early exit - { - fTotalErr = FLT_MAX; - break; - } - } - - return fTotalErr; -} - -_Use_decl_annotations_ -float D3DX_BC7::RoughMSE(EncodeParams* pEP, size_t uShape, size_t uIndexMode) noexcept -{ - assert(pEP); - assert(uShape < BC7_MAX_SHAPES); - _Analysis_assume_(uShape < BC7_MAX_SHAPES); - LDREndPntPair* aEndPts = pEP->aEndPts[uShape]; - - const uint8_t uPartitions = ms_aInfo[pEP->uMode].uPartitions; - assert(uPartitions < BC7_MAX_REGIONS); - _Analysis_assume_(uPartitions < BC7_MAX_REGIONS); - - const uint8_t uIndexPrec = uIndexMode ? ms_aInfo[pEP->uMode].uIndexPrec2 : ms_aInfo[pEP->uMode].uIndexPrec; - const uint8_t uIndexPrec2 = uIndexMode ? ms_aInfo[pEP->uMode].uIndexPrec : ms_aInfo[pEP->uMode].uIndexPrec2; - auto const uNumIndices = static_cast(1u << uIndexPrec); - auto const uNumIndices2 = static_cast(1u << uIndexPrec2); - size_t auPixIdx[NUM_PIXELS_PER_BLOCK]; - LDRColorA aPalette[BC7_MAX_REGIONS][BC7_MAX_INDICES]; - - for (size_t p = 0; p <= uPartitions; p++) - { - size_t np = 0; - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) - { - if (g_aPartitionTable[uPartitions][uShape][i] == p) - { - auPixIdx[np++] = i; - } - } - - // handle simple cases - assert(np > 0); - if (np == 1) - { - aEndPts[p].A = pEP->aLDRPixels[auPixIdx[0]]; - aEndPts[p].B = pEP->aLDRPixels[auPixIdx[0]]; - continue; - } - else if (np == 2) - { - aEndPts[p].A = pEP->aLDRPixels[auPixIdx[0]]; - aEndPts[p].B = pEP->aLDRPixels[auPixIdx[1]]; - continue; - } - - if (uIndexPrec2 == 0) - { - HDRColorA epA, epB; - OptimizeRGBA(pEP->aHDRPixels, &epA, &epB, 4, np, auPixIdx); - epA.Clamp(0.0f, 1.0f); - epB.Clamp(0.0f, 1.0f); - epA *= 255.0f; - epB *= 255.0f; - aEndPts[p].A = epA.ToLDRColorA(); - aEndPts[p].B = epB.ToLDRColorA(); - } - else - { - uint8_t uMinAlpha = 255, uMaxAlpha = 0; - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; ++i) - { - uMinAlpha = std::min(uMinAlpha, pEP->aLDRPixels[auPixIdx[i]].a); - uMaxAlpha = std::max(uMaxAlpha, pEP->aLDRPixels[auPixIdx[i]].a); - } - - HDRColorA epA, epB; - OptimizeRGB(pEP->aHDRPixels, &epA, &epB, 4, np, auPixIdx); - epA.Clamp(0.0f, 1.0f); - epB.Clamp(0.0f, 1.0f); - epA *= 255.0f; - epB *= 255.0f; - aEndPts[p].A = epA.ToLDRColorA(); - aEndPts[p].B = epB.ToLDRColorA(); - aEndPts[p].A.a = uMinAlpha; - aEndPts[p].B.a = uMaxAlpha; - } - } - - if (uIndexPrec2 == 0) - { - for (size_t p = 0; p <= uPartitions; p++) - for (size_t i = 0; i < uNumIndices; i++) - LDRColorA::Interpolate(aEndPts[p].A, aEndPts[p].B, i, i, uIndexPrec, uIndexPrec, aPalette[p][i]); - } - else - { - for (size_t p = 0; p <= uPartitions; p++) - { - for (size_t i = 0; i < uNumIndices; i++) - LDRColorA::InterpolateRGB(aEndPts[p].A, aEndPts[p].B, i, uIndexPrec, aPalette[p][i]); - for (size_t i = 0; i < uNumIndices2; i++) - LDRColorA::InterpolateA(aEndPts[p].A, aEndPts[p].B, i, uIndexPrec2, aPalette[p][i]); - } - } - - float fTotalErr = 0; - for (size_t i = 0; i < NUM_PIXELS_PER_BLOCK; i++) - { - const uint8_t uRegion = g_aPartitionTable[uPartitions][uShape][i]; - fTotalErr += ComputeError(pEP->aLDRPixels[i], aPalette[uRegion], uIndexPrec, uIndexPrec2); - } - - return fTotalErr; -} - - -//===================================================================================== -// Entry points -//===================================================================================== - -//------------------------------------------------------------------------------------- -// BC6H Compression -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -void DirectX::D3DXDecodeBC6HU(XMVECTOR *pColor, const uint8_t *pBC) noexcept -{ - assert(pColor && pBC); - static_assert(sizeof(D3DX_BC6H) == 16, "D3DX_BC6H should be 16 bytes"); - reinterpret_cast(pBC)->Decode(false, reinterpret_cast(pColor)); -} - -_Use_decl_annotations_ -void DirectX::D3DXDecodeBC6HS(XMVECTOR *pColor, const uint8_t *pBC) noexcept -{ - assert(pColor && pBC); - static_assert(sizeof(D3DX_BC6H) == 16, "D3DX_BC6H should be 16 bytes"); - reinterpret_cast(pBC)->Decode(true, reinterpret_cast(pColor)); -} - -_Use_decl_annotations_ -void DirectX::D3DXEncodeBC6HU(uint8_t *pBC, const XMVECTOR *pColor, uint32_t flags) noexcept -{ - UNREFERENCED_PARAMETER(flags); - assert(pBC && pColor); - static_assert(sizeof(D3DX_BC6H) == 16, "D3DX_BC6H should be 16 bytes"); - reinterpret_cast(pBC)->Encode(false, reinterpret_cast(pColor)); -} - -_Use_decl_annotations_ -void DirectX::D3DXEncodeBC6HS(uint8_t *pBC, const XMVECTOR *pColor, uint32_t flags) noexcept -{ - UNREFERENCED_PARAMETER(flags); - assert(pBC && pColor); - static_assert(sizeof(D3DX_BC6H) == 16, "D3DX_BC6H should be 16 bytes"); - reinterpret_cast(pBC)->Encode(true, reinterpret_cast(pColor)); -} - - -//------------------------------------------------------------------------------------- -// BC7 Compression -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -void DirectX::D3DXDecodeBC7(XMVECTOR *pColor, const uint8_t *pBC) noexcept -{ - assert(pColor && pBC); - static_assert(sizeof(D3DX_BC7) == 16, "D3DX_BC7 should be 16 bytes"); - reinterpret_cast(pBC)->Decode(reinterpret_cast(pColor)); -} - -_Use_decl_annotations_ -void DirectX::D3DXEncodeBC7(uint8_t *pBC, const XMVECTOR *pColor, uint32_t flags) noexcept -{ - assert(pBC && pColor); - static_assert(sizeof(D3DX_BC7) == 16, "D3DX_BC7 should be 16 bytes"); - reinterpret_cast(pBC)->Encode(flags, reinterpret_cast(pColor)); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/BCDirectCompute.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/BCDirectCompute.cpp deleted file mode 100644 index a98ef8b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/BCDirectCompute.cpp +++ /dev/null @@ -1,616 +0,0 @@ -//------------------------------------------------------------------------------------- -// BCDirectCompute.cpp -// -// Direct3D 11 Compute Shader BC Compressor -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -//------------------------------------------------------------------------------------- - -#include "DirectXTexP.h" - -#include "BCDirectCompute.h" - -#if defined(_DEBUG) || defined(PROFILE) -#pragma comment(lib,"dxguid.lib") -#endif - -using namespace DirectX; -using Microsoft::WRL::ComPtr; - -namespace -{ -#include "BC7Encode_EncodeBlockCS.inc" -#include "BC7Encode_TryMode02CS.inc" -#include "BC7Encode_TryMode137CS.inc" -#include "BC7Encode_TryMode456CS.inc" -#include "BC6HEncode_EncodeBlockCS.inc" -#include "BC6HEncode_TryModeG10CS.inc" -#include "BC6HEncode_TryModeLE10CS.inc" - - struct BufferBC6HBC7 - { - UINT color[4]; - }; - - struct ConstantsBC6HBC7 - { - UINT tex_width; - UINT num_block_x; - UINT format; - UINT mode_id; - UINT start_block_id; - UINT num_total_blocks; - float alpha_weight; - UINT reserved; - }; - - static_assert(sizeof(ConstantsBC6HBC7) == sizeof(UINT) * 8, "Constant buffer size mismatch"); - - inline void RunComputeShader(ID3D11DeviceContext* pContext, - ID3D11ComputeShader* shader, - ID3D11ShaderResourceView** pSRVs, - UINT srvCount, - ID3D11Buffer* pCB, - ID3D11UnorderedAccessView* pUAV, - UINT X) - { - // Force UAV to nullptr before setting SRV since we are swapping buffers - ID3D11UnorderedAccessView* nullUAV = nullptr; - pContext->CSSetUnorderedAccessViews(0, 1, &nullUAV, nullptr); - - pContext->CSSetShader(shader, nullptr, 0); - pContext->CSSetShaderResources(0, srvCount, pSRVs); - pContext->CSSetUnorderedAccessViews(0, 1, &pUAV, nullptr); - pContext->CSSetConstantBuffers(0, 1, &pCB); - pContext->Dispatch(X, 1, 1); - } - - inline void ResetContext(ID3D11DeviceContext* pContext) - { - ID3D11UnorderedAccessView* nullUAV = nullptr; - pContext->CSSetUnorderedAccessViews(0, 1, &nullUAV, nullptr); - - ID3D11ShaderResourceView* nullSRV[3] = { nullptr, nullptr, nullptr }; - pContext->CSSetShaderResources(0, 3, nullSRV); - - ID3D11Buffer* nullBuffer[1] = { nullptr }; - pContext->CSSetConstantBuffers(0, 1, nullBuffer); - } -}; - -GPUCompressBC::GPUCompressBC() noexcept : - m_bcformat(DXGI_FORMAT_UNKNOWN), - m_srcformat(DXGI_FORMAT_UNKNOWN), - m_alphaWeight(1.f), - m_bc7_mode02(false), - m_bc7_mode137(false), - m_width(0), - m_height(0) -{ -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT GPUCompressBC::Initialize(ID3D11Device* pDevice) -{ - if (!pDevice) - return E_INVALIDARG; - - // Check for DirectCompute support - const D3D_FEATURE_LEVEL fl = pDevice->GetFeatureLevel(); - - if (fl < D3D_FEATURE_LEVEL_10_0) - { - // DirectCompute not supported on Feature Level 9.x hardware - return HRESULT_E_NOT_SUPPORTED; - } - - if (fl < D3D_FEATURE_LEVEL_11_0) - { - // DirectCompute support on Feature Level 10.x hardware is optional, and this function needs it - D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS hwopts; - HRESULT hr = pDevice->CheckFeatureSupport(D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS, &hwopts, sizeof(hwopts)); - if (FAILED(hr)) - { - memset(&hwopts, 0, sizeof(hwopts)); - } - - if (!hwopts.ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x) - { - return HRESULT_E_NOT_SUPPORTED; - } - } - - // Save a device reference and obtain immediate context - m_device = pDevice; - - pDevice->GetImmediateContext(m_context.ReleaseAndGetAddressOf()); - assert(m_context); - - //--- Create compute shader library: BC6H ----------------------------------------- - - // Modes 11-14 - HRESULT hr = pDevice->CreateComputeShader(BC6HEncode_TryModeG10CS, sizeof(BC6HEncode_TryModeG10CS), nullptr, m_BC6H_tryModeG10CS.ReleaseAndGetAddressOf()); - if (FAILED(hr)) - return hr; - - // Modes 1-10 - hr = pDevice->CreateComputeShader(BC6HEncode_TryModeLE10CS, sizeof(BC6HEncode_TryModeLE10CS), nullptr, m_BC6H_tryModeLE10CS.ReleaseAndGetAddressOf()); - if (FAILED(hr)) - return hr; - - // Encode - hr = pDevice->CreateComputeShader(BC6HEncode_EncodeBlockCS, sizeof(BC6HEncode_EncodeBlockCS), nullptr, m_BC6H_encodeBlockCS.ReleaseAndGetAddressOf()); - if (FAILED(hr)) - return hr; - - //--- Create compute shader library: BC7 ------------------------------------------ - - // Modes 4, 5, 6 - hr = pDevice->CreateComputeShader(BC7Encode_TryMode456CS, sizeof(BC7Encode_TryMode456CS), nullptr, m_BC7_tryMode456CS.ReleaseAndGetAddressOf()); - if (FAILED(hr)) - return hr; - - // Modes 1, 3, 7 - hr = pDevice->CreateComputeShader(BC7Encode_TryMode137CS, sizeof(BC7Encode_TryMode137CS), nullptr, m_BC7_tryMode137CS.ReleaseAndGetAddressOf()); - if (FAILED(hr)) - return hr; - - // Modes 0, 2 - hr = pDevice->CreateComputeShader(BC7Encode_TryMode02CS, sizeof(BC7Encode_TryMode02CS), nullptr, m_BC7_tryMode02CS.ReleaseAndGetAddressOf()); - if (FAILED(hr)) - return hr; - - // Encode - hr = pDevice->CreateComputeShader(BC7Encode_EncodeBlockCS, sizeof(BC7Encode_EncodeBlockCS), nullptr, m_BC7_encodeBlockCS.ReleaseAndGetAddressOf()); - if (FAILED(hr)) - return hr; - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -HRESULT GPUCompressBC::Prepare(size_t width, size_t height, uint32_t flags, DXGI_FORMAT format, float alphaWeight) -{ - if (!width || !height || alphaWeight < 0.f) - return E_INVALIDARG; - - if ((width > UINT32_MAX) || (height > UINT32_MAX)) - return E_INVALIDARG; - - m_width = width; - m_height = height; - - m_alphaWeight = alphaWeight; - - if (flags & TEX_COMPRESS_BC7_QUICK) - { - m_bc7_mode02 = false; - m_bc7_mode137 = false; - } - else - { - m_bc7_mode02 = (flags & TEX_COMPRESS_BC7_USE_3SUBSETS) != 0; - m_bc7_mode137 = true; - } - - const size_t xblocks = std::max(1, (width + 3) >> 2); - const size_t yblocks = std::max(1, (height + 3) >> 2); - const size_t num_blocks = xblocks * yblocks; - - switch (format) - { - // BC6H GPU compressor takes RGBAF32 as input - case DXGI_FORMAT_BC6H_TYPELESS: - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - m_srcformat = DXGI_FORMAT_R32G32B32A32_FLOAT; - break; - - // BC7 GPU compressor takes RGBA32 as input - case DXGI_FORMAT_BC7_TYPELESS: - case DXGI_FORMAT_BC7_UNORM: - m_srcformat = DXGI_FORMAT_R8G8B8A8_UNORM; - break; - - case DXGI_FORMAT_BC7_UNORM_SRGB: - m_srcformat = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB; - break; - - default: - m_bcformat = m_srcformat = DXGI_FORMAT_UNKNOWN; - return HRESULT_E_NOT_SUPPORTED; - } - - m_bcformat = format; - - auto pDevice = m_device.Get(); - if (!pDevice) - return E_POINTER; - - // Create structured buffers - const uint64_t sizeInBytes = uint64_t(num_blocks) * sizeof(BufferBC6HBC7); - if (sizeInBytes >= UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - auto const bufferSize = static_cast(sizeInBytes); - - { - D3D11_BUFFER_DESC desc = {}; - desc.BindFlags = D3D11_BIND_UNORDERED_ACCESS | D3D11_BIND_SHADER_RESOURCE; - desc.Usage = D3D11_USAGE_DEFAULT; - desc.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_STRUCTURED; - desc.StructureByteStride = sizeof(BufferBC6HBC7); - desc.ByteWidth = static_cast(bufferSize); - - HRESULT hr = pDevice->CreateBuffer(&desc, nullptr, m_output.ReleaseAndGetAddressOf()); - if (FAILED(hr)) - { - return hr; - } - - hr = pDevice->CreateBuffer(&desc, nullptr, m_err1.ReleaseAndGetAddressOf()); - if (FAILED(hr)) - { - return hr; - } - - hr = pDevice->CreateBuffer(&desc, nullptr, m_err2.ReleaseAndGetAddressOf()); - if (FAILED(hr)) - { - return hr; - } - } - - // Create staging output buffer - { - D3D11_BUFFER_DESC desc = {}; - desc.Usage = D3D11_USAGE_STAGING; - desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; - desc.ByteWidth = static_cast(bufferSize); - - HRESULT hr = pDevice->CreateBuffer(&desc, nullptr, m_outputCPU.ReleaseAndGetAddressOf()); - if (FAILED(hr)) - { - return hr; - } - } - - // Create constant buffer - { - D3D11_BUFFER_DESC desc = {}; - desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; - desc.Usage = D3D11_USAGE_DYNAMIC; - desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - desc.ByteWidth = sizeof(ConstantsBC6HBC7); - - HRESULT hr = pDevice->CreateBuffer(&desc, nullptr, m_constBuffer.ReleaseAndGetAddressOf()); - if (FAILED(hr)) - { - return hr; - } - } - - // Create shader resource views - { - D3D11_SHADER_RESOURCE_VIEW_DESC desc = {}; - desc.Buffer.NumElements = static_cast(num_blocks); - desc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER; - - HRESULT hr = pDevice->CreateShaderResourceView(m_err1.Get(), &desc, m_err1SRV.ReleaseAndGetAddressOf()); - if (FAILED(hr)) - { - return hr; - } - - hr = pDevice->CreateShaderResourceView(m_err2.Get(), &desc, m_err2SRV.ReleaseAndGetAddressOf()); - if (FAILED(hr)) - { - return hr; - } - } - - // Create unordered access views - { - D3D11_UNORDERED_ACCESS_VIEW_DESC desc = {}; - desc.Buffer.NumElements = static_cast(num_blocks); - desc.ViewDimension = D3D11_UAV_DIMENSION_BUFFER; - - HRESULT hr = pDevice->CreateUnorderedAccessView(m_output.Get(), &desc, m_outputUAV.ReleaseAndGetAddressOf()); - if (FAILED(hr)) - { - return hr; - } - - hr = pDevice->CreateUnorderedAccessView(m_err1.Get(), &desc, m_err1UAV.ReleaseAndGetAddressOf()); - if (FAILED(hr)) - { - return hr; - } - - hr = pDevice->CreateUnorderedAccessView(m_err2.Get(), &desc, m_err2UAV.ReleaseAndGetAddressOf()); - if (FAILED(hr)) - { - return hr; - } - } - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -HRESULT GPUCompressBC::Compress(const Image& srcImage, const Image& destImage) -{ - if (!srcImage.pixels || !destImage.pixels) - return E_INVALIDARG; - - if (srcImage.width != destImage.width - || srcImage.height != destImage.height - || srcImage.width != m_width - || srcImage.height != m_height - || srcImage.format != m_srcformat - || destImage.format != m_bcformat) - { - return E_UNEXPECTED; - } - - //--- Create input texture -------------------------------------------------------- - auto pDevice = m_device.Get(); - if (!pDevice) - return E_POINTER; - - // We need to avoid the hardware doing additional colorspace conversion - const DXGI_FORMAT inputFormat = (m_srcformat == DXGI_FORMAT_R8G8B8A8_UNORM_SRGB) ? DXGI_FORMAT_R8G8B8A8_UNORM : m_srcformat; - - ComPtr sourceTex; - { - D3D11_TEXTURE2D_DESC desc = {}; - desc.Width = static_cast(srcImage.width); - desc.Height = static_cast(srcImage.height); - desc.MipLevels = 1; - desc.ArraySize = 1; - desc.Format = inputFormat; - desc.SampleDesc.Count = 1; - desc.Usage = D3D11_USAGE_DEFAULT; - desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; - - D3D11_SUBRESOURCE_DATA initData; - initData.pSysMem = srcImage.pixels; - initData.SysMemPitch = static_cast(srcImage.rowPitch); - initData.SysMemSlicePitch = static_cast(srcImage.slicePitch); - - HRESULT hr = pDevice->CreateTexture2D(&desc, &initData, sourceTex.GetAddressOf()); - if (FAILED(hr)) - { - return hr; - } - } - - ComPtr sourceSRV; - { - D3D11_SHADER_RESOURCE_VIEW_DESC desc = {}; - desc.Texture2D.MipLevels = 1; - desc.Format = inputFormat; - desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; - - HRESULT hr = pDevice->CreateShaderResourceView(sourceTex.Get(), &desc, sourceSRV.GetAddressOf()); - if (FAILED(hr)) - { - return hr; - } - } - - //--- Compress using DirectCompute ------------------------------------------------ - bool isbc7 = false; - switch (m_bcformat) - { - case DXGI_FORMAT_BC6H_TYPELESS: - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - break; - - case DXGI_FORMAT_BC7_TYPELESS: - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: - isbc7 = true; - break; - - default: - return E_UNEXPECTED; - } - - constexpr UINT MAX_BLOCK_BATCH = 64u; - - auto pContext = m_context.Get(); - if (!pContext) - return E_UNEXPECTED; - - const size_t xblocks = std::max(1, (m_width + 3) >> 2); - const size_t yblocks = std::max(1, (m_height + 3) >> 2); - - auto const num_total_blocks = static_cast(xblocks * yblocks); - UINT num_blocks = num_total_blocks; - UINT start_block_id = 0; - while (num_blocks > 0) - { - const UINT n = std::min(num_blocks, MAX_BLOCK_BATCH); - const UINT uThreadGroupCount = n; - - { - D3D11_MAPPED_SUBRESOURCE mapped; - HRESULT hr = pContext->Map(m_constBuffer.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped); - if (FAILED(hr)) - return hr; - - ConstantsBC6HBC7 param; - param.tex_width = static_cast(srcImage.width); - param.num_block_x = static_cast(xblocks); - param.format = static_cast(m_bcformat); - param.mode_id = 0; - param.start_block_id = start_block_id; - param.num_total_blocks = num_total_blocks; - param.alpha_weight = m_alphaWeight; - memcpy(mapped.pData, ¶m, sizeof(param)); - - pContext->Unmap(m_constBuffer.Get(), 0); - } - - if (isbc7) - { - //--- BC7 ----------------------------------------------------------------- - ID3D11ShaderResourceView* pSRVs[] = { sourceSRV.Get(), nullptr }; - RunComputeShader(pContext, m_BC7_tryMode456CS.Get(), pSRVs, 2, m_constBuffer.Get(), - m_err1UAV.Get(), std::max((uThreadGroupCount + 3) / 4, 1)); - - if (m_bc7_mode137) - { - for (UINT i = 0; i < 3; ++i) - { - static const UINT modes[] = { 1, 3, 7 }; - - // Mode 1: err1 -> err2 - // Mode 3: err2 -> err1 - // Mode 7: err1 -> err2 - { - D3D11_MAPPED_SUBRESOURCE mapped; - HRESULT hr = pContext->Map(m_constBuffer.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped); - if (FAILED(hr)) - { - ResetContext(pContext); - return hr; - } - - ConstantsBC6HBC7 param; - param.tex_width = static_cast(srcImage.width); - param.num_block_x = static_cast(xblocks); - param.format = static_cast(m_bcformat); - param.mode_id = modes[i]; - param.start_block_id = start_block_id; - param.num_total_blocks = num_total_blocks; - param.alpha_weight = m_alphaWeight; - memcpy(mapped.pData, ¶m, sizeof(param)); - pContext->Unmap(m_constBuffer.Get(), 0); - } - - pSRVs[1] = (i & 1) ? m_err2SRV.Get() : m_err1SRV.Get(); - RunComputeShader(pContext, m_BC7_tryMode137CS.Get(), pSRVs, 2, m_constBuffer.Get(), - (i & 1) ? m_err1UAV.Get() : m_err2UAV.Get(), uThreadGroupCount); - } - } - - if (m_bc7_mode02) - { - // 3 subset modes tend to be used rarely and add significant compression time - for (UINT i = 0; i < 2; ++i) - { - static const UINT modes[] = { 0, 2 }; - // Mode 0: err2 -> err1 - // Mode 2: err1 -> err2 - { - D3D11_MAPPED_SUBRESOURCE mapped; - HRESULT hr = pContext->Map(m_constBuffer.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped); - if (FAILED(hr)) - { - ResetContext(pContext); - return hr; - } - - ConstantsBC6HBC7 param; - param.tex_width = static_cast(srcImage.width); - param.num_block_x = static_cast(xblocks); - param.format = static_cast(m_bcformat); - param.mode_id = modes[i]; - param.start_block_id = start_block_id; - param.num_total_blocks = num_total_blocks; - param.alpha_weight = m_alphaWeight; - memcpy(mapped.pData, ¶m, sizeof(param)); - pContext->Unmap(m_constBuffer.Get(), 0); - } - - pSRVs[1] = (i & 1) ? m_err1SRV.Get() : m_err2SRV.Get(); - RunComputeShader(pContext, m_BC7_tryMode02CS.Get(), pSRVs, 2, m_constBuffer.Get(), - (i & 1) ? m_err2UAV.Get() : m_err1UAV.Get(), uThreadGroupCount); - } - } - - pSRVs[1] = (m_bc7_mode02 || m_bc7_mode137) ? m_err2SRV.Get() : m_err1SRV.Get(); - RunComputeShader(pContext, m_BC7_encodeBlockCS.Get(), pSRVs, 2, m_constBuffer.Get(), - m_outputUAV.Get(), std::max((uThreadGroupCount + 3) / 4, 1)); - } - else - { - //--- BC6H ---------------------------------------------------------------- - ID3D11ShaderResourceView* pSRVs[] = { sourceSRV.Get(), nullptr }; - RunComputeShader(pContext, m_BC6H_tryModeG10CS.Get(), pSRVs, 2, m_constBuffer.Get(), - m_err1UAV.Get(), std::max((uThreadGroupCount + 3) / 4, 1)); - - for (UINT i = 0; i < 10; ++i) - { - { - D3D11_MAPPED_SUBRESOURCE mapped; - HRESULT hr = pContext->Map(m_constBuffer.Get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped); - if (FAILED(hr)) - { - ResetContext(pContext); - return hr; - } - - ConstantsBC6HBC7 param; - param.tex_width = static_cast(srcImage.width); - param.num_block_x = static_cast(xblocks); - param.format = static_cast(m_bcformat); - param.mode_id = i; - param.start_block_id = start_block_id; - param.num_total_blocks = num_total_blocks; - memcpy(mapped.pData, ¶m, sizeof(param)); - pContext->Unmap(m_constBuffer.Get(), 0); - } - - pSRVs[1] = (i & 1) ? m_err2SRV.Get() : m_err1SRV.Get(); - RunComputeShader(pContext, m_BC6H_tryModeLE10CS.Get(), pSRVs, 2, m_constBuffer.Get(), - (i & 1) ? m_err1UAV.Get() : m_err2UAV.Get(), std::max((uThreadGroupCount + 1) / 2, 1)); - } - - pSRVs[1] = m_err1SRV.Get(); - RunComputeShader(pContext, m_BC6H_encodeBlockCS.Get(), pSRVs, 2, m_constBuffer.Get(), - m_outputUAV.Get(), std::max((uThreadGroupCount + 1) / 2, 1)); - } - - start_block_id += n; - num_blocks -= n; - } - - ResetContext(pContext); - - //--- Copy output texture back to CPU --------------------------------------------- - - pContext->CopyResource(m_outputCPU.Get(), m_output.Get()); - - D3D11_MAPPED_SUBRESOURCE mapped; - HRESULT hr = pContext->Map(m_outputCPU.Get(), 0, D3D11_MAP_READ, 0, &mapped); - if (SUCCEEDED(hr)) - { - auto pSrc = static_cast(mapped.pData); - uint8_t *pDest = destImage.pixels; - - const size_t pitch = xblocks * sizeof(BufferBC6HBC7); - - const size_t rows = std::max(1, (destImage.height + 3) >> 2); - - for (size_t h = 0; h < rows; ++h) - { - memcpy(pDest, pSrc, destImage.rowPitch); - - pSrc += pitch; - pDest += destImage.rowPitch; - } - - pContext->Unmap(m_outputCPU.Get(), 0); - } - - return hr; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/BCDirectCompute.h b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/BCDirectCompute.h deleted file mode 100644 index 23f013c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/BCDirectCompute.h +++ /dev/null @@ -1,64 +0,0 @@ -//------------------------------------------------------------------------------------- -// BCDirectCompute.h -// -// Direct3D 11 Compute Shader BC Compressor -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -//------------------------------------------------------------------------------------- - -#pragma once - -namespace DirectX -{ - - class GPUCompressBC - { - public: - GPUCompressBC() noexcept; - - HRESULT Initialize(_In_ ID3D11Device* pDevice); - - HRESULT Prepare(size_t width, size_t height, uint32_t flags, DXGI_FORMAT format, float alphaWeight); - - HRESULT Compress(const Image& srcImage, const Image& destImage); - - DXGI_FORMAT GetSourceFormat() const noexcept { return m_srcformat; } - - private: - DXGI_FORMAT m_bcformat; - DXGI_FORMAT m_srcformat; - float m_alphaWeight; - bool m_bc7_mode02; - bool m_bc7_mode137; - size_t m_width; - size_t m_height; - - Microsoft::WRL::ComPtr m_device; - Microsoft::WRL::ComPtr m_context; - - Microsoft::WRL::ComPtr m_err1; - Microsoft::WRL::ComPtr m_err1UAV; - Microsoft::WRL::ComPtr m_err1SRV; - - Microsoft::WRL::ComPtr m_err2; - Microsoft::WRL::ComPtr m_err2UAV; - Microsoft::WRL::ComPtr m_err2SRV; - - Microsoft::WRL::ComPtr m_output; - Microsoft::WRL::ComPtr m_outputCPU; - Microsoft::WRL::ComPtr m_outputUAV; - Microsoft::WRL::ComPtr m_constBuffer; - - // Compute shader library - Microsoft::WRL::ComPtr m_BC6H_tryModeG10CS; - Microsoft::WRL::ComPtr m_BC6H_tryModeLE10CS; - Microsoft::WRL::ComPtr m_BC6H_encodeBlockCS; - - Microsoft::WRL::ComPtr m_BC7_tryMode456CS; - Microsoft::WRL::ComPtr m_BC7_tryMode137CS; - Microsoft::WRL::ComPtr m_BC7_tryMode02CS; - Microsoft::WRL::ComPtr m_BC7_encodeBlockCS; - }; - -} // namespace diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DDS.h b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DDS.h deleted file mode 100644 index a88f14a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DDS.h +++ /dev/null @@ -1,290 +0,0 @@ -//-------------------------------------------------------------------------------------- -// DDS.h -// -// This header defines constants and structures that are useful when parsing -// DDS files. DDS files were originally designed to use several structures -// and constants that are native to DirectDraw and are defined in ddraw.h, -// such as DDSURFACEDESC2 and DDSCAPS2. This file defines similar -// (compatible) constants and structures so that one can use DDS files -// without needing to include ddraw.h. -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -// http://go.microsoft.com/fwlink/?LinkId=248929 -// http://go.microsoft.com/fwlink/?LinkID=615561 -//-------------------------------------------------------------------------------------- - -#pragma once - -#include - -namespace DirectX -{ - -#pragma pack(push,1) - - constexpr uint32_t DDS_MAGIC = 0x20534444; // "DDS " - - struct DDS_PIXELFORMAT - { - uint32_t size; - uint32_t flags; - uint32_t fourCC; - uint32_t RGBBitCount; - uint32_t RBitMask; - uint32_t GBitMask; - uint32_t BBitMask; - uint32_t ABitMask; - }; - -#define DDS_FOURCC 0x00000004 // DDPF_FOURCC -#define DDS_RGB 0x00000040 // DDPF_RGB -#define DDS_RGBA 0x00000041 // DDPF_RGB | DDPF_ALPHAPIXELS -#define DDS_LUMINANCE 0x00020000 // DDPF_LUMINANCE -#define DDS_LUMINANCEA 0x00020001 // DDPF_LUMINANCE | DDPF_ALPHAPIXELS -#define DDS_ALPHAPIXELS 0x00000001 // DDPF_ALPHAPIXELS -#define DDS_ALPHA 0x00000002 // DDPF_ALPHA -#define DDS_PAL8 0x00000020 // DDPF_PALETTEINDEXED8 -#define DDS_PAL8A 0x00000021 // DDPF_PALETTEINDEXED8 | DDPF_ALPHAPIXELS -#define DDS_BUMPDUDV 0x00080000 // DDPF_BUMPDUDV -// DDS_BUMPLUMINANCE 0x00040000 - -#ifndef MAKEFOURCC -#define MAKEFOURCC(ch0, ch1, ch2, ch3) \ - (static_cast(static_cast(ch0)) \ - | (static_cast(static_cast(ch1)) << 8) \ - | (static_cast(static_cast(ch2)) << 16) \ - | (static_cast(static_cast(ch3)) << 24)) -#endif /* MAKEFOURCC */ - -#ifndef DDSGLOBALCONST -#if defined(__GNUC__) && !defined(__MINGW32__) -#define DDSGLOBALCONST extern const __attribute__((weak)) -#else -#define DDSGLOBALCONST extern const __declspec(selectany) -#endif -#endif /* DDSGLOBALCONST */ - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DXT1 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','1'), 0, 0, 0, 0, 0 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DXT2 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','2'), 0, 0, 0, 0, 0 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DXT3 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','3'), 0, 0, 0, 0, 0 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DXT4 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','4'), 0, 0, 0, 0, 0 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DXT5 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','5'), 0, 0, 0, 0, 0 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_BC4_UNORM = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','4','U'), 0, 0, 0, 0, 0 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_BC4_SNORM = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','4','S'), 0, 0, 0, 0, 0 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_BC5_UNORM = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','5','U'), 0, 0, 0, 0, 0 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_BC5_SNORM = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','5','S'), 0, 0, 0, 0, 0 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_R8G8_B8G8 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('R','G','B','G'), 0, 0, 0, 0, 0 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_G8R8_G8B8 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('G','R','G','B'), 0, 0, 0, 0, 0 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_YUY2 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('Y','U','Y','2'), 0, 0, 0, 0, 0 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_UYVY = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('U','Y','V','Y'), 0, 0, 0, 0, 0 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8R8G8B8 = - { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_X8R8G8B8 = - { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8B8G8R8 = - { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_X8B8G8R8 = - { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_G16R16 = - { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x0000ffff, 0xffff0000, 0, 0 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_R5G6B5 = - { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0xf800, 0x07e0, 0x001f, 0 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A1R5G5B5 = - { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x7c00, 0x03e0, 0x001f, 0x8000 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_X1R5G5B5 = - { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0x7c00, 0x03e0, 0x001f, 0 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A4R4G4B4 = - { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x0f00, 0x00f0, 0x000f, 0xf000 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_X4R4G4B4 = - { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0x0f00, 0x00f0, 0x000f, 0 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_R8G8B8 = - { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 24, 0xff0000, 0x00ff00, 0x0000ff, 0 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8R3G3B2 = - { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x00e0, 0x001c, 0x0003, 0xff00 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_R3G3B2 = - { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 8, 0xe0, 0x1c, 0x03, 0 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A4L4 = - { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCEA, 0, 8, 0x0f, 0, 0, 0xf0 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_L8 = - { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCE, 0, 8, 0xff, 0, 0, 0 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_L16 = - { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCE, 0, 16, 0xffff, 0, 0, 0 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8L8 = - { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCEA, 0, 16, 0x00ff, 0, 0, 0xff00 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8L8_ALT = - { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCEA, 0, 8, 0x00ff, 0, 0, 0xff00 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_L8_NVTT1 = - { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 8, 0xff, 0, 0, 0 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_L16_NVTT1 = - { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0xffff, 0, 0, 0 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8L8_NVTT1 = - { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x00ff, 0, 0, 0xff00 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A8 = - { sizeof(DDS_PIXELFORMAT), DDS_ALPHA, 0, 8, 0, 0, 0, 0xff }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_V8U8 = - { sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 16, 0x00ff, 0xff00, 0, 0 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_Q8W8V8U8 = - { sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 }; - - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_V16U16 = - { sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 32, 0x0000ffff, 0xffff0000, 0, 0 }; - -// D3DFMT_A2R10G10B10/D3DFMT_A2B10G10R10 should be written using DX10 extension to avoid D3DX 10:10:10:2 reversal issue - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A2R10G10B10 = - { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x000003ff, 0x000ffc00, 0x3ff00000, 0xc0000000 }; - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_A2B10G10R10 = - { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x3ff00000, 0x000ffc00, 0x000003ff, 0xc0000000 }; - -// We do not support the following legacy Direct3D 9 formats: -// DDSPF_A2W10V10U10 = { sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 32, 0x3ff00000, 0x000ffc00, 0x000003ff, 0xc0000000 }; -// DDSPF_L6V5U5 = { sizeof(DDS_PIXELFORMAT), DDS_BUMPLUMINANCE, 0, 16, 0x001f, 0x03e0, 0xfc00, 0 }; -// DDSPF_X8L8V8U8 = { sizeof(DDS_PIXELFORMAT), DDS_BUMPLUMINANCE, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0 }; - -// This indicates the DDS_HEADER_DXT10 extension is present (the format is in dxgiFormat) - DDSGLOBALCONST DDS_PIXELFORMAT DDSPF_DX10 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','1','0'), 0, 0, 0, 0, 0 }; - -#define DDS_HEADER_FLAGS_TEXTURE 0x00001007 // DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT -#define DDS_HEADER_FLAGS_MIPMAP 0x00020000 // DDSD_MIPMAPCOUNT -#define DDS_HEADER_FLAGS_VOLUME 0x00800000 // DDSD_DEPTH -#define DDS_HEADER_FLAGS_PITCH 0x00000008 // DDSD_PITCH -#define DDS_HEADER_FLAGS_LINEARSIZE 0x00080000 // DDSD_LINEARSIZE - -#define DDS_HEIGHT 0x00000002 // DDSD_HEIGHT -#define DDS_WIDTH 0x00000004 // DDSD_WIDTH - -#define DDS_SURFACE_FLAGS_TEXTURE 0x00001000 // DDSCAPS_TEXTURE -#define DDS_SURFACE_FLAGS_MIPMAP 0x00400008 // DDSCAPS_COMPLEX | DDSCAPS_MIPMAP -#define DDS_SURFACE_FLAGS_CUBEMAP 0x00000008 // DDSCAPS_COMPLEX - -#define DDS_CUBEMAP_POSITIVEX 0x00000600 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEX -#define DDS_CUBEMAP_NEGATIVEX 0x00000a00 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEX -#define DDS_CUBEMAP_POSITIVEY 0x00001200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEY -#define DDS_CUBEMAP_NEGATIVEY 0x00002200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEY -#define DDS_CUBEMAP_POSITIVEZ 0x00004200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEZ -#define DDS_CUBEMAP_NEGATIVEZ 0x00008200 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEZ - -#define DDS_CUBEMAP_ALLFACES ( DDS_CUBEMAP_POSITIVEX | DDS_CUBEMAP_NEGATIVEX |\ - DDS_CUBEMAP_POSITIVEY | DDS_CUBEMAP_NEGATIVEY |\ - DDS_CUBEMAP_POSITIVEZ | DDS_CUBEMAP_NEGATIVEZ ) - -#define DDS_CUBEMAP 0x00000200 // DDSCAPS2_CUBEMAP - -#define DDS_FLAGS_VOLUME 0x00200000 // DDSCAPS2_VOLUME - -// Subset here matches D3D10_RESOURCE_DIMENSION and D3D11_RESOURCE_DIMENSION - enum DDS_RESOURCE_DIMENSION : uint32_t - { - DDS_DIMENSION_TEXTURE1D = 2, - DDS_DIMENSION_TEXTURE2D = 3, - DDS_DIMENSION_TEXTURE3D = 4, - }; - - // Subset here matches D3D10_RESOURCE_MISC_FLAG and D3D11_RESOURCE_MISC_FLAG - enum DDS_RESOURCE_MISC_FLAG : uint32_t - { - DDS_RESOURCE_MISC_TEXTURECUBE = 0x4L, - }; - - enum DDS_MISC_FLAGS2 : uint32_t - { - DDS_MISC_FLAGS2_ALPHA_MODE_MASK = 0x7L, - }; - -#ifndef DDS_ALPHA_MODE_DEFINED -#define DDS_ALPHA_MODE_DEFINED - enum DDS_ALPHA_MODE : uint32_t - { - DDS_ALPHA_MODE_UNKNOWN = 0, - DDS_ALPHA_MODE_STRAIGHT = 1, - DDS_ALPHA_MODE_PREMULTIPLIED = 2, - DDS_ALPHA_MODE_OPAQUE = 3, - DDS_ALPHA_MODE_CUSTOM = 4, - }; -#endif - - struct DDS_HEADER - { - uint32_t size; - uint32_t flags; - uint32_t height; - uint32_t width; - uint32_t pitchOrLinearSize; - uint32_t depth; // only if DDS_HEADER_FLAGS_VOLUME is set in flags - uint32_t mipMapCount; - uint32_t reserved1[11]; - DDS_PIXELFORMAT ddspf; - uint32_t caps; - uint32_t caps2; - uint32_t caps3; - uint32_t caps4; - uint32_t reserved2; - }; - - struct DDS_HEADER_DXT10 - { - DXGI_FORMAT dxgiFormat; - uint32_t resourceDimension; - uint32_t miscFlag; // see D3D11_RESOURCE_MISC_FLAG - uint32_t arraySize; - uint32_t miscFlags2; // see DDS_MISC_FLAGS2 - }; - -#pragma pack(pop) - - static_assert(sizeof(DDS_HEADER) == 124, "DDS Header size mismatch"); - static_assert(sizeof(DDS_HEADER_DXT10) == 20, "DDS DX10 Extended Header size mismatch"); - -} // namespace diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex.h b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex.h deleted file mode 100644 index ba04068..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex.h +++ /dev/null @@ -1,928 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXTex.h -// -// DirectX Texture Library -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//------------------------------------------------------------------------------------- - -#pragma once - -#include -#include -#include -#include -#include - -#ifdef _WIN32 -#if !defined(__d3d11_h__) && !defined(__d3d11_x_h__) && !defined(__d3d12_h__) && !defined(__d3d12_x_h__) && !defined(__XBOX_D3D12_X__) -#ifdef _GAMING_XBOX_SCARLETT -#include -#elif defined(_GAMING_XBOX) -#include -#elif defined(_XBOX_ONE) && defined(_TITLE) -#include -#else -#include -#endif -#endif -#else // !WIN32 -#include -#include -#endif - -#include - -#ifdef _WIN32 -#if defined(NTDDI_WIN10_FE) || defined(__MINGW32__) -#include -#else -#include -#endif - -struct IWICImagingFactory; -struct IWICMetadataQueryReader; -#endif - -#define DIRECTX_TEX_VERSION 196 - - -namespace DirectX -{ - - //--------------------------------------------------------------------------------- - // DXGI Format Utilities - constexpr bool __cdecl IsValid(_In_ DXGI_FORMAT fmt) noexcept; - bool __cdecl IsCompressed(_In_ DXGI_FORMAT fmt) noexcept; - bool __cdecl IsPacked(_In_ DXGI_FORMAT fmt) noexcept; - bool __cdecl IsVideo(_In_ DXGI_FORMAT fmt) noexcept; - bool __cdecl IsPlanar(_In_ DXGI_FORMAT fmt) noexcept; - bool __cdecl IsPalettized(_In_ DXGI_FORMAT fmt) noexcept; - bool __cdecl IsDepthStencil(_In_ DXGI_FORMAT fmt) noexcept; - bool __cdecl IsSRGB(_In_ DXGI_FORMAT fmt) noexcept; - bool __cdecl IsBGR(_In_ DXGI_FORMAT fmt) noexcept; - bool __cdecl IsTypeless(_In_ DXGI_FORMAT fmt, _In_ bool partialTypeless = true) noexcept; - - bool __cdecl HasAlpha(_In_ DXGI_FORMAT fmt) noexcept; - - size_t __cdecl BitsPerPixel(_In_ DXGI_FORMAT fmt) noexcept; - - size_t __cdecl BitsPerColor(_In_ DXGI_FORMAT fmt) noexcept; - - enum FORMAT_TYPE - { - FORMAT_TYPE_TYPELESS, - FORMAT_TYPE_FLOAT, - FORMAT_TYPE_UNORM, - FORMAT_TYPE_SNORM, - FORMAT_TYPE_UINT, - FORMAT_TYPE_SINT, - }; - - FORMAT_TYPE __cdecl FormatDataType(_In_ DXGI_FORMAT fmt) noexcept; - - enum CP_FLAGS : unsigned long - { - CP_FLAGS_NONE = 0x0, - // Normal operation - - CP_FLAGS_LEGACY_DWORD = 0x1, - // Assume pitch is DWORD aligned instead of BYTE aligned - - CP_FLAGS_PARAGRAPH = 0x2, - // Assume pitch is 16-byte aligned instead of BYTE aligned - - CP_FLAGS_YMM = 0x4, - // Assume pitch is 32-byte aligned instead of BYTE aligned - - CP_FLAGS_ZMM = 0x8, - // Assume pitch is 64-byte aligned instead of BYTE aligned - - CP_FLAGS_PAGE4K = 0x200, - // Assume pitch is 4096-byte aligned instead of BYTE aligned - - CP_FLAGS_BAD_DXTN_TAILS = 0x1000, - // BC formats with malformed mipchain blocks smaller than 4x4 - - CP_FLAGS_24BPP = 0x10000, - // Override with a legacy 24 bits-per-pixel format size - - CP_FLAGS_16BPP = 0x20000, - // Override with a legacy 16 bits-per-pixel format size - - CP_FLAGS_8BPP = 0x40000, - // Override with a legacy 8 bits-per-pixel format size - }; - - HRESULT __cdecl ComputePitch( - _In_ DXGI_FORMAT fmt, _In_ size_t width, _In_ size_t height, - _Out_ size_t& rowPitch, _Out_ size_t& slicePitch, _In_ CP_FLAGS flags = CP_FLAGS_NONE) noexcept; - - size_t __cdecl ComputeScanlines(_In_ DXGI_FORMAT fmt, _In_ size_t height) noexcept; - - DXGI_FORMAT __cdecl MakeSRGB(_In_ DXGI_FORMAT fmt) noexcept; - DXGI_FORMAT __cdecl MakeTypeless(_In_ DXGI_FORMAT fmt) noexcept; - DXGI_FORMAT __cdecl MakeTypelessUNORM(_In_ DXGI_FORMAT fmt) noexcept; - DXGI_FORMAT __cdecl MakeTypelessFLOAT(_In_ DXGI_FORMAT fmt) noexcept; - - //--------------------------------------------------------------------------------- - // Texture metadata - enum TEX_DIMENSION - // Subset here matches D3D10_RESOURCE_DIMENSION and D3D11_RESOURCE_DIMENSION - { - TEX_DIMENSION_TEXTURE1D = 2, - TEX_DIMENSION_TEXTURE2D = 3, - TEX_DIMENSION_TEXTURE3D = 4, - }; - - enum TEX_MISC_FLAG : unsigned long - // Subset here matches D3D10_RESOURCE_MISC_FLAG and D3D11_RESOURCE_MISC_FLAG - { - TEX_MISC_TEXTURECUBE = 0x4L, - }; - - enum TEX_MISC_FLAG2 : unsigned long - { - TEX_MISC2_ALPHA_MODE_MASK = 0x7L, - }; - - enum TEX_ALPHA_MODE - // Matches DDS_ALPHA_MODE, encoded in MISC_FLAGS2 - { - TEX_ALPHA_MODE_UNKNOWN = 0, - TEX_ALPHA_MODE_STRAIGHT = 1, - TEX_ALPHA_MODE_PREMULTIPLIED = 2, - TEX_ALPHA_MODE_OPAQUE = 3, - TEX_ALPHA_MODE_CUSTOM = 4, - }; - - struct TexMetadata - { - size_t width; - size_t height; // Should be 1 for 1D textures - size_t depth; // Should be 1 for 1D or 2D textures - size_t arraySize; // For cubemap, this is a multiple of 6 - size_t mipLevels; - uint32_t miscFlags; - uint32_t miscFlags2; - DXGI_FORMAT format; - TEX_DIMENSION dimension; - - size_t __cdecl ComputeIndex(_In_ size_t mip, _In_ size_t item, _In_ size_t slice) const noexcept; - // Returns size_t(-1) to indicate an out-of-range error - - bool __cdecl IsCubemap() const noexcept { return (miscFlags & TEX_MISC_TEXTURECUBE) != 0; } - // Helper for miscFlags - - bool __cdecl IsPMAlpha() const noexcept { return ((miscFlags2 & TEX_MISC2_ALPHA_MODE_MASK) == TEX_ALPHA_MODE_PREMULTIPLIED) != 0; } - void __cdecl SetAlphaMode(TEX_ALPHA_MODE mode) noexcept { miscFlags2 = (miscFlags2 & ~static_cast(TEX_MISC2_ALPHA_MODE_MASK)) | static_cast(mode); } - TEX_ALPHA_MODE __cdecl GetAlphaMode() const noexcept { return static_cast(miscFlags2 & TEX_MISC2_ALPHA_MODE_MASK); } - // Helpers for miscFlags2 - - bool __cdecl IsVolumemap() const noexcept { return (dimension == TEX_DIMENSION_TEXTURE3D); } - // Helper for dimension - }; - - enum DDS_FLAGS : unsigned long - { - DDS_FLAGS_NONE = 0x0, - - DDS_FLAGS_LEGACY_DWORD = 0x1, - // Assume pitch is DWORD aligned instead of BYTE aligned (used by some legacy DDS files) - - DDS_FLAGS_NO_LEGACY_EXPANSION = 0x2, - // Do not implicitly convert legacy formats that result in larger pixel sizes (24 bpp, 3:3:2, A8L8, A4L4, P8, A8P8) - - DDS_FLAGS_NO_R10B10G10A2_FIXUP = 0x4, - // Do not use work-around for long-standing D3DX DDS file format issue which reversed the 10:10:10:2 color order masks - - DDS_FLAGS_FORCE_RGB = 0x8, - // Convert DXGI 1.1 BGR formats to DXGI_FORMAT_R8G8B8A8_UNORM to avoid use of optional WDDM 1.1 formats - - DDS_FLAGS_NO_16BPP = 0x10, - // Conversions avoid use of 565, 5551, and 4444 formats and instead expand to 8888 to avoid use of optional WDDM 1.2 formats - - DDS_FLAGS_EXPAND_LUMINANCE = 0x20, - // When loading legacy luminance formats expand replicating the color channels rather than leaving them packed (L8, L16, A8L8) - - DDS_FLAGS_BAD_DXTN_TAILS = 0x40, - // Some older DXTn DDS files incorrectly handle mipchain tails for blocks smaller than 4x4 - - DDS_FLAGS_FORCE_DX10_EXT = 0x10000, - // Always use the 'DX10' header extension for DDS writer (i.e. don't try to write DX9 compatible DDS files) - - DDS_FLAGS_FORCE_DX10_EXT_MISC2 = 0x20000, - // DDS_FLAGS_FORCE_DX10_EXT including miscFlags2 information (result may not be compatible with D3DX10 or D3DX11) - - DDS_FLAGS_FORCE_DX9_LEGACY = 0x40000, - // Force use of legacy header for DDS writer (will fail if unable to write as such) - - DDS_FLAGS_ALLOW_LARGE_FILES = 0x1000000, - // Enables the loader to read large dimension .dds files (i.e. greater than known hardware requirements) - }; - - enum TGA_FLAGS : unsigned long - { - TGA_FLAGS_NONE = 0x0, - - TGA_FLAGS_BGR = 0x1, - // 24bpp files are returned as BGRX; 32bpp files are returned as BGRA - - TGA_FLAGS_ALLOW_ALL_ZERO_ALPHA = 0x2, - // If the loaded image has an all zero alpha channel, normally we assume it should be opaque. This flag leaves it alone. - - TGA_FLAGS_IGNORE_SRGB = 0x10, - // Ignores sRGB TGA 2.0 metadata if present in the file - - TGA_FLAGS_FORCE_SRGB = 0x20, - // Writes sRGB metadata into the file reguardless of format (TGA 2.0 only) - - TGA_FLAGS_FORCE_LINEAR = 0x40, - // Writes linear gamma metadata into the file reguardless of format (TGA 2.0 only) - - TGA_FLAGS_DEFAULT_SRGB = 0x80, - // If no colorspace is specified in TGA 2.0 metadata, assume sRGB - }; - - enum WIC_FLAGS : unsigned long - { - WIC_FLAGS_NONE = 0x0, - - WIC_FLAGS_FORCE_RGB = 0x1, - // Loads DXGI 1.1 BGR formats as DXGI_FORMAT_R8G8B8A8_UNORM to avoid use of optional WDDM 1.1 formats - - WIC_FLAGS_NO_X2_BIAS = 0x2, - // Loads DXGI 1.1 X2 10:10:10:2 format as DXGI_FORMAT_R10G10B10A2_UNORM - - WIC_FLAGS_NO_16BPP = 0x4, - // Loads 565, 5551, and 4444 formats as 8888 to avoid use of optional WDDM 1.2 formats - - WIC_FLAGS_ALLOW_MONO = 0x8, - // Loads 1-bit monochrome (black & white) as R1_UNORM rather than 8-bit grayscale - - WIC_FLAGS_ALL_FRAMES = 0x10, - // Loads all images in a multi-frame file, converting/resizing to match the first frame as needed, defaults to 0th frame otherwise - - WIC_FLAGS_IGNORE_SRGB = 0x20, - // Ignores sRGB metadata if present in the file - - WIC_FLAGS_FORCE_SRGB = 0x40, - // Writes sRGB metadata into the file reguardless of format - - WIC_FLAGS_FORCE_LINEAR = 0x80, - // Writes linear gamma metadata into the file reguardless of format - - WIC_FLAGS_DEFAULT_SRGB = 0x100, - // If no colorspace is specified, assume sRGB - - WIC_FLAGS_DITHER = 0x10000, - // Use ordered 4x4 dithering for any required conversions - - WIC_FLAGS_DITHER_DIFFUSION = 0x20000, - // Use error-diffusion dithering for any required conversions - - WIC_FLAGS_FILTER_POINT = 0x100000, - WIC_FLAGS_FILTER_LINEAR = 0x200000, - WIC_FLAGS_FILTER_CUBIC = 0x300000, - WIC_FLAGS_FILTER_FANT = 0x400000, // Combination of Linear and Box filter - // Filtering mode to use for any required image resizing (only needed when loading arrays of differently sized images; defaults to Fant) - }; - - HRESULT __cdecl GetMetadataFromDDSMemory( - _In_reads_bytes_(size) const void* pSource, _In_ size_t size, - _In_ DDS_FLAGS flags, - _Out_ TexMetadata& metadata) noexcept; - HRESULT __cdecl GetMetadataFromDDSFile( - _In_z_ const wchar_t* szFile, - _In_ DDS_FLAGS flags, - _Out_ TexMetadata& metadata) noexcept; - - HRESULT __cdecl GetMetadataFromHDRMemory( - _In_reads_bytes_(size) const void* pSource, _In_ size_t size, - _Out_ TexMetadata& metadata) noexcept; - HRESULT __cdecl GetMetadataFromHDRFile( - _In_z_ const wchar_t* szFile, - _Out_ TexMetadata& metadata) noexcept; - - HRESULT __cdecl GetMetadataFromTGAMemory( - _In_reads_bytes_(size) const void* pSource, _In_ size_t size, - _In_ TGA_FLAGS flags, - _Out_ TexMetadata& metadata) noexcept; - HRESULT __cdecl GetMetadataFromTGAFile( - _In_z_ const wchar_t* szFile, - _In_ TGA_FLAGS flags, - _Out_ TexMetadata& metadata) noexcept; - -#ifdef _WIN32 - HRESULT __cdecl GetMetadataFromWICMemory( - _In_reads_bytes_(size) const void* pSource, _In_ size_t size, - _In_ WIC_FLAGS flags, - _Out_ TexMetadata& metadata, - _In_opt_ std::function getMQR = nullptr); - - HRESULT __cdecl GetMetadataFromWICFile( - _In_z_ const wchar_t* szFile, - _In_ WIC_FLAGS flags, - _Out_ TexMetadata& metadata, - _In_opt_ std::function getMQR = nullptr); -#endif - - // Compatability helpers - HRESULT __cdecl GetMetadataFromTGAMemory( - _In_reads_bytes_(size) const void* pSource, _In_ size_t size, - _Out_ TexMetadata& metadata) noexcept; - HRESULT __cdecl GetMetadataFromTGAFile( - _In_z_ const wchar_t* szFile, - _Out_ TexMetadata& metadata) noexcept; - - //--------------------------------------------------------------------------------- - // Bitmap image container - struct Image - { - size_t width; - size_t height; - DXGI_FORMAT format; - size_t rowPitch; - size_t slicePitch; - uint8_t* pixels; - }; - - class ScratchImage - { - public: - ScratchImage() noexcept - : m_nimages(0), m_size(0), m_metadata{}, m_image(nullptr), m_memory(nullptr) {} - ScratchImage(ScratchImage&& moveFrom) noexcept - : m_nimages(0), m_size(0), m_metadata{}, m_image(nullptr), m_memory(nullptr) { *this = std::move(moveFrom); } - ~ScratchImage() { Release(); } - - ScratchImage& __cdecl operator= (ScratchImage&& moveFrom) noexcept; - - ScratchImage(const ScratchImage&) = delete; - ScratchImage& operator=(const ScratchImage&) = delete; - - HRESULT __cdecl Initialize(_In_ const TexMetadata& mdata, _In_ CP_FLAGS flags = CP_FLAGS_NONE) noexcept; - - HRESULT __cdecl Initialize1D(_In_ DXGI_FORMAT fmt, _In_ size_t length, _In_ size_t arraySize, _In_ size_t mipLevels, _In_ CP_FLAGS flags = CP_FLAGS_NONE) noexcept; - HRESULT __cdecl Initialize2D(_In_ DXGI_FORMAT fmt, _In_ size_t width, _In_ size_t height, _In_ size_t arraySize, _In_ size_t mipLevels, _In_ CP_FLAGS flags = CP_FLAGS_NONE) noexcept; - HRESULT __cdecl Initialize3D(_In_ DXGI_FORMAT fmt, _In_ size_t width, _In_ size_t height, _In_ size_t depth, _In_ size_t mipLevels, _In_ CP_FLAGS flags = CP_FLAGS_NONE) noexcept; - HRESULT __cdecl InitializeCube(_In_ DXGI_FORMAT fmt, _In_ size_t width, _In_ size_t height, _In_ size_t nCubes, _In_ size_t mipLevels, _In_ CP_FLAGS flags = CP_FLAGS_NONE) noexcept; - - HRESULT __cdecl InitializeFromImage(_In_ const Image& srcImage, _In_ bool allow1D = false, _In_ CP_FLAGS flags = CP_FLAGS_NONE) noexcept; - HRESULT __cdecl InitializeArrayFromImages(_In_reads_(nImages) const Image* images, _In_ size_t nImages, _In_ bool allow1D = false, _In_ CP_FLAGS flags = CP_FLAGS_NONE) noexcept; - HRESULT __cdecl InitializeCubeFromImages(_In_reads_(nImages) const Image* images, _In_ size_t nImages, _In_ CP_FLAGS flags = CP_FLAGS_NONE) noexcept; - HRESULT __cdecl Initialize3DFromImages(_In_reads_(depth) const Image* images, _In_ size_t depth, _In_ CP_FLAGS flags = CP_FLAGS_NONE) noexcept; - - void __cdecl Release() noexcept; - - bool __cdecl OverrideFormat(_In_ DXGI_FORMAT f) noexcept; - - const TexMetadata& __cdecl GetMetadata() const noexcept { return m_metadata; } - const Image* __cdecl GetImage(_In_ size_t mip, _In_ size_t item, _In_ size_t slice) const noexcept; - - const Image* __cdecl GetImages() const noexcept { return m_image; } - size_t __cdecl GetImageCount() const noexcept { return m_nimages; } - - uint8_t* __cdecl GetPixels() const noexcept { return m_memory; } - size_t __cdecl GetPixelsSize() const noexcept { return m_size; } - - bool __cdecl IsAlphaAllOpaque() const noexcept; - - private: - size_t m_nimages; - size_t m_size; - TexMetadata m_metadata; - Image* m_image; - uint8_t* m_memory; - }; - - //--------------------------------------------------------------------------------- - // Memory blob (allocated buffer pointer is always 16-byte aligned) - class Blob - { - public: - Blob() noexcept : m_buffer(nullptr), m_size(0) {} - Blob(Blob&& moveFrom) noexcept : m_buffer(nullptr), m_size(0) { *this = std::move(moveFrom); } - ~Blob() { Release(); } - - Blob& __cdecl operator= (Blob&& moveFrom) noexcept; - - Blob(const Blob&) = delete; - Blob& operator=(const Blob&) = delete; - - HRESULT __cdecl Initialize(_In_ size_t size) noexcept; - - void __cdecl Release() noexcept; - - void *__cdecl GetBufferPointer() const noexcept { return m_buffer; } - size_t __cdecl GetBufferSize() const noexcept { return m_size; } - - HRESULT __cdecl Resize(size_t size) noexcept; - // Reallocate for a new size - - HRESULT __cdecl Trim(size_t size) noexcept; - // Shorten size without reallocation - - private: - void* m_buffer; - size_t m_size; - }; - - //--------------------------------------------------------------------------------- - // Image I/O - - // DDS operations - HRESULT __cdecl LoadFromDDSMemory( - _In_reads_bytes_(size) const void* pSource, _In_ size_t size, - _In_ DDS_FLAGS flags, - _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept; - HRESULT __cdecl LoadFromDDSFile( - _In_z_ const wchar_t* szFile, - _In_ DDS_FLAGS flags, - _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept; - - HRESULT __cdecl SaveToDDSMemory( - _In_ const Image& image, - _In_ DDS_FLAGS flags, - _Out_ Blob& blob) noexcept; - HRESULT __cdecl SaveToDDSMemory( - _In_reads_(nimages) const Image* images, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _In_ DDS_FLAGS flags, - _Out_ Blob& blob) noexcept; - - HRESULT __cdecl SaveToDDSFile(_In_ const Image& image, _In_ DDS_FLAGS flags, _In_z_ const wchar_t* szFile) noexcept; - HRESULT __cdecl SaveToDDSFile( - _In_reads_(nimages) const Image* images, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _In_ DDS_FLAGS flags, _In_z_ const wchar_t* szFile) noexcept; - - // HDR operations - HRESULT __cdecl LoadFromHDRMemory( - _In_reads_bytes_(size) const void* pSource, _In_ size_t size, - _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept; - HRESULT __cdecl LoadFromHDRFile( - _In_z_ const wchar_t* szFile, - _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept; - - HRESULT __cdecl SaveToHDRMemory(_In_ const Image& image, _Out_ Blob& blob) noexcept; - HRESULT __cdecl SaveToHDRFile(_In_ const Image& image, _In_z_ const wchar_t* szFile) noexcept; - - // TGA operations - HRESULT __cdecl LoadFromTGAMemory( - _In_reads_bytes_(size) const void* pSource, _In_ size_t size, - _In_ TGA_FLAGS flags, - _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept; - HRESULT __cdecl LoadFromTGAFile( - _In_z_ const wchar_t* szFile, - _In_ TGA_FLAGS flags, - _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept; - - HRESULT __cdecl SaveToTGAMemory(_In_ const Image& image, - _In_ TGA_FLAGS flags, - _Out_ Blob& blob, _In_opt_ const TexMetadata* metadata = nullptr) noexcept; - HRESULT __cdecl SaveToTGAFile(_In_ const Image& image, - _In_ TGA_FLAGS flags, - _In_z_ const wchar_t* szFile, _In_opt_ const TexMetadata* metadata = nullptr) noexcept; - - // WIC operations -#ifdef _WIN32 - HRESULT __cdecl LoadFromWICMemory( - _In_reads_bytes_(size) const void* pSource, _In_ size_t size, - _In_ WIC_FLAGS flags, - _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image, - _In_opt_ std::function getMQR = nullptr); - HRESULT __cdecl LoadFromWICFile( - _In_z_ const wchar_t* szFile, _In_ WIC_FLAGS flags, - _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image, - _In_opt_ std::function getMQR = nullptr); - - HRESULT __cdecl SaveToWICMemory( - _In_ const Image& image, _In_ WIC_FLAGS flags, _In_ REFGUID guidContainerFormat, - _Out_ Blob& blob, _In_opt_ const GUID* targetFormat = nullptr, - _In_opt_ std::function setCustomProps = nullptr); - HRESULT __cdecl SaveToWICMemory( - _In_count_(nimages) const Image* images, _In_ size_t nimages, - _In_ WIC_FLAGS flags, _In_ REFGUID guidContainerFormat, - _Out_ Blob& blob, _In_opt_ const GUID* targetFormat = nullptr, - _In_opt_ std::function setCustomProps = nullptr); - - HRESULT __cdecl SaveToWICFile( - _In_ const Image& image, _In_ WIC_FLAGS flags, _In_ REFGUID guidContainerFormat, - _In_z_ const wchar_t* szFile, _In_opt_ const GUID* targetFormat = nullptr, - _In_opt_ std::function setCustomProps = nullptr); - HRESULT __cdecl SaveToWICFile( - _In_count_(nimages) const Image* images, _In_ size_t nimages, - _In_ WIC_FLAGS flags, _In_ REFGUID guidContainerFormat, - _In_z_ const wchar_t* szFile, _In_opt_ const GUID* targetFormat = nullptr, - _In_opt_ std::function setCustomProps = nullptr); -#endif // WIN32 - - // Compatability helpers - HRESULT __cdecl LoadFromTGAMemory( - _In_reads_bytes_(size) const void* pSource, _In_ size_t size, - _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept; - HRESULT __cdecl LoadFromTGAFile( - _In_z_ const wchar_t* szFile, - _Out_opt_ TexMetadata* metadata, _Out_ ScratchImage& image) noexcept; - - HRESULT __cdecl SaveToTGAMemory(_In_ const Image& image, _Out_ Blob& blob, _In_opt_ const TexMetadata* metadata = nullptr) noexcept; - HRESULT __cdecl SaveToTGAFile(_In_ const Image& image, _In_z_ const wchar_t* szFile, _In_opt_ const TexMetadata* metadata = nullptr) noexcept; - - //--------------------------------------------------------------------------------- - // Texture conversion, resizing, mipmap generation, and block compression - - enum TEX_FR_FLAGS : unsigned long - { - TEX_FR_ROTATE0 = 0x0, - TEX_FR_ROTATE90 = 0x1, - TEX_FR_ROTATE180 = 0x2, - TEX_FR_ROTATE270 = 0x3, - TEX_FR_FLIP_HORIZONTAL = 0x08, - TEX_FR_FLIP_VERTICAL = 0x10, - }; - -#ifdef _WIN32 - HRESULT __cdecl FlipRotate(_In_ const Image& srcImage, _In_ TEX_FR_FLAGS flags, _Out_ ScratchImage& image) noexcept; - HRESULT __cdecl FlipRotate( - _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _In_ TEX_FR_FLAGS flags, _Out_ ScratchImage& result) noexcept; - // Flip and/or rotate image -#endif - - enum TEX_FILTER_FLAGS : unsigned long - { - TEX_FILTER_DEFAULT = 0, - - TEX_FILTER_WRAP_U = 0x1, - TEX_FILTER_WRAP_V = 0x2, - TEX_FILTER_WRAP_W = 0x4, - TEX_FILTER_WRAP = (TEX_FILTER_WRAP_U | TEX_FILTER_WRAP_V | TEX_FILTER_WRAP_W), - TEX_FILTER_MIRROR_U = 0x10, - TEX_FILTER_MIRROR_V = 0x20, - TEX_FILTER_MIRROR_W = 0x40, - TEX_FILTER_MIRROR = (TEX_FILTER_MIRROR_U | TEX_FILTER_MIRROR_V | TEX_FILTER_MIRROR_W), - // Wrap vs. Mirror vs. Clamp filtering options - - TEX_FILTER_SEPARATE_ALPHA = 0x100, - // Resize color and alpha channel independently - - TEX_FILTER_FLOAT_X2BIAS = 0x200, - // Enable *2 - 1 conversion cases for unorm<->float and positive-only float formats - - TEX_FILTER_RGB_COPY_RED = 0x1000, - TEX_FILTER_RGB_COPY_GREEN = 0x2000, - TEX_FILTER_RGB_COPY_BLUE = 0x4000, - // When converting RGB to R, defaults to using grayscale. These flags indicate copying a specific channel instead - // When converting RGB to RG, defaults to copying RED | GREEN. These flags control which channels are selected instead. - - TEX_FILTER_DITHER = 0x10000, - // Use ordered 4x4 dithering for any required conversions - TEX_FILTER_DITHER_DIFFUSION = 0x20000, - // Use error-diffusion dithering for any required conversions - - TEX_FILTER_POINT = 0x100000, - TEX_FILTER_LINEAR = 0x200000, - TEX_FILTER_CUBIC = 0x300000, - TEX_FILTER_BOX = 0x400000, - TEX_FILTER_FANT = 0x400000, // Equiv to Box filtering for mipmap generation - TEX_FILTER_TRIANGLE = 0x500000, - // Filtering mode to use for any required image resizing - - TEX_FILTER_SRGB_IN = 0x1000000, - TEX_FILTER_SRGB_OUT = 0x2000000, - TEX_FILTER_SRGB = (TEX_FILTER_SRGB_IN | TEX_FILTER_SRGB_OUT), - // sRGB <-> RGB for use in conversion operations - // if the input format type is IsSRGB(), then SRGB_IN is on by default - // if the output format type is IsSRGB(), then SRGB_OUT is on by default - - TEX_FILTER_FORCE_NON_WIC = 0x10000000, - // Forces use of the non-WIC path when both are an option - - TEX_FILTER_FORCE_WIC = 0x20000000, - // Forces use of the WIC path even when logic would have picked a non-WIC path when both are an option - }; - - constexpr unsigned long TEX_FILTER_DITHER_MASK = 0xF0000; - constexpr unsigned long TEX_FILTER_MODE_MASK = 0xF00000; - constexpr unsigned long TEX_FILTER_SRGB_MASK = 0xF000000; - - HRESULT __cdecl Resize( - _In_ const Image& srcImage, _In_ size_t width, _In_ size_t height, - _In_ TEX_FILTER_FLAGS filter, - _Out_ ScratchImage& image) noexcept; - HRESULT __cdecl Resize( - _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _In_ size_t width, _In_ size_t height, _In_ TEX_FILTER_FLAGS filter, _Out_ ScratchImage& result) noexcept; - // Resize the image to width x height. Defaults to Fant filtering. - // Note for a complex resize, the result will always have mipLevels == 1 - - constexpr float TEX_THRESHOLD_DEFAULT = 0.5f; - // Default value for alpha threshold used when converting to 1-bit alpha - - HRESULT __cdecl Convert( - _In_ const Image& srcImage, _In_ DXGI_FORMAT format, _In_ TEX_FILTER_FLAGS filter, _In_ float threshold, - _Out_ ScratchImage& image) noexcept; - HRESULT __cdecl Convert( - _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _In_ DXGI_FORMAT format, _In_ TEX_FILTER_FLAGS filter, _In_ float threshold, _Out_ ScratchImage& result) noexcept; - // Convert the image to a new format - - HRESULT __cdecl ConvertToSinglePlane(_In_ const Image& srcImage, _Out_ ScratchImage& image) noexcept; - HRESULT __cdecl ConvertToSinglePlane( - _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _Out_ ScratchImage& image) noexcept; - // Converts the image from a planar format to an equivalent non-planar format - - HRESULT __cdecl GenerateMipMaps( - _In_ const Image& baseImage, _In_ TEX_FILTER_FLAGS filter, _In_ size_t levels, - _Inout_ ScratchImage& mipChain, _In_ bool allow1D = false) noexcept; - HRESULT __cdecl GenerateMipMaps( - _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _In_ TEX_FILTER_FLAGS filter, _In_ size_t levels, _Inout_ ScratchImage& mipChain); - // levels of '0' indicates a full mipchain, otherwise is generates that number of total levels (including the source base image) - // Defaults to Fant filtering which is equivalent to a box filter - - HRESULT __cdecl GenerateMipMaps3D( - _In_reads_(depth) const Image* baseImages, _In_ size_t depth, _In_ TEX_FILTER_FLAGS filter, _In_ size_t levels, - _Out_ ScratchImage& mipChain) noexcept; - HRESULT __cdecl GenerateMipMaps3D( - _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _In_ TEX_FILTER_FLAGS filter, _In_ size_t levels, _Out_ ScratchImage& mipChain); - // levels of '0' indicates a full mipchain, otherwise is generates that number of total levels (including the source base image) - // Defaults to Fant filtering which is equivalent to a box filter - - HRESULT __cdecl ScaleMipMapsAlphaForCoverage( - _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, _In_ size_t item, - _In_ float alphaReference, _Inout_ ScratchImage& mipChain) noexcept; - - - enum TEX_PMALPHA_FLAGS : unsigned long - { - TEX_PMALPHA_DEFAULT = 0, - - TEX_PMALPHA_IGNORE_SRGB = 0x1, - // ignores sRGB colorspace conversions - - TEX_PMALPHA_REVERSE = 0x2, - // converts from premultiplied alpha back to straight alpha - - TEX_PMALPHA_SRGB_IN = 0x1000000, - TEX_PMALPHA_SRGB_OUT = 0x2000000, - TEX_PMALPHA_SRGB = (TEX_PMALPHA_SRGB_IN | TEX_PMALPHA_SRGB_OUT), - // if the input format type is IsSRGB(), then SRGB_IN is on by default - // if the output format type is IsSRGB(), then SRGB_OUT is on by default - }; - - HRESULT __cdecl PremultiplyAlpha(_In_ const Image& srcImage, _In_ TEX_PMALPHA_FLAGS flags, _Out_ ScratchImage& image) noexcept; - HRESULT __cdecl PremultiplyAlpha( - _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _In_ TEX_PMALPHA_FLAGS flags, _Out_ ScratchImage& result) noexcept; - // Converts to/from a premultiplied alpha version of the texture - - enum TEX_COMPRESS_FLAGS : unsigned long - { - TEX_COMPRESS_DEFAULT = 0, - - TEX_COMPRESS_RGB_DITHER = 0x10000, - // Enables dithering RGB colors for BC1-3 compression - - TEX_COMPRESS_A_DITHER = 0x20000, - // Enables dithering alpha for BC1-3 compression - - TEX_COMPRESS_DITHER = 0x30000, - // Enables both RGB and alpha dithering for BC1-3 compression - - TEX_COMPRESS_UNIFORM = 0x40000, - // Uniform color weighting for BC1-3 compression; by default uses perceptual weighting - - TEX_COMPRESS_BC7_USE_3SUBSETS = 0x80000, - // Enables exhaustive search for BC7 compress for mode 0 and 2; by default skips trying these modes - - TEX_COMPRESS_BC7_QUICK = 0x100000, - // Minimal modes (usually mode 6) for BC7 compression - - TEX_COMPRESS_SRGB_IN = 0x1000000, - TEX_COMPRESS_SRGB_OUT = 0x2000000, - TEX_COMPRESS_SRGB = (TEX_COMPRESS_SRGB_IN | TEX_COMPRESS_SRGB_OUT), - // if the input format type is IsSRGB(), then SRGB_IN is on by default - // if the output format type is IsSRGB(), then SRGB_OUT is on by default - - TEX_COMPRESS_PARALLEL = 0x10000000, - // Compress is free to use multithreading to improve performance (by default it does not use multithreading) - }; - - HRESULT __cdecl Compress( - _In_ const Image& srcImage, _In_ DXGI_FORMAT format, _In_ TEX_COMPRESS_FLAGS compress, _In_ float threshold, - _Out_ ScratchImage& cImage) noexcept; - HRESULT __cdecl Compress( - _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _In_ DXGI_FORMAT format, _In_ TEX_COMPRESS_FLAGS compress, _In_ float threshold, _Out_ ScratchImage& cImages) noexcept; - // Note that threshold is only used by BC1. TEX_THRESHOLD_DEFAULT is a typical value to use - -#if defined(__d3d11_h__) || defined(__d3d11_x_h__) - HRESULT __cdecl Compress( - _In_ ID3D11Device* pDevice, _In_ const Image& srcImage, _In_ DXGI_FORMAT format, _In_ TEX_COMPRESS_FLAGS compress, - _In_ float alphaWeight, _Out_ ScratchImage& image) noexcept; - HRESULT __cdecl Compress( - _In_ ID3D11Device* pDevice, _In_ const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _In_ DXGI_FORMAT format, _In_ TEX_COMPRESS_FLAGS compress, _In_ float alphaWeight, _Out_ ScratchImage& cImages) noexcept; - // DirectCompute-based compression (alphaWeight is only used by BC7. 1.0 is the typical value to use) -#endif - - HRESULT __cdecl Decompress(_In_ const Image& cImage, _In_ DXGI_FORMAT format, _Out_ ScratchImage& image) noexcept; - HRESULT __cdecl Decompress( - _In_reads_(nimages) const Image* cImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _In_ DXGI_FORMAT format, _Out_ ScratchImage& images) noexcept; - - //--------------------------------------------------------------------------------- - // Normal map operations - - enum CNMAP_FLAGS : unsigned long - { - CNMAP_DEFAULT = 0, - - CNMAP_CHANNEL_RED = 0x1, - CNMAP_CHANNEL_GREEN = 0x2, - CNMAP_CHANNEL_BLUE = 0x3, - CNMAP_CHANNEL_ALPHA = 0x4, - CNMAP_CHANNEL_LUMINANCE = 0x5, - // Channel selection when evaluting color value for height - // Luminance is a combination of red, green, and blue - - CNMAP_MIRROR_U = 0x1000, - CNMAP_MIRROR_V = 0x2000, - CNMAP_MIRROR = 0x3000, - // Use mirror semantics for scanline references (defaults to wrap) - - CNMAP_INVERT_SIGN = 0x4000, - // Inverts normal sign - - CNMAP_COMPUTE_OCCLUSION = 0x8000, - // Computes a crude occlusion term stored in the alpha channel - }; - - HRESULT __cdecl ComputeNormalMap( - _In_ const Image& srcImage, _In_ CNMAP_FLAGS flags, _In_ float amplitude, - _In_ DXGI_FORMAT format, _Out_ ScratchImage& normalMap) noexcept; - HRESULT __cdecl ComputeNormalMap( - _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _In_ CNMAP_FLAGS flags, _In_ float amplitude, _In_ DXGI_FORMAT format, _Out_ ScratchImage& normalMaps) noexcept; - - //--------------------------------------------------------------------------------- - // Misc image operations - - struct Rect - { - size_t x; - size_t y; - size_t w; - size_t h; - - Rect() = default; - Rect(size_t _x, size_t _y, size_t _w, size_t _h) noexcept : x(_x), y(_y), w(_w), h(_h) {} - }; - - HRESULT __cdecl CopyRectangle( - _In_ const Image& srcImage, _In_ const Rect& srcRect, _In_ const Image& dstImage, - _In_ TEX_FILTER_FLAGS filter, _In_ size_t xOffset, _In_ size_t yOffset) noexcept; - - enum CMSE_FLAGS : unsigned long - { - CMSE_DEFAULT = 0, - - CMSE_IMAGE1_SRGB = 0x1, - CMSE_IMAGE2_SRGB = 0x2, - // Indicates that image needs gamma correction before comparision - - CMSE_IGNORE_RED = 0x10, - CMSE_IGNORE_GREEN = 0x20, - CMSE_IGNORE_BLUE = 0x40, - CMSE_IGNORE_ALPHA = 0x80, - // Ignore the channel when computing MSE - - CMSE_IMAGE1_X2_BIAS = 0x100, - CMSE_IMAGE2_X2_BIAS = 0x200, - // Indicates that image should be scaled and biased before comparison (i.e. UNORM -> SNORM) - }; - - HRESULT __cdecl ComputeMSE(_In_ const Image& image1, _In_ const Image& image2, _Out_ float& mse, _Out_writes_opt_(4) float* mseV, _In_ CMSE_FLAGS flags = CMSE_DEFAULT) noexcept; - - HRESULT __cdecl EvaluateImage( - _In_ const Image& image, - _In_ std::function pixelFunc); - HRESULT __cdecl EvaluateImage( - _In_reads_(nimages) const Image* images, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _In_ std::function pixelFunc); - - HRESULT __cdecl TransformImage( - _In_ const Image& image, - _In_ std::function pixelFunc, - ScratchImage& result); - HRESULT __cdecl TransformImage( - _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _In_ std::function pixelFunc, - ScratchImage& result); - - //--------------------------------------------------------------------------------- - // WIC utility code -#ifdef _WIN32 - enum WICCodecs - { - WIC_CODEC_BMP = 1, // Windows Bitmap (.bmp) - WIC_CODEC_JPEG, // Joint Photographic Experts Group (.jpg, .jpeg) - WIC_CODEC_PNG, // Portable Network Graphics (.png) - WIC_CODEC_TIFF, // Tagged Image File Format (.tif, .tiff) - WIC_CODEC_GIF, // Graphics Interchange Format (.gif) - WIC_CODEC_WMP, // Windows Media Photo / HD Photo / JPEG XR (.hdp, .jxr, .wdp) - WIC_CODEC_ICO, // Windows Icon (.ico) - WIC_CODEC_HEIF, // High Efficiency Image File (.heif, .heic) - }; - - REFGUID __cdecl GetWICCodec(_In_ WICCodecs codec) noexcept; - - IWICImagingFactory* __cdecl GetWICFactory(bool& iswic2) noexcept; - void __cdecl SetWICFactory(_In_opt_ IWICImagingFactory* pWIC) noexcept; -#endif - - //--------------------------------------------------------------------------------- - // DDS helper functions - HRESULT __cdecl EncodeDDSHeader( - _In_ const TexMetadata& metadata, DDS_FLAGS flags, - _Out_writes_bytes_to_opt_(maxsize, required) void* pDestination, _In_ size_t maxsize, - _Out_ size_t& required) noexcept; - - //--------------------------------------------------------------------------------- - // Direct3D 11 functions -#if defined(__d3d11_h__) || defined(__d3d11_x_h__) - bool __cdecl IsSupportedTexture(_In_ ID3D11Device* pDevice, _In_ const TexMetadata& metadata) noexcept; - - HRESULT __cdecl CreateTexture( - _In_ ID3D11Device* pDevice, _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _Outptr_ ID3D11Resource** ppResource) noexcept; - - HRESULT __cdecl CreateShaderResourceView( - _In_ ID3D11Device* pDevice, _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _Outptr_ ID3D11ShaderResourceView** ppSRV) noexcept; - - HRESULT __cdecl CreateTextureEx( - _In_ ID3D11Device* pDevice, _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _In_ D3D11_USAGE usage, _In_ unsigned int bindFlags, _In_ unsigned int cpuAccessFlags, _In_ unsigned int miscFlags, _In_ bool forceSRGB, - _Outptr_ ID3D11Resource** ppResource) noexcept; - - HRESULT __cdecl CreateShaderResourceViewEx( - _In_ ID3D11Device* pDevice, _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _In_ D3D11_USAGE usage, _In_ unsigned int bindFlags, _In_ unsigned int cpuAccessFlags, _In_ unsigned int miscFlags, _In_ bool forceSRGB, - _Outptr_ ID3D11ShaderResourceView** ppSRV) noexcept; - - HRESULT __cdecl CaptureTexture(_In_ ID3D11Device* pDevice, _In_ ID3D11DeviceContext* pContext, _In_ ID3D11Resource* pSource, _Out_ ScratchImage& result) noexcept; -#endif - - //--------------------------------------------------------------------------------- - // Direct3D 12 functions -#if defined(__d3d12_h__) || defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__) - bool __cdecl IsSupportedTexture(_In_ ID3D12Device* pDevice, _In_ const TexMetadata& metadata) noexcept; - - HRESULT __cdecl CreateTexture( - _In_ ID3D12Device* pDevice, _In_ const TexMetadata& metadata, - _Outptr_ ID3D12Resource** ppResource) noexcept; - - HRESULT __cdecl CreateTextureEx( - _In_ ID3D12Device* pDevice, _In_ const TexMetadata& metadata, - _In_ D3D12_RESOURCE_FLAGS resFlags, _In_ bool forceSRGB, - _Outptr_ ID3D12Resource** ppResource) noexcept; - - HRESULT __cdecl PrepareUpload( - _In_ ID3D12Device* pDevice, - _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, - std::vector& subresources); - - HRESULT __cdecl CaptureTexture( - _In_ ID3D12CommandQueue* pCommandQueue, _In_ ID3D12Resource* pSource, _In_ bool isCubeMap, - _Out_ ScratchImage& result, - _In_ D3D12_RESOURCE_STATES beforeState = D3D12_RESOURCE_STATE_RENDER_TARGET, - _In_ D3D12_RESOURCE_STATES afterState = D3D12_RESOURCE_STATE_RENDER_TARGET) noexcept; -#endif - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wcovered-switch-default" -#pragma clang diagnostic ignored "-Wdeprecated-dynamic-exception-spec" -#pragma clang diagnostic ignored "-Wswitch-enum" -#endif - -#pragma warning(push) -#pragma warning(disable : 4619 4616 4061) - -#include "DirectXTex.inl" - -#pragma warning(pop) - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -} // namespace diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex.inl b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex.inl deleted file mode 100644 index 1ca81f9..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex.inl +++ /dev/null @@ -1,212 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXTex.inl -// -// DirectX Texture Library -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//------------------------------------------------------------------------------------- - -#pragma once - -//===================================================================================== -// Bitmask flags enumerator operators -//===================================================================================== -DEFINE_ENUM_FLAG_OPERATORS(CP_FLAGS); -DEFINE_ENUM_FLAG_OPERATORS(DDS_FLAGS); -DEFINE_ENUM_FLAG_OPERATORS(TGA_FLAGS); -DEFINE_ENUM_FLAG_OPERATORS(WIC_FLAGS); -DEFINE_ENUM_FLAG_OPERATORS(TEX_FR_FLAGS); -DEFINE_ENUM_FLAG_OPERATORS(TEX_FILTER_FLAGS); -DEFINE_ENUM_FLAG_OPERATORS(TEX_PMALPHA_FLAGS); -DEFINE_ENUM_FLAG_OPERATORS(TEX_COMPRESS_FLAGS); -DEFINE_ENUM_FLAG_OPERATORS(CNMAP_FLAGS); -DEFINE_ENUM_FLAG_OPERATORS(CMSE_FLAGS); - -// WIC_FILTER modes match TEX_FILTER modes -constexpr WIC_FLAGS operator|(WIC_FLAGS a, TEX_FILTER_FLAGS b) { return static_cast(static_cast(a) | static_cast(b & TEX_FILTER_MODE_MASK)); } -constexpr WIC_FLAGS operator|(TEX_FILTER_FLAGS a, WIC_FLAGS b) { return static_cast(static_cast(a & TEX_FILTER_MODE_MASK) | static_cast(b)); } - -// TEX_PMALPHA_SRGB match TEX_FILTER_SRGB -constexpr TEX_PMALPHA_FLAGS operator|(TEX_PMALPHA_FLAGS a, TEX_FILTER_FLAGS b) { return static_cast(static_cast(a) | static_cast(b & TEX_FILTER_SRGB_MASK)); } -constexpr TEX_PMALPHA_FLAGS operator|(TEX_FILTER_FLAGS a, TEX_PMALPHA_FLAGS b) { return static_cast(static_cast(a & TEX_FILTER_SRGB_MASK) | static_cast(b)); } - -// TEX_COMPRESS_SRGB match TEX_FILTER_SRGB -constexpr TEX_COMPRESS_FLAGS operator|(TEX_COMPRESS_FLAGS a, TEX_FILTER_FLAGS b) { return static_cast(static_cast(a) | static_cast(b & TEX_FILTER_SRGB_MASK)); } -constexpr TEX_COMPRESS_FLAGS operator|(TEX_FILTER_FLAGS a, TEX_COMPRESS_FLAGS b) { return static_cast(static_cast(a & TEX_FILTER_SRGB_MASK) | static_cast(b)); } - - -//===================================================================================== -// DXGI Format Utilities -//===================================================================================== - -_Use_decl_annotations_ -constexpr bool __cdecl IsValid(DXGI_FORMAT fmt) noexcept -{ - return (static_cast(fmt) >= 1 && static_cast(fmt) <= 190); -} - -_Use_decl_annotations_ -inline bool __cdecl IsCompressed(DXGI_FORMAT fmt) noexcept -{ - switch (fmt) - { - case DXGI_FORMAT_BC1_TYPELESS: - case DXGI_FORMAT_BC1_UNORM: - case DXGI_FORMAT_BC1_UNORM_SRGB: - case DXGI_FORMAT_BC2_TYPELESS: - case DXGI_FORMAT_BC2_UNORM: - case DXGI_FORMAT_BC2_UNORM_SRGB: - case DXGI_FORMAT_BC3_TYPELESS: - case DXGI_FORMAT_BC3_UNORM: - case DXGI_FORMAT_BC3_UNORM_SRGB: - case DXGI_FORMAT_BC4_TYPELESS: - case DXGI_FORMAT_BC4_UNORM: - case DXGI_FORMAT_BC4_SNORM: - case DXGI_FORMAT_BC5_TYPELESS: - case DXGI_FORMAT_BC5_UNORM: - case DXGI_FORMAT_BC5_SNORM: - case DXGI_FORMAT_BC6H_TYPELESS: - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - case DXGI_FORMAT_BC7_TYPELESS: - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: - return true; - - default: - return false; - } -} - -_Use_decl_annotations_ -inline bool __cdecl IsPalettized(DXGI_FORMAT fmt) noexcept -{ - switch (fmt) - { - case DXGI_FORMAT_AI44: - case DXGI_FORMAT_IA44: - case DXGI_FORMAT_P8: - case DXGI_FORMAT_A8P8: - return true; - - default: - return false; - } -} - -_Use_decl_annotations_ -inline bool __cdecl IsSRGB(DXGI_FORMAT fmt) noexcept -{ - switch (fmt) - { - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - case DXGI_FORMAT_BC1_UNORM_SRGB: - case DXGI_FORMAT_BC2_UNORM_SRGB: - case DXGI_FORMAT_BC3_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - case DXGI_FORMAT_BC7_UNORM_SRGB: - return true; - - default: - return false; - } -} - -_Use_decl_annotations_ -inline bool __cdecl IsBGR(DXGI_FORMAT fmt) noexcept -{ - switch (fmt) - { - case DXGI_FORMAT_B5G6R5_UNORM: - case DXGI_FORMAT_B5G5R5A1_UNORM: - case DXGI_FORMAT_B8G8R8A8_UNORM: - case DXGI_FORMAT_B8G8R8X8_UNORM: - case DXGI_FORMAT_B8G8R8A8_TYPELESS: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8X8_TYPELESS: - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - case DXGI_FORMAT_B4G4R4A4_UNORM: - return true; - - default: - return false; - } -} - - -//===================================================================================== -// Image I/O -//===================================================================================== -_Use_decl_annotations_ -inline HRESULT __cdecl SaveToDDSMemory(const Image& image, DDS_FLAGS flags, Blob& blob) noexcept -{ - TexMetadata mdata = {}; - mdata.width = image.width; - mdata.height = image.height; - mdata.depth = 1; - mdata.arraySize = 1; - mdata.mipLevels = 1; - mdata.format = image.format; - mdata.dimension = TEX_DIMENSION_TEXTURE2D; - - return SaveToDDSMemory(&image, 1, mdata, flags, blob); -} - -_Use_decl_annotations_ -inline HRESULT __cdecl SaveToDDSFile(const Image& image, DDS_FLAGS flags, const wchar_t* szFile) noexcept -{ - TexMetadata mdata = {}; - mdata.width = image.width; - mdata.height = image.height; - mdata.depth = 1; - mdata.arraySize = 1; - mdata.mipLevels = 1; - mdata.format = image.format; - mdata.dimension = TEX_DIMENSION_TEXTURE2D; - - return SaveToDDSFile(&image, 1, mdata, flags, szFile); -} - - -//===================================================================================== -// Compatability helpers -//===================================================================================== -_Use_decl_annotations_ -inline HRESULT __cdecl GetMetadataFromTGAMemory(const void* pSource, size_t size, TexMetadata& metadata) noexcept -{ - return GetMetadataFromTGAMemory(pSource, size, TGA_FLAGS_NONE, metadata); -} - -_Use_decl_annotations_ -inline HRESULT __cdecl GetMetadataFromTGAFile(const wchar_t* szFile, TexMetadata& metadata) noexcept -{ - return GetMetadataFromTGAFile(szFile, TGA_FLAGS_NONE, metadata); -} - -_Use_decl_annotations_ -inline HRESULT __cdecl LoadFromTGAMemory(const void* pSource, size_t size, TexMetadata* metadata, ScratchImage& image) noexcept -{ - return LoadFromTGAMemory(pSource, size, TGA_FLAGS_NONE, metadata, image); -} - -_Use_decl_annotations_ -inline HRESULT __cdecl LoadFromTGAFile(const wchar_t* szFile, TexMetadata* metadata, ScratchImage& image) noexcept -{ - return LoadFromTGAFile(szFile, TGA_FLAGS_NONE, metadata, image); -} - -_Use_decl_annotations_ -inline HRESULT __cdecl SaveToTGAMemory(const Image& image, Blob& blob, const TexMetadata* metadata) noexcept -{ - return SaveToTGAMemory(image, TGA_FLAGS_NONE, blob, metadata); -} - -_Use_decl_annotations_ -inline HRESULT __cdecl SaveToTGAFile(const Image& image, const wchar_t* szFile, const TexMetadata* metadata) noexcept -{ - return SaveToTGAFile(image, TGA_FLAGS_NONE, szFile, metadata); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexCompress.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexCompress.cpp deleted file mode 100644 index 99385a9..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexCompress.cpp +++ /dev/null @@ -1,850 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXTexCompress.cpp -// -// DirectX Texture Library - Texture compression -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//------------------------------------------------------------------------------------- - -#include "DirectXTexP.h" - -#ifdef _OPENMP -#include -#pragma warning(disable : 4616 6993) -#endif - -#include "BC.h" - -using namespace DirectX; -using namespace DirectX::Internal; - -namespace -{ - constexpr uint32_t GetBCFlags(_In_ TEX_COMPRESS_FLAGS compress) noexcept - { - static_assert(static_cast(TEX_COMPRESS_RGB_DITHER) == static_cast(BC_FLAGS_DITHER_RGB), "TEX_COMPRESS_* flags should match BC_FLAGS_*"); - static_assert(static_cast(TEX_COMPRESS_A_DITHER) == static_cast(BC_FLAGS_DITHER_A), "TEX_COMPRESS_* flags should match BC_FLAGS_*"); - static_assert(static_cast(TEX_COMPRESS_DITHER) == static_cast(BC_FLAGS_DITHER_RGB | BC_FLAGS_DITHER_A), "TEX_COMPRESS_* flags should match BC_FLAGS_*"); - static_assert(static_cast(TEX_COMPRESS_UNIFORM) == static_cast(BC_FLAGS_UNIFORM), "TEX_COMPRESS_* flags should match BC_FLAGS_*"); - static_assert(static_cast(TEX_COMPRESS_BC7_USE_3SUBSETS) == static_cast(BC_FLAGS_USE_3SUBSETS), "TEX_COMPRESS_* flags should match BC_FLAGS_*"); - static_assert(static_cast(TEX_COMPRESS_BC7_QUICK) == static_cast(BC_FLAGS_FORCE_BC7_MODE6), "TEX_COMPRESS_* flags should match BC_FLAGS_*"); - return (compress & (BC_FLAGS_DITHER_RGB | BC_FLAGS_DITHER_A | BC_FLAGS_UNIFORM | BC_FLAGS_USE_3SUBSETS | BC_FLAGS_FORCE_BC7_MODE6)); - } - - constexpr TEX_FILTER_FLAGS GetSRGBFlags(_In_ TEX_COMPRESS_FLAGS compress) noexcept - { - static_assert(TEX_FILTER_SRGB_IN == 0x1000000, "TEX_FILTER_SRGB flag values don't match TEX_FILTER_SRGB_MASK"); - static_assert(static_cast(TEX_COMPRESS_SRGB_IN) == static_cast(TEX_FILTER_SRGB_IN), "TEX_COMPRESS_SRGB* should match TEX_FILTER_SRGB*"); - static_assert(static_cast(TEX_COMPRESS_SRGB_OUT) == static_cast(TEX_FILTER_SRGB_OUT), "TEX_COMPRESS_SRGB* should match TEX_FILTER_SRGB*"); - static_assert(static_cast(TEX_COMPRESS_SRGB) == static_cast(TEX_FILTER_SRGB), "TEX_COMPRESS_SRGB* should match TEX_FILTER_SRGB*"); - return static_cast(compress & TEX_FILTER_SRGB_MASK); - } - - inline bool DetermineEncoderSettings(_In_ DXGI_FORMAT format, _Out_ BC_ENCODE& pfEncode, _Out_ size_t& blocksize, _Out_ TEX_FILTER_FLAGS& cflags) noexcept - { - switch (format) - { - case DXGI_FORMAT_BC1_UNORM: - case DXGI_FORMAT_BC1_UNORM_SRGB: pfEncode = nullptr; blocksize = 8; cflags = TEX_FILTER_DEFAULT; break; - case DXGI_FORMAT_BC2_UNORM: - case DXGI_FORMAT_BC2_UNORM_SRGB: pfEncode = D3DXEncodeBC2; blocksize = 16; cflags = TEX_FILTER_DEFAULT; break; - case DXGI_FORMAT_BC3_UNORM: - case DXGI_FORMAT_BC3_UNORM_SRGB: pfEncode = D3DXEncodeBC3; blocksize = 16; cflags = TEX_FILTER_DEFAULT; break; - case DXGI_FORMAT_BC4_UNORM: pfEncode = D3DXEncodeBC4U; blocksize = 8; cflags = TEX_FILTER_RGB_COPY_RED; break; - case DXGI_FORMAT_BC4_SNORM: pfEncode = D3DXEncodeBC4S; blocksize = 8; cflags = TEX_FILTER_RGB_COPY_RED; break; - case DXGI_FORMAT_BC5_UNORM: pfEncode = D3DXEncodeBC5U; blocksize = 16; cflags = TEX_FILTER_RGB_COPY_RED | TEX_FILTER_RGB_COPY_GREEN; break; - case DXGI_FORMAT_BC5_SNORM: pfEncode = D3DXEncodeBC5S; blocksize = 16; cflags = TEX_FILTER_RGB_COPY_RED | TEX_FILTER_RGB_COPY_GREEN; break; - case DXGI_FORMAT_BC6H_UF16: pfEncode = D3DXEncodeBC6HU; blocksize = 16; cflags = TEX_FILTER_DEFAULT; break; - case DXGI_FORMAT_BC6H_SF16: pfEncode = D3DXEncodeBC6HS; blocksize = 16; cflags = TEX_FILTER_DEFAULT; break; - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: pfEncode = D3DXEncodeBC7; blocksize = 16; cflags = TEX_FILTER_DEFAULT; break; - default: pfEncode = nullptr; blocksize = 0; cflags = TEX_FILTER_DEFAULT; return false; - } - - return true; - } - - - //------------------------------------------------------------------------------------- - HRESULT CompressBC( - const Image& image, - const Image& result, - uint32_t bcflags, - TEX_FILTER_FLAGS srgb, - float threshold) noexcept - { - if (!image.pixels || !result.pixels) - return E_POINTER; - - assert(image.width == result.width); - assert(image.height == result.height); - - const DXGI_FORMAT format = image.format; - size_t sbpp = BitsPerPixel(format); - if (!sbpp) - return E_FAIL; - - if (sbpp < 8) - { - // We don't support compressing from monochrome (DXGI_FORMAT_R1_UNORM) - return HRESULT_E_NOT_SUPPORTED; - } - - // Round to bytes - sbpp = (sbpp + 7) / 8; - - uint8_t *pDest = result.pixels; - - // Determine BC format encoder - BC_ENCODE pfEncode; - size_t blocksize; - TEX_FILTER_FLAGS cflags; - if (!DetermineEncoderSettings(result.format, pfEncode, blocksize, cflags)) - return HRESULT_E_NOT_SUPPORTED; - - XM_ALIGNED_DATA(16) XMVECTOR temp[16]; - const uint8_t *pSrc = image.pixels; - const uint8_t *pEnd = image.pixels + image.slicePitch; - const size_t rowPitch = image.rowPitch; - for (size_t h = 0; h < image.height; h += 4) - { - const uint8_t *sptr = pSrc; - uint8_t* dptr = pDest; - const size_t ph = std::min(4, image.height - h); - size_t w = 0; - for (size_t count = 0; (count < result.rowPitch) && (w < image.width); count += blocksize, w += 4) - { - const size_t pw = std::min(4, image.width - w); - assert(pw > 0 && ph > 0); - - const ptrdiff_t bytesLeft = pEnd - sptr; - assert(bytesLeft > 0); - size_t bytesToRead = std::min(rowPitch, static_cast(bytesLeft)); - if (!LoadScanline(&temp[0], pw, sptr, bytesToRead, format)) - return E_FAIL; - - if (ph > 1) - { - bytesToRead = std::min(rowPitch, static_cast(bytesLeft) - rowPitch); - if (!LoadScanline(&temp[4], pw, sptr + rowPitch, bytesToRead, format)) - return E_FAIL; - - if (ph > 2) - { - bytesToRead = std::min(rowPitch, static_cast(bytesLeft) - rowPitch * 2); - if (!LoadScanline(&temp[8], pw, sptr + rowPitch * 2, bytesToRead, format)) - return E_FAIL; - - if (ph > 3) - { - bytesToRead = std::min(rowPitch, static_cast(bytesLeft) - rowPitch * 3); - if (!LoadScanline(&temp[12], pw, sptr + rowPitch * 3, bytesToRead, format)) - return E_FAIL; - } - } - } - - if (pw != 4 || ph != 4) - { - // Replicate pixels for partial block - static const size_t uSrc[] = { 0, 0, 0, 1 }; - - if (pw < 4) - { - for (size_t t = 0; t < ph && t < 4; ++t) - { - for (size_t s = pw; s < 4; ++s) - { - #pragma prefast(suppress: 26000, "PREFAST false positive") - temp[(t << 2) | s] = temp[(t << 2) | uSrc[s]]; - } - } - } - - if (ph < 4) - { - for (size_t t = ph; t < 4; ++t) - { - for (size_t s = 0; s < 4; ++s) - { - #pragma prefast(suppress: 26000, "PREFAST false positive") - temp[(t << 2) | s] = temp[(uSrc[t] << 2) | s]; - } - } - } - } - - ConvertScanline(temp, 16, result.format, format, cflags | srgb); - - if (pfEncode) - pfEncode(dptr, temp, bcflags); - else - D3DXEncodeBC1(dptr, temp, threshold, bcflags); - - sptr += sbpp * 4; - dptr += blocksize; - } - - pSrc += rowPitch * 4; - pDest += result.rowPitch; - } - - return S_OK; - } - - - //------------------------------------------------------------------------------------- -#ifdef _OPENMP - HRESULT CompressBC_Parallel( - const Image& image, - const Image& result, - uint32_t bcflags, - TEX_FILTER_FLAGS srgb, - float threshold) noexcept - { - if (!image.pixels || !result.pixels) - return E_POINTER; - - assert(image.width == result.width); - assert(image.height == result.height); - - const DXGI_FORMAT format = image.format; - size_t sbpp = BitsPerPixel(format); - if (!sbpp) - return E_FAIL; - - if (sbpp < 8) - { - // We don't support compressing from monochrome (DXGI_FORMAT_R1_UNORM) - return HRESULT_E_NOT_SUPPORTED; - } - - // Round to bytes - sbpp = (sbpp + 7) / 8; - - const uint8_t *pEnd = image.pixels + image.slicePitch; - - // Determine BC format encoder - BC_ENCODE pfEncode; - size_t blocksize; - TEX_FILTER_FLAGS cflags; - if (!DetermineEncoderSettings(result.format, pfEncode, blocksize, cflags)) - return HRESULT_E_NOT_SUPPORTED; - - // Refactored version of loop to support parallel independance - const size_t nBlocks = std::max(1, (image.width + 3) / 4) * std::max(1, (image.height + 3) / 4); - - bool fail = false; - - #pragma omp parallel for - for (int nb = 0; nb < static_cast(nBlocks); ++nb) - { - const int nbWidth = std::max(1, int((image.width + 3) / 4)); - - int y = nb / nbWidth; - const int x = (nb - (y*nbWidth)) * 4; - y *= 4; - - assert((x >= 0) && (x < int(image.width))); - assert((y >= 0) && (y < int(image.height))); - - const size_t rowPitch = image.rowPitch; - const uint8_t *pSrc = image.pixels + (size_t(y)*rowPitch) + (size_t(x)*sbpp); - - uint8_t *pDest = result.pixels + (size_t(nb)*blocksize); - - const size_t ph = std::min(4, image.height - size_t(y)); - const size_t pw = std::min(4, image.width - size_t(x)); - assert(pw > 0 && ph > 0); - - const ptrdiff_t bytesLeft = pEnd - pSrc; - assert(bytesLeft > 0); - size_t bytesToRead = std::min(rowPitch, size_t(bytesLeft)); - - XM_ALIGNED_DATA(16) XMVECTOR temp[16]; - if (!LoadScanline(&temp[0], pw, pSrc, bytesToRead, format)) - fail = true; - - if (ph > 1) - { - bytesToRead = std::min(rowPitch, size_t(bytesLeft) - rowPitch); - if (!LoadScanline(&temp[4], pw, pSrc + rowPitch, bytesToRead, format)) - fail = true; - - if (ph > 2) - { - bytesToRead = std::min(rowPitch, size_t(bytesLeft) - rowPitch * 2); - if (!LoadScanline(&temp[8], pw, pSrc + rowPitch * 2, bytesToRead, format)) - fail = true; - - if (ph > 3) - { - bytesToRead = std::min(rowPitch, size_t(bytesLeft) - rowPitch * 3); - if (!LoadScanline(&temp[12], pw, pSrc + rowPitch * 3, bytesToRead, format)) - fail = true; - } - } - } - - if (pw != 4 || ph != 4) - { - // Replicate pixels for partial block - static const size_t uSrc[] = { 0, 0, 0, 1 }; - - if (pw < 4) - { - for (size_t t = 0; t < ph && t < 4; ++t) - { - for (size_t s = pw; s < 4; ++s) - { - temp[(t << 2) | s] = temp[(t << 2) | uSrc[s]]; - } - } - } - - if (ph < 4) - { - for (size_t t = ph; t < 4; ++t) - { - for (size_t s = 0; s < 4; ++s) - { - temp[(t << 2) | s] = temp[(uSrc[t] << 2) | s]; - } - } - } - } - - ConvertScanline(temp, 16, result.format, format, cflags | srgb); - - if (pfEncode) - pfEncode(pDest, temp, bcflags); - else - D3DXEncodeBC1(pDest, temp, threshold, bcflags); - } - - return (fail) ? E_FAIL : S_OK; - } -#endif // _OPENMP - - - //------------------------------------------------------------------------------------- - DXGI_FORMAT DefaultDecompress(_In_ DXGI_FORMAT format) noexcept - { - switch (format) - { - case DXGI_FORMAT_BC1_TYPELESS: - case DXGI_FORMAT_BC1_UNORM: - case DXGI_FORMAT_BC2_TYPELESS: - case DXGI_FORMAT_BC2_UNORM: - case DXGI_FORMAT_BC3_TYPELESS: - case DXGI_FORMAT_BC3_UNORM: - case DXGI_FORMAT_BC7_TYPELESS: - case DXGI_FORMAT_BC7_UNORM: - return DXGI_FORMAT_R8G8B8A8_UNORM; - - case DXGI_FORMAT_BC1_UNORM_SRGB: - case DXGI_FORMAT_BC2_UNORM_SRGB: - case DXGI_FORMAT_BC3_UNORM_SRGB: - case DXGI_FORMAT_BC7_UNORM_SRGB: - return DXGI_FORMAT_R8G8B8A8_UNORM_SRGB; - - case DXGI_FORMAT_BC4_TYPELESS: - case DXGI_FORMAT_BC4_UNORM: - return DXGI_FORMAT_R8_UNORM; - - case DXGI_FORMAT_BC4_SNORM: - return DXGI_FORMAT_R8_SNORM; - - case DXGI_FORMAT_BC5_TYPELESS: - case DXGI_FORMAT_BC5_UNORM: - return DXGI_FORMAT_R8G8_UNORM; - - case DXGI_FORMAT_BC5_SNORM: - return DXGI_FORMAT_R8G8_SNORM; - - case DXGI_FORMAT_BC6H_TYPELESS: - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - // We could use DXGI_FORMAT_R32G32B32_FLOAT here since BC6H is always Alpha 1.0, - // but this format is more supported by viewers - return DXGI_FORMAT_R32G32B32A32_FLOAT; - - default: - return DXGI_FORMAT_UNKNOWN; - } - } - - - //------------------------------------------------------------------------------------- - HRESULT DecompressBC(_In_ const Image& cImage, _In_ const Image& result) noexcept - { - if (!cImage.pixels || !result.pixels) - return E_POINTER; - - assert(cImage.width == result.width); - assert(cImage.height == result.height); - - const DXGI_FORMAT format = result.format; - size_t dbpp = BitsPerPixel(format); - if (!dbpp) - return E_FAIL; - - if (dbpp < 8) - { - // We don't support decompressing to monochrome (DXGI_FORMAT_R1_UNORM) - return HRESULT_E_NOT_SUPPORTED; - } - - // Round to bytes - dbpp = (dbpp + 7) / 8; - - uint8_t *pDest = result.pixels; - if (!pDest) - return E_POINTER; - - // Promote "typeless" BC formats - DXGI_FORMAT cformat; - switch (cImage.format) - { - case DXGI_FORMAT_BC1_TYPELESS: cformat = DXGI_FORMAT_BC1_UNORM; break; - case DXGI_FORMAT_BC2_TYPELESS: cformat = DXGI_FORMAT_BC2_UNORM; break; - case DXGI_FORMAT_BC3_TYPELESS: cformat = DXGI_FORMAT_BC3_UNORM; break; - case DXGI_FORMAT_BC4_TYPELESS: cformat = DXGI_FORMAT_BC4_UNORM; break; - case DXGI_FORMAT_BC5_TYPELESS: cformat = DXGI_FORMAT_BC5_UNORM; break; - case DXGI_FORMAT_BC6H_TYPELESS: cformat = DXGI_FORMAT_BC6H_UF16; break; - case DXGI_FORMAT_BC7_TYPELESS: cformat = DXGI_FORMAT_BC7_UNORM; break; - default: cformat = cImage.format; break; - } - - // Determine BC format decoder - BC_DECODE pfDecode; - size_t sbpp; - switch (cformat) - { - case DXGI_FORMAT_BC1_UNORM: - case DXGI_FORMAT_BC1_UNORM_SRGB: pfDecode = D3DXDecodeBC1; sbpp = 8; break; - case DXGI_FORMAT_BC2_UNORM: - case DXGI_FORMAT_BC2_UNORM_SRGB: pfDecode = D3DXDecodeBC2; sbpp = 16; break; - case DXGI_FORMAT_BC3_UNORM: - case DXGI_FORMAT_BC3_UNORM_SRGB: pfDecode = D3DXDecodeBC3; sbpp = 16; break; - case DXGI_FORMAT_BC4_UNORM: pfDecode = D3DXDecodeBC4U; sbpp = 8; break; - case DXGI_FORMAT_BC4_SNORM: pfDecode = D3DXDecodeBC4S; sbpp = 8; break; - case DXGI_FORMAT_BC5_UNORM: pfDecode = D3DXDecodeBC5U; sbpp = 16; break; - case DXGI_FORMAT_BC5_SNORM: pfDecode = D3DXDecodeBC5S; sbpp = 16; break; - case DXGI_FORMAT_BC6H_UF16: pfDecode = D3DXDecodeBC6HU; sbpp = 16; break; - case DXGI_FORMAT_BC6H_SF16: pfDecode = D3DXDecodeBC6HS; sbpp = 16; break; - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: pfDecode = D3DXDecodeBC7; sbpp = 16; break; - default: - return HRESULT_E_NOT_SUPPORTED; - } - - XM_ALIGNED_DATA(16) XMVECTOR temp[16]; - const uint8_t *pSrc = cImage.pixels; - const size_t rowPitch = result.rowPitch; - for (size_t h = 0; h < cImage.height; h += 4) - { - const uint8_t *sptr = pSrc; - uint8_t* dptr = pDest; - const size_t ph = std::min(4, cImage.height - h); - size_t w = 0; - for (size_t count = 0; (count < cImage.rowPitch) && (w < cImage.width); count += sbpp, w += 4) - { - pfDecode(temp, sptr); - ConvertScanline(temp, 16, format, cformat, TEX_FILTER_DEFAULT); - - const size_t pw = std::min(4, cImage.width - w); - assert(pw > 0 && ph > 0); - - if (!StoreScanline(dptr, rowPitch, format, &temp[0], pw)) - return E_FAIL; - - if (ph > 1) - { - if (!StoreScanline(dptr + rowPitch, rowPitch, format, &temp[4], pw)) - return E_FAIL; - - if (ph > 2) - { - if (!StoreScanline(dptr + rowPitch * 2, rowPitch, format, &temp[8], pw)) - return E_FAIL; - - if (ph > 3) - { - if (!StoreScanline(dptr + rowPitch * 3, rowPitch, format, &temp[12], pw)) - return E_FAIL; - } - } - } - - sptr += sbpp; - dptr += dbpp * 4; - } - - pSrc += cImage.rowPitch; - pDest += rowPitch * 4; - } - - return S_OK; - } -} - -//------------------------------------------------------------------------------------- -bool DirectX::Internal::IsAlphaAllOpaqueBC(_In_ const Image& cImage) noexcept -{ - if (!cImage.pixels) - return false; - - // Promote "typeless" BC formats - DXGI_FORMAT cformat; - switch (cImage.format) - { - case DXGI_FORMAT_BC1_TYPELESS: cformat = DXGI_FORMAT_BC1_UNORM; break; - case DXGI_FORMAT_BC2_TYPELESS: cformat = DXGI_FORMAT_BC2_UNORM; break; - case DXGI_FORMAT_BC3_TYPELESS: cformat = DXGI_FORMAT_BC3_UNORM; break; - case DXGI_FORMAT_BC7_TYPELESS: cformat = DXGI_FORMAT_BC7_UNORM; break; - default: cformat = cImage.format; break; - } - - // Determine BC format decoder - BC_DECODE pfDecode; - size_t sbpp; - switch (cformat) - { - case DXGI_FORMAT_BC1_UNORM: - case DXGI_FORMAT_BC1_UNORM_SRGB: pfDecode = D3DXDecodeBC1; sbpp = 8; break; - case DXGI_FORMAT_BC2_UNORM: - case DXGI_FORMAT_BC2_UNORM_SRGB: pfDecode = D3DXDecodeBC2; sbpp = 16; break; - case DXGI_FORMAT_BC3_UNORM: - case DXGI_FORMAT_BC3_UNORM_SRGB: pfDecode = D3DXDecodeBC3; sbpp = 16; break; - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: pfDecode = D3DXDecodeBC7; sbpp = 16; break; - default: - // BC4, BC5, and BC6 don't have alpha channels - return false; - } - - // Scan blocks for non-opaque alpha - static const XMVECTORF32 threshold = { { { 0.99f, 0.99f, 0.99f, 0.99f } } }; - - XM_ALIGNED_DATA(16) XMVECTOR temp[16]; - const uint8_t* pPixels = cImage.pixels; - for (size_t h = 0; h < cImage.height; h += 4) - { - const uint8_t* ptr = pPixels; - const size_t ph = std::min(4, cImage.height - h); - size_t w = 0; - for (size_t count = 0; (count < cImage.rowPitch) && (w < cImage.width); count += sbpp, w += 4) - { - pfDecode(temp, ptr); - - const size_t pw = std::min(4, cImage.width - w); - assert(pw > 0 && ph > 0); - - if (pw == 4 && ph == 4) - { - // Full blocks - for (size_t j = 0; j < 16; ++j) - { - const XMVECTOR alpha = XMVectorSplatW(temp[j]); - if (XMVector4Less(alpha, threshold)) - return false; - } - } - else - { - // Handle partial blocks - for (size_t y = 0; y < ph; ++y) - { - for (size_t x = 0; x < pw; ++x) - { - const XMVECTOR alpha = XMVectorSplatW(temp[y * 4 + x]); - if (XMVector4Less(alpha, threshold)) - return false; - } - } - } - - ptr += sbpp; - } - - pPixels += cImage.rowPitch; - } - - return true; -} - - -//===================================================================================== -// Entry-points -//===================================================================================== - -//------------------------------------------------------------------------------------- -// Compression -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::Compress( - const Image& srcImage, - DXGI_FORMAT format, - TEX_COMPRESS_FLAGS compress, - float threshold, - ScratchImage& image) noexcept -{ - if (IsCompressed(srcImage.format) || !IsCompressed(format)) - return E_INVALIDARG; - - if (IsTypeless(format) - || IsTypeless(srcImage.format) || IsPlanar(srcImage.format) || IsPalettized(srcImage.format)) - return HRESULT_E_NOT_SUPPORTED; - - // Create compressed image - HRESULT hr = image.Initialize2D(format, srcImage.width, srcImage.height, 1, 1); - if (FAILED(hr)) - return hr; - - const Image *img = image.GetImage(0, 0, 0); - if (!img) - { - image.Release(); - return E_POINTER; - } - - // Compress single image - if (compress & TEX_COMPRESS_PARALLEL) - { - #ifndef _OPENMP - return E_NOTIMPL; - #else - hr = CompressBC_Parallel(srcImage, *img, GetBCFlags(compress), GetSRGBFlags(compress), threshold); - #endif // _OPENMP - } - else - { - hr = CompressBC(srcImage, *img, GetBCFlags(compress), GetSRGBFlags(compress), threshold); - } - - if (FAILED(hr)) - image.Release(); - - return hr; -} - -_Use_decl_annotations_ -HRESULT DirectX::Compress( - const Image* srcImages, - size_t nimages, - const TexMetadata& metadata, - DXGI_FORMAT format, - TEX_COMPRESS_FLAGS compress, - float threshold, - ScratchImage& cImages) noexcept -{ - if (!srcImages || !nimages) - return E_INVALIDARG; - - if (IsCompressed(metadata.format) || !IsCompressed(format)) - return E_INVALIDARG; - - if (IsTypeless(format) - || IsTypeless(metadata.format) || IsPlanar(metadata.format) || IsPalettized(metadata.format)) - return HRESULT_E_NOT_SUPPORTED; - - cImages.Release(); - - TexMetadata mdata2 = metadata; - mdata2.format = format; - HRESULT hr = cImages.Initialize(mdata2); - if (FAILED(hr)) - return hr; - - if (nimages != cImages.GetImageCount()) - { - cImages.Release(); - return E_FAIL; - } - - const Image* dest = cImages.GetImages(); - if (!dest) - { - cImages.Release(); - return E_POINTER; - } - - for (size_t index = 0; index < nimages; ++index) - { - assert(dest[index].format == format); - - const Image& src = srcImages[index]; - - if (src.width != dest[index].width || src.height != dest[index].height) - { - cImages.Release(); - return E_FAIL; - } - - if ((compress & TEX_COMPRESS_PARALLEL)) - { - #ifndef _OPENMP - return E_NOTIMPL; - #else - if (compress & TEX_COMPRESS_PARALLEL) - { - hr = CompressBC_Parallel(src, dest[index], GetBCFlags(compress), GetSRGBFlags(compress), threshold); - if (FAILED(hr)) - { - cImages.Release(); - return hr; - } - } - #endif // _OPENMP - } - else - { - hr = CompressBC(src, dest[index], GetBCFlags(compress), GetSRGBFlags(compress), threshold); - if (FAILED(hr)) - { - cImages.Release(); - return hr; - } - } - } - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -// Decompression -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::Decompress( - const Image& cImage, - DXGI_FORMAT format, - ScratchImage& image) noexcept -{ - if (!IsCompressed(cImage.format) || IsCompressed(format)) - return E_INVALIDARG; - - if (format == DXGI_FORMAT_UNKNOWN) - { - // Pick a default decompressed format based on BC input format - format = DefaultDecompress(cImage.format); - if (format == DXGI_FORMAT_UNKNOWN) - { - // Input is not a compressed format - return E_INVALIDARG; - } - } - else - { - if (!IsValid(format)) - return E_INVALIDARG; - - if (IsTypeless(format) || IsPlanar(format) || IsPalettized(format)) - return HRESULT_E_NOT_SUPPORTED; - } - - // Create decompressed image - HRESULT hr = image.Initialize2D(format, cImage.width, cImage.height, 1, 1); - if (FAILED(hr)) - return hr; - - const Image *img = image.GetImage(0, 0, 0); - if (!img) - { - image.Release(); - return E_POINTER; - } - - // Decompress single image - hr = DecompressBC(cImage, *img); - if (FAILED(hr)) - image.Release(); - - return hr; -} - -_Use_decl_annotations_ -HRESULT DirectX::Decompress( - const Image* cImages, - size_t nimages, - const TexMetadata& metadata, - DXGI_FORMAT format, - ScratchImage& images) noexcept -{ - if (!cImages || !nimages) - return E_INVALIDARG; - - if (!IsCompressed(metadata.format) || IsCompressed(format)) - return E_INVALIDARG; - - if (format == DXGI_FORMAT_UNKNOWN) - { - // Pick a default decompressed format based on BC input format - format = DefaultDecompress(cImages[0].format); - if (format == DXGI_FORMAT_UNKNOWN) - { - // Input is not a compressed format - return E_FAIL; - } - } - else - { - if (!IsValid(format)) - return E_INVALIDARG; - - if (IsTypeless(format) || IsPlanar(format) || IsPalettized(format)) - return HRESULT_E_NOT_SUPPORTED; - } - - images.Release(); - - TexMetadata mdata2 = metadata; - mdata2.format = format; - HRESULT hr = images.Initialize(mdata2); - if (FAILED(hr)) - return hr; - - if (nimages != images.GetImageCount()) - { - images.Release(); - return E_FAIL; - } - - const Image* dest = images.GetImages(); - if (!dest) - { - images.Release(); - return E_POINTER; - } - - for (size_t index = 0; index < nimages; ++index) - { - assert(dest[index].format == format); - - const Image& src = cImages[index]; - if (!IsCompressed(src.format)) - { - images.Release(); - return E_FAIL; - } - - if (src.width != dest[index].width || src.height != dest[index].height) - { - images.Release(); - return E_FAIL; - } - - hr = DecompressBC(src, dest[index]); - if (FAILED(hr)) - { - images.Release(); - return hr; - } - } - - return S_OK; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexCompressGPU.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexCompressGPU.cpp deleted file mode 100644 index fb9d84d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexCompressGPU.cpp +++ /dev/null @@ -1,422 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXTexCompressGPU.cpp -// -// DirectX Texture Library - DirectCompute-based texture compression -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//------------------------------------------------------------------------------------- - -#include "DirectXTexP.h" - -#include "BCDirectCompute.h" - -using namespace DirectX; -using namespace DirectX::Internal; - -namespace -{ - constexpr TEX_FILTER_FLAGS GetSRGBFlags(_In_ TEX_COMPRESS_FLAGS compress) noexcept - { - static_assert(TEX_FILTER_SRGB_IN == 0x1000000, "TEX_FILTER_SRGB flag values don't match TEX_FILTER_SRGB_MASK"); - static_assert(static_cast(TEX_COMPRESS_SRGB_IN) == static_cast(TEX_FILTER_SRGB_IN), "TEX_COMPRESS_SRGB* should match TEX_FILTER_SRGB*"); - static_assert(static_cast(TEX_COMPRESS_SRGB_OUT) == static_cast(TEX_FILTER_SRGB_OUT), "TEX_COMPRESS_SRGB* should match TEX_FILTER_SRGB*"); - static_assert(static_cast(TEX_COMPRESS_SRGB) == static_cast(TEX_FILTER_SRGB), "TEX_COMPRESS_SRGB* should match TEX_FILTER_SRGB*"); - return static_cast(compress & TEX_FILTER_SRGB_MASK); - } - - - //------------------------------------------------------------------------------------- - // Converts to R8G8B8A8_UNORM or R8G8B8A8_UNORM_SRGB doing any conversion logic needed - //------------------------------------------------------------------------------------- - HRESULT ConvertToRGBA32( - const Image& srcImage, - ScratchImage& image, - bool srgb, - TEX_FILTER_FLAGS filter) noexcept - { - if (!srcImage.pixels) - return E_POINTER; - - const DXGI_FORMAT format = srgb ? DXGI_FORMAT_R8G8B8A8_UNORM_SRGB : DXGI_FORMAT_R8G8B8A8_UNORM; - - HRESULT hr = image.Initialize2D(format, srcImage.width, srcImage.height, 1, 1); - if (FAILED(hr)) - return hr; - - const Image *img = image.GetImage(0, 0, 0); - if (!img) - { - image.Release(); - return E_POINTER; - } - - uint8_t* pDest = img->pixels; - if (!pDest) - { - image.Release(); - return E_POINTER; - } - - auto scanline = make_AlignedArrayXMVECTOR(srcImage.width); - if (!scanline) - { - image.Release(); - return E_OUTOFMEMORY; - } - - const uint8_t *pSrc = srcImage.pixels; - for (size_t h = 0; h < srcImage.height; ++h) - { - if (!LoadScanline(scanline.get(), srcImage.width, pSrc, srcImage.rowPitch, srcImage.format)) - { - image.Release(); - return E_FAIL; - } - - ConvertScanline(scanline.get(), srcImage.width, format, srcImage.format, filter); - - if (!StoreScanline(pDest, img->rowPitch, format, scanline.get(), srcImage.width)) - { - image.Release(); - return E_FAIL; - } - - pSrc += srcImage.rowPitch; - pDest += img->rowPitch; - } - - return S_OK; - } - - - //------------------------------------------------------------------------------------- - // Converts to DXGI_FORMAT_R32G32B32A32_FLOAT doing any conversion logic needed - //------------------------------------------------------------------------------------- - HRESULT ConvertToRGBAF32( - const Image& srcImage, - ScratchImage& image, - TEX_FILTER_FLAGS filter) noexcept - { - if (!srcImage.pixels) - return E_POINTER; - - HRESULT hr = image.Initialize2D(DXGI_FORMAT_R32G32B32A32_FLOAT, srcImage.width, srcImage.height, 1, 1); - if (FAILED(hr)) - return hr; - - const Image *img = image.GetImage(0, 0, 0); - if (!img) - { - image.Release(); - return E_POINTER; - } - - uint8_t* pDest = img->pixels; - if (!pDest) - { - image.Release(); - return E_POINTER; - } - - const uint8_t *pSrc = srcImage.pixels; - for (size_t h = 0; h < srcImage.height; ++h) - { - if (!LoadScanline(reinterpret_cast(pDest), srcImage.width, pSrc, srcImage.rowPitch, srcImage.format)) - { - image.Release(); - return E_FAIL; - } - - ConvertScanline(reinterpret_cast(pDest), srcImage.width, DXGI_FORMAT_R32G32B32A32_FLOAT, srcImage.format, filter); - - pSrc += srcImage.rowPitch; - pDest += img->rowPitch; - } - - return S_OK; - } - - - //------------------------------------------------------------------------------------- - // Compress using GPU, converting to the proper input format for the shader if needed - //------------------------------------------------------------------------------------- - inline HRESULT GPUCompress( - _In_ GPUCompressBC* gpubc, - const Image& srcImage, - const Image& destImage, - TEX_COMPRESS_FLAGS compress) - { - if (!gpubc) - return E_POINTER; - - assert(srcImage.pixels && destImage.pixels); - - const DXGI_FORMAT format = gpubc->GetSourceFormat(); - - if (srcImage.format == format) - { - // Input is already in our required source format - return gpubc->Compress(srcImage, destImage); - } - else - { - // Convert format and then use as the source image - ScratchImage image; - HRESULT hr = E_UNEXPECTED; - - auto const srgb = GetSRGBFlags(compress); - - switch (format) - { - case DXGI_FORMAT_R8G8B8A8_UNORM: - hr = ConvertToRGBA32(srcImage, image, false, srgb); - break; - - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - hr = ConvertToRGBA32(srcImage, image, true, srgb); - break; - - case DXGI_FORMAT_R32G32B32A32_FLOAT: - hr = ConvertToRGBAF32(srcImage, image, srgb); - break; - - default: - break; - } - - if (FAILED(hr)) - return hr; - - const Image *img = image.GetImage(0, 0, 0); - if (!img) - return E_POINTER; - - return gpubc->Compress(*img, destImage); - } - } -}; - -//===================================================================================== -// Entry-points -//===================================================================================== - -//------------------------------------------------------------------------------------- -// Compression -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::Compress( - ID3D11Device* pDevice, - const Image& srcImage, - DXGI_FORMAT format, - TEX_COMPRESS_FLAGS compress, - float alphaWeight, - ScratchImage& image) noexcept -{ - if (!pDevice || IsCompressed(srcImage.format) || !IsCompressed(format)) - return E_INVALIDARG; - - if (IsTypeless(format) - || IsTypeless(srcImage.format) || IsPlanar(srcImage.format) || IsPalettized(srcImage.format)) - return HRESULT_E_NOT_SUPPORTED; - - // Setup GPU compressor - std::unique_ptr gpubc(new (std::nothrow) GPUCompressBC); - if (!gpubc) - return E_OUTOFMEMORY; - - HRESULT hr = gpubc->Initialize(pDevice); - if (FAILED(hr)) - return hr; - - hr = gpubc->Prepare(srcImage.width, srcImage.height, compress, format, alphaWeight); - if (FAILED(hr)) - return hr; - - // Create workspace for result - hr = image.Initialize2D(format, srcImage.width, srcImage.height, 1, 1); - if (FAILED(hr)) - return hr; - - const Image *img = image.GetImage(0, 0, 0); - if (!img) - { - image.Release(); - return E_POINTER; - } - - hr = GPUCompress(gpubc.get(), srcImage, *img, compress); - if (FAILED(hr)) - image.Release(); - - return hr; -} - -_Use_decl_annotations_ -HRESULT DirectX::Compress( - ID3D11Device* pDevice, - const Image* srcImages, - size_t nimages, - const TexMetadata& metadata, - DXGI_FORMAT format, - TEX_COMPRESS_FLAGS compress, - float alphaWeight, - ScratchImage& cImages) noexcept -{ - if (!pDevice || !srcImages || !nimages) - return E_INVALIDARG; - - if (IsCompressed(metadata.format) || !IsCompressed(format)) - return E_INVALIDARG; - - if (IsTypeless(format) - || IsTypeless(metadata.format) || IsPlanar(metadata.format) || IsPalettized(metadata.format)) - return HRESULT_E_NOT_SUPPORTED; - - cImages.Release(); - - // Setup GPU compressor - std::unique_ptr gpubc(new (std::nothrow) GPUCompressBC); - if (!gpubc) - return E_OUTOFMEMORY; - - HRESULT hr = gpubc->Initialize(pDevice); - if (FAILED(hr)) - return hr; - - // Create workspace for result - TexMetadata mdata2 = metadata; - mdata2.format = format; - hr = cImages.Initialize(mdata2); - if (FAILED(hr)) - return hr; - - if (nimages != cImages.GetImageCount()) - { - cImages.Release(); - return E_FAIL; - } - - const Image* dest = cImages.GetImages(); - if (!dest) - { - cImages.Release(); - return E_POINTER; - } - - // Process images (ordered by size) - switch (metadata.dimension) - { - case TEX_DIMENSION_TEXTURE1D: - case TEX_DIMENSION_TEXTURE2D: - { - size_t w = metadata.width; - size_t h = metadata.height; - - for (size_t level = 0; level < metadata.mipLevels; ++level) - { - hr = gpubc->Prepare(w, h, compress, format, alphaWeight); - if (FAILED(hr)) - { - cImages.Release(); - return hr; - } - - for (size_t item = 0; item < metadata.arraySize; ++item) - { - const size_t index = metadata.ComputeIndex(level, item, 0); - if (index >= nimages) - { - cImages.Release(); - return E_FAIL; - } - - assert(dest[index].format == format); - - const Image& src = srcImages[index]; - - if (src.width != dest[index].width || src.height != dest[index].height) - { - cImages.Release(); - return E_FAIL; - } - - hr = GPUCompress(gpubc.get(), src, dest[index], compress); - if (FAILED(hr)) - { - cImages.Release(); - return hr; - } - } - - if (h > 1) - h >>= 1; - - if (w > 1) - w >>= 1; - } - } - break; - - case TEX_DIMENSION_TEXTURE3D: - { - size_t w = metadata.width; - size_t h = metadata.height; - size_t d = metadata.depth; - - for (size_t level = 0; level < metadata.mipLevels; ++level) - { - hr = gpubc->Prepare(w, h, compress, format, alphaWeight); - if (FAILED(hr)) - { - cImages.Release(); - return hr; - } - - for (size_t slice = 0; slice < d; ++slice) - { - const size_t index = metadata.ComputeIndex(level, 0, slice); - if (index >= nimages) - { - cImages.Release(); - return E_FAIL; - } - - assert(dest[index].format == format); - - const Image& src = srcImages[index]; - - if (src.width != dest[index].width || src.height != dest[index].height) - { - cImages.Release(); - return E_FAIL; - } - - hr = GPUCompress(gpubc.get(), src, dest[index], compress); - if (FAILED(hr)) - { - cImages.Release(); - return hr; - } - } - - if (h > 1) - h >>= 1; - - if (w > 1) - w >>= 1; - - if (d > 1) - d >>= 1; - } - } - break; - - default: - return HRESULT_E_NOT_SUPPORTED; - } - - return S_OK; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexConvert.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexConvert.cpp deleted file mode 100644 index f98fbc7..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexConvert.cpp +++ /dev/null @@ -1,5216 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXTexConvert.cpp -// -// DirectX Texture Library - Image pixel format conversion -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//------------------------------------------------------------------------------------- - -#include "DirectXTexP.h" - -using namespace DirectX; -using namespace DirectX::Internal; -using namespace DirectX::PackedVector; -using Microsoft::WRL::ComPtr; - -namespace -{ - inline uint32_t FloatTo7e3(float Value) noexcept - { - uint32_t IValue = reinterpret_cast(&Value)[0]; - - if (IValue & 0x80000000U) - { - // Positive only - return 0; - } - else if (IValue > 0x41FF73FFU) - { - // The number is too large to be represented as a 7e3. Saturate. - return 0x3FFU; - } - else - { - if (IValue < 0x3E800000U) - { - // The number is too small to be represented as a normalized 7e3. - // Convert it to a denormalized value. - const uint32_t Shift = std::min(125U - (IValue >> 23U), 24U); - IValue = (0x800000U | (IValue & 0x7FFFFFU)) >> Shift; - } - else - { - // Rebias the exponent to represent the value as a normalized 7e3. - IValue += 0xC2000000U; - } - - return ((IValue + 0x7FFFU + ((IValue >> 16U) & 1U)) >> 16U) & 0x3FFU; - } - } - - inline float FloatFrom7e3(uint32_t Value) noexcept - { - auto Mantissa = static_cast(Value & 0x7F); - - uint32_t Exponent = (Value & 0x380); - if (Exponent != 0) // The value is normalized - { - Exponent = static_cast((Value >> 7) & 0x7); - } - else if (Mantissa != 0) // The value is denormalized - { - // Normalize the value in the resulting float - Exponent = 1; - - do - { - Exponent--; - Mantissa <<= 1; - } - while ((Mantissa & 0x80) == 0); - - Mantissa &= 0x7F; - } - else // The value is zero - { - Exponent = uint32_t(-124); - } - - const uint32_t Result = ((Exponent + 124) << 23) | // Exponent - (Mantissa << 16); // Mantissa - - return reinterpret_cast(&Result)[0]; - } - - inline uint32_t FloatTo6e4(float Value) noexcept - { - uint32_t IValue = reinterpret_cast(&Value)[0]; - - if (IValue & 0x80000000U) - { - // Positive only - return 0; - } - else if (IValue > 0x43FEFFFFU) - { - // The number is too large to be represented as a 6e4. Saturate. - return 0x3FFU; - } - else - { - if (IValue < 0x3C800000U) - { - // The number is too small to be represented as a normalized 6e4. - // Convert it to a denormalized value. - const uint32_t Shift = std::min(121U - (IValue >> 23U), 24U); - IValue = (0x800000U | (IValue & 0x7FFFFFU)) >> Shift; - } - else - { - // Rebias the exponent to represent the value as a normalized 6e4. - IValue += 0xC4000000U; - } - - return ((IValue + 0xFFFFU + ((IValue >> 17U) & 1U)) >> 17U) & 0x3FFU; - } - } - - inline float FloatFrom6e4(uint32_t Value) noexcept - { - uint32_t Mantissa = static_cast(Value & 0x3F); - - uint32_t Exponent = (Value & 0x3C0); - if (Exponent != 0) // The value is normalized - { - Exponent = static_cast((Value >> 6) & 0xF); - } - else if (Mantissa != 0) // The value is denormalized - { - // Normalize the value in the resulting float - Exponent = 1; - - do - { - Exponent--; - Mantissa <<= 1; - } - while ((Mantissa & 0x40) == 0); - - Mantissa &= 0x3F; - } - else // The value is zero - { - Exponent = uint32_t(-120); - } - - const uint32_t Result = ((Exponent + 120) << 23) | // Exponent - (Mantissa << 17); // Mantissa - - return reinterpret_cast(&Result)[0]; - } - -#if DIRECTX_MATH_VERSION >= 310 -#define StoreFloat3SE XMStoreFloat3SE -#else - inline void XM_CALLCONV StoreFloat3SE(_Out_ XMFLOAT3SE* pDestination, DirectX::FXMVECTOR V) - { - assert(pDestination); - - DirectX::XMFLOAT3A tmp; - DirectX::XMStoreFloat3A(&tmp, V); - - constexpr float maxf9 = float(0x1FF << 7); - constexpr float minf9 = float(1.f / (1 << 16)); - - float x = (tmp.x >= 0.f) ? ((tmp.x > maxf9) ? maxf9 : tmp.x) : 0.f; - float y = (tmp.y >= 0.f) ? ((tmp.y > maxf9) ? maxf9 : tmp.y) : 0.f; - float z = (tmp.z >= 0.f) ? ((tmp.z > maxf9) ? maxf9 : tmp.z) : 0.f; - - const float max_xy = (x > y) ? x : y; - const float max_xyz = (max_xy > z) ? max_xy : z; - - const float maxColor = (max_xyz > minf9) ? max_xyz : minf9; - - union { float f; int32_t i; } fi; - fi.f = maxColor; - fi.i += 0x00004000; // round up leaving 9 bits in fraction (including assumed 1) - - // Fix applied from DirectXMath 3.10 - uint32_t exp = fi.i >> 23; - pDestination->e = exp - 0x6f; - - fi.i = 0x83000000 - (exp << 23); - float ScaleR = fi.f; - - pDestination->xm = static_cast(lroundf(x * ScaleR)); - pDestination->ym = static_cast(lroundf(y * ScaleR)); - pDestination->zm = static_cast(lroundf(z * ScaleR)); - } -#endif - - const XMVECTORF32 g_Grayscale = { { { 0.2125f, 0.7154f, 0.0721f, 0.0f } } }; - const XMVECTORF32 g_HalfMin = { { { -65504.f, -65504.f, -65504.f, -65504.f } } }; - const XMVECTORF32 g_HalfMax = { { { 65504.f, 65504.f, 65504.f, 65504.f } } }; - const XMVECTORF32 g_8BitBias = { { { 0.5f / 255.f, 0.5f / 255.f, 0.5f / 255.f, 0.5f / 255.f } } }; -} - -//------------------------------------------------------------------------------------- -// Copies an image row with optional clearing of alpha value to 1.0 -// (can be used in place as well) otherwise copies the image row unmodified. -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -void DirectX::Internal::CopyScanline( - void* pDestination, - size_t outSize, - const void* pSource, - size_t inSize, - DXGI_FORMAT format, - uint32_t tflags) noexcept -{ - assert(pDestination && outSize > 0); - assert(pSource && inSize > 0); - assert(IsValid(format) && !IsPalettized(format)); - - if (tflags & TEXP_SCANLINE_SETALPHA) - { - switch (static_cast(format)) - { - //----------------------------------------------------------------------------- - case DXGI_FORMAT_R32G32B32A32_TYPELESS: - case DXGI_FORMAT_R32G32B32A32_FLOAT: - case DXGI_FORMAT_R32G32B32A32_UINT: - case DXGI_FORMAT_R32G32B32A32_SINT: - if (inSize >= 16 && outSize >= 16) - { - uint32_t alpha; - if (format == DXGI_FORMAT_R32G32B32A32_FLOAT) - alpha = 0x3f800000; - else if (format == DXGI_FORMAT_R32G32B32A32_SINT) - alpha = 0x7fffffff; - else - alpha = 0xffffffff; - - if (pDestination == pSource) - { - auto dPtr = static_cast(pDestination); - for (size_t count = 0; count < (outSize - 15); count += 16) - { - dPtr += 3; - *(dPtr++) = alpha; - } - } - else - { - const uint32_t * __restrict sPtr = static_cast(pSource); - uint32_t * __restrict dPtr = static_cast(pDestination); - const size_t size = std::min(outSize, inSize); - for (size_t count = 0; count < (size - 15); count += 16) - { - *(dPtr++) = *(sPtr++); - *(dPtr++) = *(sPtr++); - *(dPtr++) = *(sPtr++); - *(dPtr++) = alpha; - ++sPtr; - } - } - } - return; - - //----------------------------------------------------------------------------- - case DXGI_FORMAT_R16G16B16A16_TYPELESS: - case DXGI_FORMAT_R16G16B16A16_FLOAT: - case DXGI_FORMAT_R16G16B16A16_UNORM: - case DXGI_FORMAT_R16G16B16A16_UINT: - case DXGI_FORMAT_R16G16B16A16_SNORM: - case DXGI_FORMAT_R16G16B16A16_SINT: - case DXGI_FORMAT_Y416: - if (inSize >= 8 && outSize >= 8) - { - uint16_t alpha; - if (format == DXGI_FORMAT_R16G16B16A16_FLOAT) - alpha = 0x3c00; - else if (format == DXGI_FORMAT_R16G16B16A16_SNORM || format == DXGI_FORMAT_R16G16B16A16_SINT) - alpha = 0x7fff; - else - alpha = 0xffff; - - if (pDestination == pSource) - { - auto dPtr = static_cast(pDestination); - for (size_t count = 0; count < (outSize - 7); count += 8) - { - dPtr += 3; - *(dPtr++) = alpha; - } - } - else - { - const uint16_t * __restrict sPtr = static_cast(pSource); - uint16_t * __restrict dPtr = static_cast(pDestination); - const size_t size = std::min(outSize, inSize); - for (size_t count = 0; count < (size - 7); count += 8) - { - *(dPtr++) = *(sPtr++); - *(dPtr++) = *(sPtr++); - *(dPtr++) = *(sPtr++); - *(dPtr++) = alpha; - ++sPtr; - } - } - } - return; - - //----------------------------------------------------------------------------- - case DXGI_FORMAT_R10G10B10A2_TYPELESS: - case DXGI_FORMAT_R10G10B10A2_UNORM: - case DXGI_FORMAT_R10G10B10A2_UINT: - case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: - case DXGI_FORMAT_Y410: - case XBOX_DXGI_FORMAT_R10G10B10_7E3_A2_FLOAT: - case XBOX_DXGI_FORMAT_R10G10B10_6E4_A2_FLOAT: - case XBOX_DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM: - if (inSize >= 4 && outSize >= 4) - { - if (pDestination == pSource) - { - auto dPtr = static_cast(pDestination); - for (size_t count = 0; count < (outSize - 3); count += 4) - { - *dPtr |= 0xC0000000; - ++dPtr; - } - } - else - { - const uint32_t * __restrict sPtr = static_cast(pSource); - uint32_t * __restrict dPtr = static_cast(pDestination); - const size_t size = std::min(outSize, inSize); - for (size_t count = 0; count < (size - 3); count += 4) - { - *(dPtr++) = *(sPtr++) | 0xC0000000; - } - } - } - return; - - //----------------------------------------------------------------------------- - case DXGI_FORMAT_R8G8B8A8_TYPELESS: - case DXGI_FORMAT_R8G8B8A8_UNORM: - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - case DXGI_FORMAT_R8G8B8A8_UINT: - case DXGI_FORMAT_R8G8B8A8_SNORM: - case DXGI_FORMAT_R8G8B8A8_SINT: - case DXGI_FORMAT_B8G8R8A8_UNORM: - case DXGI_FORMAT_B8G8R8A8_TYPELESS: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - case DXGI_FORMAT_AYUV: - if (inSize >= 4 && outSize >= 4) - { - const uint32_t alpha = (format == DXGI_FORMAT_R8G8B8A8_SNORM || format == DXGI_FORMAT_R8G8B8A8_SINT) ? 0x7f000000 : 0xff000000; - - if (pDestination == pSource) - { - auto dPtr = static_cast(pDestination); - for (size_t count = 0; count < (outSize - 3); count += 4) - { - uint32_t t = *dPtr & 0xFFFFFF; - t |= alpha; - *(dPtr++) = t; - } - } - else - { - const uint32_t * __restrict sPtr = static_cast(pSource); - uint32_t * __restrict dPtr = static_cast(pDestination); - const size_t size = std::min(outSize, inSize); - for (size_t count = 0; count < (size - 3); count += 4) - { - uint32_t t = *(sPtr++) & 0xFFFFFF; - t |= alpha; - *(dPtr++) = t; - } - } - } - return; - - //----------------------------------------------------------------------------- - case DXGI_FORMAT_B5G5R5A1_UNORM: - if (inSize >= 2 && outSize >= 2) - { - if (pDestination == pSource) - { - auto dPtr = static_cast(pDestination); - for (size_t count = 0; count < (outSize - 1); count += 2) - { - *(dPtr++) |= 0x8000; - } - } - else - { - const uint16_t * __restrict sPtr = static_cast(pSource); - uint16_t * __restrict dPtr = static_cast(pDestination); - const size_t size = std::min(outSize, inSize); - for (size_t count = 0; count < (size - 1); count += 2) - { - *(dPtr++) = uint16_t(*(sPtr++) | 0x8000); - } - } - } - return; - - //----------------------------------------------------------------------------- - case DXGI_FORMAT_A8_UNORM: - memset(pDestination, 0xff, outSize); - return; - - //----------------------------------------------------------------------------- - case DXGI_FORMAT_B4G4R4A4_UNORM: - if (inSize >= 2 && outSize >= 2) - { - if (pDestination == pSource) - { - auto dPtr = static_cast(pDestination); - for (size_t count = 0; count < (outSize - 1); count += 2) - { - *(dPtr++) |= 0xF000; - } - } - else - { - const uint16_t * __restrict sPtr = static_cast(pSource); - uint16_t * __restrict dPtr = static_cast(pDestination); - const size_t size = std::min(outSize, inSize); - for (size_t count = 0; count < (size - 1); count += 2) - { - *(dPtr++) = uint16_t(*(sPtr++) | 0xF000); - } - } - } - return; - } - } - - // Fall-through case is to just use memcpy (assuming this is not an in-place operation) - if (pDestination == pSource) - return; - - const size_t size = std::min(outSize, inSize); - memcpy(pDestination, pSource, size); -} - - -//------------------------------------------------------------------------------------- -// Swizzles (RGB <-> BGR) an image row with optional clearing of alpha value to 1.0 -// (can be used in place as well) otherwise copies the image row unmodified. -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -void DirectX::Internal::SwizzleScanline( - void* pDestination, - size_t outSize, - const void* pSource, - size_t inSize, - DXGI_FORMAT format, - uint32_t tflags) noexcept -{ - assert(pDestination && outSize > 0); - assert(pSource && inSize > 0); - assert(IsValid(format) && !IsPlanar(format) && !IsPalettized(format)); - - switch (static_cast(format)) - { - //--------------------------------------------------------------------------------- - case DXGI_FORMAT_R10G10B10A2_TYPELESS: - case DXGI_FORMAT_R10G10B10A2_UNORM: - case DXGI_FORMAT_R10G10B10A2_UINT: - case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: - case XBOX_DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM: - if (inSize >= 4 && outSize >= 4) - { - if (tflags & TEXP_SCANLINE_LEGACY) - { - // Swap Red (R) and Blue (B) channel (used for D3DFMT_A2R10G10B10 legacy sources) - if (pDestination == pSource) - { - auto dPtr = static_cast(pDestination); - for (size_t count = 0; count < (outSize - 3); count += 4) - { - const uint32_t t = *dPtr; - - uint32_t t1 = (t & 0x3ff00000) >> 20; - uint32_t t2 = (t & 0x000003ff) << 20; - uint32_t t3 = (t & 0x000ffc00); - uint32_t ta = (tflags & TEXP_SCANLINE_SETALPHA) ? 0xC0000000 : (t & 0xC0000000); - - *(dPtr++) = t1 | t2 | t3 | ta; - } - } - else - { - const uint32_t * __restrict sPtr = static_cast(pSource); - uint32_t * __restrict dPtr = static_cast(pDestination); - const size_t size = std::min(outSize, inSize); - for (size_t count = 0; count < (size - 3); count += 4) - { - const uint32_t t = *(sPtr++); - - uint32_t t1 = (t & 0x3ff00000) >> 20; - uint32_t t2 = (t & 0x000003ff) << 20; - uint32_t t3 = (t & 0x000ffc00); - uint32_t ta = (tflags & TEXP_SCANLINE_SETALPHA) ? 0xC0000000 : (t & 0xC0000000); - - *(dPtr++) = t1 | t2 | t3 | ta; - } - } - return; - } - } - break; - - //--------------------------------------------------------------------------------- - case DXGI_FORMAT_R8G8B8A8_TYPELESS: - case DXGI_FORMAT_R8G8B8A8_UNORM: - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8A8_UNORM: - case DXGI_FORMAT_B8G8R8X8_UNORM: - case DXGI_FORMAT_B8G8R8A8_TYPELESS: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8X8_TYPELESS: - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - if (inSize >= 4 && outSize >= 4) - { - // Swap Red (R) and Blue (B) channels (used to convert from DXGI 1.1 BGR formats to DXGI 1.0 RGB) - if (pDestination == pSource) - { - auto dPtr = static_cast(pDestination); - for (size_t count = 0; count < (outSize - 3); count += 4) - { - const uint32_t t = *dPtr; - - uint32_t t1 = (t & 0x00ff0000) >> 16; - uint32_t t2 = (t & 0x000000ff) << 16; - uint32_t t3 = (t & 0x0000ff00); - uint32_t ta = (tflags & TEXP_SCANLINE_SETALPHA) ? 0xff000000 : (t & 0xFF000000); - - *(dPtr++) = t1 | t2 | t3 | ta; - } - } - else - { - const uint32_t * __restrict sPtr = static_cast(pSource); - uint32_t * __restrict dPtr = static_cast(pDestination); - const size_t size = std::min(outSize, inSize); - for (size_t count = 0; count < (size - 3); count += 4) - { - const uint32_t t = *(sPtr++); - - uint32_t t1 = (t & 0x00ff0000) >> 16; - uint32_t t2 = (t & 0x000000ff) << 16; - uint32_t t3 = (t & 0x0000ff00); - uint32_t ta = (tflags & TEXP_SCANLINE_SETALPHA) ? 0xff000000 : (t & 0xFF000000); - - *(dPtr++) = t1 | t2 | t3 | ta; - } - } - return; - } - break; - - //--------------------------------------------------------------------------------- - case DXGI_FORMAT_YUY2: - if (inSize >= 4 && outSize >= 4) - { - if (tflags & TEXP_SCANLINE_LEGACY) - { - // Reorder YUV components (used to convert legacy UYVY -> YUY2) - if (pDestination == pSource) - { - auto dPtr = static_cast(pDestination); - for (size_t count = 0; count < (outSize - 3); count += 4) - { - const uint32_t t = *dPtr; - - uint32_t t1 = (t & 0x000000ff) << 8; - uint32_t t2 = (t & 0x0000ff00) >> 8; - uint32_t t3 = (t & 0x00ff0000) << 8; - uint32_t t4 = (t & 0xff000000) >> 8; - - *(dPtr++) = t1 | t2 | t3 | t4; - } - } - else - { - const uint32_t * __restrict sPtr = static_cast(pSource); - uint32_t * __restrict dPtr = static_cast(pDestination); - const size_t size = std::min(outSize, inSize); - for (size_t count = 0; count < (size - 3); count += 4) - { - const uint32_t t = *(sPtr++); - - uint32_t t1 = (t & 0x000000ff) << 8; - uint32_t t2 = (t & 0x0000ff00) >> 8; - uint32_t t3 = (t & 0x00ff0000) << 8; - uint32_t t4 = (t & 0xff000000) >> 8; - - *(dPtr++) = t1 | t2 | t3 | t4; - } - } - return; - } - } - break; - } - - // Fall-through case is to just use memcpy (assuming this is not an in-place operation) - if (pDestination == pSource) - return; - - const size_t size = std::min(outSize, inSize); - memcpy(pDestination, pSource, size); -} - - -//------------------------------------------------------------------------------------- -// Converts an image row with optional clearing of alpha value to 1.0 -// Returns true if supported, false if expansion case not supported -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -bool DirectX::Internal::ExpandScanline( - void* pDestination, - size_t outSize, - DXGI_FORMAT outFormat, - const void* pSource, - size_t inSize, - DXGI_FORMAT inFormat, - uint32_t tflags) noexcept -{ - assert(pDestination && outSize > 0); - assert(pSource && inSize > 0); - assert(IsValid(outFormat) && !IsPlanar(outFormat) && !IsPalettized(outFormat)); - assert(IsValid(inFormat) && !IsPlanar(inFormat) && !IsPalettized(inFormat)); - - switch (inFormat) - { - case DXGI_FORMAT_B5G6R5_UNORM: - if (outFormat != DXGI_FORMAT_R8G8B8A8_UNORM) - return false; - - // DXGI_FORMAT_B5G6R5_UNORM -> DXGI_FORMAT_R8G8B8A8_UNORM - if (inSize >= 2 && outSize >= 4) - { - const uint16_t * __restrict sPtr = static_cast(pSource); - uint32_t * __restrict dPtr = static_cast(pDestination); - - for (size_t ocount = 0, icount = 0; ((icount < (inSize - 1)) && (ocount < (outSize - 3))); icount += 2, ocount += 4) - { - const uint16_t t = *(sPtr++); - - uint32_t t1 = uint32_t(((t & 0xf800) >> 8) | ((t & 0xe000) >> 13)); - uint32_t t2 = uint32_t(((t & 0x07e0) << 5) | ((t & 0x0600) >> 5)); - uint32_t t3 = uint32_t(((t & 0x001f) << 19) | ((t & 0x001c) << 14)); - - *(dPtr++) = t1 | t2 | t3 | 0xff000000; - } - return true; - } - return false; - - case DXGI_FORMAT_B5G5R5A1_UNORM: - if (outFormat != DXGI_FORMAT_R8G8B8A8_UNORM) - return false; - - // DXGI_FORMAT_B5G5R5A1_UNORM -> DXGI_FORMAT_R8G8B8A8_UNORM - if (inSize >= 2 && outSize >= 4) - { - const uint16_t * __restrict sPtr = static_cast(pSource); - uint32_t * __restrict dPtr = static_cast(pDestination); - - for (size_t ocount = 0, icount = 0; ((icount < (inSize - 1)) && (ocount < (outSize - 3))); icount += 2, ocount += 4) - { - const uint16_t t = *(sPtr++); - - uint32_t t1 = uint32_t(((t & 0x7c00) >> 7) | ((t & 0x7000) >> 12)); - uint32_t t2 = uint32_t(((t & 0x03e0) << 6) | ((t & 0x0380) << 1)); - uint32_t t3 = uint32_t(((t & 0x001f) << 19) | ((t & 0x001c) << 14)); - uint32_t ta = (tflags & TEXP_SCANLINE_SETALPHA) ? 0xff000000 : ((t & 0x8000) ? 0xff000000 : 0); - - *(dPtr++) = t1 | t2 | t3 | ta; - } - return true; - } - return false; - - case DXGI_FORMAT_B4G4R4A4_UNORM: - if (outFormat != DXGI_FORMAT_R8G8B8A8_UNORM) - return false; - - // DXGI_FORMAT_B4G4R4A4_UNORM -> DXGI_FORMAT_R8G8B8A8_UNORM - if (inSize >= 2 && outSize >= 4) - { - const uint16_t * __restrict sPtr = static_cast(pSource); - uint32_t * __restrict dPtr = static_cast(pDestination); - - for (size_t ocount = 0, icount = 0; ((icount < (inSize - 1)) && (ocount < (outSize - 3))); icount += 2, ocount += 4) - { - const uint16_t t = *(sPtr++); - - uint32_t t1 = uint32_t(((t & 0x0f00) >> 4) | ((t & 0x0f00) >> 8)); - uint32_t t2 = uint32_t(((t & 0x00f0) << 8) | ((t & 0x00f0) << 4)); - uint32_t t3 = uint32_t(((t & 0x000f) << 20) | ((t & 0x000f) << 16)); - uint32_t ta = (tflags & TEXP_SCANLINE_SETALPHA) ? 0xff000000 : uint32_t(((t & 0xf000) << 16) | ((t & 0xf000) << 12)); - - *(dPtr++) = t1 | t2 | t3 | ta; - } - return true; - } - return false; - - default: - return false; - } -} - - -//------------------------------------------------------------------------------------- -// Loads an image row into standard RGBA XMVECTOR (aligned) array -//------------------------------------------------------------------------------------- -#define LOAD_SCANLINE( type, func )\ - if (size >= sizeof(type))\ - {\ - const type * __restrict sPtr = reinterpret_cast(pSource);\ - for(size_t icount = 0; icount < (size - sizeof(type) + 1); icount += sizeof(type))\ - {\ - if (dPtr >= ePtr) break;\ - *(dPtr++) = func(sPtr++);\ - }\ - return true;\ - }\ - return false; - -#define LOAD_SCANLINE3( type, func, defvec )\ - if (size >= sizeof(type))\ - {\ - const type * __restrict sPtr = reinterpret_cast(pSource);\ - for(size_t icount = 0; icount < (size - sizeof(type) + 1); icount += sizeof(type))\ - {\ - const XMVECTOR v = func(sPtr++);\ - if (dPtr >= ePtr) break;\ - *(dPtr++) = XMVectorSelect(defvec, v, g_XMSelect1110);\ - }\ - return true;\ - }\ - return false; - -#define LOAD_SCANLINE2( type, func, defvec )\ - if (size >= sizeof(type))\ - {\ - const type * __restrict sPtr = reinterpret_cast(pSource);\ - for(size_t icount = 0; icount < (size - sizeof(type) + 1); icount += sizeof(type))\ - {\ - const XMVECTOR v = func(sPtr++);\ - if (dPtr >= ePtr) break;\ - *(dPtr++) = XMVectorSelect(defvec, v, g_XMSelect1100);\ - }\ - return true;\ - }\ - return false; - -#pragma warning(suppress: 6101) -_Use_decl_annotations_ bool DirectX::Internal::LoadScanline( - XMVECTOR* pDestination, - size_t count, - const void* pSource, - size_t size, - DXGI_FORMAT format) noexcept -{ - assert(pDestination && count > 0 && ((reinterpret_cast(pDestination) & 0xF) == 0)); - assert(pSource && size > 0); - assert(IsValid(format) && !IsTypeless(format, false) && !IsCompressed(format) && !IsPlanar(format) && !IsPalettized(format)); - - XMVECTOR* __restrict dPtr = pDestination; - if (!dPtr) - return false; - - const XMVECTOR* ePtr = pDestination + count; - - switch (static_cast(format)) - { - case DXGI_FORMAT_R32G32B32A32_FLOAT: - { - const size_t msize = (size > (sizeof(XMVECTOR)*count)) ? (sizeof(XMVECTOR)*count) : size; - memcpy(dPtr, pSource, msize); - } - return true; - - case DXGI_FORMAT_R32G32B32A32_UINT: - LOAD_SCANLINE(XMUINT4, XMLoadUInt4) - - case DXGI_FORMAT_R32G32B32A32_SINT: - LOAD_SCANLINE(XMINT4, XMLoadSInt4) - - case DXGI_FORMAT_R32G32B32_FLOAT: - LOAD_SCANLINE3(XMFLOAT3, XMLoadFloat3, g_XMIdentityR3) - - case DXGI_FORMAT_R32G32B32_UINT: - LOAD_SCANLINE3(XMUINT3, XMLoadUInt3, g_XMIdentityR3) - - case DXGI_FORMAT_R32G32B32_SINT: - LOAD_SCANLINE3(XMINT3, XMLoadSInt3, g_XMIdentityR3) - - case DXGI_FORMAT_R16G16B16A16_FLOAT: - LOAD_SCANLINE(XMHALF4, XMLoadHalf4) - - case DXGI_FORMAT_R16G16B16A16_UNORM: - LOAD_SCANLINE(XMUSHORTN4, XMLoadUShortN4) - - case DXGI_FORMAT_R16G16B16A16_UINT: - LOAD_SCANLINE(XMUSHORT4, XMLoadUShort4) - - case DXGI_FORMAT_R16G16B16A16_SNORM: - LOAD_SCANLINE(XMSHORTN4, XMLoadShortN4) - - case DXGI_FORMAT_R16G16B16A16_SINT: - LOAD_SCANLINE(XMSHORT4, XMLoadShort4) - - case DXGI_FORMAT_R32G32_FLOAT: - LOAD_SCANLINE2(XMFLOAT2, XMLoadFloat2, g_XMIdentityR3) - - case DXGI_FORMAT_R32G32_UINT: - LOAD_SCANLINE2(XMUINT2, XMLoadUInt2, g_XMIdentityR3) - - case DXGI_FORMAT_R32G32_SINT: - LOAD_SCANLINE2(XMINT2, XMLoadSInt2, g_XMIdentityR3) - - case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: - { - constexpr size_t psize = sizeof(float) + sizeof(uint32_t); - if (size >= psize) - { - auto sPtr = static_cast(pSource); - for (size_t icount = 0; icount < (size - psize + 1); icount += psize) - { - auto ps8 = reinterpret_cast(&sPtr[1]); - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSet(sPtr[0], static_cast(*ps8), 0.f, 1.f); - sPtr += 2; - } - return true; - } - } - return false; - - case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: - { - constexpr size_t psize = sizeof(float) + sizeof(uint32_t); - if (size >= psize) - { - auto sPtr = static_cast(pSource); - for (size_t icount = 0; icount < (size - psize + 1); icount += psize) - { - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSet(sPtr[0], 0.f /* typeless component assumed zero */, 0.f, 1.f); - sPtr += 2; - } - return true; - } - } - return false; - - case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: - { - constexpr size_t psize = sizeof(float) + sizeof(uint32_t); - if (size >= psize) - { - auto sPtr = static_cast(pSource); - for (size_t icount = 0; icount < (size - psize + 1); icount += psize) - { - auto pg8 = reinterpret_cast(&sPtr[1]); - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSet(0.f /* typeless component assumed zero */, static_cast(*pg8), 0.f, 1.f); - sPtr += 2; - } - return true; - } - } - return false; - - case DXGI_FORMAT_R10G10B10A2_UNORM: - LOAD_SCANLINE(XMUDECN4, XMLoadUDecN4) - - case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: - LOAD_SCANLINE(XMUDECN4, XMLoadUDecN4_XR) - - case DXGI_FORMAT_R10G10B10A2_UINT: - LOAD_SCANLINE(XMUDEC4, XMLoadUDec4) - - case DXGI_FORMAT_R11G11B10_FLOAT: - LOAD_SCANLINE3(XMFLOAT3PK, XMLoadFloat3PK, g_XMIdentityR3) - - case DXGI_FORMAT_R8G8B8A8_UNORM: - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - LOAD_SCANLINE(XMUBYTEN4, XMLoadUByteN4) - - case DXGI_FORMAT_R8G8B8A8_UINT: - LOAD_SCANLINE(XMUBYTE4, XMLoadUByte4) - - case DXGI_FORMAT_R8G8B8A8_SNORM: - LOAD_SCANLINE(XMBYTEN4, XMLoadByteN4) - - case DXGI_FORMAT_R8G8B8A8_SINT: - LOAD_SCANLINE(XMBYTE4, XMLoadByte4) - - case DXGI_FORMAT_R16G16_FLOAT: - LOAD_SCANLINE2(XMHALF2, XMLoadHalf2, g_XMIdentityR3) - - case DXGI_FORMAT_R16G16_UNORM: - LOAD_SCANLINE2(XMUSHORTN2, XMLoadUShortN2, g_XMIdentityR3) - - case DXGI_FORMAT_R16G16_UINT: - LOAD_SCANLINE2(XMUSHORT2, XMLoadUShort2, g_XMIdentityR3) - - case DXGI_FORMAT_R16G16_SNORM: - LOAD_SCANLINE2(XMSHORTN2, XMLoadShortN2, g_XMIdentityR3) - - case DXGI_FORMAT_R16G16_SINT: - LOAD_SCANLINE2(XMSHORT2, XMLoadShort2, g_XMIdentityR3) - - case DXGI_FORMAT_D32_FLOAT: - case DXGI_FORMAT_R32_FLOAT: - if (size >= sizeof(float)) - { - const float* __restrict sPtr = static_cast(pSource); - for (size_t icount = 0; icount < (size - sizeof(float) + 1); icount += sizeof(float)) - { - const XMVECTOR v = XMLoadFloat(sPtr++); - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSelect(g_XMIdentityR3, v, g_XMSelect1000); - } - return true; - } - return false; - - case DXGI_FORMAT_R32_UINT: - if (size >= sizeof(uint32_t)) - { - const uint32_t* __restrict sPtr = static_cast(pSource); - for (size_t icount = 0; icount < (size - sizeof(uint32_t) + 1); icount += sizeof(uint32_t)) - { - XMVECTOR v = XMLoadInt(sPtr++); - v = XMConvertVectorUIntToFloat(v, 0); - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSelect(g_XMIdentityR3, v, g_XMSelect1000); - } - return true; - } - return false; - - case DXGI_FORMAT_R32_SINT: - if (size >= sizeof(int32_t)) - { - const int32_t * __restrict sPtr = static_cast(pSource); - for (size_t icount = 0; icount < (size - sizeof(int32_t) + 1); icount += sizeof(int32_t)) - { - XMVECTOR v = XMLoadInt(reinterpret_cast(sPtr++)); - v = XMConvertVectorIntToFloat(v, 0); - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSelect(g_XMIdentityR3, v, g_XMSelect1000); - } - return true; - } - return false; - - case DXGI_FORMAT_D24_UNORM_S8_UINT: - if (size >= sizeof(uint32_t)) - { - auto sPtr = static_cast(pSource); - for (size_t icount = 0; icount < (size - sizeof(uint32_t) + 1); icount += sizeof(uint32_t)) - { - auto const d = static_cast(*sPtr & 0xFFFFFF) / 16777215.f; - auto const s = static_cast((*sPtr & 0xFF000000) >> 24); - ++sPtr; - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSet(d, s, 0.f, 1.f); - } - return true; - } - return false; - - case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: - if (size >= sizeof(uint32_t)) - { - auto sPtr = static_cast(pSource); - for (size_t icount = 0; icount < (size - sizeof(uint32_t) + 1); icount += sizeof(uint32_t)) - { - auto const r = static_cast(*sPtr & 0xFFFFFF) / 16777215.f; - ++sPtr; - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSet(r, 0.f /* typeless component assumed zero */, 0.f, 1.f); - } - return true; - } - return false; - - case DXGI_FORMAT_X24_TYPELESS_G8_UINT: - if (size >= sizeof(uint32_t)) - { - auto sPtr = static_cast(pSource); - for (size_t icount = 0; icount < (size - sizeof(uint32_t) + 1); icount += sizeof(uint32_t)) - { - auto const g = static_cast((*sPtr & 0xFF000000) >> 24); - ++sPtr; - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSet(0.f /* typeless component assumed zero */, g, 0.f, 1.f); - } - return true; - } - return false; - - case DXGI_FORMAT_R8G8_UNORM: - LOAD_SCANLINE2(XMUBYTEN2, XMLoadUByteN2, g_XMIdentityR3) - - case DXGI_FORMAT_R8G8_UINT: - LOAD_SCANLINE2(XMUBYTE2, XMLoadUByte2, g_XMIdentityR3) - - case DXGI_FORMAT_R8G8_SNORM: - LOAD_SCANLINE2(XMBYTEN2, XMLoadByteN2, g_XMIdentityR3) - - case DXGI_FORMAT_R8G8_SINT: - LOAD_SCANLINE2(XMBYTE2, XMLoadByte2, g_XMIdentityR3) - - case DXGI_FORMAT_R16_FLOAT: - if (size >= sizeof(HALF)) - { - const HALF * __restrict sPtr = static_cast(pSource); - for (size_t icount = 0; icount < (size - sizeof(HALF) + 1); icount += sizeof(HALF)) - { - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSet(XMConvertHalfToFloat(*sPtr++), 0.f, 0.f, 1.f); - } - return true; - } - return false; - - case DXGI_FORMAT_D16_UNORM: - case DXGI_FORMAT_R16_UNORM: - if (size >= sizeof(uint16_t)) - { - const uint16_t* __restrict sPtr = static_cast(pSource); - for (size_t icount = 0; icount < (size - sizeof(uint16_t) + 1); icount += sizeof(uint16_t)) - { - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSet(static_cast(*sPtr++) / 65535.f, 0.f, 0.f, 1.f); - } - return true; - } - return false; - - case DXGI_FORMAT_R16_UINT: - if (size >= sizeof(uint16_t)) - { - const uint16_t * __restrict sPtr = static_cast(pSource); - for (size_t icount = 0; icount < (size - sizeof(uint16_t) + 1); icount += sizeof(uint16_t)) - { - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSet(static_cast(*sPtr++), 0.f, 0.f, 1.f); - } - return true; - } - return false; - - case DXGI_FORMAT_R16_SNORM: - if (size >= sizeof(int16_t)) - { - const int16_t * __restrict sPtr = static_cast(pSource); - for (size_t icount = 0; icount < (size - sizeof(int16_t) + 1); icount += sizeof(int16_t)) - { - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSet(static_cast(*sPtr++) / 32767.f, 0.f, 0.f, 1.f); - } - return true; - } - return false; - - case DXGI_FORMAT_R16_SINT: - if (size >= sizeof(int16_t)) - { - const int16_t * __restrict sPtr = static_cast(pSource); - for (size_t icount = 0; icount < (size - sizeof(int16_t) + 1); icount += sizeof(int16_t)) - { - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSet(static_cast(*sPtr++), 0.f, 0.f, 1.f); - } - return true; - } - return false; - - case DXGI_FORMAT_R8_UNORM: - if (size >= sizeof(uint8_t)) - { - const uint8_t * __restrict sPtr = static_cast(pSource); - for (size_t icount = 0; icount < size; icount += sizeof(uint8_t)) - { - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSet(static_cast(*sPtr++) / 255.f, 0.f, 0.f, 1.f); - } - return true; - } - return false; - - case DXGI_FORMAT_R8_UINT: - if (size >= sizeof(uint8_t)) - { - const uint8_t * __restrict sPtr = static_cast(pSource); - for (size_t icount = 0; icount < size; icount += sizeof(uint8_t)) - { - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSet(static_cast(*sPtr++), 0.f, 0.f, 1.f); - } - return true; - } - return false; - - case DXGI_FORMAT_R8_SNORM: - if (size >= sizeof(int8_t)) - { - const int8_t * __restrict sPtr = static_cast(pSource); - for (size_t icount = 0; icount < size; icount += sizeof(int8_t)) - { - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSet(static_cast(*sPtr++) / 127.f, 0.f, 0.f, 1.f); - } - return true; - } - return false; - - case DXGI_FORMAT_R8_SINT: - if (size >= sizeof(int8_t)) - { - const int8_t * __restrict sPtr = static_cast(pSource); - for (size_t icount = 0; icount < size; icount += sizeof(int8_t)) - { - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSet(static_cast(*sPtr++), 0.f, 0.f, 1.f); - } - return true; - } - return false; - - case DXGI_FORMAT_A8_UNORM: - if (size >= sizeof(uint8_t)) - { - const uint8_t * __restrict sPtr = static_cast(pSource); - for (size_t icount = 0; icount < size; icount += sizeof(uint8_t)) - { - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSet(0.f, 0.f, 0.f, static_cast(*sPtr++) / 255.f); - } - return true; - } - return false; - - case DXGI_FORMAT_R1_UNORM: - if (size >= sizeof(uint8_t)) - { - const uint8_t * __restrict sPtr = static_cast(pSource); - for (size_t icount = 0; icount < size; icount += sizeof(uint8_t)) - { - for (size_t bcount = 8; bcount > 0; --bcount) - { - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSet((((*sPtr >> (bcount - 1)) & 0x1) ? 1.f : 0.f), 0.f, 0.f, 1.f); - } - - ++sPtr; - } - return true; - } - return false; - - case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: - LOAD_SCANLINE3(XMFLOAT3SE, XMLoadFloat3SE, g_XMIdentityR3) - - case DXGI_FORMAT_R8G8_B8G8_UNORM: - if (size >= sizeof(XMUBYTEN4)) - { - const XMUBYTEN4 * __restrict sPtr = static_cast(pSource); - for (size_t icount = 0; icount < (size - sizeof(XMUBYTEN4) + 1); icount += sizeof(XMUBYTEN4)) - { - const XMVECTOR v = XMLoadUByteN4(sPtr++); - const XMVECTOR v1 = XMVectorSwizzle<0, 3, 2, 1>(v); - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSelect(g_XMIdentityR3, v, g_XMSelect1110); - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSelect(g_XMIdentityR3, v1, g_XMSelect1110); - } - return true; - } - return false; - - case DXGI_FORMAT_G8R8_G8B8_UNORM: - if (size >= sizeof(XMUBYTEN4)) - { - const XMUBYTEN4 * __restrict sPtr = static_cast(pSource); - for (size_t icount = 0; icount < (size - sizeof(XMUBYTEN4) + 1); icount += sizeof(XMUBYTEN4)) - { - const XMVECTOR v = XMLoadUByteN4(sPtr++); - const XMVECTOR v0 = XMVectorSwizzle<1, 0, 3, 2>(v); - const XMVECTOR v1 = XMVectorSwizzle<1, 2, 3, 0>(v); - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSelect(g_XMIdentityR3, v0, g_XMSelect1110); - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSelect(g_XMIdentityR3, v1, g_XMSelect1110); - } - return true; - } - return false; - - case DXGI_FORMAT_B5G6R5_UNORM: - if (size >= sizeof(XMU565)) - { - static const XMVECTORF32 s_Scale = { { { 1.f / 31.f, 1.f / 63.f, 1.f / 31.f, 1.f } } }; - const XMU565 * __restrict sPtr = static_cast(pSource); - for (size_t icount = 0; icount < (size - sizeof(XMU565) + 1); icount += sizeof(XMU565)) - { - XMVECTOR v = XMLoadU565(sPtr++); - v = XMVectorMultiply(v, s_Scale); - v = XMVectorSwizzle<2, 1, 0, 3>(v); - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSelect(g_XMIdentityR3, v, g_XMSelect1110); - } - return true; - } - return false; - - case DXGI_FORMAT_B5G5R5A1_UNORM: - if (size >= sizeof(XMU555)) - { - static const XMVECTORF32 s_Scale = { { { 1.f / 31.f, 1.f / 31.f, 1.f / 31.f, 1.f } } }; - const XMU555 * __restrict sPtr = static_cast(pSource); - for (size_t icount = 0; icount < (size - sizeof(XMU555) + 1); icount += sizeof(XMU555)) - { - XMVECTOR v = XMLoadU555(sPtr++); - v = XMVectorMultiply(v, s_Scale); - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSwizzle<2, 1, 0, 3>(v); - } - return true; - } - return false; - - case DXGI_FORMAT_B8G8R8A8_UNORM: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - if (size >= sizeof(XMUBYTEN4)) - { - const XMUBYTEN4 * __restrict sPtr = static_cast(pSource); - for (size_t icount = 0; icount < (size - sizeof(XMUBYTEN4) + 1); icount += sizeof(XMUBYTEN4)) - { - const XMVECTOR v = XMLoadUByteN4(sPtr++); - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSwizzle<2, 1, 0, 3>(v); - } - return true; - } - return false; - - case DXGI_FORMAT_B8G8R8X8_UNORM: - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - if (size >= sizeof(XMUBYTEN4)) - { - const XMUBYTEN4 * __restrict sPtr = static_cast(pSource); - for (size_t icount = 0; icount < (size - sizeof(XMUBYTEN4) + 1); icount += sizeof(XMUBYTEN4)) - { - XMVECTOR v = XMLoadUByteN4(sPtr++); - v = XMVectorSwizzle<2, 1, 0, 3>(v); - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSelect(g_XMIdentityR3, v, g_XMSelect1110); - } - return true; - } - return false; - - case DXGI_FORMAT_AYUV: - if (size >= sizeof(XMUBYTEN4)) - { - const XMUBYTEN4 * __restrict sPtr = static_cast(pSource); - for (size_t icount = 0; icount < (size - sizeof(XMUBYTEN4) + 1); icount += sizeof(XMUBYTEN4)) - { - const int v = int(sPtr->x) - 128; - const int u = int(sPtr->y) - 128; - const int y = int(sPtr->z) - 16; - const unsigned int a = sPtr->w; - ++sPtr; - - // http://msdn.microsoft.com/en-us/library/windows/desktop/dd206750.aspx - - // Y' = Y - 16 - // Cb' = Cb - 128 - // Cr' = Cr - 128 - - // R = 1.1644Y' + 1.5960Cr' - // G = 1.1644Y' - 0.3917Cb' - 0.8128Cr' - // B = 1.1644Y' + 2.0172Cb' - - const int r = (298 * y + 409 * v + 128) >> 8; - const int g = (298 * y - 100 * u - 208 * v + 128) >> 8; - const int b = (298 * y + 516 * u + 128) >> 8; - - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSet(float(std::min(std::max(r, 0), 255)) / 255.f, - float(std::min(std::max(g, 0), 255)) / 255.f, - float(std::min(std::max(b, 0), 255)) / 255.f, - float(a) / 255.f); - } - return true; - } - return false; - - case DXGI_FORMAT_Y410: - if (size >= sizeof(XMUDECN4)) - { - const XMUDECN4 * __restrict sPtr = static_cast(pSource); - for (size_t icount = 0; icount < (size - sizeof(XMUDECN4) + 1); icount += sizeof(XMUDECN4)) - { - const int64_t u = int(sPtr->x) - 512; - const int64_t y = int(sPtr->y) - 64; - const int64_t v = int(sPtr->z) - 512; - const unsigned int a = sPtr->w; - ++sPtr; - - // http://msdn.microsoft.com/en-us/library/windows/desktop/bb970578.aspx - - // Y' = Y - 64 - // Cb' = Cb - 512 - // Cr' = Cr - 512 - - // R = 1.1678Y' + 1.6007Cr' - // G = 1.1678Y' - 0.3929Cb' - 0.8152Cr' - // B = 1.1678Y' + 2.0232Cb' - - auto const r = static_cast((76533 * y + 104905 * v + 32768) >> 16); - auto const g = static_cast((76533 * y - 25747 * u - 53425 * v + 32768) >> 16); - auto const b = static_cast((76533 * y + 132590 * u + 32768) >> 16); - - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSet(float(std::min(std::max(r, 0), 1023)) / 1023.f, - float(std::min(std::max(g, 0), 1023)) / 1023.f, - float(std::min(std::max(b, 0), 1023)) / 1023.f, - float(a) / 3.f); - } - return true; - } - return false; - - case DXGI_FORMAT_Y416: - if (size >= sizeof(XMUSHORTN4)) - { - const XMUSHORTN4 * __restrict sPtr = static_cast(pSource); - for (size_t icount = 0; icount < (size - sizeof(XMUSHORTN4) + 1); icount += sizeof(XMUSHORTN4)) - { - const int64_t u = int64_t(sPtr->x) - 32768; - const int64_t y = int64_t(sPtr->y) - 4096; - const int64_t v = int64_t(sPtr->z) - 32768; - auto const a = static_cast(sPtr->w); - ++sPtr; - - // http://msdn.microsoft.com/en-us/library/windows/desktop/bb970578.aspx - - // Y' = Y - 4096 - // Cb' = Cb - 32768 - // Cr' = Cr - 32768 - - // R = 1.1689Y' + 1.6023Cr' - // G = 1.1689Y' - 0.3933Cb' - 0.8160Cr' - // B = 1.1689Y'+ 2.0251Cb' - - auto const r = static_cast((76607 * y + 105006 * v + 32768) >> 16); - auto const g = static_cast((76607 * y - 25772 * u - 53477 * v + 32768) >> 16); - auto const b = static_cast((76607 * y + 132718 * u + 32768) >> 16); - - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSet(float(std::min(std::max(r, 0), 65535)) / 65535.f, - float(std::min(std::max(g, 0), 65535)) / 65535.f, - float(std::min(std::max(b, 0), 65535)) / 65535.f, - float(std::min(std::max(a, 0), 65535)) / 65535.f); - } - return true; - } - return false; - - case DXGI_FORMAT_YUY2: - if (size >= sizeof(XMUBYTEN4)) - { - const XMUBYTEN4 * __restrict sPtr = static_cast(pSource); - for (size_t icount = 0; icount < (size - sizeof(XMUBYTEN4) + 1); icount += sizeof(XMUBYTEN4)) - { - const int y0 = int(sPtr->x) - 16; - const int u = int(sPtr->y) - 128; - const int y1 = int(sPtr->z) - 16; - const int v = int(sPtr->w) - 128; - ++sPtr; - - // See AYUV - int r = (298 * y0 + 409 * v + 128) >> 8; - int g = (298 * y0 - 100 * u - 208 * v + 128) >> 8; - int b = (298 * y0 + 516 * u + 128) >> 8; - - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSet(float(std::min(std::max(r, 0), 255)) / 255.f, - float(std::min(std::max(g, 0), 255)) / 255.f, - float(std::min(std::max(b, 0), 255)) / 255.f, - 1.f); - - r = (298 * y1 + 409 * v + 128) >> 8; - g = (298 * y1 - 100 * u - 208 * v + 128) >> 8; - b = (298 * y1 + 516 * u + 128) >> 8; - - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSet(float(std::min(std::max(r, 0), 255)) / 255.f, - float(std::min(std::max(g, 0), 255)) / 255.f, - float(std::min(std::max(b, 0), 255)) / 255.f, - 1.f); - } - return true; - } - return false; - - case DXGI_FORMAT_Y210: - // Same as Y216 with least significant 6 bits set to zero - if (size >= sizeof(XMUSHORTN4)) - { - const XMUSHORTN4 * __restrict sPtr = static_cast(pSource); - for (size_t icount = 0; icount < (size - sizeof(XMUSHORTN4) + 1); icount += sizeof(XMUSHORTN4)) - { - const int64_t y0 = int64_t(sPtr->x >> 6) - 64; - const int64_t u = int64_t(sPtr->y >> 6) - 512; - const int64_t y1 = int64_t(sPtr->z >> 6) - 64; - const int64_t v = int64_t(sPtr->w >> 6) - 512; - ++sPtr; - - // See Y410 - auto r = static_cast((76533 * y0 + 104905 * v + 32768) >> 16); - auto g = static_cast((76533 * y0 - 25747 * u - 53425 * v + 32768) >> 16); - auto b = static_cast((76533 * y0 + 132590 * u + 32768) >> 16); - - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSet(float(std::min(std::max(r, 0), 1023)) / 1023.f, - float(std::min(std::max(g, 0), 1023)) / 1023.f, - float(std::min(std::max(b, 0), 1023)) / 1023.f, - 1.f); - - r = static_cast((76533 * y1 + 104905 * v + 32768) >> 16); - g = static_cast((76533 * y1 - 25747 * u - 53425 * v + 32768) >> 16); - b = static_cast((76533 * y1 + 132590 * u + 32768) >> 16); - - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSet(float(std::min(std::max(r, 0), 1023)) / 1023.f, - float(std::min(std::max(g, 0), 1023)) / 1023.f, - float(std::min(std::max(b, 0), 1023)) / 1023.f, - 1.f); - } - return true; - } - return false; - - case DXGI_FORMAT_Y216: - if (size >= sizeof(XMUSHORTN4)) - { - const XMUSHORTN4 * __restrict sPtr = static_cast(pSource); - for (size_t icount = 0; icount < (size - sizeof(XMUSHORTN4) + 1); icount += sizeof(XMUSHORTN4)) - { - const int64_t y0 = int64_t(sPtr->x) - 4096; - const int64_t u = int64_t(sPtr->y) - 32768; - const int64_t y1 = int64_t(sPtr->z) - 4096; - const int64_t v = int64_t(sPtr->w) - 32768; - ++sPtr; - - // See Y416 - auto r = static_cast((76607 * y0 + 105006 * v + 32768) >> 16); - auto g = static_cast((76607 * y0 - 25772 * u - 53477 * v + 32768) >> 16); - auto b = static_cast((76607 * y0 + 132718 * u + 32768) >> 16); - - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSet(float(std::min(std::max(r, 0), 65535)) / 65535.f, - float(std::min(std::max(g, 0), 65535)) / 65535.f, - float(std::min(std::max(b, 0), 65535)) / 65535.f, - 1.f); - - r = static_cast((76607 * y1 + 105006 * v + 32768) >> 16); - g = static_cast((76607 * y1 - 25772 * u - 53477 * v + 32768) >> 16); - b = static_cast((76607 * y1 + 132718 * u + 32768) >> 16); - - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSet(float(std::min(std::max(r, 0), 65535)) / 65535.f, - float(std::min(std::max(g, 0), 65535)) / 65535.f, - float(std::min(std::max(b, 0), 65535)) / 65535.f, - 1.f); - } - return true; - } - return false; - - case DXGI_FORMAT_B4G4R4A4_UNORM: - if (size >= sizeof(XMUNIBBLE4)) - { - static const XMVECTORF32 s_Scale = { { { 1.f / 15.f, 1.f / 15.f, 1.f / 15.f, 1.f / 15.f } } }; - const XMUNIBBLE4 * __restrict sPtr = static_cast(pSource); - for (size_t icount = 0; icount < (size - sizeof(XMUNIBBLE4) + 1); icount += sizeof(XMUNIBBLE4)) - { - XMVECTOR v = XMLoadUNibble4(sPtr++); - v = XMVectorMultiply(v, s_Scale); - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSwizzle<2, 1, 0, 3>(v); - } - return true; - } - return false; - - case XBOX_DXGI_FORMAT_R10G10B10_7E3_A2_FLOAT: - // Xbox One specific 7e3 format - if (size >= sizeof(XMUDECN4)) - { - const XMUDECN4 * __restrict sPtr = static_cast(pSource); - for (size_t icount = 0; icount < (size - sizeof(XMUDECN4) + 1); icount += sizeof(XMUDECN4)) - { - if (dPtr >= ePtr) break; - - XMVECTORF32 vResult = { { { - FloatFrom7e3(sPtr->x), - FloatFrom7e3(sPtr->y), - FloatFrom7e3(sPtr->z), - static_cast(sPtr->v >> 30) / 3.0f - } } }; - - ++sPtr; - - *(dPtr++) = vResult.v; - } - return true; - } - return false; - - case XBOX_DXGI_FORMAT_R10G10B10_6E4_A2_FLOAT: - // Xbox One specific 6e4 format - if (size >= sizeof(XMUDECN4)) - { - const XMUDECN4 * __restrict sPtr = static_cast(pSource); - for (size_t icount = 0; icount < (size - sizeof(XMUDECN4) + 1); icount += sizeof(XMUDECN4)) - { - if (dPtr >= ePtr) break; - - XMVECTORF32 vResult = { { { - FloatFrom6e4(sPtr->x), - FloatFrom6e4(sPtr->y), - FloatFrom6e4(sPtr->z), - static_cast(sPtr->v >> 30) / 3.0f - } } }; - - ++sPtr; - - *(dPtr++) = vResult.v; - } - return true; - } - return false; - - case XBOX_DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM: - // Xbox One specific format - LOAD_SCANLINE(XMXDECN4, XMLoadXDecN4) - - case XBOX_DXGI_FORMAT_R4G4_UNORM: - // Xbox One specific format - if (size >= sizeof(uint8_t)) - { - static const XMVECTORF32 s_Scale = { { { 1.f / 15.f, 1.f / 15.f, 0.f, 0.f } } }; - const uint8_t * __restrict sPtr = static_cast(pSource); - for (size_t icount = 0; icount < (size - sizeof(uint8_t) + 1); icount += sizeof(uint8_t)) - { - XMUNIBBLE4 nibble; - nibble.v = static_cast(*sPtr++); - XMVECTOR v = XMLoadUNibble4(&nibble); - v = XMVectorMultiply(v, s_Scale); - if (dPtr >= ePtr) break; - *(dPtr++) = XMVectorSelect(g_XMIdentityR3, v, g_XMSelect1100); - } - return true; - } - return false; - - // We don't support the planar or palettized formats - - default: - return false; - } -} - -#undef LOAD_SCANLINE -#undef LOAD_SCANLINE3 -#undef LOAD_SCANLINE2 - - -//------------------------------------------------------------------------------------- -// Stores an image row from standard RGBA XMVECTOR (aligned) array -//------------------------------------------------------------------------------------- -#define STORE_SCANLINE( type, func )\ - if (size >= sizeof(type))\ - {\ - type * __restrict dPtr = reinterpret_cast(pDestination);\ - for(size_t icount = 0; icount < (size - sizeof(type) + 1); icount += sizeof(type))\ - {\ - if (sPtr >= ePtr) break;\ - func(dPtr++, *sPtr++);\ - }\ - return true; \ - }\ - return false; - -_Use_decl_annotations_ -bool DirectX::Internal::StoreScanline( - void* pDestination, - size_t size, - DXGI_FORMAT format, - const XMVECTOR* pSource, - size_t count, - float threshold) noexcept -{ - assert(pDestination != nullptr); - assert(IsValid(format) && !IsTypeless(format) && !IsCompressed(format) && !IsPlanar(format) && !IsPalettized(format)); - - if (!size || !count) - return false; - - const XMVECTOR* __restrict sPtr = pSource; - if (!sPtr) - return false; - - assert((reinterpret_cast(pSource) & 0xF) == 0); - - const XMVECTOR* ePtr = sPtr + count; - -#ifdef _PREFAST_ - *reinterpret_cast(pDestination) = 0; -#endif - - switch (static_cast(format)) - { - case DXGI_FORMAT_R32G32B32A32_FLOAT: - STORE_SCANLINE(XMFLOAT4, XMStoreFloat4) - - case DXGI_FORMAT_R32G32B32A32_UINT: - STORE_SCANLINE(XMUINT4, XMStoreUInt4) - - case DXGI_FORMAT_R32G32B32A32_SINT: - STORE_SCANLINE(XMINT4, XMStoreSInt4) - - case DXGI_FORMAT_R32G32B32_FLOAT: - STORE_SCANLINE(XMFLOAT3, XMStoreFloat3) - - case DXGI_FORMAT_R32G32B32_UINT: - STORE_SCANLINE(XMUINT3, XMStoreUInt3) - - case DXGI_FORMAT_R32G32B32_SINT: - STORE_SCANLINE(XMINT3, XMStoreSInt3) - - case DXGI_FORMAT_R16G16B16A16_FLOAT: - if (size >= sizeof(XMHALF4)) - { - XMHALF4* __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < (size - sizeof(XMHALF4) + 1); icount += sizeof(XMHALF4)) - { - if (sPtr >= ePtr) break; - XMVECTOR v = *sPtr++; - v = XMVectorClamp(v, g_HalfMin, g_HalfMax); - XMStoreHalf4(dPtr++, v); - } - return true; - } - return false; - - case DXGI_FORMAT_R16G16B16A16_UNORM: - STORE_SCANLINE(XMUSHORTN4, XMStoreUShortN4) - - case DXGI_FORMAT_R16G16B16A16_UINT: - STORE_SCANLINE(XMUSHORT4, XMStoreUShort4) - - case DXGI_FORMAT_R16G16B16A16_SNORM: - STORE_SCANLINE(XMSHORTN4, XMStoreShortN4) - - case DXGI_FORMAT_R16G16B16A16_SINT: - STORE_SCANLINE(XMSHORT4, XMStoreShort4) - - case DXGI_FORMAT_R32G32_FLOAT: - STORE_SCANLINE(XMFLOAT2, XMStoreFloat2) - - case DXGI_FORMAT_R32G32_UINT: - STORE_SCANLINE(XMUINT2, XMStoreUInt2) - - case DXGI_FORMAT_R32G32_SINT: - STORE_SCANLINE(XMINT2, XMStoreSInt2) - - case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: - { - constexpr size_t psize = sizeof(float) + sizeof(uint32_t); - if (size >= psize) - { - auto dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < (size - psize + 1); icount += psize) - { - if (sPtr >= ePtr) break; - XMFLOAT4 f; - XMStoreFloat4(&f, *sPtr++); - dPtr[0] = f.x; - auto ps8 = reinterpret_cast(&dPtr[1]); - ps8[0] = static_cast(std::min(255.f, std::max(0.f, f.y))); - ps8[1] = ps8[2] = ps8[3] = 0; - dPtr += 2; - } - return true; - } - } - return false; - - case DXGI_FORMAT_R10G10B10A2_UNORM: - STORE_SCANLINE(XMUDECN4, XMStoreUDecN4) - - case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: - STORE_SCANLINE(XMUDECN4, XMStoreUDecN4_XR) - - case DXGI_FORMAT_R10G10B10A2_UINT: - STORE_SCANLINE(XMUDEC4, XMStoreUDec4) - - case DXGI_FORMAT_R11G11B10_FLOAT: - STORE_SCANLINE(XMFLOAT3PK, XMStoreFloat3PK) - - case DXGI_FORMAT_R8G8B8A8_UNORM: - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - if (size >= sizeof(XMUBYTEN4)) - { - XMUBYTEN4 * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < (size - sizeof(XMUBYTEN4) + 1); icount += sizeof(XMUBYTEN4)) - { - if (sPtr >= ePtr) break; - const XMVECTOR v = XMVectorAdd(*sPtr++, g_8BitBias); - XMStoreUByteN4(dPtr++, v); - } - return true; - } - return false; - - case DXGI_FORMAT_R8G8B8A8_UINT: - STORE_SCANLINE(XMUBYTE4, XMStoreUByte4) - - case DXGI_FORMAT_R8G8B8A8_SNORM: - STORE_SCANLINE(XMBYTEN4, XMStoreByteN4) - - case DXGI_FORMAT_R8G8B8A8_SINT: - STORE_SCANLINE(XMBYTE4, XMStoreByte4) - - case DXGI_FORMAT_R16G16_FLOAT: - if (size >= sizeof(XMHALF2)) - { - XMHALF2* __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < (size - sizeof(XMHALF2) + 1); icount += sizeof(XMHALF2)) - { - if (sPtr >= ePtr) break; - XMVECTOR v = *sPtr++; - v = XMVectorClamp(v, g_HalfMin, g_HalfMax); - XMStoreHalf2(dPtr++, v); - } - return true; - } - return false; - - case DXGI_FORMAT_R16G16_UNORM: - STORE_SCANLINE(XMUSHORTN2, XMStoreUShortN2) - - case DXGI_FORMAT_R16G16_UINT: - STORE_SCANLINE(XMUSHORT2, XMStoreUShort2) - - case DXGI_FORMAT_R16G16_SNORM: - STORE_SCANLINE(XMSHORTN2, XMStoreShortN2) - - case DXGI_FORMAT_R16G16_SINT: - STORE_SCANLINE(XMSHORT2, XMStoreShort2) - - case DXGI_FORMAT_D32_FLOAT: - case DXGI_FORMAT_R32_FLOAT: - if (size >= sizeof(float)) - { - float * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < (size - sizeof(float) + 1); icount += sizeof(float)) - { - if (sPtr >= ePtr) break; - XMStoreFloat(dPtr++, *(sPtr++)); - } - return true; - } - return false; - - case DXGI_FORMAT_R32_UINT: - if (size >= sizeof(uint32_t)) - { - uint32_t * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < (size - sizeof(uint32_t) + 1); icount += sizeof(uint32_t)) - { - if (sPtr >= ePtr) break; - const XMVECTOR v = XMConvertVectorFloatToUInt(*(sPtr++), 0); - XMStoreInt(dPtr++, v); - } - return true; - } - return false; - - case DXGI_FORMAT_R32_SINT: - if (size >= sizeof(int32_t)) - { - uint32_t * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < (size - sizeof(int32_t) + 1); icount += sizeof(int32_t)) - { - if (sPtr >= ePtr) break; - const XMVECTOR v = XMConvertVectorFloatToInt(*(sPtr++), 0); - XMStoreInt(dPtr++, v); - } - return true; - } - return false; - - case DXGI_FORMAT_D24_UNORM_S8_UINT: - if (size >= sizeof(uint32_t)) - { - static const XMVECTORF32 clamp = { { { 1.f, 255.f, 0.f, 0.f } } }; - const XMVECTOR zero = XMVectorZero(); - auto dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < (size - sizeof(uint32_t) + 1); icount += sizeof(uint32_t)) - { - if (sPtr >= ePtr) break; - XMFLOAT4 f; - XMStoreFloat4(&f, XMVectorClamp(*sPtr++, zero, clamp)); - *dPtr++ = (static_cast(f.x * 16777215.f) & 0xFFFFFF) - | ((static_cast(f.y) & 0xFF) << 24); - } - return true; - } - return false; - - case DXGI_FORMAT_R8G8_UNORM: - STORE_SCANLINE(XMUBYTEN2, XMStoreUByteN2) - - case DXGI_FORMAT_R8G8_UINT: - STORE_SCANLINE(XMUBYTE2, XMStoreUByte2) - - case DXGI_FORMAT_R8G8_SNORM: - STORE_SCANLINE(XMBYTEN2, XMStoreByteN2) - - case DXGI_FORMAT_R8G8_SINT: - STORE_SCANLINE(XMBYTE2, XMStoreByte2) - - case DXGI_FORMAT_R16_FLOAT: - if (size >= sizeof(HALF)) - { - HALF * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < (size - sizeof(HALF) + 1); icount += sizeof(HALF)) - { - if (sPtr >= ePtr) break; - float v = XMVectorGetX(*sPtr++); - v = std::max(std::min(v, 65504.f), -65504.f); - *(dPtr++) = XMConvertFloatToHalf(v); - } - return true; - } - return false; - - case DXGI_FORMAT_D16_UNORM: - case DXGI_FORMAT_R16_UNORM: - if (size >= sizeof(uint16_t)) - { - uint16_t * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < (size - sizeof(uint16_t) + 1); icount += sizeof(uint16_t)) - { - if (sPtr >= ePtr) break; - float v = XMVectorGetX(*sPtr++); - v = std::max(std::min(v, 1.f), 0.f); - *(dPtr++) = static_cast(v*65535.f + 0.5f); - } - return true; - } - return false; - - case DXGI_FORMAT_R16_UINT: - if (size >= sizeof(uint16_t)) - { - uint16_t * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < (size - sizeof(uint16_t) + 1); icount += sizeof(uint16_t)) - { - if (sPtr >= ePtr) break; - float v = XMVectorGetX(*sPtr++); - v = std::max(std::min(v, 65535.f), 0.f); - *(dPtr++) = static_cast(v); - } - return true; - } - return false; - - case DXGI_FORMAT_R16_SNORM: - if (size >= sizeof(int16_t)) - { - int16_t * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < (size - sizeof(int16_t) + 1); icount += sizeof(int16_t)) - { - if (sPtr >= ePtr) break; - float v = XMVectorGetX(*sPtr++); - v = std::max(std::min(v, 1.f), -1.f); - *(dPtr++) = static_cast(lroundf(v * 32767.f)); - } - return true; - } - return false; - - case DXGI_FORMAT_R16_SINT: - if (size >= sizeof(int16_t)) - { - int16_t * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < (size - sizeof(int16_t) + 1); icount += sizeof(int16_t)) - { - if (sPtr >= ePtr) break; - float v = XMVectorGetX(*sPtr++); - v = std::max(std::min(v, 32767.f), -32767.f); - *(dPtr++) = static_cast(v); - } - return true; - } - return false; - - case DXGI_FORMAT_R8_UNORM: - if (size >= sizeof(uint8_t)) - { - uint8_t * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < size; icount += sizeof(uint8_t)) - { - if (sPtr >= ePtr) break; - float v = XMVectorGetX(*sPtr++); - v = std::max(std::min(v, 1.f), 0.f); - *(dPtr++) = static_cast(v * 255.f); - } - return true; - } - return false; - - case DXGI_FORMAT_R8_UINT: - if (size >= sizeof(uint8_t)) - { - uint8_t * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < size; icount += sizeof(uint8_t)) - { - if (sPtr >= ePtr) break; - float v = XMVectorGetX(*sPtr++); - v = std::max(std::min(v, 255.f), 0.f); - *(dPtr++) = static_cast(v); - } - return true; - } - return false; - - case DXGI_FORMAT_R8_SNORM: - if (size >= sizeof(int8_t)) - { - int8_t * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < size; icount += sizeof(int8_t)) - { - if (sPtr >= ePtr) break; - float v = XMVectorGetX(*sPtr++); - v = std::max(std::min(v, 1.f), -1.f); - *(dPtr++) = static_cast(lroundf(v * 127.f)); - } - return true; - } - return false; - - case DXGI_FORMAT_R8_SINT: - if (size >= sizeof(int8_t)) - { - int8_t * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < size; icount += sizeof(int8_t)) - { - if (sPtr >= ePtr) break; - float v = XMVectorGetX(*sPtr++); - v = std::max(std::min(v, 127.f), -127.f); - *(dPtr++) = static_cast(v); - } - return true; - } - return false; - - case DXGI_FORMAT_A8_UNORM: - if (size >= sizeof(uint8_t)) - { - uint8_t * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < size; icount += sizeof(uint8_t)) - { - if (sPtr >= ePtr) break; - float v = XMVectorGetW(*sPtr++); - v = std::max(std::min(v, 1.f), 0.f); - *(dPtr++) = static_cast(v * 255.f); - } - return true; - } - return false; - - case DXGI_FORMAT_R1_UNORM: - if (size >= sizeof(uint8_t)) - { - uint8_t * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < size; icount += sizeof(uint8_t)) - { - uint8_t pixels = 0; - for (size_t bcount = 8; bcount > 0; --bcount) - { - if (sPtr >= ePtr) break; - const float v = XMVectorGetX(*sPtr++); - - // Absolute thresholding generally doesn't give good results for all images - // Picking the 'right' threshold automatically requires whole-image analysis - - if (v > 0.25f) - pixels |= 1 << (bcount - 1); - } - *(dPtr++) = pixels; - } - return true; - } - return false; - - case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: - STORE_SCANLINE(XMFLOAT3SE, StoreFloat3SE) - - case DXGI_FORMAT_R8G8_B8G8_UNORM: - if (size >= sizeof(XMUBYTEN4)) - { - XMUBYTEN4 * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < (size - sizeof(XMUBYTEN4) + 1); icount += sizeof(XMUBYTEN4)) - { - if (sPtr >= ePtr) break; - const XMVECTOR v0 = *sPtr++; - const XMVECTOR v1 = (sPtr < ePtr) ? XMVectorSplatY(*sPtr++) : XMVectorZero(); - XMVECTOR v = XMVectorSelect(v1, v0, g_XMSelect1110); - v = XMVectorAdd(v, g_8BitBias); - XMStoreUByteN4(dPtr++, v); - } - return true; - } - return false; - - case DXGI_FORMAT_G8R8_G8B8_UNORM: - if (size >= sizeof(XMUBYTEN4)) - { - static XMVECTORU32 select1101 = { { { XM_SELECT_1, XM_SELECT_1, XM_SELECT_0, XM_SELECT_1 } } }; - - XMUBYTEN4 * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < (size - sizeof(XMUBYTEN4) + 1); icount += sizeof(XMUBYTEN4)) - { - if (sPtr >= ePtr) break; - const XMVECTOR v0 = XMVectorSwizzle<1, 0, 3, 2>(*sPtr++); - const XMVECTOR v1 = (sPtr < ePtr) ? XMVectorSplatY(*sPtr++) : XMVectorZero(); - XMVECTOR v = XMVectorSelect(v1, v0, select1101); - v = XMVectorAdd(v, g_8BitBias); - XMStoreUByteN4(dPtr++, v); - } - return true; - } - return false; - - case DXGI_FORMAT_B5G6R5_UNORM: - if (size >= sizeof(XMU565)) - { - static const XMVECTORF32 s_Scale = { { { 31.f, 63.f, 31.f, 1.f } } }; - XMU565 * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < (size - sizeof(XMU565) + 1); icount += sizeof(XMU565)) - { - if (sPtr >= ePtr) break; - XMVECTOR v = XMVectorSwizzle<2, 1, 0, 3>(*sPtr++); - v = XMVectorMultiply(v, s_Scale); - XMStoreU565(dPtr++, v); - } - return true; - } - return false; - - case DXGI_FORMAT_B5G5R5A1_UNORM: - if (size >= sizeof(XMU555)) - { - static const XMVECTORF32 s_Scale = { { { 31.f, 31.f, 31.f, 1.f } } }; - XMU555 * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < (size - sizeof(XMU555) + 1); icount += sizeof(XMU555)) - { - if (sPtr >= ePtr) break; - XMVECTOR v = XMVectorSwizzle<2, 1, 0, 3>(*sPtr++); - v = XMVectorMultiply(v, s_Scale); - XMStoreU555(dPtr, v); - dPtr->w = (XMVectorGetW(v) > threshold) ? 1u : 0u; - ++dPtr; - } - return true; - } - return false; - - case DXGI_FORMAT_B8G8R8A8_UNORM: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - if (size >= sizeof(XMUBYTEN4)) - { - XMUBYTEN4 * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < (size - sizeof(XMUBYTEN4) + 1); icount += sizeof(XMUBYTEN4)) - { - if (sPtr >= ePtr) break; - XMVECTOR v = XMVectorSwizzle<2, 1, 0, 3>(*sPtr++); - v = XMVectorAdd(v, g_8BitBias); - XMStoreUByteN4(dPtr++, v); - } - return true; - } - return false; - - case DXGI_FORMAT_B8G8R8X8_UNORM: - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - if (size >= sizeof(XMUBYTEN4)) - { - XMUBYTEN4 * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < (size - sizeof(XMUBYTEN4) + 1); icount += sizeof(XMUBYTEN4)) - { - if (sPtr >= ePtr) break; - XMVECTOR v = XMVectorPermute<2, 1, 0, 7>(*sPtr++, g_XMIdentityR3); - v = XMVectorAdd(v, g_8BitBias); - XMStoreUByteN4(dPtr++, v); - } - return true; - } - return false; - - case DXGI_FORMAT_AYUV: - if (size >= sizeof(XMUBYTEN4)) - { - XMUBYTEN4 * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < (size - sizeof(XMUBYTEN4) + 1); icount += sizeof(XMUBYTEN4)) - { - if (sPtr >= ePtr) break; - - XMUBYTEN4 rgba; - XMStoreUByteN4(&rgba, *sPtr++); - - // http://msdn.microsoft.com/en-us/library/windows/desktop/dd206750.aspx - - // Y = 0.2568R + 0.5041G + 0.1001B + 16 - // Cb = -0.1482R - 0.2910G + 0.4392B + 128 - // Cr = 0.4392R - 0.3678G - 0.0714B + 128 - - const int y = ((66 * rgba.x + 129 * rgba.y + 25 * rgba.z + 128) >> 8) + 16; - const int u = ((-38 * rgba.x - 74 * rgba.y + 112 * rgba.z + 128) >> 8) + 128; - const int v = ((112 * rgba.x - 94 * rgba.y - 18 * rgba.z + 128) >> 8) + 128; - - dPtr->x = static_cast(std::min(std::max(v, 0), 255)); - dPtr->y = static_cast(std::min(std::max(u, 0), 255)); - dPtr->z = static_cast(std::min(std::max(y, 0), 255)); - dPtr->w = rgba.w; - ++dPtr; - } - return true; - } - return false; - - case DXGI_FORMAT_Y410: - if (size >= sizeof(XMUDECN4)) - { - XMUDECN4 * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < (size - sizeof(XMUDECN4) + 1); icount += sizeof(XMUDECN4)) - { - if (sPtr >= ePtr) break; - - XMUDECN4 rgba; - XMStoreUDecN4(&rgba, *sPtr++); - - // http://msdn.microsoft.com/en-us/library/windows/desktop/bb970578.aspx - - // Y = 0.2560R + 0.5027G + 0.0998B + 64 - // Cb = -0.1478R - 0.2902G + 0.4379B + 512 - // Cr = 0.4379R - 0.3667G - 0.0712B + 512 - - const int64_t r = rgba.x; - const int64_t g = rgba.y; - const int64_t b = rgba.z; - - const int y = static_cast((16780 * r + 32942 * g + 6544 * b + 32768) >> 16) + 64; - const int u = static_cast((-9683 * r - 19017 * g + 28700 * b + 32768) >> 16) + 512; - const int v = static_cast((28700 * r - 24033 * g - 4667 * b + 32768) >> 16) + 512; - - dPtr->x = static_cast(std::min(std::max(u, 0), 1023)); - dPtr->y = static_cast(std::min(std::max(y, 0), 1023)); - dPtr->z = static_cast(std::min(std::max(v, 0), 1023)); - dPtr->w = rgba.w; - ++dPtr; - } - return true; - } - return false; - - case DXGI_FORMAT_Y416: - if (size >= sizeof(XMUSHORTN4)) - { - XMUSHORTN4 * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < (size - sizeof(XMUSHORTN4) + 1); icount += sizeof(XMUSHORTN4)) - { - if (sPtr >= ePtr) break; - - XMUSHORTN4 rgba; - XMStoreUShortN4(&rgba, *sPtr++); - - // http://msdn.microsoft.com/en-us/library/windows/desktop/bb970578.aspx - - // Y = 0.2558R + 0.5022G + 0.0998B + 4096 - // Cb = -0.1476R - 0.2899G + 0.4375B + 32768 - // Cr = 0.4375R - 0.3664G - 0.0711B + 32768 - - const int64_t r = int64_t(rgba.x); - const int64_t g = int64_t(rgba.y); - const int64_t b = int64_t(rgba.z); - - const int y = static_cast((16763 * r + 32910 * g + 6537 * b + 32768) >> 16) + 4096; - const int u = static_cast((-9674 * r - 18998 * g + 28672 * b + 32768) >> 16) + 32768; - const int v = static_cast((28672 * r - 24010 * g - 4662 * b + 32768) >> 16) + 32768; - - dPtr->x = static_cast(std::min(std::max(u, 0), 65535)); - dPtr->y = static_cast(std::min(std::max(y, 0), 65535)); - dPtr->z = static_cast(std::min(std::max(v, 0), 65535)); - dPtr->w = rgba.w; - ++dPtr; - } - return true; - } - return false; - - case DXGI_FORMAT_YUY2: - if (size >= sizeof(XMUBYTEN4)) - { - XMUBYTEN4 * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < (size - sizeof(XMUBYTEN4) + 1); icount += sizeof(XMUBYTEN4)) - { - if (sPtr >= ePtr) break; - - XMUBYTEN4 rgb1; - XMStoreUByteN4(&rgb1, *sPtr++); - - // See AYUV - const int y0 = ((66 * rgb1.x + 129 * rgb1.y + 25 * rgb1.z + 128) >> 8) + 16; - const int u0 = ((-38 * rgb1.x - 74 * rgb1.y + 112 * rgb1.z + 128) >> 8) + 128; - const int v0 = ((112 * rgb1.x - 94 * rgb1.y - 18 * rgb1.z + 128) >> 8) + 128; - - XMUBYTEN4 rgb2 = {}; - if (sPtr < ePtr) - { - XMStoreUByteN4(&rgb2, *sPtr++); - } - - const int y1 = ((66 * rgb2.x + 129 * rgb2.y + 25 * rgb2.z + 128) >> 8) + 16; - const int u1 = ((-38 * rgb2.x - 74 * rgb2.y + 112 * rgb2.z + 128) >> 8) + 128; - const int v1 = ((112 * rgb2.x - 94 * rgb2.y - 18 * rgb2.z + 128) >> 8) + 128; - - dPtr->x = static_cast(std::min(std::max(y0, 0), 255)); - dPtr->y = static_cast(std::min(std::max((u0 + u1) >> 1, 0), 255)); - dPtr->z = static_cast(std::min(std::max(y1, 0), 255)); - dPtr->w = static_cast(std::min(std::max((v0 + v1) >> 1, 0), 255)); - ++dPtr; - } - return true; - } - return false; - - case DXGI_FORMAT_Y210: - // Same as Y216 with least significant 6 bits set to zero - if (size >= sizeof(XMUSHORTN4)) - { - XMUSHORTN4 * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < (size - sizeof(XMUSHORTN4) + 1); icount += sizeof(XMUSHORTN4)) - { - if (sPtr >= ePtr) break; - - XMUDECN4 rgb1; - XMStoreUDecN4(&rgb1, *sPtr++); - - // See Y410 - int64_t r = rgb1.x; - int64_t g = rgb1.y; - int64_t b = rgb1.z; - - const int y0 = static_cast((16780 * r + 32942 * g + 6544 * b + 32768) >> 16) + 64; - const int u0 = static_cast((-9683 * r - 19017 * g + 28700 * b + 32768) >> 16) + 512; - const int v0 = static_cast((28700 * r - 24033 * g - 4667 * b + 32768) >> 16) + 512; - - XMUDECN4 rgb2 = {}; - if (sPtr < ePtr) - { - XMStoreUDecN4(&rgb2, *sPtr++); - } - - r = rgb2.x; - g = rgb2.y; - b = rgb2.z; - - const int y1 = static_cast((16780 * r + 32942 * g + 6544 * b + 32768) >> 16) + 64; - const int u1 = static_cast((-9683 * r - 19017 * g + 28700 * b + 32768) >> 16) + 512; - const int v1 = static_cast((28700 * r - 24033 * g - 4667 * b + 32768) >> 16) + 512; - - dPtr->x = static_cast(std::min(std::max(y0, 0), 1023) << 6); - dPtr->y = static_cast(std::min(std::max((u0 + u1) >> 1, 0), 1023) << 6); - dPtr->z = static_cast(std::min(std::max(y1, 0), 1023) << 6); - dPtr->w = static_cast(std::min(std::max((v0 + v1) >> 1, 0), 1023) << 6); - ++dPtr; - } - return true; - } - return false; - - case DXGI_FORMAT_Y216: - if (size >= sizeof(XMUSHORTN4)) - { - XMUSHORTN4 * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < (size - sizeof(XMUSHORTN4) + 1); icount += sizeof(XMUSHORTN4)) - { - if (sPtr >= ePtr) break; - - XMUSHORTN4 rgb1; - XMStoreUShortN4(&rgb1, *sPtr++); - - // See Y416 - int64_t r = int64_t(rgb1.x); - int64_t g = int64_t(rgb1.y); - int64_t b = int64_t(rgb1.z); - - const int y0 = static_cast((16763 * r + 32910 * g + 6537 * b + 32768) >> 16) + 4096; - const int u0 = static_cast((-9674 * r - 18998 * g + 28672 * b + 32768) >> 16) + 32768; - const int v0 = static_cast((28672 * r - 24010 * g - 4662 * b + 32768) >> 16) + 32768; - - XMUSHORTN4 rgb2 = {}; - if (sPtr < ePtr) - { - XMStoreUShortN4(&rgb2, *sPtr++); - } - - r = int64_t(rgb2.x); - g = int64_t(rgb2.y); - b = int64_t(rgb2.z); - - const int y1 = static_cast((16763 * r + 32910 * g + 6537 * b + 32768) >> 16) + 4096; - const int u1 = static_cast((-9674 * r - 18998 * g + 28672 * b + 32768) >> 16) + 32768; - const int v1 = static_cast((28672 * r - 24010 * g - 4662 * b + 32768) >> 16) + 32768; - - dPtr->x = static_cast(std::min(std::max(y0, 0), 65535)); - dPtr->y = static_cast(std::min(std::max((u0 + u1) >> 1, 0), 65535)); - dPtr->z = static_cast(std::min(std::max(y1, 0), 65535)); - dPtr->w = static_cast(std::min(std::max((v0 + v1) >> 1, 0), 65535)); - ++dPtr; - } - return true; - } - return false; - - case DXGI_FORMAT_B4G4R4A4_UNORM: - if (size >= sizeof(XMUNIBBLE4)) - { - static const XMVECTORF32 s_Scale = { { { 15.f, 15.f, 15.f, 15.f } } }; - XMUNIBBLE4 * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < (size - sizeof(XMUNIBBLE4) + 1); icount += sizeof(XMUNIBBLE4)) - { - if (sPtr >= ePtr) break; - XMVECTOR v = XMVectorSwizzle<2, 1, 0, 3>(*sPtr++); - v = XMVectorMultiply(v, s_Scale); - XMStoreUNibble4(dPtr++, v); - } - return true; - } - return false; - - case XBOX_DXGI_FORMAT_R10G10B10_7E3_A2_FLOAT: - // Xbox One specific 7e3 format with alpha - if (size >= sizeof(XMUDECN4)) - { - static const XMVECTORF32 Scale = { { { 1.0f, 1.0f, 1.0f, 3.0f } } }; - static const XMVECTORF32 C = { { { 31.875f, 31.875f, 31.875f, 3.f } } }; - - XMUDECN4 * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < (size - sizeof(XMUDECN4) + 1); icount += sizeof(XMUDECN4)) - { - if (sPtr >= ePtr) break; - - XMVECTOR V = XMVectorMultiply(*sPtr++, Scale); - V = XMVectorClamp(V, g_XMZero, C); - - XMFLOAT4A tmp; - XMStoreFloat4A(&tmp, V); - - dPtr->x = FloatTo7e3(tmp.x); - dPtr->y = FloatTo7e3(tmp.y); - dPtr->z = FloatTo7e3(tmp.z); - dPtr->w = static_cast(tmp.w); - ++dPtr; - } - return true; - } - return false; - - case XBOX_DXGI_FORMAT_R10G10B10_6E4_A2_FLOAT: - // Xbox One specific 6e4 format with alpha - if (size >= sizeof(XMUDECN4)) - { - static const XMVECTORF32 Scale = { { { 1.0f, 1.0f, 1.0f, 3.0f } } }; - static const XMVECTORF32 C = { { { 508.f, 508.f, 508.f, 3.f } } }; - - XMUDECN4 * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < (size - sizeof(XMUDECN4) + 1); icount += sizeof(XMUDECN4)) - { - if (sPtr >= ePtr) break; - - XMVECTOR V = XMVectorMultiply(*sPtr++, Scale); - V = XMVectorClamp(V, g_XMZero, C); - - XMFLOAT4A tmp; - XMStoreFloat4A(&tmp, V); - - dPtr->x = FloatTo6e4(tmp.x); - dPtr->y = FloatTo6e4(tmp.y); - dPtr->z = FloatTo6e4(tmp.z); - dPtr->w = static_cast(tmp.w); - ++dPtr; - } - return true; - } - return false; - - case XBOX_DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM: - // Xbox One specific format - STORE_SCANLINE(XMXDECN4, XMStoreXDecN4) - - case XBOX_DXGI_FORMAT_R4G4_UNORM: - // Xbox One specific format - if (size >= sizeof(uint8_t)) - { - static const XMVECTORF32 s_Scale = { { { 15.f, 15.f, 0.f, 0.f } } }; - uint8_t * __restrict dPtr = static_cast(pDestination); - for (size_t icount = 0; icount < (size - sizeof(uint8_t) + 1); icount += sizeof(uint8_t)) - { - if (sPtr >= ePtr) break; - const XMVECTOR v = XMVectorMultiply(*sPtr++, s_Scale); - - XMUNIBBLE4 nibble; - XMStoreUNibble4(&nibble, v); - *dPtr = static_cast(nibble.v); - ++dPtr; - } - return true; - } - return false; - - // We don't support the planar or palettized formats - - default: - return false; - } -} - -#undef STORE_SCANLINE - - -//------------------------------------------------------------------------------------- -// Convert DXGI image to/from GUID_WICPixelFormat128bppRGBAFloat (no range conversions) -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::Internal::ConvertToR32G32B32A32(const Image& srcImage, ScratchImage& image) noexcept -{ - if (!srcImage.pixels) - return E_POINTER; - - HRESULT hr = image.Initialize2D(DXGI_FORMAT_R32G32B32A32_FLOAT, srcImage.width, srcImage.height, 1, 1); - if (FAILED(hr)) - return hr; - - const Image *img = image.GetImage(0, 0, 0); - if (!img) - { - image.Release(); - return E_POINTER; - } - - uint8_t* pDest = img->pixels; - if (!pDest) - { - image.Release(); - return E_POINTER; - } - - const uint8_t *pSrc = srcImage.pixels; - for (size_t h = 0; h < srcImage.height; ++h) - { - if (!LoadScanline(reinterpret_cast(pDest), srcImage.width, pSrc, srcImage.rowPitch, srcImage.format)) - { - image.Release(); - return E_FAIL; - } - - pSrc += srcImage.rowPitch; - pDest += img->rowPitch; - } - - return S_OK; -} - -_Use_decl_annotations_ -HRESULT DirectX::Internal::ConvertFromR32G32B32A32(const Image& srcImage, const Image& destImage) noexcept -{ - assert(srcImage.format == DXGI_FORMAT_R32G32B32A32_FLOAT); - - if (!srcImage.pixels || !destImage.pixels) - return E_POINTER; - - if (srcImage.width != destImage.width || srcImage.height != destImage.height) - return E_FAIL; - - const uint8_t *pSrc = srcImage.pixels; - uint8_t* pDest = destImage.pixels; - - for (size_t h = 0; h < srcImage.height; ++h) - { - if (!StoreScanline(pDest, destImage.rowPitch, destImage.format, reinterpret_cast(pSrc), srcImage.width)) - return E_FAIL; - - pSrc += srcImage.rowPitch; - pDest += destImage.rowPitch; - } - - return S_OK; -} - -_Use_decl_annotations_ -HRESULT DirectX::Internal::ConvertFromR32G32B32A32( - const Image& srcImage, - DXGI_FORMAT format, - ScratchImage& image) noexcept -{ - if (!srcImage.pixels) - return E_POINTER; - - HRESULT hr = image.Initialize2D(format, srcImage.width, srcImage.height, 1, 1); - if (FAILED(hr)) - return hr; - - const Image *img = image.GetImage(0, 0, 0); - if (!img) - { - image.Release(); - return E_POINTER; - } - - hr = ConvertFromR32G32B32A32(srcImage, *img); - if (FAILED(hr)) - { - image.Release(); - return hr; - } - - return S_OK; -} - -_Use_decl_annotations_ -HRESULT DirectX::Internal::ConvertFromR32G32B32A32( - const Image* srcImages, - size_t nimages, - const TexMetadata& metadata, - DXGI_FORMAT format, - ScratchImage& result) noexcept -{ - if (!srcImages) - return E_POINTER; - - result.Release(); - - assert(metadata.format == DXGI_FORMAT_R32G32B32A32_FLOAT); - - TexMetadata mdata2 = metadata; - mdata2.format = format; - HRESULT hr = result.Initialize(mdata2); - if (FAILED(hr)) - return hr; - - if (nimages != result.GetImageCount()) - { - result.Release(); - return E_FAIL; - } - - const Image* dest = result.GetImages(); - if (!dest) - { - result.Release(); - return E_POINTER; - } - - for (size_t index = 0; index < nimages; ++index) - { - const Image& src = srcImages[index]; - const Image& dst = dest[index]; - - assert(src.format == DXGI_FORMAT_R32G32B32A32_FLOAT); - assert(dst.format == format); - - if (src.width != dst.width || src.height != dst.height) - { - result.Release(); - return E_FAIL; - } - - const uint8_t* pSrc = src.pixels; - uint8_t* pDest = dst.pixels; - if (!pSrc || !pDest) - { - result.Release(); - return E_POINTER; - } - - for (size_t h = 0; h < src.height; ++h) - { - if (!StoreScanline(pDest, dst.rowPitch, format, reinterpret_cast(pSrc), src.width)) - { - result.Release(); - return E_FAIL; - } - - pSrc += src.rowPitch; - pDest += dst.rowPitch; - } - } - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -// Convert DXGI image to/from GUID_WICPixelFormat64bppRGBAHalf (no range conversions) -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::Internal::ConvertToR16G16B16A16(const Image& srcImage, ScratchImage& image) noexcept -{ - if (!srcImage.pixels) - return E_POINTER; - - HRESULT hr = image.Initialize2D(DXGI_FORMAT_R16G16B16A16_FLOAT, srcImage.width, srcImage.height, 1, 1); - if (FAILED(hr)) - return hr; - - auto scanline = make_AlignedArrayXMVECTOR(srcImage.width); - if (!scanline) - { - image.Release(); - return E_OUTOFMEMORY; - } - - const Image *img = image.GetImage(0, 0, 0); - if (!img) - { - image.Release(); - return E_POINTER; - } - - uint8_t* pDest = img->pixels; - if (!pDest) - { - image.Release(); - return E_POINTER; - } - - const uint8_t *pSrc = srcImage.pixels; - for (size_t h = 0; h < srcImage.height; ++h) - { - if (!LoadScanline(scanline.get(), srcImage.width, pSrc, srcImage.rowPitch, srcImage.format)) - { - image.Release(); - return E_FAIL; - } - - XMConvertFloatToHalfStream( - reinterpret_cast(pDest), sizeof(HALF), - reinterpret_cast(scanline.get()), sizeof(float), - srcImage.width * 4); - - pSrc += srcImage.rowPitch; - pDest += img->rowPitch; - } - - return S_OK; -} - -_Use_decl_annotations_ -HRESULT DirectX::Internal::ConvertFromR16G16B16A16(const Image& srcImage, const Image& destImage) noexcept -{ - assert(srcImage.format == DXGI_FORMAT_R16G16B16A16_FLOAT); - - if (!srcImage.pixels || !destImage.pixels) - return E_POINTER; - - if (srcImage.width != destImage.width || srcImage.height != destImage.height) - return E_FAIL; - - auto scanline = make_AlignedArrayXMVECTOR(srcImage.width); - if (!scanline) - return E_OUTOFMEMORY; - - const uint8_t *pSrc = srcImage.pixels; - uint8_t* pDest = destImage.pixels; - - for (size_t h = 0; h < srcImage.height; ++h) - { - XMConvertHalfToFloatStream( - reinterpret_cast(scanline.get()), sizeof(float), - reinterpret_cast(pSrc), sizeof(HALF), - srcImage.width * 4); - - if (!StoreScanline(pDest, destImage.rowPitch, destImage.format, scanline.get(), srcImage.width)) - return E_FAIL; - - pSrc += srcImage.rowPitch; - pDest += destImage.rowPitch; - } - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -// Convert from Linear RGB to sRGB -// -// if C_linear <= 0.0031308 -> C_srgb = 12.92 * C_linear -// if C_linear > 0.0031308 -> C_srgb = ( 1 + a ) * pow( C_Linear, 1 / 2.4 ) - a -// where a = 0.055 -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -bool DirectX::Internal::StoreScanlineLinear( - void* pDestination, - size_t size, - DXGI_FORMAT format, - XMVECTOR* pSource, - size_t count, - TEX_FILTER_FLAGS flags, - float threshold) noexcept -{ - if (!pSource || !count) - return false; - - assert((reinterpret_cast(pSource) & 0xF) == 0); - - switch (format) - { - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - flags |= TEX_FILTER_SRGB; - break; - - case DXGI_FORMAT_R32G32B32A32_FLOAT: - case DXGI_FORMAT_R32G32B32_FLOAT: - case DXGI_FORMAT_R16G16B16A16_FLOAT: - case DXGI_FORMAT_R16G16B16A16_UNORM: - case DXGI_FORMAT_R32G32_FLOAT: - case DXGI_FORMAT_R10G10B10A2_UNORM: - case DXGI_FORMAT_R11G11B10_FLOAT: - case DXGI_FORMAT_R8G8B8A8_UNORM: - case DXGI_FORMAT_R16G16_FLOAT: - case DXGI_FORMAT_R16G16_UNORM: - case DXGI_FORMAT_R32_FLOAT: - case DXGI_FORMAT_R8G8_UNORM: - case DXGI_FORMAT_R16_FLOAT: - case DXGI_FORMAT_R16_UNORM: - case DXGI_FORMAT_R8_UNORM: - case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: - case DXGI_FORMAT_R8G8_B8G8_UNORM: - case DXGI_FORMAT_G8R8_G8B8_UNORM: - case DXGI_FORMAT_B5G6R5_UNORM: - case DXGI_FORMAT_B5G5R5A1_UNORM: - case DXGI_FORMAT_B8G8R8A8_UNORM: - case DXGI_FORMAT_B8G8R8X8_UNORM: - case DXGI_FORMAT_B4G4R4A4_UNORM: - break; - - default: - // can't treat A8, XR, Depth, SNORM, UINT, or SINT as sRGB - flags &= ~TEX_FILTER_SRGB; - break; - } - - // sRGB output processing (Linear RGB -> sRGB) - if (flags & TEX_FILTER_SRGB_OUT) - { - // To avoid the need for another temporary scanline buffer, we allow this function to overwrite the source buffer in-place - // Given the intended usage in the filtering routines, this is not a problem. - XMVECTOR* ptr = pSource; - for (size_t i = 0; i < count; ++i, ++ptr) - { - *ptr = XMColorRGBToSRGB(*ptr); - } - } - - return StoreScanline(pDestination, size, format, pSource, count, threshold); -} - - -//------------------------------------------------------------------------------------- -// Convert from sRGB to Linear RGB -// -// if C_srgb <= 0.04045 -> C_linear = C_srgb / 12.92 -// if C_srgb > 0.04045 -> C_linear = pow( ( C_srgb + a ) / ( 1 + a ), 2.4 ) -// where a = 0.055 -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -bool DirectX::Internal::LoadScanlineLinear( - XMVECTOR* pDestination, - size_t count, - const void* pSource, - size_t size, - DXGI_FORMAT format, - TEX_FILTER_FLAGS flags) noexcept -{ - switch (format) - { - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - flags |= TEX_FILTER_SRGB; - break; - - case DXGI_FORMAT_R32G32B32A32_FLOAT: - case DXGI_FORMAT_R32G32B32_FLOAT: - case DXGI_FORMAT_R16G16B16A16_FLOAT: - case DXGI_FORMAT_R16G16B16A16_UNORM: - case DXGI_FORMAT_R32G32_FLOAT: - case DXGI_FORMAT_R10G10B10A2_UNORM: - case DXGI_FORMAT_R11G11B10_FLOAT: - case DXGI_FORMAT_R8G8B8A8_UNORM: - case DXGI_FORMAT_R16G16_FLOAT: - case DXGI_FORMAT_R16G16_UNORM: - case DXGI_FORMAT_R32_FLOAT: - case DXGI_FORMAT_R8G8_UNORM: - case DXGI_FORMAT_R16_FLOAT: - case DXGI_FORMAT_R16_UNORM: - case DXGI_FORMAT_R8_UNORM: - case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: - case DXGI_FORMAT_R8G8_B8G8_UNORM: - case DXGI_FORMAT_G8R8_G8B8_UNORM: - case DXGI_FORMAT_B5G6R5_UNORM: - case DXGI_FORMAT_B5G5R5A1_UNORM: - case DXGI_FORMAT_B8G8R8A8_UNORM: - case DXGI_FORMAT_B8G8R8X8_UNORM: - case DXGI_FORMAT_B4G4R4A4_UNORM: - break; - - default: - // can't treat A8, XR, Depth, SNORM, UINT, or SINT as sRGB - flags &= ~TEX_FILTER_SRGB; - break; - } - - if (LoadScanline(pDestination, count, pSource, size, format)) - { - // sRGB input processing (sRGB -> Linear RGB) - if (flags & TEX_FILTER_SRGB_IN) - { - XMVECTOR* ptr = pDestination; - for (size_t i = 0; i < count; ++i, ++ptr) - { - *ptr = XMColorSRGBToRGB(*ptr); - } - } - - return true; - } - - return false; -} - - -//------------------------------------------------------------------------------------- -// Convert scanline based on source/target formats -//------------------------------------------------------------------------------------- -namespace -{ - struct ConvertData - { - DXGI_FORMAT format; - size_t datasize; - uint32_t flags; - }; - - const ConvertData g_ConvertTable[] = - { - { DXGI_FORMAT_R32G32B32A32_FLOAT, 32, CONVF_FLOAT | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_R32G32B32A32_UINT, 32, CONVF_UINT | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_R32G32B32A32_SINT, 32, CONVF_SINT | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_R32G32B32_FLOAT, 32, CONVF_FLOAT | CONVF_R | CONVF_G | CONVF_B }, - { DXGI_FORMAT_R32G32B32_UINT, 32, CONVF_UINT | CONVF_R | CONVF_G | CONVF_B }, - { DXGI_FORMAT_R32G32B32_SINT, 32, CONVF_SINT | CONVF_R | CONVF_G | CONVF_B }, - { DXGI_FORMAT_R16G16B16A16_FLOAT, 16, CONVF_FLOAT | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_R16G16B16A16_UNORM, 16, CONVF_UNORM | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_R16G16B16A16_UINT, 16, CONVF_UINT | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_R16G16B16A16_SNORM, 16, CONVF_SNORM | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_R16G16B16A16_SINT, 16, CONVF_SINT | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_R32G32_FLOAT, 32, CONVF_FLOAT | CONVF_R | CONVF_G }, - { DXGI_FORMAT_R32G32_UINT, 32, CONVF_UINT | CONVF_R | CONVF_G }, - { DXGI_FORMAT_R32G32_SINT, 32, CONVF_SINT | CONVF_R | CONVF_G }, - { DXGI_FORMAT_D32_FLOAT_S8X24_UINT, 32, CONVF_FLOAT | CONVF_DEPTH | CONVF_STENCIL }, - { DXGI_FORMAT_R10G10B10A2_UNORM, 10, CONVF_UNORM | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_R10G10B10A2_UINT, 10, CONVF_UINT | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_R11G11B10_FLOAT, 10, CONVF_FLOAT | CONVF_POS_ONLY | CONVF_R | CONVF_G | CONVF_B }, - { DXGI_FORMAT_R8G8B8A8_UNORM, 8, CONVF_UNORM | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, 8, CONVF_UNORM | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_R8G8B8A8_UINT, 8, CONVF_UINT | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_R8G8B8A8_SNORM, 8, CONVF_SNORM | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_R8G8B8A8_SINT, 8, CONVF_SINT | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_R16G16_FLOAT, 16, CONVF_FLOAT | CONVF_R | CONVF_G }, - { DXGI_FORMAT_R16G16_UNORM, 16, CONVF_UNORM | CONVF_R | CONVF_G }, - { DXGI_FORMAT_R16G16_UINT, 16, CONVF_UINT | CONVF_R | CONVF_G }, - { DXGI_FORMAT_R16G16_SNORM, 16, CONVF_SNORM | CONVF_R | CONVF_G }, - { DXGI_FORMAT_R16G16_SINT, 16, CONVF_SINT | CONVF_R | CONVF_G }, - { DXGI_FORMAT_D32_FLOAT, 32, CONVF_FLOAT | CONVF_DEPTH }, - { DXGI_FORMAT_R32_FLOAT, 32, CONVF_FLOAT | CONVF_R }, - { DXGI_FORMAT_R32_UINT, 32, CONVF_UINT | CONVF_R }, - { DXGI_FORMAT_R32_SINT, 32, CONVF_SINT | CONVF_R }, - { DXGI_FORMAT_D24_UNORM_S8_UINT, 32, CONVF_UNORM | CONVF_DEPTH | CONVF_STENCIL }, - { DXGI_FORMAT_R8G8_UNORM, 8, CONVF_UNORM | CONVF_R | CONVF_G }, - { DXGI_FORMAT_R8G8_UINT, 8, CONVF_UINT | CONVF_R | CONVF_G }, - { DXGI_FORMAT_R8G8_SNORM, 8, CONVF_SNORM | CONVF_R | CONVF_G }, - { DXGI_FORMAT_R8G8_SINT, 8, CONVF_SINT | CONVF_R | CONVF_G }, - { DXGI_FORMAT_R16_FLOAT, 16, CONVF_FLOAT | CONVF_R }, - { DXGI_FORMAT_D16_UNORM, 16, CONVF_UNORM | CONVF_DEPTH }, - { DXGI_FORMAT_R16_UNORM, 16, CONVF_UNORM | CONVF_R }, - { DXGI_FORMAT_R16_UINT, 16, CONVF_UINT | CONVF_R }, - { DXGI_FORMAT_R16_SNORM, 16, CONVF_SNORM | CONVF_R }, - { DXGI_FORMAT_R16_SINT, 16, CONVF_SINT | CONVF_R }, - { DXGI_FORMAT_R8_UNORM, 8, CONVF_UNORM | CONVF_R }, - { DXGI_FORMAT_R8_UINT, 8, CONVF_UINT | CONVF_R }, - { DXGI_FORMAT_R8_SNORM, 8, CONVF_SNORM | CONVF_R }, - { DXGI_FORMAT_R8_SINT, 8, CONVF_SINT | CONVF_R }, - { DXGI_FORMAT_A8_UNORM, 8, CONVF_UNORM | CONVF_A }, - { DXGI_FORMAT_R1_UNORM, 1, CONVF_UNORM | CONVF_R }, - { DXGI_FORMAT_R9G9B9E5_SHAREDEXP, 9, CONVF_FLOAT | CONVF_SHAREDEXP | CONVF_POS_ONLY | CONVF_R | CONVF_G | CONVF_B }, - { DXGI_FORMAT_R8G8_B8G8_UNORM, 8, CONVF_UNORM | CONVF_PACKED | CONVF_R | CONVF_G | CONVF_B }, - { DXGI_FORMAT_G8R8_G8B8_UNORM, 8, CONVF_UNORM | CONVF_PACKED | CONVF_R | CONVF_G | CONVF_B }, - { DXGI_FORMAT_BC1_UNORM, 8, CONVF_UNORM | CONVF_BC | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_BC1_UNORM_SRGB, 8, CONVF_UNORM | CONVF_BC | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_BC2_UNORM, 8, CONVF_UNORM | CONVF_BC | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_BC2_UNORM_SRGB, 8, CONVF_UNORM | CONVF_BC | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_BC3_UNORM, 8, CONVF_UNORM | CONVF_BC | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_BC3_UNORM_SRGB, 8, CONVF_UNORM | CONVF_BC | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_BC4_UNORM, 8, CONVF_UNORM | CONVF_BC | CONVF_R }, - { DXGI_FORMAT_BC4_SNORM, 8, CONVF_SNORM | CONVF_BC | CONVF_R }, - { DXGI_FORMAT_BC5_UNORM, 8, CONVF_UNORM | CONVF_BC | CONVF_R | CONVF_G }, - { DXGI_FORMAT_BC5_SNORM, 8, CONVF_SNORM | CONVF_BC | CONVF_R | CONVF_G }, - { DXGI_FORMAT_B5G6R5_UNORM, 5, CONVF_UNORM | CONVF_R | CONVF_G | CONVF_B }, - { DXGI_FORMAT_B5G5R5A1_UNORM, 5, CONVF_UNORM | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_B8G8R8A8_UNORM, 8, CONVF_UNORM | CONVF_BGR | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_B8G8R8X8_UNORM, 8, CONVF_UNORM | CONVF_BGR | CONVF_R | CONVF_G | CONVF_B }, - { DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM, 10, CONVF_UNORM | CONVF_XR | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_B8G8R8A8_UNORM_SRGB, 8, CONVF_UNORM | CONVF_BGR | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_B8G8R8X8_UNORM_SRGB, 8, CONVF_UNORM | CONVF_BGR | CONVF_R | CONVF_G | CONVF_B }, - { DXGI_FORMAT_BC6H_UF16, 16, CONVF_FLOAT | CONVF_BC | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_BC6H_SF16, 16, CONVF_FLOAT | CONVF_BC | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_BC7_UNORM, 8, CONVF_UNORM | CONVF_BC | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_BC7_UNORM_SRGB, 8, CONVF_UNORM | CONVF_BC | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_AYUV, 8, CONVF_UNORM | CONVF_YUV | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_Y410, 10, CONVF_UNORM | CONVF_YUV | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_Y416, 16, CONVF_UNORM | CONVF_YUV | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { DXGI_FORMAT_YUY2, 8, CONVF_UNORM | CONVF_YUV | CONVF_PACKED | CONVF_R | CONVF_G | CONVF_B }, - { DXGI_FORMAT_Y210, 10, CONVF_UNORM | CONVF_YUV | CONVF_PACKED | CONVF_R | CONVF_G | CONVF_B }, - { DXGI_FORMAT_Y216, 16, CONVF_UNORM | CONVF_YUV | CONVF_PACKED | CONVF_R | CONVF_G | CONVF_B }, - { DXGI_FORMAT_B4G4R4A4_UNORM, 4, CONVF_UNORM | CONVF_BGR | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { XBOX_DXGI_FORMAT_R10G10B10_7E3_A2_FLOAT, 10, CONVF_FLOAT | CONVF_POS_ONLY | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { XBOX_DXGI_FORMAT_R10G10B10_6E4_A2_FLOAT, 10, CONVF_FLOAT | CONVF_POS_ONLY | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { XBOX_DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM,10, CONVF_SNORM | CONVF_R | CONVF_G | CONVF_B | CONVF_A }, - { XBOX_DXGI_FORMAT_R4G4_UNORM, 4, CONVF_UNORM | CONVF_R | CONVF_G }, - }; - -#pragma prefast( suppress : 25004, "Signature must match bsearch" ); - int __cdecl ConvertCompare(const void* ptr1, const void *ptr2) noexcept - { - auto p1 = static_cast(ptr1); - auto p2 = static_cast(ptr2); - if (p1->format == p2->format) return 0; - else return (p1->format < p2->format) ? -1 : 1; - } -} - -_Use_decl_annotations_ -uint32_t DirectX::Internal::GetConvertFlags(DXGI_FORMAT format) noexcept -{ -#ifdef _DEBUG - // Ensure conversion table is in ascending order - assert(std::size(g_ConvertTable) > 0); - DXGI_FORMAT lastvalue = g_ConvertTable[0].format; - for (size_t index = 1; index < std::size(g_ConvertTable); ++index) - { - assert(g_ConvertTable[index].format > lastvalue); - lastvalue = g_ConvertTable[index].format; - } -#endif - - ConvertData key = { format, 0, 0 }; - auto in = reinterpret_cast(bsearch(&key, g_ConvertTable, std::size(g_ConvertTable), sizeof(ConvertData), - ConvertCompare)); - return (in) ? in->flags : 0; -} - -_Use_decl_annotations_ -void DirectX::Internal::ConvertScanline( - XMVECTOR* pBuffer, - size_t count, - DXGI_FORMAT outFormat, - DXGI_FORMAT inFormat, - TEX_FILTER_FLAGS flags) noexcept -{ - assert(pBuffer && count > 0 && ((reinterpret_cast(pBuffer) & 0xF) == 0)); - assert(IsValid(outFormat) && !IsTypeless(outFormat) && !IsPlanar(outFormat) && !IsPalettized(outFormat)); - assert(IsValid(inFormat) && !IsTypeless(inFormat) && !IsPlanar(inFormat) && !IsPalettized(inFormat)); - - if (!pBuffer) - return; - -#ifdef _DEBUG - // Ensure conversion table is in ascending order - assert(std::size(g_ConvertTable) > 0); - DXGI_FORMAT lastvalue = g_ConvertTable[0].format; - for (size_t index = 1; index < std::size(g_ConvertTable); ++index) - { - assert(g_ConvertTable[index].format > lastvalue); - lastvalue = g_ConvertTable[index].format; - } -#endif - - // Determine conversion details about source and dest formats - ConvertData key = { inFormat, 0, 0 }; - auto in = reinterpret_cast( - bsearch(&key, g_ConvertTable, std::size(g_ConvertTable), sizeof(ConvertData), ConvertCompare)); - key.format = outFormat; - auto out = reinterpret_cast( - bsearch(&key, g_ConvertTable, std::size(g_ConvertTable), sizeof(ConvertData), ConvertCompare)); - if (!in || !out) - { - assert(false); - return; - } - - assert(GetConvertFlags(inFormat) == in->flags); - assert(GetConvertFlags(outFormat) == out->flags); - - // Handle SRGB filtering modes - switch (inFormat) - { - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - case DXGI_FORMAT_BC1_UNORM_SRGB: - case DXGI_FORMAT_BC2_UNORM_SRGB: - case DXGI_FORMAT_BC3_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - case DXGI_FORMAT_BC7_UNORM_SRGB: - flags |= TEX_FILTER_SRGB_IN; - break; - - case DXGI_FORMAT_A8_UNORM: - case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: - flags &= ~TEX_FILTER_SRGB_IN; - break; - - default: - break; - } - - switch (outFormat) - { - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - case DXGI_FORMAT_BC1_UNORM_SRGB: - case DXGI_FORMAT_BC2_UNORM_SRGB: - case DXGI_FORMAT_BC3_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - case DXGI_FORMAT_BC7_UNORM_SRGB: - flags |= TEX_FILTER_SRGB_OUT; - break; - - case DXGI_FORMAT_A8_UNORM: - case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: - flags &= ~TEX_FILTER_SRGB_OUT; - break; - - default: - break; - } - - if ((flags & (TEX_FILTER_SRGB_IN | TEX_FILTER_SRGB_OUT)) == (TEX_FILTER_SRGB_IN | TEX_FILTER_SRGB_OUT)) - { - flags &= ~(TEX_FILTER_SRGB_IN | TEX_FILTER_SRGB_OUT); - } - - // sRGB input processing (sRGB -> Linear RGB) - if (flags & TEX_FILTER_SRGB_IN) - { - if (!(in->flags & CONVF_DEPTH) && ((in->flags & CONVF_FLOAT) || (in->flags & CONVF_UNORM))) - { - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i, ++ptr) - { - *ptr = XMColorSRGBToRGB(*ptr); - } - } - } - - // Handle conversion special cases - const uint32_t diffFlags = in->flags ^ out->flags; - if (diffFlags != 0) - { - if (diffFlags & CONVF_DEPTH) - { - //--- Depth conversions --- - if (in->flags & CONVF_DEPTH) - { - // CONVF_DEPTH -> !CONVF_DEPTH - if (in->flags & CONVF_STENCIL) - { - // Stencil -> Alpha - static const XMVECTORF32 S = { { { 1.f, 1.f, 1.f, 255.f } } }; - - if (out->flags & CONVF_UNORM) - { - // UINT -> UNORM - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - XMVECTOR v1 = XMVectorSplatY(v); - v1 = XMVectorClamp(v1, g_XMZero, S); - v1 = XMVectorDivide(v1, S); - *ptr++ = XMVectorSelect(v1, v, g_XMSelect1110); - } - } - else if (out->flags & CONVF_SNORM) - { - // UINT -> SNORM - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - XMVECTOR v1 = XMVectorSplatY(v); - v1 = XMVectorClamp(v1, g_XMZero, S); - v1 = XMVectorDivide(v1, S); - v1 = XMVectorMultiplyAdd(v1, g_XMTwo, g_XMNegativeOne); - *ptr++ = XMVectorSelect(v1, v, g_XMSelect1110); - } - } - else - { - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - const XMVECTOR v1 = XMVectorSplatY(v); - *ptr++ = XMVectorSelect(v1, v, g_XMSelect1110); - } - } - } - - // Depth -> RGB - if ((out->flags & CONVF_UNORM) && (in->flags & CONVF_FLOAT)) - { - // Depth FLOAT -> UNORM - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - XMVECTOR v1 = XMVectorSaturate(v); - v1 = XMVectorSplatX(v1); - *ptr++ = XMVectorSelect(v, v1, g_XMSelect1110); - } - } - else if (out->flags & CONVF_SNORM) - { - if (in->flags & CONVF_UNORM) - { - // Depth UNORM -> SNORM - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - XMVECTOR v1 = XMVectorMultiplyAdd(v, g_XMTwo, g_XMNegativeOne); - v1 = XMVectorSplatX(v1); - *ptr++ = XMVectorSelect(v, v1, g_XMSelect1110); - } - } - else - { - // Depth FLOAT -> SNORM - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - XMVECTOR v1 = XMVectorClamp(v, g_XMNegativeOne, g_XMOne); - v1 = XMVectorSplatX(v1); - *ptr++ = XMVectorSelect(v, v1, g_XMSelect1110); - } - } - } - else - { - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - const XMVECTOR v1 = XMVectorSplatX(v); - *ptr++ = XMVectorSelect(v, v1, g_XMSelect1110); - } - } - } - else - { - // !CONVF_DEPTH -> CONVF_DEPTH - - // RGB -> Depth (red channel) - switch (flags & (TEX_FILTER_RGB_COPY_RED | TEX_FILTER_RGB_COPY_GREEN | TEX_FILTER_RGB_COPY_BLUE)) - { - case TEX_FILTER_RGB_COPY_GREEN: - { - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - const XMVECTOR v1 = XMVectorSplatY(v); - *ptr++ = XMVectorSelect(v, v1, g_XMSelect1000); - } - } - break; - - case TEX_FILTER_RGB_COPY_BLUE: - { - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - const XMVECTOR v1 = XMVectorSplatZ(v); - *ptr++ = XMVectorSelect(v, v1, g_XMSelect1000); - } - } - break; - - default: - if ((in->flags & CONVF_UNORM) && ((in->flags & CONVF_RGB_MASK) == (CONVF_R | CONVF_G | CONVF_B))) - { - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - const XMVECTOR v1 = XMVector3Dot(v, g_Grayscale); - *ptr++ = XMVectorSelect(v, v1, g_XMSelect1000); - } - break; - } - - #if (__cplusplus >= 201703L) - [[fallthrough]]; - #elif defined(__clang__) - [[clang::fallthrough]]; - #elif defined(_MSC_VER) - __fallthrough; - #endif - - case TEX_FILTER_RGB_COPY_RED: - { - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - const XMVECTOR v1 = XMVectorSplatX(v); - *ptr++ = XMVectorSelect(v, v1, g_XMSelect1000); - } - } - break; - } - - // Finialize type conversion for depth (red channel) - if (out->flags & CONVF_UNORM) - { - if (in->flags & CONVF_SNORM) - { - // SNORM -> UNORM - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - const XMVECTOR v1 = XMVectorMultiplyAdd(v, g_XMOneHalf, g_XMOneHalf); - *ptr++ = XMVectorSelect(v, v1, g_XMSelect1000); - } - } - else if (in->flags & CONVF_FLOAT) - { - // FLOAT -> UNORM - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - const XMVECTOR v1 = XMVectorSaturate(v); - *ptr++ = XMVectorSelect(v, v1, g_XMSelect1000); - } - } - } - - if (out->flags & CONVF_STENCIL) - { - // Alpha -> Stencil (green channel) - static const XMVECTORU32 select0100 = { { { XM_SELECT_0, XM_SELECT_1, XM_SELECT_0, XM_SELECT_0 } } }; - static const XMVECTORF32 S = { { { 255.f, 255.f, 255.f, 255.f } } }; - - if (in->flags & CONVF_UNORM) - { - // UNORM -> UINT - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - XMVECTOR v1 = XMVectorMultiply(v, S); - v1 = XMVectorSplatW(v1); - *ptr++ = XMVectorSelect(v, v1, select0100); - } - } - else if (in->flags & CONVF_SNORM) - { - // SNORM -> UINT - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - XMVECTOR v1 = XMVectorMultiplyAdd(v, g_XMOneHalf, g_XMOneHalf); - v1 = XMVectorMultiply(v1, S); - v1 = XMVectorSplatW(v1); - *ptr++ = XMVectorSelect(v, v1, select0100); - } - } - else - { - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - const XMVECTOR v1 = XMVectorSplatW(v); - *ptr++ = XMVectorSelect(v, v1, select0100); - } - } - } - } - } - else if (out->flags & CONVF_DEPTH) - { - // CONVF_DEPTH -> CONVF_DEPTH - if (diffFlags & CONVF_FLOAT) - { - if (in->flags & CONVF_FLOAT) - { - // FLOAT -> UNORM depth, preserve stencil - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - const XMVECTOR v1 = XMVectorSaturate(v); - *ptr++ = XMVectorSelect(v, v1, g_XMSelect1000); - } - } - } - } - else if (out->flags & CONVF_UNORM) - { - //--- Converting to a UNORM --- - if (in->flags & CONVF_SNORM) - { - // SNORM -> UNORM - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - *ptr++ = XMVectorMultiplyAdd(v, g_XMOneHalf, g_XMOneHalf); - } - } - else if (in->flags & CONVF_FLOAT) - { - XMVECTOR* ptr = pBuffer; - if (!(in->flags & CONVF_POS_ONLY) && (flags & TEX_FILTER_FLOAT_X2BIAS)) - { - // FLOAT -> UNORM (x2 bias) - for (size_t i = 0; i < count; ++i) - { - XMVECTOR v = *ptr; - v = XMVectorClamp(v, g_XMNegativeOne, g_XMOne); - *ptr++ = XMVectorMultiplyAdd(v, g_XMOneHalf, g_XMOneHalf); - } - } - else - { - // FLOAT -> UNORM - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - *ptr++ = XMVectorSaturate(v); - } - } - } - } - else if (out->flags & CONVF_SNORM) - { - //--- Converting to a SNORM --- - if (in->flags & CONVF_UNORM) - { - // UNORM -> SNORM - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - *ptr++ = XMVectorMultiplyAdd(v, g_XMTwo, g_XMNegativeOne); - } - } - else if (in->flags & CONVF_FLOAT) - { - XMVECTOR* ptr = pBuffer; - if ((in->flags & CONVF_POS_ONLY) && (flags & TEX_FILTER_FLOAT_X2BIAS)) - { - // FLOAT (positive only, x2 bias) -> SNORM - for (size_t i = 0; i < count; ++i) - { - XMVECTOR v = *ptr; - v = XMVectorSaturate(v); - *ptr++ = XMVectorMultiplyAdd(v, g_XMTwo, g_XMNegativeOne); - } - } - else - { - // FLOAT -> SNORM - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - *ptr++ = XMVectorClamp(v, g_XMNegativeOne, g_XMOne); - } - } - } - } - else if (diffFlags & CONVF_UNORM) - { - //--- Converting from a UNORM --- - assert(in->flags & CONVF_UNORM); - if (out->flags & CONVF_FLOAT) - { - if (!(out->flags & CONVF_POS_ONLY) && (flags & TEX_FILTER_FLOAT_X2BIAS)) - { - // UNORM (x2 bias) -> FLOAT - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - *ptr++ = XMVectorMultiplyAdd(v, g_XMTwo, g_XMNegativeOne); - } - } - } - } - else if (diffFlags & CONVF_POS_ONLY) - { - if (flags & TEX_FILTER_FLOAT_X2BIAS) - { - if (in->flags & CONVF_POS_ONLY) - { - if (out->flags & CONVF_FLOAT) - { - // FLOAT (positive only, x2 bias) -> FLOAT - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - XMVECTOR v = *ptr; - v = XMVectorSaturate(v); - *ptr++ = XMVectorMultiplyAdd(v, g_XMTwo, g_XMNegativeOne); - } - } - } - else if (out->flags & CONVF_POS_ONLY) - { - if (in->flags & CONVF_FLOAT) - { - // FLOAT -> FLOAT (positive only, x2 bias) - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - XMVECTOR v = *ptr; - v = XMVectorClamp(v, g_XMNegativeOne, g_XMOne); - *ptr++ = XMVectorMultiplyAdd(v, g_XMOneHalf, g_XMOneHalf); - } - } - else if (in->flags & CONVF_SNORM) - { - // SNORM -> FLOAT (positive only, x2 bias) - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - *ptr++ = XMVectorMultiplyAdd(v, g_XMOneHalf, g_XMOneHalf); - } - } - } - } - } - - // !CONVF_A -> CONVF_A is handled because LoadScanline ensures alpha defaults to 1.0 for no-alpha formats - - // CONVF_PACKED cases are handled because LoadScanline/StoreScanline handles packing/unpacking - - if (((out->flags & CONVF_RGBA_MASK) == CONVF_A) && !(in->flags & CONVF_A)) - { - // !CONVF_A -> A format - switch (flags & (TEX_FILTER_RGB_COPY_RED | TEX_FILTER_RGB_COPY_GREEN | TEX_FILTER_RGB_COPY_BLUE)) - { - case TEX_FILTER_RGB_COPY_GREEN: - { - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - *ptr++ = XMVectorSplatY(v); - } - } - break; - - case TEX_FILTER_RGB_COPY_BLUE: - { - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - *ptr++ = XMVectorSplatZ(v); - } - } - break; - - default: - if ((in->flags & CONVF_UNORM) && ((in->flags & CONVF_RGB_MASK) == (CONVF_R | CONVF_G | CONVF_B))) - { - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - *ptr++ = XMVector3Dot(v, g_Grayscale); - } - break; - } - - #if (__cplusplus >= 201703L) - [[fallthrough]]; - #elif defined(__clang__) - [[clang::fallthrough]]; - #elif defined(_MSC_VER) - __fallthrough; - #endif - - case TEX_FILTER_RGB_COPY_RED: - { - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - *ptr++ = XMVectorSplatX(v); - } - } - break; - } - } - else if (((in->flags & CONVF_RGBA_MASK) == CONVF_A) && !(out->flags & CONVF_A)) - { - // A format -> !CONVF_A - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - *ptr++ = XMVectorSplatW(v); - } - } - else if ((in->flags & CONVF_RGB_MASK) == CONVF_R) - { - if ((out->flags & CONVF_RGB_MASK) == (CONVF_R | CONVF_G | CONVF_B)) - { - // R format -> RGB format - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - const XMVECTOR v1 = XMVectorSplatX(v); - *ptr++ = XMVectorSelect(v, v1, g_XMSelect1110); - } - } - else if ((out->flags & CONVF_RGB_MASK) == (CONVF_R | CONVF_G)) - { - // R format -> RG format - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - const XMVECTOR v1 = XMVectorSplatX(v); - *ptr++ = XMVectorSelect(v, v1, g_XMSelect1100); - } - } - } - else if ((in->flags & CONVF_RGB_MASK) == (CONVF_R | CONVF_G | CONVF_B)) - { - if ((out->flags & CONVF_RGB_MASK) == CONVF_R) - { - // RGB format -> R format - switch (flags & (TEX_FILTER_RGB_COPY_RED | TEX_FILTER_RGB_COPY_GREEN | TEX_FILTER_RGB_COPY_BLUE)) - { - case TEX_FILTER_RGB_COPY_GREEN: - { - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - const XMVECTOR v1 = XMVectorSplatY(v); - *ptr++ = XMVectorSelect(v, v1, g_XMSelect1110); - } - } - break; - - case TEX_FILTER_RGB_COPY_BLUE: - { - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - const XMVECTOR v1 = XMVectorSplatZ(v); - *ptr++ = XMVectorSelect(v, v1, g_XMSelect1110); - } - } - break; - - default: - if (in->flags & CONVF_UNORM) - { - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - const XMVECTOR v1 = XMVector3Dot(v, g_Grayscale); - *ptr++ = XMVectorSelect(v, v1, g_XMSelect1110); - } - break; - } - - #if (__cplusplus >= 201703L) - [[fallthrough]]; - #elif defined(__clang__) - [[clang::fallthrough]]; - #elif defined(_MSC_VER) - __fallthrough; - #endif - - case TEX_FILTER_RGB_COPY_RED: - // Leave data unchanged and the store will handle this... - break; - } - } - else if ((out->flags & CONVF_RGB_MASK) == (CONVF_R | CONVF_G)) - { - // RGB format -> RG format - switch (static_cast(flags & (TEX_FILTER_RGB_COPY_RED | TEX_FILTER_RGB_COPY_GREEN | TEX_FILTER_RGB_COPY_BLUE))) - { - case (static_cast(TEX_FILTER_RGB_COPY_RED) | static_cast(TEX_FILTER_RGB_COPY_BLUE)): - { - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - const XMVECTOR v1 = XMVectorSwizzle<0, 2, 0, 2>(v); - *ptr++ = XMVectorSelect(v, v1, g_XMSelect1100); - } - } - break; - - case (static_cast(TEX_FILTER_RGB_COPY_GREEN) | static_cast(TEX_FILTER_RGB_COPY_BLUE)): - { - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i) - { - const XMVECTOR v = *ptr; - const XMVECTOR v1 = XMVectorSwizzle<1, 2, 3, 0>(v); - *ptr++ = XMVectorSelect(v, v1, g_XMSelect1100); - } - } - break; - - case (static_cast(TEX_FILTER_RGB_COPY_RED) | static_cast(TEX_FILTER_RGB_COPY_GREEN)): - default: - // Leave data unchanged and the store will handle this... - break; - } - } - } - } - - // sRGB output processing (Linear RGB -> sRGB) - if (flags & TEX_FILTER_SRGB_OUT) - { - if (!(out->flags & CONVF_DEPTH) && ((out->flags & CONVF_FLOAT) || (out->flags & CONVF_UNORM))) - { - XMVECTOR* ptr = pBuffer; - for (size_t i = 0; i < count; ++i, ++ptr) - { - *ptr = XMColorRGBToSRGB(*ptr); - } - } - } -} - - -//------------------------------------------------------------------------------------- -// Dithering -//------------------------------------------------------------------------------------- -namespace -{ - // 4X4X4 ordered dithering matrix - const float g_Dither[] = - { - // (z & 3) + ( (y & 3) * 8) + (x & 3) - 0.468750f, -0.031250f, 0.343750f, -0.156250f, 0.468750f, -0.031250f, 0.343750f, -0.156250f, - -0.281250f, 0.218750f, -0.406250f, 0.093750f, -0.281250f, 0.218750f, -0.406250f, 0.093750f, - 0.281250f, -0.218750f, 0.406250f, -0.093750f, 0.281250f, -0.218750f, 0.406250f, -0.093750f, - -0.468750f, 0.031250f, -0.343750f, 0.156250f, -0.468750f, 0.031250f, -0.343750f, 0.156250f, - }; - - const XMVECTORF32 g_Scale16pc = { { { 65535.f, 65535.f, 65535.f, 65535.f } } }; - const XMVECTORF32 g_Scale15pc = { { { 32767.f, 32767.f, 32767.f, 32767.f } } }; - const XMVECTORF32 g_Scale10pc = { { { 1023.f, 1023.f, 1023.f, 3.f } } }; - const XMVECTORF32 g_Scale9pc = { { { 511.f, 511.f, 511.f, 3.f } } }; - const XMVECTORF32 g_Scale8pc = { { { 255.f, 255.f, 255.f, 255.f } } }; - const XMVECTORF32 g_Scale7pc = { { { 127.f, 127.f, 127.f, 127.f } } }; - const XMVECTORF32 g_Scale565pc = { { { 31.f, 63.f, 31.f, 1.f } } }; - const XMVECTORF32 g_Scale5551pc = { { { 31.f, 31.f, 31.f, 1.f } } }; - const XMVECTORF32 g_Scale4pc = { { { 15.f, 15.f, 15.f, 15.f } } }; - - const XMVECTORF32 g_ErrorWeight3 = { { { 3.f / 16.f, 3.f / 16.f, 3.f / 16.f, 3.f / 16.f } } }; - const XMVECTORF32 g_ErrorWeight5 = { { { 5.f / 16.f, 5.f / 16.f, 5.f / 16.f, 5.f / 16.f } } }; - const XMVECTORF32 g_ErrorWeight1 = { { { 1.f / 16.f, 1.f / 16.f, 1.f / 16.f, 1.f / 16.f } } }; - const XMVECTORF32 g_ErrorWeight7 = { { { 7.f / 16.f, 7.f / 16.f, 7.f / 16.f, 7.f / 16.f } } }; - -#define STORE_SCANLINE( type, scalev, clampzero, norm, itype, mask, row, bgr ) \ - if (size >= sizeof(type)) \ - { \ - type * __restrict dest = reinterpret_cast(pDestination); \ - for(size_t i = 0; i < count; ++i) \ - { \ - auto index = static_cast((row & 1) ? (count - i - 1) : i ); \ - ptrdiff_t delta = (row & 1) ? -2 : 0; \ - \ - XMVECTOR v = sPtr[ index ]; \ - if (bgr) { v = XMVectorSwizzle<2, 1, 0, 3>(v); } \ - if (norm && clampzero) v = XMVectorSaturate(v) ; \ - else if (clampzero) v = XMVectorClamp(v, g_XMZero, scalev); \ - else if (norm) v = XMVectorClamp(v, g_XMNegativeOne, g_XMOne); \ - else v = XMVectorClamp(v, XMVectorAdd(XMVectorNegate(scalev), g_XMOne), scalev); \ - v = XMVectorAdd(v, vError); \ - if (norm) v = XMVectorMultiply(v, scalev); \ - \ - XMVECTOR target; \ - if (pDiffusionErrors) \ - { \ - target = XMVectorRound(v); \ - vError = XMVectorSubtract(v, target); \ - if (norm) vError = XMVectorDivide(vError, scalev); \ - \ - /* Distribute error to next scanline and next pixel */ \ - pDiffusionErrors[ index-delta ] = XMVectorMultiplyAdd(g_ErrorWeight3, vError, pDiffusionErrors[ index-delta ]); \ - pDiffusionErrors[ index+1 ] = XMVectorMultiplyAdd(g_ErrorWeight5, vError, pDiffusionErrors[ index+1 ]); \ - pDiffusionErrors[ index+2+delta ] = XMVectorMultiplyAdd(g_ErrorWeight1, vError, pDiffusionErrors[ index+2+delta ]); \ - vError = XMVectorMultiply(vError, g_ErrorWeight7); \ - } \ - else \ - { \ - /* Applied ordered dither */ \ - target = XMVectorAdd(v, ordered[ index & 3 ]); \ - target = XMVectorRound(target); \ - } \ - \ - target = XMVectorMin(scalev, target); \ - target = XMVectorMax((clampzero) ? g_XMZero : (XMVectorAdd(XMVectorNegate(scalev), g_XMOne)), target); \ - \ - XMFLOAT4A tmp; \ - XMStoreFloat4A(&tmp, target); \ - \ - auto dPtr = &dest[ index ]; \ - if (dPtr >= ePtr) break; \ - dPtr->x = itype(static_cast(tmp.x) & mask); \ - dPtr->y = itype(static_cast(tmp.y) & mask); \ - dPtr->z = itype(static_cast(tmp.z) & mask); \ - dPtr->w = itype(static_cast(tmp.w) & mask); \ - } \ - return true; \ - } \ - return false; - -#define STORE_SCANLINE2( type, scalev, clampzero, norm, itype, mask, row ) \ - /* The 2 component cases are always bgr=false */ \ - if (size >= sizeof(type)) \ - { \ - type * __restrict dest = reinterpret_cast(pDestination); \ - for(size_t i = 0; i < count; ++i) \ - { \ - auto index = static_cast((row & 1) ? (count - i - 1) : i ); \ - ptrdiff_t delta = (row & 1) ? -2 : 0; \ - \ - XMVECTOR v = sPtr[ index ]; \ - if (norm && clampzero) v = XMVectorSaturate(v) ; \ - else if (clampzero) v = XMVectorClamp(v, g_XMZero, scalev); \ - else if (norm) v = XMVectorClamp(v, g_XMNegativeOne, g_XMOne); \ - else v = XMVectorClamp(v, XMVectorAdd(XMVectorNegate(scalev), g_XMOne), scalev); \ - v = XMVectorAdd(v, vError); \ - if (norm) v = XMVectorMultiply(v, scalev); \ - \ - XMVECTOR target; \ - if (pDiffusionErrors) \ - { \ - target = XMVectorRound(v); \ - vError = XMVectorSubtract(v, target); \ - if (norm) vError = XMVectorDivide(vError, scalev); \ - \ - /* Distribute error to next scanline and next pixel */ \ - pDiffusionErrors[ index-delta ] = XMVectorMultiplyAdd(g_ErrorWeight3, vError, pDiffusionErrors[ index-delta ]); \ - pDiffusionErrors[ index+1 ] = XMVectorMultiplyAdd(g_ErrorWeight5, vError, pDiffusionErrors[ index+1 ]); \ - pDiffusionErrors[ index+2+delta ] = XMVectorMultiplyAdd(g_ErrorWeight1, vError, pDiffusionErrors[ index+2+delta ]); \ - vError = XMVectorMultiply(vError, g_ErrorWeight7); \ - } \ - else \ - { \ - /* Applied ordered dither */ \ - target = XMVectorAdd(v, ordered[ index & 3 ]); \ - target = XMVectorRound(target); \ - } \ - \ - target = XMVectorMin(scalev, target); \ - target = XMVectorMax((clampzero) ? g_XMZero : (XMVectorAdd(XMVectorNegate(scalev), g_XMOne)), target); \ - \ - XMFLOAT4A tmp; \ - XMStoreFloat4A(&tmp, target); \ - \ - auto dPtr = &dest[ index ]; \ - if (dPtr >= ePtr) break; \ - dPtr->x = itype(static_cast(tmp.x) & mask); \ - dPtr->y = itype(static_cast(tmp.y) & mask); \ - } \ - return true; \ - } \ - return false; - -#define STORE_SCANLINE1( type, scalev, clampzero, norm, mask, row, selectw ) \ - /* The 1 component cases are always bgr=false */ \ - if (size >= sizeof(type)) \ - { \ - type * __restrict dest = reinterpret_cast(pDestination); \ - for(size_t i = 0; i < count; ++i) \ - { \ - auto index = static_cast((row & 1) ? (count - i - 1) : i ); \ - ptrdiff_t delta = (row & 1) ? -2 : 0; \ - \ - XMVECTOR v = sPtr[ index ]; \ - if (norm && clampzero) v = XMVectorSaturate(v) ; \ - else if (clampzero) v = XMVectorClamp(v, g_XMZero, scalev); \ - else if (norm) v = XMVectorClamp(v, g_XMNegativeOne, g_XMOne); \ - else v = XMVectorClamp(v, XMVectorAdd(XMVectorNegate(scalev), g_XMOne), scalev); \ - v = XMVectorAdd(v, vError); \ - if (norm) v = XMVectorMultiply(v, scalev); \ - \ - XMVECTOR target; \ - if (pDiffusionErrors) \ - { \ - target = XMVectorRound(v); \ - vError = XMVectorSubtract(v, target); \ - if (norm) vError = XMVectorDivide(vError, scalev); \ - \ - /* Distribute error to next scanline and next pixel */ \ - pDiffusionErrors[ index-delta ] = XMVectorMultiplyAdd(g_ErrorWeight3, vError, pDiffusionErrors[ index-delta ]); \ - pDiffusionErrors[ index+1 ] = XMVectorMultiplyAdd(g_ErrorWeight5, vError, pDiffusionErrors[ index+1 ]); \ - pDiffusionErrors[ index+2+delta ] = XMVectorMultiplyAdd(g_ErrorWeight1, vError, pDiffusionErrors[ index+2+delta ]); \ - vError = XMVectorMultiply(vError, g_ErrorWeight7); \ - } \ - else \ - { \ - /* Applied ordered dither */ \ - target = XMVectorAdd(v, ordered[ index & 3 ]); \ - target = XMVectorRound(target); \ - } \ - \ - target = XMVectorMin(scalev, target); \ - target = XMVectorMax((clampzero) ? g_XMZero : (XMVectorAdd(XMVectorNegate(scalev), g_XMOne)), target); \ - \ - auto dPtr = &dest[ index ]; \ - if (dPtr >= ePtr) break; \ - *dPtr = type(static_cast((selectw) ? XMVectorGetW(target) : XMVectorGetX(target)) & mask); \ - } \ - return true; \ - } \ - return false; -} - -#pragma warning(push) -#pragma warning( disable : 4127 ) - -_Use_decl_annotations_ -bool DirectX::Internal::StoreScanlineDither( - void* pDestination, - size_t size, - DXGI_FORMAT format, - XMVECTOR* pSource, - size_t count, - float threshold, - size_t y, - size_t z, - XMVECTOR* pDiffusionErrors) noexcept -{ - assert(pDestination != nullptr); - assert(IsValid(format) && !IsTypeless(format) && !IsCompressed(format) && !IsPlanar(format) && !IsPalettized(format)); - - if (!size || !count) - return false; - - const XMVECTOR* __restrict sPtr = pSource; - if (!sPtr) - return false; - - assert((reinterpret_cast(pSource) & 0xF) == 0); - - XMVECTOR ordered[4]; - if (pDiffusionErrors) - { - // If pDiffusionErrors != 0, then this function performs error diffusion dithering (aka Floyd-Steinberg dithering) - - // To avoid the need for another temporary scanline buffer, we allow this function to overwrite the source buffer in-place - // Given the intended usage in the conversion routines, this is not a problem. - - XMVECTOR* ptr = pSource; - const XMVECTOR* err = pDiffusionErrors + 1; - for (size_t i = 0; i < count; ++i) - { - // Add contribution from previous scanline - XMVECTOR v = XMVectorAdd(*ptr, *err++); - *ptr++ = v; - } - - // Reset errors for next scanline - memset(pDiffusionErrors, 0, sizeof(XMVECTOR)*(count + 2)); - } - else - { - // If pDiffusionErrors == 0, then this function performs ordered dithering - - const XMVECTOR dither = XMLoadFloat4(reinterpret_cast(g_Dither + (z & 3) + ((y & 3) * 8))); - - ordered[0] = XMVectorSplatX(dither); - ordered[1] = XMVectorSplatY(dither); - ordered[2] = XMVectorSplatZ(dither); - ordered[3] = XMVectorSplatW(dither); - } - - const void* ePtr = static_cast(pDestination) + size; - -#ifdef _PREFAST_ - *reinterpret_cast(pDestination) = 0; -#endif - - XMVECTOR vError = XMVectorZero(); - - switch (static_cast(format)) - { - case DXGI_FORMAT_R16G16B16A16_UNORM: - STORE_SCANLINE(XMUSHORTN4, g_Scale16pc, true, true, uint16_t, 0xFFFF, y, false) - - case DXGI_FORMAT_R16G16B16A16_UINT: - STORE_SCANLINE(XMUSHORT4, g_Scale16pc, true, false, uint16_t, 0xFFFF, y, false) - - case DXGI_FORMAT_R16G16B16A16_SNORM: - STORE_SCANLINE(XMSHORTN4, g_Scale15pc, false, true, int16_t, 0xFFFF, y, false) - - case DXGI_FORMAT_R16G16B16A16_SINT: - STORE_SCANLINE(XMSHORT4, g_Scale15pc, false, false, int16_t, 0xFFFF, y, false) - - case DXGI_FORMAT_R10G10B10A2_UNORM: - STORE_SCANLINE(XMUDECN4, g_Scale10pc, true, true, uint16_t, 0x3FF, y, false) - - case DXGI_FORMAT_R10G10B10A2_UINT: - STORE_SCANLINE(XMUDEC4, g_Scale10pc, true, false, uint16_t, 0x3FF, y, false) - - case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: - if (size >= sizeof(XMUDEC4)) - { - static const XMVECTORF32 Scale = { { { 510.0f, 510.0f, 510.0f, 3.0f } } }; - static const XMVECTORF32 Bias = { { { 384.0f, 384.0f, 384.0f, 0.0f } } }; - static const XMVECTORF32 MinXR = { { { -0.7529f, -0.7529f, -0.7529f, 0.f } } }; - static const XMVECTORF32 MaxXR = { { { 1.2529f, 1.2529f, 1.2529f, 1.0f } } }; - - XMUDEC4 * __restrict dest = static_cast(pDestination); - for (size_t i = 0; i < count; ++i) - { - auto index = static_cast((y & 1) ? (count - i - 1) : i); - ptrdiff_t delta = (y & 1) ? -2 : 0; - - XMVECTOR v = XMVectorClamp(sPtr[index], MinXR, MaxXR); - v = XMVectorMultiplyAdd(v, Scale, vError); - - XMVECTOR target; - if (pDiffusionErrors) - { - target = XMVectorRound(v); - vError = XMVectorSubtract(v, target); - vError = XMVectorDivide(vError, Scale); - - // Distribute error to next scanline and next pixel - pDiffusionErrors[index - delta] = XMVectorMultiplyAdd(g_ErrorWeight3, vError, pDiffusionErrors[index - delta]); - pDiffusionErrors[index + 1] = XMVectorMultiplyAdd(g_ErrorWeight5, vError, pDiffusionErrors[index + 1]); - pDiffusionErrors[index + 2 + delta] = XMVectorMultiplyAdd(g_ErrorWeight1, vError, pDiffusionErrors[index + 2 + delta]); - vError = XMVectorMultiply(vError, g_ErrorWeight7); - } - else - { - // Applied ordered dither - target = XMVectorAdd(v, ordered[index & 3]); - target = XMVectorRound(target); - } - - target = XMVectorAdd(target, Bias); - target = XMVectorClamp(target, g_XMZero, g_Scale10pc); - - XMFLOAT4A tmp; - XMStoreFloat4A(&tmp, target); - - auto dPtr = &dest[index]; - if (dPtr >= ePtr) break; - dPtr->x = uint16_t(static_cast(tmp.x) & 0x3FF); - dPtr->y = uint16_t(static_cast(tmp.y) & 0x3FF); - dPtr->z = uint16_t(static_cast(tmp.z) & 0x3FF); - dPtr->w = static_cast(tmp.w); - } - return true; - } - return false; - - case DXGI_FORMAT_R8G8B8A8_UNORM: - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - STORE_SCANLINE(XMUBYTEN4, g_Scale8pc, true, true, uint8_t, 0xFF, y, false) - - case DXGI_FORMAT_R8G8B8A8_UINT: - STORE_SCANLINE(XMUBYTE4, g_Scale8pc, true, false, uint8_t, 0xFF, y, false) - - case DXGI_FORMAT_R8G8B8A8_SNORM: - STORE_SCANLINE(XMBYTEN4, g_Scale7pc, false, true, int8_t, 0xFF, y, false) - - case DXGI_FORMAT_R8G8B8A8_SINT: - STORE_SCANLINE(XMBYTE4, g_Scale7pc, false, false, int8_t, 0xFF, y, false) - - case DXGI_FORMAT_R16G16_UNORM: - STORE_SCANLINE2(XMUSHORTN2, g_Scale16pc, true, true, uint16_t, 0xFFFF, y) - - case DXGI_FORMAT_R16G16_UINT: - STORE_SCANLINE2(XMUSHORT2, g_Scale16pc, true, false, uint16_t, 0xFFFF, y) - - case DXGI_FORMAT_R16G16_SNORM: - STORE_SCANLINE2(XMSHORTN2, g_Scale15pc, false, true, int16_t, 0xFFFF, y) - - case DXGI_FORMAT_R16G16_SINT: - STORE_SCANLINE2(XMSHORT2, g_Scale15pc, false, false, int16_t, 0xFFFF, y) - - case DXGI_FORMAT_D24_UNORM_S8_UINT: - if (size >= sizeof(uint32_t)) - { - static const XMVECTORF32 Clamp = { { { 1.f, 255.f, 0.f, 0.f } } }; - static const XMVECTORF32 Scale = { { { 16777215.f, 1.f, 0.f, 0.f } } }; - static const XMVECTORF32 Scale2 = { { { 16777215.f, 255.f, 0.f, 0.f } } }; - - uint32_t * __restrict dest = static_cast(pDestination); - for (size_t i = 0; i < count; ++i) - { - auto index = static_cast((y & 1) ? (count - i - 1) : i); - ptrdiff_t delta = (y & 1) ? -2 : 0; - - XMVECTOR v = XMVectorClamp(sPtr[index], g_XMZero, Clamp); - v = XMVectorAdd(v, vError); - v = XMVectorMultiply(v, Scale); - - XMVECTOR target; - if (pDiffusionErrors) - { - target = XMVectorRound(v); - vError = XMVectorSubtract(v, target); - vError = XMVectorDivide(vError, Scale); - - // Distribute error to next scanline and next pixel - pDiffusionErrors[index - delta] = XMVectorMultiplyAdd(g_ErrorWeight3, vError, pDiffusionErrors[index - delta]); - pDiffusionErrors[index + 1] = XMVectorMultiplyAdd(g_ErrorWeight5, vError, pDiffusionErrors[index + 1]); - pDiffusionErrors[index + 2 + delta] = XMVectorMultiplyAdd(g_ErrorWeight1, vError, pDiffusionErrors[index + 2 + delta]); - vError = XMVectorMultiply(vError, g_ErrorWeight7); - } - else - { - // Applied ordered dither - target = XMVectorAdd(v, ordered[index & 3]); - target = XMVectorRound(target); - } - - target = XMVectorClamp(target, g_XMZero, Scale2); - - XMFLOAT4A tmp; - XMStoreFloat4A(&tmp, target); - - auto dPtr = &dest[index]; - if (dPtr >= ePtr) break; - *dPtr = (static_cast(tmp.x) & 0xFFFFFF) - | ((static_cast(tmp.y) & 0xFF) << 24); - } - return true; - } - return false; - - case DXGI_FORMAT_R8G8_UNORM: - STORE_SCANLINE2(XMUBYTEN2, g_Scale8pc, true, true, uint8_t, 0xFF, y) - - case DXGI_FORMAT_R8G8_UINT: - STORE_SCANLINE2(XMUBYTE2, g_Scale8pc, true, false, uint8_t, 0xFF, y) - - case DXGI_FORMAT_R8G8_SNORM: - STORE_SCANLINE2(XMBYTEN2, g_Scale7pc, false, true, int8_t, 0xFF, y) - - case DXGI_FORMAT_R8G8_SINT: - STORE_SCANLINE2(XMBYTE2, g_Scale7pc, false, false, int8_t, 0xFF, y) - - case DXGI_FORMAT_D16_UNORM: - case DXGI_FORMAT_R16_UNORM: - STORE_SCANLINE1(uint16_t, g_Scale16pc, true, true, 0xFFFF, y, false) - - case DXGI_FORMAT_R16_UINT: - STORE_SCANLINE1(uint16_t, g_Scale16pc, true, false, 0xFFFF, y, false) - - case DXGI_FORMAT_R16_SNORM: - STORE_SCANLINE1(int16_t, g_Scale15pc, false, true, 0xFFFF, y, false) - - case DXGI_FORMAT_R16_SINT: - STORE_SCANLINE1(int16_t, g_Scale15pc, false, false, 0xFFFF, y, false) - - case DXGI_FORMAT_R8_UNORM: - STORE_SCANLINE1(uint8_t, g_Scale8pc, true, true, 0xFF, y, false) - - case DXGI_FORMAT_R8_UINT: - STORE_SCANLINE1(uint8_t, g_Scale8pc, true, false, 0xFF, y, false) - - case DXGI_FORMAT_R8_SNORM: - STORE_SCANLINE1(int8_t, g_Scale7pc, false, true, 0xFF, y, false) - - case DXGI_FORMAT_R8_SINT: - STORE_SCANLINE1(int8_t, g_Scale7pc, false, false, 0xFF, y, false) - - case DXGI_FORMAT_A8_UNORM: - STORE_SCANLINE1(uint8_t, g_Scale8pc, true, true, 0xFF, y, true) - - case DXGI_FORMAT_B5G6R5_UNORM: - if (size >= sizeof(XMU565)) - { - XMU565 * __restrict dest = static_cast(pDestination); - for (size_t i = 0; i < count; ++i) - { - auto index = static_cast((y & 1) ? (count - i - 1) : i); - ptrdiff_t delta = (y & 1) ? -2 : 0; - - XMVECTOR v = XMVectorSwizzle<2, 1, 0, 3>(sPtr[index]); - v = XMVectorSaturate(v); - v = XMVectorAdd(v, vError); - v = XMVectorMultiply(v, g_Scale565pc); - - XMVECTOR target; - if (pDiffusionErrors) - { - target = XMVectorRound(v); - vError = XMVectorSubtract(v, target); - vError = XMVectorDivide(vError, g_Scale565pc); - - // Distribute error to next scanline and next pixel - pDiffusionErrors[index - delta] = XMVectorMultiplyAdd(g_ErrorWeight3, vError, pDiffusionErrors[index - delta]); - pDiffusionErrors[index + 1] = XMVectorMultiplyAdd(g_ErrorWeight5, vError, pDiffusionErrors[index + 1]); - pDiffusionErrors[index + 2 + delta] = XMVectorMultiplyAdd(g_ErrorWeight1, vError, pDiffusionErrors[index + 2 + delta]); - vError = XMVectorMultiply(vError, g_ErrorWeight7); - } - else - { - // Applied ordered dither - target = XMVectorAdd(v, ordered[index & 3]); - target = XMVectorRound(target); - } - - target = XMVectorClamp(target, g_XMZero, g_Scale565pc); - - XMFLOAT4A tmp; - XMStoreFloat4A(&tmp, target); - - auto dPtr = &dest[index]; - if (dPtr >= ePtr) break; - dPtr->x = uint16_t(static_cast(tmp.x) & 0x1F); - dPtr->y = uint16_t(static_cast(tmp.y) & 0x3F); - dPtr->z = uint16_t(static_cast(tmp.z) & 0x1F); - } - return true; - } - return false; - - case DXGI_FORMAT_B5G5R5A1_UNORM: - if (size >= sizeof(XMU555)) - { - XMU555 * __restrict dest = static_cast(pDestination); - for (size_t i = 0; i < count; ++i) - { - auto index = static_cast((y & 1) ? (count - i - 1) : i); - ptrdiff_t delta = (y & 1) ? -2 : 0; - - XMVECTOR v = XMVectorSwizzle<2, 1, 0, 3>(sPtr[index]); - v = XMVectorSaturate(v); - v = XMVectorAdd(v, vError); - v = XMVectorMultiply(v, g_Scale5551pc); - - XMVECTOR target; - if (pDiffusionErrors) - { - target = XMVectorRound(v); - vError = XMVectorSubtract(v, target); - vError = XMVectorDivide(vError, g_Scale5551pc); - - // Distribute error to next scanline and next pixel - pDiffusionErrors[index - delta] = XMVectorMultiplyAdd(g_ErrorWeight3, vError, pDiffusionErrors[index - delta]); - pDiffusionErrors[index + 1] = XMVectorMultiplyAdd(g_ErrorWeight5, vError, pDiffusionErrors[index + 1]); - pDiffusionErrors[index + 2 + delta] = XMVectorMultiplyAdd(g_ErrorWeight1, vError, pDiffusionErrors[index + 2 + delta]); - vError = XMVectorMultiply(vError, g_ErrorWeight7); - } - else - { - // Applied ordered dither - target = XMVectorAdd(v, ordered[index & 3]); - target = XMVectorRound(target); - } - - target = XMVectorClamp(target, g_XMZero, g_Scale5551pc); - - XMFLOAT4A tmp; - XMStoreFloat4A(&tmp, target); - - auto dPtr = &dest[index]; - if (dPtr >= ePtr) break; - dPtr->x = uint16_t(static_cast(tmp.x) & 0x1F); - dPtr->y = uint16_t(static_cast(tmp.y) & 0x1F); - dPtr->z = uint16_t(static_cast(tmp.z) & 0x1F); - dPtr->w = (XMVectorGetW(target) > threshold) ? 1u : 0u; - } - return true; - } - return false; - - case DXGI_FORMAT_B8G8R8A8_UNORM: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - STORE_SCANLINE(XMUBYTEN4, g_Scale8pc, true, true, uint8_t, 0xFF, y, true) - - case DXGI_FORMAT_B8G8R8X8_UNORM: - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - if (size >= sizeof(XMUBYTEN4)) - { - XMUBYTEN4 * __restrict dest = static_cast(pDestination); - for (size_t i = 0; i < count; ++i) - { - auto index = static_cast((y & 1) ? (count - i - 1) : i); - ptrdiff_t delta = (y & 1) ? -2 : 0; - - XMVECTOR v = XMVectorSwizzle<2, 1, 0, 3>(sPtr[index]); - v = XMVectorSaturate(v); - v = XMVectorAdd(v, vError); - v = XMVectorMultiply(v, g_Scale8pc); - - XMVECTOR target; - if (pDiffusionErrors) - { - target = XMVectorRound(v); - vError = XMVectorSubtract(v, target); - vError = XMVectorDivide(vError, g_Scale8pc); - - // Distribute error to next scanline and next pixel - pDiffusionErrors[index - delta] = XMVectorMultiplyAdd(g_ErrorWeight3, vError, pDiffusionErrors[index - delta]); - pDiffusionErrors[index + 1] = XMVectorMultiplyAdd(g_ErrorWeight5, vError, pDiffusionErrors[index + 1]); - pDiffusionErrors[index + 2 + delta] = XMVectorMultiplyAdd(g_ErrorWeight1, vError, pDiffusionErrors[index + 2 + delta]); - vError = XMVectorMultiply(vError, g_ErrorWeight7); - } - else - { - // Applied ordered dither - target = XMVectorAdd(v, ordered[index & 3]); - target = XMVectorRound(target); - } - - target = XMVectorClamp(target, g_XMZero, g_Scale8pc); - - XMFLOAT4A tmp; - XMStoreFloat4A(&tmp, target); - - auto dPtr = &dest[index]; - if (dPtr >= ePtr) break; - dPtr->x = uint8_t(static_cast(tmp.x) & 0xFF); - dPtr->y = uint8_t(static_cast(tmp.y) & 0xFF); - dPtr->z = uint8_t(static_cast(tmp.z) & 0xFF); - dPtr->w = 0; - } - return true; - } - return false; - - case DXGI_FORMAT_B4G4R4A4_UNORM: - STORE_SCANLINE(XMUNIBBLE4, g_Scale4pc, true, true, uint8_t, 0xF, y, true) - - case XBOX_DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM: - STORE_SCANLINE(XMXDECN4, g_Scale9pc, false, true, uint16_t, 0x3FF, y, false) - - case XBOX_DXGI_FORMAT_R4G4_UNORM: - if (size >= sizeof(uint8_t)) - { - uint8_t * __restrict dest = static_cast(pDestination); - for (size_t i = 0; i < count; ++i) - { - auto index = static_cast((y & 1) ? (count - i - 1) : i); - ptrdiff_t delta = (y & 1) ? -2 : 0; - - XMVECTOR v = XMVectorSaturate(sPtr[index]); - v = XMVectorAdd(v, vError); - v = XMVectorMultiply(v, g_Scale4pc); - - XMVECTOR target; - if (pDiffusionErrors) - { - target = XMVectorRound(v); - vError = XMVectorSubtract(v, target); - vError = XMVectorDivide(vError, g_Scale4pc); - - // Distribute error to next scanline and next pixel - pDiffusionErrors[index - delta] = XMVectorMultiplyAdd(g_ErrorWeight3, vError, pDiffusionErrors[index - delta]); - pDiffusionErrors[index + 1] = XMVectorMultiplyAdd(g_ErrorWeight5, vError, pDiffusionErrors[index + 1]); - pDiffusionErrors[index + 2 + delta] = XMVectorMultiplyAdd(g_ErrorWeight1, vError, pDiffusionErrors[index + 2 + delta]); - vError = XMVectorMultiply(vError, g_ErrorWeight7); - } - else - { - // Applied ordered dither - target = XMVectorAdd(v, ordered[index & 3]); - target = XMVectorRound(target); - } - - target = XMVectorClamp(target, g_XMZero, g_Scale4pc); - - XMFLOAT4A tmp; - XMStoreFloat4A(&tmp, target); - - auto dPtr = &dest[index]; - if (dPtr >= ePtr) break; - *dPtr = static_cast((unsigned(tmp.x) & 0xF) | ((unsigned(tmp.y) & 0xF) << 4)); - } - return true; - } - return false; - - default: - return StoreScanline(pDestination, size, format, pSource, count, threshold); - } -} - -#pragma warning(pop) - -#undef STORE_SCANLINE -#undef STORE_SCANLINE2 -#undef STORE_SCANLINE1 - -namespace -{ - //------------------------------------------------------------------------------------- - // Selection logic for using WIC vs. our own routines - //------------------------------------------------------------------------------------- - inline bool UseWICConversion( - _In_ TEX_FILTER_FLAGS filter, - _In_ DXGI_FORMAT sformat, - _In_ DXGI_FORMAT tformat, - _Out_ WICPixelFormatGUID& pfGUID, - _Out_ WICPixelFormatGUID& targetGUID) noexcept - { - #ifndef _WIN32 - UNREFERENCED_PARAMETER(filter); - UNREFERENCED_PARAMETER(sformat); - UNREFERENCED_PARAMETER(tformat); - UNREFERENCED_PARAMETER(pfGUID); - UNREFERENCED_PARAMETER(targetGUID); - return false; - #else - memset(&pfGUID, 0, sizeof(GUID)); - memset(&targetGUID, 0, sizeof(GUID)); - - if (filter & TEX_FILTER_FORCE_NON_WIC) - { - // Explicit flag indicates use of non-WIC code paths - return false; - } - - if (!DXGIToWIC(sformat, pfGUID) || !DXGIToWIC(tformat, targetGUID)) - { - // Source or target format are not WIC supported native pixel formats - return false; - } - - if (filter & TEX_FILTER_FORCE_WIC) - { - // Explicit flag to use WIC code paths, skips all the case checks below - return true; - } - - if (filter & TEX_FILTER_SEPARATE_ALPHA) - { - // Alpha is not premultiplied, so use non-WIC code paths - return false; - } - - if (filter & TEX_FILTER_FLOAT_X2BIAS) - { - // X2 Scale & Bias conversions not supported by WIC code paths - return false; - } - - // Check for special cases - #if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX) - if (sformat == DXGI_FORMAT_R16G16B16A16_FLOAT - || sformat == DXGI_FORMAT_R16_FLOAT - || tformat == DXGI_FORMAT_R16G16B16A16_FLOAT - || tformat == DXGI_FORMAT_R16_FLOAT) - { - // Use non-WIC code paths as these conversions are not supported by Xbox version of WIC - return false; - } - #endif - - switch (sformat) - { - case DXGI_FORMAT_R32G32B32A32_FLOAT: - case DXGI_FORMAT_R32G32B32_FLOAT: - case DXGI_FORMAT_R32G32_FLOAT: - case DXGI_FORMAT_R32_FLOAT: - case DXGI_FORMAT_D32_FLOAT: - switch (tformat) - { - case DXGI_FORMAT_R16G16B16A16_FLOAT: - case DXGI_FORMAT_R16G16_FLOAT: - case DXGI_FORMAT_R16_FLOAT: - // WIC conversions for FP32->FP16 can result in NaN values instead of clamping for min/max value - return false; - - default: - break; - } - break; - - default: - break; - } - - switch (sformat) - { - case DXGI_FORMAT_R32G32B32A32_FLOAT: - case DXGI_FORMAT_R32G32B32_FLOAT: - case DXGI_FORMAT_R16G16B16A16_FLOAT: - switch (tformat) - { - case DXGI_FORMAT_R16_FLOAT: - case DXGI_FORMAT_R32_FLOAT: - case DXGI_FORMAT_D32_FLOAT: - // WIC converts via UNORM formats and ends up converting colorspaces for these cases - case DXGI_FORMAT_A8_UNORM: - // Conversion logic for these kinds of textures is unintuitive for WIC code paths - return false; - - default: - break; - } - break; - - case DXGI_FORMAT_R16_FLOAT: - switch (tformat) - { - case DXGI_FORMAT_R32_FLOAT: - case DXGI_FORMAT_D32_FLOAT: - // WIC converts via UNORM formats and ends up converting colorspaces for these cases - case DXGI_FORMAT_A8_UNORM: - // Conversion logic for these kinds of textures is unintuitive for WIC code paths - return false; - - default: - break; - } - break; - - case DXGI_FORMAT_A8_UNORM: - // Conversion logic for these kinds of textures is unintuitive for WIC code paths - return false; - - default: - switch (tformat) - { - case DXGI_FORMAT_A8_UNORM: - // Conversion logic for these kinds of textures is unintuitive for WIC code paths - return false; - - default: - break; - } - } - - // Check for implicit color space changes - if (IsSRGB(sformat)) - filter |= TEX_FILTER_SRGB_IN; - - if (IsSRGB(tformat)) - filter |= TEX_FILTER_SRGB_OUT; - - if ((filter & (TEX_FILTER_SRGB_IN | TEX_FILTER_SRGB_OUT)) == (TEX_FILTER_SRGB_IN | TEX_FILTER_SRGB_OUT)) - { - filter &= ~(TEX_FILTER_SRGB_IN | TEX_FILTER_SRGB_OUT); - } - - auto const wicsrgb = CheckWICColorSpace(pfGUID, targetGUID); - - if (wicsrgb != (filter & (TEX_FILTER_SRGB_IN | TEX_FILTER_SRGB_OUT))) - { - // WIC will perform a colorspace conversion we didn't request - return false; - } - - return true; - #endif // WIN32 - } - - //------------------------------------------------------------------------------------- - // Convert the source image using WIC - //------------------------------------------------------------------------------------- - HRESULT ConvertUsingWIC( - _In_ const Image& srcImage, - _In_ const WICPixelFormatGUID& pfGUID, - _In_ const WICPixelFormatGUID& targetGUID, - _In_ TEX_FILTER_FLAGS filter, - _In_ float threshold, - _In_ const Image& destImage) - { - #ifndef _WIN32 - UNREFERENCED_PARAMETER(srcImage); - UNREFERENCED_PARAMETER(pfGUID); - UNREFERENCED_PARAMETER(targetGUID); - UNREFERENCED_PARAMETER(filter); - UNREFERENCED_PARAMETER(threshold); - UNREFERENCED_PARAMETER(destImage); - return E_NOTIMPL; - #else - assert(srcImage.width == destImage.width); - assert(srcImage.height == destImage.height); - - bool iswic2 = false; - auto pWIC = GetWICFactory(iswic2); - if (!pWIC) - return E_NOINTERFACE; - - ComPtr FC; - HRESULT hr = pWIC->CreateFormatConverter(FC.GetAddressOf()); - if (FAILED(hr)) - return hr; - - // Note that WIC conversion ignores the TEX_FILTER_SRGB_IN and TEX_FILTER_SRGB_OUT flags, - // but also always assumes UNORM <-> FLOAT conversions are changing color spaces sRGB <-> scRGB - - BOOL canConvert = FALSE; - hr = FC->CanConvert(pfGUID, targetGUID, &canConvert); - if (FAILED(hr) || !canConvert) - { - // This case is not an issue for the subset of WIC formats that map directly to DXGI - return E_UNEXPECTED; - } - - if (srcImage.rowPitch > UINT32_MAX || srcImage.slicePitch > UINT32_MAX - || destImage.rowPitch > UINT32_MAX || destImage.slicePitch > UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - ComPtr source; - hr = pWIC->CreateBitmapFromMemory(static_cast(srcImage.width), static_cast(srcImage.height), pfGUID, - static_cast(srcImage.rowPitch), static_cast(srcImage.slicePitch), - srcImage.pixels, source.GetAddressOf()); - if (FAILED(hr)) - return hr; - - hr = FC->Initialize(source.Get(), targetGUID, GetWICDither(filter), nullptr, - static_cast(threshold) * 100.0, WICBitmapPaletteTypeMedianCut); - if (FAILED(hr)) - return hr; - - hr = FC->CopyPixels(nullptr, static_cast(destImage.rowPitch), static_cast(destImage.slicePitch), destImage.pixels); - if (FAILED(hr)) - return hr; - - return S_OK; - #endif // WIN32 - } - - //------------------------------------------------------------------------------------- - // Convert the source image (not using WIC) - //------------------------------------------------------------------------------------- - HRESULT ConvertCustom( - _In_ const Image& srcImage, - _In_ TEX_FILTER_FLAGS filter, - _In_ const Image& destImage, - _In_ float threshold, - size_t z) noexcept - { - assert(srcImage.width == destImage.width); - assert(srcImage.height == destImage.height); - - const uint8_t *pSrc = srcImage.pixels; - uint8_t *pDest = destImage.pixels; - if (!pSrc || !pDest) - return E_POINTER; - - size_t width = srcImage.width; - - if (filter & TEX_FILTER_DITHER_DIFFUSION) - { - // Error diffusion dithering (aka Floyd-Steinberg dithering) - auto scanline = make_AlignedArrayXMVECTOR(uint64_t(width) * 2 + 2); - if (!scanline) - return E_OUTOFMEMORY; - - XMVECTOR* pDiffusionErrors = scanline.get() + width; - memset(pDiffusionErrors, 0, sizeof(XMVECTOR)*(width + 2)); - - for (size_t h = 0; h < srcImage.height; ++h) - { - if (!LoadScanline(scanline.get(), width, pSrc, srcImage.rowPitch, srcImage.format)) - return E_FAIL; - - ConvertScanline(scanline.get(), width, destImage.format, srcImage.format, filter); - - if (!StoreScanlineDither(pDest, destImage.rowPitch, destImage.format, scanline.get(), width, threshold, h, z, pDiffusionErrors)) - return E_FAIL; - - pSrc += srcImage.rowPitch; - pDest += destImage.rowPitch; - } - } - else - { - auto scanline = make_AlignedArrayXMVECTOR(width); - if (!scanline) - return E_OUTOFMEMORY; - - if (filter & TEX_FILTER_DITHER) - { - // Ordered dithering - for (size_t h = 0; h < srcImage.height; ++h) - { - if (!LoadScanline(scanline.get(), width, pSrc, srcImage.rowPitch, srcImage.format)) - return E_FAIL; - - ConvertScanline(scanline.get(), width, destImage.format, srcImage.format, filter); - - if (!StoreScanlineDither(pDest, destImage.rowPitch, destImage.format, scanline.get(), width, threshold, h, z, nullptr)) - return E_FAIL; - - pSrc += srcImage.rowPitch; - pDest += destImage.rowPitch; - } - } - else - { - // No dithering - for (size_t h = 0; h < srcImage.height; ++h) - { - if (!LoadScanline(scanline.get(), width, pSrc, srcImage.rowPitch, srcImage.format)) - return E_FAIL; - - ConvertScanline(scanline.get(), width, destImage.format, srcImage.format, filter); - - if (!StoreScanline(pDest, destImage.rowPitch, destImage.format, scanline.get(), width, threshold)) - return E_FAIL; - - pSrc += srcImage.rowPitch; - pDest += destImage.rowPitch; - } - } - } - - return S_OK; - } - - //------------------------------------------------------------------------------------- - DXGI_FORMAT PlanarToSingle(_In_ DXGI_FORMAT format) noexcept - { - switch (format) - { - case DXGI_FORMAT_NV12: - case DXGI_FORMAT_NV11: - return DXGI_FORMAT_YUY2; - - case DXGI_FORMAT_P010: - return DXGI_FORMAT_Y210; - - case DXGI_FORMAT_P016: - return DXGI_FORMAT_Y216; - - // We currently do not support conversion for Xbox One specific 16-bit depth formats - - // We can't do anything with DXGI_FORMAT_420_OPAQUE because it's an opaque blob of bits - - // We don't support conversion of JPEG Hardware decode formats - - default: - return DXGI_FORMAT_UNKNOWN; - } - } - - //------------------------------------------------------------------------------------- - // Convert the image from a planar to non-planar image - //------------------------------------------------------------------------------------- -#define CONVERT_420_TO_422( srcType, destType )\ - {\ - const size_t rowPitch = srcImage.rowPitch;\ - \ - auto const sourceE = reinterpret_cast(pSrc + srcImage.slicePitch);\ - auto pSrcUV = pSrc + (srcImage.height * rowPitch);\ - \ - for(size_t y = 0; y < srcImage.height; y+= 2)\ - {\ - auto sPtrY0 = reinterpret_cast(pSrc);\ - auto sPtrY2 = reinterpret_cast(pSrc + rowPitch);\ - auto sPtrUV = reinterpret_cast(pSrcUV);\ - \ - destType * __restrict dPtr0 = reinterpret_cast(pDest);\ - destType * __restrict dPtr1 = reinterpret_cast(pDest + destImage.rowPitch);\ - \ - for(size_t x = 0; x < srcImage.width; x+= 2)\ - {\ - if ((sPtrUV+1) >= sourceE) break;\ - \ - const srcType u = *(sPtrUV++);\ - const srcType v = *(sPtrUV++);\ - \ - dPtr0->x = *(sPtrY0++);\ - dPtr0->y = u;\ - dPtr0->z = *(sPtrY0++);\ - dPtr0->w = v;\ - ++dPtr0;\ - \ - dPtr1->x = *(sPtrY2++);\ - dPtr1->y = u;\ - dPtr1->z = *(sPtrY2++);\ - dPtr1->w = v;\ - ++dPtr1;\ - }\ - \ - pSrc += rowPitch * 2;\ - pSrcUV += rowPitch;\ - \ - pDest += destImage.rowPitch * 2;\ - }\ - } - -#ifdef __clang__ -#pragma clang diagnostic ignored "-Wextra-semi-stmt" -#endif - - HRESULT ConvertToSinglePlane_(_In_ const Image& srcImage, _In_ const Image& destImage) noexcept - { - assert(srcImage.width == destImage.width); - assert(srcImage.height == destImage.height); - - const uint8_t *pSrc = srcImage.pixels; - uint8_t *pDest = destImage.pixels; - if (!pSrc || !pDest) - return E_POINTER; - - switch (srcImage.format) - { - case DXGI_FORMAT_NV12: - assert(destImage.format == DXGI_FORMAT_YUY2); - CONVERT_420_TO_422(uint8_t, XMUBYTEN4); - return S_OK; - - case DXGI_FORMAT_P010: - assert(destImage.format == DXGI_FORMAT_Y210); - CONVERT_420_TO_422(uint16_t, XMUSHORTN4); - return S_OK; - - case DXGI_FORMAT_P016: - assert(destImage.format == DXGI_FORMAT_Y216); - CONVERT_420_TO_422(uint16_t, XMUSHORTN4); - return S_OK; - - case DXGI_FORMAT_NV11: - assert(destImage.format == DXGI_FORMAT_YUY2); - // Convert 4:1:1 to 4:2:2 - { - const size_t rowPitch = srcImage.rowPitch; - - const uint8_t* sourceE = pSrc + srcImage.slicePitch; - const uint8_t* pSrcUV = pSrc + (srcImage.height * rowPitch); - - for (size_t y = 0; y < srcImage.height; ++y) - { - const uint8_t* sPtrY = pSrc; - const uint8_t* sPtrUV = pSrcUV; - - XMUBYTEN4 * __restrict dPtr = reinterpret_cast(pDest); - - for (size_t x = 0; x < srcImage.width; x += 4) - { - if ((sPtrUV + 1) >= sourceE) break; - - const uint8_t u = *(sPtrUV++); - const uint8_t v = *(sPtrUV++); - - dPtr->x = *(sPtrY++); - dPtr->y = u; - dPtr->z = *(sPtrY++); - dPtr->w = v; - ++dPtr; - - dPtr->x = *(sPtrY++); - dPtr->y = u; - dPtr->z = *(sPtrY++); - dPtr->w = v; - ++dPtr; - } - - pSrc += rowPitch; - pSrcUV += (rowPitch >> 1); - - pDest += destImage.rowPitch; - } - } - return S_OK; - - default: - return E_UNEXPECTED; - } - } - -#undef CONVERT_420_TO_422 -} - - -//===================================================================================== -// Entry-points -//===================================================================================== - -//------------------------------------------------------------------------------------- -// Convert image -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::Convert( - const Image& srcImage, - DXGI_FORMAT format, - TEX_FILTER_FLAGS filter, - float threshold, - ScratchImage& image) noexcept -{ - if ((srcImage.format == format) || !IsValid(format)) - return E_INVALIDARG; - - if (!srcImage.pixels) - return E_POINTER; - - if (IsCompressed(srcImage.format) || IsCompressed(format) - || IsPlanar(srcImage.format) || IsPlanar(format) - || IsPalettized(srcImage.format) || IsPalettized(format) - || IsTypeless(srcImage.format) || IsTypeless(format)) - return HRESULT_E_NOT_SUPPORTED; - - if ((srcImage.width > UINT32_MAX) || (srcImage.height > UINT32_MAX)) - return E_INVALIDARG; - - HRESULT hr = image.Initialize2D(format, srcImage.width, srcImage.height, 1, 1); - if (FAILED(hr)) - return hr; - - const Image *rimage = image.GetImage(0, 0, 0); - if (!rimage) - { - image.Release(); - return E_POINTER; - } - - WICPixelFormatGUID pfGUID, targetGUID; - if (UseWICConversion(filter, srcImage.format, format, pfGUID, targetGUID)) - { - hr = ConvertUsingWIC(srcImage, pfGUID, targetGUID, filter, threshold, *rimage); - } - else - { - hr = ConvertCustom(srcImage, filter, *rimage, threshold, 0); - } - - if (FAILED(hr)) - { - image.Release(); - return hr; - } - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -// Convert image (complex) -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::Convert( - const Image* srcImages, - size_t nimages, - const TexMetadata& metadata, - DXGI_FORMAT format, - TEX_FILTER_FLAGS filter, - float threshold, - ScratchImage& result) noexcept -{ - if (!srcImages || !nimages || (metadata.format == format) || !IsValid(format)) - return E_INVALIDARG; - - if (IsCompressed(metadata.format) || IsCompressed(format) - || IsPlanar(metadata.format) || IsPlanar(format) - || IsPalettized(metadata.format) || IsPalettized(format) - || IsTypeless(metadata.format) || IsTypeless(format)) - return HRESULT_E_NOT_SUPPORTED; - - if ((metadata.width > UINT32_MAX) || (metadata.height > UINT32_MAX)) - return E_INVALIDARG; - - TexMetadata mdata2 = metadata; - mdata2.format = format; - HRESULT hr = result.Initialize(mdata2); - if (FAILED(hr)) - return hr; - - if (nimages != result.GetImageCount()) - { - result.Release(); - return E_FAIL; - } - - const Image* dest = result.GetImages(); - if (!dest) - { - result.Release(); - return E_POINTER; - } - - WICPixelFormatGUID pfGUID, targetGUID; - const bool usewic = !metadata.IsPMAlpha() && UseWICConversion(filter, metadata.format, format, pfGUID, targetGUID); - - switch (metadata.dimension) - { - case TEX_DIMENSION_TEXTURE1D: - case TEX_DIMENSION_TEXTURE2D: - for (size_t index = 0; index < nimages; ++index) - { - const Image& src = srcImages[index]; - if (src.format != metadata.format) - { - result.Release(); - return E_FAIL; - } - - if ((src.width > UINT32_MAX) || (src.height > UINT32_MAX)) - { - result.Release(); - return E_FAIL; - } - - const Image& dst = dest[index]; - assert(dst.format == format); - - if (src.width != dst.width || src.height != dst.height) - { - result.Release(); - return E_FAIL; - } - - if (usewic) - { - hr = ConvertUsingWIC(src, pfGUID, targetGUID, filter, threshold, dst); - } - else - { - hr = ConvertCustom(src, filter, dst, threshold, 0); - } - - if (FAILED(hr)) - { - result.Release(); - return hr; - } - } - break; - - case TEX_DIMENSION_TEXTURE3D: - { - size_t index = 0; - size_t d = metadata.depth; - for (size_t level = 0; level < metadata.mipLevels; ++level) - { - for (size_t slice = 0; slice < d; ++slice, ++index) - { - if (index >= nimages) - { - result.Release(); - return E_FAIL; - } - - const Image& src = srcImages[index]; - if (src.format != metadata.format) - { - result.Release(); - return E_FAIL; - } - - if ((src.width > UINT32_MAX) || (src.height > UINT32_MAX)) - { - result.Release(); - return E_FAIL; - } - - const Image& dst = dest[index]; - assert(dst.format == format); - - if (src.width != dst.width || src.height != dst.height) - { - result.Release(); - return E_FAIL; - } - - if (usewic) - { - hr = ConvertUsingWIC(src, pfGUID, targetGUID, filter, threshold, dst); - } - else - { - hr = ConvertCustom(src, filter, dst, threshold, slice); - } - - if (FAILED(hr)) - { - result.Release(); - return hr; - } - } - - if (d > 1) - d >>= 1; - } - } - break; - - default: - result.Release(); - return E_FAIL; - } - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -// Convert image from planar to single plane (image) -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::ConvertToSinglePlane(const Image& srcImage, ScratchImage& image) noexcept -{ - if (!IsPlanar(srcImage.format)) - return E_INVALIDARG; - - if (!srcImage.pixels) - return E_POINTER; - - const DXGI_FORMAT format = PlanarToSingle(srcImage.format); - if (format == DXGI_FORMAT_UNKNOWN) - return HRESULT_E_NOT_SUPPORTED; - - if ((srcImage.width > UINT32_MAX) || (srcImage.height > UINT32_MAX)) - return E_INVALIDARG; - - HRESULT hr = image.Initialize2D(format, srcImage.width, srcImage.height, 1, 1); - if (FAILED(hr)) - return hr; - - const Image *rimage = image.GetImage(0, 0, 0); - if (!rimage) - { - image.Release(); - return E_POINTER; - } - - hr = ConvertToSinglePlane_(srcImage, *rimage); - if (FAILED(hr)) - { - image.Release(); - return hr; - } - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -// Convert image from planar to single plane (complex) -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::ConvertToSinglePlane( - const Image* srcImages, - size_t nimages, - const TexMetadata& metadata, - ScratchImage& result) noexcept -{ - if (!srcImages || !nimages) - return E_INVALIDARG; - - if (metadata.IsVolumemap()) - { - // Direct3D does not support any planar formats for Texture3D - return HRESULT_E_NOT_SUPPORTED; - } - - const DXGI_FORMAT format = PlanarToSingle(metadata.format); - if (format == DXGI_FORMAT_UNKNOWN) - return HRESULT_E_NOT_SUPPORTED; - - if ((metadata.width > UINT32_MAX) || (metadata.height > UINT32_MAX)) - return E_INVALIDARG; - - TexMetadata mdata2 = metadata; - mdata2.format = format; - HRESULT hr = result.Initialize(mdata2); - if (FAILED(hr)) - return hr; - - if (nimages != result.GetImageCount()) - { - result.Release(); - return E_FAIL; - } - - const Image* dest = result.GetImages(); - if (!dest) - { - result.Release(); - return E_POINTER; - } - - for (size_t index = 0; index < nimages; ++index) - { - const Image& src = srcImages[index]; - if (src.format != metadata.format) - { - result.Release(); - return E_FAIL; - } - - if ((src.width > UINT32_MAX) || (src.height > UINT32_MAX)) - return E_FAIL; - - const Image& dst = dest[index]; - assert(dst.format == format); - - if (src.width != dst.width || src.height != dst.height) - { - result.Release(); - return E_FAIL; - } - - hr = ConvertToSinglePlane_(src, dst); - if (FAILED(hr)) - { - result.Release(); - return hr; - } - } - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -// Returns the data type of a DXGI_FORMAT -//------------------------------------------------------------------------------------- -DirectX::FORMAT_TYPE DirectX::FormatDataType(_In_ DXGI_FORMAT fmt) noexcept -{ - const auto cflags = GetConvertFlags(fmt); - - switch (cflags & (CONVF_FLOAT | CONVF_UNORM | CONVF_UINT | CONVF_SNORM | CONVF_SINT)) - { - case CONVF_FLOAT: - return FORMAT_TYPE_FLOAT; - - case CONVF_UNORM: - return FORMAT_TYPE_UNORM; - - case CONVF_UINT: - return FORMAT_TYPE_UINT; - - case CONVF_SNORM: - return FORMAT_TYPE_SNORM; - - case CONVF_SINT: - return FORMAT_TYPE_SINT; - - default: - return FORMAT_TYPE_TYPELESS; - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexD3D11.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexD3D11.cpp deleted file mode 100644 index 735fc57..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexD3D11.cpp +++ /dev/null @@ -1,971 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXTexD3D11.cpp -// -// DirectX Texture Library - Direct3D 11 helpers -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//------------------------------------------------------------------------------------- - -#include "DirectXTexP.h" - -#ifdef _GAMING_XBOX -#error This module is not supported for GDK -#elif !defined(_XBOX_ONE) || !defined(_TITLE) -#include -#endif - -#ifndef IID_GRAPHICS_PPV_ARGS -#define IID_GRAPHICS_PPV_ARGS(x) IID_PPV_ARGS(x) -#endif - -using namespace DirectX; -using Microsoft::WRL::ComPtr; - -static_assert(static_cast(TEX_DIMENSION_TEXTURE1D) == static_cast(D3D11_RESOURCE_DIMENSION_TEXTURE1D), "header enum mismatch"); -static_assert(static_cast(TEX_DIMENSION_TEXTURE2D) == static_cast(D3D11_RESOURCE_DIMENSION_TEXTURE2D), "header enum mismatch"); -static_assert(static_cast(TEX_DIMENSION_TEXTURE3D) == static_cast(D3D11_RESOURCE_DIMENSION_TEXTURE3D), "header enum mismatch"); - -namespace -{ - HRESULT Capture( - _In_ ID3D11DeviceContext* pContext, - _In_ ID3D11Resource* pSource, - const TexMetadata& metadata, - const ScratchImage& result) noexcept - { - if (!pContext || !pSource || !result.GetPixels()) - return E_POINTER; - - #if defined(_XBOX_ONE) && defined(_TITLE) - - ComPtr d3dDevice; - pContext->GetDevice(d3dDevice.GetAddressOf()); - - if (d3dDevice->GetCreationFlags() & D3D11_CREATE_DEVICE_IMMEDIATE_CONTEXT_FAST_SEMANTICS) - { - ComPtr d3dDeviceX; - HRESULT hr = d3dDevice.As(&d3dDeviceX); - if (FAILED(hr)) - return hr; - - ComPtr d3dContextX; - hr = pContext->QueryInterface(IID_GRAPHICS_PPV_ARGS(d3dContextX.GetAddressOf())); - if (FAILED(hr)) - return hr; - - UINT64 copyFence = d3dContextX->InsertFence(0); - - while (d3dDeviceX->IsFencePending(copyFence)) - { - SwitchToThread(); - } - } - - #endif - - if (metadata.IsVolumemap()) - { - //--- Volume texture ---------------------------------------------------------- - assert(metadata.arraySize == 1); - - size_t height = metadata.height; - size_t depth = metadata.depth; - - for (size_t level = 0; level < metadata.mipLevels; ++level) - { - const UINT dindex = D3D11CalcSubresource(static_cast(level), 0, static_cast(metadata.mipLevels)); - - D3D11_MAPPED_SUBRESOURCE mapped; - HRESULT hr = pContext->Map(pSource, dindex, D3D11_MAP_READ, 0, &mapped); - if (FAILED(hr)) - return hr; - - auto pslice = static_cast(mapped.pData); - if (!pslice) - { - pContext->Unmap(pSource, dindex); - return E_POINTER; - } - - const size_t lines = ComputeScanlines(metadata.format, height); - if (!lines) - { - pContext->Unmap(pSource, dindex); - return E_UNEXPECTED; - } - - for (size_t slice = 0; slice < depth; ++slice) - { - const Image* img = result.GetImage(level, 0, slice); - if (!img) - { - pContext->Unmap(pSource, dindex); - return E_FAIL; - } - - if (!img->pixels) - { - pContext->Unmap(pSource, dindex); - return E_POINTER; - } - - const uint8_t* sptr = pslice; - uint8_t* dptr = img->pixels; - for (size_t h = 0; h < lines; ++h) - { - const size_t msize = std::min(img->rowPitch, mapped.RowPitch); - memcpy(dptr, sptr, msize); - sptr += mapped.RowPitch; - dptr += img->rowPitch; - } - - pslice += mapped.DepthPitch; - } - - pContext->Unmap(pSource, dindex); - - if (height > 1) - height >>= 1; - if (depth > 1) - depth >>= 1; - } - } - else - { - //--- 1D or 2D texture -------------------------------------------------------- - assert(metadata.depth == 1); - - for (size_t item = 0; item < metadata.arraySize; ++item) - { - size_t height = metadata.height; - - for (size_t level = 0; level < metadata.mipLevels; ++level) - { - const UINT dindex = D3D11CalcSubresource(static_cast(level), static_cast(item), static_cast(metadata.mipLevels)); - - D3D11_MAPPED_SUBRESOURCE mapped; - HRESULT hr = pContext->Map(pSource, dindex, D3D11_MAP_READ, 0, &mapped); - if (FAILED(hr)) - return hr; - - const Image* img = result.GetImage(level, item, 0); - if (!img) - { - pContext->Unmap(pSource, dindex); - return E_FAIL; - } - - if (!img->pixels) - { - pContext->Unmap(pSource, dindex); - return E_POINTER; - } - - const size_t lines = ComputeScanlines(metadata.format, height); - if (!lines) - { - pContext->Unmap(pSource, dindex); - return E_UNEXPECTED; - } - - const size_t msize = (metadata.dimension == TEX_DIMENSION_TEXTURE2D) - ? std::min(img->rowPitch, mapped.RowPitch) : img->rowPitch; - - auto sptr = static_cast(mapped.pData); - uint8_t* dptr = img->pixels; - for (size_t h = 0; h < lines; ++h) - { - memcpy(dptr, sptr, msize); - sptr += mapped.RowPitch; - dptr += img->rowPitch; - } - - pContext->Unmap(pSource, dindex); - - if (height > 1) - height >>= 1; - } - } - } - - return S_OK; - } -} - - -//===================================================================================== -// Entry-points -//===================================================================================== - -//------------------------------------------------------------------------------------- -// Determine if given texture metadata is supported on the given device -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -bool DirectX::IsSupportedTexture( - ID3D11Device* pDevice, - const TexMetadata& metadata) noexcept -{ - if (!pDevice) - return false; - - const D3D_FEATURE_LEVEL fl = pDevice->GetFeatureLevel(); - - // Validate format - const DXGI_FORMAT fmt = metadata.format; - - if (!IsValid(fmt)) - return false; - - switch (fmt) - { - case DXGI_FORMAT_BC4_TYPELESS: - case DXGI_FORMAT_BC4_UNORM: - case DXGI_FORMAT_BC4_SNORM: - case DXGI_FORMAT_BC5_TYPELESS: - case DXGI_FORMAT_BC5_UNORM: - case DXGI_FORMAT_BC5_SNORM: - if (fl < D3D_FEATURE_LEVEL_10_0) - return false; - break; - - case DXGI_FORMAT_BC6H_TYPELESS: - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - case DXGI_FORMAT_BC7_TYPELESS: - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: - if (fl < D3D_FEATURE_LEVEL_11_0) - return false; - break; - - default: - break; - } - - // Validate miplevel count - if (metadata.mipLevels > D3D11_REQ_MIP_LEVELS) - return false; - - // Validate array size, dimension, and width/height - const size_t arraySize = metadata.arraySize; - const size_t iWidth = metadata.width; - const size_t iHeight = metadata.height; - const size_t iDepth = metadata.depth; - - // Most cases are known apriori based on feature level, but we use this for robustness to handle the few optional cases - UINT formatSupport = 0; - HRESULT hr = pDevice->CheckFormatSupport(fmt, &formatSupport); - if (FAILED(hr)) - { - formatSupport = 0; - } - - if (metadata.mipLevels > 1 && !(formatSupport & D3D11_FORMAT_SUPPORT_MIP)) - { - return false; - } - - switch (metadata.dimension) - { - case TEX_DIMENSION_TEXTURE1D: - if (!(formatSupport & D3D11_FORMAT_SUPPORT_TEXTURE1D)) - return false; - - if ((arraySize > D3D11_REQ_TEXTURE1D_ARRAY_AXIS_DIMENSION) - || (iWidth > D3D11_REQ_TEXTURE1D_U_DIMENSION)) - return false; - - if (fl < D3D_FEATURE_LEVEL_11_0) - { - if ((arraySize > D3D10_REQ_TEXTURE1D_ARRAY_AXIS_DIMENSION) - || (iWidth > D3D10_REQ_TEXTURE1D_U_DIMENSION)) - return false; - - if (fl < D3D_FEATURE_LEVEL_10_0) - { - if ((arraySize > 1) || (iWidth > D3D_FL9_3_REQ_TEXTURE1D_U_DIMENSION)) - return false; - - if ((fl < D3D_FEATURE_LEVEL_9_3) && (iWidth > D3D_FL9_1_REQ_TEXTURE1D_U_DIMENSION)) - return false; - } - } - break; - - case TEX_DIMENSION_TEXTURE2D: - if (metadata.IsCubemap()) - { - if (!(formatSupport & D3D11_FORMAT_SUPPORT_TEXTURECUBE)) - return false; - - if ((arraySize > D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION) - || (iWidth > D3D11_REQ_TEXTURECUBE_DIMENSION) - || (iHeight > D3D11_REQ_TEXTURECUBE_DIMENSION)) - return false; - - if (fl < D3D_FEATURE_LEVEL_11_0) - { - if ((arraySize > D3D10_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION) - || (iWidth > D3D10_REQ_TEXTURECUBE_DIMENSION) - || (iHeight > D3D10_REQ_TEXTURECUBE_DIMENSION)) - return false; - - if ((fl < D3D_FEATURE_LEVEL_10_1) && (arraySize != 6)) - return false; - - if (fl < D3D_FEATURE_LEVEL_10_0) - { - if ((iWidth > D3D_FL9_3_REQ_TEXTURECUBE_DIMENSION) - || (iHeight > D3D_FL9_3_REQ_TEXTURECUBE_DIMENSION)) - return false; - - if ((fl < D3D_FEATURE_LEVEL_9_3) - && ((iWidth > D3D_FL9_1_REQ_TEXTURECUBE_DIMENSION) - || (iHeight > D3D_FL9_1_REQ_TEXTURECUBE_DIMENSION))) - return false; - } - } - } - else // Not a cube map - { - if (!(formatSupport & D3D11_FORMAT_SUPPORT_TEXTURE2D)) - return false; - - if ((arraySize > D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION) - || (iWidth > D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION) - || (iHeight > D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION)) - return false; - - if (fl < D3D_FEATURE_LEVEL_11_0) - { - if ((arraySize > D3D10_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION) - || (iWidth > D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION) - || (iHeight > D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION)) - return false; - - if (fl < D3D_FEATURE_LEVEL_10_0) - { - if ((arraySize > 1) - || (iWidth > D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION) - || (iHeight > D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION)) - return false; - - if ((fl < D3D_FEATURE_LEVEL_9_3) - && ((iWidth > D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION) - || (iHeight > D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION))) - return false; - } - } - } - break; - - case TEX_DIMENSION_TEXTURE3D: - if (!(formatSupport & D3D11_FORMAT_SUPPORT_TEXTURE3D)) - return false; - - if ((arraySize > 1) - || (iWidth > D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION) - || (iHeight > D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION) - || (iDepth > D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION)) - return false; - - if (fl < D3D_FEATURE_LEVEL_11_0) - { - if ((iWidth > D3D10_REQ_TEXTURE3D_U_V_OR_W_DIMENSION) - || (iHeight > D3D10_REQ_TEXTURE3D_U_V_OR_W_DIMENSION) - || (iDepth > D3D10_REQ_TEXTURE3D_U_V_OR_W_DIMENSION)) - return false; - - if (fl < D3D_FEATURE_LEVEL_10_0) - { - if ((iWidth > D3D_FL9_1_REQ_TEXTURE3D_U_V_OR_W_DIMENSION) - || (iHeight > D3D_FL9_1_REQ_TEXTURE3D_U_V_OR_W_DIMENSION) - || (iDepth > D3D_FL9_1_REQ_TEXTURE3D_U_V_OR_W_DIMENSION)) - return false; - } - } - break; - - default: - // Not a supported dimension - return false; - } - - return true; -} - - -//------------------------------------------------------------------------------------- -// Create a texture resource -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::CreateTexture( - ID3D11Device* pDevice, - const Image* srcImages, - size_t nimages, - const TexMetadata& metadata, - ID3D11Resource** ppResource) noexcept -{ - return CreateTextureEx( - pDevice, srcImages, nimages, metadata, - D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, false, - ppResource); -} - -_Use_decl_annotations_ -HRESULT DirectX::CreateTextureEx( - ID3D11Device* pDevice, - const Image* srcImages, - size_t nimages, - const TexMetadata& metadata, - D3D11_USAGE usage, - unsigned int bindFlags, - unsigned int cpuAccessFlags, - unsigned int miscFlags, - bool forceSRGB, - ID3D11Resource** ppResource) noexcept -{ - if (!pDevice || !srcImages || !nimages || !ppResource) - return E_INVALIDARG; - - *ppResource = nullptr; - - if (!metadata.mipLevels || !metadata.arraySize) - return E_INVALIDARG; - - if ((metadata.width > UINT32_MAX) || (metadata.height > UINT32_MAX) - || (metadata.mipLevels > UINT16_MAX) || (metadata.arraySize > UINT16_MAX)) - return E_INVALIDARG; - - std::unique_ptr initData(new (std::nothrow) D3D11_SUBRESOURCE_DATA[metadata.mipLevels * metadata.arraySize]); - if (!initData) - return E_OUTOFMEMORY; - - // Fill out subresource array - if (metadata.IsVolumemap()) - { - //--- Volume case ------------------------------------------------------------- - if (!metadata.depth) - return E_INVALIDARG; - - if (metadata.depth > UINT16_MAX) - return E_INVALIDARG; - - if (metadata.arraySize > 1) - // Direct3D 11 doesn't support arrays of 3D textures - return HRESULT_E_NOT_SUPPORTED; - - size_t depth = metadata.depth; - - size_t idx = 0; - for (size_t level = 0; level < metadata.mipLevels; ++level) - { - const size_t index = metadata.ComputeIndex(level, 0, 0); - if (index >= nimages) - return E_FAIL; - - const Image& img = srcImages[index]; - - if (img.format != metadata.format) - return E_FAIL; - - if (!img.pixels) - return E_POINTER; - - // Verify pixels in image 1 .. (depth-1) are exactly image->slicePitch apart - // For 3D textures, this relies on all slices of the same miplevel being continous in memory - // (this is how ScratchImage lays them out), which is why we just give the 0th slice to Direct3D 11 - const uint8_t* pSlice = img.pixels + img.slicePitch; - for (size_t slice = 1; slice < depth; ++slice) - { - const size_t tindex = metadata.ComputeIndex(level, 0, slice); - if (tindex >= nimages) - return E_FAIL; - - const Image& timg = srcImages[tindex]; - - if (!timg.pixels) - return E_POINTER; - - if (timg.pixels != pSlice - || timg.format != metadata.format - || timg.rowPitch != img.rowPitch - || timg.slicePitch != img.slicePitch) - return E_FAIL; - - pSlice = timg.pixels + img.slicePitch; - } - - assert(idx < (metadata.mipLevels * metadata.arraySize)); - - initData[idx].pSysMem = img.pixels; - initData[idx].SysMemPitch = static_cast(img.rowPitch); - initData[idx].SysMemSlicePitch = static_cast(img.slicePitch); - ++idx; - - if (depth > 1) - depth >>= 1; - } - } - else - { - //--- 1D or 2D texture case --------------------------------------------------- - size_t idx = 0; - for (size_t item = 0; item < metadata.arraySize; ++item) - { - for (size_t level = 0; level < metadata.mipLevels; ++level) - { - const size_t index = metadata.ComputeIndex(level, item, 0); - if (index >= nimages) - return E_FAIL; - - const Image& img = srcImages[index]; - - if (img.format != metadata.format) - return E_FAIL; - - if (!img.pixels) - return E_POINTER; - - assert(idx < (metadata.mipLevels * metadata.arraySize)); - - initData[idx].pSysMem = img.pixels; - initData[idx].SysMemPitch = static_cast(img.rowPitch); - initData[idx].SysMemSlicePitch = static_cast(img.slicePitch); - ++idx; - } - } - } - - // Create texture using static initialization data - HRESULT hr = E_UNEXPECTED; - - const DXGI_FORMAT tformat = (forceSRGB) ? MakeSRGB(metadata.format) : metadata.format; - - switch (metadata.dimension) - { - case TEX_DIMENSION_TEXTURE1D: - { - D3D11_TEXTURE1D_DESC desc = {}; - desc.Width = static_cast(metadata.width); - desc.MipLevels = static_cast(metadata.mipLevels); - desc.ArraySize = static_cast(metadata.arraySize); - desc.Format = tformat; - desc.Usage = usage; - desc.BindFlags = bindFlags; - desc.CPUAccessFlags = cpuAccessFlags; - desc.MiscFlags = miscFlags & ~static_cast(D3D11_RESOURCE_MISC_TEXTURECUBE); - - hr = pDevice->CreateTexture1D(&desc, initData.get(), reinterpret_cast(ppResource)); - } - break; - - case TEX_DIMENSION_TEXTURE2D: - { - D3D11_TEXTURE2D_DESC desc = {}; - desc.Width = static_cast(metadata.width); - desc.Height = static_cast(metadata.height); - desc.MipLevels = static_cast(metadata.mipLevels); - desc.ArraySize = static_cast(metadata.arraySize); - desc.Format = tformat; - desc.SampleDesc.Count = 1; - desc.SampleDesc.Quality = 0; - desc.Usage = usage; - desc.BindFlags = bindFlags; - desc.CPUAccessFlags = cpuAccessFlags; - if (metadata.IsCubemap()) - desc.MiscFlags = miscFlags | D3D11_RESOURCE_MISC_TEXTURECUBE; - else - desc.MiscFlags = miscFlags & ~static_cast(D3D11_RESOURCE_MISC_TEXTURECUBE); - - hr = pDevice->CreateTexture2D(&desc, initData.get(), reinterpret_cast(ppResource)); - } - break; - - case TEX_DIMENSION_TEXTURE3D: - { - D3D11_TEXTURE3D_DESC desc = {}; - desc.Width = static_cast(metadata.width); - desc.Height = static_cast(metadata.height); - desc.Depth = static_cast(metadata.depth); - desc.MipLevels = static_cast(metadata.mipLevels); - desc.Format = tformat; - desc.Usage = usage; - desc.BindFlags = bindFlags; - desc.CPUAccessFlags = cpuAccessFlags; - desc.MiscFlags = miscFlags & ~static_cast(D3D11_RESOURCE_MISC_TEXTURECUBE); - - hr = pDevice->CreateTexture3D(&desc, initData.get(), reinterpret_cast(ppResource)); - } - break; - } - - return hr; -} - - -//------------------------------------------------------------------------------------- -// Create a shader resource view and associated texture -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::CreateShaderResourceView( - ID3D11Device* pDevice, - const Image* srcImages, - size_t nimages, - const TexMetadata& metadata, - ID3D11ShaderResourceView** ppSRV) noexcept -{ - return CreateShaderResourceViewEx( - pDevice, srcImages, nimages, metadata, - D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, false, - ppSRV); -} - -_Use_decl_annotations_ -HRESULT DirectX::CreateShaderResourceViewEx( - ID3D11Device* pDevice, - const Image* srcImages, - size_t nimages, - const TexMetadata& metadata, - D3D11_USAGE usage, - unsigned int bindFlags, - unsigned int cpuAccessFlags, - unsigned int miscFlags, - bool forceSRGB, - ID3D11ShaderResourceView** ppSRV) noexcept -{ - if (!ppSRV) - return E_INVALIDARG; - - *ppSRV = nullptr; - - if (!(bindFlags & D3D11_BIND_SHADER_RESOURCE)) - return E_INVALIDARG; - - ComPtr resource; - HRESULT hr = CreateTextureEx(pDevice, srcImages, nimages, metadata, - usage, bindFlags, cpuAccessFlags, miscFlags, forceSRGB, - resource.GetAddressOf()); - if (FAILED(hr)) - return hr; - - assert(resource); - - D3D11_SHADER_RESOURCE_VIEW_DESC SRVDesc = {}; - if (forceSRGB) - SRVDesc.Format = MakeSRGB(metadata.format); - else - SRVDesc.Format = metadata.format; - - switch (metadata.dimension) - { - case TEX_DIMENSION_TEXTURE1D: - if (metadata.arraySize > 1) - { - SRVDesc.ViewDimension = D3D_SRV_DIMENSION_TEXTURE1DARRAY; - SRVDesc.Texture1DArray.MipLevels = static_cast(metadata.mipLevels); - SRVDesc.Texture1DArray.ArraySize = static_cast(metadata.arraySize); - } - else - { - SRVDesc.ViewDimension = D3D_SRV_DIMENSION_TEXTURE1D; - SRVDesc.Texture1D.MipLevels = static_cast(metadata.mipLevels); - } - break; - - case TEX_DIMENSION_TEXTURE2D: - if (metadata.IsCubemap()) - { - if (metadata.arraySize > 6) - { - assert((metadata.arraySize % 6) == 0); - SRVDesc.ViewDimension = D3D_SRV_DIMENSION_TEXTURECUBEARRAY; - SRVDesc.TextureCubeArray.MipLevels = static_cast(metadata.mipLevels); - SRVDesc.TextureCubeArray.NumCubes = static_cast(metadata.arraySize / 6); - } - else - { - SRVDesc.ViewDimension = D3D_SRV_DIMENSION_TEXTURECUBE; - SRVDesc.TextureCube.MipLevels = static_cast(metadata.mipLevels); - } - } - else if (metadata.arraySize > 1) - { - SRVDesc.ViewDimension = D3D_SRV_DIMENSION_TEXTURE2DARRAY; - SRVDesc.Texture2DArray.MipLevels = static_cast(metadata.mipLevels); - SRVDesc.Texture2DArray.ArraySize = static_cast(metadata.arraySize); - } - else - { - SRVDesc.ViewDimension = D3D_SRV_DIMENSION_TEXTURE2D; - SRVDesc.Texture2D.MipLevels = static_cast(metadata.mipLevels); - } - break; - - case TEX_DIMENSION_TEXTURE3D: - assert(metadata.arraySize == 1); - SRVDesc.ViewDimension = D3D_SRV_DIMENSION_TEXTURE3D; - SRVDesc.Texture3D.MipLevels = static_cast(metadata.mipLevels); - break; - - default: - return E_FAIL; - } - - hr = pDevice->CreateShaderResourceView(resource.Get(), &SRVDesc, ppSRV); - if (FAILED(hr)) - return hr; - - assert(*ppSRV); - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -// Save a texture resource -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::CaptureTexture( - ID3D11Device* pDevice, - ID3D11DeviceContext* pContext, - ID3D11Resource* pSource, - ScratchImage& result) noexcept -{ - if (!pDevice || !pContext || !pSource) - return E_INVALIDARG; - - D3D11_RESOURCE_DIMENSION resType = D3D11_RESOURCE_DIMENSION_UNKNOWN; - pSource->GetType(&resType); - - HRESULT hr = E_UNEXPECTED; - - switch (resType) - { - case D3D11_RESOURCE_DIMENSION_TEXTURE1D: - { - ComPtr pTexture; - hr = pSource->QueryInterface(IID_GRAPHICS_PPV_ARGS(pTexture.GetAddressOf())); - if (FAILED(hr)) - break; - - assert(pTexture); - - D3D11_TEXTURE1D_DESC desc; - pTexture->GetDesc(&desc); - - ComPtr pStaging; - if ((desc.Usage == D3D11_USAGE_STAGING) && (desc.CPUAccessFlags & D3D11_CPU_ACCESS_READ)) - { - // Handle case where the source is already a staging texture we can use directly - pStaging = pTexture; - } - else - { - desc.BindFlags = 0; - desc.MiscFlags = 0; - desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; - desc.Usage = D3D11_USAGE_STAGING; - - hr = pDevice->CreateTexture1D(&desc, nullptr, pStaging.GetAddressOf()); - if (FAILED(hr)) - break; - - assert(pStaging); - - pContext->CopyResource(pStaging.Get(), pSource); - } - - TexMetadata mdata; - mdata.width = desc.Width; - mdata.height = mdata.depth = 1; - mdata.arraySize = desc.ArraySize; - mdata.mipLevels = desc.MipLevels; - mdata.miscFlags = 0; - mdata.miscFlags2 = 0; - mdata.format = desc.Format; - mdata.dimension = TEX_DIMENSION_TEXTURE1D; - - hr = result.Initialize(mdata); - if (FAILED(hr)) - break; - - hr = Capture(pContext, pStaging.Get(), mdata, result); - } - break; - - case D3D11_RESOURCE_DIMENSION_TEXTURE2D: - { - ComPtr pTexture; - hr = pSource->QueryInterface(IID_GRAPHICS_PPV_ARGS(pTexture.GetAddressOf())); - if (FAILED(hr)) - break; - - assert(pTexture); - - D3D11_TEXTURE2D_DESC desc; - pTexture->GetDesc(&desc); - - ComPtr pStaging; - if (desc.SampleDesc.Count > 1) - { - desc.SampleDesc.Count = 1; - desc.SampleDesc.Quality = 0; - - ComPtr pTemp; - hr = pDevice->CreateTexture2D(&desc, nullptr, pTemp.GetAddressOf()); - if (FAILED(hr)) - break; - - assert(pTemp); - - DXGI_FORMAT fmt = desc.Format; - if (IsTypeless(fmt)) - { - // Assume a UNORM if it exists otherwise use FLOAT - fmt = MakeTypelessUNORM(fmt); - fmt = MakeTypelessFLOAT(fmt); - } - - UINT support = 0; - hr = pDevice->CheckFormatSupport(fmt, &support); - if (FAILED(hr)) - break; - - if (!(support & D3D11_FORMAT_SUPPORT_MULTISAMPLE_RESOLVE)) - { - hr = E_FAIL; - break; - } - - for (UINT item = 0; item < desc.ArraySize; ++item) - { - for (UINT level = 0; level < desc.MipLevels; ++level) - { - const UINT index = D3D11CalcSubresource(level, item, desc.MipLevels); - pContext->ResolveSubresource(pTemp.Get(), index, pSource, index, fmt); - } - } - - desc.BindFlags = 0; - desc.MiscFlags &= D3D11_RESOURCE_MISC_TEXTURECUBE; - desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; - desc.Usage = D3D11_USAGE_STAGING; - - hr = pDevice->CreateTexture2D(&desc, nullptr, pStaging.GetAddressOf()); - if (FAILED(hr)) - break; - - assert(pStaging); - - pContext->CopyResource(pStaging.Get(), pTemp.Get()); - } - else if ((desc.Usage == D3D11_USAGE_STAGING) && (desc.CPUAccessFlags & D3D11_CPU_ACCESS_READ)) - { - // Handle case where the source is already a staging texture we can use directly - pStaging = pTexture; - } - else - { - desc.BindFlags = 0; - desc.MiscFlags &= D3D11_RESOURCE_MISC_TEXTURECUBE; - desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; - desc.Usage = D3D11_USAGE_STAGING; - - hr = pDevice->CreateTexture2D(&desc, nullptr, &pStaging); - if (FAILED(hr)) - break; - - assert(pStaging); - - pContext->CopyResource(pStaging.Get(), pSource); - } - - TexMetadata mdata; - mdata.width = desc.Width; - mdata.height = desc.Height; - mdata.depth = 1; - mdata.arraySize = desc.ArraySize; - mdata.mipLevels = desc.MipLevels; - mdata.miscFlags = (desc.MiscFlags & D3D11_RESOURCE_MISC_TEXTURECUBE) ? TEX_MISC_TEXTURECUBE : 0u; - mdata.miscFlags2 = 0; - mdata.format = desc.Format; - mdata.dimension = TEX_DIMENSION_TEXTURE2D; - - hr = result.Initialize(mdata); - if (FAILED(hr)) - break; - - hr = Capture(pContext, pStaging.Get(), mdata, result); - } - break; - - case D3D11_RESOURCE_DIMENSION_TEXTURE3D: - { - ComPtr pTexture; - hr = pSource->QueryInterface(IID_GRAPHICS_PPV_ARGS(pTexture.GetAddressOf())); - if (FAILED(hr)) - break; - - assert(pTexture); - - D3D11_TEXTURE3D_DESC desc; - pTexture->GetDesc(&desc); - - ComPtr pStaging; - if ((desc.Usage == D3D11_USAGE_STAGING) && (desc.CPUAccessFlags & D3D11_CPU_ACCESS_READ)) - { - // Handle case where the source is already a staging texture we can use directly - pStaging = pTexture; - } - else - { - desc.BindFlags = 0; - desc.MiscFlags = 0; - desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; - desc.Usage = D3D11_USAGE_STAGING; - - hr = pDevice->CreateTexture3D(&desc, nullptr, pStaging.GetAddressOf()); - if (FAILED(hr)) - break; - - assert(pStaging); - - pContext->CopyResource(pStaging.Get(), pSource); - } - - TexMetadata mdata; - mdata.width = desc.Width; - mdata.height = desc.Height; - mdata.depth = desc.Depth; - mdata.arraySize = 1; - mdata.mipLevels = desc.MipLevels; - mdata.miscFlags = 0; - mdata.miscFlags2 = 0; - mdata.format = desc.Format; - mdata.dimension = TEX_DIMENSION_TEXTURE3D; - - hr = result.Initialize(mdata); - if (FAILED(hr)) - break; - - hr = Capture(pContext, pStaging.Get(), mdata, result); - } - break; - - default: - hr = E_FAIL; - break; - } - - if (FAILED(hr)) - { - result.Release(); - return hr; - } - - return S_OK; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexD3D12.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexD3D12.cpp deleted file mode 100644 index 9ebbee5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexD3D12.cpp +++ /dev/null @@ -1,817 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXTexD3D12.cpp -// -// DirectX Texture Library - Direct3D 12 helpers -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//------------------------------------------------------------------------------------- - -#include "DirectXTexP.h" - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wsign-conversion" -#pragma clang diagnostic ignored "-Wunused-macros" -#endif - -#define D3DX12_NO_STATE_OBJECT_HELPERS -#define D3DX12_NO_CHECK_FEATURE_SUPPORT_CLASS -#ifdef _GAMING_XBOX_SCARLETT -#include -#elif (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX) -#include "d3dx12_x.h" -#elif !defined(_WIN32) || defined(USING_DIRECTX_HEADERS) -#include "directx/d3dx12.h" -#include "dxguids/dxguids.h" -#else -#include "d3dx12.h" -#endif - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -#ifndef IID_GRAPHICS_PPV_ARGS -#define IID_GRAPHICS_PPV_ARGS(x) IID_PPV_ARGS(x) -#endif - -using namespace DirectX; -using Microsoft::WRL::ComPtr; - -static_assert(static_cast(TEX_DIMENSION_TEXTURE1D) == static_cast(D3D12_RESOURCE_DIMENSION_TEXTURE1D), "header enum mismatch"); -static_assert(static_cast(TEX_DIMENSION_TEXTURE2D) == static_cast(D3D12_RESOURCE_DIMENSION_TEXTURE2D), "header enum mismatch"); -static_assert(static_cast(TEX_DIMENSION_TEXTURE3D) == static_cast(D3D12_RESOURCE_DIMENSION_TEXTURE3D), "header enum mismatch"); - -namespace -{ - template void AdjustPlaneResource( - _In_ DXGI_FORMAT fmt, - _In_ size_t height, - _In_ size_t slicePlane, - _Inout_ T& res) noexcept - { - switch (static_cast(fmt)) - { - case DXGI_FORMAT_NV12: - case DXGI_FORMAT_P010: - case DXGI_FORMAT_P016: - case XBOX_DXGI_FORMAT_D16_UNORM_S8_UINT: - case XBOX_DXGI_FORMAT_R16_UNORM_X8_TYPELESS: - case XBOX_DXGI_FORMAT_X16_TYPELESS_G8_UINT: - if (!slicePlane) - { - // Plane 0 - res.SlicePitch = res.RowPitch * static_cast(height); - } - else - { - // Plane 1 - res.pData = const_cast(reinterpret_cast(res.pData) + res.RowPitch * PT(height)); - res.SlicePitch = res.RowPitch * static_cast((height + 1) >> 1); - } - break; - - case DXGI_FORMAT_NV11: - if (!slicePlane) - { - // Plane 0 - res.SlicePitch = res.RowPitch * static_cast(height); - } - else - { - // Plane 1 - res.pData = const_cast(reinterpret_cast(res.pData) + res.RowPitch * PT(height)); - res.RowPitch = (res.RowPitch >> 1); - res.SlicePitch = res.RowPitch * static_cast(height); - } - break; - } - } - - - //-------------------------------------------------------------------------------------- - inline void TransitionResource( - _In_ ID3D12GraphicsCommandList* commandList, - _In_ ID3D12Resource* resource, - _In_ D3D12_RESOURCE_STATES stateBefore, - _In_ D3D12_RESOURCE_STATES stateAfter) - { - assert(commandList != nullptr); - assert(resource != nullptr); - - if (stateBefore == stateAfter) - return; - - D3D12_RESOURCE_BARRIER desc = {}; - desc.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; - desc.Transition.pResource = resource; - desc.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES; - desc.Transition.StateBefore = stateBefore; - desc.Transition.StateAfter = stateAfter; - - commandList->ResourceBarrier(1, &desc); - } - - - //-------------------------------------------------------------------------------------- - HRESULT Capture(_In_ ID3D12Device* device, - _In_ ID3D12CommandQueue* pCommandQ, - _In_ ID3D12Resource* pSource, - const D3D12_RESOURCE_DESC& desc, - ComPtr& pStaging, - std::unique_ptr& layoutBuff, - UINT& numberOfPlanes, - UINT& numberOfResources, - D3D12_RESOURCE_STATES beforeState, - D3D12_RESOURCE_STATES afterState) noexcept - { - if (!pCommandQ || !pSource) - return E_INVALIDARG; - - numberOfPlanes = D3D12GetFormatPlaneCount(device, desc.Format); - if (!numberOfPlanes) - return E_INVALIDARG; - - if ((numberOfPlanes > 1) && IsDepthStencil(desc.Format)) - { - // DirectX 12 uses planes for stencil, DirectX 11 does not - return HRESULT_E_NOT_SUPPORTED; - } - - numberOfResources = (desc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D) - ? 1u : desc.DepthOrArraySize; - numberOfResources *= desc.MipLevels; - numberOfResources *= numberOfPlanes; - - if (numberOfResources > D3D12_REQ_SUBRESOURCES) - return E_UNEXPECTED; - - const size_t memAlloc = (sizeof(D3D12_PLACED_SUBRESOURCE_FOOTPRINT) + sizeof(UINT) + sizeof(UINT64)) * numberOfResources; - if (memAlloc > SIZE_MAX) - return E_UNEXPECTED; - - layoutBuff.reset(new (std::nothrow) uint8_t[memAlloc]); - if (!layoutBuff) - return E_OUTOFMEMORY; - - auto pLayout = reinterpret_cast(layoutBuff.get()); - auto pRowSizesInBytes = reinterpret_cast(pLayout + numberOfResources); - auto pNumRows = reinterpret_cast(pRowSizesInBytes + numberOfResources); - - UINT64 totalResourceSize = 0; - device->GetCopyableFootprints(&desc, 0, numberOfResources, 0, - pLayout, pNumRows, pRowSizesInBytes, &totalResourceSize); - - D3D12_HEAP_PROPERTIES sourceHeapProperties; - HRESULT hr = pSource->GetHeapProperties(&sourceHeapProperties, nullptr); - if (SUCCEEDED(hr) && sourceHeapProperties.Type == D3D12_HEAP_TYPE_READBACK) - { - // Handle case where the source is already a staging texture we can use directly - pStaging = pSource; - return S_OK; - } - - // Create a command allocator - ComPtr commandAlloc; - hr = device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_GRAPHICS_PPV_ARGS(commandAlloc.GetAddressOf())); - if (FAILED(hr)) - return hr; - - // Spin up a new command list - ComPtr commandList; - hr = device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, commandAlloc.Get(), nullptr, IID_GRAPHICS_PPV_ARGS(commandList.GetAddressOf())); - if (FAILED(hr)) - return hr; - - // Create a fence - ComPtr fence; - hr = device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_GRAPHICS_PPV_ARGS(fence.GetAddressOf())); - if (FAILED(hr)) - return hr; - - const CD3DX12_HEAP_PROPERTIES defaultHeapProperties(D3D12_HEAP_TYPE_DEFAULT); - const CD3DX12_HEAP_PROPERTIES readBackHeapProperties(D3D12_HEAP_TYPE_READBACK); - - // Readback resources must be buffers - D3D12_RESOURCE_DESC bufferDesc = {}; - bufferDesc.DepthOrArraySize = 1; - bufferDesc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; - bufferDesc.Flags = D3D12_RESOURCE_FLAG_NONE; - bufferDesc.Format = DXGI_FORMAT_UNKNOWN; - bufferDesc.Height = 1; - bufferDesc.Width = totalResourceSize; - bufferDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; - bufferDesc.MipLevels = 1; - bufferDesc.SampleDesc.Count = 1; - - ComPtr copySource(pSource); - if (desc.SampleDesc.Count > 1) - { - // MSAA content must be resolved before being copied to a staging texture - auto descCopy = desc; - descCopy.SampleDesc.Count = 1; - descCopy.SampleDesc.Quality = 0; - descCopy.Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT; - - ComPtr pTemp; - hr = device->CreateCommittedResource( - &defaultHeapProperties, - D3D12_HEAP_FLAG_NONE, - &descCopy, - D3D12_RESOURCE_STATE_COPY_DEST, - nullptr, - IID_GRAPHICS_PPV_ARGS(pTemp.GetAddressOf())); - if (FAILED(hr)) - return hr; - - assert(pTemp); - - DXGI_FORMAT fmt = desc.Format; - if (IsTypeless(fmt)) - { - // Assume a UNORM if it exists otherwise use FLOAT - fmt = MakeTypelessUNORM(fmt); - fmt = MakeTypelessFLOAT(fmt); - } - - D3D12_FEATURE_DATA_FORMAT_SUPPORT formatInfo = { fmt, D3D12_FORMAT_SUPPORT1_NONE, D3D12_FORMAT_SUPPORT2_NONE }; - hr = device->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT, &formatInfo, sizeof(formatInfo)); - if (FAILED(hr)) - return hr; - - if (!(formatInfo.Support1 & D3D12_FORMAT_SUPPORT1_TEXTURE2D)) - return E_FAIL; - - for (UINT plane = 0; plane < numberOfPlanes; ++plane) - { - for (UINT item = 0; item < desc.DepthOrArraySize; ++item) - { - for (UINT level = 0; level < desc.MipLevels; ++level) - { - const UINT index = D3D12CalcSubresource(level, item, plane, desc.MipLevels, desc.DepthOrArraySize); - commandList->ResolveSubresource(pTemp.Get(), index, pSource, index, fmt); - } - } - } - - copySource = pTemp; - } - - // Create a staging texture - hr = device->CreateCommittedResource( - &readBackHeapProperties, - D3D12_HEAP_FLAG_NONE, - &bufferDesc, - D3D12_RESOURCE_STATE_COPY_DEST, - nullptr, - IID_GRAPHICS_PPV_ARGS(pStaging.GetAddressOf())); - if (FAILED(hr)) - return hr; - - assert(pStaging); - - // Transition the resource if necessary - TransitionResource(commandList.Get(), pSource, beforeState, D3D12_RESOURCE_STATE_COPY_SOURCE); - - // Get the copy target location - for (UINT j = 0; j < numberOfResources; ++j) - { - const CD3DX12_TEXTURE_COPY_LOCATION copyDest(pStaging.Get(), pLayout[j]); - const CD3DX12_TEXTURE_COPY_LOCATION copySrc(copySource.Get(), j); - commandList->CopyTextureRegion(©Dest, 0, 0, 0, ©Src, nullptr); - } - - // Transition the resource to the next state - TransitionResource(commandList.Get(), pSource, D3D12_RESOURCE_STATE_COPY_SOURCE, afterState); - - hr = commandList->Close(); - if (FAILED(hr)) - return hr; - - // Execute the command list - pCommandQ->ExecuteCommandLists(1, CommandListCast(commandList.GetAddressOf())); - - // Signal the fence - hr = pCommandQ->Signal(fence.Get(), 1); - if (FAILED(hr)) - return hr; - - // Block until the copy is complete - while (fence->GetCompletedValue() < 1) - { - #ifdef _WIN32 - SwitchToThread(); - #else - std::this_thread::yield(); - #endif - } - - return S_OK; - } -} - - -//===================================================================================== -// Entry-points -//===================================================================================== - -//------------------------------------------------------------------------------------- -// Determine if given texture metadata is supported on the given device -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -bool DirectX::IsSupportedTexture( - ID3D12Device* pDevice, - const TexMetadata& metadata) noexcept -{ - if (!pDevice) - return false; - - // Validate format - const DXGI_FORMAT fmt = metadata.format; - - if (!IsValid(fmt)) - return false; - - // Validate miplevel count - if (metadata.mipLevels > D3D12_REQ_MIP_LEVELS) - return false; - - // Validate array size, dimension, and width/height - const size_t arraySize = metadata.arraySize; - const size_t iWidth = metadata.width; - const size_t iHeight = metadata.height; - const size_t iDepth = metadata.depth; - - // Most cases are known apriori based on feature level, but we use this for robustness to handle the few optional cases - D3D12_FEATURE_DATA_FORMAT_SUPPORT formatSupport = { fmt, D3D12_FORMAT_SUPPORT1_NONE, D3D12_FORMAT_SUPPORT2_NONE }; - HRESULT hr = pDevice->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT, &formatSupport, sizeof(formatSupport)); - if (FAILED(hr)) - { - memset(&formatSupport, 0, sizeof(formatSupport)); - } - - if (metadata.mipLevels > 1 && !(formatSupport.Support1 & D3D12_FORMAT_SUPPORT1_MIP)) - { - return false; - } - - switch (metadata.dimension) - { - case TEX_DIMENSION_TEXTURE1D: - if (!(formatSupport.Support1 & D3D12_FORMAT_SUPPORT1_TEXTURE1D)) - return false; - - if ((arraySize > D3D12_REQ_TEXTURE1D_ARRAY_AXIS_DIMENSION) - || (iWidth > D3D12_REQ_TEXTURE1D_U_DIMENSION)) - return false; - - { - const uint64_t numberOfResources = uint64_t(arraySize) * uint64_t(metadata.mipLevels); - if (numberOfResources > D3D12_REQ_SUBRESOURCES) - return false; - } - break; - - case TEX_DIMENSION_TEXTURE2D: - if (metadata.IsCubemap()) - { - if (!(formatSupport.Support1 & D3D12_FORMAT_SUPPORT1_TEXTURECUBE)) - return false; - - if ((arraySize > D3D12_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION) - || (iWidth > D3D12_REQ_TEXTURECUBE_DIMENSION) - || (iHeight > D3D12_REQ_TEXTURECUBE_DIMENSION)) - return false; - } - else // Not a cube map - { - if (!(formatSupport.Support1 & D3D12_FORMAT_SUPPORT1_TEXTURE2D)) - return false; - - if ((arraySize > D3D12_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION) - || (iWidth > D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION) - || (iHeight > D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION)) - return false; - } - - { - const uint64_t numberOfResources = uint64_t(arraySize) * uint64_t(metadata.mipLevels); - if (numberOfResources > D3D12_REQ_SUBRESOURCES) - return false; - } - break; - - case TEX_DIMENSION_TEXTURE3D: - if (!(formatSupport.Support1 & D3D12_FORMAT_SUPPORT1_TEXTURE3D)) - return false; - - if ((arraySize > 1) - || (iWidth > D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION) - || (iHeight > D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION) - || (iDepth > D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION)) - return false; - - { - if (metadata.mipLevels > D3D12_REQ_SUBRESOURCES) - return false; - } - break; - - default: - // Not a supported dimension - return false; - } - - return true; -} - - -//------------------------------------------------------------------------------------- -// Create a texture resource -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::CreateTexture( - ID3D12Device* pDevice, - const TexMetadata& metadata, - ID3D12Resource** ppResource) noexcept -{ - return CreateTextureEx( - pDevice, metadata, - D3D12_RESOURCE_FLAG_NONE, false, - ppResource); -} - -_Use_decl_annotations_ -HRESULT DirectX::CreateTextureEx( - ID3D12Device* pDevice, - const TexMetadata& metadata, - D3D12_RESOURCE_FLAGS resFlags, - bool forceSRGB, - ID3D12Resource** ppResource) noexcept -{ - if (!pDevice || !ppResource) - return E_INVALIDARG; - - *ppResource = nullptr; - - if (!metadata.mipLevels || !metadata.arraySize) - return E_INVALIDARG; - - if ((metadata.width > UINT32_MAX) || (metadata.height > UINT32_MAX) - || (metadata.mipLevels > UINT16_MAX) || (metadata.arraySize > UINT16_MAX)) - return E_INVALIDARG; - - DXGI_FORMAT format = metadata.format; - if (forceSRGB) - { - format = MakeSRGB(format); - } - - D3D12_RESOURCE_DESC desc = {}; - desc.Width = static_cast(metadata.width); - desc.Height = static_cast(metadata.height); - desc.MipLevels = static_cast(metadata.mipLevels); - desc.DepthOrArraySize = (metadata.dimension == TEX_DIMENSION_TEXTURE3D) - ? static_cast(metadata.depth) - : static_cast(metadata.arraySize); - desc.Format = format; - desc.Flags = resFlags; - desc.SampleDesc.Count = 1; - desc.Dimension = static_cast(metadata.dimension); - - const CD3DX12_HEAP_PROPERTIES defaultHeapProperties(D3D12_HEAP_TYPE_DEFAULT); - - HRESULT hr = pDevice->CreateCommittedResource( - &defaultHeapProperties, - D3D12_HEAP_FLAG_NONE, - &desc, - D3D12_RESOURCE_STATE_COPY_DEST, - nullptr, - IID_GRAPHICS_PPV_ARGS(ppResource)); - - return hr; -} - - -//------------------------------------------------------------------------------------- -// Prepares a texture resource for upload -//------------------------------------------------------------------------------------- - -_Use_decl_annotations_ -HRESULT DirectX::PrepareUpload( - ID3D12Device* pDevice, - const Image* srcImages, - size_t nimages, - const TexMetadata& metadata, - std::vector& subresources) -{ - if (!pDevice || !srcImages || !nimages || !metadata.mipLevels || !metadata.arraySize) - return E_INVALIDARG; - - const UINT numberOfPlanes = D3D12GetFormatPlaneCount(pDevice, metadata.format); - if (!numberOfPlanes) - return E_INVALIDARG; - - if ((numberOfPlanes > 1) && IsDepthStencil(metadata.format)) - { - // DirectX 12 uses planes for stencil, DirectX 11 does not - return HRESULT_E_NOT_SUPPORTED; - } - - size_t numberOfResources = (metadata.dimension == TEX_DIMENSION_TEXTURE3D) - ? 1u : metadata.arraySize; - numberOfResources *= metadata.mipLevels; - numberOfResources *= numberOfPlanes; - - if (numberOfResources > D3D12_REQ_SUBRESOURCES) - return E_INVALIDARG; - - subresources.clear(); - subresources.reserve(numberOfResources); - - // Fill out subresource array - if (metadata.IsVolumemap()) - { - //--- Volume case ------------------------------------------------------------- - if (!metadata.depth) - return E_INVALIDARG; - - if (metadata.depth > UINT16_MAX) - return E_INVALIDARG; - - if (metadata.arraySize > 1) - // Direct3D 12 doesn't support arrays of 3D textures - return HRESULT_E_NOT_SUPPORTED; - - for (size_t plane = 0; plane < numberOfPlanes; ++plane) - { - size_t depth = metadata.depth; - - for (size_t level = 0; level < metadata.mipLevels; ++level) - { - const size_t index = metadata.ComputeIndex(level, 0, 0); - if (index >= nimages) - return E_FAIL; - - const Image& img = srcImages[index]; - - if (img.format != metadata.format) - return E_FAIL; - - if (!img.pixels) - return E_POINTER; - - // Verify pixels in image 1 .. (depth-1) are exactly image->slicePitch apart - // For 3D textures, this relies on all slices of the same miplevel being continous in memory - // (this is how ScratchImage lays them out), which is why we just give the 0th slice to Direct3D 11 - const uint8_t* pSlice = img.pixels + img.slicePitch; - for (size_t slice = 1; slice < depth; ++slice) - { - const size_t tindex = metadata.ComputeIndex(level, 0, slice); - if (tindex >= nimages) - return E_FAIL; - - const Image& timg = srcImages[tindex]; - - if (!timg.pixels) - return E_POINTER; - - if (timg.pixels != pSlice - || timg.format != metadata.format - || timg.rowPitch != img.rowPitch - || timg.slicePitch != img.slicePitch) - return E_FAIL; - - pSlice = timg.pixels + img.slicePitch; - } - - D3D12_SUBRESOURCE_DATA res = - { - img.pixels, - static_cast(img.rowPitch), - static_cast(img.slicePitch) - }; - - AdjustPlaneResource(metadata.format, img.height, plane, res); - - subresources.emplace_back(res); - - if (depth > 1) - depth >>= 1; - } - } - } - else - { - //--- 1D or 2D texture case --------------------------------------------------- - for (size_t plane = 0; plane < numberOfPlanes; ++plane) - { - for (size_t item = 0; item < metadata.arraySize; ++item) - { - for (size_t level = 0; level < metadata.mipLevels; ++level) - { - const size_t index = metadata.ComputeIndex(level, item, 0); - if (index >= nimages) - return E_FAIL; - - const Image& img = srcImages[index]; - - if (img.format != metadata.format) - return E_FAIL; - - if (!img.pixels) - return E_POINTER; - - D3D12_SUBRESOURCE_DATA res = - { - img.pixels, - static_cast(img.rowPitch), - static_cast(img.slicePitch) - }; - - AdjustPlaneResource(metadata.format, img.height, plane, res); - - subresources.emplace_back(res); - } - } - } - } - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -// Save a texture resource -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::CaptureTexture( - ID3D12CommandQueue* pCommandQueue, - ID3D12Resource* pSource, - bool isCubeMap, - ScratchImage& result, - D3D12_RESOURCE_STATES beforeState, - D3D12_RESOURCE_STATES afterState) noexcept -{ - if (!pCommandQueue || !pSource) - return E_INVALIDARG; - - ComPtr device; - pCommandQueue->GetDevice(IID_GRAPHICS_PPV_ARGS(device.GetAddressOf())); - - auto const desc = pSource->GetDesc(); - - ComPtr pStaging; - std::unique_ptr layoutBuff; - UINT numberOfPlanes, numberOfResources; - HRESULT hr = Capture(device.Get(), - pCommandQueue, - pSource, - desc, - pStaging, - layoutBuff, - numberOfPlanes, - numberOfResources, - beforeState, - afterState); - if (FAILED(hr)) - return hr; - - if (!layoutBuff || !numberOfPlanes || !numberOfResources) - return E_UNEXPECTED; - - auto pLayout = reinterpret_cast(layoutBuff.get()); - auto pRowSizesInBytes = reinterpret_cast(pLayout + numberOfResources); - auto pNumRows = reinterpret_cast(pRowSizesInBytes + numberOfResources); - - switch (desc.Dimension) - { - case D3D12_RESOURCE_DIMENSION_TEXTURE1D: - { - TexMetadata mdata; - mdata.width = static_cast(desc.Width); - mdata.height = mdata.depth = 1; - mdata.arraySize = desc.DepthOrArraySize; - mdata.mipLevels = desc.MipLevels; - mdata.miscFlags = 0; - mdata.miscFlags2 = 0; - mdata.format = desc.Format; - mdata.dimension = TEX_DIMENSION_TEXTURE1D; - - hr = result.Initialize(mdata); - if (FAILED(hr)) - return hr; - } - break; - - case D3D12_RESOURCE_DIMENSION_TEXTURE2D: - { - TexMetadata mdata; - mdata.width = static_cast(desc.Width); - mdata.height = desc.Height; - mdata.depth = 1; - mdata.arraySize = desc.DepthOrArraySize; - mdata.mipLevels = desc.MipLevels; - mdata.miscFlags = isCubeMap ? TEX_MISC_TEXTURECUBE : 0u; - mdata.miscFlags2 = 0; - mdata.format = desc.Format; - mdata.dimension = TEX_DIMENSION_TEXTURE2D; - - hr = result.Initialize(mdata); - if (FAILED(hr)) - return hr; - } - break; - - case D3D12_RESOURCE_DIMENSION_TEXTURE3D: - { - TexMetadata mdata; - mdata.width = static_cast(desc.Width); - mdata.height = desc.Height; - mdata.depth = desc.DepthOrArraySize; - mdata.arraySize = 1; - mdata.mipLevels = desc.MipLevels; - mdata.miscFlags = 0; - mdata.miscFlags2 = 0; - mdata.format = desc.Format; - mdata.dimension = TEX_DIMENSION_TEXTURE3D; - - hr = result.Initialize(mdata); - if (FAILED(hr)) - return hr; - } - break; - - default: - return E_FAIL; - } - - BYTE* pData; - hr = pStaging->Map(0, nullptr, reinterpret_cast(&pData)); - if (FAILED(hr)) - { - result.Release(); - return E_FAIL; - } - - const UINT arraySize = (desc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D) - ? 1u - : desc.DepthOrArraySize; - - for (UINT plane = 0; plane < numberOfPlanes; ++plane) - { - for (UINT item = 0; item < arraySize; ++item) - { - for (UINT level = 0; level < desc.MipLevels; ++level) - { - const UINT dindex = D3D12CalcSubresource(level, item, plane, desc.MipLevels, arraySize); - assert(dindex < numberOfResources); - - const Image* img = result.GetImage(level, item, 0); - if (!img) - { - pStaging->Unmap(0, nullptr); - result.Release(); - return E_FAIL; - } - - if (!img->pixels) - { - pStaging->Unmap(0, nullptr); - result.Release(); - return E_POINTER; - } - - D3D12_MEMCPY_DEST destData = { img->pixels, img->rowPitch, img->slicePitch }; - - AdjustPlaneResource(img->format, img->height, plane, destData); - - D3D12_SUBRESOURCE_DATA srcData = - { - pData + pLayout[dindex].Offset, - static_cast(pLayout[dindex].Footprint.RowPitch), - static_cast(pLayout[dindex].Footprint.RowPitch) * static_cast(pNumRows[dindex]) - }; - - if (pRowSizesInBytes[dindex] > SIZE_T(-1)) - { - pStaging->Unmap(0, nullptr); - result.Release(); - return E_FAIL; - } - - MemcpySubresource(&destData, &srcData, - static_cast(pRowSizesInBytes[dindex]), - pNumRows[dindex], - pLayout[dindex].Footprint.Depth); - } - } - } - - pStaging->Unmap(0, nullptr); - - return S_OK; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexDDS.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexDDS.cpp deleted file mode 100644 index ca7fe7e..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexDDS.cpp +++ /dev/null @@ -1,2448 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXTexDDS.cpp -// -// DirectX Texture Library - Microsoft DirectDraw Surface (DDS) file format reader/writer -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//------------------------------------------------------------------------------------- - -#include "DirectXTexP.h" - -#include "DDS.h" - -using namespace DirectX; -using namespace DirectX::Internal; - -static_assert(static_cast(TEX_DIMENSION_TEXTURE1D) == static_cast(DDS_DIMENSION_TEXTURE1D), "header enum mismatch"); -static_assert(static_cast(TEX_DIMENSION_TEXTURE2D) == static_cast(DDS_DIMENSION_TEXTURE2D), "header enum mismatch"); -static_assert(static_cast(TEX_DIMENSION_TEXTURE3D) == static_cast(DDS_DIMENSION_TEXTURE3D), "header enum mismatch"); - -namespace -{ - constexpr size_t MAX_HEADER_SIZE = sizeof(uint32_t) + sizeof(DDS_HEADER) + sizeof(DDS_HEADER_DXT10); - - //------------------------------------------------------------------------------------- - // Legacy format mapping table (used for DDS files without 'DX10' extended header) - //------------------------------------------------------------------------------------- - enum CONVERSION_FLAGS : uint32_t - { - CONV_FLAGS_NONE = 0x0, - CONV_FLAGS_EXPAND = 0x1, // Conversion requires expanded pixel size - CONV_FLAGS_NOALPHA = 0x2, // Conversion requires setting alpha to known value - CONV_FLAGS_SWIZZLE = 0x4, // BGR/RGB order swizzling required - CONV_FLAGS_PAL8 = 0x8, // Has an 8-bit palette - CONV_FLAGS_888 = 0x10, // Source is an 8:8:8 (24bpp) format - CONV_FLAGS_565 = 0x20, // Source is a 5:6:5 (16bpp) format - CONV_FLAGS_5551 = 0x40, // Source is a 5:5:5:1 (16bpp) format - CONV_FLAGS_4444 = 0x80, // Source is a 4:4:4:4 (16bpp) format - CONV_FLAGS_44 = 0x100, // Source is a 4:4 (8bpp) format - CONV_FLAGS_332 = 0x200, // Source is a 3:3:2 (8bpp) format - CONV_FLAGS_8332 = 0x400, // Source is a 8:3:3:2 (16bpp) format - CONV_FLAGS_A8P8 = 0x800, // Has an 8-bit palette with an alpha channel - CONV_FLAGS_DX10 = 0x10000, // Has the 'DX10' extension header - CONV_FLAGS_PMALPHA = 0x20000, // Contains premultiplied alpha data - CONV_FLAGS_L8 = 0x40000, // Source is a 8 luminance format - CONV_FLAGS_L16 = 0x80000, // Source is a 16 luminance format - CONV_FLAGS_A8L8 = 0x100000, // Source is a 8:8 luminance format - }; - - struct LegacyDDS - { - DXGI_FORMAT format; - uint32_t convFlags; - DDS_PIXELFORMAT ddpf; - }; - - const LegacyDDS g_LegacyDDSMap[] = - { - { DXGI_FORMAT_BC1_UNORM, CONV_FLAGS_NONE, DDSPF_DXT1 }, // D3DFMT_DXT1 - { DXGI_FORMAT_BC2_UNORM, CONV_FLAGS_NONE, DDSPF_DXT3 }, // D3DFMT_DXT3 - { DXGI_FORMAT_BC3_UNORM, CONV_FLAGS_NONE, DDSPF_DXT5 }, // D3DFMT_DXT5 - - { DXGI_FORMAT_BC2_UNORM, CONV_FLAGS_PMALPHA, DDSPF_DXT2 }, // D3DFMT_DXT2 - { DXGI_FORMAT_BC3_UNORM, CONV_FLAGS_PMALPHA, DDSPF_DXT4 }, // D3DFMT_DXT4 - - { DXGI_FORMAT_BC4_UNORM, CONV_FLAGS_NONE, DDSPF_BC4_UNORM }, - { DXGI_FORMAT_BC4_SNORM, CONV_FLAGS_NONE, DDSPF_BC4_SNORM }, - { DXGI_FORMAT_BC5_UNORM, CONV_FLAGS_NONE, DDSPF_BC5_UNORM }, - { DXGI_FORMAT_BC5_SNORM, CONV_FLAGS_NONE, DDSPF_BC5_SNORM }, - - { DXGI_FORMAT_BC4_UNORM, CONV_FLAGS_NONE, { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('A', 'T', 'I', '1'), 0, 0, 0, 0, 0 } }, - { DXGI_FORMAT_BC5_UNORM, CONV_FLAGS_NONE, { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('A', 'T', 'I', '2'), 0, 0, 0, 0, 0 } }, - - { DXGI_FORMAT_BC6H_UF16, CONV_FLAGS_NONE, { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B', 'C', '6', 'H'), 0, 0, 0, 0, 0 } }, - { DXGI_FORMAT_BC7_UNORM, CONV_FLAGS_NONE, { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B', 'C', '7', 'L'), 0, 0, 0, 0, 0 } }, - { DXGI_FORMAT_BC7_UNORM, CONV_FLAGS_NONE, { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B', 'C', '7', '\0'), 0, 0, 0, 0, 0 } }, - - { DXGI_FORMAT_R8G8_B8G8_UNORM, CONV_FLAGS_NONE, DDSPF_R8G8_B8G8 }, // D3DFMT_R8G8_B8G8 - { DXGI_FORMAT_G8R8_G8B8_UNORM, CONV_FLAGS_NONE, DDSPF_G8R8_G8B8 }, // D3DFMT_G8R8_G8B8 - - { DXGI_FORMAT_B8G8R8A8_UNORM, CONV_FLAGS_NONE, DDSPF_A8R8G8B8 }, // D3DFMT_A8R8G8B8 (uses DXGI 1.1 format) - { DXGI_FORMAT_B8G8R8X8_UNORM, CONV_FLAGS_NONE, DDSPF_X8R8G8B8 }, // D3DFMT_X8R8G8B8 (uses DXGI 1.1 format) - { DXGI_FORMAT_R8G8B8A8_UNORM, CONV_FLAGS_NONE, DDSPF_A8B8G8R8 }, // D3DFMT_A8B8G8R8 - { DXGI_FORMAT_R8G8B8A8_UNORM, CONV_FLAGS_NOALPHA, DDSPF_X8B8G8R8 }, // D3DFMT_X8B8G8R8 - { DXGI_FORMAT_R16G16_UNORM, CONV_FLAGS_NONE, DDSPF_G16R16 }, // D3DFMT_G16R16 - - { DXGI_FORMAT_R10G10B10A2_UNORM, CONV_FLAGS_SWIZZLE, DDSPF_A2R10G10B10 }, // D3DFMT_A2R10G10B10 (D3DX reversal issue) - { DXGI_FORMAT_R10G10B10A2_UNORM, CONV_FLAGS_NONE, DDSPF_A2B10G10R10 }, // D3DFMT_A2B10G10R10 (D3DX reversal issue) - - { DXGI_FORMAT_R8G8B8A8_UNORM, CONV_FLAGS_EXPAND - | CONV_FLAGS_NOALPHA - | CONV_FLAGS_888, DDSPF_R8G8B8 }, // D3DFMT_R8G8B8 - - { DXGI_FORMAT_B5G6R5_UNORM, CONV_FLAGS_565, DDSPF_R5G6B5 }, // D3DFMT_R5G6B5 - { DXGI_FORMAT_B5G5R5A1_UNORM, CONV_FLAGS_5551, DDSPF_A1R5G5B5 }, // D3DFMT_A1R5G5B5 - { DXGI_FORMAT_B5G5R5A1_UNORM, CONV_FLAGS_5551 - | CONV_FLAGS_NOALPHA, DDSPF_X1R5G5B5 }, // D3DFMT_X1R5G5B5 - - { DXGI_FORMAT_R8G8B8A8_UNORM, CONV_FLAGS_EXPAND - | CONV_FLAGS_8332, DDSPF_A8R3G3B2 }, // D3DFMT_A8R3G3B2 - { DXGI_FORMAT_B5G6R5_UNORM, CONV_FLAGS_EXPAND - | CONV_FLAGS_332, DDSPF_R3G3B2 }, // D3DFMT_R3G3B2 - - { DXGI_FORMAT_R8_UNORM, CONV_FLAGS_NONE, DDSPF_L8 }, // D3DFMT_L8 - { DXGI_FORMAT_R16_UNORM, CONV_FLAGS_NONE, DDSPF_L16 }, // D3DFMT_L16 - { DXGI_FORMAT_R8G8_UNORM, CONV_FLAGS_NONE, DDSPF_A8L8 }, // D3DFMT_A8L8 - { DXGI_FORMAT_R8G8_UNORM, CONV_FLAGS_NONE, DDSPF_A8L8_ALT }, // D3DFMT_A8L8 (alternative bitcount) - - // NVTT v1 wrote these with RGB instead of LUMINANCE - { DXGI_FORMAT_R8_UNORM, CONV_FLAGS_NONE, DDSPF_L8_NVTT1 }, // D3DFMT_L8 - { DXGI_FORMAT_R16_UNORM, CONV_FLAGS_NONE, DDSPF_L16_NVTT1 }, // D3DFMT_L16 - { DXGI_FORMAT_R8G8_UNORM, CONV_FLAGS_NONE, DDSPF_A8L8_NVTT1 }, // D3DFMT_A8L8 - - { DXGI_FORMAT_A8_UNORM, CONV_FLAGS_NONE, DDSPF_A8 }, // D3DFMT_A8 - - { DXGI_FORMAT_R16G16B16A16_UNORM, CONV_FLAGS_NONE, { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, 36, 0, 0, 0, 0, 0 } }, // D3DFMT_A16B16G16R16 - { DXGI_FORMAT_R16G16B16A16_SNORM, CONV_FLAGS_NONE, { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, 110, 0, 0, 0, 0, 0 } }, // D3DFMT_Q16W16V16U16 - { DXGI_FORMAT_R16_FLOAT, CONV_FLAGS_NONE, { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, 111, 0, 0, 0, 0, 0 } }, // D3DFMT_R16F - { DXGI_FORMAT_R16G16_FLOAT, CONV_FLAGS_NONE, { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, 112, 0, 0, 0, 0, 0 } }, // D3DFMT_G16R16F - { DXGI_FORMAT_R16G16B16A16_FLOAT, CONV_FLAGS_NONE, { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, 113, 0, 0, 0, 0, 0 } }, // D3DFMT_A16B16G16R16F - { DXGI_FORMAT_R32_FLOAT, CONV_FLAGS_NONE, { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, 114, 0, 0, 0, 0, 0 } }, // D3DFMT_R32F - { DXGI_FORMAT_R32G32_FLOAT, CONV_FLAGS_NONE, { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, 115, 0, 0, 0, 0, 0 } }, // D3DFMT_G32R32F - { DXGI_FORMAT_R32G32B32A32_FLOAT, CONV_FLAGS_NONE, { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, 116, 0, 0, 0, 0, 0 } }, // D3DFMT_A32B32G32R32F - - { DXGI_FORMAT_R32_FLOAT, CONV_FLAGS_NONE, { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0xffffffff, 0, 0, 0 } }, // D3DFMT_R32F (D3DX uses FourCC 114 instead) - - { DXGI_FORMAT_R8G8B8A8_UNORM, CONV_FLAGS_EXPAND - | CONV_FLAGS_PAL8 - | CONV_FLAGS_A8P8, { sizeof(DDS_PIXELFORMAT), DDS_PAL8A, 0, 16, 0, 0, 0, 0 } }, // D3DFMT_A8P8 - { DXGI_FORMAT_R8G8B8A8_UNORM, CONV_FLAGS_EXPAND - | CONV_FLAGS_PAL8, { sizeof(DDS_PIXELFORMAT), DDS_PAL8, 0, 8, 0, 0, 0, 0 } }, // D3DFMT_P8 - - { DXGI_FORMAT_B4G4R4A4_UNORM, CONV_FLAGS_4444, DDSPF_A4R4G4B4 }, // D3DFMT_A4R4G4B4 (uses DXGI 1.2 format) - { DXGI_FORMAT_B4G4R4A4_UNORM, CONV_FLAGS_NOALPHA - | CONV_FLAGS_4444, DDSPF_X4R4G4B4 }, // D3DFMT_X4R4G4B4 (uses DXGI 1.2 format) - { DXGI_FORMAT_B4G4R4A4_UNORM, CONV_FLAGS_EXPAND - | CONV_FLAGS_44, DDSPF_A4L4 }, // D3DFMT_A4L4 (uses DXGI 1.2 format) - - { DXGI_FORMAT_YUY2, CONV_FLAGS_NONE, DDSPF_YUY2 }, // D3DFMT_YUY2 (uses DXGI 1.2 format) - { DXGI_FORMAT_YUY2, CONV_FLAGS_SWIZZLE, DDSPF_UYVY }, // D3DFMT_UYVY (uses DXGI 1.2 format) - - { DXGI_FORMAT_R8G8_SNORM, CONV_FLAGS_NONE, DDSPF_V8U8 }, // D3DFMT_V8U8 - { DXGI_FORMAT_R8G8B8A8_SNORM, CONV_FLAGS_NONE, DDSPF_Q8W8V8U8 }, // D3DFMT_Q8W8V8U8 - { DXGI_FORMAT_R16G16_SNORM, CONV_FLAGS_NONE, DDSPF_V16U16 }, // D3DFMT_V16U16 - }; - - // Note that many common DDS reader/writers (including D3DX) swap the - // the RED/BLUE masks for 10:10:10:2 formats. We assumme - // below that the 'backwards' header mask is being used since it is most - // likely written by D3DX. The more robust solution is to use the 'DX10' - // header extension and specify the DXGI_FORMAT_R10G10B10A2_UNORM format directly - - // We do not support the following legacy Direct3D 9 formats: - // BumpDuDv D3DFMT_A2W10V10U10 - // BumpLuminance D3DFMT_L6V5U5, D3DFMT_X8L8V8U8 - // FourCC 117 D3DFMT_CxV8U8 - // ZBuffer D3DFMT_D16_LOCKABLE - // FourCC 82 D3DFMT_D32F_LOCKABLE - - // We do not support the following known FourCC codes: - // FourCC CTX1 (Xbox 360 only) - // FourCC EAR, EARG, ET2, ET2A (Ericsson Texture Compression) - - DXGI_FORMAT GetDXGIFormat(const DDS_HEADER& hdr, const DDS_PIXELFORMAT& ddpf, - DDS_FLAGS flags, - _Inout_ uint32_t& convFlags) noexcept - { - uint32_t ddpfFlags = ddpf.flags; - if (hdr.reserved1[9] == MAKEFOURCC('N', 'V', 'T', 'T')) - { - // Clear out non-standard nVidia DDS flags - ddpfFlags &= ~0xC0000000 /* DDPF_SRGB | DDPF_NORMAL */; - } - - constexpr size_t MAP_SIZE = sizeof(g_LegacyDDSMap) / sizeof(LegacyDDS); - size_t index = 0; - for (index = 0; index < MAP_SIZE; ++index) - { - const LegacyDDS* entry = &g_LegacyDDSMap[index]; - - if ((ddpfFlags & DDS_FOURCC) && (entry->ddpf.flags & DDS_FOURCC)) - { - // In case of FourCC codes, ignore any other bits in ddpf.flags - if (ddpf.fourCC == entry->ddpf.fourCC) - break; - } - else if (ddpfFlags == entry->ddpf.flags) - { - if (entry->ddpf.flags & DDS_PAL8) - { - if (ddpf.RGBBitCount == entry->ddpf.RGBBitCount) - break; - } - else if (entry->ddpf.flags & DDS_ALPHA) - { - if (ddpf.RGBBitCount == entry->ddpf.RGBBitCount - && ddpf.ABitMask == entry->ddpf.ABitMask) - break; - } - else if (entry->ddpf.flags & DDS_LUMINANCE) - { - if (entry->ddpf.flags & DDS_ALPHAPIXELS) - { - // LUMINANCEA - if (ddpf.RGBBitCount == entry->ddpf.RGBBitCount - && ddpf.RBitMask == entry->ddpf.RBitMask - && ddpf.ABitMask == entry->ddpf.ABitMask) - break; - } - else - { - // LUMINANCE - if (ddpf.RGBBitCount == entry->ddpf.RGBBitCount - && ddpf.RBitMask == entry->ddpf.RBitMask) - break; - } - } - else if (entry->ddpf.flags & DDS_BUMPDUDV) - { - if (ddpf.RGBBitCount == entry->ddpf.RGBBitCount - && ddpf.RBitMask == entry->ddpf.RBitMask - && ddpf.GBitMask == entry->ddpf.GBitMask - && ddpf.BBitMask == entry->ddpf.BBitMask - && ddpf.ABitMask == entry->ddpf.ABitMask) - break; - } - else if (ddpf.RGBBitCount == entry->ddpf.RGBBitCount) - { - if (entry->ddpf.flags & DDS_ALPHAPIXELS) - { - // RGBA - if (ddpf.RBitMask == entry->ddpf.RBitMask - && ddpf.GBitMask == entry->ddpf.GBitMask - && ddpf.BBitMask == entry->ddpf.BBitMask - && ddpf.ABitMask == entry->ddpf.ABitMask) - break; - } - else - { - // RGB - if (ddpf.RBitMask == entry->ddpf.RBitMask - && ddpf.GBitMask == entry->ddpf.GBitMask - && ddpf.BBitMask == entry->ddpf.BBitMask) - break; - } - } - } - } - - if (index >= MAP_SIZE) - return DXGI_FORMAT_UNKNOWN; - - uint32_t cflags = g_LegacyDDSMap[index].convFlags; - DXGI_FORMAT format = g_LegacyDDSMap[index].format; - - if ((cflags & CONV_FLAGS_EXPAND) && (flags & DDS_FLAGS_NO_LEGACY_EXPANSION)) - return DXGI_FORMAT_UNKNOWN; - - if ((format == DXGI_FORMAT_R10G10B10A2_UNORM) && (flags & DDS_FLAGS_NO_R10B10G10A2_FIXUP)) - { - cflags ^= CONV_FLAGS_SWIZZLE; - } - - if ((hdr.reserved1[9] == MAKEFOURCC('N', 'V', 'T', 'T')) - && (ddpf.flags & 0x40000000 /* DDPF_SRGB */)) - { - format = MakeSRGB(format); - } - - convFlags = cflags; - - return format; - } - - - //------------------------------------------------------------------------------------- - // Decodes DDS header including optional DX10 extended header - //------------------------------------------------------------------------------------- - HRESULT DecodeDDSHeader( - _In_reads_bytes_(size) const void* pSource, - size_t size, - DDS_FLAGS flags, - _Out_ TexMetadata& metadata, - _Inout_ uint32_t& convFlags) noexcept - { - if (!pSource) - return E_INVALIDARG; - - memset(&metadata, 0, sizeof(TexMetadata)); - - if (size < (sizeof(DDS_HEADER) + sizeof(uint32_t))) - { - return HRESULT_E_INVALID_DATA; - } - - // DDS files always start with the same magic number ("DDS ") - auto const dwMagicNumber = *static_cast(pSource); - if (dwMagicNumber != DDS_MAGIC) - { - return E_FAIL; - } - - auto pHeader = reinterpret_cast(static_cast(pSource) + sizeof(uint32_t)); - - // Verify header to validate DDS file - if (pHeader->size != sizeof(DDS_HEADER) - || pHeader->ddspf.size != sizeof(DDS_PIXELFORMAT)) - { - return E_FAIL; - } - - metadata.mipLevels = pHeader->mipMapCount; - if (metadata.mipLevels == 0) - metadata.mipLevels = 1; - - // Check for DX10 extension - if ((pHeader->ddspf.flags & DDS_FOURCC) - && (MAKEFOURCC('D', 'X', '1', '0') == pHeader->ddspf.fourCC)) - { - // Buffer must be big enough for both headers and magic value - if (size < (sizeof(DDS_HEADER) + sizeof(uint32_t) + sizeof(DDS_HEADER_DXT10))) - { - return E_FAIL; - } - - auto d3d10ext = reinterpret_cast(static_cast(pSource) + sizeof(uint32_t) + sizeof(DDS_HEADER)); - convFlags |= CONV_FLAGS_DX10; - - metadata.arraySize = d3d10ext->arraySize; - if (metadata.arraySize == 0) - { - return HRESULT_E_INVALID_DATA; - } - - metadata.format = d3d10ext->dxgiFormat; - if (!IsValid(metadata.format) || IsPalettized(metadata.format)) - { - return HRESULT_E_NOT_SUPPORTED; - } - - static_assert(static_cast(TEX_MISC_TEXTURECUBE) == static_cast(DDS_RESOURCE_MISC_TEXTURECUBE), "DDS header mismatch"); - - metadata.miscFlags = d3d10ext->miscFlag & ~static_cast(TEX_MISC_TEXTURECUBE); - - switch (d3d10ext->resourceDimension) - { - case DDS_DIMENSION_TEXTURE1D: - - // D3DX writes 1D textures with a fixed Height of 1 - if ((pHeader->flags & DDS_HEIGHT) && pHeader->height != 1) - { - return HRESULT_E_INVALID_DATA; - } - - metadata.width = pHeader->width; - metadata.height = 1; - metadata.depth = 1; - metadata.dimension = TEX_DIMENSION_TEXTURE1D; - break; - - case DDS_DIMENSION_TEXTURE2D: - if (d3d10ext->miscFlag & DDS_RESOURCE_MISC_TEXTURECUBE) - { - metadata.miscFlags |= TEX_MISC_TEXTURECUBE; - metadata.arraySize *= 6; - } - - metadata.width = pHeader->width; - metadata.height = pHeader->height; - metadata.depth = 1; - metadata.dimension = TEX_DIMENSION_TEXTURE2D; - break; - - case DDS_DIMENSION_TEXTURE3D: - if (!(pHeader->flags & DDS_HEADER_FLAGS_VOLUME)) - { - return HRESULT_E_INVALID_DATA; - } - - if (metadata.arraySize > 1) - return HRESULT_E_NOT_SUPPORTED; - - metadata.width = pHeader->width; - metadata.height = pHeader->height; - metadata.depth = pHeader->depth; - metadata.dimension = TEX_DIMENSION_TEXTURE3D; - break; - - default: - return HRESULT_E_INVALID_DATA; - } - - static_assert(static_cast(TEX_MISC2_ALPHA_MODE_MASK) == static_cast(DDS_MISC_FLAGS2_ALPHA_MODE_MASK), "DDS header mismatch"); - - static_assert(static_cast(TEX_ALPHA_MODE_UNKNOWN) == static_cast(DDS_ALPHA_MODE_UNKNOWN), "DDS header mismatch"); - static_assert(static_cast(TEX_ALPHA_MODE_STRAIGHT) == static_cast(DDS_ALPHA_MODE_STRAIGHT), "DDS header mismatch"); - static_assert(static_cast(TEX_ALPHA_MODE_PREMULTIPLIED) == static_cast(DDS_ALPHA_MODE_PREMULTIPLIED), "DDS header mismatch"); - static_assert(static_cast(TEX_ALPHA_MODE_OPAQUE) == static_cast(DDS_ALPHA_MODE_OPAQUE), "DDS header mismatch"); - static_assert(static_cast(TEX_ALPHA_MODE_CUSTOM) == static_cast(DDS_ALPHA_MODE_CUSTOM), "DDS header mismatch"); - - metadata.miscFlags2 = d3d10ext->miscFlags2; - } - else - { - metadata.arraySize = 1; - - if (pHeader->flags & DDS_HEADER_FLAGS_VOLUME) - { - metadata.width = pHeader->width; - metadata.height = pHeader->height; - metadata.depth = pHeader->depth; - metadata.dimension = TEX_DIMENSION_TEXTURE3D; - } - else - { - if (pHeader->caps2 & DDS_CUBEMAP) - { - // We require all six faces to be defined - if ((pHeader->caps2 & DDS_CUBEMAP_ALLFACES) != DDS_CUBEMAP_ALLFACES) - return HRESULT_E_NOT_SUPPORTED; - - metadata.arraySize = 6; - metadata.miscFlags |= TEX_MISC_TEXTURECUBE; - } - - metadata.width = pHeader->width; - metadata.height = pHeader->height; - metadata.depth = 1; - metadata.dimension = TEX_DIMENSION_TEXTURE2D; - - // Note there's no way for a legacy Direct3D 9 DDS to express a '1D' texture - } - - metadata.format = GetDXGIFormat(*pHeader, pHeader->ddspf, flags, convFlags); - - if (metadata.format == DXGI_FORMAT_UNKNOWN) - return HRESULT_E_NOT_SUPPORTED; - - // Special flag for handling LUMINANCE legacy formats - if (flags & DDS_FLAGS_EXPAND_LUMINANCE) - { - switch (metadata.format) - { - case DXGI_FORMAT_R8_UNORM: - metadata.format = DXGI_FORMAT_R8G8B8A8_UNORM; - convFlags |= CONV_FLAGS_L8 | CONV_FLAGS_EXPAND; - break; - - case DXGI_FORMAT_R8G8_UNORM: - metadata.format = DXGI_FORMAT_R8G8B8A8_UNORM; - convFlags |= CONV_FLAGS_A8L8 | CONV_FLAGS_EXPAND; - break; - - case DXGI_FORMAT_R16_UNORM: - metadata.format = DXGI_FORMAT_R16G16B16A16_UNORM; - convFlags |= CONV_FLAGS_L16 | CONV_FLAGS_EXPAND; - break; - - default: - break; - } - } - } - - // Special flag for handling BGR DXGI 1.1 formats - if (flags & DDS_FLAGS_FORCE_RGB) - { - switch (metadata.format) - { - case DXGI_FORMAT_B8G8R8A8_UNORM: - metadata.format = DXGI_FORMAT_R8G8B8A8_UNORM; - convFlags |= CONV_FLAGS_SWIZZLE; - break; - - case DXGI_FORMAT_B8G8R8X8_UNORM: - metadata.format = DXGI_FORMAT_R8G8B8A8_UNORM; - convFlags |= CONV_FLAGS_SWIZZLE | CONV_FLAGS_NOALPHA; - break; - - case DXGI_FORMAT_B8G8R8A8_TYPELESS: - metadata.format = DXGI_FORMAT_R8G8B8A8_TYPELESS; - convFlags |= CONV_FLAGS_SWIZZLE; - break; - - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - metadata.format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB; - convFlags |= CONV_FLAGS_SWIZZLE; - break; - - case DXGI_FORMAT_B8G8R8X8_TYPELESS: - metadata.format = DXGI_FORMAT_R8G8B8A8_TYPELESS; - convFlags |= CONV_FLAGS_SWIZZLE | CONV_FLAGS_NOALPHA; - break; - - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - metadata.format = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB; - convFlags |= CONV_FLAGS_SWIZZLE | CONV_FLAGS_NOALPHA; - break; - - default: - break; - } - } - - // Special flag for handling 16bpp formats - if (flags & DDS_FLAGS_NO_16BPP) - { - switch (metadata.format) - { - case DXGI_FORMAT_B5G6R5_UNORM: - case DXGI_FORMAT_B5G5R5A1_UNORM: - case DXGI_FORMAT_B4G4R4A4_UNORM: - if (metadata.format == DXGI_FORMAT_B5G6R5_UNORM) - convFlags |= CONV_FLAGS_NOALPHA; - metadata.format = DXGI_FORMAT_R8G8B8A8_UNORM; - convFlags |= CONV_FLAGS_EXPAND; - break; - - default: - break; - } - } - - // Implicit alpha mode - if (convFlags & CONV_FLAGS_NOALPHA) - { - metadata.SetAlphaMode(TEX_ALPHA_MODE_OPAQUE); - } - else if (convFlags & CONV_FLAGS_PMALPHA) - { - metadata.SetAlphaMode(TEX_ALPHA_MODE_PREMULTIPLIED); - } - - // Check for .dds files that exceed known hardware support - if (!(flags & DDS_FLAGS_ALLOW_LARGE_FILES)) - { - // 16k is the maximum required resource size supported by Direct3D - if (metadata.width > 16384u /* D3D12_REQ_TEXTURE1D_U_DIMENSION, D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION */ - || metadata.height > 16384u /* D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION */ - || metadata.mipLevels > 15u /* D3D12_REQ_MIP_LEVELS */) - { - return HRESULT_E_NOT_SUPPORTED; - } - - // 2048 is the maximum required depth/array size supported by Direct3D - if (metadata.arraySize > 2048u /* D3D12_REQ_TEXTURE1D_ARRAY_AXIS_DIMENSION, D3D12_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION */ - || metadata.depth > 2048u /* D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION */) - { - return HRESULT_E_NOT_SUPPORTED; - } - } - - return S_OK; - } -} - - -//------------------------------------------------------------------------------------- -// Encodes DDS file header (magic value, header, optional DX10 extended header) -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::EncodeDDSHeader( - const TexMetadata& metadata, - DDS_FLAGS flags, - void* pDestination, - size_t maxsize, - size_t& required) noexcept -{ - if (!IsValid(metadata.format)) - return E_INVALIDARG; - - if (IsPalettized(metadata.format)) - return HRESULT_E_NOT_SUPPORTED; - - if (metadata.arraySize > 1) - { - if ((metadata.arraySize != 6) || (metadata.dimension != TEX_DIMENSION_TEXTURE2D) || !(metadata.IsCubemap())) - { - // Texture1D arrays, Texture2D arrays, and Cubemap arrays must be stored using 'DX10' extended header - if (flags & DDS_FLAGS_FORCE_DX9_LEGACY) - return HRESULT_E_CANNOT_MAKE; - - flags |= DDS_FLAGS_FORCE_DX10_EXT; - } - } - - if (flags & DDS_FLAGS_FORCE_DX10_EXT_MISC2) - { - flags |= DDS_FLAGS_FORCE_DX10_EXT; - } - - DDS_PIXELFORMAT ddpf = {}; - if (!(flags & DDS_FLAGS_FORCE_DX10_EXT)) - { - switch (metadata.format) - { - case DXGI_FORMAT_R8G8B8A8_UNORM: memcpy(&ddpf, &DDSPF_A8B8G8R8, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_R16G16_UNORM: memcpy(&ddpf, &DDSPF_G16R16, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_R8G8_UNORM: memcpy(&ddpf, &DDSPF_A8L8, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_R16_UNORM: memcpy(&ddpf, &DDSPF_L16, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_R8_UNORM: memcpy(&ddpf, &DDSPF_L8, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_A8_UNORM: memcpy(&ddpf, &DDSPF_A8, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_R8G8_B8G8_UNORM: memcpy(&ddpf, &DDSPF_R8G8_B8G8, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_G8R8_G8B8_UNORM: memcpy(&ddpf, &DDSPF_G8R8_G8B8, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_BC1_UNORM: memcpy(&ddpf, &DDSPF_DXT1, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_BC2_UNORM: memcpy(&ddpf, metadata.IsPMAlpha() ? (&DDSPF_DXT2) : (&DDSPF_DXT3), sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_BC3_UNORM: memcpy(&ddpf, metadata.IsPMAlpha() ? (&DDSPF_DXT4) : (&DDSPF_DXT5), sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_BC4_SNORM: memcpy(&ddpf, &DDSPF_BC4_SNORM, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_BC5_SNORM: memcpy(&ddpf, &DDSPF_BC5_SNORM, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_B5G6R5_UNORM: memcpy(&ddpf, &DDSPF_R5G6B5, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_B5G5R5A1_UNORM: memcpy(&ddpf, &DDSPF_A1R5G5B5, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_R8G8_SNORM: memcpy(&ddpf, &DDSPF_V8U8, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_R8G8B8A8_SNORM: memcpy(&ddpf, &DDSPF_Q8W8V8U8, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_R16G16_SNORM: memcpy(&ddpf, &DDSPF_V16U16, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_B8G8R8A8_UNORM: memcpy(&ddpf, &DDSPF_A8R8G8B8, sizeof(DDS_PIXELFORMAT)); break; // DXGI 1.1 - case DXGI_FORMAT_B8G8R8X8_UNORM: memcpy(&ddpf, &DDSPF_X8R8G8B8, sizeof(DDS_PIXELFORMAT)); break; // DXGI 1.1 - case DXGI_FORMAT_B4G4R4A4_UNORM: memcpy(&ddpf, &DDSPF_A4R4G4B4, sizeof(DDS_PIXELFORMAT)); break; // DXGI 1.2 - case DXGI_FORMAT_YUY2: memcpy(&ddpf, &DDSPF_YUY2, sizeof(DDS_PIXELFORMAT)); break; // DXGI 1.2 - - // Legacy D3DX formats using D3DFMT enum value as FourCC - case DXGI_FORMAT_R32G32B32A32_FLOAT: - ddpf.size = sizeof(DDS_PIXELFORMAT); ddpf.flags = DDS_FOURCC; ddpf.fourCC = 116; // D3DFMT_A32B32G32R32F - break; - case DXGI_FORMAT_R16G16B16A16_FLOAT: - ddpf.size = sizeof(DDS_PIXELFORMAT); ddpf.flags = DDS_FOURCC; ddpf.fourCC = 113; // D3DFMT_A16B16G16R16F - break; - case DXGI_FORMAT_R16G16B16A16_UNORM: - ddpf.size = sizeof(DDS_PIXELFORMAT); ddpf.flags = DDS_FOURCC; ddpf.fourCC = 36; // D3DFMT_A16B16G16R16 - break; - case DXGI_FORMAT_R16G16B16A16_SNORM: - ddpf.size = sizeof(DDS_PIXELFORMAT); ddpf.flags = DDS_FOURCC; ddpf.fourCC = 110; // D3DFMT_Q16W16V16U16 - break; - case DXGI_FORMAT_R32G32_FLOAT: - ddpf.size = sizeof(DDS_PIXELFORMAT); ddpf.flags = DDS_FOURCC; ddpf.fourCC = 115; // D3DFMT_G32R32F - break; - case DXGI_FORMAT_R16G16_FLOAT: - ddpf.size = sizeof(DDS_PIXELFORMAT); ddpf.flags = DDS_FOURCC; ddpf.fourCC = 112; // D3DFMT_G16R16F - break; - case DXGI_FORMAT_R32_FLOAT: - ddpf.size = sizeof(DDS_PIXELFORMAT); ddpf.flags = DDS_FOURCC; ddpf.fourCC = 114; // D3DFMT_R32F - break; - case DXGI_FORMAT_R16_FLOAT: - ddpf.size = sizeof(DDS_PIXELFORMAT); ddpf.flags = DDS_FOURCC; ddpf.fourCC = 111; // D3DFMT_R16F - break; - - // DX9 legacy pixel formats - case DXGI_FORMAT_R10G10B10A2_UNORM: - if (flags & DDS_FLAGS_FORCE_DX9_LEGACY) - { - // Write using the 'incorrect' mask version to match D3DX bug - memcpy(&ddpf, &DDSPF_A2B10G10R10, sizeof(DDS_PIXELFORMAT)); - } - break; - - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - if (flags & DDS_FLAGS_FORCE_DX9_LEGACY) - { - memcpy(&ddpf, &DDSPF_A8B8G8R8, sizeof(DDS_PIXELFORMAT)); - } - break; - - case DXGI_FORMAT_BC1_UNORM_SRGB: - if (flags & DDS_FLAGS_FORCE_DX9_LEGACY) - { - memcpy(&ddpf, &DDSPF_DXT1, sizeof(DDS_PIXELFORMAT)); - } - break; - - case DXGI_FORMAT_BC2_UNORM_SRGB: - if (flags & DDS_FLAGS_FORCE_DX9_LEGACY) - { - memcpy(&ddpf, metadata.IsPMAlpha() ? (&DDSPF_DXT2) : (&DDSPF_DXT3), sizeof(DDS_PIXELFORMAT)); - } - break; - - case DXGI_FORMAT_BC3_UNORM_SRGB: - if (flags & DDS_FLAGS_FORCE_DX9_LEGACY) - { - memcpy(&ddpf, metadata.IsPMAlpha() ? (&DDSPF_DXT4) : (&DDSPF_DXT5), sizeof(DDS_PIXELFORMAT)); - } - break; - - case DXGI_FORMAT_BC4_UNORM: - memcpy(&ddpf, &DDSPF_BC4_UNORM, sizeof(DDS_PIXELFORMAT)); - if (flags & DDS_FLAGS_FORCE_DX9_LEGACY) - { - ddpf.fourCC = MAKEFOURCC('A', 'T', 'I', '1'); - } - break; - - case DXGI_FORMAT_BC5_UNORM: - memcpy(&ddpf, &DDSPF_BC5_UNORM, sizeof(DDS_PIXELFORMAT)); - if (flags & DDS_FLAGS_FORCE_DX9_LEGACY) - { - ddpf.fourCC = MAKEFOURCC('A', 'T', 'I', '2'); - } - break; - - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - if (flags & DDS_FLAGS_FORCE_DX9_LEGACY) - { - memcpy(&ddpf, &DDSPF_A8R8G8B8, sizeof(DDS_PIXELFORMAT)); - } - break; - - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - if (flags & DDS_FLAGS_FORCE_DX9_LEGACY) - { - memcpy(&ddpf, &DDSPF_X8R8G8B8, sizeof(DDS_PIXELFORMAT)); - } - break; - - default: - break; - } - } - - required = sizeof(uint32_t) + sizeof(DDS_HEADER); - - if (ddpf.size == 0) - { - if (flags & DDS_FLAGS_FORCE_DX9_LEGACY) - return HRESULT_E_CANNOT_MAKE; - - required += sizeof(DDS_HEADER_DXT10); - } - - if (!pDestination) - return S_OK; - - if (maxsize < required) - return E_NOT_SUFFICIENT_BUFFER; - - *static_cast(pDestination) = DDS_MAGIC; - - auto header = reinterpret_cast(static_cast(pDestination) + sizeof(uint32_t)); - assert(header); - - memset(header, 0, sizeof(DDS_HEADER)); - header->size = sizeof(DDS_HEADER); - header->flags = DDS_HEADER_FLAGS_TEXTURE; - header->caps = DDS_SURFACE_FLAGS_TEXTURE; - - if (metadata.mipLevels > 0) - { - header->flags |= DDS_HEADER_FLAGS_MIPMAP; - - if (metadata.mipLevels > UINT16_MAX) - return E_INVALIDARG; - - header->mipMapCount = static_cast(metadata.mipLevels); - - if (header->mipMapCount > 1) - header->caps |= DDS_SURFACE_FLAGS_MIPMAP; - } - - switch (metadata.dimension) - { - case TEX_DIMENSION_TEXTURE1D: - if (metadata.width > UINT32_MAX) - return E_INVALIDARG; - - header->width = static_cast(metadata.width); - header->height = header->depth = 1; - break; - - case TEX_DIMENSION_TEXTURE2D: - if (metadata.height > UINT32_MAX - || metadata.width > UINT32_MAX) - return E_INVALIDARG; - - header->height = static_cast(metadata.height); - header->width = static_cast(metadata.width); - header->depth = 1; - - if (metadata.IsCubemap()) - { - header->caps |= DDS_SURFACE_FLAGS_CUBEMAP; - header->caps2 |= DDS_CUBEMAP_ALLFACES; - } - break; - - case TEX_DIMENSION_TEXTURE3D: - if (metadata.height > UINT32_MAX - || metadata.width > UINT32_MAX - || metadata.depth > UINT16_MAX) - return E_INVALIDARG; - - header->flags |= DDS_HEADER_FLAGS_VOLUME; - header->caps2 |= DDS_FLAGS_VOLUME; - header->height = static_cast(metadata.height); - header->width = static_cast(metadata.width); - header->depth = static_cast(metadata.depth); - break; - - default: - return E_FAIL; - } - - size_t rowPitch, slicePitch; - HRESULT hr = ComputePitch(metadata.format, metadata.width, metadata.height, rowPitch, slicePitch, CP_FLAGS_NONE); - if (FAILED(hr)) - return hr; - - if (slicePitch > UINT32_MAX - || rowPitch > UINT32_MAX) - return E_FAIL; - - if (IsCompressed(metadata.format)) - { - header->flags |= DDS_HEADER_FLAGS_LINEARSIZE; - header->pitchOrLinearSize = static_cast(slicePitch); - } - else - { - header->flags |= DDS_HEADER_FLAGS_PITCH; - header->pitchOrLinearSize = static_cast(rowPitch); - } - - if (ddpf.size == 0) - { - memcpy(&header->ddspf, &DDSPF_DX10, sizeof(DDS_PIXELFORMAT)); - - auto ext = reinterpret_cast(reinterpret_cast(header) + sizeof(DDS_HEADER)); - assert(ext); - - memset(ext, 0, sizeof(DDS_HEADER_DXT10)); - ext->dxgiFormat = metadata.format; - ext->resourceDimension = metadata.dimension; - - if (metadata.arraySize > UINT16_MAX) - return E_INVALIDARG; - - static_assert(static_cast(TEX_MISC_TEXTURECUBE) == static_cast(DDS_RESOURCE_MISC_TEXTURECUBE), "DDS header mismatch"); - - ext->miscFlag = metadata.miscFlags & ~static_cast(TEX_MISC_TEXTURECUBE); - - if (metadata.miscFlags & TEX_MISC_TEXTURECUBE) - { - ext->miscFlag |= TEX_MISC_TEXTURECUBE; - assert((metadata.arraySize % 6) == 0); - ext->arraySize = static_cast(metadata.arraySize / 6); - } - else - { - ext->arraySize = static_cast(metadata.arraySize); - } - - static_assert(static_cast(TEX_MISC2_ALPHA_MODE_MASK) == static_cast(DDS_MISC_FLAGS2_ALPHA_MODE_MASK), "DDS header mismatch"); - - static_assert(static_cast(TEX_ALPHA_MODE_UNKNOWN) == static_cast(DDS_ALPHA_MODE_UNKNOWN), "DDS header mismatch"); - static_assert(static_cast(TEX_ALPHA_MODE_STRAIGHT) == static_cast(DDS_ALPHA_MODE_STRAIGHT), "DDS header mismatch"); - static_assert(static_cast(TEX_ALPHA_MODE_PREMULTIPLIED) == static_cast(DDS_ALPHA_MODE_PREMULTIPLIED), "DDS header mismatch"); - static_assert(static_cast(TEX_ALPHA_MODE_OPAQUE) == static_cast(DDS_ALPHA_MODE_OPAQUE), "DDS header mismatch"); - static_assert(static_cast(TEX_ALPHA_MODE_CUSTOM) == static_cast(DDS_ALPHA_MODE_CUSTOM), "DDS header mismatch"); - - if (flags & DDS_FLAGS_FORCE_DX10_EXT_MISC2) - { - // This was formerly 'reserved'. D3DX10 and D3DX11 will fail if this value is anything other than 0 - ext->miscFlags2 = metadata.miscFlags2; - } - } - else - { - memcpy(&header->ddspf, &ddpf, sizeof(ddpf)); - } - - return S_OK; -} - - -namespace -{ - //------------------------------------------------------------------------------------- - // Converts an image row with optional clearing of alpha value to 1.0 - // Returns true if supported, false if expansion case not supported - //------------------------------------------------------------------------------------- - enum TEXP_LEGACY_FORMAT - { - TEXP_LEGACY_UNKNOWN = 0, - TEXP_LEGACY_R8G8B8, - TEXP_LEGACY_R3G3B2, - TEXP_LEGACY_A8R3G3B2, - TEXP_LEGACY_P8, - TEXP_LEGACY_A8P8, - TEXP_LEGACY_A4L4, - TEXP_LEGACY_B4G4R4A4, - TEXP_LEGACY_L8, - TEXP_LEGACY_L16, - TEXP_LEGACY_A8L8 - }; - - constexpr TEXP_LEGACY_FORMAT FindLegacyFormat(uint32_t flags) noexcept - { - TEXP_LEGACY_FORMAT lformat = TEXP_LEGACY_UNKNOWN; - - if (flags & CONV_FLAGS_PAL8) - { - lformat = (flags & CONV_FLAGS_A8P8) ? TEXP_LEGACY_A8P8 : TEXP_LEGACY_P8; - } - else if (flags & CONV_FLAGS_888) - lformat = TEXP_LEGACY_R8G8B8; - else if (flags & CONV_FLAGS_332) - lformat = TEXP_LEGACY_R3G3B2; - else if (flags & CONV_FLAGS_8332) - lformat = TEXP_LEGACY_A8R3G3B2; - else if (flags & CONV_FLAGS_44) - lformat = TEXP_LEGACY_A4L4; - else if (flags & CONV_FLAGS_4444) - lformat = TEXP_LEGACY_B4G4R4A4; - else if (flags & CONV_FLAGS_L8) - lformat = TEXP_LEGACY_L8; - else if (flags & CONV_FLAGS_L16) - lformat = TEXP_LEGACY_L16; - else if (flags & CONV_FLAGS_A8L8) - lformat = TEXP_LEGACY_A8L8; - - return lformat; - } - - _Success_(return) - bool LegacyExpandScanline( - _Out_writes_bytes_(outSize) void* pDestination, - size_t outSize, - _In_ DXGI_FORMAT outFormat, - _In_reads_bytes_(inSize) const void* pSource, - size_t inSize, - _In_ TEXP_LEGACY_FORMAT inFormat, - _In_reads_opt_(256) const uint32_t* pal8, - _In_ uint32_t tflags) noexcept - { - assert(pDestination && outSize > 0); - assert(pSource && inSize > 0); - assert(IsValid(outFormat) && !IsPlanar(outFormat) && !IsPalettized(outFormat)); - - switch (inFormat) - { - case TEXP_LEGACY_R8G8B8: - if (outFormat != DXGI_FORMAT_R8G8B8A8_UNORM) - return false; - - // D3DFMT_R8G8B8 -> DXGI_FORMAT_R8G8B8A8_UNORM - if (inSize >= 3 && outSize >= 4) - { - const uint8_t * __restrict sPtr = static_cast(pSource); - uint32_t * __restrict dPtr = static_cast(pDestination); - - for (size_t ocount = 0, icount = 0; ((icount < (inSize - 2)) && (ocount < (outSize - 3))); icount += 3, ocount += 4) - { - // 24bpp Direct3D 9 files are actually BGR, so need to swizzle as well - uint32_t t1 = uint32_t(*(sPtr) << 16); - uint32_t t2 = uint32_t(*(sPtr + 1) << 8); - uint32_t t3 = uint32_t(*(sPtr + 2)); - - *(dPtr++) = t1 | t2 | t3 | 0xff000000; - sPtr += 3; - } - return true; - } - return false; - - case TEXP_LEGACY_R3G3B2: - switch (outFormat) - { - case DXGI_FORMAT_R8G8B8A8_UNORM: - // D3DFMT_R3G3B2 -> DXGI_FORMAT_R8G8B8A8_UNORM - if (inSize >= 1 && outSize >= 4) - { - const uint8_t* __restrict sPtr = static_cast(pSource); - uint32_t * __restrict dPtr = static_cast(pDestination); - - for (size_t ocount = 0, icount = 0; ((icount < inSize) && (ocount < (outSize - 3))); ++icount, ocount += 4) - { - const uint8_t t = *(sPtr++); - - uint32_t t1 = uint32_t((t & 0xe0) | ((t & 0xe0) >> 3) | ((t & 0xc0) >> 6)); - uint32_t t2 = uint32_t(((t & 0x1c) << 11) | ((t & 0x1c) << 8) | ((t & 0x18) << 5)); - uint32_t t3 = uint32_t(((t & 0x03) << 22) | ((t & 0x03) << 20) | ((t & 0x03) << 18) | ((t & 0x03) << 16)); - - *(dPtr++) = t1 | t2 | t3 | 0xff000000; - } - return true; - } - return false; - - case DXGI_FORMAT_B5G6R5_UNORM: - // D3DFMT_R3G3B2 -> DXGI_FORMAT_B5G6R5_UNORM - if (inSize >= 1 && outSize >= 2) - { - const uint8_t* __restrict sPtr = static_cast(pSource); - uint16_t * __restrict dPtr = static_cast(pDestination); - - for (size_t ocount = 0, icount = 0; ((icount < inSize) && (ocount < (outSize - 1))); ++icount, ocount += 2) - { - const unsigned t = *(sPtr++); - - unsigned t1 = ((t & 0xe0u) << 8) | ((t & 0xc0u) << 5); - unsigned t2 = ((t & 0x1cu) << 6) | ((t & 0x1cu) << 3); - unsigned t3 = ((t & 0x03u) << 3) | ((t & 0x03u) << 1) | ((t & 0x02) >> 1); - - *(dPtr++) = static_cast(t1 | t2 | t3); - } - return true; - } - return false; - - default: - return false; - } - - case TEXP_LEGACY_A8R3G3B2: - if (outFormat != DXGI_FORMAT_R8G8B8A8_UNORM) - return false; - - // D3DFMT_A8R3G3B2 -> DXGI_FORMAT_R8G8B8A8_UNORM - if (inSize >= 2 && outSize >= 4) - { - const uint16_t* __restrict sPtr = static_cast(pSource); - uint32_t * __restrict dPtr = static_cast(pDestination); - - for (size_t ocount = 0, icount = 0; ((icount < (inSize - 1)) && (ocount < (outSize - 3))); icount += 2, ocount += 4) - { - const uint16_t t = *(sPtr++); - - uint32_t t1 = uint32_t((t & 0x00e0) | ((t & 0x00e0) >> 3) | ((t & 0x00c0) >> 6)); - uint32_t t2 = uint32_t(((t & 0x001c) << 11) | ((t & 0x001c) << 8) | ((t & 0x0018) << 5)); - uint32_t t3 = uint32_t(((t & 0x0003) << 22) | ((t & 0x0003) << 20) | ((t & 0x0003) << 18) | ((t & 0x0003) << 16)); - uint32_t ta = (tflags & TEXP_SCANLINE_SETALPHA) ? 0xff000000 : uint32_t((t & 0xff00) << 16); - - *(dPtr++) = t1 | t2 | t3 | ta; - } - return true; - } - return false; - - case TEXP_LEGACY_P8: - if ((outFormat != DXGI_FORMAT_R8G8B8A8_UNORM) || !pal8) - return false; - - // D3DFMT_P8 -> DXGI_FORMAT_R8G8B8A8_UNORM - if (inSize >= 1 && outSize >= 4) - { - const uint8_t* __restrict sPtr = static_cast(pSource); - uint32_t * __restrict dPtr = static_cast(pDestination); - - for (size_t ocount = 0, icount = 0; ((icount < inSize) && (ocount < (outSize - 3))); ++icount, ocount += 4) - { - uint8_t t = *(sPtr++); - - *(dPtr++) = pal8[t]; - } - return true; - } - return false; - - case TEXP_LEGACY_A8P8: - if ((outFormat != DXGI_FORMAT_R8G8B8A8_UNORM) || !pal8) - return false; - - // D3DFMT_A8P8 -> DXGI_FORMAT_R8G8B8A8_UNORM - if (inSize >= 2 && outSize >= 4) - { - const uint16_t* __restrict sPtr = static_cast(pSource); - uint32_t * __restrict dPtr = static_cast(pDestination); - - for (size_t ocount = 0, icount = 0; ((icount < (inSize - 1)) && (ocount < (outSize - 3))); icount += 2, ocount += 4) - { - const uint16_t t = *(sPtr++); - - uint32_t t1 = pal8[t & 0xff]; - uint32_t ta = (tflags & TEXP_SCANLINE_SETALPHA) ? 0xff000000 : uint32_t((t & 0xff00) << 16); - - *(dPtr++) = t1 | ta; - } - return true; - } - return false; - - case TEXP_LEGACY_A4L4: - switch (outFormat) - { - case DXGI_FORMAT_B4G4R4A4_UNORM: - // D3DFMT_A4L4 -> DXGI_FORMAT_B4G4R4A4_UNORM - if (inSize >= 1 && outSize >= 2) - { - const uint8_t * __restrict sPtr = static_cast(pSource); - uint16_t * __restrict dPtr = static_cast(pDestination); - - for (size_t ocount = 0, icount = 0; ((icount < inSize) && (ocount < (outSize - 1))); ++icount, ocount += 2) - { - const unsigned t = *(sPtr++); - - unsigned t1 = (t & 0x0fu); - unsigned ta = (tflags & TEXP_SCANLINE_SETALPHA) ? 0xf000u : ((t & 0xf0u) << 8); - - *(dPtr++) = static_cast(t1 | (t1 << 4) | (t1 << 8) | ta); - } - return true; - } - return false; - - case DXGI_FORMAT_R8G8B8A8_UNORM: - // D3DFMT_A4L4 -> DXGI_FORMAT_R8G8B8A8_UNORM - if (inSize >= 1 && outSize >= 4) - { - const uint8_t * __restrict sPtr = static_cast(pSource); - uint32_t * __restrict dPtr = static_cast(pDestination); - - for (size_t ocount = 0, icount = 0; ((icount < inSize) && (ocount < (outSize - 3))); ++icount, ocount += 4) - { - const uint8_t t = *(sPtr++); - - uint32_t t1 = uint32_t(((t & 0x0f) << 4) | (t & 0x0f)); - uint32_t ta = (tflags & TEXP_SCANLINE_SETALPHA) ? 0xff000000 : uint32_t(((t & 0xf0) << 24) | ((t & 0xf0) << 20)); - - *(dPtr++) = t1 | (t1 << 8) | (t1 << 16) | ta; - } - return true; - } - return false; - - default: - return false; - } - - case TEXP_LEGACY_B4G4R4A4: - if (outFormat != DXGI_FORMAT_R8G8B8A8_UNORM) - return false; - - // D3DFMT_A4R4G4B4 -> DXGI_FORMAT_R8G8B8A8_UNORM - if (inSize >= 2 && outSize >= 4) - { - const uint16_t * __restrict sPtr = static_cast(pSource); - uint32_t * __restrict dPtr = static_cast(pDestination); - - for (size_t ocount = 0, icount = 0; ((icount < (inSize - 1)) && (ocount < (outSize - 3))); icount += 2, ocount += 4) - { - const uint32_t t = *(sPtr++); - - uint32_t t1 = uint32_t((t & 0x0f00) >> 4) | ((t & 0x0f00) >> 8); - uint32_t t2 = uint32_t((t & 0x00f0) << 8) | ((t & 0x00f0) << 4); - uint32_t t3 = uint32_t((t & 0x000f) << 20) | ((t & 0x000f) << 16); - uint32_t ta = uint32_t((tflags & TEXP_SCANLINE_SETALPHA) ? 0xff000000 : (((t & 0xf000) << 16) | ((t & 0xf000) << 12))); - - *(dPtr++) = t1 | t2 | t3 | ta; - } - return true; - } - return false; - - case TEXP_LEGACY_L8: - if (outFormat != DXGI_FORMAT_R8G8B8A8_UNORM) - return false; - - // D3DFMT_L8 -> DXGI_FORMAT_R8G8B8A8_UNORM - if (inSize >= 1 && outSize >= 4) - { - const uint8_t * __restrict sPtr = static_cast(pSource); - uint32_t * __restrict dPtr = static_cast(pDestination); - - for (size_t ocount = 0, icount = 0; ((icount < inSize) && (ocount < (outSize - 3))); ++icount, ocount += 4) - { - uint32_t t1 = *(sPtr++); - uint32_t t2 = (t1 << 8); - uint32_t t3 = (t1 << 16); - - *(dPtr++) = t1 | t2 | t3 | 0xff000000; - } - return true; - } - return false; - - case TEXP_LEGACY_L16: - if (outFormat != DXGI_FORMAT_R16G16B16A16_UNORM) - return false; - - // D3DFMT_L16 -> DXGI_FORMAT_R16G16B16A16_UNORM - if (inSize >= 2 && outSize >= 8) - { - const uint16_t* __restrict sPtr = static_cast(pSource); - uint64_t * __restrict dPtr = static_cast(pDestination); - - for (size_t ocount = 0, icount = 0; ((icount < (inSize - 1)) && (ocount < (outSize - 7))); icount += 2, ocount += 8) - { - const uint16_t t = *(sPtr++); - - uint64_t t1 = t; - uint64_t t2 = (t1 << 16); - uint64_t t3 = (t1 << 32); - - *(dPtr++) = t1 | t2 | t3 | 0xffff000000000000; - } - return true; - } - return false; - - case TEXP_LEGACY_A8L8: - if (outFormat != DXGI_FORMAT_R8G8B8A8_UNORM) - return false; - - // D3DFMT_A8L8 -> DXGI_FORMAT_R8G8B8A8_UNORM - if (inSize >= 2 && outSize >= 4) - { - const uint16_t* __restrict sPtr = static_cast(pSource); - uint32_t * __restrict dPtr = static_cast(pDestination); - - for (size_t ocount = 0, icount = 0; ((icount < (inSize - 1)) && (ocount < (outSize - 3))); icount += 2, ocount += 4) - { - const uint16_t t = *(sPtr++); - - uint32_t t1 = uint32_t(t & 0xff); - uint32_t t2 = uint32_t(t1 << 8); - uint32_t t3 = uint32_t(t1 << 16); - uint32_t ta = (tflags & TEXP_SCANLINE_SETALPHA) ? 0xff000000 : uint32_t((t & 0xff00) << 16); - - *(dPtr++) = t1 | t2 | t3 | ta; - } - return true; - } - return false; - - default: - return false; - } - } - - - //------------------------------------------------------------------------------------- - // Converts or copies image data from pPixels into scratch image data - //------------------------------------------------------------------------------------- - HRESULT CopyImage( - _In_reads_bytes_(size) const void* pPixels, - _In_ size_t size, - _In_ const TexMetadata& metadata, - _In_ CP_FLAGS cpFlags, - _In_ uint32_t convFlags, - _In_reads_opt_(256) const uint32_t *pal8, - _In_ const ScratchImage& image) noexcept - { - assert(pPixels); - assert(image.GetPixels()); - - if (!size) - return E_FAIL; - - if (convFlags & CONV_FLAGS_EXPAND) - { - if (convFlags & CONV_FLAGS_888) - cpFlags |= CP_FLAGS_24BPP; - else if (convFlags & (CONV_FLAGS_565 | CONV_FLAGS_5551 | CONV_FLAGS_4444 | CONV_FLAGS_8332 | CONV_FLAGS_A8P8 | CONV_FLAGS_L16 | CONV_FLAGS_A8L8)) - cpFlags |= CP_FLAGS_16BPP; - else if (convFlags & (CONV_FLAGS_44 | CONV_FLAGS_332 | CONV_FLAGS_PAL8 | CONV_FLAGS_L8)) - cpFlags |= CP_FLAGS_8BPP; - } - - size_t pixelSize, nimages; - if (!DetermineImageArray(metadata, cpFlags, nimages, pixelSize)) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - if ((nimages == 0) || (nimages != image.GetImageCount())) - { - return E_FAIL; - } - - if (pixelSize > size) - { - return HRESULT_E_HANDLE_EOF; - } - - std::unique_ptr timages(new (std::nothrow) Image[nimages]); - if (!timages) - { - return E_OUTOFMEMORY; - } - - if (!SetupImageArray( - const_cast(reinterpret_cast(pPixels)), - pixelSize, - metadata, - cpFlags, - timages.get(), - nimages)) - { - return E_FAIL; - } - - if (nimages != image.GetImageCount()) - { - return E_FAIL; - } - - const Image* images = image.GetImages(); - if (!images) - { - return E_FAIL; - } - - uint32_t tflags = (convFlags & CONV_FLAGS_NOALPHA) ? TEXP_SCANLINE_SETALPHA : 0u; - if (convFlags & CONV_FLAGS_SWIZZLE) - tflags |= TEXP_SCANLINE_LEGACY; - - switch (metadata.dimension) - { - case TEX_DIMENSION_TEXTURE1D: - case TEX_DIMENSION_TEXTURE2D: - { - size_t index = 0; - for (size_t item = 0; item < metadata.arraySize; ++item) - { - size_t lastgood = 0; - for (size_t level = 0; level < metadata.mipLevels; ++level, ++index) - { - if (index >= nimages) - return E_FAIL; - - if (images[index].height != timages[index].height) - return E_FAIL; - - size_t dpitch = images[index].rowPitch; - const size_t spitch = timages[index].rowPitch; - - const uint8_t *pSrc = timages[index].pixels; - if (!pSrc) - return E_POINTER; - - uint8_t *pDest = images[index].pixels; - if (!pDest) - return E_POINTER; - - if (IsCompressed(metadata.format)) - { - size_t csize = std::min(images[index].slicePitch, timages[index].slicePitch); - memcpy(pDest, pSrc, csize); - - if (cpFlags & CP_FLAGS_BAD_DXTN_TAILS) - { - if (images[index].width < 4 || images[index].height < 4) - { - csize = std::min(images[index].slicePitch, timages[lastgood].slicePitch); - memcpy(pDest, timages[lastgood].pixels, csize); - } - else - { - lastgood = index; - } - } - } - else if (IsPlanar(metadata.format)) - { - const size_t count = ComputeScanlines(metadata.format, images[index].height); - if (!count) - return E_UNEXPECTED; - - const size_t csize = std::min(dpitch, spitch); - for (size_t h = 0; h < count; ++h) - { - memcpy(pDest, pSrc, csize); - pSrc += spitch; - pDest += dpitch; - } - } - else - { - for (size_t h = 0; h < images[index].height; ++h) - { - if (convFlags & CONV_FLAGS_EXPAND) - { - if (convFlags & (CONV_FLAGS_565 | CONV_FLAGS_5551 | CONV_FLAGS_4444)) - { - if (!ExpandScanline(pDest, dpitch, DXGI_FORMAT_R8G8B8A8_UNORM, - pSrc, spitch, - (convFlags & CONV_FLAGS_565) ? DXGI_FORMAT_B5G6R5_UNORM : DXGI_FORMAT_B5G5R5A1_UNORM, - tflags)) - return E_FAIL; - } - else - { - const TEXP_LEGACY_FORMAT lformat = FindLegacyFormat(convFlags); - if (!LegacyExpandScanline(pDest, dpitch, metadata.format, - pSrc, spitch, lformat, pal8, - tflags)) - return E_FAIL; - } - } - else if (convFlags & CONV_FLAGS_SWIZZLE) - { - SwizzleScanline(pDest, dpitch, pSrc, spitch, - metadata.format, tflags); - } - else - { - CopyScanline(pDest, dpitch, pSrc, spitch, - metadata.format, tflags); - } - - pSrc += spitch; - pDest += dpitch; - } - } - } - } - } - break; - - case TEX_DIMENSION_TEXTURE3D: - { - size_t index = 0; - size_t d = metadata.depth; - - size_t lastgood = 0; - for (size_t level = 0; level < metadata.mipLevels; ++level) - { - for (size_t slice = 0; slice < d; ++slice, ++index) - { - if (index >= nimages) - return E_FAIL; - - if (images[index].height != timages[index].height) - return E_FAIL; - - size_t dpitch = images[index].rowPitch; - const size_t spitch = timages[index].rowPitch; - - const uint8_t *pSrc = timages[index].pixels; - if (!pSrc) - return E_POINTER; - - uint8_t *pDest = images[index].pixels; - if (!pDest) - return E_POINTER; - - if (IsCompressed(metadata.format)) - { - size_t csize = std::min(images[index].slicePitch, timages[index].slicePitch); - memcpy(pDest, pSrc, csize); - - if (cpFlags & CP_FLAGS_BAD_DXTN_TAILS) - { - if (images[index].width < 4 || images[index].height < 4) - { - csize = std::min(images[index].slicePitch, timages[lastgood + slice].slicePitch); - memcpy(pDest, timages[lastgood + slice].pixels, csize); - } - else if (!slice) - { - lastgood = index; - } - } - } - else if (IsPlanar(metadata.format)) - { - // Direct3D does not support any planar formats for Texture3D - return HRESULT_E_NOT_SUPPORTED; - } - else - { - for (size_t h = 0; h < images[index].height; ++h) - { - if (convFlags & CONV_FLAGS_EXPAND) - { - if (convFlags & (CONV_FLAGS_565 | CONV_FLAGS_5551 | CONV_FLAGS_4444)) - { - if (!ExpandScanline(pDest, dpitch, DXGI_FORMAT_R8G8B8A8_UNORM, - pSrc, spitch, - (convFlags & CONV_FLAGS_565) ? DXGI_FORMAT_B5G6R5_UNORM : DXGI_FORMAT_B5G5R5A1_UNORM, - tflags)) - return E_FAIL; - } - else - { - const TEXP_LEGACY_FORMAT lformat = FindLegacyFormat(convFlags); - if (!LegacyExpandScanline(pDest, dpitch, metadata.format, - pSrc, spitch, lformat, pal8, - tflags)) - return E_FAIL; - } - } - else if (convFlags & CONV_FLAGS_SWIZZLE) - { - SwizzleScanline(pDest, dpitch, pSrc, spitch, metadata.format, tflags); - } - else - { - CopyScanline(pDest, dpitch, pSrc, spitch, metadata.format, tflags); - } - - pSrc += spitch; - pDest += dpitch; - } - } - } - - if (d > 1) - d >>= 1; - } - } - break; - - default: - return E_FAIL; - } - - return S_OK; - } - - HRESULT CopyImageInPlace(uint32_t convFlags, _In_ const ScratchImage& image) noexcept - { - if (!image.GetPixels()) - return E_FAIL; - - const Image* images = image.GetImages(); - if (!images) - return E_FAIL; - - const TexMetadata& metadata = image.GetMetadata(); - - if (IsPlanar(metadata.format)) - return HRESULT_E_NOT_SUPPORTED; - - uint32_t tflags = (convFlags & CONV_FLAGS_NOALPHA) ? TEXP_SCANLINE_SETALPHA : 0u; - if (convFlags & CONV_FLAGS_SWIZZLE) - tflags |= TEXP_SCANLINE_LEGACY; - - for (size_t i = 0; i < image.GetImageCount(); ++i) - { - const Image* img = &images[i]; - uint8_t *pPixels = img->pixels; - if (!pPixels) - return E_POINTER; - - size_t rowPitch = img->rowPitch; - - for (size_t h = 0; h < img->height; ++h) - { - if (convFlags & CONV_FLAGS_SWIZZLE) - { - SwizzleScanline(pPixels, rowPitch, pPixels, rowPitch, metadata.format, tflags); - } - else - { - CopyScanline(pPixels, rowPitch, pPixels, rowPitch, metadata.format, tflags); - } - - pPixels += rowPitch; - } - } - - return S_OK; - } -} - - -//===================================================================================== -// Entry-points -//===================================================================================== - -//------------------------------------------------------------------------------------- -// Obtain metadata from DDS file in memory/on disk -//------------------------------------------------------------------------------------- - -_Use_decl_annotations_ -HRESULT DirectX::GetMetadataFromDDSMemory( - const void* pSource, - size_t size, - DDS_FLAGS flags, - TexMetadata& metadata) noexcept -{ - if (!pSource || size == 0) - return E_INVALIDARG; - - uint32_t convFlags = 0; - return DecodeDDSHeader(pSource, size, flags, metadata, convFlags); -} - -_Use_decl_annotations_ -HRESULT DirectX::GetMetadataFromDDSFile( - const wchar_t* szFile, - DDS_FLAGS flags, - TexMetadata& metadata) noexcept -{ - if (!szFile) - return E_INVALIDARG; - -#ifdef _WIN32 -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(szFile, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, - FILE_FLAG_SEQUENTIAL_SCAN, nullptr))); -#endif - if (!hFile) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - // Get the file size - FILE_STANDARD_INFO fileInfo; - if (!GetFileInformationByHandleEx(hFile.get(), FileStandardInfo, &fileInfo, sizeof(fileInfo))) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - // File is too big for 32-bit allocation, so reject read (4 GB should be plenty large enough for a valid DDS file) - if (fileInfo.EndOfFile.HighPart > 0) - { - return HRESULT_E_FILE_TOO_LARGE; - } - - const size_t len = fileInfo.EndOfFile.LowPart; -#else // !WIN32 - std::ifstream inFile(std::filesystem::path(szFile), std::ios::in | std::ios::binary | std::ios::ate); - if (!inFile) - return E_FAIL; - - std::streampos fileLen = inFile.tellg(); - if (!inFile) - return E_FAIL; - - if (fileLen > UINT32_MAX) - return HRESULT_E_FILE_TOO_LARGE; - - inFile.seekg(0, std::ios::beg); - if (!inFile) - return E_FAIL; - - const size_t len = fileLen; -#endif - - // Need at least enough data to fill the standard header and magic number to be a valid DDS - if (len < (sizeof(DDS_HEADER) + sizeof(uint32_t))) - { - return E_FAIL; - } - - // Read the header in (including extended header if present) - uint8_t header[MAX_HEADER_SIZE] = {}; - -#ifdef _WIN32 - DWORD bytesRead = 0; - if (!ReadFile(hFile.get(), header, MAX_HEADER_SIZE, &bytesRead, nullptr)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - auto const headerLen = static_cast(bytesRead); -#else - auto const headerLen = std::min(len, MAX_HEADER_SIZE); - - inFile.read(reinterpret_cast(header), headerLen); - if (!inFile) - return E_FAIL; -#endif - - uint32_t convFlags = 0; - return DecodeDDSHeader(header, headerLen, flags, metadata, convFlags); -} - - -//------------------------------------------------------------------------------------- -// Load a DDS file in memory -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::LoadFromDDSMemory( - const void* pSource, - size_t size, - DDS_FLAGS flags, - TexMetadata* metadata, - ScratchImage& image) noexcept -{ - if (!pSource || size == 0) - return E_INVALIDARG; - - image.Release(); - - uint32_t convFlags = 0; - TexMetadata mdata; - HRESULT hr = DecodeDDSHeader(pSource, size, flags, mdata, convFlags); - if (FAILED(hr)) - return hr; - - size_t offset = sizeof(uint32_t) + sizeof(DDS_HEADER); - if (convFlags & CONV_FLAGS_DX10) - offset += sizeof(DDS_HEADER_DXT10); - - assert(offset <= size); - - const uint32_t *pal8 = nullptr; - if (convFlags & CONV_FLAGS_PAL8) - { - pal8 = reinterpret_cast(static_cast(pSource) + offset); - assert(pal8); - offset += (256 * sizeof(uint32_t)); - if (size < offset) - return E_FAIL; - } - - hr = image.Initialize(mdata); - if (FAILED(hr)) - return hr; - - CP_FLAGS cflags = CP_FLAGS_NONE; - if (flags & DDS_FLAGS_LEGACY_DWORD) - { - cflags |= CP_FLAGS_LEGACY_DWORD; - } - if (flags & DDS_FLAGS_BAD_DXTN_TAILS) - { - cflags |= CP_FLAGS_BAD_DXTN_TAILS; - } - - const void* pPixels = static_cast(pSource) + offset; - assert(pPixels); - hr = CopyImage(pPixels, - size - offset, - mdata, - cflags, - convFlags, - pal8, - image); - if (FAILED(hr)) - { - image.Release(); - return hr; - } - if (metadata) - memcpy(metadata, &mdata, sizeof(TexMetadata)); - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -// Load a DDS file from disk -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::LoadFromDDSFile( - const wchar_t* szFile, - DDS_FLAGS flags, - TexMetadata* metadata, - ScratchImage& image) noexcept -{ - if (!szFile) - return E_INVALIDARG; - - image.Release(); - -#ifdef _WIN32 -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(szFile, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, - FILE_FLAG_SEQUENTIAL_SCAN, nullptr))); -#endif - if (!hFile) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - // Get the file size - FILE_STANDARD_INFO fileInfo; - if (!GetFileInformationByHandleEx(hFile.get(), FileStandardInfo, &fileInfo, sizeof(fileInfo))) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - // File is too big for 32-bit allocation, so reject read (4 GB should be plenty large enough for a valid DDS file) - if (fileInfo.EndOfFile.HighPart > 0) - return HRESULT_E_FILE_TOO_LARGE; - - const size_t len = fileInfo.EndOfFile.LowPart; -#else // !WIN32 - std::ifstream inFile(std::filesystem::path(szFile), std::ios::in | std::ios::binary | std::ios::ate); - if (!inFile) - return E_FAIL; - - std::streampos fileLen = inFile.tellg(); - if (!inFile) - return E_FAIL; - - if (fileLen > UINT32_MAX) - return HRESULT_E_FILE_TOO_LARGE; - - inFile.seekg(0, std::ios::beg); - if (!inFile) - return E_FAIL; - - const size_t len = fileLen; -#endif - - // Need at least enough data to fill the standard header and magic number to be a valid DDS - if (len < (sizeof(DDS_HEADER) + sizeof(uint32_t))) - { - return E_FAIL; - } - - // Read the header in (including extended header if present) - uint8_t header[MAX_HEADER_SIZE] = {}; - -#ifdef _WIN32 - DWORD bytesRead = 0; - if (!ReadFile(hFile.get(), header, MAX_HEADER_SIZE, &bytesRead, nullptr)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - auto const headerLen = static_cast(bytesRead); -#else - auto const headerLen = std::min(len, MAX_HEADER_SIZE); - - inFile.read(reinterpret_cast(header), headerLen); - if (!inFile) - return E_FAIL; -#endif - - uint32_t convFlags = 0; - TexMetadata mdata; - HRESULT hr = DecodeDDSHeader(header, headerLen, flags, mdata, convFlags); - if (FAILED(hr)) - return hr; - - size_t offset = MAX_HEADER_SIZE; - - if (!(convFlags & CONV_FLAGS_DX10)) - { - #ifdef _WIN32 - // Must reset file position since we read more than the standard header above - const LARGE_INTEGER filePos = { { sizeof(uint32_t) + sizeof(DDS_HEADER), 0 } }; - if (!SetFilePointerEx(hFile.get(), filePos, nullptr, FILE_BEGIN)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - #else - inFile.seekg(sizeof(uint32_t) + sizeof(DDS_HEADER), std::ios::beg); - if (!inFile) - return E_FAIL; - #endif - - offset = sizeof(uint32_t) + sizeof(DDS_HEADER); - } - - std::unique_ptr pal8; - if (convFlags & CONV_FLAGS_PAL8) - { - pal8.reset(new (std::nothrow) uint32_t[256]); - if (!pal8) - { - return E_OUTOFMEMORY; - } - - #ifdef _WIN32 - if (!ReadFile(hFile.get(), pal8.get(), 256 * sizeof(uint32_t), &bytesRead, nullptr)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesRead != (256 * sizeof(uint32_t))) - { - return E_FAIL; - } - #else - inFile.read(reinterpret_cast(pal8.get()), 256 * sizeof(uint32_t)); - if (!inFile) - return E_FAIL; - #endif - - offset += (256 * sizeof(uint32_t)); - } - - const size_t remaining = len - offset; - if (remaining == 0) - return E_FAIL; - - hr = image.Initialize(mdata); - if (FAILED(hr)) - return hr; - - if ((convFlags & CONV_FLAGS_EXPAND) || (flags & (DDS_FLAGS_LEGACY_DWORD | DDS_FLAGS_BAD_DXTN_TAILS))) - { - std::unique_ptr temp(new (std::nothrow) uint8_t[remaining]); - if (!temp) - { - image.Release(); - return E_OUTOFMEMORY; - } - - #ifdef _WIN32 - if (!ReadFile(hFile.get(), temp.get(), static_cast(remaining), &bytesRead, nullptr)) - { - image.Release(); - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesRead != remaining) - { - image.Release(); - return E_FAIL; - } - #else - inFile.read(reinterpret_cast(temp.get()), remaining); - if (!inFile) - { - image.Release(); - return E_FAIL; - } - #endif - - CP_FLAGS cflags = CP_FLAGS_NONE; - if (flags & DDS_FLAGS_LEGACY_DWORD) - { - cflags |= CP_FLAGS_LEGACY_DWORD; - } - if (flags & DDS_FLAGS_BAD_DXTN_TAILS) - { - cflags |= CP_FLAGS_BAD_DXTN_TAILS; - } - - hr = CopyImage(temp.get(), - remaining, - mdata, - cflags, - convFlags, - pal8.get(), - image); - if (FAILED(hr)) - { - image.Release(); - return hr; - } - } - else - { - if (remaining < image.GetPixelsSize()) - { - image.Release(); - return HRESULT_E_HANDLE_EOF; - } - - if (image.GetPixelsSize() > UINT32_MAX) - { - image.Release(); - return HRESULT_E_ARITHMETIC_OVERFLOW; - } - - #ifdef _WIN32 - auto pixelBytes = static_cast(image.GetPixelsSize()); - if (!ReadFile(hFile.get(), image.GetPixels(), pixelBytes, &bytesRead, nullptr)) - { - image.Release(); - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesRead != pixelBytes) - { - image.Release(); - return E_FAIL; - } - #else - inFile.read(reinterpret_cast(image.GetPixels()), image.GetPixelsSize()); - if (!inFile) - { - image.Release(); - return E_FAIL; - } - #endif - - if (convFlags & (CONV_FLAGS_SWIZZLE | CONV_FLAGS_NOALPHA)) - { - // Swizzle/copy image in place - hr = CopyImageInPlace(convFlags, image); - if (FAILED(hr)) - { - image.Release(); - return hr; - } - } - } - - if (metadata) - memcpy(metadata, &mdata, sizeof(TexMetadata)); - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -// Save a DDS file to memory -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::SaveToDDSMemory( - const Image* images, - size_t nimages, - const TexMetadata& metadata, - DDS_FLAGS flags, - Blob& blob) noexcept -{ - if (!images || (nimages == 0)) - return E_INVALIDARG; - - // Determine memory required - size_t required = 0; - HRESULT hr = EncodeDDSHeader(metadata, flags, nullptr, 0, required); - if (FAILED(hr)) - return hr; - - bool fastpath = true; - - for (size_t i = 0; i < nimages; ++i) - { - if (!images[i].pixels) - return E_POINTER; - - if (images[i].format != metadata.format) - return E_FAIL; - - size_t ddsRowPitch, ddsSlicePitch; - hr = ComputePitch(metadata.format, images[i].width, images[i].height, ddsRowPitch, ddsSlicePitch, CP_FLAGS_NONE); - if (FAILED(hr)) - return hr; - - assert(images[i].rowPitch > 0); - assert(images[i].slicePitch > 0); - - if ((images[i].rowPitch != ddsRowPitch) || (images[i].slicePitch != ddsSlicePitch)) - { - fastpath = false; - } - - required += ddsSlicePitch; - } - - assert(required > 0); - - blob.Release(); - - hr = blob.Initialize(required); - if (FAILED(hr)) - return hr; - - auto pDestination = static_cast(blob.GetBufferPointer()); - assert(pDestination); - - hr = EncodeDDSHeader(metadata, flags, pDestination, blob.GetBufferSize(), required); - if (FAILED(hr)) - { - blob.Release(); - return hr; - } - - size_t remaining = blob.GetBufferSize() - required; - pDestination += required; - - if (!remaining) - { - blob.Release(); - return E_FAIL; - } - - switch (static_cast(metadata.dimension)) - { - case DDS_DIMENSION_TEXTURE1D: - case DDS_DIMENSION_TEXTURE2D: - { - size_t index = 0; - for (size_t item = 0; item < metadata.arraySize; ++item) - { - for (size_t level = 0; level < metadata.mipLevels; ++level) - { - if (index >= nimages) - { - blob.Release(); - return E_FAIL; - } - - if (fastpath) - { - size_t pixsize = images[index].slicePitch; - memcpy(pDestination, images[index].pixels, pixsize); - - pDestination += pixsize; - remaining -= pixsize; - } - else - { - size_t ddsRowPitch, ddsSlicePitch; - hr = ComputePitch(metadata.format, images[index].width, images[index].height, ddsRowPitch, ddsSlicePitch, CP_FLAGS_NONE); - if (FAILED(hr)) - { - blob.Release(); - return hr; - } - - const size_t rowPitch = images[index].rowPitch; - - const uint8_t * __restrict sPtr = images[index].pixels; - uint8_t * __restrict dPtr = pDestination; - - const size_t lines = ComputeScanlines(metadata.format, images[index].height); - const size_t csize = std::min(rowPitch, ddsRowPitch); - size_t tremaining = remaining; - for (size_t j = 0; j < lines; ++j) - { - if (tremaining < csize) - { - blob.Release(); - return E_FAIL; - } - - memcpy(dPtr, sPtr, csize); - - sPtr += rowPitch; - dPtr += ddsRowPitch; - tremaining -= ddsRowPitch; - } - - pDestination += ddsSlicePitch; - remaining -= ddsSlicePitch; - } - - ++index; - } - } - } - break; - - case DDS_DIMENSION_TEXTURE3D: - { - if (metadata.arraySize != 1) - { - blob.Release(); - return E_FAIL; - } - - size_t d = metadata.depth; - - size_t index = 0; - for (size_t level = 0; level < metadata.mipLevels; ++level) - { - for (size_t slice = 0; slice < d; ++slice) - { - if (index >= nimages) - { - blob.Release(); - return E_FAIL; - } - - if (fastpath) - { - size_t pixsize = images[index].slicePitch; - memcpy(pDestination, images[index].pixels, pixsize); - - pDestination += pixsize; - remaining -= pixsize; - } - else - { - size_t ddsRowPitch, ddsSlicePitch; - hr = ComputePitch(metadata.format, images[index].width, images[index].height, ddsRowPitch, ddsSlicePitch, CP_FLAGS_NONE); - if (FAILED(hr)) - { - blob.Release(); - return hr; - } - - const size_t rowPitch = images[index].rowPitch; - - const uint8_t * __restrict sPtr = images[index].pixels; - uint8_t * __restrict dPtr = pDestination; - - const size_t lines = ComputeScanlines(metadata.format, images[index].height); - const size_t csize = std::min(rowPitch, ddsRowPitch); - size_t tremaining = remaining; - for (size_t j = 0; j < lines; ++j) - { - if (tremaining < csize) - { - blob.Release(); - return E_FAIL; - } - - memcpy(dPtr, sPtr, csize); - - sPtr += rowPitch; - dPtr += ddsRowPitch; - tremaining -= ddsRowPitch; - } - - pDestination += ddsSlicePitch; - remaining -= ddsSlicePitch; - } - - ++index; - } - - if (d > 1) - d >>= 1; - } - } - break; - - default: - blob.Release(); - return E_FAIL; - } - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -// Save a DDS file to disk -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::SaveToDDSFile( - const Image* images, - size_t nimages, - const TexMetadata& metadata, - DDS_FLAGS flags, - const wchar_t* szFile) noexcept -{ - if (!szFile) - return E_INVALIDARG; - - // Create DDS Header - uint8_t header[MAX_HEADER_SIZE]; - size_t required; - HRESULT hr = EncodeDDSHeader(metadata, flags, header, MAX_HEADER_SIZE, required); - if (FAILED(hr)) - return hr; - - // Create file and write header -#ifdef _WIN32 -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFile, - GENERIC_WRITE | DELETE, 0, CREATE_ALWAYS, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(szFile, - GENERIC_WRITE | DELETE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr))); -#endif - if (!hFile) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - auto_delete_file delonfail(hFile.get()); - - DWORD bytesWritten; - if (!WriteFile(hFile.get(), header, static_cast(required), &bytesWritten, nullptr)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesWritten != required) - { - return E_FAIL; - } -#else // !WIN32 - std::ofstream outFile(std::filesystem::path(szFile), std::ios::out | std::ios::binary | std::ios::trunc); - if (!outFile) - return E_FAIL; - - outFile.write(reinterpret_cast(header), static_cast(required)); - if (!outFile) - return E_FAIL; -#endif - - // Write images - switch (static_cast(metadata.dimension)) - { - case DDS_DIMENSION_TEXTURE1D: - case DDS_DIMENSION_TEXTURE2D: - { - size_t index = 0; - for (size_t item = 0; item < metadata.arraySize; ++item) - { - for (size_t level = 0; level < metadata.mipLevels; ++level, ++index) - { - if (index >= nimages) - return E_FAIL; - - if (!images[index].pixels) - return E_POINTER; - - assert(images[index].rowPitch > 0); - assert(images[index].slicePitch > 0); - - size_t ddsRowPitch, ddsSlicePitch; - hr = ComputePitch(metadata.format, images[index].width, images[index].height, ddsRowPitch, ddsSlicePitch, CP_FLAGS_NONE); - if (FAILED(hr)) - return hr; - - if ((images[index].slicePitch == ddsSlicePitch) && (ddsSlicePitch <= UINT32_MAX)) - { - #ifdef _WIN32 - if (!WriteFile(hFile.get(), images[index].pixels, static_cast(ddsSlicePitch), &bytesWritten, nullptr)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesWritten != ddsSlicePitch) - { - return E_FAIL; - } - #else - outFile.write(reinterpret_cast(images[index].pixels), static_cast(ddsSlicePitch)); - if (!outFile) - return E_FAIL; - #endif - } - else - { - const size_t rowPitch = images[index].rowPitch; - if (rowPitch < ddsRowPitch) - { - // DDS uses 1-byte alignment, so if this is happening then the input pitch isn't actually a full line of data - return E_FAIL; - } - - if (ddsRowPitch > UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - const uint8_t * __restrict sPtr = images[index].pixels; - - const size_t lines = ComputeScanlines(metadata.format, images[index].height); - for (size_t j = 0; j < lines; ++j) - { - #ifdef _WIN32 - if (!WriteFile(hFile.get(), sPtr, static_cast(ddsRowPitch), &bytesWritten, nullptr)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesWritten != ddsRowPitch) - { - return E_FAIL; - } - #else - outFile.write(reinterpret_cast(sPtr), static_cast(ddsRowPitch)); - if (!outFile) - return E_FAIL; - #endif - - sPtr += rowPitch; - } - } - } - } - } - break; - - case DDS_DIMENSION_TEXTURE3D: - { - if (metadata.arraySize != 1) - return E_FAIL; - - size_t d = metadata.depth; - - size_t index = 0; - for (size_t level = 0; level < metadata.mipLevels; ++level) - { - for (size_t slice = 0; slice < d; ++slice, ++index) - { - if (index >= nimages) - return E_FAIL; - - if (!images[index].pixels) - return E_POINTER; - - assert(images[index].rowPitch > 0); - assert(images[index].slicePitch > 0); - - size_t ddsRowPitch, ddsSlicePitch; - hr = ComputePitch(metadata.format, images[index].width, images[index].height, ddsRowPitch, ddsSlicePitch, CP_FLAGS_NONE); - if (FAILED(hr)) - return hr; - - if ((images[index].slicePitch == ddsSlicePitch) && (ddsSlicePitch <= UINT32_MAX)) - { - #ifdef _WIN32 - if (!WriteFile(hFile.get(), images[index].pixels, static_cast(ddsSlicePitch), &bytesWritten, nullptr)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesWritten != ddsSlicePitch) - { - return E_FAIL; - } - #else - outFile.write(reinterpret_cast(images[index].pixels), static_cast(ddsSlicePitch)); - if (!outFile) - return E_FAIL; - #endif - } - else - { - const size_t rowPitch = images[index].rowPitch; - if (rowPitch < ddsRowPitch) - { - // DDS uses 1-byte alignment, so if this is happening then the input pitch isn't actually a full line of data - return E_FAIL; - } - - if (ddsRowPitch > UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - const uint8_t * __restrict sPtr = images[index].pixels; - - const size_t lines = ComputeScanlines(metadata.format, images[index].height); - for (size_t j = 0; j < lines; ++j) - { - #ifdef _WIN32 - if (!WriteFile(hFile.get(), sPtr, static_cast(ddsRowPitch), &bytesWritten, nullptr)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesWritten != ddsRowPitch) - { - return E_FAIL; - } - #else - outFile.write(reinterpret_cast(sPtr), static_cast(ddsRowPitch)); - if (!outFile) - return E_FAIL; - #endif - sPtr += rowPitch; - } - } - } - - if (d > 1) - d >>= 1; - } - } - break; - - default: - return E_FAIL; - } - -#ifdef _WIN32 - delonfail.clear(); -#endif - - return S_OK; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexFlipRotate.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexFlipRotate.cpp deleted file mode 100644 index 1b26e68..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexFlipRotate.cpp +++ /dev/null @@ -1,411 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXTexFlipRotate.cpp -// -// DirectX Texture Library - Image flip/rotate operations -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//------------------------------------------------------------------------------------- - -#include "DirectXTexP.h" - -using namespace DirectX; -using namespace DirectX::Internal; -using Microsoft::WRL::ComPtr; - -namespace -{ - //------------------------------------------------------------------------------------- - // Do flip/rotate operation using WIC - //------------------------------------------------------------------------------------- - HRESULT PerformFlipRotateUsingWIC( - const Image& srcImage, - TEX_FR_FLAGS flags, - const WICPixelFormatGUID& pfGUID, - const Image& destImage) noexcept - { - if (!srcImage.pixels || !destImage.pixels) - return E_POINTER; - - assert(srcImage.format == destImage.format); - - bool iswic2 = false; - auto pWIC = GetWICFactory(iswic2); - if (!pWIC) - return E_NOINTERFACE; - - if (srcImage.rowPitch > UINT32_MAX || srcImage.slicePitch > UINT32_MAX - || destImage.rowPitch > UINT32_MAX || destImage.slicePitch > UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - ComPtr source; - HRESULT hr = pWIC->CreateBitmapFromMemory(static_cast(srcImage.width), static_cast(srcImage.height), pfGUID, - static_cast(srcImage.rowPitch), static_cast(srcImage.slicePitch), - srcImage.pixels, source.GetAddressOf()); - if (FAILED(hr)) - return hr; - - ComPtr FR; - hr = pWIC->CreateBitmapFlipRotator(FR.GetAddressOf()); - if (FAILED(hr)) - return hr; - - hr = FR->Initialize(source.Get(), static_cast(flags)); - if (FAILED(hr)) - return hr; - - WICPixelFormatGUID pfFR; - hr = FR->GetPixelFormat(&pfFR); - if (FAILED(hr)) - return hr; - - if (memcmp(&pfFR, &pfGUID, sizeof(GUID)) != 0) - { - // Flip/rotate should return the same format as the source... - return HRESULT_E_NOT_SUPPORTED; - } - - UINT nwidth, nheight; - hr = FR->GetSize(&nwidth, &nheight); - if (FAILED(hr)) - return hr; - - if (destImage.width != nwidth || destImage.height != nheight) - return E_FAIL; - - hr = FR->CopyPixels(nullptr, static_cast(destImage.rowPitch), static_cast(destImage.slicePitch), destImage.pixels); - if (FAILED(hr)) - return hr; - - return S_OK; - } - - - //------------------------------------------------------------------------------------- - // Do conversion, flip/rotate using WIC, conversion cycle - // - // For large images we have to use F16 instead of F32 to avoid exceeding the 32-bit - // memory limitations of WIC. - //------------------------------------------------------------------------------------- - HRESULT PerformFlipRotateViaF16( - const Image& srcImage, - TEX_FR_FLAGS flags, - const Image& destImage) noexcept - { - if (!srcImage.pixels || !destImage.pixels) - return E_POINTER; - - assert(srcImage.format != DXGI_FORMAT_R16G16B16A16_FLOAT); - assert(srcImage.format == destImage.format); - - ScratchImage temp; - HRESULT hr = ConvertToR16G16B16A16(srcImage, temp); - if (FAILED(hr)) - return hr; - - const Image *tsrc = temp.GetImage(0, 0, 0); - if (!tsrc) - return E_POINTER; - - ScratchImage rtemp; - hr = rtemp.Initialize2D(DXGI_FORMAT_R16G16B16A16_FLOAT, destImage.width, destImage.height, 1, 1); - if (FAILED(hr)) - return hr; - - const Image *tdest = rtemp.GetImage(0, 0, 0); - if (!tdest) - return E_POINTER; - - hr = PerformFlipRotateUsingWIC(*tsrc, flags, GUID_WICPixelFormat64bppRGBAHalf, *tdest); - if (FAILED(hr)) - return hr; - - temp.Release(); - - hr = ConvertFromR16G16B16A16(*tdest, destImage); - if (FAILED(hr)) - return hr; - - return S_OK; - } - - HRESULT PerformFlipRotateViaF32( - const Image& srcImage, - TEX_FR_FLAGS flags, - const Image& destImage) noexcept - { - if (!srcImage.pixels || !destImage.pixels) - return E_POINTER; - - assert(srcImage.format != DXGI_FORMAT_R32G32B32A32_FLOAT); - assert(srcImage.format == destImage.format); - - ScratchImage temp; - HRESULT hr = ConvertToR32G32B32A32(srcImage, temp); - if (FAILED(hr)) - return hr; - - const Image *tsrc = temp.GetImage(0, 0, 0); - if (!tsrc) - return E_POINTER; - - ScratchImage rtemp; - hr = rtemp.Initialize2D(DXGI_FORMAT_R32G32B32A32_FLOAT, destImage.width, destImage.height, 1, 1); - if (FAILED(hr)) - return hr; - - const Image *tdest = rtemp.GetImage(0, 0, 0); - if (!tdest) - return E_POINTER; - - hr = PerformFlipRotateUsingWIC(*tsrc, flags, GUID_WICPixelFormat128bppRGBAFloat, *tdest); - if (FAILED(hr)) - return hr; - - temp.Release(); - - hr = ConvertFromR32G32B32A32(*tdest, destImage); - if (FAILED(hr)) - return hr; - - return S_OK; - } -} - - -//===================================================================================== -// Entry-points -//===================================================================================== - -//------------------------------------------------------------------------------------- -// Flip/rotate image -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::FlipRotate( - const Image& srcImage, - TEX_FR_FLAGS flags, - ScratchImage& image) noexcept -{ - if (!srcImage.pixels) - return E_POINTER; - - if (!flags) - return E_INVALIDARG; - - if ((srcImage.width > UINT32_MAX) || (srcImage.height > UINT32_MAX)) - return E_INVALIDARG; - - if (IsCompressed(srcImage.format)) - { - // We don't support flip/rotate operations on compressed images - return HRESULT_E_NOT_SUPPORTED; - } - - static_assert(static_cast(TEX_FR_ROTATE0) == static_cast(WICBitmapTransformRotate0), "TEX_FR_ROTATE0 no longer matches WIC"); - static_assert(static_cast(TEX_FR_ROTATE90) == static_cast(WICBitmapTransformRotate90), "TEX_FR_ROTATE90 no longer matches WIC"); - static_assert(static_cast(TEX_FR_ROTATE180) == static_cast(WICBitmapTransformRotate180), "TEX_FR_ROTATE180 no longer matches WIC"); - static_assert(static_cast(TEX_FR_ROTATE270) == static_cast(WICBitmapTransformRotate270), "TEX_FR_ROTATE270 no longer matches WIC"); - static_assert(static_cast(TEX_FR_FLIP_HORIZONTAL) == static_cast(WICBitmapTransformFlipHorizontal), "TEX_FR_FLIP_HORIZONTAL no longer matches WIC"); - static_assert(static_cast(TEX_FR_FLIP_VERTICAL) == static_cast(WICBitmapTransformFlipVertical), "TEX_FR_FLIP_VERTICAL no longer matches WIC"); - - // Only supports 90, 180, 270, or no rotation flags... not a combination of rotation flags - const int rotateMode = static_cast(flags & (TEX_FR_ROTATE0 | TEX_FR_ROTATE90 | TEX_FR_ROTATE180 | TEX_FR_ROTATE270)); - - switch (rotateMode) - { - case 0: - case TEX_FR_ROTATE90: - case TEX_FR_ROTATE180: - case TEX_FR_ROTATE270: - break; - - default: - return E_INVALIDARG; - } - - size_t nwidth = srcImage.width; - size_t nheight = srcImage.height; - - if ((rotateMode == TEX_FR_ROTATE90) || (rotateMode == TEX_FR_ROTATE270)) - { - nwidth = srcImage.height; - nheight = srcImage.width; - } - - HRESULT hr = image.Initialize2D(srcImage.format, nwidth, nheight, 1, 1); - if (FAILED(hr)) - return hr; - - const Image *rimage = image.GetImage(0, 0, 0); - if (!rimage) - { - image.Release(); - return E_POINTER; - } - - WICPixelFormatGUID pfGUID; - if (DXGIToWIC(srcImage.format, pfGUID)) - { - // Case 1: Source format is supported by Windows Imaging Component - hr = PerformFlipRotateUsingWIC(srcImage, flags, pfGUID, *rimage); - } - else - { - // Case 2: Source format is not supported by WIC, so we have to convert, flip/rotate, and convert back - const uint64_t expandedSize = uint64_t(srcImage.width) * uint64_t(srcImage.height) * sizeof(float) * 4; - if (expandedSize > UINT32_MAX) - { - // Image is too large for float32, so have to use float16 instead - hr = PerformFlipRotateViaF16(srcImage, flags, *rimage); - } - else - { - hr = PerformFlipRotateViaF32(srcImage, flags, *rimage); - } - } - - if (FAILED(hr)) - { - image.Release(); - return hr; - } - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -// Flip/rotate image (complex) -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::FlipRotate( - const Image* srcImages, - size_t nimages, - const TexMetadata& metadata, - TEX_FR_FLAGS flags, - ScratchImage& result) noexcept -{ - if (!srcImages || !nimages) - return E_INVALIDARG; - - if (IsCompressed(metadata.format)) - { - // We don't support flip/rotate operations on compressed images - return HRESULT_E_NOT_SUPPORTED; - } - - static_assert(static_cast(TEX_FR_ROTATE0) == static_cast(WICBitmapTransformRotate0), "TEX_FR_ROTATE0 no longer matches WIC"); - static_assert(static_cast(TEX_FR_ROTATE90) == static_cast(WICBitmapTransformRotate90), "TEX_FR_ROTATE90 no longer matches WIC"); - static_assert(static_cast(TEX_FR_ROTATE180) == static_cast(WICBitmapTransformRotate180), "TEX_FR_ROTATE180 no longer matches WIC"); - static_assert(static_cast(TEX_FR_ROTATE270) == static_cast(WICBitmapTransformRotate270), "TEX_FR_ROTATE270 no longer matches WIC"); - static_assert(static_cast(TEX_FR_FLIP_HORIZONTAL) == static_cast(WICBitmapTransformFlipHorizontal), "TEX_FR_FLIP_HORIZONTAL no longer matches WIC"); - static_assert(static_cast(TEX_FR_FLIP_VERTICAL) == static_cast(WICBitmapTransformFlipVertical), "TEX_FR_FLIP_VERTICAL no longer matches WIC"); - - // Only supports 90, 180, 270, or no rotation flags... not a combination of rotation flags - const int rotateMode = static_cast(flags & (TEX_FR_ROTATE0 | TEX_FR_ROTATE90 | TEX_FR_ROTATE180 | TEX_FR_ROTATE270)); - - switch (rotateMode) - { - case 0: - case TEX_FR_ROTATE90: - case TEX_FR_ROTATE180: - case TEX_FR_ROTATE270: - break; - - default: - return E_INVALIDARG; - } - - TexMetadata mdata2 = metadata; - - bool flipwh = false; - if ((rotateMode == TEX_FR_ROTATE90) || (rotateMode == TEX_FR_ROTATE270)) - { - flipwh = true; - mdata2.width = metadata.height; - mdata2.height = metadata.width; - } - - HRESULT hr = result.Initialize(mdata2); - if (FAILED(hr)) - return hr; - - if (nimages != result.GetImageCount()) - { - result.Release(); - return E_FAIL; - } - - const Image* dest = result.GetImages(); - if (!dest) - { - result.Release(); - return E_POINTER; - } - - WICPixelFormatGUID pfGUID; - const bool wicpf = DXGIToWIC(metadata.format, pfGUID); - - for (size_t index = 0; index < nimages; ++index) - { - const Image& src = srcImages[index]; - if (src.format != metadata.format) - { - result.Release(); - return E_FAIL; - } - - if ((src.width > UINT32_MAX) || (src.height > UINT32_MAX)) - return E_FAIL; - - const Image& dst = dest[index]; - assert(dst.format == metadata.format); - - if (flipwh) - { - if (src.width != dst.height || src.height != dst.width) - { - result.Release(); - return E_FAIL; - } - } - else - { - if (src.width != dst.width || src.height != dst.height) - { - result.Release(); - return E_FAIL; - } - } - - if (wicpf) - { - // Case 1: Source format is supported by Windows Imaging Component - hr = PerformFlipRotateUsingWIC(src, flags, pfGUID, dst); - } - else - { - // Case 2: Source format is not supported by WIC, so we have to convert, flip/rotate, and convert back - const uint64_t expandedSize = uint64_t(src.width) * uint64_t(src.height) * sizeof(float) * 4; - if (expandedSize > UINT32_MAX) - { - // Image is too large for float32, so have to use float16 instead - hr = PerformFlipRotateViaF16(src, flags, dst); - } - else - { - hr = PerformFlipRotateViaF32(src, flags, dst); - } - } - - if (FAILED(hr)) - { - result.Release(); - return hr; - } - } - - return S_OK; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexHDR.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexHDR.cpp deleted file mode 100644 index d0a41a7..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexHDR.cpp +++ /dev/null @@ -1,1300 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXTexHDR.cpp -// -// DirectX Texture Library - Radiance HDR (RGBE) file format reader/writer -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//------------------------------------------------------------------------------------- - -#include "DirectXTexP.h" -// -// In theory HDR (RGBE) Radiance files can have any of the following data orientations -// -// +X width +Y height -// +X width -Y height -// -X width +Y height -// -X width -Y height -// +Y height +X width -// -Y height +X width -// +Y height -X width -// -Y height -X width -// -// All HDR files we've encountered are always written as "-Y height +X width", so -// we support only that one as that's what other Radiance parsing code does as well. -// - -//Uncomment to disable the use of adapative RLE encoding when writing an HDR. Used for testing only. -//#define DISABLE_COMPRESS - -//Uncomment to use "old colors" standard RLE encoding when writing an HDR. Used for testing only. -//#define WRITE_OLD_COLORS - -using namespace DirectX; - -#ifndef _WIN32 -#include - -#define strncpy_s strncpy -#define sscanf_s sscanf -#endif - -namespace -{ - const char g_Signature[] = "#?RADIANCE"; - // This is the official header signature for the .HDR (RGBE) file format. - - const char g_AltSignature[] = "#?RGBE"; - // This is a common variant header signature that is otherwise exactly the same format. - - const char g_Format[] = "FORMAT="; - const char g_Exposure[] = "EXPOSURE="; - - const char g_sRGBE[] = "32-bit_rle_rgbe"; - const char g_sXYZE[] = "32-bit_rle_xyze"; - - const char g_Header[] = - "#?RADIANCE\n"\ - "FORMAT=32-bit_rle_rgbe\n"\ - "\n"\ - "-Y %u +X %u\n"; - - inline size_t FindEOL(const char* str, size_t maxlen) noexcept - { - size_t pos = 0; - - while (pos < maxlen) - { - if (str[pos] == '\n') - return pos; - else if (str[pos] == '\0') - return size_t(-1); - ++pos; - } - - return 0; - } - -#ifndef _WIN32 - template - inline int sprintf_s(char(&buffer)[sizeOfBuffer], const char* format, ...) - { - // This is adapter code. It is not a full implementation of sprintf_s! - va_list ap; - va_start(ap, format); - int result = vsprintf(buffer, format, ap); - va_end(ap); - return result; - } -#endif - - //------------------------------------------------------------------------------------- - // Decodes HDR header - //------------------------------------------------------------------------------------- - HRESULT DecodeHDRHeader( - _In_reads_bytes_(size) const void* pSource, - size_t size, - _Out_ TexMetadata& metadata, - size_t& offset, - float& exposure) noexcept - { - if (!pSource) - return E_INVALIDARG; - - memset(&metadata, 0, sizeof(TexMetadata)); - - exposure = 1.f; - - if (size < sizeof(g_Signature)) - { - return HRESULT_E_INVALID_DATA; - } - - // Verify magic signature - if (memcmp(pSource, g_Signature, sizeof(g_Signature) - 1) != 0 - && memcmp(pSource, g_AltSignature, sizeof(g_AltSignature) - 1) != 0) - { - return E_FAIL; - } - - // Process first part of header - bool formatFound = false; - auto info = static_cast(pSource); - while (size > 0) - { - if (*info == '\n') - { - ++info; - --size; - break; - } - - constexpr size_t formatLen = sizeof(g_Format) - 1; - constexpr size_t exposureLen = sizeof(g_Exposure) - 1; - if ((size > formatLen) && memcmp(info, g_Format, formatLen) == 0) - { - info += formatLen; - size -= formatLen; - - // Trim whitespace - while (*info == ' ' || *info == '\t') - { - if (--size == 0) - return E_FAIL; - ++info; - } - - static_assert(sizeof(g_sRGBE) == sizeof(g_sXYZE), "Format strings length mismatch"); - - constexpr size_t encodingLen = sizeof(g_sRGBE) - 1; - - if (size < encodingLen) - { - return E_FAIL; - } - - if (memcmp(info, g_sRGBE, encodingLen) != 0 && memcmp(info, g_sXYZE, encodingLen) != 0) - { - return HRESULT_E_NOT_SUPPORTED; - } - - formatFound = true; - - const size_t len = FindEOL(info, size); - if (len == size_t(-1)) - { - return E_FAIL; - } - - info += len + 1; - size -= len + 1; - } - else if ((size > exposureLen) && memcmp(info, g_Exposure, exposureLen) == 0) - { - info += exposureLen; - size -= exposureLen; - - // Trim whitespace - while (*info == ' ' || *info == '\t') - { - if (--size == 0) - return E_FAIL; - ++info; - } - - const size_t len = FindEOL(info, size); - if (len == size_t(-1) - || len < 1) - { - return E_FAIL; - } - - char buff[32] = {}; - strncpy_s(buff, info, std::min(31, len)); - - auto newExposure = static_cast(atof(buff)); - if ((newExposure >= 1e-12f) && (newExposure <= 1e12f)) - { - // Note that we ignore strange exposure values (like EXPOSURE=0) - exposure *= newExposure; - } - - info += len + 1; - size -= len + 1; - } - else - { - const size_t len = FindEOL(info, size); - if (len == size_t(-1)) - { - return E_FAIL; - } - - info += len + 1; - size -= len + 1; - } - } - - if (!formatFound) - { - return E_FAIL; - } - - // Get orientation - char orientation[256] = {}; - - const size_t len = FindEOL(info, std::min(sizeof(orientation), size - 1)); - if (len == size_t(-1) - || len <= 2) - { - return E_FAIL; - } - - strncpy_s(orientation, info, len); - - if (orientation[0] != '-' && orientation[1] != 'Y') - { - // We only support the -Y +X orientation (see top of file) - return (static_cast(((orientation[0] == '+' || orientation[0] == '-') && (orientation[1] == 'X' || orientation[1] == 'Y')))) - ? HRESULT_E_NOT_SUPPORTED : HRESULT_E_INVALID_DATA; - } - - uint32_t height = 0; - if (sscanf_s(orientation + 2, "%u", &height) != 1) - { - return E_FAIL; - } - - const char* ptr = orientation + 2; - while (*ptr != 0 && *ptr != '-' && *ptr != '+') - ++ptr; - - if (*ptr == 0) - { - return E_FAIL; - } - else if (*ptr != '+') - { - // We only support the -Y +X orientation (see top of file) - return HRESULT_E_NOT_SUPPORTED; - } - - ++ptr; - if (*ptr == 0 || (*ptr != 'X' && *ptr != 'Y')) - { - return E_FAIL; - } - else if (*ptr != 'X') - { - // We only support the -Y +X orientation (see top of file) - return HRESULT_E_NOT_SUPPORTED; - } - - ++ptr; - uint32_t width; - if (sscanf_s(ptr, "%u", &width) != 1) - { - return E_FAIL; - } - - info += len + 1; - size -= len + 1; - - if (!width || !height) - { - return HRESULT_E_INVALID_DATA; - } - - if (size == 0) - { - return E_FAIL; - } - - offset = size_t(info - static_cast(pSource)); - - metadata.width = width; - metadata.height = height; - metadata.depth = metadata.arraySize = metadata.mipLevels = 1; - metadata.format = DXGI_FORMAT_R32G32B32A32_FLOAT; - metadata.dimension = TEX_DIMENSION_TEXTURE2D; - metadata.SetAlphaMode(TEX_ALPHA_MODE_OPAQUE); - - return S_OK; - } - - //------------------------------------------------------------------------------------- - // FloatToRGBE - //------------------------------------------------------------------------------------- - inline void FloatToRGBE(_Out_writes_(width*4) uint8_t* pDestination, _In_reads_(width*fpp) const float* pSource, size_t width, _In_range_(3, 4) int fpp) noexcept - { - auto ePtr = pSource + width * size_t(fpp); - - for (size_t j = 0; j < width; ++j) - { - if (pSource + 2 >= ePtr) break; - const float r = pSource[0] >= 0.f ? pSource[0] : 0.f; - const float g = pSource[1] >= 0.f ? pSource[1] : 0.f; - const float b = pSource[2] >= 0.f ? pSource[2] : 0.f; - pSource += fpp; - - const float max_xy = (r > g) ? r : g; - float max_xyz = (max_xy > b) ? max_xy : b; - - if (max_xyz > 1e-32f) - { - int e; - max_xyz = frexpf(max_xyz, &e) * 256.f / max_xyz; - e += 128; - - const uint8_t red = uint8_t(r * max_xyz); - const uint8_t green = uint8_t(g * max_xyz); - const uint8_t blue = uint8_t(b * max_xyz); - - pDestination[0] = red; - pDestination[1] = green; - pDestination[2] = blue; - pDestination[3] = (red || green || blue) ? uint8_t(e & 0xff) : 0u; - } - else - { - pDestination[0] = pDestination[1] = pDestination[2] = pDestination[3] = 0; - } - - pDestination += 4; - } - } - - //------------------------------------------------------------------------------------- - // HalfToRGBE - //------------------------------------------------------------------------------------- - inline void HalfToRGBE(_Out_writes_(width * 4) uint8_t* pDestination, _In_reads_(width* fpp) const uint16_t* pSource, size_t width, _In_range_(3, 4) int fpp) noexcept - { - auto ePtr = pSource + width * size_t(fpp); - - for (size_t j = 0; j < width; ++j) - { - if (pSource + 2 >= ePtr) break; - float r = PackedVector::XMConvertHalfToFloat(pSource[0]); r = (r >= 0.f) ? r : 0.f; - float g = PackedVector::XMConvertHalfToFloat(pSource[1]); g = (g >= 0.f) ? g : 0.f; - float b = PackedVector::XMConvertHalfToFloat(pSource[2]); b = (b >= 0.f) ? b : 0.f; - pSource += fpp; - - const float max_xy = (r > g) ? r : g; - float max_xyz = (max_xy > b) ? max_xy : b; - - if (max_xyz > 1e-32f) - { - int e; - max_xyz = frexpf(max_xyz, &e) * 256.f / max_xyz; - e += 128; - - const uint8_t red = uint8_t(r * max_xyz); - const uint8_t green = uint8_t(g * max_xyz); - const uint8_t blue = uint8_t(b * max_xyz); - - pDestination[0] = red; - pDestination[1] = green; - pDestination[2] = blue; - pDestination[3] = (red || green || blue) ? uint8_t(e & 0xff) : 0u; - } - else - { - pDestination[0] = pDestination[1] = pDestination[2] = pDestination[3] = 0; - } - - pDestination += 4; - } - } - - //------------------------------------------------------------------------------------- - // Encode using Adapative RLE - //------------------------------------------------------------------------------------- - _Success_(return > 0) - size_t EncodeRLE(_Out_writes_(width * 4) uint8_t* enc, _In_reads_(width * 4) const uint8_t* rgbe, size_t rowPitch, size_t width) noexcept - { - if (width < 8 || width > INT16_MAX) - { - // Don't try to compress too narrow or too wide scan-lines - return 0; - } - - #ifdef WRITE_OLD_COLORS - size_t encSize = 0; - - const uint8_t* scanPtr = rgbe; - for (size_t pixelCount = 0; pixelCount < width;) - { - size_t spanLen = 1; - auto spanPtr = reinterpret_cast(scanPtr); - while (pixelCount + spanLen < width && spanLen < INT16_MAX) - { - if (spanPtr[spanLen] == *spanPtr) - { - ++spanLen; - } - else - break; - } - - if (spanLen > 2) - { - if (scanPtr[0] == 1 && scanPtr[1] == 1 && scanPtr[2] == 1) - { - return 0; - } - - if (encSize + 8 > rowPitch) - return 0; - - auto rleLen = static_cast(std::min(spanLen - 1, 255)); - - enc[0] = scanPtr[0]; - enc[1] = scanPtr[1]; - enc[2] = scanPtr[2]; - enc[3] = scanPtr[3]; - enc[4] = 1; - enc[5] = 1; - enc[6] = 1; - enc[7] = rleLen; - enc += 8; - encSize += 8; - - size_t remaining = spanLen - 1 - rleLen; - - if (remaining > 0) - { - rleLen = static_cast(remaining >> 8); - - if (rleLen > 0) - { - if (encSize + 4 > rowPitch) - return 0; - - enc[0] = 1; - enc[1] = 1; - enc[2] = 1; - enc[3] = rleLen; - enc += 4; - encSize += 4; - - remaining -= (rleLen << 8); - } - - while (remaining > 0) - { - if (encSize + 4 > rowPitch) - return 0; - - enc[0] = scanPtr[0]; - enc[1] = scanPtr[1]; - enc[2] = scanPtr[2]; - enc[3] = scanPtr[3]; - enc += 4; - encSize += 4; - - --remaining; - } - } - - scanPtr += spanLen * 4; - pixelCount += spanLen; - } - else if (scanPtr[0] == 1 && scanPtr[1] == 1 && scanPtr[2] == 1) - { - return 0; - } - else - { - if (encSize + 4 > rowPitch) - return 0; - - enc[0] = scanPtr[0]; - enc[1] = scanPtr[1]; - enc[2] = scanPtr[2]; - enc[3] = scanPtr[3]; - enc += 4; - encSize += 4; - ++pixelCount; - scanPtr += 4; - } - } - - return encSize; - #else - enc[0] = 2; - enc[1] = 2; - enc[2] = uint8_t(width >> 8); - enc[3] = uint8_t(width & 0xff); - enc += 4; - size_t encSize = 4; - - uint8_t scan[128] = {}; - - for (int channel = 0; channel < 4; ++channel) - { - const uint8_t* spanPtr = rgbe + channel; - for (size_t pixelCount = 0; pixelCount < width;) - { - uint8_t spanLen = 1; - while (pixelCount + spanLen < width && spanLen < 127) - { - if (spanPtr[spanLen * 4] == *spanPtr) - { - ++spanLen; - } - else - break; - } - - if (spanLen > 1) - { - if (encSize + 2 > rowPitch) - return 0; - - enc[0] = 128u + spanLen; - enc[1] = *spanPtr; - enc += 2; - encSize += 2; - spanPtr += size_t(spanLen) * 4; - pixelCount += spanLen; - } - else - { - uint8_t runLen = 1; - scan[0] = *spanPtr; - while (pixelCount + runLen < width && runLen < 127) - { - if (spanPtr[(runLen - 1) * 4] != spanPtr[runLen * 4]) - { - scan[runLen] = spanPtr[runLen * 4]; - runLen++; - } - else - break; - } - - if (encSize + runLen + 1 > rowPitch) - return 0; - - *enc++ = runLen; - memcpy(enc, scan, runLen); - enc += runLen; - encSize += size_t(runLen) + 1; - spanPtr += size_t(runLen) * 4; - pixelCount += runLen; - } - } - } - - return encSize; - #endif - } -} - - -//===================================================================================== -// Entry-points -//===================================================================================== - -//------------------------------------------------------------------------------------- -// Obtain metadata from HDR file in memory/on disk -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::GetMetadataFromHDRMemory(const void* pSource, size_t size, TexMetadata& metadata) noexcept -{ - if (!pSource || size == 0) - return E_INVALIDARG; - - size_t offset; - float exposure; - return DecodeHDRHeader(pSource, size, metadata, offset, exposure); -} - -_Use_decl_annotations_ -HRESULT DirectX::GetMetadataFromHDRFile(const wchar_t* szFile, TexMetadata& metadata) noexcept -{ - if (!szFile) - return E_INVALIDARG; - -#ifdef _WIN32 -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(szFile, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, - FILE_FLAG_SEQUENTIAL_SCAN, nullptr))); -#endif - if (!hFile) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - // Get the file size - FILE_STANDARD_INFO fileInfo; - if (!GetFileInformationByHandleEx(hFile.get(), FileStandardInfo, &fileInfo, sizeof(fileInfo))) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - // File is too big for 32-bit allocation, so reject read (4 GB should be plenty large enough for a valid HDR file) - if (fileInfo.EndOfFile.HighPart > 0) - { - return HRESULT_E_FILE_TOO_LARGE; - } - - const size_t len = fileInfo.EndOfFile.LowPart; -#else // !WIN32 - std::ifstream inFile(std::filesystem::path(szFile), std::ios::in | std::ios::binary | std::ios::ate); - if (!inFile) - return E_FAIL; - - std::streampos fileLen = inFile.tellg(); - if (!inFile) - return E_FAIL; - - if (fileLen > UINT32_MAX) - return HRESULT_E_FILE_TOO_LARGE; - - inFile.seekg(0, std::ios::beg); - if (!inFile) - return E_FAIL; - - const size_t len = fileLen; -#endif - - // Need at least enough data to fill the standard header to be a valid HDR - if (len < sizeof(g_Signature)) - { - return E_FAIL; - } - - // Read the first part of the file to find the header - uint8_t header[8192] = {}; - -#ifdef _WIN32 - DWORD bytesRead = 0; - if (!ReadFile(hFile.get(), header, std::min(sizeof(header), fileInfo.EndOfFile.LowPart), &bytesRead, nullptr)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - auto const headerLen = static_cast(bytesRead); -#else - auto const headerLen = std::min(sizeof(header), len); - - inFile.read(reinterpret_cast(header), headerLen); - if (!inFile) - return E_FAIL; -#endif - - size_t offset; - float exposure; - return DecodeHDRHeader(header, headerLen, metadata, offset, exposure); -} - - -//------------------------------------------------------------------------------------- -// Load a HDR file in memory -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::LoadFromHDRMemory(const void* pSource, size_t size, TexMetadata* metadata, ScratchImage& image) noexcept -{ - if (!pSource || size == 0) - return E_INVALIDARG; - - image.Release(); - - size_t offset; - float exposure; - TexMetadata mdata; - HRESULT hr = DecodeHDRHeader(pSource, size, mdata, offset, exposure); - if (FAILED(hr)) - return hr; - - if (offset > size) - return E_FAIL; - - const size_t remaining = size - offset; - if (remaining == 0) - return E_FAIL; - - hr = image.Initialize2D(mdata.format, mdata.width, mdata.height, 1, 1); - if (FAILED(hr)) - return hr; - - // Copy pixels - auto sourcePtr = static_cast(pSource) + offset; - - size_t pixelLen = remaining; - - const Image* img = image.GetImage(0, 0, 0); - if (!img) - { - image.Release(); - return E_POINTER; - } - - auto destPtr = img->pixels; - -#ifdef _DEBUG - memset(img->pixels, 0xFF, img->rowPitch * img->height); -#endif - - for (size_t scan = 0; scan < mdata.height; ++scan) - { - if (pixelLen < 4) - { - image.Release(); - return E_FAIL; - } - - uint8_t inColor[4]; - memcpy(inColor, sourcePtr, 4); - sourcePtr += 4; - pixelLen -= 4; - - auto scanLine = reinterpret_cast(destPtr); - - if (inColor[0] == 2 && inColor[1] == 2 && inColor[2] < 128) - { - // Adaptive Run Length Encoding (RLE) - if (size_t((size_t(inColor[2]) << 8) + inColor[3]) != mdata.width) - { - image.Release(); - return E_FAIL; - } - - for (int channel = 0; channel < 4; ++channel) - { - auto pixelLoc = scanLine + channel; - for (size_t pixelCount = 0; pixelCount < mdata.width;) - { - if (pixelLen < 2) - { - image.Release(); - return E_FAIL; - } - - assert(sourcePtr < (reinterpret_cast(pSource) + size)); - - uint8_t runLen = *sourcePtr; - if (runLen > 128) - { - runLen &= 127; - if (pixelCount + runLen > mdata.width) - { - image.Release(); - return E_FAIL; - } - - auto val = static_cast(sourcePtr[1]); - for (uint8_t j = 0; j < runLen; ++j) - { - *pixelLoc = val; - pixelLoc += 4; - } - pixelCount += runLen; - sourcePtr += 2; - pixelLen -= 2; - } - else if ((size < size_t(runLen) + 1) || ((pixelCount + size_t(runLen)) > mdata.width)) - { - image.Release(); - return E_FAIL; - } - else - { - ++sourcePtr; - for (uint8_t j = 0; j < runLen; ++j) - { - auto val = static_cast(*sourcePtr++); - *pixelLoc = val; - pixelLoc += 4; - } - pixelCount += runLen; - pixelLen -= size_t(runLen) + 1; - } - } - } - } - else - { - auto pixelLoc = scanLine; - - float prevColor[4]; - prevColor[0] = inColor[0]; - prevColor[1] = inColor[1]; - prevColor[2] = inColor[2]; - prevColor[3] = inColor[3]; - - int bitShift = 0; - for (size_t pixelCount = 0; pixelCount < mdata.width;) - { - if (inColor[0] == 1 && inColor[1] == 1 && inColor[2] == 1) - { - if (bitShift > 24) - { - image.Release(); - return E_FAIL; - } - - // "Standard" Run Length Encoding - const size_t spanLen = size_t(inColor[3]) << bitShift; - if (spanLen + pixelCount > mdata.width) - { - image.Release(); - return E_FAIL; - } - - for (size_t j = 0; j < spanLen; ++j) - { - pixelLoc[0] = prevColor[0]; - pixelLoc[1] = prevColor[1]; - pixelLoc[2] = prevColor[2]; - pixelLoc[3] = prevColor[3]; - pixelLoc += 4; - } - pixelCount += spanLen; - bitShift += 8; - } - else - { - // Uncompressed - pixelLoc[0] = prevColor[0] = inColor[0]; - pixelLoc[1] = prevColor[1] = inColor[1]; - pixelLoc[2] = prevColor[2] = inColor[2]; - pixelLoc[3] = prevColor[3] = inColor[3]; - bitShift = 0; - ++pixelCount; - pixelLoc += 4; - } - - if (pixelCount >= mdata.width) - break; - - if (pixelLen < 4) - { - image.Release(); - return E_FAIL; - } - - memcpy(inColor, sourcePtr, 4); - sourcePtr += 4; - pixelLen -= 4; - } - } - - destPtr += img->rowPitch; - } - - // Transform values - { - auto fdata = reinterpret_cast(image.GetPixels()); - - for (size_t j = 0; j < image.GetPixelsSize(); j += 16) - { - auto const exponent = static_cast(fdata[3]); - fdata[0] = 1.0f / exposure*ldexpf((fdata[0] + 0.5f), exponent - (128 + 8)); - fdata[1] = 1.0f / exposure*ldexpf((fdata[1] + 0.5f), exponent - (128 + 8)); - fdata[2] = 1.0f / exposure*ldexpf((fdata[2] + 0.5f), exponent - (128 + 8)); - fdata[3] = 1.f; - - fdata += 4; - } - } - - if (metadata) - memcpy(metadata, &mdata, sizeof(TexMetadata)); - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -// Load a HDR file from disk -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::LoadFromHDRFile(const wchar_t* szFile, TexMetadata* metadata, ScratchImage& image) noexcept -{ - if (!szFile) - return E_INVALIDARG; - - image.Release(); - -#ifdef _WIN32 -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(szFile, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, - FILE_FLAG_SEQUENTIAL_SCAN, nullptr))); -#endif - if (!hFile) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - // Get the file size - FILE_STANDARD_INFO fileInfo; - if (!GetFileInformationByHandleEx(hFile.get(), FileStandardInfo, &fileInfo, sizeof(fileInfo))) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - // File is too big for 32-bit allocation, so reject read (4 GB should be plenty large enough for a valid HDR file) - if (fileInfo.EndOfFile.HighPart > 0) - { - return HRESULT_E_FILE_TOO_LARGE; - } - - const size_t len = fileInfo.EndOfFile.LowPart; -#else // !WIN32 - std::ifstream inFile(std::filesystem::path(szFile), std::ios::in | std::ios::binary | std::ios::ate); - if (!inFile) - return E_FAIL; - - std::streampos fileLen = inFile.tellg(); - if (!inFile) - return E_FAIL; - - if (fileLen > UINT32_MAX) - return HRESULT_E_FILE_TOO_LARGE; - - inFile.seekg(0, std::ios::beg); - if (!inFile) - return E_FAIL; - - const size_t len = fileLen; -#endif - - // Need at least enough data to fill the header to be a valid HDR - if (len < sizeof(g_Signature)) - { - return E_FAIL; - } - - // Read file - std::unique_ptr temp(new (std::nothrow) uint8_t[len]); - if (!temp) - { - return E_OUTOFMEMORY; - } - -#ifdef _WIN32 - DWORD bytesRead = 0; - if (!ReadFile(hFile.get(), temp.get(), fileInfo.EndOfFile.LowPart, &bytesRead, nullptr)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesRead != fileInfo.EndOfFile.LowPart) - { - return E_FAIL; - } -#else - inFile.read(reinterpret_cast(temp.get()), len); - if (!inFile) - return E_FAIL; -#endif - - return LoadFromHDRMemory(temp.get(), len, metadata, image); -} - - -//------------------------------------------------------------------------------------- -// Save a HDR file to memory -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::SaveToHDRMemory(const Image& image, Blob& blob) noexcept -{ - if (!image.pixels) - return E_POINTER; - - if (image.width > INT16_MAX || image.height > INT16_MAX) - { - // Images larger than this can't be RLE encoded. They are technically allowed as - // uncompresssed, but we just don't support them. - return HRESULT_E_NOT_SUPPORTED; - } - - int fpp; - switch (image.format) - { - case DXGI_FORMAT_R32G32B32A32_FLOAT: - case DXGI_FORMAT_R16G16B16A16_FLOAT: - fpp = 4; - break; - case DXGI_FORMAT_R32G32B32_FLOAT: - fpp = 3; - break; - - default: - return HRESULT_E_NOT_SUPPORTED; - } - - blob.Release(); - - char header[256] = {}; - sprintf_s(header, g_Header, image.height, image.width); - - auto headerLen = static_cast(strlen(header)); - - size_t rowPitch = image.width * 4; - const size_t slicePitch = image.height * rowPitch; - - HRESULT hr = blob.Initialize(headerLen + slicePitch); - if (FAILED(hr)) - return hr; - - // Copy header - auto dPtr = static_cast(blob.GetBufferPointer()); - assert(dPtr != nullptr); - memcpy(dPtr, header, headerLen); - dPtr += headerLen; - -#ifdef DISABLE_COMPRESS - // Uncompressed write - auto sPtr = reinterpret_cast(image.pixels); - for (size_t scan = 0; scan < image.height; ++scan) - { - FloatToRGBE(dPtr, reinterpret_cast(sPtr), image.width, fpp); - dPtr += rowPitch; - sPtr += image.rowPitch; - } -#else - std::unique_ptr temp(new (std::nothrow) uint8_t[rowPitch * 2]); - if (!temp) - { - blob.Release(); - return E_OUTOFMEMORY; - } - - auto rgbe = temp.get(); - auto enc = temp.get() + rowPitch; - - const uint8_t* sPtr = image.pixels; - for (size_t scan = 0; scan < image.height; ++scan) - { - if (image.format == DXGI_FORMAT_R32G32B32A32_FLOAT || image.format == DXGI_FORMAT_R32G32B32_FLOAT) - { - FloatToRGBE(rgbe, reinterpret_cast(sPtr), image.width, fpp); - } - else if (image.format == DXGI_FORMAT_R16G16B16A16_FLOAT) - { - HalfToRGBE(rgbe, reinterpret_cast(sPtr), image.width, fpp); - } - sPtr += image.rowPitch; - - size_t encSize = EncodeRLE(enc, rgbe, rowPitch, image.width); - if (encSize > 0) - { - memcpy(dPtr, enc, encSize); - dPtr += encSize; - } - else - { - memcpy(dPtr, rgbe, rowPitch); - dPtr += rowPitch; - } - } -#endif - - hr = blob.Trim(size_t(dPtr - static_cast(blob.GetBufferPointer()))); - if (FAILED(hr)) - { - blob.Release(); - return hr; - } - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -// Save a HDR file to disk -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::SaveToHDRFile(const Image& image, const wchar_t* szFile) noexcept -{ - if (!szFile) - return E_INVALIDARG; - - if (!image.pixels) - return E_POINTER; - - if (image.width > INT16_MAX || image.height > INT16_MAX) - { - // Images larger than this can't be RLE encoded. They are technically allowed as - // uncompresssed, but we just don't support them. - return HRESULT_E_NOT_SUPPORTED; - } - - int fpp; - switch (image.format) - { - case DXGI_FORMAT_R32G32B32A32_FLOAT: - case DXGI_FORMAT_R16G16B16A16_FLOAT: - fpp = 4; - break; - case DXGI_FORMAT_R32G32B32_FLOAT: - fpp = 3; - break; - - default: - return HRESULT_E_NOT_SUPPORTED; - } - - // Create file and write header -#ifdef _WIN32 -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFile, - GENERIC_WRITE, 0, CREATE_ALWAYS, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(szFile, - GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr))); -#endif - if (!hFile) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - auto_delete_file delonfail(hFile.get()); -#else // !WIN32 - std::ofstream outFile(std::filesystem::path(szFile), std::ios::out | std::ios::binary | std::ios::trunc); - if (!outFile) - return E_FAIL; -#endif - - const uint64_t pitch = uint64_t(image.width) * 4u; - const uint64_t slicePitch = uint64_t(image.height) * pitch; - - if (pitch > UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - size_t rowPitch = static_cast(pitch); - - if (slicePitch < 65535) - { - // For small images, it is better to create an in-memory file and write it out - Blob blob; - - HRESULT hr = SaveToHDRMemory(image, blob); - if (FAILED(hr)) - return hr; - - // Write blob - #ifdef _WIN32 - auto const bytesToWrite = static_cast(blob.GetBufferSize()); - DWORD bytesWritten; - if (!WriteFile(hFile.get(), blob.GetBufferPointer(), bytesToWrite, &bytesWritten, nullptr)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesWritten != bytesToWrite) - { - return E_FAIL; - } - #else - outFile.write(reinterpret_cast(blob.GetBufferPointer()), - static_cast(blob.GetBufferSize())); - - if (!outFile) - return E_FAIL; - #endif - } - else - { - // Otherwise, write the image one scanline at a time... - std::unique_ptr temp(new (std::nothrow) uint8_t[rowPitch * 2]); - if (!temp) - return E_OUTOFMEMORY; - - auto rgbe = temp.get(); - - // Write header - char header[256] = {}; - sprintf_s(header, g_Header, image.height, image.width); - - #ifdef _WIN32 - auto const headerLen = static_cast(strlen(header)); - - DWORD bytesWritten; - if (!WriteFile(hFile.get(), header, headerLen, &bytesWritten, nullptr)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesWritten != headerLen) - return E_FAIL; - #else - outFile.write(reinterpret_cast(header), static_cast(strlen(header))); - if (!outFile) - return E_FAIL; - #endif - - #ifdef DISABLE_COMPRESS - // Uncompressed write - auto sPtr = reinterpret_cast(image.pixels); - for (size_t scan = 0; scan < image.height; ++scan) - { - FloatToRGBE(rgbe, reinterpret_cast(sPtr), image.width, fpp); - sPtr += image.rowPitch; - - #ifdef _WIN32 - if (!WriteFile(hFile.get(), rgbe, static_cast(rowPitch), &bytesWritten, nullptr)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesWritten != rowPitch) - return E_FAIL; - #else - outFile.write(reinterpret_cast(rgbe), static_cast(rowPitch)); - if (!outFile) - return E_FAIL; - #endif - - } - #else - auto enc = temp.get() + rowPitch; - - const uint8_t* sPtr = image.pixels; - for (size_t scan = 0; scan < image.height; ++scan) - { - if (image.format == DXGI_FORMAT_R32G32B32A32_FLOAT || image.format == DXGI_FORMAT_R32G32B32_FLOAT) - { - FloatToRGBE(rgbe, reinterpret_cast(sPtr), image.width, fpp); - } - else if (image.format == DXGI_FORMAT_R16G16B16A16_FLOAT) - { - HalfToRGBE(rgbe, reinterpret_cast(sPtr), image.width, fpp); - } - sPtr += image.rowPitch; - - const size_t encSize = EncodeRLE(enc, rgbe, rowPitch, image.width); - if (encSize > 0) - { - if (encSize > UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - #ifdef _WIN32 - if (!WriteFile(hFile.get(), enc, static_cast(encSize), &bytesWritten, nullptr)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesWritten != encSize) - return E_FAIL; - #else - outFile.write(reinterpret_cast(enc), static_cast(encSize)); - if (!outFile) - return E_FAIL; - #endif - } - else - { - #ifdef _WIN32 - if (!WriteFile(hFile.get(), rgbe, static_cast(rowPitch), &bytesWritten, nullptr)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesWritten != rowPitch) - return E_FAIL; - #else - outFile.write(reinterpret_cast(rgbe), static_cast(rowPitch)); - if (!outFile) - return E_FAIL; - #endif - } - } - #endif - } - -#ifdef _WIN32 - delonfail.clear(); -#endif - - return S_OK; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexImage.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexImage.cpp deleted file mode 100644 index 4083a2c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexImage.cpp +++ /dev/null @@ -1,830 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXTexImage.cpp -// -// DirectX Texture Library - Image container -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//------------------------------------------------------------------------------------- - -#include "DirectXTexP.h" - -using namespace DirectX; -using namespace DirectX::Internal; - -#ifndef _WIN32 -namespace -{ - inline void * _aligned_malloc(size_t size, size_t alignment) - { - size = (size + alignment - 1) & ~(alignment - 1); - return std::aligned_alloc(alignment, size); - } - -#define _aligned_free free -} -#endif - -//------------------------------------------------------------------------------------- -// Determines number of image array entries and pixel size -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -bool DirectX::Internal::DetermineImageArray( - const TexMetadata& metadata, - CP_FLAGS cpFlags, - size_t& nImages, - size_t& pixelSize) noexcept -{ - assert(metadata.width > 0 && metadata.height > 0 && metadata.depth > 0); - assert(metadata.arraySize > 0); - assert(metadata.mipLevels > 0); - - uint64_t totalPixelSize = 0; - size_t nimages = 0; - - switch (metadata.dimension) - { - case TEX_DIMENSION_TEXTURE1D: - case TEX_DIMENSION_TEXTURE2D: - for (size_t item = 0; item < metadata.arraySize; ++item) - { - size_t w = metadata.width; - size_t h = metadata.height; - - for (size_t level = 0; level < metadata.mipLevels; ++level) - { - size_t rowPitch, slicePitch; - if (FAILED(ComputePitch(metadata.format, w, h, rowPitch, slicePitch, cpFlags))) - { - nImages = pixelSize = 0; - return false; - } - - totalPixelSize += uint64_t(slicePitch); - ++nimages; - - if (h > 1) - h >>= 1; - - if (w > 1) - w >>= 1; - } - } - break; - - case TEX_DIMENSION_TEXTURE3D: - { - size_t w = metadata.width; - size_t h = metadata.height; - size_t d = metadata.depth; - - for (size_t level = 0; level < metadata.mipLevels; ++level) - { - size_t rowPitch, slicePitch; - if (FAILED(ComputePitch(metadata.format, w, h, rowPitch, slicePitch, cpFlags))) - { - nImages = pixelSize = 0; - return false; - } - - for (size_t slice = 0; slice < d; ++slice) - { - totalPixelSize += uint64_t(slicePitch); - ++nimages; - } - - if (h > 1) - h >>= 1; - - if (w > 1) - w >>= 1; - - if (d > 1) - d >>= 1; - } - } - break; - - default: - nImages = pixelSize = 0; - return false; - } - -#if defined(_M_IX86) || defined(_M_ARM) || defined(_M_HYBRID_X86_ARM64) - static_assert(sizeof(size_t) == 4, "Not a 32-bit platform!"); - if (totalPixelSize > UINT32_MAX) - { - nImages = pixelSize = 0; - return false; - } -#else - static_assert(sizeof(size_t) == 8, "Not a 64-bit platform!"); -#endif - - nImages = nimages; - pixelSize = static_cast(totalPixelSize); - - return true; -} - - -//------------------------------------------------------------------------------------- -// Fills in the image array entries -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -bool DirectX::Internal::SetupImageArray( - uint8_t *pMemory, - size_t pixelSize, - const TexMetadata& metadata, - CP_FLAGS cpFlags, - Image* images, - size_t nImages) noexcept -{ - assert(pMemory); - assert(pixelSize > 0); - assert(nImages > 0); - - if (!images) - return false; - - size_t index = 0; - uint8_t* pixels = pMemory; - const uint8_t* pEndBits = pMemory + pixelSize; - - switch (metadata.dimension) - { - case TEX_DIMENSION_TEXTURE1D: - case TEX_DIMENSION_TEXTURE2D: - if (metadata.arraySize == 0 || metadata.mipLevels == 0) - { - return false; - } - - for (size_t item = 0; item < metadata.arraySize; ++item) - { - size_t w = metadata.width; - size_t h = metadata.height; - - for (size_t level = 0; level < metadata.mipLevels; ++level) - { - if (index >= nImages) - { - return false; - } - - size_t rowPitch, slicePitch; - if (FAILED(ComputePitch(metadata.format, w, h, rowPitch, slicePitch, cpFlags))) - return false; - - images[index].width = w; - images[index].height = h; - images[index].format = metadata.format; - images[index].rowPitch = rowPitch; - images[index].slicePitch = slicePitch; - images[index].pixels = pixels; - ++index; - - pixels += slicePitch; - if (pixels > pEndBits) - { - return false; - } - - if (h > 1) - h >>= 1; - - if (w > 1) - w >>= 1; - } - } - return true; - - case TEX_DIMENSION_TEXTURE3D: - { - if (metadata.mipLevels == 0 || metadata.depth == 0) - { - return false; - } - - size_t w = metadata.width; - size_t h = metadata.height; - size_t d = metadata.depth; - - for (size_t level = 0; level < metadata.mipLevels; ++level) - { - size_t rowPitch, slicePitch; - if (FAILED(ComputePitch(metadata.format, w, h, rowPitch, slicePitch, cpFlags))) - return false; - - for (size_t slice = 0; slice < d; ++slice) - { - if (index >= nImages) - { - return false; - } - - // We use the same memory organization that Direct3D 11 needs for D3D11_SUBRESOURCE_DATA - // with all slices of a given miplevel being continuous in memory - images[index].width = w; - images[index].height = h; - images[index].format = metadata.format; - images[index].rowPitch = rowPitch; - images[index].slicePitch = slicePitch; - images[index].pixels = pixels; - ++index; - - pixels += slicePitch; - if (pixels > pEndBits) - { - return false; - } - } - - if (h > 1) - h >>= 1; - - if (w > 1) - w >>= 1; - - if (d > 1) - d >>= 1; - } - } - return true; - - default: - return false; - } -} - - -//===================================================================================== -// ScratchImage - Bitmap image container -//===================================================================================== - -ScratchImage& ScratchImage::operator= (ScratchImage&& moveFrom) noexcept -{ - if (this != &moveFrom) - { - Release(); - - m_nimages = moveFrom.m_nimages; - m_size = moveFrom.m_size; - m_metadata = moveFrom.m_metadata; - m_image = moveFrom.m_image; - m_memory = moveFrom.m_memory; - - moveFrom.m_nimages = 0; - moveFrom.m_size = 0; - moveFrom.m_image = nullptr; - moveFrom.m_memory = nullptr; - } - return *this; -} - - -//------------------------------------------------------------------------------------- -// Methods -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT ScratchImage::Initialize(const TexMetadata& mdata, CP_FLAGS flags) noexcept -{ - if (!IsValid(mdata.format)) - return E_INVALIDARG; - - if (IsPalettized(mdata.format)) - return HRESULT_E_NOT_SUPPORTED; - - size_t mipLevels = mdata.mipLevels; - - switch (mdata.dimension) - { - case TEX_DIMENSION_TEXTURE1D: - if (!mdata.width || mdata.height != 1 || mdata.depth != 1 || !mdata.arraySize) - return E_INVALIDARG; - - if (!CalculateMipLevels(mdata.width, 1, mipLevels)) - return E_INVALIDARG; - break; - - case TEX_DIMENSION_TEXTURE2D: - if (!mdata.width || !mdata.height || mdata.depth != 1 || !mdata.arraySize) - return E_INVALIDARG; - - if (mdata.IsCubemap()) - { - if ((mdata.arraySize % 6) != 0) - return E_INVALIDARG; - } - - if (!CalculateMipLevels(mdata.width, mdata.height, mipLevels)) - return E_INVALIDARG; - break; - - case TEX_DIMENSION_TEXTURE3D: - if (!mdata.width || !mdata.height || !mdata.depth || mdata.arraySize != 1) - return E_INVALIDARG; - - if (!CalculateMipLevels3D(mdata.width, mdata.height, mdata.depth, mipLevels)) - return E_INVALIDARG; - break; - - default: - return HRESULT_E_NOT_SUPPORTED; - } - - Release(); - - m_metadata.width = mdata.width; - m_metadata.height = mdata.height; - m_metadata.depth = mdata.depth; - m_metadata.arraySize = mdata.arraySize; - m_metadata.mipLevels = mipLevels; - m_metadata.miscFlags = mdata.miscFlags; - m_metadata.miscFlags2 = mdata.miscFlags2; - m_metadata.format = mdata.format; - m_metadata.dimension = mdata.dimension; - - size_t pixelSize, nimages; - if (!DetermineImageArray(m_metadata, flags, nimages, pixelSize)) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - m_image = new (std::nothrow) Image[nimages]; - if (!m_image) - return E_OUTOFMEMORY; - - m_nimages = nimages; - memset(m_image, 0, sizeof(Image) * nimages); - - m_memory = static_cast(_aligned_malloc(pixelSize, 16)); - if (!m_memory) - { - Release(); - return E_OUTOFMEMORY; - } - m_size = pixelSize; - if (!SetupImageArray(m_memory, pixelSize, m_metadata, flags, m_image, nimages)) - { - Release(); - return E_FAIL; - } - - return S_OK; -} - -_Use_decl_annotations_ -HRESULT ScratchImage::Initialize1D(DXGI_FORMAT fmt, size_t length, size_t arraySize, size_t mipLevels, CP_FLAGS flags) noexcept -{ - if (!length || !arraySize) - return E_INVALIDARG; - - // 1D is a special case of the 2D case - HRESULT hr = Initialize2D(fmt, length, 1, arraySize, mipLevels, flags); - if (FAILED(hr)) - return hr; - - m_metadata.dimension = TEX_DIMENSION_TEXTURE1D; - - return S_OK; -} - -_Use_decl_annotations_ -HRESULT ScratchImage::Initialize2D(DXGI_FORMAT fmt, size_t width, size_t height, size_t arraySize, size_t mipLevels, CP_FLAGS flags) noexcept -{ - if (!IsValid(fmt) || !width || !height || !arraySize) - return E_INVALIDARG; - - if (IsPalettized(fmt)) - return HRESULT_E_NOT_SUPPORTED; - - if (!CalculateMipLevels(width, height, mipLevels)) - return E_INVALIDARG; - - Release(); - - m_metadata.width = width; - m_metadata.height = height; - m_metadata.depth = 1; - m_metadata.arraySize = arraySize; - m_metadata.mipLevels = mipLevels; - m_metadata.miscFlags = 0; - m_metadata.miscFlags2 = 0; - m_metadata.format = fmt; - m_metadata.dimension = TEX_DIMENSION_TEXTURE2D; - - size_t pixelSize, nimages; - if (!DetermineImageArray(m_metadata, flags, nimages, pixelSize)) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - m_image = new (std::nothrow) Image[nimages]; - if (!m_image) - return E_OUTOFMEMORY; - - m_nimages = nimages; - memset(m_image, 0, sizeof(Image) * nimages); - - m_memory = static_cast(_aligned_malloc(pixelSize, 16)); - if (!m_memory) - { - Release(); - return E_OUTOFMEMORY; - } - m_size = pixelSize; - if (!SetupImageArray(m_memory, pixelSize, m_metadata, flags, m_image, nimages)) - { - Release(); - return E_FAIL; - } - - return S_OK; -} - -_Use_decl_annotations_ -HRESULT ScratchImage::Initialize3D(DXGI_FORMAT fmt, size_t width, size_t height, size_t depth, size_t mipLevels, CP_FLAGS flags) noexcept -{ - if (!IsValid(fmt) || !width || !height || !depth) - return E_INVALIDARG; - - if (IsPalettized(fmt)) - return HRESULT_E_NOT_SUPPORTED; - - if (!CalculateMipLevels3D(width, height, depth, mipLevels)) - return E_INVALIDARG; - - Release(); - - m_metadata.width = width; - m_metadata.height = height; - m_metadata.depth = depth; - m_metadata.arraySize = 1; // Direct3D 10.x/11 does not support arrays of 3D textures - m_metadata.mipLevels = mipLevels; - m_metadata.miscFlags = 0; - m_metadata.miscFlags2 = 0; - m_metadata.format = fmt; - m_metadata.dimension = TEX_DIMENSION_TEXTURE3D; - - size_t pixelSize, nimages; - if (!DetermineImageArray(m_metadata, flags, nimages, pixelSize)) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - m_image = new (std::nothrow) Image[nimages]; - if (!m_image) - { - Release(); - return E_OUTOFMEMORY; - } - m_nimages = nimages; - memset(m_image, 0, sizeof(Image) * nimages); - - m_memory = static_cast(_aligned_malloc(pixelSize, 16)); - if (!m_memory) - { - Release(); - return E_OUTOFMEMORY; - } - m_size = pixelSize; - - if (!SetupImageArray(m_memory, pixelSize, m_metadata, flags, m_image, nimages)) - { - Release(); - return E_FAIL; - } - - return S_OK; -} - -_Use_decl_annotations_ -HRESULT ScratchImage::InitializeCube(DXGI_FORMAT fmt, size_t width, size_t height, size_t nCubes, size_t mipLevels, CP_FLAGS flags) noexcept -{ - if (!width || !height || !nCubes) - return E_INVALIDARG; - - // A DirectX11 cubemap is just a 2D texture array that is a multiple of 6 for each cube - HRESULT hr = Initialize2D(fmt, width, height, nCubes * 6, mipLevels, flags); - if (FAILED(hr)) - return hr; - - m_metadata.miscFlags |= TEX_MISC_TEXTURECUBE; - - return S_OK; -} - -_Use_decl_annotations_ -HRESULT ScratchImage::InitializeFromImage(const Image& srcImage, bool allow1D, CP_FLAGS flags) noexcept -{ - HRESULT hr = (srcImage.height > 1 || !allow1D) - ? Initialize2D(srcImage.format, srcImage.width, srcImage.height, 1, 1, flags) - : Initialize1D(srcImage.format, srcImage.width, 1, 1, flags); - - if (FAILED(hr)) - return hr; - - const size_t rowCount = ComputeScanlines(srcImage.format, srcImage.height); - if (!rowCount) - return E_UNEXPECTED; - - const uint8_t* sptr = srcImage.pixels; - if (!sptr) - return E_POINTER; - - uint8_t* dptr = m_image[0].pixels; - if (!dptr) - return E_POINTER; - - const size_t spitch = srcImage.rowPitch; - const size_t dpitch = m_image[0].rowPitch; - - const size_t size = std::min(dpitch, spitch); - - for (size_t y = 0; y < rowCount; ++y) - { - memcpy(dptr, sptr, size); - sptr += spitch; - dptr += dpitch; - } - - return S_OK; -} - -_Use_decl_annotations_ -HRESULT ScratchImage::InitializeArrayFromImages(const Image* images, size_t nImages, bool allow1D, CP_FLAGS flags) noexcept -{ - if (!images || !nImages) - return E_INVALIDARG; - - const DXGI_FORMAT format = images[0].format; - const size_t width = images[0].width; - const size_t height = images[0].height; - - for (size_t index = 0; index < nImages; ++index) - { - if (!images[index].pixels) - return E_POINTER; - - if (images[index].format != format || images[index].width != width || images[index].height != height) - { - // All images must be the same format, width, and height - return E_FAIL; - } - } - - HRESULT hr = (height > 1 || !allow1D) - ? Initialize2D(format, width, height, nImages, 1, flags) - : Initialize1D(format, width, nImages, 1, flags); - - if (FAILED(hr)) - return hr; - - const size_t rowCount = ComputeScanlines(format, height); - if (!rowCount) - return E_UNEXPECTED; - - for (size_t index = 0; index < nImages; ++index) - { - const uint8_t* sptr = images[index].pixels; - if (!sptr) - return E_POINTER; - - assert(index < m_nimages); - uint8_t* dptr = m_image[index].pixels; - if (!dptr) - return E_POINTER; - - const size_t spitch = images[index].rowPitch; - const size_t dpitch = m_image[index].rowPitch; - - const size_t size = std::min(dpitch, spitch); - - for (size_t y = 0; y < rowCount; ++y) - { - memcpy(dptr, sptr, size); - sptr += spitch; - dptr += dpitch; - } - } - - return S_OK; -} - -_Use_decl_annotations_ -HRESULT ScratchImage::InitializeCubeFromImages(const Image* images, size_t nImages, CP_FLAGS flags) noexcept -{ - if (!images || !nImages) - return E_INVALIDARG; - - // A DirectX11 cubemap is just a 2D texture array that is a multiple of 6 for each cube - if ((nImages % 6) != 0) - return E_INVALIDARG; - - HRESULT hr = InitializeArrayFromImages(images, nImages, false, flags); - if (FAILED(hr)) - return hr; - - m_metadata.miscFlags |= TEX_MISC_TEXTURECUBE; - - return S_OK; -} - -_Use_decl_annotations_ -HRESULT ScratchImage::Initialize3DFromImages(const Image* images, size_t depth, CP_FLAGS flags) noexcept -{ - if (!images || !depth) - return E_INVALIDARG; - - const DXGI_FORMAT format = images[0].format; - const size_t width = images[0].width; - const size_t height = images[0].height; - - for (size_t slice = 0; slice < depth; ++slice) - { - if (!images[slice].pixels) - return E_POINTER; - - if (images[slice].format != format || images[slice].width != width || images[slice].height != height) - { - // All images must be the same format, width, and height - return E_FAIL; - } - } - - HRESULT hr = Initialize3D(format, width, height, depth, 1, flags); - if (FAILED(hr)) - return hr; - - const size_t rowCount = ComputeScanlines(format, height); - if (!rowCount) - return E_UNEXPECTED; - - for (size_t slice = 0; slice < depth; ++slice) - { - const uint8_t* sptr = images[slice].pixels; - if (!sptr) - return E_POINTER; - - assert(slice < m_nimages); - uint8_t* dptr = m_image[slice].pixels; - if (!dptr) - return E_POINTER; - - const size_t spitch = images[slice].rowPitch; - const size_t dpitch = m_image[slice].rowPitch; - - const size_t size = std::min(dpitch, spitch); - - for (size_t y = 0; y < rowCount; ++y) - { - memcpy(dptr, sptr, size); - sptr += spitch; - dptr += dpitch; - } - } - - return S_OK; -} - -void ScratchImage::Release() noexcept -{ - m_nimages = 0; - m_size = 0; - - if (m_image) - { - delete[] m_image; - m_image = nullptr; - } - - if (m_memory) - { - _aligned_free(m_memory); - m_memory = nullptr; - } - - memset(&m_metadata, 0, sizeof(m_metadata)); -} - -_Use_decl_annotations_ -bool ScratchImage::OverrideFormat(DXGI_FORMAT f) noexcept -{ - if (!m_image) - return false; - - if (!IsValid(f) || IsPlanar(f) || IsPalettized(f)) - return false; - - for (size_t index = 0; index < m_nimages; ++index) - { - m_image[index].format = f; - } - - m_metadata.format = f; - - return true; -} - -_Use_decl_annotations_ -const Image* ScratchImage::GetImage(size_t mip, size_t item, size_t slice) const noexcept -{ - if (mip >= m_metadata.mipLevels) - return nullptr; - - size_t index = 0; - - switch (m_metadata.dimension) - { - case TEX_DIMENSION_TEXTURE1D: - case TEX_DIMENSION_TEXTURE2D: - if (slice > 0) - return nullptr; - - if (item >= m_metadata.arraySize) - return nullptr; - - index = item*(m_metadata.mipLevels) + mip; - break; - - case TEX_DIMENSION_TEXTURE3D: - if (item > 0) - { - // No support for arrays of volumes - return nullptr; - } - else - { - size_t d = m_metadata.depth; - - for (size_t level = 0; level < mip; ++level) - { - index += d; - if (d > 1) - d >>= 1; - } - - if (slice >= d) - return nullptr; - - index += slice; - } - break; - - default: - return nullptr; - } - - return &m_image[index]; -} - -bool ScratchImage::IsAlphaAllOpaque() const noexcept -{ - if (!m_image) - return false; - - if (!HasAlpha(m_metadata.format)) - return true; - - if (IsCompressed(m_metadata.format)) - { - for (size_t index = 0; index < m_nimages; ++index) - { - if (!IsAlphaAllOpaqueBC(m_image[index])) - return false; - } - } - else - { - auto scanline = make_AlignedArrayXMVECTOR(m_metadata.width); - if (!scanline) - return false; - - static const XMVECTORF32 threshold = { { { 0.997f, 0.997f, 0.997f, 0.997f } } }; - - for (size_t index = 0; index < m_nimages; ++index) - { - #pragma warning( suppress : 6011 ) - const Image& img = m_image[index]; - - const uint8_t *pPixels = img.pixels; - assert(pPixels); - - for (size_t h = 0; h < img.height; ++h) - { - if (!LoadScanline(scanline.get(), img.width, pPixels, img.rowPitch, img.format)) - return false; - - const XMVECTOR* ptr = scanline.get(); - for (size_t w = 0; w < img.width; ++w) - { - const XMVECTOR alpha = XMVectorSplatW(*ptr); - if (XMVector4Less(alpha, threshold)) - return false; - ++ptr; - } - - pPixels += img.rowPitch; - } - } - } - - return true; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexMipmaps.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexMipmaps.cpp deleted file mode 100644 index 03c30c0..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexMipmaps.cpp +++ /dev/null @@ -1,3529 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXTexMipMaps.cpp -// -// DirectX Texture Library - Mip-map generation -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//------------------------------------------------------------------------------------- - -#include "DirectXTexP.h" - -#include "filters.h" - -using namespace DirectX; -using namespace DirectX::Internal; -using Microsoft::WRL::ComPtr; - -namespace -{ - constexpr bool ispow2(_In_ size_t x) noexcept - { - return ((x != 0) && !(x & (x - 1))); - } - - - size_t CountMips(_In_ size_t width, _In_ size_t height) noexcept - { - size_t mipLevels = 1; - - while (height > 1 || width > 1) - { - if (height > 1) - height >>= 1; - - if (width > 1) - width >>= 1; - - ++mipLevels; - } - - return mipLevels; - } - - - size_t CountMips3D(_In_ size_t width, _In_ size_t height, _In_ size_t depth) noexcept - { - size_t mipLevels = 1; - - while (height > 1 || width > 1 || depth > 1) - { - if (height > 1) - height >>= 1; - - if (width > 1) - width >>= 1; - - if (depth > 1) - depth >>= 1; - - ++mipLevels; - } - - return mipLevels; - } - -#ifdef _WIN32 - HRESULT EnsureWicBitmapPixelFormat( - _In_ IWICImagingFactory* pWIC, - _In_ IWICBitmap* src, - _In_ TEX_FILTER_FLAGS filter, - _In_ const WICPixelFormatGUID& desiredPixelFormat, - _Deref_out_ IWICBitmap** dest) noexcept - { - if (!pWIC || !src || !dest) - return E_POINTER; - - *dest = nullptr; - - WICPixelFormatGUID actualPixelFormat; - HRESULT hr = src->GetPixelFormat(&actualPixelFormat); - - if (SUCCEEDED(hr)) - { - if (memcmp(&actualPixelFormat, &desiredPixelFormat, sizeof(WICPixelFormatGUID)) == 0) - { - src->AddRef(); - *dest = src; - } - else - { - ComPtr converter; - hr = pWIC->CreateFormatConverter(converter.GetAddressOf()); - - if (SUCCEEDED(hr)) - { - BOOL canConvert = FALSE; - hr = converter->CanConvert(actualPixelFormat, desiredPixelFormat, &canConvert); - if (FAILED(hr) || !canConvert) - { - return E_UNEXPECTED; - } - } - - if (SUCCEEDED(hr)) - { - hr = converter->Initialize(src, desiredPixelFormat, GetWICDither(filter), nullptr, - 0, WICBitmapPaletteTypeMedianCut); - } - - if (SUCCEEDED(hr)) - { - hr = pWIC->CreateBitmapFromSource(converter.Get(), WICBitmapCacheOnDemand, dest); - } - } - } - - return hr; - } -#endif // WIN32 - - -#if DIRECTX_MATH_VERSION >= 310 -#define VectorSum XMVectorSum -#else - inline XMVECTOR XM_CALLCONV VectorSum - ( - FXMVECTOR V - ) - { - XMVECTOR vTemp = XMVectorSwizzle<2, 3, 0, 1>(V); - XMVECTOR vTemp2 = XMVectorAdd(V, vTemp); - vTemp = XMVectorSwizzle<1, 0, 3, 2>(vTemp2); - return XMVectorAdd(vTemp, vTemp2); - } -#endif - - - HRESULT ScaleAlpha( - const Image& srcImage, - float alphaScale, - const Image& destImage) noexcept - { - assert(srcImage.width == destImage.width); - assert(srcImage.height == destImage.height); - - auto scanline = make_AlignedArrayXMVECTOR(srcImage.width); - if (!scanline) - { - return E_OUTOFMEMORY; - } - - const uint8_t* pSrc = srcImage.pixels; - uint8_t* pDest = destImage.pixels; - if (!pSrc || !pDest) - { - return E_POINTER; - } - - const XMVECTOR vscale = XMVectorReplicate(alphaScale); - - for (size_t h = 0; h < srcImage.height; ++h) - { - if (!LoadScanline(scanline.get(), srcImage.width, pSrc, srcImage.rowPitch, srcImage.format)) - { - return E_FAIL; - } - - XMVECTOR* ptr = scanline.get(); - for (size_t w = 0; w < srcImage.width; ++w) - { - const XMVECTOR v = *ptr; - const XMVECTOR alpha = XMVectorMultiply(XMVectorSplatW(v), vscale); - *(ptr++) = XMVectorSelect(alpha, v, g_XMSelect1110); - } - - if (!StoreScanline(pDest, destImage.rowPitch, destImage.format, scanline.get(), srcImage.width)) - { - return E_FAIL; - } - - pSrc += srcImage.rowPitch; - pDest += destImage.rowPitch; - } - - return S_OK; - } - - - void GenerateAlphaCoverageConvolutionVectors( - _In_ size_t N, - _Out_writes_(N*N) XMVECTOR* vectors) noexcept - { - for (size_t sy = 0; sy < N; ++sy) - { - const float fy = (float(sy) + 0.5f) / float(N); - const float ify = 1.0f - fy; - - for (size_t sx = 0; sx < N; ++sx) - { - const float fx = (float(sx) + 0.5f) / float(N); - const float ifx = 1.0f - fx; - - // [0]=(x+0, y+0), [1]=(x+0, y+1), [2]=(x+1, y+0), [3]=(x+1, y+1) - vectors[sy * N + sx] = XMVectorSet(ifx * ify, ifx * fy, fx * ify, fx * fy); - } - } - } - - - HRESULT CalculateAlphaCoverage( - const Image& srcImage, - float alphaReference, - float alphaScale, - float& coverage) noexcept - { - coverage = 0.0f; - - auto row0 = make_AlignedArrayXMVECTOR(srcImage.width); - if (!row0) - { - return E_OUTOFMEMORY; - } - - auto row1 = make_AlignedArrayXMVECTOR(srcImage.width); - if (!row1) - { - return E_OUTOFMEMORY; - } - - const XMVECTOR scale = XMVectorReplicate(alphaScale); - - const uint8_t *pSrcRow0 = srcImage.pixels; - if (!pSrcRow0) - { - return E_POINTER; - } - - constexpr size_t N = 8; - XMVECTOR convolution[N * N]; - GenerateAlphaCoverageConvolutionVectors(N, convolution); - - size_t coverageCount = 0; - for (size_t y = 0; y < srcImage.height - 1; ++y) - { - if (!LoadScanlineLinear(row0.get(), srcImage.width, pSrcRow0, srcImage.rowPitch, srcImage.format, TEX_FILTER_DEFAULT)) - { - return E_FAIL; - } - - const uint8_t *pSrcRow1 = pSrcRow0 + srcImage.rowPitch; - if (!LoadScanlineLinear(row1.get(), srcImage.width, pSrcRow1, srcImage.rowPitch, srcImage.format, TEX_FILTER_DEFAULT)) - { - return E_FAIL; - } - - const XMVECTOR* pRow0 = row0.get(); - const XMVECTOR* pRow1 = row1.get(); - for (size_t x = 0; x < srcImage.width - 1; ++x) - { - // [0]=(x+0, y+0), [1]=(x+0, y+1), [2]=(x+1, y+0), [3]=(x+1, y+1) - XMVECTOR r0 = XMVectorSplatW(*pRow0); - XMVECTOR r1 = XMVectorSplatW(*pRow1); - - XMVECTOR v1 = XMVectorSaturate(XMVectorMultiply(r0, scale)); - XMVECTOR v2 = XMVectorSaturate(XMVectorMultiply(r1, scale)); - - r0 = XMVectorSplatW(*(++pRow0)); - r1 = XMVectorSplatW(*(++pRow1)); - - XMVECTOR v3 = XMVectorSaturate(XMVectorMultiply(XMVectorSplatW(r0), scale)); - XMVECTOR v4 = XMVectorSaturate(XMVectorMultiply(XMVectorSplatW(r1), scale)); - - v1 = XMVectorMergeXY(v1, v2); // [v1.x v2.x --- ---] - v3 = XMVectorMergeXY(v3, v4); // [v3.x v4.x --- ---] - - XMVECTOR v = XMVectorPermute<0, 1, 4, 5>(v1, v3); // [v1.x v2.x v3.x v4.x] - - for (size_t sy = 0; sy < N; ++sy) - { - const size_t ry = sy * N; - for (size_t sx = 0; sx < N; ++sx) - { - v = VectorSum(XMVectorMultiply(v, convolution[ry + sx])); - if (XMVectorGetX(v) > alphaReference) - { - ++coverageCount; - } - } - } - } - - pSrcRow0 = pSrcRow1; - } - - float cscale = static_cast((srcImage.width - 1) * (srcImage.height - 1) * N * N); - if (cscale > 0.f) - { - coverage = static_cast(coverageCount) / cscale; - } - - return S_OK; - } - - - HRESULT EstimateAlphaScaleForCoverage( - const Image& srcImage, - float alphaReference, - float targetCoverage, - float& alphaScale) noexcept - { - float minAlphaScale = 0.0f; - float maxAlphaScale = 4.0f; - float bestError = FLT_MAX; - - // Determine desired scale using a binary search. Hardcoded to 10 steps max. - alphaScale = 1.0f; - constexpr size_t N = 10; - for (size_t i = 0; i < N; ++i) - { - float currentCoverage = 0.0f; - HRESULT hr = CalculateAlphaCoverage(srcImage, alphaReference, alphaScale, currentCoverage); - if (FAILED(hr)) - { - return hr; - } - - const float error = fabsf(currentCoverage - targetCoverage); - if (error < bestError) - { - bestError = error; - } - - if (currentCoverage < targetCoverage) - { - minAlphaScale = alphaScale; - } - else if (currentCoverage > targetCoverage) - { - maxAlphaScale = alphaScale; - } - else - { - break; - } - - alphaScale = (minAlphaScale + maxAlphaScale) * 0.5f; - } - - return S_OK; - } -} - -_Use_decl_annotations_ -bool DirectX::Internal::CalculateMipLevels( - size_t width, - size_t height, - size_t& mipLevels) noexcept -{ - if (mipLevels > 1) - { - const size_t maxMips = CountMips(width, height); - if (mipLevels > maxMips) - return false; - } - else if (mipLevels == 0) - { - mipLevels = CountMips(width, height); - } - else - { - mipLevels = 1; - } - return true; -} - -_Use_decl_annotations_ -bool DirectX::Internal::CalculateMipLevels3D( - size_t width, - size_t height, - size_t depth, - size_t& mipLevels) noexcept -{ - if (mipLevels > 1) - { - const size_t maxMips = CountMips3D(width, height, depth); - if (mipLevels > maxMips) - return false; - } - else if (mipLevels == 0) - { - mipLevels = CountMips3D(width, height, depth); - } - else - { - mipLevels = 1; - } - return true; -} - -#ifdef _WIN32 -//--- Resizing color and alpha channels separately using WIC --- -_Use_decl_annotations_ -HRESULT DirectX::Internal::ResizeSeparateColorAndAlpha( - IWICImagingFactory* pWIC, - bool iswic2, - IWICBitmap* original, - size_t newWidth, - size_t newHeight, - TEX_FILTER_FLAGS filter, - const Image* img) noexcept -{ - if (!pWIC || !original || !img) - return E_POINTER; - - const WICBitmapInterpolationMode interpolationMode = GetWICInterp(filter); - - WICPixelFormatGUID desiredPixelFormat = GUID_WICPixelFormatUndefined; - HRESULT hr = original->GetPixelFormat(&desiredPixelFormat); - - size_t colorBytesInPixel = 0; - size_t colorBytesPerPixel = 0; - size_t colorWithAlphaBytesPerPixel = 0; - WICPixelFormatGUID colorPixelFormat = GUID_WICPixelFormatUndefined; - WICPixelFormatGUID colorWithAlphaPixelFormat = GUID_WICPixelFormatUndefined; - - if (SUCCEEDED(hr)) - { - ComPtr componentInfo; - hr = pWIC->CreateComponentInfo(desiredPixelFormat, componentInfo.GetAddressOf()); - - ComPtr pixelFormatInfo; - if (SUCCEEDED(hr)) - { - hr = componentInfo.As(&pixelFormatInfo); - } - - UINT bitsPerPixel = 0; - if (SUCCEEDED(hr)) - { - hr = pixelFormatInfo->GetBitsPerPixel(&bitsPerPixel); - } - - if (SUCCEEDED(hr)) - { - if (bitsPerPixel <= 32) - { - colorBytesInPixel = colorBytesPerPixel = 3; - colorPixelFormat = GUID_WICPixelFormat24bppBGR; - - colorWithAlphaBytesPerPixel = 4; - colorWithAlphaPixelFormat = GUID_WICPixelFormat32bppBGRA; - } - else - { - #if(_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE) - if (iswic2) - { - colorBytesInPixel = colorBytesPerPixel = 12; - colorPixelFormat = GUID_WICPixelFormat96bppRGBFloat; - } - else - #else - UNREFERENCED_PARAMETER(iswic2); - #endif - { - colorBytesInPixel = 12; - colorBytesPerPixel = 16; - colorPixelFormat = GUID_WICPixelFormat128bppRGBFloat; - } - - colorWithAlphaBytesPerPixel = 16; - colorWithAlphaPixelFormat = GUID_WICPixelFormat128bppRGBAFloat; - } - } - } - - // Resize color only image (no alpha channel) - ComPtr resizedColor; - if (SUCCEEDED(hr)) - { - ComPtr colorScaler; - hr = pWIC->CreateBitmapScaler(colorScaler.GetAddressOf()); - if (SUCCEEDED(hr)) - { - ComPtr converted; - hr = EnsureWicBitmapPixelFormat(pWIC, original, filter, colorPixelFormat, converted.GetAddressOf()); - if (SUCCEEDED(hr)) - { - hr = colorScaler->Initialize(converted.Get(), static_cast(newWidth), static_cast(newHeight), interpolationMode); - } - } - - if (SUCCEEDED(hr)) - { - ComPtr resized; - hr = pWIC->CreateBitmapFromSource(colorScaler.Get(), WICBitmapCacheOnDemand, resized.GetAddressOf()); - if (SUCCEEDED(hr)) - { - hr = EnsureWicBitmapPixelFormat(pWIC, resized.Get(), filter, colorPixelFormat, resizedColor.GetAddressOf()); - } - } - } - - // Resize color+alpha image - ComPtr resizedColorWithAlpha; - if (SUCCEEDED(hr)) - { - ComPtr colorWithAlphaScaler; - hr = pWIC->CreateBitmapScaler(colorWithAlphaScaler.GetAddressOf()); - if (SUCCEEDED(hr)) - { - ComPtr converted; - hr = EnsureWicBitmapPixelFormat(pWIC, original, filter, colorWithAlphaPixelFormat, converted.GetAddressOf()); - if (SUCCEEDED(hr)) - { - hr = colorWithAlphaScaler->Initialize(converted.Get(), static_cast(newWidth), static_cast(newHeight), interpolationMode); - } - } - - if (SUCCEEDED(hr)) - { - ComPtr resized; - hr = pWIC->CreateBitmapFromSource(colorWithAlphaScaler.Get(), WICBitmapCacheOnDemand, resized.GetAddressOf()); - if (SUCCEEDED(hr)) - { - hr = EnsureWicBitmapPixelFormat(pWIC, resized.Get(), filter, colorWithAlphaPixelFormat, resizedColorWithAlpha.GetAddressOf()); - } - } - } - - // Merge pixels (copying color channels from color only image to color+alpha image) - if (SUCCEEDED(hr)) - { - ComPtr colorLock; - ComPtr colorWithAlphaLock; - hr = resizedColor->Lock(nullptr, WICBitmapLockRead, colorLock.GetAddressOf()); - if (SUCCEEDED(hr)) - { - hr = resizedColorWithAlpha->Lock(nullptr, WICBitmapLockWrite, colorWithAlphaLock.GetAddressOf()); - } - - if (SUCCEEDED(hr)) - { - BYTE* colorWithAlphaData = nullptr; - UINT colorWithAlphaSizeInBytes = 0; - UINT colorWithAlphaStride = 0; - - hr = colorWithAlphaLock->GetDataPointer(&colorWithAlphaSizeInBytes, &colorWithAlphaData); - if (SUCCEEDED(hr)) - { - if (!colorWithAlphaData) - { - hr = E_POINTER; - } - else - { - hr = colorWithAlphaLock->GetStride(&colorWithAlphaStride); - } - } - - BYTE* colorData = nullptr; - UINT colorSizeInBytes = 0; - UINT colorStride = 0; - if (SUCCEEDED(hr)) - { - hr = colorLock->GetDataPointer(&colorSizeInBytes, &colorData); - if (SUCCEEDED(hr)) - { - if (!colorData) - { - hr = E_POINTER; - } - else - { - hr = colorLock->GetStride(&colorStride); - } - } - } - - for (size_t j = 0; SUCCEEDED(hr) && j < newHeight; j++) - { - for (size_t i = 0; SUCCEEDED(hr) && i < newWidth; i++) - { - size_t colorWithAlphaIndex = (j * colorWithAlphaStride) + (i * colorWithAlphaBytesPerPixel); - const size_t colorIndex = (j * colorStride) + (i * colorBytesPerPixel); - - if (((colorWithAlphaIndex + colorBytesInPixel) > colorWithAlphaSizeInBytes) - || ((colorIndex + colorBytesPerPixel) > colorSizeInBytes)) - { - hr = E_INVALIDARG; - } - else - { - #pragma warning( suppress : 26014 6386 ) // No overflow possible here - memcpy_s(colorWithAlphaData + colorWithAlphaIndex, colorWithAlphaBytesPerPixel, colorData + colorIndex, colorBytesInPixel); - } - } - } - } - } - - if (SUCCEEDED(hr)) - { - if (img->rowPitch > UINT32_MAX || img->slicePitch > UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - ComPtr wicBitmap; - hr = EnsureWicBitmapPixelFormat(pWIC, resizedColorWithAlpha.Get(), filter, desiredPixelFormat, wicBitmap.GetAddressOf()); - if (SUCCEEDED(hr)) - { - hr = wicBitmap->CopyPixels(nullptr, static_cast(img->rowPitch), static_cast(img->slicePitch), img->pixels); - } - } - - return hr; -} -#endif // WIN32 - -namespace -{ -#ifdef _WIN32 - //--- determine when to use WIC vs. non-WIC paths --- - bool UseWICFiltering(_In_ DXGI_FORMAT format, _In_ TEX_FILTER_FLAGS filter) noexcept - { - if (filter & TEX_FILTER_FORCE_NON_WIC) - { - // Explicit flag indicates use of non-WIC code paths - return false; - } - - if (filter & TEX_FILTER_FORCE_WIC) - { - // Explicit flag to use WIC code paths, skips all the case checks below - return true; - } - - if (IsSRGB(format) || (filter & TEX_FILTER_SRGB)) - { - // Use non-WIC code paths for sRGB correct filtering - return false; - } - - #if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX) - if (format == DXGI_FORMAT_R16G16B16A16_FLOAT - || format == DXGI_FORMAT_R16_FLOAT) - { - // Use non-WIC code paths as these conversions are not supported by Xbox version of WIC - return false; - } - #endif - - static_assert(TEX_FILTER_POINT == 0x100000, "TEX_FILTER_ flag values don't match TEX_FILTER_MODE_MASK"); - - switch (filter & TEX_FILTER_MODE_MASK) - { - case TEX_FILTER_LINEAR: - if (filter & TEX_FILTER_WRAP) - { - // WIC only supports 'clamp' semantics (MIRROR is equivalent to clamp for linear) - return false; - } - - if (BitsPerColor(format) > 8) - { - // Avoid the WIC bitmap scaler when doing Linear filtering of XR/HDR formats - return false; - } - break; - - case TEX_FILTER_CUBIC: - if (filter & (TEX_FILTER_WRAP | TEX_FILTER_MIRROR)) - { - // WIC only supports 'clamp' semantics - return false; - } - - if (BitsPerColor(format) > 8) - { - // Avoid the WIC bitmap scaler when doing Cubic filtering of XR/HDR formats - return false; - } - break; - - case TEX_FILTER_TRIANGLE: - // WIC does not implement this filter - return false; - - default: - if (BitsPerColor(format) > 8) - { - // Avoid the WIC bitmap scaler when doing filtering of XR/HDR formats - return false; - } - break; - } - - return true; - } - - - //--- mipmap (1D/2D) generation using WIC image scalar --- - HRESULT GenerateMipMapsUsingWIC( - _In_ const Image& baseImage, - _In_ TEX_FILTER_FLAGS filter, - _In_ size_t levels, - _In_ const WICPixelFormatGUID& pfGUID, - _In_ const ScratchImage& mipChain, - _In_ size_t item) noexcept - { - assert(levels > 1); - - if (!baseImage.pixels || !mipChain.GetPixels()) - return E_POINTER; - - bool iswic2 = false; - auto pWIC = GetWICFactory(iswic2); - if (!pWIC) - return E_NOINTERFACE; - - size_t width = baseImage.width; - size_t height = baseImage.height; - - if (baseImage.rowPitch > UINT32_MAX || baseImage.slicePitch > UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - ComPtr source; - HRESULT hr = pWIC->CreateBitmapFromMemory(static_cast(width), static_cast(height), pfGUID, - static_cast(baseImage.rowPitch), static_cast(baseImage.slicePitch), - baseImage.pixels, source.GetAddressOf()); - if (FAILED(hr)) - return hr; - - // Copy base image to top miplevel - const Image *img0 = mipChain.GetImage(0, item, 0); - if (!img0) - return E_POINTER; - - uint8_t* pDest = img0->pixels; - if (!pDest) - return E_POINTER; - - const uint8_t *pSrc = baseImage.pixels; - for (size_t h = 0; h < height; ++h) - { - const size_t msize = std::min(img0->rowPitch, baseImage.rowPitch); - memcpy_s(pDest, img0->rowPitch, pSrc, msize); - pSrc += baseImage.rowPitch; - pDest += img0->rowPitch; - } - - ComPtr componentInfo; - hr = pWIC->CreateComponentInfo(pfGUID, componentInfo.GetAddressOf()); - if (FAILED(hr)) - return hr; - - ComPtr pixelFormatInfo; - hr = componentInfo.As(&pixelFormatInfo); - if (FAILED(hr)) - return hr; - - BOOL supportsTransparency = FALSE; - hr = pixelFormatInfo->SupportsTransparency(&supportsTransparency); - if (FAILED(hr)) - return hr; - - // Resize base image to each target mip level - for (size_t level = 1; level < levels; ++level) - { - const Image *img = mipChain.GetImage(level, item, 0); - if (!img) - return E_POINTER; - - if (height > 1) - height >>= 1; - - if (width > 1) - width >>= 1; - - assert(img->width == width && img->height == height && img->format == baseImage.format); - - if ((filter & TEX_FILTER_SEPARATE_ALPHA) && supportsTransparency) - { - hr = ResizeSeparateColorAndAlpha(pWIC, iswic2, source.Get(), width, height, filter, img); - if (FAILED(hr)) - return hr; - } - else - { - ComPtr scaler; - hr = pWIC->CreateBitmapScaler(scaler.GetAddressOf()); - if (FAILED(hr)) - return hr; - - if (img->rowPitch > UINT32_MAX || img->slicePitch > UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - hr = scaler->Initialize(source.Get(), - static_cast(width), static_cast(height), - GetWICInterp(filter)); - if (FAILED(hr)) - return hr; - - WICPixelFormatGUID pfScaler; - hr = scaler->GetPixelFormat(&pfScaler); - if (FAILED(hr)) - return hr; - - if (memcmp(&pfScaler, &pfGUID, sizeof(WICPixelFormatGUID)) == 0) - { - hr = scaler->CopyPixels(nullptr, static_cast(img->rowPitch), static_cast(img->slicePitch), img->pixels); - if (FAILED(hr)) - return hr; - } - else - { - // The WIC bitmap scaler is free to return a different pixel format than the source image, so here we - // convert it back - ComPtr FC; - hr = pWIC->CreateFormatConverter(FC.GetAddressOf()); - if (FAILED(hr)) - return hr; - - BOOL canConvert = FALSE; - hr = FC->CanConvert(pfScaler, pfGUID, &canConvert); - if (FAILED(hr) || !canConvert) - { - return E_UNEXPECTED; - } - - hr = FC->Initialize(scaler.Get(), pfGUID, GetWICDither(filter), nullptr, - 0, WICBitmapPaletteTypeMedianCut); - if (FAILED(hr)) - return hr; - - hr = FC->CopyPixels(nullptr, static_cast(img->rowPitch), static_cast(img->slicePitch), img->pixels); - if (FAILED(hr)) - return hr; - } - } - } - - return S_OK; - } -#endif // WIN32 - - - //------------------------------------------------------------------------------------- - // Generate (1D/2D) mip-map helpers (custom filtering) - //------------------------------------------------------------------------------------- - HRESULT Setup2DMips( - _In_reads_(nimages) const Image* baseImages, - _In_ size_t nimages, - _In_ const TexMetadata& mdata, - _Out_ ScratchImage& mipChain) noexcept - { - if (!baseImages || !nimages) - return E_INVALIDARG; - - assert(mdata.mipLevels > 1); - assert(mdata.arraySize == nimages); - assert(mdata.depth == 1 && mdata.dimension != TEX_DIMENSION_TEXTURE3D); - assert(mdata.width == baseImages[0].width); - assert(mdata.height == baseImages[0].height); - assert(mdata.format == baseImages[0].format); - - HRESULT hr = mipChain.Initialize(mdata); - if (FAILED(hr)) - return hr; - - // Copy base image(s) to top of mip chain - for (size_t item = 0; item < nimages; ++item) - { - const Image& src = baseImages[item]; - - const Image *dest = mipChain.GetImage(0, item, 0); - if (!dest) - { - mipChain.Release(); - return E_POINTER; - } - - assert(src.format == dest->format); - - uint8_t* pDest = dest->pixels; - if (!pDest) - { - mipChain.Release(); - return E_POINTER; - } - - const uint8_t *pSrc = src.pixels; - const size_t rowPitch = src.rowPitch; - for (size_t h = 0; h < mdata.height; ++h) - { - const size_t msize = std::min(dest->rowPitch, rowPitch); - memcpy(pDest, pSrc, msize); - pSrc += rowPitch; - pDest += dest->rowPitch; - } - } - - return S_OK; - } - - //--- 2D Point Filter --- - HRESULT Generate2DMipsPointFilter(size_t levels, const ScratchImage& mipChain, size_t item) noexcept - { - if (!mipChain.GetImages()) - return E_INVALIDARG; - - // This assumes that the base image is already placed into the mipChain at the top level... (see _Setup2DMips) - - assert(levels > 1); - - size_t width = mipChain.GetMetadata().width; - size_t height = mipChain.GetMetadata().height; - - // Allocate temporary space (2 scanlines) - auto scanline = make_AlignedArrayXMVECTOR(uint64_t(width) * 2); - if (!scanline) - return E_OUTOFMEMORY; - - XMVECTOR* target = scanline.get(); - - XMVECTOR* row = target + width; - - // Resize base image to each target mip level - for (size_t level = 1; level < levels; ++level) - { - #ifdef _DEBUG - memset(row, 0xCD, sizeof(XMVECTOR)*width); - #endif - - // 2D point filter - const Image* src = mipChain.GetImage(level - 1, item, 0); - const Image* dest = mipChain.GetImage(level, item, 0); - - if (!src || !dest) - return E_POINTER; - - const uint8_t* pSrc = src->pixels; - uint8_t* pDest = dest->pixels; - - const size_t rowPitch = src->rowPitch; - - const size_t nwidth = (width > 1) ? (width >> 1) : 1; - const size_t nheight = (height > 1) ? (height >> 1) : 1; - - const size_t xinc = (width << 16) / nwidth; - const size_t yinc = (height << 16) / nheight; - - size_t lasty = size_t(-1); - - size_t sy = 0; - for (size_t y = 0; y < nheight; ++y) - { - if ((lasty ^ sy) >> 16) - { - if (!LoadScanline(row, width, pSrc + (rowPitch * (sy >> 16)), rowPitch, src->format)) - return E_FAIL; - lasty = sy; - } - - size_t sx = 0; - for (size_t x = 0; x < nwidth; ++x) - { - target[x] = row[sx >> 16]; - sx += xinc; - } - - if (!StoreScanline(pDest, dest->rowPitch, dest->format, target, nwidth)) - return E_FAIL; - pDest += dest->rowPitch; - - sy += yinc; - } - - if (height > 1) - height >>= 1; - - if (width > 1) - width >>= 1; - } - - return S_OK; - } - - - //--- 2D Box Filter --- - HRESULT Generate2DMipsBoxFilter(size_t levels, TEX_FILTER_FLAGS filter, const ScratchImage& mipChain, size_t item) noexcept - { - using namespace DirectX::Filters; - - if (!mipChain.GetImages()) - return E_INVALIDARG; - - // This assumes that the base image is already placed into the mipChain at the top level... (see _Setup2DMips) - - assert(levels > 1); - - size_t width = mipChain.GetMetadata().width; - size_t height = mipChain.GetMetadata().height; - - if (!ispow2(width) || !ispow2(height)) - return E_FAIL; - - // Allocate temporary space (3 scanlines) - auto scanline = make_AlignedArrayXMVECTOR(uint64_t(width) * 3); - if (!scanline) - return E_OUTOFMEMORY; - - XMVECTOR* target = scanline.get(); - - XMVECTOR* urow0 = target + width; - XMVECTOR* urow1 = target + width * 2; - - const XMVECTOR* urow2 = urow0 + 1; - const XMVECTOR* urow3 = urow1 + 1; - - // Resize base image to each target mip level - for (size_t level = 1; level < levels; ++level) - { - if (height <= 1) - { - urow1 = urow0; - } - - if (width <= 1) - { - urow2 = urow0; - urow3 = urow1; - } - - // 2D box filter - const Image* src = mipChain.GetImage(level - 1, item, 0); - const Image* dest = mipChain.GetImage(level, item, 0); - - if (!src || !dest) - return E_POINTER; - - const uint8_t* pSrc = src->pixels; - uint8_t* pDest = dest->pixels; - - const size_t rowPitch = src->rowPitch; - - const size_t nwidth = (width > 1) ? (width >> 1) : 1; - const size_t nheight = (height > 1) ? (height >> 1) : 1; - - for (size_t y = 0; y < nheight; ++y) - { - if (!LoadScanlineLinear(urow0, width, pSrc, rowPitch, src->format, filter)) - return E_FAIL; - pSrc += rowPitch; - - if (urow0 != urow1) - { - if (!LoadScanlineLinear(urow1, width, pSrc, rowPitch, src->format, filter)) - return E_FAIL; - pSrc += rowPitch; - } - - for (size_t x = 0; x < nwidth; ++x) - { - const size_t x2 = x << 1; - - AVERAGE4(target[x], urow0[x2], urow1[x2], urow2[x2], urow3[x2]) - } - - if (!StoreScanlineLinear(pDest, dest->rowPitch, dest->format, target, nwidth, filter)) - return E_FAIL; - pDest += dest->rowPitch; - } - - if (height > 1) - height >>= 1; - - if (width > 1) - width >>= 1; - } - - return S_OK; - } - - - //--- 2D Linear Filter --- - HRESULT Generate2DMipsLinearFilter(size_t levels, TEX_FILTER_FLAGS filter, const ScratchImage& mipChain, size_t item) noexcept - { - using namespace DirectX::Filters; - - if (!mipChain.GetImages()) - return E_INVALIDARG; - - // This assumes that the base image is already placed into the mipChain at the top level... (see _Setup2DMips) - - assert(levels > 1); - - size_t width = mipChain.GetMetadata().width; - size_t height = mipChain.GetMetadata().height; - - // Allocate temporary space (3 scanlines, plus X and Y filters) - auto scanline = make_AlignedArrayXMVECTOR(uint64_t(width) * 3); - if (!scanline) - return E_OUTOFMEMORY; - - std::unique_ptr lf(new (std::nothrow) LinearFilter[width + height]); - if (!lf) - return E_OUTOFMEMORY; - - LinearFilter* lfX = lf.get(); - LinearFilter* lfY = lf.get() + width; - - XMVECTOR* target = scanline.get(); - - XMVECTOR* row0 = target + width; - XMVECTOR* row1 = target + width * 2; - - // Resize base image to each target mip level - for (size_t level = 1; level < levels; ++level) - { - // 2D linear filter - const Image* src = mipChain.GetImage(level - 1, item, 0); - const Image* dest = mipChain.GetImage(level, item, 0); - - if (!src || !dest) - return E_POINTER; - - const uint8_t* pSrc = src->pixels; - uint8_t* pDest = dest->pixels; - - const size_t rowPitch = src->rowPitch; - - const size_t nwidth = (width > 1) ? (width >> 1) : 1; - CreateLinearFilter(width, nwidth, (filter & TEX_FILTER_WRAP_U) != 0, lfX); - - const size_t nheight = (height > 1) ? (height >> 1) : 1; - CreateLinearFilter(height, nheight, (filter & TEX_FILTER_WRAP_V) != 0, lfY); - - #ifdef _DEBUG - memset(row0, 0xCD, sizeof(XMVECTOR)*width); - memset(row1, 0xDD, sizeof(XMVECTOR)*width); - #endif - - size_t u0 = size_t(-1); - size_t u1 = size_t(-1); - - for (size_t y = 0; y < nheight; ++y) - { - auto const& toY = lfY[y]; - - if (toY.u0 != u0) - { - if (toY.u0 != u1) - { - u0 = toY.u0; - - if (!LoadScanlineLinear(row0, width, pSrc + (rowPitch * u0), rowPitch, src->format, filter)) - return E_FAIL; - } - else - { - u0 = u1; - u1 = size_t(-1); - - std::swap(row0, row1); - } - } - - if (toY.u1 != u1) - { - u1 = toY.u1; - - if (!LoadScanlineLinear(row1, width, pSrc + (rowPitch * u1), rowPitch, src->format, filter)) - return E_FAIL; - } - - for (size_t x = 0; x < nwidth; ++x) - { - auto const& toX = lfX[x]; - - BILINEAR_INTERPOLATE(target[x], toX, toY, row0, row1) - } - - if (!StoreScanlineLinear(pDest, dest->rowPitch, dest->format, target, nwidth, filter)) - return E_FAIL; - pDest += dest->rowPitch; - } - - if (height > 1) - height >>= 1; - - if (width > 1) - width >>= 1; - } - - return S_OK; - } - - //--- 2D Cubic Filter --- -#ifdef __clang__ -#pragma clang diagnostic ignored "-Wextra-semi-stmt" -#endif - - HRESULT Generate2DMipsCubicFilter(size_t levels, TEX_FILTER_FLAGS filter, const ScratchImage& mipChain, size_t item) noexcept - { - using namespace DirectX::Filters; - - if (!mipChain.GetImages()) - return E_INVALIDARG; - - // This assumes that the base image is already placed into the mipChain at the top level... (see _Setup2DMips) - - assert(levels > 1); - - size_t width = mipChain.GetMetadata().width; - size_t height = mipChain.GetMetadata().height; - - // Allocate temporary space (5 scanlines, plus X and Y filters) - auto scanline = make_AlignedArrayXMVECTOR(uint64_t(width) * 5); - if (!scanline) - return E_OUTOFMEMORY; - - std::unique_ptr cf(new (std::nothrow) CubicFilter[width + height]); - if (!cf) - return E_OUTOFMEMORY; - - CubicFilter* cfX = cf.get(); - CubicFilter* cfY = cf.get() + width; - - XMVECTOR* target = scanline.get(); - - XMVECTOR* row0 = target + width; - XMVECTOR* row1 = target + width * 2; - XMVECTOR* row2 = target + width * 3; - XMVECTOR* row3 = target + width * 4; - - // Resize base image to each target mip level - for (size_t level = 1; level < levels; ++level) - { - // 2D cubic filter - const Image* src = mipChain.GetImage(level - 1, item, 0); - const Image* dest = mipChain.GetImage(level, item, 0); - - if (!src || !dest) - return E_POINTER; - - const uint8_t* pSrc = src->pixels; - uint8_t* pDest = dest->pixels; - - const size_t rowPitch = src->rowPitch; - - const size_t nwidth = (width > 1) ? (width >> 1) : 1; - CreateCubicFilter(width, nwidth, (filter & TEX_FILTER_WRAP_U) != 0, (filter & TEX_FILTER_MIRROR_U) != 0, cfX); - - const size_t nheight = (height > 1) ? (height >> 1) : 1; - CreateCubicFilter(height, nheight, (filter & TEX_FILTER_WRAP_V) != 0, (filter & TEX_FILTER_MIRROR_V) != 0, cfY); - - #ifdef _DEBUG - memset(row0, 0xCD, sizeof(XMVECTOR)*width); - memset(row1, 0xDD, sizeof(XMVECTOR)*width); - memset(row2, 0xED, sizeof(XMVECTOR)*width); - memset(row3, 0xFD, sizeof(XMVECTOR)*width); - #endif - - size_t u0 = size_t(-1); - size_t u1 = size_t(-1); - size_t u2 = size_t(-1); - size_t u3 = size_t(-1); - - for (size_t y = 0; y < nheight; ++y) - { - auto const& toY = cfY[y]; - - // Scanline 1 - if (toY.u0 != u0) - { - if (toY.u0 != u1 && toY.u0 != u2 && toY.u0 != u3) - { - u0 = toY.u0; - - if (!LoadScanlineLinear(row0, width, pSrc + (rowPitch * u0), rowPitch, src->format, filter)) - return E_FAIL; - } - else if (toY.u0 == u1) - { - u0 = u1; - u1 = size_t(-1); - - std::swap(row0, row1); - } - else if (toY.u0 == u2) - { - u0 = u2; - u2 = size_t(-1); - - std::swap(row0, row2); - } - else if (toY.u0 == u3) - { - u0 = u3; - u3 = size_t(-1); - - std::swap(row0, row3); - } - } - - // Scanline 2 - if (toY.u1 != u1) - { - if (toY.u1 != u2 && toY.u1 != u3) - { - u1 = toY.u1; - - if (!LoadScanlineLinear(row1, width, pSrc + (rowPitch * u1), rowPitch, src->format, filter)) - return E_FAIL; - } - else if (toY.u1 == u2) - { - u1 = u2; - u2 = size_t(-1); - - std::swap(row1, row2); - } - else if (toY.u1 == u3) - { - u1 = u3; - u3 = size_t(-1); - - std::swap(row1, row3); - } - } - - // Scanline 3 - if (toY.u2 != u2) - { - if (toY.u2 != u3) - { - u2 = toY.u2; - - if (!LoadScanlineLinear(row2, width, pSrc + (rowPitch * u2), rowPitch, src->format, filter)) - return E_FAIL; - } - else - { - u2 = u3; - u3 = size_t(-1); - - std::swap(row2, row3); - } - } - - // Scanline 4 - if (toY.u3 != u3) - { - u3 = toY.u3; - - if (!LoadScanlineLinear(row3, width, pSrc + (rowPitch * u3), rowPitch, src->format, filter)) - return E_FAIL; - } - - for (size_t x = 0; x < nwidth; ++x) - { - auto const& toX = cfX[x]; - - XMVECTOR C0, C1, C2, C3; - - CUBIC_INTERPOLATE(C0, toX.x, row0[toX.u0], row0[toX.u1], row0[toX.u2], row0[toX.u3]); - CUBIC_INTERPOLATE(C1, toX.x, row1[toX.u0], row1[toX.u1], row1[toX.u2], row1[toX.u3]); - CUBIC_INTERPOLATE(C2, toX.x, row2[toX.u0], row2[toX.u1], row2[toX.u2], row2[toX.u3]); - CUBIC_INTERPOLATE(C3, toX.x, row3[toX.u0], row3[toX.u1], row3[toX.u2], row3[toX.u3]); - - CUBIC_INTERPOLATE(target[x], toY.x, C0, C1, C2, C3); - } - - if (!StoreScanlineLinear(pDest, dest->rowPitch, dest->format, target, nwidth, filter)) - return E_FAIL; - pDest += dest->rowPitch; - } - - if (height > 1) - height >>= 1; - - if (width > 1) - width >>= 1; - } - - return S_OK; - } - - - //--- 2D Triangle Filter --- - HRESULT Generate2DMipsTriangleFilter(size_t levels, TEX_FILTER_FLAGS filter, const ScratchImage& mipChain, size_t item) noexcept - { - using namespace DirectX::Filters; - - if (!mipChain.GetImages()) - return E_INVALIDARG; - - // This assumes that the base image is already placed into the mipChain at the top level... (see _Setup2DMips) - - assert(levels > 1); - - size_t width = mipChain.GetMetadata().width; - size_t height = mipChain.GetMetadata().height; - - // Allocate initial temporary space (1 scanline, accumulation rows, plus X and Y filters) - auto scanline = make_AlignedArrayXMVECTOR(width); - if (!scanline) - return E_OUTOFMEMORY; - - std::unique_ptr rowActive(new (std::nothrow) TriangleRow[height]); - if (!rowActive) - return E_OUTOFMEMORY; - - TriangleRow * rowFree = nullptr; - - std::unique_ptr tfX, tfY; - - XMVECTOR* row = scanline.get(); - - // Resize base image to each target mip level - for (size_t level = 1; level < levels; ++level) - { - // 2D triangle filter - const Image* src = mipChain.GetImage(level - 1, item, 0); - const Image* dest = mipChain.GetImage(level, item, 0); - - if (!src || !dest) - return E_POINTER; - - const uint8_t* pSrc = src->pixels; - const size_t rowPitch = src->rowPitch; - const uint8_t* pEndSrc = pSrc + rowPitch * height; - - uint8_t* pDest = dest->pixels; - - const size_t nwidth = (width > 1) ? (width >> 1) : 1; - HRESULT hr = CreateTriangleFilter(width, nwidth, (filter & TEX_FILTER_WRAP_U) != 0, tfX); - if (FAILED(hr)) - return hr; - - const size_t nheight = (height > 1) ? (height >> 1) : 1; - hr = CreateTriangleFilter(height, nheight, (filter & TEX_FILTER_WRAP_V) != 0, tfY); - if (FAILED(hr)) - return hr; - - #ifdef _DEBUG - memset(row, 0xCD, sizeof(XMVECTOR)*width); - #endif - - auto xFromEnd = reinterpret_cast(reinterpret_cast(tfX.get()) + tfX->sizeInBytes); - auto yFromEnd = reinterpret_cast(reinterpret_cast(tfY.get()) + tfY->sizeInBytes); - - // Count times rows get written (and clear out any leftover accumulation rows from last miplevel) - for (FilterFrom* yFrom = tfY->from; yFrom < yFromEnd; ) - { - for (size_t j = 0; j < yFrom->count; ++j) - { - const size_t v = yFrom->to[j].u; - assert(v < nheight); - TriangleRow* rowAcc = &rowActive[v]; - - ++rowAcc->remaining; - - if (rowAcc->scanline) - { - memset(rowAcc->scanline.get(), 0, sizeof(XMVECTOR) * nwidth); - } - } - - yFrom = reinterpret_cast(reinterpret_cast(yFrom) + yFrom->sizeInBytes); - } - - // Filter image - for (FilterFrom* yFrom = tfY->from; yFrom < yFromEnd; ) - { - // Create accumulation rows as needed - for (size_t j = 0; j < yFrom->count; ++j) - { - const size_t v = yFrom->to[j].u; - assert(v < nheight); - TriangleRow* rowAcc = &rowActive[v]; - - if (!rowAcc->scanline) - { - if (rowFree) - { - // Steal and reuse scanline from 'free row' list - // (it will always be at least as wide as nwidth due to loop decending order) - assert(rowFree->scanline != nullptr); - rowAcc->scanline.reset(rowFree->scanline.release()); - rowFree = rowFree->next; - } - else - { - auto nscanline = make_AlignedArrayXMVECTOR(nwidth); - if (!nscanline) - return E_OUTOFMEMORY; - rowAcc->scanline.swap(nscanline); - } - - memset(rowAcc->scanline.get(), 0, sizeof(XMVECTOR) * nwidth); - } - } - - // Load source scanline - if ((pSrc + rowPitch) > pEndSrc) - return E_FAIL; - - if (!LoadScanlineLinear(row, width, pSrc, rowPitch, src->format, filter)) - return E_FAIL; - - pSrc += rowPitch; - - // Process row - size_t x = 0; - for (FilterFrom* xFrom = tfX->from; xFrom < xFromEnd; ++x) - { - for (size_t j = 0; j < yFrom->count; ++j) - { - const size_t v = yFrom->to[j].u; - assert(v < nheight); - const float yweight = yFrom->to[j].weight; - - XMVECTOR* accPtr = rowActive[v].scanline.get(); - if (!accPtr) - return E_POINTER; - - for (size_t k = 0; k < xFrom->count; ++k) - { - size_t u = xFrom->to[k].u; - assert(u < nwidth); - - const XMVECTOR weight = XMVectorReplicate(yweight * xFrom->to[k].weight); - - assert(x < width); - accPtr[u] = XMVectorMultiplyAdd(row[x], weight, accPtr[u]); - } - } - - xFrom = reinterpret_cast(reinterpret_cast(xFrom) + xFrom->sizeInBytes); - } - - // Write completed accumulation rows - for (size_t j = 0; j < yFrom->count; ++j) - { - size_t v = yFrom->to[j].u; - assert(v < nheight); - TriangleRow* rowAcc = &rowActive[v]; - - assert(rowAcc->remaining > 0); - --rowAcc->remaining; - - if (!rowAcc->remaining) - { - XMVECTOR* pAccSrc = rowAcc->scanline.get(); - if (!pAccSrc) - return E_POINTER; - - switch (dest->format) - { - case DXGI_FORMAT_R10G10B10A2_UNORM: - case DXGI_FORMAT_R10G10B10A2_UINT: - { - // Need to slightly bias results for floating-point error accumulation which can - // be visible with harshly quantized values - static const XMVECTORF32 Bias = { { { 0.f, 0.f, 0.f, 0.1f } } }; - - XMVECTOR* ptr = pAccSrc; - for (size_t i = 0; i < dest->width; ++i, ++ptr) - { - *ptr = XMVectorAdd(*ptr, Bias); - } - } - break; - - default: - break; - } - - // This performs any required clamping - if (!StoreScanlineLinear(pDest + (dest->rowPitch * v), dest->rowPitch, dest->format, pAccSrc, dest->width, filter)) - return E_FAIL; - - // Put row on freelist to reuse it's allocated scanline - rowAcc->next = rowFree; - rowFree = rowAcc; - } - } - - yFrom = reinterpret_cast(reinterpret_cast(yFrom) + yFrom->sizeInBytes); - } - - if (height > 1) - height >>= 1; - - if (width > 1) - width >>= 1; - } - - return S_OK; - } - - - //------------------------------------------------------------------------------------- - // Generate volume mip-map helpers - //------------------------------------------------------------------------------------- - HRESULT Setup3DMips( - _In_reads_(depth) const Image* baseImages, - size_t depth, - size_t levels, - _Out_ ScratchImage& mipChain) noexcept - { - if (!baseImages || !depth) - return E_INVALIDARG; - - assert(levels > 1); - - const size_t width = baseImages[0].width; - const size_t height = baseImages[0].height; - - HRESULT hr = mipChain.Initialize3D(baseImages[0].format, width, height, depth, levels); - if (FAILED(hr)) - return hr; - - // Copy base images to top slice - for (size_t slice = 0; slice < depth; ++slice) - { - const Image& src = baseImages[slice]; - - const Image *dest = mipChain.GetImage(0, 0, slice); - if (!dest) - { - mipChain.Release(); - return E_POINTER; - } - - assert(src.format == dest->format); - - uint8_t* pDest = dest->pixels; - if (!pDest) - { - mipChain.Release(); - return E_POINTER; - } - - const uint8_t *pSrc = src.pixels; - const size_t rowPitch = src.rowPitch; - for (size_t h = 0; h < height; ++h) - { - const size_t msize = std::min(dest->rowPitch, rowPitch); - memcpy(pDest, pSrc, msize); - pSrc += rowPitch; - pDest += dest->rowPitch; - } - } - - return S_OK; - } - - - //--- 3D Point Filter --- - HRESULT Generate3DMipsPointFilter(size_t depth, size_t levels, const ScratchImage& mipChain) noexcept - { - if (!depth || !mipChain.GetImages()) - return E_INVALIDARG; - - // This assumes that the base images are already placed into the mipChain at the top level... (see _Setup3DMips) - - assert(levels > 1); - - size_t width = mipChain.GetMetadata().width; - size_t height = mipChain.GetMetadata().height; - - // Allocate temporary space (2 scanlines) - auto scanline = make_AlignedArrayXMVECTOR(uint64_t(width) * 2); - if (!scanline) - return E_OUTOFMEMORY; - - XMVECTOR* target = scanline.get(); - - XMVECTOR* row = target + width; - - // Resize base image to each target mip level - for (size_t level = 1; level < levels; ++level) - { - #ifdef _DEBUG - memset(row, 0xCD, sizeof(XMVECTOR)*width); - #endif - - if (depth > 1) - { - // 3D point filter - const size_t ndepth = depth >> 1; - - const size_t zinc = (depth << 16) / ndepth; - - size_t sz = 0; - for (size_t slice = 0; slice < ndepth; ++slice) - { - const Image* src = mipChain.GetImage(level - 1, 0, (sz >> 16)); - const Image* dest = mipChain.GetImage(level, 0, slice); - - if (!src || !dest) - return E_POINTER; - - const uint8_t* pSrc = src->pixels; - uint8_t* pDest = dest->pixels; - - const size_t rowPitch = src->rowPitch; - - const size_t nwidth = (width > 1) ? (width >> 1) : 1; - const size_t nheight = (height > 1) ? (height >> 1) : 1; - - const size_t xinc = (width << 16) / nwidth; - const size_t yinc = (height << 16) / nheight; - - size_t lasty = size_t(-1); - - size_t sy = 0; - for (size_t y = 0; y < nheight; ++y) - { - if ((lasty ^ sy) >> 16) - { - if (!LoadScanline(row, width, pSrc + (rowPitch * (sy >> 16)), rowPitch, src->format)) - return E_FAIL; - lasty = sy; - } - - size_t sx = 0; - for (size_t x = 0; x < nwidth; ++x) - { - target[x] = row[sx >> 16]; - sx += xinc; - } - - if (!StoreScanline(pDest, dest->rowPitch, dest->format, target, nwidth)) - return E_FAIL; - pDest += dest->rowPitch; - - sy += yinc; - } - - sz += zinc; - } - } - else - { - // 2D point filter - const Image* src = mipChain.GetImage(level - 1, 0, 0); - const Image* dest = mipChain.GetImage(level, 0, 0); - - if (!src || !dest) - return E_POINTER; - - const uint8_t* pSrc = src->pixels; - uint8_t* pDest = dest->pixels; - - const size_t rowPitch = src->rowPitch; - - const size_t nwidth = (width > 1) ? (width >> 1) : 1; - const size_t nheight = (height > 1) ? (height >> 1) : 1; - - const size_t xinc = (width << 16) / nwidth; - const size_t yinc = (height << 16) / nheight; - - size_t lasty = size_t(-1); - - size_t sy = 0; - for (size_t y = 0; y < nheight; ++y) - { - if ((lasty ^ sy) >> 16) - { - if (!LoadScanline(row, width, pSrc + (rowPitch * (sy >> 16)), rowPitch, src->format)) - return E_FAIL; - lasty = sy; - } - - size_t sx = 0; - for (size_t x = 0; x < nwidth; ++x) - { - target[x] = row[sx >> 16]; - sx += xinc; - } - - if (!StoreScanline(pDest, dest->rowPitch, dest->format, target, nwidth)) - return E_FAIL; - pDest += dest->rowPitch; - - sy += yinc; - } - } - - if (height > 1) - height >>= 1; - - if (width > 1) - width >>= 1; - - if (depth > 1) - depth >>= 1; - } - - return S_OK; - } - - - //--- 3D Box Filter --- - HRESULT Generate3DMipsBoxFilter(size_t depth, size_t levels, TEX_FILTER_FLAGS filter, const ScratchImage& mipChain) noexcept - { - using namespace DirectX::Filters; - - if (!depth || !mipChain.GetImages()) - return E_INVALIDARG; - - // This assumes that the base images are already placed into the mipChain at the top level... (see _Setup3DMips) - - assert(levels > 1); - - size_t width = mipChain.GetMetadata().width; - size_t height = mipChain.GetMetadata().height; - - if (!ispow2(width) || !ispow2(height) || !ispow2(depth)) - return E_FAIL; - - // Allocate temporary space (5 scanlines) - auto scanline = make_AlignedArrayXMVECTOR(uint64_t(width) * 5); - if (!scanline) - return E_OUTOFMEMORY; - - XMVECTOR* target = scanline.get(); - - XMVECTOR* urow0 = target + width; - XMVECTOR* urow1 = target + width * 2; - XMVECTOR* vrow0 = target + width * 3; - XMVECTOR* vrow1 = target + width * 4; - - const XMVECTOR* urow2 = urow0 + 1; - const XMVECTOR* urow3 = urow1 + 1; - const XMVECTOR* vrow2 = vrow0 + 1; - const XMVECTOR* vrow3 = vrow1 + 1; - - // Resize base image to each target mip level - for (size_t level = 1; level < levels; ++level) - { - if (height <= 1) - { - urow1 = urow0; - vrow1 = vrow0; - } - - if (width <= 1) - { - urow2 = urow0; - urow3 = urow1; - vrow2 = vrow0; - vrow3 = vrow1; - } - - if (depth > 1) - { - // 3D box filter - const size_t ndepth = depth >> 1; - - for (size_t slice = 0; slice < ndepth; ++slice) - { - const size_t slicea = std::min(slice * 2, depth - 1); - const size_t sliceb = std::min(slicea + 1, depth - 1); - - const Image* srca = mipChain.GetImage(level - 1, 0, slicea); - const Image* srcb = mipChain.GetImage(level - 1, 0, sliceb); - const Image* dest = mipChain.GetImage(level, 0, slice); - - if (!srca || !srcb || !dest) - return E_POINTER; - - const uint8_t* pSrc1 = srca->pixels; - const uint8_t* pSrc2 = srcb->pixels; - uint8_t* pDest = dest->pixels; - - const size_t aRowPitch = srca->rowPitch; - const size_t bRowPitch = srcb->rowPitch; - - const size_t nwidth = (width > 1) ? (width >> 1) : 1; - const size_t nheight = (height > 1) ? (height >> 1) : 1; - - for (size_t y = 0; y < nheight; ++y) - { - if (!LoadScanlineLinear(urow0, width, pSrc1, aRowPitch, srca->format, filter)) - return E_FAIL; - pSrc1 += aRowPitch; - - if (urow0 != urow1) - { - if (!LoadScanlineLinear(urow1, width, pSrc1, aRowPitch, srca->format, filter)) - return E_FAIL; - pSrc1 += aRowPitch; - } - - if (!LoadScanlineLinear(vrow0, width, pSrc2, bRowPitch, srcb->format, filter)) - return E_FAIL; - pSrc2 += bRowPitch; - - if (vrow0 != vrow1) - { - if (!LoadScanlineLinear(vrow1, width, pSrc2, bRowPitch, srcb->format, filter)) - return E_FAIL; - pSrc2 += bRowPitch; - } - - for (size_t x = 0; x < nwidth; ++x) - { - const size_t x2 = x << 1; - - AVERAGE8(target[x], urow0[x2], urow1[x2], urow2[x2], urow3[x2], - vrow0[x2], vrow1[x2], vrow2[x2], vrow3[x2]) - } - - if (!StoreScanlineLinear(pDest, dest->rowPitch, dest->format, target, nwidth, filter)) - return E_FAIL; - pDest += dest->rowPitch; - } - } - } - else - { - // 2D box filter - const Image* src = mipChain.GetImage(level - 1, 0, 0); - const Image* dest = mipChain.GetImage(level, 0, 0); - - if (!src || !dest) - return E_POINTER; - - const uint8_t* pSrc = src->pixels; - uint8_t* pDest = dest->pixels; - - const size_t rowPitch = src->rowPitch; - - const size_t nwidth = (width > 1) ? (width >> 1) : 1; - const size_t nheight = (height > 1) ? (height >> 1) : 1; - - for (size_t y = 0; y < nheight; ++y) - { - if (!LoadScanlineLinear(urow0, width, pSrc, rowPitch, src->format, filter)) - return E_FAIL; - pSrc += rowPitch; - - if (urow0 != urow1) - { - if (!LoadScanlineLinear(urow1, width, pSrc, rowPitch, src->format, filter)) - return E_FAIL; - pSrc += rowPitch; - } - - for (size_t x = 0; x < nwidth; ++x) - { - const size_t x2 = x << 1; - - AVERAGE4(target[x], urow0[x2], urow1[x2], urow2[x2], urow3[x2]) - } - - if (!StoreScanlineLinear(pDest, dest->rowPitch, dest->format, target, nwidth, filter)) - return E_FAIL; - pDest += dest->rowPitch; - } - } - - if (height > 1) - height >>= 1; - - if (width > 1) - width >>= 1; - - if (depth > 1) - depth >>= 1; - } - - return S_OK; - } - - - //--- 3D Linear Filter --- - HRESULT Generate3DMipsLinearFilter(size_t depth, size_t levels, TEX_FILTER_FLAGS filter, const ScratchImage& mipChain) noexcept - { - using namespace DirectX::Filters; - - if (!depth || !mipChain.GetImages()) - return E_INVALIDARG; - - // This assumes that the base images are already placed into the mipChain at the top level... (see _Setup3DMips) - - assert(levels > 1); - - size_t width = mipChain.GetMetadata().width; - size_t height = mipChain.GetMetadata().height; - - // Allocate temporary space (5 scanlines, plus X/Y/Z filters) - auto scanline = make_AlignedArrayXMVECTOR(uint64_t(width) * 5); - if (!scanline) - return E_OUTOFMEMORY; - - std::unique_ptr lf(new (std::nothrow) LinearFilter[width + height + depth]); - if (!lf) - return E_OUTOFMEMORY; - - LinearFilter* lfX = lf.get(); - LinearFilter* lfY = lf.get() + width; - LinearFilter* lfZ = lf.get() + width + height; - - XMVECTOR* target = scanline.get(); - - XMVECTOR* urow0 = target + width; - XMVECTOR* urow1 = target + width * 2; - XMVECTOR* vrow0 = target + width * 3; - XMVECTOR* vrow1 = target + width * 4; - - // Resize base image to each target mip level - for (size_t level = 1; level < levels; ++level) - { - const size_t nwidth = (width > 1) ? (width >> 1) : 1; - CreateLinearFilter(width, nwidth, (filter & TEX_FILTER_WRAP_U) != 0, lfX); - - const size_t nheight = (height > 1) ? (height >> 1) : 1; - CreateLinearFilter(height, nheight, (filter & TEX_FILTER_WRAP_V) != 0, lfY); - - #ifdef _DEBUG - memset(urow0, 0xCD, sizeof(XMVECTOR)*width); - memset(urow1, 0xDD, sizeof(XMVECTOR)*width); - memset(vrow0, 0xED, sizeof(XMVECTOR)*width); - memset(vrow1, 0xFD, sizeof(XMVECTOR)*width); - #endif - - if (depth > 1) - { - // 3D linear filter - const size_t ndepth = depth >> 1; - CreateLinearFilter(depth, ndepth, (filter & TEX_FILTER_WRAP_W) != 0, lfZ); - - for (size_t slice = 0; slice < ndepth; ++slice) - { - auto const& toZ = lfZ[slice]; - - const Image* srca = mipChain.GetImage(level - 1, 0, toZ.u0); - const Image* srcb = mipChain.GetImage(level - 1, 0, toZ.u1); - if (!srca || !srcb) - return E_POINTER; - - size_t u0 = size_t(-1); - size_t u1 = size_t(-1); - - const Image* dest = mipChain.GetImage(level, 0, slice); - if (!dest) - return E_POINTER; - - uint8_t* pDest = dest->pixels; - - for (size_t y = 0; y < nheight; ++y) - { - auto const& toY = lfY[y]; - - if (toY.u0 != u0) - { - if (toY.u0 != u1) - { - u0 = toY.u0; - - if (!LoadScanlineLinear(urow0, width, srca->pixels + (srca->rowPitch * u0), srca->rowPitch, srca->format, filter) - || !LoadScanlineLinear(vrow0, width, srcb->pixels + (srcb->rowPitch * u0), srcb->rowPitch, srcb->format, filter)) - return E_FAIL; - } - else - { - u0 = u1; - u1 = size_t(-1); - - std::swap(urow0, urow1); - std::swap(vrow0, vrow1); - } - } - - if (toY.u1 != u1) - { - u1 = toY.u1; - - if (!LoadScanlineLinear(urow1, width, srca->pixels + (srca->rowPitch * u1), srca->rowPitch, srca->format, filter) - || !LoadScanlineLinear(vrow1, width, srcb->pixels + (srcb->rowPitch * u1), srcb->rowPitch, srcb->format, filter)) - return E_FAIL; - } - - for (size_t x = 0; x < nwidth; ++x) - { - auto const& toX = lfX[x]; - - TRILINEAR_INTERPOLATE(target[x], toX, toY, toZ, urow0, urow1, vrow0, vrow1) - } - - if (!StoreScanlineLinear(pDest, dest->rowPitch, dest->format, target, nwidth, filter)) - return E_FAIL; - pDest += dest->rowPitch; - } - } - } - else - { - // 2D linear filter - const Image* src = mipChain.GetImage(level - 1, 0, 0); - const Image* dest = mipChain.GetImage(level, 0, 0); - - if (!src || !dest) - return E_POINTER; - - const uint8_t* pSrc = src->pixels; - uint8_t* pDest = dest->pixels; - - const size_t rowPitch = src->rowPitch; - - size_t u0 = size_t(-1); - size_t u1 = size_t(-1); - - for (size_t y = 0; y < nheight; ++y) - { - auto const& toY = lfY[y]; - - if (toY.u0 != u0) - { - if (toY.u0 != u1) - { - u0 = toY.u0; - - if (!LoadScanlineLinear(urow0, width, pSrc + (rowPitch * u0), rowPitch, src->format, filter)) - return E_FAIL; - } - else - { - u0 = u1; - u1 = size_t(-1); - - std::swap(urow0, urow1); - } - } - - if (toY.u1 != u1) - { - u1 = toY.u1; - - if (!LoadScanlineLinear(urow1, width, pSrc + (rowPitch * u1), rowPitch, src->format, filter)) - return E_FAIL; - } - - for (size_t x = 0; x < nwidth; ++x) - { - auto const& toX = lfX[x]; - - BILINEAR_INTERPOLATE(target[x], toX, toY, urow0, urow1) - } - - if (!StoreScanlineLinear(pDest, dest->rowPitch, dest->format, target, nwidth, filter)) - return E_FAIL; - pDest += dest->rowPitch; - } - } - - if (height > 1) - height >>= 1; - - if (width > 1) - width >>= 1; - - if (depth > 1) - depth >>= 1; - } - - return S_OK; - } - - - //--- 3D Cubic Filter --- - HRESULT Generate3DMipsCubicFilter(size_t depth, size_t levels, TEX_FILTER_FLAGS filter, const ScratchImage& mipChain) noexcept - { - using namespace DirectX::Filters; - - if (!depth || !mipChain.GetImages()) - return E_INVALIDARG; - - // This assumes that the base images are already placed into the mipChain at the top level... (see _Setup3DMips) - - assert(levels > 1); - - size_t width = mipChain.GetMetadata().width; - size_t height = mipChain.GetMetadata().height; - - // Allocate temporary space (17 scanlines, plus X/Y/Z filters) - auto scanline = make_AlignedArrayXMVECTOR(uint64_t(width) * 17); - if (!scanline) - return E_OUTOFMEMORY; - - std::unique_ptr cf(new (std::nothrow) CubicFilter[width + height + depth]); - if (!cf) - return E_OUTOFMEMORY; - - CubicFilter* cfX = cf.get(); - CubicFilter* cfY = cf.get() + width; - CubicFilter* cfZ = cf.get() + width + height; - - XMVECTOR* target = scanline.get(); - - XMVECTOR* urow[4]; - XMVECTOR* vrow[4]; - XMVECTOR* srow[4]; - XMVECTOR* trow[4]; - - XMVECTOR *ptr = scanline.get() + width; - for (size_t j = 0; j < 4; ++j) - { - urow[j] = ptr; ptr += width; - vrow[j] = ptr; ptr += width; - srow[j] = ptr; ptr += width; - trow[j] = ptr; ptr += width; - } - - // Resize base image to each target mip level - for (size_t level = 1; level < levels; ++level) - { - const size_t nwidth = (width > 1) ? (width >> 1) : 1; - CreateCubicFilter(width, nwidth, (filter & TEX_FILTER_WRAP_U) != 0, (filter & TEX_FILTER_MIRROR_U) != 0, cfX); - - const size_t nheight = (height > 1) ? (height >> 1) : 1; - CreateCubicFilter(height, nheight, (filter & TEX_FILTER_WRAP_V) != 0, (filter & TEX_FILTER_MIRROR_V) != 0, cfY); - - #ifdef _DEBUG - for (size_t j = 0; j < 4; ++j) - { - memset(urow[j], 0xCD, sizeof(XMVECTOR)*width); - memset(vrow[j], 0xDD, sizeof(XMVECTOR)*width); - memset(srow[j], 0xED, sizeof(XMVECTOR)*width); - memset(trow[j], 0xFD, sizeof(XMVECTOR)*width); - } - #endif - - if (depth > 1) - { - // 3D cubic filter - const size_t ndepth = depth >> 1; - CreateCubicFilter(depth, ndepth, (filter & TEX_FILTER_WRAP_W) != 0, (filter & TEX_FILTER_MIRROR_W) != 0, cfZ); - - for (size_t slice = 0; slice < ndepth; ++slice) - { - auto const& toZ = cfZ[slice]; - - const Image* srca = mipChain.GetImage(level - 1, 0, toZ.u0); - const Image* srcb = mipChain.GetImage(level - 1, 0, toZ.u1); - const Image* srcc = mipChain.GetImage(level - 1, 0, toZ.u2); - const Image* srcd = mipChain.GetImage(level - 1, 0, toZ.u3); - if (!srca || !srcb || !srcc || !srcd) - return E_POINTER; - - size_t u0 = size_t(-1); - size_t u1 = size_t(-1); - size_t u2 = size_t(-1); - size_t u3 = size_t(-1); - - const Image* dest = mipChain.GetImage(level, 0, slice); - if (!dest) - return E_POINTER; - - uint8_t* pDest = dest->pixels; - - for (size_t y = 0; y < nheight; ++y) - { - auto const& toY = cfY[y]; - - // Scanline 1 - if (toY.u0 != u0) - { - if (toY.u0 != u1 && toY.u0 != u2 && toY.u0 != u3) - { - u0 = toY.u0; - - if (!LoadScanlineLinear(urow[0], width, srca->pixels + (srca->rowPitch * u0), srca->rowPitch, srca->format, filter) - || !LoadScanlineLinear(urow[1], width, srcb->pixels + (srcb->rowPitch * u0), srcb->rowPitch, srcb->format, filter) - || !LoadScanlineLinear(urow[2], width, srcc->pixels + (srcc->rowPitch * u0), srcc->rowPitch, srcc->format, filter) - || !LoadScanlineLinear(urow[3], width, srcd->pixels + (srcd->rowPitch * u0), srcd->rowPitch, srcd->format, filter)) - return E_FAIL; - } - else if (toY.u0 == u1) - { - u0 = u1; - u1 = size_t(-1); - - std::swap(urow[0], vrow[0]); - std::swap(urow[1], vrow[1]); - std::swap(urow[2], vrow[2]); - std::swap(urow[3], vrow[3]); - } - else if (toY.u0 == u2) - { - u0 = u2; - u2 = size_t(-1); - - std::swap(urow[0], srow[0]); - std::swap(urow[1], srow[1]); - std::swap(urow[2], srow[2]); - std::swap(urow[3], srow[3]); - } - else if (toY.u0 == u3) - { - u0 = u3; - u3 = size_t(-1); - - std::swap(urow[0], trow[0]); - std::swap(urow[1], trow[1]); - std::swap(urow[2], trow[2]); - std::swap(urow[3], trow[3]); - } - } - - // Scanline 2 - if (toY.u1 != u1) - { - if (toY.u1 != u2 && toY.u1 != u3) - { - u1 = toY.u1; - - if (!LoadScanlineLinear(vrow[0], width, srca->pixels + (srca->rowPitch * u1), srca->rowPitch, srca->format, filter) - || !LoadScanlineLinear(vrow[1], width, srcb->pixels + (srcb->rowPitch * u1), srcb->rowPitch, srcb->format, filter) - || !LoadScanlineLinear(vrow[2], width, srcc->pixels + (srcc->rowPitch * u1), srcc->rowPitch, srcc->format, filter) - || !LoadScanlineLinear(vrow[3], width, srcd->pixels + (srcd->rowPitch * u1), srcd->rowPitch, srcd->format, filter)) - return E_FAIL; - } - else if (toY.u1 == u2) - { - u1 = u2; - u2 = size_t(-1); - - std::swap(vrow[0], srow[0]); - std::swap(vrow[1], srow[1]); - std::swap(vrow[2], srow[2]); - std::swap(vrow[3], srow[3]); - } - else if (toY.u1 == u3) - { - u1 = u3; - u3 = size_t(-1); - - std::swap(vrow[0], trow[0]); - std::swap(vrow[1], trow[1]); - std::swap(vrow[2], trow[2]); - std::swap(vrow[3], trow[3]); - } - } - - // Scanline 3 - if (toY.u2 != u2) - { - if (toY.u2 != u3) - { - u2 = toY.u2; - - if (!LoadScanlineLinear(srow[0], width, srca->pixels + (srca->rowPitch * u2), srca->rowPitch, srca->format, filter) - || !LoadScanlineLinear(srow[1], width, srcb->pixels + (srcb->rowPitch * u2), srcb->rowPitch, srcb->format, filter) - || !LoadScanlineLinear(srow[2], width, srcc->pixels + (srcc->rowPitch * u2), srcc->rowPitch, srcc->format, filter) - || !LoadScanlineLinear(srow[3], width, srcd->pixels + (srcd->rowPitch * u2), srcd->rowPitch, srcd->format, filter)) - return E_FAIL; - } - else - { - u2 = u3; - u3 = size_t(-1); - - std::swap(srow[0], trow[0]); - std::swap(srow[1], trow[1]); - std::swap(srow[2], trow[2]); - std::swap(srow[3], trow[3]); - } - } - - // Scanline 4 - if (toY.u3 != u3) - { - u3 = toY.u3; - - if (!LoadScanlineLinear(trow[0], width, srca->pixels + (srca->rowPitch * u3), srca->rowPitch, srca->format, filter) - || !LoadScanlineLinear(trow[1], width, srcb->pixels + (srcb->rowPitch * u3), srcb->rowPitch, srcb->format, filter) - || !LoadScanlineLinear(trow[2], width, srcc->pixels + (srcc->rowPitch * u3), srcc->rowPitch, srcc->format, filter) - || !LoadScanlineLinear(trow[3], width, srcd->pixels + (srcd->rowPitch * u3), srcd->rowPitch, srcd->format, filter)) - return E_FAIL; - } - - for (size_t x = 0; x < nwidth; ++x) - { - auto const& toX = cfX[x]; - - XMVECTOR D[4]; - - for (size_t j = 0; j < 4; ++j) - { - XMVECTOR C0, C1, C2, C3; - CUBIC_INTERPOLATE(C0, toX.x, urow[j][toX.u0], urow[j][toX.u1], urow[j][toX.u2], urow[j][toX.u3]); - CUBIC_INTERPOLATE(C1, toX.x, vrow[j][toX.u0], vrow[j][toX.u1], vrow[j][toX.u2], vrow[j][toX.u3]); - CUBIC_INTERPOLATE(C2, toX.x, srow[j][toX.u0], srow[j][toX.u1], srow[j][toX.u2], srow[j][toX.u3]); - CUBIC_INTERPOLATE(C3, toX.x, trow[j][toX.u0], trow[j][toX.u1], trow[j][toX.u2], trow[j][toX.u3]); - - CUBIC_INTERPOLATE(D[j], toY.x, C0, C1, C2, C3); - } - - CUBIC_INTERPOLATE(target[x], toZ.x, D[0], D[1], D[2], D[3]); - } - - if (!StoreScanlineLinear(pDest, dest->rowPitch, dest->format, target, nwidth, filter)) - return E_FAIL; - pDest += dest->rowPitch; - } - } - } - else - { - // 2D cubic filter - const Image* src = mipChain.GetImage(level - 1, 0, 0); - const Image* dest = mipChain.GetImage(level, 0, 0); - - if (!src || !dest) - return E_POINTER; - - const uint8_t* pSrc = src->pixels; - uint8_t* pDest = dest->pixels; - - const size_t rowPitch = src->rowPitch; - - size_t u0 = size_t(-1); - size_t u1 = size_t(-1); - size_t u2 = size_t(-1); - size_t u3 = size_t(-1); - - for (size_t y = 0; y < nheight; ++y) - { - auto const& toY = cfY[y]; - - // Scanline 1 - if (toY.u0 != u0) - { - if (toY.u0 != u1 && toY.u0 != u2 && toY.u0 != u3) - { - u0 = toY.u0; - - if (!LoadScanlineLinear(urow[0], width, pSrc + (rowPitch * u0), rowPitch, src->format, filter)) - return E_FAIL; - } - else if (toY.u0 == u1) - { - u0 = u1; - u1 = size_t(-1); - - std::swap(urow[0], vrow[0]); - } - else if (toY.u0 == u2) - { - u0 = u2; - u2 = size_t(-1); - - std::swap(urow[0], srow[0]); - } - else if (toY.u0 == u3) - { - u0 = u3; - u3 = size_t(-1); - - std::swap(urow[0], trow[0]); - } - } - - // Scanline 2 - if (toY.u1 != u1) - { - if (toY.u1 != u2 && toY.u1 != u3) - { - u1 = toY.u1; - - if (!LoadScanlineLinear(vrow[0], width, pSrc + (rowPitch * u1), rowPitch, src->format, filter)) - return E_FAIL; - } - else if (toY.u1 == u2) - { - u1 = u2; - u2 = size_t(-1); - - std::swap(vrow[0], srow[0]); - } - else if (toY.u1 == u3) - { - u1 = u3; - u3 = size_t(-1); - - std::swap(vrow[0], trow[0]); - } - } - - // Scanline 3 - if (toY.u2 != u2) - { - if (toY.u2 != u3) - { - u2 = toY.u2; - - if (!LoadScanlineLinear(srow[0], width, pSrc + (rowPitch * u2), rowPitch, src->format, filter)) - return E_FAIL; - } - else - { - u2 = u3; - u3 = size_t(-1); - - std::swap(srow[0], trow[0]); - } - } - - // Scanline 4 - if (toY.u3 != u3) - { - u3 = toY.u3; - - if (!LoadScanlineLinear(trow[0], width, pSrc + (rowPitch * u3), rowPitch, src->format, filter)) - return E_FAIL; - } - - for (size_t x = 0; x < nwidth; ++x) - { - auto const& toX = cfX[x]; - - XMVECTOR C0, C1, C2, C3; - CUBIC_INTERPOLATE(C0, toX.x, urow[0][toX.u0], urow[0][toX.u1], urow[0][toX.u2], urow[0][toX.u3]); - CUBIC_INTERPOLATE(C1, toX.x, vrow[0][toX.u0], vrow[0][toX.u1], vrow[0][toX.u2], vrow[0][toX.u3]); - CUBIC_INTERPOLATE(C2, toX.x, srow[0][toX.u0], srow[0][toX.u1], srow[0][toX.u2], srow[0][toX.u3]); - CUBIC_INTERPOLATE(C3, toX.x, trow[0][toX.u0], trow[0][toX.u1], trow[0][toX.u2], trow[0][toX.u3]); - - CUBIC_INTERPOLATE(target[x], toY.x, C0, C1, C2, C3); - } - - if (!StoreScanlineLinear(pDest, dest->rowPitch, dest->format, target, nwidth, filter)) - return E_FAIL; - pDest += dest->rowPitch; - } - } - - if (height > 1) - height >>= 1; - - if (width > 1) - width >>= 1; - - if (depth > 1) - depth >>= 1; - } - - return S_OK; - } - - - //--- 3D Triangle Filter --- - HRESULT Generate3DMipsTriangleFilter(size_t depth, size_t levels, TEX_FILTER_FLAGS filter, const ScratchImage& mipChain) noexcept - { - using namespace DirectX::Filters; - - if (!depth || !mipChain.GetImages()) - return E_INVALIDARG; - - // This assumes that the base images are already placed into the mipChain at the top level... (see _Setup3DMips) - - assert(levels > 1); - - size_t width = mipChain.GetMetadata().width; - size_t height = mipChain.GetMetadata().height; - - // Allocate initial temporary space (1 scanline, accumulation rows, plus X/Y/Z filters) - auto scanline = make_AlignedArrayXMVECTOR(width); - if (!scanline) - return E_OUTOFMEMORY; - - std::unique_ptr sliceActive(new (std::nothrow) TriangleRow[depth]); - if (!sliceActive) - return E_OUTOFMEMORY; - - TriangleRow * sliceFree = nullptr; - - std::unique_ptr tfX, tfY, tfZ; - - XMVECTOR* row = scanline.get(); - - // Resize base image to each target mip level - for (size_t level = 1; level < levels; ++level) - { - const size_t nwidth = (width > 1) ? (width >> 1) : 1; - HRESULT hr = CreateTriangleFilter(width, nwidth, (filter & TEX_FILTER_WRAP_U) != 0, tfX); - if (FAILED(hr)) - return hr; - - const size_t nheight = (height > 1) ? (height >> 1) : 1; - hr = CreateTriangleFilter(height, nheight, (filter & TEX_FILTER_WRAP_V) != 0, tfY); - if (FAILED(hr)) - return hr; - - const size_t ndepth = (depth > 1) ? (depth >> 1) : 1; - hr = CreateTriangleFilter(depth, ndepth, (filter & TEX_FILTER_WRAP_W) != 0, tfZ); - if (FAILED(hr)) - return hr; - - #ifdef _DEBUG - memset(row, 0xCD, sizeof(XMVECTOR)*width); - #endif - - auto xFromEnd = reinterpret_cast(reinterpret_cast(tfX.get()) + tfX->sizeInBytes); - auto yFromEnd = reinterpret_cast(reinterpret_cast(tfY.get()) + tfY->sizeInBytes); - auto zFromEnd = reinterpret_cast(reinterpret_cast(tfZ.get()) + tfZ->sizeInBytes); - - // Count times slices get written (and clear out any leftover accumulation slices from last miplevel) - for (FilterFrom* zFrom = tfZ->from; zFrom < zFromEnd; ) - { - for (size_t j = 0; j < zFrom->count; ++j) - { - const size_t w = zFrom->to[j].u; - assert(w < ndepth); - TriangleRow* sliceAcc = &sliceActive[w]; - - ++sliceAcc->remaining; - - if (sliceAcc->scanline) - { - memset(sliceAcc->scanline.get(), 0, sizeof(XMVECTOR) * nwidth * nheight); - } - } - - zFrom = reinterpret_cast(reinterpret_cast(zFrom) + zFrom->sizeInBytes); - } - - // Filter image - size_t z = 0; - for (FilterFrom* zFrom = tfZ->from; zFrom < zFromEnd; ++z) - { - // Create accumulation slices as needed - for (size_t j = 0; j < zFrom->count; ++j) - { - const size_t w = zFrom->to[j].u; - assert(w < ndepth); - TriangleRow* sliceAcc = &sliceActive[w]; - - if (!sliceAcc->scanline) - { - if (sliceFree) - { - // Steal and reuse scanline from 'free slice' list - // (it will always be at least as large as nwidth*nheight due to loop decending order) - assert(sliceFree->scanline != nullptr); - sliceAcc->scanline.reset(sliceFree->scanline.release()); - sliceFree = sliceFree->next; - } - else - { - auto nscanline = make_AlignedArrayXMVECTOR(uint64_t(nwidth) * uint64_t(nheight)); - if (!nscanline) - return E_OUTOFMEMORY; - sliceAcc->scanline.swap(nscanline); - } - - memset(sliceAcc->scanline.get(), 0, sizeof(XMVECTOR) * nwidth * nheight); - } - } - - assert(z < depth); - const Image* src = mipChain.GetImage(level - 1, 0, z); - if (!src) - return E_POINTER; - - const uint8_t* pSrc = src->pixels; - const size_t rowPitch = src->rowPitch; - const uint8_t* pEndSrc = pSrc + rowPitch * height; - - for (FilterFrom* yFrom = tfY->from; yFrom < yFromEnd; ) - { - // Load source scanline - if ((pSrc + rowPitch) > pEndSrc) - return E_FAIL; - - if (!LoadScanlineLinear(row, width, pSrc, rowPitch, src->format, filter)) - return E_FAIL; - - pSrc += rowPitch; - - // Process row - size_t x = 0; - for (FilterFrom* xFrom = tfX->from; xFrom < xFromEnd; ++x) - { - for (size_t j = 0; j < zFrom->count; ++j) - { - const size_t w = zFrom->to[j].u; - assert(w < ndepth); - const float zweight = zFrom->to[j].weight; - - XMVECTOR* accSlice = sliceActive[w].scanline.get(); - if (!accSlice) - return E_POINTER; - - for (size_t k = 0; k < yFrom->count; ++k) - { - size_t v = yFrom->to[k].u; - assert(v < nheight); - const float yweight = yFrom->to[k].weight; - - XMVECTOR * accPtr = accSlice + v * nwidth; - - for (size_t l = 0; l < xFrom->count; ++l) - { - size_t u = xFrom->to[l].u; - assert(u < nwidth); - - const XMVECTOR weight = XMVectorReplicate(zweight * yweight * xFrom->to[l].weight); - - assert(x < width); - accPtr[u] = XMVectorMultiplyAdd(row[x], weight, accPtr[u]); - } - } - } - - xFrom = reinterpret_cast(reinterpret_cast(xFrom) + xFrom->sizeInBytes); - } - - yFrom = reinterpret_cast(reinterpret_cast(yFrom) + yFrom->sizeInBytes); - } - - // Write completed accumulation slices - for (size_t j = 0; j < zFrom->count; ++j) - { - const size_t w = zFrom->to[j].u; - assert(w < ndepth); - TriangleRow* sliceAcc = &sliceActive[w]; - - assert(sliceAcc->remaining > 0); - --sliceAcc->remaining; - - if (!sliceAcc->remaining) - { - const Image* dest = mipChain.GetImage(level, 0, w); - XMVECTOR* pAccSrc = sliceAcc->scanline.get(); - if (!dest || !pAccSrc) - return E_POINTER; - - uint8_t* pDest = dest->pixels; - - for (size_t h = 0; h < nheight; ++h) - { - switch (dest->format) - { - case DXGI_FORMAT_R10G10B10A2_UNORM: - case DXGI_FORMAT_R10G10B10A2_UINT: - { - // Need to slightly bias results for floating-point error accumulation which can - // be visible with harshly quantized values - static const XMVECTORF32 Bias = { { { 0.f, 0.f, 0.f, 0.1f } } }; - - XMVECTOR* ptr = pAccSrc; - for (size_t i = 0; i < dest->width; ++i, ++ptr) - { - *ptr = XMVectorAdd(*ptr, Bias); - } - } - break; - - default: - break; - } - - // This performs any required clamping - if (!StoreScanlineLinear(pDest, dest->rowPitch, dest->format, pAccSrc, dest->width, filter)) - return E_FAIL; - - pDest += dest->rowPitch; - pAccSrc += nwidth; - } - - // Put slice on freelist to reuse it's allocated scanline - sliceAcc->next = sliceFree; - sliceFree = sliceAcc; - } - } - - zFrom = reinterpret_cast(reinterpret_cast(zFrom) + zFrom->sizeInBytes); - } - - if (height > 1) - height >>= 1; - - if (width > 1) - width >>= 1; - - if (depth > 1) - depth >>= 1; - } - - return S_OK; - } -} - - -//===================================================================================== -// Entry-points -//===================================================================================== - -//------------------------------------------------------------------------------------- -// Generate mipmap chain -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::GenerateMipMaps( - const Image& baseImage, - TEX_FILTER_FLAGS filter, - size_t levels, - ScratchImage& mipChain, - bool allow1D) noexcept -{ - if (!IsValid(baseImage.format)) - return E_INVALIDARG; - - if (!baseImage.pixels) - return E_POINTER; - - if (!CalculateMipLevels(baseImage.width, baseImage.height, levels)) - return E_INVALIDARG; - - if (levels <= 1) - return E_INVALIDARG; - - if (IsCompressed(baseImage.format) || IsTypeless(baseImage.format) || IsPlanar(baseImage.format) || IsPalettized(baseImage.format)) - { - return HRESULT_E_NOT_SUPPORTED; - } - - HRESULT hr = E_UNEXPECTED; - - static_assert(TEX_FILTER_POINT == 0x100000, "TEX_FILTER_ flag values don't match TEX_FILTER_MODE_MASK"); - -#ifdef _WIN32 - bool usewic = UseWICFiltering(baseImage.format, filter); - - WICPixelFormatGUID pfGUID = {}; - const bool wicpf = (usewic) ? DXGIToWIC(baseImage.format, pfGUID, true) : false; - - if (usewic && !wicpf) - { - // Check to see if the source and/or result size is too big for WIC - const uint64_t expandedSize = uint64_t(std::max(1, baseImage.width >> 1)) * uint64_t(std::max(1, baseImage.height >> 1)) * sizeof(float) * 4; - const uint64_t expandedSize2 = uint64_t(baseImage.width) * uint64_t(baseImage.height) * sizeof(float) * 4; - if (expandedSize > UINT32_MAX || expandedSize2 > UINT32_MAX) - { - if (filter & TEX_FILTER_FORCE_WIC) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - usewic = false; - } - } - - if (usewic) - { - //--- Use WIC filtering to generate mipmaps ----------------------------------- - switch (filter & TEX_FILTER_MODE_MASK) - { - case 0: - case TEX_FILTER_POINT: - case TEX_FILTER_FANT: // Equivalent to Box filter - case TEX_FILTER_LINEAR: - case TEX_FILTER_CUBIC: - { - static_assert(TEX_FILTER_FANT == TEX_FILTER_BOX, "TEX_FILTER_ flag alias mismatch"); - - if (wicpf) - { - // Case 1: Base image format is supported by Windows Imaging Component - hr = (baseImage.height > 1 || !allow1D) - ? mipChain.Initialize2D(baseImage.format, baseImage.width, baseImage.height, 1, levels) - : mipChain.Initialize1D(baseImage.format, baseImage.width, 1, levels); - if (FAILED(hr)) - return hr; - - return GenerateMipMapsUsingWIC(baseImage, filter, levels, pfGUID, mipChain, 0); - } - else - { - // Case 2: Base image format is not supported by WIC, so we have to convert, generate, and convert back - assert(baseImage.format != DXGI_FORMAT_R32G32B32A32_FLOAT); - ScratchImage temp; - hr = ConvertToR32G32B32A32(baseImage, temp); - if (FAILED(hr)) - return hr; - - const Image *timg = temp.GetImage(0, 0, 0); - if (!timg) - return E_POINTER; - - ScratchImage tMipChain; - hr = (baseImage.height > 1 || !allow1D) - ? tMipChain.Initialize2D(DXGI_FORMAT_R32G32B32A32_FLOAT, baseImage.width, baseImage.height, 1, levels) - : tMipChain.Initialize1D(DXGI_FORMAT_R32G32B32A32_FLOAT, baseImage.width, 1, levels); - if (FAILED(hr)) - return hr; - - hr = GenerateMipMapsUsingWIC(*timg, filter, levels, GUID_WICPixelFormat128bppRGBAFloat, tMipChain, 0); - if (FAILED(hr)) - return hr; - - temp.Release(); - - return ConvertFromR32G32B32A32(tMipChain.GetImages(), tMipChain.GetImageCount(), tMipChain.GetMetadata(), baseImage.format, mipChain); - } - } - - default: - return HRESULT_E_NOT_SUPPORTED; - } - } - else - #endif // WIN32 - { - //--- Use custom filters to generate mipmaps ---------------------------------- - TexMetadata mdata = {}; - mdata.width = baseImage.width; - if (baseImage.height > 1 || !allow1D) - { - mdata.height = baseImage.height; - mdata.dimension = TEX_DIMENSION_TEXTURE2D; - } - else - { - mdata.height = 1; - mdata.dimension = TEX_DIMENSION_TEXTURE1D; - } - mdata.depth = mdata.arraySize = 1; - mdata.mipLevels = levels; - mdata.format = baseImage.format; - - unsigned long filter_select = (filter & TEX_FILTER_MODE_MASK); - if (!filter_select) - { - // Default filter choice - filter_select = (ispow2(baseImage.width) && ispow2(baseImage.height)) ? TEX_FILTER_BOX : TEX_FILTER_LINEAR; - } - - switch (filter_select) - { - case TEX_FILTER_BOX: - hr = Setup2DMips(&baseImage, 1, mdata, mipChain); - if (FAILED(hr)) - return hr; - - hr = Generate2DMipsBoxFilter(levels, filter, mipChain, 0); - if (FAILED(hr)) - mipChain.Release(); - return hr; - - case TEX_FILTER_POINT: - hr = Setup2DMips(&baseImage, 1, mdata, mipChain); - if (FAILED(hr)) - return hr; - - hr = Generate2DMipsPointFilter(levels, mipChain, 0); - if (FAILED(hr)) - mipChain.Release(); - return hr; - - case TEX_FILTER_LINEAR: - hr = Setup2DMips(&baseImage, 1, mdata, mipChain); - if (FAILED(hr)) - return hr; - - hr = Generate2DMipsLinearFilter(levels, filter, mipChain, 0); - if (FAILED(hr)) - mipChain.Release(); - return hr; - - case TEX_FILTER_CUBIC: - hr = Setup2DMips(&baseImage, 1, mdata, mipChain); - if (FAILED(hr)) - return hr; - - hr = Generate2DMipsCubicFilter(levels, filter, mipChain, 0); - if (FAILED(hr)) - mipChain.Release(); - return hr; - - case TEX_FILTER_TRIANGLE: - hr = Setup2DMips(&baseImage, 1, mdata, mipChain); - if (FAILED(hr)) - return hr; - - hr = Generate2DMipsTriangleFilter(levels, filter, mipChain, 0); - if (FAILED(hr)) - mipChain.Release(); - return hr; - - default: - return HRESULT_E_NOT_SUPPORTED; - } - } -} - -_Use_decl_annotations_ -HRESULT DirectX::GenerateMipMaps( - const Image* srcImages, - size_t nimages, - const TexMetadata& metadata, - TEX_FILTER_FLAGS filter, - size_t levels, - ScratchImage& mipChain) -{ - if (!srcImages || !nimages || !IsValid(metadata.format)) - return E_INVALIDARG; - - if (metadata.IsVolumemap() - || IsCompressed(metadata.format) || IsTypeless(metadata.format) || IsPlanar(metadata.format) || IsPalettized(metadata.format)) - return HRESULT_E_NOT_SUPPORTED; - - if (!CalculateMipLevels(metadata.width, metadata.height, levels)) - return E_INVALIDARG; - - if (levels <= 1) - return E_INVALIDARG; - - std::vector baseImages; - baseImages.reserve(metadata.arraySize); - for (size_t item = 0; item < metadata.arraySize; ++item) - { - const size_t index = metadata.ComputeIndex(0, item, 0); - if (index >= nimages) - return E_FAIL; - - const Image& src = srcImages[index]; - if (!src.pixels) - return E_POINTER; - - if (src.format != metadata.format || src.width != metadata.width || src.height != metadata.height) - { - // All base images must be the same format, width, and height - return E_FAIL; - } - - baseImages.push_back(src); - } - - assert(baseImages.size() == metadata.arraySize); - - HRESULT hr = E_UNEXPECTED; - - if (baseImages.empty()) - return hr; - - static_assert(TEX_FILTER_POINT == 0x100000, "TEX_FILTER_ flag values don't match TEX_FILTER_MODE_MASK"); - -#ifdef _WIN32 - bool usewic = !metadata.IsPMAlpha() && UseWICFiltering(metadata.format, filter); - - WICPixelFormatGUID pfGUID = {}; - const bool wicpf = (usewic) ? DXGIToWIC(metadata.format, pfGUID, true) : false; - - if (usewic && !wicpf) - { - // Check to see if the source and/or result size is too big for WIC - const uint64_t expandedSize = uint64_t(std::max(1, metadata.width >> 1)) * uint64_t(std::max(1, metadata.height >> 1)) * sizeof(float) * 4; - const uint64_t expandedSize2 = uint64_t(metadata.width) * uint64_t(metadata.height) * sizeof(float) * 4; - if (expandedSize > UINT32_MAX || expandedSize2 > UINT32_MAX) - { - if (filter & TEX_FILTER_FORCE_WIC) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - usewic = false; - } - } - - if (usewic) - { - //--- Use WIC filtering to generate mipmaps ----------------------------------- - switch (filter & TEX_FILTER_MODE_MASK) - { - case 0: - case TEX_FILTER_POINT: - case TEX_FILTER_FANT: // Equivalent to Box filter - case TEX_FILTER_LINEAR: - case TEX_FILTER_CUBIC: - { - static_assert(TEX_FILTER_FANT == TEX_FILTER_BOX, "TEX_FILTER_ flag alias mismatch"); - - if (wicpf) - { - // Case 1: Base image format is supported by Windows Imaging Component - TexMetadata mdata2 = metadata; - mdata2.mipLevels = levels; - hr = mipChain.Initialize(mdata2); - if (FAILED(hr)) - return hr; - - for (size_t item = 0; item < metadata.arraySize; ++item) - { - hr = GenerateMipMapsUsingWIC(baseImages[item], filter, levels, pfGUID, mipChain, item); - if (FAILED(hr)) - { - mipChain.Release(); - return hr; - } - } - - return S_OK; - } - else - { - // Case 2: Base image format is not supported by WIC, so we have to convert, generate, and convert back - assert(metadata.format != DXGI_FORMAT_R32G32B32A32_FLOAT); - - TexMetadata mdata2 = metadata; - mdata2.mipLevels = levels; - mdata2.format = DXGI_FORMAT_R32G32B32A32_FLOAT; - ScratchImage tMipChain; - hr = tMipChain.Initialize(mdata2); - if (FAILED(hr)) - return hr; - - for (size_t item = 0; item < metadata.arraySize; ++item) - { - ScratchImage temp; - hr = ConvertToR32G32B32A32(baseImages[item], temp); - if (FAILED(hr)) - return hr; - - const Image *timg = temp.GetImage(0, 0, 0); - if (!timg) - return E_POINTER; - - hr = GenerateMipMapsUsingWIC(*timg, filter, levels, GUID_WICPixelFormat128bppRGBAFloat, tMipChain, item); - if (FAILED(hr)) - return hr; - } - - return ConvertFromR32G32B32A32(tMipChain.GetImages(), tMipChain.GetImageCount(), tMipChain.GetMetadata(), metadata.format, mipChain); - } - } - - default: - return HRESULT_E_NOT_SUPPORTED; - } - } - else - #endif // WIN32 - { - //--- Use custom filters to generate mipmaps ---------------------------------- - TexMetadata mdata2 = metadata; - mdata2.mipLevels = levels; - - unsigned long filter_select = (filter & TEX_FILTER_MODE_MASK); - if (!filter_select) - { - // Default filter choice - filter_select = (ispow2(metadata.width) && ispow2(metadata.height)) ? TEX_FILTER_BOX : TEX_FILTER_LINEAR; - } - - switch (filter_select) - { - case TEX_FILTER_BOX: - hr = Setup2DMips(&baseImages[0], metadata.arraySize, mdata2, mipChain); - if (FAILED(hr)) - return hr; - - for (size_t item = 0; item < metadata.arraySize; ++item) - { - hr = Generate2DMipsBoxFilter(levels, filter, mipChain, item); - if (FAILED(hr)) - mipChain.Release(); - } - return hr; - - case TEX_FILTER_POINT: - hr = Setup2DMips(&baseImages[0], metadata.arraySize, mdata2, mipChain); - if (FAILED(hr)) - return hr; - - for (size_t item = 0; item < metadata.arraySize; ++item) - { - hr = Generate2DMipsPointFilter(levels, mipChain, item); - if (FAILED(hr)) - mipChain.Release(); - } - return hr; - - case TEX_FILTER_LINEAR: - hr = Setup2DMips(&baseImages[0], metadata.arraySize, mdata2, mipChain); - if (FAILED(hr)) - return hr; - - for (size_t item = 0; item < metadata.arraySize; ++item) - { - hr = Generate2DMipsLinearFilter(levels, filter, mipChain, item); - if (FAILED(hr)) - mipChain.Release(); - } - return hr; - - case TEX_FILTER_CUBIC: - hr = Setup2DMips(&baseImages[0], metadata.arraySize, mdata2, mipChain); - if (FAILED(hr)) - return hr; - - for (size_t item = 0; item < metadata.arraySize; ++item) - { - hr = Generate2DMipsCubicFilter(levels, filter, mipChain, item); - if (FAILED(hr)) - mipChain.Release(); - } - return hr; - - case TEX_FILTER_TRIANGLE: - hr = Setup2DMips(&baseImages[0], metadata.arraySize, mdata2, mipChain); - if (FAILED(hr)) - return hr; - - for (size_t item = 0; item < metadata.arraySize; ++item) - { - hr = Generate2DMipsTriangleFilter(levels, filter, mipChain, item); - if (FAILED(hr)) - mipChain.Release(); - } - return hr; - - default: - return HRESULT_E_NOT_SUPPORTED; - } - } -} - - -//------------------------------------------------------------------------------------- -// Generate mipmap chain for volume texture -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::GenerateMipMaps3D( - const Image* baseImages, - size_t depth, - TEX_FILTER_FLAGS filter, - size_t levels, - ScratchImage& mipChain) noexcept -{ - if (!baseImages || !depth) - return E_INVALIDARG; - - if (filter & TEX_FILTER_FORCE_WIC) - return HRESULT_E_NOT_SUPPORTED; - - const DXGI_FORMAT format = baseImages[0].format; - const size_t width = baseImages[0].width; - const size_t height = baseImages[0].height; - - if (!CalculateMipLevels3D(width, height, depth, levels)) - return E_INVALIDARG; - - if (levels <= 1) - return E_INVALIDARG; - - for (size_t slice = 0; slice < depth; ++slice) - { - if (!baseImages[slice].pixels) - return E_POINTER; - - if (baseImages[slice].format != format || baseImages[slice].width != width || baseImages[slice].height != height) - { - // All base images must be the same format, width, and height - return E_FAIL; - } - } - - if (IsCompressed(format) || IsTypeless(format) || IsPlanar(format) || IsPalettized(format)) - return HRESULT_E_NOT_SUPPORTED; - - static_assert(TEX_FILTER_POINT == 0x100000, "TEX_FILTER_ flag values don't match TEX_FILTER_MODE_MASK"); - - HRESULT hr = E_UNEXPECTED; - - unsigned long filter_select = (filter & TEX_FILTER_MODE_MASK); - if (!filter_select) - { - // Default filter choice - filter_select = (ispow2(width) && ispow2(height) && ispow2(depth)) ? TEX_FILTER_BOX : TEX_FILTER_TRIANGLE; - } - - switch (filter_select) - { - case TEX_FILTER_BOX: - hr = Setup3DMips(baseImages, depth, levels, mipChain); - if (FAILED(hr)) - return hr; - - hr = Generate3DMipsBoxFilter(depth, levels, filter, mipChain); - if (FAILED(hr)) - mipChain.Release(); - return hr; - - case TEX_FILTER_POINT: - hr = Setup3DMips(baseImages, depth, levels, mipChain); - if (FAILED(hr)) - return hr; - - hr = Generate3DMipsPointFilter(depth, levels, mipChain); - if (FAILED(hr)) - mipChain.Release(); - return hr; - - case TEX_FILTER_LINEAR: - hr = Setup3DMips(baseImages, depth, levels, mipChain); - if (FAILED(hr)) - return hr; - - hr = Generate3DMipsLinearFilter(depth, levels, filter, mipChain); - if (FAILED(hr)) - mipChain.Release(); - return hr; - - case TEX_FILTER_CUBIC: - hr = Setup3DMips(baseImages, depth, levels, mipChain); - if (FAILED(hr)) - return hr; - - hr = Generate3DMipsCubicFilter(depth, levels, filter, mipChain); - if (FAILED(hr)) - mipChain.Release(); - return hr; - - case TEX_FILTER_TRIANGLE: - hr = Setup3DMips(baseImages, depth, levels, mipChain); - if (FAILED(hr)) - return hr; - - hr = Generate3DMipsTriangleFilter(depth, levels, filter, mipChain); - if (FAILED(hr)) - mipChain.Release(); - return hr; - - default: - return HRESULT_E_NOT_SUPPORTED; - } -} - -_Use_decl_annotations_ -HRESULT DirectX::GenerateMipMaps3D( - const Image* srcImages, - size_t nimages, - const TexMetadata& metadata, - TEX_FILTER_FLAGS filter, - size_t levels, - ScratchImage& mipChain) -{ - if (!srcImages || !nimages || !IsValid(metadata.format)) - return E_INVALIDARG; - - if (filter & TEX_FILTER_FORCE_WIC) - return HRESULT_E_NOT_SUPPORTED; - - if (!metadata.IsVolumemap() - || IsCompressed(metadata.format) || IsTypeless(metadata.format) || IsPlanar(metadata.format) || IsPalettized(metadata.format)) - return HRESULT_E_NOT_SUPPORTED; - - if (!CalculateMipLevels3D(metadata.width, metadata.height, metadata.depth, levels)) - return E_INVALIDARG; - - if (levels <= 1) - return E_INVALIDARG; - - std::vector baseImages; - baseImages.reserve(metadata.depth); - for (size_t slice = 0; slice < metadata.depth; ++slice) - { - const size_t index = metadata.ComputeIndex(0, 0, slice); - if (index >= nimages) - return E_FAIL; - - const Image& src = srcImages[index]; - if (!src.pixels) - return E_POINTER; - - if (src.format != metadata.format || src.width != metadata.width || src.height != metadata.height) - { - // All base images must be the same format, width, and height - return E_FAIL; - } - - baseImages.push_back(src); - } - - assert(baseImages.size() == metadata.depth); - - HRESULT hr = E_UNEXPECTED; - - static_assert(TEX_FILTER_POINT == 0x100000, "TEX_FILTER_ flag values don't match TEX_FILTER_MODE_MASK"); - - unsigned long filter_select = (filter & TEX_FILTER_MODE_MASK); - if (!filter_select) - { - // Default filter choice - filter_select = (ispow2(metadata.width) && ispow2(metadata.height) && ispow2(metadata.depth)) ? TEX_FILTER_BOX : TEX_FILTER_TRIANGLE; - } - - switch (filter_select) - { - case TEX_FILTER_BOX: - hr = Setup3DMips(&baseImages[0], metadata.depth, levels, mipChain); - if (FAILED(hr)) - return hr; - - hr = Generate3DMipsBoxFilter(metadata.depth, levels, filter, mipChain); - if (FAILED(hr)) - mipChain.Release(); - return hr; - - case TEX_FILTER_POINT: - hr = Setup3DMips(&baseImages[0], metadata.depth, levels, mipChain); - if (FAILED(hr)) - return hr; - - hr = Generate3DMipsPointFilter(metadata.depth, levels, mipChain); - if (FAILED(hr)) - mipChain.Release(); - return hr; - - case TEX_FILTER_LINEAR: - hr = Setup3DMips(&baseImages[0], metadata.depth, levels, mipChain); - if (FAILED(hr)) - return hr; - - hr = Generate3DMipsLinearFilter(metadata.depth, levels, filter, mipChain); - if (FAILED(hr)) - mipChain.Release(); - return hr; - - case TEX_FILTER_CUBIC: - hr = Setup3DMips(&baseImages[0], metadata.depth, levels, mipChain); - if (FAILED(hr)) - return hr; - - hr = Generate3DMipsCubicFilter(metadata.depth, levels, filter, mipChain); - if (FAILED(hr)) - mipChain.Release(); - return hr; - - case TEX_FILTER_TRIANGLE: - hr = Setup3DMips(&baseImages[0], metadata.depth, levels, mipChain); - if (FAILED(hr)) - return hr; - - hr = Generate3DMipsTriangleFilter(metadata.depth, levels, filter, mipChain); - if (FAILED(hr)) - mipChain.Release(); - return hr; - - default: - return HRESULT_E_NOT_SUPPORTED; - } -} - -_Use_decl_annotations_ -HRESULT DirectX::ScaleMipMapsAlphaForCoverage( - const Image* srcImages, - size_t nimages, - const TexMetadata& metadata, - size_t item, - float alphaReference, - ScratchImage& mipChain) noexcept -{ - if (!srcImages || !nimages || !IsValid(metadata.format) || nimages > metadata.mipLevels || !mipChain.GetImages()) - return E_INVALIDARG; - - if (metadata.IsVolumemap() - || IsCompressed(metadata.format) || IsTypeless(metadata.format) || IsPlanar(metadata.format) || IsPalettized(metadata.format)) - return HRESULT_E_NOT_SUPPORTED; - - if (srcImages[0].format != metadata.format || srcImages[0].width != metadata.width || srcImages[0].height != metadata.height) - { - // Base image must be the same format, width, and height - return E_FAIL; - } - - float targetCoverage = 0.0f; - HRESULT hr = CalculateAlphaCoverage(srcImages[0], alphaReference, 1.0f, targetCoverage); - if (FAILED(hr)) - return hr; - - // Copy base image - { - const Image& src = srcImages[0]; - - const Image *dest = mipChain.GetImage(0, item, 0); - if (!dest) - return E_POINTER; - - uint8_t* pDest = dest->pixels; - if (!pDest) - return E_POINTER; - - const uint8_t *pSrc = src.pixels; - const size_t rowPitch = src.rowPitch; - for (size_t h = 0; h < metadata.height; ++h) - { - const size_t msize = std::min(dest->rowPitch, rowPitch); - memcpy(pDest, pSrc, msize); - pSrc += rowPitch; - pDest += dest->rowPitch; - } - } - - for (size_t level = 1; level < metadata.mipLevels; ++level) - { - if (level >= nimages) - return E_FAIL; - - float alphaScale = 0.0f; - hr = EstimateAlphaScaleForCoverage(srcImages[level], alphaReference, targetCoverage, alphaScale); - if (FAILED(hr)) - return hr; - - const Image* mipImage = mipChain.GetImage(level, item, 0); - if (!mipImage) - return E_POINTER; - - hr = ScaleAlpha(srcImages[level], alphaScale, *mipImage); - if (FAILED(hr)) - return hr; - } - - return S_OK; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexMisc.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexMisc.cpp deleted file mode 100644 index 1f3b9be..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexMisc.cpp +++ /dev/null @@ -1,767 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXTexMisc.cpp -// -// DirectX Texture Library - Misc image operations -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//------------------------------------------------------------------------------------- - -#include "DirectXTexP.h" - -using namespace DirectX; -using namespace DirectX::Internal; - -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wignored-attributes" -#endif - -namespace -{ - const XMVECTORF32 g_Gamma22 = { { { 2.2f, 2.2f, 2.2f, 1.f } } }; - - //------------------------------------------------------------------------------------- - HRESULT ComputeMSE_( - const Image& image1, - const Image& image2, - float& mse, - _Out_writes_opt_(4) float* mseV, - CMSE_FLAGS flags) noexcept - { - if (!image1.pixels || !image2.pixels) - return E_POINTER; - - assert(image1.width == image2.width && image1.height == image2.height); - assert(!IsCompressed(image1.format) && !IsCompressed(image2.format)); - - const size_t width = image1.width; - - auto scanline = make_AlignedArrayXMVECTOR(uint64_t(width) * 2); - if (!scanline) - return E_OUTOFMEMORY; - - // Flags implied from image formats - switch (image1.format) - { - case DXGI_FORMAT_B8G8R8X8_UNORM: - flags |= CMSE_IGNORE_ALPHA; - break; - - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - flags |= CMSE_IMAGE1_SRGB | CMSE_IGNORE_ALPHA; - break; - - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - case DXGI_FORMAT_BC1_UNORM_SRGB: - case DXGI_FORMAT_BC2_UNORM_SRGB: - case DXGI_FORMAT_BC3_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - case DXGI_FORMAT_BC7_UNORM_SRGB: - flags |= CMSE_IMAGE1_SRGB; - break; - - default: - break; - } - - switch (image2.format) - { - case DXGI_FORMAT_B8G8R8X8_UNORM: - flags |= CMSE_IGNORE_ALPHA; - break; - - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - flags |= CMSE_IMAGE2_SRGB | CMSE_IGNORE_ALPHA; - break; - - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - case DXGI_FORMAT_BC1_UNORM_SRGB: - case DXGI_FORMAT_BC2_UNORM_SRGB: - case DXGI_FORMAT_BC3_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - case DXGI_FORMAT_BC7_UNORM_SRGB: - flags |= CMSE_IMAGE2_SRGB; - break; - - default: - break; - } - - const uint8_t *pSrc1 = image1.pixels; - const size_t rowPitch1 = image1.rowPitch; - - const uint8_t *pSrc2 = image2.pixels; - const size_t rowPitch2 = image2.rowPitch; - - XMVECTOR acc = g_XMZero; - static XMVECTORF32 two = { { { 2.0f, 2.0f, 2.0f, 2.0f } } }; - - for (size_t h = 0; h < image1.height; ++h) - { - XMVECTOR* ptr1 = scanline.get(); - if (!LoadScanline(ptr1, width, pSrc1, rowPitch1, image1.format)) - return E_FAIL; - - XMVECTOR* ptr2 = scanline.get() + width; - if (!LoadScanline(ptr2, width, pSrc2, rowPitch2, image2.format)) - return E_FAIL; - - for (size_t i = 0; i < width; ++i) - { - XMVECTOR v1 = *(ptr1++); - if (flags & CMSE_IMAGE1_SRGB) - { - v1 = XMVectorPow(v1, g_Gamma22); - } - if (flags & CMSE_IMAGE1_X2_BIAS) - { - v1 = XMVectorMultiplyAdd(v1, two, g_XMNegativeOne); - } - - XMVECTOR v2 = *(ptr2++); - if (flags & CMSE_IMAGE2_SRGB) - { - v2 = XMVectorPow(v2, g_Gamma22); - } - if (flags & CMSE_IMAGE2_X2_BIAS) - { - v2 = XMVectorMultiplyAdd(v2, two, g_XMNegativeOne); - } - - // sum[ (I1 - I2)^2 ] - XMVECTOR v = XMVectorSubtract(v1, v2); - if (flags & CMSE_IGNORE_RED) - { - v = XMVectorSelect(v, g_XMZero, g_XMMaskX); - } - if (flags & CMSE_IGNORE_GREEN) - { - v = XMVectorSelect(v, g_XMZero, g_XMMaskY); - } - if (flags & CMSE_IGNORE_BLUE) - { - v = XMVectorSelect(v, g_XMZero, g_XMMaskZ); - } - if (flags & CMSE_IGNORE_ALPHA) - { - v = XMVectorSelect(v, g_XMZero, g_XMMaskW); - } - - acc = XMVectorMultiplyAdd(v, v, acc); - } - - pSrc1 += rowPitch1; - pSrc2 += rowPitch2; - } - - // MSE = sum[ (I1 - I2)^2 ] / w*h - const XMVECTOR d = XMVectorReplicate(float(image1.width * image1.height)); - const XMVECTOR v = XMVectorDivide(acc, d); - if (mseV) - { - XMStoreFloat4(reinterpret_cast(mseV), v); - mse = mseV[0] + mseV[1] + mseV[2] + mseV[3]; - } - else - { - XMFLOAT4 _mseV; - XMStoreFloat4(&_mseV, v); - mse = _mseV.x + _mseV.y + _mseV.z + _mseV.w; - } - - return S_OK; - } - - //------------------------------------------------------------------------------------- - HRESULT EvaluateImage_( - const Image& image, - const std::function& pixelFunc) - { - if (!pixelFunc) - return E_INVALIDARG; - - if (!image.pixels) - return E_POINTER; - - assert(!IsCompressed(image.format)); - - const size_t width = image.width; - - auto scanline = make_AlignedArrayXMVECTOR(width); - if (!scanline) - return E_OUTOFMEMORY; - - const uint8_t *pSrc = image.pixels; - const size_t rowPitch = image.rowPitch; - - for (size_t h = 0; h < image.height; ++h) - { - if (!LoadScanline(scanline.get(), width, pSrc, rowPitch, image.format)) - return E_FAIL; - - pixelFunc(scanline.get(), width, h); - - pSrc += rowPitch; - } - - return S_OK; - } - - - //------------------------------------------------------------------------------------- - HRESULT TransformImage_( - const Image& srcImage, - const std::function& pixelFunc, - const Image& destImage) - { - if (!pixelFunc) - return E_INVALIDARG; - - if (!srcImage.pixels || !destImage.pixels) - return E_POINTER; - - if (srcImage.width != destImage.width || srcImage.height != destImage.height || srcImage.format != destImage.format) - return E_FAIL; - - const size_t width = srcImage.width; - - auto scanlines = make_AlignedArrayXMVECTOR(uint64_t(width) * 2); - if (!scanlines) - return E_OUTOFMEMORY; - - XMVECTOR* sScanline = scanlines.get(); - XMVECTOR* dScanline = scanlines.get() + width; - - const uint8_t *pSrc = srcImage.pixels; - const size_t spitch = srcImage.rowPitch; - - uint8_t *pDest = destImage.pixels; - const size_t dpitch = destImage.rowPitch; - - for (size_t h = 0; h < srcImage.height; ++h) - { - if (!LoadScanline(sScanline, width, pSrc, spitch, srcImage.format)) - return E_FAIL; - - #ifdef _DEBUG - memset(dScanline, 0xCD, sizeof(XMVECTOR)*width); - #endif - - pixelFunc(dScanline, sScanline, width, h); - - if (!StoreScanline(pDest, destImage.rowPitch, destImage.format, dScanline, width)) - return E_FAIL; - - pSrc += spitch; - pDest += dpitch; - } - - return S_OK; - } -}; - - -//===================================================================================== -// Entry points -//===================================================================================== - -//------------------------------------------------------------------------------------- -// Copies a rectangle from one image into another -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::CopyRectangle( - const Image& srcImage, - const Rect& srcRect, - const Image& dstImage, - TEX_FILTER_FLAGS filter, - size_t xOffset, - size_t yOffset) noexcept -{ - if (!srcImage.pixels || !dstImage.pixels) - return E_POINTER; - - if (IsCompressed(srcImage.format) || IsCompressed(dstImage.format) - || IsPlanar(srcImage.format) || IsPlanar(dstImage.format) - || IsPalettized(srcImage.format) || IsPalettized(dstImage.format)) - return HRESULT_E_NOT_SUPPORTED; - - // Validate rectangle/offset - if (!srcRect.w || !srcRect.h || ((srcRect.x + srcRect.w) > srcImage.width) || ((srcRect.y + srcRect.h) > srcImage.height)) - { - return E_INVALIDARG; - } - - if (((xOffset + srcRect.w) > dstImage.width) || ((yOffset + srcRect.h) > dstImage.height)) - { - return E_INVALIDARG; - } - - // Compute source bytes-per-pixel - size_t sbpp = BitsPerPixel(srcImage.format); - if (!sbpp) - return E_FAIL; - - if (sbpp < 8) - { - // We don't support monochrome (DXGI_FORMAT_R1_UNORM) - return HRESULT_E_NOT_SUPPORTED; - } - - const uint8_t* pEndSrc = srcImage.pixels + srcImage.rowPitch*srcImage.height; - const uint8_t* pEndDest = dstImage.pixels + dstImage.rowPitch*dstImage.height; - - // Round to bytes - sbpp = (sbpp + 7) / 8; - - const uint8_t* pSrc = srcImage.pixels + (srcRect.y * srcImage.rowPitch) + (srcRect.x * sbpp); - - if (srcImage.format == dstImage.format) - { - // Direct copy case (avoid intermediate conversions) - uint8_t* pDest = dstImage.pixels + (yOffset * dstImage.rowPitch) + (xOffset * sbpp); - const size_t copyW = srcRect.w * sbpp; - for (size_t h = 0; h < srcRect.h; ++h) - { - if (((pSrc + copyW) > pEndSrc) || (pDest > pEndDest)) - return E_FAIL; - - memcpy(pDest, pSrc, copyW); - - pSrc += srcImage.rowPitch; - pDest += dstImage.rowPitch; - } - - return S_OK; - } - - // Compute destination bytes-per-pixel (not the same format as source) - size_t dbpp = BitsPerPixel(dstImage.format); - if (!dbpp) - return E_FAIL; - - if (dbpp < 8) - { - // We don't support monochrome (DXGI_FORMAT_R1_UNORM) - return HRESULT_E_NOT_SUPPORTED; - } - - // Round to bytes - dbpp = (dbpp + 7) / 8; - - uint8_t* pDest = dstImage.pixels + (yOffset * dstImage.rowPitch) + (xOffset * dbpp); - - auto scanline = make_AlignedArrayXMVECTOR(srcRect.w); - if (!scanline) - return E_OUTOFMEMORY; - - const size_t copyS = srcRect.w * sbpp; - const size_t copyD = srcRect.w * dbpp; - - for (size_t h = 0; h < srcRect.h; ++h) - { - if (((pSrc + copyS) > pEndSrc) || ((pDest + copyD) > pEndDest)) - return E_FAIL; - - if (!LoadScanline(scanline.get(), srcRect.w, pSrc, copyS, srcImage.format)) - return E_FAIL; - - ConvertScanline(scanline.get(), srcRect.w, dstImage.format, srcImage.format, filter); - - if (!StoreScanline(pDest, copyD, dstImage.format, scanline.get(), srcRect.w)) - return E_FAIL; - - pSrc += srcImage.rowPitch; - pDest += dstImage.rowPitch; - } - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -// Computes the Mean-Squared-Error (MSE) between two images -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::ComputeMSE( - const Image& image1, - const Image& image2, - float& mse, - float* mseV, - CMSE_FLAGS flags) noexcept -{ - if (!image1.pixels || !image2.pixels) - return E_POINTER; - - if (image1.width != image2.width || image1.height != image2.height) - return E_INVALIDARG; - - if (!IsValid(image1.format) || !IsValid(image2.format)) - return E_INVALIDARG; - - if (IsPlanar(image1.format) || IsPlanar(image2.format) - || IsPalettized(image1.format) || IsPalettized(image2.format) - || IsTypeless(image1.format) || IsTypeless(image2.format)) - return HRESULT_E_NOT_SUPPORTED; - - if (IsCompressed(image1.format)) - { - if (IsCompressed(image2.format)) - { - // Case 1: both images are compressed, expand to RGBA32F - ScratchImage temp1; - HRESULT hr = Decompress(image1, DXGI_FORMAT_R32G32B32A32_FLOAT, temp1); - if (FAILED(hr)) - return hr; - - ScratchImage temp2; - hr = Decompress(image2, DXGI_FORMAT_R32G32B32A32_FLOAT, temp2); - if (FAILED(hr)) - return hr; - - const Image* img1 = temp1.GetImage(0, 0, 0); - const Image* img2 = temp2.GetImage(0, 0, 0); - if (!img1 || !img2) - return E_POINTER; - - return ComputeMSE_(*img1, *img2, mse, mseV, flags); - } - else - { - // Case 2: image1 is compressed, expand to RGBA32F - ScratchImage temp; - HRESULT hr = Decompress(image1, DXGI_FORMAT_R32G32B32A32_FLOAT, temp); - if (FAILED(hr)) - return hr; - - const Image* img = temp.GetImage(0, 0, 0); - if (!img) - return E_POINTER; - - return ComputeMSE_(*img, image2, mse, mseV, flags); - } - } - else - { - if (IsCompressed(image2.format)) - { - // Case 3: image2 is compressed, expand to RGBA32F - ScratchImage temp; - HRESULT hr = Decompress(image2, DXGI_FORMAT_R32G32B32A32_FLOAT, temp); - if (FAILED(hr)) - return hr; - - const Image* img = temp.GetImage(0, 0, 0); - if (!img) - return E_POINTER; - - return ComputeMSE_(image1, *img, mse, mseV, flags); - } - else - { - // Case 4: neither image is compressed - return ComputeMSE_(image1, image2, mse, mseV, flags); - } - } -} - - -//------------------------------------------------------------------------------------- -// Evaluates a user-supplied function for all the pixels in the image -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::EvaluateImage( - const Image& image, - std::function pixelFunc) -{ - if (image.width > UINT32_MAX - || image.height > UINT32_MAX) - return E_INVALIDARG; - - if (!IsValid(image.format)) - return E_INVALIDARG; - - if (IsPlanar(image.format) || IsPalettized(image.format) || IsTypeless(image.format)) - return HRESULT_E_NOT_SUPPORTED; - - if (IsCompressed(image.format)) - { - ScratchImage temp; - HRESULT hr = Decompress(image, DXGI_FORMAT_R32G32B32A32_FLOAT, temp); - if (FAILED(hr)) - return hr; - - const Image* img = temp.GetImage(0, 0, 0); - if (!img) - return E_POINTER; - - return EvaluateImage_(*img, pixelFunc); - } - else - { - return EvaluateImage_(image, pixelFunc); - } -} - -_Use_decl_annotations_ -HRESULT DirectX::EvaluateImage( - const Image* images, - size_t nimages, - const TexMetadata& metadata, - std::function pixelFunc) -{ - if (!images || !nimages) - return E_INVALIDARG; - - if (!IsValid(metadata.format)) - return E_INVALIDARG; - - if (IsPlanar(metadata.format) || IsPalettized(metadata.format) || IsTypeless(metadata.format)) - return HRESULT_E_NOT_SUPPORTED; - - if (metadata.width > UINT32_MAX - || metadata.height > UINT32_MAX) - return E_INVALIDARG; - - if (metadata.IsVolumemap() && metadata.depth > UINT16_MAX) - return E_INVALIDARG; - - ScratchImage temp; - DXGI_FORMAT format = metadata.format; - if (IsCompressed(format)) - { - HRESULT hr = Decompress(images, nimages, metadata, DXGI_FORMAT_R32G32B32A32_FLOAT, temp); - if (FAILED(hr)) - return hr; - - if (nimages != temp.GetImageCount()) - return E_UNEXPECTED; - - images = temp.GetImages(); - format = DXGI_FORMAT_R32G32B32A32_FLOAT; - } - - switch (metadata.dimension) - { - case TEX_DIMENSION_TEXTURE1D: - case TEX_DIMENSION_TEXTURE2D: - for (size_t index = 0; index < nimages; ++index) - { - const Image& img = images[index]; - if (img.format != format) - return E_FAIL; - - if ((img.width > UINT32_MAX) || (img.height > UINT32_MAX)) - return E_FAIL; - - HRESULT hr = EvaluateImage_(img, pixelFunc); - if (FAILED(hr)) - return hr; - } - break; - - case TEX_DIMENSION_TEXTURE3D: - { - size_t index = 0; - size_t d = metadata.depth; - for (size_t level = 0; level < metadata.mipLevels; ++level) - { - for (size_t slice = 0; slice < d; ++slice, ++index) - { - if (index >= nimages) - return E_FAIL; - - const Image& img = images[index]; - if (img.format != format) - return E_FAIL; - - if ((img.width > UINT32_MAX) || (img.height > UINT32_MAX)) - return E_FAIL; - - HRESULT hr = EvaluateImage_(img, pixelFunc); - if (FAILED(hr)) - return hr; - } - - if (d > 1) - d >>= 1; - } - } - break; - - default: - return E_FAIL; - } - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -// Use a user-supplied function to compute a new image from an input image -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::TransformImage( - const Image& image, - std::function pixelFunc, - ScratchImage& result) -{ - if (image.width > UINT32_MAX - || image.height > UINT32_MAX) - return E_INVALIDARG; - - if (IsPlanar(image.format) || IsPalettized(image.format) || IsCompressed(image.format) || IsTypeless(image.format)) - return HRESULT_E_NOT_SUPPORTED; - - HRESULT hr = result.Initialize2D(image.format, image.width, image.height, 1, 1); - if (FAILED(hr)) - return hr; - - const Image* dimg = result.GetImage(0, 0, 0); - if (!dimg) - { - result.Release(); - return E_POINTER; - } - - hr = TransformImage_(image, pixelFunc, *dimg); - if (FAILED(hr)) - { - result.Release(); - return hr; - } - - return S_OK; -} - -_Use_decl_annotations_ -HRESULT DirectX::TransformImage( - const Image* srcImages, - size_t nimages, const TexMetadata& metadata, - std::function pixelFunc, - ScratchImage& result) -{ - if (!srcImages || !nimages) - return E_INVALIDARG; - - if (IsPlanar(metadata.format) || IsPalettized(metadata.format) || IsCompressed(metadata.format) || IsTypeless(metadata.format)) - return HRESULT_E_NOT_SUPPORTED; - - if (metadata.width > UINT32_MAX - || metadata.height > UINT32_MAX) - return E_INVALIDARG; - - if (metadata.IsVolumemap() && metadata.depth > UINT16_MAX) - return E_INVALIDARG; - - HRESULT hr = result.Initialize(metadata); - if (FAILED(hr)) - return hr; - - if (nimages != result.GetImageCount()) - { - result.Release(); - return E_FAIL; - } - - const Image* dest = result.GetImages(); - if (!dest) - { - result.Release(); - return E_POINTER; - } - - switch (metadata.dimension) - { - case TEX_DIMENSION_TEXTURE1D: - case TEX_DIMENSION_TEXTURE2D: - for (size_t index = 0; index < nimages; ++index) - { - const Image& src = srcImages[index]; - if (src.format != metadata.format) - { - result.Release(); - return E_FAIL; - } - - if ((src.width > UINT32_MAX) || (src.height > UINT32_MAX)) - { - result.Release(); - return E_FAIL; - } - - const Image& dst = dest[index]; - - if (src.width != dst.width || src.height != dst.height) - { - result.Release(); - return E_FAIL; - } - - hr = TransformImage_(src, pixelFunc, dst); - if (FAILED(hr)) - { - result.Release(); - return hr; - } - } - break; - - case TEX_DIMENSION_TEXTURE3D: - { - size_t index = 0; - size_t d = metadata.depth; - for (size_t level = 0; level < metadata.mipLevels; ++level) - { - for (size_t slice = 0; slice < d; ++slice, ++index) - { - if (index >= nimages) - { - result.Release(); - return E_FAIL; - } - - const Image& src = srcImages[index]; - if (src.format != metadata.format) - { - result.Release(); - return E_FAIL; - } - - if ((src.width > UINT32_MAX) || (src.height > UINT32_MAX)) - { - result.Release(); - return E_FAIL; - } - - const Image& dst = dest[index]; - - if (src.width != dst.width || src.height != dst.height) - { - result.Release(); - return E_FAIL; - } - - hr = TransformImage_(src, pixelFunc, dst); - if (FAILED(hr)) - { - result.Release(); - return hr; - } - } - - if (d > 1) - d >>= 1; - } - } - break; - - default: - result.Release(); - return E_FAIL; - } - - return S_OK; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexNormalMaps.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexNormalMaps.cpp deleted file mode 100644 index 0a35900..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexNormalMaps.cpp +++ /dev/null @@ -1,393 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXTexNormalMaps.cpp -// -// DirectX Texture Library - Normal map operations -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//------------------------------------------------------------------------------------- - -#include "DirectXTexP.h" - -using namespace DirectX; -using namespace DirectX::Internal; - -namespace -{ - -#pragma prefast(suppress : 25000, "FXMVECTOR is 16 bytes") - inline float EvaluateColor(_In_ FXMVECTOR val, _In_ CNMAP_FLAGS flags) noexcept - { - XMFLOAT4A f; - - static XMVECTORF32 lScale = { { { 0.2125f, 0.7154f, 0.0721f, 1.f } } }; - - static_assert(CNMAP_CHANNEL_RED == 0x1, "CNMAP_CHANNEL_ flag values don't match mask"); - switch (flags & 0xf) - { - case 0: - case CNMAP_CHANNEL_RED: return XMVectorGetX(val); - case CNMAP_CHANNEL_GREEN: return XMVectorGetY(val); - case CNMAP_CHANNEL_BLUE: return XMVectorGetZ(val); - case CNMAP_CHANNEL_ALPHA: return XMVectorGetW(val); - - case CNMAP_CHANNEL_LUMINANCE: - { - const XMVECTOR v = XMVectorMultiply(val, lScale); - XMStoreFloat4A(&f, v); - return f.x + f.y + f.z; - } - - default: - assert(false); - return 0.f; - } - } - - void EvaluateRow( - _In_reads_(width) const XMVECTOR* pSource, - _Out_writes_(width + 2) float* pDest, - size_t width, - CNMAP_FLAGS flags) noexcept - { - assert(pSource && pDest); - assert(width > 0); - - for (size_t x = 0; x < width; ++x) - { - pDest[x + 1] = EvaluateColor(pSource[x], flags); - } - - if (flags & CNMAP_MIRROR_U) - { - // Mirror in U - pDest[0] = EvaluateColor(pSource[0], flags); - pDest[width + 1] = EvaluateColor(pSource[width - 1], flags); - } - else - { - // Wrap in U - pDest[0] = EvaluateColor(pSource[width - 1], flags); - pDest[width + 1] = EvaluateColor(pSource[0], flags); - } - } - - HRESULT ComputeNMap(_In_ const Image& srcImage, _In_ CNMAP_FLAGS flags, _In_ float amplitude, - _In_ DXGI_FORMAT format, _In_ const Image& normalMap) noexcept - { - if (!srcImage.pixels || !normalMap.pixels) - return E_INVALIDARG; - - const uint32_t convFlags = GetConvertFlags(format); - if (!convFlags) - return E_FAIL; - - if (!(convFlags & (CONVF_UNORM | CONVF_SNORM | CONVF_FLOAT))) - return HRESULT_E_NOT_SUPPORTED; - - const size_t width = srcImage.width; - const size_t height = srcImage.height; - if (width != normalMap.width || height != normalMap.height) - return E_FAIL; - - // Allocate temporary space (4 scanlines and 3 evaluated rows) - auto scanline = make_AlignedArrayXMVECTOR(uint64_t(width) * 4); - if (!scanline) - return E_OUTOFMEMORY; - - auto buffer = make_AlignedArrayFloat((uint64_t(width) + 2) * 3); - if (!buffer) - return E_OUTOFMEMORY; - - uint8_t* pDest = normalMap.pixels; - if (!pDest) - return E_POINTER; - - XMVECTOR* row0 = scanline.get(); - XMVECTOR* row1 = row0 + width; - XMVECTOR* row2 = row1 + width; - XMVECTOR* target = row2 + width; - - float* val0 = buffer.get(); - float* val1 = val0 + width + 2; - float* val2 = val1 + width + 2; - - const size_t rowPitch = srcImage.rowPitch; - const uint8_t* pSrc = srcImage.pixels; - - // Read first scanline row into 'row1' - if (!LoadScanline(row1, width, pSrc, rowPitch, srcImage.format)) - return E_FAIL; - - // Setup 'row0' - if (flags & CNMAP_MIRROR_V) - { - // Mirror first row - memcpy(row0, row1, rowPitch); - } - else - { - // Read last row (Wrap V) - if (!LoadScanline(row0, width, pSrc + (rowPitch * (height - 1)), rowPitch, srcImage.format)) - return E_FAIL; - } - - // Evaluate the initial rows - EvaluateRow(row0, val0, width, flags); - EvaluateRow(row1, val1, width, flags); - - pSrc += rowPitch; - - for (size_t y = 0; y < height; ++y) - { - // Load next scanline of source image - if (y < (height - 1)) - { - if (!LoadScanline(row2, width, pSrc, rowPitch, srcImage.format)) - return E_FAIL; - } - else - { - if (flags & CNMAP_MIRROR_V) - { - // Use last row of source image - if (!LoadScanline(row2, width, srcImage.pixels + (rowPitch * (height - 1)), rowPitch, srcImage.format)) - return E_FAIL; - } - else - { - // Use first row of source image (Wrap V) - if (!LoadScanline(row2, width, srcImage.pixels, rowPitch, srcImage.format)) - return E_FAIL; - } - } - - // Evaluate row - EvaluateRow(row2, val2, width, flags); - - // Generate target scanline - XMVECTOR *dptr = target; - for (size_t x = 0; x < width; ++x) - { - // Compute normal via central differencing - float totDelta = (val0[x] - val0[x + 2]) + (val1[x] - val1[x + 2]) + (val2[x] - val2[x + 2]); - const float deltaZX = totDelta * amplitude / 6.f; - - totDelta = (val0[x] - val2[x]) + (val0[x + 1] - val2[x + 1]) + (val0[x + 2] - val2[x + 2]); - const float deltaZY = totDelta * amplitude / 6.f; - - const XMVECTOR vx = XMVectorSetZ(g_XMNegIdentityR0, deltaZX); // (-1.0f, 0.0f, deltaZX) - const XMVECTOR vy = XMVectorSetZ(g_XMNegIdentityR1, deltaZY); // (0.0f, -1.0f, deltaZY) - - const XMVECTOR normal = XMVector3Normalize(XMVector3Cross(vx, vy)); - - // Compute alpha (1.0 or an occlusion term) - float alpha = 1.f; - - if (flags & CNMAP_COMPUTE_OCCLUSION) - { - float delta = 0.f; - const float c = val1[x + 1]; - - float t = val0[x] - c; if (t > 0.f) delta += t; - t = val0[x + 1] - c; if (t > 0.f) delta += t; - t = val0[x + 2] - c; if (t > 0.f) delta += t; - t = val1[x] - c; if (t > 0.f) delta += t; - // Skip current pixel - t = val1[x + 2] - c; if (t > 0.f) delta += t; - t = val2[x] - c; if (t > 0.f) delta += t; - t = val2[x + 1] - c; if (t > 0.f) delta += t; - t = val2[x + 2] - c; if (t > 0.f) delta += t; - - // Average delta (divide by 8, scale by amplitude factor) - delta *= 0.125f * amplitude; - if (delta > 0.f) - { - // If < 0, then no occlusion - const float r = sqrtf(1.f + delta*delta); - alpha = (r - delta) / r; - } - } - - // Encode based on target format - if (convFlags & CONVF_UNORM) - { - // 0.5f*normal + 0.5f -or- invert sign case: -0.5f*normal + 0.5f - const XMVECTOR n1 = XMVectorMultiplyAdd((flags & CNMAP_INVERT_SIGN) ? g_XMNegativeOneHalf : g_XMOneHalf, normal, g_XMOneHalf); - *dptr++ = XMVectorSetW(n1, alpha); - } - else if (flags & CNMAP_INVERT_SIGN) - { - *dptr++ = XMVectorSetW(XMVectorNegate(normal), alpha); - } - else - { - *dptr++ = XMVectorSetW(normal, alpha); - } - } - - if (!StoreScanline(pDest, normalMap.rowPitch, format, target, width)) - return E_FAIL; - - // Cycle buffers - float* temp = val0; - val0 = val1; - val1 = val2; - val2 = temp; - - pSrc += rowPitch; - pDest += normalMap.rowPitch; - } - - return S_OK; - } -} - - -//===================================================================================== -// Entry points -//===================================================================================== - -//------------------------------------------------------------------------------------- -// Generates a normal map from a height-map -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::ComputeNormalMap( - const Image& srcImage, - CNMAP_FLAGS flags, - float amplitude, - DXGI_FORMAT format, - ScratchImage& normalMap) noexcept -{ - if (!srcImage.pixels || !IsValid(format)) - return E_INVALIDARG; - - static_assert(CNMAP_CHANNEL_RED == 0x1, "CNMAP_CHANNEL_ flag values don't match mask"); - switch (flags & 0xf) - { - case 0: - case CNMAP_CHANNEL_RED: - case CNMAP_CHANNEL_GREEN: - case CNMAP_CHANNEL_BLUE: - case CNMAP_CHANNEL_ALPHA: - case CNMAP_CHANNEL_LUMINANCE: - break; - - default: - return E_INVALIDARG; - } - - if (IsCompressed(format) || IsCompressed(srcImage.format) - || IsTypeless(format) || IsTypeless(srcImage.format) - || IsPlanar(format) || IsPlanar(srcImage.format) - || IsPalettized(format) || IsPalettized(srcImage.format)) - return HRESULT_E_NOT_SUPPORTED; - - // Setup target image - normalMap.Release(); - - HRESULT hr = normalMap.Initialize2D(format, srcImage.width, srcImage.height, 1, 1); - if (FAILED(hr)) - return hr; - - const Image *img = normalMap.GetImage(0, 0, 0); - if (!img) - { - normalMap.Release(); - return E_POINTER; - } - - hr = ComputeNMap(srcImage, flags, amplitude, format, *img); - if (FAILED(hr)) - { - normalMap.Release(); - return hr; - } - - return S_OK; -} - -_Use_decl_annotations_ -HRESULT DirectX::ComputeNormalMap( - const Image* srcImages, - size_t nimages, - const TexMetadata& metadata, - CNMAP_FLAGS flags, - float amplitude, - DXGI_FORMAT format, - ScratchImage& normalMaps) noexcept -{ - if (!srcImages || !nimages || !IsValid(format)) - return E_INVALIDARG; - - if (IsCompressed(format) || IsCompressed(metadata.format) - || IsTypeless(format) || IsTypeless(metadata.format) - || IsPlanar(format) || IsPlanar(metadata.format) - || IsPalettized(format) || IsPalettized(metadata.format)) - return HRESULT_E_NOT_SUPPORTED; - - static_assert(CNMAP_CHANNEL_RED == 0x1, "CNMAP_CHANNEL_ flag values don't match mask"); - switch (flags & 0xf) - { - case 0: - case CNMAP_CHANNEL_RED: - case CNMAP_CHANNEL_GREEN: - case CNMAP_CHANNEL_BLUE: - case CNMAP_CHANNEL_ALPHA: - case CNMAP_CHANNEL_LUMINANCE: - break; - - default: - return E_INVALIDARG; - } - - normalMaps.Release(); - - TexMetadata mdata2 = metadata; - mdata2.format = format; - HRESULT hr = normalMaps.Initialize(mdata2); - if (FAILED(hr)) - return hr; - - if (nimages != normalMaps.GetImageCount()) - { - normalMaps.Release(); - return E_FAIL; - } - - const Image* dest = normalMaps.GetImages(); - if (!dest) - { - normalMaps.Release(); - return E_POINTER; - } - - for (size_t index = 0; index < nimages; ++index) - { - assert(dest[index].format == format); - - const Image& src = srcImages[index]; - if (IsCompressed(src.format) || IsTypeless(src.format)) - { - normalMaps.Release(); - return HRESULT_E_NOT_SUPPORTED; - } - - if (src.width != dest[index].width || src.height != dest[index].height) - { - normalMaps.Release(); - return E_FAIL; - } - - hr = ComputeNMap(src, flags, amplitude, format, dest[index]); - if (FAILED(hr)) - { - normalMaps.Release(); - return hr; - } - } - - return S_OK; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexP.h b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexP.h deleted file mode 100644 index 7a55e0d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexP.h +++ /dev/null @@ -1,438 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXTexP.h -// -// DirectX Texture Library - Private header -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//------------------------------------------------------------------------------------- - -#pragma once - -// Off by default warnings -#pragma warning(disable : 4619 4616 4061 4265 4365 4571 4623 4625 4626 4628 4668 4710 4711 4746 4774 4820 4987 5026 5027 5031 5032 5039 5045 5219 5246 26812) -// C4619/4616 #pragma warning warnings -// C4061 enumerator 'X' in switch of enum 'X' is not explicitly handled by a case label -// C4265 class has virtual functions, but destructor is not virtual -// C4365 signed/unsigned mismatch -// C4571 behavior change -// C4623 default constructor was implicitly defined as deleted -// C4625 copy constructor was implicitly defined as deleted -// C4626 assignment operator was implicitly defined as deleted -// C4628 digraphs not supported -// C4668 not defined as a preprocessor macro -// C4710 function not inlined -// C4711 selected for automatic inline expansion -// C4746 volatile access of '' is subject to /volatile: setting -// C4774 format string expected in argument 3 is not a string literal -// C4820 padding added after data member -// C4987 nonstandard extension used -// C5026 move constructor was implicitly defined as deleted -// C5027 move assignment operator was implicitly defined as deleted -// C5031/5032 push/pop mismatches in windows headers -// C5039 pointer or reference to potentially throwing function passed to extern C function under - EHc -// C5045 Spectre mitigation warning -// C5219 implicit conversion from 'int' to 'float', possible loss of data -// C5246 the initialization of a subobject should be wrapped in braces -// 26812: The enum type 'x' is unscoped. Prefer 'enum class' over 'enum' (Enum.3). - -// Windows 8.1 SDK related Off by default warnings -#pragma warning(disable : 4471 4917 4986 5029) -// C4471 forward declaration of an unscoped enumeration must have an underlying type -// C4917 a GUID can only be associated with a class, interface or namespace -// C4986 exception specification does not match previous declaration -// C5029 nonstandard extension used - -// Xbox One XDK related Off by default warnings -#pragma warning(disable : 4643) -// C4643 Forward declaring in namespace std is not permitted by the C++ Standard - -#ifdef __INTEL_COMPILER -#pragma warning(disable : 161) -// warning #161: unrecognized #pragma -#endif - -#ifdef __clang__ -#pragma clang diagnostic ignored "-Wc++98-compat" -#pragma clang diagnostic ignored "-Wc++98-compat-pedantic" -#pragma clang diagnostic ignored "-Wc++98-compat-local-type-template-args" -#pragma clang diagnostic ignored "-Wcovered-switch-default" -#pragma clang diagnostic ignored "-Wfloat-equal" -#pragma clang diagnostic ignored "-Wglobal-constructors" -#pragma clang diagnostic ignored "-Wgnu-anonymous-struct" -#pragma clang diagnostic ignored "-Wlanguage-extension-token" -#pragma clang diagnostic ignored "-Wmissing-variable-declarations" -#pragma clang diagnostic ignored "-Wnested-anon-types" -#pragma clang diagnostic ignored "-Wreserved-id-macro" -#pragma clang diagnostic ignored "-Wswitch-enum" -#pragma clang diagnostic ignored "-Wtautological-type-limit-compare" -#pragma clang diagnostic ignored "-Wunknown-pragmas" -#endif - -#ifdef _WIN32 -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif - -#pragma warning(push) -#pragma warning(disable : 4005) -#define NOMINMAX 1 -#define NODRAWTEXT -#define NOGDI -#define NOBITMAP -#define NOMCX -#define NOSERVICE -#define NOHELP -#pragma warning(pop) - -#include - -#ifdef __MINGW32__ -#include -#endif - -#ifndef _WIN32_WINNT_WIN10 -#define _WIN32_WINNT_WIN10 0x0A00 -#endif - -#ifdef _GAMING_XBOX_SCARLETT -#pragma warning(push) -#pragma warning(disable: 5204 5249) -#include -#pragma warning(pop) -#elif defined(_GAMING_XBOX) -#pragma warning(push) -#pragma warning(disable: 5204) -#include -#pragma warning(pop) -#elif defined(_XBOX_ONE) && defined(_TITLE) -#include -#include -#elif (_WIN32_WINNT >= _WIN32_WINNT_WIN10) -#ifdef USING_DIRECTX_HEADERS -#include -#include -#else -#include -#endif -#include -#else -#include -#endif -#else // !WIN32 -#include -#include -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef _WIN32 -#include -#include -#include -#endif - -#define _XM_NO_XMVECTOR_OVERLOADS_ - -#include - -#if (DIRECTX_MATH_VERSION < 315) -#define XM_ALIGNED_DATA(x) __declspec(align(x)) -#endif - -#include "DirectXTex.h" - -#include - -#ifdef _WIN32 -#if defined(NTDDI_WIN10_FE) || defined(__MINGW32__) -#include -#else -#include -#endif -#include -#include -#else -using WICPixelFormatGUID = GUID; -#endif - -#include "scoped.h" - -#define XBOX_DXGI_FORMAT_R10G10B10_7E3_A2_FLOAT DXGI_FORMAT(116) -#define XBOX_DXGI_FORMAT_R10G10B10_6E4_A2_FLOAT DXGI_FORMAT(117) -#define XBOX_DXGI_FORMAT_D16_UNORM_S8_UINT DXGI_FORMAT(118) -#define XBOX_DXGI_FORMAT_R16_UNORM_X8_TYPELESS DXGI_FORMAT(119) -#define XBOX_DXGI_FORMAT_X16_TYPELESS_G8_UINT DXGI_FORMAT(120) - -#define WIN10_DXGI_FORMAT_P208 DXGI_FORMAT(130) -#define WIN10_DXGI_FORMAT_V208 DXGI_FORMAT(131) -#define WIN10_DXGI_FORMAT_V408 DXGI_FORMAT(132) - -#ifndef XBOX_DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM -#define XBOX_DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM DXGI_FORMAT(189) -#endif - -#define XBOX_DXGI_FORMAT_R4G4_UNORM DXGI_FORMAT(190) - -#if defined(__MINGW32__) && !defined(E_BOUNDS) -#define E_BOUNDS static_cast(0x8000000BL) -#endif - -// HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW) -#define HRESULT_E_ARITHMETIC_OVERFLOW static_cast(0x80070216L) - -// HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED) -#define HRESULT_E_NOT_SUPPORTED static_cast(0x80070032L) - -// HRESULT_FROM_WIN32(ERROR_HANDLE_EOF) -#define HRESULT_E_HANDLE_EOF static_cast(0x80070026L) - -// HRESULT_FROM_WIN32(ERROR_INVALID_DATA) -#define HRESULT_E_INVALID_DATA static_cast(0x8007000DL) - -// HRESULT_FROM_WIN32(ERROR_FILE_TOO_LARGE) -#define HRESULT_E_FILE_TOO_LARGE static_cast(0x800700DFL) - -// HRESULT_FROM_WIN32(ERROR_CANNOT_MAKE) -#define HRESULT_E_CANNOT_MAKE static_cast(0x80070052L) - -// HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER) -#ifndef E_NOT_SUFFICIENT_BUFFER -#define E_NOT_SUFFICIENT_BUFFER static_cast(0x8007007AL) -#endif - -//------------------------------------------------------------------------------------- -namespace DirectX -{ - namespace Internal - { - //----------------------------------------------------------------------------- - // WIC helper functions - #ifdef _WIN32 - DXGI_FORMAT __cdecl WICToDXGI(_In_ const GUID& guid) noexcept; - bool __cdecl DXGIToWIC(_In_ DXGI_FORMAT format, _Out_ GUID& guid, _In_ bool ignoreRGBvsBGR = false) noexcept; - - TEX_FILTER_FLAGS __cdecl CheckWICColorSpace(_In_ const GUID& sourceGUID, _In_ const GUID& targetGUID) noexcept; - - inline WICBitmapDitherType __cdecl GetWICDither(_In_ TEX_FILTER_FLAGS flags) noexcept - { - static_assert(TEX_FILTER_DITHER == 0x10000, "TEX_FILTER_DITHER* flag values don't match mask"); - - static_assert(static_cast(TEX_FILTER_DITHER) == static_cast(WIC_FLAGS_DITHER), "TEX_FILTER_DITHER* should match WIC_FLAGS_DITHER*"); - static_assert(static_cast(TEX_FILTER_DITHER_DIFFUSION) == static_cast(WIC_FLAGS_DITHER_DIFFUSION), "TEX_FILTER_DITHER* should match WIC_FLAGS_DITHER*"); - - switch (flags & TEX_FILTER_DITHER_MASK) - { - case TEX_FILTER_DITHER: - return WICBitmapDitherTypeOrdered4x4; - - case TEX_FILTER_DITHER_DIFFUSION: - return WICBitmapDitherTypeErrorDiffusion; - - default: - return WICBitmapDitherTypeNone; - } - } - - inline WICBitmapDitherType __cdecl GetWICDither(_In_ WIC_FLAGS flags) noexcept - { - switch (flags & TEX_FILTER_DITHER_MASK) - { - case WIC_FLAGS_DITHER: - return WICBitmapDitherTypeOrdered4x4; - - case WIC_FLAGS_DITHER_DIFFUSION: - return WICBitmapDitherTypeErrorDiffusion; - - default: - return WICBitmapDitherTypeNone; - } - } - - inline WICBitmapInterpolationMode __cdecl GetWICInterp(_In_ WIC_FLAGS flags) noexcept - { - static_assert(TEX_FILTER_POINT == 0x100000, "TEX_FILTER_ flag values don't match TEX_FILTER_MASK"); - - static_assert(static_cast(TEX_FILTER_POINT) == static_cast(WIC_FLAGS_FILTER_POINT), "TEX_FILTER_* flags should match WIC_FLAGS_FILTER_*"); - static_assert(static_cast(TEX_FILTER_LINEAR) == static_cast(WIC_FLAGS_FILTER_LINEAR), "TEX_FILTER_* flags should match WIC_FLAGS_FILTER_*"); - static_assert(static_cast(TEX_FILTER_CUBIC) == static_cast(WIC_FLAGS_FILTER_CUBIC), "TEX_FILTER_* flags should match WIC_FLAGS_FILTER_*"); - static_assert(static_cast(TEX_FILTER_FANT) == static_cast(WIC_FLAGS_FILTER_FANT), "TEX_FILTER_* flags should match WIC_FLAGS_FILTER_*"); - - switch (flags & TEX_FILTER_MODE_MASK) - { - case TEX_FILTER_POINT: - return WICBitmapInterpolationModeNearestNeighbor; - - case TEX_FILTER_LINEAR: - return WICBitmapInterpolationModeLinear; - - case TEX_FILTER_CUBIC: - return WICBitmapInterpolationModeCubic; - - case TEX_FILTER_FANT: - default: - return WICBitmapInterpolationModeFant; - } - } - - inline WICBitmapInterpolationMode __cdecl GetWICInterp(_In_ TEX_FILTER_FLAGS flags) noexcept - { - switch (flags & TEX_FILTER_MODE_MASK) - { - case TEX_FILTER_POINT: - return WICBitmapInterpolationModeNearestNeighbor; - - case TEX_FILTER_LINEAR: - return WICBitmapInterpolationModeLinear; - - case TEX_FILTER_CUBIC: - return WICBitmapInterpolationModeCubic; - - case TEX_FILTER_FANT: - default: - return WICBitmapInterpolationModeFant; - } - } - #endif // WIN32 - - //--------------------------------------------------------------------------------- - // Image helper functions - _Success_(return) bool __cdecl DetermineImageArray( - _In_ const TexMetadata& metadata, _In_ CP_FLAGS cpFlags, - _Out_ size_t& nImages, _Out_ size_t& pixelSize) noexcept; - - _Success_(return) bool __cdecl SetupImageArray( - _In_reads_bytes_(pixelSize) uint8_t* pMemory, _In_ size_t pixelSize, - _In_ const TexMetadata& metadata, _In_ CP_FLAGS cpFlags, - _Out_writes_(nImages) Image* images, _In_ size_t nImages) noexcept; - - //--------------------------------------------------------------------------------- - // Conversion helper functions - - enum TEXP_SCANLINE_FLAGS : uint32_t - { - TEXP_SCANLINE_NONE = 0, - - TEXP_SCANLINE_SETALPHA = 0x1, - // Set alpha channel to known opaque value - - TEXP_SCANLINE_LEGACY = 0x2, - // Enables specific legacy format conversion cases - }; - - enum CONVERT_FLAGS : uint32_t - { - CONVF_FLOAT = 0x1, - CONVF_UNORM = 0x2, - CONVF_UINT = 0x4, - CONVF_SNORM = 0x8, - CONVF_SINT = 0x10, - CONVF_DEPTH = 0x20, - CONVF_STENCIL = 0x40, - CONVF_SHAREDEXP = 0x80, - CONVF_BGR = 0x100, - CONVF_XR = 0x200, - CONVF_PACKED = 0x400, - CONVF_BC = 0x800, - CONVF_YUV = 0x1000, - CONVF_POS_ONLY = 0x2000, - CONVF_R = 0x10000, - CONVF_G = 0x20000, - CONVF_B = 0x40000, - CONVF_A = 0x80000, - CONVF_RGB_MASK = 0x70000, - CONVF_RGBA_MASK = 0xF0000, - }; - - uint32_t __cdecl GetConvertFlags(_In_ DXGI_FORMAT format) noexcept; - - void __cdecl CopyScanline( - _When_(pDestination == pSource, _Inout_updates_bytes_(outSize)) - _When_(pDestination != pSource, _Out_writes_bytes_(outSize)) - void* pDestination, _In_ size_t outSize, - _In_reads_bytes_(inSize) const void* pSource, _In_ size_t inSize, - _In_ DXGI_FORMAT format, _In_ uint32_t tflags) noexcept; - - void __cdecl SwizzleScanline( - _When_(pDestination == pSource, _In_) - _When_(pDestination != pSource, _Out_writes_bytes_(outSize)) - void* pDestination, _In_ size_t outSize, - _In_reads_bytes_(inSize) const void* pSource, _In_ size_t inSize, - _In_ DXGI_FORMAT format, _In_ uint32_t tflags) noexcept; - - _Success_(return) bool __cdecl ExpandScanline( - _Out_writes_bytes_(outSize) void* pDestination, _In_ size_t outSize, - _In_ DXGI_FORMAT outFormat, - _In_reads_bytes_(inSize) const void* pSource, _In_ size_t inSize, - _In_ DXGI_FORMAT inFormat, _In_ uint32_t tflags) noexcept; - - _Success_(return) bool __cdecl LoadScanline( - _Out_writes_(count) XMVECTOR* pDestination, _In_ size_t count, - _In_reads_bytes_(size) const void* pSource, _In_ size_t size, - _In_ DXGI_FORMAT format) noexcept; - - _Success_(return) bool __cdecl LoadScanlineLinear( - _Out_writes_(count) XMVECTOR* pDestination, _In_ size_t count, - _In_reads_bytes_(size) const void* pSource, _In_ size_t size, - _In_ DXGI_FORMAT format, _In_ TEX_FILTER_FLAGS flags) noexcept; - - _Success_(return) bool __cdecl StoreScanline( - _Out_writes_bytes_(size) void* pDestination, _In_ size_t size, _In_ DXGI_FORMAT format, - _In_reads_(count) const XMVECTOR* pSource, _In_ size_t count, _In_ float threshold = 0) noexcept; - - _Success_(return) bool __cdecl StoreScanlineLinear( - _Out_writes_bytes_(size) void* pDestination, _In_ size_t size, _In_ DXGI_FORMAT format, - _Inout_updates_all_(count) XMVECTOR* pSource, _In_ size_t count, - _In_ TEX_FILTER_FLAGS flags, _In_ float threshold = 0) noexcept; - - _Success_(return) bool __cdecl StoreScanlineDither( - _Out_writes_bytes_(size) void* pDestination, _In_ size_t size, _In_ DXGI_FORMAT format, - _Inout_updates_all_(count) XMVECTOR* pSource, _In_ size_t count, - _In_ float threshold, size_t y, size_t z, - _Inout_updates_all_opt_(count + 2) XMVECTOR* pDiffusionErrors) noexcept; - - HRESULT __cdecl ConvertToR32G32B32A32(_In_ const Image& srcImage, _Inout_ ScratchImage& image) noexcept; - - HRESULT __cdecl ConvertFromR32G32B32A32(_In_ const Image& srcImage, _In_ const Image& destImage) noexcept; - HRESULT __cdecl ConvertFromR32G32B32A32( - _In_ const Image& srcImage, _In_ DXGI_FORMAT format, _Inout_ ScratchImage& image) noexcept; - HRESULT __cdecl ConvertFromR32G32B32A32( - _In_reads_(nimages) const Image* srcImages, _In_ size_t nimages, _In_ const TexMetadata& metadata, - _In_ DXGI_FORMAT format, _Out_ ScratchImage& result) noexcept; - - HRESULT __cdecl ConvertToR16G16B16A16(_In_ const Image& srcImage, _Inout_ ScratchImage& image) noexcept; - - HRESULT __cdecl ConvertFromR16G16B16A16(_In_ const Image& srcImage, _In_ const Image& destImage) noexcept; - - void __cdecl ConvertScanline( - _Inout_updates_all_(count) XMVECTOR* pBuffer, _In_ size_t count, - _In_ DXGI_FORMAT outFormat, _In_ DXGI_FORMAT inFormat, _In_ TEX_FILTER_FLAGS flags) noexcept; - - //--------------------------------------------------------------------------------- - // Misc helper functions - bool __cdecl IsAlphaAllOpaqueBC(_In_ const Image& cImage) noexcept; - bool __cdecl CalculateMipLevels(_In_ size_t width, _In_ size_t height, _Inout_ size_t& mipLevels) noexcept; - bool __cdecl CalculateMipLevels3D(_In_ size_t width, _In_ size_t height, _In_ size_t depth, - _Inout_ size_t& mipLevels) noexcept; - - #ifdef _WIN32 - HRESULT __cdecl ResizeSeparateColorAndAlpha(_In_ IWICImagingFactory* pWIC, - _In_ bool iswic2, - _In_ IWICBitmap* original, - _In_ size_t newWidth, _In_ size_t newHeight, _In_ TEX_FILTER_FLAGS filter, - _Inout_ const Image* img) noexcept; - #endif - - } // namespace Internal -} // namespace DirectX diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexPMAlpha.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexPMAlpha.cpp deleted file mode 100644 index 059af95..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexPMAlpha.cpp +++ /dev/null @@ -1,344 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXTexPMAlpha.cpp -// -// DirectX Texture Library - Premultiplied alpha operations -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//------------------------------------------------------------------------------------- - -#include "DirectXTexP.h" - -using namespace DirectX; -using namespace DirectX::Internal; - -namespace -{ - constexpr TEX_FILTER_FLAGS GetSRGBFlags(_In_ TEX_PMALPHA_FLAGS compress) noexcept - { - static_assert(TEX_FILTER_SRGB_IN == 0x1000000, "TEX_FILTER_SRGB flag values don't match TEX_FILTER_SRGB_MASK"); - static_assert(static_cast(TEX_PMALPHA_SRGB_IN) == static_cast(TEX_FILTER_SRGB_IN), "TEX_PMALPHA_SRGB* should match TEX_FILTER_SRGB*"); - static_assert(static_cast(TEX_PMALPHA_SRGB_OUT) == static_cast(TEX_FILTER_SRGB_OUT), "TEX_PMALPHA_SRGB* should match TEX_FILTER_SRGB*"); - static_assert(static_cast(TEX_PMALPHA_SRGB) == static_cast(TEX_FILTER_SRGB), "TEX_PMALPHA_SRGB* should match TEX_FILTER_SRGB*"); - return static_cast(compress & TEX_FILTER_SRGB_MASK); - } - - //--------------------------------------------------------------------------------- - // NonPremultiplied alpha -> Premultiplied alpha - HRESULT PremultiplyAlpha_(const Image& srcImage, const Image& destImage) noexcept - { - assert(srcImage.width == destImage.width); - assert(srcImage.height == destImage.height); - - auto scanline = make_AlignedArrayXMVECTOR(srcImage.width); - if (!scanline) - return E_OUTOFMEMORY; - - const uint8_t *pSrc = srcImage.pixels; - uint8_t *pDest = destImage.pixels; - if (!pSrc || !pDest) - return E_POINTER; - - for (size_t h = 0; h < srcImage.height; ++h) - { - if (!LoadScanline(scanline.get(), srcImage.width, pSrc, srcImage.rowPitch, srcImage.format)) - return E_FAIL; - - XMVECTOR* ptr = scanline.get(); - for (size_t w = 0; w < srcImage.width; ++w) - { - const XMVECTOR v = *ptr; - XMVECTOR alpha = XMVectorSplatW(*ptr); - alpha = XMVectorMultiply(v, alpha); - *(ptr++) = XMVectorSelect(v, alpha, g_XMSelect1110); - } - - if (!StoreScanline(pDest, destImage.rowPitch, destImage.format, scanline.get(), srcImage.width)) - return E_FAIL; - - pSrc += srcImage.rowPitch; - pDest += destImage.rowPitch; - } - - return S_OK; - } - - HRESULT PremultiplyAlphaLinear(const Image& srcImage, TEX_PMALPHA_FLAGS flags, const Image& destImage) noexcept - { - assert(srcImage.width == destImage.width); - assert(srcImage.height == destImage.height); - - static_assert(static_cast(TEX_PMALPHA_SRGB_IN) == static_cast(TEX_FILTER_SRGB_IN), "TEX_PMALHPA_SRGB* should match TEX_FILTER_SRGB*"); - static_assert(static_cast(TEX_PMALPHA_SRGB_OUT) == static_cast(TEX_FILTER_SRGB_OUT), "TEX_PMALHPA_SRGB* should match TEX_FILTER_SRGB*"); - static_assert(static_cast(TEX_PMALPHA_SRGB) == static_cast(TEX_FILTER_SRGB), "TEX_PMALHPA_SRGB* should match TEX_FILTER_SRGB*"); - flags &= TEX_PMALPHA_SRGB; - - auto scanline = make_AlignedArrayXMVECTOR(srcImage.width); - if (!scanline) - return E_OUTOFMEMORY; - - const uint8_t *pSrc = srcImage.pixels; - uint8_t *pDest = destImage.pixels; - if (!pSrc || !pDest) - return E_POINTER; - - const TEX_FILTER_FLAGS filter = GetSRGBFlags(flags); - - for (size_t h = 0; h < srcImage.height; ++h) - { - if (!LoadScanlineLinear(scanline.get(), srcImage.width, pSrc, srcImage.rowPitch, srcImage.format, filter)) - return E_FAIL; - - XMVECTOR* ptr = scanline.get(); - for (size_t w = 0; w < srcImage.width; ++w) - { - const XMVECTOR v = *ptr; - XMVECTOR alpha = XMVectorSplatW(*ptr); - alpha = XMVectorMultiply(v, alpha); - *(ptr++) = XMVectorSelect(v, alpha, g_XMSelect1110); - } - - if (!StoreScanlineLinear(pDest, destImage.rowPitch, destImage.format, scanline.get(), srcImage.width, filter)) - return E_FAIL; - - pSrc += srcImage.rowPitch; - pDest += destImage.rowPitch; - } - - return S_OK; - } - - //--------------------------------------------------------------------------------- - // Premultiplied alpha -> NonPremultiplied alpha (a.k.a. Straight alpha) - HRESULT DemultiplyAlpha(const Image& srcImage, const Image& destImage) noexcept - { - assert(srcImage.width == destImage.width); - assert(srcImage.height == destImage.height); - - auto scanline = make_AlignedArrayXMVECTOR(srcImage.width); - if (!scanline) - return E_OUTOFMEMORY; - - const uint8_t *pSrc = srcImage.pixels; - uint8_t *pDest = destImage.pixels; - if (!pSrc || !pDest) - return E_POINTER; - - for (size_t h = 0; h < srcImage.height; ++h) - { - if (!LoadScanline(scanline.get(), srcImage.width, pSrc, srcImage.rowPitch, srcImage.format)) - return E_FAIL; - - XMVECTOR* ptr = scanline.get(); - for (size_t w = 0; w < srcImage.width; ++w) - { - const XMVECTOR v = *ptr; - XMVECTOR alpha = XMVectorSplatW(*ptr); - if (XMVectorGetX(alpha) > 0) - { - alpha = XMVectorDivide(v, alpha); - } - *(ptr++) = XMVectorSelect(v, alpha, g_XMSelect1110); - } - - if (!StoreScanline(pDest, destImage.rowPitch, destImage.format, scanline.get(), srcImage.width)) - return E_FAIL; - - pSrc += srcImage.rowPitch; - pDest += destImage.rowPitch; - } - - return S_OK; - } - - HRESULT DemultiplyAlphaLinear(const Image& srcImage, TEX_PMALPHA_FLAGS flags, const Image& destImage) noexcept - { - assert(srcImage.width == destImage.width); - assert(srcImage.height == destImage.height); - - static_assert(static_cast(TEX_PMALPHA_SRGB_IN) == static_cast(TEX_FILTER_SRGB_IN), "TEX_PMALPHA_SRGB* should match TEX_FILTER_SRGB*"); - static_assert(static_cast(TEX_PMALPHA_SRGB_OUT) == static_cast(TEX_FILTER_SRGB_OUT), "TEX_PMALPHA_SRGB* should match TEX_FILTER_SRGB*"); - static_assert(static_cast(TEX_PMALPHA_SRGB) == static_cast(TEX_FILTER_SRGB), "TEX_PMALPHA_SRGB* should match TEX_FILTER_SRGB*"); - flags &= TEX_PMALPHA_SRGB; - - auto scanline = make_AlignedArrayXMVECTOR(srcImage.width); - if (!scanline) - return E_OUTOFMEMORY; - - const uint8_t *pSrc = srcImage.pixels; - uint8_t *pDest = destImage.pixels; - if (!pSrc || !pDest) - return E_POINTER; - - const TEX_FILTER_FLAGS filter = GetSRGBFlags(flags); - - for (size_t h = 0; h < srcImage.height; ++h) - { - if (!LoadScanlineLinear(scanline.get(), srcImage.width, pSrc, srcImage.rowPitch, srcImage.format, filter)) - return E_FAIL; - - XMVECTOR* ptr = scanline.get(); - for (size_t w = 0; w < srcImage.width; ++w) - { - const XMVECTOR v = *ptr; - XMVECTOR alpha = XMVectorSplatW(*ptr); - if (XMVectorGetX(alpha) > 0) - { - alpha = XMVectorDivide(v, alpha); - } - *(ptr++) = XMVectorSelect(v, alpha, g_XMSelect1110); - } - - if (!StoreScanlineLinear(pDest, destImage.rowPitch, destImage.format, scanline.get(), srcImage.width, filter)) - return E_FAIL; - - pSrc += srcImage.rowPitch; - pDest += destImage.rowPitch; - } - - return S_OK; - } -} - - -//===================================================================================== -// Entry-points -//===================================================================================== - -//------------------------------------------------------------------------------------- -// Converts to/from a premultiplied alpha version of the texture -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::PremultiplyAlpha( - const Image& srcImage, - TEX_PMALPHA_FLAGS flags, - ScratchImage& image) noexcept -{ - if (!srcImage.pixels) - return E_POINTER; - - if (IsCompressed(srcImage.format) - || IsPlanar(srcImage.format) - || IsPalettized(srcImage.format) - || IsTypeless(srcImage.format) - || !HasAlpha(srcImage.format)) - return HRESULT_E_NOT_SUPPORTED; - - if ((srcImage.width > UINT32_MAX) || (srcImage.height > UINT32_MAX)) - return E_INVALIDARG; - - HRESULT hr = image.Initialize2D(srcImage.format, srcImage.width, srcImage.height, 1, 1); - if (FAILED(hr)) - return hr; - - const Image *rimage = image.GetImage(0, 0, 0); - if (!rimage) - { - image.Release(); - return E_POINTER; - } - - if (flags & TEX_PMALPHA_REVERSE) - { - hr = (flags & TEX_PMALPHA_IGNORE_SRGB) ? DemultiplyAlpha(srcImage, *rimage) : DemultiplyAlphaLinear(srcImage, flags, *rimage); - } - else - { - hr = (flags & TEX_PMALPHA_IGNORE_SRGB) ? PremultiplyAlpha_(srcImage, *rimage) : PremultiplyAlphaLinear(srcImage, flags, *rimage); - } - if (FAILED(hr)) - { - image.Release(); - return hr; - } - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -// Converts to/from a premultiplied alpha version of the texture (complex) -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::PremultiplyAlpha( - const Image* srcImages, - size_t nimages, - const TexMetadata& metadata, - TEX_PMALPHA_FLAGS flags, - ScratchImage& result) noexcept -{ - if (!srcImages || !nimages) - return E_INVALIDARG; - - if (IsCompressed(metadata.format) - || IsPlanar(metadata.format) - || IsPalettized(metadata.format) - || IsTypeless(metadata.format) - || !HasAlpha(metadata.format)) - return HRESULT_E_NOT_SUPPORTED; - - if ((metadata.width > UINT32_MAX) || (metadata.height > UINT32_MAX)) - return E_INVALIDARG; - - if (metadata.IsPMAlpha() != ((flags & TEX_PMALPHA_REVERSE) != 0)) - return E_FAIL; - - TexMetadata mdata2 = metadata; - mdata2.SetAlphaMode((flags & TEX_PMALPHA_REVERSE) ? TEX_ALPHA_MODE_STRAIGHT : TEX_ALPHA_MODE_PREMULTIPLIED); - HRESULT hr = result.Initialize(mdata2); - if (FAILED(hr)) - return hr; - - if (nimages != result.GetImageCount()) - { - result.Release(); - return E_FAIL; - } - - const Image* dest = result.GetImages(); - if (!dest) - { - result.Release(); - return E_POINTER; - } - - for (size_t index = 0; index < nimages; ++index) - { - const Image& src = srcImages[index]; - if (src.format != metadata.format) - { - result.Release(); - return E_FAIL; - } - - if ((src.width > UINT32_MAX) || (src.height > UINT32_MAX)) - return E_FAIL; - - const Image& dst = dest[index]; - assert(dst.format == metadata.format); - - if (src.width != dst.width || src.height != dst.height) - { - result.Release(); - return E_FAIL; - } - - if (flags & TEX_PMALPHA_REVERSE) - { - hr = (flags & TEX_PMALPHA_IGNORE_SRGB) ? DemultiplyAlpha(src, dst) : DemultiplyAlphaLinear(src, flags, dst); - } - else - { - hr = (flags & TEX_PMALPHA_IGNORE_SRGB) ? PremultiplyAlpha_(src, dst) : PremultiplyAlphaLinear(src, flags, dst); - } - if (FAILED(hr)) - { - result.Release(); - return hr; - } - } - - return S_OK; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexResize.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexResize.cpp deleted file mode 100644 index 831235b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexResize.cpp +++ /dev/null @@ -1,1118 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXTexResize.cpp -// -// DirectX Texture Library - Image resizing operations -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//------------------------------------------------------------------------------------- - -#include "DirectXTexP.h" - -#include "filters.h" - -using namespace DirectX; -using namespace DirectX::Internal; -using Microsoft::WRL::ComPtr; - -namespace -{ -#ifdef _WIN32 - //--- Do image resize using WIC --- - HRESULT PerformResizeUsingWIC( - const Image& srcImage, - TEX_FILTER_FLAGS filter, - const WICPixelFormatGUID& pfGUID, - const Image& destImage) noexcept - { - if (!srcImage.pixels || !destImage.pixels) - return E_POINTER; - - assert(srcImage.format == destImage.format); - - bool iswic2 = false; - auto pWIC = GetWICFactory(iswic2); - if (!pWIC) - return E_NOINTERFACE; - - ComPtr componentInfo; - HRESULT hr = pWIC->CreateComponentInfo(pfGUID, componentInfo.GetAddressOf()); - if (FAILED(hr)) - return hr; - - ComPtr pixelFormatInfo; - hr = componentInfo.As(&pixelFormatInfo); - if (FAILED(hr)) - return hr; - - BOOL supportsTransparency = FALSE; - hr = pixelFormatInfo->SupportsTransparency(&supportsTransparency); - if (FAILED(hr)) - return hr; - - if (srcImage.rowPitch > UINT32_MAX || srcImage.slicePitch > UINT32_MAX - || destImage.rowPitch > UINT32_MAX || destImage.slicePitch > UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - ComPtr source; - hr = pWIC->CreateBitmapFromMemory(static_cast(srcImage.width), static_cast(srcImage.height), pfGUID, - static_cast(srcImage.rowPitch), static_cast(srcImage.slicePitch), - srcImage.pixels, source.GetAddressOf()); - if (FAILED(hr)) - return hr; - - if ((filter & TEX_FILTER_SEPARATE_ALPHA) && supportsTransparency) - { - hr = ResizeSeparateColorAndAlpha(pWIC, iswic2, source.Get(), destImage.width, destImage.height, filter, &destImage); - if (FAILED(hr)) - return hr; - } - else - { - ComPtr scaler; - hr = pWIC->CreateBitmapScaler(scaler.GetAddressOf()); - if (FAILED(hr)) - return hr; - - hr = scaler->Initialize(source.Get(), - static_cast(destImage.width), static_cast(destImage.height), - GetWICInterp(filter)); - if (FAILED(hr)) - return hr; - - WICPixelFormatGUID pfScaler; - hr = scaler->GetPixelFormat(&pfScaler); - if (FAILED(hr)) - return hr; - - if (memcmp(&pfScaler, &pfGUID, sizeof(WICPixelFormatGUID)) == 0) - { - hr = scaler->CopyPixels(nullptr, static_cast(destImage.rowPitch), static_cast(destImage.slicePitch), destImage.pixels); - if (FAILED(hr)) - return hr; - } - else - { - // The WIC bitmap scaler is free to return a different pixel format than the source image, so here we - // convert it back - ComPtr FC; - hr = pWIC->CreateFormatConverter(FC.GetAddressOf()); - if (FAILED(hr)) - return hr; - - BOOL canConvert = FALSE; - hr = FC->CanConvert(pfScaler, pfGUID, &canConvert); - if (FAILED(hr) || !canConvert) - { - return E_UNEXPECTED; - } - - hr = FC->Initialize(scaler.Get(), pfGUID, GetWICDither(filter), nullptr, - 0, WICBitmapPaletteTypeMedianCut); - if (FAILED(hr)) - return hr; - - hr = FC->CopyPixels(nullptr, static_cast(destImage.rowPitch), static_cast(destImage.slicePitch), destImage.pixels); - if (FAILED(hr)) - return hr; - } - } - - return S_OK; - } - - - //--- Do conversion, resize using WIC, conversion cycle --- - HRESULT PerformResizeViaF32( - const Image& srcImage, - TEX_FILTER_FLAGS filter, - const Image& destImage) noexcept - { - if (!srcImage.pixels || !destImage.pixels) - return E_POINTER; - - assert(srcImage.format != DXGI_FORMAT_R32G32B32A32_FLOAT); - assert(srcImage.format == destImage.format); - - ScratchImage temp; - HRESULT hr = ConvertToR32G32B32A32(srcImage, temp); - if (FAILED(hr)) - return hr; - - const Image *tsrc = temp.GetImage(0, 0, 0); - if (!tsrc) - return E_POINTER; - - ScratchImage rtemp; - hr = rtemp.Initialize2D(DXGI_FORMAT_R32G32B32A32_FLOAT, destImage.width, destImage.height, 1, 1); - if (FAILED(hr)) - return hr; - - const Image *tdest = rtemp.GetImage(0, 0, 0); - if (!tdest) - return E_POINTER; - - hr = PerformResizeUsingWIC(*tsrc, filter, GUID_WICPixelFormat128bppRGBAFloat, *tdest); - if (FAILED(hr)) - return hr; - - temp.Release(); - - hr = ConvertFromR32G32B32A32(*tdest, destImage); - if (FAILED(hr)) - return hr; - - return S_OK; - } - - - //--- determine when to use WIC vs. non-WIC paths --- - bool UseWICFiltering(_In_ DXGI_FORMAT format, _In_ TEX_FILTER_FLAGS filter) noexcept - { - if (filter & TEX_FILTER_FORCE_NON_WIC) - { - // Explicit flag indicates use of non-WIC code paths - return false; - } - - if (filter & TEX_FILTER_FORCE_WIC) - { - // Explicit flag to use WIC code paths, skips all the case checks below - return true; - } - - if (IsSRGB(format) || (filter & TEX_FILTER_SRGB)) - { - // Use non-WIC code paths for sRGB correct filtering - return false; - } - - #if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX) - if (format == DXGI_FORMAT_R16G16B16A16_FLOAT - || format == DXGI_FORMAT_R16_FLOAT) - { - // Use non-WIC code paths as these conversions are not supported by Xbox version of WIC - return false; - } - #endif - - static_assert(TEX_FILTER_POINT == 0x100000, "TEX_FILTER_ flag values don't match TEX_FILTER_MASK"); - - switch (filter & TEX_FILTER_MODE_MASK) - { - case TEX_FILTER_LINEAR: - if (filter & TEX_FILTER_WRAP) - { - // WIC only supports 'clamp' semantics (MIRROR is equivalent to clamp for linear) - return false; - } - - if (BitsPerColor(format) > 8) - { - // Avoid the WIC bitmap scaler when doing Linear filtering of XR/HDR formats - return false; - } - break; - - case TEX_FILTER_CUBIC: - if (filter & (TEX_FILTER_WRAP | TEX_FILTER_MIRROR)) - { - // WIC only supports 'clamp' semantics - return false; - } - - if (BitsPerColor(format) > 8) - { - // Avoid the WIC bitmap scaler when doing Cubic filtering of XR/HDR formats - return false; - } - break; - - case TEX_FILTER_TRIANGLE: - // WIC does not implement this filter - return false; - - default: - if (BitsPerColor(format) > 8) - { - // Avoid the WIC bitmap scaler when doing filtering of XR/HDR formats - return false; - } - break; - } - - return true; - } -#endif // WIN32 - - //------------------------------------------------------------------------------------- - // Resize custom filters - //------------------------------------------------------------------------------------- - - //--- Point Filter --- - HRESULT ResizePointFilter(const Image& srcImage, const Image& destImage) noexcept - { - assert(srcImage.pixels && destImage.pixels); - assert(srcImage.format == destImage.format); - - // Allocate temporary space (2 scanlines) - auto scanline = make_AlignedArrayXMVECTOR(uint64_t(srcImage.width) + destImage.width); - if (!scanline) - return E_OUTOFMEMORY; - - XMVECTOR* target = scanline.get(); - - XMVECTOR* row = target + destImage.width; - - #ifdef _DEBUG - memset(row, 0xCD, sizeof(XMVECTOR)*srcImage.width); - #endif - - const uint8_t* pSrc = srcImage.pixels; - uint8_t* pDest = destImage.pixels; - - const size_t rowPitch = srcImage.rowPitch; - - const size_t xinc = (srcImage.width << 16) / destImage.width; - const size_t yinc = (srcImage.height << 16) / destImage.height; - - size_t lasty = size_t(-1); - - size_t sy = 0; - for (size_t y = 0; y < destImage.height; ++y) - { - if ((lasty ^ sy) >> 16) - { - if (!LoadScanline(row, srcImage.width, pSrc + (rowPitch * (sy >> 16)), rowPitch, srcImage.format)) - return E_FAIL; - lasty = sy; - } - - size_t sx = 0; - for (size_t x = 0; x < destImage.width; ++x) - { - target[x] = row[sx >> 16]; - sx += xinc; - } - - if (!StoreScanline(pDest, destImage.rowPitch, destImage.format, target, destImage.width)) - return E_FAIL; - pDest += destImage.rowPitch; - - sy += yinc; - } - - return S_OK; - } - - - //--- Box Filter --- - HRESULT ResizeBoxFilter(const Image& srcImage, TEX_FILTER_FLAGS filter, const Image& destImage) noexcept - { - using namespace DirectX::Filters; - - assert(srcImage.pixels && destImage.pixels); - assert(srcImage.format == destImage.format); - - if (((destImage.width << 1) != srcImage.width) || ((destImage.height << 1) != srcImage.height)) - return E_FAIL; - - // Allocate temporary space (3 scanlines) - auto scanline = make_AlignedArrayXMVECTOR(uint64_t(srcImage.width) * 2 + destImage.width); - if (!scanline) - return E_OUTOFMEMORY; - - XMVECTOR* target = scanline.get(); - - XMVECTOR* urow0 = target + destImage.width; - XMVECTOR* urow1 = urow0 + srcImage.width; - - #ifdef _DEBUG - memset(urow0, 0xCD, sizeof(XMVECTOR)*srcImage.width); - memset(urow1, 0xDD, sizeof(XMVECTOR)*srcImage.width); - #endif - - const XMVECTOR* urow2 = urow0 + 1; - const XMVECTOR* urow3 = urow1 + 1; - - const uint8_t* pSrc = srcImage.pixels; - uint8_t* pDest = destImage.pixels; - - const size_t rowPitch = srcImage.rowPitch; - - for (size_t y = 0; y < destImage.height; ++y) - { - if (!LoadScanlineLinear(urow0, srcImage.width, pSrc, rowPitch, srcImage.format, filter)) - return E_FAIL; - pSrc += rowPitch; - - if (urow0 != urow1) - { - if (!LoadScanlineLinear(urow1, srcImage.width, pSrc, rowPitch, srcImage.format, filter)) - return E_FAIL; - pSrc += rowPitch; - } - - for (size_t x = 0; x < destImage.width; ++x) - { - const size_t x2 = x << 1; - - AVERAGE4(target[x], urow0[x2], urow1[x2], urow2[x2], urow3[x2]) - } - - if (!StoreScanlineLinear(pDest, destImage.rowPitch, destImage.format, target, destImage.width, filter)) - return E_FAIL; - pDest += destImage.rowPitch; - } - - return S_OK; - } - - - //--- Linear Filter --- - HRESULT ResizeLinearFilter(const Image& srcImage, TEX_FILTER_FLAGS filter, const Image& destImage) noexcept - { - using namespace DirectX::Filters; - - assert(srcImage.pixels && destImage.pixels); - assert(srcImage.format == destImage.format); - - // Allocate temporary space (3 scanlines, plus X and Y filters) - auto scanline = make_AlignedArrayXMVECTOR(uint64_t(srcImage.width) * 2 + destImage.width); - if (!scanline) - return E_OUTOFMEMORY; - - std::unique_ptr lf(new (std::nothrow) LinearFilter[destImage.width + destImage.height]); - if (!lf) - return E_OUTOFMEMORY; - - LinearFilter* lfX = lf.get(); - LinearFilter* lfY = lf.get() + destImage.width; - - CreateLinearFilter(srcImage.width, destImage.width, (filter & TEX_FILTER_WRAP_U) != 0, lfX); - CreateLinearFilter(srcImage.height, destImage.height, (filter & TEX_FILTER_WRAP_V) != 0, lfY); - - XMVECTOR* target = scanline.get(); - - XMVECTOR* row0 = target + destImage.width; - XMVECTOR* row1 = row0 + srcImage.width; - - #ifdef _DEBUG - memset(row0, 0xCD, sizeof(XMVECTOR)*srcImage.width); - memset(row1, 0xDD, sizeof(XMVECTOR)*srcImage.width); - #endif - - const uint8_t* pSrc = srcImage.pixels; - uint8_t* pDest = destImage.pixels; - - const size_t rowPitch = srcImage.rowPitch; - - size_t u0 = size_t(-1); - size_t u1 = size_t(-1); - - for (size_t y = 0; y < destImage.height; ++y) - { - auto const& toY = lfY[y]; - - if (toY.u0 != u0) - { - if (toY.u0 != u1) - { - u0 = toY.u0; - - if (!LoadScanlineLinear(row0, srcImage.width, pSrc + (rowPitch * u0), rowPitch, srcImage.format, filter)) - return E_FAIL; - } - else - { - u0 = u1; - u1 = size_t(-1); - - std::swap(row0, row1); - } - } - - if (toY.u1 != u1) - { - u1 = toY.u1; - - if (!LoadScanlineLinear(row1, srcImage.width, pSrc + (rowPitch * u1), rowPitch, srcImage.format, filter)) - return E_FAIL; - } - - for (size_t x = 0; x < destImage.width; ++x) - { - auto const& toX = lfX[x]; - - BILINEAR_INTERPOLATE(target[x], toX, toY, row0, row1) - } - - if (!StoreScanlineLinear(pDest, destImage.rowPitch, destImage.format, target, destImage.width, filter)) - return E_FAIL; - pDest += destImage.rowPitch; - } - - return S_OK; - } - - - //--- Cubic Filter --- -#ifdef __clang__ -#pragma clang diagnostic ignored "-Wextra-semi-stmt" -#endif - - HRESULT ResizeCubicFilter(const Image& srcImage, TEX_FILTER_FLAGS filter, const Image& destImage) noexcept - { - using namespace DirectX::Filters; - - assert(srcImage.pixels && destImage.pixels); - assert(srcImage.format == destImage.format); - - // Allocate temporary space (5 scanlines, plus X and Y filters) - auto scanline = make_AlignedArrayXMVECTOR(uint64_t(srcImage.width) * 4 + destImage.width); - if (!scanline) - return E_OUTOFMEMORY; - - std::unique_ptr cf(new (std::nothrow) CubicFilter[destImage.width + destImage.height]); - if (!cf) - return E_OUTOFMEMORY; - - CubicFilter* cfX = cf.get(); - CubicFilter* cfY = cf.get() + destImage.width; - - CreateCubicFilter(srcImage.width, destImage.width, (filter & TEX_FILTER_WRAP_U) != 0, (filter & TEX_FILTER_MIRROR_U) != 0, cfX); - CreateCubicFilter(srcImage.height, destImage.height, (filter & TEX_FILTER_WRAP_V) != 0, (filter & TEX_FILTER_MIRROR_V) != 0, cfY); - - XMVECTOR* target = scanline.get(); - - XMVECTOR* row0 = target + destImage.width; - XMVECTOR* row1 = row0 + srcImage.width; - XMVECTOR* row2 = row0 + srcImage.width * 2; - XMVECTOR* row3 = row0 + srcImage.width * 3; - - #ifdef _DEBUG - memset(row0, 0xCD, sizeof(XMVECTOR)*srcImage.width); - memset(row1, 0xDD, sizeof(XMVECTOR)*srcImage.width); - memset(row2, 0xED, sizeof(XMVECTOR)*srcImage.width); - memset(row3, 0xFD, sizeof(XMVECTOR)*srcImage.width); - #endif - - const uint8_t* pSrc = srcImage.pixels; - uint8_t* pDest = destImage.pixels; - - const size_t rowPitch = srcImage.rowPitch; - - size_t u0 = size_t(-1); - size_t u1 = size_t(-1); - size_t u2 = size_t(-1); - size_t u3 = size_t(-1); - - for (size_t y = 0; y < destImage.height; ++y) - { - auto const& toY = cfY[y]; - - // Scanline 1 - if (toY.u0 != u0) - { - if (toY.u0 != u1 && toY.u0 != u2 && toY.u0 != u3) - { - u0 = toY.u0; - - if (!LoadScanlineLinear(row0, srcImage.width, pSrc + (rowPitch * u0), rowPitch, srcImage.format, filter)) - return E_FAIL; - } - else if (toY.u0 == u1) - { - u0 = u1; - u1 = size_t(-1); - - std::swap(row0, row1); - } - else if (toY.u0 == u2) - { - u0 = u2; - u2 = size_t(-1); - - std::swap(row0, row2); - } - else if (toY.u0 == u3) - { - u0 = u3; - u3 = size_t(-1); - - std::swap(row0, row3); - } - } - - // Scanline 2 - if (toY.u1 != u1) - { - if (toY.u1 != u2 && toY.u1 != u3) - { - u1 = toY.u1; - - if (!LoadScanlineLinear(row1, srcImage.width, pSrc + (rowPitch * u1), rowPitch, srcImage.format, filter)) - return E_FAIL; - } - else if (toY.u1 == u2) - { - u1 = u2; - u2 = size_t(-1); - - std::swap(row1, row2); - } - else if (toY.u1 == u3) - { - u1 = u3; - u3 = size_t(-1); - - std::swap(row1, row3); - } - } - - // Scanline 3 - if (toY.u2 != u2) - { - if (toY.u2 != u3) - { - u2 = toY.u2; - - if (!LoadScanlineLinear(row2, srcImage.width, pSrc + (rowPitch * u2), rowPitch, srcImage.format, filter)) - return E_FAIL; - } - else - { - u2 = u3; - u3 = size_t(-1); - - std::swap(row2, row3); - } - } - - // Scanline 4 - if (toY.u3 != u3) - { - u3 = toY.u3; - - if (!LoadScanlineLinear(row3, srcImage.width, pSrc + (rowPitch * u3), rowPitch, srcImage.format, filter)) - return E_FAIL; - } - - for (size_t x = 0; x < destImage.width; ++x) - { - auto const& toX = cfX[x]; - - XMVECTOR C0, C1, C2, C3; - - CUBIC_INTERPOLATE(C0, toX.x, row0[toX.u0], row0[toX.u1], row0[toX.u2], row0[toX.u3]); - CUBIC_INTERPOLATE(C1, toX.x, row1[toX.u0], row1[toX.u1], row1[toX.u2], row1[toX.u3]); - CUBIC_INTERPOLATE(C2, toX.x, row2[toX.u0], row2[toX.u1], row2[toX.u2], row2[toX.u3]); - CUBIC_INTERPOLATE(C3, toX.x, row3[toX.u0], row3[toX.u1], row3[toX.u2], row3[toX.u3]); - - CUBIC_INTERPOLATE(target[x], toY.x, C0, C1, C2, C3); - } - - if (!StoreScanlineLinear(pDest, destImage.rowPitch, destImage.format, target, destImage.width, filter)) - return E_FAIL; - pDest += destImage.rowPitch; - } - - return S_OK; - } - - - //--- Triangle Filter --- - HRESULT ResizeTriangleFilter(const Image& srcImage, TEX_FILTER_FLAGS filter, const Image& destImage) noexcept - { - using namespace DirectX::Filters; - - assert(srcImage.pixels && destImage.pixels); - assert(srcImage.format == destImage.format); - - // Allocate initial temporary space (1 scanline, accumulation rows, plus X and Y filters) - auto scanline = make_AlignedArrayXMVECTOR(srcImage.width); - if (!scanline) - return E_OUTOFMEMORY; - - std::unique_ptr rowActive(new (std::nothrow) TriangleRow[destImage.height]); - if (!rowActive) - return E_OUTOFMEMORY; - - TriangleRow * rowFree = nullptr; - - std::unique_ptr tfX; - HRESULT hr = CreateTriangleFilter(srcImage.width, destImage.width, (filter & TEX_FILTER_WRAP_U) != 0, tfX); - if (FAILED(hr)) - return hr; - - std::unique_ptr tfY; - hr = CreateTriangleFilter(srcImage.height, destImage.height, (filter & TEX_FILTER_WRAP_V) != 0, tfY); - if (FAILED(hr)) - return hr; - - XMVECTOR* row = scanline.get(); - - #ifdef _DEBUG - memset(row, 0xCD, sizeof(XMVECTOR)*srcImage.width); - #endif - - auto xFromEnd = reinterpret_cast(reinterpret_cast(tfX.get()) + tfX->sizeInBytes); - auto yFromEnd = reinterpret_cast(reinterpret_cast(tfY.get()) + tfY->sizeInBytes); - - // Count times rows get written - for (FilterFrom* yFrom = tfY->from; yFrom < yFromEnd; ) - { - for (size_t j = 0; j < yFrom->count; ++j) - { - const size_t v = yFrom->to[j].u; - assert(v < destImage.height); - ++rowActive[v].remaining; - } - - yFrom = reinterpret_cast(reinterpret_cast(yFrom) + yFrom->sizeInBytes); - } - - // Filter image - const uint8_t* pSrc = srcImage.pixels; - const size_t rowPitch = srcImage.rowPitch; - const uint8_t* pEndSrc = pSrc + rowPitch * srcImage.height; - - uint8_t* pDest = destImage.pixels; - - for (FilterFrom* yFrom = tfY->from; yFrom < yFromEnd; ) - { - // Create accumulation rows as needed - for (size_t j = 0; j < yFrom->count; ++j) - { - const size_t v = yFrom->to[j].u; - assert(v < destImage.height); - TriangleRow* rowAcc = &rowActive[v]; - - if (!rowAcc->scanline) - { - if (rowFree) - { - // Steal and reuse scanline from 'free row' list - assert(rowFree->scanline != nullptr); - rowAcc->scanline.reset(rowFree->scanline.release()); - rowFree = rowFree->next; - } - else - { - auto nscanline = make_AlignedArrayXMVECTOR(destImage.width); - if (!nscanline) - return E_OUTOFMEMORY; - rowAcc->scanline.swap(nscanline); - } - - memset(rowAcc->scanline.get(), 0, sizeof(XMVECTOR) * destImage.width); - } - } - - // Load source scanline - if ((pSrc + rowPitch) > pEndSrc) - return E_FAIL; - - if (!LoadScanlineLinear(row, srcImage.width, pSrc, rowPitch, srcImage.format, filter)) - return E_FAIL; - - pSrc += rowPitch; - - // Process row - size_t x = 0; - for (FilterFrom* xFrom = tfX->from; xFrom < xFromEnd; ++x) - { - for (size_t j = 0; j < yFrom->count; ++j) - { - const size_t v = yFrom->to[j].u; - assert(v < destImage.height); - const float yweight = yFrom->to[j].weight; - - XMVECTOR* accPtr = rowActive[v].scanline.get(); - if (!accPtr) - return E_POINTER; - - for (size_t k = 0; k < xFrom->count; ++k) - { - size_t u = xFrom->to[k].u; - assert(u < destImage.width); - - const XMVECTOR weight = XMVectorReplicate(yweight * xFrom->to[k].weight); - - assert(x < srcImage.width); - accPtr[u] = XMVectorMultiplyAdd(row[x], weight, accPtr[u]); - } - } - - xFrom = reinterpret_cast(reinterpret_cast(xFrom) + xFrom->sizeInBytes); - } - - // Write completed accumulation rows - for (size_t j = 0; j < yFrom->count; ++j) - { - size_t v = yFrom->to[j].u; - assert(v < destImage.height); - TriangleRow* rowAcc = &rowActive[v]; - - assert(rowAcc->remaining > 0); - --rowAcc->remaining; - - if (!rowAcc->remaining) - { - XMVECTOR* pAccSrc = rowAcc->scanline.get(); - if (!pAccSrc) - return E_POINTER; - - switch (destImage.format) - { - case DXGI_FORMAT_R10G10B10A2_UNORM: - case DXGI_FORMAT_R10G10B10A2_UINT: - { - // Need to slightly bias results for floating-point error accumulation which can - // be visible with harshly quantized values - static const XMVECTORF32 Bias = { { { 0.f, 0.f, 0.f, 0.1f } } }; - - XMVECTOR* ptr = pAccSrc; - for (size_t i = 0; i < destImage.width; ++i, ++ptr) - { - *ptr = XMVectorAdd(*ptr, Bias); - } - } - break; - - default: - break; - } - - // This performs any required clamping - if (!StoreScanlineLinear(pDest + (destImage.rowPitch * v), destImage.rowPitch, destImage.format, pAccSrc, destImage.width, filter)) - return E_FAIL; - - // Put row on freelist to reuse it's allocated scanline - rowAcc->next = rowFree; - rowFree = rowAcc; - } - } - - yFrom = reinterpret_cast(reinterpret_cast(yFrom) + yFrom->sizeInBytes); - } - - return S_OK; - } - - - //--- Custom filter resize --- - HRESULT PerformResizeUsingCustomFilters(const Image& srcImage, TEX_FILTER_FLAGS filter, const Image& destImage) noexcept - { - if (!srcImage.pixels || !destImage.pixels) - return E_POINTER; - - static_assert(TEX_FILTER_POINT == 0x100000, "TEX_FILTER_ flag values don't match TEX_FILTER_MASK"); - - unsigned long filter_select = filter & TEX_FILTER_MODE_MASK; - if (!filter_select) - { - // Default filter choice - filter_select = (((destImage.width << 1) == srcImage.width) && ((destImage.height << 1) == srcImage.height)) - ? TEX_FILTER_BOX : TEX_FILTER_LINEAR; - } - - switch (filter_select) - { - case TEX_FILTER_POINT: - return ResizePointFilter(srcImage, destImage); - - case TEX_FILTER_BOX: - return ResizeBoxFilter(srcImage, filter, destImage); - - case TEX_FILTER_LINEAR: - return ResizeLinearFilter(srcImage, filter, destImage); - - case TEX_FILTER_CUBIC: - return ResizeCubicFilter(srcImage, filter, destImage); - - case TEX_FILTER_TRIANGLE: - return ResizeTriangleFilter(srcImage, filter, destImage); - - default: - return HRESULT_E_NOT_SUPPORTED; - } - } -} - - -//===================================================================================== -// Entry-points -//===================================================================================== - -//------------------------------------------------------------------------------------- -// Resize image -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::Resize( - const Image& srcImage, - size_t width, - size_t height, - TEX_FILTER_FLAGS filter, - ScratchImage& image) noexcept -{ - if (width == 0 || height == 0) - return E_INVALIDARG; - - if ((srcImage.width > UINT32_MAX) || (srcImage.height > UINT32_MAX)) - return E_INVALIDARG; - - if ((width > UINT32_MAX) || (height > UINT32_MAX)) - return E_INVALIDARG; - - if (!srcImage.pixels) - return E_POINTER; - - if (IsCompressed(srcImage.format)) - { - // We don't support resizing compressed images - return HRESULT_E_NOT_SUPPORTED; - } - -#ifdef _WIN32 - bool usewic = UseWICFiltering(srcImage.format, filter); - - WICPixelFormatGUID pfGUID = {}; - const bool wicpf = (usewic) ? DXGIToWIC(srcImage.format, pfGUID, true) : false; - - if (usewic && !wicpf) - { - // Check to see if the source and/or result size is too big for WIC - const uint64_t expandedSize = uint64_t(width) * uint64_t(height) * sizeof(float) * 4; - const uint64_t expandedSize2 = uint64_t(srcImage.width) * uint64_t(srcImage.height) * sizeof(float) * 4; - if (expandedSize > UINT32_MAX || expandedSize2 > UINT32_MAX) - { - if (filter & TEX_FILTER_FORCE_WIC) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - usewic = false; - } - } -#endif // WIN32 - - HRESULT hr = image.Initialize2D(srcImage.format, width, height, 1, 1); - if (FAILED(hr)) - return hr; - - const Image *rimage = image.GetImage(0, 0, 0); - if (!rimage) - return E_POINTER; - -#ifdef _WIN32 - if (usewic) - { - if (wicpf) - { - // Case 1: Source format is supported by Windows Imaging Component - hr = PerformResizeUsingWIC(srcImage, filter, pfGUID, *rimage); - } - else - { - // Case 2: Source format is not supported by WIC, so we have to convert, resize, and convert back - hr = PerformResizeViaF32(srcImage, filter, *rimage); - } - } - else - #endif - { - // Case 3: not using WIC resizing - hr = PerformResizeUsingCustomFilters(srcImage, filter, *rimage); - } - - if (FAILED(hr)) - { - image.Release(); - return hr; - } - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -// Resize image (complex) -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::Resize( - const Image* srcImages, - size_t nimages, - const TexMetadata& metadata, - size_t width, - size_t height, - TEX_FILTER_FLAGS filter, - ScratchImage& result) noexcept -{ - if (!srcImages || !nimages || width == 0 || height == 0) - return E_INVALIDARG; - - if ((width > UINT32_MAX) || (height > UINT32_MAX)) - return E_INVALIDARG; - - TexMetadata mdata2 = metadata; - mdata2.width = width; - mdata2.height = height; - mdata2.mipLevels = 1; - HRESULT hr = result.Initialize(mdata2); - if (FAILED(hr)) - return hr; - -#ifdef _WIN32 - bool usewic = !metadata.IsPMAlpha() && UseWICFiltering(metadata.format, filter); - - WICPixelFormatGUID pfGUID = {}; - const bool wicpf = (usewic) ? DXGIToWIC(metadata.format, pfGUID, true) : false; - - if (usewic && !wicpf) - { - // Check to see if the source and/or result size is too big for WIC - const uint64_t expandedSize = uint64_t(width) * uint64_t(height) * sizeof(float) * 4; - const uint64_t expandedSize2 = uint64_t(metadata.width) * uint64_t(metadata.height) * sizeof(float) * 4; - if (expandedSize > UINT32_MAX || expandedSize2 > UINT32_MAX) - { - if (filter & TEX_FILTER_FORCE_WIC) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - usewic = false; - } - } -#endif - - switch (metadata.dimension) - { - case TEX_DIMENSION_TEXTURE1D: - case TEX_DIMENSION_TEXTURE2D: - assert(metadata.depth == 1); - - for (size_t item = 0; item < metadata.arraySize; ++item) - { - const size_t srcIndex = metadata.ComputeIndex(0, item, 0); - if (srcIndex >= nimages) - { - result.Release(); - return E_FAIL; - } - - const Image* srcimg = &srcImages[srcIndex]; - const Image* destimg = result.GetImage(0, item, 0); - if (!srcimg || !destimg) - { - result.Release(); - return E_POINTER; - } - - if (srcimg->format != metadata.format) - { - result.Release(); - return E_FAIL; - } - - if ((srcimg->width > UINT32_MAX) || (srcimg->height > UINT32_MAX)) - { - result.Release(); - return E_FAIL; - } - - #ifdef _WIN32 - if (usewic) - { - if (wicpf) - { - // Case 1: Source format is supported by Windows Imaging Component - hr = PerformResizeUsingWIC(*srcimg, filter, pfGUID, *destimg); - } - else - { - // Case 2: Source format is not supported by WIC, so we have to convert, resize, and convert back - hr = PerformResizeViaF32(*srcimg, filter, *destimg); - } - } - else - #endif - { - // Case 3: not using WIC resizing - hr = PerformResizeUsingCustomFilters(*srcimg, filter, *destimg); - } - - if (FAILED(hr)) - { - result.Release(); - return hr; - } - } - break; - - case TEX_DIMENSION_TEXTURE3D: - assert(metadata.arraySize == 1); - - for (size_t slice = 0; slice < metadata.depth; ++slice) - { - const size_t srcIndex = metadata.ComputeIndex(0, 0, slice); - if (srcIndex >= nimages) - { - result.Release(); - return E_FAIL; - } - - const Image* srcimg = &srcImages[srcIndex]; - const Image* destimg = result.GetImage(0, 0, slice); - if (!srcimg || !destimg) - { - result.Release(); - return E_POINTER; - } - - if (srcimg->format != metadata.format) - { - result.Release(); - return E_FAIL; - } - - if ((srcimg->width > UINT32_MAX) || (srcimg->height > UINT32_MAX)) - { - result.Release(); - return E_FAIL; - } - - #ifdef _WIN32 - if (usewic) - { - if (wicpf) - { - // Case 1: Source format is supported by Windows Imaging Component - hr = PerformResizeUsingWIC(*srcimg, filter, pfGUID, *destimg); - } - else - { - // Case 2: Source format is not supported by WIC, so we have to convert, resize, and convert back - hr = PerformResizeViaF32(*srcimg, filter, *destimg); - } - } - else - #endif - { - // Case 3: not using WIC resizing - hr = PerformResizeUsingCustomFilters(*srcimg, filter, *destimg); - } - - if (FAILED(hr)) - { - result.Release(); - return hr; - } - } - break; - - default: - result.Release(); - return E_FAIL; - } - - return S_OK; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexTGA.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexTGA.cpp deleted file mode 100644 index 4f0b4a0..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexTGA.cpp +++ /dev/null @@ -1,2524 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXTexTGA.cpp -// -// DirectX Texture Library - Targa Truevision (TGA) file format reader/writer -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//------------------------------------------------------------------------------------- - -#include "DirectXTexP.h" - -// -// The implementation here has the following limitations: -// * Does not support files that contain color maps (these are rare in practice) -// * Interleaved files are not supported (deprecated aspect of TGA format) -// * Only supports 8-bit grayscale; 16-, 24-, and 32-bit truecolor images RLE or uncompressed -// plus 24-bit color-mapped uncompressed images -// * Always writes uncompressed files (i.e. can read RLE compression, but does not write it) -// - -using namespace DirectX; -using namespace DirectX::Internal; - -namespace -{ - constexpr float GAMMA_EPSILON = 0.01f; - - const char g_Signature[] = "TRUEVISION-XFILE."; - // This is the official footer signature for the TGA 2.0 file format. - - enum TGAImageType - { - TGA_NO_IMAGE = 0, - TGA_COLOR_MAPPED = 1, - TGA_TRUECOLOR = 2, - TGA_BLACK_AND_WHITE = 3, - TGA_COLOR_MAPPED_RLE = 9, - TGA_TRUECOLOR_RLE = 10, - TGA_BLACK_AND_WHITE_RLE = 11, - }; - - enum TGADescriptorFlags - { - TGA_FLAGS_INVERTX = 0x10, - TGA_FLAGS_INVERTY = 0x20, - TGA_FLAGS_INTERLEAVED_2WAY = 0x40, // Deprecated - TGA_FLAGS_INTERLEAVED_4WAY = 0x80, // Deprecated - }; - - enum TGAAttributesType : uint8_t - { - TGA_ATTRIBUTE_NONE = 0, // 0: no alpha data included - TGA_ATTRIBUTE_IGNORED = 1, // 1: undefined data, can be ignored - TGA_ATTRIBUTE_UNDEFINED = 2, // 2: uedefined data, should be retained - TGA_ATTRIBUTE_ALPHA = 3, // 3: useful alpha channel data - TGA_ATTRIBUTE_PREMULTIPLIED = 4, // 4: pre-multiplied alpha - }; - -#pragma pack(push,1) - struct TGA_HEADER - { - uint8_t bIDLength; - uint8_t bColorMapType; - uint8_t bImageType; - uint16_t wColorMapFirst; - uint16_t wColorMapLength; - uint8_t bColorMapSize; - uint16_t wXOrigin; - uint16_t wYOrigin; - uint16_t wWidth; - uint16_t wHeight; - uint8_t bBitsPerPixel; - uint8_t bDescriptor; - }; - - static_assert(sizeof(TGA_HEADER) == 18, "TGA 2.0 size mismatch"); - - constexpr size_t TGA_HEADER_LEN = 18; - - struct TGA_FOOTER - { - uint32_t dwExtensionOffset; - uint32_t dwDeveloperOffset; - char Signature[18]; - }; - - static_assert(sizeof(TGA_FOOTER) == 26, "TGA 2.0 size mismatch"); - - struct TGA_EXTENSION - { - uint16_t wSize; - char szAuthorName[41]; - char szAuthorComment[324]; - uint16_t wStampMonth; - uint16_t wStampDay; - uint16_t wStampYear; - uint16_t wStampHour; - uint16_t wStampMinute; - uint16_t wStampSecond; - char szJobName[41]; - uint16_t wJobHour; - uint16_t wJobMinute; - uint16_t wJobSecond; - char szSoftwareId[41]; - uint16_t wVersionNumber; - uint8_t bVersionLetter; - uint32_t dwKeyColor; - uint16_t wPixelNumerator; - uint16_t wPixelDenominator; - uint16_t wGammaNumerator; - uint16_t wGammaDenominator; - uint32_t dwColorOffset; - uint32_t dwStampOffset; - uint32_t dwScanOffset; - uint8_t bAttributesType; - }; - - static_assert(sizeof(TGA_EXTENSION) == 495, "TGA 2.0 size mismatch"); - -#pragma pack(pop) - - enum CONVERSION_FLAGS - { - CONV_FLAGS_NONE = 0x0, - CONV_FLAGS_EXPAND = 0x1, // Conversion requires expanded pixel size - CONV_FLAGS_INVERTX = 0x2, // If set, scanlines are right-to-left - CONV_FLAGS_INVERTY = 0x4, // If set, scanlines are top-to-bottom - CONV_FLAGS_RLE = 0x8, // Source data is RLE compressed - CONV_FLAGS_PALETTED = 0x10, // Source data is paletted - - CONV_FLAGS_SWIZZLE = 0x10000, // Swizzle BGR<->RGB data - CONV_FLAGS_888 = 0x20000, // 24bpp format - }; - - - //------------------------------------------------------------------------------------- - // Decodes TGA header - //------------------------------------------------------------------------------------- - HRESULT DecodeTGAHeader( - _In_reads_bytes_(size) const void* pSource, - size_t size, - TGA_FLAGS flags, - _Out_ TexMetadata& metadata, - size_t& offset, - _Inout_opt_ uint32_t* convFlags) noexcept - { - if (!pSource) - return E_INVALIDARG; - - memset(&metadata, 0, sizeof(TexMetadata)); - - if (size < TGA_HEADER_LEN) - { - return HRESULT_E_INVALID_DATA; - } - - auto pHeader = static_cast(pSource); - - if (pHeader->bDescriptor & (TGA_FLAGS_INTERLEAVED_2WAY | TGA_FLAGS_INTERLEAVED_4WAY)) - { - return HRESULT_E_NOT_SUPPORTED; - } - - if (!pHeader->wWidth || !pHeader->wHeight) - { - // These are uint16 values so are already bounded by UINT16_MAX. - return HRESULT_E_INVALID_DATA; - } - - switch (pHeader->bImageType) - { - case TGA_NO_IMAGE: - case TGA_COLOR_MAPPED_RLE: - return HRESULT_E_NOT_SUPPORTED; - - case TGA_COLOR_MAPPED: - if (pHeader->bColorMapType != 1 - || pHeader->wColorMapLength == 0 - || pHeader->bBitsPerPixel != 8) - { - return HRESULT_E_NOT_SUPPORTED; - } - - switch (pHeader->bColorMapSize) - { - case 24: - if (flags & TGA_FLAGS_BGR) - { - metadata.format = DXGI_FORMAT_B8G8R8X8_UNORM; - } - else - { - metadata.format = DXGI_FORMAT_R8G8B8A8_UNORM; - metadata.SetAlphaMode(TEX_ALPHA_MODE_OPAQUE); - } - break; - - // Other possible values are 15, 16, and 32 which we do not support. - - default: - return HRESULT_E_NOT_SUPPORTED; - } - - if (convFlags) - { - *convFlags |= CONV_FLAGS_PALETTED; - } - break; - - case TGA_TRUECOLOR: - case TGA_TRUECOLOR_RLE: - if (pHeader->bColorMapType != 0 - || pHeader->wColorMapLength != 0) - { - return HRESULT_E_NOT_SUPPORTED; - } - - switch (pHeader->bBitsPerPixel) - { - case 16: - metadata.format = DXGI_FORMAT_B5G5R5A1_UNORM; - break; - - case 24: - if (flags & TGA_FLAGS_BGR) - { - metadata.format = DXGI_FORMAT_B8G8R8X8_UNORM; - } - else - { - metadata.format = DXGI_FORMAT_R8G8B8A8_UNORM; - metadata.SetAlphaMode(TEX_ALPHA_MODE_OPAQUE); - } - - if (convFlags) - *convFlags |= CONV_FLAGS_EXPAND; - break; - - case 32: - metadata.format = (flags & TGA_FLAGS_BGR) ? DXGI_FORMAT_B8G8R8A8_UNORM : DXGI_FORMAT_R8G8B8A8_UNORM; - break; - - default: - return HRESULT_E_NOT_SUPPORTED; - } - - if (convFlags && (pHeader->bImageType == TGA_TRUECOLOR_RLE)) - { - *convFlags |= CONV_FLAGS_RLE; - } - break; - - case TGA_BLACK_AND_WHITE: - case TGA_BLACK_AND_WHITE_RLE: - if (pHeader->bColorMapType != 0 - || pHeader->wColorMapLength != 0) - { - return HRESULT_E_NOT_SUPPORTED; - } - - switch (pHeader->bBitsPerPixel) - { - case 8: - metadata.format = DXGI_FORMAT_R8_UNORM; - break; - - default: - return HRESULT_E_NOT_SUPPORTED; - } - - if (convFlags && (pHeader->bImageType == TGA_BLACK_AND_WHITE_RLE)) - { - *convFlags |= CONV_FLAGS_RLE; - } - break; - - default: - return HRESULT_E_INVALID_DATA; - } - - metadata.width = pHeader->wWidth; - metadata.height = pHeader->wHeight; - metadata.depth = metadata.arraySize = metadata.mipLevels = 1; - metadata.dimension = TEX_DIMENSION_TEXTURE2D; - - if (convFlags) - { - if (pHeader->bDescriptor & TGA_FLAGS_INVERTX) - *convFlags |= CONV_FLAGS_INVERTX; - - if (pHeader->bDescriptor & TGA_FLAGS_INVERTY) - *convFlags |= CONV_FLAGS_INVERTY; - } - - offset = TGA_HEADER_LEN; - - if (pHeader->bIDLength != 0) - { - offset += pHeader->bIDLength; - } - - return S_OK; - } - - - //------------------------------------------------------------------------------------- - // Reads palette for color-mapped TGA formats - //------------------------------------------------------------------------------------- - HRESULT ReadPalette( - _In_reads_(TGA_HEADER_LEN) const uint8_t* header, - _In_reads_bytes_(size) const void* pSource, - size_t size, - TGA_FLAGS flags, - uint8_t palette[256 * 4], - size_t& colorMapSize) noexcept - { - assert(header && pSource); - - auto pHeader = reinterpret_cast(header); - - if (pHeader->bColorMapType != 1 - || pHeader->wColorMapLength == 0 - || pHeader->wColorMapLength > 256 - || pHeader->bColorMapSize != 24) - { - return HRESULT_E_NOT_SUPPORTED; - } - - size_t maxColorMap = size_t(pHeader->wColorMapFirst) + size_t(pHeader->wColorMapLength); - if (maxColorMap > 256) - { - return HRESULT_E_NOT_SUPPORTED; - } - - colorMapSize = size_t(pHeader->wColorMapLength) * ((size_t(pHeader->bColorMapSize) + 7) >> 3); - if (colorMapSize > size) - { - return HRESULT_E_INVALID_DATA; - } - - auto bytes = reinterpret_cast(pSource); - - for (size_t i = pHeader->wColorMapFirst; i < maxColorMap; ++i) - { - if (flags & TGA_FLAGS_BGR) - { - palette[i * 4 + 0] = bytes[0]; - palette[i * 4 + 2] = bytes[2]; - } - else - { - palette[i * 4 + 0] = bytes[2]; - palette[i * 4 + 2] = bytes[0]; - } - palette[i * 4 + 1] = bytes[1]; - palette[i * 4 + 3] = 255; - bytes += 3; - } - - return S_OK; - } - - - //------------------------------------------------------------------------------------- - // Set alpha for images with all 0 alpha channel - //------------------------------------------------------------------------------------- - HRESULT SetAlphaChannelToOpaque(_In_ const Image* image) noexcept - { - assert(image); - - uint8_t* pPixels = image->pixels; - if (!pPixels) - return E_POINTER; - - for (size_t y = 0; y < image->height; ++y) - { - CopyScanline(pPixels, image->rowPitch, pPixels, image->rowPitch, image->format, TEXP_SCANLINE_SETALPHA); - pPixels += image->rowPitch; - } - - return S_OK; - } - - - //------------------------------------------------------------------------------------- - // Uncompress pixel data from a TGA into the target image - //------------------------------------------------------------------------------------- - HRESULT UncompressPixels( - _In_reads_bytes_(size) const void* pSource, - size_t size, - TGA_FLAGS flags, - _In_ const Image* image, - _In_ uint32_t convFlags) noexcept - { - assert(pSource && size > 0); - - if (!image || !image->pixels) - return E_POINTER; - - // Compute TGA image data pitch - size_t rowPitch, slicePitch; - HRESULT hr = ComputePitch(image->format, image->width, image->height, rowPitch, slicePitch, - (convFlags & CONV_FLAGS_EXPAND) ? CP_FLAGS_24BPP : CP_FLAGS_NONE); - if (FAILED(hr)) - return hr; - - auto sPtr = static_cast(pSource); - const uint8_t* endPtr = sPtr + size; - - bool opaquealpha = false; - - switch (image->format) - { - //--------------------------------------------------------------------------- 8-bit - case DXGI_FORMAT_R8_UNORM: - for (size_t y = 0; y < image->height; ++y) - { - size_t offset = ((convFlags & CONV_FLAGS_INVERTX) ? (image->width - 1) : 0); - assert(offset < rowPitch); - - uint8_t* dPtr = image->pixels - + (image->rowPitch * ((convFlags & CONV_FLAGS_INVERTY) ? y : (image->height - y - 1))) - + offset; - - for (size_t x = 0; x < image->width; ) - { - if (sPtr >= endPtr) - return E_FAIL; - - if (*sPtr & 0x80) - { - // Repeat - size_t j = size_t(*sPtr & 0x7F) + 1; - if (++sPtr >= endPtr) - return E_FAIL; - - for (; j > 0; --j, ++x) - { - if (x >= image->width) - return E_FAIL; - - *dPtr = *sPtr; - - if (convFlags & CONV_FLAGS_INVERTX) - --dPtr; - else - ++dPtr; - } - - ++sPtr; - } - else - { - // Literal - size_t j = size_t(*sPtr & 0x7F) + 1; - ++sPtr; - - if (sPtr + j > endPtr) - return E_FAIL; - - for (; j > 0; --j, ++x) - { - if (x >= image->width) - return E_FAIL; - - *dPtr = *(sPtr++); - - if (convFlags & CONV_FLAGS_INVERTX) - --dPtr; - else - ++dPtr; - } - } - } - } - break; - - //-------------------------------------------------------------------------- 16-bit - case DXGI_FORMAT_B5G5R5A1_UNORM: - { - uint32_t minalpha = 255; - uint32_t maxalpha = 0; - - for (size_t y = 0; y < image->height; ++y) - { - size_t offset = ((convFlags & CONV_FLAGS_INVERTX) ? (image->width - 1) : 0); - assert(offset * 2 < rowPitch); - - auto dPtr = reinterpret_cast(image->pixels - + (image->rowPitch * ((convFlags & CONV_FLAGS_INVERTY) ? y : (image->height - y - 1)))) - + offset; - - for (size_t x = 0; x < image->width; ) - { - if (sPtr >= endPtr) - return E_FAIL; - - if (*sPtr & 0x80) - { - // Repeat - size_t j = size_t(*sPtr & 0x7F) + 1; - ++sPtr; - - if (sPtr + 1 >= endPtr) - return E_FAIL; - - auto t = static_cast(uint32_t(*sPtr) | uint32_t(*(sPtr + 1u) << 8)); - - const uint32_t alpha = (t & 0x8000) ? 255 : 0; - minalpha = std::min(minalpha, alpha); - maxalpha = std::max(maxalpha, alpha); - - sPtr += 2; - - for (; j > 0; --j, ++x) - { - if (x >= image->width) - return E_FAIL; - - *dPtr = t; - - if (convFlags & CONV_FLAGS_INVERTX) - --dPtr; - else - ++dPtr; - } - } - else - { - // Literal - size_t j = size_t(*sPtr & 0x7F) + 1; - ++sPtr; - - if (sPtr + (j * 2) > endPtr) - return E_FAIL; - - for (; j > 0; --j, ++x) - { - if (x >= image->width) - return E_FAIL; - - auto t = static_cast(uint32_t(*sPtr) | uint32_t(*(sPtr + 1u) << 8)); - - const uint32_t alpha = (t & 0x8000) ? 255 : 0; - minalpha = std::min(minalpha, alpha); - maxalpha = std::max(maxalpha, alpha); - - sPtr += 2; - *dPtr = t; - - if (convFlags & CONV_FLAGS_INVERTX) - --dPtr; - else - ++dPtr; - } - } - } - } - - // If there are no non-zero alpha channel entries, we'll assume alpha is not used and force it to opaque - if (maxalpha == 0 && !(flags & TGA_FLAGS_ALLOW_ALL_ZERO_ALPHA)) - { - opaquealpha = true; - hr = SetAlphaChannelToOpaque(image); - if (FAILED(hr)) - return hr; - } - else if (minalpha == 255) - { - opaquealpha = true; - } - } - break; - - //------------------------------------------------------ 24/32-bit (with swizzling) - case DXGI_FORMAT_R8G8B8A8_UNORM: - { - uint32_t minalpha = 255; - uint32_t maxalpha = 0; - - for (size_t y = 0; y < image->height; ++y) - { - size_t offset = ((convFlags & CONV_FLAGS_INVERTX) ? (image->width - 1) : 0); - - auto dPtr = reinterpret_cast(image->pixels - + (image->rowPitch * ((convFlags & CONV_FLAGS_INVERTY) ? y : (image->height - y - 1)))) - + offset; - - for (size_t x = 0; x < image->width; ) - { - if (sPtr >= endPtr) - return E_FAIL; - - if (*sPtr & 0x80) - { - // Repeat - size_t j = size_t(*sPtr & 0x7F) + 1; - ++sPtr; - - uint32_t t; - if (convFlags & CONV_FLAGS_EXPAND) - { - assert(offset * 3 < rowPitch); - - if (sPtr + 2 >= endPtr) - return E_FAIL; - - // BGR -> RGBA - t = uint32_t(*sPtr << 16) | uint32_t(*(sPtr + 1) << 8) | uint32_t(*(sPtr + 2)) | 0xFF000000; - sPtr += 3; - - minalpha = maxalpha = 255; - } - else - { - assert(offset * 4 < rowPitch); - - if (sPtr + 3 >= endPtr) - return E_FAIL; - - // BGRA -> RGBA - const uint32_t alpha = *(sPtr + 3); - t = uint32_t(*sPtr << 16) | uint32_t(*(sPtr + 1) << 8) | uint32_t(*(sPtr + 2)) | uint32_t(alpha << 24); - - minalpha = std::min(minalpha, alpha); - maxalpha = std::max(maxalpha, alpha); - - sPtr += 4; - } - - for (; j > 0; --j, ++x) - { - if (x >= image->width) - return E_FAIL; - - *dPtr = t; - - if (convFlags & CONV_FLAGS_INVERTX) - --dPtr; - else - ++dPtr; - } - } - else - { - // Literal - size_t j = size_t(*sPtr & 0x7F) + 1; - ++sPtr; - - if (convFlags & CONV_FLAGS_EXPAND) - { - if (sPtr + (j * 3) > endPtr) - return E_FAIL; - } - else - { - if (sPtr + (j * 4) > endPtr) - return E_FAIL; - } - - for (; j > 0; --j, ++x) - { - if (x >= image->width) - return E_FAIL; - - if (convFlags & CONV_FLAGS_EXPAND) - { - assert(offset * 3 < rowPitch); - - if (sPtr + 2 >= endPtr) - return E_FAIL; - - // BGR -> RGBA - *dPtr = uint32_t(*sPtr << 16) | uint32_t(*(sPtr + 1) << 8) | uint32_t(*(sPtr + 2)) | 0xFF000000; - sPtr += 3; - - minalpha = maxalpha = 255; - } - else - { - assert(offset * 4 < rowPitch); - - if (sPtr + 3 >= endPtr) - return E_FAIL; - - // BGRA -> RGBA - uint32_t alpha = *(sPtr + 3); - *dPtr = uint32_t(*sPtr << 16) | uint32_t(*(sPtr + 1) << 8) | uint32_t(*(sPtr + 2)) | uint32_t(alpha << 24); - - minalpha = std::min(minalpha, alpha); - maxalpha = std::max(maxalpha, alpha); - - sPtr += 4; - } - - if (convFlags & CONV_FLAGS_INVERTX) - --dPtr; - else - ++dPtr; - } - } - } - } - - // If there are no non-zero alpha channel entries, we'll assume alpha is not used and force it to opaque - if (maxalpha == 0 && !(flags & TGA_FLAGS_ALLOW_ALL_ZERO_ALPHA)) - { - opaquealpha = true; - hr = SetAlphaChannelToOpaque(image); - if (FAILED(hr)) - return hr; - } - else if (minalpha == 255) - { - opaquealpha = true; - } - } - break; - - //-------------------------------------------------------------------- 32-bit (BGR) - case DXGI_FORMAT_B8G8R8A8_UNORM: - { - assert((convFlags & CONV_FLAGS_EXPAND) == 0); - - uint32_t minalpha = 255; - uint32_t maxalpha = 0; - - for (size_t y = 0; y < image->height; ++y) - { - size_t offset = ((convFlags & CONV_FLAGS_INVERTX) ? (image->width - 1) : 0); - - auto dPtr = reinterpret_cast(image->pixels - + (image->rowPitch * ((convFlags & CONV_FLAGS_INVERTY) ? y : (image->height - y - 1)))) - + offset; - - for (size_t x = 0; x < image->width; ) - { - if (sPtr >= endPtr) - return E_FAIL; - - if (*sPtr & 0x80) - { - // Repeat - size_t j = size_t(*sPtr & 0x7F) + 1; - ++sPtr; - - assert(offset * 4 < rowPitch); - - if (sPtr + 3 >= endPtr) - return E_FAIL; - - const uint32_t alpha = *(sPtr + 3); - - auto t = *reinterpret_cast(sPtr); - - minalpha = std::min(minalpha, alpha); - maxalpha = std::max(maxalpha, alpha); - - sPtr += 4; - - for (; j > 0; --j, ++x) - { - if (x >= image->width) - return E_FAIL; - - *dPtr = t; - - if (convFlags & CONV_FLAGS_INVERTX) - --dPtr; - else - ++dPtr; - } - } - else - { - // Literal - size_t j = size_t(*sPtr & 0x7F) + 1; - ++sPtr; - - if (sPtr + (j * 4) > endPtr) - return E_FAIL; - - for (; j > 0; --j, ++x) - { - if (x >= image->width) - return E_FAIL; - - assert(offset * 4 < rowPitch); - - if (sPtr + 3 >= endPtr) - return E_FAIL; - - const uint32_t alpha = *(sPtr + 3); - *dPtr = *reinterpret_cast(sPtr); - - minalpha = std::min(minalpha, alpha); - maxalpha = std::max(maxalpha, alpha); - - sPtr += 4; - - if (convFlags & CONV_FLAGS_INVERTX) - --dPtr; - else - ++dPtr; - } - } - } - } - - // If there are no non-zero alpha channel entries, we'll assume alpha is not used and force it to opaque - if (maxalpha == 0 && !(flags & TGA_FLAGS_ALLOW_ALL_ZERO_ALPHA)) - { - opaquealpha = true; - hr = SetAlphaChannelToOpaque(image); - if (FAILED(hr)) - return hr; - } - else if (minalpha == 255) - { - opaquealpha = true; - } - } - break; - - //-------------------------------------------------------------------- 24-bit (BGR) - case DXGI_FORMAT_B8G8R8X8_UNORM: - { - assert((convFlags & CONV_FLAGS_EXPAND) != 0); - - for (size_t y = 0; y < image->height; ++y) - { - size_t offset = ((convFlags & CONV_FLAGS_INVERTX) ? (image->width - 1) : 0); - - auto dPtr = reinterpret_cast(image->pixels - + (image->rowPitch * ((convFlags & CONV_FLAGS_INVERTY) ? y : (image->height - y - 1)))) - + offset; - - for (size_t x = 0; x < image->width; ) - { - if (sPtr >= endPtr) - return E_FAIL; - - if (*sPtr & 0x80) - { - // Repeat - size_t j = size_t(*sPtr & 0x7F) + 1; - ++sPtr; - - assert(offset * 3 < rowPitch); - - if (sPtr + 2 >= endPtr) - return E_FAIL; - - uint32_t t = uint32_t(*sPtr) | uint32_t(*(sPtr + 1) << 8) | uint32_t(*(sPtr + 2) << 16); - sPtr += 3; - - for (; j > 0; --j, ++x) - { - if (x >= image->width) - return E_FAIL; - - *dPtr = t; - - if (convFlags & CONV_FLAGS_INVERTX) - --dPtr; - else - ++dPtr; - } - } - else - { - // Literal - size_t j = size_t(*sPtr & 0x7F) + 1; - ++sPtr; - - if (sPtr + (j * 3) > endPtr) - return E_FAIL; - - for (; j > 0; --j, ++x) - { - if (x >= image->width) - return E_FAIL; - - assert(offset * 3 < rowPitch); - - if (sPtr + 2 >= endPtr) - return E_FAIL; - - *dPtr = uint32_t(*sPtr) | uint32_t(*(sPtr + 1) << 8) | uint32_t(*(sPtr + 2) << 16); - sPtr += 3; - - if (convFlags & CONV_FLAGS_INVERTX) - --dPtr; - else - ++dPtr; - } - } - } - } - } - break; - - //--------------------------------------------------------------------------------- - default: - return E_FAIL; - } - - return opaquealpha ? S_FALSE : S_OK; - } - - - //------------------------------------------------------------------------------------- - // Copies pixel data from a TGA into the target image - //------------------------------------------------------------------------------------- - HRESULT CopyPixels( - _In_reads_bytes_(size) const void* pSource, - size_t size, - TGA_FLAGS flags, - _In_ const Image* image, - _In_ uint32_t convFlags, - _In_opt_ uint8_t* palette) noexcept - { - assert(pSource && size > 0); - - if (!image || !image->pixels) - return E_POINTER; - - // Compute TGA image data pitch - size_t rowPitch, slicePitch; - HRESULT hr = ComputePitch(image->format, image->width, image->height, - rowPitch, slicePitch, - (convFlags & CONV_FLAGS_EXPAND) ? CP_FLAGS_24BPP : CP_FLAGS_NONE); - if (FAILED(hr)) - return hr; - - auto sPtr = static_cast(pSource); - const uint8_t* endPtr = sPtr + size; - - bool opaquealpha = false; - - if ((convFlags & CONV_FLAGS_PALETTED) != 0) - { - if (!palette) - return E_UNEXPECTED; - - const auto table = reinterpret_cast(palette); - - for (size_t y = 0; y < image->height; ++y) - { - size_t offset = ((convFlags & CONV_FLAGS_INVERTX) ? (image->width - 1) : 0); - assert(offset < rowPitch); - - auto dPtr = reinterpret_cast(image->pixels - + (image->rowPitch * ((convFlags & CONV_FLAGS_INVERTY) ? y : (image->height - y - 1)))) - + offset; - - for (size_t x = 0; x < image->width; ++x) - { - if (sPtr >= endPtr) - return E_FAIL; - - *dPtr = table[*(sPtr++)]; - - if (convFlags & CONV_FLAGS_INVERTX) - --dPtr; - else - ++dPtr; - } - } - } - else - { - switch (image->format) - { - //----------------------------------------------------------------------- 8-bit - case DXGI_FORMAT_R8_UNORM: - for (size_t y = 0; y < image->height; ++y) - { - size_t offset = ((convFlags & CONV_FLAGS_INVERTX) ? (image->width - 1) : 0); - assert(offset < rowPitch); - - uint8_t* dPtr = image->pixels - + (image->rowPitch * ((convFlags & CONV_FLAGS_INVERTY) ? y : (image->height - y - 1))) - + offset; - - for (size_t x = 0; x < image->width; ++x) - { - if (sPtr >= endPtr) - return E_FAIL; - - *dPtr = *(sPtr++); - - if (convFlags & CONV_FLAGS_INVERTX) - --dPtr; - else - ++dPtr; - } - } - break; - - //---------------------------------------------------------------------- 16-bit - case DXGI_FORMAT_B5G5R5A1_UNORM: - { - uint32_t minalpha = 255; - uint32_t maxalpha = 0; - - for (size_t y = 0; y < image->height; ++y) - { - size_t offset = ((convFlags & CONV_FLAGS_INVERTX) ? (image->width - 1) : 0); - assert(offset * 2 < rowPitch); - - auto dPtr = reinterpret_cast(image->pixels - + (image->rowPitch * ((convFlags & CONV_FLAGS_INVERTY) ? y : (image->height - y - 1)))) - + offset; - - for (size_t x = 0; x < image->width; ++x) - { - if (sPtr + 1 >= endPtr) - return E_FAIL; - - auto t = static_cast(uint32_t(*sPtr) | uint32_t(*(sPtr + 1u) << 8)); - sPtr += 2; - *dPtr = t; - - const uint32_t alpha = (t & 0x8000) ? 255 : 0; - minalpha = std::min(minalpha, alpha); - maxalpha = std::max(maxalpha, alpha); - - if (convFlags & CONV_FLAGS_INVERTX) - --dPtr; - else - ++dPtr; - } - } - - // If there are no non-zero alpha channel entries, we'll assume alpha is not used and force it to opaque - if (maxalpha == 0 && !(flags & TGA_FLAGS_ALLOW_ALL_ZERO_ALPHA)) - { - opaquealpha = true; - hr = SetAlphaChannelToOpaque(image); - if (FAILED(hr)) - return hr; - } - else if (minalpha == 255) - { - opaquealpha = true; - } - } - break; - - //-------------------------------------------------- 24/32-bit (with swizzling) - case DXGI_FORMAT_R8G8B8A8_UNORM: - { - uint32_t minalpha = 255; - uint32_t maxalpha = 0; - - for (size_t y = 0; y < image->height; ++y) - { - size_t offset = ((convFlags & CONV_FLAGS_INVERTX) ? (image->width - 1) : 0); - - auto dPtr = reinterpret_cast(image->pixels - + (image->rowPitch * ((convFlags & CONV_FLAGS_INVERTY) ? y : (image->height - y - 1)))) - + offset; - - for (size_t x = 0; x < image->width; ++x) - { - if (convFlags & CONV_FLAGS_EXPAND) - { - assert(offset * 3 < rowPitch); - - if (sPtr + 2 >= endPtr) - return E_FAIL; - - // BGR -> RGBA - *dPtr = uint32_t(*sPtr << 16) | uint32_t(*(sPtr + 1) << 8) | uint32_t(*(sPtr + 2)) | 0xFF000000; - sPtr += 3; - - minalpha = maxalpha = 255; - } - else - { - assert(offset * 4 < rowPitch); - - if (sPtr + 3 >= endPtr) - return E_FAIL; - - // BGRA -> RGBA - uint32_t alpha = *(sPtr + 3); - *dPtr = uint32_t(*sPtr << 16) | uint32_t(*(sPtr + 1) << 8) | uint32_t(*(sPtr + 2)) | uint32_t(alpha << 24); - - minalpha = std::min(minalpha, alpha); - maxalpha = std::max(maxalpha, alpha); - - sPtr += 4; - } - - if (convFlags & CONV_FLAGS_INVERTX) - --dPtr; - else - ++dPtr; - } - } - - // If there are no non-zero alpha channel entries, we'll assume alpha is not used and force it to opaque - if (maxalpha == 0 && !(flags & TGA_FLAGS_ALLOW_ALL_ZERO_ALPHA)) - { - opaquealpha = true; - hr = SetAlphaChannelToOpaque(image); - if (FAILED(hr)) - return hr; - } - else if (minalpha == 255) - { - opaquealpha = true; - } - } - break; - - //---------------------------------------------------------------- 32-bit (BGR) - case DXGI_FORMAT_B8G8R8A8_UNORM: - { - assert((convFlags & CONV_FLAGS_EXPAND) == 0); - - uint32_t minalpha = 255; - uint32_t maxalpha = 0; - - for (size_t y = 0; y < image->height; ++y) - { - size_t offset = ((convFlags & CONV_FLAGS_INVERTX) ? (image->width - 1) : 0); - - auto dPtr = reinterpret_cast(image->pixels - + (image->rowPitch * ((convFlags & CONV_FLAGS_INVERTY) ? y : (image->height - y - 1)))) - + offset; - - for (size_t x = 0; x < image->width; ++x) - { - assert(offset * 4 < rowPitch); - - if (sPtr + 3 >= endPtr) - return E_FAIL; - - const uint32_t alpha = *(sPtr + 3); - *dPtr = *reinterpret_cast(sPtr); - - minalpha = std::min(minalpha, alpha); - maxalpha = std::max(maxalpha, alpha); - - sPtr += 4; - - if (convFlags & CONV_FLAGS_INVERTX) - --dPtr; - else - ++dPtr; - } - } - - // If there are no non-zero alpha channel entries, we'll assume alpha is not used and force it to opaque - if (maxalpha == 0 && !(flags & TGA_FLAGS_ALLOW_ALL_ZERO_ALPHA)) - { - opaquealpha = true; - hr = SetAlphaChannelToOpaque(image); - if (FAILED(hr)) - return hr; - } - else if (minalpha == 255) - { - opaquealpha = true; - } - } - break; - - //---------------------------------------------------------------- 24-bit (BGR) - case DXGI_FORMAT_B8G8R8X8_UNORM: - { - assert((convFlags & CONV_FLAGS_EXPAND) != 0); - - for (size_t y = 0; y < image->height; ++y) - { - size_t offset = ((convFlags & CONV_FLAGS_INVERTX) ? (image->width - 1) : 0); - - auto dPtr = reinterpret_cast(image->pixels - + (image->rowPitch * ((convFlags & CONV_FLAGS_INVERTY) ? y : (image->height - y - 1)))) - + offset; - - for (size_t x = 0; x < image->width; ++x) - { - assert(offset * 3 < rowPitch); - - if (sPtr + 2 >= endPtr) - return E_FAIL; - - *dPtr = uint32_t(*sPtr) | uint32_t(*(sPtr + 1) << 8) | uint32_t(*(sPtr + 2) << 16); - sPtr += 3; - - if (convFlags & CONV_FLAGS_INVERTX) - --dPtr; - else - ++dPtr; - } - } - } - break; - - //----------------------------------------------------------------------------- - default: - return E_FAIL; - } - } - - return opaquealpha ? S_FALSE : S_OK; - } - - - //------------------------------------------------------------------------------------- - // Encodes TGA file header - //------------------------------------------------------------------------------------- - HRESULT EncodeTGAHeader(_In_ const Image& image, _Out_ TGA_HEADER& header, _Inout_ uint32_t& convFlags) noexcept - { - memset(&header, 0, TGA_HEADER_LEN); - - if ((image.width > UINT16_MAX) - || (image.height > UINT16_MAX)) - { - return HRESULT_E_NOT_SUPPORTED; - } - - header.wWidth = static_cast(image.width); - header.wHeight = static_cast(image.height); - - switch (image.format) - { - case DXGI_FORMAT_R8G8B8A8_UNORM: - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - header.bImageType = TGA_TRUECOLOR; - header.bBitsPerPixel = 32; - header.bDescriptor = TGA_FLAGS_INVERTY | 8; - convFlags |= CONV_FLAGS_SWIZZLE; - break; - - case DXGI_FORMAT_B8G8R8A8_UNORM: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - header.bImageType = TGA_TRUECOLOR; - header.bBitsPerPixel = 32; - header.bDescriptor = TGA_FLAGS_INVERTY | 8; - break; - - case DXGI_FORMAT_B8G8R8X8_UNORM: - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - header.bImageType = TGA_TRUECOLOR; - header.bBitsPerPixel = 24; - header.bDescriptor = TGA_FLAGS_INVERTY; - convFlags |= CONV_FLAGS_888; - break; - - case DXGI_FORMAT_R8_UNORM: - case DXGI_FORMAT_A8_UNORM: - header.bImageType = TGA_BLACK_AND_WHITE; - header.bBitsPerPixel = 8; - header.bDescriptor = TGA_FLAGS_INVERTY; - break; - - case DXGI_FORMAT_B5G5R5A1_UNORM: - header.bImageType = TGA_TRUECOLOR; - header.bBitsPerPixel = 16; - header.bDescriptor = TGA_FLAGS_INVERTY | 1; - break; - - default: - return HRESULT_E_NOT_SUPPORTED; - } - - return S_OK; - } - - - //------------------------------------------------------------------------------------- - // Copies BGRX data to form BGR 24bpp data - //------------------------------------------------------------------------------------- -#pragma warning(suppress: 6001 6101) // In the case where outSize is insufficient we do not write to pDestination - void Copy24bppScanline( - _Out_writes_bytes_(outSize) void* pDestination, - _In_ size_t outSize, - _In_reads_bytes_(inSize) const void* pSource, - _In_ size_t inSize) noexcept - { - assert(pDestination && outSize > 0); - assert(pSource && inSize > 0); - - assert(pDestination != pSource); - - const uint32_t * __restrict sPtr = static_cast(pSource); - uint8_t * __restrict dPtr = static_cast(pDestination); - - if (inSize >= 4 && outSize >= 3) - { - const uint8_t* endPtr = dPtr + outSize; - - for (size_t count = 0; count < (inSize - 3); count += 4) - { - uint32_t t = *(sPtr++); - - if (dPtr + 3 > endPtr) - return; - - *(dPtr++) = uint8_t(t & 0xFF); // Blue - *(dPtr++) = uint8_t((t & 0xFF00) >> 8); // Green - *(dPtr++) = uint8_t((t & 0xFF0000) >> 16); // Red - } - } - } - - //------------------------------------------------------------------------------------- - // TGA 2.0 Extension helpers - //------------------------------------------------------------------------------------- - void SetExtension(_In_ TGA_EXTENSION *ext, TGA_FLAGS flags, const TexMetadata& metadata) noexcept - { - memset(ext, 0, sizeof(TGA_EXTENSION)); - - ext->wSize = sizeof(TGA_EXTENSION); - - memcpy(ext->szSoftwareId, "DirectXTex", sizeof("DirectXTex")); - ext->wVersionNumber = DIRECTX_TEX_VERSION; - ext->bVersionLetter = ' '; - - const bool sRGB = ((flags & TGA_FLAGS_FORCE_LINEAR) == 0) && ((flags & TGA_FLAGS_FORCE_SRGB) != 0 || IsSRGB(metadata.format)); - if (sRGB) - { - ext->wGammaNumerator = 22; - ext->wGammaDenominator = 10; - } - else if (flags & TGA_FLAGS_FORCE_LINEAR) - { - ext->wGammaNumerator = 1; - ext->wGammaDenominator = 1; - } - - switch (metadata.GetAlphaMode()) - { - case TEX_ALPHA_MODE_UNKNOWN: - ext->bAttributesType = HasAlpha(metadata.format) ? TGA_ATTRIBUTE_UNDEFINED : TGA_ATTRIBUTE_NONE; - break; - - case TEX_ALPHA_MODE_STRAIGHT: - ext->bAttributesType = TGA_ATTRIBUTE_ALPHA; - break; - - case TEX_ALPHA_MODE_PREMULTIPLIED: - ext->bAttributesType = TGA_ATTRIBUTE_PREMULTIPLIED; - break; - - case TEX_ALPHA_MODE_OPAQUE: - ext->bAttributesType = TGA_ATTRIBUTE_IGNORED; - break; - - case TEX_ALPHA_MODE_CUSTOM: - ext->bAttributesType = TGA_ATTRIBUTE_UNDEFINED; - break; - } - - // Set file time stamp - { - time_t now = {}; - time(&now); - - #ifdef _WIN32 - tm info; - auto pinfo = &info; - if (!gmtime_s(pinfo, &now)) - #else - const tm* pinfo = gmtime(&now); - if (pinfo) - #endif - { - ext->wStampMonth = static_cast(pinfo->tm_mon + 1); - ext->wStampDay = static_cast(pinfo->tm_mday); - ext->wStampYear = static_cast(pinfo->tm_year + 1900); - ext->wStampHour = static_cast(pinfo->tm_hour); - ext->wStampMinute = static_cast(pinfo->tm_min); - ext->wStampSecond = static_cast(pinfo->tm_sec); - } - } - } - - TEX_ALPHA_MODE GetAlphaModeFromExtension(_In_opt_ const TGA_EXTENSION *ext) noexcept - { - if (ext && ext->wSize == sizeof(TGA_EXTENSION)) - { - switch (ext->bAttributesType) - { - case TGA_ATTRIBUTE_IGNORED: return TEX_ALPHA_MODE_OPAQUE; - case TGA_ATTRIBUTE_UNDEFINED: return TEX_ALPHA_MODE_CUSTOM; - case TGA_ATTRIBUTE_ALPHA: return TEX_ALPHA_MODE_STRAIGHT; - case TGA_ATTRIBUTE_PREMULTIPLIED: return TEX_ALPHA_MODE_PREMULTIPLIED; - } - } - - return TEX_ALPHA_MODE_UNKNOWN; - } - - DXGI_FORMAT GetSRGBFromExtension(_In_opt_ const TGA_EXTENSION* ext, DXGI_FORMAT format, TGA_FLAGS flags, _In_opt_ ScratchImage* image) noexcept - { - bool sRGB = false; - - if (ext && ext->wSize == sizeof(TGA_EXTENSION) && ext->wGammaDenominator != 0) - { - auto const gamma = static_cast(ext->wGammaNumerator) / static_cast(ext->wGammaDenominator); - if (fabsf(gamma - 2.2f) < GAMMA_EPSILON || fabsf(gamma - 2.4f) < GAMMA_EPSILON) - { - sRGB = true; - } - } - else - { - sRGB = (flags & TGA_FLAGS_DEFAULT_SRGB) != 0; - } - - if (sRGB) - { - format = MakeSRGB(format); - if (image) - { - image->OverrideFormat(format); - } - } - - return format; - } -} - - -//===================================================================================== -// Entry-points -//===================================================================================== - -//------------------------------------------------------------------------------------- -// Obtain metadata from TGA file in memory/on disk -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::GetMetadataFromTGAMemory( - const void* pSource, - size_t size, - TGA_FLAGS flags, - TexMetadata& metadata) noexcept -{ - if (!pSource || size == 0) - return E_INVALIDARG; - - size_t offset; - HRESULT hr = DecodeTGAHeader(pSource, size, flags, metadata, offset, nullptr); - if (FAILED(hr)) - return hr; - - // Optional TGA 2.0 footer & extension area - const TGA_EXTENSION* ext = nullptr; - if (size >= sizeof(TGA_FOOTER)) - { - auto footer = reinterpret_cast(static_cast(pSource) + size - sizeof(TGA_FOOTER)); - - if (memcmp(footer->Signature, g_Signature, sizeof(g_Signature)) == 0) - { - if (footer->dwExtensionOffset != 0 - && ((footer->dwExtensionOffset + sizeof(TGA_EXTENSION)) <= size)) - { - ext = reinterpret_cast(static_cast(pSource) + footer->dwExtensionOffset); - metadata.SetAlphaMode(GetAlphaModeFromExtension(ext)); - } - } - } - - if (!(flags & TGA_FLAGS_IGNORE_SRGB)) - { - metadata.format = GetSRGBFromExtension(ext, metadata.format, flags, nullptr); - } - - return S_OK; -} - -_Use_decl_annotations_ -HRESULT DirectX::GetMetadataFromTGAFile(const wchar_t* szFile, TGA_FLAGS flags, TexMetadata& metadata) noexcept -{ - if (!szFile) - return E_INVALIDARG; - -#ifdef _WIN32 -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(szFile, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, - FILE_FLAG_SEQUENTIAL_SCAN, nullptr))); -#endif - if (!hFile) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - // Get the file size - FILE_STANDARD_INFO fileInfo; - if (!GetFileInformationByHandleEx(hFile.get(), FileStandardInfo, &fileInfo, sizeof(fileInfo))) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - // File is too big for 32-bit allocation, so reject read (4 GB should be plenty large enough for a valid TGA file) - if (fileInfo.EndOfFile.HighPart > 0) - { - return HRESULT_E_FILE_TOO_LARGE; - } - - const size_t len = fileInfo.EndOfFile.LowPart; -#else // !WIN32 - std::ifstream inFile(std::filesystem::path(szFile), std::ios::in | std::ios::binary | std::ios::ate); - if (!inFile) - return E_FAIL; - - std::streampos fileLen = inFile.tellg(); - if (!inFile) - return E_FAIL; - - if (fileLen > UINT32_MAX) - return HRESULT_E_FILE_TOO_LARGE; - - inFile.seekg(0, std::ios::beg); - if (!inFile) - return E_FAIL; - - size_t len = fileLen; -#endif - - // Need at least enough data to fill the standard header to be a valid TGA - if (len < TGA_HEADER_LEN) - { - return E_FAIL; - } - - // Read the standard header (we don't need the file footer to parse the file) - uint8_t header[TGA_HEADER_LEN] = {}; - -#ifdef _WIN32 - DWORD bytesRead = 0; - if (!ReadFile(hFile.get(), header, TGA_HEADER_LEN, &bytesRead, nullptr)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - auto const headerLen = static_cast(bytesRead); -#else - inFile.read(reinterpret_cast(header), TGA_HEADER_LEN); - if (!inFile) - return E_FAIL; - - size_t headerLen = TGA_HEADER_LEN; -#endif - - size_t offset; - HRESULT hr = DecodeTGAHeader(header, headerLen, flags, metadata, offset, nullptr); - if (FAILED(hr)) - return hr; - - // Optional TGA 2.0 footer & extension area - const TGA_EXTENSION* ext = nullptr; - TGA_EXTENSION extData = {}; - { - TGA_FOOTER footer = {}; - - #ifdef _WIN32 - if (SetFilePointer(hFile.get(), -static_cast(sizeof(TGA_FOOTER)), nullptr, FILE_END) != INVALID_SET_FILE_POINTER) - { - if (!ReadFile(hFile.get(), &footer, sizeof(TGA_FOOTER), &bytesRead, nullptr)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesRead != sizeof(TGA_FOOTER)) - { - return E_FAIL; - } - } - #else - inFile.seekg(-static_cast(sizeof(TGA_FOOTER)), std::ios::end); - if (inFile) - { - inFile.read(reinterpret_cast(&footer), sizeof(TGA_FOOTER)); - if (!inFile) - return E_FAIL; - } - #endif - - if (memcmp(footer.Signature, g_Signature, sizeof(g_Signature)) == 0) - { - if (footer.dwExtensionOffset != 0 - && ((footer.dwExtensionOffset + sizeof(TGA_EXTENSION)) <= len)) - { - #ifdef _WIN32 - const LARGE_INTEGER filePos = { { static_cast(footer.dwExtensionOffset), 0 } }; - if (SetFilePointerEx(hFile.get(), filePos, nullptr, FILE_BEGIN)) - { - if (ReadFile(hFile.get(), &extData, sizeof(TGA_EXTENSION), &bytesRead, nullptr) - && bytesRead == sizeof(TGA_EXTENSION)) - { - ext = &extData; - metadata.SetAlphaMode(GetAlphaModeFromExtension(ext)); - } - } - #else // !WIN32 - inFile.seekg(static_cast(footer.dwExtensionOffset), std::ios::beg); - if (inFile) - { - inFile.read(reinterpret_cast(&extData), sizeof(TGA_EXTENSION)); - if (inFile) - { - ext = &extData; - metadata.SetAlphaMode(GetAlphaModeFromExtension(ext)); - } - } - #endif - } - } - } - - if (!(flags & TGA_FLAGS_IGNORE_SRGB)) - { - metadata.format = GetSRGBFromExtension(ext, metadata.format, flags, nullptr); - } - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -// Load a TGA file in memory -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::LoadFromTGAMemory( - const void* pSource, - size_t size, - TGA_FLAGS flags, - TexMetadata* metadata, - ScratchImage& image) noexcept -{ - if (!pSource || size == 0) - return E_INVALIDARG; - - image.Release(); - - size_t offset; - uint32_t convFlags = 0; - TexMetadata mdata; - HRESULT hr = DecodeTGAHeader(pSource, size, flags, mdata, offset, &convFlags); - if (FAILED(hr)) - return hr; - - if (offset > size) - return E_FAIL; - - size_t paletteOffset = 0; - uint8_t palette[256 * 4] = {}; - if (convFlags & CONV_FLAGS_PALETTED) - { - const size_t remaining = size - offset; - if (remaining == 0) - return E_FAIL; - - auto pColorMap = static_cast(pSource) + offset; - - _Analysis_assume_(size > TGA_HEADER_LEN); - hr = ReadPalette(static_cast(pSource), pColorMap, remaining, flags, - palette, paletteOffset); - if (FAILED(hr)) - return hr; - } - - const size_t remaining = size - offset - paletteOffset; - if (remaining == 0) - return E_FAIL; - - const void* pPixels = static_cast(pSource) + offset + paletteOffset; - - hr = image.Initialize2D(mdata.format, mdata.width, mdata.height, 1, 1); - if (FAILED(hr)) - return hr; - - if (convFlags & CONV_FLAGS_RLE) - { - hr = UncompressPixels(pPixels, remaining, flags, image.GetImage(0, 0, 0), convFlags); - } - else - { - hr = CopyPixels(pPixels, remaining, flags, image.GetImage(0, 0, 0), convFlags, palette); - } - - if (FAILED(hr)) - { - image.Release(); - return hr; - } - - // Optional TGA 2.0 footer & extension area - const TGA_EXTENSION* ext = nullptr; - if (size >= sizeof(TGA_FOOTER)) - { - auto footer = reinterpret_cast(static_cast(pSource) + size - sizeof(TGA_FOOTER)); - - if (memcmp(footer->Signature, g_Signature, sizeof(g_Signature)) == 0) - { - if (footer->dwExtensionOffset != 0 - && ((footer->dwExtensionOffset + sizeof(TGA_EXTENSION)) <= size)) - { - ext = reinterpret_cast(static_cast(pSource) + footer->dwExtensionOffset); - } - } - } - - if (!(flags & TGA_FLAGS_IGNORE_SRGB)) - { - mdata.format = GetSRGBFromExtension(ext, mdata.format, flags, &image); - } - - if (metadata) - { - memcpy(metadata, &mdata, sizeof(TexMetadata)); - if (hr == S_FALSE) - { - metadata->SetAlphaMode(TEX_ALPHA_MODE_OPAQUE); - } - else if (ext) - { - metadata->SetAlphaMode(GetAlphaModeFromExtension(ext)); - } - } - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -// Load a TGA file from disk -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::LoadFromTGAFile( - const wchar_t* szFile, - TGA_FLAGS flags, - TexMetadata* metadata, - ScratchImage& image) noexcept -{ - if (!szFile) - return E_INVALIDARG; - - image.Release(); - -#ifdef _WIN32 -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(szFile, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, - FILE_FLAG_SEQUENTIAL_SCAN, nullptr))); -#endif - if (!hFile) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - // Get the file size - FILE_STANDARD_INFO fileInfo; - if (!GetFileInformationByHandleEx(hFile.get(), FileStandardInfo, &fileInfo, sizeof(fileInfo))) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - // File is too big for 32-bit allocation, so reject read (4 GB should be plenty large enough for a valid TGA file) - if (fileInfo.EndOfFile.HighPart > 0) - { - return HRESULT_E_FILE_TOO_LARGE; - } - - const size_t len = fileInfo.EndOfFile.LowPart; -#else // !WIN32 - std::ifstream inFile(std::filesystem::path(szFile), std::ios::in | std::ios::binary | std::ios::ate); - if (!inFile) - return E_FAIL; - - std::streampos fileLen = inFile.tellg(); - if (!inFile) - return E_FAIL; - - if (fileLen > UINT32_MAX) - return HRESULT_E_FILE_TOO_LARGE; - - inFile.seekg(0, std::ios::beg); - if (!inFile) - return E_FAIL; - - size_t len = fileLen; -#endif - - // Need at least enough data to fill the header to be a valid TGA - if (len < TGA_HEADER_LEN) - { - return E_FAIL; - } - - // Read the header - uint8_t header[TGA_HEADER_LEN] = {}; - -#ifdef _WIN32 - DWORD bytesRead = 0; - if (!ReadFile(hFile.get(), header, TGA_HEADER_LEN, &bytesRead, nullptr)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - auto const headerLen = static_cast(bytesRead); -#else - inFile.read(reinterpret_cast(header), TGA_HEADER_LEN); - if (!inFile) - return E_FAIL; - - size_t headerLen = TGA_HEADER_LEN; -#endif - - size_t offset; - uint32_t convFlags = 0; - TexMetadata mdata; - HRESULT hr = DecodeTGAHeader(header, headerLen, flags, mdata, offset, &convFlags); - if (FAILED(hr)) - return hr; - - // Read the pixels - auto const remaining = len - offset; - if (remaining == 0) - return E_FAIL; - - if (offset > TGA_HEADER_LEN) - { - #ifdef _WIN32 - // Skip past the id string - const LARGE_INTEGER filePos = { { static_cast(offset), 0 } }; - if (!SetFilePointerEx(hFile.get(), filePos, nullptr, FILE_BEGIN)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - #else - inFile.seekg(offset, std::ios::beg); - if (!inFile) - return E_FAIL; - #endif - } - - hr = image.Initialize2D(mdata.format, mdata.width, mdata.height, 1, 1); - if (FAILED(hr)) - return hr; - - assert(image.GetPixels()); - - bool opaquealpha = false; - - if (!(convFlags & (CONV_FLAGS_RLE | CONV_FLAGS_EXPAND | CONV_FLAGS_INVERTX | CONV_FLAGS_PALETTED)) && (convFlags & CONV_FLAGS_INVERTY)) - { - // This case we can read directly into the image buffer in place - if (remaining < image.GetPixelsSize()) - { - image.Release(); - return HRESULT_E_HANDLE_EOF; - } - - if (image.GetPixelsSize() > UINT32_MAX) - { - image.Release(); - return HRESULT_E_ARITHMETIC_OVERFLOW; - } - - #ifdef _WIN32 - if (!ReadFile(hFile.get(), image.GetPixels(), static_cast(image.GetPixelsSize()), &bytesRead, nullptr)) - { - image.Release(); - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesRead != image.GetPixelsSize()) - { - image.Release(); - return E_FAIL; - } - #else - inFile.read(reinterpret_cast(image.GetPixels()), image.GetPixelsSize()); - if (!inFile) - { - image.Release(); - return E_FAIL; - } - #endif - - switch (mdata.format) - { - case DXGI_FORMAT_R8G8B8A8_UNORM: - { - // TGA stores 32-bit data in BGRA form, need to swizzle to RGBA - assert(image.GetImageCount() == 1); - const Image* img = image.GetImage(0, 0, 0); - if (!img) - { - image.Release(); - return E_POINTER; - } - - uint8_t *pPixels = img->pixels; - if (!pPixels) - { - image.Release(); - return E_POINTER; - } - - size_t rowPitch = img->rowPitch; - - // Scan for non-zero alpha channel - uint32_t minalpha = 255; - uint32_t maxalpha = 0; - - for (size_t h = 0; h < img->height; ++h) - { - auto sPtr = reinterpret_cast(pPixels); - - for (size_t x = 0; x < img->width; ++x) - { - const uint32_t alpha = ((*sPtr & 0xFF000000) >> 24); - - minalpha = std::min(minalpha, alpha); - maxalpha = std::max(maxalpha, alpha); - - ++sPtr; - } - - pPixels += rowPitch; - } - - uint32_t tflags = TEXP_SCANLINE_NONE; - if (maxalpha == 0 && !(flags & TGA_FLAGS_ALLOW_ALL_ZERO_ALPHA)) - { - opaquealpha = true; - tflags = TEXP_SCANLINE_SETALPHA; - } - else if (minalpha == 255) - { - opaquealpha = true; - } - - // Swizzle scanlines - pPixels = img->pixels; - - for (size_t h = 0; h < img->height; ++h) - { - SwizzleScanline(pPixels, rowPitch, pPixels, rowPitch, mdata.format, tflags); - pPixels += rowPitch; - } - } - break; - - case DXGI_FORMAT_B8G8R8A8_UNORM: - { - assert(image.GetImageCount() == 1); - const Image* img = image.GetImage(0, 0, 0); - if (!img) - { - image.Release(); - return E_POINTER; - } - - // Scan for non-zero alpha channel - uint32_t minalpha = 255; - uint32_t maxalpha = 0; - - const uint8_t *pPixels = img->pixels; - if (!pPixels) - { - image.Release(); - return E_POINTER; - } - - const size_t rowPitch = img->rowPitch; - - for (size_t h = 0; h < img->height; ++h) - { - auto sPtr = reinterpret_cast(pPixels); - - for (size_t x = 0; x < img->width; ++x) - { - const uint32_t alpha = ((*sPtr & 0xFF000000) >> 24); - - minalpha = std::min(minalpha, alpha); - maxalpha = std::max(maxalpha, alpha); - - ++sPtr; - } - - pPixels += rowPitch; - } - - // If there are no non-zero alpha channel entries, we'll assume alpha is not used and force it to opaque - if (maxalpha == 0 && !(flags & TGA_FLAGS_ALLOW_ALL_ZERO_ALPHA)) - { - opaquealpha = true; - hr = SetAlphaChannelToOpaque(img); - if (FAILED(hr)) - { - image.Release(); - return hr; - } - } - else if (minalpha == 255) - { - opaquealpha = true; - } - } - break; - - case DXGI_FORMAT_B5G5R5A1_UNORM: - { - assert(image.GetImageCount() == 1); - const Image* img = image.GetImage(0, 0, 0); - if (!img) - { - image.Release(); - return E_POINTER; - } - - // Scan for non-zero alpha channel - uint32_t minalpha = 255; - uint32_t maxalpha = 0; - - const uint8_t *pPixels = img->pixels; - if (!pPixels) - { - image.Release(); - return E_POINTER; - } - - const size_t rowPitch = img->rowPitch; - - for (size_t h = 0; h < img->height; ++h) - { - auto sPtr = reinterpret_cast(pPixels); - - for (size_t x = 0; x < img->width; ++x) - { - const uint32_t alpha = (*sPtr & 0x8000) ? 255 : 0; - - minalpha = std::min(minalpha, alpha); - maxalpha = std::max(maxalpha, alpha); - - ++sPtr; - } - - pPixels += rowPitch; - } - - // If there are no non-zero alpha channel entries, we'll assume alpha is not used and force it to opaque - if (maxalpha == 0 && !(flags & TGA_FLAGS_ALLOW_ALL_ZERO_ALPHA)) - { - opaquealpha = true; - hr = SetAlphaChannelToOpaque(img); - if (FAILED(hr)) - { - image.Release(); - return hr; - } - } - else if (minalpha == 255) - { - opaquealpha = true; - } - } - break; - - case DXGI_FORMAT_B8G8R8X8_UNORM: - // Should never be trying to direct-read 24bpp - return E_FAIL; - - default: - break; - } - } - else // RLE || EXPAND || INVERTX || PALETTED || !INVERTY - { - std::unique_ptr temp(new (std::nothrow) uint8_t[remaining]); - if (!temp) - { - image.Release(); - return E_OUTOFMEMORY; - } - - #ifdef _WIN32 - if (!ReadFile(hFile.get(), temp.get(), static_cast(remaining), &bytesRead, nullptr)) - { - image.Release(); - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesRead != remaining) - { - image.Release(); - return E_FAIL; - } - #else - inFile.read(reinterpret_cast(temp.get()), remaining); - if (!inFile) - { - image.Release(); - return E_FAIL; - } - #endif - - size_t paletteOffset = 0; - uint8_t palette[256 * 4] = {}; - if (convFlags & CONV_FLAGS_PALETTED) - { - hr = ReadPalette(header, temp.get(), remaining, flags, palette, paletteOffset); - if (FAILED(hr)) - { - image.Release(); - return hr; - } - } - - if (convFlags & CONV_FLAGS_RLE) - { - hr = UncompressPixels(temp.get() + paletteOffset, remaining - paletteOffset, - flags, image.GetImage(0, 0, 0), convFlags); - } - else - { - hr = CopyPixels(temp.get() + paletteOffset, remaining - paletteOffset, - flags, image.GetImage(0, 0, 0), convFlags, palette); - } - - if (FAILED(hr)) - { - image.Release(); - return hr; - } - - if (hr == S_FALSE) - opaquealpha = true; - } - - // Optional TGA 2.0 footer & extension area - const TGA_EXTENSION* ext = nullptr; - TGA_EXTENSION extData = {}; - { - TGA_FOOTER footer = {}; - - #ifdef _WIN32 - if (SetFilePointer(hFile.get(), -static_cast(sizeof(TGA_FOOTER)), nullptr, FILE_END) != INVALID_SET_FILE_POINTER) - { - if (!ReadFile(hFile.get(), &footer, sizeof(TGA_FOOTER), &bytesRead, nullptr)) - { - image.Release(); - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesRead != sizeof(TGA_FOOTER)) - { - image.Release(); - return E_FAIL; - } - } - #else // !WIN32 - inFile.seekg(-static_cast(sizeof(TGA_FOOTER)), std::ios::end); - if (inFile) - { - inFile.read(reinterpret_cast(&footer), sizeof(TGA_FOOTER)); - if (!inFile) - { - image.Release(); - return E_FAIL; - } - } - #endif - - if (memcmp(footer.Signature, g_Signature, sizeof(g_Signature)) == 0) - { - if (footer.dwExtensionOffset != 0 - && ((footer.dwExtensionOffset + sizeof(TGA_EXTENSION)) <= len)) - { - #ifdef _WIN32 - const LARGE_INTEGER filePos = { { static_cast(footer.dwExtensionOffset), 0 } }; - if (SetFilePointerEx(hFile.get(), filePos, nullptr, FILE_BEGIN)) - { - if (ReadFile(hFile.get(), &extData, sizeof(TGA_EXTENSION), &bytesRead, nullptr) - && bytesRead == sizeof(TGA_EXTENSION)) - { - ext = &extData; - } - } - #else // !WIN32 - inFile.seekg(static_cast(footer.dwExtensionOffset), std::ios::beg); - if (inFile) - { - inFile.read(reinterpret_cast(&extData), sizeof(TGA_EXTENSION)); - if (inFile) - { - ext = &extData; - } - } - #endif - } - } - } - - if (!(flags & TGA_FLAGS_IGNORE_SRGB)) - { - mdata.format = GetSRGBFromExtension(ext, mdata.format, flags, &image); - } - - if (metadata) - { - memcpy(metadata, &mdata, sizeof(TexMetadata)); - if (opaquealpha) - { - metadata->SetAlphaMode(TEX_ALPHA_MODE_OPAQUE); - } - else if (ext) - { - metadata->SetAlphaMode(GetAlphaModeFromExtension(ext)); - } - } - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -// Save a TGA file to memory -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::SaveToTGAMemory( - const Image& image, - TGA_FLAGS flags, - Blob& blob, - const TexMetadata* metadata) noexcept -{ - if ((flags & (TGA_FLAGS_FORCE_LINEAR | TGA_FLAGS_FORCE_SRGB)) != 0 && !metadata) - return E_INVALIDARG; - - if (!image.pixels) - return E_POINTER; - - TGA_HEADER tga_header = {}; - uint32_t convFlags = 0; - HRESULT hr = EncodeTGAHeader(image, tga_header, convFlags); - if (FAILED(hr)) - return hr; - - blob.Release(); - - // Determine memory required for image data - size_t rowPitch, slicePitch; - hr = ComputePitch(image.format, image.width, image.height, rowPitch, slicePitch, - (convFlags & CONV_FLAGS_888) ? CP_FLAGS_24BPP : CP_FLAGS_NONE); - if (FAILED(hr)) - return hr; - - hr = blob.Initialize(TGA_HEADER_LEN - + slicePitch - + (metadata ? sizeof(TGA_EXTENSION) : 0) - + sizeof(TGA_FOOTER)); - if (FAILED(hr)) - return hr; - - // Copy header - auto destPtr = static_cast(blob.GetBufferPointer()); - assert(destPtr != nullptr); - - uint8_t* dPtr = destPtr; - memcpy(dPtr, &tga_header, TGA_HEADER_LEN); - dPtr += TGA_HEADER_LEN; - - const uint8_t* pPixels = image.pixels; - assert(pPixels); - - for (size_t y = 0; y < image.height; ++y) - { - // Copy pixels - if (convFlags & CONV_FLAGS_888) - { - Copy24bppScanline(dPtr, rowPitch, pPixels, image.rowPitch); - } - else if (convFlags & CONV_FLAGS_SWIZZLE) - { - SwizzleScanline(dPtr, rowPitch, pPixels, image.rowPitch, image.format, TEXP_SCANLINE_NONE); - } - else - { - CopyScanline(dPtr, rowPitch, pPixels, image.rowPitch, image.format, TEXP_SCANLINE_NONE); - } - - dPtr += rowPitch; - pPixels += image.rowPitch; - } - - uint32_t extOffset = 0; - if (metadata) - { - // metadata is only used for writing the TGA 2.0 extension header - auto ext = reinterpret_cast(dPtr); - SetExtension(ext, flags, *metadata); - - extOffset = static_cast(dPtr - destPtr); - dPtr += sizeof(TGA_EXTENSION); - } - - // Copy TGA 2.0 footer - auto footer = reinterpret_cast(dPtr); - footer->dwDeveloperOffset = 0; - footer->dwExtensionOffset = extOffset; - memcpy(footer->Signature, g_Signature, sizeof(g_Signature)); - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -// Save a TGA file to disk -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::SaveToTGAFile( - const Image& image, - TGA_FLAGS flags, - const wchar_t* szFile, - const TexMetadata* metadata) noexcept -{ - if (!szFile) - return E_INVALIDARG; - - if ((flags & (TGA_FLAGS_FORCE_LINEAR | TGA_FLAGS_FORCE_SRGB)) != 0 && !metadata) - return E_INVALIDARG; - - if (!image.pixels) - return E_POINTER; - - TGA_HEADER tga_header = {}; - uint32_t convFlags = 0; - HRESULT hr = EncodeTGAHeader(image, tga_header, convFlags); - if (FAILED(hr)) - return hr; - - // Create file and write header -#ifdef _WIN32 -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_WRITE, 0, - CREATE_ALWAYS, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(szFile, - GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr))); -#endif - if (!hFile) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - auto_delete_file delonfail(hFile.get()); -#else - std::ofstream outFile(std::filesystem::path(szFile), std::ios::out | std::ios::binary | std::ios::trunc); - if (!outFile) - return E_FAIL; -#endif - - // Determine size for TGA pixel data - size_t rowPitch, slicePitch; - hr = ComputePitch(image.format, image.width, image.height, rowPitch, slicePitch, - (convFlags & CONV_FLAGS_888) ? CP_FLAGS_24BPP : CP_FLAGS_NONE); - if (FAILED(hr)) - return hr; - - if (slicePitch < 65535) - { - // For small images, it is better to create an in-memory file and write it out - Blob blob; - - hr = SaveToTGAMemory(image, flags, blob, metadata); - if (FAILED(hr)) - return hr; - - // Write blob - #ifdef _WIN32 - const DWORD bytesToWrite = static_cast(blob.GetBufferSize()); - DWORD bytesWritten; - if (!WriteFile(hFile.get(), blob.GetBufferPointer(), bytesToWrite, &bytesWritten, nullptr)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesWritten != bytesToWrite) - { - return E_FAIL; - } - #else - outFile.write(reinterpret_cast(blob.GetBufferPointer()), - static_cast(blob.GetBufferSize())); - - if (!outFile) - return E_FAIL; - #endif - } - else - { - // Otherwise, write the image one scanline at a time... - std::unique_ptr temp(new (std::nothrow) uint8_t[rowPitch]); - if (!temp) - return E_OUTOFMEMORY; - - // Write header - #ifdef _WIN32 - DWORD bytesWritten; - if (!WriteFile(hFile.get(), &tga_header, TGA_HEADER_LEN, &bytesWritten, nullptr)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesWritten != TGA_HEADER_LEN) - return E_FAIL; - #else - outFile.write(reinterpret_cast(&tga_header), TGA_HEADER_LEN); - if (!outFile) - return E_FAIL; - #endif - - if (rowPitch > UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - // Write pixels - const uint8_t* pPixels = image.pixels; - - for (size_t y = 0; y < image.height; ++y) - { - // Copy pixels - if (convFlags & CONV_FLAGS_888) - { - Copy24bppScanline(temp.get(), rowPitch, pPixels, image.rowPitch); - } - else if (convFlags & CONV_FLAGS_SWIZZLE) - { - SwizzleScanline(temp.get(), rowPitch, pPixels, image.rowPitch, image.format, TEXP_SCANLINE_NONE); - } - else - { - CopyScanline(temp.get(), rowPitch, pPixels, image.rowPitch, image.format, TEXP_SCANLINE_NONE); - } - - pPixels += image.rowPitch; - - #ifdef _WIN32 - if (!WriteFile(hFile.get(), temp.get(), static_cast(rowPitch), &bytesWritten, nullptr)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesWritten != rowPitch) - return E_FAIL; - #else - outFile.write(reinterpret_cast(temp.get()), rowPitch); - if (!outFile) - return E_FAIL; - #endif - } - - uint32_t extOffset = 0; - if (metadata) - { - // metadata is only used for writing the TGA 2.0 extension header - TGA_EXTENSION ext = {}; - SetExtension(&ext, flags, *metadata); - - #ifdef _WIN32 - extOffset = SetFilePointer(hFile.get(), 0, nullptr, FILE_CURRENT); - if (extOffset == INVALID_SET_FILE_POINTER) - { - return E_FAIL; - } - - if (!WriteFile(hFile.get(), &ext, sizeof(TGA_EXTENSION), &bytesWritten, nullptr)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesWritten != sizeof(TGA_EXTENSION)) - return E_FAIL; - #else - extOffset = static_cast(outFile.tellp()); - if (!outFile) - return E_FAIL; - - outFile.write(reinterpret_cast(&ext), sizeof(TGA_EXTENSION)); - if (!outFile) - return E_FAIL; - #endif - } - - // Write TGA 2.0 footer - TGA_FOOTER footer = {}; - footer.dwExtensionOffset = extOffset; - memcpy(footer.Signature, g_Signature, sizeof(g_Signature)); - - #ifdef _WIN32 - if (!WriteFile(hFile.get(), &footer, sizeof(TGA_FOOTER), &bytesWritten, nullptr)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesWritten != sizeof(footer)) - return E_FAIL; - #else - outFile.write(reinterpret_cast(&footer), sizeof(TGA_FOOTER)); - if (!outFile) - return E_FAIL; - #endif - } - -#ifdef _WIN32 - delonfail.clear(); -#endif - - return S_OK; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexUtil.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexUtil.cpp deleted file mode 100644 index 02a00fd..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexUtil.cpp +++ /dev/null @@ -1,1540 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXTexUtil.cpp -// -// DirectX Texture Library - Utilities -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//------------------------------------------------------------------------------------- - -#include "DirectXTexP.h" - -#if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX) -static_assert(XBOX_DXGI_FORMAT_R10G10B10_7E3_A2_FLOAT == DXGI_FORMAT_R10G10B10_7E3_A2_FLOAT, "Xbox mismatch detected"); -static_assert(XBOX_DXGI_FORMAT_R10G10B10_6E4_A2_FLOAT == DXGI_FORMAT_R10G10B10_6E4_A2_FLOAT, "Xbox mismatch detected"); -static_assert(XBOX_DXGI_FORMAT_D16_UNORM_S8_UINT == DXGI_FORMAT_D16_UNORM_S8_UINT, "Xbox mismatch detected"); -static_assert(XBOX_DXGI_FORMAT_R16_UNORM_X8_TYPELESS == DXGI_FORMAT_R16_UNORM_X8_TYPELESS, "Xbox mismatch detected"); -static_assert(XBOX_DXGI_FORMAT_X16_TYPELESS_G8_UINT == DXGI_FORMAT_X16_TYPELESS_G8_UINT, "Xbox mismatch detected"); -static_assert(XBOX_DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM == DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM, "Xbox mismatch detected"); -static_assert(XBOX_DXGI_FORMAT_R4G4_UNORM == DXGI_FORMAT_R4G4_UNORM, "Xbox mismatch detected"); -#endif - -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10) -static_assert(WIN10_DXGI_FORMAT_P208 == DXGI_FORMAT_P208, "Windows SDK mismatch detected"); -static_assert(WIN10_DXGI_FORMAT_V208 == DXGI_FORMAT_V208, "Windows SDK mismatch detected"); -static_assert(WIN10_DXGI_FORMAT_V408 == DXGI_FORMAT_V408, "Windows SDK mismatch detected"); -#endif - -using namespace DirectX; -using Microsoft::WRL::ComPtr; - -namespace -{ -#ifdef _WIN32 - //------------------------------------------------------------------------------------- - // WIC Pixel Format Translation Data - //------------------------------------------------------------------------------------- - struct WICTranslate - { - const GUID& wic; - DXGI_FORMAT format; - bool srgb; - }; - - constexpr WICTranslate g_WICFormats[] = - { - { GUID_WICPixelFormat128bppRGBAFloat, DXGI_FORMAT_R32G32B32A32_FLOAT, false }, - - { GUID_WICPixelFormat64bppRGBAHalf, DXGI_FORMAT_R16G16B16A16_FLOAT, false }, - { GUID_WICPixelFormat64bppRGBA, DXGI_FORMAT_R16G16B16A16_UNORM, true }, - - { GUID_WICPixelFormat32bppRGBA, DXGI_FORMAT_R8G8B8A8_UNORM, true }, - { GUID_WICPixelFormat32bppBGRA, DXGI_FORMAT_B8G8R8A8_UNORM, true }, // DXGI 1.1 - { GUID_WICPixelFormat32bppBGR, DXGI_FORMAT_B8G8R8X8_UNORM, true }, // DXGI 1.1 - - { GUID_WICPixelFormat32bppRGBA1010102XR, DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM, true }, // DXGI 1.1 - { GUID_WICPixelFormat32bppRGBA1010102, DXGI_FORMAT_R10G10B10A2_UNORM, true }, - - { GUID_WICPixelFormat16bppBGRA5551, DXGI_FORMAT_B5G5R5A1_UNORM, true }, - { GUID_WICPixelFormat16bppBGR565, DXGI_FORMAT_B5G6R5_UNORM, true }, - - { GUID_WICPixelFormat32bppGrayFloat, DXGI_FORMAT_R32_FLOAT, false }, - { GUID_WICPixelFormat16bppGrayHalf, DXGI_FORMAT_R16_FLOAT, false }, - { GUID_WICPixelFormat16bppGray, DXGI_FORMAT_R16_UNORM, true }, - { GUID_WICPixelFormat8bppGray, DXGI_FORMAT_R8_UNORM, true }, - - { GUID_WICPixelFormat8bppAlpha, DXGI_FORMAT_A8_UNORM, false }, - - { GUID_WICPixelFormatBlackWhite, DXGI_FORMAT_R1_UNORM, false }, - }; - - bool g_WIC2 = false; - IWICImagingFactory* g_Factory = nullptr; - - BOOL WINAPI InitializeWICFactory(PINIT_ONCE, PVOID, PVOID *ifactory) noexcept - { - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE) - HRESULT hr = CoCreateInstance( - CLSID_WICImagingFactory2, - nullptr, - CLSCTX_INPROC_SERVER, - __uuidof(IWICImagingFactory2), - ifactory - ); - - if (SUCCEEDED(hr)) - { - // WIC2 is available on Windows 10, Windows 8.x, and Windows 7 SP1 with KB 2670838 installed - g_WIC2 = true; - return TRUE; - } - else - { - g_WIC2 = false; - - hr = CoCreateInstance( - CLSID_WICImagingFactory1, - nullptr, - CLSCTX_INPROC_SERVER, - __uuidof(IWICImagingFactory), - ifactory - ); - return SUCCEEDED(hr) ? TRUE : FALSE; - } - #else - g_WIC2 = false; - - return SUCCEEDED(CoCreateInstance( - CLSID_WICImagingFactory, - nullptr, - CLSCTX_INPROC_SERVER, - __uuidof(IWICImagingFactory), - ifactory)) ? TRUE : FALSE; - #endif - } - -#else // !WIN32 - inline void * _aligned_malloc(size_t size, size_t alignment) - { - size = (size + alignment - 1) & ~(alignment - 1); - return std::aligned_alloc(alignment, size); - } - -#define _aligned_free free -#endif -} - - -#ifdef _WIN32 -//===================================================================================== -// WIC Utilities -//===================================================================================== - -_Use_decl_annotations_ -DXGI_FORMAT DirectX::Internal::WICToDXGI(const GUID& guid) noexcept -{ - for (size_t i = 0; i < std::size(g_WICFormats); ++i) - { - if (memcmp(&g_WICFormats[i].wic, &guid, sizeof(GUID)) == 0) - return g_WICFormats[i].format; - } - -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE) - if (g_WIC2) - { - if (memcmp(&GUID_WICPixelFormat96bppRGBFloat, &guid, sizeof(GUID)) == 0) - return DXGI_FORMAT_R32G32B32_FLOAT; - } -#endif - - return DXGI_FORMAT_UNKNOWN; -} - -_Use_decl_annotations_ -bool DirectX::Internal::DXGIToWIC(DXGI_FORMAT format, GUID& guid, bool ignoreRGBvsBGR) noexcept -{ - switch (format) - { - case DXGI_FORMAT_R8G8B8A8_UNORM: - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - if (ignoreRGBvsBGR) - { - // If we are not doing conversion so don't really care about BGR vs RGB color-order, - // we can use the canonical WIC 32bppBGRA format which avoids an extra format conversion when using the WIC scaler - memcpy(&guid, &GUID_WICPixelFormat32bppBGRA, sizeof(GUID)); - } - else - { - memcpy(&guid, &GUID_WICPixelFormat32bppRGBA, sizeof(GUID)); - } - return true; - - case DXGI_FORMAT_D32_FLOAT: - memcpy(&guid, &GUID_WICPixelFormat32bppGrayFloat, sizeof(GUID)); - return true; - - case DXGI_FORMAT_D16_UNORM: - memcpy(&guid, &GUID_WICPixelFormat16bppGray, sizeof(GUID)); - return true; - - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - memcpy(&guid, &GUID_WICPixelFormat32bppBGRA, sizeof(GUID)); - return true; - - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - memcpy(&guid, &GUID_WICPixelFormat32bppBGR, sizeof(GUID)); - return true; - - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE) - case DXGI_FORMAT_R32G32B32_FLOAT: - if (g_WIC2) - { - memcpy(&guid, &GUID_WICPixelFormat96bppRGBFloat, sizeof(GUID)); - return true; - } - break; - #endif - - default: - for (size_t i = 0; i < std::size(g_WICFormats); ++i) - { - if (g_WICFormats[i].format == format) - { - memcpy(&guid, &g_WICFormats[i].wic, sizeof(GUID)); - return true; - } - } - break; - } - - memset(&guid, 0, sizeof(GUID)); - return false; -} - -TEX_FILTER_FLAGS DirectX::Internal::CheckWICColorSpace(_In_ const GUID& sourceGUID, _In_ const GUID& targetGUID) noexcept -{ - TEX_FILTER_FLAGS srgb = TEX_FILTER_DEFAULT; - - for (size_t i = 0; i < std::size(g_WICFormats); ++i) - { - if (memcmp(&g_WICFormats[i].wic, &sourceGUID, sizeof(GUID)) == 0) - { - if (g_WICFormats[i].srgb) - srgb |= TEX_FILTER_SRGB_IN; - } - - if (memcmp(&g_WICFormats[i].wic, &targetGUID, sizeof(GUID)) == 0) - { - if (g_WICFormats[i].srgb) - srgb |= TEX_FILTER_SRGB_OUT; - } - } - - if ((srgb & (TEX_FILTER_SRGB_IN | TEX_FILTER_SRGB_OUT)) == (TEX_FILTER_SRGB_IN | TEX_FILTER_SRGB_OUT)) - { - srgb &= ~(TEX_FILTER_SRGB_IN | TEX_FILTER_SRGB_OUT); - } - - return srgb; -} - - -//------------------------------------------------------------------------------------- -// Public helper function to get common WIC codec GUIDs -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -REFGUID DirectX::GetWICCodec(WICCodecs codec) noexcept -{ - switch (codec) - { - case WIC_CODEC_BMP: - return GUID_ContainerFormatBmp; - - case WIC_CODEC_JPEG: - return GUID_ContainerFormatJpeg; - - case WIC_CODEC_PNG: - return GUID_ContainerFormatPng; - - case WIC_CODEC_TIFF: - return GUID_ContainerFormatTiff; - - case WIC_CODEC_GIF: - return GUID_ContainerFormatGif; - - case WIC_CODEC_WMP: - return GUID_ContainerFormatWmp; - - case WIC_CODEC_ICO: - return GUID_ContainerFormatIco; - -#ifdef NTDDI_WIN10_RS4 - case WIC_CODEC_HEIF: - // This requires installing https://aka.ms/heif - return GUID_ContainerFormatHeif; -#endif - - default: - return GUID_NULL; - } -} - - -//------------------------------------------------------------------------------------- -// Singleton function for WIC factory -//------------------------------------------------------------------------------------- -IWICImagingFactory* DirectX::GetWICFactory(bool& iswic2) noexcept -{ - if (g_Factory) - { - iswic2 = g_WIC2; - return g_Factory; - } - - static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT; - - if (!InitOnceExecuteOnce(&s_initOnce, - InitializeWICFactory, - nullptr, - reinterpret_cast(&g_Factory))) - { - return nullptr; - } - - iswic2 = g_WIC2; - return g_Factory; -} - - -//------------------------------------------------------------------------------------- -// Optional initializer for WIC factory -//------------------------------------------------------------------------------------- -void DirectX::SetWICFactory(_In_opt_ IWICImagingFactory* pWIC) noexcept -{ - if (pWIC == g_Factory) - return; - - bool iswic2 = false; - if (pWIC) - { - #if(_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE) - ComPtr wic2; - HRESULT hr = pWIC->QueryInterface(IID_PPV_ARGS(wic2.GetAddressOf())); - if (SUCCEEDED(hr)) - { - iswic2 = true; - } - #endif - pWIC->AddRef(); - } - - g_WIC2 = iswic2; - std::swap(pWIC, g_Factory); - if (pWIC) - pWIC->Release(); -} -#endif // WIN32 - - -//===================================================================================== -// DXGI Format Utilities -//===================================================================================== - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -bool DirectX::IsPacked(DXGI_FORMAT fmt) noexcept -{ - switch (static_cast(fmt)) - { - case DXGI_FORMAT_R8G8_B8G8_UNORM: - case DXGI_FORMAT_G8R8_G8B8_UNORM: - case DXGI_FORMAT_YUY2: // 4:2:2 8-bit - case DXGI_FORMAT_Y210: // 4:2:2 10-bit - case DXGI_FORMAT_Y216: // 4:2:2 16-bit - return true; - - default: - return false; - } -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -bool DirectX::IsVideo(DXGI_FORMAT fmt) noexcept -{ - switch (static_cast(fmt)) - { - case DXGI_FORMAT_AYUV: - case DXGI_FORMAT_Y410: - case DXGI_FORMAT_Y416: - case DXGI_FORMAT_NV12: - case DXGI_FORMAT_P010: - case DXGI_FORMAT_P016: - case DXGI_FORMAT_YUY2: - case DXGI_FORMAT_Y210: - case DXGI_FORMAT_Y216: - case DXGI_FORMAT_NV11: - // These video formats can be used with the 3D pipeline through special view mappings - - case DXGI_FORMAT_420_OPAQUE: - case DXGI_FORMAT_AI44: - case DXGI_FORMAT_IA44: - case DXGI_FORMAT_P8: - case DXGI_FORMAT_A8P8: - // These are limited use video formats not usable in any way by the 3D pipeline - - case WIN10_DXGI_FORMAT_P208: - case WIN10_DXGI_FORMAT_V208: - case WIN10_DXGI_FORMAT_V408: - // These video formats are for JPEG Hardware decode (DXGI 1.4) - return true; - - default: - return false; - } -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -bool DirectX::IsPlanar(DXGI_FORMAT fmt) noexcept -{ - switch (static_cast(fmt)) - { - case DXGI_FORMAT_NV12: // 4:2:0 8-bit - case DXGI_FORMAT_P010: // 4:2:0 10-bit - case DXGI_FORMAT_P016: // 4:2:0 16-bit - case DXGI_FORMAT_420_OPAQUE:// 4:2:0 8-bit - case DXGI_FORMAT_NV11: // 4:1:1 8-bit - - case WIN10_DXGI_FORMAT_P208: // 4:2:2 8-bit - case WIN10_DXGI_FORMAT_V208: // 4:4:0 8-bit - case WIN10_DXGI_FORMAT_V408: // 4:4:4 8-bit - // These are JPEG Hardware decode formats (DXGI 1.4) - - case XBOX_DXGI_FORMAT_D16_UNORM_S8_UINT: - case XBOX_DXGI_FORMAT_R16_UNORM_X8_TYPELESS: - case XBOX_DXGI_FORMAT_X16_TYPELESS_G8_UINT: - // These are Xbox One platform specific types - return true; - - default: - return false; - } -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -bool DirectX::IsDepthStencil(DXGI_FORMAT fmt) noexcept -{ - switch (static_cast(fmt)) - { - case DXGI_FORMAT_R32G8X24_TYPELESS: - case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: - case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: - case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: - case DXGI_FORMAT_D32_FLOAT: - case DXGI_FORMAT_R24G8_TYPELESS: - case DXGI_FORMAT_D24_UNORM_S8_UINT: - case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: - case DXGI_FORMAT_X24_TYPELESS_G8_UINT: - case DXGI_FORMAT_D16_UNORM: - case XBOX_DXGI_FORMAT_D16_UNORM_S8_UINT: - case XBOX_DXGI_FORMAT_R16_UNORM_X8_TYPELESS: - case XBOX_DXGI_FORMAT_X16_TYPELESS_G8_UINT: - return true; - - default: - return false; - } -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -bool DirectX::IsTypeless(DXGI_FORMAT fmt, bool partialTypeless) noexcept -{ - switch (static_cast(fmt)) - { - case DXGI_FORMAT_R32G32B32A32_TYPELESS: - case DXGI_FORMAT_R32G32B32_TYPELESS: - case DXGI_FORMAT_R16G16B16A16_TYPELESS: - case DXGI_FORMAT_R32G32_TYPELESS: - case DXGI_FORMAT_R32G8X24_TYPELESS: - case DXGI_FORMAT_R10G10B10A2_TYPELESS: - case DXGI_FORMAT_R8G8B8A8_TYPELESS: - case DXGI_FORMAT_R16G16_TYPELESS: - case DXGI_FORMAT_R32_TYPELESS: - case DXGI_FORMAT_R24G8_TYPELESS: - case DXGI_FORMAT_R8G8_TYPELESS: - case DXGI_FORMAT_R16_TYPELESS: - case DXGI_FORMAT_R8_TYPELESS: - case DXGI_FORMAT_BC1_TYPELESS: - case DXGI_FORMAT_BC2_TYPELESS: - case DXGI_FORMAT_BC3_TYPELESS: - case DXGI_FORMAT_BC4_TYPELESS: - case DXGI_FORMAT_BC5_TYPELESS: - case DXGI_FORMAT_B8G8R8A8_TYPELESS: - case DXGI_FORMAT_B8G8R8X8_TYPELESS: - case DXGI_FORMAT_BC6H_TYPELESS: - case DXGI_FORMAT_BC7_TYPELESS: - return true; - - case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: - case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: - case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: - case DXGI_FORMAT_X24_TYPELESS_G8_UINT: - case XBOX_DXGI_FORMAT_R16_UNORM_X8_TYPELESS: - case XBOX_DXGI_FORMAT_X16_TYPELESS_G8_UINT: - return partialTypeless; - - default: - return false; - } -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -bool DirectX::HasAlpha(DXGI_FORMAT fmt) noexcept -{ - switch (static_cast(fmt)) - { - case DXGI_FORMAT_R32G32B32A32_TYPELESS: - case DXGI_FORMAT_R32G32B32A32_FLOAT: - case DXGI_FORMAT_R32G32B32A32_UINT: - case DXGI_FORMAT_R32G32B32A32_SINT: - case DXGI_FORMAT_R16G16B16A16_TYPELESS: - case DXGI_FORMAT_R16G16B16A16_FLOAT: - case DXGI_FORMAT_R16G16B16A16_UNORM: - case DXGI_FORMAT_R16G16B16A16_UINT: - case DXGI_FORMAT_R16G16B16A16_SNORM: - case DXGI_FORMAT_R16G16B16A16_SINT: - case DXGI_FORMAT_R10G10B10A2_TYPELESS: - case DXGI_FORMAT_R10G10B10A2_UNORM: - case DXGI_FORMAT_R10G10B10A2_UINT: - case DXGI_FORMAT_R8G8B8A8_TYPELESS: - case DXGI_FORMAT_R8G8B8A8_UNORM: - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - case DXGI_FORMAT_R8G8B8A8_UINT: - case DXGI_FORMAT_R8G8B8A8_SNORM: - case DXGI_FORMAT_R8G8B8A8_SINT: - case DXGI_FORMAT_A8_UNORM: - case DXGI_FORMAT_BC1_TYPELESS: - case DXGI_FORMAT_BC1_UNORM: - case DXGI_FORMAT_BC1_UNORM_SRGB: - case DXGI_FORMAT_BC2_TYPELESS: - case DXGI_FORMAT_BC2_UNORM: - case DXGI_FORMAT_BC2_UNORM_SRGB: - case DXGI_FORMAT_BC3_TYPELESS: - case DXGI_FORMAT_BC3_UNORM: - case DXGI_FORMAT_BC3_UNORM_SRGB: - case DXGI_FORMAT_B5G5R5A1_UNORM: - case DXGI_FORMAT_B8G8R8A8_UNORM: - case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: - case DXGI_FORMAT_B8G8R8A8_TYPELESS: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - case DXGI_FORMAT_BC7_TYPELESS: - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: - case DXGI_FORMAT_AYUV: - case DXGI_FORMAT_Y410: - case DXGI_FORMAT_Y416: - case DXGI_FORMAT_AI44: - case DXGI_FORMAT_IA44: - case DXGI_FORMAT_A8P8: - case DXGI_FORMAT_B4G4R4A4_UNORM: - case XBOX_DXGI_FORMAT_R10G10B10_7E3_A2_FLOAT: - case XBOX_DXGI_FORMAT_R10G10B10_6E4_A2_FLOAT: - case XBOX_DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM: - return true; - - default: - return false; - } -} - - -//------------------------------------------------------------------------------------- -// Returns bits-per-pixel for a given DXGI format, or 0 on failure -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -size_t DirectX::BitsPerPixel(DXGI_FORMAT fmt) noexcept -{ - switch (static_cast(fmt)) - { - case DXGI_FORMAT_R32G32B32A32_TYPELESS: - case DXGI_FORMAT_R32G32B32A32_FLOAT: - case DXGI_FORMAT_R32G32B32A32_UINT: - case DXGI_FORMAT_R32G32B32A32_SINT: - return 128; - - case DXGI_FORMAT_R32G32B32_TYPELESS: - case DXGI_FORMAT_R32G32B32_FLOAT: - case DXGI_FORMAT_R32G32B32_UINT: - case DXGI_FORMAT_R32G32B32_SINT: - return 96; - - case DXGI_FORMAT_R16G16B16A16_TYPELESS: - case DXGI_FORMAT_R16G16B16A16_FLOAT: - case DXGI_FORMAT_R16G16B16A16_UNORM: - case DXGI_FORMAT_R16G16B16A16_UINT: - case DXGI_FORMAT_R16G16B16A16_SNORM: - case DXGI_FORMAT_R16G16B16A16_SINT: - case DXGI_FORMAT_R32G32_TYPELESS: - case DXGI_FORMAT_R32G32_FLOAT: - case DXGI_FORMAT_R32G32_UINT: - case DXGI_FORMAT_R32G32_SINT: - case DXGI_FORMAT_R32G8X24_TYPELESS: - case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: - case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: - case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: - case DXGI_FORMAT_Y416: - case DXGI_FORMAT_Y210: - case DXGI_FORMAT_Y216: - return 64; - - case DXGI_FORMAT_R10G10B10A2_TYPELESS: - case DXGI_FORMAT_R10G10B10A2_UNORM: - case DXGI_FORMAT_R10G10B10A2_UINT: - case DXGI_FORMAT_R11G11B10_FLOAT: - case DXGI_FORMAT_R8G8B8A8_TYPELESS: - case DXGI_FORMAT_R8G8B8A8_UNORM: - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - case DXGI_FORMAT_R8G8B8A8_UINT: - case DXGI_FORMAT_R8G8B8A8_SNORM: - case DXGI_FORMAT_R8G8B8A8_SINT: - case DXGI_FORMAT_R16G16_TYPELESS: - case DXGI_FORMAT_R16G16_FLOAT: - case DXGI_FORMAT_R16G16_UNORM: - case DXGI_FORMAT_R16G16_UINT: - case DXGI_FORMAT_R16G16_SNORM: - case DXGI_FORMAT_R16G16_SINT: - case DXGI_FORMAT_R32_TYPELESS: - case DXGI_FORMAT_D32_FLOAT: - case DXGI_FORMAT_R32_FLOAT: - case DXGI_FORMAT_R32_UINT: - case DXGI_FORMAT_R32_SINT: - case DXGI_FORMAT_R24G8_TYPELESS: - case DXGI_FORMAT_D24_UNORM_S8_UINT: - case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: - case DXGI_FORMAT_X24_TYPELESS_G8_UINT: - case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: - case DXGI_FORMAT_R8G8_B8G8_UNORM: - case DXGI_FORMAT_G8R8_G8B8_UNORM: - case DXGI_FORMAT_B8G8R8A8_UNORM: - case DXGI_FORMAT_B8G8R8X8_UNORM: - case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: - case DXGI_FORMAT_B8G8R8A8_TYPELESS: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8X8_TYPELESS: - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - case DXGI_FORMAT_AYUV: - case DXGI_FORMAT_Y410: - case DXGI_FORMAT_YUY2: - case XBOX_DXGI_FORMAT_R10G10B10_7E3_A2_FLOAT: - case XBOX_DXGI_FORMAT_R10G10B10_6E4_A2_FLOAT: - case XBOX_DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM: - return 32; - - case DXGI_FORMAT_P010: - case DXGI_FORMAT_P016: - case XBOX_DXGI_FORMAT_D16_UNORM_S8_UINT: - case XBOX_DXGI_FORMAT_R16_UNORM_X8_TYPELESS: - case XBOX_DXGI_FORMAT_X16_TYPELESS_G8_UINT: - case WIN10_DXGI_FORMAT_V408: - return 24; - - case DXGI_FORMAT_R8G8_TYPELESS: - case DXGI_FORMAT_R8G8_UNORM: - case DXGI_FORMAT_R8G8_UINT: - case DXGI_FORMAT_R8G8_SNORM: - case DXGI_FORMAT_R8G8_SINT: - case DXGI_FORMAT_R16_TYPELESS: - case DXGI_FORMAT_R16_FLOAT: - case DXGI_FORMAT_D16_UNORM: - case DXGI_FORMAT_R16_UNORM: - case DXGI_FORMAT_R16_UINT: - case DXGI_FORMAT_R16_SNORM: - case DXGI_FORMAT_R16_SINT: - case DXGI_FORMAT_B5G6R5_UNORM: - case DXGI_FORMAT_B5G5R5A1_UNORM: - case DXGI_FORMAT_A8P8: - case DXGI_FORMAT_B4G4R4A4_UNORM: - case WIN10_DXGI_FORMAT_P208: - case WIN10_DXGI_FORMAT_V208: - return 16; - - case DXGI_FORMAT_NV12: - case DXGI_FORMAT_420_OPAQUE: - case DXGI_FORMAT_NV11: - return 12; - - case DXGI_FORMAT_R8_TYPELESS: - case DXGI_FORMAT_R8_UNORM: - case DXGI_FORMAT_R8_UINT: - case DXGI_FORMAT_R8_SNORM: - case DXGI_FORMAT_R8_SINT: - case DXGI_FORMAT_A8_UNORM: - case DXGI_FORMAT_BC2_TYPELESS: - case DXGI_FORMAT_BC2_UNORM: - case DXGI_FORMAT_BC2_UNORM_SRGB: - case DXGI_FORMAT_BC3_TYPELESS: - case DXGI_FORMAT_BC3_UNORM: - case DXGI_FORMAT_BC3_UNORM_SRGB: - case DXGI_FORMAT_BC5_TYPELESS: - case DXGI_FORMAT_BC5_UNORM: - case DXGI_FORMAT_BC5_SNORM: - case DXGI_FORMAT_BC6H_TYPELESS: - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - case DXGI_FORMAT_BC7_TYPELESS: - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: - case DXGI_FORMAT_AI44: - case DXGI_FORMAT_IA44: - case DXGI_FORMAT_P8: - case XBOX_DXGI_FORMAT_R4G4_UNORM: - return 8; - - case DXGI_FORMAT_R1_UNORM: - return 1; - - case DXGI_FORMAT_BC1_TYPELESS: - case DXGI_FORMAT_BC1_UNORM: - case DXGI_FORMAT_BC1_UNORM_SRGB: - case DXGI_FORMAT_BC4_TYPELESS: - case DXGI_FORMAT_BC4_UNORM: - case DXGI_FORMAT_BC4_SNORM: - return 4; - - default: - return 0; - } -} - - -//------------------------------------------------------------------------------------- -// Returns bits-per-color-channel for a given DXGI format, or 0 on failure -// For mixed formats, it returns the largest color-depth in the format -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -size_t DirectX::BitsPerColor(DXGI_FORMAT fmt) noexcept -{ - switch (static_cast(fmt)) - { - case DXGI_FORMAT_R32G32B32A32_TYPELESS: - case DXGI_FORMAT_R32G32B32A32_FLOAT: - case DXGI_FORMAT_R32G32B32A32_UINT: - case DXGI_FORMAT_R32G32B32A32_SINT: - case DXGI_FORMAT_R32G32B32_TYPELESS: - case DXGI_FORMAT_R32G32B32_FLOAT: - case DXGI_FORMAT_R32G32B32_UINT: - case DXGI_FORMAT_R32G32B32_SINT: - case DXGI_FORMAT_R32G32_TYPELESS: - case DXGI_FORMAT_R32G32_FLOAT: - case DXGI_FORMAT_R32G32_UINT: - case DXGI_FORMAT_R32G32_SINT: - case DXGI_FORMAT_R32G8X24_TYPELESS: - case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: - case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: - case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: - case DXGI_FORMAT_R32_TYPELESS: - case DXGI_FORMAT_D32_FLOAT: - case DXGI_FORMAT_R32_FLOAT: - case DXGI_FORMAT_R32_UINT: - case DXGI_FORMAT_R32_SINT: - return 32; - - case DXGI_FORMAT_R24G8_TYPELESS: - case DXGI_FORMAT_D24_UNORM_S8_UINT: - case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: - case DXGI_FORMAT_X24_TYPELESS_G8_UINT: - return 24; - - case DXGI_FORMAT_R16G16B16A16_TYPELESS: - case DXGI_FORMAT_R16G16B16A16_FLOAT: - case DXGI_FORMAT_R16G16B16A16_UNORM: - case DXGI_FORMAT_R16G16B16A16_UINT: - case DXGI_FORMAT_R16G16B16A16_SNORM: - case DXGI_FORMAT_R16G16B16A16_SINT: - case DXGI_FORMAT_R16G16_TYPELESS: - case DXGI_FORMAT_R16G16_FLOAT: - case DXGI_FORMAT_R16G16_UNORM: - case DXGI_FORMAT_R16G16_UINT: - case DXGI_FORMAT_R16G16_SNORM: - case DXGI_FORMAT_R16G16_SINT: - case DXGI_FORMAT_R16_TYPELESS: - case DXGI_FORMAT_R16_FLOAT: - case DXGI_FORMAT_D16_UNORM: - case DXGI_FORMAT_R16_UNORM: - case DXGI_FORMAT_R16_UINT: - case DXGI_FORMAT_R16_SNORM: - case DXGI_FORMAT_R16_SINT: - case DXGI_FORMAT_BC6H_TYPELESS: - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - case DXGI_FORMAT_Y416: - case DXGI_FORMAT_P016: - case DXGI_FORMAT_Y216: - case XBOX_DXGI_FORMAT_D16_UNORM_S8_UINT: - case XBOX_DXGI_FORMAT_R16_UNORM_X8_TYPELESS: - case XBOX_DXGI_FORMAT_X16_TYPELESS_G8_UINT: - return 16; - - case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: - return 14; - - case DXGI_FORMAT_R11G11B10_FLOAT: - return 11; - - case DXGI_FORMAT_R10G10B10A2_TYPELESS: - case DXGI_FORMAT_R10G10B10A2_UNORM: - case DXGI_FORMAT_R10G10B10A2_UINT: - case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: - case DXGI_FORMAT_Y410: - case DXGI_FORMAT_P010: - case DXGI_FORMAT_Y210: - case XBOX_DXGI_FORMAT_R10G10B10_7E3_A2_FLOAT: - case XBOX_DXGI_FORMAT_R10G10B10_6E4_A2_FLOAT: - case XBOX_DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM: - return 10; - - case DXGI_FORMAT_R8G8B8A8_TYPELESS: - case DXGI_FORMAT_R8G8B8A8_UNORM: - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - case DXGI_FORMAT_R8G8B8A8_UINT: - case DXGI_FORMAT_R8G8B8A8_SNORM: - case DXGI_FORMAT_R8G8B8A8_SINT: - case DXGI_FORMAT_R8G8_TYPELESS: - case DXGI_FORMAT_R8G8_UNORM: - case DXGI_FORMAT_R8G8_UINT: - case DXGI_FORMAT_R8G8_SNORM: - case DXGI_FORMAT_R8G8_SINT: - case DXGI_FORMAT_R8_TYPELESS: - case DXGI_FORMAT_R8_UNORM: - case DXGI_FORMAT_R8_UINT: - case DXGI_FORMAT_R8_SNORM: - case DXGI_FORMAT_R8_SINT: - case DXGI_FORMAT_A8_UNORM: - case DXGI_FORMAT_R8G8_B8G8_UNORM: - case DXGI_FORMAT_G8R8_G8B8_UNORM: - case DXGI_FORMAT_BC4_TYPELESS: - case DXGI_FORMAT_BC4_UNORM: - case DXGI_FORMAT_BC4_SNORM: - case DXGI_FORMAT_BC5_TYPELESS: - case DXGI_FORMAT_BC5_UNORM: - case DXGI_FORMAT_BC5_SNORM: - case DXGI_FORMAT_B8G8R8A8_UNORM: - case DXGI_FORMAT_B8G8R8X8_UNORM: - case DXGI_FORMAT_B8G8R8A8_TYPELESS: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8X8_TYPELESS: - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - case DXGI_FORMAT_AYUV: - case DXGI_FORMAT_NV12: - case DXGI_FORMAT_420_OPAQUE: - case DXGI_FORMAT_YUY2: - case DXGI_FORMAT_NV11: - case WIN10_DXGI_FORMAT_P208: - case WIN10_DXGI_FORMAT_V208: - case WIN10_DXGI_FORMAT_V408: - return 8; - - case DXGI_FORMAT_BC7_TYPELESS: - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: - return 7; - - case DXGI_FORMAT_BC1_TYPELESS: - case DXGI_FORMAT_BC1_UNORM: - case DXGI_FORMAT_BC1_UNORM_SRGB: - case DXGI_FORMAT_BC2_TYPELESS: - case DXGI_FORMAT_BC2_UNORM: - case DXGI_FORMAT_BC2_UNORM_SRGB: - case DXGI_FORMAT_BC3_TYPELESS: - case DXGI_FORMAT_BC3_UNORM: - case DXGI_FORMAT_BC3_UNORM_SRGB: - case DXGI_FORMAT_B5G6R5_UNORM: - return 6; - - case DXGI_FORMAT_B5G5R5A1_UNORM: - return 5; - - case DXGI_FORMAT_B4G4R4A4_UNORM: - case XBOX_DXGI_FORMAT_R4G4_UNORM: - return 4; - - case DXGI_FORMAT_R1_UNORM: - return 1; - - case DXGI_FORMAT_AI44: - case DXGI_FORMAT_IA44: - case DXGI_FORMAT_P8: - case DXGI_FORMAT_A8P8: - // Palettized formats return 0 for this function - - default: - return 0; - } -} - - -//------------------------------------------------------------------------------------- -// Computes the image row pitch in bytes, and the slice ptich (size in bytes of the image) -// based on DXGI format, width, and height -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::ComputePitch(DXGI_FORMAT fmt, size_t width, size_t height, - size_t& rowPitch, size_t& slicePitch, CP_FLAGS flags) noexcept -{ - uint64_t pitch = 0; - uint64_t slice = 0; - - switch (static_cast(fmt)) - { - case DXGI_FORMAT_BC1_TYPELESS: - case DXGI_FORMAT_BC1_UNORM: - case DXGI_FORMAT_BC1_UNORM_SRGB: - case DXGI_FORMAT_BC4_TYPELESS: - case DXGI_FORMAT_BC4_UNORM: - case DXGI_FORMAT_BC4_SNORM: - assert(IsCompressed(fmt)); - { - if (flags & CP_FLAGS_BAD_DXTN_TAILS) - { - const size_t nbw = width >> 2; - const size_t nbh = height >> 2; - pitch = std::max(1u, uint64_t(nbw) * 8u); - slice = std::max(1u, pitch * uint64_t(nbh)); - } - else - { - const uint64_t nbw = std::max(1u, (uint64_t(width) + 3u) / 4u); - const uint64_t nbh = std::max(1u, (uint64_t(height) + 3u) / 4u); - pitch = nbw * 8u; - slice = pitch * nbh; - } - } - break; - - case DXGI_FORMAT_BC2_TYPELESS: - case DXGI_FORMAT_BC2_UNORM: - case DXGI_FORMAT_BC2_UNORM_SRGB: - case DXGI_FORMAT_BC3_TYPELESS: - case DXGI_FORMAT_BC3_UNORM: - case DXGI_FORMAT_BC3_UNORM_SRGB: - case DXGI_FORMAT_BC5_TYPELESS: - case DXGI_FORMAT_BC5_UNORM: - case DXGI_FORMAT_BC5_SNORM: - case DXGI_FORMAT_BC6H_TYPELESS: - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - case DXGI_FORMAT_BC7_TYPELESS: - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: - assert(IsCompressed(fmt)); - { - if (flags & CP_FLAGS_BAD_DXTN_TAILS) - { - const size_t nbw = width >> 2; - const size_t nbh = height >> 2; - pitch = std::max(1u, uint64_t(nbw) * 16u); - slice = std::max(1u, pitch * uint64_t(nbh)); - } - else - { - const uint64_t nbw = std::max(1u, (uint64_t(width) + 3u) / 4u); - const uint64_t nbh = std::max(1u, (uint64_t(height) + 3u) / 4u); - pitch = nbw * 16u; - slice = pitch * nbh; - } - } - break; - - case DXGI_FORMAT_R8G8_B8G8_UNORM: - case DXGI_FORMAT_G8R8_G8B8_UNORM: - case DXGI_FORMAT_YUY2: - assert(IsPacked(fmt)); - pitch = ((uint64_t(width) + 1u) >> 1) * 4u; - slice = pitch * uint64_t(height); - break; - - case DXGI_FORMAT_Y210: - case DXGI_FORMAT_Y216: - assert(IsPacked(fmt)); - pitch = ((uint64_t(width) + 1u) >> 1) * 8u; - slice = pitch * uint64_t(height); - break; - - case DXGI_FORMAT_NV12: - case DXGI_FORMAT_420_OPAQUE: - assert(IsPlanar(fmt)); - pitch = ((uint64_t(width) + 1u) >> 1) * 2u; - slice = pitch * (uint64_t(height) + ((uint64_t(height) + 1u) >> 1)); - break; - - case DXGI_FORMAT_P010: - case DXGI_FORMAT_P016: - case XBOX_DXGI_FORMAT_D16_UNORM_S8_UINT: - case XBOX_DXGI_FORMAT_R16_UNORM_X8_TYPELESS: - case XBOX_DXGI_FORMAT_X16_TYPELESS_G8_UINT: - assert(IsPlanar(fmt)); - pitch = ((uint64_t(width) + 1u) >> 1) * 4u; - slice = pitch * (uint64_t(height) + ((uint64_t(height) + 1u) >> 1)); - break; - - case DXGI_FORMAT_NV11: - assert(IsPlanar(fmt)); - pitch = ((uint64_t(width) + 3u) >> 2) * 4u; - slice = pitch * uint64_t(height) * 2u; - break; - - case WIN10_DXGI_FORMAT_P208: - assert(IsPlanar(fmt)); - pitch = ((uint64_t(width) + 1u) >> 1) * 2u; - slice = pitch * uint64_t(height) * 2u; - break; - - case WIN10_DXGI_FORMAT_V208: - assert(IsPlanar(fmt)); - pitch = uint64_t(width); - slice = pitch * (uint64_t(height) + (((uint64_t(height) + 1u) >> 1) * 2u)); - break; - - case WIN10_DXGI_FORMAT_V408: - assert(IsPlanar(fmt)); - pitch = uint64_t(width); - slice = pitch * (uint64_t(height) + (uint64_t(height >> 1) * 4u)); - break; - - default: - assert(!IsCompressed(fmt) && !IsPacked(fmt) && !IsPlanar(fmt)); - { - size_t bpp; - - if (flags & CP_FLAGS_24BPP) - bpp = 24; - else if (flags & CP_FLAGS_16BPP) - bpp = 16; - else if (flags & CP_FLAGS_8BPP) - bpp = 8; - else - bpp = BitsPerPixel(fmt); - - if (!bpp) - return E_INVALIDARG; - - if (flags & (CP_FLAGS_LEGACY_DWORD | CP_FLAGS_PARAGRAPH | CP_FLAGS_YMM | CP_FLAGS_ZMM | CP_FLAGS_PAGE4K)) - { - if (flags & CP_FLAGS_PAGE4K) - { - pitch = ((uint64_t(width) * bpp + 32767u) / 32768u) * 4096u; - slice = pitch * uint64_t(height); - } - else if (flags & CP_FLAGS_ZMM) - { - pitch = ((uint64_t(width) * bpp + 511u) / 512u) * 64u; - slice = pitch * uint64_t(height); - } - else if (flags & CP_FLAGS_YMM) - { - pitch = ((uint64_t(width) * bpp + 255u) / 256u) * 32u; - slice = pitch * uint64_t(height); - } - else if (flags & CP_FLAGS_PARAGRAPH) - { - pitch = ((uint64_t(width) * bpp + 127u) / 128u) * 16u; - slice = pitch * uint64_t(height); - } - else // DWORD alignment - { - // Special computation for some incorrectly created DDS files based on - // legacy DirectDraw assumptions about pitch alignment - pitch = ((uint64_t(width) * bpp + 31u) / 32u) * sizeof(uint32_t); - slice = pitch * uint64_t(height); - } - } - else - { - // Default byte alignment - pitch = (uint64_t(width) * bpp + 7u) / 8u; - slice = pitch * uint64_t(height); - } - } - break; - } - -#if defined(_M_IX86) || defined(_M_ARM) || defined(_M_HYBRID_X86_ARM64) - static_assert(sizeof(size_t) == 4, "Not a 32-bit platform!"); - if (pitch > UINT32_MAX || slice > UINT32_MAX) - { - rowPitch = slicePitch = 0; - return HRESULT_E_ARITHMETIC_OVERFLOW; - } -#else - static_assert(sizeof(size_t) == 8, "Not a 64-bit platform!"); -#endif - - rowPitch = static_cast(pitch); - slicePitch = static_cast(slice); - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -size_t DirectX::ComputeScanlines(DXGI_FORMAT fmt, size_t height) noexcept -{ - switch (static_cast(fmt)) - { - case DXGI_FORMAT_BC1_TYPELESS: - case DXGI_FORMAT_BC1_UNORM: - case DXGI_FORMAT_BC1_UNORM_SRGB: - case DXGI_FORMAT_BC2_TYPELESS: - case DXGI_FORMAT_BC2_UNORM: - case DXGI_FORMAT_BC2_UNORM_SRGB: - case DXGI_FORMAT_BC3_TYPELESS: - case DXGI_FORMAT_BC3_UNORM: - case DXGI_FORMAT_BC3_UNORM_SRGB: - case DXGI_FORMAT_BC4_TYPELESS: - case DXGI_FORMAT_BC4_UNORM: - case DXGI_FORMAT_BC4_SNORM: - case DXGI_FORMAT_BC5_TYPELESS: - case DXGI_FORMAT_BC5_UNORM: - case DXGI_FORMAT_BC5_SNORM: - case DXGI_FORMAT_BC6H_TYPELESS: - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - case DXGI_FORMAT_BC7_TYPELESS: - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: - assert(IsCompressed(fmt)); - return std::max(1, (height + 3) / 4); - - case DXGI_FORMAT_NV11: - case WIN10_DXGI_FORMAT_P208: - assert(IsPlanar(fmt)); - return height * 2; - - case WIN10_DXGI_FORMAT_V208: - assert(IsPlanar(fmt)); - return height + (((height + 1) >> 1) * 2); - - case WIN10_DXGI_FORMAT_V408: - assert(IsPlanar(fmt)); - return height + ((height >> 1) * 4); - - case DXGI_FORMAT_NV12: - case DXGI_FORMAT_P010: - case DXGI_FORMAT_P016: - case DXGI_FORMAT_420_OPAQUE: - case XBOX_DXGI_FORMAT_D16_UNORM_S8_UINT: - case XBOX_DXGI_FORMAT_R16_UNORM_X8_TYPELESS: - case XBOX_DXGI_FORMAT_X16_TYPELESS_G8_UINT: - assert(IsPlanar(fmt)); - return height + ((height + 1) >> 1); - - default: - assert(IsValid(fmt)); - assert(!IsCompressed(fmt) && !IsPlanar(fmt)); - return height; - } -} - - -//------------------------------------------------------------------------------------- -// Converts to an SRGB equivalent type if available -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -DXGI_FORMAT DirectX::MakeSRGB(DXGI_FORMAT fmt) noexcept -{ - switch (fmt) - { - case DXGI_FORMAT_R8G8B8A8_UNORM: - return DXGI_FORMAT_R8G8B8A8_UNORM_SRGB; - - case DXGI_FORMAT_BC1_UNORM: - return DXGI_FORMAT_BC1_UNORM_SRGB; - - case DXGI_FORMAT_BC2_UNORM: - return DXGI_FORMAT_BC2_UNORM_SRGB; - - case DXGI_FORMAT_BC3_UNORM: - return DXGI_FORMAT_BC3_UNORM_SRGB; - - case DXGI_FORMAT_B8G8R8A8_UNORM: - return DXGI_FORMAT_B8G8R8A8_UNORM_SRGB; - - case DXGI_FORMAT_B8G8R8X8_UNORM: - return DXGI_FORMAT_B8G8R8X8_UNORM_SRGB; - - case DXGI_FORMAT_BC7_UNORM: - return DXGI_FORMAT_BC7_UNORM_SRGB; - - default: - return fmt; - } -} - - -//------------------------------------------------------------------------------------- -// Converts to a format to an equivalent TYPELESS format if available -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -DXGI_FORMAT DirectX::MakeTypeless(DXGI_FORMAT fmt) noexcept -{ - switch (static_cast(fmt)) - { - case DXGI_FORMAT_R32G32B32A32_FLOAT: - case DXGI_FORMAT_R32G32B32A32_UINT: - case DXGI_FORMAT_R32G32B32A32_SINT: - return DXGI_FORMAT_R32G32B32A32_TYPELESS; - - case DXGI_FORMAT_R32G32B32_FLOAT: - case DXGI_FORMAT_R32G32B32_UINT: - case DXGI_FORMAT_R32G32B32_SINT: - return DXGI_FORMAT_R32G32B32_TYPELESS; - - case DXGI_FORMAT_R16G16B16A16_FLOAT: - case DXGI_FORMAT_R16G16B16A16_UNORM: - case DXGI_FORMAT_R16G16B16A16_UINT: - case DXGI_FORMAT_R16G16B16A16_SNORM: - case DXGI_FORMAT_R16G16B16A16_SINT: - return DXGI_FORMAT_R16G16B16A16_TYPELESS; - - case DXGI_FORMAT_R32G32_FLOAT: - case DXGI_FORMAT_R32G32_UINT: - case DXGI_FORMAT_R32G32_SINT: - return DXGI_FORMAT_R32G32_TYPELESS; - - case DXGI_FORMAT_R10G10B10A2_UNORM: - case DXGI_FORMAT_R10G10B10A2_UINT: - case XBOX_DXGI_FORMAT_R10G10B10_7E3_A2_FLOAT: - case XBOX_DXGI_FORMAT_R10G10B10_6E4_A2_FLOAT: - case XBOX_DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM: - return DXGI_FORMAT_R10G10B10A2_TYPELESS; - - case DXGI_FORMAT_R8G8B8A8_UNORM: - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - case DXGI_FORMAT_R8G8B8A8_UINT: - case DXGI_FORMAT_R8G8B8A8_SNORM: - case DXGI_FORMAT_R8G8B8A8_SINT: - return DXGI_FORMAT_R8G8B8A8_TYPELESS; - - case DXGI_FORMAT_R16G16_FLOAT: - case DXGI_FORMAT_R16G16_UNORM: - case DXGI_FORMAT_R16G16_UINT: - case DXGI_FORMAT_R16G16_SNORM: - case DXGI_FORMAT_R16G16_SINT: - return DXGI_FORMAT_R16G16_TYPELESS; - - case DXGI_FORMAT_D32_FLOAT: - case DXGI_FORMAT_R32_FLOAT: - case DXGI_FORMAT_R32_UINT: - case DXGI_FORMAT_R32_SINT: - return DXGI_FORMAT_R32_TYPELESS; - - case DXGI_FORMAT_R8G8_UNORM: - case DXGI_FORMAT_R8G8_UINT: - case DXGI_FORMAT_R8G8_SNORM: - case DXGI_FORMAT_R8G8_SINT: - return DXGI_FORMAT_R8G8_TYPELESS; - - case DXGI_FORMAT_R16_FLOAT: - case DXGI_FORMAT_D16_UNORM: - case DXGI_FORMAT_R16_UNORM: - case DXGI_FORMAT_R16_UINT: - case DXGI_FORMAT_R16_SNORM: - case DXGI_FORMAT_R16_SINT: - return DXGI_FORMAT_R16_TYPELESS; - - case DXGI_FORMAT_R8_UNORM: - case DXGI_FORMAT_R8_UINT: - case DXGI_FORMAT_R8_SNORM: - case DXGI_FORMAT_R8_SINT: - case XBOX_DXGI_FORMAT_R4G4_UNORM: - return DXGI_FORMAT_R8_TYPELESS; - - case DXGI_FORMAT_BC1_UNORM: - case DXGI_FORMAT_BC1_UNORM_SRGB: - return DXGI_FORMAT_BC1_TYPELESS; - - case DXGI_FORMAT_BC2_UNORM: - case DXGI_FORMAT_BC2_UNORM_SRGB: - return DXGI_FORMAT_BC2_TYPELESS; - - case DXGI_FORMAT_BC3_UNORM: - case DXGI_FORMAT_BC3_UNORM_SRGB: - return DXGI_FORMAT_BC3_TYPELESS; - - case DXGI_FORMAT_BC4_UNORM: - case DXGI_FORMAT_BC4_SNORM: - return DXGI_FORMAT_BC4_TYPELESS; - - case DXGI_FORMAT_BC5_UNORM: - case DXGI_FORMAT_BC5_SNORM: - return DXGI_FORMAT_BC5_TYPELESS; - - case DXGI_FORMAT_B8G8R8A8_UNORM: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - return DXGI_FORMAT_B8G8R8A8_TYPELESS; - - case DXGI_FORMAT_B8G8R8X8_UNORM: - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - return DXGI_FORMAT_B8G8R8X8_TYPELESS; - - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - return DXGI_FORMAT_BC6H_TYPELESS; - - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: - return DXGI_FORMAT_BC7_TYPELESS; - - default: - return fmt; - } -} - - -//------------------------------------------------------------------------------------- -// Converts to a TYPELESS format to an equivalent UNORM format if available -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -DXGI_FORMAT DirectX::MakeTypelessUNORM(DXGI_FORMAT fmt) noexcept -{ - switch (fmt) - { - case DXGI_FORMAT_R16G16B16A16_TYPELESS: - return DXGI_FORMAT_R16G16B16A16_UNORM; - - case DXGI_FORMAT_R10G10B10A2_TYPELESS: - return DXGI_FORMAT_R10G10B10A2_UNORM; - - case DXGI_FORMAT_R8G8B8A8_TYPELESS: - return DXGI_FORMAT_R8G8B8A8_UNORM; - - case DXGI_FORMAT_R16G16_TYPELESS: - return DXGI_FORMAT_R16G16_UNORM; - - case DXGI_FORMAT_R8G8_TYPELESS: - return DXGI_FORMAT_R8G8_UNORM; - - case DXGI_FORMAT_R16_TYPELESS: - return DXGI_FORMAT_R16_UNORM; - - case DXGI_FORMAT_R8_TYPELESS: - return DXGI_FORMAT_R8_UNORM; - - case DXGI_FORMAT_BC1_TYPELESS: - return DXGI_FORMAT_BC1_UNORM; - - case DXGI_FORMAT_BC2_TYPELESS: - return DXGI_FORMAT_BC2_UNORM; - - case DXGI_FORMAT_BC3_TYPELESS: - return DXGI_FORMAT_BC3_UNORM; - - case DXGI_FORMAT_BC4_TYPELESS: - return DXGI_FORMAT_BC4_UNORM; - - case DXGI_FORMAT_BC5_TYPELESS: - return DXGI_FORMAT_BC5_UNORM; - - case DXGI_FORMAT_B8G8R8A8_TYPELESS: - return DXGI_FORMAT_B8G8R8A8_UNORM; - - case DXGI_FORMAT_B8G8R8X8_TYPELESS: - return DXGI_FORMAT_B8G8R8X8_UNORM; - - case DXGI_FORMAT_BC7_TYPELESS: - return DXGI_FORMAT_BC7_UNORM; - - default: - return fmt; - } -} - - -//------------------------------------------------------------------------------------- -// Converts to a TYPELESS format to an equivalent FLOAT format if available -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -DXGI_FORMAT DirectX::MakeTypelessFLOAT(DXGI_FORMAT fmt) noexcept -{ - switch (fmt) - { - case DXGI_FORMAT_R32G32B32A32_TYPELESS: - return DXGI_FORMAT_R32G32B32A32_FLOAT; - - case DXGI_FORMAT_R32G32B32_TYPELESS: - return DXGI_FORMAT_R32G32B32_FLOAT; - - case DXGI_FORMAT_R16G16B16A16_TYPELESS: - return DXGI_FORMAT_R16G16B16A16_FLOAT; - - case DXGI_FORMAT_R32G32_TYPELESS: - return DXGI_FORMAT_R32G32_FLOAT; - - case DXGI_FORMAT_R16G16_TYPELESS: - return DXGI_FORMAT_R16G16_FLOAT; - - case DXGI_FORMAT_R32_TYPELESS: - return DXGI_FORMAT_R32_FLOAT; - - case DXGI_FORMAT_R16_TYPELESS: - return DXGI_FORMAT_R16_FLOAT; - - default: - return fmt; - } -} - - -//===================================================================================== -// TexMetadata -//===================================================================================== - -_Use_decl_annotations_ -size_t TexMetadata::ComputeIndex(size_t mip, size_t item, size_t slice) const noexcept -{ - if (mip >= mipLevels) - return size_t(-1); - - switch (dimension) - { - case TEX_DIMENSION_TEXTURE1D: - case TEX_DIMENSION_TEXTURE2D: - if (slice > 0) - return size_t(-1); - - if (item >= arraySize) - return size_t(-1); - - return (item*(mipLevels)+mip); - - case TEX_DIMENSION_TEXTURE3D: - if (item > 0) - { - // No support for arrays of volumes - return size_t(-1); - } - else - { - size_t index = 0; - size_t d = depth; - - for (size_t level = 0; level < mip; ++level) - { - index += d; - if (d > 1) - d >>= 1; - } - - if (slice >= d) - return size_t(-1); - - index += slice; - - return index; - } - - default: - return size_t(-1); - } -} - - -//===================================================================================== -// Blob - Bitmap image container -//===================================================================================== - -Blob& Blob::operator= (Blob&& moveFrom) noexcept -{ - if (this != &moveFrom) - { - Release(); - - m_buffer = moveFrom.m_buffer; - m_size = moveFrom.m_size; - - moveFrom.m_buffer = nullptr; - moveFrom.m_size = 0; - } - return *this; -} - -void Blob::Release() noexcept -{ - if (m_buffer) - { - _aligned_free(m_buffer); - m_buffer = nullptr; - } - - m_size = 0; -} - -_Use_decl_annotations_ -HRESULT Blob::Initialize(size_t size) noexcept -{ - if (!size) - return E_INVALIDARG; - - Release(); - - m_buffer = _aligned_malloc(size, 16); - if (!m_buffer) - { - Release(); - return E_OUTOFMEMORY; - } - - m_size = size; - - return S_OK; -} - -HRESULT Blob::Trim(size_t size) noexcept -{ - if (!size) - return E_INVALIDARG; - - if (!m_buffer) - return E_UNEXPECTED; - - if (size > m_size) - return E_INVALIDARG; - - m_size = size; - - return S_OK; -} - -HRESULT Blob::Resize(size_t size) noexcept -{ - if (!size) - return E_INVALIDARG; - - if (!m_buffer || !m_size) - return E_UNEXPECTED; - - void *tbuffer = _aligned_malloc(size, 16); - if (!tbuffer) - return E_OUTOFMEMORY; - - memcpy(tbuffer, m_buffer, std::min(m_size, size)); - - Release(); - - m_buffer = tbuffer; - m_size = size; - - return S_OK; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexWIC.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexWIC.cpp deleted file mode 100644 index fc1ebac..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTexWIC.cpp +++ /dev/null @@ -1,1619 +0,0 @@ -//------------------------------------------------------------------------------------- -// DirectXTexWIC.cpp -// -// DirectX Texture Library - WIC-based file reader/writer -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//------------------------------------------------------------------------------------- - -#include "DirectXTexP.h" - -using namespace DirectX; -using namespace DirectX::Internal; -using Microsoft::WRL::ComPtr; - -namespace -{ - //------------------------------------------------------------------------------------- - // WIC Pixel Format nearest conversion table - //------------------------------------------------------------------------------------- - struct WICConvert - { - const GUID& source; - const GUID& target; - TEX_ALPHA_MODE alphaMode; - }; - - constexpr WICConvert g_WICConvert[] = - { - // Directly support the formats listed in XnaTexUtil::g_WICFormats, so no conversion required - // Note target GUID in this conversion table must be one of those directly supported formats. - - { GUID_WICPixelFormat1bppIndexed, GUID_WICPixelFormat32bppRGBA, TEX_ALPHA_MODE_UNKNOWN }, // DXGI_FORMAT_R8G8B8A8_UNORM - { GUID_WICPixelFormat2bppIndexed, GUID_WICPixelFormat32bppRGBA, TEX_ALPHA_MODE_UNKNOWN }, // DXGI_FORMAT_R8G8B8A8_UNORM - { GUID_WICPixelFormat4bppIndexed, GUID_WICPixelFormat32bppRGBA, TEX_ALPHA_MODE_UNKNOWN }, // DXGI_FORMAT_R8G8B8A8_UNORM - { GUID_WICPixelFormat8bppIndexed, GUID_WICPixelFormat32bppRGBA, TEX_ALPHA_MODE_UNKNOWN }, // DXGI_FORMAT_R8G8B8A8_UNORM - - { GUID_WICPixelFormat2bppGray, GUID_WICPixelFormat8bppGray, TEX_ALPHA_MODE_UNKNOWN }, // DXGI_FORMAT_R8_UNORM - { GUID_WICPixelFormat4bppGray, GUID_WICPixelFormat8bppGray, TEX_ALPHA_MODE_UNKNOWN }, // DXGI_FORMAT_R8_UNORM - - { GUID_WICPixelFormat16bppGrayFixedPoint, GUID_WICPixelFormat16bppGrayHalf, TEX_ALPHA_MODE_UNKNOWN }, // DXGI_FORMAT_R16_FLOAT - { GUID_WICPixelFormat32bppGrayFixedPoint, GUID_WICPixelFormat32bppGrayFloat, TEX_ALPHA_MODE_UNKNOWN }, // DXGI_FORMAT_R32_FLOAT - - { GUID_WICPixelFormat16bppBGR555, GUID_WICPixelFormat16bppBGRA5551, TEX_ALPHA_MODE_OPAQUE }, // DXGI_FORMAT_B5G5R5A1_UNORM - { GUID_WICPixelFormat32bppBGR101010, GUID_WICPixelFormat32bppRGBA1010102, TEX_ALPHA_MODE_OPAQUE }, // DXGI_FORMAT_R10G10B10A2_UNORM - - { GUID_WICPixelFormat24bppBGR, GUID_WICPixelFormat32bppRGBA, TEX_ALPHA_MODE_OPAQUE }, // DXGI_FORMAT_R8G8B8A8_UNORM - { GUID_WICPixelFormat24bppRGB, GUID_WICPixelFormat32bppRGBA, TEX_ALPHA_MODE_OPAQUE }, // DXGI_FORMAT_R8G8B8A8_UNORM - { GUID_WICPixelFormat32bppPBGRA, GUID_WICPixelFormat32bppRGBA, TEX_ALPHA_MODE_UNKNOWN }, // DXGI_FORMAT_R8G8B8A8_UNORM - { GUID_WICPixelFormat32bppPRGBA, GUID_WICPixelFormat32bppRGBA, TEX_ALPHA_MODE_UNKNOWN }, // DXGI_FORMAT_R8G8B8A8_UNORM - - { GUID_WICPixelFormat48bppRGB, GUID_WICPixelFormat64bppRGBA, TEX_ALPHA_MODE_OPAQUE }, // DXGI_FORMAT_R16G16B16A16_UNORM - { GUID_WICPixelFormat48bppBGR, GUID_WICPixelFormat64bppRGBA, TEX_ALPHA_MODE_OPAQUE }, // DXGI_FORMAT_R16G16B16A16_UNORM - { GUID_WICPixelFormat64bppBGRA, GUID_WICPixelFormat64bppRGBA, TEX_ALPHA_MODE_UNKNOWN }, // DXGI_FORMAT_R16G16B16A16_UNORM - { GUID_WICPixelFormat64bppPRGBA, GUID_WICPixelFormat64bppRGBA, TEX_ALPHA_MODE_UNKNOWN }, // DXGI_FORMAT_R16G16B16A16_UNORM - { GUID_WICPixelFormat64bppPBGRA, GUID_WICPixelFormat64bppRGBA, TEX_ALPHA_MODE_UNKNOWN }, // DXGI_FORMAT_R16G16B16A16_UNORM - - { GUID_WICPixelFormat48bppRGBFixedPoint, GUID_WICPixelFormat64bppRGBAHalf, TEX_ALPHA_MODE_OPAQUE }, // DXGI_FORMAT_R16G16B16A16_FLOAT - { GUID_WICPixelFormat48bppBGRFixedPoint, GUID_WICPixelFormat64bppRGBAHalf, TEX_ALPHA_MODE_OPAQUE }, // DXGI_FORMAT_R16G16B16A16_FLOAT - { GUID_WICPixelFormat64bppRGBAFixedPoint, GUID_WICPixelFormat64bppRGBAHalf, TEX_ALPHA_MODE_UNKNOWN }, // DXGI_FORMAT_R16G16B16A16_FLOAT - { GUID_WICPixelFormat64bppBGRAFixedPoint, GUID_WICPixelFormat64bppRGBAHalf, TEX_ALPHA_MODE_UNKNOWN }, // DXGI_FORMAT_R16G16B16A16_FLOAT - { GUID_WICPixelFormat64bppRGBFixedPoint, GUID_WICPixelFormat64bppRGBAHalf, TEX_ALPHA_MODE_OPAQUE }, // DXGI_FORMAT_R16G16B16A16_FLOAT - { GUID_WICPixelFormat64bppRGBHalf, GUID_WICPixelFormat64bppRGBAHalf, TEX_ALPHA_MODE_OPAQUE }, // DXGI_FORMAT_R16G16B16A16_FLOAT - { GUID_WICPixelFormat48bppRGBHalf, GUID_WICPixelFormat64bppRGBAHalf, TEX_ALPHA_MODE_OPAQUE }, // DXGI_FORMAT_R16G16B16A16_FLOAT - - { GUID_WICPixelFormat128bppPRGBAFloat, GUID_WICPixelFormat128bppRGBAFloat, TEX_ALPHA_MODE_UNKNOWN }, // DXGI_FORMAT_R32G32B32A32_FLOAT - { GUID_WICPixelFormat128bppRGBFloat, GUID_WICPixelFormat128bppRGBAFloat, TEX_ALPHA_MODE_OPAQUE }, // DXGI_FORMAT_R32G32B32A32_FLOAT - { GUID_WICPixelFormat128bppRGBAFixedPoint, GUID_WICPixelFormat128bppRGBAFloat, TEX_ALPHA_MODE_UNKNOWN }, // DXGI_FORMAT_R32G32B32A32_FLOAT - { GUID_WICPixelFormat128bppRGBFixedPoint, GUID_WICPixelFormat128bppRGBAFloat, TEX_ALPHA_MODE_OPAQUE }, // DXGI_FORMAT_R32G32B32A32_FLOAT - { GUID_WICPixelFormat32bppRGBE, GUID_WICPixelFormat128bppRGBAFloat, TEX_ALPHA_MODE_OPAQUE }, // DXGI_FORMAT_R32G32B32A32_FLOAT - - { GUID_WICPixelFormat32bppCMYK, GUID_WICPixelFormat32bppRGBA, TEX_ALPHA_MODE_OPAQUE }, // DXGI_FORMAT_R8G8B8A8_UNORM - { GUID_WICPixelFormat64bppCMYK, GUID_WICPixelFormat64bppRGBA, TEX_ALPHA_MODE_OPAQUE }, // DXGI_FORMAT_R16G16B16A16_UNORM - { GUID_WICPixelFormat40bppCMYKAlpha, GUID_WICPixelFormat32bppRGBA, TEX_ALPHA_MODE_UNKNOWN }, // DXGI_FORMAT_R8G8B8A8_UNORM - { GUID_WICPixelFormat80bppCMYKAlpha, GUID_WICPixelFormat64bppRGBA, TEX_ALPHA_MODE_UNKNOWN }, // DXGI_FORMAT_R16G16B16A16_UNORM - - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE) - { GUID_WICPixelFormat32bppRGB, GUID_WICPixelFormat32bppRGBA, TEX_ALPHA_MODE_OPAQUE }, // DXGI_FORMAT_R8G8B8A8_UNORM - { GUID_WICPixelFormat64bppRGB, GUID_WICPixelFormat64bppRGBA, TEX_ALPHA_MODE_OPAQUE }, // DXGI_FORMAT_R16G16B16A16_UNORM - { GUID_WICPixelFormat64bppPRGBAHalf, GUID_WICPixelFormat64bppRGBAHalf, TEX_ALPHA_MODE_UNKNOWN }, // DXGI_FORMAT_R16G16B16A16_FLOAT - #endif - - // We don't support n-channel formats - }; - - //------------------------------------------------------------------------------------- - // Returns the DXGI format and optionally the WIC pixel GUID to convert to - //------------------------------------------------------------------------------------- - DXGI_FORMAT DetermineFormat( - _In_ const WICPixelFormatGUID& pixelFormat, - WIC_FLAGS flags, - bool iswic2, - _Out_opt_ WICPixelFormatGUID* pConvert, - _Out_ TEX_ALPHA_MODE* alphaMode) noexcept - { - if (pConvert) - memset(pConvert, 0, sizeof(WICPixelFormatGUID)); - - *alphaMode = TEX_ALPHA_MODE_UNKNOWN; - - DXGI_FORMAT format = WICToDXGI(pixelFormat); - - if (format == DXGI_FORMAT_UNKNOWN) - { - if (memcmp(&GUID_WICPixelFormat96bppRGBFixedPoint, &pixelFormat, sizeof(WICPixelFormatGUID)) == 0) - { - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE) - if (iswic2) - { - if (pConvert) - memcpy_s(pConvert, sizeof(WICPixelFormatGUID), &GUID_WICPixelFormat96bppRGBFloat, sizeof(GUID)); - format = DXGI_FORMAT_R32G32B32_FLOAT; - } - else - #else - UNREFERENCED_PARAMETER(iswic2); - #endif - { - if (pConvert) - memcpy_s(pConvert, sizeof(WICPixelFormatGUID), &GUID_WICPixelFormat128bppRGBAFloat, sizeof(GUID)); - format = DXGI_FORMAT_R32G32B32A32_FLOAT; - *alphaMode = TEX_ALPHA_MODE_OPAQUE; - } - } - else - { - for (size_t i = 0; i < std::size(g_WICConvert); ++i) - { - if (memcmp(&g_WICConvert[i].source, &pixelFormat, sizeof(WICPixelFormatGUID)) == 0) - { - if (pConvert) - memcpy_s(pConvert, sizeof(WICPixelFormatGUID), &g_WICConvert[i].target, sizeof(GUID)); - - format = WICToDXGI(g_WICConvert[i].target); - assert(format != DXGI_FORMAT_UNKNOWN); - *alphaMode = g_WICConvert[i].alphaMode; - break; - } - } - } - } - - // Handle special cases based on flags - switch (format) - { - case DXGI_FORMAT_B8G8R8A8_UNORM: // BGRA - case DXGI_FORMAT_B8G8R8X8_UNORM: // BGRX - if (flags & WIC_FLAGS_FORCE_RGB) - { - format = DXGI_FORMAT_R8G8B8A8_UNORM; - if (pConvert) - memcpy_s(pConvert, sizeof(WICPixelFormatGUID), &GUID_WICPixelFormat32bppRGBA, sizeof(GUID)); - } - break; - - case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: - if (flags & WIC_FLAGS_NO_X2_BIAS) - { - format = DXGI_FORMAT_R10G10B10A2_UNORM; - if (pConvert) - memcpy_s(pConvert, sizeof(WICPixelFormatGUID), &GUID_WICPixelFormat32bppRGBA1010102, sizeof(GUID)); - } - break; - - case DXGI_FORMAT_B5G5R5A1_UNORM: - case DXGI_FORMAT_B5G6R5_UNORM: - if (flags & WIC_FLAGS_NO_16BPP) - { - format = DXGI_FORMAT_R8G8B8A8_UNORM; - if (pConvert) - memcpy_s(pConvert, sizeof(WICPixelFormatGUID), &GUID_WICPixelFormat32bppRGBA, sizeof(GUID)); - } - break; - - case DXGI_FORMAT_R1_UNORM: - if (!(flags & WIC_FLAGS_ALLOW_MONO)) - { - // By default we want to promote a black & white to gresycale since R1 is not a generally supported D3D format - format = DXGI_FORMAT_R8_UNORM; - if (pConvert) - memcpy_s(pConvert, sizeof(WICPixelFormatGUID), &GUID_WICPixelFormat8bppGray, sizeof(GUID)); - } - break; - - default: - break; - } - - return format; - } - - - //------------------------------------------------------------------------------------- - // IStream over a Blob for WIC in-memory write functions - //------------------------------------------------------------------------------------- - class MemoryStreamOnBlob : public IStream - { - MemoryStreamOnBlob(Blob& blob) noexcept : - mBlob(blob), - m_streamPosition(0), - m_streamEOF(0), - mRefCount(1) - { - assert(mBlob.GetBufferPointer() && mBlob.GetBufferSize() > 0); - } - - public: - virtual ~MemoryStreamOnBlob() = default; - - MemoryStreamOnBlob(MemoryStreamOnBlob&&) = delete; - MemoryStreamOnBlob& operator= (MemoryStreamOnBlob&&) = delete; - - MemoryStreamOnBlob(MemoryStreamOnBlob const&) = delete; - MemoryStreamOnBlob& operator= (MemoryStreamOnBlob const&) = delete; - - // IUnknown - HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void** ppvObject) override - { - if (iid == __uuidof(IUnknown) - || iid == __uuidof(IStream) - || iid == __uuidof(ISequentialStream)) - { - *ppvObject = static_cast(this); - AddRef(); - return S_OK; - } - else - return E_NOINTERFACE; - } - - ULONG STDMETHODCALLTYPE AddRef() override - { - return InterlockedIncrement(&mRefCount); - } - - ULONG STDMETHODCALLTYPE Release() override - { - const ULONG res = InterlockedDecrement(&mRefCount); - if (res == 0) - { - delete this; - } - return res; - } - - // ISequentialStream - HRESULT STDMETHODCALLTYPE Read(void* pv, ULONG cb, ULONG* pcbRead) override - { - size_t maxRead = m_streamEOF - m_streamPosition; - auto ptr = static_cast(mBlob.GetBufferPointer()); - if (cb > maxRead) - { - const uint64_t pos = uint64_t(m_streamPosition) + uint64_t(maxRead); - if (pos > UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - memcpy(pv, &ptr[m_streamPosition], maxRead); - - m_streamPosition = static_cast(pos); - - if (pcbRead) - { - *pcbRead = static_cast(maxRead); - } - return E_BOUNDS; - } - else - { - const uint64_t pos = uint64_t(m_streamPosition) + uint64_t(cb); - if (pos > UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - memcpy(pv, &ptr[m_streamPosition], cb); - - m_streamPosition = static_cast(pos); - - if (pcbRead) - { - *pcbRead = cb; - } - return S_OK; - } - } - - HRESULT STDMETHODCALLTYPE Write(void const* pv, ULONG cb, ULONG* pcbWritten) override - { - const size_t blobSize = mBlob.GetBufferSize(); - const size_t spaceAvailable = blobSize - m_streamPosition; - size_t growAmount = cb; - - if (spaceAvailable > 0) - { - if (spaceAvailable >= growAmount) - { - growAmount = 0; - } - else - { - growAmount -= spaceAvailable; - } - } - - if (growAmount > 0) - { - uint64_t newSize = uint64_t(blobSize); - const uint64_t targetSize = uint64_t(blobSize) + growAmount; - HRESULT hr = ComputeGrowSize(newSize, targetSize); - if (FAILED(hr)) - return hr; - - hr = mBlob.Resize(static_cast(newSize)); - if (FAILED(hr)) - return hr; - } - - const uint64_t pos = uint64_t(m_streamPosition) + uint64_t(cb); - if (pos > UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - auto ptr = static_cast(mBlob.GetBufferPointer()); - memcpy(&ptr[m_streamPosition], pv, cb); - - m_streamPosition = static_cast(pos); - m_streamEOF = std::max(m_streamEOF, m_streamPosition); - - if (pcbWritten) - { - *pcbWritten = cb; - } - return S_OK; - } - - // IStream - HRESULT STDMETHODCALLTYPE SetSize(ULARGE_INTEGER size) override - { - if (size.HighPart > 0) - return E_OUTOFMEMORY; - - const size_t blobSize = mBlob.GetBufferSize(); - - if (blobSize >= size.LowPart) - { - auto ptr = static_cast(mBlob.GetBufferPointer()); - if (m_streamEOF < size.LowPart) - { - memset(&ptr[m_streamEOF], 0, size.LowPart - m_streamEOF); - } - - m_streamEOF = static_cast(size.LowPart); - } - else - { - uint64_t newSize = uint64_t(blobSize); - const uint64_t targetSize = uint64_t(size.QuadPart); - HRESULT hr = ComputeGrowSize(newSize, targetSize); - if (FAILED(hr)) - return hr; - - hr = mBlob.Resize(static_cast(newSize)); - if (FAILED(hr)) - return hr; - - auto ptr = static_cast(mBlob.GetBufferPointer()); - if (m_streamEOF < size.LowPart) - { - memset(&ptr[m_streamEOF], 0, size.LowPart - m_streamEOF); - } - - m_streamEOF = static_cast(size.LowPart); - } - - if (m_streamPosition > m_streamEOF) - { - m_streamPosition = m_streamEOF; - } - - return S_OK; - } - - HRESULT STDMETHODCALLTYPE CopyTo(IStream*, ULARGE_INTEGER, ULARGE_INTEGER*, ULARGE_INTEGER*) override - { - return E_NOTIMPL; - } - - HRESULT STDMETHODCALLTYPE Commit(DWORD) override - { - return E_NOTIMPL; - } - - HRESULT STDMETHODCALLTYPE Revert() override - { - return E_NOTIMPL; - } - - HRESULT STDMETHODCALLTYPE LockRegion(ULARGE_INTEGER, ULARGE_INTEGER, DWORD) override - { - return E_NOTIMPL; - } - - HRESULT STDMETHODCALLTYPE UnlockRegion(ULARGE_INTEGER, ULARGE_INTEGER, DWORD) override - { - return E_NOTIMPL; - } - - HRESULT STDMETHODCALLTYPE Clone(IStream**) override - { - return E_NOTIMPL; - } - - HRESULT STDMETHODCALLTYPE Seek(LARGE_INTEGER liDistanceToMove, DWORD dwOrigin, ULARGE_INTEGER* lpNewFilePointer) override - { - LONGLONG newPosition = 0; - - switch (dwOrigin) - { - case STREAM_SEEK_SET: - newPosition = liDistanceToMove.QuadPart; - break; - - case STREAM_SEEK_CUR: - newPosition = static_cast(m_streamPosition) + liDistanceToMove.QuadPart; - break; - - case STREAM_SEEK_END: - newPosition = static_cast(m_streamEOF) + liDistanceToMove.QuadPart; - break; - - default: - return STG_E_INVALIDFUNCTION; - } - - HRESULT result = S_OK; - - if (newPosition > static_cast(m_streamEOF)) - { - m_streamPosition = m_streamEOF; - result = E_BOUNDS; - } - else if (newPosition < 0) - { - m_streamPosition = 0; - result = E_BOUNDS; - } - else - { - m_streamPosition = static_cast(newPosition); - } - - if (lpNewFilePointer) - { - lpNewFilePointer->QuadPart = static_cast(m_streamPosition); - } - - return result; - } - - HRESULT STDMETHODCALLTYPE Stat(STATSTG* pStatstg, DWORD) override - { - if (!pStatstg) - return E_INVALIDARG; - pStatstg->cbSize.QuadPart = static_cast(m_streamEOF); - return S_OK; - } - - HRESULT Finialize() noexcept - { - if (mRefCount > 1) - return E_FAIL; - - return mBlob.Trim(m_streamEOF); - } - - static HRESULT CreateMemoryStream(_Outptr_ MemoryStreamOnBlob** stream, Blob& blob) noexcept - { - if (!stream) - return E_INVALIDARG; - - *stream = nullptr; - - auto ptr = new (std::nothrow) MemoryStreamOnBlob(blob); - if (!ptr) - return E_OUTOFMEMORY; - - *stream = ptr; - - return S_OK; - } - - private: - Blob& mBlob; - size_t m_streamPosition; - size_t m_streamEOF; - ULONG mRefCount; - - static HRESULT ComputeGrowSize(uint64_t& newSize, const uint64_t targetSize) noexcept - { - // We grow by doubling until we hit 256MB, then we add 16MB at a time. - while (newSize < targetSize) - { - if (newSize < (256 * 1024 * 1024)) - { - newSize <<= 1; - } - else - { - newSize += 16 * 1024 * 1024; - } - if (newSize > UINT32_MAX) - return E_OUTOFMEMORY; - } - - return S_OK; - } - }; - - //------------------------------------------------------------------------------------- - // Determines metadata for image - //------------------------------------------------------------------------------------- - HRESULT DecodeMetadata( - WIC_FLAGS flags, - bool iswic2, - _In_ IWICBitmapDecoder *decoder, - _In_ IWICBitmapFrameDecode *frame, - _Out_ TexMetadata& metadata, - _Out_opt_ WICPixelFormatGUID* pConvert, - _In_opt_ std::function getMQR) - { - if (!decoder || !frame) - return E_POINTER; - - memset(&metadata, 0, sizeof(TexMetadata)); - metadata.depth = 1; - metadata.mipLevels = 1; - metadata.dimension = TEX_DIMENSION_TEXTURE2D; - - UINT w, h; - HRESULT hr = frame->GetSize(&w, &h); - if (FAILED(hr)) - return hr; - - metadata.width = w; - metadata.height = h; - - if (flags & WIC_FLAGS_ALL_FRAMES) - { - UINT fcount; - hr = decoder->GetFrameCount(&fcount); - if (FAILED(hr)) - return hr; - - metadata.arraySize = fcount; - } - else - metadata.arraySize = 1; - - WICPixelFormatGUID pixelFormat; - hr = frame->GetPixelFormat(&pixelFormat); - if (FAILED(hr)) - return hr; - - TEX_ALPHA_MODE alphaMode; - metadata.format = DetermineFormat(pixelFormat, flags, iswic2, pConvert, &alphaMode); - if (metadata.format == DXGI_FORMAT_UNKNOWN) - return HRESULT_E_NOT_SUPPORTED; - - metadata.SetAlphaMode(alphaMode); - - if (!(flags & WIC_FLAGS_IGNORE_SRGB)) - { - GUID containerFormat; - hr = decoder->GetContainerFormat(&containerFormat); - if (FAILED(hr)) - return hr; - - ComPtr metareader; - hr = frame->GetMetadataQueryReader(metareader.GetAddressOf()); - if (SUCCEEDED(hr)) - { - // Check for sRGB colorspace metadata - bool sRGB = false; - - PROPVARIANT value; - PropVariantInit(&value); - - // Check for colorspace chunks - if (memcmp(&containerFormat, &GUID_ContainerFormatPng, sizeof(GUID)) == 0) - { - if (SUCCEEDED(metareader->GetMetadataByName(L"/sRGB/RenderingIntent", &value)) && value.vt == VT_UI1) - { - sRGB = true; - } - else if (SUCCEEDED(metareader->GetMetadataByName(L"/gAMA/ImageGamma", &value)) && value.vt == VT_UI4) - { - sRGB = (value.uintVal == 45455); - } - else - { - sRGB = (flags & WIC_FLAGS_DEFAULT_SRGB) != 0; - } - } - #if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX) - else if (memcmp(&containerFormat, &GUID_ContainerFormatJpeg, sizeof(GUID)) == 0) - { - if (SUCCEEDED(metareader->GetMetadataByName(L"/app1/ifd/exif/{ushort=40961}", &value)) && value.vt == VT_UI2) - { - sRGB = (value.uiVal == 1); - } - else - { - sRGB = (flags & WIC_FLAGS_DEFAULT_SRGB) != 0; - } - } - else if (memcmp(&containerFormat, &GUID_ContainerFormatTiff, sizeof(GUID)) == 0) - { - if (SUCCEEDED(metareader->GetMetadataByName(L"/ifd/exif/{ushort=40961}", &value)) && value.vt == VT_UI2) - { - sRGB = (value.uiVal == 1); - } - else - { - sRGB = (flags & WIC_FLAGS_DEFAULT_SRGB) != 0; - } - } - #else - else if (SUCCEEDED(metareader->GetMetadataByName(L"System.Image.ColorSpace", &value)) && value.vt == VT_UI2) - { - sRGB = (value.uiVal == 1); - } - else - { - sRGB = (flags & WIC_FLAGS_DEFAULT_SRGB) != 0; - } - #endif - - std::ignore = PropVariantClear(&value); - - if (sRGB) - metadata.format = MakeSRGB(metadata.format); - } - else if (hr == WINCODEC_ERR_UNSUPPORTEDOPERATION) - { - // Some formats just don't support metadata (BMP, ICO, etc.), so ignore this failure - hr = S_OK; - } - } - - if (getMQR) - { - ComPtr metareader; - if (SUCCEEDED(frame->GetMetadataQueryReader(metareader.GetAddressOf()))) - { - getMQR(metareader.Get()); - } - } - - return hr; - } - - - //------------------------------------------------------------------------------------- - // Decodes a single frame - //------------------------------------------------------------------------------------- - HRESULT DecodeSingleFrame( - WIC_FLAGS flags, - const TexMetadata& metadata, - const WICPixelFormatGUID& convertGUID, - _In_ IWICBitmapFrameDecode *frame, - _Inout_ ScratchImage& image) - { - if (!frame) - return E_POINTER; - - HRESULT hr = image.Initialize2D(metadata.format, metadata.width, metadata.height, 1, 1); - if (FAILED(hr)) - return hr; - - const Image *img = image.GetImage(0, 0, 0); - if (!img) - return E_POINTER; - - bool iswic2 = false; - auto pWIC = GetWICFactory(iswic2); - if (!pWIC) - return E_NOINTERFACE; - - if (img->rowPitch > UINT32_MAX || img->slicePitch > UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - if (memcmp(&convertGUID, &GUID_NULL, sizeof(GUID)) == 0) - { - hr = frame->CopyPixels(nullptr, static_cast(img->rowPitch), static_cast(img->slicePitch), img->pixels); - if (FAILED(hr)) - return hr; - } - else - { - ComPtr FC; - hr = pWIC->CreateFormatConverter(FC.GetAddressOf()); - if (FAILED(hr)) - return hr; - - WICPixelFormatGUID pixelFormat; - hr = frame->GetPixelFormat(&pixelFormat); - if (FAILED(hr)) - return hr; - - BOOL canConvert = FALSE; - hr = FC->CanConvert(pixelFormat, convertGUID, &canConvert); - if (FAILED(hr) || !canConvert) - { - return E_UNEXPECTED; - } - - hr = FC->Initialize(frame, convertGUID, GetWICDither(flags), nullptr, - 0, WICBitmapPaletteTypeMedianCut); - if (FAILED(hr)) - return hr; - - hr = FC->CopyPixels(nullptr, static_cast(img->rowPitch), static_cast(img->slicePitch), img->pixels); - if (FAILED(hr)) - return hr; - } - - return S_OK; - } - - - //------------------------------------------------------------------------------------- - // Decodes an image array, resizing/format converting as needed - //------------------------------------------------------------------------------------- - HRESULT DecodeMultiframe( - WIC_FLAGS flags, - const TexMetadata& metadata, - _In_ IWICBitmapDecoder *decoder, - _Inout_ ScratchImage& image) - { - if (!decoder) - return E_POINTER; - - HRESULT hr = image.Initialize2D(metadata.format, metadata.width, metadata.height, metadata.arraySize, 1); - if (FAILED(hr)) - return hr; - - bool iswic2 = false; - auto pWIC = GetWICFactory(iswic2); - if (!pWIC) - return E_NOINTERFACE; - - WICPixelFormatGUID sourceGUID; - if (!DXGIToWIC(metadata.format, sourceGUID)) - return E_FAIL; - - for (size_t index = 0; index < metadata.arraySize; ++index) - { - const Image* img = image.GetImage(0, index, 0); - if (!img) - return E_POINTER; - - if (img->rowPitch > UINT32_MAX || img->slicePitch > UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - ComPtr frame; - hr = decoder->GetFrame(static_cast(index), frame.GetAddressOf()); - if (FAILED(hr)) - return hr; - - WICPixelFormatGUID pfGuid; - hr = frame->GetPixelFormat(&pfGuid); - if (FAILED(hr)) - return hr; - - UINT w, h; - hr = frame->GetSize(&w, &h); - if (FAILED(hr)) - return hr; - - if (w == metadata.width && h == metadata.height) - { - // This frame does not need resized - if (memcmp(&pfGuid, &sourceGUID, sizeof(WICPixelFormatGUID)) == 0) - { - hr = frame->CopyPixels(nullptr, static_cast(img->rowPitch), static_cast(img->slicePitch), img->pixels); - if (FAILED(hr)) - return hr; - } - else - { - ComPtr FC; - hr = pWIC->CreateFormatConverter(FC.GetAddressOf()); - if (FAILED(hr)) - return hr; - - BOOL canConvert = FALSE; - hr = FC->CanConvert(pfGuid, sourceGUID, &canConvert); - if (FAILED(hr) || !canConvert) - { - return E_UNEXPECTED; - } - - hr = FC->Initialize(frame.Get(), sourceGUID, GetWICDither(flags), nullptr, - 0, WICBitmapPaletteTypeMedianCut); - if (FAILED(hr)) - return hr; - - hr = FC->CopyPixels(nullptr, static_cast(img->rowPitch), static_cast(img->slicePitch), img->pixels); - if (FAILED(hr)) - return hr; - } - } - else - { - // This frame needs resizing - ComPtr scaler; - hr = pWIC->CreateBitmapScaler(scaler.GetAddressOf()); - if (FAILED(hr)) - return hr; - - hr = scaler->Initialize(frame.Get(), - static_cast(metadata.width), static_cast(metadata.height), - GetWICInterp(flags)); - if (FAILED(hr)) - return hr; - - WICPixelFormatGUID pfScaler; - hr = scaler->GetPixelFormat(&pfScaler); - if (FAILED(hr)) - return hr; - - if (memcmp(&pfScaler, &sourceGUID, sizeof(WICPixelFormatGUID)) == 0) - { - hr = scaler->CopyPixels(nullptr, static_cast(img->rowPitch), static_cast(img->slicePitch), img->pixels); - if (FAILED(hr)) - return hr; - } - else - { - // The WIC bitmap scaler is free to return a different pixel format than the source image, so here we - // convert it to our desired format - ComPtr FC; - hr = pWIC->CreateFormatConverter(FC.GetAddressOf()); - if (FAILED(hr)) - return hr; - - BOOL canConvert = FALSE; - hr = FC->CanConvert(pfScaler, sourceGUID, &canConvert); - if (FAILED(hr) || !canConvert) - { - return E_UNEXPECTED; - } - - hr = FC->Initialize(scaler.Get(), sourceGUID, GetWICDither(flags), nullptr, - 0, WICBitmapPaletteTypeMedianCut); - if (FAILED(hr)) - return hr; - - hr = FC->CopyPixels(nullptr, static_cast(img->rowPitch), static_cast(img->slicePitch), img->pixels); - if (FAILED(hr)) - return hr; - } - } - } - - return S_OK; - } - - - //------------------------------------------------------------------------------------- - // Encodes image metadata - //------------------------------------------------------------------------------------- - HRESULT EncodeMetadata( - WIC_FLAGS flags, - _In_ IWICBitmapFrameEncode* frame, - const GUID& containerFormat, - DXGI_FORMAT format) - { - if (!frame) - return E_POINTER; - - ComPtr metawriter; - HRESULT hr = frame->GetMetadataQueryWriter(metawriter.GetAddressOf()); - if (SUCCEEDED(hr)) - { - PROPVARIANT value; - PropVariantInit(&value); - - const bool sRGB = ((flags & WIC_FLAGS_FORCE_LINEAR) == 0) && ((flags & WIC_FLAGS_FORCE_SRGB) != 0 || IsSRGB(format)); - - value.vt = VT_LPSTR; - value.pszVal = const_cast("DirectXTex"); - - if (memcmp(&containerFormat, &GUID_ContainerFormatPng, sizeof(GUID)) == 0) - { - // Set Software name - std::ignore = metawriter->SetMetadataByName(L"/tEXt/{str=Software}", &value); - - // Set sRGB chunk - if (sRGB) - { - value.vt = VT_UI1; - value.bVal = 0; - std::ignore = metawriter->SetMetadataByName(L"/sRGB/RenderingIntent", &value); - } - else - { - // add gAMA chunk with gamma 1.0 - value.vt = VT_UI4; - value.uintVal = 100000; // gama value * 100,000 -- i.e. gamma 1.0 - std::ignore = metawriter->SetMetadataByName(L"/gAMA/ImageGamma", &value); - - // remove sRGB chunk which is added by default. - std::ignore = metawriter->RemoveMetadataByName(L"/sRGB/RenderingIntent"); - } - } - #if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX) - else if (memcmp(&containerFormat, &GUID_ContainerFormatJpeg, sizeof(GUID)) == 0) - { - // Set Software name - std::ignore = metawriter->SetMetadataByName(L"/app1/ifd/{ushort=305}", &value); - - if (sRGB) - { - // Set EXIF Colorspace of sRGB - value.vt = VT_UI2; - value.uiVal = 1; - std::ignore = metawriter->SetMetadataByName(L"/app1/ifd/exif/{ushort=40961}", &value); - } - } - else if (memcmp(&containerFormat, &GUID_ContainerFormatTiff, sizeof(GUID)) == 0) - { - // Set Software name - std::ignore = metawriter->SetMetadataByName(L"/ifd/{ushort=305}", &value); - - if (sRGB) - { - // Set EXIF Colorspace of sRGB - value.vt = VT_UI2; - value.uiVal = 1; - std::ignore = metawriter->SetMetadataByName(L"/ifd/exif/{ushort=40961}", &value); - } - } - #else - else - { - // Set Software name - std::ignore = metawriter->SetMetadataByName(L"System.ApplicationName", &value); - - if (sRGB) - { - // Set EXIF Colorspace of sRGB - value.vt = VT_UI2; - value.uiVal = 1; - std::ignore = metawriter->SetMetadataByName(L"System.Image.ColorSpace", &value); - } - } - #endif - } - else if (hr == WINCODEC_ERR_UNSUPPORTEDOPERATION) - { - // Some formats just don't support metadata (BMP, ICO, etc.), so ignore this failure - hr = S_OK; - } - - return hr; - } - - - //------------------------------------------------------------------------------------- - // Encodes a single frame - //------------------------------------------------------------------------------------- - HRESULT EncodeImage( - const Image& image, - WIC_FLAGS flags, - _In_ REFGUID containerFormat, - _In_ IWICBitmapFrameEncode* frame, - _In_opt_ IPropertyBag2* props, - _In_opt_ const GUID* targetFormat) - { - if (!frame) - return E_INVALIDARG; - - if (!image.pixels) - return E_POINTER; - - WICPixelFormatGUID pfGuid; - if (!DXGIToWIC(image.format, pfGuid)) - return HRESULT_E_NOT_SUPPORTED; - - HRESULT hr = frame->Initialize(props); - if (FAILED(hr)) - return hr; - - if ((image.width > UINT32_MAX) || (image.height > UINT32_MAX)) - return E_INVALIDARG; - - if (image.rowPitch > UINT32_MAX || image.slicePitch > UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - hr = frame->SetSize(static_cast(image.width), static_cast(image.height)); - if (FAILED(hr)) - return hr; - - hr = frame->SetResolution(72, 72); - if (FAILED(hr)) - return hr; - - WICPixelFormatGUID targetGuid = (targetFormat) ? (*targetFormat) : pfGuid; - hr = frame->SetPixelFormat(&targetGuid); - if (FAILED(hr)) - return hr; - - if (targetFormat && memcmp(targetFormat, &targetGuid, sizeof(WICPixelFormatGUID)) != 0) - { - // Requested output pixel format is not supported by the WIC codec - return E_FAIL; - } - - hr = EncodeMetadata(flags, frame, containerFormat, image.format); - if (FAILED(hr)) - return hr; - - if (memcmp(&targetGuid, &pfGuid, sizeof(WICPixelFormatGUID)) != 0) - { - // Conversion required to write - bool iswic2 = false; - auto pWIC = GetWICFactory(iswic2); - if (!pWIC) - return E_NOINTERFACE; - - ComPtr source; - hr = pWIC->CreateBitmapFromMemory(static_cast(image.width), static_cast(image.height), pfGuid, - static_cast(image.rowPitch), static_cast(image.slicePitch), - image.pixels, source.GetAddressOf()); - if (FAILED(hr)) - return hr; - - ComPtr FC; - hr = pWIC->CreateFormatConverter(FC.GetAddressOf()); - if (FAILED(hr)) - return hr; - - BOOL canConvert = FALSE; - hr = FC->CanConvert(pfGuid, targetGuid, &canConvert); - if (FAILED(hr) || !canConvert) - { - return E_UNEXPECTED; - } - - hr = FC->Initialize(source.Get(), targetGuid, GetWICDither(flags), nullptr, - 0, WICBitmapPaletteTypeMedianCut); - if (FAILED(hr)) - return hr; - - WICRect rect = { 0, 0, static_cast(image.width), static_cast(image.height) }; - hr = frame->WriteSource(FC.Get(), &rect); - if (FAILED(hr)) - return hr; - } - else - { - // No conversion required - hr = frame->WritePixels(static_cast(image.height), static_cast(image.rowPitch), static_cast(image.slicePitch), - reinterpret_cast(image.pixels)); - if (FAILED(hr)) - return hr; - } - - hr = frame->Commit(); - if (FAILED(hr)) - return hr; - - return S_OK; - } - - HRESULT EncodeSingleFrame( - const Image& image, - WIC_FLAGS flags, - _In_ REFGUID containerFormat, - _Inout_ IStream* stream, - _In_opt_ const GUID* targetFormat, - _In_opt_ std::function setCustomProps) - { - if (!stream) - return E_INVALIDARG; - - // Initialize WIC - bool iswic2 = false; - auto pWIC = GetWICFactory(iswic2); - if (!pWIC) - return E_NOINTERFACE; - - ComPtr encoder; - HRESULT hr = pWIC->CreateEncoder(containerFormat, nullptr, encoder.GetAddressOf()); - if (FAILED(hr)) - return hr; - - hr = encoder->Initialize(stream, WICBitmapEncoderNoCache); - if (FAILED(hr)) - return hr; - - ComPtr frame; - ComPtr props; - hr = encoder->CreateNewFrame(frame.GetAddressOf(), props.GetAddressOf()); - if (FAILED(hr)) - return hr; - - if (memcmp(&containerFormat, &GUID_ContainerFormatBmp, sizeof(WICPixelFormatGUID)) == 0 && iswic2) - { - // Opt-in to the WIC2 support for writing 32-bit Windows BMP files with an alpha channel - PROPBAG2 option = {}; - option.pstrName = const_cast(L"EnableV5Header32bppBGRA"); - - VARIANT varValue; - varValue.vt = VT_BOOL; - varValue.boolVal = VARIANT_TRUE; - std::ignore = props->Write(1, &option, &varValue); - } - - if (setCustomProps) - { - setCustomProps(props.Get()); - } - - hr = EncodeImage(image, flags, containerFormat, frame.Get(), props.Get(), targetFormat); - if (FAILED(hr)) - return hr; - - hr = encoder->Commit(); - if (FAILED(hr)) - return hr; - - return S_OK; - } - - - //------------------------------------------------------------------------------------- - // Encodes an image array - //------------------------------------------------------------------------------------- - HRESULT EncodeMultiframe( - _In_reads_(nimages) const Image* images, - size_t nimages, - WIC_FLAGS flags, - _In_ REFGUID containerFormat, - _Inout_ IStream* stream, - _In_opt_ const GUID* targetFormat, - _In_opt_ std::function setCustomProps) - { - if (!stream || nimages < 2) - return E_INVALIDARG; - - if (!images) - return E_POINTER; - - // Initialize WIC - bool iswic2 = false; - auto pWIC = GetWICFactory(iswic2); - if (!pWIC) - return E_NOINTERFACE; - - ComPtr encoder; - HRESULT hr = pWIC->CreateEncoder(containerFormat, nullptr, encoder.GetAddressOf()); - if (FAILED(hr)) - return hr; - - ComPtr einfo; - hr = encoder->GetEncoderInfo(einfo.GetAddressOf()); - if (FAILED(hr)) - return hr; - - BOOL mframe = FALSE; - hr = einfo->DoesSupportMultiframe(&mframe); - if (FAILED(hr)) - return hr; - - if (!mframe) - return HRESULT_E_NOT_SUPPORTED; - - hr = encoder->Initialize(stream, WICBitmapEncoderNoCache); - if (FAILED(hr)) - return hr; - - for (size_t index = 0; index < nimages; ++index) - { - ComPtr frame; - ComPtr props; - hr = encoder->CreateNewFrame(frame.GetAddressOf(), props.GetAddressOf()); - if (FAILED(hr)) - return hr; - - if (setCustomProps) - { - setCustomProps(props.Get()); - } - - hr = EncodeImage(images[index], flags, containerFormat, frame.Get(), props.Get(), targetFormat); - if (FAILED(hr)) - return hr; - } - - hr = encoder->Commit(); - if (FAILED(hr)) - return hr; - - return S_OK; - } -} - - -//===================================================================================== -// Entry-points -//===================================================================================== - -//------------------------------------------------------------------------------------- -// Obtain metadata from WIC-supported file in memory -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::GetMetadataFromWICMemory( - const void* pSource, - size_t size, - WIC_FLAGS flags, - TexMetadata& metadata, - std::function getMQR) -{ - if (!pSource || size == 0) - return E_INVALIDARG; - - if (size > UINT32_MAX) - return HRESULT_E_FILE_TOO_LARGE; - - bool iswic2 = false; - auto pWIC = GetWICFactory(iswic2); - if (!pWIC) - return E_NOINTERFACE; - - // Create input stream for memory - ComPtr stream; - HRESULT hr = pWIC->CreateStream(stream.GetAddressOf()); - if (FAILED(hr)) - return hr; - - hr = stream->InitializeFromMemory(static_cast(const_cast(pSource)), - static_cast(size)); - if (FAILED(hr)) - return hr; - - // Initialize WIC - ComPtr decoder; - hr = pWIC->CreateDecoderFromStream(stream.Get(), nullptr, WICDecodeMetadataCacheOnDemand, decoder.GetAddressOf()); - if (FAILED(hr)) - return hr; - - ComPtr frame; - hr = decoder->GetFrame(0, frame.GetAddressOf()); - if (FAILED(hr)) - return hr; - - // Get metadata - hr = DecodeMetadata(flags, iswic2, decoder.Get(), frame.Get(), metadata, nullptr, getMQR); - if (FAILED(hr)) - return hr; - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -// Obtain metadata from WIC-supported file on disk -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::GetMetadataFromWICFile( - const wchar_t* szFile, - WIC_FLAGS flags, - TexMetadata& metadata, - std::function getMQR) -{ - if (!szFile) - return E_INVALIDARG; - - bool iswic2 = false; - auto pWIC = GetWICFactory(iswic2); - if (!pWIC) - return E_NOINTERFACE; - - // Initialize WIC - ComPtr decoder; - HRESULT hr = pWIC->CreateDecoderFromFilename(szFile, nullptr, GENERIC_READ, WICDecodeMetadataCacheOnDemand, decoder.GetAddressOf()); - if (FAILED(hr)) - return hr; - - ComPtr frame; - hr = decoder->GetFrame(0, frame.GetAddressOf()); - if (FAILED(hr)) - return hr; - - // Get metadata - hr = DecodeMetadata(flags, iswic2, decoder.Get(), frame.Get(), metadata, nullptr, getMQR); - if (FAILED(hr)) - return hr; - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -// Load a WIC-supported file in memory -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::LoadFromWICMemory( - const void* pSource, - size_t size, - WIC_FLAGS flags, - TexMetadata* metadata, - ScratchImage& image, - std::function getMQR) -{ - if (!pSource || size == 0) - return E_INVALIDARG; - - if (size > UINT32_MAX) - return HRESULT_E_FILE_TOO_LARGE; - - bool iswic2 = false; - auto pWIC = GetWICFactory(iswic2); - if (!pWIC) - return E_NOINTERFACE; - - image.Release(); - - // Create input stream for memory - ComPtr stream; - HRESULT hr = pWIC->CreateStream(stream.GetAddressOf()); - if (FAILED(hr)) - return hr; - - hr = stream->InitializeFromMemory(static_cast(const_cast(pSource)), static_cast(size)); - if (FAILED(hr)) - return hr; - - // Initialize WIC - ComPtr decoder; - hr = pWIC->CreateDecoderFromStream(stream.Get(), nullptr, WICDecodeMetadataCacheOnDemand, decoder.GetAddressOf()); - if (FAILED(hr)) - return hr; - - ComPtr frame; - hr = decoder->GetFrame(0, frame.GetAddressOf()); - if (FAILED(hr)) - return hr; - - // Get metadata - TexMetadata mdata = {}; - WICPixelFormatGUID convertGUID = {}; - hr = DecodeMetadata(flags, iswic2, decoder.Get(), frame.Get(), mdata, &convertGUID, getMQR); - if (FAILED(hr)) - return hr; - - if ((mdata.arraySize > 1) && (flags & WIC_FLAGS_ALL_FRAMES)) - { - hr = DecodeMultiframe(flags, mdata, decoder.Get(), image); - } - else - { - hr = DecodeSingleFrame(flags, mdata, convertGUID, frame.Get(), image); - } - - if (FAILED(hr)) - { - image.Release(); - return hr; - } - - if (metadata) - memcpy(metadata, &mdata, sizeof(TexMetadata)); - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -// Load a WIC-supported file from disk -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::LoadFromWICFile( - const wchar_t* szFile, - WIC_FLAGS flags, - TexMetadata* metadata, - ScratchImage& image, - std::function getMQR) -{ - if (!szFile) - return E_INVALIDARG; - - bool iswic2 = false; - auto pWIC = GetWICFactory(iswic2); - if (!pWIC) - return E_NOINTERFACE; - - image.Release(); - - // Initialize WIC - ComPtr decoder; - HRESULT hr = pWIC->CreateDecoderFromFilename(szFile, nullptr, GENERIC_READ, WICDecodeMetadataCacheOnDemand, decoder.GetAddressOf()); - if (FAILED(hr)) - return hr; - - ComPtr frame; - hr = decoder->GetFrame(0, frame.GetAddressOf()); - if (FAILED(hr)) - return hr; - - // Get metadata - TexMetadata mdata = {}; - WICPixelFormatGUID convertGUID = {}; - hr = DecodeMetadata(flags, iswic2, decoder.Get(), frame.Get(), mdata, &convertGUID, getMQR); - if (FAILED(hr)) - return hr; - - if ((mdata.arraySize > 1) && (flags & WIC_FLAGS_ALL_FRAMES)) - { - hr = DecodeMultiframe(flags, mdata, decoder.Get(), image); - } - else - { - hr = DecodeSingleFrame(flags, mdata, convertGUID, frame.Get(), image); - } - - if (FAILED(hr)) - { - image.Release(); - return hr; - } - - if (metadata) - memcpy(metadata, &mdata, sizeof(TexMetadata)); - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -// Save a WIC-supported file to memory -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::SaveToWICMemory( - const Image& image, - WIC_FLAGS flags, - REFGUID containerFormat, - Blob& blob, - const GUID* targetFormat, - std::function setCustomProps) -{ - if (!image.pixels) - return E_POINTER; - - HRESULT hr = blob.Initialize(65535u); - if (FAILED(hr)) - return hr; - - ComPtr stream; - hr = MemoryStreamOnBlob::CreateMemoryStream(&stream, blob); - if (FAILED(hr)) - { - blob.Release(); - return hr; - } - - hr = EncodeSingleFrame(image, flags, containerFormat, stream.Get(), targetFormat, setCustomProps); - if (FAILED(hr)) - { - blob.Release(); - return hr; - } - - hr = stream->Finialize(); - if (FAILED(hr)) - { - blob.Release(); - return hr; - } - - stream.Reset(); - - return S_OK; -} - -_Use_decl_annotations_ -HRESULT DirectX::SaveToWICMemory( - const Image* images, - size_t nimages, - WIC_FLAGS flags, - REFGUID containerFormat, - Blob& blob, - const GUID* targetFormat, - std::function setCustomProps) -{ - if (!images || nimages == 0) - return E_INVALIDARG; - - HRESULT hr = blob.Initialize(65535u); - if (FAILED(hr)) - return hr; - - ComPtr stream; - hr = MemoryStreamOnBlob::CreateMemoryStream(&stream, blob); - if (FAILED(hr)) - { - blob.Release(); - return hr; - } - - if (nimages > 1) - hr = EncodeMultiframe(images, nimages, flags, containerFormat, stream.Get(), targetFormat, setCustomProps); - else - hr = EncodeSingleFrame(images[0], flags, containerFormat, stream.Get(), targetFormat, setCustomProps); - - if (FAILED(hr)) - { - blob.Release(); - return hr; - } - - hr = stream->Finialize(); - if (FAILED(hr)) - { - blob.Release(); - return hr; - } - - stream.Reset(); - - return S_OK; -} - - -//------------------------------------------------------------------------------------- -// Save a WIC-supported file to disk -//------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::SaveToWICFile( - const Image& image, - WIC_FLAGS flags, - REFGUID containerFormat, - const wchar_t* szFile, - const GUID* targetFormat, - std::function setCustomProps) -{ - if (!szFile) - return E_INVALIDARG; - - if (!image.pixels) - return E_POINTER; - - bool iswic2 = false; - auto pWIC = GetWICFactory(iswic2); - if (!pWIC) - return E_NOINTERFACE; - - ComPtr stream; - HRESULT hr = pWIC->CreateStream(stream.GetAddressOf()); - if (FAILED(hr)) - return hr; - - hr = stream->InitializeFromFilename(szFile, GENERIC_WRITE); - if (FAILED(hr)) - return hr; - - hr = EncodeSingleFrame(image, flags, containerFormat, stream.Get(), targetFormat, setCustomProps); - if (FAILED(hr)) - { - stream.Reset(); - std::ignore = DeleteFileW(szFile); - return hr; - } - - return S_OK; -} - -_Use_decl_annotations_ -HRESULT DirectX::SaveToWICFile( - const Image* images, - size_t nimages, - WIC_FLAGS flags, - REFGUID containerFormat, - const wchar_t* szFile, - const GUID* targetFormat, - std::function setCustomProps) -{ - if (!szFile || !images || nimages == 0) - return E_INVALIDARG; - - bool iswic2 = false; - auto pWIC = GetWICFactory(iswic2); - if (!pWIC) - return E_NOINTERFACE; - - ComPtr stream; - HRESULT hr = pWIC->CreateStream(stream.GetAddressOf()); - if (FAILED(hr)) - return hr; - - hr = stream->InitializeFromFilename(szFile, GENERIC_WRITE); - if (FAILED(hr)) - return hr; - - if (nimages > 1) - hr = EncodeMultiframe(images, nimages, flags, containerFormat, stream.Get(), targetFormat, setCustomProps); - else - hr = EncodeSingleFrame(images[0], flags, containerFormat, stream.Get(), targetFormat, setCustomProps); - - if (FAILED(hr)) - { - stream.Reset(); - std::ignore = DeleteFileW(szFile); - return hr; - } - - return S_OK; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Desktop_2019.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Desktop_2019.vcxproj deleted file mode 100644 index 948bd33..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Desktop_2019.vcxproj +++ /dev/null @@ -1,357 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Profile - Win32 - - - Profile - x64 - - - Release - Win32 - - - Release - x64 - - - - DirectXTex - {371B9FA9-4C90-4AC6-A123-ACED756D6C77} - DirectXTex - Win32Proj - 10.0 - x64 - - - - StaticLibrary - true - Unicode - v142 - - - StaticLibrary - true - Unicode - v142 - - - StaticLibrary - Unicode - v142 - - - StaticLibrary - Unicode - v142 - - - StaticLibrary - Unicode - v142 - - - StaticLibrary - Unicode - v142 - - - - - - - - - - - - - - - - - - - - - - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - DirectXTex - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - DirectXTex - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - DirectXTex - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - DirectXTex - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - DirectXTex - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - DirectXTex - true - - - - EnableAllWarnings - Disabled - MultiThreadedDebugDLL - true - Fast - StreamingSIMDExtensions2 - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;_DEBUG;_LIB;_WIN7_PLATFORM_UPDATE;_WIN32_WINNT=0x0601;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - $(IntDir)$(TargetName).pdb - true - true - Level4 - ProgramDatabase - false - - - Windows - true - - - false - - - - - EnableAllWarnings - Disabled - MultiThreadedDebugDLL - true - Fast - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;_DEBUG;_LIB;_WIN7_PLATFORM_UPDATE;_WIN32_WINNT=0x0601;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - $(IntDir)$(TargetName).pdb - true - true - Level4 - ProgramDatabase - false - - - Windows - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - StreamingSIMDExtensions2 - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;NDEBUG;_LIB;_WIN7_PLATFORM_UPDATE;_WIN32_WINNT=0x0601;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - $(IntDir)$(TargetName).pdb - true - true - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;NDEBUG;_LIB;_WIN7_PLATFORM_UPDATE;_WIN32_WINNT=0x0601;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - $(IntDir)$(TargetName).pdb - true - true - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - StreamingSIMDExtensions2 - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;NDEBUG;PROFILE;_LIB;_WIN7_PLATFORM_UPDATE;_WIN32_WINNT=0x0601;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - $(IntDir)$(TargetName).pdb - true - true - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;NDEBUG;PROFILE;_LIB;_WIN7_PLATFORM_UPDATE;_WIN32_WINNT=0x0601;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - $(IntDir)$(TargetName).pdb - true - true - Level4 - - - true - Windows - true - true - - - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create - Create - Create - Create - Create - Create - - - - - - Document - - - Document - - - - - - - - - - <_ATGFXCPath>$(WindowsSDK_ExecutablePath_x64.Split(';')[0]) - <_ATGFXCPath>$(_ATGFXCPath.Replace("x64","")) - <_ATGFXCPath Condition="'$(_ATGFXCPath)' != '' and !HasTrailingSlash('$(_ATGFXCPath)')">$(_ATGFXCPath)\ - - - - <_ATGFXCPath /> - - - - - <_ATGShaderHeaders Include="$(ProjectDir)Shaders/Compiled/*.inc" /> - <_ATGShaderSymbols Include="$(ProjectDir)Shaders/Compiled/*.pdb" /> - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Desktop_2019.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Desktop_2019.vcxproj.filters deleted file mode 100644 index 455edda..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Desktop_2019.vcxproj.filters +++ /dev/null @@ -1,115 +0,0 @@ - - - - - {68652706-b700-4472-9af7-a56a482bd896} - - - {9b7fcbc5-2533-4b88-b75b-d4803e55fa7c} - - - {eb989628-e889-44bf-837a-05c9f09b258e} - - - - - Header Files - - - Header Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files - - - - - Source Files\Shaders - - - Source Files\Shaders - - - Source Files\Shaders - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Desktop_2019_Win10.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Desktop_2019_Win10.vcxproj deleted file mode 100644 index 8aeb691..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Desktop_2019_Win10.vcxproj +++ /dev/null @@ -1,496 +0,0 @@ - - - - - Debug - ARM64 - - - Debug - Win32 - - - Debug - x64 - - - Profile - ARM64 - - - Profile - Win32 - - - Profile - x64 - - - Release - ARM64 - - - Release - Win32 - - - Release - x64 - - - - DirectXTex - {371B9FA9-4C90-4AC6-A123-ACED756D6C77} - DirectXTex - Win32Proj - 10.0 - x64 - - - - StaticLibrary - true - Unicode - v142 - - - StaticLibrary - true - Unicode - v142 - - - StaticLibrary - true - Unicode - v142 - - - StaticLibrary - Unicode - v142 - - - StaticLibrary - Unicode - v142 - - - StaticLibrary - Unicode - v142 - - - StaticLibrary - Unicode - v142 - - - StaticLibrary - Unicode - v142 - - - StaticLibrary - Unicode - v142 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - DirectXTex - true - - - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - DirectXTex - true - - - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - DirectXTex - true - - - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - DirectXTex - true - - - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - DirectXTex - true - - - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - DirectXTex - true - - - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - DirectXTex - true - - - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - DirectXTex - true - - - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2019_Win10\$(Platform)\$(Configuration)\ - DirectXTex - true - - - - EnableAllWarnings - Disabled - MultiThreadedDebugDLL - true - Fast - StreamingSIMDExtensions2 - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;_DEBUG;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - $(IntDir)$(TargetName).pdb - true - true - Level4 - ProgramDatabase - false - - - Windows - true - - - false - - - - - EnableAllWarnings - Disabled - MultiThreadedDebugDLL - true - Fast - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;_DEBUG;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - $(IntDir)$(TargetName).pdb - true - true - Level4 - ProgramDatabase - false - - - Windows - true - - - false - - - - - EnableAllWarnings - Disabled - MultiThreadedDebugDLL - true - Fast - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;_DEBUG;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - $(IntDir)$(TargetName).pdb - true - true - Level4 - ProgramDatabase - false - - - Windows - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - StreamingSIMDExtensions2 - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;NDEBUG;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - $(IntDir)$(TargetName).pdb - true - true - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;NDEBUG;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - $(IntDir)$(TargetName).pdb - true - true - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;NDEBUG;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - $(IntDir)$(TargetName).pdb - true - true - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - StreamingSIMDExtensions2 - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;NDEBUG;PROFILE;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - $(IntDir)$(TargetName).pdb - true - true - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;NDEBUG;PROFILE;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - $(IntDir)$(TargetName).pdb - true - true - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;NDEBUG;PROFILE;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - $(IntDir)$(TargetName).pdb - true - true - Level4 - - - true - Windows - true - true - - - false - - - - - Document - - - Document - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create - Create - Create - Create - Create - Create - Create - Create - Create - - - - - - - - - - - <_ATGFXCPath>$(WindowsSDK_ExecutablePath_x64.Split(';')[0]) - <_ATGFXCPath>$(_ATGFXCPath.Replace("x64","")) - <_ATGFXCPath Condition="'$(_ATGFXCPath)' != '' and !HasTrailingSlash('$(_ATGFXCPath)')">$(_ATGFXCPath)\ - - - - <_ATGFXCPath /> - - - - - <_ATGShaderHeaders Include="$(ProjectDir)Shaders/Compiled/*.inc" /> - <_ATGShaderSymbols Include="$(ProjectDir)Shaders/Compiled/*.pdb" /> - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Desktop_2019_Win10.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Desktop_2019_Win10.vcxproj.filters deleted file mode 100644 index d8bca58..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Desktop_2019_Win10.vcxproj.filters +++ /dev/null @@ -1,121 +0,0 @@ - - - - - {68652706-b700-4472-9af7-a56a482bd896} - - - {9b7fcbc5-2533-4b88-b75b-d4803e55fa7c} - - - {d665bb3f-6d2a-415d-83f5-abd5c813962b} - - - - - Header Files - - - Header Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files - - - - - Source Files\Shaders - - - Source Files\Shaders - - - Source Files\Shaders - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Desktop_2022.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Desktop_2022.vcxproj deleted file mode 100644 index 345ef8b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Desktop_2022.vcxproj +++ /dev/null @@ -1,357 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Profile - Win32 - - - Profile - x64 - - - Release - Win32 - - - Release - x64 - - - - DirectXTex - {371B9FA9-4C90-4AC6-A123-ACED756D6C77} - DirectXTex - Win32Proj - 10.0 - x64 - - - - StaticLibrary - true - Unicode - v143 - - - StaticLibrary - true - Unicode - v143 - - - StaticLibrary - Unicode - v143 - - - StaticLibrary - Unicode - v143 - - - StaticLibrary - Unicode - v143 - - - StaticLibrary - Unicode - v143 - - - - - - - - - - - - - - - - - - - - - - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - DirectXTex - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - DirectXTex - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - DirectXTex - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - DirectXTex - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - DirectXTex - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - DirectXTex - true - - - - EnableAllWarnings - Disabled - MultiThreadedDebugDLL - true - Fast - StreamingSIMDExtensions2 - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;_DEBUG;_LIB;_WIN7_PLATFORM_UPDATE;_WIN32_WINNT=0x0601;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - $(IntDir)$(TargetName).pdb - true - true - Level4 - ProgramDatabase - false - - - Windows - true - - - false - - - - - EnableAllWarnings - Disabled - MultiThreadedDebugDLL - true - Fast - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;_DEBUG;_LIB;_WIN7_PLATFORM_UPDATE;_WIN32_WINNT=0x0601;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - $(IntDir)$(TargetName).pdb - true - true - Level4 - ProgramDatabase - false - - - Windows - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - StreamingSIMDExtensions2 - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;NDEBUG;_LIB;_WIN7_PLATFORM_UPDATE;_WIN32_WINNT=0x0601;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - $(IntDir)$(TargetName).pdb - true - true - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;NDEBUG;_LIB;_WIN7_PLATFORM_UPDATE;_WIN32_WINNT=0x0601;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - $(IntDir)$(TargetName).pdb - true - true - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - StreamingSIMDExtensions2 - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;NDEBUG;PROFILE;_LIB;_WIN7_PLATFORM_UPDATE;_WIN32_WINNT=0x0601;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - $(IntDir)$(TargetName).pdb - true - true - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;NDEBUG;PROFILE;_LIB;_WIN7_PLATFORM_UPDATE;_WIN32_WINNT=0x0601;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - $(IntDir)$(TargetName).pdb - true - true - Level4 - - - true - Windows - true - true - - - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create - Create - Create - Create - Create - Create - - - - - - Document - - - Document - - - - - - - - - - <_ATGFXCPath>$(WindowsSDK_ExecutablePath_x64.Split(';')[0]) - <_ATGFXCPath>$(_ATGFXCPath.Replace("x64","")) - <_ATGFXCPath Condition="'$(_ATGFXCPath)' != '' and !HasTrailingSlash('$(_ATGFXCPath)')">$(_ATGFXCPath)\ - - - - <_ATGFXCPath /> - - - - - <_ATGShaderHeaders Include="$(ProjectDir)Shaders/Compiled/*.inc" /> - <_ATGShaderSymbols Include="$(ProjectDir)Shaders/Compiled/*.pdb" /> - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Desktop_2022.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Desktop_2022.vcxproj.filters deleted file mode 100644 index 455edda..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Desktop_2022.vcxproj.filters +++ /dev/null @@ -1,115 +0,0 @@ - - - - - {68652706-b700-4472-9af7-a56a482bd896} - - - {9b7fcbc5-2533-4b88-b75b-d4803e55fa7c} - - - {eb989628-e889-44bf-837a-05c9f09b258e} - - - - - Header Files - - - Header Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files - - - - - Source Files\Shaders - - - Source Files\Shaders - - - Source Files\Shaders - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Desktop_2022_Win10.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Desktop_2022_Win10.vcxproj deleted file mode 100644 index baf2f76..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Desktop_2022_Win10.vcxproj +++ /dev/null @@ -1,496 +0,0 @@ - - - - - Debug - ARM64 - - - Debug - Win32 - - - Debug - x64 - - - Profile - ARM64 - - - Profile - Win32 - - - Profile - x64 - - - Release - ARM64 - - - Release - Win32 - - - Release - x64 - - - - DirectXTex - {371B9FA9-4C90-4AC6-A123-ACED756D6C77} - DirectXTex - Win32Proj - 10.0 - x64 - - - - StaticLibrary - true - Unicode - v143 - - - StaticLibrary - true - Unicode - v143 - - - StaticLibrary - true - Unicode - v143 - - - StaticLibrary - Unicode - v143 - - - StaticLibrary - Unicode - v143 - - - StaticLibrary - Unicode - v143 - - - StaticLibrary - Unicode - v143 - - - StaticLibrary - Unicode - v143 - - - StaticLibrary - Unicode - v143 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - DirectXTex - true - - - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - DirectXTex - true - - - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - DirectXTex - true - - - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - DirectXTex - true - - - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - DirectXTex - true - - - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - DirectXTex - true - - - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - DirectXTex - true - - - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - DirectXTex - true - - - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - Bin\Desktop_2022_Win10\$(Platform)\$(Configuration)\ - DirectXTex - true - - - - EnableAllWarnings - Disabled - MultiThreadedDebugDLL - true - Fast - StreamingSIMDExtensions2 - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;_DEBUG;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - $(IntDir)$(TargetName).pdb - true - true - Level4 - ProgramDatabase - false - - - Windows - true - - - false - - - - - EnableAllWarnings - Disabled - MultiThreadedDebugDLL - true - Fast - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;_DEBUG;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - $(IntDir)$(TargetName).pdb - true - true - Level4 - ProgramDatabase - false - - - Windows - true - - - false - - - - - EnableAllWarnings - Disabled - MultiThreadedDebugDLL - true - Fast - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;_DEBUG;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - $(IntDir)$(TargetName).pdb - true - true - Level4 - ProgramDatabase - false - - - Windows - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - StreamingSIMDExtensions2 - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;NDEBUG;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - $(IntDir)$(TargetName).pdb - true - true - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;NDEBUG;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - $(IntDir)$(TargetName).pdb - true - true - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;NDEBUG;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - $(IntDir)$(TargetName).pdb - true - true - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - StreamingSIMDExtensions2 - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;NDEBUG;PROFILE;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - $(IntDir)$(TargetName).pdb - true - true - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;NDEBUG;PROFILE;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - $(IntDir)$(TargetName).pdb - true - true - Level4 - - - true - Windows - true - true - - - false - - - - - EnableAllWarnings - MaxSpeed - true - Fast - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - _UNICODE;UNICODE;WIN32;NDEBUG;PROFILE;_LIB;_WIN32_WINNT=0x0A00;_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - $(IntDir)$(TargetName).pdb - true - true - Level4 - - - true - Windows - true - true - - - false - - - - - Document - - - Document - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create - Create - Create - Create - Create - Create - Create - Create - Create - - - - - - - - - - - <_ATGFXCPath>$(WindowsSDK_ExecutablePath_x64.Split(';')[0]) - <_ATGFXCPath>$(_ATGFXCPath.Replace("x64","")) - <_ATGFXCPath Condition="'$(_ATGFXCPath)' != '' and !HasTrailingSlash('$(_ATGFXCPath)')">$(_ATGFXCPath)\ - - - - <_ATGFXCPath /> - - - - - <_ATGShaderHeaders Include="$(ProjectDir)Shaders/Compiled/*.inc" /> - <_ATGShaderSymbols Include="$(ProjectDir)Shaders/Compiled/*.pdb" /> - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Desktop_2022_Win10.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Desktop_2022_Win10.vcxproj.filters deleted file mode 100644 index d8bca58..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Desktop_2022_Win10.vcxproj.filters +++ /dev/null @@ -1,121 +0,0 @@ - - - - - {68652706-b700-4472-9af7-a56a482bd896} - - - {9b7fcbc5-2533-4b88-b75b-d4803e55fa7c} - - - {d665bb3f-6d2a-415d-83f5-abd5c813962b} - - - - - Header Files - - - Header Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files - - - - - Source Files\Shaders - - - Source Files\Shaders - - - Source Files\Shaders - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_GDK_2019.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_GDK_2019.vcxproj deleted file mode 100644 index b50755a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_GDK_2019.vcxproj +++ /dev/null @@ -1,535 +0,0 @@ - - - - - Debug - Gaming.Desktop.x64 - - - Debug - Gaming.Xbox.Scarlett.x64 - - - Profile - Gaming.Desktop.x64 - - - Profile - Gaming.Xbox.Scarlett.x64 - - - Release - Gaming.Desktop.x64 - - - Release - Gaming.Xbox.Scarlett.x64 - - - Release - Gaming.Xbox.XboxOne.x64 - - - Profile - Gaming.Xbox.XboxOne.x64 - - - Debug - Gaming.Xbox.XboxOne.x64 - - - - DirectXTex - {e66dd892-857b-4e89-b135-5e2a971a9933} - en-US - Win32Proj - - 15.0 - Native - x64 - - - - - StaticLibrary - v142 - false - Unicode - false - false - - - StaticLibrary - v142 - false - Unicode - - - StaticLibrary - v142 - false - Unicode - - - StaticLibrary - v142 - false - Unicode - false - false - - - StaticLibrary - v142 - false - Unicode - - - StaticLibrary - v142 - false - Unicode - - - StaticLibrary - v142 - true - Unicode - false - false - - - StaticLibrary - v142 - true - Unicode - - - StaticLibrary - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkLibPath) - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkIncludeRoot) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - false - Bin\GDK_2019\$(Platform)\$(Configuration)\ - Bin\GDK_2019\$(Platform)\$(Configuration)\ - DirectXTex - - - $(Console_SdkLibPath);$(LibraryPath) - $(Console_SdkIncludeRoot);$(IncludePath) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - false - Bin\GDK_2019\$(Platform)\$(Configuration)\ - Bin\GDK_2019\$(Platform)\$(Configuration)\ - DirectXTex - - - $(Console_SdkLibPath);$(LibraryPath) - $(Console_SdkIncludeRoot);$(IncludePath) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - false - Bin\GDK_2019\$(Platform)\$(Configuration)\ - Bin\GDK_2019\$(Platform)\$(Configuration)\ - DirectXTex - - - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkLibPath) - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkIncludeRoot) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - false - Bin\GDK_2019\$(Platform)\$(Configuration)\ - Bin\GDK_2019\$(Platform)\$(Configuration)\ - DirectXTex - - - $(Console_SdkLibPath);$(LibraryPath) - $(Console_SdkIncludeRoot);$(IncludePath) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - false - Bin\GDK_2019\$(Platform)\$(Configuration)\ - Bin\GDK_2019\$(Platform)\$(Configuration)\ - DirectXTex - - - $(Console_SdkLibPath);$(LibraryPath) - $(Console_SdkIncludeRoot);$(IncludePath) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - false - Bin\GDK_2019\$(Platform)\$(Configuration)\ - Bin\GDK_2019\$(Platform)\$(Configuration)\ - DirectXTex - - - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkLibPath) - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkIncludeRoot) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - true - Bin\GDK_2019\$(Platform)\$(Configuration)\ - Bin\GDK_2019\$(Platform)\$(Configuration)\ - DirectXTex - - - $(Console_SdkLibPath);$(LibraryPath) - $(Console_SdkIncludeRoot);$(IncludePath) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - true - Bin\GDK_2019\$(Platform)\$(Configuration)\ - Bin\GDK_2019\$(Platform)\$(Configuration)\ - DirectXTex - - - $(Console_SdkLibPath);$(LibraryPath) - $(Console_SdkIncludeRoot);$(IncludePath) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - true - Bin\GDK_2019\$(Platform)\$(Configuration)\ - Bin\GDK_2019\$(Platform)\$(Configuration)\ - DirectXTex - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - true - Windows - true - true - - - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - MaxSpeed - NDEBUG;_LIB;%(PreprocessorDefinitions) - EnableAllWarnings - true - true - true - true - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Level4 - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - true - Windows - true - true - - - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - MaxSpeed - NDEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;%(PreprocessorDefinitions) - EnableAllWarnings - true - true - true - true - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Level4 - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - true - Windows - true - true - - - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - MaxSpeed - NDEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;%(PreprocessorDefinitions) - EnableAllWarnings - true - true - true - true - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Level4 - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - true - Windows - true - true - - - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - MaxSpeed - NDEBUG;_LIB;PROFILE;%(PreprocessorDefinitions) - EnableAllWarnings - true - true - true - true - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Level4 - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - true - Windows - true - true - - - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - MaxSpeed - NDEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;PROFILE;%(PreprocessorDefinitions) - EnableAllWarnings - true - true - true - true - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Level4 - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - true - Windows - true - true - - - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - MaxSpeed - NDEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;PROFILE;%(PreprocessorDefinitions) - EnableAllWarnings - true - true - true - true - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Level4 - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - Windows - true - - - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - Use - false - EnableAllWarnings - Disabled - _DEBUG;_LIB;%(PreprocessorDefinitions) - true - true - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Level4 - ProgramDatabase - false - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - Windows - true - - - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - Use - false - EnableAllWarnings - Disabled - _DEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;%(PreprocessorDefinitions) - true - true - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Level4 - ProgramDatabase - false - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - Windows - true - - - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - Use - false - EnableAllWarnings - Disabled - _DEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;%(PreprocessorDefinitions) - true - true - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Level4 - ProgramDatabase - false - - - 6.0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create - Create - Create - Create - Create - Create - Create - Create - Create - - - - - - Document - - - Document - - - - - - - <_ATGFXCPath>$(WindowsSDK_ExecutablePath_x64.Split(';')[0]) - <_ATGFXCPath>$(_ATGFXCPath.Replace("x64","")) - <_ATGFXCPath Condition="'$(_ATGFXCPath)' != '' and !HasTrailingSlash('$(_ATGFXCPath)')">$(_ATGFXCPath)\ - - - - <_ATGFXCPath /> - - - - - <_ATGShaderHeaders Include="$(ProjectDir)Shaders/Compiled/*.inc" /> - <_ATGShaderSymbols Include="$(ProjectDir)Shaders/Compiled/*.pdb" /> - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_GDK_2019.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_GDK_2019.vcxproj.filters deleted file mode 100644 index fbd667f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_GDK_2019.vcxproj.filters +++ /dev/null @@ -1,110 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {c60baf7a-25a9-4215-842d-8d49d65d538e} - - - - - Header Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Source Files\Shaders - - - Source Files\Shaders - - - Source Files\Shaders - - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_GDK_2022.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_GDK_2022.vcxproj deleted file mode 100644 index db1f8d6..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_GDK_2022.vcxproj +++ /dev/null @@ -1,535 +0,0 @@ - - - - - Debug - Gaming.Desktop.x64 - - - Debug - Gaming.Xbox.Scarlett.x64 - - - Profile - Gaming.Desktop.x64 - - - Profile - Gaming.Xbox.Scarlett.x64 - - - Release - Gaming.Desktop.x64 - - - Release - Gaming.Xbox.Scarlett.x64 - - - Release - Gaming.Xbox.XboxOne.x64 - - - Profile - Gaming.Xbox.XboxOne.x64 - - - Debug - Gaming.Xbox.XboxOne.x64 - - - - DirectXTex - {e66dd892-857b-4e89-b135-5e2a971a9933} - en-US - Win32Proj - - 15.0 - Native - x64 - - - - - StaticLibrary - v143 - false - Unicode - false - false - - - StaticLibrary - v143 - false - Unicode - - - StaticLibrary - v143 - false - Unicode - - - StaticLibrary - v143 - false - Unicode - false - false - - - StaticLibrary - v143 - false - Unicode - - - StaticLibrary - v143 - false - Unicode - - - StaticLibrary - v143 - true - Unicode - false - false - - - StaticLibrary - v143 - true - Unicode - - - StaticLibrary - v143 - true - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkLibPath) - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkIncludeRoot) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - false - Bin\GDK_2022\$(Platform)\$(Configuration)\ - Bin\GDK_2022\$(Platform)\$(Configuration)\ - DirectXTex - - - $(Console_SdkLibPath);$(LibraryPath) - $(Console_SdkIncludeRoot);$(IncludePath) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - false - Bin\GDK_2022\$(Platform)\$(Configuration)\ - Bin\GDK_2022\$(Platform)\$(Configuration)\ - DirectXTex - - - $(Console_SdkLibPath);$(LibraryPath) - $(Console_SdkIncludeRoot);$(IncludePath) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - false - Bin\GDK_2022\$(Platform)\$(Configuration)\ - Bin\GDK_2022\$(Platform)\$(Configuration)\ - DirectXTex - - - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkLibPath) - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkIncludeRoot) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - false - Bin\GDK_2022\$(Platform)\$(Configuration)\ - Bin\GDK_2022\$(Platform)\$(Configuration)\ - DirectXTex - - - $(Console_SdkLibPath);$(LibraryPath) - $(Console_SdkIncludeRoot);$(IncludePath) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - false - Bin\GDK_2022\$(Platform)\$(Configuration)\ - Bin\GDK_2022\$(Platform)\$(Configuration)\ - DirectXTex - - - $(Console_SdkLibPath);$(LibraryPath) - $(Console_SdkIncludeRoot);$(IncludePath) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - false - Bin\GDK_2022\$(Platform)\$(Configuration)\ - Bin\GDK_2022\$(Platform)\$(Configuration)\ - DirectXTex - - - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkLibPath) - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkIncludeRoot) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - true - Bin\GDK_2022\$(Platform)\$(Configuration)\ - Bin\GDK_2022\$(Platform)\$(Configuration)\ - DirectXTex - - - $(Console_SdkLibPath);$(LibraryPath) - $(Console_SdkIncludeRoot);$(IncludePath) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - true - Bin\GDK_2022\$(Platform)\$(Configuration)\ - Bin\GDK_2022\$(Platform)\$(Configuration)\ - DirectXTex - - - $(Console_SdkLibPath);$(LibraryPath) - $(Console_SdkIncludeRoot);$(IncludePath) - $(Console_SdkRoot)bin;$(Console_SdkToolPath);$(ExecutablePath) - true - Bin\GDK_2022\$(Platform)\$(Configuration)\ - Bin\GDK_2022\$(Platform)\$(Configuration)\ - DirectXTex - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - true - Windows - true - true - - - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - MaxSpeed - NDEBUG;_LIB;%(PreprocessorDefinitions) - EnableAllWarnings - true - true - true - true - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - Level4 - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - true - Windows - true - true - - - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - MaxSpeed - NDEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;%(PreprocessorDefinitions) - EnableAllWarnings - true - true - true - true - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - Level4 - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - true - Windows - true - true - - - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - MaxSpeed - NDEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;%(PreprocessorDefinitions) - EnableAllWarnings - true - true - true - true - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - Level4 - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - true - Windows - true - true - - - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - MaxSpeed - NDEBUG;_LIB;PROFILE;%(PreprocessorDefinitions) - EnableAllWarnings - true - true - true - true - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - Level4 - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - true - Windows - true - true - - - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - MaxSpeed - NDEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;PROFILE;%(PreprocessorDefinitions) - EnableAllWarnings - true - true - true - true - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - Level4 - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - true - Windows - true - true - - - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - MaxSpeed - NDEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;PROFILE;%(PreprocessorDefinitions) - EnableAllWarnings - true - true - true - true - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - Level4 - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - Windows - true - - - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - Use - false - EnableAllWarnings - Disabled - _DEBUG;_LIB;%(PreprocessorDefinitions) - true - true - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - Level4 - ProgramDatabase - false - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - Windows - true - - - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - Use - false - EnableAllWarnings - Disabled - _DEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;%(PreprocessorDefinitions) - true - true - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - Level4 - ProgramDatabase - false - - - 6.0 - - - - - $(Console_Libs);%(XboxExtensionsDependencies);%(AdditionalDependencies) - Windows - true - - - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - Use - false - EnableAllWarnings - Disabled - _DEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;%(PreprocessorDefinitions) - true - true - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - Level4 - ProgramDatabase - false - - - 6.0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create - Create - Create - Create - Create - Create - Create - Create - Create - - - - - - Document - - - Document - - - - - - - <_ATGFXCPath>$(WindowsSDK_ExecutablePath_x64.Split(';')[0]) - <_ATGFXCPath>$(_ATGFXCPath.Replace("x64","")) - <_ATGFXCPath Condition="'$(_ATGFXCPath)' != '' and !HasTrailingSlash('$(_ATGFXCPath)')">$(_ATGFXCPath)\ - - - - <_ATGFXCPath /> - - - - - <_ATGShaderHeaders Include="$(ProjectDir)Shaders/Compiled/*.inc" /> - <_ATGShaderSymbols Include="$(ProjectDir)Shaders/Compiled/*.pdb" /> - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_GDK_2022.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_GDK_2022.vcxproj.filters deleted file mode 100644 index fbd667f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_GDK_2022.vcxproj.filters +++ /dev/null @@ -1,110 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {c60baf7a-25a9-4215-842d-8d49d65d538e} - - - - - Header Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Source Files\Shaders - - - Source Files\Shaders - - - Source Files\Shaders - - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Windows10_2019.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Windows10_2019.vcxproj deleted file mode 100644 index 8ba117f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Windows10_2019.vcxproj +++ /dev/null @@ -1,443 +0,0 @@ - - - - - Debug - ARM - - - Debug - ARM64 - - - Debug - Win32 - - - Debug - x64 - - - Release - ARM - - - Release - ARM64 - - - Release - Win32 - - - Release - x64 - - - - - - - - - - - - - - - - - - - - - - - - Create - Create - Create - Create - Create - Create - Create - Create - - - - - - - - - - - - - - - - - - - - Document - - - Document - - - - {fb3f52b5-bfe8-43fd-836f-363735dab738} - StaticLibrary - DirectXTex - DirectXTex - en-US - 14.0 - true - Windows Store - 10.0 - 10.0.14393.0 - 10.0 - x64 - - - - StaticLibrary - true - v142 - - - StaticLibrary - true - v142 - - - StaticLibrary - true - v142 - - - StaticLibrary - true - v142 - - - StaticLibrary - false - v142 - - - StaticLibrary - false - v142 - - - StaticLibrary - false - v142 - - - StaticLibrary - false - v142 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - DirectXTex - false - - - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - DirectXTex - false - - - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - DirectXTex - false - - - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - DirectXTex - false - - - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - DirectXTex - false - - - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - DirectXTex - false - - - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - DirectXTex - false - - - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - Bin\Windows10_2019\$(Platform)\$(Configuration)\ - DirectXTex - false - - - - Use - - false - true - Fast - StreamingSIMDExtensions2 - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - true - ProgramDatabase - false - Level4 - - - Console - false - false - - - - - Use - - false - true - Fast - StreamingSIMDExtensions2 - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - true - Level4 - - - Console - false - false - - - - - Use - - false - true - Fast - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - true - ProgramDatabase - false - Level4 - - - Console - false - false - - - - - Use - - - false - true - Fast - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - true - ProgramDatabase - false - Level4 - - - Console - false - false - - - - - Use - - false - true - Fast - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - true - Level4 - - - Console - false - false - - - - - Use - - - false - true - Fast - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - true - Level4 - - - Console - false - false - - - - - Use - - false - true - Fast - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - true - ProgramDatabase - false - Level4 - - - Console - false - false - - - - - Use - - false - true - Fast - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - true - Level4 - - - Console - false - false - - - - - - - - <_ATGFXCPath>$(WindowsSDK_ExecutablePath_x64.Split(';')[0]) - <_ATGFXCPath>$(_ATGFXCPath.Replace("x64","")) - <_ATGFXCPath Condition="'$(_ATGFXCPath)' != '' and !HasTrailingSlash('$(_ATGFXCPath)')">$(_ATGFXCPath)\ - - - - <_ATGFXCPath /> - - - - - <_ATGShaderHeaders Include="$(ProjectDir)Shaders/Compiled/*.inc" /> - <_ATGShaderSymbols Include="$(ProjectDir)Shaders/Compiled/*.pdb" /> - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Windows10_2019.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Windows10_2019.vcxproj.filters deleted file mode 100644 index caccf47..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Windows10_2019.vcxproj.filters +++ /dev/null @@ -1,136 +0,0 @@ - - - - - {f4d68f4f-adbe-40a1-b052-f2e4cae3b5ae} - - - {b42472b0-7a63-47b0-b77f-4ffe492471a0} - - - {1838e3e6-1f80-4713-9a98-41ea7e654d12} - - - - - {f4d68f4f-adbe-40a1-b052-f2e4cae3b5ae} - - - {b42472b0-7a63-47b0-b77f-4ffe492471a0} - - - {1838e3e6-1f80-4713-9a98-41ea7e654d12} - - - {7c13ba68-1ec8-4710-a8dd-cd973621b725} - - - {fbc9373c-d511-4fd1-a7b8-d55df1b27d2e} - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Source Files\Shaders - - - Source Files\Shaders - - - Source Files\Shaders - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Windows10_2022.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Windows10_2022.vcxproj deleted file mode 100644 index 249643f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Windows10_2022.vcxproj +++ /dev/null @@ -1,443 +0,0 @@ - - - - - Debug - ARM - - - Debug - ARM64 - - - Debug - Win32 - - - Debug - x64 - - - Release - ARM - - - Release - ARM64 - - - Release - Win32 - - - Release - x64 - - - - - - - - - - - - - - - - - - - - - - - - Create - Create - Create - Create - Create - Create - Create - Create - - - - - - - - - - - - - - - - - - - - Document - - - Document - - - - {fb3f52b5-bfe8-43fd-836f-363735dab738} - StaticLibrary - DirectXTex - DirectXTex - en-US - 14.0 - true - Windows Store - 10.0 - 10.0.17763.0 - 10.0 - x64 - - - - StaticLibrary - true - v143 - - - StaticLibrary - true - v143 - - - StaticLibrary - true - v143 - - - StaticLibrary - true - v143 - - - StaticLibrary - false - v143 - - - StaticLibrary - false - v143 - - - StaticLibrary - false - v143 - - - StaticLibrary - false - v143 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - DirectXTex - false - - - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - DirectXTex - false - - - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - DirectXTex - false - - - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - DirectXTex - false - - - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - DirectXTex - false - - - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - DirectXTex - false - - - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - DirectXTex - false - - - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - Bin\Windows10_2022\$(Platform)\$(Configuration)\ - DirectXTex - false - - - - Use - - false - true - Fast - StreamingSIMDExtensions2 - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - true - ProgramDatabase - false - Level4 - - - Console - false - false - - - - - Use - - false - true - Fast - StreamingSIMDExtensions2 - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - true - Level4 - - - Console - false - false - - - - - Use - - false - true - Fast - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - true - ProgramDatabase - false - Level4 - - - Console - false - false - - - - - Use - - - false - true - Fast - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - true - ProgramDatabase - false - Level4 - - - Console - false - false - - - - - Use - - false - true - Fast - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - true - Level4 - - - Console - false - false - - - - - Use - - - false - true - Fast - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - true - Level4 - - - Console - false - false - - - - - Use - - false - true - Fast - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - true - ProgramDatabase - false - Level4 - - - Console - false - false - - - - - Use - - false - true - Fast - $(IntDir)$(TargetName).pdb - EnableAllWarnings - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS;%(PreprocessorDefinitions) - true - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - true - Level4 - - - Console - false - false - - - - - - - - <_ATGFXCPath>$(WindowsSDK_ExecutablePath_x64.Split(';')[0]) - <_ATGFXCPath>$(_ATGFXCPath.Replace("x64","")) - <_ATGFXCPath Condition="'$(_ATGFXCPath)' != '' and !HasTrailingSlash('$(_ATGFXCPath)')">$(_ATGFXCPath)\ - - - - <_ATGFXCPath /> - - - - - <_ATGShaderHeaders Include="$(ProjectDir)Shaders/Compiled/*.inc" /> - <_ATGShaderSymbols Include="$(ProjectDir)Shaders/Compiled/*.pdb" /> - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Windows10_2022.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Windows10_2022.vcxproj.filters deleted file mode 100644 index caccf47..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_Windows10_2022.vcxproj.filters +++ /dev/null @@ -1,136 +0,0 @@ - - - - - {f4d68f4f-adbe-40a1-b052-f2e4cae3b5ae} - - - {b42472b0-7a63-47b0-b77f-4ffe492471a0} - - - {1838e3e6-1f80-4713-9a98-41ea7e654d12} - - - - - {f4d68f4f-adbe-40a1-b052-f2e4cae3b5ae} - - - {b42472b0-7a63-47b0-b77f-4ffe492471a0} - - - {1838e3e6-1f80-4713-9a98-41ea7e654d12} - - - {7c13ba68-1ec8-4710-a8dd-cd973621b725} - - - {fbc9373c-d511-4fd1-a7b8-d55df1b27d2e} - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Source Files\Shaders - - - Source Files\Shaders - - - Source Files\Shaders - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_XboxOneXDK_2017.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_XboxOneXDK_2017.vcxproj deleted file mode 100644 index 7bcf5d8..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_XboxOneXDK_2017.vcxproj +++ /dev/null @@ -1,244 +0,0 @@ - - - - - Release - Durango - - - Profile - Durango - - - Debug - Durango - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create - Create - Create - - - - - - Document - - - Document - - - - DirectXTex - {879b5023-53b7-4108-aeae-f019c2e9410d} - en-US - Win32Proj - title - - v141 - 14.0 - Native - - - - StaticLibrary - v141 - false - Unicode - false - false - - - StaticLibrary - v141 - false - Unicode - false - false - - - StaticLibrary - v141 - true - Unicode - false - false - - - - - - - - - - - - - - - - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkLibPath) - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkIncludeRoot) - $(Console_SdkRoot)bin;$(VCInstallDir)bin\x86_amd64;$(VCInstallDir)bin;$(WindowsSDK_ExecutablePath_x86);$(VSInstallDir)Common7\Tools\bin;$(VSInstallDir)Common7\tools;$(VSInstallDir)Common7\ide;$(ProgramFiles)\HTML Help Workshop;$(MSBuildToolsPath32);$(FxCopDir);$(PATH); - Bin\XboxOneXDK_2017\$(Platform)\$(Configuration)\ - Bin\XboxOneXDK_2017\$(Platform)\$(Configuration)\ - DirectXTex - - - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkLibPath) - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkIncludeRoot) - $(Console_SdkRoot)bin;$(VCInstallDir)bin\x86_amd64;$(VCInstallDir)bin;$(WindowsSDK_ExecutablePath_x86);$(VSInstallDir)Common7\Tools\bin;$(VSInstallDir)Common7\tools;$(VSInstallDir)Common7\ide;$(ProgramFiles)\HTML Help Workshop;$(MSBuildToolsPath32);$(FxCopDir);$(PATH); - Bin\XboxOneXDK_2017\$(Platform)\$(Configuration)\ - Bin\XboxOneXDK_2017\$(Platform)\$(Configuration)\ - DirectXTex - - - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkLibPath) - $(Console_SdkLibPath);$(Console_SdkWindowsMetadataPath) - $(Console_SdkIncludeRoot) - $(Console_SdkRoot)bin;$(VCInstallDir)bin\x86_amd64;$(VCInstallDir)bin;$(WindowsSDK_ExecutablePath_x86);$(VSInstallDir)Common7\Tools\bin;$(VSInstallDir)Common7\tools;$(VSInstallDir)Common7\ide;$(ProgramFiles)\HTML Help Workshop;$(MSBuildToolsPath32);$(FxCopDir);$(PATH); - Bin\XboxOneXDK_2017\$(Platform)\$(Configuration)\ - Bin\XboxOneXDK_2017\$(Platform)\$(Configuration)\ - DirectXTex - - - - d3d11_x.lib;combase.lib;kernelx.lib;toolhelpx.lib;uuid.lib; - - - true - Windows - true - true - false - - - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - - - MaxSpeed - true - NDEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;%(PreprocessorDefinitions) - EnableAllWarnings - true - true - false - $(IntDir)$(TargetName).pdb - - - - - pixEvt.lib;d3d11_x.lib;combase.lib;kernelx.lib;toolhelpx.lib;uuid.lib; - - - true - Windows - true - true - false - - - Use - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - - - MaxSpeed - true - NDEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;PROFILE;%(PreprocessorDefinitions) - EnableAllWarnings - true - true - false - $(IntDir)$(TargetName).pdb - - - - - d3d11_x.lib;combase.lib;kernelx.lib;toolhelpx.lib;uuid.lib; - Windows - true - false - - - DirectXTexP.h - $(ProjectDir);$(ProjectDir)Shaders\Compiled;%(AdditionalIncludeDirectories) - Use - false - - - EnableAllWarnings - Disabled - true - _DEBUG;__WRL_NO_DEFAULT_LIB__;_LIB;%(PreprocessorDefinitions) - false - $(IntDir)$(TargetName).pdb - ProgramDatabase - false - - - - - - - - <_ATGFXCPath>$(WindowsSDK_ExecutablePath_x64.Split(';')[0]) - <_ATGFXCPath>$(_ATGFXCPath.Replace("x64","")) - <_ATGFXCPath Condition="'$(_ATGFXCPath)' != '' and !HasTrailingSlash('$(_ATGFXCPath)')">$(_ATGFXCPath)\ - - - - <_ATGFXCPath /> - - - - - <_ATGShaderHeaders Include="$(ProjectDir)Shaders/Compiled/*.inc" /> - <_ATGShaderSymbols Include="$(ProjectDir)Shaders/Compiled/*.pdb" /> - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_XboxOneXDK_2017.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_XboxOneXDK_2017.vcxproj.filters deleted file mode 100644 index 6b60823..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/DirectXTex_XboxOneXDK_2017.vcxproj.filters +++ /dev/null @@ -1,118 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {c60baf7a-25a9-4215-842d-8d49d65d538e} - - - - - Header Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Source Files\Shaders - - - Source Files\Shaders - - - Source Files\Shaders - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/Shaders/BC6HEncode.hlsl b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/Shaders/BC6HEncode.hlsl deleted file mode 100644 index 7daea76..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/Shaders/BC6HEncode.hlsl +++ /dev/null @@ -1,2567 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: BC6HEncode.hlsl -// -// The Compute Shader for BC6H Encoder -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -//-------------------------------------------------------------------------------------- - -#define REF_DEVICE - -#define UINTLENGTH 32 -#define NCHANNELS 3 -#define SIGNED_F16 96 -#define UNSIGNED_F16 95 -#define MAX_FLOAT asfloat(0x7F7FFFFF) -#define MIN_FLOAT asfloat(0xFF7FFFFF) -#define MAX_INT asint(0x7FFFFFFF) -#define MIN_INT asint(0x80000000) - -cbuffer cbCS : register(b0) -{ - uint g_tex_width; - uint g_num_block_x; - uint g_format; //either SIGNED_F16 for DXGI_FORMAT_BC6H_SF16 or UNSIGNED_F16 for DXGI_FORMAT_BC6H_UF16 - uint g_mode_id; - uint g_start_block_id; - uint g_num_total_blocks; -}; - -static const uint candidateModeMemory[14] = { 0x00, 0x01, 0x02, 0x06, 0x0A, 0x0E, 0x12, 0x16, 0x1A, 0x1E, 0x03, 0x07, 0x0B, 0x0F }; -static const uint candidateModeFlag[14] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; -static const bool candidateModeTransformed[14] = { true, true, true, true, true, true, true, true, true, false, false, true, true, true }; -static const uint4 candidateModePrec[14] = { uint4(10,5,5,5), uint4(7,6,6,6), - uint4(11,5,4,4), uint4(11,4,5,4), uint4(11,4,4,5), uint4(9,5,5,5), - uint4(8,6,5,5), uint4(8,5,6,5), uint4(8,5,5,6), uint4(6,6,6,6), - uint4(10,10,10,10), uint4(11,9,9,9), uint4(12,8,8,8), uint4(16,4,4,4) }; - -/*static const uint4x4 candidateSection[32] = -{ - {0,0,1,1, 0,0,1,1, 0,0,1,1, 0,0,1,1}, {0,0,0,1, 0,0,0,1, 0,0,0,1, 0,0,0,1}, {0,1,1,1, 0,1,1,1, 0,1,1,1, 0,1,1,1}, {0,0,0,1, 0,0,1,1, 0,0,1,1, 0,1,1,1}, - {0,0,0,0, 0,0,0,1, 0,0,0,1, 0,0,1,1}, {0,0,1,1, 0,1,1,1, 0,1,1,1, 1,1,1,1}, {0,0,0,1, 0,0,1,1, 0,1,1,1, 1,1,1,1}, {0,0,0,0, 0,0,0,1, 0,0,1,1, 0,1,1,1}, - {0,0,0,0, 0,0,0,0, 0,0,0,1, 0,0,1,1}, {0,0,1,1, 0,1,1,1, 1,1,1,1, 1,1,1,1}, {0,0,0,0, 0,0,0,1, 0,1,1,1, 1,1,1,1}, {0,0,0,0, 0,0,0,0, 0,0,0,1, 0,1,1,1}, - {0,0,0,1, 0,1,1,1, 1,1,1,1, 1,1,1,1}, {0,0,0,0, 0,0,0,0, 1,1,1,1, 1,1,1,1}, {0,0,0,0, 1,1,1,1, 1,1,1,1, 1,1,1,1}, {0,0,0,0, 0,0,0,0, 0,0,0,0, 1,1,1,1}, - {0,0,0,0, 1,0,0,0, 1,1,1,0, 1,1,1,1}, {0,1,1,1, 0,0,0,1, 0,0,0,0, 0,0,0,0}, {0,0,0,0, 0,0,0,0, 1,0,0,0, 1,1,1,0}, {0,1,1,1, 0,0,1,1, 0,0,0,1, 0,0,0,0}, - {0,0,1,1, 0,0,0,1, 0,0,0,0, 0,0,0,0}, {0,0,0,0, 1,0,0,0, 1,1,0,0, 1,1,1,0}, {0,0,0,0, 0,0,0,0, 1,0,0,0, 1,1,0,0}, {0,1,1,1, 0,0,1,1, 0,0,1,1, 0,0,0,1}, - {0,0,1,1, 0,0,0,1, 0,0,0,1, 0,0,0,0}, {0,0,0,0, 1,0,0,0, 1,0,0,0, 1,1,0,0}, {0,1,1,0, 0,1,1,0, 0,1,1,0, 0,1,1,0}, {0,0,1,1, 0,1,1,0, 0,1,1,0, 1,1,0,0}, - {0,0,0,1, 0,1,1,1, 1,1,1,0, 1,0,0,0}, {0,0,0,0, 1,1,1,1, 1,1,1,1, 0,0,0,0}, {0,1,1,1, 0,0,0,1, 1,0,0,0, 1,1,1,0}, {0,0,1,1, 1,0,0,1, 1,0,0,1, 1,1,0,0} -};*/ - -static const uint candidateSectionBit[32] = -{ - 0xCCCC, 0x8888, 0xEEEE, 0xECC8, - 0xC880, 0xFEEC, 0xFEC8, 0xEC80, - 0xC800, 0xFFEC, 0xFE80, 0xE800, - 0xFFE8, 0xFF00, 0xFFF0, 0xF000, - 0xF710, 0x008E, 0x7100, 0x08CE, - 0x008C, 0x7310, 0x3100, 0x8CCE, - 0x088C, 0x3110, 0x6666, 0x366C, - 0x17E8, 0x0FF0, 0x718E, 0x399C -}; - -static const uint candidateFixUpIndex1D[32] = -{ - 15,15,15,15, - 15,15,15,15, - 15,15,15,15, - 15,15,15,15, - 15, 2, 8, 2, - 2, 8, 8,15, - 2, 8, 2, 2, - 8, 8, 2, 2 -}; - -//0, 9, 18, 27, 37, 46, 55, 64 -static const uint aStep1[64] = { 0,0,0,0,0,1,1,1, - 1,1,1,1,1,1,2,2, - 2,2,2,2,2,2,2,3, - 3,3,3,3,3,3,3,3, - 3,4,4,4,4,4,4,4, - 4,4,5,5,5,5,5,5, - 5,5,5,6,6,6,6,6, - 6,6,6,6,7,7,7,7 }; - -//0, 4, 9, 13, 17, 21, 26, 30, 34, 38, 43, 47, 51, 55, 60, 64 -static const uint aStep2[64] = { 0, 0, 0, 1, 1, 1, 1, 2, - 2, 2, 2, 2, 3, 3, 3, 3, - 4, 4, 4, 4, 5, 5, 5, 5, - 6, 6, 6, 6, 6, 7, 7, 7, - 7, 8, 8, 8, 8, 9, 9, 9, - 9,10,10,10,10,10,11,11, - 11,11,12,12,12,12,13,13, - 13,13,14,14,14,14,15,15 }; - -static const float3 RGB2LUM = float3(0.2126f, 0.7152f, 0.0722f); - -#define THREAD_GROUP_SIZE 64 -#define BLOCK_SIZE_Y 4 -#define BLOCK_SIZE_X 4 -#define BLOCK_SIZE (BLOCK_SIZE_Y * BLOCK_SIZE_X) - - -//Forward declaration -uint3 float2half(float3 pixel_f); -int3 start_quantize(uint3 pixel_h); -void quantize(inout int2x3 endPoint, uint prec); -void finish_quantize_0(inout int bBadQuantize, inout int2x3 endPoint, uint4 prec, bool transformed); -void finish_quantize_1(inout int bBadQuantize, inout int2x3 endPoint, uint4 prec, bool transformed); -void finish_quantize(out bool bBadQuantize, inout int2x3 endPoint, uint4 prec, bool transformed); - -void start_unquantize(inout int2x3 endPoint[2], uint4 prec, bool transformed); -void start_unquantize(inout int2x3 endPoint, uint4 prec, bool transformed); -void unquantize(inout int2x3 color, uint prec); -uint3 finish_unquantize(int3 color); -void generate_palette_unquantized8(out uint3 palette, int3 low, int3 high, int i); -void generate_palette_unquantized16(out uint3 palette, int3 low, int3 high, int i); -float3 half2float(uint3 color_h); - -void block_package(inout uint4 block, int2x3 endPoint[2], uint mode_type, uint partition_index); -void block_package(inout uint4 block, int2x3 endPoint, uint mode_type); - -void swap(inout int3 lhs, inout int3 rhs) -{ - int3 tmp = lhs; - lhs = rhs; - rhs = tmp; -} - -Texture2D g_Input : register(t0); -StructuredBuffer g_InBuff : register(t1); - -RWStructuredBuffer g_OutBuff : register(u0); - -struct SharedData -{ - float3 pixel; - int3 pixel_ph; - float3 pixel_hr; - float pixel_lum; - float error; - uint best_mode; - uint best_partition; - int3 endPoint_low; - int3 endPoint_high; - float endPoint_lum_low; - float endPoint_lum_high; -}; - -groupshared SharedData shared_temp[THREAD_GROUP_SIZE]; - -[numthreads(THREAD_GROUP_SIZE, 1, 1)] -void TryModeG10CS(uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID) -{ - const uint MAX_USED_THREAD = 16; - uint BLOCK_IN_GROUP = THREAD_GROUP_SIZE / MAX_USED_THREAD; - uint blockInGroup = GI / MAX_USED_THREAD; - uint blockID = g_start_block_id + groupID.x * BLOCK_IN_GROUP + blockInGroup; - uint threadBase = blockInGroup * MAX_USED_THREAD; - uint threadInBlock = GI - threadBase; - -#ifndef REF_DEVICE - if (blockID >= g_num_total_blocks) - { - return; - } -#endif - - uint block_y = blockID / g_num_block_x; - uint block_x = blockID - block_y * g_num_block_x; - uint base_x = block_x * BLOCK_SIZE_X; - uint base_y = block_y * BLOCK_SIZE_Y; - - if (threadInBlock < 16) - { - shared_temp[GI].pixel = g_Input.Load(uint3(base_x + threadInBlock % 4, base_y + threadInBlock / 4, 0)).rgb; - uint3 pixel_h = float2half(shared_temp[GI].pixel); - shared_temp[GI].pixel_hr = half2float(pixel_h); - shared_temp[GI].pixel_lum = dot(shared_temp[GI].pixel_hr, RGB2LUM); - shared_temp[GI].pixel_ph = start_quantize(pixel_h); - - shared_temp[GI].endPoint_low = shared_temp[GI].pixel_ph; - shared_temp[GI].endPoint_high = shared_temp[GI].pixel_ph; - shared_temp[GI].endPoint_lum_low = shared_temp[GI].pixel_lum; - shared_temp[GI].endPoint_lum_high = shared_temp[GI].pixel_lum; - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - - if (threadInBlock < 8) - { - if (shared_temp[GI].endPoint_lum_low > shared_temp[GI + 8].endPoint_lum_low) - { - shared_temp[GI].endPoint_low = shared_temp[GI + 8].endPoint_low; - shared_temp[GI].endPoint_lum_low = shared_temp[GI + 8].endPoint_lum_low; - } - if (shared_temp[GI].endPoint_lum_high < shared_temp[GI + 8].endPoint_lum_high) - { - shared_temp[GI].endPoint_high = shared_temp[GI + 8].endPoint_high; - shared_temp[GI].endPoint_lum_high = shared_temp[GI + 8].endPoint_lum_high; - } - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 4) - { - if (shared_temp[GI].endPoint_lum_low > shared_temp[GI + 4].endPoint_lum_low) - { - shared_temp[GI].endPoint_low = shared_temp[GI + 4].endPoint_low; - shared_temp[GI].endPoint_lum_low = shared_temp[GI + 4].endPoint_lum_low; - } - if (shared_temp[GI].endPoint_lum_high < shared_temp[GI + 4].endPoint_lum_high) - { - shared_temp[GI].endPoint_high = shared_temp[GI + 4].endPoint_high; - shared_temp[GI].endPoint_lum_high = shared_temp[GI + 4].endPoint_lum_high; - } - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 2) - { - if (shared_temp[GI].endPoint_lum_low > shared_temp[GI + 2].endPoint_lum_low) - { - shared_temp[GI].endPoint_low = shared_temp[GI + 2].endPoint_low; - shared_temp[GI].endPoint_lum_low = shared_temp[GI + 2].endPoint_lum_low; - } - if (shared_temp[GI].endPoint_lum_high < shared_temp[GI + 2].endPoint_lum_high) - { - shared_temp[GI].endPoint_high = shared_temp[GI + 2].endPoint_high; - shared_temp[GI].endPoint_lum_high = shared_temp[GI + 2].endPoint_lum_high; - } - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 1) - { - if (shared_temp[GI].endPoint_lum_low > shared_temp[GI + 1].endPoint_lum_low) - { - shared_temp[GI].endPoint_low = shared_temp[GI + 1].endPoint_low; - shared_temp[GI].endPoint_lum_low = shared_temp[GI + 1].endPoint_lum_low; - } - if (shared_temp[GI].endPoint_lum_high < shared_temp[GI + 1].endPoint_lum_high) - { - shared_temp[GI].endPoint_high = shared_temp[GI + 1].endPoint_high; - shared_temp[GI].endPoint_lum_high = shared_temp[GI + 1].endPoint_lum_high; - } - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - - //ergod mode_type 11:14 - if (threadInBlock == 0) - { - int2x3 endPoint; - // find_axis - endPoint[0] = shared_temp[threadBase + 0].endPoint_low; - endPoint[1] = shared_temp[threadBase + 0].endPoint_high; - - //compute_index - float3 span = endPoint[1] - endPoint[0];// fixed a bug in v0.2 - float span_norm_sqr = dot(span, span);// fixed a bug in v0.2 - float dotProduct = dot(span, shared_temp[threadBase + 0].pixel_ph - endPoint[0]);// fixed a bug in v0.2 - if (span_norm_sqr > 0 && dotProduct >= 0 && uint(dotProduct * 63.49999 / span_norm_sqr) > 32) - { - swap(endPoint[0], endPoint[1]); - - shared_temp[GI].endPoint_low = endPoint[0]; - shared_temp[GI].endPoint_high = endPoint[1]; - } - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - - if (threadInBlock < 4) - { - int2x3 endPoint; - endPoint[0] = shared_temp[threadBase + 0].endPoint_low; - endPoint[1] = shared_temp[threadBase + 0].endPoint_high; - - float3 span = endPoint[1] - endPoint[0]; - float span_norm_sqr = dot(span, span); - - uint4 prec = candidateModePrec[threadInBlock + 10]; - int2x3 endPoint_q = endPoint; - quantize(endPoint_q, prec.x); - - bool transformed = candidateModeTransformed[threadInBlock + 10]; - if (transformed) - { - endPoint_q[1] -= endPoint_q[0]; - } - - bool bBadQuantize; - finish_quantize(bBadQuantize, endPoint_q, prec, transformed); - - start_unquantize(endPoint_q, prec, transformed); - - unquantize(endPoint_q, prec.x); - - float error = 0; - [loop] for (uint j = 0; j < 16; j++) - { - float dotProduct = dot(span, shared_temp[threadBase + j].pixel_ph - endPoint[0]);// fixed a bug in v0.2 - uint index = (span_norm_sqr <= 0 || dotProduct <= 0) ? 0 - : ((dotProduct < span_norm_sqr) ? aStep2[uint(dotProduct * 63.49999 / span_norm_sqr)] : aStep2[63]); - - uint3 pixel_rh; - generate_palette_unquantized16(pixel_rh, endPoint_q[0], endPoint_q[1], index); - float3 pixel_r = half2float(pixel_rh); - pixel_r -= shared_temp[threadBase + j].pixel_hr; - error += dot(pixel_r, pixel_r); - } - if (bBadQuantize) - error = 1e20f; - - shared_temp[GI].error = error; - shared_temp[GI].best_mode = candidateModeFlag[threadInBlock + 10]; - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - - if (threadInBlock < 2) - { - if (shared_temp[GI].error > shared_temp[GI + 2].error) - { - shared_temp[GI].error = shared_temp[GI + 2].error; - shared_temp[GI].best_mode = shared_temp[GI + 2].best_mode; - } - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 1) - { - if (shared_temp[GI].error > shared_temp[GI + 1].error) - { - shared_temp[GI].error = shared_temp[GI + 1].error; - shared_temp[GI].best_mode = shared_temp[GI + 1].best_mode; - } - - g_OutBuff[blockID] = uint4(asuint(shared_temp[GI].error), shared_temp[GI].best_mode, 0, 0); - } -} - -[numthreads(THREAD_GROUP_SIZE, 1, 1)] -void TryModeLE10CS(uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID) -{ - const uint MAX_USED_THREAD = 32; - uint BLOCK_IN_GROUP = THREAD_GROUP_SIZE / MAX_USED_THREAD; - uint blockInGroup = GI / MAX_USED_THREAD; - uint blockID = g_start_block_id + groupID.x * BLOCK_IN_GROUP + blockInGroup; - uint threadBase = blockInGroup * MAX_USED_THREAD; - uint threadInBlock = GI - threadBase; - -#ifndef REF_DEVICE - if (blockID >= g_num_total_blocks) - { - return; - } - - if (asfloat(g_InBuff[blockID].x) < 1e-6f) - { - g_OutBuff[blockID] = g_InBuff[blockID]; - return; - } -#endif - - uint block_y = blockID / g_num_block_x; - uint block_x = blockID - block_y * g_num_block_x; - uint base_x = block_x * BLOCK_SIZE_X; - uint base_y = block_y * BLOCK_SIZE_Y; - - if (threadInBlock < 16) - { - shared_temp[GI].pixel = g_Input.Load(uint3(base_x + threadInBlock % 4, base_y + threadInBlock / 4, 0)).rgb; - uint3 pixel_h = float2half(shared_temp[GI].pixel); - shared_temp[GI].pixel_hr = half2float(pixel_h); - shared_temp[GI].pixel_lum = dot(shared_temp[GI].pixel_hr, RGB2LUM); - shared_temp[GI].pixel_ph = start_quantize(pixel_h); - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - - //ergod mode_type 1:10 - if (threadInBlock < 32) - { - // find_axis - int2x3 endPoint[2]; - endPoint[0][0] = MAX_INT; - endPoint[0][1] = MIN_INT; - endPoint[1][0] = MAX_INT; - endPoint[1][1] = MIN_INT; - - float2 endPoint_lum[2]; - endPoint_lum[0][0] = MAX_FLOAT; - endPoint_lum[0][1] = MIN_FLOAT; - endPoint_lum[1][0] = MAX_FLOAT; - endPoint_lum[1][1] = MIN_FLOAT; - - uint bit = candidateSectionBit[threadInBlock]; - for (uint i = 0; i < 16; i++) - { - int3 pixel_ph = shared_temp[threadBase + i].pixel_ph; - float pixel_lum = shared_temp[threadBase + i].pixel_lum; - if ((bit >> i) & 1) //It gets error when using "candidateSection" as "endPoint_ph" index - { - if (endPoint_lum[1][0] > pixel_lum) - { - endPoint[1][0] = pixel_ph; - endPoint_lum[1][0] = pixel_lum; - } - if (endPoint_lum[1][1] < pixel_lum) - { - endPoint[1][1] = pixel_ph; - endPoint_lum[1][1] = pixel_lum; - } - } - else - { - if (endPoint_lum[0][0] > pixel_lum) - { - endPoint[0][0] = pixel_ph; - endPoint_lum[0][0] = pixel_lum; - } - if (endPoint_lum[0][1] < pixel_lum) - { - endPoint[0][1] = pixel_ph; - endPoint_lum[0][1] = pixel_lum; - } - } - } - - //compute_index - float3 span[2];// fixed a bug in v0.2 - float span_norm_sqr[2];// fixed a bug in v0.2 - [unroll] - for (uint p = 0; p < 2; ++p) - { - span[p] = endPoint[p][1] - endPoint[p][0]; - span_norm_sqr[p] = dot(span[p], span[p]); - - float dotProduct = dot(span[p], shared_temp[threadBase + (0 == p ? 0 : candidateFixUpIndex1D[threadInBlock])].pixel_ph - endPoint[p][0]);// fixed a bug in v0.2 - if (span_norm_sqr[p] > 0 && dotProduct >= 0 && uint(dotProduct * 63.49999 / span_norm_sqr[p]) > 32) - { - span[p] = -span[p]; - swap(endPoint[p][0], endPoint[p][1]); - } - } - - uint4 prec = candidateModePrec[g_mode_id]; - int2x3 endPoint_q[2] = endPoint; - quantize(endPoint_q[0], prec.x); - quantize(endPoint_q[1], prec.x); - - bool transformed = candidateModeTransformed[g_mode_id]; - if (transformed) - { - endPoint_q[0][1] -= endPoint_q[0][0]; - endPoint_q[1][0] -= endPoint_q[0][0]; - endPoint_q[1][1] -= endPoint_q[0][0]; - } - - int bBadQuantize = 0; - finish_quantize_0(bBadQuantize, endPoint_q[0], prec, transformed); - finish_quantize_1(bBadQuantize, endPoint_q[1], prec, transformed); - - start_unquantize(endPoint_q, prec, transformed); - - unquantize(endPoint_q[0], prec.x); - unquantize(endPoint_q[1], prec.x); - - float error = 0; - for (uint j = 0; j < 16; j++) - { - uint3 pixel_rh; - if ((bit >> j) & 1) - { - float dotProduct = dot(span[1], shared_temp[threadBase + j].pixel_ph - endPoint[1][0]);// fixed a bug in v0.2 - uint index = (span_norm_sqr[1] <= 0 || dotProduct <= 0) ? 0 - : ((dotProduct < span_norm_sqr[1]) ? aStep1[uint(dotProduct * 63.49999 / span_norm_sqr[1])] : aStep1[63]); - generate_palette_unquantized8(pixel_rh, endPoint_q[1][0], endPoint_q[1][1], index); - } - else - { - float dotProduct = dot(span[0], shared_temp[threadBase + j].pixel_ph - endPoint[0][0]);// fixed a bug in v0.2 - uint index = (span_norm_sqr[0] <= 0 || dotProduct <= 0) ? 0 - : ((dotProduct < span_norm_sqr[0]) ? aStep1[uint(dotProduct * 63.49999 / span_norm_sqr[0])] : aStep1[63]); - generate_palette_unquantized8(pixel_rh, endPoint_q[0][0], endPoint_q[0][1], index); - } - - float3 pixel_r = half2float(pixel_rh); - pixel_r -= shared_temp[threadBase + j].pixel_hr; - error += dot(pixel_r, pixel_r); - } - if (bBadQuantize) - error = 1e20f; - - shared_temp[GI].error = error; - shared_temp[GI].best_mode = candidateModeFlag[g_mode_id]; - shared_temp[GI].best_partition = threadInBlock; - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - - if (threadInBlock < 16) - { - if (shared_temp[GI].error > shared_temp[GI + 16].error) - { - shared_temp[GI].error = shared_temp[GI + 16].error; - shared_temp[GI].best_mode = shared_temp[GI + 16].best_mode; - shared_temp[GI].best_partition = shared_temp[GI + 16].best_partition; - } - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 8) - { - if (shared_temp[GI].error > shared_temp[GI + 8].error) - { - shared_temp[GI].error = shared_temp[GI + 8].error; - shared_temp[GI].best_mode = shared_temp[GI + 8].best_mode; - shared_temp[GI].best_partition = shared_temp[GI + 8].best_partition; - } - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 4) - { - if (shared_temp[GI].error > shared_temp[GI + 4].error) - { - shared_temp[GI].error = shared_temp[GI + 4].error; - shared_temp[GI].best_mode = shared_temp[GI + 4].best_mode; - shared_temp[GI].best_partition = shared_temp[GI + 4].best_partition; - } - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 2) - { - if (shared_temp[GI].error > shared_temp[GI + 2].error) - { - shared_temp[GI].error = shared_temp[GI + 2].error; - shared_temp[GI].best_mode = shared_temp[GI + 2].best_mode; - shared_temp[GI].best_partition = shared_temp[GI + 2].best_partition; - } - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 1) - { - if (shared_temp[GI].error > shared_temp[GI + 1].error) - { - shared_temp[GI].error = shared_temp[GI + 1].error; - shared_temp[GI].best_mode = shared_temp[GI + 1].best_mode; - shared_temp[GI].best_partition = shared_temp[GI + 1].best_partition; - } - - if (asfloat(g_InBuff[blockID].x) > shared_temp[GI].error) - { - g_OutBuff[blockID] = uint4(asuint(shared_temp[GI].error), shared_temp[GI].best_mode, shared_temp[GI].best_partition, 0); - } - else - { - g_OutBuff[blockID] = g_InBuff[blockID]; - } - } -} - -[numthreads(THREAD_GROUP_SIZE, 1, 1)] -void EncodeBlockCS(uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID) -{ - const uint MAX_USED_THREAD = 32; - uint BLOCK_IN_GROUP = THREAD_GROUP_SIZE / MAX_USED_THREAD; - uint blockInGroup = GI / MAX_USED_THREAD; - uint blockID = g_start_block_id + groupID.x * BLOCK_IN_GROUP + blockInGroup; - uint threadBase = blockInGroup * MAX_USED_THREAD; - uint threadInBlock = GI - threadBase; - -#ifndef REF_DEVICE - if (blockID >= g_num_total_blocks) - { - return; - } -#endif - - uint block_y = blockID / g_num_block_x; - uint block_x = blockID - block_y * g_num_block_x; - uint base_x = block_x * BLOCK_SIZE_X; - uint base_y = block_y * BLOCK_SIZE_Y; - - if (threadInBlock < 16) - { - shared_temp[GI].pixel = g_Input.Load(uint3(base_x + threadInBlock % 4, base_y + threadInBlock / 4, 0)).rgb; - shared_temp[GI].pixel_lum = dot(shared_temp[GI].pixel, RGB2LUM); - uint3 pixel_h = float2half(shared_temp[GI].pixel); - shared_temp[GI].pixel_ph = start_quantize(pixel_h); - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - - uint best_mode = g_InBuff[blockID].y; - uint best_partition = g_InBuff[blockID].z; - - uint4 block = 0; - - if (threadInBlock < 32) - { - int2x3 endPoint; - endPoint[0] = MAX_INT; - endPoint[1] = MIN_INT; - - float2 endPoint_lum; - endPoint_lum[0] = MAX_FLOAT; - endPoint_lum[1] = MIN_FLOAT; - - int2 endPoint_lum_index; - endPoint_lum_index[0] = -1; - endPoint_lum_index[1] = -1; - - int3 pixel_ph = shared_temp[threadBase + (threadInBlock & 0xF)].pixel_ph; - float pixel_lum = shared_temp[threadBase + (threadInBlock & 0xF)].pixel_lum; - if (threadInBlock < 16) - { - if (best_mode > 10) - { - endPoint[0] = endPoint[1] = pixel_ph; - endPoint_lum[0] = endPoint_lum[1] = pixel_lum; - } - else - { - uint bits = candidateSectionBit[best_partition]; - if (0 == ((bits >> threadInBlock) & 1)) - { - endPoint[0] = endPoint[1] = pixel_ph; - endPoint_lum[0] = endPoint_lum[1] = pixel_lum; - } - } - } - else - { - if (best_mode <= 10) - { - uint bits = candidateSectionBit[best_partition]; - if (1 == ((bits >> (threadInBlock & 0xF)) & 1)) - { - endPoint[0] = endPoint[1] = pixel_ph; - endPoint_lum[0] = endPoint_lum[1] = pixel_lum; - } - } - } - - shared_temp[GI].endPoint_low = endPoint[0]; - shared_temp[GI].endPoint_high = endPoint[1]; - - shared_temp[GI].endPoint_lum_low = endPoint_lum[0]; - shared_temp[GI].endPoint_lum_high = endPoint_lum[1]; - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if ((threadInBlock & 0xF) < 8) - { - if (shared_temp[GI].endPoint_lum_low > shared_temp[GI + 8].endPoint_lum_low) - { - shared_temp[GI].endPoint_low = shared_temp[GI + 8].endPoint_low; - shared_temp[GI].endPoint_lum_low = shared_temp[GI + 8].endPoint_lum_low; - } - if (shared_temp[GI].endPoint_lum_high < shared_temp[GI + 8].endPoint_lum_high) - { - shared_temp[GI].endPoint_high = shared_temp[GI + 8].endPoint_high; - shared_temp[GI].endPoint_lum_high = shared_temp[GI + 8].endPoint_lum_high; - } - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if ((threadInBlock & 0xF) < 4) - { - if (shared_temp[GI].endPoint_lum_low > shared_temp[GI + 4].endPoint_lum_low) - { - shared_temp[GI].endPoint_low = shared_temp[GI + 4].endPoint_low; - shared_temp[GI].endPoint_lum_low = shared_temp[GI + 4].endPoint_lum_low; - } - if (shared_temp[GI].endPoint_lum_high < shared_temp[GI + 4].endPoint_lum_high) - { - shared_temp[GI].endPoint_high = shared_temp[GI + 4].endPoint_high; - shared_temp[GI].endPoint_lum_high = shared_temp[GI + 4].endPoint_lum_high; - } - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if ((threadInBlock & 0xF) < 2) - { - if (shared_temp[GI].endPoint_lum_low > shared_temp[GI + 2].endPoint_lum_low) - { - shared_temp[GI].endPoint_low = shared_temp[GI + 2].endPoint_low; - shared_temp[GI].endPoint_lum_low = shared_temp[GI + 2].endPoint_lum_low; - } - if (shared_temp[GI].endPoint_lum_high < shared_temp[GI + 2].endPoint_lum_high) - { - shared_temp[GI].endPoint_high = shared_temp[GI + 2].endPoint_high; - shared_temp[GI].endPoint_lum_high = shared_temp[GI + 2].endPoint_lum_high; - } - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if ((threadInBlock & 0xF) < 1) - { - if (shared_temp[GI].endPoint_lum_low > shared_temp[GI + 1].endPoint_lum_low) - { - shared_temp[GI].endPoint_low = shared_temp[GI + 1].endPoint_low; - shared_temp[GI].endPoint_lum_low = shared_temp[GI + 1].endPoint_lum_low; - } - if (shared_temp[GI].endPoint_lum_high < shared_temp[GI + 1].endPoint_lum_high) - { - shared_temp[GI].endPoint_high = shared_temp[GI + 1].endPoint_high; - shared_temp[GI].endPoint_lum_high = shared_temp[GI + 1].endPoint_lum_high; - } - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - - if (threadInBlock < 2) - { - // find_axis - int2x3 endPoint; - endPoint[0] = shared_temp[threadBase + threadInBlock * 16].endPoint_low; - endPoint[1] = shared_temp[threadBase + threadInBlock * 16].endPoint_high; - - uint fixup = 0; - if ((1 == threadInBlock) && (best_mode <= 10)) - { - fixup = candidateFixUpIndex1D[best_partition]; - } - - float3 span = endPoint[1] - endPoint[0]; - float span_norm_sqr = dot(span, span); - float dotProduct = dot(span, shared_temp[threadBase + fixup].pixel_ph - endPoint[0]); - if (span_norm_sqr > 0 && dotProduct >= 0 && uint(dotProduct * 63.49999 / span_norm_sqr) > 32) - { - swap(endPoint[0], endPoint[1]); - } - - shared_temp[GI].endPoint_low = endPoint[0]; - shared_temp[GI].endPoint_high = endPoint[1]; - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - - if (threadInBlock < 16) - { - uint bits; - if (best_mode > 10) - { - bits = 0; - } - else - { - bits = candidateSectionBit[best_partition]; - } - - float3 span; - float dotProduct; - if ((bits >> threadInBlock) & 1) - { - span = shared_temp[threadBase + 1].endPoint_high - shared_temp[threadBase + 1].endPoint_low; - dotProduct = dot(span, shared_temp[threadBase + threadInBlock].pixel_ph - shared_temp[threadBase + 1].endPoint_low); - } - else - { - span = shared_temp[threadBase + 0].endPoint_high - shared_temp[threadBase + 0].endPoint_low; - dotProduct = dot(span, shared_temp[threadBase + threadInBlock].pixel_ph - shared_temp[threadBase + 0].endPoint_low); - } - float span_norm_sqr = dot(span, span); - - if (best_mode > 10) - { - uint index = (span_norm_sqr <= 0 || dotProduct <= 0) ? 0 - : ((dotProduct < span_norm_sqr) ? aStep2[uint(dotProduct * 63.49999 / span_norm_sqr)] : aStep2[63]); - if (threadInBlock == 0) - { - block.z |= index << 1; - } - else if (threadInBlock < 8) - { - block.z |= index << (threadInBlock * 4); - } - else - { - block.w |= index << ((threadInBlock - 8) * 4); - } - } - else - { - uint index = (span_norm_sqr <= 0 || dotProduct <= 0) ? 0 - : ((dotProduct < span_norm_sqr) ? aStep1[uint(dotProduct * 63.49999 / span_norm_sqr)] : aStep1[63]); - - uint fixup = candidateFixUpIndex1D[best_partition]; - int2 offset = int2((fixup != 2), (fixup == 15)); - - if (threadInBlock == 0) - { - block.z |= index << 18; - } - else if (threadInBlock < 3) - { - block.z |= index << (20 + (threadInBlock - 1) * 3); - } - else if (threadInBlock < 5) - { - block.z |= index << (25 + (threadInBlock - 3) * 3 + offset.x); - } - else if (threadInBlock == 5) - { - block.w |= index >> !offset.x; - if (!offset.x) - { - block.z |= index << 31; - } - } - else if (threadInBlock < 9) - { - block.w |= index << (2 + (threadInBlock - 6) * 3 + offset.x); - } - else - { - block.w |= index << (11 + (threadInBlock - 9) * 3 + offset.y); - } - } - - shared_temp[GI].pixel_hr.xy = asfloat(block.zw); - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 8) - { - shared_temp[GI].pixel_hr.xy = asfloat(asuint(shared_temp[GI].pixel_hr.xy) | asuint(shared_temp[GI + 8].pixel_hr.xy)); - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 4) - { - shared_temp[GI].pixel_hr.xy = asfloat(asuint(shared_temp[GI].pixel_hr.xy) | asuint(shared_temp[GI + 4].pixel_hr.xy)); - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 2) - { - shared_temp[GI].pixel_hr.xy = asfloat(asuint(shared_temp[GI].pixel_hr.xy) | asuint(shared_temp[GI + 2].pixel_hr.xy)); - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 1) - { - shared_temp[GI].pixel_hr.xy = asfloat(asuint(shared_temp[GI].pixel_hr.xy) | asuint(shared_temp[GI + 1].pixel_hr.xy)); - - block.zw = asuint(shared_temp[GI].pixel_hr.xy); - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - - bool transformed = candidateModeTransformed[best_mode - 1]; - uint4 prec = candidateModePrec[best_mode - 1]; - if (threadInBlock == 2) - { - int2x3 endPoint_q; - endPoint_q[0] = shared_temp[threadBase + 0].endPoint_low; - endPoint_q[1] = shared_temp[threadBase + 0].endPoint_high; - - quantize(endPoint_q, prec.x); - if (transformed) - { - endPoint_q[1] -= endPoint_q[0]; - } - - shared_temp[GI].endPoint_low = endPoint_q[0]; - shared_temp[GI].endPoint_high = endPoint_q[1]; - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock == 3) - { - int3 ep0 = shared_temp[threadBase + 2].endPoint_low; - int2x3 endPoint_q; - endPoint_q[0] = shared_temp[threadBase + 1].endPoint_low; - endPoint_q[1] = shared_temp[threadBase + 1].endPoint_high; - - if (best_mode <= 10) - { - quantize(endPoint_q, prec.x); - if (transformed) - { - endPoint_q[0] -= ep0; - endPoint_q[1] -= ep0; - } - - shared_temp[GI].endPoint_low = endPoint_q[0]; - shared_temp[GI].endPoint_high = endPoint_q[1]; - } - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - - if (threadInBlock < 2) - { - int2x3 endPoint_q; - endPoint_q[0] = shared_temp[threadBase + threadInBlock + 2].endPoint_low; - endPoint_q[1] = shared_temp[threadBase + threadInBlock + 2].endPoint_high; - - int bBadQuantize = 0; - if (threadInBlock == 0) - { - if (best_mode > 10) - { - finish_quantize(bBadQuantize, endPoint_q, prec, transformed); - } - else - { - finish_quantize_0(bBadQuantize, endPoint_q, prec, transformed); - } - } - else // if (threadInBlock == 1) - { - if (best_mode <= 10) - { - finish_quantize_1(bBadQuantize, endPoint_q, prec, transformed); - } - } - - shared_temp[GI].endPoint_low = endPoint_q[0]; - shared_temp[GI].endPoint_high = endPoint_q[1]; - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - - if (threadInBlock == 0) - { - int2x3 endPoint_q[2]; - endPoint_q[0][0] = shared_temp[threadBase + 0].endPoint_low; - endPoint_q[0][1] = shared_temp[threadBase + 0].endPoint_high; - endPoint_q[1][0] = shared_temp[threadBase + 1].endPoint_low; - endPoint_q[1][1] = shared_temp[threadBase + 1].endPoint_high; - - if (best_mode > 10) - { - block_package(block, endPoint_q[0], best_mode); - } - else - { - block_package(block, endPoint_q, best_mode, best_partition); - } - - g_OutBuff[blockID] = block; - } -} - -uint float2half1(float f) -{ - uint Result; - - uint IValue = asuint(f); - uint Sign = (IValue & 0x80000000U) >> 16U; - IValue = IValue & 0x7FFFFFFFU; - - if (IValue > 0x47FFEFFFU) - { - // The number is too large to be represented as a half. Saturate to infinity. - Result = 0x7FFFU; - } - else - { - if (IValue < 0x38800000U) - { - // The number is too small to be represented as a normalized half. - // Convert it to a denormalized value. - uint Shift = 113U - (IValue >> 23U); - IValue = (0x800000U | (IValue & 0x7FFFFFU)) >> Shift; - } - else - { - // Rebias the exponent to represent the value as a normalized half. - IValue += 0xC8000000U; - } - - Result = ((IValue + 0x0FFFU + ((IValue >> 13U) & 1U)) >> 13U)&0x7FFFU; - } - return (Result|Sign); -} - -uint3 float2half(float3 endPoint_f) -{ - //uint3 sign = asuint(endPoint_f) & 0x80000000; - //uint3 expo = asuint(endPoint_f) & 0x7F800000; - //uint3 base = asuint(endPoint_f) & 0x007FFFFF; - //return ( expo < 0x33800000 ) ? 0 - // //0x33800000 indicating 2^-24, which is minimal denormalized number that half can present - // : ( ( expo < 0x38800000 ) ? ( sign >> 16 ) | ( ( base + 0x00800000 ) >> ( 23 - ( ( expo - 0x33800000 ) >> 23 ) ) )//fixed a bug in v0.2 - // //0x38800000 indicating 2^-14, which is minimal normalized number that half can present, so need to use denormalized half presentation - // : ( ( expo == 0x7F800000 || expo > 0x47000000 ) ? ( ( sign >> 16 ) | 0x7bff ) - // // treat NaN as INF, treat INF (including NaN) as the maximum/minimum number that half can present - // // 0x47000000 indicating 2^15, which is maximum exponent that half can present, so cut to 0x7bff which is the maximum half number - // : ( ( sign >> 16 ) | ( ( ( expo - 0x38000000 ) | base ) >> 13 ) ) ) ); - - - return uint3(float2half1(endPoint_f.x), float2half1(endPoint_f.y), float2half1(endPoint_f.z)); -} -int3 start_quantize(uint3 pixel_h) -{ - if (g_format == UNSIGNED_F16) - { - return asint((pixel_h << 6) / 31); - } - else - { - return (pixel_h < 0x8000) ? ((pixel_h == 0x7bff) ? 0x7fff : asint((pixel_h << 5) / 31))// fixed a bug in v0.2 - : ((pixel_h == 0x7bff) ? 0xffff8001 : -asint(((0x00007fff & pixel_h) << 5) / 31));// fixed a bug in v0.2 - } -} -void quantize(inout int2x3 endPoint, uint prec) -{ - int iprec = asint(prec); - if (g_format == UNSIGNED_F16) - { - endPoint = ((iprec >= 15) | (endPoint == 0)) ? endPoint - : ((endPoint == asint(0xFFFF)) ? ((1 << iprec) - 1) - : (((endPoint << iprec) + asint(0x0000)) >> 16)); - } - else - { - endPoint = ((iprec >= 16) | (endPoint == 0)) ? endPoint - : ((endPoint >= 0) ? ((endPoint == asint(0x7FFF)) ? ((1 << (iprec - 1)) - 1) : (((endPoint << (iprec - 1)) + asint(0x0000)) >> 15)) - : ((-endPoint == asint(0x7FFF)) ? -((1 << (iprec - 1)) - 1) : -(((-endPoint << (iprec - 1)) + asint(0x0000)) >> 15))); - } -} -void finish_quantize_0(inout int bBadQuantize, inout int2x3 endPoint, uint4 prec, bool transformed) -{ - if (transformed) - { - bool3 bBadComponent = (endPoint[1] >= 0) ? (endPoint[1] >= (1 << (prec.yzw - 1))) - : (-endPoint[1] > (1 << (prec.yzw - 1))); - bBadQuantize |= any(bBadComponent); - - endPoint[0] = endPoint[0] & ((1 << prec.x) - 1); - endPoint[1] = (endPoint[1] >= 0) ? ((endPoint[1] >= (1 << (prec.yzw - 1))) ? ((1 << (prec.yzw - 1)) - 1) : endPoint[1]) - : ((-endPoint[1] > (1 << (prec.yzw - 1))) ? (1 << (prec.yzw - 1)) : (endPoint[1] & ((1 << prec.yzw) - 1))); - } - else - { - endPoint &= ((1 << prec.x) - 1); - } -} -void finish_quantize_1(inout int bBadQuantize, inout int2x3 endPoint, uint4 prec, bool transformed) -{ - if (transformed) - { - bool2x3 bBadComponent; - bBadComponent[0] = (endPoint[0] >= 0) ? (endPoint[0] >= (1 << (prec.yzw - 1))) - : (-endPoint[0] > (1 << (prec.yzw - 1))); - bBadComponent[1] = (endPoint[1] >= 0) ? (endPoint[1] >= (1 << (prec.yzw - 1))) - : (-endPoint[1] > (1 << (prec.yzw - 1))); - bBadQuantize |= any(bBadComponent); - - endPoint[0] = (endPoint[0] >= 0) ? ((endPoint[0] >= (1 << (prec.yzw - 1))) ? ((1 << (prec.yzw - 1)) - 1) : endPoint[0]) - : ((-endPoint[0] > (1 << (prec.yzw - 1))) ? (1 << (prec.yzw - 1)) : (endPoint[0] & ((1 << prec.yzw) - 1))); - endPoint[1] = (endPoint[1] >= 0) ? ((endPoint[1] >= (1 << (prec.yzw - 1))) ? ((1 << (prec.yzw - 1)) - 1) : endPoint[1]) - : ((-endPoint[1] > (1 << (prec.yzw - 1))) ? (1 << (prec.yzw - 1)) : (endPoint[1] & ((1 << prec.yzw) - 1))); - } - else - { - endPoint &= ((1 << prec.x) - 1); - } -} -void finish_quantize(out bool bBadQuantize, inout int2x3 endPoint, uint4 prec, bool transformed) -{ - if (transformed) - { - bool3 bBadComponent; - bBadComponent = (endPoint[1] >= 0) ? (endPoint[1] >= (1 << (prec.yzw - 1))) - : (-endPoint[1] > (1 << (prec.yzw - 1))); - bBadQuantize = any(bBadComponent); - - endPoint[0] = endPoint[0] & ((1 << prec.x) - 1); - endPoint[1] = (endPoint[1] >= 0) ? ((endPoint[1] >= (1 << (prec.yzw - 1))) ? ((1 << (prec.yzw - 1)) - 1) : endPoint[1]) - : ((-endPoint[1] > (1 << (prec.yzw - 1))) ? (1 << (prec.yzw - 1)) : (endPoint[1] & ((1 << prec.yzw) - 1))); - } - else - { - endPoint &= ((1 << prec.x) - 1); - - bBadQuantize = 0; - } -} - -void SIGN_EXTEND(uint3 prec, inout int3 color) -{ - uint3 p = 1 << (prec - 1); - color = (color & p) ? (color & (p - 1)) - p : color; -} - -void sign_extend(bool transformed, uint4 prec, inout int2x3 endPoint) -{ - if (g_format == SIGNED_F16) - SIGN_EXTEND(prec.x, endPoint[0]); - if (g_format == SIGNED_F16 || transformed) - SIGN_EXTEND(prec.yzw, endPoint[1]); -} - -void sign_extend(bool transformed, uint4 prec, inout int2x3 endPoint[2]) -{ - if (g_format == SIGNED_F16) - SIGN_EXTEND(prec.x, endPoint[0][0]); - if (g_format == SIGNED_F16 || transformed) - { - SIGN_EXTEND(prec.yzw, endPoint[0][1]); - SIGN_EXTEND(prec.yzw, endPoint[1][0]); - SIGN_EXTEND(prec.yzw, endPoint[1][1]); - } -} -void start_unquantize(inout int2x3 endPoint[2], uint4 prec, bool transformed) -{ - sign_extend(transformed, prec, endPoint); - if (transformed) - { - endPoint[0][1] += endPoint[0][0]; - endPoint[1][0] += endPoint[0][0]; - endPoint[1][1] += endPoint[0][0]; - } -} -void start_unquantize(inout int2x3 endPoint, uint4 prec, bool transformed) -{ - sign_extend(transformed, prec, endPoint); - if (transformed) - endPoint[1] += endPoint[0]; -} -void unquantize(inout int2x3 color, uint prec) -{ - int iprec = asint(prec); - if (g_format == UNSIGNED_F16) - { - if (prec < 15) - { - color = (color != 0) ? (color == ((1 << iprec) - 1) ? 0xFFFF : (((color << 16) + 0x8000) >> iprec)) : color; - } - } - else - { - if (prec < 16) - { - uint2x3 s = color >= 0 ? 0 : 1; - color = abs(color); - color = (color != 0) ? (color >= ((1 << (iprec - 1)) - 1) ? 0x7FFF : (((color << 15) + 0x4000) >> (iprec - 1))) : color; - color = s > 0 ? -color : color; - } - } -} -uint3 finish_unquantize(int3 color) -{ - if (g_format == UNSIGNED_F16) - color = (color * 31) >> 6; - else - { - color = (color < 0) ? -((-color * 31) >> 5) : (color * 31) >> 5; - color = (color < 0) ? ((-color) | 0x8000) : color; - } - return asuint(color); -} -void generate_palette_unquantized8(out uint3 palette, int3 low, int3 high, int i) -{ - static const int aWeight3[] = { 0, 9, 18, 27, 37, 46, 55, 64 }; - - int3 tmp = (low * (64 - aWeight3[i]) + high * aWeight3[i] + 32) >> 6; - palette = finish_unquantize(tmp); -} -void generate_palette_unquantized16(out uint3 palette, int3 low, int3 high, int i) -{ - static const int aWeight4[] = { 0, 4, 9, 13, 17, 21, 26, 30, 34, 38, 43, 47, 51, 55, 60, 64 }; - - int3 tmp = (low * (64 - aWeight4[i]) + high * aWeight4[i] + 32) >> 6; - palette = finish_unquantize(tmp); -} - -float half2float1(uint Value) -{ - uint Mantissa = (uint)(Value & 0x03FF); - - uint Exponent; - if ((Value & 0x7C00) != 0) // The value is normalized - { - Exponent = (uint)((Value >> 10) & 0x1F); - } - else if (Mantissa != 0) // The value is denormalized - { - // Normalize the value in the resulting float - Exponent = 1; - - do - { - Exponent--; - Mantissa <<= 1; - } while ((Mantissa & 0x0400) == 0); - - Mantissa &= 0x03FF; - } - else // The value is zero - { - Exponent = (uint)(-112); - } - - uint Result = ((Value & 0x8000) << 16) | // Sign - ((Exponent + 112) << 23) | // Exponent - (Mantissa << 13); // Mantissa - - return asfloat(Result); -} - -float3 half2float(uint3 color_h) -{ - //uint3 sign = color_h & 0x8000; - //uint3 expo = color_h & 0x7C00; - //uint3 base = color_h & 0x03FF; - //return ( expo == 0 ) ? asfloat( ( sign << 16 ) | asuint( float3(base) / 16777216 ) ) //16777216 = 2^24 - // : asfloat( ( sign << 16 ) | ( ( ( expo + 0x1C000 ) | base ) << 13 ) ); //0x1C000 = 0x1FC00 - 0x3C00 - - return float3(half2float1(color_h.x), half2float1(color_h.y), half2float1(color_h.z)); -} - -void block_package(inout uint4 block, int2x3 endPoint[2], uint mode_type, uint partition_index) // for mode 1 - 10 -{ - block.xy = 0; - block.z &= 0xFFFC0000; - - //block.z |= (partition_index & 0x1f) << 13; - - if (mode_type == candidateModeFlag[0]) - { - /*block.x = candidateModeMemory[0]; - block.x |= ( ( endPoint[0][0].r << 5 ) & 0x00007FE0 ) | ( ( endPoint[0][0].g << 15 ) & 0x01FF8000 ) | ( ( endPoint[0][0].b << 25 ) & 0xFE000000 ); - block.x |= ( endPoint[1][0].g >> 2 ) & 0x00000004; - block.x |= ( endPoint[1][0].b >> 1 ) & 0x00000008; - block.x |= endPoint[1][1].b & 0x00000010; - block.y |= ( ( endPoint[0][0].b >> 7 ) & 0x00000007 ); - block.y |= ( ( endPoint[0][1].r << 3 ) & 0x000000F8 ) | ( ( endPoint[0][1].g << 13 ) & 0x0003E000 ) | ( ( endPoint[0][1].b << 23 ) & 0x0F800000 ); - block.yz |= ( endPoint[1][0].gr << uint2(9, 1) ) & uint2(0x00001E00, 0x0000003E); - block.y |= ( endPoint[1][0].b << 29 ) & 0xE0000000; - block.y |= ( ( endPoint[1][1].g << 4 ) & 0x00000100 ); - block.yz |= ( endPoint[1][1].gr << uint2(19, 7) ) & uint2(0x00780000, 0x00000F80); - block.yz |= ( ( endPoint[1][1].b << uint2(27, 9) ) & uint2(0x10000000, 0x00001000) ) | ( ( endPoint[1][1].b << uint2(18, 4) ) & uint2(0x00040000, 0x00000040) ); - block.z |= ( endPoint[1][0].b >> 3 ) & 0x00000001;*/ - - block.x |= ((candidateModeMemory[0] >> 0) & 1) << 0; - block.x |= ((candidateModeMemory[0] >> 1) & 1) << 1; - block.x |= ((endPoint[1][0].g >> 4) & 1) << 2; - block.x |= ((endPoint[1][0].b >> 4) & 1) << 3; - block.x |= ((endPoint[1][1].b >> 4) & 1) << 4; - block.x |= ((endPoint[0][0].r >> 0) & 1) << 5; - block.x |= ((endPoint[0][0].r >> 1) & 1) << 6; - block.x |= ((endPoint[0][0].r >> 2) & 1) << 7; - block.x |= ((endPoint[0][0].r >> 3) & 1) << 8; - block.x |= ((endPoint[0][0].r >> 4) & 1) << 9; - block.x |= ((endPoint[0][0].r >> 5) & 1) << 10; - block.x |= ((endPoint[0][0].r >> 6) & 1) << 11; - block.x |= ((endPoint[0][0].r >> 7) & 1) << 12; - block.x |= ((endPoint[0][0].r >> 8) & 1) << 13; - block.x |= ((endPoint[0][0].r >> 9) & 1) << 14; - block.x |= ((endPoint[0][0].g >> 0) & 1) << 15; - block.x |= ((endPoint[0][0].g >> 1) & 1) << 16; - block.x |= ((endPoint[0][0].g >> 2) & 1) << 17; - block.x |= ((endPoint[0][0].g >> 3) & 1) << 18; - block.x |= ((endPoint[0][0].g >> 4) & 1) << 19; - block.x |= ((endPoint[0][0].g >> 5) & 1) << 20; - block.x |= ((endPoint[0][0].g >> 6) & 1) << 21; - block.x |= ((endPoint[0][0].g >> 7) & 1) << 22; - block.x |= ((endPoint[0][0].g >> 8) & 1) << 23; - block.x |= ((endPoint[0][0].g >> 9) & 1) << 24; - block.x |= ((endPoint[0][0].b >> 0) & 1) << 25; - block.x |= ((endPoint[0][0].b >> 1) & 1) << 26; - block.x |= ((endPoint[0][0].b >> 2) & 1) << 27; - block.x |= ((endPoint[0][0].b >> 3) & 1) << 28; - block.x |= ((endPoint[0][0].b >> 4) & 1) << 29; - block.x |= ((endPoint[0][0].b >> 5) & 1) << 30; - block.x |= ((endPoint[0][0].b >> 6) & 1) << 31; - block.y |= ((endPoint[0][0].b >> 7) & 1) << 0; - block.y |= ((endPoint[0][0].b >> 8) & 1) << 1; - block.y |= ((endPoint[0][0].b >> 9) & 1) << 2; - block.y |= ((endPoint[0][1].r >> 0) & 1) << 3; - block.y |= ((endPoint[0][1].r >> 1) & 1) << 4; - block.y |= ((endPoint[0][1].r >> 2) & 1) << 5; - block.y |= ((endPoint[0][1].r >> 3) & 1) << 6; - block.y |= ((endPoint[0][1].r >> 4) & 1) << 7; - block.y |= ((endPoint[1][1].g >> 4) & 1) << 8; - block.y |= ((endPoint[1][0].g >> 0) & 1) << 9; - block.y |= ((endPoint[1][0].g >> 1) & 1) << 10; - block.y |= ((endPoint[1][0].g >> 2) & 1) << 11; - block.y |= ((endPoint[1][0].g >> 3) & 1) << 12; - block.y |= ((endPoint[0][1].g >> 0) & 1) << 13; - block.y |= ((endPoint[0][1].g >> 1) & 1) << 14; - block.y |= ((endPoint[0][1].g >> 2) & 1) << 15; - block.y |= ((endPoint[0][1].g >> 3) & 1) << 16; - block.y |= ((endPoint[0][1].g >> 4) & 1) << 17; - block.y |= ((endPoint[1][1].b >> 0) & 1) << 18; - block.y |= ((endPoint[1][1].g >> 0) & 1) << 19; - block.y |= ((endPoint[1][1].g >> 1) & 1) << 20; - block.y |= ((endPoint[1][1].g >> 2) & 1) << 21; - block.y |= ((endPoint[1][1].g >> 3) & 1) << 22; - block.y |= ((endPoint[0][1].b >> 0) & 1) << 23; - block.y |= ((endPoint[0][1].b >> 1) & 1) << 24; - block.y |= ((endPoint[0][1].b >> 2) & 1) << 25; - block.y |= ((endPoint[0][1].b >> 3) & 1) << 26; - block.y |= ((endPoint[0][1].b >> 4) & 1) << 27; - block.y |= ((endPoint[1][1].b >> 1) & 1) << 28; - block.y |= ((endPoint[1][0].b >> 0) & 1) << 29; - block.y |= ((endPoint[1][0].b >> 1) & 1) << 30; - block.y |= ((endPoint[1][0].b >> 2) & 1) << 31; - block.z |= ((endPoint[1][0].b >> 3) & 1) << 0; - block.z |= ((endPoint[1][0].r >> 0) & 1) << 1; - block.z |= ((endPoint[1][0].r >> 1) & 1) << 2; - block.z |= ((endPoint[1][0].r >> 2) & 1) << 3; - block.z |= ((endPoint[1][0].r >> 3) & 1) << 4; - block.z |= ((endPoint[1][0].r >> 4) & 1) << 5; - block.z |= ((endPoint[1][1].b >> 2) & 1) << 6; - block.z |= ((endPoint[1][1].r >> 0) & 1) << 7; - block.z |= ((endPoint[1][1].r >> 1) & 1) << 8; - block.z |= ((endPoint[1][1].r >> 2) & 1) << 9; - block.z |= ((endPoint[1][1].r >> 3) & 1) << 10; - block.z |= ((endPoint[1][1].r >> 4) & 1) << 11; - block.z |= ((endPoint[1][1].b >> 3) & 1) << 12; - block.z |= ((partition_index >> 0) & 1) << 13; - block.z |= ((partition_index >> 1) & 1) << 14; - block.z |= ((partition_index >> 2) & 1) << 15; - block.z |= ((partition_index >> 3) & 1) << 16; - block.z |= ((partition_index >> 4) & 1) << 17; - } - else if (mode_type == candidateModeFlag[1]) - { - /*block.x = candidateModeMemory[1]; - block.x |= ( ( endPoint[0][0].r << 5 ) & 0x00000FE0 ) | ( ( endPoint[0][0].g << 15 ) & 0x003F8000 ) | ( ( endPoint[0][0].b << 25 ) & 0xFE000000 ); - block.y |= ( ( endPoint[0][1].r << 3 ) & 0x000001F8 ) | ( ( endPoint[0][1].g << 13 ) & 0x0007E000 ) | ( ( endPoint[0][1].b << 23 ) & 0x1F800000 ); - block.x |= ( ( endPoint[1][0].g >> 3 ) & 0x00000004 ) | ( ( endPoint[1][0].g << 20 ) & 0x01000000 ); - block.x |= ( endPoint[1][1].g >> 1 ) & 0x00000018; - block.x |= ( ( endPoint[1][1].b << 21 ) & 0x00800000 ) | ( ( endPoint[1][1].b << 12 ) & 0x00003000 ); - block.x |= ( ( endPoint[1][0].b << 17 ) & 0x00400000 ) | ( ( endPoint[1][0].b << 10 ) & 0x00004000 ); - block.yz |= ( endPoint[1][0].gr << uint2(9, 1) ) & uint2(0x00001E00, 0x0000007E); - block.y |= ( endPoint[1][0].b << 29 ) & 0xE0000000; - block.yz |= ( endPoint[1][1].gr << uint2(19, 7) ) & uint2(0x00780000, 0x00001F80); - block.y |= ( ( endPoint[1][1].b >> 4 ) & 0x00000002 ) | ( ( endPoint[1][1].b >> 2 ) & 0x00000004 ) | ( ( endPoint[1][1].b >> 3 ) & 0x00000001 ); - block.z |= ( endPoint[1][0].b >> 3 ) & 0x00000001;*/ - - block.x |= ((candidateModeMemory[1] >> 0) & 1) << 0; - block.x |= ((candidateModeMemory[1] >> 1) & 1) << 1; - block.x |= ((endPoint[1][0].g >> 5) & 1) << 2; - block.x |= ((endPoint[1][1].g >> 4) & 1) << 3; - block.x |= ((endPoint[1][1].g >> 5) & 1) << 4; - block.x |= ((endPoint[0][0].r >> 0) & 1) << 5; - block.x |= ((endPoint[0][0].r >> 1) & 1) << 6; - block.x |= ((endPoint[0][0].r >> 2) & 1) << 7; - block.x |= ((endPoint[0][0].r >> 3) & 1) << 8; - block.x |= ((endPoint[0][0].r >> 4) & 1) << 9; - block.x |= ((endPoint[0][0].r >> 5) & 1) << 10; - block.x |= ((endPoint[0][0].r >> 6) & 1) << 11; - block.x |= ((endPoint[1][1].b >> 0) & 1) << 12; - block.x |= ((endPoint[1][1].b >> 1) & 1) << 13; - block.x |= ((endPoint[1][0].b >> 4) & 1) << 14; - block.x |= ((endPoint[0][0].g >> 0) & 1) << 15; - block.x |= ((endPoint[0][0].g >> 1) & 1) << 16; - block.x |= ((endPoint[0][0].g >> 2) & 1) << 17; - block.x |= ((endPoint[0][0].g >> 3) & 1) << 18; - block.x |= ((endPoint[0][0].g >> 4) & 1) << 19; - block.x |= ((endPoint[0][0].g >> 5) & 1) << 20; - block.x |= ((endPoint[0][0].g >> 6) & 1) << 21; - block.x |= ((endPoint[1][0].b >> 5) & 1) << 22; - block.x |= ((endPoint[1][1].b >> 2) & 1) << 23; - block.x |= ((endPoint[1][0].g >> 4) & 1) << 24; - block.x |= ((endPoint[0][0].b >> 0) & 1) << 25; - block.x |= ((endPoint[0][0].b >> 1) & 1) << 26; - block.x |= ((endPoint[0][0].b >> 2) & 1) << 27; - block.x |= ((endPoint[0][0].b >> 3) & 1) << 28; - block.x |= ((endPoint[0][0].b >> 4) & 1) << 29; - block.x |= ((endPoint[0][0].b >> 5) & 1) << 30; - block.x |= ((endPoint[0][0].b >> 6) & 1) << 31; - block.y |= ((endPoint[1][1].b >> 3) & 1) << 0; - block.y |= ((endPoint[1][1].b >> 5) & 1) << 1; - block.y |= ((endPoint[1][1].b >> 4) & 1) << 2; - block.y |= ((endPoint[0][1].r >> 0) & 1) << 3; - block.y |= ((endPoint[0][1].r >> 1) & 1) << 4; - block.y |= ((endPoint[0][1].r >> 2) & 1) << 5; - block.y |= ((endPoint[0][1].r >> 3) & 1) << 6; - block.y |= ((endPoint[0][1].r >> 4) & 1) << 7; - block.y |= ((endPoint[0][1].r >> 5) & 1) << 8; - block.y |= ((endPoint[1][0].g >> 0) & 1) << 9; - block.y |= ((endPoint[1][0].g >> 1) & 1) << 10; - block.y |= ((endPoint[1][0].g >> 2) & 1) << 11; - block.y |= ((endPoint[1][0].g >> 3) & 1) << 12; - block.y |= ((endPoint[0][1].g >> 0) & 1) << 13; - block.y |= ((endPoint[0][1].g >> 1) & 1) << 14; - block.y |= ((endPoint[0][1].g >> 2) & 1) << 15; - block.y |= ((endPoint[0][1].g >> 3) & 1) << 16; - block.y |= ((endPoint[0][1].g >> 4) & 1) << 17; - block.y |= ((endPoint[0][1].g >> 5) & 1) << 18; - block.y |= ((endPoint[1][1].g >> 0) & 1) << 19; - block.y |= ((endPoint[1][1].g >> 1) & 1) << 20; - block.y |= ((endPoint[1][1].g >> 2) & 1) << 21; - block.y |= ((endPoint[1][1].g >> 3) & 1) << 22; - block.y |= ((endPoint[0][1].b >> 0) & 1) << 23; - block.y |= ((endPoint[0][1].b >> 1) & 1) << 24; - block.y |= ((endPoint[0][1].b >> 2) & 1) << 25; - block.y |= ((endPoint[0][1].b >> 3) & 1) << 26; - block.y |= ((endPoint[0][1].b >> 4) & 1) << 27; - block.y |= ((endPoint[0][1].b >> 5) & 1) << 28; - block.y |= ((endPoint[1][0].b >> 0) & 1) << 29; - block.y |= ((endPoint[1][0].b >> 1) & 1) << 30; - block.y |= ((endPoint[1][0].b >> 2) & 1) << 31; - block.z |= ((endPoint[1][0].b >> 3) & 1) << 0; - block.z |= ((endPoint[1][0].r >> 0) & 1) << 1; - block.z |= ((endPoint[1][0].r >> 1) & 1) << 2; - block.z |= ((endPoint[1][0].r >> 2) & 1) << 3; - block.z |= ((endPoint[1][0].r >> 3) & 1) << 4; - block.z |= ((endPoint[1][0].r >> 4) & 1) << 5; - block.z |= ((endPoint[1][0].r >> 5) & 1) << 6; - block.z |= ((endPoint[1][1].r >> 0) & 1) << 7; - block.z |= ((endPoint[1][1].r >> 1) & 1) << 8; - block.z |= ((endPoint[1][1].r >> 2) & 1) << 9; - block.z |= ((endPoint[1][1].r >> 3) & 1) << 10; - block.z |= ((endPoint[1][1].r >> 4) & 1) << 11; - block.z |= ((endPoint[1][1].r >> 5) & 1) << 12; - block.z |= ((partition_index >> 0) & 1) << 13; - block.z |= ((partition_index >> 1) & 1) << 14; - block.z |= ((partition_index >> 2) & 1) << 15; - block.z |= ((partition_index >> 3) & 1) << 16; - block.z |= ((partition_index >> 4) & 1) << 17; - } - else if (mode_type == candidateModeFlag[2]) - { - /*block.x = candidateModeMemory[2]; - block.x |= ( ( endPoint[0][0].r << 5 ) & 0x00007FE0 ) | ( ( endPoint[0][0].g << 15 ) & 0x01FF8000 ) | ( ( endPoint[0][0].b << 25 ) & 0xFE000000 ); - block.y |= ( endPoint[0][0].r >> 2 ) & 0x00000100; - block.y |= ( endPoint[0][0].g << 7 ) & 0x00020000; - block.y |= ( ( endPoint[0][0].b << 17 ) & 0x08000000 ) | ( ( endPoint[0][0].b >> 7 ) & 0x00000007 ); - block.y |= ( ( endPoint[0][1].r << 3 ) & 0x000000F8 ) | ( ( endPoint[0][1].g << 13 ) & 0x0001E000 ) | ( ( endPoint[0][1].b << 23 ) & 0x07800000 ); - block.yz |= ( endPoint[1][0].gr << uint2(9, 1) ) & uint2(0x00001E00, 0x0000003E); - block.y |= ( endPoint[1][0].b << 29 ) & 0xE0000000; - block.yz |= ( endPoint[1][1].gr << uint2(19, 7) ) & uint2(0x00780000, 0x00000F80); - block.yz |= ( ( endPoint[1][1].b << uint2(27, 9) ) & uint2(0x10000000, 0x00001000) ) | ( ( endPoint[1][1].b << uint2(18, 4) ) & uint2(0x00040000, 0x00000040) ); - block.z |= ( endPoint[1][0].b >> 3 ) & 0x00000001;*/ - - block.x |= ((candidateModeMemory[2] >> 0) & 1) << 0; - block.x |= ((candidateModeMemory[2] >> 1) & 1) << 1; - block.x |= ((candidateModeMemory[2] >> 2) & 1) << 2; - block.x |= ((candidateModeMemory[2] >> 3) & 1) << 3; - block.x |= ((candidateModeMemory[2] >> 4) & 1) << 4; - block.x |= ((endPoint[0][0].r >> 0) & 1) << 5; - block.x |= ((endPoint[0][0].r >> 1) & 1) << 6; - block.x |= ((endPoint[0][0].r >> 2) & 1) << 7; - block.x |= ((endPoint[0][0].r >> 3) & 1) << 8; - block.x |= ((endPoint[0][0].r >> 4) & 1) << 9; - block.x |= ((endPoint[0][0].r >> 5) & 1) << 10; - block.x |= ((endPoint[0][0].r >> 6) & 1) << 11; - block.x |= ((endPoint[0][0].r >> 7) & 1) << 12; - block.x |= ((endPoint[0][0].r >> 8) & 1) << 13; - block.x |= ((endPoint[0][0].r >> 9) & 1) << 14; - block.x |= ((endPoint[0][0].g >> 0) & 1) << 15; - block.x |= ((endPoint[0][0].g >> 1) & 1) << 16; - block.x |= ((endPoint[0][0].g >> 2) & 1) << 17; - block.x |= ((endPoint[0][0].g >> 3) & 1) << 18; - block.x |= ((endPoint[0][0].g >> 4) & 1) << 19; - block.x |= ((endPoint[0][0].g >> 5) & 1) << 20; - block.x |= ((endPoint[0][0].g >> 6) & 1) << 21; - block.x |= ((endPoint[0][0].g >> 7) & 1) << 22; - block.x |= ((endPoint[0][0].g >> 8) & 1) << 23; - block.x |= ((endPoint[0][0].g >> 9) & 1) << 24; - block.x |= ((endPoint[0][0].b >> 0) & 1) << 25; - block.x |= ((endPoint[0][0].b >> 1) & 1) << 26; - block.x |= ((endPoint[0][0].b >> 2) & 1) << 27; - block.x |= ((endPoint[0][0].b >> 3) & 1) << 28; - block.x |= ((endPoint[0][0].b >> 4) & 1) << 29; - block.x |= ((endPoint[0][0].b >> 5) & 1) << 30; - block.x |= ((endPoint[0][0].b >> 6) & 1) << 31; - block.y |= ((endPoint[0][0].b >> 7) & 1) << 0; - block.y |= ((endPoint[0][0].b >> 8) & 1) << 1; - block.y |= ((endPoint[0][0].b >> 9) & 1) << 2; - block.y |= ((endPoint[0][1].r >> 0) & 1) << 3; - block.y |= ((endPoint[0][1].r >> 1) & 1) << 4; - block.y |= ((endPoint[0][1].r >> 2) & 1) << 5; - block.y |= ((endPoint[0][1].r >> 3) & 1) << 6; - block.y |= ((endPoint[0][1].r >> 4) & 1) << 7; - block.y |= ((endPoint[0][0].r >> 10) & 1) << 8; - block.y |= ((endPoint[1][0].g >> 0) & 1) << 9; - block.y |= ((endPoint[1][0].g >> 1) & 1) << 10; - block.y |= ((endPoint[1][0].g >> 2) & 1) << 11; - block.y |= ((endPoint[1][0].g >> 3) & 1) << 12; - block.y |= ((endPoint[0][1].g >> 0) & 1) << 13; - block.y |= ((endPoint[0][1].g >> 1) & 1) << 14; - block.y |= ((endPoint[0][1].g >> 2) & 1) << 15; - block.y |= ((endPoint[0][1].g >> 3) & 1) << 16; - block.y |= ((endPoint[0][0].g >> 10) & 1) << 17; - block.y |= ((endPoint[1][1].b >> 0) & 1) << 18; - block.y |= ((endPoint[1][1].g >> 0) & 1) << 19; - block.y |= ((endPoint[1][1].g >> 1) & 1) << 20; - block.y |= ((endPoint[1][1].g >> 2) & 1) << 21; - block.y |= ((endPoint[1][1].g >> 3) & 1) << 22; - block.y |= ((endPoint[0][1].b >> 0) & 1) << 23; - block.y |= ((endPoint[0][1].b >> 1) & 1) << 24; - block.y |= ((endPoint[0][1].b >> 2) & 1) << 25; - block.y |= ((endPoint[0][1].b >> 3) & 1) << 26; - block.y |= ((endPoint[0][0].b >> 10) & 1) << 27; - block.y |= ((endPoint[1][1].b >> 1) & 1) << 28; - block.y |= ((endPoint[1][0].b >> 0) & 1) << 29; - block.y |= ((endPoint[1][0].b >> 1) & 1) << 30; - block.y |= ((endPoint[1][0].b >> 2) & 1) << 31; - block.z |= ((endPoint[1][0].b >> 3) & 1) << 0; - block.z |= ((endPoint[1][0].r >> 0) & 1) << 1; - block.z |= ((endPoint[1][0].r >> 1) & 1) << 2; - block.z |= ((endPoint[1][0].r >> 2) & 1) << 3; - block.z |= ((endPoint[1][0].r >> 3) & 1) << 4; - block.z |= ((endPoint[1][0].r >> 4) & 1) << 5; - block.z |= ((endPoint[1][1].b >> 2) & 1) << 6; - block.z |= ((endPoint[1][1].r >> 0) & 1) << 7; - block.z |= ((endPoint[1][1].r >> 1) & 1) << 8; - block.z |= ((endPoint[1][1].r >> 2) & 1) << 9; - block.z |= ((endPoint[1][1].r >> 3) & 1) << 10; - block.z |= ((endPoint[1][1].r >> 4) & 1) << 11; - block.z |= ((endPoint[1][1].b >> 3) & 1) << 12; - block.z |= ((partition_index >> 0) & 1) << 13; - block.z |= ((partition_index >> 1) & 1) << 14; - block.z |= ((partition_index >> 2) & 1) << 15; - block.z |= ((partition_index >> 3) & 1) << 16; - block.z |= ((partition_index >> 4) & 1) << 17; - } - else if (mode_type == candidateModeFlag[3]) - { - /*block.x = candidateModeMemory[3]; - block.x |= ( ( endPoint[0][0].r << 5 ) & 0x00007FE0 ) | ( ( endPoint[0][0].g << 15 ) & 0x01FF8000 ) | ( ( endPoint[0][0].b << 25 ) & 0xFE000000 ); - block.y |= ( endPoint[0][0].r >> 3 ) & 0x00000080; - block.y |= ( endPoint[0][0].g << 8 ) & 0x00040000; - block.y |= ( ( endPoint[0][0].b << 17 ) & 0x08000000 ) | ( ( endPoint[0][0].b >> 7 ) & 0x00000007 ); - block.y |= ( ( endPoint[0][1].r << 3 ) & 0x00000078 ) | ( ( endPoint[0][1].g << 13 ) & 0x0003E000 ) | ( ( endPoint[0][1].b << 23 ) & 0x07800000 ); - block.yz |= ( endPoint[1][0].gr << uint2(9, 1) ) & uint2(0x00001E00, 0x0000001E); - block.y |= ( endPoint[1][0].b << 29 ) & 0xE0000000; - block.y |= ( ( endPoint[1][1].g << 4 ) & 0x00000100 ); - block.yz |= ( endPoint[1][1].gr << uint2(19, 7) ) & uint2(0x00780000, 0x00000780); - block.yz |= ( endPoint[1][1].b << uint2(27, 9) ) & uint2(0x10000000, 0x00001000); - block.z |= ( ( endPoint[1][0].g << 7 ) & 0x00000800 ); - block.z |= ( endPoint[1][0].b >> 3 ) & 0x00000001; - block.z |= ( endPoint[1][1].b << 4 ) & 0x00000040; - block.z |= ( endPoint[1][1].b << 5 ) & 0x00000020;*/ - - block.x |= ((candidateModeMemory[3] >> 0) & 1) << 0; - block.x |= ((candidateModeMemory[3] >> 1) & 1) << 1; - block.x |= ((candidateModeMemory[3] >> 2) & 1) << 2; - block.x |= ((candidateModeMemory[3] >> 3) & 1) << 3; - block.x |= ((candidateModeMemory[3] >> 4) & 1) << 4; - block.x |= ((endPoint[0][0].r >> 0) & 1) << 5; - block.x |= ((endPoint[0][0].r >> 1) & 1) << 6; - block.x |= ((endPoint[0][0].r >> 2) & 1) << 7; - block.x |= ((endPoint[0][0].r >> 3) & 1) << 8; - block.x |= ((endPoint[0][0].r >> 4) & 1) << 9; - block.x |= ((endPoint[0][0].r >> 5) & 1) << 10; - block.x |= ((endPoint[0][0].r >> 6) & 1) << 11; - block.x |= ((endPoint[0][0].r >> 7) & 1) << 12; - block.x |= ((endPoint[0][0].r >> 8) & 1) << 13; - block.x |= ((endPoint[0][0].r >> 9) & 1) << 14; - block.x |= ((endPoint[0][0].g >> 0) & 1) << 15; - block.x |= ((endPoint[0][0].g >> 1) & 1) << 16; - block.x |= ((endPoint[0][0].g >> 2) & 1) << 17; - block.x |= ((endPoint[0][0].g >> 3) & 1) << 18; - block.x |= ((endPoint[0][0].g >> 4) & 1) << 19; - block.x |= ((endPoint[0][0].g >> 5) & 1) << 20; - block.x |= ((endPoint[0][0].g >> 6) & 1) << 21; - block.x |= ((endPoint[0][0].g >> 7) & 1) << 22; - block.x |= ((endPoint[0][0].g >> 8) & 1) << 23; - block.x |= ((endPoint[0][0].g >> 9) & 1) << 24; - block.x |= ((endPoint[0][0].b >> 0) & 1) << 25; - block.x |= ((endPoint[0][0].b >> 1) & 1) << 26; - block.x |= ((endPoint[0][0].b >> 2) & 1) << 27; - block.x |= ((endPoint[0][0].b >> 3) & 1) << 28; - block.x |= ((endPoint[0][0].b >> 4) & 1) << 29; - block.x |= ((endPoint[0][0].b >> 5) & 1) << 30; - block.x |= ((endPoint[0][0].b >> 6) & 1) << 31; - block.y |= ((endPoint[0][0].b >> 7) & 1) << 0; - block.y |= ((endPoint[0][0].b >> 8) & 1) << 1; - block.y |= ((endPoint[0][0].b >> 9) & 1) << 2; - block.y |= ((endPoint[0][1].r >> 0) & 1) << 3; - block.y |= ((endPoint[0][1].r >> 1) & 1) << 4; - block.y |= ((endPoint[0][1].r >> 2) & 1) << 5; - block.y |= ((endPoint[0][1].r >> 3) & 1) << 6; - block.y |= ((endPoint[0][0].r >> 10) & 1) << 7; - block.y |= ((endPoint[1][1].g >> 4) & 1) << 8; - block.y |= ((endPoint[1][0].g >> 0) & 1) << 9; - block.y |= ((endPoint[1][0].g >> 1) & 1) << 10; - block.y |= ((endPoint[1][0].g >> 2) & 1) << 11; - block.y |= ((endPoint[1][0].g >> 3) & 1) << 12; - block.y |= ((endPoint[0][1].g >> 0) & 1) << 13; - block.y |= ((endPoint[0][1].g >> 1) & 1) << 14; - block.y |= ((endPoint[0][1].g >> 2) & 1) << 15; - block.y |= ((endPoint[0][1].g >> 3) & 1) << 16; - block.y |= ((endPoint[0][1].g >> 4) & 1) << 17; - block.y |= ((endPoint[0][0].g >> 10) & 1) << 18; - block.y |= ((endPoint[1][1].g >> 0) & 1) << 19; - block.y |= ((endPoint[1][1].g >> 1) & 1) << 20; - block.y |= ((endPoint[1][1].g >> 2) & 1) << 21; - block.y |= ((endPoint[1][1].g >> 3) & 1) << 22; - block.y |= ((endPoint[0][1].b >> 0) & 1) << 23; - block.y |= ((endPoint[0][1].b >> 1) & 1) << 24; - block.y |= ((endPoint[0][1].b >> 2) & 1) << 25; - block.y |= ((endPoint[0][1].b >> 3) & 1) << 26; - block.y |= ((endPoint[0][0].b >> 10) & 1) << 27; - block.y |= ((endPoint[1][1].b >> 1) & 1) << 28; - block.y |= ((endPoint[1][0].b >> 0) & 1) << 29; - block.y |= ((endPoint[1][0].b >> 1) & 1) << 30; - block.y |= ((endPoint[1][0].b >> 2) & 1) << 31; - block.z |= ((endPoint[1][0].b >> 3) & 1) << 0; - block.z |= ((endPoint[1][0].r >> 0) & 1) << 1; - block.z |= ((endPoint[1][0].r >> 1) & 1) << 2; - block.z |= ((endPoint[1][0].r >> 2) & 1) << 3; - block.z |= ((endPoint[1][0].r >> 3) & 1) << 4; - block.z |= ((endPoint[1][1].b >> 0) & 1) << 5; - block.z |= ((endPoint[1][1].b >> 2) & 1) << 6; - block.z |= ((endPoint[1][1].r >> 0) & 1) << 7; - block.z |= ((endPoint[1][1].r >> 1) & 1) << 8; - block.z |= ((endPoint[1][1].r >> 2) & 1) << 9; - block.z |= ((endPoint[1][1].r >> 3) & 1) << 10; - block.z |= ((endPoint[1][0].g >> 4) & 1) << 11; - block.z |= ((endPoint[1][1].b >> 3) & 1) << 12; - block.z |= ((partition_index >> 0) & 1) << 13; - block.z |= ((partition_index >> 1) & 1) << 14; - block.z |= ((partition_index >> 2) & 1) << 15; - block.z |= ((partition_index >> 3) & 1) << 16; - block.z |= ((partition_index >> 4) & 1) << 17; - } - else if (mode_type == candidateModeFlag[4]) - { - /*block.x = candidateModeMemory[4]; - block.x |= ( ( endPoint[0][0].r << 5 ) & 0x00007FE0 ) | ( ( endPoint[0][0].g << 15 ) & 0x01FF8000 ) | ( ( endPoint[0][0].b << 25 ) & 0xFE000000 ); - block.y |= ( endPoint[0][0].r >> 3 ) & 0x00000080; - block.y |= ( endPoint[0][0].g << 7 ) & 0x00020000; - block.y |= ( ( endPoint[0][0].b << 18 ) & 0x10000000 ) | ( ( endPoint[0][0].b >> 7 ) & 0x00000007 ); - block.y |= ( ( endPoint[0][1].r << 3 ) & 0x00000078 ) | ( ( endPoint[0][1].g << 13 ) & 0x0001E000 ) | ( ( endPoint[0][1].b << 23 ) & 0x0F800000 ); - block.y |= ( ( endPoint[1][0].g << 9 ) & 0x00001E00 ) | ( ( endPoint[1][0].b << 4 ) & 0x00000100 ); - block.y |= ( endPoint[1][0].b << 29 ) & 0xE0000000; - block.yz |= ( endPoint[1][1].gr << uint2(19, 7) ) & uint2(0x00780000, 0x00000780); - block.yz |= ( endPoint[1][1].b << uint2(18, 4) ) & uint2(0x00040000, 0x00000060); - block.z |= ( endPoint[1][0].r << 1 ) & 0x0000001E; - block.z |= ( endPoint[1][0].b >> 3 ) & 0x00000001; - block.z |= ( ( endPoint[1][1].b << 7 ) & 0x00000800 ) | ( ( endPoint[1][1].b << 9 ) & 0x00001000 );*/ - - block.x |= ((candidateModeMemory[4] >> 0) & 1) << 0; - block.x |= ((candidateModeMemory[4] >> 1) & 1) << 1; - block.x |= ((candidateModeMemory[4] >> 2) & 1) << 2; - block.x |= ((candidateModeMemory[4] >> 3) & 1) << 3; - block.x |= ((candidateModeMemory[4] >> 4) & 1) << 4; - block.x |= ((endPoint[0][0].r >> 0) & 1) << 5; - block.x |= ((endPoint[0][0].r >> 1) & 1) << 6; - block.x |= ((endPoint[0][0].r >> 2) & 1) << 7; - block.x |= ((endPoint[0][0].r >> 3) & 1) << 8; - block.x |= ((endPoint[0][0].r >> 4) & 1) << 9; - block.x |= ((endPoint[0][0].r >> 5) & 1) << 10; - block.x |= ((endPoint[0][0].r >> 6) & 1) << 11; - block.x |= ((endPoint[0][0].r >> 7) & 1) << 12; - block.x |= ((endPoint[0][0].r >> 8) & 1) << 13; - block.x |= ((endPoint[0][0].r >> 9) & 1) << 14; - block.x |= ((endPoint[0][0].g >> 0) & 1) << 15; - block.x |= ((endPoint[0][0].g >> 1) & 1) << 16; - block.x |= ((endPoint[0][0].g >> 2) & 1) << 17; - block.x |= ((endPoint[0][0].g >> 3) & 1) << 18; - block.x |= ((endPoint[0][0].g >> 4) & 1) << 19; - block.x |= ((endPoint[0][0].g >> 5) & 1) << 20; - block.x |= ((endPoint[0][0].g >> 6) & 1) << 21; - block.x |= ((endPoint[0][0].g >> 7) & 1) << 22; - block.x |= ((endPoint[0][0].g >> 8) & 1) << 23; - block.x |= ((endPoint[0][0].g >> 9) & 1) << 24; - block.x |= ((endPoint[0][0].b >> 0) & 1) << 25; - block.x |= ((endPoint[0][0].b >> 1) & 1) << 26; - block.x |= ((endPoint[0][0].b >> 2) & 1) << 27; - block.x |= ((endPoint[0][0].b >> 3) & 1) << 28; - block.x |= ((endPoint[0][0].b >> 4) & 1) << 29; - block.x |= ((endPoint[0][0].b >> 5) & 1) << 30; - block.x |= ((endPoint[0][0].b >> 6) & 1) << 31; - block.y |= ((endPoint[0][0].b >> 7) & 1) << 0; - block.y |= ((endPoint[0][0].b >> 8) & 1) << 1; - block.y |= ((endPoint[0][0].b >> 9) & 1) << 2; - block.y |= ((endPoint[0][1].r >> 0) & 1) << 3; - block.y |= ((endPoint[0][1].r >> 1) & 1) << 4; - block.y |= ((endPoint[0][1].r >> 2) & 1) << 5; - block.y |= ((endPoint[0][1].r >> 3) & 1) << 6; - block.y |= ((endPoint[0][0].r >> 10) & 1) << 7; - block.y |= ((endPoint[1][0].b >> 4) & 1) << 8; - block.y |= ((endPoint[1][0].g >> 0) & 1) << 9; - block.y |= ((endPoint[1][0].g >> 1) & 1) << 10; - block.y |= ((endPoint[1][0].g >> 2) & 1) << 11; - block.y |= ((endPoint[1][0].g >> 3) & 1) << 12; - block.y |= ((endPoint[0][1].g >> 0) & 1) << 13; - block.y |= ((endPoint[0][1].g >> 1) & 1) << 14; - block.y |= ((endPoint[0][1].g >> 2) & 1) << 15; - block.y |= ((endPoint[0][1].g >> 3) & 1) << 16; - block.y |= ((endPoint[0][0].g >> 10) & 1) << 17; - block.y |= ((endPoint[1][1].b >> 0) & 1) << 18; - block.y |= ((endPoint[1][1].g >> 0) & 1) << 19; - block.y |= ((endPoint[1][1].g >> 1) & 1) << 20; - block.y |= ((endPoint[1][1].g >> 2) & 1) << 21; - block.y |= ((endPoint[1][1].g >> 3) & 1) << 22; - block.y |= ((endPoint[0][1].b >> 0) & 1) << 23; - block.y |= ((endPoint[0][1].b >> 1) & 1) << 24; - block.y |= ((endPoint[0][1].b >> 2) & 1) << 25; - block.y |= ((endPoint[0][1].b >> 3) & 1) << 26; - block.y |= ((endPoint[0][1].b >> 4) & 1) << 27; - block.y |= ((endPoint[0][0].b >> 10) & 1) << 28; - block.y |= ((endPoint[1][0].b >> 0) & 1) << 29; - block.y |= ((endPoint[1][0].b >> 1) & 1) << 30; - block.y |= ((endPoint[1][0].b >> 2) & 1) << 31; - block.z |= ((endPoint[1][0].b >> 3) & 1) << 0; - block.z |= ((endPoint[1][0].r >> 0) & 1) << 1; - block.z |= ((endPoint[1][0].r >> 1) & 1) << 2; - block.z |= ((endPoint[1][0].r >> 2) & 1) << 3; - block.z |= ((endPoint[1][0].r >> 3) & 1) << 4; - block.z |= ((endPoint[1][1].b >> 1) & 1) << 5; - block.z |= ((endPoint[1][1].b >> 2) & 1) << 6; - block.z |= ((endPoint[1][1].r >> 0) & 1) << 7; - block.z |= ((endPoint[1][1].r >> 1) & 1) << 8; - block.z |= ((endPoint[1][1].r >> 2) & 1) << 9; - block.z |= ((endPoint[1][1].r >> 3) & 1) << 10; - block.z |= ((endPoint[1][1].b >> 4) & 1) << 11; - block.z |= ((endPoint[1][1].b >> 3) & 1) << 12; - block.z |= ((partition_index >> 0) & 1) << 13; - block.z |= ((partition_index >> 1) & 1) << 14; - block.z |= ((partition_index >> 2) & 1) << 15; - block.z |= ((partition_index >> 3) & 1) << 16; - block.z |= ((partition_index >> 4) & 1) << 17; - } - else if (mode_type == candidateModeFlag[5]) - { - /*block.x = candidateModeMemory[5]; - block.x |= ( ( endPoint[0][0].r << 5 ) & 0x00003FE0 ) | ( ( endPoint[0][0].g << 15 ) & 0x00FF8000 ) | ( ( endPoint[0][0].b << 25 ) & 0xFE000000); - block.y |= ( endPoint[0][0].b >> 7 ) & 0x00000003; - block.y |= ( ( endPoint[0][1].r << 3 ) & 0x000000F8 ) | ( ( endPoint[0][1].g << 13 ) & 0x0003E000 ) | ( ( endPoint[0][1].b << 23 ) & 0x0F800000 ); - block.x |= ( ( endPoint[1][0].g << 20 ) & 0x01000000 ) | ( ( endPoint[1][0].b << 10 ) & 0x00004000 ); - block.yz |= ( endPoint[1][0].gr << uint2(9, 1) ) & uint2(0x00001E00, 0x0000003E); - block.y |= ( endPoint[1][0].b << 29 ) & 0xE0000000; - block.y |= ( ( endPoint[1][1].g << 4 ) & 0x00000100 ) | ( ( endPoint[1][1].b >> 2 ) & 0x00000004 ); - block.y |= ( ( endPoint[1][1].b << 27 ) & 0x10000000 ); - block.yz |= ( endPoint[1][1].gr << uint2(19, 7) ) & uint2(0x00780000, 0x00000F80); - block.yz |= ( endPoint[1][1].b << uint2(18, 4) ) & uint2(0x00040000, 0x00000040); - block.z |= ( endPoint[1][0].b >> 3 ) & 0x00000001; - block.z |= ( ( endPoint[1][1].b << 9 ) & 0x00001000 );*/ - - block.x |= ((candidateModeMemory[5] >> 0) & 1) << 0; - block.x |= ((candidateModeMemory[5] >> 1) & 1) << 1; - block.x |= ((candidateModeMemory[5] >> 2) & 1) << 2; - block.x |= ((candidateModeMemory[5] >> 3) & 1) << 3; - block.x |= ((candidateModeMemory[5] >> 4) & 1) << 4; - block.x |= ((endPoint[0][0].r >> 0) & 1) << 5; - block.x |= ((endPoint[0][0].r >> 1) & 1) << 6; - block.x |= ((endPoint[0][0].r >> 2) & 1) << 7; - block.x |= ((endPoint[0][0].r >> 3) & 1) << 8; - block.x |= ((endPoint[0][0].r >> 4) & 1) << 9; - block.x |= ((endPoint[0][0].r >> 5) & 1) << 10; - block.x |= ((endPoint[0][0].r >> 6) & 1) << 11; - block.x |= ((endPoint[0][0].r >> 7) & 1) << 12; - block.x |= ((endPoint[0][0].r >> 8) & 1) << 13; - block.x |= ((endPoint[1][0].b >> 4) & 1) << 14; - block.x |= ((endPoint[0][0].g >> 0) & 1) << 15; - block.x |= ((endPoint[0][0].g >> 1) & 1) << 16; - block.x |= ((endPoint[0][0].g >> 2) & 1) << 17; - block.x |= ((endPoint[0][0].g >> 3) & 1) << 18; - block.x |= ((endPoint[0][0].g >> 4) & 1) << 19; - block.x |= ((endPoint[0][0].g >> 5) & 1) << 20; - block.x |= ((endPoint[0][0].g >> 6) & 1) << 21; - block.x |= ((endPoint[0][0].g >> 7) & 1) << 22; - block.x |= ((endPoint[0][0].g >> 8) & 1) << 23; - block.x |= ((endPoint[1][0].g >> 4) & 1) << 24; - block.x |= ((endPoint[0][0].b >> 0) & 1) << 25; - block.x |= ((endPoint[0][0].b >> 1) & 1) << 26; - block.x |= ((endPoint[0][0].b >> 2) & 1) << 27; - block.x |= ((endPoint[0][0].b >> 3) & 1) << 28; - block.x |= ((endPoint[0][0].b >> 4) & 1) << 29; - block.x |= ((endPoint[0][0].b >> 5) & 1) << 30; - block.x |= ((endPoint[0][0].b >> 6) & 1) << 31; - block.y |= ((endPoint[0][0].b >> 7) & 1) << 0; - block.y |= ((endPoint[0][0].b >> 8) & 1) << 1; - block.y |= ((endPoint[1][1].b >> 4) & 1) << 2; - block.y |= ((endPoint[0][1].r >> 0) & 1) << 3; - block.y |= ((endPoint[0][1].r >> 1) & 1) << 4; - block.y |= ((endPoint[0][1].r >> 2) & 1) << 5; - block.y |= ((endPoint[0][1].r >> 3) & 1) << 6; - block.y |= ((endPoint[0][1].r >> 4) & 1) << 7; - block.y |= ((endPoint[1][1].g >> 4) & 1) << 8; - block.y |= ((endPoint[1][0].g >> 0) & 1) << 9; - block.y |= ((endPoint[1][0].g >> 1) & 1) << 10; - block.y |= ((endPoint[1][0].g >> 2) & 1) << 11; - block.y |= ((endPoint[1][0].g >> 3) & 1) << 12; - block.y |= ((endPoint[0][1].g >> 0) & 1) << 13; - block.y |= ((endPoint[0][1].g >> 1) & 1) << 14; - block.y |= ((endPoint[0][1].g >> 2) & 1) << 15; - block.y |= ((endPoint[0][1].g >> 3) & 1) << 16; - block.y |= ((endPoint[0][1].g >> 4) & 1) << 17; - block.y |= ((endPoint[1][1].b >> 0) & 1) << 18; - block.y |= ((endPoint[1][1].g >> 0) & 1) << 19; - block.y |= ((endPoint[1][1].g >> 1) & 1) << 20; - block.y |= ((endPoint[1][1].g >> 2) & 1) << 21; - block.y |= ((endPoint[1][1].g >> 3) & 1) << 22; - block.y |= ((endPoint[0][1].b >> 0) & 1) << 23; - block.y |= ((endPoint[0][1].b >> 1) & 1) << 24; - block.y |= ((endPoint[0][1].b >> 2) & 1) << 25; - block.y |= ((endPoint[0][1].b >> 3) & 1) << 26; - block.y |= ((endPoint[0][1].b >> 4) & 1) << 27; - block.y |= ((endPoint[1][1].b >> 1) & 1) << 28; - block.y |= ((endPoint[1][0].b >> 0) & 1) << 29; - block.y |= ((endPoint[1][0].b >> 1) & 1) << 30; - block.y |= ((endPoint[1][0].b >> 2) & 1) << 31; - block.z |= ((endPoint[1][0].b >> 3) & 1) << 0; - block.z |= ((endPoint[1][0].r >> 0) & 1) << 1; - block.z |= ((endPoint[1][0].r >> 1) & 1) << 2; - block.z |= ((endPoint[1][0].r >> 2) & 1) << 3; - block.z |= ((endPoint[1][0].r >> 3) & 1) << 4; - block.z |= ((endPoint[1][0].r >> 4) & 1) << 5; - block.z |= ((endPoint[1][1].b >> 2) & 1) << 6; - block.z |= ((endPoint[1][1].r >> 0) & 1) << 7; - block.z |= ((endPoint[1][1].r >> 1) & 1) << 8; - block.z |= ((endPoint[1][1].r >> 2) & 1) << 9; - block.z |= ((endPoint[1][1].r >> 3) & 1) << 10; - block.z |= ((endPoint[1][1].r >> 4) & 1) << 11; - block.z |= ((endPoint[1][1].b >> 3) & 1) << 12; - block.z |= ((partition_index >> 0) & 1) << 13; - block.z |= ((partition_index >> 1) & 1) << 14; - block.z |= ((partition_index >> 2) & 1) << 15; - block.z |= ((partition_index >> 3) & 1) << 16; - block.z |= ((partition_index >> 4) & 1) << 17; - } - else if (mode_type == candidateModeFlag[6]) - { - /*block.x = candidateModeMemory[6]; - block.x |= ( ( endPoint[0][0].r << 5 ) & 0x00001FE0 ) | ( ( endPoint[0][0].g << 15 ) & 0x007F8000 ) | ( ( endPoint[0][0].b << 25 ) & 0xFE000000 ); - block.y |= ( endPoint[0][0].b >> 7 ) & 0x00000001; - block.y |= ( ( endPoint[0][1].r << 3 ) & 0x000001F8 ) | ( ( endPoint[0][1].g << 13 ) & 0x0003E000 ) | ( ( endPoint[0][1].b << 23 ) & 0x0F800000 ); - block.x |= ( ( endPoint[1][0].g << 20 ) & 0x01000000 ) | ( ( endPoint[1][0].b << 10 ) & 0x00004000); - block.x |= ( ( endPoint[1][1].g << 9 ) & 0x00002000 ) | ( ( endPoint[1][1].b << 21 ) & 0x00800000); - block.yz |= ( endPoint[1][0].gr << uint2(9, 1) ) & uint2(0x00001E00, 0x0000007E); - block.y |= ( endPoint[1][0].b << 29 ) & 0xE0000000; - block.yz |= ( endPoint[1][1].gr << uint2(19, 7) ) & uint2(0x00780000, 0x00001F80); - block.y |= ( ( endPoint[1][1].b >> 2 ) & 0x00000006 ); - block.y |= ( ( endPoint[1][1].b << 27 ) & 0x10000000 ) | ( ( endPoint[1][1].b << 18 ) & 0x00040000 ); - block.z |= ( endPoint[1][0].b >> 3 ) & 0x00000001;*/ - - block.x |= ((candidateModeMemory[6] >> 0) & 1) << 0; - block.x |= ((candidateModeMemory[6] >> 1) & 1) << 1; - block.x |= ((candidateModeMemory[6] >> 2) & 1) << 2; - block.x |= ((candidateModeMemory[6] >> 3) & 1) << 3; - block.x |= ((candidateModeMemory[6] >> 4) & 1) << 4; - block.x |= ((endPoint[0][0].r >> 0) & 1) << 5; - block.x |= ((endPoint[0][0].r >> 1) & 1) << 6; - block.x |= ((endPoint[0][0].r >> 2) & 1) << 7; - block.x |= ((endPoint[0][0].r >> 3) & 1) << 8; - block.x |= ((endPoint[0][0].r >> 4) & 1) << 9; - block.x |= ((endPoint[0][0].r >> 5) & 1) << 10; - block.x |= ((endPoint[0][0].r >> 6) & 1) << 11; - block.x |= ((endPoint[0][0].r >> 7) & 1) << 12; - block.x |= ((endPoint[1][1].g >> 4) & 1) << 13; - block.x |= ((endPoint[1][0].b >> 4) & 1) << 14; - block.x |= ((endPoint[0][0].g >> 0) & 1) << 15; - block.x |= ((endPoint[0][0].g >> 1) & 1) << 16; - block.x |= ((endPoint[0][0].g >> 2) & 1) << 17; - block.x |= ((endPoint[0][0].g >> 3) & 1) << 18; - block.x |= ((endPoint[0][0].g >> 4) & 1) << 19; - block.x |= ((endPoint[0][0].g >> 5) & 1) << 20; - block.x |= ((endPoint[0][0].g >> 6) & 1) << 21; - block.x |= ((endPoint[0][0].g >> 7) & 1) << 22; - block.x |= ((endPoint[1][1].b >> 2) & 1) << 23; - block.x |= ((endPoint[1][0].g >> 4) & 1) << 24; - block.x |= ((endPoint[0][0].b >> 0) & 1) << 25; - block.x |= ((endPoint[0][0].b >> 1) & 1) << 26; - block.x |= ((endPoint[0][0].b >> 2) & 1) << 27; - block.x |= ((endPoint[0][0].b >> 3) & 1) << 28; - block.x |= ((endPoint[0][0].b >> 4) & 1) << 29; - block.x |= ((endPoint[0][0].b >> 5) & 1) << 30; - block.x |= ((endPoint[0][0].b >> 6) & 1) << 31; - block.y |= ((endPoint[0][0].b >> 7) & 1) << 0; - block.y |= ((endPoint[1][1].b >> 3) & 1) << 1; - block.y |= ((endPoint[1][1].b >> 4) & 1) << 2; - block.y |= ((endPoint[0][1].r >> 0) & 1) << 3; - block.y |= ((endPoint[0][1].r >> 1) & 1) << 4; - block.y |= ((endPoint[0][1].r >> 2) & 1) << 5; - block.y |= ((endPoint[0][1].r >> 3) & 1) << 6; - block.y |= ((endPoint[0][1].r >> 4) & 1) << 7; - block.y |= ((endPoint[0][1].r >> 5) & 1) << 8; - block.y |= ((endPoint[1][0].g >> 0) & 1) << 9; - block.y |= ((endPoint[1][0].g >> 1) & 1) << 10; - block.y |= ((endPoint[1][0].g >> 2) & 1) << 11; - block.y |= ((endPoint[1][0].g >> 3) & 1) << 12; - block.y |= ((endPoint[0][1].g >> 0) & 1) << 13; - block.y |= ((endPoint[0][1].g >> 1) & 1) << 14; - block.y |= ((endPoint[0][1].g >> 2) & 1) << 15; - block.y |= ((endPoint[0][1].g >> 3) & 1) << 16; - block.y |= ((endPoint[0][1].g >> 4) & 1) << 17; - block.y |= ((endPoint[1][1].b >> 0) & 1) << 18; - block.y |= ((endPoint[1][1].g >> 0) & 1) << 19; - block.y |= ((endPoint[1][1].g >> 1) & 1) << 20; - block.y |= ((endPoint[1][1].g >> 2) & 1) << 21; - block.y |= ((endPoint[1][1].g >> 3) & 1) << 22; - block.y |= ((endPoint[0][1].b >> 0) & 1) << 23; - block.y |= ((endPoint[0][1].b >> 1) & 1) << 24; - block.y |= ((endPoint[0][1].b >> 2) & 1) << 25; - block.y |= ((endPoint[0][1].b >> 3) & 1) << 26; - block.y |= ((endPoint[0][1].b >> 4) & 1) << 27; - block.y |= ((endPoint[1][1].b >> 1) & 1) << 28; - block.y |= ((endPoint[1][0].b >> 0) & 1) << 29; - block.y |= ((endPoint[1][0].b >> 1) & 1) << 30; - block.y |= ((endPoint[1][0].b >> 2) & 1) << 31; - block.z |= ((endPoint[1][0].b >> 3) & 1) << 0; - block.z |= ((endPoint[1][0].r >> 0) & 1) << 1; - block.z |= ((endPoint[1][0].r >> 1) & 1) << 2; - block.z |= ((endPoint[1][0].r >> 2) & 1) << 3; - block.z |= ((endPoint[1][0].r >> 3) & 1) << 4; - block.z |= ((endPoint[1][0].r >> 4) & 1) << 5; - block.z |= ((endPoint[1][0].r >> 5) & 1) << 6; - block.z |= ((endPoint[1][1].r >> 0) & 1) << 7; - block.z |= ((endPoint[1][1].r >> 1) & 1) << 8; - block.z |= ((endPoint[1][1].r >> 2) & 1) << 9; - block.z |= ((endPoint[1][1].r >> 3) & 1) << 10; - block.z |= ((endPoint[1][1].r >> 4) & 1) << 11; - block.z |= ((endPoint[1][1].r >> 5) & 1) << 12; - block.z |= ((partition_index >> 0) & 1) << 13; - block.z |= ((partition_index >> 1) & 1) << 14; - block.z |= ((partition_index >> 2) & 1) << 15; - block.z |= ((partition_index >> 3) & 1) << 16; - block.z |= ((partition_index >> 4) & 1) << 17; - } - else if (mode_type == candidateModeFlag[7]) - { - /*block.x = candidateModeMemory[7]; - block.x |= ( ( endPoint[0][0].r << 5 ) & 0x00001FE0 ) | ( ( endPoint[0][0].g << 15 ) & 0x007F8000 ) | ( ( endPoint[0][0].b << 25 ) & 0xFE000000 ); - block.y |= ( endPoint[0][0].b >> 7 ) & 0x00000001; - block.y |= ( ( endPoint[0][1].r << 3 ) & 0x000000F8 ) | ( ( endPoint[0][1].g << 13 ) & 0x0007E000 ) | ( ( endPoint[0][1].b << 23 ) & 0x0F800000 ); - block.x |= ( ( endPoint[1][0].g << 20 ) & 0x01000000 ) | ( ( endPoint[1][0].b << 10 ) & 0x00004000 ); - block.x |= ( ( endPoint[1][0].g << 18 ) & 0x00800000 ); - block.x |= ( ( endPoint[1][1].b << 13 ) & 0x00002000 ); - block.yz |= ( endPoint[1][0].gr << uint2(9, 1) ) & uint2(0x00001E00, 0x0000003E); - block.yz |= ( endPoint[1][1].gr << uint2(19, 7) ) & uint2(0x00780000, 0x00000F80); - block.y |= ( endPoint[1][0].b << 29 ) & 0xE0000000; - block.y |= ( ( endPoint[1][1].g >> 4 ) & 0x00000002 ) | ( ( endPoint[1][1].g << 4 ) & 0x00000100 ) | ( ( endPoint[1][1].b >> 2 ) & 0x00000004 ); - block.y |= ( endPoint[1][1].b << 27 ) & 0x10000000; - block.z |= ( endPoint[1][0].b >> 3 ) & 0x00000001; - block.z |= ( ( endPoint[1][1].b << 9 ) & 0x00001000 ) | ( ( endPoint[1][1].b << 4 ) & 0x00000040 );*/ - - block.x |= ((candidateModeMemory[7] >> 0) & 1) << 0; - block.x |= ((candidateModeMemory[7] >> 1) & 1) << 1; - block.x |= ((candidateModeMemory[7] >> 2) & 1) << 2; - block.x |= ((candidateModeMemory[7] >> 3) & 1) << 3; - block.x |= ((candidateModeMemory[7] >> 4) & 1) << 4; - block.x |= ((endPoint[0][0].r >> 0) & 1) << 5; - block.x |= ((endPoint[0][0].r >> 1) & 1) << 6; - block.x |= ((endPoint[0][0].r >> 2) & 1) << 7; - block.x |= ((endPoint[0][0].r >> 3) & 1) << 8; - block.x |= ((endPoint[0][0].r >> 4) & 1) << 9; - block.x |= ((endPoint[0][0].r >> 5) & 1) << 10; - block.x |= ((endPoint[0][0].r >> 6) & 1) << 11; - block.x |= ((endPoint[0][0].r >> 7) & 1) << 12; - block.x |= ((endPoint[1][1].b >> 0) & 1) << 13; - block.x |= ((endPoint[1][0].b >> 4) & 1) << 14; - block.x |= ((endPoint[0][0].g >> 0) & 1) << 15; - block.x |= ((endPoint[0][0].g >> 1) & 1) << 16; - block.x |= ((endPoint[0][0].g >> 2) & 1) << 17; - block.x |= ((endPoint[0][0].g >> 3) & 1) << 18; - block.x |= ((endPoint[0][0].g >> 4) & 1) << 19; - block.x |= ((endPoint[0][0].g >> 5) & 1) << 20; - block.x |= ((endPoint[0][0].g >> 6) & 1) << 21; - block.x |= ((endPoint[0][0].g >> 7) & 1) << 22; - block.x |= ((endPoint[1][0].g >> 5) & 1) << 23; - block.x |= ((endPoint[1][0].g >> 4) & 1) << 24; - block.x |= ((endPoint[0][0].b >> 0) & 1) << 25; - block.x |= ((endPoint[0][0].b >> 1) & 1) << 26; - block.x |= ((endPoint[0][0].b >> 2) & 1) << 27; - block.x |= ((endPoint[0][0].b >> 3) & 1) << 28; - block.x |= ((endPoint[0][0].b >> 4) & 1) << 29; - block.x |= ((endPoint[0][0].b >> 5) & 1) << 30; - block.x |= ((endPoint[0][0].b >> 6) & 1) << 31; - block.y |= ((endPoint[0][0].b >> 7) & 1) << 0; - block.y |= ((endPoint[1][1].g >> 5) & 1) << 1; - block.y |= ((endPoint[1][1].b >> 4) & 1) << 2; - block.y |= ((endPoint[0][1].r >> 0) & 1) << 3; - block.y |= ((endPoint[0][1].r >> 1) & 1) << 4; - block.y |= ((endPoint[0][1].r >> 2) & 1) << 5; - block.y |= ((endPoint[0][1].r >> 3) & 1) << 6; - block.y |= ((endPoint[0][1].r >> 4) & 1) << 7; - block.y |= ((endPoint[1][1].g >> 4) & 1) << 8; - block.y |= ((endPoint[1][0].g >> 0) & 1) << 9; - block.y |= ((endPoint[1][0].g >> 1) & 1) << 10; - block.y |= ((endPoint[1][0].g >> 2) & 1) << 11; - block.y |= ((endPoint[1][0].g >> 3) & 1) << 12; - block.y |= ((endPoint[0][1].g >> 0) & 1) << 13; - block.y |= ((endPoint[0][1].g >> 1) & 1) << 14; - block.y |= ((endPoint[0][1].g >> 2) & 1) << 15; - block.y |= ((endPoint[0][1].g >> 3) & 1) << 16; - block.y |= ((endPoint[0][1].g >> 4) & 1) << 17; - block.y |= ((endPoint[0][1].g >> 5) & 1) << 18; - block.y |= ((endPoint[1][1].g >> 0) & 1) << 19; - block.y |= ((endPoint[1][1].g >> 1) & 1) << 20; - block.y |= ((endPoint[1][1].g >> 2) & 1) << 21; - block.y |= ((endPoint[1][1].g >> 3) & 1) << 22; - block.y |= ((endPoint[0][1].b >> 0) & 1) << 23; - block.y |= ((endPoint[0][1].b >> 1) & 1) << 24; - block.y |= ((endPoint[0][1].b >> 2) & 1) << 25; - block.y |= ((endPoint[0][1].b >> 3) & 1) << 26; - block.y |= ((endPoint[0][1].b >> 4) & 1) << 27; - block.y |= ((endPoint[1][1].b >> 1) & 1) << 28; - block.y |= ((endPoint[1][0].b >> 0) & 1) << 29; - block.y |= ((endPoint[1][0].b >> 1) & 1) << 30; - block.y |= ((endPoint[1][0].b >> 2) & 1) << 31; - block.z |= ((endPoint[1][0].b >> 3) & 1) << 0; - block.z |= ((endPoint[1][0].r >> 0) & 1) << 1; - block.z |= ((endPoint[1][0].r >> 1) & 1) << 2; - block.z |= ((endPoint[1][0].r >> 2) & 1) << 3; - block.z |= ((endPoint[1][0].r >> 3) & 1) << 4; - block.z |= ((endPoint[1][0].r >> 4) & 1) << 5; - block.z |= ((endPoint[1][1].b >> 2) & 1) << 6; - block.z |= ((endPoint[1][1].r >> 0) & 1) << 7; - block.z |= ((endPoint[1][1].r >> 1) & 1) << 8; - block.z |= ((endPoint[1][1].r >> 2) & 1) << 9; - block.z |= ((endPoint[1][1].r >> 3) & 1) << 10; - block.z |= ((endPoint[1][1].r >> 4) & 1) << 11; - block.z |= ((endPoint[1][1].b >> 3) & 1) << 12; - block.z |= ((partition_index >> 0) & 1) << 13; - block.z |= ((partition_index >> 1) & 1) << 14; - block.z |= ((partition_index >> 2) & 1) << 15; - block.z |= ((partition_index >> 3) & 1) << 16; - block.z |= ((partition_index >> 4) & 1) << 17; - } - else if (mode_type == candidateModeFlag[8]) - { - /*block.x = candidateModeMemory[8]; - block.x |= ( ( endPoint[0][0].r << 5 ) & 0x00001FE0 ) | ( ( endPoint[0][0].g << 15 ) & 0x007F8000 ) | ( ( endPoint[0][0].b << 25 ) & 0xFE000000 ); - block.y |= ( endPoint[0][0].b >> 7 ) & 0x00000001; - block.y |= ( ( endPoint[0][1].r << 3 ) & 0x000000F8 ) | ( ( endPoint[0][1].g << 13 ) & 0x0003E000 ) | ( ( endPoint[0][1].b << 23 ) & 0x1F800000 ); - block.x |= ( ( endPoint[1][0].g << 20 ) & 0x01000000 ) | ( ( endPoint[1][0].b << 10 ) & 0x00004000 ); - block.x |= ( ( endPoint[1][0].b << 18 ) & 0x00800000 ); - block.x |= ( endPoint[1][1].b << 12 ) & 0x00002000; - block.y |= ( endPoint[1][0].b << 29 ) & 0xE0000000; - block.y |= ( ( endPoint[1][1].g << 4 ) & 0x00000100 ) | ( ( endPoint[1][1].b >> 4 ) & 0x00000002 ) | ( ( endPoint[1][1].b >> 2 ) & 0x00000004 ); - block.yz |= ( endPoint[1][0].gr << uint2(9, 1) ) & uint2(0x00001E00, 0x0000003E); - block.yz |= ( endPoint[1][1].gr << uint2(19, 7) ) & uint2(0x00780000, 0x00000F80); - block.y |= ( endPoint[1][1].b << 18 ) & 0x00040000; - block.z |= ( endPoint[1][0].b >> 3 ) & 0x00000001; - block.z |= ( ( endPoint[1][1].b << 9 ) & 0x00001000 ) | ( ( endPoint[1][1].b << 4 ) & 0x00000040 );*/ - - block.x |= ((candidateModeMemory[8] >> 0) & 1) << 0; - block.x |= ((candidateModeMemory[8] >> 1) & 1) << 1; - block.x |= ((candidateModeMemory[8] >> 2) & 1) << 2; - block.x |= ((candidateModeMemory[8] >> 3) & 1) << 3; - block.x |= ((candidateModeMemory[8] >> 4) & 1) << 4; - block.x |= ((endPoint[0][0].r >> 0) & 1) << 5; - block.x |= ((endPoint[0][0].r >> 1) & 1) << 6; - block.x |= ((endPoint[0][0].r >> 2) & 1) << 7; - block.x |= ((endPoint[0][0].r >> 3) & 1) << 8; - block.x |= ((endPoint[0][0].r >> 4) & 1) << 9; - block.x |= ((endPoint[0][0].r >> 5) & 1) << 10; - block.x |= ((endPoint[0][0].r >> 6) & 1) << 11; - block.x |= ((endPoint[0][0].r >> 7) & 1) << 12; - block.x |= ((endPoint[1][1].b >> 1) & 1) << 13; - block.x |= ((endPoint[1][0].b >> 4) & 1) << 14; - block.x |= ((endPoint[0][0].g >> 0) & 1) << 15; - block.x |= ((endPoint[0][0].g >> 1) & 1) << 16; - block.x |= ((endPoint[0][0].g >> 2) & 1) << 17; - block.x |= ((endPoint[0][0].g >> 3) & 1) << 18; - block.x |= ((endPoint[0][0].g >> 4) & 1) << 19; - block.x |= ((endPoint[0][0].g >> 5) & 1) << 20; - block.x |= ((endPoint[0][0].g >> 6) & 1) << 21; - block.x |= ((endPoint[0][0].g >> 7) & 1) << 22; - block.x |= ((endPoint[1][0].b >> 5) & 1) << 23; - block.x |= ((endPoint[1][0].g >> 4) & 1) << 24; - block.x |= ((endPoint[0][0].b >> 0) & 1) << 25; - block.x |= ((endPoint[0][0].b >> 1) & 1) << 26; - block.x |= ((endPoint[0][0].b >> 2) & 1) << 27; - block.x |= ((endPoint[0][0].b >> 3) & 1) << 28; - block.x |= ((endPoint[0][0].b >> 4) & 1) << 29; - block.x |= ((endPoint[0][0].b >> 5) & 1) << 30; - block.x |= ((endPoint[0][0].b >> 6) & 1) << 31; - block.y |= ((endPoint[0][0].b >> 7) & 1) << 0; - block.y |= ((endPoint[1][1].b >> 5) & 1) << 1; - block.y |= ((endPoint[1][1].b >> 4) & 1) << 2; - block.y |= ((endPoint[0][1].r >> 0) & 1) << 3; - block.y |= ((endPoint[0][1].r >> 1) & 1) << 4; - block.y |= ((endPoint[0][1].r >> 2) & 1) << 5; - block.y |= ((endPoint[0][1].r >> 3) & 1) << 6; - block.y |= ((endPoint[0][1].r >> 4) & 1) << 7; - block.y |= ((endPoint[1][1].g >> 4) & 1) << 8; - block.y |= ((endPoint[1][0].g >> 0) & 1) << 9; - block.y |= ((endPoint[1][0].g >> 1) & 1) << 10; - block.y |= ((endPoint[1][0].g >> 2) & 1) << 11; - block.y |= ((endPoint[1][0].g >> 3) & 1) << 12; - block.y |= ((endPoint[0][1].g >> 0) & 1) << 13; - block.y |= ((endPoint[0][1].g >> 1) & 1) << 14; - block.y |= ((endPoint[0][1].g >> 2) & 1) << 15; - block.y |= ((endPoint[0][1].g >> 3) & 1) << 16; - block.y |= ((endPoint[0][1].g >> 4) & 1) << 17; - block.y |= ((endPoint[1][1].b >> 0) & 1) << 18; - block.y |= ((endPoint[1][1].g >> 0) & 1) << 19; - block.y |= ((endPoint[1][1].g >> 1) & 1) << 20; - block.y |= ((endPoint[1][1].g >> 2) & 1) << 21; - block.y |= ((endPoint[1][1].g >> 3) & 1) << 22; - block.y |= ((endPoint[0][1].b >> 0) & 1) << 23; - block.y |= ((endPoint[0][1].b >> 1) & 1) << 24; - block.y |= ((endPoint[0][1].b >> 2) & 1) << 25; - block.y |= ((endPoint[0][1].b >> 3) & 1) << 26; - block.y |= ((endPoint[0][1].b >> 4) & 1) << 27; - block.y |= ((endPoint[0][1].b >> 5) & 1) << 28; - block.y |= ((endPoint[1][0].b >> 0) & 1) << 29; - block.y |= ((endPoint[1][0].b >> 1) & 1) << 30; - block.y |= ((endPoint[1][0].b >> 2) & 1) << 31; - block.z |= ((endPoint[1][0].b >> 3) & 1) << 0; - block.z |= ((endPoint[1][0].r >> 0) & 1) << 1; - block.z |= ((endPoint[1][0].r >> 1) & 1) << 2; - block.z |= ((endPoint[1][0].r >> 2) & 1) << 3; - block.z |= ((endPoint[1][0].r >> 3) & 1) << 4; - block.z |= ((endPoint[1][0].r >> 4) & 1) << 5; - block.z |= ((endPoint[1][1].b >> 2) & 1) << 6; - block.z |= ((endPoint[1][1].r >> 0) & 1) << 7; - block.z |= ((endPoint[1][1].r >> 1) & 1) << 8; - block.z |= ((endPoint[1][1].r >> 2) & 1) << 9; - block.z |= ((endPoint[1][1].r >> 3) & 1) << 10; - block.z |= ((endPoint[1][1].r >> 4) & 1) << 11; - block.z |= ((endPoint[1][1].b >> 3) & 1) << 12; - block.z |= ((partition_index >> 0) & 1) << 13; - block.z |= ((partition_index >> 1) & 1) << 14; - block.z |= ((partition_index >> 2) & 1) << 15; - block.z |= ((partition_index >> 3) & 1) << 16; - block.z |= ((partition_index >> 4) & 1) << 17; - } - else if (mode_type == candidateModeFlag[9]) - { - /*block.x = candidateModeMemory[9]; - block.x |= ( ( endPoint[0][0].r << 5 ) & 0x000007E0 ) | ( ( endPoint[0][0].g << 15 ) & 0x001F8000 ) | ( ( endPoint[0][0].b << 25 ) & 0x7E000000 ); - block.y |= ( ( endPoint[0][1].r << 3 ) & 0x000001F8 ) | ( ( endPoint[0][1].g << 13 ) & 0x0007E000 ) | ( ( endPoint[0][1].b << 23 ) & 0x1F800000 ); - block.x |= ( ( endPoint[1][0].g << 16 ) & 0x00200000 ) | ( ( endPoint[1][0].g << 20 ) & 0x01000000 ); - block.x |= ( ( endPoint[1][0].b << 17 ) & 0x00400000 ) | ( ( endPoint[1][0].b << 10 ) & 0x00004000 ); - block.x |= ( ( endPoint[1][1].b << 21 ) & 0x00800000 ) | ( ( endPoint[1][1].b << 12 ) & 0x00003000 ); - block.x |= ( ( endPoint[1][1].g << 26 ) & 0x80000000 ) | ( ( endPoint[1][1].g << 7 ) & 0x00000800 ); - block.yz |= ( endPoint[1][0].gr << uint2(9, 1) ) & uint2(0x00001E00, 0x0000007E); - block.yz |= ( endPoint[1][1].gr << uint2(19, 7) ) & uint2(0x00780000, 0x00001F80); - block.y |= ( endPoint[1][0].b << 29 ) & 0xE0000000; - block.y |= ( ( endPoint[1][1].b >> 4 ) & 0x00000002 ) | ( ( endPoint[1][1].b >> 2 ) & 0x00000004 ) | ( ( endPoint[1][1].b >> 3 ) & 0x00000001 ); - block.z |= ( endPoint[1][0].b >> 3 ) & 0x00000001;*/ - - block.x |= ((candidateModeMemory[9] >> 0) & 1) << 0; - block.x |= ((candidateModeMemory[9] >> 1) & 1) << 1; - block.x |= ((candidateModeMemory[9] >> 2) & 1) << 2; - block.x |= ((candidateModeMemory[9] >> 3) & 1) << 3; - block.x |= ((candidateModeMemory[9] >> 4) & 1) << 4; - block.x |= ((endPoint[0][0].r >> 0) & 1) << 5; - block.x |= ((endPoint[0][0].r >> 1) & 1) << 6; - block.x |= ((endPoint[0][0].r >> 2) & 1) << 7; - block.x |= ((endPoint[0][0].r >> 3) & 1) << 8; - block.x |= ((endPoint[0][0].r >> 4) & 1) << 9; - block.x |= ((endPoint[0][0].r >> 5) & 1) << 10; - block.x |= ((endPoint[1][1].g >> 4) & 1) << 11; - block.x |= ((endPoint[1][1].b >> 0) & 1) << 12; - block.x |= ((endPoint[1][1].b >> 1) & 1) << 13; - block.x |= ((endPoint[1][0].b >> 4) & 1) << 14; - block.x |= ((endPoint[0][0].g >> 0) & 1) << 15; - block.x |= ((endPoint[0][0].g >> 1) & 1) << 16; - block.x |= ((endPoint[0][0].g >> 2) & 1) << 17; - block.x |= ((endPoint[0][0].g >> 3) & 1) << 18; - block.x |= ((endPoint[0][0].g >> 4) & 1) << 19; - block.x |= ((endPoint[0][0].g >> 5) & 1) << 20; - block.x |= ((endPoint[1][0].g >> 5) & 1) << 21; - block.x |= ((endPoint[1][0].b >> 5) & 1) << 22; - block.x |= ((endPoint[1][1].b >> 2) & 1) << 23; - block.x |= ((endPoint[1][0].g >> 4) & 1) << 24; - block.x |= ((endPoint[0][0].b >> 0) & 1) << 25; - block.x |= ((endPoint[0][0].b >> 1) & 1) << 26; - block.x |= ((endPoint[0][0].b >> 2) & 1) << 27; - block.x |= ((endPoint[0][0].b >> 3) & 1) << 28; - block.x |= ((endPoint[0][0].b >> 4) & 1) << 29; - block.x |= ((endPoint[0][0].b >> 5) & 1) << 30; - block.x |= ((endPoint[1][1].g >> 5) & 1) << 31; - block.y |= ((endPoint[1][1].b >> 3) & 1) << 0; - block.y |= ((endPoint[1][1].b >> 5) & 1) << 1; - block.y |= ((endPoint[1][1].b >> 4) & 1) << 2; - block.y |= ((endPoint[0][1].r >> 0) & 1) << 3; - block.y |= ((endPoint[0][1].r >> 1) & 1) << 4; - block.y |= ((endPoint[0][1].r >> 2) & 1) << 5; - block.y |= ((endPoint[0][1].r >> 3) & 1) << 6; - block.y |= ((endPoint[0][1].r >> 4) & 1) << 7; - block.y |= ((endPoint[0][1].r >> 5) & 1) << 8; - block.y |= ((endPoint[1][0].g >> 0) & 1) << 9; - block.y |= ((endPoint[1][0].g >> 1) & 1) << 10; - block.y |= ((endPoint[1][0].g >> 2) & 1) << 11; - block.y |= ((endPoint[1][0].g >> 3) & 1) << 12; - block.y |= ((endPoint[0][1].g >> 0) & 1) << 13; - block.y |= ((endPoint[0][1].g >> 1) & 1) << 14; - block.y |= ((endPoint[0][1].g >> 2) & 1) << 15; - block.y |= ((endPoint[0][1].g >> 3) & 1) << 16; - block.y |= ((endPoint[0][1].g >> 4) & 1) << 17; - block.y |= ((endPoint[0][1].g >> 5) & 1) << 18; - block.y |= ((endPoint[1][1].g >> 0) & 1) << 19; - block.y |= ((endPoint[1][1].g >> 1) & 1) << 20; - block.y |= ((endPoint[1][1].g >> 2) & 1) << 21; - block.y |= ((endPoint[1][1].g >> 3) & 1) << 22; - block.y |= ((endPoint[0][1].b >> 0) & 1) << 23; - block.y |= ((endPoint[0][1].b >> 1) & 1) << 24; - block.y |= ((endPoint[0][1].b >> 2) & 1) << 25; - block.y |= ((endPoint[0][1].b >> 3) & 1) << 26; - block.y |= ((endPoint[0][1].b >> 4) & 1) << 27; - block.y |= ((endPoint[0][1].b >> 5) & 1) << 28; - block.y |= ((endPoint[1][0].b >> 0) & 1) << 29; - block.y |= ((endPoint[1][0].b >> 1) & 1) << 30; - block.y |= ((endPoint[1][0].b >> 2) & 1) << 31; - block.z |= ((endPoint[1][0].b >> 3) & 1) << 0; - block.z |= ((endPoint[1][0].r >> 0) & 1) << 1; - block.z |= ((endPoint[1][0].r >> 1) & 1) << 2; - block.z |= ((endPoint[1][0].r >> 2) & 1) << 3; - block.z |= ((endPoint[1][0].r >> 3) & 1) << 4; - block.z |= ((endPoint[1][0].r >> 4) & 1) << 5; - block.z |= ((endPoint[1][0].r >> 5) & 1) << 6; - block.z |= ((endPoint[1][1].r >> 0) & 1) << 7; - block.z |= ((endPoint[1][1].r >> 1) & 1) << 8; - block.z |= ((endPoint[1][1].r >> 2) & 1) << 9; - block.z |= ((endPoint[1][1].r >> 3) & 1) << 10; - block.z |= ((endPoint[1][1].r >> 4) & 1) << 11; - block.z |= ((endPoint[1][1].r >> 5) & 1) << 12; - block.z |= ((partition_index >> 0) & 1) << 13; - block.z |= ((partition_index >> 1) & 1) << 14; - block.z |= ((partition_index >> 2) & 1) << 15; - block.z |= ((partition_index >> 3) & 1) << 16; - block.z |= ((partition_index >> 4) & 1) << 17; - } -} -void block_package(inout uint4 block, int2x3 endPoint, uint mode_type) // for mode 11 - 14 -{ - /*block.x = ( ( endPoint[0].r << 5 ) & 0x00007FE0 ) | ( ( endPoint[0].g << 15 ) & 0x01FF8000 ) | ( ( endPoint[0].b << 25 ) & 0xFE000000 ); - block.y |= ( endPoint[0].b >> 7 ) & 0x00000007;*/ - - block.xy = 0; - block.z &= 0xFFFFFFFE; - - - if (mode_type == candidateModeFlag[10]) - { - /* block.x |= candidateModeMemory[10]; - block.y |= ( ( endPoint[1].r << 3 ) & 0x00001FF8 ) | ( ( endPoint[1].g << 13 ) & 0x007FE000 ) | ( ( endPoint[1].b << 23 ) & 0xFF800000 ); - block.z |= ( endPoint[1].b >> 9 ) & 0x00000001;*/ - - block.x |= ((candidateModeMemory[10] >> 0) & 1) << 0; - block.x |= ((candidateModeMemory[10] >> 1) & 1) << 1; - block.x |= ((candidateModeMemory[10] >> 2) & 1) << 2; - block.x |= ((candidateModeMemory[10] >> 3) & 1) << 3; - block.x |= ((candidateModeMemory[10] >> 4) & 1) << 4; - block.x |= ((endPoint[0].r >> 0) & 1) << 5; - block.x |= ((endPoint[0].r >> 1) & 1) << 6; - block.x |= ((endPoint[0].r >> 2) & 1) << 7; - block.x |= ((endPoint[0].r >> 3) & 1) << 8; - block.x |= ((endPoint[0].r >> 4) & 1) << 9; - block.x |= ((endPoint[0].r >> 5) & 1) << 10; - block.x |= ((endPoint[0].r >> 6) & 1) << 11; - block.x |= ((endPoint[0].r >> 7) & 1) << 12; - block.x |= ((endPoint[0].r >> 8) & 1) << 13; - block.x |= ((endPoint[0].r >> 9) & 1) << 14; - block.x |= ((endPoint[0].g >> 0) & 1) << 15; - block.x |= ((endPoint[0].g >> 1) & 1) << 16; - block.x |= ((endPoint[0].g >> 2) & 1) << 17; - block.x |= ((endPoint[0].g >> 3) & 1) << 18; - block.x |= ((endPoint[0].g >> 4) & 1) << 19; - block.x |= ((endPoint[0].g >> 5) & 1) << 20; - block.x |= ((endPoint[0].g >> 6) & 1) << 21; - block.x |= ((endPoint[0].g >> 7) & 1) << 22; - block.x |= ((endPoint[0].g >> 8) & 1) << 23; - block.x |= ((endPoint[0].g >> 9) & 1) << 24; - block.x |= ((endPoint[0].b >> 0) & 1) << 25; - block.x |= ((endPoint[0].b >> 1) & 1) << 26; - block.x |= ((endPoint[0].b >> 2) & 1) << 27; - block.x |= ((endPoint[0].b >> 3) & 1) << 28; - block.x |= ((endPoint[0].b >> 4) & 1) << 29; - block.x |= ((endPoint[0].b >> 5) & 1) << 30; - block.x |= ((endPoint[0].b >> 6) & 1) << 31; - block.y |= ((endPoint[0].b >> 7) & 1) << 0; - block.y |= ((endPoint[0].b >> 8) & 1) << 1; - block.y |= ((endPoint[0].b >> 9) & 1) << 2; - block.y |= ((endPoint[1].r >> 0) & 1) << 3; - block.y |= ((endPoint[1].r >> 1) & 1) << 4; - block.y |= ((endPoint[1].r >> 2) & 1) << 5; - block.y |= ((endPoint[1].r >> 3) & 1) << 6; - block.y |= ((endPoint[1].r >> 4) & 1) << 7; - block.y |= ((endPoint[1].r >> 5) & 1) << 8; - block.y |= ((endPoint[1].r >> 6) & 1) << 9; - block.y |= ((endPoint[1].r >> 7) & 1) << 10; - block.y |= ((endPoint[1].r >> 8) & 1) << 11; - block.y |= ((endPoint[1].r >> 9) & 1) << 12; - block.y |= ((endPoint[1].g >> 0) & 1) << 13; - block.y |= ((endPoint[1].g >> 1) & 1) << 14; - block.y |= ((endPoint[1].g >> 2) & 1) << 15; - block.y |= ((endPoint[1].g >> 3) & 1) << 16; - block.y |= ((endPoint[1].g >> 4) & 1) << 17; - block.y |= ((endPoint[1].g >> 5) & 1) << 18; - block.y |= ((endPoint[1].g >> 6) & 1) << 19; - block.y |= ((endPoint[1].g >> 7) & 1) << 20; - block.y |= ((endPoint[1].g >> 8) & 1) << 21; - block.y |= ((endPoint[1].g >> 9) & 1) << 22; - block.y |= ((endPoint[1].b >> 0) & 1) << 23; - block.y |= ((endPoint[1].b >> 1) & 1) << 24; - block.y |= ((endPoint[1].b >> 2) & 1) << 25; - block.y |= ((endPoint[1].b >> 3) & 1) << 26; - block.y |= ((endPoint[1].b >> 4) & 1) << 27; - block.y |= ((endPoint[1].b >> 5) & 1) << 28; - block.y |= ((endPoint[1].b >> 6) & 1) << 29; - block.y |= ((endPoint[1].b >> 7) & 1) << 30; - block.y |= ((endPoint[1].b >> 8) & 1) << 31; - block.z |= ((endPoint[1].b >> 9) & 1) << 0; - } - else if (mode_type == candidateModeFlag[11]) - { - /*block.x |= candidateModeMemory[11]; - block.y |= ( ( endPoint[0].r << 2 ) & 0x00001000 ) | ( ( endPoint[0].g << 12 ) & 0x00400000 ); - block.y |= ( ( endPoint[1].r << 3 ) & 0x00000FF8 ) | ( ( endPoint[1].g << 13 ) & 0x003FE000 ) | ( ( endPoint[1].b << 23 ) & 0xFF800000 ); - block.z |= ( endPoint[0].b >> 10 ) & 0x00000001;*/ - - block.x |= ((candidateModeMemory[11] >> 0) & 1) << 0; - block.x |= ((candidateModeMemory[11] >> 1) & 1) << 1; - block.x |= ((candidateModeMemory[11] >> 2) & 1) << 2; - block.x |= ((candidateModeMemory[11] >> 3) & 1) << 3; - block.x |= ((candidateModeMemory[11] >> 4) & 1) << 4; - block.x |= ((endPoint[0].r >> 0) & 1) << 5; - block.x |= ((endPoint[0].r >> 1) & 1) << 6; - block.x |= ((endPoint[0].r >> 2) & 1) << 7; - block.x |= ((endPoint[0].r >> 3) & 1) << 8; - block.x |= ((endPoint[0].r >> 4) & 1) << 9; - block.x |= ((endPoint[0].r >> 5) & 1) << 10; - block.x |= ((endPoint[0].r >> 6) & 1) << 11; - block.x |= ((endPoint[0].r >> 7) & 1) << 12; - block.x |= ((endPoint[0].r >> 8) & 1) << 13; - block.x |= ((endPoint[0].r >> 9) & 1) << 14; - block.x |= ((endPoint[0].g >> 0) & 1) << 15; - block.x |= ((endPoint[0].g >> 1) & 1) << 16; - block.x |= ((endPoint[0].g >> 2) & 1) << 17; - block.x |= ((endPoint[0].g >> 3) & 1) << 18; - block.x |= ((endPoint[0].g >> 4) & 1) << 19; - block.x |= ((endPoint[0].g >> 5) & 1) << 20; - block.x |= ((endPoint[0].g >> 6) & 1) << 21; - block.x |= ((endPoint[0].g >> 7) & 1) << 22; - block.x |= ((endPoint[0].g >> 8) & 1) << 23; - block.x |= ((endPoint[0].g >> 9) & 1) << 24; - block.x |= ((endPoint[0].b >> 0) & 1) << 25; - block.x |= ((endPoint[0].b >> 1) & 1) << 26; - block.x |= ((endPoint[0].b >> 2) & 1) << 27; - block.x |= ((endPoint[0].b >> 3) & 1) << 28; - block.x |= ((endPoint[0].b >> 4) & 1) << 29; - block.x |= ((endPoint[0].b >> 5) & 1) << 30; - block.x |= ((endPoint[0].b >> 6) & 1) << 31; - block.y |= ((endPoint[0].b >> 7) & 1) << 0; - block.y |= ((endPoint[0].b >> 8) & 1) << 1; - block.y |= ((endPoint[0].b >> 9) & 1) << 2; - block.y |= ((endPoint[1].r >> 0) & 1) << 3; - block.y |= ((endPoint[1].r >> 1) & 1) << 4; - block.y |= ((endPoint[1].r >> 2) & 1) << 5; - block.y |= ((endPoint[1].r >> 3) & 1) << 6; - block.y |= ((endPoint[1].r >> 4) & 1) << 7; - block.y |= ((endPoint[1].r >> 5) & 1) << 8; - block.y |= ((endPoint[1].r >> 6) & 1) << 9; - block.y |= ((endPoint[1].r >> 7) & 1) << 10; - block.y |= ((endPoint[1].r >> 8) & 1) << 11; - block.y |= ((endPoint[0].r >> 10) & 1) << 12; - block.y |= ((endPoint[1].g >> 0) & 1) << 13; - block.y |= ((endPoint[1].g >> 1) & 1) << 14; - block.y |= ((endPoint[1].g >> 2) & 1) << 15; - block.y |= ((endPoint[1].g >> 3) & 1) << 16; - block.y |= ((endPoint[1].g >> 4) & 1) << 17; - block.y |= ((endPoint[1].g >> 5) & 1) << 18; - block.y |= ((endPoint[1].g >> 6) & 1) << 19; - block.y |= ((endPoint[1].g >> 7) & 1) << 20; - block.y |= ((endPoint[1].g >> 8) & 1) << 21; - block.y |= ((endPoint[0].g >> 10) & 1) << 22; - block.y |= ((endPoint[1].b >> 0) & 1) << 23; - block.y |= ((endPoint[1].b >> 1) & 1) << 24; - block.y |= ((endPoint[1].b >> 2) & 1) << 25; - block.y |= ((endPoint[1].b >> 3) & 1) << 26; - block.y |= ((endPoint[1].b >> 4) & 1) << 27; - block.y |= ((endPoint[1].b >> 5) & 1) << 28; - block.y |= ((endPoint[1].b >> 6) & 1) << 29; - block.y |= ((endPoint[1].b >> 7) & 1) << 30; - block.y |= ((endPoint[1].b >> 8) & 1) << 31; - block.z |= ((endPoint[0].b >> 10) & 1) << 0; - } - else if (mode_type == candidateModeFlag[12])// violate the spec in [0].low - { - /*block.x |= candidateModeMemory[12]; - block.y |= ( ( endPoint[0].r << 2 ) & 0x00001000 ) | ( ( endPoint[0].g << 12 ) & 0x00400000 ); - block.y |= ( ( endPoint[0].r << 0 ) & 0x00000800 ) | ( ( endPoint[0].g << 10 ) & 0x00200000 ); - block.y |= ( endPoint[0].b << 20 ) & 0x80000000; - block.y |= ( ( endPoint[1].r << 3 ) & 0x000007F8 ) | ( ( endPoint[1].g << 13 ) & 0x001FE000 ) | ( ( endPoint[1].b << 23 ) & 0x7F800000 ); - block.z |= ( endPoint[0].b >> 10 ) & 0x00000001;*/ - - block.x |= ((candidateModeMemory[12] >> 0) & 1) << 0; - block.x |= ((candidateModeMemory[12] >> 1) & 1) << 1; - block.x |= ((candidateModeMemory[12] >> 2) & 1) << 2; - block.x |= ((candidateModeMemory[12] >> 3) & 1) << 3; - block.x |= ((candidateModeMemory[12] >> 4) & 1) << 4; - block.x |= ((endPoint[0].r >> 0) & 1) << 5; - block.x |= ((endPoint[0].r >> 1) & 1) << 6; - block.x |= ((endPoint[0].r >> 2) & 1) << 7; - block.x |= ((endPoint[0].r >> 3) & 1) << 8; - block.x |= ((endPoint[0].r >> 4) & 1) << 9; - block.x |= ((endPoint[0].r >> 5) & 1) << 10; - block.x |= ((endPoint[0].r >> 6) & 1) << 11; - block.x |= ((endPoint[0].r >> 7) & 1) << 12; - block.x |= ((endPoint[0].r >> 8) & 1) << 13; - block.x |= ((endPoint[0].r >> 9) & 1) << 14; - block.x |= ((endPoint[0].g >> 0) & 1) << 15; - block.x |= ((endPoint[0].g >> 1) & 1) << 16; - block.x |= ((endPoint[0].g >> 2) & 1) << 17; - block.x |= ((endPoint[0].g >> 3) & 1) << 18; - block.x |= ((endPoint[0].g >> 4) & 1) << 19; - block.x |= ((endPoint[0].g >> 5) & 1) << 20; - block.x |= ((endPoint[0].g >> 6) & 1) << 21; - block.x |= ((endPoint[0].g >> 7) & 1) << 22; - block.x |= ((endPoint[0].g >> 8) & 1) << 23; - block.x |= ((endPoint[0].g >> 9) & 1) << 24; - block.x |= ((endPoint[0].b >> 0) & 1) << 25; - block.x |= ((endPoint[0].b >> 1) & 1) << 26; - block.x |= ((endPoint[0].b >> 2) & 1) << 27; - block.x |= ((endPoint[0].b >> 3) & 1) << 28; - block.x |= ((endPoint[0].b >> 4) & 1) << 29; - block.x |= ((endPoint[0].b >> 5) & 1) << 30; - block.x |= ((endPoint[0].b >> 6) & 1) << 31; - block.y |= ((endPoint[0].b >> 7) & 1) << 0; - block.y |= ((endPoint[0].b >> 8) & 1) << 1; - block.y |= ((endPoint[0].b >> 9) & 1) << 2; - block.y |= ((endPoint[1].r >> 0) & 1) << 3; - block.y |= ((endPoint[1].r >> 1) & 1) << 4; - block.y |= ((endPoint[1].r >> 2) & 1) << 5; - block.y |= ((endPoint[1].r >> 3) & 1) << 6; - block.y |= ((endPoint[1].r >> 4) & 1) << 7; - block.y |= ((endPoint[1].r >> 5) & 1) << 8; - block.y |= ((endPoint[1].r >> 6) & 1) << 9; - block.y |= ((endPoint[1].r >> 7) & 1) << 10; - block.y |= ((endPoint[0].r >> 11) & 1) << 11; - block.y |= ((endPoint[0].r >> 10) & 1) << 12; - block.y |= ((endPoint[1].g >> 0) & 1) << 13; - block.y |= ((endPoint[1].g >> 1) & 1) << 14; - block.y |= ((endPoint[1].g >> 2) & 1) << 15; - block.y |= ((endPoint[1].g >> 3) & 1) << 16; - block.y |= ((endPoint[1].g >> 4) & 1) << 17; - block.y |= ((endPoint[1].g >> 5) & 1) << 18; - block.y |= ((endPoint[1].g >> 6) & 1) << 19; - block.y |= ((endPoint[1].g >> 7) & 1) << 20; - block.y |= ((endPoint[0].g >> 11) & 1) << 21; - block.y |= ((endPoint[0].g >> 10) & 1) << 22; - block.y |= ((endPoint[1].b >> 0) & 1) << 23; - block.y |= ((endPoint[1].b >> 1) & 1) << 24; - block.y |= ((endPoint[1].b >> 2) & 1) << 25; - block.y |= ((endPoint[1].b >> 3) & 1) << 26; - block.y |= ((endPoint[1].b >> 4) & 1) << 27; - block.y |= ((endPoint[1].b >> 5) & 1) << 28; - block.y |= ((endPoint[1].b >> 6) & 1) << 29; - block.y |= ((endPoint[1].b >> 7) & 1) << 30; - block.y |= ((endPoint[0].b >> 11) & 1) << 31; - block.z |= ((endPoint[0].b >> 10) & 1) << 0; - } - else if (mode_type == candidateModeFlag[13]) - { - /*block.x |= candidateModeMemory[13]; - block.y |= ( ( endPoint[0].r >> 8 ) & 0x00000080 ); - block.y |= ( ( endPoint[0].r >> 6 ) & 0x00000100 ); - block.y |= ( ( endPoint[0].r >> 4 ) & 0x00000200 ); - block.y |= ( ( endPoint[0].r >> 2 ) & 0x00000400 ); - block.y |= ( ( endPoint[0].r >> 0 ) & 0x00000800 ); - block.y |= ( ( endPoint[0].r << 2 ) & 0x00001000 ); - block.y |= ( ( endPoint[0].g << 2 ) & 0x00020000 ); - block.y |= ( ( endPoint[0].g << 4 ) & 0x00040000 ); - block.y |= ( ( endPoint[0].g << 6 ) & 0x00080000 ); - block.y |= ( ( endPoint[0].g << 8 ) & 0x00100000 ); - block.y |= ( ( endPoint[0].g << 10 ) & 0x00200000 ); - block.y |= ( ( endPoint[0].g << 12 ) & 0x00400000 ); - block.y |= ( ( endPoint[0].b << 12 ) & 0x08000000 ); - block.y |= ( ( endPoint[0].b << 14 ) & 0x10000000 ); - block.y |= ( ( endPoint[0].b << 16 ) & 0x20000000 ); - block.y |= ( ( endPoint[0].b << 18 ) & 0x40000000 ); - block.y |= ( ( endPoint[0].b << 20 ) & 0x80000000 ); - block.y |= ( ( endPoint[1].r << 3 ) & 0x00000078 ) | ( ( endPoint[1].g << 13 ) & 0x0001E000 ) | ( ( endPoint[1].b << 23 ) & 0x07800000 ); - block.z |= ( endPoint[0].b >> 10 ) & 0x00000001;*/ - - block.x |= ((candidateModeMemory[13] >> 0) & 1) << 0; - block.x |= ((candidateModeMemory[13] >> 1) & 1) << 1; - block.x |= ((candidateModeMemory[13] >> 2) & 1) << 2; - block.x |= ((candidateModeMemory[13] >> 3) & 1) << 3; - block.x |= ((candidateModeMemory[13] >> 4) & 1) << 4; - block.x |= ((endPoint[0].r >> 0) & 1) << 5; - block.x |= ((endPoint[0].r >> 1) & 1) << 6; - block.x |= ((endPoint[0].r >> 2) & 1) << 7; - block.x |= ((endPoint[0].r >> 3) & 1) << 8; - block.x |= ((endPoint[0].r >> 4) & 1) << 9; - block.x |= ((endPoint[0].r >> 5) & 1) << 10; - block.x |= ((endPoint[0].r >> 6) & 1) << 11; - block.x |= ((endPoint[0].r >> 7) & 1) << 12; - block.x |= ((endPoint[0].r >> 8) & 1) << 13; - block.x |= ((endPoint[0].r >> 9) & 1) << 14; - block.x |= ((endPoint[0].g >> 0) & 1) << 15; - block.x |= ((endPoint[0].g >> 1) & 1) << 16; - block.x |= ((endPoint[0].g >> 2) & 1) << 17; - block.x |= ((endPoint[0].g >> 3) & 1) << 18; - block.x |= ((endPoint[0].g >> 4) & 1) << 19; - block.x |= ((endPoint[0].g >> 5) & 1) << 20; - block.x |= ((endPoint[0].g >> 6) & 1) << 21; - block.x |= ((endPoint[0].g >> 7) & 1) << 22; - block.x |= ((endPoint[0].g >> 8) & 1) << 23; - block.x |= ((endPoint[0].g >> 9) & 1) << 24; - block.x |= ((endPoint[0].b >> 0) & 1) << 25; - block.x |= ((endPoint[0].b >> 1) & 1) << 26; - block.x |= ((endPoint[0].b >> 2) & 1) << 27; - block.x |= ((endPoint[0].b >> 3) & 1) << 28; - block.x |= ((endPoint[0].b >> 4) & 1) << 29; - block.x |= ((endPoint[0].b >> 5) & 1) << 30; - block.x |= ((endPoint[0].b >> 6) & 1) << 31; - block.y |= ((endPoint[0].b >> 7) & 1) << 0; - block.y |= ((endPoint[0].b >> 8) & 1) << 1; - block.y |= ((endPoint[0].b >> 9) & 1) << 2; - block.y |= ((endPoint[1].r >> 0) & 1) << 3; - block.y |= ((endPoint[1].r >> 1) & 1) << 4; - block.y |= ((endPoint[1].r >> 2) & 1) << 5; - block.y |= ((endPoint[1].r >> 3) & 1) << 6; - block.y |= ((endPoint[0].r >> 15) & 1) << 7; - block.y |= ((endPoint[0].r >> 14) & 1) << 8; - block.y |= ((endPoint[0].r >> 13) & 1) << 9; - block.y |= ((endPoint[0].r >> 12) & 1) << 10; - block.y |= ((endPoint[0].r >> 11) & 1) << 11; - block.y |= ((endPoint[0].r >> 10) & 1) << 12; - block.y |= ((endPoint[1].g >> 0) & 1) << 13; - block.y |= ((endPoint[1].g >> 1) & 1) << 14; - block.y |= ((endPoint[1].g >> 2) & 1) << 15; - block.y |= ((endPoint[1].g >> 3) & 1) << 16; - block.y |= ((endPoint[0].g >> 15) & 1) << 17; - block.y |= ((endPoint[0].g >> 14) & 1) << 18; - block.y |= ((endPoint[0].g >> 13) & 1) << 19; - block.y |= ((endPoint[0].g >> 12) & 1) << 20; - block.y |= ((endPoint[0].g >> 11) & 1) << 21; - block.y |= ((endPoint[0].g >> 10) & 1) << 22; - block.y |= ((endPoint[1].b >> 0) & 1) << 23; - block.y |= ((endPoint[1].b >> 1) & 1) << 24; - block.y |= ((endPoint[1].b >> 2) & 1) << 25; - block.y |= ((endPoint[1].b >> 3) & 1) << 26; - block.y |= ((endPoint[0].b >> 15) & 1) << 27; - block.y |= ((endPoint[0].b >> 14) & 1) << 28; - block.y |= ((endPoint[0].b >> 13) & 1) << 29; - block.y |= ((endPoint[0].b >> 12) & 1) << 30; - block.y |= ((endPoint[0].b >> 11) & 1) << 31; - block.z |= ((endPoint[0].b >> 10) & 1) << 0; - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/Shaders/BC7Encode.hlsl b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/Shaders/BC7Encode.hlsl deleted file mode 100644 index eed5578..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/Shaders/BC7Encode.hlsl +++ /dev/null @@ -1,1932 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: BC7Encode.hlsl -// -// The Compute Shader for BC7 Encoder -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -//-------------------------------------------------------------------------------------- - -#define REF_DEVICE - -#define CHAR_LENGTH 8 -#define NCHANNELS 4 -#define BC7_UNORM 98 -#define MAX_UINT 0xFFFFFFFF -#define MIN_UINT 0 - -static const uint candidateSectionBit[64] = //Associated to partition 0-63 -{ - 0xCCCC, 0x8888, 0xEEEE, 0xECC8, - 0xC880, 0xFEEC, 0xFEC8, 0xEC80, - 0xC800, 0xFFEC, 0xFE80, 0xE800, - 0xFFE8, 0xFF00, 0xFFF0, 0xF000, - 0xF710, 0x008E, 0x7100, 0x08CE, - 0x008C, 0x7310, 0x3100, 0x8CCE, - 0x088C, 0x3110, 0x6666, 0x366C, - 0x17E8, 0x0FF0, 0x718E, 0x399C, - 0xaaaa, 0xf0f0, 0x5a5a, 0x33cc, - 0x3c3c, 0x55aa, 0x9696, 0xa55a, - 0x73ce, 0x13c8, 0x324c, 0x3bdc, - 0x6996, 0xc33c, 0x9966, 0x660, - 0x272, 0x4e4, 0x4e40, 0x2720, - 0xc936, 0x936c, 0x39c6, 0x639c, - 0x9336, 0x9cc6, 0x817e, 0xe718, - 0xccf0, 0xfcc, 0x7744, 0xee22, -}; -static const uint candidateSectionBit2[64] = //Associated to partition 64-127 -{ - 0xaa685050, 0x6a5a5040, 0x5a5a4200, 0x5450a0a8, - 0xa5a50000, 0xa0a05050, 0x5555a0a0, 0x5a5a5050, - 0xaa550000, 0xaa555500, 0xaaaa5500, 0x90909090, - 0x94949494, 0xa4a4a4a4, 0xa9a59450, 0x2a0a4250, - 0xa5945040, 0x0a425054, 0xa5a5a500, 0x55a0a0a0, - 0xa8a85454, 0x6a6a4040, 0xa4a45000, 0x1a1a0500, - 0x0050a4a4, 0xaaa59090, 0x14696914, 0x69691400, - 0xa08585a0, 0xaa821414, 0x50a4a450, 0x6a5a0200, - 0xa9a58000, 0x5090a0a8, 0xa8a09050, 0x24242424, - 0x00aa5500, 0x24924924, 0x24499224, 0x50a50a50, - 0x500aa550, 0xaaaa4444, 0x66660000, 0xa5a0a5a0, - 0x50a050a0, 0x69286928, 0x44aaaa44, 0x66666600, - 0xaa444444, 0x54a854a8, 0x95809580, 0x96969600, - 0xa85454a8, 0x80959580, 0xaa141414, 0x96960000, - 0xaaaa1414, 0xa05050a0, 0xa0a5a5a0, 0x96000000, - 0x40804080, 0xa9a8a9a8, 0xaaaaaa44, 0x2a4a5254, -}; -static const uint2 candidateFixUpIndex1D[128] = -{ - {15, 0},{15, 0},{15, 0},{15, 0}, - {15, 0},{15, 0},{15, 0},{15, 0}, - {15, 0},{15, 0},{15, 0},{15, 0}, - {15, 0},{15, 0},{15, 0},{15, 0}, - {15, 0},{ 2, 0},{ 8, 0},{ 2, 0}, - { 2, 0},{ 8, 0},{ 8, 0},{15, 0}, - { 2, 0},{ 8, 0},{ 2, 0},{ 2, 0}, - { 8, 0},{ 8, 0},{ 2, 0},{ 2, 0}, - - {15, 0},{15, 0},{ 6, 0},{ 8, 0}, - { 2, 0},{ 8, 0},{15, 0},{15, 0}, - { 2, 0},{ 8, 0},{ 2, 0},{ 2, 0}, - { 2, 0},{15, 0},{15, 0},{ 6, 0}, - { 6, 0},{ 2, 0},{ 6, 0},{ 8, 0}, - {15, 0},{15, 0},{ 2, 0},{ 2, 0}, - {15, 0},{15, 0},{15, 0},{15, 0}, - {15, 0},{ 2, 0},{ 2, 0},{15, 0}, - //candidateFixUpIndex1D[i][1], i < 64 should not be used - - { 3,15},{ 3, 8},{15, 8},{15, 3}, - { 8,15},{ 3,15},{15, 3},{15, 8}, - { 8,15},{ 8,15},{ 6,15},{ 6,15}, - { 6,15},{ 5,15},{ 3,15},{ 3, 8}, - { 3,15},{ 3, 8},{ 8,15},{15, 3}, - { 3,15},{ 3, 8},{ 6,15},{10, 8}, - { 5, 3},{ 8,15},{ 8, 6},{ 6,10}, - { 8,15},{ 5,15},{15,10},{15, 8}, - - { 8,15},{15, 3},{ 3,15},{ 5,10}, - { 6,10},{10, 8},{ 8, 9},{15,10}, - {15, 6},{ 3,15},{15, 8},{ 5,15}, - {15, 3},{15, 6},{15, 6},{15, 8}, //The Spec doesn't mark the first fixed up index in this row, so I apply 15 for them, and seems correct - { 3,15},{15, 3},{ 5,15},{ 5,15}, - { 5,15},{ 8,15},{ 5,15},{10,15}, - { 5,15},{10,15},{ 8,15},{13,15}, - {15, 3},{12,15},{ 3,15},{ 3, 8}, -}; -static const uint2 candidateFixUpIndex1DOrdered[128] = //Same with candidateFixUpIndex1D but order the result when i >= 64 -{ - {15, 0},{15, 0},{15, 0},{15, 0}, - {15, 0},{15, 0},{15, 0},{15, 0}, - {15, 0},{15, 0},{15, 0},{15, 0}, - {15, 0},{15, 0},{15, 0},{15, 0}, - {15, 0},{ 2, 0},{ 8, 0},{ 2, 0}, - { 2, 0},{ 8, 0},{ 8, 0},{15, 0}, - { 2, 0},{ 8, 0},{ 2, 0},{ 2, 0}, - { 8, 0},{ 8, 0},{ 2, 0},{ 2, 0}, - - {15, 0},{15, 0},{ 6, 0},{ 8, 0}, - { 2, 0},{ 8, 0},{15, 0},{15, 0}, - { 2, 0},{ 8, 0},{ 2, 0},{ 2, 0}, - { 2, 0},{15, 0},{15, 0},{ 6, 0}, - { 6, 0},{ 2, 0},{ 6, 0},{ 8, 0}, - {15, 0},{15, 0},{ 2, 0},{ 2, 0}, - {15, 0},{15, 0},{15, 0},{15, 0}, - {15, 0},{ 2, 0},{ 2, 0},{15, 0}, - //candidateFixUpIndex1DOrdered[i][1], i < 64 should not be used - - { 3,15},{ 3, 8},{ 8,15},{ 3,15}, - { 8,15},{ 3,15},{ 3,15},{ 8,15}, - { 8,15},{ 8,15},{ 6,15},{ 6,15}, - { 6,15},{ 5,15},{ 3,15},{ 3, 8}, - { 3,15},{ 3, 8},{ 8,15},{ 3,15}, - { 3,15},{ 3, 8},{ 6,15},{ 8,10}, - { 3, 5},{ 8,15},{ 6, 8},{ 6,10}, - { 8,15},{ 5,15},{10,15},{ 8,15}, - - { 8,15},{ 3,15},{ 3,15},{ 5,10}, - { 6,10},{ 8,10},{ 8, 9},{10,15}, - { 6,15},{ 3,15},{ 8,15},{ 5,15}, - { 3,15},{ 6,15},{ 6,15},{ 8,15}, //The Spec doesn't mark the first fixed up index in this row, so I apply 15 for them, and seems correct - { 3,15},{ 3,15},{ 5,15},{ 5,15}, - { 5,15},{ 8,15},{ 5,15},{10,15}, - { 5,15},{10,15},{ 8,15},{13,15}, - { 3,15},{12,15},{ 3,15},{ 3, 8}, -}; -//static const uint4x4 candidateRotation[4] = -//{ -// {1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1}, -// {0,0,0,1},{0,1,0,0},{0,0,1,0},{1,0,0,0}, -// {1,0,0,0},{0,0,0,1},{0,0,1,0},{0,1,0,0}, -// {1,0,0,0},{0,1,0,0},{0,0,0,1},{0,0,1,0} -//}; -//static const uint2 candidateIndexPrec[8] = {{3,0},{3,0},{2,0},{2,0}, -// {2,3}, //color index and alpha index can exchange -// {2,2},{4,4},{2,2}}; - -static const uint aWeight[3][16] = { {0, 4, 9, 13, 17, 21, 26, 30, 34, 38, 43, 47, 51, 55, 60, 64}, - {0, 9, 18, 27, 37, 46, 55, 64, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 21, 43, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }; - -//4 bit index: 0, 4, 9, 13, 17, 21, 26, 30, 34, 38, 43, 47, 51, 55, 60, 64 -static const uint aStep[3][64] = { { 0, 0, 0, 1, 1, 1, 1, 2, - 2, 2, 2, 2, 3, 3, 3, 3, - 4, 4, 4, 4, 5, 5, 5, 5, - 6, 6, 6, 6, 6, 7, 7, 7, - 7, 8, 8, 8, 8, 9, 9, 9, - 9,10,10,10,10,10,11,11, - 11,11,12,12,12,12,13,13, - 13,13,14,14,14,14,15,15 }, - //3 bit index: 0, 9, 18, 27, 37, 46, 55, 64 - { 0,0,0,0,0,1,1,1, - 1,1,1,1,1,1,2,2, - 2,2,2,2,2,2,2,3, - 3,3,3,3,3,3,3,3, - 3,4,4,4,4,4,4,4, - 4,4,5,5,5,5,5,5, - 5,5,5,6,6,6,6,6, - 6,6,6,6,7,7,7,7 }, - //2 bit index: 0, 21, 43, 64 - { 0,0,0,0,0,0,0,0, - 0,0,0,1,1,1,1,1, - 1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1, - 1,2,2,2,2,2,2,2, - 2,2,2,2,2,2,2,2, - 2,2,2,2,2,2,3,3, - 3,3,3,3,3,3,3,3 } }; - -cbuffer cbCS : register(b0) -{ - uint g_tex_width; - uint g_num_block_x; - uint g_format; - uint g_mode_id; - uint g_start_block_id; - uint g_num_total_blocks; - float g_alpha_weight; -}; - -//Forward declaration -uint2x4 compress_endpoints0(inout uint2x4 endPoint, uint2 P); //Mode = 0 -uint2x4 compress_endpoints1(inout uint2x4 endPoint, uint2 P); //Mode = 1 -uint2x4 compress_endpoints2(inout uint2x4 endPoint); //Mode = 2 -uint2x4 compress_endpoints3(inout uint2x4 endPoint, uint2 P); //Mode = 3 -uint2x4 compress_endpoints7(inout uint2x4 endPoint, uint2 P); //Mode = 7 -uint2x4 compress_endpoints6(inout uint2x4 endPoint, uint2 P); //Mode = 6 -uint2x4 compress_endpoints4(inout uint2x4 endPoint); //Mode = 4 -uint2x4 compress_endpoints5(inout uint2x4 endPoint); //Mode = 5 - -void block_package0(out uint4 block, uint partition, uint threadBase); //Mode0 -void block_package1(out uint4 block, uint partition, uint threadBase); //Mode1 -void block_package2(out uint4 block, uint partition, uint threadBase); //Mode2 -void block_package3(out uint4 block, uint partition, uint threadBase); //Mode3 -void block_package4(out uint4 block, uint rotation, uint index_selector, uint threadBase); //Mode4 -void block_package5(out uint4 block, uint rotation, uint threadBase); //Mode5 -void block_package6(out uint4 block, uint threadBase); //Mode6 -void block_package7(out uint4 block, uint partition, uint threadBase); //Mode7 - - -void swap(inout uint4 lhs, inout uint4 rhs) -{ - uint4 tmp = lhs; - lhs = rhs; - rhs = tmp; -} -void swap(inout uint3 lhs, inout uint3 rhs) -{ - uint3 tmp = lhs; - lhs = rhs; - rhs = tmp; -} -void swap(inout uint lhs, inout uint rhs) -{ - uint tmp = lhs; - lhs = rhs; - rhs = tmp; -} - -uint ComputeError(in uint4 a, in uint4 b) -{ - return dot(a.rgb, b.rgb) + g_alpha_weight * a.a*b.a; -} - -void Ensure_A_Is_Larger(inout uint4 a, inout uint4 b) -{ - if (a.x < b.x) - swap(a.x, b.x); - if (a.y < b.y) - swap(a.y, b.y); - if (a.z < b.z) - swap(a.z, b.z); - if (a.w < b.w) - swap(a.w, b.w); -} - - -Texture2D g_Input : register(t0); -StructuredBuffer g_InBuff : register(t1); - -RWStructuredBuffer g_OutBuff : register(u0); - -#define THREAD_GROUP_SIZE 64 -#define BLOCK_SIZE_Y 4 -#define BLOCK_SIZE_X 4 -#define BLOCK_SIZE (BLOCK_SIZE_Y * BLOCK_SIZE_X) - -struct BufferShared -{ - uint4 pixel; - uint error; - uint mode; - uint partition; - uint index_selector; - uint rotation; - uint4 endPoint_low; - uint4 endPoint_high; - uint4 endPoint_low_quantized; - uint4 endPoint_high_quantized; -}; -groupshared BufferShared shared_temp[THREAD_GROUP_SIZE]; - -[numthreads(THREAD_GROUP_SIZE, 1, 1)] -void TryMode456CS(uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID) // mode 4 5 6 all have 1 subset per block, and fix-up index is always index 0 -{ - // we process 4 BC blocks per thread group - const uint MAX_USED_THREAD = 16; // pixels in a BC (block compressed) block - uint BLOCK_IN_GROUP = THREAD_GROUP_SIZE / MAX_USED_THREAD; // the number of BC blocks a thread group processes = 64 / 16 = 4 - uint blockInGroup = GI / MAX_USED_THREAD; // what BC block this thread is on within this thread group - uint blockID = g_start_block_id + groupID.x * BLOCK_IN_GROUP + blockInGroup; // what global BC block this thread is on - uint threadBase = blockInGroup * MAX_USED_THREAD; // the first id of the pixel in this BC block in this thread group - uint threadInBlock = GI - threadBase; // id of the pixel in this BC block - -#ifndef REF_DEVICE - if (blockID >= g_num_total_blocks) - { - return; - } -#endif - - uint block_y = blockID / g_num_block_x; - uint block_x = blockID - block_y * g_num_block_x; - uint base_x = block_x * BLOCK_SIZE_X; - uint base_y = block_y * BLOCK_SIZE_Y; - - if (threadInBlock < 16) - { - shared_temp[GI].pixel = clamp(uint4(g_Input.Load(uint3(base_x + threadInBlock % 4, base_y + threadInBlock / 4, 0)) * 255), 0, 255); - - shared_temp[GI].endPoint_low = shared_temp[GI].pixel; - shared_temp[GI].endPoint_high = shared_temp[GI].pixel; - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - - if (threadInBlock < 8) - { - shared_temp[GI].endPoint_low = min(shared_temp[GI].endPoint_low, shared_temp[GI + 8].endPoint_low); - shared_temp[GI].endPoint_high = max(shared_temp[GI].endPoint_high, shared_temp[GI + 8].endPoint_high); - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 4) - { - shared_temp[GI].endPoint_low = min(shared_temp[GI].endPoint_low, shared_temp[GI + 4].endPoint_low); - shared_temp[GI].endPoint_high = max(shared_temp[GI].endPoint_high, shared_temp[GI + 4].endPoint_high); - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 2) - { - shared_temp[GI].endPoint_low = min(shared_temp[GI].endPoint_low, shared_temp[GI + 2].endPoint_low); - shared_temp[GI].endPoint_high = max(shared_temp[GI].endPoint_high, shared_temp[GI + 2].endPoint_high); - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 1) - { - shared_temp[GI].endPoint_low = min(shared_temp[GI].endPoint_low, shared_temp[GI + 1].endPoint_low); - shared_temp[GI].endPoint_high = max(shared_temp[GI].endPoint_high, shared_temp[GI + 1].endPoint_high); - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - - uint2x4 endPoint; - endPoint[0] = shared_temp[threadBase].endPoint_low; - endPoint[1] = shared_temp[threadBase].endPoint_high; - - uint error = 0xFFFFFFFF; - uint mode = 0; - uint index_selector = 0; - uint rotation = 0; - - uint2 indexPrec; - if (threadInBlock < 8) // all threads of threadInBlock < 8 will be working on trying out mode 4, since only mode 4 has index selector bit - { - if (0 == (threadInBlock & 1)) // thread 0, 2, 4, 6 - { - //2 represents 2bit index precision; 1 represents 3bit index precision - index_selector = 0; - indexPrec = uint2(2, 1); - } - else // thread 1, 3, 5, 7 - { - //2 represents 2bit index precision; 1 represents 3bit index precision - index_selector = 1; - indexPrec = uint2(1, 2); - } - } - else - { - //2 represents 2bit index precision - indexPrec = uint2(2, 2); - } - - uint4 pixel_r; - uint color_index; - uint alpha_index; - int4 span; - int2 span_norm_sqr; - int2 dotProduct; - if (threadInBlock < 12) // Try mode 4 5 in threads 0..11 - { - // mode 4 5 have component rotation - if ((threadInBlock < 2) || (8 == threadInBlock)) // rotation = 0 in thread 0, 1 - { - rotation = 0; - } - else if ((threadInBlock < 4) || (9 == threadInBlock)) // rotation = 1 in thread 2, 3 - { - endPoint[0].ra = endPoint[0].ar; - endPoint[1].ra = endPoint[1].ar; - - rotation = 1; - } - else if ((threadInBlock < 6) || (10 == threadInBlock)) // rotation = 2 in thread 4, 5 - { - endPoint[0].ga = endPoint[0].ag; - endPoint[1].ga = endPoint[1].ag; - - rotation = 2; - } - else if ((threadInBlock < 8) || (11 == threadInBlock)) // rotation = 3 in thread 6, 7 - { - endPoint[0].ba = endPoint[0].ab; - endPoint[1].ba = endPoint[1].ab; - - rotation = 3; - } - - if (threadInBlock < 8) // try mode 4 in threads 0..7 - { - // mode 4 thread distribution - // Thread 0 1 2 3 4 5 6 7 - // Rotation 0 0 1 1 2 2 3 3 - // Index selector 0 1 0 1 0 1 0 1 - - mode = 4; - compress_endpoints4(endPoint); - } - else // try mode 5 in threads 8..11 - { - // mode 5 thread distribution - // Thread 8 9 10 11 - // Rotation 0 1 2 3 - - mode = 5; - compress_endpoints5(endPoint); - } - - uint4 pixel = shared_temp[threadBase + 0].pixel; - if (1 == rotation) - { - pixel.ra = pixel.ar; - } - else if (2 == rotation) - { - pixel.ga = pixel.ag; - } - else if (3 == rotation) - { - pixel.ba = pixel.ab; - } - - span = endPoint[1] - endPoint[0]; - span_norm_sqr = uint2(dot(span.rgb, span.rgb), span.a * span.a); - - // in mode 4 5 6, end point 0 must be closer to pixel 0 than end point 1, because of the fix-up index is always index 0 - // TODO: this shouldn't be necessary here in error calculation - /* - dotProduct = int2( dot( span.rgb, pixel.rgb - endPoint[0].rgb ), span.a * ( pixel.a - endPoint[0].a ) ); - if ( span_norm_sqr.x > 0 && dotProduct.x > 0 && uint( dotProduct.x * 63.49999 ) > uint( 32 * span_norm_sqr.x ) ) - { - span.rgb = -span.rgb; - swap(endPoint[0].rgb, endPoint[1].rgb); - } - if ( span_norm_sqr.y > 0 && dotProduct.y > 0 && uint( dotProduct.y * 63.49999 ) > uint( 32 * span_norm_sqr.y ) ) - { - span.a = -span.a; - swap(endPoint[0].a, endPoint[1].a); - } - */ - - // should be the same as above - dotProduct = int2(dot(pixel.rgb - endPoint[0].rgb, pixel.rgb - endPoint[0].rgb), dot(pixel.rgb - endPoint[1].rgb, pixel.rgb - endPoint[1].rgb)); - if (dotProduct.x > dotProduct.y) - { - span.rgb = -span.rgb; - swap(endPoint[0].rgb, endPoint[1].rgb); - } - dotProduct = int2(dot(pixel.a - endPoint[0].a, pixel.a - endPoint[0].a), dot(pixel.a - endPoint[1].a, pixel.a - endPoint[1].a)); - if (dotProduct.x > dotProduct.y) - { - span.a = -span.a; - swap(endPoint[0].a, endPoint[1].a); - } - - error = 0; - for (uint i = 0; i < 16; i++) - { - pixel = shared_temp[threadBase + i].pixel; - if (1 == rotation) - { - pixel.ra = pixel.ar; - } - else if (2 == rotation) - { - pixel.ga = pixel.ag; - } - else if (3 == rotation) - { - pixel.ba = pixel.ab; - } - - dotProduct.x = dot(span.rgb, pixel.rgb - endPoint[0].rgb); - color_index = (span_norm_sqr.x <= 0 /*endPoint[0] == endPoint[1]*/ || dotProduct.x <= 0 /*pixel == endPoint[0]*/) ? 0 - : ((dotProduct.x < span_norm_sqr.x) ? aStep[indexPrec.x][uint(dotProduct.x * 63.49999 / span_norm_sqr.x)] : aStep[indexPrec.x][63]); - dotProduct.y = dot(span.a, pixel.a - endPoint[0].a); - alpha_index = (span_norm_sqr.y <= 0 || dotProduct.y <= 0) ? 0 - : ((dotProduct.y < span_norm_sqr.y) ? aStep[indexPrec.y][uint(dotProduct.y * 63.49999 / span_norm_sqr.y)] : aStep[indexPrec.y][63]); - - // the same color_index and alpha_index should be used for reconstruction, so this should be left commented out - /*if (index_selector) - { - swap(color_index, alpha_index); - }*/ - - pixel_r.rgb = ((64 - aWeight[indexPrec.x][color_index]) * endPoint[0].rgb + - aWeight[indexPrec.x][color_index] * endPoint[1].rgb + - 32) >> 6; - pixel_r.a = ((64 - aWeight[indexPrec.y][alpha_index]) * endPoint[0].a + - aWeight[indexPrec.y][alpha_index] * endPoint[1].a + - 32) >> 6; - - Ensure_A_Is_Larger(pixel_r, pixel); - pixel_r -= pixel; - if (1 == rotation) - { - pixel_r.ra = pixel_r.ar; - } - else if (2 == rotation) - { - pixel_r.ga = pixel_r.ag; - } - else if (3 == rotation) - { - pixel_r.ba = pixel_r.ab; - } - error += ComputeError(pixel_r, pixel_r); - } - } - else if (threadInBlock < 16) // Try mode 6 in threads 12..15, since in mode 4 5 6, only mode 6 has p bit - { - uint p = threadInBlock - 12; - - compress_endpoints6(endPoint, uint2(p >> 0, p >> 1) & 1); - - uint4 pixel = shared_temp[threadBase + 0].pixel; - - span = endPoint[1] - endPoint[0]; - span_norm_sqr = dot(span, span); - dotProduct = dot(span, pixel - endPoint[0]); - if (span_norm_sqr.x > 0 && dotProduct.x >= 0 && uint(dotProduct.x * 63.49999) > uint(32 * span_norm_sqr.x)) - { - span = -span; - swap(endPoint[0], endPoint[1]); - } - - error = 0; - for (uint i = 0; i < 16; i++) - { - pixel = shared_temp[threadBase + i].pixel; - - dotProduct.x = dot(span, pixel - endPoint[0]); - color_index = (span_norm_sqr.x <= 0 || dotProduct.x <= 0) ? 0 - : ((dotProduct.x < span_norm_sqr.x) ? aStep[0][uint(dotProduct.x * 63.49999 / span_norm_sqr.x)] : aStep[0][63]); - - pixel_r = ((64 - aWeight[0][color_index]) * endPoint[0] - + aWeight[0][color_index] * endPoint[1] + 32) >> 6; - - Ensure_A_Is_Larger(pixel_r, pixel); - pixel_r -= pixel; - error += ComputeError(pixel_r, pixel_r); - } - - mode = 6; - rotation = p; // Borrow rotation for p - } - - shared_temp[GI].error = error; - shared_temp[GI].mode = mode; - shared_temp[GI].index_selector = index_selector; - shared_temp[GI].rotation = rotation; - -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - - if (threadInBlock < 8) - { - if (shared_temp[GI].error > shared_temp[GI + 8].error) - { - shared_temp[GI].error = shared_temp[GI + 8].error; - shared_temp[GI].mode = shared_temp[GI + 8].mode; - shared_temp[GI].index_selector = shared_temp[GI + 8].index_selector; - shared_temp[GI].rotation = shared_temp[GI + 8].rotation; - } - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 4) - { - if (shared_temp[GI].error > shared_temp[GI + 4].error) - { - shared_temp[GI].error = shared_temp[GI + 4].error; - shared_temp[GI].mode = shared_temp[GI + 4].mode; - shared_temp[GI].index_selector = shared_temp[GI + 4].index_selector; - shared_temp[GI].rotation = shared_temp[GI + 4].rotation; - } - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 2) - { - if (shared_temp[GI].error > shared_temp[GI + 2].error) - { - shared_temp[GI].error = shared_temp[GI + 2].error; - shared_temp[GI].mode = shared_temp[GI + 2].mode; - shared_temp[GI].index_selector = shared_temp[GI + 2].index_selector; - shared_temp[GI].rotation = shared_temp[GI + 2].rotation; - } - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 1) - { - if (shared_temp[GI].error > shared_temp[GI + 1].error) - { - shared_temp[GI].error = shared_temp[GI + 1].error; - shared_temp[GI].mode = shared_temp[GI + 1].mode; - shared_temp[GI].index_selector = shared_temp[GI + 1].index_selector; - shared_temp[GI].rotation = shared_temp[GI + 1].rotation; - } - - g_OutBuff[blockID] = uint4(shared_temp[GI].error, (shared_temp[GI].index_selector << 31) | shared_temp[GI].mode, - 0, shared_temp[GI].rotation); // rotation is indeed rotation for mode 4 5. for mode 6, rotation is p bit - } -} - -[numthreads(THREAD_GROUP_SIZE, 1, 1)] -void TryMode137CS(uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID) // mode 1 3 7 all have 2 subsets per block -{ - const uint MAX_USED_THREAD = 64; - uint BLOCK_IN_GROUP = THREAD_GROUP_SIZE / MAX_USED_THREAD; - uint blockInGroup = GI / MAX_USED_THREAD; - uint blockID = g_start_block_id + groupID.x * BLOCK_IN_GROUP + blockInGroup; - uint threadBase = blockInGroup * MAX_USED_THREAD; - uint threadInBlock = GI - threadBase; - - uint block_y = blockID / g_num_block_x; - uint block_x = blockID - block_y * g_num_block_x; - uint base_x = block_x * BLOCK_SIZE_X; - uint base_y = block_y * BLOCK_SIZE_Y; - - if (threadInBlock < 16) - { - shared_temp[GI].pixel = clamp(uint4(g_Input.Load(uint3(base_x + threadInBlock % 4, base_y + threadInBlock / 4, 0)) * 255), 0, 255); - } - GroupMemoryBarrierWithGroupSync(); - - shared_temp[GI].error = 0xFFFFFFFF; - - uint4 pixel_r; - uint2x4 endPoint[2]; // endPoint[0..1 for subset id][0..1 for low and high in the subset] - uint2x4 endPointBackup[2]; - uint color_index; - if (threadInBlock < 64) - { - uint partition = threadInBlock; - - endPoint[0][0] = MAX_UINT; - endPoint[0][1] = MIN_UINT; - endPoint[1][0] = MAX_UINT; - endPoint[1][1] = MIN_UINT; - uint bits = candidateSectionBit[partition]; - for (uint i = 0; i < 16; i++) - { - uint4 pixel = shared_temp[threadBase + i].pixel; - if (((bits >> i) & 0x01) == 1) - { - endPoint[1][0] = min(endPoint[1][0], pixel); - endPoint[1][1] = max(endPoint[1][1], pixel); - } - else - { - endPoint[0][0] = min(endPoint[0][0], pixel); - endPoint[0][1] = max(endPoint[0][1], pixel); - } - } - - endPointBackup[0] = endPoint[0]; - endPointBackup[1] = endPoint[1]; - - uint max_p; - if (1 == g_mode_id) - { - // in mode 1, there is only one p bit per subset - max_p = 2; - } - else - { - // in mode 3 7, there are two p bits per subset, one for each end point - max_p = 4; - } - - uint final_p[2] = { 0, 0 }; - uint error[2] = { MAX_UINT, MAX_UINT }; - for (uint p = 0; p < max_p; p++) - { - endPoint[0] = endPointBackup[0]; - endPoint[1] = endPointBackup[1]; - - for (i = 0; i < 2; i++) // loop through 2 subsets - { - if (g_mode_id == 1) - { - compress_endpoints1(endPoint[i], p); - } - else if (g_mode_id == 3) - { - compress_endpoints3(endPoint[i], uint2(p, p >> 1) & 1); - } - else if (g_mode_id == 7) - { - compress_endpoints7(endPoint[i], uint2(p, p >> 1) & 1); - } - } - - int4 span[2]; - span[0] = endPoint[0][1] - endPoint[0][0]; - span[1] = endPoint[1][1] - endPoint[1][0]; - - if (g_mode_id != 7) - { - span[0].w = span[1].w = 0; - } - - int span_norm_sqr[2]; - span_norm_sqr[0] = dot(span[0], span[0]); - span_norm_sqr[1] = dot(span[1], span[1]); - - // TODO: again, this shouldn't be necessary here in error calculation - int dotProduct = dot(span[0], shared_temp[threadBase + 0].pixel - endPoint[0][0]); - if (span_norm_sqr[0] > 0 && dotProduct > 0 && uint(dotProduct * 63.49999) > uint(32 * span_norm_sqr[0])) - { - span[0] = -span[0]; - swap(endPoint[0][0], endPoint[0][1]); - } - dotProduct = dot(span[1], shared_temp[threadBase + candidateFixUpIndex1D[partition].x].pixel - endPoint[1][0]); - if (span_norm_sqr[1] > 0 && dotProduct > 0 && uint(dotProduct * 63.49999) > uint(32 * span_norm_sqr[1])) - { - span[1] = -span[1]; - swap(endPoint[1][0], endPoint[1][1]); - } - - uint step_selector; - if (g_mode_id != 1) - { - step_selector = 2; // mode 3 7 have 2 bit index - } - else - { - step_selector = 1; // mode 1 has 3 bit index - } - - uint p_error[2] = { 0, 0 }; - for (i = 0; i < 16; i++) - { - uint subset_index = (bits >> i) & 0x01; - - if (subset_index == 1) - { - dotProduct = dot(span[1], shared_temp[threadBase + i].pixel - endPoint[1][0]); - color_index = (span_norm_sqr[1] <= 0 || dotProduct <= 0) ? 0 - : ((dotProduct < span_norm_sqr[1]) ? aStep[step_selector][uint(dotProduct * 63.49999 / span_norm_sqr[1])] : aStep[step_selector][63]); - } - else - { - dotProduct = dot(span[0], shared_temp[threadBase + i].pixel - endPoint[0][0]); - color_index = (span_norm_sqr[0] <= 0 || dotProduct <= 0) ? 0 - : ((dotProduct < span_norm_sqr[0]) ? aStep[step_selector][uint(dotProduct * 63.49999 / span_norm_sqr[0])] : aStep[step_selector][63]); - } - - pixel_r = ((64 - aWeight[step_selector][color_index]) * endPoint[subset_index][0] - + aWeight[step_selector][color_index] * endPoint[subset_index][1] + 32) >> 6; - if (g_mode_id != 7) - { - pixel_r.a = 255; - } - - uint4 pixel = shared_temp[threadBase + i].pixel; - Ensure_A_Is_Larger(pixel_r, pixel); - pixel_r -= pixel; - uint pixel_error = ComputeError(pixel_r, pixel_r); - if (subset_index == 1) - p_error[1] += pixel_error; - else - p_error[0] += pixel_error; - } - - for (i = 0; i < 2; i++) - { - if (p_error[i] < error[i]) - { - error[i] = p_error[i]; - final_p[i] = p; - } - } - } - - shared_temp[GI].error = error[0] + error[1]; - shared_temp[GI].mode = g_mode_id; - shared_temp[GI].partition = partition; - - // mode 1 3 7 don't have rotation, we use rotation for p bits - if (g_mode_id == 1) - shared_temp[GI].rotation = (final_p[1] << 1) | final_p[0]; - else - shared_temp[GI].rotation = (final_p[1] << 2) | final_p[0]; - } - GroupMemoryBarrierWithGroupSync(); - - if (threadInBlock < 32) - { - if (shared_temp[GI].error > shared_temp[GI + 32].error) - { - shared_temp[GI].error = shared_temp[GI + 32].error; - shared_temp[GI].mode = shared_temp[GI + 32].mode; - shared_temp[GI].partition = shared_temp[GI + 32].partition; - shared_temp[GI].rotation = shared_temp[GI + 32].rotation; - } - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 16) - { - if (shared_temp[GI].error > shared_temp[GI + 16].error) - { - shared_temp[GI].error = shared_temp[GI + 16].error; - shared_temp[GI].mode = shared_temp[GI + 16].mode; - shared_temp[GI].partition = shared_temp[GI + 16].partition; - shared_temp[GI].rotation = shared_temp[GI + 16].rotation; - } - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 8) - { - if (shared_temp[GI].error > shared_temp[GI + 8].error) - { - shared_temp[GI].error = shared_temp[GI + 8].error; - shared_temp[GI].mode = shared_temp[GI + 8].mode; - shared_temp[GI].partition = shared_temp[GI + 8].partition; - shared_temp[GI].rotation = shared_temp[GI + 8].rotation; - } - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 4) - { - if (shared_temp[GI].error > shared_temp[GI + 4].error) - { - shared_temp[GI].error = shared_temp[GI + 4].error; - shared_temp[GI].mode = shared_temp[GI + 4].mode; - shared_temp[GI].partition = shared_temp[GI + 4].partition; - shared_temp[GI].rotation = shared_temp[GI + 4].rotation; - } - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 2) - { - if (shared_temp[GI].error > shared_temp[GI + 2].error) - { - shared_temp[GI].error = shared_temp[GI + 2].error; - shared_temp[GI].mode = shared_temp[GI + 2].mode; - shared_temp[GI].partition = shared_temp[GI + 2].partition; - shared_temp[GI].rotation = shared_temp[GI + 2].rotation; - } - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 1) - { - if (shared_temp[GI].error > shared_temp[GI + 1].error) - { - shared_temp[GI].error = shared_temp[GI + 1].error; - shared_temp[GI].mode = shared_temp[GI + 1].mode; - shared_temp[GI].partition = shared_temp[GI + 1].partition; - shared_temp[GI].rotation = shared_temp[GI + 1].rotation; - } - - if (g_InBuff[blockID].x > shared_temp[GI].error) - { - g_OutBuff[blockID] = uint4(shared_temp[GI].error, shared_temp[GI].mode, shared_temp[GI].partition, shared_temp[GI].rotation); // mode 1 3 7 don't have rotation, we use rotation for p bits - } - else - { - g_OutBuff[blockID] = g_InBuff[blockID]; - } - } -} - -[numthreads(THREAD_GROUP_SIZE, 1, 1)] -void TryMode02CS(uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID) // mode 0 2 have 3 subsets per block -{ - const uint MAX_USED_THREAD = 64; - uint BLOCK_IN_GROUP = THREAD_GROUP_SIZE / MAX_USED_THREAD; - uint blockInGroup = GI / MAX_USED_THREAD; - uint blockID = g_start_block_id + groupID.x * BLOCK_IN_GROUP + blockInGroup; - uint threadBase = blockInGroup * MAX_USED_THREAD; - uint threadInBlock = GI - threadBase; - - uint block_y = blockID / g_num_block_x; - uint block_x = blockID - block_y * g_num_block_x; - uint base_x = block_x * BLOCK_SIZE_X; - uint base_y = block_y * BLOCK_SIZE_Y; - - if (threadInBlock < 16) - { - shared_temp[GI].pixel = clamp(uint4(g_Input.Load(uint3(base_x + threadInBlock % 4, base_y + threadInBlock / 4, 0)) * 255), 0, 255); - } - GroupMemoryBarrierWithGroupSync(); - - shared_temp[GI].error = 0xFFFFFFFF; - - uint num_partitions; - if (0 == g_mode_id) - { - num_partitions = 16; - } - else - { - num_partitions = 64; - } - - uint4 pixel_r; - uint2x4 endPoint[3]; // endPoint[0..1 for subset id][0..1 for low and high in the subset] - uint2x4 endPointBackup[3]; - uint color_index[16]; - if (threadInBlock < num_partitions) - { - uint partition = threadInBlock + 64; - - endPoint[0][0] = MAX_UINT; - endPoint[0][1] = MIN_UINT; - endPoint[1][0] = MAX_UINT; - endPoint[1][1] = MIN_UINT; - endPoint[2][0] = MAX_UINT; - endPoint[2][1] = MIN_UINT; - uint bits2 = candidateSectionBit2[partition - 64]; - for (uint i = 0; i < 16; i++) - { - uint4 pixel = shared_temp[threadBase + i].pixel; - uint subset_index = (bits2 >> (i * 2)) & 0x03; - if (subset_index == 2) - { - endPoint[2][0] = min(endPoint[2][0], pixel); - endPoint[2][1] = max(endPoint[2][1], pixel); - } - else if (subset_index == 1) - { - endPoint[1][0] = min(endPoint[1][0], pixel); - endPoint[1][1] = max(endPoint[1][1], pixel); - } - else - { - endPoint[0][0] = min(endPoint[0][0], pixel); - endPoint[0][1] = max(endPoint[0][1], pixel); - } - } - - endPointBackup[0] = endPoint[0]; - endPointBackup[1] = endPoint[1]; - endPointBackup[2] = endPoint[2]; - - uint max_p; - if (0 == g_mode_id) - { - max_p = 4; - } - else - { - max_p = 1; - } - - uint final_p[3] = { 0, 0, 0 }; - uint error[3] = { MAX_UINT, MAX_UINT, MAX_UINT }; - for (uint p = 0; p < max_p; p++) - { - endPoint[0] = endPointBackup[0]; - endPoint[1] = endPointBackup[1]; - endPoint[2] = endPointBackup[2]; - - for (i = 0; i < 3; i++) - { - if (0 == g_mode_id) - { - compress_endpoints0(endPoint[i], uint2(p, p >> 1) & 1); - } - else - { - compress_endpoints2(endPoint[i]); - } - } - - uint step_selector = 1 + (2 == g_mode_id); - - int4 span[3]; - span[0] = endPoint[0][1] - endPoint[0][0]; - span[1] = endPoint[1][1] - endPoint[1][0]; - span[2] = endPoint[2][1] - endPoint[2][0]; - span[0].w = span[1].w = span[2].w = 0; - int span_norm_sqr[3]; - span_norm_sqr[0] = dot(span[0], span[0]); - span_norm_sqr[1] = dot(span[1], span[1]); - span_norm_sqr[2] = dot(span[2], span[2]); - - // TODO: again, this shouldn't be necessary here in error calculation - uint ci[3] = { 0, candidateFixUpIndex1D[partition].x, candidateFixUpIndex1D[partition].y }; - for (i = 0; i < 3; i++) - { - int dotProduct = dot(span[i], shared_temp[threadBase + ci[i]].pixel - endPoint[i][0]); - if (span_norm_sqr[i] > 0 && dotProduct > 0 && uint(dotProduct * 63.49999) > uint(32 * span_norm_sqr[i])) - { - span[i] = -span[i]; - swap(endPoint[i][0], endPoint[i][1]); - } - } - - uint p_error[3] = { 0, 0, 0 }; - for (i = 0; i < 16; i++) - { - uint subset_index = (bits2 >> (i * 2)) & 0x03; - if (subset_index == 2) - { - int dotProduct = dot(span[2], shared_temp[threadBase + i].pixel - endPoint[2][0]); - color_index[i] = (span_norm_sqr[2] <= 0 || dotProduct <= 0) ? 0 - : ((dotProduct < span_norm_sqr[2]) ? aStep[step_selector][uint(dotProduct * 63.49999 / span_norm_sqr[2])] : aStep[step_selector][63]); - } - else if (subset_index == 1) - { - int dotProduct = dot(span[1], shared_temp[threadBase + i].pixel - endPoint[1][0]); - color_index[i] = (span_norm_sqr[1] <= 0 || dotProduct <= 0) ? 0 - : ((dotProduct < span_norm_sqr[1]) ? aStep[step_selector][uint(dotProduct * 63.49999 / span_norm_sqr[1])] : aStep[step_selector][63]); - } - else - { - int dotProduct = dot(span[0], shared_temp[threadBase + i].pixel - endPoint[0][0]); - color_index[i] = (span_norm_sqr[0] <= 0 || dotProduct <= 0) ? 0 - : ((dotProduct < span_norm_sqr[0]) ? aStep[step_selector][uint(dotProduct * 63.49999 / span_norm_sqr[0])] : aStep[step_selector][63]); - } - - pixel_r = ((64 - aWeight[step_selector][color_index[i]]) * endPoint[subset_index][0] - + aWeight[step_selector][color_index[i]] * endPoint[subset_index][1] + 32) >> 6; - pixel_r.a = 255; - - uint4 pixel = shared_temp[threadBase + i].pixel; - Ensure_A_Is_Larger(pixel_r, pixel); - pixel_r -= pixel; - - uint pixel_error = ComputeError(pixel_r, pixel_r); - - if (subset_index == 2) - p_error[2] += pixel_error; - else if (subset_index == 1) - p_error[1] += pixel_error; - else - p_error[0] += pixel_error; - } - - for (i = 0; i < 3; i++) - { - if (p_error[i] < error[i]) - { - error[i] = p_error[i]; - final_p[i] = p; // Borrow rotation for p - } - } - } - - shared_temp[GI].error = error[0] + error[1] + error[2]; - shared_temp[GI].partition = partition; - shared_temp[GI].rotation = (final_p[2] << 4) | (final_p[1] << 2) | final_p[0]; - } - GroupMemoryBarrierWithGroupSync(); - - if (threadInBlock < 32) - { - if (shared_temp[GI].error > shared_temp[GI + 32].error) - { - shared_temp[GI].error = shared_temp[GI + 32].error; - shared_temp[GI].partition = shared_temp[GI + 32].partition; - shared_temp[GI].rotation = shared_temp[GI + 32].rotation; - } - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 16) - { - if (shared_temp[GI].error > shared_temp[GI + 16].error) - { - shared_temp[GI].error = shared_temp[GI + 16].error; - shared_temp[GI].partition = shared_temp[GI + 16].partition; - shared_temp[GI].rotation = shared_temp[GI + 16].rotation; - } - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 8) - { - if (shared_temp[GI].error > shared_temp[GI + 8].error) - { - shared_temp[GI].error = shared_temp[GI + 8].error; - shared_temp[GI].partition = shared_temp[GI + 8].partition; - shared_temp[GI].rotation = shared_temp[GI + 8].rotation; - } - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 4) - { - if (shared_temp[GI].error > shared_temp[GI + 4].error) - { - shared_temp[GI].error = shared_temp[GI + 4].error; - shared_temp[GI].partition = shared_temp[GI + 4].partition; - shared_temp[GI].rotation = shared_temp[GI + 4].rotation; - } - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 2) - { - if (shared_temp[GI].error > shared_temp[GI + 2].error) - { - shared_temp[GI].error = shared_temp[GI + 2].error; - shared_temp[GI].partition = shared_temp[GI + 2].partition; - shared_temp[GI].rotation = shared_temp[GI + 2].rotation; - } - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 1) - { - if (shared_temp[GI].error > shared_temp[GI + 1].error) - { - shared_temp[GI].error = shared_temp[GI + 1].error; - shared_temp[GI].partition = shared_temp[GI + 1].partition; - shared_temp[GI].rotation = shared_temp[GI + 1].rotation; - } - - if (g_InBuff[blockID].x > shared_temp[GI].error) - { - g_OutBuff[blockID] = uint4(shared_temp[GI].error, g_mode_id, shared_temp[GI].partition, shared_temp[GI].rotation); // rotation is actually p bit for mode 0. for mode 2, rotation is always 0 - } - else - { - g_OutBuff[blockID] = g_InBuff[blockID]; - } - } -} - -[numthreads(THREAD_GROUP_SIZE, 1, 1)] -void EncodeBlockCS(uint GI : SV_GroupIndex, uint3 groupID : SV_GroupID) -{ - const uint MAX_USED_THREAD = 16; - uint BLOCK_IN_GROUP = THREAD_GROUP_SIZE / MAX_USED_THREAD; - uint blockInGroup = GI / MAX_USED_THREAD; - uint blockID = g_start_block_id + groupID.x * BLOCK_IN_GROUP + blockInGroup; - uint threadBase = blockInGroup * MAX_USED_THREAD; - uint threadInBlock = GI - threadBase; - -#ifndef REF_DEVICE - if (blockID >= g_num_total_blocks) - { - return; - } -#endif - - uint block_y = blockID / g_num_block_x; - uint block_x = blockID - block_y * g_num_block_x; - uint base_x = block_x * BLOCK_SIZE_X; - uint base_y = block_y * BLOCK_SIZE_Y; - - uint mode = g_InBuff[blockID].y & 0x7FFFFFFF; - uint partition = g_InBuff[blockID].z; - uint index_selector = (g_InBuff[blockID].y >> 31) & 1; - uint rotation = g_InBuff[blockID].w; - - if (threadInBlock < 16) - { - uint4 pixel = clamp(uint4(g_Input.Load(uint3(base_x + threadInBlock % 4, base_y + threadInBlock / 4, 0)) * 255), 0, 255); - - if ((4 == mode) || (5 == mode)) - { - if (1 == rotation) - { - pixel.ra = pixel.ar; - } - else if (2 == rotation) - { - pixel.ga = pixel.ag; - } - else if (3 == rotation) - { - pixel.ba = pixel.ab; - } - } - - shared_temp[GI].pixel = pixel; - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - - uint bits = candidateSectionBit[partition]; - uint bits2 = candidateSectionBit2[partition - 64]; - - uint2x4 ep; - ep[0] = MAX_UINT; - ep[1] = MIN_UINT; - uint2x4 ep_quantized; - [unroll] - for (int ii = 2; ii >= 0; --ii) - { - if (threadInBlock < 16) - { - uint2x4 ep; - ep[0] = MAX_UINT; - ep[1] = MIN_UINT; - - uint4 pixel = shared_temp[GI].pixel; - - uint subset_index = (bits >> threadInBlock) & 0x01; - uint subset_index2 = (bits2 >> (threadInBlock * 2)) & 0x03; - if (0 == ii) - { - if ((0 == mode) || (2 == mode)) - { - if (0 == subset_index2) - { - ep[0] = ep[1] = pixel; - } - } - else if ((1 == mode) || (3 == mode) || (7 == mode)) - { - if (0 == subset_index) - { - ep[0] = ep[1] = pixel; - } - } - else if ((4 == mode) || (5 == mode) || (6 == mode)) - { - ep[0] = ep[1] = pixel; - } - } - else if (1 == ii) - { - if ((0 == mode) || (2 == mode)) - { - if (1 == subset_index2) - { - ep[0] = ep[1] = pixel; - } - } - else if ((1 == mode) || (3 == mode) || (7 == mode)) - { - if (1 == subset_index) - { - ep[0] = ep[1] = pixel; - } - } - } - else - { - if ((0 == mode) || (2 == mode)) - { - if (2 == subset_index2) - { - ep[0] = ep[1] = pixel; - } - } - } - - shared_temp[GI].endPoint_low = ep[0]; - shared_temp[GI].endPoint_high = ep[1]; - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - - if (threadInBlock < 8) - { - shared_temp[GI].endPoint_low = min(shared_temp[GI].endPoint_low, shared_temp[GI + 8].endPoint_low); - shared_temp[GI].endPoint_high = max(shared_temp[GI].endPoint_high, shared_temp[GI + 8].endPoint_high); - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 4) - { - shared_temp[GI].endPoint_low = min(shared_temp[GI].endPoint_low, shared_temp[GI + 4].endPoint_low); - shared_temp[GI].endPoint_high = max(shared_temp[GI].endPoint_high, shared_temp[GI + 4].endPoint_high); - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 2) - { - shared_temp[GI].endPoint_low = min(shared_temp[GI].endPoint_low, shared_temp[GI + 2].endPoint_low); - shared_temp[GI].endPoint_high = max(shared_temp[GI].endPoint_high, shared_temp[GI + 2].endPoint_high); - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - if (threadInBlock < 1) - { - shared_temp[GI].endPoint_low = min(shared_temp[GI].endPoint_low, shared_temp[GI + 1].endPoint_low); - shared_temp[GI].endPoint_high = max(shared_temp[GI].endPoint_high, shared_temp[GI + 1].endPoint_high); - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - - if (ii == (int)threadInBlock) - { - ep[0] = shared_temp[threadBase].endPoint_low; - ep[1] = shared_temp[threadBase].endPoint_high; - } - } - - if (threadInBlock < 3) - { - uint2 P; - if (1 == mode) - { - P = (rotation >> threadInBlock) & 1; - } - else - { - P = uint2(rotation >> (threadInBlock * 2 + 0), rotation >> (threadInBlock * 2 + 1)) & 1; - } - - if (0 == mode) - { - ep_quantized = compress_endpoints0(ep, P); - } - else if (1 == mode) - { - ep_quantized = compress_endpoints1(ep, P); - } - else if (2 == mode) - { - ep_quantized = compress_endpoints2(ep); - } - else if (3 == mode) - { - ep_quantized = compress_endpoints3(ep, P); - } - else if (4 == mode) - { - ep_quantized = compress_endpoints4(ep); - } - else if (5 == mode) - { - ep_quantized = compress_endpoints5(ep); - } - else if (6 == mode) - { - ep_quantized = compress_endpoints6(ep, P); - } - else //if (7 == mode) - { - ep_quantized = compress_endpoints7(ep, P); - } - - int4 span = ep[1] - ep[0]; - if (mode < 4) - { - span.w = 0; - } - - if ((4 == mode) || (5 == mode)) - { - if (0 == threadInBlock) - { - int2 span_norm_sqr = uint2(dot(span.rgb, span.rgb), span.a * span.a); - int2 dotProduct = int2(dot(span.rgb, shared_temp[threadBase + 0].pixel.rgb - ep[0].rgb), span.a * (shared_temp[threadBase + 0].pixel.a - ep[0].a)); - if (span_norm_sqr.x > 0 && dotProduct.x > 0 && uint(dotProduct.x * 63.49999) > uint(32 * span_norm_sqr.x)) - { - swap(ep[0].rgb, ep[1].rgb); - swap(ep_quantized[0].rgb, ep_quantized[1].rgb); - } - if (span_norm_sqr.y > 0 && dotProduct.y > 0 && uint(dotProduct.y * 63.49999) > uint(32 * span_norm_sqr.y)) - { - swap(ep[0].a, ep[1].a); - swap(ep_quantized[0].a, ep_quantized[1].a); - } - } - } - else //if ((0 == mode) || (2 == mode) || (1 == mode) || (3 == mode) || (7 == mode) || (6 == mode)) - { - int p; - if (0 == threadInBlock) - { - p = 0; - } - else if (1 == threadInBlock) - { - p = candidateFixUpIndex1D[partition].x; - } - else //if (2 == threadInBlock) - { - p = candidateFixUpIndex1D[partition].y; - } - - int span_norm_sqr = dot(span, span); - int dotProduct = dot(span, shared_temp[threadBase + p].pixel - ep[0]); - if (span_norm_sqr > 0 && dotProduct > 0 && uint(dotProduct * 63.49999) > uint(32 * span_norm_sqr)) - { - swap(ep[0], ep[1]); - swap(ep_quantized[0], ep_quantized[1]); - } - } - - shared_temp[GI].endPoint_low = ep[0]; - shared_temp[GI].endPoint_high = ep[1]; - shared_temp[GI].endPoint_low_quantized = ep_quantized[0]; - shared_temp[GI].endPoint_high_quantized = ep_quantized[1]; - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - - if (threadInBlock < 16) - { - uint color_index = 0; - uint alpha_index = 0; - - uint2x4 ep; - - uint2 indexPrec; - if ((0 == mode) || (1 == mode)) - { - indexPrec = 1; - } - else if (6 == mode) - { - indexPrec = 0; - } - else if (4 == mode) - { - if (0 == index_selector) - { - indexPrec = uint2(2, 1); - } - else - { - indexPrec = uint2(1, 2); - } - } - else - { - indexPrec = 2; - } - - int subset_index; - if ((0 == mode) || (2 == mode)) - { - subset_index = (bits2 >> (threadInBlock * 2)) & 0x03; - } - else if ((1 == mode) || (3 == mode) || (7 == mode)) - { - subset_index = (bits >> threadInBlock) & 0x01; - } - else - { - subset_index = 0; - } - - ep[0] = shared_temp[threadBase + subset_index].endPoint_low; - ep[1] = shared_temp[threadBase + subset_index].endPoint_high; - - int4 span = ep[1] - ep[0]; - if (mode < 4) - { - span.w = 0; - } - - if ((4 == mode) || (5 == mode)) - { - int2 span_norm_sqr; - span_norm_sqr.x = dot(span.rgb, span.rgb); - span_norm_sqr.y = span.a * span.a; - - int dotProduct = dot(span.rgb, shared_temp[threadBase + threadInBlock].pixel.rgb - ep[0].rgb); - color_index = (span_norm_sqr.x <= 0 || dotProduct <= 0) ? 0 - : ((dotProduct < span_norm_sqr.x) ? aStep[indexPrec.x][uint(dotProduct * 63.49999 / span_norm_sqr.x)] : aStep[indexPrec.x][63]); - dotProduct = dot(span.a, shared_temp[threadBase + threadInBlock].pixel.a - ep[0].a); - alpha_index = (span_norm_sqr.y <= 0 || dotProduct <= 0) ? 0 - : ((dotProduct < span_norm_sqr.y) ? aStep[indexPrec.y][uint(dotProduct * 63.49999 / span_norm_sqr.y)] : aStep[indexPrec.y][63]); - - if (index_selector) - { - swap(color_index, alpha_index); - } - } - else - { - int span_norm_sqr = dot(span, span); - - int dotProduct = dot(span, shared_temp[threadBase + threadInBlock].pixel - ep[0]); - color_index = (span_norm_sqr <= 0 || dotProduct <= 0) ? 0 - : ((dotProduct < span_norm_sqr) ? aStep[indexPrec.x][uint(dotProduct * 63.49999 / span_norm_sqr)] : aStep[indexPrec.x][63]); - } - - shared_temp[GI].error = color_index; - shared_temp[GI].mode = alpha_index; - } -#ifdef REF_DEVICE - GroupMemoryBarrierWithGroupSync(); -#endif - - if (0 == threadInBlock) - { - uint4 block; - if (0 == mode) - { - block_package0(block, partition, threadBase); - } - else if (1 == mode) - { - block_package1(block, partition, threadBase); - } - else if (2 == mode) - { - block_package2(block, partition, threadBase); - } - else if (3 == mode) - { - block_package3(block, partition, threadBase); - } - else if (4 == mode) - { - block_package4(block, rotation, index_selector, threadBase); - } - else if (5 == mode) - { - block_package5(block, rotation, threadBase); - } - else if (6 == mode) - { - block_package6(block, threadBase); - } - else //if (7 == mode) - { - block_package7(block, partition, threadBase); - } - - g_OutBuff[blockID] = block; - } -} - -//uint4 truncate_and_round( uint4 color, uint bits) -//{ -// uint precisionMask = ((1 << bits) - 1) << (8 - bits); -// uint precisionHalf = (1 << (7-bits)); -// -// uint4 truncated = color & precisionMask; -// uint4 rounded = min(255, color + precisionHalf) & precisionMask; -// -// uint4 truncated_bak = truncated = truncated | (truncated >> bits); -// uint4 rounded_bak = rounded = rounded | (rounded >> bits); -// -// uint4 color_bak = color; -// -// Ensure_A_Is_Larger( rounded, color ); -// Ensure_A_Is_Larger( truncated, color_bak ); -// -// if (dot(rounded - color, rounded - color) < -// dot(truncated - color_bak, truncated - color_bak)) -// { -// return rounded_bak; -// } -// else -// { -// return truncated_bak; -// } -//} - -uint4 quantize(uint4 color, uint uPrec) -{ - return (((color << 8) + color) * ((1 << uPrec) - 1) + 32768) >> 16; -} - -uint4 unquantize(uint4 color, uint uPrec) -{ - color = color << (8 - uPrec); - return color | (color >> uPrec); -} - -uint2x4 compress_endpoints0(inout uint2x4 endPoint, uint2 P) -{ - uint2x4 quantized; - [unroll] for (uint j = 0; j < 2; j++) - { - quantized[j].rgb = quantize(endPoint[j].rgbb, 5).rgb & 0xFFFFFFFE; - quantized[j].rgb |= P[j]; - quantized[j].a = 0xFF; - - endPoint[j].rgb = unquantize(quantized[j].rgbb, 5).rgb; - endPoint[j].a = 0xFF; - - quantized[j] <<= 3; - } - return quantized; -} -uint2x4 compress_endpoints1(inout uint2x4 endPoint, uint2 P) -{ - uint2x4 quantized; - [unroll] for (uint j = 0; j < 2; j++) - { - quantized[j].rgb = quantize(endPoint[j].rgbb, 7).rgb & 0xFFFFFFFE; - quantized[j].rgb |= P[j]; - quantized[j].a = 0xFF; - - endPoint[j].rgb = unquantize(quantized[j].rgbb, 7).rgb; - endPoint[j].a = 0xFF; - - quantized[j] <<= 1; - } - return quantized; -} -uint2x4 compress_endpoints2(inout uint2x4 endPoint) -{ - uint2x4 quantized; - [unroll] for (uint j = 0; j < 2; j++) - { - quantized[j].rgb = quantize(endPoint[j].rgbb, 5).rgb; - quantized[j].a = 0xFF; - - endPoint[j].rgb = unquantize(quantized[j].rgbb, 5).rgb; - endPoint[j].a = 0xFF; - - quantized[j] <<= 3; - } - return quantized; -} -uint2x4 compress_endpoints3(inout uint2x4 endPoint, uint2 P) -{ - uint2x4 quantized; - for (uint j = 0; j < 2; j++) - { - quantized[j].rgb = endPoint[j].rgb & 0xFFFFFFFE; - quantized[j].rgb |= P[j]; - quantized[j].a = 0xFF; - - endPoint[j].rgb = quantized[j].rgb; - endPoint[j].a = 0xFF; - } - return quantized; -} -uint2x4 compress_endpoints4(inout uint2x4 endPoint) -{ - uint2x4 quantized; - [unroll] for (uint j = 0; j < 2; j++) - { - quantized[j].rgb = quantize(endPoint[j].rgbb, 5).rgb; - quantized[j].a = quantize(endPoint[j].a, 6).r; - - endPoint[j].rgb = unquantize(quantized[j].rgbb, 5).rgb; - endPoint[j].a = unquantize(quantized[j].a, 6).r; - - quantized[j].rgb <<= 3; - quantized[j].a <<= 2; - } - return quantized; -} -uint2x4 compress_endpoints5(inout uint2x4 endPoint) -{ - uint2x4 quantized; - [unroll] for (uint j = 0; j < 2; j++) - { - quantized[j].rgb = quantize(endPoint[j].rgbb, 7).rgb; - quantized[j].a = endPoint[j].a; - - endPoint[j].rgb = unquantize(quantized[j].rgbb, 7).rgb; - // endPoint[j].a Alpha is full precision - - quantized[j].rgb <<= 1; - } - return quantized; -} -uint2x4 compress_endpoints6(inout uint2x4 endPoint, uint2 P) -{ - uint2x4 quantized; - for (uint j = 0; j < 2; j++) - { - quantized[j] = endPoint[j] & 0xFFFFFFFE; - quantized[j] |= P[j]; - - endPoint[j] = quantized[j]; - } - return quantized; -} -uint2x4 compress_endpoints7(inout uint2x4 endPoint, uint2 P) -{ - uint2x4 quantized; - [unroll] for (uint j = 0; j < 2; j++) - { - quantized[j] = quantize(endPoint[j], 6) & 0xFFFFFFFE; - quantized[j] |= P[j]; - - endPoint[j] = unquantize(quantized[j], 6); - } - return quantized << 2; -} - -#define get_end_point_l(subset) shared_temp[threadBase + subset].endPoint_low_quantized -#define get_end_point_h(subset) shared_temp[threadBase + subset].endPoint_high_quantized -#define get_color_index(index) shared_temp[threadBase + index].error -#define get_alpha_index(index) shared_temp[threadBase + index].mode - -void block_package0(out uint4 block, uint partition, uint threadBase) -{ - block.x = 0x01 | ((partition - 64) << 1) - | ((get_end_point_l(0).r & 0xF0) << 1) | ((get_end_point_h(0).r & 0xF0) << 5) - | ((get_end_point_l(1).r & 0xF0) << 9) | ((get_end_point_h(1).r & 0xF0) << 13) - | ((get_end_point_l(2).r & 0xF0) << 17) | ((get_end_point_h(2).r & 0xF0) << 21) - | ((get_end_point_l(0).g & 0xF0) << 25); - block.y = ((get_end_point_l(0).g & 0xF0) >> 7) | ((get_end_point_h(0).g & 0xF0) >> 3) - | ((get_end_point_l(1).g & 0xF0) << 1) | ((get_end_point_h(1).g & 0xF0) << 5) - | ((get_end_point_l(2).g & 0xF0) << 9) | ((get_end_point_h(2).g & 0xF0) << 13) - | ((get_end_point_l(0).b & 0xF0) << 17) | ((get_end_point_h(0).b & 0xF0) << 21) - | ((get_end_point_l(1).b & 0xF0) << 25); - block.z = ((get_end_point_l(1).b & 0xF0) >> 7) | ((get_end_point_h(1).b & 0xF0) >> 3) - | ((get_end_point_l(2).b & 0xF0) << 1) | ((get_end_point_h(2).b & 0xF0) << 5) - | ((get_end_point_l(0).r & 0x08) << 10) | ((get_end_point_h(0).r & 0x08) << 11) - | ((get_end_point_l(1).r & 0x08) << 12) | ((get_end_point_h(1).r & 0x08) << 13) - | ((get_end_point_l(2).r & 0x08) << 14) | ((get_end_point_h(2).r & 0x08) << 15) - | (get_color_index(0) << 19); - block.w = 0; - uint i = 1; - for (; i <= min(candidateFixUpIndex1DOrdered[partition][0], 4); i++) - { - block.z |= get_color_index(i) << (i * 3 + 18); - } - if (candidateFixUpIndex1DOrdered[partition][0] < 4) //i = 4 - { - block.z |= get_color_index(4) << 29; - i += 1; - } - else //i = 5 - { - block.w |= (get_color_index(4) & 0x04) >> 2; - for (; i <= candidateFixUpIndex1DOrdered[partition][0]; i++) - block.w |= get_color_index(i) << (i * 3 - 14); - } - for (; i <= candidateFixUpIndex1DOrdered[partition][1]; i++) - { - block.w |= get_color_index(i) << (i * 3 - 15); - } - for (; i < 16; i++) - { - block.w |= get_color_index(i) << (i * 3 - 16); - } -} -void block_package1(out uint4 block, uint partition, uint threadBase) -{ - block.x = 0x02 | (partition << 2) - | ((get_end_point_l(0).r & 0xFC) << 6) | ((get_end_point_h(0).r & 0xFC) << 12) - | ((get_end_point_l(1).r & 0xFC) << 18) | ((get_end_point_h(1).r & 0xFC) << 24); - block.y = ((get_end_point_l(0).g & 0xFC) >> 2) | ((get_end_point_h(0).g & 0xFC) << 4) - | ((get_end_point_l(1).g & 0xFC) << 10) | ((get_end_point_h(1).g & 0xFC) << 16) - | ((get_end_point_l(0).b & 0xFC) << 22) | ((get_end_point_h(0).b & 0xFC) << 28); - block.z = ((get_end_point_h(0).b & 0xFC) >> 4) | ((get_end_point_l(1).b & 0xFC) << 2) - | ((get_end_point_h(1).b & 0xFC) << 8) - | ((get_end_point_l(0).r & 0x02) << 15) | ((get_end_point_l(1).r & 0x02) << 16) - | (get_color_index(0) << 18); - if (candidateFixUpIndex1DOrdered[partition][0] == 15) - { - block.w = (get_color_index(15) << 30) | (get_color_index(14) << 27) | (get_color_index(13) << 24) | (get_color_index(12) << 21) | (get_color_index(11) << 18) | (get_color_index(10) << 15) - | (get_color_index(9) << 12) | (get_color_index(8) << 9) | (get_color_index(7) << 6) | (get_color_index(6) << 3) | get_color_index(5); - block.z |= (get_color_index(4) << 29) | (get_color_index(3) << 26) | (get_color_index(2) << 23) | (get_color_index(1) << 20) | (get_color_index(0) << 18); - } - else if (candidateFixUpIndex1DOrdered[partition][0] == 2) - { - block.w = (get_color_index(15) << 29) | (get_color_index(14) << 26) | (get_color_index(13) << 23) | (get_color_index(12) << 20) | (get_color_index(11) << 17) | (get_color_index(10) << 14) - | (get_color_index(9) << 11) | (get_color_index(8) << 8) | (get_color_index(7) << 5) | (get_color_index(6) << 2) | (get_color_index(5) >> 1); - block.z |= (get_color_index(5) << 31) | (get_color_index(4) << 28) | (get_color_index(3) << 25) | (get_color_index(2) << 23) | (get_color_index(1) << 20) | (get_color_index(0) << 18); - } - else if (candidateFixUpIndex1DOrdered[partition][0] == 8) - { - block.w = (get_color_index(15) << 29) | (get_color_index(14) << 26) | (get_color_index(13) << 23) | (get_color_index(12) << 20) | (get_color_index(11) << 17) | (get_color_index(10) << 14) - | (get_color_index(9) << 11) | (get_color_index(8) << 9) | (get_color_index(7) << 6) | (get_color_index(6) << 3) | get_color_index(5); - block.z |= (get_color_index(4) << 29) | (get_color_index(3) << 26) | (get_color_index(2) << 23) | (get_color_index(1) << 20) | (get_color_index(0) << 18); - } - else //candidateFixUpIndex1DOrdered[partition] == 6 - { - block.w = (get_color_index(15) << 29) | (get_color_index(14) << 26) | (get_color_index(13) << 23) | (get_color_index(12) << 20) | (get_color_index(11) << 17) | (get_color_index(10) << 14) - | (get_color_index(9) << 11) | (get_color_index(8) << 8) | (get_color_index(7) << 5) | (get_color_index(6) << 3) | get_color_index(5); - block.z |= (get_color_index(4) << 29) | (get_color_index(3) << 26) | (get_color_index(2) << 23) | (get_color_index(1) << 20) | (get_color_index(0) << 18); - } -} -void block_package2(out uint4 block, uint partition, uint threadBase) -{ - block.x = 0x04 | ((partition - 64) << 3) - | ((get_end_point_l(0).r & 0xF8) << 6) | ((get_end_point_h(0).r & 0xF8) << 11) - | ((get_end_point_l(1).r & 0xF8) << 16) | ((get_end_point_h(1).r & 0xF8) << 21) - | ((get_end_point_l(2).r & 0xF8) << 26); - block.y = ((get_end_point_l(2).r & 0xF8) >> 6) | ((get_end_point_h(2).r & 0xF8) >> 1) - | ((get_end_point_l(0).g & 0xF8) << 4) | ((get_end_point_h(0).g & 0xF8) << 9) - | ((get_end_point_l(1).g & 0xF8) << 14) | ((get_end_point_h(1).g & 0xF8) << 19) - | ((get_end_point_l(2).g & 0xF8) << 24); - block.z = ((get_end_point_h(2).g & 0xF8) >> 3) | ((get_end_point_l(0).b & 0xF8) << 2) - | ((get_end_point_h(0).b & 0xF8) << 7) | ((get_end_point_l(1).b & 0xF8) << 12) - | ((get_end_point_h(1).b & 0xF8) << 17) | ((get_end_point_l(2).b & 0xF8) << 22) - | ((get_end_point_h(2).b & 0xF8) << 27); - block.w = ((get_end_point_h(2).b & 0xF8) >> 5) - | (get_color_index(0) << 3); - uint i = 1; - for (; i <= candidateFixUpIndex1DOrdered[partition][0]; i++) - { - block.w |= get_color_index(i) << (i * 2 + 2); - } - for (; i <= candidateFixUpIndex1DOrdered[partition][1]; i++) - { - block.w |= get_color_index(i) << (i * 2 + 1); - } - for (; i < 16; i++) - { - block.w |= get_color_index(i) << (i * 2); - } -} -void block_package3(out uint4 block, uint partition, uint threadBase) -{ - block.x = 0x08 | (partition << 4) - | ((get_end_point_l(0).r & 0xFE) << 9) | ((get_end_point_h(0).r & 0xFE) << 16) - | ((get_end_point_l(1).r & 0xFE) << 23) | ((get_end_point_h(1).r & 0xFE) << 30); - block.y = ((get_end_point_h(1).r & 0xFE) >> 2) | ((get_end_point_l(0).g & 0xFE) << 5) - | ((get_end_point_h(0).g & 0xFE) << 12) | ((get_end_point_l(1).g & 0xFE) << 19) - | ((get_end_point_h(1).g & 0xFE) << 26); - block.z = ((get_end_point_h(1).g & 0xFE) >> 6) | ((get_end_point_l(0).b & 0xFE) << 1) - | ((get_end_point_h(0).b & 0xFE) << 8) | ((get_end_point_l(1).b & 0xFE) << 15) - | ((get_end_point_h(1).b & 0xFE) << 22) - | ((get_end_point_l(0).r & 0x01) << 30) | ((get_end_point_h(0).r & 0x01) << 31); - block.w = ((get_end_point_l(1).r & 0x01) << 0) | ((get_end_point_h(1).r & 0x01) << 1) - | (get_color_index(0) << 2); - uint i = 1; - for (; i <= candidateFixUpIndex1DOrdered[partition][0]; i++) - { - block.w |= get_color_index(i) << (i * 2 + 1); - } - for (; i < 16; i++) - { - block.w |= get_color_index(i) << (i * 2); - } -} -void block_package4(out uint4 block, uint rotation, uint index_selector, uint threadBase) -{ - block.x = 0x10 | ((rotation & 3) << 5) | ((index_selector & 1) << 7) - | ((get_end_point_l(0).r & 0xF8) << 5) | ((get_end_point_h(0).r & 0xF8) << 10) - | ((get_end_point_l(0).g & 0xF8) << 15) | ((get_end_point_h(0).g & 0xF8) << 20) - | ((get_end_point_l(0).b & 0xF8) << 25); - - block.y = ((get_end_point_l(0).b & 0xF8) >> 7) | ((get_end_point_h(0).b & 0xF8) >> 2) - | ((get_end_point_l(0).a & 0xFC) << 4) | ((get_end_point_h(0).a & 0xFC) << 10) - | ((get_color_index(0) & 1) << 18) | (get_color_index(1) << 19) | (get_color_index(2) << 21) | (get_color_index(3) << 23) - | (get_color_index(4) << 25) | (get_color_index(5) << 27) | (get_color_index(6) << 29) | (get_color_index(7) << 31); - - block.z = (get_color_index(7) >> 1) | (get_color_index(8) << 1) | (get_color_index(9) << 3) | (get_color_index(10)<< 5) - | (get_color_index(11)<< 7) | (get_color_index(12)<< 9) | (get_color_index(13)<< 11) | (get_color_index(14)<< 13) - | (get_color_index(15)<< 15) | ((get_alpha_index(0) & 3) << 17) | (get_alpha_index(1) << 19) | (get_alpha_index(2) << 22) - | (get_alpha_index(3) << 25) | (get_alpha_index(4) << 28) | (get_alpha_index(5) << 31); - - block.w = (get_alpha_index(5) >> 1) | (get_alpha_index(6) << 2) | (get_alpha_index(7) << 5) | (get_alpha_index(8) << 8) - | (get_alpha_index(9) << 11) | (get_alpha_index(10)<< 14) | (get_alpha_index(11)<< 17) | (get_alpha_index(12)<< 20) - | (get_alpha_index(13)<< 23) | (get_alpha_index(14)<< 26) | (get_alpha_index(15)<< 29); -} -void block_package5(out uint4 block, uint rotation, uint threadBase) -{ - block.x = 0x20 | (rotation << 6) - | ((get_end_point_l(0).r & 0xFE) << 7) | ((get_end_point_h(0).r & 0xFE) << 14) - | ((get_end_point_l(0).g & 0xFE) << 21) | ((get_end_point_h(0).g & 0xFE) << 28); - block.y = ((get_end_point_h(0).g & 0xFE) >> 4) | ((get_end_point_l(0).b & 0xFE) << 3) - | ((get_end_point_h(0).b & 0xFE) << 10) | (get_end_point_l(0).a << 18) | (get_end_point_h(0).a << 26); - block.z = (get_end_point_h(0).a >> 6) - | (get_color_index(0) << 2) | (get_color_index(1) << 3) | (get_color_index(2) << 5) | (get_color_index(3) << 7) - | (get_color_index(4) << 9) | (get_color_index(5) << 11) | (get_color_index(6) << 13) | (get_color_index(7) << 15) - | (get_color_index(8) << 17) | (get_color_index(9) << 19) | (get_color_index(10)<< 21) | (get_color_index(11)<< 23) - | (get_color_index(12)<< 25) | (get_color_index(13)<< 27) | (get_color_index(14)<< 29) | (get_color_index(15)<< 31); - block.w = (get_color_index(15)>> 1) | (get_alpha_index(0) << 1) | (get_alpha_index(1) << 2) | (get_alpha_index(2) << 4) - | (get_alpha_index(3) << 6) | (get_alpha_index(4) << 8) | (get_alpha_index(5) << 10) | (get_alpha_index(6) << 12) - | (get_alpha_index(7) << 14) | (get_alpha_index(8) << 16) | (get_alpha_index(9) << 18) | (get_alpha_index(10)<< 20) - | (get_alpha_index(11)<< 22) | (get_alpha_index(12)<< 24) | (get_alpha_index(13)<< 26) | (get_alpha_index(14)<< 28) - | (get_alpha_index(15)<< 30); -} -void block_package6(out uint4 block, uint threadBase) -{ - block.x = 0x40 - | ((get_end_point_l(0).r & 0xFE) << 6) | ((get_end_point_h(0).r & 0xFE) << 13) - | ((get_end_point_l(0).g & 0xFE) << 20) | ((get_end_point_h(0).g & 0xFE) << 27); - block.y = ((get_end_point_h(0).g & 0xFE) >> 5) | ((get_end_point_l(0).b & 0xFE) << 2) - | ((get_end_point_h(0).b & 0xFE) << 9) | ((get_end_point_l(0).a & 0xFE) << 16) - | ((get_end_point_h(0).a & 0xFE) << 23) - | (get_end_point_l(0).r & 0x01) << 31; - block.z = (get_end_point_h(0).r & 0x01) - | (get_color_index(0) << 1) | (get_color_index(1) << 4) | (get_color_index(2) << 8) | (get_color_index(3) << 12) - | (get_color_index(4) << 16) | (get_color_index(5) << 20) | (get_color_index(6) << 24) | (get_color_index(7) << 28); - block.w = (get_color_index(8) << 0) | (get_color_index(9) << 4) | (get_color_index(10)<< 8) | (get_color_index(11)<< 12) - | (get_color_index(12)<< 16) | (get_color_index(13)<< 20) | (get_color_index(14)<< 24) | (get_color_index(15)<< 28); -} -void block_package7(out uint4 block, uint partition, uint threadBase) -{ - block.x = 0x80 | (partition << 8) - | ((get_end_point_l(0).r & 0xF8) << 11) | ((get_end_point_h(0).r & 0xF8) << 16) - | ((get_end_point_l(1).r & 0xF8) << 21) | ((get_end_point_h(1).r & 0xF8) << 26); - block.y = ((get_end_point_h(1).r & 0xF8) >> 6) | ((get_end_point_l(0).g & 0xF8) >> 1) - | ((get_end_point_h(0).g & 0xF8) << 4) | ((get_end_point_l(1).g & 0xF8) << 9) - | ((get_end_point_h(1).g & 0xF8) << 14) | ((get_end_point_l(0).b & 0xF8) << 19) - | ((get_end_point_h(0).b & 0xF8) << 24); - block.z = ((get_end_point_l(1).b & 0xF8) >> 3) | ((get_end_point_h(1).b & 0xF8) << 2) - | ((get_end_point_l(0).a & 0xF8) << 7) | ((get_end_point_h(0).a & 0xF8) << 12) - | ((get_end_point_l(1).a & 0xF8) << 17) | ((get_end_point_h(1).a & 0xF8) << 22) - | ((get_end_point_l(0).r & 0x04) << 28) | ((get_end_point_h(0).r & 0x04) << 29); - block.w = ((get_end_point_l(1).r & 0x04) >> 2) | ((get_end_point_h(1).r & 0x04) >> 1) - | (get_color_index(0) << 2); - uint i = 1; - for (; i <= candidateFixUpIndex1DOrdered[partition][0]; i++) - { - block.w |= get_color_index(i) << (i * 2 + 1); - } - for (; i < 16; i++) - { - block.w |= get_color_index(i) << (i * 2); - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/Shaders/CompileShaders.cmd b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/Shaders/CompileShaders.cmd deleted file mode 100644 index 6d953bb..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/Shaders/CompileShaders.cmd +++ /dev/null @@ -1,51 +0,0 @@ -@echo off -rem Copyright (c) Microsoft Corporation. -rem Licensed under the MIT License. - -setlocal -set error=0 - -set FXCOPTS=/nologo /WX /Ges /Zi /Zpc /Qstrip_reflect /Qstrip_debug - -set PCFXC="%WindowsSdkVerBinPath%x86\fxc.exe" -if exist %PCFXC% goto continue -set PCFXC="%WindowsSdkBinPath%%WindowsSDKVersion%\x86\fxc.exe" -if exist %PCFXC% goto continue -set PCFXC="%WindowsSdkDir%bin\%WindowsSDKVersion%\x86\fxc.exe" -if exist %PCFXC% goto continue - -set PCFXC=fxc.exe - -:continue -if not defined CompileShadersOutput set CompileShadersOutput=Compiled -set StrTrim=%CompileShadersOutput%## -set StrTrim=%StrTrim: ##=% -set CompileShadersOutput=%StrTrim:##=% -@if not exist "%CompileShadersOutput%" mkdir "%CompileShadersOutput%" -call :CompileShader BC7Encode TryMode456CS -call :CompileShader BC7Encode TryMode137CS -call :CompileShader BC7Encode TryMode02CS -call :CompileShader BC7Encode EncodeBlockCS - -call :CompileShader BC6HEncode TryModeG10CS -call :CompileShader BC6HEncode TryModeLE10CS -call :CompileShader BC6HEncode EncodeBlockCS - -echo. - -if %error% == 0 ( - echo Shaders compiled ok -) else ( - echo There were shader compilation errors! - exit /b 1 -) - -endlocal -exit /b 0 - -:CompileShader -set fxc=%PCFXC% %1.hlsl %FXCOPTS% /Tcs_4_0 /E%2 "/Fh%CompileShadersOutput%\%1_%2.inc" "/Fd%CompileShadersOutput%\%1_%2.pdb" /Vn%1_%2 -echo. -echo %fxc% -%fxc% || set error=1 -exit /b diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/d3dx12.h b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/d3dx12.h deleted file mode 100644 index 42f26a6..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/d3dx12.h +++ /dev/null @@ -1,5116 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License (MIT). -// -//********************************************************* - -#ifndef __D3DX12_H__ -#define __D3DX12_H__ - -#include "d3d12.h" - -#if defined( __cplusplus ) - -struct CD3DX12_DEFAULT {}; -extern const DECLSPEC_SELECTANY CD3DX12_DEFAULT D3D12_DEFAULT; - -//------------------------------------------------------------------------------------------------ -inline bool operator==( const D3D12_VIEWPORT& l, const D3D12_VIEWPORT& r ) noexcept -{ - return l.TopLeftX == r.TopLeftX && l.TopLeftY == r.TopLeftY && l.Width == r.Width && - l.Height == r.Height && l.MinDepth == r.MinDepth && l.MaxDepth == r.MaxDepth; -} - -//------------------------------------------------------------------------------------------------ -inline bool operator!=( const D3D12_VIEWPORT& l, const D3D12_VIEWPORT& r ) noexcept -{ return !( l == r ); } - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_RECT : public D3D12_RECT -{ - CD3DX12_RECT() = default; - explicit CD3DX12_RECT( const D3D12_RECT& o ) noexcept : - D3D12_RECT( o ) - {} - explicit CD3DX12_RECT( - LONG Left, - LONG Top, - LONG Right, - LONG Bottom ) noexcept - { - left = Left; - top = Top; - right = Right; - bottom = Bottom; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_VIEWPORT : public D3D12_VIEWPORT -{ - CD3DX12_VIEWPORT() = default; - explicit CD3DX12_VIEWPORT( const D3D12_VIEWPORT& o ) noexcept : - D3D12_VIEWPORT( o ) - {} - explicit CD3DX12_VIEWPORT( - FLOAT topLeftX, - FLOAT topLeftY, - FLOAT width, - FLOAT height, - FLOAT minDepth = D3D12_MIN_DEPTH, - FLOAT maxDepth = D3D12_MAX_DEPTH ) noexcept - { - TopLeftX = topLeftX; - TopLeftY = topLeftY; - Width = width; - Height = height; - MinDepth = minDepth; - MaxDepth = maxDepth; - } - explicit CD3DX12_VIEWPORT( - _In_ ID3D12Resource* pResource, - UINT mipSlice = 0, - FLOAT topLeftX = 0.0f, - FLOAT topLeftY = 0.0f, - FLOAT minDepth = D3D12_MIN_DEPTH, - FLOAT maxDepth = D3D12_MAX_DEPTH ) noexcept - { - const auto Desc = pResource->GetDesc(); - const UINT64 SubresourceWidth = Desc.Width >> mipSlice; - const UINT64 SubresourceHeight = Desc.Height >> mipSlice; - switch (Desc.Dimension) - { - case D3D12_RESOURCE_DIMENSION_BUFFER: - TopLeftX = topLeftX; - TopLeftY = 0.0f; - Width = float(Desc.Width) - topLeftX; - Height = 1.0f; - break; - case D3D12_RESOURCE_DIMENSION_TEXTURE1D: - TopLeftX = topLeftX; - TopLeftY = 0.0f; - Width = (SubresourceWidth ? float(SubresourceWidth) : 1.0f) - topLeftX; - Height = 1.0f; - break; - case D3D12_RESOURCE_DIMENSION_TEXTURE2D: - case D3D12_RESOURCE_DIMENSION_TEXTURE3D: - TopLeftX = topLeftX; - TopLeftY = topLeftY; - Width = (SubresourceWidth ? float(SubresourceWidth) : 1.0f) - topLeftX; - Height = (SubresourceHeight ? float(SubresourceHeight) : 1.0f) - topLeftY; - break; - default: break; - } - - MinDepth = minDepth; - MaxDepth = maxDepth; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_BOX : public D3D12_BOX -{ - CD3DX12_BOX() = default; - explicit CD3DX12_BOX( const D3D12_BOX& o ) noexcept : - D3D12_BOX( o ) - {} - explicit CD3DX12_BOX( - LONG Left, - LONG Right ) noexcept - { - left = static_cast(Left); - top = 0; - front = 0; - right = static_cast(Right); - bottom = 1; - back = 1; - } - explicit CD3DX12_BOX( - LONG Left, - LONG Top, - LONG Right, - LONG Bottom ) noexcept - { - left = static_cast(Left); - top = static_cast(Top); - front = 0; - right = static_cast(Right); - bottom = static_cast(Bottom); - back = 1; - } - explicit CD3DX12_BOX( - LONG Left, - LONG Top, - LONG Front, - LONG Right, - LONG Bottom, - LONG Back ) noexcept - { - left = static_cast(Left); - top = static_cast(Top); - front = static_cast(Front); - right = static_cast(Right); - bottom = static_cast(Bottom); - back = static_cast(Back); - } -}; -inline bool operator==( const D3D12_BOX& l, const D3D12_BOX& r ) noexcept -{ - return l.left == r.left && l.top == r.top && l.front == r.front && - l.right == r.right && l.bottom == r.bottom && l.back == r.back; -} -inline bool operator!=( const D3D12_BOX& l, const D3D12_BOX& r ) noexcept -{ return !( l == r ); } - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_DEPTH_STENCIL_DESC : public D3D12_DEPTH_STENCIL_DESC -{ - CD3DX12_DEPTH_STENCIL_DESC() = default; - explicit CD3DX12_DEPTH_STENCIL_DESC( const D3D12_DEPTH_STENCIL_DESC& o ) noexcept : - D3D12_DEPTH_STENCIL_DESC( o ) - {} - explicit CD3DX12_DEPTH_STENCIL_DESC( CD3DX12_DEFAULT ) noexcept - { - DepthEnable = TRUE; - DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ALL; - DepthFunc = D3D12_COMPARISON_FUNC_LESS; - StencilEnable = FALSE; - StencilReadMask = D3D12_DEFAULT_STENCIL_READ_MASK; - StencilWriteMask = D3D12_DEFAULT_STENCIL_WRITE_MASK; - const D3D12_DEPTH_STENCILOP_DESC defaultStencilOp = - { D3D12_STENCIL_OP_KEEP, D3D12_STENCIL_OP_KEEP, D3D12_STENCIL_OP_KEEP, D3D12_COMPARISON_FUNC_ALWAYS }; - FrontFace = defaultStencilOp; - BackFace = defaultStencilOp; - } - explicit CD3DX12_DEPTH_STENCIL_DESC( - BOOL depthEnable, - D3D12_DEPTH_WRITE_MASK depthWriteMask, - D3D12_COMPARISON_FUNC depthFunc, - BOOL stencilEnable, - UINT8 stencilReadMask, - UINT8 stencilWriteMask, - D3D12_STENCIL_OP frontStencilFailOp, - D3D12_STENCIL_OP frontStencilDepthFailOp, - D3D12_STENCIL_OP frontStencilPassOp, - D3D12_COMPARISON_FUNC frontStencilFunc, - D3D12_STENCIL_OP backStencilFailOp, - D3D12_STENCIL_OP backStencilDepthFailOp, - D3D12_STENCIL_OP backStencilPassOp, - D3D12_COMPARISON_FUNC backStencilFunc ) noexcept - { - DepthEnable = depthEnable; - DepthWriteMask = depthWriteMask; - DepthFunc = depthFunc; - StencilEnable = stencilEnable; - StencilReadMask = stencilReadMask; - StencilWriteMask = stencilWriteMask; - FrontFace.StencilFailOp = frontStencilFailOp; - FrontFace.StencilDepthFailOp = frontStencilDepthFailOp; - FrontFace.StencilPassOp = frontStencilPassOp; - FrontFace.StencilFunc = frontStencilFunc; - BackFace.StencilFailOp = backStencilFailOp; - BackFace.StencilDepthFailOp = backStencilDepthFailOp; - BackFace.StencilPassOp = backStencilPassOp; - BackFace.StencilFunc = backStencilFunc; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_DEPTH_STENCIL_DESC1 : public D3D12_DEPTH_STENCIL_DESC1 -{ - CD3DX12_DEPTH_STENCIL_DESC1() = default; - explicit CD3DX12_DEPTH_STENCIL_DESC1( const D3D12_DEPTH_STENCIL_DESC1& o ) noexcept : - D3D12_DEPTH_STENCIL_DESC1( o ) - {} - explicit CD3DX12_DEPTH_STENCIL_DESC1( const D3D12_DEPTH_STENCIL_DESC& o ) noexcept - { - DepthEnable = o.DepthEnable; - DepthWriteMask = o.DepthWriteMask; - DepthFunc = o.DepthFunc; - StencilEnable = o.StencilEnable; - StencilReadMask = o.StencilReadMask; - StencilWriteMask = o.StencilWriteMask; - FrontFace.StencilFailOp = o.FrontFace.StencilFailOp; - FrontFace.StencilDepthFailOp = o.FrontFace.StencilDepthFailOp; - FrontFace.StencilPassOp = o.FrontFace.StencilPassOp; - FrontFace.StencilFunc = o.FrontFace.StencilFunc; - BackFace.StencilFailOp = o.BackFace.StencilFailOp; - BackFace.StencilDepthFailOp = o.BackFace.StencilDepthFailOp; - BackFace.StencilPassOp = o.BackFace.StencilPassOp; - BackFace.StencilFunc = o.BackFace.StencilFunc; - DepthBoundsTestEnable = FALSE; - } - explicit CD3DX12_DEPTH_STENCIL_DESC1( CD3DX12_DEFAULT ) noexcept - { - DepthEnable = TRUE; - DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ALL; - DepthFunc = D3D12_COMPARISON_FUNC_LESS; - StencilEnable = FALSE; - StencilReadMask = D3D12_DEFAULT_STENCIL_READ_MASK; - StencilWriteMask = D3D12_DEFAULT_STENCIL_WRITE_MASK; - const D3D12_DEPTH_STENCILOP_DESC defaultStencilOp = - { D3D12_STENCIL_OP_KEEP, D3D12_STENCIL_OP_KEEP, D3D12_STENCIL_OP_KEEP, D3D12_COMPARISON_FUNC_ALWAYS }; - FrontFace = defaultStencilOp; - BackFace = defaultStencilOp; - DepthBoundsTestEnable = FALSE; - } - explicit CD3DX12_DEPTH_STENCIL_DESC1( - BOOL depthEnable, - D3D12_DEPTH_WRITE_MASK depthWriteMask, - D3D12_COMPARISON_FUNC depthFunc, - BOOL stencilEnable, - UINT8 stencilReadMask, - UINT8 stencilWriteMask, - D3D12_STENCIL_OP frontStencilFailOp, - D3D12_STENCIL_OP frontStencilDepthFailOp, - D3D12_STENCIL_OP frontStencilPassOp, - D3D12_COMPARISON_FUNC frontStencilFunc, - D3D12_STENCIL_OP backStencilFailOp, - D3D12_STENCIL_OP backStencilDepthFailOp, - D3D12_STENCIL_OP backStencilPassOp, - D3D12_COMPARISON_FUNC backStencilFunc, - BOOL depthBoundsTestEnable ) noexcept - { - DepthEnable = depthEnable; - DepthWriteMask = depthWriteMask; - DepthFunc = depthFunc; - StencilEnable = stencilEnable; - StencilReadMask = stencilReadMask; - StencilWriteMask = stencilWriteMask; - FrontFace.StencilFailOp = frontStencilFailOp; - FrontFace.StencilDepthFailOp = frontStencilDepthFailOp; - FrontFace.StencilPassOp = frontStencilPassOp; - FrontFace.StencilFunc = frontStencilFunc; - BackFace.StencilFailOp = backStencilFailOp; - BackFace.StencilDepthFailOp = backStencilDepthFailOp; - BackFace.StencilPassOp = backStencilPassOp; - BackFace.StencilFunc = backStencilFunc; - DepthBoundsTestEnable = depthBoundsTestEnable; - } - operator D3D12_DEPTH_STENCIL_DESC() const noexcept - { - D3D12_DEPTH_STENCIL_DESC D; - D.DepthEnable = DepthEnable; - D.DepthWriteMask = DepthWriteMask; - D.DepthFunc = DepthFunc; - D.StencilEnable = StencilEnable; - D.StencilReadMask = StencilReadMask; - D.StencilWriteMask = StencilWriteMask; - D.FrontFace.StencilFailOp = FrontFace.StencilFailOp; - D.FrontFace.StencilDepthFailOp = FrontFace.StencilDepthFailOp; - D.FrontFace.StencilPassOp = FrontFace.StencilPassOp; - D.FrontFace.StencilFunc = FrontFace.StencilFunc; - D.BackFace.StencilFailOp = BackFace.StencilFailOp; - D.BackFace.StencilDepthFailOp = BackFace.StencilDepthFailOp; - D.BackFace.StencilPassOp = BackFace.StencilPassOp; - D.BackFace.StencilFunc = BackFace.StencilFunc; - return D; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_BLEND_DESC : public D3D12_BLEND_DESC -{ - CD3DX12_BLEND_DESC() = default; - explicit CD3DX12_BLEND_DESC( const D3D12_BLEND_DESC& o ) noexcept : - D3D12_BLEND_DESC( o ) - {} - explicit CD3DX12_BLEND_DESC( CD3DX12_DEFAULT ) noexcept - { - AlphaToCoverageEnable = FALSE; - IndependentBlendEnable = FALSE; - const D3D12_RENDER_TARGET_BLEND_DESC defaultRenderTargetBlendDesc = - { - FALSE,FALSE, - D3D12_BLEND_ONE, D3D12_BLEND_ZERO, D3D12_BLEND_OP_ADD, - D3D12_BLEND_ONE, D3D12_BLEND_ZERO, D3D12_BLEND_OP_ADD, - D3D12_LOGIC_OP_NOOP, - D3D12_COLOR_WRITE_ENABLE_ALL, - }; - for (UINT i = 0; i < D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i) - RenderTarget[ i ] = defaultRenderTargetBlendDesc; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_RASTERIZER_DESC : public D3D12_RASTERIZER_DESC -{ - CD3DX12_RASTERIZER_DESC() = default; - explicit CD3DX12_RASTERIZER_DESC( const D3D12_RASTERIZER_DESC& o ) noexcept : - D3D12_RASTERIZER_DESC( o ) - {} - explicit CD3DX12_RASTERIZER_DESC( CD3DX12_DEFAULT ) noexcept - { - FillMode = D3D12_FILL_MODE_SOLID; - CullMode = D3D12_CULL_MODE_BACK; - FrontCounterClockwise = FALSE; - DepthBias = D3D12_DEFAULT_DEPTH_BIAS; - DepthBiasClamp = D3D12_DEFAULT_DEPTH_BIAS_CLAMP; - SlopeScaledDepthBias = D3D12_DEFAULT_SLOPE_SCALED_DEPTH_BIAS; - DepthClipEnable = TRUE; - MultisampleEnable = FALSE; - AntialiasedLineEnable = FALSE; - ForcedSampleCount = 0; - ConservativeRaster = D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF; - } - explicit CD3DX12_RASTERIZER_DESC( - D3D12_FILL_MODE fillMode, - D3D12_CULL_MODE cullMode, - BOOL frontCounterClockwise, - INT depthBias, - FLOAT depthBiasClamp, - FLOAT slopeScaledDepthBias, - BOOL depthClipEnable, - BOOL multisampleEnable, - BOOL antialiasedLineEnable, - UINT forcedSampleCount, - D3D12_CONSERVATIVE_RASTERIZATION_MODE conservativeRaster) noexcept - { - FillMode = fillMode; - CullMode = cullMode; - FrontCounterClockwise = frontCounterClockwise; - DepthBias = depthBias; - DepthBiasClamp = depthBiasClamp; - SlopeScaledDepthBias = slopeScaledDepthBias; - DepthClipEnable = depthClipEnable; - MultisampleEnable = multisampleEnable; - AntialiasedLineEnable = antialiasedLineEnable; - ForcedSampleCount = forcedSampleCount; - ConservativeRaster = conservativeRaster; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_RESOURCE_ALLOCATION_INFO : public D3D12_RESOURCE_ALLOCATION_INFO -{ - CD3DX12_RESOURCE_ALLOCATION_INFO() = default; - explicit CD3DX12_RESOURCE_ALLOCATION_INFO( const D3D12_RESOURCE_ALLOCATION_INFO& o ) noexcept : - D3D12_RESOURCE_ALLOCATION_INFO( o ) - {} - CD3DX12_RESOURCE_ALLOCATION_INFO( - UINT64 size, - UINT64 alignment ) noexcept - { - SizeInBytes = size; - Alignment = alignment; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_HEAP_PROPERTIES : public D3D12_HEAP_PROPERTIES -{ - CD3DX12_HEAP_PROPERTIES() = default; - explicit CD3DX12_HEAP_PROPERTIES(const D3D12_HEAP_PROPERTIES &o) noexcept : - D3D12_HEAP_PROPERTIES(o) - {} - CD3DX12_HEAP_PROPERTIES( - D3D12_CPU_PAGE_PROPERTY cpuPageProperty, - D3D12_MEMORY_POOL memoryPoolPreference, - UINT creationNodeMask = 1, - UINT nodeMask = 1 ) noexcept - { - Type = D3D12_HEAP_TYPE_CUSTOM; - CPUPageProperty = cpuPageProperty; - MemoryPoolPreference = memoryPoolPreference; - CreationNodeMask = creationNodeMask; - VisibleNodeMask = nodeMask; - } - explicit CD3DX12_HEAP_PROPERTIES( - D3D12_HEAP_TYPE type, - UINT creationNodeMask = 1, - UINT nodeMask = 1 ) noexcept - { - Type = type; - CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; - MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; - CreationNodeMask = creationNodeMask; - VisibleNodeMask = nodeMask; - } - bool IsCPUAccessible() const noexcept - { - return Type == D3D12_HEAP_TYPE_UPLOAD || Type == D3D12_HEAP_TYPE_READBACK || (Type == D3D12_HEAP_TYPE_CUSTOM && - (CPUPageProperty == D3D12_CPU_PAGE_PROPERTY_WRITE_COMBINE || CPUPageProperty == D3D12_CPU_PAGE_PROPERTY_WRITE_BACK)); - } -}; -inline bool operator==( const D3D12_HEAP_PROPERTIES& l, const D3D12_HEAP_PROPERTIES& r ) noexcept -{ - return l.Type == r.Type && l.CPUPageProperty == r.CPUPageProperty && - l.MemoryPoolPreference == r.MemoryPoolPreference && - l.CreationNodeMask == r.CreationNodeMask && - l.VisibleNodeMask == r.VisibleNodeMask; -} -inline bool operator!=( const D3D12_HEAP_PROPERTIES& l, const D3D12_HEAP_PROPERTIES& r ) noexcept -{ return !( l == r ); } - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_HEAP_DESC : public D3D12_HEAP_DESC -{ - CD3DX12_HEAP_DESC() = default; - explicit CD3DX12_HEAP_DESC(const D3D12_HEAP_DESC &o) noexcept : - D3D12_HEAP_DESC(o) - {} - CD3DX12_HEAP_DESC( - UINT64 size, - D3D12_HEAP_PROPERTIES properties, - UINT64 alignment = 0, - D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE ) noexcept - { - SizeInBytes = size; - Properties = properties; - Alignment = alignment; - Flags = flags; - } - CD3DX12_HEAP_DESC( - UINT64 size, - D3D12_HEAP_TYPE type, - UINT64 alignment = 0, - D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE ) noexcept - { - SizeInBytes = size; - Properties = CD3DX12_HEAP_PROPERTIES( type ); - Alignment = alignment; - Flags = flags; - } - CD3DX12_HEAP_DESC( - UINT64 size, - D3D12_CPU_PAGE_PROPERTY cpuPageProperty, - D3D12_MEMORY_POOL memoryPoolPreference, - UINT64 alignment = 0, - D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE ) noexcept - { - SizeInBytes = size; - Properties = CD3DX12_HEAP_PROPERTIES( cpuPageProperty, memoryPoolPreference ); - Alignment = alignment; - Flags = flags; - } - CD3DX12_HEAP_DESC( - const D3D12_RESOURCE_ALLOCATION_INFO& resAllocInfo, - D3D12_HEAP_PROPERTIES properties, - D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE ) noexcept - { - SizeInBytes = resAllocInfo.SizeInBytes; - Properties = properties; - Alignment = resAllocInfo.Alignment; - Flags = flags; - } - CD3DX12_HEAP_DESC( - const D3D12_RESOURCE_ALLOCATION_INFO& resAllocInfo, - D3D12_HEAP_TYPE type, - D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE ) noexcept - { - SizeInBytes = resAllocInfo.SizeInBytes; - Properties = CD3DX12_HEAP_PROPERTIES( type ); - Alignment = resAllocInfo.Alignment; - Flags = flags; - } - CD3DX12_HEAP_DESC( - const D3D12_RESOURCE_ALLOCATION_INFO& resAllocInfo, - D3D12_CPU_PAGE_PROPERTY cpuPageProperty, - D3D12_MEMORY_POOL memoryPoolPreference, - D3D12_HEAP_FLAGS flags = D3D12_HEAP_FLAG_NONE ) noexcept - { - SizeInBytes = resAllocInfo.SizeInBytes; - Properties = CD3DX12_HEAP_PROPERTIES( cpuPageProperty, memoryPoolPreference ); - Alignment = resAllocInfo.Alignment; - Flags = flags; - } - bool IsCPUAccessible() const noexcept - { return static_cast< const CD3DX12_HEAP_PROPERTIES* >( &Properties )->IsCPUAccessible(); } -}; -inline bool operator==( const D3D12_HEAP_DESC& l, const D3D12_HEAP_DESC& r ) noexcept -{ - return l.SizeInBytes == r.SizeInBytes && - l.Properties == r.Properties && - l.Alignment == r.Alignment && - l.Flags == r.Flags; -} -inline bool operator!=( const D3D12_HEAP_DESC& l, const D3D12_HEAP_DESC& r ) noexcept -{ return !( l == r ); } - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_CLEAR_VALUE : public D3D12_CLEAR_VALUE -{ - CD3DX12_CLEAR_VALUE() = default; - explicit CD3DX12_CLEAR_VALUE(const D3D12_CLEAR_VALUE &o) noexcept : - D3D12_CLEAR_VALUE(o) - {} - CD3DX12_CLEAR_VALUE( - DXGI_FORMAT format, - const FLOAT color[4] ) noexcept - { - Format = format; - memcpy( Color, color, sizeof( Color ) ); - } - CD3DX12_CLEAR_VALUE( - DXGI_FORMAT format, - FLOAT depth, - UINT8 stencil ) noexcept - { - Format = format; - memset( &Color, 0, sizeof( Color ) ); - /* Use memcpy to preserve NAN values */ - memcpy( &DepthStencil.Depth, &depth, sizeof( depth ) ); - DepthStencil.Stencil = stencil; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_RANGE : public D3D12_RANGE -{ - CD3DX12_RANGE() = default; - explicit CD3DX12_RANGE(const D3D12_RANGE &o) noexcept : - D3D12_RANGE(o) - {} - CD3DX12_RANGE( - SIZE_T begin, - SIZE_T end ) noexcept - { - Begin = begin; - End = end; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_RANGE_UINT64 : public D3D12_RANGE_UINT64 -{ - CD3DX12_RANGE_UINT64() = default; - explicit CD3DX12_RANGE_UINT64(const D3D12_RANGE_UINT64 &o) noexcept : - D3D12_RANGE_UINT64(o) - {} - CD3DX12_RANGE_UINT64( - UINT64 begin, - UINT64 end ) noexcept - { - Begin = begin; - End = end; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_SUBRESOURCE_RANGE_UINT64 : public D3D12_SUBRESOURCE_RANGE_UINT64 -{ - CD3DX12_SUBRESOURCE_RANGE_UINT64() = default; - explicit CD3DX12_SUBRESOURCE_RANGE_UINT64(const D3D12_SUBRESOURCE_RANGE_UINT64 &o) noexcept : - D3D12_SUBRESOURCE_RANGE_UINT64(o) - {} - CD3DX12_SUBRESOURCE_RANGE_UINT64( - UINT subresource, - const D3D12_RANGE_UINT64& range ) noexcept - { - Subresource = subresource; - Range = range; - } - CD3DX12_SUBRESOURCE_RANGE_UINT64( - UINT subresource, - UINT64 begin, - UINT64 end ) noexcept - { - Subresource = subresource; - Range.Begin = begin; - Range.End = end; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_SHADER_BYTECODE : public D3D12_SHADER_BYTECODE -{ - CD3DX12_SHADER_BYTECODE() = default; - explicit CD3DX12_SHADER_BYTECODE(const D3D12_SHADER_BYTECODE &o) noexcept : - D3D12_SHADER_BYTECODE(o) - {} - CD3DX12_SHADER_BYTECODE( - _In_ ID3DBlob* pShaderBlob ) noexcept - { - pShaderBytecode = pShaderBlob->GetBufferPointer(); - BytecodeLength = pShaderBlob->GetBufferSize(); - } - CD3DX12_SHADER_BYTECODE( - const void* _pShaderBytecode, - SIZE_T bytecodeLength ) noexcept - { - pShaderBytecode = _pShaderBytecode; - BytecodeLength = bytecodeLength; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_TILED_RESOURCE_COORDINATE : public D3D12_TILED_RESOURCE_COORDINATE -{ - CD3DX12_TILED_RESOURCE_COORDINATE() = default; - explicit CD3DX12_TILED_RESOURCE_COORDINATE(const D3D12_TILED_RESOURCE_COORDINATE &o) noexcept : - D3D12_TILED_RESOURCE_COORDINATE(o) - {} - CD3DX12_TILED_RESOURCE_COORDINATE( - UINT x, - UINT y, - UINT z, - UINT subresource ) noexcept - { - X = x; - Y = y; - Z = z; - Subresource = subresource; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_TILE_REGION_SIZE : public D3D12_TILE_REGION_SIZE -{ - CD3DX12_TILE_REGION_SIZE() = default; - explicit CD3DX12_TILE_REGION_SIZE(const D3D12_TILE_REGION_SIZE &o) noexcept : - D3D12_TILE_REGION_SIZE(o) - {} - CD3DX12_TILE_REGION_SIZE( - UINT numTiles, - BOOL useBox, - UINT width, - UINT16 height, - UINT16 depth ) noexcept - { - NumTiles = numTiles; - UseBox = useBox; - Width = width; - Height = height; - Depth = depth; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_SUBRESOURCE_TILING : public D3D12_SUBRESOURCE_TILING -{ - CD3DX12_SUBRESOURCE_TILING() = default; - explicit CD3DX12_SUBRESOURCE_TILING(const D3D12_SUBRESOURCE_TILING &o) noexcept : - D3D12_SUBRESOURCE_TILING(o) - {} - CD3DX12_SUBRESOURCE_TILING( - UINT widthInTiles, - UINT16 heightInTiles, - UINT16 depthInTiles, - UINT startTileIndexInOverallResource ) noexcept - { - WidthInTiles = widthInTiles; - HeightInTiles = heightInTiles; - DepthInTiles = depthInTiles; - StartTileIndexInOverallResource = startTileIndexInOverallResource; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_TILE_SHAPE : public D3D12_TILE_SHAPE -{ - CD3DX12_TILE_SHAPE() = default; - explicit CD3DX12_TILE_SHAPE(const D3D12_TILE_SHAPE &o) noexcept : - D3D12_TILE_SHAPE(o) - {} - CD3DX12_TILE_SHAPE( - UINT widthInTexels, - UINT heightInTexels, - UINT depthInTexels ) noexcept - { - WidthInTexels = widthInTexels; - HeightInTexels = heightInTexels; - DepthInTexels = depthInTexels; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_RESOURCE_BARRIER : public D3D12_RESOURCE_BARRIER -{ - CD3DX12_RESOURCE_BARRIER() = default; - explicit CD3DX12_RESOURCE_BARRIER(const D3D12_RESOURCE_BARRIER &o) noexcept : - D3D12_RESOURCE_BARRIER(o) - {} - static inline CD3DX12_RESOURCE_BARRIER Transition( - _In_ ID3D12Resource* pResource, - D3D12_RESOURCE_STATES stateBefore, - D3D12_RESOURCE_STATES stateAfter, - UINT subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES, - D3D12_RESOURCE_BARRIER_FLAGS flags = D3D12_RESOURCE_BARRIER_FLAG_NONE) noexcept - { - CD3DX12_RESOURCE_BARRIER result = {}; - D3D12_RESOURCE_BARRIER &barrier = result; - result.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; - result.Flags = flags; - barrier.Transition.pResource = pResource; - barrier.Transition.StateBefore = stateBefore; - barrier.Transition.StateAfter = stateAfter; - barrier.Transition.Subresource = subresource; - return result; - } - static inline CD3DX12_RESOURCE_BARRIER Aliasing( - _In_ ID3D12Resource* pResourceBefore, - _In_ ID3D12Resource* pResourceAfter) noexcept - { - CD3DX12_RESOURCE_BARRIER result = {}; - D3D12_RESOURCE_BARRIER &barrier = result; - result.Type = D3D12_RESOURCE_BARRIER_TYPE_ALIASING; - barrier.Aliasing.pResourceBefore = pResourceBefore; - barrier.Aliasing.pResourceAfter = pResourceAfter; - return result; - } - static inline CD3DX12_RESOURCE_BARRIER UAV( - _In_ ID3D12Resource* pResource) noexcept - { - CD3DX12_RESOURCE_BARRIER result = {}; - D3D12_RESOURCE_BARRIER &barrier = result; - result.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV; - barrier.UAV.pResource = pResource; - return result; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_PACKED_MIP_INFO : public D3D12_PACKED_MIP_INFO -{ - CD3DX12_PACKED_MIP_INFO() = default; - explicit CD3DX12_PACKED_MIP_INFO(const D3D12_PACKED_MIP_INFO &o) noexcept : - D3D12_PACKED_MIP_INFO(o) - {} - CD3DX12_PACKED_MIP_INFO( - UINT8 numStandardMips, - UINT8 numPackedMips, - UINT numTilesForPackedMips, - UINT startTileIndexInOverallResource ) noexcept - { - NumStandardMips = numStandardMips; - NumPackedMips = numPackedMips; - NumTilesForPackedMips = numTilesForPackedMips; - StartTileIndexInOverallResource = startTileIndexInOverallResource; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_SUBRESOURCE_FOOTPRINT : public D3D12_SUBRESOURCE_FOOTPRINT -{ - CD3DX12_SUBRESOURCE_FOOTPRINT() = default; - explicit CD3DX12_SUBRESOURCE_FOOTPRINT(const D3D12_SUBRESOURCE_FOOTPRINT &o) noexcept : - D3D12_SUBRESOURCE_FOOTPRINT(o) - {} - CD3DX12_SUBRESOURCE_FOOTPRINT( - DXGI_FORMAT format, - UINT width, - UINT height, - UINT depth, - UINT rowPitch ) noexcept - { - Format = format; - Width = width; - Height = height; - Depth = depth; - RowPitch = rowPitch; - } - explicit CD3DX12_SUBRESOURCE_FOOTPRINT( - const D3D12_RESOURCE_DESC& resDesc, - UINT rowPitch ) noexcept - { - Format = resDesc.Format; - Width = UINT( resDesc.Width ); - Height = resDesc.Height; - Depth = (resDesc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D ? resDesc.DepthOrArraySize : 1u); - RowPitch = rowPitch; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_TEXTURE_COPY_LOCATION : public D3D12_TEXTURE_COPY_LOCATION -{ - CD3DX12_TEXTURE_COPY_LOCATION() = default; - explicit CD3DX12_TEXTURE_COPY_LOCATION(const D3D12_TEXTURE_COPY_LOCATION &o) noexcept : - D3D12_TEXTURE_COPY_LOCATION(o) - {} - CD3DX12_TEXTURE_COPY_LOCATION(_In_ ID3D12Resource* pRes) noexcept - { - pResource = pRes; - Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX; - PlacedFootprint = {}; - } - CD3DX12_TEXTURE_COPY_LOCATION(_In_ ID3D12Resource* pRes, D3D12_PLACED_SUBRESOURCE_FOOTPRINT const& Footprint) noexcept - { - pResource = pRes; - Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT; - PlacedFootprint = Footprint; - } - CD3DX12_TEXTURE_COPY_LOCATION(_In_ ID3D12Resource* pRes, UINT Sub) noexcept - { - pResource = pRes; - Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX; - PlacedFootprint = {}; - SubresourceIndex = Sub; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_DESCRIPTOR_RANGE : public D3D12_DESCRIPTOR_RANGE -{ - CD3DX12_DESCRIPTOR_RANGE() = default; - explicit CD3DX12_DESCRIPTOR_RANGE(const D3D12_DESCRIPTOR_RANGE &o) noexcept : - D3D12_DESCRIPTOR_RANGE(o) - {} - CD3DX12_DESCRIPTOR_RANGE( - D3D12_DESCRIPTOR_RANGE_TYPE rangeType, - UINT numDescriptors, - UINT baseShaderRegister, - UINT registerSpace = 0, - UINT offsetInDescriptorsFromTableStart = - D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) noexcept - { - Init(rangeType, numDescriptors, baseShaderRegister, registerSpace, offsetInDescriptorsFromTableStart); - } - - inline void Init( - D3D12_DESCRIPTOR_RANGE_TYPE rangeType, - UINT numDescriptors, - UINT baseShaderRegister, - UINT registerSpace = 0, - UINT offsetInDescriptorsFromTableStart = - D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) noexcept - { - Init(*this, rangeType, numDescriptors, baseShaderRegister, registerSpace, offsetInDescriptorsFromTableStart); - } - - static inline void Init( - _Out_ D3D12_DESCRIPTOR_RANGE &range, - D3D12_DESCRIPTOR_RANGE_TYPE rangeType, - UINT numDescriptors, - UINT baseShaderRegister, - UINT registerSpace = 0, - UINT offsetInDescriptorsFromTableStart = - D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) noexcept - { - range.RangeType = rangeType; - range.NumDescriptors = numDescriptors; - range.BaseShaderRegister = baseShaderRegister; - range.RegisterSpace = registerSpace; - range.OffsetInDescriptorsFromTableStart = offsetInDescriptorsFromTableStart; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_ROOT_DESCRIPTOR_TABLE : public D3D12_ROOT_DESCRIPTOR_TABLE -{ - CD3DX12_ROOT_DESCRIPTOR_TABLE() = default; - explicit CD3DX12_ROOT_DESCRIPTOR_TABLE(const D3D12_ROOT_DESCRIPTOR_TABLE &o) noexcept : - D3D12_ROOT_DESCRIPTOR_TABLE(o) - {} - CD3DX12_ROOT_DESCRIPTOR_TABLE( - UINT numDescriptorRanges, - _In_reads_opt_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE* _pDescriptorRanges) noexcept - { - Init(numDescriptorRanges, _pDescriptorRanges); - } - - inline void Init( - UINT numDescriptorRanges, - _In_reads_opt_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE* _pDescriptorRanges) noexcept - { - Init(*this, numDescriptorRanges, _pDescriptorRanges); - } - - static inline void Init( - _Out_ D3D12_ROOT_DESCRIPTOR_TABLE &rootDescriptorTable, - UINT numDescriptorRanges, - _In_reads_opt_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE* _pDescriptorRanges) noexcept - { - rootDescriptorTable.NumDescriptorRanges = numDescriptorRanges; - rootDescriptorTable.pDescriptorRanges = _pDescriptorRanges; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_ROOT_CONSTANTS : public D3D12_ROOT_CONSTANTS -{ - CD3DX12_ROOT_CONSTANTS() = default; - explicit CD3DX12_ROOT_CONSTANTS(const D3D12_ROOT_CONSTANTS &o) noexcept : - D3D12_ROOT_CONSTANTS(o) - {} - CD3DX12_ROOT_CONSTANTS( - UINT num32BitValues, - UINT shaderRegister, - UINT registerSpace = 0) noexcept - { - Init(num32BitValues, shaderRegister, registerSpace); - } - - inline void Init( - UINT num32BitValues, - UINT shaderRegister, - UINT registerSpace = 0) noexcept - { - Init(*this, num32BitValues, shaderRegister, registerSpace); - } - - static inline void Init( - _Out_ D3D12_ROOT_CONSTANTS &rootConstants, - UINT num32BitValues, - UINT shaderRegister, - UINT registerSpace = 0) noexcept - { - rootConstants.Num32BitValues = num32BitValues; - rootConstants.ShaderRegister = shaderRegister; - rootConstants.RegisterSpace = registerSpace; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_ROOT_DESCRIPTOR : public D3D12_ROOT_DESCRIPTOR -{ - CD3DX12_ROOT_DESCRIPTOR() = default; - explicit CD3DX12_ROOT_DESCRIPTOR(const D3D12_ROOT_DESCRIPTOR &o) noexcept : - D3D12_ROOT_DESCRIPTOR(o) - {} - CD3DX12_ROOT_DESCRIPTOR( - UINT shaderRegister, - UINT registerSpace = 0) noexcept - { - Init(shaderRegister, registerSpace); - } - - inline void Init( - UINT shaderRegister, - UINT registerSpace = 0) noexcept - { - Init(*this, shaderRegister, registerSpace); - } - - static inline void Init(_Out_ D3D12_ROOT_DESCRIPTOR &table, UINT shaderRegister, UINT registerSpace = 0) noexcept - { - table.ShaderRegister = shaderRegister; - table.RegisterSpace = registerSpace; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_ROOT_PARAMETER : public D3D12_ROOT_PARAMETER -{ - CD3DX12_ROOT_PARAMETER() = default; - explicit CD3DX12_ROOT_PARAMETER(const D3D12_ROOT_PARAMETER &o) noexcept : - D3D12_ROOT_PARAMETER(o) - {} - - static inline void InitAsDescriptorTable( - _Out_ D3D12_ROOT_PARAMETER &rootParam, - UINT numDescriptorRanges, - _In_reads_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE* pDescriptorRanges, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; - rootParam.ShaderVisibility = visibility; - CD3DX12_ROOT_DESCRIPTOR_TABLE::Init(rootParam.DescriptorTable, numDescriptorRanges, pDescriptorRanges); - } - - static inline void InitAsConstants( - _Out_ D3D12_ROOT_PARAMETER &rootParam, - UINT num32BitValues, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS; - rootParam.ShaderVisibility = visibility; - CD3DX12_ROOT_CONSTANTS::Init(rootParam.Constants, num32BitValues, shaderRegister, registerSpace); - } - - static inline void InitAsConstantBufferView( - _Out_ D3D12_ROOT_PARAMETER &rootParam, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; - rootParam.ShaderVisibility = visibility; - CD3DX12_ROOT_DESCRIPTOR::Init(rootParam.Descriptor, shaderRegister, registerSpace); - } - - static inline void InitAsShaderResourceView( - _Out_ D3D12_ROOT_PARAMETER &rootParam, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_SRV; - rootParam.ShaderVisibility = visibility; - CD3DX12_ROOT_DESCRIPTOR::Init(rootParam.Descriptor, shaderRegister, registerSpace); - } - - static inline void InitAsUnorderedAccessView( - _Out_ D3D12_ROOT_PARAMETER &rootParam, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_UAV; - rootParam.ShaderVisibility = visibility; - CD3DX12_ROOT_DESCRIPTOR::Init(rootParam.Descriptor, shaderRegister, registerSpace); - } - - inline void InitAsDescriptorTable( - UINT numDescriptorRanges, - _In_reads_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE* pDescriptorRanges, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - InitAsDescriptorTable(*this, numDescriptorRanges, pDescriptorRanges, visibility); - } - - inline void InitAsConstants( - UINT num32BitValues, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - InitAsConstants(*this, num32BitValues, shaderRegister, registerSpace, visibility); - } - - inline void InitAsConstantBufferView( - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - InitAsConstantBufferView(*this, shaderRegister, registerSpace, visibility); - } - - inline void InitAsShaderResourceView( - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - InitAsShaderResourceView(*this, shaderRegister, registerSpace, visibility); - } - - inline void InitAsUnorderedAccessView( - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - InitAsUnorderedAccessView(*this, shaderRegister, registerSpace, visibility); - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_STATIC_SAMPLER_DESC : public D3D12_STATIC_SAMPLER_DESC -{ - CD3DX12_STATIC_SAMPLER_DESC() = default; - explicit CD3DX12_STATIC_SAMPLER_DESC(const D3D12_STATIC_SAMPLER_DESC &o) noexcept : - D3D12_STATIC_SAMPLER_DESC(o) - {} - CD3DX12_STATIC_SAMPLER_DESC( - UINT shaderRegister, - D3D12_FILTER filter = D3D12_FILTER_ANISOTROPIC, - D3D12_TEXTURE_ADDRESS_MODE addressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP, - D3D12_TEXTURE_ADDRESS_MODE addressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP, - D3D12_TEXTURE_ADDRESS_MODE addressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP, - FLOAT mipLODBias = 0, - UINT maxAnisotropy = 16, - D3D12_COMPARISON_FUNC comparisonFunc = D3D12_COMPARISON_FUNC_LESS_EQUAL, - D3D12_STATIC_BORDER_COLOR borderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE, - FLOAT minLOD = 0.f, - FLOAT maxLOD = D3D12_FLOAT32_MAX, - D3D12_SHADER_VISIBILITY shaderVisibility = D3D12_SHADER_VISIBILITY_ALL, - UINT registerSpace = 0) noexcept - { - Init( - shaderRegister, - filter, - addressU, - addressV, - addressW, - mipLODBias, - maxAnisotropy, - comparisonFunc, - borderColor, - minLOD, - maxLOD, - shaderVisibility, - registerSpace); - } - - static inline void Init( - _Out_ D3D12_STATIC_SAMPLER_DESC &samplerDesc, - UINT shaderRegister, - D3D12_FILTER filter = D3D12_FILTER_ANISOTROPIC, - D3D12_TEXTURE_ADDRESS_MODE addressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP, - D3D12_TEXTURE_ADDRESS_MODE addressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP, - D3D12_TEXTURE_ADDRESS_MODE addressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP, - FLOAT mipLODBias = 0, - UINT maxAnisotropy = 16, - D3D12_COMPARISON_FUNC comparisonFunc = D3D12_COMPARISON_FUNC_LESS_EQUAL, - D3D12_STATIC_BORDER_COLOR borderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE, - FLOAT minLOD = 0.f, - FLOAT maxLOD = D3D12_FLOAT32_MAX, - D3D12_SHADER_VISIBILITY shaderVisibility = D3D12_SHADER_VISIBILITY_ALL, - UINT registerSpace = 0) noexcept - { - samplerDesc.ShaderRegister = shaderRegister; - samplerDesc.Filter = filter; - samplerDesc.AddressU = addressU; - samplerDesc.AddressV = addressV; - samplerDesc.AddressW = addressW; - samplerDesc.MipLODBias = mipLODBias; - samplerDesc.MaxAnisotropy = maxAnisotropy; - samplerDesc.ComparisonFunc = comparisonFunc; - samplerDesc.BorderColor = borderColor; - samplerDesc.MinLOD = minLOD; - samplerDesc.MaxLOD = maxLOD; - samplerDesc.ShaderVisibility = shaderVisibility; - samplerDesc.RegisterSpace = registerSpace; - } - inline void Init( - UINT shaderRegister, - D3D12_FILTER filter = D3D12_FILTER_ANISOTROPIC, - D3D12_TEXTURE_ADDRESS_MODE addressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP, - D3D12_TEXTURE_ADDRESS_MODE addressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP, - D3D12_TEXTURE_ADDRESS_MODE addressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP, - FLOAT mipLODBias = 0, - UINT maxAnisotropy = 16, - D3D12_COMPARISON_FUNC comparisonFunc = D3D12_COMPARISON_FUNC_LESS_EQUAL, - D3D12_STATIC_BORDER_COLOR borderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE, - FLOAT minLOD = 0.f, - FLOAT maxLOD = D3D12_FLOAT32_MAX, - D3D12_SHADER_VISIBILITY shaderVisibility = D3D12_SHADER_VISIBILITY_ALL, - UINT registerSpace = 0) noexcept - { - Init( - *this, - shaderRegister, - filter, - addressU, - addressV, - addressW, - mipLODBias, - maxAnisotropy, - comparisonFunc, - borderColor, - minLOD, - maxLOD, - shaderVisibility, - registerSpace); - } - -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_ROOT_SIGNATURE_DESC : public D3D12_ROOT_SIGNATURE_DESC -{ - CD3DX12_ROOT_SIGNATURE_DESC() = default; - explicit CD3DX12_ROOT_SIGNATURE_DESC(const D3D12_ROOT_SIGNATURE_DESC &o) noexcept : - D3D12_ROOT_SIGNATURE_DESC(o) - {} - CD3DX12_ROOT_SIGNATURE_DESC( - UINT numParameters, - _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters, - UINT numStaticSamplers = 0, - _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, - D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept - { - Init(numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags); - } - CD3DX12_ROOT_SIGNATURE_DESC(CD3DX12_DEFAULT) noexcept - { - Init(0, nullptr, 0, nullptr, D3D12_ROOT_SIGNATURE_FLAG_NONE); - } - - inline void Init( - UINT numParameters, - _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters, - UINT numStaticSamplers = 0, - _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, - D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept - { - Init(*this, numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags); - } - - static inline void Init( - _Out_ D3D12_ROOT_SIGNATURE_DESC &desc, - UINT numParameters, - _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters, - UINT numStaticSamplers = 0, - _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, - D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept - { - desc.NumParameters = numParameters; - desc.pParameters = _pParameters; - desc.NumStaticSamplers = numStaticSamplers; - desc.pStaticSamplers = _pStaticSamplers; - desc.Flags = flags; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_DESCRIPTOR_RANGE1 : public D3D12_DESCRIPTOR_RANGE1 -{ - CD3DX12_DESCRIPTOR_RANGE1() = default; - explicit CD3DX12_DESCRIPTOR_RANGE1(const D3D12_DESCRIPTOR_RANGE1 &o) noexcept : - D3D12_DESCRIPTOR_RANGE1(o) - {} - CD3DX12_DESCRIPTOR_RANGE1( - D3D12_DESCRIPTOR_RANGE_TYPE rangeType, - UINT numDescriptors, - UINT baseShaderRegister, - UINT registerSpace = 0, - D3D12_DESCRIPTOR_RANGE_FLAGS flags = D3D12_DESCRIPTOR_RANGE_FLAG_NONE, - UINT offsetInDescriptorsFromTableStart = - D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) noexcept - { - Init(rangeType, numDescriptors, baseShaderRegister, registerSpace, flags, offsetInDescriptorsFromTableStart); - } - - inline void Init( - D3D12_DESCRIPTOR_RANGE_TYPE rangeType, - UINT numDescriptors, - UINT baseShaderRegister, - UINT registerSpace = 0, - D3D12_DESCRIPTOR_RANGE_FLAGS flags = D3D12_DESCRIPTOR_RANGE_FLAG_NONE, - UINT offsetInDescriptorsFromTableStart = - D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) noexcept - { - Init(*this, rangeType, numDescriptors, baseShaderRegister, registerSpace, flags, offsetInDescriptorsFromTableStart); - } - - static inline void Init( - _Out_ D3D12_DESCRIPTOR_RANGE1 &range, - D3D12_DESCRIPTOR_RANGE_TYPE rangeType, - UINT numDescriptors, - UINT baseShaderRegister, - UINT registerSpace = 0, - D3D12_DESCRIPTOR_RANGE_FLAGS flags = D3D12_DESCRIPTOR_RANGE_FLAG_NONE, - UINT offsetInDescriptorsFromTableStart = - D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) noexcept - { - range.RangeType = rangeType; - range.NumDescriptors = numDescriptors; - range.BaseShaderRegister = baseShaderRegister; - range.RegisterSpace = registerSpace; - range.Flags = flags; - range.OffsetInDescriptorsFromTableStart = offsetInDescriptorsFromTableStart; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_ROOT_DESCRIPTOR_TABLE1 : public D3D12_ROOT_DESCRIPTOR_TABLE1 -{ - CD3DX12_ROOT_DESCRIPTOR_TABLE1() = default; - explicit CD3DX12_ROOT_DESCRIPTOR_TABLE1(const D3D12_ROOT_DESCRIPTOR_TABLE1 &o) noexcept : - D3D12_ROOT_DESCRIPTOR_TABLE1(o) - {} - CD3DX12_ROOT_DESCRIPTOR_TABLE1( - UINT numDescriptorRanges, - _In_reads_opt_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE1* _pDescriptorRanges) noexcept - { - Init(numDescriptorRanges, _pDescriptorRanges); - } - - inline void Init( - UINT numDescriptorRanges, - _In_reads_opt_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE1* _pDescriptorRanges) noexcept - { - Init(*this, numDescriptorRanges, _pDescriptorRanges); - } - - static inline void Init( - _Out_ D3D12_ROOT_DESCRIPTOR_TABLE1 &rootDescriptorTable, - UINT numDescriptorRanges, - _In_reads_opt_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE1* _pDescriptorRanges) noexcept - { - rootDescriptorTable.NumDescriptorRanges = numDescriptorRanges; - rootDescriptorTable.pDescriptorRanges = _pDescriptorRanges; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_ROOT_DESCRIPTOR1 : public D3D12_ROOT_DESCRIPTOR1 -{ - CD3DX12_ROOT_DESCRIPTOR1() = default; - explicit CD3DX12_ROOT_DESCRIPTOR1(const D3D12_ROOT_DESCRIPTOR1 &o) noexcept : - D3D12_ROOT_DESCRIPTOR1(o) - {} - CD3DX12_ROOT_DESCRIPTOR1( - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE) noexcept - { - Init(shaderRegister, registerSpace, flags); - } - - inline void Init( - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE) noexcept - { - Init(*this, shaderRegister, registerSpace, flags); - } - - static inline void Init( - _Out_ D3D12_ROOT_DESCRIPTOR1 &table, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE) noexcept - { - table.ShaderRegister = shaderRegister; - table.RegisterSpace = registerSpace; - table.Flags = flags; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_ROOT_PARAMETER1 : public D3D12_ROOT_PARAMETER1 -{ - CD3DX12_ROOT_PARAMETER1() = default; - explicit CD3DX12_ROOT_PARAMETER1(const D3D12_ROOT_PARAMETER1 &o) noexcept : - D3D12_ROOT_PARAMETER1(o) - {} - - static inline void InitAsDescriptorTable( - _Out_ D3D12_ROOT_PARAMETER1 &rootParam, - UINT numDescriptorRanges, - _In_reads_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE1* pDescriptorRanges, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; - rootParam.ShaderVisibility = visibility; - CD3DX12_ROOT_DESCRIPTOR_TABLE1::Init(rootParam.DescriptorTable, numDescriptorRanges, pDescriptorRanges); - } - - static inline void InitAsConstants( - _Out_ D3D12_ROOT_PARAMETER1 &rootParam, - UINT num32BitValues, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS; - rootParam.ShaderVisibility = visibility; - CD3DX12_ROOT_CONSTANTS::Init(rootParam.Constants, num32BitValues, shaderRegister, registerSpace); - } - - static inline void InitAsConstantBufferView( - _Out_ D3D12_ROOT_PARAMETER1 &rootParam, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; - rootParam.ShaderVisibility = visibility; - CD3DX12_ROOT_DESCRIPTOR1::Init(rootParam.Descriptor, shaderRegister, registerSpace, flags); - } - - static inline void InitAsShaderResourceView( - _Out_ D3D12_ROOT_PARAMETER1 &rootParam, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_SRV; - rootParam.ShaderVisibility = visibility; - CD3DX12_ROOT_DESCRIPTOR1::Init(rootParam.Descriptor, shaderRegister, registerSpace, flags); - } - - static inline void InitAsUnorderedAccessView( - _Out_ D3D12_ROOT_PARAMETER1 &rootParam, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - rootParam.ParameterType = D3D12_ROOT_PARAMETER_TYPE_UAV; - rootParam.ShaderVisibility = visibility; - CD3DX12_ROOT_DESCRIPTOR1::Init(rootParam.Descriptor, shaderRegister, registerSpace, flags); - } - - inline void InitAsDescriptorTable( - UINT numDescriptorRanges, - _In_reads_(numDescriptorRanges) const D3D12_DESCRIPTOR_RANGE1* pDescriptorRanges, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - InitAsDescriptorTable(*this, numDescriptorRanges, pDescriptorRanges, visibility); - } - - inline void InitAsConstants( - UINT num32BitValues, - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - InitAsConstants(*this, num32BitValues, shaderRegister, registerSpace, visibility); - } - - inline void InitAsConstantBufferView( - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - InitAsConstantBufferView(*this, shaderRegister, registerSpace, flags, visibility); - } - - inline void InitAsShaderResourceView( - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - InitAsShaderResourceView(*this, shaderRegister, registerSpace, flags, visibility); - } - - inline void InitAsUnorderedAccessView( - UINT shaderRegister, - UINT registerSpace = 0, - D3D12_ROOT_DESCRIPTOR_FLAGS flags = D3D12_ROOT_DESCRIPTOR_FLAG_NONE, - D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL) noexcept - { - InitAsUnorderedAccessView(*this, shaderRegister, registerSpace, flags, visibility); - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC : public D3D12_VERSIONED_ROOT_SIGNATURE_DESC -{ - CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC() = default; - explicit CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC &o) noexcept : - D3D12_VERSIONED_ROOT_SIGNATURE_DESC(o) - {} - explicit CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC(const D3D12_ROOT_SIGNATURE_DESC &o) noexcept - { - Version = D3D_ROOT_SIGNATURE_VERSION_1_0; - Desc_1_0 = o; - } - explicit CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC(const D3D12_ROOT_SIGNATURE_DESC1 &o) noexcept - { - Version = D3D_ROOT_SIGNATURE_VERSION_1_1; - Desc_1_1 = o; - } - CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC( - UINT numParameters, - _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters, - UINT numStaticSamplers = 0, - _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, - D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept - { - Init_1_0(numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags); - } - CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC( - UINT numParameters, - _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER1* _pParameters, - UINT numStaticSamplers = 0, - _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, - D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept - { - Init_1_1(numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags); - } - CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC(CD3DX12_DEFAULT) noexcept - { - Init_1_1(0, nullptr, 0, nullptr, D3D12_ROOT_SIGNATURE_FLAG_NONE); - } - - inline void Init_1_0( - UINT numParameters, - _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters, - UINT numStaticSamplers = 0, - _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, - D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept - { - Init_1_0(*this, numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags); - } - - static inline void Init_1_0( - _Out_ D3D12_VERSIONED_ROOT_SIGNATURE_DESC &desc, - UINT numParameters, - _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER* _pParameters, - UINT numStaticSamplers = 0, - _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, - D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept - { - desc.Version = D3D_ROOT_SIGNATURE_VERSION_1_0; - desc.Desc_1_0.NumParameters = numParameters; - desc.Desc_1_0.pParameters = _pParameters; - desc.Desc_1_0.NumStaticSamplers = numStaticSamplers; - desc.Desc_1_0.pStaticSamplers = _pStaticSamplers; - desc.Desc_1_0.Flags = flags; - } - - inline void Init_1_1( - UINT numParameters, - _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER1* _pParameters, - UINT numStaticSamplers = 0, - _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, - D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept - { - Init_1_1(*this, numParameters, _pParameters, numStaticSamplers, _pStaticSamplers, flags); - } - - static inline void Init_1_1( - _Out_ D3D12_VERSIONED_ROOT_SIGNATURE_DESC &desc, - UINT numParameters, - _In_reads_opt_(numParameters) const D3D12_ROOT_PARAMETER1* _pParameters, - UINT numStaticSamplers = 0, - _In_reads_opt_(numStaticSamplers) const D3D12_STATIC_SAMPLER_DESC* _pStaticSamplers = nullptr, - D3D12_ROOT_SIGNATURE_FLAGS flags = D3D12_ROOT_SIGNATURE_FLAG_NONE) noexcept - { - desc.Version = D3D_ROOT_SIGNATURE_VERSION_1_1; - desc.Desc_1_1.NumParameters = numParameters; - desc.Desc_1_1.pParameters = _pParameters; - desc.Desc_1_1.NumStaticSamplers = numStaticSamplers; - desc.Desc_1_1.pStaticSamplers = _pStaticSamplers; - desc.Desc_1_1.Flags = flags; - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_CPU_DESCRIPTOR_HANDLE : public D3D12_CPU_DESCRIPTOR_HANDLE -{ - CD3DX12_CPU_DESCRIPTOR_HANDLE() = default; - explicit CD3DX12_CPU_DESCRIPTOR_HANDLE(const D3D12_CPU_DESCRIPTOR_HANDLE &o) noexcept : - D3D12_CPU_DESCRIPTOR_HANDLE(o) - {} - CD3DX12_CPU_DESCRIPTOR_HANDLE(CD3DX12_DEFAULT) noexcept { ptr = 0; } - CD3DX12_CPU_DESCRIPTOR_HANDLE(_In_ const D3D12_CPU_DESCRIPTOR_HANDLE &other, INT offsetScaledByIncrementSize) noexcept - { - InitOffsetted(other, offsetScaledByIncrementSize); - } - CD3DX12_CPU_DESCRIPTOR_HANDLE(_In_ const D3D12_CPU_DESCRIPTOR_HANDLE &other, INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept - { - InitOffsetted(other, offsetInDescriptors, descriptorIncrementSize); - } - CD3DX12_CPU_DESCRIPTOR_HANDLE& Offset(INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept - { - ptr = SIZE_T(INT64(ptr) + INT64(offsetInDescriptors) * INT64(descriptorIncrementSize)); - return *this; - } - CD3DX12_CPU_DESCRIPTOR_HANDLE& Offset(INT offsetScaledByIncrementSize) noexcept - { - ptr = SIZE_T(INT64(ptr) + INT64(offsetScaledByIncrementSize)); - return *this; - } - bool operator==(_In_ const D3D12_CPU_DESCRIPTOR_HANDLE& other) const noexcept - { - return (ptr == other.ptr); - } - bool operator!=(_In_ const D3D12_CPU_DESCRIPTOR_HANDLE& other) const noexcept - { - return (ptr != other.ptr); - } - CD3DX12_CPU_DESCRIPTOR_HANDLE &operator=(const D3D12_CPU_DESCRIPTOR_HANDLE &other) noexcept - { - ptr = other.ptr; - return *this; - } - - inline void InitOffsetted(_In_ const D3D12_CPU_DESCRIPTOR_HANDLE &base, INT offsetScaledByIncrementSize) noexcept - { - InitOffsetted(*this, base, offsetScaledByIncrementSize); - } - - inline void InitOffsetted(_In_ const D3D12_CPU_DESCRIPTOR_HANDLE &base, INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept - { - InitOffsetted(*this, base, offsetInDescriptors, descriptorIncrementSize); - } - - static inline void InitOffsetted(_Out_ D3D12_CPU_DESCRIPTOR_HANDLE &handle, _In_ const D3D12_CPU_DESCRIPTOR_HANDLE &base, INT offsetScaledByIncrementSize) noexcept - { - handle.ptr = SIZE_T(INT64(base.ptr) + INT64(offsetScaledByIncrementSize)); - } - - static inline void InitOffsetted(_Out_ D3D12_CPU_DESCRIPTOR_HANDLE &handle, _In_ const D3D12_CPU_DESCRIPTOR_HANDLE &base, INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept - { - handle.ptr = SIZE_T(INT64(base.ptr) + INT64(offsetInDescriptors) * INT64(descriptorIncrementSize)); - } -}; - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_GPU_DESCRIPTOR_HANDLE : public D3D12_GPU_DESCRIPTOR_HANDLE -{ - CD3DX12_GPU_DESCRIPTOR_HANDLE() = default; - explicit CD3DX12_GPU_DESCRIPTOR_HANDLE(const D3D12_GPU_DESCRIPTOR_HANDLE &o) noexcept : - D3D12_GPU_DESCRIPTOR_HANDLE(o) - {} - CD3DX12_GPU_DESCRIPTOR_HANDLE(CD3DX12_DEFAULT) noexcept { ptr = 0; } - CD3DX12_GPU_DESCRIPTOR_HANDLE(_In_ const D3D12_GPU_DESCRIPTOR_HANDLE &other, INT offsetScaledByIncrementSize) noexcept - { - InitOffsetted(other, offsetScaledByIncrementSize); - } - CD3DX12_GPU_DESCRIPTOR_HANDLE(_In_ const D3D12_GPU_DESCRIPTOR_HANDLE &other, INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept - { - InitOffsetted(other, offsetInDescriptors, descriptorIncrementSize); - } - CD3DX12_GPU_DESCRIPTOR_HANDLE& Offset(INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept - { - ptr = UINT64(INT64(ptr) + INT64(offsetInDescriptors) * INT64(descriptorIncrementSize)); - return *this; - } - CD3DX12_GPU_DESCRIPTOR_HANDLE& Offset(INT offsetScaledByIncrementSize) noexcept - { - ptr = UINT64(INT64(ptr) + INT64(offsetScaledByIncrementSize)); - return *this; - } - inline bool operator==(_In_ const D3D12_GPU_DESCRIPTOR_HANDLE& other) const noexcept - { - return (ptr == other.ptr); - } - inline bool operator!=(_In_ const D3D12_GPU_DESCRIPTOR_HANDLE& other) const noexcept - { - return (ptr != other.ptr); - } - CD3DX12_GPU_DESCRIPTOR_HANDLE &operator=(const D3D12_GPU_DESCRIPTOR_HANDLE &other) noexcept - { - ptr = other.ptr; - return *this; - } - - inline void InitOffsetted(_In_ const D3D12_GPU_DESCRIPTOR_HANDLE &base, INT offsetScaledByIncrementSize) noexcept - { - InitOffsetted(*this, base, offsetScaledByIncrementSize); - } - - inline void InitOffsetted(_In_ const D3D12_GPU_DESCRIPTOR_HANDLE &base, INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept - { - InitOffsetted(*this, base, offsetInDescriptors, descriptorIncrementSize); - } - - static inline void InitOffsetted(_Out_ D3D12_GPU_DESCRIPTOR_HANDLE &handle, _In_ const D3D12_GPU_DESCRIPTOR_HANDLE &base, INT offsetScaledByIncrementSize) noexcept - { - handle.ptr = UINT64(INT64(base.ptr) + INT64(offsetScaledByIncrementSize)); - } - - static inline void InitOffsetted(_Out_ D3D12_GPU_DESCRIPTOR_HANDLE &handle, _In_ const D3D12_GPU_DESCRIPTOR_HANDLE &base, INT offsetInDescriptors, UINT descriptorIncrementSize) noexcept - { - handle.ptr = UINT64(INT64(base.ptr) + INT64(offsetInDescriptors) * INT64(descriptorIncrementSize)); - } -}; - -//------------------------------------------------------------------------------------------------ -constexpr UINT D3D12CalcSubresource( UINT MipSlice, UINT ArraySlice, UINT PlaneSlice, UINT MipLevels, UINT ArraySize ) noexcept -{ - return MipSlice + ArraySlice * MipLevels + PlaneSlice * MipLevels * ArraySize; -} - -//------------------------------------------------------------------------------------------------ -template -inline void D3D12DecomposeSubresource( UINT Subresource, UINT MipLevels, UINT ArraySize, _Out_ T& MipSlice, _Out_ U& ArraySlice, _Out_ V& PlaneSlice ) noexcept -{ - MipSlice = static_cast(Subresource % MipLevels); - ArraySlice = static_cast((Subresource / MipLevels) % ArraySize); - PlaneSlice = static_cast(Subresource / (MipLevels * ArraySize)); -} - -//------------------------------------------------------------------------------------------------ -inline UINT8 D3D12GetFormatPlaneCount( - _In_ ID3D12Device* pDevice, - DXGI_FORMAT Format - ) noexcept -{ - D3D12_FEATURE_DATA_FORMAT_INFO formatInfo = { Format, 0 }; - if (FAILED(pDevice->CheckFeatureSupport(D3D12_FEATURE_FORMAT_INFO, &formatInfo, sizeof(formatInfo)))) - { - return 0; - } - return formatInfo.PlaneCount; -} - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_RESOURCE_DESC : public D3D12_RESOURCE_DESC -{ - CD3DX12_RESOURCE_DESC() = default; - explicit CD3DX12_RESOURCE_DESC( const D3D12_RESOURCE_DESC& o ) noexcept : - D3D12_RESOURCE_DESC( o ) - {} - CD3DX12_RESOURCE_DESC( - D3D12_RESOURCE_DIMENSION dimension, - UINT64 alignment, - UINT64 width, - UINT height, - UINT16 depthOrArraySize, - UINT16 mipLevels, - DXGI_FORMAT format, - UINT sampleCount, - UINT sampleQuality, - D3D12_TEXTURE_LAYOUT layout, - D3D12_RESOURCE_FLAGS flags ) noexcept - { - Dimension = dimension; - Alignment = alignment; - Width = width; - Height = height; - DepthOrArraySize = depthOrArraySize; - MipLevels = mipLevels; - Format = format; - SampleDesc.Count = sampleCount; - SampleDesc.Quality = sampleQuality; - Layout = layout; - Flags = flags; - } - static inline CD3DX12_RESOURCE_DESC Buffer( - const D3D12_RESOURCE_ALLOCATION_INFO& resAllocInfo, - D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE ) noexcept - { - return CD3DX12_RESOURCE_DESC( D3D12_RESOURCE_DIMENSION_BUFFER, resAllocInfo.Alignment, resAllocInfo.SizeInBytes, - 1, 1, 1, DXGI_FORMAT_UNKNOWN, 1, 0, D3D12_TEXTURE_LAYOUT_ROW_MAJOR, flags ); - } - static inline CD3DX12_RESOURCE_DESC Buffer( - UINT64 width, - D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, - UINT64 alignment = 0 ) noexcept - { - return CD3DX12_RESOURCE_DESC( D3D12_RESOURCE_DIMENSION_BUFFER, alignment, width, 1, 1, 1, - DXGI_FORMAT_UNKNOWN, 1, 0, D3D12_TEXTURE_LAYOUT_ROW_MAJOR, flags ); - } - static inline CD3DX12_RESOURCE_DESC Tex1D( - DXGI_FORMAT format, - UINT64 width, - UINT16 arraySize = 1, - UINT16 mipLevels = 0, - D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, - D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, - UINT64 alignment = 0 ) noexcept - { - return CD3DX12_RESOURCE_DESC( D3D12_RESOURCE_DIMENSION_TEXTURE1D, alignment, width, 1, arraySize, - mipLevels, format, 1, 0, layout, flags ); - } - static inline CD3DX12_RESOURCE_DESC Tex2D( - DXGI_FORMAT format, - UINT64 width, - UINT height, - UINT16 arraySize = 1, - UINT16 mipLevels = 0, - UINT sampleCount = 1, - UINT sampleQuality = 0, - D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, - D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, - UINT64 alignment = 0 ) noexcept - { - return CD3DX12_RESOURCE_DESC( D3D12_RESOURCE_DIMENSION_TEXTURE2D, alignment, width, height, arraySize, - mipLevels, format, sampleCount, sampleQuality, layout, flags ); - } - static inline CD3DX12_RESOURCE_DESC Tex3D( - DXGI_FORMAT format, - UINT64 width, - UINT height, - UINT16 depth, - UINT16 mipLevels = 0, - D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, - D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, - UINT64 alignment = 0 ) noexcept - { - return CD3DX12_RESOURCE_DESC( D3D12_RESOURCE_DIMENSION_TEXTURE3D, alignment, width, height, depth, - mipLevels, format, 1, 0, layout, flags ); - } - inline UINT16 Depth() const noexcept - { return (Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D ? DepthOrArraySize : 1u); } - inline UINT16 ArraySize() const noexcept - { return (Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE3D ? DepthOrArraySize : 1u); } - inline UINT8 PlaneCount(_In_ ID3D12Device* pDevice) const noexcept - { return D3D12GetFormatPlaneCount(pDevice, Format); } - inline UINT Subresources(_In_ ID3D12Device* pDevice) const noexcept - { return static_cast(MipLevels) * ArraySize() * PlaneCount(pDevice); } - inline UINT CalcSubresource(UINT MipSlice, UINT ArraySlice, UINT PlaneSlice) noexcept - { return D3D12CalcSubresource(MipSlice, ArraySlice, PlaneSlice, MipLevels, ArraySize()); } -}; -inline bool operator==( const D3D12_RESOURCE_DESC& l, const D3D12_RESOURCE_DESC& r ) noexcept -{ - return l.Dimension == r.Dimension && - l.Alignment == r.Alignment && - l.Width == r.Width && - l.Height == r.Height && - l.DepthOrArraySize == r.DepthOrArraySize && - l.MipLevels == r.MipLevels && - l.Format == r.Format && - l.SampleDesc.Count == r.SampleDesc.Count && - l.SampleDesc.Quality == r.SampleDesc.Quality && - l.Layout == r.Layout && - l.Flags == r.Flags; -} -inline bool operator!=( const D3D12_RESOURCE_DESC& l, const D3D12_RESOURCE_DESC& r ) noexcept -{ return !( l == r ); } - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_RESOURCE_DESC1 : public D3D12_RESOURCE_DESC1 -{ - CD3DX12_RESOURCE_DESC1() = default; - explicit CD3DX12_RESOURCE_DESC1( const D3D12_RESOURCE_DESC1& o ) noexcept : - D3D12_RESOURCE_DESC1( o ) - {} - explicit CD3DX12_RESOURCE_DESC1( const D3D12_RESOURCE_DESC& o ) noexcept - { - Dimension = o.Dimension; - Alignment = o.Alignment; - Width = o.Width; - Height = o.Height; - DepthOrArraySize = o.DepthOrArraySize; - MipLevels = o.MipLevels; - Format = o.Format; - SampleDesc = o.SampleDesc; - Layout = o.Layout; - Flags = o.Flags; - SamplerFeedbackMipRegion = {}; - } - CD3DX12_RESOURCE_DESC1( - D3D12_RESOURCE_DIMENSION dimension, - UINT64 alignment, - UINT64 width, - UINT height, - UINT16 depthOrArraySize, - UINT16 mipLevels, - DXGI_FORMAT format, - UINT sampleCount, - UINT sampleQuality, - D3D12_TEXTURE_LAYOUT layout, - D3D12_RESOURCE_FLAGS flags, - UINT samplerFeedbackMipRegionWidth = 0, - UINT samplerFeedbackMipRegionHeight = 0, - UINT samplerFeedbackMipRegionDepth = 0) noexcept - { - Dimension = dimension; - Alignment = alignment; - Width = width; - Height = height; - DepthOrArraySize = depthOrArraySize; - MipLevels = mipLevels; - Format = format; - SampleDesc.Count = sampleCount; - SampleDesc.Quality = sampleQuality; - Layout = layout; - Flags = flags; - SamplerFeedbackMipRegion.Width = samplerFeedbackMipRegionWidth; - SamplerFeedbackMipRegion.Height = samplerFeedbackMipRegionHeight; - SamplerFeedbackMipRegion.Depth = samplerFeedbackMipRegionDepth; - } - static inline CD3DX12_RESOURCE_DESC1 Buffer( - const D3D12_RESOURCE_ALLOCATION_INFO& resAllocInfo, - D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE ) noexcept - { - return CD3DX12_RESOURCE_DESC1( D3D12_RESOURCE_DIMENSION_BUFFER, resAllocInfo.Alignment, resAllocInfo.SizeInBytes, - 1, 1, 1, DXGI_FORMAT_UNKNOWN, 1, 0, D3D12_TEXTURE_LAYOUT_ROW_MAJOR, flags, 0, 0, 0 ); - } - static inline CD3DX12_RESOURCE_DESC1 Buffer( - UINT64 width, - D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, - UINT64 alignment = 0 ) noexcept - { - return CD3DX12_RESOURCE_DESC1( D3D12_RESOURCE_DIMENSION_BUFFER, alignment, width, 1, 1, 1, - DXGI_FORMAT_UNKNOWN, 1, 0, D3D12_TEXTURE_LAYOUT_ROW_MAJOR, flags, 0, 0, 0 ); - } - static inline CD3DX12_RESOURCE_DESC1 Tex1D( - DXGI_FORMAT format, - UINT64 width, - UINT16 arraySize = 1, - UINT16 mipLevels = 0, - D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, - D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, - UINT64 alignment = 0 ) noexcept - { - return CD3DX12_RESOURCE_DESC1( D3D12_RESOURCE_DIMENSION_TEXTURE1D, alignment, width, 1, arraySize, - mipLevels, format, 1, 0, layout, flags, 0, 0, 0 ); - } - static inline CD3DX12_RESOURCE_DESC1 Tex2D( - DXGI_FORMAT format, - UINT64 width, - UINT height, - UINT16 arraySize = 1, - UINT16 mipLevels = 0, - UINT sampleCount = 1, - UINT sampleQuality = 0, - D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, - D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, - UINT64 alignment = 0, - UINT samplerFeedbackMipRegionWidth = 0, - UINT samplerFeedbackMipRegionHeight = 0, - UINT samplerFeedbackMipRegionDepth = 0) noexcept - { - return CD3DX12_RESOURCE_DESC1( D3D12_RESOURCE_DIMENSION_TEXTURE2D, alignment, width, height, arraySize, - mipLevels, format, sampleCount, sampleQuality, layout, flags, samplerFeedbackMipRegionWidth, - samplerFeedbackMipRegionHeight, samplerFeedbackMipRegionDepth ); - } - static inline CD3DX12_RESOURCE_DESC1 Tex3D( - DXGI_FORMAT format, - UINT64 width, - UINT height, - UINT16 depth, - UINT16 mipLevels = 0, - D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE, - D3D12_TEXTURE_LAYOUT layout = D3D12_TEXTURE_LAYOUT_UNKNOWN, - UINT64 alignment = 0 ) noexcept - { - return CD3DX12_RESOURCE_DESC1( D3D12_RESOURCE_DIMENSION_TEXTURE3D, alignment, width, height, depth, - mipLevels, format, 1, 0, layout, flags, 0, 0, 0 ); - } - inline UINT16 Depth() const noexcept - { return (Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D ? DepthOrArraySize : 1u); } - inline UINT16 ArraySize() const noexcept - { return (Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE3D ? DepthOrArraySize : 1u); } - inline UINT8 PlaneCount(_In_ ID3D12Device* pDevice) const noexcept - { return D3D12GetFormatPlaneCount(pDevice, Format); } - inline UINT Subresources(_In_ ID3D12Device* pDevice) const noexcept - { return static_cast(MipLevels) * ArraySize() * PlaneCount(pDevice); } - inline UINT CalcSubresource(UINT MipSlice, UINT ArraySlice, UINT PlaneSlice) noexcept - { return D3D12CalcSubresource(MipSlice, ArraySlice, PlaneSlice, MipLevels, ArraySize()); } -}; -inline bool operator==( const D3D12_RESOURCE_DESC1& l, const D3D12_RESOURCE_DESC1& r ) noexcept -{ - return l.Dimension == r.Dimension && - l.Alignment == r.Alignment && - l.Width == r.Width && - l.Height == r.Height && - l.DepthOrArraySize == r.DepthOrArraySize && - l.MipLevels == r.MipLevels && - l.Format == r.Format && - l.SampleDesc.Count == r.SampleDesc.Count && - l.SampleDesc.Quality == r.SampleDesc.Quality && - l.Layout == r.Layout && - l.Flags == r.Flags && - l.SamplerFeedbackMipRegion.Width == r.SamplerFeedbackMipRegion.Width && - l.SamplerFeedbackMipRegion.Height == r.SamplerFeedbackMipRegion.Height && - l.SamplerFeedbackMipRegion.Depth == r.SamplerFeedbackMipRegion.Depth; -} -inline bool operator!=( const D3D12_RESOURCE_DESC1& l, const D3D12_RESOURCE_DESC1& r ) noexcept -{ return !( l == r ); } - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_VIEW_INSTANCING_DESC : public D3D12_VIEW_INSTANCING_DESC -{ - CD3DX12_VIEW_INSTANCING_DESC() = default; - explicit CD3DX12_VIEW_INSTANCING_DESC( const D3D12_VIEW_INSTANCING_DESC& o ) noexcept : - D3D12_VIEW_INSTANCING_DESC( o ) - {} - explicit CD3DX12_VIEW_INSTANCING_DESC( CD3DX12_DEFAULT ) noexcept - { - ViewInstanceCount = 0; - pViewInstanceLocations = nullptr; - Flags = D3D12_VIEW_INSTANCING_FLAG_NONE; - } - explicit CD3DX12_VIEW_INSTANCING_DESC( - UINT InViewInstanceCount, - const D3D12_VIEW_INSTANCE_LOCATION* InViewInstanceLocations, - D3D12_VIEW_INSTANCING_FLAGS InFlags) noexcept - { - ViewInstanceCount = InViewInstanceCount; - pViewInstanceLocations = InViewInstanceLocations; - Flags = InFlags; - } -}; - -//------------------------------------------------------------------------------------------------ -// Row-by-row memcpy -inline void MemcpySubresource( - _In_ const D3D12_MEMCPY_DEST* pDest, - _In_ const D3D12_SUBRESOURCE_DATA* pSrc, - SIZE_T RowSizeInBytes, - UINT NumRows, - UINT NumSlices) noexcept -{ - for (UINT z = 0; z < NumSlices; ++z) - { - auto pDestSlice = static_cast(pDest->pData) + pDest->SlicePitch * z; - auto pSrcSlice = static_cast(pSrc->pData) + pSrc->SlicePitch * LONG_PTR(z); - for (UINT y = 0; y < NumRows; ++y) - { - memcpy(pDestSlice + pDest->RowPitch * y, - pSrcSlice + pSrc->RowPitch * LONG_PTR(y), - RowSizeInBytes); - } - } -} - -//------------------------------------------------------------------------------------------------ -// Row-by-row memcpy -inline void MemcpySubresource( - _In_ const D3D12_MEMCPY_DEST* pDest, - _In_ const void* pResourceData, - _In_ const D3D12_SUBRESOURCE_INFO* pSrc, - SIZE_T RowSizeInBytes, - UINT NumRows, - UINT NumSlices) noexcept -{ - for (UINT z = 0; z < NumSlices; ++z) - { - auto pDestSlice = static_cast(pDest->pData) + pDest->SlicePitch * z; - auto pSrcSlice = (static_cast(pResourceData) + pSrc->Offset) + pSrc->DepthPitch * ULONG_PTR(z); - for (UINT y = 0; y < NumRows; ++y) - { - memcpy(pDestSlice + pDest->RowPitch * y, - pSrcSlice + pSrc->RowPitch * ULONG_PTR(y), - RowSizeInBytes); - } - } -} - -//------------------------------------------------------------------------------------------------ -// Returns required size of a buffer to be used for data upload -inline UINT64 GetRequiredIntermediateSize( - _In_ ID3D12Resource* pDestinationResource, - _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, - _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources) noexcept -{ - const auto Desc = pDestinationResource->GetDesc(); - UINT64 RequiredSize = 0; - - ID3D12Device* pDevice = nullptr; - pDestinationResource->GetDevice(IID_ID3D12Device, reinterpret_cast(&pDevice)); - pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, 0, nullptr, nullptr, nullptr, &RequiredSize); - pDevice->Release(); - - return RequiredSize; -} - -//------------------------------------------------------------------------------------------------ -// All arrays must be populated (e.g. by calling GetCopyableFootprints) -inline UINT64 UpdateSubresources( - _In_ ID3D12GraphicsCommandList* pCmdList, - _In_ ID3D12Resource* pDestinationResource, - _In_ ID3D12Resource* pIntermediate, - _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, - _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, - UINT64 RequiredSize, - _In_reads_(NumSubresources) const D3D12_PLACED_SUBRESOURCE_FOOTPRINT* pLayouts, - _In_reads_(NumSubresources) const UINT* pNumRows, - _In_reads_(NumSubresources) const UINT64* pRowSizesInBytes, - _In_reads_(NumSubresources) const D3D12_SUBRESOURCE_DATA* pSrcData) noexcept -{ - // Minor validation - const auto IntermediateDesc = pIntermediate->GetDesc(); - const auto DestinationDesc = pDestinationResource->GetDesc(); - if (IntermediateDesc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER || - IntermediateDesc.Width < RequiredSize + pLayouts[0].Offset || - RequiredSize > SIZE_T(-1) || - (DestinationDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER && - (FirstSubresource != 0 || NumSubresources != 1))) - { - return 0; - } - - BYTE* pData; - HRESULT hr = pIntermediate->Map(0, nullptr, reinterpret_cast(&pData)); - if (FAILED(hr)) - { - return 0; - } - - for (UINT i = 0; i < NumSubresources; ++i) - { - if (pRowSizesInBytes[i] > SIZE_T(-1)) return 0; - D3D12_MEMCPY_DEST DestData = { pData + pLayouts[i].Offset, pLayouts[i].Footprint.RowPitch, SIZE_T(pLayouts[i].Footprint.RowPitch) * SIZE_T(pNumRows[i]) }; - MemcpySubresource(&DestData, &pSrcData[i], static_cast(pRowSizesInBytes[i]), pNumRows[i], pLayouts[i].Footprint.Depth); - } - pIntermediate->Unmap(0, nullptr); - - if (DestinationDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER) - { - pCmdList->CopyBufferRegion( - pDestinationResource, 0, pIntermediate, pLayouts[0].Offset, pLayouts[0].Footprint.Width); - } - else - { - for (UINT i = 0; i < NumSubresources; ++i) - { - const CD3DX12_TEXTURE_COPY_LOCATION Dst(pDestinationResource, i + FirstSubresource); - const CD3DX12_TEXTURE_COPY_LOCATION Src(pIntermediate, pLayouts[i]); - pCmdList->CopyTextureRegion(&Dst, 0, 0, 0, &Src, nullptr); - } - } - return RequiredSize; -} - -//------------------------------------------------------------------------------------------------ -// All arrays must be populated (e.g. by calling GetCopyableFootprints) -inline UINT64 UpdateSubresources( - _In_ ID3D12GraphicsCommandList* pCmdList, - _In_ ID3D12Resource* pDestinationResource, - _In_ ID3D12Resource* pIntermediate, - _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, - _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, - UINT64 RequiredSize, - _In_reads_(NumSubresources) const D3D12_PLACED_SUBRESOURCE_FOOTPRINT* pLayouts, - _In_reads_(NumSubresources) const UINT* pNumRows, - _In_reads_(NumSubresources) const UINT64* pRowSizesInBytes, - _In_ const void* pResourceData, - _In_reads_(NumSubresources) const D3D12_SUBRESOURCE_INFO* pSrcData) noexcept -{ - // Minor validation - const auto IntermediateDesc = pIntermediate->GetDesc(); - const auto DestinationDesc = pDestinationResource->GetDesc(); - if (IntermediateDesc.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER || - IntermediateDesc.Width < RequiredSize + pLayouts[0].Offset || - RequiredSize > SIZE_T(-1) || - (DestinationDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER && - (FirstSubresource != 0 || NumSubresources != 1))) - { - return 0; - } - - BYTE* pData; - HRESULT hr = pIntermediate->Map(0, nullptr, reinterpret_cast(&pData)); - if (FAILED(hr)) - { - return 0; - } - - for (UINT i = 0; i < NumSubresources; ++i) - { - if (pRowSizesInBytes[i] > SIZE_T(-1)) return 0; - D3D12_MEMCPY_DEST DestData = { pData + pLayouts[i].Offset, pLayouts[i].Footprint.RowPitch, SIZE_T(pLayouts[i].Footprint.RowPitch) * SIZE_T(pNumRows[i]) }; - MemcpySubresource(&DestData, pResourceData, &pSrcData[i], static_cast(pRowSizesInBytes[i]), pNumRows[i], pLayouts[i].Footprint.Depth); - } - pIntermediate->Unmap(0, nullptr); - - if (DestinationDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER) - { - pCmdList->CopyBufferRegion( - pDestinationResource, 0, pIntermediate, pLayouts[0].Offset, pLayouts[0].Footprint.Width); - } - else - { - for (UINT i = 0; i < NumSubresources; ++i) - { - const CD3DX12_TEXTURE_COPY_LOCATION Dst(pDestinationResource, i + FirstSubresource); - const CD3DX12_TEXTURE_COPY_LOCATION Src(pIntermediate, pLayouts[i]); - pCmdList->CopyTextureRegion(&Dst, 0, 0, 0, &Src, nullptr); - } - } - return RequiredSize; -} - -//------------------------------------------------------------------------------------------------ -// Heap-allocating UpdateSubresources implementation -inline UINT64 UpdateSubresources( - _In_ ID3D12GraphicsCommandList* pCmdList, - _In_ ID3D12Resource* pDestinationResource, - _In_ ID3D12Resource* pIntermediate, - UINT64 IntermediateOffset, - _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, - _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, - _In_reads_(NumSubresources) const D3D12_SUBRESOURCE_DATA* pSrcData) noexcept -{ - UINT64 RequiredSize = 0; - const auto MemToAlloc = static_cast(sizeof(D3D12_PLACED_SUBRESOURCE_FOOTPRINT) + sizeof(UINT) + sizeof(UINT64)) * NumSubresources; - if (MemToAlloc > SIZE_MAX) - { - return 0; - } - void* pMem = HeapAlloc(GetProcessHeap(), 0, static_cast(MemToAlloc)); - if (pMem == nullptr) - { - return 0; - } - auto pLayouts = static_cast(pMem); - auto pRowSizesInBytes = reinterpret_cast(pLayouts + NumSubresources); - auto pNumRows = reinterpret_cast(pRowSizesInBytes + NumSubresources); - - const auto Desc = pDestinationResource->GetDesc(); - ID3D12Device* pDevice = nullptr; - pDestinationResource->GetDevice(IID_ID3D12Device, reinterpret_cast(&pDevice)); - pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, IntermediateOffset, pLayouts, pNumRows, pRowSizesInBytes, &RequiredSize); - pDevice->Release(); - - const UINT64 Result = UpdateSubresources(pCmdList, pDestinationResource, pIntermediate, FirstSubresource, NumSubresources, RequiredSize, pLayouts, pNumRows, pRowSizesInBytes, pSrcData); - HeapFree(GetProcessHeap(), 0, pMem); - return Result; -} - -//------------------------------------------------------------------------------------------------ -// Heap-allocating UpdateSubresources implementation -inline UINT64 UpdateSubresources( - _In_ ID3D12GraphicsCommandList* pCmdList, - _In_ ID3D12Resource* pDestinationResource, - _In_ ID3D12Resource* pIntermediate, - UINT64 IntermediateOffset, - _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, - _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, - _In_ const void* pResourceData, - _In_reads_(NumSubresources) const D3D12_SUBRESOURCE_INFO* pSrcData) noexcept -{ - UINT64 RequiredSize = 0; - const auto MemToAlloc = static_cast(sizeof(D3D12_PLACED_SUBRESOURCE_FOOTPRINT) + sizeof(UINT) + sizeof(UINT64)) * NumSubresources; - if (MemToAlloc > SIZE_MAX) - { - return 0; - } - void* pMem = HeapAlloc(GetProcessHeap(), 0, static_cast(MemToAlloc)); - if (pMem == nullptr) - { - return 0; - } - auto pLayouts = static_cast(pMem); - auto pRowSizesInBytes = reinterpret_cast(pLayouts + NumSubresources); - auto pNumRows = reinterpret_cast(pRowSizesInBytes + NumSubresources); - - const auto Desc = pDestinationResource->GetDesc(); - ID3D12Device* pDevice = nullptr; - pDestinationResource->GetDevice(IID_ID3D12Device, reinterpret_cast(&pDevice)); - pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, IntermediateOffset, pLayouts, pNumRows, pRowSizesInBytes, &RequiredSize); - pDevice->Release(); - - const UINT64 Result = UpdateSubresources(pCmdList, pDestinationResource, pIntermediate, FirstSubresource, NumSubresources, RequiredSize, pLayouts, pNumRows, pRowSizesInBytes, pResourceData, pSrcData); - HeapFree(GetProcessHeap(), 0, pMem); - return Result; -} - -//------------------------------------------------------------------------------------------------ -// Stack-allocating UpdateSubresources implementation -template -inline UINT64 UpdateSubresources( - _In_ ID3D12GraphicsCommandList* pCmdList, - _In_ ID3D12Resource* pDestinationResource, - _In_ ID3D12Resource* pIntermediate, - UINT64 IntermediateOffset, - _In_range_(0,MaxSubresources) UINT FirstSubresource, - _In_range_(1,MaxSubresources-FirstSubresource) UINT NumSubresources, - _In_reads_(NumSubresources) const D3D12_SUBRESOURCE_DATA* pSrcData) noexcept -{ - UINT64 RequiredSize = 0; - D3D12_PLACED_SUBRESOURCE_FOOTPRINT Layouts[MaxSubresources]; - UINT NumRows[MaxSubresources]; - UINT64 RowSizesInBytes[MaxSubresources]; - - const auto Desc = pDestinationResource->GetDesc(); - ID3D12Device* pDevice = nullptr; - pDestinationResource->GetDevice(IID_ID3D12Device, reinterpret_cast(&pDevice)); - pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, IntermediateOffset, Layouts, NumRows, RowSizesInBytes, &RequiredSize); - pDevice->Release(); - - return UpdateSubresources(pCmdList, pDestinationResource, pIntermediate, FirstSubresource, NumSubresources, RequiredSize, Layouts, NumRows, RowSizesInBytes, pSrcData); -} - -//------------------------------------------------------------------------------------------------ -// Stack-allocating UpdateSubresources implementation -template -inline UINT64 UpdateSubresources( - _In_ ID3D12GraphicsCommandList* pCmdList, - _In_ ID3D12Resource* pDestinationResource, - _In_ ID3D12Resource* pIntermediate, - UINT64 IntermediateOffset, - _In_range_(0,MaxSubresources) UINT FirstSubresource, - _In_range_(1,MaxSubresources-FirstSubresource) UINT NumSubresources, - _In_ const void* pResourceData, - _In_reads_(NumSubresources) const D3D12_SUBRESOURCE_INFO* pSrcData) noexcept -{ - UINT64 RequiredSize = 0; - D3D12_PLACED_SUBRESOURCE_FOOTPRINT Layouts[MaxSubresources]; - UINT NumRows[MaxSubresources]; - UINT64 RowSizesInBytes[MaxSubresources]; - - const auto Desc = pDestinationResource->GetDesc(); - ID3D12Device* pDevice = nullptr; - pDestinationResource->GetDevice(IID_ID3D12Device, reinterpret_cast(&pDevice)); - pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, IntermediateOffset, Layouts, NumRows, RowSizesInBytes, &RequiredSize); - pDevice->Release(); - - return UpdateSubresources(pCmdList, pDestinationResource, pIntermediate, FirstSubresource, NumSubresources, RequiredSize, Layouts, NumRows, RowSizesInBytes, pResourceData, pSrcData); -} - -//------------------------------------------------------------------------------------------------ -constexpr bool D3D12IsLayoutOpaque( D3D12_TEXTURE_LAYOUT Layout ) noexcept -{ return Layout == D3D12_TEXTURE_LAYOUT_UNKNOWN || Layout == D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE; } - -//------------------------------------------------------------------------------------------------ -template -inline ID3D12CommandList * const * CommandListCast(t_CommandListType * const * pp) noexcept -{ - // This cast is useful for passing strongly typed command list pointers into - // ExecuteCommandLists. - // This cast is valid as long as the const-ness is respected. D3D12 APIs do - // respect the const-ness of their arguments. - return reinterpret_cast(pp); -} - -//------------------------------------------------------------------------------------------------ -// D3D12 exports a new method for serializing root signatures in the Windows 10 Anniversary Update. -// To help enable root signature 1.1 features when they are available and not require maintaining -// two code paths for building root signatures, this helper method reconstructs a 1.0 signature when -// 1.1 is not supported. -inline HRESULT D3DX12SerializeVersionedRootSignature( - _In_ const D3D12_VERSIONED_ROOT_SIGNATURE_DESC* pRootSignatureDesc, - D3D_ROOT_SIGNATURE_VERSION MaxVersion, - _Outptr_ ID3DBlob** ppBlob, - _Always_(_Outptr_opt_result_maybenull_) ID3DBlob** ppErrorBlob) noexcept -{ - if (ppErrorBlob != nullptr) - { - *ppErrorBlob = nullptr; - } - - switch (MaxVersion) - { - case D3D_ROOT_SIGNATURE_VERSION_1_0: - switch (pRootSignatureDesc->Version) - { - case D3D_ROOT_SIGNATURE_VERSION_1_0: - return D3D12SerializeRootSignature(&pRootSignatureDesc->Desc_1_0, D3D_ROOT_SIGNATURE_VERSION_1, ppBlob, ppErrorBlob); - - case D3D_ROOT_SIGNATURE_VERSION_1_1: - { - HRESULT hr = S_OK; - const D3D12_ROOT_SIGNATURE_DESC1& desc_1_1 = pRootSignatureDesc->Desc_1_1; - - const SIZE_T ParametersSize = sizeof(D3D12_ROOT_PARAMETER) * desc_1_1.NumParameters; - void* pParameters = (ParametersSize > 0) ? HeapAlloc(GetProcessHeap(), 0, ParametersSize) : nullptr; - if (ParametersSize > 0 && pParameters == nullptr) - { - hr = E_OUTOFMEMORY; - } - auto pParameters_1_0 = static_cast(pParameters); - - if (SUCCEEDED(hr)) - { - for (UINT n = 0; n < desc_1_1.NumParameters; n++) - { - __analysis_assume(ParametersSize == sizeof(D3D12_ROOT_PARAMETER) * desc_1_1.NumParameters); - pParameters_1_0[n].ParameterType = desc_1_1.pParameters[n].ParameterType; - pParameters_1_0[n].ShaderVisibility = desc_1_1.pParameters[n].ShaderVisibility; - - switch (desc_1_1.pParameters[n].ParameterType) - { - case D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS: - pParameters_1_0[n].Constants.Num32BitValues = desc_1_1.pParameters[n].Constants.Num32BitValues; - pParameters_1_0[n].Constants.RegisterSpace = desc_1_1.pParameters[n].Constants.RegisterSpace; - pParameters_1_0[n].Constants.ShaderRegister = desc_1_1.pParameters[n].Constants.ShaderRegister; - break; - - case D3D12_ROOT_PARAMETER_TYPE_CBV: - case D3D12_ROOT_PARAMETER_TYPE_SRV: - case D3D12_ROOT_PARAMETER_TYPE_UAV: - pParameters_1_0[n].Descriptor.RegisterSpace = desc_1_1.pParameters[n].Descriptor.RegisterSpace; - pParameters_1_0[n].Descriptor.ShaderRegister = desc_1_1.pParameters[n].Descriptor.ShaderRegister; - break; - - case D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE: - const D3D12_ROOT_DESCRIPTOR_TABLE1& table_1_1 = desc_1_1.pParameters[n].DescriptorTable; - - const SIZE_T DescriptorRangesSize = sizeof(D3D12_DESCRIPTOR_RANGE) * table_1_1.NumDescriptorRanges; - void* pDescriptorRanges = (DescriptorRangesSize > 0 && SUCCEEDED(hr)) ? HeapAlloc(GetProcessHeap(), 0, DescriptorRangesSize) : nullptr; - if (DescriptorRangesSize > 0 && pDescriptorRanges == nullptr) - { - hr = E_OUTOFMEMORY; - } - auto pDescriptorRanges_1_0 = static_cast(pDescriptorRanges); - - if (SUCCEEDED(hr)) - { - for (UINT x = 0; x < table_1_1.NumDescriptorRanges; x++) - { - __analysis_assume(DescriptorRangesSize == sizeof(D3D12_DESCRIPTOR_RANGE) * table_1_1.NumDescriptorRanges); - pDescriptorRanges_1_0[x].BaseShaderRegister = table_1_1.pDescriptorRanges[x].BaseShaderRegister; - pDescriptorRanges_1_0[x].NumDescriptors = table_1_1.pDescriptorRanges[x].NumDescriptors; - pDescriptorRanges_1_0[x].OffsetInDescriptorsFromTableStart = table_1_1.pDescriptorRanges[x].OffsetInDescriptorsFromTableStart; - pDescriptorRanges_1_0[x].RangeType = table_1_1.pDescriptorRanges[x].RangeType; - pDescriptorRanges_1_0[x].RegisterSpace = table_1_1.pDescriptorRanges[x].RegisterSpace; - } - } - - D3D12_ROOT_DESCRIPTOR_TABLE& table_1_0 = pParameters_1_0[n].DescriptorTable; - table_1_0.NumDescriptorRanges = table_1_1.NumDescriptorRanges; - table_1_0.pDescriptorRanges = pDescriptorRanges_1_0; - } - } - } - - if (SUCCEEDED(hr)) - { - const CD3DX12_ROOT_SIGNATURE_DESC desc_1_0(desc_1_1.NumParameters, pParameters_1_0, desc_1_1.NumStaticSamplers, desc_1_1.pStaticSamplers, desc_1_1.Flags); - hr = D3D12SerializeRootSignature(&desc_1_0, D3D_ROOT_SIGNATURE_VERSION_1, ppBlob, ppErrorBlob); - } - - if (pParameters) - { - for (UINT n = 0; n < desc_1_1.NumParameters; n++) - { - if (desc_1_1.pParameters[n].ParameterType == D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE) - { - auto pDescriptorRanges_1_0 = pParameters_1_0[n].DescriptorTable.pDescriptorRanges; - HeapFree(GetProcessHeap(), 0, reinterpret_cast(const_cast(pDescriptorRanges_1_0))); - } - } - HeapFree(GetProcessHeap(), 0, pParameters); - } - return hr; - } - } - break; - - case D3D_ROOT_SIGNATURE_VERSION_1_1: - return D3D12SerializeVersionedRootSignature(pRootSignatureDesc, ppBlob, ppErrorBlob); - } - - return E_INVALIDARG; -} - -//------------------------------------------------------------------------------------------------ -struct CD3DX12_RT_FORMAT_ARRAY : public D3D12_RT_FORMAT_ARRAY -{ - CD3DX12_RT_FORMAT_ARRAY() = default; - explicit CD3DX12_RT_FORMAT_ARRAY(const D3D12_RT_FORMAT_ARRAY& o) noexcept - : D3D12_RT_FORMAT_ARRAY(o) - {} - explicit CD3DX12_RT_FORMAT_ARRAY(_In_reads_(NumFormats) const DXGI_FORMAT* pFormats, UINT NumFormats) noexcept - { - NumRenderTargets = NumFormats; - memcpy(RTFormats, pFormats, sizeof(RTFormats)); - // assumes ARRAY_SIZE(pFormats) == ARRAY_SIZE(RTFormats) - } -}; - -//------------------------------------------------------------------------------------------------ -// Pipeline State Stream Helpers -//------------------------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------------------------ -// Stream Subobjects, i.e. elements of a stream - -struct DefaultSampleMask { operator UINT() noexcept { return UINT_MAX; } }; -struct DefaultSampleDesc { operator DXGI_SAMPLE_DESC() noexcept { return DXGI_SAMPLE_DESC{1, 0}; } }; - -#pragma warning(push) -#pragma warning(disable : 4324) -template -class alignas(void*) CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT -{ -private: - D3D12_PIPELINE_STATE_SUBOBJECT_TYPE pssType; - InnerStructType pssInner; -public: - CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT() noexcept : pssType(Type), pssInner(DefaultArg()) {} - CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT(InnerStructType const& i) noexcept : pssType(Type), pssInner(i) {} - CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT& operator=(InnerStructType const& i) noexcept { pssType = Type; pssInner = i; return *this; } - operator InnerStructType const&() const noexcept { return pssInner; } - operator InnerStructType&() noexcept { return pssInner; } - InnerStructType* operator&() noexcept { return &pssInner; } - InnerStructType const* operator&() const noexcept { return &pssInner; } -}; -#pragma warning(pop) -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_PIPELINE_STATE_FLAGS, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_FLAGS> CD3DX12_PIPELINE_STATE_STREAM_FLAGS; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< UINT, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_NODE_MASK> CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< ID3D12RootSignature*, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_ROOT_SIGNATURE> CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_INPUT_LAYOUT_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_INPUT_LAYOUT> CD3DX12_PIPELINE_STATE_STREAM_INPUT_LAYOUT; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_INDEX_BUFFER_STRIP_CUT_VALUE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_IB_STRIP_CUT_VALUE> CD3DX12_PIPELINE_STATE_STREAM_IB_STRIP_CUT_VALUE; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_PRIMITIVE_TOPOLOGY_TYPE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PRIMITIVE_TOPOLOGY> CD3DX12_PIPELINE_STATE_STREAM_PRIMITIVE_TOPOLOGY; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VS> CD3DX12_PIPELINE_STATE_STREAM_VS; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_GS> CD3DX12_PIPELINE_STATE_STREAM_GS; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_STREAM_OUTPUT_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_STREAM_OUTPUT> CD3DX12_PIPELINE_STATE_STREAM_STREAM_OUTPUT; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_HS> CD3DX12_PIPELINE_STATE_STREAM_HS; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DS> CD3DX12_PIPELINE_STATE_STREAM_DS; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PS> CD3DX12_PIPELINE_STATE_STREAM_PS; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_AS> CD3DX12_PIPELINE_STATE_STREAM_AS; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MS> CD3DX12_PIPELINE_STATE_STREAM_MS; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CS> CD3DX12_PIPELINE_STATE_STREAM_CS; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_BLEND_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_BLEND, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_DEPTH_STENCIL_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_DEPTH_STENCIL_DESC1, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL1; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< DXGI_FORMAT, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL_FORMAT> CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL_FORMAT; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_RASTERIZER_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_RT_FORMAT_ARRAY, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RENDER_TARGET_FORMATS> CD3DX12_PIPELINE_STATE_STREAM_RENDER_TARGET_FORMATS; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< DXGI_SAMPLE_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_DESC, DefaultSampleDesc> CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_DESC; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< UINT, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_MASK, DefaultSampleMask> CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_MASK; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_CACHED_PIPELINE_STATE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CACHED_PSO> CD3DX12_PIPELINE_STATE_STREAM_CACHED_PSO; -typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_VIEW_INSTANCING_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VIEW_INSTANCING, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_VIEW_INSTANCING; - -//------------------------------------------------------------------------------------------------ -// Stream Parser Helpers - -struct ID3DX12PipelineParserCallbacks -{ - // Subobject Callbacks - virtual void FlagsCb(D3D12_PIPELINE_STATE_FLAGS) {} - virtual void NodeMaskCb(UINT) {} - virtual void RootSignatureCb(ID3D12RootSignature*) {} - virtual void InputLayoutCb(const D3D12_INPUT_LAYOUT_DESC&) {} - virtual void IBStripCutValueCb(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE) {} - virtual void PrimitiveTopologyTypeCb(D3D12_PRIMITIVE_TOPOLOGY_TYPE) {} - virtual void VSCb(const D3D12_SHADER_BYTECODE&) {} - virtual void GSCb(const D3D12_SHADER_BYTECODE&) {} - virtual void StreamOutputCb(const D3D12_STREAM_OUTPUT_DESC&) {} - virtual void HSCb(const D3D12_SHADER_BYTECODE&) {} - virtual void DSCb(const D3D12_SHADER_BYTECODE&) {} - virtual void PSCb(const D3D12_SHADER_BYTECODE&) {} - virtual void CSCb(const D3D12_SHADER_BYTECODE&) {} - virtual void ASCb(const D3D12_SHADER_BYTECODE&) {} - virtual void MSCb(const D3D12_SHADER_BYTECODE&) {} - virtual void BlendStateCb(const D3D12_BLEND_DESC&) {} - virtual void DepthStencilStateCb(const D3D12_DEPTH_STENCIL_DESC&) {} - virtual void DepthStencilState1Cb(const D3D12_DEPTH_STENCIL_DESC1&) {} - virtual void DSVFormatCb(DXGI_FORMAT) {} - virtual void RasterizerStateCb(const D3D12_RASTERIZER_DESC&) {} - virtual void RTVFormatsCb(const D3D12_RT_FORMAT_ARRAY&) {} - virtual void SampleDescCb(const DXGI_SAMPLE_DESC&) {} - virtual void SampleMaskCb(UINT) {} - virtual void ViewInstancingCb(const D3D12_VIEW_INSTANCING_DESC&) {} - virtual void CachedPSOCb(const D3D12_CACHED_PIPELINE_STATE&) {} - - // Error Callbacks - virtual void ErrorBadInputParameter(UINT /*ParameterIndex*/) {} - virtual void ErrorDuplicateSubobject(D3D12_PIPELINE_STATE_SUBOBJECT_TYPE /*DuplicateType*/) {} - virtual void ErrorUnknownSubobject(UINT /*UnknownTypeValue*/) {} - - virtual ~ID3DX12PipelineParserCallbacks() = default; -}; - -struct D3DX12_MESH_SHADER_PIPELINE_STATE_DESC -{ - ID3D12RootSignature* pRootSignature; - D3D12_SHADER_BYTECODE AS; - D3D12_SHADER_BYTECODE MS; - D3D12_SHADER_BYTECODE PS; - D3D12_BLEND_DESC BlendState; - UINT SampleMask; - D3D12_RASTERIZER_DESC RasterizerState; - D3D12_DEPTH_STENCIL_DESC DepthStencilState; - D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType; - UINT NumRenderTargets; - DXGI_FORMAT RTVFormats[ D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT ]; - DXGI_FORMAT DSVFormat; - DXGI_SAMPLE_DESC SampleDesc; - UINT NodeMask; - D3D12_CACHED_PIPELINE_STATE CachedPSO; - D3D12_PIPELINE_STATE_FLAGS Flags; -}; - -// CD3DX12_PIPELINE_STATE_STREAM2 Works on OS Build 19041+ (where there is a new mesh shader pipeline). -// Use CD3DX12_PIPELINE_STATE_STREAM1 for OS Build 16299+ (where there is a new view instancing subobject). -// Use CD3DX12_PIPELINE_STATE_STREAM for OS Build 15063+ support. -struct CD3DX12_PIPELINE_STATE_STREAM2 -{ - CD3DX12_PIPELINE_STATE_STREAM2() = default; - // Mesh and amplification shaders must be set manually, since they do not have representation in D3D12_GRAPHICS_PIPELINE_STATE_DESC - CD3DX12_PIPELINE_STATE_STREAM2(const D3D12_GRAPHICS_PIPELINE_STATE_DESC& Desc) noexcept - : Flags(Desc.Flags) - , NodeMask(Desc.NodeMask) - , pRootSignature(Desc.pRootSignature) - , InputLayout(Desc.InputLayout) - , IBStripCutValue(Desc.IBStripCutValue) - , PrimitiveTopologyType(Desc.PrimitiveTopologyType) - , VS(Desc.VS) - , GS(Desc.GS) - , StreamOutput(Desc.StreamOutput) - , HS(Desc.HS) - , DS(Desc.DS) - , PS(Desc.PS) - , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) - , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC1(Desc.DepthStencilState)) - , DSVFormat(Desc.DSVFormat) - , RasterizerState(CD3DX12_RASTERIZER_DESC(Desc.RasterizerState)) - , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) - , SampleDesc(Desc.SampleDesc) - , SampleMask(Desc.SampleMask) - , CachedPSO(Desc.CachedPSO) - , ViewInstancingDesc(CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT())) - {} - CD3DX12_PIPELINE_STATE_STREAM2(const D3DX12_MESH_SHADER_PIPELINE_STATE_DESC& Desc) noexcept - : Flags(Desc.Flags) - , NodeMask(Desc.NodeMask) - , pRootSignature(Desc.pRootSignature) - , PrimitiveTopologyType(Desc.PrimitiveTopologyType) - , PS(Desc.PS) - , AS(Desc.AS) - , MS(Desc.MS) - , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) - , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC1(Desc.DepthStencilState)) - , DSVFormat(Desc.DSVFormat) - , RasterizerState(CD3DX12_RASTERIZER_DESC(Desc.RasterizerState)) - , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) - , SampleDesc(Desc.SampleDesc) - , SampleMask(Desc.SampleMask) - , CachedPSO(Desc.CachedPSO) - , ViewInstancingDesc(CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT())) - {} - CD3DX12_PIPELINE_STATE_STREAM2(const D3D12_COMPUTE_PIPELINE_STATE_DESC& Desc) noexcept - : Flags(Desc.Flags) - , NodeMask(Desc.NodeMask) - , pRootSignature(Desc.pRootSignature) - , CS(CD3DX12_SHADER_BYTECODE(Desc.CS)) - , CachedPSO(Desc.CachedPSO) - { - static_cast(DepthStencilState).DepthEnable = false; - } - CD3DX12_PIPELINE_STATE_STREAM_FLAGS Flags; - CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK NodeMask; - CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE pRootSignature; - CD3DX12_PIPELINE_STATE_STREAM_INPUT_LAYOUT InputLayout; - CD3DX12_PIPELINE_STATE_STREAM_IB_STRIP_CUT_VALUE IBStripCutValue; - CD3DX12_PIPELINE_STATE_STREAM_PRIMITIVE_TOPOLOGY PrimitiveTopologyType; - CD3DX12_PIPELINE_STATE_STREAM_VS VS; - CD3DX12_PIPELINE_STATE_STREAM_GS GS; - CD3DX12_PIPELINE_STATE_STREAM_STREAM_OUTPUT StreamOutput; - CD3DX12_PIPELINE_STATE_STREAM_HS HS; - CD3DX12_PIPELINE_STATE_STREAM_DS DS; - CD3DX12_PIPELINE_STATE_STREAM_PS PS; - CD3DX12_PIPELINE_STATE_STREAM_AS AS; - CD3DX12_PIPELINE_STATE_STREAM_MS MS; - CD3DX12_PIPELINE_STATE_STREAM_CS CS; - CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC BlendState; - CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL1 DepthStencilState; - CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL_FORMAT DSVFormat; - CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER RasterizerState; - CD3DX12_PIPELINE_STATE_STREAM_RENDER_TARGET_FORMATS RTVFormats; - CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_DESC SampleDesc; - CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_MASK SampleMask; - CD3DX12_PIPELINE_STATE_STREAM_CACHED_PSO CachedPSO; - CD3DX12_PIPELINE_STATE_STREAM_VIEW_INSTANCING ViewInstancingDesc; - D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDescV0() const noexcept - { - D3D12_GRAPHICS_PIPELINE_STATE_DESC D; - D.Flags = this->Flags; - D.NodeMask = this->NodeMask; - D.pRootSignature = this->pRootSignature; - D.InputLayout = this->InputLayout; - D.IBStripCutValue = this->IBStripCutValue; - D.PrimitiveTopologyType = this->PrimitiveTopologyType; - D.VS = this->VS; - D.GS = this->GS; - D.StreamOutput = this->StreamOutput; - D.HS = this->HS; - D.DS = this->DS; - D.PS = this->PS; - D.BlendState = this->BlendState; - D.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(D3D12_DEPTH_STENCIL_DESC1(this->DepthStencilState)); - D.DSVFormat = this->DSVFormat; - D.RasterizerState = this->RasterizerState; - D.NumRenderTargets = D3D12_RT_FORMAT_ARRAY(this->RTVFormats).NumRenderTargets; - memcpy(D.RTVFormats, D3D12_RT_FORMAT_ARRAY(this->RTVFormats).RTFormats, sizeof(D.RTVFormats)); - D.SampleDesc = this->SampleDesc; - D.SampleMask = this->SampleMask; - D.CachedPSO = this->CachedPSO; - return D; - } - D3D12_COMPUTE_PIPELINE_STATE_DESC ComputeDescV0() const noexcept - { - D3D12_COMPUTE_PIPELINE_STATE_DESC D; - D.Flags = this->Flags; - D.NodeMask = this->NodeMask; - D.pRootSignature = this->pRootSignature; - D.CS = this->CS; - D.CachedPSO = this->CachedPSO; - return D; - } -}; - -// CD3DX12_PIPELINE_STATE_STREAM1 Works on OS Build 16299+ (where there is a new view instancing subobject). -// Use CD3DX12_PIPELINE_STATE_STREAM for OS Build 15063+ support. -struct CD3DX12_PIPELINE_STATE_STREAM1 -{ - CD3DX12_PIPELINE_STATE_STREAM1() = default; - // Mesh and amplification shaders must be set manually, since they do not have representation in D3D12_GRAPHICS_PIPELINE_STATE_DESC - CD3DX12_PIPELINE_STATE_STREAM1(const D3D12_GRAPHICS_PIPELINE_STATE_DESC& Desc) noexcept - : Flags(Desc.Flags) - , NodeMask(Desc.NodeMask) - , pRootSignature(Desc.pRootSignature) - , InputLayout(Desc.InputLayout) - , IBStripCutValue(Desc.IBStripCutValue) - , PrimitiveTopologyType(Desc.PrimitiveTopologyType) - , VS(Desc.VS) - , GS(Desc.GS) - , StreamOutput(Desc.StreamOutput) - , HS(Desc.HS) - , DS(Desc.DS) - , PS(Desc.PS) - , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) - , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC1(Desc.DepthStencilState)) - , DSVFormat(Desc.DSVFormat) - , RasterizerState(CD3DX12_RASTERIZER_DESC(Desc.RasterizerState)) - , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) - , SampleDesc(Desc.SampleDesc) - , SampleMask(Desc.SampleMask) - , CachedPSO(Desc.CachedPSO) - , ViewInstancingDesc(CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT())) - {} - CD3DX12_PIPELINE_STATE_STREAM1(const D3DX12_MESH_SHADER_PIPELINE_STATE_DESC& Desc) noexcept - : Flags(Desc.Flags) - , NodeMask(Desc.NodeMask) - , pRootSignature(Desc.pRootSignature) - , PrimitiveTopologyType(Desc.PrimitiveTopologyType) - , PS(Desc.PS) - , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) - , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC1(Desc.DepthStencilState)) - , DSVFormat(Desc.DSVFormat) - , RasterizerState(CD3DX12_RASTERIZER_DESC(Desc.RasterizerState)) - , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) - , SampleDesc(Desc.SampleDesc) - , SampleMask(Desc.SampleMask) - , CachedPSO(Desc.CachedPSO) - , ViewInstancingDesc(CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT())) - {} - CD3DX12_PIPELINE_STATE_STREAM1(const D3D12_COMPUTE_PIPELINE_STATE_DESC& Desc) noexcept - : Flags(Desc.Flags) - , NodeMask(Desc.NodeMask) - , pRootSignature(Desc.pRootSignature) - , CS(CD3DX12_SHADER_BYTECODE(Desc.CS)) - , CachedPSO(Desc.CachedPSO) - { - static_cast(DepthStencilState).DepthEnable = false; - } - CD3DX12_PIPELINE_STATE_STREAM_FLAGS Flags; - CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK NodeMask; - CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE pRootSignature; - CD3DX12_PIPELINE_STATE_STREAM_INPUT_LAYOUT InputLayout; - CD3DX12_PIPELINE_STATE_STREAM_IB_STRIP_CUT_VALUE IBStripCutValue; - CD3DX12_PIPELINE_STATE_STREAM_PRIMITIVE_TOPOLOGY PrimitiveTopologyType; - CD3DX12_PIPELINE_STATE_STREAM_VS VS; - CD3DX12_PIPELINE_STATE_STREAM_GS GS; - CD3DX12_PIPELINE_STATE_STREAM_STREAM_OUTPUT StreamOutput; - CD3DX12_PIPELINE_STATE_STREAM_HS HS; - CD3DX12_PIPELINE_STATE_STREAM_DS DS; - CD3DX12_PIPELINE_STATE_STREAM_PS PS; - CD3DX12_PIPELINE_STATE_STREAM_CS CS; - CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC BlendState; - CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL1 DepthStencilState; - CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL_FORMAT DSVFormat; - CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER RasterizerState; - CD3DX12_PIPELINE_STATE_STREAM_RENDER_TARGET_FORMATS RTVFormats; - CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_DESC SampleDesc; - CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_MASK SampleMask; - CD3DX12_PIPELINE_STATE_STREAM_CACHED_PSO CachedPSO; - CD3DX12_PIPELINE_STATE_STREAM_VIEW_INSTANCING ViewInstancingDesc; - D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDescV0() const noexcept - { - D3D12_GRAPHICS_PIPELINE_STATE_DESC D; - D.Flags = this->Flags; - D.NodeMask = this->NodeMask; - D.pRootSignature = this->pRootSignature; - D.InputLayout = this->InputLayout; - D.IBStripCutValue = this->IBStripCutValue; - D.PrimitiveTopologyType = this->PrimitiveTopologyType; - D.VS = this->VS; - D.GS = this->GS; - D.StreamOutput = this->StreamOutput; - D.HS = this->HS; - D.DS = this->DS; - D.PS = this->PS; - D.BlendState = this->BlendState; - D.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(D3D12_DEPTH_STENCIL_DESC1(this->DepthStencilState)); - D.DSVFormat = this->DSVFormat; - D.RasterizerState = this->RasterizerState; - D.NumRenderTargets = D3D12_RT_FORMAT_ARRAY(this->RTVFormats).NumRenderTargets; - memcpy(D.RTVFormats, D3D12_RT_FORMAT_ARRAY(this->RTVFormats).RTFormats, sizeof(D.RTVFormats)); - D.SampleDesc = this->SampleDesc; - D.SampleMask = this->SampleMask; - D.CachedPSO = this->CachedPSO; - return D; - } - D3D12_COMPUTE_PIPELINE_STATE_DESC ComputeDescV0() const noexcept - { - D3D12_COMPUTE_PIPELINE_STATE_DESC D; - D.Flags = this->Flags; - D.NodeMask = this->NodeMask; - D.pRootSignature = this->pRootSignature; - D.CS = this->CS; - D.CachedPSO = this->CachedPSO; - return D; - } -}; - - -struct CD3DX12_PIPELINE_MESH_STATE_STREAM -{ - CD3DX12_PIPELINE_MESH_STATE_STREAM() = default; - CD3DX12_PIPELINE_MESH_STATE_STREAM(const D3DX12_MESH_SHADER_PIPELINE_STATE_DESC& Desc) noexcept - : Flags(Desc.Flags) - , NodeMask(Desc.NodeMask) - , pRootSignature(Desc.pRootSignature) - , PS(Desc.PS) - , AS(Desc.AS) - , MS(Desc.MS) - , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) - , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC1(Desc.DepthStencilState)) - , DSVFormat(Desc.DSVFormat) - , RasterizerState(CD3DX12_RASTERIZER_DESC(Desc.RasterizerState)) - , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) - , SampleDesc(Desc.SampleDesc) - , SampleMask(Desc.SampleMask) - , CachedPSO(Desc.CachedPSO) - , ViewInstancingDesc(CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT())) - {} - CD3DX12_PIPELINE_STATE_STREAM_FLAGS Flags; - CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK NodeMask; - CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE pRootSignature; - CD3DX12_PIPELINE_STATE_STREAM_PS PS; - CD3DX12_PIPELINE_STATE_STREAM_AS AS; - CD3DX12_PIPELINE_STATE_STREAM_MS MS; - CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC BlendState; - CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL1 DepthStencilState; - CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL_FORMAT DSVFormat; - CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER RasterizerState; - CD3DX12_PIPELINE_STATE_STREAM_RENDER_TARGET_FORMATS RTVFormats; - CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_DESC SampleDesc; - CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_MASK SampleMask; - CD3DX12_PIPELINE_STATE_STREAM_CACHED_PSO CachedPSO; - CD3DX12_PIPELINE_STATE_STREAM_VIEW_INSTANCING ViewInstancingDesc; - D3DX12_MESH_SHADER_PIPELINE_STATE_DESC MeshShaderDescV0() const noexcept - { - D3DX12_MESH_SHADER_PIPELINE_STATE_DESC D; - D.Flags = this->Flags; - D.NodeMask = this->NodeMask; - D.pRootSignature = this->pRootSignature; - D.PS = this->PS; - D.AS = this->AS; - D.MS = this->MS; - D.BlendState = this->BlendState; - D.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(D3D12_DEPTH_STENCIL_DESC1(this->DepthStencilState)); - D.DSVFormat = this->DSVFormat; - D.RasterizerState = this->RasterizerState; - D.NumRenderTargets = D3D12_RT_FORMAT_ARRAY(this->RTVFormats).NumRenderTargets; - memcpy(D.RTVFormats, D3D12_RT_FORMAT_ARRAY(this->RTVFormats).RTFormats, sizeof(D.RTVFormats)); - D.SampleDesc = this->SampleDesc; - D.SampleMask = this->SampleMask; - D.CachedPSO = this->CachedPSO; - return D; - } -}; - -// CD3DX12_PIPELINE_STATE_STREAM works on OS Build 15063+ but does not support new subobject(s) added in OS Build 16299+. -// See CD3DX12_PIPELINE_STATE_STREAM1 for instance. -struct CD3DX12_PIPELINE_STATE_STREAM -{ - CD3DX12_PIPELINE_STATE_STREAM() = default; - CD3DX12_PIPELINE_STATE_STREAM(const D3D12_GRAPHICS_PIPELINE_STATE_DESC& Desc) noexcept - : Flags(Desc.Flags) - , NodeMask(Desc.NodeMask) - , pRootSignature(Desc.pRootSignature) - , InputLayout(Desc.InputLayout) - , IBStripCutValue(Desc.IBStripCutValue) - , PrimitiveTopologyType(Desc.PrimitiveTopologyType) - , VS(Desc.VS) - , GS(Desc.GS) - , StreamOutput(Desc.StreamOutput) - , HS(Desc.HS) - , DS(Desc.DS) - , PS(Desc.PS) - , BlendState(CD3DX12_BLEND_DESC(Desc.BlendState)) - , DepthStencilState(CD3DX12_DEPTH_STENCIL_DESC1(Desc.DepthStencilState)) - , DSVFormat(Desc.DSVFormat) - , RasterizerState(CD3DX12_RASTERIZER_DESC(Desc.RasterizerState)) - , RTVFormats(CD3DX12_RT_FORMAT_ARRAY(Desc.RTVFormats, Desc.NumRenderTargets)) - , SampleDesc(Desc.SampleDesc) - , SampleMask(Desc.SampleMask) - , CachedPSO(Desc.CachedPSO) - {} - CD3DX12_PIPELINE_STATE_STREAM(const D3D12_COMPUTE_PIPELINE_STATE_DESC& Desc) noexcept - : Flags(Desc.Flags) - , NodeMask(Desc.NodeMask) - , pRootSignature(Desc.pRootSignature) - , CS(CD3DX12_SHADER_BYTECODE(Desc.CS)) - , CachedPSO(Desc.CachedPSO) - {} - CD3DX12_PIPELINE_STATE_STREAM_FLAGS Flags; - CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK NodeMask; - CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE pRootSignature; - CD3DX12_PIPELINE_STATE_STREAM_INPUT_LAYOUT InputLayout; - CD3DX12_PIPELINE_STATE_STREAM_IB_STRIP_CUT_VALUE IBStripCutValue; - CD3DX12_PIPELINE_STATE_STREAM_PRIMITIVE_TOPOLOGY PrimitiveTopologyType; - CD3DX12_PIPELINE_STATE_STREAM_VS VS; - CD3DX12_PIPELINE_STATE_STREAM_GS GS; - CD3DX12_PIPELINE_STATE_STREAM_STREAM_OUTPUT StreamOutput; - CD3DX12_PIPELINE_STATE_STREAM_HS HS; - CD3DX12_PIPELINE_STATE_STREAM_DS DS; - CD3DX12_PIPELINE_STATE_STREAM_PS PS; - CD3DX12_PIPELINE_STATE_STREAM_CS CS; - CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC BlendState; - CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL1 DepthStencilState; - CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL_FORMAT DSVFormat; - CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER RasterizerState; - CD3DX12_PIPELINE_STATE_STREAM_RENDER_TARGET_FORMATS RTVFormats; - CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_DESC SampleDesc; - CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_MASK SampleMask; - CD3DX12_PIPELINE_STATE_STREAM_CACHED_PSO CachedPSO; - D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDescV0() const noexcept - { - D3D12_GRAPHICS_PIPELINE_STATE_DESC D; - D.Flags = this->Flags; - D.NodeMask = this->NodeMask; - D.pRootSignature = this->pRootSignature; - D.InputLayout = this->InputLayout; - D.IBStripCutValue = this->IBStripCutValue; - D.PrimitiveTopologyType = this->PrimitiveTopologyType; - D.VS = this->VS; - D.GS = this->GS; - D.StreamOutput = this->StreamOutput; - D.HS = this->HS; - D.DS = this->DS; - D.PS = this->PS; - D.BlendState = this->BlendState; - D.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(D3D12_DEPTH_STENCIL_DESC1(this->DepthStencilState)); - D.DSVFormat = this->DSVFormat; - D.RasterizerState = this->RasterizerState; - D.NumRenderTargets = D3D12_RT_FORMAT_ARRAY(this->RTVFormats).NumRenderTargets; - memcpy(D.RTVFormats, D3D12_RT_FORMAT_ARRAY(this->RTVFormats).RTFormats, sizeof(D.RTVFormats)); - D.SampleDesc = this->SampleDesc; - D.SampleMask = this->SampleMask; - D.CachedPSO = this->CachedPSO; - return D; - } - D3D12_COMPUTE_PIPELINE_STATE_DESC ComputeDescV0() const noexcept - { - D3D12_COMPUTE_PIPELINE_STATE_DESC D; - D.Flags = this->Flags; - D.NodeMask = this->NodeMask; - D.pRootSignature = this->pRootSignature; - D.CS = this->CS; - D.CachedPSO = this->CachedPSO; - return D; - } -}; - -struct CD3DX12_PIPELINE_STATE_STREAM2_PARSE_HELPER : public ID3DX12PipelineParserCallbacks -{ - CD3DX12_PIPELINE_STATE_STREAM2 PipelineStream; - CD3DX12_PIPELINE_STATE_STREAM2_PARSE_HELPER() noexcept - : SeenDSS(false) - { - // Adjust defaults to account for absent members. - PipelineStream.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; - - // Depth disabled if no DSV format specified. - static_cast(PipelineStream.DepthStencilState).DepthEnable = false; - } - - // ID3DX12PipelineParserCallbacks - void FlagsCb(D3D12_PIPELINE_STATE_FLAGS Flags) override {PipelineStream.Flags = Flags;} - void NodeMaskCb(UINT NodeMask) override {PipelineStream.NodeMask = NodeMask;} - void RootSignatureCb(ID3D12RootSignature* pRootSignature) override {PipelineStream.pRootSignature = pRootSignature;} - void InputLayoutCb(const D3D12_INPUT_LAYOUT_DESC& InputLayout) override {PipelineStream.InputLayout = InputLayout;} - void IBStripCutValueCb(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue) override {PipelineStream.IBStripCutValue = IBStripCutValue;} - void PrimitiveTopologyTypeCb(D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType) override {PipelineStream.PrimitiveTopologyType = PrimitiveTopologyType;} - void VSCb(const D3D12_SHADER_BYTECODE& VS) override {PipelineStream.VS = VS;} - void GSCb(const D3D12_SHADER_BYTECODE& GS) override {PipelineStream.GS = GS;} - void StreamOutputCb(const D3D12_STREAM_OUTPUT_DESC& StreamOutput) override {PipelineStream.StreamOutput = StreamOutput;} - void HSCb(const D3D12_SHADER_BYTECODE& HS) override {PipelineStream.HS = HS;} - void DSCb(const D3D12_SHADER_BYTECODE& DS) override {PipelineStream.DS = DS;} - void PSCb(const D3D12_SHADER_BYTECODE& PS) override {PipelineStream.PS = PS;} - void CSCb(const D3D12_SHADER_BYTECODE& CS) override {PipelineStream.CS = CS;} - void ASCb(const D3D12_SHADER_BYTECODE& AS) override {PipelineStream.AS = AS;} - void MSCb(const D3D12_SHADER_BYTECODE& MS) override {PipelineStream.MS = MS;} - void BlendStateCb(const D3D12_BLEND_DESC& BlendState) override {PipelineStream.BlendState = CD3DX12_BLEND_DESC(BlendState);} - void DepthStencilStateCb(const D3D12_DEPTH_STENCIL_DESC& DepthStencilState) override - { - PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(DepthStencilState); - SeenDSS = true; - } - void DepthStencilState1Cb(const D3D12_DEPTH_STENCIL_DESC1& DepthStencilState) override - { - PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(DepthStencilState); - SeenDSS = true; - } - void DSVFormatCb(DXGI_FORMAT DSVFormat) override - { - PipelineStream.DSVFormat = DSVFormat; - if (!SeenDSS && DSVFormat != DXGI_FORMAT_UNKNOWN) - { - // Re-enable depth for the default state. - static_cast(PipelineStream.DepthStencilState).DepthEnable = true; - } - } - void RasterizerStateCb(const D3D12_RASTERIZER_DESC& RasterizerState) override {PipelineStream.RasterizerState = CD3DX12_RASTERIZER_DESC(RasterizerState);} - void RTVFormatsCb(const D3D12_RT_FORMAT_ARRAY& RTVFormats) override {PipelineStream.RTVFormats = RTVFormats;} - void SampleDescCb(const DXGI_SAMPLE_DESC& SampleDesc) override {PipelineStream.SampleDesc = SampleDesc;} - void SampleMaskCb(UINT SampleMask) override {PipelineStream.SampleMask = SampleMask;} - void ViewInstancingCb(const D3D12_VIEW_INSTANCING_DESC& ViewInstancingDesc) override {PipelineStream.ViewInstancingDesc = CD3DX12_VIEW_INSTANCING_DESC(ViewInstancingDesc);} - void CachedPSOCb(const D3D12_CACHED_PIPELINE_STATE& CachedPSO) override {PipelineStream.CachedPSO = CachedPSO;} - -private: - bool SeenDSS; -}; - - -struct CD3DX12_PIPELINE_STATE_STREAM_PARSE_HELPER : public ID3DX12PipelineParserCallbacks -{ - CD3DX12_PIPELINE_STATE_STREAM1 PipelineStream; - CD3DX12_PIPELINE_STATE_STREAM_PARSE_HELPER() noexcept - : SeenDSS(false) - { - // Adjust defaults to account for absent members. - PipelineStream.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; - - // Depth disabled if no DSV format specified. - static_cast(PipelineStream.DepthStencilState).DepthEnable = false; - } - - // ID3DX12PipelineParserCallbacks - void FlagsCb(D3D12_PIPELINE_STATE_FLAGS Flags) override {PipelineStream.Flags = Flags;} - void NodeMaskCb(UINT NodeMask) override {PipelineStream.NodeMask = NodeMask;} - void RootSignatureCb(ID3D12RootSignature* pRootSignature) override {PipelineStream.pRootSignature = pRootSignature;} - void InputLayoutCb(const D3D12_INPUT_LAYOUT_DESC& InputLayout) override {PipelineStream.InputLayout = InputLayout;} - void IBStripCutValueCb(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue) override {PipelineStream.IBStripCutValue = IBStripCutValue;} - void PrimitiveTopologyTypeCb(D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType) override {PipelineStream.PrimitiveTopologyType = PrimitiveTopologyType;} - void VSCb(const D3D12_SHADER_BYTECODE& VS) override {PipelineStream.VS = VS;} - void GSCb(const D3D12_SHADER_BYTECODE& GS) override {PipelineStream.GS = GS;} - void StreamOutputCb(const D3D12_STREAM_OUTPUT_DESC& StreamOutput) override {PipelineStream.StreamOutput = StreamOutput;} - void HSCb(const D3D12_SHADER_BYTECODE& HS) override {PipelineStream.HS = HS;} - void DSCb(const D3D12_SHADER_BYTECODE& DS) override {PipelineStream.DS = DS;} - void PSCb(const D3D12_SHADER_BYTECODE& PS) override {PipelineStream.PS = PS;} - void CSCb(const D3D12_SHADER_BYTECODE& CS) override {PipelineStream.CS = CS;} - void BlendStateCb(const D3D12_BLEND_DESC& BlendState) override {PipelineStream.BlendState = CD3DX12_BLEND_DESC(BlendState);} - void DepthStencilStateCb(const D3D12_DEPTH_STENCIL_DESC& DepthStencilState) override - { - PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(DepthStencilState); - SeenDSS = true; - } - void DepthStencilState1Cb(const D3D12_DEPTH_STENCIL_DESC1& DepthStencilState) override - { - PipelineStream.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(DepthStencilState); - SeenDSS = true; - } - void DSVFormatCb(DXGI_FORMAT DSVFormat) override - { - PipelineStream.DSVFormat = DSVFormat; - if (!SeenDSS && DSVFormat != DXGI_FORMAT_UNKNOWN) - { - // Re-enable depth for the default state. - static_cast(PipelineStream.DepthStencilState).DepthEnable = true; - } - } - void RasterizerStateCb(const D3D12_RASTERIZER_DESC& RasterizerState) override {PipelineStream.RasterizerState = CD3DX12_RASTERIZER_DESC(RasterizerState);} - void RTVFormatsCb(const D3D12_RT_FORMAT_ARRAY& RTVFormats) override {PipelineStream.RTVFormats = RTVFormats;} - void SampleDescCb(const DXGI_SAMPLE_DESC& SampleDesc) override {PipelineStream.SampleDesc = SampleDesc;} - void SampleMaskCb(UINT SampleMask) override {PipelineStream.SampleMask = SampleMask;} - void ViewInstancingCb(const D3D12_VIEW_INSTANCING_DESC& ViewInstancingDesc) override {PipelineStream.ViewInstancingDesc = CD3DX12_VIEW_INSTANCING_DESC(ViewInstancingDesc);} - void CachedPSOCb(const D3D12_CACHED_PIPELINE_STATE& CachedPSO) override {PipelineStream.CachedPSO = CachedPSO;} - -private: - bool SeenDSS; -}; - -inline D3D12_PIPELINE_STATE_SUBOBJECT_TYPE D3DX12GetBaseSubobjectType(D3D12_PIPELINE_STATE_SUBOBJECT_TYPE SubobjectType) noexcept -{ - switch (SubobjectType) - { - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1: - return D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL; - default: - return SubobjectType; - } -} - -inline HRESULT D3DX12ParsePipelineStream(const D3D12_PIPELINE_STATE_STREAM_DESC& Desc, ID3DX12PipelineParserCallbacks* pCallbacks) -{ - if (pCallbacks == nullptr) - { - return E_INVALIDARG; - } - - if (Desc.SizeInBytes == 0 || Desc.pPipelineStateSubobjectStream == nullptr) - { - pCallbacks->ErrorBadInputParameter(1); // first parameter issue - return E_INVALIDARG; - } - - bool SubobjectSeen[D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MAX_VALID] = {}; - for (SIZE_T CurOffset = 0, SizeOfSubobject = 0; CurOffset < Desc.SizeInBytes; CurOffset += SizeOfSubobject) - { - BYTE* pStream = static_cast(Desc.pPipelineStateSubobjectStream)+CurOffset; - auto SubobjectType = *reinterpret_cast(pStream); - if (SubobjectType < 0 || SubobjectType >= D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MAX_VALID) - { - pCallbacks->ErrorUnknownSubobject(SubobjectType); - return E_INVALIDARG; - } - if (SubobjectSeen[D3DX12GetBaseSubobjectType(SubobjectType)]) - { - pCallbacks->ErrorDuplicateSubobject(SubobjectType); - return E_INVALIDARG; // disallow subobject duplicates in a stream - } - SubobjectSeen[SubobjectType] = true; - switch (SubobjectType) - { - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_ROOT_SIGNATURE: - pCallbacks->RootSignatureCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::pRootSignature); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VS: - pCallbacks->VSCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::VS); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PS: - pCallbacks->PSCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::PS); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DS: - pCallbacks->DSCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::DS); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_HS: - pCallbacks->HSCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::HS); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_GS: - pCallbacks->GSCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::GS); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CS: - pCallbacks->CSCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::CS); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_AS: - pCallbacks->ASCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM2::AS); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MS: - pCallbacks->MSCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM2::MS); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_STREAM_OUTPUT: - pCallbacks->StreamOutputCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::StreamOutput); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_BLEND: - pCallbacks->BlendStateCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::BlendState); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_MASK: - pCallbacks->SampleMaskCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::SampleMask); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER: - pCallbacks->RasterizerStateCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::RasterizerState); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL: - pCallbacks->DepthStencilStateCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1: - pCallbacks->DepthStencilState1Cb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::DepthStencilState); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_INPUT_LAYOUT: - pCallbacks->InputLayoutCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::InputLayout); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_IB_STRIP_CUT_VALUE: - pCallbacks->IBStripCutValueCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::IBStripCutValue); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PRIMITIVE_TOPOLOGY: - pCallbacks->PrimitiveTopologyTypeCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::PrimitiveTopologyType); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RENDER_TARGET_FORMATS: - pCallbacks->RTVFormatsCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::RTVFormats); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL_FORMAT: - pCallbacks->DSVFormatCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::DSVFormat); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_DESC: - pCallbacks->SampleDescCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::SampleDesc); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_NODE_MASK: - pCallbacks->NodeMaskCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::NodeMask); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CACHED_PSO: - pCallbacks->CachedPSOCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::CachedPSO); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_FLAGS: - pCallbacks->FlagsCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM::Flags); - break; - case D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VIEW_INSTANCING: - pCallbacks->ViewInstancingCb(*reinterpret_cast(pStream)); - SizeOfSubobject = sizeof(CD3DX12_PIPELINE_STATE_STREAM1::ViewInstancingDesc); - break; - default: - pCallbacks->ErrorUnknownSubobject(SubobjectType); - return E_INVALIDARG; - } - } - - return S_OK; -} - -//------------------------------------------------------------------------------------------------ -inline bool operator==( const D3D12_CLEAR_VALUE &a, const D3D12_CLEAR_VALUE &b) noexcept -{ - if (a.Format != b.Format) return false; - if (a.Format == DXGI_FORMAT_D24_UNORM_S8_UINT - || a.Format == DXGI_FORMAT_D16_UNORM - || a.Format == DXGI_FORMAT_D32_FLOAT - || a.Format == DXGI_FORMAT_D32_FLOAT_S8X24_UINT) - { - return (a.DepthStencil.Depth == b.DepthStencil.Depth) && - (a.DepthStencil.Stencil == b.DepthStencil.Stencil); - } else { - return (a.Color[0] == b.Color[0]) && - (a.Color[1] == b.Color[1]) && - (a.Color[2] == b.Color[2]) && - (a.Color[3] == b.Color[3]); - } -} -inline bool operator==( const D3D12_RENDER_PASS_BEGINNING_ACCESS_CLEAR_PARAMETERS &a, const D3D12_RENDER_PASS_BEGINNING_ACCESS_CLEAR_PARAMETERS &b) noexcept -{ - return a.ClearValue == b.ClearValue; -} -inline bool operator==( const D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_PARAMETERS &a, const D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_PARAMETERS &b) noexcept -{ - if (a.pSrcResource != b.pSrcResource) return false; - if (a.pDstResource != b.pDstResource) return false; - if (a.SubresourceCount != b.SubresourceCount) return false; - if (a.Format != b.Format) return false; - if (a.ResolveMode != b.ResolveMode) return false; - if (a.PreserveResolveSource != b.PreserveResolveSource) return false; - return true; -} -inline bool operator==( const D3D12_RENDER_PASS_BEGINNING_ACCESS &a, const D3D12_RENDER_PASS_BEGINNING_ACCESS &b) noexcept -{ - if (a.Type != b.Type) return false; - if (a.Type == D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_CLEAR && !(a.Clear == b.Clear)) return false; - return true; -} -inline bool operator==( const D3D12_RENDER_PASS_ENDING_ACCESS &a, const D3D12_RENDER_PASS_ENDING_ACCESS &b) noexcept -{ - if (a.Type != b.Type) return false; - if (a.Type == D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_RESOLVE && !(a.Resolve == b.Resolve)) return false; - return true; -} -inline bool operator==( const D3D12_RENDER_PASS_RENDER_TARGET_DESC &a, const D3D12_RENDER_PASS_RENDER_TARGET_DESC &b) noexcept -{ - if (a.cpuDescriptor.ptr != b.cpuDescriptor.ptr) return false; - if (!(a.BeginningAccess == b.BeginningAccess)) return false; - if (!(a.EndingAccess == b.EndingAccess)) return false; - return true; -} -inline bool operator==( const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC &a, const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC &b) noexcept -{ - if (a.cpuDescriptor.ptr != b.cpuDescriptor.ptr) return false; - if (!(a.DepthBeginningAccess == b.DepthBeginningAccess)) return false; - if (!(a.StencilBeginningAccess == b.StencilBeginningAccess)) return false; - if (!(a.DepthEndingAccess == b.DepthEndingAccess)) return false; - if (!(a.StencilEndingAccess == b.StencilEndingAccess)) return false; - return true; -} - - -#ifndef D3DX12_NO_STATE_OBJECT_HELPERS - -//================================================================================================ -// D3DX12 State Object Creation Helpers -// -// Helper classes for creating new style state objects out of an arbitrary set of subobjects. -// Uses STL -// -// Start by instantiating CD3DX12_STATE_OBJECT_DESC (see its public methods). -// One of its methods is CreateSubobject(), which has a comment showing a couple of options for -// defining subobjects using the helper classes for each subobject (CD3DX12_DXIL_LIBRARY_SUBOBJECT -// etc.). The subobject helpers each have methods specific to the subobject for configuring its -// contents. -// -//================================================================================================ -#include -#include -#include -#include -#ifndef D3DX12_USE_ATL -#include -#define D3DX12_COM_PTR Microsoft::WRL::ComPtr -#define D3DX12_COM_PTR_GET(x) x.Get() -#define D3DX12_COM_PTR_ADDRESSOF(x) x.GetAddressOf() -#else -#include -#define D3DX12_COM_PTR ATL::CComPtr -#define D3DX12_COM_PTR_GET(x) x.p -#define D3DX12_COM_PTR_ADDRESSOF(x) &x.p -#endif - -//------------------------------------------------------------------------------------------------ -class CD3DX12_STATE_OBJECT_DESC -{ -public: - CD3DX12_STATE_OBJECT_DESC() noexcept - { - Init(D3D12_STATE_OBJECT_TYPE_COLLECTION); - } - CD3DX12_STATE_OBJECT_DESC(D3D12_STATE_OBJECT_TYPE Type) noexcept - { - Init(Type); - } - void SetStateObjectType(D3D12_STATE_OBJECT_TYPE Type) noexcept { m_Desc.Type = Type; } - operator const D3D12_STATE_OBJECT_DESC&() - { - // Do final preparation work - m_RepointedAssociations.clear(); - m_SubobjectArray.clear(); - m_SubobjectArray.reserve(m_Desc.NumSubobjects); - // Flatten subobjects into an array (each flattened subobject still has a - // member that's a pointer to its desc that's not flattened) - for (auto Iter = m_SubobjectList.begin(); - Iter != m_SubobjectList.end(); Iter++) - { - m_SubobjectArray.push_back(*Iter); - // Store new location in array so we can redirect pointers contained in subobjects - Iter->pSubobjectArrayLocation = &m_SubobjectArray.back(); - } - // For subobjects with pointer fields, create a new copy of those subobject definitions - // with fixed pointers - for (UINT i = 0; i < m_Desc.NumSubobjects; i++) - { - if (m_SubobjectArray[i].Type == D3D12_STATE_SUBOBJECT_TYPE_SUBOBJECT_TO_EXPORTS_ASSOCIATION) - { - auto pOriginalSubobjectAssociation = - static_cast(m_SubobjectArray[i].pDesc); - D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION Repointed = *pOriginalSubobjectAssociation; - auto pWrapper = - static_cast(pOriginalSubobjectAssociation->pSubobjectToAssociate); - Repointed.pSubobjectToAssociate = pWrapper->pSubobjectArrayLocation; - m_RepointedAssociations.push_back(Repointed); - m_SubobjectArray[i].pDesc = &m_RepointedAssociations.back(); - } - } - // Below: using ugly way to get pointer in case .data() is not defined - m_Desc.pSubobjects = m_Desc.NumSubobjects ? &m_SubobjectArray[0] : nullptr; - return m_Desc; - } - operator const D3D12_STATE_OBJECT_DESC*() - { - // Cast calls the above final preparation work - return &static_cast(*this); - } - - // CreateSubobject creates a sububject helper (e.g. CD3DX12_HIT_GROUP_SUBOBJECT) - // whose lifetime is owned by this class. - // e.g. - // - // CD3DX12_STATE_OBJECT_DESC Collection1(D3D12_STATE_OBJECT_TYPE_COLLECTION); - // auto Lib0 = Collection1.CreateSubobject(); - // Lib0->SetDXILLibrary(&pMyAppDxilLibs[0]); - // Lib0->DefineExport(L"rayGenShader0"); // in practice these export listings might be - // // data/engine driven - // etc. - // - // Alternatively, users can instantiate sububject helpers explicitly, such as via local - // variables instead, passing the state object desc that should point to it into the helper - // constructor (or call mySubobjectHelper.AddToStateObject(Collection1)). - // In this alternative scenario, the user must keep the subobject alive as long as the state - // object it is associated with is alive, else its pointer references will be stale. - // e.g. - // - // CD3DX12_STATE_OBJECT_DESC RaytracingState2(D3D12_STATE_OBJECT_TYPE_RAYTRACING_PIPELINE); - // CD3DX12_DXIL_LIBRARY_SUBOBJECT LibA(RaytracingState2); - // LibA.SetDXILLibrary(&pMyAppDxilLibs[4]); // not manually specifying exports - // // - meaning all exports in the libraries - // // are exported - // etc. - - template - T* CreateSubobject() - { - T* pSubobject = new T(*this); - m_OwnedSubobjectHelpers.emplace_back(pSubobject); - return pSubobject; - } - -private: - D3D12_STATE_SUBOBJECT* TrackSubobject(D3D12_STATE_SUBOBJECT_TYPE Type, void* pDesc) - { - SUBOBJECT_WRAPPER Subobject; - Subobject.pSubobjectArrayLocation = nullptr; - Subobject.Type = Type; - Subobject.pDesc = pDesc; - m_SubobjectList.push_back(Subobject); - m_Desc.NumSubobjects++; - return &m_SubobjectList.back(); - } - void Init(D3D12_STATE_OBJECT_TYPE Type) noexcept - { - SetStateObjectType(Type); - m_Desc.pSubobjects = nullptr; - m_Desc.NumSubobjects = 0; - m_SubobjectList.clear(); - m_SubobjectArray.clear(); - m_RepointedAssociations.clear(); - } - typedef struct SUBOBJECT_WRAPPER : public D3D12_STATE_SUBOBJECT - { - D3D12_STATE_SUBOBJECT* pSubobjectArrayLocation; // new location when flattened into array - // for repointing pointers in subobjects - } SUBOBJECT_WRAPPER; - D3D12_STATE_OBJECT_DESC m_Desc; - std::list m_SubobjectList; // Pointers to list nodes handed out so - // these can be edited live - std::vector m_SubobjectArray; // Built at the end, copying list contents - - std::list - m_RepointedAssociations; // subobject type that contains pointers to other subobjects, - // repointed to flattened array - - class StringContainer - { - public: - LPCWSTR LocalCopy(LPCWSTR string, bool bSingleString = false) - { - if (string) - { - if (bSingleString) - { - m_Strings.clear(); - m_Strings.push_back(string); - } - else - { - m_Strings.push_back(string); - } - return m_Strings.back().c_str(); - } - else - { - return nullptr; - } - } - void clear() noexcept { m_Strings.clear(); } - private: - std::list m_Strings; - }; - - class SUBOBJECT_HELPER_BASE - { - public: - SUBOBJECT_HELPER_BASE() noexcept { Init(); } - virtual ~SUBOBJECT_HELPER_BASE() = default; - virtual D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept = 0; - void AddToStateObject(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - m_pSubobject = ContainingStateObject.TrackSubobject(Type(), Data()); - } - protected: - virtual void* Data() noexcept = 0; - void Init() noexcept { m_pSubobject = nullptr; } - D3D12_STATE_SUBOBJECT* m_pSubobject; - }; - -#if(__cplusplus >= 201103L) - std::list> m_OwnedSubobjectHelpers; -#else - class OWNED_HELPER - { - public: - OWNED_HELPER(const SUBOBJECT_HELPER_BASE* pHelper) noexcept { m_pHelper = pHelper; } - ~OWNED_HELPER() { delete m_pHelper; } - const SUBOBJECT_HELPER_BASE* m_pHelper; - }; - - std::list m_OwnedSubobjectHelpers; -#endif - - friend class CD3DX12_DXIL_LIBRARY_SUBOBJECT; - friend class CD3DX12_EXISTING_COLLECTION_SUBOBJECT; - friend class CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT; - friend class CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION; - friend class CD3DX12_HIT_GROUP_SUBOBJECT; - friend class CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT; - friend class CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT; - friend class CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT; - friend class CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT; - friend class CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT; - friend class CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT; - friend class CD3DX12_NODE_MASK_SUBOBJECT; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_DXIL_LIBRARY_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_DXIL_LIBRARY_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_DXIL_LIBRARY_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void SetDXILLibrary(const D3D12_SHADER_BYTECODE* pCode) noexcept - { - static const D3D12_SHADER_BYTECODE Default = {}; - m_Desc.DXILLibrary = pCode ? *pCode : Default; - } - void DefineExport( - LPCWSTR Name, - LPCWSTR ExportToRename = nullptr, - D3D12_EXPORT_FLAGS Flags = D3D12_EXPORT_FLAG_NONE) - { - D3D12_EXPORT_DESC Export; - Export.Name = m_Strings.LocalCopy(Name); - Export.ExportToRename = m_Strings.LocalCopy(ExportToRename); - Export.Flags = Flags; - m_Exports.push_back(Export); - m_Desc.pExports = &m_Exports[0]; // using ugly way to get pointer in case .data() is not defined - m_Desc.NumExports = static_cast(m_Exports.size()); - } - template - void DefineExports(LPCWSTR(&Exports)[N]) - { - for (UINT i = 0; i < N; i++) - { - DefineExport(Exports[i]); - } - } - void DefineExports(const LPCWSTR* Exports, UINT N) - { - for (UINT i = 0; i < N; i++) - { - DefineExport(Exports[i]); - } - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_DXIL_LIBRARY; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator const D3D12_DXIL_LIBRARY_DESC&() const noexcept { return m_Desc; } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_Desc = {}; - m_Strings.clear(); - m_Exports.clear(); - } - void* Data() noexcept override { return &m_Desc; } - D3D12_DXIL_LIBRARY_DESC m_Desc; - CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings; - std::vector m_Exports; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_EXISTING_COLLECTION_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_EXISTING_COLLECTION_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_EXISTING_COLLECTION_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void SetExistingCollection(ID3D12StateObject*pExistingCollection) noexcept - { - m_Desc.pExistingCollection = pExistingCollection; - m_CollectionRef = pExistingCollection; - } - void DefineExport( - LPCWSTR Name, - LPCWSTR ExportToRename = nullptr, - D3D12_EXPORT_FLAGS Flags = D3D12_EXPORT_FLAG_NONE) - { - D3D12_EXPORT_DESC Export; - Export.Name = m_Strings.LocalCopy(Name); - Export.ExportToRename = m_Strings.LocalCopy(ExportToRename); - Export.Flags = Flags; - m_Exports.push_back(Export); - m_Desc.pExports = &m_Exports[0]; // using ugly way to get pointer in case .data() is not defined - m_Desc.NumExports = static_cast(m_Exports.size()); - } - template - void DefineExports(LPCWSTR(&Exports)[N]) - { - for (UINT i = 0; i < N; i++) - { - DefineExport(Exports[i]); - } - } - void DefineExports(const LPCWSTR* Exports, UINT N) - { - for (UINT i = 0; i < N; i++) - { - DefineExport(Exports[i]); - } - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_EXISTING_COLLECTION; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator const D3D12_EXISTING_COLLECTION_DESC&() const noexcept { return m_Desc; } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_Desc = {}; - m_CollectionRef = nullptr; - m_Strings.clear(); - m_Exports.clear(); - } - void* Data() noexcept override { return &m_Desc; } - D3D12_EXISTING_COLLECTION_DESC m_Desc; - D3DX12_COM_PTR m_CollectionRef; - CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings; - std::vector m_Exports; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_SUBOBJECT_TO_EXPORTS_ASSOCIATION_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void SetSubobjectToAssociate(const D3D12_STATE_SUBOBJECT& SubobjectToAssociate) noexcept - { - m_Desc.pSubobjectToAssociate = &SubobjectToAssociate; - } - void AddExport(LPCWSTR Export) - { - m_Desc.NumExports++; - m_Exports.push_back(m_Strings.LocalCopy(Export)); - m_Desc.pExports = &m_Exports[0]; // using ugly way to get pointer in case .data() is not defined - } - template - void AddExports(LPCWSTR (&Exports)[N]) - { - for (UINT i = 0; i < N; i++) - { - AddExport(Exports[i]); - } - } - void AddExports(const LPCWSTR* Exports, UINT N) - { - for (UINT i = 0; i < N; i++) - { - AddExport(Exports[i]); - } - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_SUBOBJECT_TO_EXPORTS_ASSOCIATION; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator const D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION&() const noexcept { return m_Desc; } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_Desc = {}; - m_Strings.clear(); - m_Exports.clear(); - } - void* Data() noexcept override { return &m_Desc; } - D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION m_Desc; - CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings; - std::vector m_Exports; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION() noexcept - { - Init(); - } - CD3DX12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void SetSubobjectNameToAssociate(LPCWSTR SubobjectToAssociate) - { - m_Desc.SubobjectToAssociate = m_SubobjectName.LocalCopy(SubobjectToAssociate, true); - } - void AddExport(LPCWSTR Export) - { - m_Desc.NumExports++; - m_Exports.push_back(m_Strings.LocalCopy(Export)); - m_Desc.pExports = &m_Exports[0]; // using ugly way to get pointer in case .data() is not defined - } - template - void AddExports(LPCWSTR (&Exports)[N]) - { - for (UINT i = 0; i < N; i++) - { - AddExport(Exports[i]); - } - } - void AddExports(const LPCWSTR* Exports, UINT N) - { - for (UINT i = 0; i < N; i++) - { - AddExport(Exports[i]); - } - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator const D3D12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION&() const noexcept { return m_Desc; } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_Desc = {}; - m_Strings.clear(); - m_SubobjectName.clear(); - m_Exports.clear(); - } - void* Data() noexcept override { return &m_Desc; } - D3D12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION m_Desc; - CD3DX12_STATE_OBJECT_DESC::StringContainer m_Strings; - CD3DX12_STATE_OBJECT_DESC::StringContainer m_SubobjectName; - std::vector m_Exports; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_HIT_GROUP_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_HIT_GROUP_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_HIT_GROUP_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void SetHitGroupExport(LPCWSTR exportName) - { - m_Desc.HitGroupExport = m_Strings[0].LocalCopy(exportName, true); - } - void SetHitGroupType(D3D12_HIT_GROUP_TYPE Type) noexcept { m_Desc.Type = Type; } - void SetAnyHitShaderImport(LPCWSTR importName) - { - m_Desc.AnyHitShaderImport = m_Strings[1].LocalCopy(importName, true); - } - void SetClosestHitShaderImport(LPCWSTR importName) - { - m_Desc.ClosestHitShaderImport = m_Strings[2].LocalCopy(importName, true); - } - void SetIntersectionShaderImport(LPCWSTR importName) - { - m_Desc.IntersectionShaderImport = m_Strings[3].LocalCopy(importName, true); - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_HIT_GROUP; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator const D3D12_HIT_GROUP_DESC&() const noexcept { return m_Desc; } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_Desc = {}; - for (UINT i = 0; i < m_NumStrings; i++) - { - m_Strings[i].clear(); - } - } - void* Data() noexcept override { return &m_Desc; } - D3D12_HIT_GROUP_DESC m_Desc; - static constexpr UINT m_NumStrings = 4; - CD3DX12_STATE_OBJECT_DESC::StringContainer - m_Strings[m_NumStrings]; // one string for every entrypoint name -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_RAYTRACING_SHADER_CONFIG_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void Config(UINT MaxPayloadSizeInBytes, UINT MaxAttributeSizeInBytes) noexcept - { - m_Desc.MaxPayloadSizeInBytes = MaxPayloadSizeInBytes; - m_Desc.MaxAttributeSizeInBytes = MaxAttributeSizeInBytes; - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_SHADER_CONFIG; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator const D3D12_RAYTRACING_SHADER_CONFIG&() const noexcept { return m_Desc; } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_Desc = {}; - } - void* Data() noexcept override { return &m_Desc; } - D3D12_RAYTRACING_SHADER_CONFIG m_Desc; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_RAYTRACING_PIPELINE_CONFIG_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void Config(UINT MaxTraceRecursionDepth) noexcept - { - m_Desc.MaxTraceRecursionDepth = MaxTraceRecursionDepth; - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_PIPELINE_CONFIG; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator const D3D12_RAYTRACING_PIPELINE_CONFIG&() const noexcept { return m_Desc; } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_Desc = {}; - } - void* Data() noexcept override { return &m_Desc; } - D3D12_RAYTRACING_PIPELINE_CONFIG m_Desc; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_RAYTRACING_PIPELINE_CONFIG1_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void Config(UINT MaxTraceRecursionDepth, D3D12_RAYTRACING_PIPELINE_FLAGS Flags) noexcept - { - m_Desc.MaxTraceRecursionDepth = MaxTraceRecursionDepth; - m_Desc.Flags = Flags; - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_PIPELINE_CONFIG1; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator const D3D12_RAYTRACING_PIPELINE_CONFIG1&() const noexcept { return m_Desc; } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_Desc = {}; - } - void* Data() noexcept override { return &m_Desc; } - D3D12_RAYTRACING_PIPELINE_CONFIG1 m_Desc; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_GLOBAL_ROOT_SIGNATURE_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void SetRootSignature(ID3D12RootSignature* pRootSig) noexcept - { - m_pRootSig = pRootSig; - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_GLOBAL_ROOT_SIGNATURE; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator ID3D12RootSignature*() const noexcept { return D3DX12_COM_PTR_GET(m_pRootSig); } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_pRootSig = nullptr; - } - void* Data() noexcept override { return D3DX12_COM_PTR_ADDRESSOF(m_pRootSig); } - D3DX12_COM_PTR m_pRootSig; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_LOCAL_ROOT_SIGNATURE_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void SetRootSignature(ID3D12RootSignature* pRootSig) noexcept - { - m_pRootSig = pRootSig; - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_LOCAL_ROOT_SIGNATURE; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator ID3D12RootSignature*() const noexcept { return D3DX12_COM_PTR_GET(m_pRootSig); } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_pRootSig = nullptr; - } - void* Data() noexcept override { return D3DX12_COM_PTR_ADDRESSOF(m_pRootSig); } - D3DX12_COM_PTR m_pRootSig; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_STATE_OBJECT_CONFIG_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void SetFlags(D3D12_STATE_OBJECT_FLAGS Flags) noexcept - { - m_Desc.Flags = Flags; - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_STATE_OBJECT_CONFIG; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator const D3D12_STATE_OBJECT_CONFIG&() const noexcept { return m_Desc; } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_Desc = {}; - } - void* Data() noexcept override { return &m_Desc; } - D3D12_STATE_OBJECT_CONFIG m_Desc; -}; - -//------------------------------------------------------------------------------------------------ -class CD3DX12_NODE_MASK_SUBOBJECT - : public CD3DX12_STATE_OBJECT_DESC::SUBOBJECT_HELPER_BASE -{ -public: - CD3DX12_NODE_MASK_SUBOBJECT() noexcept - { - Init(); - } - CD3DX12_NODE_MASK_SUBOBJECT(CD3DX12_STATE_OBJECT_DESC& ContainingStateObject) - { - Init(); - AddToStateObject(ContainingStateObject); - } - void SetNodeMask(UINT NodeMask) noexcept - { - m_Desc.NodeMask = NodeMask; - } - D3D12_STATE_SUBOBJECT_TYPE Type() const noexcept override - { - return D3D12_STATE_SUBOBJECT_TYPE_NODE_MASK; - } - operator const D3D12_STATE_SUBOBJECT&() const noexcept { return *m_pSubobject; } - operator const D3D12_NODE_MASK&() const noexcept { return m_Desc; } -private: - void Init() noexcept - { - SUBOBJECT_HELPER_BASE::Init(); - m_Desc = {}; - } - void* Data() noexcept override { return &m_Desc; } - D3D12_NODE_MASK m_Desc; -}; - -#endif // !D3DX12_NO_STATE_OBJECT_HELPERS - - -#if defined(NTDDI_WIN10_NI) || defined(USING_D3D12_AGILITY_SDK) - -//================================================================================================ -// D3DX12 Enhanced Barrier Helpers -//================================================================================================ - -class CD3DX12_BARRIER_SUBRESOURCE_RANGE : public D3D12_BARRIER_SUBRESOURCE_RANGE -{ -public: - CD3DX12_BARRIER_SUBRESOURCE_RANGE() = default; - CD3DX12_BARRIER_SUBRESOURCE_RANGE(const D3D12_BARRIER_SUBRESOURCE_RANGE &o) noexcept : - D3D12_BARRIER_SUBRESOURCE_RANGE(o) - {} - explicit CD3DX12_BARRIER_SUBRESOURCE_RANGE(UINT Subresource) noexcept : - D3D12_BARRIER_SUBRESOURCE_RANGE{ Subresource, 0, 0, 0, 0, 0 } - {} - CD3DX12_BARRIER_SUBRESOURCE_RANGE( - UINT FirstMipLevel, - UINT NumMips, - UINT FirstArraySlice, - UINT NumArraySlices, - UINT FirstPlane = 0, - UINT NumPlanes = 1) noexcept : - D3D12_BARRIER_SUBRESOURCE_RANGE - { - FirstMipLevel, - NumMips, - FirstArraySlice, - NumArraySlices, - FirstPlane, - NumPlanes - } - {} -}; - -class CD3DX12_GLOBAL_BARRIER : public D3D12_GLOBAL_BARRIER -{ -public: - CD3DX12_GLOBAL_BARRIER() = default; - CD3DX12_GLOBAL_BARRIER(const D3D12_GLOBAL_BARRIER &o) noexcept : D3D12_GLOBAL_BARRIER(o){} - CD3DX12_GLOBAL_BARRIER( - D3D12_BARRIER_SYNC syncBefore, - D3D12_BARRIER_SYNC syncAfter, - D3D12_BARRIER_ACCESS accessBefore, - D3D12_BARRIER_ACCESS accessAfter) noexcept : D3D12_GLOBAL_BARRIER { - syncBefore, - syncAfter, - accessBefore, - accessAfter - } - {} -}; - -class CD3DX12_BUFFER_BARRIER : public D3D12_BUFFER_BARRIER -{ -public: - CD3DX12_BUFFER_BARRIER() = default; - CD3DX12_BUFFER_BARRIER(const D3D12_BUFFER_BARRIER &o) noexcept : D3D12_BUFFER_BARRIER(o){} - CD3DX12_BUFFER_BARRIER( - D3D12_BARRIER_SYNC syncBefore, - D3D12_BARRIER_SYNC syncAfter, - D3D12_BARRIER_ACCESS accessBefore, - D3D12_BARRIER_ACCESS accessAfter, - ID3D12Resource *pRes) noexcept : D3D12_BUFFER_BARRIER { - syncBefore, - syncAfter, - accessBefore, - accessAfter, - pRes, - 0, ULLONG_MAX - } - {} -}; - -class CD3DX12_TEXTURE_BARRIER : public D3D12_TEXTURE_BARRIER -{ -public: - CD3DX12_TEXTURE_BARRIER() = default; - CD3DX12_TEXTURE_BARRIER(const D3D12_TEXTURE_BARRIER &o) noexcept : D3D12_TEXTURE_BARRIER(o){} - CD3DX12_TEXTURE_BARRIER( - D3D12_BARRIER_SYNC syncBefore, - D3D12_BARRIER_SYNC syncAfter, - D3D12_BARRIER_ACCESS accessBefore, - D3D12_BARRIER_ACCESS accessAfter, - D3D12_BARRIER_LAYOUT layoutBefore, - D3D12_BARRIER_LAYOUT layoutAfter, - ID3D12Resource *pRes, - const D3D12_BARRIER_SUBRESOURCE_RANGE &subresources, - D3D12_TEXTURE_BARRIER_FLAGS flag = D3D12_TEXTURE_BARRIER_FLAG_NONE) noexcept : D3D12_TEXTURE_BARRIER { - syncBefore, - syncAfter, - accessBefore, - accessAfter, - layoutBefore, - layoutAfter, - pRes, - subresources, - flag - } - {} -}; - -class CD3DX12_BARRIER_GROUP : public D3D12_BARRIER_GROUP -{ -public: - CD3DX12_BARRIER_GROUP() = default; - CD3DX12_BARRIER_GROUP(const D3D12_BARRIER_GROUP &o) noexcept : D3D12_BARRIER_GROUP(o){} - CD3DX12_BARRIER_GROUP(UINT32 numBarriers, const D3D12_BUFFER_BARRIER *pBarriers) noexcept - { - Type = D3D12_BARRIER_TYPE_BUFFER; - NumBarriers = numBarriers; - pBufferBarriers = pBarriers; - } - CD3DX12_BARRIER_GROUP(UINT32 numBarriers, const D3D12_TEXTURE_BARRIER *pBarriers) noexcept - { - Type = D3D12_BARRIER_TYPE_TEXTURE; - NumBarriers = numBarriers; - pTextureBarriers = pBarriers; - } - CD3DX12_BARRIER_GROUP(UINT32 numBarriers, const D3D12_GLOBAL_BARRIER *pBarriers) noexcept - { - Type = D3D12_BARRIER_TYPE_GLOBAL; - NumBarriers = numBarriers; - pGlobalBarriers = pBarriers; - } -}; - -#endif // NTDDI_WIN10_NI || USING_D3D12_AGILITY_SDK - - -#if (defined(NTDDI_WIN10_CO) || defined(USING_D3D12_AGILITY_SDK)) && !defined(D3DX12_NO_CHECK_FEATURE_SUPPORT_CLASS) - -//================================================================================================ -// D3DX12 Check Feature Support -//================================================================================================ - -#include - -class CD3DX12FeatureSupport -{ -public: // Function declaration - // Default constructor that creates an empty object - CD3DX12FeatureSupport() noexcept; - - // Initialize data from the given device - HRESULT Init(ID3D12Device* pDevice); - - // Retreives the status of the object. If an error occurred in the initialization process, the function returns the error code. - HRESULT GetStatus() const noexcept { return m_hStatus; } - - // Getter functions for each feature class - // D3D12_OPTIONS - BOOL DoublePrecisionFloatShaderOps() const noexcept; - BOOL OutputMergerLogicOp() const noexcept; - D3D12_SHADER_MIN_PRECISION_SUPPORT MinPrecisionSupport() const noexcept; - D3D12_TILED_RESOURCES_TIER TiledResourcesTier() const noexcept; - D3D12_RESOURCE_BINDING_TIER ResourceBindingTier() const noexcept; - BOOL PSSpecifiedStencilRefSupported() const noexcept; - BOOL TypedUAVLoadAdditionalFormats() const noexcept; - BOOL ROVsSupported() const noexcept; - D3D12_CONSERVATIVE_RASTERIZATION_TIER ConservativeRasterizationTier() const noexcept; - BOOL StandardSwizzle64KBSupported() const noexcept; - BOOL CrossAdapterRowMajorTextureSupported() const noexcept; - BOOL VPAndRTArrayIndexFromAnyShaderFeedingRasterizerSupportedWithoutGSEmulation() const noexcept; - D3D12_RESOURCE_HEAP_TIER ResourceHeapTier() const noexcept; - D3D12_CROSS_NODE_SHARING_TIER CrossNodeSharingTier() const noexcept; - UINT MaxGPUVirtualAddressBitsPerResource() const noexcept; - - // FEATURE_LEVELS - D3D_FEATURE_LEVEL MaxSupportedFeatureLevel() const noexcept; - - // FORMAT_SUPPORT - HRESULT FormatSupport(DXGI_FORMAT Format, D3D12_FORMAT_SUPPORT1& Support1, D3D12_FORMAT_SUPPORT2& Support2) const; - - // MUTLTISAMPLE_QUALITY_LEVELS - HRESULT MultisampleQualityLevels(DXGI_FORMAT Format, UINT SampleCount, D3D12_MULTISAMPLE_QUALITY_LEVEL_FLAGS Flags, UINT& NumQualityLevels) const; - - // FORMAT_INFO - HRESULT FormatInfo(DXGI_FORMAT Format, UINT8& PlaneCount) const; - - // GPU_VIRTUAL_ADDRESS_SUPPORT - UINT MaxGPUVirtualAddressBitsPerProcess() const noexcept; - - // SHADER_MODEL - D3D_SHADER_MODEL HighestShaderModel() const noexcept; - - // D3D12_OPTIONS1 - BOOL WaveOps() const noexcept; - UINT WaveLaneCountMin() const noexcept; - UINT WaveLaneCountMax() const noexcept; - UINT TotalLaneCount() const noexcept; - BOOL ExpandedComputeResourceStates() const noexcept; - BOOL Int64ShaderOps() const noexcept; - - // PROTECTED_RESOURCE_SESSION_SUPPORT - D3D12_PROTECTED_RESOURCE_SESSION_SUPPORT_FLAGS ProtectedResourceSessionSupport(UINT NodeIndex = 0) const; - - // ROOT_SIGNATURE - D3D_ROOT_SIGNATURE_VERSION HighestRootSignatureVersion() const noexcept; - - // ARCHITECTURE1 - BOOL TileBasedRenderer(UINT NodeIndex = 0) const; - BOOL UMA(UINT NodeIndex = 0) const; - BOOL CacheCoherentUMA(UINT NodeIndex = 0) const; - BOOL IsolatedMMU(UINT NodeIndex = 0) const; - - // D3D12_OPTIONS2 - BOOL DepthBoundsTestSupported() const noexcept; - D3D12_PROGRAMMABLE_SAMPLE_POSITIONS_TIER ProgrammableSamplePositionsTier() const noexcept; - - // SHADER_CACHE - D3D12_SHADER_CACHE_SUPPORT_FLAGS ShaderCacheSupportFlags() const noexcept; - - // COMMAND_QUEUE_PRIORITY - BOOL CommandQueuePrioritySupported(D3D12_COMMAND_LIST_TYPE CommandListType, UINT Priority); - - // D3D12_OPTIONS3 - BOOL CopyQueueTimestampQueriesSupported() const noexcept; - BOOL CastingFullyTypedFormatSupported() const noexcept; - D3D12_COMMAND_LIST_SUPPORT_FLAGS WriteBufferImmediateSupportFlags() const noexcept; - D3D12_VIEW_INSTANCING_TIER ViewInstancingTier() const noexcept; - BOOL BarycentricsSupported() const noexcept; - - // EXISTING_HEAPS - BOOL ExistingHeapsSupported() const noexcept; - - // D3D12_OPTIONS4 - BOOL MSAA64KBAlignedTextureSupported() const noexcept; - D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER SharedResourceCompatibilityTier() const noexcept; - BOOL Native16BitShaderOpsSupported() const noexcept; - - // SERIALIZATION - D3D12_HEAP_SERIALIZATION_TIER HeapSerializationTier(UINT NodeIndex = 0) const; - - // CROSS_NODE - // CrossNodeSharingTier handled in D3D12Options - BOOL CrossNodeAtomicShaderInstructions() const noexcept; - - // D3D12_OPTIONS5 - BOOL SRVOnlyTiledResourceTier3() const noexcept; - D3D12_RENDER_PASS_TIER RenderPassesTier() const noexcept; - D3D12_RAYTRACING_TIER RaytracingTier() const noexcept; - - // DISPLAYABLE - BOOL DisplayableTexture() const noexcept; - // SharedResourceCompatibilityTier handled in D3D12Options4 - - // D3D12_OPTIONS6 - BOOL AdditionalShadingRatesSupported() const noexcept; - BOOL PerPrimitiveShadingRateSupportedWithViewportIndexing() const noexcept; - D3D12_VARIABLE_SHADING_RATE_TIER VariableShadingRateTier() const noexcept; - UINT ShadingRateImageTileSize() const noexcept; - BOOL BackgroundProcessingSupported() const noexcept; - - // QUERY_META_COMMAND - HRESULT QueryMetaCommand(D3D12_FEATURE_DATA_QUERY_META_COMMAND& dQueryMetaCommand) const; - - // D3D12_OPTIONS7 - D3D12_MESH_SHADER_TIER MeshShaderTier() const noexcept; - D3D12_SAMPLER_FEEDBACK_TIER SamplerFeedbackTier() const noexcept; - - // PROTECTED_RESOURCE_SESSION_TYPE_COUNT - UINT ProtectedResourceSessionTypeCount(UINT NodeIndex = 0) const; - - // PROTECTED_RESOURCE_SESSION_TYPES - std::vector ProtectedResourceSessionTypes(UINT NodeIndex = 0) const; - - // D3D12_OPTIONS8 - BOOL UnalignedBlockTexturesSupported() const noexcept; - - // D3D12_OPTIONS9 - BOOL MeshShaderPipelineStatsSupported() const noexcept; - BOOL MeshShaderSupportsFullRangeRenderTargetArrayIndex() const noexcept; - BOOL AtomicInt64OnTypedResourceSupported() const noexcept; - BOOL AtomicInt64OnGroupSharedSupported() const noexcept; - BOOL DerivativesInMeshAndAmplificationShadersSupported() const noexcept; - D3D12_WAVE_MMA_TIER WaveMMATier() const noexcept; - - // D3D12_OPTIONS10 - BOOL VariableRateShadingSumCombinerSupported() const noexcept; - BOOL MeshShaderPerPrimitiveShadingRateSupported() const noexcept; - - // D3D12_OPTIONS11 - BOOL AtomicInt64OnDescriptorHeapResourceSupported() const noexcept; - - -#if defined(NTDDI_WIN10_NI) || defined(USING_D3D12_AGILITY_SDK) - // D3D12_OPTIONS12 - D3D12_TRI_STATE MSPrimitivesPipelineStatisticIncludesCulledPrimitives() const noexcept; - BOOL EnhancedBarriersSupported() const noexcept; - BOOL RelaxedFormatCastingSupported() const noexcept; - - // D3D12_OPTIONS13 - BOOL UnrestrictedBufferTextureCopyPitchSupported() const noexcept; - BOOL UnrestrictedVertexElementAlignmentSupported() const noexcept; - BOOL InvertedViewportHeightFlipsYSupported() const noexcept; - BOOL InvertedViewportDepthFlipsZSupported() const noexcept; - BOOL TextureCopyBetweenDimensionsSupported() const noexcept; - BOOL AlphaBlendFactorSupported() const noexcept; -#endif - -private: // Private structs and helpers declaration - struct ProtectedResourceSessionTypesLocal : D3D12_FEATURE_DATA_PROTECTED_RESOURCE_SESSION_TYPES - { - std::vector TypeVec; - }; - - // Helper function to decide the highest shader model supported by the system - // Stores the result in m_dShaderModel - // Must be updated whenever a new shader model is added to the d3d12.h header - HRESULT QueryHighestShaderModel(); - - // Helper function to decide the highest root signature supported - // Must be updated whenever a new root signature version is added to the d3d12.h header - HRESULT QueryHighestRootSignatureVersion(); - - // Helper funcion to decide the highest feature level - HRESULT QueryHighestFeatureLevel(); - - // Helper function to initialize local protected resource session types structs - HRESULT QueryProtectedResourceSessionTypes(UINT NodeIndex, UINT Count); - -private: // Member data - // Pointer to the underlying device - ID3D12Device* m_pDevice; - - // Stores the error code from initialization - HRESULT m_hStatus; - - // Feature support data structs - D3D12_FEATURE_DATA_D3D12_OPTIONS m_dOptions; - D3D_FEATURE_LEVEL m_eMaxFeatureLevel; - D3D12_FEATURE_DATA_GPU_VIRTUAL_ADDRESS_SUPPORT m_dGPUVASupport; - D3D12_FEATURE_DATA_SHADER_MODEL m_dShaderModel; - D3D12_FEATURE_DATA_D3D12_OPTIONS1 m_dOptions1; - std::vector m_dProtectedResourceSessionSupport; - D3D12_FEATURE_DATA_ROOT_SIGNATURE m_dRootSignature; - std::vector m_dArchitecture1; - D3D12_FEATURE_DATA_D3D12_OPTIONS2 m_dOptions2; - D3D12_FEATURE_DATA_SHADER_CACHE m_dShaderCache; - D3D12_FEATURE_DATA_COMMAND_QUEUE_PRIORITY m_dCommandQueuePriority; - D3D12_FEATURE_DATA_D3D12_OPTIONS3 m_dOptions3; - D3D12_FEATURE_DATA_EXISTING_HEAPS m_dExistingHeaps; - D3D12_FEATURE_DATA_D3D12_OPTIONS4 m_dOptions4; - std::vector m_dSerialization; // Cat2 NodeIndex - D3D12_FEATURE_DATA_CROSS_NODE m_dCrossNode; - D3D12_FEATURE_DATA_D3D12_OPTIONS5 m_dOptions5; - D3D12_FEATURE_DATA_DISPLAYABLE m_dDisplayable; - D3D12_FEATURE_DATA_D3D12_OPTIONS6 m_dOptions6; - D3D12_FEATURE_DATA_D3D12_OPTIONS7 m_dOptions7; - std::vector m_dProtectedResourceSessionTypeCount; // Cat2 NodeIndex - std::vector m_dProtectedResourceSessionTypes; // Cat3 - D3D12_FEATURE_DATA_D3D12_OPTIONS8 m_dOptions8; - D3D12_FEATURE_DATA_D3D12_OPTIONS9 m_dOptions9; - D3D12_FEATURE_DATA_D3D12_OPTIONS10 m_dOptions10; - D3D12_FEATURE_DATA_D3D12_OPTIONS11 m_dOptions11; -#if defined(NTDDI_WIN10_NI) || defined(USING_D3D12_AGILITY_SDK) - D3D12_FEATURE_DATA_D3D12_OPTIONS12 m_dOptions12; - D3D12_FEATURE_DATA_D3D12_OPTIONS13 m_dOptions13; -#endif -}; - -// Implementations for CD3DX12FeatureSupport functions - -// Macro to set up a getter function for each entry in feature support data -// The getter function will have the same name as the feature option name -#define FEATURE_SUPPORT_GET(RETTYPE,FEATURE,OPTION) \ -inline RETTYPE CD3DX12FeatureSupport::OPTION() const noexcept \ -{ \ - return FEATURE.OPTION; \ -} - -// Macro to set up a getter function for each entry in feature support data -// Also specifies the name for the function which can be different from the feature name -#define FEATURE_SUPPORT_GET_NAME(RETTYPE,FEATURE,OPTION,NAME) \ -inline RETTYPE CD3DX12FeatureSupport::NAME() const noexcept \ -{\ - return FEATURE.OPTION; \ -} - -// Macro to set up a getter function for feature data indexed by the graphics node ID -// The default parameter is 0, or the first availabe graphics device node -#define FEATURE_SUPPORT_GET_NODE_INDEXED(RETTYPE,FEATURE,OPTION) \ -inline RETTYPE CD3DX12FeatureSupport::OPTION(UINT NodeIndex) const \ -{\ - return FEATURE[NodeIndex].OPTION; \ -} - -// Macro to set up a getter function for feature data indexed by NodeIndex -// Allows a custom name for the getter function -#define FEATURE_SUPPORT_GET_NODE_INDEXED_NAME(RETTYPE,FEATURE,OPTION,NAME) \ -inline RETTYPE CD3DX12FeatureSupport::NAME(UINT NodeIndex) const \ -{\ - return FEATURE[NodeIndex].OPTION; \ -} - -inline CD3DX12FeatureSupport::CD3DX12FeatureSupport() noexcept -: m_pDevice(nullptr) -, m_hStatus(E_INVALIDARG) -, m_dOptions{} -, m_eMaxFeatureLevel{} -, m_dGPUVASupport{} -, m_dShaderModel{} -, m_dOptions1{} -, m_dRootSignature{} -, m_dOptions2{} -, m_dShaderCache{} -, m_dCommandQueuePriority{} -, m_dOptions3{} -, m_dExistingHeaps{} -, m_dOptions4{} -, m_dCrossNode{} -, m_dOptions5{} -, m_dDisplayable{} -, m_dOptions6{} -, m_dOptions7{} -, m_dOptions8{} -, m_dOptions9{} -, m_dOptions10{} -, m_dOptions11{} -#if defined(NTDDI_WIN10_NI) || defined(USING_D3D12_AGILITY_SDK) -, m_dOptions12{} -, m_dOptions13{} -#endif -{} - -inline HRESULT CD3DX12FeatureSupport::Init(ID3D12Device* pDevice) -{ - if (!pDevice) - { - m_hStatus = E_INVALIDARG; - return m_hStatus; - } - - m_pDevice = pDevice; - - // Initialize static feature support data structures - if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS, &m_dOptions, sizeof(m_dOptions)))) - { - m_dOptions.DoublePrecisionFloatShaderOps = false; - m_dOptions.OutputMergerLogicOp = false; - m_dOptions.MinPrecisionSupport = D3D12_SHADER_MIN_PRECISION_SUPPORT_NONE; - m_dOptions.TiledResourcesTier = D3D12_TILED_RESOURCES_TIER_NOT_SUPPORTED; - m_dOptions.ResourceBindingTier = static_cast(0); - m_dOptions.PSSpecifiedStencilRefSupported = false; - m_dOptions.TypedUAVLoadAdditionalFormats = false; - m_dOptions.ROVsSupported = false; - m_dOptions.ConservativeRasterizationTier = D3D12_CONSERVATIVE_RASTERIZATION_TIER_NOT_SUPPORTED; - m_dOptions.MaxGPUVirtualAddressBitsPerResource = 0; - m_dOptions.StandardSwizzle64KBSupported = false; - m_dOptions.CrossNodeSharingTier = D3D12_CROSS_NODE_SHARING_TIER_NOT_SUPPORTED; - m_dOptions.CrossAdapterRowMajorTextureSupported = false; - m_dOptions.VPAndRTArrayIndexFromAnyShaderFeedingRasterizerSupportedWithoutGSEmulation = false; - m_dOptions.ResourceHeapTier = static_cast(0); - } - - if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_GPU_VIRTUAL_ADDRESS_SUPPORT, &m_dGPUVASupport, sizeof(m_dGPUVASupport)))) - { - m_dGPUVASupport.MaxGPUVirtualAddressBitsPerProcess = 0; - m_dGPUVASupport.MaxGPUVirtualAddressBitsPerResource = 0; - } - - if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS1, &m_dOptions1, sizeof(m_dOptions1)))) - { - m_dOptions1.WaveOps = false; - m_dOptions1.WaveLaneCountMax = 0; - m_dOptions1.WaveLaneCountMin = 0; - m_dOptions1.TotalLaneCount = 0; - m_dOptions1.ExpandedComputeResourceStates = 0; - m_dOptions1.Int64ShaderOps = 0; - } - - if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS2, &m_dOptions2, sizeof(m_dOptions2)))) - { - m_dOptions2.DepthBoundsTestSupported = false; - m_dOptions2.ProgrammableSamplePositionsTier = D3D12_PROGRAMMABLE_SAMPLE_POSITIONS_TIER_NOT_SUPPORTED; - } - - if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_SHADER_CACHE, &m_dShaderCache, sizeof(m_dShaderCache)))) - { - m_dShaderCache.SupportFlags = D3D12_SHADER_CACHE_SUPPORT_NONE; - } - - if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS3, &m_dOptions3, sizeof(m_dOptions3)))) - { - m_dOptions3.CopyQueueTimestampQueriesSupported = false; - m_dOptions3.CastingFullyTypedFormatSupported = false; - m_dOptions3.WriteBufferImmediateSupportFlags = D3D12_COMMAND_LIST_SUPPORT_FLAG_NONE; - m_dOptions3.ViewInstancingTier = D3D12_VIEW_INSTANCING_TIER_NOT_SUPPORTED; - m_dOptions3.BarycentricsSupported = false; - } - - if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_EXISTING_HEAPS, &m_dExistingHeaps, sizeof(m_dExistingHeaps)))) - { - m_dExistingHeaps.Supported = false; - } - - if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS4, &m_dOptions4, sizeof(m_dOptions4)))) - { - m_dOptions4.MSAA64KBAlignedTextureSupported = false; - m_dOptions4.Native16BitShaderOpsSupported = false; - m_dOptions4.SharedResourceCompatibilityTier = D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER_0; - } - - if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_CROSS_NODE, &m_dCrossNode, sizeof(m_dCrossNode)))) - { - m_dCrossNode.SharingTier = D3D12_CROSS_NODE_SHARING_TIER_NOT_SUPPORTED; - m_dCrossNode.AtomicShaderInstructions = false; - } - - if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS5, &m_dOptions5, sizeof(m_dOptions5)))) - { - m_dOptions5.SRVOnlyTiledResourceTier3 = false; - m_dOptions5.RenderPassesTier = D3D12_RENDER_PASS_TIER_0; - m_dOptions5.RaytracingTier = D3D12_RAYTRACING_TIER_NOT_SUPPORTED; - } - - if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_DISPLAYABLE, &m_dDisplayable, sizeof(m_dDisplayable)))) - { - m_dDisplayable.DisplayableTexture = false; - m_dDisplayable.SharedResourceCompatibilityTier = D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER_0; - } - - if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS6, &m_dOptions6, sizeof(m_dOptions6)))) - { - m_dOptions6.AdditionalShadingRatesSupported = false; - m_dOptions6.PerPrimitiveShadingRateSupportedWithViewportIndexing = false; - m_dOptions6.VariableShadingRateTier = D3D12_VARIABLE_SHADING_RATE_TIER_NOT_SUPPORTED; - m_dOptions6.ShadingRateImageTileSize = 0; - m_dOptions6.BackgroundProcessingSupported = false; - } - - if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS7, &m_dOptions7, sizeof(m_dOptions7)))) - { - m_dOptions7.MeshShaderTier = D3D12_MESH_SHADER_TIER_NOT_SUPPORTED; - m_dOptions7.SamplerFeedbackTier = D3D12_SAMPLER_FEEDBACK_TIER_NOT_SUPPORTED; - } - - if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS8, &m_dOptions8, sizeof(m_dOptions8)))) - { - m_dOptions8.UnalignedBlockTexturesSupported = false; - } - - if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS9, &m_dOptions9, sizeof(m_dOptions9)))) - { - m_dOptions9.MeshShaderPipelineStatsSupported = false; - m_dOptions9.MeshShaderSupportsFullRangeRenderTargetArrayIndex = false; - m_dOptions9.AtomicInt64OnGroupSharedSupported = false; - m_dOptions9.AtomicInt64OnTypedResourceSupported = false; - m_dOptions9.DerivativesInMeshAndAmplificationShadersSupported = false; - m_dOptions9.WaveMMATier = D3D12_WAVE_MMA_TIER_NOT_SUPPORTED; - } - - if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS10, &m_dOptions10, sizeof(m_dOptions10)))) - { - m_dOptions10.MeshShaderPerPrimitiveShadingRateSupported = false; - m_dOptions10.VariableRateShadingSumCombinerSupported = false; - } - - if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS11, &m_dOptions11, sizeof(m_dOptions11)))) - { - m_dOptions11.AtomicInt64OnDescriptorHeapResourceSupported = false; - } - -#if defined(NTDDI_WIN10_NI) || defined(USING_D3D12_AGILITY_SDK) - if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS12, &m_dOptions12, sizeof(m_dOptions12)))) - { - m_dOptions12.MSPrimitivesPipelineStatisticIncludesCulledPrimitives = D3D12_TRI_STATE::D3D12_TRI_STATE_UNKNOWN; - m_dOptions12.EnhancedBarriersSupported = false; - m_dOptions12.RelaxedFormatCastingSupported = false; - } - - if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS13, &m_dOptions13, sizeof(m_dOptions13)))) - { - m_dOptions13.UnrestrictedBufferTextureCopyPitchSupported = false; - m_dOptions13.UnrestrictedVertexElementAlignmentSupported = false; - m_dOptions13.InvertedViewportHeightFlipsYSupported = false; - m_dOptions13.InvertedViewportDepthFlipsZSupported = false; - m_dOptions13.TextureCopyBetweenDimensionsSupported = false; - m_dOptions13.AlphaBlendFactorSupported = false; - } -#endif - - // Initialize per-node feature support data structures - const UINT uNodeCount = m_pDevice->GetNodeCount(); - m_dProtectedResourceSessionSupport.resize(uNodeCount); - m_dArchitecture1.resize(uNodeCount); - m_dSerialization.resize(uNodeCount); - m_dProtectedResourceSessionTypeCount.resize(uNodeCount); - m_dProtectedResourceSessionTypes.resize(uNodeCount); - for (UINT NodeIndex = 0; NodeIndex < uNodeCount; NodeIndex++) - { - m_dProtectedResourceSessionSupport[NodeIndex].NodeIndex = NodeIndex; - if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_PROTECTED_RESOURCE_SESSION_SUPPORT, &m_dProtectedResourceSessionSupport[NodeIndex], sizeof(m_dProtectedResourceSessionSupport[NodeIndex])))) - { - m_dProtectedResourceSessionSupport[NodeIndex].Support = D3D12_PROTECTED_RESOURCE_SESSION_SUPPORT_FLAG_NONE; - } - - m_dArchitecture1[NodeIndex].NodeIndex = NodeIndex; - if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_ARCHITECTURE1, &m_dArchitecture1[NodeIndex], sizeof(m_dArchitecture1[NodeIndex])))) - { - D3D12_FEATURE_DATA_ARCHITECTURE dArchLocal = {}; - dArchLocal.NodeIndex = NodeIndex; - if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_ARCHITECTURE, &dArchLocal, sizeof(dArchLocal)))) - { - dArchLocal.TileBasedRenderer = false; - dArchLocal.UMA = false; - dArchLocal.CacheCoherentUMA = false; - } - - m_dArchitecture1[NodeIndex].TileBasedRenderer = dArchLocal.TileBasedRenderer; - m_dArchitecture1[NodeIndex].UMA = dArchLocal.UMA; - m_dArchitecture1[NodeIndex].CacheCoherentUMA = dArchLocal.CacheCoherentUMA; - m_dArchitecture1[NodeIndex].IsolatedMMU = false; - } - - m_dSerialization[NodeIndex].NodeIndex = NodeIndex; - if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_SERIALIZATION, &m_dSerialization[NodeIndex], sizeof(m_dSerialization[NodeIndex])))) - { - m_dSerialization[NodeIndex].HeapSerializationTier = D3D12_HEAP_SERIALIZATION_TIER_0; - } - - m_dProtectedResourceSessionTypeCount[NodeIndex].NodeIndex = NodeIndex; - if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_PROTECTED_RESOURCE_SESSION_TYPE_COUNT, &m_dProtectedResourceSessionTypeCount[NodeIndex], sizeof(m_dProtectedResourceSessionTypeCount[NodeIndex])))) - { - m_dProtectedResourceSessionTypeCount[NodeIndex].Count = 0; - } - - // Special procedure to initialize local protected resource session types structs - // Must wait until session type count initialized - QueryProtectedResourceSessionTypes(NodeIndex, m_dProtectedResourceSessionTypeCount[NodeIndex].Count); - } - - // Initialize features that requires highest version check - if (FAILED(m_hStatus = QueryHighestShaderModel())) - { - return m_hStatus; - } - - if (FAILED(m_hStatus = QueryHighestRootSignatureVersion())) - { - return m_hStatus; - } - - // Initialize Feature Levels data - if (FAILED(m_hStatus = QueryHighestFeatureLevel())) - { - return m_hStatus; - } - - return m_hStatus; -} - -// 0: D3D12_OPTIONS -FEATURE_SUPPORT_GET(BOOL, m_dOptions, DoublePrecisionFloatShaderOps); -FEATURE_SUPPORT_GET(BOOL, m_dOptions, OutputMergerLogicOp); -FEATURE_SUPPORT_GET(D3D12_SHADER_MIN_PRECISION_SUPPORT, m_dOptions, MinPrecisionSupport); -FEATURE_SUPPORT_GET(D3D12_TILED_RESOURCES_TIER, m_dOptions, TiledResourcesTier); -FEATURE_SUPPORT_GET(D3D12_RESOURCE_BINDING_TIER, m_dOptions, ResourceBindingTier); -FEATURE_SUPPORT_GET(BOOL, m_dOptions, PSSpecifiedStencilRefSupported); -FEATURE_SUPPORT_GET(BOOL, m_dOptions, TypedUAVLoadAdditionalFormats); -FEATURE_SUPPORT_GET(BOOL, m_dOptions, ROVsSupported); -FEATURE_SUPPORT_GET(D3D12_CONSERVATIVE_RASTERIZATION_TIER, m_dOptions, ConservativeRasterizationTier); -FEATURE_SUPPORT_GET(BOOL, m_dOptions, StandardSwizzle64KBSupported); -FEATURE_SUPPORT_GET(BOOL, m_dOptions, CrossAdapterRowMajorTextureSupported); -FEATURE_SUPPORT_GET(BOOL, m_dOptions, VPAndRTArrayIndexFromAnyShaderFeedingRasterizerSupportedWithoutGSEmulation); -FEATURE_SUPPORT_GET(D3D12_RESOURCE_HEAP_TIER, m_dOptions, ResourceHeapTier); - -// Special procedure for handling caps that is also part of other features -inline D3D12_CROSS_NODE_SHARING_TIER CD3DX12FeatureSupport::CrossNodeSharingTier() const noexcept -{ - if (m_dCrossNode.SharingTier > D3D12_CROSS_NODE_SHARING_TIER_NOT_SUPPORTED) - { - return m_dCrossNode.SharingTier; - } - else - { - return m_dOptions.CrossNodeSharingTier; - } -} - -inline UINT CD3DX12FeatureSupport::MaxGPUVirtualAddressBitsPerResource() const noexcept -{ - if (m_dOptions.MaxGPUVirtualAddressBitsPerResource > 0) - { - return m_dOptions.MaxGPUVirtualAddressBitsPerResource; - } - else - { - return m_dGPUVASupport.MaxGPUVirtualAddressBitsPerResource; - } -} - -// 1: Architecture -// Combined with Architecture1 - -// 2: Feature Levels -// Simply returns the highest supported feature level -inline D3D_FEATURE_LEVEL CD3DX12FeatureSupport::MaxSupportedFeatureLevel() const noexcept -{ - return m_eMaxFeatureLevel; -} - -// 3: Feature Format Support -inline HRESULT CD3DX12FeatureSupport::FormatSupport(DXGI_FORMAT Format, D3D12_FORMAT_SUPPORT1& Support1, D3D12_FORMAT_SUPPORT2& Support2) const -{ - D3D12_FEATURE_DATA_FORMAT_SUPPORT dFormatSupport; - dFormatSupport.Format = Format; - - // It is possible that the function call returns an error - HRESULT result = m_pDevice->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT, &dFormatSupport, sizeof(D3D12_FEATURE_DATA_FORMAT_SUPPORT)); - - Support1 = dFormatSupport.Support1; - Support2 = dFormatSupport.Support2; // Two outputs. Probably better just to take in the struct as an argument? - - return result; -} - -// 4: Multisample Quality Levels -inline HRESULT CD3DX12FeatureSupport::MultisampleQualityLevels(DXGI_FORMAT Format, UINT SampleCount, D3D12_MULTISAMPLE_QUALITY_LEVEL_FLAGS Flags, UINT& NumQualityLevels) const -{ - D3D12_FEATURE_DATA_MULTISAMPLE_QUALITY_LEVELS dMultisampleQualityLevels; - dMultisampleQualityLevels.Format = Format; - dMultisampleQualityLevels.SampleCount = SampleCount; - dMultisampleQualityLevels.Flags = Flags; - - HRESULT result = m_pDevice->CheckFeatureSupport(D3D12_FEATURE_MULTISAMPLE_QUALITY_LEVELS, &dMultisampleQualityLevels, sizeof(D3D12_FEATURE_DATA_MULTISAMPLE_QUALITY_LEVELS)); - - if (SUCCEEDED(result)) - { - NumQualityLevels = dMultisampleQualityLevels.NumQualityLevels; - } - else - { - NumQualityLevels = 0; - } - - return result; -} - -// 5: Format Info -inline HRESULT CD3DX12FeatureSupport::FormatInfo(DXGI_FORMAT Format, UINT8& PlaneCount) const -{ - D3D12_FEATURE_DATA_FORMAT_INFO dFormatInfo; - dFormatInfo.Format = Format; - - HRESULT result = m_pDevice->CheckFeatureSupport(D3D12_FEATURE_FORMAT_INFO, &dFormatInfo, sizeof(D3D12_FEATURE_DATA_FORMAT_INFO)); - if (FAILED(result)) - { - PlaneCount = 0; - } - else - { - PlaneCount = dFormatInfo.PlaneCount; - } - return result; -} - -// 6: GPU Virtual Address Support -// MaxGPUVirtualAddressBitsPerResource handled in D3D12Options -FEATURE_SUPPORT_GET(UINT, m_dGPUVASupport, MaxGPUVirtualAddressBitsPerProcess); - -// 7: Shader Model -inline D3D_SHADER_MODEL CD3DX12FeatureSupport::HighestShaderModel() const noexcept -{ - return m_dShaderModel.HighestShaderModel; -} - -// 8: D3D12 Options1 -FEATURE_SUPPORT_GET(BOOL, m_dOptions1, WaveOps); -FEATURE_SUPPORT_GET(UINT, m_dOptions1, WaveLaneCountMin); -FEATURE_SUPPORT_GET(UINT, m_dOptions1, WaveLaneCountMax); -FEATURE_SUPPORT_GET(UINT, m_dOptions1, TotalLaneCount); -FEATURE_SUPPORT_GET(BOOL, m_dOptions1, ExpandedComputeResourceStates); -FEATURE_SUPPORT_GET(BOOL, m_dOptions1, Int64ShaderOps); - -// 10: Protected Resource Session Support -inline D3D12_PROTECTED_RESOURCE_SESSION_SUPPORT_FLAGS CD3DX12FeatureSupport::ProtectedResourceSessionSupport(UINT NodeIndex) const -{ - return m_dProtectedResourceSessionSupport[NodeIndex].Support; -} - -// 12: Root Signature -inline D3D_ROOT_SIGNATURE_VERSION CD3DX12FeatureSupport::HighestRootSignatureVersion() const noexcept -{ - return m_dRootSignature.HighestVersion; -} - -// 16: Architecture1 -// Same data fields can be queried from m_dArchitecture -FEATURE_SUPPORT_GET_NODE_INDEXED(BOOL, m_dArchitecture1, TileBasedRenderer); -FEATURE_SUPPORT_GET_NODE_INDEXED(BOOL, m_dArchitecture1, UMA); -FEATURE_SUPPORT_GET_NODE_INDEXED(BOOL, m_dArchitecture1, CacheCoherentUMA); -FEATURE_SUPPORT_GET_NODE_INDEXED(BOOL, m_dArchitecture1, IsolatedMMU); - -// 18: D3D12 Options2 -FEATURE_SUPPORT_GET(BOOL, m_dOptions2, DepthBoundsTestSupported); -FEATURE_SUPPORT_GET(D3D12_PROGRAMMABLE_SAMPLE_POSITIONS_TIER, m_dOptions2, ProgrammableSamplePositionsTier); - -// 19: Shader Cache -FEATURE_SUPPORT_GET_NAME(D3D12_SHADER_CACHE_SUPPORT_FLAGS, m_dShaderCache, SupportFlags, ShaderCacheSupportFlags); - -// 20: Command Queue Priority -inline BOOL CD3DX12FeatureSupport::CommandQueuePrioritySupported(D3D12_COMMAND_LIST_TYPE CommandListType, UINT Priority) -{ - m_dCommandQueuePriority.CommandListType = CommandListType; - m_dCommandQueuePriority.Priority = Priority; - - if (FAILED(m_pDevice->CheckFeatureSupport(D3D12_FEATURE_COMMAND_QUEUE_PRIORITY, &m_dCommandQueuePriority, sizeof(D3D12_FEATURE_DATA_COMMAND_QUEUE_PRIORITY)))) - { - return false; - } - - return m_dCommandQueuePriority.PriorityForTypeIsSupported; -} - -// 21: D3D12 Options3 -FEATURE_SUPPORT_GET(BOOL, m_dOptions3, CopyQueueTimestampQueriesSupported); -FEATURE_SUPPORT_GET(BOOL, m_dOptions3, CastingFullyTypedFormatSupported); -FEATURE_SUPPORT_GET(D3D12_COMMAND_LIST_SUPPORT_FLAGS, m_dOptions3, WriteBufferImmediateSupportFlags); -FEATURE_SUPPORT_GET(D3D12_VIEW_INSTANCING_TIER, m_dOptions3, ViewInstancingTier); -FEATURE_SUPPORT_GET(BOOL, m_dOptions3, BarycentricsSupported); - -// 22: Existing Heaps -FEATURE_SUPPORT_GET_NAME(BOOL, m_dExistingHeaps, Supported, ExistingHeapsSupported); - -// 23: D3D12 Options4 -FEATURE_SUPPORT_GET(BOOL, m_dOptions4, MSAA64KBAlignedTextureSupported); -FEATURE_SUPPORT_GET(D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER, m_dOptions4, SharedResourceCompatibilityTier); -FEATURE_SUPPORT_GET(BOOL, m_dOptions4, Native16BitShaderOpsSupported); - -// 24: Serialization -FEATURE_SUPPORT_GET_NODE_INDEXED(D3D12_HEAP_SERIALIZATION_TIER, m_dSerialization, HeapSerializationTier); - -// 25: Cross Node -// CrossNodeSharingTier handled in D3D12Options -FEATURE_SUPPORT_GET_NAME(BOOL, m_dCrossNode, AtomicShaderInstructions, CrossNodeAtomicShaderInstructions); - -// 27: D3D12 Options5 -FEATURE_SUPPORT_GET(BOOL, m_dOptions5, SRVOnlyTiledResourceTier3); -FEATURE_SUPPORT_GET(D3D12_RENDER_PASS_TIER, m_dOptions5, RenderPassesTier); -FEATURE_SUPPORT_GET(D3D12_RAYTRACING_TIER, m_dOptions5, RaytracingTier); - -// 28: Displayable -FEATURE_SUPPORT_GET(BOOL, m_dDisplayable, DisplayableTexture); -// SharedResourceCompatibilityTier handled in D3D12Options4 - -// 30: D3D12 Options6 -FEATURE_SUPPORT_GET(BOOL, m_dOptions6, AdditionalShadingRatesSupported); -FEATURE_SUPPORT_GET(BOOL, m_dOptions6, PerPrimitiveShadingRateSupportedWithViewportIndexing); -FEATURE_SUPPORT_GET(D3D12_VARIABLE_SHADING_RATE_TIER, m_dOptions6, VariableShadingRateTier); -FEATURE_SUPPORT_GET(UINT, m_dOptions6, ShadingRateImageTileSize); -FEATURE_SUPPORT_GET(BOOL, m_dOptions6, BackgroundProcessingSupported); - -// 31: Query Meta Command -// Keep the original call routine -inline HRESULT CD3DX12FeatureSupport::QueryMetaCommand(D3D12_FEATURE_DATA_QUERY_META_COMMAND& dQueryMetaCommand) const -{ - return m_pDevice->CheckFeatureSupport(D3D12_FEATURE_QUERY_META_COMMAND, &dQueryMetaCommand, sizeof(D3D12_FEATURE_DATA_QUERY_META_COMMAND)); -} - -// 32: D3D12 Options7 -FEATURE_SUPPORT_GET(D3D12_MESH_SHADER_TIER, m_dOptions7, MeshShaderTier); -FEATURE_SUPPORT_GET(D3D12_SAMPLER_FEEDBACK_TIER, m_dOptions7, SamplerFeedbackTier); - -// 33: Protected Resource Session Type Count -FEATURE_SUPPORT_GET_NODE_INDEXED_NAME(UINT, m_dProtectedResourceSessionTypeCount, Count, ProtectedResourceSessionTypeCount); - -// 34: Protected Resource Session Types -FEATURE_SUPPORT_GET_NODE_INDEXED_NAME(std::vector, m_dProtectedResourceSessionTypes, TypeVec, ProtectedResourceSessionTypes); - -// 36: Options8 -FEATURE_SUPPORT_GET(BOOL, m_dOptions8, UnalignedBlockTexturesSupported); - -// 37: Options9 -FEATURE_SUPPORT_GET(BOOL, m_dOptions9, MeshShaderPipelineStatsSupported); -FEATURE_SUPPORT_GET(BOOL, m_dOptions9, MeshShaderSupportsFullRangeRenderTargetArrayIndex); -FEATURE_SUPPORT_GET(BOOL, m_dOptions9, AtomicInt64OnTypedResourceSupported); -FEATURE_SUPPORT_GET(BOOL, m_dOptions9, AtomicInt64OnGroupSharedSupported); -FEATURE_SUPPORT_GET(BOOL, m_dOptions9, DerivativesInMeshAndAmplificationShadersSupported); -FEATURE_SUPPORT_GET(D3D12_WAVE_MMA_TIER, m_dOptions9, WaveMMATier); - -// 39: Options10 -FEATURE_SUPPORT_GET(BOOL, m_dOptions10, VariableRateShadingSumCombinerSupported); -FEATURE_SUPPORT_GET(BOOL, m_dOptions10, MeshShaderPerPrimitiveShadingRateSupported); - -// 40: Options11 -FEATURE_SUPPORT_GET(BOOL, m_dOptions11, AtomicInt64OnDescriptorHeapResourceSupported); - -#if defined(NTDDI_WIN10_NI) || defined(USING_D3D12_AGILITY_SDK) -// 41: Options12 -FEATURE_SUPPORT_GET(D3D12_TRI_STATE, m_dOptions12, MSPrimitivesPipelineStatisticIncludesCulledPrimitives); -FEATURE_SUPPORT_GET(BOOL, m_dOptions12, EnhancedBarriersSupported); -FEATURE_SUPPORT_GET(BOOL, m_dOptions12, RelaxedFormatCastingSupported); - -// 42: Options13 -FEATURE_SUPPORT_GET(BOOL, m_dOptions13, UnrestrictedBufferTextureCopyPitchSupported); -FEATURE_SUPPORT_GET(BOOL, m_dOptions13, UnrestrictedVertexElementAlignmentSupported); -FEATURE_SUPPORT_GET(BOOL, m_dOptions13, InvertedViewportHeightFlipsYSupported); -FEATURE_SUPPORT_GET(BOOL, m_dOptions13, InvertedViewportDepthFlipsZSupported); -FEATURE_SUPPORT_GET(BOOL, m_dOptions13, TextureCopyBetweenDimensionsSupported); -FEATURE_SUPPORT_GET(BOOL, m_dOptions13, AlphaBlendFactorSupported); -#endif - -// Helper function to decide the highest shader model supported by the system -// Stores the result in m_dShaderModel -// Must be updated whenever a new shader model is added to the d3d12.h header -inline HRESULT CD3DX12FeatureSupport::QueryHighestShaderModel() -{ - // Check support in descending order - HRESULT result; - - const D3D_SHADER_MODEL allModelVersions[] = - { - D3D_SHADER_MODEL_6_7, - D3D_SHADER_MODEL_6_6, - D3D_SHADER_MODEL_6_5, - D3D_SHADER_MODEL_6_4, - D3D_SHADER_MODEL_6_3, - D3D_SHADER_MODEL_6_2, - D3D_SHADER_MODEL_6_1, - D3D_SHADER_MODEL_6_0, - D3D_SHADER_MODEL_5_1 - }; - constexpr size_t numModelVersions = sizeof(allModelVersions) / sizeof(D3D_SHADER_MODEL); - - for (size_t i = 0; i < numModelVersions; i++) - { - m_dShaderModel.HighestShaderModel = allModelVersions[i]; - result = m_pDevice->CheckFeatureSupport(D3D12_FEATURE_SHADER_MODEL, &m_dShaderModel, sizeof(D3D12_FEATURE_DATA_SHADER_MODEL)); - if (result != E_INVALIDARG) - { - // Indicates that the version is recognizable by the runtime and stored in the struct - // Also terminate on unexpected error code - if (FAILED(result)) - { - m_dShaderModel.HighestShaderModel = static_cast(0); - } - return result; - } - } - - // Shader model may not be supported. Continue the rest initializations - m_dShaderModel.HighestShaderModel = static_cast(0); - return S_OK; -} - -// Helper function to decide the highest root signature supported -// Must be updated whenever a new root signature version is added to the d3d12.h header -inline HRESULT CD3DX12FeatureSupport::QueryHighestRootSignatureVersion() -{ - HRESULT result; - - const D3D_ROOT_SIGNATURE_VERSION allRootSignatureVersions[] = - { - D3D_ROOT_SIGNATURE_VERSION_1_1, - D3D_ROOT_SIGNATURE_VERSION_1_0, - D3D_ROOT_SIGNATURE_VERSION_1, - }; - constexpr size_t numRootSignatureVersions = sizeof(allRootSignatureVersions) / sizeof(D3D_ROOT_SIGNATURE_VERSION); - - for (size_t i = 0; i < numRootSignatureVersions; i++) - { - m_dRootSignature.HighestVersion = allRootSignatureVersions[i]; - result = m_pDevice->CheckFeatureSupport(D3D12_FEATURE_ROOT_SIGNATURE, &m_dRootSignature, sizeof(D3D12_FEATURE_DATA_ROOT_SIGNATURE)); - if (result != E_INVALIDARG) - { - if (FAILED(result)) - { - m_dRootSignature.HighestVersion = static_cast(0); - } - // If succeeded, the highest version is already written into the member struct - return result; - } - } - - // No version left. Set to invalid value and continue. - m_dRootSignature.HighestVersion = static_cast(0); - return S_OK; -} - -// Helper funcion to decide the highest feature level -inline HRESULT CD3DX12FeatureSupport::QueryHighestFeatureLevel() -{ - HRESULT result; - - // Check against a list of all feature levels present in d3dcommon.h - // Needs to be updated for future feature levels - const D3D_FEATURE_LEVEL allLevels[] = - { - D3D_FEATURE_LEVEL_12_2, - D3D_FEATURE_LEVEL_12_1, - D3D_FEATURE_LEVEL_12_0, - D3D_FEATURE_LEVEL_11_1, - D3D_FEATURE_LEVEL_11_0, - D3D_FEATURE_LEVEL_10_1, - D3D_FEATURE_LEVEL_10_0, - D3D_FEATURE_LEVEL_9_3, - D3D_FEATURE_LEVEL_9_2, - D3D_FEATURE_LEVEL_9_1, - D3D_FEATURE_LEVEL_1_0_CORE - }; - - D3D12_FEATURE_DATA_FEATURE_LEVELS dFeatureLevel; - dFeatureLevel.NumFeatureLevels = static_cast(sizeof(allLevels) / sizeof(D3D_FEATURE_LEVEL)); - dFeatureLevel.pFeatureLevelsRequested = allLevels; - - result = m_pDevice->CheckFeatureSupport(D3D12_FEATURE_FEATURE_LEVELS, &dFeatureLevel, sizeof(D3D12_FEATURE_DATA_FEATURE_LEVELS)); - if (SUCCEEDED(result)) - { - m_eMaxFeatureLevel = dFeatureLevel.MaxSupportedFeatureLevel; - } - else - { - m_eMaxFeatureLevel = static_cast(0); - - if (result == DXGI_ERROR_UNSUPPORTED) - { - // Indicates that none supported. Continue initialization - result = S_OK; - } - } - return result; -} - -// Helper function to initialize local protected resource session types structs -inline HRESULT CD3DX12FeatureSupport::QueryProtectedResourceSessionTypes(UINT NodeIndex, UINT Count) -{ - auto& CurrentPRSTypes = m_dProtectedResourceSessionTypes[NodeIndex]; - CurrentPRSTypes.NodeIndex = NodeIndex; - CurrentPRSTypes.Count = Count; - CurrentPRSTypes.TypeVec.resize(CurrentPRSTypes.Count); - CurrentPRSTypes.pTypes = CurrentPRSTypes.TypeVec.data(); - - HRESULT result = m_pDevice->CheckFeatureSupport(D3D12_FEATURE_PROTECTED_RESOURCE_SESSION_TYPES, &m_dProtectedResourceSessionTypes[NodeIndex], sizeof(D3D12_FEATURE_DATA_PROTECTED_RESOURCE_SESSION_TYPES)); - if (FAILED(result)) - { - // Resize TypeVec to empty - CurrentPRSTypes.TypeVec.clear(); - } - - return result; -} - -#undef FEATURE_SUPPORT_GET -#undef FEATURE_SUPPORT_GET_NAME -#undef FEATURE_SUPPORT_GET_NODE_INDEXED -#undef FEATURE_SUPPORT_GET_NODE_INDEXED_NAME - -// end CD3DX12FeatureSupport - -#endif // !D3DX12_NO_CHECK_FEATURE_SUPPORT_CLASS - -#undef D3DX12_COM_PTR -#undef D3DX12_COM_PTR_GET -#undef D3DX12_COM_PTR_ADDRESSOF - -#endif // defined( __cplusplus ) - -#endif //__D3DX12_H__ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/filters.h b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/filters.h deleted file mode 100644 index fb8a63f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/filters.h +++ /dev/null @@ -1,422 +0,0 @@ -//------------------------------------------------------------------------------------- -// filters.h -// -// Utility header with helpers for implementing image filters -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -//------------------------------------------------------------------------------------- - -#pragma once - -#include -#include - -#include - -#include "scoped.h" - - -namespace DirectX -{ - namespace Filters - { - //------------------------------------------------------------------------------------- - // Box filtering helpers - //------------------------------------------------------------------------------------- - - XMGLOBALCONST XMVECTORF32 g_boxScale = { { { 0.25f, 0.25f, 0.25f, 0.25f } } }; - XMGLOBALCONST XMVECTORF32 g_boxScale3D = { { { 0.125f, 0.125f, 0.125f, 0.125f } } }; - - #define AVERAGE4( res, p0, p1, p2, p3 ) \ -{ \ - XMVECTOR v = XMVectorAdd((p0), (p1)); \ - v = XMVectorAdd(v, (p2)); \ - v = XMVectorAdd(v, (p3)); \ - res = XMVectorMultiply(v, g_boxScale); \ -} - - #define AVERAGE8( res, p0, p1, p2, p3, p4, p5, p6, p7) \ -{ \ - XMVECTOR v = XMVectorAdd((p0), (p1)); \ - v = XMVectorAdd(v, (p2)); \ - v = XMVectorAdd(v, (p3)); \ - v = XMVectorAdd(v, (p4)); \ - v = XMVectorAdd(v, (p5)); \ - v = XMVectorAdd(v, (p6)); \ - v = XMVectorAdd(v, (p7)); \ - res = XMVectorMultiply(v, g_boxScale3D); \ -} - - - //------------------------------------------------------------------------------------- - // Linear filtering helpers - //------------------------------------------------------------------------------------- - - struct LinearFilter - { - size_t u0; - float weight0; - size_t u1; - float weight1; - }; - - inline void CreateLinearFilter(_In_ size_t source, _In_ size_t dest, _In_ bool wrap, _Out_writes_(dest) LinearFilter* lf) noexcept - { - assert(source > 0); - assert(dest > 0); - assert(lf != nullptr); - - const float scale = float(source) / float(dest); - - // Mirror is the same case as clamp for linear - - for (size_t u = 0; u < dest; ++u) - { - const float srcB = (float(u) + 0.5f) * scale + 0.5f; - - ptrdiff_t isrcB = ptrdiff_t(srcB); - ptrdiff_t isrcA = isrcB - 1; - - const float weight = 1.0f + float(isrcB) - srcB; - - if (isrcA < 0) - { - isrcA = (wrap) ? (ptrdiff_t(source) - 1) : 0; - } - - if (size_t(isrcB) >= source) - { - isrcB = (wrap) ? 0 : (ptrdiff_t(source) - 1); - } - - auto& entry = lf[u]; - entry.u0 = size_t(isrcA); - entry.weight0 = weight; - - entry.u1 = size_t(isrcB); - entry.weight1 = 1.0f - weight; - } - } - - #define BILINEAR_INTERPOLATE( res, x, y, r0, r1 ) \ - res = XMVectorAdd(XMVectorScale(XMVectorAdd(XMVectorScale((r0)[ x.u0 ], x.weight0), XMVectorScale((r0)[ x.u1 ], x.weight1)), y.weight0), \ - XMVectorScale(XMVectorAdd(XMVectorScale((r1)[ x.u0 ], x.weight0), XMVectorScale((r1)[ x.u1 ], x.weight1)), y.weight1) ); - - #define TRILINEAR_INTERPOLATE( res, x, y, z, r0, r1, r2, r3 ) \ -{\ - const XMVECTOR a0 = XMVectorScale(XMVectorAdd(XMVectorScale((r0)[ x.u0 ], x.weight0 ), XMVectorScale((r0)[ x.u1 ], x.weight1)), y.weight0); \ - const XMVECTOR a1 = XMVectorScale(XMVectorAdd(XMVectorScale((r1)[ x.u0 ], x.weight0 ), XMVectorScale((r1)[ x.u1 ], x.weight1)), y.weight1); \ - const XMVECTOR a2 = XMVectorScale(XMVectorAdd(XMVectorScale((r2)[ x.u0 ], x.weight0 ), XMVectorScale((r2)[ x.u1 ], x.weight1)), y.weight0); \ - const XMVECTOR a3 = XMVectorScale(XMVectorAdd(XMVectorScale((r3)[ x.u0 ], x.weight0 ), XMVectorScale((r3)[ x.u1 ], x.weight1)), y.weight1); \ - res = XMVectorAdd(XMVectorScale(XMVectorAdd(a0, a1), z.weight0), XMVectorScale(XMVectorAdd(a2, a3), z.weight1)); \ -} - - //------------------------------------------------------------------------------------- - // Cubic filtering helpers - //------------------------------------------------------------------------------------- - - XMGLOBALCONST XMVECTORF32 g_cubicThird = { { { 1.f / 3.f, 1.f / 3.f, 1.f / 3.f, 1.f / 3.f } } }; - XMGLOBALCONST XMVECTORF32 g_cubicSixth = { { { 1.f / 6.f, 1.f / 6.f, 1.f / 6.f, 1.f / 6.f } } }; - XMGLOBALCONST XMVECTORF32 g_cubicHalf = { { { 1.f / 2.f, 1.f / 2.f, 1.f / 2.f, 1.f / 2.f } } }; - - constexpr ptrdiff_t bounduvw(ptrdiff_t u, ptrdiff_t maxu, bool wrap, bool mirror) noexcept - { - if (wrap) - { - if (u < 0) - { - u = maxu + u + 1; - } - else if (u > maxu) - { - u = u - maxu - 1; - } - } - else if (mirror) - { - if (u < 0) - { - u = (-u) - 1; - } - else if (u > maxu) - { - u = maxu - (u - maxu - 1); - } - } - - // Handles clamp, but also a safety factor for degenerate images for wrap/mirror - u = std::min(u, maxu); - u = std::max(u, 0); - - return u; - } - - struct CubicFilter - { - size_t u0; - size_t u1; - size_t u2; - size_t u3; - float x; - }; - - inline void CreateCubicFilter(_In_ size_t source, _In_ size_t dest, _In_ bool wrap, _In_ bool mirror, _Out_writes_(dest) CubicFilter* cf) noexcept - { - assert(source > 0); - assert(dest > 0); - assert(cf != nullptr); - - const float scale = float(source) / float(dest); - - for (size_t u = 0; u < dest; ++u) - { - const float srcB = (float(u) + 0.5f) * scale - 0.5f; - - const ptrdiff_t isrcB = bounduvw(ptrdiff_t(srcB), ptrdiff_t(source) - 1, wrap, mirror); - const ptrdiff_t isrcA = bounduvw(isrcB - 1, ptrdiff_t(source) - 1, wrap, mirror); - const ptrdiff_t isrcC = bounduvw(isrcB + 1, ptrdiff_t(source) - 1, wrap, mirror); - const ptrdiff_t isrcD = bounduvw(isrcB + 2, ptrdiff_t(source) - 1, wrap, mirror); - - auto& entry = cf[u]; - entry.u0 = size_t(isrcA); - entry.u1 = size_t(isrcB); - entry.u2 = size_t(isrcC); - entry.u3 = size_t(isrcD); - - const float x = srcB - float(isrcB); - entry.x = x; - } - } - - #define CUBIC_INTERPOLATE( res, dx, p0, p1, p2, p3 ) \ -{ \ - const XMVECTOR a0 = (p1); \ - const XMVECTOR d0 = XMVectorSubtract(p0, a0); \ - const XMVECTOR d2 = XMVectorSubtract(p2, a0); \ - const XMVECTOR d3 = XMVectorSubtract(p3, a0); \ - XMVECTOR a1 = XMVectorSubtract(d2, XMVectorMultiply(g_cubicThird, d0)); \ - a1 = XMVectorSubtract(a1, XMVectorMultiply(g_cubicSixth, d3)); \ - const XMVECTOR a2 = XMVectorAdd(XMVectorMultiply(g_cubicHalf, d0), XMVectorMultiply(g_cubicHalf, d2)); \ - XMVECTOR a3 = XMVectorSubtract(XMVectorMultiply(g_cubicSixth, d3), XMVectorMultiply(g_cubicSixth, d0)); \ - a3 = XMVectorSubtract(a3, XMVectorMultiply(g_cubicHalf, d2)); \ - const XMVECTOR vdx = XMVectorReplicate(dx); \ - const XMVECTOR vdx2 = XMVectorMultiply(vdx, vdx); \ - const XMVECTOR vdx3 = XMVectorMultiply(vdx2, vdx); \ - res = XMVectorAdd(XMVectorAdd(XMVectorAdd(a0, XMVectorMultiply(a1, vdx)), XMVectorMultiply(a2, vdx2)), XMVectorMultiply(a3, vdx3)); \ -} - - - //------------------------------------------------------------------------------------- - // Triangle filtering helpers - //------------------------------------------------------------------------------------- - - struct FilterTo - { - size_t u; - float weight; - }; - - struct FilterFrom - { - size_t count; - size_t sizeInBytes; - FilterTo to[1]; // variable-sized array - }; - - struct Filter - { - size_t sizeInBytes; - size_t totalSize; - FilterFrom from[1]; // variable-sized array - }; - - struct TriangleRow - { - size_t remaining; - TriangleRow* next; - ScopedAlignedArrayXMVECTOR scanline; - - TriangleRow() noexcept : remaining(0), next(nullptr) {} - }; - - constexpr size_t TF_FILTER_SIZE = sizeof(Filter) - sizeof(FilterFrom); - constexpr size_t TF_FROM_SIZE = sizeof(FilterFrom) - sizeof(FilterTo); - constexpr size_t TF_TO_SIZE = sizeof(FilterTo); - - constexpr float TF_EPSILON = 0.00001f; - - inline HRESULT CreateTriangleFilter(_In_ size_t source, _In_ size_t dest, _In_ bool wrap, _Inout_ std::unique_ptr& tf) noexcept - { - assert(source > 0); - assert(dest > 0); - - const float scale = float(dest) / float(source); - const float scaleInv = 0.5f / scale; - - // Determine storage required for filter and allocate memory if needed - size_t totalSize = TF_FILTER_SIZE + TF_FROM_SIZE + TF_TO_SIZE; - const float repeat = (wrap) ? 1.f : 0.f; - - for (size_t u = 0; u < source; ++u) - { - const float src = float(u) - 0.5f; - const float destMin = src * scale; - const float destMax = destMin + scale; - const float t = destMax - destMin + repeat + 1.f; - totalSize += TF_FROM_SIZE + TF_TO_SIZE + size_t(t) * TF_TO_SIZE * 2; - } - - uint8_t* pFilter = nullptr; - - if (tf) - { - // See if existing filter memory block is large enough to reuse - if (tf->totalSize >= totalSize) - { - pFilter = reinterpret_cast(tf.get()); - } - else - { - // Need to reallocate filter memory block - tf.reset(nullptr); - } - } - - if (!tf) - { - // Allocate filter memory block - pFilter = new (std::nothrow) uint8_t[totalSize]; - if (!pFilter) - return E_OUTOFMEMORY; - - tf.reset(reinterpret_cast(pFilter)); - tf->totalSize = totalSize; - } - - assert(pFilter != nullptr); - _Analysis_assume_(pFilter != nullptr); - - // Filter setup - size_t sizeInBytes = TF_FILTER_SIZE; - size_t accumU = 0; - float accumWeight = 0.f; - - for (size_t u = 0; u < source; ++u) - { - // Setup from entry - const size_t sizeFrom = sizeInBytes; - auto pFrom = reinterpret_cast(pFilter + sizeInBytes); - sizeInBytes += TF_FROM_SIZE; - - if (sizeInBytes > totalSize) - return E_FAIL; - - size_t toCount = 0; - - // Perform two passes to capture the influences from both sides - for (size_t j = 0; j < 2; ++j) - { - const float src = float(u + j) - 0.5f; - - float destMin = src * scale; - float destMax = destMin + scale; - - if (!wrap) - { - // Clamp - if (destMin < 0.f) - destMin = 0.f; - if (destMax > float(dest)) - destMax = float(dest); - } - - for (auto k = static_cast(floorf(destMin)); float(k) < destMax; ++k) - { - float d0 = float(k); - float d1 = d0 + 1.f; - - size_t u0; - if (k < 0) - { - // Handle wrap - u0 = size_t(k + ptrdiff_t(dest)); - } - else if (k >= ptrdiff_t(dest)) - { - // Handle wrap - u0 = size_t(k - ptrdiff_t(dest)); - } - else - { - u0 = size_t(k); - } - - // Save previous accumulated weight (if any) - if (u0 != accumU) - { - if (accumWeight > TF_EPSILON) - { - auto pTo = reinterpret_cast(pFilter + sizeInBytes); - sizeInBytes += TF_TO_SIZE; - ++toCount; - - if (sizeInBytes > totalSize) - return E_FAIL; - - pTo->u = accumU; - pTo->weight = accumWeight; - } - - accumWeight = 0.f; - accumU = u0; - } - - // Clip destination - if (d0 < destMin) - d0 = destMin; - if (d1 > destMax) - d1 = destMax; - - // Calculate average weight over destination pixel - - float weight; - if (!wrap && src < 0.f) - weight = 1.f; - else if (!wrap && ((src + 1.f) >= float(source))) - weight = 0.f; - else - weight = (d0 + d1) * scaleInv - src; - - accumWeight += (d1 - d0) * (j ? (1.f - weight) : weight); - } - } - - // Store accumulated weight - if (accumWeight > TF_EPSILON) - { - auto pTo = reinterpret_cast(pFilter + sizeInBytes); - sizeInBytes += TF_TO_SIZE; - ++toCount; - - if (sizeInBytes > totalSize) - return E_FAIL; - - pTo->u = accumU; - pTo->weight = accumWeight; - } - - accumWeight = 0.f; - - // Finalize from entry - pFrom->count = toCount; - pFrom->sizeInBytes = sizeInBytes - sizeFrom; - } - - tf->sizeInBytes = sizeInBytes; - - return S_OK; - } - - } // namespace Filters -} // namespace DirectX diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/scoped.h b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/scoped.h deleted file mode 100644 index 363c393..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex/scoped.h +++ /dev/null @@ -1,112 +0,0 @@ -//------------------------------------------------------------------------------------- -// scoped.h -// -// Utility header with helper classes for exception-safe handling of resources -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -//------------------------------------------------------------------------------------- - -#pragma once - -#include -#include -#include -#include -#include - -#ifndef _WIN32 -#include - -struct aligned_deleter { void operator()(void* p) noexcept { free(p); } }; - -using ScopedAlignedArrayFloat = std::unique_ptr; - -inline ScopedAlignedArrayFloat make_AlignedArrayFloat(uint64_t count) -{ - uint64_t size = sizeof(float) * count; - size = (size + 15u) & ~0xF; - if (size > static_cast(UINT32_MAX)) - return nullptr; - - auto ptr = aligned_alloc(16, static_cast(size)); - return ScopedAlignedArrayFloat(static_cast(ptr)); -} - -using ScopedAlignedArrayXMVECTOR = std::unique_ptr; - -inline ScopedAlignedArrayXMVECTOR make_AlignedArrayXMVECTOR(uint64_t count) -{ - uint64_t size = sizeof(DirectX::XMVECTOR) * count; - if (size > static_cast(UINT32_MAX)) - return nullptr; - auto ptr = aligned_alloc(16, static_cast(size)); - return ScopedAlignedArrayXMVECTOR(static_cast(ptr)); -} - -#else // WIN32 -//--------------------------------------------------------------------------------- -#include - -struct aligned_deleter { void operator()(void* p) noexcept { _aligned_free(p); } }; - -using ScopedAlignedArrayFloat = std::unique_ptr; - -inline ScopedAlignedArrayFloat make_AlignedArrayFloat(uint64_t count) -{ - const uint64_t size = sizeof(float) * count; - if (size > static_cast(UINT32_MAX)) - return nullptr; - auto ptr = _aligned_malloc(static_cast(size), 16); - return ScopedAlignedArrayFloat(static_cast(ptr)); -} - -using ScopedAlignedArrayXMVECTOR = std::unique_ptr; - -inline ScopedAlignedArrayXMVECTOR make_AlignedArrayXMVECTOR(uint64_t count) -{ - const uint64_t size = sizeof(DirectX::XMVECTOR) * count; - if (size > static_cast(UINT32_MAX)) - return nullptr; - auto ptr = _aligned_malloc(static_cast(size), 16); - return ScopedAlignedArrayXMVECTOR(static_cast(ptr)); -} - -//--------------------------------------------------------------------------------- -struct handle_closer { void operator()(HANDLE h) noexcept { assert(h != INVALID_HANDLE_VALUE); if (h) CloseHandle(h); } }; - -using ScopedHandle = std::unique_ptr; - -inline HANDLE safe_handle(HANDLE h) noexcept { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; } - -//--------------------------------------------------------------------------------- -struct find_closer { void operator()(HANDLE h) noexcept { assert(h != INVALID_HANDLE_VALUE); if (h) FindClose(h); } }; - -using ScopedFindHandle = std::unique_ptr; - -//--------------------------------------------------------------------------------- -class auto_delete_file -{ -public: - auto_delete_file(HANDLE hFile) noexcept : m_handle(hFile) {} - - auto_delete_file(const auto_delete_file&) = delete; - auto_delete_file& operator=(const auto_delete_file&) = delete; - - ~auto_delete_file() - { - if (m_handle) - { - FILE_DISPOSITION_INFO info = {}; - info.DeleteFile = TRUE; - std::ignore = SetFileInformationByHandle(m_handle, FileDispositionInfo, &info, sizeof(info)); - } - } - - void clear() noexcept { m_handle = nullptr; } - -private: - HANDLE m_handle; -}; - -#endif // WIN32 diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex_Desktop_2019.sln b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex_Desktop_2019.sln deleted file mode 100644 index 01ef610..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex_Desktop_2019.sln +++ /dev/null @@ -1,107 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.28729.10 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXTex", "DirectXTex\DirectXTex_Desktop_2019.vcxproj", "{371B9FA9-4C90-4AC6-A123-ACED756D6C77}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "texassemble", "Texassemble\Texassemble_Desktop_2019.vcxproj", "{8F18CBD7-4116-4956-BCD8-20D688A4CBD1}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "texconv", "Texconv\Texconv_Desktop_2019.vcxproj", "{C3A65381-8FD3-4F69-B29E-654B4B0ED136}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DDSView", "DDSView\DDSView_Desktop_2019.vcxproj", "{9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{AEA1D9F7-EA95-4BF7-8E6D-0EA068077943}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Sample", "Sample", "{E14090F7-2FE9-47EE-A331-14ED71801FDE}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "texdiag", "Texdiag\texdiag_Desktop_2019.vcxproj", "{8E31A619-F4F8-413F-A973-4EE37B1AAA5D}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A40FB626-EA42-48D5-AE40-EE5A6FD3742E}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x86 = Debug|x86 - Debug|x64 = Debug|x64 - Profile|x86 = Profile|x86 - Profile|x64 = Profile|x64 - Release|x86 = Release|x86 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|x86.ActiveCfg = Debug|Win32 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|x86.Build.0 = Debug|Win32 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|x64.ActiveCfg = Debug|x64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|x64.Build.0 = Debug|x64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|x86.ActiveCfg = Profile|Win32 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|x86.Build.0 = Profile|Win32 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|x64.ActiveCfg = Profile|x64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|x64.Build.0 = Profile|x64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|x86.ActiveCfg = Release|Win32 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|x86.Build.0 = Release|Win32 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|x64.ActiveCfg = Release|x64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|x64.Build.0 = Release|x64 - {8F18CBD7-4116-4956-BCD8-20D688A4CBD1}.Debug|x86.ActiveCfg = Debug|Win32 - {8F18CBD7-4116-4956-BCD8-20D688A4CBD1}.Debug|x86.Build.0 = Debug|Win32 - {8F18CBD7-4116-4956-BCD8-20D688A4CBD1}.Debug|x64.ActiveCfg = Debug|x64 - {8F18CBD7-4116-4956-BCD8-20D688A4CBD1}.Debug|x64.Build.0 = Debug|x64 - {8F18CBD7-4116-4956-BCD8-20D688A4CBD1}.Profile|x86.ActiveCfg = Profile|Win32 - {8F18CBD7-4116-4956-BCD8-20D688A4CBD1}.Profile|x86.Build.0 = Profile|Win32 - {8F18CBD7-4116-4956-BCD8-20D688A4CBD1}.Profile|x64.ActiveCfg = Profile|x64 - {8F18CBD7-4116-4956-BCD8-20D688A4CBD1}.Profile|x64.Build.0 = Profile|x64 - {8F18CBD7-4116-4956-BCD8-20D688A4CBD1}.Release|x86.ActiveCfg = Release|Win32 - {8F18CBD7-4116-4956-BCD8-20D688A4CBD1}.Release|x86.Build.0 = Release|Win32 - {8F18CBD7-4116-4956-BCD8-20D688A4CBD1}.Release|x64.ActiveCfg = Release|x64 - {8F18CBD7-4116-4956-BCD8-20D688A4CBD1}.Release|x64.Build.0 = Release|x64 - {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Debug|x86.ActiveCfg = Debug|Win32 - {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Debug|x86.Build.0 = Debug|Win32 - {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Debug|x64.ActiveCfg = Debug|x64 - {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Debug|x64.Build.0 = Debug|x64 - {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Profile|x86.ActiveCfg = Profile|Win32 - {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Profile|x86.Build.0 = Profile|Win32 - {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Profile|x64.ActiveCfg = Profile|x64 - {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Profile|x64.Build.0 = Profile|x64 - {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Release|x86.ActiveCfg = Release|Win32 - {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Release|x86.Build.0 = Release|Win32 - {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Release|x64.ActiveCfg = Release|x64 - {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Release|x64.Build.0 = Release|x64 - {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Debug|x86.ActiveCfg = Debug|Win32 - {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Debug|x86.Build.0 = Debug|Win32 - {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Debug|x64.ActiveCfg = Debug|x64 - {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Debug|x64.Build.0 = Debug|x64 - {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Profile|x86.ActiveCfg = Profile|Win32 - {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Profile|x86.Build.0 = Profile|Win32 - {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Profile|x64.ActiveCfg = Profile|x64 - {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Profile|x64.Build.0 = Profile|x64 - {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Release|x86.ActiveCfg = Release|Win32 - {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Release|x86.Build.0 = Release|Win32 - {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Release|x64.ActiveCfg = Release|x64 - {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Release|x64.Build.0 = Release|x64 - {8E31A619-F4F8-413F-A973-4EE37B1AAA5D}.Debug|x86.ActiveCfg = Debug|Win32 - {8E31A619-F4F8-413F-A973-4EE37B1AAA5D}.Debug|x86.Build.0 = Debug|Win32 - {8E31A619-F4F8-413F-A973-4EE37B1AAA5D}.Debug|x64.ActiveCfg = Debug|x64 - {8E31A619-F4F8-413F-A973-4EE37B1AAA5D}.Debug|x64.Build.0 = Debug|x64 - {8E31A619-F4F8-413F-A973-4EE37B1AAA5D}.Profile|x86.ActiveCfg = Profile|Win32 - {8E31A619-F4F8-413F-A973-4EE37B1AAA5D}.Profile|x86.Build.0 = Profile|Win32 - {8E31A619-F4F8-413F-A973-4EE37B1AAA5D}.Profile|x64.ActiveCfg = Profile|x64 - {8E31A619-F4F8-413F-A973-4EE37B1AAA5D}.Profile|x64.Build.0 = Profile|x64 - {8E31A619-F4F8-413F-A973-4EE37B1AAA5D}.Release|x86.ActiveCfg = Release|Win32 - {8E31A619-F4F8-413F-A973-4EE37B1AAA5D}.Release|x86.Build.0 = Release|Win32 - {8E31A619-F4F8-413F-A973-4EE37B1AAA5D}.Release|x64.ActiveCfg = Release|x64 - {8E31A619-F4F8-413F-A973-4EE37B1AAA5D}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {8F18CBD7-4116-4956-BCD8-20D688A4CBD1} = {AEA1D9F7-EA95-4BF7-8E6D-0EA068077943} - {C3A65381-8FD3-4F69-B29E-654B4B0ED136} = {AEA1D9F7-EA95-4BF7-8E6D-0EA068077943} - {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84} = {E14090F7-2FE9-47EE-A331-14ED71801FDE} - {8E31A619-F4F8-413F-A973-4EE37B1AAA5D} = {AEA1D9F7-EA95-4BF7-8E6D-0EA068077943} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {CFB3C228-4C26-4746-8E0C-71C310403E8C} - EndGlobalSection -EndGlobal diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex_Desktop_2019_Win10.sln b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex_Desktop_2019_Win10.sln deleted file mode 100644 index 453e771..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex_Desktop_2019_Win10.sln +++ /dev/null @@ -1,50 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.28729.10 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXTex", "DirectXTex\DirectXTex_Desktop_2019_Win10.vcxproj", "{371B9FA9-4C90-4AC6-A123-ACED756D6C77}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5200A2F8-5215-421E-BCE6-E8DCDAB7779D}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|ARM64 = Debug|ARM64 - Debug|x86 = Debug|x86 - Debug|x64 = Debug|x64 - Profile|ARM64 = Profile|ARM64 - Profile|x86 = Profile|x86 - Profile|x64 = Profile|x64 - Release|ARM64 = Release|ARM64 - Release|x86 = Release|x86 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|ARM64.Build.0 = Debug|ARM64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|x86.ActiveCfg = Debug|Win32 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|x86.Build.0 = Debug|Win32 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|x64.ActiveCfg = Debug|x64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|x64.Build.0 = Debug|x64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|ARM64.ActiveCfg = Profile|ARM64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|ARM64.Build.0 = Profile|ARM64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|x86.ActiveCfg = Profile|Win32 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|x86.Build.0 = Profile|Win32 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|x64.ActiveCfg = Profile|x64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|x64.Build.0 = Profile|x64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|ARM64.ActiveCfg = Release|ARM64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|ARM64.Build.0 = Release|ARM64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|x86.ActiveCfg = Release|Win32 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|x86.Build.0 = Release|Win32 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|x64.ActiveCfg = Release|x64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {22D52797-6BAE-4409-AE3B-513587E92758} - EndGlobalSection -EndGlobal diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex_Desktop_2022.sln b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex_Desktop_2022.sln deleted file mode 100644 index 57cb16f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex_Desktop_2022.sln +++ /dev/null @@ -1,107 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 16.0.28729.10 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXTex", "DirectXTex\DirectXTex_Desktop_2022.vcxproj", "{371B9FA9-4C90-4AC6-A123-ACED756D6C77}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "texassemble", "Texassemble\Texassemble_Desktop_2022.vcxproj", "{8F18CBD7-4116-4956-BCD8-20D688A4CBD1}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "texconv", "Texconv\Texconv_Desktop_2022.vcxproj", "{C3A65381-8FD3-4F69-B29E-654B4B0ED136}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DDSView", "DDSView\DDSView_Desktop_2022.vcxproj", "{9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{AEA1D9F7-EA95-4BF7-8E6D-0EA068077943}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Sample", "Sample", "{E14090F7-2FE9-47EE-A331-14ED71801FDE}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "texdiag", "Texdiag\texdiag_Desktop_2022.vcxproj", "{8E31A619-F4F8-413F-A973-4EE37B1AAA5D}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A40FB626-EA42-48D5-AE40-EE5A6FD3742E}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x86 = Debug|x86 - Debug|x64 = Debug|x64 - Profile|x86 = Profile|x86 - Profile|x64 = Profile|x64 - Release|x86 = Release|x86 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|x86.ActiveCfg = Debug|Win32 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|x86.Build.0 = Debug|Win32 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|x64.ActiveCfg = Debug|x64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|x64.Build.0 = Debug|x64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|x86.ActiveCfg = Profile|Win32 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|x86.Build.0 = Profile|Win32 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|x64.ActiveCfg = Profile|x64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|x64.Build.0 = Profile|x64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|x86.ActiveCfg = Release|Win32 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|x86.Build.0 = Release|Win32 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|x64.ActiveCfg = Release|x64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|x64.Build.0 = Release|x64 - {8F18CBD7-4116-4956-BCD8-20D688A4CBD1}.Debug|x86.ActiveCfg = Debug|Win32 - {8F18CBD7-4116-4956-BCD8-20D688A4CBD1}.Debug|x86.Build.0 = Debug|Win32 - {8F18CBD7-4116-4956-BCD8-20D688A4CBD1}.Debug|x64.ActiveCfg = Debug|x64 - {8F18CBD7-4116-4956-BCD8-20D688A4CBD1}.Debug|x64.Build.0 = Debug|x64 - {8F18CBD7-4116-4956-BCD8-20D688A4CBD1}.Profile|x86.ActiveCfg = Profile|Win32 - {8F18CBD7-4116-4956-BCD8-20D688A4CBD1}.Profile|x86.Build.0 = Profile|Win32 - {8F18CBD7-4116-4956-BCD8-20D688A4CBD1}.Profile|x64.ActiveCfg = Profile|x64 - {8F18CBD7-4116-4956-BCD8-20D688A4CBD1}.Profile|x64.Build.0 = Profile|x64 - {8F18CBD7-4116-4956-BCD8-20D688A4CBD1}.Release|x86.ActiveCfg = Release|Win32 - {8F18CBD7-4116-4956-BCD8-20D688A4CBD1}.Release|x86.Build.0 = Release|Win32 - {8F18CBD7-4116-4956-BCD8-20D688A4CBD1}.Release|x64.ActiveCfg = Release|x64 - {8F18CBD7-4116-4956-BCD8-20D688A4CBD1}.Release|x64.Build.0 = Release|x64 - {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Debug|x86.ActiveCfg = Debug|Win32 - {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Debug|x86.Build.0 = Debug|Win32 - {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Debug|x64.ActiveCfg = Debug|x64 - {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Debug|x64.Build.0 = Debug|x64 - {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Profile|x86.ActiveCfg = Profile|Win32 - {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Profile|x86.Build.0 = Profile|Win32 - {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Profile|x64.ActiveCfg = Profile|x64 - {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Profile|x64.Build.0 = Profile|x64 - {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Release|x86.ActiveCfg = Release|Win32 - {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Release|x86.Build.0 = Release|Win32 - {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Release|x64.ActiveCfg = Release|x64 - {C3A65381-8FD3-4F69-B29E-654B4B0ED136}.Release|x64.Build.0 = Release|x64 - {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Debug|x86.ActiveCfg = Debug|Win32 - {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Debug|x86.Build.0 = Debug|Win32 - {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Debug|x64.ActiveCfg = Debug|x64 - {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Debug|x64.Build.0 = Debug|x64 - {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Profile|x86.ActiveCfg = Profile|Win32 - {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Profile|x86.Build.0 = Profile|Win32 - {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Profile|x64.ActiveCfg = Profile|x64 - {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Profile|x64.Build.0 = Profile|x64 - {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Release|x86.ActiveCfg = Release|Win32 - {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Release|x86.Build.0 = Release|Win32 - {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Release|x64.ActiveCfg = Release|x64 - {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84}.Release|x64.Build.0 = Release|x64 - {8E31A619-F4F8-413F-A973-4EE37B1AAA5D}.Debug|x86.ActiveCfg = Debug|Win32 - {8E31A619-F4F8-413F-A973-4EE37B1AAA5D}.Debug|x86.Build.0 = Debug|Win32 - {8E31A619-F4F8-413F-A973-4EE37B1AAA5D}.Debug|x64.ActiveCfg = Debug|x64 - {8E31A619-F4F8-413F-A973-4EE37B1AAA5D}.Debug|x64.Build.0 = Debug|x64 - {8E31A619-F4F8-413F-A973-4EE37B1AAA5D}.Profile|x86.ActiveCfg = Profile|Win32 - {8E31A619-F4F8-413F-A973-4EE37B1AAA5D}.Profile|x86.Build.0 = Profile|Win32 - {8E31A619-F4F8-413F-A973-4EE37B1AAA5D}.Profile|x64.ActiveCfg = Profile|x64 - {8E31A619-F4F8-413F-A973-4EE37B1AAA5D}.Profile|x64.Build.0 = Profile|x64 - {8E31A619-F4F8-413F-A973-4EE37B1AAA5D}.Release|x86.ActiveCfg = Release|Win32 - {8E31A619-F4F8-413F-A973-4EE37B1AAA5D}.Release|x86.Build.0 = Release|Win32 - {8E31A619-F4F8-413F-A973-4EE37B1AAA5D}.Release|x64.ActiveCfg = Release|x64 - {8E31A619-F4F8-413F-A973-4EE37B1AAA5D}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {8F18CBD7-4116-4956-BCD8-20D688A4CBD1} = {AEA1D9F7-EA95-4BF7-8E6D-0EA068077943} - {C3A65381-8FD3-4F69-B29E-654B4B0ED136} = {AEA1D9F7-EA95-4BF7-8E6D-0EA068077943} - {9D3EDCAD-A800-43F0-B77F-FE6E4DFA3D84} = {E14090F7-2FE9-47EE-A331-14ED71801FDE} - {8E31A619-F4F8-413F-A973-4EE37B1AAA5D} = {AEA1D9F7-EA95-4BF7-8E6D-0EA068077943} - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {CFB3C228-4C26-4746-8E0C-71C310403E8C} - EndGlobalSection -EndGlobal diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex_Desktop_2022_Win10.sln b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex_Desktop_2022_Win10.sln deleted file mode 100644 index 1478872..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex_Desktop_2022_Win10.sln +++ /dev/null @@ -1,50 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 16.0.28729.10 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXTex", "DirectXTex\DirectXTex_Desktop_2022_Win10.vcxproj", "{371B9FA9-4C90-4AC6-A123-ACED756D6C77}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5200A2F8-5215-421E-BCE6-E8DCDAB7779D}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|ARM64 = Debug|ARM64 - Debug|x86 = Debug|x86 - Debug|x64 = Debug|x64 - Profile|ARM64 = Profile|ARM64 - Profile|x86 = Profile|x86 - Profile|x64 = Profile|x64 - Release|ARM64 = Release|ARM64 - Release|x86 = Release|x86 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|ARM64.Build.0 = Debug|ARM64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|x86.ActiveCfg = Debug|Win32 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|x86.Build.0 = Debug|Win32 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|x64.ActiveCfg = Debug|x64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Debug|x64.Build.0 = Debug|x64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|ARM64.ActiveCfg = Profile|ARM64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|ARM64.Build.0 = Profile|ARM64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|x86.ActiveCfg = Profile|Win32 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|x86.Build.0 = Profile|Win32 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|x64.ActiveCfg = Profile|x64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Profile|x64.Build.0 = Profile|x64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|ARM64.ActiveCfg = Release|ARM64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|ARM64.Build.0 = Release|ARM64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|x86.ActiveCfg = Release|Win32 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|x86.Build.0 = Release|Win32 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|x64.ActiveCfg = Release|x64 - {371B9FA9-4C90-4AC6-A123-ACED756D6C77}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {22D52797-6BAE-4409-AE3B-513587E92758} - EndGlobalSection -EndGlobal diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex_GDK_2019.sln b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex_GDK_2019.sln deleted file mode 100644 index 7da1b29..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex_GDK_2019.sln +++ /dev/null @@ -1,51 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30404.54 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXTex_GDK_2019", "DirectXTex\DirectXTex_GDK_2019.vcxproj", "{E66DD892-857B-4E89-B135-5E2A971A9933}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{AB602393-CA4A-4D64-913E-E37D85A6CC6D}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Gaming.Desktop.x64 = Debug|Gaming.Desktop.x64 - Debug|Gaming.Xbox.Scarlett.x64 = Debug|Gaming.Xbox.Scarlett.x64 - Debug|Gaming.Xbox.XboxOne.x64 = Debug|Gaming.Xbox.XboxOne.x64 - Profile|Gaming.Desktop.x64 = Profile|Gaming.Desktop.x64 - Profile|Gaming.Xbox.Scarlett.x64 = Profile|Gaming.Xbox.Scarlett.x64 - Profile|Gaming.Xbox.XboxOne.x64 = Profile|Gaming.Xbox.XboxOne.x64 - Release|Gaming.Desktop.x64 = Release|Gaming.Desktop.x64 - Release|Gaming.Xbox.Scarlett.x64 = Release|Gaming.Xbox.Scarlett.x64 - Release|Gaming.Xbox.XboxOne.x64 = Release|Gaming.Xbox.XboxOne.x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E66DD892-857B-4E89-B135-5E2A971A9933}.Debug|Gaming.Desktop.x64.ActiveCfg = Debug|Gaming.Desktop.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Debug|Gaming.Desktop.x64.Build.0 = Debug|Gaming.Desktop.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Debug|Gaming.Xbox.Scarlett.x64.ActiveCfg = Debug|Gaming.Xbox.Scarlett.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Debug|Gaming.Xbox.Scarlett.x64.Build.0 = Debug|Gaming.Xbox.Scarlett.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Debug|Gaming.Xbox.XboxOne.x64.ActiveCfg = Debug|Gaming.Xbox.XboxOne.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Debug|Gaming.Xbox.XboxOne.x64.Build.0 = Debug|Gaming.Xbox.XboxOne.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Profile|Gaming.Desktop.x64.ActiveCfg = Profile|Gaming.Desktop.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Profile|Gaming.Desktop.x64.Build.0 = Profile|Gaming.Desktop.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Profile|Gaming.Xbox.Scarlett.x64.ActiveCfg = Profile|Gaming.Xbox.Scarlett.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Profile|Gaming.Xbox.Scarlett.x64.Build.0 = Profile|Gaming.Xbox.Scarlett.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Profile|Gaming.Xbox.XboxOne.x64.ActiveCfg = Profile|Gaming.Xbox.XboxOne.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Profile|Gaming.Xbox.XboxOne.x64.Build.0 = Profile|Gaming.Xbox.XboxOne.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Release|Gaming.Desktop.x64.ActiveCfg = Release|Gaming.Desktop.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Release|Gaming.Desktop.x64.Build.0 = Release|Gaming.Desktop.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Release|Gaming.Xbox.Scarlett.x64.ActiveCfg = Release|Gaming.Xbox.Scarlett.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Release|Gaming.Xbox.Scarlett.x64.Build.0 = Release|Gaming.Xbox.Scarlett.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Release|Gaming.Xbox.XboxOne.x64.ActiveCfg = Release|Gaming.Xbox.XboxOne.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Release|Gaming.Xbox.XboxOne.x64.Build.0 = Release|Gaming.Xbox.XboxOne.x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {40D61785-B6CB-4A60-89E6-544E89B61BE0} - EndGlobalSection -EndGlobal diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex_GDK_2022.sln b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex_GDK_2022.sln deleted file mode 100644 index 55e5390..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex_GDK_2022.sln +++ /dev/null @@ -1,51 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 16.0.30404.54 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXTex_GDK_2022", "DirectXTex\DirectXTex_GDK_2022.vcxproj", "{E66DD892-857B-4E89-B135-5E2A971A9933}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{AB602393-CA4A-4D64-913E-E37D85A6CC6D}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Gaming.Desktop.x64 = Debug|Gaming.Desktop.x64 - Debug|Gaming.Xbox.Scarlett.x64 = Debug|Gaming.Xbox.Scarlett.x64 - Debug|Gaming.Xbox.XboxOne.x64 = Debug|Gaming.Xbox.XboxOne.x64 - Profile|Gaming.Desktop.x64 = Profile|Gaming.Desktop.x64 - Profile|Gaming.Xbox.Scarlett.x64 = Profile|Gaming.Xbox.Scarlett.x64 - Profile|Gaming.Xbox.XboxOne.x64 = Profile|Gaming.Xbox.XboxOne.x64 - Release|Gaming.Desktop.x64 = Release|Gaming.Desktop.x64 - Release|Gaming.Xbox.Scarlett.x64 = Release|Gaming.Xbox.Scarlett.x64 - Release|Gaming.Xbox.XboxOne.x64 = Release|Gaming.Xbox.XboxOne.x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E66DD892-857B-4E89-B135-5E2A971A9933}.Debug|Gaming.Desktop.x64.ActiveCfg = Debug|Gaming.Desktop.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Debug|Gaming.Desktop.x64.Build.0 = Debug|Gaming.Desktop.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Debug|Gaming.Xbox.Scarlett.x64.ActiveCfg = Debug|Gaming.Xbox.Scarlett.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Debug|Gaming.Xbox.Scarlett.x64.Build.0 = Debug|Gaming.Xbox.Scarlett.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Debug|Gaming.Xbox.XboxOne.x64.ActiveCfg = Debug|Gaming.Xbox.XboxOne.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Debug|Gaming.Xbox.XboxOne.x64.Build.0 = Debug|Gaming.Xbox.XboxOne.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Profile|Gaming.Desktop.x64.ActiveCfg = Profile|Gaming.Desktop.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Profile|Gaming.Desktop.x64.Build.0 = Profile|Gaming.Desktop.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Profile|Gaming.Xbox.Scarlett.x64.ActiveCfg = Profile|Gaming.Xbox.Scarlett.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Profile|Gaming.Xbox.Scarlett.x64.Build.0 = Profile|Gaming.Xbox.Scarlett.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Profile|Gaming.Xbox.XboxOne.x64.ActiveCfg = Profile|Gaming.Xbox.XboxOne.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Profile|Gaming.Xbox.XboxOne.x64.Build.0 = Profile|Gaming.Xbox.XboxOne.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Release|Gaming.Desktop.x64.ActiveCfg = Release|Gaming.Desktop.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Release|Gaming.Desktop.x64.Build.0 = Release|Gaming.Desktop.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Release|Gaming.Xbox.Scarlett.x64.ActiveCfg = Release|Gaming.Xbox.Scarlett.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Release|Gaming.Xbox.Scarlett.x64.Build.0 = Release|Gaming.Xbox.Scarlett.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Release|Gaming.Xbox.XboxOne.x64.ActiveCfg = Release|Gaming.Xbox.XboxOne.x64 - {E66DD892-857B-4E89-B135-5E2A971A9933}.Release|Gaming.Xbox.XboxOne.x64.Build.0 = Release|Gaming.Xbox.XboxOne.x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {40D61785-B6CB-4A60-89E6-544E89B61BE0} - EndGlobalSection -EndGlobal diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex_Windows10_2019.sln b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex_Windows10_2019.sln deleted file mode 100644 index 25f7500..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex_Windows10_2019.sln +++ /dev/null @@ -1,48 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 15.0.27130.2020 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXTex", "DirectXTex\DirectXTex_Windows10_2019.vcxproj", "{FB3F52B5-BFE8-43FD-836F-363735DAB738}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8D3EE191-AC2D-4DA6-97EB-058D8A28B933}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|ARM = Debug|ARM - Debug|ARM64 = Debug|ARM64 - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|ARM = Release|ARM - Release|ARM64 = Release|ARM64 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Debug|ARM.ActiveCfg = Debug|ARM - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Debug|ARM.Build.0 = Debug|ARM - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Debug|ARM64.Build.0 = Debug|ARM64 - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Debug|x64.ActiveCfg = Debug|x64 - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Debug|x64.Build.0 = Debug|x64 - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Debug|x86.ActiveCfg = Debug|Win32 - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Debug|x86.Build.0 = Debug|Win32 - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Release|ARM.ActiveCfg = Release|ARM - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Release|ARM.Build.0 = Release|ARM - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Release|ARM64.ActiveCfg = Release|ARM64 - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Release|ARM64.Build.0 = Release|ARM64 - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Release|x64.ActiveCfg = Release|x64 - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Release|x64.Build.0 = Release|x64 - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Release|x86.ActiveCfg = Release|Win32 - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {E507EBC0-EBB7-4519-A886-15B7E0917E2F} - EndGlobalSection -EndGlobal diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex_Windows10_2022.sln b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex_Windows10_2022.sln deleted file mode 100644 index 887fc1b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex_Windows10_2022.sln +++ /dev/null @@ -1,48 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 15.0.27130.2020 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXTex", "DirectXTex\DirectXTex_Windows10_2022.vcxproj", "{FB3F52B5-BFE8-43FD-836F-363735DAB738}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8D3EE191-AC2D-4DA6-97EB-058D8A28B933}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|ARM = Debug|ARM - Debug|ARM64 = Debug|ARM64 - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|ARM = Release|ARM - Release|ARM64 = Release|ARM64 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Debug|ARM.ActiveCfg = Debug|ARM - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Debug|ARM.Build.0 = Debug|ARM - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Debug|ARM64.Build.0 = Debug|ARM64 - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Debug|x64.ActiveCfg = Debug|x64 - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Debug|x64.Build.0 = Debug|x64 - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Debug|x86.ActiveCfg = Debug|Win32 - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Debug|x86.Build.0 = Debug|Win32 - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Release|ARM.ActiveCfg = Release|ARM - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Release|ARM.Build.0 = Release|ARM - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Release|ARM64.ActiveCfg = Release|ARM64 - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Release|ARM64.Build.0 = Release|ARM64 - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Release|x64.ActiveCfg = Release|x64 - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Release|x64.Build.0 = Release|x64 - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Release|x86.ActiveCfg = Release|Win32 - {FB3F52B5-BFE8-43FD-836F-363735DAB738}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {E507EBC0-EBB7-4519-A886-15B7E0917E2F} - EndGlobalSection -EndGlobal diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex_XboxOneXDK_2017.sln b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex_XboxOneXDK_2017.sln deleted file mode 100644 index 8bf5561..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/DirectXTex_XboxOneXDK_2017.sln +++ /dev/null @@ -1,33 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27130.2020 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DirectXTex_XboxOneXDK_2017", "DirectXTex\DirectXTex_XboxOneXDK_2017.vcxproj", "{879B5023-53B7-4108-AEAE-F019C2E9410D}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{98781974-DA38-4814-9D99-4C17922F35F7}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Durango = Debug|Durango - Profile|Durango = Profile|Durango - Release|Durango = Release|Durango - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {879B5023-53B7-4108-AEAE-F019C2E9410D}.Debug|Durango.ActiveCfg = Debug|Durango - {879B5023-53B7-4108-AEAE-F019C2E9410D}.Debug|Durango.Build.0 = Debug|Durango - {879B5023-53B7-4108-AEAE-F019C2E9410D}.Profile|Durango.ActiveCfg = Profile|Durango - {879B5023-53B7-4108-AEAE-F019C2E9410D}.Profile|Durango.Build.0 = Profile|Durango - {879B5023-53B7-4108-AEAE-F019C2E9410D}.Release|Durango.ActiveCfg = Release|Durango - {879B5023-53B7-4108-AEAE-F019C2E9410D}.Release|Durango.Build.0 = Release|Durango - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {AEA78A02-2861-40C0-86D1-72DC17A9DE13} - EndGlobalSection -EndGlobal diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/HISTORY.md b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/HISTORY.md deleted file mode 100644 index f1504ee..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/HISTORY.md +++ /dev/null @@ -1,538 +0,0 @@ -# DirectXTex texture processing library - -http://go.microsoft.com/fwlink/?LinkId=248926 - -Release available for download on [GitHub](https://github.com/microsoft/DirectXTex/releases) - -## Release History - -### May 9, 2022 -* TGA reader updated to support 24-bit paletted uncompressed color-mapped images (used by a DCC application) -* Added IsBGR utility method -* Workaround for driver issue on some systems using DirectX 11 Capture method -* Fix for problem with resizing/mipmaps generation for HDR content which should avoid going through WIC code paths -* Minor updates for VS 2022 (17.2) -* CMake project updates (now supports MSVC, clang/LLVM, and MinGW) -* Updated D3DX12 internal copy with latest changes from DirectX-Headers GitHub -* Retired VS 2017 projects -* Code cleanup -* Reformat source using updated .editorconfig settings -* texconv: Improve -nmap handling for 16-bit sources going to BC formats - -### March 24, 2022 -* Fixed end-point bounds issue with BC6H CPU compressor if none of the pixels are in 0-1 range -* Fixed bug in alpha-to-coverage computation -* Add support for installable WIC codecs for HEIF and WEBP (if present) -* Update build switches for SDL recommendations -* CMake project updates and UWP platform CMakePresets -* Code cleaup for tools -* Optional C++17 usage in a few places - -### February 28, 2022 -* Updated D3DX12 internal copy with latest changes from GitHub -* Code and project review including fixing clang v13 warnings -* Added CMakePresets.json - -### November 8, 2021 -* VS 2022 support -* Updated D3DX12 internal copy with latest change from GitHubf -* Minor code and project review -* VS 2017 projects updated to require the Windows 10 SDK (19401) -* texassemble/texconv: Updated with 12.2 for ``-fl`` switch -* texassemble/texconv/texdiag: Fixed potential locale issue with ``-flist`` - -### September 28, 2021 -* Minor code and project cleanup - -### August 1, 2021 -* Fixed weighting bug in custom linear filtering for wrap/mirroring -* Added VS 2022 Preview projects -* texconv: Made default output extension to be lower-case like most Windows applications -* texconv: updated colorspace rotation names for -rotatecolor switch -* texassemble, texconv: Order of operations fix for -swizzle using 0, 1 -* Minor code review - -### June 9, 2021 -* Minor bug fix for metadata behavior when using ``DDS_FLAGS_NO_16BPP`` flag for B5G6R5 content -* texdiag: added ``-c`` and ``-t`` switches for diff command -* texconv: Fixed bug in ``-m`` switch handling when resizing changes the max mipmap count -* texconv et al: improved ``-flist`` switch to support wildcards and file exclusions -* texconv et al: Added 'BGR' alias to ``-f`` switch for the B8G8R8X8_UNORM format -* WICTextureLoader / DDSTextureLoader12 updated to use typed enum bitmask flags for loadFlags parameter -* Minor code review - -### April 6, 2021 -* DDS reader updated to accept nVidia Texture Tool v1 single-channel and dual-channel files marked as RGB instead of LUMINANCE -* Fixed TGA reader regression with files smaller than 26 bytes total -* Removed use of ``CreateStreamOnHGlobal``, ``CreateStreamOverRandomAccessStream``, and ``SHCreateMemStream`` for WICToMemory functions -* Fix for the DirectX 12 ``CaptureTexture`` for reserved and MSAA resources -* Minor code and project cleanup -* texassemble: added ``-stripmips`` switch -* texassemble, texconv: the ``swizzle`` switch now accepts ``0`` and ``1`` values in swizzle masks -* texconv: added "709toDisplayP3" and "DisplayP3to709" to ``-rotatecolor`` switch -* texconv: Fixed ``-reconstructz`` for UNORM formats -* texassemble, texconv, texdiag: Updated with descriptions for HRESULT failure codes, and always uses exit code 1 on failure - -### January 9, 2021 -* Windows Subsystem for Linux support -* Code review for improved conformance -* CMake updated to support package install -* texassemble: Merge command now supports ``-swizzle`` option -* texconv: Updated with ``-r:keep`` and ``-swizzle`` options - -### November 11, 2020 -* Use ``SHCreateMemStream`` instead of ``CreateStreamOnHGlobal`` for Win32 on Windows 8.x or Windows 10 -* Updated D3DX12 internal copy with latest change from GitHub -* Minor code and project cleanup - -### September 30, 2020 -* Added ``TGA_FLAGS`` [flags](https://github.com/microsoft/DirectXTex/wiki/TGA-I-O-Functions#related-flags) to TGA reader/writer to control RGB vs. BGR, handling for all zero alpha channels, and TGA 2.0 colorspace metadata - * TGA reader will now return a ``DXGI_FORMAT_*_SRGB`` format if TGA 2.0 colorspace metadata contains 2.2 or 2.4 gamma - * Added forwarders for existing non-flags TGA functions, so there are no breaking changes -* ``R16_SNORM`` and ``R8_SNORM`` pixel write code updated to round instead of truncate to better match DirectXMath behavior -* Fixed bug in standalone WICTextureLoader for DX11/DX12 that resulted in ``WINCODEC_ERR_INSUFFICIENTBUFFER`` for some resize requests -* Added ``Ex`` variants for DDSTextureLoader/WICTextureLoader for DX9 to support loading resources for non-DEFAULT pools -* Minor code and project cleanup - -### August 15, 2020 -* Added ``DDS_FLAGS_ALLOW_LARGE_FILES`` flag for DDS loader to allow textures with dimensions that are too big for Direct3D -* Added ``FormatDataType`` function -* Fixed bug with DX12 ``Capture`` with 'small alignment' textures -* Code review and project updates -* Added GDK projects -* texassemble: updated with ``-fl`` switch for feature level based warning -* texconv: updated with ``-reconstructz`` switch for BC5 compressed normal map view conversion - -### July 2, 2020 -* Minor warning fixes for VS 2019 (16.7) -* CMake updates -* texassemble: Fixed animated gif handling with transparency - -### June 15, 2020 -* Code cleanup for some new VC++ 16.7 warnings and static code analysis -* texconv: Updated with support for Portable Pix Map (ppm) & Portable Float Map (pfm) file formats - -### June 1, 2020 -* Converted to typed enum bitmask flags (see release notes for details on this potential *breaking change*) - + **ComputePitch**, **xxxDDSxxx**, **xxxWICxxx**, **FlipRotate**, **Resize**, **Convert**, **GenerateMipMaps**, **GenerateMipMaps3D**, **PremultiplyAlpha**, **Compress**, **ComputeNormalMap**, **CopyRectangle**, **ComputeMSE** -* ``WIC_FLAGS_DEFAULT_SRGB`` / ``WIC_LOADER_SRGB_DEFAULT`` flag added when loading image via WIC without explicit colorspace metadata -* WIC loader for ``PNG`` codec now checks ``gAMA`` chunk to determine colorspace if the ``sRGB`` chunk is not found for legacy sRGB detection. -* Fixed conformance issues when using ``/Zc:preprocessor`` -* CMake project updates - -### May 10, 2020 -* HDR (RGBE Radiance) file format writer updated to accept half16 input -* Code cleanup -* Updated D3DX12 internal copy to Windows 10 SDK (19041) version -* texassemble, texconv, texdiag: Updated with ``-l`` switch for case-sensitive file systems -* texconv: Added ``-dx9`` switch to force legacy compatible DDS files -* texconv: Collapsed ``-bcuniform``, ``-bcdither``, ``-bcquick``, and ``-bcmax`` into one ``-bc`` switch -* Updates to **DDSTextureLoader**, **ScreenGrab**, and **WICTextureLoader** including new DX9 version - -### April 3, 2020 -* Updated D3DX12 internal copy to latest version -* DDS loader updated for another BC7 FourCC variant -* Code review (``constexpr`` / ``noexcept`` usage) -* CMake updated for PCH usage with 3.16 or later - -### February 14, 2020 -* Fixed quality bug in BC4S/BC5S compressor -* Guard for divide-by-zero case in **PremultiplyAlpha** -* texconv: added ``-at`` switch for alpha threshold value with BC1 compression -* texconv: Fixed ``-nmap`` when outputting compressed UNORM formats -* Code and project cleaup -* Retired VS 2015 projects - -### December 17, 2019 -* Added ARM64 platform to VS 2019 Win32 desktop Win10 project -* Updated CMake project -* Code cleaup - -### October 17, 2019 -* Codec readers updated to return ``TEX_ALPHA_MODE_OPAQUE`` if reader returned an alpha channel due to conversion -* Added DDS reader support for 'non-standard' BC6H/BC7 FourCC codes used by nVidia texture tools -* TGA codec updated for TGA 2.0 -* Minor code review -* Updated ScreenGrab module -* texconv: Added ``-fixbc4x4switch`` - -### August 21, 2019 -* Updated D3DX12 internal copy to latest version -* Added texassemble, texconv, and texdiag to CMake project -* Code cleanup - -### June 30, 2019 -* Additional validation for Direct3D 11 texture loaders -* Clang/LLVM warning cleanup -* Renamed ``DirectXTex_Windows10.vcxproj`` to ``_Windows10_2017.vcxproj`` -* Added VS 2019 UWP project - -### May 30, 2019 -* Regenerated shaders using Windows 10 April 2019 Update SDK (18362) -* Added CMake project files -* Code cleanup - -### April 26, 2019 -* Added VS 2019 desktop projects -* Code cleanup for texture loaders -* Officially dropped Windows Vista support -* Minor code cleanup - -### February 7, 2019 -* Added **ScaleMipMapsAlphaForCoverage** function to the library -* WIC Writer now has two new flags: ``WIC_FLAGS_FORCE_SRGB`` and ``WIC_FLAGS_FORCE_LINEAR`` -* texassemble: added ``array-strip`` command -* texconv: added ``-inverty``, ``-keepcoverage`` switches - -### November 16, 2018 -* VS 2017 updated for Windows 10 October 2018 Update SDK (17763) -* ARM64 platform configurations added to UWP projects - -### October 25, 2018 -* Use UTF-8 instead of ANSI for narrow strings -* Updated D3DX12 internal copy to latest version -* Minor code cleanup - -### August 17, 2018 -* Fixed problem loading legacy DDS files containing FOURCC pixel formats with ``ALPHAPIXELS`` also set -* Fixed ``FlipRotate`` bug when doing 180 degree rotation -* Updated for VS 2017 15.8 - -### August 5, 2018 -* Improved support and validation for 16k textures (requires x64 native) -* ``ComputePitch`` now returns an HRESULT -* Fix BC7 GPU shaders on WARP device - -### July 3, 2018 -* BC7 CPU codec fix for 3subsets/``-bcmax`` and minor optimization -* BC7 GPU codec quantize fix and pbit optimization -* BC6H CPU codec bounds checking fix -* Code and project cleanup - -### May 31, 2018 -* Fix for **IsAlphaAllOpaque** for 'near opaque' values -* VS 2017 updated for Windows 10 April 2018 Update SDK (17134) - -### May 11, 2018 -* Workaround for WIC issue doing FP32->FP16 conversions -* Updated for VS 2017 15.7 update warnings -* Code and project cleanup -* Retired VS 2013 projects - -### April 23, 2018 -* Code cleanup -* texconv: Updated with support reading "Extended BMP" files using DXTn -* texconv: Updated to handle non-power-of-2 volume textures with mipmaps -* texassemble, texconv, texdiag: support format name aliases like DXT3, RGBA, BGRA, FP16, etc. in addition to truncated ``DXGI_FORMAT_`` values - -### February 9, 2018 -* HDR (RGBE Radiance) file format reader updated to support ``#?RGBE`` signature -* texconv: Added ``-rotatecolor`` and ``-nits`` switches -* texassemble: Added merge and gif commands -* texdiag: added dumpdds command - -### February 7, 2018 -* Fixed bug with GPU BC7 encoding (mode 1, fixup 6) -* Updated for a few more VS 2017 warnings -* Code cleanup - -### December 13, 2017 -* Updated for VS 2017 15.5 update warnings -* Support building library with ``_XM_NO_XMVECTOR_OVERLOADS_`` -* Code cleanup - -### November 1, 2017 -* VS 2017 updated for Windows 10 Fall Creators Update SDK (16299) - -### September 22, 2017 -* Updated for VS 2017 15.3 update ``/permissive-`` changes -* WIC writer and ScreenGrab updated to use non-sRGB metadata for PNG -* texassemble, texconv, texdiag: added ``-flist`` option - -### July 26, 2017 -* Support for reading non-standard DDS files written by nVidia Texture Tools (NVTT) -* Fix for **ComputeMSE** when using ``CMSE_IMAGE2_X2_BIAS`` -* Fix for WIC writer then codec target format requires a palette -* Code cleanup - -### April 24, 2017 -* VS 2017 project updates -* Regenerated shaders using Windows 10 Creators Update SDK (15063) -* Updated D3DX12 internal copy to latest version - -### April 7, 2017 -* VS 2017 updated for Windows Creators Update SDK (15063) -* texassemble: ``-tonemap`` switch -* texconv: ``-wicmulti`` switch - -### January 31, 2017 -* DirectX 12 versions of **IsSupported**, **CreateTexture** (PrepareUpload), and **CaptureTexture** -* Update to DirectX 11 version of **IsSupported** -* WIC format 40bppCMYKAlpha should be converted to RGBA8 rather than RGBA16 -* DDS support for L8A8 with bit-count 8 rather than 16 -* ``DXGI_FORMAT_R32G8X24_TYPELESS`` and ``DXGI_FORMAT_R24G8_TYPELESS`` should be IsDepthStencil formats -* Updates to DDSTextureLoader, ScreenGrab, and WICTextureLoader -* Minor code cleanup - -### December 5, 2016 -* Fixed over-validation in DDS header parsing -* VS 2017 RC projects added -* Minor code cleanup - -### October 5, 2016 -* *breaking change* Renamed Evaluate to **EvaluateImage**, Transform to **TransformImage** -* texdiag: new command-line tool for texture debugging -* texconv: ``-bcmax``, ``-bcquick``, ``-tonemap``, and ``-x2bias`` switches -* texconv: overwrite writing and ``-y`` switch -* texconv/texassemble: optional OpenEXR support -* texassemble: command syntax with support for generating strip and cross images from cubemap -* Updates to DDSTextureLoader, WICTextureLoader, and ScreenGrab -* Minor code cleanup - -### September 14, 2016 -* [HDR (RGBE Radiance)](https://en.wikipedia.org/wiki/RGBE_image_format) file format reader and writer -* **Evaluate** and **Transform** functions for computing user-defined functions on images -* Fix BC6H GPU shaders on WARP device -* Fix for alignment issues on ARM devices in software compression codec -* Added ``TEX_THRESHOLD_DEFAULT`` (0.5f) constant default alpha threshold value for Convert & Compress -* Minor **CaptureTexture** optimization -* texconv/texassemble: Support for .hdr file format -* texconv: added ``-gpu`` switch to specify adapter to use for GPU-based compression codecs -* texconv: added ``-badtails`` switch to enable loading of legacy DXTn DDS files with incomplete mipchain tails -* texconv: added ``-c`` switch for old-school colorkey/chromakey transparency to alpha conversion -* texconv: added ``-alpha`` switch for reverse premultiply along with ``TEX_PMALPHA_REVERSE`` flag -* texconv: added wildcard support for input filename and optional ``-r`` switch for recursive search - -### August 4, 2016 -* ``CompileShader`` script updated to build external pdbs -* Regenerated shaders using Windows 10 Anniversary Update SDK (14393) - -### August 2, 2016 -* Updated for VS 2015 Update 3 and Windows 10 SDK (14393) - -### August 1, 2016 -* Workaround for bug in XMStoreFloat3SE (impacts conversions to ``DXGI_FORMAT_R9G9B9E5_SHAREDEXP``) -* **DDSTextureLoader12**, **WICTextureLoader12**, and **ScreenGrab12** for Direct3D 12 support -* Minor code cleanup - -### June 27, 2016 -* texconv command-line tool ``-wicq`` and ``-wiclossless`` switches -* Code cleanup - -### April 26, 2016 -* Optional callback from WIC reader functions to query additional metadata -* Retired obsolete adapter code -* Minor code cleanup - -### February 23, 2016 -* Fix to clean up partial or zero-length image files on failed write -* Retired VS 2012 projects - -### November 30, 2015 -* texconv command-line tool ``-fl`` switch now supports 12.0 and 12.1 feature levels -* Updated for VS 2015 Update 1 and Windows 10 SDK (10586) - -### October 30, 2015 -* DDS support for legacy bumpmap formats (V8U8, Q8W8V8U8, V16U16) -* Fix for buffer overread in BC CPU compressor -* Minor code cleanup - -### August 18, 2015 -* Added **GetWICFactory** and **SetWICFactory** -* Updates for new DXGI 1.3 types -* Xbox One platform updates - -### July 29, 2015 -* Fixed rounding problem with 32-bit RGBA/BGRA format conversions -* texconv: use CPU parallel compression for BC1-BC5 (``-singleproc`` disables) -* Updated for VS 2015 and Windows 10 SDK RTM -* Retired VS 2010 and Windows 8.0 Store projects - -### June 18, 2015 -* New ``BC_FLAGS_USE_3SUBSETS`` option for BC7 compressors; now defaults to skipping 3 subset blocks -* Fixed bug with **MakeTypeless** and ``A8_UNORM`` -* Fixed file length validation problem in **LoadDDSFromFile** - -### March 27, 2015 -* Added projects for Windows apps Technical Preview -* Fixed bug with WIC-based mipmap generation for non-WIC supported formats -* Fixed bug with WIC multiframe loader when resizing required -* texconv: Added ``-nmap``/``-nmapamp`` for generating normal maps from height maps -* texconv/texassemble: Updated to load multiframe WIC files (tiff, gif) -* Minor code cleanup - -### November 24, 2014 -* Updates for Visual Studio 2015 Technical Preview -* Minor code cleanup - -### September 22, 2014 -* Format conversion improvements and bug fixes (depth/stencil, alpha-only, float16, RGB -> 1 channel) -* Fixed issue when BC decompressing non-standard compressed rowPitch images -* Explicit calling-convention annotation for all 'public' functions -* Code cleanup -* Xbox One platform updates - -### July 15, 2014 -* texconv command-line tool fixes -* Fixed problem with 'wide' images with CPU **Compress** -* Updates to Xbox One platform support - -### April 3, 2014 -* Windows phone 8.1 platform support - -### February 24, 2014 -* Direct3D 11 video and Xbox One extended format support -* New APIs: **IsPlanar**, **IsPalettized**, **IsDepthStencil**, **ConvertToSinglePlane** -* Added 'alphaWeight' parameter to GPU **Compress** *breaking change* -* texconv ``-aw`` switch to control the alpha weighting for the BC7 GPU compressor -* Fixed bug with ordered dithering in non-WIC conversion codepaths -* Fixed **SaveToDDSxxx** functions when using arbitrary row pitch values - -### January 24, 2014 -* Added sRGB flags for **Compress** (``TEX_COMPRESS_SRGB*``) -* Added 'compress' flag parameter to GPU versions of **Compress** *breaking change* -* Minor fix for potential rounding problem in GPU **Compress** -* Code cleanup (removed ``DXGI_1_2_FORMATS`` control define; ``ScopedObject`` typedef removed) -* Dropped VS 2010 support without the Windows 8.1 SDK (removed ``USE_XNAMATH`` control define) - -### December 24, 2013 -* texconv updated with ``-fl`` and ``-pow2`` command-line switches -* Fixed bug in **Resize** when doing custom filtering which occurred when exactly doubling the image size -* Added move operators to **ScratchImage** and **Blob** classes -* Xbox One platform support - -### October 21, 2013 -* Updated for Visual Studio 2013 and Windows 8.1 SDK RTM -* **PremultiplyAlpha** updated with new 'flags' parameter and to use sRGB correct blending -* Fixed colorspace conversion issue with DirectCompute compressor when compressing for BC7 SRGB - -### August 13, 2013 -* DirectCompute 4.0 BC6H/BC7 compressor integration -* texconv utility uses DirectCompute compression by default for BC6H/BC7, ``-nogpu`` disables use of DirectCompute - -### August 1, 2013 -* Support for BC compression/decompression of non-power-of-2 mipmapped textures -* Fixes for BC6H / BC7 codecs to better match published standard -* Fix for BC4 / BC5 codecs when compressing RGB images -* Minor fix for the BC1-3 codec -* New optional flags for **ComputeMSE** to compare UNORM vs. SNORM images -* New WIC loading flag added to control use of WIC metadata to return sRGB vs. non-sRGB formats -* Code cleanup and /analyze fixes -* Project file cleanup -* texconv utility uses parallel BC compression by default for BC6H/BC7, ``-singleproc`` disables multithreaded behavior - -### July 1, 2013 -* VS 2013 Preview projects added -* SaveToWIC functions updated with new optional ``setCustomProps`` parameter - -### June 15, 2013 -* Custom filtering implementation for **Resize** & **GenerateMipMaps(3D)** - Point, Box, Linear, Cubic, and Triangle - + ``TEX_FILTER_TRIANGLE`` finite low-pass triangle filter - + ``TEX_FILTER_WRAP``, ``TEX_FILTER_MIRROR`` texture semantics for custom filtering - + ``TEX_FILTER_BOX`` alias for ``TEX_FILTER_FANT WIC`` -* Ordered and error diffusion dithering for non-WIC conversion -* sRGB gamma correct custom filtering and conversion -* ``DDS_FLAGS_EXPAND_LUMINANCE`` - Reader conversion option for L8, L16, and A8L8 legacy DDS files -* Added use of WIC metadata for sRGB pixel formats -* Added **BitsPerColor** utility function -* Fixed **Convert** threshold parameter usage -* Non-power-of-2 volume map support, fixed bug with non-square volume maps -* texconv utility update with ``-xlum``, ``-wrap``, and ``-mirror`` options; reworked ``-if`` options for improved dithering -* texassemble utility for creating cubemaps, volume maps, and texture arrays -* DDSTextureLoader and WICTextureLoader sync'd with DirectXTK versions - -### April 16, 2013 -* Updated alpha-mode metadata details in .DDS files -* Added new control flags for **Convert** -* Added new optional flags for **ComputeMSE** -* Fixed conversion handling for sRGB formats -* Fixed internal routines for handling ``R10G10B10_XR_BIAS_A2_UNORM``, ``R9G9B9E5_SHAREDEXP``, and ``FORMAT_R1_UNORM`` -* Fixed WIC I/O for ``GUID_WICPixelFormat32bppRGBE``4 pixel format files (HD Photo) -* Fixed non-square image handling in **GenerateMipMaps3D** -* Fixed some error handling in the DDS load code - -### March 22, 2013 -* Supports reading and writing alpha-mode (straight, premultiplied, etc.) metadata in .DDS files -* Added build option to use WICCreateImagingFactory_Proxy instead of ``CoCreateInstance`` to obtain WIC factory - -### January 29, 2013 -* Added **PremultiplyAlpha** to DirectXTex; ``-pmalpha`` switch for texconv command-line tool -* Fixed problem with forceSRGB implementation for Ex versions of CreateTexture, CreateShaderResourceView, DDSTextureLoader and WICTextureLoader - -### December 11, 2012 -* Ex versions of **CreateTexture**, **CreateShaderResourceView**, **DDSTextureLoader** and **WICTextureLoader** -* Fixed BC2 and BC3 decompression issue for unusual color encoding case -* Converted annotation to SAL2 for improved VS 2012 /analyze experience -* Updated DirectXTex, DDSView, and Texconv with VS 2010 + Windows 8.0 SDK project using official 'property sheets' - -### November 15, 2012 -* Added support for WIC2 when available on Windows 8 and Windows 7 with KB 2670838 -* Added optional ``targetGUID`` parameter to SaveWIC* APIs to influence final container pixel format choice -* Fixed bug in **SaveDDSxxx** which was generating invalid DDS files for 1D dimension textures -* Improved robustness of **CaptureTexture** when resolving MSAA source textures -* Sync'd DDSTextureLoader, ScreenGrab, and WICTextureLoader standalone versions with latest DirectXTK release - -### September 28, 2012 -* Added **ScreenGrab** module for creating runtime screenshots -* Renamed project files for better naming consistency -* New Typeless utilities for DirectXTex -* Some minor code cleanup for DirectXTex's WIC writer function -* Bug fixes and new ``-tu``/``-tf`` options for texconv - -### June 22, 2012 -* Moved to using XNA Math 2.05 instead of XNA Math 2.04 for ``USE_XNAMATH`` builds -* Fixed BGR vs. RGB color channel swizzle problem with 24bpp legacy .DDS files in DirectXTex -* Update to DirectXTex WIC and WICTextureLoader for additional 96bpp float format handling on Windows 8 - -### May 31, 2012 -* Minor fix for DDSTextureLoader's retry fallback that can happen with 10level9 feature levels -* Switched to use ``_DEBUG`` instead of ``DEBUG`` and cleaned up debug warnings -* added Windows Store style application project files for DirectXTex - -### April 20, 2012 -* DirectTex's WIC-based writer opts-in for the Windows 8 BMP encoder option for writing 32 bpp RGBA files with the ``BITMAPV5HEADER`` - -### March 30, 2012 -* WICTextureLoader updated with Windows 8 WIC pixel formats -* DirectXTex updated with limited non-power-of-2 texture support and ``TEX_FILTER_SEPARATE_ALPHA`` option -* Texconv updated with ``-sepalpha`` command-line option -* Added ``USE_XNAMATH`` control define to build DirectXTex using either XNAMath or DirectXMath -* Added VS 2012 project files (which use DirectXMath instead of XNAMath and define ``DXGI_1_2_FORMATS``) - -### March 15, 2012 -* Fix for resource leak in **CreateShaderResourceView** Direct3D 11 helper function in DirectXTex - -### March 5, 2012 -* Fix for too much temp memory allocated by WICTextureLoader; cleaned up legacy 'min/max' macro usage in DirectXTex - -### February 21, 2012 -* WICTextureLoader updated to handle systems and device drivers without BGRA or 16bpp format support - -### February 20, 2012 -* Some code cleanup for DirectXTex and DDSTextureLoader -* Fixed bug in 10:10:10:2 format fixup in the **LoadDDSFromMemory** function -* Fixed bugs in "non-zero alpha" special-case handling in **LoadTGAFromFile** -* Fixed bug in ``_SwizzleScanline`` when copying alpha channel for BGRA<->RGBA swizzling - -### February 11, 2012 -* Update of DDSTextureLoader to also build in Windows Store style apps; added **WICTextureLoader** -* Added CMYK WIC pixel formats to the DirectXTex conversion table - -### January 30, 2012 -* Minor code-cleanup for DirectXTex to enable use of PCH through 'directxtexp.h' header - -### January 24, 2012 -* Some code-cleanup for DirectXTex -* Added DXGI 1.2 implementation for DDSTextureLoader and DirectXTex guarded with ``DXGI_1_2_FORMATS`` compilation define - -### December 16, 2011 -* Fixed x64 compilation warnings in DDSTextureLoader - -### November 30, 2011 -* Fixed some of the constants used in **IsSupportedTexture** -* added ability to strip off top levels of mips in DDSTextureLoader -* changed DirectXTex to use CoCreateInstance rather than LoadLibrary to obtain the WIC factory -* a few minor ``/analyze`` related annotations for DirectXTex - -### October 27, 2011 -* Original release diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/LICENSE b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/LICENSE deleted file mode 100644 index eb3a123..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ - The MIT License (MIT) - -Copyright (c) 2011-2022 Microsoft Corp - -Permission is hereby granted, free of charge, to any person obtaining a copy of this -software and associated documentation files (the "Software"), to deal in the Software -without restriction, including without limitation the rights to use, copy, modify, -merge, publish, distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be included in all copies -or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE -OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/README.md b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/README.md deleted file mode 100644 index ad291c5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/README.md +++ /dev/null @@ -1,116 +0,0 @@ -![DirectX Logo](https://raw.githubusercontent.com/wiki/Microsoft/DirectXTex/X_jpg.jpg) - -# DirectXTex texture processing library - -http://go.microsoft.com/fwlink/?LinkId=248926 - -Copyright (c) Microsoft Corporation. - -**May 9, 2022** - -This package contains DirectXTex, a shared source library for reading and writing ``.DDS`` files, and performing various texture content processing operations including resizing, format conversion, mip-map generation, block compression for Direct3D runtime texture resources, and height-map to normal-map conversion. This library makes use of the Windows Image Component (WIC) APIs. It also includes ``.TGA`` and ``.HDR`` readers and writers since these image file formats are commonly used for texture content processing pipelines, but are not currently supported by a built-in WIC codec. - -This code is designed to build with Visual Studio 2019 (16.7 or later), Visual Studio 2022, or clang for Windows v11 or later. Use of the Windows 10 May 2020 Update SDK ([19041](https://walbourn.github.io/windows-10-may-2020-update-sdk/)) or later is required. - -These components are designed to work without requiring any content from the legacy DirectX SDK. For details, see [Where is the DirectX SDK?](https://aka.ms/dxsdk). - -## Directory Layout - -* ``DirectXTex\`` - - + This contains the DirectXTex library. This includes a full-featured DDS reader and writer including legacy format conversions, a TGA reader and writer, a HDR reader and writer, a WIC-based bitmap reader and writer (BMP, JPEG, PNG, TIFF, and HD Photo), and various texture processing functions. This is intended primarily for tool usage. - -> The majority of the header files here are intended for internal implementation - of the library only (``BC.h``, ``BCDirectCompute.h``, ``DDS.h``, ``DirectXTexP.h``, etc.). Only ``DirectXTex.h`` and ``DirectXTex.inl`` are meant as the 'public' header for the library. - -* ``Texconv\`` - - + This DirectXTex sample is an implementation of the [texconv](https://github.com/Microsoft/DirectXTex/wiki/Texconv) command-line texture utility from the DirectX SDK utilizing DirectXTex rather than D3DX. - - It supports the same arguments as the *Texture Conversion Tool Extended* (``texconvex.exe``) legacy DirectX SDK utility. The primary differences are the ``-10`` and ``-11`` arguments are not applicable and the filter names (``POINT``, ``LINEAR``, ``CUBIC``, ``FANT`` or ``BOX``, ``TRIANGLE``, ``*_DITHER``, ``*_DITHER_DIFFUSION``). This also includes support for the JPEG XR (HD Photo) bitmap format. - -* ``Texassemble\`` - - + This DirectXTex sample is a [command-line utility](https://github.com/Microsoft/DirectXTex/wiki/Texassemble) for creating cubemaps, volume maps, or texture arrays from a set of individual input image files. - -* ``Texdiag\`` - - + This DirectXTex sample is a [command-line utility](https://github.com/Microsoft/DirectXTex/wiki/Texdiag) for analyzing image contents, primarily for debugging purposes. - -* ``DDSView\`` - - + This DirectXTex sample is a simple Direct3D 11-based viewer for DDS files. For array textures or volume maps, the "<" and ">" keyboard keys will show different images contained in the DDS. The "1" through "0" keys can also be used to jump to a specific image index. - -* ``DDSTextureLoader\`` - - + This contains a streamlined version of the legacy DirectX SDK sample *DDSWithoutD3DX11* texture loading code for a simple light-weight runtime DDS loader. There are versions for Direct3D 9, Direct3D 11, and Direct3D 12. This performs no runtime pixel data conversions. This is ideal for runtime usage, and supports the full complement of Direct3D texture resources (1D, 2D, volume maps, cubemaps, mipmap levels, texture arrays, BC formats, etc.). - -* ``ScreenGrab\`` - - + This contains texture writing modules for Direct3D 9, Direct3D 11, and Direct3D 12 primarily intended for creating screenshots. The images are written as a DDS or as an image file format using WIC. - -* ``WICTextureLoader\`` - - + This contains a Direct3D 9, Direct3D 11 and Direct3D 12 2D texture loader that uses WIC to load a bitmap (BMP, JPEG, PNG, HD Photo, or other WIC supported file container), resize if needed based on the current feature level (or by explicit parameter), format convert to a DXGI_FORMAT if required, and then create a 2D texture. Note this does not support 1D textures, volume textures, cubemaps, or texture arrays. DDSTextureLoader is recommended for fully "precooked" textures for maximum performance and image quality, but this loader can be useful for creating simple 2D texture from standard image files at runtime. - -> DDSTextureLoader11, ScreenGrab11, and WICTextureLoader11 are 'stand-alone' versions of the same modules provided in the [DirectX Tool Kit for DX11](https://github.com/Microsoft/DirectXTK) - -> DDSTextureLoader12, ScreenGrab12, and WICTextureLoader12 are 'stand-alone' versions of the same modules provided in the [DirectX Tool Kit for DX12](https://github.com/Microsoft/DirectXTK12). - -# Documentation - -Documentation is available on the [GitHub wiki](https://github.com/Microsoft/DirectXTex/wiki). - -## Notices - -All content and source code for this package are subject to the terms of the [MIT License](https://github.com/microsoft/DirectXTex/blob/main/LICENSE). - -For the latest version of DirectXTex, bug reports, etc. please visit the project site on [GitHub](https://github.com/microsoft/DirectXTex). - -## Release Notes - -* Starting with the June 2020 release, this library makes use of typed enum bitmask flags per the recommendation of the _C++ Standard_ section *17.5.2.1.3 Bitmask types*. This is consistent with Direct3D 12's use of the ``DEFINE_ENUM_FLAG_OPERATORS`` macro. This may have *breaking change* impacts to client code: - - * You cannot pass the ``0`` literal as your flags value. Instead you must make use of the appropriate default enum value: ``CP_FLAGS_NONE``, ``DDS_FLAGS_NONE``, ``WIC_FLAGS_NONE``, ``TEX_FR_ROTATE0``, ``TEX_FILTER_DEFAULT``, ``TEX_FILTER_DEFAULT``, ``TEX_FILTER_DEFAULT``, ``CNMAP_DEFAULT``, or ``CNMAP_DEFAULT``. - - * Use the enum type instead of ``DWORD`` if building up flags values locally with bitmask operations. For example, ```DDS_FLAGS flags = DDS_FLAGS_NONE; if (...) flags |= DDS_FLAGS_EXPAND_LUMINANCE;``` - - * In cases where some of the flags overlap, you can use the ``|`` to combine the relevant types: ``TEX_FILTER_FLAGS`` filter modes combine with ``WIC_FLAGS``, ``TEX_FILTER_FLAGS`` sRGB flags combine with ``TEX_PMALPHA_FLAGS`` or ``TEX_COMPRESS_FLAGS``. No other bitwise operators are defined. For example, ```WIC_FLAGS wicFlags = WIC_FLAGS_NONE | TEX_FILTER_CUBIC;``` - -* Due to the underlying Windows BMP WIC codec, alpha channels are not supported for 16bpp or 32bpp BMP pixel format files. The Windows 8.x and Windows 10 version of the Windows BMP WIC codec does support 32bpp pixel formats with alpha when using the ``BITMAPV5HEADER`` file header. Note the updated WIC is available on Windows 7 SP1 with [KB 2670838](https://walbourn.github.io/directx-11-1-and-windows-7-update/) installed. - -* While DXGI 1.0 and DXGI 1.1 include 5:6:5 (``DXGI_FORMAT_B5G6R5_UNORM``) and 5:5:5:1 (``DXGI_FORMAT_B5G5R5A1_UNORM``) pixel format enumerations, the DirectX 10.x and 11.0 Runtimes do not support these formats for use with Direct3D. The DirectX 11.1 runtime, DXGI 1.2, and the WDDM 1.2 driver model fully support 16bpp formats (5:6:5, 5:5:5:1, and 4:4:4:4). - -* WICTextureLoader cannot load ``.TGA`` or ``.HDR`` files unless the system has a 3rd party WIC codec installed. You must use the DirectXTex library for TGA/HDR file format support without relying on an add-on WIC codec. - -* Loading of 96bpp floating-point TIFF files results in a corrupted image prior to Windows 8. This fix is available on Windows 7 SP1 with KB 2670838 installed. - -* The UWP projects and the Win10 classic desktop project include configurations for the ARM64 platform. Building these requires installing the ARM64 toolset. - -* When using clang/LLVM for the ARM64 platform, the Windows 11 SDK ([22000](https://walbourn.github.io/windows-sdk-for-windows-11/)) is required. - -* The ``CompileShaders.cmd`` script must have Windows-style (CRLF) line-endings. If it is changed to Linux-style (LF) line-endings, it can fail to build all the required shaders. - -## Support - -For questions, consider using [Stack Overflow](https://stackoverflow.com/questions/tagged/directxtk) with the *directxtk* tag, or the [DirectX Discord Server](https://discord.gg/directx) in the *dx12-developers* or *dx9-dx11-developers* channel. - -For bug reports and feature requests, please use GitHub [issues](https://github.com/microsoft/DirectXTex/issues) for this project. - -## Contributing - -This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com. - -When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA. - -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. - -## Trademarks - -This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow [Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general). Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies. - -## Credits - -The DirectXTex library is the work of Chuck Walbourn, with contributions from Matt Lee, Xin Huang, Craig Peeper, and the numerous other Microsoft engineers who developed the D3DX utility library over the years. - -Thanks to Paul Penson for his help with the implementation of ``MemoryStreamOnBlob``. diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/SECURITY.md b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/SECURITY.md deleted file mode 100644 index f7b8998..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/SECURITY.md +++ /dev/null @@ -1,41 +0,0 @@ - - -## Security - -Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). - -If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)), please report it to us as described below. - -## Reporting Security Issues - -**Please do not report security vulnerabilities through public GitHub issues.** - -Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report). - -If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc). - -You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc). - -Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: - - * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) - * Full paths of source file(s) related to the manifestation of the issue - * The location of the affected source code (tag/branch/commit or direct URL) - * Any special configuration required to reproduce the issue - * Step-by-step instructions to reproduce the issue - * Proof-of-concept or exploit code (if possible) - * Impact of the issue, including how an attacker might exploit the issue - -This information will help us triage your report more quickly. - -If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs. - -## Preferred Languages - -We prefer all communications to be in English. - -## Policy - -Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd). - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/ScreenGrab/ScreenGrab11.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/ScreenGrab/ScreenGrab11.cpp deleted file mode 100644 index 75645a3..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/ScreenGrab/ScreenGrab11.cpp +++ /dev/null @@ -1,1261 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: ScreenGrab11.cpp -// -// Function for capturing a 2D texture and saving it to a file (aka a 'screenshot' -// when used on a Direct3D Render Target). -// -// Note these functions are useful as a light-weight runtime screen grabber. For -// full-featured texture capture, DDS writer, and texture processing pipeline, -// see the 'Texconv' sample and the 'DirectXTex' library. -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -// http://go.microsoft.com/fwlink/?LinkId=248929 -//-------------------------------------------------------------------------------------- - -// Does not capture 1D textures or 3D textures (volume maps) - -// Does not capture mipmap chains, only the top-most texture level is saved - -// For 2D array textures and cubemaps, it captures only the first image in the array - -#include "ScreenGrab11.h" - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#ifdef _MSC_VER -// Off by default warnings -#pragma warning(disable : 4619 4616 4061 4062 4623 4626 5027) -// C4619/4616 #pragma warning warnings -// C4061 enumerator 'x' in switch of enum 'y' is not explicitly handled by a case label -// C4062 enumerator 'x' in switch of enum 'y' is not handled -// C4623 default constructor was implicitly defined as deleted -// C4626 assignment operator was implicitly defined as deleted -// C5027 move assignment operator was implicitly defined as deleted -#endif - -#ifdef __clang__ -#pragma clang diagnostic ignored "-Wcovered-switch-default" -#pragma clang diagnostic ignored "-Wswitch-enum" -#endif - -using Microsoft::WRL::ComPtr; - -//-------------------------------------------------------------------------------------- -// Macros -//-------------------------------------------------------------------------------------- -#ifndef MAKEFOURCC -#define MAKEFOURCC(ch0, ch1, ch2, ch3) \ - ((uint32_t)(uint8_t)(ch0) | ((uint32_t)(uint8_t)(ch1) << 8) | \ - ((uint32_t)(uint8_t)(ch2) << 16) | ((uint32_t)(uint8_t)(ch3) << 24 )) -#endif /* defined(MAKEFOURCC) */ - -//-------------------------------------------------------------------------------------- -// DDS file structure definitions -// -// See DDS.h in the 'Texconv' sample and the 'DirectXTex' library -//-------------------------------------------------------------------------------------- -namespace -{ -#pragma pack(push,1) - -#define DDS_MAGIC 0x20534444 // "DDS " - - struct DDS_PIXELFORMAT - { - uint32_t size; - uint32_t flags; - uint32_t fourCC; - uint32_t RGBBitCount; - uint32_t RBitMask; - uint32_t GBitMask; - uint32_t BBitMask; - uint32_t ABitMask; - }; - -#define DDS_FOURCC 0x00000004 // DDPF_FOURCC -#define DDS_RGB 0x00000040 // DDPF_RGB -#define DDS_RGBA 0x00000041 // DDPF_RGB | DDPF_ALPHAPIXELS -#define DDS_LUMINANCE 0x00020000 // DDPF_LUMINANCE -#define DDS_LUMINANCEA 0x00020001 // DDPF_LUMINANCE | DDPF_ALPHAPIXELS -#define DDS_ALPHA 0x00000002 // DDPF_ALPHA -#define DDS_BUMPDUDV 0x00080000 // DDPF_BUMPDUDV - -#define DDS_HEADER_FLAGS_TEXTURE 0x00001007 // DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT -#define DDS_HEADER_FLAGS_MIPMAP 0x00020000 // DDSD_MIPMAPCOUNT -#define DDS_HEADER_FLAGS_PITCH 0x00000008 // DDSD_PITCH -#define DDS_HEADER_FLAGS_LINEARSIZE 0x00080000 // DDSD_LINEARSIZE - -#define DDS_SURFACE_FLAGS_TEXTURE 0x00001000 // DDSCAPS_TEXTURE - - struct DDS_HEADER - { - uint32_t size; - uint32_t flags; - uint32_t height; - uint32_t width; - uint32_t pitchOrLinearSize; - uint32_t depth; // only if DDS_HEADER_FLAGS_VOLUME is set in flags - uint32_t mipMapCount; - uint32_t reserved1[11]; - DDS_PIXELFORMAT ddspf; - uint32_t caps; - uint32_t caps2; - uint32_t caps3; - uint32_t caps4; - uint32_t reserved2; - }; - - struct DDS_HEADER_DXT10 - { - DXGI_FORMAT dxgiFormat; - uint32_t resourceDimension; - uint32_t miscFlag; // see D3D11_RESOURCE_MISC_FLAG - uint32_t arraySize; - uint32_t reserved; - }; - -#pragma pack(pop) - - const DDS_PIXELFORMAT DDSPF_DXT1 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','1'), 0, 0, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_DXT3 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','3'), 0, 0, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_DXT5 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','5'), 0, 0, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_BC4_UNORM = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','4','U'), 0, 0, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_BC4_SNORM = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','4','S'), 0, 0, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_BC5_UNORM = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','5','U'), 0, 0, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_BC5_SNORM = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','5','S'), 0, 0, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_R8G8_B8G8 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('R','G','B','G'), 0, 0, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_G8R8_G8B8 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('G','R','G','B'), 0, 0, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_YUY2 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('Y','U','Y','2'), 0, 0, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_A8R8G8B8 = - { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 }; - - const DDS_PIXELFORMAT DDSPF_X8R8G8B8 = - { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0 }; - - const DDS_PIXELFORMAT DDSPF_A8B8G8R8 = - { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 }; - - const DDS_PIXELFORMAT DDSPF_G16R16 = - { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x0000ffff, 0xffff0000, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_R5G6B5 = - { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0xf800, 0x07e0, 0x001f, 0 }; - - const DDS_PIXELFORMAT DDSPF_A1R5G5B5 = - { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x7c00, 0x03e0, 0x001f, 0x8000 }; - - const DDS_PIXELFORMAT DDSPF_A4R4G4B4 = - { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x0f00, 0x00f0, 0x000f, 0xf000 }; - - const DDS_PIXELFORMAT DDSPF_L8 = - { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCE, 0, 8, 0xff, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_L16 = - { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCE, 0, 16, 0xffff, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_A8L8 = - { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCEA, 0, 16, 0x00ff, 0, 0, 0xff00 }; - - const DDS_PIXELFORMAT DDSPF_A8 = - { sizeof(DDS_PIXELFORMAT), DDS_ALPHA, 0, 8, 0, 0, 0, 0xff }; - - const DDS_PIXELFORMAT DDSPF_V8U8 = - { sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 16, 0x00ff, 0xff00, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_Q8W8V8U8 = - { sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 }; - - const DDS_PIXELFORMAT DDSPF_V16U16 = - { sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 32, 0x0000ffff, 0xffff0000, 0, 0 }; - - // DXGI_FORMAT_R10G10B10A2_UNORM should be written using DX10 extension to avoid D3DX 10:10:10:2 reversal issue - - // This indicates the DDS_HEADER_DXT10 extension is present (the format is in dxgiFormat) - const DDS_PIXELFORMAT DDSPF_DX10 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','1','0'), 0, 0, 0, 0, 0 }; - - //----------------------------------------------------------------------------- - struct handle_closer { void operator()(HANDLE h) noexcept { if (h) CloseHandle(h); } }; - - using ScopedHandle = std::unique_ptr; - - inline HANDLE safe_handle(HANDLE h) noexcept { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; } - - class auto_delete_file - { - public: - auto_delete_file(HANDLE hFile) noexcept : m_handle(hFile) {} - ~auto_delete_file() - { - if (m_handle) - { - FILE_DISPOSITION_INFO info = {}; - info.DeleteFile = TRUE; - std::ignore = SetFileInformationByHandle(m_handle, FileDispositionInfo, &info, sizeof(info)); - } - } - - auto_delete_file(const auto_delete_file&) = delete; - auto_delete_file& operator=(const auto_delete_file&) = delete; - - auto_delete_file(const auto_delete_file&&) = delete; - auto_delete_file& operator=(const auto_delete_file&&) = delete; - - void clear() noexcept { m_handle = nullptr; } - - private: - HANDLE m_handle; - }; - - class auto_delete_file_wic - { - public: - auto_delete_file_wic(ComPtr& hFile, const wchar_t* szFile) noexcept : m_filename(szFile), m_handle(hFile) {} - ~auto_delete_file_wic() - { - if (m_filename) - { - m_handle.Reset(); - DeleteFileW(m_filename); - } - } - - auto_delete_file_wic(const auto_delete_file_wic&) = delete; - auto_delete_file_wic& operator=(const auto_delete_file_wic&) = delete; - - auto_delete_file_wic(const auto_delete_file_wic&&) = delete; - auto_delete_file_wic& operator=(const auto_delete_file_wic&&) = delete; - - void clear() noexcept { m_filename = nullptr; } - - private: - const wchar_t* m_filename; - ComPtr& m_handle; - }; - - //-------------------------------------------------------------------------------------- - // Return the BPP for a particular format - //-------------------------------------------------------------------------------------- - size_t BitsPerPixel(_In_ DXGI_FORMAT fmt) noexcept - { - switch (fmt) - { - case DXGI_FORMAT_R32G32B32A32_TYPELESS: - case DXGI_FORMAT_R32G32B32A32_FLOAT: - case DXGI_FORMAT_R32G32B32A32_UINT: - case DXGI_FORMAT_R32G32B32A32_SINT: - return 128; - - case DXGI_FORMAT_R32G32B32_TYPELESS: - case DXGI_FORMAT_R32G32B32_FLOAT: - case DXGI_FORMAT_R32G32B32_UINT: - case DXGI_FORMAT_R32G32B32_SINT: - return 96; - - case DXGI_FORMAT_R16G16B16A16_TYPELESS: - case DXGI_FORMAT_R16G16B16A16_FLOAT: - case DXGI_FORMAT_R16G16B16A16_UNORM: - case DXGI_FORMAT_R16G16B16A16_UINT: - case DXGI_FORMAT_R16G16B16A16_SNORM: - case DXGI_FORMAT_R16G16B16A16_SINT: - case DXGI_FORMAT_R32G32_TYPELESS: - case DXGI_FORMAT_R32G32_FLOAT: - case DXGI_FORMAT_R32G32_UINT: - case DXGI_FORMAT_R32G32_SINT: - case DXGI_FORMAT_R32G8X24_TYPELESS: - case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: - case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: - case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: - case DXGI_FORMAT_Y416: - case DXGI_FORMAT_Y210: - case DXGI_FORMAT_Y216: - return 64; - - case DXGI_FORMAT_R10G10B10A2_TYPELESS: - case DXGI_FORMAT_R10G10B10A2_UNORM: - case DXGI_FORMAT_R10G10B10A2_UINT: - case DXGI_FORMAT_R11G11B10_FLOAT: - case DXGI_FORMAT_R8G8B8A8_TYPELESS: - case DXGI_FORMAT_R8G8B8A8_UNORM: - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - case DXGI_FORMAT_R8G8B8A8_UINT: - case DXGI_FORMAT_R8G8B8A8_SNORM: - case DXGI_FORMAT_R8G8B8A8_SINT: - case DXGI_FORMAT_R16G16_TYPELESS: - case DXGI_FORMAT_R16G16_FLOAT: - case DXGI_FORMAT_R16G16_UNORM: - case DXGI_FORMAT_R16G16_UINT: - case DXGI_FORMAT_R16G16_SNORM: - case DXGI_FORMAT_R16G16_SINT: - case DXGI_FORMAT_R32_TYPELESS: - case DXGI_FORMAT_D32_FLOAT: - case DXGI_FORMAT_R32_FLOAT: - case DXGI_FORMAT_R32_UINT: - case DXGI_FORMAT_R32_SINT: - case DXGI_FORMAT_R24G8_TYPELESS: - case DXGI_FORMAT_D24_UNORM_S8_UINT: - case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: - case DXGI_FORMAT_X24_TYPELESS_G8_UINT: - case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: - case DXGI_FORMAT_R8G8_B8G8_UNORM: - case DXGI_FORMAT_G8R8_G8B8_UNORM: - case DXGI_FORMAT_B8G8R8A8_UNORM: - case DXGI_FORMAT_B8G8R8X8_UNORM: - case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: - case DXGI_FORMAT_B8G8R8A8_TYPELESS: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8X8_TYPELESS: - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - case DXGI_FORMAT_AYUV: - case DXGI_FORMAT_Y410: - case DXGI_FORMAT_YUY2: - return 32; - - case DXGI_FORMAT_P010: - case DXGI_FORMAT_P016: - return 24; - - case DXGI_FORMAT_R8G8_TYPELESS: - case DXGI_FORMAT_R8G8_UNORM: - case DXGI_FORMAT_R8G8_UINT: - case DXGI_FORMAT_R8G8_SNORM: - case DXGI_FORMAT_R8G8_SINT: - case DXGI_FORMAT_R16_TYPELESS: - case DXGI_FORMAT_R16_FLOAT: - case DXGI_FORMAT_D16_UNORM: - case DXGI_FORMAT_R16_UNORM: - case DXGI_FORMAT_R16_UINT: - case DXGI_FORMAT_R16_SNORM: - case DXGI_FORMAT_R16_SINT: - case DXGI_FORMAT_B5G6R5_UNORM: - case DXGI_FORMAT_B5G5R5A1_UNORM: - case DXGI_FORMAT_A8P8: - case DXGI_FORMAT_B4G4R4A4_UNORM: - return 16; - - case DXGI_FORMAT_NV12: - case DXGI_FORMAT_420_OPAQUE: - case DXGI_FORMAT_NV11: - return 12; - - case DXGI_FORMAT_R8_TYPELESS: - case DXGI_FORMAT_R8_UNORM: - case DXGI_FORMAT_R8_UINT: - case DXGI_FORMAT_R8_SNORM: - case DXGI_FORMAT_R8_SINT: - case DXGI_FORMAT_A8_UNORM: - case DXGI_FORMAT_BC2_TYPELESS: - case DXGI_FORMAT_BC2_UNORM: - case DXGI_FORMAT_BC2_UNORM_SRGB: - case DXGI_FORMAT_BC3_TYPELESS: - case DXGI_FORMAT_BC3_UNORM: - case DXGI_FORMAT_BC3_UNORM_SRGB: - case DXGI_FORMAT_BC5_TYPELESS: - case DXGI_FORMAT_BC5_UNORM: - case DXGI_FORMAT_BC5_SNORM: - case DXGI_FORMAT_BC6H_TYPELESS: - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - case DXGI_FORMAT_BC7_TYPELESS: - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: - case DXGI_FORMAT_AI44: - case DXGI_FORMAT_IA44: - case DXGI_FORMAT_P8: - return 8; - - case DXGI_FORMAT_R1_UNORM: - return 1; - - case DXGI_FORMAT_BC1_TYPELESS: - case DXGI_FORMAT_BC1_UNORM: - case DXGI_FORMAT_BC1_UNORM_SRGB: - case DXGI_FORMAT_BC4_TYPELESS: - case DXGI_FORMAT_BC4_UNORM: - case DXGI_FORMAT_BC4_SNORM: - return 4; - - default: - return 0; - } - } - - - //-------------------------------------------------------------------------------------- - // Determines if the format is block compressed - //-------------------------------------------------------------------------------------- - bool IsCompressed(_In_ DXGI_FORMAT fmt) noexcept - { - switch (fmt) - { - case DXGI_FORMAT_BC1_TYPELESS: - case DXGI_FORMAT_BC1_UNORM: - case DXGI_FORMAT_BC1_UNORM_SRGB: - case DXGI_FORMAT_BC2_TYPELESS: - case DXGI_FORMAT_BC2_UNORM: - case DXGI_FORMAT_BC2_UNORM_SRGB: - case DXGI_FORMAT_BC3_TYPELESS: - case DXGI_FORMAT_BC3_UNORM: - case DXGI_FORMAT_BC3_UNORM_SRGB: - case DXGI_FORMAT_BC4_TYPELESS: - case DXGI_FORMAT_BC4_UNORM: - case DXGI_FORMAT_BC4_SNORM: - case DXGI_FORMAT_BC5_TYPELESS: - case DXGI_FORMAT_BC5_UNORM: - case DXGI_FORMAT_BC5_SNORM: - case DXGI_FORMAT_BC6H_TYPELESS: - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - case DXGI_FORMAT_BC7_TYPELESS: - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: - return true; - - default: - return false; - } - } - - - //-------------------------------------------------------------------------------------- - // Get surface information for a particular format - //-------------------------------------------------------------------------------------- - HRESULT GetSurfaceInfo( - _In_ size_t width, - _In_ size_t height, - _In_ DXGI_FORMAT fmt, - _Out_opt_ size_t* outNumBytes, - _Out_opt_ size_t* outRowBytes, - _Out_opt_ size_t* outNumRows) noexcept - { - uint64_t numBytes = 0; - uint64_t rowBytes = 0; - uint64_t numRows = 0; - - bool bc = false; - bool packed = false; - bool planar = false; - size_t bpe = 0; - switch (fmt) - { - case DXGI_FORMAT_BC1_TYPELESS: - case DXGI_FORMAT_BC1_UNORM: - case DXGI_FORMAT_BC1_UNORM_SRGB: - case DXGI_FORMAT_BC4_TYPELESS: - case DXGI_FORMAT_BC4_UNORM: - case DXGI_FORMAT_BC4_SNORM: - bc = true; - bpe = 8; - break; - - case DXGI_FORMAT_BC2_TYPELESS: - case DXGI_FORMAT_BC2_UNORM: - case DXGI_FORMAT_BC2_UNORM_SRGB: - case DXGI_FORMAT_BC3_TYPELESS: - case DXGI_FORMAT_BC3_UNORM: - case DXGI_FORMAT_BC3_UNORM_SRGB: - case DXGI_FORMAT_BC5_TYPELESS: - case DXGI_FORMAT_BC5_UNORM: - case DXGI_FORMAT_BC5_SNORM: - case DXGI_FORMAT_BC6H_TYPELESS: - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - case DXGI_FORMAT_BC7_TYPELESS: - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: - bc = true; - bpe = 16; - break; - - case DXGI_FORMAT_R8G8_B8G8_UNORM: - case DXGI_FORMAT_G8R8_G8B8_UNORM: - case DXGI_FORMAT_YUY2: - packed = true; - bpe = 4; - break; - - case DXGI_FORMAT_Y210: - case DXGI_FORMAT_Y216: - packed = true; - bpe = 8; - break; - - case DXGI_FORMAT_NV12: - case DXGI_FORMAT_420_OPAQUE: - planar = true; - bpe = 2; - break; - - case DXGI_FORMAT_P010: - case DXGI_FORMAT_P016: - planar = true; - bpe = 4; - break; - - default: - break; - } - - if (bc) - { - uint64_t numBlocksWide = 0; - if (width > 0) - { - numBlocksWide = std::max(1u, (uint64_t(width) + 3u) / 4u); - } - uint64_t numBlocksHigh = 0; - if (height > 0) - { - numBlocksHigh = std::max(1u, (uint64_t(height) + 3u) / 4u); - } - rowBytes = numBlocksWide * bpe; - numRows = numBlocksHigh; - numBytes = rowBytes * numBlocksHigh; - } - else if (packed) - { - rowBytes = ((uint64_t(width) + 1u) >> 1) * bpe; - numRows = uint64_t(height); - numBytes = rowBytes * height; - } - else if (fmt == DXGI_FORMAT_NV11) - { - rowBytes = ((uint64_t(width) + 3u) >> 2) * 4u; - numRows = uint64_t(height) * 2u; // Direct3D makes this simplifying assumption, although it is larger than the 4:1:1 data - numBytes = rowBytes * numRows; - } - else if (planar) - { - rowBytes = ((uint64_t(width) + 1u) >> 1) * bpe; - numBytes = (rowBytes * uint64_t(height)) + ((rowBytes * uint64_t(height) + 1u) >> 1); - numRows = height + ((uint64_t(height) + 1u) >> 1); - } - else - { - const size_t bpp = BitsPerPixel(fmt); - if (!bpp) - return E_INVALIDARG; - - rowBytes = (uint64_t(width) * bpp + 7u) / 8u; // round up to nearest byte - numRows = uint64_t(height); - numBytes = rowBytes * height; - } - - #if defined(_M_IX86) || defined(_M_ARM) || defined(_M_HYBRID_X86_ARM64) - static_assert(sizeof(size_t) == 4, "Not a 32-bit platform!"); - if (numBytes > UINT32_MAX || rowBytes > UINT32_MAX || numRows > UINT32_MAX) - return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); - #else - static_assert(sizeof(size_t) == 8, "Not a 64-bit platform!"); - #endif - - if (outNumBytes) - { - *outNumBytes = static_cast(numBytes); - } - if (outRowBytes) - { - *outRowBytes = static_cast(rowBytes); - } - if (outNumRows) - { - *outNumRows = static_cast(numRows); - } - - return S_OK; - } - - - //-------------------------------------------------------------------------------------- - DXGI_FORMAT EnsureNotTypeless(DXGI_FORMAT fmt) noexcept - { - // Assumes UNORM or FLOAT; doesn't use UINT or SINT - switch (fmt) - { - case DXGI_FORMAT_R32G32B32A32_TYPELESS: return DXGI_FORMAT_R32G32B32A32_FLOAT; - case DXGI_FORMAT_R32G32B32_TYPELESS: return DXGI_FORMAT_R32G32B32_FLOAT; - case DXGI_FORMAT_R16G16B16A16_TYPELESS: return DXGI_FORMAT_R16G16B16A16_UNORM; - case DXGI_FORMAT_R32G32_TYPELESS: return DXGI_FORMAT_R32G32_FLOAT; - case DXGI_FORMAT_R10G10B10A2_TYPELESS: return DXGI_FORMAT_R10G10B10A2_UNORM; - case DXGI_FORMAT_R8G8B8A8_TYPELESS: return DXGI_FORMAT_R8G8B8A8_UNORM; - case DXGI_FORMAT_R16G16_TYPELESS: return DXGI_FORMAT_R16G16_UNORM; - case DXGI_FORMAT_R32_TYPELESS: return DXGI_FORMAT_R32_FLOAT; - case DXGI_FORMAT_R8G8_TYPELESS: return DXGI_FORMAT_R8G8_UNORM; - case DXGI_FORMAT_R16_TYPELESS: return DXGI_FORMAT_R16_UNORM; - case DXGI_FORMAT_R8_TYPELESS: return DXGI_FORMAT_R8_UNORM; - case DXGI_FORMAT_BC1_TYPELESS: return DXGI_FORMAT_BC1_UNORM; - case DXGI_FORMAT_BC2_TYPELESS: return DXGI_FORMAT_BC2_UNORM; - case DXGI_FORMAT_BC3_TYPELESS: return DXGI_FORMAT_BC3_UNORM; - case DXGI_FORMAT_BC4_TYPELESS: return DXGI_FORMAT_BC4_UNORM; - case DXGI_FORMAT_BC5_TYPELESS: return DXGI_FORMAT_BC5_UNORM; - case DXGI_FORMAT_B8G8R8A8_TYPELESS: return DXGI_FORMAT_B8G8R8A8_UNORM; - case DXGI_FORMAT_B8G8R8X8_TYPELESS: return DXGI_FORMAT_B8G8R8X8_UNORM; - case DXGI_FORMAT_BC7_TYPELESS: return DXGI_FORMAT_BC7_UNORM; - default: return fmt; - } - } - - - //-------------------------------------------------------------------------------------- - HRESULT CaptureTexture( - _In_ ID3D11DeviceContext* pContext, - _In_ ID3D11Resource* pSource, - D3D11_TEXTURE2D_DESC& desc, - ComPtr& pStaging) noexcept - { - if (!pContext || !pSource) - return E_INVALIDARG; - - D3D11_RESOURCE_DIMENSION resType = D3D11_RESOURCE_DIMENSION_UNKNOWN; - pSource->GetType(&resType); - - if (resType != D3D11_RESOURCE_DIMENSION_TEXTURE2D) - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - - ComPtr pTexture; - HRESULT hr = pSource->QueryInterface(IID_ID3D11Texture2D, reinterpret_cast(pTexture.GetAddressOf())); - if (FAILED(hr)) - return hr; - - assert(pTexture); - - pTexture->GetDesc(&desc); - - ComPtr d3dDevice; - pContext->GetDevice(d3dDevice.GetAddressOf()); - - if (desc.SampleDesc.Count > 1) - { - // MSAA content must be resolved before being copied to a staging texture - desc.SampleDesc.Count = 1; - desc.SampleDesc.Quality = 0; - - ComPtr pTemp; - hr = d3dDevice->CreateTexture2D(&desc, nullptr, pTemp.GetAddressOf()); - if (FAILED(hr)) - return hr; - - assert(pTemp); - - const DXGI_FORMAT fmt = EnsureNotTypeless(desc.Format); - - UINT support = 0; - hr = d3dDevice->CheckFormatSupport(fmt, &support); - if (FAILED(hr)) - return hr; - - if (!(support & D3D11_FORMAT_SUPPORT_MULTISAMPLE_RESOLVE)) - return E_FAIL; - - for (UINT item = 0; item < desc.ArraySize; ++item) - { - for (UINT level = 0; level < desc.MipLevels; ++level) - { - const UINT index = D3D11CalcSubresource(level, item, desc.MipLevels); - pContext->ResolveSubresource(pTemp.Get(), index, pSource, index, fmt); - } - } - - desc.BindFlags = 0; - desc.MiscFlags &= D3D11_RESOURCE_MISC_TEXTURECUBE; - desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; - desc.Usage = D3D11_USAGE_STAGING; - - hr = d3dDevice->CreateTexture2D(&desc, nullptr, pStaging.ReleaseAndGetAddressOf()); - if (FAILED(hr)) - return hr; - - assert(pStaging); - - pContext->CopyResource(pStaging.Get(), pTemp.Get()); - } - else if ((desc.Usage == D3D11_USAGE_STAGING) && (desc.CPUAccessFlags & D3D11_CPU_ACCESS_READ)) - { - // Handle case where the source is already a staging texture we can use directly - pStaging = pTexture; - } - else - { - // Otherwise, create a staging texture from the non-MSAA source - desc.BindFlags = 0; - desc.MiscFlags &= D3D11_RESOURCE_MISC_TEXTURECUBE; - desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; - desc.Usage = D3D11_USAGE_STAGING; - - hr = d3dDevice->CreateTexture2D(&desc, nullptr, pStaging.ReleaseAndGetAddressOf()); - if (FAILED(hr)) - return hr; - - assert(pStaging); - - pContext->CopyResource(pStaging.Get(), pSource); - } - - return S_OK; - } - - //-------------------------------------------------------------------------------------- - bool g_WIC2 = false; - - BOOL WINAPI InitializeWICFactory(PINIT_ONCE, PVOID, PVOID* ifactory) noexcept - { - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE) - HRESULT hr = CoCreateInstance( - CLSID_WICImagingFactory2, - nullptr, - CLSCTX_INPROC_SERVER, - __uuidof(IWICImagingFactory2), - ifactory - ); - - if (SUCCEEDED(hr)) - { - // WIC2 is available on Windows 10, Windows 8.x, and Windows 7 SP1 with KB 2670838 installed - g_WIC2 = true; - return TRUE; - } - else - { - hr = CoCreateInstance( - CLSID_WICImagingFactory1, - nullptr, - CLSCTX_INPROC_SERVER, - __uuidof(IWICImagingFactory), - ifactory - ); - return SUCCEEDED(hr) ? TRUE : FALSE; - } - #else - return SUCCEEDED(CoCreateInstance( - CLSID_WICImagingFactory, - nullptr, - CLSCTX_INPROC_SERVER, - __uuidof(IWICImagingFactory), - ifactory)) ? TRUE : FALSE; - #endif - } - - IWICImagingFactory* GetWIC() noexcept - { - static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT; - - IWICImagingFactory* factory = nullptr; - if (!InitOnceExecuteOnce(&s_initOnce, - InitializeWICFactory, - nullptr, - reinterpret_cast(&factory))) - { - return nullptr; - } - - return factory; - } -} // anonymous namespace - - -//-------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::SaveDDSTextureToFile( - ID3D11DeviceContext* pContext, - ID3D11Resource* pSource, - const wchar_t* fileName) noexcept -{ - if (!fileName) - return E_INVALIDARG; - - D3D11_TEXTURE2D_DESC desc = {}; - ComPtr pStaging; - HRESULT hr = CaptureTexture(pContext, pSource, desc, pStaging); - if (FAILED(hr)) - return hr; - - // Create file -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(fileName, - GENERIC_WRITE | DELETE, 0, CREATE_ALWAYS, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(fileName, - GENERIC_WRITE | DELETE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr))); -#endif - if (!hFile) - return HRESULT_FROM_WIN32(GetLastError()); - - auto_delete_file delonfail(hFile.get()); - - // Setup header - constexpr size_t MAX_HEADER_SIZE = sizeof(uint32_t) + sizeof(DDS_HEADER) + sizeof(DDS_HEADER_DXT10); - uint8_t fileHeader[MAX_HEADER_SIZE] = {}; - - *reinterpret_cast(&fileHeader[0]) = DDS_MAGIC; - - auto header = reinterpret_cast(&fileHeader[0] + sizeof(uint32_t)); - size_t headerSize = sizeof(uint32_t) + sizeof(DDS_HEADER); - header->size = sizeof(DDS_HEADER); - header->flags = DDS_HEADER_FLAGS_TEXTURE | DDS_HEADER_FLAGS_MIPMAP; - header->height = desc.Height; - header->width = desc.Width; - header->mipMapCount = 1; - header->caps = DDS_SURFACE_FLAGS_TEXTURE; - - // Try to use a legacy .DDS pixel format for better tools support, otherwise fallback to 'DX10' header extension - DDS_HEADER_DXT10* extHeader = nullptr; - switch (desc.Format) - { - case DXGI_FORMAT_R8G8B8A8_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_A8B8G8R8, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_R16G16_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_G16R16, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_R8G8_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_A8L8, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_R16_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_L16, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_R8_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_L8, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_A8_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_A8, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_R8G8_B8G8_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_R8G8_B8G8, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_G8R8_G8B8_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_G8R8_G8B8, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_BC1_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_DXT1, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_BC2_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_DXT3, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_BC3_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_DXT5, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_BC4_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_BC4_UNORM, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_BC4_SNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_BC4_SNORM, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_BC5_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_BC5_UNORM, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_BC5_SNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_BC5_SNORM, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_B5G6R5_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_R5G6B5, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_B5G5R5A1_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_A1R5G5B5, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_R8G8_SNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_V8U8, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_R8G8B8A8_SNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_Q8W8V8U8, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_R16G16_SNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_V16U16, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_B8G8R8A8_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_A8R8G8B8, sizeof(DDS_PIXELFORMAT)); break; // DXGI 1.1 - case DXGI_FORMAT_B8G8R8X8_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_X8R8G8B8, sizeof(DDS_PIXELFORMAT)); break; // DXGI 1.1 - case DXGI_FORMAT_YUY2: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_YUY2, sizeof(DDS_PIXELFORMAT)); break; // DXGI 1.2 - case DXGI_FORMAT_B4G4R4A4_UNORM: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_A4R4G4B4, sizeof(DDS_PIXELFORMAT)); break; // DXGI 1.2 - - // Legacy D3DX formats using D3DFMT enum value as FourCC - case DXGI_FORMAT_R32G32B32A32_FLOAT: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 116; break; // D3DFMT_A32B32G32R32F - case DXGI_FORMAT_R16G16B16A16_FLOAT: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 113; break; // D3DFMT_A16B16G16R16F - case DXGI_FORMAT_R16G16B16A16_UNORM: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 36; break; // D3DFMT_A16B16G16R16 - case DXGI_FORMAT_R16G16B16A16_SNORM: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 110; break; // D3DFMT_Q16W16V16U16 - case DXGI_FORMAT_R32G32_FLOAT: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 115; break; // D3DFMT_G32R32F - case DXGI_FORMAT_R16G16_FLOAT: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 112; break; // D3DFMT_G16R16F - case DXGI_FORMAT_R32_FLOAT: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 114; break; // D3DFMT_R32F - case DXGI_FORMAT_R16_FLOAT: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 111; break; // D3DFMT_R16F - - case DXGI_FORMAT_AI44: - case DXGI_FORMAT_IA44: - case DXGI_FORMAT_P8: - case DXGI_FORMAT_A8P8: - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - - default: - memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_DX10, sizeof(DDS_PIXELFORMAT)); - - headerSize += sizeof(DDS_HEADER_DXT10); - extHeader = reinterpret_cast(fileHeader + sizeof(uint32_t) + sizeof(DDS_HEADER)); - extHeader->dxgiFormat = desc.Format; - extHeader->resourceDimension = D3D11_RESOURCE_DIMENSION_TEXTURE2D; - extHeader->arraySize = 1; - break; - } - - size_t rowPitch, slicePitch, rowCount; - hr = GetSurfaceInfo(desc.Width, desc.Height, desc.Format, &slicePitch, &rowPitch, &rowCount); - if (FAILED(hr)) - return hr; - - if (rowPitch > UINT32_MAX || slicePitch > UINT32_MAX) - return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); - - if (IsCompressed(desc.Format)) - { - header->flags |= DDS_HEADER_FLAGS_LINEARSIZE; - header->pitchOrLinearSize = static_cast(slicePitch); - } - else - { - header->flags |= DDS_HEADER_FLAGS_PITCH; - header->pitchOrLinearSize = static_cast(rowPitch); - } - - // Setup pixels - std::unique_ptr pixels(new (std::nothrow) uint8_t[slicePitch]); - if (!pixels) - return E_OUTOFMEMORY; - - D3D11_MAPPED_SUBRESOURCE mapped; - hr = pContext->Map(pStaging.Get(), 0, D3D11_MAP_READ, 0, &mapped); - if (FAILED(hr)) - return hr; - - auto sptr = static_cast(mapped.pData); - if (!sptr) - { - pContext->Unmap(pStaging.Get(), 0); - return E_POINTER; - } - - uint8_t* dptr = pixels.get(); - - const size_t msize = std::min(rowPitch, mapped.RowPitch); - for (size_t h = 0; h < rowCount; ++h) - { - memcpy_s(dptr, rowPitch, sptr, msize); - sptr += mapped.RowPitch; - dptr += rowPitch; - } - - pContext->Unmap(pStaging.Get(), 0); - - // Write header & pixels - DWORD bytesWritten; - if (!WriteFile(hFile.get(), fileHeader, static_cast(headerSize), &bytesWritten, nullptr)) - return HRESULT_FROM_WIN32(GetLastError()); - - if (bytesWritten != headerSize) - return E_FAIL; - - if (!WriteFile(hFile.get(), pixels.get(), static_cast(slicePitch), &bytesWritten, nullptr)) - return HRESULT_FROM_WIN32(GetLastError()); - - if (bytesWritten != slicePitch) - return E_FAIL; - - delonfail.clear(); - - return S_OK; -} - -//-------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::SaveWICTextureToFile( - ID3D11DeviceContext* pContext, - ID3D11Resource* pSource, - REFGUID guidContainerFormat, - const wchar_t* fileName, - const GUID* targetFormat, - std::function setCustomProps, - bool forceSRGB) -{ - if (!fileName) - return E_INVALIDARG; - - D3D11_TEXTURE2D_DESC desc = {}; - ComPtr pStaging; - HRESULT hr = CaptureTexture(pContext, pSource, desc, pStaging); - if (FAILED(hr)) - return hr; - - // Determine source format's WIC equivalent - WICPixelFormatGUID pfGuid = {}; - bool sRGB = forceSRGB; - switch (desc.Format) - { - case DXGI_FORMAT_R32G32B32A32_FLOAT: pfGuid = GUID_WICPixelFormat128bppRGBAFloat; break; - case DXGI_FORMAT_R16G16B16A16_FLOAT: pfGuid = GUID_WICPixelFormat64bppRGBAHalf; break; - case DXGI_FORMAT_R16G16B16A16_UNORM: pfGuid = GUID_WICPixelFormat64bppRGBA; break; - case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: pfGuid = GUID_WICPixelFormat32bppRGBA1010102XR; break; // DXGI 1.1 - case DXGI_FORMAT_R10G10B10A2_UNORM: pfGuid = GUID_WICPixelFormat32bppRGBA1010102; break; - case DXGI_FORMAT_B5G5R5A1_UNORM: pfGuid = GUID_WICPixelFormat16bppBGRA5551; break; - case DXGI_FORMAT_B5G6R5_UNORM: pfGuid = GUID_WICPixelFormat16bppBGR565; break; - case DXGI_FORMAT_R32_FLOAT: pfGuid = GUID_WICPixelFormat32bppGrayFloat; break; - case DXGI_FORMAT_R16_FLOAT: pfGuid = GUID_WICPixelFormat16bppGrayHalf; break; - case DXGI_FORMAT_R16_UNORM: pfGuid = GUID_WICPixelFormat16bppGray; break; - case DXGI_FORMAT_R8_UNORM: pfGuid = GUID_WICPixelFormat8bppGray; break; - case DXGI_FORMAT_A8_UNORM: pfGuid = GUID_WICPixelFormat8bppAlpha; break; - - case DXGI_FORMAT_R8G8B8A8_UNORM: - pfGuid = GUID_WICPixelFormat32bppRGBA; - break; - - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - pfGuid = GUID_WICPixelFormat32bppRGBA; - sRGB = true; - break; - - case DXGI_FORMAT_B8G8R8A8_UNORM: // DXGI 1.1 - pfGuid = GUID_WICPixelFormat32bppBGRA; - break; - - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: // DXGI 1.1 - pfGuid = GUID_WICPixelFormat32bppBGRA; - sRGB = true; - break; - - case DXGI_FORMAT_B8G8R8X8_UNORM: // DXGI 1.1 - pfGuid = GUID_WICPixelFormat32bppBGR; - break; - - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: // DXGI 1.1 - pfGuid = GUID_WICPixelFormat32bppBGR; - sRGB = true; - break; - - default: - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - - auto pWIC = GetWIC(); - if (!pWIC) - return E_NOINTERFACE; - - ComPtr stream; - hr = pWIC->CreateStream(stream.GetAddressOf()); - if (FAILED(hr)) - return hr; - - hr = stream->InitializeFromFilename(fileName, GENERIC_WRITE); - if (FAILED(hr)) - return hr; - - auto_delete_file_wic delonfail(stream, fileName); - - ComPtr encoder; - hr = pWIC->CreateEncoder(guidContainerFormat, nullptr, encoder.GetAddressOf()); - if (FAILED(hr)) - return hr; - - hr = encoder->Initialize(stream.Get(), WICBitmapEncoderNoCache); - if (FAILED(hr)) - return hr; - - ComPtr frame; - ComPtr props; - hr = encoder->CreateNewFrame(frame.GetAddressOf(), props.GetAddressOf()); - if (FAILED(hr)) - return hr; - - if (targetFormat && memcmp(&guidContainerFormat, &GUID_ContainerFormatBmp, sizeof(WICPixelFormatGUID)) == 0 && g_WIC2) - { - // Opt-in to the WIC2 support for writing 32-bit Windows BMP files with an alpha channel - PROPBAG2 option = {}; - option.pstrName = const_cast(L"EnableV5Header32bppBGRA"); - - VARIANT varValue; - varValue.vt = VT_BOOL; - varValue.boolVal = VARIANT_TRUE; - std::ignore = props->Write(1, &option, &varValue); - } - - if (setCustomProps) - { - setCustomProps(props.Get()); - } - - hr = frame->Initialize(props.Get()); - if (FAILED(hr)) - return hr; - - hr = frame->SetSize(desc.Width, desc.Height); - if (FAILED(hr)) - return hr; - - hr = frame->SetResolution(72, 72); - if (FAILED(hr)) - return hr; - - // Pick a target format - WICPixelFormatGUID targetGuid = {}; - if (targetFormat) - { - targetGuid = *targetFormat; - } - else - { - // Screenshots don't typically include the alpha channel of the render target - switch (desc.Format) - { - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE) - case DXGI_FORMAT_R32G32B32A32_FLOAT: - case DXGI_FORMAT_R16G16B16A16_FLOAT: - if (g_WIC2) - { - targetGuid = GUID_WICPixelFormat96bppRGBFloat; - } - else - { - targetGuid = GUID_WICPixelFormat24bppBGR; - } - break; - #endif - - case DXGI_FORMAT_R16G16B16A16_UNORM: targetGuid = GUID_WICPixelFormat48bppBGR; break; - case DXGI_FORMAT_B5G5R5A1_UNORM: targetGuid = GUID_WICPixelFormat16bppBGR555; break; - case DXGI_FORMAT_B5G6R5_UNORM: targetGuid = GUID_WICPixelFormat16bppBGR565; break; - - case DXGI_FORMAT_R32_FLOAT: - case DXGI_FORMAT_R16_FLOAT: - case DXGI_FORMAT_R16_UNORM: - case DXGI_FORMAT_R8_UNORM: - case DXGI_FORMAT_A8_UNORM: - targetGuid = GUID_WICPixelFormat8bppGray; - break; - - default: - targetGuid = GUID_WICPixelFormat24bppBGR; - break; - } - } - - hr = frame->SetPixelFormat(&targetGuid); - if (FAILED(hr)) - return hr; - - if (targetFormat && memcmp(targetFormat, &targetGuid, sizeof(WICPixelFormatGUID)) != 0) - { - // Requested output pixel format is not supported by the WIC codec - return E_FAIL; - } - - // Encode WIC metadata - ComPtr metawriter; - if (SUCCEEDED(frame->GetMetadataQueryWriter(metawriter.GetAddressOf()))) - { - PROPVARIANT value; - PropVariantInit(&value); - - value.vt = VT_LPSTR; - value.pszVal = const_cast("DirectXTK"); - - if (memcmp(&guidContainerFormat, &GUID_ContainerFormatPng, sizeof(GUID)) == 0) - { - // Set Software name - std::ignore = metawriter->SetMetadataByName(L"/tEXt/{str=Software}", &value); - - // Set sRGB chunk - if (sRGB) - { - value.vt = VT_UI1; - value.bVal = 0; - std::ignore = metawriter->SetMetadataByName(L"/sRGB/RenderingIntent", &value); - } - else - { - // add gAMA chunk with gamma 1.0 - value.vt = VT_UI4; - value.uintVal = 100000; // gama value * 100,000 -- i.e. gamma 1.0 - std::ignore = metawriter->SetMetadataByName(L"/gAMA/ImageGamma", &value); - - // remove sRGB chunk which is added by default. - std::ignore = metawriter->RemoveMetadataByName(L"/sRGB/RenderingIntent"); - } - } - else - { - // Set Software name - std::ignore = metawriter->SetMetadataByName(L"System.ApplicationName", &value); - - if (sRGB) - { - // Set EXIF Colorspace of sRGB - value.vt = VT_UI2; - value.uiVal = 1; - std::ignore = metawriter->SetMetadataByName(L"System.Image.ColorSpace", &value); - } - } - } - - D3D11_MAPPED_SUBRESOURCE mapped; - hr = pContext->Map(pStaging.Get(), 0, D3D11_MAP_READ, 0, &mapped); - if (FAILED(hr)) - return hr; - - const uint64_t imageSize = uint64_t(mapped.RowPitch) * uint64_t(desc.Height); - if (imageSize > UINT32_MAX) - { - pContext->Unmap(pStaging.Get(), 0); - return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); - } - - if (memcmp(&targetGuid, &pfGuid, sizeof(WICPixelFormatGUID)) != 0) - { - // Conversion required to write - ComPtr source; - hr = pWIC->CreateBitmapFromMemory(desc.Width, desc.Height, - pfGuid, - mapped.RowPitch, static_cast(imageSize), - static_cast(mapped.pData), source.GetAddressOf()); - if (FAILED(hr)) - { - pContext->Unmap(pStaging.Get(), 0); - return hr; - } - - ComPtr FC; - hr = pWIC->CreateFormatConverter(FC.GetAddressOf()); - if (FAILED(hr)) - { - pContext->Unmap(pStaging.Get(), 0); - return hr; - } - - BOOL canConvert = FALSE; - hr = FC->CanConvert(pfGuid, targetGuid, &canConvert); - if (FAILED(hr) || !canConvert) - { - pContext->Unmap(pStaging.Get(), 0); - return E_UNEXPECTED; - } - - hr = FC->Initialize(source.Get(), targetGuid, WICBitmapDitherTypeNone, nullptr, 0, WICBitmapPaletteTypeMedianCut); - if (FAILED(hr)) - { - pContext->Unmap(pStaging.Get(), 0); - return hr; - } - - WICRect rect = { 0, 0, static_cast(desc.Width), static_cast(desc.Height) }; - hr = frame->WriteSource(FC.Get(), &rect); - } - else - { - // No conversion required - hr = frame->WritePixels(desc.Height, - mapped.RowPitch, static_cast(imageSize), - static_cast(mapped.pData)); - } - - pContext->Unmap(pStaging.Get(), 0); - - if (FAILED(hr)) - return hr; - - hr = frame->Commit(); - if (FAILED(hr)) - return hr; - - hr = encoder->Commit(); - if (FAILED(hr)) - return hr; - - delonfail.clear(); - - return S_OK; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/ScreenGrab/ScreenGrab11.h b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/ScreenGrab/ScreenGrab11.h deleted file mode 100644 index 0c44887..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/ScreenGrab/ScreenGrab11.h +++ /dev/null @@ -1,46 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: ScreenGrab11.h -// -// Function for capturing a 2D texture and saving it to a file (aka a 'screenshot' -// when used on a Direct3D 11 Render Target). -// -// Note these functions are useful as a light-weight runtime screen grabber. For -// full-featured texture capture, DDS writer, and texture processing pipeline, -// see the 'Texconv' sample and the 'DirectXTex' library. -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -// http://go.microsoft.com/fwlink/?LinkId=248929 -//-------------------------------------------------------------------------------------- - -#pragma once - -#include - -#if defined(NTDDI_WIN10_FE) || defined(__MINGW32__) -#include -#else -#include -#endif - -#include - - -namespace DirectX -{ - HRESULT __cdecl SaveDDSTextureToFile( - _In_ ID3D11DeviceContext* pContext, - _In_ ID3D11Resource* pSource, - _In_z_ const wchar_t* fileName) noexcept; - - HRESULT __cdecl SaveWICTextureToFile( - _In_ ID3D11DeviceContext* pContext, - _In_ ID3D11Resource* pSource, - _In_ REFGUID guidContainerFormat, - _In_z_ const wchar_t* fileName, - _In_opt_ const GUID* targetFormat = nullptr, - _In_opt_ std::function setCustomProps = nullptr, - _In_ bool forceSRGB = false); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/ScreenGrab/ScreenGrab12.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/ScreenGrab/ScreenGrab12.cpp deleted file mode 100644 index 14ee491..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/ScreenGrab/ScreenGrab12.cpp +++ /dev/null @@ -1,1428 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: ScreenGrab12.cpp -// -// Function for capturing a 2D texture and saving it to a file (aka a 'screenshot' -// when used on a Direct3D Render Target). -// -// Note these functions are useful as a light-weight runtime screen grabber. For -// full-featured texture capture, DDS writer, and texture processing pipeline, -// see the 'Texconv' sample and the 'DirectXTex' library. -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -// http://go.microsoft.com/fwlink/?LinkID=615561 -//-------------------------------------------------------------------------------------- - -// Does not capture 1D textures or 3D textures (volume maps) - -// Does not capture mipmap chains, only the top-most texture level is saved - -// For 2D array textures and cubemaps, it captures only the first image in the array - -#include "ScreenGrab12.h" - -#include -#include -#include -#include -#include -#include -#include - -#ifdef _WIN32 -#include -#include -#else -#include -#include -#include -#endif - -#ifdef _MSC_VER -// Off by default warnings -#pragma warning(disable : 4619 4616 4061 4062 4623 4626 5027) -// C4619/4616 #pragma warning warnings -// C4061 enumerator 'x' in switch of enum 'y' is not explicitly handled by a case label -// C4062 enumerator 'x' in switch of enum 'y' is not handled -// C4623 default constructor was implicitly defined as deleted -// C4626 assignment operator was implicitly defined as deleted -// C5027 move assignment operator was implicitly defined as deleted -#endif - -#ifdef __clang__ -#pragma clang diagnostic ignored "-Wtautological-type-limit-compare" -#pragma clang diagnostic ignored "-Wcovered-switch-default" -#pragma clang diagnostic ignored "-Wswitch" -#pragma clang diagnostic ignored "-Wswitch-enum" -#pragma clang diagnostic ignored "-Wunused-macros" -#endif - -#define D3DX12_NO_STATE_OBJECT_HELPERS -#define D3DX12_NO_CHECK_FEATURE_SUPPORT_CLASS -#if !defined(_WIN32) || defined(USING_DIRECTX_HEADERS) -#include "directx/d3dx12.h" -#else -#include "d3dx12.h" -#endif - -using Microsoft::WRL::ComPtr; - -//-------------------------------------------------------------------------------------- -// Macros -//-------------------------------------------------------------------------------------- -#ifndef MAKEFOURCC -#define MAKEFOURCC(ch0, ch1, ch2, ch3) \ - ((uint32_t)(uint8_t)(ch0) | ((uint32_t)(uint8_t)(ch1) << 8) | \ - ((uint32_t)(uint8_t)(ch2) << 16) | ((uint32_t)(uint8_t)(ch3) << 24 )) -#endif /* defined(MAKEFOURCC) */ - -// HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW) -#define HRESULT_E_ARITHMETIC_OVERFLOW static_cast(0x80070216L) - -// HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED) -#define HRESULT_E_NOT_SUPPORTED static_cast(0x80070032L) - -//-------------------------------------------------------------------------------------- -// DDS file structure definitions -// -// See DDS.h in the 'Texconv' sample and the 'DirectXTex' library -//-------------------------------------------------------------------------------------- -namespace -{ -#pragma pack(push,1) - -#define DDS_MAGIC 0x20534444 // "DDS " - - struct DDS_PIXELFORMAT - { - uint32_t size; - uint32_t flags; - uint32_t fourCC; - uint32_t RGBBitCount; - uint32_t RBitMask; - uint32_t GBitMask; - uint32_t BBitMask; - uint32_t ABitMask; - }; - -#define DDS_FOURCC 0x00000004 // DDPF_FOURCC -#define DDS_RGB 0x00000040 // DDPF_RGB -#define DDS_RGBA 0x00000041 // DDPF_RGB | DDPF_ALPHAPIXELS -#define DDS_LUMINANCE 0x00020000 // DDPF_LUMINANCE -#define DDS_LUMINANCEA 0x00020001 // DDPF_LUMINANCE | DDPF_ALPHAPIXELS -#define DDS_ALPHA 0x00000002 // DDPF_ALPHA -#define DDS_BUMPDUDV 0x00080000 // DDPF_BUMPDUDV - -#define DDS_HEADER_FLAGS_TEXTURE 0x00001007 // DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT -#define DDS_HEADER_FLAGS_MIPMAP 0x00020000 // DDSD_MIPMAPCOUNT -#define DDS_HEADER_FLAGS_PITCH 0x00000008 // DDSD_PITCH -#define DDS_HEADER_FLAGS_LINEARSIZE 0x00080000 // DDSD_LINEARSIZE - -#define DDS_SURFACE_FLAGS_TEXTURE 0x00001000 // DDSCAPS_TEXTURE - - struct DDS_HEADER - { - uint32_t size; - uint32_t flags; - uint32_t height; - uint32_t width; - uint32_t pitchOrLinearSize; - uint32_t depth; // only if DDS_HEADER_FLAGS_VOLUME is set in flags - uint32_t mipMapCount; - uint32_t reserved1[11]; - DDS_PIXELFORMAT ddspf; - uint32_t caps; - uint32_t caps2; - uint32_t caps3; - uint32_t caps4; - uint32_t reserved2; - }; - - struct DDS_HEADER_DXT10 - { - DXGI_FORMAT dxgiFormat; - uint32_t resourceDimension; - uint32_t miscFlag; // see D3D11_RESOURCE_MISC_FLAG - uint32_t arraySize; - uint32_t reserved; - }; - -#pragma pack(pop) - - const DDS_PIXELFORMAT DDSPF_DXT1 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','1'), 0, 0, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_DXT3 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','3'), 0, 0, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_DXT5 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','5'), 0, 0, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_BC4_UNORM = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','4','U'), 0, 0, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_BC4_SNORM = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','4','S'), 0, 0, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_BC5_UNORM = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','5','U'), 0, 0, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_BC5_SNORM = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('B','C','5','S'), 0, 0, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_R8G8_B8G8 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('R','G','B','G'), 0, 0, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_G8R8_G8B8 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('G','R','G','B'), 0, 0, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_YUY2 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('Y','U','Y','2'), 0, 0, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_A8R8G8B8 = - { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 }; - - const DDS_PIXELFORMAT DDSPF_X8R8G8B8 = - { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0 }; - - const DDS_PIXELFORMAT DDSPF_A8B8G8R8 = - { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 }; - - const DDS_PIXELFORMAT DDSPF_G16R16 = - { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x0000ffff, 0xffff0000, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_R5G6B5 = - { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0xf800, 0x07e0, 0x001f, 0 }; - - const DDS_PIXELFORMAT DDSPF_A1R5G5B5 = - { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x7c00, 0x03e0, 0x001f, 0x8000 }; - - const DDS_PIXELFORMAT DDSPF_A4R4G4B4 = - { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x0f00, 0x00f0, 0x000f, 0xf000 }; - - const DDS_PIXELFORMAT DDSPF_L8 = - { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCE, 0, 8, 0xff, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_L16 = - { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCE, 0, 16, 0xffff, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_A8L8 = - { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCEA, 0, 16, 0x00ff, 0, 0, 0xff00 }; - - const DDS_PIXELFORMAT DDSPF_A8 = - { sizeof(DDS_PIXELFORMAT), DDS_ALPHA, 0, 8, 0, 0, 0, 0xff }; - - const DDS_PIXELFORMAT DDSPF_V8U8 = - { sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 16, 0x00ff, 0xff00, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_Q8W8V8U8 = - { sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 }; - - const DDS_PIXELFORMAT DDSPF_V16U16 = - { sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 32, 0x0000ffff, 0xffff0000, 0, 0 }; - - // DXGI_FORMAT_R10G10B10A2_UNORM should be written using DX10 extension to avoid D3DX 10:10:10:2 reversal issue - - // This indicates the DDS_HEADER_DXT10 extension is present (the format is in dxgiFormat) - const DDS_PIXELFORMAT DDSPF_DX10 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','1','0'), 0, 0, 0, 0, 0 }; - - //----------------------------------------------------------------------------- -#ifdef _WIN32 - struct handle_closer { void operator()(HANDLE h) noexcept { if (h) CloseHandle(h); } }; - - using ScopedHandle = std::unique_ptr; - - inline HANDLE safe_handle(HANDLE h) noexcept { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; } - - class auto_delete_file - { - public: - auto_delete_file(HANDLE hFile) noexcept : m_handle(hFile) {} - ~auto_delete_file() - { - if (m_handle) - { - FILE_DISPOSITION_INFO info = {}; - info.DeleteFile = TRUE; - std::ignore = SetFileInformationByHandle(m_handle, FileDispositionInfo, &info, sizeof(info)); - } - } - - auto_delete_file(const auto_delete_file&) = delete; - auto_delete_file& operator=(const auto_delete_file&) = delete; - - auto_delete_file(const auto_delete_file&&) = delete; - auto_delete_file& operator=(const auto_delete_file&&) = delete; - - void clear() noexcept { m_handle = nullptr; } - - private: - HANDLE m_handle; - }; - - class auto_delete_file_wic - { - public: - auto_delete_file_wic(ComPtr& hFile, const wchar_t* szFile) noexcept : m_filename(szFile), m_handle(hFile) {} - ~auto_delete_file_wic() - { - if (m_filename) - { - m_handle.Reset(); - DeleteFileW(m_filename); - } - } - - auto_delete_file_wic(const auto_delete_file_wic&) = delete; - auto_delete_file_wic& operator=(const auto_delete_file_wic&) = delete; - - auto_delete_file_wic(const auto_delete_file_wic&&) = delete; - auto_delete_file_wic& operator=(const auto_delete_file_wic&&) = delete; - - void clear() noexcept { m_filename = nullptr; } - - private: - const wchar_t* m_filename; - ComPtr& m_handle; - }; -#endif - - //-------------------------------------------------------------------------------------- - // Return the BPP for a particular format - //-------------------------------------------------------------------------------------- - size_t BitsPerPixel(_In_ DXGI_FORMAT fmt) noexcept - { - switch (fmt) - { - case DXGI_FORMAT_R32G32B32A32_TYPELESS: - case DXGI_FORMAT_R32G32B32A32_FLOAT: - case DXGI_FORMAT_R32G32B32A32_UINT: - case DXGI_FORMAT_R32G32B32A32_SINT: - return 128; - - case DXGI_FORMAT_R32G32B32_TYPELESS: - case DXGI_FORMAT_R32G32B32_FLOAT: - case DXGI_FORMAT_R32G32B32_UINT: - case DXGI_FORMAT_R32G32B32_SINT: - return 96; - - case DXGI_FORMAT_R16G16B16A16_TYPELESS: - case DXGI_FORMAT_R16G16B16A16_FLOAT: - case DXGI_FORMAT_R16G16B16A16_UNORM: - case DXGI_FORMAT_R16G16B16A16_UINT: - case DXGI_FORMAT_R16G16B16A16_SNORM: - case DXGI_FORMAT_R16G16B16A16_SINT: - case DXGI_FORMAT_R32G32_TYPELESS: - case DXGI_FORMAT_R32G32_FLOAT: - case DXGI_FORMAT_R32G32_UINT: - case DXGI_FORMAT_R32G32_SINT: - case DXGI_FORMAT_R32G8X24_TYPELESS: - case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: - case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: - case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: - case DXGI_FORMAT_Y416: - case DXGI_FORMAT_Y210: - case DXGI_FORMAT_Y216: - return 64; - - case DXGI_FORMAT_R10G10B10A2_TYPELESS: - case DXGI_FORMAT_R10G10B10A2_UNORM: - case DXGI_FORMAT_R10G10B10A2_UINT: - case DXGI_FORMAT_R11G11B10_FLOAT: - case DXGI_FORMAT_R8G8B8A8_TYPELESS: - case DXGI_FORMAT_R8G8B8A8_UNORM: - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - case DXGI_FORMAT_R8G8B8A8_UINT: - case DXGI_FORMAT_R8G8B8A8_SNORM: - case DXGI_FORMAT_R8G8B8A8_SINT: - case DXGI_FORMAT_R16G16_TYPELESS: - case DXGI_FORMAT_R16G16_FLOAT: - case DXGI_FORMAT_R16G16_UNORM: - case DXGI_FORMAT_R16G16_UINT: - case DXGI_FORMAT_R16G16_SNORM: - case DXGI_FORMAT_R16G16_SINT: - case DXGI_FORMAT_R32_TYPELESS: - case DXGI_FORMAT_D32_FLOAT: - case DXGI_FORMAT_R32_FLOAT: - case DXGI_FORMAT_R32_UINT: - case DXGI_FORMAT_R32_SINT: - case DXGI_FORMAT_R24G8_TYPELESS: - case DXGI_FORMAT_D24_UNORM_S8_UINT: - case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: - case DXGI_FORMAT_X24_TYPELESS_G8_UINT: - case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: - case DXGI_FORMAT_R8G8_B8G8_UNORM: - case DXGI_FORMAT_G8R8_G8B8_UNORM: - case DXGI_FORMAT_B8G8R8A8_UNORM: - case DXGI_FORMAT_B8G8R8X8_UNORM: - case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: - case DXGI_FORMAT_B8G8R8A8_TYPELESS: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8X8_TYPELESS: - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - case DXGI_FORMAT_AYUV: - case DXGI_FORMAT_Y410: - case DXGI_FORMAT_YUY2: - return 32; - - case DXGI_FORMAT_P010: - case DXGI_FORMAT_P016: - case DXGI_FORMAT_V408: - return 24; - - case DXGI_FORMAT_R8G8_TYPELESS: - case DXGI_FORMAT_R8G8_UNORM: - case DXGI_FORMAT_R8G8_UINT: - case DXGI_FORMAT_R8G8_SNORM: - case DXGI_FORMAT_R8G8_SINT: - case DXGI_FORMAT_R16_TYPELESS: - case DXGI_FORMAT_R16_FLOAT: - case DXGI_FORMAT_D16_UNORM: - case DXGI_FORMAT_R16_UNORM: - case DXGI_FORMAT_R16_UINT: - case DXGI_FORMAT_R16_SNORM: - case DXGI_FORMAT_R16_SINT: - case DXGI_FORMAT_B5G6R5_UNORM: - case DXGI_FORMAT_B5G5R5A1_UNORM: - case DXGI_FORMAT_A8P8: - case DXGI_FORMAT_B4G4R4A4_UNORM: - case DXGI_FORMAT_P208: - case DXGI_FORMAT_V208: - return 16; - - case DXGI_FORMAT_NV12: - case DXGI_FORMAT_420_OPAQUE: - case DXGI_FORMAT_NV11: - return 12; - - case DXGI_FORMAT_R8_TYPELESS: - case DXGI_FORMAT_R8_UNORM: - case DXGI_FORMAT_R8_UINT: - case DXGI_FORMAT_R8_SNORM: - case DXGI_FORMAT_R8_SINT: - case DXGI_FORMAT_A8_UNORM: - case DXGI_FORMAT_BC2_TYPELESS: - case DXGI_FORMAT_BC2_UNORM: - case DXGI_FORMAT_BC2_UNORM_SRGB: - case DXGI_FORMAT_BC3_TYPELESS: - case DXGI_FORMAT_BC3_UNORM: - case DXGI_FORMAT_BC3_UNORM_SRGB: - case DXGI_FORMAT_BC5_TYPELESS: - case DXGI_FORMAT_BC5_UNORM: - case DXGI_FORMAT_BC5_SNORM: - case DXGI_FORMAT_BC6H_TYPELESS: - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - case DXGI_FORMAT_BC7_TYPELESS: - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: - case DXGI_FORMAT_AI44: - case DXGI_FORMAT_IA44: - case DXGI_FORMAT_P8: - return 8; - - case DXGI_FORMAT_R1_UNORM: - return 1; - - case DXGI_FORMAT_BC1_TYPELESS: - case DXGI_FORMAT_BC1_UNORM: - case DXGI_FORMAT_BC1_UNORM_SRGB: - case DXGI_FORMAT_BC4_TYPELESS: - case DXGI_FORMAT_BC4_UNORM: - case DXGI_FORMAT_BC4_SNORM: - return 4; - - default: - return 0; - } - } - - - //-------------------------------------------------------------------------------------- - // Determines if the format is block compressed - //-------------------------------------------------------------------------------------- - bool IsCompressed(_In_ DXGI_FORMAT fmt) noexcept - { - switch (fmt) - { - case DXGI_FORMAT_BC1_TYPELESS: - case DXGI_FORMAT_BC1_UNORM: - case DXGI_FORMAT_BC1_UNORM_SRGB: - case DXGI_FORMAT_BC2_TYPELESS: - case DXGI_FORMAT_BC2_UNORM: - case DXGI_FORMAT_BC2_UNORM_SRGB: - case DXGI_FORMAT_BC3_TYPELESS: - case DXGI_FORMAT_BC3_UNORM: - case DXGI_FORMAT_BC3_UNORM_SRGB: - case DXGI_FORMAT_BC4_TYPELESS: - case DXGI_FORMAT_BC4_UNORM: - case DXGI_FORMAT_BC4_SNORM: - case DXGI_FORMAT_BC5_TYPELESS: - case DXGI_FORMAT_BC5_UNORM: - case DXGI_FORMAT_BC5_SNORM: - case DXGI_FORMAT_BC6H_TYPELESS: - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - case DXGI_FORMAT_BC7_TYPELESS: - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: - return true; - - default: - return false; - } - } - - - //-------------------------------------------------------------------------------------- - // Get surface information for a particular format - //-------------------------------------------------------------------------------------- - HRESULT GetSurfaceInfo( - _In_ size_t width, - _In_ size_t height, - _In_ DXGI_FORMAT fmt, - _Out_opt_ size_t* outNumBytes, - _Out_opt_ size_t* outRowBytes, - _Out_opt_ size_t* outNumRows) noexcept - { - uint64_t numBytes = 0; - uint64_t rowBytes = 0; - uint64_t numRows = 0; - - bool bc = false; - bool packed = false; - bool planar = false; - size_t bpe = 0; - switch (fmt) - { - case DXGI_FORMAT_BC1_TYPELESS: - case DXGI_FORMAT_BC1_UNORM: - case DXGI_FORMAT_BC1_UNORM_SRGB: - case DXGI_FORMAT_BC4_TYPELESS: - case DXGI_FORMAT_BC4_UNORM: - case DXGI_FORMAT_BC4_SNORM: - bc = true; - bpe = 8; - break; - - case DXGI_FORMAT_BC2_TYPELESS: - case DXGI_FORMAT_BC2_UNORM: - case DXGI_FORMAT_BC2_UNORM_SRGB: - case DXGI_FORMAT_BC3_TYPELESS: - case DXGI_FORMAT_BC3_UNORM: - case DXGI_FORMAT_BC3_UNORM_SRGB: - case DXGI_FORMAT_BC5_TYPELESS: - case DXGI_FORMAT_BC5_UNORM: - case DXGI_FORMAT_BC5_SNORM: - case DXGI_FORMAT_BC6H_TYPELESS: - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - case DXGI_FORMAT_BC7_TYPELESS: - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: - bc = true; - bpe = 16; - break; - - case DXGI_FORMAT_R8G8_B8G8_UNORM: - case DXGI_FORMAT_G8R8_G8B8_UNORM: - case DXGI_FORMAT_YUY2: - packed = true; - bpe = 4; - break; - - case DXGI_FORMAT_Y210: - case DXGI_FORMAT_Y216: - packed = true; - bpe = 8; - break; - - case DXGI_FORMAT_NV12: - case DXGI_FORMAT_420_OPAQUE: - case DXGI_FORMAT_P208: - planar = true; - bpe = 2; - break; - - case DXGI_FORMAT_P010: - case DXGI_FORMAT_P016: - planar = true; - bpe = 4; - break; - - default: - break; - } - - if (bc) - { - uint64_t numBlocksWide = 0; - if (width > 0) - { - numBlocksWide = std::max(1u, (uint64_t(width) + 3u) / 4u); - } - uint64_t numBlocksHigh = 0; - if (height > 0) - { - numBlocksHigh = std::max(1u, (uint64_t(height) + 3u) / 4u); - } - rowBytes = numBlocksWide * bpe; - numRows = numBlocksHigh; - numBytes = rowBytes * numBlocksHigh; - } - else if (packed) - { - rowBytes = ((uint64_t(width) + 1u) >> 1) * bpe; - numRows = uint64_t(height); - numBytes = rowBytes * height; - } - else if (fmt == DXGI_FORMAT_NV11) - { - rowBytes = ((uint64_t(width) + 3u) >> 2) * 4u; - numRows = uint64_t(height) * 2u; // Direct3D makes this simplifying assumption, although it is larger than the 4:1:1 data - numBytes = rowBytes * numRows; - } - else if (planar) - { - rowBytes = ((uint64_t(width) + 1u) >> 1) * bpe; - numBytes = (rowBytes * uint64_t(height)) + ((rowBytes * uint64_t(height) + 1u) >> 1); - numRows = height + ((uint64_t(height) + 1u) >> 1); - } - else - { - const size_t bpp = BitsPerPixel(fmt); - if (!bpp) - return E_INVALIDARG; - - rowBytes = (uint64_t(width) * bpp + 7u) / 8u; // round up to nearest byte - numRows = uint64_t(height); - numBytes = rowBytes * height; - } - - #if defined(_M_IX86) || defined(_M_ARM) || defined(_M_HYBRID_X86_ARM64) - static_assert(sizeof(size_t) == 4, "Not a 32-bit platform!"); - if (numBytes > UINT32_MAX || rowBytes > UINT32_MAX || numRows > UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - #else - static_assert(sizeof(size_t) == 8, "Not a 64-bit platform!"); - #endif - - if (outNumBytes) - { - *outNumBytes = static_cast(numBytes); - } - if (outRowBytes) - { - *outRowBytes = static_cast(rowBytes); - } - if (outNumRows) - { - *outNumRows = static_cast(numRows); - } - - return S_OK; - } - - - //-------------------------------------------------------------------------------------- - DXGI_FORMAT EnsureNotTypeless(DXGI_FORMAT fmt) noexcept - { - // Assumes UNORM or FLOAT; doesn't use UINT or SINT - switch (fmt) - { - case DXGI_FORMAT_R32G32B32A32_TYPELESS: return DXGI_FORMAT_R32G32B32A32_FLOAT; - case DXGI_FORMAT_R32G32B32_TYPELESS: return DXGI_FORMAT_R32G32B32_FLOAT; - case DXGI_FORMAT_R16G16B16A16_TYPELESS: return DXGI_FORMAT_R16G16B16A16_UNORM; - case DXGI_FORMAT_R32G32_TYPELESS: return DXGI_FORMAT_R32G32_FLOAT; - case DXGI_FORMAT_R10G10B10A2_TYPELESS: return DXGI_FORMAT_R10G10B10A2_UNORM; - case DXGI_FORMAT_R8G8B8A8_TYPELESS: return DXGI_FORMAT_R8G8B8A8_UNORM; - case DXGI_FORMAT_R16G16_TYPELESS: return DXGI_FORMAT_R16G16_UNORM; - case DXGI_FORMAT_R32_TYPELESS: return DXGI_FORMAT_R32_FLOAT; - case DXGI_FORMAT_R8G8_TYPELESS: return DXGI_FORMAT_R8G8_UNORM; - case DXGI_FORMAT_R16_TYPELESS: return DXGI_FORMAT_R16_UNORM; - case DXGI_FORMAT_R8_TYPELESS: return DXGI_FORMAT_R8_UNORM; - case DXGI_FORMAT_BC1_TYPELESS: return DXGI_FORMAT_BC1_UNORM; - case DXGI_FORMAT_BC2_TYPELESS: return DXGI_FORMAT_BC2_UNORM; - case DXGI_FORMAT_BC3_TYPELESS: return DXGI_FORMAT_BC3_UNORM; - case DXGI_FORMAT_BC4_TYPELESS: return DXGI_FORMAT_BC4_UNORM; - case DXGI_FORMAT_BC5_TYPELESS: return DXGI_FORMAT_BC5_UNORM; - case DXGI_FORMAT_B8G8R8A8_TYPELESS: return DXGI_FORMAT_B8G8R8A8_UNORM; - case DXGI_FORMAT_B8G8R8X8_TYPELESS: return DXGI_FORMAT_B8G8R8X8_UNORM; - case DXGI_FORMAT_BC7_TYPELESS: return DXGI_FORMAT_BC7_UNORM; - default: return fmt; - } - } - - - //-------------------------------------------------------------------------------------- - inline void TransitionResource( - _In_ ID3D12GraphicsCommandList* commandList, - _In_ ID3D12Resource* resource, - _In_ D3D12_RESOURCE_STATES stateBefore, - _In_ D3D12_RESOURCE_STATES stateAfter) noexcept - { - assert(commandList != nullptr); - assert(resource != nullptr); - - if (stateBefore == stateAfter) - return; - - D3D12_RESOURCE_BARRIER desc = {}; - desc.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; - desc.Transition.pResource = resource; - desc.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES; - desc.Transition.StateBefore = stateBefore; - desc.Transition.StateAfter = stateAfter; - - commandList->ResourceBarrier(1, &desc); - } - - - //-------------------------------------------------------------------------------------- - HRESULT CaptureTexture(_In_ ID3D12Device* device, - _In_ ID3D12CommandQueue* pCommandQ, - _In_ ID3D12Resource* pSource, - UINT64 srcPitch, - const D3D12_RESOURCE_DESC& desc, - ComPtr& pStaging, - D3D12_RESOURCE_STATES beforeState, - D3D12_RESOURCE_STATES afterState) noexcept - { - if (!pCommandQ || !pSource) - return E_INVALIDARG; - - if (desc.Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE2D) - return HRESULT_E_NOT_SUPPORTED; - - if (srcPitch > UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - const UINT numberOfPlanes = D3D12GetFormatPlaneCount(device, desc.Format); - if (numberOfPlanes != 1) - return HRESULT_E_NOT_SUPPORTED; - - D3D12_HEAP_PROPERTIES sourceHeapProperties; - HRESULT hr = pSource->GetHeapProperties(&sourceHeapProperties, nullptr); - if (SUCCEEDED(hr) && sourceHeapProperties.Type == D3D12_HEAP_TYPE_READBACK) - { - // Handle case where the source is already a staging texture we can use directly - pStaging = pSource; - return S_OK; - } - - // Create a command allocator - ComPtr commandAlloc; - hr = device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_ID3D12CommandAllocator, reinterpret_cast(commandAlloc.GetAddressOf())); - if (FAILED(hr)) - return hr; - - // Spin up a new command list - ComPtr commandList; - hr = device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, commandAlloc.Get(), nullptr, IID_ID3D12GraphicsCommandList, reinterpret_cast(commandList.GetAddressOf())); - if (FAILED(hr)) - return hr; - - // Create a fence - ComPtr fence; - hr = device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_ID3D12Fence, reinterpret_cast(fence.GetAddressOf())); - if (FAILED(hr)) - return hr; - - assert((srcPitch & 0xFF) == 0); - - const CD3DX12_HEAP_PROPERTIES defaultHeapProperties(D3D12_HEAP_TYPE_DEFAULT); - const CD3DX12_HEAP_PROPERTIES readBackHeapProperties(D3D12_HEAP_TYPE_READBACK); - - // Readback resources must be buffers - D3D12_RESOURCE_DESC bufferDesc = {}; - bufferDesc.DepthOrArraySize = 1; - bufferDesc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; - bufferDesc.Flags = D3D12_RESOURCE_FLAG_NONE; - bufferDesc.Format = DXGI_FORMAT_UNKNOWN; - bufferDesc.Height = 1; - bufferDesc.Width = srcPitch * desc.Height; - bufferDesc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; - bufferDesc.MipLevels = 1; - bufferDesc.SampleDesc.Count = 1; - - ComPtr copySource(pSource); - if (desc.SampleDesc.Count > 1) - { - // MSAA content must be resolved before being copied to a staging texture - auto descCopy = desc; - descCopy.SampleDesc.Count = 1; - descCopy.SampleDesc.Quality = 0; - descCopy.Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT; - - ComPtr pTemp; - hr = device->CreateCommittedResource( - &defaultHeapProperties, - D3D12_HEAP_FLAG_NONE, - &descCopy, - D3D12_RESOURCE_STATE_COPY_DEST, - nullptr, - IID_ID3D12Resource, - reinterpret_cast(pTemp.GetAddressOf())); - if (FAILED(hr)) - return hr; - - assert(pTemp); - - const DXGI_FORMAT fmt = EnsureNotTypeless(desc.Format); - - D3D12_FEATURE_DATA_FORMAT_SUPPORT formatInfo = { fmt, D3D12_FORMAT_SUPPORT1_NONE, D3D12_FORMAT_SUPPORT2_NONE }; - hr = device->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT, &formatInfo, sizeof(formatInfo)); - if (FAILED(hr)) - return hr; - - if (!(formatInfo.Support1 & D3D12_FORMAT_SUPPORT1_TEXTURE2D)) - return E_FAIL; - - for (UINT item = 0; item < desc.DepthOrArraySize; ++item) - { - for (UINT level = 0; level < desc.MipLevels; ++level) - { - const UINT index = D3D12CalcSubresource(level, item, 0, desc.MipLevels, desc.DepthOrArraySize); - commandList->ResolveSubresource(pTemp.Get(), index, pSource, index, fmt); - } - } - - copySource = pTemp; - } - - // Create a staging texture - hr = device->CreateCommittedResource( - &readBackHeapProperties, - D3D12_HEAP_FLAG_NONE, - &bufferDesc, - D3D12_RESOURCE_STATE_COPY_DEST, - nullptr, - IID_ID3D12Resource, - reinterpret_cast(pStaging.ReleaseAndGetAddressOf())); - if (FAILED(hr)) - return hr; - - assert(pStaging); - - // Transition the resource if necessary - TransitionResource(commandList.Get(), pSource, beforeState, D3D12_RESOURCE_STATE_COPY_SOURCE); - - // Get the copy target location - D3D12_PLACED_SUBRESOURCE_FOOTPRINT bufferFootprint = {}; - bufferFootprint.Footprint.Width = static_cast(desc.Width); - bufferFootprint.Footprint.Height = desc.Height; - bufferFootprint.Footprint.Depth = 1; - bufferFootprint.Footprint.RowPitch = static_cast(srcPitch); - bufferFootprint.Footprint.Format = desc.Format; - - const CD3DX12_TEXTURE_COPY_LOCATION copyDest(pStaging.Get(), bufferFootprint); - const CD3DX12_TEXTURE_COPY_LOCATION copySrc(copySource.Get(), 0); - - // Copy the texture - commandList->CopyTextureRegion(©Dest, 0, 0, 0, ©Src, nullptr); - - // Transition the resource to the next state - TransitionResource(commandList.Get(), pSource, D3D12_RESOURCE_STATE_COPY_SOURCE, afterState); - - hr = commandList->Close(); - if (FAILED(hr)) - return hr; - - // Execute the command list - pCommandQ->ExecuteCommandLists(1, CommandListCast(commandList.GetAddressOf())); - - // Signal the fence - hr = pCommandQ->Signal(fence.Get(), 1); - if (FAILED(hr)) - return hr; - - // Block until the copy is complete - while (fence->GetCompletedValue() < 1) - { - #ifdef _WIN32 - SwitchToThread(); - #else - std::this_thread::yield(); - #endif - } - - return S_OK; - } - -#ifdef _WIN32 - BOOL WINAPI InitializeWICFactory(PINIT_ONCE, PVOID, PVOID* ifactory) noexcept - { - return SUCCEEDED(CoCreateInstance( - CLSID_WICImagingFactory2, - nullptr, - CLSCTX_INPROC_SERVER, - __uuidof(IWICImagingFactory2), - ifactory)) ? TRUE : FALSE; - } - - IWICImagingFactory2* GetWIC() noexcept - { - static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT; - - IWICImagingFactory2* factory = nullptr; - if (!InitOnceExecuteOnce(&s_initOnce, - InitializeWICFactory, - nullptr, - reinterpret_cast(&factory))) - { - return nullptr; - } - - return factory; - } -#endif -} // anonymous namespace - - -//-------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::SaveDDSTextureToFile( - ID3D12CommandQueue* pCommandQ, - ID3D12Resource* pSource, - const wchar_t* fileName, - D3D12_RESOURCE_STATES beforeState, - D3D12_RESOURCE_STATES afterState) noexcept -{ - if (!fileName) - return E_INVALIDARG; - - ComPtr device; - pCommandQ->GetDevice(IID_ID3D12Device, reinterpret_cast(device.GetAddressOf())); - - // Get the size of the image - const auto desc = pSource->GetDesc(); - - if (desc.Width > UINT32_MAX) - return E_INVALIDARG; - - UINT64 totalResourceSize = 0; - UINT64 fpRowPitch = 0; - UINT fpRowCount = 0; - // Get the rowcount, pitch and size of the top mip - device->GetCopyableFootprints( - &desc, - 0, - 1, - 0, - nullptr, - &fpRowCount, - &fpRowPitch, - &totalResourceSize); - - // Round up the srcPitch to multiples of 256 - const UINT64 dstRowPitch = (fpRowPitch + 255) & ~0xFFu; - - if (dstRowPitch > UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - ComPtr pStaging; - HRESULT hr = CaptureTexture(device.Get(), pCommandQ, pSource, dstRowPitch, desc, pStaging, beforeState, afterState); - if (FAILED(hr)) - return hr; - - // Create file -#ifdef _WIN32 - ScopedHandle hFile(safe_handle(CreateFile2(fileName, GENERIC_WRITE, 0, CREATE_ALWAYS, nullptr))); - if (!hFile) - return HRESULT_FROM_WIN32(GetLastError()); - - auto_delete_file delonfail(hFile.get()); -#else - std::ofstream outFile(std::filesystem::path(fileName), std::ios::out | std::ios::binary | std::ios::trunc); - if (!outFile) - return E_FAIL; -#endif - - // Setup header - constexpr size_t MAX_HEADER_SIZE = sizeof(uint32_t) + sizeof(DDS_HEADER) + sizeof(DDS_HEADER_DXT10); - uint8_t fileHeader[MAX_HEADER_SIZE] = {}; - - *reinterpret_cast(&fileHeader[0]) = DDS_MAGIC; - - auto header = reinterpret_cast(&fileHeader[0] + sizeof(uint32_t)); - size_t headerSize = sizeof(uint32_t) + sizeof(DDS_HEADER); - header->size = sizeof(DDS_HEADER); - header->flags = DDS_HEADER_FLAGS_TEXTURE | DDS_HEADER_FLAGS_MIPMAP; - header->height = desc.Height; - header->width = static_cast(desc.Width); - header->mipMapCount = 1; - header->caps = DDS_SURFACE_FLAGS_TEXTURE; - - // Try to use a legacy .DDS pixel format for better tools support, otherwise fallback to 'DX10' header extension - DDS_HEADER_DXT10* extHeader = nullptr; - switch (desc.Format) - { - case DXGI_FORMAT_R8G8B8A8_UNORM: memcpy(&header->ddspf, &DDSPF_A8B8G8R8, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_R16G16_UNORM: memcpy(&header->ddspf, &DDSPF_G16R16, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_R8G8_UNORM: memcpy(&header->ddspf, &DDSPF_A8L8, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_R16_UNORM: memcpy(&header->ddspf, &DDSPF_L16, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_R8_UNORM: memcpy(&header->ddspf, &DDSPF_L8, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_A8_UNORM: memcpy(&header->ddspf, &DDSPF_A8, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_R8G8_B8G8_UNORM: memcpy(&header->ddspf, &DDSPF_R8G8_B8G8, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_G8R8_G8B8_UNORM: memcpy(&header->ddspf, &DDSPF_G8R8_G8B8, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_BC1_UNORM: memcpy(&header->ddspf, &DDSPF_DXT1, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_BC2_UNORM: memcpy(&header->ddspf, &DDSPF_DXT3, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_BC3_UNORM: memcpy(&header->ddspf, &DDSPF_DXT5, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_BC4_UNORM: memcpy(&header->ddspf, &DDSPF_BC4_UNORM, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_BC4_SNORM: memcpy(&header->ddspf, &DDSPF_BC4_SNORM, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_BC5_UNORM: memcpy(&header->ddspf, &DDSPF_BC5_UNORM, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_BC5_SNORM: memcpy(&header->ddspf, &DDSPF_BC5_SNORM, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_B5G6R5_UNORM: memcpy(&header->ddspf, &DDSPF_R5G6B5, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_B5G5R5A1_UNORM: memcpy(&header->ddspf, &DDSPF_A1R5G5B5, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_R8G8_SNORM: memcpy(&header->ddspf, &DDSPF_V8U8, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_R8G8B8A8_SNORM: memcpy(&header->ddspf, &DDSPF_Q8W8V8U8, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_R16G16_SNORM: memcpy(&header->ddspf, &DDSPF_V16U16, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_B8G8R8A8_UNORM: memcpy(&header->ddspf, &DDSPF_A8R8G8B8, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_B8G8R8X8_UNORM: memcpy(&header->ddspf, &DDSPF_X8R8G8B8, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_YUY2: memcpy(&header->ddspf, &DDSPF_YUY2, sizeof(DDS_PIXELFORMAT)); break; - case DXGI_FORMAT_B4G4R4A4_UNORM: memcpy(&header->ddspf, &DDSPF_A4R4G4B4, sizeof(DDS_PIXELFORMAT)); break; - - // Legacy D3DX formats using D3DFMT enum value as FourCC - case DXGI_FORMAT_R32G32B32A32_FLOAT: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 116; break; // D3DFMT_A32B32G32R32F - case DXGI_FORMAT_R16G16B16A16_FLOAT: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 113; break; // D3DFMT_A16B16G16R16F - case DXGI_FORMAT_R16G16B16A16_UNORM: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 36; break; // D3DFMT_A16B16G16R16 - case DXGI_FORMAT_R16G16B16A16_SNORM: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 110; break; // D3DFMT_Q16W16V16U16 - case DXGI_FORMAT_R32G32_FLOAT: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 115; break; // D3DFMT_G32R32F - case DXGI_FORMAT_R16G16_FLOAT: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 112; break; // D3DFMT_G16R16F - case DXGI_FORMAT_R32_FLOAT: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 114; break; // D3DFMT_R32F - case DXGI_FORMAT_R16_FLOAT: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 111; break; // D3DFMT_R16F - - case DXGI_FORMAT_AI44: - case DXGI_FORMAT_IA44: - case DXGI_FORMAT_P8: - case DXGI_FORMAT_A8P8: - return HRESULT_E_NOT_SUPPORTED; - - default: - memcpy(&header->ddspf, &DDSPF_DX10, sizeof(DDS_PIXELFORMAT)); - - headerSize += sizeof(DDS_HEADER_DXT10); - extHeader = reinterpret_cast(fileHeader + sizeof(uint32_t) + sizeof(DDS_HEADER)); - extHeader->dxgiFormat = desc.Format; - extHeader->resourceDimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; - extHeader->arraySize = 1; - break; - } - - size_t rowPitch, slicePitch, rowCount; - hr = GetSurfaceInfo(static_cast(desc.Width), desc.Height, desc.Format, &slicePitch, &rowPitch, &rowCount); - if (FAILED(hr)) - return hr; - - if (rowPitch > UINT32_MAX || slicePitch > UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - if (IsCompressed(desc.Format)) - { - header->flags |= DDS_HEADER_FLAGS_LINEARSIZE; - header->pitchOrLinearSize = static_cast(slicePitch); - } - else - { - header->flags |= DDS_HEADER_FLAGS_PITCH; - header->pitchOrLinearSize = static_cast(rowPitch); - } - - // Setup pixels - std::unique_ptr pixels(new (std::nothrow) uint8_t[slicePitch]); - if (!pixels) - return E_OUTOFMEMORY; - - assert(fpRowCount == rowCount); - assert(fpRowPitch == rowPitch); - - const UINT64 imageSize = dstRowPitch * UINT64(rowCount); - if (imageSize > UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - void* pMappedMemory = nullptr; - D3D12_RANGE readRange = { 0, static_cast(imageSize) }; - D3D12_RANGE writeRange = { 0, 0 }; - hr = pStaging->Map(0, &readRange, &pMappedMemory); - if (FAILED(hr)) - return hr; - - auto sptr = static_cast(pMappedMemory); - if (!sptr) - { - pStaging->Unmap(0, &writeRange); - return E_POINTER; - } - - uint8_t* dptr = pixels.get(); - - const size_t msize = std::min(rowPitch, size_t(dstRowPitch)); - for (size_t h = 0; h < rowCount; ++h) - { - memcpy(dptr, sptr, msize); - sptr += dstRowPitch; - dptr += rowPitch; - } - - pStaging->Unmap(0, &writeRange); - - // Write header & pixels -#ifdef _WIN32 - DWORD bytesWritten; - if (!WriteFile(hFile.get(), fileHeader, static_cast(headerSize), &bytesWritten, nullptr)) - return HRESULT_FROM_WIN32(GetLastError()); - - if (bytesWritten != headerSize) - return E_FAIL; - - if (!WriteFile(hFile.get(), pixels.get(), static_cast(slicePitch), &bytesWritten, nullptr)) - return HRESULT_FROM_WIN32(GetLastError()); - - if (bytesWritten != slicePitch) - return E_FAIL; - - delonfail.clear(); -#else - outFile.write(reinterpret_cast(fileHeader), static_cast(headerSize)); - if (!outFile) - return E_FAIL; - - outFile.write(reinterpret_cast(pixels.get()), static_cast(slicePitch)); - if (!outFile) - return E_FAIL; - - outFile.close(); -#endif - - return S_OK; -} - -//-------------------------------------------------------------------------------------- -#ifdef _WIN32 -_Use_decl_annotations_ -HRESULT DirectX::SaveWICTextureToFile( - ID3D12CommandQueue* pCommandQ, - ID3D12Resource* pSource, - REFGUID guidContainerFormat, - const wchar_t* fileName, - D3D12_RESOURCE_STATES beforeState, - D3D12_RESOURCE_STATES afterState, - const GUID* targetFormat, - std::function setCustomProps, - bool forceSRGB) -{ - if (!fileName) - return E_INVALIDARG; - - ComPtr device; - pCommandQ->GetDevice(IID_ID3D12Device, reinterpret_cast(device.GetAddressOf())); - - // Get the size of the image - const auto desc = pSource->GetDesc(); - - if (desc.Width > UINT32_MAX) - return E_INVALIDARG; - - UINT64 totalResourceSize = 0; - UINT64 fpRowPitch = 0; - UINT fpRowCount = 0; - // Get the rowcount, pitch and size of the top mip - device->GetCopyableFootprints( - &desc, - 0, - 1, - 0, - nullptr, - &fpRowCount, - &fpRowPitch, - &totalResourceSize); - - // Round up the srcPitch to multiples of 256 - const UINT64 dstRowPitch = (fpRowPitch + 255) & ~0xFFu; - - if (dstRowPitch > UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - ComPtr pStaging; - HRESULT hr = CaptureTexture(device.Get(), pCommandQ, pSource, dstRowPitch, desc, pStaging, beforeState, afterState); - if (FAILED(hr)) - return hr; - - // Determine source format's WIC equivalent - WICPixelFormatGUID pfGuid = {}; - bool sRGB = forceSRGB; - switch (desc.Format) - { - case DXGI_FORMAT_R32G32B32A32_FLOAT: pfGuid = GUID_WICPixelFormat128bppRGBAFloat; break; - case DXGI_FORMAT_R16G16B16A16_FLOAT: pfGuid = GUID_WICPixelFormat64bppRGBAHalf; break; - case DXGI_FORMAT_R16G16B16A16_UNORM: pfGuid = GUID_WICPixelFormat64bppRGBA; break; - case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: pfGuid = GUID_WICPixelFormat32bppRGBA1010102XR; break; - case DXGI_FORMAT_R10G10B10A2_UNORM: pfGuid = GUID_WICPixelFormat32bppRGBA1010102; break; - case DXGI_FORMAT_B5G5R5A1_UNORM: pfGuid = GUID_WICPixelFormat16bppBGRA5551; break; - case DXGI_FORMAT_B5G6R5_UNORM: pfGuid = GUID_WICPixelFormat16bppBGR565; break; - case DXGI_FORMAT_R32_FLOAT: pfGuid = GUID_WICPixelFormat32bppGrayFloat; break; - case DXGI_FORMAT_R16_FLOAT: pfGuid = GUID_WICPixelFormat16bppGrayHalf; break; - case DXGI_FORMAT_R16_UNORM: pfGuid = GUID_WICPixelFormat16bppGray; break; - case DXGI_FORMAT_R8_UNORM: pfGuid = GUID_WICPixelFormat8bppGray; break; - case DXGI_FORMAT_A8_UNORM: pfGuid = GUID_WICPixelFormat8bppAlpha; break; - - case DXGI_FORMAT_R8G8B8A8_UNORM: - pfGuid = GUID_WICPixelFormat32bppRGBA; - break; - - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - pfGuid = GUID_WICPixelFormat32bppRGBA; - sRGB = true; - break; - - case DXGI_FORMAT_B8G8R8A8_UNORM: - pfGuid = GUID_WICPixelFormat32bppBGRA; - break; - - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - pfGuid = GUID_WICPixelFormat32bppBGRA; - sRGB = true; - break; - - case DXGI_FORMAT_B8G8R8X8_UNORM: - pfGuid = GUID_WICPixelFormat32bppBGR; - break; - - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - pfGuid = GUID_WICPixelFormat32bppBGR; - sRGB = true; - break; - - default: - return HRESULT_E_NOT_SUPPORTED; - } - - auto pWIC = GetWIC(); - if (!pWIC) - return E_NOINTERFACE; - - ComPtr stream; - hr = pWIC->CreateStream(stream.GetAddressOf()); - if (FAILED(hr)) - return hr; - - hr = stream->InitializeFromFilename(fileName, GENERIC_WRITE); - if (FAILED(hr)) - return hr; - - auto_delete_file_wic delonfail(stream, fileName); - - ComPtr encoder; - hr = pWIC->CreateEncoder(guidContainerFormat, nullptr, encoder.GetAddressOf()); - if (FAILED(hr)) - return hr; - - hr = encoder->Initialize(stream.Get(), WICBitmapEncoderNoCache); - if (FAILED(hr)) - return hr; - - ComPtr frame; - ComPtr props; - hr = encoder->CreateNewFrame(frame.GetAddressOf(), props.GetAddressOf()); - if (FAILED(hr)) - return hr; - - if (targetFormat && memcmp(&guidContainerFormat, &GUID_ContainerFormatBmp, sizeof(WICPixelFormatGUID)) == 0) - { - // Opt-in to the WIC2 support for writing 32-bit Windows BMP files with an alpha channel - PROPBAG2 option = {}; - option.pstrName = const_cast(L"EnableV5Header32bppBGRA"); - - VARIANT varValue; - varValue.vt = VT_BOOL; - varValue.boolVal = VARIANT_TRUE; - std::ignore = props->Write(1, &option, &varValue); - } - - if (setCustomProps) - { - setCustomProps(props.Get()); - } - - hr = frame->Initialize(props.Get()); - if (FAILED(hr)) - return hr; - - hr = frame->SetSize(static_cast(desc.Width), desc.Height); - if (FAILED(hr)) - return hr; - - hr = frame->SetResolution(72, 72); - if (FAILED(hr)) - return hr; - - // Pick a target format - WICPixelFormatGUID targetGuid = {}; - if (targetFormat) - { - targetGuid = *targetFormat; - } - else - { - // Screenshots don't typically include the alpha channel of the render target - switch (desc.Format) - { - case DXGI_FORMAT_R32G32B32A32_FLOAT: - case DXGI_FORMAT_R16G16B16A16_FLOAT: - targetGuid = GUID_WICPixelFormat96bppRGBFloat; // WIC 2 - break; - - case DXGI_FORMAT_R16G16B16A16_UNORM: targetGuid = GUID_WICPixelFormat48bppBGR; break; - case DXGI_FORMAT_B5G5R5A1_UNORM: targetGuid = GUID_WICPixelFormat16bppBGR555; break; - case DXGI_FORMAT_B5G6R5_UNORM: targetGuid = GUID_WICPixelFormat16bppBGR565; break; - - case DXGI_FORMAT_R32_FLOAT: - case DXGI_FORMAT_R16_FLOAT: - case DXGI_FORMAT_R16_UNORM: - case DXGI_FORMAT_R8_UNORM: - case DXGI_FORMAT_A8_UNORM: - targetGuid = GUID_WICPixelFormat8bppGray; - break; - - default: - targetGuid = GUID_WICPixelFormat24bppBGR; - break; - } - } - - hr = frame->SetPixelFormat(&targetGuid); - if (FAILED(hr)) - return hr; - - if (targetFormat && memcmp(targetFormat, &targetGuid, sizeof(WICPixelFormatGUID)) != 0) - { - // Requested output pixel format is not supported by the WIC codec - return E_FAIL; - } - - // Encode WIC metadata - ComPtr metawriter; - if (SUCCEEDED(frame->GetMetadataQueryWriter(metawriter.GetAddressOf()))) - { - PROPVARIANT value; - PropVariantInit(&value); - - value.vt = VT_LPSTR; - value.pszVal = const_cast("DirectXTK"); - - if (memcmp(&guidContainerFormat, &GUID_ContainerFormatPng, sizeof(GUID)) == 0) - { - // Set Software name - std::ignore = metawriter->SetMetadataByName(L"/tEXt/{str=Software}", &value); - - // Set sRGB chunk - if (sRGB) - { - value.vt = VT_UI1; - value.bVal = 0; - std::ignore = metawriter->SetMetadataByName(L"/sRGB/RenderingIntent", &value); - } - else - { - // add gAMA chunk with gamma 1.0 - value.vt = VT_UI4; - value.uintVal = 100000; // gama value * 100,000 -- i.e. gamma 1.0 - std::ignore = metawriter->SetMetadataByName(L"/gAMA/ImageGamma", &value); - - // remove sRGB chunk which is added by default. - std::ignore = metawriter->RemoveMetadataByName(L"/sRGB/RenderingIntent"); - } - } - else - { - // Set Software name - std::ignore = metawriter->SetMetadataByName(L"System.ApplicationName", &value); - - if (sRGB) - { - // Set EXIF Colorspace of sRGB - value.vt = VT_UI2; - value.uiVal = 1; - std::ignore = metawriter->SetMetadataByName(L"System.Image.ColorSpace", &value); - } - } - } - - const UINT64 imageSize = dstRowPitch * UINT64(desc.Height); - if (imageSize > UINT32_MAX) - return HRESULT_E_ARITHMETIC_OVERFLOW; - - void* pMappedMemory = nullptr; - D3D12_RANGE readRange = { 0, static_cast(imageSize) }; - D3D12_RANGE writeRange = { 0, 0 }; - hr = pStaging->Map(0, &readRange, &pMappedMemory); - if (FAILED(hr)) - return hr; - - if (memcmp(&targetGuid, &pfGuid, sizeof(WICPixelFormatGUID)) != 0) - { - // Conversion required to write - ComPtr source; - hr = pWIC->CreateBitmapFromMemory(static_cast(desc.Width), desc.Height, - pfGuid, - static_cast(dstRowPitch), static_cast(imageSize), - static_cast(pMappedMemory), source.GetAddressOf()); - if (FAILED(hr)) - { - pStaging->Unmap(0, &writeRange); - return hr; - } - - ComPtr FC; - hr = pWIC->CreateFormatConverter(FC.GetAddressOf()); - if (FAILED(hr)) - { - pStaging->Unmap(0, &writeRange); - return hr; - } - - BOOL canConvert = FALSE; - hr = FC->CanConvert(pfGuid, targetGuid, &canConvert); - if (FAILED(hr) || !canConvert) - { - pStaging->Unmap(0, &writeRange); - return E_UNEXPECTED; - } - - hr = FC->Initialize(source.Get(), targetGuid, WICBitmapDitherTypeNone, nullptr, 0, WICBitmapPaletteTypeMedianCut); - if (FAILED(hr)) - { - pStaging->Unmap(0, &writeRange); - return hr; - } - - WICRect rect = { 0, 0, static_cast(desc.Width), static_cast(desc.Height) }; - hr = frame->WriteSource(FC.Get(), &rect); - } - else - { - // No conversion required - hr = frame->WritePixels(desc.Height, static_cast(dstRowPitch), static_cast(imageSize), static_cast(pMappedMemory)); - } - - pStaging->Unmap(0, &writeRange); - - if (FAILED(hr)) - return hr; - - hr = frame->Commit(); - if (FAILED(hr)) - return hr; - - hr = encoder->Commit(); - if (FAILED(hr)) - return hr; - - delonfail.clear(); - - return S_OK; -} -#endif // WIN32 diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/ScreenGrab/ScreenGrab12.h b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/ScreenGrab/ScreenGrab12.h deleted file mode 100644 index c023481..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/ScreenGrab/ScreenGrab12.h +++ /dev/null @@ -1,69 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: ScreenGrab12.h -// -// Function for capturing a 2D texture and saving it to a file (aka a 'screenshot' -// when used on a Direct3D 12 Render Target). -// -// Note these functions are useful as a light-weight runtime screen grabber. For -// full-featured texture capture, DDS writer, and texture processing pipeline, -// see the 'Texconv' sample and the 'DirectXTex' library. -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -// http://go.microsoft.com/fwlink/?LinkID=615561 -//-------------------------------------------------------------------------------------- - -#pragma once - -#ifdef __MINGW32__ -#include -#endif - -#ifndef _WIN32 -#include -#include -#endif - -#if !defined(_WIN32) || defined(USING_DIRECTX_HEADERS) -#include -#include -#else -#include -#pragma comment(lib,"dxguid.lib") -#endif - -#ifdef _WIN32 -#if defined(NTDDI_WIN10_FE) || defined(__MINGW32__) -#include -#else -#include -#endif - -#include -#endif - - -namespace DirectX -{ - HRESULT __cdecl SaveDDSTextureToFile( - _In_ ID3D12CommandQueue* pCommandQueue, - _In_ ID3D12Resource* pSource, - _In_z_ const wchar_t* fileName, - D3D12_RESOURCE_STATES beforeState = D3D12_RESOURCE_STATE_RENDER_TARGET, - D3D12_RESOURCE_STATES afterState = D3D12_RESOURCE_STATE_RENDER_TARGET) noexcept; - -#ifdef _WIN32 - HRESULT __cdecl SaveWICTextureToFile( - _In_ ID3D12CommandQueue* pCommandQ, - _In_ ID3D12Resource* pSource, - REFGUID guidContainerFormat, - _In_z_ const wchar_t* fileName, - D3D12_RESOURCE_STATES beforeState = D3D12_RESOURCE_STATE_RENDER_TARGET, - D3D12_RESOURCE_STATES afterState = D3D12_RESOURCE_STATE_RENDER_TARGET, - _In_opt_ const GUID* targetFormat = nullptr, - _In_opt_ std::function setCustomProps = nullptr, - bool forceSRGB = false); -#endif -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/ScreenGrab/ScreenGrab9.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/ScreenGrab/ScreenGrab9.cpp deleted file mode 100644 index 43077c1..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/ScreenGrab/ScreenGrab9.cpp +++ /dev/null @@ -1,1023 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: ScreenGrab9.cpp -// -// Function for saving 2D surface to a file (aka a 'screenshot' -// when used on a Direct3D 9's GetFrontBufferData). -// -// Note these functions are useful as a light-weight runtime screen grabber. For -// full-featured texture capture, DDS writer, and texture processing pipeline, -// see the 'Texconv' sample and the 'DirectXTex' library. -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -// http://go.microsoft.com/fwlink/?LinkId=248929 -//-------------------------------------------------------------------------------------- - -#include "ScreenGrab9.h" - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#ifdef _MSC_VER -// Off by default warnings -#pragma warning(disable : 4619 4616 4061 4062 4623 4626 5027) -// C4619/4616 #pragma warning warnings -// C4061 enumerator 'x' in switch of enum 'y' is not explicitly handled by a case label -// C4062 enumerator 'x' in switch of enum 'y' is not handled -// C4623 default constructor was implicitly defined as deleted -// C4626 assignment operator was implicitly defined as deleted -// C5027 move assignment operator was implicitly defined as deleted -#endif - -#ifdef __clang__ -#pragma clang diagnostic ignored "-Wcovered-switch-default" -#pragma clang diagnostic ignored "-Wswitch-enum" -#endif - -using Microsoft::WRL::ComPtr; - -//-------------------------------------------------------------------------------------- -// Macros -//-------------------------------------------------------------------------------------- -#ifndef MAKEFOURCC -#define MAKEFOURCC(ch0, ch1, ch2, ch3) \ - ((uint32_t)(uint8_t)(ch0) | ((uint32_t)(uint8_t)(ch1) << 8) | \ - ((uint32_t)(uint8_t)(ch2) << 16) | ((uint32_t)(uint8_t)(ch3) << 24 )) -#endif /* defined(MAKEFOURCC) */ - -//-------------------------------------------------------------------------------------- -// DDS file structure definitions -// -// See DDS.h in the 'Texconv' sample and the 'DirectXTex' library -//-------------------------------------------------------------------------------------- -namespace -{ -#pragma pack(push,1) - -#define DDS_MAGIC 0x20534444 // "DDS " - - struct DDS_PIXELFORMAT - { - uint32_t size; - uint32_t flags; - uint32_t fourCC; - uint32_t RGBBitCount; - uint32_t RBitMask; - uint32_t GBitMask; - uint32_t BBitMask; - uint32_t ABitMask; - }; - -#define DDS_FOURCC 0x00000004 // DDPF_FOURCC -#define DDS_RGB 0x00000040 // DDPF_RGB -#define DDS_RGBA 0x00000041 // DDPF_RGB | DDPF_ALPHAPIXELS -#define DDS_LUMINANCE 0x00020000 // DDPF_LUMINANCE -#define DDS_LUMINANCEA 0x00020001 // DDPF_LUMINANCE | DDPF_ALPHAPIXELS -#define DDS_ALPHA 0x00000002 // DDPF_ALPHA -#define DDS_BUMPDUDV 0x00080000 // DDPF_BUMPDUDV -#define DDS_BUMPLUMINANCE 0x00040000 // DDPF_BUMPLUMINANCE - -#define DDS_HEADER_FLAGS_TEXTURE 0x00001007 // DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT -#define DDS_HEADER_FLAGS_MIPMAP 0x00020000 // DDSD_MIPMAPCOUNT -#define DDS_HEADER_FLAGS_PITCH 0x00000008 // DDSD_PITCH -#define DDS_HEADER_FLAGS_LINEARSIZE 0x00080000 // DDSD_LINEARSIZE - -#define DDS_SURFACE_FLAGS_TEXTURE 0x00001000 // DDSCAPS_TEXTURE - - struct DDS_HEADER - { - uint32_t size; - uint32_t flags; - uint32_t height; - uint32_t width; - uint32_t pitchOrLinearSize; - uint32_t depth; // only if DDS_HEADER_FLAGS_VOLUME is set in flags - uint32_t mipMapCount; - uint32_t reserved1[11]; - DDS_PIXELFORMAT ddspf; - uint32_t caps; - uint32_t caps2; - uint32_t caps3; - uint32_t caps4; - uint32_t reserved2; - }; - -#pragma pack(pop) - - const DDS_PIXELFORMAT DDSPF_DXT1 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','1'), 0, 0, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_DXT2 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','2'), 0, 0, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_DXT3 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','3'), 0, 0, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_DXT4 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','4'), 0, 0, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_DXT5 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('D','X','T','5'), 0, 0, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_R8G8_B8G8 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('R','G','B','G'), 0, 0, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_G8R8_G8B8 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('G','R','G','B'), 0, 0, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_YUY2 = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('Y','U','Y','2'), 0, 0, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_UYVY = - { sizeof(DDS_PIXELFORMAT), DDS_FOURCC, MAKEFOURCC('U','Y','V','Y'), 0, 0, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_A8R8G8B8 = - { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000 }; - - const DDS_PIXELFORMAT DDSPF_X8R8G8B8 = - { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0 }; - - const DDS_PIXELFORMAT DDSPF_A8B8G8R8 = - { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 }; - - const DDS_PIXELFORMAT DDSPF_X8B8G8R8 = - { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0 }; - - const DDS_PIXELFORMAT DDSPF_G16R16 = - { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 32, 0x0000ffff, 0xffff0000, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_R5G6B5 = - { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0xf800, 0x07e0, 0x001f, 0 }; - - const DDS_PIXELFORMAT DDSPF_A1R5G5B5 = - { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x7c00, 0x03e0, 0x001f, 0x8000 }; - - const DDS_PIXELFORMAT DDSPF_X1R5G5B5 = - { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0x7c00, 0x03e0, 0x001f, 0 }; - - const DDS_PIXELFORMAT DDSPF_A4R4G4B4 = - { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x0f00, 0x00f0, 0x000f, 0xf000 }; - - const DDS_PIXELFORMAT DDSPF_X4R4G4B4 = - { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 16, 0x0f00, 0x00f0, 0x000f, 0 }; - - const DDS_PIXELFORMAT DDSPF_R8G8B8 = - { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 24, 0xff0000, 0x00ff00, 0x0000ff, 0 }; - - const DDS_PIXELFORMAT DDSPF_A8R3G3B2 = - { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 16, 0x00e0, 0x001c, 0x0003, 0xff00 }; - - const DDS_PIXELFORMAT DDSPF_R3G3B2 = - { sizeof(DDS_PIXELFORMAT), DDS_RGB, 0, 8, 0xe0, 0x1c, 0x03, 0 }; - - const DDS_PIXELFORMAT DDSPF_A4L4 = - { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCEA, 0, 8, 0x0f, 0, 0, 0xf0 }; - - const DDS_PIXELFORMAT DDSPF_L8 = - { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCE, 0, 8, 0xff, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_L16 = - { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCE, 0, 16, 0xffff, 0, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_A8L8 = - { sizeof(DDS_PIXELFORMAT), DDS_LUMINANCEA, 0, 16, 0x00ff, 0, 0, 0xff00 }; - - const DDS_PIXELFORMAT DDSPF_A8 = - { sizeof(DDS_PIXELFORMAT), DDS_ALPHA, 0, 8, 0, 0, 0, 0xff }; - - const DDS_PIXELFORMAT DDSPF_V8U8 = - { sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 16, 0x00ff, 0xff00, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_Q8W8V8U8 = - { sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000 }; - - const DDS_PIXELFORMAT DDSPF_V16U16 = - { sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 32, 0x0000ffff, 0xffff0000, 0, 0 }; - - const DDS_PIXELFORMAT DDSPF_A2W10V10U10 = - { sizeof(DDS_PIXELFORMAT), DDS_BUMPDUDV, 0, 32, 0x3ff00000, 0x000ffc00, 0x000003ff, 0xc0000000 }; - - const DDS_PIXELFORMAT DDSPF_L6V5U5 = - { sizeof(DDS_PIXELFORMAT), DDS_BUMPLUMINANCE, 0, 16, 0x001f, 0x03e0, 0xfc00, 0 }; - - const DDS_PIXELFORMAT DDSPF_X8L8V8U8 = - { sizeof(DDS_PIXELFORMAT), DDS_BUMPLUMINANCE, 0, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0 }; - - // Note these 10:10:10:2 format RGB masks are reversed to support a long-standing bug in D3DX - const DDS_PIXELFORMAT DDSPF_A2R10G10B10 = - { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x000003ff, 0x000ffc00, 0x3ff00000, 0xc0000000 }; - const DDS_PIXELFORMAT DDSPF_A2B10G10R10 = - { sizeof(DDS_PIXELFORMAT), DDS_RGBA, 0, 32, 0x3ff00000, 0x000ffc00, 0x000003ff, 0xc0000000 }; - - //----------------------------------------------------------------------------- - struct handle_closer { void operator()(HANDLE h) noexcept { if (h) CloseHandle(h); } }; - - using ScopedHandle = std::unique_ptr; - - inline HANDLE safe_handle(HANDLE h) noexcept { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; } - - class auto_delete_file - { - public: - auto_delete_file(HANDLE hFile) noexcept : m_handle(hFile) {} - ~auto_delete_file() - { - if (m_handle) - { - FILE_DISPOSITION_INFO info = {}; - info.DeleteFile = TRUE; - std::ignore = SetFileInformationByHandle(m_handle, FileDispositionInfo, &info, sizeof(info)); - } - } - - auto_delete_file(const auto_delete_file&) = delete; - auto_delete_file& operator=(const auto_delete_file&) = delete; - - auto_delete_file(const auto_delete_file&&) = delete; - auto_delete_file& operator=(const auto_delete_file&&) = delete; - - void clear() noexcept { m_handle = nullptr; } - - private: - HANDLE m_handle; - }; - - class auto_delete_file_wic - { - public: - auto_delete_file_wic(ComPtr& hFile, const wchar_t* szFile) noexcept : m_filename(szFile), m_handle(hFile) {} - ~auto_delete_file_wic() - { - if (m_filename) - { - m_handle.Reset(); - DeleteFileW(m_filename); - } - } - - auto_delete_file_wic(const auto_delete_file_wic&) = delete; - auto_delete_file_wic& operator=(const auto_delete_file_wic&) = delete; - - auto_delete_file_wic(const auto_delete_file_wic&&) = delete; - auto_delete_file_wic& operator=(const auto_delete_file_wic&&) = delete; - - void clear() noexcept { m_filename = nullptr; } - - private: - const wchar_t* m_filename; - ComPtr& m_handle; - }; - - - //-------------------------------------------------------------------------------------- - // Return the BPP for a particular format - //-------------------------------------------------------------------------------------- - size_t BitsPerPixel(_In_ D3DFORMAT fmt) noexcept - { - switch (static_cast(fmt)) - { - case D3DFMT_A32B32G32R32F: - return 128; - - case D3DFMT_A16B16G16R16: - case D3DFMT_Q16W16V16U16: - case D3DFMT_A16B16G16R16F: - case D3DFMT_G32R32F: - return 64; - - case D3DFMT_A8R8G8B8: - case D3DFMT_X8R8G8B8: - case D3DFMT_A2B10G10R10: - case D3DFMT_A8B8G8R8: - case D3DFMT_X8B8G8R8: - case D3DFMT_G16R16: - case D3DFMT_A2R10G10B10: - case D3DFMT_Q8W8V8U8: - case D3DFMT_V16U16: - case D3DFMT_X8L8V8U8: - case D3DFMT_A2W10V10U10: - case D3DFMT_D32: - case D3DFMT_D24S8: - case D3DFMT_D24X8: - case D3DFMT_D24X4S4: - case D3DFMT_D32F_LOCKABLE: - case D3DFMT_D24FS8: - case D3DFMT_INDEX32: - case D3DFMT_G16R16F: - case D3DFMT_R32F: - #if !defined(D3D_DISABLE_9EX) - case D3DFMT_D32_LOCKABLE: - #endif - return 32; - - case D3DFMT_R8G8B8: - return 24; - - case D3DFMT_A4R4G4B4: - case D3DFMT_X4R4G4B4: - case D3DFMT_R5G6B5: - case D3DFMT_L16: - case D3DFMT_A8L8: - case D3DFMT_X1R5G5B5: - case D3DFMT_A1R5G5B5: - case D3DFMT_A8R3G3B2: - case D3DFMT_V8U8: - case D3DFMT_CxV8U8: - case D3DFMT_L6V5U5: - case D3DFMT_G8R8_G8B8: - case D3DFMT_R8G8_B8G8: - case D3DFMT_D16_LOCKABLE: - case D3DFMT_D15S1: - case D3DFMT_D16: - case D3DFMT_INDEX16: - case D3DFMT_R16F: - case D3DFMT_YUY2: - // From DX docs, reference/d3d/enums/d3dformat.asp - // (note how it says that D3DFMT_R8G8_B8G8 is "A 16-bit packed RGB format analogous to UYVY (U0Y0, V0Y1, U2Y2, and so on)") - case D3DFMT_UYVY: - return 16; - - case D3DFMT_R3G3B2: - case D3DFMT_A8: - case D3DFMT_A8P8: - case D3DFMT_P8: - case D3DFMT_L8: - case D3DFMT_A4L4: - #if !defined(D3D_DISABLE_9EX) - case D3DFMT_S8_LOCKABLE: - #endif - return 8; - - case D3DFMT_DXT1: - return 4; - - case D3DFMT_DXT2: - case D3DFMT_DXT3: - case D3DFMT_DXT4: - case D3DFMT_DXT5: - // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directshow/htm/directxvideoaccelerationdxvavideosubtypes.asp - case MAKEFOURCC('A', 'I', '4', '4'): - case MAKEFOURCC('I', 'A', '4', '4'): - return 8; - - case MAKEFOURCC('Y', 'V', '1', '2'): - return 12; - - #if !defined(D3D_DISABLE_9EX) - case D3DFMT_A1: - return 1; - #endif - - default: - return 0; - } - } - - - //-------------------------------------------------------------------------------------- - // Determines if the format is block compressed - //-------------------------------------------------------------------------------------- - bool IsCompressed(_In_ D3DFORMAT fmt) noexcept - { - switch (fmt) - { - case D3DFMT_DXT1: - case D3DFMT_DXT2: - case D3DFMT_DXT3: - case D3DFMT_DXT4: - case D3DFMT_DXT5: - return true; - - default: - return false; - } - } - - - //-------------------------------------------------------------------------------------- - // Get surface information for a particular format - //-------------------------------------------------------------------------------------- - HRESULT GetSurfaceInfo( - _In_ size_t width, - _In_ size_t height, - _In_ D3DFORMAT fmt, - size_t* outNumBytes, - _Out_opt_ size_t* outRowBytes, - _Out_opt_ size_t* outNumRows) noexcept - { - uint64_t numBytes = 0; - uint64_t rowBytes = 0; - uint64_t numRows = 0; - - bool bc = false; - bool packed = false; - size_t bpe = 0; - switch (static_cast(fmt)) - { - case D3DFMT_DXT1: - bc = true; - bpe = 8; - break; - - case D3DFMT_DXT2: - case D3DFMT_DXT3: - case D3DFMT_DXT4: - case D3DFMT_DXT5: - bc = true; - bpe = 16; - break; - - case D3DFMT_R8G8_B8G8: - case D3DFMT_G8R8_G8B8: - case D3DFMT_UYVY: - case D3DFMT_YUY2: - packed = true; - bpe = 4; - break; - - default: - break; - } - - if (bc) - { - uint64_t numBlocksWide = 0; - if (width > 0) - { - numBlocksWide = std::max(1u, (uint64_t(width) + 3u) / 4u); - } - uint64_t numBlocksHigh = 0; - if (height > 0) - { - numBlocksHigh = std::max(1u, (uint64_t(height) + 3u) / 4u); - } - rowBytes = numBlocksWide * bpe; - numRows = numBlocksHigh; - numBytes = rowBytes * numBlocksHigh; - } - else if (packed) - { - rowBytes = ((uint64_t(width) + 1u) >> 1) * bpe; - numRows = uint64_t(height); - numBytes = rowBytes * height; - } - else - { - const size_t bpp = BitsPerPixel(fmt); - if (!bpp) - return E_INVALIDARG; - - rowBytes = (uint64_t(width) * bpp + 7u) / 8u; // round up to nearest byte - numRows = uint64_t(height); - numBytes = rowBytes * height; - } - - #if defined(_M_IX86) || defined(_M_ARM) || defined(_M_HYBRID_X86_ARM64) - static_assert(sizeof(size_t) == 4, "Not a 32-bit platform!"); - if (numBytes > UINT32_MAX || rowBytes > UINT32_MAX || numRows > UINT32_MAX) - return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); - #else - static_assert(sizeof(size_t) == 8, "Not a 64-bit platform!"); - #endif - - if (outNumBytes) - { - *outNumBytes = static_cast(numBytes); - } - if (outRowBytes) - { - *outRowBytes = static_cast(rowBytes); - } - if (outNumRows) - { - *outNumRows = static_cast(numRows); - } - - return S_OK; - } - - - //-------------------------------------------------------------------------------------- - bool g_WIC2 = false; - - BOOL WINAPI InitializeWICFactory(PINIT_ONCE, PVOID, PVOID* ifactory) noexcept - { - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE) - HRESULT hr = CoCreateInstance( - CLSID_WICImagingFactory2, - nullptr, - CLSCTX_INPROC_SERVER, - __uuidof(IWICImagingFactory2), - ifactory - ); - - if (SUCCEEDED(hr)) - { - // WIC2 is available on Windows 10, Windows 8.x, and Windows 7 SP1 with KB 2670838 installed - g_WIC2 = true; - return TRUE; - } - else - { - hr = CoCreateInstance( - CLSID_WICImagingFactory1, - nullptr, - CLSCTX_INPROC_SERVER, - __uuidof(IWICImagingFactory), - ifactory - ); - return SUCCEEDED(hr) ? TRUE : FALSE; - } - #else - return SUCCEEDED(CoCreateInstance( - CLSID_WICImagingFactory, - nullptr, - CLSCTX_INPROC_SERVER, - __uuidof(IWICImagingFactory), - ifactory)) ? TRUE : FALSE; - #endif - } - - IWICImagingFactory* GetWIC() - { - static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT; - - IWICImagingFactory* factory = nullptr; - if (!InitOnceExecuteOnce(&s_initOnce, - InitializeWICFactory, - nullptr, - reinterpret_cast(&factory))) - { - return nullptr; - } - - return factory; - } -} // anonymous namespace - - -//-------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::SaveDDSTextureToFile( - LPDIRECT3DSURFACE9 pSource, - const wchar_t* fileName) noexcept -{ - if (!pSource || !fileName) - return E_INVALIDARG; - - D3DSURFACE_DESC desc = {}; - HRESULT hr = pSource->GetDesc(&desc); - if (FAILED(hr)) - return hr; - - if (desc.Type != D3DRTYPE_SURFACE && desc.Type != D3DRTYPE_TEXTURE) - { - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - - if (desc.MultiSampleType != D3DMULTISAMPLE_NONE) - { - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - - // Create file -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(fileName, - GENERIC_WRITE | DELETE, 0, CREATE_ALWAYS, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(fileName, - GENERIC_WRITE | DELETE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr))); -#endif - if (!hFile) - return HRESULT_FROM_WIN32(GetLastError()); - - auto_delete_file delonfail(hFile.get()); - - // Setup header - constexpr size_t MAX_HEADER_SIZE = sizeof(uint32_t) + sizeof(DDS_HEADER); - uint8_t fileHeader[MAX_HEADER_SIZE] = {}; - - *reinterpret_cast(&fileHeader[0]) = DDS_MAGIC; - - auto header = reinterpret_cast(&fileHeader[0] + sizeof(uint32_t)); - constexpr size_t headerSize = sizeof(uint32_t) + sizeof(DDS_HEADER); - header->size = sizeof(DDS_HEADER); - header->flags = DDS_HEADER_FLAGS_TEXTURE | DDS_HEADER_FLAGS_MIPMAP; - header->height = desc.Height; - header->width = desc.Width; - header->mipMapCount = 1; - header->caps = DDS_SURFACE_FLAGS_TEXTURE; - - switch (desc.Format) - { - case D3DFMT_R8G8B8: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_R8G8B8, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_A8R8G8B8: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_A8R8G8B8, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_X8R8G8B8: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_X8R8G8B8, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_R5G6B5: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_R5G6B5, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_X1R5G5B5: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_X1R5G5B5, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_A1R5G5B5: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_A1R5G5B5, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_A4R4G4B4: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_A4R4G4B4, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_R3G3B2: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_R3G3B2, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_A8: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_A8, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_A8R3G3B2: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_A8R3G3B2, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_X4R4G4B4: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_X4R4G4B4, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_A2B10G10R10: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_A2B10G10R10, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_A8B8G8R8: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_A8B8G8R8, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_X8B8G8R8: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_X8B8G8R8, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_G16R16: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_G16R16, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_A2R10G10B10: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_A2R10G10B10, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_L8: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_L8, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_A8L8: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_A8L8, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_A4L4: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_A4L4, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_V8U8: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_V8U8, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_L6V5U5: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_L6V5U5, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_X8L8V8U8: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_X8L8V8U8, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_Q8W8V8U8: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_Q8W8V8U8, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_V16U16: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_V16U16, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_A2W10V10U10: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_A2W10V10U10, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_L16: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_L16, sizeof(DDS_PIXELFORMAT)); break; - - // FourCC formats - case D3DFMT_UYVY: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_UYVY, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_R8G8_B8G8: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_R8G8_B8G8, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_YUY2: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_YUY2, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_G8R8_G8B8: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_G8R8_G8B8, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_DXT1: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_DXT1, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_DXT2: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_DXT2, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_DXT3: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_DXT3, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_DXT4: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_DXT4, sizeof(DDS_PIXELFORMAT)); break; - case D3DFMT_DXT5: memcpy_s(&header->ddspf, sizeof(header->ddspf), &DDSPF_DXT5, sizeof(DDS_PIXELFORMAT)); break; - - // Legacy D3DX formats using D3DFMT enum value as FourCC - case D3DFMT_A16B16G16R16: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 36; break; - case D3DFMT_Q16W16V16U16: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 110; break; - case D3DFMT_R16F: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 111; break; - case D3DFMT_G16R16F: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 112; break; - case D3DFMT_A16B16G16R16F: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 113; break; - case D3DFMT_R32F: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 114; break; - case D3DFMT_G32R32F: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 115; break; - case D3DFMT_A32B32G32R32F: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 116; break; - case D3DFMT_CxV8U8: header->ddspf.size = sizeof(DDS_PIXELFORMAT); header->ddspf.flags = DDS_FOURCC; header->ddspf.fourCC = 117; break; - - default: - // No support for paletted formats D3DFMT_P8, D3DFMT_A8P8 - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - - size_t rowPitch, slicePitch, rowCount; - hr = GetSurfaceInfo(desc.Width, desc.Height, desc.Format, &slicePitch, &rowPitch, &rowCount); - if (FAILED(hr)) - return hr; - - if (rowPitch > UINT32_MAX || slicePitch > UINT32_MAX) - return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); - - if (IsCompressed(desc.Format)) - { - header->flags |= DDS_HEADER_FLAGS_LINEARSIZE; - header->pitchOrLinearSize = static_cast(slicePitch); - } - else - { - header->flags |= DDS_HEADER_FLAGS_PITCH; - header->pitchOrLinearSize = static_cast(rowPitch); - } - - // Setup pixels - std::unique_ptr pixels(new (std::nothrow) uint8_t[slicePitch]); - if (!pixels) - return E_OUTOFMEMORY; - - D3DLOCKED_RECT lockedRect = {}; - hr = pSource->LockRect(&lockedRect, nullptr, D3DLOCK_READONLY); - if (FAILED(hr)) - return hr; - - auto sptr = static_cast(lockedRect.pBits); - if (!sptr) - { - pSource->UnlockRect(); - return E_POINTER; - } - - uint8_t* dptr = pixels.get(); - - const size_t msize = std::min(rowPitch, static_cast(lockedRect.Pitch)); - for (size_t h = 0; h < rowCount; ++h) - { - memcpy_s(dptr, rowPitch, sptr, msize); - sptr += lockedRect.Pitch; - dptr += rowPitch; - } - - pSource->UnlockRect(); - - // Write header & pixels - DWORD bytesWritten; - if (!WriteFile(hFile.get(), fileHeader, static_cast(headerSize), &bytesWritten, nullptr)) - return HRESULT_FROM_WIN32(GetLastError()); - - if (bytesWritten != headerSize) - return E_FAIL; - - if (!WriteFile(hFile.get(), pixels.get(), static_cast(slicePitch), &bytesWritten, nullptr)) - return HRESULT_FROM_WIN32(GetLastError()); - - if (bytesWritten != slicePitch) - return E_FAIL; - - delonfail.clear(); - - return S_OK; -} - - -//-------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::SaveWICTextureToFile( - LPDIRECT3DSURFACE9 pSource, - REFGUID guidContainerFormat, - const wchar_t* fileName, - const GUID* targetFormat, - std::function setCustomProps) -{ - if (!pSource || !fileName) - return E_INVALIDARG; - - D3DSURFACE_DESC desc = {}; - HRESULT hr = pSource->GetDesc(&desc); - if (FAILED(hr)) - return hr; - - if (desc.Type != D3DRTYPE_SURFACE && desc.Type != D3DRTYPE_TEXTURE) - { - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - - if (desc.MultiSampleType != D3DMULTISAMPLE_NONE) - { - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - - auto pWIC = GetWIC(); - if (!pWIC) - return E_NOINTERFACE; - - // Determine source format's WIC equivalent - WICPixelFormatGUID pfGuid = {}; - switch (desc.Format) - { - case D3DFMT_R8G8B8: pfGuid = GUID_WICPixelFormat24bppBGR; break; - case D3DFMT_A8R8G8B8: pfGuid = GUID_WICPixelFormat32bppBGRA; break; - case D3DFMT_X8R8G8B8: pfGuid = GUID_WICPixelFormat32bppBGR; break; - case D3DFMT_R5G6B5: pfGuid = GUID_WICPixelFormat16bppBGR565; break; - case D3DFMT_X1R5G5B5: pfGuid = GUID_WICPixelFormat16bppBGR555; break; - case D3DFMT_A1R5G5B5: pfGuid = GUID_WICPixelFormat16bppBGRA5551; break; - case D3DFMT_A8: pfGuid = GUID_WICPixelFormat8bppAlpha; break; - case D3DFMT_A2B10G10R10: pfGuid = GUID_WICPixelFormat32bppRGBA1010102; break; - case D3DFMT_A8B8G8R8: pfGuid = GUID_WICPixelFormat32bppRGBA; break; - case D3DFMT_A16B16G16R16: pfGuid = GUID_WICPixelFormat64bppRGBA; break; - case D3DFMT_L8: pfGuid = GUID_WICPixelFormat8bppGray; break; - case D3DFMT_L16: pfGuid = GUID_WICPixelFormat16bppGray; break; - case D3DFMT_R16F: pfGuid = GUID_WICPixelFormat16bppGrayHalf; break; - case D3DFMT_A16B16G16R16F: pfGuid = GUID_WICPixelFormat64bppRGBAHalf; break; - case D3DFMT_R32F: pfGuid = GUID_WICPixelFormat32bppGrayFloat; break; - case D3DFMT_A32B32G32R32F: pfGuid = GUID_WICPixelFormat128bppRGBAFloat; break; - - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE) - case D3DFMT_X8B8G8R8: - if (g_WIC2) - pfGuid = GUID_WICPixelFormat32bppRGB; - else - HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - break; - #endif - - default: - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - - ComPtr stream; - hr = pWIC->CreateStream(stream.GetAddressOf()); - if (FAILED(hr)) - return hr; - - hr = stream->InitializeFromFilename(fileName, GENERIC_WRITE); - if (FAILED(hr)) - return hr; - - auto_delete_file_wic delonfail(stream, fileName); - - ComPtr encoder; - hr = pWIC->CreateEncoder(guidContainerFormat, nullptr, encoder.GetAddressOf()); - if (FAILED(hr)) - return hr; - - hr = encoder->Initialize(stream.Get(), WICBitmapEncoderNoCache); - if (FAILED(hr)) - return hr; - - ComPtr frame; - ComPtr props; - hr = encoder->CreateNewFrame(frame.GetAddressOf(), props.GetAddressOf()); - if (FAILED(hr)) - return hr; - - if (targetFormat && memcmp(&guidContainerFormat, &GUID_ContainerFormatBmp, sizeof(WICPixelFormatGUID)) == 0 && g_WIC2) - { - // Opt-in to the WIC2 support for writing 32-bit Windows BMP files with an alpha channel - PROPBAG2 option = {}; - option.pstrName = const_cast(L"EnableV5Header32bppBGRA"); - - VARIANT varValue; - varValue.vt = VT_BOOL; - varValue.boolVal = VARIANT_TRUE; - std::ignore = props->Write(1, &option, &varValue); - } - - if (setCustomProps) - { - setCustomProps(props.Get()); - } - - hr = frame->Initialize(props.Get()); - if (FAILED(hr)) - return hr; - - hr = frame->SetSize(desc.Width, desc.Height); - if (FAILED(hr)) - return hr; - - hr = frame->SetResolution(72, 72); - if (FAILED(hr)) - return hr; - - // Pick a target format - WICPixelFormatGUID targetGuid = {}; - if (targetFormat) - { - targetGuid = *targetFormat; - } - else - { - // Screenshots don't typically include the alpha channel of the render target - switch (desc.Format) - { - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE) - case D3DFMT_A32B32G32R32F: - case D3DFMT_A16B16G16R16F: - if (g_WIC2) - { - targetGuid = GUID_WICPixelFormat96bppRGBFloat; - } - else - { - targetGuid = GUID_WICPixelFormat24bppBGR; - } - break; - #endif - - case D3DFMT_A16B16G16R16: targetGuid = GUID_WICPixelFormat48bppBGR; break; - case D3DFMT_R5G6B5: targetGuid = GUID_WICPixelFormat16bppBGR565; break; - - case D3DFMT_A1R5G5B5: - case D3DFMT_X1R5G5B5: - targetGuid = GUID_WICPixelFormat16bppBGR555; - break; - - case D3DFMT_L16: - targetGuid = GUID_WICPixelFormat16bppGray; - break; - - case D3DFMT_R32F: - case D3DFMT_R16F: - case D3DFMT_L8: - targetGuid = GUID_WICPixelFormat8bppGray; - break; - - default: - targetGuid = GUID_WICPixelFormat24bppBGR; - break; - } - } - - hr = frame->SetPixelFormat(&targetGuid); - if (FAILED(hr)) - return hr; - - if (targetFormat && memcmp(targetFormat, &targetGuid, sizeof(WICPixelFormatGUID)) != 0) - { - // Requested output pixel format is not supported by the WIC codec - return E_FAIL; - } - - // Encode WIC metadata - ComPtr metawriter; - if (SUCCEEDED(frame->GetMetadataQueryWriter(metawriter.GetAddressOf()))) - { - PROPVARIANT value; - PropVariantInit(&value); - - value.vt = VT_LPSTR; - value.pszVal = const_cast("DirectXTK"); - - if (memcmp(&guidContainerFormat, &GUID_ContainerFormatPng, sizeof(GUID)) == 0) - { - // Set Software name - std::ignore = metawriter->SetMetadataByName(L"/tEXt/{str=Software}", &value); - } - else - { - // Set Software name - std::ignore = metawriter->SetMetadataByName(L"System.ApplicationName", &value); - } - } - - D3DLOCKED_RECT lockedRect = {}; - hr = pSource->LockRect(&lockedRect, nullptr, D3DLOCK_READONLY); - if (FAILED(hr)) - return hr; - - const uint64_t imageSize = uint64_t(lockedRect.Pitch) * uint64_t(desc.Height); - if (imageSize > UINT32_MAX) - { - pSource->UnlockRect(); - return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); - } - - if (memcmp(&targetGuid, &pfGuid, sizeof(WICPixelFormatGUID)) != 0) - { - // Conversion required to write - ComPtr source; - hr = pWIC->CreateBitmapFromMemory(desc.Width, desc.Height, - pfGuid, - static_cast(lockedRect.Pitch), static_cast(imageSize), - static_cast(lockedRect.pBits), source.GetAddressOf()); - if (FAILED(hr)) - { - pSource->UnlockRect(); - return hr; - } - - ComPtr FC; - hr = pWIC->CreateFormatConverter(FC.GetAddressOf()); - if (FAILED(hr)) - { - pSource->UnlockRect(); - return hr; - } - - BOOL canConvert = FALSE; - hr = FC->CanConvert(pfGuid, targetGuid, &canConvert); - if (FAILED(hr) || !canConvert) - { - pSource->UnlockRect(); - return E_UNEXPECTED; - } - - hr = FC->Initialize(source.Get(), targetGuid, WICBitmapDitherTypeNone, nullptr, 0, WICBitmapPaletteTypeMedianCut); - if (FAILED(hr)) - { - pSource->UnlockRect(); - return hr; - } - - WICRect rect = { 0, 0, static_cast(desc.Width), static_cast(desc.Height) }; - hr = frame->WriteSource(FC.Get(), &rect); - } - else - { - // No conversion required - hr = frame->WritePixels(desc.Height, - static_cast(lockedRect.Pitch), static_cast(imageSize), - static_cast(lockedRect.pBits)); - } - - pSource->UnlockRect(); - - if (FAILED(hr)) - return hr; - - hr = frame->Commit(); - if (FAILED(hr)) - return hr; - - hr = encoder->Commit(); - if (FAILED(hr)) - return hr; - - delonfail.clear(); - - return S_OK; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/ScreenGrab/ScreenGrab9.h b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/ScreenGrab/ScreenGrab9.h deleted file mode 100644 index f2f5563..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/ScreenGrab/ScreenGrab9.h +++ /dev/null @@ -1,47 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: ScreenGrab9.h -// -// Function for saving 2D surface to a file (aka a 'screenshot' -// when used on a Direct3D 9's GetFrontBufferData). -// -// Note these functions are useful as a light-weight runtime screen grabber. For -// full-featured texture capture, DDS writer, and texture processing pipeline, -// see the 'Texconv' sample and the 'DirectXTex' library. -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -// http://go.microsoft.com/fwlink/?LinkId=248929 -//-------------------------------------------------------------------------------------- - -#pragma once - -#ifndef DIRECT3D_VERSION -#define DIRECT3D_VERSION 0x900 -#endif - -#include - -#if defined(NTDDI_WIN10_FE) || defined(__MINGW32__) -#include -#else -#include -#endif - -#include - - -namespace DirectX -{ - HRESULT __cdecl SaveDDSTextureToFile( - _In_ LPDIRECT3DSURFACE9 pSource, - _In_z_ const wchar_t* fileName) noexcept; - - HRESULT __cdecl SaveWICTextureToFile( - _In_ LPDIRECT3DSURFACE9 pSource, - _In_ REFGUID guidContainerFormat, - _In_z_ const wchar_t* fileName, - _In_opt_ const GUID* targetFormat = nullptr, - _In_opt_ std::function setCustomProps = nullptr); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texassemble/AnimatedGif.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texassemble/AnimatedGif.cpp deleted file mode 100644 index 0829892..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texassemble/AnimatedGif.cpp +++ /dev/null @@ -1,411 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: AnimatedGif.cpp -// -// Code for converting an animated GIF to a series of texture frames. -// -// References: -// https://github.com/microsoft/Windows-classic-samples/tree/main/Samples/Win7Samples/multimedia/wic/wicanimatedgif -// http://www.imagemagick.org/Usage/anim_basics/#dispose -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//-------------------------------------------------------------------------------------- - -#pragma warning(push) -#pragma warning(disable : 4005) -#define WIN32_LEAN_AND_MEAN -#define NOMINMAX -#define NODRAWTEXT -#define NOGDI -#define NOMCX -#define NOSERVICE -#define NOHELP -#pragma warning(pop) - -#include -#include -#include -#include -#include -#include - -#include - -#include - -#pragma warning(disable : 4619 4616 26812) - -#include "DirectXTex.h" - -using namespace DirectX; -using Microsoft::WRL::ComPtr; - -namespace -{ - enum - { - DM_UNDEFINED = 0, - DM_NONE = 1, - DM_BACKGROUND = 2, - DM_PREVIOUS = 3 - }; - - - void FillRectangle(const Image& img, const RECT& destRect, uint32_t color) - { - RECT clipped = - { - (destRect.left < 0) ? 0 : destRect.left, - (destRect.top < 0) ? 0 : destRect.top, - (destRect.right > static_cast(img.width)) ? static_cast(img.width) : destRect.right, - (destRect.bottom > static_cast(img.height)) ? static_cast(img.height) : destRect.bottom - }; - - auto ptr = reinterpret_cast(img.pixels + size_t(clipped.top) * img.rowPitch + size_t(clipped.left) * sizeof(uint32_t)); - - for (long y = clipped.top; y < clipped.bottom; ++y) - { - auto pixelPtr = reinterpret_cast(ptr); - for (long x = clipped.left; x < clipped.right; ++x) - { - *pixelPtr++ = color; - } - - ptr += img.rowPitch; - } - } - - - void BlendRectangle(const Image& composed, const Image& raw, const RECT& destRect, uint32_t transparent) - { - RECT clipped = - { - (destRect.left < 0) ? 0 : destRect.left, - (destRect.top < 0) ? 0 : destRect.top, - (destRect.right > static_cast(composed.width)) ? static_cast(composed.width) : destRect.right, - (destRect.bottom > static_cast(composed.height)) ? static_cast(composed.height) : destRect.bottom - }; - - auto rawPtr = reinterpret_cast(raw.pixels); - auto composedPtr = reinterpret_cast( - composed.pixels - + size_t(clipped.top) * composed.rowPitch - + size_t(clipped.left) * sizeof(uint32_t)); - - for (long y = clipped.top; y < clipped.bottom; ++y) - { - auto srcPtr = reinterpret_cast(rawPtr); - auto destPtr = reinterpret_cast(composedPtr); - for (long x = clipped.left; x < clipped.right; ++x, ++srcPtr, ++destPtr) - { - if (transparent == *srcPtr) - continue; - - *destPtr = *srcPtr; - } - - rawPtr += raw.rowPitch; - composedPtr += composed.rowPitch; - } - } -} - -HRESULT LoadAnimatedGif(const wchar_t* szFile, std::vector>& loadedImages, bool usebgcolor) -{ - bool iswic2; - auto pWIC = GetWICFactory(iswic2); - if (!pWIC) - return E_NOINTERFACE; - - ComPtr decoder; - HRESULT hr = pWIC->CreateDecoderFromFilename(szFile, nullptr, GENERIC_READ, WICDecodeMetadataCacheOnDemand, decoder.GetAddressOf()); - if (FAILED(hr)) - return hr; - - { - GUID containerFormat; - hr = decoder->GetContainerFormat(&containerFormat); - if (FAILED(hr)) - return hr; - - if (memcmp(&containerFormat, &GUID_ContainerFormatGif, sizeof(GUID)) != 0) - { - // This function only works for GIF - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - } - - ComPtr metareader; - hr = decoder->GetMetadataQueryReader(metareader.GetAddressOf()); - if (FAILED(hr)) - return hr; - - PROPVARIANT propValue; - PropVariantInit(&propValue); - - // Get palette - WICColor rgbColors[256] = {}; - UINT actualColors = 0; - { - ComPtr palette; - hr = pWIC->CreatePalette(palette.GetAddressOf()); - if (FAILED(hr)) - return hr; - - hr = decoder->CopyPalette(palette.Get()); - if (FAILED(hr)) - return hr; - - hr = palette->GetColors(static_cast(std::size(rgbColors)), rgbColors, &actualColors); - if (FAILED(hr)) - return hr; - } - - // Get background color - UINT bgColor = 0; - if (usebgcolor) - { - // Most browsers just ignore the background color metadata and always use transparency - hr = metareader->GetMetadataByName(L"/logscrdesc/GlobalColorTableFlag", &propValue); - if (SUCCEEDED(hr)) - { - const bool hasTable = (propValue.vt == VT_BOOL && propValue.boolVal); - PropVariantClear(&propValue); - - if (hasTable) - { - hr = metareader->GetMetadataByName(L"/logscrdesc/BackgroundColorIndex", &propValue); - if (SUCCEEDED(hr)) - { - if (propValue.vt == VT_UI1) - { - const uint8_t index = propValue.bVal; - - if (index < actualColors) - { - bgColor = rgbColors[index]; - } - } - PropVariantClear(&propValue); - } - } - } - } - - // Get global frame size - UINT width = 0; - UINT height = 0; - - hr = metareader->GetMetadataByName(L"/logscrdesc/Width", &propValue); - if (FAILED(hr)) - return hr; - - if (propValue.vt != VT_UI2) - return E_FAIL; - - width = propValue.uiVal; - PropVariantClear(&propValue); - - hr = metareader->GetMetadataByName(L"/logscrdesc/Height", &propValue); - if (FAILED(hr)) - return hr; - - if (propValue.vt != VT_UI2) - return E_FAIL; - - height = propValue.uiVal; - PropVariantClear(&propValue); - - UINT fcount; - hr = decoder->GetFrameCount(&fcount); - if (FAILED(hr)) - return hr; - - UINT disposal = DM_UNDEFINED; - RECT rct = {}; - - UINT previousFrame = 0; - for (UINT iframe = 0; iframe < fcount; ++iframe) - { - int transparentIndex = -1; - - std::unique_ptr frameImage(new (std::nothrow) ScratchImage); - if (!frameImage) - return E_OUTOFMEMORY; - - if (disposal == DM_PREVIOUS) - { - hr = frameImage->InitializeFromImage(*loadedImages[previousFrame]->GetImage(0, 0, 0)); - } - else if (iframe > 0) - { - hr = frameImage->InitializeFromImage(*loadedImages[iframe - 1]->GetImage(0, 0, 0)); - } - else - { - hr = frameImage->Initialize2D(DXGI_FORMAT_B8G8R8A8_UNORM, width, height, 1, 1); - } - if (FAILED(hr)) - return hr; - - auto composedImage = frameImage->GetImage(0, 0, 0); - - if (!iframe) - { - RECT fullRct = { 0, 0, static_cast(width), static_cast(height) }; - FillRectangle(*composedImage, fullRct, bgColor); - } - else if (disposal == DM_BACKGROUND) - { - FillRectangle(*composedImage, rct, bgColor); - } - - ComPtr frame; - hr = decoder->GetFrame(iframe, frame.GetAddressOf()); - if (FAILED(hr)) - return hr; - - WICPixelFormatGUID pixelFormat; - hr = frame->GetPixelFormat(&pixelFormat); - if (FAILED(hr)) - return hr; - - if (memcmp(&pixelFormat, &GUID_WICPixelFormat8bppIndexed, sizeof(GUID)) != 0) - { - // GIF is always loaded as this format - return E_UNEXPECTED; - } - - ComPtr frameMeta; - hr = frame->GetMetadataQueryReader(frameMeta.GetAddressOf()); - if (SUCCEEDED(hr)) - { - hr = frameMeta->GetMetadataByName(L"/imgdesc/Left", &propValue); - if (SUCCEEDED(hr)) - { - hr = (propValue.vt == VT_UI2 ? S_OK : E_FAIL); - if (SUCCEEDED(hr)) - { - rct.left = static_cast(propValue.uiVal); - } - PropVariantClear(&propValue); - } - - hr = frameMeta->GetMetadataByName(L"/imgdesc/Top", &propValue); - if (SUCCEEDED(hr)) - { - hr = (propValue.vt == VT_UI2 ? S_OK : E_FAIL); - if (SUCCEEDED(hr)) - { - rct.top = static_cast(propValue.uiVal); - } - PropVariantClear(&propValue); - } - - hr = frameMeta->GetMetadataByName(L"/imgdesc/Width", &propValue); - if (SUCCEEDED(hr)) - { - hr = (propValue.vt == VT_UI2 ? S_OK : E_FAIL); - if (SUCCEEDED(hr)) - { - rct.right = static_cast(propValue.uiVal) + rct.left; - } - PropVariantClear(&propValue); - } - - hr = frameMeta->GetMetadataByName(L"/imgdesc/Height", &propValue); - if (SUCCEEDED(hr)) - { - hr = (propValue.vt == VT_UI2 ? S_OK : E_FAIL); - if (SUCCEEDED(hr)) - { - rct.bottom = static_cast(propValue.uiVal) + rct.top; - } - PropVariantClear(&propValue); - } - - disposal = DM_UNDEFINED; - hr = frameMeta->GetMetadataByName(L"/grctlext/Disposal", &propValue); - if (SUCCEEDED(hr)) - { - hr = (propValue.vt == VT_UI1 ? S_OK : E_FAIL); - if (SUCCEEDED(hr)) - { - disposal = propValue.bVal; - } - PropVariantClear(&propValue); - } - - hr = frameMeta->GetMetadataByName(L"/grctlext/TransparencyFlag", &propValue); - if (SUCCEEDED(hr)) - { - hr = (propValue.vt == VT_BOOL ? S_OK : E_FAIL); - if (SUCCEEDED(hr) && propValue.boolVal) - { - PropVariantClear(&propValue); - hr = frameMeta->GetMetadataByName(L"/grctlext/TransparentColorIndex", &propValue); - if (SUCCEEDED(hr)) - { - hr = (propValue.vt == VT_UI1 ? S_OK : E_FAIL); - if (SUCCEEDED(hr) && propValue.uiVal < actualColors) - { - transparentIndex = static_cast(propValue.uiVal); - } - } - } - PropVariantClear(&propValue); - } - - } - - UINT w, h; - hr = frame->GetSize(&w, &h); - if (FAILED(hr)) - return hr; - - ScratchImage rawFrame; - hr = rawFrame.Initialize2D(DXGI_FORMAT_B8G8R8A8_UNORM, w, h, 1, 1); - if (FAILED(hr)) - return hr; - - ComPtr FC; - hr = pWIC->CreateFormatConverter(FC.GetAddressOf()); - if (FAILED(hr)) - return hr; - - hr = FC->Initialize(frame.Get(), GUID_WICPixelFormat32bppBGRA, WICBitmapDitherTypeNone, nullptr, 0, WICBitmapPaletteTypeMedianCut); - if (FAILED(hr)) - return hr; - - auto img = rawFrame.GetImage(0, 0, 0); - - hr = FC->CopyPixels(nullptr, static_cast(img->rowPitch), static_cast(img->slicePitch), img->pixels); - if (FAILED(hr)) - return hr; - - if (!iframe || transparentIndex == -1) - { - const Rect fullRect(0, 0, img->width, img->height); - hr = CopyRectangle(*img, fullRect, *composedImage, TEX_FILTER_DEFAULT, size_t(rct.left), size_t(rct.top)); - if (FAILED(hr)) - return hr; - } - else - { - BlendRectangle(*composedImage, *img, rct, rgbColors[transparentIndex]); - } - - if (disposal == DM_UNDEFINED || disposal == DM_NONE) - { - previousFrame = iframe; - } - - loadedImages.emplace_back(std::move(frameImage)); - } - - PropVariantClear(&propValue); - - return S_OK; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texassemble/Texassemble_Desktop_2019.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texassemble/Texassemble_Desktop_2019.vcxproj deleted file mode 100644 index c2ea625..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texassemble/Texassemble_Desktop_2019.vcxproj +++ /dev/null @@ -1,292 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Profile - Win32 - - - Profile - x64 - - - Release - Win32 - - - Release - x64 - - - - texassemble - {8F18CBD7-4116-4956-BCD8-20D688A4CBD1} - texassemble - Win32Proj - 10.0 - - - - Application - true - Unicode - v142 - - - Application - true - Unicode - v142 - - - Application - true - Unicode - v142 - - - Application - true - Unicode - v142 - - - Application - true - Unicode - v142 - - - Application - true - Unicode - v142 - - - - - - - - - - - - - - - - - - - - - - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - texassemble - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - texassemble - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - texassemble - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - texassemble - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - texassemble - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - texassemble - true - - - - Level4 - Disabled - MultiThreadedDebugDLL - Fast - StreamingSIMDExtensions2 - ..\DirectXTex;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;DEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - Console - true - true - - - false - - - - - Level4 - Disabled - MultiThreadedDebugDLL - Fast - ..\DirectXTex;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;DEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - Console - true - - - false - - - - - Level4 - MaxSpeed - Fast - StreamingSIMDExtensions2 - ..\DirectXTex;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - Guard - true - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - true - - - false - - - - - Level4 - MaxSpeed - Fast - ..\DirectXTex;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - Guard - true - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - - - false - - - - - Level4 - MaxSpeed - Fast - StreamingSIMDExtensions2 - ..\DirectXTex;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Guard - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - true - - - false - - - - - Level4 - MaxSpeed - Fast - ..\DirectXTex;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Guard - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - - - false - - - - - - - - - - - - {371b9fa9-4c90-4ac6-a123-aced756d6c77} - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texassemble/Texassemble_Desktop_2019.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texassemble/Texassemble_Desktop_2019.vcxproj.filters deleted file mode 100644 index e1687da..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texassemble/Texassemble_Desktop_2019.vcxproj.filters +++ /dev/null @@ -1,18 +0,0 @@ - - - - - {8e114980-c1a3-4ada-ad7c-83caadf5daeb} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - - - - - - - Resource Files - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texassemble/Texassemble_Desktop_2022.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texassemble/Texassemble_Desktop_2022.vcxproj deleted file mode 100644 index 4d463a0..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texassemble/Texassemble_Desktop_2022.vcxproj +++ /dev/null @@ -1,298 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Profile - Win32 - - - Profile - x64 - - - Release - Win32 - - - Release - x64 - - - - texassemble - {8F18CBD7-4116-4956-BCD8-20D688A4CBD1} - texassemble - Win32Proj - 10.0 - - - - Application - true - Unicode - v143 - - - Application - true - Unicode - v143 - - - Application - true - Unicode - v143 - - - Application - true - Unicode - v143 - - - Application - true - Unicode - v143 - - - Application - true - Unicode - v143 - - - - - - - - - - - - - - - - - - - - - - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - texassemble - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - texassemble - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - texassemble - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - texassemble - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - texassemble - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - texassemble - true - - - - Level4 - Disabled - MultiThreadedDebugDLL - Fast - StreamingSIMDExtensions2 - ..\DirectXTex;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;DEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - true - /Zc:__cplusplus %(AdditionalOptions) - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - Console - true - true - true - - - false - - - - - Level4 - Disabled - MultiThreadedDebugDLL - Fast - ..\DirectXTex;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;DEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - true - /Zc:__cplusplus %(AdditionalOptions) - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - Console - true - true - - - false - - - - - Level4 - MaxSpeed - Fast - StreamingSIMDExtensions2 - ..\DirectXTex;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - Guard - true - true - /Zc:__cplusplus %(AdditionalOptions) - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - true - true - - - false - - - - - Level4 - MaxSpeed - Fast - ..\DirectXTex;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - Guard - true - true - /Zc:__cplusplus %(AdditionalOptions) - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - true - - - false - - - - - Level4 - MaxSpeed - Fast - StreamingSIMDExtensions2 - ..\DirectXTex;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - true - /Zc:__cplusplus %(AdditionalOptions) - Guard - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - true - true - - - false - - - - - Level4 - MaxSpeed - Fast - ..\DirectXTex;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - true - /Zc:__cplusplus %(AdditionalOptions) - Guard - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - true - - - false - - - - - - - - - - - - {371b9fa9-4c90-4ac6-a123-aced756d6c77} - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texassemble/Texassemble_Desktop_2022.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texassemble/Texassemble_Desktop_2022.vcxproj.filters deleted file mode 100644 index e1687da..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texassemble/Texassemble_Desktop_2022.vcxproj.filters +++ /dev/null @@ -1,18 +0,0 @@ - - - - - {8e114980-c1a3-4ada-ad7c-83caadf5daeb} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - - - - - - - Resource Files - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texassemble/directx.ico b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texassemble/directx.ico deleted file mode 100644 index bc43c1b..0000000 Binary files a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texassemble/directx.ico and /dev/null differ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texassemble/texassemble.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texassemble/texassemble.cpp deleted file mode 100644 index 0df5485..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texassemble/texassemble.cpp +++ /dev/null @@ -1,2284 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: Texassemble.cpp -// -// DirectX Texture assembler for cube maps, volume maps, and arrays -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//-------------------------------------------------------------------------------------- - -#pragma warning(push) -#pragma warning(disable : 4005) -#define WIN32_LEAN_AND_MEAN -#define NOMINMAX -#define NODRAWTEXT -#define NOGDI -#define NOMCX -#define NOSERVICE -#define NOHELP -#pragma warning(pop) - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include - -#pragma warning(disable : 4619 4616 26812) - -#include "DirectXTex.h" - -//Uncomment to add support for OpenEXR (.exr) -//#define USE_OPENEXR - -#ifdef USE_OPENEXR -// See for details -#include "DirectXTexEXR.h" -#endif - -using namespace DirectX; -using Microsoft::WRL::ComPtr; - -namespace -{ - enum COMMANDS : uint32_t - { - CMD_CUBE = 1, - CMD_VOLUME, - CMD_ARRAY, - CMD_CUBEARRAY, - CMD_H_CROSS, - CMD_V_CROSS, - CMD_H_STRIP, - CMD_V_STRIP, - CMD_MERGE, - CMD_GIF, - CMD_ARRAY_STRIP, - CMD_MAX - }; - - enum OPTIONS : uint32_t - { - OPT_RECURSIVE = 1, - OPT_FILELIST, - OPT_WIDTH, - OPT_HEIGHT, - OPT_FORMAT, - OPT_FILTER, - OPT_SRGBI, - OPT_SRGBO, - OPT_SRGB, - OPT_OUTPUTFILE, - OPT_TOLOWER, - OPT_OVERWRITE, - OPT_USE_DX10, - OPT_NOLOGO, - OPT_SEPALPHA, - OPT_NO_WIC, - OPT_DEMUL_ALPHA, - OPT_TA_WRAP, - OPT_TA_MIRROR, - OPT_FEATURE_LEVEL, - OPT_TONEMAP, - OPT_GIF_BGCOLOR, - OPT_SWIZZLE, - OPT_STRIP_MIPS, - OPT_MAX - }; - - static_assert(OPT_MAX <= 32, "dwOptions is a unsigned int bitfield"); - - struct SConversion - { - wchar_t szSrc[MAX_PATH]; - }; - - struct SValue - { - const wchar_t* name; - uint32_t value; - }; - - ////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////////// - - const SValue g_pCommands[] = - { - { L"cube", CMD_CUBE }, - { L"volume", CMD_VOLUME }, - { L"array", CMD_ARRAY }, - { L"cubearray", CMD_CUBEARRAY }, - { L"h-cross", CMD_H_CROSS }, - { L"v-cross", CMD_V_CROSS }, - { L"h-strip", CMD_H_STRIP }, - { L"v-strip", CMD_V_STRIP }, - { L"merge", CMD_MERGE }, - { L"gif", CMD_GIF }, - { L"array-strip", CMD_ARRAY_STRIP }, - { nullptr, 0 } - }; - - const SValue g_pOptions[] = - { - { L"r", OPT_RECURSIVE }, - { L"flist", OPT_FILELIST }, - { L"w", OPT_WIDTH }, - { L"h", OPT_HEIGHT }, - { L"f", OPT_FORMAT }, - { L"if", OPT_FILTER }, - { L"srgbi", OPT_SRGBI }, - { L"srgbo", OPT_SRGBO }, - { L"srgb", OPT_SRGB }, - { L"o", OPT_OUTPUTFILE }, - { L"l", OPT_TOLOWER }, - { L"y", OPT_OVERWRITE }, - { L"dx10", OPT_USE_DX10 }, - { L"nologo", OPT_NOLOGO }, - { L"sepalpha", OPT_SEPALPHA }, - { L"nowic", OPT_NO_WIC }, - { L"alpha", OPT_DEMUL_ALPHA }, - { L"wrap", OPT_TA_WRAP }, - { L"mirror", OPT_TA_MIRROR }, - { L"fl", OPT_FEATURE_LEVEL }, - { L"tonemap", OPT_TONEMAP }, - { L"bgcolor", OPT_GIF_BGCOLOR }, - { L"swizzle", OPT_SWIZZLE }, - { L"stripmips", OPT_STRIP_MIPS }, - { nullptr, 0 } - }; - -#define DEFFMT(fmt) { L## #fmt, DXGI_FORMAT_ ## fmt } - - const SValue g_pFormats[] = - { - // List does not include _TYPELESS or depth/stencil formats - DEFFMT(R32G32B32A32_FLOAT), - DEFFMT(R32G32B32A32_UINT), - DEFFMT(R32G32B32A32_SINT), - DEFFMT(R32G32B32_FLOAT), - DEFFMT(R32G32B32_UINT), - DEFFMT(R32G32B32_SINT), - DEFFMT(R16G16B16A16_FLOAT), - DEFFMT(R16G16B16A16_UNORM), - DEFFMT(R16G16B16A16_UINT), - DEFFMT(R16G16B16A16_SNORM), - DEFFMT(R16G16B16A16_SINT), - DEFFMT(R32G32_FLOAT), - DEFFMT(R32G32_UINT), - DEFFMT(R32G32_SINT), - DEFFMT(R10G10B10A2_UNORM), - DEFFMT(R10G10B10A2_UINT), - DEFFMT(R11G11B10_FLOAT), - DEFFMT(R8G8B8A8_UNORM), - DEFFMT(R8G8B8A8_UNORM_SRGB), - DEFFMT(R8G8B8A8_UINT), - DEFFMT(R8G8B8A8_SNORM), - DEFFMT(R8G8B8A8_SINT), - DEFFMT(R16G16_FLOAT), - DEFFMT(R16G16_UNORM), - DEFFMT(R16G16_UINT), - DEFFMT(R16G16_SNORM), - DEFFMT(R16G16_SINT), - DEFFMT(R32_FLOAT), - DEFFMT(R32_UINT), - DEFFMT(R32_SINT), - DEFFMT(R8G8_UNORM), - DEFFMT(R8G8_UINT), - DEFFMT(R8G8_SNORM), - DEFFMT(R8G8_SINT), - DEFFMT(R16_FLOAT), - DEFFMT(R16_UNORM), - DEFFMT(R16_UINT), - DEFFMT(R16_SNORM), - DEFFMT(R16_SINT), - DEFFMT(R8_UNORM), - DEFFMT(R8_UINT), - DEFFMT(R8_SNORM), - DEFFMT(R8_SINT), - DEFFMT(A8_UNORM), - //DEFFMT(R1_UNORM) - DEFFMT(R9G9B9E5_SHAREDEXP), - DEFFMT(R8G8_B8G8_UNORM), - DEFFMT(G8R8_G8B8_UNORM), - DEFFMT(B5G6R5_UNORM), - DEFFMT(B5G5R5A1_UNORM), - - // DXGI 1.1 formats - DEFFMT(B8G8R8A8_UNORM), - DEFFMT(B8G8R8X8_UNORM), - DEFFMT(R10G10B10_XR_BIAS_A2_UNORM), - DEFFMT(B8G8R8A8_UNORM_SRGB), - DEFFMT(B8G8R8X8_UNORM_SRGB), - - // DXGI 1.2 formats - DEFFMT(AYUV), - DEFFMT(Y410), - DEFFMT(Y416), - DEFFMT(YUY2), - DEFFMT(Y210), - DEFFMT(Y216), - // No support for legacy paletted video formats (AI44, IA44, P8, A8P8) - DEFFMT(B4G4R4A4_UNORM), - - { nullptr, DXGI_FORMAT_UNKNOWN } - }; - - const SValue g_pFormatAliases[] = - { - { L"RGBA", DXGI_FORMAT_R8G8B8A8_UNORM }, - { L"BGRA", DXGI_FORMAT_B8G8R8A8_UNORM }, - { L"BGR", DXGI_FORMAT_B8G8R8X8_UNORM }, - - { L"FP16", DXGI_FORMAT_R16G16B16A16_FLOAT }, - { L"FP32", DXGI_FORMAT_R32G32B32A32_FLOAT }, - - { nullptr, DXGI_FORMAT_UNKNOWN } - }; - - const SValue g_pFilters[] = - { - { L"POINT", TEX_FILTER_POINT }, - { L"LINEAR", TEX_FILTER_LINEAR }, - { L"CUBIC", TEX_FILTER_CUBIC }, - { L"FANT", TEX_FILTER_FANT }, - { L"BOX", TEX_FILTER_BOX }, - { L"TRIANGLE", TEX_FILTER_TRIANGLE }, - { L"POINT_DITHER", TEX_FILTER_POINT | TEX_FILTER_DITHER }, - { L"LINEAR_DITHER", TEX_FILTER_LINEAR | TEX_FILTER_DITHER }, - { L"CUBIC_DITHER", TEX_FILTER_CUBIC | TEX_FILTER_DITHER }, - { L"FANT_DITHER", TEX_FILTER_FANT | TEX_FILTER_DITHER }, - { L"BOX_DITHER", TEX_FILTER_BOX | TEX_FILTER_DITHER }, - { L"TRIANGLE_DITHER", TEX_FILTER_TRIANGLE | TEX_FILTER_DITHER }, - { L"POINT_DITHER_DIFFUSION", TEX_FILTER_POINT | TEX_FILTER_DITHER_DIFFUSION }, - { L"LINEAR_DITHER_DIFFUSION", TEX_FILTER_LINEAR | TEX_FILTER_DITHER_DIFFUSION }, - { L"CUBIC_DITHER_DIFFUSION", TEX_FILTER_CUBIC | TEX_FILTER_DITHER_DIFFUSION }, - { L"FANT_DITHER_DIFFUSION", TEX_FILTER_FANT | TEX_FILTER_DITHER_DIFFUSION }, - { L"BOX_DITHER_DIFFUSION", TEX_FILTER_BOX | TEX_FILTER_DITHER_DIFFUSION }, - { L"TRIANGLE_DITHER_DIFFUSION", TEX_FILTER_TRIANGLE | TEX_FILTER_DITHER_DIFFUSION }, - { nullptr, TEX_FILTER_DEFAULT } - }; - -#define CODEC_DDS 0xFFFF0001 -#define CODEC_TGA 0xFFFF0002 -#define CODEC_HDR 0xFFFF0005 - -#ifdef USE_OPENEXR -#define CODEC_EXR 0xFFFF0006 -#endif - - const SValue g_pExtFileTypes[] = - { - { L".BMP", WIC_CODEC_BMP }, - { L".JPG", WIC_CODEC_JPEG }, - { L".JPEG", WIC_CODEC_JPEG }, - { L".PNG", WIC_CODEC_PNG }, - { L".DDS", CODEC_DDS }, - { L".TGA", CODEC_TGA }, - { L".HDR", CODEC_HDR }, - { L".TIF", WIC_CODEC_TIFF }, - { L".TIFF", WIC_CODEC_TIFF }, - { L".WDP", WIC_CODEC_WMP }, - { L".HDP", WIC_CODEC_WMP }, - { L".JXR", WIC_CODEC_WMP }, - #ifdef USE_OPENEXR - { L"EXR", CODEC_EXR }, - #endif - { nullptr, CODEC_DDS } - }; - - const SValue g_pFeatureLevels[] = // valid feature levels for -fl for maximimum size - { - { L"9.1", 2048 }, - { L"9.2", 2048 }, - { L"9.3", 4096 }, - { L"10.0", 8192 }, - { L"10.1", 8192 }, - { L"11.0", 16384 }, - { L"11.1", 16384 }, - { L"12.0", 16384 }, - { L"12.1", 16384 }, - { L"12.2", 16384 }, - { nullptr, 0 }, - }; - - const SValue g_pFeatureLevelsCube[] = // valid feature levels for -fl for maximum cubemap size - { - { L"9.1", 512 }, - { L"9.2", 512 }, - { L"9.3", 4096 }, - { L"10.0", 8192 }, - { L"10.1", 8192 }, - { L"11.0", 16384 }, - { L"11.1", 16384 }, - { L"12.0", 16384 }, - { L"12.1", 16384 }, - { L"12.2", 16384 }, - { nullptr, 0 }, - }; - - const SValue g_pFeatureLevelsArray[] = // valid feature levels for -fl for maximum array size - { - { L"9.1", 1 }, - { L"9.2", 1 }, - { L"9.3", 1 }, - { L"10.0", 512 }, - { L"10.1", 512 }, - { L"11.0", 2048 }, - { L"11.1", 2048 }, - { L"12.0", 2048 }, - { L"12.1", 2048 }, - { L"12.2", 2048 }, - { nullptr, 0 }, - }; - - const SValue g_pFeatureLevelsVolume[] = // valid feature levels for -fl for maximum depth size - { - { L"9.1", 256 }, - { L"9.2", 256 }, - { L"9.3", 256 }, - { L"10.0", 2048 }, - { L"10.1", 2048 }, - { L"11.0", 2048 }, - { L"11.1", 2048 }, - { L"12.0", 2048 }, - { L"12.1", 2048 }, - { L"12.2", 2048 }, - { nullptr, 0 }, - }; -} - -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -HRESULT LoadAnimatedGif(const wchar_t* szFile, - std::vector>& loadedImages, - bool usebgcolor); - -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -namespace -{ - inline HANDLE safe_handle(HANDLE h) noexcept { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; } - - struct find_closer { void operator()(HANDLE h) noexcept { assert(h != INVALID_HANDLE_VALUE); if (h) FindClose(h); } }; - - using ScopedFindHandle = std::unique_ptr; - -#ifdef _PREFAST_ -#pragma prefast(disable : 26018, "Only used with static internal arrays") -#endif - - uint32_t LookupByName(const wchar_t *pName, const SValue *pArray) - { - while (pArray->name) - { - if (!_wcsicmp(pName, pArray->name)) - return pArray->value; - - pArray++; - } - - return 0; - } - - void SearchForFiles(const wchar_t* path, std::list& files, bool recursive) - { - // Process files - WIN32_FIND_DATAW findData = {}; - ScopedFindHandle hFile(safe_handle(FindFirstFileExW(path, - FindExInfoBasic, &findData, - FindExSearchNameMatch, nullptr, - FIND_FIRST_EX_LARGE_FETCH))); - if (hFile) - { - for (;;) - { - if (!(findData.dwFileAttributes & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_DIRECTORY))) - { - wchar_t drive[_MAX_DRIVE] = {}; - wchar_t dir[_MAX_DIR] = {}; - _wsplitpath_s(path, drive, _MAX_DRIVE, dir, _MAX_DIR, nullptr, 0, nullptr, 0); - - SConversion conv = {}; - _wmakepath_s(conv.szSrc, drive, dir, findData.cFileName, nullptr); - files.push_back(conv); - } - - if (!FindNextFileW(hFile.get(), &findData)) - break; - } - } - - // Process directories - if (recursive) - { - wchar_t searchDir[MAX_PATH] = {}; - { - wchar_t drive[_MAX_DRIVE] = {}; - wchar_t dir[_MAX_DIR] = {}; - _wsplitpath_s(path, drive, _MAX_DRIVE, dir, _MAX_DIR, nullptr, 0, nullptr, 0); - _wmakepath_s(searchDir, drive, dir, L"*", nullptr); - } - - hFile.reset(safe_handle(FindFirstFileExW(searchDir, - FindExInfoBasic, &findData, - FindExSearchLimitToDirectories, nullptr, - FIND_FIRST_EX_LARGE_FETCH))); - if (!hFile) - return; - - for (;;) - { - if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - { - if (findData.cFileName[0] != L'.') - { - wchar_t subdir[MAX_PATH] = {}; - - { - wchar_t drive[_MAX_DRIVE] = {}; - wchar_t dir[_MAX_DIR] = {}; - wchar_t fname[_MAX_FNAME] = {}; - wchar_t ext[_MAX_FNAME] = {}; - _wsplitpath_s(path, drive, dir, fname, ext); - wcscat_s(dir, findData.cFileName); - _wmakepath_s(subdir, drive, dir, fname, ext); - } - - SearchForFiles(subdir, files, recursive); - } - } - - if (!FindNextFileW(hFile.get(), &findData)) - break; - } - } - } - - void ProcessFileList(std::wifstream& inFile, std::list& files) - { - std::list flist; - std::set excludes; - wchar_t fname[1024] = {}; - for (;;) - { - inFile >> fname; - if (!inFile) - break; - - if (*fname == L'#') - { - // Comment - } - else if (*fname == L'-') - { - if (flist.empty()) - { - wprintf(L"WARNING: Ignoring the line '%ls' in -flist\n", fname); - } - else - { - if (wcspbrk(fname, L"?*") != nullptr) - { - std::list removeFiles; - SearchForFiles(&fname[1], removeFiles, false); - - for (auto it : removeFiles) - { - _wcslwr_s(it.szSrc); - excludes.insert(it.szSrc); - } - } - else - { - std::wstring name = (fname + 1); - std::transform(name.begin(), name.end(), name.begin(), towlower); - excludes.insert(name); - } - } - } - else if (wcspbrk(fname, L"?*") != nullptr) - { - SearchForFiles(fname, flist, false); - } - else - { - SConversion conv = {}; - wcscpy_s(conv.szSrc, MAX_PATH, fname); - flist.push_back(conv); - } - - inFile.ignore(1000, '\n'); - } - - inFile.close(); - - if (!excludes.empty()) - { - // Remove any excluded files - for (auto it = flist.begin(); it != flist.end();) - { - std::wstring name = it->szSrc; - std::transform(name.begin(), name.end(), name.begin(), towlower); - auto item = it; - ++it; - if (excludes.find(name) != excludes.end()) - { - flist.erase(item); - } - } - } - - if (flist.empty()) - { - wprintf(L"WARNING: No file names found in -flist\n"); - } - else - { - files.splice(files.end(), flist); - } - } - - void PrintFormat(DXGI_FORMAT Format) - { - for (auto pFormat = g_pFormats; pFormat->name; pFormat++) - { - if (static_cast(pFormat->value) == Format) - { - wprintf(L"%ls", pFormat->name); - break; - } - } - } - - void PrintInfo(const TexMetadata& info) - { - wprintf(L" (%zux%zu", info.width, info.height); - - if (TEX_DIMENSION_TEXTURE3D == info.dimension) - wprintf(L"x%zu", info.depth); - - if (info.mipLevels > 1) - wprintf(L",%zu", info.mipLevels); - - if (info.arraySize > 1) - wprintf(L",%zu", info.arraySize); - - wprintf(L" "); - PrintFormat(info.format); - - switch (info.dimension) - { - case TEX_DIMENSION_TEXTURE1D: - wprintf(L"%ls", (info.arraySize > 1) ? L" 1DArray" : L" 1D"); - break; - - case TEX_DIMENSION_TEXTURE2D: - if (info.IsCubemap()) - { - wprintf(L"%ls", (info.arraySize > 6) ? L" CubeArray" : L" Cube"); - } - else - { - wprintf(L"%ls", (info.arraySize > 1) ? L" 2DArray" : L" 2D"); - } - break; - - case TEX_DIMENSION_TEXTURE3D: - wprintf(L" 3D"); - break; - } - - switch (info.GetAlphaMode()) - { - case TEX_ALPHA_MODE_OPAQUE: - wprintf(L" \x0e0:Opaque"); - break; - case TEX_ALPHA_MODE_PREMULTIPLIED: - wprintf(L" \x0e0:PM"); - break; - case TEX_ALPHA_MODE_STRAIGHT: - wprintf(L" \x0e0:NonPM"); - break; - case TEX_ALPHA_MODE_CUSTOM: - wprintf(L" \x0e0:Custom"); - break; - case TEX_ALPHA_MODE_UNKNOWN: - break; - } - - wprintf(L")"); - } - - void PrintList(size_t cch, const SValue *pValue) - { - while (pValue->name) - { - const size_t cchName = wcslen(pValue->name); - - if (cch + cchName + 2 >= 80) - { - wprintf(L"\n "); - cch = 6; - } - - wprintf(L"%ls ", pValue->name); - cch += cchName + 2; - pValue++; - } - - wprintf(L"\n"); - } - - void PrintLogo() - { - wchar_t version[32] = {}; - - wchar_t appName[_MAX_PATH] = {}; - if (GetModuleFileNameW(nullptr, appName, static_cast(std::size(appName)))) - { - const DWORD size = GetFileVersionInfoSizeW(appName, nullptr); - if (size > 0) - { - auto verInfo = std::make_unique(size); - if (GetFileVersionInfoW(appName, 0, size, verInfo.get())) - { - LPVOID lpstr = nullptr; - UINT strLen = 0; - if (VerQueryValueW(verInfo.get(), L"\\StringFileInfo\\040904B0\\ProductVersion", &lpstr, &strLen)) - { - wcsncpy_s(version, reinterpret_cast(lpstr), strLen); - } - } - } - } - - if (!*version || wcscmp(version, L"1.0.0.0") == 0) - { - swprintf_s(version, L"%03d (library)", DIRECTX_TEX_VERSION); - } - - wprintf(L"Microsoft (R) DirectX Texture Assembler [DirectXTex] Version %ls\n", version); - wprintf(L"Copyright (C) Microsoft Corp.\n"); - #ifdef _DEBUG - wprintf(L"*** Debug build ***\n"); - #endif - wprintf(L"\n"); - } - - const wchar_t* GetErrorDesc(HRESULT hr) - { - static wchar_t desc[1024] = {}; - - LPWSTR errorText = nullptr; - - const DWORD result = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_ALLOCATE_BUFFER, - nullptr, static_cast(hr), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast(&errorText), 0, nullptr); - - *desc = 0; - - if (result > 0 && errorText) - { - swprintf_s(desc, L": %ls", errorText); - - size_t len = wcslen(desc); - if (len >= 1) - { - desc[len - 1] = 0; - } - - if (errorText) - LocalFree(errorText); - } - - return desc; - } - - void PrintUsage() - { - PrintLogo(); - - wprintf(L"Usage: texassemble \n\n"); - wprintf(L" cube create cubemap\n"); - wprintf(L" volume create volume map\n"); - wprintf(L" array create texture array\n"); - wprintf(L" cubearray create cubemap array\n"); - wprintf(L" h-cross or v-cross create a cross image from a cubemap\n"); - wprintf(L" h-strip or v-strip create a strip image from a cubemap\n"); - wprintf(L" array-strip creates a strip image from a 1D/2D array\n"); - wprintf(L" merge create texture from rgb image and alpha image\n"); - wprintf(L" gif create array from animated gif\n\n"); - wprintf(L" -r wildcard filename search is recursive\n"); - wprintf(L" -flist use text file with a list of input files (one per line)\n"); - wprintf(L" -w width\n"); - wprintf(L" -h height\n"); - wprintf(L" -f format\n"); - wprintf(L" -if image filtering\n"); - wprintf(L" -srgb{i|o} sRGB {input, output}\n"); - wprintf(L" -o output filename\n"); - wprintf(L" -l force output filename to lower case\n"); - wprintf(L" -y overwrite existing output file (if any)\n"); - wprintf(L" -sepalpha resize alpha channel separately from color channels\n"); - wprintf(L" -nowic Force non-WIC filtering\n"); - wprintf(L" -wrap, -mirror texture addressing mode (wrap, mirror, or clamp)\n"); - wprintf(L" -alpha convert premultiplied alpha to straight alpha\n"); - wprintf(L" -dx10 Force use of 'DX10' extended header\n"); - wprintf(L" -nologo suppress copyright message\n"); - wprintf(L" -fl Set maximum feature level target (defaults to 11.0)\n"); - wprintf(L" -tonemap Apply a tonemap operator based on maximum luminance\n"); - wprintf(L"\n (gif only)\n"); - wprintf(L" -bgcolor Use background color instead of transparency\n"); - wprintf(L"\n (merge only)\n"); - wprintf(L" -swizzle Select channels for merge (defaults to rgbB)\n"); - wprintf(L"\n (cube, volume, array, cubearray, merge only)\n"); - wprintf(L" -stripmips Use only base image from input dds files\n"); - - wprintf(L"\n : "); - PrintList(13, g_pFormats); - wprintf(L" "); - PrintList(13, g_pFormatAliases); - - wprintf(L"\n : "); - PrintList(13, g_pFilters); - - wprintf(L"\n : "); - PrintList(13, g_pFeatureLevels); - } - - HRESULT SaveImageFile(const Image& img, uint32_t fileType, const wchar_t* szOutputFile) - { - switch (fileType) - { - case CODEC_DDS: - return SaveToDDSFile(img, DDS_FLAGS_NONE, szOutputFile); - - case CODEC_TGA: - return SaveToTGAFile(img, TGA_FLAGS_NONE, szOutputFile); - - case CODEC_HDR: - return SaveToHDRFile(img, szOutputFile); - - #ifdef USE_OPENEXR - case CODEC_EXR: - return SaveToEXRFile(img, szOutputFile); - #endif - - default: - { - HRESULT hr = SaveToWICFile(img, WIC_FLAGS_NONE, GetWICCodec(static_cast(fileType)), szOutputFile); - if ((hr == static_cast(0xc00d5212) /* MF_E_TOPO_CODEC_NOT_FOUND */) && (fileType == WIC_CODEC_HEIF)) - { - wprintf(L"\nINFO: This format requires installing the HEIF Image Extensions - https://aka.ms/heif\n"); - } - return hr; - } - } - } - - bool ParseSwizzleMask( - _In_reads_(4) const wchar_t* mask, - _Out_writes_(4) uint32_t* permuteElements, - _Out_writes_(4) uint32_t* zeroElements, - _Out_writes_(4) uint32_t* oneElements) - { - if (!mask || !permuteElements || !zeroElements || !oneElements) - return false; - - if (!mask[0]) - return false; - - for (uint32_t j = 0; j < 4; ++j) - { - if (!mask[j]) - break; - - switch (mask[j]) - { - case L'r': - case L'x': - for (uint32_t k = j; k < 4; ++k) - { - permuteElements[k] = 0; - zeroElements[k] = 0; - oneElements[k] = 0; - } - break; - - case L'R': - case L'X': - for (uint32_t k = j; k < 4; ++k) - { - permuteElements[k] = 4; - zeroElements[k] = 0; - oneElements[k] = 0; - } - break; - - case L'g': - case L'y': - for (uint32_t k = j; k < 4; ++k) - { - permuteElements[k] = 1; - zeroElements[k] = 0; - oneElements[k] = 0; - } - break; - - case L'G': - case L'Y': - for (uint32_t k = j; k < 4; ++k) - { - permuteElements[k] = 5; - zeroElements[k] = 0; - oneElements[k] = 0; - } - break; - - case L'b': - case L'z': - for (uint32_t k = j; k < 4; ++k) - { - permuteElements[k] = 2; - zeroElements[k] = 0; - oneElements[k] = 0; - } - break; - - case L'B': - case L'Z': - for (uint32_t k = j; k < 4; ++k) - { - permuteElements[k] = 6; - zeroElements[k] = 0; - oneElements[k] = 0; - } - break; - - case L'a': - case L'w': - for (uint32_t k = j; k < 4; ++k) - { - permuteElements[k] = 3; - zeroElements[k] = 0; - oneElements[k] = 0; - } - break; - - case L'A': - case L'W': - for (uint32_t k = j; k < 4; ++k) - { - permuteElements[k] = 7; - zeroElements[k] = 0; - oneElements[k] = 0; - } - break; - - case L'0': - for (uint32_t k = j; k < 4; ++k) - { - permuteElements[k] = k; - zeroElements[k] = 1; - oneElements[k] = 0; - } - break; - - case L'1': - for (uint32_t k = j; k < 4; ++k) - { - permuteElements[k] = k; - zeroElements[k] = 0; - oneElements[k] = 1; - } - break; - - default: - return false; - } - } - - return true; - } -} - -//-------------------------------------------------------------------------------------- -// Entry-point -//-------------------------------------------------------------------------------------- -#ifdef _PREFAST_ -#pragma prefast(disable : 28198, "Command-line tool, frees all memory on exit") -#endif - -int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[]) -{ - // Parameters and defaults - size_t width = 0; - size_t height = 0; - - DXGI_FORMAT format = DXGI_FORMAT_UNKNOWN; - TEX_FILTER_FLAGS dwFilter = TEX_FILTER_DEFAULT; - TEX_FILTER_FLAGS dwSRGB = TEX_FILTER_DEFAULT; - TEX_FILTER_FLAGS dwFilterOpts = TEX_FILTER_DEFAULT; - uint32_t fileType = WIC_CODEC_BMP; - uint32_t maxSize = 16384; - uint32_t maxCube = 16384; - uint32_t maxArray = 2048; - uint32_t maxVolume = 2048; - - // DXTex's Open Alpha onto Surface always loaded alpha from the blue channel - uint32_t permuteElements[4] = { 0, 1, 2, 6 }; - uint32_t zeroElements[4] = {}; - uint32_t oneElements[4] = {}; - - wchar_t szOutputFile[MAX_PATH] = {}; - - // Set locale for output since GetErrorDesc can get localized strings. - std::locale::global(std::locale("")); - - // Initialize COM (needed for WIC) - HRESULT hr = hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED); - if (FAILED(hr)) - { - wprintf(L"Failed to initialize COM (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - // Process command line - if (argc < 2) - { - PrintUsage(); - return 0; - } - - const uint32_t dwCommand = LookupByName(argv[1], g_pCommands); - switch (dwCommand) - { - case CMD_CUBE: - case CMD_VOLUME: - case CMD_ARRAY: - case CMD_CUBEARRAY: - case CMD_H_CROSS: - case CMD_V_CROSS: - case CMD_H_STRIP: - case CMD_V_STRIP: - case CMD_MERGE: - case CMD_GIF: - case CMD_ARRAY_STRIP: - break; - - default: - wprintf(L"Must use one of: cube, volume, array, cubearray,\n h-cross, v-cross, h-strip, v-strip, array-strip\n merge, gif\n\n"); - return 1; - } - - uint32_t dwOptions = 0; - std::list conversion; - - for (int iArg = 2; iArg < argc; iArg++) - { - PWSTR pArg = argv[iArg]; - - if (('-' == pArg[0]) || ('/' == pArg[0])) - { - pArg++; - PWSTR pValue; - - for (pValue = pArg; *pValue && (':' != *pValue); pValue++); - - if (*pValue) - *pValue++ = 0; - - const uint32_t dwOption = LookupByName(pArg, g_pOptions); - - if (!dwOption || (dwOptions & (1 << dwOption))) - { - PrintUsage(); - return 1; - } - - dwOptions |= 1 << dwOption; - - // Handle options with additional value parameter - switch (dwOption) - { - case OPT_FILELIST: - case OPT_WIDTH: - case OPT_HEIGHT: - case OPT_FORMAT: - case OPT_FILTER: - case OPT_OUTPUTFILE: - case OPT_FEATURE_LEVEL: - case OPT_SWIZZLE: - if (!*pValue) - { - if ((iArg + 1 >= argc)) - { - PrintUsage(); - return 1; - } - - iArg++; - pValue = argv[iArg]; - } - break; - - default: - break; - } - - switch (dwOption) - { - case OPT_WIDTH: - if (swscanf_s(pValue, L"%zu", &width) != 1) - { - wprintf(L"Invalid value specified with -w (%ls)\n", pValue); - return 1; - } - break; - - case OPT_HEIGHT: - if (swscanf_s(pValue, L"%zu", &height) != 1) - { - wprintf(L"Invalid value specified with -h (%ls)\n", pValue); - return 1; - } - break; - - case OPT_FORMAT: - format = static_cast(LookupByName(pValue, g_pFormats)); - if (!format) - { - format = static_cast(LookupByName(pValue, g_pFormatAliases)); - if (!format) - { - wprintf(L"Invalid value specified with -f (%ls)\n", pValue); - return 1; - } - } - break; - - case OPT_FILTER: - dwFilter = static_cast(LookupByName(pValue, g_pFilters)); - if (!dwFilter) - { - wprintf(L"Invalid value specified with -if (%ls)\n", pValue); - return 1; - } - break; - - case OPT_SRGBI: - dwSRGB |= TEX_FILTER_SRGB_IN; - break; - - case OPT_SRGBO: - dwSRGB |= TEX_FILTER_SRGB_OUT; - break; - - case OPT_SRGB: - dwSRGB |= TEX_FILTER_SRGB; - break; - - case OPT_SEPALPHA: - dwFilterOpts |= TEX_FILTER_SEPARATE_ALPHA; - break; - - case OPT_NO_WIC: - dwFilterOpts |= TEX_FILTER_FORCE_NON_WIC; - break; - - case OPT_OUTPUTFILE: - { - wcscpy_s(szOutputFile, MAX_PATH, pValue); - - wchar_t ext[_MAX_EXT] = {}; - _wsplitpath_s(szOutputFile, nullptr, 0, nullptr, 0, nullptr, 0, ext, _MAX_EXT); - - fileType = LookupByName(ext, g_pExtFileTypes); - - switch (dwCommand) - { - case CMD_H_CROSS: - case CMD_V_CROSS: - case CMD_H_STRIP: - case CMD_V_STRIP: - case CMD_MERGE: - case CMD_ARRAY_STRIP: - break; - - default: - if (fileType != CODEC_DDS) - { - wprintf(L"Assembled output file must be a dds\n"); - return 1; - } - } - break; - } - - case OPT_TA_WRAP: - if (dwFilterOpts & TEX_FILTER_MIRROR) - { - wprintf(L"Can't use -wrap and -mirror at same time\n\n"); - PrintUsage(); - return 1; - } - dwFilterOpts |= TEX_FILTER_WRAP; - break; - - case OPT_TA_MIRROR: - if (dwFilterOpts & TEX_FILTER_WRAP) - { - wprintf(L"Can't use -wrap and -mirror at same time\n\n"); - PrintUsage(); - return 1; - } - dwFilterOpts |= TEX_FILTER_MIRROR; - break; - - case OPT_FILELIST: - { - std::wifstream inFile(pValue); - if (!inFile) - { - wprintf(L"Error opening -flist file %ls\n", pValue); - return 1; - } - - inFile.imbue(std::locale::classic()); - - ProcessFileList(inFile, conversion); - } - break; - - case OPT_FEATURE_LEVEL: - maxSize = LookupByName(pValue, g_pFeatureLevels); - maxCube = LookupByName(pValue, g_pFeatureLevelsCube); - maxArray = LookupByName(pValue, g_pFeatureLevelsArray); - maxVolume = LookupByName(pValue, g_pFeatureLevelsVolume); - if (!maxSize || !maxCube || !maxArray || !maxVolume) - { - wprintf(L"Invalid value specified with -fl (%ls)\n", pValue); - wprintf(L"\n"); - PrintUsage(); - return 1; - } - break; - - case OPT_GIF_BGCOLOR: - if (dwCommand != CMD_GIF) - { - wprintf(L"-bgcolor only applies to gif command\n"); - return 1; - } - break; - - case OPT_SWIZZLE: - if (dwCommand != CMD_MERGE) - { - wprintf(L"-swizzle only applies to merge command\n"); - return 1; - } - if (!*pValue || wcslen(pValue) > 4) - { - wprintf(L"Invalid value specified with -swizzle (%ls)\n\n", pValue); - PrintUsage(); - return 1; - } - else if (!ParseSwizzleMask(pValue, permuteElements, zeroElements, oneElements)) - { - wprintf(L"-swizzle requires a 1 to 4 character mask composed of these letters: r, g, b, a, x, y, w, z, 0, 1.\n Lowercase letters are from the first image, upper-case letters are from the second image.\n"); - return 1; - } - break; - - case OPT_STRIP_MIPS: - switch (dwCommand) - { - case CMD_CUBE: - case CMD_VOLUME: - case CMD_ARRAY: - case CMD_CUBEARRAY: - case CMD_MERGE: - break; - - default: - wprintf(L"-stripmips only applies to cube, volume, array, cubearray, or merge commands\n"); - return 1; - } - break; - - default: - break; - } - } - else if (wcspbrk(pArg, L"?*") != nullptr) - { - const size_t count = conversion.size(); - SearchForFiles(pArg, conversion, (dwOptions & (1 << OPT_RECURSIVE)) != 0); - if (conversion.size() <= count) - { - wprintf(L"No matching files found for %ls\n", pArg); - return 1; - } - } - else - { - SConversion conv = {}; - wcscpy_s(conv.szSrc, MAX_PATH, pArg); - - conversion.push_back(conv); - } - } - - if (conversion.empty()) - { - PrintUsage(); - return 0; - } - - if (~dwOptions & (1 << OPT_NOLOGO)) - PrintLogo(); - - switch (dwCommand) - { - case CMD_H_CROSS: - case CMD_V_CROSS: - case CMD_H_STRIP: - case CMD_V_STRIP: - case CMD_GIF: - case CMD_ARRAY_STRIP: - if (conversion.size() > 1) - { - wprintf(L"ERROR: cross/strip/gif output only accepts 1 input file\n"); - return 1; - } - break; - - case CMD_MERGE: - if (conversion.size() > 2) - { - wprintf(L"ERROR: merge output only accepts 2 input files\n"); - return 1; - } - break; - - default: - break; - } - - // Convert images - size_t images = 0; - - std::vector> loadedImages; - - if (dwCommand == CMD_GIF) - { - wchar_t ext[_MAX_EXT] = {}; - wchar_t fname[_MAX_FNAME] = {}; - _wsplitpath_s(conversion.front().szSrc, nullptr, 0, nullptr, 0, fname, _MAX_FNAME, ext, _MAX_EXT); - - wprintf(L"reading %ls", conversion.front().szSrc); - fflush(stdout); - - if (!*szOutputFile) - { - _wmakepath_s(szOutputFile, nullptr, nullptr, fname, L".dds"); - } - - hr = LoadAnimatedGif(conversion.front().szSrc, loadedImages, (dwOptions & (1 << OPT_GIF_BGCOLOR)) != 0); - if (FAILED(hr)) - { - wprintf(L" FAILED (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - } - else - { - for (auto pConv = conversion.begin(); pConv != conversion.end(); ++pConv) - { - wchar_t ext[_MAX_EXT] = {}; - wchar_t fname[_MAX_FNAME] = {}; - _wsplitpath_s(pConv->szSrc, nullptr, 0, nullptr, 0, fname, _MAX_FNAME, ext, _MAX_EXT); - - // Load source image - if (pConv != conversion.begin()) - wprintf(L"\n"); - else if (!*szOutputFile) - { - switch (dwCommand) - { - case CMD_H_CROSS: - case CMD_V_CROSS: - case CMD_H_STRIP: - case CMD_V_STRIP: - case CMD_ARRAY_STRIP: - _wmakepath_s(szOutputFile, nullptr, nullptr, fname, L".bmp"); - break; - - default: - if (_wcsicmp(ext, L".dds") == 0) - { - wprintf(L"ERROR: Need to specify output file via -o\n"); - return 1; - } - - _wmakepath_s(szOutputFile, nullptr, nullptr, fname, L".dds"); - break; - } - } - - wprintf(L"reading %ls", pConv->szSrc); - fflush(stdout); - - TexMetadata info; - std::unique_ptr image(new (std::nothrow) ScratchImage); - if (!image) - { - wprintf(L"\nERROR: Memory allocation failed\n"); - return 1; - } - - switch (dwCommand) - { - case CMD_H_CROSS: - case CMD_V_CROSS: - case CMD_H_STRIP: - case CMD_V_STRIP: - if (_wcsicmp(ext, L".dds") == 0) - { - hr = LoadFromDDSFile(pConv->szSrc, DDS_FLAGS_ALLOW_LARGE_FILES, &info, *image); - if (FAILED(hr)) - { - wprintf(L" FAILED (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - if (!info.IsCubemap()) - { - wprintf(L"\nERROR: Input must be a cubemap\n"); - return 1; - } - else if (info.arraySize != 6) - { - wprintf(L"\nWARNING: Only the first cubemap in an array is written out as a cross/strip\n"); - } - } - else - { - wprintf(L"\nERROR: Input must be a dds of a cubemap\n"); - return 1; - } - break; - - case CMD_ARRAY_STRIP: - if (_wcsicmp(ext, L".dds") == 0) - { - hr = LoadFromDDSFile(pConv->szSrc, DDS_FLAGS_ALLOW_LARGE_FILES, &info, *image); - if (FAILED(hr)) - { - wprintf(L" FAILED (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - if (info.dimension == TEX_DIMENSION_TEXTURE3D || info.arraySize < 2 || info.IsCubemap()) - { - wprintf(L"\nERROR: Input must be a 1D/2D array\n"); - return 1; - } - } - else - { - wprintf(L"\nERROR: Input must be a dds of a 1D/2D array\n"); - return 1; - } - break; - - default: - if (_wcsicmp(ext, L".dds") == 0) - { - hr = LoadFromDDSFile(pConv->szSrc, DDS_FLAGS_ALLOW_LARGE_FILES, &info, *image); - if (FAILED(hr)) - { - wprintf(L" FAILED (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - if (info.IsVolumemap() || info.IsCubemap()) - { - wprintf(L"\nERROR: Can't assemble complex surfaces\n"); - return 1; - } - else if ((info.mipLevels > 1) && ((dwOptions & (1 << OPT_STRIP_MIPS)) == 0)) - { - wprintf(L"\nERROR: Can't assemble using input mips. To ignore mips, try again with -stripmips\n"); - return 1; - } - } - else if (_wcsicmp(ext, L".tga") == 0) - { - TGA_FLAGS tgaFlags = (IsBGR(format)) ? TGA_FLAGS_BGR : TGA_FLAGS_NONE; - - hr = LoadFromTGAFile(pConv->szSrc, tgaFlags, &info, *image); - if (FAILED(hr)) - { - wprintf(L" FAILED (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - } - else if (_wcsicmp(ext, L".hdr") == 0) - { - hr = LoadFromHDRFile(pConv->szSrc, &info, *image); - if (FAILED(hr)) - { - wprintf(L" FAILED (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - } - #ifdef USE_OPENEXR - else if (_wcsicmp(ext, L".exr") == 0) - { - hr = LoadFromEXRFile(pConv->szSrc, &info, *image); - if (FAILED(hr)) - { - wprintf(L" FAILED (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - } - #endif - else - { - // WIC shares the same filter values for mode and dither - static_assert(static_cast(WIC_FLAGS_DITHER) == static_cast(TEX_FILTER_DITHER), "WIC_FLAGS_* & TEX_FILTER_* should match"); - static_assert(static_cast(WIC_FLAGS_DITHER_DIFFUSION) == static_cast(TEX_FILTER_DITHER_DIFFUSION), "WIC_FLAGS_* & TEX_FILTER_* should match"); - static_assert(static_cast(WIC_FLAGS_FILTER_POINT) == static_cast(TEX_FILTER_POINT), "WIC_FLAGS_* & TEX_FILTER_* should match"); - static_assert(static_cast(WIC_FLAGS_FILTER_LINEAR) == static_cast(TEX_FILTER_LINEAR), "WIC_FLAGS_* & TEX_FILTER_* should match"); - static_assert(static_cast(WIC_FLAGS_FILTER_CUBIC) == static_cast(TEX_FILTER_CUBIC), "WIC_FLAGS_* & TEX_FILTER_* should match"); - static_assert(static_cast(WIC_FLAGS_FILTER_FANT) == static_cast(TEX_FILTER_FANT), "WIC_FLAGS_* & TEX_FILTER_* should match"); - - hr = LoadFromWICFile(pConv->szSrc, WIC_FLAGS_ALL_FRAMES | dwFilter, &info, *image); - if (FAILED(hr)) - { - wprintf(L" FAILED (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - if (hr == static_cast(0xc00d5212) /* MF_E_TOPO_CODEC_NOT_FOUND */) - { - if (_wcsicmp(ext, L".heic") == 0 || _wcsicmp(ext, L".heif") == 0) - { - wprintf(L"INFO: This format requires installing the HEIF Image Extensions - https://aka.ms/heif\n"); - } - else if (_wcsicmp(ext, L".webp") == 0) - { - wprintf(L"INFO: This format requires installing the WEBP Image Extensions - https://www.microsoft.com/p/webp-image-extensions/9pg2dk419drg\n"); - } - } - return 1; - } - } - break; - } - - PrintInfo(info); - - // Convert texture - fflush(stdout); - - // --- Planar ------------------------------------------------------------------ - if (IsPlanar(info.format)) - { - auto img = image->GetImage(0, 0, 0); - assert(img); - const size_t nimg = image->GetImageCount(); - - std::unique_ptr timage(new (std::nothrow) ScratchImage); - if (!timage) - { - wprintf(L"\nERROR: Memory allocation failed\n"); - return 1; - } - - hr = ConvertToSinglePlane(img, nimg, info, *timage); - if (FAILED(hr)) - { - wprintf(L" FAILED [converttosingleplane] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - auto& tinfo = timage->GetMetadata(); - - info.format = tinfo.format; - - assert(info.width == tinfo.width); - assert(info.height == tinfo.height); - assert(info.depth == tinfo.depth); - assert(info.arraySize == tinfo.arraySize); - assert(info.mipLevels == tinfo.mipLevels); - assert(info.miscFlags == tinfo.miscFlags); - assert(info.dimension == tinfo.dimension); - - image.swap(timage); - } - - // --- Decompress -------------------------------------------------------------- - if (IsCompressed(info.format)) - { - const Image* img = image->GetImage(0, 0, 0); - assert(img); - const size_t nimg = image->GetImageCount(); - - std::unique_ptr timage(new (std::nothrow) ScratchImage); - if (!timage) - { - wprintf(L"\nERROR: Memory allocation failed\n"); - return 1; - } - - hr = Decompress(img, nimg, info, DXGI_FORMAT_UNKNOWN /* picks good default */, *timage.get()); - if (FAILED(hr)) - { - wprintf(L" FAILED [decompress] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - auto& tinfo = timage->GetMetadata(); - - info.format = tinfo.format; - - assert(info.width == tinfo.width); - assert(info.height == tinfo.height); - assert(info.depth == tinfo.depth); - assert(info.arraySize == tinfo.arraySize); - assert(info.mipLevels == tinfo.mipLevels); - assert(info.miscFlags == tinfo.miscFlags); - assert(info.dimension == tinfo.dimension); - - image.swap(timage); - } - - // --- Strip Mips (if requested) ----------------------------------------------- - if ((info.mipLevels > 1) && (dwOptions & (1 << OPT_STRIP_MIPS))) - { - std::unique_ptr timage(new (std::nothrow) ScratchImage); - if (!timage) - { - wprintf(L"\nERROR: Memory allocation failed\n"); - return 1; - } - - TexMetadata mdata = info; - mdata.mipLevels = 1; - hr = timage->Initialize(mdata); - if (FAILED(hr)) - { - wprintf(L" FAILED [copy to single level] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - if (info.dimension == TEX_DIMENSION_TEXTURE3D) - { - for (size_t d = 0; d < info.depth; ++d) - { - hr = CopyRectangle(*image->GetImage(0, 0, d), Rect(0, 0, info.width, info.height), - *timage->GetImage(0, 0, d), TEX_FILTER_DEFAULT, 0, 0); - if (FAILED(hr)) - { - wprintf(L" FAILED [copy to single level] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - } - } - else - { - for (size_t i = 0; i < info.arraySize; ++i) - { - hr = CopyRectangle(*image->GetImage(0, i, 0), Rect(0, 0, info.width, info.height), - *timage->GetImage(0, i, 0), TEX_FILTER_DEFAULT, 0, 0); - if (FAILED(hr)) - { - wprintf(L" FAILED [copy to single level] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - } - } - - image.swap(timage); - info.mipLevels = 1; - } - - // --- Undo Premultiplied Alpha (if requested) --------------------------------- - if ((dwOptions & (1 << OPT_DEMUL_ALPHA)) - && HasAlpha(info.format) - && info.format != DXGI_FORMAT_A8_UNORM) - { - if (info.GetAlphaMode() == TEX_ALPHA_MODE_STRAIGHT) - { - printf("\nWARNING: Image is already using straight alpha\n"); - } - else if (!info.IsPMAlpha()) - { - printf("\nWARNING: Image is not using premultipled alpha\n"); - } - else - { - auto img = image->GetImage(0, 0, 0); - assert(img); - const size_t nimg = image->GetImageCount(); - - std::unique_ptr timage(new (std::nothrow) ScratchImage); - if (!timage) - { - wprintf(L"\nERROR: Memory allocation failed\n"); - return 1; - } - - hr = PremultiplyAlpha(img, nimg, info, TEX_PMALPHA_REVERSE | dwSRGB, *timage); - if (FAILED(hr)) - { - wprintf(L" FAILED [demultiply alpha] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - auto& tinfo = timage->GetMetadata(); - info.miscFlags2 = tinfo.miscFlags2; - - assert(info.width == tinfo.width); - assert(info.height == tinfo.height); - assert(info.depth == tinfo.depth); - assert(info.arraySize == tinfo.arraySize); - assert(info.mipLevels == tinfo.mipLevels); - assert(info.miscFlags == tinfo.miscFlags); - assert(info.dimension == tinfo.dimension); - - image.swap(timage); - } - } - - // --- Resize ------------------------------------------------------------------ - if (!width) - { - width = info.width; - } - if (!height) - { - height = info.height; - } - if (info.width != width || info.height != height) - { - std::unique_ptr timage(new (std::nothrow) ScratchImage); - if (!timage) - { - wprintf(L"\nERROR: Memory allocation failed\n"); - return 1; - } - - hr = Resize(image->GetImages(), image->GetImageCount(), image->GetMetadata(), width, height, dwFilter | dwFilterOpts, *timage.get()); - if (FAILED(hr)) - { - wprintf(L" FAILED [resize] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - auto& tinfo = timage->GetMetadata(); - - assert(tinfo.width == width && tinfo.height == height && tinfo.mipLevels == 1); - info.width = tinfo.width; - info.height = tinfo.height; - info.mipLevels = 1; - - assert(info.depth == tinfo.depth); - assert(info.arraySize == tinfo.arraySize); - assert(info.miscFlags == tinfo.miscFlags); - assert(info.format == tinfo.format); - assert(info.dimension == tinfo.dimension); - - image.swap(timage); - } - - // --- Tonemap (if requested) -------------------------------------------------- - if (dwOptions & (1 << OPT_TONEMAP)) - { - std::unique_ptr timage(new (std::nothrow) ScratchImage); - if (!timage) - { - wprintf(L"\nERROR: Memory allocation failed\n"); - return 1; - } - - // Compute max luminosity across all images - XMVECTOR maxLum = XMVectorZero(); - hr = EvaluateImage(image->GetImages(), image->GetImageCount(), image->GetMetadata(), - [&](const XMVECTOR* pixels, size_t w, size_t y) - { - UNREFERENCED_PARAMETER(y); - - for (size_t j = 0; j < w; ++j) - { - static const XMVECTORF32 s_luminance = { { { 0.3f, 0.59f, 0.11f, 0.f } } }; - - XMVECTOR v = *pixels++; - - v = XMVector3Dot(v, s_luminance); - - maxLum = XMVectorMax(v, maxLum); - } - }); - if (FAILED(hr)) - { - wprintf(L" FAILED [tonemap maxlum] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - // Reinhard et al, "Photographic Tone Reproduction for Digital Images" - // http://www.cs.utah.edu/~reinhard/cdrom/ - maxLum = XMVectorMultiply(maxLum, maxLum); - - hr = TransformImage(image->GetImages(), image->GetImageCount(), image->GetMetadata(), - [&](XMVECTOR* outPixels, const XMVECTOR* inPixels, size_t w, size_t y) - { - UNREFERENCED_PARAMETER(y); - - for (size_t j = 0; j < w; ++j) - { - XMVECTOR value = inPixels[j]; - - const XMVECTOR scale = XMVectorDivide( - XMVectorAdd(g_XMOne, XMVectorDivide(value, maxLum)), - XMVectorAdd(g_XMOne, value)); - const XMVECTOR nvalue = XMVectorMultiply(value, scale); - - value = XMVectorSelect(value, nvalue, g_XMSelect1110); - - outPixels[j] = value; - } - }, *timage); - if (FAILED(hr)) - { - wprintf(L" FAILED [tonemap apply] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - #ifndef NDEBUG - auto& tinfo = timage->GetMetadata(); - #endif - - assert(info.width == tinfo.width); - assert(info.height == tinfo.height); - assert(info.depth == tinfo.depth); - assert(info.arraySize == tinfo.arraySize); - assert(info.mipLevels == tinfo.mipLevels); - assert(info.miscFlags == tinfo.miscFlags); - assert(info.format == tinfo.format); - assert(info.dimension == tinfo.dimension); - - image.swap(timage); - } - - // --- Convert ----------------------------------------------------------------- - if (format == DXGI_FORMAT_UNKNOWN) - { - format = info.format; - } - else if (info.format != format && !IsCompressed(format)) - { - std::unique_ptr timage(new (std::nothrow) ScratchImage); - if (!timage) - { - wprintf(L"\nERROR: Memory allocation failed\n"); - return 1; - } - - hr = Convert(image->GetImages(), image->GetImageCount(), image->GetMetadata(), format, - dwFilter | dwFilterOpts | dwSRGB, TEX_THRESHOLD_DEFAULT, *timage.get()); - if (FAILED(hr)) - { - wprintf(L" FAILED [convert] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - auto& tinfo = timage->GetMetadata(); - - assert(tinfo.format == format); - info.format = tinfo.format; - - assert(info.width == tinfo.width); - assert(info.height == tinfo.height); - assert(info.depth == tinfo.depth); - assert(info.arraySize == tinfo.arraySize); - assert(info.mipLevels == tinfo.mipLevels); - assert(info.miscFlags == tinfo.miscFlags); - assert(info.dimension == tinfo.dimension); - - image.swap(timage); - } - - images += info.arraySize; - loadedImages.emplace_back(std::move(image)); - } - } - - switch (dwCommand) - { - case CMD_CUBE: - if (images != 6) - { - wprintf(L"\nERROR: cube requires six images to form the faces of the cubemap\n"); - return 1; - } - break; - - case CMD_CUBEARRAY: - if ((images < 6) || (images % 6) != 0) - { - wprintf(L"cubearray requires a multiple of 6 images to form the faces of the cubemaps\n"); - return 1; - } - break; - - case CMD_H_CROSS: - case CMD_V_CROSS: - case CMD_H_STRIP: - case CMD_V_STRIP: - case CMD_GIF: - break; - - default: - if (images < 2) - { - wprintf(L"\nERROR: Need at least 2 images to assemble\n\n"); - return 1; - } - break; - } - - // --- Create result --------------------------------------------------------------- - switch (dwCommand) - { - case CMD_H_CROSS: - case CMD_V_CROSS: - case CMD_H_STRIP: - case CMD_V_STRIP: - { - size_t twidth = 0; - size_t theight = 0; - - switch (dwCommand) - { - case CMD_H_CROSS: - // posy - // negx posz posx negz - // negy - twidth = width * 4; - theight = height * 3; - break; - - case CMD_V_CROSS: - // posy - // posz posx negz - // negy - // negx - twidth = width * 3; - theight = height * 4; - break; - - case CMD_H_STRIP: - twidth = width * 6; - theight = height; - break; - - case CMD_V_STRIP: - twidth = width; - theight = height * 6; - break; - - default: - break; - } - - ScratchImage result; - hr = result.Initialize2D(format, twidth, theight, 1, 1); - if (FAILED(hr)) - { - wprintf(L"FAILED setting up result image (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - memset(result.GetPixels(), 0, result.GetPixelsSize()); - - auto src = loadedImages.cbegin(); - auto dest = result.GetImage(0, 0, 0); - - for (size_t index = 0; index < 6; ++index) - { - auto img = (*src)->GetImage(0, index, 0); - if (!img) - { - wprintf(L"FAILED: Unexpected error\n"); - return 1; - } - - const Rect rect(0, 0, width, height); - - size_t offsetx = 0; - size_t offsety = 0; - - switch (dwCommand) - { - case CMD_H_CROSS: - { - // posy - // negx posz posx negz - // negy - - static const size_t s_offsetx[6] = { 2, 0, 1, 1, 1, 3 }; - static const size_t s_offsety[6] = { 1, 1, 0, 2, 1, 1 }; - - offsetx = s_offsetx[index] * width; - offsety = s_offsety[index] * height; - break; - } - - case CMD_V_CROSS: - { - // posy - // posz posx negz - // negy - // negx - - static const size_t s_offsetx[6] = { 1, 1, 1, 1, 0, 2 }; - static const size_t s_offsety[6] = { 1, 3, 0, 2, 1, 1 }; - - offsetx = s_offsetx[index] * width; - offsety = s_offsety[index] * height; - break; - } - - case CMD_H_STRIP: - // posx, negx, posy, negy, posz, negz - offsetx = index * width; - break; - - case CMD_V_STRIP: - // posx, negx, posy, negy, posz, negz - offsety = index * height; - break; - - default: - break; - } - - hr = CopyRectangle(*img, rect, *dest, dwFilter | dwFilterOpts, offsetx, offsety); - if (FAILED(hr)) - { - wprintf(L"FAILED building result image (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - } - - // Write cross/strip - wprintf(L"\nWriting %ls ", szOutputFile); - PrintInfo(result.GetMetadata()); - wprintf(L"\n"); - fflush(stdout); - - if (dwOptions & (1 << OPT_TOLOWER)) - { - std::ignore = _wcslwr_s(szOutputFile); - } - - if (~dwOptions & (1 << OPT_OVERWRITE)) - { - if (GetFileAttributesW(szOutputFile) != INVALID_FILE_ATTRIBUTES) - { - wprintf(L"\nERROR: Output file already exists, use -y to overwrite\n"); - return 1; - } - } - - hr = SaveImageFile(*dest, fileType, szOutputFile); - if (FAILED(hr)) - { - wprintf(L" FAILED (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - break; - } - - case CMD_MERGE: - { - // Capture data from our second source image - ScratchImage tempImage; - hr = Convert(*loadedImages[1]->GetImage(0, 0, 0), DXGI_FORMAT_R32G32B32A32_FLOAT, - dwFilter | dwFilterOpts | dwSRGB, TEX_THRESHOLD_DEFAULT, tempImage); - if (FAILED(hr)) - { - wprintf(L" FAILED [convert second input] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - const Image& img = *tempImage.GetImage(0, 0, 0); - - // Merge with our first source image - const Image& rgb = *loadedImages[0]->GetImage(0, 0, 0); - - const XMVECTOR zc = XMVectorSelectControl(zeroElements[0], zeroElements[1], zeroElements[2], zeroElements[3]); - const XMVECTOR oc = XMVectorSelectControl(oneElements[0], oneElements[1], oneElements[2], oneElements[3]); - - ScratchImage result; - hr = TransformImage(rgb, [&, zc, oc](XMVECTOR* outPixels, const XMVECTOR* inPixels, size_t w, size_t y) - { - const XMVECTOR *inPixels2 = reinterpret_cast(img.pixels + img.rowPitch * y); - - for (size_t j = 0; j < w; ++j) - { - XMVECTOR pixel = XMVectorPermute(inPixels[j], inPixels2[j], - permuteElements[0], permuteElements[1], permuteElements[2], permuteElements[3]); - pixel = XMVectorSelect(pixel, g_XMZero, zc); - outPixels[j] = XMVectorSelect(pixel, g_XMOne, oc); - } - }, result); - if (FAILED(hr)) - { - wprintf(L" FAILED [merge image] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - // Write merged texture - wprintf(L"\nWriting %ls ", szOutputFile); - PrintInfo(result.GetMetadata()); - wprintf(L"\n"); - fflush(stdout); - - if (dwOptions & (1 << OPT_TOLOWER)) - { - std::ignore = _wcslwr_s(szOutputFile); - } - - if (~dwOptions & (1 << OPT_OVERWRITE)) - { - if (GetFileAttributesW(szOutputFile) != INVALID_FILE_ATTRIBUTES) - { - wprintf(L"\nERROR: Output file already exists, use -y to overwrite\n"); - return 1; - } - } - - hr = SaveImageFile(*result.GetImage(0, 0, 0), fileType, szOutputFile); - if (FAILED(hr)) - { - wprintf(L" FAILED (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - break; - } - - case CMD_ARRAY_STRIP: - { - const size_t twidth = width; - const size_t theight = height * images; - - ScratchImage result; - hr = result.Initialize2D(format, twidth, theight, 1, 1); - if (FAILED(hr)) - { - wprintf(L"FAILED setting up result image (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - memset(result.GetPixels(), 0, result.GetPixelsSize()); - - auto src = loadedImages.cbegin(); - auto dest = result.GetImage(0, 0, 0); - - for (size_t index = 0; index < images; ++index) - { - auto img = (*src)->GetImage(0, index, 0); - if (!img) - { - wprintf(L"FAILED: Unexpected error\n"); - return 1; - } - - const Rect rect(0, 0, width, height); - - constexpr size_t offsetx = 0; - size_t offsety = 0; - - offsety = index * height; - - hr = CopyRectangle(*img, rect, *dest, dwFilter | dwFilterOpts, offsetx, offsety); - if (FAILED(hr)) - { - wprintf(L"FAILED building result image (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - } - - // Write array strip - wprintf(L"\nWriting %ls ", szOutputFile); - PrintInfo(result.GetMetadata()); - wprintf(L"\n"); - fflush(stdout); - - if (dwOptions & (1 << OPT_TOLOWER)) - { - std::ignore = _wcslwr_s(szOutputFile); - } - - if (~dwOptions & (1 << OPT_OVERWRITE)) - { - if (GetFileAttributesW(szOutputFile) != INVALID_FILE_ATTRIBUTES) - { - wprintf(L"\nERROR: Output file already exists, use -y to overwrite\n"); - return 1; - } - } - - hr = SaveImageFile(*dest, fileType, szOutputFile); - if (FAILED(hr)) - { - wprintf(L" FAILED (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - break; - } - default: - { - std::vector imageArray; - imageArray.reserve(images); - - for (auto it = loadedImages.cbegin(); it != loadedImages.cend(); ++it) - { - const ScratchImage* simage = it->get(); - assert(simage != nullptr); - for (size_t j = 0; j < simage->GetMetadata().arraySize; ++j) - { - const Image* img = simage->GetImage(0, j, 0); - assert(img != nullptr); - imageArray.push_back(*img); - } - } - - switch (dwCommand) - { - case CMD_CUBE: - if (imageArray[0].width > maxCube || imageArray[0].height > maxCube) - { - wprintf(L"\nWARNING: Target size exceeds maximum cube dimensions for feature level (%u)\n", maxCube); - } - break; - - case CMD_VOLUME: - if (imageArray[0].width > maxVolume || imageArray[0].height > maxVolume || imageArray.size() > maxVolume) - { - wprintf(L"\nWARNING: Target size exceeds volume extent for feature level (%u)\n", maxVolume); - } - break; - - case CMD_ARRAY: - if (imageArray[0].width > maxSize || imageArray[0].height > maxSize || imageArray.size() > maxArray) - { - wprintf(L"\nWARNING: Target size exceeds maximum size for feature level (size %u, array %u)\n", maxSize, maxArray); - } - break; - - case CMD_CUBEARRAY: - if (imageArray[0].width > maxCube || imageArray[0].height > maxCube || imageArray.size() > maxArray) - { - wprintf(L"\nWARNING: Target size exceeds maximum cube dimensions for feature level (size %u, array %u)\n", maxCube, maxArray); - } - break; - - default: - if (imageArray[0].width > maxSize || imageArray[0].height > maxSize) - { - wprintf(L"\nWARNING: Target size exceeds maximum size for feature level (%u)\n", maxSize); - } - break; - } - - ScratchImage result; - switch (dwCommand) - { - case CMD_VOLUME: - hr = result.Initialize3DFromImages(&imageArray[0], imageArray.size()); - break; - - case CMD_ARRAY: - case CMD_GIF: - hr = result.InitializeArrayFromImages(&imageArray[0], imageArray.size(), (dwOptions & (1 << OPT_USE_DX10)) != 0); - break; - - case CMD_CUBE: - case CMD_CUBEARRAY: - hr = result.InitializeCubeFromImages(&imageArray[0], imageArray.size()); - break; - - default: - break; - } - - if (FAILED(hr)) - { - wprintf(L"FAILED building result image (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - // Write texture - wprintf(L"\nWriting %ls ", szOutputFile); - PrintInfo(result.GetMetadata()); - wprintf(L"\n"); - fflush(stdout); - - if (dwOptions & (1 << OPT_TOLOWER)) - { - std::ignore = _wcslwr_s(szOutputFile); - } - - if (~dwOptions & (1 << OPT_OVERWRITE)) - { - if (GetFileAttributesW(szOutputFile) != INVALID_FILE_ATTRIBUTES) - { - wprintf(L"\nERROR: Output file already exists, use -y to overwrite\n"); - return 1; - } - } - - hr = SaveToDDSFile(result.GetImages(), result.GetImageCount(), result.GetMetadata(), - (dwOptions & (1 << OPT_USE_DX10)) ? (DDS_FLAGS_FORCE_DX10_EXT | DDS_FLAGS_FORCE_DX10_EXT_MISC2) : DDS_FLAGS_NONE, - szOutputFile); - if (FAILED(hr)) - { - wprintf(L"\nFAILED (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - break; - } - } - - return 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texassemble/texassemble.rc b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texassemble/texassemble.rc deleted file mode 100644 index 4000de9..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texassemble/texassemble.rc +++ /dev/null @@ -1,115 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#define IDC_STATIC -1 -#include - - - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (United States) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_MAIN_ICON ICON "directx.ico" - - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#define IDC_STATIC -1\r\n" - "#include \r\n" - "\r\n" - "\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,0 - PRODUCTVERSION 1,0,0,0 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "CompanyName", "Microsoft Corp" - VALUE "FileDescription", "Texture assembler command-line tool" - VALUE "FileVersion", "1.0.0.0" - VALUE "InternalName", "texassemble.exe" - VALUE "LegalCopyright", "Copyright (c) Microsoft Corp." - VALUE "OriginalFilename", "texassemble.exe" - VALUE "ProductName", "DirectXTex" - VALUE "ProductVersion", "1.0.0.0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // English (United States) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texconv/ExtendedBMP.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texconv/ExtendedBMP.cpp deleted file mode 100644 index d60f189..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texconv/ExtendedBMP.cpp +++ /dev/null @@ -1,193 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: ExtendedBMP.cpp -// -// Utilities for reading BMP files including the DXTn unofficial "FS70" -// extension created for Microsoft flight simulators. -// -// http://www.mwgfx.co.uk/programs/dxtbmp.htm -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//-------------------------------------------------------------------------------------- - -#pragma warning(push) -#pragma warning(disable : 4005) -#define WIN32_LEAN_AND_MEAN -#define NOMINMAX -#define NODRAWTEXT -#define NOMCX -#define NOSERVICE -#define NOHELP -#pragma warning(pop) - -#include - -#include -#include -#include -#include - -#include "DirectXTex.h" - -using namespace DirectX; - -namespace -{ - struct handle_closer { void operator()(HANDLE h) noexcept { if (h) CloseHandle(h); } }; - - using ScopedHandle = std::unique_ptr; - - inline HANDLE safe_handle(HANDLE h) noexcept { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; } - - HRESULT ReadData(_In_z_ const wchar_t* szFile, std::unique_ptr& blob, size_t& blobSize) - { - blob.reset(); - - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); - #else - ScopedHandle hFile(safe_handle(CreateFileW(szFile, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, - FILE_FLAG_SEQUENTIAL_SCAN, nullptr))); - #endif - if (!hFile) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - // Get the file size - FILE_STANDARD_INFO fileInfo; - if (!GetFileInformationByHandleEx(hFile.get(), FileStandardInfo, &fileInfo, sizeof(fileInfo))) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - // File is too big for 32-bit allocation, so reject read (4 GB should be plenty large enough) - if (fileInfo.EndOfFile.HighPart > 0) - { - return HRESULT_FROM_WIN32(ERROR_FILE_TOO_LARGE); - } - - // Zero-sized files assumed to be invalid - if (fileInfo.EndOfFile.LowPart < 1) - { - return E_FAIL; - } - - // Read file - blob.reset(new (std::nothrow) uint8_t[fileInfo.EndOfFile.LowPart]); - if (!blob) - { - return E_OUTOFMEMORY; - } - - DWORD bytesRead = 0; - if (!ReadFile(hFile.get(), blob.get(), fileInfo.EndOfFile.LowPart, &bytesRead, nullptr)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesRead != fileInfo.EndOfFile.LowPart) - { - return E_FAIL; - } - - blobSize = fileInfo.EndOfFile.LowPart; - - return S_OK; - } - - HRESULT LoadFromExtendedBMPMemory( - _In_reads_bytes_(size) const void* pSource, - _In_ size_t size, - _Out_opt_ TexMetadata* metadata, - _Out_ ScratchImage& image) - { - // This loads from non-standard BMP files that are not supported by WIC - image.Release(); - - if (size < (sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER))) - return E_FAIL; - - // Valid BMP files always start with 'BM' at the top - auto filehdr = reinterpret_cast(pSource); - if (filehdr->bfType != 0x4D42) - return E_FAIL; - - if (size < filehdr->bfOffBits) - return E_FAIL; - - auto header = reinterpret_cast(reinterpret_cast(pSource) + sizeof(BITMAPFILEHEADER)); - if (header->biSize != sizeof(BITMAPINFOHEADER)) - return E_FAIL; - - if (header->biWidth < 1 || header->biHeight < 1 || header->biPlanes != 1 || header->biBitCount != 16) - { - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - - DXGI_FORMAT format = DXGI_FORMAT_UNKNOWN; - switch (header->biCompression) - { - case 0x31545844: // FourCC "DXT1" - format = DXGI_FORMAT_BC1_UNORM; - break; - case 0x33545844: // FourCC "DXT3" - format = DXGI_FORMAT_BC2_UNORM; - break; - case 0x35545844: // FourCC "DXT5" - format = DXGI_FORMAT_BC3_UNORM; - break; - - default: - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - - HRESULT hr = image.Initialize2D(format, size_t(header->biWidth), size_t(header->biHeight), 1, 1); - if (FAILED(hr)) - return hr; - - if (header->biSizeImage != image.GetPixelsSize()) - return E_UNEXPECTED; - - const size_t remaining = size - filehdr->bfOffBits; - if (!remaining) - return E_FAIL; - - if (remaining < image.GetPixelsSize()) - return E_UNEXPECTED; - - auto pixels = reinterpret_cast(pSource) + filehdr->bfOffBits; - - memcpy(image.GetPixels(), pixels, image.GetPixelsSize()); - - if (metadata) - { - *metadata = image.GetMetadata(); - } - - return S_OK; - } -} - -HRESULT __cdecl LoadFromBMPEx( - _In_z_ const wchar_t* szFile, - _In_ WIC_FLAGS flags, - _Out_opt_ TexMetadata* metadata, - _Out_ ScratchImage& image) noexcept -{ - std::unique_ptr bmpData; - size_t bmpSize; - HRESULT hr = ReadData(szFile, bmpData, bmpSize); - if (FAILED(hr)) - return hr; - - hr = LoadFromWICMemory(bmpData.get(), bmpSize, flags, metadata, image); - if (FAILED(hr)) - { - hr = LoadFromExtendedBMPMemory(bmpData.get(), bmpSize, metadata, image); - } - - return hr; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texconv/PortablePixMap.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texconv/PortablePixMap.cpp deleted file mode 100644 index c31768d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texconv/PortablePixMap.cpp +++ /dev/null @@ -1,688 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: PortablePixMap.cpp -// -// Utilities for reading & writing Portable PixMap files (PPM/PFM) -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//-------------------------------------------------------------------------------------- - -#pragma warning(push) -#pragma warning(disable : 4005) -#define WIN32_LEAN_AND_MEAN -#define NOMINMAX -#define NODRAWTEXT -#define NOMCX -#define NOSERVICE -#define NOHELP -#pragma warning(pop) - -#include - -#include -#include -#include -#include -#include -#include - -#include "DirectXTex.h" - -using namespace DirectX; - -namespace -{ - struct handle_closer { void operator()(HANDLE h) noexcept { if (h) CloseHandle(h); } }; - - using ScopedHandle = std::unique_ptr; - - inline HANDLE safe_handle(HANDLE h) noexcept { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; } - - class auto_delete_file - { - public: - auto_delete_file(HANDLE hFile) noexcept : m_handle(hFile) {} - - auto_delete_file(const auto_delete_file&) = delete; - auto_delete_file& operator=(const auto_delete_file&) = delete; - - ~auto_delete_file() - { - if (m_handle) - { - FILE_DISPOSITION_INFO info = {}; - info.DeleteFile = TRUE; - std::ignore = SetFileInformationByHandle(m_handle, FileDispositionInfo, &info, sizeof(info)); - } - } - - void clear() noexcept { m_handle = nullptr; } - - private: - HANDLE m_handle; - }; - - inline size_t FindEOL(_In_z_ const char* pString, size_t max) - { - size_t pos = 0; - - //find endl - while (pos < max) - { - if (pString[pos] == '\n') - return pos; - pos++; - } - - return 0; - } - - HRESULT ReadData(_In_z_ const wchar_t* szFile, std::unique_ptr& blob, size_t& blobSize) - { - blob.reset(); - - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFile, GENERIC_READ, FILE_SHARE_READ, OPEN_EXISTING, nullptr))); - #else - ScopedHandle hFile(safe_handle(CreateFileW(szFile, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, - FILE_FLAG_SEQUENTIAL_SCAN, nullptr))); - #endif - if (!hFile) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - // Get the file size - FILE_STANDARD_INFO fileInfo; - if (!GetFileInformationByHandleEx(hFile.get(), FileStandardInfo, &fileInfo, sizeof(fileInfo))) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - // File is too big for 32-bit allocation, so reject read (4 GB should be plenty large enough) - if (fileInfo.EndOfFile.HighPart > 0) - { - return HRESULT_FROM_WIN32(ERROR_FILE_TOO_LARGE); - } - - // Zero-sized files assumed to be invalid - if (fileInfo.EndOfFile.LowPart < 1) - { - return E_FAIL; - } - - // Read file - blob.reset(new (std::nothrow) uint8_t[fileInfo.EndOfFile.LowPart]); - if (!blob) - { - return E_OUTOFMEMORY; - } - - DWORD bytesRead = 0; - if (!ReadFile(hFile.get(), blob.get(), fileInfo.EndOfFile.LowPart, &bytesRead, nullptr)) - { - return HRESULT_FROM_WIN32(GetLastError()); - } - - if (bytesRead != fileInfo.EndOfFile.LowPart) - { - return E_FAIL; - } - - blobSize = fileInfo.EndOfFile.LowPart; - - return S_OK; - } -} - - -//============================================================================ -// PPM (Portable PixMap) -// http://paulbourke.net/dataformats/ppm/ -//============================================================================ - -HRESULT __cdecl LoadFromPortablePixMap( - _In_z_ const wchar_t* szFile, - _Out_opt_ TexMetadata* metadata, - _Out_ ScratchImage& image) noexcept -{ - std::unique_ptr ppmData; - size_t ppmSize; - HRESULT hr = ReadData(szFile, ppmData, ppmSize); - if (FAILED(hr)) - return hr; - - if (ppmSize < 3) - return E_FAIL; - - if (ppmData[0] != 'P' || (ppmData[1] != '3' && ppmData[1] != '6')) - return E_FAIL; - - const bool ascii = ppmData[1] == '3'; - - enum - { - PPM_WIDTH, PPM_HEIGHT, PPM_MAX, PPM_DATA_R, PPM_DATA_G, PPM_DATA_B - }; - - int mode = PPM_WIDTH; - - auto pData = ppmData.get() + 2; - ppmSize -= 2; - - size_t width = 0; - uint32_t max = 255; - uint32_t *pixels = nullptr; - uint32_t *pixelEnd = nullptr; - - while (ppmSize > 0) - { - if (!ascii && mode == PPM_DATA_R) - { - // Binary data - if (max > 255 || !pixels || !pixelEnd) - return E_UNEXPECTED; - - if (ppmSize > 1 && '\r' == *pData) - { - pData++; - ppmSize--; - } - - if (*pData != '\n') - return E_FAIL; - - pData++; - ppmSize--; - - while (ppmSize > 0 && (pixels < pixelEnd)) - { - *pixels++ = (255 * pData[0] / max) - | ((255 * pData[1] / max) << 8) - | ((255 * pData[2] / max) << 16) - | 0xff000000; - - pData += 3; - ppmSize -= 3; - } - - return (pixels != pixelEnd) ? E_FAIL : S_OK; - } - - if (isspace(*pData)) - { - // Whitespace - pData++; - ppmSize--; - } - else if (*pData == '#') - { - // Comment - while (ppmSize > 0 && *pData != '\n') - { - pData++; - ppmSize--; - } - - if (ppmSize > 0) - { - pData++; - ppmSize--; - } - } - else - { - // ASCII number - uint32_t u = 0; - - while (ppmSize > 0 && !isspace(*pData)) - { - if (!isdigit(*pData)) - return E_FAIL; - - u = u * 10 + (*pData - '0'); - - pData++; - ppmSize--; - } - - switch (mode) - { - case PPM_WIDTH: - if (u == 0) - return E_FAIL; - - width = u; - break; - - case PPM_HEIGHT: - { - if (u == 0) - return E_FAIL; - - if (metadata) - { - *metadata = {}; - metadata->width = width; - metadata->height = u; - metadata->depth = metadata->arraySize = metadata->mipLevels = 1; - metadata->format = DXGI_FORMAT_R8G8B8A8_UNORM; - metadata->dimension = TEX_DIMENSION_TEXTURE2D; - } - - hr = image.Initialize2D(DXGI_FORMAT_R8G8B8A8_UNORM, width, u, 1, 1); - if (FAILED(hr)) - return hr; - - auto img = image.GetImage(0, 0, 0); - - pixels = reinterpret_cast(img->pixels); - pixelEnd = pixels + width * u; - } - break; - - case PPM_MAX: - if (u == 0) - return E_FAIL; - - max = u; - break; - - case PPM_DATA_R: - if (pixels >= pixelEnd) - return HRESULT_FROM_WIN32(ERROR_HANDLE_EOF); - - *pixels = ((u * 255) / max) | 0xff000000; - break; - - case PPM_DATA_G: - if (pixels >= pixelEnd) - return HRESULT_FROM_WIN32(ERROR_HANDLE_EOF); - - *pixels |= ((u * 255) / max) << 8; - break; - - case PPM_DATA_B: - if (pixels >= pixelEnd) - return HRESULT_FROM_WIN32(ERROR_HANDLE_EOF); - - *pixels |= ((u * 255) / max) << 16; - - if (++pixels == pixelEnd) - return S_OK; - - mode = PPM_DATA_R - 1; - break; - } - - mode++; - } - } - - return E_FAIL; -} - - -HRESULT __cdecl SaveToPortablePixMap( - _In_ const Image& image, - _In_z_ const wchar_t* szFile) noexcept -{ - switch (image.format) - { - case DXGI_FORMAT_R8G8B8A8_UNORM: - case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8A8_UNORM: - case DXGI_FORMAT_B8G8R8X8_UNORM: - case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - break; - - default: - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - - char header[256] = {}; - const int len = sprintf_s(header, "P6\n%zu %zu\n255\n", image.width, image.height); - if (len == -1) - return E_UNEXPECTED; - - ScratchImage tmpImage; - if (image.format == DXGI_FORMAT_R8G8B8A8_UNORM || image.format == DXGI_FORMAT_R8G8B8A8_UNORM_SRGB) - { - tmpImage.InitializeFromImage(image); - } - else - { - HRESULT hr = Convert(image, - IsSRGB(image.format) ? DXGI_FORMAT_R8G8B8A8_UNORM_SRGB : DXGI_FORMAT_R8G8B8A8_UNORM, - TEX_FILTER_DEFAULT, 0.f, tmpImage); - if (FAILED(hr)) - return hr; - } - - ScratchImage data; - data.Initialize2D(DXGI_FORMAT_R8G8B8A8_UNORM, image.width, image.height, 1, 1, CP_FLAGS_24BPP); - - const auto& img = tmpImage.GetImage(0, 0, 0); - auto dptr = data.GetPixels(); - for (size_t y = 0; y < image.height; ++y) - { - auto sptr = img->pixels + y * image.rowPitch; - - for (size_t x = 0; x < image.width; ++x) - { - *(dptr++) = sptr[0]; - *(dptr++) = sptr[1]; - *(dptr++) = sptr[2]; - sptr += 4; - } - } - -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFile, - GENERIC_WRITE, 0, CREATE_ALWAYS, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(szFile, - GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr))); -#endif - if (!hFile) - return HRESULT_FROM_WIN32(GetLastError()); - - auto_delete_file delonfail(hFile.get()); - - DWORD bytesWritten; - if (!WriteFile(hFile.get(), header, static_cast(len), &bytesWritten, nullptr)) - return HRESULT_FROM_WIN32(GetLastError()); - - if (!WriteFile(hFile.get(), data.GetPixels(), static_cast(data.GetPixelsSize()), &bytesWritten, nullptr)) - return HRESULT_FROM_WIN32(GetLastError()); - - delonfail.clear(); - - return S_OK; -} - - -//============================================================================ -// PFM (Portable Float Map) -// http://paulbourke.net/dataformats/pbmhdr/ -// https://oyranos.org/2015/03/portable-float-map-with-16-bit-half/index.html -//============================================================================ - -HRESULT __cdecl LoadFromPortablePixMapHDR( - _In_z_ const wchar_t* szFile, - _Out_opt_ TexMetadata* metadata, - _Out_ ScratchImage& image) noexcept -{ - std::unique_ptr pfmData; - size_t pfmSize; - HRESULT hr = ReadData(szFile, pfmData, pfmSize); - if (FAILED(hr)) - return hr; - - if (pfmSize < 3) - return E_FAIL; - - if (pfmData[0] != 'P' || pfmData[2] != '\n') - return E_FAIL; - - DXGI_FORMAT format = DXGI_FORMAT_UNKNOWN; - bool monochrome = false; - bool half16 = false; - switch (pfmData[1]) - { - case 'f': format = DXGI_FORMAT_R32_FLOAT; monochrome = true; break; - case 'F': format = DXGI_FORMAT_R32G32B32A32_FLOAT; break; - case 'h': format = DXGI_FORMAT_R16_FLOAT; monochrome = true; half16 = true; break; - case 'H': format = DXGI_FORMAT_R16G16B16A16_FLOAT; half16 = true; break; - default: - return E_FAIL; - } - - auto pData = reinterpret_cast(pfmData.get()) + 3; - pfmSize -= 3; - if (!pfmSize) - return E_FAIL; - - // Ignore any comment lines (some tools add them) - size_t len = 0; - while (pfmSize > 0) - { - len = FindEOL(pData, 256); - if (!len) - return E_FAIL; - - if (*pData != '#') - break; - - pData += len + 1; - pfmSize -= len + 1; - if (!pfmSize) - return E_FAIL; - } - - char dataStr[256] = {}; - char junkStr[256] = {}; - strncpy_s(dataStr, pData, len + 1); - - size_t width = 0, height = 0; - if (sscanf_s(dataStr, "%zu %zu%s", &width, &height, junkStr, 256) != 2) - return E_FAIL; - - pData += len + 1; - pfmSize -= len + 1; - if (!pfmSize) - return E_FAIL; - - // Ignore any comment lines (some tools add them) - len = 0; - while (pfmSize > 0) - { - len = FindEOL(pData, 256); - if (!len) - return E_FAIL; - - if (*pData != '#') - break; - - pData += len + 1; - pfmSize -= len + 1; - if (!pfmSize) - return E_FAIL; - } - - strncpy_s(dataStr, pData, len + 1); - - float aspectRatio = 0.f; - if (sscanf_s(dataStr, "%f%s", &aspectRatio, junkStr, 256) != 1) - return E_FAIL; - - const bool bigendian = (aspectRatio >= 0); - - pData += len + 1; - pfmSize -= len + 1; - if (!pfmSize) - return E_FAIL; - - const size_t scanline = width * (half16 ? sizeof(uint16_t) : sizeof(float)) * (monochrome ? 1 : 3); - if (pfmSize < scanline * height) - return HRESULT_FROM_WIN32(ERROR_HANDLE_EOF); - - if (metadata) - { - *metadata = {}; - metadata->width = width; - metadata->height = height; - metadata->depth = metadata->arraySize = metadata->mipLevels = 1; - metadata->format = format; - metadata->dimension = TEX_DIMENSION_TEXTURE2D; - } - - hr = image.Initialize2D(format, width, height, 1, 1); - if (FAILED(hr)) - return hr; - - auto img = image.GetImage(0, 0, 0); - - - if (half16) - { - auto sptr = reinterpret_cast(pData); - if (monochrome) - { - for (size_t y = 0; y < height; ++y) - { - auto dptr = reinterpret_cast(img->pixels + (height - y - 1) * img->rowPitch); - - for (size_t x = 0; x < width; ++x) - { - *dptr++ = (bigendian) ? _byteswap_ushort(*sptr++) : *sptr++; - } - } - } - else - { - for (size_t y = 0; y < height; ++y) - { - auto dptr = reinterpret_cast(img->pixels + (height - y - 1) * img->rowPitch); - - for (size_t x = 0; x < width; ++x) - { - if (bigendian) - { - dptr[0] = _byteswap_ushort(sptr[0]); - dptr[1] = _byteswap_ushort(sptr[1]); - dptr[2] = _byteswap_ushort(sptr[2]); - } - else - { - dptr[0] = sptr[0]; - dptr[1] = sptr[1]; - dptr[2] = sptr[2]; - } - - dptr[3] = 0x3c00; // 1.f - sptr += 3; - dptr += 4; - } - } - } - } - else - { - auto sptr = reinterpret_cast(pData); - - if (monochrome) - { - for (size_t y = 0; y < height; ++y) - { - auto dptr = reinterpret_cast(img->pixels + (height - y - 1) * img->rowPitch); - - for (size_t x = 0; x < width; ++x) - { - *dptr++ = (bigendian) ? _byteswap_ulong(*sptr++) : *sptr++; - } - } - } - else - { - for (size_t y = 0; y < height; ++y) - { - auto dptr = reinterpret_cast(img->pixels + (height - y - 1) * img->rowPitch); - - for (size_t x = 0; x < width; ++x) - { - if (bigendian) - { - dptr[0] = _byteswap_ulong(sptr[0]); - dptr[1] = _byteswap_ulong(sptr[1]); - dptr[2] = _byteswap_ulong(sptr[2]); - } - else - { - dptr[0] = sptr[0]; - dptr[1] = sptr[1]; - dptr[2] = sptr[2]; - } - - dptr[3] = 0x3f800000; // 1.f - sptr += 3; - dptr += 4; - } - } - } - } - - return S_OK; -} - - -// We always save as PF or Pf as that's the most common PFM implementation. -HRESULT __cdecl SaveToPortablePixMapHDR( - _In_ const Image& image, - _In_z_ const wchar_t* szFile) noexcept -{ - switch (image.format) - { - case DXGI_FORMAT_R32G32B32A32_FLOAT: - case DXGI_FORMAT_R32G32B32_FLOAT: - case DXGI_FORMAT_R16G16B16A16_FLOAT: - case DXGI_FORMAT_R32_FLOAT: - break; - - default: - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - - char header[256] = {}; - const int len = sprintf_s(header, "P%c\n%zu %zu\n-1.000000\n", - (image.format == DXGI_FORMAT_R32_FLOAT) ? 'f' : 'F', - image.width, image.height); - - if (len == -1) - return E_UNEXPECTED; - - ScratchImage tmpImage; - if (image.format == DXGI_FORMAT_R32_FLOAT || image.format == DXGI_FORMAT_R32G32B32_FLOAT) - { - tmpImage.InitializeFromImage(image); - } - else - { - HRESULT hr = Convert(image, DXGI_FORMAT_R32G32B32_FLOAT, TEX_FILTER_DEFAULT, 0.f, tmpImage); - if (FAILED(hr)) - return hr; - } - - ScratchImage flipImage; - HRESULT hr = FlipRotate(*tmpImage.GetImage(0, 0, 0), TEX_FR_FLIP_VERTICAL, flipImage); - if (FAILED(hr)) - return hr; - - tmpImage.Release(); - -#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) - ScopedHandle hFile(safe_handle(CreateFile2(szFile, - GENERIC_WRITE, 0, CREATE_ALWAYS, nullptr))); -#else - ScopedHandle hFile(safe_handle(CreateFileW(szFile, - GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr))); -#endif - if (!hFile) - return HRESULT_FROM_WIN32(GetLastError()); - - auto_delete_file delonfail(hFile.get()); - - DWORD bytesWritten; - if (!WriteFile(hFile.get(), header, static_cast(len), &bytesWritten, nullptr)) - return HRESULT_FROM_WIN32(GetLastError()); - - if (!WriteFile(hFile.get(), flipImage.GetPixels(), static_cast(flipImage.GetPixelsSize()), &bytesWritten, nullptr)) - return HRESULT_FROM_WIN32(GetLastError()); - - delonfail.clear(); - - return S_OK; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texconv/Texconv.rc b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texconv/Texconv.rc deleted file mode 100644 index e030300..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texconv/Texconv.rc +++ /dev/null @@ -1,115 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#define IDC_STATIC -1 -#include - - - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (United States) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_MAIN_ICON ICON "directx.ico" - - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#define IDC_STATIC -1\r\n" - "#include \r\n" - "\r\n" - "\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,0 - PRODUCTVERSION 1,0,0,0 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "CompanyName", "Microsoft Corp" - VALUE "FileDescription", "Texture conversion command-line tool" - VALUE "FileVersion", "1.0.0.0" - VALUE "InternalName", "texconv.exe" - VALUE "LegalCopyright", "Copyright (c) Microsoft Corp." - VALUE "OriginalFilename", "texconv.exe" - VALUE "ProductName", "DirectXTex" - VALUE "ProductVersion", "1.0.0.0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // English (United States) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texconv/Texconv_Desktop_2019.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texconv/Texconv_Desktop_2019.vcxproj deleted file mode 100644 index 6063c05..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texconv/Texconv_Desktop_2019.vcxproj +++ /dev/null @@ -1,299 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Profile - Win32 - - - Profile - x64 - - - Release - Win32 - - - Release - x64 - - - - texconv - {C3A65381-8FD3-4F69-B29E-654B4B0ED136} - texconv - Win32Proj - 10.0 - - - - Application - true - Unicode - v142 - - - Application - true - Unicode - v142 - - - Application - true - Unicode - v142 - - - Application - true - Unicode - v142 - - - Application - true - Unicode - v142 - - - Application - true - Unicode - v142 - - - - - - - - - - - - - - - - - - - - - - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - texconv - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - texconv - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - texconv - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - texconv - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - texconv - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - texconv - true - - - - Level4 - Disabled - MultiThreadedDebugDLL - true - Fast - StreamingSIMDExtensions2 - ..\DirectXTex;%(AdditionalIncludeDirectories) - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - WIN32;_DEBUG;DEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - true - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - Console - true - true - - - false - - - - - Level4 - Disabled - MultiThreadedDebugDLL - true - Fast - ..\DirectXTex;%(AdditionalIncludeDirectories) - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - WIN32;_DEBUG;DEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - true - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - Console - true - - - false - - - - - Level4 - MaxSpeed - true - Fast - StreamingSIMDExtensions2 - ..\DirectXTex;%(AdditionalIncludeDirectories) - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - WIN32;NDEBUG;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - Guard - true - true - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - true - - - false - - - - - Level4 - MaxSpeed - true - Fast - ..\DirectXTex;%(AdditionalIncludeDirectories) - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - WIN32;NDEBUG;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - Guard - true - true - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - - - false - - - - - Level4 - MaxSpeed - true - Fast - StreamingSIMDExtensions2 - ..\DirectXTex;%(AdditionalIncludeDirectories) - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - WIN32;NDEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - true - Guard - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - true - - - false - - - - - Level4 - MaxSpeed - true - Fast - ..\DirectXTex;%(AdditionalIncludeDirectories) - /Zc:twoPhase- /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - WIN32;NDEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - true - Guard - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - - - false - - - - - - - - - - - - - {371b9fa9-4c90-4ac6-a123-aced756d6c77} - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texconv/Texconv_Desktop_2019.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texconv/Texconv_Desktop_2019.vcxproj.filters deleted file mode 100644 index 80e1359..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texconv/Texconv_Desktop_2019.vcxproj.filters +++ /dev/null @@ -1,19 +0,0 @@ - - - - - {8e114980-c1a3-4ada-ad7c-83caadf5daeb} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - - - - - - - - Resource Files - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texconv/Texconv_Desktop_2022.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texconv/Texconv_Desktop_2022.vcxproj deleted file mode 100644 index 0faf9e7..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texconv/Texconv_Desktop_2022.vcxproj +++ /dev/null @@ -1,305 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Profile - Win32 - - - Profile - x64 - - - Release - Win32 - - - Release - x64 - - - - texconv - {C3A65381-8FD3-4F69-B29E-654B4B0ED136} - texconv - Win32Proj - 10.0 - - - - Application - true - Unicode - v143 - - - Application - true - Unicode - v143 - - - Application - true - Unicode - v143 - - - Application - true - Unicode - v143 - - - Application - true - Unicode - v143 - - - Application - true - Unicode - v143 - - - - - - - - - - - - - - - - - - - - - - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - texconv - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - texconv - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - texconv - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - texconv - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - texconv - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - texconv - true - - - - Level4 - Disabled - MultiThreadedDebugDLL - true - Fast - StreamingSIMDExtensions2 - ..\DirectXTex;%(AdditionalIncludeDirectories) - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - WIN32;_DEBUG;DEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - true - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - Console - true - true - true - - - false - - - - - Level4 - Disabled - MultiThreadedDebugDLL - true - Fast - ..\DirectXTex;%(AdditionalIncludeDirectories) - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - WIN32;_DEBUG;DEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - true - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - Console - true - true - - - false - - - - - Level4 - MaxSpeed - true - Fast - StreamingSIMDExtensions2 - ..\DirectXTex;%(AdditionalIncludeDirectories) - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - WIN32;NDEBUG;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - Guard - true - true - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - true - true - - - false - - - - - Level4 - MaxSpeed - true - Fast - ..\DirectXTex;%(AdditionalIncludeDirectories) - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - WIN32;NDEBUG;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - Guard - true - true - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - true - - - false - - - - - Level4 - MaxSpeed - true - Fast - StreamingSIMDExtensions2 - ..\DirectXTex;%(AdditionalIncludeDirectories) - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - WIN32;NDEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - true - Guard - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - true - true - - - false - - - - - Level4 - MaxSpeed - true - Fast - ..\DirectXTex;%(AdditionalIncludeDirectories) - /Zc:twoPhase- /Zc:__cplusplus %(AdditionalOptions) - WIN32;NDEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - true - Guard - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - true - - - false - - - - - - - - - - - - - {371b9fa9-4c90-4ac6-a123-aced756d6c77} - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texconv/Texconv_Desktop_2022.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texconv/Texconv_Desktop_2022.vcxproj.filters deleted file mode 100644 index 80e1359..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texconv/Texconv_Desktop_2022.vcxproj.filters +++ /dev/null @@ -1,19 +0,0 @@ - - - - - {8e114980-c1a3-4ada-ad7c-83caadf5daeb} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - - - - - - - - Resource Files - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texconv/directx.ico b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texconv/directx.ico deleted file mode 100644 index bc43c1b..0000000 Binary files a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texconv/directx.ico and /dev/null differ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texconv/texconv.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texconv/texconv.cpp deleted file mode 100644 index 38c1d51..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texconv/texconv.cpp +++ /dev/null @@ -1,3743 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: TexConv.cpp -// -// DirectX Texture Converter -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//-------------------------------------------------------------------------------------- - -#pragma warning(push) -#pragma warning(disable : 4005) -#define WIN32_LEAN_AND_MEAN -#define NOMINMAX -#define NODRAWTEXT -#define NOMCX -#define NOSERVICE -#define NOHELP -#pragma warning(pop) - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include - -#pragma warning(disable : 4619 4616 26812) - -#include "DirectXTex.h" - -#include "DirectXPackedVector.h" - -//Uncomment to add support for OpenEXR (.exr) -//#define USE_OPENEXR - -#ifdef USE_OPENEXR -// See for details -#include "DirectXTexEXR.h" -#endif - -using namespace DirectX; -using namespace DirectX::PackedVector; -using Microsoft::WRL::ComPtr; - -namespace -{ - enum OPTIONS : uint64_t - { - OPT_RECURSIVE = 1, - OPT_FILELIST, - OPT_WIDTH, - OPT_HEIGHT, - OPT_MIPLEVELS, - OPT_FORMAT, - OPT_FILTER, - OPT_SRGBI, - OPT_SRGBO, - OPT_SRGB, - OPT_PREFIX, - OPT_SUFFIX, - OPT_OUTPUTDIR, - OPT_TOLOWER, - OPT_OVERWRITE, - OPT_FILETYPE, - OPT_HFLIP, - OPT_VFLIP, - OPT_DDS_DWORD_ALIGN, - OPT_DDS_BAD_DXTN_TAILS, - OPT_USE_DX10, - OPT_USE_DX9, - OPT_TGA20, - OPT_WIC_QUALITY, - OPT_WIC_LOSSLESS, - OPT_WIC_MULTIFRAME, - OPT_NOLOGO, - OPT_TIMING, - OPT_SEPALPHA, - OPT_NO_WIC, - OPT_TYPELESS_UNORM, - OPT_TYPELESS_FLOAT, - OPT_PREMUL_ALPHA, - OPT_DEMUL_ALPHA, - OPT_EXPAND_LUMINANCE, - OPT_TA_WRAP, - OPT_TA_MIRROR, - OPT_FORCE_SINGLEPROC, - OPT_GPU, - OPT_NOGPU, - OPT_FEATURE_LEVEL, - OPT_FIT_POWEROF2, - OPT_ALPHA_THRESHOLD, - OPT_ALPHA_WEIGHT, - OPT_NORMAL_MAP, - OPT_NORMAL_MAP_AMPLITUDE, - OPT_BC_COMPRESS, - OPT_COLORKEY, - OPT_TONEMAP, - OPT_X2_BIAS, - OPT_PRESERVE_ALPHA_COVERAGE, - OPT_INVERT_Y, - OPT_RECONSTRUCT_Z, - OPT_ROTATE_COLOR, - OPT_PAPER_WHITE_NITS, - OPT_BCNONMULT4FIX, - OPT_SWIZZLE, - OPT_MAX - }; - - enum - { - ROTATE_709_TO_HDR10 = 1, - ROTATE_HDR10_TO_709, - ROTATE_709_TO_2020, - ROTATE_2020_TO_709, - ROTATE_P3D65_TO_HDR10, - ROTATE_P3D65_TO_2020, - ROTATE_709_TO_P3D65, - ROTATE_P3D65_TO_709, - }; - - static_assert(OPT_MAX <= 64, "dwOptions is a unsigned int bitfield"); - - struct SConversion - { - wchar_t szSrc[MAX_PATH]; - wchar_t szFolder[MAX_PATH]; - }; - - template - struct SValue - { - const wchar_t* name; - T value; - }; - - const SValue g_pOptions[] = - { - { L"r", OPT_RECURSIVE }, - { L"flist", OPT_FILELIST }, - { L"w", OPT_WIDTH }, - { L"h", OPT_HEIGHT }, - { L"m", OPT_MIPLEVELS }, - { L"f", OPT_FORMAT }, - { L"if", OPT_FILTER }, - { L"srgbi", OPT_SRGBI }, - { L"srgbo", OPT_SRGBO }, - { L"srgb", OPT_SRGB }, - { L"px", OPT_PREFIX }, - { L"sx", OPT_SUFFIX }, - { L"o", OPT_OUTPUTDIR }, - { L"l", OPT_TOLOWER }, - { L"y", OPT_OVERWRITE }, - { L"ft", OPT_FILETYPE }, - { L"hflip", OPT_HFLIP }, - { L"vflip", OPT_VFLIP }, - { L"dword", OPT_DDS_DWORD_ALIGN }, - { L"badtails", OPT_DDS_BAD_DXTN_TAILS }, - { L"dx10", OPT_USE_DX10 }, - { L"dx9", OPT_USE_DX9 }, - { L"tga20", OPT_TGA20 }, - { L"wicq", OPT_WIC_QUALITY }, - { L"wiclossless", OPT_WIC_LOSSLESS }, - { L"wicmulti", OPT_WIC_MULTIFRAME }, - { L"nologo", OPT_NOLOGO }, - { L"timing", OPT_TIMING }, - { L"sepalpha", OPT_SEPALPHA }, - { L"keepcoverage", OPT_PRESERVE_ALPHA_COVERAGE }, - { L"nowic", OPT_NO_WIC }, - { L"tu", OPT_TYPELESS_UNORM }, - { L"tf", OPT_TYPELESS_FLOAT }, - { L"pmalpha", OPT_PREMUL_ALPHA }, - { L"alpha", OPT_DEMUL_ALPHA }, - { L"xlum", OPT_EXPAND_LUMINANCE }, - { L"wrap", OPT_TA_WRAP }, - { L"mirror", OPT_TA_MIRROR }, - { L"singleproc", OPT_FORCE_SINGLEPROC }, - { L"gpu", OPT_GPU }, - { L"nogpu", OPT_NOGPU }, - { L"fl", OPT_FEATURE_LEVEL }, - { L"pow2", OPT_FIT_POWEROF2 }, - { L"at", OPT_ALPHA_THRESHOLD }, - { L"aw", OPT_ALPHA_WEIGHT }, - { L"nmap", OPT_NORMAL_MAP }, - { L"nmapamp", OPT_NORMAL_MAP_AMPLITUDE }, - { L"bc", OPT_BC_COMPRESS }, - { L"c", OPT_COLORKEY }, - { L"tonemap", OPT_TONEMAP }, - { L"x2bias", OPT_X2_BIAS }, - { L"inverty", OPT_INVERT_Y }, - { L"reconstructz", OPT_RECONSTRUCT_Z }, - { L"rotatecolor", OPT_ROTATE_COLOR }, - { L"nits", OPT_PAPER_WHITE_NITS }, - { L"fixbc4x4", OPT_BCNONMULT4FIX }, - { L"swizzle", OPT_SWIZZLE }, - { nullptr, 0 } - }; - -#define DEFFMT(fmt) { L## #fmt, DXGI_FORMAT_ ## fmt } - - const SValue g_pFormats[] = - { - // List does not include _TYPELESS or depth/stencil formats - DEFFMT(R32G32B32A32_FLOAT), - DEFFMT(R32G32B32A32_UINT), - DEFFMT(R32G32B32A32_SINT), - DEFFMT(R32G32B32_FLOAT), - DEFFMT(R32G32B32_UINT), - DEFFMT(R32G32B32_SINT), - DEFFMT(R16G16B16A16_FLOAT), - DEFFMT(R16G16B16A16_UNORM), - DEFFMT(R16G16B16A16_UINT), - DEFFMT(R16G16B16A16_SNORM), - DEFFMT(R16G16B16A16_SINT), - DEFFMT(R32G32_FLOAT), - DEFFMT(R32G32_UINT), - DEFFMT(R32G32_SINT), - DEFFMT(R10G10B10A2_UNORM), - DEFFMT(R10G10B10A2_UINT), - DEFFMT(R11G11B10_FLOAT), - DEFFMT(R8G8B8A8_UNORM), - DEFFMT(R8G8B8A8_UNORM_SRGB), - DEFFMT(R8G8B8A8_UINT), - DEFFMT(R8G8B8A8_SNORM), - DEFFMT(R8G8B8A8_SINT), - DEFFMT(R16G16_FLOAT), - DEFFMT(R16G16_UNORM), - DEFFMT(R16G16_UINT), - DEFFMT(R16G16_SNORM), - DEFFMT(R16G16_SINT), - DEFFMT(R32_FLOAT), - DEFFMT(R32_UINT), - DEFFMT(R32_SINT), - DEFFMT(R8G8_UNORM), - DEFFMT(R8G8_UINT), - DEFFMT(R8G8_SNORM), - DEFFMT(R8G8_SINT), - DEFFMT(R16_FLOAT), - DEFFMT(R16_UNORM), - DEFFMT(R16_UINT), - DEFFMT(R16_SNORM), - DEFFMT(R16_SINT), - DEFFMT(R8_UNORM), - DEFFMT(R8_UINT), - DEFFMT(R8_SNORM), - DEFFMT(R8_SINT), - DEFFMT(A8_UNORM), - DEFFMT(R9G9B9E5_SHAREDEXP), - DEFFMT(R8G8_B8G8_UNORM), - DEFFMT(G8R8_G8B8_UNORM), - DEFFMT(BC1_UNORM), - DEFFMT(BC1_UNORM_SRGB), - DEFFMT(BC2_UNORM), - DEFFMT(BC2_UNORM_SRGB), - DEFFMT(BC3_UNORM), - DEFFMT(BC3_UNORM_SRGB), - DEFFMT(BC4_UNORM), - DEFFMT(BC4_SNORM), - DEFFMT(BC5_UNORM), - DEFFMT(BC5_SNORM), - DEFFMT(B5G6R5_UNORM), - DEFFMT(B5G5R5A1_UNORM), - - // DXGI 1.1 formats - DEFFMT(B8G8R8A8_UNORM), - DEFFMT(B8G8R8X8_UNORM), - DEFFMT(R10G10B10_XR_BIAS_A2_UNORM), - DEFFMT(B8G8R8A8_UNORM_SRGB), - DEFFMT(B8G8R8X8_UNORM_SRGB), - DEFFMT(BC6H_UF16), - DEFFMT(BC6H_SF16), - DEFFMT(BC7_UNORM), - DEFFMT(BC7_UNORM_SRGB), - - // DXGI 1.2 formats - DEFFMT(AYUV), - DEFFMT(Y410), - DEFFMT(Y416), - DEFFMT(YUY2), - DEFFMT(Y210), - DEFFMT(Y216), - // No support for legacy paletted video formats (AI44, IA44, P8, A8P8) - DEFFMT(B4G4R4A4_UNORM), - - { nullptr, DXGI_FORMAT_UNKNOWN } - }; - - const SValue g_pFormatAliases[] = - { - { L"DXT1", DXGI_FORMAT_BC1_UNORM }, - { L"DXT2", DXGI_FORMAT_BC2_UNORM }, - { L"DXT3", DXGI_FORMAT_BC2_UNORM }, - { L"DXT4", DXGI_FORMAT_BC3_UNORM }, - { L"DXT5", DXGI_FORMAT_BC3_UNORM }, - - { L"RGBA", DXGI_FORMAT_R8G8B8A8_UNORM }, - { L"BGRA", DXGI_FORMAT_B8G8R8A8_UNORM }, - { L"BGR", DXGI_FORMAT_B8G8R8X8_UNORM }, - - { L"FP16", DXGI_FORMAT_R16G16B16A16_FLOAT }, - { L"FP32", DXGI_FORMAT_R32G32B32A32_FLOAT }, - - { L"BPTC", DXGI_FORMAT_BC7_UNORM }, - { L"BPTC_FLOAT", DXGI_FORMAT_BC6H_UF16 }, - - { nullptr, DXGI_FORMAT_UNKNOWN } - }; - - const SValue g_pReadOnlyFormats[] = - { - DEFFMT(R32G32B32A32_TYPELESS), - DEFFMT(R32G32B32_TYPELESS), - DEFFMT(R16G16B16A16_TYPELESS), - DEFFMT(R32G32_TYPELESS), - DEFFMT(R32G8X24_TYPELESS), - DEFFMT(D32_FLOAT_S8X24_UINT), - DEFFMT(R32_FLOAT_X8X24_TYPELESS), - DEFFMT(X32_TYPELESS_G8X24_UINT), - DEFFMT(R10G10B10A2_TYPELESS), - DEFFMT(R8G8B8A8_TYPELESS), - DEFFMT(R16G16_TYPELESS), - DEFFMT(R32_TYPELESS), - DEFFMT(D32_FLOAT), - DEFFMT(R24G8_TYPELESS), - DEFFMT(D24_UNORM_S8_UINT), - DEFFMT(R24_UNORM_X8_TYPELESS), - DEFFMT(X24_TYPELESS_G8_UINT), - DEFFMT(R8G8_TYPELESS), - DEFFMT(R16_TYPELESS), - DEFFMT(R8_TYPELESS), - DEFFMT(BC1_TYPELESS), - DEFFMT(BC2_TYPELESS), - DEFFMT(BC3_TYPELESS), - DEFFMT(BC4_TYPELESS), - DEFFMT(BC5_TYPELESS), - - // DXGI 1.1 formats - DEFFMT(B8G8R8A8_TYPELESS), - DEFFMT(B8G8R8X8_TYPELESS), - DEFFMT(BC6H_TYPELESS), - DEFFMT(BC7_TYPELESS), - - // DXGI 1.2 formats - DEFFMT(NV12), - DEFFMT(P010), - DEFFMT(P016), - DEFFMT(420_OPAQUE), - DEFFMT(NV11), - - // DXGI 1.3 formats - { L"P208", DXGI_FORMAT(130) }, - { L"V208", DXGI_FORMAT(131) }, - { L"V408", DXGI_FORMAT(132) }, - - { nullptr, DXGI_FORMAT_UNKNOWN } - }; - - const SValue g_pFilters[] = - { - { L"POINT", TEX_FILTER_POINT }, - { L"LINEAR", TEX_FILTER_LINEAR }, - { L"CUBIC", TEX_FILTER_CUBIC }, - { L"FANT", TEX_FILTER_FANT }, - { L"BOX", TEX_FILTER_BOX }, - { L"TRIANGLE", TEX_FILTER_TRIANGLE }, - { L"POINT_DITHER", TEX_FILTER_POINT | TEX_FILTER_DITHER }, - { L"LINEAR_DITHER", TEX_FILTER_LINEAR | TEX_FILTER_DITHER }, - { L"CUBIC_DITHER", TEX_FILTER_CUBIC | TEX_FILTER_DITHER }, - { L"FANT_DITHER", TEX_FILTER_FANT | TEX_FILTER_DITHER }, - { L"BOX_DITHER", TEX_FILTER_BOX | TEX_FILTER_DITHER }, - { L"TRIANGLE_DITHER", TEX_FILTER_TRIANGLE | TEX_FILTER_DITHER }, - { L"POINT_DITHER_DIFFUSION", TEX_FILTER_POINT | TEX_FILTER_DITHER_DIFFUSION }, - { L"LINEAR_DITHER_DIFFUSION", TEX_FILTER_LINEAR | TEX_FILTER_DITHER_DIFFUSION }, - { L"CUBIC_DITHER_DIFFUSION", TEX_FILTER_CUBIC | TEX_FILTER_DITHER_DIFFUSION }, - { L"FANT_DITHER_DIFFUSION", TEX_FILTER_FANT | TEX_FILTER_DITHER_DIFFUSION }, - { L"BOX_DITHER_DIFFUSION", TEX_FILTER_BOX | TEX_FILTER_DITHER_DIFFUSION }, - { L"TRIANGLE_DITHER_DIFFUSION", TEX_FILTER_TRIANGLE | TEX_FILTER_DITHER_DIFFUSION }, - { nullptr, TEX_FILTER_DEFAULT } - }; - - const SValue g_pRotateColor[] = - { - { L"709to2020", ROTATE_709_TO_2020 }, - { L"2020to709", ROTATE_2020_TO_709 }, - { L"709toHDR10", ROTATE_709_TO_HDR10 }, - { L"HDR10to709", ROTATE_HDR10_TO_709 }, - { L"P3D65to2020", ROTATE_P3D65_TO_2020 }, - { L"P3D65toHDR10", ROTATE_P3D65_TO_HDR10 }, - { L"709toP3D65", ROTATE_709_TO_P3D65 }, - { L"P3D65to709", ROTATE_P3D65_TO_709 }, - { nullptr, 0 }, - }; - -#define CODEC_DDS 0xFFFF0001 -#define CODEC_TGA 0xFFFF0002 -#define CODEC_HDP 0xFFFF0003 -#define CODEC_JXR 0xFFFF0004 -#define CODEC_HDR 0xFFFF0005 -#define CODEC_PPM 0xFFFF0006 -#define CODEC_PFM 0xFFFF0007 - -#ifdef USE_OPENEXR -#define CODEC_EXR 0xFFFF0008 -#endif - - const SValue g_pSaveFileTypes[] = // valid formats to write to - { - { L"bmp", WIC_CODEC_BMP }, - { L"jpg", WIC_CODEC_JPEG }, - { L"jpeg", WIC_CODEC_JPEG }, - { L"png", WIC_CODEC_PNG }, - { L"dds", CODEC_DDS }, - { L"tga", CODEC_TGA }, - { L"hdr", CODEC_HDR }, - { L"tif", WIC_CODEC_TIFF }, - { L"tiff", WIC_CODEC_TIFF }, - { L"wdp", WIC_CODEC_WMP }, - { L"hdp", CODEC_HDP }, - { L"jxr", CODEC_JXR }, - { L"ppm", CODEC_PPM }, - { L"pfm", CODEC_PFM }, - #ifdef USE_OPENEXR - { L"exr", CODEC_EXR }, - #endif - { L"heic", WIC_CODEC_HEIF }, - { L"heif", WIC_CODEC_HEIF }, - { nullptr, CODEC_DDS } - }; - - const SValue g_pFeatureLevels[] = // valid feature levels for -fl for maximimum size - { - { L"9.1", 2048 }, - { L"9.2", 2048 }, - { L"9.3", 4096 }, - { L"10.0", 8192 }, - { L"10.1", 8192 }, - { L"11.0", 16384 }, - { L"11.1", 16384 }, - { L"12.0", 16384 }, - { L"12.1", 16384 }, - { L"12.2", 16384 }, - { nullptr, 0 }, - }; -} - -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -HRESULT __cdecl LoadFromBMPEx( - _In_z_ const wchar_t* szFile, - _In_ WIC_FLAGS flags, - _Out_opt_ TexMetadata* metadata, - _Out_ ScratchImage& image) noexcept; - -HRESULT __cdecl LoadFromPortablePixMap( - _In_z_ const wchar_t* szFile, - _Out_opt_ TexMetadata* metadata, - _Out_ ScratchImage& image) noexcept; - -HRESULT __cdecl SaveToPortablePixMap( - _In_ const Image& image, - _In_z_ const wchar_t* szFile) noexcept; - -HRESULT __cdecl LoadFromPortablePixMapHDR( - _In_z_ const wchar_t* szFile, - _Out_opt_ TexMetadata* metadata, - _Out_ ScratchImage& image) noexcept; - -HRESULT __cdecl SaveToPortablePixMapHDR( - _In_ const Image& image, - _In_z_ const wchar_t* szFile) noexcept; - -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -#pragma warning( disable : 4616 6211 ) - -namespace -{ - inline HANDLE safe_handle(HANDLE h) noexcept { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; } - - struct find_closer { void operator()(HANDLE h) noexcept { assert(h != INVALID_HANDLE_VALUE); if (h) FindClose(h); } }; - - using ScopedFindHandle = std::unique_ptr; - - constexpr static bool ispow2(size_t x) - { - return ((x != 0) && !(x & (x - 1))); - } - -#ifdef _PREFAST_ -#pragma prefast(disable : 26018, "Only used with static internal arrays") -#endif - - template - T LookupByName(const wchar_t *pName, const SValue *pArray) - { - while (pArray->name) - { - if (!_wcsicmp(pName, pArray->name)) - return pArray->value; - - pArray++; - } - - return 0; - } - - template - const wchar_t* LookupByValue(T value, const SValue *pArray) - { - while (pArray->name) - { - if (value == pArray->value) - return pArray->name; - - pArray++; - } - - return L""; - } - - void SearchForFiles(const wchar_t* path, std::list& files, bool recursive, const wchar_t* folder) - { - // Process files - WIN32_FIND_DATAW findData = {}; - ScopedFindHandle hFile(safe_handle(FindFirstFileExW(path, - FindExInfoBasic, &findData, - FindExSearchNameMatch, nullptr, - FIND_FIRST_EX_LARGE_FETCH))); - if (hFile) - { - for (;;) - { - if (!(findData.dwFileAttributes & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_DIRECTORY))) - { - wchar_t drive[_MAX_DRIVE] = {}; - wchar_t dir[_MAX_DIR] = {}; - _wsplitpath_s(path, drive, _MAX_DRIVE, dir, _MAX_DIR, nullptr, 0, nullptr, 0); - - SConversion conv = {}; - _wmakepath_s(conv.szSrc, drive, dir, findData.cFileName, nullptr); - if (folder) - { - wcscpy_s(conv.szFolder, folder); - } - files.push_back(conv); - } - - if (!FindNextFileW(hFile.get(), &findData)) - break; - } - } - - // Process directories - if (recursive) - { - wchar_t searchDir[MAX_PATH] = {}; - { - wchar_t drive[_MAX_DRIVE] = {}; - wchar_t dir[_MAX_DIR] = {}; - _wsplitpath_s(path, drive, _MAX_DRIVE, dir, _MAX_DIR, nullptr, 0, nullptr, 0); - _wmakepath_s(searchDir, drive, dir, L"*", nullptr); - } - - hFile.reset(safe_handle(FindFirstFileExW(searchDir, - FindExInfoBasic, &findData, - FindExSearchLimitToDirectories, nullptr, - FIND_FIRST_EX_LARGE_FETCH))); - if (!hFile) - return; - - for (;;) - { - if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - { - if (findData.cFileName[0] != L'.') - { - wchar_t subdir[MAX_PATH] = {}; - auto subfolder = (folder) - ? (std::wstring(folder) + std::wstring(findData.cFileName) + L"\\") - : (std::wstring(findData.cFileName) + L"\\"); - { - wchar_t drive[_MAX_DRIVE] = {}; - wchar_t dir[_MAX_DIR] = {}; - wchar_t fname[_MAX_FNAME] = {}; - wchar_t ext[_MAX_FNAME] = {}; - _wsplitpath_s(path, drive, dir, fname, ext); - wcscat_s(dir, findData.cFileName); - _wmakepath_s(subdir, drive, dir, fname, ext); - } - - SearchForFiles(subdir, files, recursive, subfolder.c_str()); - } - } - - if (!FindNextFileW(hFile.get(), &findData)) - break; - } - } - } - - void ProcessFileList(std::wifstream& inFile, std::list& files) - { - std::list flist; - std::set excludes; - wchar_t fname[1024] = {}; - for (;;) - { - inFile >> fname; - if (!inFile) - break; - - if (*fname == L'#') - { - // Comment - } - else if (*fname == L'-') - { - if (flist.empty()) - { - wprintf(L"WARNING: Ignoring the line '%ls' in -flist\n", fname); - } - else - { - if (wcspbrk(fname, L"?*") != nullptr) - { - std::list removeFiles; - SearchForFiles(&fname[1], removeFiles, false, nullptr); - - for (auto it : removeFiles) - { - _wcslwr_s(it.szSrc); - excludes.insert(it.szSrc); - } - } - else - { - std::wstring name = (fname + 1); - std::transform(name.begin(), name.end(), name.begin(), towlower); - excludes.insert(name); - } - } - } - else if (wcspbrk(fname, L"?*") != nullptr) - { - SearchForFiles(fname, flist, false, nullptr); - } - else - { - SConversion conv = {}; - wcscpy_s(conv.szSrc, MAX_PATH, fname); - flist.push_back(conv); - } - - inFile.ignore(1000, '\n'); - } - - inFile.close(); - - if (!excludes.empty()) - { - // Remove any excluded files - for (auto it = flist.begin(); it != flist.end();) - { - std::wstring name = it->szSrc; - std::transform(name.begin(), name.end(), name.begin(), towlower); - auto item = it; - ++it; - if (excludes.find(name) != excludes.end()) - { - flist.erase(item); - } - } - } - - if (flist.empty()) - { - wprintf(L"WARNING: No file names found in -flist\n"); - } - else - { - files.splice(files.end(), flist); - } - } - - void PrintFormat(DXGI_FORMAT Format) - { - for (auto pFormat = g_pFormats; pFormat->name; pFormat++) - { - if (static_cast(pFormat->value) == Format) - { - wprintf(L"%ls", pFormat->name); - return; - } - } - - for (auto pFormat = g_pReadOnlyFormats; pFormat->name; pFormat++) - { - if (static_cast(pFormat->value) == Format) - { - wprintf(L"%ls", pFormat->name); - return; - } - } - - wprintf(L"*UNKNOWN*"); - } - - void PrintInfo(const TexMetadata& info) - { - wprintf(L" (%zux%zu", info.width, info.height); - - if (TEX_DIMENSION_TEXTURE3D == info.dimension) - wprintf(L"x%zu", info.depth); - - if (info.mipLevels > 1) - wprintf(L",%zu", info.mipLevels); - - if (info.arraySize > 1) - wprintf(L",%zu", info.arraySize); - - wprintf(L" "); - PrintFormat(info.format); - - switch (info.dimension) - { - case TEX_DIMENSION_TEXTURE1D: - wprintf(L"%ls", (info.arraySize > 1) ? L" 1DArray" : L" 1D"); - break; - - case TEX_DIMENSION_TEXTURE2D: - if (info.IsCubemap()) - { - wprintf(L"%ls", (info.arraySize > 6) ? L" CubeArray" : L" Cube"); - } - else - { - wprintf(L"%ls", (info.arraySize > 1) ? L" 2DArray" : L" 2D"); - } - break; - - case TEX_DIMENSION_TEXTURE3D: - wprintf(L" 3D"); - break; - } - - switch (info.GetAlphaMode()) - { - case TEX_ALPHA_MODE_OPAQUE: - wprintf(L" \x0e0:Opaque"); - break; - case TEX_ALPHA_MODE_PREMULTIPLIED: - wprintf(L" \x0e0:PM"); - break; - case TEX_ALPHA_MODE_STRAIGHT: - wprintf(L" \x0e0:NonPM"); - break; - case TEX_ALPHA_MODE_CUSTOM: - wprintf(L" \x0e0:Custom"); - break; - case TEX_ALPHA_MODE_UNKNOWN: - break; - } - - wprintf(L")"); - } - - void PrintList(size_t cch, const SValue *pValue) - { - while (pValue->name) - { - const size_t cchName = wcslen(pValue->name); - - if (cch + cchName + 2 >= 80) - { - wprintf(L"\n "); - cch = 6; - } - - wprintf(L"%ls ", pValue->name); - cch += cchName + 2; - pValue++; - } - - wprintf(L"\n"); - } - - void PrintLogo() - { - wchar_t version[32] = {}; - - wchar_t appName[_MAX_PATH] = {}; - if (GetModuleFileNameW(nullptr, appName, static_cast(std::size(appName)))) - { - const DWORD size = GetFileVersionInfoSizeW(appName, nullptr); - if (size > 0) - { - auto verInfo = std::make_unique(size); - if (GetFileVersionInfoW(appName, 0, size, verInfo.get())) - { - LPVOID lpstr = nullptr; - UINT strLen = 0; - if (VerQueryValueW(verInfo.get(), L"\\StringFileInfo\\040904B0\\ProductVersion", &lpstr, &strLen)) - { - wcsncpy_s(version, reinterpret_cast(lpstr), strLen); - } - } - } - } - - if (!*version || wcscmp(version, L"1.0.0.0") == 0) - { - swprintf_s(version, L"%03d (library)", DIRECTX_TEX_VERSION); - } - - wprintf(L"Microsoft (R) DirectX Texture Converter [DirectXTex] Version %ls\n", version); - wprintf(L"Copyright (C) Microsoft Corp.\n"); - #ifdef _DEBUG - wprintf(L"*** Debug build ***\n"); - #endif - wprintf(L"\n"); - } - - _Success_(return) - bool GetDXGIFactory(_Outptr_ IDXGIFactory1** pFactory) - { - if (!pFactory) - return false; - - *pFactory = nullptr; - - typedef HRESULT(WINAPI* pfn_CreateDXGIFactory1)(REFIID riid, _Out_ void **ppFactory); - - static pfn_CreateDXGIFactory1 s_CreateDXGIFactory1 = nullptr; - - if (!s_CreateDXGIFactory1) - { - HMODULE hModDXGI = LoadLibraryW(L"dxgi.dll"); - if (!hModDXGI) - return false; - - s_CreateDXGIFactory1 = reinterpret_cast(reinterpret_cast(GetProcAddress(hModDXGI, "CreateDXGIFactory1"))); - if (!s_CreateDXGIFactory1) - return false; - } - - return SUCCEEDED(s_CreateDXGIFactory1(IID_PPV_ARGS(pFactory))); - } - - void PrintUsage() - { - PrintLogo(); - - wprintf(L"Usage: texconv \n\n"); - wprintf(L" -r wildcard filename search is recursive\n"); - wprintf(L" -r:flatten flatten the directory structure (default)\n"); - wprintf(L" -r:keep keep the directory structure\n"); - wprintf(L" -flist use text file with a list of input files (one per line)\n"); - wprintf(L"\n -w width\n"); - wprintf(L" -h height\n"); - wprintf(L" -m miplevels\n"); - wprintf(L" -f format\n"); - wprintf(L"\n -if image filtering\n"); - wprintf(L" -srgb{i|o} sRGB {input, output}\n"); - wprintf(L"\n -px name prefix\n"); - wprintf(L" -sx name suffix\n"); - wprintf(L" -o output directory\n"); - wprintf(L" -l force output filename to lower case\n"); - wprintf(L" -y overwrite existing output file (if any)\n"); - wprintf(L" -ft output file type\n"); - wprintf(L"\n -hflip horizonal flip of source image\n"); - wprintf(L" -vflip vertical flip of source image\n"); - wprintf(L"\n -sepalpha resize/generate mips alpha channel separately\n"); - wprintf(L" from color channels\n"); - wprintf(L" -keepcoverage Preserve alpha coverage in mips for alpha test ref\n"); - wprintf(L"\n -nowic Force non-WIC filtering\n"); - wprintf(L" -wrap, -mirror texture addressing mode (wrap, mirror, or clamp)\n"); - wprintf(L" -pmalpha convert final texture to use premultiplied alpha\n"); - wprintf(L" -alpha convert premultiplied alpha to straight alpha\n"); - wprintf( - L" -at Alpha threshold used for BC1, RGBA5551, and WIC\n" - L" (defaults to 0.5)\n"); - wprintf(L"\n -fl Set maximum feature level target (defaults to 11.0)\n"); - wprintf(L" -pow2 resize to fit a power-of-2, respecting aspect ratio\n"); - wprintf( - L"\n -nmap converts height-map to normal-map\n" - L" options must be one or more of\n" - L" r, g, b, a, l, m, u, v, i, o\n"); - wprintf(L" -nmapamp normal map amplitude (defaults to 1.0)\n"); - wprintf(L"\n (DDS input only)\n"); - wprintf(L" -t{u|f} TYPELESS format is treated as UNORM or FLOAT\n"); - wprintf(L" -dword Use DWORD instead of BYTE alignment\n"); - wprintf(L" -badtails Fix for older DXTn with bad mipchain tails\n"); - wprintf(L" -fixbc4x4 Fix for odd-sized BC files that Direct3D can't load\n"); - wprintf(L" -xlum expand legacy L8, L16, and A8P8 formats\n"); - wprintf(L"\n (DDS output only)\n"); - wprintf(L" -dx10 Force use of 'DX10' extended header\n"); - wprintf(L" -dx9 Force use of legacy DX9 header\n"); - wprintf(L"\n (TGA output only)\n"); - wprintf(L" -tga20 Write file including TGA 2.0 extension area\n"); - wprintf(L"\n (BMP, PNG, JPG, TIF, WDP output only)\n"); - wprintf(L" -wicq When writing images with WIC use quality (0.0 to 1.0)\n"); - wprintf(L" -wiclossless When writing images with WIC use lossless mode\n"); - wprintf(L" -wicmulti When writing images with WIC encode multiframe images\n"); - wprintf(L"\n -nologo suppress copyright message\n"); - wprintf(L" -timing Display elapsed processing time\n\n"); - #ifdef _OPENMP - wprintf(L" -singleproc Do not use multi-threaded compression\n"); - #endif - wprintf(L" -gpu Select GPU for DirectCompute-based codecs (0 is default)\n"); - wprintf(L" -nogpu Do not use DirectCompute-based codecs\n"); - wprintf( - L"\n -bc Sets options for BC compression\n" - L" options must be one or more of\n" - L" d, u, q, x\n"); - wprintf( - L" -aw BC7 GPU compressor weighting for alpha error metric\n" - L" (defaults to 1.0)\n"); - wprintf(L"\n -c colorkey (a.k.a. chromakey) transparency\n"); - wprintf(L" -rotatecolor rotates color primaries and/or applies a curve\n"); - wprintf(L" -nits paper-white value in nits to use for HDR10 (def: 200.0)\n"); - wprintf(L" -tonemap Apply a tonemap operator based on maximum luminance\n"); - wprintf(L" -x2bias Enable *2 - 1 conversion cases for unorm/pos-only-float\n"); - wprintf(L" -inverty Invert Y (i.e. green) channel values\n"); - wprintf(L" -reconstructz Rebuild Z (blue) channel assuming X/Y are normals\n"); - wprintf(L" -swizzle Swizzle image channels using HLSL-style mask\n"); - - wprintf(L"\n : "); - PrintList(13, g_pFormats); - wprintf(L" "); - PrintList(13, g_pFormatAliases); - - wprintf(L"\n : "); - PrintList(13, g_pFilters); - - wprintf(L"\n : "); - PrintList(13, g_pRotateColor); - - wprintf(L"\n : "); - PrintList(15, g_pSaveFileTypes); - - wprintf(L"\n : "); - PrintList(13, g_pFeatureLevels); - - ComPtr dxgiFactory; - if (GetDXGIFactory(dxgiFactory.GetAddressOf())) - { - wprintf(L"\n :\n"); - - ComPtr adapter; - for (UINT adapterIndex = 0; - SUCCEEDED(dxgiFactory->EnumAdapters(adapterIndex, adapter.ReleaseAndGetAddressOf())); - ++adapterIndex) - { - DXGI_ADAPTER_DESC desc; - if (SUCCEEDED(adapter->GetDesc(&desc))) - { - wprintf(L" %u: VID:%04X, PID:%04X - %ls\n", adapterIndex, desc.VendorId, desc.DeviceId, desc.Description); - } - } - } - } - - const wchar_t* GetErrorDesc(HRESULT hr) - { - static wchar_t desc[1024] = {}; - - LPWSTR errorText = nullptr; - - const DWORD result = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_ALLOCATE_BUFFER, - nullptr, static_cast(hr), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast(&errorText), 0, nullptr); - - *desc = 0; - - if (result > 0 && errorText) - { - swprintf_s(desc, L": %ls", errorText); - - size_t len = wcslen(desc); - if (len >= 1) - { - desc[len - 1] = 0; - } - - if (errorText) - LocalFree(errorText); - } - - return desc; - } - - _Success_(return) - bool CreateDevice(int adapter, _Outptr_ ID3D11Device** pDevice) - { - if (!pDevice) - return false; - - *pDevice = nullptr; - - static PFN_D3D11_CREATE_DEVICE s_DynamicD3D11CreateDevice = nullptr; - - if (!s_DynamicD3D11CreateDevice) - { - HMODULE hModD3D11 = LoadLibraryW(L"d3d11.dll"); - if (!hModD3D11) - return false; - - s_DynamicD3D11CreateDevice = reinterpret_cast(reinterpret_cast(GetProcAddress(hModD3D11, "D3D11CreateDevice"))); - if (!s_DynamicD3D11CreateDevice) - return false; - } - - const D3D_FEATURE_LEVEL featureLevels[] = - { - D3D_FEATURE_LEVEL_11_0, - D3D_FEATURE_LEVEL_10_1, - D3D_FEATURE_LEVEL_10_0, - }; - - UINT createDeviceFlags = 0; - #ifdef _DEBUG - createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG; - #endif - - ComPtr pAdapter; - if (adapter >= 0) - { - ComPtr dxgiFactory; - if (GetDXGIFactory(dxgiFactory.GetAddressOf())) - { - if (FAILED(dxgiFactory->EnumAdapters(static_cast(adapter), pAdapter.GetAddressOf()))) - { - wprintf(L"\nERROR: Invalid GPU adapter index (%d)!\n", adapter); - return false; - } - } - } - - D3D_FEATURE_LEVEL fl; - HRESULT hr = s_DynamicD3D11CreateDevice(pAdapter.Get(), - (pAdapter) ? D3D_DRIVER_TYPE_UNKNOWN : D3D_DRIVER_TYPE_HARDWARE, - nullptr, createDeviceFlags, featureLevels, static_cast(std::size(featureLevels)), - D3D11_SDK_VERSION, pDevice, &fl, nullptr); - if (SUCCEEDED(hr)) - { - if (fl < D3D_FEATURE_LEVEL_11_0) - { - D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS hwopts; - hr = (*pDevice)->CheckFeatureSupport(D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS, &hwopts, sizeof(hwopts)); - if (FAILED(hr)) - memset(&hwopts, 0, sizeof(hwopts)); - - if (!hwopts.ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x) - { - if (*pDevice) - { - (*pDevice)->Release(); - *pDevice = nullptr; - } - hr = HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - } - } - - if (SUCCEEDED(hr)) - { - ComPtr dxgiDevice; - hr = (*pDevice)->QueryInterface(IID_PPV_ARGS(dxgiDevice.GetAddressOf())); - if (SUCCEEDED(hr)) - { - hr = dxgiDevice->GetAdapter(pAdapter.ReleaseAndGetAddressOf()); - if (SUCCEEDED(hr)) - { - DXGI_ADAPTER_DESC desc; - hr = pAdapter->GetDesc(&desc); - if (SUCCEEDED(hr)) - { - wprintf(L"\n[Using DirectCompute on \"%ls\"]\n", desc.Description); - } - } - } - - return true; - } - else - return false; - } - - void FitPowerOf2(size_t origx, size_t origy, _Inout_ size_t& targetx, _Inout_ size_t& targety, size_t maxsize) - { - const float origAR = float(origx) / float(origy); - - if (origx > origy) - { - size_t x; - for (x = maxsize; x > 1; x >>= 1) { if (x <= targetx) break; } - targetx = x; - - float bestScore = FLT_MAX; - for (size_t y = maxsize; y > 0; y >>= 1) - { - const float score = fabsf((float(x) / float(y)) - origAR); - if (score < bestScore) - { - bestScore = score; - targety = y; - } - } - } - else - { - size_t y; - for (y = maxsize; y > 1; y >>= 1) { if (y <= targety) break; } - targety = y; - - float bestScore = FLT_MAX; - for (size_t x = maxsize; x > 0; x >>= 1) - { - const float score = fabsf((float(x) / float(y)) - origAR); - if (score < bestScore) - { - bestScore = score; - targetx = x; - } - } - } - } - - constexpr size_t CountMips(_In_ size_t width, _In_ size_t height) noexcept - { - size_t mipLevels = 1; - - while (height > 1 || width > 1) - { - if (height > 1) - height >>= 1; - - if (width > 1) - width >>= 1; - - ++mipLevels; - } - - return mipLevels; - } - - constexpr size_t CountMips3D(_In_ size_t width, _In_ size_t height, _In_ size_t depth) noexcept - { - size_t mipLevels = 1; - - while (height > 1 || width > 1 || depth > 1) - { - if (height > 1) - height >>= 1; - - if (width > 1) - width >>= 1; - - if (depth > 1) - depth >>= 1; - - ++mipLevels; - } - - return mipLevels; - } - - const XMVECTORF32 c_MaxNitsFor2084 = { { { 10000.0f, 10000.0f, 10000.0f, 1.f } } }; - - // HDTV to UHDTV (Rec.709 color primaries into Rec.2020) - const XMMATRIX c_from709to2020 = - { - 0.6274040f, 0.0690970f, 0.0163916f, 0.f, - 0.3292820f, 0.9195400f, 0.0880132f, 0.f, - 0.0433136f, 0.0113612f, 0.8955950f, 0.f, - 0.f, 0.f, 0.f, 1.f - }; - - // UHDTV to HDTV - const XMMATRIX c_from2020to709 = - { - 1.6604910f, -0.1245505f, -0.0181508f, 0.f, - -0.5876411f, 1.1328999f, -0.1005789f, 0.f, - -0.0728499f, -0.0083494f, 1.1187297f, 0.f, - 0.f, 0.f, 0.f, 1.f - }; - - // DCI-P3-D65 https://en.wikipedia.org/wiki/DCI-P3 to UHDTV (DCI-P3-D65 color primaries into Rec.2020) - const XMMATRIX c_fromP3D65to2020 = - { - 0.753845f, 0.0457456f, -0.00121055f, 0.f, - 0.198593f, 0.941777f, 0.0176041f, 0.f, - 0.047562f, 0.0124772f, 0.983607f, 0.f, - 0.f, 0.f, 0.f, 1.f - }; - - // HDTV to DCI-P3-D65 (a.k.a. Display P3 or P3D65) - const XMMATRIX c_from709toP3D65 = - { - 0.822461969f, 0.033194199f, 0.017082631f, 0.f, - 0.1775380f, 0.9668058f, 0.0723974f, 0.f, - 0.0000000f, 0.0000000f, 0.9105199f, 0.f, - 0.f, 0.f, 0.f, 1.f - }; - - // DCI-P3-D65 to HDTV - const XMMATRIX c_fromP3D65to709 = - { - 1.224940176f, -0.042056955f, -0.019637555f, 0.f, - -0.224940176f, 1.042056955f, -0.078636046f, 0.f, - 0.0000000f, 0.0000000f, 1.098273600f, 0.f, - 0.f, 0.f, 0.f, 1.f - }; - - inline float LinearToST2084(float normalizedLinearValue) - { - const float ST2084 = pow((0.8359375f + 18.8515625f * pow(abs(normalizedLinearValue), 0.1593017578f)) / (1.0f + 18.6875f * pow(abs(normalizedLinearValue), 0.1593017578f)), 78.84375f); - return ST2084; // Don't clamp between [0..1], so we can still perform operations on scene values higher than 10,000 nits - } - - inline float ST2084ToLinear(float ST2084) - { - const float normalizedLinear = pow(std::max(pow(abs(ST2084), 1.0f / 78.84375f) - 0.8359375f, 0.0f) / (18.8515625f - 18.6875f * pow(abs(ST2084), 1.0f / 78.84375f)), 1.0f / 0.1593017578f); - return normalizedLinear; - } - - bool ParseSwizzleMask( - _In_reads_(4) const wchar_t* mask, - _Out_writes_(4) uint32_t* swizzleElements, - _Out_writes_(4) uint32_t* zeroElements, - _Out_writes_(4) uint32_t* oneElements) - { - if (!mask || !swizzleElements || !zeroElements || !oneElements) - return false; - - if (!mask[0]) - return false; - - for (uint32_t j = 0; j < 4; ++j) - { - if (!mask[j]) - break; - - switch (mask[j]) - { - case L'R': - case L'X': - case L'r': - case L'x': - for (uint32_t k = j; k < 4; ++k) - { - swizzleElements[k] = 0; - zeroElements[k] = 0; - oneElements[k] = 0; - } - break; - - case L'G': - case L'Y': - case L'g': - case L'y': - for (uint32_t k = j; k < 4; ++k) - { - swizzleElements[k] = 1; - zeroElements[k] = 0; - oneElements[k] = 0; - } - break; - - case L'B': - case L'Z': - case L'b': - case L'z': - for (uint32_t k = j; k < 4; ++k) - { - swizzleElements[k] = 2; - zeroElements[k] = 0; - oneElements[k] = 0; - } - break; - - case L'A': - case L'W': - case L'a': - case L'w': - for (size_t k = j; k < 4; ++k) - { - swizzleElements[k] = 3; - zeroElements[k] = 0; - oneElements[k] = 0; - } - break; - - case L'0': - for (uint32_t k = j; k < 4; ++k) - { - swizzleElements[k] = k; - zeroElements[k] = 1; - oneElements[k] = 0; - } - break; - - case L'1': - for (uint32_t k = j; k < 4; ++k) - { - swizzleElements[k] = k; - zeroElements[k] = 0; - oneElements[k] = 1; - } - break; - - default: - return false; - } - } - - return true; - } -} - -//-------------------------------------------------------------------------------------- -// Entry-point -//-------------------------------------------------------------------------------------- -#ifdef _PREFAST_ -#pragma prefast(disable : 28198, "Command-line tool, frees all memory on exit") -#endif - -int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[]) -{ - // Parameters and defaults - size_t width = 0; - size_t height = 0; - size_t mipLevels = 0; - DXGI_FORMAT format = DXGI_FORMAT_UNKNOWN; - TEX_FILTER_FLAGS dwFilter = TEX_FILTER_DEFAULT; - TEX_FILTER_FLAGS dwSRGB = TEX_FILTER_DEFAULT; - TEX_FILTER_FLAGS dwConvert = TEX_FILTER_DEFAULT; - TEX_COMPRESS_FLAGS dwCompress = TEX_COMPRESS_DEFAULT; - TEX_FILTER_FLAGS dwFilterOpts = TEX_FILTER_DEFAULT; - uint32_t FileType = CODEC_DDS; - uint32_t maxSize = 16384; - int adapter = -1; - float alphaThreshold = TEX_THRESHOLD_DEFAULT; - float alphaWeight = 1.f; - CNMAP_FLAGS dwNormalMap = CNMAP_DEFAULT; - float nmapAmplitude = 1.f; - float wicQuality = -1.f; - uint32_t colorKey = 0; - uint32_t dwRotateColor = 0; - float paperWhiteNits = 200.f; - float preserveAlphaCoverageRef = 0.0f; - bool keepRecursiveDirs = false; - uint32_t swizzleElements[4] = { 0, 1, 2, 3 }; - uint32_t zeroElements[4] = {}; - uint32_t oneElements[4] = {}; - - wchar_t szPrefix[MAX_PATH] = {}; - wchar_t szSuffix[MAX_PATH] = {}; - wchar_t szOutputDir[MAX_PATH] = {}; - - // Set locale for output since GetErrorDesc can get localized strings. - std::locale::global(std::locale("")); - - // Initialize COM (needed for WIC) - HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED); - if (FAILED(hr)) - { - wprintf(L"Failed to initialize COM (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - // Process command line - uint64_t dwOptions = 0; - std::list conversion; - - for (int iArg = 1; iArg < argc; iArg++) - { - PWSTR pArg = argv[iArg]; - - if (('-' == pArg[0]) || ('/' == pArg[0])) - { - pArg++; - PWSTR pValue; - - for (pValue = pArg; *pValue && (':' != *pValue); pValue++); - - if (*pValue) - *pValue++ = 0; - - const uint64_t dwOption = LookupByName(pArg, g_pOptions); - - if (!dwOption || (dwOptions & (uint64_t(1) << dwOption))) - { - PrintUsage(); - return 1; - } - - dwOptions |= (uint64_t(1) << dwOption); - - // Handle options with additional value parameter - switch (dwOption) - { - case OPT_WIDTH: - case OPT_HEIGHT: - case OPT_MIPLEVELS: - case OPT_FORMAT: - case OPT_FILTER: - case OPT_PREFIX: - case OPT_SUFFIX: - case OPT_OUTPUTDIR: - case OPT_FILETYPE: - case OPT_GPU: - case OPT_FEATURE_LEVEL: - case OPT_ALPHA_THRESHOLD: - case OPT_ALPHA_WEIGHT: - case OPT_NORMAL_MAP: - case OPT_NORMAL_MAP_AMPLITUDE: - case OPT_WIC_QUALITY: - case OPT_BC_COMPRESS: - case OPT_COLORKEY: - case OPT_FILELIST: - case OPT_ROTATE_COLOR: - case OPT_PAPER_WHITE_NITS: - case OPT_PRESERVE_ALPHA_COVERAGE: - case OPT_SWIZZLE: - // These support either "-arg:value" or "-arg value" - if (!*pValue) - { - if ((iArg + 1 >= argc)) - { - PrintUsage(); - return 1; - } - - iArg++; - pValue = argv[iArg]; - } - break; - } - - switch (dwOption) - { - case OPT_WIDTH: - if (swscanf_s(pValue, L"%zu", &width) != 1) - { - wprintf(L"Invalid value specified with -w (%ls)\n", pValue); - wprintf(L"\n"); - PrintUsage(); - return 1; - } - break; - - case OPT_HEIGHT: - if (swscanf_s(pValue, L"%zu", &height) != 1) - { - wprintf(L"Invalid value specified with -h (%ls)\n", pValue); - printf("\n"); - PrintUsage(); - return 1; - } - break; - - case OPT_MIPLEVELS: - if (swscanf_s(pValue, L"%zu", &mipLevels) != 1) - { - wprintf(L"Invalid value specified with -m (%ls)\n", pValue); - wprintf(L"\n"); - PrintUsage(); - return 1; - } - break; - - case OPT_FORMAT: - format = static_cast(LookupByName(pValue, g_pFormats)); - if (!format) - { - format = static_cast(LookupByName(pValue, g_pFormatAliases)); - if (!format) - { - wprintf(L"Invalid value specified with -f (%ls)\n", pValue); - wprintf(L"\n"); - PrintUsage(); - return 1; - } - } - break; - - case OPT_FILTER: - dwFilter = static_cast(LookupByName(pValue, g_pFilters)); - if (!dwFilter) - { - wprintf(L"Invalid value specified with -if (%ls)\n", pValue); - wprintf(L"\n"); - PrintUsage(); - return 1; - } - break; - - case OPT_ROTATE_COLOR: - dwRotateColor = LookupByName(pValue, g_pRotateColor); - if (!dwRotateColor) - { - wprintf(L"Invalid value specified with -rotatecolor (%ls)\n", pValue); - wprintf(L"\n"); - PrintUsage(); - return 1; - } - break; - - case OPT_SRGBI: - dwSRGB |= TEX_FILTER_SRGB_IN; - break; - - case OPT_SRGBO: - dwSRGB |= TEX_FILTER_SRGB_OUT; - break; - - case OPT_SRGB: - dwSRGB |= TEX_FILTER_SRGB; - break; - - case OPT_SEPALPHA: - dwFilterOpts |= TEX_FILTER_SEPARATE_ALPHA; - break; - - case OPT_NO_WIC: - dwFilterOpts |= TEX_FILTER_FORCE_NON_WIC; - break; - - case OPT_PREFIX: - wcscpy_s(szPrefix, MAX_PATH, pValue); - break; - - case OPT_SUFFIX: - wcscpy_s(szSuffix, MAX_PATH, pValue); - break; - - case OPT_OUTPUTDIR: - wcscpy_s(szOutputDir, MAX_PATH, pValue); - break; - - case OPT_FILETYPE: - FileType = LookupByName(pValue, g_pSaveFileTypes); - if (!FileType) - { - wprintf(L"Invalid value specified with -ft (%ls)\n", pValue); - wprintf(L"\n"); - PrintUsage(); - return 1; - } - break; - - case OPT_PREMUL_ALPHA: - if (dwOptions & (uint64_t(1) << OPT_DEMUL_ALPHA)) - { - wprintf(L"Can't use -pmalpha and -alpha at same time\n\n"); - PrintUsage(); - return 1; - } - break; - - case OPT_DEMUL_ALPHA: - if (dwOptions & (uint64_t(1) << OPT_PREMUL_ALPHA)) - { - wprintf(L"Can't use -pmalpha and -alpha at same time\n\n"); - PrintUsage(); - return 1; - } - break; - - case OPT_TA_WRAP: - if (dwFilterOpts & TEX_FILTER_MIRROR) - { - wprintf(L"Can't use -wrap and -mirror at same time\n\n"); - PrintUsage(); - return 1; - } - dwFilterOpts |= TEX_FILTER_WRAP; - break; - - case OPT_TA_MIRROR: - if (dwFilterOpts & TEX_FILTER_WRAP) - { - wprintf(L"Can't use -wrap and -mirror at same time\n\n"); - PrintUsage(); - return 1; - } - dwFilterOpts |= TEX_FILTER_MIRROR; - break; - - case OPT_NORMAL_MAP: - { - dwNormalMap = CNMAP_DEFAULT; - - if (wcschr(pValue, L'l')) - { - dwNormalMap |= CNMAP_CHANNEL_LUMINANCE; - } - else if (wcschr(pValue, L'r')) - { - dwNormalMap |= CNMAP_CHANNEL_RED; - } - else if (wcschr(pValue, L'g')) - { - dwNormalMap |= CNMAP_CHANNEL_GREEN; - } - else if (wcschr(pValue, L'b')) - { - dwNormalMap |= CNMAP_CHANNEL_BLUE; - } - else if (wcschr(pValue, L'a')) - { - dwNormalMap |= CNMAP_CHANNEL_ALPHA; - } - else - { - wprintf(L"Invalid value specified for -nmap (%ls), missing l, r, g, b, or a\n\n", pValue); - return 1; - } - - if (wcschr(pValue, L'm')) - { - dwNormalMap |= CNMAP_MIRROR; - } - else - { - if (wcschr(pValue, L'u')) - { - dwNormalMap |= CNMAP_MIRROR_U; - } - if (wcschr(pValue, L'v')) - { - dwNormalMap |= CNMAP_MIRROR_V; - } - } - - if (wcschr(pValue, L'i')) - { - dwNormalMap |= CNMAP_INVERT_SIGN; - } - - if (wcschr(pValue, L'o')) - { - dwNormalMap |= CNMAP_COMPUTE_OCCLUSION; - } - } - break; - - case OPT_NORMAL_MAP_AMPLITUDE: - if (!dwNormalMap) - { - wprintf(L"-nmapamp requires -nmap\n\n"); - PrintUsage(); - return 1; - } - else if (swscanf_s(pValue, L"%f", &nmapAmplitude) != 1) - { - wprintf(L"Invalid value specified with -nmapamp (%ls)\n\n", pValue); - PrintUsage(); - return 1; - } - else if (nmapAmplitude < 0.f) - { - wprintf(L"Normal map amplitude must be positive (%ls)\n\n", pValue); - return 1; - } - break; - - case OPT_GPU: - if (swscanf_s(pValue, L"%d", &adapter) != 1) - { - wprintf(L"Invalid value specified with -gpu (%ls)\n\n", pValue); - PrintUsage(); - return 1; - } - else if (adapter < 0) - { - wprintf(L"Invalid adapter index (%ls)\n\n", pValue); - PrintUsage(); - return 1; - } - break; - - case OPT_FEATURE_LEVEL: - maxSize = LookupByName(pValue, g_pFeatureLevels); - if (!maxSize) - { - wprintf(L"Invalid value specified with -fl (%ls)\n", pValue); - wprintf(L"\n"); - PrintUsage(); - return 1; - } - break; - - case OPT_ALPHA_THRESHOLD: - if (swscanf_s(pValue, L"%f", &alphaThreshold) != 1) - { - wprintf(L"Invalid value specified with -at (%ls)\n", pValue); - wprintf(L"\n"); - PrintUsage(); - return 1; - } - else if (alphaThreshold < 0.f) - { - wprintf(L"-at (%ls) parameter must be positive\n", pValue); - wprintf(L"\n"); - return 1; - } - break; - - case OPT_ALPHA_WEIGHT: - if (swscanf_s(pValue, L"%f", &alphaWeight) != 1) - { - wprintf(L"Invalid value specified with -aw (%ls)\n", pValue); - wprintf(L"\n"); - PrintUsage(); - return 1; - } - else if (alphaWeight < 0.f) - { - wprintf(L"-aw (%ls) parameter must be positive\n", pValue); - wprintf(L"\n"); - return 1; - } - break; - - case OPT_BC_COMPRESS: - { - dwCompress = TEX_COMPRESS_DEFAULT; - - bool found = false; - if (wcschr(pValue, L'u')) - { - dwCompress |= TEX_COMPRESS_UNIFORM; - found = true; - } - - if (wcschr(pValue, L'd')) - { - dwCompress |= TEX_COMPRESS_DITHER; - found = true; - } - - if (wcschr(pValue, L'q')) - { - dwCompress |= TEX_COMPRESS_BC7_QUICK; - found = true; - } - - if (wcschr(pValue, L'x')) - { - dwCompress |= TEX_COMPRESS_BC7_USE_3SUBSETS; - found = true; - } - - if ((dwCompress & (TEX_COMPRESS_BC7_QUICK | TEX_COMPRESS_BC7_USE_3SUBSETS)) == (TEX_COMPRESS_BC7_QUICK | TEX_COMPRESS_BC7_USE_3SUBSETS)) - { - wprintf(L"Can't use -bc x (max) and -bc q (quick) at same time\n\n"); - PrintUsage(); - return 1; - } - - if (!found) - { - wprintf(L"Invalid value specified for -bc (%ls), missing d, u, q, or x\n\n", pValue); - return 1; - } - } - break; - - case OPT_WIC_QUALITY: - if (swscanf_s(pValue, L"%f", &wicQuality) != 1 - || (wicQuality < 0.f) - || (wicQuality > 1.f)) - { - wprintf(L"Invalid value specified with -wicq (%ls)\n", pValue); - printf("\n"); - PrintUsage(); - return 1; - } - break; - - case OPT_COLORKEY: - if (swscanf_s(pValue, L"%x", &colorKey) != 1) - { - printf("Invalid value specified with -c (%ls)\n", pValue); - printf("\n"); - PrintUsage(); - return 1; - } - colorKey &= 0xFFFFFF; - break; - - case OPT_X2_BIAS: - dwConvert |= TEX_FILTER_FLOAT_X2BIAS; - break; - - case OPT_USE_DX10: - if (dwOptions & (uint64_t(1) << OPT_USE_DX9)) - { - wprintf(L"Can't use -dx9 and -dx10 at same time\n\n"); - PrintUsage(); - return 1; - } - break; - - case OPT_USE_DX9: - if (dwOptions & (uint64_t(1) << OPT_USE_DX10)) - { - wprintf(L"Can't use -dx9 and -dx10 at same time\n\n"); - PrintUsage(); - return 1; - } - break; - - case OPT_RECURSIVE: - if (*pValue) - { - // This option takes 'flatten' or 'keep' with ':' syntax - if (!_wcsicmp(pValue, L"keep")) - { - keepRecursiveDirs = true; - } - else if (_wcsicmp(pValue, L"flatten") != 0) - { - wprintf(L"For recursive use -r, -r:flatten, or -r:keep\n\n"); - PrintUsage(); - return 1; - } - } - break; - - case OPT_FILELIST: - { - std::wifstream inFile(pValue); - if (!inFile) - { - wprintf(L"Error opening -flist file %ls\n", pValue); - return 1; - } - - inFile.imbue(std::locale::classic()); - - ProcessFileList(inFile, conversion); - } - break; - - case OPT_PAPER_WHITE_NITS: - if (swscanf_s(pValue, L"%f", &paperWhiteNits) != 1) - { - wprintf(L"Invalid value specified with -nits (%ls)\n\n", pValue); - PrintUsage(); - return 1; - } - else if (paperWhiteNits > 10000.f || paperWhiteNits <= 0.f) - { - wprintf(L"-nits (%ls) parameter must be between 0 and 10000\n\n", pValue); - return 1; - } - break; - - case OPT_PRESERVE_ALPHA_COVERAGE: - if (swscanf_s(pValue, L"%f", &preserveAlphaCoverageRef) != 1) - { - wprintf(L"Invalid value specified with -keepcoverage (%ls)\n\n", pValue); - PrintUsage(); - return 1; - } - else if (preserveAlphaCoverageRef < 0.0f || preserveAlphaCoverageRef > 1.0f) - { - wprintf(L"-keepcoverage (%ls) parameter must be between 0.0 and 1.0\n\n", pValue); - return 1; - } - break; - - case OPT_SWIZZLE: - if (!*pValue || wcslen(pValue) > 4) - { - wprintf(L"Invalid value specified with -swizzle (%ls)\n\n", pValue); - PrintUsage(); - return 1; - } - else if (!ParseSwizzleMask(pValue, swizzleElements, zeroElements, oneElements)) - { - wprintf(L"-swizzle requires a 1 to 4 character mask composed of these letters: r, g, b, a, x, y, w, z, 0, 1\n"); - return 1; - } - break; - } - } - else if (wcspbrk(pArg, L"?*") != nullptr) - { - const size_t count = conversion.size(); - SearchForFiles(pArg, conversion, (dwOptions & (uint64_t(1) << OPT_RECURSIVE)) != 0, nullptr); - if (conversion.size() <= count) - { - wprintf(L"No matching files found for %ls\n", pArg); - return 1; - } - } - else - { - SConversion conv = {}; - wcscpy_s(conv.szSrc, MAX_PATH, pArg); - - conversion.push_back(conv); - } - } - - if (conversion.empty()) - { - PrintUsage(); - return 0; - } - - if (~dwOptions & (uint64_t(1) << OPT_NOLOGO)) - PrintLogo(); - - // Work out out filename prefix and suffix - if (szOutputDir[0] && (L'\\' != szOutputDir[wcslen(szOutputDir) - 1])) - wcscat_s(szOutputDir, MAX_PATH, L"\\"); - - auto fileTypeName = LookupByValue(FileType, g_pSaveFileTypes); - - if (fileTypeName) - { - wcscat_s(szSuffix, MAX_PATH, L"."); - wcscat_s(szSuffix, MAX_PATH, fileTypeName); - } - else - { - wcscat_s(szSuffix, MAX_PATH, L".unknown"); - } - - if (FileType != CODEC_DDS) - { - mipLevels = 1; - } - - LARGE_INTEGER qpcFreq = {}; - std::ignore = QueryPerformanceFrequency(&qpcFreq); - - LARGE_INTEGER qpcStart = {}; - std::ignore = QueryPerformanceCounter(&qpcStart); - - // Convert images - bool sizewarn = false; - bool nonpow2warn = false; - bool non4bc = false; - bool preserveAlphaCoverage = false; - ComPtr pDevice; - - int retVal = 0; - - for (auto pConv = conversion.begin(); pConv != conversion.end(); ++pConv) - { - if (pConv != conversion.begin()) - wprintf(L"\n"); - - // --- Load source image ------------------------------------------------------- - wprintf(L"reading %ls", pConv->szSrc); - fflush(stdout); - - wchar_t ext[_MAX_EXT] = {}; - wchar_t fname[_MAX_FNAME] = {}; - _wsplitpath_s(pConv->szSrc, nullptr, 0, nullptr, 0, fname, _MAX_FNAME, ext, _MAX_EXT); - - TexMetadata info; - std::unique_ptr image(new (std::nothrow) ScratchImage); - - if (!image) - { - wprintf(L"\nERROR: Memory allocation failed\n"); - return 1; - } - - if (_wcsicmp(ext, L".dds") == 0) - { - DDS_FLAGS ddsFlags = DDS_FLAGS_ALLOW_LARGE_FILES; - if (dwOptions & (uint64_t(1) << OPT_DDS_DWORD_ALIGN)) - ddsFlags |= DDS_FLAGS_LEGACY_DWORD; - if (dwOptions & (uint64_t(1) << OPT_EXPAND_LUMINANCE)) - ddsFlags |= DDS_FLAGS_EXPAND_LUMINANCE; - if (dwOptions & (uint64_t(1) << OPT_DDS_BAD_DXTN_TAILS)) - ddsFlags |= DDS_FLAGS_BAD_DXTN_TAILS; - - hr = LoadFromDDSFile(pConv->szSrc, ddsFlags, &info, *image); - if (FAILED(hr)) - { - wprintf(L" FAILED (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - retVal = 1; - continue; - } - - if (IsTypeless(info.format)) - { - if (dwOptions & (uint64_t(1) << OPT_TYPELESS_UNORM)) - { - info.format = MakeTypelessUNORM(info.format); - } - else if (dwOptions & (uint64_t(1) << OPT_TYPELESS_FLOAT)) - { - info.format = MakeTypelessFLOAT(info.format); - } - - if (IsTypeless(info.format)) - { - wprintf(L" FAILED due to Typeless format %d\n", info.format); - retVal = 1; - continue; - } - - image->OverrideFormat(info.format); - } - } - else if (_wcsicmp(ext, L".bmp") == 0) - { - hr = LoadFromBMPEx(pConv->szSrc, WIC_FLAGS_NONE | dwFilter, &info, *image); - if (FAILED(hr)) - { - wprintf(L" FAILED (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - retVal = 1; - continue; - } - } - else if (_wcsicmp(ext, L".tga") == 0) - { - TGA_FLAGS tgaFlags = (IsBGR(format)) ? TGA_FLAGS_BGR : TGA_FLAGS_NONE; - - hr = LoadFromTGAFile(pConv->szSrc, tgaFlags, &info, *image); - if (FAILED(hr)) - { - wprintf(L" FAILED (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - retVal = 1; - continue; - } - } - else if (_wcsicmp(ext, L".hdr") == 0) - { - hr = LoadFromHDRFile(pConv->szSrc, &info, *image); - if (FAILED(hr)) - { - wprintf(L" FAILED (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - retVal = 1; - continue; - } - } - else if (_wcsicmp(ext, L".ppm") == 0) - { - hr = LoadFromPortablePixMap(pConv->szSrc, &info, *image); - if (FAILED(hr)) - { - wprintf(L" FAILED (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - retVal = 1; - continue; - } - } - else if (_wcsicmp(ext, L".pfm") == 0) - { - hr = LoadFromPortablePixMapHDR(pConv->szSrc, &info, *image); - if (FAILED(hr)) - { - wprintf(L" FAILED (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - retVal = 1; - continue; - } - } - #ifdef USE_OPENEXR - else if (_wcsicmp(ext, L".exr") == 0) - { - hr = LoadFromEXRFile(pConv->szSrc, &info, *image); - if (FAILED(hr)) - { - wprintf(L" FAILED (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - retVal = 1; - continue; - } - } - #endif - else - { - // WIC shares the same filter values for mode and dither - static_assert(static_cast(WIC_FLAGS_DITHER) == static_cast(TEX_FILTER_DITHER), "WIC_FLAGS_* & TEX_FILTER_* should match"); - static_assert(static_cast(WIC_FLAGS_DITHER_DIFFUSION) == static_cast(TEX_FILTER_DITHER_DIFFUSION), "WIC_FLAGS_* & TEX_FILTER_* should match"); - static_assert(static_cast(WIC_FLAGS_FILTER_POINT) == static_cast(TEX_FILTER_POINT), "WIC_FLAGS_* & TEX_FILTER_* should match"); - static_assert(static_cast(WIC_FLAGS_FILTER_LINEAR) == static_cast(TEX_FILTER_LINEAR), "WIC_FLAGS_* & TEX_FILTER_* should match"); - static_assert(static_cast(WIC_FLAGS_FILTER_CUBIC) == static_cast(TEX_FILTER_CUBIC), "WIC_FLAGS_* & TEX_FILTER_* should match"); - static_assert(static_cast(WIC_FLAGS_FILTER_FANT) == static_cast(TEX_FILTER_FANT), "WIC_FLAGS_* & TEX_FILTER_* should match"); - - WIC_FLAGS wicFlags = WIC_FLAGS_NONE | dwFilter; - if (FileType == CODEC_DDS) - wicFlags |= WIC_FLAGS_ALL_FRAMES; - - hr = LoadFromWICFile(pConv->szSrc, wicFlags, &info, *image); - if (FAILED(hr)) - { - wprintf(L" FAILED (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - retVal = 1; - if (hr == static_cast(0xc00d5212) /* MF_E_TOPO_CODEC_NOT_FOUND */) - { - if (_wcsicmp(ext, L".heic") == 0 || _wcsicmp(ext, L".heif") == 0) - { - wprintf(L"INFO: This format requires installing the HEIF Image Extensions - https://aka.ms/heif\n"); - } - else if (_wcsicmp(ext, L".webp") == 0) - { - wprintf(L"INFO: This format requires installing the WEBP Image Extensions - https://www.microsoft.com/p/webp-image-extensions/9pg2dk419drg\n"); - } - } - continue; - } - } - - PrintInfo(info); - - size_t tMips = (!mipLevels && info.mipLevels > 1) ? info.mipLevels : mipLevels; - - // Convert texture - wprintf(L" as"); - fflush(stdout); - - // --- Planar ------------------------------------------------------------------ - if (IsPlanar(info.format)) - { - auto img = image->GetImage(0, 0, 0); - assert(img); - const size_t nimg = image->GetImageCount(); - - std::unique_ptr timage(new (std::nothrow) ScratchImage); - if (!timage) - { - wprintf(L"\nERROR: Memory allocation failed\n"); - return 1; - } - - hr = ConvertToSinglePlane(img, nimg, info, *timage); - if (FAILED(hr)) - { - wprintf(L" FAILED [converttosingleplane] (%08X%ls)\n", - static_cast(hr), GetErrorDesc(hr)); - retVal = 1; - continue; - } - - auto& tinfo = timage->GetMetadata(); - - info.format = tinfo.format; - - assert(info.width == tinfo.width); - assert(info.height == tinfo.height); - assert(info.depth == tinfo.depth); - assert(info.arraySize == tinfo.arraySize); - assert(info.mipLevels == tinfo.mipLevels); - assert(info.miscFlags == tinfo.miscFlags); - assert(info.dimension == tinfo.dimension); - - image.swap(timage); - } - - const DXGI_FORMAT tformat = (format == DXGI_FORMAT_UNKNOWN) ? info.format : format; - - // --- Decompress -------------------------------------------------------------- - std::unique_ptr cimage; - if (IsCompressed(info.format)) - { - // Direct3D can only create BC resources with multiple-of-4 top levels - if ((info.width % 4) != 0 || (info.height % 4) != 0) - { - if (dwOptions & (uint64_t(1) << OPT_BCNONMULT4FIX)) - { - std::unique_ptr timage(new (std::nothrow) ScratchImage); - if (!timage) - { - wprintf(L"\nERROR: Memory allocation failed\n"); - return 1; - } - - // If we started with < 4x4 then no need to generate mips - if (info.width < 4 && info.height < 4) - { - tMips = 1; - } - - // Fix by changing size but also have to trim any mip-levels which can be invalid - TexMetadata mdata = image->GetMetadata(); - mdata.width = (info.width + 3u) & ~0x3u; - mdata.height = (info.height + 3u) & ~0x3u; - mdata.mipLevels = 1; - hr = timage->Initialize(mdata); - if (FAILED(hr)) - { - wprintf(L" FAILED [BC non-multiple-of-4 fixup] (%08X%ls)\n", - static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - if (mdata.dimension == TEX_DIMENSION_TEXTURE3D) - { - for (size_t d = 0; d < mdata.depth; ++d) - { - auto simg = image->GetImage(0, 0, d); - auto dimg = timage->GetImage(0, 0, d); - - memcpy_s(dimg->pixels, dimg->slicePitch, simg->pixels, simg->slicePitch); - } - } - else - { - for (size_t i = 0; i < mdata.arraySize; ++i) - { - auto simg = image->GetImage(0, i, 0); - auto dimg = timage->GetImage(0, i, 0); - - memcpy_s(dimg->pixels, dimg->slicePitch, simg->pixels, simg->slicePitch); - } - } - - info.width = mdata.width; - info.height = mdata.height; - info.mipLevels = mdata.mipLevels; - image.swap(timage); - } - else if (IsCompressed(tformat)) - { - non4bc = true; - } - } - - auto img = image->GetImage(0, 0, 0); - assert(img); - const size_t nimg = image->GetImageCount(); - - std::unique_ptr timage(new (std::nothrow) ScratchImage); - if (!timage) - { - wprintf(L"\nERROR: Memory allocation failed\n"); - return 1; - } - - hr = Decompress(img, nimg, info, DXGI_FORMAT_UNKNOWN /* picks good default */, *timage); - if (FAILED(hr)) - { - wprintf(L" FAILED [decompress] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - retVal = 1; - continue; - } - - auto& tinfo = timage->GetMetadata(); - - info.format = tinfo.format; - - assert(info.width == tinfo.width); - assert(info.height == tinfo.height); - assert(info.depth == tinfo.depth); - assert(info.arraySize == tinfo.arraySize); - assert(info.mipLevels == tinfo.mipLevels); - assert(info.miscFlags == tinfo.miscFlags); - assert(info.dimension == tinfo.dimension); - - if (FileType == CODEC_DDS) - { - // Keep the original compressed image in case we can reuse it - cimage.reset(image.release()); - image.reset(timage.release()); - } - else - { - image.swap(timage); - } - } - - // --- Undo Premultiplied Alpha (if requested) --------------------------------- - if ((dwOptions & (uint64_t(1) << OPT_DEMUL_ALPHA)) - && HasAlpha(info.format) - && info.format != DXGI_FORMAT_A8_UNORM) - { - if (info.GetAlphaMode() == TEX_ALPHA_MODE_STRAIGHT) - { - printf("\nWARNING: Image is already using straight alpha\n"); - } - else if (!info.IsPMAlpha()) - { - printf("\nWARNING: Image is not using premultipled alpha\n"); - } - else - { - auto img = image->GetImage(0, 0, 0); - assert(img); - const size_t nimg = image->GetImageCount(); - - std::unique_ptr timage(new (std::nothrow) ScratchImage); - if (!timage) - { - wprintf(L"\nERROR: Memory allocation failed\n"); - return 1; - } - - hr = PremultiplyAlpha(img, nimg, info, TEX_PMALPHA_REVERSE | dwSRGB, *timage); - if (FAILED(hr)) - { - wprintf(L" FAILED [demultiply alpha] (%08X%ls)\n", - static_cast(hr), GetErrorDesc(hr)); - retVal = 1; - continue; - } - - auto& tinfo = timage->GetMetadata(); - info.miscFlags2 = tinfo.miscFlags2; - - assert(info.width == tinfo.width); - assert(info.height == tinfo.height); - assert(info.depth == tinfo.depth); - assert(info.arraySize == tinfo.arraySize); - assert(info.mipLevels == tinfo.mipLevels); - assert(info.miscFlags == tinfo.miscFlags); - assert(info.dimension == tinfo.dimension); - - image.swap(timage); - cimage.reset(); - } - } - - // --- Flip/Rotate ------------------------------------------------------------- - if (dwOptions & ((uint64_t(1) << OPT_HFLIP) | (uint64_t(1) << OPT_VFLIP))) - { - std::unique_ptr timage(new (std::nothrow) ScratchImage); - if (!timage) - { - wprintf(L"\nERROR: Memory allocation failed\n"); - return 1; - } - - TEX_FR_FLAGS dwFlags = TEX_FR_ROTATE0; - - if (dwOptions & (uint64_t(1) << OPT_HFLIP)) - dwFlags |= TEX_FR_FLIP_HORIZONTAL; - - if (dwOptions & (uint64_t(1) << OPT_VFLIP)) - dwFlags |= TEX_FR_FLIP_VERTICAL; - - assert(dwFlags != 0); - - hr = FlipRotate(image->GetImages(), image->GetImageCount(), image->GetMetadata(), dwFlags, *timage); - if (FAILED(hr)) - { - wprintf(L" FAILED [fliprotate] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - auto& tinfo = timage->GetMetadata(); - - info.width = tinfo.width; - info.height = tinfo.height; - - assert(info.depth == tinfo.depth); - assert(info.arraySize == tinfo.arraySize); - assert(info.mipLevels == tinfo.mipLevels); - assert(info.miscFlags == tinfo.miscFlags); - assert(info.format == tinfo.format); - assert(info.dimension == tinfo.dimension); - - image.swap(timage); - cimage.reset(); - } - - // --- Resize ------------------------------------------------------------------ - size_t twidth = (!width) ? info.width : width; - if (twidth > maxSize) - { - if (!width) - twidth = maxSize; - else - sizewarn = true; - } - - size_t theight = (!height) ? info.height : height; - if (theight > maxSize) - { - if (!height) - theight = maxSize; - else - sizewarn = true; - } - - if (dwOptions & (uint64_t(1) << OPT_FIT_POWEROF2)) - { - FitPowerOf2(info.width, info.height, twidth, theight, maxSize); - } - - if (info.width != twidth || info.height != theight) - { - std::unique_ptr timage(new (std::nothrow) ScratchImage); - if (!timage) - { - wprintf(L"\nERROR: Memory allocation failed\n"); - return 1; - } - - hr = Resize(image->GetImages(), image->GetImageCount(), image->GetMetadata(), twidth, theight, dwFilter | dwFilterOpts, *timage); - if (FAILED(hr)) - { - wprintf(L" FAILED [resize] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - auto& tinfo = timage->GetMetadata(); - - assert(tinfo.width == twidth && tinfo.height == theight && tinfo.mipLevels == 1); - info.width = tinfo.width; - info.height = tinfo.height; - info.mipLevels = 1; - - assert(info.depth == tinfo.depth); - assert(info.arraySize == tinfo.arraySize); - assert(info.miscFlags == tinfo.miscFlags); - assert(info.format == tinfo.format); - assert(info.dimension == tinfo.dimension); - - image.swap(timage); - cimage.reset(); - - if (tMips > 0) - { - const size_t maxMips = (info.depth > 1) - ? CountMips3D(info.width, info.height, info.depth) - : CountMips(info.width, info.height); - - if (tMips > maxMips) - { - tMips = maxMips; - } - } - } - - // --- Swizzle (if requested) -------------------------------------------------- - if (swizzleElements[0] != 0 || swizzleElements[1] != 1 || swizzleElements[2] != 2 || swizzleElements[3] != 3 - || zeroElements[0] != 0 || zeroElements[1] != 0 || zeroElements[2] != 0 || zeroElements[3] != 0 - || oneElements[0] != 0 || oneElements[1] != 0 || oneElements[2] != 0 || oneElements[3] != 0) - { - std::unique_ptr timage(new (std::nothrow) ScratchImage); - if (!timage) - { - wprintf(L"\nERROR: Memory allocation failed\n"); - return 1; - } - - const XMVECTOR zc = XMVectorSelectControl(zeroElements[0], zeroElements[1], zeroElements[2], zeroElements[3]); - const XMVECTOR oc = XMVectorSelectControl(oneElements[0], oneElements[1], oneElements[2], oneElements[3]); - - hr = TransformImage(image->GetImages(), image->GetImageCount(), image->GetMetadata(), - [&, zc, oc](XMVECTOR* outPixels, const XMVECTOR* inPixels, size_t w, size_t y) - { - UNREFERENCED_PARAMETER(y); - - for (size_t j = 0; j < w; ++j) - { - XMVECTOR pixel = XMVectorSwizzle(inPixels[j], - swizzleElements[0], swizzleElements[1], swizzleElements[2], swizzleElements[3]); - pixel = XMVectorSelect(pixel, g_XMZero, zc); - outPixels[j] = XMVectorSelect(pixel, g_XMOne, oc); - } - }, *timage); - if (FAILED(hr)) - { - wprintf(L" FAILED [swizzle] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - #ifndef NDEBUG - auto& tinfo = timage->GetMetadata(); - #endif - - assert(info.width == tinfo.width); - assert(info.height == tinfo.height); - assert(info.depth == tinfo.depth); - assert(info.arraySize == tinfo.arraySize); - assert(info.mipLevels == tinfo.mipLevels); - assert(info.miscFlags == tinfo.miscFlags); - assert(info.format == tinfo.format); - assert(info.dimension == tinfo.dimension); - - image.swap(timage); - cimage.reset(); - } - - // --- Color rotation (if requested) ------------------------------------------- - if (dwRotateColor) - { - if (dwRotateColor == ROTATE_HDR10_TO_709 || dwRotateColor == ROTATE_P3D65_TO_709) - { - std::unique_ptr timage(new (std::nothrow) ScratchImage); - if (!timage) - { - wprintf(L"\nERROR: Memory allocation failed\n"); - return 1; - } - - hr = Convert(image->GetImages(), image->GetImageCount(), image->GetMetadata(), DXGI_FORMAT_R16G16B16A16_FLOAT, - dwFilter | dwFilterOpts | dwSRGB | dwConvert, alphaThreshold, *timage); - if (FAILED(hr)) - { - wprintf(L" FAILED [convert] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - #ifndef NDEBUG - auto& tinfo = timage->GetMetadata(); - #endif - - assert(tinfo.format == DXGI_FORMAT_R16G16B16A16_FLOAT); - info.format = DXGI_FORMAT_R16G16B16A16_FLOAT; - - assert(info.width == tinfo.width); - assert(info.height == tinfo.height); - assert(info.depth == tinfo.depth); - assert(info.arraySize == tinfo.arraySize); - assert(info.mipLevels == tinfo.mipLevels); - assert(info.miscFlags == tinfo.miscFlags); - assert(info.dimension == tinfo.dimension); - - image.swap(timage); - cimage.reset(); - } - - std::unique_ptr timage(new (std::nothrow) ScratchImage); - if (!timage) - { - wprintf(L"\nERROR: Memory allocation failed\n"); - return 1; - } - - switch (dwRotateColor) - { - case ROTATE_709_TO_HDR10: - hr = TransformImage(image->GetImages(), image->GetImageCount(), image->GetMetadata(), - [&](XMVECTOR* outPixels, const XMVECTOR* inPixels, size_t w, size_t y) - { - UNREFERENCED_PARAMETER(y); - - const XMVECTOR paperWhite = XMVectorReplicate(paperWhiteNits); - - for (size_t j = 0; j < w; ++j) - { - XMVECTOR value = inPixels[j]; - - XMVECTOR nvalue = XMVector3Transform(value, c_from709to2020); - - // Convert to ST.2084 - nvalue = XMVectorDivide(XMVectorMultiply(nvalue, paperWhite), c_MaxNitsFor2084); - - XMFLOAT4A tmp; - XMStoreFloat4A(&tmp, nvalue); - - tmp.x = LinearToST2084(tmp.x); - tmp.y = LinearToST2084(tmp.y); - tmp.z = LinearToST2084(tmp.z); - - nvalue = XMLoadFloat4A(&tmp); - - value = XMVectorSelect(value, nvalue, g_XMSelect1110); - - outPixels[j] = value; - } - }, *timage); - break; - - case ROTATE_709_TO_2020: - hr = TransformImage(image->GetImages(), image->GetImageCount(), image->GetMetadata(), - [&](XMVECTOR* outPixels, const XMVECTOR* inPixels, size_t w, size_t y) - { - UNREFERENCED_PARAMETER(y); - - for (size_t j = 0; j < w; ++j) - { - XMVECTOR value = inPixels[j]; - - const XMVECTOR nvalue = XMVector3Transform(value, c_from709to2020); - - value = XMVectorSelect(value, nvalue, g_XMSelect1110); - - outPixels[j] = value; - } - }, *timage); - break; - - case ROTATE_HDR10_TO_709: - hr = TransformImage(image->GetImages(), image->GetImageCount(), image->GetMetadata(), - [&](XMVECTOR* outPixels, const XMVECTOR* inPixels, size_t w, size_t y) - { - UNREFERENCED_PARAMETER(y); - - const XMVECTOR paperWhite = XMVectorReplicate(paperWhiteNits); - - for (size_t j = 0; j < w; ++j) - { - XMVECTOR value = inPixels[j]; - - // Convert from ST.2084 - XMFLOAT4A tmp; - XMStoreFloat4A(&tmp, value); - - tmp.x = ST2084ToLinear(tmp.x); - tmp.y = ST2084ToLinear(tmp.y); - tmp.z = ST2084ToLinear(tmp.z); - - XMVECTOR nvalue = XMLoadFloat4A(&tmp); - - nvalue = XMVectorDivide(XMVectorMultiply(nvalue, c_MaxNitsFor2084), paperWhite); - - nvalue = XMVector3Transform(nvalue, c_from2020to709); - - value = XMVectorSelect(value, nvalue, g_XMSelect1110); - - outPixels[j] = value; - } - }, *timage); - break; - - case ROTATE_2020_TO_709: - hr = TransformImage(image->GetImages(), image->GetImageCount(), image->GetMetadata(), - [&](XMVECTOR* outPixels, const XMVECTOR* inPixels, size_t w, size_t y) - { - UNREFERENCED_PARAMETER(y); - - for (size_t j = 0; j < w; ++j) - { - XMVECTOR value = inPixels[j]; - - const XMVECTOR nvalue = XMVector3Transform(value, c_from2020to709); - - value = XMVectorSelect(value, nvalue, g_XMSelect1110); - - outPixels[j] = value; - } - }, *timage); - break; - - case ROTATE_P3D65_TO_HDR10: - hr = TransformImage(image->GetImages(), image->GetImageCount(), image->GetMetadata(), - [&](XMVECTOR* outPixels, const XMVECTOR* inPixels, size_t w, size_t y) - { - UNREFERENCED_PARAMETER(y); - - const XMVECTOR paperWhite = XMVectorReplicate(paperWhiteNits); - - for (size_t j = 0; j < w; ++j) - { - XMVECTOR value = inPixels[j]; - - XMVECTOR nvalue = XMVector3Transform(value, c_fromP3D65to2020); - - // Convert to ST.2084 - nvalue = XMVectorDivide(XMVectorMultiply(nvalue, paperWhite), c_MaxNitsFor2084); - - XMFLOAT4A tmp; - XMStoreFloat4A(&tmp, nvalue); - - tmp.x = LinearToST2084(tmp.x); - tmp.y = LinearToST2084(tmp.y); - tmp.z = LinearToST2084(tmp.z); - - nvalue = XMLoadFloat4A(&tmp); - - value = XMVectorSelect(value, nvalue, g_XMSelect1110); - - outPixels[j] = value; - } - }, *timage); - break; - - case ROTATE_P3D65_TO_2020: - hr = TransformImage(image->GetImages(), image->GetImageCount(), image->GetMetadata(), - [&](XMVECTOR* outPixels, const XMVECTOR* inPixels, size_t w, size_t y) - { - UNREFERENCED_PARAMETER(y); - - for (size_t j = 0; j < w; ++j) - { - XMVECTOR value = inPixels[j]; - - const XMVECTOR nvalue = XMVector3Transform(value, c_fromP3D65to2020); - - value = XMVectorSelect(value, nvalue, g_XMSelect1110); - - outPixels[j] = value; - } - }, *timage); - break; - - case ROTATE_709_TO_P3D65: - hr = TransformImage(image->GetImages(), image->GetImageCount(), image->GetMetadata(), - [&](XMVECTOR* outPixels, const XMVECTOR* inPixels, size_t w, size_t y) - { - UNREFERENCED_PARAMETER(y); - - for (size_t j = 0; j < w; ++j) - { - XMVECTOR value = inPixels[j]; - - const XMVECTOR nvalue = XMVector3Transform(value, c_from709toP3D65); - - value = XMVectorSelect(value, nvalue, g_XMSelect1110); - - outPixels[j] = value; - } - }, *timage); - break; - - case ROTATE_P3D65_TO_709: - hr = TransformImage(image->GetImages(), image->GetImageCount(), image->GetMetadata(), - [&](XMVECTOR* outPixels, const XMVECTOR* inPixels, size_t w, size_t y) - { - UNREFERENCED_PARAMETER(y); - - for (size_t j = 0; j < w; ++j) - { - XMVECTOR value = inPixels[j]; - - const XMVECTOR nvalue = XMVector3Transform(value, c_fromP3D65to709); - - value = XMVectorSelect(value, nvalue, g_XMSelect1110); - - outPixels[j] = value; - } - }, *timage); - break; - - default: - hr = E_NOTIMPL; - break; - } - if (FAILED(hr)) - { - wprintf(L" FAILED [rotate color apply] (%08X%ls)\n", - static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - #ifndef NDEBUG - auto& tinfo = timage->GetMetadata(); - #endif - - assert(info.width == tinfo.width); - assert(info.height == tinfo.height); - assert(info.depth == tinfo.depth); - assert(info.arraySize == tinfo.arraySize); - assert(info.mipLevels == tinfo.mipLevels); - assert(info.miscFlags == tinfo.miscFlags); - assert(info.format == tinfo.format); - assert(info.dimension == tinfo.dimension); - - image.swap(timage); - cimage.reset(); - } - - // --- Tonemap (if requested) -------------------------------------------------- - if (dwOptions & uint64_t(1) << OPT_TONEMAP) - { - std::unique_ptr timage(new (std::nothrow) ScratchImage); - if (!timage) - { - wprintf(L"\nERROR: Memory allocation failed\n"); - return 1; - } - - // Compute max luminosity across all images - XMVECTOR maxLum = XMVectorZero(); - hr = EvaluateImage(image->GetImages(), image->GetImageCount(), image->GetMetadata(), - [&](const XMVECTOR* pixels, size_t w, size_t y) - { - UNREFERENCED_PARAMETER(y); - - for (size_t j = 0; j < w; ++j) - { - static const XMVECTORF32 s_luminance = { { { 0.3f, 0.59f, 0.11f, 0.f } } }; - - XMVECTOR v = *pixels++; - - v = XMVector3Dot(v, s_luminance); - - maxLum = XMVectorMax(v, maxLum); - } - }); - if (FAILED(hr)) - { - wprintf(L" FAILED [tonemap maxlum] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - // Reinhard et al, "Photographic Tone Reproduction for Digital Images" - // http://www.cs.utah.edu/~reinhard/cdrom/ - maxLum = XMVectorMultiply(maxLum, maxLum); - - hr = TransformImage(image->GetImages(), image->GetImageCount(), image->GetMetadata(), - [&](XMVECTOR* outPixels, const XMVECTOR* inPixels, size_t w, size_t y) - { - UNREFERENCED_PARAMETER(y); - - for (size_t j = 0; j < w; ++j) - { - XMVECTOR value = inPixels[j]; - - const XMVECTOR scale = XMVectorDivide( - XMVectorAdd(g_XMOne, XMVectorDivide(value, maxLum)), - XMVectorAdd(g_XMOne, value)); - const XMVECTOR nvalue = XMVectorMultiply(value, scale); - - value = XMVectorSelect(value, nvalue, g_XMSelect1110); - - outPixels[j] = value; - } - }, *timage); - if (FAILED(hr)) - { - wprintf(L" FAILED [tonemap apply] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - #ifndef NDEBUG - auto& tinfo = timage->GetMetadata(); - #endif - - assert(info.width == tinfo.width); - assert(info.height == tinfo.height); - assert(info.depth == tinfo.depth); - assert(info.arraySize == tinfo.arraySize); - assert(info.mipLevels == tinfo.mipLevels); - assert(info.miscFlags == tinfo.miscFlags); - assert(info.format == tinfo.format); - assert(info.dimension == tinfo.dimension); - - image.swap(timage); - cimage.reset(); - } - - // --- Convert ----------------------------------------------------------------- - if (dwOptions & (uint64_t(1) << OPT_NORMAL_MAP)) - { - std::unique_ptr timage(new (std::nothrow) ScratchImage); - if (!timage) - { - wprintf(L"\nERROR: Memory allocation failed\n"); - return 1; - } - - DXGI_FORMAT nmfmt = tformat; - if (IsCompressed(tformat)) - { - switch (tformat) - { - case DXGI_FORMAT_BC4_SNORM: - case DXGI_FORMAT_BC5_SNORM: - nmfmt = (BitsPerColor(info.format) > 8) ? DXGI_FORMAT_R16G16B16A16_SNORM : DXGI_FORMAT_R8G8B8A8_SNORM; - break; - - case DXGI_FORMAT_BC6H_SF16: - case DXGI_FORMAT_BC6H_UF16: - nmfmt = DXGI_FORMAT_R32G32B32_FLOAT; - break; - - default: - nmfmt = (BitsPerColor(info.format) > 8) ? DXGI_FORMAT_R16G16B16A16_UNORM : DXGI_FORMAT_R8G8B8A8_UNORM; - break; - } - } - - hr = ComputeNormalMap(image->GetImages(), image->GetImageCount(), image->GetMetadata(), dwNormalMap, nmapAmplitude, nmfmt, *timage); - if (FAILED(hr)) - { - wprintf(L" FAILED [normalmap] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - auto& tinfo = timage->GetMetadata(); - - assert(tinfo.format == nmfmt); - info.format = tinfo.format; - - assert(info.width == tinfo.width); - assert(info.height == tinfo.height); - assert(info.depth == tinfo.depth); - assert(info.arraySize == tinfo.arraySize); - assert(info.mipLevels == tinfo.mipLevels); - assert(info.miscFlags == tinfo.miscFlags); - assert(info.dimension == tinfo.dimension); - - image.swap(timage); - cimage.reset(); - } - else if (info.format != tformat && !IsCompressed(tformat)) - { - std::unique_ptr timage(new (std::nothrow) ScratchImage); - if (!timage) - { - wprintf(L"\nERROR: Memory allocation failed\n"); - return 1; - } - - hr = Convert(image->GetImages(), image->GetImageCount(), image->GetMetadata(), tformat, - dwFilter | dwFilterOpts | dwSRGB | dwConvert, alphaThreshold, *timage); - if (FAILED(hr)) - { - wprintf(L" FAILED [convert] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - auto& tinfo = timage->GetMetadata(); - - assert(tinfo.format == tformat); - info.format = tinfo.format; - - assert(info.width == tinfo.width); - assert(info.height == tinfo.height); - assert(info.depth == tinfo.depth); - assert(info.arraySize == tinfo.arraySize); - assert(info.mipLevels == tinfo.mipLevels); - assert(info.miscFlags == tinfo.miscFlags); - assert(info.dimension == tinfo.dimension); - - image.swap(timage); - cimage.reset(); - } - - // --- ColorKey/ChromaKey ------------------------------------------------------ - if ((dwOptions & (uint64_t(1) << OPT_COLORKEY)) - && HasAlpha(info.format)) - { - std::unique_ptr timage(new (std::nothrow) ScratchImage); - if (!timage) - { - wprintf(L"\nERROR: Memory allocation failed\n"); - return 1; - } - - XMVECTOR colorKeyValue = XMLoadColor(reinterpret_cast(&colorKey)); - - hr = TransformImage(image->GetImages(), image->GetImageCount(), image->GetMetadata(), - [&](XMVECTOR* outPixels, const XMVECTOR* inPixels, size_t w, size_t y) - { - static const XMVECTORF32 s_tolerance = { { { 0.2f, 0.2f, 0.2f, 0.f } } }; - - UNREFERENCED_PARAMETER(y); - - for (size_t j = 0; j < w; ++j) - { - XMVECTOR value = inPixels[j]; - - if (XMVector3NearEqual(value, colorKeyValue, s_tolerance)) - { - value = g_XMZero; - } - else - { - value = XMVectorSelect(g_XMOne, value, g_XMSelect1110); - } - - outPixels[j] = value; - } - }, *timage); - if (FAILED(hr)) - { - wprintf(L" FAILED [colorkey] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - #ifndef NDEBUG - auto& tinfo = timage->GetMetadata(); - #endif - - assert(info.width == tinfo.width); - assert(info.height == tinfo.height); - assert(info.depth == tinfo.depth); - assert(info.arraySize == tinfo.arraySize); - assert(info.mipLevels == tinfo.mipLevels); - assert(info.miscFlags == tinfo.miscFlags); - assert(info.format == tinfo.format); - assert(info.dimension == tinfo.dimension); - - image.swap(timage); - cimage.reset(); - } - - // --- Invert Y Channel -------------------------------------------------------- - if (dwOptions & (uint64_t(1) << OPT_INVERT_Y)) - { - std::unique_ptr timage(new (std::nothrow) ScratchImage); - if (!timage) - { - wprintf(L"\nERROR: Memory allocation failed\n"); - return 1; - } - - hr = TransformImage(image->GetImages(), image->GetImageCount(), image->GetMetadata(), - [&](XMVECTOR* outPixels, const XMVECTOR* inPixels, size_t w, size_t y) - { - static const XMVECTORU32 s_selecty = { { { XM_SELECT_0, XM_SELECT_1, XM_SELECT_0, XM_SELECT_0 } } }; - - UNREFERENCED_PARAMETER(y); - - for (size_t j = 0; j < w; ++j) - { - const XMVECTOR value = inPixels[j]; - - const XMVECTOR inverty = XMVectorSubtract(g_XMOne, value); - - outPixels[j] = XMVectorSelect(value, inverty, s_selecty); - } - }, *timage); - if (FAILED(hr)) - { - wprintf(L" FAILED [inverty] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - #ifndef NDEBUG - auto& tinfo = timage->GetMetadata(); - #endif - - assert(info.width == tinfo.width); - assert(info.height == tinfo.height); - assert(info.depth == tinfo.depth); - assert(info.arraySize == tinfo.arraySize); - assert(info.mipLevels == tinfo.mipLevels); - assert(info.miscFlags == tinfo.miscFlags); - assert(info.format == tinfo.format); - assert(info.dimension == tinfo.dimension); - - image.swap(timage); - cimage.reset(); - } - - // --- Reconstruct Z Channel --------------------------------------------------- - if (dwOptions & (uint64_t(1) << OPT_RECONSTRUCT_Z)) - { - std::unique_ptr timage(new (std::nothrow) ScratchImage); - if (!timage) - { - wprintf(L"\nERROR: Memory allocation failed\n"); - return 1; - } - - bool isunorm = (FormatDataType(info.format) == FORMAT_TYPE_UNORM) != 0; - - hr = TransformImage(image->GetImages(), image->GetImageCount(), image->GetMetadata(), - [&](XMVECTOR* outPixels, const XMVECTOR* inPixels, size_t w, size_t y) - { - static const XMVECTORU32 s_selectz = { { { XM_SELECT_0, XM_SELECT_0, XM_SELECT_1, XM_SELECT_0 } } }; - - UNREFERENCED_PARAMETER(y); - - for (size_t j = 0; j < w; ++j) - { - const XMVECTOR value = inPixels[j]; - - XMVECTOR z; - if (isunorm) - { - XMVECTOR x2 = XMVectorMultiplyAdd(value, g_XMTwo, g_XMNegativeOne); - x2 = XMVectorSqrt(XMVectorSubtract(g_XMOne, XMVector2Dot(x2, x2))); - z = XMVectorMultiplyAdd(x2, g_XMOneHalf, g_XMOneHalf); - } - else - { - z = XMVectorSqrt(XMVectorSubtract(g_XMOne, XMVector2Dot(value, value))); - } - - outPixels[j] = XMVectorSelect(value, z, s_selectz); - } - }, *timage); - if (FAILED(hr)) - { - wprintf(L" FAILED [reconstructz] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - #ifndef NDEBUG - auto& tinfo = timage->GetMetadata(); - #endif - - assert(info.width == tinfo.width); - assert(info.height == tinfo.height); - assert(info.depth == tinfo.depth); - assert(info.arraySize == tinfo.arraySize); - assert(info.mipLevels == tinfo.mipLevels); - assert(info.miscFlags == tinfo.miscFlags); - assert(info.format == tinfo.format); - assert(info.dimension == tinfo.dimension); - - image.swap(timage); - cimage.reset(); - } - - // --- Determine whether preserve alpha coverage is required (if requested) ---- - if (preserveAlphaCoverageRef > 0.0f && HasAlpha(info.format) && !image->IsAlphaAllOpaque()) - { - preserveAlphaCoverage = true; - } - - // --- Generate mips ----------------------------------------------------------- - TEX_FILTER_FLAGS dwFilter3D = dwFilter; - if (!ispow2(info.width) || !ispow2(info.height) || !ispow2(info.depth)) - { - if (!tMips || info.mipLevels != 1) - { - nonpow2warn = true; - } - - if (info.dimension == TEX_DIMENSION_TEXTURE3D) - { - // Must force triangle filter for non-power-of-2 volume textures to get correct results - dwFilter3D = TEX_FILTER_TRIANGLE; - } - } - - if ((!tMips || info.mipLevels != tMips || preserveAlphaCoverage) && (info.mipLevels != 1)) - { - // Mips generation only works on a single base image, so strip off existing mip levels - // Also required for preserve alpha coverage so that existing mips are regenerated - - std::unique_ptr timage(new (std::nothrow) ScratchImage); - if (!timage) - { - wprintf(L"\nERROR: Memory allocation failed\n"); - return 1; - } - - TexMetadata mdata = info; - mdata.mipLevels = 1; - hr = timage->Initialize(mdata); - if (FAILED(hr)) - { - wprintf(L" FAILED [copy to single level] (%08X%ls)\n", - static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - if (info.dimension == TEX_DIMENSION_TEXTURE3D) - { - for (size_t d = 0; d < info.depth; ++d) - { - hr = CopyRectangle(*image->GetImage(0, 0, d), Rect(0, 0, info.width, info.height), - *timage->GetImage(0, 0, d), TEX_FILTER_DEFAULT, 0, 0); - if (FAILED(hr)) - { - wprintf(L" FAILED [copy to single level] (%08X%ls)\n", - static_cast(hr), GetErrorDesc(hr)); - return 1; - } - } - } - else - { - for (size_t i = 0; i < info.arraySize; ++i) - { - hr = CopyRectangle(*image->GetImage(0, i, 0), Rect(0, 0, info.width, info.height), - *timage->GetImage(0, i, 0), TEX_FILTER_DEFAULT, 0, 0); - if (FAILED(hr)) - { - wprintf(L" FAILED [copy to single level] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - } - } - - image.swap(timage); - info.mipLevels = 1; - - if (cimage && (tMips == 1)) - { - // Special case for trimming mips off compressed images and keeping the original compressed highest level mip - mdata = cimage->GetMetadata(); - mdata.mipLevels = 1; - hr = timage->Initialize(mdata); - if (FAILED(hr)) - { - wprintf(L" FAILED [copy compressed to single level] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - if (mdata.dimension == TEX_DIMENSION_TEXTURE3D) - { - for (size_t d = 0; d < mdata.depth; ++d) - { - auto simg = cimage->GetImage(0, 0, d); - auto dimg = timage->GetImage(0, 0, d); - - memcpy_s(dimg->pixels, dimg->slicePitch, simg->pixels, simg->slicePitch); - } - } - else - { - for (size_t i = 0; i < mdata.arraySize; ++i) - { - auto simg = cimage->GetImage(0, i, 0); - auto dimg = timage->GetImage(0, i, 0); - - memcpy_s(dimg->pixels, dimg->slicePitch, simg->pixels, simg->slicePitch); - } - } - - cimage.swap(timage); - } - else - { - cimage.reset(); - } - } - - if ((!tMips || info.mipLevels != tMips) && (info.width > 1 || info.height > 1 || info.depth > 1)) - { - std::unique_ptr timage(new (std::nothrow) ScratchImage); - if (!timage) - { - wprintf(L"\nERROR: Memory allocation failed\n"); - return 1; - } - - if (info.dimension == TEX_DIMENSION_TEXTURE3D) - { - hr = GenerateMipMaps3D(image->GetImages(), image->GetImageCount(), image->GetMetadata(), dwFilter3D | dwFilterOpts, tMips, *timage); - } - else - { - hr = GenerateMipMaps(image->GetImages(), image->GetImageCount(), image->GetMetadata(), dwFilter | dwFilterOpts, tMips, *timage); - } - if (FAILED(hr)) - { - wprintf(L" FAILED [mipmaps] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - auto& tinfo = timage->GetMetadata(); - info.mipLevels = tinfo.mipLevels; - - assert(info.width == tinfo.width); - assert(info.height == tinfo.height); - assert(info.depth == tinfo.depth); - assert(info.arraySize == tinfo.arraySize); - assert(info.miscFlags == tinfo.miscFlags); - assert(info.format == tinfo.format); - assert(info.dimension == tinfo.dimension); - - image.swap(timage); - cimage.reset(); - } - - // --- Preserve mipmap alpha coverage (if requested) --------------------------- - if (preserveAlphaCoverage && info.mipLevels != 1 && (info.dimension != TEX_DIMENSION_TEXTURE3D)) - { - std::unique_ptr timage(new (std::nothrow) ScratchImage); - if (!timage) - { - wprintf(L"\nERROR: Memory allocation failed\n"); - return 1; - } - - hr = timage->Initialize(image->GetMetadata()); - if (FAILED(hr)) - { - wprintf(L" FAILED [keepcoverage] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - const size_t items = image->GetMetadata().arraySize; - for (size_t item = 0; item < items; ++item) - { - auto img = image->GetImage(0, item, 0); - assert(img); - - hr = ScaleMipMapsAlphaForCoverage(img, info.mipLevels, info, item, preserveAlphaCoverageRef, *timage); - if (FAILED(hr)) - { - wprintf(L" FAILED [keepcoverage] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - } - - #ifndef NDEBUG - auto& tinfo = timage->GetMetadata(); - #endif - - assert(info.width == tinfo.width); - assert(info.height == tinfo.height); - assert(info.depth == tinfo.depth); - assert(info.arraySize == tinfo.arraySize); - assert(info.mipLevels == tinfo.mipLevels); - assert(info.miscFlags == tinfo.miscFlags); - assert(info.dimension == tinfo.dimension); - - image.swap(timage); - cimage.reset(); - } - - // --- Premultiplied alpha (if requested) -------------------------------------- - if ((dwOptions & (uint64_t(1) << OPT_PREMUL_ALPHA)) - && HasAlpha(info.format) - && info.format != DXGI_FORMAT_A8_UNORM) - { - if (info.IsPMAlpha()) - { - printf("\nWARNING: Image is already using premultiplied alpha\n"); - } - else - { - auto img = image->GetImage(0, 0, 0); - assert(img); - const size_t nimg = image->GetImageCount(); - - std::unique_ptr timage(new (std::nothrow) ScratchImage); - if (!timage) - { - wprintf(L"\nERROR: Memory allocation failed\n"); - return 1; - } - - hr = PremultiplyAlpha(img, nimg, info, TEX_PMALPHA_DEFAULT | dwSRGB, *timage); - if (FAILED(hr)) - { - wprintf(L" FAILED [premultiply alpha] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - retVal = 1; - continue; - } - - auto& tinfo = timage->GetMetadata(); - info.miscFlags2 = tinfo.miscFlags2; - - assert(info.width == tinfo.width); - assert(info.height == tinfo.height); - assert(info.depth == tinfo.depth); - assert(info.arraySize == tinfo.arraySize); - assert(info.mipLevels == tinfo.mipLevels); - assert(info.miscFlags == tinfo.miscFlags); - assert(info.dimension == tinfo.dimension); - - image.swap(timage); - cimage.reset(); - } - } - - // --- Compress ---------------------------------------------------------------- - if (IsCompressed(tformat) && (FileType == CODEC_DDS)) - { - if (cimage && (cimage->GetMetadata().format == tformat)) - { - // We never changed the image and it was already compressed in our desired format, use original data - image.reset(cimage.release()); - - auto& tinfo = image->GetMetadata(); - - if ((tinfo.width % 4) != 0 || (tinfo.height % 4) != 0) - { - non4bc = true; - } - - info.format = tinfo.format; - assert(info.width == tinfo.width); - assert(info.height == tinfo.height); - assert(info.depth == tinfo.depth); - assert(info.arraySize == tinfo.arraySize); - assert(info.mipLevels == tinfo.mipLevels); - assert(info.miscFlags == tinfo.miscFlags); - assert(info.dimension == tinfo.dimension); - } - else - { - cimage.reset(); - - auto img = image->GetImage(0, 0, 0); - assert(img); - const size_t nimg = image->GetImageCount(); - - std::unique_ptr timage(new (std::nothrow) ScratchImage); - if (!timage) - { - wprintf(L"\nERROR: Memory allocation failed\n"); - return 1; - } - - bool bc6hbc7 = false; - switch (tformat) - { - case DXGI_FORMAT_BC6H_TYPELESS: - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - case DXGI_FORMAT_BC7_TYPELESS: - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: - bc6hbc7 = true; - - { - static bool s_tryonce = false; - - if (!s_tryonce) - { - s_tryonce = true; - - if (!(dwOptions & (uint64_t(1) << OPT_NOGPU))) - { - if (!CreateDevice(adapter, pDevice.GetAddressOf())) - wprintf(L"\nWARNING: DirectCompute is not available, using BC6H / BC7 CPU codec\n"); - } - else - { - wprintf(L"\nWARNING: using BC6H / BC7 CPU codec\n"); - } - } - } - break; - - default: - break; - } - - TEX_COMPRESS_FLAGS cflags = dwCompress; - #ifdef _OPENMP - if (!(dwOptions & (uint64_t(1) << OPT_FORCE_SINGLEPROC))) - { - cflags |= TEX_COMPRESS_PARALLEL; - } - #endif - - if ((img->width % 4) != 0 || (img->height % 4) != 0) - { - non4bc = true; - } - - if (bc6hbc7 && pDevice) - { - hr = Compress(pDevice.Get(), img, nimg, info, tformat, dwCompress | dwSRGB, alphaWeight, *timage); - } - else - { - hr = Compress(img, nimg, info, tformat, cflags | dwSRGB, alphaThreshold, *timage); - } - if (FAILED(hr)) - { - wprintf(L" FAILED [compress] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - retVal = 1; - continue; - } - - auto& tinfo = timage->GetMetadata(); - - info.format = tinfo.format; - assert(info.width == tinfo.width); - assert(info.height == tinfo.height); - assert(info.depth == tinfo.depth); - assert(info.arraySize == tinfo.arraySize); - assert(info.mipLevels == tinfo.mipLevels); - assert(info.miscFlags == tinfo.miscFlags); - assert(info.dimension == tinfo.dimension); - - image.swap(timage); - } - } - else - { - cimage.reset(); - } - - // --- Set alpha mode ---------------------------------------------------------- - if (HasAlpha(info.format) - && info.format != DXGI_FORMAT_A8_UNORM) - { - if (image->IsAlphaAllOpaque()) - { - info.SetAlphaMode(TEX_ALPHA_MODE_OPAQUE); - } - else if (info.IsPMAlpha()) - { - // Aleady set TEX_ALPHA_MODE_PREMULTIPLIED - } - else if (dwOptions & (uint64_t(1) << OPT_SEPALPHA)) - { - info.SetAlphaMode(TEX_ALPHA_MODE_CUSTOM); - } - else if (info.GetAlphaMode() == TEX_ALPHA_MODE_UNKNOWN) - { - info.SetAlphaMode(TEX_ALPHA_MODE_STRAIGHT); - } - } - else - { - info.SetAlphaMode(TEX_ALPHA_MODE_UNKNOWN); - } - - // --- Save result ------------------------------------------------------------- - { - auto img = image->GetImage(0, 0, 0); - assert(img); - const size_t nimg = image->GetImageCount(); - - PrintInfo(info); - wprintf(L"\n"); - - // Figure out dest filename - wchar_t *pchSlash, *pchDot; - - wchar_t szDest[1024] = {}; - wcscpy_s(szDest, szOutputDir); - - if (keepRecursiveDirs && *pConv->szFolder) - { - wcscat_s(szDest, pConv->szFolder); - - wchar_t szPath[MAX_PATH] = {}; - if (!GetFullPathNameW(szDest, MAX_PATH, szPath, nullptr)) - { - wprintf(L" get full path FAILED (%08X%ls)\n", - static_cast(HRESULT_FROM_WIN32(GetLastError())), GetErrorDesc(HRESULT_FROM_WIN32(GetLastError()))); - retVal = 1; - continue; - } - - auto const err = static_cast(SHCreateDirectoryExW(nullptr, szPath, nullptr)); - if (err != ERROR_SUCCESS && err != ERROR_ALREADY_EXISTS) - { - wprintf(L" directory creation FAILED (%08X%ls)\n", - static_cast(HRESULT_FROM_WIN32(err)), GetErrorDesc(HRESULT_FROM_WIN32(err))); - retVal = 1; - continue; - } - } - - if (*szPrefix) - wcscat_s(szDest, szPrefix); - - pchSlash = wcsrchr(pConv->szSrc, L'\\'); - if (pchSlash) - wcscat_s(szDest, pchSlash + 1); - else - wcscat_s(szDest, pConv->szSrc); - - pchSlash = wcsrchr(szDest, '\\'); - pchDot = wcsrchr(szDest, '.'); - - if (pchDot > pchSlash) - *pchDot = 0; - - if (*szSuffix) - wcscat_s(szDest, szSuffix); - - if (dwOptions & (uint64_t(1) << OPT_TOLOWER)) - { - std::ignore = _wcslwr_s(szDest); - } - - if (wcslen(szDest) > _MAX_PATH) - { - wprintf(L"\nERROR: Output filename exceeds max-path, skipping!\n"); - retVal = 1; - continue; - } - - // Write texture - wprintf(L"writing %ls", szDest); - fflush(stdout); - - if (~dwOptions & (uint64_t(1) << OPT_OVERWRITE)) - { - if (GetFileAttributesW(szDest) != INVALID_FILE_ATTRIBUTES) - { - wprintf(L"\nERROR: Output file already exists, use -y to overwrite:\n"); - retVal = 1; - continue; - } - } - - switch (FileType) - { - case CODEC_DDS: - { - DDS_FLAGS ddsFlags = DDS_FLAGS_NONE; - if (dwOptions & (uint64_t(1) << OPT_USE_DX10)) - { - ddsFlags |= DDS_FLAGS_FORCE_DX10_EXT | DDS_FLAGS_FORCE_DX10_EXT_MISC2; - } - else if (dwOptions & (uint64_t(1) << OPT_USE_DX9)) - { - ddsFlags |= DDS_FLAGS_FORCE_DX9_LEGACY; - } - - hr = SaveToDDSFile(img, nimg, info, ddsFlags, szDest); - break; - } - - case CODEC_TGA: - hr = SaveToTGAFile(img[0], TGA_FLAGS_NONE, szDest, (dwOptions & (uint64_t(1) << OPT_TGA20)) ? &info : nullptr); - break; - - case CODEC_HDR: - hr = SaveToHDRFile(img[0], szDest); - break; - - case CODEC_PPM: - hr = SaveToPortablePixMap(img[0], szDest); - break; - - case CODEC_PFM: - hr = SaveToPortablePixMapHDR(img[0], szDest); - break; - - #ifdef USE_OPENEXR - case CODEC_EXR: - hr = SaveToEXRFile(img[0], szDest); - break; - #endif - - default: - { - const WICCodecs codec = (FileType == CODEC_HDP || FileType == CODEC_JXR) ? WIC_CODEC_WMP : static_cast(FileType); - const size_t nimages = (dwOptions & (uint64_t(1) << OPT_WIC_MULTIFRAME)) ? nimg : 1; - hr = SaveToWICFile(img, nimages, WIC_FLAGS_NONE, GetWICCodec(codec), szDest, nullptr, - [&](IPropertyBag2* props) - { - const bool wicLossless = (dwOptions & (uint64_t(1) << OPT_WIC_LOSSLESS)) != 0; - - switch (FileType) - { - case WIC_CODEC_JPEG: - if (wicLossless || wicQuality >= 0.f) - { - PROPBAG2 options = {}; - VARIANT varValues = {}; - options.pstrName = const_cast(L"ImageQuality"); - varValues.vt = VT_R4; - varValues.fltVal = (wicLossless) ? 1.f : wicQuality; - std::ignore = props->Write(1, &options, &varValues); - } - break; - - case WIC_CODEC_TIFF: - { - PROPBAG2 options = {}; - VARIANT varValues = {}; - if (wicLossless) - { - options.pstrName = const_cast(L"TiffCompressionMethod"); - varValues.vt = VT_UI1; - varValues.bVal = WICTiffCompressionNone; - } - else if (wicQuality >= 0.f) - { - options.pstrName = const_cast(L"CompressionQuality"); - varValues.vt = VT_R4; - varValues.fltVal = wicQuality; - } - std::ignore = props->Write(1, &options, &varValues); - } - break; - - case WIC_CODEC_WMP: - case CODEC_HDP: - case CODEC_JXR: - { - PROPBAG2 options = {}; - VARIANT varValues = {}; - if (wicLossless) - { - options.pstrName = const_cast(L"Lossless"); - varValues.vt = VT_BOOL; - varValues.bVal = TRUE; - } - else if (wicQuality >= 0.f) - { - options.pstrName = const_cast(L"ImageQuality"); - varValues.vt = VT_R4; - varValues.fltVal = wicQuality; - } - std::ignore = props->Write(1, &options, &varValues); - } - break; - } - }); - } - break; - } - - if (FAILED(hr)) - { - wprintf(L" FAILED (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - retVal = 1; - if ((hr == static_cast(0xc00d5212) /* MF_E_TOPO_CODEC_NOT_FOUND */) && (FileType == WIC_CODEC_HEIF)) - { - wprintf(L"INFO: This format requires installing the HEIF Image Extensions - https://aka.ms/heif\n"); - } - continue; - } - wprintf(L"\n"); - } - } - - if (sizewarn) - { - wprintf(L"\nWARNING: Target size exceeds maximum size for feature level (%u)\n", maxSize); - } - - if (nonpow2warn && maxSize <= 4096) - { - // Only emit this warning if ran with -fl set to a 9.x feature level - wprintf(L"\nWARNING: Not all feature levels support non-power-of-2 textures with mipmaps\n"); - } - - if (non4bc) - wprintf(L"\nWARNING: Direct3D requires BC image to be multiple of 4 in width & height\n"); - - if (dwOptions & (uint64_t(1) << OPT_TIMING)) - { - LARGE_INTEGER qpcEnd = {}; - std::ignore = QueryPerformanceCounter(&qpcEnd); - - const LONGLONG delta = qpcEnd.QuadPart - qpcStart.QuadPart; - wprintf(L"\n Processing time: %f seconds\n", double(delta) / double(qpcFreq.QuadPart)); - } - - return retVal; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texdiag/directx.ico b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texdiag/directx.ico deleted file mode 100644 index bc43c1b..0000000 Binary files a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texdiag/directx.ico and /dev/null differ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texdiag/texdiag.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texdiag/texdiag.cpp deleted file mode 100644 index 37bc46a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texdiag/texdiag.cpp +++ /dev/null @@ -1,4172 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: Texdiag.cpp -// -// DirectX Texture diagnostic tool -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//-------------------------------------------------------------------------------------- - -#pragma warning(push) -#pragma warning(disable : 4005) -#define WIN32_LEAN_AND_MEAN -#define NOMINMAX -#define NODRAWTEXT -#define NOGDI -#define NOMCX -#define NOSERVICE -#define NOHELP -#pragma warning(pop) - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#pragma warning(disable : 4619 4616 26812) - -#include "DirectXTex.h" - -#include - -//Uncomment to add support for OpenEXR (.exr) -//#define USE_OPENEXR - -#ifdef USE_OPENEXR -// See for details -#include "DirectXTexEXR.h" -#endif - -using namespace DirectX; - -enum COMMANDS : uint32_t -{ - CMD_INFO = 1, - CMD_ANALYZE, - CMD_COMPARE, - CMD_DIFF, - CMD_DUMPBC, - CMD_DUMPDDS, - CMD_MAX -}; - -enum OPTIONS : uint32_t -{ - OPT_RECURSIVE = 1, - OPT_FORMAT, - OPT_FILTER, - OPT_DDS_DWORD_ALIGN, - OPT_DDS_BAD_DXTN_TAILS, - OPT_OUTPUTFILE, - OPT_TOLOWER, - OPT_OVERWRITE, - OPT_FILETYPE, - OPT_NOLOGO, - OPT_TYPELESS_UNORM, - OPT_TYPELESS_FLOAT, - OPT_EXPAND_LUMINANCE, - OPT_TARGET_PIXELX, - OPT_TARGET_PIXELY, - OPT_DIFF_COLOR, - OPT_THRESHOLD, - OPT_FILELIST, - OPT_MAX -}; - -static_assert(OPT_MAX <= 32, "dwOptions is a unsigned int bitfield"); - -struct SConversion -{ - wchar_t szSrc[MAX_PATH]; -}; - -struct SValue -{ - const wchar_t* name; - uint32_t value; -}; - -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -const SValue g_pCommands[] = -{ - { L"info", CMD_INFO }, - { L"analyze", CMD_ANALYZE }, - { L"compare", CMD_COMPARE }, - { L"diff", CMD_DIFF }, - { L"dumpbc", CMD_DUMPBC }, - { L"dumpdds", CMD_DUMPDDS }, - { nullptr, 0 } -}; - -const SValue g_pOptions[] = -{ - { L"r", OPT_RECURSIVE }, - { L"f", OPT_FORMAT }, - { L"if", OPT_FILTER }, - { L"dword", OPT_DDS_DWORD_ALIGN }, - { L"badtails", OPT_DDS_BAD_DXTN_TAILS }, - { L"nologo", OPT_NOLOGO }, - { L"o", OPT_OUTPUTFILE }, - { L"l", OPT_TOLOWER }, - { L"y", OPT_OVERWRITE }, - { L"ft", OPT_FILETYPE }, - { L"tu", OPT_TYPELESS_UNORM }, - { L"tf", OPT_TYPELESS_FLOAT }, - { L"xlum", OPT_EXPAND_LUMINANCE }, - { L"targetx", OPT_TARGET_PIXELX }, - { L"targety", OPT_TARGET_PIXELY }, - { L"c", OPT_DIFF_COLOR }, - { L"t", OPT_THRESHOLD }, - { L"flist", OPT_FILELIST }, - { nullptr, 0 } -}; - -#define DEFFMT(fmt) { L## #fmt, DXGI_FORMAT_ ## fmt } - -const SValue g_pFormats[] = -{ - // List does not include _TYPELESS, depth/stencil, or BC formats - DEFFMT(R32G32B32A32_FLOAT), - DEFFMT(R32G32B32A32_UINT), - DEFFMT(R32G32B32A32_SINT), - DEFFMT(R32G32B32_FLOAT), - DEFFMT(R32G32B32_UINT), - DEFFMT(R32G32B32_SINT), - DEFFMT(R16G16B16A16_FLOAT), - DEFFMT(R16G16B16A16_UNORM), - DEFFMT(R16G16B16A16_UINT), - DEFFMT(R16G16B16A16_SNORM), - DEFFMT(R16G16B16A16_SINT), - DEFFMT(R32G32_FLOAT), - DEFFMT(R32G32_UINT), - DEFFMT(R32G32_SINT), - DEFFMT(R10G10B10A2_UNORM), - DEFFMT(R10G10B10A2_UINT), - DEFFMT(R11G11B10_FLOAT), - DEFFMT(R8G8B8A8_UNORM), - DEFFMT(R8G8B8A8_UNORM_SRGB), - DEFFMT(R8G8B8A8_UINT), - DEFFMT(R8G8B8A8_SNORM), - DEFFMT(R8G8B8A8_SINT), - DEFFMT(R16G16_FLOAT), - DEFFMT(R16G16_UNORM), - DEFFMT(R16G16_UINT), - DEFFMT(R16G16_SNORM), - DEFFMT(R16G16_SINT), - DEFFMT(R32_FLOAT), - DEFFMT(R32_UINT), - DEFFMT(R32_SINT), - DEFFMT(R8G8_UNORM), - DEFFMT(R8G8_UINT), - DEFFMT(R8G8_SNORM), - DEFFMT(R8G8_SINT), - DEFFMT(R16_FLOAT), - DEFFMT(R16_UNORM), - DEFFMT(R16_UINT), - DEFFMT(R16_SNORM), - DEFFMT(R16_SINT), - DEFFMT(R8_UNORM), - DEFFMT(R8_UINT), - DEFFMT(R8_SNORM), - DEFFMT(R8_SINT), - DEFFMT(A8_UNORM), - DEFFMT(R9G9B9E5_SHAREDEXP), - DEFFMT(R8G8_B8G8_UNORM), - DEFFMT(G8R8_G8B8_UNORM), - DEFFMT(B5G6R5_UNORM), - DEFFMT(B5G5R5A1_UNORM), - - // DXGI 1.1 formats - DEFFMT(B8G8R8A8_UNORM), - DEFFMT(B8G8R8X8_UNORM), - DEFFMT(R10G10B10_XR_BIAS_A2_UNORM), - DEFFMT(B8G8R8A8_UNORM_SRGB), - DEFFMT(B8G8R8X8_UNORM_SRGB), - - // DXGI 1.2 formats - DEFFMT(AYUV), - DEFFMT(Y410), - DEFFMT(Y416), - DEFFMT(YUY2), - DEFFMT(Y210), - DEFFMT(Y216), - DEFFMT(B4G4R4A4_UNORM), - - { nullptr, DXGI_FORMAT_UNKNOWN } -}; - -const SValue g_pFormatAliases[] = -{ - { L"RGBA", DXGI_FORMAT_R8G8B8A8_UNORM }, - { L"BGRA", DXGI_FORMAT_B8G8R8A8_UNORM }, - { L"BGR", DXGI_FORMAT_B8G8R8X8_UNORM }, - - { L"FP16", DXGI_FORMAT_R16G16B16A16_FLOAT }, - { L"FP32", DXGI_FORMAT_R32G32B32A32_FLOAT }, - - { nullptr, DXGI_FORMAT_UNKNOWN } -}; - -const SValue g_pReadOnlyFormats[] = -{ - DEFFMT(R32G32B32A32_TYPELESS), - DEFFMT(R32G32B32_TYPELESS), - DEFFMT(R16G16B16A16_TYPELESS), - DEFFMT(R32G32_TYPELESS), - DEFFMT(R32G8X24_TYPELESS), - DEFFMT(D32_FLOAT_S8X24_UINT), - DEFFMT(R32_FLOAT_X8X24_TYPELESS), - DEFFMT(X32_TYPELESS_G8X24_UINT), - DEFFMT(R10G10B10A2_TYPELESS), - DEFFMT(R8G8B8A8_TYPELESS), - DEFFMT(R16G16_TYPELESS), - DEFFMT(R32_TYPELESS), - DEFFMT(D32_FLOAT), - DEFFMT(R24G8_TYPELESS), - DEFFMT(D24_UNORM_S8_UINT), - DEFFMT(R24_UNORM_X8_TYPELESS), - DEFFMT(X24_TYPELESS_G8_UINT), - DEFFMT(R8G8_TYPELESS), - DEFFMT(R16_TYPELESS), - DEFFMT(R8_TYPELESS), - DEFFMT(BC1_TYPELESS), - DEFFMT(BC1_UNORM), - DEFFMT(BC1_UNORM_SRGB), - DEFFMT(BC2_TYPELESS), - DEFFMT(BC2_UNORM), - DEFFMT(BC2_UNORM_SRGB), - DEFFMT(BC3_TYPELESS), - DEFFMT(BC3_UNORM), - DEFFMT(BC3_UNORM_SRGB), - DEFFMT(BC4_TYPELESS), - DEFFMT(BC4_UNORM), - DEFFMT(BC4_SNORM), - DEFFMT(BC5_TYPELESS), - DEFFMT(BC5_UNORM), - DEFFMT(BC5_SNORM), - - // DXGI 1.1 formats - DEFFMT(B8G8R8A8_TYPELESS), - DEFFMT(B8G8R8X8_TYPELESS), - DEFFMT(BC6H_TYPELESS), - DEFFMT(BC6H_UF16), - DEFFMT(BC6H_SF16), - DEFFMT(BC7_TYPELESS), - DEFFMT(BC7_UNORM), - DEFFMT(BC7_UNORM_SRGB), - - // DXGI 1.2 formats - DEFFMT(AI44), - DEFFMT(IA44), - DEFFMT(P8), - DEFFMT(A8P8), - DEFFMT(NV12), - DEFFMT(P010), - DEFFMT(P016), - DEFFMT(420_OPAQUE), - DEFFMT(NV11), - - // DXGI 1.3 formats - { L"P208", DXGI_FORMAT(130) }, - { L"V208", DXGI_FORMAT(131) }, - { L"V408", DXGI_FORMAT(132) }, - - // Xbox-specific formats - { L"R10G10B10_7E3_A2_FLOAT (Xbox)", DXGI_FORMAT(116) }, - { L"R10G10B10_6E4_A2_FLOAT (Xbox)", DXGI_FORMAT(117) }, - { L"D16_UNORM_S8_UINT (Xbox)", DXGI_FORMAT(118) }, - { L"R16_UNORM_X8_TYPELESS (Xbox)", DXGI_FORMAT(119) }, - { L"X16_TYPELESS_G8_UINT (Xbox)", DXGI_FORMAT(120) }, - { L"R10G10B10_SNORM_A2_UNORM (Xbox)", DXGI_FORMAT(189) }, - { L"R4G4_UNORM (Xbox)", DXGI_FORMAT(190) }, - - { nullptr, DXGI_FORMAT_UNKNOWN } -}; - -const SValue g_pFilters[] = -{ - { L"POINT", TEX_FILTER_POINT }, - { L"LINEAR", TEX_FILTER_LINEAR }, - { L"CUBIC", TEX_FILTER_CUBIC }, - { L"FANT", TEX_FILTER_FANT }, - { L"BOX", TEX_FILTER_BOX }, - { L"TRIANGLE", TEX_FILTER_TRIANGLE }, - { L"POINT_DITHER", TEX_FILTER_POINT | TEX_FILTER_DITHER }, - { L"LINEAR_DITHER", TEX_FILTER_LINEAR | TEX_FILTER_DITHER }, - { L"CUBIC_DITHER", TEX_FILTER_CUBIC | TEX_FILTER_DITHER }, - { L"FANT_DITHER", TEX_FILTER_FANT | TEX_FILTER_DITHER }, - { L"BOX_DITHER", TEX_FILTER_BOX | TEX_FILTER_DITHER }, - { L"TRIANGLE_DITHER", TEX_FILTER_TRIANGLE | TEX_FILTER_DITHER }, - { L"POINT_DITHER_DIFFUSION", TEX_FILTER_POINT | TEX_FILTER_DITHER_DIFFUSION }, - { L"LINEAR_DITHER_DIFFUSION", TEX_FILTER_LINEAR | TEX_FILTER_DITHER_DIFFUSION }, - { L"CUBIC_DITHER_DIFFUSION", TEX_FILTER_CUBIC | TEX_FILTER_DITHER_DIFFUSION }, - { L"FANT_DITHER_DIFFUSION", TEX_FILTER_FANT | TEX_FILTER_DITHER_DIFFUSION }, - { L"BOX_DITHER_DIFFUSION", TEX_FILTER_BOX | TEX_FILTER_DITHER_DIFFUSION }, - { L"TRIANGLE_DITHER_DIFFUSION", TEX_FILTER_TRIANGLE | TEX_FILTER_DITHER_DIFFUSION }, - { nullptr, TEX_FILTER_DEFAULT } -}; - -#define CODEC_DDS 0xFFFF0001 -#define CODEC_TGA 0xFFFF0002 -#define CODEC_HDR 0xFFFF0005 - -#ifdef USE_OPENEXR -#define CODEC_EXR 0xFFFF0006 -#endif - -const SValue g_pDumpFileTypes[] = -{ - { L"bmp", WIC_CODEC_BMP }, - { L"jpg", WIC_CODEC_JPEG }, - { L"jpeg", WIC_CODEC_JPEG }, - { L"png", WIC_CODEC_PNG }, - { L"tga", CODEC_TGA }, - { L"hdr", CODEC_HDR }, - { L"tif", WIC_CODEC_TIFF }, - { L"tiff", WIC_CODEC_TIFF }, - { L"jxr", WIC_CODEC_WMP }, -#ifdef USE_OPENEXR - { L"exr", CODEC_EXR }, -#endif - { nullptr, CODEC_DDS } -}; - -const SValue g_pExtFileTypes[] = -{ - { L".bmp", WIC_CODEC_BMP }, - { L".jpg", WIC_CODEC_JPEG }, - { L".jpeg", WIC_CODEC_JPEG }, - { L".png", WIC_CODEC_PNG }, - { L".dds", CODEC_DDS }, - { L".tga", CODEC_TGA }, - { L".hdr", CODEC_HDR }, - { L".tif", WIC_CODEC_TIFF }, - { L".tiff", WIC_CODEC_TIFF }, - { L".wdp", WIC_CODEC_WMP }, - { L".hdp", WIC_CODEC_WMP }, - { L".jxr", WIC_CODEC_WMP }, -#ifdef USE_OPENEXR - { L"exr", CODEC_EXR }, -#endif - { nullptr, CODEC_DDS } -}; - -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -namespace -{ - inline HANDLE safe_handle(HANDLE h) noexcept { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; } - - struct find_closer { void operator()(HANDLE h) noexcept { assert(h != INVALID_HANDLE_VALUE); if (h) FindClose(h); } }; - - using ScopedFindHandle = std::unique_ptr; - -#ifdef _PREFAST_ -#pragma prefast(disable : 26018, "Only used with static internal arrays") -#endif - - uint32_t LookupByName(const wchar_t *pName, const SValue *pArray) - { - while (pArray->name) - { - if (!_wcsicmp(pName, pArray->name)) - return pArray->value; - - pArray++; - } - - return 0; - } - - const wchar_t* LookupByValue(uint32_t pValue, const SValue *pArray) - { - while (pArray->name) - { - if (pValue == pArray->value) - return pArray->name; - - pArray++; - } - - return L""; - } - - void SearchForFiles(const wchar_t* path, std::list& files, bool recursive) - { - // Process files - WIN32_FIND_DATAW findData = {}; - ScopedFindHandle hFile(safe_handle(FindFirstFileExW(path, - FindExInfoBasic, &findData, - FindExSearchNameMatch, nullptr, - FIND_FIRST_EX_LARGE_FETCH))); - if (hFile) - { - for (;;) - { - if (!(findData.dwFileAttributes & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_DIRECTORY))) - { - wchar_t drive[_MAX_DRIVE] = {}; - wchar_t dir[_MAX_DIR] = {}; - _wsplitpath_s(path, drive, _MAX_DRIVE, dir, _MAX_DIR, nullptr, 0, nullptr, 0); - - SConversion conv = {}; - _wmakepath_s(conv.szSrc, drive, dir, findData.cFileName, nullptr); - files.push_back(conv); - } - - if (!FindNextFileW(hFile.get(), &findData)) - break; - } - } - - // Process directories - if (recursive) - { - wchar_t searchDir[MAX_PATH] = {}; - { - wchar_t drive[_MAX_DRIVE] = {}; - wchar_t dir[_MAX_DIR] = {}; - _wsplitpath_s(path, drive, _MAX_DRIVE, dir, _MAX_DIR, nullptr, 0, nullptr, 0); - _wmakepath_s(searchDir, drive, dir, L"*", nullptr); - } - - hFile.reset(safe_handle(FindFirstFileExW(searchDir, - FindExInfoBasic, &findData, - FindExSearchLimitToDirectories, nullptr, - FIND_FIRST_EX_LARGE_FETCH))); - if (!hFile) - return; - - for (;;) - { - if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) - { - if (findData.cFileName[0] != L'.') - { - wchar_t subdir[MAX_PATH] = {}; - - { - wchar_t drive[_MAX_DRIVE] = {}; - wchar_t dir[_MAX_DIR] = {}; - wchar_t fname[_MAX_FNAME] = {}; - wchar_t ext[_MAX_FNAME] = {}; - _wsplitpath_s(path, drive, dir, fname, ext); - wcscat_s(dir, findData.cFileName); - _wmakepath_s(subdir, drive, dir, fname, ext); - } - - SearchForFiles(subdir, files, recursive); - } - } - - if (!FindNextFileW(hFile.get(), &findData)) - break; - } - } - } - - void ProcessFileList(std::wifstream& inFile, std::list& files) - { - std::list flist; - std::set excludes; - wchar_t fname[1024] = {}; - for (;;) - { - inFile >> fname; - if (!inFile) - break; - - if (*fname == L'#') - { - // Comment - } - else if (*fname == L'-') - { - if (flist.empty()) - { - wprintf(L"WARNING: Ignoring the line '%ls' in -flist\n", fname); - } - else - { - if (wcspbrk(fname, L"?*") != nullptr) - { - std::list removeFiles; - SearchForFiles(&fname[1], removeFiles, false); - - for (auto it : removeFiles) - { - _wcslwr_s(it.szSrc); - excludes.insert(it.szSrc); - } - } - else - { - std::wstring name = (fname + 1); - std::transform(name.begin(), name.end(), name.begin(), towlower); - excludes.insert(name); - } - } - } - else if (wcspbrk(fname, L"?*") != nullptr) - { - SearchForFiles(fname, flist, false); - } - else - { - SConversion conv = {}; - wcscpy_s(conv.szSrc, MAX_PATH, fname); - flist.push_back(conv); - } - - inFile.ignore(1000, '\n'); - } - - inFile.close(); - - if (!excludes.empty()) - { - // Remove any excluded files - for (auto it = flist.begin(); it != flist.end();) - { - std::wstring name = it->szSrc; - std::transform(name.begin(), name.end(), name.begin(), towlower); - auto item = it; - ++it; - if (excludes.find(name) != excludes.end()) - { - flist.erase(item); - } - } - } - - if (flist.empty()) - { - wprintf(L"WARNING: No file names found in -flist\n"); - } - else - { - files.splice(files.end(), flist); - } - } - - void PrintFormat(DXGI_FORMAT Format) - { - for (auto pFormat = g_pFormats; pFormat->name; pFormat++) - { - if (static_cast(pFormat->value) == Format) - { - wprintf(L"%ls", pFormat->name); - return; - } - } - - for (auto pFormat = g_pReadOnlyFormats; pFormat->name; pFormat++) - { - if (static_cast(pFormat->value) == Format) - { - wprintf(L"%ls", pFormat->name); - return; - } - } - - wprintf(L"*UNKNOWN*"); - } - - void PrintList(size_t cch, const SValue *pValue) - { - while (pValue->name) - { - const size_t cchName = wcslen(pValue->name); - - if (cch + cchName + 2 >= 80) - { - wprintf(L"\n "); - cch = 6; - } - - wprintf(L"%ls ", pValue->name); - cch += cchName + 2; - pValue++; - } - - wprintf(L"\n"); - } - - void PrintLogo() - { - wchar_t version[32] = {}; - - wchar_t appName[_MAX_PATH] = {}; - if (GetModuleFileNameW(nullptr, appName, static_cast(std::size(appName)))) - { - const DWORD size = GetFileVersionInfoSizeW(appName, nullptr); - if (size > 0) - { - auto verInfo = std::make_unique(size); - if (GetFileVersionInfoW(appName, 0, size, verInfo.get())) - { - LPVOID lpstr = nullptr; - UINT strLen = 0; - if (VerQueryValueW(verInfo.get(), L"\\StringFileInfo\\040904B0\\ProductVersion", &lpstr, &strLen)) - { - wcsncpy_s(version, reinterpret_cast(lpstr), strLen); - } - } - } - } - - if (!*version || wcscmp(version, L"1.0.0.0") == 0) - { - swprintf_s(version, L"%03d (library)", DIRECTX_TEX_VERSION); - } - - wprintf(L"Microsoft (R) DirectX Texture Diagnostic Tool [DirectXTex] Version %ls\n", version); - wprintf(L"Copyright (C) Microsoft Corp.\n"); - #ifdef _DEBUG - wprintf(L"*** Debug build ***\n"); - #endif - wprintf(L"\n"); - } - - void PrintUsage() - { - PrintLogo(); - - wprintf(L"Usage: texdiag \n\n"); - wprintf(L" info Output image metadata\n"); - wprintf(L" analyze Analyze and summarize image information\n"); - wprintf(L" compare Compare two images with MSE error metric\n"); - wprintf(L" diff Generate difference image from two images\n"); - wprintf(L" dumpbc Dump out compressed blocks (DDS BC only)\n"); - wprintf(L" dumpdds Dump out all the images in a complex DDS\n\n"); - wprintf(L" -r wildcard filename search is recursive\n"); - wprintf(L" -if image filtering\n"); - wprintf(L"\n (DDS input only)\n"); - wprintf(L" -t{u|f} TYPELESS format is treated as UNORM or FLOAT\n"); - wprintf(L" -dword Use DWORD instead of BYTE alignment\n"); - wprintf(L" -badtails Fix for older DXTn with bad mipchain tails\n"); - wprintf(L" -xlum expand legacy L8, L16, and A8P8 formats\n"); - wprintf(L"\n (diff only)\n"); - wprintf(L" -f format\n"); - wprintf(L" -o output filename\n"); - wprintf(L" -l force output filename to lower case\n"); - wprintf(L" -y overwrite existing output file (if any)\n"); - wprintf(L" -c highlight difference color (defaults to off)\n"); - wprintf(L" -t highlight threshold (defaults to 0.25)\n"); - wprintf(L"\n (dumpbc only)\n"); - wprintf(L" -targetx dump pixels at location x (defaults to all)\n"); - wprintf(L" -targety dump pixels at location y (defaults to all)\n"); - wprintf(L"\n (dumpdds only)\n"); - wprintf(L" -ft output file type\n"); - wprintf(L"\n -nologo suppress copyright message\n"); - wprintf(L" -flist use text file with a list of input files (one per line)\n"); - - wprintf(L"\n : "); - PrintList(13, g_pFormats); - wprintf(L" "); - PrintList(13, g_pFormatAliases); - - wprintf(L"\n : "); - PrintList(13, g_pFilters); - - wprintf(L"\n : "); - PrintList(15, g_pDumpFileTypes); - } - - const wchar_t* GetErrorDesc(HRESULT hr) - { - static wchar_t desc[1024] = {}; - - LPWSTR errorText = nullptr; - - const DWORD result = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_ALLOCATE_BUFFER, - nullptr, static_cast(hr), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast(&errorText), 0, nullptr); - - *desc = 0; - - if (result > 0 && errorText) - { - swprintf_s(desc, L": %ls", errorText); - - size_t len = wcslen(desc); - if (len >= 1) - { - desc[len - 1] = 0; - } - - if (errorText) - LocalFree(errorText); - } - - return desc; - } - - HRESULT LoadImage( - const wchar_t *fileName, - uint32_t dwOptions, - TEX_FILTER_FLAGS dwFilter, - TexMetadata& info, - std::unique_ptr& image) - { - if (!fileName) - return E_INVALIDARG; - - image.reset(new (std::nothrow) ScratchImage); - if (!image) - return E_OUTOFMEMORY; - - wchar_t ext[_MAX_EXT] = {}; - _wsplitpath_s(fileName, nullptr, 0, nullptr, 0, nullptr, 0, ext, _MAX_EXT); - - if (_wcsicmp(ext, L".dds") == 0) - { - DDS_FLAGS ddsFlags = DDS_FLAGS_ALLOW_LARGE_FILES; - if (dwOptions & (1 << OPT_DDS_DWORD_ALIGN)) - ddsFlags |= DDS_FLAGS_LEGACY_DWORD; - if (dwOptions & (1 << OPT_EXPAND_LUMINANCE)) - ddsFlags |= DDS_FLAGS_EXPAND_LUMINANCE; - if (dwOptions & (1 << OPT_DDS_BAD_DXTN_TAILS)) - ddsFlags |= DDS_FLAGS_BAD_DXTN_TAILS; - - HRESULT hr = LoadFromDDSFile(fileName, ddsFlags, &info, *image); - if (FAILED(hr)) - return hr; - - if (IsTypeless(info.format)) - { - if (dwOptions & (1 << OPT_TYPELESS_UNORM)) - { - info.format = MakeTypelessUNORM(info.format); - } - else if (dwOptions & (1 << OPT_TYPELESS_FLOAT)) - { - info.format = MakeTypelessFLOAT(info.format); - } - - if (IsTypeless(info.format)) - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - - image->OverrideFormat(info.format); - } - - return S_OK; - } - else if (_wcsicmp(ext, L".tga") == 0) - { - return LoadFromTGAFile(fileName, TGA_FLAGS_NONE, &info, *image); - } - else if (_wcsicmp(ext, L".hdr") == 0) - { - return LoadFromHDRFile(fileName, &info, *image); - } - #ifdef USE_OPENEXR - else if (_wcsicmp(ext, L".exr") == 0) - { - return LoadFromEXRFile(fileName, &info, *image); - } - #endif - else - { - // WIC shares the same filter values for mode and dither - static_assert(static_cast(WIC_FLAGS_DITHER) == static_cast(TEX_FILTER_DITHER), "WIC_FLAGS_* & TEX_FILTER_* should match"); - static_assert(static_cast(WIC_FLAGS_DITHER_DIFFUSION) == static_cast(TEX_FILTER_DITHER_DIFFUSION), "WIC_FLAGS_* & TEX_FILTER_* should match"); - static_assert(static_cast(WIC_FLAGS_FILTER_POINT) == static_cast(TEX_FILTER_POINT), "WIC_FLAGS_* & TEX_FILTER_* should match"); - static_assert(static_cast(WIC_FLAGS_FILTER_LINEAR) == static_cast(TEX_FILTER_LINEAR), "WIC_FLAGS_* & TEX_FILTER_* should match"); - static_assert(static_cast(WIC_FLAGS_FILTER_CUBIC) == static_cast(TEX_FILTER_CUBIC), "WIC_FLAGS_* & TEX_FILTER_* should match"); - static_assert(static_cast(WIC_FLAGS_FILTER_FANT) == static_cast(TEX_FILTER_FANT), "WIC_FLAGS_* & TEX_FILTER_* should match"); - - HRESULT hr = LoadFromWICFile(fileName, dwFilter | WIC_FLAGS_ALL_FRAMES, &info, *image); - if (hr == static_cast(0xc00d5212) /* MF_E_TOPO_CODEC_NOT_FOUND */) - { - if (_wcsicmp(ext, L".heic") == 0 || _wcsicmp(ext, L".heif") == 0) - { - wprintf(L"\nINFO: This format requires installing the HEIF Image Extensions - https://aka.ms/heif\n"); - } - else if (_wcsicmp(ext, L".webp") == 0) - { - wprintf(L"\nINFO: This format requires installing the WEBP Image Extensions - https://www.microsoft.com/p/webp-image-extensions/9pg2dk419drg\n"); - } - } - return hr; - } - } - - HRESULT SaveImage(const Image* image, const wchar_t *fileName, uint32_t codec) - { - switch (codec) - { - case CODEC_DDS: - return SaveToDDSFile(*image, DDS_FLAGS_NONE, fileName); - - case CODEC_TGA: - return SaveToTGAFile(*image, TGA_FLAGS_NONE, fileName); - - case CODEC_HDR: - return SaveToHDRFile(*image, fileName); - - #ifdef USE_OPENEXR - case CODEC_EXR: - return SaveToEXRFile(*image, fileName); - #endif - - default: - return SaveToWICFile(*image, WIC_FLAGS_NONE, GetWICCodec(static_cast(codec)), fileName); - } - } - - //-------------------------------------------------------------------------------------- - struct AnalyzeData - { - XMFLOAT4 imageMin; - XMFLOAT4 imageMax; - XMFLOAT4 imageAvg; - XMFLOAT4 imageVariance; - XMFLOAT4 imageStdDev; - float luminance; - size_t specials_x; - size_t specials_y; - size_t specials_z; - size_t specials_w; - - void Print() - { - wprintf(L"\t Minimum - (%f %f %f %f)\n", imageMin.x, imageMin.y, imageMin.z, imageMin.w); - wprintf(L"\t Average - (%f %f %f %f)\n", imageAvg.x, imageAvg.y, imageAvg.z, imageAvg.w); - wprintf(L"\t Maximum - (%f %f %f %f)\n", imageMax.x, imageMax.y, imageMax.z, imageMax.w); - wprintf(L"\t Variance - (%f %f %f %f)\n", imageVariance.x, imageVariance.y, imageVariance.z, imageVariance.w); - wprintf(L"\t Std Dev - (%f %f %f %f)\n", imageStdDev.x, imageStdDev.y, imageStdDev.z, imageStdDev.w); - - wprintf(L"\tLuminance - %f (maximum)\n", luminance); - - if ((specials_x > 0) || (specials_y > 0) || (specials_z > 0) || (specials_w > 0)) - { - wprintf(L" FP specials - (%zu %zu %zu %zu)\n", specials_x, specials_y, specials_z, specials_w); - } - } - }; - - HRESULT Analyze(const Image& image, _Out_ AnalyzeData& result) - { - memset(&result, 0, sizeof(AnalyzeData)); - - // First pass - XMVECTOR minv = g_XMFltMax; - XMVECTOR maxv = XMVectorNegate(g_XMFltMax); - XMVECTOR acc = g_XMZero; - XMVECTOR luminance = g_XMZero; - - size_t totalPixels = 0; - - HRESULT hr = EvaluateImage(image, [&](const XMVECTOR * pixels, size_t width, size_t y) - { - static const XMVECTORF32 s_luminance = { { { 0.3f, 0.59f, 0.11f, 0.f } } }; - - UNREFERENCED_PARAMETER(y); - - for (size_t x = 0; x < width; ++x) - { - const XMVECTOR v = *pixels++; - luminance = XMVectorMax(luminance, XMVector3Dot(v, s_luminance)); - minv = XMVectorMin(minv, v); - maxv = XMVectorMax(maxv, v); - acc = XMVectorAdd(v, acc); - ++totalPixels; - - XMFLOAT4 f; - XMStoreFloat4(&f, v); - if (!isfinite(f.x)) - { - ++result.specials_x; - } - - if (!isfinite(f.y)) - { - ++result.specials_y; - } - - if (!isfinite(f.z)) - { - ++result.specials_z; - } - - if (!isfinite(f.w)) - { - ++result.specials_w; - } - } - }); - if (FAILED(hr)) - return hr; - - if (!totalPixels) - return S_FALSE; - - result.luminance = XMVectorGetX(luminance); - XMStoreFloat4(&result.imageMin, minv); - XMStoreFloat4(&result.imageMax, maxv); - - const XMVECTOR pixelv = XMVectorReplicate(float(totalPixels)); - XMVECTOR avgv = XMVectorDivide(acc, pixelv); - XMStoreFloat4(&result.imageAvg, avgv); - - // Second pass - acc = g_XMZero; - - hr = EvaluateImage(image, [&](const XMVECTOR * pixels, size_t width, size_t y) - { - UNREFERENCED_PARAMETER(y); - - for (size_t x = 0; x < width; ++x) - { - const XMVECTOR v = *pixels++; - - const XMVECTOR diff = XMVectorSubtract(v, avgv); - acc = XMVectorMultiplyAdd(diff, diff, acc); - } - }); - if (FAILED(hr)) - return hr; - - XMStoreFloat4(&result.imageVariance, acc); - - const XMVECTOR stddev = XMVectorSqrt(acc); - - XMStoreFloat4(&result.imageStdDev, stddev); - - return S_OK; - } - - //-------------------------------------------------------------------------------------- - struct AnalyzeBCData - { - size_t blocks; - size_t blockHist[15]; - - void Print(DXGI_FORMAT fmt) - { - wprintf(L"\t Compression - "); - PrintFormat(fmt); - wprintf(L"\n\t Total blocks - %zu\n", blocks); - - switch (fmt) - { - case DXGI_FORMAT_BC1_UNORM: - case DXGI_FORMAT_BC1_UNORM_SRGB: - wprintf(L"\t 4 color blocks - %zu\n", blockHist[0]); - wprintf(L"\t 3 color blocks - %zu\n", blockHist[1]); - break; - - // BC2 only has a single 'type' of block - - case DXGI_FORMAT_BC3_UNORM: - case DXGI_FORMAT_BC3_UNORM_SRGB: - wprintf(L"\t 8 alpha blocks - %zu\n", blockHist[0]); - wprintf(L"\t 6 alpha blocks - %zu\n", blockHist[1]); - break; - - case DXGI_FORMAT_BC4_UNORM: - case DXGI_FORMAT_BC4_SNORM: - wprintf(L"\t 8 red blocks - %zu\n", blockHist[0]); - wprintf(L"\t 6 red blocks - %zu\n", blockHist[1]); - break; - - case DXGI_FORMAT_BC5_UNORM: - case DXGI_FORMAT_BC5_SNORM: - wprintf(L"\t 8 red blocks - %zu\n", blockHist[0]); - wprintf(L"\t 6 red blocks - %zu\n", blockHist[1]); - wprintf(L"\t 8 green blocks - %zu\n", blockHist[2]); - wprintf(L"\t 6 green blocks - %zu\n", blockHist[3]); - break; - - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - for (size_t j = 1; j <= 14; ++j) - { - if (blockHist[j] > 0) - wprintf(L"\t Mode %02zu blocks - %zu\n", j, blockHist[j]); - } - if (blockHist[0] > 0) - wprintf(L"\tReserved mode blcks - %zu\n", blockHist[0]); - break; - - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: - for (size_t j = 0; j <= 7; ++j) - { - if (blockHist[j] > 0) - wprintf(L"\t Mode %02zu blocks - %zu\n", j, blockHist[j]); - } - if (blockHist[8] > 0) - wprintf(L"\tReserved mode blcks - %zu\n", blockHist[8]); - break; - - default: - break; - } - } - }; - -#pragma pack(push,1) - struct BC1Block - { - uint16_t rgb[2]; // 565 colors - uint32_t bitmap; // 2bpp rgb bitmap - }; - - struct BC2Block - { - uint32_t bitmap[2]; // 4bpp alpha bitmap - BC1Block bc1; // BC1 rgb data - }; - - struct BC3Block - { - uint8_t alpha[2]; // alpha values - uint8_t bitmap[6]; // 3bpp alpha bitmap - BC1Block bc1; // BC1 rgb data - }; - - struct BC4UBlock - { - uint8_t red_0; - uint8_t red_1; - uint8_t indices[6]; - }; - - struct BC4SBlock - { - int8_t red_0; - int8_t red_1; - uint8_t indices[6]; - }; - - struct BC5UBlock - { - BC4UBlock u; - BC4UBlock v; - }; - - struct BC5SBlock - { - BC4SBlock u; - BC4SBlock v; - }; -#pragma pack(pop) - - HRESULT AnalyzeBC(const Image& image, _Out_ AnalyzeBCData& result) - { - memset(&result, 0, sizeof(AnalyzeBCData)); - - size_t sbpp; - switch (image.format) - { - case DXGI_FORMAT_BC1_UNORM: - case DXGI_FORMAT_BC1_UNORM_SRGB: - case DXGI_FORMAT_BC4_UNORM: - case DXGI_FORMAT_BC4_SNORM: - sbpp = 8; - break; - - case DXGI_FORMAT_BC2_UNORM: - case DXGI_FORMAT_BC2_UNORM_SRGB: - case DXGI_FORMAT_BC3_UNORM: - case DXGI_FORMAT_BC3_UNORM_SRGB: - case DXGI_FORMAT_BC5_UNORM: - case DXGI_FORMAT_BC5_SNORM: - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: - sbpp = 16; - break; - - default: - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - - const uint8_t *pSrc = image.pixels; - const size_t rowPitch = image.rowPitch; - - for (size_t h = 0; h < image.height; h += 4) - { - const uint8_t *sptr = pSrc; - - for (size_t count = 0; count < rowPitch; count += sbpp) - { - switch (image.format) - { - case DXGI_FORMAT_BC1_UNORM: - case DXGI_FORMAT_BC1_UNORM_SRGB: - { - auto block = reinterpret_cast(sptr); - - if (block->rgb[0] <= block->rgb[1]) - { - // Transparent block - ++result.blockHist[1]; - } - else - { - // Opaque block - ++result.blockHist[0]; - } - } - break; - - // BC2 only has a single 'type' of block - - case DXGI_FORMAT_BC3_UNORM: - case DXGI_FORMAT_BC3_UNORM_SRGB: - { - auto block = reinterpret_cast(sptr); - - if (block->alpha[0] > block->alpha[1]) - { - // 8 alpha block - ++result.blockHist[0]; - } - else - { - // 6 alpha block - ++result.blockHist[1]; - } - } - break; - - case DXGI_FORMAT_BC4_UNORM: - { - auto block = reinterpret_cast(sptr); - - if (block->red_0 > block->red_1) - { - // 8 red block - ++result.blockHist[0]; - } - else - { - // 6 red block - ++result.blockHist[1]; - } - } - break; - - case DXGI_FORMAT_BC4_SNORM: - { - auto block = reinterpret_cast(sptr); - - if (block->red_0 > block->red_1) - { - // 8 red block - ++result.blockHist[0]; - } - else - { - // 6 red block - ++result.blockHist[1]; - } - } - break; - - case DXGI_FORMAT_BC5_UNORM: - { - auto block = reinterpret_cast(sptr); - - if (block->u.red_0 > block->u.red_1) - { - // 8 red block - ++result.blockHist[0]; - } - else - { - // 6 red block - ++result.blockHist[1]; - } - - if (block->v.red_0 > block->v.red_1) - { - // 8 green block - ++result.blockHist[2]; - } - else - { - // 6 green block - ++result.blockHist[3]; - } - } - break; - - case DXGI_FORMAT_BC5_SNORM: - { - auto block = reinterpret_cast(sptr); - - if (block->u.red_0 > block->u.red_1) - { - // 8 red block - ++result.blockHist[0]; - } - else - { - // 6 red block - ++result.blockHist[1]; - } - - if (block->v.red_0 > block->v.red_1) - { - // 8 green block - ++result.blockHist[2]; - } - else - { - // 6 green block - ++result.blockHist[3]; - } - } - break; - - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - switch (*sptr & 0x03) - { - case 0x00: - // Mode 1 (2 bits, 00) - ++result.blockHist[1]; - break; - - case 0x01: - // Mode 2 (2 bits, 01) - ++result.blockHist[2]; - break; - - default: - switch (*sptr & 0x1F) - { - case 0x02: - // Mode 3 (5 bits, 00010) - ++result.blockHist[3]; - break; - - case 0x06: - // Mode 4 (5 bits, 00110) - ++result.blockHist[4]; - break; - - case 0x0A: - // Mode 5 (5 bits, 01010) - ++result.blockHist[5]; - break; - - case 0x0E: - // Mode 6 (5 bits, 01110) - ++result.blockHist[6]; - break; - - case 0x12: - // Mode 7 (5 bits, 10010) - ++result.blockHist[7]; - break; - - case 0x16: - // Mode 8 (5 bits, 10110) - ++result.blockHist[8]; - break; - - case 0x1A: - // Mode 9 (5 bits, 11010) - ++result.blockHist[9]; - break; - - case 0x1E: - // Mode 10 (5 bits, 11110) - ++result.blockHist[10]; - break; - - case 0x03: - // Mode 11 (5 bits, 00011) - ++result.blockHist[11]; - break; - - case 0x07: - // Mode 12 (5 bits, 00111) - ++result.blockHist[12]; - break; - - case 0x0B: - // Mode 13 (5 bits, 01011) - ++result.blockHist[13]; - break; - - case 0x0F: - // Mode 14 (5 bits, 01111) - ++result.blockHist[14]; - break; - - case 0x13: // Reserved mode (5 bits, 10011) - case 0x17: // Reserved mode (5 bits, 10111) - case 0x1B: // Reserved mode (5 bits, 11011) - case 0x1F: // Reserved mode (5 bits, 11111) - default: - ++result.blockHist[0]; - break; - } - break; - } - break; - - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: - if (*sptr & 0x01) - { - // Mode 0 (1) - ++result.blockHist[0]; - } - else if (*sptr & 0x02) - { - // Mode 1 (01) - ++result.blockHist[1]; - } - else if (*sptr & 0x04) - { - // Mode 2 (001) - ++result.blockHist[2]; - } - else if (*sptr & 0x08) - { - // Mode 3 (0001) - ++result.blockHist[3]; - } - else if (*sptr & 0x10) - { - // Mode 4 (00001) - ++result.blockHist[4]; - } - else if (*sptr & 0x20) - { - // Mode 5 (000001) - ++result.blockHist[5]; - } - else if (*sptr & 0x40) - { - // Mode 6 (0000001) - ++result.blockHist[6]; - } - else if (*sptr & 0x80) - { - // Mode 7 (00000001) - ++result.blockHist[7]; - } - else - { - // Reserved mode 8 (00000000) - ++result.blockHist[8]; - } - break; - - default: - break; - } - - sptr += sbpp; - ++result.blocks; - } - - pSrc += rowPitch; - } - - return S_OK; - } - - //-------------------------------------------------------------------------------------- - HRESULT Difference( - const Image& image1, - const Image& image2, - TEX_FILTER_FLAGS dwFilter, - DXGI_FORMAT format, - uint32_t diffColor, - float threshold, - ScratchImage& result) - { - if (!image1.pixels || !image2.pixels) - return E_POINTER; - - if (image1.width != image2.width - || image1.height != image2.height) - return E_FAIL; - - ScratchImage tempA; - const Image* imageA = &image1; - if (IsCompressed(image1.format)) - { - HRESULT hr = Decompress(image1, DXGI_FORMAT_R32G32B32A32_FLOAT, tempA); - if (FAILED(hr)) - return hr; - - imageA = tempA.GetImage(0, 0, 0); - } - - ScratchImage tempB; - const Image* imageB = &image2; - if (image2.format != DXGI_FORMAT_R32G32B32A32_FLOAT) - { - if (IsCompressed(image2.format)) - { - HRESULT hr = Decompress(image2, DXGI_FORMAT_R32G32B32A32_FLOAT, tempB); - if (FAILED(hr)) - return hr; - - imageB = tempB.GetImage(0, 0, 0); - } - else - { - HRESULT hr = Convert(image2, DXGI_FORMAT_R32G32B32A32_FLOAT, dwFilter, TEX_THRESHOLD_DEFAULT, tempB); - if (FAILED(hr)) - return hr; - - imageB = tempB.GetImage(0, 0, 0); - } - } - - if (!imageA || !imageB) - return E_POINTER; - - XMVECTOR colorValue = PackedVector::XMLoadColor(reinterpret_cast(&diffColor)); - colorValue = XMVectorSelect(g_XMIdentityR3, colorValue, g_XMSelect1110); - - ScratchImage diffImage; - HRESULT hr = TransformImage(*imageA, [&](XMVECTOR* outPixels, const XMVECTOR * inPixels, size_t width, size_t y) - { - const XMVECTOR tolerance = XMVectorReplicate(threshold); - - auto *inPixelsB = reinterpret_cast(imageB->pixels + (y*imageB->rowPitch)); - - for (size_t x = 0; x < width; ++x) - { - XMVECTOR v1 = *inPixels++; - const XMVECTOR v2 = *inPixelsB++; - - v1 = XMVectorSubtract(v1, v2); - v1 = XMVectorAbs(v1); - v1 = XMVectorSelect(g_XMIdentityR3, v1, g_XMSelect1110); - - if (diffColor && XMVector3GreaterOrEqual(v1, tolerance)) - { - *outPixels++ = colorValue; - } - else - { - *outPixels++ = v1; - } - } - }, (format == DXGI_FORMAT_R32G32B32A32_FLOAT) ? result : diffImage); - if (FAILED(hr)) - return hr; - - if (format == diffImage.GetMetadata().format) - { - std::swap(diffImage, result); - return S_OK; - } - - return Convert(diffImage.GetImages(), diffImage.GetImageCount(), diffImage.GetMetadata(), format, dwFilter, TEX_THRESHOLD_DEFAULT, result); - } - -#pragma region DumpBC - //-------------------------------------------------------------------------------------- - // Partition, Shape, Fixup - const uint8_t g_aFixUp[3][64][3] = - { - { // No fix-ups for 1st subset for BC6H or BC7 - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 }, - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 }, - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 }, - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 }, - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 }, - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 }, - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 }, - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 }, - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 }, - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 }, - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 }, - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 }, - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 }, - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 }, - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 }, - { 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 },{ 0, 0, 0 } - }, - - { // BC6H/BC7 Partition Set Fixups for 2 Subsets - { 0,15, 0 },{ 0,15, 0 },{ 0,15, 0 },{ 0,15, 0 }, - { 0,15, 0 },{ 0,15, 0 },{ 0,15, 0 },{ 0,15, 0 }, - { 0,15, 0 },{ 0,15, 0 },{ 0,15, 0 },{ 0,15, 0 }, - { 0,15, 0 },{ 0,15, 0 },{ 0,15, 0 },{ 0,15, 0 }, - { 0,15, 0 },{ 0, 2, 0 },{ 0, 8, 0 },{ 0, 2, 0 }, - { 0, 2, 0 },{ 0, 8, 0 },{ 0, 8, 0 },{ 0,15, 0 }, - { 0, 2, 0 },{ 0, 8, 0 },{ 0, 2, 0 },{ 0, 2, 0 }, - { 0, 8, 0 },{ 0, 8, 0 },{ 0, 2, 0 },{ 0, 2, 0 }, - - // BC7 Partition Set Fixups for 2 Subsets (second-half) - { 0,15, 0 },{ 0,15, 0 },{ 0, 6, 0 },{ 0, 8, 0 }, - { 0, 2, 0 },{ 0, 8, 0 },{ 0,15, 0 },{ 0,15, 0 }, - { 0, 2, 0 },{ 0, 8, 0 },{ 0, 2, 0 },{ 0, 2, 0 }, - { 0, 2, 0 },{ 0,15, 0 },{ 0,15, 0 },{ 0, 6, 0 }, - { 0, 6, 0 },{ 0, 2, 0 },{ 0, 6, 0 },{ 0, 8, 0 }, - { 0,15, 0 },{ 0,15, 0 },{ 0, 2, 0 },{ 0, 2, 0 }, - { 0,15, 0 },{ 0,15, 0 },{ 0,15, 0 },{ 0,15, 0 }, - { 0,15, 0 },{ 0, 2, 0 },{ 0, 2, 0 },{ 0,15, 0 } - }, - - { // BC7 Partition Set Fixups for 3 Subsets - { 0, 3,15 },{ 0, 3, 8 },{ 0,15, 8 },{ 0,15, 3 }, - { 0, 8,15 },{ 0, 3,15 },{ 0,15, 3 },{ 0,15, 8 }, - { 0, 8,15 },{ 0, 8,15 },{ 0, 6,15 },{ 0, 6,15 }, - { 0, 6,15 },{ 0, 5,15 },{ 0, 3,15 },{ 0, 3, 8 }, - { 0, 3,15 },{ 0, 3, 8 },{ 0, 8,15 },{ 0,15, 3 }, - { 0, 3,15 },{ 0, 3, 8 },{ 0, 6,15 },{ 0,10, 8 }, - { 0, 5, 3 },{ 0, 8,15 },{ 0, 8, 6 },{ 0, 6,10 }, - { 0, 8,15 },{ 0, 5,15 },{ 0,15,10 },{ 0,15, 8 }, - { 0, 8,15 },{ 0,15, 3 },{ 0, 3,15 },{ 0, 5,10 }, - { 0, 6,10 },{ 0,10, 8 },{ 0, 8, 9 },{ 0,15,10 }, - { 0,15, 6 },{ 0, 3,15 },{ 0,15, 8 },{ 0, 5,15 }, - { 0,15, 3 },{ 0,15, 6 },{ 0,15, 6 },{ 0,15, 8 }, - { 0, 3,15 },{ 0,15, 3 },{ 0, 5,15 },{ 0, 5,15 }, - { 0, 5,15 },{ 0, 8,15 },{ 0, 5,15 },{ 0,10,15 }, - { 0, 5,15 },{ 0,10,15 },{ 0, 8,15 },{ 0,13,15 }, - { 0,15, 3 },{ 0,12,15 },{ 0, 3,15 },{ 0, 3, 8 } - } - }; - - inline static bool IsFixUpOffset( - _In_range_(0, 2) size_t uPartitions, - _In_range_(0, 63) uint64_t uShape, - _In_range_(0, 15) size_t uOffset) - { - for (size_t p = 0; p <= uPartitions; p++) - { - if (uOffset == g_aFixUp[uPartitions][uShape][p]) - { - return true; - } - } - return false; - } - - //-------------------------------------------------------------------------------------- -#define SIGN_EXTEND(x,nb) ((((x)&(1<<((nb)-1)))?((~0)^((1<<(nb))-1)):0)|(x)) - -#define NUM_PIXELS_PER_BLOCK 16 - - void Print565(uint16_t rgb) - { - auto const r = float(((rgb >> 11) & 31) * (1.0f / 31.0f)); - auto const g = float(((rgb >> 5) & 63) * (1.0f / 63.0f)); - auto const b = float(((rgb >> 0) & 31) * (1.0f / 31.0f)); - - wprintf(L"(R: %.3f, G: %.3f, B: %.3f)", r, g, b); - } - - void PrintIndex2bpp(uint32_t bitmap) - { - for (size_t j = 0; j < NUM_PIXELS_PER_BLOCK; ++j, bitmap >>= 2) - { - wprintf(L"%u%ls", bitmap & 0x3, ((j < (NUM_PIXELS_PER_BLOCK - 1)) && ((j % 4) == 3)) ? L" | " : L" "); - } - } - - void PrintIndex2bpp(uint64_t bitmap, size_t parts, uint64_t shape) - { - for (size_t j = 0; j < NUM_PIXELS_PER_BLOCK; ++j) - { - if (IsFixUpOffset(parts, shape, j)) - { - wprintf(L"%llu%ls", bitmap & 0x1, ((j < (NUM_PIXELS_PER_BLOCK - 1)) && ((j % 4) == 3)) ? L" | " : L" "); - bitmap >>= 1; - } - else - { - wprintf(L"%llu%ls", bitmap & 0x3, ((j < (NUM_PIXELS_PER_BLOCK - 1)) && ((j % 4) == 3)) ? L" | " : L" "); - bitmap >>= 2; - } - } - } - - void PrintIndex3bpp(uint64_t bitmap, size_t parts, uint64_t shape) - { - for (size_t j = 0; j < NUM_PIXELS_PER_BLOCK; ++j) - { - if (IsFixUpOffset(parts, shape, j)) - { - wprintf(L"%llu%ls", bitmap & 0x3, ((j < (NUM_PIXELS_PER_BLOCK - 1)) && ((j % 4) == 3)) ? L" | " : L" "); - bitmap >>= 2; - } - else - { - wprintf(L"%llu%ls", bitmap & 0x7, ((j < (NUM_PIXELS_PER_BLOCK - 1)) && ((j % 4) == 3)) ? L" | " : L" "); - bitmap >>= 3; - } - } - } - - void PrintIndex4bpp(uint64_t bitmap, size_t parts, uint64_t shape) - { - for (size_t j = 0; j < NUM_PIXELS_PER_BLOCK; ++j) - { - if (IsFixUpOffset(parts, shape, j)) - { - wprintf(L"%llX%ls", bitmap & 0x7, ((j < (NUM_PIXELS_PER_BLOCK - 1)) && ((j % 4) == 3)) ? L" | " : L" "); - bitmap >>= 3; - } - else - { - wprintf(L"%llX%ls", bitmap & 0xF, ((j < (NUM_PIXELS_PER_BLOCK - 1)) && ((j % 4) == 3)) ? L" | " : L" "); - bitmap >>= 4; - } - } - } - - void PrintIndex3bpp(const uint8_t data[6]) - { - uint32_t bitmap = uint32_t(data[0]) | (uint32_t(data[1]) << 8) | (uint32_t(data[2]) << 16); - - size_t j = 0; - for (; j < (NUM_PIXELS_PER_BLOCK / 2); ++j, bitmap >>= 3) - { - wprintf(L"%u%ls", bitmap & 0x7, ((j % 4) == 3) ? L" | " : L" "); - } - - bitmap = uint32_t(data[3]) | (uint32_t(data[4]) << 8) | (uint32_t(data[5]) << 16); - - for (; j < NUM_PIXELS_PER_BLOCK; ++j, bitmap >>= 3) - { - wprintf(L"%u%ls", bitmap & 0x7, ((j < (NUM_PIXELS_PER_BLOCK - 1)) && ((j % 4) == 3)) ? L" | " : L" "); - } - } - - const wchar_t* GetRotBits(uint64_t rot) - { - switch (rot) - { - case 1: return L" (R<->A)"; - case 2: return L" (G<->A)"; - case 3: return L" (B<->A)"; - default: return L""; - } - } - - HRESULT DumpBCImage(const Image& image, int pixelx, int pixely) - { - size_t sbpp; - switch (image.format) - { - case DXGI_FORMAT_BC1_UNORM: - case DXGI_FORMAT_BC1_UNORM_SRGB: - case DXGI_FORMAT_BC4_UNORM: - case DXGI_FORMAT_BC4_SNORM: - sbpp = 8; - break; - - case DXGI_FORMAT_BC2_UNORM: - case DXGI_FORMAT_BC2_UNORM_SRGB: - case DXGI_FORMAT_BC3_UNORM: - case DXGI_FORMAT_BC3_UNORM_SRGB: - case DXGI_FORMAT_BC5_UNORM: - case DXGI_FORMAT_BC5_SNORM: - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: - sbpp = 16; - break; - - default: - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - - const uint8_t *pSrc = image.pixels; - const size_t rowPitch = image.rowPitch; - - size_t nblock = 0; - for (size_t h = 0; h < image.height; h += 4, pSrc += rowPitch) - { - if (pixely >= 0) - { - if ((pixely < int(h)) || (pixely >= int(h + 4))) - continue; - } - - const uint8_t *sptr = pSrc; - - size_t w = 0; - for (size_t count = 0; count < rowPitch; count += sbpp, w += 4, ++nblock, sptr += sbpp) - { - if (pixelx >= 0) - { - if ((pixelx < int(w)) || (pixelx >= int(w + 4))) - continue; - } - - wprintf(L" Block %zu (pixel: %zu x %zu)\n", nblock, w, h); - switch (image.format) - { - case DXGI_FORMAT_BC1_UNORM: - case DXGI_FORMAT_BC1_UNORM_SRGB: - { - auto block = reinterpret_cast(sptr); - - if (block->rgb[0] <= block->rgb[1]) - { - // Transparent block - wprintf(L"\tTransparent - E0: "); - } - else - { - // Opaque block - wprintf(L"\t Opaque - E0: "); - } - - Print565(block->rgb[0]); - wprintf(L"\n\t E1: "); - Print565(block->rgb[1]); - wprintf(L"\n\t Index: "); - PrintIndex2bpp(block->bitmap); - wprintf(L"\n"); - } - break; - - case DXGI_FORMAT_BC2_UNORM: - case DXGI_FORMAT_BC2_UNORM_SRGB: - { - auto block = reinterpret_cast(sptr); - - wprintf(L"\tColor - E0: "); - Print565(block->bc1.rgb[0]); - wprintf(L"\n\t E1: "); - Print565(block->bc1.rgb[1]); - wprintf(L"\n\t Index: "); - PrintIndex2bpp(block->bc1.bitmap); - wprintf(L"\n"); - - wprintf(L"\tAlpha - "); - - size_t j = 0; - uint32_t bitmap = block->bitmap[0]; - for (; j < (NUM_PIXELS_PER_BLOCK / 2); ++j, bitmap >>= 4) - { - wprintf(L"%X%ls", bitmap & 0xF, ((j % 4) == 3) ? L" | " : L" "); - } - - bitmap = block->bitmap[1]; - for (; j < NUM_PIXELS_PER_BLOCK; ++j, bitmap >>= 4) - { - wprintf(L"%X%ls", bitmap & 0xF, ((j < (NUM_PIXELS_PER_BLOCK - 1)) && ((j % 4) == 3)) ? L" | " : L" "); - } - - wprintf(L"\n"); - } - break; - - case DXGI_FORMAT_BC3_UNORM: - case DXGI_FORMAT_BC3_UNORM_SRGB: - { - auto block = reinterpret_cast(sptr); - - wprintf(L"\tColor - E0: "); - Print565(block->bc1.rgb[0]); - wprintf(L"\n\t E1: "); - Print565(block->bc1.rgb[1]); - wprintf(L"\n\t Index: "); - PrintIndex2bpp(block->bc1.bitmap); - wprintf(L"\n"); - - wprintf(L"\tAlpha - E0: %0.3f E1: %0.3f (%u)\n\t Index: ", - (float(block->alpha[0]) / 255.f), - (float(block->alpha[1]) / 255.f), (block->alpha[0] > block->alpha[1]) ? 8u : 6u); - - PrintIndex3bpp(block->bitmap); - - wprintf(L"\n"); - } - break; - - case DXGI_FORMAT_BC4_UNORM: - { - auto block = reinterpret_cast(sptr); - - wprintf(L"\t E0: %0.3f E1: %0.3f (%u)\n\tIndex: ", - (float(block->red_0) / 255.f), - (float(block->red_1) / 255.f), (block->red_0 > block->red_1) ? 8u : 6u); - - PrintIndex3bpp(block->indices); - - wprintf(L"\n"); - } - break; - - case DXGI_FORMAT_BC4_SNORM: - { - auto block = reinterpret_cast(sptr); - - wprintf(L"\t E0: %0.3f E1: %0.3f (%u)\n\tIndex: ", - (float(block->red_0) / 127.f), - (float(block->red_1) / 127.f), (block->red_0 > block->red_1) ? 8u : 6u); - - PrintIndex3bpp(block->indices); - - wprintf(L"\n"); - } - break; - - case DXGI_FORMAT_BC5_UNORM: - { - auto block = reinterpret_cast(sptr); - - wprintf(L"\tU - E0: %0.3f E1: %0.3f (%u)\n\t Index: ", - (float(block->u.red_0) / 255.f), - (float(block->u.red_1) / 255.f), (block->u.red_0 > block->u.red_1) ? 8u : 6u); - - PrintIndex3bpp(block->u.indices); - - wprintf(L"\n"); - - wprintf(L"\tV - E0: %0.3f E1: %0.3f (%u)\n\t Index: ", - (float(block->v.red_0) / 255.f), - (float(block->v.red_1) / 255.f), (block->v.red_0 > block->v.red_1) ? 8u : 6u); - - PrintIndex3bpp(block->v.indices); - - wprintf(L"\n"); - } - break; - - case DXGI_FORMAT_BC5_SNORM: - { - auto block = reinterpret_cast(sptr); - - wprintf(L"\tU - E0: %0.3f E1: %0.3f (%u)\n\t Index: ", - (float(block->u.red_0) / 127.f), - (float(block->u.red_1) / 127.f), (block->u.red_0 > block->u.red_1) ? 8u : 6u); - - PrintIndex3bpp(block->u.indices); - - wprintf(L"\n"); - - wprintf(L"\tV - E0: %0.3f E1: %0.3f (%u)\n\t Index: ", - (float(block->v.red_0) / 127.f), - (float(block->v.red_1) / 127.f), (block->v.red_0 > block->v.red_1) ? 8u : 6u); - - PrintIndex3bpp(block->v.indices); - - wprintf(L"\n"); - } - break; - - case DXGI_FORMAT_BC6H_UF16: - case DXGI_FORMAT_BC6H_SF16: - // http://msdn.microsoft.com/en-us/library/windows/desktop/hh308952.aspx#decoding_the_bc6h_format - - switch (*sptr & 0x03) - { - case 0x00: - // Mode 1 (2 bits, 00) - { - struct bc6h_mode1 - { - uint64_t mode : 2; // { M, 0}, { M, 1} - uint64_t gy4 : 1; // {GY, 4} - uint64_t by4 : 1; // {BY, 4} - uint64_t bz4 : 1; // {BZ, 4} - uint64_t rw : 10; // {RW, 0}, {RW, 1}, {RW, 2}, {RW, 3}, {RW, 4}, {RW, 5}, {RW, 6}, {RW, 7}, {RW, 8}, {RW, 9} - uint64_t gw : 10; // {GW, 0}, {GW, 1}, {GW, 2}, {GW, 3}, {GW, 4}, {GW, 5}, {GW, 6}, {GW, 7}, {GW, 8}, {GW, 9} - uint64_t bw : 10; // {BW, 0}, {BW, 1}, {BW, 2}, {BW, 3}, {BW, 4}, {BW, 5}, {BW, 6}, {BW, 7}, {BW, 8}, {BW, 9} - uint64_t rx : 5; // {RX, 0}, {RX, 1}, {RX, 2}, {RX, 3}, {RX, 4} - uint64_t gz4 : 1; // {GZ, 4} - uint64_t gy : 4; // {GY, 0}, {GY, 1}, {GY, 2}, {GY, 3} - uint64_t gx : 5; // {GX, 0}, {GX, 1}, {GX, 2}, {GX, 3}, {GX, 4} - uint64_t bz0 : 1; // {BZ, 0}, - uint64_t gz : 4; // {GZ, 0}, {GZ, 1}, {GZ, 2}, {GZ, 3} - uint64_t bx : 5; // {BX, 0}, {BX, 1}, {BX, 2}, {BX, 3}, {BX, 4} - uint64_t bz1 : 1; // {BZ, 1} - uint64_t by : 3; // {BY, 0}, {BY, 1}, {BY, 2} - uint64_t by3 : 1; // {BY, 3} - uint64_t ry : 5; // {RY, 0}, {RY, 1}, {RY, 2}, {RY, 3}, {RY, 4} - uint64_t bz2 : 1; // {BZ, 2} - uint64_t rz : 5; // {RZ, 0}, {RZ, 1}, {RZ, 2}, {RZ, 3}, {RZ, 4} - uint64_t bz3 : 1; // {BZ, 3} - uint64_t d : 5; // { D, 0}, { D, 1}, { D, 2}, { D, 3}, { D, 4} - uint64_t indices : 46; - }; - static_assert(sizeof(bc6h_mode1) == 16, "Block size must be 16 bytes"); - - const bool bSigned = (image.format == DXGI_FORMAT_BC6H_SF16) ? true : false; - - auto m = reinterpret_cast(sptr); - - XMINT3 e0_A(int(m->rw), int(m->gw), int(m->bw)); - XMINT3 e0_B(int(m->rx), int(m->gx), int(m->bx)); - XMINT3 e1_A(int(m->ry), - int(m->gy | (m->gy4 << 4)), - int(m->by | (m->by3 << 3) | (m->by4 << 4))); - XMINT3 e1_B(int(m->rz), - int(m->gz | (m->gz4 << 4)), - int(m->bz0 | (m->bz1 << 1) | (m->bz2 << 2) | (m->bz3 << 3) | (m->bz4 << 4))); - - if (bSigned) - { - e0_A.x = SIGN_EXTEND(e0_A.x, 10); - e0_A.y = SIGN_EXTEND(e0_A.y, 10); - e0_A.z = SIGN_EXTEND(e0_A.z, 10); - - e0_B.x = SIGN_EXTEND(e0_B.x, 5); - e0_B.y = SIGN_EXTEND(e0_B.y, 5); - e0_B.z = SIGN_EXTEND(e0_B.z, 5); - - e1_A.x = SIGN_EXTEND(e1_A.x, 5); - e1_A.y = SIGN_EXTEND(e1_A.y, 5); - e1_A.z = SIGN_EXTEND(e1_A.z, 5); - - e1_B.x = SIGN_EXTEND(e1_B.x, 5); - e1_B.y = SIGN_EXTEND(e1_B.y, 5); - e1_B.z = SIGN_EXTEND(e1_B.z, 5); - } - - wprintf(L"\tMode 1 - [10 5 5 5] shape %llu\n", m->d); - wprintf(L"\t E0(A): (%04X, %04X, %04X)\n", e0_A.x & 0xFFFF, e0_A.y & 0xFFFF, e0_A.z & 0xFFFF); - wprintf(L"\t E0(B): (%04X, %04X, %04X)\n", e0_B.x & 0xFFFF, e0_B.y & 0xFFFF, e0_B.z & 0xFFFF); - wprintf(L"\t E1(A): (%04X, %04X, %04X)\n", e1_A.x & 0xFFFF, e1_A.y & 0xFFFF, e1_A.z & 0xFFFF); - wprintf(L"\t E1(B): (%04X, %04X, %04X)\n", e1_B.x & 0xFFFF, e1_B.y & 0xFFFF, e1_B.z & 0xFFFF); - wprintf(L"\t Index: "); - PrintIndex3bpp(m->indices, 1, m->d); - wprintf(L"\n"); - } - break; - - case 0x01: - // Mode 2 (2 bits, 01) - { - struct bc6h_mode2 - { - uint64_t mode : 2; // { M, 0}, { M, 1} - uint64_t gy5 : 1; // {GY, 5} - uint64_t gz45 : 2; // {GZ, 4}, {GZ, 5} - uint64_t rw : 7; // {RW, 0}, {RW, 1}, {RW, 2}, {RW, 3}, {RW, 4}, {RW, 5}, {RW, 6} - uint64_t bz : 2; // {BZ, 0}, {BZ, 1} - uint64_t by4 : 1; // {BY, 4}, - uint64_t gw : 7; // {GW, 0}, {GW, 1}, {GW, 2}, {GW, 3}, {GW, 4}, {GW, 5}, {GW, 6} - uint64_t by5 : 1; // {BY, 5} - uint64_t bz2 : 1; // {BZ, 2} - uint64_t gy4 : 1; // {GY, 4} - uint64_t bw : 7; // {BW, 0}, {BW, 1}, {BW, 2}, {BW, 3}, {BW, 4}, {BW, 5}, {BW, 6} - uint64_t bz3 : 1; // {BZ, 3} - uint64_t bz5 : 1; // {BZ, 5} - uint64_t bz4 : 1; // {BZ, 4} - uint64_t rx : 6; // {RX, 0}, {RX, 1}, {RX, 2}, {RX, 3}, {RX, 4}, {RX, 5} - uint64_t gy : 4; // {GY, 0}, {GY, 1}, {GY, 2}, {GY, 3} - uint64_t gx : 6; // {GX, 0}, {GX, 1}, {GX, 2}, {GX, 3}, {GX, 4}, {GX, 5} - uint64_t gz : 4; // {GZ, 0}, {GZ, 1}, {GZ, 2}, {GZ, 3} - uint64_t bx : 5; // {BX, 0}, {BX, 1}, {BX, 2}, {BX, 3}, {BX, 4}, {BX, 5} - uint64_t by : 4; // {BY, 0}, {BY, 1}, {BY, 2}, {BY, 3} - uint64_t ry : 6; // {RY, 0}, {RY, 1}, {RY, 2}, {RY, 3}, {RY, 4}, {RY, 5} - uint64_t rz : 6; // {RZ, 0}, {RZ, 1}, {RZ, 2}, {RZ, 3}, {RZ, 4}, {RZ, 5}, - uint64_t d : 5; // { D, 0}, { D, 1}, { D, 2}, { D, 3}, { D, 4} - uint64_t indices : 46; - - }; - static_assert(sizeof(bc6h_mode2) == 16, "Block size must be 16 bytes"); - - const bool bSigned = (image.format == DXGI_FORMAT_BC6H_SF16) ? true : false; - - auto m = reinterpret_cast(sptr); - - XMINT3 e0_A(int(m->rw), int(m->gw), int(m->bw)); - XMINT3 e0_B(int(m->rx), int(m->gx), int(m->bx)); - XMINT3 e1_A(int(m->ry), - int(m->gy | (m->gy4 << 4) | (m->gy5 << 5)), - int(m->by | (m->by4 << 4) | (m->by5 << 5))); - XMINT3 e1_B(int(m->rz), - int(m->gz | (m->gz45 << 4)), - int(m->bz | (m->bz2 << 2) | (m->bz3 << 3) | (m->bz4 << 4) | (m->bz5 << 5))); - - if (bSigned) - { - e0_A.x = SIGN_EXTEND(e0_A.x, 7); - e0_A.y = SIGN_EXTEND(e0_A.y, 7); - e0_A.z = SIGN_EXTEND(e0_A.z, 7); - - e0_B.x = SIGN_EXTEND(e0_B.x, 6); - e0_B.y = SIGN_EXTEND(e0_B.y, 6); - e0_B.z = SIGN_EXTEND(e0_B.z, 6); - - e1_A.x = SIGN_EXTEND(e1_A.x, 6); - e1_A.y = SIGN_EXTEND(e1_A.y, 6); - e1_A.z = SIGN_EXTEND(e1_A.z, 6); - - e1_B.x = SIGN_EXTEND(e1_B.x, 6); - e1_B.y = SIGN_EXTEND(e1_B.y, 6); - e1_B.z = SIGN_EXTEND(e1_B.z, 6); - } - - wprintf(L"\tMode 2 - [7 6 6 6] shape %llu\n", m->d); - wprintf(L"\t E0(A): (%04X, %04X, %04X)\n", e0_A.x & 0xFFFF, e0_A.y & 0xFFFF, e0_A.z & 0xFFFF); - wprintf(L"\t E0(B): (%04X, %04X, %04X)\n", e0_B.x & 0xFFFF, e0_B.y & 0xFFFF, e0_B.z & 0xFFFF); - wprintf(L"\t E1(A): (%04X, %04X, %04X)\n", e1_A.x & 0xFFFF, e1_A.y & 0xFFFF, e1_A.z & 0xFFFF); - wprintf(L"\t E1(B): (%04X, %04X, %04X)\n", e1_B.x & 0xFFFF, e1_B.y & 0xFFFF, e1_B.z & 0xFFFF); - wprintf(L"\t Index: "); - PrintIndex3bpp(m->indices, 1, m->d); - wprintf(L"\n"); - } - break; - - default: - switch (*sptr & 0x1F) - { - case 0x02: - // Mode 3 (5 bits, 00010) - { - struct bc6h_mode3 - { - uint64_t mode : 5; // { M, 0}, { M, 1}, { M, 2}, { M, 3}, { M, 4} - uint64_t rw : 10; // {RW, 0}, {RW, 1}, {RW, 2}, {RW, 3}, {RW, 4}, {RW, 5}, {RW, 6}, {RW, 7}, {RW, 8}, {RW, 9} - uint64_t gw : 10; // {GW, 0}, {GW, 1}, {GW, 2}, {GW, 3}, {GW, 4}, {GW, 5}, {GW, 6}, {GW, 7}, {GW, 8}, {GW, 9} - uint64_t bw : 10; // {BW, 0}, {BW, 1}, {BW, 2}, {BW, 3}, {BW, 4}, {BW, 5}, {BW, 6}, {BW, 7}, {BW, 8}, {BW, 9} - uint64_t rx : 5; // {RX, 0}, {RX, 1}, {RX, 2}, {RX, 3}, {RX, 4} - uint64_t rw10 : 1; // {RW,10} - uint64_t gy : 4; // {GY, 0}, {GY, 1}, {GY, 2}, {GY, 3} - uint64_t gx : 4; // {GX, 0}, {GX, 1}, {GX, 2}, {GX, 3} - uint64_t gw10 : 1; // {GW,10} - uint64_t bz0 : 1; // {BZ, 0} - uint64_t gz : 4; // {GZ, 0}, {GZ, 1}, {GZ, 2}, {GZ, 3} - uint64_t bx : 4; // {BX, 0}, {BX, 1}, {BX, 2}, {BX, 3} - uint64_t bw10 : 1; // {BW,10} - uint64_t bz1 : 1; // {BZ, 1} - uint64_t by : 3; // {BY, 0}, {BY, 1}, {BY, 2} - uint64_t by3 : 1; // {BY, 3} - uint64_t ry : 5; // {RY, 0}, {RY, 1}, {RY, 2}, {RY, 3}, {RY, 4} - uint64_t bz2 : 1; // {BZ, 2} - uint64_t rz : 5; // {RZ, 0}, {RZ, 1}, {RZ, 2}, {RZ, 3}, {RZ, 4} - uint64_t bz3 : 1; // {BZ, 3} - uint64_t d : 5; // { D, 0}, { D, 1}, { D, 2}, { D, 3}, { D, 4} - uint64_t indices : 46; - - }; - static_assert(sizeof(bc6h_mode3) == 16, "Block size must be 16 bytes"); - - const bool bSigned = (image.format == DXGI_FORMAT_BC6H_SF16) ? true : false; - - auto m = reinterpret_cast(sptr); - - XMINT3 e0_A(int(m->rw | (m->rw10 << 10)), - int(m->gw | (m->gw10 << 10)), - int(m->bw | (m->bw10 << 10))); - XMINT3 e0_B(int(m->rx), int(m->gx), int(m->bx)); - XMINT3 e1_A(int(m->ry), int(m->gy), - int(m->by | (m->by3 << 3))); - XMINT3 e1_B(int(m->rz), - int(m->gz), - int(m->bz0 | (m->bz1 << 1) | (m->bz2 << 2) | (m->bz3 << 3))); - - if (bSigned) - { - e0_A.x = SIGN_EXTEND(e0_A.x, 11); - e0_A.y = SIGN_EXTEND(e0_A.y, 11); - e0_A.z = SIGN_EXTEND(e0_A.z, 11); - - e0_B.x = SIGN_EXTEND(e0_B.x, 5); - e0_B.y = SIGN_EXTEND(e0_B.y, 4); - e0_B.z = SIGN_EXTEND(e0_B.z, 4); - - e1_A.x = SIGN_EXTEND(e1_A.x, 5); - e1_A.y = SIGN_EXTEND(e1_A.y, 4); - e1_A.z = SIGN_EXTEND(e1_A.z, 4); - - e1_B.x = SIGN_EXTEND(e1_B.x, 5); - e1_B.y = SIGN_EXTEND(e1_B.y, 4); - e1_B.z = SIGN_EXTEND(e1_B.z, 4); - } - - wprintf(L"\tMode 3 - [11 5 4 4] shape %llu\n", m->d); - wprintf(L"\t E0(A): (%04X, %04X, %04X)\n", e0_A.x & 0xFFFF, e0_A.y & 0xFFFF, e0_A.z & 0xFFFF); - wprintf(L"\t E0(B): (%04X, %04X, %04X)\n", e0_B.x & 0xFFFF, e0_B.y & 0xFFFF, e0_B.z & 0xFFFF); - wprintf(L"\t E1(A): (%04X, %04X, %04X)\n", e1_A.x & 0xFFFF, e1_A.y & 0xFFFF, e1_A.z & 0xFFFF); - wprintf(L"\t E1(B): (%04X, %04X, %04X)\n", e1_B.x & 0xFFFF, e1_B.y & 0xFFFF, e1_B.z & 0xFFFF); - wprintf(L"\t Index: "); - PrintIndex3bpp(m->indices, 1, m->d); - wprintf(L"\n"); - } - break; - - case 0x06: - // Mode 4 (5 bits, 00110) - { - struct bc6h_mode4 - { - uint64_t mode : 5; // { M, 0}, { M, 1}, { M, 2}, { M, 3}, { M, 4} - uint64_t rw : 10; // {RW, 0}, {RW, 1}, {RW, 2}, {RW, 3}, {RW, 4}, {RW, 5}, {RW, 6}, {RW, 7}, {RW, 8}, {RW, 9} - uint64_t gw : 10; // {GW, 0}, {GW, 1}, {GW, 2}, {GW, 3}, {GW, 4}, {GW, 5}, {GW, 6}, {GW, 7}, {GW, 8}, {GW, 9} - uint64_t bw : 10; // {BW, 0}, {BW, 1}, {BW, 2}, {BW, 3}, {BW, 4}, {BW, 5}, {BW, 6}, {BW, 7}, {BW, 8}, {BW, 9} - uint64_t rx : 4; // {RX, 0}, {RX, 1}, {RX, 2}, {RX, 3} - uint64_t rw10 : 1; // {RW,10} - uint64_t gz4 : 1; // {GZ, 4} - uint64_t gy : 4; // {GY, 0}, {GY, 1}, {GY, 2}, {GY, 3} - uint64_t gx : 5; // {GX, 0}, {GX, 1}, {GX, 2}, {GX, 3}, {GX, 4} - uint64_t gw10 : 1; // {GW,10} - uint64_t gz : 4; // {GZ, 0}, {GZ, 1}, {GZ, 2}, {GZ, 3} - uint64_t bx : 4; // {BX, 0}, {BX, 1}, {BX, 2}, {BX, 3} - uint64_t bw10 : 1; // {BW,10} - uint64_t bz1 : 1; // {BZ, 1} - uint64_t by : 3; // {BY, 0}, {BY, 1}, {BY, 2} - uint64_t by3 : 1; // {BY, 3} - uint64_t ry : 4; // {RY, 0}, {RY, 1}, {RY, 2}, {RY, 3} - uint64_t bz0 : 1; // {BZ, 0} - uint64_t bz2 : 1; // {BZ, 2} - uint64_t rz : 4; // {RZ, 0}, {RZ, 1}, {RZ, 2}, {RZ, 3} - uint64_t gy4 : 1; // {GY, 4} - uint64_t bz3 : 1; // {BZ, 3} - uint64_t d : 5; // { D, 0}, { D, 1}, { D, 2}, { D, 3}, { D, 4} - uint64_t indices : 46; - - }; - static_assert(sizeof(bc6h_mode4) == 16, "Block size must be 16 bytes"); - - const bool bSigned = (image.format == DXGI_FORMAT_BC6H_SF16) ? true : false; - - auto m = reinterpret_cast(sptr); - - XMINT3 e0_A(int(m->rw | (m->rw10 << 10)), - int(m->gw | (m->gw10 << 10)), - int(m->bw | (m->bw10 << 10))); - XMINT3 e0_B(int(m->rx), int(m->gx), int(m->bx)); - XMINT3 e1_A(int(m->ry), - int(m->gy | (m->gy4 << 4)), - int(m->by | (m->by3 << 3))); - XMINT3 e1_B(int(m->rz), - int(m->gz | (m->gz4 << 4)), - int(m->bz0 | (m->bz1 << 1) | (m->bz2 << 2) | (m->bz3 << 3))); - - if (bSigned) - { - e0_A.x = SIGN_EXTEND(e0_A.x, 11); - e0_A.y = SIGN_EXTEND(e0_A.y, 11); - e0_A.z = SIGN_EXTEND(e0_A.z, 11); - - e0_B.x = SIGN_EXTEND(e0_B.x, 4); - e0_B.y = SIGN_EXTEND(e0_B.y, 5); - e0_B.z = SIGN_EXTEND(e0_B.z, 4); - - e1_A.x = SIGN_EXTEND(e1_A.x, 4); - e1_A.y = SIGN_EXTEND(e1_A.y, 5); - e1_A.z = SIGN_EXTEND(e1_A.z, 4); - - e1_B.x = SIGN_EXTEND(e1_B.x, 4); - e1_B.y = SIGN_EXTEND(e1_B.y, 5); - e1_B.z = SIGN_EXTEND(e1_B.z, 4); - } - - wprintf(L"\tMode 4 - [11 4 5 4] shape %llu\n", m->d); - wprintf(L"\t E0(A): (%04X, %04X, %04X)\n", e0_A.x & 0xFFFF, e0_A.y & 0xFFFF, e0_A.z & 0xFFFF); - wprintf(L"\t E0(B): (%04X, %04X, %04X)\n", e0_B.x & 0xFFFF, e0_B.y & 0xFFFF, e0_B.z & 0xFFFF); - wprintf(L"\t E1(A): (%04X, %04X, %04X)\n", e1_A.x & 0xFFFF, e1_A.y & 0xFFFF, e1_A.z & 0xFFFF); - wprintf(L"\t E1(B): (%04X, %04X, %04X)\n", e1_B.x & 0xFFFF, e1_B.y & 0xFFFF, e1_B.z & 0xFFFF); - wprintf(L"\t Index: "); - PrintIndex3bpp(m->indices, 1, m->d); - wprintf(L"\n"); - } - break; - - case 0x0A: - // Mode 5 (5 bits, 01010) - { - struct bc6h_mode5 - { - uint64_t mode : 5; // { M, 0}, { M, 1}, { M, 2}, { M, 3}, { M, 4} - uint64_t rw : 10; // {RW, 0}, {RW, 1}, {RW, 2}, {RW, 3}, {RW, 4}, {RW, 5}, {RW, 6}, {RW, 7}, {RW, 8}, {RW, 9} - uint64_t gw : 10; // {GW, 0}, {GW, 1}, {GW, 2}, {GW, 3}, {GW, 4}, {GW, 5}, {GW, 6}, {GW, 7}, {GW, 8}, {GW, 9} - uint64_t bw : 10; // {BW, 0}, {BW, 1}, {BW, 2}, {BW, 3}, {BW, 4}, {BW, 5}, {BW, 6}, {BW, 7}, {BW, 8}, {BW, 9} - uint64_t rx : 4; // {RX, 0}, {RX, 1}, {RX, 2}, {RX, 3} - uint64_t rw10 : 1; // {RW,10} - uint64_t by4 : 1; // {BY, 4} - uint64_t gy : 4; // {GY, 0}, {GY, 1}, {GY, 2}, {GY, 3} - uint64_t gx : 4; // {GX, 0}, {GX, 1}, {GX, 2}, {GX, 3} - uint64_t gw10 : 1; // {GW,10} - uint64_t bz0 : 1; // {BZ, 0} - uint64_t gz : 4; // {GZ, 0}, {GZ, 1}, {GZ, 2}, {GZ, 3} - uint64_t bx : 5; // {BX, 0}, {BX, 1}, {BX, 2}, {BX, 3}, {BX, 4} - uint64_t bw10 : 1; // {BW,10} - uint64_t by : 3; // {BY, 0}, {BY, 1}, {BY, 2} - uint64_t by3 : 1; // {BY, 3} - uint64_t ry : 4; // {RY, 0}, {RY, 1}, {RY, 2}, {RY, 3} - uint64_t bz12 : 2; // {BZ, 1}, {BZ, 2} - uint64_t rz : 5; // {RZ, 0}, {RZ, 1}, {RZ, 2}, {RZ, 3}, {BZ, 4} - uint64_t bz3 : 1; // {BZ, 3} - uint64_t d : 5; // { D, 0}, { D, 1}, { D, 2}, { D, 3}, { D, 4} - uint64_t indices : 46; - }; - static_assert(sizeof(bc6h_mode5) == 16, "Block size must be 16 bytes"); - - const bool bSigned = (image.format == DXGI_FORMAT_BC6H_SF16) ? true : false; - - auto m = reinterpret_cast(sptr); - - XMINT3 e0_A(int(m->rw | (m->rw10 << 10)), - int(m->gw | (m->gw10 << 10)), - int(m->bw | (m->bw10 << 10))); - XMINT3 e0_B(int(m->rx), int(m->gx), int(m->bx)); - XMINT3 e1_A(int(m->ry), int(m->gy), - int(m->by | (m->by3 << 3) | (m->by4 << 4))); - XMINT3 e1_B(int(m->rz), int(m->gz), - int(m->bz0 | (m->bz12 << 1) | (m->bz3 << 3))); - - if (bSigned) - { - e0_A.x = SIGN_EXTEND(e0_A.x, 11); - e0_A.y = SIGN_EXTEND(e0_A.y, 11); - e0_A.z = SIGN_EXTEND(e0_A.z, 11); - - e0_B.x = SIGN_EXTEND(e0_B.x, 4); - e0_B.y = SIGN_EXTEND(e0_B.y, 4); - e0_B.z = SIGN_EXTEND(e0_B.z, 5); - - e1_A.x = SIGN_EXTEND(e1_A.x, 4); - e1_A.y = SIGN_EXTEND(e1_A.y, 4); - e1_A.z = SIGN_EXTEND(e1_A.z, 5); - - e1_B.x = SIGN_EXTEND(e1_B.x, 4); - e1_B.y = SIGN_EXTEND(e1_B.y, 4); - e1_B.z = SIGN_EXTEND(e1_B.z, 5); - } - - wprintf(L"\tMode 5 - [11 4 4 5] shape %llu\n", m->d); - wprintf(L"\t E0(A): (%04X, %04X, %04X)\n", e0_A.x & 0xFFFF, e0_A.y & 0xFFFF, e0_A.z & 0xFFFF); - wprintf(L"\t E0(B): (%04X, %04X, %04X)\n", e0_B.x & 0xFFFF, e0_B.y & 0xFFFF, e0_B.z & 0xFFFF); - wprintf(L"\t E1(A): (%04X, %04X, %04X)\n", e1_A.x & 0xFFFF, e1_A.y & 0xFFFF, e1_A.z & 0xFFFF); - wprintf(L"\t E1(B): (%04X, %04X, %04X)\n", e1_B.x & 0xFFFF, e1_B.y & 0xFFFF, e1_B.z & 0xFFFF); - wprintf(L"\t Index: "); - PrintIndex3bpp(m->indices, 1, m->d); - wprintf(L"\n"); - } - break; - - case 0x0E: - // Mode 6 (5 bits, 01110) - { - struct bc6h_mode6 - { - uint64_t mode : 5; // { M, 0}, { M, 1}, { M, 2}, { M, 3}, { M, 4} - uint64_t rw : 9; // {RW, 0}, {RW, 1}, {RW, 2}, {RW, 3}, {RW, 4}, {RW, 5}, {RW, 6}, {RW, 7}, {RW, 8} - uint64_t by4 : 1; // {BY, 4} - uint64_t gw : 9; // {GW, 0}, {GW, 1}, {GW, 2}, {GW, 3}, {GW, 4}, {GW, 5}, {GW, 6}, {GW, 7}, {GW, 8} - uint64_t gy4 : 1; // {GY, 4} - uint64_t bw : 9; // {BW, 0}, {BW, 1}, {BW, 2}, {BW, 3}, {BW, 4}, {BW, 5}, {BW, 6}, {BW, 7}, {BW, 8} - uint64_t bz4 : 1; // {BZ, 4} - uint64_t rx : 5; // {RX, 0}, {RX, 1}, {RX, 2}, {RX, 3}, {RX, 4} - uint64_t gz4 : 1; // {GZ, 4} - uint64_t gy : 4; // {GY, 0}, {GY, 1}, {GY, 2}, {GY, 3} - uint64_t gx : 5; // {GX, 0}, {GX, 1}, {GX, 2}, {GX, 3}, {GX, 4} - uint64_t bz0 : 1; // {BZ, 0} - uint64_t gz : 4; // {GZ, 0}, {GZ, 1}, {GZ, 2}, {GZ, 3} - uint64_t bx : 5; // {BX, 0}, {BX, 1}, {BX, 2}, {BX, 3}, {BX, 4} - uint64_t bz1 : 1; // {BZ, 1} - uint64_t by : 3; // {BY, 0}, {BY, 1}, {BY, 2} - uint64_t by3 : 1; // {BY, 3} - uint64_t ry : 5; // {RY, 0}, {RY, 1}, {RY, 2}, {RY, 3}, {RY, 4}, - uint64_t bz2 : 1; // {BZ, 2} - uint64_t rz : 5; // {RZ, 0}, {RZ, 1}, {RZ, 2}, {RZ, 3}, {BZ, 4} - uint64_t bz3 : 1; // {BZ, 3} - uint64_t d : 5; // { D, 0}, { D, 1}, { D, 2}, { D, 3}, { D, 4} - uint64_t indices : 46; - }; - static_assert(sizeof(bc6h_mode6) == 16, "Block size must be 16 bytes"); - - const bool bSigned = (image.format == DXGI_FORMAT_BC6H_SF16) ? true : false; - - auto m = reinterpret_cast(sptr); - - XMINT3 e0_A(int(m->rw), int(m->gw), int(m->bw)); - XMINT3 e0_B(int(m->rx), int(m->gx), int(m->bx)); - XMINT3 e1_A(int(m->ry), - int(m->gy | (m->gy4 << 4)), - int(m->by | (m->by3 << 3) | (m->by4 << 4))); - XMINT3 e1_B(int(m->rz), - int(m->gz | (m->gz4 << 4)), - int(m->bz0 | (m->bz1 << 1) | (m->bz2 << 2) | (m->bz3 << 3) | (m->bz4 << 4))); - - if (bSigned) - { - e0_A.x = SIGN_EXTEND(e0_A.x, 9); - e0_A.y = SIGN_EXTEND(e0_A.y, 9); - e0_A.z = SIGN_EXTEND(e0_A.z, 9); - - e0_B.x = SIGN_EXTEND(e0_B.x, 5); - e0_B.y = SIGN_EXTEND(e0_B.y, 5); - e0_B.z = SIGN_EXTEND(e0_B.z, 5); - - e1_A.x = SIGN_EXTEND(e1_A.x, 5); - e1_A.y = SIGN_EXTEND(e1_A.y, 5); - e1_A.z = SIGN_EXTEND(e1_A.z, 5); - - e1_B.x = SIGN_EXTEND(e1_B.x, 5); - e1_B.y = SIGN_EXTEND(e1_B.y, 5); - e1_B.z = SIGN_EXTEND(e1_B.z, 5); - } - - wprintf(L"\tMode 6 - [9 5 5 5] shape %llu\n", m->d); - wprintf(L"\t E0(A): (%04X, %04X, %04X)\n", e0_A.x & 0xFFFF, e0_A.y & 0xFFFF, e0_A.z & 0xFFFF); - wprintf(L"\t E0(B): (%04X, %04X, %04X)\n", e0_B.x & 0xFFFF, e0_B.y & 0xFFFF, e0_B.z & 0xFFFF); - wprintf(L"\t E1(A): (%04X, %04X, %04X)\n", e1_A.x & 0xFFFF, e1_A.y & 0xFFFF, e1_A.z & 0xFFFF); - wprintf(L"\t E1(B): (%04X, %04X, %04X)\n", e1_B.x & 0xFFFF, e1_B.y & 0xFFFF, e1_B.z & 0xFFFF); - wprintf(L"\t Index: "); - PrintIndex3bpp(m->indices, 1, m->d); - wprintf(L"\n"); - } - break; - - case 0x12: - // Mode 7 (5 bits, 10010) - { - struct bc6h_mode7 - { - uint64_t mode : 5; // { M, 0}, { M, 1}, { M, 2}, { M, 3}, { M, 4} - uint64_t rw : 8; // {RW, 0}, {RW, 1}, {RW, 2}, {RW, 3}, {RW, 4}, {RW, 5}, {RW, 6}, {RW, 7} - uint64_t gz4 : 1; // {GZ, 4} - uint64_t by4 : 1; // {BY, 4} - uint64_t gw : 8; // {GW, 0}, {GW, 1}, {GW, 2}, {GW, 3}, {GW, 4}, {GW, 5}, {GW, 6}, {GW, 7} - uint64_t bz2 : 1; // {BZ, 2} - uint64_t gy4 : 1; // {GY, 4} - uint64_t bw : 8; // {BW, 0}, {BW, 1}, {BW, 2}, {BW, 3}, {BW, 4}, {BW, 5}, {BW, 6}, {BW, 7} - uint64_t bz3 : 1; // {BZ, 3} - uint64_t bz4 : 1; // {BZ, 4} - uint64_t rx : 6; // {RX, 0}, {RX, 1}, {RX, 2}, {RX, 3}, {RX, 4}, {RX, 5} - uint64_t gy : 4; // {GY, 0}, {GY, 1}, {GY, 2}, {GY, 3} - uint64_t gx : 5; // {GX, 0}, {GX, 1}, {GX, 2}, {GX, 3}, {GX, 4} - uint64_t bz0 : 1; // {BZ, 0} - uint64_t gz : 4; // {GZ, 0}, {GZ, 1}, {GZ, 2}, {GZ, 3} - uint64_t bx : 5; // {BX, 0}, {BX, 1}, {BX, 2}, {BX, 3}, {BX, 4} - uint64_t bz1 : 1; // {BZ, 1} - uint64_t by : 3; // {BY, 0}, {BY, 1}, {BY, 2} - uint64_t by3 : 1; // {BY, 3} - uint64_t ry : 6; // {RY, 0}, {RY, 1}, {RY, 2}, {RY, 3}, {RY, 4}, {RY, 5} - uint64_t rz : 6; // {RZ, 0}, {RZ, 1}, {RZ, 2}, {RZ, 3}, {RZ, 4}, {RZ, 5} - uint64_t d : 5; // { D, 0}, { D, 1}, { D, 2}, { D, 3}, { D, 4} - uint64_t indices : 46; - }; - static_assert(sizeof(bc6h_mode7) == 16, "Block size must be 16 bytes"); - - const bool bSigned = (image.format == DXGI_FORMAT_BC6H_SF16) ? true : false; - - auto m = reinterpret_cast(sptr); - - XMINT3 e0_A(int(m->rw), int(m->gw), int(m->bw)); - XMINT3 e0_B(int(m->rx), int(m->gx), int(m->bx)); - XMINT3 e1_A(int(m->ry), - int(m->gy | (m->gy4 << 4)), - int(m->by | (m->by3 << 3) | (m->by4 << 4))); - XMINT3 e1_B(int(m->rz), - int(m->gz | (m->gz4 << 4)), - int(m->bz0 | (m->bz1 << 1) | (m->bz2 << 2) | (m->bz3 << 3) | (m->bz4 << 4))); - - if (bSigned) - { - e0_A.x = SIGN_EXTEND(e0_A.x, 8); - e0_A.y = SIGN_EXTEND(e0_A.y, 8); - e0_A.z = SIGN_EXTEND(e0_A.z, 8); - - e0_B.x = SIGN_EXTEND(e0_B.x, 6); - e0_B.y = SIGN_EXTEND(e0_B.y, 5); - e0_B.z = SIGN_EXTEND(e0_B.z, 5); - - e1_A.x = SIGN_EXTEND(e1_A.x, 6); - e1_A.y = SIGN_EXTEND(e1_A.y, 5); - e1_A.z = SIGN_EXTEND(e1_A.z, 5); - - e1_B.x = SIGN_EXTEND(e1_B.x, 6); - e1_B.y = SIGN_EXTEND(e1_B.y, 5); - e1_B.z = SIGN_EXTEND(e1_B.z, 5); - } - - wprintf(L"\tMode 7 - [8 6 5 5] shape %llu\n", m->d); - wprintf(L"\t E0(A): (%04X, %04X, %04X)\n", e0_A.x & 0xFFFF, e0_A.y & 0xFFFF, e0_A.z & 0xFFFF); - wprintf(L"\t E0(B): (%04X, %04X, %04X)\n", e0_B.x & 0xFFFF, e0_B.y & 0xFFFF, e0_B.z & 0xFFFF); - wprintf(L"\t E1(A): (%04X, %04X, %04X)\n", e1_A.x & 0xFFFF, e1_A.y & 0xFFFF, e1_A.z & 0xFFFF); - wprintf(L"\t E1(B): (%04X, %04X, %04X)\n", e1_B.x & 0xFFFF, e1_B.y & 0xFFFF, e1_B.z & 0xFFFF); - wprintf(L"\t Index: "); - PrintIndex3bpp(m->indices, 1, m->d); - wprintf(L"\n"); - } - break; - - case 0x16: - // Mode 8 (5 bits, 10110) - { - struct bc6h_mode8 - { - uint64_t mode : 5; // { M, 0}, { M, 1}, { M, 2}, { M, 3}, { M, 4} - uint64_t rw : 8; // {RW, 0}, {RW, 1}, {RW, 2}, {RW, 3}, {RW, 4}, {RW, 5}, {RW, 6}, {RW, 7} - uint64_t bz0 : 1; // {BZ, 0} - uint64_t by4 : 1; // {BY, 4} - uint64_t gw : 8; // {GW, 0}, {GW, 1}, {GW, 2}, {GW, 3}, {GW, 4}, {GW, 5}, {GW, 6}, {GW, 7} - uint64_t gy5 : 1; // {GY, 5} - uint64_t gy4 : 1; // {GY, 4} - uint64_t bw : 8; // {BW, 0}, {BW, 1}, {BW, 2}, {BW, 3}, {BW, 4}, {BW, 5}, {BW, 6}, {BW, 7} - uint64_t gz5 : 1; // {GZ, 5} - uint64_t bz4 : 1; // {BZ, 4} - uint64_t rx : 5; // {RX, 0}, {RX, 1}, {RX, 2}, {RX, 3}, {RX, 4} - uint64_t gz4 : 1; // {GZ, 4} - uint64_t gy : 4; // {GY, 0}, {GY, 1}, {GY, 2}, {GY, 3} - uint64_t gx : 6; // {GX, 0}, {GX, 1}, {GX, 2}, {GX, 3}, {GX, 4}, {GX, 5} - uint64_t gz : 4; // {GZ, 0}, {GZ, 1}, {GZ, 2}, {GZ, 3} - uint64_t bx : 5; // {BX, 0}, {BX, 1}, {BX, 2}, {BX, 3}, {BX, 4} - uint64_t bz1 : 1; // {BZ, 1} - uint64_t by : 3; // {BY, 0}, {BY, 1}, {BY, 2} - uint64_t by3 : 1; // {BY, 3} - uint64_t ry : 5; // {RY, 0}, {RY, 1}, {RY, 2}, {RY, 3}, {RY, 4} - uint64_t bz2 : 1; // {BZ, 2} - uint64_t rz : 5; // {RZ, 0}, {RZ, 1}, {RZ, 2}, {RZ, 3}, {RZ, 4} - uint64_t bz3 : 1; // {BZ, 3} - uint64_t d : 5; // { D, 0}, { D, 1}, { D, 2}, { D, 3}, { D, 4} - uint64_t indices : 46; - }; - static_assert(sizeof(bc6h_mode8) == 16, "Block size must be 16 bytes"); - - const bool bSigned = (image.format == DXGI_FORMAT_BC6H_SF16) ? true : false; - - auto m = reinterpret_cast(sptr); - - XMINT3 e0_A(int(m->rw), int(m->gw), int(m->bw)); - XMINT3 e0_B(int(m->rx), int(m->gx), int(m->bx)); - XMINT3 e1_A(int(m->ry), - int(m->gy | (m->gy4 << 4) | (m->gy5 << 5)), - int(m->by | (m->by3 << 3) | (m->by4 << 4))); - XMINT3 e1_B(int(m->rz), - int(m->gz | (m->gz4 << 4) | (m->gz5 << 5)), - int(m->bz0 | (m->bz1 << 1) | (m->bz2 << 2) | (m->bz3 << 3) | (m->bz4 << 4))); - - if (bSigned) - { - e0_A.x = SIGN_EXTEND(e0_A.x, 8); - e0_A.y = SIGN_EXTEND(e0_A.y, 8); - e0_A.z = SIGN_EXTEND(e0_A.z, 8); - - e0_B.x = SIGN_EXTEND(e0_B.x, 5); - e0_B.y = SIGN_EXTEND(e0_B.y, 6); - e0_B.z = SIGN_EXTEND(e0_B.z, 5); - - e1_A.x = SIGN_EXTEND(e1_A.x, 5); - e1_A.y = SIGN_EXTEND(e1_A.y, 6); - e1_A.z = SIGN_EXTEND(e1_A.z, 5); - - e1_B.x = SIGN_EXTEND(e1_B.x, 5); - e1_B.y = SIGN_EXTEND(e1_B.y, 6); - e1_B.z = SIGN_EXTEND(e1_B.z, 5); - } - - wprintf(L"\tMode 8 - [8 5 6 5] shape %llu\n", m->d); - wprintf(L"\t E0(A): (%04X, %04X, %04X)\n", e0_A.x & 0xFFFF, e0_A.y & 0xFFFF, e0_A.z & 0xFFFF); - wprintf(L"\t E0(B): (%04X, %04X, %04X)\n", e0_B.x & 0xFFFF, e0_B.y & 0xFFFF, e0_B.z & 0xFFFF); - wprintf(L"\t E1(A): (%04X, %04X, %04X)\n", e1_A.x & 0xFFFF, e1_A.y & 0xFFFF, e1_A.z & 0xFFFF); - wprintf(L"\t E1(B): (%04X, %04X, %04X)\n", e1_B.x & 0xFFFF, e1_B.y & 0xFFFF, e1_B.z & 0xFFFF); - wprintf(L"\t Index: "); - PrintIndex3bpp(m->indices, 1, m->d); - wprintf(L"\n"); - } - break; - - case 0x1A: - // Mode 9 (5 bits, 11010) - { - struct bc6h_mode9 - { - uint64_t mode : 5; // { M, 0}, { M, 1}, { M, 2}, { M, 3}, { M, 4} - uint64_t rw : 8; // {RW, 0}, {RW, 1}, {RW, 2}, {RW, 3}, {RW, 4}, {RW, 5}, {RW, 6}, {RW, 7} - uint64_t bz1 : 1; // {BZ, 1} - uint64_t by4 : 1; // {BY, 4} - uint64_t gw : 8; // {GW, 0}, {GW, 1}, {GW, 2}, {GW, 3}, {GW, 4}, {GW, 5}, {GW, 6}, {GW, 7} - uint64_t by5 : 1; // {BY, 5} - uint64_t gy4 : 1; // {GY, 4} - uint64_t bw : 8; // {BW, 0}, {BW, 1}, {BW, 2}, {BW, 3}, {BW, 4}, {BW, 5}, {BW, 6}, {BW, 7} - uint64_t bz5 : 1; // {BZ, 5} - uint64_t bz4 : 1; // {BZ, 4} - uint64_t rx : 5; // {RX, 0}, {RX, 1}, {RX, 2}, {RX, 3}, {RX, 4} - uint64_t gz4 : 1; // {GZ, 4} - uint64_t gy : 4; // {GY, 0}, {GY, 1}, {GY, 2}, {GY, 3} - uint64_t gx : 5; // {GX, 0}, {GX, 1}, {GX, 2}, {GX, 3}, {GX, 4} - uint64_t bz0 : 1; // {BZ, 0} - uint64_t gz : 4; // {GZ, 0}, {GZ, 1}, {GZ, 2}, {GZ, 3} - uint64_t bx : 6; // {BX, 0}, {BX, 1}, {BX, 2}, {BX, 3}, {BX, 4}, {BX, 5} - uint64_t by : 3; // {BY, 0}, {BY, 1}, {BY, 2} - uint64_t by3 : 1; // {BY, 3} - uint64_t ry : 5; // {RY, 0}, {RY, 1}, {RY, 2}, {RY, 3}, {RY, 4} - uint64_t bz2 : 1; // {BZ, 2} - uint64_t rz : 5; // {RZ, 0}, {RZ, 1}, {RZ, 2}, {RZ, 3}, {RZ, 4} - uint64_t bz3 : 1; // {BZ, 3} - uint64_t d : 5; // { D, 0}, { D, 1}, { D, 2}, { D, 3}, { D, 4} - uint64_t indices : 46; - }; - static_assert(sizeof(bc6h_mode9) == 16, "Block size must be 16 bytes"); - - const bool bSigned = (image.format == DXGI_FORMAT_BC6H_SF16) ? true : false; - - auto m = reinterpret_cast(sptr); - - XMINT3 e0_A(int(m->rw), int(m->gw), int(m->bw)); - XMINT3 e0_B(int(m->rx), int(m->gx), int(m->bx)); - XMINT3 e1_A(int(m->ry), - int(m->gy | (m->gy4 << 4)), - int(m->by | (m->by3 << 3) | (m->by4 << 4) | (m->by5 << 5))); - XMINT3 e1_B(int(m->rz), - int(m->gz | (m->gz4 << 4)), - int(m->bz0 | (m->bz1 << 1) | (m->bz2 << 2) | (m->bz3 << 3) | (m->bz4 << 4) | (m->bz5 << 5))); - - if (bSigned) - { - e0_A.x = SIGN_EXTEND(e0_A.x, 8); - e0_A.y = SIGN_EXTEND(e0_A.y, 8); - e0_A.z = SIGN_EXTEND(e0_A.z, 8); - - e0_B.x = SIGN_EXTEND(e0_B.x, 5); - e0_B.y = SIGN_EXTEND(e0_B.y, 5); - e0_B.z = SIGN_EXTEND(e0_B.z, 6); - - e1_A.x = SIGN_EXTEND(e1_A.x, 5); - e1_A.y = SIGN_EXTEND(e1_A.y, 5); - e1_A.z = SIGN_EXTEND(e1_A.z, 6); - - e1_B.x = SIGN_EXTEND(e1_B.x, 5); - e1_B.y = SIGN_EXTEND(e1_B.y, 5); - e1_B.z = SIGN_EXTEND(e1_B.z, 6); - } - - wprintf(L"\tMode 9 - [8 5 5 6] shape %llu\n", m->d); - wprintf(L"\t E0(A): (%04X, %04X, %04X)\n", e0_A.x & 0xFFFF, e0_A.y & 0xFFFF, e0_A.z & 0xFFFF); - wprintf(L"\t E0(B): (%04X, %04X, %04X)\n", e0_B.x & 0xFFFF, e0_B.y & 0xFFFF, e0_B.z & 0xFFFF); - wprintf(L"\t E1(A): (%04X, %04X, %04X)\n", e1_A.x & 0xFFFF, e1_A.y & 0xFFFF, e1_A.z & 0xFFFF); - wprintf(L"\t E1(B): (%04X, %04X, %04X)\n", e1_B.x & 0xFFFF, e1_B.y & 0xFFFF, e1_B.z & 0xFFFF); - wprintf(L"\t Index: "); - PrintIndex3bpp(m->indices, 1, m->d); - wprintf(L"\n"); - } - break; - - case 0x1E: - // Mode 10 (5 bits, 11110) - { - struct bc6h_mode10 - { - uint64_t mode : 5; // { M, 0}, { M, 1}, { M, 2}, { M, 3}, { M, 4} - uint64_t rw : 6; // {RW, 0}, {RW, 1}, {RW, 2}, {RW, 3}, {RW, 4}, {RW, 5} - uint64_t gz4 : 1; // {GZ, 4} - uint64_t bz : 2; // {BZ, 0}, {BZ, 1} - uint64_t by4 : 1; // {BY, 4} - uint64_t gw : 6; // {GW, 0}, {GW, 1}, {GW, 2}, {GW, 3}, {GW, 4}, {GW, 5} - uint64_t gy5 : 1; // {GY, 5} - uint64_t by5 : 1; // {BY, 5} - uint64_t bz2 : 1; // {BZ, 2} - uint64_t gy4 : 1; // {GY, 4} - uint64_t bw : 6; // {BW, 0}, {BW, 1}, {BW, 2}, {BW, 3}, {BW, 4}, {BW, 5}, {GZ, 5} - uint64_t bz3 : 1; // {BZ, 3} - uint64_t bz5 : 1; // {BZ, 5} - uint64_t bz4 : 1; // {BZ, 4} - uint64_t rx : 6; // {RX, 0}, {RX, 1}, {RX, 2}, {RX, 3}, {RX, 4}, {RX, 5} - uint64_t gy : 4; // {GY, 0}, {GY, 1}, {GY, 2}, {GY, 3} - uint64_t gx : 6; // {GX, 0}, {GX, 1}, {GX, 2}, {GX, 3}, {GX, 4}, {GX, 5} - uint64_t gz : 4; // {GZ, 0}, {GZ, 1}, {GZ, 2}, {GZ, 3} - uint64_t bx : 6; // {BX, 0}, {BX, 1}, {BX, 2}, {BX, 3}, {BX, 4}, {BX, 5} - uint64_t by : 3; // {BY, 0}, {BY, 1}, {BY, 2} - uint64_t by3 : 1; // {BY, 3} - uint64_t ry : 6; // {RY, 0}, {RY, 1}, {RY, 2}, {RY, 3}, {RY, 4}, {RY, 5} - uint64_t rz : 6; // {RZ, 0}, {RZ, 1}, {RZ, 2}, {RZ, 3}, {RZ, 4}, {RZ, 5} - uint64_t d : 5; // { D, 0}, { D, 1}, { D, 2}, { D, 3}, { D, 4} - uint64_t indices : 46; - }; - static_assert(sizeof(bc6h_mode10) == 16, "Block size must be 16 bytes"); - - const bool bSigned = (image.format == DXGI_FORMAT_BC6H_SF16) ? true : false; - - auto m = reinterpret_cast(sptr); - - XMINT3 e0_A(int(m->rw), int(m->gw), int(m->bw)); - XMINT3 e0_B(int(m->rx), int(m->gx), int(m->bx)); - XMINT3 e1_A(int(m->ry), - int(m->gy | (m->gy4 << 4) | (m->gy5 << 5)), - int(m->by | (m->by3 << 3) | (m->by4 << 4) | (m->by5 << 5))); - XMINT3 e1_B(int(m->rz), - int(m->gz | (m->gz4 << 4)), - int(m->bz | (m->bz2 << 2) | (m->bz3 << 3) | (m->bz4 << 4) | (m->bz5 << 5))); - - if (bSigned) - { - e0_A.x = SIGN_EXTEND(e0_A.x, 6); - e0_A.y = SIGN_EXTEND(e0_A.y, 6); - e0_A.z = SIGN_EXTEND(e0_A.z, 6); - - e0_B.x = SIGN_EXTEND(e0_B.x, 6); - e0_B.y = SIGN_EXTEND(e0_B.y, 6); - e0_B.z = SIGN_EXTEND(e0_B.z, 6); - - e1_A.x = SIGN_EXTEND(e1_A.x, 6); - e1_A.y = SIGN_EXTEND(e1_A.y, 6); - e1_A.z = SIGN_EXTEND(e1_A.z, 6); - - e1_B.x = SIGN_EXTEND(e1_B.x, 6); - e1_B.y = SIGN_EXTEND(e1_B.y, 6); - e1_B.z = SIGN_EXTEND(e1_B.z, 6); - } - - wprintf(L"\tMode 10 - [6 6 6 6] shape %llu\n", m->d); - wprintf(L"\t E0(A): (%04X, %04X, %04X)\n", e0_A.x & 0xFFFF, e0_A.y & 0xFFFF, e0_A.z & 0xFFFF); - wprintf(L"\t E0(B): (%04X, %04X, %04X)\n", e0_B.x & 0xFFFF, e0_B.y & 0xFFFF, e0_B.z & 0xFFFF); - wprintf(L"\t E1(A): (%04X, %04X, %04X)\n", e1_A.x & 0xFFFF, e1_A.y & 0xFFFF, e1_A.z & 0xFFFF); - wprintf(L"\t E1(B): (%04X, %04X, %04X)\n", e1_B.x & 0xFFFF, e1_B.y & 0xFFFF, e1_B.z & 0xFFFF); - wprintf(L"\t Index: "); - PrintIndex3bpp(m->indices, 1, m->d); - wprintf(L"\n"); - } - break; - - case 0x03: - // Mode 11 (5 bits, 00011) - { - struct bc6h_mode11 - { - uint64_t mode : 5; // { M, 0}, { M, 1}, { M, 2}, { M, 3}, { M, 4} - uint64_t rw : 10; // {RW, 0}, {RW, 1}, {RW, 2}, {RW, 3}, {RW, 4}, {RW, 5}, {RW, 6}, {RW, 7}, {RW, 8}, {RW, 9} - uint64_t gw : 10; // {GW, 0}, {GW, 1}, {GW, 2}, {GW, 3}, {GW, 4}, {GW, 5}, {GW, 6}, {GW, 7}, {GW, 8}, {GW, 9} - uint64_t bw : 10; // {BW, 0}, {BW, 1}, {BW, 2}, {BW, 3}, {BW, 4}, {BW, 5}, {BW, 6}, {BW, 7}, {BW, 8}, {BW, 9} - uint64_t rx : 10; // {RX, 0}, {RX, 1}, {RX, 2}, {RX, 3}, {RX, 4}, {RX, 5}, {RX, 6}, {RX, 7}, {RX, 8}, {RX, 9} - uint64_t gx : 10; // {GX, 0}, {GX, 1}, {GX, 2}, {GX, 3}, {GX, 4}, {GX, 5}, {GX, 6}, {GX, 7}, {GX, 8}, {GX, 9} - uint64_t bx : 9; // {BX, 0}, {BX, 1}, {BX, 2}, {BX, 3}, {BX, 4}, {BX, 5}, {BX, 6}, {BX, 7}, {BX, 8} - uint64_t bx9 : 1; // {BX, 9} - uint64_t indices : 63; - }; - static_assert(sizeof(bc6h_mode11) == 16, "Block size must be 16 bytes"); - - const bool bSigned = (image.format == DXGI_FORMAT_BC6H_SF16) ? true : false; - - auto m = reinterpret_cast(sptr); - - XMINT3 e0_A(int(m->rw), int(m->gw), int(m->bw)); - XMINT3 e0_B(int(m->rx), int(m->gx), - int(m->bx | (m->bx9 << 9))); - - if (bSigned) - { - e0_A.x = SIGN_EXTEND(e0_A.x, 10); - e0_A.y = SIGN_EXTEND(e0_A.y, 10); - e0_A.z = SIGN_EXTEND(e0_A.z, 10); - - e0_B.x = SIGN_EXTEND(e0_B.x, 10); - e0_B.y = SIGN_EXTEND(e0_B.y, 10); - e0_B.z = SIGN_EXTEND(e0_B.z, 10); - } - - wprintf(L"\tMode 11 - [10 10]\n"); - wprintf(L"\t E(A): (%04X, %04X, %04X)\n", e0_A.x & 0xFFFF, e0_A.y & 0xFFFF, e0_A.z & 0xFFFF); - wprintf(L"\t E(B): (%04X, %04X, %04X)\n", e0_B.x & 0xFFFF, e0_B.y & 0xFFFF, e0_B.z & 0xFFFF); - wprintf(L"\t Index: "); - PrintIndex4bpp(m->indices, 0, 0); - wprintf(L"\n"); - } - break; - - case 0x07: - // Mode 12 (5 bits, 00111) - { - struct bc6h_mode12 - { - uint64_t mode : 5; // { M, 0}, { M, 1}, { M, 2}, { M, 3}, { M, 4} - uint64_t rw : 10; // {RW, 0}, {RW, 1}, {RW, 2}, {RW, 3}, {RW, 4}, {RW, 5}, {RW, 6}, {RW, 7}, {RW, 8}, {RW, 9} - uint64_t gw : 10; // {GW, 0}, {GW, 1}, {GW, 2}, {GW, 3}, {GW, 4}, {GW, 5}, {GW, 6}, {GW, 7}, {GW, 8}, {GW, 9} - uint64_t bw : 10; // {BW, 0}, {BW, 1}, {BW, 2}, {BW, 3}, {BW, 4}, {BW, 5}, {BW, 6}, {BW, 7}, {BW, 8}, {BW, 9} - uint64_t rx : 9; // {RX, 0}, {RX, 1}, {RX, 2}, {RX, 3}, {RX, 4}, {RX, 5}, {RX, 6}, {RX, 7}, {RX, 8} - uint64_t rw10 : 1; // {RW,10} - uint64_t gx : 9; // {GX, 0}, {GX, 1}, {GX, 2}, {GX, 3}, {GX, 4}, {GX, 5}, {GX, 6}, {GX, 7}, {GX, 8} - uint64_t gw10 : 1; // {GW,10} - uint64_t bx : 9; // {BX, 0}, {BX, 1}, {BX, 2}, {BX, 3}, {BX, 4}, {BX, 5}, {BX, 6}, {BX, 7}, {BX, 8} - uint64_t bw10 : 1; // {BW,10} - uint64_t indices : 63; - }; - static_assert(sizeof(bc6h_mode12) == 16, "Block size must be 16 bytes"); - - const bool bSigned = (image.format == DXGI_FORMAT_BC6H_SF16) ? true : false; - - auto m = reinterpret_cast(sptr); - - XMINT3 e0_A(int(m->rw | (m->rw10 << 10)), - int(m->gw | (m->gw10 << 10)), - int(m->bw | (m->bw10 << 10))); - XMINT3 e0_B(int(m->rx), int(m->gx), int(m->bx)); - - if (bSigned) - { - e0_A.x = SIGN_EXTEND(e0_A.x, 11); - e0_A.y = SIGN_EXTEND(e0_A.y, 11); - e0_A.z = SIGN_EXTEND(e0_A.z, 11); - - e0_B.x = SIGN_EXTEND(e0_B.x, 9); - e0_B.y = SIGN_EXTEND(e0_B.y, 9); - e0_B.z = SIGN_EXTEND(e0_B.z, 9); - } - - wprintf(L"\tMode 12 - [11 9]\n"); - wprintf(L"\t E(A): (%04X, %04X, %04X)\n", e0_A.x & 0xFFFF, e0_A.y & 0xFFFF, e0_A.z & 0xFFFF); - wprintf(L"\t E(B): (%04X, %04X, %04X)\n", e0_B.x & 0xFFFF, e0_B.y & 0xFFFF, e0_B.z & 0xFFFF); - wprintf(L"\t Index: "); - PrintIndex4bpp(m->indices, 0, 0); - wprintf(L"\n"); - } - break; - - case 0x0B: - // Mode 13 (5 bits, 01011) - { - struct bc6h_mode13 - { - uint64_t mode : 5; // { M, 0}, { M, 1}, { M, 2}, { M, 3}, { M, 4} - uint64_t rw : 10; // {RW, 0}, {RW, 1}, {RW, 2}, {RW, 3}, {RW, 4}, {RW, 5}, {RW, 6}, {RW, 7}, {RW, 8}, {RW, 9} - uint64_t gw : 10; // {GW, 0}, {GW, 1}, {GW, 2}, {GW, 3}, {GW, 4}, {GW, 5}, {GW, 6}, {GW, 7}, {GW, 8}, {GW, 9} - uint64_t bw : 10; // {BW, 0}, {BW, 1}, {BW, 2}, {BW, 3}, {BW, 4}, {BW, 5}, {BW, 6}, {BW, 7}, {BW, 8}, {BW, 9} - uint64_t rx : 8; // {RX, 0}, {RX, 1}, {RX, 2}, {RX, 3}, {RX, 4}, {RX, 5}, {RX, 6}, {RX, 7} - uint64_t rw11 : 1; // {RW,11} - uint64_t rw10 : 1; // {RW,10} - uint64_t gx : 8; // {GX, 0}, {GX, 1}, {GX, 2}, {GX, 3}, {GX, 4}, {GX, 5}, {GX, 6}, {GX, 7} - uint64_t gw11 : 1; // {GW,11} - uint64_t gw10 : 1; // {GW,10} - uint64_t bx : 8; // {BX, 0}, {BX, 1}, {BX, 2}, {BX, 3}, {BX, 4}, {BX, 5}, {BX, 6}, {BX, 7} - uint64_t bw11 : 1; // {BW,11} - uint64_t bw10 : 1; // {BW,10} - uint64_t indices : 63; - }; - static_assert(sizeof(bc6h_mode13) == 16, "Block size must be 16 bytes"); - - const bool bSigned = (image.format == DXGI_FORMAT_BC6H_SF16) ? true : false; - - auto m = reinterpret_cast(sptr); - - XMINT3 e0_A(int(m->rw | (m->rw10 << 10) | (m->rw11 << 11)), - int(m->gw | (m->gw10 << 10) | (m->gw11 << 11)), - int(m->bw | (m->bw10 << 10) | (m->bw11 << 11))); - XMINT3 e0_B(int(m->rx), int(m->gx), int(m->bx)); - - if (bSigned) - { - e0_A.x = SIGN_EXTEND(e0_A.x, 12); - e0_A.y = SIGN_EXTEND(e0_A.y, 12); - e0_A.z = SIGN_EXTEND(e0_A.z, 12); - - e0_B.x = SIGN_EXTEND(e0_B.x, 8); - e0_B.y = SIGN_EXTEND(e0_B.y, 8); - e0_B.z = SIGN_EXTEND(e0_B.z, 8); - } - - wprintf(L"\tMode 13 - [12 8]\n"); - wprintf(L"\t E(A): (%04X, %04X, %04X)\n", e0_A.x & 0xFFFF, e0_A.y & 0xFFFF, e0_A.z & 0xFFFF); - wprintf(L"\t E(B): (%04X, %04X, %04X)\n", e0_B.x & 0xFFFF, e0_B.y & 0xFFFF, e0_B.z & 0xFFFF); - wprintf(L"\t Index: "); - PrintIndex4bpp(m->indices, 0, 0); - wprintf(L"\n"); - } - break; - - case 0x0F: - // Mode 14 (5 bits, 01111) - { - struct bc6h_mode14 - { - uint64_t mode : 5; // { M, 0}, { M, 1}, { M, 2}, { M, 3}, { M, 4} - uint64_t rw : 10; // {RW, 0}, {RW, 1}, {RW, 2}, {RW, 3}, {RW, 4}, {RW, 5}, {RW, 6}, {RW, 7}, {RW, 8}, {RW, 9} - uint64_t gw : 10; // {GW, 0}, {GW, 1}, {GW, 2}, {GW, 3}, {GW, 4}, {GW, 5}, {GW, 6}, {GW, 7}, {GW, 8}, {GW, 9} - uint64_t bw : 10; // {BW, 0}, {BW, 1}, {BW, 2}, {BW, 3}, {BW, 4}, {BW, 5}, {BW, 6}, {BW, 7}, {BW, 8}, {BW, 9} - uint64_t rx : 4; // {RX, 0}, {RX, 1}, {RX, 2}, {RX, 3} - uint64_t rw15 : 1; // {RW,15} - uint64_t rw14 : 1; // {RW,14} - uint64_t rw13 : 1; // {RW,13} - uint64_t rw12 : 1; // {RW,12} - uint64_t rw11 : 1; // {RW,11} - uint64_t rw10 : 1; // {RW,10} - uint64_t gx : 4; // {GX, 0}, {GX, 1}, {GX, 2}, {GX, 3} - uint64_t gw15 : 1; // {GW,15} - uint64_t gw14 : 1; // {GW,14} - uint64_t gw13 : 1; // {GW,13} - uint64_t gw12 : 1; // {GW,12} - uint64_t gw11 : 1; // {GW,11} - uint64_t gw10 : 1; // {GW,10} - uint64_t bx : 4; // {BX, 0}, {BX, 1}, {BX, 2}, {BX, 3} - uint64_t bw15 : 1; // {BW,15} - uint64_t bw14 : 1; // {BW,14} - uint64_t bw13 : 1; // {BW,13} - uint64_t bw12 : 1; // {BW,12} - uint64_t bw11 : 1; // {BW,11} - uint64_t bw10 : 1; // {BW,10} - uint64_t indices : 63; - }; - static_assert(sizeof(bc6h_mode14) == 16, "Block size must be 16 bytes"); - - const bool bSigned = (image.format == DXGI_FORMAT_BC6H_SF16) ? true : false; - - auto m = reinterpret_cast(sptr); - - XMINT3 e0_A(int(m->rw | (m->rw10 << 10) | (m->rw11 << 11) | (m->rw12 << 12) | (m->rw13 << 13) | (m->rw14 << 14) | (m->rw15 << 15)), - int(m->gw | (m->gw10 << 10) | (m->gw11 << 11) | (m->gw12 << 12) | (m->gw13 << 13) | (m->gw14 << 14) | (m->gw15 << 15)), - int(m->bw | (m->bw10 << 10) | (m->bw11 << 11) | (m->bw12 << 12) | (m->bw13 << 13) | (m->bw14 << 14) | (m->bw15 << 15))); - XMINT3 e0_B(int(m->rx), int(m->gx), int(m->bx)); - - if (bSigned) - { - e0_A.x = SIGN_EXTEND(e0_A.x, 16); - e0_A.y = SIGN_EXTEND(e0_A.y, 16); - e0_A.z = SIGN_EXTEND(e0_A.z, 16); - - e0_B.x = SIGN_EXTEND(e0_B.x, 4); - e0_B.y = SIGN_EXTEND(e0_B.y, 4); - e0_B.z = SIGN_EXTEND(e0_B.z, 4); - } - - wprintf(L"\tMode 14 - [16 4]\n"); - wprintf(L"\t E(A): (%04X, %04X, %04X)\n", e0_A.x & 0xFFFF, e0_A.y & 0xFFFF, e0_A.z & 0xFFFF); - wprintf(L"\t E(B): (%04X, %04X, %04X)\n", e0_B.x & 0xFFFF, e0_B.y & 0xFFFF, e0_B.z & 0xFFFF); - wprintf(L"\t Index: "); - PrintIndex4bpp(m->indices, 0, 0); - wprintf(L"\n"); - } - break; - - case 0x13: // Reserved mode (5 bits, 10011) - wprintf(L"\tERROR - Reserved mode 10011\n"); - break; - - case 0x17: // Reserved mode (5 bits, 10111) - wprintf(L"\tERROR - Reserved mode 10011\n"); - break; - - case 0x1B: // Reserved mode (5 bits, 11011) - wprintf(L"\tERROR - Reserved mode 11011\n"); - break; - - case 0x1F: // Reserved mode (5 bits, 11111) - wprintf(L"\tERROR - Reserved mode 11111\n"); - break; - - default: - break; - } - break; - } - break; - - case DXGI_FORMAT_BC7_UNORM: - case DXGI_FORMAT_BC7_UNORM_SRGB: - // http://msdn.microsoft.com/en-us/library/windows/desktop/hh308954.aspx - - if (*sptr & 0x01) - { - // Mode 0 (1) - struct bc7_mode0 - { - uint64_t mode : 1; - uint64_t part : 4; - uint64_t r0 : 4; - uint64_t r1 : 4; - uint64_t r2 : 4; - uint64_t r3 : 4; - uint64_t r4 : 4; - uint64_t r5 : 4; - uint64_t g0 : 4; - uint64_t g1 : 4; - uint64_t g2 : 4; - uint64_t g3 : 4; - uint64_t g4 : 4; - uint64_t g5 : 4; - uint64_t b0 : 4; - uint64_t b1 : 4; - uint64_t b2 : 3; - uint64_t b2n : 1; - uint64_t b3 : 4; - uint64_t b4 : 4; - uint64_t b5 : 4; - uint64_t P0 : 1; - uint64_t P1 : 1; - uint64_t P2 : 1; - uint64_t P3 : 1; - uint64_t P4 : 1; - uint64_t P5 : 1; - uint64_t index : 45; - }; - static_assert(sizeof(bc7_mode0) == 16, "Block size must be 16 bytes"); - - auto m = reinterpret_cast(sptr); - - wprintf(L"\tMode 0 - [4 4 4] partition %llu\n", m->part); - wprintf(L"\t E0:(%0.3f, %0.3f, %0.3f)\n", float((m->r0 << 1) | m->P0) / 31.f, float((m->g0 << 1) | m->P0) / 31.f, float((m->b0 << 1) | m->P0) / 31.f); - wprintf(L"\t E1:(%0.3f, %0.3f, %0.3f)\n", float((m->r1 << 1) | m->P1) / 31.f, float((m->g1 << 1) | m->P1) / 31.f, float((m->b1 << 1) | m->P1) / 31.f); - wprintf(L"\t E2:(%0.3f, %0.3f, %0.3f)\n", float((m->r2 << 1) | m->P2) / 31.f, float((m->g2 << 1) | m->P2) / 31.f, float(((m->b2 | (m->b2n << 3)) << 1) | m->P2) / 31.f); - wprintf(L"\t E3:(%0.3f, %0.3f, %0.3f)\n", float((m->r3 << 1) | m->P3) / 31.f, float((m->g3 << 1) | m->P3) / 31.f, float((m->b3 << 1) | m->P3) / 31.f); - wprintf(L"\t E4:(%0.3f, %0.3f, %0.3f)\n", float((m->r4 << 1) | m->P4) / 31.f, float((m->g4 << 1) | m->P4) / 31.f, float((m->b4 << 1) | m->P4) / 31.f); - wprintf(L"\t E5:(%0.3f, %0.3f, %0.3f)\n", float((m->r5 << 1) | m->P5) / 31.f, float((m->g5 << 1) | m->P5) / 31.f, float((m->b5 << 1) | m->P5) / 31.f); - wprintf(L"\t Index: "); - PrintIndex2bpp(m->index, 2, m->part); - wprintf(L"\n"); - } - else if (*sptr & 0x02) - { - // Mode 1 (01) - struct bc7_mode1 - { - uint64_t mode : 2; - uint64_t part : 6; - uint64_t r0 : 6; - uint64_t r1 : 6; - uint64_t r2 : 6; - uint64_t r3 : 6; - uint64_t g0 : 6; - uint64_t g1 : 6; - uint64_t g2 : 6; - uint64_t g3 : 6; - uint64_t b0 : 6; - uint64_t b1 : 2; - uint64_t b1n : 4; - uint64_t b2 : 6; - uint64_t b3 : 6; - uint64_t P0 : 1; - uint64_t P1 : 1; - uint64_t index : 46; - }; - static_assert(sizeof(bc7_mode1) == 16, "Block size must be 16 bytes"); - - auto m = reinterpret_cast(sptr); - - wprintf(L"\tMode 1 - [6 6 6] partition %llu\n", m->part); - wprintf(L"\t E0:(%0.3f, %0.3f, %0.3f)\n", float((m->r0 << 1) | m->P0) / 127.f, float((m->g0 << 1) | m->P0) / 127.f, float((m->b0 << 1) | m->P0) / 127.f); - wprintf(L"\t E1:(%0.3f, %0.3f, %0.3f)\n", float((m->r1 << 1) | m->P0) / 127.f, float((m->g1 << 1) | m->P0) / 127.f, float(((m->b1 | (m->b1n << 2)) << 1) | m->P0) / 127.f); - wprintf(L"\t E2:(%0.3f, %0.3f, %0.3f)\n", float((m->r2 << 1) | m->P1) / 127.f, float((m->g2 << 1) | m->P1) / 127.f, float((m->b2 << 1) | m->P1) / 127.f); - wprintf(L"\t E3:(%0.3f, %0.3f, %0.3f)\n", float((m->r3 << 1) | m->P1) / 127.f, float((m->g3 << 1) | m->P1) / 127.f, float((m->b3 << 1) | m->P1) / 127.f); - wprintf(L"\t Index: "); - PrintIndex3bpp(m->index, 1, m->part); - wprintf(L"\n"); - } - else if (*sptr & 0x04) - { - // Mode 2 (001) - struct bc7_mode2 - { - uint64_t mode : 3; - uint64_t part : 6; - uint64_t r0 : 5; - uint64_t r1 : 5; - uint64_t r2 : 5; - uint64_t r3 : 5; - uint64_t r4 : 5; - uint64_t r5 : 5; - uint64_t g0 : 5; - uint64_t g1 : 5; - uint64_t g2 : 5; - uint64_t g3 : 5; - uint64_t g4 : 5; - uint64_t g5 : 5; - uint64_t b0 : 5; - uint64_t b1 : 5; - uint64_t b2 : 5; - uint64_t b3 : 5; - uint64_t b4 : 5; - uint64_t b5 : 5; - uint64_t index : 29; - }; - static_assert(sizeof(bc7_mode2) == 16, "Block size must be 16 bytes"); - - auto m = reinterpret_cast(sptr); - - wprintf(L"\tMode 2 - [5 5 5] partition %llu\n", m->part); - wprintf(L"\t E0:(%0.3f, %0.3f, %0.3f)\n", float(m->r0) / 31.f, float(m->g0) / 31.f, float(m->b0) / 31.f); - wprintf(L"\t E1:(%0.3f, %0.3f, %0.3f)\n", float(m->r1) / 31.f, float(m->g1) / 31.f, float(m->b1) / 31.f); - wprintf(L"\t E2:(%0.3f, %0.3f, %0.3f)\n", float(m->r2) / 31.f, float(m->g2) / 31.f, float(m->b2) / 31.f); - wprintf(L"\t E3:(%0.3f, %0.3f, %0.3f)\n", float(m->r3) / 31.f, float(m->g3) / 31.f, float(m->b3) / 31.f); - wprintf(L"\t E4:(%0.3f, %0.3f, %0.3f)\n", float(m->r4) / 31.f, float(m->g4) / 31.f, float(m->b4) / 31.f); - wprintf(L"\t E5:(%0.3f, %0.3f, %0.3f)\n", float(m->r5) / 31.f, float(m->g5) / 31.f, float(m->b5) / 31.f); - wprintf(L"\t Index: "); - PrintIndex2bpp(m->index, 2, m->part); - wprintf(L"\n"); - } - else if (*sptr & 0x08) - { - // Mode 3 (0001) - struct bc7_mode3 - { - uint64_t mode : 4; - uint64_t part : 6; - uint64_t r0 : 7; - uint64_t r1 : 7; - uint64_t r2 : 7; - uint64_t r3 : 7; - uint64_t g0 : 7; - uint64_t g1 : 7; - uint64_t g2 : 7; - uint64_t g3 : 5; - uint64_t g3n : 2; - uint64_t b0 : 7; - uint64_t b1 : 7; - uint64_t b2 : 7; - uint64_t b3 : 7; - uint64_t P0 : 1; - uint64_t P1 : 1; - uint64_t P2 : 1; - uint64_t P3 : 1; - uint64_t index : 30; - }; - static_assert(sizeof(bc7_mode3) == 16, "Block size must be 16 bytes"); - - auto m = reinterpret_cast(sptr); - - wprintf(L"\tMode 3 - [7 7 7] partition %llu\n", m->part); - wprintf(L"\t E0:(%0.3f, %0.3f, %0.3f)\n", float((m->r0 << 1) | m->P0) / 255.f, float((m->g0 << 1) | m->P0) / 255.f, float((m->b0 << 1) | m->P0) / 255.f); - wprintf(L"\t E1:(%0.3f, %0.3f, %0.3f)\n", float((m->r1 << 1) | m->P1) / 255.f, float((m->g1 << 1) | m->P1) / 255.f, float((m->b1 << 1) | m->P1) / 255.f); - wprintf(L"\t E2:(%0.3f, %0.3f, %0.3f)\n", float((m->r2 << 1) | m->P2) / 255.f, float((m->g2 << 1) | m->P2) / 255.f, float((m->b2 << 1) | m->P2) / 255.f); - wprintf(L"\t E3:(%0.3f, %0.3f, %0.3f)\n", float((m->r3 << 1) | m->P3) / 255.f, float(((m->g3 | (m->g3n << 5)) << 1) | m->P3) / 255.f, float((m->b3 << 1) | m->P3) / 255.f); - wprintf(L"\t Index: "); - PrintIndex2bpp(m->index, 1, m->part); - wprintf(L"\n"); - } - else if (*sptr & 0x10) - { - // Mode 4 (00001) - struct bc7_mode4 - { - uint64_t mode : 5; - uint64_t rot : 2; - uint64_t idx : 1; - uint64_t r0 : 5; - uint64_t r1 : 5; - uint64_t g0 : 5; - uint64_t g1 : 5; - uint64_t b0 : 5; - uint64_t b1 : 5; - uint64_t a0 : 6; - uint64_t a1 : 6; - uint64_t color_index : 14; - uint64_t color_indexn : 17; - uint64_t alpha_index : 47; - }; - static_assert(sizeof(bc7_mode4) == 16, "Block size must be 16 bytes"); - - auto m = reinterpret_cast(sptr); - - wprintf(L"\tMode 4 - [5 5 5 A6] indx mode %ls, rot-bits %llu%ls\n", m->idx ? L"3-bit" : L"2-bit", m->rot, GetRotBits(m->rot)); - wprintf(L"\t C0:(%0.3f, %0.3f, %0.3f)\n", float(m->r0) / 31.f, float(m->g0) / 31.f, float(m->b0) / 31.f); - wprintf(L"\t C1:(%0.3f, %0.3f, %0.3f)\n", float(m->r1) / 31.f, float(m->g1) / 31.f, float(m->b1) / 31.f); - wprintf(L"\t A0:(%0.3f)\n", float(m->a0) / 63.f); - wprintf(L"\t A1:(%0.3f)\n", float(m->a1) / 63.f); - wprintf(L"\t Colors: "); - - const uint64_t color_index = uint64_t(m->color_index) | uint64_t(m->color_indexn << 14); - if (m->idx) - PrintIndex3bpp(color_index, 0, 0); - else - PrintIndex2bpp(color_index, 0, 0); - wprintf(L"\n"); - wprintf(L"\t Alpha: "); - PrintIndex3bpp(m->alpha_index, 0, 0); - wprintf(L"\n"); - } - else if (*sptr & 0x20) - { - // Mode 5 (000001) - struct bc7_mode5 - { - uint64_t mode : 6; - uint64_t rot : 2; - uint64_t r0 : 7; - uint64_t r1 : 7; - uint64_t g0 : 7; - uint64_t g1 : 7; - uint64_t b0 : 7; - uint64_t b1 : 7; - uint64_t a0 : 8; - uint64_t a1 : 6; - uint64_t a1n : 2; - uint64_t color_index : 31; - uint64_t alpha_index : 31; - }; - static_assert(sizeof(bc7_mode5) == 16, "Block size must be 16 bytes"); - - auto m = reinterpret_cast(sptr); - - wprintf(L"\tMode 5 - [7 7 7 A8] rot-bits %llu%ls\n", m->rot, GetRotBits(m->rot)); - wprintf(L"\t C0:(%0.3f, %0.3f, %0.3f)\n", float(m->r0) / 127.f, float(m->g0) / 127.f, float(m->b0) / 127.f); - wprintf(L"\t C1:(%0.3f, %0.3f, %0.3f)\n", float(m->r1) / 127.f, float(m->g1) / 127.f, float(m->b1) / 127.f); - wprintf(L"\t A0:(%0.3f)\n", float(m->a0) / 255.f); - wprintf(L"\t A1:(%0.3f)\n", float(m->a1 | (m->a1n << 6)) / 255.f); - wprintf(L"\t Colors: "); - PrintIndex2bpp(m->color_index, 0, 0); - wprintf(L"\n"); - wprintf(L"\t Alpha: "); - PrintIndex2bpp(m->alpha_index, 0, 0); - wprintf(L"\n"); - } - else if (*sptr & 0x40) - { - // Mode 6 (0000001) - struct bc7_mode6 - { - uint64_t mode : 7; - uint64_t r0 : 7; - uint64_t r1 : 7; - uint64_t g0 : 7; - uint64_t g1 : 7; - uint64_t b0 : 7; - uint64_t b1 : 7; - uint64_t a0 : 7; - uint64_t a1 : 7; - uint64_t P0 : 1; - uint64_t P1 : 1; - uint64_t index : 63; - - }; - static_assert(sizeof(bc7_mode6) == 16, "Block size must be 16 bytes"); - - auto m = reinterpret_cast(sptr); - - wprintf(L"\tMode 6 - [7 7 7 A7]\n"); - wprintf(L"\t C0:(%0.3f, %0.3f, %0.3f)\n", float((m->r0 << 1) | m->P0) / 255.f, float((m->g0 << 1) | m->P0) / 255.f, float((m->b0 << 1) | m->P0) / 255.f); - wprintf(L"\t C1:(%0.3f, %0.3f, %0.3f)\n", float((m->r1 << 1) | m->P1) / 255.f, float((m->g1 << 1) | m->P1) / 255.f, float((m->b1 << 1) | m->P1) / 255.f); - wprintf(L"\t A0:(%0.3f)\n", float((m->a0 << 1) | m->P0) / 255.f); - wprintf(L"\t A1:(%0.3f)\n", float((m->a1 << 1) | m->P1) / 255.f); - wprintf(L"\t Index: "); - PrintIndex4bpp(m->index, 0, 0); - wprintf(L"\n"); - } - else if (*sptr & 0x80) - { - // Mode 7 (00000001) - struct bc7_mode7 - { - uint64_t mode : 8; - uint64_t part : 6; - uint64_t r0 : 5; - uint64_t r1 : 5; - uint64_t r2 : 5; - uint64_t r3 : 5; - uint64_t g0 : 5; - uint64_t g1 : 5; - uint64_t g2 : 5; - uint64_t g3 : 5; - uint64_t b0 : 5; - uint64_t b1 : 5; - uint64_t b2 : 5; - uint64_t b3 : 5; - uint64_t a0 : 5; - uint64_t a1 : 5; - uint64_t a2 : 5; - uint64_t a3 : 5; - uint64_t P0 : 1; - uint64_t P1 : 1; - uint64_t P2 : 1; - uint64_t P3 : 1; - uint64_t index : 30; - - }; - static_assert(sizeof(bc7_mode7) == 16, "Block size must be 16 bytes"); - - auto m = reinterpret_cast(sptr); - - wprintf(L"\tMode 7 - [5 5 5 A5] partition %llu\n", m->part); - wprintf(L"\t C0:(%0.3f, %0.3f, %0.3f)\n", float((m->r0 << 1) | m->P0) / 63.f, float((m->g0 << 1) | m->P0) / 63.f, float((m->b0 << 1) | m->P0) / 63.f); - wprintf(L"\t C1:(%0.3f, %0.3f, %0.3f)\n", float((m->r1 << 1) | m->P1) / 63.f, float((m->g1 << 1) | m->P1) / 63.f, float((m->b1 << 1) | m->P1) / 63.f); - wprintf(L"\t C2:(%0.3f, %0.3f, %0.3f)\n", float((m->r2 << 1) | m->P2) / 63.f, float((m->g2 << 1) | m->P2) / 63.f, float((m->b2 << 1) | m->P2) / 63.f); - wprintf(L"\t C3:(%0.3f, %0.3f, %0.3f)\n", float((m->r3 << 1) | m->P3) / 63.f, float((m->g3 << 1) | m->P3) / 63.f, float((m->b3 << 1) | m->P3) / 63.f); - wprintf(L"\t A0:(%0.3f)\n", float((m->a0 << 1) | m->P0) / 63.f); - wprintf(L"\t A1:(%0.3f)\n", float((m->a1 << 1) | m->P1) / 63.f); - wprintf(L"\t A2:(%0.3f)\n", float((m->a2 << 1) | m->P2) / 63.f); - wprintf(L"\t A3:(%0.3f)\n", float((m->a3 << 1) | m->P3) / 63.f); - wprintf(L"\t Index: "); - PrintIndex4bpp(m->index, 1, m->part); - wprintf(L"\n"); - } - else - { - // Reserved mode 8 (00000000) - wprintf(L"\tERROR - Reserved mode 8\n"); - } - break; - } - } - } - - return S_OK; - } -#pragma endregion -} - - -//-------------------------------------------------------------------------------------- -// Entry-point -//-------------------------------------------------------------------------------------- -#ifdef _PREFAST_ -#pragma prefast(disable : 28198, "Command-line tool, frees all memory on exit") -#endif - -int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[]) -{ - // Parameters and defaults - TEX_FILTER_FLAGS dwFilter = TEX_FILTER_DEFAULT; - int pixelx = -1; - int pixely = -1; - uint32_t diffColor = 0; - float threshold = 0.25f; - DXGI_FORMAT diffFormat = DXGI_FORMAT_B8G8R8A8_UNORM; - uint32_t fileType = WIC_CODEC_BMP; - wchar_t szOutputFile[MAX_PATH] = {}; - - // Set locale for output since GetErrorDesc can get localized strings. - std::locale::global(std::locale("")); - - // Initialize COM (needed for WIC) - HRESULT hr = hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED); - if (FAILED(hr)) - { - wprintf(L"Failed to initialize COM (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - // Process command line - if (argc < 2) - { - PrintUsage(); - return 0; - } - - const uint32_t dwCommand = LookupByName(argv[1], g_pCommands); - switch (dwCommand) - { - case CMD_INFO: - case CMD_ANALYZE: - case CMD_COMPARE: - case CMD_DIFF: - case CMD_DUMPBC: - case CMD_DUMPDDS: - break; - - default: - wprintf(L"Must use one of: info, analyze, compare, diff, dumpbc, or dumpdds\n\n"); - return 1; - } - - uint32_t dwOptions = 0; - std::list conversion; - - for (int iArg = 2; iArg < argc; iArg++) - { - PWSTR pArg = argv[iArg]; - - if (('-' == pArg[0]) || ('/' == pArg[0])) - { - pArg++; - PWSTR pValue; - - for (pValue = pArg; *pValue && (':' != *pValue); pValue++); - - if (*pValue) - *pValue++ = 0; - - const uint32_t dwOption = LookupByName(pArg, g_pOptions); - - if (!dwOption || (dwOptions & (1 << dwOption))) - { - PrintUsage(); - return 1; - } - - dwOptions |= 1 << dwOption; - - // Handle options with additional value parameter - switch (dwOption) - { - case OPT_FILTER: - case OPT_FORMAT: - case OPT_FILETYPE: - case OPT_OUTPUTFILE: - case OPT_TARGET_PIXELX: - case OPT_TARGET_PIXELY: - case OPT_DIFF_COLOR: - case OPT_THRESHOLD: - case OPT_FILELIST: - if (!*pValue) - { - if ((iArg + 1 >= argc)) - { - PrintUsage(); - return 1; - } - - iArg++; - pValue = argv[iArg]; - } - break; - - default: - break; - } - - switch (dwOption) - { - case OPT_FORMAT: - if (dwCommand != CMD_DIFF) - { - wprintf(L"-f only valid for use with diff command\n"); - return 1; - } - else - { - diffFormat = static_cast(LookupByName(pValue, g_pFormats)); - if (!diffFormat) - { - diffFormat = static_cast(LookupByName(pValue, g_pFormatAliases)); - if (!diffFormat) - { - wprintf(L"Invalid value specified with -f (%ls)\n", pValue); - return 1; - } - } - } - break; - - case OPT_FILTER: - dwFilter = static_cast(LookupByName(pValue, g_pFilters)); - if (!dwFilter) - { - wprintf(L"Invalid value specified with -if (%ls)\n", pValue); - return 1; - } - break; - - case OPT_OUTPUTFILE: - if (dwCommand != CMD_DIFF) - { - wprintf(L"-o only valid for use with diff command\n"); - return 1; - } - else - { - wcscpy_s(szOutputFile, MAX_PATH, pValue); - - wchar_t ext[_MAX_EXT] = {}; - _wsplitpath_s(szOutputFile, nullptr, 0, nullptr, 0, nullptr, 0, ext, _MAX_EXT); - - fileType = LookupByName(ext, g_pExtFileTypes); - } - break; - - case OPT_FILETYPE: - if (dwCommand != CMD_DUMPDDS) - { - wprintf(L"-ft only valid for use with dumpdds command\n"); - return 1; - } - else - { - fileType = LookupByName(pValue, g_pDumpFileTypes); - if (!fileType) - { - wprintf(L"Invalid value specified with -ft (%ls)\n", pValue); - wprintf(L"\n"); - PrintUsage(); - return 1; - } - } - break; - - case OPT_TARGET_PIXELX: - if (dwCommand != CMD_DUMPBC) - { - wprintf(L"-targetx only valid with dumpbc command\n"); - return 1; - } - else if (swscanf_s(pValue, L"%d", &pixelx) != 1) - { - wprintf(L"Invalid value for pixel x location (%ls)\n", pValue); - return 1; - } - break; - - case OPT_TARGET_PIXELY: - if (dwCommand != CMD_DUMPBC) - { - wprintf(L"-targety only valid with dumpbc command\n"); - return 1; - } - else if (swscanf_s(pValue, L"%d", &pixely) != 1) - { - wprintf(L"Invalid value for pixel y location (%ls)\n", pValue); - return 1; - } - break; - - case OPT_DIFF_COLOR: - if (swscanf_s(pValue, L"%x", &diffColor) != 1) - { - printf("Invalid value specified with -c (%ls)\n", pValue); - printf("\n"); - PrintUsage(); - return 1; - } - diffColor &= 0xFFFFFF; - break; - - case OPT_THRESHOLD: - if (swscanf_s(pValue, L"%f", &threshold) != 1) - { - printf("Invalid value specified with -t (%ls)\n", pValue); - printf("\n"); - PrintUsage(); - return 1; - } - break; - - case OPT_FILELIST: - { - std::wifstream inFile(pValue); - if (!inFile) - { - wprintf(L"Error opening -flist file %ls\n", pValue); - return 1; - } - - inFile.imbue(std::locale::classic()); - - ProcessFileList(inFile, conversion); - } - break; - - default: - break; - } - } - else if (wcspbrk(pArg, L"?*") != nullptr) - { - const size_t count = conversion.size(); - SearchForFiles(pArg, conversion, (dwOptions & (1 << OPT_RECURSIVE)) != 0); - if (conversion.size() <= count) - { - wprintf(L"No matching files found for %ls\n", pArg); - return 1; - } - } - else - { - SConversion conv = {}; - wcscpy_s(conv.szSrc, MAX_PATH, pArg); - - conversion.push_back(conv); - } - } - - if (conversion.empty()) - { - PrintUsage(); - return 0; - } - - if (~dwOptions & (1 << OPT_NOLOGO)) - PrintLogo(); - - switch (dwCommand) - { - case CMD_COMPARE: - case CMD_DIFF: - // --- Compare/Diff ------------------------------------------------------------ - if (conversion.size() != 2) - { - wprintf(L"ERROR: compare/diff needs exactly two images\n"); - return 1; - } - else - { - auto pImage1 = conversion.cbegin(); - - wprintf(L"1: %ls", pImage1->szSrc); - fflush(stdout); - - TexMetadata info1; - std::unique_ptr image1; - hr = LoadImage(pImage1->szSrc, dwOptions, dwFilter, info1, image1); - if (FAILED(hr)) - { - wprintf(L" FAILED (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - auto pImage2 = conversion.cbegin(); - std::advance(pImage2, 1); - - wprintf(L"\n2: %ls", pImage2->szSrc); - fflush(stdout); - - TexMetadata info2; - std::unique_ptr image2; - hr = LoadImage(pImage2->szSrc, dwOptions, dwFilter, info2, image2); - if (FAILED(hr)) - { - wprintf(L" FAILED (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - wprintf(L"\n"); - fflush(stdout); - - if (info1.height != info2.height - || info1.width != info2.width) - { - wprintf(L"ERROR: Can only compare/diff images of the same width & height\n"); - return 1; - } - - if (dwCommand == CMD_DIFF) - { - if (!*szOutputFile) - { - wchar_t ext[_MAX_EXT] = {}; - wchar_t fname[_MAX_FNAME] = {}; - _wsplitpath_s(pImage1->szSrc, nullptr, 0, nullptr, 0, fname, _MAX_FNAME, ext, _MAX_EXT); - if (_wcsicmp(ext, L".bmp") == 0) - { - wprintf(L"ERROR: Need to specify output file via -o\n"); - return 1; - } - - _wmakepath_s(szOutputFile, nullptr, nullptr, fname, L".bmp"); - } - - if (image1->GetImageCount() > 1 || image2->GetImageCount() > 1) - wprintf(L"WARNING: ignoring all images but first one in each file\n"); - - ScratchImage diffImage; - hr = Difference(*image1->GetImage(0, 0, 0), *image2->GetImage(0, 0, 0), dwFilter, diffFormat, diffColor, threshold, diffImage); - if (FAILED(hr)) - { - wprintf(L"Failed diffing images (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - if (dwOptions & (1 << OPT_TOLOWER)) - { - std::ignore = _wcslwr_s(szOutputFile); - } - - if (~dwOptions & (1 << OPT_OVERWRITE)) - { - if (GetFileAttributesW(szOutputFile) != INVALID_FILE_ATTRIBUTES) - { - wprintf(L"\nERROR: Output file already exists, use -y to overwrite\n"); - return 1; - } - } - - hr = SaveImage(diffImage.GetImage(0, 0, 0), szOutputFile, fileType); - if (FAILED(hr)) - { - wprintf(L" FAILED (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - wprintf(L"Difference %ls\n", szOutputFile); - } - else if ((info1.depth == 1 - && info1.arraySize == 1 - && info1.mipLevels == 1) - || info1.depth != info2.depth - || info1.arraySize != info2.arraySize - || info1.mipLevels != info2.mipLevels - || image1->GetImageCount() != image2->GetImageCount()) - { - // Compare single image - if (image1->GetImageCount() > 1 || image2->GetImageCount() > 1) - wprintf(L"WARNING: ignoring all images but first one in each file\n"); - - float mse, mseV[4]; - hr = ComputeMSE(*image1->GetImage(0, 0, 0), *image2->GetImage(0, 0, 0), mse, mseV); - if (FAILED(hr)) - { - wprintf(L"Failed comparing images (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - wprintf(L"Result: %f (%f %f %f %f) PSNR %f dB\n", mse, mseV[0], mseV[1], mseV[2], mseV[3], - 10.0 * log10(3.0 / (double(mseV[0]) + double(mseV[1]) + double(mseV[2])))); - } - else - { - // Compare all images - float min_mse = FLT_MAX; - float min_mseV[4] = { FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX }; - - float max_mse = -FLT_MAX; - float max_mseV[4] = { -FLT_MAX, -FLT_MAX, -FLT_MAX, -FLT_MAX }; - - double sum_mse = 0; - double sum_mseV[4] = { 0, 0, 0, 0 }; - - size_t total_images = 0; - - if (info1.depth > 1) - { - wprintf(L"Results by mip (%3zu) and slice (%3zu)\n\n", info1.mipLevels, info1.depth); - - size_t depth = info1.depth; - for (size_t mip = 0; mip < info1.mipLevels; ++mip) - { - for (size_t slice = 0; slice < depth; ++slice) - { - const Image* img1 = image1->GetImage(mip, 0, slice); - const Image* img2 = image2->GetImage(mip, 0, slice); - - if (!img1 - || !img2 - || img1->height != img2->height - || img1->width != img2->width) - { - wprintf(L"ERROR: Unexpected mismatch at slice %3zu, mip %3zu\n", slice, mip); - return 1; - } - else - { - float mse, mseV[4]; - hr = ComputeMSE(*img1, *img2, mse, mseV); - if (FAILED(hr)) - { - wprintf(L"Failed comparing images at slice %3zu, mip %3zu (%08X%ls)\n", slice, mip, static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - min_mse = std::min(min_mse, mse); - max_mse = std::max(max_mse, mse); - sum_mse += double(mse); - - for (size_t j = 0; j < 4; ++j) - { - min_mseV[j] = std::min(min_mseV[j], mseV[j]); - max_mseV[j] = std::max(max_mseV[j], mseV[j]); - sum_mseV[j] += double(mseV[j]); - } - - ++total_images; - - wprintf(L"[%3zu,%3zu]: %f (%f %f %f %f) PSNR %f dB\n", mip, slice, mse, mseV[0], mseV[1], mseV[2], mseV[3], - 10.0 * log10(3.0 / (double(mseV[0]) + double(mseV[1]) + double(mseV[2])))); - } - } - - if (depth > 1) - depth >>= 1; - } - } - else - { - wprintf(L"Results by item (%3zu) and mip (%3zu)\n\n", info1.arraySize, info1.mipLevels); - - for (size_t item = 0; item < info1.arraySize; ++item) - { - for (size_t mip = 0; mip < info1.mipLevels; ++mip) - { - const Image* img1 = image1->GetImage(mip, item, 0); - const Image* img2 = image2->GetImage(mip, item, 0); - - if (!img1 - || !img2 - || img1->height != img2->height - || img1->width != img2->width) - { - wprintf(L"ERROR: Unexpected mismatch at item %3zu, mip %3zu\n", item, mip); - return 1; - } - else - { - float mse, mseV[4]; - hr = ComputeMSE(*img1, *img2, mse, mseV); - if (FAILED(hr)) - { - wprintf(L"Failed comparing images at item %3zu, mip %3zu (%08X%ls)\n", item, mip, static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - min_mse = std::min(min_mse, mse); - max_mse = std::max(max_mse, mse); - sum_mse += double(mse); - - for (size_t j = 0; j < 4; ++j) - { - min_mseV[j] = std::min(min_mseV[j], mseV[j]); - max_mseV[j] = std::max(max_mseV[j], mseV[j]); - sum_mseV[j] += double(mseV[j]); - } - - ++total_images; - - wprintf(L"[%3zu,%3zu]: %f (%f %f %f %f) PSNR %f dB\n", item, mip, mse, mseV[0], mseV[1], mseV[2], mseV[3], - 10.0 * log10(3.0 / (double(mseV[0]) + double(mseV[1]) + double(mseV[2])))); - } - } - } - } - - // Output multi-image stats - if (total_images > 1) - { - wprintf(L"\n Minimum MSE: %f (%f %f %f %f) PSNR %f dB\n", min_mse, min_mseV[0], min_mseV[1], min_mseV[2], min_mseV[3], - 10.0 * log10(3.0 / (double(min_mseV[0]) + double(min_mseV[1]) + double(min_mseV[2])))); - const double total_mseV0 = sum_mseV[0] / double(total_images); - const double total_mseV1 = sum_mseV[1] / double(total_images); - const double total_mseV2 = sum_mseV[2] / double(total_images); - wprintf(L" Average MSE: %f (%f %f %f %f) PSNR %f dB\n", sum_mse / double(total_images), - total_mseV0, - total_mseV1, - total_mseV2, - sum_mseV[3] / double(total_images), - 10.0 * log10(3.0 / (total_mseV0 + total_mseV1 + total_mseV2))); - wprintf(L" Maximum MSE: %f (%f %f %f %f) PSNR %f dB\n", max_mse, max_mseV[0], max_mseV[1], max_mseV[2], max_mseV[3], - 10.0 * log10(3.0 / (double(max_mseV[0]) + double(max_mseV[1]) + double(max_mseV[2])))); - } - } - } - break; - - default: - for (auto pConv = conversion.cbegin(); pConv != conversion.cend(); ++pConv) - { - // Load source image - if (pConv != conversion.begin()) - wprintf(L"\n"); - - wprintf(L"%ls", pConv->szSrc); - fflush(stdout); - - TexMetadata info; - std::unique_ptr image; - hr = LoadImage(pConv->szSrc, dwOptions, dwFilter, info, image); - if (FAILED(hr)) - { - wprintf(L" FAILED (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - wprintf(L"\n"); - fflush(stdout); - - if (dwCommand == CMD_INFO) - { - // --- Info ---------------------------------------------------------------- - wprintf(L" width = %zu\n", info.width); - wprintf(L" height = %zu\n", info.height); - wprintf(L" depth = %zu\n", info.depth); - wprintf(L" mipLevels = %zu\n", info.mipLevels); - wprintf(L" arraySize = %zu\n", info.arraySize); - wprintf(L" format = "); - PrintFormat(info.format); - wprintf(L"\n dimension = "); - switch (info.dimension) - { - case TEX_DIMENSION_TEXTURE1D: - wprintf(L"%ls", (info.arraySize > 1) ? L"1DArray\n" : L"1D\n"); - break; - - case TEX_DIMENSION_TEXTURE2D: - if (info.IsCubemap()) - { - wprintf(L"%ls", (info.arraySize > 6) ? L"CubeArray\n" : L"Cube\n"); - } - else - { - wprintf(L"%ls", (info.arraySize > 1) ? L"2DArray\n" : L"2D\n"); - } - break; - - case TEX_DIMENSION_TEXTURE3D: - wprintf(L" 3D"); - break; - } - - wprintf(L" alpha mode = "); - switch (info.GetAlphaMode()) - { - case TEX_ALPHA_MODE_OPAQUE: - wprintf(L"Opaque"); - break; - case TEX_ALPHA_MODE_PREMULTIPLIED: - wprintf(L"Premultiplied"); - break; - case TEX_ALPHA_MODE_STRAIGHT: - wprintf(L"Straight"); - break; - case TEX_ALPHA_MODE_CUSTOM: - wprintf(L"Custom"); - break; - case TEX_ALPHA_MODE_UNKNOWN: - wprintf(L"Unknown"); - break; - } - - wprintf(L"\n images = %zu\n", image->GetImageCount()); - - auto const sizeInKb = static_cast(image->GetPixelsSize() / 1024); - - wprintf(L" pixel size = %u (KB)\n\n", sizeInKb); - } - else if (dwCommand == CMD_DUMPDDS) - { - // --- Dump DDS ------------------------------------------------------------ - if (IsCompressed(info.format)) - { - wprintf(L"ERROR: dumpdds only operates on non-compressed format DDS files\n"); - return 1; - } - - wchar_t ext[_MAX_EXT] = {}; - wchar_t fname[_MAX_FNAME] = {}; - _wsplitpath_s(pConv->szSrc, nullptr, 0, nullptr, 0, fname, _MAX_FNAME, nullptr, 0); - - wcscpy_s(ext, LookupByValue(fileType, g_pDumpFileTypes)); - - if (info.depth > 1) - { - wprintf(L"Writing by mip (%3zu) and slice (%3zu)...", info.mipLevels, info.depth); - - size_t depth = info.depth; - for (size_t mip = 0; mip < info.mipLevels; ++mip) - { - for (size_t slice = 0; slice < depth; ++slice) - { - const Image* img = image->GetImage(mip, 0, slice); - - if (!img) - { - wprintf(L"ERROR: Unexpected error at slice %3zu, mip %3zu\n", slice, mip); - return 1; - } - else - { - wchar_t subFname[_MAX_FNAME] = {}; - if (info.mipLevels > 1) - { - swprintf_s(subFname, L"%ls_slice%03zu_mip%03zu", fname, slice, mip); - } - else - { - swprintf_s(subFname, L"%ls_slice%03zu", fname, slice); - } - - _wmakepath_s(szOutputFile, nullptr, nullptr, subFname, ext); - - hr = SaveImage(img, szOutputFile, fileType); - if (FAILED(hr)) - { - wprintf(L" FAILED (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - } - } - - if (depth > 1) - depth >>= 1; - } - wprintf(L"\n"); - } - else - { - wprintf(L"Writing by item (%3zu) and mip (%3zu)...", info.arraySize, info.mipLevels); - - for (size_t item = 0; item < info.arraySize; ++item) - { - for (size_t mip = 0; mip < info.mipLevels; ++mip) - { - const Image* img = image->GetImage(mip, item, 0); - - if (!img) - { - wprintf(L"ERROR: Unexpected error at item %3zu, mip %3zu\n", item, mip); - return 1; - } - else - { - wchar_t subFname[_MAX_FNAME]; - if (info.mipLevels > 1) - { - swprintf_s(subFname, L"%ls_item%03zu_mip%03zu", fname, item, mip); - } - else - { - swprintf_s(subFname, L"%ls_item%03zu", fname, item); - } - - _wmakepath_s(szOutputFile, nullptr, nullptr, subFname, ext); - - hr = SaveImage(img, szOutputFile, fileType); - if (FAILED(hr)) - { - wprintf(L" FAILED (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - } - } - } - - wprintf(L"\n"); - } - } - else if (dwCommand == CMD_DUMPBC) - { - // --- Dump BC ------------------------------------------------------------- - if (!IsCompressed(info.format)) - { - wprintf(L"ERROR: dumpbc only operates on BC format DDS files\n"); - return 1; - } - - if (pixelx >= int(info.width) - || pixely >= int(info.height)) - { - wprintf(L"WARNING: Specified pixel location (%d x %d) is out of range for image (%zu x %zu)\n", pixelx, pixely, info.width, info.height); - continue; - } - - wprintf(L"Compression: "); - PrintFormat(info.format); - wprintf(L"\n"); - - if (info.depth > 1) - { - wprintf(L"Results by mip (%3zu) and slice (%3zu)\n", info.mipLevels, info.depth); - - size_t depth = info.depth; - for (size_t mip = 0; mip < info.mipLevels; ++mip) - { - for (size_t slice = 0; slice < depth; ++slice) - { - const Image* img = image->GetImage(mip, 0, slice); - - if (!img) - { - wprintf(L"ERROR: Unexpected error at slice %3zu, mip %3zu\n", slice, mip); - return 1; - } - else - { - wprintf(L"\n[%3zu, %3zu]:\n", mip, slice); - - hr = DumpBCImage(*img, pixelx, pixely); - if (FAILED(hr)) - { - wprintf(L"ERROR: Failed dumping image at slice %3zu, mip %3zu (%08X%ls)\n", slice, mip, static_cast(hr), GetErrorDesc(hr)); - return 1; - } - } - } - - if (depth > 1) - depth >>= 1; - - if (pixelx > 0) - pixelx >>= 1; - - if (pixely > 0) - pixely >>= 1; - } - } - else - { - wprintf(L"Results by item (%3zu) and mip (%3zu)\n", info.arraySize, info.mipLevels); - - for (size_t item = 0; item < info.arraySize; ++item) - { - int tpixelx = pixelx; - int tpixely = pixely; - - for (size_t mip = 0; mip < info.mipLevels; ++mip) - { - const Image* img = image->GetImage(mip, item, 0); - - if (!img) - { - wprintf(L"ERROR: Unexpected error at item %3zu, mip %3zu\n", item, mip); - return 1; - } - else - { - if (image->GetImageCount() > 1) - { - wprintf(L"\n[%3zu, %3zu]:\n", item, mip); - } - hr = DumpBCImage(*img, tpixelx, tpixely); - if (FAILED(hr)) - { - wprintf(L"ERROR: Failed dumping image at item %3zu, mip %3zu (%08X%ls)\n", item, mip, static_cast(hr), GetErrorDesc(hr)); - return 1; - } - } - - if (tpixelx > 0) - tpixelx >>= 1; - - if (tpixely > 0) - tpixely >>= 1; - } - } - } - } - else - { - // --- Analyze ------------------------------------------------------------- - if (IsPlanar(info.format)) - { - auto img = image->GetImage(0, 0, 0); - assert(img); - const size_t nimg = image->GetImageCount(); - - std::unique_ptr timage(new (std::nothrow) ScratchImage); - if (!timage) - { - wprintf(L"\nERROR: Memory allocation failed\n"); - return 1; - } - - hr = ConvertToSinglePlane(img, nimg, info, *timage); - if (FAILED(hr)) - { - wprintf(L" FAILED [converttosingleplane] (%08X%ls)\n", static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - auto& tinfo = timage->GetMetadata(); - - info.format = tinfo.format; - - assert(info.width == tinfo.width); - assert(info.height == tinfo.height); - assert(info.depth == tinfo.depth); - assert(info.arraySize == tinfo.arraySize); - assert(info.mipLevels == tinfo.mipLevels); - assert(info.miscFlags == tinfo.miscFlags); - assert(info.dimension == tinfo.dimension); - - image.swap(timage); - } - - if (info.depth > 1) - { - wprintf(L"Results by mip (%3zu) and slice (%3zu)\n\n", info.mipLevels, info.depth); - - size_t depth = info.depth; - for (size_t mip = 0; mip < info.mipLevels; ++mip) - { - for (size_t slice = 0; slice < depth; ++slice) - { - const Image* img = image->GetImage(mip, 0, slice); - - if (!img) - { - wprintf(L"ERROR: Unexpected error at slice %3zu, mip %3zu\n", slice, mip); - return 1; - } - else - { - AnalyzeData data; - hr = Analyze(*img, data); - if (FAILED(hr)) - { - wprintf(L"ERROR: Failed analyzing image at slice %3zu, mip %3zu (%08X%ls)\n", slice, mip, static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - wprintf(L"Result slice %3zu, mip %3zu:\n", slice, mip); - data.Print(); - } - - if (IsCompressed(info.format)) - { - AnalyzeBCData data; - hr = AnalyzeBC(*img, data); - if (FAILED(hr)) - { - wprintf(L"ERROR: Failed analyzing BC image at slice %3zu, mip %3zu (%08X%ls)\n", slice, mip, static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - data.Print(img->format); - } - wprintf(L"\n"); - } - - if (depth > 1) - depth >>= 1; - } - } - else - { - wprintf(L"Results by item (%3zu) and mip (%3zu)\n\n", info.arraySize, info.mipLevels); - - for (size_t item = 0; item < info.arraySize; ++item) - { - for (size_t mip = 0; mip < info.mipLevels; ++mip) - { - const Image* img = image->GetImage(mip, item, 0); - - if (!img) - { - wprintf(L"ERROR: Unexpected error at item %3zu, mip %3zu\n", item, mip); - return 1; - } - else - { - AnalyzeData data; - hr = Analyze(*img, data); - if (FAILED(hr)) - { - wprintf(L"ERROR: Failed analyzing image at item %3zu, mip %3zu (%08X%ls)\n", item, mip, static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - if (image->GetImageCount() > 1) - { - wprintf(L"Result item %3zu, mip %3zu:\n", item, mip); - } - data.Print(); - } - - if (IsCompressed(info.format)) - { - AnalyzeBCData data; - hr = AnalyzeBC(*img, data); - if (FAILED(hr)) - { - wprintf(L"ERROR: Failed analyzing BC image at item %3zu, mip %3zu (%08X%ls)\n", item, mip, static_cast(hr), GetErrorDesc(hr)); - return 1; - } - - data.Print(img->format); - } - wprintf(L"\n"); - } - } - } - } - } - break; - } - - return 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texdiag/texdiag.rc b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texdiag/texdiag.rc deleted file mode 100644 index 81f3784..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texdiag/texdiag.rc +++ /dev/null @@ -1,115 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#define IDC_STATIC -1 -#include - - - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (United States) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_MAIN_ICON ICON "directx.ico" - - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#define IDC_STATIC -1\r\n" - "#include \r\n" - "\r\n" - "\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,0 - PRODUCTVERSION 1,0,0,0 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "CompanyName", "Microsoft Corp" - VALUE "FileDescription", "Texture debugger command-line tool" - VALUE "FileVersion", "1.0.0.0" - VALUE "InternalName", "texdiag.exe" - VALUE "LegalCopyright", "Copyright (c) Microsoft Corp." - VALUE "OriginalFilename", "texdiag.exe" - VALUE "ProductName", "DirectXTex" - VALUE "ProductVersion", "1.0.0.0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // English (United States) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texdiag/texdiag_Desktop_2019.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texdiag/texdiag_Desktop_2019.vcxproj deleted file mode 100644 index 5bcb545..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texdiag/texdiag_Desktop_2019.vcxproj +++ /dev/null @@ -1,291 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Profile - Win32 - - - Profile - x64 - - - Release - Win32 - - - Release - x64 - - - - texdiag - {8E31A619-F4F8-413F-A973-4EE37B1AAA5D} - texdiag - Win32Proj - 10.0 - - - - Application - true - Unicode - v142 - - - Application - true - Unicode - v142 - - - Application - true - Unicode - v142 - - - Application - true - Unicode - v142 - - - Application - true - Unicode - v142 - - - Application - true - Unicode - v142 - - - - - - - - - - - - - - - - - - - - - - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - texdiag - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - texdiag - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - texdiag - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - texdiag - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - texdiag - true - - - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - Bin\Desktop_2019\$(Platform)\$(Configuration)\ - texdiag - true - - - - Level4 - Disabled - MultiThreadedDebugDLL - Fast - StreamingSIMDExtensions2 - ..\DirectXTex;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;DEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - Console - true - true - - - false - - - - - Level4 - Disabled - MultiThreadedDebugDLL - Fast - ..\DirectXTex;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;DEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - Console - true - - - false - - - - - Level4 - MaxSpeed - Fast - StreamingSIMDExtensions2 - ..\DirectXTex;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - Guard - true - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - true - - - false - - - - - Level4 - MaxSpeed - Fast - ..\DirectXTex;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - Guard - true - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - - - false - - - - - Level4 - MaxSpeed - Fast - StreamingSIMDExtensions2 - ..\DirectXTex;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Guard - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - true - - - false - - - - - Level4 - MaxSpeed - Fast - ..\DirectXTex;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - true - /Zc:__cplusplus /ZH:SHA_256 %(AdditionalOptions) - Guard - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - - - false - - - - - - - - - - - {371b9fa9-4c90-4ac6-a123-aced756d6c77} - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texdiag/texdiag_Desktop_2019.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texdiag/texdiag_Desktop_2019.vcxproj.filters deleted file mode 100644 index 3a2f907..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texdiag/texdiag_Desktop_2019.vcxproj.filters +++ /dev/null @@ -1,17 +0,0 @@ - - - - - {8e114980-c1a3-4ada-ad7c-83caadf5daeb} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - - - - - - Resource Files - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texdiag/texdiag_Desktop_2022.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texdiag/texdiag_Desktop_2022.vcxproj deleted file mode 100644 index a618e16..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texdiag/texdiag_Desktop_2022.vcxproj +++ /dev/null @@ -1,297 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Profile - Win32 - - - Profile - x64 - - - Release - Win32 - - - Release - x64 - - - - texdiag - {8E31A619-F4F8-413F-A973-4EE37B1AAA5D} - texdiag - Win32Proj - 10.0 - - - - Application - true - Unicode - v143 - - - Application - true - Unicode - v143 - - - Application - true - Unicode - v143 - - - Application - true - Unicode - v143 - - - Application - true - Unicode - v143 - - - Application - true - Unicode - v143 - - - - - - - - - - - - - - - - - - - - - - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - texdiag - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - texdiag - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - texdiag - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - texdiag - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - texdiag - true - - - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - Bin\Desktop_2022\$(Platform)\$(Configuration)\ - texdiag - true - - - - Level4 - Disabled - MultiThreadedDebugDLL - Fast - StreamingSIMDExtensions2 - ..\DirectXTex;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;DEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - true - /Zc:__cplusplus %(AdditionalOptions) - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - Console - true - true - true - - - false - - - - - Level4 - Disabled - MultiThreadedDebugDLL - Fast - ..\DirectXTex;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;DEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - true - /Zc:__cplusplus %(AdditionalOptions) - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - Console - true - true - - - false - - - - - Level4 - MaxSpeed - Fast - StreamingSIMDExtensions2 - ..\DirectXTex;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - Guard - true - true - /Zc:__cplusplus %(AdditionalOptions) - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - true - true - - - false - - - - - Level4 - MaxSpeed - Fast - ..\DirectXTex;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - Guard - true - true - /Zc:__cplusplus %(AdditionalOptions) - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - true - - - false - - - - - Level4 - MaxSpeed - Fast - StreamingSIMDExtensions2 - ..\DirectXTex;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - true - /Zc:__cplusplus %(AdditionalOptions) - Guard - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - true - true - - - false - - - - - Level4 - MaxSpeed - Fast - ..\DirectXTex;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;PROFILE;_CONSOLE;_WIN32_WINNT=0x0601;%(PreprocessorDefinitions) - true - true - /Zc:__cplusplus %(AdditionalOptions) - Guard - 26812 - - - ole32.lib;windowscodecs.lib;uuid.lib;version.lib;%(AdditionalDependencies) - true - Console - true - true - true - - - false - - - - - - - - - - - {371b9fa9-4c90-4ac6-a123-aced756d6c77} - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texdiag/texdiag_Desktop_2022.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texdiag/texdiag_Desktop_2022.vcxproj.filters deleted file mode 100644 index 3a2f907..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/Texdiag/texdiag_Desktop_2022.vcxproj.filters +++ /dev/null @@ -1,17 +0,0 @@ - - - - - {8e114980-c1a3-4ada-ad7c-83caadf5daeb} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - - - - - - Resource Files - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/WICTextureLoader/WICTextureLoader11.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/WICTextureLoader/WICTextureLoader11.cpp deleted file mode 100644 index ec81ec1..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/WICTextureLoader/WICTextureLoader11.cpp +++ /dev/null @@ -1,1094 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: WICTextureLoader11.cpp -// -// Function for loading a WIC image and creating a Direct3D runtime texture for it -// (auto-generating mipmaps if possible) -// -// Note: Assumes application has already called CoInitializeEx -// -// Warning: CreateWICTexture* functions are not thread-safe if given a d3dContext instance for -// auto-gen mipmap support. -// -// Note these functions are useful for images created as simple 2D textures. For -// more complex resources, DDSTextureLoader is an excellent light-weight runtime loader. -// For a full-featured DDS file reader, writer, and texture processing pipeline see -// the 'Texconv' sample and the 'DirectXTex' library. -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -// http://go.microsoft.com/fwlink/?LinkId=248929 -//-------------------------------------------------------------------------------------- - -// We could load multi-frame images (TIFF/GIF) into a texture array. -// For now, we just load the first frame (note: DirectXTex supports multi-frame images) - -#include "WICTextureLoader11.h" - -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef _MSC_VER -// Off by default warnings -#pragma warning(disable : 4619 4616 4061 4062 4623 4626 5027) -// C4619/4616 #pragma warning warnings -// C4061 enumerator 'x' in switch of enum 'y' is not explicitly handled by a case label -// C4062 enumerator 'x' in switch of enum 'y' is not handled -// C4623 default constructor was implicitly defined as deleted -// C4626 assignment operator was implicitly defined as deleted -// C5027 move assignment operator was implicitly defined as deleted -#endif - -#ifdef __clang__ -#pragma clang diagnostic ignored "-Wcovered-switch-default" -#pragma clang diagnostic ignored "-Wswitch-enum" -#endif - -using namespace DirectX; -using Microsoft::WRL::ComPtr; - -namespace -{ - //-------------------------------------------------------------------------------------- - #if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) ) - template - inline void SetDebugObjectName(_In_ ID3D11DeviceChild* resource, _In_ const char(&name)[TNameLength]) noexcept - { - resource->SetPrivateData(WKPDID_D3DDebugObjectName, TNameLength - 1, name); - } - #else - template - inline void SetDebugObjectName(_In_ ID3D11DeviceChild*, _In_ const char(&)[TNameLength]) noexcept - { - } - #endif - - //------------------------------------------------------------------------------------- - // WIC Pixel Format Translation Data - //------------------------------------------------------------------------------------- - struct WICTranslate - { - const GUID& wic; - DXGI_FORMAT format; - }; - - constexpr WICTranslate g_WICFormats[] = - { - { GUID_WICPixelFormat128bppRGBAFloat, DXGI_FORMAT_R32G32B32A32_FLOAT }, - - { GUID_WICPixelFormat64bppRGBAHalf, DXGI_FORMAT_R16G16B16A16_FLOAT }, - { GUID_WICPixelFormat64bppRGBA, DXGI_FORMAT_R16G16B16A16_UNORM }, - - { GUID_WICPixelFormat32bppRGBA, DXGI_FORMAT_R8G8B8A8_UNORM }, - { GUID_WICPixelFormat32bppBGRA, DXGI_FORMAT_B8G8R8A8_UNORM }, // DXGI 1.1 - { GUID_WICPixelFormat32bppBGR, DXGI_FORMAT_B8G8R8X8_UNORM }, // DXGI 1.1 - - { GUID_WICPixelFormat32bppRGBA1010102XR, DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM }, // DXGI 1.1 - { GUID_WICPixelFormat32bppRGBA1010102, DXGI_FORMAT_R10G10B10A2_UNORM }, - - { GUID_WICPixelFormat16bppBGRA5551, DXGI_FORMAT_B5G5R5A1_UNORM }, - { GUID_WICPixelFormat16bppBGR565, DXGI_FORMAT_B5G6R5_UNORM }, - - { GUID_WICPixelFormat32bppGrayFloat, DXGI_FORMAT_R32_FLOAT }, - { GUID_WICPixelFormat16bppGrayHalf, DXGI_FORMAT_R16_FLOAT }, - { GUID_WICPixelFormat16bppGray, DXGI_FORMAT_R16_UNORM }, - { GUID_WICPixelFormat8bppGray, DXGI_FORMAT_R8_UNORM }, - - { GUID_WICPixelFormat8bppAlpha, DXGI_FORMAT_A8_UNORM }, - }; - - //------------------------------------------------------------------------------------- - // WIC Pixel Format nearest conversion table - //------------------------------------------------------------------------------------- - struct WICConvert - { - const GUID& source; - const GUID& target; - }; - - constexpr WICConvert g_WICConvert[] = - { - // Note target GUID in this conversion table must be one of those directly supported formats (above). - - { GUID_WICPixelFormatBlackWhite, GUID_WICPixelFormat8bppGray }, // DXGI_FORMAT_R8_UNORM - - { GUID_WICPixelFormat1bppIndexed, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM - { GUID_WICPixelFormat2bppIndexed, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM - { GUID_WICPixelFormat4bppIndexed, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM - { GUID_WICPixelFormat8bppIndexed, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM - - { GUID_WICPixelFormat2bppGray, GUID_WICPixelFormat8bppGray }, // DXGI_FORMAT_R8_UNORM - { GUID_WICPixelFormat4bppGray, GUID_WICPixelFormat8bppGray }, // DXGI_FORMAT_R8_UNORM - - { GUID_WICPixelFormat16bppGrayFixedPoint, GUID_WICPixelFormat16bppGrayHalf }, // DXGI_FORMAT_R16_FLOAT - { GUID_WICPixelFormat32bppGrayFixedPoint, GUID_WICPixelFormat32bppGrayFloat }, // DXGI_FORMAT_R32_FLOAT - - { GUID_WICPixelFormat16bppBGR555, GUID_WICPixelFormat16bppBGRA5551 }, // DXGI_FORMAT_B5G5R5A1_UNORM - - { GUID_WICPixelFormat32bppBGR101010, GUID_WICPixelFormat32bppRGBA1010102 }, // DXGI_FORMAT_R10G10B10A2_UNORM - - { GUID_WICPixelFormat24bppBGR, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM - { GUID_WICPixelFormat24bppRGB, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM - { GUID_WICPixelFormat32bppPBGRA, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM - { GUID_WICPixelFormat32bppPRGBA, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM - - { GUID_WICPixelFormat48bppRGB, GUID_WICPixelFormat64bppRGBA }, // DXGI_FORMAT_R16G16B16A16_UNORM - { GUID_WICPixelFormat48bppBGR, GUID_WICPixelFormat64bppRGBA }, // DXGI_FORMAT_R16G16B16A16_UNORM - { GUID_WICPixelFormat64bppBGRA, GUID_WICPixelFormat64bppRGBA }, // DXGI_FORMAT_R16G16B16A16_UNORM - { GUID_WICPixelFormat64bppPRGBA, GUID_WICPixelFormat64bppRGBA }, // DXGI_FORMAT_R16G16B16A16_UNORM - { GUID_WICPixelFormat64bppPBGRA, GUID_WICPixelFormat64bppRGBA }, // DXGI_FORMAT_R16G16B16A16_UNORM - - { GUID_WICPixelFormat48bppRGBFixedPoint, GUID_WICPixelFormat64bppRGBAHalf }, // DXGI_FORMAT_R16G16B16A16_FLOAT - { GUID_WICPixelFormat48bppBGRFixedPoint, GUID_WICPixelFormat64bppRGBAHalf }, // DXGI_FORMAT_R16G16B16A16_FLOAT - { GUID_WICPixelFormat64bppRGBAFixedPoint, GUID_WICPixelFormat64bppRGBAHalf }, // DXGI_FORMAT_R16G16B16A16_FLOAT - { GUID_WICPixelFormat64bppBGRAFixedPoint, GUID_WICPixelFormat64bppRGBAHalf }, // DXGI_FORMAT_R16G16B16A16_FLOAT - { GUID_WICPixelFormat64bppRGBFixedPoint, GUID_WICPixelFormat64bppRGBAHalf }, // DXGI_FORMAT_R16G16B16A16_FLOAT - { GUID_WICPixelFormat64bppRGBHalf, GUID_WICPixelFormat64bppRGBAHalf }, // DXGI_FORMAT_R16G16B16A16_FLOAT - { GUID_WICPixelFormat48bppRGBHalf, GUID_WICPixelFormat64bppRGBAHalf }, // DXGI_FORMAT_R16G16B16A16_FLOAT - - { GUID_WICPixelFormat128bppPRGBAFloat, GUID_WICPixelFormat128bppRGBAFloat }, // DXGI_FORMAT_R32G32B32A32_FLOAT - { GUID_WICPixelFormat128bppRGBFloat, GUID_WICPixelFormat128bppRGBAFloat }, // DXGI_FORMAT_R32G32B32A32_FLOAT - { GUID_WICPixelFormat128bppRGBAFixedPoint, GUID_WICPixelFormat128bppRGBAFloat }, // DXGI_FORMAT_R32G32B32A32_FLOAT - { GUID_WICPixelFormat128bppRGBFixedPoint, GUID_WICPixelFormat128bppRGBAFloat }, // DXGI_FORMAT_R32G32B32A32_FLOAT - { GUID_WICPixelFormat32bppRGBE, GUID_WICPixelFormat128bppRGBAFloat }, // DXGI_FORMAT_R32G32B32A32_FLOAT - - { GUID_WICPixelFormat32bppCMYK, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM - { GUID_WICPixelFormat64bppCMYK, GUID_WICPixelFormat64bppRGBA }, // DXGI_FORMAT_R16G16B16A16_UNORM - { GUID_WICPixelFormat40bppCMYKAlpha, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM - { GUID_WICPixelFormat80bppCMYKAlpha, GUID_WICPixelFormat64bppRGBA }, // DXGI_FORMAT_R16G16B16A16_UNORM - - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE) - { GUID_WICPixelFormat32bppRGB, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM - { GUID_WICPixelFormat64bppRGB, GUID_WICPixelFormat64bppRGBA }, // DXGI_FORMAT_R16G16B16A16_UNORM - { GUID_WICPixelFormat64bppPRGBAHalf, GUID_WICPixelFormat64bppRGBAHalf }, // DXGI_FORMAT_R16G16B16A16_FLOAT - #endif - - // We don't support n-channel formats - }; - - bool g_WIC2 = false; - - BOOL WINAPI InitializeWICFactory(PINIT_ONCE, PVOID, PVOID *ifactory) noexcept - { - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE) - HRESULT hr = CoCreateInstance( - CLSID_WICImagingFactory2, - nullptr, - CLSCTX_INPROC_SERVER, - __uuidof(IWICImagingFactory2), - ifactory - ); - - if (SUCCEEDED(hr)) - { - // WIC2 is available on Windows 10, Windows 8.x, and Windows 7 SP1 with KB 2670838 installed - g_WIC2 = true; - return TRUE; - } - else - { - hr = CoCreateInstance( - CLSID_WICImagingFactory1, - nullptr, - CLSCTX_INPROC_SERVER, - __uuidof(IWICImagingFactory), - ifactory - ); - return SUCCEEDED(hr) ? TRUE : FALSE; - } - #else - return SUCCEEDED(CoCreateInstance( - CLSID_WICImagingFactory, - nullptr, - CLSCTX_INPROC_SERVER, - __uuidof(IWICImagingFactory), - ifactory)) ? TRUE : FALSE; - #endif - } - - IWICImagingFactory* GetWIC() noexcept - { - static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT; - - IWICImagingFactory* factory = nullptr; - if (!InitOnceExecuteOnce( - &s_initOnce, - InitializeWICFactory, - nullptr, - reinterpret_cast(&factory))) - { - return nullptr; - } - - return factory; - } - - //--------------------------------------------------------------------------------- - DXGI_FORMAT WICToDXGI(const GUID& guid) noexcept - { - for (size_t i = 0; i < std::size(g_WICFormats); ++i) - { - if (memcmp(&g_WICFormats[i].wic, &guid, sizeof(GUID)) == 0) - return g_WICFormats[i].format; - } - - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE) - if (g_WIC2) - { - if (memcmp(&GUID_WICPixelFormat96bppRGBFloat, &guid, sizeof(GUID)) == 0) - return DXGI_FORMAT_R32G32B32_FLOAT; - } - #endif - - return DXGI_FORMAT_UNKNOWN; - } - - //--------------------------------------------------------------------------------- - size_t WICBitsPerPixel(REFGUID targetGuid) noexcept - { - auto pWIC = GetWIC(); - if (!pWIC) - return 0; - - ComPtr cinfo; - if (FAILED(pWIC->CreateComponentInfo(targetGuid, cinfo.GetAddressOf()))) - return 0; - - WICComponentType type; - if (FAILED(cinfo->GetComponentType(&type))) - return 0; - - if (type != WICPixelFormat) - return 0; - - ComPtr pfinfo; - if (FAILED(cinfo.As(&pfinfo))) - return 0; - - UINT bpp; - if (FAILED(pfinfo->GetBitsPerPixel(&bpp))) - return 0; - - return bpp; - } - - - //-------------------------------------------------------------------------------------- - DXGI_FORMAT MakeSRGB(_In_ DXGI_FORMAT format) noexcept - { - switch (format) - { - case DXGI_FORMAT_R8G8B8A8_UNORM: - return DXGI_FORMAT_R8G8B8A8_UNORM_SRGB; - - case DXGI_FORMAT_BC1_UNORM: - return DXGI_FORMAT_BC1_UNORM_SRGB; - - case DXGI_FORMAT_BC2_UNORM: - return DXGI_FORMAT_BC2_UNORM_SRGB; - - case DXGI_FORMAT_BC3_UNORM: - return DXGI_FORMAT_BC3_UNORM_SRGB; - - case DXGI_FORMAT_B8G8R8A8_UNORM: - return DXGI_FORMAT_B8G8R8A8_UNORM_SRGB; - - case DXGI_FORMAT_B8G8R8X8_UNORM: - return DXGI_FORMAT_B8G8R8X8_UNORM_SRGB; - - case DXGI_FORMAT_BC7_UNORM: - return DXGI_FORMAT_BC7_UNORM_SRGB; - - default: - return format; - } - } - - - //--------------------------------------------------------------------------------- - void FitPowerOf2(UINT origx, UINT origy, UINT& targetx, UINT& targety, size_t maxsize) - { - const float origAR = float(origx) / float(origy); - - if (origx > origy) - { - size_t x; - for (x = maxsize; x > 1; x >>= 1) { if (x <= targetx) break; } - targetx = UINT(x); - - float bestScore = FLT_MAX; - for (size_t y = maxsize; y > 0; y >>= 1) - { - const float score = fabsf((float(x) / float(y)) - origAR); - if (score < bestScore) - { - bestScore = score; - targety = UINT(y); - } - } - } - else - { - size_t y; - for (y = maxsize; y > 1; y >>= 1) { if (y <= targety) break; } - targety = UINT(y); - - float bestScore = FLT_MAX; - for (size_t x = maxsize; x > 0; x >>= 1) - { - const float score = fabsf((float(x) / float(y)) - origAR); - if (score < bestScore) - { - bestScore = score; - targetx = UINT(x); - } - } - } - } - - - //--------------------------------------------------------------------------------- - HRESULT CreateTextureFromWIC(_In_ ID3D11Device* d3dDevice, - _In_opt_ ID3D11DeviceContext* d3dContext, - _In_ IWICBitmapFrameDecode* frame, - _In_ size_t maxsize, - _In_ D3D11_USAGE usage, - _In_ unsigned int bindFlags, - _In_ unsigned int cpuAccessFlags, - _In_ unsigned int miscFlags, - _In_ WIC_LOADER_FLAGS loadFlags, - _Outptr_opt_ ID3D11Resource** texture, - _Outptr_opt_ ID3D11ShaderResourceView** textureView) noexcept - { - UINT width, height; - HRESULT hr = frame->GetSize(&width, &height); - if (FAILED(hr)) - return hr; - - if (maxsize > UINT32_MAX) - return E_INVALIDARG; - - assert(width > 0 && height > 0); - - if (!maxsize) - { - // This is a bit conservative because the hardware could support larger textures than - // the Feature Level defined minimums, but doing it this way is much easier and more - // performant for WIC than the 'fail and retry' model used by DDSTextureLoader - - switch (d3dDevice->GetFeatureLevel()) - { - case D3D_FEATURE_LEVEL_9_1: - case D3D_FEATURE_LEVEL_9_2: - maxsize = 2048u /*D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION*/; - break; - - case D3D_FEATURE_LEVEL_9_3: - maxsize = 4096u /*D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION*/; - break; - - case D3D_FEATURE_LEVEL_10_0: - case D3D_FEATURE_LEVEL_10_1: - maxsize = 8192u /*D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION*/; - break; - - default: - maxsize = size_t(D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION); - break; - } - } - - assert(maxsize > 0); - - UINT twidth = width; - UINT theight = height; - if (loadFlags & WIC_LOADER_FIT_POW2) - { - FitPowerOf2(width, height, twidth, theight, maxsize); - } - else if (width > maxsize || height > maxsize) - { - const float ar = static_cast(height) / static_cast(width); - if (width > height) - { - twidth = static_cast(maxsize); - theight = std::max(1, static_cast(static_cast(maxsize) * ar)); - } - else - { - theight = static_cast(maxsize); - twidth = std::max(1, static_cast(static_cast(maxsize) / ar)); - } - assert(twidth <= maxsize && theight <= maxsize); - } - - if (loadFlags & WIC_LOADER_MAKE_SQUARE) - { - twidth = std::max(twidth, theight); - theight = twidth; - } - - // Determine format - WICPixelFormatGUID pixelFormat; - hr = frame->GetPixelFormat(&pixelFormat); - if (FAILED(hr)) - return hr; - - WICPixelFormatGUID convertGUID; - memcpy_s(&convertGUID, sizeof(WICPixelFormatGUID), &pixelFormat, sizeof(GUID)); - - size_t bpp = 0; - - DXGI_FORMAT format = WICToDXGI(pixelFormat); - if (format == DXGI_FORMAT_UNKNOWN) - { - if (memcmp(&GUID_WICPixelFormat96bppRGBFixedPoint, &pixelFormat, sizeof(WICPixelFormatGUID)) == 0) - { - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE) - if (g_WIC2) - { - memcpy_s(&convertGUID, sizeof(WICPixelFormatGUID), &GUID_WICPixelFormat96bppRGBFloat, sizeof(GUID)); - format = DXGI_FORMAT_R32G32B32_FLOAT; - bpp = 96; - } - else - #endif - { - memcpy_s(&convertGUID, sizeof(WICPixelFormatGUID), &GUID_WICPixelFormat128bppRGBAFloat, sizeof(GUID)); - format = DXGI_FORMAT_R32G32B32A32_FLOAT; - bpp = 128; - } - } - else - { - for (size_t i = 0; i < std::size(g_WICConvert); ++i) - { - if (memcmp(&g_WICConvert[i].source, &pixelFormat, sizeof(WICPixelFormatGUID)) == 0) - { - memcpy_s(&convertGUID, sizeof(WICPixelFormatGUID), &g_WICConvert[i].target, sizeof(GUID)); - - format = WICToDXGI(g_WICConvert[i].target); - assert(format != DXGI_FORMAT_UNKNOWN); - bpp = WICBitsPerPixel(convertGUID); - break; - } - } - } - - if (format == DXGI_FORMAT_UNKNOWN) - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - else - { - bpp = WICBitsPerPixel(pixelFormat); - } - - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE) - if ((format == DXGI_FORMAT_R32G32B32_FLOAT) && d3dContext && textureView) - { - // Special case test for optional device support for autogen mipchains for R32G32B32_FLOAT - UINT fmtSupport = 0; - hr = d3dDevice->CheckFormatSupport(DXGI_FORMAT_R32G32B32_FLOAT, &fmtSupport); - if (FAILED(hr) || !(fmtSupport & D3D11_FORMAT_SUPPORT_MIP_AUTOGEN)) - { - // Use R32G32B32A32_FLOAT instead which is required for Feature Level 10.0 and up - memcpy_s(&convertGUID, sizeof(WICPixelFormatGUID), &GUID_WICPixelFormat128bppRGBAFloat, sizeof(GUID)); - format = DXGI_FORMAT_R32G32B32A32_FLOAT; - bpp = 128; - } - } - #endif - - if (loadFlags & WIC_LOADER_FORCE_RGBA32) - { - memcpy_s(&convertGUID, sizeof(WICPixelFormatGUID), &GUID_WICPixelFormat32bppRGBA, sizeof(GUID)); - format = DXGI_FORMAT_R8G8B8A8_UNORM; - bpp = 32; - } - - if (!bpp) - return E_FAIL; - - // Handle sRGB formats - if (loadFlags & WIC_LOADER_FORCE_SRGB) - { - format = MakeSRGB(format); - } - else if (!(loadFlags & WIC_LOADER_IGNORE_SRGB)) - { - ComPtr metareader; - if (SUCCEEDED(frame->GetMetadataQueryReader(metareader.GetAddressOf()))) - { - GUID containerFormat; - if (SUCCEEDED(metareader->GetContainerFormat(&containerFormat))) - { - bool sRGB = false; - - PROPVARIANT value; - PropVariantInit(&value); - - // Check for colorspace chunks - if (memcmp(&containerFormat, &GUID_ContainerFormatPng, sizeof(GUID)) == 0) - { - if (SUCCEEDED(metareader->GetMetadataByName(L"/sRGB/RenderingIntent", &value)) && value.vt == VT_UI1) - { - sRGB = true; - } - else if (SUCCEEDED(metareader->GetMetadataByName(L"/gAMA/ImageGamma", &value)) && value.vt == VT_UI4) - { - sRGB = (value.uintVal == 45455); - } - else - { - sRGB = (loadFlags & WIC_LOADER_SRGB_DEFAULT) != 0; - } - } - else if (SUCCEEDED(metareader->GetMetadataByName(L"System.Image.ColorSpace", &value)) && value.vt == VT_UI2) - { - sRGB = (value.uiVal == 1); - } - else - { - sRGB = (loadFlags & WIC_LOADER_SRGB_DEFAULT) != 0; - } - - std::ignore = PropVariantClear(&value); - - if (sRGB) - format = MakeSRGB(format); - } - } - } - - // Verify our target format is supported by the current device - // (handles WDDM 1.0 or WDDM 1.1 device driver cases as well as DirectX 11.0 Runtime without 16bpp format support) - UINT support = 0; - hr = d3dDevice->CheckFormatSupport(format, &support); - if (FAILED(hr) || !(support & D3D11_FORMAT_SUPPORT_TEXTURE2D)) - { - // Fallback to RGBA 32-bit format which is supported by all devices - memcpy_s(&convertGUID, sizeof(WICPixelFormatGUID), &GUID_WICPixelFormat32bppRGBA, sizeof(GUID)); - format = DXGI_FORMAT_R8G8B8A8_UNORM; - bpp = 32; - } - - // Allocate temporary memory for image - const uint64_t rowBytes = (uint64_t(twidth) * uint64_t(bpp) + 7u) / 8u; - const uint64_t numBytes = rowBytes * uint64_t(theight); - - if (rowBytes > UINT32_MAX || numBytes > UINT32_MAX) - return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); - - auto const rowPitch = static_cast(rowBytes); - auto const imageSize = static_cast(numBytes); - - std::unique_ptr temp(new (std::nothrow) uint8_t[imageSize]); - if (!temp) - return E_OUTOFMEMORY; - - // Load image data - if (memcmp(&convertGUID, &pixelFormat, sizeof(GUID)) == 0 - && twidth == width - && theight == height) - { - // No format conversion or resize needed - hr = frame->CopyPixels(nullptr, static_cast(rowPitch), static_cast(imageSize), temp.get()); - if (FAILED(hr)) - return hr; - } - else if (twidth != width || theight != height) - { - // Resize - auto pWIC = GetWIC(); - if (!pWIC) - return E_NOINTERFACE; - - ComPtr scaler; - hr = pWIC->CreateBitmapScaler(scaler.GetAddressOf()); - if (FAILED(hr)) - return hr; - - hr = scaler->Initialize(frame, twidth, theight, WICBitmapInterpolationModeFant); - if (FAILED(hr)) - return hr; - - WICPixelFormatGUID pfScaler; - hr = scaler->GetPixelFormat(&pfScaler); - if (FAILED(hr)) - return hr; - - if (memcmp(&convertGUID, &pfScaler, sizeof(GUID)) == 0) - { - // No format conversion needed - hr = scaler->CopyPixels(nullptr, static_cast(rowPitch), static_cast(imageSize), temp.get()); - if (FAILED(hr)) - return hr; - } - else - { - ComPtr FC; - hr = pWIC->CreateFormatConverter(FC.GetAddressOf()); - if (FAILED(hr)) - return hr; - - BOOL canConvert = FALSE; - hr = FC->CanConvert(pfScaler, convertGUID, &canConvert); - if (FAILED(hr) || !canConvert) - { - return E_UNEXPECTED; - } - - hr = FC->Initialize(scaler.Get(), convertGUID, WICBitmapDitherTypeErrorDiffusion, nullptr, 0, WICBitmapPaletteTypeMedianCut); - if (FAILED(hr)) - return hr; - - hr = FC->CopyPixels(nullptr, static_cast(rowPitch), static_cast(imageSize), temp.get()); - if (FAILED(hr)) - return hr; - } - } - else - { - // Format conversion but no resize - auto pWIC = GetWIC(); - if (!pWIC) - return E_NOINTERFACE; - - ComPtr FC; - hr = pWIC->CreateFormatConverter(FC.GetAddressOf()); - if (FAILED(hr)) - return hr; - - BOOL canConvert = FALSE; - hr = FC->CanConvert(pixelFormat, convertGUID, &canConvert); - if (FAILED(hr) || !canConvert) - { - return E_UNEXPECTED; - } - - hr = FC->Initialize(frame, convertGUID, WICBitmapDitherTypeErrorDiffusion, nullptr, 0, WICBitmapPaletteTypeMedianCut); - if (FAILED(hr)) - return hr; - - hr = FC->CopyPixels(nullptr, static_cast(rowPitch), static_cast(imageSize), temp.get()); - if (FAILED(hr)) - return hr; - } - - // See if format is supported for auto-gen mipmaps (varies by feature level) - bool autogen = false; - if (d3dContext && textureView) // Must have context and shader-view to auto generate mipmaps - { - UINT fmtSupport = 0; - hr = d3dDevice->CheckFormatSupport(format, &fmtSupport); - if (SUCCEEDED(hr) && (fmtSupport & D3D11_FORMAT_SUPPORT_MIP_AUTOGEN)) - { - autogen = true; - } - } - - // Create texture - D3D11_TEXTURE2D_DESC desc = {}; - desc.Width = twidth; - desc.Height = theight; - desc.MipLevels = (autogen) ? 0u : 1u; - desc.ArraySize = 1; - desc.Format = format; - desc.SampleDesc.Count = 1; - desc.SampleDesc.Quality = 0; - desc.Usage = usage; - desc.CPUAccessFlags = cpuAccessFlags; - - if (autogen) - { - desc.BindFlags = bindFlags | D3D11_BIND_RENDER_TARGET; - desc.MiscFlags = miscFlags | D3D11_RESOURCE_MISC_GENERATE_MIPS; - } - else - { - desc.BindFlags = bindFlags; - desc.MiscFlags = miscFlags; - } - - D3D11_SUBRESOURCE_DATA initData; - initData.pSysMem = temp.get(); - initData.SysMemPitch = static_cast(rowPitch); - initData.SysMemSlicePitch = static_cast(imageSize); - - ID3D11Texture2D* tex = nullptr; - hr = d3dDevice->CreateTexture2D(&desc, (autogen) ? nullptr : &initData, &tex); - if (SUCCEEDED(hr) && tex) - { - if (textureView) - { - D3D11_SHADER_RESOURCE_VIEW_DESC SRVDesc = {}; - SRVDesc.Format = desc.Format; - - SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; - SRVDesc.Texture2D.MipLevels = (autogen) ? unsigned(-1) : 1u; - - hr = d3dDevice->CreateShaderResourceView(tex, &SRVDesc, textureView); - if (FAILED(hr)) - { - tex->Release(); - return hr; - } - - if (autogen) - { - assert(d3dContext != nullptr); - d3dContext->UpdateSubresource(tex, 0, nullptr, temp.get(), static_cast(rowPitch), static_cast(imageSize)); - d3dContext->GenerateMips(*textureView); - } - } - - if (texture) - { - *texture = tex; - } - else - { - SetDebugObjectName(tex, "WICTextureLoader"); - tex->Release(); - } - } - - return hr; - } - - - //-------------------------------------------------------------------------------------- - void SetDebugTextureInfo( - _In_z_ const wchar_t* fileName, - _In_opt_ ID3D11Resource** texture, - _In_opt_ ID3D11ShaderResourceView** textureView) noexcept - { - #if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) ) - if (texture || textureView) - { - CHAR strFileA[MAX_PATH]; - const int result = WideCharToMultiByte(CP_UTF8, - WC_NO_BEST_FIT_CHARS, - fileName, - -1, - strFileA, - MAX_PATH, - nullptr, - nullptr - ); - if (result > 0) - { - const char* pstrName = strrchr(strFileA, '\\'); - if (!pstrName) - { - pstrName = strFileA; - } - else - { - pstrName++; - } - - if (texture && *texture) - { - (*texture)->SetPrivateData(WKPDID_D3DDebugObjectName, - static_cast(strnlen_s(pstrName, MAX_PATH)), - pstrName - ); - } - - if (textureView && *textureView) - { - (*textureView)->SetPrivateData(WKPDID_D3DDebugObjectName, - static_cast(strnlen_s(pstrName, MAX_PATH)), - pstrName - ); - } - } - } - #else - UNREFERENCED_PARAMETER(fileName); - UNREFERENCED_PARAMETER(texture); - UNREFERENCED_PARAMETER(textureView); - #endif - } -} // anonymous namespace - -//-------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::CreateWICTextureFromMemory( - ID3D11Device* d3dDevice, - const uint8_t* wicData, - size_t wicDataSize, - ID3D11Resource** texture, - ID3D11ShaderResourceView** textureView, - size_t maxsize) noexcept -{ - return CreateWICTextureFromMemoryEx(d3dDevice, nullptr, - wicData, wicDataSize, - maxsize, - D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, - WIC_LOADER_DEFAULT, - texture, textureView); -} - -_Use_decl_annotations_ -HRESULT DirectX::CreateWICTextureFromMemory( - ID3D11Device* d3dDevice, - ID3D11DeviceContext* d3dContext, - const uint8_t* wicData, - size_t wicDataSize, - ID3D11Resource** texture, - ID3D11ShaderResourceView** textureView, - size_t maxsize) noexcept -{ - return CreateWICTextureFromMemoryEx(d3dDevice, d3dContext, - wicData, wicDataSize, - maxsize, - D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, - WIC_LOADER_DEFAULT, - texture, textureView); -} - -_Use_decl_annotations_ -HRESULT DirectX::CreateWICTextureFromMemoryEx( - ID3D11Device* d3dDevice, - const uint8_t* wicData, - size_t wicDataSize, - size_t maxsize, - D3D11_USAGE usage, - unsigned int bindFlags, - unsigned int cpuAccessFlags, - unsigned int miscFlags, - WIC_LOADER_FLAGS loadFlags, - ID3D11Resource** texture, - ID3D11ShaderResourceView** textureView) noexcept -{ - return CreateWICTextureFromMemoryEx(d3dDevice, nullptr, - wicData, wicDataSize, - maxsize, - usage, bindFlags, cpuAccessFlags, miscFlags, - loadFlags, - texture, textureView); -} - -_Use_decl_annotations_ -HRESULT DirectX::CreateWICTextureFromMemoryEx( - ID3D11Device* d3dDevice, - ID3D11DeviceContext* d3dContext, - const uint8_t* wicData, - size_t wicDataSize, - size_t maxsize, - D3D11_USAGE usage, - unsigned int bindFlags, - unsigned int cpuAccessFlags, - unsigned int miscFlags, - WIC_LOADER_FLAGS loadFlags, - ID3D11Resource** texture, - ID3D11ShaderResourceView** textureView) noexcept -{ - if (texture) - { - *texture = nullptr; - } - if (textureView) - { - *textureView = nullptr; - } - - if (!d3dDevice || !wicData || (!texture && !textureView)) - { - return E_INVALIDARG; - } - - if (textureView && !(bindFlags & D3D11_BIND_SHADER_RESOURCE)) - { - return E_INVALIDARG; - } - - if (!wicDataSize) - return E_FAIL; - - if (wicDataSize > UINT32_MAX) - return HRESULT_FROM_WIN32(ERROR_FILE_TOO_LARGE); - - auto pWIC = GetWIC(); - if (!pWIC) - return E_NOINTERFACE; - - // Create input stream for memory - ComPtr stream; - HRESULT hr = pWIC->CreateStream(stream.GetAddressOf()); - if (FAILED(hr)) - return hr; - - hr = stream->InitializeFromMemory(const_cast(wicData), static_cast(wicDataSize)); - if (FAILED(hr)) - return hr; - - // Initialize WIC - ComPtr decoder; - hr = pWIC->CreateDecoderFromStream(stream.Get(), nullptr, WICDecodeMetadataCacheOnDemand, decoder.GetAddressOf()); - if (FAILED(hr)) - return hr; - - ComPtr frame; - hr = decoder->GetFrame(0, frame.GetAddressOf()); - if (FAILED(hr)) - return hr; - - hr = CreateTextureFromWIC(d3dDevice, d3dContext, - frame.Get(), - maxsize, - usage, bindFlags, cpuAccessFlags, miscFlags, - loadFlags, - texture, textureView); - if (FAILED(hr)) - return hr; - - if (texture && *texture) - { - SetDebugObjectName(*texture, "WICTextureLoader"); - } - - if (textureView && *textureView) - { - SetDebugObjectName(*textureView, "WICTextureLoader"); - } - - return hr; -} - -//-------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::CreateWICTextureFromFile( - ID3D11Device* d3dDevice, - const wchar_t* fileName, - ID3D11Resource** texture, - ID3D11ShaderResourceView** textureView, - size_t maxsize) noexcept -{ - return CreateWICTextureFromFileEx(d3dDevice, nullptr, - fileName, maxsize, - D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, - WIC_LOADER_DEFAULT, - texture, textureView); -} - -_Use_decl_annotations_ -HRESULT DirectX::CreateWICTextureFromFile( - ID3D11Device* d3dDevice, - ID3D11DeviceContext* d3dContext, - const wchar_t* fileName, - ID3D11Resource** texture, - ID3D11ShaderResourceView** textureView, - size_t maxsize) noexcept -{ - return CreateWICTextureFromFileEx(d3dDevice, d3dContext, - fileName, - maxsize, - D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, - WIC_LOADER_DEFAULT, - texture, textureView); -} - -_Use_decl_annotations_ -HRESULT DirectX::CreateWICTextureFromFileEx( - ID3D11Device* d3dDevice, - const wchar_t* fileName, - size_t maxsize, - D3D11_USAGE usage, - unsigned int bindFlags, - unsigned int cpuAccessFlags, - unsigned int miscFlags, - WIC_LOADER_FLAGS loadFlags, - ID3D11Resource** texture, - ID3D11ShaderResourceView** textureView) noexcept -{ - return CreateWICTextureFromFileEx(d3dDevice, nullptr, - fileName, - maxsize, - usage, bindFlags, cpuAccessFlags, miscFlags, - loadFlags, - texture, textureView); -} - -_Use_decl_annotations_ -HRESULT DirectX::CreateWICTextureFromFileEx( - ID3D11Device* d3dDevice, - ID3D11DeviceContext* d3dContext, - const wchar_t* fileName, - size_t maxsize, - D3D11_USAGE usage, - unsigned int bindFlags, - unsigned int cpuAccessFlags, - unsigned int miscFlags, - WIC_LOADER_FLAGS loadFlags, - ID3D11Resource** texture, - ID3D11ShaderResourceView** textureView) noexcept -{ - if (texture) - { - *texture = nullptr; - } - if (textureView) - { - *textureView = nullptr; - } - - if (!d3dDevice || !fileName || (!texture && !textureView)) - { - return E_INVALIDARG; - } - - if (textureView && !(bindFlags & D3D11_BIND_SHADER_RESOURCE)) - { - return E_INVALIDARG; - } - - auto pWIC = GetWIC(); - if (!pWIC) - return E_NOINTERFACE; - - // Initialize WIC - ComPtr decoder; - HRESULT hr = pWIC->CreateDecoderFromFilename(fileName, - nullptr, - GENERIC_READ, - WICDecodeMetadataCacheOnDemand, - decoder.GetAddressOf()); - if (FAILED(hr)) - return hr; - - ComPtr frame; - hr = decoder->GetFrame(0, frame.GetAddressOf()); - if (FAILED(hr)) - return hr; - - hr = CreateTextureFromWIC(d3dDevice, d3dContext, - frame.Get(), - maxsize, - usage, bindFlags, cpuAccessFlags, miscFlags, - loadFlags, - texture, textureView); - - if (SUCCEEDED(hr)) - { - SetDebugTextureInfo(fileName, texture, textureView); - } - - return hr; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/WICTextureLoader/WICTextureLoader11.h b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/WICTextureLoader/WICTextureLoader11.h deleted file mode 100644 index 151da38..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/WICTextureLoader/WICTextureLoader11.h +++ /dev/null @@ -1,148 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: WICTextureLoader11.h -// -// Function for loading a WIC image and creating a Direct3D runtime texture for it -// (auto-generating mipmaps if possible) -// -// Note: Assumes application has already called CoInitializeEx -// -// Warning: CreateWICTexture* functions are not thread-safe if given a d3dContext instance for -// auto-gen mipmap support. -// -// Note these functions are useful for images created as simple 2D textures. For -// more complex resources, DDSTextureLoader is an excellent light-weight runtime loader. -// For a full-featured DDS file reader, writer, and texture processing pipeline see -// the 'Texconv' sample and the 'DirectXTex' library. -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -// http://go.microsoft.com/fwlink/?LinkId=248929 -//-------------------------------------------------------------------------------------- - -#pragma once - -#include - -#pragma comment(lib,"dxguid.lib") -#pragma comment(lib,"windowscodecs.lib") - -#include -#include - -namespace DirectX -{ -#ifndef WIC_LOADER_FLAGS_DEFINED -#define WIC_LOADER_FLAGS_DEFINED - enum WIC_LOADER_FLAGS : uint32_t - { - WIC_LOADER_DEFAULT = 0, - WIC_LOADER_FORCE_SRGB = 0x1, - WIC_LOADER_IGNORE_SRGB = 0x2, - WIC_LOADER_SRGB_DEFAULT = 0x4, - WIC_LOADER_FIT_POW2 = 0x20, - WIC_LOADER_MAKE_SQUARE = 0x40, - WIC_LOADER_FORCE_RGBA32 = 0x80, - }; - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-dynamic-exception-spec" -#endif - - DEFINE_ENUM_FLAG_OPERATORS(WIC_LOADER_FLAGS); - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif -#endif - - // Standard version - HRESULT CreateWICTextureFromMemory( - _In_ ID3D11Device* d3dDevice, - _In_reads_bytes_(wicDataSize) const uint8_t* wicData, - _In_ size_t wicDataSize, - _Outptr_opt_ ID3D11Resource** texture, - _Outptr_opt_ ID3D11ShaderResourceView** textureView, - _In_ size_t maxsize = 0) noexcept; - - HRESULT CreateWICTextureFromFile( - _In_ ID3D11Device* d3dDevice, - _In_z_ const wchar_t* szFileName, - _Outptr_opt_ ID3D11Resource** texture, - _Outptr_opt_ ID3D11ShaderResourceView** textureView, - _In_ size_t maxsize = 0) noexcept; - - // Standard version with optional auto-gen mipmap support - HRESULT CreateWICTextureFromMemory( - _In_ ID3D11Device* d3dDevice, - _In_opt_ ID3D11DeviceContext* d3dContext, - _In_reads_bytes_(wicDataSize) const uint8_t* wicData, - _In_ size_t wicDataSize, - _Outptr_opt_ ID3D11Resource** texture, - _Outptr_opt_ ID3D11ShaderResourceView** textureView, - _In_ size_t maxsize = 0) noexcept; - - HRESULT CreateWICTextureFromFile( - _In_ ID3D11Device* d3dDevice, - _In_opt_ ID3D11DeviceContext* d3dContext, - _In_z_ const wchar_t* szFileName, - _Outptr_opt_ ID3D11Resource** texture, - _Outptr_opt_ ID3D11ShaderResourceView** textureView, - _In_ size_t maxsize = 0) noexcept; - - // Extended version - HRESULT CreateWICTextureFromMemoryEx( - _In_ ID3D11Device* d3dDevice, - _In_reads_bytes_(wicDataSize) const uint8_t* wicData, - _In_ size_t wicDataSize, - _In_ size_t maxsize, - _In_ D3D11_USAGE usage, - _In_ unsigned int bindFlags, - _In_ unsigned int cpuAccessFlags, - _In_ unsigned int miscFlags, - _In_ WIC_LOADER_FLAGS loadFlags, - _Outptr_opt_ ID3D11Resource** texture, - _Outptr_opt_ ID3D11ShaderResourceView** textureView) noexcept; - - HRESULT CreateWICTextureFromFileEx( - _In_ ID3D11Device* d3dDevice, - _In_z_ const wchar_t* szFileName, - _In_ size_t maxsize, - _In_ D3D11_USAGE usage, - _In_ unsigned int bindFlags, - _In_ unsigned int cpuAccessFlags, - _In_ unsigned int miscFlags, - _In_ WIC_LOADER_FLAGS loadFlags, - _Outptr_opt_ ID3D11Resource** texture, - _Outptr_opt_ ID3D11ShaderResourceView** textureView) noexcept; - - // Extended version with optional auto-gen mipmap support - HRESULT CreateWICTextureFromMemoryEx( - _In_ ID3D11Device* d3dDevice, - _In_opt_ ID3D11DeviceContext* d3dContext, - _In_reads_bytes_(wicDataSize) const uint8_t* wicData, - _In_ size_t wicDataSize, - _In_ size_t maxsize, - _In_ D3D11_USAGE usage, - _In_ unsigned int bindFlags, - _In_ unsigned int cpuAccessFlags, - _In_ unsigned int miscFlags, - _In_ WIC_LOADER_FLAGS loadFlags, - _Outptr_opt_ ID3D11Resource** texture, - _Outptr_opt_ ID3D11ShaderResourceView** textureView) noexcept; - - HRESULT CreateWICTextureFromFileEx( - _In_ ID3D11Device* d3dDevice, - _In_opt_ ID3D11DeviceContext* d3dContext, - _In_z_ const wchar_t* szFileName, - _In_ size_t maxsize, - _In_ D3D11_USAGE usage, - _In_ unsigned int bindFlags, - _In_ unsigned int cpuAccessFlags, - _In_ unsigned int miscFlags, - _In_ WIC_LOADER_FLAGS loadFlags, - _Outptr_opt_ ID3D11Resource** texture, - _Outptr_opt_ ID3D11ShaderResourceView** textureView) noexcept; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/WICTextureLoader/WICTextureLoader12.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/WICTextureLoader/WICTextureLoader12.cpp deleted file mode 100644 index 42dec1a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/WICTextureLoader/WICTextureLoader12.cpp +++ /dev/null @@ -1,829 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: WICTextureLoader12.cpp -// -// Function for loading a WIC image and creating a Direct3D runtime texture for it -// (auto-generating mipmaps if possible) -// -// Note: Assumes application has already called CoInitializeEx -// -// Note these functions are useful for images created as simple 2D textures. For -// more complex resources, DDSTextureLoader is an excellent light-weight runtime loader. -// For a full-featured DDS file reader, writer, and texture processing pipeline see -// the 'Texconv' sample and the 'DirectXTex' library. -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -// http://go.microsoft.com/fwlink/?LinkID=615561 -//-------------------------------------------------------------------------------------- - -// We could load multi-frame images (TIFF/GIF) into a texture array. -// For now, we just load the first frame (note: DirectXTex supports multi-frame images) - -#include "WICTextureLoader12.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#ifdef _MSC_VER -// Off by default warnings -#pragma warning(disable : 4619 4616 4061 4062 4623 4626 5027) -// C4619/4616 #pragma warning warnings -// C4061 enumerator 'x' in switch of enum 'y' is not explicitly handled by a case label -// C4062 enumerator 'x' in switch of enum 'y' is not handled -// C4623 default constructor was implicitly defined as deleted -// C4626 assignment operator was implicitly defined as deleted -// C5027 move assignment operator was implicitly defined as deleted -#endif - -#ifdef __clang__ -#pragma clang diagnostic ignored "-Wtautological-type-limit-compare" -#pragma clang diagnostic ignored "-Wcovered-switch-default" -#pragma clang diagnostic ignored "-Wswitch" -#pragma clang diagnostic ignored "-Wswitch-enum" -#pragma clang diagnostic ignored "-Wunused-macros" -#endif - -#define D3DX12_NO_STATE_OBJECT_HELPERS -#define D3DX12_NO_CHECK_FEATURE_SUPPORT_CLASS -#ifdef USING_DIRECTX_HEADERS -#include "directx/d3dx12.h" -#else -#include "d3dx12.h" -#endif - -using namespace DirectX; -using Microsoft::WRL::ComPtr; - -namespace -{ - //------------------------------------------------------------------------------------- - // WIC Pixel Format Translation Data - //------------------------------------------------------------------------------------- - struct WICTranslate - { - const GUID& wic; - DXGI_FORMAT format; - }; - - constexpr WICTranslate g_WICFormats[] = - { - { GUID_WICPixelFormat128bppRGBAFloat, DXGI_FORMAT_R32G32B32A32_FLOAT }, - - { GUID_WICPixelFormat64bppRGBAHalf, DXGI_FORMAT_R16G16B16A16_FLOAT }, - { GUID_WICPixelFormat64bppRGBA, DXGI_FORMAT_R16G16B16A16_UNORM }, - - { GUID_WICPixelFormat32bppRGBA, DXGI_FORMAT_R8G8B8A8_UNORM }, - { GUID_WICPixelFormat32bppBGRA, DXGI_FORMAT_B8G8R8A8_UNORM }, - { GUID_WICPixelFormat32bppBGR, DXGI_FORMAT_B8G8R8X8_UNORM }, - - { GUID_WICPixelFormat32bppRGBA1010102XR, DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM }, - { GUID_WICPixelFormat32bppRGBA1010102, DXGI_FORMAT_R10G10B10A2_UNORM }, - - { GUID_WICPixelFormat16bppBGRA5551, DXGI_FORMAT_B5G5R5A1_UNORM }, - { GUID_WICPixelFormat16bppBGR565, DXGI_FORMAT_B5G6R5_UNORM }, - - { GUID_WICPixelFormat32bppGrayFloat, DXGI_FORMAT_R32_FLOAT }, - { GUID_WICPixelFormat16bppGrayHalf, DXGI_FORMAT_R16_FLOAT }, - { GUID_WICPixelFormat16bppGray, DXGI_FORMAT_R16_UNORM }, - { GUID_WICPixelFormat8bppGray, DXGI_FORMAT_R8_UNORM }, - - { GUID_WICPixelFormat8bppAlpha, DXGI_FORMAT_A8_UNORM }, - - { GUID_WICPixelFormat96bppRGBFloat, DXGI_FORMAT_R32G32B32_FLOAT }, - }; - - //------------------------------------------------------------------------------------- - // WIC Pixel Format nearest conversion table - //------------------------------------------------------------------------------------- - struct WICConvert - { - const GUID& source; - const GUID& target; - }; - - constexpr WICConvert g_WICConvert[] = - { - // Note target GUID in this conversion table must be one of those directly supported formats (above). - - { GUID_WICPixelFormatBlackWhite, GUID_WICPixelFormat8bppGray }, // DXGI_FORMAT_R8_UNORM - - { GUID_WICPixelFormat1bppIndexed, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM - { GUID_WICPixelFormat2bppIndexed, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM - { GUID_WICPixelFormat4bppIndexed, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM - { GUID_WICPixelFormat8bppIndexed, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM - - { GUID_WICPixelFormat2bppGray, GUID_WICPixelFormat8bppGray }, // DXGI_FORMAT_R8_UNORM - { GUID_WICPixelFormat4bppGray, GUID_WICPixelFormat8bppGray }, // DXGI_FORMAT_R8_UNORM - - { GUID_WICPixelFormat16bppGrayFixedPoint, GUID_WICPixelFormat16bppGrayHalf }, // DXGI_FORMAT_R16_FLOAT - { GUID_WICPixelFormat32bppGrayFixedPoint, GUID_WICPixelFormat32bppGrayFloat }, // DXGI_FORMAT_R32_FLOAT - - { GUID_WICPixelFormat16bppBGR555, GUID_WICPixelFormat16bppBGRA5551 }, // DXGI_FORMAT_B5G5R5A1_UNORM - - { GUID_WICPixelFormat32bppBGR101010, GUID_WICPixelFormat32bppRGBA1010102 }, // DXGI_FORMAT_R10G10B10A2_UNORM - - { GUID_WICPixelFormat24bppBGR, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM - { GUID_WICPixelFormat24bppRGB, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM - { GUID_WICPixelFormat32bppPBGRA, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM - { GUID_WICPixelFormat32bppPRGBA, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM - - { GUID_WICPixelFormat48bppRGB, GUID_WICPixelFormat64bppRGBA }, // DXGI_FORMAT_R16G16B16A16_UNORM - { GUID_WICPixelFormat48bppBGR, GUID_WICPixelFormat64bppRGBA }, // DXGI_FORMAT_R16G16B16A16_UNORM - { GUID_WICPixelFormat64bppBGRA, GUID_WICPixelFormat64bppRGBA }, // DXGI_FORMAT_R16G16B16A16_UNORM - { GUID_WICPixelFormat64bppPRGBA, GUID_WICPixelFormat64bppRGBA }, // DXGI_FORMAT_R16G16B16A16_UNORM - { GUID_WICPixelFormat64bppPBGRA, GUID_WICPixelFormat64bppRGBA }, // DXGI_FORMAT_R16G16B16A16_UNORM - - { GUID_WICPixelFormat48bppRGBFixedPoint, GUID_WICPixelFormat64bppRGBAHalf }, // DXGI_FORMAT_R16G16B16A16_FLOAT - { GUID_WICPixelFormat48bppBGRFixedPoint, GUID_WICPixelFormat64bppRGBAHalf }, // DXGI_FORMAT_R16G16B16A16_FLOAT - { GUID_WICPixelFormat64bppRGBAFixedPoint, GUID_WICPixelFormat64bppRGBAHalf }, // DXGI_FORMAT_R16G16B16A16_FLOAT - { GUID_WICPixelFormat64bppBGRAFixedPoint, GUID_WICPixelFormat64bppRGBAHalf }, // DXGI_FORMAT_R16G16B16A16_FLOAT - { GUID_WICPixelFormat64bppRGBFixedPoint, GUID_WICPixelFormat64bppRGBAHalf }, // DXGI_FORMAT_R16G16B16A16_FLOAT - { GUID_WICPixelFormat64bppRGBHalf, GUID_WICPixelFormat64bppRGBAHalf }, // DXGI_FORMAT_R16G16B16A16_FLOAT - { GUID_WICPixelFormat48bppRGBHalf, GUID_WICPixelFormat64bppRGBAHalf }, // DXGI_FORMAT_R16G16B16A16_FLOAT - - { GUID_WICPixelFormat128bppPRGBAFloat, GUID_WICPixelFormat128bppRGBAFloat }, // DXGI_FORMAT_R32G32B32A32_FLOAT - { GUID_WICPixelFormat128bppRGBFloat, GUID_WICPixelFormat128bppRGBAFloat }, // DXGI_FORMAT_R32G32B32A32_FLOAT - { GUID_WICPixelFormat128bppRGBAFixedPoint, GUID_WICPixelFormat128bppRGBAFloat }, // DXGI_FORMAT_R32G32B32A32_FLOAT - { GUID_WICPixelFormat128bppRGBFixedPoint, GUID_WICPixelFormat128bppRGBAFloat }, // DXGI_FORMAT_R32G32B32A32_FLOAT - { GUID_WICPixelFormat32bppRGBE, GUID_WICPixelFormat128bppRGBAFloat }, // DXGI_FORMAT_R32G32B32A32_FLOAT - - { GUID_WICPixelFormat32bppCMYK, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM - { GUID_WICPixelFormat64bppCMYK, GUID_WICPixelFormat64bppRGBA }, // DXGI_FORMAT_R16G16B16A16_UNORM - { GUID_WICPixelFormat40bppCMYKAlpha, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM - { GUID_WICPixelFormat80bppCMYKAlpha, GUID_WICPixelFormat64bppRGBA }, // DXGI_FORMAT_R16G16B16A16_UNORM - - { GUID_WICPixelFormat32bppRGB, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM - { GUID_WICPixelFormat64bppRGB, GUID_WICPixelFormat64bppRGBA }, // DXGI_FORMAT_R16G16B16A16_UNORM - { GUID_WICPixelFormat64bppPRGBAHalf, GUID_WICPixelFormat64bppRGBAHalf }, // DXGI_FORMAT_R16G16B16A16_FLOAT - - { GUID_WICPixelFormat96bppRGBFixedPoint, GUID_WICPixelFormat96bppRGBFloat }, // DXGI_FORMAT_R32G32B32_FLOAT - - // We don't support n-channel formats - }; - - BOOL WINAPI InitializeWICFactory(PINIT_ONCE, PVOID, PVOID* ifactory) noexcept - { - return SUCCEEDED(CoCreateInstance( - CLSID_WICImagingFactory2, - nullptr, - CLSCTX_INPROC_SERVER, - __uuidof(IWICImagingFactory2), - ifactory)) ? TRUE : FALSE; - } - - IWICImagingFactory2* GetWIC() noexcept - { - static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT; - - IWICImagingFactory2* factory = nullptr; - if (!InitOnceExecuteOnce( - &s_initOnce, - InitializeWICFactory, - nullptr, - reinterpret_cast(&factory))) - { - return nullptr; - } - - return factory; - } - - //--------------------------------------------------------------------------------- - #if !defined(NO_D3D12_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) ) - template - inline void SetDebugObjectName(_In_ ID3D12DeviceChild* resource, _In_z_ const wchar_t(&name)[TNameLength]) noexcept - { - resource->SetName(name); - } - #else - template - inline void SetDebugObjectName(_In_ ID3D12DeviceChild*, _In_z_ const wchar_t(&)[TNameLength]) noexcept - { - } - #endif - - inline uint32_t CountMips(uint32_t width, uint32_t height) noexcept - { - if (width == 0 || height == 0) - return 0; - - uint32_t count = 1; - while (width > 1 || height > 1) - { - width >>= 1; - height >>= 1; - count++; - } - return count; - } - - //-------------------------------------------------------------------------------------- - DXGI_FORMAT MakeSRGB(_In_ DXGI_FORMAT format) noexcept - { - switch (format) - { - case DXGI_FORMAT_R8G8B8A8_UNORM: - return DXGI_FORMAT_R8G8B8A8_UNORM_SRGB; - - case DXGI_FORMAT_BC1_UNORM: - return DXGI_FORMAT_BC1_UNORM_SRGB; - - case DXGI_FORMAT_BC2_UNORM: - return DXGI_FORMAT_BC2_UNORM_SRGB; - - case DXGI_FORMAT_BC3_UNORM: - return DXGI_FORMAT_BC3_UNORM_SRGB; - - case DXGI_FORMAT_B8G8R8A8_UNORM: - return DXGI_FORMAT_B8G8R8A8_UNORM_SRGB; - - case DXGI_FORMAT_B8G8R8X8_UNORM: - return DXGI_FORMAT_B8G8R8X8_UNORM_SRGB; - - case DXGI_FORMAT_BC7_UNORM: - return DXGI_FORMAT_BC7_UNORM_SRGB; - - default: - return format; - } - } - - //--------------------------------------------------------------------------------- - DXGI_FORMAT WICToDXGI(const GUID& guid) noexcept - { - for (size_t i = 0; i < std::size(g_WICFormats); ++i) - { - if (memcmp(&g_WICFormats[i].wic, &guid, sizeof(GUID)) == 0) - return g_WICFormats[i].format; - } - - return DXGI_FORMAT_UNKNOWN; - } - - //--------------------------------------------------------------------------------- - size_t WICBitsPerPixel(REFGUID targetGuid) noexcept - { - auto pWIC = GetWIC(); - if (!pWIC) - return 0; - - ComPtr cinfo; - if (FAILED(pWIC->CreateComponentInfo(targetGuid, cinfo.GetAddressOf()))) - return 0; - - WICComponentType type; - if (FAILED(cinfo->GetComponentType(&type))) - return 0; - - if (type != WICPixelFormat) - return 0; - - ComPtr pfinfo; - if (FAILED(cinfo.As(&pfinfo))) - return 0; - - UINT bpp; - if (FAILED(pfinfo->GetBitsPerPixel(&bpp))) - return 0; - - return bpp; - } - - //--------------------------------------------------------------------------------- - void FitPowerOf2(UINT origx, UINT origy, UINT& targetx, UINT& targety, size_t maxsize) - { - const float origAR = float(origx) / float(origy); - - if (origx > origy) - { - size_t x; - for (x = maxsize; x > 1; x >>= 1) { if (x <= targetx) break; } - targetx = UINT(x); - - float bestScore = FLT_MAX; - for (size_t y = maxsize; y > 0; y >>= 1) - { - const float score = fabsf((float(x) / float(y)) - origAR); - if (score < bestScore) - { - bestScore = score; - targety = UINT(y); - } - } - } - else - { - size_t y; - for (y = maxsize; y > 1; y >>= 1) { if (y <= targety) break; } - targety = UINT(y); - - float bestScore = FLT_MAX; - for (size_t x = maxsize; x > 0; x >>= 1) - { - const float score = fabsf((float(x) / float(y)) - origAR); - if (score < bestScore) - { - bestScore = score; - targetx = UINT(x); - } - } - } - } - - //--------------------------------------------------------------------------------- - HRESULT CreateTextureFromWIC(_In_ ID3D12Device* d3dDevice, - _In_ IWICBitmapFrameDecode *frame, - size_t maxsize, - D3D12_RESOURCE_FLAGS resFlags, - unsigned int loadFlags, - _Outptr_ ID3D12Resource** texture, - std::unique_ptr& decodedData, - D3D12_SUBRESOURCE_DATA& subresource) noexcept - { - UINT width, height; - HRESULT hr = frame->GetSize(&width, &height); - if (FAILED(hr)) - return hr; - - assert(width > 0 && height > 0); - - if (maxsize > UINT32_MAX) - return E_INVALIDARG; - - if (!maxsize) - { - maxsize = size_t(D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION); - } - - UINT twidth = width; - UINT theight = height; - if (loadFlags & WIC_LOADER_FIT_POW2) - { - FitPowerOf2(width, height, twidth, theight, maxsize); - } - else if (width > maxsize || height > maxsize) - { - const float ar = static_cast(height) / static_cast(width); - if (width > height) - { - twidth = static_cast(maxsize); - theight = std::max(1, static_cast(static_cast(maxsize) * ar)); - } - else - { - theight = static_cast(maxsize); - twidth = std::max(1, static_cast(static_cast(maxsize) / ar)); - } - assert(twidth <= maxsize && theight <= maxsize); - } - - if (loadFlags & WIC_LOADER_MAKE_SQUARE) - { - twidth = std::max(twidth, theight); - theight = twidth; - } - - // Determine format - WICPixelFormatGUID pixelFormat; - hr = frame->GetPixelFormat(&pixelFormat); - if (FAILED(hr)) - return hr; - - WICPixelFormatGUID convertGUID; - memcpy_s(&convertGUID, sizeof(WICPixelFormatGUID), &pixelFormat, sizeof(GUID)); - - size_t bpp = 0; - - DXGI_FORMAT format = WICToDXGI(pixelFormat); - if (format == DXGI_FORMAT_UNKNOWN) - { - for (size_t i = 0; i < std::size(g_WICConvert); ++i) - { - if (memcmp(&g_WICConvert[i].source, &pixelFormat, sizeof(WICPixelFormatGUID)) == 0) - { - memcpy_s(&convertGUID, sizeof(WICPixelFormatGUID), &g_WICConvert[i].target, sizeof(GUID)); - - format = WICToDXGI(g_WICConvert[i].target); - assert(format != DXGI_FORMAT_UNKNOWN); - bpp = WICBitsPerPixel(convertGUID); - break; - } - } - - if (format == DXGI_FORMAT_UNKNOWN) - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - else - { - bpp = WICBitsPerPixel(pixelFormat); - } - - if (loadFlags & WIC_LOADER_FORCE_RGBA32) - { - memcpy_s(&convertGUID, sizeof(WICPixelFormatGUID), &GUID_WICPixelFormat32bppRGBA, sizeof(GUID)); - format = DXGI_FORMAT_R8G8B8A8_UNORM; - bpp = 32; - } - - if (!bpp) - return E_FAIL; - - // Handle sRGB formats - if (loadFlags & WIC_LOADER_FORCE_SRGB) - { - format = MakeSRGB(format); - } - else if (!(loadFlags & WIC_LOADER_IGNORE_SRGB)) - { - ComPtr metareader; - if (SUCCEEDED(frame->GetMetadataQueryReader(metareader.GetAddressOf()))) - { - GUID containerFormat; - if (SUCCEEDED(metareader->GetContainerFormat(&containerFormat))) - { - bool sRGB = false; - - PROPVARIANT value; - PropVariantInit(&value); - - // Check for colorspace chunks - if (memcmp(&containerFormat, &GUID_ContainerFormatPng, sizeof(GUID)) == 0) - { - if (SUCCEEDED(metareader->GetMetadataByName(L"/sRGB/RenderingIntent", &value)) && value.vt == VT_UI1) - { - sRGB = true; - } - else if (SUCCEEDED(metareader->GetMetadataByName(L"/gAMA/ImageGamma", &value)) && value.vt == VT_UI4) - { - sRGB = (value.uintVal == 45455); - } - else - { - sRGB = (loadFlags & WIC_LOADER_SRGB_DEFAULT) != 0; - } - } - else if (SUCCEEDED(metareader->GetMetadataByName(L"System.Image.ColorSpace", &value)) && value.vt == VT_UI2) - { - sRGB = (value.uiVal == 1); - } - else - { - sRGB = (loadFlags & WIC_LOADER_SRGB_DEFAULT) != 0; - } - - std::ignore = PropVariantClear(&value); - - if (sRGB) - format = MakeSRGB(format); - } - } - } - - // Allocate memory for decoded image - const uint64_t rowBytes = (uint64_t(twidth) * uint64_t(bpp) + 7u) / 8u; - const uint64_t numBytes = rowBytes * uint64_t(theight); - - if (rowBytes > UINT32_MAX || numBytes > UINT32_MAX) - return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); - - auto const rowPitch = static_cast(rowBytes); - auto const imageSize = static_cast(numBytes); - - decodedData.reset(new (std::nothrow) uint8_t[imageSize]); - if (!decodedData) - return E_OUTOFMEMORY; - - // Load image data - if (memcmp(&convertGUID, &pixelFormat, sizeof(GUID)) == 0 - && twidth == width - && theight == height) - { - // No format conversion or resize needed - hr = frame->CopyPixels(nullptr, static_cast(rowPitch), static_cast(imageSize), decodedData.get()); - if (FAILED(hr)) - return hr; - } - else if (twidth != width || theight != height) - { - // Resize - auto pWIC = GetWIC(); - if (!pWIC) - return E_NOINTERFACE; - - ComPtr scaler; - hr = pWIC->CreateBitmapScaler(scaler.GetAddressOf()); - if (FAILED(hr)) - return hr; - - hr = scaler->Initialize(frame, twidth, theight, WICBitmapInterpolationModeFant); - if (FAILED(hr)) - return hr; - - WICPixelFormatGUID pfScaler; - hr = scaler->GetPixelFormat(&pfScaler); - if (FAILED(hr)) - return hr; - - if (memcmp(&convertGUID, &pfScaler, sizeof(GUID)) == 0) - { - // No format conversion needed - hr = scaler->CopyPixels(nullptr, static_cast(rowPitch), static_cast(imageSize), decodedData.get()); - if (FAILED(hr)) - return hr; - } - else - { - ComPtr FC; - hr = pWIC->CreateFormatConverter(FC.GetAddressOf()); - if (FAILED(hr)) - return hr; - - BOOL canConvert = FALSE; - hr = FC->CanConvert(pfScaler, convertGUID, &canConvert); - if (FAILED(hr) || !canConvert) - { - return E_UNEXPECTED; - } - - hr = FC->Initialize(scaler.Get(), convertGUID, WICBitmapDitherTypeErrorDiffusion, nullptr, 0, WICBitmapPaletteTypeMedianCut); - if (FAILED(hr)) - return hr; - - hr = FC->CopyPixels(nullptr, static_cast(rowPitch), static_cast(imageSize), decodedData.get()); - if (FAILED(hr)) - return hr; - } - } - else - { - // Format conversion but no resize - auto pWIC = GetWIC(); - if (!pWIC) - return E_NOINTERFACE; - - ComPtr FC; - hr = pWIC->CreateFormatConverter(FC.GetAddressOf()); - if (FAILED(hr)) - return hr; - - BOOL canConvert = FALSE; - hr = FC->CanConvert(pixelFormat, convertGUID, &canConvert); - if (FAILED(hr) || !canConvert) - { - return E_UNEXPECTED; - } - - hr = FC->Initialize(frame, convertGUID, WICBitmapDitherTypeErrorDiffusion, nullptr, 0, WICBitmapPaletteTypeMedianCut); - if (FAILED(hr)) - return hr; - - hr = FC->CopyPixels(nullptr, static_cast(rowPitch), static_cast(imageSize), decodedData.get()); - if (FAILED(hr)) - return hr; - } - - // Count the number of mips - const uint32_t mipCount = (loadFlags & (WIC_LOADER_MIP_AUTOGEN | WIC_LOADER_MIP_RESERVE)) - ? CountMips(twidth, theight) : 1u; - - // Create texture - D3D12_RESOURCE_DESC desc = {}; - desc.Width = twidth; - desc.Height = theight; - desc.MipLevels = static_cast(mipCount); - desc.DepthOrArraySize = 1; - desc.Format = format; - desc.SampleDesc.Count = 1; - desc.SampleDesc.Quality = 0; - desc.Flags = resFlags; - desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; - - const CD3DX12_HEAP_PROPERTIES defaultHeapProperties(D3D12_HEAP_TYPE_DEFAULT); - - ID3D12Resource* tex = nullptr; - hr = d3dDevice->CreateCommittedResource( - &defaultHeapProperties, - D3D12_HEAP_FLAG_NONE, - &desc, - D3D12_RESOURCE_STATE_COPY_DEST, - nullptr, - IID_ID3D12Resource, - reinterpret_cast(&tex)); - - if (FAILED(hr)) - { - return hr; - } - - _Analysis_assume_(tex != nullptr); - - subresource.pData = decodedData.get(); - subresource.RowPitch = static_cast(rowPitch); - subresource.SlicePitch = static_cast(imageSize); - - *texture = tex; - return hr; - } - - //-------------------------------------------------------------------------------------- - void SetDebugTextureInfo( - _In_z_ const wchar_t* fileName, - _In_ ID3D12Resource** texture) noexcept - { - #if !defined(NO_D3D12_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) ) - if (texture && *texture) - { - const wchar_t* pstrName = wcsrchr(fileName, '\\'); - if (!pstrName) - { - pstrName = fileName; - } - else - { - pstrName++; - } - - (*texture)->SetName(pstrName); - } - #else - UNREFERENCED_PARAMETER(fileName); - UNREFERENCED_PARAMETER(texture); - #endif - } -} // anonymous namespace - - -//-------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::LoadWICTextureFromMemory( - ID3D12Device* d3dDevice, - const uint8_t* wicData, - size_t wicDataSize, - ID3D12Resource** texture, - std::unique_ptr& decodedData, - D3D12_SUBRESOURCE_DATA& subresource, - size_t maxsize) noexcept -{ - return LoadWICTextureFromMemoryEx( - d3dDevice, - wicData, - wicDataSize, - maxsize, - D3D12_RESOURCE_FLAG_NONE, - WIC_LOADER_DEFAULT, - texture, - decodedData, - subresource); -} - - -//-------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::LoadWICTextureFromMemoryEx( - ID3D12Device* d3dDevice, - const uint8_t* wicData, - size_t wicDataSize, - size_t maxsize, - D3D12_RESOURCE_FLAGS resFlags, - WIC_LOADER_FLAGS loadFlags, - ID3D12Resource** texture, - std::unique_ptr& decodedData, - D3D12_SUBRESOURCE_DATA& subresource) noexcept -{ - if (texture) - { - *texture = nullptr; - } - - if (!d3dDevice || !wicData || !texture) - return E_INVALIDARG; - - if (!wicDataSize) - return E_FAIL; - - if (wicDataSize > UINT32_MAX) - return HRESULT_FROM_WIN32(ERROR_FILE_TOO_LARGE); - - auto pWIC = GetWIC(); - if (!pWIC) - return E_NOINTERFACE; - - // Create input stream for memory - ComPtr stream; - HRESULT hr = pWIC->CreateStream(stream.GetAddressOf()); - if (FAILED(hr)) - return hr; - - hr = stream->InitializeFromMemory(const_cast(wicData), static_cast(wicDataSize)); - if (FAILED(hr)) - return hr; - - // Initialize WIC - ComPtr decoder; - hr = pWIC->CreateDecoderFromStream(stream.Get(), nullptr, WICDecodeMetadataCacheOnDemand, decoder.GetAddressOf()); - if (FAILED(hr)) - return hr; - - ComPtr frame; - hr = decoder->GetFrame(0, frame.GetAddressOf()); - if (FAILED(hr)) - return hr; - - hr = CreateTextureFromWIC(d3dDevice, - frame.Get(), maxsize, - resFlags, loadFlags, - texture, decodedData, subresource); - if (FAILED(hr)) - return hr; - - _Analysis_assume_(*texture != nullptr); - SetDebugObjectName(*texture, L"WICTextureLoader"); - - return hr; -} - - -//-------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::LoadWICTextureFromFile( - ID3D12Device* d3dDevice, - const wchar_t* fileName, - ID3D12Resource** texture, - std::unique_ptr& wicData, - D3D12_SUBRESOURCE_DATA& subresource, - size_t maxsize) noexcept -{ - return LoadWICTextureFromFileEx( - d3dDevice, - fileName, - maxsize, - D3D12_RESOURCE_FLAG_NONE, - WIC_LOADER_DEFAULT, - texture, - wicData, - subresource); -} - - -//-------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::LoadWICTextureFromFileEx( - ID3D12Device* d3dDevice, - const wchar_t* fileName, - size_t maxsize, - D3D12_RESOURCE_FLAGS resFlags, - WIC_LOADER_FLAGS loadFlags, - ID3D12Resource** texture, - std::unique_ptr& decodedData, - D3D12_SUBRESOURCE_DATA& subresource) noexcept -{ - if (texture) - { - *texture = nullptr; - } - - if (!d3dDevice || !fileName || !texture) - return E_INVALIDARG; - - auto pWIC = GetWIC(); - if (!pWIC) - return E_NOINTERFACE; - - // Initialize WIC - ComPtr decoder; - HRESULT hr = pWIC->CreateDecoderFromFilename(fileName, - nullptr, - GENERIC_READ, - WICDecodeMetadataCacheOnDemand, - decoder.GetAddressOf()); - if (FAILED(hr)) - return hr; - - ComPtr frame; - hr = decoder->GetFrame(0, frame.GetAddressOf()); - if (FAILED(hr)) - return hr; - - hr = CreateTextureFromWIC(d3dDevice, frame.Get(), maxsize, - resFlags, loadFlags, - texture, decodedData, subresource); - - if (SUCCEEDED(hr)) - { - SetDebugTextureInfo(fileName, texture); - } - - return hr; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/WICTextureLoader/WICTextureLoader12.h b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/WICTextureLoader/WICTextureLoader12.h deleted file mode 100644 index 54d8b8a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/WICTextureLoader/WICTextureLoader12.h +++ /dev/null @@ -1,114 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: WICTextureLoader12.h -// -// Function for loading a WIC image and creating a Direct3D runtime texture for it -// (auto-generating mipmaps if possible) -// -// Note: Assumes application has already called CoInitializeEx -// -// Note these functions are useful for images created as simple 2D textures. For -// more complex resources, DDSTextureLoader is an excellent light-weight runtime loader. -// For a full-featured DDS file reader, writer, and texture processing pipeline see -// the 'Texconv' sample and the 'DirectXTex' library. -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -// http://go.microsoft.com/fwlink/?LinkID=615561 -//-------------------------------------------------------------------------------------- - -#pragma once - -#ifndef _WIN32 -#error This module only supports Windows -#endif - -#ifdef __MINGW32__ -#include -#endif - -#ifdef USING_DIRECTX_HEADERS -#include -#include -#else -#include -#pragma comment(lib,"dxguid.lib") -#endif - -#pragma comment(lib,"windowscodecs.lib") - -#include -#include -#include - - -namespace DirectX -{ -#ifndef WIC_LOADER_FLAGS_DEFINED -#define WIC_LOADER_FLAGS_DEFINED - enum WIC_LOADER_FLAGS : uint32_t - { - WIC_LOADER_DEFAULT = 0, - WIC_LOADER_FORCE_SRGB = 0x1, - WIC_LOADER_IGNORE_SRGB = 0x2, - WIC_LOADER_SRGB_DEFAULT = 0x4, - WIC_LOADER_MIP_AUTOGEN = 0x8, - WIC_LOADER_MIP_RESERVE = 0x10, - WIC_LOADER_FIT_POW2 = 0x20, - WIC_LOADER_MAKE_SQUARE = 0x40, - WIC_LOADER_FORCE_RGBA32 = 0x80, - }; - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-dynamic-exception-spec" -#endif - - DEFINE_ENUM_FLAG_OPERATORS(WIC_LOADER_FLAGS); - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif -#endif - - // Standard version - HRESULT __cdecl LoadWICTextureFromMemory( - _In_ ID3D12Device* d3dDevice, - _In_reads_bytes_(wicDataSize) const uint8_t* wicData, - size_t wicDataSize, - _Outptr_ ID3D12Resource** texture, - std::unique_ptr& decodedData, - D3D12_SUBRESOURCE_DATA& subresource, - size_t maxsize = 0) noexcept; - - HRESULT __cdecl LoadWICTextureFromFile( - _In_ ID3D12Device* d3dDevice, - _In_z_ const wchar_t* szFileName, - _Outptr_ ID3D12Resource** texture, - std::unique_ptr& decodedData, - D3D12_SUBRESOURCE_DATA& subresource, - size_t maxsize = 0) noexcept; - - // Extended version - HRESULT __cdecl LoadWICTextureFromMemoryEx( - _In_ ID3D12Device* d3dDevice, - _In_reads_bytes_(wicDataSize) const uint8_t* wicData, - size_t wicDataSize, - size_t maxsize, - D3D12_RESOURCE_FLAGS resFlags, - WIC_LOADER_FLAGS loadFlags, - _Outptr_ ID3D12Resource** texture, - std::unique_ptr& decodedData, - D3D12_SUBRESOURCE_DATA& subresource) noexcept; - - HRESULT __cdecl LoadWICTextureFromFileEx( - _In_ ID3D12Device* d3dDevice, - _In_z_ const wchar_t* szFileName, - size_t maxsize, - D3D12_RESOURCE_FLAGS resFlags, - WIC_LOADER_FLAGS loadFlags, - _Outptr_ ID3D12Resource** texture, - std::unique_ptr& decodedData, - D3D12_SUBRESOURCE_DATA& subresource) noexcept; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/WICTextureLoader/WICTextureLoader9.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/WICTextureLoader/WICTextureLoader9.cpp deleted file mode 100644 index af646eb..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/WICTextureLoader/WICTextureLoader9.cpp +++ /dev/null @@ -1,652 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: WICTextureLoader9.cpp -// -// Function for loading a WIC image and creating a Direct3D runtime texture for it -// -// Note: Assumes application has already called CoInitializeEx -// -// Note these functions are useful for images created as simple 2D textures. For -// more complex resources, DDSTextureLoader is an excellent light-weight runtime loader. -// For a full-featured DDS file reader, writer, and texture processing pipeline see -// the 'Texconv' sample and the 'DirectXTex' library. -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -// http://go.microsoft.com/fwlink/?LinkId=248929 -//-------------------------------------------------------------------------------------- - -// We could load multi-frame images (TIFF/GIF) into a texture array. -// For now, we just load the first frame (note: DirectXTex supports multi-frame images) - -#include "WICTextureLoader9.h" - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#ifdef _MSC_VER -// Off by default warnings -#pragma warning(disable : 4619 4616 4061 4623 4626 5027) -// C4619/4616 #pragma warning warnings -// C4061 enumerator 'x' in switch of enum 'y' is not explicitly handled by a case label -// C4623 default constructor was implicitly defined as deleted -// C4626 assignment operator was implicitly defined as deleted -// C5027 move assignment operator was implicitly defined as deleted -#endif - -#ifdef __clang__ -#pragma clang diagnostic ignored "-Wcovered-switch-default" -#pragma clang diagnostic ignored "-Wswitch-enum" -#endif - -using namespace DirectX; -using Microsoft::WRL::ComPtr; - -namespace -{ - //------------------------------------------------------------------------------------- - // WIC Pixel Format Translation Data - //------------------------------------------------------------------------------------- - struct WICTranslate - { - const GUID& wic; - D3DFORMAT format; - }; - - constexpr WICTranslate g_WICFormats[] = - { - { GUID_WICPixelFormat128bppRGBAFloat, D3DFMT_A32B32G32R32F }, - - { GUID_WICPixelFormat64bppRGBAHalf, D3DFMT_A16B16G16R16F }, - { GUID_WICPixelFormat64bppRGBA, D3DFMT_A16B16G16R16 }, - - { GUID_WICPixelFormat32bppBGRA, D3DFMT_A8R8G8B8 }, - - { GUID_WICPixelFormat32bppRGBA1010102, D3DFMT_A2B10G10R10 }, - - { GUID_WICPixelFormat16bppBGRA5551, D3DFMT_A1R5G5B5 }, - { GUID_WICPixelFormat16bppBGR555, D3DFMT_X1R5G5B5 }, - { GUID_WICPixelFormat16bppBGR565, D3DFMT_R5G6B5 }, - - { GUID_WICPixelFormat32bppGrayFloat, D3DFMT_R32F }, - { GUID_WICPixelFormat16bppGrayHalf, D3DFMT_R16F }, - { GUID_WICPixelFormat16bppGray, D3DFMT_L16 }, - { GUID_WICPixelFormat8bppGray, D3DFMT_L8 }, - - { GUID_WICPixelFormat8bppAlpha, D3DFMT_A8 }, - }; - - //------------------------------------------------------------------------------------- - // WIC Pixel Format nearest conversion table - //------------------------------------------------------------------------------------- - struct WICConvert - { - const GUID& source; - const GUID& target; - }; - - constexpr WICConvert g_WICConvert[] = - { - // Note target GUID in this conversion table must be one of those directly supported formats (above). - - { GUID_WICPixelFormatBlackWhite, GUID_WICPixelFormat8bppGray }, // D3DFMT_L8 - - { GUID_WICPixelFormat1bppIndexed, GUID_WICPixelFormat32bppBGRA }, // D3DFMT_A8R8G8B8 - { GUID_WICPixelFormat2bppIndexed, GUID_WICPixelFormat32bppBGRA }, // D3DFMT_A8R8G8B8 - { GUID_WICPixelFormat4bppIndexed, GUID_WICPixelFormat32bppBGRA }, // D3DFMT_A8R8G8B8 - { GUID_WICPixelFormat8bppIndexed, GUID_WICPixelFormat32bppBGRA }, // D3DFMT_A8R8G8B8 - - { GUID_WICPixelFormat2bppGray, GUID_WICPixelFormat8bppGray }, // D3DFMT_L8 - { GUID_WICPixelFormat4bppGray, GUID_WICPixelFormat8bppGray }, // D3DFMT_L8 - - { GUID_WICPixelFormat16bppGrayFixedPoint, GUID_WICPixelFormat16bppGrayHalf }, // D3DFMT_R16F - { GUID_WICPixelFormat32bppGrayFixedPoint, GUID_WICPixelFormat32bppGrayFloat }, // D3DFMT_R32F - - { GUID_WICPixelFormat32bppBGR101010, GUID_WICPixelFormat32bppRGBA1010102 }, // D3DFMT_A2B10G10R10 - - { GUID_WICPixelFormat24bppBGR, GUID_WICPixelFormat32bppBGRA }, // D3DFMT_A8R8G8B8 - { GUID_WICPixelFormat24bppRGB, GUID_WICPixelFormat32bppBGRA }, // D3DFMT_A8R8G8B8 - { GUID_WICPixelFormat32bppBGR, GUID_WICPixelFormat32bppBGRA }, // D3DFMT_A8R8G8B8 - { GUID_WICPixelFormat32bppRGBA, GUID_WICPixelFormat32bppBGRA }, // D3DFMT_A8R8G8B8 - { GUID_WICPixelFormat32bppPBGRA, GUID_WICPixelFormat32bppBGRA }, // D3DFMT_A8R8G8B8 - { GUID_WICPixelFormat32bppPRGBA, GUID_WICPixelFormat32bppBGRA }, // D3DFMT_A8R8G8B8 - - { GUID_WICPixelFormat48bppRGB, GUID_WICPixelFormat64bppRGBA }, // D3DFMT_A16B16G16R16 - { GUID_WICPixelFormat48bppBGR, GUID_WICPixelFormat64bppRGBA }, // D3DFMT_A16B16G16R16 - { GUID_WICPixelFormat64bppBGRA, GUID_WICPixelFormat64bppRGBA }, // D3DFMT_A16B16G16R16 - { GUID_WICPixelFormat64bppPRGBA, GUID_WICPixelFormat64bppRGBA }, // D3DFMT_A16B16G16R16 - { GUID_WICPixelFormat64bppPBGRA, GUID_WICPixelFormat64bppRGBA }, // D3DFMT_A16B16G16R16 - - { GUID_WICPixelFormat48bppRGBFixedPoint, GUID_WICPixelFormat64bppRGBAHalf }, // D3DFMT_A16B16G16R16F - { GUID_WICPixelFormat48bppBGRFixedPoint, GUID_WICPixelFormat64bppRGBAHalf }, // D3DFMT_A16B16G16R16F - { GUID_WICPixelFormat64bppRGBAFixedPoint, GUID_WICPixelFormat64bppRGBAHalf }, // D3DFMT_A16B16G16R16F - { GUID_WICPixelFormat64bppBGRAFixedPoint, GUID_WICPixelFormat64bppRGBAHalf }, // D3DFMT_A16B16G16R16F - { GUID_WICPixelFormat64bppRGBFixedPoint, GUID_WICPixelFormat64bppRGBAHalf }, // D3DFMT_A16B16G16R16F - { GUID_WICPixelFormat64bppRGBHalf, GUID_WICPixelFormat64bppRGBAHalf }, // D3DFMT_A16B16G16R16F - { GUID_WICPixelFormat48bppRGBHalf, GUID_WICPixelFormat64bppRGBAHalf }, // D3DFMT_A16B16G16R16F - - { GUID_WICPixelFormat128bppPRGBAFloat, GUID_WICPixelFormat128bppRGBAFloat }, // D3DFMT_A32B32G32R32F - { GUID_WICPixelFormat128bppRGBFloat, GUID_WICPixelFormat128bppRGBAFloat }, // D3DFMT_A32B32G32R32F - { GUID_WICPixelFormat128bppRGBAFixedPoint, GUID_WICPixelFormat128bppRGBAFloat }, // D3DFMT_A32B32G32R32F - { GUID_WICPixelFormat128bppRGBFixedPoint, GUID_WICPixelFormat128bppRGBAFloat }, // D3DFMT_A32B32G32R32F - { GUID_WICPixelFormat32bppRGBE, GUID_WICPixelFormat128bppRGBAFloat }, // D3DFMT_A32B32G32R32F - - { GUID_WICPixelFormat32bppCMYK, GUID_WICPixelFormat32bppBGRA }, // D3DFMT_A8R8G8B8 - { GUID_WICPixelFormat64bppCMYK, GUID_WICPixelFormat64bppRGBA }, // D3DFMT_A16B16G16R16 - { GUID_WICPixelFormat40bppCMYKAlpha, GUID_WICPixelFormat32bppBGRA }, // D3DFMT_A8R8G8B8 - { GUID_WICPixelFormat80bppCMYKAlpha, GUID_WICPixelFormat64bppRGBA }, // D3DFMT_A16B16G16R16 - - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE) - { GUID_WICPixelFormat32bppRGB, GUID_WICPixelFormat32bppBGRA }, // D3DFMT_A8R8G8B8 - { GUID_WICPixelFormat64bppRGB, GUID_WICPixelFormat64bppRGBA }, // D3DFMT_A16B16G16R16 - { GUID_WICPixelFormat64bppPRGBAHalf, GUID_WICPixelFormat64bppRGBAHalf }, // D3DFMT_A16B16G16R16F - { GUID_WICPixelFormat96bppRGBFloat, GUID_WICPixelFormat128bppRGBAFloat }, // D3DFMT_A32B32G32R32F - #endif - - // We don't support n-channel formats - }; - - bool g_WIC2 = false; - - //-------------------------------------------------------------------------------------- - BOOL WINAPI InitializeWICFactory(PINIT_ONCE, PVOID, PVOID* ifactory) noexcept - { - #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE) - HRESULT hr = CoCreateInstance( - CLSID_WICImagingFactory2, - nullptr, - CLSCTX_INPROC_SERVER, - __uuidof(IWICImagingFactory2), - ifactory - ); - - if (SUCCEEDED(hr)) - { - // WIC2 is available on Windows 10, Windows 8.x, and Windows 7 SP1 with KB 2670838 installed - g_WIC2 = true; - return TRUE; - } - else - { - hr = CoCreateInstance( - CLSID_WICImagingFactory1, - nullptr, - CLSCTX_INPROC_SERVER, - __uuidof(IWICImagingFactory), - ifactory - ); - return SUCCEEDED(hr) ? TRUE : FALSE; - } - #else - return SUCCEEDED(CoCreateInstance( - CLSID_WICImagingFactory, - nullptr, - CLSCTX_INPROC_SERVER, - __uuidof(IWICImagingFactory), - ifactory)) ? TRUE : FALSE; - #endif - } - - IWICImagingFactory* GetWIC() noexcept - { - static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT; - - IWICImagingFactory* factory = nullptr; - if (!InitOnceExecuteOnce( - &s_initOnce, - InitializeWICFactory, - nullptr, - reinterpret_cast(&factory))) - { - return nullptr; - } - - return factory; - } - - //--------------------------------------------------------------------------------- - D3DFORMAT WICToD3D9(const GUID& guid) noexcept - { - for (size_t i = 0; i < std::size(g_WICFormats); ++i) - { - if (memcmp(&g_WICFormats[i].wic, &guid, sizeof(GUID)) == 0) - return g_WICFormats[i].format; - } - - return D3DFMT_UNKNOWN; - } - - //--------------------------------------------------------------------------------- - void FitPowerOf2(UINT origx, UINT origy, UINT& targetx, UINT& targety, size_t maxsize) - { - const float origAR = float(origx) / float(origy); - - if (origx > origy) - { - size_t x; - for (x = maxsize; x > 1; x >>= 1) { if (x <= targetx) break; } - targetx = UINT(x); - - float bestScore = FLT_MAX; - for (size_t y = maxsize; y > 0; y >>= 1) - { - const float score = fabsf((float(x) / float(y)) - origAR); - if (score < bestScore) - { - bestScore = score; - targety = UINT(y); - } - } - } - else - { - size_t y; - for (y = maxsize; y > 1; y >>= 1) { if (y <= targety) break; } - targety = UINT(y); - - float bestScore = FLT_MAX; - for (size_t x = maxsize; x > 0; x >>= 1) - { - const float score = fabsf((float(x) / float(y)) - origAR); - if (score < bestScore) - { - bestScore = score; - targetx = UINT(x); - } - } - } - } - - //--------------------------------------------------------------------------------- - HRESULT CreateTextureFromWIC( - _In_ LPDIRECT3DDEVICE9 device, - _In_ IWICBitmapFrameDecode* frame, - _In_ size_t maxsize, - _In_ DWORD usage, - _In_ D3DPOOL pool, - _In_ WIC_LOADER_FLAGS loadFlags, - _Outptr_ LPDIRECT3DTEXTURE9* texture) noexcept - { - UINT width, height; - HRESULT hr = frame->GetSize(&width, &height); - if (FAILED(hr)) - return hr; - - if (maxsize > UINT32_MAX) - return E_INVALIDARG; - - assert(width > 0 && height > 0); - - if (!maxsize) - { - maxsize = 4096u /*D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION*/; - } - - assert(maxsize > 0); - - UINT twidth = width; - UINT theight = height; - if (loadFlags & WIC_LOADER_FIT_POW2) - { - FitPowerOf2(width, height, twidth, theight, maxsize); - } - else if (width > maxsize || height > maxsize) - { - const float ar = static_cast(height) / static_cast(width); - if (width > height) - { - twidth = static_cast(maxsize); - theight = std::max(1, static_cast(static_cast(maxsize) * ar)); - } - else - { - theight = static_cast(maxsize); - twidth = std::max(1, static_cast(static_cast(maxsize) / ar)); - } - assert(twidth <= maxsize && theight <= maxsize); - } - - if (loadFlags & WIC_LOADER_MAKE_SQUARE) - { - twidth = std::max(twidth, theight); - theight = twidth; - } - - // Determine format - WICPixelFormatGUID pixelFormat; - hr = frame->GetPixelFormat(&pixelFormat); - if (FAILED(hr)) - return hr; - - WICPixelFormatGUID convertGUID; - memcpy_s(&convertGUID, sizeof(WICPixelFormatGUID), &pixelFormat, sizeof(GUID)); - - D3DFORMAT format = WICToD3D9(pixelFormat); - if (format == D3DFMT_UNKNOWN) - { - for (size_t i = 0; i < std::size(g_WICConvert); ++i) - { - if (memcmp(&g_WICConvert[i].source, &pixelFormat, sizeof(WICPixelFormatGUID)) == 0) - { - memcpy_s(&convertGUID, sizeof(WICPixelFormatGUID), &g_WICConvert[i].target, sizeof(GUID)); - - format = WICToD3D9(g_WICConvert[i].target); - assert(format != D3DFMT_UNKNOWN); - break; - } - } - - if (format == D3DFMT_UNKNOWN) - return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED); - } - - if (loadFlags & WIC_LOADER_FORCE_RGBA32) - { - memcpy_s(&convertGUID, sizeof(WICPixelFormatGUID), &GUID_WICPixelFormat32bppBGRA, sizeof(GUID)); - format = D3DFMT_A8R8G8B8; - } - - // Create texture - if (loadFlags & WIC_LOADER_MIP_AUTOGEN) - usage |= D3DUSAGE_AUTOGENMIPMAP; - - ComPtr pTexture; - hr = device->CreateTexture(twidth, theight, 1u, - usage, format, pool, - pTexture.GetAddressOf(), nullptr); - if (FAILED(hr)) - return hr; - - // Create staging texture memory - ComPtr pStagingTexture; - if (pool == D3DPOOL_DEFAULT) - { - hr = device->CreateTexture(twidth, theight, 1u, - 0u, format, D3DPOOL_SYSTEMMEM, - pStagingTexture.GetAddressOf(), nullptr); - if (FAILED(hr)) - return hr; - } - else - { - pStagingTexture = pTexture; - } - - D3DLOCKED_RECT LockedRect = {}; - hr = pStagingTexture->LockRect(0, &LockedRect, nullptr, 0); - if (FAILED(hr)) - return hr; - - const uint64_t numBytes = uint64_t(LockedRect.Pitch) * uint64_t(theight); - - pStagingTexture->UnlockRect(0); - - if (numBytes > UINT32_MAX) - { - return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW); - } - - // Load image data - if (memcmp(&convertGUID, &pixelFormat, sizeof(GUID)) == 0 - && twidth == width - && theight == height) - { - // No format conversion or resize needed - hr = pStagingTexture->LockRect(0, &LockedRect, nullptr, 0); - if (FAILED(hr)) - return hr; - - hr = frame->CopyPixels(nullptr, static_cast(LockedRect.Pitch), static_cast(numBytes), - static_cast(LockedRect.pBits)); - - pStagingTexture->UnlockRect(0); - - if (FAILED(hr)) - return hr; - } - else if (twidth != width || theight != height) - { - // Resize - auto pWIC = GetWIC(); - if (!pWIC) - return E_NOINTERFACE; - - ComPtr scaler; - hr = pWIC->CreateBitmapScaler(scaler.GetAddressOf()); - if (FAILED(hr)) - return hr; - - hr = scaler->Initialize(frame, twidth, theight, WICBitmapInterpolationModeFant); - if (FAILED(hr)) - return hr; - - WICPixelFormatGUID pfScaler; - hr = scaler->GetPixelFormat(&pfScaler); - if (FAILED(hr)) - return hr; - - if (memcmp(&convertGUID, &pfScaler, sizeof(GUID)) == 0) - { - // No format conversion needed - hr = pStagingTexture->LockRect(0, &LockedRect, nullptr, 0); - if (FAILED(hr)) - return hr; - - hr = scaler->CopyPixels(nullptr, static_cast(LockedRect.Pitch), static_cast(numBytes), - static_cast(LockedRect.pBits)); - - pStagingTexture->UnlockRect(0); - - if (FAILED(hr)) - return hr; - } - else - { - ComPtr FC; - hr = pWIC->CreateFormatConverter(FC.GetAddressOf()); - if (FAILED(hr)) - return hr; - - BOOL canConvert = FALSE; - hr = FC->CanConvert(pfScaler, convertGUID, &canConvert); - if (FAILED(hr) || !canConvert) - { - return E_UNEXPECTED; - } - - hr = FC->Initialize(scaler.Get(), convertGUID, WICBitmapDitherTypeErrorDiffusion, nullptr, 0, WICBitmapPaletteTypeMedianCut); - if (FAILED(hr)) - return hr; - - hr = pStagingTexture->LockRect(0, &LockedRect, nullptr, 0); - if (FAILED(hr)) - return hr; - - hr = FC->CopyPixels(nullptr, static_cast(LockedRect.Pitch), static_cast(numBytes), - static_cast(LockedRect.pBits)); - - pStagingTexture->UnlockRect(0); - - if (FAILED(hr)) - return hr; - } - } - else - { - // Format conversion but no resize - auto pWIC = GetWIC(); - if (!pWIC) - return E_NOINTERFACE; - - ComPtr FC; - hr = pWIC->CreateFormatConverter(FC.GetAddressOf()); - if (FAILED(hr)) - return hr; - - BOOL canConvert = FALSE; - hr = FC->CanConvert(pixelFormat, convertGUID, &canConvert); - if (FAILED(hr) || !canConvert) - { - return E_UNEXPECTED; - } - - hr = FC->Initialize(frame, convertGUID, WICBitmapDitherTypeErrorDiffusion, nullptr, 0, WICBitmapPaletteTypeMedianCut); - if (FAILED(hr)) - return hr; - - hr = pStagingTexture->LockRect(0, &LockedRect, nullptr, 0); - if (FAILED(hr)) - return hr; - - hr = FC->CopyPixels(nullptr, static_cast(LockedRect.Pitch), static_cast(numBytes), - static_cast(LockedRect.pBits)); - - pStagingTexture->UnlockRect(0); - - if (FAILED(hr)) - return hr; - } - - if (pool == D3DPOOL_DEFAULT) - { - hr = device->UpdateTexture(pStagingTexture.Get(), pTexture.Get()); - if (FAILED(hr)) - return hr; - } - - *texture = pTexture.Detach(); - - return S_OK; - } -} // anonymous namespace - -//-------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::CreateWICTextureFromMemory( - LPDIRECT3DDEVICE9 d3dDevice, - const uint8_t* wicData, - size_t wicDataSize, - LPDIRECT3DTEXTURE9* texture, - size_t maxsize, - WIC_LOADER_FLAGS loadFlags) noexcept -{ - return CreateWICTextureFromMemoryEx(d3dDevice, wicData, wicDataSize, maxsize, 0u, D3DPOOL_DEFAULT, loadFlags, texture); -} - - -_Use_decl_annotations_ -HRESULT DirectX::CreateWICTextureFromMemoryEx( - LPDIRECT3DDEVICE9 d3dDevice, - const uint8_t* wicData, - size_t wicDataSize, - _In_ size_t maxsize, - _In_ DWORD usage, - _In_ D3DPOOL pool, - _In_ WIC_LOADER_FLAGS loadFlags, - LPDIRECT3DTEXTURE9* texture) noexcept -{ - if (texture) - { - *texture = nullptr; - } - - if (!d3dDevice || !wicData || !wicDataSize || !texture) - return E_INVALIDARG; - - if (!wicDataSize) - return E_FAIL; - - if (wicDataSize > UINT32_MAX) - return HRESULT_FROM_WIN32(ERROR_FILE_TOO_LARGE); - - auto pWIC = GetWIC(); - if (!pWIC) - return E_NOINTERFACE; - - // Create input stream for memory - ComPtr stream; - HRESULT hr = pWIC->CreateStream(stream.GetAddressOf()); - if (FAILED(hr)) - return hr; - - hr = stream->InitializeFromMemory(const_cast(wicData), static_cast(wicDataSize)); - if (FAILED(hr)) - return hr; - - // Initialize WIC - ComPtr decoder; - hr = pWIC->CreateDecoderFromStream(stream.Get(), nullptr, WICDecodeMetadataCacheOnDemand, decoder.GetAddressOf()); - if (FAILED(hr)) - return hr; - - ComPtr frame; - hr = decoder->GetFrame(0, frame.GetAddressOf()); - if (FAILED(hr)) - return hr; - - return CreateTextureFromWIC(d3dDevice, frame.Get(), maxsize, usage, pool, loadFlags, texture); -} - -//-------------------------------------------------------------------------------------- -_Use_decl_annotations_ -HRESULT DirectX::CreateWICTextureFromFile( - LPDIRECT3DDEVICE9 d3dDevice, - const wchar_t* fileName, - LPDIRECT3DTEXTURE9* texture, - size_t maxsize, - WIC_LOADER_FLAGS loadFlags) noexcept -{ - return CreateWICTextureFromFileEx(d3dDevice, fileName, maxsize, 0u, D3DPOOL_DEFAULT, loadFlags, texture); -} - -_Use_decl_annotations_ -HRESULT DirectX::CreateWICTextureFromFileEx( - LPDIRECT3DDEVICE9 d3dDevice, - const wchar_t* fileName, - size_t maxsize, - DWORD usage, - D3DPOOL pool, - WIC_LOADER_FLAGS loadFlags, - LPDIRECT3DTEXTURE9* texture) noexcept -{ - if (texture) - { - *texture = nullptr; - } - - if (!d3dDevice || !fileName || !texture) - return E_INVALIDARG; - - auto pWIC = GetWIC(); - if (!pWIC) - return E_NOINTERFACE; - - // Initialize WIC - ComPtr decoder; - HRESULT hr = pWIC->CreateDecoderFromFilename(fileName, - nullptr, - GENERIC_READ, - WICDecodeMetadataCacheOnDemand, - decoder.GetAddressOf()); - if (FAILED(hr)) - return hr; - - ComPtr frame; - hr = decoder->GetFrame(0, frame.GetAddressOf()); - if (FAILED(hr)) - return hr; - - return CreateTextureFromWIC(d3dDevice, frame.Get(), maxsize, usage, pool, loadFlags, texture); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/WICTextureLoader/WICTextureLoader9.h b/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/WICTextureLoader/WICTextureLoader9.h deleted file mode 100644 index cee2ef6..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/DirectXTex/WICTextureLoader/WICTextureLoader9.h +++ /dev/null @@ -1,92 +0,0 @@ -//-------------------------------------------------------------------------------------- -// File: WICTextureLoader9.h -// -// Function for loading a WIC image and creating a Direct3D runtime texture for it -// (auto-generating mipmaps if possible) -// -// Note: Assumes application has already called CoInitializeEx -// -// Note these functions are useful for images created as simple 2D textures. For -// more complex resources, DDSTextureLoader is an excellent light-weight runtime loader. -// For a full-featured DDS file reader, writer, and texture processing pipeline see -// the 'Texconv' sample and the 'DirectXTex' library. -// -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -// -// http://go.microsoft.com/fwlink/?LinkId=248926 -//-------------------------------------------------------------------------------------- - -#pragma once - -#ifndef DIRECT3D_VERSION -#define DIRECT3D_VERSION 0x900 -#endif -#include - -#pragma comment(lib,"windowscodecs.lib") - -#include -#include - -namespace DirectX -{ -#ifndef WIC_LOADER_FLAGS_DEFINED -#define WIC_LOADER_FLAGS_DEFINED - enum WIC_LOADER_FLAGS : uint32_t - { - WIC_LOADER_DEFAULT = 0, - WIC_LOADER_MIP_AUTOGEN = 0x8, - WIC_LOADER_FIT_POW2 = 0x20, - WIC_LOADER_MAKE_SQUARE = 0x40, - WIC_LOADER_FORCE_RGBA32 = 0x80, - }; - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-dynamic-exception-spec" -#endif - - DEFINE_ENUM_FLAG_OPERATORS(WIC_LOADER_FLAGS); - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif -#endif - - // Standard version - HRESULT CreateWICTextureFromMemory( - _In_ LPDIRECT3DDEVICE9 d3dDevice, - _In_reads_bytes_(wicDataSize) const uint8_t* wicData, - _In_ size_t wicDataSize, - _Outptr_ LPDIRECT3DTEXTURE9* texture, - _In_ size_t maxsize = 0, - _In_ WIC_LOADER_FLAGS loadFlags = WIC_LOADER_DEFAULT) noexcept; - - HRESULT CreateWICTextureFromFile( - _In_ LPDIRECT3DDEVICE9 d3dDevice, - _In_z_ const wchar_t* fileName, - _Outptr_ LPDIRECT3DTEXTURE9* texture, - _In_ size_t maxsize = 0, - _In_ WIC_LOADER_FLAGS loadFlags = WIC_LOADER_DEFAULT) noexcept; - - // Extended version - HRESULT CreateWICTextureFromMemoryEx( - _In_ LPDIRECT3DDEVICE9 d3dDevice, - _In_reads_bytes_(wicDataSize) const uint8_t* wicData, - _In_ size_t wicDataSize, - _In_ size_t maxsize, - _In_ DWORD usage, - _In_ D3DPOOL pool, - _In_ WIC_LOADER_FLAGS loadFlags, - _Outptr_ LPDIRECT3DTEXTURE9* texture) noexcept; - - HRESULT CreateWICTextureFromFileEx( - _In_ LPDIRECT3DDEVICE9 d3dDevice, - _In_z_ const wchar_t* fileName, - _In_ size_t maxsize, - _In_ DWORD usage, - _In_ D3DPOOL pool, - _In_ WIC_LOADER_FLAGS loadFlags, - _Outptr_ LPDIRECT3DTEXTURE9* texture) noexcept; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/WinPixEventRuntime/Include/WinPixEventRuntime/PIXEvents.h b/xess/samples/xess_demo/MiniEngine/Dependencies/WinPixEventRuntime/Include/WinPixEventRuntime/PIXEvents.h deleted file mode 100644 index e694834..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/WinPixEventRuntime/Include/WinPixEventRuntime/PIXEvents.h +++ /dev/null @@ -1,659 +0,0 @@ -/*==========================================================================; - * - * Copyright (C) Microsoft Corporation. All Rights Reserved. - * - * File: PIXEvents.h - * Content: PIX include file - * Don't include this file directly - use pix3.h - * - ****************************************************************************/ -#pragma once - -#ifndef _PixEvents_H_ -#define _PixEvents_H_ - -#ifndef _PIX3_H_ -# error Do not include this file directly - use pix3.h -#endif - -#include "PIXEventsCommon.h" - -#if _MSC_VER < 1800 -# error This version of pix3.h is only supported on Visual Studio 2013 or higher -#elif _MSC_VER < 1900 -# ifndef constexpr // Visual Studio 2013 doesn't support constexpr -# define constexpr -# define PIX3__DEFINED_CONSTEXPR -# endif -#endif - -// Xbox does not support CPU events for retail scenarios -#if defined(USE_PIX) || !defined(PIX_XBOX) -#define PIX_CONTEXT_EMIT_CPU_EVENTS -#endif - -namespace PIXEventsDetail -{ - template - struct PIXEventTypeInferer - { - static constexpr PIXEventType Begin() { return PIXEvent_BeginEvent_VarArgs; } - static constexpr PIXEventType SetMarker() { return PIXEvent_SetMarker_VarArgs; } - static constexpr PIXEventType BeginOnContext() { return PIXEvent_BeginEvent_OnContext_VarArgs; } - static constexpr PIXEventType SetMarkerOnContext() { return PIXEvent_SetMarker_OnContext_VarArgs; } - - // Xbox and Windows store different types of events for context events. - // On Xbox these include a context argument, while on Windows they do - // not. It is important not to change the event types used on the - // Windows version as there are OS components (eg debug layer & DRED) - // that decode event structs. -#ifdef PIX_XBOX - static constexpr PIXEventType GpuBeginOnContext() { return PIXEvent_BeginEvent_OnContext_VarArgs; } - static constexpr PIXEventType GpuSetMarkerOnContext() { return PIXEvent_SetMarker_OnContext_VarArgs; } -#else - static constexpr PIXEventType GpuBeginOnContext() { return PIXEvent_BeginEvent_VarArgs; } - static constexpr PIXEventType GpuSetMarkerOnContext() { return PIXEvent_SetMarker_VarArgs; } -#endif - }; - - template<> - struct PIXEventTypeInferer - { - static constexpr PIXEventType Begin() { return PIXEvent_BeginEvent_NoArgs; } - static constexpr PIXEventType SetMarker() { return PIXEvent_SetMarker_NoArgs; } - static constexpr PIXEventType BeginOnContext() { return PIXEvent_BeginEvent_OnContext_NoArgs; } - static constexpr PIXEventType SetMarkerOnContext() { return PIXEvent_SetMarker_OnContext_NoArgs; } - -#ifdef PIX_XBOX - static constexpr PIXEventType GpuBeginOnContext() { return PIXEvent_BeginEvent_OnContext_NoArgs; } - static constexpr PIXEventType GpuSetMarkerOnContext() { return PIXEvent_SetMarker_OnContext_NoArgs; } -#else - static constexpr PIXEventType GpuBeginOnContext() { return PIXEvent_BeginEvent_NoArgs; } - static constexpr PIXEventType GpuSetMarkerOnContext() { return PIXEvent_SetMarker_NoArgs; } -#endif - }; - - inline void PIXCopyEventArguments(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit) - { - // nothing - UNREFERENCED_PARAMETER(destination); - UNREFERENCED_PARAMETER(limit); - } - - template - void PIXCopyEventArguments(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, ARG const& arg, ARGS const&... args) - { - PIXCopyEventArgument(destination, limit, arg); - PIXCopyEventArguments(destination, limit, args...); - } - - template - __declspec(noinline) void PIXBeginEventAllocate(PIXEventsThreadInfo* threadInfo, UINT64 color, STR formatString, ARGS... args) - { -#ifdef PIX_XBOX - UINT64 time = PIXEventsReplaceBlock(false); -#else - UINT64 time = PIXEventsReplaceBlock(threadInfo, false); -#endif - if (!time) - return; - - UINT64* destination = threadInfo->destination; - UINT64* limit = threadInfo->biasedLimit; - if (destination >= limit) - return; - - limit += PIXEventsSafeFastCopySpaceQwords; - *destination++ = PIXEncodeEventInfo(time, PIXEventTypeInferer::Begin()); - *destination++ = color; - - PIXCopyEventArguments(destination, limit, formatString, args...); - - *destination = PIXEventsBlockEndMarker; - threadInfo->destination = destination; - } - - template - void PIXBeginEvent(UINT64 color, STR formatString, ARGS... args) - { - PIXEventsThreadInfo* threadInfo = PIXGetThreadInfo(); - UINT64* limit = threadInfo->biasedLimit; - if (limit != nullptr) - { - UINT64* destination = threadInfo->destination; - if (destination < limit) - { - limit += PIXEventsSafeFastCopySpaceQwords; - UINT64 time = PIXGetTimestampCounter(); - *destination++ = PIXEncodeEventInfo(time, PIXEventTypeInferer::Begin()); - *destination++ = color; - - PIXCopyEventArguments(destination, limit, formatString, args...); - - *destination = PIXEventsBlockEndMarker; - threadInfo->destination = destination; - } - else - { - PIXBeginEventAllocate(threadInfo, color, formatString, args...); - } - } - } - - template - __declspec(noinline) void PIXSetMarkerAllocate(PIXEventsThreadInfo* threadInfo, UINT64 color, STR formatString, ARGS... args) - { -#ifdef PIX_XBOX - UINT64 time = PIXEventsReplaceBlock(false); -#else - UINT64 time = PIXEventsReplaceBlock(threadInfo, false); -#endif - if (!time) - return; - - UINT64* destination = threadInfo->destination; - UINT64* limit = threadInfo->biasedLimit; - - if (destination >= limit) - return; - - limit += PIXEventsSafeFastCopySpaceQwords; - *destination++ = PIXEncodeEventInfo(time, PIXEventTypeInferer::SetMarker()); - *destination++ = color; - - PIXCopyEventArguments(destination, limit, formatString, args...); - - *destination = PIXEventsBlockEndMarker; - threadInfo->destination = destination; - } - - template - void PIXSetMarker(UINT64 color, STR formatString, ARGS... args) - { - PIXEventsThreadInfo* threadInfo = PIXGetThreadInfo(); - UINT64* limit = threadInfo->biasedLimit; - if (limit != nullptr) - { - UINT64* destination = threadInfo->destination; - if (destination < limit) - { - limit += PIXEventsSafeFastCopySpaceQwords; - UINT64 time = PIXGetTimestampCounter(); - *destination++ = PIXEncodeEventInfo(time, PIXEventTypeInferer::SetMarker()); - *destination++ = color; - - PIXCopyEventArguments(destination, limit, formatString, args...); - - *destination = PIXEventsBlockEndMarker; - threadInfo->destination = destination; - } - else - { - PIXSetMarkerAllocate(threadInfo, color, formatString, args...); - } - } - } - - template - __declspec(noinline) void PIXBeginEventOnContextCpuAllocate(PIXEventsThreadInfo* threadInfo, void* context, UINT64 color, STR formatString, ARGS... args) - { -#ifdef PIX_XBOX - UINT64 time = PIXEventsReplaceBlock(false); -#else - UINT64 time = PIXEventsReplaceBlock(threadInfo, false); -#endif - if (!time) - return; - - UINT64* destination = threadInfo->destination; - UINT64* limit = threadInfo->biasedLimit; - - if (destination >= limit) - return; - - limit += PIXEventsSafeFastCopySpaceQwords; - *destination++ = PIXEncodeEventInfo(time, PIXEventTypeInferer::BeginOnContext()); - *destination++ = color; - -#ifdef PIX_XBOX - UNREFERENCED_PARAMETER(context); - PIXCopyEventArguments(destination, limit, formatString, args...); -#else - PIXCopyEventArguments(destination, limit, context, formatString, args...); -#endif - - *destination = PIXEventsBlockEndMarker; - threadInfo->destination = destination; - } - - template - void PIXBeginEventOnContextCpu(void* context, UINT64 color, STR formatString, ARGS... args) - { - PIXEventsThreadInfo* threadInfo = PIXGetThreadInfo(); - UINT64* limit = threadInfo->biasedLimit; - if (limit != nullptr) - { - UINT64* destination = threadInfo->destination; - if (destination < limit) - { - limit += PIXEventsSafeFastCopySpaceQwords; - UINT64 time = PIXGetTimestampCounter(); - *destination++ = PIXEncodeEventInfo(time, PIXEventTypeInferer::BeginOnContext()); - *destination++ = color; - -#ifdef PIX_XBOX - PIXCopyEventArguments(destination, limit, formatString, args...); -#else - PIXCopyEventArguments(destination, limit, context, formatString, args...); -#endif - - *destination = PIXEventsBlockEndMarker; - threadInfo->destination = destination; - } - else - { - PIXBeginEventOnContextCpuAllocate(threadInfo, context, color, formatString, args...); - } - } - } - - template - void PIXBeginEvent(CONTEXT* context, UINT64 color, STR formatString, ARGS... args) - { -#ifdef PIX_CONTEXT_EMIT_CPU_EVENTS - PIXBeginEventOnContextCpu(context, color, formatString, args...); -#endif - - // TODO: we've already encoded this once for the CPU event - figure out way to avoid doing it again - UINT64 buffer[PIXEventsGraphicsRecordSpaceQwords]; - UINT64* destination = buffer; - UINT64* limit = buffer + PIXEventsGraphicsRecordSpaceQwords - PIXEventsReservedTailSpaceQwords; - - *destination++ = PIXEncodeEventInfo(0, PIXEventTypeInferer::GpuBeginOnContext()); - *destination++ = color; - - PIXCopyEventArguments(destination, limit, formatString, args...); - *destination = 0ull; - - PIXBeginGPUEventOnContext(context, static_cast(buffer), static_cast(reinterpret_cast(destination) - reinterpret_cast(buffer))); - } - - template - __declspec(noinline) void PIXSetMarkerOnContextCpuAllocate(PIXEventsThreadInfo* threadInfo, void* context, UINT64 color, STR formatString, ARGS... args) - { -#ifdef PIX_XBOX - UINT64 time = PIXEventsReplaceBlock(false); -#else - UINT64 time = PIXEventsReplaceBlock(threadInfo, false); -#endif - if (!time) - return; - - UINT64* destination = threadInfo->destination; - UINT64* limit = threadInfo->biasedLimit; - - if (destination >= limit) - return; - - limit += PIXEventsSafeFastCopySpaceQwords; - *destination++ = PIXEncodeEventInfo(time, PIXEventTypeInferer::SetMarkerOnContext()); - *destination++ = color; - -#ifdef PIX_XBOX - UNREFERENCED_PARAMETER(context); - PIXCopyEventArguments(destination, limit, formatString, args...); -#else - PIXCopyEventArguments(destination, limit, context, formatString, args...); -#endif - - *destination = PIXEventsBlockEndMarker; - threadInfo->destination = destination; - } - - template - void PIXSetMarkerOnContextCpu(void* context, UINT64 color, STR formatString, ARGS... args) - { - PIXEventsThreadInfo* threadInfo = PIXGetThreadInfo(); - UINT64* limit = threadInfo->biasedLimit; - if (limit != nullptr) - { - UINT64* destination = threadInfo->destination; - if (destination < limit) - { - limit += PIXEventsSafeFastCopySpaceQwords; - UINT64 time = PIXGetTimestampCounter(); - *destination++ = PIXEncodeEventInfo(time, PIXEventTypeInferer::SetMarkerOnContext()); - *destination++ = color; - -#ifdef PIX_XBOX - PIXCopyEventArguments(destination, limit, formatString, args...); -#else - PIXCopyEventArguments(destination, limit, context, formatString, args...); -#endif - - *destination = PIXEventsBlockEndMarker; - threadInfo->destination = destination; - } - else - { - PIXSetMarkerOnContextCpuAllocate(threadInfo, context, color, formatString, args...); - } - } - } - - template - void PIXSetMarker(CONTEXT* context, UINT64 color, STR formatString, ARGS... args) - { -#ifdef PIX_CONTEXT_EMIT_CPU_EVENTS - PIXSetMarkerOnContextCpu(context, color, formatString, args...); -#endif - - UINT64 buffer[PIXEventsGraphicsRecordSpaceQwords]; - UINT64* destination = buffer; - UINT64* limit = buffer + PIXEventsGraphicsRecordSpaceQwords - PIXEventsReservedTailSpaceQwords; - - *destination++ = PIXEncodeEventInfo(0, PIXEventTypeInferer::GpuSetMarkerOnContext()); - *destination++ = color; - - PIXCopyEventArguments(destination, limit, formatString, args...); - *destination = 0ull; - - PIXSetGPUMarkerOnContext(context, static_cast(buffer), static_cast(reinterpret_cast(destination) - reinterpret_cast(buffer))); - } - - __declspec(noinline) inline void PIXEndEventAllocate(PIXEventsThreadInfo* threadInfo) - { -#ifdef PIX_XBOX - UINT64 time = PIXEventsReplaceBlock(true); -#else - UINT64 time = PIXEventsReplaceBlock(threadInfo, true); -#endif - if (!time) - return; - - UINT64* destination = threadInfo->destination; - UINT64* limit = threadInfo->biasedLimit; - - if (destination >= limit) - return; - - limit += PIXEventsSafeFastCopySpaceQwords; - *destination++ = PIXEncodeEventInfo(time, PIXEvent_EndEvent); - *destination = PIXEventsBlockEndMarker; - threadInfo->destination = destination; - } - - inline void PIXEndEvent() - { - PIXEventsThreadInfo* threadInfo = PIXGetThreadInfo(); - UINT64* limit = threadInfo->biasedLimit; - if (limit != nullptr) - { - UINT64* destination = threadInfo->destination; - if (destination < limit) - { - limit += PIXEventsSafeFastCopySpaceQwords; - UINT64 time = PIXGetTimestampCounter(); - *destination++ = PIXEncodeEventInfo(time, PIXEvent_EndEvent); - *destination = PIXEventsBlockEndMarker; - threadInfo->destination = destination; - } - else - { - PIXEndEventAllocate(threadInfo); - } - } - } - - __declspec(noinline) inline void PIXEndEventOnContextCpuAllocate(PIXEventsThreadInfo* threadInfo, void* context) - { -#ifdef PIX_XBOX - UINT64 time = PIXEventsReplaceBlock(true); -#else - UINT64 time = PIXEventsReplaceBlock(threadInfo, true); -#endif - if (!time) - return; - - UINT64* destination = threadInfo->destination; - UINT64* limit = threadInfo->biasedLimit; - - if (destination >= limit) - return; - - limit += PIXEventsSafeFastCopySpaceQwords; - *destination++ = PIXEncodeEventInfo(time, PIXEvent_EndEvent_OnContext); -#ifdef PIX_XBOX - UNREFERENCED_PARAMETER(context); -#else - PIXCopyEventArgument(destination, limit, context); -#endif - *destination = PIXEventsBlockEndMarker; - threadInfo->destination = destination; - } - - inline void PIXEndEventOnContextCpu(void* context) - { - PIXEventsThreadInfo* threadInfo = PIXGetThreadInfo(); - UINT64* limit = threadInfo->biasedLimit; - if (limit != nullptr) - { - UINT64* destination = threadInfo->destination; - if (destination < limit) - { - limit += PIXEventsSafeFastCopySpaceQwords; - UINT64 time = PIXGetTimestampCounter(); - *destination++ = PIXEncodeEventInfo(time, PIXEvent_EndEvent_OnContext); -#ifndef PIX_XBOX - PIXCopyEventArgument(destination, limit, context); -#endif - *destination = PIXEventsBlockEndMarker; - threadInfo->destination = destination; - } - else - { - PIXEndEventOnContextCpuAllocate(threadInfo, context); - } - } - } - - template - void PIXEndEvent(CONTEXT* context) - { -#ifdef PIX_CONTEXT_EMIT_CPU_EVENTS - PIXEndEventOnContextCpu(context); -#endif - PIXEndGPUEventOnContext(context); - } -} - -#if defined(USE_PIX) - -template -void PIXBeginEvent(UINT64 color, PCWSTR formatString, ARGS... args) -{ - PIXEventsDetail::PIXBeginEvent(color, formatString, args...); -} - -template -void PIXBeginEvent(UINT64 color, PCSTR formatString, ARGS... args) -{ - PIXEventsDetail::PIXBeginEvent(color, formatString, args...); -} - -template -void PIXSetMarker(UINT64 color, PCWSTR formatString, ARGS... args) -{ - PIXEventsDetail::PIXSetMarker(color, formatString, args...); -} - -template -void PIXSetMarker(UINT64 color, PCSTR formatString, ARGS... args) -{ - PIXEventsDetail::PIXSetMarker(color, formatString, args...); -} - -template -void PIXBeginEvent(CONTEXT* context, UINT64 color, PCWSTR formatString, ARGS... args) -{ - PIXEventsDetail::PIXBeginEvent(context, color, formatString, args...); -} - -template -void PIXBeginEvent(CONTEXT* context, UINT64 color, PCSTR formatString, ARGS... args) -{ - PIXEventsDetail::PIXBeginEvent(context, color, formatString, args...); -} - -template -void PIXSetMarker(CONTEXT* context, UINT64 color, PCWSTR formatString, ARGS... args) -{ - PIXEventsDetail::PIXSetMarker(context, color, formatString, args...); -} - -template -void PIXSetMarker(CONTEXT* context, UINT64 color, PCSTR formatString, ARGS... args) -{ - PIXEventsDetail::PIXSetMarker(context, color, formatString, args...); -} - -inline void PIXEndEvent() -{ - PIXEventsDetail::PIXEndEvent(); -} - -template -void PIXEndEvent(CONTEXT* context) -{ - PIXEventsDetail::PIXEndEvent(context); -} - -#else // USE_PIX_RETAIL - -inline void PIXBeginEvent(UINT64, _In_ PCSTR, ...) {} -inline void PIXBeginEvent(UINT64, _In_ PCWSTR, ...) {} -inline void PIXBeginEvent(void*, UINT64, _In_ PCSTR, ...) {} -inline void PIXBeginEvent(void*, UINT64, _In_ PCWSTR, ...) {} -inline void PIXEndEvent() {} -inline void PIXEndEvent(void*) {} -inline void PIXSetMarker(UINT64, _In_ PCSTR, ...) {} -inline void PIXSetMarker(UINT64, _In_ PCWSTR, ...) {} -inline void PIXSetMarker(void*, UINT64, _In_ PCSTR, ...) {} -inline void PIXSetMarker(void*, UINT64, _In_ PCWSTR, ...) {} - -#endif // USE_PIX - -template -void PIXBeginRetailEvent(CONTEXT* context, UINT64 color, PCWSTR formatString, ARGS... args) -{ - PIXEventsDetail::PIXBeginEvent(context, color, formatString, args...); -} - -template -void PIXBeginRetailEvent(CONTEXT* context, UINT64 color, PCSTR formatString, ARGS... args) -{ - PIXEventsDetail::PIXBeginEvent(context, color, formatString, args...); -} - -template -void PIXSetRetailMarker(CONTEXT* context, UINT64 color, PCWSTR formatString, ARGS... args) -{ - PIXEventsDetail::PIXSetMarker(context, color, formatString, args...); -} - -template -void PIXSetRetailMarker(CONTEXT* context, UINT64 color, PCSTR formatString, ARGS... args) -{ - PIXEventsDetail::PIXSetMarker(context, color, formatString, args...); -} - -template -void PIXEndRetailEvent(CONTEXT* context) -{ - PIXEventsDetail::PIXEndEvent(context); -} - -template -class PIXScopedEventObject -{ - CONTEXT* m_context; - -public: - template - PIXScopedEventObject(CONTEXT* context, UINT64 color, PCWSTR formatString, ARGS... args) - : m_context(context) - { - PIXBeginEvent(m_context, color, formatString, args...); - } - - template - PIXScopedEventObject(CONTEXT* context, UINT64 color, PCSTR formatString, ARGS... args) - : m_context(context) - { - PIXBeginEvent(m_context, color, formatString, args...); - } - - ~PIXScopedEventObject() - { - PIXEndEvent(m_context); - } -}; - -template -class PIXScopedRetailEventObject -{ - CONTEXT* m_context; - -public: - template - PIXScopedRetailEventObject(CONTEXT* context, UINT64 color, PCWSTR formatString, ARGS... args) - : m_context(context) - { - PIXBeginRetailEvent(m_context, color, formatString, args...); - } - - template - PIXScopedRetailEventObject(CONTEXT* context, UINT64 color, PCSTR formatString, ARGS... args) - : m_context(context) - { - PIXBeginRetailEvent(m_context, color, formatString, args...); - } - - ~PIXScopedRetailEventObject() - { - PIXEndRetailEvent(m_context); - } -}; - -template<> -class PIXScopedEventObject -{ -public: - template - PIXScopedEventObject(UINT64 color, PCWSTR formatString, ARGS... args) - { - PIXBeginEvent(color, formatString, args...); - } - - template - PIXScopedEventObject(UINT64 color, PCSTR formatString, ARGS... args) - { - PIXBeginEvent(color, formatString, args...); - } - - ~PIXScopedEventObject() - { - PIXEndEvent(); - } -}; - -#define PIXConcatenate(a, b) a ## b -#define PIXGetScopedEventVariableName(a, b) PIXConcatenate(a, b) -#define PIXScopedEvent(context, ...) PIXScopedEventObject::Type> PIXGetScopedEventVariableName(pixEvent, __LINE__)(context, __VA_ARGS__) - -#ifdef PIX3__DEFINED_CONSTEXPR -#undef constexpr -#undef PIX3__DEFINED_CONSTEXPR -#endif - -#endif // _PIXEvents_H__ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/WinPixEventRuntime/Include/WinPixEventRuntime/PIXEventsCommon.h b/xess/samples/xess_demo/MiniEngine/Dependencies/WinPixEventRuntime/Include/WinPixEventRuntime/PIXEventsCommon.h deleted file mode 100644 index 8ecbf78..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/WinPixEventRuntime/Include/WinPixEventRuntime/PIXEventsCommon.h +++ /dev/null @@ -1,595 +0,0 @@ -/*==========================================================================; -* -* Copyright (C) Microsoft Corporation. All Rights Reserved. -* -* File: PIXEventsCommon.h -* Content: PIX include file -* Don't include this file directly - use pix3.h -* -****************************************************************************/ -#pragma once - -#ifndef _PIXEventsCommon_H_ -#define _PIXEventsCommon_H_ - -#if defined(XBOX) || defined(_XBOX_ONE) || defined(_DURANGO) || defined(_GAMING_XBOX) || defined(_GAMING_XBOX_SCARLETT) -#define PIX_XBOX -#endif - -#include - -#if defined(_M_X64) || defined(_M_IX86) -#include -#endif - -// -// The PIXBeginEvent and PIXSetMarker functions have an optimized path for -// copying strings that work by copying 128-bit or 64-bits at a time. In some -// circumstances this may result in PIX logging the remaining memory after the -// null terminator. -// -// By default this optimization is enabled unless Address Sanitizer is enabled, -// since this optimization can trigger a global-buffer-overflow when copying -// string literals. -// -// The PIX_ENABLE_BLOCK_ARGUMENT_COPY controls whether or not this optimization -// is enabled. Applications may also explicitly set this macro to 0 to disable -// the optimization if necessary. -// - -#if defined(PIX_ENABLE_BLOCK_ARGUMENT_COPY) -// Previously set values override everything -# define PIX_ENABLE_BLOCK_ARGUMENT_COPY_SET 0 -#elif defined(__has_feature) -# if __has_feature(address_sanitizer) -// Disable block argument copy when address sanitizer is enabled -# define PIX_ENABLE_BLOCK_ARGUMENT_COPY 0 -# define PIX_ENABLE_BLOCK_ARGUMENT_COPY_SET 1 -# endif -#endif - -#if !defined(PIX_ENABLE_BLOCK_ARGUMENT_COPY) -// Default to enabled. -# define PIX_ENABLE_BLOCK_ARGUMENT_COPY 1 -# define PIX_ENABLE_BLOCK_ARGUMENT_COPY_SET 1 -#endif - -struct PIXEventsBlockInfo; - -struct PIXEventsThreadInfo -{ - PIXEventsBlockInfo* block; - UINT64* biasedLimit; - UINT64* destination; -}; - -#ifdef PIX_XBOX -extern "C" UINT64 WINAPI PIXEventsReplaceBlock(bool getEarliestTime) noexcept; -#else -extern "C" UINT64 WINAPI PIXEventsReplaceBlock(PIXEventsThreadInfo * threadInfo, bool getEarliestTime) noexcept; -#endif - -enum PIXEventType -{ - PIXEvent_EndEvent = 0x000, - PIXEvent_BeginEvent_VarArgs = 0x001, - PIXEvent_BeginEvent_NoArgs = 0x002, - PIXEvent_SetMarker_VarArgs = 0x007, - PIXEvent_SetMarker_NoArgs = 0x008, - - PIXEvent_EndEvent_OnContext = 0x010, - PIXEvent_BeginEvent_OnContext_VarArgs = 0x011, - PIXEvent_BeginEvent_OnContext_NoArgs = 0x012, - PIXEvent_SetMarker_OnContext_VarArgs = 0x017, - PIXEvent_SetMarker_OnContext_NoArgs = 0x018, -}; - -static const UINT64 PIXEventsReservedRecordSpaceQwords = 64; -//this is used to make sure SSE string copy always will end 16-byte write in the current block -//this way only a check if destination < limit can be performed, instead of destination < limit - 1 -//since both these are UINT64* and SSE writes in 16 byte chunks, 8 bytes are kept in reserve -//so even if SSE overwrites 8 extra bytes, those will still belong to the correct block -//on next iteration check destination will be greater than limit -//this is used as well for fixed size UMD events and PIXEndEvent since these require less space -//than other variable length user events and do not need big reserved space -static const UINT64 PIXEventsReservedTailSpaceQwords = 2; -static const UINT64 PIXEventsSafeFastCopySpaceQwords = PIXEventsReservedRecordSpaceQwords - PIXEventsReservedTailSpaceQwords; -static const UINT64 PIXEventsGraphicsRecordSpaceQwords = 64; - -//Bits 7-19 (13 bits) -static const UINT64 PIXEventsBlockEndMarker = 0x00000000000FFF80; - -//Bits 10-19 (10 bits) -static const UINT64 PIXEventsTypeReadMask = 0x00000000000FFC00; -static const UINT64 PIXEventsTypeWriteMask = 0x00000000000003FF; -static const UINT64 PIXEventsTypeBitShift = 10; - -//Bits 20-63 (44 bits) -static const UINT64 PIXEventsTimestampReadMask = 0xFFFFFFFFFFF00000; -static const UINT64 PIXEventsTimestampWriteMask = 0x00000FFFFFFFFFFF; -static const UINT64 PIXEventsTimestampBitShift = 20; - -inline UINT64 PIXEncodeEventInfo(UINT64 timestamp, PIXEventType eventType) -{ - return ((timestamp & PIXEventsTimestampWriteMask) << PIXEventsTimestampBitShift) | - (((UINT64)eventType & PIXEventsTypeWriteMask) << PIXEventsTypeBitShift); -} - -//Bits 60-63 (4) -static const UINT64 PIXEventsStringAlignmentWriteMask = 0x000000000000000F; -static const UINT64 PIXEventsStringAlignmentReadMask = 0xF000000000000000; -static const UINT64 PIXEventsStringAlignmentBitShift = 60; - -//Bits 55-59 (5) -static const UINT64 PIXEventsStringCopyChunkSizeWriteMask = 0x000000000000001F; -static const UINT64 PIXEventsStringCopyChunkSizeReadMask = 0x0F80000000000000; -static const UINT64 PIXEventsStringCopyChunkSizeBitShift = 55; - -//Bit 54 -static const UINT64 PIXEventsStringIsANSIWriteMask = 0x0000000000000001; -static const UINT64 PIXEventsStringIsANSIReadMask = 0x0040000000000000; -static const UINT64 PIXEventsStringIsANSIBitShift = 54; - -//Bit 53 -static const UINT64 PIXEventsStringIsShortcutWriteMask = 0x0000000000000001; -static const UINT64 PIXEventsStringIsShortcutReadMask = 0x0020000000000000; -static const UINT64 PIXEventsStringIsShortcutBitShift = 53; - -inline UINT64 PIXEncodeStringInfo(UINT64 alignment, UINT64 copyChunkSize, BOOL isANSI, BOOL isShortcut) -{ - return ((alignment & PIXEventsStringAlignmentWriteMask) << PIXEventsStringAlignmentBitShift) | - ((copyChunkSize & PIXEventsStringCopyChunkSizeWriteMask) << PIXEventsStringCopyChunkSizeBitShift) | - (((UINT64)isANSI & PIXEventsStringIsANSIWriteMask) << PIXEventsStringIsANSIBitShift) | - (((UINT64)isShortcut & PIXEventsStringIsShortcutWriteMask) << PIXEventsStringIsShortcutBitShift); -} - -template -inline bool PIXIsPointerAligned(T* pointer) -{ - return !(((UINT64)pointer) & (alignment - 1)); -} - -// Generic template version slower because of the additional clear write -template -inline void PIXCopyEventArgument(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, T argument) -{ - if (destination < limit) - { - *destination = 0ull; - *((T*)destination) = argument; - ++destination; - } -} - -// int32 specialization to avoid slower double memory writes -template<> -inline void PIXCopyEventArgument(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, INT32 argument) -{ - if (destination < limit) - { - *reinterpret_cast(destination) = static_cast(argument); - ++destination; - } -} - -// unsigned int32 specialization to avoid slower double memory writes -template<> -inline void PIXCopyEventArgument(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, UINT32 argument) -{ - if (destination < limit) - { - *destination = static_cast(argument); - ++destination; - } -} - -// int64 specialization to avoid slower double memory writes -template<> -inline void PIXCopyEventArgument(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, INT64 argument) -{ - if (destination < limit) - { - *reinterpret_cast(destination) = argument; - ++destination; - } -} - -// unsigned int64 specialization to avoid slower double memory writes -template<> -inline void PIXCopyEventArgument(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, UINT64 argument) -{ - if (destination < limit) - { - *destination = argument; - ++destination; - } -} - -//floats must be cast to double during writing the data to be properly printed later when reading the data -//this is needed because when float is passed to varargs function it's cast to double -template<> -inline void PIXCopyEventArgument(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, float argument) -{ - if (destination < limit) - { - *reinterpret_cast(destination) = static_cast(argument); - ++destination; - } -} - -//char has to be cast to a longer signed integer type -//this is due to printf not ignoring correctly the upper bits of unsigned long long for a char format specifier -template<> -inline void PIXCopyEventArgument(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, char argument) -{ - if (destination < limit) - { - *reinterpret_cast(destination) = static_cast(argument); - ++destination; - } -} - -//unsigned char has to be cast to a longer unsigned integer type -//this is due to printf not ignoring correctly the upper bits of unsigned long long for a char format specifier -template<> -inline void PIXCopyEventArgument(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, unsigned char argument) -{ - if (destination < limit) - { - *destination = static_cast(argument); - ++destination; - } -} - -//bool has to be cast to an integer since it's not explicitly supported by string format routines -//there's no format specifier for bool type, but it should work with integer format specifiers -template<> -inline void PIXCopyEventArgument(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, bool argument) -{ - if (destination < limit) - { - *destination = static_cast(argument); - ++destination; - } -} - -inline void PIXCopyEventArgumentSlowest(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PCSTR argument) -{ - *destination++ = PIXEncodeStringInfo(0, 8, TRUE, FALSE); - while (destination < limit) - { - UINT64 c = static_cast(argument[0]); - if (!c) - { - *destination++ = 0; - return; - } - UINT64 x = c; - c = static_cast(argument[1]); - if (!c) - { - *destination++ = x; - return; - } - x |= c << 8; - c = static_cast(argument[2]); - if (!c) - { - *destination++ = x; - return; - } - x |= c << 16; - c = static_cast(argument[3]); - if (!c) - { - *destination++ = x; - return; - } - x |= c << 24; - c = static_cast(argument[4]); - if (!c) - { - *destination++ = x; - return; - } - x |= c << 32; - c = static_cast(argument[5]); - if (!c) - { - *destination++ = x; - return; - } - x |= c << 40; - c = static_cast(argument[6]); - if (!c) - { - *destination++ = x; - return; - } - x |= c << 48; - c = static_cast(argument[7]); - if (!c) - { - *destination++ = x; - return; - } - x |= c << 56; - *destination++ = x; - argument += 8; - } -} - -inline void PIXCopyEventArgumentSlow(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PCSTR argument) -{ -#if PIX_ENABLE_BLOCK_ARGUMENT_COPY - if (PIXIsPointerAligned<8>(argument)) - { - *destination++ = PIXEncodeStringInfo(0, 8, TRUE, FALSE); - UINT64* source = (UINT64*)argument; - while (destination < limit) - { - UINT64 qword = *source++; - *destination++ = qword; - //check if any of the characters is a terminating zero - if (!((qword & 0xFF00000000000000) && - (qword & 0xFF000000000000) && - (qword & 0xFF0000000000) && - (qword & 0xFF00000000) && - (qword & 0xFF000000) && - (qword & 0xFF0000) && - (qword & 0xFF00) && - (qword & 0xFF))) - { - break; - } - } - } - else -#endif // PIX_ENABLE_BLOCK_ARGUMENT_COPY - { - PIXCopyEventArgumentSlowest(destination, limit, argument); - } -} - -template<> -inline void PIXCopyEventArgument(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PCSTR argument) -{ - if (destination < limit) - { - if (argument != nullptr) - { -#if (defined(_M_X64) || defined(_M_IX86)) && PIX_ENABLE_BLOCK_ARGUMENT_COPY - if (PIXIsPointerAligned<16>(argument)) - { - *destination++ = PIXEncodeStringInfo(0, 16, TRUE, FALSE); - __m128i zero = _mm_setzero_si128(); - if (PIXIsPointerAligned<16>(destination)) - { - while (destination < limit) - { - __m128i mem = _mm_load_si128((__m128i*)argument); - _mm_store_si128((__m128i*)destination, mem); - //check if any of the characters is a terminating zero - __m128i res = _mm_cmpeq_epi8(mem, zero); - destination += 2; - if (_mm_movemask_epi8(res)) - break; - argument += 16; - } - } - else - { - while (destination < limit) - { - __m128i mem = _mm_load_si128((__m128i*)argument); - _mm_storeu_si128((__m128i*)destination, mem); - //check if any of the characters is a terminating zero - __m128i res = _mm_cmpeq_epi8(mem, zero); - destination += 2; - if (_mm_movemask_epi8(res)) - break; - argument += 16; - } - } - } - else -#endif // (defined(_M_X64) || defined(_M_IX86)) && PIX_ENABLE_BLOCK_ARGUMENT_COPY - { - PIXCopyEventArgumentSlow(destination, limit, argument); - } - } - else - { - *destination++ = 0ull; - } - } -} - -template<> -inline void PIXCopyEventArgument(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PSTR argument) -{ - PIXCopyEventArgument(destination, limit, (PCSTR)argument); -} - -inline void PIXCopyEventArgumentSlowest(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PCWSTR argument) -{ - *destination++ = PIXEncodeStringInfo(0, 8, FALSE, FALSE); - while (destination < limit) - { - UINT64 c = static_cast(argument[0]); - if (!c) - { - *destination++ = 0; - return; - } - UINT64 x = c; - c = static_cast(argument[1]); - if (!c) - { - *destination++ = x; - return; - } - x |= c << 16; - c = static_cast(argument[2]); - if (!c) - { - *destination++ = x; - return; - } - x |= c << 32; - c = static_cast(argument[3]); - if (!c) - { - *destination++ = x; - return; - } - x |= c << 48; - *destination++ = x; - argument += 4; - } -} - -inline void PIXCopyEventArgumentSlow(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PCWSTR argument) -{ -#if PIX_ENABLE_BLOCK_ARGUMENT_COPY - if (PIXIsPointerAligned<8>(argument)) - { - *destination++ = PIXEncodeStringInfo(0, 8, FALSE, FALSE); - UINT64* source = (UINT64*)argument; - while (destination < limit) - { - UINT64 qword = *source++; - *destination++ = qword; - //check if any of the characters is a terminating zero - //TODO: check if reversed condition is faster - if (!((qword & 0xFFFF000000000000) && - (qword & 0xFFFF00000000) && - (qword & 0xFFFF0000) && - (qword & 0xFFFF))) - { - break; - } - } - } - else -#endif // PIX_ENABLE_BLOCK_ARGUMENT_COPY - { - PIXCopyEventArgumentSlowest(destination, limit, argument); - } -} - -template<> -inline void PIXCopyEventArgument(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PCWSTR argument) -{ - if (destination < limit) - { - if (argument != nullptr) - { -#if (defined(_M_X64) || defined(_M_IX86)) && PIX_ENABLE_BLOCK_ARGUMENT_COPY - if (PIXIsPointerAligned<16>(argument)) - { - *destination++ = PIXEncodeStringInfo(0, 16, FALSE, FALSE); - __m128i zero = _mm_setzero_si128(); - if (PIXIsPointerAligned<16>(destination)) - { - while (destination < limit) - { - __m128i mem = _mm_load_si128((__m128i*)argument); - _mm_store_si128((__m128i*)destination, mem); - //check if any of the characters is a terminating zero - __m128i res = _mm_cmpeq_epi16(mem, zero); - destination += 2; - if (_mm_movemask_epi8(res)) - break; - argument += 8; - } - } - else - { - while (destination < limit) - { - __m128i mem = _mm_load_si128((__m128i*)argument); - _mm_storeu_si128((__m128i*)destination, mem); - //check if any of the characters is a terminating zero - __m128i res = _mm_cmpeq_epi16(mem, zero); - destination += 2; - if (_mm_movemask_epi8(res)) - break; - argument += 8; - } - } - } - else -#endif // (defined(_M_X64) || defined(_M_IX86)) && PIX_ENABLE_BLOCK_ARGUMENT_COPY - { - PIXCopyEventArgumentSlow(destination, limit, argument); - } - } - else - { - *destination++ = 0ull; - } - } -} - -template<> -inline void PIXCopyEventArgument(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PWSTR argument) -{ - PIXCopyEventArgument(destination, limit, (PCWSTR)argument); -}; - -#if defined(__d3d12_x_h__) || defined(__d3d12_xs_h__) || defined(__d3d12_h__) - -inline void PIXSetGPUMarkerOnContext(_In_ ID3D12GraphicsCommandList* commandList, _In_reads_bytes_(size) void* data, UINT size) -{ - commandList->SetMarker(D3D12_EVENT_METADATA, data, size); -} - -inline void PIXSetGPUMarkerOnContext(_In_ ID3D12CommandQueue* commandQueue, _In_reads_bytes_(size) void* data, UINT size) -{ - commandQueue->SetMarker(D3D12_EVENT_METADATA, data, size); -} - -inline void PIXBeginGPUEventOnContext(_In_ ID3D12GraphicsCommandList* commandList, _In_reads_bytes_(size) void* data, UINT size) -{ - commandList->BeginEvent(D3D12_EVENT_METADATA, data, size); -} - -inline void PIXBeginGPUEventOnContext(_In_ ID3D12CommandQueue* commandQueue, _In_reads_bytes_(size) void* data, UINT size) -{ - commandQueue->BeginEvent(D3D12_EVENT_METADATA, data, size); -} - -inline void PIXEndGPUEventOnContext(_In_ ID3D12GraphicsCommandList* commandList) -{ - commandList->EndEvent(); -} - -inline void PIXEndGPUEventOnContext(_In_ ID3D12CommandQueue* commandQueue) -{ - commandQueue->EndEvent(); -} - -#endif //__d3d12_h__ - -template struct PIXInferScopedEventType { typedef T Type; }; -template struct PIXInferScopedEventType { typedef T Type; }; -template struct PIXInferScopedEventType { typedef T Type; }; -template struct PIXInferScopedEventType { typedef T Type; }; -template<> struct PIXInferScopedEventType { typedef void Type; }; -template<> struct PIXInferScopedEventType { typedef void Type; }; -template<> struct PIXInferScopedEventType { typedef void Type; }; -template<> struct PIXInferScopedEventType { typedef void Type; }; -template<> struct PIXInferScopedEventType { typedef void Type; }; -template<> struct PIXInferScopedEventType { typedef void Type; }; -template<> struct PIXInferScopedEventType { typedef void Type; }; -template<> struct PIXInferScopedEventType { typedef void Type; }; - - -#if PIX_ENABLE_BLOCK_ARGUMENT_COPY_SET -#undef PIX_ENABLE_BLOCK_ARGUMENT_COPY -#endif - -#undef PIX_ENABLE_BLOCK_ARGUMENT_COPY_SET - -#endif //_PIXEventsCommon_H_ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/WinPixEventRuntime/Include/WinPixEventRuntime/pix3.h b/xess/samples/xess_demo/MiniEngine/Dependencies/WinPixEventRuntime/Include/WinPixEventRuntime/pix3.h deleted file mode 100644 index 24d2eb1..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/WinPixEventRuntime/Include/WinPixEventRuntime/pix3.h +++ /dev/null @@ -1,163 +0,0 @@ -/*==========================================================================; - * - * Copyright (C) Microsoft Corporation. All Rights Reserved. - * - * File: pix3.h - * Content: PIX include file - * - ****************************************************************************/ -#pragma once - -#ifndef _PIX3_H_ -#define _PIX3_H_ - -#include - -#ifndef __cplusplus -#error "Only C++ files can include pix3.h. C is not supported." -#endif - -#if !defined(USE_PIX_SUPPORTED_ARCHITECTURE) -#if defined(_M_X64) || defined(USE_PIX_ON_ALL_ARCHITECTURES) || defined(_M_ARM64) -#define USE_PIX_SUPPORTED_ARCHITECTURE -#endif -#endif - -#if !defined(USE_PIX) -#if defined(USE_PIX_SUPPORTED_ARCHITECTURE) && (defined(_DEBUG) || DBG || defined(PROFILE) || defined(PROFILE_BUILD)) && !defined(_PREFAST_) -#define USE_PIX -#endif -#endif - -#if defined(USE_PIX) && !defined(USE_PIX_SUPPORTED_ARCHITECTURE) -#pragma message("Warning: Pix markers are only supported on AMD64 and ARM64") -#endif - -#if defined(XBOX) || defined(_XBOX_ONE) || defined(_DURANGO) || defined(_GAMING_XBOX) || defined(_GAMING_XBOX_SCARLETT) -#include "pix3_xbox.h" -#else -#include "pix3_win.h" -#endif - -// These flags are used by both PIXBeginCapture and PIXGetCaptureState -#define PIX_CAPTURE_TIMING (1 << 0) -#define PIX_CAPTURE_GPU (1 << 1) -#define PIX_CAPTURE_FUNCTION_SUMMARY (1 << 2) -#define PIX_CAPTURE_FUNCTION_DETAILS (1 << 3) -#define PIX_CAPTURE_CALLGRAPH (1 << 4) -#define PIX_CAPTURE_INSTRUCTION_TRACE (1 << 5) -#define PIX_CAPTURE_SYSTEM_MONITOR_COUNTERS (1 << 6) -#define PIX_CAPTURE_VIDEO (1 << 7) -#define PIX_CAPTURE_AUDIO (1 << 8) -#define PIX_CAPTURE_RESERVED (1 << 15) - -union PIXCaptureParameters -{ - enum PIXCaptureStorage - { - Memory = 0, - }; - - struct GpuCaptureParameters - { - PVOID reserved; - } GpuCaptureParameters; - - struct TimingCaptureParameters - { - PWSTR FileName; - UINT32 MaximumToolingMemorySizeMb; - PIXCaptureStorage CaptureStorage; - - BOOL CaptureGpuTiming; - - BOOL CaptureCallstacks; - BOOL CaptureCpuSamples; - UINT32 CpuSamplesPerSecond; - - BOOL CaptureFileIO; - - BOOL CaptureVirtualAllocEvents; - BOOL CaptureHeapAllocEvents; - BOOL CaptureXMemEvents; // Xbox only - BOOL CapturePixMemEvents; // Xbox only - } TimingCaptureParameters; -}; - -typedef PIXCaptureParameters* PPIXCaptureParameters; - -#if defined(USE_PIX_SUPPORTED_ARCHITECTURE) && (defined(USE_PIX) || defined(USE_PIX_RETAIL)) - -#define PIX_EVENTS_ARE_TURNED_ON - -#include "PIXEventsCommon.h" -#include "PIXEvents.h" - -#ifdef USE_PIX -// Starts a programmatically controlled capture. -// captureFlags uses the PIX_CAPTURE_* family of flags to specify the type of capture to take -extern "C" HRESULT WINAPI PIXBeginCapture2(DWORD captureFlags, _In_opt_ const PPIXCaptureParameters captureParameters); -inline HRESULT PIXBeginCapture(DWORD captureFlags, _In_opt_ const PPIXCaptureParameters captureParameters) { return PIXBeginCapture2(captureFlags, captureParameters); } - -// Stops a programmatically controlled capture -// If discard == TRUE, the captured data is discarded -// If discard == FALSE, the captured data is saved -extern "C" HRESULT WINAPI PIXEndCapture(BOOL discard); - -extern "C" DWORD WINAPI PIXGetCaptureState(); - -extern "C" void WINAPI PIXReportCounter(_In_ PCWSTR name, float value); - -#endif // USE_PIX - -#endif // (USE_PIX_SUPPORTED_ARCHITECTURE) && (USE_PIX || USE_PIX_RETAIL) - -#if !defined(USE_PIX_SUPPORTED_ARCHITECTURE) || !defined(USE_PIX) - -// Eliminate these APIs when not using PIX -inline HRESULT PIXBeginCapture2(DWORD, _In_opt_ const PIXCaptureParameters*) { return S_OK; } -inline HRESULT PIXBeginCapture(DWORD, _In_opt_ const PIXCaptureParameters*) { return S_OK; } -inline HRESULT PIXEndCapture(BOOL) { return S_OK; } -inline DWORD PIXGetCaptureState() { return 0; } -inline void PIXReportCounter(_In_ PCWSTR, float) {} -inline void PIXNotifyWakeFromFenceSignal(_In_ HANDLE) {} - -#if !defined(USE_PIX_RETAIL) - -inline void PIXBeginEvent(UINT64, _In_ PCSTR, ...) {} -inline void PIXBeginEvent(UINT64, _In_ PCWSTR, ...) {} -inline void PIXBeginEvent(void*, UINT64, _In_ PCSTR, ...) {} -inline void PIXBeginEvent(void*, UINT64, _In_ PCWSTR, ...) {} -inline void PIXEndEvent() {} -inline void PIXEndEvent(void*) {} -inline void PIXSetMarker(UINT64, _In_ PCSTR, ...) {} -inline void PIXSetMarker(UINT64, _In_ PCWSTR, ...) {} -inline void PIXSetMarker(void*, UINT64, _In_ PCSTR, ...) {} -inline void PIXSetMarker(void*, UINT64, _In_ PCWSTR, ...) {} -inline void PIXBeginRetailEvent(void*, UINT64, _In_ PCSTR, ...) {} -inline void PIXBeginRetailEvent(void*, UINT64, _In_ PCWSTR, ...) {} -inline void PIXEndRetailEvent(void*) {} -inline void PIXSetRetailMarker(void*, UINT64, _In_ PCSTR, ...) {} -inline void PIXSetRetailMarker(void*, UINT64, _In_ PCWSTR, ...) {} -inline void PIXScopedEvent(UINT64, _In_ PCSTR, ...) {} -inline void PIXScopedEvent(UINT64, _In_ PCWSTR, ...) {} -inline void PIXScopedEvent(void*, UINT64, _In_ PCSTR, ...) {} -inline void PIXScopedEvent(void*, UINT64, _In_ PCWSTR, ...) {} - -#endif // !USE_PIX_RETAIL - -// don't show warnings about expressions with no effect -#pragma warning(disable:4548) -#pragma warning(disable:4555) - -#endif // !USE_PIX_SUPPORTED_ARCHITECTURE || !USE_PIX - -// Use these functions to specify colors to pass as metadata to a PIX event/marker API. -// Use PIX_COLOR() to specify a particular color for an event. -// Or, use PIX_COLOR_INDEX() to specify a set of unique event categories, and let PIX choose -// the colors to represent each category. -inline UINT PIX_COLOR(BYTE r, BYTE g, BYTE b) { return 0xff000000 | (r << 16) | (g << 8) | b; } -inline UINT PIX_COLOR_INDEX(BYTE i) { return i; } -const UINT PIX_COLOR_DEFAULT = PIX_COLOR_INDEX(0); - -#endif // _PIX3_H_ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/WinPixEventRuntime/Include/WinPixEventRuntime/pix3_win.h b/xess/samples/xess_demo/MiniEngine/Dependencies/WinPixEventRuntime/Include/WinPixEventRuntime/pix3_win.h deleted file mode 100644 index 33b8937..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/WinPixEventRuntime/Include/WinPixEventRuntime/pix3_win.h +++ /dev/null @@ -1,48 +0,0 @@ -/*==========================================================================; - * - * Copyright (C) Microsoft Corporation. All Rights Reserved. - * - * File: PIX3_win.h - * Content: PIX include file - * Don't include this file directly - use pix3.h - * - ****************************************************************************/ - -#pragma once - -#ifndef _PIX3_H_ -#error Don't include this file directly - use pix3.h -#endif - -#ifndef _PIX3_WIN_H_ -#define _PIX3_WIN_H_ - -// PIXEventsThreadInfo is defined in PIXEventsCommon.h -struct PIXEventsThreadInfo; - -extern "C" PIXEventsThreadInfo* PIXGetThreadInfo() noexcept; - -#if defined(USE_PIX) && defined(USE_PIX_SUPPORTED_ARCHITECTURE) -// Notifies PIX that an event handle was set as a result of a D3D12 fence being signaled. -// The event specified must have the same handle value as the handle -// used in ID3D12Fence::SetEventOnCompletion. -extern "C" void WINAPI PIXNotifyWakeFromFenceSignal(_In_ HANDLE event); -#endif - -// The following defines denote the different metadata values that have been used -// by tools to denote how to parse pix marker event data. The first two values -// are legacy values. -#define WINPIX_EVENT_UNICODE_VERSION 0 -#define WINPIX_EVENT_ANSI_VERSION 1 -#define WINPIX_EVENT_PIX3BLOB_VERSION 2 - -#define D3D12_EVENT_METADATA WINPIX_EVENT_PIX3BLOB_VERSION - -__forceinline UINT64 PIXGetTimestampCounter() -{ - LARGE_INTEGER time = {}; - QueryPerformanceCounter(&time); - return time.QuadPart; -} - -#endif //_PIX3_WIN_H_ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/WinPixEventRuntime/ThirdPartyNotices.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/WinPixEventRuntime/ThirdPartyNotices.txt deleted file mode 100644 index 8281e7e..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/WinPixEventRuntime/ThirdPartyNotices.txt +++ /dev/null @@ -1,149 +0,0 @@ -THIRD-PARTY SOFTWARE NOTICES AND INFORMATION - -Note: While Microsoft is not the author of the files below, Microsoft is -offering you a license subject to the terms of the Microsoft Software License -Terms for Microsoft PIX Developer Tool (the "Microsoft Program"). Microsoft -reserves all other rights. The notices below are provided for informational -purposes only and are not the license terms under which Microsoft distributes -these files. - -The Microsoft Program includes the following third-party software: - -1. Boost v. 1.66.0 (https://sourceforge.net/projects/boost/files/boost/1.66.0) -2. fmt v4.1.0 (https://github.com/fmtlib/fmt/releases/tag/4.1.0) - - -As the recipient of the above third-party software, Microsoft sets forth a copy -of the notices and other information below. - - -BOOST NOTICES AND INFORMATION BEGIN HERE -======================================== - -Boost v. 1.66.0 -Copyright Beman Dawes, David Abrahams, 1998-2005 -Copyright Rene Rivera 2006-2007 -Provided for Informational Purposes Only -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by this -license (the "Software") to use, reproduce, display, distribute, execute, and -transmit the Software, and to prepare derivative works of the Software, and to -permit third-parties to whom the Software is furnished to do so, all subject to -the following: - -The copyright notices in the Software and this entire statement, including the -above license grant, this restriction and the following disclaimer, must be -included in all copies of the Software, in whole or in part, and all derivative -works of the Software, unless such copies or derivative works are solely in the -form of machine-executable object code generated by a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL -THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY -DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE - -END OF BOOST NOTICES AND INFORMATION -==================================== - -FMT NOTICES AND INFORMATION BEGIN HERE -====================================== - -fmt v4.1.0 -Copyright (c) 2012 - 2016, Victor Zverovich -Provided for Informational Purposes Only -BSD 2-clause - - -Copyright (c) 2012 - 2016, Victor Zverovich - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -END OF FMT NOTICES AND INFORMATION -================================== - -RETROFIT NOTICES AND INFORMATION BEGIN HERE -=========================================== - -Copyright (C) 2016 Max Delta Group - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE MAX -DELTA GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of the Max Delta Group and its -members shall not be used in advertising or otherwise to promote the sale, use -or other dealings in this Software without prior written authorization from the -Max Delta Group. - -END OF RETROFIT NOTICES AND INFORMATION -======================================= - -SQLITE3 NOTICES AND INFORMATION BEGIN HERE -========================================== - -https://www.sqlite.org/copyright.html -SQLite Is Public Domain - -All of the code and documentation in SQLite has been dedicated to the public -domain by the authors. All code authors, and representatives of the companies -they work for, have signed affidavits dedicating their contributions to the -public domain and originals of those signed affidavits are stored in a firesafe -at the main offices of Hwaci. Anyone is free to copy, modify, publish, use, -compile, sell, or distribute the original SQLite code, either in source code -form or as a compiled binary, for any purpose, commercial or non-commercial, and -by any means. - -The previous paragraph applies to the deliverable code and documentation in SQLite - -those parts of the SQLite library that you actually bundle and ship with a larger -application. Some scripts used as part of the build process (for example the "configure" -scripts generated by autoconf) might fall under other open-source licenses. Nothing -from these build scripts ever reaches the final deliverable SQLite library, however, -and so the licenses associated with those scripts should not be a factor in assessing -your rights to copy and use the SQLite library. - -All of the deliverable code in SQLite has been written from scratch. No code has been -taken from other projects or from the open internet. Every line of code can be traced -back to its original author, and all of those authors have public domain dedications -on file. So the SQLite code base is clean and is uncontaminated with licensed code -from other projects. - -END OF SQLITE3 NOTICES AND INFORMATION -====================================== diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/WinPixEventRuntime/license.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/WinPixEventRuntime/license.txt deleted file mode 100644 index 50976a5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/WinPixEventRuntime/license.txt +++ /dev/null @@ -1,78 +0,0 @@ -MICROSOFT SOFTWARE LICENSE TERMS - -PIX EVENT RUNTIME FOR WINDOWS - -IF YOU LIVE IN (OR ARE A BUSINESS WITH A PRINCIPAL PLACE OF BUSINESS IN) THE UNITED STATES, PLEASE READ THE “BINDING ARBITRATION AND CLASS ACTION WAIVER” SECTION BELOW. IT AFFECTS HOW DISPUTES ARE RESOLVED. - -These license terms are an agreement between you and Microsoft Corporation (or one of its affiliates). They apply to the software named above and any Microsoft services or software updates (except to the extent such services or updates are accompanied by new or additional terms, in which case those different terms apply prospectively and do not alter your or Microsoft’s rights relating to pre-updated software or services). IF YOU COMPLY WITH THESE LICENSE TERMS, YOU HAVE THE RIGHTS BELOW. BY USING THE SOFTWARE, YOU ACCEPT THESE TERMS. - -1. INSTALLATION AND USE RIGHTS. - a. General. You may install and use any number of copies of the software to design, develop and test your Microsoft Windows programs. - b. Third Party Software. The software may include third party applications that are licensed to you under this agreement or under their own terms. License terms, notices, and acknowledgements, if any, for the third party applications may be accessible online at http://aka.ms/thirdpartynotices or in an accompanying notices file. Even if such applications are governed by other agreements, the disclaimer, limitations on, and exclusions of damages below also apply to the extent allowed by applicable law. - -2. DISTRIBUTABLE CODE. - a. Distributable Code. The software is comprised of Distributable Code. “Distributable Code” is code that you are permitted to distribute in programs you develop if you comply with the terms below. - (i) Right to Use and Distribute. - * You may copy and distribute the object code form of the software. - * Third Party Distribution. You may permit distributors of your programs to copy and distribute the Distributable Code as part of those programs. - (ii) Distribution Requirements. For any Distributable Code you distribute, you must - * add significant primary functionality to it in your programs; - * require distributors and external end users to agree to terms that protect it at least as much as this agreement; - * display your valid copyright notice on your programs; and - * indemnify, defend, and hold harmless Microsoft from any claims, including attorneys’ fees, related to the distribution or use of your programs. - (iii) Distribution Restrictions. You may not - * alter any copyright, trademark or patent notice in the Distributable Code; - * use Microsoft’s trademarks in your programs’ names or in a way that suggests your programs come from or are endorsed by Microsoft; - * distribute Distributable Code to run on a platform other than a Windows platform; - * include Distributable Code in malicious, deceptive or unlawful programs; or - * modify or distribute the source code of any Distributable Code so that any part of it becomes subject to an Excluded License. An Excluded License is one that requires, as a condition of use, modification or distribution, that - * the code be disclosed or distributed in source code form; or - * others have the right to modify it. - -3. SCOPE OF LICENSE. The software is licensed, not sold. Microsoft reserves all other rights. Unless applicable law gives you more rights despite this limitation, you will not (and have no right to): - a. work around any technical limitations in the software that only allow you to use it in certain ways; - b. reverse engineer, decompile or disassemble the software; - c. remove, minimize, block, or modify any notices of Microsoft or its suppliers in the software; - d. use the software in any way that is against the law or to create or propagate malware; or - e. share, publish, distribute, or lend the software, provide the software as a stand-alone hosted solution for others to use, or transfer the software or this agreement to any third party. - -4. EXPORT RESTRICTIONS. You must comply with all domestic and international export laws and regulations that apply to the software, which include restrictions on destinations, end users, and end use. For further information on export restrictions, visit http://aka.ms/exporting. - -5. SUPPORT SERVICES. Microsoft is not obligated under this agreement to provide any support services for the software. Any support provided is “as is”, “with all faults”, and without warranty of any kind. - -6. BINDING ARBITRATION AND CLASS ACTION WAIVER. This Section applies if you live in (or, if a business, your principal place of business is in) the United States. If you and Microsoft have a dispute, you and Microsoft agree to try for 60 days to resolve it informally. If you and Microsoft can’t, you and Microsoft agree to binding individual arbitration before the American Arbitration Association under the Federal Arbitration Act (“FAA”), and not to sue in court in front of a judge or jury. Instead, a neutral arbitrator will decide. Class action lawsuits, class-wide arbitrations, private attorney-general actions, and any other proceeding where someone acts in a representative capacity are not allowed; nor is combining individual proceedings without the consent of all parties. The complete Arbitration Agreement contains more terms and is at http://aka.ms/arb-agreement-1. You and Microsoft agree to these terms. - -7. ENTIRE AGREEMENT. This agreement, and any other terms Microsoft may provide for supplements, updates, or third-party applications, is the entire agreement for the software. - -8. APPLICABLE LAW AND PLACE TO RESOLVE DISPUTES. If you acquired the software in the United States or Canada, the laws of the state or province where you live (or, if a business, where your principal place of business is located) govern the interpretation of this agreement, claims for its breach, and all other claims (including consumer protection, unfair competition, and tort claims), regardless of conflict of laws principles, except that the FAA governs everything related to arbitration. If you acquired the software in any other country, its laws apply, except that the FAA governs everything related to arbitration. If U.S. federal jurisdiction exists, you and Microsoft consent to exclusive jurisdiction and venue in the federal court in King County, Washington for all disputes heard in court (excluding arbitration). If not, you and Microsoft consent to exclusive jurisdiction and venue in the Superior Court of King County, Washington for all disputes heard in court (excluding arbitration). - -9. CONSUMER RIGHTS; REGIONAL VARIATIONS. This agreement describes certain legal rights. You may have other rights, including consumer rights, under the laws of your state, province, or country. Separate and apart from your relationship with Microsoft, you may also have rights with respect to the party from which you acquired the software. This agreement does not change those other rights if the laws of your state, province, or country do not permit it to do so. For example, if you acquired the software in one of the below regions, or mandatory country law applies, then the following provisions apply to you: - a. Australia. You have statutory guarantees under the Australian Consumer Law and nothing in this agreement is intended to affect those rights. - b. Canada. If you acquired this software in Canada, you may stop receiving updates by turning off the automatic update feature, disconnecting your device from the Internet (if and when you re-connect to the Internet, however, the software will resume checking for and installing updates), or uninstalling the software. The product documentation, if any, may also specify how to turn off updates for your specific device or software. - c. Germany and Austria. - (i) Warranty. The properly licensed software will perform substantially as described in any Microsoft materials that accompany the software. However, Microsoft gives no contractual guarantee in relation to the licensed software. - (ii) Limitation of Liability. In case of intentional conduct, gross negligence, claims based on the Product Liability Act, as well as, in case of death or personal or physical injury, Microsoft is liable according to the statutory law. - Subject to the foregoing clause (ii), Microsoft will only be liable for slight negligence if Microsoft is in breach of such material contractual obligations, the fulfillment of which facilitate the due performance of this agreement, the breach of which would endanger the purpose of this agreement and the compliance with which a party may constantly trust in (so-called "cardinal obligations"). In other cases of slight negligence, Microsoft will not be liable for slight negligence. - -10. DISCLAIMER OF WARRANTY. THE SOFTWARE IS LICENSED “AS IS.” YOU BEAR THE RISK OF USING IT. MICROSOFT GIVES NO EXPRESS WARRANTIES, GUARANTEES, OR CONDITIONS. TO THE EXTENT PERMITTED UNDER APPLICABLE LAWS, MICROSOFT EXCLUDES ALL IMPLIED WARRANTIES, INCLUDING MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. - -11. LIMITATION ON AND EXCLUSION OF DAMAGES. IF YOU HAVE ANY BASIS FOR RECOVERING DAMAGES DESPITE THE PRECEDING DISCLAIMER OF WARRANTY, YOU CAN RECOVER FROM MICROSOFT AND ITS SUPPLIERS ONLY DIRECT DAMAGES UP TO U.S. $5.00. YOU CANNOT RECOVER ANY OTHER DAMAGES, INCLUDING CONSEQUENTIAL, LOST PROFITS, SPECIAL, INDIRECT OR INCIDENTAL DAMAGES. -This limitation applies to (a) anything related to the software, services, content (including code) on third party Internet sites, or third party applications; and (b) claims for breach of contract, warranty, guarantee, or condition; strict liability, negligence, or other tort; or any other claim; in each case to the extent permitted by applicable law. -It also applies even if Microsoft knew or should have known about the possibility of the damages. The above limitation or exclusion may not apply to you because your state, province, or country may not allow the exclusion or limitation of incidental, consequential, or other damages. - - -[Please note: As this software is distributed in Canada, some of the clauses in this agreement are provided below in French. - -Remarque: Ce logiciel étant distribué au Canada, certaines des clauses dans ce contrat sont fournies ci-dessous en français. - -EXONÉRATION DE GARANTIE. Le logiciel visé par une licence est offert « tel quel ». Toute utilisation de ce logiciel est à votre seule risque et péril. Microsoft n’accorde aucune autre garantie expresse. Vous pouvez bénéficier de droits additionnels en vertu du droit local sur la protection des consommateurs, que ce contrat ne peut modifier. La ou elles sont permises par le droit locale, les garanties implicites de qualité marchande, d’adéquation à un usage particulier et d’absence de contrefaçon sont exclues. - -LIMITATION DES DOMMAGES-INTÉRÊTS ET EXCLUSION DE RESPONSABILITÉ POUR LES DOMMAGES. Vous pouvez obtenir de Microsoft et de ses fournisseurs une indemnisation en cas de dommages directs uniquement à hauteur de 5,00 $ US. Vous ne pouvez prétendre à aucune indemnisation pour les autres dommages, y compris les dommages spéciaux, indirects ou accessoires et pertes de bénéfices. - -Cette limitation concerne: - * tout ce qui est relié au logiciel, aux services ou au contenu (y compris le code) figurant sur des sites Internet tiers ou dans des programmes tiers; et - * les réclamations au titre de violation de contrat ou de garantie, ou au titre de responsabilité stricte, de négligence ou d’une autre faute dans la limite autorisée par la loi en vigueur. - -Elle s’applique également, même si Microsoft connaissait ou devrait connaître l’éventualité d’un tel dommage. Si votre pays n’autorise pas l’exclusion ou la limitation de responsabilité pour les dommages indirects, accessoires ou de quelque nature que ce soit, il se peut que la limitation ou l’exclusion ci-dessus ne s’appliquera pas à votre égard. - -EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous pourriez avoir d’autres droits prévus par les lois de votre pays. Le présent contrat ne modifie pas les droits que vous confèrent les lois de votre pays si celles-ci ne le permettent pas.] diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/.editorconfig b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/.editorconfig deleted file mode 100644 index c6dc600..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/.editorconfig +++ /dev/null @@ -1,24 +0,0 @@ -# See http://editorconfig.org to read about the EditorConfig format. -# - In theory automatically supported by VS2017+ and most common IDE or text editors. -# - In practice VS2019 stills gets trailing whitespaces wrong :( -# - Suggest install to trim whitespaces: https://marketplace.visualstudio.com/items?itemName=MadsKristensen.TrailingWhitespaceVisualizer -# - Alternative for older VS2010 to VS2015: https://marketplace.visualstudio.com/items?itemName=EditorConfigTeam.EditorConfig - -# top-most EditorConfig file -root = true - -# Default settings: -# Use 4 spaces as indentation -[*] -indent_style = space -indent_size = 4 -insert_final_newline = true -trim_trailing_whitespace = true - -[imstb_*] -indent_size = 3 -trim_trailing_whitespace = false - -[Makefile] -indent_style = tab -indent_size = 4 diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/.gitattributes b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/.gitattributes deleted file mode 100644 index d48470e..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/.gitattributes +++ /dev/null @@ -1,30 +0,0 @@ -* text=auto - -*.c text -*.cpp text -*.h text -*.m text -*.mm text -*.md text -*.txt text -*.html text -*.bat text -*.frag text -*.vert text -*.mkb text -*.icf text - -*.sln text eol=crlf -*.vcxproj text eol=crlf -*.vcxproj.filters text eol=crlf -*.natvis text eol=crlf - -Makefile text eol=lf -*.sh text eol=lf -*.pbxproj text eol=lf -*.storyboard text eol=lf -*.plist text eol=lf - -*.png binary -*.ttf binary -*.lib binary diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/.github/FUNDING.yml b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/.github/FUNDING.yml deleted file mode 100644 index 2aa08b4..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/.github/FUNDING.yml +++ /dev/null @@ -1 +0,0 @@ -custom: ['https://github.com/ocornut/imgui/wiki/Sponsors'] diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/.github/issue_template.md b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/.github/issue_template.md deleted file mode 100644 index fdd0943..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/.github/issue_template.md +++ /dev/null @@ -1,46 +0,0 @@ -(Click "Preview" above ^ to turn URL into clickable links) - -1. FOR FIRST-TIME USERS ISSUES COMPILING/LINKING/RUNNING or LOADING FONTS, please use [GitHub Discussions](https://github.com/ocornut/imgui/discussions). - -2. PLEASE CAREFULLY READ: [FAQ](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md) - -3. PLEASE CAREFULLY READ: [Issue Submitting Guidelines](https://github.com/ocornut/imgui/issues/2261) - -4. PLEASE MAKE SURE that you have: read the FAQ; explored the contents of `ShowDemoWindow()` including the Examples menu; searched among Issues; used your IDE to search for keywords in all sources and text files; and read the links above. - -5. Be mindful that messages are being sent to the e-mail box of "Watching" users. Try to proof-read your messages before sending them. Edits are not seen by those users. - -6. Delete points 1-6 and PLEASE FILL THE TEMPLATE BELOW before submitting your issue. - -Thank you! - ----- - -_(you may also go to Demo>About Window, and click "Config/Build Information" to obtain a bunch of detailed information that you can paste here)_ - -**Version/Branch of Dear ImGui:** - -Version: XXX -Branch: XXX _(master/viewport/docking/etc.)_ - -**Back-end/Renderer/Compiler/OS** - -Back-ends: imgui_impl_XXX.cpp + imgui_impl_XXX.cpp _(or specify if using a custom engine/back-end)_ -Compiler: XXX _(if the question is related to building or platform specific features)_ -Operating System: XXX - -**My Issue/Question:** - -XXX _(please provide as much context as possible)_ - -**Screenshots/Video** - -XXX _(you can drag files here)_ - -**Standalone, minimal, complete and verifiable example:** _(see https://github.com/ocornut/imgui/issues/2261)_ -``` -// Here's some code anyone can copy and paste to reproduce your issue -ImGui::Begin("Example Bug"); -MoreCodeToExplainMyIssue(); -ImGui::End(); -``` diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/.github/pull_request_template.md b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/.github/pull_request_template.md deleted file mode 100644 index 187d710..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/.github/pull_request_template.md +++ /dev/null @@ -1,6 +0,0 @@ -(Click "Preview" to turn any http URL into a clickable link) - -1. PLEASE CAREFULLY READ: [Issue Submitting Guidelines](https://github.com/ocornut/imgui/issues/2261) - -2. Clear this template before submitting your PR. - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/.github/workflows/build.yml b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/.github/workflows/build.yml deleted file mode 100644 index f01bff8..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/.github/workflows/build.yml +++ /dev/null @@ -1,516 +0,0 @@ -name: build - -on: - push: - pull_request: - workflow_run: - # Use a workflow as a trigger of scheduled builds. Forked repositories can disable scheduled builds by disabling - # "scheduled" workflow, while maintaining ability to perform local CI builds. - workflows: - - scheduled - branches: - - master - - docking - types: - - requested - -jobs: - Windows: - runs-on: windows-2019 - env: - VS_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\ - MSBUILD_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\ - steps: - - uses: actions/checkout@v2 - - - name: Install Dependencies - shell: powershell - run: | - Invoke-WebRequest -Uri "https://www.libsdl.org/release/SDL2-devel-2.0.10-VC.zip" -OutFile "SDL2-devel-2.0.10-VC.zip" - Expand-Archive -Path SDL2-devel-2.0.10-VC.zip - echo "SDL2_DIR=$(pwd)\SDL2-devel-2.0.10-VC\SDL2-2.0.10\" >>${env:GITHUB_ENV} - - Invoke-WebRequest -Uri "https://github.com/ocornut/imgui/files/3789205/vulkan-sdk-1.1.121.2.zip" -OutFile vulkan-sdk-1.1.121.2.zip - Expand-Archive -Path vulkan-sdk-1.1.121.2.zip - echo "VULKAN_SDK=$(pwd)\vulkan-sdk-1.1.121.2\" >>${env:GITHUB_ENV} - - - name: Fix Projects - shell: powershell - run: | - # WARNING: This will need updating if toolset/sdk change in project files! - gci -recurse -filter "*.vcxproj" | ForEach-Object { - # Fix SDK and toolset for most samples. - (Get-Content $_.FullName) -Replace "v110","v142" | Set-Content -Path $_.FullName - (Get-Content $_.FullName) -Replace "8.1","10.0.18362.0" | Set-Content -Path $_.FullName - # Fix SDK and toolset for samples that require newer SDK/toolset. At the moment it is only dx12. - (Get-Content $_.FullName) -Replace "v140","v142" | Set-Content -Path $_.FullName - (Get-Content $_.FullName) -Replace "10.0.14393.0","10.0.18362.0" | Set-Content -Path $_.FullName - } - - # Not using matrix here because it would inflate job count too much. Check out and setup is done for every job and that makes build times way too long. - - name: Build example_null (extra warnings, mingw 64-bit) - run: mingw32-make -C examples/example_null WITH_EXTRA_WARNINGS=1 - - - name: Build example_null (extra warnings, msvc 64-bit) - shell: cmd - run: | - cd examples\example_null - call "%VS_PATH%\VC\Auxiliary\Build\vcvars64.bat" - .\build_win32.bat /W4 - - - name: Build example_null (single file build) - shell: bash - run: | - cat > example_single_file.cpp <<'EOF' - - #define IMGUI_IMPLEMENTATION - #include "misc/single_file/imgui_single_file.h" - #include "examples/example_null/main.cpp" - - EOF - g++ -I. -Wall -Wformat -o example_single_file.exe example_single_file.cpp -limm32 - - - name: Build example_null (with IMGUI_DISABLE_WIN32_FUNCTIONS) - shell: bash - run: | - cat > example_single_file.cpp <<'EOF' - - #define IMGUI_DISABLE_WIN32_FUNCTIONS - #define IMGUI_IMPLEMENTATION - #include "misc/single_file/imgui_single_file.h" - #include "examples/example_null/main.cpp" - - EOF - g++ -I. -Wall -Wformat -o example_single_file.exe example_single_file.cpp -limm32 - - - name: Build example_null (as DLL) - shell: cmd - run: | - call "%VS_PATH%\VC\Auxiliary\Build\vcvars64.bat" - - echo #ifdef _EXPORT > example_single_file.cpp - echo # define IMGUI_API __declspec(dllexport) >> example_single_file.cpp - echo #else >> example_single_file.cpp - echo # define IMGUI_API __declspec(dllimport) >> example_single_file.cpp - echo #endif >> example_single_file.cpp - echo #define IMGUI_IMPLEMENTATION >> example_single_file.cpp - echo #include "misc/single_file/imgui_single_file.h" >> example_single_file.cpp - - cl.exe /D_USRDLL /D_WINDLL /D_EXPORT /I. example_single_file.cpp /LD /FeImGui.dll /link - cl.exe /I. ImGui.lib /Feexample_null.exe examples/example_null/main.cpp - - - name: Build Win32 example_glfw_opengl2 - shell: cmd - run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj /p:Platform=Win32 /p:Configuration=Release' - - - name: Build Win32 example_glfw_opengl3 - shell: cmd - run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj /p:Platform=Win32 /p:Configuration=Release' - if: github.event_name == 'workflow_run' - - - name: Build Win32 example_glfw_vulkan - shell: cmd - run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj /p:Platform=Win32 /p:Configuration=Release' - if: github.event_name == 'workflow_run' - - - name: Build Win32 example_sdl_vulkan - shell: cmd - run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj /p:Platform=Win32 /p:Configuration=Release' - if: github.event_name == 'workflow_run' - - - name: Build Win32 example_sdl_opengl2 - shell: cmd - run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj /p:Platform=Win32 /p:Configuration=Release' - if: github.event_name == 'workflow_run' - - - name: Build Win32 example_sdl_opengl3 - shell: cmd - run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj /p:Platform=Win32 /p:Configuration=Release' - - - name: Build Win32 example_sdl_directx11 - shell: cmd - run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_directx11/example_sdl_directx11.vcxproj /p:Platform=Win32 /p:Configuration=Release' - if: github.event_name == 'workflow_run' - - - name: Build Win32 example_win32_directx9 - shell: cmd - run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx9/example_win32_directx9.vcxproj /p:Platform=Win32 /p:Configuration=Release' - - - name: Build Win32 example_win32_directx10 - shell: cmd - run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx10/example_win32_directx10.vcxproj /p:Platform=Win32 /p:Configuration=Release' - - - name: Build Win32 example_win32_directx11 - shell: cmd - run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx11/example_win32_directx11.vcxproj /p:Platform=Win32 /p:Configuration=Release' - if: github.event_name == 'workflow_run' - - - name: Build x64 example_glfw_opengl2 - shell: cmd - run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj /p:Platform=x64 /p:Configuration=Release' - if: github.event_name == 'workflow_run' - - - name: Build x64 example_glfw_opengl3 - shell: cmd - run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj /p:Platform=x64 /p:Configuration=Release' - - - name: Build x64 example_glfw_vulkan - shell: cmd - run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj /p:Platform=x64 /p:Configuration=Release' - - - name: Build x64 example_sdl_vulkan - shell: cmd - run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj /p:Platform=x64 /p:Configuration=Release' - if: github.event_name == 'workflow_run' - - - name: Build x64 example_sdl_opengl2 - shell: cmd - run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj /p:Platform=x64 /p:Configuration=Release' - if: github.event_name == 'workflow_run' - - - name: Build x64 example_sdl_opengl3 - shell: cmd - run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj /p:Platform=x64 /p:Configuration=Release' - if: github.event_name == 'workflow_run' - - - name: Build x64 example_sdl_directx11 - shell: cmd - run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_sdl_directx11/example_sdl_directx11.vcxproj /p:Platform=x64 /p:Configuration=Release' - - - name: Build x64 example_win32_directx9 - shell: cmd - run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx9/example_win32_directx9.vcxproj /p:Platform=x64 /p:Configuration=Release' - if: github.event_name == 'workflow_run' - - - name: Build x64 example_win32_directx10 - shell: cmd - run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx10/example_win32_directx10.vcxproj /p:Platform=x64 /p:Configuration=Release' - if: github.event_name == 'workflow_run' - - - name: Build x64 example_win32_directx11 - shell: cmd - run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx11/example_win32_directx11.vcxproj /p:Platform=x64 /p:Configuration=Release' - if: github.event_name == 'workflow_run' - - - name: Build x64 example_win32_directx12 - shell: cmd - run: '"%MSBUILD_PATH%\MSBuild.exe" examples/example_win32_directx12/example_win32_directx12.vcxproj /p:Platform=x64 /p:Configuration=Release' - - Linux: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - - name: Install Dependencies - run: | - sudo apt-get update - sudo apt-get install -y libglfw3-dev libsdl2-dev gcc-multilib g++-multilib libfreetype6-dev libvulkan-dev - - - name: Build example_null (extra warnings, gcc 32-bit) - run: | - make -C examples/example_null clean - CXXFLAGS="$CXXFLAGS -m32 -Werror" make -C examples/example_null WITH_EXTRA_WARNINGS=1 - - - name: Build example_null (extra warnings, gcc 64-bit) - run: | - make -C examples/example_null clean - CXXFLAGS="$CXXFLAGS -m64 -Werror" make -C examples/example_null WITH_EXTRA_WARNINGS=1 - - - name: Build example_null (extra warnings, clang 32-bit) - run: | - make -C examples/example_null clean - CXXFLAGS="$CXXFLAGS -m32 -Werror" CXX=clang++ make -C examples/example_null WITH_EXTRA_WARNINGS=1 - - - name: Build example_null (extra warnings, clang 64-bit) - run: | - make -C examples/example_null clean - CXXFLAGS="$CXXFLAGS -m64 -Werror" CXX=clang++ make -C examples/example_null WITH_EXTRA_WARNINGS=1 - - - name: Build example_null (extra warnings, empty IM_ASSERT) - run: | - cat > example_single_file.cpp <<'EOF' - - #define IM_ASSERT(x) - #define IMGUI_IMPLEMENTATION - #include "misc/single_file/imgui_single_file.h" - #include "examples/example_null/main.cpp" - - EOF - g++ -I. -Wall -Wformat -Wextra -Werror -Wno-zero-as-null-pointer-constant -Wno-double-promotion -Wno-variadic-macros -Wno-empty-body -o example_single_file example_single_file.cpp - - - name: Build example_null (freetype) - run: | - make -C examples/example_null clean - make -C examples/example_null WITH_FREETYPE=1 - - - name: Build example_null (single file build) - run: | - cat > example_single_file.cpp <<'EOF' - - #define IMGUI_IMPLEMENTATION - #include "misc/single_file/imgui_single_file.h" - #include "examples/example_null/main.cpp" - - EOF - g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp - - - name: Build example_null (with ImWchar32) - run: | - cat > example_single_file.cpp <<'EOF' - - #define IMGUI_USE_WCHAR32 - #define IMGUI_IMPLEMENTATION - #include "misc/single_file/imgui_single_file.h" - #include "examples/example_null/main.cpp" - - EOF - g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp - - - name: Build example_null (with large ImDrawIdx + pointer ImTextureID) - run: | - cat > example_single_file.cpp <<'EOF' - - #define ImTextureID void* - #define ImDrawIdx unsigned int - #define IMGUI_IMPLEMENTATION - #include "misc/single_file/imgui_single_file.h" - #include "examples/example_null/main.cpp" - - EOF - g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp - - - name: Build example_null (with IMGUI_DISABLE_OBSOLETE_FUNCTIONS) - run: | - cat > example_single_file.cpp <<'EOF' - - #define IMGUI_DISABLE_OBSOLETE_FUNCTIONS - #define IMGUI_IMPLEMENTATION - #include "misc/single_file/imgui_single_file.h" - #include "examples/example_null/main.cpp" - - EOF - g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp - - - name: Build example_null (with IMGUI_DISABLE_DEMO_WINDOWS and IMGUI_DISABLE_METRICS_WINDOW) - run: | - cat > example_single_file.cpp <<'EOF' - - #define IMGUI_DISABLE_DEMO_WINDOWS - #define IMGUI_DISABLE_METRICS_WINDOW - #define IMGUI_IMPLEMENTATION - #include "misc/single_file/imgui_single_file.h" - #include "examples/example_null/main.cpp" - - EOF - g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp - - - name: Build example_null (with IMGUI_DISABLE_FILE_FUNCTIONS) - run: | - cat > example_single_file.cpp <<'EOF' - - #define IMGUI_DISABLE_FILE_FUNCTIONS - #define IMGUI_IMPLEMENTATION - #include "misc/single_file/imgui_single_file.h" - #include "examples/example_null/main.cpp" - - EOF - g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp - - - name: Build example_null (with IMGUI_USE_BGRA_PACKED_COLOR) - run: | - cat > example_single_file.cpp <<'EOF' - - #define IMGUI_USE_BGRA_PACKED_COLOR - #define IMGUI_IMPLEMENTATION - #include "misc/single_file/imgui_single_file.h" - #include "examples/example_null/main.cpp" - - EOF - g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp - - - name: Build example_null (with IM_VEC2_CLASS_EXTRA and IM_VEC4_CLASS_EXTRA) - run: | - cat > example_single_file.cpp <<'EOF' - - struct MyVec2 { float x; float y; MyVec2(float x, float y) : x(x), y(y) { } }; - struct MyVec4 { float x; float y; float z; float w; - MyVec4(float x, float y, float z, float w) : x(x), y(y), z(z), w(w) { } }; - #define IM_VEC2_CLASS_EXTRA \ - ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \ - operator MyVec2() const { return MyVec2(x, y); } - #define IM_VEC4_CLASS_EXTRA \ - ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \ - operator MyVec4() const { return MyVec4(x, y, z, w); } - #define IMGUI_IMPLEMENTATION - #include "misc/single_file/imgui_single_file.h" - #include "examples/example_null/main.cpp" - - EOF - g++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp - - - name: Build example_null (without c++ runtime, Clang) - run: | - cat > example_single_file.cpp <<'EOF' - - #define IMGUI_IMPLEMENTATION - #define IMGUI_DISABLE_DEMO_WINDOWS - #include "misc/single_file/imgui_single_file.h" - #include "examples/example_null/main.cpp" - - EOF - clang++ -I. -Wall -Wformat -nodefaultlibs -fno-rtti -fno-exceptions -fno-threadsafe-statics -lc -lm -o example_single_file example_single_file.cpp - - - name: Build example_glfw_opengl2 - run: make -C examples/example_glfw_opengl2 - - - name: Build example_glfw_opengl3 - run: make -C examples/example_glfw_opengl3 - if: github.event_name == 'workflow_run' - - - name: Build example_sdl_opengl2 - run: make -C examples/example_sdl_opengl2 - if: github.event_name == 'workflow_run' - - - name: Build example_sdl_opengl3 - run: make -C examples/example_sdl_opengl3 - - - name: Build with IMGUI_IMPL_VULKAN_NO_PROTOTYPES - run: g++ -c -I. -DIMGUI_IMPL_VULKAN_NO_PROTOTYPES=1 backends/imgui_impl_vulkan.cpp - - MacOS: - runs-on: macos-latest - steps: - - uses: actions/checkout@v2 - - - name: Install Dependencies - run: | - brew install glfw3 sdl2 - - - name: Build example_null (extra warnings, clang 64-bit) - run: make -C examples/example_null WITH_EXTRA_WARNINGS=1 - - - name: Build example_null (single file build) - run: | - cat > example_single_file.cpp <<'EOF' - - #define IMGUI_IMPLEMENTATION - #include "misc/single_file/imgui_single_file.h" - #include "examples/example_null/main.cpp" - - EOF - clang++ -I. -Wall -Wformat -o example_single_file example_single_file.cpp - - - name: Build example_null (without c++ runtime) - run: | - cat > example_single_file.cpp <<'EOF' - - #define IMGUI_IMPLEMENTATION - #include "misc/single_file/imgui_single_file.h" - #include "examples/example_null/main.cpp" - - EOF - clang++ -I. -Wall -Wformat -nodefaultlibs -fno-rtti -fno-exceptions -fno-threadsafe-statics -lc -lm -o example_single_file example_single_file.cpp - - - name: Build example_glfw_opengl2 - run: make -C examples/example_glfw_opengl2 - - - name: Build example_glfw_opengl3 - run: make -C examples/example_glfw_opengl3 - if: github.event_name == 'workflow_run' - - - name: Build example_glfw_metal - run: make -C examples/example_glfw_metal - - - name: Build example_sdl_metal - run: make -C examples/example_sdl_metal - - - name: Build example_sdl_opengl2 - run: make -C examples/example_sdl_opengl2 - if: github.event_name == 'workflow_run' - - - name: Build example_sdl_opengl3 - run: make -C examples/example_sdl_opengl3 - - - name: Build example_apple_metal - run: xcodebuild -project examples/example_apple_metal/example_apple_metal.xcodeproj -target example_apple_metal_macos - - - name: Build example_apple_opengl2 - run: xcodebuild -project examples/example_apple_opengl2/example_apple_opengl2.xcodeproj -target example_osx_opengl2 - - iOS: - runs-on: macos-latest - steps: - - uses: actions/checkout@v2 - - - name: Build example_apple_metal - run: | - # Code signing is required, but we disable it because it is irrelevant for CI builds. - xcodebuild -project examples/example_apple_metal/example_apple_metal.xcodeproj -target example_apple_metal_ios CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO - - Emscripten: - runs-on: ubuntu-18.04 - steps: - - uses: actions/checkout@v2 - - - name: Install Dependencies - run: | - wget -q https://github.com/emscripten-core/emsdk/archive/master.tar.gz - tar -xvf master.tar.gz - emsdk-master/emsdk update - emsdk-master/emsdk install latest - emsdk-master/emsdk activate latest - - - name: Build example_emscripten_opengl3 - run: | - pushd emsdk-master - source ./emsdk_env.sh - popd - make -C examples/example_emscripten_opengl3 - - - name: Build example_emscripten_wgpu - run: | - pushd emsdk-master - source ./emsdk_env.sh - popd - make -C examples/example_emscripten_wgpu - - Android: - runs-on: ubuntu-18.04 - steps: - - uses: actions/checkout@v2 - - - name: Build example_android_opengl3 - run: | - cd examples/example_android_opengl3/android - gradle assembleDebug - - Discord-CI: - runs-on: ubuntu-18.04 - if: always() - needs: [Windows, Linux, MacOS, iOS, Emscripten, Android] - steps: - - uses: dearimgui/github_discord_notifier@latest - with: - discord-webhook: ${{ secrets.DISCORD_CI_WEBHOOK }} - github-token: ${{ github.token }} - action-task: discord-jobs - discord-filter: "'{{ github.branch }}'.match(/master|docking/g) != null && '{{ run.conclusion }}' != '{{ last_run.conclusion }}'" - discord-username: GitHub Actions - discord-job-new-failure-message: '' - discord-job-fixed-failure-message: '' - discord-job-new-failure-embed: | - { - "title": "`{{ job.name }}` job is failing on `{{ github.branch }}`!", - "description": "Commit [{{ github.context.payload.head_commit.title }}]({{ github.context.payload.head_commit.url }}) pushed to [{{ github.branch }}]({{ github.branch_url }}) broke [{{ job.name }}]({{ job.url }}) build job.\nFailing steps: {{ failing_steps }}", - "url": "{{ job.url }}", - "color": "0xFF0000", - "timestamp": "{{ run.updated_at }}" - } - discord-job-fixed-failure-embed: | - { - "title": "`{{ github.branch }}` branch is no longer failing!", - "description": "Build failures were fixed on [{{ github.branch }}]({{ github.branch_url }}) branch.", - "color": "0x00FF00", - "url": "{{ github.context.payload.head_commit.url }}", - "timestamp": "{{ run.completed_at }}" - } diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/.github/workflows/scheduled.yml b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/.github/workflows/scheduled.yml deleted file mode 100644 index 2a08578..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/.github/workflows/scheduled.yml +++ /dev/null @@ -1,15 +0,0 @@ -# -# This is a dummy workflow used to trigger scheduled builds. Forked repositories most likely should disable this -# workflow to avoid daily builds of inactive repositories. -# -name: scheduled - -on: - schedule: - - cron: '0 9 * * *' - -jobs: - scheduled: - runs-on: ubuntu-latest - steps: - - run: exit 0 diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/.github/workflows/static-analysis.yml b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/.github/workflows/static-analysis.yml deleted file mode 100644 index f3e6b2d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/.github/workflows/static-analysis.yml +++ /dev/null @@ -1,77 +0,0 @@ -name: static-analysis - -on: - workflow_run: - # Perform static analysis together with build workflow. Build triggers of "build" workflow do not need to be repeated here. - workflows: - - build - types: - - requested - -jobs: - PVS-Studio: - runs-on: ubuntu-18.04 - steps: - - uses: actions/checkout@v1 - with: - fetch-depth: 1 - - - name: Install Dependencies - env: - # The Secret variable setup in GitHub must be in format: "name_or_email key", on a single line - PVS_STUDIO_LICENSE: ${{ secrets.PVS_STUDIO_LICENSE }} - run: | - if [[ "$PVS_STUDIO_LICENSE" != "" ]]; - then - wget -q https://files.viva64.com/etc/pubkey.txt - sudo apt-key add pubkey.txt - sudo wget -O /etc/apt/sources.list.d/viva64.list https://files.viva64.com/etc/viva64.list - sudo apt-get update - sudo apt-get install -y pvs-studio - pvs-studio-analyzer credentials -o pvs-studio.lic $PVS_STUDIO_LICENSE - fi - - - name: PVS-Studio static analysis - run: | - if [[ ! -f pvs-studio.lic ]]; - then - echo "PVS Studio license is missing. No analysis will be performed." - echo "If you have a PVS Studio license please create a project secret named PVS_STUDIO_LICENSE with your license." - echo "You may use a free license. More information at https://www.viva64.com/en/b/0457/" - exit 0 - fi - cd examples/example_null - pvs-studio-analyzer trace -- make WITH_EXTRA_WARNINGS=1 - pvs-studio-analyzer analyze -e ../../imstb_rectpack.h -e ../../imstb_textedit.h -e ../../imstb_truetype.h -l ../../pvs-studio.lic -o pvs-studio.log - plog-converter -a 'GA:1,2;OP:1' -d V1071 -t errorfile -w pvs-studio.log - - Discord-CI: - runs-on: ubuntu-18.04 - needs: [PVS-Studio] - if: always() - steps: - - uses: dearimgui/github_discord_notifier@latest - with: - discord-webhook: ${{ secrets.DISCORD_CI_WEBHOOK }} - github-token: ${{ github.token }} - action-task: discord-jobs - discord-filter: "'{{ github.branch }}'.match(/master|docking/g) != null && '{{ run.conclusion }}' != '{{ last_run.conclusion }}'" - discord-username: GitHub Actions - discord-job-new-failure-message: '' - discord-job-fixed-failure-message: '' - discord-job-new-failure-embed: | - { - "title": "`{{ job.name }}` job is failing on `{{ github.branch }}`!", - "description": "Commit [{{ github.context.payload.head_commit.title }}]({{ github.context.payload.head_commit.url }}) pushed to [{{ github.branch }}]({{ github.branch_url }}) broke static analysis [{{ job.name }}]({{ job.url }}) job.\nFailing steps: {{ failing_steps }}", - "url": "{{ job.url }}", - "color": "0xFF0000", - "timestamp": "{{ run.updated_at }}" - } - discord-job-fixed-failure-embed: | - { - "title": "`{{ github.branch }}` branch is no longer failing!", - "description": "Static analysis failures were fixed on [{{ github.branch }}]({{ github.branch_url }}) branch.", - "color": "0x00FF00", - "url": "{{ github.context.payload.head_commit.url }}", - "timestamp": "{{ run.completed_at }}" - } diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/.gitignore b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/.gitignore deleted file mode 100644 index 86bed60..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/.gitignore +++ /dev/null @@ -1,53 +0,0 @@ -## OSX artifacts -.DS_Store - -## Dear ImGui artifacts -imgui.ini - -## General build artifacts -*.o -*.obj -*.exe -examples/build/* -examples/*/Debug/* -examples/*/Release/* -examples/*/x64/* - -## Visual Studio artifacts -.vs -ipch -*.opensdf -*.log -*.pdb -*.ilk -*.user -*.sdf -*.suo -*.VC.db -*.VC.VC.opendb - -## Commonly used CMake directories -/build*/ - -## Xcode artifacts -project.xcworkspace -xcuserdata - -## Emscripten artifacts -examples/*.o.tmp -examples/*.out.js -examples/*.out.wasm -examples/example_emscripten_opengl3/web/* -examples/example_emscripten_wgpu/web/* - -## JetBrains IDE artifacts -.idea -cmake-build-* - -## Unix executables from our example Makefiles -examples/example_glfw_opengl2/example_glfw_opengl2 -examples/example_glfw_opengl3/example_glfw_opengl3 -examples/example_glut_opengl2/example_glut_opengl2 -examples/example_null/example_null -examples/example_sdl_opengl2/example_sdl_opengl2 -examples/example_sdl_opengl3/example_sdl_opengl3 diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/LICENSE.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/LICENSE.txt deleted file mode 100644 index 780533d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014-2021 Omar Cornut - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_allegro5.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_allegro5.cpp deleted file mode 100644 index ccb1396..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_allegro5.cpp +++ /dev/null @@ -1,478 +0,0 @@ -// dear imgui: Renderer + Platform Backend for Allegro 5 -// (Info: Allegro 5 is a cross-platform general purpose library for handling windows, inputs, graphics, etc.) - -// Implemented features: -// [X] Renderer: User texture binding. Use 'ALLEGRO_BITMAP*' as ImTextureID. Read the FAQ about ImTextureID! -// [X] Platform: Clipboard support (from Allegro 5.1.12) -// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. -// Issues: -// [ ] Renderer: The renderer is suboptimal as we need to unindex our buffers and convert vertices manually. -// [ ] Platform: Missing gamepad support. - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -// CHANGELOG -// (minor and older changes stripped away, please see git history for details) -// 2021-08-17: Calling io.AddFocusEvent() on ALLEGRO_EVENT_DISPLAY_SWITCH_OUT/ALLEGRO_EVENT_DISPLAY_SWITCH_IN events. -// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX). -// 2021-05-19: Renderer: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement) -// 2021-02-18: Change blending equation to preserve alpha in output buffer. -// 2020-08-10: Inputs: Fixed horizontal mouse wheel direction. -// 2019-12-05: Inputs: Added support for ImGuiMouseCursor_NotAllowed mouse cursor. -// 2019-07-21: Inputs: Added mapping for ImGuiKey_KeyPadEnter. -// 2019-05-11: Inputs: Don't filter character value from ALLEGRO_EVENT_KEY_CHAR before calling AddInputCharacter(). -// 2019-04-30: Renderer: Added support for special ImDrawCallback_ResetRenderState callback to reset render state. -// 2018-11-30: Platform: Added touchscreen support. -// 2018-11-30: Misc: Setting up io.BackendPlatformName/io.BackendRendererName so they can be displayed in the About Window. -// 2018-06-13: Platform: Added clipboard support (from Allegro 5.1.12). -// 2018-06-13: Renderer: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle. -// 2018-06-13: Renderer: Backup/restore transform and clipping rectangle. -// 2018-06-11: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors flag + honor ImGuiConfigFlags_NoMouseCursorChange flag. -// 2018-04-18: Misc: Renamed file from imgui_impl_a5.cpp to imgui_impl_allegro5.cpp. -// 2018-04-18: Misc: Added support for 32-bit vertex indices to avoid conversion at runtime. Added imconfig_allegro5.h to enforce 32-bit indices when included from imgui.h. -// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplAllegro5_RenderDrawData() in the .h file so you can call it yourself. -// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves. -// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space. - -#include // uint64_t -#include // memcpy -#include "imgui.h" -#include "imgui_impl_allegro5.h" - -// Allegro -#include -#include -#ifdef _WIN32 -#include -#endif -#define ALLEGRO_HAS_CLIPBOARD (ALLEGRO_VERSION_INT >= ((5 << 24) | (1 << 16) | (12 << 8))) // Clipboard only supported from Allegro 5.1.12 - -// Visual Studio warnings -#ifdef _MSC_VER -#pragma warning (disable: 4127) // condition expression is constant -#endif - -// Allegro Data -struct ImGui_ImplAllegro5_Data -{ - ALLEGRO_DISPLAY* Display; - ALLEGRO_BITMAP* Texture; - double Time; - ALLEGRO_MOUSE_CURSOR* MouseCursorInvisible; - ALLEGRO_VERTEX_DECL* VertexDecl; - char* ClipboardTextData; - - ImGui_ImplAllegro5_Data() { memset(this, 0, sizeof(*this)); } -}; - -// Backend data stored in io.BackendPlatformUserData to allow support for multiple Dear ImGui contexts -// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts. -// FIXME: multi-context support is not well tested and probably dysfunctional in this backend. -static ImGui_ImplAllegro5_Data* ImGui_ImplAllegro5_GetBackendData() { return ImGui::GetCurrentContext() ? (ImGui_ImplAllegro5_Data*)ImGui::GetIO().BackendPlatformUserData : NULL; } - -struct ImDrawVertAllegro -{ - ImVec2 pos; - ImVec2 uv; - ALLEGRO_COLOR col; -}; - -static void ImGui_ImplAllegro5_SetupRenderState(ImDrawData* draw_data) -{ - // Setup blending - al_set_separate_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA, ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA); - - // Setup orthographic projection matrix - // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). - { - float L = draw_data->DisplayPos.x; - float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x; - float T = draw_data->DisplayPos.y; - float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y; - ALLEGRO_TRANSFORM transform; - al_identity_transform(&transform); - al_use_transform(&transform); - al_orthographic_transform(&transform, L, T, 1.0f, R, B, -1.0f); - al_use_projection_transform(&transform); - } -} - -// Render function. -void ImGui_ImplAllegro5_RenderDrawData(ImDrawData* draw_data) -{ - // Avoid rendering when minimized - if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f) - return; - - // Backup Allegro state that will be modified - ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData(); - ALLEGRO_TRANSFORM last_transform = *al_get_current_transform(); - ALLEGRO_TRANSFORM last_projection_transform = *al_get_current_projection_transform(); - int last_clip_x, last_clip_y, last_clip_w, last_clip_h; - al_get_clipping_rectangle(&last_clip_x, &last_clip_y, &last_clip_w, &last_clip_h); - int last_blender_op, last_blender_src, last_blender_dst; - al_get_blender(&last_blender_op, &last_blender_src, &last_blender_dst); - - // Setup desired render state - ImGui_ImplAllegro5_SetupRenderState(draw_data); - - // Render command lists - for (int n = 0; n < draw_data->CmdListsCount; n++) - { - const ImDrawList* cmd_list = draw_data->CmdLists[n]; - - // Allegro's implementation of al_draw_indexed_prim() for DX9 is completely broken. Unindex our buffers ourselves. - // FIXME-OPT: Unfortunately Allegro doesn't support 32-bit packed colors so we have to convert them to 4 float as well.. - static ImVector vertices; - vertices.resize(cmd_list->IdxBuffer.Size); - for (int i = 0; i < cmd_list->IdxBuffer.Size; i++) - { - const ImDrawVert* src_v = &cmd_list->VtxBuffer[cmd_list->IdxBuffer[i]]; - ImDrawVertAllegro* dst_v = &vertices[i]; - dst_v->pos = src_v->pos; - dst_v->uv = src_v->uv; - unsigned char* c = (unsigned char*)&src_v->col; - dst_v->col = al_map_rgba(c[0], c[1], c[2], c[3]); - } - - const int* indices = NULL; - if (sizeof(ImDrawIdx) == 2) - { - // FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices.. You can '#define ImDrawIdx int' in imconfig.h to request Dear ImGui to output 32-bit indices. - // Otherwise, we convert them from 16-bit to 32-bit at runtime here, which works perfectly but is a little wasteful. - static ImVector indices_converted; - indices_converted.resize(cmd_list->IdxBuffer.Size); - for (int i = 0; i < cmd_list->IdxBuffer.Size; ++i) - indices_converted[i] = (int)cmd_list->IdxBuffer.Data[i]; - indices = indices_converted.Data; - } - else if (sizeof(ImDrawIdx) == 4) - { - indices = (const int*)cmd_list->IdxBuffer.Data; - } - - // Render command lists - int idx_offset = 0; - ImVec2 clip_off = draw_data->DisplayPos; - for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) - { - const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; - if (pcmd->UserCallback) - { - // User callback, registered via ImDrawList::AddCallback() - // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.) - if (pcmd->UserCallback == ImDrawCallback_ResetRenderState) - ImGui_ImplAllegro5_SetupRenderState(draw_data); - else - pcmd->UserCallback(cmd_list, pcmd); - } - else - { - // Project scissor/clipping rectangles into framebuffer space - ImVec2 clip_min(pcmd->ClipRect.x - clip_off.x, pcmd->ClipRect.y - clip_off.y); - ImVec2 clip_max(pcmd->ClipRect.z - clip_off.x, pcmd->ClipRect.w - clip_off.y); - if (clip_max.x < clip_min.x || clip_max.y < clip_min.y) - continue; - - // Apply scissor/clipping rectangle, Draw - ALLEGRO_BITMAP* texture = (ALLEGRO_BITMAP*)pcmd->GetTexID(); - al_set_clipping_rectangle(clip_min.x, clip_min.y, clip_max.x - clip_min.x, clip_max.y - clip_min.y); - al_draw_prim(&vertices[0], bd->VertexDecl, texture, idx_offset, idx_offset + pcmd->ElemCount, ALLEGRO_PRIM_TRIANGLE_LIST); - } - idx_offset += pcmd->ElemCount; - } - } - - // Restore modified Allegro state - al_set_blender(last_blender_op, last_blender_src, last_blender_dst); - al_set_clipping_rectangle(last_clip_x, last_clip_y, last_clip_w, last_clip_h); - al_use_transform(&last_transform); - al_use_projection_transform(&last_projection_transform); -} - -bool ImGui_ImplAllegro5_CreateDeviceObjects() -{ - // Build texture atlas - ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData(); - ImGuiIO& io = ImGui::GetIO(); - unsigned char* pixels; - int width, height; - io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); - - // Create texture - int flags = al_get_new_bitmap_flags(); - int fmt = al_get_new_bitmap_format(); - al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP | ALLEGRO_MIN_LINEAR | ALLEGRO_MAG_LINEAR); - al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ABGR_8888_LE); - ALLEGRO_BITMAP* img = al_create_bitmap(width, height); - al_set_new_bitmap_flags(flags); - al_set_new_bitmap_format(fmt); - if (!img) - return false; - - ALLEGRO_LOCKED_REGION* locked_img = al_lock_bitmap(img, al_get_bitmap_format(img), ALLEGRO_LOCK_WRITEONLY); - if (!locked_img) - { - al_destroy_bitmap(img); - return false; - } - memcpy(locked_img->data, pixels, sizeof(int) * width * height); - al_unlock_bitmap(img); - - // Convert software texture to hardware texture. - ALLEGRO_BITMAP* cloned_img = al_clone_bitmap(img); - al_destroy_bitmap(img); - if (!cloned_img) - return false; - - // Store our identifier - io.Fonts->SetTexID((void*)cloned_img); - bd->Texture = cloned_img; - - // Create an invisible mouse cursor - // Because al_hide_mouse_cursor() seems to mess up with the actual inputs.. - ALLEGRO_BITMAP* mouse_cursor = al_create_bitmap(8, 8); - bd->MouseCursorInvisible = al_create_mouse_cursor(mouse_cursor, 0, 0); - al_destroy_bitmap(mouse_cursor); - - return true; -} - -void ImGui_ImplAllegro5_InvalidateDeviceObjects() -{ - ImGuiIO& io = ImGui::GetIO(); - ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData(); - if (bd->Texture) - { - io.Fonts->SetTexID(NULL); - al_destroy_bitmap(bd->Texture); - bd->Texture = NULL; - } - if (bd->MouseCursorInvisible) - { - al_destroy_mouse_cursor(bd->MouseCursorInvisible); - bd->MouseCursorInvisible = NULL; - } -} - -#if ALLEGRO_HAS_CLIPBOARD -static const char* ImGui_ImplAllegro5_GetClipboardText(void*) -{ - ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData(); - if (bd->ClipboardTextData) - al_free(bd->ClipboardTextData); - bd->ClipboardTextData = al_get_clipboard_text(bd->Display); - return bd->ClipboardTextData; -} - -static void ImGui_ImplAllegro5_SetClipboardText(void*, const char* text) -{ - ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData(); - al_set_clipboard_text(bd->Display, text); -} -#endif - -bool ImGui_ImplAllegro5_Init(ALLEGRO_DISPLAY* display) -{ - ImGuiIO& io = ImGui::GetIO(); - IM_ASSERT(io.BackendPlatformUserData == NULL && "Already initialized a platform backend!"); - - // Setup backend capabilities flags - ImGui_ImplAllegro5_Data* bd = IM_NEW(ImGui_ImplAllegro5_Data)(); - io.BackendPlatformUserData = (void*)bd; - io.BackendPlatformName = io.BackendRendererName = "imgui_impl_allegro5"; - io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional) - - bd->Display = display; - - // Create custom vertex declaration. - // Unfortunately Allegro doesn't support 32-bit packed colors so we have to convert them to 4 floats. - // We still use a custom declaration to use 'ALLEGRO_PRIM_TEX_COORD' instead of 'ALLEGRO_PRIM_TEX_COORD_PIXEL' else we can't do a reliable conversion. - ALLEGRO_VERTEX_ELEMENT elems[] = - { - { ALLEGRO_PRIM_POSITION, ALLEGRO_PRIM_FLOAT_2, IM_OFFSETOF(ImDrawVertAllegro, pos) }, - { ALLEGRO_PRIM_TEX_COORD, ALLEGRO_PRIM_FLOAT_2, IM_OFFSETOF(ImDrawVertAllegro, uv) }, - { ALLEGRO_PRIM_COLOR_ATTR, 0, IM_OFFSETOF(ImDrawVertAllegro, col) }, - { 0, 0, 0 } - }; - bd->VertexDecl = al_create_vertex_decl(elems, sizeof(ImDrawVertAllegro)); - - io.KeyMap[ImGuiKey_Tab] = ALLEGRO_KEY_TAB; - io.KeyMap[ImGuiKey_LeftArrow] = ALLEGRO_KEY_LEFT; - io.KeyMap[ImGuiKey_RightArrow] = ALLEGRO_KEY_RIGHT; - io.KeyMap[ImGuiKey_UpArrow] = ALLEGRO_KEY_UP; - io.KeyMap[ImGuiKey_DownArrow] = ALLEGRO_KEY_DOWN; - io.KeyMap[ImGuiKey_PageUp] = ALLEGRO_KEY_PGUP; - io.KeyMap[ImGuiKey_PageDown] = ALLEGRO_KEY_PGDN; - io.KeyMap[ImGuiKey_Home] = ALLEGRO_KEY_HOME; - io.KeyMap[ImGuiKey_End] = ALLEGRO_KEY_END; - io.KeyMap[ImGuiKey_Insert] = ALLEGRO_KEY_INSERT; - io.KeyMap[ImGuiKey_Delete] = ALLEGRO_KEY_DELETE; - io.KeyMap[ImGuiKey_Backspace] = ALLEGRO_KEY_BACKSPACE; - io.KeyMap[ImGuiKey_Space] = ALLEGRO_KEY_SPACE; - io.KeyMap[ImGuiKey_Enter] = ALLEGRO_KEY_ENTER; - io.KeyMap[ImGuiKey_Escape] = ALLEGRO_KEY_ESCAPE; - io.KeyMap[ImGuiKey_KeyPadEnter] = ALLEGRO_KEY_PAD_ENTER; - io.KeyMap[ImGuiKey_A] = ALLEGRO_KEY_A; - io.KeyMap[ImGuiKey_C] = ALLEGRO_KEY_C; - io.KeyMap[ImGuiKey_V] = ALLEGRO_KEY_V; - io.KeyMap[ImGuiKey_X] = ALLEGRO_KEY_X; - io.KeyMap[ImGuiKey_Y] = ALLEGRO_KEY_Y; - io.KeyMap[ImGuiKey_Z] = ALLEGRO_KEY_Z; - io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX); - -#if ALLEGRO_HAS_CLIPBOARD - io.SetClipboardTextFn = ImGui_ImplAllegro5_SetClipboardText; - io.GetClipboardTextFn = ImGui_ImplAllegro5_GetClipboardText; - io.ClipboardUserData = NULL; -#endif - - return true; -} - -void ImGui_ImplAllegro5_Shutdown() -{ - ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData(); - IM_ASSERT(bd != NULL && "No platform backend to shutdown, or already shutdown?"); - ImGuiIO& io = ImGui::GetIO(); - - ImGui_ImplAllegro5_InvalidateDeviceObjects(); - if (bd->VertexDecl) - al_destroy_vertex_decl(bd->VertexDecl); - if (bd->ClipboardTextData) - al_free(bd->ClipboardTextData); - - io.BackendPlatformUserData = NULL; - io.BackendPlatformName = io.BackendRendererName = NULL; - IM_DELETE(bd); -} - -// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. -// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. -// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. -// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. -bool ImGui_ImplAllegro5_ProcessEvent(ALLEGRO_EVENT* ev) -{ - ImGuiIO& io = ImGui::GetIO(); - ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData(); - - switch (ev->type) - { - case ALLEGRO_EVENT_MOUSE_AXES: - if (ev->mouse.display == bd->Display) - { - io.MouseWheel += ev->mouse.dz; - io.MouseWheelH -= ev->mouse.dw; - io.MousePos = ImVec2(ev->mouse.x, ev->mouse.y); - } - return true; - case ALLEGRO_EVENT_MOUSE_BUTTON_DOWN: - case ALLEGRO_EVENT_MOUSE_BUTTON_UP: - if (ev->mouse.display == bd->Display && ev->mouse.button <= 5) - io.MouseDown[ev->mouse.button - 1] = (ev->type == ALLEGRO_EVENT_MOUSE_BUTTON_DOWN); - return true; - case ALLEGRO_EVENT_TOUCH_MOVE: - if (ev->touch.display == bd->Display) - io.MousePos = ImVec2(ev->touch.x, ev->touch.y); - return true; - case ALLEGRO_EVENT_TOUCH_BEGIN: - case ALLEGRO_EVENT_TOUCH_END: - case ALLEGRO_EVENT_TOUCH_CANCEL: - if (ev->touch.display == bd->Display && ev->touch.primary) - io.MouseDown[0] = (ev->type == ALLEGRO_EVENT_TOUCH_BEGIN); - return true; - case ALLEGRO_EVENT_MOUSE_LEAVE_DISPLAY: - if (ev->mouse.display == bd->Display) - io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX); - return true; - case ALLEGRO_EVENT_KEY_CHAR: - if (ev->keyboard.display == bd->Display) - if (ev->keyboard.unichar != 0) - io.AddInputCharacter((unsigned int)ev->keyboard.unichar); - return true; - case ALLEGRO_EVENT_KEY_DOWN: - case ALLEGRO_EVENT_KEY_UP: - if (ev->keyboard.display == bd->Display) - io.KeysDown[ev->keyboard.keycode] = (ev->type == ALLEGRO_EVENT_KEY_DOWN); - return true; - case ALLEGRO_EVENT_DISPLAY_SWITCH_OUT: - if (ev->display.source == bd->Display) - io.AddFocusEvent(false); - return true; - case ALLEGRO_EVENT_DISPLAY_SWITCH_IN: - if (ev->display.source == bd->Display) - { - io.AddFocusEvent(true); -#if defined(ALLEGRO_UNSTABLE) - al_clear_keyboard_state(bd->Display); -#endif - } - return true; - } - return false; -} - -static void ImGui_ImplAllegro5_UpdateMouseCursor() -{ - ImGuiIO& io = ImGui::GetIO(); - if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) - return; - - ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData(); - ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor(); - if (io.MouseDrawCursor || imgui_cursor == ImGuiMouseCursor_None) - { - // Hide OS mouse cursor if imgui is drawing it or if it wants no cursor - al_set_mouse_cursor(bd->Display, bd->MouseCursorInvisible); - } - else - { - ALLEGRO_SYSTEM_MOUSE_CURSOR cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_DEFAULT; - switch (imgui_cursor) - { - case ImGuiMouseCursor_TextInput: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_EDIT; break; - case ImGuiMouseCursor_ResizeAll: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_MOVE; break; - case ImGuiMouseCursor_ResizeNS: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_N; break; - case ImGuiMouseCursor_ResizeEW: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_E; break; - case ImGuiMouseCursor_ResizeNESW: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_NE; break; - case ImGuiMouseCursor_ResizeNWSE: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_NW; break; - case ImGuiMouseCursor_NotAllowed: cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_UNAVAILABLE; break; - } - al_set_system_mouse_cursor(bd->Display, cursor_id); - } -} - -void ImGui_ImplAllegro5_NewFrame() -{ - ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData(); - IM_ASSERT(bd != NULL && "Did you call ImGui_ImplAllegro5_Init()?"); - - if (!bd->Texture) - ImGui_ImplAllegro5_CreateDeviceObjects(); - - ImGuiIO& io = ImGui::GetIO(); - - // Setup display size (every frame to accommodate for window resizing) - int w, h; - w = al_get_display_width(bd->Display); - h = al_get_display_height(bd->Display); - io.DisplaySize = ImVec2((float)w, (float)h); - - // Setup time step - double current_time = al_get_time(); - io.DeltaTime = bd->Time > 0.0 ? (float)(current_time - bd->Time) : (float)(1.0f / 60.0f); - bd->Time = current_time; - - // Setup inputs - ALLEGRO_KEYBOARD_STATE keys; - al_get_keyboard_state(&keys); - io.KeyCtrl = al_key_down(&keys, ALLEGRO_KEY_LCTRL) || al_key_down(&keys, ALLEGRO_KEY_RCTRL); - io.KeyShift = al_key_down(&keys, ALLEGRO_KEY_LSHIFT) || al_key_down(&keys, ALLEGRO_KEY_RSHIFT); - io.KeyAlt = al_key_down(&keys, ALLEGRO_KEY_ALT) || al_key_down(&keys, ALLEGRO_KEY_ALTGR); - io.KeySuper = al_key_down(&keys, ALLEGRO_KEY_LWIN) || al_key_down(&keys, ALLEGRO_KEY_RWIN); - - ImGui_ImplAllegro5_UpdateMouseCursor(); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_allegro5.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_allegro5.h deleted file mode 100644 index 06c7120..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_allegro5.h +++ /dev/null @@ -1,31 +0,0 @@ -// dear imgui: Renderer + Platform Backend for Allegro 5 -// (Info: Allegro 5 is a cross-platform general purpose library for handling windows, inputs, graphics, etc.) - -// Implemented features: -// [X] Renderer: User texture binding. Use 'ALLEGRO_BITMAP*' as ImTextureID. Read the FAQ about ImTextureID! -// [X] Platform: Clipboard support (from Allegro 5.1.12) -// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. -// Issues: -// [ ] Renderer: The renderer is suboptimal as we need to unindex our buffers and convert vertices manually. -// [ ] Platform: Missing gamepad support. - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -#pragma once -#include "imgui.h" // IMGUI_IMPL_API - -struct ALLEGRO_DISPLAY; -union ALLEGRO_EVENT; - -IMGUI_IMPL_API bool ImGui_ImplAllegro5_Init(ALLEGRO_DISPLAY* display); -IMGUI_IMPL_API void ImGui_ImplAllegro5_Shutdown(); -IMGUI_IMPL_API void ImGui_ImplAllegro5_NewFrame(); -IMGUI_IMPL_API void ImGui_ImplAllegro5_RenderDrawData(ImDrawData* draw_data); -IMGUI_IMPL_API bool ImGui_ImplAllegro5_ProcessEvent(ALLEGRO_EVENT* event); - -// Use if you want to reset your rendering device without losing Dear ImGui state. -IMGUI_IMPL_API bool ImGui_ImplAllegro5_CreateDeviceObjects(); -IMGUI_IMPL_API void ImGui_ImplAllegro5_InvalidateDeviceObjects(); diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_android.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_android.cpp deleted file mode 100644 index aae8e6b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_android.cpp +++ /dev/null @@ -1,187 +0,0 @@ -// dear imgui: Platform Binding for Android native app -// This needs to be used along with the OpenGL 3 Renderer (imgui_impl_opengl3) - -// Implemented features: -// [X] Platform: Keyboard arrays indexed using AKEYCODE_* codes, e.g. ImGui::IsKeyPressed(AKEYCODE_SPACE). -// Missing features: -// [ ] Platform: Clipboard support. -// [ ] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. -// [ ] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: Check if this is even possible with Android. -// Important: -// - FIXME: On-screen keyboard currently needs to be enabled by the application (see examples/ and issue #3446) -// - FIXME: Unicode character inputs needs to be passed by Dear ImGui by the application (see examples/ and issue #3446) - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -// CHANGELOG -// (minor and older changes stripped away, please see git history for details) -// 2021-03-04: Initial version. - -#include "imgui.h" -#include "imgui_impl_android.h" -#include -#include -#include -#include -#include -#include -#include - -// Android data -static double g_Time = 0.0; -static ANativeWindow* g_Window; -static char g_LogTag[] = "ImGuiExample"; -static std::map> g_KeyEventQueues; // FIXME: Remove dependency on map and queue once we use upcoming input queue. - -int32_t ImGui_ImplAndroid_HandleInputEvent(AInputEvent* input_event) -{ - ImGuiIO& io = ImGui::GetIO(); - int32_t event_type = AInputEvent_getType(input_event); - switch (event_type) - { - case AINPUT_EVENT_TYPE_KEY: - { - int32_t event_key_code = AKeyEvent_getKeyCode(input_event); - int32_t event_action = AKeyEvent_getAction(input_event); - int32_t event_meta_state = AKeyEvent_getMetaState(input_event); - - io.KeyCtrl = ((event_meta_state & AMETA_CTRL_ON) != 0); - io.KeyShift = ((event_meta_state & AMETA_SHIFT_ON) != 0); - io.KeyAlt = ((event_meta_state & AMETA_ALT_ON) != 0); - - switch (event_action) - { - // FIXME: AKEY_EVENT_ACTION_DOWN and AKEY_EVENT_ACTION_UP occur at once as soon as a touch pointer - // goes up from a key. We use a simple key event queue/ and process one event per key per frame in - // ImGui_ImplAndroid_NewFrame()...or consider using IO queue, if suitable: https://github.com/ocornut/imgui/issues/2787 - case AKEY_EVENT_ACTION_DOWN: - case AKEY_EVENT_ACTION_UP: - g_KeyEventQueues[event_key_code].push(event_action); - break; - default: - break; - } - break; - } - case AINPUT_EVENT_TYPE_MOTION: - { - int32_t event_action = AMotionEvent_getAction(input_event); - int32_t event_pointer_index = (event_action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT; - event_action &= AMOTION_EVENT_ACTION_MASK; - switch (event_action) - { - case AMOTION_EVENT_ACTION_DOWN: - case AMOTION_EVENT_ACTION_UP: - // Physical mouse buttons (and probably other physical devices) also invoke the actions AMOTION_EVENT_ACTION_DOWN/_UP, - // but we have to process them separately to identify the actual button pressed. This is done below via - // AMOTION_EVENT_ACTION_BUTTON_PRESS/_RELEASE. Here, we only process "FINGER" input (and "UNKNOWN", as a fallback). - if((AMotionEvent_getToolType(input_event, event_pointer_index) == AMOTION_EVENT_TOOL_TYPE_FINGER) - || (AMotionEvent_getToolType(input_event, event_pointer_index) == AMOTION_EVENT_TOOL_TYPE_UNKNOWN)) - { - io.MouseDown[0] = (event_action == AMOTION_EVENT_ACTION_DOWN); - io.MousePos = ImVec2(AMotionEvent_getX(input_event, event_pointer_index), AMotionEvent_getY(input_event, event_pointer_index)); - } - break; - case AMOTION_EVENT_ACTION_BUTTON_PRESS: - case AMOTION_EVENT_ACTION_BUTTON_RELEASE: - { - int32_t button_state = AMotionEvent_getButtonState(input_event); - io.MouseDown[0] = ((button_state & AMOTION_EVENT_BUTTON_PRIMARY) != 0); - io.MouseDown[1] = ((button_state & AMOTION_EVENT_BUTTON_SECONDARY) != 0); - io.MouseDown[2] = ((button_state & AMOTION_EVENT_BUTTON_TERTIARY) != 0); - } - break; - case AMOTION_EVENT_ACTION_HOVER_MOVE: // Hovering: Tool moves while NOT pressed (such as a physical mouse) - case AMOTION_EVENT_ACTION_MOVE: // Touch pointer moves while DOWN - io.MousePos = ImVec2(AMotionEvent_getX(input_event, event_pointer_index), AMotionEvent_getY(input_event, event_pointer_index)); - break; - case AMOTION_EVENT_ACTION_SCROLL: - io.MouseWheel = AMotionEvent_getAxisValue(input_event, AMOTION_EVENT_AXIS_VSCROLL, event_pointer_index); - io.MouseWheelH = AMotionEvent_getAxisValue(input_event, AMOTION_EVENT_AXIS_HSCROLL, event_pointer_index); - break; - default: - break; - } - } - return 1; - default: - break; - } - - return 0; -} - -bool ImGui_ImplAndroid_Init(ANativeWindow* window) -{ - g_Window = window; - g_Time = 0.0; - - // Setup backend capabilities flags - ImGuiIO& io = ImGui::GetIO(); - io.BackendPlatformName = "imgui_impl_android"; - - // Keyboard mapping. Dear ImGui will use those indices to peek into the io.KeysDown[] array. - io.KeyMap[ImGuiKey_Tab] = AKEYCODE_TAB; - io.KeyMap[ImGuiKey_LeftArrow] = AKEYCODE_DPAD_LEFT; // also covers physical keyboard arrow key - io.KeyMap[ImGuiKey_RightArrow] = AKEYCODE_DPAD_RIGHT; // also covers physical keyboard arrow key - io.KeyMap[ImGuiKey_UpArrow] = AKEYCODE_DPAD_UP; // also covers physical keyboard arrow key - io.KeyMap[ImGuiKey_DownArrow] = AKEYCODE_DPAD_DOWN; // also covers physical keyboard arrow key - io.KeyMap[ImGuiKey_PageUp] = AKEYCODE_PAGE_UP; - io.KeyMap[ImGuiKey_PageDown] = AKEYCODE_PAGE_DOWN; - io.KeyMap[ImGuiKey_Home] = AKEYCODE_MOVE_HOME; - io.KeyMap[ImGuiKey_End] = AKEYCODE_MOVE_END; - io.KeyMap[ImGuiKey_Insert] = AKEYCODE_INSERT; - io.KeyMap[ImGuiKey_Delete] = AKEYCODE_FORWARD_DEL; - io.KeyMap[ImGuiKey_Backspace] = AKEYCODE_DEL; - io.KeyMap[ImGuiKey_Space] = AKEYCODE_SPACE; - io.KeyMap[ImGuiKey_Enter] = AKEYCODE_ENTER; - io.KeyMap[ImGuiKey_Escape] = AKEYCODE_ESCAPE; - io.KeyMap[ImGuiKey_KeyPadEnter] = AKEYCODE_NUMPAD_ENTER; - io.KeyMap[ImGuiKey_A] = AKEYCODE_A; - io.KeyMap[ImGuiKey_C] = AKEYCODE_C; - io.KeyMap[ImGuiKey_V] = AKEYCODE_V; - io.KeyMap[ImGuiKey_X] = AKEYCODE_X; - io.KeyMap[ImGuiKey_Y] = AKEYCODE_Y; - io.KeyMap[ImGuiKey_Z] = AKEYCODE_Z; - - return true; -} - -void ImGui_ImplAndroid_Shutdown() -{ -} - -void ImGui_ImplAndroid_NewFrame() -{ - ImGuiIO& io = ImGui::GetIO(); - - // Process queued key events - // FIXME: This is a workaround for multiple key event actions occurring at once (see above) and can be removed once we use upcoming input queue. - for (auto& key_queue : g_KeyEventQueues) - { - if (key_queue.second.empty()) - continue; - io.KeysDown[key_queue.first] = (key_queue.second.front() == AKEY_EVENT_ACTION_DOWN); - key_queue.second.pop(); - } - - // Setup display size (every frame to accommodate for window resizing) - int32_t window_width = ANativeWindow_getWidth(g_Window); - int32_t window_height = ANativeWindow_getHeight(g_Window); - int display_width = window_width; - int display_height = window_height; - - io.DisplaySize = ImVec2((float)window_width, (float)window_height); - if (window_width > 0 && window_height > 0) - io.DisplayFramebufferScale = ImVec2((float)display_width / window_width, (float)display_height / window_height); - - // Setup time step - struct timespec current_timespec; - clock_gettime(CLOCK_MONOTONIC, ¤t_timespec); - double current_time = (double)(current_timespec.tv_sec) + (current_timespec.tv_nsec / 1000000000.0); - io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f / 60.0f); - g_Time = current_time; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_android.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_android.h deleted file mode 100644 index 92b466b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_android.h +++ /dev/null @@ -1,27 +0,0 @@ -// dear imgui: Platform Binding for Android native app -// This needs to be used along with the OpenGL 3 Renderer (imgui_impl_opengl3) - -// Implemented features: -// [X] Platform: Keyboard arrays indexed using AKEYCODE_* codes, e.g. ImGui::IsKeyPressed(AKEYCODE_SPACE). -// Missing features: -// [ ] Platform: Clipboard support. -// [ ] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. -// [ ] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: Check if this is even possible with Android. -// Important: -// - FIXME: On-screen keyboard currently needs to be enabled by the application (see examples/ and issue #3446) -// - FIXME: Unicode character inputs needs to be passed by Dear ImGui by the application (see examples/ and issue #3446) - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -#pragma once - -struct ANativeWindow; -struct AInputEvent; - -IMGUI_IMPL_API bool ImGui_ImplAndroid_Init(ANativeWindow* window); -IMGUI_IMPL_API int32_t ImGui_ImplAndroid_HandleInputEvent(AInputEvent* input_event); -IMGUI_IMPL_API void ImGui_ImplAndroid_Shutdown(); -IMGUI_IMPL_API void ImGui_ImplAndroid_NewFrame(); diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_dx10.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_dx10.cpp deleted file mode 100644 index 5be46f6..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_dx10.cpp +++ /dev/null @@ -1,578 +0,0 @@ -// dear imgui: Renderer Backend for DirectX10 -// This needs to be used along with a Platform Backend (e.g. Win32) - -// Implemented features: -// [X] Renderer: User texture backend. Use 'ID3D10ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID! -// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -// CHANGELOG -// (minor and older changes stripped away, please see git history for details) -// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX). -// 2021-05-19: DirectX10: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement) -// 2021-02-18: DirectX10: Change blending equation to preserve alpha in output buffer. -// 2019-07-21: DirectX10: Backup, clear and restore Geometry Shader is any is bound when calling ImGui_ImplDX10_RenderDrawData(). -// 2019-05-29: DirectX10: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag. -// 2019-04-30: DirectX10: Added support for special ImDrawCallback_ResetRenderState callback to reset render state. -// 2018-12-03: Misc: Added #pragma comment statement to automatically link with d3dcompiler.lib when using D3DCompile(). -// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window. -// 2018-07-13: DirectX10: Fixed unreleased resources in Init and Shutdown functions. -// 2018-06-08: Misc: Extracted imgui_impl_dx10.cpp/.h away from the old combined DX10+Win32 example. -// 2018-06-08: DirectX10: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle. -// 2018-04-09: Misc: Fixed erroneous call to io.Fonts->ClearInputData() + ClearTexData() that was left in DX10 example but removed in 1.47 (Nov 2015) on other backends. -// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplDX10_RenderDrawData() in the .h file so you can call it yourself. -// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves. -// 2016-05-07: DirectX10: Disabling depth-write. - -#include "imgui.h" -#include "imgui_impl_dx10.h" - -// DirectX -#include -#include -#include -#include -#ifdef _MSC_VER -#pragma comment(lib, "d3dcompiler") // Automatically link with d3dcompiler.lib as we are using D3DCompile() below. -#endif - -// DirectX data -struct ImGui_ImplDX10_Data -{ - ID3D10Device* pd3dDevice; - IDXGIFactory* pFactory; - ID3D10Buffer* pVB; - ID3D10Buffer* pIB; - ID3D10VertexShader* pVertexShader; - ID3D10InputLayout* pInputLayout; - ID3D10Buffer* pVertexConstantBuffer; - ID3D10PixelShader* pPixelShader; - ID3D10SamplerState* pFontSampler; - ID3D10ShaderResourceView* pFontTextureView; - ID3D10RasterizerState* pRasterizerState; - ID3D10BlendState* pBlendState; - ID3D10DepthStencilState* pDepthStencilState; - int VertexBufferSize; - int IndexBufferSize; - - ImGui_ImplDX10_Data() { memset(this, 0, sizeof(*this)); VertexBufferSize = 5000; IndexBufferSize = 10000; } -}; - -struct VERTEX_CONSTANT_BUFFER -{ - float mvp[4][4]; -}; - -// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts -// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts. -static ImGui_ImplDX10_Data* ImGui_ImplDX10_GetBackendData() -{ - return ImGui::GetCurrentContext() ? (ImGui_ImplDX10_Data*)ImGui::GetIO().BackendRendererUserData : NULL; -} - -// Functions -static void ImGui_ImplDX10_SetupRenderState(ImDrawData* draw_data, ID3D10Device* ctx) -{ - ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_GetBackendData(); - - // Setup viewport - D3D10_VIEWPORT vp; - memset(&vp, 0, sizeof(D3D10_VIEWPORT)); - vp.Width = (UINT)draw_data->DisplaySize.x; - vp.Height = (UINT)draw_data->DisplaySize.y; - vp.MinDepth = 0.0f; - vp.MaxDepth = 1.0f; - vp.TopLeftX = vp.TopLeftY = 0; - ctx->RSSetViewports(1, &vp); - - // Bind shader and vertex buffers - unsigned int stride = sizeof(ImDrawVert); - unsigned int offset = 0; - ctx->IASetInputLayout(bd->pInputLayout); - ctx->IASetVertexBuffers(0, 1, &bd->pVB, &stride, &offset); - ctx->IASetIndexBuffer(bd->pIB, sizeof(ImDrawIdx) == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT, 0); - ctx->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - ctx->VSSetShader(bd->pVertexShader); - ctx->VSSetConstantBuffers(0, 1, &bd->pVertexConstantBuffer); - ctx->PSSetShader(bd->pPixelShader); - ctx->PSSetSamplers(0, 1, &bd->pFontSampler); - ctx->GSSetShader(NULL); - - // Setup render state - const float blend_factor[4] = { 0.f, 0.f, 0.f, 0.f }; - ctx->OMSetBlendState(bd->pBlendState, blend_factor, 0xffffffff); - ctx->OMSetDepthStencilState(bd->pDepthStencilState, 0); - ctx->RSSetState(bd->pRasterizerState); -} - -// Render function -void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data) -{ - // Avoid rendering when minimized - if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f) - return; - - ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_GetBackendData(); - ID3D10Device* ctx = bd->pd3dDevice; - - // Create and grow vertex/index buffers if needed - if (!bd->pVB || bd->VertexBufferSize < draw_data->TotalVtxCount) - { - if (bd->pVB) { bd->pVB->Release(); bd->pVB = NULL; } - bd->VertexBufferSize = draw_data->TotalVtxCount + 5000; - D3D10_BUFFER_DESC desc; - memset(&desc, 0, sizeof(D3D10_BUFFER_DESC)); - desc.Usage = D3D10_USAGE_DYNAMIC; - desc.ByteWidth = bd->VertexBufferSize * sizeof(ImDrawVert); - desc.BindFlags = D3D10_BIND_VERTEX_BUFFER; - desc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE; - desc.MiscFlags = 0; - if (ctx->CreateBuffer(&desc, NULL, &bd->pVB) < 0) - return; - } - - if (!bd->pIB || bd->IndexBufferSize < draw_data->TotalIdxCount) - { - if (bd->pIB) { bd->pIB->Release(); bd->pIB = NULL; } - bd->IndexBufferSize = draw_data->TotalIdxCount + 10000; - D3D10_BUFFER_DESC desc; - memset(&desc, 0, sizeof(D3D10_BUFFER_DESC)); - desc.Usage = D3D10_USAGE_DYNAMIC; - desc.ByteWidth = bd->IndexBufferSize * sizeof(ImDrawIdx); - desc.BindFlags = D3D10_BIND_INDEX_BUFFER; - desc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE; - if (ctx->CreateBuffer(&desc, NULL, &bd->pIB) < 0) - return; - } - - // Copy and convert all vertices into a single contiguous buffer - ImDrawVert* vtx_dst = NULL; - ImDrawIdx* idx_dst = NULL; - bd->pVB->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&vtx_dst); - bd->pIB->Map(D3D10_MAP_WRITE_DISCARD, 0, (void**)&idx_dst); - for (int n = 0; n < draw_data->CmdListsCount; n++) - { - const ImDrawList* cmd_list = draw_data->CmdLists[n]; - memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert)); - memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx)); - vtx_dst += cmd_list->VtxBuffer.Size; - idx_dst += cmd_list->IdxBuffer.Size; - } - bd->pVB->Unmap(); - bd->pIB->Unmap(); - - // Setup orthographic projection matrix into our constant buffer - // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps. - { - void* mapped_resource; - if (bd->pVertexConstantBuffer->Map(D3D10_MAP_WRITE_DISCARD, 0, &mapped_resource) != S_OK) - return; - VERTEX_CONSTANT_BUFFER* constant_buffer = (VERTEX_CONSTANT_BUFFER*)mapped_resource; - float L = draw_data->DisplayPos.x; - float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x; - float T = draw_data->DisplayPos.y; - float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y; - float mvp[4][4] = - { - { 2.0f/(R-L), 0.0f, 0.0f, 0.0f }, - { 0.0f, 2.0f/(T-B), 0.0f, 0.0f }, - { 0.0f, 0.0f, 0.5f, 0.0f }, - { (R+L)/(L-R), (T+B)/(B-T), 0.5f, 1.0f }, - }; - memcpy(&constant_buffer->mvp, mvp, sizeof(mvp)); - bd->pVertexConstantBuffer->Unmap(); - } - - // Backup DX state that will be modified to restore it afterwards (unfortunately this is very ugly looking and verbose. Close your eyes!) - struct BACKUP_DX10_STATE - { - UINT ScissorRectsCount, ViewportsCount; - D3D10_RECT ScissorRects[D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE]; - D3D10_VIEWPORT Viewports[D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE]; - ID3D10RasterizerState* RS; - ID3D10BlendState* BlendState; - FLOAT BlendFactor[4]; - UINT SampleMask; - UINT StencilRef; - ID3D10DepthStencilState* DepthStencilState; - ID3D10ShaderResourceView* PSShaderResource; - ID3D10SamplerState* PSSampler; - ID3D10PixelShader* PS; - ID3D10VertexShader* VS; - ID3D10GeometryShader* GS; - D3D10_PRIMITIVE_TOPOLOGY PrimitiveTopology; - ID3D10Buffer* IndexBuffer, *VertexBuffer, *VSConstantBuffer; - UINT IndexBufferOffset, VertexBufferStride, VertexBufferOffset; - DXGI_FORMAT IndexBufferFormat; - ID3D10InputLayout* InputLayout; - }; - BACKUP_DX10_STATE old = {}; - old.ScissorRectsCount = old.ViewportsCount = D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE; - ctx->RSGetScissorRects(&old.ScissorRectsCount, old.ScissorRects); - ctx->RSGetViewports(&old.ViewportsCount, old.Viewports); - ctx->RSGetState(&old.RS); - ctx->OMGetBlendState(&old.BlendState, old.BlendFactor, &old.SampleMask); - ctx->OMGetDepthStencilState(&old.DepthStencilState, &old.StencilRef); - ctx->PSGetShaderResources(0, 1, &old.PSShaderResource); - ctx->PSGetSamplers(0, 1, &old.PSSampler); - ctx->PSGetShader(&old.PS); - ctx->VSGetShader(&old.VS); - ctx->VSGetConstantBuffers(0, 1, &old.VSConstantBuffer); - ctx->GSGetShader(&old.GS); - ctx->IAGetPrimitiveTopology(&old.PrimitiveTopology); - ctx->IAGetIndexBuffer(&old.IndexBuffer, &old.IndexBufferFormat, &old.IndexBufferOffset); - ctx->IAGetVertexBuffers(0, 1, &old.VertexBuffer, &old.VertexBufferStride, &old.VertexBufferOffset); - ctx->IAGetInputLayout(&old.InputLayout); - - // Setup desired DX state - ImGui_ImplDX10_SetupRenderState(draw_data, ctx); - - // Render command lists - // (Because we merged all buffers into a single one, we maintain our own offset into them) - int global_vtx_offset = 0; - int global_idx_offset = 0; - ImVec2 clip_off = draw_data->DisplayPos; - for (int n = 0; n < draw_data->CmdListsCount; n++) - { - const ImDrawList* cmd_list = draw_data->CmdLists[n]; - for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) - { - const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; - if (pcmd->UserCallback) - { - // User callback, registered via ImDrawList::AddCallback() - // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.) - if (pcmd->UserCallback == ImDrawCallback_ResetRenderState) - ImGui_ImplDX10_SetupRenderState(draw_data, ctx); - else - pcmd->UserCallback(cmd_list, pcmd); - } - else - { - // Project scissor/clipping rectangles into framebuffer space - ImVec2 clip_min(pcmd->ClipRect.x - clip_off.x, pcmd->ClipRect.y - clip_off.y); - ImVec2 clip_max(pcmd->ClipRect.z - clip_off.x, pcmd->ClipRect.w - clip_off.y); - if (clip_max.x < clip_min.x || clip_max.y < clip_min.y) - continue; - - // Apply scissor/clipping rectangle - const D3D10_RECT r = { (LONG)clip_min.x, (LONG)clip_min.y, (LONG)clip_max.x, (LONG)clip_max.y }; - ctx->RSSetScissorRects(1, &r); - - // Bind texture, Draw - ID3D10ShaderResourceView* texture_srv = (ID3D10ShaderResourceView*)pcmd->GetTexID(); - ctx->PSSetShaderResources(0, 1, &texture_srv); - ctx->DrawIndexed(pcmd->ElemCount, pcmd->IdxOffset + global_idx_offset, pcmd->VtxOffset + global_vtx_offset); - } - } - global_idx_offset += cmd_list->IdxBuffer.Size; - global_vtx_offset += cmd_list->VtxBuffer.Size; - } - - // Restore modified DX state - ctx->RSSetScissorRects(old.ScissorRectsCount, old.ScissorRects); - ctx->RSSetViewports(old.ViewportsCount, old.Viewports); - ctx->RSSetState(old.RS); if (old.RS) old.RS->Release(); - ctx->OMSetBlendState(old.BlendState, old.BlendFactor, old.SampleMask); if (old.BlendState) old.BlendState->Release(); - ctx->OMSetDepthStencilState(old.DepthStencilState, old.StencilRef); if (old.DepthStencilState) old.DepthStencilState->Release(); - ctx->PSSetShaderResources(0, 1, &old.PSShaderResource); if (old.PSShaderResource) old.PSShaderResource->Release(); - ctx->PSSetSamplers(0, 1, &old.PSSampler); if (old.PSSampler) old.PSSampler->Release(); - ctx->PSSetShader(old.PS); if (old.PS) old.PS->Release(); - ctx->VSSetShader(old.VS); if (old.VS) old.VS->Release(); - ctx->GSSetShader(old.GS); if (old.GS) old.GS->Release(); - ctx->VSSetConstantBuffers(0, 1, &old.VSConstantBuffer); if (old.VSConstantBuffer) old.VSConstantBuffer->Release(); - ctx->IASetPrimitiveTopology(old.PrimitiveTopology); - ctx->IASetIndexBuffer(old.IndexBuffer, old.IndexBufferFormat, old.IndexBufferOffset); if (old.IndexBuffer) old.IndexBuffer->Release(); - ctx->IASetVertexBuffers(0, 1, &old.VertexBuffer, &old.VertexBufferStride, &old.VertexBufferOffset); if (old.VertexBuffer) old.VertexBuffer->Release(); - ctx->IASetInputLayout(old.InputLayout); if (old.InputLayout) old.InputLayout->Release(); -} - -static void ImGui_ImplDX10_CreateFontsTexture() -{ - // Build texture atlas - ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_GetBackendData(); - ImGuiIO& io = ImGui::GetIO(); - unsigned char* pixels; - int width, height; - io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); - - // Upload texture to graphics system - { - D3D10_TEXTURE2D_DESC desc; - ZeroMemory(&desc, sizeof(desc)); - desc.Width = width; - desc.Height = height; - desc.MipLevels = 1; - desc.ArraySize = 1; - desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; - desc.SampleDesc.Count = 1; - desc.Usage = D3D10_USAGE_DEFAULT; - desc.BindFlags = D3D10_BIND_SHADER_RESOURCE; - desc.CPUAccessFlags = 0; - - ID3D10Texture2D* pTexture = NULL; - D3D10_SUBRESOURCE_DATA subResource; - subResource.pSysMem = pixels; - subResource.SysMemPitch = desc.Width * 4; - subResource.SysMemSlicePitch = 0; - bd->pd3dDevice->CreateTexture2D(&desc, &subResource, &pTexture); - IM_ASSERT(pTexture != NULL); - - // Create texture view - D3D10_SHADER_RESOURCE_VIEW_DESC srv_desc; - ZeroMemory(&srv_desc, sizeof(srv_desc)); - srv_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; - srv_desc.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2D; - srv_desc.Texture2D.MipLevels = desc.MipLevels; - srv_desc.Texture2D.MostDetailedMip = 0; - bd->pd3dDevice->CreateShaderResourceView(pTexture, &srv_desc, &bd->pFontTextureView); - pTexture->Release(); - } - - // Store our identifier - io.Fonts->SetTexID((ImTextureID)bd->pFontTextureView); - - // Create texture sampler - { - D3D10_SAMPLER_DESC desc; - ZeroMemory(&desc, sizeof(desc)); - desc.Filter = D3D10_FILTER_MIN_MAG_MIP_LINEAR; - desc.AddressU = D3D10_TEXTURE_ADDRESS_WRAP; - desc.AddressV = D3D10_TEXTURE_ADDRESS_WRAP; - desc.AddressW = D3D10_TEXTURE_ADDRESS_WRAP; - desc.MipLODBias = 0.f; - desc.ComparisonFunc = D3D10_COMPARISON_ALWAYS; - desc.MinLOD = 0.f; - desc.MaxLOD = 0.f; - bd->pd3dDevice->CreateSamplerState(&desc, &bd->pFontSampler); - } -} - -bool ImGui_ImplDX10_CreateDeviceObjects() -{ - ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_GetBackendData(); - if (!bd->pd3dDevice) - return false; - if (bd->pFontSampler) - ImGui_ImplDX10_InvalidateDeviceObjects(); - - // By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A) - // If you would like to use this DX10 sample code but remove this dependency you can: - // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution] - // 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL. - // See https://github.com/ocornut/imgui/pull/638 for sources and details. - - // Create the vertex shader - { - static const char* vertexShader = - "cbuffer vertexBuffer : register(b0) \ - {\ - float4x4 ProjectionMatrix; \ - };\ - struct VS_INPUT\ - {\ - float2 pos : POSITION;\ - float4 col : COLOR0;\ - float2 uv : TEXCOORD0;\ - };\ - \ - struct PS_INPUT\ - {\ - float4 pos : SV_POSITION;\ - float4 col : COLOR0;\ - float2 uv : TEXCOORD0;\ - };\ - \ - PS_INPUT main(VS_INPUT input)\ - {\ - PS_INPUT output;\ - output.pos = mul( ProjectionMatrix, float4(input.pos.xy, 0.f, 1.f));\ - output.col = input.col;\ - output.uv = input.uv;\ - return output;\ - }"; - - ID3DBlob* vertexShaderBlob; - if (FAILED(D3DCompile(vertexShader, strlen(vertexShader), NULL, NULL, NULL, "main", "vs_4_0", 0, 0, &vertexShaderBlob, NULL))) - return false; // NB: Pass ID3DBlob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob! - if (bd->pd3dDevice->CreateVertexShader(vertexShaderBlob->GetBufferPointer(), vertexShaderBlob->GetBufferSize(), &bd->pVertexShader) != S_OK) - { - vertexShaderBlob->Release(); - return false; - } - - // Create the input layout - D3D10_INPUT_ELEMENT_DESC local_layout[] = - { - { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, pos), D3D10_INPUT_PER_VERTEX_DATA, 0 }, - { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, uv), D3D10_INPUT_PER_VERTEX_DATA, 0 }, - { "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (UINT)IM_OFFSETOF(ImDrawVert, col), D3D10_INPUT_PER_VERTEX_DATA, 0 }, - }; - if (bd->pd3dDevice->CreateInputLayout(local_layout, 3, vertexShaderBlob->GetBufferPointer(), vertexShaderBlob->GetBufferSize(), &bd->pInputLayout) != S_OK) - { - vertexShaderBlob->Release(); - return false; - } - vertexShaderBlob->Release(); - - // Create the constant buffer - { - D3D10_BUFFER_DESC desc; - desc.ByteWidth = sizeof(VERTEX_CONSTANT_BUFFER); - desc.Usage = D3D10_USAGE_DYNAMIC; - desc.BindFlags = D3D10_BIND_CONSTANT_BUFFER; - desc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE; - desc.MiscFlags = 0; - bd->pd3dDevice->CreateBuffer(&desc, NULL, &bd->pVertexConstantBuffer); - } - } - - // Create the pixel shader - { - static const char* pixelShader = - "struct PS_INPUT\ - {\ - float4 pos : SV_POSITION;\ - float4 col : COLOR0;\ - float2 uv : TEXCOORD0;\ - };\ - sampler sampler0;\ - Texture2D texture0;\ - \ - float4 main(PS_INPUT input) : SV_Target\ - {\ - float4 out_col = input.col * texture0.Sample(sampler0, input.uv); \ - return out_col; \ - }"; - - ID3DBlob* pixelShaderBlob; - if (FAILED(D3DCompile(pixelShader, strlen(pixelShader), NULL, NULL, NULL, "main", "ps_4_0", 0, 0, &pixelShaderBlob, NULL))) - return false; // NB: Pass ID3DBlob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob! - if (bd->pd3dDevice->CreatePixelShader(pixelShaderBlob->GetBufferPointer(), pixelShaderBlob->GetBufferSize(), &bd->pPixelShader) != S_OK) - { - pixelShaderBlob->Release(); - return false; - } - pixelShaderBlob->Release(); - } - - // Create the blending setup - { - D3D10_BLEND_DESC desc; - ZeroMemory(&desc, sizeof(desc)); - desc.AlphaToCoverageEnable = false; - desc.BlendEnable[0] = true; - desc.SrcBlend = D3D10_BLEND_SRC_ALPHA; - desc.DestBlend = D3D10_BLEND_INV_SRC_ALPHA; - desc.BlendOp = D3D10_BLEND_OP_ADD; - desc.SrcBlendAlpha = D3D10_BLEND_ONE; - desc.DestBlendAlpha = D3D10_BLEND_INV_SRC_ALPHA; - desc.BlendOpAlpha = D3D10_BLEND_OP_ADD; - desc.RenderTargetWriteMask[0] = D3D10_COLOR_WRITE_ENABLE_ALL; - bd->pd3dDevice->CreateBlendState(&desc, &bd->pBlendState); - } - - // Create the rasterizer state - { - D3D10_RASTERIZER_DESC desc; - ZeroMemory(&desc, sizeof(desc)); - desc.FillMode = D3D10_FILL_SOLID; - desc.CullMode = D3D10_CULL_NONE; - desc.ScissorEnable = true; - desc.DepthClipEnable = true; - bd->pd3dDevice->CreateRasterizerState(&desc, &bd->pRasterizerState); - } - - // Create depth-stencil State - { - D3D10_DEPTH_STENCIL_DESC desc; - ZeroMemory(&desc, sizeof(desc)); - desc.DepthEnable = false; - desc.DepthWriteMask = D3D10_DEPTH_WRITE_MASK_ALL; - desc.DepthFunc = D3D10_COMPARISON_ALWAYS; - desc.StencilEnable = false; - desc.FrontFace.StencilFailOp = desc.FrontFace.StencilDepthFailOp = desc.FrontFace.StencilPassOp = D3D10_STENCIL_OP_KEEP; - desc.FrontFace.StencilFunc = D3D10_COMPARISON_ALWAYS; - desc.BackFace = desc.FrontFace; - bd->pd3dDevice->CreateDepthStencilState(&desc, &bd->pDepthStencilState); - } - - ImGui_ImplDX10_CreateFontsTexture(); - - return true; -} - -void ImGui_ImplDX10_InvalidateDeviceObjects() -{ - ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_GetBackendData(); - if (!bd->pd3dDevice) - return; - - if (bd->pFontSampler) { bd->pFontSampler->Release(); bd->pFontSampler = NULL; } - if (bd->pFontTextureView) { bd->pFontTextureView->Release(); bd->pFontTextureView = NULL; ImGui::GetIO().Fonts->SetTexID(NULL); } // We copied bd->pFontTextureView to io.Fonts->TexID so let's clear that as well. - if (bd->pIB) { bd->pIB->Release(); bd->pIB = NULL; } - if (bd->pVB) { bd->pVB->Release(); bd->pVB = NULL; } - if (bd->pBlendState) { bd->pBlendState->Release(); bd->pBlendState = NULL; } - if (bd->pDepthStencilState) { bd->pDepthStencilState->Release(); bd->pDepthStencilState = NULL; } - if (bd->pRasterizerState) { bd->pRasterizerState->Release(); bd->pRasterizerState = NULL; } - if (bd->pPixelShader) { bd->pPixelShader->Release(); bd->pPixelShader = NULL; } - if (bd->pVertexConstantBuffer) { bd->pVertexConstantBuffer->Release(); bd->pVertexConstantBuffer = NULL; } - if (bd->pInputLayout) { bd->pInputLayout->Release(); bd->pInputLayout = NULL; } - if (bd->pVertexShader) { bd->pVertexShader->Release(); bd->pVertexShader = NULL; } -} - -bool ImGui_ImplDX10_Init(ID3D10Device* device) -{ - ImGuiIO& io = ImGui::GetIO(); - IM_ASSERT(io.BackendRendererUserData == NULL && "Already initialized a renderer backend!"); - - // Setup backend capabilities flags - ImGui_ImplDX10_Data* bd = IM_NEW(ImGui_ImplDX10_Data)(); - io.BackendRendererUserData = (void*)bd; - io.BackendRendererName = "imgui_impl_dx10"; - io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. - - // Get factory from device - IDXGIDevice* pDXGIDevice = NULL; - IDXGIAdapter* pDXGIAdapter = NULL; - IDXGIFactory* pFactory = NULL; - if (device->QueryInterface(IID_PPV_ARGS(&pDXGIDevice)) == S_OK) - if (pDXGIDevice->GetParent(IID_PPV_ARGS(&pDXGIAdapter)) == S_OK) - if (pDXGIAdapter->GetParent(IID_PPV_ARGS(&pFactory)) == S_OK) - { - bd->pd3dDevice = device; - bd->pFactory = pFactory; - } - if (pDXGIDevice) pDXGIDevice->Release(); - if (pDXGIAdapter) pDXGIAdapter->Release(); - bd->pd3dDevice->AddRef(); - - return true; -} - -void ImGui_ImplDX10_Shutdown() -{ - ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_GetBackendData(); - IM_ASSERT(bd != NULL && "No renderer backend to shutdown, or already shutdown?"); - ImGuiIO& io = ImGui::GetIO(); - - ImGui_ImplDX10_InvalidateDeviceObjects(); - if (bd->pFactory) { bd->pFactory->Release(); } - if (bd->pd3dDevice) { bd->pd3dDevice->Release(); } - io.BackendRendererName = NULL; - io.BackendRendererUserData = NULL; - IM_DELETE(bd); -} - -void ImGui_ImplDX10_NewFrame() -{ - ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_GetBackendData(); - IM_ASSERT(bd != NULL && "Did you call ImGui_ImplDX10_Init()?"); - - if (!bd->pFontSampler) - ImGui_ImplDX10_CreateDeviceObjects(); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_dx10.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_dx10.h deleted file mode 100644 index 31e62ac..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_dx10.h +++ /dev/null @@ -1,25 +0,0 @@ -// dear imgui: Renderer Backend for DirectX10 -// This needs to be used along with a Platform Backend (e.g. Win32) - -// Implemented features: -// [X] Renderer: User texture backend. Use 'ID3D10ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID! -// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -#pragma once -#include "imgui.h" // IMGUI_IMPL_API - -struct ID3D10Device; - -IMGUI_IMPL_API bool ImGui_ImplDX10_Init(ID3D10Device* device); -IMGUI_IMPL_API void ImGui_ImplDX10_Shutdown(); -IMGUI_IMPL_API void ImGui_ImplDX10_NewFrame(); -IMGUI_IMPL_API void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data); - -// Use if you want to reset your rendering device without losing Dear ImGui state. -IMGUI_IMPL_API void ImGui_ImplDX10_InvalidateDeviceObjects(); -IMGUI_IMPL_API bool ImGui_ImplDX10_CreateDeviceObjects(); diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_dx11.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_dx11.cpp deleted file mode 100644 index bfe5dca..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_dx11.cpp +++ /dev/null @@ -1,594 +0,0 @@ -// dear imgui: Renderer Backend for DirectX11 -// This needs to be used along with a Platform Backend (e.g. Win32) - -// Implemented features: -// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID! -// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -// CHANGELOG -// (minor and older changes stripped away, please see git history for details) -// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX). -// 2021-05-19: DirectX11: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement) -// 2021-02-18: DirectX11: Change blending equation to preserve alpha in output buffer. -// 2019-08-01: DirectX11: Fixed code querying the Geometry Shader state (would generally error with Debug layer enabled). -// 2019-07-21: DirectX11: Backup, clear and restore Geometry Shader is any is bound when calling ImGui_ImplDX10_RenderDrawData. Clearing Hull/Domain/Compute shaders without backup/restore. -// 2019-05-29: DirectX11: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag. -// 2019-04-30: DirectX11: Added support for special ImDrawCallback_ResetRenderState callback to reset render state. -// 2018-12-03: Misc: Added #pragma comment statement to automatically link with d3dcompiler.lib when using D3DCompile(). -// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window. -// 2018-08-01: DirectX11: Querying for IDXGIFactory instead of IDXGIFactory1 to increase compatibility. -// 2018-07-13: DirectX11: Fixed unreleased resources in Init and Shutdown functions. -// 2018-06-08: Misc: Extracted imgui_impl_dx11.cpp/.h away from the old combined DX11+Win32 example. -// 2018-06-08: DirectX11: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle. -// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplDX11_RenderDrawData() in the .h file so you can call it yourself. -// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves. -// 2016-05-07: DirectX11: Disabling depth-write. - -#include "imgui.h" -#include "imgui_impl_dx11.h" - -// DirectX -#include -#include -#include -#ifdef _MSC_VER -#pragma comment(lib, "d3dcompiler") // Automatically link with d3dcompiler.lib as we are using D3DCompile() below. -#endif - -// DirectX11 data -struct ImGui_ImplDX11_Data -{ - ID3D11Device* pd3dDevice; - ID3D11DeviceContext* pd3dDeviceContext; - IDXGIFactory* pFactory; - ID3D11Buffer* pVB; - ID3D11Buffer* pIB; - ID3D11VertexShader* pVertexShader; - ID3D11InputLayout* pInputLayout; - ID3D11Buffer* pVertexConstantBuffer; - ID3D11PixelShader* pPixelShader; - ID3D11SamplerState* pFontSampler; - ID3D11ShaderResourceView* pFontTextureView; - ID3D11RasterizerState* pRasterizerState; - ID3D11BlendState* pBlendState; - ID3D11DepthStencilState* pDepthStencilState; - int VertexBufferSize; - int IndexBufferSize; - - ImGui_ImplDX11_Data() { memset(this, 0, sizeof(*this)); VertexBufferSize = 5000; IndexBufferSize = 10000; } -}; - -struct VERTEX_CONSTANT_BUFFER -{ - float mvp[4][4]; -}; - -// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts -// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts. -static ImGui_ImplDX11_Data* ImGui_ImplDX11_GetBackendData() -{ - return ImGui::GetCurrentContext() ? (ImGui_ImplDX11_Data*)ImGui::GetIO().BackendRendererUserData : NULL; -} - -// Functions -static void ImGui_ImplDX11_SetupRenderState(ImDrawData* draw_data, ID3D11DeviceContext* ctx) -{ - ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData(); - - // Setup viewport - D3D11_VIEWPORT vp; - memset(&vp, 0, sizeof(D3D11_VIEWPORT)); - vp.Width = draw_data->DisplaySize.x; - vp.Height = draw_data->DisplaySize.y; - vp.MinDepth = 0.0f; - vp.MaxDepth = 1.0f; - vp.TopLeftX = vp.TopLeftY = 0; - ctx->RSSetViewports(1, &vp); - - // Setup shader and vertex buffers - unsigned int stride = sizeof(ImDrawVert); - unsigned int offset = 0; - ctx->IASetInputLayout(bd->pInputLayout); - ctx->IASetVertexBuffers(0, 1, &bd->pVB, &stride, &offset); - ctx->IASetIndexBuffer(bd->pIB, sizeof(ImDrawIdx) == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT, 0); - ctx->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - ctx->VSSetShader(bd->pVertexShader, NULL, 0); - ctx->VSSetConstantBuffers(0, 1, &bd->pVertexConstantBuffer); - ctx->PSSetShader(bd->pPixelShader, NULL, 0); - ctx->PSSetSamplers(0, 1, &bd->pFontSampler); - ctx->GSSetShader(NULL, NULL, 0); - ctx->HSSetShader(NULL, NULL, 0); // In theory we should backup and restore this as well.. very infrequently used.. - ctx->DSSetShader(NULL, NULL, 0); // In theory we should backup and restore this as well.. very infrequently used.. - ctx->CSSetShader(NULL, NULL, 0); // In theory we should backup and restore this as well.. very infrequently used.. - - // Setup blend state - const float blend_factor[4] = { 0.f, 0.f, 0.f, 0.f }; - ctx->OMSetBlendState(bd->pBlendState, blend_factor, 0xffffffff); - ctx->OMSetDepthStencilState(bd->pDepthStencilState, 0); - ctx->RSSetState(bd->pRasterizerState); -} - -// Render function -void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data) -{ - // Avoid rendering when minimized - if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f) - return; - - ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData(); - ID3D11DeviceContext* ctx = bd->pd3dDeviceContext; - - // Create and grow vertex/index buffers if needed - if (!bd->pVB || bd->VertexBufferSize < draw_data->TotalVtxCount) - { - if (bd->pVB) { bd->pVB->Release(); bd->pVB = NULL; } - bd->VertexBufferSize = draw_data->TotalVtxCount + 5000; - D3D11_BUFFER_DESC desc; - memset(&desc, 0, sizeof(D3D11_BUFFER_DESC)); - desc.Usage = D3D11_USAGE_DYNAMIC; - desc.ByteWidth = bd->VertexBufferSize * sizeof(ImDrawVert); - desc.BindFlags = D3D11_BIND_VERTEX_BUFFER; - desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - desc.MiscFlags = 0; - if (bd->pd3dDevice->CreateBuffer(&desc, NULL, &bd->pVB) < 0) - return; - } - if (!bd->pIB || bd->IndexBufferSize < draw_data->TotalIdxCount) - { - if (bd->pIB) { bd->pIB->Release(); bd->pIB = NULL; } - bd->IndexBufferSize = draw_data->TotalIdxCount + 10000; - D3D11_BUFFER_DESC desc; - memset(&desc, 0, sizeof(D3D11_BUFFER_DESC)); - desc.Usage = D3D11_USAGE_DYNAMIC; - desc.ByteWidth = bd->IndexBufferSize * sizeof(ImDrawIdx); - desc.BindFlags = D3D11_BIND_INDEX_BUFFER; - desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - if (bd->pd3dDevice->CreateBuffer(&desc, NULL, &bd->pIB) < 0) - return; - } - - // Upload vertex/index data into a single contiguous GPU buffer - D3D11_MAPPED_SUBRESOURCE vtx_resource, idx_resource; - if (ctx->Map(bd->pVB, 0, D3D11_MAP_WRITE_DISCARD, 0, &vtx_resource) != S_OK) - return; - if (ctx->Map(bd->pIB, 0, D3D11_MAP_WRITE_DISCARD, 0, &idx_resource) != S_OK) - return; - ImDrawVert* vtx_dst = (ImDrawVert*)vtx_resource.pData; - ImDrawIdx* idx_dst = (ImDrawIdx*)idx_resource.pData; - for (int n = 0; n < draw_data->CmdListsCount; n++) - { - const ImDrawList* cmd_list = draw_data->CmdLists[n]; - memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert)); - memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx)); - vtx_dst += cmd_list->VtxBuffer.Size; - idx_dst += cmd_list->IdxBuffer.Size; - } - ctx->Unmap(bd->pVB, 0); - ctx->Unmap(bd->pIB, 0); - - // Setup orthographic projection matrix into our constant buffer - // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps. - { - D3D11_MAPPED_SUBRESOURCE mapped_resource; - if (ctx->Map(bd->pVertexConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_resource) != S_OK) - return; - VERTEX_CONSTANT_BUFFER* constant_buffer = (VERTEX_CONSTANT_BUFFER*)mapped_resource.pData; - float L = draw_data->DisplayPos.x; - float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x; - float T = draw_data->DisplayPos.y; - float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y; - float mvp[4][4] = - { - { 2.0f/(R-L), 0.0f, 0.0f, 0.0f }, - { 0.0f, 2.0f/(T-B), 0.0f, 0.0f }, - { 0.0f, 0.0f, 0.5f, 0.0f }, - { (R+L)/(L-R), (T+B)/(B-T), 0.5f, 1.0f }, - }; - memcpy(&constant_buffer->mvp, mvp, sizeof(mvp)); - ctx->Unmap(bd->pVertexConstantBuffer, 0); - } - - // Backup DX state that will be modified to restore it afterwards (unfortunately this is very ugly looking and verbose. Close your eyes!) - struct BACKUP_DX11_STATE - { - UINT ScissorRectsCount, ViewportsCount; - D3D11_RECT ScissorRects[D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE]; - D3D11_VIEWPORT Viewports[D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE]; - ID3D11RasterizerState* RS; - ID3D11BlendState* BlendState; - FLOAT BlendFactor[4]; - UINT SampleMask; - UINT StencilRef; - ID3D11DepthStencilState* DepthStencilState; - ID3D11ShaderResourceView* PSShaderResource; - ID3D11SamplerState* PSSampler; - ID3D11PixelShader* PS; - ID3D11VertexShader* VS; - ID3D11GeometryShader* GS; - UINT PSInstancesCount, VSInstancesCount, GSInstancesCount; - ID3D11ClassInstance *PSInstances[256], *VSInstances[256], *GSInstances[256]; // 256 is max according to PSSetShader documentation - D3D11_PRIMITIVE_TOPOLOGY PrimitiveTopology; - ID3D11Buffer* IndexBuffer, *VertexBuffer, *VSConstantBuffer; - UINT IndexBufferOffset, VertexBufferStride, VertexBufferOffset; - DXGI_FORMAT IndexBufferFormat; - ID3D11InputLayout* InputLayout; - }; - BACKUP_DX11_STATE old = {}; - old.ScissorRectsCount = old.ViewportsCount = D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE; - ctx->RSGetScissorRects(&old.ScissorRectsCount, old.ScissorRects); - ctx->RSGetViewports(&old.ViewportsCount, old.Viewports); - ctx->RSGetState(&old.RS); - ctx->OMGetBlendState(&old.BlendState, old.BlendFactor, &old.SampleMask); - ctx->OMGetDepthStencilState(&old.DepthStencilState, &old.StencilRef); - ctx->PSGetShaderResources(0, 1, &old.PSShaderResource); - ctx->PSGetSamplers(0, 1, &old.PSSampler); - old.PSInstancesCount = old.VSInstancesCount = old.GSInstancesCount = 256; - ctx->PSGetShader(&old.PS, old.PSInstances, &old.PSInstancesCount); - ctx->VSGetShader(&old.VS, old.VSInstances, &old.VSInstancesCount); - ctx->VSGetConstantBuffers(0, 1, &old.VSConstantBuffer); - ctx->GSGetShader(&old.GS, old.GSInstances, &old.GSInstancesCount); - - ctx->IAGetPrimitiveTopology(&old.PrimitiveTopology); - ctx->IAGetIndexBuffer(&old.IndexBuffer, &old.IndexBufferFormat, &old.IndexBufferOffset); - ctx->IAGetVertexBuffers(0, 1, &old.VertexBuffer, &old.VertexBufferStride, &old.VertexBufferOffset); - ctx->IAGetInputLayout(&old.InputLayout); - - // Setup desired DX state - ImGui_ImplDX11_SetupRenderState(draw_data, ctx); - - // Render command lists - // (Because we merged all buffers into a single one, we maintain our own offset into them) - int global_idx_offset = 0; - int global_vtx_offset = 0; - ImVec2 clip_off = draw_data->DisplayPos; - for (int n = 0; n < draw_data->CmdListsCount; n++) - { - const ImDrawList* cmd_list = draw_data->CmdLists[n]; - for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) - { - const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; - if (pcmd->UserCallback != NULL) - { - // User callback, registered via ImDrawList::AddCallback() - // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.) - if (pcmd->UserCallback == ImDrawCallback_ResetRenderState) - ImGui_ImplDX11_SetupRenderState(draw_data, ctx); - else - pcmd->UserCallback(cmd_list, pcmd); - } - else - { - // Project scissor/clipping rectangles into framebuffer space - ImVec2 clip_min(pcmd->ClipRect.x - clip_off.x, pcmd->ClipRect.y - clip_off.y); - ImVec2 clip_max(pcmd->ClipRect.z - clip_off.x, pcmd->ClipRect.w - clip_off.y); - if (clip_max.x < clip_min.x || clip_max.y < clip_min.y) - continue; - - // Apply scissor/clipping rectangle - const D3D11_RECT r = { (LONG)clip_min.x, (LONG)clip_min.y, (LONG)clip_max.x, (LONG)clip_max.y }; - ctx->RSSetScissorRects(1, &r); - - // Bind texture, Draw - ID3D11ShaderResourceView* texture_srv = (ID3D11ShaderResourceView*)pcmd->GetTexID(); - ctx->PSSetShaderResources(0, 1, &texture_srv); - ctx->DrawIndexed(pcmd->ElemCount, pcmd->IdxOffset + global_idx_offset, pcmd->VtxOffset + global_vtx_offset); - } - } - global_idx_offset += cmd_list->IdxBuffer.Size; - global_vtx_offset += cmd_list->VtxBuffer.Size; - } - - // Restore modified DX state - ctx->RSSetScissorRects(old.ScissorRectsCount, old.ScissorRects); - ctx->RSSetViewports(old.ViewportsCount, old.Viewports); - ctx->RSSetState(old.RS); if (old.RS) old.RS->Release(); - ctx->OMSetBlendState(old.BlendState, old.BlendFactor, old.SampleMask); if (old.BlendState) old.BlendState->Release(); - ctx->OMSetDepthStencilState(old.DepthStencilState, old.StencilRef); if (old.DepthStencilState) old.DepthStencilState->Release(); - ctx->PSSetShaderResources(0, 1, &old.PSShaderResource); if (old.PSShaderResource) old.PSShaderResource->Release(); - ctx->PSSetSamplers(0, 1, &old.PSSampler); if (old.PSSampler) old.PSSampler->Release(); - ctx->PSSetShader(old.PS, old.PSInstances, old.PSInstancesCount); if (old.PS) old.PS->Release(); - for (UINT i = 0; i < old.PSInstancesCount; i++) if (old.PSInstances[i]) old.PSInstances[i]->Release(); - ctx->VSSetShader(old.VS, old.VSInstances, old.VSInstancesCount); if (old.VS) old.VS->Release(); - ctx->VSSetConstantBuffers(0, 1, &old.VSConstantBuffer); if (old.VSConstantBuffer) old.VSConstantBuffer->Release(); - ctx->GSSetShader(old.GS, old.GSInstances, old.GSInstancesCount); if (old.GS) old.GS->Release(); - for (UINT i = 0; i < old.VSInstancesCount; i++) if (old.VSInstances[i]) old.VSInstances[i]->Release(); - ctx->IASetPrimitiveTopology(old.PrimitiveTopology); - ctx->IASetIndexBuffer(old.IndexBuffer, old.IndexBufferFormat, old.IndexBufferOffset); if (old.IndexBuffer) old.IndexBuffer->Release(); - ctx->IASetVertexBuffers(0, 1, &old.VertexBuffer, &old.VertexBufferStride, &old.VertexBufferOffset); if (old.VertexBuffer) old.VertexBuffer->Release(); - ctx->IASetInputLayout(old.InputLayout); if (old.InputLayout) old.InputLayout->Release(); -} - -static void ImGui_ImplDX11_CreateFontsTexture() -{ - // Build texture atlas - ImGuiIO& io = ImGui::GetIO(); - ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData(); - unsigned char* pixels; - int width, height; - io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); - - // Upload texture to graphics system - { - D3D11_TEXTURE2D_DESC desc; - ZeroMemory(&desc, sizeof(desc)); - desc.Width = width; - desc.Height = height; - desc.MipLevels = 1; - desc.ArraySize = 1; - desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; - desc.SampleDesc.Count = 1; - desc.Usage = D3D11_USAGE_DEFAULT; - desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; - desc.CPUAccessFlags = 0; - - ID3D11Texture2D* pTexture = NULL; - D3D11_SUBRESOURCE_DATA subResource; - subResource.pSysMem = pixels; - subResource.SysMemPitch = desc.Width * 4; - subResource.SysMemSlicePitch = 0; - bd->pd3dDevice->CreateTexture2D(&desc, &subResource, &pTexture); - IM_ASSERT(pTexture != NULL); - - // Create texture view - D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc; - ZeroMemory(&srvDesc, sizeof(srvDesc)); - srvDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; - srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; - srvDesc.Texture2D.MipLevels = desc.MipLevels; - srvDesc.Texture2D.MostDetailedMip = 0; - bd->pd3dDevice->CreateShaderResourceView(pTexture, &srvDesc, &bd->pFontTextureView); - pTexture->Release(); - } - - // Store our identifier - io.Fonts->SetTexID((ImTextureID)bd->pFontTextureView); - - // Create texture sampler - { - D3D11_SAMPLER_DESC desc; - ZeroMemory(&desc, sizeof(desc)); - desc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; - desc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP; - desc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP; - desc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP; - desc.MipLODBias = 0.f; - desc.ComparisonFunc = D3D11_COMPARISON_ALWAYS; - desc.MinLOD = 0.f; - desc.MaxLOD = 0.f; - bd->pd3dDevice->CreateSamplerState(&desc, &bd->pFontSampler); - } -} - -bool ImGui_ImplDX11_CreateDeviceObjects() -{ - ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData(); - if (!bd->pd3dDevice) - return false; - if (bd->pFontSampler) - ImGui_ImplDX11_InvalidateDeviceObjects(); - - // By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A) - // If you would like to use this DX11 sample code but remove this dependency you can: - // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution] - // 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL. - // See https://github.com/ocornut/imgui/pull/638 for sources and details. - - // Create the vertex shader - { - static const char* vertexShader = - "cbuffer vertexBuffer : register(b0) \ - {\ - float4x4 ProjectionMatrix; \ - };\ - struct VS_INPUT\ - {\ - float2 pos : POSITION;\ - float4 col : COLOR0;\ - float2 uv : TEXCOORD0;\ - };\ - \ - struct PS_INPUT\ - {\ - float4 pos : SV_POSITION;\ - float4 col : COLOR0;\ - float2 uv : TEXCOORD0;\ - };\ - \ - PS_INPUT main(VS_INPUT input)\ - {\ - PS_INPUT output;\ - output.pos = mul( ProjectionMatrix, float4(input.pos.xy, 0.f, 1.f));\ - output.col = input.col;\ - output.uv = input.uv;\ - return output;\ - }"; - - ID3DBlob* vertexShaderBlob; - if (FAILED(D3DCompile(vertexShader, strlen(vertexShader), NULL, NULL, NULL, "main", "vs_4_0", 0, 0, &vertexShaderBlob, NULL))) - return false; // NB: Pass ID3DBlob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob! - if (bd->pd3dDevice->CreateVertexShader(vertexShaderBlob->GetBufferPointer(), vertexShaderBlob->GetBufferSize(), NULL, &bd->pVertexShader) != S_OK) - { - vertexShaderBlob->Release(); - return false; - } - - // Create the input layout - D3D11_INPUT_ELEMENT_DESC local_layout[] = - { - { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, pos), D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, uv), D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (UINT)IM_OFFSETOF(ImDrawVert, col), D3D11_INPUT_PER_VERTEX_DATA, 0 }, - }; - if (bd->pd3dDevice->CreateInputLayout(local_layout, 3, vertexShaderBlob->GetBufferPointer(), vertexShaderBlob->GetBufferSize(), &bd->pInputLayout) != S_OK) - { - vertexShaderBlob->Release(); - return false; - } - vertexShaderBlob->Release(); - - // Create the constant buffer - { - D3D11_BUFFER_DESC desc; - desc.ByteWidth = sizeof(VERTEX_CONSTANT_BUFFER); - desc.Usage = D3D11_USAGE_DYNAMIC; - desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; - desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - desc.MiscFlags = 0; - bd->pd3dDevice->CreateBuffer(&desc, NULL, &bd->pVertexConstantBuffer); - } - } - - // Create the pixel shader - { - static const char* pixelShader = - "struct PS_INPUT\ - {\ - float4 pos : SV_POSITION;\ - float4 col : COLOR0;\ - float2 uv : TEXCOORD0;\ - };\ - sampler sampler0;\ - Texture2D texture0;\ - \ - float4 main(PS_INPUT input) : SV_Target\ - {\ - float4 out_col = input.col * texture0.Sample(sampler0, input.uv); \ - return out_col; \ - }"; - - ID3DBlob* pixelShaderBlob; - if (FAILED(D3DCompile(pixelShader, strlen(pixelShader), NULL, NULL, NULL, "main", "ps_4_0", 0, 0, &pixelShaderBlob, NULL))) - return false; // NB: Pass ID3DBlob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob! - if (bd->pd3dDevice->CreatePixelShader(pixelShaderBlob->GetBufferPointer(), pixelShaderBlob->GetBufferSize(), NULL, &bd->pPixelShader) != S_OK) - { - pixelShaderBlob->Release(); - return false; - } - pixelShaderBlob->Release(); - } - - // Create the blending setup - { - D3D11_BLEND_DESC desc; - ZeroMemory(&desc, sizeof(desc)); - desc.AlphaToCoverageEnable = false; - desc.RenderTarget[0].BlendEnable = true; - desc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA; - desc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA; - desc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; - desc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; - desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA; - desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; - desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; - bd->pd3dDevice->CreateBlendState(&desc, &bd->pBlendState); - } - - // Create the rasterizer state - { - D3D11_RASTERIZER_DESC desc; - ZeroMemory(&desc, sizeof(desc)); - desc.FillMode = D3D11_FILL_SOLID; - desc.CullMode = D3D11_CULL_NONE; - desc.ScissorEnable = true; - desc.DepthClipEnable = true; - bd->pd3dDevice->CreateRasterizerState(&desc, &bd->pRasterizerState); - } - - // Create depth-stencil State - { - D3D11_DEPTH_STENCIL_DESC desc; - ZeroMemory(&desc, sizeof(desc)); - desc.DepthEnable = false; - desc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL; - desc.DepthFunc = D3D11_COMPARISON_ALWAYS; - desc.StencilEnable = false; - desc.FrontFace.StencilFailOp = desc.FrontFace.StencilDepthFailOp = desc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP; - desc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS; - desc.BackFace = desc.FrontFace; - bd->pd3dDevice->CreateDepthStencilState(&desc, &bd->pDepthStencilState); - } - - ImGui_ImplDX11_CreateFontsTexture(); - - return true; -} - -void ImGui_ImplDX11_InvalidateDeviceObjects() -{ - ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData(); - if (!bd->pd3dDevice) - return; - - if (bd->pFontSampler) { bd->pFontSampler->Release(); bd->pFontSampler = NULL; } - if (bd->pFontTextureView) { bd->pFontTextureView->Release(); bd->pFontTextureView = NULL; ImGui::GetIO().Fonts->SetTexID(NULL); } // We copied data->pFontTextureView to io.Fonts->TexID so let's clear that as well. - if (bd->pIB) { bd->pIB->Release(); bd->pIB = NULL; } - if (bd->pVB) { bd->pVB->Release(); bd->pVB = NULL; } - if (bd->pBlendState) { bd->pBlendState->Release(); bd->pBlendState = NULL; } - if (bd->pDepthStencilState) { bd->pDepthStencilState->Release(); bd->pDepthStencilState = NULL; } - if (bd->pRasterizerState) { bd->pRasterizerState->Release(); bd->pRasterizerState = NULL; } - if (bd->pPixelShader) { bd->pPixelShader->Release(); bd->pPixelShader = NULL; } - if (bd->pVertexConstantBuffer) { bd->pVertexConstantBuffer->Release(); bd->pVertexConstantBuffer = NULL; } - if (bd->pInputLayout) { bd->pInputLayout->Release(); bd->pInputLayout = NULL; } - if (bd->pVertexShader) { bd->pVertexShader->Release(); bd->pVertexShader = NULL; } -} - -bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_context) -{ - ImGuiIO& io = ImGui::GetIO(); - IM_ASSERT(io.BackendRendererUserData == NULL && "Already initialized a renderer backend!"); - - // Setup backend capabilities flags - ImGui_ImplDX11_Data* bd = IM_NEW(ImGui_ImplDX11_Data)(); - io.BackendRendererUserData = (void*)bd; - io.BackendRendererName = "imgui_impl_dx11"; - io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. - - // Get factory from device - IDXGIDevice* pDXGIDevice = NULL; - IDXGIAdapter* pDXGIAdapter = NULL; - IDXGIFactory* pFactory = NULL; - - if (device->QueryInterface(IID_PPV_ARGS(&pDXGIDevice)) == S_OK) - if (pDXGIDevice->GetParent(IID_PPV_ARGS(&pDXGIAdapter)) == S_OK) - if (pDXGIAdapter->GetParent(IID_PPV_ARGS(&pFactory)) == S_OK) - { - bd->pd3dDevice = device; - bd->pd3dDeviceContext = device_context; - bd->pFactory = pFactory; - } - if (pDXGIDevice) pDXGIDevice->Release(); - if (pDXGIAdapter) pDXGIAdapter->Release(); - bd->pd3dDevice->AddRef(); - bd->pd3dDeviceContext->AddRef(); - - return true; -} - -void ImGui_ImplDX11_Shutdown() -{ - ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData(); - IM_ASSERT(bd != NULL && "No renderer backend to shutdown, or already shutdown?"); - ImGuiIO& io = ImGui::GetIO(); - - ImGui_ImplDX11_InvalidateDeviceObjects(); - if (bd->pFactory) { bd->pFactory->Release(); } - if (bd->pd3dDevice) { bd->pd3dDevice->Release(); } - if (bd->pd3dDeviceContext) { bd->pd3dDeviceContext->Release(); } - io.BackendRendererName = NULL; - io.BackendRendererUserData = NULL; - IM_DELETE(bd); -} - -void ImGui_ImplDX11_NewFrame() -{ - ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData(); - IM_ASSERT(bd != NULL && "Did you call ImGui_ImplDX11_Init()?"); - - if (!bd->pFontSampler) - ImGui_ImplDX11_CreateDeviceObjects(); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_dx11.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_dx11.h deleted file mode 100644 index a83bce1..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_dx11.h +++ /dev/null @@ -1,26 +0,0 @@ -// dear imgui: Renderer Backend for DirectX11 -// This needs to be used along with a Platform Backend (e.g. Win32) - -// Implemented features: -// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID! -// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -#pragma once -#include "imgui.h" // IMGUI_IMPL_API - -struct ID3D11Device; -struct ID3D11DeviceContext; - -IMGUI_IMPL_API bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_context); -IMGUI_IMPL_API void ImGui_ImplDX11_Shutdown(); -IMGUI_IMPL_API void ImGui_ImplDX11_NewFrame(); -IMGUI_IMPL_API void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data); - -// Use if you want to reset your rendering device without losing Dear ImGui state. -IMGUI_IMPL_API void ImGui_ImplDX11_InvalidateDeviceObjects(); -IMGUI_IMPL_API bool ImGui_ImplDX11_CreateDeviceObjects(); diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_dx12.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_dx12.cpp deleted file mode 100644 index 5058885..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_dx12.cpp +++ /dev/null @@ -1,746 +0,0 @@ -// dear imgui: Renderer Backend for DirectX12 -// This needs to be used along with a Platform Backend (e.g. Win32) - -// Implemented features: -// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID! -// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. - -// Important: to compile on 32-bit systems, this backend requires code to be compiled with '#define ImTextureID ImU64'. -// This is because we need ImTextureID to carry a 64-bit value and by default ImTextureID is defined as void*. -// To build this on 32-bit systems: -// - [Solution 1] IDE/msbuild: in "Properties/C++/Preprocessor Definitions" add 'ImTextureID=ImU64' (this is what we do in the 'example_win32_direct12/example_win32_direct12.vcxproj' project file) -// - [Solution 2] IDE/msbuild: in "Properties/C++/Preprocessor Definitions" add 'IMGUI_USER_CONFIG="my_imgui_config.h"' and inside 'my_imgui_config.h' add '#define ImTextureID ImU64' and as many other options as you like. -// - [Solution 3] IDE/msbuild: edit imconfig.h and add '#define ImTextureID ImU64' (prefer solution 2 to create your own config file!) -// - [Solution 4] command-line: add '/D ImTextureID=ImU64' to your cl.exe command-line (this is what we do in the example_win32_direct12/build_win32.bat file) - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -// CHANGELOG -// (minor and older changes stripped away, please see git history for details) -// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX). -// 2021-05-19: DirectX12: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement) -// 2021-02-18: DirectX12: Change blending equation to preserve alpha in output buffer. -// 2021-01-11: DirectX12: Improve Windows 7 compatibility (for D3D12On7) by loading d3d12.dll dynamically. -// 2020-09-16: DirectX12: Avoid rendering calls with zero-sized scissor rectangle since it generates a validation layer warning. -// 2020-09-08: DirectX12: Clarified support for building on 32-bit systems by redefining ImTextureID. -// 2019-10-18: DirectX12: *BREAKING CHANGE* Added extra ID3D12DescriptorHeap parameter to ImGui_ImplDX12_Init() function. -// 2019-05-29: DirectX12: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag. -// 2019-04-30: DirectX12: Added support for special ImDrawCallback_ResetRenderState callback to reset render state. -// 2019-03-29: Misc: Various minor tidying up. -// 2018-12-03: Misc: Added #pragma comment statement to automatically link with d3dcompiler.lib when using D3DCompile(). -// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window. -// 2018-06-12: DirectX12: Moved the ID3D12GraphicsCommandList* parameter from NewFrame() to RenderDrawData(). -// 2018-06-08: Misc: Extracted imgui_impl_dx12.cpp/.h away from the old combined DX12+Win32 example. -// 2018-06-08: DirectX12: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle (to ease support for future multi-viewport). -// 2018-02-22: Merged into master with all Win32 code synchronized to other examples. - -#include "imgui.h" -#include "imgui_impl_dx12.h" - -// DirectX -#include -#include -#include -#ifdef _MSC_VER -#pragma comment(lib, "d3dcompiler") // Automatically link with d3dcompiler.lib as we are using D3DCompile() below. -#endif - -// DirectX data -struct ImGui_ImplDX12_RenderBuffers -{ - ID3D12Resource* IndexBuffer; - ID3D12Resource* VertexBuffer; - int IndexBufferSize; - int VertexBufferSize; -}; - -struct ImGui_ImplDX12_Data -{ - ID3D12Device* pd3dDevice; - ID3D12RootSignature* pRootSignature; - ID3D12PipelineState* pPipelineState; - DXGI_FORMAT RTVFormat; - ID3D12Resource* pFontTextureResource; - D3D12_CPU_DESCRIPTOR_HANDLE hFontSrvCpuDescHandle; - D3D12_GPU_DESCRIPTOR_HANDLE hFontSrvGpuDescHandle; - - ImGui_ImplDX12_RenderBuffers* pFrameResources; - UINT numFramesInFlight; - UINT frameIndex; - - ImGui_ImplDX12_Data() { memset(this, 0, sizeof(*this)); frameIndex = UINT_MAX; } -}; - -struct VERTEX_CONSTANT_BUFFER -{ - float mvp[4][4]; -}; - -// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts -// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts. -static ImGui_ImplDX12_Data* ImGui_ImplDX12_GetBackendData() -{ - return ImGui::GetCurrentContext() ? (ImGui_ImplDX12_Data*)ImGui::GetIO().BackendRendererUserData : NULL; -} - -// Functions -static void ImGui_ImplDX12_SetupRenderState(ImDrawData* draw_data, ID3D12GraphicsCommandList* ctx, ImGui_ImplDX12_RenderBuffers* fr) -{ - ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData(); - - // Setup orthographic projection matrix into our constant buffer - // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). - VERTEX_CONSTANT_BUFFER vertex_constant_buffer; - { - float L = draw_data->DisplayPos.x; - float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x; - float T = draw_data->DisplayPos.y; - float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y; - float mvp[4][4] = - { - { 2.0f/(R-L), 0.0f, 0.0f, 0.0f }, - { 0.0f, 2.0f/(T-B), 0.0f, 0.0f }, - { 0.0f, 0.0f, 0.5f, 0.0f }, - { (R+L)/(L-R), (T+B)/(B-T), 0.5f, 1.0f }, - }; - memcpy(&vertex_constant_buffer.mvp, mvp, sizeof(mvp)); - } - - // Setup viewport - D3D12_VIEWPORT vp; - memset(&vp, 0, sizeof(D3D12_VIEWPORT)); - vp.Width = draw_data->DisplaySize.x; - vp.Height = draw_data->DisplaySize.y; - vp.MinDepth = 0.0f; - vp.MaxDepth = 1.0f; - vp.TopLeftX = vp.TopLeftY = 0.0f; - ctx->RSSetViewports(1, &vp); - - // Bind shader and vertex buffers - unsigned int stride = sizeof(ImDrawVert); - unsigned int offset = 0; - D3D12_VERTEX_BUFFER_VIEW vbv; - memset(&vbv, 0, sizeof(D3D12_VERTEX_BUFFER_VIEW)); - vbv.BufferLocation = fr->VertexBuffer->GetGPUVirtualAddress() + offset; - vbv.SizeInBytes = fr->VertexBufferSize * stride; - vbv.StrideInBytes = stride; - ctx->IASetVertexBuffers(0, 1, &vbv); - D3D12_INDEX_BUFFER_VIEW ibv; - memset(&ibv, 0, sizeof(D3D12_INDEX_BUFFER_VIEW)); - ibv.BufferLocation = fr->IndexBuffer->GetGPUVirtualAddress(); - ibv.SizeInBytes = fr->IndexBufferSize * sizeof(ImDrawIdx); - ibv.Format = sizeof(ImDrawIdx) == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT; - ctx->IASetIndexBuffer(&ibv); - ctx->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - ctx->SetPipelineState(bd->pPipelineState); - ctx->SetGraphicsRootSignature(bd->pRootSignature); - ctx->SetGraphicsRoot32BitConstants(0, 16, &vertex_constant_buffer, 0); - - // Setup blend factor - const float blend_factor[4] = { 0.f, 0.f, 0.f, 0.f }; - ctx->OMSetBlendFactor(blend_factor); -} - -template -static inline void SafeRelease(T*& res) -{ - if (res) - res->Release(); - res = NULL; -} - -// Render function -void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandList* ctx) -{ - // Avoid rendering when minimized - if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f) - return; - - // FIXME: I'm assuming that this only gets called once per frame! - // If not, we can't just re-allocate the IB or VB, we'll have to do a proper allocator. - ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData(); - bd->frameIndex = bd->frameIndex + 1; - ImGui_ImplDX12_RenderBuffers* fr = &bd->pFrameResources[bd->frameIndex % bd->numFramesInFlight]; - - // Create and grow vertex/index buffers if needed - if (fr->VertexBuffer == NULL || fr->VertexBufferSize < draw_data->TotalVtxCount) - { - SafeRelease(fr->VertexBuffer); - fr->VertexBufferSize = draw_data->TotalVtxCount + 5000; - D3D12_HEAP_PROPERTIES props; - memset(&props, 0, sizeof(D3D12_HEAP_PROPERTIES)); - props.Type = D3D12_HEAP_TYPE_UPLOAD; - props.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; - props.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; - D3D12_RESOURCE_DESC desc; - memset(&desc, 0, sizeof(D3D12_RESOURCE_DESC)); - desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; - desc.Width = fr->VertexBufferSize * sizeof(ImDrawVert); - desc.Height = 1; - desc.DepthOrArraySize = 1; - desc.MipLevels = 1; - desc.Format = DXGI_FORMAT_UNKNOWN; - desc.SampleDesc.Count = 1; - desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; - desc.Flags = D3D12_RESOURCE_FLAG_NONE; - if (bd->pd3dDevice->CreateCommittedResource(&props, D3D12_HEAP_FLAG_NONE, &desc, D3D12_RESOURCE_STATE_GENERIC_READ, NULL, IID_PPV_ARGS(&fr->VertexBuffer)) < 0) - return; - } - if (fr->IndexBuffer == NULL || fr->IndexBufferSize < draw_data->TotalIdxCount) - { - SafeRelease(fr->IndexBuffer); - fr->IndexBufferSize = draw_data->TotalIdxCount + 10000; - D3D12_HEAP_PROPERTIES props; - memset(&props, 0, sizeof(D3D12_HEAP_PROPERTIES)); - props.Type = D3D12_HEAP_TYPE_UPLOAD; - props.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; - props.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; - D3D12_RESOURCE_DESC desc; - memset(&desc, 0, sizeof(D3D12_RESOURCE_DESC)); - desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; - desc.Width = fr->IndexBufferSize * sizeof(ImDrawIdx); - desc.Height = 1; - desc.DepthOrArraySize = 1; - desc.MipLevels = 1; - desc.Format = DXGI_FORMAT_UNKNOWN; - desc.SampleDesc.Count = 1; - desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; - desc.Flags = D3D12_RESOURCE_FLAG_NONE; - if (bd->pd3dDevice->CreateCommittedResource(&props, D3D12_HEAP_FLAG_NONE, &desc, D3D12_RESOURCE_STATE_GENERIC_READ, NULL, IID_PPV_ARGS(&fr->IndexBuffer)) < 0) - return; - } - - // Upload vertex/index data into a single contiguous GPU buffer - void* vtx_resource, *idx_resource; - D3D12_RANGE range; - memset(&range, 0, sizeof(D3D12_RANGE)); - if (fr->VertexBuffer->Map(0, &range, &vtx_resource) != S_OK) - return; - if (fr->IndexBuffer->Map(0, &range, &idx_resource) != S_OK) - return; - ImDrawVert* vtx_dst = (ImDrawVert*)vtx_resource; - ImDrawIdx* idx_dst = (ImDrawIdx*)idx_resource; - for (int n = 0; n < draw_data->CmdListsCount; n++) - { - const ImDrawList* cmd_list = draw_data->CmdLists[n]; - memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert)); - memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx)); - vtx_dst += cmd_list->VtxBuffer.Size; - idx_dst += cmd_list->IdxBuffer.Size; - } - fr->VertexBuffer->Unmap(0, &range); - fr->IndexBuffer->Unmap(0, &range); - - // Setup desired DX state - ImGui_ImplDX12_SetupRenderState(draw_data, ctx, fr); - - // Render command lists - // (Because we merged all buffers into a single one, we maintain our own offset into them) - int global_vtx_offset = 0; - int global_idx_offset = 0; - ImVec2 clip_off = draw_data->DisplayPos; - for (int n = 0; n < draw_data->CmdListsCount; n++) - { - const ImDrawList* cmd_list = draw_data->CmdLists[n]; - for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) - { - const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; - if (pcmd->UserCallback != NULL) - { - // User callback, registered via ImDrawList::AddCallback() - // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.) - if (pcmd->UserCallback == ImDrawCallback_ResetRenderState) - ImGui_ImplDX12_SetupRenderState(draw_data, ctx, fr); - else - pcmd->UserCallback(cmd_list, pcmd); - } - else - { - // Project scissor/clipping rectangles into framebuffer space - ImVec2 clip_min(pcmd->ClipRect.x - clip_off.x, pcmd->ClipRect.y - clip_off.y); - ImVec2 clip_max(pcmd->ClipRect.z - clip_off.x, pcmd->ClipRect.w - clip_off.y); - if (clip_max.x < clip_min.x || clip_max.y < clip_min.y) - continue; - - // Apply Scissor/clipping rectangle, Bind texture, Draw - const D3D12_RECT r = { (LONG)clip_min.x, (LONG)clip_min.y, (LONG)clip_max.x, (LONG)clip_max.y }; - D3D12_GPU_DESCRIPTOR_HANDLE texture_handle = {}; - texture_handle.ptr = (UINT64)pcmd->GetTexID(); - ctx->SetGraphicsRootDescriptorTable(1, texture_handle); - ctx->RSSetScissorRects(1, &r); - ctx->DrawIndexedInstanced(pcmd->ElemCount, 1, pcmd->IdxOffset + global_idx_offset, pcmd->VtxOffset + global_vtx_offset, 0); - } - } - global_idx_offset += cmd_list->IdxBuffer.Size; - global_vtx_offset += cmd_list->VtxBuffer.Size; - } -} - -static void ImGui_ImplDX12_CreateFontsTexture() -{ - // Build texture atlas - ImGuiIO& io = ImGui::GetIO(); - ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData(); - unsigned char* pixels; - int width, height; - io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); - - // Upload texture to graphics system - { - D3D12_HEAP_PROPERTIES props; - memset(&props, 0, sizeof(D3D12_HEAP_PROPERTIES)); - props.Type = D3D12_HEAP_TYPE_DEFAULT; - props.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; - props.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; - - D3D12_RESOURCE_DESC desc; - ZeroMemory(&desc, sizeof(desc)); - desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; - desc.Alignment = 0; - desc.Width = width; - desc.Height = height; - desc.DepthOrArraySize = 1; - desc.MipLevels = 1; - desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; - desc.SampleDesc.Count = 1; - desc.SampleDesc.Quality = 0; - desc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN; - desc.Flags = D3D12_RESOURCE_FLAG_NONE; - - ID3D12Resource* pTexture = NULL; - bd->pd3dDevice->CreateCommittedResource(&props, D3D12_HEAP_FLAG_NONE, &desc, - D3D12_RESOURCE_STATE_COPY_DEST, NULL, IID_PPV_ARGS(&pTexture)); - - UINT uploadPitch = (width * 4 + D3D12_TEXTURE_DATA_PITCH_ALIGNMENT - 1u) & ~(D3D12_TEXTURE_DATA_PITCH_ALIGNMENT - 1u); - UINT uploadSize = height * uploadPitch; - desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER; - desc.Alignment = 0; - desc.Width = uploadSize; - desc.Height = 1; - desc.DepthOrArraySize = 1; - desc.MipLevels = 1; - desc.Format = DXGI_FORMAT_UNKNOWN; - desc.SampleDesc.Count = 1; - desc.SampleDesc.Quality = 0; - desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; - desc.Flags = D3D12_RESOURCE_FLAG_NONE; - - props.Type = D3D12_HEAP_TYPE_UPLOAD; - props.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; - props.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; - - ID3D12Resource* uploadBuffer = NULL; - HRESULT hr = bd->pd3dDevice->CreateCommittedResource(&props, D3D12_HEAP_FLAG_NONE, &desc, - D3D12_RESOURCE_STATE_GENERIC_READ, NULL, IID_PPV_ARGS(&uploadBuffer)); - IM_ASSERT(SUCCEEDED(hr)); - - void* mapped = NULL; - D3D12_RANGE range = { 0, uploadSize }; - hr = uploadBuffer->Map(0, &range, &mapped); - IM_ASSERT(SUCCEEDED(hr)); - for (int y = 0; y < height; y++) - memcpy((void*) ((uintptr_t) mapped + y * uploadPitch), pixels + y * width * 4, width * 4); - uploadBuffer->Unmap(0, &range); - - D3D12_TEXTURE_COPY_LOCATION srcLocation = {}; - srcLocation.pResource = uploadBuffer; - srcLocation.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT; - srcLocation.PlacedFootprint.Footprint.Format = DXGI_FORMAT_R8G8B8A8_UNORM; - srcLocation.PlacedFootprint.Footprint.Width = width; - srcLocation.PlacedFootprint.Footprint.Height = height; - srcLocation.PlacedFootprint.Footprint.Depth = 1; - srcLocation.PlacedFootprint.Footprint.RowPitch = uploadPitch; - - D3D12_TEXTURE_COPY_LOCATION dstLocation = {}; - dstLocation.pResource = pTexture; - dstLocation.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX; - dstLocation.SubresourceIndex = 0; - - D3D12_RESOURCE_BARRIER barrier = {}; - barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; - barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; - barrier.Transition.pResource = pTexture; - barrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES; - barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_COPY_DEST; - barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE; - - ID3D12Fence* fence = NULL; - hr = bd->pd3dDevice->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&fence)); - IM_ASSERT(SUCCEEDED(hr)); - - HANDLE event = CreateEvent(0, 0, 0, 0); - IM_ASSERT(event != NULL); - - D3D12_COMMAND_QUEUE_DESC queueDesc = {}; - queueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT; - queueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE; - queueDesc.NodeMask = 1; - - ID3D12CommandQueue* cmdQueue = NULL; - hr = bd->pd3dDevice->CreateCommandQueue(&queueDesc, IID_PPV_ARGS(&cmdQueue)); - IM_ASSERT(SUCCEEDED(hr)); - - ID3D12CommandAllocator* cmdAlloc = NULL; - hr = bd->pd3dDevice->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&cmdAlloc)); - IM_ASSERT(SUCCEEDED(hr)); - - ID3D12GraphicsCommandList* cmdList = NULL; - hr = bd->pd3dDevice->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, cmdAlloc, NULL, IID_PPV_ARGS(&cmdList)); - IM_ASSERT(SUCCEEDED(hr)); - - cmdList->CopyTextureRegion(&dstLocation, 0, 0, 0, &srcLocation, NULL); - cmdList->ResourceBarrier(1, &barrier); - - hr = cmdList->Close(); - IM_ASSERT(SUCCEEDED(hr)); - - cmdQueue->ExecuteCommandLists(1, (ID3D12CommandList* const*)&cmdList); - hr = cmdQueue->Signal(fence, 1); - IM_ASSERT(SUCCEEDED(hr)); - - fence->SetEventOnCompletion(1, event); - WaitForSingleObject(event, INFINITE); - - cmdList->Release(); - cmdAlloc->Release(); - cmdQueue->Release(); - CloseHandle(event); - fence->Release(); - uploadBuffer->Release(); - - // Create texture view - D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc; - ZeroMemory(&srvDesc, sizeof(srvDesc)); - srvDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; - srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; - srvDesc.Texture2D.MipLevels = desc.MipLevels; - srvDesc.Texture2D.MostDetailedMip = 0; - srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; - bd->pd3dDevice->CreateShaderResourceView(pTexture, &srvDesc, bd->hFontSrvCpuDescHandle); - SafeRelease(bd->pFontTextureResource); - bd->pFontTextureResource = pTexture; - } - - // Store our identifier - // READ THIS IF THE STATIC_ASSERT() TRIGGERS: - // - Important: to compile on 32-bit systems, this backend requires code to be compiled with '#define ImTextureID ImU64'. - // - This is because we need ImTextureID to carry a 64-bit value and by default ImTextureID is defined as void*. - // [Solution 1] IDE/msbuild: in "Properties/C++/Preprocessor Definitions" add 'ImTextureID=ImU64' (this is what we do in the 'example_win32_direct12/example_win32_direct12.vcxproj' project file) - // [Solution 2] IDE/msbuild: in "Properties/C++/Preprocessor Definitions" add 'IMGUI_USER_CONFIG="my_imgui_config.h"' and inside 'my_imgui_config.h' add '#define ImTextureID ImU64' and as many other options as you like. - // [Solution 3] IDE/msbuild: edit imconfig.h and add '#define ImTextureID ImU64' (prefer solution 2 to create your own config file!) - // [Solution 4] command-line: add '/D ImTextureID=ImU64' to your cl.exe command-line (this is what we do in the example_win32_direct12/build_win32.bat file) - static_assert(sizeof(ImTextureID) >= sizeof(bd->hFontSrvGpuDescHandle.ptr), "Can't pack descriptor handle into TexID, 32-bit not supported yet."); - io.Fonts->SetTexID((ImTextureID)bd->hFontSrvGpuDescHandle.ptr); -} - -bool ImGui_ImplDX12_CreateDeviceObjects() -{ - ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData(); - if (!bd || !bd->pd3dDevice) - return false; - if (bd->pPipelineState) - ImGui_ImplDX12_InvalidateDeviceObjects(); - - // Create the root signature - { - D3D12_DESCRIPTOR_RANGE descRange = {}; - descRange.RangeType = D3D12_DESCRIPTOR_RANGE_TYPE_SRV; - descRange.NumDescriptors = 1; - descRange.BaseShaderRegister = 0; - descRange.RegisterSpace = 0; - descRange.OffsetInDescriptorsFromTableStart = 0; - - D3D12_ROOT_PARAMETER param[2] = {}; - - param[0].ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS; - param[0].Constants.ShaderRegister = 0; - param[0].Constants.RegisterSpace = 0; - param[0].Constants.Num32BitValues = 16; - param[0].ShaderVisibility = D3D12_SHADER_VISIBILITY_VERTEX; - - param[1].ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; - param[1].DescriptorTable.NumDescriptorRanges = 1; - param[1].DescriptorTable.pDescriptorRanges = &descRange; - param[1].ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL; - - D3D12_STATIC_SAMPLER_DESC staticSampler = {}; - staticSampler.Filter = D3D12_FILTER_MIN_MAG_MIP_LINEAR; - staticSampler.AddressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP; - staticSampler.AddressV = D3D12_TEXTURE_ADDRESS_MODE_WRAP; - staticSampler.AddressW = D3D12_TEXTURE_ADDRESS_MODE_WRAP; - staticSampler.MipLODBias = 0.f; - staticSampler.MaxAnisotropy = 0; - staticSampler.ComparisonFunc = D3D12_COMPARISON_FUNC_ALWAYS; - staticSampler.BorderColor = D3D12_STATIC_BORDER_COLOR_TRANSPARENT_BLACK; - staticSampler.MinLOD = 0.f; - staticSampler.MaxLOD = 0.f; - staticSampler.ShaderRegister = 0; - staticSampler.RegisterSpace = 0; - staticSampler.ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL; - - D3D12_ROOT_SIGNATURE_DESC desc = {}; - desc.NumParameters = _countof(param); - desc.pParameters = param; - desc.NumStaticSamplers = 1; - desc.pStaticSamplers = &staticSampler; - desc.Flags = - D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT | - D3D12_ROOT_SIGNATURE_FLAG_DENY_HULL_SHADER_ROOT_ACCESS | - D3D12_ROOT_SIGNATURE_FLAG_DENY_DOMAIN_SHADER_ROOT_ACCESS | - D3D12_ROOT_SIGNATURE_FLAG_DENY_GEOMETRY_SHADER_ROOT_ACCESS; - - // Load d3d12.dll and D3D12SerializeRootSignature() function address dynamically to facilitate using with D3D12On7. - // See if any version of d3d12.dll is already loaded in the process. If so, give preference to that. - static HINSTANCE d3d12_dll = ::GetModuleHandleA("d3d12.dll"); - if (d3d12_dll == NULL) - { - // Attempt to load d3d12.dll from local directories. This will only succeed if - // (1) the current OS is Windows 7, and - // (2) there exists a version of d3d12.dll for Windows 7 (D3D12On7) in one of the following directories. - // See https://github.com/ocornut/imgui/pull/3696 for details. - const char* localD3d12Paths[] = { ".\\d3d12.dll", ".\\d3d12on7\\d3d12.dll", ".\\12on7\\d3d12.dll" }; // A. current directory, B. used by some games, C. used in Microsoft D3D12On7 sample - for (int i = 0; i < IM_ARRAYSIZE(localD3d12Paths); i++) - if ((d3d12_dll = ::LoadLibraryA(localD3d12Paths[i])) != NULL) - break; - - // If failed, we are on Windows >= 10. - if (d3d12_dll == NULL) - d3d12_dll = ::LoadLibraryA("d3d12.dll"); - - if (d3d12_dll == NULL) - return false; - } - - PFN_D3D12_SERIALIZE_ROOT_SIGNATURE D3D12SerializeRootSignatureFn = (PFN_D3D12_SERIALIZE_ROOT_SIGNATURE)::GetProcAddress(d3d12_dll, "D3D12SerializeRootSignature"); - if (D3D12SerializeRootSignatureFn == NULL) - return false; - - ID3DBlob* blob = NULL; - if (D3D12SerializeRootSignatureFn(&desc, D3D_ROOT_SIGNATURE_VERSION_1, &blob, NULL) != S_OK) - return false; - - bd->pd3dDevice->CreateRootSignature(0, blob->GetBufferPointer(), blob->GetBufferSize(), IID_PPV_ARGS(&bd->pRootSignature)); - blob->Release(); - } - - // By using D3DCompile() from / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A) - // If you would like to use this DX12 sample code but remove this dependency you can: - // 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution] - // 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL. - // See https://github.com/ocornut/imgui/pull/638 for sources and details. - - D3D12_GRAPHICS_PIPELINE_STATE_DESC psoDesc; - memset(&psoDesc, 0, sizeof(D3D12_GRAPHICS_PIPELINE_STATE_DESC)); - psoDesc.NodeMask = 1; - psoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; - psoDesc.pRootSignature = bd->pRootSignature; - psoDesc.SampleMask = UINT_MAX; - psoDesc.NumRenderTargets = 1; - psoDesc.RTVFormats[0] = bd->RTVFormat; - psoDesc.SampleDesc.Count = 1; - psoDesc.Flags = D3D12_PIPELINE_STATE_FLAG_NONE; - - ID3DBlob* vertexShaderBlob; - ID3DBlob* pixelShaderBlob; - - // Create the vertex shader - { - static const char* vertexShader = - "cbuffer vertexBuffer : register(b0) \ - {\ - float4x4 ProjectionMatrix; \ - };\ - struct VS_INPUT\ - {\ - float2 pos : POSITION;\ - float4 col : COLOR0;\ - float2 uv : TEXCOORD0;\ - };\ - \ - struct PS_INPUT\ - {\ - float4 pos : SV_POSITION;\ - float4 col : COLOR0;\ - float2 uv : TEXCOORD0;\ - };\ - \ - PS_INPUT main(VS_INPUT input)\ - {\ - PS_INPUT output;\ - output.pos = mul( ProjectionMatrix, float4(input.pos.xy, 0.f, 1.f));\ - output.col = input.col;\ - output.uv = input.uv;\ - return output;\ - }"; - - if (FAILED(D3DCompile(vertexShader, strlen(vertexShader), NULL, NULL, NULL, "main", "vs_5_0", 0, 0, &vertexShaderBlob, NULL))) - return false; // NB: Pass ID3D10Blob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob! - psoDesc.VS = { vertexShaderBlob->GetBufferPointer(), vertexShaderBlob->GetBufferSize() }; - - // Create the input layout - static D3D12_INPUT_ELEMENT_DESC local_layout[] = - { - { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, pos), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, - { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, uv), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, - { "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (UINT)IM_OFFSETOF(ImDrawVert, col), D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, - }; - psoDesc.InputLayout = { local_layout, 3 }; - } - - // Create the pixel shader - { - static const char* pixelShader = - "struct PS_INPUT\ - {\ - float4 pos : SV_POSITION;\ - float4 col : COLOR0;\ - float2 uv : TEXCOORD0;\ - };\ - SamplerState sampler0 : register(s0);\ - Texture2D texture0 : register(t0);\ - \ - float4 main(PS_INPUT input) : SV_Target\ - {\ - float4 out_col = input.col * texture0.Sample(sampler0, input.uv); \ - return out_col; \ - }"; - - if (FAILED(D3DCompile(pixelShader, strlen(pixelShader), NULL, NULL, NULL, "main", "ps_5_0", 0, 0, &pixelShaderBlob, NULL))) - { - vertexShaderBlob->Release(); - return false; // NB: Pass ID3D10Blob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob! - } - psoDesc.PS = { pixelShaderBlob->GetBufferPointer(), pixelShaderBlob->GetBufferSize() }; - } - - // Create the blending setup - { - D3D12_BLEND_DESC& desc = psoDesc.BlendState; - desc.AlphaToCoverageEnable = false; - desc.RenderTarget[0].BlendEnable = true; - desc.RenderTarget[0].SrcBlend = D3D12_BLEND_SRC_ALPHA; - desc.RenderTarget[0].DestBlend = D3D12_BLEND_INV_SRC_ALPHA; - desc.RenderTarget[0].BlendOp = D3D12_BLEND_OP_ADD; - desc.RenderTarget[0].SrcBlendAlpha = D3D12_BLEND_ONE; - desc.RenderTarget[0].DestBlendAlpha = D3D12_BLEND_INV_SRC_ALPHA; - desc.RenderTarget[0].BlendOpAlpha = D3D12_BLEND_OP_ADD; - desc.RenderTarget[0].RenderTargetWriteMask = D3D12_COLOR_WRITE_ENABLE_ALL; - } - - // Create the rasterizer state - { - D3D12_RASTERIZER_DESC& desc = psoDesc.RasterizerState; - desc.FillMode = D3D12_FILL_MODE_SOLID; - desc.CullMode = D3D12_CULL_MODE_NONE; - desc.FrontCounterClockwise = FALSE; - desc.DepthBias = D3D12_DEFAULT_DEPTH_BIAS; - desc.DepthBiasClamp = D3D12_DEFAULT_DEPTH_BIAS_CLAMP; - desc.SlopeScaledDepthBias = D3D12_DEFAULT_SLOPE_SCALED_DEPTH_BIAS; - desc.DepthClipEnable = true; - desc.MultisampleEnable = FALSE; - desc.AntialiasedLineEnable = FALSE; - desc.ForcedSampleCount = 0; - desc.ConservativeRaster = D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF; - } - - // Create depth-stencil State - { - D3D12_DEPTH_STENCIL_DESC& desc = psoDesc.DepthStencilState; - desc.DepthEnable = false; - desc.DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ALL; - desc.DepthFunc = D3D12_COMPARISON_FUNC_ALWAYS; - desc.StencilEnable = false; - desc.FrontFace.StencilFailOp = desc.FrontFace.StencilDepthFailOp = desc.FrontFace.StencilPassOp = D3D12_STENCIL_OP_KEEP; - desc.FrontFace.StencilFunc = D3D12_COMPARISON_FUNC_ALWAYS; - desc.BackFace = desc.FrontFace; - } - - HRESULT result_pipeline_state = bd->pd3dDevice->CreateGraphicsPipelineState(&psoDesc, IID_PPV_ARGS(&bd->pPipelineState)); - vertexShaderBlob->Release(); - pixelShaderBlob->Release(); - if (result_pipeline_state != S_OK) - return false; - - ImGui_ImplDX12_CreateFontsTexture(); - - return true; -} - -void ImGui_ImplDX12_InvalidateDeviceObjects() -{ - ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData(); - if (!bd || !bd->pd3dDevice) - return; - ImGuiIO& io = ImGui::GetIO(); - - SafeRelease(bd->pRootSignature); - SafeRelease(bd->pPipelineState); - SafeRelease(bd->pFontTextureResource); - io.Fonts->SetTexID(NULL); // We copied bd->pFontTextureView to io.Fonts->TexID so let's clear that as well. - - for (UINT i = 0; i < bd->numFramesInFlight; i++) - { - ImGui_ImplDX12_RenderBuffers* fr = &bd->pFrameResources[i]; - SafeRelease(fr->IndexBuffer); - SafeRelease(fr->VertexBuffer); - } -} - -bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format, ID3D12DescriptorHeap* cbv_srv_heap, - D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle) -{ - ImGuiIO& io = ImGui::GetIO(); - IM_ASSERT(io.BackendRendererUserData == NULL && "Already initialized a renderer backend!"); - - // Setup backend capabilities flags - ImGui_ImplDX12_Data* bd = IM_NEW(ImGui_ImplDX12_Data)(); - io.BackendRendererUserData = (void*)bd; - io.BackendRendererName = "imgui_impl_dx12"; - io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. - - bd->pd3dDevice = device; - bd->RTVFormat = rtv_format; - bd->hFontSrvCpuDescHandle = font_srv_cpu_desc_handle; - bd->hFontSrvGpuDescHandle = font_srv_gpu_desc_handle; - bd->pFrameResources = new ImGui_ImplDX12_RenderBuffers[num_frames_in_flight]; - bd->numFramesInFlight = num_frames_in_flight; - bd->frameIndex = UINT_MAX; - IM_UNUSED(cbv_srv_heap); // Unused in master branch (will be used by multi-viewports) - - // Create buffers with a default size (they will later be grown as needed) - for (int i = 0; i < num_frames_in_flight; i++) - { - ImGui_ImplDX12_RenderBuffers* fr = &bd->pFrameResources[i]; - fr->IndexBuffer = NULL; - fr->VertexBuffer = NULL; - fr->IndexBufferSize = 10000; - fr->VertexBufferSize = 5000; - } - - return true; -} - -void ImGui_ImplDX12_Shutdown() -{ - ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData(); - IM_ASSERT(bd != NULL && "No renderer backend to shutdown, or already shutdown?"); - ImGuiIO& io = ImGui::GetIO(); - - ImGui_ImplDX12_InvalidateDeviceObjects(); - delete[] bd->pFrameResources; - io.BackendRendererName = NULL; - io.BackendRendererUserData = NULL; - IM_DELETE(bd); -} - -void ImGui_ImplDX12_NewFrame() -{ - ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData(); - IM_ASSERT(bd != NULL && "Did you call ImGui_ImplDX12_Init()?"); - - if (!bd->pPipelineState) - ImGui_ImplDX12_CreateDeviceObjects(); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_dx12.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_dx12.h deleted file mode 100644 index 899c822..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_dx12.h +++ /dev/null @@ -1,39 +0,0 @@ -// dear imgui: Renderer Backend for DirectX12 -// This needs to be used along with a Platform Backend (e.g. Win32) - -// Implemented features: -// [X] Renderer: User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID! -// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. - -// Important: to compile on 32-bit systems, this backend requires code to be compiled with '#define ImTextureID ImU64'. -// This is because we need ImTextureID to carry a 64-bit value and by default ImTextureID is defined as void*. -// This define is set in the example .vcxproj file and need to be replicated in your app or by adding it to your imconfig.h file. - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -#pragma once -#include "imgui.h" // IMGUI_IMPL_API -#include // DXGI_FORMAT - -struct ID3D12Device; -struct ID3D12DescriptorHeap; -struct ID3D12GraphicsCommandList; -struct D3D12_CPU_DESCRIPTOR_HANDLE; -struct D3D12_GPU_DESCRIPTOR_HANDLE; - -// cmd_list is the command list that the implementation will use to render imgui draw lists. -// Before calling the render function, caller must prepare cmd_list by resetting it and setting the appropriate -// render target and descriptor heap that contains font_srv_cpu_desc_handle/font_srv_gpu_desc_handle. -// font_srv_cpu_desc_handle and font_srv_gpu_desc_handle are handles to a single SRV descriptor to use for the internal font texture. -IMGUI_IMPL_API bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FORMAT rtv_format, ID3D12DescriptorHeap* cbv_srv_heap, - D3D12_CPU_DESCRIPTOR_HANDLE font_srv_cpu_desc_handle, D3D12_GPU_DESCRIPTOR_HANDLE font_srv_gpu_desc_handle); -IMGUI_IMPL_API void ImGui_ImplDX12_Shutdown(); -IMGUI_IMPL_API void ImGui_ImplDX12_NewFrame(); -IMGUI_IMPL_API void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandList* graphics_command_list); - -// Use if you want to reset your rendering device without losing Dear ImGui state. -IMGUI_IMPL_API void ImGui_ImplDX12_InvalidateDeviceObjects(); -IMGUI_IMPL_API bool ImGui_ImplDX12_CreateDeviceObjects(); diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_dx9.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_dx9.cpp deleted file mode 100644 index 9234cb0..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_dx9.cpp +++ /dev/null @@ -1,378 +0,0 @@ -// dear imgui: Renderer Backend for DirectX9 -// This needs to be used along with a Platform Backend (e.g. Win32) - -// Implemented features: -// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID! -// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -// CHANGELOG -// (minor and older changes stripped away, please see git history for details) -// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX). -// 2021-06-25: DirectX9: Explicitly disable texture state stages after >= 1. -// 2021-05-19: DirectX9: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement) -// 2021-04-23: DirectX9: Explicitly setting up more graphics states to increase compatibility with unusual non-default states. -// 2021-03-18: DirectX9: Calling IDirect3DStateBlock9::Capture() after CreateStateBlock() as a workaround for state restoring issues (see #3857). -// 2021-03-03: DirectX9: Added support for IMGUI_USE_BGRA_PACKED_COLOR in user's imconfig file. -// 2021-02-18: DirectX9: Change blending equation to preserve alpha in output buffer. -// 2019-05-29: DirectX9: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag. -// 2019-04-30: DirectX9: Added support for special ImDrawCallback_ResetRenderState callback to reset render state. -// 2019-03-29: Misc: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). -// 2019-01-16: Misc: Disabled fog before drawing UI's. Fixes issue #2288. -// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window. -// 2018-06-08: Misc: Extracted imgui_impl_dx9.cpp/.h away from the old combined DX9+Win32 example. -// 2018-06-08: DirectX9: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle. -// 2018-05-07: Render: Saving/restoring Transform because they don't seem to be included in the StateBlock. Setting shading mode to Gouraud. -// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplDX9_RenderDrawData() in the .h file so you can call it yourself. -// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves. - -#include "imgui.h" -#include "imgui_impl_dx9.h" - -// DirectX -#include - -// DirectX data -struct ImGui_ImplDX9_Data -{ - LPDIRECT3DDEVICE9 pd3dDevice; - LPDIRECT3DVERTEXBUFFER9 pVB; - LPDIRECT3DINDEXBUFFER9 pIB; - LPDIRECT3DTEXTURE9 FontTexture; - int VertexBufferSize; - int IndexBufferSize; - - ImGui_ImplDX9_Data() { memset(this, 0, sizeof(*this)); VertexBufferSize = 5000; IndexBufferSize = 10000; } -}; - -struct CUSTOMVERTEX -{ - float pos[3]; - D3DCOLOR col; - float uv[2]; -}; -#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1) - -#ifdef IMGUI_USE_BGRA_PACKED_COLOR -#define IMGUI_COL_TO_DX9_ARGB(_COL) (_COL) -#else -#define IMGUI_COL_TO_DX9_ARGB(_COL) (((_COL) & 0xFF00FF00) | (((_COL) & 0xFF0000) >> 16) | (((_COL) & 0xFF) << 16)) -#endif - -// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts -// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts. -static ImGui_ImplDX9_Data* ImGui_ImplDX9_GetBackendData() -{ - return ImGui::GetCurrentContext() ? (ImGui_ImplDX9_Data*)ImGui::GetIO().BackendRendererUserData : NULL; -} - -// Functions -static void ImGui_ImplDX9_SetupRenderState(ImDrawData* draw_data) -{ - ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData(); - - // Setup viewport - D3DVIEWPORT9 vp; - vp.X = vp.Y = 0; - vp.Width = (DWORD)draw_data->DisplaySize.x; - vp.Height = (DWORD)draw_data->DisplaySize.y; - vp.MinZ = 0.0f; - vp.MaxZ = 1.0f; - bd->pd3dDevice->SetViewport(&vp); - - // Setup render state: fixed-pipeline, alpha-blending, no face culling, no depth testing, shade mode (for gradient) - bd->pd3dDevice->SetPixelShader(NULL); - bd->pd3dDevice->SetVertexShader(NULL); - bd->pd3dDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID); - bd->pd3dDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD); - bd->pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE, FALSE); - bd->pd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); - bd->pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); - bd->pd3dDevice->SetRenderState(D3DRS_ZENABLE, FALSE); - bd->pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - bd->pd3dDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD); - bd->pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); - bd->pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); - bd->pd3dDevice->SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, TRUE); - bd->pd3dDevice->SetRenderState(D3DRS_SRCBLENDALPHA, D3DBLEND_ONE); - bd->pd3dDevice->SetRenderState(D3DRS_DESTBLENDALPHA, D3DBLEND_INVSRCALPHA); - bd->pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE); - bd->pd3dDevice->SetRenderState(D3DRS_FOGENABLE, FALSE); - bd->pd3dDevice->SetRenderState(D3DRS_RANGEFOGENABLE, FALSE); - bd->pd3dDevice->SetRenderState(D3DRS_SPECULARENABLE, FALSE); - bd->pd3dDevice->SetRenderState(D3DRS_STENCILENABLE, FALSE); - bd->pd3dDevice->SetRenderState(D3DRS_CLIPPING, TRUE); - bd->pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE); - bd->pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); - bd->pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - bd->pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - bd->pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE); - bd->pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); - bd->pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); - bd->pd3dDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE); - bd->pd3dDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - bd->pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); - bd->pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); - - // Setup orthographic projection matrix - // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps. - // Being agnostic of whether or can be used, we aren't relying on D3DXMatrixIdentity()/D3DXMatrixOrthoOffCenterLH() or DirectX::XMMatrixIdentity()/DirectX::XMMatrixOrthographicOffCenterLH() - { - float L = draw_data->DisplayPos.x + 0.5f; - float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x + 0.5f; - float T = draw_data->DisplayPos.y + 0.5f; - float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y + 0.5f; - D3DMATRIX mat_identity = { { { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f } } }; - D3DMATRIX mat_projection = - { { { - 2.0f/(R-L), 0.0f, 0.0f, 0.0f, - 0.0f, 2.0f/(T-B), 0.0f, 0.0f, - 0.0f, 0.0f, 0.5f, 0.0f, - (L+R)/(L-R), (T+B)/(B-T), 0.5f, 1.0f - } } }; - bd->pd3dDevice->SetTransform(D3DTS_WORLD, &mat_identity); - bd->pd3dDevice->SetTransform(D3DTS_VIEW, &mat_identity); - bd->pd3dDevice->SetTransform(D3DTS_PROJECTION, &mat_projection); - } -} - -// Render function. -void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data) -{ - // Avoid rendering when minimized - if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f) - return; - - // Create and grow buffers if needed - ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData(); - if (!bd->pVB || bd->VertexBufferSize < draw_data->TotalVtxCount) - { - if (bd->pVB) { bd->pVB->Release(); bd->pVB = NULL; } - bd->VertexBufferSize = draw_data->TotalVtxCount + 5000; - if (bd->pd3dDevice->CreateVertexBuffer(bd->VertexBufferSize * sizeof(CUSTOMVERTEX), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &bd->pVB, NULL) < 0) - return; - } - if (!bd->pIB || bd->IndexBufferSize < draw_data->TotalIdxCount) - { - if (bd->pIB) { bd->pIB->Release(); bd->pIB = NULL; } - bd->IndexBufferSize = draw_data->TotalIdxCount + 10000; - if (bd->pd3dDevice->CreateIndexBuffer(bd->IndexBufferSize * sizeof(ImDrawIdx), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, sizeof(ImDrawIdx) == 2 ? D3DFMT_INDEX16 : D3DFMT_INDEX32, D3DPOOL_DEFAULT, &bd->pIB, NULL) < 0) - return; - } - - // Backup the DX9 state - IDirect3DStateBlock9* d3d9_state_block = NULL; - if (bd->pd3dDevice->CreateStateBlock(D3DSBT_ALL, &d3d9_state_block) < 0) - return; - if (d3d9_state_block->Capture() < 0) - { - d3d9_state_block->Release(); - return; - } - - // Backup the DX9 transform (DX9 documentation suggests that it is included in the StateBlock but it doesn't appear to) - D3DMATRIX last_world, last_view, last_projection; - bd->pd3dDevice->GetTransform(D3DTS_WORLD, &last_world); - bd->pd3dDevice->GetTransform(D3DTS_VIEW, &last_view); - bd->pd3dDevice->GetTransform(D3DTS_PROJECTION, &last_projection); - - // Allocate buffers - CUSTOMVERTEX* vtx_dst; - ImDrawIdx* idx_dst; - if (bd->pVB->Lock(0, (UINT)(draw_data->TotalVtxCount * sizeof(CUSTOMVERTEX)), (void**)&vtx_dst, D3DLOCK_DISCARD) < 0) - { - d3d9_state_block->Release(); - return; - } - if (bd->pIB->Lock(0, (UINT)(draw_data->TotalIdxCount * sizeof(ImDrawIdx)), (void**)&idx_dst, D3DLOCK_DISCARD) < 0) - { - bd->pVB->Unlock(); - d3d9_state_block->Release(); - return; - } - - // Copy and convert all vertices into a single contiguous buffer, convert colors to DX9 default format. - // FIXME-OPT: This is a minor waste of resource, the ideal is to use imconfig.h and - // 1) to avoid repacking colors: #define IMGUI_USE_BGRA_PACKED_COLOR - // 2) to avoid repacking vertices: #define IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT struct ImDrawVert { ImVec2 pos; float z; ImU32 col; ImVec2 uv; } - for (int n = 0; n < draw_data->CmdListsCount; n++) - { - const ImDrawList* cmd_list = draw_data->CmdLists[n]; - const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data; - for (int i = 0; i < cmd_list->VtxBuffer.Size; i++) - { - vtx_dst->pos[0] = vtx_src->pos.x; - vtx_dst->pos[1] = vtx_src->pos.y; - vtx_dst->pos[2] = 0.0f; - vtx_dst->col = IMGUI_COL_TO_DX9_ARGB(vtx_src->col); - vtx_dst->uv[0] = vtx_src->uv.x; - vtx_dst->uv[1] = vtx_src->uv.y; - vtx_dst++; - vtx_src++; - } - memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx)); - idx_dst += cmd_list->IdxBuffer.Size; - } - bd->pVB->Unlock(); - bd->pIB->Unlock(); - bd->pd3dDevice->SetStreamSource(0, bd->pVB, 0, sizeof(CUSTOMVERTEX)); - bd->pd3dDevice->SetIndices(bd->pIB); - bd->pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX); - - // Setup desired DX state - ImGui_ImplDX9_SetupRenderState(draw_data); - - // Render command lists - // (Because we merged all buffers into a single one, we maintain our own offset into them) - int global_vtx_offset = 0; - int global_idx_offset = 0; - ImVec2 clip_off = draw_data->DisplayPos; - for (int n = 0; n < draw_data->CmdListsCount; n++) - { - const ImDrawList* cmd_list = draw_data->CmdLists[n]; - for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) - { - const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; - if (pcmd->UserCallback != NULL) - { - // User callback, registered via ImDrawList::AddCallback() - // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.) - if (pcmd->UserCallback == ImDrawCallback_ResetRenderState) - ImGui_ImplDX9_SetupRenderState(draw_data); - else - pcmd->UserCallback(cmd_list, pcmd); - } - else - { - // Project scissor/clipping rectangles into framebuffer space - ImVec2 clip_min(pcmd->ClipRect.x - clip_off.x, pcmd->ClipRect.y - clip_off.y); - ImVec2 clip_max(pcmd->ClipRect.z - clip_off.x, pcmd->ClipRect.w - clip_off.y); - if (clip_max.x < clip_min.x || clip_max.y < clip_min.y) - continue; - - // Apply Scissor/clipping rectangle, Bind texture, Draw - const RECT r = { (LONG)clip_min.x, (LONG)clip_min.y, (LONG)clip_max.x, (LONG)clip_max.y }; - const LPDIRECT3DTEXTURE9 texture = (LPDIRECT3DTEXTURE9)pcmd->GetTexID(); - bd->pd3dDevice->SetTexture(0, texture); - bd->pd3dDevice->SetScissorRect(&r); - bd->pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, pcmd->VtxOffset + global_vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, pcmd->IdxOffset + global_idx_offset, pcmd->ElemCount / 3); - } - } - global_idx_offset += cmd_list->IdxBuffer.Size; - global_vtx_offset += cmd_list->VtxBuffer.Size; - } - - // Restore the DX9 transform - bd->pd3dDevice->SetTransform(D3DTS_WORLD, &last_world); - bd->pd3dDevice->SetTransform(D3DTS_VIEW, &last_view); - bd->pd3dDevice->SetTransform(D3DTS_PROJECTION, &last_projection); - - // Restore the DX9 state - d3d9_state_block->Apply(); - d3d9_state_block->Release(); -} - -bool ImGui_ImplDX9_Init(IDirect3DDevice9* device) -{ - ImGuiIO& io = ImGui::GetIO(); - IM_ASSERT(io.BackendRendererUserData == NULL && "Already initialized a renderer backend!"); - - // Setup backend capabilities flags - ImGui_ImplDX9_Data* bd = IM_NEW(ImGui_ImplDX9_Data)(); - io.BackendRendererUserData = (void*)bd; - io.BackendRendererName = "imgui_impl_dx9"; - io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. - - bd->pd3dDevice = device; - bd->pd3dDevice->AddRef(); - - return true; -} - -void ImGui_ImplDX9_Shutdown() -{ - ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData(); - IM_ASSERT(bd != NULL && "No renderer backend to shutdown, or already shutdown?"); - ImGuiIO& io = ImGui::GetIO(); - - ImGui_ImplDX9_InvalidateDeviceObjects(); - if (bd->pd3dDevice) { bd->pd3dDevice->Release(); } - io.BackendRendererName = NULL; - io.BackendRendererUserData = NULL; - IM_DELETE(bd); -} - -static bool ImGui_ImplDX9_CreateFontsTexture() -{ - // Build texture atlas - ImGuiIO& io = ImGui::GetIO(); - ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData(); - unsigned char* pixels; - int width, height, bytes_per_pixel; - io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height, &bytes_per_pixel); - - // Convert RGBA32 to BGRA32 (because RGBA32 is not well supported by DX9 devices) -#ifndef IMGUI_USE_BGRA_PACKED_COLOR - if (io.Fonts->TexPixelsUseColors) - { - ImU32* dst_start = (ImU32*)ImGui::MemAlloc((size_t)width * height * bytes_per_pixel); - for (ImU32* src = (ImU32*)pixels, *dst = dst_start, *dst_end = dst_start + (size_t)width * height; dst < dst_end; src++, dst++) - *dst = IMGUI_COL_TO_DX9_ARGB(*src); - pixels = (unsigned char*)dst_start; - } -#endif - - // Upload texture to graphics system - bd->FontTexture = NULL; - if (bd->pd3dDevice->CreateTexture(width, height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &bd->FontTexture, NULL) < 0) - return false; - D3DLOCKED_RECT tex_locked_rect; - if (bd->FontTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK) - return false; - for (int y = 0; y < height; y++) - memcpy((unsigned char*)tex_locked_rect.pBits + (size_t)tex_locked_rect.Pitch * y, pixels + (size_t)width * bytes_per_pixel * y, (size_t)width * bytes_per_pixel); - bd->FontTexture->UnlockRect(0); - - // Store our identifier - io.Fonts->SetTexID((ImTextureID)bd->FontTexture); - -#ifndef IMGUI_USE_BGRA_PACKED_COLOR - if (io.Fonts->TexPixelsUseColors) - ImGui::MemFree(pixels); -#endif - - return true; -} - -bool ImGui_ImplDX9_CreateDeviceObjects() -{ - ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData(); - if (!bd || !bd->pd3dDevice) - return false; - if (!ImGui_ImplDX9_CreateFontsTexture()) - return false; - return true; -} - -void ImGui_ImplDX9_InvalidateDeviceObjects() -{ - ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData(); - if (!bd || !bd->pd3dDevice) - return; - if (bd->pVB) { bd->pVB->Release(); bd->pVB = NULL; } - if (bd->pIB) { bd->pIB->Release(); bd->pIB = NULL; } - if (bd->FontTexture) { bd->FontTexture->Release(); bd->FontTexture = NULL; ImGui::GetIO().Fonts->SetTexID(NULL); } // We copied bd->pFontTextureView to io.Fonts->TexID so let's clear that as well. -} - -void ImGui_ImplDX9_NewFrame() -{ - ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData(); - IM_ASSERT(bd != NULL && "Did you call ImGui_ImplDX9_Init()?"); - - if (!bd->FontTexture) - ImGui_ImplDX9_CreateDeviceObjects(); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_dx9.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_dx9.h deleted file mode 100644 index 6dc805b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_dx9.h +++ /dev/null @@ -1,25 +0,0 @@ -// dear imgui: Renderer Backend for DirectX9 -// This needs to be used along with a Platform Backend (e.g. Win32) - -// Implemented features: -// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID! -// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -#pragma once -#include "imgui.h" // IMGUI_IMPL_API - -struct IDirect3DDevice9; - -IMGUI_IMPL_API bool ImGui_ImplDX9_Init(IDirect3DDevice9* device); -IMGUI_IMPL_API void ImGui_ImplDX9_Shutdown(); -IMGUI_IMPL_API void ImGui_ImplDX9_NewFrame(); -IMGUI_IMPL_API void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data); - -// Use if you want to reset your rendering device without losing Dear ImGui state. -IMGUI_IMPL_API bool ImGui_ImplDX9_CreateDeviceObjects(); -IMGUI_IMPL_API void ImGui_ImplDX9_InvalidateDeviceObjects(); diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_glfw.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_glfw.cpp deleted file mode 100644 index bf2a654..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_glfw.cpp +++ /dev/null @@ -1,454 +0,0 @@ -// dear imgui: Platform Backend for GLFW -// This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan, WebGPU..) -// (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.) -// (Requires: GLFW 3.1+) - -// Implemented features: -// [X] Platform: Clipboard support. -// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. -// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange' (note: the resizing cursors requires GLFW 3.4+). -// [X] Platform: Keyboard arrays indexed using GLFW_KEY_* codes, e.g. ImGui::IsKeyPressed(GLFW_KEY_SPACE). - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -// CHANGELOG -// (minor and older changes stripped away, please see git history for details) -// 2021-08-17: *BREAKING CHANGE*: Now using glfwSetWindowFocusCallback() to calling io.AddFocusEvent(). If you called ImGui_ImplGlfw_InitXXX() with install_callbacks = false, you MUST install glfwSetWindowFocusCallback() and forward it to the backend via ImGui_ImplGlfw_WindowFocusCallback(). -// 2021-07-29: *BREAKING CHANGE*: Now using glfwSetCursorEnterCallback(). MousePos is correctly reported when the host platform window is hovered but not focused. If you called ImGui_ImplGlfw_InitXXX() with install_callbacks = false, you MUST install glfwSetWindowFocusCallback() callback and forward it to the backend via ImGui_ImplGlfw_CursorEnterCallback(). -// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX). -// 2020-01-17: Inputs: Disable error callback while assigning mouse cursors because some X11 setup don't have them and it generates errors. -// 2019-12-05: Inputs: Added support for new mouse cursors added in GLFW 3.4+ (resizing cursors, not allowed cursor). -// 2019-10-18: Misc: Previously installed user callbacks are now restored on shutdown. -// 2019-07-21: Inputs: Added mapping for ImGuiKey_KeyPadEnter. -// 2019-05-11: Inputs: Don't filter value from character callback before calling AddInputCharacter(). -// 2019-03-12: Misc: Preserve DisplayFramebufferScale when main window is minimized. -// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window. -// 2018-11-07: Inputs: When installing our GLFW callbacks, we save user's previously installed ones - if any - and chain call them. -// 2018-08-01: Inputs: Workaround for Emscripten which doesn't seem to handle focus related calls. -// 2018-06-29: Inputs: Added support for the ImGuiMouseCursor_Hand cursor. -// 2018-06-08: Misc: Extracted imgui_impl_glfw.cpp/.h away from the old combined GLFW+OpenGL/Vulkan examples. -// 2018-03-20: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors flag + honor ImGuiConfigFlags_NoMouseCursorChange flag. -// 2018-02-20: Inputs: Added support for mouse cursors (ImGui::GetMouseCursor() value, passed to glfwSetCursor()). -// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves. -// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space. -// 2018-01-25: Inputs: Added gamepad support if ImGuiConfigFlags_NavEnableGamepad is set. -// 2018-01-25: Inputs: Honoring the io.WantSetMousePos by repositioning the mouse (when using navigation and ImGuiConfigFlags_NavMoveMouse is set). -// 2018-01-20: Inputs: Added Horizontal Mouse Wheel support. -// 2018-01-18: Inputs: Added mapping for ImGuiKey_Insert. -// 2017-08-25: Inputs: MousePos set to -FLT_MAX,-FLT_MAX when mouse is unavailable/missing (instead of -1,-1). -// 2016-10-15: Misc: Added a void* user_data parameter to Clipboard function handlers. - -#include "imgui.h" -#include "imgui_impl_glfw.h" - -// GLFW -#include -#ifdef _WIN32 -#undef APIENTRY -#define GLFW_EXPOSE_NATIVE_WIN32 -#include // for glfwGetWin32Window -#endif -#define GLFW_HAS_WINDOW_TOPMOST (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3200) // 3.2+ GLFW_FLOATING -#define GLFW_HAS_WINDOW_HOVERED (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+ GLFW_HOVERED -#define GLFW_HAS_WINDOW_ALPHA (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+ glfwSetWindowOpacity -#define GLFW_HAS_PER_MONITOR_DPI (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+ glfwGetMonitorContentScale -#define GLFW_HAS_VULKAN (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3200) // 3.2+ glfwCreateWindowSurface -#ifdef GLFW_RESIZE_NESW_CURSOR // Let's be nice to people who pulled GLFW between 2019-04-16 (3.4 define) and 2019-11-29 (cursors defines) // FIXME: Remove when GLFW 3.4 is released? -#define GLFW_HAS_NEW_CURSORS (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3400) // 3.4+ GLFW_RESIZE_ALL_CURSOR, GLFW_RESIZE_NESW_CURSOR, GLFW_RESIZE_NWSE_CURSOR, GLFW_NOT_ALLOWED_CURSOR -#else -#define GLFW_HAS_NEW_CURSORS (0) -#endif - -// GLFW data -enum GlfwClientApi -{ - GlfwClientApi_Unknown, - GlfwClientApi_OpenGL, - GlfwClientApi_Vulkan -}; - -struct ImGui_ImplGlfw_Data -{ - GLFWwindow* Window; - GlfwClientApi ClientApi; - double Time; - GLFWwindow* MouseWindow; - bool MouseJustPressed[ImGuiMouseButton_COUNT]; - GLFWcursor* MouseCursors[ImGuiMouseCursor_COUNT]; - bool InstalledCallbacks; - - // Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any. - GLFWwindowfocusfun PrevUserCallbackWindowFocus; - GLFWcursorenterfun PrevUserCallbackCursorEnter; - GLFWmousebuttonfun PrevUserCallbackMousebutton; - GLFWscrollfun PrevUserCallbackScroll; - GLFWkeyfun PrevUserCallbackKey; - GLFWcharfun PrevUserCallbackChar; - GLFWmonitorfun PrevUserCallbackMonitor; - - ImGui_ImplGlfw_Data() { memset(this, 0, sizeof(*this)); } -}; - -// Backend data stored in io.BackendPlatformUserData to allow support for multiple Dear ImGui contexts -// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts. -// FIXME: multi-context support is not well tested and probably dysfunctional in this backend. -// - Because glfwPollEvents() process all windows and some events may be called outside of it, you will need to register your own callbacks -// (passing install_callbacks=false in ImGui_ImplGlfw_InitXXX functions), set the current dear imgui context and then call our callbacks. -// - Otherwise we may need to store a GLFWWindow* -> ImGuiContext* map and handle this in the backend, adding a little bit of extra complexity to it. -// FIXME: some shared resources (mouse cursor shape, gamepad) are mishandled when using multi-context. -static ImGui_ImplGlfw_Data* ImGui_ImplGlfw_GetBackendData() -{ - return ImGui::GetCurrentContext() ? (ImGui_ImplGlfw_Data*)ImGui::GetIO().BackendPlatformUserData : NULL; -} - -// Functions -static const char* ImGui_ImplGlfw_GetClipboardText(void* user_data) -{ - return glfwGetClipboardString((GLFWwindow*)user_data); -} - -static void ImGui_ImplGlfw_SetClipboardText(void* user_data, const char* text) -{ - glfwSetClipboardString((GLFWwindow*)user_data, text); -} - -void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods) -{ - ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData(); - if (bd->PrevUserCallbackMousebutton != NULL && window == bd->Window) - bd->PrevUserCallbackMousebutton(window, button, action, mods); - - if (action == GLFW_PRESS && button >= 0 && button < IM_ARRAYSIZE(bd->MouseJustPressed)) - bd->MouseJustPressed[button] = true; -} - -void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset) -{ - ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData(); - if (bd->PrevUserCallbackScroll != NULL && window == bd->Window) - bd->PrevUserCallbackScroll(window, xoffset, yoffset); - - ImGuiIO& io = ImGui::GetIO(); - io.MouseWheelH += (float)xoffset; - io.MouseWheel += (float)yoffset; -} - -void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods) -{ - ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData(); - if (bd->PrevUserCallbackKey != NULL && window == bd->Window) - bd->PrevUserCallbackKey(window, key, scancode, action, mods); - - ImGuiIO& io = ImGui::GetIO(); - if (key >= 0 && key < IM_ARRAYSIZE(io.KeysDown)) - { - if (action == GLFW_PRESS) - io.KeysDown[key] = true; - if (action == GLFW_RELEASE) - io.KeysDown[key] = false; - } - - // Modifiers are not reliable across systems - io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL]; - io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT]; - io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT]; -#ifdef _WIN32 - io.KeySuper = false; -#else - io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER]; -#endif -} - -void ImGui_ImplGlfw_WindowFocusCallback(GLFWwindow* window, int focused) -{ - ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData(); - if (bd->PrevUserCallbackWindowFocus != NULL && window == bd->Window) - bd->PrevUserCallbackWindowFocus(window, focused); - - ImGuiIO& io = ImGui::GetIO(); - io.AddFocusEvent(focused != 0); -} - -void ImGui_ImplGlfw_CursorEnterCallback(GLFWwindow* window, int entered) -{ - ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData(); - if (bd->PrevUserCallbackCursorEnter != NULL && window == bd->Window) - bd->PrevUserCallbackCursorEnter(window, entered); - - if (entered) - bd->MouseWindow = window; - if (!entered && bd->MouseWindow == window) - bd->MouseWindow = NULL; -} - -void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c) -{ - ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData(); - if (bd->PrevUserCallbackChar != NULL && window == bd->Window) - bd->PrevUserCallbackChar(window, c); - - ImGuiIO& io = ImGui::GetIO(); - io.AddInputCharacter(c); -} - -void ImGui_ImplGlfw_MonitorCallback(GLFWmonitor*, int) -{ - // Unused in 'master' branch but 'docking' branch will use this, so we declare it ahead of it so if you have to install callbacks you can install this one too. -} - -static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, GlfwClientApi client_api) -{ - ImGuiIO& io = ImGui::GetIO(); - IM_ASSERT(io.BackendPlatformUserData == NULL && "Already initialized a platform backend!"); - - // Setup backend capabilities flags - ImGui_ImplGlfw_Data* bd = IM_NEW(ImGui_ImplGlfw_Data)(); - io.BackendPlatformUserData = (void*)bd; - io.BackendPlatformName = "imgui_impl_glfw"; - io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional) - io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used) - - bd->Window = window; - bd->Time = 0.0; - - // Keyboard mapping. Dear ImGui will use those indices to peek into the io.KeysDown[] array. - io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB; - io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT; - io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT; - io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP; - io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN; - io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP; - io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN; - io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME; - io.KeyMap[ImGuiKey_End] = GLFW_KEY_END; - io.KeyMap[ImGuiKey_Insert] = GLFW_KEY_INSERT; - io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE; - io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE; - io.KeyMap[ImGuiKey_Space] = GLFW_KEY_SPACE; - io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER; - io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE; - io.KeyMap[ImGuiKey_KeyPadEnter] = GLFW_KEY_KP_ENTER; - io.KeyMap[ImGuiKey_A] = GLFW_KEY_A; - io.KeyMap[ImGuiKey_C] = GLFW_KEY_C; - io.KeyMap[ImGuiKey_V] = GLFW_KEY_V; - io.KeyMap[ImGuiKey_X] = GLFW_KEY_X; - io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y; - io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z; - - io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText; - io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText; - io.ClipboardUserData = bd->Window; -#if defined(_WIN32) - io.ImeWindowHandle = (void*)glfwGetWin32Window(bd->Window); -#endif - - // Create mouse cursors - // (By design, on X11 cursors are user configurable and some cursors may be missing. When a cursor doesn't exist, - // GLFW will emit an error which will often be printed by the app, so we temporarily disable error reporting. - // Missing cursors will return NULL and our _UpdateMouseCursor() function will use the Arrow cursor instead.) - GLFWerrorfun prev_error_callback = glfwSetErrorCallback(NULL); - bd->MouseCursors[ImGuiMouseCursor_Arrow] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); - bd->MouseCursors[ImGuiMouseCursor_TextInput] = glfwCreateStandardCursor(GLFW_IBEAM_CURSOR); - bd->MouseCursors[ImGuiMouseCursor_ResizeNS] = glfwCreateStandardCursor(GLFW_VRESIZE_CURSOR); - bd->MouseCursors[ImGuiMouseCursor_ResizeEW] = glfwCreateStandardCursor(GLFW_HRESIZE_CURSOR); - bd->MouseCursors[ImGuiMouseCursor_Hand] = glfwCreateStandardCursor(GLFW_HAND_CURSOR); -#if GLFW_HAS_NEW_CURSORS - bd->MouseCursors[ImGuiMouseCursor_ResizeAll] = glfwCreateStandardCursor(GLFW_RESIZE_ALL_CURSOR); - bd->MouseCursors[ImGuiMouseCursor_ResizeNESW] = glfwCreateStandardCursor(GLFW_RESIZE_NESW_CURSOR); - bd->MouseCursors[ImGuiMouseCursor_ResizeNWSE] = glfwCreateStandardCursor(GLFW_RESIZE_NWSE_CURSOR); - bd->MouseCursors[ImGuiMouseCursor_NotAllowed] = glfwCreateStandardCursor(GLFW_NOT_ALLOWED_CURSOR); -#else - bd->MouseCursors[ImGuiMouseCursor_ResizeAll] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); - bd->MouseCursors[ImGuiMouseCursor_ResizeNESW] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); - bd->MouseCursors[ImGuiMouseCursor_ResizeNWSE] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); - bd->MouseCursors[ImGuiMouseCursor_NotAllowed] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR); -#endif - glfwSetErrorCallback(prev_error_callback); - - // Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any. - bd->PrevUserCallbackWindowFocus = NULL; - bd->PrevUserCallbackMousebutton = NULL; - bd->PrevUserCallbackScroll = NULL; - bd->PrevUserCallbackKey = NULL; - bd->PrevUserCallbackChar = NULL; - bd->PrevUserCallbackMonitor = NULL; - if (install_callbacks) - { - bd->InstalledCallbacks = true; - bd->PrevUserCallbackWindowFocus = glfwSetWindowFocusCallback(window, ImGui_ImplGlfw_WindowFocusCallback); - bd->PrevUserCallbackCursorEnter = glfwSetCursorEnterCallback(window, ImGui_ImplGlfw_CursorEnterCallback); - bd->PrevUserCallbackMousebutton = glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback); - bd->PrevUserCallbackScroll = glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback); - bd->PrevUserCallbackKey = glfwSetKeyCallback(window, ImGui_ImplGlfw_KeyCallback); - bd->PrevUserCallbackChar = glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback); - bd->PrevUserCallbackMonitor = glfwSetMonitorCallback(ImGui_ImplGlfw_MonitorCallback); - } - - bd->ClientApi = client_api; - return true; -} - -bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks) -{ - return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_OpenGL); -} - -bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks) -{ - return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_Vulkan); -} - -bool ImGui_ImplGlfw_InitForOther(GLFWwindow* window, bool install_callbacks) -{ - return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_Unknown); -} - -void ImGui_ImplGlfw_Shutdown() -{ - ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData(); - IM_ASSERT(bd != NULL && "No platform backend to shutdown, or already shutdown?"); - ImGuiIO& io = ImGui::GetIO(); - - if (bd->InstalledCallbacks) - { - glfwSetWindowFocusCallback(bd->Window, bd->PrevUserCallbackWindowFocus); - glfwSetCursorEnterCallback(bd->Window, bd->PrevUserCallbackCursorEnter); - glfwSetMouseButtonCallback(bd->Window, bd->PrevUserCallbackMousebutton); - glfwSetScrollCallback(bd->Window, bd->PrevUserCallbackScroll); - glfwSetKeyCallback(bd->Window, bd->PrevUserCallbackKey); - glfwSetCharCallback(bd->Window, bd->PrevUserCallbackChar); - glfwSetMonitorCallback(bd->PrevUserCallbackMonitor); - } - - for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++) - glfwDestroyCursor(bd->MouseCursors[cursor_n]); - - io.BackendPlatformName = NULL; - io.BackendPlatformUserData = NULL; - IM_DELETE(bd); -} - -static void ImGui_ImplGlfw_UpdateMousePosAndButtons() -{ - ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData(); - ImGuiIO& io = ImGui::GetIO(); - - const ImVec2 mouse_pos_prev = io.MousePos; - io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX); - - // Update mouse buttons - // (if a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame) - for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) - { - io.MouseDown[i] = bd->MouseJustPressed[i] || glfwGetMouseButton(bd->Window, i) != 0; - bd->MouseJustPressed[i] = false; - } - -#ifdef __EMSCRIPTEN__ - const bool focused = true; -#else - const bool focused = glfwGetWindowAttrib(bd->Window, GLFW_FOCUSED) != 0; -#endif - GLFWwindow* mouse_window = (bd->MouseWindow == bd->Window || focused) ? bd->Window : NULL; - - // Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user) - if (io.WantSetMousePos && focused) - glfwSetCursorPos(bd->Window, (double)mouse_pos_prev.x, (double)mouse_pos_prev.y); - - // Set Dear ImGui mouse position from OS position - if (mouse_window != NULL) - { - double mouse_x, mouse_y; - glfwGetCursorPos(mouse_window, &mouse_x, &mouse_y); - io.MousePos = ImVec2((float)mouse_x, (float)mouse_y); - } -} - -static void ImGui_ImplGlfw_UpdateMouseCursor() -{ - ImGuiIO& io = ImGui::GetIO(); - ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData(); - if ((io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) || glfwGetInputMode(bd->Window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED) - return; - - ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor(); - if (imgui_cursor == ImGuiMouseCursor_None || io.MouseDrawCursor) - { - // Hide OS mouse cursor if imgui is drawing it or if it wants no cursor - glfwSetInputMode(bd->Window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); - } - else - { - // Show OS mouse cursor - // FIXME-PLATFORM: Unfocused windows seems to fail changing the mouse cursor with GLFW 3.2, but 3.3 works here. - glfwSetCursor(bd->Window, bd->MouseCursors[imgui_cursor] ? bd->MouseCursors[imgui_cursor] : bd->MouseCursors[ImGuiMouseCursor_Arrow]); - glfwSetInputMode(bd->Window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); - } -} - -static void ImGui_ImplGlfw_UpdateGamepads() -{ - ImGuiIO& io = ImGui::GetIO(); - memset(io.NavInputs, 0, sizeof(io.NavInputs)); - if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0) - return; - - // Update gamepad inputs - #define MAP_BUTTON(NAV_NO, BUTTON_NO) { if (buttons_count > BUTTON_NO && buttons[BUTTON_NO] == GLFW_PRESS) io.NavInputs[NAV_NO] = 1.0f; } - #define MAP_ANALOG(NAV_NO, AXIS_NO, V0, V1) { float v = (axes_count > AXIS_NO) ? axes[AXIS_NO] : V0; v = (v - V0) / (V1 - V0); if (v > 1.0f) v = 1.0f; if (io.NavInputs[NAV_NO] < v) io.NavInputs[NAV_NO] = v; } - int axes_count = 0, buttons_count = 0; - const float* axes = glfwGetJoystickAxes(GLFW_JOYSTICK_1, &axes_count); - const unsigned char* buttons = glfwGetJoystickButtons(GLFW_JOYSTICK_1, &buttons_count); - MAP_BUTTON(ImGuiNavInput_Activate, 0); // Cross / A - MAP_BUTTON(ImGuiNavInput_Cancel, 1); // Circle / B - MAP_BUTTON(ImGuiNavInput_Menu, 2); // Square / X - MAP_BUTTON(ImGuiNavInput_Input, 3); // Triangle / Y - MAP_BUTTON(ImGuiNavInput_DpadLeft, 13); // D-Pad Left - MAP_BUTTON(ImGuiNavInput_DpadRight, 11); // D-Pad Right - MAP_BUTTON(ImGuiNavInput_DpadUp, 10); // D-Pad Up - MAP_BUTTON(ImGuiNavInput_DpadDown, 12); // D-Pad Down - MAP_BUTTON(ImGuiNavInput_FocusPrev, 4); // L1 / LB - MAP_BUTTON(ImGuiNavInput_FocusNext, 5); // R1 / RB - MAP_BUTTON(ImGuiNavInput_TweakSlow, 4); // L1 / LB - MAP_BUTTON(ImGuiNavInput_TweakFast, 5); // R1 / RB - MAP_ANALOG(ImGuiNavInput_LStickLeft, 0, -0.3f, -0.9f); - MAP_ANALOG(ImGuiNavInput_LStickRight,0, +0.3f, +0.9f); - MAP_ANALOG(ImGuiNavInput_LStickUp, 1, +0.3f, +0.9f); - MAP_ANALOG(ImGuiNavInput_LStickDown, 1, -0.3f, -0.9f); - #undef MAP_BUTTON - #undef MAP_ANALOG - if (axes_count > 0 && buttons_count > 0) - io.BackendFlags |= ImGuiBackendFlags_HasGamepad; - else - io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad; -} - -void ImGui_ImplGlfw_NewFrame() -{ - ImGuiIO& io = ImGui::GetIO(); - ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData(); - IM_ASSERT(bd != NULL && "Did you call ImGui_ImplGlfw_InitForXXX()?"); - - // Setup display size (every frame to accommodate for window resizing) - int w, h; - int display_w, display_h; - glfwGetWindowSize(bd->Window, &w, &h); - glfwGetFramebufferSize(bd->Window, &display_w, &display_h); - io.DisplaySize = ImVec2((float)w, (float)h); - if (w > 0 && h > 0) - io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h); - - // Setup time step - double current_time = glfwGetTime(); - io.DeltaTime = bd->Time > 0.0 ? (float)(current_time - bd->Time) : (float)(1.0f / 60.0f); - bd->Time = current_time; - - ImGui_ImplGlfw_UpdateMousePosAndButtons(); - ImGui_ImplGlfw_UpdateMouseCursor(); - - // Update game controllers (if enabled and available) - ImGui_ImplGlfw_UpdateGamepads(); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_glfw.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_glfw.h deleted file mode 100644 index 5e1fb06..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_glfw.h +++ /dev/null @@ -1,41 +0,0 @@ -// dear imgui: Platform Backend for GLFW -// This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan, WebGPU..) -// (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.) - -// Implemented features: -// [X] Platform: Clipboard support. -// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. -// [x] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: 3 cursors types are missing from GLFW. -// [X] Platform: Keyboard arrays indexed using GLFW_KEY_* codes, e.g. ImGui::IsKeyPressed(GLFW_KEY_SPACE). - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -// About GLSL version: -// The 'glsl_version' initialization parameter defaults to "#version 150" if NULL. -// Only override if your GL version doesn't handle this GLSL version. Keep NULL if unsure! - -#pragma once -#include "imgui.h" // IMGUI_IMPL_API - -struct GLFWwindow; -struct GLFWmonitor; - -IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks); -IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks); -IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOther(GLFWwindow* window, bool install_callbacks); -IMGUI_IMPL_API void ImGui_ImplGlfw_Shutdown(); -IMGUI_IMPL_API void ImGui_ImplGlfw_NewFrame(); - -// GLFW callbacks -// - When calling Init with 'install_callbacks=true': GLFW callbacks will be installed for you. They will call user's previously installed callbacks, if any. -// - When calling Init with 'install_callbacks=false': GLFW callbacks won't be installed. You will need to call those function yourself from your own GLFW callbacks. -IMGUI_IMPL_API void ImGui_ImplGlfw_WindowFocusCallback(GLFWwindow* window, int focused); -IMGUI_IMPL_API void ImGui_ImplGlfw_CursorEnterCallback(GLFWwindow* window, int entered); -IMGUI_IMPL_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods); -IMGUI_IMPL_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset); -IMGUI_IMPL_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods); -IMGUI_IMPL_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c); -IMGUI_IMPL_API void ImGui_ImplGlfw_MonitorCallback(GLFWmonitor* monitor, int event); diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_glut.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_glut.cpp deleted file mode 100644 index 85bea77..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_glut.cpp +++ /dev/null @@ -1,217 +0,0 @@ -// dear imgui: Platform Backend for GLUT/FreeGLUT -// This needs to be used along with a Renderer (e.g. OpenGL2) - -// !!! GLUT/FreeGLUT IS OBSOLETE PREHISTORIC SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!! -// !!! If someone or something is teaching you GLUT today, you are being abused. Please show some resistance. !!! -// !!! Nowadays, prefer using GLFW or SDL instead! - -// Issues: -// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I -// [ ] Platform: Missing mouse cursor shape/visibility support. -// [ ] Platform: Missing clipboard support (not supported by Glut). -// [ ] Platform: Missing gamepad support. - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -// CHANGELOG -// (minor and older changes stripped away, please see git history for details) -// 2019-04-03: Misc: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h. -// 2019-03-25: Misc: Made io.DeltaTime always above zero. -// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window. -// 2018-03-22: Added GLUT Platform binding. - -#include "imgui.h" -#include "imgui_impl_glut.h" -#ifdef __APPLE__ -#include -#else -#include -#endif - -#ifdef _MSC_VER -#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff) -#endif - -static int g_Time = 0; // Current time, in milliseconds - -bool ImGui_ImplGLUT_Init() -{ - ImGuiIO& io = ImGui::GetIO(); - -#ifdef FREEGLUT - io.BackendPlatformName = "imgui_impl_glut (freeglut)"; -#else - io.BackendPlatformName = "imgui_impl_glut"; -#endif - - g_Time = 0; - - // Glut has 1 function for characters and one for "special keys". We map the characters in the 0..255 range and the keys above. - io.KeyMap[ImGuiKey_Tab] = '\t'; // == 9 == CTRL+I - io.KeyMap[ImGuiKey_LeftArrow] = 256 + GLUT_KEY_LEFT; - io.KeyMap[ImGuiKey_RightArrow] = 256 + GLUT_KEY_RIGHT; - io.KeyMap[ImGuiKey_UpArrow] = 256 + GLUT_KEY_UP; - io.KeyMap[ImGuiKey_DownArrow] = 256 + GLUT_KEY_DOWN; - io.KeyMap[ImGuiKey_PageUp] = 256 + GLUT_KEY_PAGE_UP; - io.KeyMap[ImGuiKey_PageDown] = 256 + GLUT_KEY_PAGE_DOWN; - io.KeyMap[ImGuiKey_Home] = 256 + GLUT_KEY_HOME; - io.KeyMap[ImGuiKey_End] = 256 + GLUT_KEY_END; - io.KeyMap[ImGuiKey_Insert] = 256 + GLUT_KEY_INSERT; - io.KeyMap[ImGuiKey_Delete] = 127; - io.KeyMap[ImGuiKey_Backspace] = 8; // == CTRL+H - io.KeyMap[ImGuiKey_Space] = ' '; - io.KeyMap[ImGuiKey_Enter] = 13; // == CTRL+M - io.KeyMap[ImGuiKey_Escape] = 27; - io.KeyMap[ImGuiKey_KeyPadEnter] = 13; // == CTRL+M - io.KeyMap[ImGuiKey_A] = 'A'; - io.KeyMap[ImGuiKey_C] = 'C'; - io.KeyMap[ImGuiKey_V] = 'V'; - io.KeyMap[ImGuiKey_X] = 'X'; - io.KeyMap[ImGuiKey_Y] = 'Y'; - io.KeyMap[ImGuiKey_Z] = 'Z'; - - return true; -} - -void ImGui_ImplGLUT_InstallFuncs() -{ - glutReshapeFunc(ImGui_ImplGLUT_ReshapeFunc); - glutMotionFunc(ImGui_ImplGLUT_MotionFunc); - glutPassiveMotionFunc(ImGui_ImplGLUT_MotionFunc); - glutMouseFunc(ImGui_ImplGLUT_MouseFunc); -#ifdef __FREEGLUT_EXT_H__ - glutMouseWheelFunc(ImGui_ImplGLUT_MouseWheelFunc); -#endif - glutKeyboardFunc(ImGui_ImplGLUT_KeyboardFunc); - glutKeyboardUpFunc(ImGui_ImplGLUT_KeyboardUpFunc); - glutSpecialFunc(ImGui_ImplGLUT_SpecialFunc); - glutSpecialUpFunc(ImGui_ImplGLUT_SpecialUpFunc); -} - -void ImGui_ImplGLUT_Shutdown() -{ -} - -void ImGui_ImplGLUT_NewFrame() -{ - // Setup time step - ImGuiIO& io = ImGui::GetIO(); - int current_time = glutGet(GLUT_ELAPSED_TIME); - int delta_time_ms = (current_time - g_Time); - if (delta_time_ms <= 0) - delta_time_ms = 1; - io.DeltaTime = delta_time_ms / 1000.0f; - g_Time = current_time; - - // Start the frame - ImGui::NewFrame(); -} - -static void ImGui_ImplGLUT_UpdateKeyboardMods() -{ - ImGuiIO& io = ImGui::GetIO(); - int mods = glutGetModifiers(); - io.KeyCtrl = (mods & GLUT_ACTIVE_CTRL) != 0; - io.KeyShift = (mods & GLUT_ACTIVE_SHIFT) != 0; - io.KeyAlt = (mods & GLUT_ACTIVE_ALT) != 0; -} - -void ImGui_ImplGLUT_KeyboardFunc(unsigned char c, int x, int y) -{ - // Send character to imgui - //printf("char_down_func %d '%c'\n", c, c); - ImGuiIO& io = ImGui::GetIO(); - if (c >= 32) - io.AddInputCharacter((unsigned int)c); - - // Store letters in KeysDown[] array as both uppercase and lowercase + Handle GLUT translating CTRL+A..CTRL+Z as 1..26. - // This is a hacky mess but GLUT is unable to distinguish e.g. a TAB key from CTRL+I so this is probably the best we can do here. - if (c >= 1 && c <= 26) - io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = true; - else if (c >= 'a' && c <= 'z') - io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = true; - else if (c >= 'A' && c <= 'Z') - io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = true; - else - io.KeysDown[c] = true; - ImGui_ImplGLUT_UpdateKeyboardMods(); - (void)x; (void)y; // Unused -} - -void ImGui_ImplGLUT_KeyboardUpFunc(unsigned char c, int x, int y) -{ - //printf("char_up_func %d '%c'\n", c, c); - ImGuiIO& io = ImGui::GetIO(); - if (c >= 1 && c <= 26) - io.KeysDown[c] = io.KeysDown[c - 1 + 'a'] = io.KeysDown[c - 1 + 'A'] = false; - else if (c >= 'a' && c <= 'z') - io.KeysDown[c] = io.KeysDown[c - 'a' + 'A'] = false; - else if (c >= 'A' && c <= 'Z') - io.KeysDown[c] = io.KeysDown[c - 'A' + 'a'] = false; - else - io.KeysDown[c] = false; - ImGui_ImplGLUT_UpdateKeyboardMods(); - (void)x; (void)y; // Unused -} - -void ImGui_ImplGLUT_SpecialFunc(int key, int x, int y) -{ - //printf("key_down_func %d\n", key); - ImGuiIO& io = ImGui::GetIO(); - if (key + 256 < IM_ARRAYSIZE(io.KeysDown)) - io.KeysDown[key + 256] = true; - ImGui_ImplGLUT_UpdateKeyboardMods(); - (void)x; (void)y; // Unused -} - -void ImGui_ImplGLUT_SpecialUpFunc(int key, int x, int y) -{ - //printf("key_up_func %d\n", key); - ImGuiIO& io = ImGui::GetIO(); - if (key + 256 < IM_ARRAYSIZE(io.KeysDown)) - io.KeysDown[key + 256] = false; - ImGui_ImplGLUT_UpdateKeyboardMods(); - (void)x; (void)y; // Unused -} - -void ImGui_ImplGLUT_MouseFunc(int glut_button, int state, int x, int y) -{ - ImGuiIO& io = ImGui::GetIO(); - io.MousePos = ImVec2((float)x, (float)y); - int button = -1; - if (glut_button == GLUT_LEFT_BUTTON) button = 0; - if (glut_button == GLUT_RIGHT_BUTTON) button = 1; - if (glut_button == GLUT_MIDDLE_BUTTON) button = 2; - if (button != -1 && state == GLUT_DOWN) - io.MouseDown[button] = true; - if (button != -1 && state == GLUT_UP) - io.MouseDown[button] = false; -} - -#ifdef __FREEGLUT_EXT_H__ -void ImGui_ImplGLUT_MouseWheelFunc(int button, int dir, int x, int y) -{ - ImGuiIO& io = ImGui::GetIO(); - io.MousePos = ImVec2((float)x, (float)y); - if (dir > 0) - io.MouseWheel += 1.0; - else if (dir < 0) - io.MouseWheel -= 1.0; - (void)button; // Unused -} -#endif - -void ImGui_ImplGLUT_ReshapeFunc(int w, int h) -{ - ImGuiIO& io = ImGui::GetIO(); - io.DisplaySize = ImVec2((float)w, (float)h); -} - -void ImGui_ImplGLUT_MotionFunc(int x, int y) -{ - ImGuiIO& io = ImGui::GetIO(); - io.MousePos = ImVec2((float)x, (float)y); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_glut.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_glut.h deleted file mode 100644 index 96c779f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_glut.h +++ /dev/null @@ -1,37 +0,0 @@ -// dear imgui: Platform Backend for GLUT/FreeGLUT -// This needs to be used along with a Renderer (e.g. OpenGL2) - -// !!! GLUT/FreeGLUT IS OBSOLETE PREHISTORIC SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!! -// !!! If someone or something is teaching you GLUT today, you are being abused. Please show some resistance. !!! -// !!! Nowadays, prefer using GLFW or SDL instead! - -// Issues: -// [ ] Platform: GLUT is unable to distinguish e.g. Backspace from CTRL+H or TAB from CTRL+I -// [ ] Platform: Missing mouse cursor shape/visibility support. -// [ ] Platform: Missing clipboard support (not supported by Glut). -// [ ] Platform: Missing gamepad support. - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -#pragma once -#include "imgui.h" // IMGUI_IMPL_API - -IMGUI_IMPL_API bool ImGui_ImplGLUT_Init(); -IMGUI_IMPL_API void ImGui_ImplGLUT_InstallFuncs(); -IMGUI_IMPL_API void ImGui_ImplGLUT_Shutdown(); -IMGUI_IMPL_API void ImGui_ImplGLUT_NewFrame(); - -// You can call ImGui_ImplGLUT_InstallFuncs() to get all those functions installed automatically, -// or call them yourself from your own GLUT handlers. We are using the same weird names as GLUT for consistency.. -//---------------------------------------- GLUT name --------------------------------------------- Decent Name --------- -IMGUI_IMPL_API void ImGui_ImplGLUT_ReshapeFunc(int w, int h); // ~ ResizeFunc -IMGUI_IMPL_API void ImGui_ImplGLUT_MotionFunc(int x, int y); // ~ MouseMoveFunc -IMGUI_IMPL_API void ImGui_ImplGLUT_MouseFunc(int button, int state, int x, int y); // ~ MouseButtonFunc -IMGUI_IMPL_API void ImGui_ImplGLUT_MouseWheelFunc(int button, int dir, int x, int y); // ~ MouseWheelFunc -IMGUI_IMPL_API void ImGui_ImplGLUT_KeyboardFunc(unsigned char c, int x, int y); // ~ CharPressedFunc -IMGUI_IMPL_API void ImGui_ImplGLUT_KeyboardUpFunc(unsigned char c, int x, int y); // ~ CharReleasedFunc -IMGUI_IMPL_API void ImGui_ImplGLUT_SpecialFunc(int key, int x, int y); // ~ KeyPressedFunc -IMGUI_IMPL_API void ImGui_ImplGLUT_SpecialUpFunc(int key, int x, int y); // ~ KeyReleasedFunc diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_marmalade.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_marmalade.cpp deleted file mode 100644 index aa6b320..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_marmalade.cpp +++ /dev/null @@ -1,318 +0,0 @@ -// dear imgui: Renderer + Platform Backend for Marmalade + IwGx -// Marmalade code: Copyright (C) 2015 by Giovanni Zito (this file is part of Dear ImGui) - -// Implemented features: -// [X] Renderer: User texture binding. Use 'CIwTexture*' as ImTextureID. Read the FAQ about ImTextureID! -// Missing features: -// [ ] Renderer: Clipping rectangles are not honored. - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -// CHANGELOG -// (minor and older changes stripped away, please see git history for details) -// 2021-05-19: Renderer: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement) -// 2019-07-21: Inputs: Added mapping for ImGuiKey_KeyPadEnter. -// 2019-05-11: Inputs: Don't filter value from character callback before calling AddInputCharacter(). -// 2018-11-30: Misc: Setting up io.BackendPlatformName/io.BackendRendererName so they can be displayed in the About Window. -// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_Marmalade_RenderDrawData() in the .h file so you can call it yourself. -// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves. -// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space. - -#include "imgui.h" -#include "imgui_impl_marmalade.h" - -#include -#include -#include -#include -#include - -// Data -static double g_Time = 0.0f; -static bool g_MousePressed[3] = { false, false, false }; -static CIwTexture* g_FontTexture = NULL; -static char* g_ClipboardText = NULL; -static bool g_osdKeyboardEnabled = false; - -// use this setting to scale the interface - e.g. on device you could use 2 or 3 scale factor -static ImVec2 g_RenderScale = ImVec2(1.0f, 1.0f); - -// Render function. -void ImGui_Marmalade_RenderDrawData(ImDrawData* draw_data) -{ - // Avoid rendering when minimized - if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f) - return; - - // Render command lists - for (int n = 0; n < draw_data->CmdListsCount; n++) - { - const ImDrawList* cmd_list = draw_data->CmdLists[n]; - const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data; - const int nVert = cmd_list->VtxBuffer.Size; - CIwFVec2* pVertStream = IW_GX_ALLOC(CIwFVec2, nVert); - CIwFVec2* pUVStream = IW_GX_ALLOC(CIwFVec2, nVert); - CIwColour* pColStream = IW_GX_ALLOC(CIwColour, nVert); - - for (int i = 0; i < nVert; i++) - { - // FIXME-OPT: optimize multiplication on GPU using vertex shader/projection matrix. - pVertStream[i].x = cmd_list->VtxBuffer[i].pos.x * g_RenderScale.x; - pVertStream[i].y = cmd_list->VtxBuffer[i].pos.y * g_RenderScale.y; - pUVStream[i].x = cmd_list->VtxBuffer[i].uv.x; - pUVStream[i].y = cmd_list->VtxBuffer[i].uv.y; - pColStream[i] = cmd_list->VtxBuffer[i].col; - } - - IwGxSetVertStreamScreenSpace(pVertStream, nVert); - IwGxSetUVStream(pUVStream); - IwGxSetColStream(pColStream, nVert); - IwGxSetNormStream(0); - - for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) - { - const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; - if (pcmd->UserCallback) - { - pcmd->UserCallback(cmd_list, pcmd); - } - else - { - // FIXME: Not honoring ClipRect fields. - CIwMaterial* pCurrentMaterial = IW_GX_ALLOC_MATERIAL(); - pCurrentMaterial->SetShadeMode(CIwMaterial::SHADE_FLAT); - pCurrentMaterial->SetCullMode(CIwMaterial::CULL_NONE); - pCurrentMaterial->SetFiltering(false); - pCurrentMaterial->SetAlphaMode(CIwMaterial::ALPHA_BLEND); - pCurrentMaterial->SetDepthWriteMode(CIwMaterial::DEPTH_WRITE_NORMAL); - pCurrentMaterial->SetAlphaTestMode(CIwMaterial::ALPHATEST_DISABLED); - pCurrentMaterial->SetTexture((CIwTexture*)pcmd->GetTexID()); - IwGxSetMaterial(pCurrentMaterial); - IwGxDrawPrims(IW_GX_TRI_LIST, (uint16*)idx_buffer, pcmd->ElemCount); - } - idx_buffer += pcmd->ElemCount; - } - IwGxFlush(); - } - - // TODO: restore modified state (i.e. mvp matrix) -} - -static const char* ImGui_Marmalade_GetClipboardText(void* /*user_data*/) -{ - if (!s3eClipboardAvailable()) - return NULL; - - if (int size = s3eClipboardGetText(NULL, 0)) - { - if (g_ClipboardText) - delete[] g_ClipboardText; - g_ClipboardText = new char[size]; - g_ClipboardText[0] = '\0'; - s3eClipboardGetText(g_ClipboardText, size); - } - - return g_ClipboardText; -} - -static void ImGui_Marmalade_SetClipboardText(void* /*user_data*/, const char* text) -{ - if (s3eClipboardAvailable()) - s3eClipboardSetText(text); -} - -int32 ImGui_Marmalade_PointerButtonEventCallback(void* system_data, void* user_data) -{ - // pEvent->m_Button is of type s3ePointerButton and indicates which mouse - // button was pressed. For touchscreen this should always have the value - // S3E_POINTER_BUTTON_SELECT - s3ePointerEvent* pEvent = (s3ePointerEvent*)system_data; - - if (pEvent->m_Pressed == 1) - { - if (pEvent->m_Button == S3E_POINTER_BUTTON_LEFTMOUSE) - g_MousePressed[0] = true; - if (pEvent->m_Button == S3E_POINTER_BUTTON_RIGHTMOUSE) - g_MousePressed[1] = true; - if (pEvent->m_Button == S3E_POINTER_BUTTON_MIDDLEMOUSE) - g_MousePressed[2] = true; - if (pEvent->m_Button == S3E_POINTER_BUTTON_MOUSEWHEELUP) - io.MouseWheel += pEvent->m_y; - if (pEvent->m_Button == S3E_POINTER_BUTTON_MOUSEWHEELDOWN) - io.MouseWheel += pEvent->m_y; - } - - return 0; -} - -int32 ImGui_Marmalade_KeyCallback(void* system_data, void* user_data) -{ - ImGuiIO& io = ImGui::GetIO(); - s3eKeyboardEvent* e = (s3eKeyboardEvent*)system_data; - if (e->m_Pressed == 1) - io.KeysDown[e->m_Key] = true; - if (e->m_Pressed == 0) - io.KeysDown[e->m_Key] = false; - - io.KeyCtrl = s3eKeyboardGetState(s3eKeyLeftControl) == S3E_KEY_STATE_DOWN || s3eKeyboardGetState(s3eKeyRightControl) == S3E_KEY_STATE_DOWN; - io.KeyShift = s3eKeyboardGetState(s3eKeyLeftShift) == S3E_KEY_STATE_DOWN || s3eKeyboardGetState(s3eKeyRightShift) == S3E_KEY_STATE_DOWN; - io.KeyAlt = s3eKeyboardGetState(s3eKeyLeftAlt) == S3E_KEY_STATE_DOWN || s3eKeyboardGetState(s3eKeyRightAlt) == S3E_KEY_STATE_DOWN; - io.KeySuper = s3eKeyboardGetState(s3eKeyLeftWindows) == S3E_KEY_STATE_DOWN || s3eKeyboardGetState(s3eKeyRightWindows) == S3E_KEY_STATE_DOWN; - - return 0; -} - -int32 ImGui_Marmalade_CharCallback(void* system_data, void* user_data) -{ - ImGuiIO& io = ImGui::GetIO(); - s3eKeyboardCharEvent* e = (s3eKeyboardCharEvent*)system_data; - io.AddInputCharacter((unsigned int)e->m_Char); - - return 0; -} - -bool ImGui_Marmalade_CreateDeviceObjects() -{ - // Build texture atlas - ImGuiIO& io = ImGui::GetIO(); - unsigned char* pixels; - int width, height; - io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); - - // Upload texture to graphics system - g_FontTexture = new CIwTexture(); - g_FontTexture->SetModifiable(true); - CIwImage& image = g_FontTexture->GetImage(); - image.SetFormat(CIwImage::ARGB_8888); - image.SetWidth(width); - image.SetHeight(height); - image.SetBuffers(); // allocates and own buffers - image.ReadTexels(pixels); - g_FontTexture->SetMipMapping(false); - g_FontTexture->SetFiltering(false); - g_FontTexture->Upload(); - - // Store our identifier - io.Fonts->SetTexID((ImTextureID)g_FontTexture); - - return true; -} - -void ImGui_Marmalade_InvalidateDeviceObjects() -{ - if (g_ClipboardText) - { - delete[] g_ClipboardText; - g_ClipboardText = NULL; - } - - if (g_FontTexture) - { - ImGui::GetIO().Fonts->SetTexID(0); - delete g_FontTexture; - g_FontTexture = NULL; - } -} - -bool ImGui_Marmalade_Init(bool install_callbacks) -{ - ImGuiIO& io = ImGui::GetIO(); - io.BackendPlatformName = io.BackendRendererName = "imgui_impl_marmalade"; - - // Keyboard mapping. Dear ImGui will use those indices to peek into the io.KeysDown[] array. - io.KeyMap[ImGuiKey_Tab] = s3eKeyTab - io.KeyMap[ImGuiKey_LeftArrow] = s3eKeyLeft; - io.KeyMap[ImGuiKey_RightArrow] = s3eKeyRight; - io.KeyMap[ImGuiKey_UpArrow] = s3eKeyUp; - io.KeyMap[ImGuiKey_DownArrow] = s3eKeyDown; - io.KeyMap[ImGuiKey_PageUp] = s3eKeyPageUp; - io.KeyMap[ImGuiKey_PageDown] = s3eKeyPageDown; - io.KeyMap[ImGuiKey_Home] = s3eKeyHome; - io.KeyMap[ImGuiKey_End] = s3eKeyEnd; - io.KeyMap[ImGuiKey_Insert] = s3eKeyInsert; - io.KeyMap[ImGuiKey_Delete] = s3eKeyDelete; - io.KeyMap[ImGuiKey_Backspace] = s3eKeyBackspace; - io.KeyMap[ImGuiKey_Space] = s3eKeySpace; - io.KeyMap[ImGuiKey_Enter] = s3eKeyEnter; - io.KeyMap[ImGuiKey_Escape] = s3eKeyEsc; - io.KeyMap[ImGuiKey_KeyPadEnter] = s3eKeyNumPadEnter; - io.KeyMap[ImGuiKey_A] = s3eKeyA; - io.KeyMap[ImGuiKey_C] = s3eKeyC; - io.KeyMap[ImGuiKey_V] = s3eKeyV; - io.KeyMap[ImGuiKey_X] = s3eKeyX; - io.KeyMap[ImGuiKey_Y] = s3eKeyY; - io.KeyMap[ImGuiKey_Z] = s3eKeyZ; - - io.SetClipboardTextFn = ImGui_Marmalade_SetClipboardText; - io.GetClipboardTextFn = ImGui_Marmalade_GetClipboardText; - - if (install_callbacks) - { - s3ePointerRegister(S3E_POINTER_BUTTON_EVENT, ImGui_Marmalade_PointerButtonEventCallback, 0); - s3eKeyboardRegister(S3E_KEYBOARD_KEY_EVENT, ImGui_Marmalade_KeyCallback, 0); - s3eKeyboardRegister(S3E_KEYBOARD_CHAR_EVENT, ImGui_Marmalade_CharCallback, 0); - } - - return true; -} - -void ImGui_Marmalade_Shutdown() -{ - ImGui_Marmalade_InvalidateDeviceObjects(); -} - -void ImGui_Marmalade_NewFrame() -{ - if (!g_FontTexture) - ImGui_Marmalade_CreateDeviceObjects(); - - ImGuiIO& io = ImGui::GetIO(); - - // Setup display size (every frame to accommodate for window resizing) - int w = IwGxGetScreenWidth(), h = IwGxGetScreenHeight(); - io.DisplaySize = ImVec2((float)w, (float)h); - // For retina display or other situations where window coordinates are different from framebuffer coordinates. User storage only, presently not used by ImGui. - io.DisplayFramebufferScale = g_scale; - - // Setup time step - double current_time = s3eTimerGetUST() / 1000.0f; - io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f / 60.0f); - g_Time = current_time; - - double mouse_x, mouse_y; - mouse_x = s3ePointerGetX(); - mouse_y = s3ePointerGetY(); - io.MousePos = ImVec2((float)mouse_x / g_scale.x, (float)mouse_y / g_scale.y); // Mouse position (set to -FLT_MAX,-FLT_MAX if no mouse / on another screen, etc.) - - for (int i = 0; i < 3; i++) - { - io.MouseDown[i] = g_MousePressed[i] || s3ePointerGetState((s3ePointerButton)i) != S3E_POINTER_STATE_UP; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame. - g_MousePressed[i] = false; - } - - // TODO: Hide OS mouse cursor if ImGui is drawing it - // s3ePointerSetInt(S3E_POINTER_HIDE_CURSOR,(io.MouseDrawCursor ? 0 : 1)); - - // Show/hide OSD keyboard - if (io.WantTextInput) - { - // Some text input widget is active? - if (!g_osdKeyboardEnabled) - { - g_osdKeyboardEnabled = true; - s3eKeyboardSetInt(S3E_KEYBOARD_GET_CHAR, 1); // show OSD keyboard - } - } - else - { - // No text input widget is active - if (g_osdKeyboardEnabled) - { - g_osdKeyboardEnabled = false; - s3eKeyboardSetInt(S3E_KEYBOARD_GET_CHAR, 0); // hide OSD keyboard - } - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_marmalade.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_marmalade.h deleted file mode 100644 index 87aaa47..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_marmalade.h +++ /dev/null @@ -1,28 +0,0 @@ -// dear imgui: Renderer + Platform Backend for Marmalade + IwGx -// Marmalade code: Copyright (C) 2015 by Giovanni Zito (this file is part of Dear ImGui) - -// Implemented features: -// [X] Renderer: User texture binding. Use 'CIwTexture*' as ImTextureID. Read the FAQ about ImTextureID! - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -#pragma once -#include "imgui.h" // IMGUI_IMPL_API - -IMGUI_IMPL_API bool ImGui_Marmalade_Init(bool install_callbacks); -IMGUI_IMPL_API void ImGui_Marmalade_Shutdown(); -IMGUI_IMPL_API void ImGui_Marmalade_NewFrame(); -IMGUI_IMPL_API void ImGui_Marmalade_RenderDrawData(ImDrawData* draw_data); - -// Use if you want to reset your rendering device without losing Dear ImGui state. -IMGUI_IMPL_API void ImGui_Marmalade_InvalidateDeviceObjects(); -IMGUI_IMPL_API bool ImGui_Marmalade_CreateDeviceObjects(); - -// Callbacks (installed by default if you enable 'install_callbacks' during initialization) -// You can also handle inputs yourself and use those as a reference. -IMGUI_IMPL_API int32 ImGui_Marmalade_PointerButtonEventCallback(void* system_data, void* user_data); -IMGUI_IMPL_API int32 ImGui_Marmalade_KeyCallback(void* system_data, void* user_data); -IMGUI_IMPL_API int32 ImGui_Marmalade_CharCallback(void* system_data, void* user_data); diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_metal.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_metal.h deleted file mode 100644 index c0c6018..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_metal.h +++ /dev/null @@ -1,29 +0,0 @@ -// dear imgui: Renderer Backend for Metal -// This needs to be used along with a Platform Backend (e.g. OSX) - -// Implemented features: -// [X] Renderer: User texture binding. Use 'MTLTexture' as ImTextureID. Read the FAQ about ImTextureID! -// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -#include "imgui.h" // IMGUI_IMPL_API - -@class MTLRenderPassDescriptor; -@protocol MTLDevice, MTLCommandBuffer, MTLRenderCommandEncoder; - -IMGUI_IMPL_API bool ImGui_ImplMetal_Init(id device); -IMGUI_IMPL_API void ImGui_ImplMetal_Shutdown(); -IMGUI_IMPL_API void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor* renderPassDescriptor); -IMGUI_IMPL_API void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data, - id commandBuffer, - id commandEncoder); - -// Called by Init/NewFrame/Shutdown -IMGUI_IMPL_API bool ImGui_ImplMetal_CreateFontsTexture(id device); -IMGUI_IMPL_API void ImGui_ImplMetal_DestroyFontsTexture(); -IMGUI_IMPL_API bool ImGui_ImplMetal_CreateDeviceObjects(id device); -IMGUI_IMPL_API void ImGui_ImplMetal_DestroyDeviceObjects(); diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_metal.mm b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_metal.mm deleted file mode 100644 index 18dcc91..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_metal.mm +++ /dev/null @@ -1,556 +0,0 @@ -// dear imgui: Renderer Backend for Metal -// This needs to be used along with a Platform Backend (e.g. OSX) - -// Implemented features: -// [X] Renderer: User texture binding. Use 'MTLTexture' as ImTextureID. Read the FAQ about ImTextureID! -// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -// CHANGELOG -// (minor and older changes stripped away, please see git history for details) -// 2021-08-24: Metal: Fixed a crash when clipping rect larger than framebuffer is submitted. (#4464) -// 2021-05-19: Metal: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement) -// 2021-02-18: Metal: Change blending equation to preserve alpha in output buffer. -// 2021-01-25: Metal: Fixed texture storage mode when building on Mac Catalyst. -// 2019-05-29: Metal: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag. -// 2019-04-30: Metal: Added support for special ImDrawCallback_ResetRenderState callback to reset render state. -// 2019-02-11: Metal: Projecting clipping rectangles correctly using draw_data->FramebufferScale to allow multi-viewports for retina display. -// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window. -// 2018-07-05: Metal: Added new Metal backend implementation. - -#include "imgui.h" -#include "imgui_impl_metal.h" - -#import -// #import // Not supported in XCode 9.2. Maybe a macro to detect the SDK version can be used (something like #if MACOS_SDK >= 10.13 ...) -#import - -#pragma mark - Support classes - -// A wrapper around a MTLBuffer object that knows the last time it was reused -@interface MetalBuffer : NSObject -@property (nonatomic, strong) id buffer; -@property (nonatomic, assign) NSTimeInterval lastReuseTime; -- (instancetype)initWithBuffer:(id)buffer; -@end - -// An object that encapsulates the data necessary to uniquely identify a -// render pipeline state. These are used as cache keys. -@interface FramebufferDescriptor : NSObject -@property (nonatomic, assign) unsigned long sampleCount; -@property (nonatomic, assign) MTLPixelFormat colorPixelFormat; -@property (nonatomic, assign) MTLPixelFormat depthPixelFormat; -@property (nonatomic, assign) MTLPixelFormat stencilPixelFormat; -- (instancetype)initWithRenderPassDescriptor:(MTLRenderPassDescriptor *)renderPassDescriptor; -@end - -// A singleton that stores long-lived objects that are needed by the Metal -// renderer backend. Stores the render pipeline state cache and the default -// font texture, and manages the reusable buffer cache. -@interface MetalContext : NSObject -@property (nonatomic, strong) id depthStencilState; -@property (nonatomic, strong) FramebufferDescriptor *framebufferDescriptor; // framebuffer descriptor for current frame; transient -@property (nonatomic, strong) NSMutableDictionary *renderPipelineStateCache; // pipeline cache; keyed on framebuffer descriptors -@property (nonatomic, strong, nullable) id fontTexture; -@property (nonatomic, strong) NSMutableArray *bufferCache; -@property (nonatomic, assign) NSTimeInterval lastBufferCachePurge; -- (void)makeDeviceObjectsWithDevice:(id)device; -- (void)makeFontTextureWithDevice:(id)device; -- (MetalBuffer *)dequeueReusableBufferOfLength:(NSUInteger)length device:(id)device; -- (void)enqueueReusableBuffer:(MetalBuffer *)buffer; -- (id)renderPipelineStateForFrameAndDevice:(id)device; -- (void)emptyRenderPipelineStateCache; -- (void)setupRenderState:(ImDrawData *)drawData - commandBuffer:(id)commandBuffer - commandEncoder:(id)commandEncoder - renderPipelineState:(id)renderPipelineState - vertexBuffer:(MetalBuffer *)vertexBuffer - vertexBufferOffset:(size_t)vertexBufferOffset; -- (void)renderDrawData:(ImDrawData *)drawData - commandBuffer:(id)commandBuffer - commandEncoder:(id)commandEncoder; -@end - -static MetalContext *g_sharedMetalContext = nil; - -#pragma mark - ImGui API implementation - -bool ImGui_ImplMetal_Init(id device) -{ - ImGuiIO& io = ImGui::GetIO(); - io.BackendRendererName = "imgui_impl_metal"; - io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. - - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - g_sharedMetalContext = [[MetalContext alloc] init]; - }); - - ImGui_ImplMetal_CreateDeviceObjects(device); - - return true; -} - -void ImGui_ImplMetal_Shutdown() -{ - ImGui_ImplMetal_DestroyDeviceObjects(); -} - -void ImGui_ImplMetal_NewFrame(MTLRenderPassDescriptor *renderPassDescriptor) -{ - IM_ASSERT(g_sharedMetalContext != nil && "No Metal context. Did you call ImGui_ImplMetal_Init() ?"); - - g_sharedMetalContext.framebufferDescriptor = [[FramebufferDescriptor alloc] initWithRenderPassDescriptor:renderPassDescriptor]; -} - -// Metal Render function. -void ImGui_ImplMetal_RenderDrawData(ImDrawData* draw_data, id commandBuffer, id commandEncoder) -{ - [g_sharedMetalContext renderDrawData:draw_data commandBuffer:commandBuffer commandEncoder:commandEncoder]; -} - -bool ImGui_ImplMetal_CreateFontsTexture(id device) -{ - [g_sharedMetalContext makeFontTextureWithDevice:device]; - - ImGuiIO& io = ImGui::GetIO(); - io.Fonts->SetTexID((__bridge void *)g_sharedMetalContext.fontTexture); // ImTextureID == void* - - return (g_sharedMetalContext.fontTexture != nil); -} - -void ImGui_ImplMetal_DestroyFontsTexture() -{ - ImGuiIO& io = ImGui::GetIO(); - g_sharedMetalContext.fontTexture = nil; - io.Fonts->SetTexID(nullptr); -} - -bool ImGui_ImplMetal_CreateDeviceObjects(id device) -{ - [g_sharedMetalContext makeDeviceObjectsWithDevice:device]; - - ImGui_ImplMetal_CreateFontsTexture(device); - - return true; -} - -void ImGui_ImplMetal_DestroyDeviceObjects() -{ - ImGui_ImplMetal_DestroyFontsTexture(); - [g_sharedMetalContext emptyRenderPipelineStateCache]; -} - -#pragma mark - MetalBuffer implementation - -@implementation MetalBuffer -- (instancetype)initWithBuffer:(id)buffer -{ - if ((self = [super init])) - { - _buffer = buffer; - _lastReuseTime = [NSDate date].timeIntervalSince1970; - } - return self; -} -@end - -#pragma mark - FramebufferDescriptor implementation - -@implementation FramebufferDescriptor -- (instancetype)initWithRenderPassDescriptor:(MTLRenderPassDescriptor *)renderPassDescriptor -{ - if ((self = [super init])) - { - _sampleCount = renderPassDescriptor.colorAttachments[0].texture.sampleCount; - _colorPixelFormat = renderPassDescriptor.colorAttachments[0].texture.pixelFormat; - _depthPixelFormat = renderPassDescriptor.depthAttachment.texture.pixelFormat; - _stencilPixelFormat = renderPassDescriptor.stencilAttachment.texture.pixelFormat; - } - return self; -} - -- (nonnull id)copyWithZone:(nullable NSZone *)zone -{ - FramebufferDescriptor *copy = [[FramebufferDescriptor allocWithZone:zone] init]; - copy.sampleCount = self.sampleCount; - copy.colorPixelFormat = self.colorPixelFormat; - copy.depthPixelFormat = self.depthPixelFormat; - copy.stencilPixelFormat = self.stencilPixelFormat; - return copy; -} - -- (NSUInteger)hash -{ - NSUInteger sc = _sampleCount & 0x3; - NSUInteger cf = _colorPixelFormat & 0x3FF; - NSUInteger df = _depthPixelFormat & 0x3FF; - NSUInteger sf = _stencilPixelFormat & 0x3FF; - NSUInteger hash = (sf << 22) | (df << 12) | (cf << 2) | sc; - return hash; -} - -- (BOOL)isEqual:(id)object -{ - FramebufferDescriptor *other = object; - if (![other isKindOfClass:[FramebufferDescriptor class]]) - return NO; - return other.sampleCount == self.sampleCount && - other.colorPixelFormat == self.colorPixelFormat && - other.depthPixelFormat == self.depthPixelFormat && - other.stencilPixelFormat == self.stencilPixelFormat; -} - -@end - -#pragma mark - MetalContext implementation - -@implementation MetalContext -- (instancetype)init { - if ((self = [super init])) - { - _renderPipelineStateCache = [NSMutableDictionary dictionary]; - _bufferCache = [NSMutableArray array]; - _lastBufferCachePurge = [NSDate date].timeIntervalSince1970; - } - return self; -} - -- (void)makeDeviceObjectsWithDevice:(id)device -{ - MTLDepthStencilDescriptor *depthStencilDescriptor = [[MTLDepthStencilDescriptor alloc] init]; - depthStencilDescriptor.depthWriteEnabled = NO; - depthStencilDescriptor.depthCompareFunction = MTLCompareFunctionAlways; - self.depthStencilState = [device newDepthStencilStateWithDescriptor:depthStencilDescriptor]; -} - -// We are retrieving and uploading the font atlas as a 4-channels RGBA texture here. -// In theory we could call GetTexDataAsAlpha8() and upload a 1-channel texture to save on memory access bandwidth. -// However, using a shader designed for 1-channel texture would make it less obvious to use the ImTextureID facility to render users own textures. -// You can make that change in your implementation. -- (void)makeFontTextureWithDevice:(id)device -{ - ImGuiIO &io = ImGui::GetIO(); - unsigned char* pixels; - int width, height; - io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); - MTLTextureDescriptor *textureDescriptor = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatRGBA8Unorm - width:(NSUInteger)width - height:(NSUInteger)height - mipmapped:NO]; - textureDescriptor.usage = MTLTextureUsageShaderRead; -#if TARGET_OS_OSX || TARGET_OS_MACCATALYST - textureDescriptor.storageMode = MTLStorageModeManaged; -#else - textureDescriptor.storageMode = MTLStorageModeShared; -#endif - id texture = [device newTextureWithDescriptor:textureDescriptor]; - [texture replaceRegion:MTLRegionMake2D(0, 0, (NSUInteger)width, (NSUInteger)height) mipmapLevel:0 withBytes:pixels bytesPerRow:(NSUInteger)width * 4]; - self.fontTexture = texture; -} - -- (MetalBuffer *)dequeueReusableBufferOfLength:(NSUInteger)length device:(id)device -{ - NSTimeInterval now = [NSDate date].timeIntervalSince1970; - - // Purge old buffers that haven't been useful for a while - if (now - self.lastBufferCachePurge > 1.0) - { - NSMutableArray *survivors = [NSMutableArray array]; - for (MetalBuffer *candidate in self.bufferCache) - { - if (candidate.lastReuseTime > self.lastBufferCachePurge) - { - [survivors addObject:candidate]; - } - } - self.bufferCache = [survivors mutableCopy]; - self.lastBufferCachePurge = now; - } - - // See if we have a buffer we can reuse - MetalBuffer *bestCandidate = nil; - for (MetalBuffer *candidate in self.bufferCache) - if (candidate.buffer.length >= length && (bestCandidate == nil || bestCandidate.lastReuseTime > candidate.lastReuseTime)) - bestCandidate = candidate; - - if (bestCandidate != nil) - { - [self.bufferCache removeObject:bestCandidate]; - bestCandidate.lastReuseTime = now; - return bestCandidate; - } - - // No luck; make a new buffer - id backing = [device newBufferWithLength:length options:MTLResourceStorageModeShared]; - return [[MetalBuffer alloc] initWithBuffer:backing]; -} - -- (void)enqueueReusableBuffer:(MetalBuffer *)buffer -{ - [self.bufferCache addObject:buffer]; -} - -- (_Nullable id)renderPipelineStateForFrameAndDevice:(id)device -{ - // Try to retrieve a render pipeline state that is compatible with the framebuffer config for this frame - // The hit rate for this cache should be very near 100%. - id renderPipelineState = self.renderPipelineStateCache[self.framebufferDescriptor]; - - if (renderPipelineState == nil) - { - // No luck; make a new render pipeline state - renderPipelineState = [self _renderPipelineStateForFramebufferDescriptor:self.framebufferDescriptor device:device]; - // Cache render pipeline state for later reuse - self.renderPipelineStateCache[self.framebufferDescriptor] = renderPipelineState; - } - - return renderPipelineState; -} - -- (id)_renderPipelineStateForFramebufferDescriptor:(FramebufferDescriptor *)descriptor device:(id)device -{ - NSError *error = nil; - - NSString *shaderSource = @"" - "#include \n" - "using namespace metal;\n" - "\n" - "struct Uniforms {\n" - " float4x4 projectionMatrix;\n" - "};\n" - "\n" - "struct VertexIn {\n" - " float2 position [[attribute(0)]];\n" - " float2 texCoords [[attribute(1)]];\n" - " uchar4 color [[attribute(2)]];\n" - "};\n" - "\n" - "struct VertexOut {\n" - " float4 position [[position]];\n" - " float2 texCoords;\n" - " float4 color;\n" - "};\n" - "\n" - "vertex VertexOut vertex_main(VertexIn in [[stage_in]],\n" - " constant Uniforms &uniforms [[buffer(1)]]) {\n" - " VertexOut out;\n" - " out.position = uniforms.projectionMatrix * float4(in.position, 0, 1);\n" - " out.texCoords = in.texCoords;\n" - " out.color = float4(in.color) / float4(255.0);\n" - " return out;\n" - "}\n" - "\n" - "fragment half4 fragment_main(VertexOut in [[stage_in]],\n" - " texture2d texture [[texture(0)]]) {\n" - " constexpr sampler linearSampler(coord::normalized, min_filter::linear, mag_filter::linear, mip_filter::linear);\n" - " half4 texColor = texture.sample(linearSampler, in.texCoords);\n" - " return half4(in.color) * texColor;\n" - "}\n"; - - id library = [device newLibraryWithSource:shaderSource options:nil error:&error]; - if (library == nil) - { - NSLog(@"Error: failed to create Metal library: %@", error); - return nil; - } - - id vertexFunction = [library newFunctionWithName:@"vertex_main"]; - id fragmentFunction = [library newFunctionWithName:@"fragment_main"]; - - if (vertexFunction == nil || fragmentFunction == nil) - { - NSLog(@"Error: failed to find Metal shader functions in library: %@", error); - return nil; - } - - MTLVertexDescriptor *vertexDescriptor = [MTLVertexDescriptor vertexDescriptor]; - vertexDescriptor.attributes[0].offset = IM_OFFSETOF(ImDrawVert, pos); - vertexDescriptor.attributes[0].format = MTLVertexFormatFloat2; // position - vertexDescriptor.attributes[0].bufferIndex = 0; - vertexDescriptor.attributes[1].offset = IM_OFFSETOF(ImDrawVert, uv); - vertexDescriptor.attributes[1].format = MTLVertexFormatFloat2; // texCoords - vertexDescriptor.attributes[1].bufferIndex = 0; - vertexDescriptor.attributes[2].offset = IM_OFFSETOF(ImDrawVert, col); - vertexDescriptor.attributes[2].format = MTLVertexFormatUChar4; // color - vertexDescriptor.attributes[2].bufferIndex = 0; - vertexDescriptor.layouts[0].stepRate = 1; - vertexDescriptor.layouts[0].stepFunction = MTLVertexStepFunctionPerVertex; - vertexDescriptor.layouts[0].stride = sizeof(ImDrawVert); - - MTLRenderPipelineDescriptor *pipelineDescriptor = [[MTLRenderPipelineDescriptor alloc] init]; - pipelineDescriptor.vertexFunction = vertexFunction; - pipelineDescriptor.fragmentFunction = fragmentFunction; - pipelineDescriptor.vertexDescriptor = vertexDescriptor; - pipelineDescriptor.sampleCount = self.framebufferDescriptor.sampleCount; - pipelineDescriptor.colorAttachments[0].pixelFormat = self.framebufferDescriptor.colorPixelFormat; - pipelineDescriptor.colorAttachments[0].blendingEnabled = YES; - pipelineDescriptor.colorAttachments[0].rgbBlendOperation = MTLBlendOperationAdd; - pipelineDescriptor.colorAttachments[0].sourceRGBBlendFactor = MTLBlendFactorSourceAlpha; - pipelineDescriptor.colorAttachments[0].destinationRGBBlendFactor = MTLBlendFactorOneMinusSourceAlpha; - pipelineDescriptor.colorAttachments[0].alphaBlendOperation = MTLBlendOperationAdd; - pipelineDescriptor.colorAttachments[0].sourceAlphaBlendFactor = MTLBlendFactorOne; - pipelineDescriptor.colorAttachments[0].destinationAlphaBlendFactor = MTLBlendFactorOneMinusSourceAlpha; - pipelineDescriptor.depthAttachmentPixelFormat = self.framebufferDescriptor.depthPixelFormat; - pipelineDescriptor.stencilAttachmentPixelFormat = self.framebufferDescriptor.stencilPixelFormat; - - id renderPipelineState = [device newRenderPipelineStateWithDescriptor:pipelineDescriptor error:&error]; - if (error != nil) - { - NSLog(@"Error: failed to create Metal pipeline state: %@", error); - } - - return renderPipelineState; -} - -- (void)emptyRenderPipelineStateCache -{ - [self.renderPipelineStateCache removeAllObjects]; -} - -- (void)setupRenderState:(ImDrawData *)drawData - commandBuffer:(id)commandBuffer - commandEncoder:(id)commandEncoder - renderPipelineState:(id)renderPipelineState - vertexBuffer:(MetalBuffer *)vertexBuffer - vertexBufferOffset:(size_t)vertexBufferOffset -{ - [commandEncoder setCullMode:MTLCullModeNone]; - [commandEncoder setDepthStencilState:g_sharedMetalContext.depthStencilState]; - - // Setup viewport, orthographic projection matrix - // Our visible imgui space lies from draw_data->DisplayPos (top left) to - // draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayMin is typically (0,0) for single viewport apps. - MTLViewport viewport = - { - .originX = 0.0, - .originY = 0.0, - .width = (double)(drawData->DisplaySize.x * drawData->FramebufferScale.x), - .height = (double)(drawData->DisplaySize.y * drawData->FramebufferScale.y), - .znear = 0.0, - .zfar = 1.0 - }; - [commandEncoder setViewport:viewport]; - - float L = drawData->DisplayPos.x; - float R = drawData->DisplayPos.x + drawData->DisplaySize.x; - float T = drawData->DisplayPos.y; - float B = drawData->DisplayPos.y + drawData->DisplaySize.y; - float N = (float)viewport.znear; - float F = (float)viewport.zfar; - const float ortho_projection[4][4] = - { - { 2.0f/(R-L), 0.0f, 0.0f, 0.0f }, - { 0.0f, 2.0f/(T-B), 0.0f, 0.0f }, - { 0.0f, 0.0f, 1/(F-N), 0.0f }, - { (R+L)/(L-R), (T+B)/(B-T), N/(F-N), 1.0f }, - }; - [commandEncoder setVertexBytes:&ortho_projection length:sizeof(ortho_projection) atIndex:1]; - - [commandEncoder setRenderPipelineState:renderPipelineState]; - - [commandEncoder setVertexBuffer:vertexBuffer.buffer offset:0 atIndex:0]; - [commandEncoder setVertexBufferOffset:vertexBufferOffset atIndex:0]; -} - -- (void)renderDrawData:(ImDrawData *)drawData - commandBuffer:(id)commandBuffer - commandEncoder:(id)commandEncoder -{ - // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates) - int fb_width = (int)(drawData->DisplaySize.x * drawData->FramebufferScale.x); - int fb_height = (int)(drawData->DisplaySize.y * drawData->FramebufferScale.y); - if (fb_width <= 0 || fb_height <= 0 || drawData->CmdListsCount == 0) - return; - - id renderPipelineState = [self renderPipelineStateForFrameAndDevice:commandBuffer.device]; - - size_t vertexBufferLength = (size_t)drawData->TotalVtxCount * sizeof(ImDrawVert); - size_t indexBufferLength = (size_t)drawData->TotalIdxCount * sizeof(ImDrawIdx); - MetalBuffer* vertexBuffer = [self dequeueReusableBufferOfLength:vertexBufferLength device:commandBuffer.device]; - MetalBuffer* indexBuffer = [self dequeueReusableBufferOfLength:indexBufferLength device:commandBuffer.device]; - - [self setupRenderState:drawData commandBuffer:commandBuffer commandEncoder:commandEncoder renderPipelineState:renderPipelineState vertexBuffer:vertexBuffer vertexBufferOffset:0]; - - // Will project scissor/clipping rectangles into framebuffer space - ImVec2 clip_off = drawData->DisplayPos; // (0,0) unless using multi-viewports - ImVec2 clip_scale = drawData->FramebufferScale; // (1,1) unless using retina display which are often (2,2) - - // Render command lists - size_t vertexBufferOffset = 0; - size_t indexBufferOffset = 0; - for (int n = 0; n < drawData->CmdListsCount; n++) - { - const ImDrawList* cmd_list = drawData->CmdLists[n]; - - memcpy((char *)vertexBuffer.buffer.contents + vertexBufferOffset, cmd_list->VtxBuffer.Data, (size_t)cmd_list->VtxBuffer.Size * sizeof(ImDrawVert)); - memcpy((char *)indexBuffer.buffer.contents + indexBufferOffset, cmd_list->IdxBuffer.Data, (size_t)cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx)); - - for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) - { - const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; - if (pcmd->UserCallback) - { - // User callback, registered via ImDrawList::AddCallback() - // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.) - if (pcmd->UserCallback == ImDrawCallback_ResetRenderState) - [self setupRenderState:drawData commandBuffer:commandBuffer commandEncoder:commandEncoder renderPipelineState:renderPipelineState vertexBuffer:vertexBuffer vertexBufferOffset:vertexBufferOffset]; - else - pcmd->UserCallback(cmd_list, pcmd); - } - else - { - // Project scissor/clipping rectangles into framebuffer space - ImVec2 clip_min((pcmd->ClipRect.x - clip_off.x) * clip_scale.x, (pcmd->ClipRect.y - clip_off.y) * clip_scale.y); - ImVec2 clip_max((pcmd->ClipRect.z - clip_off.x) * clip_scale.x, (pcmd->ClipRect.w - clip_off.y) * clip_scale.y); - - // Clamp to viewport as setScissorRect() won't accept values that are off bounds - if (clip_min.x < 0.0f) { clip_min.x = 0.0f; } - if (clip_min.y < 0.0f) { clip_min.y = 0.0f; } - if (clip_max.x > fb_width) { clip_max.x = (float)fb_width; } - if (clip_max.y > fb_height) { clip_max.y = (float)fb_height; } - if (clip_max.x < clip_min.x || clip_max.y < clip_min.y) - continue; - - // Apply scissor/clipping rectangle - MTLScissorRect scissorRect = - { - .x = NSUInteger(clip_min.x), - .y = NSUInteger(clip_min.y), - .width = NSUInteger(clip_max.x - clip_min.x), - .height = NSUInteger(clip_max.y - clip_min.y) - }; - [commandEncoder setScissorRect:scissorRect]; - - // Bind texture, Draw - if (ImTextureID tex_id = pcmd->GetTexID()) - [commandEncoder setFragmentTexture:(__bridge id)(tex_id) atIndex:0]; - - [commandEncoder setVertexBufferOffset:(vertexBufferOffset + pcmd->VtxOffset * sizeof(ImDrawVert)) atIndex:0]; - [commandEncoder drawIndexedPrimitives:MTLPrimitiveTypeTriangle - indexCount:pcmd->ElemCount - indexType:sizeof(ImDrawIdx) == 2 ? MTLIndexTypeUInt16 : MTLIndexTypeUInt32 - indexBuffer:indexBuffer.buffer - indexBufferOffset:indexBufferOffset + pcmd->IdxOffset * sizeof(ImDrawIdx)]; - } - } - - vertexBufferOffset += (size_t)cmd_list->VtxBuffer.Size * sizeof(ImDrawVert); - indexBufferOffset += (size_t)cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx); - } - - __weak id weakSelf = self; - [commandBuffer addCompletedHandler:^(id) - { - dispatch_async(dispatch_get_main_queue(), ^{ - [weakSelf enqueueReusableBuffer:vertexBuffer]; - [weakSelf enqueueReusableBuffer:indexBuffer]; - }); - }]; -} - -@end diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_opengl2.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_opengl2.cpp deleted file mode 100644 index ee52632..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_opengl2.cpp +++ /dev/null @@ -1,285 +0,0 @@ -// dear imgui: Renderer Backend for OpenGL2 (legacy OpenGL, fixed pipeline) -// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..) - -// Implemented features: -// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID! - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)** -// **Prefer using the code in imgui_impl_opengl3.cpp** -// This code is mostly provided as a reference to learn how ImGui integration works, because it is shorter to read. -// If your code is using GL3+ context or any semi modern OpenGL calls, using this is likely to make everything more -// complicated, will require your code to reset every single OpenGL attributes to their initial state, and might -// confuse your GPU driver. -// The GL2 code is unable to reset attributes or even call e.g. "glUseProgram(0)" because they don't exist in that API. - -// CHANGELOG -// (minor and older changes stripped away, please see git history for details) -// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX). -// 2021-05-19: OpenGL: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement) -// 2021-01-03: OpenGL: Backup, setup and restore GL_SHADE_MODEL state, disable GL_STENCIL_TEST and disable GL_NORMAL_ARRAY client state to increase compatibility with legacy OpenGL applications. -// 2020-01-23: OpenGL: Backup, setup and restore GL_TEXTURE_ENV to increase compatibility with legacy OpenGL applications. -// 2019-04-30: OpenGL: Added support for special ImDrawCallback_ResetRenderState callback to reset render state. -// 2019-02-11: OpenGL: Projecting clipping rectangles correctly using draw_data->FramebufferScale to allow multi-viewports for retina display. -// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window. -// 2018-08-03: OpenGL: Disabling/restoring GL_LIGHTING and GL_COLOR_MATERIAL to increase compatibility with legacy OpenGL applications. -// 2018-06-08: Misc: Extracted imgui_impl_opengl2.cpp/.h away from the old combined GLFW/SDL+OpenGL2 examples. -// 2018-06-08: OpenGL: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle. -// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplOpenGL2_RenderDrawData() in the .h file so you can call it yourself. -// 2017-09-01: OpenGL: Save and restore current polygon mode. -// 2016-09-10: OpenGL: Uploading font texture as RGBA32 to increase compatibility with users shaders (not ideal). -// 2016-09-05: OpenGL: Fixed save and restore of current scissor rectangle. - -#include "imgui.h" -#include "imgui_impl_opengl2.h" -#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier -#include // intptr_t -#else -#include // intptr_t -#endif - -// Include OpenGL header (without an OpenGL loader) requires a bit of fiddling -#if defined(_WIN32) && !defined(APIENTRY) -#define APIENTRY __stdcall // It is customary to use APIENTRY for OpenGL function pointer declarations on all platforms. Additionally, the Windows OpenGL header needs APIENTRY. -#endif -#if defined(_WIN32) && !defined(WINGDIAPI) -#define WINGDIAPI __declspec(dllimport) // Some Windows OpenGL headers need this -#endif -#if defined(__APPLE__) -#define GL_SILENCE_DEPRECATION -#include -#else -#include -#endif - -struct ImGui_ImplOpenGL2_Data -{ - GLuint FontTexture; - - ImGui_ImplOpenGL2_Data() { memset(this, 0, sizeof(*this)); } -}; - -// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts -// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts. -static ImGui_ImplOpenGL2_Data* ImGui_ImplOpenGL2_GetBackendData() -{ - return ImGui::GetCurrentContext() ? (ImGui_ImplOpenGL2_Data*)ImGui::GetIO().BackendRendererUserData : NULL; -} - -// Functions -bool ImGui_ImplOpenGL2_Init() -{ - ImGuiIO& io = ImGui::GetIO(); - IM_ASSERT(io.BackendRendererUserData == NULL && "Already initialized a renderer backend!"); - - // Setup backend capabilities flags - ImGui_ImplOpenGL2_Data* bd = IM_NEW(ImGui_ImplOpenGL2_Data)(); - io.BackendRendererUserData = (void*)bd; - io.BackendRendererName = "imgui_impl_opengl2"; - - return true; -} - -void ImGui_ImplOpenGL2_Shutdown() -{ - ImGui_ImplOpenGL2_Data* bd = ImGui_ImplOpenGL2_GetBackendData(); - IM_ASSERT(bd != NULL && "No renderer backend to shutdown, or already shutdown?"); - ImGuiIO& io = ImGui::GetIO(); - - ImGui_ImplOpenGL2_DestroyDeviceObjects(); - io.BackendRendererName = NULL; - io.BackendRendererUserData = NULL; - IM_DELETE(bd); -} - -void ImGui_ImplOpenGL2_NewFrame() -{ - ImGui_ImplOpenGL2_Data* bd = ImGui_ImplOpenGL2_GetBackendData(); - IM_ASSERT(bd != NULL && "Did you call ImGui_ImplOpenGL2_Init()?"); - - if (!bd->FontTexture) - ImGui_ImplOpenGL2_CreateDeviceObjects(); -} - -static void ImGui_ImplOpenGL2_SetupRenderState(ImDrawData* draw_data, int fb_width, int fb_height) -{ - // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers, polygon fill. - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - //glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); // In order to composite our output buffer we need to preserve alpha - glDisable(GL_CULL_FACE); - glDisable(GL_DEPTH_TEST); - glDisable(GL_STENCIL_TEST); - glDisable(GL_LIGHTING); - glDisable(GL_COLOR_MATERIAL); - glEnable(GL_SCISSOR_TEST); - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glEnableClientState(GL_COLOR_ARRAY); - glDisableClientState(GL_NORMAL_ARRAY); - glEnable(GL_TEXTURE_2D); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - glShadeModel(GL_SMOOTH); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - - // If you are using this code with non-legacy OpenGL header/contexts (which you should not, prefer using imgui_impl_opengl3.cpp!!), - // you may need to backup/reset/restore other state, e.g. for current shader using the commented lines below. - // (DO NOT MODIFY THIS FILE! Add the code in your calling function) - // GLint last_program; - // glGetIntegerv(GL_CURRENT_PROGRAM, &last_program); - // glUseProgram(0); - // ImGui_ImplOpenGL2_RenderDrawData(...); - // glUseProgram(last_program) - // There are potentially many more states you could need to clear/setup that we can't access from default headers. - // e.g. glBindBuffer(GL_ARRAY_BUFFER, 0), glDisable(GL_TEXTURE_CUBE_MAP). - - // Setup viewport, orthographic projection matrix - // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps. - glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height); - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - glOrtho(draw_data->DisplayPos.x, draw_data->DisplayPos.x + draw_data->DisplaySize.x, draw_data->DisplayPos.y + draw_data->DisplaySize.y, draw_data->DisplayPos.y, -1.0f, +1.0f); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); -} - -// OpenGL2 Render function. -// Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly. -// This is in order to be able to run within an OpenGL engine that doesn't do so. -void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data) -{ - // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates) - int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x); - int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y); - if (fb_width == 0 || fb_height == 0) - return; - - // Backup GL state - GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture); - GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode); - GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport); - GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box); - GLint last_shade_model; glGetIntegerv(GL_SHADE_MODEL, &last_shade_model); - GLint last_tex_env_mode; glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &last_tex_env_mode); - glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT); - - // Setup desired GL state - ImGui_ImplOpenGL2_SetupRenderState(draw_data, fb_width, fb_height); - - // Will project scissor/clipping rectangles into framebuffer space - ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports - ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2) - - // Render command lists - for (int n = 0; n < draw_data->CmdListsCount; n++) - { - const ImDrawList* cmd_list = draw_data->CmdLists[n]; - const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data; - const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data; - glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, pos))); - glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, uv))); - glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, col))); - - for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) - { - const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; - if (pcmd->UserCallback) - { - // User callback, registered via ImDrawList::AddCallback() - // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.) - if (pcmd->UserCallback == ImDrawCallback_ResetRenderState) - ImGui_ImplOpenGL2_SetupRenderState(draw_data, fb_width, fb_height); - else - pcmd->UserCallback(cmd_list, pcmd); - } - else - { - // Project scissor/clipping rectangles into framebuffer space - ImVec2 clip_min((pcmd->ClipRect.x - clip_off.x) * clip_scale.x, (pcmd->ClipRect.y - clip_off.y) * clip_scale.y); - ImVec2 clip_max((pcmd->ClipRect.z - clip_off.x) * clip_scale.x, (pcmd->ClipRect.w - clip_off.y) * clip_scale.y); - if (clip_max.x < clip_min.x || clip_max.y < clip_min.y) - continue; - - // Apply scissor/clipping rectangle (Y is inverted in OpenGL) - glScissor((int)clip_min.x, (int)(fb_height - clip_max.y), (int)(clip_max.x - clip_min.x), (int)(clip_max.y - clip_min.y)); - - // Bind texture, Draw - glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->GetTexID()); - glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer); - } - idx_buffer += pcmd->ElemCount; - } - } - - // Restore modified GL state - glDisableClientState(GL_COLOR_ARRAY); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - glDisableClientState(GL_VERTEX_ARRAY); - glBindTexture(GL_TEXTURE_2D, (GLuint)last_texture); - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glPopAttrib(); - glPolygonMode(GL_FRONT, (GLenum)last_polygon_mode[0]); glPolygonMode(GL_BACK, (GLenum)last_polygon_mode[1]); - glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]); - glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]); - glShadeModel(last_shade_model); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, last_tex_env_mode); -} - -bool ImGui_ImplOpenGL2_CreateFontsTexture() -{ - // Build texture atlas - ImGuiIO& io = ImGui::GetIO(); - ImGui_ImplOpenGL2_Data* bd = ImGui_ImplOpenGL2_GetBackendData(); - unsigned char* pixels; - int width, height; - io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bit (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory. - - // Upload texture to graphics system - GLint last_texture; - glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture); - glGenTextures(1, &bd->FontTexture); - glBindTexture(GL_TEXTURE_2D, bd->FontTexture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); - - // Store our identifier - io.Fonts->SetTexID((ImTextureID)(intptr_t)bd->FontTexture); - - // Restore state - glBindTexture(GL_TEXTURE_2D, last_texture); - - return true; -} - -void ImGui_ImplOpenGL2_DestroyFontsTexture() -{ - ImGuiIO& io = ImGui::GetIO(); - ImGui_ImplOpenGL2_Data* bd = ImGui_ImplOpenGL2_GetBackendData(); - if (bd->FontTexture) - { - glDeleteTextures(1, &bd->FontTexture); - io.Fonts->SetTexID(0); - bd->FontTexture = 0; - } -} - -bool ImGui_ImplOpenGL2_CreateDeviceObjects() -{ - return ImGui_ImplOpenGL2_CreateFontsTexture(); -} - -void ImGui_ImplOpenGL2_DestroyDeviceObjects() -{ - ImGui_ImplOpenGL2_DestroyFontsTexture(); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_opengl2.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_opengl2.h deleted file mode 100644 index d00d27f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_opengl2.h +++ /dev/null @@ -1,32 +0,0 @@ -// dear imgui: Renderer Backend for OpenGL2 (legacy OpenGL, fixed pipeline) -// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..) - -// Implemented features: -// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID! - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)** -// **Prefer using the code in imgui_impl_opengl3.cpp** -// This code is mostly provided as a reference to learn how ImGui integration works, because it is shorter to read. -// If your code is using GL3+ context or any semi modern OpenGL calls, using this is likely to make everything more -// complicated, will require your code to reset every single OpenGL attributes to their initial state, and might -// confuse your GPU driver. -// The GL2 code is unable to reset attributes or even call e.g. "glUseProgram(0)" because they don't exist in that API. - -#pragma once -#include "imgui.h" // IMGUI_IMPL_API - -IMGUI_IMPL_API bool ImGui_ImplOpenGL2_Init(); -IMGUI_IMPL_API void ImGui_ImplOpenGL2_Shutdown(); -IMGUI_IMPL_API void ImGui_ImplOpenGL2_NewFrame(); -IMGUI_IMPL_API void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data); - -// Called by Init/NewFrame/Shutdown -IMGUI_IMPL_API bool ImGui_ImplOpenGL2_CreateFontsTexture(); -IMGUI_IMPL_API void ImGui_ImplOpenGL2_DestroyFontsTexture(); -IMGUI_IMPL_API bool ImGui_ImplOpenGL2_CreateDeviceObjects(); -IMGUI_IMPL_API void ImGui_ImplOpenGL2_DestroyDeviceObjects(); diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_opengl3.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_opengl3.cpp deleted file mode 100644 index 58664ea..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_opengl3.cpp +++ /dev/null @@ -1,778 +0,0 @@ -// dear imgui: Renderer Backend for modern OpenGL with shaders / programmatic pipeline -// - Desktop GL: 2.x 3.x 4.x -// - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0) -// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..) - -// Implemented features: -// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID! -// [x] Renderer: Desktop GL only: Support for large meshes (64k+ vertices) with 16-bit indices. - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -// CHANGELOG -// (minor and older changes stripped away, please see git history for details) -// 2021-08-23: OpenGL: Fixed ES 3.0 shader ("#version 300 es") use normal precision floats to avoid wobbly rendering at HD resolutions. -// 2021-08-19: OpenGL: Embed and use our own minimal GL loader (imgui_impl_opengl3_loader.h), removing requirement and support for third-party loader. -// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX). -// 2021-06-25: OpenGL: Use OES_vertex_array extension on Emscripten + backup/restore current state. -// 2021-06-21: OpenGL: Destroy individual vertex/fragment shader objects right after they are linked into the main shader. -// 2021-05-24: OpenGL: Access GL_CLIP_ORIGIN when "GL_ARB_clip_control" extension is detected, inside of just OpenGL 4.5 version. -// 2021-05-19: OpenGL: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement) -// 2021-04-06: OpenGL: Don't try to read GL_CLIP_ORIGIN unless we're OpenGL 4.5 or greater. -// 2021-02-18: OpenGL: Change blending equation to preserve alpha in output buffer. -// 2021-01-03: OpenGL: Backup, setup and restore GL_STENCIL_TEST state. -// 2020-10-23: OpenGL: Backup, setup and restore GL_PRIMITIVE_RESTART state. -// 2020-10-15: OpenGL: Use glGetString(GL_VERSION) instead of glGetIntegerv(GL_MAJOR_VERSION, ...) when the later returns zero (e.g. Desktop GL 2.x) -// 2020-09-17: OpenGL: Fix to avoid compiling/calling glBindSampler() on ES or pre 3.3 context which have the defines set by a loader. -// 2020-07-10: OpenGL: Added support for glad2 OpenGL loader. -// 2020-05-08: OpenGL: Made default GLSL version 150 (instead of 130) on OSX. -// 2020-04-21: OpenGL: Fixed handling of glClipControl(GL_UPPER_LEFT) by inverting projection matrix. -// 2020-04-12: OpenGL: Fixed context version check mistakenly testing for 4.0+ instead of 3.2+ to enable ImGuiBackendFlags_RendererHasVtxOffset. -// 2020-03-24: OpenGL: Added support for glbinding 2.x OpenGL loader. -// 2020-01-07: OpenGL: Added support for glbinding 3.x OpenGL loader. -// 2019-10-25: OpenGL: Using a combination of GL define and runtime GL version to decide whether to use glDrawElementsBaseVertex(). Fix building with pre-3.2 GL loaders. -// 2019-09-22: OpenGL: Detect default GL loader using __has_include compiler facility. -// 2019-09-16: OpenGL: Tweak initialization code to allow application calling ImGui_ImplOpenGL3_CreateFontsTexture() before the first NewFrame() call. -// 2019-05-29: OpenGL: Desktop GL only: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag. -// 2019-04-30: OpenGL: Added support for special ImDrawCallback_ResetRenderState callback to reset render state. -// 2019-03-29: OpenGL: Not calling glBindBuffer more than necessary in the render loop. -// 2019-03-15: OpenGL: Added a GL call + comments in ImGui_ImplOpenGL3_Init() to detect uninitialized GL function loaders early. -// 2019-03-03: OpenGL: Fix support for ES 2.0 (WebGL 1.0). -// 2019-02-20: OpenGL: Fix for OSX not supporting OpenGL 4.5, we don't try to read GL_CLIP_ORIGIN even if defined by the headers/loader. -// 2019-02-11: OpenGL: Projecting clipping rectangles correctly using draw_data->FramebufferScale to allow multi-viewports for retina display. -// 2019-02-01: OpenGL: Using GLSL 410 shaders for any version over 410 (e.g. 430, 450). -// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window. -// 2018-11-13: OpenGL: Support for GL 4.5's glClipControl(GL_UPPER_LEFT) / GL_CLIP_ORIGIN. -// 2018-08-29: OpenGL: Added support for more OpenGL loaders: glew and glad, with comments indicative that any loader can be used. -// 2018-08-09: OpenGL: Default to OpenGL ES 3 on iOS and Android. GLSL version default to "#version 300 ES". -// 2018-07-30: OpenGL: Support for GLSL 300 ES and 410 core. Fixes for Emscripten compilation. -// 2018-07-10: OpenGL: Support for more GLSL versions (based on the GLSL version string). Added error output when shaders fail to compile/link. -// 2018-06-08: Misc: Extracted imgui_impl_opengl3.cpp/.h away from the old combined GLFW/SDL+OpenGL3 examples. -// 2018-06-08: OpenGL: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle. -// 2018-05-25: OpenGL: Removed unnecessary backup/restore of GL_ELEMENT_ARRAY_BUFFER_BINDING since this is part of the VAO state. -// 2018-05-14: OpenGL: Making the call to glBindSampler() optional so 3.2 context won't fail if the function is a NULL pointer. -// 2018-03-06: OpenGL: Added const char* glsl_version parameter to ImGui_ImplOpenGL3_Init() so user can override the GLSL version e.g. "#version 150". -// 2018-02-23: OpenGL: Create the VAO in the render function so the setup can more easily be used with multiple shared GL context. -// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplSdlGL3_RenderDrawData() in the .h file so you can call it yourself. -// 2018-01-07: OpenGL: Changed GLSL shader version from 330 to 150. -// 2017-09-01: OpenGL: Save and restore current bound sampler. Save and restore current polygon mode. -// 2017-05-01: OpenGL: Fixed save and restore of current blend func state. -// 2017-05-01: OpenGL: Fixed save and restore of current GL_ACTIVE_TEXTURE. -// 2016-09-05: OpenGL: Fixed save and restore of current scissor rectangle. -// 2016-07-29: OpenGL: Explicitly setting GL_UNPACK_ROW_LENGTH to reduce issues because SDL changes it. (#752) - -//---------------------------------------- -// OpenGL GLSL GLSL -// version version string -//---------------------------------------- -// 2.0 110 "#version 110" -// 2.1 120 "#version 120" -// 3.0 130 "#version 130" -// 3.1 140 "#version 140" -// 3.2 150 "#version 150" -// 3.3 330 "#version 330 core" -// 4.0 400 "#version 400 core" -// 4.1 410 "#version 410 core" -// 4.2 420 "#version 410 core" -// 4.3 430 "#version 430 core" -// ES 2.0 100 "#version 100" = WebGL 1.0 -// ES 3.0 300 "#version 300 es" = WebGL 2.0 -//---------------------------------------- - -#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) -#define _CRT_SECURE_NO_WARNINGS -#endif - -#include "imgui.h" -#include "imgui_impl_opengl3.h" -#include -#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier -#include // intptr_t -#else -#include // intptr_t -#endif - -// GL includes -#if defined(IMGUI_IMPL_OPENGL_ES2) -#include -#if defined(__EMSCRIPTEN__) -#ifndef GL_GLEXT_PROTOTYPES -#define GL_GLEXT_PROTOTYPES -#endif -#include -#endif -#elif defined(IMGUI_IMPL_OPENGL_ES3) -#if defined(__APPLE__) -#include -#endif -#if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV)) -#include // Use GL ES 3 -#else -#include // Use GL ES 3 -#endif -#elif !defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM) -// Modern desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers. -// Helper libraries are often used for this purpose! Here we are using our own minimal custom loader based on gl3w. -// In the rest of your app/engine, you can use another loader of your choice (gl3w, glew, glad, glbinding, glext, glLoadGen, etc.). -// If you happen to be developing a new feature for this backend (imgui_impl_opengl3.cpp): -// - You may need to regenerate imgui_impl_opengl3_loader.h to add new symbols. See https://github.com/dearimgui/gl3w_stripped -// - You can temporarily use an unstripped version. See https://github.com/dearimgui/gl3w_stripped/releases -// Changes to this backend using new APIs should be accompanied by a regenerated stripped loader version. -#define IMGL3W_IMPL -#include "imgui_impl_opengl3_loader.h" -#endif - -// Vertex arrays are not supported on ES2/WebGL1 unless Emscripten which uses an extension -#ifndef IMGUI_IMPL_OPENGL_ES2 -#define IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY -#elif defined(__EMSCRIPTEN__) -#define IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY -#define glBindVertexArray glBindVertexArrayOES -#define glGenVertexArrays glGenVertexArraysOES -#define glDeleteVertexArrays glDeleteVertexArraysOES -#define GL_VERTEX_ARRAY_BINDING GL_VERTEX_ARRAY_BINDING_OES -#endif - -// Desktop GL 2.0+ has glPolygonMode() which GL ES and WebGL don't have. -#ifdef GL_POLYGON_MODE -#define IMGUI_IMPL_HAS_POLYGON_MODE -#endif - -// Desktop GL 3.2+ has glDrawElementsBaseVertex() which GL ES and WebGL don't have. -#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3) && defined(GL_VERSION_3_2) -#define IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET -#endif - -// Desktop GL 3.3+ has glBindSampler() -#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3) && defined(GL_VERSION_3_3) -#define IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER -#endif - -// Desktop GL 3.1+ has GL_PRIMITIVE_RESTART state -#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3) && defined(GL_VERSION_3_1) -#define IMGUI_IMPL_OPENGL_MAY_HAVE_PRIMITIVE_RESTART -#endif - -// Desktop GL use extension detection -#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3) -#define IMGUI_IMPL_OPENGL_MAY_HAVE_EXTENSIONS -#endif - -// OpenGL Data -struct ImGui_ImplOpenGL3_Data -{ - GLuint GlVersion; // Extracted at runtime using GL_MAJOR_VERSION, GL_MINOR_VERSION queries (e.g. 320 for GL 3.2) - char GlslVersionString[32]; // Specified by user or detected based on compile time GL settings. - GLuint FontTexture; - GLuint ShaderHandle; - GLint AttribLocationTex; // Uniforms location - GLint AttribLocationProjMtx; - GLuint AttribLocationVtxPos; // Vertex attributes location - GLuint AttribLocationVtxUV; - GLuint AttribLocationVtxColor; - unsigned int VboHandle, ElementsHandle; - bool HasClipOrigin; - - ImGui_ImplOpenGL3_Data() { memset(this, 0, sizeof(*this)); } -}; - -// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts -// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts. -static ImGui_ImplOpenGL3_Data* ImGui_ImplOpenGL3_GetBackendData() -{ - return ImGui::GetCurrentContext() ? (ImGui_ImplOpenGL3_Data*)ImGui::GetIO().BackendRendererUserData : NULL; -} - -// Functions -bool ImGui_ImplOpenGL3_Init(const char* glsl_version) -{ - ImGuiIO& io = ImGui::GetIO(); - IM_ASSERT(io.BackendRendererUserData == NULL && "Already initialized a renderer backend!"); - - // Initialize our loader -#if !defined(IMGUI_IMPL_OPENGL_ES2) && !defined(IMGUI_IMPL_OPENGL_ES3) && !defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM) - if (imgl3wInit() != 0) - { - fprintf(stderr, "Failed to initialize OpenGL loader!\n"); - return false; - } -#endif - - // Setup backend capabilities flags - ImGui_ImplOpenGL3_Data* bd = IM_NEW(ImGui_ImplOpenGL3_Data)(); - io.BackendRendererUserData = (void*)bd; - io.BackendRendererName = "imgui_impl_opengl3"; - - // Query for GL version (e.g. 320 for GL 3.2) -#if !defined(IMGUI_IMPL_OPENGL_ES2) - GLint major = 0; - GLint minor = 0; - glGetIntegerv(GL_MAJOR_VERSION, &major); - glGetIntegerv(GL_MINOR_VERSION, &minor); - if (major == 0 && minor == 0) - { - // Query GL_VERSION in desktop GL 2.x, the string will start with "." - const char* gl_version = (const char*)glGetString(GL_VERSION); - sscanf(gl_version, "%d.%d", &major, &minor); - } - bd->GlVersion = (GLuint)(major * 100 + minor * 10); -#else - bd->GlVersion = 200; // GLES 2 -#endif - -#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET - if (bd->GlVersion >= 320) - io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. -#endif - - // Store GLSL version string so we can refer to it later in case we recreate shaders. - // Note: GLSL version is NOT the same as GL version. Leave this to NULL if unsure. - if (glsl_version == NULL) - { -#if defined(IMGUI_IMPL_OPENGL_ES2) - glsl_version = "#version 100"; -#elif defined(IMGUI_IMPL_OPENGL_ES3) - glsl_version = "#version 300 es"; -#elif defined(__APPLE__) - glsl_version = "#version 150"; -#else - glsl_version = "#version 130"; -#endif - } - IM_ASSERT((int)strlen(glsl_version) + 2 < IM_ARRAYSIZE(bd->GlslVersionString)); - strcpy(bd->GlslVersionString, glsl_version); - strcat(bd->GlslVersionString, "\n"); - - // Make an arbitrary GL call (we don't actually need the result) - // IF YOU GET A CRASH HERE: it probably means the OpenGL function loader didn't do its job. Let us know! - GLint current_texture; - glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_texture); - - // Detect extensions we support - bd->HasClipOrigin = (bd->GlVersion >= 450); -#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_EXTENSIONS - GLint num_extensions = 0; - glGetIntegerv(GL_NUM_EXTENSIONS, &num_extensions); - for (GLint i = 0; i < num_extensions; i++) - { - const char* extension = (const char*)glGetStringi(GL_EXTENSIONS, i); - if (extension != NULL && strcmp(extension, "GL_ARB_clip_control") == 0) - bd->HasClipOrigin = true; - } -#endif - - return true; -} - -void ImGui_ImplOpenGL3_Shutdown() -{ - ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData(); - IM_ASSERT(bd != NULL && "No renderer backend to shutdown, or already shutdown?"); - ImGuiIO& io = ImGui::GetIO(); - - ImGui_ImplOpenGL3_DestroyDeviceObjects(); - io.BackendRendererName = NULL; - io.BackendRendererUserData = NULL; - IM_DELETE(bd); -} - -void ImGui_ImplOpenGL3_NewFrame() -{ - ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData(); - IM_ASSERT(bd != NULL && "Did you call ImGui_ImplOpenGL3_Init()?"); - - if (!bd->ShaderHandle) - ImGui_ImplOpenGL3_CreateDeviceObjects(); -} - -static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_width, int fb_height, GLuint vertex_array_object) -{ - ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData(); - - // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, polygon fill - glEnable(GL_BLEND); - glBlendEquation(GL_FUNC_ADD); - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - glDisable(GL_CULL_FACE); - glDisable(GL_DEPTH_TEST); - glDisable(GL_STENCIL_TEST); - glEnable(GL_SCISSOR_TEST); -#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_PRIMITIVE_RESTART - if (bd->GlVersion >= 310) - glDisable(GL_PRIMITIVE_RESTART); -#endif -#ifdef IMGUI_IMPL_HAS_POLYGON_MODE - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); -#endif - - // Support for GL 4.5 rarely used glClipControl(GL_UPPER_LEFT) -#if defined(GL_CLIP_ORIGIN) - bool clip_origin_lower_left = true; - if (bd->HasClipOrigin) - { - GLenum current_clip_origin = 0; glGetIntegerv(GL_CLIP_ORIGIN, (GLint*)¤t_clip_origin); - if (current_clip_origin == GL_UPPER_LEFT) - clip_origin_lower_left = false; - } -#endif - - // Setup viewport, orthographic projection matrix - // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps. - glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height); - float L = draw_data->DisplayPos.x; - float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x; - float T = draw_data->DisplayPos.y; - float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y; -#if defined(GL_CLIP_ORIGIN) - if (!clip_origin_lower_left) { float tmp = T; T = B; B = tmp; } // Swap top and bottom if origin is upper left -#endif - const float ortho_projection[4][4] = - { - { 2.0f/(R-L), 0.0f, 0.0f, 0.0f }, - { 0.0f, 2.0f/(T-B), 0.0f, 0.0f }, - { 0.0f, 0.0f, -1.0f, 0.0f }, - { (R+L)/(L-R), (T+B)/(B-T), 0.0f, 1.0f }, - }; - glUseProgram(bd->ShaderHandle); - glUniform1i(bd->AttribLocationTex, 0); - glUniformMatrix4fv(bd->AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]); - -#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER - if (bd->GlVersion >= 330) - glBindSampler(0, 0); // We use combined texture/sampler state. Applications using GL 3.3 may set that otherwise. -#endif - - (void)vertex_array_object; -#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY - glBindVertexArray(vertex_array_object); -#endif - - // Bind vertex/index buffers and setup attributes for ImDrawVert - glBindBuffer(GL_ARRAY_BUFFER, bd->VboHandle); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bd->ElementsHandle); - glEnableVertexAttribArray(bd->AttribLocationVtxPos); - glEnableVertexAttribArray(bd->AttribLocationVtxUV); - glEnableVertexAttribArray(bd->AttribLocationVtxColor); - glVertexAttribPointer(bd->AttribLocationVtxPos, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, pos)); - glVertexAttribPointer(bd->AttribLocationVtxUV, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, uv)); - glVertexAttribPointer(bd->AttribLocationVtxColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, col)); -} - -// OpenGL3 Render function. -// Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly. -// This is in order to be able to run within an OpenGL engine that doesn't do so. -void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data) -{ - // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates) - int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x); - int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y); - if (fb_width <= 0 || fb_height <= 0) - return; - - ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData(); - - // Backup GL state - GLenum last_active_texture; glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint*)&last_active_texture); - glActiveTexture(GL_TEXTURE0); - GLuint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*)&last_program); - GLuint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint*)&last_texture); -#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER - GLuint last_sampler; if (bd->GlVersion >= 330) { glGetIntegerv(GL_SAMPLER_BINDING, (GLint*)&last_sampler); } else { last_sampler = 0; } -#endif - GLuint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, (GLint*)&last_array_buffer); -#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY - GLuint last_vertex_array_object; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, (GLint*)&last_vertex_array_object); -#endif -#ifdef IMGUI_IMPL_HAS_POLYGON_MODE - GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode); -#endif - GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport); - GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box); - GLenum last_blend_src_rgb; glGetIntegerv(GL_BLEND_SRC_RGB, (GLint*)&last_blend_src_rgb); - GLenum last_blend_dst_rgb; glGetIntegerv(GL_BLEND_DST_RGB, (GLint*)&last_blend_dst_rgb); - GLenum last_blend_src_alpha; glGetIntegerv(GL_BLEND_SRC_ALPHA, (GLint*)&last_blend_src_alpha); - GLenum last_blend_dst_alpha; glGetIntegerv(GL_BLEND_DST_ALPHA, (GLint*)&last_blend_dst_alpha); - GLenum last_blend_equation_rgb; glGetIntegerv(GL_BLEND_EQUATION_RGB, (GLint*)&last_blend_equation_rgb); - GLenum last_blend_equation_alpha; glGetIntegerv(GL_BLEND_EQUATION_ALPHA, (GLint*)&last_blend_equation_alpha); - GLboolean last_enable_blend = glIsEnabled(GL_BLEND); - GLboolean last_enable_cull_face = glIsEnabled(GL_CULL_FACE); - GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST); - GLboolean last_enable_stencil_test = glIsEnabled(GL_STENCIL_TEST); - GLboolean last_enable_scissor_test = glIsEnabled(GL_SCISSOR_TEST); -#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_PRIMITIVE_RESTART - GLboolean last_enable_primitive_restart = (bd->GlVersion >= 310) ? glIsEnabled(GL_PRIMITIVE_RESTART) : GL_FALSE; -#endif - - // Setup desired GL state - // Recreate the VAO every time (this is to easily allow multiple GL contexts to be rendered to. VAO are not shared among GL contexts) - // The renderer would actually work without any VAO bound, but then our VertexAttrib calls would overwrite the default one currently bound. - GLuint vertex_array_object = 0; -#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY - glGenVertexArrays(1, &vertex_array_object); -#endif - ImGui_ImplOpenGL3_SetupRenderState(draw_data, fb_width, fb_height, vertex_array_object); - - // Will project scissor/clipping rectangles into framebuffer space - ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports - ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2) - - // Render command lists - for (int n = 0; n < draw_data->CmdListsCount; n++) - { - const ImDrawList* cmd_list = draw_data->CmdLists[n]; - - // Upload vertex/index buffers - glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.Size * (int)sizeof(ImDrawVert), (const GLvoid*)cmd_list->VtxBuffer.Data, GL_STREAM_DRAW); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.Size * (int)sizeof(ImDrawIdx), (const GLvoid*)cmd_list->IdxBuffer.Data, GL_STREAM_DRAW); - - for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) - { - const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; - if (pcmd->UserCallback != NULL) - { - // User callback, registered via ImDrawList::AddCallback() - // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.) - if (pcmd->UserCallback == ImDrawCallback_ResetRenderState) - ImGui_ImplOpenGL3_SetupRenderState(draw_data, fb_width, fb_height, vertex_array_object); - else - pcmd->UserCallback(cmd_list, pcmd); - } - else - { - // Project scissor/clipping rectangles into framebuffer space - ImVec2 clip_min((pcmd->ClipRect.x - clip_off.x) * clip_scale.x, (pcmd->ClipRect.y - clip_off.y) * clip_scale.y); - ImVec2 clip_max((pcmd->ClipRect.z - clip_off.x) * clip_scale.x, (pcmd->ClipRect.w - clip_off.y) * clip_scale.y); - if (clip_max.x < clip_min.x || clip_max.y < clip_min.y) - continue; - - // Apply scissor/clipping rectangle (Y is inverted in OpenGL) - glScissor((int)clip_min.x, (int)(fb_height - clip_max.y), (int)(clip_max.x - clip_min.x), (int)(clip_max.y - clip_min.y)); - - // Bind texture, Draw - glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->GetTexID()); -#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET - if (bd->GlVersion >= 320) - glDrawElementsBaseVertex(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx)), (GLint)pcmd->VtxOffset); - else -#endif - glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx))); - } - } - } - - // Destroy the temporary VAO -#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY - glDeleteVertexArrays(1, &vertex_array_object); -#endif - - // Restore modified GL state - glUseProgram(last_program); - glBindTexture(GL_TEXTURE_2D, last_texture); -#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_BIND_SAMPLER - if (bd->GlVersion >= 330) - glBindSampler(0, last_sampler); -#endif - glActiveTexture(last_active_texture); -#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY - glBindVertexArray(last_vertex_array_object); -#endif - glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer); - glBlendEquationSeparate(last_blend_equation_rgb, last_blend_equation_alpha); - glBlendFuncSeparate(last_blend_src_rgb, last_blend_dst_rgb, last_blend_src_alpha, last_blend_dst_alpha); - if (last_enable_blend) glEnable(GL_BLEND); else glDisable(GL_BLEND); - if (last_enable_cull_face) glEnable(GL_CULL_FACE); else glDisable(GL_CULL_FACE); - if (last_enable_depth_test) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST); - if (last_enable_stencil_test) glEnable(GL_STENCIL_TEST); else glDisable(GL_STENCIL_TEST); - if (last_enable_scissor_test) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST); -#ifdef IMGUI_IMPL_OPENGL_MAY_HAVE_PRIMITIVE_RESTART - if (bd->GlVersion >= 310) { if (last_enable_primitive_restart) glEnable(GL_PRIMITIVE_RESTART); else glDisable(GL_PRIMITIVE_RESTART); } -#endif - -#ifdef IMGUI_IMPL_HAS_POLYGON_MODE - glPolygonMode(GL_FRONT_AND_BACK, (GLenum)last_polygon_mode[0]); -#endif - glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]); - glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]); - (void)bd; // Not all compilation paths use this -} - -bool ImGui_ImplOpenGL3_CreateFontsTexture() -{ - ImGuiIO& io = ImGui::GetIO(); - ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData(); - - // Build texture atlas - unsigned char* pixels; - int width, height; - io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bit (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory. - - // Upload texture to graphics system - GLint last_texture; - glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture); - glGenTextures(1, &bd->FontTexture); - glBindTexture(GL_TEXTURE_2D, bd->FontTexture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); -#ifdef GL_UNPACK_ROW_LENGTH // Not on WebGL/ES - glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); -#endif - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); - - // Store our identifier - io.Fonts->SetTexID((ImTextureID)(intptr_t)bd->FontTexture); - - // Restore state - glBindTexture(GL_TEXTURE_2D, last_texture); - - return true; -} - -void ImGui_ImplOpenGL3_DestroyFontsTexture() -{ - ImGuiIO& io = ImGui::GetIO(); - ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData(); - if (bd->FontTexture) - { - glDeleteTextures(1, &bd->FontTexture); - io.Fonts->SetTexID(0); - bd->FontTexture = 0; - } -} - -// If you get an error please report on github. You may try different GL context version or GLSL version. See GL<>GLSL version table at the top of this file. -static bool CheckShader(GLuint handle, const char* desc) -{ - ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData(); - GLint status = 0, log_length = 0; - glGetShaderiv(handle, GL_COMPILE_STATUS, &status); - glGetShaderiv(handle, GL_INFO_LOG_LENGTH, &log_length); - if ((GLboolean)status == GL_FALSE) - fprintf(stderr, "ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to compile %s! With GLSL: %s\n", desc, bd->GlslVersionString); - if (log_length > 1) - { - ImVector buf; - buf.resize((int)(log_length + 1)); - glGetShaderInfoLog(handle, log_length, NULL, (GLchar*)buf.begin()); - fprintf(stderr, "%s\n", buf.begin()); - } - return (GLboolean)status == GL_TRUE; -} - -// If you get an error please report on GitHub. You may try different GL context version or GLSL version. -static bool CheckProgram(GLuint handle, const char* desc) -{ - ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData(); - GLint status = 0, log_length = 0; - glGetProgramiv(handle, GL_LINK_STATUS, &status); - glGetProgramiv(handle, GL_INFO_LOG_LENGTH, &log_length); - if ((GLboolean)status == GL_FALSE) - fprintf(stderr, "ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to link %s! With GLSL %s\n", desc, bd->GlslVersionString); - if (log_length > 1) - { - ImVector buf; - buf.resize((int)(log_length + 1)); - glGetProgramInfoLog(handle, log_length, NULL, (GLchar*)buf.begin()); - fprintf(stderr, "%s\n", buf.begin()); - } - return (GLboolean)status == GL_TRUE; -} - -bool ImGui_ImplOpenGL3_CreateDeviceObjects() -{ - ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData(); - - // Backup GL state - GLint last_texture, last_array_buffer; - glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture); - glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer); -#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY - GLint last_vertex_array; - glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array); -#endif - - // Parse GLSL version string - int glsl_version = 130; - sscanf(bd->GlslVersionString, "#version %d", &glsl_version); - - const GLchar* vertex_shader_glsl_120 = - "uniform mat4 ProjMtx;\n" - "attribute vec2 Position;\n" - "attribute vec2 UV;\n" - "attribute vec4 Color;\n" - "varying vec2 Frag_UV;\n" - "varying vec4 Frag_Color;\n" - "void main()\n" - "{\n" - " Frag_UV = UV;\n" - " Frag_Color = Color;\n" - " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n" - "}\n"; - - const GLchar* vertex_shader_glsl_130 = - "uniform mat4 ProjMtx;\n" - "in vec2 Position;\n" - "in vec2 UV;\n" - "in vec4 Color;\n" - "out vec2 Frag_UV;\n" - "out vec4 Frag_Color;\n" - "void main()\n" - "{\n" - " Frag_UV = UV;\n" - " Frag_Color = Color;\n" - " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n" - "}\n"; - - const GLchar* vertex_shader_glsl_300_es = - "precision highp float;\n" - "layout (location = 0) in vec2 Position;\n" - "layout (location = 1) in vec2 UV;\n" - "layout (location = 2) in vec4 Color;\n" - "uniform mat4 ProjMtx;\n" - "out vec2 Frag_UV;\n" - "out vec4 Frag_Color;\n" - "void main()\n" - "{\n" - " Frag_UV = UV;\n" - " Frag_Color = Color;\n" - " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n" - "}\n"; - - const GLchar* vertex_shader_glsl_410_core = - "layout (location = 0) in vec2 Position;\n" - "layout (location = 1) in vec2 UV;\n" - "layout (location = 2) in vec4 Color;\n" - "uniform mat4 ProjMtx;\n" - "out vec2 Frag_UV;\n" - "out vec4 Frag_Color;\n" - "void main()\n" - "{\n" - " Frag_UV = UV;\n" - " Frag_Color = Color;\n" - " gl_Position = ProjMtx * vec4(Position.xy,0,1);\n" - "}\n"; - - const GLchar* fragment_shader_glsl_120 = - "#ifdef GL_ES\n" - " precision mediump float;\n" - "#endif\n" - "uniform sampler2D Texture;\n" - "varying vec2 Frag_UV;\n" - "varying vec4 Frag_Color;\n" - "void main()\n" - "{\n" - " gl_FragColor = Frag_Color * texture2D(Texture, Frag_UV.st);\n" - "}\n"; - - const GLchar* fragment_shader_glsl_130 = - "uniform sampler2D Texture;\n" - "in vec2 Frag_UV;\n" - "in vec4 Frag_Color;\n" - "out vec4 Out_Color;\n" - "void main()\n" - "{\n" - " Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n" - "}\n"; - - const GLchar* fragment_shader_glsl_300_es = - "precision mediump float;\n" - "uniform sampler2D Texture;\n" - "in vec2 Frag_UV;\n" - "in vec4 Frag_Color;\n" - "layout (location = 0) out vec4 Out_Color;\n" - "void main()\n" - "{\n" - " Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n" - "}\n"; - - const GLchar* fragment_shader_glsl_410_core = - "in vec2 Frag_UV;\n" - "in vec4 Frag_Color;\n" - "uniform sampler2D Texture;\n" - "layout (location = 0) out vec4 Out_Color;\n" - "void main()\n" - "{\n" - " Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n" - "}\n"; - - // Select shaders matching our GLSL versions - const GLchar* vertex_shader = NULL; - const GLchar* fragment_shader = NULL; - if (glsl_version < 130) - { - vertex_shader = vertex_shader_glsl_120; - fragment_shader = fragment_shader_glsl_120; - } - else if (glsl_version >= 410) - { - vertex_shader = vertex_shader_glsl_410_core; - fragment_shader = fragment_shader_glsl_410_core; - } - else if (glsl_version == 300) - { - vertex_shader = vertex_shader_glsl_300_es; - fragment_shader = fragment_shader_glsl_300_es; - } - else - { - vertex_shader = vertex_shader_glsl_130; - fragment_shader = fragment_shader_glsl_130; - } - - // Create shaders - const GLchar* vertex_shader_with_version[2] = { bd->GlslVersionString, vertex_shader }; - GLuint vert_handle = glCreateShader(GL_VERTEX_SHADER); - glShaderSource(vert_handle, 2, vertex_shader_with_version, NULL); - glCompileShader(vert_handle); - CheckShader(vert_handle, "vertex shader"); - - const GLchar* fragment_shader_with_version[2] = { bd->GlslVersionString, fragment_shader }; - GLuint frag_handle = glCreateShader(GL_FRAGMENT_SHADER); - glShaderSource(frag_handle, 2, fragment_shader_with_version, NULL); - glCompileShader(frag_handle); - CheckShader(frag_handle, "fragment shader"); - - // Link - bd->ShaderHandle = glCreateProgram(); - glAttachShader(bd->ShaderHandle, vert_handle); - glAttachShader(bd->ShaderHandle, frag_handle); - glLinkProgram(bd->ShaderHandle); - CheckProgram(bd->ShaderHandle, "shader program"); - - glDetachShader(bd->ShaderHandle, vert_handle); - glDetachShader(bd->ShaderHandle, frag_handle); - glDeleteShader(vert_handle); - glDeleteShader(frag_handle); - - bd->AttribLocationTex = glGetUniformLocation(bd->ShaderHandle, "Texture"); - bd->AttribLocationProjMtx = glGetUniformLocation(bd->ShaderHandle, "ProjMtx"); - bd->AttribLocationVtxPos = (GLuint)glGetAttribLocation(bd->ShaderHandle, "Position"); - bd->AttribLocationVtxUV = (GLuint)glGetAttribLocation(bd->ShaderHandle, "UV"); - bd->AttribLocationVtxColor = (GLuint)glGetAttribLocation(bd->ShaderHandle, "Color"); - - // Create buffers - glGenBuffers(1, &bd->VboHandle); - glGenBuffers(1, &bd->ElementsHandle); - - ImGui_ImplOpenGL3_CreateFontsTexture(); - - // Restore modified GL state - glBindTexture(GL_TEXTURE_2D, last_texture); - glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer); -#ifdef IMGUI_IMPL_OPENGL_USE_VERTEX_ARRAY - glBindVertexArray(last_vertex_array); -#endif - - return true; -} - -void ImGui_ImplOpenGL3_DestroyDeviceObjects() -{ - ImGui_ImplOpenGL3_Data* bd = ImGui_ImplOpenGL3_GetBackendData(); - if (bd->VboHandle) { glDeleteBuffers(1, &bd->VboHandle); bd->VboHandle = 0; } - if (bd->ElementsHandle) { glDeleteBuffers(1, &bd->ElementsHandle); bd->ElementsHandle = 0; } - if (bd->ShaderHandle) { glDeleteProgram(bd->ShaderHandle); bd->ShaderHandle = 0; } - ImGui_ImplOpenGL3_DestroyFontsTexture(); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_opengl3.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_opengl3.h deleted file mode 100644 index 98c9aca..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_opengl3.h +++ /dev/null @@ -1,55 +0,0 @@ -// dear imgui: Renderer Backend for modern OpenGL with shaders / programmatic pipeline -// - Desktop GL: 2.x 3.x 4.x -// - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0) -// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..) - -// Implemented features: -// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID! -// [x] Renderer: Desktop GL only: Support for large meshes (64k+ vertices) with 16-bit indices. - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -// About GLSL version: -// The 'glsl_version' initialization parameter should be NULL (default) or a "#version XXX" string. -// On computer platform the GLSL version default to "#version 130". On OpenGL ES 3 platform it defaults to "#version 300 es" -// Only override if your GL version doesn't handle this GLSL version. See GLSL version table at the top of imgui_impl_opengl3.cpp. - -#pragma once -#include "imgui.h" // IMGUI_IMPL_API - -// Backend API -IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = NULL); -IMGUI_IMPL_API void ImGui_ImplOpenGL3_Shutdown(); -IMGUI_IMPL_API void ImGui_ImplOpenGL3_NewFrame(); -IMGUI_IMPL_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data); - -// (Optional) Called by Init/NewFrame/Shutdown -IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateFontsTexture(); -IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyFontsTexture(); -IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateDeviceObjects(); -IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects(); - -// Specific OpenGL ES versions -//#define IMGUI_IMPL_OPENGL_ES2 // Auto-detected on Emscripten -//#define IMGUI_IMPL_OPENGL_ES3 // Auto-detected on iOS/Android - -// You can explicitly select GLES2 or GLES3 API by using one of the '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line. -#if !defined(IMGUI_IMPL_OPENGL_ES2) \ - && !defined(IMGUI_IMPL_OPENGL_ES3) - -// Try to detect GLES on matching platforms -#if defined(__APPLE__) -#include -#endif -#if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV)) || (defined(__ANDROID__)) -#define IMGUI_IMPL_OPENGL_ES3 // iOS, Android -> GL ES 3, "#version 300 es" -#elif defined(__EMSCRIPTEN__) -#define IMGUI_IMPL_OPENGL_ES2 // Emscripten -> GL ES 2, "#version 100" -#else -// Otherwise imgui_impl_opengl3_loader.h will be used. -#endif - -#endif diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_opengl3_loader.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_opengl3_loader.h deleted file mode 100644 index 9313ded..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_opengl3_loader.h +++ /dev/null @@ -1,752 +0,0 @@ -//----------------------------------------------------------------------------- -// About imgui_impl_opengl3_loader.h: -// -// We embed our own OpenGL loader to not require user to provide their own or to have to use ours, -// which proved to be endless problems for users. -// Our loader is custom-generated, based on gl3w but automatically filtered to only include -// enums/functions that we use in our imgui_impl_opengl3.cpp source file in order to be small. -// -// YOU SHOULD NOT NEED TO INCLUDE/USE THIS DIRECTLY. THIS IS USED BY imgui_impl_opengl3.cpp ONLY. -// THE REST OF YOUR APP SHOULD USE A DIFFERENT GL LOADER: ANY GL LOADER OF YOUR CHOICE. -// -// Regenerate with: -// python gl3w_gen.py --output ../imgui/backends/imgui_impl_opengl3_loader.h --ref ../imgui/backends/imgui_impl_opengl3.cpp ./extra_symbols.txt -// -// More info: -// https://github.com/dearimgui/gl3w_stripped -// https://github.com/ocornut/imgui/issues/4445 -//----------------------------------------------------------------------------- - -/* - * This file was generated with gl3w_gen.py, part of imgl3w - * (hosted at https://github.com/dearimgui/gl3w_stripped) - * - * This is free and unencumbered software released into the public domain. - * - * Anyone is free to copy, modify, publish, use, compile, sell, or - * distribute this software, either in source code form or as a compiled - * binary, for any purpose, commercial or non-commercial, and by any - * means. - * - * In jurisdictions that recognize copyright laws, the author or authors - * of this software dedicate any and all copyright interest in the - * software to the public domain. We make this dedication for the benefit - * of the public at large and to the detriment of our heirs and - * successors. We intend this dedication to be an overt act of - * relinquishment in perpetuity of all present and future rights to this - * software under copyright law. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef __gl3w_h_ -#define __gl3w_h_ - -// Adapted from KHR/khrplatform.h to avoid including entire file. -#ifndef __khrplatform_h_ -typedef float khronos_float_t; -typedef signed char khronos_int8_t; -typedef unsigned char khronos_uint8_t; -typedef signed short int khronos_int16_t; -typedef unsigned short int khronos_uint16_t; -#ifdef _WIN64 -typedef signed long long int khronos_intptr_t; -typedef signed long long int khronos_ssize_t; -#else -typedef signed long int khronos_intptr_t; -typedef signed long int khronos_ssize_t; -#endif - -#if defined(_MSC_VER) && !defined(__clang__) -typedef signed __int64 khronos_int64_t; -typedef unsigned __int64 khronos_uint64_t; -#elif (defined(__clang__) || defined(__GNUC__)) && (__cplusplus < 201100) -#include -typedef int64_t khronos_int64_t; -typedef uint64_t khronos_uint64_t; -#else -typedef signed long long khronos_int64_t; -typedef unsigned long long khronos_uint64_t; -#endif -#endif // __khrplatform_h_ - -#ifndef __gl_glcorearb_h_ -#define __gl_glcorearb_h_ 1 -#ifdef __cplusplus -extern "C" { -#endif -/* -** Copyright 2013-2020 The Khronos Group Inc. -** SPDX-License-Identifier: MIT -** -** This header is generated from the Khronos OpenGL / OpenGL ES XML -** API Registry. The current version of the Registry, generator scripts -** used to make the header, and the header can be found at -** https://github.com/KhronosGroup/OpenGL-Registry -*/ -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN 1 -#endif -#include -#endif -#ifndef APIENTRY -#define APIENTRY -#endif -#ifndef APIENTRYP -#define APIENTRYP APIENTRY * -#endif -#ifndef GLAPI -#define GLAPI extern -#endif -/* glcorearb.h is for use with OpenGL core profile implementations. -** It should should be placed in the same directory as gl.h and -** included as . -** -** glcorearb.h includes only APIs in the latest OpenGL core profile -** implementation together with APIs in newer ARB extensions which -** can be supported by the core profile. It does not, and never will -** include functionality removed from the core profile, such as -** fixed-function vertex and fragment processing. -** -** Do not #include both and either of or -** in the same source file. -*/ -/* Generated C header for: - * API: gl - * Profile: core - * Versions considered: .* - * Versions emitted: .* - * Default extensions included: glcore - * Additional extensions included: _nomatch_^ - * Extensions removed: _nomatch_^ - */ -#ifndef GL_VERSION_1_0 -typedef void GLvoid; -typedef unsigned int GLenum; - -typedef khronos_float_t GLfloat; -typedef int GLint; -typedef int GLsizei; -typedef unsigned int GLbitfield; -typedef double GLdouble; -typedef unsigned int GLuint; -typedef unsigned char GLboolean; -typedef khronos_uint8_t GLubyte; -#define GL_COLOR_BUFFER_BIT 0x00004000 -#define GL_FALSE 0 -#define GL_TRUE 1 -#define GL_TRIANGLES 0x0004 -#define GL_ONE 1 -#define GL_SRC_ALPHA 0x0302 -#define GL_ONE_MINUS_SRC_ALPHA 0x0303 -#define GL_FRONT_AND_BACK 0x0408 -#define GL_POLYGON_MODE 0x0B40 -#define GL_CULL_FACE 0x0B44 -#define GL_DEPTH_TEST 0x0B71 -#define GL_STENCIL_TEST 0x0B90 -#define GL_VIEWPORT 0x0BA2 -#define GL_BLEND 0x0BE2 -#define GL_SCISSOR_BOX 0x0C10 -#define GL_SCISSOR_TEST 0x0C11 -#define GL_UNPACK_ROW_LENGTH 0x0CF2 -#define GL_PACK_ALIGNMENT 0x0D05 -#define GL_TEXTURE_2D 0x0DE1 -#define GL_UNSIGNED_BYTE 0x1401 -#define GL_UNSIGNED_SHORT 0x1403 -#define GL_UNSIGNED_INT 0x1405 -#define GL_FLOAT 0x1406 -#define GL_RGBA 0x1908 -#define GL_FILL 0x1B02 -#define GL_VERSION 0x1F02 -#define GL_EXTENSIONS 0x1F03 -#define GL_LINEAR 0x2601 -#define GL_TEXTURE_MAG_FILTER 0x2800 -#define GL_TEXTURE_MIN_FILTER 0x2801 -typedef void (APIENTRYP PFNGLPOLYGONMODEPROC) (GLenum face, GLenum mode); -typedef void (APIENTRYP PFNGLSCISSORPROC) (GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRYP PFNGLCLEARPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLCLEARCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -typedef void (APIENTRYP PFNGLDISABLEPROC) (GLenum cap); -typedef void (APIENTRYP PFNGLENABLEPROC) (GLenum cap); -typedef void (APIENTRYP PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); -typedef GLenum (APIENTRYP PFNGLGETERRORPROC) (void); -typedef void (APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *data); -typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGPROC) (GLenum name); -typedef GLboolean (APIENTRYP PFNGLISENABLEDPROC) (GLenum cap); -typedef void (APIENTRYP PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPolygonMode (GLenum face, GLenum mode); -GLAPI void APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); -GLAPI void APIENTRY glClear (GLbitfield mask); -GLAPI void APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -GLAPI void APIENTRY glDisable (GLenum cap); -GLAPI void APIENTRY glEnable (GLenum cap); -GLAPI void APIENTRY glPixelStorei (GLenum pname, GLint param); -GLAPI void APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); -GLAPI GLenum APIENTRY glGetError (void); -GLAPI void APIENTRY glGetIntegerv (GLenum pname, GLint *data); -GLAPI const GLubyte *APIENTRY glGetString (GLenum name); -GLAPI GLboolean APIENTRY glIsEnabled (GLenum cap); -GLAPI void APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); -#endif -#endif /* GL_VERSION_1_0 */ -#ifndef GL_VERSION_1_1 -typedef khronos_float_t GLclampf; -typedef double GLclampd; -#define GL_TEXTURE_BINDING_2D 0x8069 -typedef void (APIENTRYP PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices); -typedef void (APIENTRYP PFNGLBINDTEXTUREPROC) (GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLDELETETEXTURESPROC) (GLsizei n, const GLuint *textures); -typedef void (APIENTRYP PFNGLGENTEXTURESPROC) (GLsizei n, GLuint *textures); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const void *indices); -GLAPI void APIENTRY glBindTexture (GLenum target, GLuint texture); -GLAPI void APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); -GLAPI void APIENTRY glGenTextures (GLsizei n, GLuint *textures); -#endif -#endif /* GL_VERSION_1_1 */ -#ifndef GL_VERSION_1_3 -#define GL_TEXTURE0 0x84C0 -#define GL_ACTIVE_TEXTURE 0x84E0 -typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveTexture (GLenum texture); -#endif -#endif /* GL_VERSION_1_3 */ -#ifndef GL_VERSION_1_4 -#define GL_BLEND_DST_RGB 0x80C8 -#define GL_BLEND_SRC_RGB 0x80C9 -#define GL_BLEND_DST_ALPHA 0x80CA -#define GL_BLEND_SRC_ALPHA 0x80CB -#define GL_FUNC_ADD 0x8006 -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -GLAPI void APIENTRY glBlendEquation (GLenum mode); -#endif -#endif /* GL_VERSION_1_4 */ -#ifndef GL_VERSION_1_5 -typedef khronos_ssize_t GLsizeiptr; -typedef khronos_intptr_t GLintptr; -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 -#define GL_ARRAY_BUFFER_BINDING 0x8894 -#define GL_STREAM_DRAW 0x88E0 -typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); -typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); -GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); -GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); -GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage); -#endif -#endif /* GL_VERSION_1_5 */ -#ifndef GL_VERSION_2_0 -typedef char GLchar; -typedef khronos_int16_t GLshort; -typedef khronos_int8_t GLbyte; -typedef khronos_uint16_t GLushort; -#define GL_BLEND_EQUATION_RGB 0x8009 -#define GL_BLEND_EQUATION_ALPHA 0x883D -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_COMPILE_STATUS 0x8B81 -#define GL_LINK_STATUS 0x8B82 -#define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_CURRENT_PROGRAM 0x8B8D -#define GL_UPPER_LEFT 0x8CA2 -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); -typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); -typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); -typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); -GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); -GLAPI void APIENTRY glCompileShader (GLuint shader); -GLAPI GLuint APIENTRY glCreateProgram (void); -GLAPI GLuint APIENTRY glCreateShader (GLenum type); -GLAPI void APIENTRY glDeleteProgram (GLuint program); -GLAPI void APIENTRY glDeleteShader (GLuint shader); -GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); -GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); -GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); -GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); -GLAPI void APIENTRY glLinkProgram (GLuint program); -GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); -GLAPI void APIENTRY glUseProgram (GLuint program); -GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); -GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); -#endif -#endif /* GL_VERSION_2_0 */ -#ifndef GL_VERSION_3_0 -typedef khronos_uint16_t GLhalf; -#define GL_MAJOR_VERSION 0x821B -#define GL_MINOR_VERSION 0x821C -#define GL_NUM_EXTENSIONS 0x821D -#define GL_FRAMEBUFFER_SRGB 0x8DB9 -#define GL_VERTEX_ARRAY_BINDING 0x85B5 -typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); -typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); -typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); -typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); -typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI const GLubyte *APIENTRY glGetStringi (GLenum name, GLuint index); -GLAPI void APIENTRY glBindVertexArray (GLuint array); -GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); -GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); -#endif -#endif /* GL_VERSION_3_0 */ -#ifndef GL_VERSION_3_1 -#define GL_VERSION_3_1 1 -#define GL_PRIMITIVE_RESTART 0x8F9D -#endif /* GL_VERSION_3_1 */ -#ifndef GL_VERSION_3_2 -#define GL_VERSION_3_2 1 -typedef struct __GLsync *GLsync; -typedef khronos_uint64_t GLuint64; -typedef khronos_int64_t GLint64; -typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); -typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); -#endif -#endif /* GL_VERSION_3_2 */ -#ifndef GL_VERSION_3_3 -#define GL_VERSION_3_3 1 -#define GL_SAMPLER_BINDING 0x8919 -typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); -#endif -#endif /* GL_VERSION_3_3 */ -#ifndef GL_VERSION_4_1 -typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); -typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); -#endif /* GL_VERSION_4_1 */ -#ifndef GL_VERSION_4_3 -typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); -#endif /* GL_VERSION_4_3 */ -#ifndef GL_VERSION_4_5 -#define GL_CLIP_ORIGIN 0x935C -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint *param); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI64_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint64 *param); -#endif /* GL_VERSION_4_5 */ -#ifndef GL_ARB_bindless_texture -typedef khronos_uint64_t GLuint64EXT; -#endif /* GL_ARB_bindless_texture */ -#ifndef GL_ARB_cl_event -struct _cl_context; -struct _cl_event; -#endif /* GL_ARB_cl_event */ -#ifndef GL_ARB_clip_control -#define GL_ARB_clip_control 1 -#endif /* GL_ARB_clip_control */ -#ifndef GL_ARB_debug_output -typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); -#endif /* GL_ARB_debug_output */ -#ifndef GL_EXT_EGL_image_storage -typedef void *GLeglImageOES; -#endif /* GL_EXT_EGL_image_storage */ -#ifndef GL_EXT_direct_state_access -typedef void (APIENTRYP PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index, void **params); -typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); -typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, void **param); -#endif /* GL_EXT_direct_state_access */ -#ifndef GL_NV_draw_vulkan_image -typedef void (APIENTRY *GLVULKANPROCNV)(void); -#endif /* GL_NV_draw_vulkan_image */ -#ifndef GL_NV_gpu_shader5 -typedef khronos_int64_t GLint64EXT; -#endif /* GL_NV_gpu_shader5 */ -#ifndef GL_NV_vertex_buffer_unified_memory -typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result); -#endif /* GL_NV_vertex_buffer_unified_memory */ -#ifdef __cplusplus -} -#endif -#endif - -#ifndef GL3W_API -#define GL3W_API -#endif - -#ifndef __gl_h_ -#define __gl_h_ -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#define GL3W_OK 0 -#define GL3W_ERROR_INIT -1 -#define GL3W_ERROR_LIBRARY_OPEN -2 -#define GL3W_ERROR_OPENGL_VERSION -3 - -typedef void (*GL3WglProc)(void); -typedef GL3WglProc (*GL3WGetProcAddressProc)(const char *proc); - -/* gl3w api */ -GL3W_API int imgl3wInit(void); -GL3W_API int imgl3wInit2(GL3WGetProcAddressProc proc); -GL3W_API int imgl3wIsSupported(int major, int minor); -GL3W_API GL3WglProc imgl3wGetProcAddress(const char *proc); - -/* gl3w internal state */ -union GL3WProcs { - GL3WglProc ptr[53]; - struct { - PFNGLACTIVETEXTUREPROC ActiveTexture; - PFNGLATTACHSHADERPROC AttachShader; - PFNGLBINDBUFFERPROC BindBuffer; - PFNGLBINDSAMPLERPROC BindSampler; - PFNGLBINDTEXTUREPROC BindTexture; - PFNGLBINDVERTEXARRAYPROC BindVertexArray; - PFNGLBLENDEQUATIONPROC BlendEquation; - PFNGLBLENDEQUATIONSEPARATEPROC BlendEquationSeparate; - PFNGLBLENDFUNCSEPARATEPROC BlendFuncSeparate; - PFNGLBUFFERDATAPROC BufferData; - PFNGLCLEARPROC Clear; - PFNGLCLEARCOLORPROC ClearColor; - PFNGLCOMPILESHADERPROC CompileShader; - PFNGLCREATEPROGRAMPROC CreateProgram; - PFNGLCREATESHADERPROC CreateShader; - PFNGLDELETEBUFFERSPROC DeleteBuffers; - PFNGLDELETEPROGRAMPROC DeleteProgram; - PFNGLDELETESHADERPROC DeleteShader; - PFNGLDELETETEXTURESPROC DeleteTextures; - PFNGLDELETEVERTEXARRAYSPROC DeleteVertexArrays; - PFNGLDETACHSHADERPROC DetachShader; - PFNGLDISABLEPROC Disable; - PFNGLDRAWELEMENTSPROC DrawElements; - PFNGLDRAWELEMENTSBASEVERTEXPROC DrawElementsBaseVertex; - PFNGLENABLEPROC Enable; - PFNGLENABLEVERTEXATTRIBARRAYPROC EnableVertexAttribArray; - PFNGLGENBUFFERSPROC GenBuffers; - PFNGLGENTEXTURESPROC GenTextures; - PFNGLGENVERTEXARRAYSPROC GenVertexArrays; - PFNGLGETATTRIBLOCATIONPROC GetAttribLocation; - PFNGLGETERRORPROC GetError; - PFNGLGETINTEGERVPROC GetIntegerv; - PFNGLGETPROGRAMINFOLOGPROC GetProgramInfoLog; - PFNGLGETPROGRAMIVPROC GetProgramiv; - PFNGLGETSHADERINFOLOGPROC GetShaderInfoLog; - PFNGLGETSHADERIVPROC GetShaderiv; - PFNGLGETSTRINGPROC GetString; - PFNGLGETSTRINGIPROC GetStringi; - PFNGLGETUNIFORMLOCATIONPROC GetUniformLocation; - PFNGLISENABLEDPROC IsEnabled; - PFNGLLINKPROGRAMPROC LinkProgram; - PFNGLPIXELSTOREIPROC PixelStorei; - PFNGLPOLYGONMODEPROC PolygonMode; - PFNGLREADPIXELSPROC ReadPixels; - PFNGLSCISSORPROC Scissor; - PFNGLSHADERSOURCEPROC ShaderSource; - PFNGLTEXIMAGE2DPROC TexImage2D; - PFNGLTEXPARAMETERIPROC TexParameteri; - PFNGLUNIFORM1IPROC Uniform1i; - PFNGLUNIFORMMATRIX4FVPROC UniformMatrix4fv; - PFNGLUSEPROGRAMPROC UseProgram; - PFNGLVERTEXATTRIBPOINTERPROC VertexAttribPointer; - PFNGLVIEWPORTPROC Viewport; - } gl; -}; - -GL3W_API extern union GL3WProcs imgl3wProcs; - -/* OpenGL functions */ -#define glActiveTexture imgl3wProcs.gl.ActiveTexture -#define glAttachShader imgl3wProcs.gl.AttachShader -#define glBindBuffer imgl3wProcs.gl.BindBuffer -#define glBindSampler imgl3wProcs.gl.BindSampler -#define glBindTexture imgl3wProcs.gl.BindTexture -#define glBindVertexArray imgl3wProcs.gl.BindVertexArray -#define glBlendEquation imgl3wProcs.gl.BlendEquation -#define glBlendEquationSeparate imgl3wProcs.gl.BlendEquationSeparate -#define glBlendFuncSeparate imgl3wProcs.gl.BlendFuncSeparate -#define glBufferData imgl3wProcs.gl.BufferData -#define glClear imgl3wProcs.gl.Clear -#define glClearColor imgl3wProcs.gl.ClearColor -#define glCompileShader imgl3wProcs.gl.CompileShader -#define glCreateProgram imgl3wProcs.gl.CreateProgram -#define glCreateShader imgl3wProcs.gl.CreateShader -#define glDeleteBuffers imgl3wProcs.gl.DeleteBuffers -#define glDeleteProgram imgl3wProcs.gl.DeleteProgram -#define glDeleteShader imgl3wProcs.gl.DeleteShader -#define glDeleteTextures imgl3wProcs.gl.DeleteTextures -#define glDeleteVertexArrays imgl3wProcs.gl.DeleteVertexArrays -#define glDetachShader imgl3wProcs.gl.DetachShader -#define glDisable imgl3wProcs.gl.Disable -#define glDrawElements imgl3wProcs.gl.DrawElements -#define glDrawElementsBaseVertex imgl3wProcs.gl.DrawElementsBaseVertex -#define glEnable imgl3wProcs.gl.Enable -#define glEnableVertexAttribArray imgl3wProcs.gl.EnableVertexAttribArray -#define glGenBuffers imgl3wProcs.gl.GenBuffers -#define glGenTextures imgl3wProcs.gl.GenTextures -#define glGenVertexArrays imgl3wProcs.gl.GenVertexArrays -#define glGetAttribLocation imgl3wProcs.gl.GetAttribLocation -#define glGetError imgl3wProcs.gl.GetError -#define glGetIntegerv imgl3wProcs.gl.GetIntegerv -#define glGetProgramInfoLog imgl3wProcs.gl.GetProgramInfoLog -#define glGetProgramiv imgl3wProcs.gl.GetProgramiv -#define glGetShaderInfoLog imgl3wProcs.gl.GetShaderInfoLog -#define glGetShaderiv imgl3wProcs.gl.GetShaderiv -#define glGetString imgl3wProcs.gl.GetString -#define glGetStringi imgl3wProcs.gl.GetStringi -#define glGetUniformLocation imgl3wProcs.gl.GetUniformLocation -#define glIsEnabled imgl3wProcs.gl.IsEnabled -#define glLinkProgram imgl3wProcs.gl.LinkProgram -#define glPixelStorei imgl3wProcs.gl.PixelStorei -#define glPolygonMode imgl3wProcs.gl.PolygonMode -#define glReadPixels imgl3wProcs.gl.ReadPixels -#define glScissor imgl3wProcs.gl.Scissor -#define glShaderSource imgl3wProcs.gl.ShaderSource -#define glTexImage2D imgl3wProcs.gl.TexImage2D -#define glTexParameteri imgl3wProcs.gl.TexParameteri -#define glUniform1i imgl3wProcs.gl.Uniform1i -#define glUniformMatrix4fv imgl3wProcs.gl.UniformMatrix4fv -#define glUseProgram imgl3wProcs.gl.UseProgram -#define glVertexAttribPointer imgl3wProcs.gl.VertexAttribPointer -#define glViewport imgl3wProcs.gl.Viewport - -#ifdef __cplusplus -} -#endif - -#endif - -#ifdef IMGL3W_IMPL -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) - -#if defined(_WIN32) -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN 1 -#endif -#include - -static HMODULE libgl; -typedef PROC(__stdcall* GL3WglGetProcAddr)(LPCSTR); -static GL3WglGetProcAddr wgl_get_proc_address; - -static int open_libgl(void) -{ - libgl = LoadLibraryA("opengl32.dll"); - if (!libgl) - return GL3W_ERROR_LIBRARY_OPEN; - wgl_get_proc_address = (GL3WglGetProcAddr)GetProcAddress(libgl, "wglGetProcAddress"); - return GL3W_OK; -} - -static void close_libgl(void) { FreeLibrary(libgl); } -static GL3WglProc get_proc(const char *proc) -{ - GL3WglProc res; - res = (GL3WglProc)wgl_get_proc_address(proc); - if (!res) - res = (GL3WglProc)GetProcAddress(libgl, proc); - return res; -} -#elif defined(__APPLE__) -#include - -static void *libgl; -static int open_libgl(void) -{ - libgl = dlopen("/System/Library/Frameworks/OpenGL.framework/OpenGL", RTLD_LAZY | RTLD_LOCAL); - if (!libgl) - return GL3W_ERROR_LIBRARY_OPEN; - return GL3W_OK; -} - -static void close_libgl(void) { dlclose(libgl); } - -static GL3WglProc get_proc(const char *proc) -{ - GL3WglProc res; - *(void **)(&res) = dlsym(libgl, proc); - return res; -} -#else -#include - -static void *libgl; -static GL3WglProc (*glx_get_proc_address)(const GLubyte *); - -static int open_libgl(void) -{ - libgl = dlopen("libGL.so.1", RTLD_LAZY | RTLD_LOCAL); - if (!libgl) - return GL3W_ERROR_LIBRARY_OPEN; - *(void **)(&glx_get_proc_address) = dlsym(libgl, "glXGetProcAddressARB"); - return GL3W_OK; -} - -static void close_libgl(void) { dlclose(libgl); } - -static GL3WglProc get_proc(const char *proc) -{ - GL3WglProc res; - res = glx_get_proc_address((const GLubyte *)proc); - if (!res) - *(void **)(&res) = dlsym(libgl, proc); - return res; -} -#endif - -static struct { int major, minor; } version; - -static int parse_version(void) -{ - if (!glGetIntegerv) - return GL3W_ERROR_INIT; - glGetIntegerv(GL_MAJOR_VERSION, &version.major); - glGetIntegerv(GL_MINOR_VERSION, &version.minor); - if (version.major < 3) - return GL3W_ERROR_OPENGL_VERSION; - return GL3W_OK; -} - -static void load_procs(GL3WGetProcAddressProc proc); - -int imgl3wInit(void) -{ - int res = open_libgl(); - if (res) - return res; - atexit(close_libgl); - return imgl3wInit2(get_proc); -} - -int imgl3wInit2(GL3WGetProcAddressProc proc) -{ - load_procs(proc); - return parse_version(); -} - -int imgl3wIsSupported(int major, int minor) -{ - if (major < 3) - return 0; - if (version.major == major) - return version.minor >= minor; - return version.major >= major; -} - -GL3WglProc imgl3wGetProcAddress(const char *proc) { return get_proc(proc); } - -static const char *proc_names[] = { - "glActiveTexture", - "glAttachShader", - "glBindBuffer", - "glBindSampler", - "glBindTexture", - "glBindVertexArray", - "glBlendEquation", - "glBlendEquationSeparate", - "glBlendFuncSeparate", - "glBufferData", - "glClear", - "glClearColor", - "glCompileShader", - "glCreateProgram", - "glCreateShader", - "glDeleteBuffers", - "glDeleteProgram", - "glDeleteShader", - "glDeleteTextures", - "glDeleteVertexArrays", - "glDetachShader", - "glDisable", - "glDrawElements", - "glDrawElementsBaseVertex", - "glEnable", - "glEnableVertexAttribArray", - "glGenBuffers", - "glGenTextures", - "glGenVertexArrays", - "glGetAttribLocation", - "glGetError", - "glGetIntegerv", - "glGetProgramInfoLog", - "glGetProgramiv", - "glGetShaderInfoLog", - "glGetShaderiv", - "glGetString", - "glGetStringi", - "glGetUniformLocation", - "glIsEnabled", - "glLinkProgram", - "glPixelStorei", - "glPolygonMode", - "glReadPixels", - "glScissor", - "glShaderSource", - "glTexImage2D", - "glTexParameteri", - "glUniform1i", - "glUniformMatrix4fv", - "glUseProgram", - "glVertexAttribPointer", - "glViewport", -}; - -GL3W_API union GL3WProcs imgl3wProcs; - -static void load_procs(GL3WGetProcAddressProc proc) -{ - size_t i; - for (i = 0; i < ARRAY_SIZE(proc_names); i++) - imgl3wProcs.ptr[i] = proc(proc_names[i]); -} - -#ifdef __cplusplus -} -#endif -#endif diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_osx.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_osx.h deleted file mode 100644 index e4c1d04..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_osx.h +++ /dev/null @@ -1,24 +0,0 @@ -// dear imgui: Platform Backend for OSX / Cocoa -// This needs to be used along with a Renderer (e.g. OpenGL2, OpenGL3, Vulkan, Metal..) -// [ALPHA] Early backend, not well tested. If you want a portable application, prefer using the GLFW or SDL platform Backends on Mac. - -// Implemented features: -// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. -// [X] Platform: OSX clipboard is supported within core Dear ImGui (no specific code in this backend). -// Issues: -// [ ] Platform: Keys are all generally very broken. Best using [event keycode] and not [event characters].. - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -#include "imgui.h" // IMGUI_IMPL_API - -@class NSEvent; -@class NSView; - -IMGUI_IMPL_API bool ImGui_ImplOSX_Init(); -IMGUI_IMPL_API void ImGui_ImplOSX_Shutdown(); -IMGUI_IMPL_API void ImGui_ImplOSX_NewFrame(NSView* _Nullable view); -IMGUI_IMPL_API bool ImGui_ImplOSX_HandleEvent(NSEvent* _Nonnull event, NSView* _Nullable view); diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_osx.mm b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_osx.mm deleted file mode 100644 index 97555e6..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_osx.mm +++ /dev/null @@ -1,387 +0,0 @@ -// dear imgui: Platform Backend for OSX / Cocoa -// This needs to be used along with a Renderer (e.g. OpenGL2, OpenGL3, Vulkan, Metal..) -// [ALPHA] Early backend, not well tested. If you want a portable application, prefer using the GLFW or SDL platform Backends on Mac. - -// Implemented features: -// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. -// [X] Platform: OSX clipboard is supported within core Dear ImGui (no specific code in this backend). -// Issues: -// [ ] Platform: Keys are all generally very broken. Best using [event keycode] and not [event characters].. - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -#include "imgui.h" -#include "imgui_impl_osx.h" -#import -#include - -// CHANGELOG -// (minor and older changes stripped away, please see git history for details) -// 2021-09-21: Use mach_absolute_time as CFAbsoluteTimeGetCurrent can jump backwards. -// 2021-08-17: Calling io.AddFocusEvent() on NSApplicationDidBecomeActiveNotification/NSApplicationDidResignActiveNotification events. -// 2021-06-23: Inputs: Added a fix for shortcuts using CTRL key instead of CMD key. -// 2021-04-19: Inputs: Added a fix for keys remaining stuck in pressed state when CMD-tabbing into different application. -// 2021-01-27: Inputs: Added a fix for mouse position not being reported when mouse buttons other than left one are down. -// 2020-10-28: Inputs: Added a fix for handling keypad-enter key. -// 2020-05-25: Inputs: Added a fix for missing trackpad clicks when done with "soft tap". -// 2019-12-05: Inputs: Added support for ImGuiMouseCursor_NotAllowed mouse cursor. -// 2019-10-11: Inputs: Fix using Backspace key. -// 2019-07-21: Re-added clipboard handlers as they are not enabled by default in core imgui.cpp (reverted 2019-05-18 change). -// 2019-05-28: Inputs: Added mouse cursor shape and visibility support. -// 2019-05-18: Misc: Removed clipboard handlers as they are now supported by core imgui.cpp. -// 2019-05-11: Inputs: Don't filter character values before calling AddInputCharacter() apart from 0xF700..0xFFFF range. -// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window. -// 2018-07-07: Initial version. - -@class ImFocusObserver; - -// Data -static double g_HostClockPeriod = 0.0; -static double g_Time = 0.0; -static NSCursor* g_MouseCursors[ImGuiMouseCursor_COUNT] = {}; -static bool g_MouseCursorHidden = false; -static bool g_MouseJustPressed[ImGuiMouseButton_COUNT] = {}; -static bool g_MouseDown[ImGuiMouseButton_COUNT] = {}; -static ImFocusObserver* g_FocusObserver = NULL; - -// Undocumented methods for creating cursors. -@interface NSCursor() -+ (id)_windowResizeNorthWestSouthEastCursor; -+ (id)_windowResizeNorthEastSouthWestCursor; -+ (id)_windowResizeNorthSouthCursor; -+ (id)_windowResizeEastWestCursor; -@end - -static void InitHostClockPeriod() -{ - struct mach_timebase_info info; - mach_timebase_info(&info); - g_HostClockPeriod = 1e-9 * ((double)info.denom / (double)info.numer); // Period is the reciprocal of frequency. -} - -static double GetMachAbsoluteTimeInSeconds() -{ - return (double)mach_absolute_time() * g_HostClockPeriod; -} - -static void resetKeys() -{ - ImGuiIO& io = ImGui::GetIO(); - memset(io.KeysDown, 0, sizeof(io.KeysDown)); - io.KeyCtrl = io.KeyShift = io.KeyAlt = io.KeySuper = false; -} - -@interface ImFocusObserver : NSObject - -- (void)onApplicationBecomeActive:(NSNotification*)aNotification; -- (void)onApplicationBecomeInactive:(NSNotification*)aNotification; - -@end - -@implementation ImFocusObserver - -- (void)onApplicationBecomeActive:(NSNotification*)aNotification -{ - ImGuiIO& io = ImGui::GetIO(); - io.AddFocusEvent(true); -} - -- (void)onApplicationBecomeInactive:(NSNotification*)aNotification -{ - ImGuiIO& io = ImGui::GetIO(); - io.AddFocusEvent(false); - - // Unfocused applications do not receive input events, therefore we must manually - // release any pressed keys when application loses focus, otherwise they would remain - // stuck in a pressed state. https://github.com/ocornut/imgui/issues/3832 - resetKeys(); -} - -@end - -// Functions -bool ImGui_ImplOSX_Init() -{ - ImGuiIO& io = ImGui::GetIO(); - - // Setup backend capabilities flags - io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional) - //io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used) - //io.BackendFlags |= ImGuiBackendFlags_PlatformHasViewports; // We can create multi-viewports on the Platform side (optional) - //io.BackendFlags |= ImGuiBackendFlags_HasMouseHoveredViewport; // We can set io.MouseHoveredViewport correctly (optional, not easy) - io.BackendPlatformName = "imgui_impl_osx"; - - // Keyboard mapping. Dear ImGui will use those indices to peek into the io.KeyDown[] array. - const int offset_for_function_keys = 256 - 0xF700; - io.KeyMap[ImGuiKey_Tab] = '\t'; - io.KeyMap[ImGuiKey_LeftArrow] = NSLeftArrowFunctionKey + offset_for_function_keys; - io.KeyMap[ImGuiKey_RightArrow] = NSRightArrowFunctionKey + offset_for_function_keys; - io.KeyMap[ImGuiKey_UpArrow] = NSUpArrowFunctionKey + offset_for_function_keys; - io.KeyMap[ImGuiKey_DownArrow] = NSDownArrowFunctionKey + offset_for_function_keys; - io.KeyMap[ImGuiKey_PageUp] = NSPageUpFunctionKey + offset_for_function_keys; - io.KeyMap[ImGuiKey_PageDown] = NSPageDownFunctionKey + offset_for_function_keys; - io.KeyMap[ImGuiKey_Home] = NSHomeFunctionKey + offset_for_function_keys; - io.KeyMap[ImGuiKey_End] = NSEndFunctionKey + offset_for_function_keys; - io.KeyMap[ImGuiKey_Insert] = NSInsertFunctionKey + offset_for_function_keys; - io.KeyMap[ImGuiKey_Delete] = NSDeleteFunctionKey + offset_for_function_keys; - io.KeyMap[ImGuiKey_Backspace] = 127; - io.KeyMap[ImGuiKey_Space] = 32; - io.KeyMap[ImGuiKey_Enter] = 13; - io.KeyMap[ImGuiKey_Escape] = 27; - io.KeyMap[ImGuiKey_KeyPadEnter] = 3; - io.KeyMap[ImGuiKey_A] = 'A'; - io.KeyMap[ImGuiKey_C] = 'C'; - io.KeyMap[ImGuiKey_V] = 'V'; - io.KeyMap[ImGuiKey_X] = 'X'; - io.KeyMap[ImGuiKey_Y] = 'Y'; - io.KeyMap[ImGuiKey_Z] = 'Z'; - - // Load cursors. Some of them are undocumented. - g_MouseCursorHidden = false; - g_MouseCursors[ImGuiMouseCursor_Arrow] = [NSCursor arrowCursor]; - g_MouseCursors[ImGuiMouseCursor_TextInput] = [NSCursor IBeamCursor]; - g_MouseCursors[ImGuiMouseCursor_ResizeAll] = [NSCursor closedHandCursor]; - g_MouseCursors[ImGuiMouseCursor_Hand] = [NSCursor pointingHandCursor]; - g_MouseCursors[ImGuiMouseCursor_NotAllowed] = [NSCursor operationNotAllowedCursor]; - g_MouseCursors[ImGuiMouseCursor_ResizeNS] = [NSCursor respondsToSelector:@selector(_windowResizeNorthSouthCursor)] ? [NSCursor _windowResizeNorthSouthCursor] : [NSCursor resizeUpDownCursor]; - g_MouseCursors[ImGuiMouseCursor_ResizeEW] = [NSCursor respondsToSelector:@selector(_windowResizeEastWestCursor)] ? [NSCursor _windowResizeEastWestCursor] : [NSCursor resizeLeftRightCursor]; - g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = [NSCursor respondsToSelector:@selector(_windowResizeNorthEastSouthWestCursor)] ? [NSCursor _windowResizeNorthEastSouthWestCursor] : [NSCursor closedHandCursor]; - g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = [NSCursor respondsToSelector:@selector(_windowResizeNorthWestSouthEastCursor)] ? [NSCursor _windowResizeNorthWestSouthEastCursor] : [NSCursor closedHandCursor]; - - // Note that imgui.cpp also include default OSX clipboard handlers which can be enabled - // by adding '#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS' in imconfig.h and adding '-framework ApplicationServices' to your linker command-line. - // Since we are already in ObjC land here, it is easy for us to add a clipboard handler using the NSPasteboard api. - io.SetClipboardTextFn = [](void*, const char* str) -> void - { - NSPasteboard* pasteboard = [NSPasteboard generalPasteboard]; - [pasteboard declareTypes:[NSArray arrayWithObject:NSPasteboardTypeString] owner:nil]; - [pasteboard setString:[NSString stringWithUTF8String:str] forType:NSPasteboardTypeString]; - }; - - io.GetClipboardTextFn = [](void*) -> const char* - { - NSPasteboard* pasteboard = [NSPasteboard generalPasteboard]; - NSString* available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:NSPasteboardTypeString]]; - if (![available isEqualToString:NSPasteboardTypeString]) - return NULL; - - NSString* string = [pasteboard stringForType:NSPasteboardTypeString]; - if (string == nil) - return NULL; - - const char* string_c = (const char*)[string UTF8String]; - size_t string_len = strlen(string_c); - static ImVector s_clipboard; - s_clipboard.resize((int)string_len + 1); - strcpy(s_clipboard.Data, string_c); - return s_clipboard.Data; - }; - - g_FocusObserver = [[ImFocusObserver alloc] init]; - [[NSNotificationCenter defaultCenter] addObserver:g_FocusObserver - selector:@selector(onApplicationBecomeActive:) - name:NSApplicationDidBecomeActiveNotification - object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:g_FocusObserver - selector:@selector(onApplicationBecomeInactive:) - name:NSApplicationDidResignActiveNotification - object:nil]; - - return true; -} - -void ImGui_ImplOSX_Shutdown() -{ - g_FocusObserver = NULL; -} - -static void ImGui_ImplOSX_UpdateMouseCursorAndButtons() -{ - // Update buttons - ImGuiIO& io = ImGui::GetIO(); - for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) - { - // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame. - io.MouseDown[i] = g_MouseJustPressed[i] || g_MouseDown[i]; - g_MouseJustPressed[i] = false; - } - - if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) - return; - - ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor(); - if (io.MouseDrawCursor || imgui_cursor == ImGuiMouseCursor_None) - { - // Hide OS mouse cursor if imgui is drawing it or if it wants no cursor - if (!g_MouseCursorHidden) - { - g_MouseCursorHidden = true; - [NSCursor hide]; - } - } - else - { - // Show OS mouse cursor - [g_MouseCursors[g_MouseCursors[imgui_cursor] ? imgui_cursor : ImGuiMouseCursor_Arrow] set]; - if (g_MouseCursorHidden) - { - g_MouseCursorHidden = false; - [NSCursor unhide]; - } - } -} - -void ImGui_ImplOSX_NewFrame(NSView* view) -{ - // Setup display size - ImGuiIO& io = ImGui::GetIO(); - if (view) - { - const float dpi = (float)[view.window backingScaleFactor]; - io.DisplaySize = ImVec2((float)view.bounds.size.width, (float)view.bounds.size.height); - io.DisplayFramebufferScale = ImVec2(dpi, dpi); - } - - // Setup time step - if (g_Time == 0.0) - { - InitHostClockPeriod(); - g_Time = GetMachAbsoluteTimeInSeconds(); - } - double current_time = GetMachAbsoluteTimeInSeconds(); - io.DeltaTime = (float)(current_time - g_Time); - g_Time = current_time; - - ImGui_ImplOSX_UpdateMouseCursorAndButtons(); -} - -static int mapCharacterToKey(int c) -{ - if (c >= 'a' && c <= 'z') - return c - 'a' + 'A'; - if (c == 25) // SHIFT+TAB -> TAB - return 9; - if (c >= 0 && c < 256) - return c; - if (c >= 0xF700 && c < 0xF700 + 256) - return c - 0xF700 + 256; - return -1; -} - -bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view) -{ - ImGuiIO& io = ImGui::GetIO(); - - if (event.type == NSEventTypeLeftMouseDown || event.type == NSEventTypeRightMouseDown || event.type == NSEventTypeOtherMouseDown) - { - int button = (int)[event buttonNumber]; - if (button >= 0 && button < IM_ARRAYSIZE(g_MouseDown)) - g_MouseDown[button] = g_MouseJustPressed[button] = true; - return io.WantCaptureMouse; - } - - if (event.type == NSEventTypeLeftMouseUp || event.type == NSEventTypeRightMouseUp || event.type == NSEventTypeOtherMouseUp) - { - int button = (int)[event buttonNumber]; - if (button >= 0 && button < IM_ARRAYSIZE(g_MouseDown)) - g_MouseDown[button] = false; - return io.WantCaptureMouse; - } - - if (event.type == NSEventTypeMouseMoved || event.type == NSEventTypeLeftMouseDragged || event.type == NSEventTypeRightMouseDragged || event.type == NSEventTypeOtherMouseDragged) - { - NSPoint mousePoint = event.locationInWindow; - mousePoint = [view convertPoint:mousePoint fromView:nil]; - mousePoint = NSMakePoint(mousePoint.x, view.bounds.size.height - mousePoint.y); - io.MousePos = ImVec2((float)mousePoint.x, (float)mousePoint.y); - } - - if (event.type == NSEventTypeScrollWheel) - { - double wheel_dx = 0.0; - double wheel_dy = 0.0; - - #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 - if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) - { - wheel_dx = [event scrollingDeltaX]; - wheel_dy = [event scrollingDeltaY]; - if ([event hasPreciseScrollingDeltas]) - { - wheel_dx *= 0.1; - wheel_dy *= 0.1; - } - } - else - #endif // MAC_OS_X_VERSION_MAX_ALLOWED - { - wheel_dx = [event deltaX]; - wheel_dy = [event deltaY]; - } - - if (fabs(wheel_dx) > 0.0) - io.MouseWheelH += (float)wheel_dx * 0.1f; - if (fabs(wheel_dy) > 0.0) - io.MouseWheel += (float)wheel_dy * 0.1f; - return io.WantCaptureMouse; - } - - // FIXME: All the key handling is wrong and broken. Refer to GLFW's cocoa_init.mm and cocoa_window.mm. - if (event.type == NSEventTypeKeyDown) - { - NSString* str = [event characters]; - NSUInteger len = [str length]; - for (NSUInteger i = 0; i < len; i++) - { - int c = [str characterAtIndex:i]; - if (!io.KeySuper && !(c >= 0xF700 && c <= 0xFFFF) && c != 127) - io.AddInputCharacter((unsigned int)c); - - // We must reset in case we're pressing a sequence of special keys while keeping the command pressed - int key = mapCharacterToKey(c); - if (key != -1 && key < 256 && !io.KeySuper) - resetKeys(); - if (key != -1) - io.KeysDown[key] = true; - } - return io.WantCaptureKeyboard; - } - - if (event.type == NSEventTypeKeyUp) - { - NSString* str = [event characters]; - NSUInteger len = [str length]; - for (NSUInteger i = 0; i < len; i++) - { - int c = [str characterAtIndex:i]; - int key = mapCharacterToKey(c); - if (key != -1) - io.KeysDown[key] = false; - } - return io.WantCaptureKeyboard; - } - - if (event.type == NSEventTypeFlagsChanged) - { - unsigned int flags = [event modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask; - - bool oldKeyCtrl = io.KeyCtrl; - bool oldKeyShift = io.KeyShift; - bool oldKeyAlt = io.KeyAlt; - bool oldKeySuper = io.KeySuper; - io.KeyCtrl = flags & NSEventModifierFlagControl; - io.KeyShift = flags & NSEventModifierFlagShift; - io.KeyAlt = flags & NSEventModifierFlagOption; - io.KeySuper = flags & NSEventModifierFlagCommand; - - // We must reset them as we will not receive any keyUp event if they where pressed with a modifier - if ((oldKeyShift && !io.KeyShift) || (oldKeyCtrl && !io.KeyCtrl) || (oldKeyAlt && !io.KeyAlt) || (oldKeySuper && !io.KeySuper)) - resetKeys(); - return io.WantCaptureKeyboard; - } - - return false; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_sdl.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_sdl.cpp deleted file mode 100644 index b725e0a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_sdl.cpp +++ /dev/null @@ -1,449 +0,0 @@ -// dear imgui: Platform Backend for SDL2 -// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) -// (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.) -// (Prefer SDL 2.0.5+ for full feature support.) - -// Implemented features: -// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. -// [X] Platform: Clipboard support. -// [X] Platform: Keyboard arrays indexed using SDL_SCANCODE_* codes, e.g. ImGui::IsKeyPressed(SDL_SCANCODE_SPACE). -// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. -// Missing features: -// [ ] Platform: SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME. - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -// CHANGELOG -// (minor and older changes stripped away, please see git history for details) -// 2021-08-17: Calling io.AddFocusEvent() on SDL_WINDOWEVENT_FOCUS_GAINED/SDL_WINDOWEVENT_FOCUS_LOST. -// 2021-07-29: Inputs: MousePos is correctly reported when the host platform window is hovered but not focused (using SDL_GetMouseFocus() + SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, requires SDL 2.0.5+) -// 2021-06-29: *BREAKING CHANGE* Removed 'SDL_Window* window' parameter to ImGui_ImplSDL2_NewFrame() which was unnecessary. -// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX). -// 2021-03-22: Rework global mouse pos availability check listing supported platforms explicitly, effectively fixing mouse access on Raspberry Pi. (#2837, #3950) -// 2020-05-25: Misc: Report a zero display-size when window is minimized, to be consistent with other backends. -// 2020-02-20: Inputs: Fixed mapping for ImGuiKey_KeyPadEnter (using SDL_SCANCODE_KP_ENTER instead of SDL_SCANCODE_RETURN2). -// 2019-12-17: Inputs: On Wayland, use SDL_GetMouseState (because there is no global mouse state). -// 2019-12-05: Inputs: Added support for ImGuiMouseCursor_NotAllowed mouse cursor. -// 2019-07-21: Inputs: Added mapping for ImGuiKey_KeyPadEnter. -// 2019-04-23: Inputs: Added support for SDL_GameController (if ImGuiConfigFlags_NavEnableGamepad is set by user application). -// 2019-03-12: Misc: Preserve DisplayFramebufferScale when main window is minimized. -// 2018-12-21: Inputs: Workaround for Android/iOS which don't seem to handle focus related calls. -// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window. -// 2018-11-14: Changed the signature of ImGui_ImplSDL2_ProcessEvent() to take a 'const SDL_Event*'. -// 2018-08-01: Inputs: Workaround for Emscripten which doesn't seem to handle focus related calls. -// 2018-06-29: Inputs: Added support for the ImGuiMouseCursor_Hand cursor. -// 2018-06-08: Misc: Extracted imgui_impl_sdl.cpp/.h away from the old combined SDL2+OpenGL/Vulkan examples. -// 2018-06-08: Misc: ImGui_ImplSDL2_InitForOpenGL() now takes a SDL_GLContext parameter. -// 2018-05-09: Misc: Fixed clipboard paste memory leak (we didn't call SDL_FreeMemory on the data returned by SDL_GetClipboardText). -// 2018-03-20: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors flag + honor ImGuiConfigFlags_NoMouseCursorChange flag. -// 2018-02-16: Inputs: Added support for mouse cursors, honoring ImGui::GetMouseCursor() value. -// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves. -// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space. -// 2018-02-05: Misc: Using SDL_GetPerformanceCounter() instead of SDL_GetTicks() to be able to handle very high framerate (1000+ FPS). -// 2018-02-05: Inputs: Keyboard mapping is using scancodes everywhere instead of a confusing mixture of keycodes and scancodes. -// 2018-01-20: Inputs: Added Horizontal Mouse Wheel support. -// 2018-01-19: Inputs: When available (SDL 2.0.4+) using SDL_CaptureMouse() to retrieve coordinates outside of client area when dragging. Otherwise (SDL 2.0.3 and before) testing for SDL_WINDOW_INPUT_FOCUS instead of SDL_WINDOW_MOUSE_FOCUS. -// 2018-01-18: Inputs: Added mapping for ImGuiKey_Insert. -// 2017-08-25: Inputs: MousePos set to -FLT_MAX,-FLT_MAX when mouse is unavailable/missing (instead of -1,-1). -// 2016-10-15: Misc: Added a void* user_data parameter to Clipboard function handlers. - -#include "imgui.h" -#include "imgui_impl_sdl.h" - -// SDL -#include -#include -#if defined(__APPLE__) -#include -#endif - -#if SDL_VERSION_ATLEAST(2,0,4) && !defined(__EMSCRIPTEN__) && !defined(__ANDROID__) && !(defined(__APPLE__) && TARGET_OS_IOS) -#define SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE 1 -#else -#define SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE 0 -#endif -#define SDL_HAS_MOUSE_FOCUS_CLICKTHROUGH SDL_VERSION_ATLEAST(2,0,5) -#define SDL_HAS_VULKAN SDL_VERSION_ATLEAST(2,0,6) - -// SDL Data -struct ImGui_ImplSDL2_Data -{ - SDL_Window* Window; - Uint64 Time; - bool MousePressed[3]; - SDL_Cursor* MouseCursors[ImGuiMouseCursor_COUNT]; - char* ClipboardTextData; - bool MouseCanUseGlobalState; - - ImGui_ImplSDL2_Data() { memset(this, 0, sizeof(*this)); } -}; - -// Backend data stored in io.BackendPlatformUserData to allow support for multiple Dear ImGui contexts -// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts. -// FIXME: multi-context support is not well tested and probably dysfunctional in this backend. -// FIXME: some shared resources (mouse cursor shape, gamepad) are mishandled when using multi-context. -static ImGui_ImplSDL2_Data* ImGui_ImplSDL2_GetBackendData() -{ - return ImGui::GetCurrentContext() ? (ImGui_ImplSDL2_Data*)ImGui::GetIO().BackendPlatformUserData : NULL; -} - -// Functions -static const char* ImGui_ImplSDL2_GetClipboardText(void*) -{ - ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData(); - if (bd->ClipboardTextData) - SDL_free(bd->ClipboardTextData); - bd->ClipboardTextData = SDL_GetClipboardText(); - return bd->ClipboardTextData; -} - -static void ImGui_ImplSDL2_SetClipboardText(void*, const char* text) -{ - SDL_SetClipboardText(text); -} - -// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. -// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. -// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. -// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. -// If you have multiple SDL events and some of them are not meant to be used by dear imgui, you may need to filter events based on their windowID field. -bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event) -{ - ImGuiIO& io = ImGui::GetIO(); - ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData(); - - switch (event->type) - { - case SDL_MOUSEWHEEL: - { - if (event->wheel.x > 0) io.MouseWheelH += 1; - if (event->wheel.x < 0) io.MouseWheelH -= 1; - if (event->wheel.y > 0) io.MouseWheel += 1; - if (event->wheel.y < 0) io.MouseWheel -= 1; - return true; - } - case SDL_MOUSEBUTTONDOWN: - { - if (event->button.button == SDL_BUTTON_LEFT) { bd->MousePressed[0] = true; } - if (event->button.button == SDL_BUTTON_RIGHT) { bd->MousePressed[1] = true; } - if (event->button.button == SDL_BUTTON_MIDDLE) { bd->MousePressed[2] = true; } - return true; - } - case SDL_TEXTINPUT: - { - io.AddInputCharactersUTF8(event->text.text); - return true; - } - case SDL_KEYDOWN: - case SDL_KEYUP: - { - int key = event->key.keysym.scancode; - IM_ASSERT(key >= 0 && key < IM_ARRAYSIZE(io.KeysDown)); - io.KeysDown[key] = (event->type == SDL_KEYDOWN); - io.KeyShift = ((SDL_GetModState() & KMOD_SHIFT) != 0); - io.KeyCtrl = ((SDL_GetModState() & KMOD_CTRL) != 0); - io.KeyAlt = ((SDL_GetModState() & KMOD_ALT) != 0); -#ifdef _WIN32 - io.KeySuper = false; -#else - io.KeySuper = ((SDL_GetModState() & KMOD_GUI) != 0); -#endif - return true; - } - case SDL_WINDOWEVENT: - { - if (event->window.event == SDL_WINDOWEVENT_FOCUS_GAINED) - io.AddFocusEvent(true); - else if (event->window.event == SDL_WINDOWEVENT_FOCUS_LOST) - io.AddFocusEvent(false); - return true; - } - } - return false; -} - -static bool ImGui_ImplSDL2_Init(SDL_Window* window) -{ - ImGuiIO& io = ImGui::GetIO(); - IM_ASSERT(io.BackendPlatformUserData == NULL && "Already initialized a platform backend!"); - - // Check and store if we are on a SDL backend that supports global mouse position - // ("wayland" and "rpi" don't support it, but we chose to use a white-list instead of a black-list) - bool mouse_can_use_global_state = false; -#if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE - const char* sdl_backend = SDL_GetCurrentVideoDriver(); - const char* global_mouse_whitelist[] = { "windows", "cocoa", "x11", "DIVE", "VMAN" }; - for (int n = 0; n < IM_ARRAYSIZE(global_mouse_whitelist); n++) - if (strncmp(sdl_backend, global_mouse_whitelist[n], strlen(global_mouse_whitelist[n])) == 0) - mouse_can_use_global_state = true; -#endif - - // Setup backend capabilities flags - ImGui_ImplSDL2_Data* bd = IM_NEW(ImGui_ImplSDL2_Data)(); - io.BackendPlatformUserData = (void*)bd; - io.BackendPlatformName = "imgui_impl_sdl"; - io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional) - io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used) - - bd->Window = window; - bd->MouseCanUseGlobalState = mouse_can_use_global_state; - - // Keyboard mapping. Dear ImGui will use those indices to peek into the io.KeysDown[] array. - io.KeyMap[ImGuiKey_Tab] = SDL_SCANCODE_TAB; - io.KeyMap[ImGuiKey_LeftArrow] = SDL_SCANCODE_LEFT; - io.KeyMap[ImGuiKey_RightArrow] = SDL_SCANCODE_RIGHT; - io.KeyMap[ImGuiKey_UpArrow] = SDL_SCANCODE_UP; - io.KeyMap[ImGuiKey_DownArrow] = SDL_SCANCODE_DOWN; - io.KeyMap[ImGuiKey_PageUp] = SDL_SCANCODE_PAGEUP; - io.KeyMap[ImGuiKey_PageDown] = SDL_SCANCODE_PAGEDOWN; - io.KeyMap[ImGuiKey_Home] = SDL_SCANCODE_HOME; - io.KeyMap[ImGuiKey_End] = SDL_SCANCODE_END; - io.KeyMap[ImGuiKey_Insert] = SDL_SCANCODE_INSERT; - io.KeyMap[ImGuiKey_Delete] = SDL_SCANCODE_DELETE; - io.KeyMap[ImGuiKey_Backspace] = SDL_SCANCODE_BACKSPACE; - io.KeyMap[ImGuiKey_Space] = SDL_SCANCODE_SPACE; - io.KeyMap[ImGuiKey_Enter] = SDL_SCANCODE_RETURN; - io.KeyMap[ImGuiKey_Escape] = SDL_SCANCODE_ESCAPE; - io.KeyMap[ImGuiKey_KeyPadEnter] = SDL_SCANCODE_KP_ENTER; - io.KeyMap[ImGuiKey_A] = SDL_SCANCODE_A; - io.KeyMap[ImGuiKey_C] = SDL_SCANCODE_C; - io.KeyMap[ImGuiKey_V] = SDL_SCANCODE_V; - io.KeyMap[ImGuiKey_X] = SDL_SCANCODE_X; - io.KeyMap[ImGuiKey_Y] = SDL_SCANCODE_Y; - io.KeyMap[ImGuiKey_Z] = SDL_SCANCODE_Z; - - io.SetClipboardTextFn = ImGui_ImplSDL2_SetClipboardText; - io.GetClipboardTextFn = ImGui_ImplSDL2_GetClipboardText; - io.ClipboardUserData = NULL; - - // Load mouse cursors - bd->MouseCursors[ImGuiMouseCursor_Arrow] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW); - bd->MouseCursors[ImGuiMouseCursor_TextInput] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM); - bd->MouseCursors[ImGuiMouseCursor_ResizeAll] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL); - bd->MouseCursors[ImGuiMouseCursor_ResizeNS] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENS); - bd->MouseCursors[ImGuiMouseCursor_ResizeEW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEWE); - bd->MouseCursors[ImGuiMouseCursor_ResizeNESW] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENESW); - bd->MouseCursors[ImGuiMouseCursor_ResizeNWSE] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZENWSE); - bd->MouseCursors[ImGuiMouseCursor_Hand] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND); - bd->MouseCursors[ImGuiMouseCursor_NotAllowed] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NO); - -#ifdef _WIN32 - SDL_SysWMinfo info; - SDL_VERSION(&info.version); - if (SDL_GetWindowWMInfo(window, &info)) - io.ImeWindowHandle = info.info.win.window; -#else - (void)window; -#endif - - // Set SDL hint to receive mouse click events on window focus, otherwise SDL doesn't emit the event. - // Without this, when clicking to gain focus, our widgets wouldn't activate even though they showed as hovered. - // (This is unfortunately a global SDL setting, so enabling it might have a side-effect on your application. - // It is unlikely to make a difference, but if your app absolutely needs to ignore the initial on-focus click: - // you can ignore SDL_MOUSEBUTTONDOWN events coming right after a SDL_WINDOWEVENT_FOCUS_GAINED) -#if SDL_HAS_MOUSE_FOCUS_CLICKTHROUGH - SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1"); -#endif - - return true; -} - -bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context) -{ - IM_UNUSED(sdl_gl_context); // Viewport branch will need this. - return ImGui_ImplSDL2_Init(window); -} - -bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window) -{ -#if !SDL_HAS_VULKAN - IM_ASSERT(0 && "Unsupported"); -#endif - return ImGui_ImplSDL2_Init(window); -} - -bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window) -{ -#if !defined(_WIN32) - IM_ASSERT(0 && "Unsupported"); -#endif - return ImGui_ImplSDL2_Init(window); -} - -bool ImGui_ImplSDL2_InitForMetal(SDL_Window* window) -{ - return ImGui_ImplSDL2_Init(window); -} - -bool ImGui_ImplSDL2_InitForSDLRenderer(SDL_Window* window) -{ - return ImGui_ImplSDL2_Init(window); -} - -void ImGui_ImplSDL2_Shutdown() -{ - ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData(); - IM_ASSERT(bd != NULL && "No platform backend to shutdown, or already shutdown?"); - ImGuiIO& io = ImGui::GetIO(); - - if (bd->ClipboardTextData) - SDL_free(bd->ClipboardTextData); - for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++) - SDL_FreeCursor(bd->MouseCursors[cursor_n]); - - io.BackendPlatformName = NULL; - io.BackendPlatformUserData = NULL; - IM_DELETE(bd); -} - -static void ImGui_ImplSDL2_UpdateMousePosAndButtons() -{ - ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData(); - ImGuiIO& io = ImGui::GetIO(); - - ImVec2 mouse_pos_prev = io.MousePos; - io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX); - - // Update mouse buttons - int mouse_x_local, mouse_y_local; - Uint32 mouse_buttons = SDL_GetMouseState(&mouse_x_local, &mouse_y_local); - io.MouseDown[0] = bd->MousePressed[0] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0; // If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame. - io.MouseDown[1] = bd->MousePressed[1] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0; - io.MouseDown[2] = bd->MousePressed[2] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0; - bd->MousePressed[0] = bd->MousePressed[1] = bd->MousePressed[2] = false; - - // Obtain focused and hovered window. We forward mouse input when focused or when hovered (and no other window is capturing) -#if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE - SDL_Window* focused_window = SDL_GetKeyboardFocus(); - SDL_Window* hovered_window = SDL_HAS_MOUSE_FOCUS_CLICKTHROUGH ? SDL_GetMouseFocus() : NULL; // This is better but is only reliably useful with SDL 2.0.5+ and SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH. - SDL_Window* mouse_window = NULL; - if (hovered_window && bd->Window == hovered_window) - mouse_window = hovered_window; - else if (focused_window && bd->Window == focused_window) - mouse_window = focused_window; - - // SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger other operations outside - SDL_CaptureMouse(ImGui::IsAnyMouseDown() ? SDL_TRUE : SDL_FALSE); -#else - // SDL 2.0.3 and non-windowed systems: single-viewport only - SDL_Window* mouse_window = (SDL_GetWindowFlags(bd->Window) & SDL_WINDOW_INPUT_FOCUS) ? bd->Window : NULL; -#endif - - if (mouse_window == NULL) - return; - - // Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user) - if (io.WantSetMousePos) - SDL_WarpMouseInWindow(bd->Window, (int)mouse_pos_prev.x, (int)mouse_pos_prev.y); - - // Set Dear ImGui mouse position from OS position + get buttons. (this is the common behavior) - if (bd->MouseCanUseGlobalState) - { - // Single-viewport mode: mouse position in client window coordinates (io.MousePos is (0,0) when the mouse is on the upper-left corner of the app window) - // Unlike local position obtained earlier this will be valid when straying out of bounds. - int mouse_x_global, mouse_y_global; - SDL_GetGlobalMouseState(&mouse_x_global, &mouse_y_global); - int window_x, window_y; - SDL_GetWindowPosition(mouse_window, &window_x, &window_y); - io.MousePos = ImVec2((float)(mouse_x_global - window_x), (float)(mouse_y_global - window_y)); - } - else - { - io.MousePos = ImVec2((float)mouse_x_local, (float)mouse_y_local); - } -} - -static void ImGui_ImplSDL2_UpdateMouseCursor() -{ - ImGuiIO& io = ImGui::GetIO(); - if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) - return; - ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData(); - - ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor(); - if (io.MouseDrawCursor || imgui_cursor == ImGuiMouseCursor_None) - { - // Hide OS mouse cursor if imgui is drawing it or if it wants no cursor - SDL_ShowCursor(SDL_FALSE); - } - else - { - // Show OS mouse cursor - SDL_SetCursor(bd->MouseCursors[imgui_cursor] ? bd->MouseCursors[imgui_cursor] : bd->MouseCursors[ImGuiMouseCursor_Arrow]); - SDL_ShowCursor(SDL_TRUE); - } -} - -static void ImGui_ImplSDL2_UpdateGamepads() -{ - ImGuiIO& io = ImGui::GetIO(); - memset(io.NavInputs, 0, sizeof(io.NavInputs)); - if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0) - return; - - // Get gamepad - SDL_GameController* game_controller = SDL_GameControllerOpen(0); - if (!game_controller) - { - io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad; - return; - } - - // Update gamepad inputs - #define MAP_BUTTON(NAV_NO, BUTTON_NO) { io.NavInputs[NAV_NO] = (SDL_GameControllerGetButton(game_controller, BUTTON_NO) != 0) ? 1.0f : 0.0f; } - #define MAP_ANALOG(NAV_NO, AXIS_NO, V0, V1) { float vn = (float)(SDL_GameControllerGetAxis(game_controller, AXIS_NO) - V0) / (float)(V1 - V0); if (vn > 1.0f) vn = 1.0f; if (vn > 0.0f && io.NavInputs[NAV_NO] < vn) io.NavInputs[NAV_NO] = vn; } - const int thumb_dead_zone = 8000; // SDL_gamecontroller.h suggests using this value. - MAP_BUTTON(ImGuiNavInput_Activate, SDL_CONTROLLER_BUTTON_A); // Cross / A - MAP_BUTTON(ImGuiNavInput_Cancel, SDL_CONTROLLER_BUTTON_B); // Circle / B - MAP_BUTTON(ImGuiNavInput_Menu, SDL_CONTROLLER_BUTTON_X); // Square / X - MAP_BUTTON(ImGuiNavInput_Input, SDL_CONTROLLER_BUTTON_Y); // Triangle / Y - MAP_BUTTON(ImGuiNavInput_DpadLeft, SDL_CONTROLLER_BUTTON_DPAD_LEFT); // D-Pad Left - MAP_BUTTON(ImGuiNavInput_DpadRight, SDL_CONTROLLER_BUTTON_DPAD_RIGHT); // D-Pad Right - MAP_BUTTON(ImGuiNavInput_DpadUp, SDL_CONTROLLER_BUTTON_DPAD_UP); // D-Pad Up - MAP_BUTTON(ImGuiNavInput_DpadDown, SDL_CONTROLLER_BUTTON_DPAD_DOWN); // D-Pad Down - MAP_BUTTON(ImGuiNavInput_FocusPrev, SDL_CONTROLLER_BUTTON_LEFTSHOULDER); // L1 / LB - MAP_BUTTON(ImGuiNavInput_FocusNext, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER); // R1 / RB - MAP_BUTTON(ImGuiNavInput_TweakSlow, SDL_CONTROLLER_BUTTON_LEFTSHOULDER); // L1 / LB - MAP_BUTTON(ImGuiNavInput_TweakFast, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER); // R1 / RB - MAP_ANALOG(ImGuiNavInput_LStickLeft, SDL_CONTROLLER_AXIS_LEFTX, -thumb_dead_zone, -32768); - MAP_ANALOG(ImGuiNavInput_LStickRight, SDL_CONTROLLER_AXIS_LEFTX, +thumb_dead_zone, +32767); - MAP_ANALOG(ImGuiNavInput_LStickUp, SDL_CONTROLLER_AXIS_LEFTY, -thumb_dead_zone, -32767); - MAP_ANALOG(ImGuiNavInput_LStickDown, SDL_CONTROLLER_AXIS_LEFTY, +thumb_dead_zone, +32767); - - io.BackendFlags |= ImGuiBackendFlags_HasGamepad; - #undef MAP_BUTTON - #undef MAP_ANALOG -} - -void ImGui_ImplSDL2_NewFrame() -{ - ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData(); - IM_ASSERT(bd != NULL && "Did you call ImGui_ImplSDL2_Init()?"); - ImGuiIO& io = ImGui::GetIO(); - - // Setup display size (every frame to accommodate for window resizing) - int w, h; - int display_w, display_h; - SDL_GetWindowSize(bd->Window, &w, &h); - if (SDL_GetWindowFlags(bd->Window) & SDL_WINDOW_MINIMIZED) - w = h = 0; - SDL_GL_GetDrawableSize(bd->Window, &display_w, &display_h); - io.DisplaySize = ImVec2((float)w, (float)h); - if (w > 0 && h > 0) - io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h); - - // Setup time step (we don't use SDL_GetTicks() because it is using millisecond resolution) - static Uint64 frequency = SDL_GetPerformanceFrequency(); - Uint64 current_time = SDL_GetPerformanceCounter(); - io.DeltaTime = bd->Time > 0 ? (float)((double)(current_time - bd->Time) / frequency) : (float)(1.0f / 60.0f); - bd->Time = current_time; - - ImGui_ImplSDL2_UpdateMousePosAndButtons(); - ImGui_ImplSDL2_UpdateMouseCursor(); - - // Update game controllers (if enabled and available) - ImGui_ImplSDL2_UpdateGamepads(); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_sdl.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_sdl.h deleted file mode 100644 index d2439eb..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_sdl.h +++ /dev/null @@ -1,35 +0,0 @@ -// dear imgui: Platform Backend for SDL2 -// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) -// (Info: SDL2 is a cross-platform general purpose library for handling windows, inputs, graphics context creation, etc.) - -// Implemented features: -// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. -// [X] Platform: Clipboard support. -// [X] Platform: Keyboard arrays indexed using SDL_SCANCODE_* codes, e.g. ImGui::IsKeyPressed(SDL_SCANCODE_SPACE). -// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. -// Missing features: -// [ ] Platform: SDL2 handling of IME under Windows appears to be broken and it explicitly disable the regular Windows IME. You can restore Windows IME by compiling SDL with SDL_DISABLE_WINDOWS_IME. - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -#pragma once -#include "imgui.h" // IMGUI_IMPL_API - -struct SDL_Window; -typedef union SDL_Event SDL_Event; - -IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context); -IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window); -IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForD3D(SDL_Window* window); -IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForMetal(SDL_Window* window); -IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForSDLRenderer(SDL_Window* window); -IMGUI_IMPL_API void ImGui_ImplSDL2_Shutdown(); -IMGUI_IMPL_API void ImGui_ImplSDL2_NewFrame(); -IMGUI_IMPL_API bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event); - -#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS -static inline void ImGui_ImplSDL2_NewFrame(SDL_Window*) { ImGui_ImplSDL2_NewFrame(); } // 1.84: removed unnecessary parameter -#endif diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_sdlrenderer.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_sdlrenderer.cpp deleted file mode 100644 index bfc2b67..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_sdlrenderer.cpp +++ /dev/null @@ -1,238 +0,0 @@ -// dear imgui: Renderer Backend for SDL_Renderer -// (Requires: SDL 2.0.17+) - -// Important to understand: SDL_Renderer is an _optional_ component of SDL. We do not recommend you use SDL_Renderer -// because it provide a rather limited API to the end-user. We provide this backend for the sake of completeness. -// For a multi-platform app consider using e.g. SDL+DirectX on Windows and SDL+OpenGL on Linux/OSX. - -// Implemented features: -// [X] Renderer: User texture binding. Use 'SDL_Texture*' as ImTextureID. Read the FAQ about ImTextureID! -// Missing features: -// [ ] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. - -// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -// CHANGELOG -// 2021-10-06: Backup and restore modified ClipRect/Viewport. -// 2021-09-21: Initial version. - -#include "imgui.h" -#include "imgui_impl_sdlrenderer.h" -#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier -#include // intptr_t -#else -#include // intptr_t -#endif - -// SDL -#include -#if !SDL_VERSION_ATLEAST(2,0,17) -#error This backend requires SDL 2.0.17+ because of SDL_RenderGeometry() function -#endif - -// SDL_Renderer data -struct ImGui_ImplSDLRenderer_Data -{ - SDL_Renderer* SDLRenderer; - SDL_Texture* FontTexture; - ImGui_ImplSDLRenderer_Data() { memset(this, 0, sizeof(*this)); } -}; - -// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts -// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts. -static ImGui_ImplSDLRenderer_Data* ImGui_ImplSDLRenderer_GetBackendData() -{ - return ImGui::GetCurrentContext() ? (ImGui_ImplSDLRenderer_Data*)ImGui::GetIO().BackendRendererUserData : NULL; -} - -// Functions -bool ImGui_ImplSDLRenderer_Init(SDL_Renderer* renderer) -{ - ImGuiIO& io = ImGui::GetIO(); - IM_ASSERT(io.BackendRendererUserData == NULL && "Already initialized a renderer backend!"); - IM_ASSERT(renderer != NULL && "SDL_Renderer not initialized!"); - - // Setup backend capabilities flags - ImGui_ImplSDLRenderer_Data* bd = IM_NEW(ImGui_ImplSDLRenderer_Data)(); - io.BackendRendererUserData = (void*)bd; - io.BackendRendererName = "imgui_impl_sdlrenderer"; - - bd->SDLRenderer = renderer; - - return true; -} - -void ImGui_ImplSDLRenderer_Shutdown() -{ - ImGui_ImplSDLRenderer_Data* bd = ImGui_ImplSDLRenderer_GetBackendData(); - IM_ASSERT(bd != NULL && "No renderer backend to shutdown, or already shutdown?"); - ImGuiIO& io = ImGui::GetIO(); - - ImGui_ImplSDLRenderer_DestroyDeviceObjects(); - - io.BackendRendererName = NULL; - io.BackendRendererUserData = NULL; - IM_DELETE(bd); -} - -static void ImGui_ImplSDLRenderer_SetupRenderState() -{ - ImGui_ImplSDLRenderer_Data* bd = ImGui_ImplSDLRenderer_GetBackendData(); - - // Clear out any viewports and cliprect set by the user - // FIXME: Technically speaking there are lots of other things we could backup/setup/restore during our render process. - SDL_RenderSetViewport(bd->SDLRenderer, NULL); - SDL_RenderSetClipRect(bd->SDLRenderer, NULL); -} - -void ImGui_ImplSDLRenderer_NewFrame() -{ - ImGui_ImplSDLRenderer_Data* bd = ImGui_ImplSDLRenderer_GetBackendData(); - IM_ASSERT(bd != NULL && "Did you call ImGui_ImplSDLRenderer_Init()?"); - - if (!bd->FontTexture) - ImGui_ImplSDLRenderer_CreateDeviceObjects(); -} - -void ImGui_ImplSDLRenderer_RenderDrawData(ImDrawData* draw_data) -{ - ImGui_ImplSDLRenderer_Data* bd = ImGui_ImplSDLRenderer_GetBackendData(); - - // If there's a scale factor set by the user, use that instead - // If the user has specified a scale factor to SDL_Renderer already via SDL_RenderSetScale(), SDL will scale whatever we pass - // to SDL_RenderGeometryRaw() by that scale factor. In that case we don't want to be also scaling it ourselves here. - float rsx = 1.0f; - float rsy = 1.0f; - SDL_RenderGetScale(bd->SDLRenderer, &rsx, &rsy); - ImVec2 render_scale; - render_scale.x = (rsx == 1.0f) ? draw_data->FramebufferScale.x : 1.0f; - render_scale.y = (rsy == 1.0f) ? draw_data->FramebufferScale.y : 1.0f; - - // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates) - int fb_width = (int)(draw_data->DisplaySize.x * render_scale.x); - int fb_height = (int)(draw_data->DisplaySize.y * render_scale.y); - if (fb_width == 0 || fb_height == 0) - return; - - // Backup SDL_Renderer state that will be modified to restore it afterwards - struct BackupSDLRendererState - { - SDL_Rect Viewport; - bool ClipEnabled; - SDL_Rect ClipRect; - }; - BackupSDLRendererState old = {}; - old.ClipEnabled = SDL_RenderIsClipEnabled(bd->SDLRenderer); - SDL_RenderGetViewport(bd->SDLRenderer, &old.Viewport); - SDL_RenderGetClipRect(bd->SDLRenderer, &old.ClipRect); - - // Will project scissor/clipping rectangles into framebuffer space - ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports - ImVec2 clip_scale = render_scale; - - // Render command lists - ImGui_ImplSDLRenderer_SetupRenderState(); - for (int n = 0; n < draw_data->CmdListsCount; n++) - { - const ImDrawList* cmd_list = draw_data->CmdLists[n]; - const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data; - const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data; - - for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) - { - const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; - if (pcmd->UserCallback) - { - // User callback, registered via ImDrawList::AddCallback() - // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.) - if (pcmd->UserCallback == ImDrawCallback_ResetRenderState) - ImGui_ImplSDLRenderer_SetupRenderState(); - else - pcmd->UserCallback(cmd_list, pcmd); - } - else - { - // Project scissor/clipping rectangles into framebuffer space - ImVec2 clip_min((pcmd->ClipRect.x - clip_off.x) * clip_scale.x, (pcmd->ClipRect.y - clip_off.y) * clip_scale.y); - ImVec2 clip_max((pcmd->ClipRect.z - clip_off.x) * clip_scale.x, (pcmd->ClipRect.w - clip_off.y) * clip_scale.y); - if (clip_min.x < 0.0f) { clip_min.x = 0.0f; } - if (clip_min.y < 0.0f) { clip_min.y = 0.0f; } - if (clip_max.x > fb_width) { clip_max.x = (float)fb_width; } - if (clip_max.y > fb_height) { clip_max.y = (float)fb_height; } - if (clip_max.x < clip_min.x || clip_max.y < clip_min.y) - continue; - - SDL_Rect r = { (int)(clip_min.x), (int)(clip_min.y), (int)(clip_max.x - clip_min.x), (int)(clip_max.y - clip_min.y) }; - SDL_RenderSetClipRect(bd->SDLRenderer, &r); - - const float* xy = (const float*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, pos)); - const float* uv = (const float*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, uv)); - const int* color = (const int*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, col)); - - // Bind texture, Draw - SDL_Texture* tex = (SDL_Texture*)pcmd->GetTexID(); - SDL_RenderGeometryRaw(bd->SDLRenderer, tex, - xy, (int)sizeof(ImDrawVert), - color, (int)sizeof(ImDrawVert), - uv, (int)sizeof(ImDrawVert), - cmd_list->VtxBuffer.Size, - idx_buffer + pcmd->IdxOffset, pcmd->ElemCount, sizeof(ImDrawIdx)); - } - } - } - - // Restore modified SDL_Renderer state - SDL_RenderSetViewport(bd->SDLRenderer, &old.Viewport); - SDL_RenderSetClipRect(bd->SDLRenderer, old.ClipEnabled ? &old.ClipRect : NULL); -} - -// Called by Init/NewFrame/Shutdown -bool ImGui_ImplSDLRenderer_CreateFontsTexture() -{ - ImGuiIO& io = ImGui::GetIO(); - ImGui_ImplSDLRenderer_Data* bd = ImGui_ImplSDLRenderer_GetBackendData(); - - // Build texture atlas - unsigned char* pixels; - int width, height; - io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bit (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory. - - // Upload texture to graphics system - bd->FontTexture = SDL_CreateTexture(bd->SDLRenderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_STATIC, width, height); - if (bd->FontTexture == NULL) - { - SDL_Log("error creating texture"); - return false; - } - SDL_UpdateTexture(bd->FontTexture, NULL, pixels, 4 * width); - SDL_SetTextureBlendMode(bd->FontTexture, SDL_BLENDMODE_BLEND); - - // Store our identifier - io.Fonts->SetTexID((ImTextureID)(intptr_t)bd->FontTexture); - - return true; -} - -void ImGui_ImplSDLRenderer_DestroyFontsTexture() -{ - ImGuiIO& io = ImGui::GetIO(); - ImGui_ImplSDLRenderer_Data* bd = ImGui_ImplSDLRenderer_GetBackendData(); - if (bd->FontTexture) - { - io.Fonts->SetTexID(0); - SDL_DestroyTexture(bd->FontTexture); - bd->FontTexture = NULL; - } -} - -bool ImGui_ImplSDLRenderer_CreateDeviceObjects() -{ - return ImGui_ImplSDLRenderer_CreateFontsTexture(); -} - -void ImGui_ImplSDLRenderer_DestroyDeviceObjects() -{ - ImGui_ImplSDLRenderer_DestroyFontsTexture(); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_sdlrenderer.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_sdlrenderer.h deleted file mode 100644 index 8c67fa3..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_sdlrenderer.h +++ /dev/null @@ -1,27 +0,0 @@ -// dear imgui: Renderer Backend for SDL_Renderer -// (Requires: SDL 2.0.17+) - -// Important to understand: SDL_Renderer is an _optional_ component of SDL. We do not recommend you use SDL_Renderer -// because it provide a rather limited API to the end-user. We provide this backend for the sake of completeness. -// For a multi-platform app consider using e.g. SDL+DirectX on Windows and SDL+OpenGL on Linux/OSX. - -// Implemented features: -// [X] Renderer: User texture binding. Use 'SDL_Texture*' as ImTextureID. Read the FAQ about ImTextureID! -// Missing features: -// [ ] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. - -#pragma once -#include "imgui.h" // IMGUI_IMPL_API - -struct SDL_Renderer; - -IMGUI_IMPL_API bool ImGui_ImplSDLRenderer_Init(SDL_Renderer* renderer); -IMGUI_IMPL_API void ImGui_ImplSDLRenderer_Shutdown(); -IMGUI_IMPL_API void ImGui_ImplSDLRenderer_NewFrame(); -IMGUI_IMPL_API void ImGui_ImplSDLRenderer_RenderDrawData(ImDrawData* draw_data); - -// Called by Init/NewFrame/Shutdown -IMGUI_IMPL_API bool ImGui_ImplSDLRenderer_CreateFontsTexture(); -IMGUI_IMPL_API void ImGui_ImplSDLRenderer_DestroyFontsTexture(); -IMGUI_IMPL_API bool ImGui_ImplSDLRenderer_CreateDeviceObjects(); -IMGUI_IMPL_API void ImGui_ImplSDLRenderer_DestroyDeviceObjects(); diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_vulkan.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_vulkan.cpp deleted file mode 100644 index 296304f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_vulkan.cpp +++ /dev/null @@ -1,1463 +0,0 @@ -// dear imgui: Renderer Backend for Vulkan -// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..) - -// Implemented features: -// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. -// Missing features: -// [ ] Renderer: User texture binding. Changes of ImTextureID aren't supported by this backend! See https://github.com/ocornut/imgui/pull/914 - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -// The aim of imgui_impl_vulkan.h/.cpp is to be usable in your engine without any modification. -// IF YOU FEEL YOU NEED TO MAKE ANY CHANGE TO THIS CODE, please share them and your feedback at https://github.com/ocornut/imgui/ - -// Important note to the reader who wish to integrate imgui_impl_vulkan.cpp/.h in their own engine/app. -// - Common ImGui_ImplVulkan_XXX functions and structures are used to interface with imgui_impl_vulkan.cpp/.h. -// You will use those if you want to use this rendering backend in your engine/app. -// - Helper ImGui_ImplVulkanH_XXX functions and structures are only used by this example (main.cpp) and by -// the backend itself (imgui_impl_vulkan.cpp), but should PROBABLY NOT be used by your own engine/app code. -// Read comments in imgui_impl_vulkan.h. - -// CHANGELOG -// (minor and older changes stripped away, please see git history for details) -// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX). -// 2021-03-22: Vulkan: Fix mapped memory validation error when buffer sizes are not multiple of VkPhysicalDeviceLimits::nonCoherentAtomSize. -// 2021-02-18: Vulkan: Change blending equation to preserve alpha in output buffer. -// 2021-01-27: Vulkan: Added support for custom function load and IMGUI_IMPL_VULKAN_NO_PROTOTYPES by using ImGui_ImplVulkan_LoadFunctions(). -// 2020-11-11: Vulkan: Added support for specifying which subpass to reference during VkPipeline creation. -// 2020-09-07: Vulkan: Added VkPipeline parameter to ImGui_ImplVulkan_RenderDrawData (default to one passed to ImGui_ImplVulkan_Init). -// 2020-05-04: Vulkan: Fixed crash if initial frame has no vertices. -// 2020-04-26: Vulkan: Fixed edge case where render callbacks wouldn't be called if the ImDrawData didn't have vertices. -// 2019-08-01: Vulkan: Added support for specifying multisample count. Set ImGui_ImplVulkan_InitInfo::MSAASamples to one of the VkSampleCountFlagBits values to use, default is non-multisampled as before. -// 2019-05-29: Vulkan: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag. -// 2019-04-30: Vulkan: Added support for special ImDrawCallback_ResetRenderState callback to reset render state. -// 2019-04-04: *BREAKING CHANGE*: Vulkan: Added ImageCount/MinImageCount fields in ImGui_ImplVulkan_InitInfo, required for initialization (was previously a hard #define IMGUI_VK_QUEUED_FRAMES 2). Added ImGui_ImplVulkan_SetMinImageCount(). -// 2019-04-04: Vulkan: Added VkInstance argument to ImGui_ImplVulkanH_CreateWindow() optional helper. -// 2019-04-04: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like. -// 2019-04-01: Vulkan: Support for 32-bit index buffer (#define ImDrawIdx unsigned int). -// 2019-02-16: Vulkan: Viewport and clipping rectangles correctly using draw_data->FramebufferScale to allow retina display. -// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window. -// 2018-08-25: Vulkan: Fixed mishandled VkSurfaceCapabilitiesKHR::maxImageCount=0 case. -// 2018-06-22: Inverted the parameters to ImGui_ImplVulkan_RenderDrawData() to be consistent with other backends. -// 2018-06-08: Misc: Extracted imgui_impl_vulkan.cpp/.h away from the old combined GLFW+Vulkan example. -// 2018-06-08: Vulkan: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle. -// 2018-03-03: Vulkan: Various refactor, created a couple of ImGui_ImplVulkanH_XXX helper that the example can use and that viewport support will use. -// 2018-03-01: Vulkan: Renamed ImGui_ImplVulkan_Init_Info to ImGui_ImplVulkan_InitInfo and fields to match more closely Vulkan terminology. -// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback, ImGui_ImplVulkan_Render() calls ImGui_ImplVulkan_RenderDrawData() itself. -// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves. -// 2017-05-15: Vulkan: Fix scissor offset being negative. Fix new Vulkan validation warnings. Set required depth member for buffer image copy. -// 2016-11-13: Vulkan: Fix validation layer warnings and errors and redeclare gl_PerVertex. -// 2016-10-18: Vulkan: Add location decorators & change to use structs as in/out in glsl, update embedded spv (produced with glslangValidator -x). Null the released resources. -// 2016-08-27: Vulkan: Fix Vulkan example for use when a depth buffer is active. - -#include "imgui_impl_vulkan.h" -#include - -// Reusable buffers used for rendering 1 current in-flight frame, for ImGui_ImplVulkan_RenderDrawData() -// [Please zero-clear before use!] -struct ImGui_ImplVulkanH_FrameRenderBuffers -{ - VkDeviceMemory VertexBufferMemory; - VkDeviceMemory IndexBufferMemory; - VkDeviceSize VertexBufferSize; - VkDeviceSize IndexBufferSize; - VkBuffer VertexBuffer; - VkBuffer IndexBuffer; -}; - -// Each viewport will hold 1 ImGui_ImplVulkanH_WindowRenderBuffers -// [Please zero-clear before use!] -struct ImGui_ImplVulkanH_WindowRenderBuffers -{ - uint32_t Index; - uint32_t Count; - ImGui_ImplVulkanH_FrameRenderBuffers* FrameRenderBuffers; -}; - -// Vulkan data -struct ImGui_ImplVulkan_Data -{ - ImGui_ImplVulkan_InitInfo VulkanInitInfo; - VkRenderPass RenderPass; - VkDeviceSize BufferMemoryAlignment; - VkPipelineCreateFlags PipelineCreateFlags; - VkDescriptorSetLayout DescriptorSetLayout; - VkPipelineLayout PipelineLayout; - VkDescriptorSet DescriptorSet; - VkPipeline Pipeline; - uint32_t Subpass; - VkShaderModule ShaderModuleVert; - VkShaderModule ShaderModuleFrag; - - // Font data - VkSampler FontSampler; - VkDeviceMemory FontMemory; - VkImage FontImage; - VkImageView FontView; - VkDeviceMemory UploadBufferMemory; - VkBuffer UploadBuffer; - - // Render buffers - ImGui_ImplVulkanH_WindowRenderBuffers MainWindowRenderBuffers; - - ImGui_ImplVulkan_Data() - { - memset(this, 0, sizeof(*this)); - BufferMemoryAlignment = 256; - } -}; - -// Forward Declarations -bool ImGui_ImplVulkan_CreateDeviceObjects(); -void ImGui_ImplVulkan_DestroyDeviceObjects(); -void ImGui_ImplVulkanH_DestroyFrame(VkDevice device, ImGui_ImplVulkanH_Frame* fd, const VkAllocationCallbacks* allocator); -void ImGui_ImplVulkanH_DestroyFrameSemaphores(VkDevice device, ImGui_ImplVulkanH_FrameSemaphores* fsd, const VkAllocationCallbacks* allocator); -void ImGui_ImplVulkanH_DestroyFrameRenderBuffers(VkDevice device, ImGui_ImplVulkanH_FrameRenderBuffers* buffers, const VkAllocationCallbacks* allocator); -void ImGui_ImplVulkanH_DestroyWindowRenderBuffers(VkDevice device, ImGui_ImplVulkanH_WindowRenderBuffers* buffers, const VkAllocationCallbacks* allocator); -void ImGui_ImplVulkanH_CreateWindowSwapChain(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, const VkAllocationCallbacks* allocator, int w, int h, uint32_t min_image_count); -void ImGui_ImplVulkanH_CreateWindowCommandBuffers(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, uint32_t queue_family, const VkAllocationCallbacks* allocator); - -// Vulkan prototypes for use with custom loaders -// (see description of IMGUI_IMPL_VULKAN_NO_PROTOTYPES in imgui_impl_vulkan.h -#ifdef VK_NO_PROTOTYPES -static bool g_FunctionsLoaded = false; -#else -static bool g_FunctionsLoaded = true; -#endif -#ifdef VK_NO_PROTOTYPES -#define IMGUI_VULKAN_FUNC_MAP(IMGUI_VULKAN_FUNC_MAP_MACRO) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkAllocateCommandBuffers) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkAllocateDescriptorSets) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkAllocateMemory) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkBindBufferMemory) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkBindImageMemory) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBindDescriptorSets) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBindIndexBuffer) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBindPipeline) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdBindVertexBuffers) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdCopyBufferToImage) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdDrawIndexed) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdPipelineBarrier) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdPushConstants) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdSetScissor) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkCmdSetViewport) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkCreateBuffer) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkCreateCommandPool) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkCreateDescriptorSetLayout) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkCreateFence) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkCreateFramebuffer) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkCreateGraphicsPipelines) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkCreateImage) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkCreateImageView) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkCreatePipelineLayout) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkCreateRenderPass) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkCreateSampler) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkCreateSemaphore) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkCreateShaderModule) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkCreateSwapchainKHR) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkDestroyBuffer) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkDestroyCommandPool) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkDestroyDescriptorSetLayout) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkDestroyFence) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkDestroyFramebuffer) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkDestroyImage) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkDestroyImageView) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkDestroyPipeline) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkDestroyPipelineLayout) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkDestroyRenderPass) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkDestroySampler) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkDestroySemaphore) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkDestroyShaderModule) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkDestroySurfaceKHR) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkDestroySwapchainKHR) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkDeviceWaitIdle) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkFlushMappedMemoryRanges) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkFreeCommandBuffers) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkFreeMemory) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetBufferMemoryRequirements) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetImageMemoryRequirements) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetPhysicalDeviceMemoryProperties) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetPhysicalDeviceSurfaceCapabilitiesKHR) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetPhysicalDeviceSurfaceFormatsKHR) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetPhysicalDeviceSurfacePresentModesKHR) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkGetSwapchainImagesKHR) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkMapMemory) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkUnmapMemory) \ - IMGUI_VULKAN_FUNC_MAP_MACRO(vkUpdateDescriptorSets) - -// Define function pointers -#define IMGUI_VULKAN_FUNC_DEF(func) static PFN_##func func; -IMGUI_VULKAN_FUNC_MAP(IMGUI_VULKAN_FUNC_DEF) -#undef IMGUI_VULKAN_FUNC_DEF -#endif // VK_NO_PROTOTYPES - -//----------------------------------------------------------------------------- -// SHADERS -//----------------------------------------------------------------------------- - -// glsl_shader.vert, compiled with: -// # glslangValidator -V -x -o glsl_shader.vert.u32 glsl_shader.vert -/* -#version 450 core -layout(location = 0) in vec2 aPos; -layout(location = 1) in vec2 aUV; -layout(location = 2) in vec4 aColor; -layout(push_constant) uniform uPushConstant { vec2 uScale; vec2 uTranslate; } pc; - -out gl_PerVertex { vec4 gl_Position; }; -layout(location = 0) out struct { vec4 Color; vec2 UV; } Out; - -void main() -{ - Out.Color = aColor; - Out.UV = aUV; - gl_Position = vec4(aPos * pc.uScale + pc.uTranslate, 0, 1); -} -*/ -static uint32_t __glsl_shader_vert_spv[] = -{ - 0x07230203,0x00010000,0x00080001,0x0000002e,0x00000000,0x00020011,0x00000001,0x0006000b, - 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, - 0x000a000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x0000000b,0x0000000f,0x00000015, - 0x0000001b,0x0000001c,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d, - 0x00000000,0x00030005,0x00000009,0x00000000,0x00050006,0x00000009,0x00000000,0x6f6c6f43, - 0x00000072,0x00040006,0x00000009,0x00000001,0x00005655,0x00030005,0x0000000b,0x0074754f, - 0x00040005,0x0000000f,0x6c6f4361,0x0000726f,0x00030005,0x00000015,0x00565561,0x00060005, - 0x00000019,0x505f6c67,0x65567265,0x78657472,0x00000000,0x00060006,0x00000019,0x00000000, - 0x505f6c67,0x7469736f,0x006e6f69,0x00030005,0x0000001b,0x00000000,0x00040005,0x0000001c, - 0x736f5061,0x00000000,0x00060005,0x0000001e,0x73755075,0x6e6f4368,0x6e617473,0x00000074, - 0x00050006,0x0000001e,0x00000000,0x61635375,0x0000656c,0x00060006,0x0000001e,0x00000001, - 0x61725475,0x616c736e,0x00006574,0x00030005,0x00000020,0x00006370,0x00040047,0x0000000b, - 0x0000001e,0x00000000,0x00040047,0x0000000f,0x0000001e,0x00000002,0x00040047,0x00000015, - 0x0000001e,0x00000001,0x00050048,0x00000019,0x00000000,0x0000000b,0x00000000,0x00030047, - 0x00000019,0x00000002,0x00040047,0x0000001c,0x0000001e,0x00000000,0x00050048,0x0000001e, - 0x00000000,0x00000023,0x00000000,0x00050048,0x0000001e,0x00000001,0x00000023,0x00000008, - 0x00030047,0x0000001e,0x00000002,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002, - 0x00030016,0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000004,0x00040017, - 0x00000008,0x00000006,0x00000002,0x0004001e,0x00000009,0x00000007,0x00000008,0x00040020, - 0x0000000a,0x00000003,0x00000009,0x0004003b,0x0000000a,0x0000000b,0x00000003,0x00040015, - 0x0000000c,0x00000020,0x00000001,0x0004002b,0x0000000c,0x0000000d,0x00000000,0x00040020, - 0x0000000e,0x00000001,0x00000007,0x0004003b,0x0000000e,0x0000000f,0x00000001,0x00040020, - 0x00000011,0x00000003,0x00000007,0x0004002b,0x0000000c,0x00000013,0x00000001,0x00040020, - 0x00000014,0x00000001,0x00000008,0x0004003b,0x00000014,0x00000015,0x00000001,0x00040020, - 0x00000017,0x00000003,0x00000008,0x0003001e,0x00000019,0x00000007,0x00040020,0x0000001a, - 0x00000003,0x00000019,0x0004003b,0x0000001a,0x0000001b,0x00000003,0x0004003b,0x00000014, - 0x0000001c,0x00000001,0x0004001e,0x0000001e,0x00000008,0x00000008,0x00040020,0x0000001f, - 0x00000009,0x0000001e,0x0004003b,0x0000001f,0x00000020,0x00000009,0x00040020,0x00000021, - 0x00000009,0x00000008,0x0004002b,0x00000006,0x00000028,0x00000000,0x0004002b,0x00000006, - 0x00000029,0x3f800000,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8, - 0x00000005,0x0004003d,0x00000007,0x00000010,0x0000000f,0x00050041,0x00000011,0x00000012, - 0x0000000b,0x0000000d,0x0003003e,0x00000012,0x00000010,0x0004003d,0x00000008,0x00000016, - 0x00000015,0x00050041,0x00000017,0x00000018,0x0000000b,0x00000013,0x0003003e,0x00000018, - 0x00000016,0x0004003d,0x00000008,0x0000001d,0x0000001c,0x00050041,0x00000021,0x00000022, - 0x00000020,0x0000000d,0x0004003d,0x00000008,0x00000023,0x00000022,0x00050085,0x00000008, - 0x00000024,0x0000001d,0x00000023,0x00050041,0x00000021,0x00000025,0x00000020,0x00000013, - 0x0004003d,0x00000008,0x00000026,0x00000025,0x00050081,0x00000008,0x00000027,0x00000024, - 0x00000026,0x00050051,0x00000006,0x0000002a,0x00000027,0x00000000,0x00050051,0x00000006, - 0x0000002b,0x00000027,0x00000001,0x00070050,0x00000007,0x0000002c,0x0000002a,0x0000002b, - 0x00000028,0x00000029,0x00050041,0x00000011,0x0000002d,0x0000001b,0x0000000d,0x0003003e, - 0x0000002d,0x0000002c,0x000100fd,0x00010038 -}; - -// glsl_shader.frag, compiled with: -// # glslangValidator -V -x -o glsl_shader.frag.u32 glsl_shader.frag -/* -#version 450 core -layout(location = 0) out vec4 fColor; -layout(set=0, binding=0) uniform sampler2D sTexture; -layout(location = 0) in struct { vec4 Color; vec2 UV; } In; -void main() -{ - fColor = In.Color * texture(sTexture, In.UV.st); -} -*/ -static uint32_t __glsl_shader_frag_spv[] = -{ - 0x07230203,0x00010000,0x00080001,0x0000001e,0x00000000,0x00020011,0x00000001,0x0006000b, - 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, - 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000009,0x0000000d,0x00030010, - 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d, - 0x00000000,0x00040005,0x00000009,0x6c6f4366,0x0000726f,0x00030005,0x0000000b,0x00000000, - 0x00050006,0x0000000b,0x00000000,0x6f6c6f43,0x00000072,0x00040006,0x0000000b,0x00000001, - 0x00005655,0x00030005,0x0000000d,0x00006e49,0x00050005,0x00000016,0x78655473,0x65727574, - 0x00000000,0x00040047,0x00000009,0x0000001e,0x00000000,0x00040047,0x0000000d,0x0000001e, - 0x00000000,0x00040047,0x00000016,0x00000022,0x00000000,0x00040047,0x00000016,0x00000021, - 0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006, - 0x00000020,0x00040017,0x00000007,0x00000006,0x00000004,0x00040020,0x00000008,0x00000003, - 0x00000007,0x0004003b,0x00000008,0x00000009,0x00000003,0x00040017,0x0000000a,0x00000006, - 0x00000002,0x0004001e,0x0000000b,0x00000007,0x0000000a,0x00040020,0x0000000c,0x00000001, - 0x0000000b,0x0004003b,0x0000000c,0x0000000d,0x00000001,0x00040015,0x0000000e,0x00000020, - 0x00000001,0x0004002b,0x0000000e,0x0000000f,0x00000000,0x00040020,0x00000010,0x00000001, - 0x00000007,0x00090019,0x00000013,0x00000006,0x00000001,0x00000000,0x00000000,0x00000000, - 0x00000001,0x00000000,0x0003001b,0x00000014,0x00000013,0x00040020,0x00000015,0x00000000, - 0x00000014,0x0004003b,0x00000015,0x00000016,0x00000000,0x0004002b,0x0000000e,0x00000018, - 0x00000001,0x00040020,0x00000019,0x00000001,0x0000000a,0x00050036,0x00000002,0x00000004, - 0x00000000,0x00000003,0x000200f8,0x00000005,0x00050041,0x00000010,0x00000011,0x0000000d, - 0x0000000f,0x0004003d,0x00000007,0x00000012,0x00000011,0x0004003d,0x00000014,0x00000017, - 0x00000016,0x00050041,0x00000019,0x0000001a,0x0000000d,0x00000018,0x0004003d,0x0000000a, - 0x0000001b,0x0000001a,0x00050057,0x00000007,0x0000001c,0x00000017,0x0000001b,0x00050085, - 0x00000007,0x0000001d,0x00000012,0x0000001c,0x0003003e,0x00000009,0x0000001d,0x000100fd, - 0x00010038 -}; - -//----------------------------------------------------------------------------- -// FUNCTIONS -//----------------------------------------------------------------------------- - -// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts -// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts. -// FIXME: multi-context support is not tested and probably dysfunctional in this backend. -static ImGui_ImplVulkan_Data* ImGui_ImplVulkan_GetBackendData() -{ - return ImGui::GetCurrentContext() ? (ImGui_ImplVulkan_Data*)ImGui::GetIO().BackendRendererUserData : NULL; -} - -static uint32_t ImGui_ImplVulkan_MemoryType(VkMemoryPropertyFlags properties, uint32_t type_bits) -{ - ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData(); - ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo; - VkPhysicalDeviceMemoryProperties prop; - vkGetPhysicalDeviceMemoryProperties(v->PhysicalDevice, &prop); - for (uint32_t i = 0; i < prop.memoryTypeCount; i++) - if ((prop.memoryTypes[i].propertyFlags & properties) == properties && type_bits & (1 << i)) - return i; - return 0xFFFFFFFF; // Unable to find memoryType -} - -static void check_vk_result(VkResult err) -{ - ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData(); - if (!bd) - return; - ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo; - if (v->CheckVkResultFn) - v->CheckVkResultFn(err); -} - -static void CreateOrResizeBuffer(VkBuffer& buffer, VkDeviceMemory& buffer_memory, VkDeviceSize& p_buffer_size, size_t new_size, VkBufferUsageFlagBits usage) -{ - ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData(); - ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo; - VkResult err; - if (buffer != VK_NULL_HANDLE) - vkDestroyBuffer(v->Device, buffer, v->Allocator); - if (buffer_memory != VK_NULL_HANDLE) - vkFreeMemory(v->Device, buffer_memory, v->Allocator); - - VkDeviceSize vertex_buffer_size_aligned = ((new_size - 1) / bd->BufferMemoryAlignment + 1) * bd->BufferMemoryAlignment; - VkBufferCreateInfo buffer_info = {}; - buffer_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; - buffer_info.size = vertex_buffer_size_aligned; - buffer_info.usage = usage; - buffer_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; - err = vkCreateBuffer(v->Device, &buffer_info, v->Allocator, &buffer); - check_vk_result(err); - - VkMemoryRequirements req; - vkGetBufferMemoryRequirements(v->Device, buffer, &req); - bd->BufferMemoryAlignment = (bd->BufferMemoryAlignment > req.alignment) ? bd->BufferMemoryAlignment : req.alignment; - VkMemoryAllocateInfo alloc_info = {}; - alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; - alloc_info.allocationSize = req.size; - alloc_info.memoryTypeIndex = ImGui_ImplVulkan_MemoryType(VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, req.memoryTypeBits); - err = vkAllocateMemory(v->Device, &alloc_info, v->Allocator, &buffer_memory); - check_vk_result(err); - - err = vkBindBufferMemory(v->Device, buffer, buffer_memory, 0); - check_vk_result(err); - p_buffer_size = req.size; -} - -static void ImGui_ImplVulkan_SetupRenderState(ImDrawData* draw_data, VkPipeline pipeline, VkCommandBuffer command_buffer, ImGui_ImplVulkanH_FrameRenderBuffers* rb, int fb_width, int fb_height) -{ - ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData(); - - // Bind pipeline and descriptor sets: - { - vkCmdBindPipeline(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); - VkDescriptorSet desc_set[1] = { bd->DescriptorSet }; - vkCmdBindDescriptorSets(command_buffer, VK_PIPELINE_BIND_POINT_GRAPHICS, bd->PipelineLayout, 0, 1, desc_set, 0, NULL); - } - - // Bind Vertex And Index Buffer: - if (draw_data->TotalVtxCount > 0) - { - VkBuffer vertex_buffers[1] = { rb->VertexBuffer }; - VkDeviceSize vertex_offset[1] = { 0 }; - vkCmdBindVertexBuffers(command_buffer, 0, 1, vertex_buffers, vertex_offset); - vkCmdBindIndexBuffer(command_buffer, rb->IndexBuffer, 0, sizeof(ImDrawIdx) == 2 ? VK_INDEX_TYPE_UINT16 : VK_INDEX_TYPE_UINT32); - } - - // Setup viewport: - { - VkViewport viewport; - viewport.x = 0; - viewport.y = 0; - viewport.width = (float)fb_width; - viewport.height = (float)fb_height; - viewport.minDepth = 0.0f; - viewport.maxDepth = 1.0f; - vkCmdSetViewport(command_buffer, 0, 1, &viewport); - } - - // Setup scale and translation: - // Our visible imgui space lies from draw_data->DisplayPps (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps. - { - float scale[2]; - scale[0] = 2.0f / draw_data->DisplaySize.x; - scale[1] = 2.0f / draw_data->DisplaySize.y; - float translate[2]; - translate[0] = -1.0f - draw_data->DisplayPos.x * scale[0]; - translate[1] = -1.0f - draw_data->DisplayPos.y * scale[1]; - vkCmdPushConstants(command_buffer, bd->PipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, sizeof(float) * 0, sizeof(float) * 2, scale); - vkCmdPushConstants(command_buffer, bd->PipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, sizeof(float) * 2, sizeof(float) * 2, translate); - } -} - -// Render function -void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer command_buffer, VkPipeline pipeline) -{ - // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates) - int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x); - int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y); - if (fb_width <= 0 || fb_height <= 0) - return; - - ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData(); - ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo; - if (pipeline == VK_NULL_HANDLE) - pipeline = bd->Pipeline; - - // Allocate array to store enough vertex/index buffers - ImGui_ImplVulkanH_WindowRenderBuffers* wrb = &bd->MainWindowRenderBuffers; - if (wrb->FrameRenderBuffers == NULL) - { - wrb->Index = 0; - wrb->Count = v->ImageCount; - wrb->FrameRenderBuffers = (ImGui_ImplVulkanH_FrameRenderBuffers*)IM_ALLOC(sizeof(ImGui_ImplVulkanH_FrameRenderBuffers) * wrb->Count); - memset(wrb->FrameRenderBuffers, 0, sizeof(ImGui_ImplVulkanH_FrameRenderBuffers) * wrb->Count); - } - IM_ASSERT(wrb->Count == v->ImageCount); - wrb->Index = (wrb->Index + 1) % wrb->Count; - ImGui_ImplVulkanH_FrameRenderBuffers* rb = &wrb->FrameRenderBuffers[wrb->Index]; - - if (draw_data->TotalVtxCount > 0) - { - // Create or resize the vertex/index buffers - size_t vertex_size = draw_data->TotalVtxCount * sizeof(ImDrawVert); - size_t index_size = draw_data->TotalIdxCount * sizeof(ImDrawIdx); - if (rb->VertexBuffer == VK_NULL_HANDLE || rb->VertexBufferSize < vertex_size) - CreateOrResizeBuffer(rb->VertexBuffer, rb->VertexBufferMemory, rb->VertexBufferSize, vertex_size, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT); - if (rb->IndexBuffer == VK_NULL_HANDLE || rb->IndexBufferSize < index_size) - CreateOrResizeBuffer(rb->IndexBuffer, rb->IndexBufferMemory, rb->IndexBufferSize, index_size, VK_BUFFER_USAGE_INDEX_BUFFER_BIT); - - // Upload vertex/index data into a single contiguous GPU buffer - ImDrawVert* vtx_dst = NULL; - ImDrawIdx* idx_dst = NULL; - VkResult err = vkMapMemory(v->Device, rb->VertexBufferMemory, 0, rb->VertexBufferSize, 0, (void**)(&vtx_dst)); - check_vk_result(err); - err = vkMapMemory(v->Device, rb->IndexBufferMemory, 0, rb->IndexBufferSize, 0, (void**)(&idx_dst)); - check_vk_result(err); - for (int n = 0; n < draw_data->CmdListsCount; n++) - { - const ImDrawList* cmd_list = draw_data->CmdLists[n]; - memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert)); - memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx)); - vtx_dst += cmd_list->VtxBuffer.Size; - idx_dst += cmd_list->IdxBuffer.Size; - } - VkMappedMemoryRange range[2] = {}; - range[0].sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE; - range[0].memory = rb->VertexBufferMemory; - range[0].size = VK_WHOLE_SIZE; - range[1].sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE; - range[1].memory = rb->IndexBufferMemory; - range[1].size = VK_WHOLE_SIZE; - err = vkFlushMappedMemoryRanges(v->Device, 2, range); - check_vk_result(err); - vkUnmapMemory(v->Device, rb->VertexBufferMemory); - vkUnmapMemory(v->Device, rb->IndexBufferMemory); - } - - // Setup desired Vulkan state - ImGui_ImplVulkan_SetupRenderState(draw_data, pipeline, command_buffer, rb, fb_width, fb_height); - - // Will project scissor/clipping rectangles into framebuffer space - ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports - ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2) - - // Render command lists - // (Because we merged all buffers into a single one, we maintain our own offset into them) - int global_vtx_offset = 0; - int global_idx_offset = 0; - for (int n = 0; n < draw_data->CmdListsCount; n++) - { - const ImDrawList* cmd_list = draw_data->CmdLists[n]; - for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) - { - const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; - if (pcmd->UserCallback != NULL) - { - // User callback, registered via ImDrawList::AddCallback() - // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.) - if (pcmd->UserCallback == ImDrawCallback_ResetRenderState) - ImGui_ImplVulkan_SetupRenderState(draw_data, pipeline, command_buffer, rb, fb_width, fb_height); - else - pcmd->UserCallback(cmd_list, pcmd); - } - else - { - // Project scissor/clipping rectangles into framebuffer space - ImVec2 clip_min((pcmd->ClipRect.x - clip_off.x) * clip_scale.x, (pcmd->ClipRect.y - clip_off.y) * clip_scale.y); - ImVec2 clip_max((pcmd->ClipRect.z - clip_off.x) * clip_scale.x, (pcmd->ClipRect.w - clip_off.y) * clip_scale.y); - - // Clamp to viewport as vkCmdSetScissor() won't accept values that are off bounds - if (clip_min.x < 0.0f) { clip_min.x = 0.0f; } - if (clip_min.y < 0.0f) { clip_min.y = 0.0f; } - if (clip_max.x > fb_width) { clip_max.x = (float)fb_width; } - if (clip_max.y > fb_height) { clip_max.y = (float)fb_height; } - if (clip_max.x < clip_min.x || clip_max.y < clip_min.y) - continue; - - // Apply scissor/clipping rectangle - VkRect2D scissor; - scissor.offset.x = (int32_t)(clip_min.x); - scissor.offset.y = (int32_t)(clip_min.y); - scissor.extent.width = (uint32_t)(clip_max.x - clip_min.x); - scissor.extent.height = (uint32_t)(clip_max.y - clip_min.y); - vkCmdSetScissor(command_buffer, 0, 1, &scissor); - - // Draw - vkCmdDrawIndexed(command_buffer, pcmd->ElemCount, 1, pcmd->IdxOffset + global_idx_offset, pcmd->VtxOffset + global_vtx_offset, 0); - } - } - global_idx_offset += cmd_list->IdxBuffer.Size; - global_vtx_offset += cmd_list->VtxBuffer.Size; - } -} - -bool ImGui_ImplVulkan_CreateFontsTexture(VkCommandBuffer command_buffer) -{ - ImGuiIO& io = ImGui::GetIO(); - ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData(); - ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo; - - unsigned char* pixels; - int width, height; - io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); - size_t upload_size = width * height * 4 * sizeof(char); - - VkResult err; - - // Create the Image: - { - VkImageCreateInfo info = {}; - info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; - info.imageType = VK_IMAGE_TYPE_2D; - info.format = VK_FORMAT_R8G8B8A8_UNORM; - info.extent.width = width; - info.extent.height = height; - info.extent.depth = 1; - info.mipLevels = 1; - info.arrayLayers = 1; - info.samples = VK_SAMPLE_COUNT_1_BIT; - info.tiling = VK_IMAGE_TILING_OPTIMAL; - info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; - info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; - info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; - err = vkCreateImage(v->Device, &info, v->Allocator, &bd->FontImage); - check_vk_result(err); - VkMemoryRequirements req; - vkGetImageMemoryRequirements(v->Device, bd->FontImage, &req); - VkMemoryAllocateInfo alloc_info = {}; - alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; - alloc_info.allocationSize = req.size; - alloc_info.memoryTypeIndex = ImGui_ImplVulkan_MemoryType(VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, req.memoryTypeBits); - err = vkAllocateMemory(v->Device, &alloc_info, v->Allocator, &bd->FontMemory); - check_vk_result(err); - err = vkBindImageMemory(v->Device, bd->FontImage, bd->FontMemory, 0); - check_vk_result(err); - } - - // Create the Image View: - { - VkImageViewCreateInfo info = {}; - info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; - info.image = bd->FontImage; - info.viewType = VK_IMAGE_VIEW_TYPE_2D; - info.format = VK_FORMAT_R8G8B8A8_UNORM; - info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - info.subresourceRange.levelCount = 1; - info.subresourceRange.layerCount = 1; - err = vkCreateImageView(v->Device, &info, v->Allocator, &bd->FontView); - check_vk_result(err); - } - - // Update the Descriptor Set: - { - VkDescriptorImageInfo desc_image[1] = {}; - desc_image[0].sampler = bd->FontSampler; - desc_image[0].imageView = bd->FontView; - desc_image[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; - VkWriteDescriptorSet write_desc[1] = {}; - write_desc[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; - write_desc[0].dstSet = bd->DescriptorSet; - write_desc[0].descriptorCount = 1; - write_desc[0].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; - write_desc[0].pImageInfo = desc_image; - vkUpdateDescriptorSets(v->Device, 1, write_desc, 0, NULL); - } - - // Create the Upload Buffer: - { - VkBufferCreateInfo buffer_info = {}; - buffer_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; - buffer_info.size = upload_size; - buffer_info.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT; - buffer_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; - err = vkCreateBuffer(v->Device, &buffer_info, v->Allocator, &bd->UploadBuffer); - check_vk_result(err); - VkMemoryRequirements req; - vkGetBufferMemoryRequirements(v->Device, bd->UploadBuffer, &req); - bd->BufferMemoryAlignment = (bd->BufferMemoryAlignment > req.alignment) ? bd->BufferMemoryAlignment : req.alignment; - VkMemoryAllocateInfo alloc_info = {}; - alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; - alloc_info.allocationSize = req.size; - alloc_info.memoryTypeIndex = ImGui_ImplVulkan_MemoryType(VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, req.memoryTypeBits); - err = vkAllocateMemory(v->Device, &alloc_info, v->Allocator, &bd->UploadBufferMemory); - check_vk_result(err); - err = vkBindBufferMemory(v->Device, bd->UploadBuffer, bd->UploadBufferMemory, 0); - check_vk_result(err); - } - - // Upload to Buffer: - { - char* map = NULL; - err = vkMapMemory(v->Device, bd->UploadBufferMemory, 0, upload_size, 0, (void**)(&map)); - check_vk_result(err); - memcpy(map, pixels, upload_size); - VkMappedMemoryRange range[1] = {}; - range[0].sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE; - range[0].memory = bd->UploadBufferMemory; - range[0].size = upload_size; - err = vkFlushMappedMemoryRanges(v->Device, 1, range); - check_vk_result(err); - vkUnmapMemory(v->Device, bd->UploadBufferMemory); - } - - // Copy to Image: - { - VkImageMemoryBarrier copy_barrier[1] = {}; - copy_barrier[0].sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - copy_barrier[0].dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; - copy_barrier[0].oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; - copy_barrier[0].newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; - copy_barrier[0].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - copy_barrier[0].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - copy_barrier[0].image = bd->FontImage; - copy_barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - copy_barrier[0].subresourceRange.levelCount = 1; - copy_barrier[0].subresourceRange.layerCount = 1; - vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, NULL, 0, NULL, 1, copy_barrier); - - VkBufferImageCopy region = {}; - region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - region.imageSubresource.layerCount = 1; - region.imageExtent.width = width; - region.imageExtent.height = height; - region.imageExtent.depth = 1; - vkCmdCopyBufferToImage(command_buffer, bd->UploadBuffer, bd->FontImage, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, ®ion); - - VkImageMemoryBarrier use_barrier[1] = {}; - use_barrier[0].sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - use_barrier[0].srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; - use_barrier[0].dstAccessMask = VK_ACCESS_SHADER_READ_BIT; - use_barrier[0].oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; - use_barrier[0].newLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; - use_barrier[0].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - use_barrier[0].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - use_barrier[0].image = bd->FontImage; - use_barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - use_barrier[0].subresourceRange.levelCount = 1; - use_barrier[0].subresourceRange.layerCount = 1; - vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, 0, 0, NULL, 0, NULL, 1, use_barrier); - } - - // Store our identifier - io.Fonts->SetTexID((ImTextureID)(intptr_t)bd->FontImage); - - return true; -} - -static void ImGui_ImplVulkan_CreateShaderModules(VkDevice device, const VkAllocationCallbacks* allocator) -{ - // Create the shader modules - ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData(); - if (bd->ShaderModuleVert == VK_NULL_HANDLE) - { - VkShaderModuleCreateInfo vert_info = {}; - vert_info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; - vert_info.codeSize = sizeof(__glsl_shader_vert_spv); - vert_info.pCode = (uint32_t*)__glsl_shader_vert_spv; - VkResult err = vkCreateShaderModule(device, &vert_info, allocator, &bd->ShaderModuleVert); - check_vk_result(err); - } - if (bd->ShaderModuleFrag == VK_NULL_HANDLE) - { - VkShaderModuleCreateInfo frag_info = {}; - frag_info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; - frag_info.codeSize = sizeof(__glsl_shader_frag_spv); - frag_info.pCode = (uint32_t*)__glsl_shader_frag_spv; - VkResult err = vkCreateShaderModule(device, &frag_info, allocator, &bd->ShaderModuleFrag); - check_vk_result(err); - } -} - -static void ImGui_ImplVulkan_CreateFontSampler(VkDevice device, const VkAllocationCallbacks* allocator) -{ - ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData(); - if (bd->FontSampler) - return; - - VkSamplerCreateInfo info = {}; - info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; - info.magFilter = VK_FILTER_LINEAR; - info.minFilter = VK_FILTER_LINEAR; - info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR; - info.addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT; - info.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT; - info.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT; - info.minLod = -1000; - info.maxLod = 1000; - info.maxAnisotropy = 1.0f; - VkResult err = vkCreateSampler(device, &info, allocator, &bd->FontSampler); - check_vk_result(err); -} - -static void ImGui_ImplVulkan_CreateDescriptorSetLayout(VkDevice device, const VkAllocationCallbacks* allocator) -{ - ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData(); - if (bd->DescriptorSetLayout) - return; - - ImGui_ImplVulkan_CreateFontSampler(device, allocator); - VkSampler sampler[1] = { bd->FontSampler }; - VkDescriptorSetLayoutBinding binding[1] = {}; - binding[0].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; - binding[0].descriptorCount = 1; - binding[0].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; - binding[0].pImmutableSamplers = sampler; - VkDescriptorSetLayoutCreateInfo info = {}; - info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; - info.bindingCount = 1; - info.pBindings = binding; - VkResult err = vkCreateDescriptorSetLayout(device, &info, allocator, &bd->DescriptorSetLayout); - check_vk_result(err); -} - -static void ImGui_ImplVulkan_CreatePipelineLayout(VkDevice device, const VkAllocationCallbacks* allocator) -{ - ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData(); - if (bd->PipelineLayout) - return; - - // Constants: we are using 'vec2 offset' and 'vec2 scale' instead of a full 3d projection matrix - ImGui_ImplVulkan_CreateDescriptorSetLayout(device, allocator); - VkPushConstantRange push_constants[1] = {}; - push_constants[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; - push_constants[0].offset = sizeof(float) * 0; - push_constants[0].size = sizeof(float) * 4; - VkDescriptorSetLayout set_layout[1] = { bd->DescriptorSetLayout }; - VkPipelineLayoutCreateInfo layout_info = {}; - layout_info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; - layout_info.setLayoutCount = 1; - layout_info.pSetLayouts = set_layout; - layout_info.pushConstantRangeCount = 1; - layout_info.pPushConstantRanges = push_constants; - VkResult err = vkCreatePipelineLayout(device, &layout_info, allocator, &bd->PipelineLayout); - check_vk_result(err); -} - -static void ImGui_ImplVulkan_CreatePipeline(VkDevice device, const VkAllocationCallbacks* allocator, VkPipelineCache pipelineCache, VkRenderPass renderPass, VkSampleCountFlagBits MSAASamples, VkPipeline* pipeline, uint32_t subpass) -{ - ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData(); - ImGui_ImplVulkan_CreateShaderModules(device, allocator); - - VkPipelineShaderStageCreateInfo stage[2] = {}; - stage[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; - stage[0].stage = VK_SHADER_STAGE_VERTEX_BIT; - stage[0].module = bd->ShaderModuleVert; - stage[0].pName = "main"; - stage[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; - stage[1].stage = VK_SHADER_STAGE_FRAGMENT_BIT; - stage[1].module = bd->ShaderModuleFrag; - stage[1].pName = "main"; - - VkVertexInputBindingDescription binding_desc[1] = {}; - binding_desc[0].stride = sizeof(ImDrawVert); - binding_desc[0].inputRate = VK_VERTEX_INPUT_RATE_VERTEX; - - VkVertexInputAttributeDescription attribute_desc[3] = {}; - attribute_desc[0].location = 0; - attribute_desc[0].binding = binding_desc[0].binding; - attribute_desc[0].format = VK_FORMAT_R32G32_SFLOAT; - attribute_desc[0].offset = IM_OFFSETOF(ImDrawVert, pos); - attribute_desc[1].location = 1; - attribute_desc[1].binding = binding_desc[0].binding; - attribute_desc[1].format = VK_FORMAT_R32G32_SFLOAT; - attribute_desc[1].offset = IM_OFFSETOF(ImDrawVert, uv); - attribute_desc[2].location = 2; - attribute_desc[2].binding = binding_desc[0].binding; - attribute_desc[2].format = VK_FORMAT_R8G8B8A8_UNORM; - attribute_desc[2].offset = IM_OFFSETOF(ImDrawVert, col); - - VkPipelineVertexInputStateCreateInfo vertex_info = {}; - vertex_info.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; - vertex_info.vertexBindingDescriptionCount = 1; - vertex_info.pVertexBindingDescriptions = binding_desc; - vertex_info.vertexAttributeDescriptionCount = 3; - vertex_info.pVertexAttributeDescriptions = attribute_desc; - - VkPipelineInputAssemblyStateCreateInfo ia_info = {}; - ia_info.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; - ia_info.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; - - VkPipelineViewportStateCreateInfo viewport_info = {}; - viewport_info.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; - viewport_info.viewportCount = 1; - viewport_info.scissorCount = 1; - - VkPipelineRasterizationStateCreateInfo raster_info = {}; - raster_info.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; - raster_info.polygonMode = VK_POLYGON_MODE_FILL; - raster_info.cullMode = VK_CULL_MODE_NONE; - raster_info.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; - raster_info.lineWidth = 1.0f; - - VkPipelineMultisampleStateCreateInfo ms_info = {}; - ms_info.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; - ms_info.rasterizationSamples = (MSAASamples != 0) ? MSAASamples : VK_SAMPLE_COUNT_1_BIT; - - VkPipelineColorBlendAttachmentState color_attachment[1] = {}; - color_attachment[0].blendEnable = VK_TRUE; - color_attachment[0].srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA; - color_attachment[0].dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; - color_attachment[0].colorBlendOp = VK_BLEND_OP_ADD; - color_attachment[0].srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE; - color_attachment[0].dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; - color_attachment[0].alphaBlendOp = VK_BLEND_OP_ADD; - color_attachment[0].colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT; - - VkPipelineDepthStencilStateCreateInfo depth_info = {}; - depth_info.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; - - VkPipelineColorBlendStateCreateInfo blend_info = {}; - blend_info.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; - blend_info.attachmentCount = 1; - blend_info.pAttachments = color_attachment; - - VkDynamicState dynamic_states[2] = { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR }; - VkPipelineDynamicStateCreateInfo dynamic_state = {}; - dynamic_state.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; - dynamic_state.dynamicStateCount = (uint32_t)IM_ARRAYSIZE(dynamic_states); - dynamic_state.pDynamicStates = dynamic_states; - - ImGui_ImplVulkan_CreatePipelineLayout(device, allocator); - - VkGraphicsPipelineCreateInfo info = {}; - info.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; - info.flags = bd->PipelineCreateFlags; - info.stageCount = 2; - info.pStages = stage; - info.pVertexInputState = &vertex_info; - info.pInputAssemblyState = &ia_info; - info.pViewportState = &viewport_info; - info.pRasterizationState = &raster_info; - info.pMultisampleState = &ms_info; - info.pDepthStencilState = &depth_info; - info.pColorBlendState = &blend_info; - info.pDynamicState = &dynamic_state; - info.layout = bd->PipelineLayout; - info.renderPass = renderPass; - info.subpass = subpass; - VkResult err = vkCreateGraphicsPipelines(device, pipelineCache, 1, &info, allocator, pipeline); - check_vk_result(err); -} - -bool ImGui_ImplVulkan_CreateDeviceObjects() -{ - ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData(); - ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo; - VkResult err; - - if (!bd->FontSampler) - { - VkSamplerCreateInfo info = {}; - info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; - info.magFilter = VK_FILTER_LINEAR; - info.minFilter = VK_FILTER_LINEAR; - info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR; - info.addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT; - info.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT; - info.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT; - info.minLod = -1000; - info.maxLod = 1000; - info.maxAnisotropy = 1.0f; - err = vkCreateSampler(v->Device, &info, v->Allocator, &bd->FontSampler); - check_vk_result(err); - } - - if (!bd->DescriptorSetLayout) - { - VkSampler sampler[1] = {bd->FontSampler}; - VkDescriptorSetLayoutBinding binding[1] = {}; - binding[0].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; - binding[0].descriptorCount = 1; - binding[0].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; - binding[0].pImmutableSamplers = sampler; - VkDescriptorSetLayoutCreateInfo info = {}; - info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; - info.bindingCount = 1; - info.pBindings = binding; - err = vkCreateDescriptorSetLayout(v->Device, &info, v->Allocator, &bd->DescriptorSetLayout); - check_vk_result(err); - } - - // Create Descriptor Set: - { - VkDescriptorSetAllocateInfo alloc_info = {}; - alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; - alloc_info.descriptorPool = v->DescriptorPool; - alloc_info.descriptorSetCount = 1; - alloc_info.pSetLayouts = &bd->DescriptorSetLayout; - err = vkAllocateDescriptorSets(v->Device, &alloc_info, &bd->DescriptorSet); - check_vk_result(err); - } - - if (!bd->PipelineLayout) - { - // Constants: we are using 'vec2 offset' and 'vec2 scale' instead of a full 3d projection matrix - VkPushConstantRange push_constants[1] = {}; - push_constants[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; - push_constants[0].offset = sizeof(float) * 0; - push_constants[0].size = sizeof(float) * 4; - VkDescriptorSetLayout set_layout[1] = { bd->DescriptorSetLayout }; - VkPipelineLayoutCreateInfo layout_info = {}; - layout_info.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; - layout_info.setLayoutCount = 1; - layout_info.pSetLayouts = set_layout; - layout_info.pushConstantRangeCount = 1; - layout_info.pPushConstantRanges = push_constants; - err = vkCreatePipelineLayout(v->Device, &layout_info, v->Allocator, &bd->PipelineLayout); - check_vk_result(err); - } - - ImGui_ImplVulkan_CreatePipeline(v->Device, v->Allocator, v->PipelineCache, bd->RenderPass, v->MSAASamples, &bd->Pipeline, bd->Subpass); - - return true; -} - -void ImGui_ImplVulkan_DestroyFontUploadObjects() -{ - ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData(); - ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo; - if (bd->UploadBuffer) - { - vkDestroyBuffer(v->Device, bd->UploadBuffer, v->Allocator); - bd->UploadBuffer = VK_NULL_HANDLE; - } - if (bd->UploadBufferMemory) - { - vkFreeMemory(v->Device, bd->UploadBufferMemory, v->Allocator); - bd->UploadBufferMemory = VK_NULL_HANDLE; - } -} - -void ImGui_ImplVulkan_DestroyDeviceObjects() -{ - ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData(); - ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo; - ImGui_ImplVulkanH_DestroyWindowRenderBuffers(v->Device, &bd->MainWindowRenderBuffers, v->Allocator); - ImGui_ImplVulkan_DestroyFontUploadObjects(); - - if (bd->ShaderModuleVert) { vkDestroyShaderModule(v->Device, bd->ShaderModuleVert, v->Allocator); bd->ShaderModuleVert = VK_NULL_HANDLE; } - if (bd->ShaderModuleFrag) { vkDestroyShaderModule(v->Device, bd->ShaderModuleFrag, v->Allocator); bd->ShaderModuleFrag = VK_NULL_HANDLE; } - if (bd->FontView) { vkDestroyImageView(v->Device, bd->FontView, v->Allocator); bd->FontView = VK_NULL_HANDLE; } - if (bd->FontImage) { vkDestroyImage(v->Device, bd->FontImage, v->Allocator); bd->FontImage = VK_NULL_HANDLE; } - if (bd->FontMemory) { vkFreeMemory(v->Device, bd->FontMemory, v->Allocator); bd->FontMemory = VK_NULL_HANDLE; } - if (bd->FontSampler) { vkDestroySampler(v->Device, bd->FontSampler, v->Allocator); bd->FontSampler = VK_NULL_HANDLE; } - if (bd->DescriptorSetLayout) { vkDestroyDescriptorSetLayout(v->Device, bd->DescriptorSetLayout, v->Allocator); bd->DescriptorSetLayout = VK_NULL_HANDLE; } - if (bd->PipelineLayout) { vkDestroyPipelineLayout(v->Device, bd->PipelineLayout, v->Allocator); bd->PipelineLayout = VK_NULL_HANDLE; } - if (bd->Pipeline) { vkDestroyPipeline(v->Device, bd->Pipeline, v->Allocator); bd->Pipeline = VK_NULL_HANDLE; } -} - -bool ImGui_ImplVulkan_LoadFunctions(PFN_vkVoidFunction(*loader_func)(const char* function_name, void* user_data), void* user_data) -{ - // Load function pointers - // You can use the default Vulkan loader using: - // ImGui_ImplVulkan_LoadFunctions([](const char* function_name, void*) { return vkGetInstanceProcAddr(your_vk_isntance, function_name); }); - // But this would be equivalent to not setting VK_NO_PROTOTYPES. -#ifdef VK_NO_PROTOTYPES -#define IMGUI_VULKAN_FUNC_LOAD(func) \ - func = reinterpret_cast(loader_func(#func, user_data)); \ - if (func == NULL) \ - return false; - IMGUI_VULKAN_FUNC_MAP(IMGUI_VULKAN_FUNC_LOAD) -#undef IMGUI_VULKAN_FUNC_LOAD -#else - IM_UNUSED(loader_func); - IM_UNUSED(user_data); -#endif - g_FunctionsLoaded = true; - return true; -} - -bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info, VkRenderPass render_pass) -{ - IM_ASSERT(g_FunctionsLoaded && "Need to call ImGui_ImplVulkan_LoadFunctions() if IMGUI_IMPL_VULKAN_NO_PROTOTYPES or VK_NO_PROTOTYPES are set!"); - - ImGuiIO& io = ImGui::GetIO(); - IM_ASSERT(io.BackendRendererUserData == NULL && "Already initialized a renderer backend!"); - - // Setup backend capabilities flags - ImGui_ImplVulkan_Data* bd = IM_NEW(ImGui_ImplVulkan_Data)(); - io.BackendRendererUserData = (void*)bd; - io.BackendRendererName = "imgui_impl_vulkan"; - io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. - - IM_ASSERT(info->Instance != VK_NULL_HANDLE); - IM_ASSERT(info->PhysicalDevice != VK_NULL_HANDLE); - IM_ASSERT(info->Device != VK_NULL_HANDLE); - IM_ASSERT(info->Queue != VK_NULL_HANDLE); - IM_ASSERT(info->DescriptorPool != VK_NULL_HANDLE); - IM_ASSERT(info->MinImageCount >= 2); - IM_ASSERT(info->ImageCount >= info->MinImageCount); - IM_ASSERT(render_pass != VK_NULL_HANDLE); - - bd->VulkanInitInfo = *info; - bd->RenderPass = render_pass; - bd->Subpass = info->Subpass; - - ImGui_ImplVulkan_CreateDeviceObjects(); - - return true; -} - -void ImGui_ImplVulkan_Shutdown() -{ - ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData(); - IM_ASSERT(bd != NULL && "No renderer backend to shutdown, or already shutdown?"); - ImGuiIO& io = ImGui::GetIO(); - - ImGui_ImplVulkan_DestroyDeviceObjects(); - io.BackendRendererName = NULL; - io.BackendRendererUserData = NULL; - IM_DELETE(bd); -} - -void ImGui_ImplVulkan_NewFrame() -{ - ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData(); - IM_ASSERT(bd != NULL && "Did you call ImGui_ImplVulkan_Init()?"); - IM_UNUSED(bd); -} - -void ImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count) -{ - ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData(); - IM_ASSERT(min_image_count >= 2); - if (bd->VulkanInitInfo.MinImageCount == min_image_count) - return; - - ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo; - VkResult err = vkDeviceWaitIdle(v->Device); - check_vk_result(err); - ImGui_ImplVulkanH_DestroyWindowRenderBuffers(v->Device, &bd->MainWindowRenderBuffers, v->Allocator); - bd->VulkanInitInfo.MinImageCount = min_image_count; -} - - -//------------------------------------------------------------------------- -// Internal / Miscellaneous Vulkan Helpers -// (Used by example's main.cpp. Used by multi-viewport features. PROBABLY NOT used by your own app.) -//------------------------------------------------------------------------- -// You probably do NOT need to use or care about those functions. -// Those functions only exist because: -// 1) they facilitate the readability and maintenance of the multiple main.cpp examples files. -// 2) the upcoming multi-viewport feature will need them internally. -// Generally we avoid exposing any kind of superfluous high-level helpers in the backends, -// but it is too much code to duplicate everywhere so we exceptionally expose them. -// -// Your engine/app will likely _already_ have code to setup all that stuff (swap chain, render pass, frame buffers, etc.). -// You may read this code to learn about Vulkan, but it is recommended you use you own custom tailored code to do equivalent work. -// (The ImGui_ImplVulkanH_XXX functions do not interact with any of the state used by the regular ImGui_ImplVulkan_XXX functions) -//------------------------------------------------------------------------- - -VkSurfaceFormatKHR ImGui_ImplVulkanH_SelectSurfaceFormat(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkFormat* request_formats, int request_formats_count, VkColorSpaceKHR request_color_space) -{ - IM_ASSERT(g_FunctionsLoaded && "Need to call ImGui_ImplVulkan_LoadFunctions() if IMGUI_IMPL_VULKAN_NO_PROTOTYPES or VK_NO_PROTOTYPES are set!"); - IM_ASSERT(request_formats != NULL); - IM_ASSERT(request_formats_count > 0); - - // Per Spec Format and View Format are expected to be the same unless VK_IMAGE_CREATE_MUTABLE_BIT was set at image creation - // Assuming that the default behavior is without setting this bit, there is no need for separate Swapchain image and image view format - // Additionally several new color spaces were introduced with Vulkan Spec v1.0.40, - // hence we must make sure that a format with the mostly available color space, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR, is found and used. - uint32_t avail_count; - vkGetPhysicalDeviceSurfaceFormatsKHR(physical_device, surface, &avail_count, NULL); - ImVector avail_format; - avail_format.resize((int)avail_count); - vkGetPhysicalDeviceSurfaceFormatsKHR(physical_device, surface, &avail_count, avail_format.Data); - - // First check if only one format, VK_FORMAT_UNDEFINED, is available, which would imply that any format is available - if (avail_count == 1) - { - if (avail_format[0].format == VK_FORMAT_UNDEFINED) - { - VkSurfaceFormatKHR ret; - ret.format = request_formats[0]; - ret.colorSpace = request_color_space; - return ret; - } - else - { - // No point in searching another format - return avail_format[0]; - } - } - else - { - // Request several formats, the first found will be used - for (int request_i = 0; request_i < request_formats_count; request_i++) - for (uint32_t avail_i = 0; avail_i < avail_count; avail_i++) - if (avail_format[avail_i].format == request_formats[request_i] && avail_format[avail_i].colorSpace == request_color_space) - return avail_format[avail_i]; - - // If none of the requested image formats could be found, use the first available - return avail_format[0]; - } -} - -VkPresentModeKHR ImGui_ImplVulkanH_SelectPresentMode(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkPresentModeKHR* request_modes, int request_modes_count) -{ - IM_ASSERT(g_FunctionsLoaded && "Need to call ImGui_ImplVulkan_LoadFunctions() if IMGUI_IMPL_VULKAN_NO_PROTOTYPES or VK_NO_PROTOTYPES are set!"); - IM_ASSERT(request_modes != NULL); - IM_ASSERT(request_modes_count > 0); - - // Request a certain mode and confirm that it is available. If not use VK_PRESENT_MODE_FIFO_KHR which is mandatory - uint32_t avail_count = 0; - vkGetPhysicalDeviceSurfacePresentModesKHR(physical_device, surface, &avail_count, NULL); - ImVector avail_modes; - avail_modes.resize((int)avail_count); - vkGetPhysicalDeviceSurfacePresentModesKHR(physical_device, surface, &avail_count, avail_modes.Data); - //for (uint32_t avail_i = 0; avail_i < avail_count; avail_i++) - // printf("[vulkan] avail_modes[%d] = %d\n", avail_i, avail_modes[avail_i]); - - for (int request_i = 0; request_i < request_modes_count; request_i++) - for (uint32_t avail_i = 0; avail_i < avail_count; avail_i++) - if (request_modes[request_i] == avail_modes[avail_i]) - return request_modes[request_i]; - - return VK_PRESENT_MODE_FIFO_KHR; // Always available -} - -void ImGui_ImplVulkanH_CreateWindowCommandBuffers(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, uint32_t queue_family, const VkAllocationCallbacks* allocator) -{ - IM_ASSERT(physical_device != VK_NULL_HANDLE && device != VK_NULL_HANDLE); - (void)physical_device; - (void)allocator; - - // Create Command Buffers - VkResult err; - for (uint32_t i = 0; i < wd->ImageCount; i++) - { - ImGui_ImplVulkanH_Frame* fd = &wd->Frames[i]; - ImGui_ImplVulkanH_FrameSemaphores* fsd = &wd->FrameSemaphores[i]; - { - VkCommandPoolCreateInfo info = {}; - info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; - info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; - info.queueFamilyIndex = queue_family; - err = vkCreateCommandPool(device, &info, allocator, &fd->CommandPool); - check_vk_result(err); - } - { - VkCommandBufferAllocateInfo info = {}; - info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; - info.commandPool = fd->CommandPool; - info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; - info.commandBufferCount = 1; - err = vkAllocateCommandBuffers(device, &info, &fd->CommandBuffer); - check_vk_result(err); - } - { - VkFenceCreateInfo info = {}; - info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; - info.flags = VK_FENCE_CREATE_SIGNALED_BIT; - err = vkCreateFence(device, &info, allocator, &fd->Fence); - check_vk_result(err); - } - { - VkSemaphoreCreateInfo info = {}; - info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; - err = vkCreateSemaphore(device, &info, allocator, &fsd->ImageAcquiredSemaphore); - check_vk_result(err); - err = vkCreateSemaphore(device, &info, allocator, &fsd->RenderCompleteSemaphore); - check_vk_result(err); - } - } -} - -int ImGui_ImplVulkanH_GetMinImageCountFromPresentMode(VkPresentModeKHR present_mode) -{ - if (present_mode == VK_PRESENT_MODE_MAILBOX_KHR) - return 3; - if (present_mode == VK_PRESENT_MODE_FIFO_KHR || present_mode == VK_PRESENT_MODE_FIFO_RELAXED_KHR) - return 2; - if (present_mode == VK_PRESENT_MODE_IMMEDIATE_KHR) - return 1; - IM_ASSERT(0); - return 1; -} - -// Also destroy old swap chain and in-flight frames data, if any. -void ImGui_ImplVulkanH_CreateWindowSwapChain(VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, const VkAllocationCallbacks* allocator, int w, int h, uint32_t min_image_count) -{ - VkResult err; - VkSwapchainKHR old_swapchain = wd->Swapchain; - wd->Swapchain = VK_NULL_HANDLE; - err = vkDeviceWaitIdle(device); - check_vk_result(err); - - // We don't use ImGui_ImplVulkanH_DestroyWindow() because we want to preserve the old swapchain to create the new one. - // Destroy old Framebuffer - for (uint32_t i = 0; i < wd->ImageCount; i++) - { - ImGui_ImplVulkanH_DestroyFrame(device, &wd->Frames[i], allocator); - ImGui_ImplVulkanH_DestroyFrameSemaphores(device, &wd->FrameSemaphores[i], allocator); - } - IM_FREE(wd->Frames); - IM_FREE(wd->FrameSemaphores); - wd->Frames = NULL; - wd->FrameSemaphores = NULL; - wd->ImageCount = 0; - if (wd->RenderPass) - vkDestroyRenderPass(device, wd->RenderPass, allocator); - if (wd->Pipeline) - vkDestroyPipeline(device, wd->Pipeline, allocator); - - // If min image count was not specified, request different count of images dependent on selected present mode - if (min_image_count == 0) - min_image_count = ImGui_ImplVulkanH_GetMinImageCountFromPresentMode(wd->PresentMode); - - // Create Swapchain - { - VkSwapchainCreateInfoKHR info = {}; - info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; - info.surface = wd->Surface; - info.minImageCount = min_image_count; - info.imageFormat = wd->SurfaceFormat.format; - info.imageColorSpace = wd->SurfaceFormat.colorSpace; - info.imageArrayLayers = 1; - info.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; - info.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE; // Assume that graphics family == present family - info.preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR; - info.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR; - info.presentMode = wd->PresentMode; - info.clipped = VK_TRUE; - info.oldSwapchain = old_swapchain; - VkSurfaceCapabilitiesKHR cap; - err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physical_device, wd->Surface, &cap); - check_vk_result(err); - if (info.minImageCount < cap.minImageCount) - info.minImageCount = cap.minImageCount; - else if (cap.maxImageCount != 0 && info.minImageCount > cap.maxImageCount) - info.minImageCount = cap.maxImageCount; - - if (cap.currentExtent.width == 0xffffffff) - { - info.imageExtent.width = wd->Width = w; - info.imageExtent.height = wd->Height = h; - } - else - { - info.imageExtent.width = wd->Width = cap.currentExtent.width; - info.imageExtent.height = wd->Height = cap.currentExtent.height; - } - err = vkCreateSwapchainKHR(device, &info, allocator, &wd->Swapchain); - check_vk_result(err); - err = vkGetSwapchainImagesKHR(device, wd->Swapchain, &wd->ImageCount, NULL); - check_vk_result(err); - VkImage backbuffers[16] = {}; - IM_ASSERT(wd->ImageCount >= min_image_count); - IM_ASSERT(wd->ImageCount < IM_ARRAYSIZE(backbuffers)); - err = vkGetSwapchainImagesKHR(device, wd->Swapchain, &wd->ImageCount, backbuffers); - check_vk_result(err); - - IM_ASSERT(wd->Frames == NULL); - wd->Frames = (ImGui_ImplVulkanH_Frame*)IM_ALLOC(sizeof(ImGui_ImplVulkanH_Frame) * wd->ImageCount); - wd->FrameSemaphores = (ImGui_ImplVulkanH_FrameSemaphores*)IM_ALLOC(sizeof(ImGui_ImplVulkanH_FrameSemaphores) * wd->ImageCount); - memset(wd->Frames, 0, sizeof(wd->Frames[0]) * wd->ImageCount); - memset(wd->FrameSemaphores, 0, sizeof(wd->FrameSemaphores[0]) * wd->ImageCount); - for (uint32_t i = 0; i < wd->ImageCount; i++) - wd->Frames[i].Backbuffer = backbuffers[i]; - } - if (old_swapchain) - vkDestroySwapchainKHR(device, old_swapchain, allocator); - - // Create the Render Pass - { - VkAttachmentDescription attachment = {}; - attachment.format = wd->SurfaceFormat.format; - attachment.samples = VK_SAMPLE_COUNT_1_BIT; - attachment.loadOp = wd->ClearEnable ? VK_ATTACHMENT_LOAD_OP_CLEAR : VK_ATTACHMENT_LOAD_OP_DONT_CARE; - attachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE; - attachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; - attachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; - attachment.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; - attachment.finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; - VkAttachmentReference color_attachment = {}; - color_attachment.attachment = 0; - color_attachment.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; - VkSubpassDescription subpass = {}; - subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS; - subpass.colorAttachmentCount = 1; - subpass.pColorAttachments = &color_attachment; - VkSubpassDependency dependency = {}; - dependency.srcSubpass = VK_SUBPASS_EXTERNAL; - dependency.dstSubpass = 0; - dependency.srcStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; - dependency.dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; - dependency.srcAccessMask = 0; - dependency.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; - VkRenderPassCreateInfo info = {}; - info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; - info.attachmentCount = 1; - info.pAttachments = &attachment; - info.subpassCount = 1; - info.pSubpasses = &subpass; - info.dependencyCount = 1; - info.pDependencies = &dependency; - err = vkCreateRenderPass(device, &info, allocator, &wd->RenderPass); - check_vk_result(err); - - // We do not create a pipeline by default as this is also used by examples' main.cpp, - // but secondary viewport in multi-viewport mode may want to create one with: - //ImGui_ImplVulkan_CreatePipeline(device, allocator, VK_NULL_HANDLE, wd->RenderPass, VK_SAMPLE_COUNT_1_BIT, &wd->Pipeline, bd->Subpass); - } - - // Create The Image Views - { - VkImageViewCreateInfo info = {}; - info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; - info.viewType = VK_IMAGE_VIEW_TYPE_2D; - info.format = wd->SurfaceFormat.format; - info.components.r = VK_COMPONENT_SWIZZLE_R; - info.components.g = VK_COMPONENT_SWIZZLE_G; - info.components.b = VK_COMPONENT_SWIZZLE_B; - info.components.a = VK_COMPONENT_SWIZZLE_A; - VkImageSubresourceRange image_range = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 }; - info.subresourceRange = image_range; - for (uint32_t i = 0; i < wd->ImageCount; i++) - { - ImGui_ImplVulkanH_Frame* fd = &wd->Frames[i]; - info.image = fd->Backbuffer; - err = vkCreateImageView(device, &info, allocator, &fd->BackbufferView); - check_vk_result(err); - } - } - - // Create Framebuffer - { - VkImageView attachment[1]; - VkFramebufferCreateInfo info = {}; - info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; - info.renderPass = wd->RenderPass; - info.attachmentCount = 1; - info.pAttachments = attachment; - info.width = wd->Width; - info.height = wd->Height; - info.layers = 1; - for (uint32_t i = 0; i < wd->ImageCount; i++) - { - ImGui_ImplVulkanH_Frame* fd = &wd->Frames[i]; - attachment[0] = fd->BackbufferView; - err = vkCreateFramebuffer(device, &info, allocator, &fd->Framebuffer); - check_vk_result(err); - } - } -} - -// Create or resize window -void ImGui_ImplVulkanH_CreateOrResizeWindow(VkInstance instance, VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wd, uint32_t queue_family, const VkAllocationCallbacks* allocator, int width, int height, uint32_t min_image_count) -{ - IM_ASSERT(g_FunctionsLoaded && "Need to call ImGui_ImplVulkan_LoadFunctions() if IMGUI_IMPL_VULKAN_NO_PROTOTYPES or VK_NO_PROTOTYPES are set!"); - (void)instance; - ImGui_ImplVulkanH_CreateWindowSwapChain(physical_device, device, wd, allocator, width, height, min_image_count); - ImGui_ImplVulkanH_CreateWindowCommandBuffers(physical_device, device, wd, queue_family, allocator); -} - -void ImGui_ImplVulkanH_DestroyWindow(VkInstance instance, VkDevice device, ImGui_ImplVulkanH_Window* wd, const VkAllocationCallbacks* allocator) -{ - vkDeviceWaitIdle(device); // FIXME: We could wait on the Queue if we had the queue in wd-> (otherwise VulkanH functions can't use globals) - //vkQueueWaitIdle(bd->Queue); - - for (uint32_t i = 0; i < wd->ImageCount; i++) - { - ImGui_ImplVulkanH_DestroyFrame(device, &wd->Frames[i], allocator); - ImGui_ImplVulkanH_DestroyFrameSemaphores(device, &wd->FrameSemaphores[i], allocator); - } - IM_FREE(wd->Frames); - IM_FREE(wd->FrameSemaphores); - wd->Frames = NULL; - wd->FrameSemaphores = NULL; - vkDestroyPipeline(device, wd->Pipeline, allocator); - vkDestroyRenderPass(device, wd->RenderPass, allocator); - vkDestroySwapchainKHR(device, wd->Swapchain, allocator); - vkDestroySurfaceKHR(instance, wd->Surface, allocator); - - *wd = ImGui_ImplVulkanH_Window(); -} - -void ImGui_ImplVulkanH_DestroyFrame(VkDevice device, ImGui_ImplVulkanH_Frame* fd, const VkAllocationCallbacks* allocator) -{ - vkDestroyFence(device, fd->Fence, allocator); - vkFreeCommandBuffers(device, fd->CommandPool, 1, &fd->CommandBuffer); - vkDestroyCommandPool(device, fd->CommandPool, allocator); - fd->Fence = VK_NULL_HANDLE; - fd->CommandBuffer = VK_NULL_HANDLE; - fd->CommandPool = VK_NULL_HANDLE; - - vkDestroyImageView(device, fd->BackbufferView, allocator); - vkDestroyFramebuffer(device, fd->Framebuffer, allocator); -} - -void ImGui_ImplVulkanH_DestroyFrameSemaphores(VkDevice device, ImGui_ImplVulkanH_FrameSemaphores* fsd, const VkAllocationCallbacks* allocator) -{ - vkDestroySemaphore(device, fsd->ImageAcquiredSemaphore, allocator); - vkDestroySemaphore(device, fsd->RenderCompleteSemaphore, allocator); - fsd->ImageAcquiredSemaphore = fsd->RenderCompleteSemaphore = VK_NULL_HANDLE; -} - -void ImGui_ImplVulkanH_DestroyFrameRenderBuffers(VkDevice device, ImGui_ImplVulkanH_FrameRenderBuffers* buffers, const VkAllocationCallbacks* allocator) -{ - if (buffers->VertexBuffer) { vkDestroyBuffer(device, buffers->VertexBuffer, allocator); buffers->VertexBuffer = VK_NULL_HANDLE; } - if (buffers->VertexBufferMemory) { vkFreeMemory(device, buffers->VertexBufferMemory, allocator); buffers->VertexBufferMemory = VK_NULL_HANDLE; } - if (buffers->IndexBuffer) { vkDestroyBuffer(device, buffers->IndexBuffer, allocator); buffers->IndexBuffer = VK_NULL_HANDLE; } - if (buffers->IndexBufferMemory) { vkFreeMemory(device, buffers->IndexBufferMemory, allocator); buffers->IndexBufferMemory = VK_NULL_HANDLE; } - buffers->VertexBufferSize = 0; - buffers->IndexBufferSize = 0; -} - -void ImGui_ImplVulkanH_DestroyWindowRenderBuffers(VkDevice device, ImGui_ImplVulkanH_WindowRenderBuffers* buffers, const VkAllocationCallbacks* allocator) -{ - for (uint32_t n = 0; n < buffers->Count; n++) - ImGui_ImplVulkanH_DestroyFrameRenderBuffers(device, &buffers->FrameRenderBuffers[n], allocator); - IM_FREE(buffers->FrameRenderBuffers); - buffers->FrameRenderBuffers = NULL; - buffers->Index = 0; - buffers->Count = 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_vulkan.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_vulkan.h deleted file mode 100644 index c770d0c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_vulkan.h +++ /dev/null @@ -1,149 +0,0 @@ -// dear imgui: Renderer Backend for Vulkan -// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..) - -// Implemented features: -// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. -// Missing features: -// [ ] Renderer: User texture binding. Changes of ImTextureID aren't supported by this backend! See https://github.com/ocornut/imgui/pull/914 - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -// The aim of imgui_impl_vulkan.h/.cpp is to be usable in your engine without any modification. -// IF YOU FEEL YOU NEED TO MAKE ANY CHANGE TO THIS CODE, please share them and your feedback at https://github.com/ocornut/imgui/ - -// Important note to the reader who wish to integrate imgui_impl_vulkan.cpp/.h in their own engine/app. -// - Common ImGui_ImplVulkan_XXX functions and structures are used to interface with imgui_impl_vulkan.cpp/.h. -// You will use those if you want to use this rendering backend in your engine/app. -// - Helper ImGui_ImplVulkanH_XXX functions and structures are only used by this example (main.cpp) and by -// the backend itself (imgui_impl_vulkan.cpp), but should PROBABLY NOT be used by your own engine/app code. -// Read comments in imgui_impl_vulkan.h. - -#pragma once -#include "imgui.h" // IMGUI_IMPL_API - -// [Configuration] in order to use a custom Vulkan function loader: -// (1) You'll need to disable default Vulkan function prototypes. -// We provide a '#define IMGUI_IMPL_VULKAN_NO_PROTOTYPES' convenience configuration flag. -// In order to make sure this is visible from the imgui_impl_vulkan.cpp compilation unit: -// - Add '#define IMGUI_IMPL_VULKAN_NO_PROTOTYPES' in your imconfig.h file -// - Or as a compilation flag in your build system -// - Or uncomment here (not recommended because you'd be modifying imgui sources!) -// - Do not simply add it in a .cpp file! -// (2) Call ImGui_ImplVulkan_LoadFunctions() before ImGui_ImplVulkan_Init() with your custom function. -// If you have no idea what this is, leave it alone! -//#define IMGUI_IMPL_VULKAN_NO_PROTOTYPES - -// Vulkan includes -#if defined(IMGUI_IMPL_VULKAN_NO_PROTOTYPES) && !defined(VK_NO_PROTOTYPES) -#define VK_NO_PROTOTYPES -#endif -#include - -// Initialization data, for ImGui_ImplVulkan_Init() -// [Please zero-clear before use!] -struct ImGui_ImplVulkan_InitInfo -{ - VkInstance Instance; - VkPhysicalDevice PhysicalDevice; - VkDevice Device; - uint32_t QueueFamily; - VkQueue Queue; - VkPipelineCache PipelineCache; - VkDescriptorPool DescriptorPool; - uint32_t Subpass; - uint32_t MinImageCount; // >= 2 - uint32_t ImageCount; // >= MinImageCount - VkSampleCountFlagBits MSAASamples; // >= VK_SAMPLE_COUNT_1_BIT - const VkAllocationCallbacks* Allocator; - void (*CheckVkResultFn)(VkResult err); -}; - -// Called by user code -IMGUI_IMPL_API bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info, VkRenderPass render_pass); -IMGUI_IMPL_API void ImGui_ImplVulkan_Shutdown(); -IMGUI_IMPL_API void ImGui_ImplVulkan_NewFrame(); -IMGUI_IMPL_API void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer command_buffer, VkPipeline pipeline = VK_NULL_HANDLE); -IMGUI_IMPL_API bool ImGui_ImplVulkan_CreateFontsTexture(VkCommandBuffer command_buffer); -IMGUI_IMPL_API void ImGui_ImplVulkan_DestroyFontUploadObjects(); -IMGUI_IMPL_API void ImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count); // To override MinImageCount after initialization (e.g. if swap chain is recreated) - -// Optional: load Vulkan functions with a custom function loader -// This is only useful with IMGUI_IMPL_VULKAN_NO_PROTOTYPES / VK_NO_PROTOTYPES -IMGUI_IMPL_API bool ImGui_ImplVulkan_LoadFunctions(PFN_vkVoidFunction(*loader_func)(const char* function_name, void* user_data), void* user_data = NULL); - -//------------------------------------------------------------------------- -// Internal / Miscellaneous Vulkan Helpers -// (Used by example's main.cpp. Used by multi-viewport features. PROBABLY NOT used by your own engine/app.) -//------------------------------------------------------------------------- -// You probably do NOT need to use or care about those functions. -// Those functions only exist because: -// 1) they facilitate the readability and maintenance of the multiple main.cpp examples files. -// 2) the upcoming multi-viewport feature will need them internally. -// Generally we avoid exposing any kind of superfluous high-level helpers in the backends, -// but it is too much code to duplicate everywhere so we exceptionally expose them. -// -// Your engine/app will likely _already_ have code to setup all that stuff (swap chain, render pass, frame buffers, etc.). -// You may read this code to learn about Vulkan, but it is recommended you use you own custom tailored code to do equivalent work. -// (The ImGui_ImplVulkanH_XXX functions do not interact with any of the state used by the regular ImGui_ImplVulkan_XXX functions) -//------------------------------------------------------------------------- - -struct ImGui_ImplVulkanH_Frame; -struct ImGui_ImplVulkanH_Window; - -// Helpers -IMGUI_IMPL_API void ImGui_ImplVulkanH_CreateOrResizeWindow(VkInstance instance, VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wnd, uint32_t queue_family, const VkAllocationCallbacks* allocator, int w, int h, uint32_t min_image_count); -IMGUI_IMPL_API void ImGui_ImplVulkanH_DestroyWindow(VkInstance instance, VkDevice device, ImGui_ImplVulkanH_Window* wnd, const VkAllocationCallbacks* allocator); -IMGUI_IMPL_API VkSurfaceFormatKHR ImGui_ImplVulkanH_SelectSurfaceFormat(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkFormat* request_formats, int request_formats_count, VkColorSpaceKHR request_color_space); -IMGUI_IMPL_API VkPresentModeKHR ImGui_ImplVulkanH_SelectPresentMode(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkPresentModeKHR* request_modes, int request_modes_count); -IMGUI_IMPL_API int ImGui_ImplVulkanH_GetMinImageCountFromPresentMode(VkPresentModeKHR present_mode); - -// Helper structure to hold the data needed by one rendering frame -// (Used by example's main.cpp. Used by multi-viewport features. Probably NOT used by your own engine/app.) -// [Please zero-clear before use!] -struct ImGui_ImplVulkanH_Frame -{ - VkCommandPool CommandPool; - VkCommandBuffer CommandBuffer; - VkFence Fence; - VkImage Backbuffer; - VkImageView BackbufferView; - VkFramebuffer Framebuffer; -}; - -struct ImGui_ImplVulkanH_FrameSemaphores -{ - VkSemaphore ImageAcquiredSemaphore; - VkSemaphore RenderCompleteSemaphore; -}; - -// Helper structure to hold the data needed by one rendering context into one OS window -// (Used by example's main.cpp. Used by multi-viewport features. Probably NOT used by your own engine/app.) -struct ImGui_ImplVulkanH_Window -{ - int Width; - int Height; - VkSwapchainKHR Swapchain; - VkSurfaceKHR Surface; - VkSurfaceFormatKHR SurfaceFormat; - VkPresentModeKHR PresentMode; - VkRenderPass RenderPass; - VkPipeline Pipeline; // The window pipeline may uses a different VkRenderPass than the one passed in ImGui_ImplVulkan_InitInfo - bool ClearEnable; - VkClearValue ClearValue; - uint32_t FrameIndex; // Current frame being rendered to (0 <= FrameIndex < FrameInFlightCount) - uint32_t ImageCount; // Number of simultaneous in-flight frames (returned by vkGetSwapchainImagesKHR, usually derived from min_image_count) - uint32_t SemaphoreIndex; // Current set of swapchain wait semaphores we're using (needs to be distinct from per frame data) - ImGui_ImplVulkanH_Frame* Frames; - ImGui_ImplVulkanH_FrameSemaphores* FrameSemaphores; - - ImGui_ImplVulkanH_Window() - { - memset(this, 0, sizeof(*this)); - PresentMode = VK_PRESENT_MODE_MAX_ENUM_KHR; - ClearEnable = true; - } -}; - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_wgpu.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_wgpu.cpp deleted file mode 100644 index 2f621ed..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_wgpu.cpp +++ /dev/null @@ -1,717 +0,0 @@ -// dear imgui: Renderer for WebGPU -// This needs to be used along with a Platform Binding (e.g. GLFW) -// (Please note that WebGPU is currently experimental, will not run on non-beta browsers, and may break.) - -// Implemented features: -// [X] Renderer: User texture binding. Use 'WGPUTextureView' as ImTextureID. Read the FAQ about ImTextureID! -// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -// CHANGELOG -// (minor and older changes stripped away, please see git history for details) -// 2021-08-24: Fix for latest specs. -// 2021-05-24: Add support for draw_data->FramebufferScale. -// 2021-05-19: Replaced direct access to ImDrawCmd::TextureId with a call to ImDrawCmd::GetTexID(). (will become a requirement) -// 2021-05-16: Update to latest WebGPU specs (compatible with Emscripten 2.0.20 and Chrome Canary 92). -// 2021-02-18: Change blending equation to preserve alpha in output buffer. -// 2021-01-28: Initial version. - -#include "imgui.h" -#include "imgui_impl_wgpu.h" -#include -#include - -#define HAS_EMSCRIPTEN_VERSION(major, minor, tiny) (__EMSCRIPTEN_major__ > (major) || (__EMSCRIPTEN_major__ == (major) && __EMSCRIPTEN_minor__ > (minor)) || (__EMSCRIPTEN_major__ == (major) && __EMSCRIPTEN_minor__ == (minor) && __EMSCRIPTEN_tiny__ >= (tiny))) - -#if defined(__EMSCRIPTEN__) && !HAS_EMSCRIPTEN_VERSION(2, 0, 20) -#error "Requires at least emscripten 2.0.20" -#endif - -// Dear ImGui prototypes from imgui_internal.h -extern ImGuiID ImHashData(const void* data_p, size_t data_size, ImU32 seed = 0); - -// WebGPU data -static WGPUDevice g_wgpuDevice = NULL; -static WGPUQueue g_defaultQueue = NULL; -static WGPUTextureFormat g_renderTargetFormat = WGPUTextureFormat_Undefined; -static WGPURenderPipeline g_pipelineState = NULL; - -struct RenderResources -{ - WGPUTexture FontTexture; // Font texture - WGPUTextureView FontTextureView; // Texture view for font texture - WGPUSampler Sampler; // Sampler for the font texture - WGPUBuffer Uniforms; // Shader uniforms - WGPUBindGroup CommonBindGroup; // Resources bind-group to bind the common resources to pipeline - ImGuiStorage ImageBindGroups; // Resources bind-group to bind the font/image resources to pipeline (this is a key->value map) - WGPUBindGroup ImageBindGroup; // Default font-resource of Dear ImGui - WGPUBindGroupLayout ImageBindGroupLayout; // Cache layout used for the image bind group. Avoids allocating unnecessary JS objects when working with WebASM -}; -static RenderResources g_resources; - -struct FrameResources -{ - WGPUBuffer IndexBuffer; - WGPUBuffer VertexBuffer; - ImDrawIdx* IndexBufferHost; - ImDrawVert* VertexBufferHost; - int IndexBufferSize; - int VertexBufferSize; -}; -static FrameResources* g_pFrameResources = NULL; -static unsigned int g_numFramesInFlight = 0; -static unsigned int g_frameIndex = UINT_MAX; - -struct Uniforms -{ - float MVP[4][4]; -}; - -//----------------------------------------------------------------------------- -// SHADERS -//----------------------------------------------------------------------------- - -// glsl_shader.vert, compiled with: -// # glslangValidator -V -x -o glsl_shader.vert.u32 glsl_shader.vert -/* -#version 450 core -layout(location = 0) in vec2 aPos; -layout(location = 1) in vec2 aUV; -layout(location = 2) in vec4 aColor; -layout(set=0, binding = 0) uniform transform { mat4 mvp; }; - -out gl_PerVertex { vec4 gl_Position; }; -layout(location = 0) out struct { vec4 Color; vec2 UV; } Out; - -void main() -{ - Out.Color = aColor; - Out.UV = aUV; - gl_Position = mvp * vec4(aPos, 0, 1); -} -*/ -static uint32_t __glsl_shader_vert_spv[] = -{ - 0x07230203,0x00010000,0x00080007,0x0000002c,0x00000000,0x00020011,0x00000001,0x0006000b, - 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, - 0x000a000f,0x00000000,0x00000004,0x6e69616d,0x00000000,0x0000000b,0x0000000f,0x00000015, - 0x0000001b,0x00000023,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d, - 0x00000000,0x00030005,0x00000009,0x00000000,0x00050006,0x00000009,0x00000000,0x6f6c6f43, - 0x00000072,0x00040006,0x00000009,0x00000001,0x00005655,0x00030005,0x0000000b,0x0074754f, - 0x00040005,0x0000000f,0x6c6f4361,0x0000726f,0x00030005,0x00000015,0x00565561,0x00060005, - 0x00000019,0x505f6c67,0x65567265,0x78657472,0x00000000,0x00060006,0x00000019,0x00000000, - 0x505f6c67,0x7469736f,0x006e6f69,0x00030005,0x0000001b,0x00000000,0x00050005,0x0000001d, - 0x6e617274,0x726f6673,0x0000006d,0x00040006,0x0000001d,0x00000000,0x0070766d,0x00030005, - 0x0000001f,0x00000000,0x00040005,0x00000023,0x736f5061,0x00000000,0x00040047,0x0000000b, - 0x0000001e,0x00000000,0x00040047,0x0000000f,0x0000001e,0x00000002,0x00040047,0x00000015, - 0x0000001e,0x00000001,0x00050048,0x00000019,0x00000000,0x0000000b,0x00000000,0x00030047, - 0x00000019,0x00000002,0x00040048,0x0000001d,0x00000000,0x00000005,0x00050048,0x0000001d, - 0x00000000,0x00000023,0x00000000,0x00050048,0x0000001d,0x00000000,0x00000007,0x00000010, - 0x00030047,0x0000001d,0x00000002,0x00040047,0x0000001f,0x00000022,0x00000000,0x00040047, - 0x0000001f,0x00000021,0x00000000,0x00040047,0x00000023,0x0000001e,0x00000000,0x00020013, - 0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020,0x00040017, - 0x00000007,0x00000006,0x00000004,0x00040017,0x00000008,0x00000006,0x00000002,0x0004001e, - 0x00000009,0x00000007,0x00000008,0x00040020,0x0000000a,0x00000003,0x00000009,0x0004003b, - 0x0000000a,0x0000000b,0x00000003,0x00040015,0x0000000c,0x00000020,0x00000001,0x0004002b, - 0x0000000c,0x0000000d,0x00000000,0x00040020,0x0000000e,0x00000001,0x00000007,0x0004003b, - 0x0000000e,0x0000000f,0x00000001,0x00040020,0x00000011,0x00000003,0x00000007,0x0004002b, - 0x0000000c,0x00000013,0x00000001,0x00040020,0x00000014,0x00000001,0x00000008,0x0004003b, - 0x00000014,0x00000015,0x00000001,0x00040020,0x00000017,0x00000003,0x00000008,0x0003001e, - 0x00000019,0x00000007,0x00040020,0x0000001a,0x00000003,0x00000019,0x0004003b,0x0000001a, - 0x0000001b,0x00000003,0x00040018,0x0000001c,0x00000007,0x00000004,0x0003001e,0x0000001d, - 0x0000001c,0x00040020,0x0000001e,0x00000002,0x0000001d,0x0004003b,0x0000001e,0x0000001f, - 0x00000002,0x00040020,0x00000020,0x00000002,0x0000001c,0x0004003b,0x00000014,0x00000023, - 0x00000001,0x0004002b,0x00000006,0x00000025,0x00000000,0x0004002b,0x00000006,0x00000026, - 0x3f800000,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005, - 0x0004003d,0x00000007,0x00000010,0x0000000f,0x00050041,0x00000011,0x00000012,0x0000000b, - 0x0000000d,0x0003003e,0x00000012,0x00000010,0x0004003d,0x00000008,0x00000016,0x00000015, - 0x00050041,0x00000017,0x00000018,0x0000000b,0x00000013,0x0003003e,0x00000018,0x00000016, - 0x00050041,0x00000020,0x00000021,0x0000001f,0x0000000d,0x0004003d,0x0000001c,0x00000022, - 0x00000021,0x0004003d,0x00000008,0x00000024,0x00000023,0x00050051,0x00000006,0x00000027, - 0x00000024,0x00000000,0x00050051,0x00000006,0x00000028,0x00000024,0x00000001,0x00070050, - 0x00000007,0x00000029,0x00000027,0x00000028,0x00000025,0x00000026,0x00050091,0x00000007, - 0x0000002a,0x00000022,0x00000029,0x00050041,0x00000011,0x0000002b,0x0000001b,0x0000000d, - 0x0003003e,0x0000002b,0x0000002a,0x000100fd,0x00010038 -}; - -// glsl_shader.frag, compiled with: -// # glslangValidator -V -x -o glsl_shader.frag.u32 glsl_shader.frag -/* -#version 450 core -layout(location = 0) out vec4 fColor; -layout(set=0, binding=1) uniform sampler s; -layout(set=1, binding=0) uniform texture2D t; -layout(location = 0) in struct { vec4 Color; vec2 UV; } In; -void main() -{ - fColor = In.Color * texture(sampler2D(t, s), In.UV.st); -} -*/ -static uint32_t __glsl_shader_frag_spv[] = -{ - 0x07230203,0x00010000,0x00080007,0x00000023,0x00000000,0x00020011,0x00000001,0x0006000b, - 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, - 0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000009,0x0000000d,0x00030010, - 0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d, - 0x00000000,0x00040005,0x00000009,0x6c6f4366,0x0000726f,0x00030005,0x0000000b,0x00000000, - 0x00050006,0x0000000b,0x00000000,0x6f6c6f43,0x00000072,0x00040006,0x0000000b,0x00000001, - 0x00005655,0x00030005,0x0000000d,0x00006e49,0x00030005,0x00000015,0x00000074,0x00030005, - 0x00000019,0x00000073,0x00040047,0x00000009,0x0000001e,0x00000000,0x00040047,0x0000000d, - 0x0000001e,0x00000000,0x00040047,0x00000015,0x00000022,0x00000001,0x00040047,0x00000015, - 0x00000021,0x00000000,0x00040047,0x00000019,0x00000022,0x00000000,0x00040047,0x00000019, - 0x00000021,0x00000001,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016, - 0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000004,0x00040020,0x00000008, - 0x00000003,0x00000007,0x0004003b,0x00000008,0x00000009,0x00000003,0x00040017,0x0000000a, - 0x00000006,0x00000002,0x0004001e,0x0000000b,0x00000007,0x0000000a,0x00040020,0x0000000c, - 0x00000001,0x0000000b,0x0004003b,0x0000000c,0x0000000d,0x00000001,0x00040015,0x0000000e, - 0x00000020,0x00000001,0x0004002b,0x0000000e,0x0000000f,0x00000000,0x00040020,0x00000010, - 0x00000001,0x00000007,0x00090019,0x00000013,0x00000006,0x00000001,0x00000000,0x00000000, - 0x00000000,0x00000001,0x00000000,0x00040020,0x00000014,0x00000000,0x00000013,0x0004003b, - 0x00000014,0x00000015,0x00000000,0x0002001a,0x00000017,0x00040020,0x00000018,0x00000000, - 0x00000017,0x0004003b,0x00000018,0x00000019,0x00000000,0x0003001b,0x0000001b,0x00000013, - 0x0004002b,0x0000000e,0x0000001d,0x00000001,0x00040020,0x0000001e,0x00000001,0x0000000a, - 0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x00050041, - 0x00000010,0x00000011,0x0000000d,0x0000000f,0x0004003d,0x00000007,0x00000012,0x00000011, - 0x0004003d,0x00000013,0x00000016,0x00000015,0x0004003d,0x00000017,0x0000001a,0x00000019, - 0x00050056,0x0000001b,0x0000001c,0x00000016,0x0000001a,0x00050041,0x0000001e,0x0000001f, - 0x0000000d,0x0000001d,0x0004003d,0x0000000a,0x00000020,0x0000001f,0x00050057,0x00000007, - 0x00000021,0x0000001c,0x00000020,0x00050085,0x00000007,0x00000022,0x00000012,0x00000021, - 0x0003003e,0x00000009,0x00000022,0x000100fd,0x00010038 -}; - -static void SafeRelease(ImDrawIdx*& res) -{ - if (res) - delete[] res; - res = NULL; -} -static void SafeRelease(ImDrawVert*& res) -{ - if (res) - delete[] res; - res = NULL; -} -static void SafeRelease(WGPUBindGroupLayout& res) -{ - if (res) - wgpuBindGroupLayoutRelease(res); - res = NULL; -} -static void SafeRelease(WGPUBindGroup& res) -{ - if (res) - wgpuBindGroupRelease(res); - res = NULL; -} -static void SafeRelease(WGPUBuffer& res) -{ - if (res) - wgpuBufferRelease(res); - res = NULL; -} -static void SafeRelease(WGPURenderPipeline& res) -{ - if (res) - wgpuRenderPipelineRelease(res); - res = NULL; -} -static void SafeRelease(WGPUSampler& res) -{ - if (res) - wgpuSamplerRelease(res); - res = NULL; -} -static void SafeRelease(WGPUShaderModule& res) -{ - if (res) - wgpuShaderModuleRelease(res); - res = NULL; -} -static void SafeRelease(WGPUTextureView& res) -{ - if (res) - wgpuTextureViewRelease(res); - res = NULL; -} -static void SafeRelease(WGPUTexture& res) -{ - if (res) - wgpuTextureRelease(res); - res = NULL; -} - -static void SafeRelease(RenderResources& res) -{ - SafeRelease(res.FontTexture); - SafeRelease(res.FontTextureView); - SafeRelease(res.Sampler); - SafeRelease(res.Uniforms); - SafeRelease(res.CommonBindGroup); - SafeRelease(res.ImageBindGroup); - SafeRelease(res.ImageBindGroupLayout); -}; - -static void SafeRelease(FrameResources& res) -{ - SafeRelease(res.IndexBuffer); - SafeRelease(res.VertexBuffer); - SafeRelease(res.IndexBufferHost); - SafeRelease(res.VertexBufferHost); -} - -static WGPUProgrammableStageDescriptor ImGui_ImplWGPU_CreateShaderModule(uint32_t* binary_data, uint32_t binary_data_size) -{ - WGPUShaderModuleSPIRVDescriptor spirv_desc = {}; - spirv_desc.chain.sType = WGPUSType_ShaderModuleSPIRVDescriptor; - spirv_desc.codeSize = binary_data_size; - spirv_desc.code = binary_data; - - WGPUShaderModuleDescriptor desc = {}; - desc.nextInChain = reinterpret_cast(&spirv_desc); - - WGPUProgrammableStageDescriptor stage_desc = {}; - stage_desc.module = wgpuDeviceCreateShaderModule(g_wgpuDevice, &desc); - stage_desc.entryPoint = "main"; - return stage_desc; -} - -static WGPUBindGroup ImGui_ImplWGPU_CreateImageBindGroup(WGPUBindGroupLayout layout, WGPUTextureView texture) -{ - WGPUBindGroupEntry image_bg_entries[] = { { nullptr, 0, 0, 0, 0, 0, texture } }; - - WGPUBindGroupDescriptor image_bg_descriptor = {}; - image_bg_descriptor.layout = layout; - image_bg_descriptor.entryCount = sizeof(image_bg_entries) / sizeof(WGPUBindGroupEntry); - image_bg_descriptor.entries = image_bg_entries; - return wgpuDeviceCreateBindGroup(g_wgpuDevice, &image_bg_descriptor); -} - -static void ImGui_ImplWGPU_SetupRenderState(ImDrawData* draw_data, WGPURenderPassEncoder ctx, FrameResources* fr) -{ - // Setup orthographic projection matrix into our constant buffer - // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). - { - float L = draw_data->DisplayPos.x; - float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x; - float T = draw_data->DisplayPos.y; - float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y; - float mvp[4][4] = - { - { 2.0f/(R-L), 0.0f, 0.0f, 0.0f }, - { 0.0f, 2.0f/(T-B), 0.0f, 0.0f }, - { 0.0f, 0.0f, 0.5f, 0.0f }, - { (R+L)/(L-R), (T+B)/(B-T), 0.5f, 1.0f }, - }; - wgpuQueueWriteBuffer(g_defaultQueue, g_resources.Uniforms, 0, mvp, sizeof(mvp)); - } - - // Setup viewport - wgpuRenderPassEncoderSetViewport(ctx, 0, 0, draw_data->FramebufferScale.x * draw_data->DisplaySize.x, draw_data->FramebufferScale.y * draw_data->DisplaySize.y, 0, 1); - - // Bind shader and vertex buffers - wgpuRenderPassEncoderSetVertexBuffer(ctx, 0, fr->VertexBuffer, 0, 0); - wgpuRenderPassEncoderSetIndexBuffer(ctx, fr->IndexBuffer, sizeof(ImDrawIdx) == 2 ? WGPUIndexFormat_Uint16 : WGPUIndexFormat_Uint32, 0, 0); - wgpuRenderPassEncoderSetPipeline(ctx, g_pipelineState); - wgpuRenderPassEncoderSetBindGroup(ctx, 0, g_resources.CommonBindGroup, 0, NULL); - - // Setup blend factor - WGPUColor blend_color = { 0.f, 0.f, 0.f, 0.f }; - wgpuRenderPassEncoderSetBlendConstant(ctx, &blend_color); -} - -// Render function -// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop) -void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder pass_encoder) -{ - // Avoid rendering when minimized - if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f) - return; - - // FIXME: Assuming that this only gets called once per frame! - // If not, we can't just re-allocate the IB or VB, we'll have to do a proper allocator. - g_frameIndex = g_frameIndex + 1; - FrameResources* fr = &g_pFrameResources[g_frameIndex % g_numFramesInFlight]; - - // Create and grow vertex/index buffers if needed - if (fr->VertexBuffer == NULL || fr->VertexBufferSize < draw_data->TotalVtxCount) - { - if (fr->VertexBuffer) - { - wgpuBufferDestroy(fr->VertexBuffer); - wgpuBufferRelease(fr->VertexBuffer); - } - SafeRelease(fr->VertexBufferHost); - fr->VertexBufferSize = draw_data->TotalVtxCount + 5000; - - WGPUBufferDescriptor vb_desc = - { - NULL, - "Dear ImGui Vertex buffer", - WGPUBufferUsage_CopyDst | WGPUBufferUsage_Vertex, - fr->VertexBufferSize * sizeof(ImDrawVert), - false - }; - fr->VertexBuffer = wgpuDeviceCreateBuffer(g_wgpuDevice, &vb_desc); - if (!fr->VertexBuffer) - return; - - fr->VertexBufferHost = new ImDrawVert[fr->VertexBufferSize]; - } - if (fr->IndexBuffer == NULL || fr->IndexBufferSize < draw_data->TotalIdxCount) - { - if (fr->IndexBuffer) - { - wgpuBufferDestroy(fr->IndexBuffer); - wgpuBufferRelease(fr->IndexBuffer); - } - SafeRelease(fr->IndexBufferHost); - fr->IndexBufferSize = draw_data->TotalIdxCount + 10000; - - WGPUBufferDescriptor ib_desc = - { - NULL, - "Dear ImGui Index buffer", - WGPUBufferUsage_CopyDst | WGPUBufferUsage_Index, - fr->IndexBufferSize * sizeof(ImDrawIdx), - false - }; - fr->IndexBuffer = wgpuDeviceCreateBuffer(g_wgpuDevice, &ib_desc); - if (!fr->IndexBuffer) - return; - - fr->IndexBufferHost = new ImDrawIdx[fr->IndexBufferSize]; - } - - // Upload vertex/index data into a single contiguous GPU buffer - ImDrawVert* vtx_dst = (ImDrawVert*)fr->VertexBufferHost; - ImDrawIdx* idx_dst = (ImDrawIdx*)fr->IndexBufferHost; - for (int n = 0; n < draw_data->CmdListsCount; n++) - { - const ImDrawList* cmd_list = draw_data->CmdLists[n]; - memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert)); - memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx)); - vtx_dst += cmd_list->VtxBuffer.Size; - idx_dst += cmd_list->IdxBuffer.Size; - } - int64_t vb_write_size = ((char*)vtx_dst - (char*)fr->VertexBufferHost + 3) & ~3; - int64_t ib_write_size = ((char*)idx_dst - (char*)fr->IndexBufferHost + 3) & ~3; - wgpuQueueWriteBuffer(g_defaultQueue, fr->VertexBuffer, 0, fr->VertexBufferHost, vb_write_size); - wgpuQueueWriteBuffer(g_defaultQueue, fr->IndexBuffer, 0, fr->IndexBufferHost, ib_write_size); - - // Setup desired render state - ImGui_ImplWGPU_SetupRenderState(draw_data, pass_encoder, fr); - - // Render command lists - // (Because we merged all buffers into a single one, we maintain our own offset into them) - int global_vtx_offset = 0; - int global_idx_offset = 0; - ImVec2 clip_scale = draw_data->FramebufferScale; - ImVec2 clip_off = draw_data->DisplayPos; - for (int n = 0; n < draw_data->CmdListsCount; n++) - { - const ImDrawList* cmd_list = draw_data->CmdLists[n]; - for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) - { - const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; - if (pcmd->UserCallback != NULL) - { - // User callback, registered via ImDrawList::AddCallback() - // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.) - if (pcmd->UserCallback == ImDrawCallback_ResetRenderState) - ImGui_ImplWGPU_SetupRenderState(draw_data, pass_encoder, fr); - else - pcmd->UserCallback(cmd_list, pcmd); - } - else - { - // Bind custom texture - ImTextureID tex_id = pcmd->GetTexID(); - ImGuiID tex_id_hash = ImHashData(&tex_id, sizeof(tex_id)); - auto bind_group = g_resources.ImageBindGroups.GetVoidPtr(tex_id_hash); - if (bind_group) - { - wgpuRenderPassEncoderSetBindGroup(pass_encoder, 1, (WGPUBindGroup)bind_group, 0, NULL); - } - else - { - WGPUBindGroup image_bind_group = ImGui_ImplWGPU_CreateImageBindGroup(g_resources.ImageBindGroupLayout, (WGPUTextureView)tex_id); - g_resources.ImageBindGroups.SetVoidPtr(tex_id_hash, image_bind_group); - wgpuRenderPassEncoderSetBindGroup(pass_encoder, 1, image_bind_group, 0, NULL); - } - - // Project scissor/clipping rectangles into framebuffer space - ImVec2 clip_min((pcmd->ClipRect.x - clip_off.x) * clip_scale.x, (pcmd->ClipRect.y - clip_off.y) * clip_scale.y); - ImVec2 clip_max((pcmd->ClipRect.z - clip_off.x) * clip_scale.x, (pcmd->ClipRect.w - clip_off.y) * clip_scale.y); - if (clip_max.x < clip_min.x || clip_max.y < clip_min.y) - continue; - - // Apply scissor/clipping rectangle, Draw - wgpuRenderPassEncoderSetScissorRect(pass_encoder, (uint32_t)clip_min.x, (uint32_t)clip_min.y, (uint32_t)(clip_max.x - clip_min.x), (uint32_t)(clip_max.y - clip_min.y)); - wgpuRenderPassEncoderDrawIndexed(pass_encoder, pcmd->ElemCount, 1, pcmd->IdxOffset + global_idx_offset, pcmd->VtxOffset + global_vtx_offset, 0); - } - } - global_idx_offset += cmd_list->IdxBuffer.Size; - global_vtx_offset += cmd_list->VtxBuffer.Size; - } -} - -static void ImGui_ImplWGPU_CreateFontsTexture() -{ - // Build texture atlas - ImGuiIO& io = ImGui::GetIO(); - unsigned char* pixels; - int width, height, size_pp; - io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height, &size_pp); - - // Upload texture to graphics system - { - WGPUTextureDescriptor tex_desc = {}; - tex_desc.label = "Dear ImGui Font Texture"; - tex_desc.dimension = WGPUTextureDimension_2D; - tex_desc.size.width = width; - tex_desc.size.height = height; - tex_desc.size.depthOrArrayLayers = 1; - tex_desc.sampleCount = 1; - tex_desc.format = WGPUTextureFormat_RGBA8Unorm; - tex_desc.mipLevelCount = 1; - tex_desc.usage = WGPUTextureUsage_CopyDst | WGPUTextureUsage_TextureBinding; - g_resources.FontTexture = wgpuDeviceCreateTexture(g_wgpuDevice, &tex_desc); - - WGPUTextureViewDescriptor tex_view_desc = {}; - tex_view_desc.format = WGPUTextureFormat_RGBA8Unorm; - tex_view_desc.dimension = WGPUTextureViewDimension_2D; - tex_view_desc.baseMipLevel = 0; - tex_view_desc.mipLevelCount = 1; - tex_view_desc.baseArrayLayer = 0; - tex_view_desc.arrayLayerCount = 1; - tex_view_desc.aspect = WGPUTextureAspect_All; - g_resources.FontTextureView = wgpuTextureCreateView(g_resources.FontTexture, &tex_view_desc); - } - - // Upload texture data - { - WGPUImageCopyTexture dst_view = {}; - dst_view.texture = g_resources.FontTexture; - dst_view.mipLevel = 0; - dst_view.origin = { 0, 0, 0 }; - dst_view.aspect = WGPUTextureAspect_All; - WGPUTextureDataLayout layout = {}; - layout.offset = 0; - layout.bytesPerRow = width * size_pp; - layout.rowsPerImage = height; - WGPUExtent3D size = { (uint32_t)width, (uint32_t)height, 1 }; - wgpuQueueWriteTexture(g_defaultQueue, &dst_view, pixels, (uint32_t)(width * size_pp * height), &layout, &size); - } - - // Create the associated sampler - { - WGPUSamplerDescriptor sampler_desc = {}; - sampler_desc.minFilter = WGPUFilterMode_Linear; - sampler_desc.magFilter = WGPUFilterMode_Linear; - sampler_desc.mipmapFilter = WGPUFilterMode_Linear; - sampler_desc.addressModeU = WGPUAddressMode_Repeat; - sampler_desc.addressModeV = WGPUAddressMode_Repeat; - sampler_desc.addressModeW = WGPUAddressMode_Repeat; - sampler_desc.maxAnisotropy = 1; - g_resources.Sampler = wgpuDeviceCreateSampler(g_wgpuDevice, &sampler_desc); - } - - // Store our identifier - static_assert(sizeof(ImTextureID) >= sizeof(g_resources.FontTexture), "Can't pack descriptor handle into TexID, 32-bit not supported yet."); - io.Fonts->SetTexID((ImTextureID)g_resources.FontTextureView); -} - -static void ImGui_ImplWGPU_CreateUniformBuffer() -{ - WGPUBufferDescriptor ub_desc = - { - NULL, - "Dear ImGui Uniform buffer", - WGPUBufferUsage_CopyDst | WGPUBufferUsage_Uniform, - sizeof(Uniforms), - false - }; - g_resources.Uniforms = wgpuDeviceCreateBuffer(g_wgpuDevice, &ub_desc); -} - -bool ImGui_ImplWGPU_CreateDeviceObjects() -{ - if (!g_wgpuDevice) - return false; - if (g_pipelineState) - ImGui_ImplWGPU_InvalidateDeviceObjects(); - - // Create render pipeline - WGPURenderPipelineDescriptor graphics_pipeline_desc = {}; - graphics_pipeline_desc.primitive.topology = WGPUPrimitiveTopology_TriangleList; - graphics_pipeline_desc.primitive.stripIndexFormat = WGPUIndexFormat_Undefined; - graphics_pipeline_desc.primitive.frontFace = WGPUFrontFace_CW; - graphics_pipeline_desc.primitive.cullMode = WGPUCullMode_None; - graphics_pipeline_desc.multisample.count = 1; - graphics_pipeline_desc.multisample.mask = UINT_MAX; - graphics_pipeline_desc.multisample.alphaToCoverageEnabled = false; - graphics_pipeline_desc.layout = nullptr; // Use automatic layout generation - - // Create the vertex shader - WGPUProgrammableStageDescriptor vertex_shader_desc = ImGui_ImplWGPU_CreateShaderModule(__glsl_shader_vert_spv, sizeof(__glsl_shader_vert_spv) / sizeof(uint32_t)); - graphics_pipeline_desc.vertex.module = vertex_shader_desc.module; - graphics_pipeline_desc.vertex.entryPoint = vertex_shader_desc.entryPoint; - - // Vertex input configuration - WGPUVertexAttribute attribute_desc[] = - { - { WGPUVertexFormat_Float32x2, (uint64_t)IM_OFFSETOF(ImDrawVert, pos), 0 }, - { WGPUVertexFormat_Float32x2, (uint64_t)IM_OFFSETOF(ImDrawVert, uv), 1 }, - { WGPUVertexFormat_Unorm8x4, (uint64_t)IM_OFFSETOF(ImDrawVert, col), 2 }, - }; - - WGPUVertexBufferLayout buffer_layouts[1]; - buffer_layouts[0].arrayStride = sizeof(ImDrawVert); - buffer_layouts[0].stepMode = WGPUVertexStepMode_Vertex; - buffer_layouts[0].attributeCount = 3; - buffer_layouts[0].attributes = attribute_desc; - - graphics_pipeline_desc.vertex.bufferCount = 1; - graphics_pipeline_desc.vertex.buffers = buffer_layouts; - - // Create the pixel shader - WGPUProgrammableStageDescriptor pixel_shader_desc = ImGui_ImplWGPU_CreateShaderModule(__glsl_shader_frag_spv, sizeof(__glsl_shader_frag_spv) / sizeof(uint32_t)); - - // Create the blending setup - WGPUBlendState blend_state = {}; - blend_state.alpha.operation = WGPUBlendOperation_Add; - blend_state.alpha.srcFactor = WGPUBlendFactor_One; - blend_state.alpha.dstFactor = WGPUBlendFactor_OneMinusSrcAlpha; - blend_state.color.operation = WGPUBlendOperation_Add; - blend_state.color.srcFactor = WGPUBlendFactor_SrcAlpha; - blend_state.color.dstFactor = WGPUBlendFactor_OneMinusSrcAlpha; - - WGPUColorTargetState color_state = {}; - color_state.format = g_renderTargetFormat; - color_state.blend = &blend_state; - color_state.writeMask = WGPUColorWriteMask_All; - - WGPUFragmentState fragment_state = {}; - fragment_state.module = pixel_shader_desc.module; - fragment_state.entryPoint = pixel_shader_desc.entryPoint; - fragment_state.targetCount = 1; - fragment_state.targets = &color_state; - - graphics_pipeline_desc.fragment = &fragment_state; - - // Create depth-stencil State - WGPUDepthStencilState depth_stencil_state = {}; - depth_stencil_state.depthBias = 0; - depth_stencil_state.depthBiasClamp = 0; - depth_stencil_state.depthBiasSlopeScale = 0; - - // Configure disabled depth-stencil state - graphics_pipeline_desc.depthStencil = nullptr; - - g_pipelineState = wgpuDeviceCreateRenderPipeline(g_wgpuDevice, &graphics_pipeline_desc); - - ImGui_ImplWGPU_CreateFontsTexture(); - ImGui_ImplWGPU_CreateUniformBuffer(); - - // Create resource bind group - WGPUBindGroupLayout bg_layouts[2]; - bg_layouts[0] = wgpuRenderPipelineGetBindGroupLayout(g_pipelineState, 0); - bg_layouts[1] = wgpuRenderPipelineGetBindGroupLayout(g_pipelineState, 1); - - WGPUBindGroupEntry common_bg_entries[] = - { - { nullptr, 0, g_resources.Uniforms, 0, sizeof(Uniforms), 0, 0 }, - { nullptr, 1, 0, 0, 0, g_resources.Sampler, 0 }, - }; - - WGPUBindGroupDescriptor common_bg_descriptor = {}; - common_bg_descriptor.layout = bg_layouts[0]; - common_bg_descriptor.entryCount = sizeof(common_bg_entries) / sizeof(WGPUBindGroupEntry); - common_bg_descriptor.entries = common_bg_entries; - g_resources.CommonBindGroup = wgpuDeviceCreateBindGroup(g_wgpuDevice, &common_bg_descriptor); - - WGPUBindGroup image_bind_group = ImGui_ImplWGPU_CreateImageBindGroup(bg_layouts[1], g_resources.FontTextureView); - g_resources.ImageBindGroup = image_bind_group; - g_resources.ImageBindGroupLayout = bg_layouts[1]; - g_resources.ImageBindGroups.SetVoidPtr(ImHashData(&g_resources.FontTextureView, sizeof(ImTextureID)), image_bind_group); - - SafeRelease(vertex_shader_desc.module); - SafeRelease(pixel_shader_desc.module); - SafeRelease(bg_layouts[0]); - - return true; -} - -void ImGui_ImplWGPU_InvalidateDeviceObjects() -{ - if (!g_wgpuDevice) - return; - - SafeRelease(g_pipelineState); - SafeRelease(g_resources); - - ImGuiIO& io = ImGui::GetIO(); - io.Fonts->SetTexID(NULL); // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well. - - for (unsigned int i = 0; i < g_numFramesInFlight; i++) - SafeRelease(g_pFrameResources[i]); -} - -bool ImGui_ImplWGPU_Init(WGPUDevice device, int num_frames_in_flight, WGPUTextureFormat rt_format) -{ - // Setup backend capabilities flags - ImGuiIO& io = ImGui::GetIO(); - io.BackendRendererName = "imgui_impl_webgpu"; - io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. - - g_wgpuDevice = device; - g_defaultQueue = wgpuDeviceGetQueue(g_wgpuDevice); - g_renderTargetFormat = rt_format; - g_pFrameResources = new FrameResources[num_frames_in_flight]; - g_numFramesInFlight = num_frames_in_flight; - g_frameIndex = UINT_MAX; - - g_resources.FontTexture = NULL; - g_resources.FontTextureView = NULL; - g_resources.Sampler = NULL; - g_resources.Uniforms = NULL; - g_resources.CommonBindGroup = NULL; - g_resources.ImageBindGroups.Data.reserve(100); - g_resources.ImageBindGroup = NULL; - g_resources.ImageBindGroupLayout = NULL; - - // Create buffers with a default size (they will later be grown as needed) - for (int i = 0; i < num_frames_in_flight; i++) - { - FrameResources* fr = &g_pFrameResources[i]; - fr->IndexBuffer = NULL; - fr->VertexBuffer = NULL; - fr->IndexBufferHost = NULL; - fr->VertexBufferHost = NULL; - fr->IndexBufferSize = 10000; - fr->VertexBufferSize = 5000; - } - - return true; -} - -void ImGui_ImplWGPU_Shutdown() -{ - ImGui_ImplWGPU_InvalidateDeviceObjects(); - delete[] g_pFrameResources; - g_pFrameResources = NULL; - wgpuQueueRelease(g_defaultQueue); - g_wgpuDevice = NULL; - g_numFramesInFlight = 0; - g_frameIndex = UINT_MAX; -} - -void ImGui_ImplWGPU_NewFrame() -{ - if (!g_pipelineState) - ImGui_ImplWGPU_CreateDeviceObjects(); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_wgpu.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_wgpu.h deleted file mode 100644 index ec10768..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_wgpu.h +++ /dev/null @@ -1,25 +0,0 @@ -// dear imgui: Renderer for WebGPU -// This needs to be used along with a Platform Binding (e.g. GLFW) -// (Please note that WebGPU is currently experimental, will not run on non-beta browsers, and may break.) - -// Implemented features: -// [X] Renderer: User texture binding. Use 'WGPUTextureView' as ImTextureID. Read the FAQ about ImTextureID! -// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -#pragma once -#include "imgui.h" // IMGUI_IMPL_API -#include - -IMGUI_IMPL_API bool ImGui_ImplWGPU_Init(WGPUDevice device, int num_frames_in_flight, WGPUTextureFormat rt_format); -IMGUI_IMPL_API void ImGui_ImplWGPU_Shutdown(); -IMGUI_IMPL_API void ImGui_ImplWGPU_NewFrame(); -IMGUI_IMPL_API void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder pass_encoder); - -// Use if you want to reset your rendering device without losing Dear ImGui state. -IMGUI_IMPL_API void ImGui_ImplWGPU_InvalidateDeviceObjects(); -IMGUI_IMPL_API bool ImGui_ImplWGPU_CreateDeviceObjects(); diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_win32.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_win32.cpp deleted file mode 100644 index 51fb470..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_win32.cpp +++ /dev/null @@ -1,616 +0,0 @@ -// dear imgui: Platform Backend for Windows (standard windows API for 32 and 64 bits applications) -// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) - -// Implemented features: -// [X] Platform: Clipboard support (for Win32 this is actually part of core dear imgui) -// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. -// [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE). -// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -#include "imgui.h" -#include "imgui_impl_win32.h" -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif -#include -#include -#include - -// Configuration flags to add in your imconfig.h file: -//#define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD // Disable gamepad support. This was meaningful before <1.81 but we now load XInput dynamically so the option is now less relevant. - -// Using XInput for gamepad (will load DLL dynamically) -#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD -#include -typedef DWORD (WINAPI *PFN_XInputGetCapabilities)(DWORD, DWORD, XINPUT_CAPABILITIES*); -typedef DWORD (WINAPI *PFN_XInputGetState)(DWORD, XINPUT_STATE*); -#endif - -// CHANGELOG -// (minor and older changes stripped away, please see git history for details) -// 2021-08-17: Calling io.AddFocusEvent() on WM_SETFOCUS/WM_KILLFOCUS messages. -// 2021-08-02: Inputs: Fixed keyboard modifiers being reported when host windo doesn't have focus. -// 2021-07-29: Inputs: MousePos is correctly reported when the host platform window is hovered but not focused (using TrackMouseEvent() to receive WM_MOUSELEAVE events). -// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX). -// 2021-06-08: Fixed ImGui_ImplWin32_EnableDpiAwareness() and ImGui_ImplWin32_GetDpiScaleForMonitor() to handle Windows 8.1/10 features without a manifest (per-monitor DPI, and properly calls SetProcessDpiAwareness() on 8.1). -// 2021-03-23: Inputs: Clearing keyboard down array when losing focus (WM_KILLFOCUS). -// 2021-02-18: Added ImGui_ImplWin32_EnableAlphaCompositing(). Non Visual Studio users will need to link with dwmapi.lib (MinGW/gcc: use -ldwmapi). -// 2021-02-17: Fixed ImGui_ImplWin32_EnableDpiAwareness() attempting to get SetProcessDpiAwareness from shcore.dll on Windows 8 whereas it is only supported on Windows 8.1. -// 2021-01-25: Inputs: Dynamically loading XInput DLL. -// 2020-12-04: Misc: Fixed setting of io.DisplaySize to invalid/uninitialized data when after hwnd has been closed. -// 2020-03-03: Inputs: Calling AddInputCharacterUTF16() to support surrogate pairs leading to codepoint >= 0x10000 (for more complete CJK inputs) -// 2020-02-17: Added ImGui_ImplWin32_EnableDpiAwareness(), ImGui_ImplWin32_GetDpiScaleForHwnd(), ImGui_ImplWin32_GetDpiScaleForMonitor() helper functions. -// 2020-01-14: Inputs: Added support for #define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD/IMGUI_IMPL_WIN32_DISABLE_LINKING_XINPUT. -// 2019-12-05: Inputs: Added support for ImGuiMouseCursor_NotAllowed mouse cursor. -// 2019-05-11: Inputs: Don't filter value from WM_CHAR before calling AddInputCharacter(). -// 2019-01-17: Misc: Using GetForegroundWindow()+IsChild() instead of GetActiveWindow() to be compatible with windows created in a different thread or parent. -// 2019-01-17: Inputs: Added support for mouse buttons 4 and 5 via WM_XBUTTON* messages. -// 2019-01-15: Inputs: Added support for XInput gamepads (if ImGuiConfigFlags_NavEnableGamepad is set by user application). -// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window. -// 2018-06-29: Inputs: Added support for the ImGuiMouseCursor_Hand cursor. -// 2018-06-10: Inputs: Fixed handling of mouse wheel messages to support fine position messages (typically sent by track-pads). -// 2018-06-08: Misc: Extracted imgui_impl_win32.cpp/.h away from the old combined DX9/DX10/DX11/DX12 examples. -// 2018-03-20: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors and ImGuiBackendFlags_HasSetMousePos flags + honor ImGuiConfigFlags_NoMouseCursorChange flag. -// 2018-02-20: Inputs: Added support for mouse cursors (ImGui::GetMouseCursor() value and WM_SETCURSOR message handling). -// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space. -// 2018-02-06: Inputs: Honoring the io.WantSetMousePos by repositioning the mouse (when using navigation and ImGuiConfigFlags_NavMoveMouse is set). -// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves. -// 2018-01-20: Inputs: Added Horizontal Mouse Wheel support. -// 2018-01-08: Inputs: Added mapping for ImGuiKey_Insert. -// 2018-01-05: Inputs: Added WM_LBUTTONDBLCLK double-click handlers for window classes with the CS_DBLCLKS flag. -// 2017-10-23: Inputs: Added WM_SYSKEYDOWN / WM_SYSKEYUP handlers so e.g. the VK_MENU key can be read. -// 2017-10-23: Inputs: Using Win32 ::SetCapture/::GetCapture() to retrieve mouse positions outside the client area when dragging. -// 2016-11-12: Inputs: Only call Win32 ::SetCursor(NULL) when io.MouseDrawCursor is set. - -struct ImGui_ImplWin32_Data -{ - HWND hWnd; - HWND MouseHwnd; - bool MouseTracked; - INT64 Time; - INT64 TicksPerSecond; - ImGuiMouseCursor LastMouseCursor; - bool HasGamepad; - bool WantUpdateHasGamepad; - -#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD - HMODULE XInputDLL; - PFN_XInputGetCapabilities XInputGetCapabilities; - PFN_XInputGetState XInputGetState; -#endif - - ImGui_ImplWin32_Data() { memset(this, 0, sizeof(*this)); } -}; - -// Backend data stored in io.BackendPlatformUserData to allow support for multiple Dear ImGui contexts -// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts. -// FIXME: multi-context support is not well tested and probably dysfunctional in this backend. -// FIXME: some shared resources (mouse cursor shape, gamepad) are mishandled when using multi-context. -static ImGui_ImplWin32_Data* ImGui_ImplWin32_GetBackendData() -{ - return ImGui::GetCurrentContext() ? (ImGui_ImplWin32_Data*)ImGui::GetIO().BackendPlatformUserData : NULL; -} - -// Functions -bool ImGui_ImplWin32_Init(void* hwnd) -{ - ImGuiIO& io = ImGui::GetIO(); - IM_ASSERT(io.BackendPlatformUserData == NULL && "Already initialized a platform backend!"); - - INT64 perf_frequency, perf_counter; - if (!::QueryPerformanceFrequency((LARGE_INTEGER*)&perf_frequency)) - return false; - if (!::QueryPerformanceCounter((LARGE_INTEGER*)&perf_counter)) - return false; - - // Setup backend capabilities flags - ImGui_ImplWin32_Data* bd = IM_NEW(ImGui_ImplWin32_Data)(); - io.BackendPlatformUserData = (void*)bd; - io.BackendPlatformName = "imgui_impl_win32"; - io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional) - io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used) - - bd->hWnd = (HWND)hwnd; - bd->WantUpdateHasGamepad = true; - bd->TicksPerSecond = perf_frequency; - bd->Time = perf_counter; - bd->LastMouseCursor = ImGuiMouseCursor_COUNT; - - io.ImeWindowHandle = hwnd; - - // Keyboard mapping. Dear ImGui will use those indices to peek into the io.KeysDown[] array that we will update during the application lifetime. - io.KeyMap[ImGuiKey_Tab] = VK_TAB; - io.KeyMap[ImGuiKey_LeftArrow] = VK_LEFT; - io.KeyMap[ImGuiKey_RightArrow] = VK_RIGHT; - io.KeyMap[ImGuiKey_UpArrow] = VK_UP; - io.KeyMap[ImGuiKey_DownArrow] = VK_DOWN; - io.KeyMap[ImGuiKey_PageUp] = VK_PRIOR; - io.KeyMap[ImGuiKey_PageDown] = VK_NEXT; - io.KeyMap[ImGuiKey_Home] = VK_HOME; - io.KeyMap[ImGuiKey_End] = VK_END; - io.KeyMap[ImGuiKey_Insert] = VK_INSERT; - io.KeyMap[ImGuiKey_Delete] = VK_DELETE; - io.KeyMap[ImGuiKey_Backspace] = VK_BACK; - io.KeyMap[ImGuiKey_Space] = VK_SPACE; - io.KeyMap[ImGuiKey_Enter] = VK_RETURN; - io.KeyMap[ImGuiKey_Escape] = VK_ESCAPE; - io.KeyMap[ImGuiKey_KeyPadEnter] = VK_RETURN; - io.KeyMap[ImGuiKey_A] = 'A'; - io.KeyMap[ImGuiKey_C] = 'C'; - io.KeyMap[ImGuiKey_V] = 'V'; - io.KeyMap[ImGuiKey_X] = 'X'; - io.KeyMap[ImGuiKey_Y] = 'Y'; - io.KeyMap[ImGuiKey_Z] = 'Z'; - - // Dynamically load XInput library -#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD - const char* xinput_dll_names[] = - { - "xinput1_4.dll", // Windows 8+ - "xinput1_3.dll", // DirectX SDK - "xinput9_1_0.dll", // Windows Vista, Windows 7 - "xinput1_2.dll", // DirectX SDK - "xinput1_1.dll" // DirectX SDK - }; - for (int n = 0; n < IM_ARRAYSIZE(xinput_dll_names); n++) - if (HMODULE dll = ::LoadLibraryA(xinput_dll_names[n])) - { - bd->XInputDLL = dll; - bd->XInputGetCapabilities = (PFN_XInputGetCapabilities)::GetProcAddress(dll, "XInputGetCapabilities"); - bd->XInputGetState = (PFN_XInputGetState)::GetProcAddress(dll, "XInputGetState"); - break; - } -#endif // IMGUI_IMPL_WIN32_DISABLE_GAMEPAD - - return true; -} - -void ImGui_ImplWin32_Shutdown() -{ - ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData(); - IM_ASSERT(bd != NULL && "No platform backend to shutdown, or already shutdown?"); - ImGuiIO& io = ImGui::GetIO(); - - // Unload XInput library -#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD - if (bd->XInputDLL) - ::FreeLibrary(bd->XInputDLL); -#endif // IMGUI_IMPL_WIN32_DISABLE_GAMEPAD - - io.BackendPlatformName = NULL; - io.BackendPlatformUserData = NULL; - IM_DELETE(bd); -} - -static bool ImGui_ImplWin32_UpdateMouseCursor() -{ - ImGuiIO& io = ImGui::GetIO(); - if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) - return false; - - ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor(); - if (imgui_cursor == ImGuiMouseCursor_None || io.MouseDrawCursor) - { - // Hide OS mouse cursor if imgui is drawing it or if it wants no cursor - ::SetCursor(NULL); - } - else - { - // Show OS mouse cursor - LPTSTR win32_cursor = IDC_ARROW; - switch (imgui_cursor) - { - case ImGuiMouseCursor_Arrow: win32_cursor = IDC_ARROW; break; - case ImGuiMouseCursor_TextInput: win32_cursor = IDC_IBEAM; break; - case ImGuiMouseCursor_ResizeAll: win32_cursor = IDC_SIZEALL; break; - case ImGuiMouseCursor_ResizeEW: win32_cursor = IDC_SIZEWE; break; - case ImGuiMouseCursor_ResizeNS: win32_cursor = IDC_SIZENS; break; - case ImGuiMouseCursor_ResizeNESW: win32_cursor = IDC_SIZENESW; break; - case ImGuiMouseCursor_ResizeNWSE: win32_cursor = IDC_SIZENWSE; break; - case ImGuiMouseCursor_Hand: win32_cursor = IDC_HAND; break; - case ImGuiMouseCursor_NotAllowed: win32_cursor = IDC_NO; break; - } - ::SetCursor(::LoadCursor(NULL, win32_cursor)); - } - return true; -} - -static void ImGui_ImplWin32_UpdateMousePos() -{ - ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData(); - ImGuiIO& io = ImGui::GetIO(); - IM_ASSERT(bd->hWnd != 0); - - const ImVec2 mouse_pos_prev = io.MousePos; - io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX); - - // Obtain focused and hovered window. We forward mouse input when focused or when hovered (and no other window is capturing) - HWND focused_window = ::GetForegroundWindow(); - HWND hovered_window = bd->MouseHwnd; - HWND mouse_window = NULL; - if (hovered_window && (hovered_window == bd->hWnd || ::IsChild(hovered_window, bd->hWnd))) - mouse_window = hovered_window; - else if (focused_window && (focused_window == bd->hWnd || ::IsChild(focused_window, bd->hWnd))) - mouse_window = focused_window; - if (mouse_window == NULL) - return; - - // Set OS mouse position from Dear ImGui if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user) - if (io.WantSetMousePos) - { - POINT pos = { (int)mouse_pos_prev.x, (int)mouse_pos_prev.y }; - if (::ClientToScreen(bd->hWnd, &pos)) - ::SetCursorPos(pos.x, pos.y); - } - - // Set Dear ImGui mouse position from OS position - POINT pos; - if (::GetCursorPos(&pos) && ::ScreenToClient(mouse_window, &pos)) - io.MousePos = ImVec2((float)pos.x, (float)pos.y); -} - -// Gamepad navigation mapping -static void ImGui_ImplWin32_UpdateGamepads() -{ -#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD - ImGuiIO& io = ImGui::GetIO(); - ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData(); - memset(io.NavInputs, 0, sizeof(io.NavInputs)); - if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0) - return; - - // Calling XInputGetState() every frame on disconnected gamepads is unfortunately too slow. - // Instead we refresh gamepad availability by calling XInputGetCapabilities() _only_ after receiving WM_DEVICECHANGE. - if (bd->WantUpdateHasGamepad) - { - XINPUT_CAPABILITIES caps; - bd->HasGamepad = bd->XInputGetCapabilities ? (bd->XInputGetCapabilities(0, XINPUT_FLAG_GAMEPAD, &caps) == ERROR_SUCCESS) : false; - bd->WantUpdateHasGamepad = false; - } - - io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad; - XINPUT_STATE xinput_state; - if (bd->HasGamepad && bd->XInputGetState && bd->XInputGetState(0, &xinput_state) == ERROR_SUCCESS) - { - const XINPUT_GAMEPAD& gamepad = xinput_state.Gamepad; - io.BackendFlags |= ImGuiBackendFlags_HasGamepad; - - #define MAP_BUTTON(NAV_NO, BUTTON_ENUM) { io.NavInputs[NAV_NO] = (gamepad.wButtons & BUTTON_ENUM) ? 1.0f : 0.0f; } - #define MAP_ANALOG(NAV_NO, VALUE, V0, V1) { float vn = (float)(VALUE - V0) / (float)(V1 - V0); if (vn > 1.0f) vn = 1.0f; if (vn > 0.0f && io.NavInputs[NAV_NO] < vn) io.NavInputs[NAV_NO] = vn; } - MAP_BUTTON(ImGuiNavInput_Activate, XINPUT_GAMEPAD_A); // Cross / A - MAP_BUTTON(ImGuiNavInput_Cancel, XINPUT_GAMEPAD_B); // Circle / B - MAP_BUTTON(ImGuiNavInput_Menu, XINPUT_GAMEPAD_X); // Square / X - MAP_BUTTON(ImGuiNavInput_Input, XINPUT_GAMEPAD_Y); // Triangle / Y - MAP_BUTTON(ImGuiNavInput_DpadLeft, XINPUT_GAMEPAD_DPAD_LEFT); // D-Pad Left - MAP_BUTTON(ImGuiNavInput_DpadRight, XINPUT_GAMEPAD_DPAD_RIGHT); // D-Pad Right - MAP_BUTTON(ImGuiNavInput_DpadUp, XINPUT_GAMEPAD_DPAD_UP); // D-Pad Up - MAP_BUTTON(ImGuiNavInput_DpadDown, XINPUT_GAMEPAD_DPAD_DOWN); // D-Pad Down - MAP_BUTTON(ImGuiNavInput_FocusPrev, XINPUT_GAMEPAD_LEFT_SHOULDER); // L1 / LB - MAP_BUTTON(ImGuiNavInput_FocusNext, XINPUT_GAMEPAD_RIGHT_SHOULDER); // R1 / RB - MAP_BUTTON(ImGuiNavInput_TweakSlow, XINPUT_GAMEPAD_LEFT_SHOULDER); // L1 / LB - MAP_BUTTON(ImGuiNavInput_TweakFast, XINPUT_GAMEPAD_RIGHT_SHOULDER); // R1 / RB - MAP_ANALOG(ImGuiNavInput_LStickLeft, gamepad.sThumbLX, -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, -32768); - MAP_ANALOG(ImGuiNavInput_LStickRight, gamepad.sThumbLX, +XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, +32767); - MAP_ANALOG(ImGuiNavInput_LStickUp, gamepad.sThumbLY, +XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, +32767); - MAP_ANALOG(ImGuiNavInput_LStickDown, gamepad.sThumbLY, -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, -32767); - #undef MAP_BUTTON - #undef MAP_ANALOG - } -#endif // #ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD -} - -void ImGui_ImplWin32_NewFrame() -{ - ImGuiIO& io = ImGui::GetIO(); - ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData(); - IM_ASSERT(bd != NULL && "Did you call ImGui_ImplWin32_Init()?"); - - // Setup display size (every frame to accommodate for window resizing) - RECT rect = { 0, 0, 0, 0 }; - ::GetClientRect(bd->hWnd, &rect); - io.DisplaySize = ImVec2((float)(rect.right - rect.left), (float)(rect.bottom - rect.top)); - - // Setup time step - INT64 current_time = 0; - ::QueryPerformanceCounter((LARGE_INTEGER*)¤t_time); - io.DeltaTime = (float)(current_time - bd->Time) / bd->TicksPerSecond; - bd->Time = current_time; - - // Update OS mouse position - ImGui_ImplWin32_UpdateMousePos(); - - // Update OS mouse cursor with the cursor requested by imgui - ImGuiMouseCursor mouse_cursor = io.MouseDrawCursor ? ImGuiMouseCursor_None : ImGui::GetMouseCursor(); - if (bd->LastMouseCursor != mouse_cursor) - { - bd->LastMouseCursor = mouse_cursor; - ImGui_ImplWin32_UpdateMouseCursor(); - } - - // Update game controllers (if enabled and available) - ImGui_ImplWin32_UpdateGamepads(); -} - -// Allow compilation with old Windows SDK. MinGW doesn't have default _WIN32_WINNT/WINVER versions. -#ifndef WM_MOUSEHWHEEL -#define WM_MOUSEHWHEEL 0x020E -#endif -#ifndef DBT_DEVNODES_CHANGED -#define DBT_DEVNODES_CHANGED 0x0007 -#endif - -// Win32 message handler (process Win32 mouse/keyboard inputs, etc.) -// Call from your application's message handler. -// When implementing your own backend, you can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if Dear ImGui wants to use your inputs. -// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. -// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. -// Generally you may always pass all inputs to Dear ImGui, and hide them from your application based on those two flags. -// PS: In this Win32 handler, we use the capture API (GetCapture/SetCapture/ReleaseCapture) to be able to read mouse coordinates when dragging mouse outside of our window bounds. -// PS: We treat DBLCLK messages as regular mouse down messages, so this code will work on windows classes that have the CS_DBLCLKS flag set. Our own example app code doesn't set this flag. -#if 0 -// Copy this line into your .cpp file to forward declare the function. -extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); -#endif -IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - if (ImGui::GetCurrentContext() == NULL) - return 0; - - ImGuiIO& io = ImGui::GetIO(); - ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData(); - - switch (msg) - { - case WM_MOUSEMOVE: - // We need to call TrackMouseEvent in order to receive WM_MOUSELEAVE events - bd->MouseHwnd = hwnd; - if (!bd->MouseTracked) - { - TRACKMOUSEEVENT tme = { sizeof(tme), TME_LEAVE, hwnd, 0 }; - ::TrackMouseEvent(&tme); - bd->MouseTracked = true; - } - break; - case WM_MOUSELEAVE: - if (bd->MouseHwnd == hwnd) - bd->MouseHwnd = NULL; - bd->MouseTracked = false; - break; - case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK: - case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK: - case WM_MBUTTONDOWN: case WM_MBUTTONDBLCLK: - case WM_XBUTTONDOWN: case WM_XBUTTONDBLCLK: - { - int button = 0; - if (msg == WM_LBUTTONDOWN || msg == WM_LBUTTONDBLCLK) { button = 0; } - if (msg == WM_RBUTTONDOWN || msg == WM_RBUTTONDBLCLK) { button = 1; } - if (msg == WM_MBUTTONDOWN || msg == WM_MBUTTONDBLCLK) { button = 2; } - if (msg == WM_XBUTTONDOWN || msg == WM_XBUTTONDBLCLK) { button = (GET_XBUTTON_WPARAM(wParam) == XBUTTON1) ? 3 : 4; } - if (!ImGui::IsAnyMouseDown() && ::GetCapture() == NULL) - ::SetCapture(hwnd); - io.MouseDown[button] = true; - return 0; - } - case WM_LBUTTONUP: - case WM_RBUTTONUP: - case WM_MBUTTONUP: - case WM_XBUTTONUP: - { - int button = 0; - if (msg == WM_LBUTTONUP) { button = 0; } - if (msg == WM_RBUTTONUP) { button = 1; } - if (msg == WM_MBUTTONUP) { button = 2; } - if (msg == WM_XBUTTONUP) { button = (GET_XBUTTON_WPARAM(wParam) == XBUTTON1) ? 3 : 4; } - io.MouseDown[button] = false; - if (!ImGui::IsAnyMouseDown() && ::GetCapture() == hwnd) - ::ReleaseCapture(); - return 0; - } - case WM_MOUSEWHEEL: - io.MouseWheel += (float)GET_WHEEL_DELTA_WPARAM(wParam) / (float)WHEEL_DELTA; - return 0; - case WM_MOUSEHWHEEL: - io.MouseWheelH += (float)GET_WHEEL_DELTA_WPARAM(wParam) / (float)WHEEL_DELTA; - return 0; - case WM_KEYDOWN: - case WM_KEYUP: - case WM_SYSKEYDOWN: - case WM_SYSKEYUP: - { - bool down = (msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN); - if (wParam < 256) - io.KeysDown[wParam] = down; - if (wParam == VK_CONTROL) - io.KeyCtrl = down; - if (wParam == VK_SHIFT) - io.KeyShift = down; - if (wParam == VK_MENU) - io.KeyAlt = down; - return 0; - } - case WM_SETFOCUS: - case WM_KILLFOCUS: - io.AddFocusEvent(msg == WM_SETFOCUS); - return 0; - case WM_CHAR: - // You can also use ToAscii()+GetKeyboardState() to retrieve characters. - if (wParam > 0 && wParam < 0x10000) - io.AddInputCharacterUTF16((unsigned short)wParam); - return 0; - case WM_SETCURSOR: - if (LOWORD(lParam) == HTCLIENT && ImGui_ImplWin32_UpdateMouseCursor()) - return 1; - return 0; - case WM_DEVICECHANGE: - if ((UINT)wParam == DBT_DEVNODES_CHANGED) - bd->WantUpdateHasGamepad = true; - return 0; - } - return 0; -} - - -//-------------------------------------------------------------------------------------------------------- -// DPI-related helpers (optional) -//-------------------------------------------------------------------------------------------------------- -// - Use to enable DPI awareness without having to create an application manifest. -// - Your own app may already do this via a manifest or explicit calls. This is mostly useful for our examples/ apps. -// - In theory we could call simple functions from Windows SDK such as SetProcessDPIAware(), SetProcessDpiAwareness(), etc. -// but most of the functions provided by Microsoft require Windows 8.1/10+ SDK at compile time and Windows 8/10+ at runtime, -// neither we want to require the user to have. So we dynamically select and load those functions to avoid dependencies. -//--------------------------------------------------------------------------------------------------------- -// This is the scheme successfully used by GLFW (from which we borrowed some of the code) and other apps aiming to be highly portable. -// ImGui_ImplWin32_EnableDpiAwareness() is just a helper called by main.cpp, we don't call it automatically. -// If you are trying to implement your own backend for your own engine, you may ignore that noise. -//--------------------------------------------------------------------------------------------------------- - -// Perform our own check with RtlVerifyVersionInfo() instead of using functions from as they -// require a manifest to be functional for checks above 8.1. See https://github.com/ocornut/imgui/issues/4200 -static BOOL _IsWindowsVersionOrGreater(WORD major, WORD minor, WORD) -{ - typedef LONG(WINAPI* PFN_RtlVerifyVersionInfo)(OSVERSIONINFOEXW*, ULONG, ULONGLONG); - static PFN_RtlVerifyVersionInfo RtlVerifyVersionInfoFn = NULL; - if (RtlVerifyVersionInfoFn == NULL) - if (HMODULE ntdllModule = ::GetModuleHandleA("ntdll.dll")) - RtlVerifyVersionInfoFn = (PFN_RtlVerifyVersionInfo)GetProcAddress(ntdllModule, "RtlVerifyVersionInfo"); - if (RtlVerifyVersionInfoFn == NULL) - return FALSE; - - RTL_OSVERSIONINFOEXW versionInfo = { }; - ULONGLONG conditionMask = 0; - versionInfo.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW); - versionInfo.dwMajorVersion = major; - versionInfo.dwMinorVersion = minor; - VER_SET_CONDITION(conditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL); - VER_SET_CONDITION(conditionMask, VER_MINORVERSION, VER_GREATER_EQUAL); - return (RtlVerifyVersionInfoFn(&versionInfo, VER_MAJORVERSION | VER_MINORVERSION, conditionMask) == 0) ? TRUE : FALSE; -} - -#define _IsWindowsVistaOrGreater() _IsWindowsVersionOrGreater(HIBYTE(0x0600), LOBYTE(0x0600), 0) // _WIN32_WINNT_VISTA -#define _IsWindows8OrGreater() _IsWindowsVersionOrGreater(HIBYTE(0x0602), LOBYTE(0x0602), 0) // _WIN32_WINNT_WIN8 -#define _IsWindows8Point1OrGreater() _IsWindowsVersionOrGreater(HIBYTE(0x0603), LOBYTE(0x0603), 0) // _WIN32_WINNT_WINBLUE -#define _IsWindows10OrGreater() _IsWindowsVersionOrGreater(HIBYTE(0x0A00), LOBYTE(0x0A00), 0) // _WIN32_WINNT_WINTHRESHOLD / _WIN32_WINNT_WIN10 - -#ifndef DPI_ENUMS_DECLARED -typedef enum { PROCESS_DPI_UNAWARE = 0, PROCESS_SYSTEM_DPI_AWARE = 1, PROCESS_PER_MONITOR_DPI_AWARE = 2 } PROCESS_DPI_AWARENESS; -typedef enum { MDT_EFFECTIVE_DPI = 0, MDT_ANGULAR_DPI = 1, MDT_RAW_DPI = 2, MDT_DEFAULT = MDT_EFFECTIVE_DPI } MONITOR_DPI_TYPE; -#endif -#ifndef _DPI_AWARENESS_CONTEXTS_ -DECLARE_HANDLE(DPI_AWARENESS_CONTEXT); -#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE (DPI_AWARENESS_CONTEXT)-3 -#endif -#ifndef DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 -#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 (DPI_AWARENESS_CONTEXT)-4 -#endif -typedef HRESULT(WINAPI* PFN_SetProcessDpiAwareness)(PROCESS_DPI_AWARENESS); // Shcore.lib + dll, Windows 8.1+ -typedef HRESULT(WINAPI* PFN_GetDpiForMonitor)(HMONITOR, MONITOR_DPI_TYPE, UINT*, UINT*); // Shcore.lib + dll, Windows 8.1+ -typedef DPI_AWARENESS_CONTEXT(WINAPI* PFN_SetThreadDpiAwarenessContext)(DPI_AWARENESS_CONTEXT); // User32.lib + dll, Windows 10 v1607+ (Creators Update) - -// Helper function to enable DPI awareness without setting up a manifest -void ImGui_ImplWin32_EnableDpiAwareness() -{ - if (_IsWindows10OrGreater()) - { - static HINSTANCE user32_dll = ::LoadLibraryA("user32.dll"); // Reference counted per-process - if (PFN_SetThreadDpiAwarenessContext SetThreadDpiAwarenessContextFn = (PFN_SetThreadDpiAwarenessContext)::GetProcAddress(user32_dll, "SetThreadDpiAwarenessContext")) - { - SetThreadDpiAwarenessContextFn(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); - return; - } - } - if (_IsWindows8Point1OrGreater()) - { - static HINSTANCE shcore_dll = ::LoadLibraryA("shcore.dll"); // Reference counted per-process - if (PFN_SetProcessDpiAwareness SetProcessDpiAwarenessFn = (PFN_SetProcessDpiAwareness)::GetProcAddress(shcore_dll, "SetProcessDpiAwareness")) - { - SetProcessDpiAwarenessFn(PROCESS_PER_MONITOR_DPI_AWARE); - return; - } - } -#if _WIN32_WINNT >= 0x0600 - ::SetProcessDPIAware(); -#endif -} - -#if defined(_MSC_VER) && !defined(NOGDI) -#pragma comment(lib, "gdi32") // Link with gdi32.lib for GetDeviceCaps(). MinGW will require linking with '-lgdi32' -#endif - -float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor) -{ - UINT xdpi = 96, ydpi = 96; - if (_IsWindows8Point1OrGreater()) - { - static HINSTANCE shcore_dll = ::LoadLibraryA("shcore.dll"); // Reference counted per-process - static PFN_GetDpiForMonitor GetDpiForMonitorFn = NULL; - if (GetDpiForMonitorFn == NULL && shcore_dll != NULL) - GetDpiForMonitorFn = (PFN_GetDpiForMonitor)::GetProcAddress(shcore_dll, "GetDpiForMonitor"); - if (GetDpiForMonitorFn != NULL) - { - GetDpiForMonitorFn((HMONITOR)monitor, MDT_EFFECTIVE_DPI, &xdpi, &ydpi); - IM_ASSERT(xdpi == ydpi); // Please contact me if you hit this assert! - return xdpi / 96.0f; - } - } -#ifndef NOGDI - const HDC dc = ::GetDC(NULL); - xdpi = ::GetDeviceCaps(dc, LOGPIXELSX); - ydpi = ::GetDeviceCaps(dc, LOGPIXELSY); - IM_ASSERT(xdpi == ydpi); // Please contact me if you hit this assert! - ::ReleaseDC(NULL, dc); -#endif - return xdpi / 96.0f; -} - -float ImGui_ImplWin32_GetDpiScaleForHwnd(void* hwnd) -{ - HMONITOR monitor = ::MonitorFromWindow((HWND)hwnd, MONITOR_DEFAULTTONEAREST); - return ImGui_ImplWin32_GetDpiScaleForMonitor(monitor); -} - -//--------------------------------------------------------------------------------------------------------- -// Transparency related helpers (optional) -//-------------------------------------------------------------------------------------------------------- - -#if defined(_MSC_VER) -#pragma comment(lib, "dwmapi") // Link with dwmapi.lib. MinGW will require linking with '-ldwmapi' -#endif - -// [experimental] -// Borrowed from GLFW's function updateFramebufferTransparency() in src/win32_window.c -// (the Dwm* functions are Vista era functions but we are borrowing logic from GLFW) -void ImGui_ImplWin32_EnableAlphaCompositing(void* hwnd) -{ - if (!_IsWindowsVistaOrGreater()) - return; - - BOOL composition; - if (FAILED(::DwmIsCompositionEnabled(&composition)) || !composition) - return; - - BOOL opaque; - DWORD color; - if (_IsWindows8OrGreater() || (SUCCEEDED(::DwmGetColorizationColor(&color, &opaque)) && !opaque)) - { - HRGN region = ::CreateRectRgn(0, 0, -1, -1); - DWM_BLURBEHIND bb = {}; - bb.dwFlags = DWM_BB_ENABLE | DWM_BB_BLURREGION; - bb.hRgnBlur = region; - bb.fEnable = TRUE; - ::DwmEnableBlurBehindWindow((HWND)hwnd, &bb); - ::DeleteObject(region); - } - else - { - DWM_BLURBEHIND bb = {}; - bb.dwFlags = DWM_BB_ENABLE; - ::DwmEnableBlurBehindWindow((HWND)hwnd, &bb); - } -} - -//--------------------------------------------------------------------------------------------------------- diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_win32.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_win32.h deleted file mode 100644 index 768fe16..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/imgui_impl_win32.h +++ /dev/null @@ -1,42 +0,0 @@ -// dear imgui: Platform Backend for Windows (standard windows API for 32 and 64 bits applications) -// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) - -// Implemented features: -// [X] Platform: Clipboard support (for Win32 this is actually part of core dear imgui) -// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. -// [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE). -// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. - -// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. -// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -#pragma once -#include "imgui.h" // IMGUI_IMPL_API - -IMGUI_IMPL_API bool ImGui_ImplWin32_Init(void* hwnd); -IMGUI_IMPL_API void ImGui_ImplWin32_Shutdown(); -IMGUI_IMPL_API void ImGui_ImplWin32_NewFrame(); - -// Win32 message handler your application need to call. -// - Intentionally commented out in a '#if 0' block to avoid dragging dependencies on from this helper. -// - You should COPY the line below into your .cpp code to forward declare the function and then you can call it. -#if 0 -extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); -#endif - -// DPI-related helpers (optional) -// - Use to enable DPI awareness without having to create an application manifest. -// - Your own app may already do this via a manifest or explicit calls. This is mostly useful for our examples/ apps. -// - In theory we could call simple functions from Windows SDK such as SetProcessDPIAware(), SetProcessDpiAwareness(), etc. -// but most of the functions provided by Microsoft require Windows 8.1/10+ SDK at compile time and Windows 8/10+ at runtime, -// neither we want to require the user to have. So we dynamically select and load those functions to avoid dependencies. -IMGUI_IMPL_API void ImGui_ImplWin32_EnableDpiAwareness(); -IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForHwnd(void* hwnd); // HWND hwnd -IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor); // HMONITOR monitor - -// Transparency related helpers (optional) [experimental] -// - Use to enable alpha compositing transparency with the desktop. -// - Use together with e.g. clearing your framebuffer with zero-alpha. -IMGUI_IMPL_API void ImGui_ImplWin32_EnableAlphaCompositing(void* hwnd); // HWND hwnd diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/vulkan/generate_spv.sh b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/vulkan/generate_spv.sh deleted file mode 100644 index 948ef77..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/vulkan/generate_spv.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -## -V: create SPIR-V binary -## -x: save binary output as text-based 32-bit hexadecimal numbers -## -o: output file -glslangValidator -V -x -o glsl_shader.frag.u32 glsl_shader.frag -glslangValidator -V -x -o glsl_shader.vert.u32 glsl_shader.vert diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/vulkan/glsl_shader.frag b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/vulkan/glsl_shader.frag deleted file mode 100644 index ce7e6f7..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/vulkan/glsl_shader.frag +++ /dev/null @@ -1,14 +0,0 @@ -#version 450 core -layout(location = 0) out vec4 fColor; - -layout(set=0, binding=0) uniform sampler2D sTexture; - -layout(location = 0) in struct { - vec4 Color; - vec2 UV; -} In; - -void main() -{ - fColor = In.Color * texture(sTexture, In.UV.st); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/vulkan/glsl_shader.vert b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/vulkan/glsl_shader.vert deleted file mode 100644 index 9425365..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/backends/vulkan/glsl_shader.vert +++ /dev/null @@ -1,25 +0,0 @@ -#version 450 core -layout(location = 0) in vec2 aPos; -layout(location = 1) in vec2 aUV; -layout(location = 2) in vec4 aColor; - -layout(push_constant) uniform uPushConstant { - vec2 uScale; - vec2 uTranslate; -} pc; - -out gl_PerVertex { - vec4 gl_Position; -}; - -layout(location = 0) out struct { - vec4 Color; - vec2 UV; -} Out; - -void main() -{ - Out.Color = aColor; - Out.UV = aUV; - gl_Position = vec4(aPos * pc.uScale + pc.uTranslate, 0, 1); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/docs/BACKENDS.md b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/docs/BACKENDS.md deleted file mode 100644 index c878132..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/docs/BACKENDS.md +++ /dev/null @@ -1,142 +0,0 @@ -_(You may browse this at https://github.com/ocornut/imgui/blob/master/docs/BACKENDS.md or view this file with any Markdown viewer)_ - -## Dear ImGui: Backends - -**The backends/ folder contains backends for popular platforms/graphics API, which you can use in -your application or engine to easily integrate Dear ImGui.** Each backend is typically self-contained in a pair of files: imgui_impl_XXXX.cpp + imgui_impl_XXXX.h. - -- The 'Platform' backends are in charge of: mouse/keyboard/gamepad inputs, cursor shape, timing, windowing.
    - e.g. Windows ([imgui_impl_win32.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_win32.cpp)), GLFW ([imgui_impl_glfw.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_glfw.cpp)), SDL2 ([imgui_impl_sdl.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_sdl.cpp)), etc. - -- The 'Renderer' backends are in charge of: creating atlas texture, rendering imgui draw data.
    - e.g. DirectX11 ([imgui_impl_dx11.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_dx11.cpp)), OpenGL/WebGL ([imgui_impl_opengl3.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_opengl3.cpp), Vulkan ([imgui_impl_vulkan.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_vulkan.cpp), etc. - -- For some high-level frameworks, a single backend usually handle both 'Platform' and 'Renderer' parts.
    - e.g. Allegro 5 ([imgui_impl_allegro5.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_allegro5.cpp)), Marmalade ([imgui_impl_marmalade.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_marmalade.cpp)). If you end up creating a custom backend for your engine, you may want to do the same. - -An application usually combines 1 Platform backend + 1 Renderer backend + main Dear ImGui sources. -For example, the [example_win32_directx11](https://github.com/ocornut/imgui/tree/master/examples/example_win32_directx11) application combines imgui_impl_win32.cpp + imgui_impl_dx11.cpp. There are 20+ examples in the [examples/](https://github.com/ocornut/imgui/blob/master/examples/) folder. See [EXAMPLES.MD](https://github.com/ocornut/imgui/blob/master/docs/EXAMPLES.md) for details. - -**Once Dear ImGui is setup and running, run and refer to `ImGui::ShowDemoWindow()` in imgui_demo.cpp for usage of the end-user API.** - - -### What are backends - -Dear ImGui is highly portable and only requires a few things to run and render, typically: - - - Required: providing mouse/keyboard inputs (fed into the `ImGuiIO` structure). - - Required: uploading the font atlas texture into graphics memory. - - Required: rendering indexed textured triangles with a clipping rectangle. - - Extra features are opt-in, our backends try to support as many as possible: - - - Optional: custom texture binding support. - - Optional: clipboard support. - - Optional: gamepad support. - - Optional: mouse cursor shape support. - - Optional: IME support. - - Optional: multi-viewports support. - etc. - -This is essentially what each backends are doing + obligatory portability cruft. Using default backends ensure you can get all those features including the ones that would be harder to implement on your side (e.g. multi-viewports support). - -It is important to understand the difference between the core Dear ImGui library (files in the root folder) -and backends which we are describing here (backends/ folder). - -- Some issues may only be backend or platform specific. -- You should be able to write backends for pretty much any platform and any 3D graphics API. - e.g. you can get creative and use software rendering or render remotely on a different machine. - - -### Integrating a backend - -See "Getting Started" section of [EXAMPLES.MD](https://github.com/ocornut/imgui/blob/master/docs/EXAMPLES.md) for more details. - - -### List of backends - -In the [backends/](https://github.com/ocornut/imgui/blob/master/backends) folder: - -List of Platforms Backends: - - imgui_impl_android.cpp ; Android native app API - imgui_impl_glfw.cpp ; GLFW (Windows, macOS, Linux, etc.) http://www.glfw.org/ - imgui_impl_osx.mm ; macOS native API (not as feature complete as glfw/sdl backends) - imgui_impl_sdl.cpp ; SDL2 (Windows, macOS, Linux, iOS, Android) https://www.libsdl.org - imgui_impl_win32.cpp ; Win32 native API (Windows) - imgui_impl_glut.cpp ; GLUT/FreeGLUT (this is prehistoric software and absolutely not recommended today!) - -List of Renderer Backends: - - imgui_impl_dx9.cpp ; DirectX9 - imgui_impl_dx10.cpp ; DirectX10 - imgui_impl_dx11.cpp ; DirectX11 - imgui_impl_dx12.cpp ; DirectX12 - imgui_impl_metal.mm ; Metal (with ObjC) - imgui_impl_opengl2.cpp ; OpenGL 2 (legacy, fixed pipeline <- don't use with modern OpenGL context) - imgui_impl_opengl3.cpp ; OpenGL 3/4, OpenGL ES 2, OpenGL ES 3 (modern programmable pipeline) - imgui_impl_sdlrenderer.cpp; SDL_Renderer (optional component of SDL2 available from SDL 2.0.18+) - imgui_impl_vulkan.cpp ; Vulkan - imgui_impl_wgpu.cpp ; WebGPU - -List of high-level Frameworks Backends (combining Platform + Renderer): - - imgui_impl_allegro5.cpp - imgui_impl_marmalade.cpp - -Emscripten is also supported. -The [example_emscripten_opengl3](https://github.com/ocornut/imgui/tree/master/examples/example_emscripten_opengl3) app uses imgui_impl_sdl.cpp + imgui_impl_opengl3.cpp, but other combos are possible. - -### Backends for third-party frameworks, graphics API or other languages - -See https://github.com/ocornut/imgui/wiki/Bindings for the full list. - -### Recommended Backends - -If you are not sure which backend to use, the recommended platform/frameworks for portable applications: - -|Library |Website |Backend |Note | -|--------|--------|--------|-----| -| GLFW | https://github.com/glfw/glfw | imgui_impl_glfw.cpp | | -| SDL2 | https://www.libsdl.org | imgui_impl_sdl.cpp | | -| Sokol | https://github.com/floooh/sokol | [util/sokol_imgui.h](https://github.com/floooh/sokol/blob/master/util/sokol_imgui.h) | Lower-level than GLFW/SDL | - - -### Using a custom engine? - -You will likely be tempted to start by rewrite your own backend using your own custom/high-level facilities...
    -Think twice! - -If you are new to Dear ImGui, first try using the existing backends as-is. -You will save lots of time integrating the library. -You can LATER decide to rewrite yourself a custom backend if you really need to. -In most situations, custom backends have less features and more bugs than the standard backends we provide. -If you want portability, you can use multiple backends and choose between them either at compile time -or at runtime. - -**Example A**: your engine is built over Windows + DirectX11 but you have your own high-level rendering -system layered over DirectX11.
    -Suggestion: try using imgui_impl_win32.cpp + imgui_impl_dx11.cpp first. -Once it works, if you really need it you can replace the imgui_impl_dx11.cpp code with a -custom renderer using your own rendering functions, and keep using the standard Win32 code etc. - -**Example B**: your engine runs on Windows, Mac, Linux and uses DirectX11, Metal, Vulkan respectively.
    -Suggestion: use multiple generic backends! -Once it works, if you really need it you can replace parts of backends with your own abstractions. - -**Example C**: your engine runs on platforms we can't provide public backends for (e.g. PS4/PS5, Switch), -and you have high-level systems everywhere.
    -Suggestion: try using a non-portable backend first (e.g. win32 + underlying graphics API) to get -your desktop builds working first. This will get you running faster and get your acquainted with -how Dear ImGui works and is setup. You can then rewrite a custom backend using your own engine API. - -Also: -The [multi-viewports feature](https://github.com/ocornut/imgui/issues/1542) of the 'docking' branch allows -Dear ImGui windows to be seamlessly detached from the main application window. This is achieved using an -extra layer to the Platform and Renderer backends, which allows Dear ImGui to communicate platform-specific -requests such as: "create an additional OS window", "create a render context", "get the OS position of this -window" etc. See 'ImGuiPlatformIO' for details. -Supporting the multi-viewports feature correctly using 100% of your own abstractions is more difficult -than supporting single-viewport. -If you decide to use unmodified imgui_impl_XXXX.cpp files, you can automatically benefit from -improvements and fixes related to viewports and platform windows without extra work on your side. diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/docs/CHANGELOG.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/docs/CHANGELOG.txt deleted file mode 100644 index 0bb5855..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/docs/CHANGELOG.txt +++ /dev/null @@ -1,3289 +0,0 @@ -dear imgui -CHANGELOG - -This document holds the user-facing changelog that we also use in release notes. -We generally fold multiple commits pertaining to the same topic as a single entry. -Changes to backends are also included within the individual .cpp files of each backend. - -RELEASE NOTES: https://github.com/ocornut/imgui/releases -REPORT ISSUES: https://github.com/ocornut/imgui/issues -DISCUSS, ASK QUESTIONS: https://github.com/ocornut/imgui/discussions -FAQ https://www.dearimgui.org/faq/ -WIKI https://github.com/ocornut/imgui/wiki - -WHEN TO UPDATE? - -- Keeping your copy of Dear ImGui updated regularly is recommended. -- It is generally safe to sync to the latest commit in master or docking branches - The library is fairly stable and regressions tends to be fixed fast when reported. - -HOW TO UPDATE? - -- Overwrite every file except imconfig.h (if you have modified it). -- You may also locally branch to modify imconfig.h and merge latest into your branch. -- Read the `Breaking Changes` section (in imgui.cpp or here in the Changelog). -- If you have a problem with a missing function/symbols, search for its name in the code, there will likely be a comment about it. -- If you are dropping this repository in your codebase, please leave the demo and text files in there, they will be useful. -- You may diff your previous Changelog with the one you just copied and read that diff. -- You may enable `IMGUI_DISABLE_OBSOLETE_FUNCTIONS` in imconfig.h to forcefully disable legacy names and symbols. - Doing it every once in a while is a good way to make sure you are not using obsolete symbols. Dear ImGui is in active development, - and API updates have been a little more frequent lately. They are documented below and in imgui.cpp and should not affect all users. -- Please report any issue! - ------------------------------------------------------------------------ - VERSION 1.85 (Released 2021-10-12) ------------------------------------------------------------------------ - -This is the last release officially supporting C++03 and Visual Studio 2008/2010. (#4537) -We expect that the next release will require a subset of the C++11 language (VS 2012~, GCC 4.8.1, Clang 3.3). -We may use some C++11 language features but we will not use any C++ library headers. -If you are stuck on ancient compiler you may need to stay at this version onward. - -Breaking Changes: - -- Removed GetWindowContentRegionWidth() function. keep inline redirection helper. - Can use 'GetWindowContentRegionMax().x - GetWindowContentRegionMin().x' instead but it's not - very useful in practice, and the only use of it in the demo was illfit. - Using 'GetContentRegionAvail().x' is generally a better choice. - -Other Changes: - -- Debug: Stack Tool: Added "Stack Tool" available in "Demo->Tools->Stack Tool", "Metrics->Tools", - or by calling the ShowStackToolWindow() function. The tool run queries on hovered id to display - details about individual components that were hashed to create an ID. It helps understanding - the ID stack system and debugging potential ID collisions. (#4631) [@ocornut, @rokups] -- Windows: Fixed background order of overlapping childs submitted sequentially. (#4493) -- IsWindowFocused: Added ImGuiFocusedFlags_NoPopupHierarchy flag allowing to exclude child popups - from the tested windows when combined with _ChildWindows. -- IsWindowHovered: Added ImGuiHoveredFlags_NoPopupHierarchy flag allowing to exclude child popups - from the tested windows when combined with _ChildWindows. -- InputTextMultiline: Fixed label size not being included into window contents rect unless - the whole widget is clipped. -- InputText: Allow activating/cancelling/validating input with gamepad nav events. (#2321, #4552) -- InputText: Fixed selection rectangle appearing one frame late when selecting all. -- TextUnformatted: Accept null ranges including (NULL,NULL) without asserting, in order to conform - to common idioms (e.g. passing .data(), .data() + .size() from a null string). (#3615) -- Disabled: Added assert guard for mismatching BeginDisabled()/EndDisabled() blocks. (#211) -- Nav: Fixed using SetKeyboardFocusHere() on non-visible/clipped items. It now works and will scroll - toward the item. When called during a frame where the parent window is appearing, scrolling will - aim to center the item in the window. When calling during a frame where the parent window is already - visible, scrolling will aim to scroll as little as possible to make the item visible. We will later - expose scroll functions and flags in public API to select those behaviors. (#343, #4079, #2352) -- Nav: Fixed using SetKeyboardFocusHere() from activating a different item on the next frame if - submitted items have changed during that frame. (#432) -- Nav: Fixed toggling menu layer with Alt or exiting menu layer with Esc not moving mouse when - the ImGuiConfigFlags_NavEnableSetMousePos config flag is set. -- Nav: Fixed a few widgets from not setting reference keyboard/gamepad navigation ID when - activated with mouse. More specifically: BeginTabItem(), the scrolling arrows of BeginTabBar(), - the arrow section of TreeNode(), the +/- buttons of InputInt()/InputFloat(), Selectable() with - ImGuiSelectableFlags_SelectOnRelease. More generally: any direct use of ButtonBehavior() with - the PressedOnClick/PressedOnDoubleClick/PressedOnRelease button policy. -- Nav: Fixed an issue with losing focus on docked windows when pressing Alt while keyboard navigation - is disabled. (#4547, #4439) [@PathogenDavid] -- Nav: Fixed vertical scoring offset when wrapping on Y in a decorated window. -- Nav: Improve scrolling behavior when navigating to an item larger than view. -- TreePush(): removed unnecessary/inconsistent legacy behavior where passing a NULL value to - the TreePush(const char*) and TreePush(const void*) functions would use an hard-coded replacement. - The only situation where that change would make a meaningful difference is TreePush((const char*)NULL) - (_explicitly_ casting a null pointer to const char*), which is unlikely and will now crash. - You may replace it with anything else. -- ColorEdit4: Fixed not being able to change hue when saturation is 0. (#4014) [@rokups] -- ColorEdit4: Fixed hue resetting to 0 when it is set to 255. [@rokups] -- ColorEdit4: Fixed hue value jitter when source color is stored as RGB in 32-bit integer and perform - RGB<>HSV round trips every frames. [@rokups] -- ColorPicker4: Fixed picker being unable to select exact 1.0f color when dragging toward the edges - of the SV square (previously picked 0.999989986f). (#3517) [@rokups] -- Menus: Fixed vertical alignments of MenuItem() calls within a menu bar (broken in 1.84). (#4538) -- Menus: Improve closing logic when moving diagonally in empty between between parent and child menus to - accommodate for varying font size and dpi. -- Menus: Fixed crash when navigating left inside a child window inside a sub-menu. (#4510). -- Menus: Fixed an assertion happening in some situations when closing nested menus (broken in 1.83). (#4640) -- Drag and Drop: Fixed using BeginDragDropSource() inside a BeginChild() that returned false. (#4515) -- PlotHistogram: Fixed zero-line position when manually specifying min<0 and max>0. (#4349) [@filippocrocchini] -- Misc: Added asserts for missing PopItemFlag() calls. -- Misc: Fixed printf-style format checks on Clang+MinGW. (#4626, #4183, #3592) [@guusw] -- IO: Added 'io.WantCaptureMouseUnlessPopupClose' alternative to `io.WantCaptureMouse'. (#4480) - This allows apps to receive the click on void when that click is used to close popup (by default, - clicking on a void when a popup is open will close the popup but not release io.WantCaptureMouse). -- Fonts: imgui_freetype: Fixed crash when FT_Render_Glyph() fails to render a glyph and returns NULL - (which apparently happens with Freetype 2.11). (#4394, #4145?). -- Fonts: Fixed ImFontAtlas::ClearInputData() marking atlas as not built. (#4455, #3487) -- Backends: Added more implicit asserts to detect invalid/redundant calls to Shutdown functions. (#4562) -- Backends: OpenGL3: Fixed our custom GL loader conflicting with user using GL3W. (#4445) [@rokups] -- Backends: WebGPU: Fixed for latest specs. (#4472, #4512) [@Kangz, @bfierz] -- Backends: SDL_Renderer: Added SDL_Renderer backend compatible with upcoming SDL 2.0.18. (#3926) [@1bsyl] -- Backends: Metal: Fixed a crash when clipping rect larger than framebuffer is submitted via - a direct unclipped PushClipRect() call. (#4464) -- Backends: OSX: Use mach_absolute_time as CFAbsoluteTimeGetCurrent can jump backwards. (#4557, #4563) [@lfnoise] -- Backends: All renderers: Normalize clipping rect handling across backends. (#4464) -- Examples: Added SDL + SDL_Renderer example in "examples/example_sdl_sdlrenderer/" folder. (#3926) [@1bsyl] - - ------------------------------------------------------------------------ - VERSION 1.84.2 (Released 2021-08-23) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.84.2 - -- Disabled: Fixed nested BeginDisabled()/EndDisabled() calls. (#211, #4452, #4453, #4462) [@Legulysse] -- Backends: OpenGL3: OpenGL: Fixed ES 3.0 shader ("#version 300 es") to use normal precision - floats. Avoid wobbly rendering at HD resolutions. (#4463) [@nicolasnoble] - - ------------------------------------------------------------------------ - VERSION 1.84.1 (Released 2021-08-20) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.84.1 - -- Disabled: Fixed BeginDisabled(false) - BeginDisabled(true) was working. (#211, #4452, #4453) - - ------------------------------------------------------------------------ - VERSION 1.84 (Released 2021-08-20) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.84 - -Breaking Changes: - -- Commented out redirecting functions/enums names that were marked obsolete in 1.67 and 1.69 (March 2019): - - ImGui::GetOverlayDrawList() -> use ImGui::GetForegroundDrawList() - - ImFont::GlyphRangesBuilder -> use ImFontGlyphRangesBuilder -- Backends: OpenGL3: added a third source file "imgui_impl_opengl3_loader.h". [@rokups] -- Backends: GLFW: backend now uses glfwSetCursorEnterCallback(). (#3751, #4377, #2445) -- Backends: GLFW: backend now uses glfwSetWindowFocusCallback(). (#4388) [@thedmd] - - If calling ImGui_ImplGlfw_InitXXX with install_callbacks=true: this is already done for you. - - If calling ImGui_ImplGlfw_InitXXX with install_callbacks=false: you WILL NEED to register the GLFW callbacks - and forward them to the backend: - - Register glfwSetCursorEnterCallback, forward events to ImGui_ImplGlfw_CursorEnterCallback(). - - Register glfwSetWindowFocusCallback, forward events to ImGui_ImplGlfw_WindowFocusCallback(). -- Backends: SDL2: removed unnecessary SDL_Window* parameter from ImGui_ImplSDL2_NewFrame(). (#3244) [@funchal] - Kept inline redirection function (will obsolete). -- Backends: SDL2: backend needs to set 'SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1")' in order to - receive mouse clicks events on window focus, otherwise SDL doesn't emit the event. (#3751, #4377, #2445) - This is unfortunately a global SDL setting, so enabling it _might_ have a side-effect on your application. - It is unlikely to make a difference, but if your app absolutely needs to ignore the initial on-focus click: - you can ignore SDL_MOUSEBUTTONDOWN events coming right after a SDL_WINDOWEVENT_FOCUS_GAINED event). -- Internals: (for custom widgets): because disabled items now sets HoveredId, if you want custom widgets to - not react as hovered when disabled, in the majority of use cases it is preferable to check the "hovered" - return value of ButtonBehavior() rather than (HoveredId == id). - -Other Changes: - -- IO: Added io.AddFocusEvent() api for backend to tell when host window has gained/lost focus. (#4388) [@thedmd] - If you use a custom backend, consider adding support for this! -- Disabled: added BeginDisabled()/EndDisabled() api to create a scope where interactions are disabled. (#211) - - Added style.DisabledAlpha (default to 0.60f) and ImGuiStyleVar_DisabledAlpha. (#211) - - Unlike the internal-and-undocumented-but-somehow-known PushItemFlag(ImGuiItemFlags_Disabled), this also alters - visuals. Currently this is done by lowering alpha of all widgets. Future styling system may do that differently. - - Disabled items set HoveredId, allowing e.g. HoveredIdTimer to run. (#211, #3419) [@rokups] - - Disabled items more consistently release ActiveId if the active item got disabled. (#211) - - Nav: Fixed disabled items from being candidate for default focus. (#211, #787) - - Fixed Selectable() selection not showing when disabled. (#211) - - Fixed IsItemHovered() returning true on disabled item when navigated to. (#211) - - Fixed IsItemHovered() when popping disabled state after item, or when using Selectable_Disabled. (#211) -- Windows: ImGuiWindowFlags_UnsavedDocument/ImGuiTabItemFlags_UnsavedDocument displays a dot instead of a '*' so it - is independent from font style. When in a tab, the dot is displayed at the same position as the close button. - Added extra comments to clarify the purpose of this flag in the context of docked windows. -- Tables: Added ImGuiTableColumnFlags_Disabled acting a master disable over (hidden from user/context menu). (#3935) -- Tables: Clarified that TableSetColumnEnabled() requires the table to use the ImGuiTableFlags_Hideable flag, - because it manipulates the user-accessible show/hide state. (#3935) -- Tables: Added ImGuiTableColumnFlags_NoHeaderLabel to request TableHeadersRow() to not submit label for a column. - Convenient for some small columns. Name will still appear in context menu. (#4206). -- Tables: Fixed columns order on TableSetupScrollFreeze() if previous data got frozen columns out of their section. -- Tables: Fixed invalid data in TableGetSortSpecs() when SpecsDirty flag is unset. (#4233) -- TabBar: Fixed using more than 32 KB-worth of tab names. (#4176) -- InputInt/InputFloat: When used with Steps values and _ReadOnly flag, the step button look disabled. (#211) -- InputText: Fixed named filtering flags disabling newline or tabs in multiline inputs (#4409, #4410) [@kfsone] -- Drag and Drop: drop target highlight doesn't try to bypass host clipping rectangle. (#4281, #3272) -- Drag and Drop: Fixed using AcceptDragDropPayload() with ImGuiDragDropFlags_AcceptNoPreviewTooltip. [@JeffM2501] -- Menus: MenuItem() and BeginMenu() are not affected/overlapping when style.SelectableTextAlign is altered. -- Menus: Fixed hovering a disabled menu or menu item not closing other menus. (#211) -- Popups: Fixed BeginPopup/OpenPopup sequence failing when there are no focused windows. (#4308) [@rokups] -- Nav: Alt doesn't toggle menu layer if other modifiers are held. (#4439) -- Fixed printf-style format checks on non-MinGW flavors. (#4183, #3592) -- Fonts: Functions with a 'float size_pixels' parameter can accept zero if it is set in ImFontSize::SizePixels. -- Fonts: Prefer using U+FFFD character for fallback instead of '?', if available. (#4269) -- Fonts: Use U+FF0E dot character to construct an ellipsis if U+002E '.' is not available. (#4269) -- Fonts: Added U+FFFD ("replacement character") to default asian glyphs ranges. (#4269) -- Fonts: Fixed calling ClearTexData() (clearing CPU side font data) triggering an assert in NewFrame(). (#3487) -- DrawList: Fixed AddCircle/AddCircleFilled() with auto-tesselation not using accelerated paths for small circles. - Fixed AddCircle/AddCircleFilled() with 12 segments which had a broken edge. (#4419, #4421) [@thedmd] -- Demo: Fixed requirement in 1.83 to link with imgui_demo.cpp if IMGUI_DISABLE_METRICS_WINDOW is not set. (#4171) - Normally the right way to disable compiling the demo is to set IMGUI_DISABLE_DEMO_WINDOWS, but we want to avoid - implying that the file is required. -- Metrics: Fixed a crash when inspecting the individual draw command of a foreground drawlist. [@rokups] -- Backends: Reorganized most backends (Win32, SDL, GLFW, OpenGL2/3, DX9/10/11/12, Vulkan, Allegro) to pull their - data from a single structure stored inside the main Dear ImGui context. This facilitate/allow usage of standard - backends with multiple-contexts BUT is only partially tested and not well supported. It is generally advised to - instead use the multi-viewports feature of docking branch where a single Dear ImGui context can be used across - multiple windows. (#586, #1851, #2004, #3012, #3934, #4141) -- Backends: Win32: Rework to handle certain Windows 8.1/10 features without a manifest. (#4200, #4191) - - ImGui_ImplWin32_GetDpiScaleForMonitor() will handle per-monitor DPI on Windows 10 without a manifest. - - ImGui_ImplWin32_EnableDpiAwareness() will call SetProcessDpiAwareness() fallback on Windows 8.1 without a manifest. -- Backends: Win32: IME functions are disabled by default for non-Visual Studio compilers (MinGW etc.). Enable with - '#define IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS' for those compilers. Undo change from 1.82. (#2590, #738, #4185, #4301) -- Backends: Win32: Mouse position is correctly reported when the host window is hovered but not focused. (#2445, #2696, #3751, #4377) -- Backends: Win32, SDL2, GLFW, OSX, Allegro: now calling io.AddFocusEvent() on focus gain/loss. (#4388) [@thedmd] - This allow us to ignore certain inputs on focus loss (previously relied on mouse loss but backends are now - reporting mouse even when host window is unfocused, as per #2445, #2696, #3751, #4377) -- Backends: Fixed keyboard modifiers being reported when host window doesn't have focus. (#2622) -- Backends: GLFW: Mouse position is correctly reported when the host window is hovered but not focused. (#3751, #4377, #2445) - (backend now uses glfwSetCursorEnterCallback(). If you called ImGui_ImplGlfw_InitXXX with install_callbacks=false, you will - need to install this callback and forward the data to the backend via ImGui_ImplGlfw_CursorEnterCallback). -- Backends: SDL2: Mouse position is correctly reported when the host window is hovered but not focused. (#3751, #4377, #2445) - (enabled with SDL 2.0.5+ as SDL_GetMouseFocus() is only usable with SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH). -- Backends: DX9: Explicitly disable texture state stages after >= 1. (#4268) [@NZJenkins] -- Backends: DX12: Fix texture casting crash on 32-bit systems (introduced on 2021/05/19 and v1.83) + added comments - about building on 32-bit systems. (#4225) [@kingofthebongo2008] -- Backends: OpenGL3: Embed our own minimal GL headers/loader (imgui_impl_opengl3_loader.h) based on gl3w. - Reduces the frequent issues and confusion coming from having to support multiple loaders and requiring users to use and - initialize the same loader as the backend. [@rokups] - Removed support for gl3w, glew, glad, glad2, glbinding2, glbinding3 (all now unnecessary). -- Backends: OpenGL3: Handle GL_CLIP_ORIGIN on <4.5 contexts if "GL_ARB_clip_control" extension is detected. (#4170, #3998) -- Backends: OpenGL3: Destroy vertex/fragment shader objects right after they are linked into main shader. (#4244) [@Crowbarous] -- Backends: OpenGL3: Use OES_vertex_array extension on Emscripten + backup/restore current state. (#4266, #4267) [@harry75369] -- Backends: GLFW: Installing and exposed ImGui_ImplGlfw_MonitorCallback() for forward compatibility with docking branch. -- Backends: OSX: Added a fix for shortcuts using CTRL key instead of CMD key. (#4253) [@rokups] -- Examples: DX12: Fixed handling of Alt+Enter in example app (using swapchain's ResizeBuffers). (#4346) [@PathogenDavid] -- Examples: DX12: Removed unnecessary recreation of backend-owned device objects when window is resized. (#4347) [@PathogenDavid] -- Examples: OpenGL3+GLFW,SDL: Remove include cruft to support variety of GL loaders (no longer necessary). [@rokups] -- Examples: OSX+OpenGL2: Fix event forwarding (fix key remaining stuck when using shortcuts with Cmd/Super key). - Other OSX examples were not affected. (#4253, #1873) [@rokups] -- Examples: Updated all .vcxproj to VS2015 (toolset v140) to facilitate usage with vcpkg. -- Examples: SDL2: Accommodate for vcpkg install having headers in SDL2/SDL.h vs SDL.h. - - ------------------------------------------------------------------------ - VERSION 1.83 (Released 2021-05-24) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.83 - -Breaking Changes: - -- Backends: Obsoleted direct access to ImDrawCmd::TextureId in favor of calling ImDrawCmd::GetTexID(). (#3761) [@thedmd] - - If you are using official backends from the source tree: you have nothing to do. - - If you copied old backend code or using your own: change access to draw_cmd->TextureId to draw_cmd->GetTexID(). - Why are we doing this? - - This change will be required in the future when adding support for incremental texture atlas updates. - - Please note this won't break soon, but we are making the change ahead of time. - -Other Changes: - -- Scrolling: Fix scroll tracking with e.g. SetScrollHereX/Y() when WindowPadding < ItemSpacing. -- Scrolling: Fix scroll snapping on edge of scroll region when both scrollbars are enabled. -- Scrolling: Fix mouse wheel axis swap when using SHIFT on macOS (system already does it). (#4010) -- Window: Fix IsWindowAppearing() from returning true twice in most cases. (#3982, #1497, #1061) -- Nav: Fixed toggling menu layer while an InputText() is active not stealing active id. (#787) -- Nav: Fixed pressing Escape to leave menu layer while in a popup or child window. (#787) -- Nav, InputText: Fixed accidental menu toggling while typing non-ascii characters using AltGR. [@rokups] (#370) -- Nav: Fixed using SetItemDefaultFocus() on windows with _NavFlattened flag. (#787) -- Nav: Fixed Tabbing initial activation from skipping the first item if it is tabbable through. (#787) -- Nav: Fixed fast CTRL+Tab (where keys are only held for one single frame) from properly enabling the - menu layer of target window if it doesn't have other active layers. -- Tables: Expose TableSetColumnEnabled() in public api. (#3935) -- Tables: Better preserve widths when columns count changes. (#4046) -- Tables: Sharing more memory buffers between tables, reducing general memory footprints. (#3740) -- TabBar: Fixed mouse reordering with very fast movements (e.g. crossing multiple tabs in a single - frame and then immediately standing still (would only affect automation/bots). [@rokups] -- Menus: made MenuItem() in a menu bar reflect the 'selected' argument with a highlight. (#4128) [@mattelegende] -- Drags, Sliders, Inputs: Specifying a NULL format to Float functions default them to "%.3f" to be - consistent with the compile-time default. (#3922) -- DragScalar: Add default value for v_speed argument to match higher-level functions. (#3922) [@eliasdaler] -- ColorEdit4: Alpha default to 255 (instead of 0) when omitted in hex input. (#3973) [@squadack] -- InputText: Fix handling of paste failure (buffer full) which in some cases could corrupt the undo stack. (#4038) - (fix submitted to https://github.com/nothings/stb/pull/1158) [@Unit2Ed, @ocornut] -- InputText: Do not filter private unicode codepoints (e.g. icons) when pasted from clipboard. (#4005) [@dougbinks] -- InputText: Align caret/cursor to pixel coordinates. (#4080) [@elvissteinjr] -- InputText: Fixed CTRL+Arrow or OSX double-click leaking the presence of spaces when ImGuiInputTextFlags_Password - is used. (#4155, #4156) [@michael-swan] -- LabelText: Fixed clipping of multi-line value text when label is single-line. (#4004) -- LabelText: Fixed vertical alignment of single-line value text when label is multi-line. (#4004) -- Combos: Changed the combo popup to use a different id to also using a context menu with the default item id. - Fixed using BeginPopupContextItem() with no parameter after a combo. (#4167) -- Popups: Added 'OpenPopup(ImGuiID id)' overload to facilitate calling from nested stacks. (#3993, #331) [@zlash] -- Tweak computation of io.Framerate so it is less biased toward high-values in the first 120 frames. (#4138) -- Optimization: Disabling some of MSVC most aggressive Debug runtime checks for some simple/low-level functions - (e.g. ImVec2, ImVector) leading to a 10-20% increase of performances with MSVC "default" Debug settings. -- ImDrawList: Add and use SSE-enabled ImRsqrt() in place of 1.0f / ImSqrt(). (#4091) [@wolfpld] -- ImDrawList: Fixed/improved thickness of thick strokes with sharp angles. (#4053, #3366, #2964, #2868, #2518, #2183) - Effectively introduced a regression in 1.67 (Jan 2019), and a fix in 1.70 (Apr 2019) but the fix wasn't actually on - par with original version. Now incorporating the correct revert. -- ImDrawList: Fixed PathArcTo() regression from 1.82 preventing use of counter-clockwise angles. (#4030, #3491) [@thedmd] -- Demo: Improved popups demo and comments. -- Metrics: Added "Fonts" section with same information as available in "Style Editor">"Fonts". -- Backends: SDL2: Rework global mouse pos availability check listing supported platforms explicitly, - effectively fixing mouse access on Raspberry Pi. (#2837, #3950) [@lethal-guitar, @hinxx] -- Backends: Win32: Clearing keyboard down array when losing focus (WM_KILLFOCUS). (#2062, #3532, #3961) - [@1025798851] -- Backends: OSX: Fix keys remaining stuck when CMD-tabbing to a different application. (#3832) [@rokups] -- Backends: DirectX9: calling IDirect3DStateBlock9::Capture() after CreateStateBlock() which appears to - workaround/fix state restoring issues. Unknown exactly why so, bit of a cargo-cult fix. (#3857) -- Backends: DirectX9: explicitly setting up more graphics states to increase compatibility with unusual - non-default states. (#4063) -- Backends: DirectX10, DirectX11: fixed a crash when backing/restoring state if nothing is bound when - entering the rendering function. (#4045) [@Nemirtingas] -- Backends: GLFW: Adding bound check in KeyCallback because GLFW appears to send -1 on some setups. [#4124] -- Backends: Vulkan: Fix mapped memory Vulkan validation error when buffer sizes are not multiple of - VkPhysicalDeviceLimits::nonCoherentAtomSize. (#3957) [@AgentX1994] -- Backends: WebGPU: Update to latest specs (Chrome Canary 92 and Emscripten 2.0.20). (#4116, #3632) [@bfierz, @Kangz] -- Backends: OpenGL3: Don't try to read GL_CLIP_ORIGIN unless we're OpenGL 4.5. (#3998, #2366, #2186) [@s7jones] -- Examples: OpenGL: Add OpenGL ES 2.0 support to modern GL examples. (#2837, #3951) [@lethal-guitar, @hinxx] -- Examples: Vulkan: Rebuild swapchain on VK_SUBOPTIMAL_KHR. (#3881) -- Examples: Vulkan: Prefer using discrete GPU if there are more than one available. (#4012) [@rokups] -- Examples: SDL2: Link with shell32.lib required by SDL2main.lib since SDL 2.0.12. [#3988] -- Examples: Android: Make Android example build compatible with Gradle 7.0. (#3446) -- Docs: Improvements to description of using colored glyphs/emojis. (#4169, #3369) -- Docs: Improvements to minor mistakes in documentation comments (#3923) [@ANF-Studios] - - ------------------------------------------------------------------------ - VERSION 1.82 (Released 2021-02-15) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.82 - -Breaking Changes: - -- Removed redirecting functions/enums names that were marked obsolete in 1.66 (September 2018): - - ImGui::SetScrollHere() --> use ImGui::SetScrollHereY() -- ImDrawList: upgraded AddPolyline()/PathStroke()'s "bool closed" parameter to use "ImDrawFlags flags". - - bool closed = false --> use ImDrawFlags_None, or 0 - - bool closed = true --> use ImDrawFlags_Closed - The matching ImDrawFlags_Closed value is guaranteed to always stay == 1 in the future. - Difference may not be noticeable for most but zealous type-checking tools may report a need to change. -- ImDrawList: upgraded AddRect(), AddRectFilled(), PathRect() to use ImDrawFlags instead of ImDrawCornersFlags. - - ImDrawCornerFlags_TopLeft --> use ImDrawFlags_RoundCornersTopLeft - - ImDrawCornerFlags_BotRight --> use ImDrawFlags_RoundCornersBottomRight - - ImDrawCornerFlags_None --> use ImDrawFlags_RoundCornersNone etc. - Flags now sanely defaults to 0 instead of 0x0F, consistent with all other flags in the API. - IMPORTANT: The default with rounding > 0.0f is now "round all corners" vs old implicit "round no corners": - - rounding == 0.0f + flags == 0 --> meant no rounding --> unchanged (common use) - - rounding > 0.0f + flags != 0 --> meant rounding --> unchanged (common use) - - rounding == 0.0f + flags != 0 --> meant no rounding --> unchanged (unlikely use) - - rounding > 0.0f + flags == 0 --> meant no rounding --> BREAKING (unlikely use)! - - this ONLY matters for hardcoded use of 0 with rounding > 0.0f. - - fix by using named ImDrawFlags_RoundCornersNone or rounding == 0.0f! - - this is technically the only real breaking change which we can't solve automatically (it's also uncommon). - The old ImDrawCornersFlags used awkward default values of ~0 or 0xF (4 lower bits set) to signify "round all corners" - and we sometimes encouraged using them as shortcuts. As a result the legacy path still support use of hardcoded ~0 - or any value from 0x1 or 0xF. They will behave the same with legacy paths enabled (will assert otherwise). - Courtesy of legacy untangling commity: [@rokups, @ocornut, @thedmd] -- ImDrawList: clarified that PathArcTo()/PathArcToFast() won't render with radius < 0.0f. Previously it sorts - of accidentally worked but would lead to counter-clockwise paths which and have an effect on anti-aliasing. -- InputText: renamed ImGuiInputTextFlags_AlwaysInsertMode to ImGuiInputTextFlags_AlwaysOverwrite, old name was an - incorrect description of behavior. Was ostly used by memory editor. Kept inline redirection function. (#2863) -- Moved 'misc/natvis/imgui.natvis' to 'misc/debuggers/imgui.natvis' as we will provide scripts for other debuggers. -- Style: renamed rarely used style.CircleSegmentMaxError (old default = 1.60f) - to style.CircleTessellationMaxError (new default = 0.30f) as its meaning changed. (#3808) [@thedmd] -- Win32+MinGW: Re-enabled IME functions by default even under MinGW. In July 2016, issue #738 had me incorrectly - disable those default functions for MinGW. MinGW users should: either link with -limm32, either set their - imconfig file with '#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS'. (#2590, #738) [@actboy168] - *EDIT* Undid in 1.84. -- Backends: Win32: Pragma linking with dwmapi.lib (Vista-era, ~9 kb). MinGW users will need to link with -ldwmapi. - -Other Changes: - -- Window, Nav: Fixed crash when calling SetWindowFocus(NULL) at the time a new window appears. (#3865) [@nem0] -- Window: Shrink close button hit-testing region when it covers an abnormally high portion of the window visible - area (e.g. when window is collapsed + moved in a corner) to facilitate moving the window away. (#3825) -- Nav: Various fixes for losing gamepad/keyboard navigation reference point when a window reappears or - when it appears while gamepad/keyboard are not being used. (#787) -- Drags: Fixed crash when using DragScalar() directly (not via common wrapper like DragFloat() etc.) - with ImGuiSliderFlags_AlwaysClamp + only one of either p_min or p_max set. (#3824) [@harry75369] -- Drags, Sliders: Fixed a bug where editing value would use wrong number if there were digits right after - format specifier (e.g. using "%f123" as a format string). [@rokups] -- Drags, Sliders: Fixed a bug where using custom formatting flags (',$,_) supported by stb_sprintf.h - would cause incorrect value to be displayed. (#3604) [@rokups] -- Drags, Sliders: Support ImGuiSliderFlags_Logarithmic flag with integers. Because why not? (#3786) -- Tables: Fixed unaligned accesses when using TableSetBgColor(ImGuiTableBgTarget_CellBg). (#3872) -- IsItemHovered(): fixed return value false positive when used after EndChild(), EndGroup() or widgets using - either of them, when the hovered location is located within a child window, e.g. InputTextMultiline(). - This is intended to have no side effects, but brace yourself for the possible comeback.. (#3851, #1370) -- Drag and Drop: can use BeginDragDropSource() for other than the left mouse button as long as the item - has an ID (for ID-less items will add new functionalities later). (#1637, #3885) -- ImFontAtlas: Added 'bool TexPixelsUseColors' output to help backend decide of underlying texture format. (#3369) - This can currently only ever be set by the Freetype renderer. -- imgui_freetype: Added ImGuiFreeTypeBuilderFlags_Bitmap flag to request Freetype loading bitmap data. - This may have an effect on size and must be called with correct size values. (#3879) [@metarutaiga] -- ImDrawList: PathArcTo() now supports "int num_segments = 0" (new default) and adaptively tessellate. - The adaptive tessellation uses look up tables, tends to be faster than old PathArcTo() while maintaining - quality for large arcs (tessellation quality derived from "style.CircleTessellationMaxError") (#3491) [@thedmd] -- ImDrawList: PathArcToFast() also adaptively tessellate efficiently. This means that large rounded corners - in e.g. hi-dpi settings will generally look better. (#3491) [@thedmd] -- ImDrawList: AddCircle, AddCircleFilled(): Tweaked default segment count calculation to honor MaxError - with more accuracy. Made default segment count always even for better looking result. (#3808) [@thedmd] -- Misc: Added GetAllocatorFunctions() to facilitate sharing allocators across DLL boundaries. (#3836) -- Misc: Added 'debuggers/imgui.gdb' and 'debuggers/imgui.natstepfilter' (along with existing 'imgui.natvis') - scripts to configure popular debuggers into skipping trivial functions when using StepInto. [@rokups] -- Backends: Android: Added native Android backend. (#3446) [@duddel] -- Backends: Win32: Added ImGui_ImplWin32_EnableAlphaCompositing() to facilitate experimenting with - alpha compositing and transparent windows. (#2766, #3447 etc.). -- Backends: OpenGL, Vulkan, DX9, DX10, DX11, DX12, Metal, WebGPU, Allegro: Rework blending equation to - preserve alpha in output buffer (using SrcBlendAlpha = ONE, DstBlendAlpha = ONE_MINUS_SRC_ALPHA consistently - accross all backends), facilitating compositing of the output buffer with another buffer. - (#2693, #2764, #2766, #2873, #3447, #3813, #3816) [@ocornut, @thedmd, @ShawnM427, @Ubpa, @aiekick] -- Backends: DX9: Fix to support IMGUI_USE_BGRA_PACKED_COLOR. (#3844) [@Xiliusha] -- Backends: DX9: Fix to support colored glyphs, using newly introduced 'TexPixelsUseColors' info. (#3844) -- Examples: Android: Added Android + GL ES3 example. (#3446) [@duddel] -- Examples: Reworked setup of clear color to be compatible with transparent values. -- CI: Use a dedicated "scheduled" workflow to trigger scheduled builds. Forks may disable this workflow if - scheduled builds builds are not required. [@rokups] -- Log/Capture: Added LogTextV, a va_list variant of LogText. [@PathogenDavid] - - ------------------------------------------------------------------------ - VERSION 1.81 (Released 2021-02-10) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.81 - -Breaking Changes: - -- ListBox helpers: - - Renamed ListBoxHeader(const char* label, ImVec2 size) to BeginListBox(). - - Renamed ListBoxFooter() to EndListBox(). - - Removed ListBoxHeader(const char* label, int items_count, int height_in_items = -1) in favor of specifying size. - In the redirection function, made vertical padding consistent regardless of (items_count <= height_in_items) or not. - - Kept inline redirection function for all threes (will obsolete). -- imgui_freetype: - - Removed ImGuiFreeType::BuildFontAtlas(). Kept inline redirection function. - Prefer using '#define IMGUI_ENABLE_FREETYPE', but there's a runtime selection path available too. - - The shared extra flags parameters (very rarely used) are now stored in ImFontAtlas::FontBuilderFlags. - - Renamed ImFontConfig::RasterizerFlags (used by FreeType) to ImFontConfig::FontBuilderFlags. - - Renamed ImGuiFreeType::XXX flags to ImGuiFreeTypeBuilderFlags_XXX for consistency with other API. - -Other Changes: - -- Viewports Added ImGui::GetMainViewport() as a way to get the bounds and work area of the host display. (#3789, #1542) - - In 'master' branch or without multi-viewports feature enabled: - - GetMainViewport()->Pos is always == (0,0) - - GetMainViewport()->Size is always == io.DisplaySize - - In 'docking' branch and with the multi-viewports feature enabled: - - GetMainViewport() will return information from your host Platform Window. - - In the future, we will support a "no main viewport" mode and this may return bounds of your main monitor. - - For forward compatibility with multi-viewports/multi-monitors: - - Code using (0,0) as a way to signify "upper-left of the host window" should use GetMainViewport()->Pos. - - Code using io.DisplaySize as a way to signify "size of the host window" should use GetMainViewport()->Size. - - We are also exposing a work area in ImGuiViewport ('WorkPos', 'WorkSize' vs 'Pos', 'Size' for full area): - - For a Platform Window, the work area is generally the full area minus space used by menu-bars. - - For a Platform Monitor, the work area is generally the full area minus space used by task-bars. - - All of this has been the case in 'docking' branch for a long time. What we've done is merely merging - a small chunk of the multi-viewport logic into 'master' to standardize some concepts ahead of time. -- Tables: Fixed PopItemWidth() or multi-components items not restoring per-colum ItemWidth correctly. (#3760) -- Window: Fixed minor title bar text clipping issue when FramePadding is small/zero and there are no - close button in the window. (#3731) -- SliderInt: Fixed click/drag when v_min==v_max from setting the value to zero. (#3774) [@erwincoumans] - Would also repro with DragFloat() when using ImGuiSliderFlags_Logarithmic with v_min==v_max. -- Menus: Fixed an issue with child-menu auto sizing (issue introduced in 1.80 on 2021/01/25) (#3779) -- InputText: Fixed slightly off ScrollX tracking, noticeable with large values of FramePadding.x. (#3781) -- InputText: Multiline: Fixed padding/cliprect not precisely matching single-line version. (#3781) -- InputText: Multiline: Fixed FramePadding.y worth of vertical offset when aiming with mouse. -- ListBox: Tweaked default height calculation. -- Fonts: imgui_freetype: Facilitated using FreeType integration: [@Xipiryon, @ocornut] - - Use '#define IMGUI_ENABLE_FREETYPE' in imconfig.h should make it work with no other modifications - other than compiling misc/freetype/imgui_freetype.cpp and linking with FreeType. - - Use '#define IMGUI_ENABLE_STB_TRUETYPE' if you somehow need the stb_truetype rasterizer to be - compiled in along with the FreeType one, otherwise it is enabled by default. -- Fonts: imgui_freetype: Added support for colored glyphs as supported by Freetype 2.10+ (for .ttf using CPAL/COLR - tables only). Enable the ImGuiFreeTypeBuilderFlags_LoadColor on a given font. Atlas always output directly - as RGBA8 in this situation. Likely to make sense with IMGUI_USE_WCHAR32. (#3369) [@pshurgal] -- Fonts: Fixed CalcTextSize() width rounding so it behaves more like a ceil. This is in order for text wrapping - to have enough space when provided width precisely calculated with CalcTextSize().x. (#3776) - Note that the rounding of either positions and widths are technically undesirable (e.g. #3437, #791) but - variety of code is currently on it so we are first fixing current behavior before we'll eventually change it. -- Log/Capture: Fix various new line/spacing issue when logging widgets. [@Xipiryon, @ocornut] -- Log/Capture: Improved the ASCII look of various widgets, making large dumps more easily human readable. -- ImDrawList: Fixed AddCircle()/AddCircleFilled() with (rad > 0.0f && rad < 1.0f && num_segments == 0). (#3738) - Would lead to a buffer read overflow. -- ImDrawList: Clarified PathArcTo() need for a_min <= a_max with an assert. -- ImDrawList: Fixed PathArcToFast() handling of a_min > a_max. -- Metrics: Back-ported "Viewports" debug visualizer from 'docking' branch. -- Demo: Added 'Examples->Fullscreen Window' demo using GetMainViewport() values. (#3789) -- Demo: 'Simple Overlay' demo now moves under main menu-bar (if any) using GetMainViewport()'s work area. -- Backends: Win32: Dynamically loading XInput DLL instead of linking with it, facilitate compiling with - old WindowSDK versions or running on Windows 7. (#3646, #3645, #3248, #2716) [@Demonese] -- Backends: Vulkan: Add support for custom Vulkan function loader and VK_NO_PROTOTYPES. (#3759, #3227) [@Hossein-Noroozpour] - User needs to call ImGui_ImplVulkan_LoadFunctions() with their custom loader prior to other functions. -- Backends: Metal: Fixed texture storage mode when building on Mac Catalyst. (#3748) [@Belinsky-L-V] -- Backends: OSX: Fixed mouse position not being reported when mouse buttons other than left one are down. (#3762) [@rokups] -- Backends: WebGPU: Added enderer backend for WebGPU support (imgui_impl_wgpu.cpp) (#3632) [@bfierz] - Please note that WebGPU is currently experimental, will not run on non-beta browsers, and may break. -- Examples: WebGPU: Added Emscripten+WebGPU example. (#3632) [@bfierz] -- Backends: GLFW: Added ImGui_ImplGlfw_InitForOther() initialization call to use with non OpenGL API. (#3632) - - ------------------------------------------------------------------------ - VERSION 1.80 (Released 2021-01-21) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.80 - -Breaking Changes: - -- Added imgui_tables.cpp file! Manually constructed project files will need the new file added! (#3740) -- Backends: moved all backends files (imgui_impl_XXXX.cpp, imgui_impl_XXXX.h) from examples/ to backends/. (#3513) -- Renamed ImDrawList::AddBezierCurve() to ImDrawList::AddBezierCubic(). Kept inline redirection function (will obsolete). -- Renamed ImDrawList::PathBezierCurveTo() to ImDrawList::PathBezierCubicCurveTo(). Kept inline redirection function (will obsolete). -- Removed redirecting functions/enums names that were marked obsolete in 1.60 (April 2018): - - io.RenderDrawListsFn pointer -> use ImGui::GetDrawData() value and call the render function of your backend - - ImGui::IsAnyWindowFocused() -> use ImGui::IsWindowFocused(ImGuiFocusedFlags_AnyWindow) - - ImGui::IsAnyWindowHovered() -> use ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow) - - ImGuiStyleVar_Count_ -> use ImGuiStyleVar_COUNT - - ImGuiMouseCursor_Count_ -> use ImGuiMouseCursor_COUNT -- Removed redirecting functions/enums names that were marked obsolete in 1.61 (May 2018): - - InputFloat (... int decimal_precision ...) -> use InputFloat (... const char* format ...) with format = "%.Xf" where X was value for decimal_precision. - - same for InputFloat2()/InputFloat3()/InputFloat4() variants taking a `int decimal_precision` parameter. -- Removed redirecting functions/enums names that were marked obsolete in 1.63 (August 2018): - - ImGui::IsItemDeactivatedAfterChange() -> use ImGui::IsItemDeactivatedAfterEdit(). - - ImGuiCol_ModalWindowDarkening -> use ImGuiCol_ModalWindowDimBg - - ImGuiInputTextCallback -> use ImGuiTextEditCallback - - ImGuiInputTextCallbackData -> use ImGuiTextEditCallbackData -- If you were still using the old names, while you are cleaning up, considering enabling - IMGUI_DISABLE_OBSOLETE_FUNCTIONS in imconfig.h even temporarily to have a pass at finding - and removing up old API calls, if any remaining. -- Internals: Columns: renamed undocumented/internals ImGuiColumnsFlags_* to ImGuiOldColumnFlags_* to reduce - confusion with Tables API. Keep redirection enums (will obsolete). (#125, #513, #913, #1204, #1444, #2142, #2707) -- Renamed io.ConfigWindowsMemoryCompactTimer to io.ConfigMemoryCompactTimer as the feature now applies - to other data structures. (#2636) - -Other Changes: - -- Tables: added new Tables Beta API as a replacement for old Columns. (#3740, #2957, #125) - Check out 'Demo->Tables' for many demos. - Read API comments in imgui.h for details. Read extra commentary in imgui_tables.cpp. - - Added 16 functions: - - BeginTable(), EndTable() - - TableNextRow(), TableNextColumn(), TableSetColumnIndex() - - TableSetupColumn(), TableSetupScrollFreeze() - - TableHeadersRow(), TableHeader() - - TableGetRowIndex(), TableGetColumnCount(), TableGetColumnIndex(), TableGetColumnName(), TableGetColumnFlags() - - TableGetSortSpecs(), TableSetBgColor() - - Added 3 flags sets: - - ImGuiTableFlags (29 flags for: features, decorations, sizing policies, padding, clipping, scrolling, sorting etc.) - - ImGuiTableColumnFlags (24 flags for: width policies, default settings, sorting options, indentation options etc.) - - ImGuiTableRowFlags (1 flag for: header row) - - Added 2 structures: ImGuiTableSortSpecs, ImGuiTableColumnSortSpecs - - Added 2 enums: ImGuiSortDirection, ImGuiTableBgTarget - - Added 1 style variable: ImGuiStyleVar_CellPadding - - Added 5 style colors: ImGuiCol_TableHeaderBg, ImGuiCol_TableBorderStrong, ImGuiCol_TableBorderLight, ImGuiCol_TableRowBg, ImGuiCol_TableRowBgAlt. -- Tab Bar: Made it possible to append to an existing tab bar by calling BeginTabBar()/EndTabBar() again. -- Tab Bar: Fixed using more than 128 tabs in a tab bar (scrolling policy recommended). -- Tab Bar: Do not display a tooltip if the name already fits over a given tab. (#3521) -- Tab Bar: Fixed minor/unlikely bug skipping over a button when scrolling left with arrows. -- Tab Bar: Requested ideal content size (for auto-fit) doesn't affect horizontal scrolling. (#3414) -- Drag and Drop: Fix losing drop source ActiveID (and often source tooltip) when opening a TreeNode() - or CollapsingHeader() while dragging. (#1738) -- Drag and Drop: Fix drag and drop to tie same-size drop targets by chosen the later one. Fixes dragging - into a full-window-sized dockspace inside a zero-padded window. (#3519, #2717) [@Black-Cat] -- Checkbox: Added CheckboxFlags() helper with int* type (internals have a template version, not exposed). -- Clipper: Fixed incorrect end-list positioning when using ImGuiListClipper with 1 item (bug in 1.79). (#3663) [@nyorain] -- InputText: Fixed updating cursor/selection position when a callback altered the buffer in a way - where the byte count is unchanged but the decoded character count changes. (#3587) [@gqw] -- InputText: Fixed switching from single to multi-line while preserving same ID. -- Combo: Fixed using IsItemEdited() after Combo() not matching the return value from Combo(). (#2034) -- DragFloat, DragInt: very slightly increased mouse drag threshold + expressing it as a factor of default value. -- DragFloat, DragInt: added experimental io.ConfigDragClickToInputText feature to enable turning DragXXX widgets - into text input with a simple mouse click-release (without moving). (#3737) -- Nav: Fixed IsItemFocused() from returning false when Nav highlight is hidden because mouse has moved. - It's essentially been always the case but it doesn't make much sense. Instead we will aim at exposing - feedback and control of keyboard/gamepad navigation highlight and mouse hover disable flag. (#787, #2048) -- Metrics: Fixed mishandling of ImDrawCmd::VtxOffset in wireframe mesh renderer. -- Metrics: Rebranded as "Dear ImGui Metrics/Debugger" to clarify its purpose. -- ImDrawList: Added ImDrawList::AddQuadBezierCurve(), ImDrawList::PathQuadBezierCurveTo() quadratic bezier - helpers. (#3127, #3664, #3665) [@aiekick] -- Fonts: Updated GetGlyphRangesJapanese() to include a larger 2999 ideograms selection of Joyo/Jinmeiyo - kanjis, from the previous 1946 ideograms selection. This will consume a some more memory but be generally - much more fitting for Japanese display, until we switch to a more dynamic atlas. (#3627) [@vaiorabbit] -- Log/Capture: fix capture to work on clipped child windows. -- Misc: Made the ItemFlags stack shared, so effectively the ButtonRepeat/AllowKeyboardFocus states - (and others exposed in internals such as PushItemFlag) are inherited by stacked Begin/End pairs, - vs previously a non-child stacked Begin() would reset those flags back to zero for the stacked window. -- Misc: Replaced UTF-8 decoder with one based on branchless one by Christopher Wellons. [@rokups] - Super minor fix handling incomplete UTF-8 contents: if input does not contain enough bytes, decoder - returns IM_UNICODE_CODEPOINT_INVALID and consume remaining bytes (vs old decoded consumed only 1 byte). -- Misc: Fix format warnings when using gnu printf extensions in a setup that supports them (gcc/mingw). (#3592) -- Misc: Made EndFrame() assertion for key modifiers being unchanged during the frame (added in 1.76) more - lenient, allowing full mid-frame releases. This is to accommodate the use of mid-frame modal native - windows calls, which leads backends such as GLFW to send key clearing events on focus loss. (#3575) -- Style: Changed default style.WindowRounding value to 0.0f (matches default for multi-viewports). -- Style: Reduced the size of the resizing grip, made alpha less prominent. -- Style: Classic: Increase the default alpha value of WindowBg to be closer to other styles. -- Demo: Clarify usage of right-aligned items in Demo>Layout>Widgets Width. -- Backends: OpenGL3: Use glGetString(GL_VERSION) query instead of glGetIntegerv(GL_MAJOR_VERSION, ...) - when the later returns zero (e.g. Desktop GL 2.x). (#3530) [@xndcn] -- Backends: OpenGL2: Backup and restore GL_SHADE_MODEL and disable GL_NORMAL_ARRAY state to increase - compatibility with legacy code. (#3671) -- Backends: OpenGL3: Backup and restore GL_PRIMITIVE_RESTART state. (#3544) [@Xipiryon] -- Backends: OpenGL2, OpenGL3: Backup and restore GL_STENCIL_TEST enable state. (#3668) -- Backends: Vulkan: Added support for specifying which sub-pass to reference during VkPipeline creation. (@3579) [@bdero] -- Backends: DX12: Improve Windows 7 compatibility (for D3D12On7) by loading d3d12.dll dynamically. (#3696) [@Mattiwatti] -- Backends: Win32: Fix setting of io.DisplaySize to invalid/uninitialized data after hwnd has been closed. -- Backends: OSX: Fix keypad-enter key not working on MacOS. (#3554) [@rokups, @lfnoise] -- Examples: Apple+Metal: Consolidated/simplified to get closer to other examples. (#3543) [@warrenm] -- Examples: Apple+Metal: Forward events down so OS key combination like Cmd+Q can work. (#3554) [@rokups] -- Examples: Emscripten: Renamed example_emscripten/ to example_emscripten_opengl3/. (#3632) -- Examples: Emscripten: Added 'make serve' helper to spawn a web-server on localhost. (#3705) [@Horki] -- Examples: DirectX12: Move ImGui::Render() call above the first barrier to clarify its lack of effect on the graphics pipe. -- CI: Fix testing for Windows DLL builds. (#3603, #3601) [@iboB] -- Docs: Improved the wiki and added a https://github.com/ocornut/imgui/wiki/Useful-Widgets page. [@Xipiryon] - [2021/05/20: moved to https://github.com/ocornut/imgui/wiki/Useful-Extensions] -- Docs: Split examples/README.txt into docs/BACKENDS.md and docs/EXAMPLES.md, and improved them. -- Docs: Consistently renamed all occurrences of "binding" and "back-end" to "backend" in comments and docs. - - ------------------------------------------------------------------------ - VERSION 1.79 (Released 2020-10-08) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.79 - -Breaking Changes: - -- Fonts: Removed ImFont::DisplayOffset in favor of ImFontConfig::GlyphOffset. DisplayOffset was applied - after scaling and not very meaningful/useful outside of being needed by the default ProggyClean font. - It was also getting in the way of better font scaling, so let's get rid of it now! - If you used DisplayOffset it was probably in association to rasterizing a font at a specific size, - in which case the corresponding offset may be reported into GlyphOffset. (#1619) - If you scaled this value after calling AddFontDefault(), this is now done automatically. -- ImGuiListClipper: Renamed constructor parameters which created an ambiguous alternative to using - the ImGuiListClipper::Begin() function, with misleading edge cases. Always use ImGuiListClipper::Begin()! - Kept inline redirection function (will obsolete). - (note: imgui_memory_editor <0.40 from imgui_club/ used this old clipper API. Update your copy if needed). -- Style: Renamed style.TabMinWidthForUnselectedCloseButton to style.TabMinWidthForCloseButton. -- Renamed ImGuiSliderFlags_ClampOnInput to ImGuiSliderFlags_AlwaysClamp. Kept redirection enum (will obsolete). -- Renamed OpenPopupContextItem() back to OpenPopupOnItemClick(), REVERTED CHANGE FROM 1.77. - For variety of reason this is more self-explanatory and less error-prone. Kept inline redirection function. -- Removed return value from OpenPopupOnItemClick() - returned true on mouse release on an item - because it - is inconsistent with other popups API and makes others misleading. It's also and unnecessary: you can - use IsWindowAppearing() after BeginPopup() for a similar result. - -Other Changes: - -- Window: Fixed using non-zero pivot in SetNextWindowPos() when the window is collapsed. (#3433) -- Nav: Fixed navigation resuming on first visible item when using gamepad. [@rokups] -- Nav: Fixed using Alt to toggle the Menu layer when inside a Modal window. (#787) -- Scrolling: Fixed SetScrollHere(0) functions edge snapping when called during a frame where - ContentSize is changing (issue introduced in 1.78). (#3452). -- InputText: Added support for Page Up/Down in InputTextMultiline(). (#3430) [@Xipiryon] -- InputText: Added selection helpers in ImGuiInputTextCallbackData(). -- InputText: Added ImGuiInputTextFlags_CallbackEdit to modify internally owned buffer after an edit. - (note that InputText() already returns true on edit, the callback is useful mainly to manipulate the - underlying buffer while focus is active). -- InputText: Fixed using ImGuiInputTextFlags_Password with InputTextMultiline(). (#3427, #3428) - It is a rather unusual or useless combination of features but no reason it shouldn't work! -- InputText: Fixed minor scrolling glitch when erasing trailing lines in InputTextMultiline(). -- InputText: Fixed cursor being partially covered after using Ctrl+End key. -- InputText: Fixed callback's helper DeleteChars() function when cursor is inside the deleted block. (#3454) -- InputText: Made pressing Down arrow on the last line when it doesn't have a carriage return not move to - the end of the line (so it is consistent with Up arrow, and behave same as Notepad and Visual Studio. - Note that some other text editors instead would move the cursor to the end of the line). [@Xipiryon] -- DragFloat, DragScalar: Fixed ImGuiSliderFlags_ClampOnInput not being honored in the special case - where v_min == v_max. (#3361) -- SliderInt, SliderScalar: Fixed reaching of maximum value with inverted integer min/max ranges, both - with signed and unsigned types. Added reverse Sliders to Demo. (#3432, #3449) [@rokups] -- Text: Bypass unnecessary formatting when using the TextColored()/TextWrapped()/TextDisabled() helpers - with a "%s" format string. (#3466) -- CheckboxFlags: Display mixed-value/tristate marker when passed flags that have multiple bits set and - stored value matches neither zero neither the full set. -- BeginMenuBar: Fixed minor bug where CursorPosMax gets pushed to CursorPos prior to calling BeginMenuBar(), - so e.g. calling the function at the end of a window would often add +ItemSpacing.y to scrolling range. -- TreeNode, CollapsingHeader: Made clicking on arrow toggle toggle the open state on the Mouse Down event - rather than the Mouse Down+Up sequence, even if the _OpenOnArrow flag isn't set. This is standard behavior - and amends the change done in 1.76 which only affected cases were _OpenOnArrow flag was set. - (This is also necessary to support full multi/range-select/drag and drop operations.) -- Tab Bar: Added TabItemButton() to submit tab that behave like a button. (#3291) [@Xipiryon] -- Tab Bar: Added ImGuiTabItemFlags_Leading and ImGuiTabItemFlags_Trailing flags to position tabs or button - at either end of the tab bar. Those tabs won't be part of the scrolling region, and when reordering cannot - be moving outside of their section. Most often used with TabItemButton(). (#3291) [@Xipiryon] -- Tab Bar: Added ImGuiTabItemFlags_NoReorder flag to disable reordering a given tab. -- Tab Bar: Keep tab item close button visible while dragging a tab (independent of hovering state). -- Tab Bar: Fixed a small bug where closing a tab that is not selected would leave a tab hole for a frame. -- Tab Bar: Fixed a small bug where scrolling buttons (with ImGuiTabBarFlags_FittingPolicyScroll) would - generate an unnecessary extra draw call. -- Tab Bar: Fixed a small bug where toggling a tab bar from Reorderable to not Reorderable would leave - tabs reordered in the tab list popup. [@Xipiryon] -- Columns: Fix inverted ClipRect being passed to renderer when using certain primitives inside of - a fully clipped column. (#3475) [@szreder] -- Popups, Tooltips: Fix edge cases issues with positioning popups and tooltips when they are larger than - viewport on either or both axises. [@Rokups] -- Fonts: AddFontDefault() adjust its vertical offset based on floor(size/13) instead of always +1. - Was previously done by altering DisplayOffset.y but wouldn't work for DPI scaled font. -- Metrics: Various tweaks, listing windows front-to-back, greying inactive items when possible. -- Demo: Add simple InputText() callbacks demo (aside from the more elaborate ones in 'Examples->Console'). -- Backends: OpenGL3: Fix to avoid compiling/calling glBindSampler() on ES or pre 3.3 contexts which have - the defines set by a loader. (#3467, #1985) [@jjwebb] -- Backends: Vulkan: Some internal refactor aimed at allowing multi-viewport feature to create their - own render pass. (#3455, #3459) [@FunMiles] -- Backends: DX12: Clarified that imgui_impl_dx12 can be compiled on 32-bit systems by redefining - the ImTextureID to be 64-bit (e.g. '#define ImTextureID ImU64' in imconfig.h). (#301) -- Backends: DX12: Fix debug layer warning when scissor rect is zero-sized. (#3472, #3462) [@StoneWolf] -- Examples: Vulkan: Reworked buffer resize handling, fix for Linux/X11. (#3390, #2626) [@RoryO] -- Examples: Vulkan: Switch validation layer to use "VK_LAYER_KHRONOS_validation" instead of - "VK_LAYER_LUNARG_standard_validation" which is deprecated (#3459) [@FunMiles] -- Examples: DX12: Enable breaking on any warning/error when debug interface is enabled. -- Examples: DX12: Added '#define ImTextureID ImU64' in project and build files to also allow building - on 32-bit systems. Added project to default Visual Studio solution file. (#301) - - ------------------------------------------------------------------------ - VERSION 1.78 (Released 2020-08-18) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.78 - -Breaking Changes: - -- Obsoleted use of the trailing 'float power=1.0f' parameter for those functions: [@Shironekoben, @ocornut] - - DragFloat(), DragFloat2(), DragFloat3(), DragFloat4(), DragFloatRange2(), DragScalar(), DragScalarN() - - SliderFloat(), SliderFloat2(), SliderFloat3(), SliderFloat4(), SliderScalar(), SliderScalarN() - - VSliderFloat(), VSliderScalar() - Replaced the final 'float power=1.0f' argument with ImGuiSliderFlags defaulting to 0 (as with all our flags). - Worked out a backward-compatibility scheme so hopefully most C++ codebase should not be affected. - In short, when calling those functions: - - If you omitted the 'power' parameter (likely!), you are not affected. - - If you set the 'power' parameter to 1.0f (same as previous default value): - - Your compiler may warn on float>int conversion. - - Everything else will work (but will assert if IMGUI_DISABLE_OBSOLETE_FUNCTIONS is defined). - - You can replace the 1.0f value with 0 to fix the warning, and be technically correct. - - If you set the 'power' parameter to >1.0f (to enable non-linear editing): - - Your compiler may warn on float>int conversion. - - Code will assert at runtime for IM_ASSERT(power == 1.0f) with the following assert description: - "Call Drag function with ImGuiSliderFlags_Logarithmic instead of using the old 'float power' function!". - - In case asserts are disabled, the code will not crash and enable the _Logarithmic flag. - - You can replace the >1.0f value with ImGuiSliderFlags_Logarithmic to fix the warning/assert - and get a _similar_ effect as previous uses of power >1.0f. - See https://github.com/ocornut/imgui/issues/3361 for all details. - For shared code, you can version check at compile-time with `#if IMGUI_VERSION_NUM >= 17704`. - Kept inline redirection functions (will obsolete) apart for: DragFloatRange2(), VSliderFloat(), VSliderScalar(). - For those three the 'float power=1.0f' version was removed directly as they were most unlikely ever used. -- DragInt, DragFloat, DragScalar: Obsoleted use of v_min > v_max to lock edits (introduced in 1.73, this was not - demoed nor documented much, will be replaced a more generic ReadOnly feature). - -Other Changes: - -- Nav: Fixed clicking on void (behind any windows) from not clearing the focused window. - This would be problematic e.g. in situation where the application relies on io.WantCaptureKeyboard - flag being cleared accordingly. (bug introduced in 1.77 WIP on 2020/06/16) (#3344, #2880) -- Window: Fixed clicking over an item which hovering has been disabled (e.g inhibited by a popup) - from marking the window as moved. -- Drag, Slider: Added ImGuiSliderFlags parameters. - - For float functions they replace the old trailing 'float power=1.0' parameter. - (See #3361 and the "Breaking Changes" block above for all details). - - Added ImGuiSliderFlags_Logarithmic flag to enable logarithmic editing - (generally more precision around zero), as a replacement to the old 'float power' parameter - which was obsoleted. (#1823, #1316, #642) [@Shironekoben, @AndrewBelt] - - Added ImGuiSliderFlags_ClampOnInput flag to force clamping value when using - CTRL+Click to type in a value manually. (#1829, #3209, #946, #413). - [note: RENAMED to ImGuiSliderFlags_AlwaysClamp in 1.79]. - - Added ImGuiSliderFlags_NoRoundToFormat flag to disable rounding underlying - value to match precision of the display format string. (#642) - - Added ImGuiSliderFlags_NoInput flag to disable turning widget into a text input - with CTRL+Click or Nav Enter. -- Nav, Slider: Fix using keyboard/gamepad controls with certain logarithmic sliders where - pushing a direction near zero values would be cancelled out. [@Shironekoben] -- DragFloatRange2, DragIntRange2: Fixed an issue allowing to drag out of bounds when both - min and max value are on the same value. (#1441) -- InputText, ImDrawList: Fixed assert triggering when drawing single line of text with more - than ~16 KB characters. (Note that current code is going to show corrupted display if after - clipping, more than 16 KB characters are visible in the same low-level ImDrawList::RenderText() - call. ImGui-level functions such as TextUnformatted() are not affected. This is quite rare - but it will be addressed later). (#3349) -- Selectable: Fixed highlight/hit extent when used with horizontal scrolling (in or outside columns). - Also fixed related text clipping when used in a column after the first one. (#3187, #3386) -- Scrolling: Avoid SetScroll, SetScrollFromPos functions from snapping on the edge of scroll - limits when close-enough by (WindowPadding - ItemPadding), which was a tweak with too many - side-effects. The behavior is still present in SetScrollHere functions as they are more explicitly - aiming at making widgets visible. May later be moved to a flag. -- Tab Bar: Allow calling SetTabItemClosed() after a tab has been submitted (will process next frame). -- InvisibleButton: Made public a small selection of ImGuiButtonFlags (previously in imgui_internal.h) - and allowed to pass them to InvisibleButton(): ImGuiButtonFlags_MouseButtonLeft/Right/Middle. - This is a small but rather important change because lots of multi-button behaviors could previously - only be achieved using lower-level/internal API. Now also available via high-level InvisibleButton() - with is a de-facto versatile building block to creating custom widgets with the public API. -- Fonts: Fixed ImFontConfig::GlyphExtraSpacing and ImFontConfig::PixelSnapH settings being pulled - from the merged/target font settings when merging fonts, instead of being pulled from the source - font settings. -- ImDrawList: Thick anti-aliased strokes (> 1.0f) with integer thickness now use a texture-based - path, reducing the amount of vertices/indices and CPU/GPU usage. (#3245) [@Shironekoben] - - This change will facilitate the wider use of thick borders in future style changes. - - Requires an extra bit of texture space (~64x64 by default), relies on GPU bilinear filtering. - - Set `io.AntiAliasedLinesUseTex = false` to disable rendering using this method. - - Clear `ImFontAtlasFlags_NoBakedLines` in ImFontAtlas::Flags to disable baking data in texture. -- ImDrawList: changed AddCircle(), AddCircleFilled() default num_segments from 12 to 0, effectively - enabling auto-tessellation by default. Tweak tessellation in Style Editor->Rendering section, or - by modifying the 'style.CircleSegmentMaxError' value. [@ShironekoBen] -- ImDrawList: Fixed minor bug introduced in 1.75 where AddCircle() with 12 segments would generate - an extra vertex. (This bug was mistakenly marked as fixed in earlier 1.77 release). [@ShironekoBen] -- Demo: Improved "Custom Rendering"->"Canvas" demo with a grid, scrolling and context menu. - Also showcase using InvisibleButton() with multiple mouse buttons flags. -- Demo: Improved "Layout & Scrolling" -> "Clipping" section. -- Demo: Improved "Layout & Scrolling" -> "Child Windows" section. -- Style Editor: Added preview of circle auto-tessellation when editing the corresponding value. -- Backends: OpenGL3: Added support for glad2 loader. (#3330) [@moritz-h] -- Backends: Allegro 5: Fixed horizontal scrolling direction with mouse wheel / touch pads (it seems - like Allegro 5 reports it differently from GLFW and SDL). (#3394, #2424, #1463) [@nobody-special666] -- Examples: Vulkan: Fixed GLFW+Vulkan and SDL+Vulkan clear color not being set. (#3390) [@RoryO] -- CI: Emscripten has stopped their support for their fastcomp backend, switching to latest sdk [@Xipiryon] - - ------------------------------------------------------------------------ - VERSION 1.77 (Released 2020-06-29) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.77 - -Breaking Changes: - -- Removed unnecessary ID (first arg) of ImFontAtlas::AddCustomRectRegular() function. Please - note that this is a Beta api and will likely be reworked in order to support multi-DPI across - multiple monitors. -- Renamed OpenPopupOnItemClick() to OpenPopupContextItem(). Kept inline redirection function (will obsolete). - [NOTE: THIS WAS REVERTED IN 1.79] -- Removed BeginPopupContextWindow(const char*, int mouse_button, bool also_over_items) in favor - of BeginPopupContextWindow(const char*, ImGuiPopupFlags flags) with ImGuiPopupFlags_NoOverItems. - Kept inline redirection function (will obsolete). -- Removed obsoleted CalcItemRectClosestPoint() entry point (has been asserting since December 2017). - -Other Changes: - -- TreeNode: Fixed bug where BeginDragDropSource() failed when the _OpenOnDoubleClick flag is - enabled (bug introduced in 1.76, but pre-1.76 it would also fail unless the _OpenOnArrow - flag was also set, and _OpenOnArrow is frequently set along with _OpenOnDoubleClick). -- TreeNode: Fixed bug where dragging a payload over a TreeNode() with either _OpenOnDoubleClick - or _OpenOnArrow would open the node. (#143) -- Windows: Fix unintended feedback loops when resizing windows close to main viewport edges. [@rokups] -- Tabs: Added style.TabMinWidthForUnselectedCloseButton settings: - - Set to 0.0f (default) to always make a close button appear on hover (same as Chrome, VS). - - Set to FLT_MAX to only display a close button when selected (merely hovering is not enough). - - Set to an intermediary value to toggle behavior based on width (same as Firefox). -- Tabs: Added a ImGuiTabItemFlags_NoTooltip flag to disable the tooltip for individual tab item - (vs ImGuiTabBarFlags_NoTooltip for entire tab bar). [@Xipiryon] -- Popups: All functions capable of opening popups (OpenPopup*, BeginPopupContext*) now take a new - ImGuiPopupFlags sets of flags instead of a mouse button index. The API is automatically backward - compatible as ImGuiPopupFlags is guaranteed to hold mouse button index in the lower bits. -- Popups: Added ImGuiPopupFlags_NoOpenOverExistingPopup for OpenPopup*/BeginPopupContext* functions - to first test for the presence of another popup at the same level. -- Popups: Added ImGuiPopupFlags_NoOpenOverItems for BeginPopupContextWindow() - similar to testing - for !IsAnyItemHovered() prior to doing an OpenPopup(). -- Popups: Added ImGuiPopupFlags_AnyPopupId and ImGuiPopupFlags_AnyPopupLevel flags for IsPopupOpen(), - allowing to check if any popup is open at the current level, if a given popup is open at any popup - level, if any popup is open at all. -- Popups: Fix an edge case where programmatically closing a popup while clicking on its empty space - would attempt to focus it and close other popups. (#2880) -- Popups: Fix BeginPopupContextVoid() when clicking over the area made unavailable by a modal. (#1636) -- Popups: Clarified some of the comments and function prototypes. -- Modals: BeginPopupModal() doesn't set the ImGuiWindowFlags_NoSavedSettings flag anymore, and will - not always be auto-centered. Note that modals are more similar to regular windows than they are to - popups, so api and behavior may evolve further toward embracing this. (#915, #3091) - Enforce centering using e.g. SetNextWindowPos(io.DisplaySize * 0.5f, ImGuiCond_Appearing, ImVec2(0.5f,0.5f)). -- Metrics: Added a "Settings" section with some details about persistent ini settings. -- Nav, Menus: Fix vertical wrap-around in menus or popups created with multiple appending calls to - BeginMenu()/EndMenu() or BeginPopup(0/EndPopup(). (#3223, #1207) [@rokups] -- Drag and Drop: Fixed unintended fallback "..." tooltip display during drag operation when - drag source uses _SourceNoPreviewTooltip flags. (#3160) [@rokups] -- Columns: Lower overhead on column switches and switching to background channel. - Benefits Columns but was primarily made with Tables in mind! -- Fonts: Fix GetGlyphRangesKorean() end-range to end at 0xD7A3 (instead of 0xD79D). (#348, #3217) [@marukrap] -- ImDrawList: Fixed an issue where draw command merging or primitive unreserve while crossing the - VtxOffset boundary would lead to draw commands with wrong VtxOffset. (#3129, #3163, #3232, #2591) - [@thedmd, @Shironekoben, @sergeyn, @ocornut] -- ImDrawList, ImDrawListSplitter, Columns: Fixed an issue where changing channels with different - TextureId, VtxOffset would incorrectly apply new settings to draw channels. (#3129, #3163) - [@ocornut, @thedmd, @Shironekoben] -- ImDrawList, ImDrawListSplitter, Columns: Fixed an issue where starting a split when current - VtxOffset was not zero would lead to draw commands with wrong VtxOffset. (#2591) -- ImDrawList, ImDrawListSplitter, Columns: Fixed an issue where starting a split right after - a callback draw command would incorrectly override the callback draw command. -- Misc, Freetype: Fix for rare case where FT_Get_Char_Index() succeeds but FT_Load_Glyph() fails. -- Docs: Improved and moved font documentation to docs/FONTS.md so it can be readable on the web. - Updated various links/wiki accordingly. Added FAQ entry about DPI. (#2861) [@ButternCream, @ocornut] -- CI: Added CI test to verify we're never accidentally dragging libstdc++ (on some compiler setups, - static constructors for non-pod data seems to drag in libstdc++ due to thread-safety concerns). - Fixed a static constructor which led to this dependency on some compiler setups. [@rokups] -- Backends: Win32: Support for #define NOGDI, won't try to call GetDeviceCaps(). (#3137, #2327) -- Backends: Win32: Fix _WIN32_WINNT < 0x0600 (MinGW defaults to 0x502 == Windows 2003). (#3183) -- Backends: SDL: Report a zero display-size when window is minimized, consistent with other backends, - making more render/clipping code use an early out path. -- Backends: OpenGL: Fixed handling of GL 4.5+ glClipControl(GL_UPPER_LEFT) by inverting the - projection matrix top and bottom values. (#3143, #3146) [@u3shit] -- Backends: OpenGL: On OSX, if unspecified by app, made default GLSL version 150. (#3199) [@albertvaka] -- Backends: OpenGL: Fixed loader auto-detection to not interfere with ES2/ES3 defines. (#3246) [@funchal] -- Backends: Vulkan: Fixed error in if initial frame has no vertices. (#3177) -- Backends: Vulkan: Fixed edge case where render callbacks wouldn't be called if the ImDrawData - structure didn't have any vertices. (#2697) [@kudaba] -- Backends: OSX: Added workaround to avoid fast mouse clicks. (#3261, #1992, #2525) [@nburrus] -- Examples: GLFW+Vulkan, SDL+Vulkan: Fix for handling of minimized windows. (#3259) -- Examples: Apple: Fixed example_apple_metal and example_apple_opengl2 using imgui_impl_osx.mm - not forwarding right and center mouse clicks. (#3260) [@nburrus] - - ------------------------------------------------------------------------ - VERSION 1.76 (Released 2020-04-12) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.76 - -Other Changes: - -- Drag and Drop, Nav: Disabling navigation arrow keys when drag and drop is active. In the docking - branch pressing arrow keys while dragging a window from a tab could trigger an assert. (#3025) -- BeginMenu: Using same ID multiple times appends content to a menu. (#1207) [@rokups] -- BeginMenu: Fixed a bug where SetNextWindowXXX data before a BeginMenu() would not be cleared - when the menu is not open. (#3030) -- InputText: Fixed password fields displaying ASCII spaces as blanks instead of using the '*' - glyph. (#2149, #515) -- Selectable: Fixed honoring style.SelectableTextAlign with unspecified size. (#2347, #2601) -- Selectable: Allow using ImGuiSelectableFlags_SpanAllColumns in other columns than first. (#125) -- TreeNode: Made clicking on arrow with _OpenOnArrow toggle the open state on the Mouse Down - event rather than the Mouse Down+Up sequence (this is rather standard behavior). -- ColorButton: Added ImGuiColorEditFlags_NoBorder flag to remove the border normally enforced - by default for standalone ColorButton. -- Nav: Fixed interactions with ImGuiListClipper, so e.g. Home/End result would not clip the - landing item on the landing frame. (#787) -- Nav: Fixed currently focused item from ever being clipped by ItemAdd(). (#787) -- Scrolling: Fixed scrolling centering API leading to non-integer scrolling values and initial - cursor position. This would often get fixed after the fix item submission, but using the - ImGuiListClipper as the first thing after Begin() could largely break size calculations. (#3073) -- Added optional support for Unicode plane 1-16 (#2538, #2541, #2815) [@cloudwu, @samhocevar] - - Compile-time enable with '#define IMGUI_USE_WCHAR32' in imconfig.h. - - More onsistent handling of unsupported code points (0xFFFD). - - Surrogate pairs are supported when submitting UTF-16 data via io.AddInputCharacterUTF16(), - allowing for more complete CJK input. - - sizeof(ImWchar) goes from 2 to 4. IM_UNICODE_CODEPOINT_MAX goes from 0xFFFF to 0x10FFFF. - - Various structures such as ImFont, ImFontGlyphRangesBuilder will use more memory, this - is currently not particularly efficient. -- Columns: undid the change in 1.75 were Columns()/BeginColumns() were preemptively limited - to 64 columns with an assert. (#3037, #125) -- Window: Fixed a bug with child window inheriting ItemFlags from their parent when the child - window also manipulate the ItemFlags stack. (#3024) [@Stanbroek] -- Font: Fixed non-ASCII space occasionally creating unnecessary empty looking polygons. -- Misc: Added an explicit compile-time test for non-scoped IM_ASSERT() macros to redirect users - to a solution rather than encourage people to add braces in the codebase. -- Misc: Added additional checks in EndFrame() to verify that io.KeyXXX values have not been - tampered with between NewFrame() and EndFrame(). -- Misc: Made default clipboard handlers for Win32 and OSX use a buffer inside the main context - instead of a static buffer, so it can be freed properly on Shutdown. (#3110) -- Misc, Freetype: Fixed support for IMGUI_STB_RECT_PACK_FILENAME compile time directive - in imgui_freetype.cpp (matching support in the regular code path). (#3062) [@DonKult] -- Metrics: Made Tools section more prominent. Showing wire-frame mesh directly hovering the ImDrawCmd - instead of requiring to open it. Added options to disable bounding box and mesh display. - Added notes on inactive/gc-ed windows. -- Demo: Added black and white and color gradients to Demo>Examples>Custom Rendering. -- CI: Added more tests on the continuous-integration server: extra warnings for Clang/GCC, building - SDL+Metal example, building imgui_freetype.cpp, more compile-time imconfig.h settings: disabling - obsolete functions, enabling 32-bit ImDrawIdx, enabling 32-bit ImWchar, disabling demo. [@rokups] -- Backends: OpenGL3: Fixed version check mistakenly testing for GL 4.0+ instead of 3.2+ to enable - ImGuiBackendFlags_RendererHasVtxOffset, leaving 3.2 contexts without it. (#3119, #2866) [@wolfpld] -- Backends: OpenGL3: Added include support for older glbinding 2.x loader. (#3061) [@DonKult] -- Backends: Win32: Added ImGui_ImplWin32_EnableDpiAwareness(), ImGui_ImplWin32_GetDpiScaleForHwnd(), - ImGui_ImplWin32_GetDpiScaleForMonitor() helpers functions (backported from the docking branch). - Those functions makes it easier for example apps to support hi-dpi features without setting up - a manifest. -- Backends: Win32: Calling AddInputCharacterUTF16() from WM_CHAR message handler in order to support - high-plane surrogate pairs. (#2815) [@cloudwu, @samhocevar] -- Backends: SDL: Added ImGui_ImplSDL2_InitForMetal() for API consistency (even though the function - currently does nothing). -- Backends: SDL: Fixed mapping for ImGuiKey_KeyPadEnter. (#3031) [@Davido71] -- Examples: Win32+DX12: Fixed resizing main window, enabled debug layer. (#3087, #3115) [@sergeyn] -- Examples: SDL+DX11: Fixed resizing main window. (#3057) [@joeslay] -- Examples: Added SDL+Metal example application. (#3017) [@coding-jackalope] - - ------------------------------------------------------------------------ - VERSION 1.75 (Released 2020-02-10) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.75 - -Breaking Changes: - -- Removed redirecting functions/enums names that were marked obsolete in 1.53 (December 2017): - - ShowTestWindow() -> use ShowDemoWindow() - - IsRootWindowFocused() -> use IsWindowFocused(ImGuiFocusedFlags_RootWindow) - - IsRootWindowOrAnyChildFocused() -> use IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows) - - SetNextWindowContentWidth(w) -> use SetNextWindowContentSize(ImVec2(w, 0.0f) - - GetItemsLineHeightWithSpacing() -> use GetFrameHeightWithSpacing() - - ImGuiCol_ChildWindowBg -> use ImGuiCol_ChildBg - - ImGuiStyleVar_ChildWindowRounding -> use ImGuiStyleVar_ChildRounding - - ImGuiTreeNodeFlags_AllowOverlapMode -> use ImGuiTreeNodeFlags_AllowItemOverlap - - IMGUI_DISABLE_TEST_WINDOWS -> use IMGUI_DISABLE_DEMO_WINDOWS - If you were still using the old names, while you are cleaning up, considering enabling - IMGUI_DISABLE_OBSOLETE_FUNCTIONS in imconfig.h even temporarily to have a pass at finding - and removing up old API calls, if any remaining. -- Removed implicit default parameter to IsMouseDragging(int button = 0) to be consistent - with other mouse functions (none of the other functions have it). -- Obsoleted calling ImDrawList::PrimReserve() with a negative count (which was vaguely - documented and rarely if ever used). Instead we added an explicit PrimUnreserve() API - which can be implemented faster. Also clarified pre-existing constraints which weren't - documented (can only unreserve from the last reserve call). If you suspect you ever - used that feature before (very unlikely, but grep for call to PrimReserve in your code), - you can #define IMGUI_DEBUG_PARANOID in imconfig.h to catch existing calls. [@ShironekoBen] -- ImDrawList::AddCircle()/AddCircleFilled() functions don't accept negative radius. -- Limiting Columns()/BeginColumns() api to 64 columns with an assert. While the current code - technically supports it, future code may not so we're putting the restriction ahead. - [Undid that change in 1.76] -- imgui_internal.h: changed ImRect() default constructor initializes all fields to 0.0f instead - of (FLT_MAX,FLT_MAX,-FLT_MAX,-FLT_MAX). If you used ImRect::Add() to create bounding boxes by - adding points into it without explicit initialization, you may need to fix your initial value. - -Other Changes: - -- Inputs: Added ImGuiMouseButton enum for convenience (e.g. ImGuiMouseButton_Right=1). - We forever guarantee that the existing value will not changes so existing code is free to use 0/1/2. -- Nav: Fixed a bug where the initial CTRL-Tab press while in a child window sometimes selected - the current root window instead of always selecting the previous root window. (#787) -- ColorEdit: Fix label alignment when using ImGuiColorEditFlags_NoInputs. (#2955) [@rokups] -- ColorEdit: In HSV display of a RGB stored value, attempt to locally preserve Saturation - when Value==0.0 (similar to changes done in 1.73 for Hue). Removed Hue editing lock since - those improvements in 1.73 makes them unnecessary. (#2722, #2770). [@rokups] -- ColorEdit: "Copy As" context-menu tool shows hex values with a '#' prefix instead of '0x'. -- ColorEdit: "Copy As" content-menu tool shows hex values both with/without alpha when available. -- InputText: Fix corruption or crash when executing undo after clearing input with ESC, as a - byproduct we are allowing to later undo the revert with a CTRL+Z. (#3008). -- InputText: Fix using a combination of _CallbackResize (e.g. for std::string binding), along with the - _EnterReturnsTrue flag along with the rarely used property of using an InputText without persisting - user-side storage. Previously if you had e.g. a local unsaved std::string and reading result back - from the widget, the user string object wouldn't be resized when Enter key was pressed. (#3009) -- MenuBar: Fix minor clipping issue where occasionally a menu text can overlap the right-most border. -- Window: Fix SetNextWindowBgAlpha(1.0f) failing to override alpha component. (#3007) [@Albog] -- Window: When testing for the presence of the ImGuiWindowFlags_NoBringToFrontOnFocus flag we - test both the focused/clicked window (which could be a child window) and the root window. -- ImDrawList: AddCircle(), AddCircleFilled() API can now auto-tessellate when provided a segment - count of zero. Alter tessellation quality with 'style.CircleSegmentMaxError'. [@ShironekoBen] -- ImDrawList: Add AddNgon(), AddNgonFilled() API with a guarantee on the explicit segment count. - In the current branch they are essentially the same as AddCircle(), AddCircleFilled() but as - we will rework the circle rendering functions to use textures and automatic segment count - selection, those new api can fill a gap. [@ShironekoBen] -- Columns: ImDrawList::Channels* functions now work inside columns. Added extra comments to - suggest using user-owned ImDrawListSplitter instead of ImDrawList functions. [@rokups] -- Misc: Added ImGuiMouseCursor_NotAllowed enum so it can be used by more shared widgets. [@rokups] -- Misc: Added IMGUI_DISABLE compile-time definition to make all headers and sources empty. -- Misc: Disable format checks when using stb_printf, to allow using extra formats. - Made IMGUI_USE_STB_SPRINTF a properly documented imconfig.h flag. (#2954) [@loicmolinari] -- Misc: Added misc/single_file/imgui_single_file.h, We use this to validate compiling all *.cpp - files in a same compilation unit. Actual users of that technique (also called "Unity builds") - can generally provide this themselves, so we don't really recommend you use this. [@rokups] -- CI: Added PVS-Studio static analysis on the continuous-integration server. [@rokups] -- Backends: GLFW, SDL, Win32, OSX, Allegro: Added support for ImGuiMouseCursor_NotAllowed. [@rokups] -- Backends: GLFW: Added support for the missing mouse cursors newly added in GLFW 3.4+. [@rokups] -- Backends: SDL: Wayland: use SDL_GetMouseState (because there is no global mouse state available - on Wayland). (#2800, #2802) [@NeroBurner] -- Backends: GLFW, SDL: report Windows key (io.KeySuper) as always released. Neither GLFW nor SDL can - correctly report the key release in every cases (e.g. when using Win+V) causing problems with some - widgets. The next release of GLFW (3.4+) will have a fix for it. However since it is both difficult - and discouraged to make use of this key for Windows application anyway, we just hide it. (#2976) -- Backends: Win32: Added support for #define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD to disable all - XInput using code, and IMGUI_IMPL_WIN32_DISABLE_LINKING_XINPUT to disable linking with XInput, - the later may be problematic if compiling with recent Windows SDK and you want your app to run - on Windows 7. You can instead try linking with Xinput9_1_0.lib instead. (#2716) -- Backends: Glut: Improved FreeGLUT support for MinGW. (#3004) [@podsvirov] -- Backends: Emscripten: Avoid forcefully setting IMGUI_DISABLE_FILE_FUNCTIONS. (#3005) [@podsvirov] -- Examples: OpenGL: Explicitly adding -DIMGUI_IMPL_OPENGL_LOADER_GL3W to Makefile to match linking - settings (otherwise if another loader such as Glew is accessible, the OpenGL3 backend might - automatically use it). (#2919, #2798) -- Examples: OpenGL: Added support for glbinding OpenGL loader. (#2870) [@rokups] -- Examples: Emscripten: Demonstrating embedding fonts in Makefile and code. (#2953) [@Oipo] -- Examples: Metal: Wrapped main loop in @autoreleasepool block to ensure allocations get freed - even if underlying system event loop gets paused due to app nap. (#2910, #2917) [@bear24rw] - - ------------------------------------------------------------------------ - VERSION 1.74 (Released 2019-11-25) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.74 - -Breaking Changes: - -- Removed redirecting functions/enums names that were marked obsolete in 1.52 (October 2017): - - Begin() [old 5 args version] -> use Begin() [3 args], use SetNextWindowSize() SetNextWindowBgAlpha() if needed - - IsRootWindowOrAnyChildHovered() -> use IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows) - - AlignFirstTextHeightToWidgets() -> use AlignTextToFramePadding() - - SetNextWindowPosCenter() -> use SetNextWindowPos() with a pivot of (0.5f, 0.5f) - - ImFont::Glyph -> use ImFontGlyph - If you were still using the old names, read "API Breaking Changes" section of imgui.cpp to find out - the new names or equivalent features, or see how they were implemented until 1.73. -- Inputs: Fixed a miscalculation in the keyboard/mouse "typematic" repeat delay/rate calculation, used - by keys and e.g. repeating mouse buttons as well as the GetKeyPressedAmount() function. - If you were using a non-default value for io.KeyRepeatRate (previous default was 0.250), you can - add +io.KeyRepeatDelay to it to compensate for the fix. - The function was triggering on: 0.0 and (delay+rate*N) where (N>=1). Fixed formula responds to (N>=0). - Effectively it made io.KeyRepeatRate behave like it was set to (io.KeyRepeatRate + io.KeyRepeatDelay). - Fixed the code and altered default io.KeyRepeatRate,Delay from 0.250,0.050 to 0.300,0.050 to compensate. - If you never altered io.KeyRepeatRate nor used GetKeyPressedAmount() this won't affect you. -- Misc: Renamed IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS to IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS. (#1038) -- Misc: Renamed IMGUI_DISABLE_MATH_FUNCTIONS to IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS. -- Fonts: ImFontAtlas::AddCustomRectRegular() now requires an ID larger than 0x110000 (instead of 0x10000) to - conform with supporting Unicode planes 1-16 in a future update. ID below 0x110000 will now assert. -- Backends: DX12: Added extra ID3D12DescriptorHeap parameter to ImGui_ImplDX12_Init() function. - The value is unused in master branch but will be used by the multi-viewport feature. (#2851) [@obfuscate] - -Other Changes: - -- InputText, Nav: Fixed Home/End key broken when activating Keyboard Navigation. (#787) -- InputText: Filter out ASCII 127 (DEL) emitted by low-level OSX layer, as we are using the Key value. (#2578) -- Layout: Fixed a couple of subtle bounding box vertical positioning issues relating to the handling of text - baseline alignment. The issue would generally manifest when laying out multiple items on a same line, - with varying heights and text baseline offsets. - Some specific examples, e.g. a button with regular frame padding followed by another item with a - multi-line label and no frame padding, such as: multi-line text, small button, tree node item, etc. - The second item was correctly offset to match text baseline, and would interact/display correctly, - but it wouldn't push the contents area boundary low enough. -- Scrollbar: Fixed an issue where scrollbars wouldn't display on the frame following a frame where - all child window contents would be culled. -- ColorPicker: Fixed SV triangle gradient to block (broken in 1.73). (#2864, #2711). [@lewa-j] -- TreeNode: Fixed combination of ImGuiTreeNodeFlags_SpanFullWidth and ImGuiTreeNodeFlags_OpenOnArrow - incorrectly locating the arrow hit position to the left of the frame. (#2451, #2438, #1897) -- TreeNode: The collapsing arrow accepts click even if modifier keys are being held, facilitating - interactions with custom multi-selections patterns. (#2886, #1896, #1861) -- TreeNode: Added IsItemToggledOpen() to explicitly query if item was just open/closed, facilitating - interactions with custom multi-selections patterns. (#1896, #1861) -- DragScalar, SliderScalar, InputScalar: Added p_ prefix to parameter that are pointers to the data - to clarify how they are used, and more comments redirecting to the demo code. (#2844) -- Error handling: Assert if user mistakenly calls End() instead of EndChild() on a child window. (#1651) -- Misc: Optimized storage of window settings data (reducing allocation count). -- Misc: Windows: Do not use _wfopen() if IMGUI_DISABLE_WIN32_FUNCTIONS is defined. (#2815) -- Misc: Windows: Disabled win32 function by default when building with UWP. (#2892, #2895) -- Misc: Using static_assert() when using C++11, instead of our own construct (avoid zealous Clang warnings). -- Misc: Added IMGUI_DISABLE_FILE_FUNCTIONS/IMGUI_DISABLE_DEFAULT_FILE_FUNCTION to nullify or disable - default implementation of ImFileXXX functions linking with fopen/fclose/fread/fwrite. (#2734) -- Docs: Improved and moved FAQ to docs/FAQ.md so it can be readable on the web. [@ButternCream, @ocornut] -- Docs: Moved misc/fonts/README.txt to docs/FONTS.txt. -- Docs: Added permanent redirect from https://www.dearimgui.org/faq to FAQ page. -- Demo: Added simple item reordering demo in Widgets -> Drag and Drop section. (#2823, #143) [@rokups] -- Metrics: Show wire-frame mesh and approximate surface area when hovering ImDrawCmd. [@ShironekoBen] -- Metrics: Expose basic details of each window key/value state storage. -- Examples: DX12: Using IDXGIDebug1::ReportLiveObjects() when DX12_ENABLE_DEBUG_LAYER is enabled. -- Examples: Emscripten: Removed BINARYEN_TRAP_MODE=clamp from Makefile which was removed in Emscripten 1.39.0 - but required prior to 1.39.0, making life easier for absolutely no-one. (#2877, #2878) [@podsvirov] -- Backends: OpenGL2: Explicitly backup, setup and restore GL_TEXTURE_ENV to increase compatibility with - legacy OpenGL applications. (#3000) -- Backends: OpenGL3: Fix building with pre-3.2 GL loaders which do not expose glDrawElementsBaseVertex(), - using runtime GL version to decide if we set ImGuiBackendFlags_RendererHasVtxOffset. (#2866, #2852) [@dpilawa] -- Backends: OSX: Fix using Backspace key. (#2578, #2817, #2818) [@DiligentGraphics] -- Backends: GLFW: Previously installed user callbacks are now restored on shutdown. (#2836) [@malte-v] -- CI: Set up a bunch of continuous-integration tests using GitHub Actions. We now compile many of the example - applications on Windows, Linux, MacOS, iOS, Emscripten. Removed Travis integration. (#2865) [@rokups] - - ------------------------------------------------------------------------ - VERSION 1.73 (Released 2019-09-24) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.73 - -Other Changes: - -- Nav, Scrolling: Added support for Home/End key. (#787) -- ColorEdit: Disable Hue edit when Saturation==0 instead of letting Hue values jump around. -- ColorEdit, ColorPicker: In HSV display of a RGB stored value, attempt to locally preserve Hue - when Saturation==0, which reduces accidentally lossy interactions. (#2722, #2770) [@rokups] -- ColorPicker: Made rendering aware of global style alpha of the picker can be faded out. (#2711) - Note that some elements won't accurately fade down with the same intensity, and the color wheel - when enabled will have small overlap glitches with (style.Alpha < 1.0). -- TabBar: Fixed single-tab not shrinking their width down. -- TabBar: Fixed clicking on a tab larger than tab-bar width creating a bouncing feedback loop. -- TabBar: Feed desired width (sum of unclipped tabs width) into layout system to allow for auto-resize. (#2768) - (before 1.71 tab bars fed the sum of current width which created feedback loops in certain situations). -- TabBar: Improved shrinking for large number of tabs to avoid leaving extraneous space on the right side. - Individuals tabs are given integer-rounded width and remainder is spread between tabs left-to-right. -- Columns, Separator: Fixed a bug where non-visible separators within columns would alter the next row position - differently than visible ones. -- SliderScalar: Improved assert when using U32 or U64 types with a large v_max value. (#2765) [@loicmouton] -- DragInt, DragFloat, DragScalar: Using (v_min > v_max) allows locking any edits to the value. -- DragScalar: Fixed dragging of unsigned values on ARM cpu (float to uint cast is undefined). (#2780) [@dBagrat] -- TreeNode: Added ImGuiTreeNodeFlags_SpanAvailWidth flag. (#2451, #2438, #1897) [@Melix19, @PathogenDavid] - This extends the hit-box to the right-most edge, even if the node is not framed. - (Note: this is not the default in order to allow adding other items on the same line. In the future we will - aim toward refactoring the hit-system to be front-to-back, allowing more natural overlapping of items, - and then we will be able to make this the default.) -- TreeNode: Added ImGuiTreeNodeFlags_SpanFullWidth flag. This extends the hit-box to both the left-most and - right-most edge of the working area, bypassing indentation. -- CollapsingHeader: Added support for ImGuiTreeNodeFlags_Bullet and ImGuiTreeNodeFlags_Leaf on framed nodes, - mostly for consistency. (#2159, #2160) [@goran-w] -- Selectable: Added ImGuiSelectableFlags_AllowItemOverlap flag in public api (was previously internal only). -- Style: Allow style.WindowMenuButtonPosition to be set to ImGuiDir_None to hide the collapse button. (#2634, #2639) -- Font: Better ellipsis ("...") drawing implementation. Instead of drawing three pixel-ey dots (which was glaringly - unfitting with many types of fonts) we first attempt to find a standard ellipsis glyphs within the loaded set. - Otherwise we render ellipsis using '.' from the font from where we trim excessive spacing to make it as narrow - as possible. (#2775) [@rokups] -- ImDrawList: Clarified the name of many parameters so reading the code is a little easier. (#2740) -- ImDrawListSplitter: Fixed merging channels if the last submitted draw command used a different texture. (#2506) -- Using offsetof() when available in C++11. Avoids Clang sanitizer complaining about old-style macros. (#94) -- ImVector: Added find(), find_erase(), find_erase_unsorted() helpers. -- Added a mechanism to compact/free the larger allocations of unused windows (buffers are compacted when - a window is unused for 60 seconds, as per io.ConfigWindowsMemoryCompactTimer = 60.0f). Note that memory - usage has never been reported as a problem, so this is merely a touch of overzealous luxury. (#2636) -- Documentation: Various tweaks and improvements to the README page. [@ker0chan] -- Backends: OpenGL3: Tweaked initialization code allow application calling ImGui_ImplOpenGL3_CreateFontsTexture() - before ImGui_ImplOpenGL3_NewFrame(), which sometimes can be convenient. -- Backends: OpenGL3: Attempt to automatically detect default GL loader by using __has_include. (#2798) [@o-micron] -- Backends: DX11: Fixed GSGetShader() call not passing an initialized instance count, which would - generally make the DX11 debug layer complain (bug added in 1.72). -- Backends: Vulkan: Added support for specifying multisample count. Set 'ImGui_ImplVulkan_InitInfo::MSAASamples' to - one of the VkSampleCountFlagBits values to use, default is non-multisampled as before. (#2705, #2706) [@vilya] -- Examples: OSX: Fix example_apple_opengl2/main.mm not forwarding mouse clicks and drags correctly. (#1961, #2710) - [@intonarumori, @ElectricMagic] -- Misc: Updated stb_rect_pack.h from 0.99 to 1.00 (fixes by @rygorous: off-by-1 bug in best-fit heuristic, - fix handling of rectangles too large to fit inside texture). (#2762) [@tido64] - - ------------------------------------------------------------------------ - VERSION 1.72b (Released 2019-07-31) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.72b - -Other Changes: - -- Nav, Scrolling: Fixed programmatic scroll leading to a slightly incorrect scroll offset when - the window has decorations or a menu-bar (broken in 1.71). This was mostly noticeable when - a keyboard/gamepad movement led to scrolling the view, or using e.g. SetScrollHereY() function. -- Nav: Made hovering non-MenuItem Selectable not re-assign the source item for keyboard navigation. -- Nav: Fixed an issue with NavFlattened window flag (beta) where widgets not entirely fitting - in child window (often selectables because of their protruding sides) would be not considered - as entry points to to navigate toward the child window. (#787) - - ------------------------------------------------------------------------ - VERSION 1.72 (Released 2019-07-27) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.72 - -Breaking Changes: - -- Removed redirecting functions/enums names that were marked obsolete in 1.51 (June 2017): - - ImGuiCol_Column*, ImGuiSetCond_* enums. - - IsItemHoveredRect(), IsPosHoveringAnyWindow(), IsMouseHoveringAnyWindow(), IsMouseHoveringWindow() functions. - - IMGUI_ONCE_UPON_A_FRAME macro. - If you were still using the old names, read "API Breaking Changes" section of imgui.cpp to find out - the new names or equivalent features. -- Renamed ImFontAtlas::CustomRect to ImFontAtlasCustomRect. Kept redirection typedef (will obsolete). -- Removed TreeAdvanceToLabelPos() which is rarely used and only does SetCursorPosX(GetCursorPosX() + GetTreeNodeToLabelSpacing()). - Kept redirection function (will obsolete). (#581, #324) - -Other Changes: - -- Scrolling: Made mouse-wheel scrolling lock the underlying window until the mouse is moved again or - until a short delay expires (~2 seconds). This allow uninterrupted scroll even if child windows are - passing under the mouse cursor. (#2604) -- Scrolling: Made it possible for mouse wheel and navigation-triggered scrolling to override a call to - SetScrollX()/SetScrollY(), making it possible to use a simpler stateless pattern for auto-scrolling: - // (Submit items..) - if (ImGui::GetScrollY() >= ImGui::GetScrollMaxY()) // If scrolling at the already at the bottom.. - ImGui::SetScrollHereY(1.0f); // ..make last item fully visible -- Scrolling: Added SetScrollHereX(), SetScrollFromPosX() for completeness. (#1580) [@kevreco] -- Scrolling: Mouse wheel scrolling while hovering a child window is automatically forwarded to parent window - if ScrollMax is zero on the scrolling axis. - Also still the case if ImGuiWindowFlags_NoScrollWithMouse is set (not new), but previously the forwarding - would be disabled if ImGuiWindowFlags_NoScrollbar was set on the child window, which is not the case - any more. Forwarding can still be disabled by setting ImGuiWindowFlags_NoInputs. (amend #1502, #1380). -- Window: Fixed InnerClipRect right-most coordinates using wrong padding setting (introduced in 1.71). -- Window: Fixed old SetWindowFontScale() api value from not being inherited by child window. Added - comments about the right way to scale your UI (load a font at the right side, rebuild atlas, scale style). -- Scrollbar: Avoid overlapping the opposite side when window (often a child window) is forcibly too small. -- Combo: Hide arrow when there's not enough space even for the square button. -- InputText: Testing for newly added ImGuiKey_KeyPadEnter key. (#2677, #2005) [@amc522] -- TabBar: Fixed unfocused tab bar separator color (was using ImGuiCol_Tab, should use ImGuiCol_TabUnfocusedActive). -- Columns: Fixed a regression from 1.71 where the right-side of the contents rectangle within each column - would wrongly use a WindowPadding.x instead of ItemSpacing.x like it always did. (#125, #2666) -- Columns: Made the right-most edge reaches up to the clipping rectangle (removing half of WindowPadding.x - worth of asymmetrical/extraneous padding, note that there's another half that conservatively has to offset - the right-most column, otherwise it's clipping width won't match the other columns). (#125, #2666) -- Columns: Improved honoring alignment with various values of ItemSpacing.x and WindowPadding.x. (#125, #2666) -- Columns: Made GetColumnOffset() and GetColumnWidth() behave when there's no column set, consistently with - other column functions. (#2683) -- InputTextMultiline: Fixed vertical scrolling tracking glitch. -- Word-wrapping: Fixed overzealous word-wrapping when glyph edge lands exactly on the limit. Because - of this, auto-fitting exactly unwrapped text would make it wrap. (fixes initial 1.15 commit, 78645a7d). -- Style: Attenuated default opacity of ImGuiCol_Separator in Classic and Light styles. -- Style: Added style.ColorButtonPosition (left/right, defaults to ImGuiDir_Right) to move the color button - of ColorEdit3/ColorEdit4 functions to either side of the inputs. -- IO: Added ImGuiKey_KeyPadEnter and support in various backends (previously backends would need to - specifically redirect key-pad keys to their regular counterpart). This is a temporary attenuating measure - until we actually refactor and add whole sets of keys into the ImGuiKey enum. (#2677, #2005) [@amc522] -- Misc: Made Button(), ColorButton() not trigger an "edited" event leading to IsItemDeactivatedAfterEdit() - returning true. This also effectively make ColorEdit4() not incorrect trigger IsItemDeactivatedAfterEdit() - when clicking the color button to open the picker popup. (#1875) -- Misc: Added IMGUI_DISABLE_METRICS_WINDOW imconfig.h setting to explicitly compile out ShowMetricsWindow(). -- Debug, Metrics: Added "Tools->Item Picker" tool which allow clicking on a widget to break in the debugger - within the item code. The tool calls IM_DEBUG_BREAK() which can be redefined in imconfig.h if needed. -- ImDrawList: Fixed CloneOutput() helper crashing. (#1860) [@gviot] -- ImDrawList::ChannelsSplit(), ImDrawListSplitter: Fixed an issue with merging draw commands between - channel 0 and 1. (#2624) -- ImDrawListSplitter: Fixed memory leak when using low-level split api (was not affecting ImDrawList api, - also this type was added in 1.71 and not advertised as a public-facing feature). -- Fonts: binary_to_compressed_c.cpp: Display an error message if failing to open/read the input font file. -- Demo: Log, Console: Using a simpler stateless pattern for auto-scrolling. -- Demo: Widgets: Showing how to use the format parameter of Slider/Drag functions to display the name - of an enum value instead of the underlying integer value. -- Demo: Renamed the "Help" menu to "Tools" (more accurate). -- Backends: DX10/DX11: Backup, clear and restore Geometry Shader is any is bound when calling renderer. -- Backends: DX11: Clear Hull Shader, Domain Shader, Compute Shader before rendering. Not backing/restoring them. -- Backends: OSX: Disabled default native Mac clipboard copy/paste implementation in core library (added in 1.71), - because it needs application to be linked with '-framework ApplicationServices'. It can be explicitly - enabled back by using '#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS' in imconfig.h. Re-added - equivalent using NSPasteboard api in the imgui_impl_osx.mm experimental backend. (#2546) -- Backends: SDL2: Added ImGui_ImplSDL2_InitForD3D() function to make D3D support more visible. - (#2482, #2632) [@josiahmanson] -- Examples: Added SDL2+DirectX11 example application. (#2632, #2612, #2482) [@vincenthamm] - - ------------------------------------------------------------------------ - VERSION 1.71 (Released 2019-06-12) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.71 - -Breaking Changes: - -- IO: changed AddInputCharacter(unsigned short c) signature to AddInputCharacter(unsigned int c). -- Renamed SetNextTreeNodeOpen() to SetNextItemOpen(). Kept inline redirection function (will obsolete). -- Window: rendering of child windows outer decorations (e.g. bg color, border, scrollbars) is now - performed as part of their parent window, avoiding the creation of an extraneous draw commands. - If you have overlapping child windows with decorations, and relied on their relative z-order to be - mapped to submission their order, this will affect your rendering. The optimization is disabled - if the parent window has no visual output because it appears to be the most common situation leading - to the creation of overlapping child windows. Please reach out if you are affected by this change! - -Other Changes: - -- Window: clarified behavior of SetNextWindowContentSize(). Content size is defined as the size available - after removal of WindowPadding on each sides. So SetNextWindowContentSize(ImVec2(100,100)) + auto-resize - will always allow submitting a 100x100 item without creating a scrollbar, regarding of WindowPadding. - The exact meaning of ContentSize for decorated windows was previously ill-defined. -- Window: Fixed auto-resize with AlwaysVerticalScrollbar or AlwaysHorizontalScrollbar flags. -- Window: Fixed one case where auto-resize by double-clicking the resize grip would make either scrollbar - appear for a single frame after the resize. -- Separator: Revert 1.70 "Declare its thickness (1.0f) to the layout" change. It's not incorrect - but it breaks existing some layout patterns. Will return back to it when we expose Separator flags. -- Fixed InputScalar, InputScalarN, SliderScalarN, DragScalarN with non-visible label from inserting - style.ItemInnerSpacing.x worth of trailing spacing. -- Fixed InputFloatX, SliderFloatX, DragFloatX functions erroneously reporting IsItemEdited() multiple - times when the text input doesn't match the formatted output value (e.g. input "1" shows "1.000"). - It wasn't much of a problem because we typically use the return value instead of IsItemEdited() here. -- Fixed uses of IsItemDeactivated(), IsItemDeactivatedAfterEdit() on multi-components widgets and - after EndGroup(). (#2550, #1875) -- Fixed crash when appending with BeginMainMenuBar() more than once and no other window are showing. (#2567) -- ColorEdit: Fixed the color picker popup only displaying inputs as HSV instead of showing multiple - options. (#2587, broken in 1.69 by #2384). -- CollapsingHeader: Better clipping when a close button is enabled and it overlaps the label. (#600) -- Scrollbar: Minor bounding box adjustment to cope with various border size. -- Scrollbar, Style: Changed default style.ScrollbarSize from 16 to 14. -- Combo: Fixed rounding not applying with the ImGuiComboFlags_NoArrowButton flag. (#2607) [@DucaRii] -- Nav: Fixed gamepad/keyboard moving of window affecting contents size incorrectly, sometimes leading - to scrollbars appearing during the movement. -- Nav: Fixed rare crash when e.g. releasing Alt-key while focusing a window with a menu at the same - frame as clearing the focus. This was in most noticeable in backends such as Glfw and SDL which - emits key release events when focusing another viewport, leading to Alt+clicking on void on another - viewport triggering the issue. (#2609) -- TreeNode, CollapsingHeader: Fixed highlight frame not covering horizontal area fully when using - horizontal scrolling. (#2211, #2579) -- TabBar: Fixed BeginTabBar() within a window with horizontal scrolling from creating a feedback - loop with the horizontal contents size. -- Columns: Fixed Columns() within a window with horizontal scrolling from not covering the full - horizontal area (previously only worked with an explicit contents size). (#125) -- Columns: Fixed Separator from creating an extraneous draw command. (#125) -- Columns: Fixed Selectable with SpanAllColumns flag from creating an extraneous draw command. (#125) -- Style: Added style.WindowMenuButtonPosition (left/right, defaults to ImGuiDir_Left) to move the - collapsing/docking button to the other side of the title bar. -- Style: Made window close button cross slightly smaller. -- Log/Capture: Fixed BeginTabItem() label not being included in a text log/capture. -- ImDrawList: Added ImDrawCmd::VtxOffset value to support large meshes (64k+ vertices) using 16-bit indices. - The renderer backend needs to set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset' to enable - this, and honor the ImDrawCmd::VtxOffset field. Otherwise the value will always be zero. (#2591) - This has the advantage of preserving smaller index buffers and allowing to execute on hardware that do not - support 32-bit indices. Most examples backends have been modified to support the VtxOffset field. -- ImDrawList: Added ImDrawCmd::IdxOffset value, equivalent to summing element count for each draw command. - This is provided for convenience and consistency with VtxOffset. (#2591) -- ImDrawCallback: Allow to override the signature of ImDrawCallback by #define-ing it. This is meant to - facilitate custom rendering backends passing local render-specific data to the draw callback. -- ImFontAtlas: FreeType: Added RasterizerFlags::Monochrome flag to disable font anti-aliasing. Combine - with RasterizerFlags::MonoHinting for best results. (#2545) [@HolyBlackCat] -- ImFontGlyphRangesBuilder: Fixed unnecessarily over-sized buffer, which incidentally was also not - fully cleared. Fixed edge-case overflow when adding character 0xFFFF. (#2568). [@NIKE3500] -- Demo: Added full "Dear ImGui" prefix to the title of "Dear ImGui Demo" and "Dear ImGui Metrics" windows. -- Backends: Add native Mac clipboard copy/paste default implementation in core library to match what we are - dealing with Win32, and to facilitate integration in custom engines. (#2546) [@andrewwillmott] -- Backends: OSX: imgui_impl_osx: Added mouse cursor support. (#2585, #1873) [@actboy168] -- Examples/Backends: DirectX9/10/11/12, Metal, Vulkan, OpenGL3 (Desktop GL only): Added support for large meshes - (64k+ vertices) with 16-bit indices, enable 'ImGuiBackendFlags_RendererHasVtxOffset' in those backends. (#2591) -- Examples/Backends: Don't filter characters under 0x10000 before calling io.AddInputCharacter(), - the filtering is done in io.AddInputCharacter() itself. This is in prevision for fuller Unicode - support. (#2538, #2541) - - ------------------------------------------------------------------------ - VERSION 1.70 (Released 2019-05-06) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.70 - -Breaking Changes: - -- ImDrawList: Improved algorithm for mitre joints on thick lines, preserving correct thickness - up to 90 degrees angles (e.g. rectangles). If you have custom rendering using thick lines, - they will appear a little thicker now. (#2518) [@rmitton] -- Obsoleted GetContentRegionAvailWidth(), use GetContentRegionAvail().x instead. - Kept inline redirection function. -- Examples: Vulkan: Added MinImageCount/ImageCount fields in ImGui_ImplVulkan_InitInfo, required - during initialization to specify the number of in-flight image requested by swap chains. - (was previously a hard #define IMGUI_VK_QUEUED_FRAMES 2). (#2071, #1677) [@nathanvoglsam] -- Examples: Vulkan: Tidying up the demo/internals helpers (most engine/app should not rely - on them but it is possible you have!). - -Other Changes: - -- ImDrawList: Added ImDrawCallback_ResetRenderState, a special ImDrawList::AddCallback() value - to request the renderer backend to reset its render state. (#2037, #1639, #2452) - Examples: Added support for ImDrawCallback_ResetRenderState in all renderer backends. Each - renderer code setting up initial render state has been moved to a function so it could be - called at the start of rendering and when a ResetRenderState is requested. [@ocornut, @bear24rw] -- InputText: Fixed selection background rendering one frame after the cursor movement when - first transitioning from no-selection to has-selection. (Bug in 1.69) (#2436) [@Nazg-Gul] -- InputText: Work-around for buggy standard libraries where isprint('\t') returns true. (#2467, #1336) -- InputText: Fixed ImGuiInputTextFlags_AllowTabInput leading to two tabs characters being inserted - if the backend provided both Key and Character input. (#2467, #1336) -- Layout: Added SetNextItemWidth() helper to avoid using PushItemWidth/PopItemWidth() for single items. - Note that SetNextItemWidth() currently only affect the same subset of items as PushItemWidth(), - generally referred to as the large framed+labeled items. Because the new SetNextItemWidth() - function is explicit we may later extend its effect to more items. -- Layout: Fixed PushItemWidth(-width) for right-side alignment laying out some items (button, listbox, etc.) - with negative sizes if the 'width' argument was smaller than the available width at the time of item - submission. -- Window: Fixed window with the AlwaysAutoResize flag unnecessarily extending their hovering boundaries - by a few pixels (this is used to facilitate resizing from borders when available for a given window). - One of the noticeable minor side effect was that navigating menus would have had a tendency to disable - highlight from parent menu items earlier than necessary while approaching the child menu. -- Window: Close button is horizontally aligned with style.FramePadding.x. -- Window: Fixed contents region being off by WindowBorderSize amount on the right when scrollbar is active. -- Window: Fixed SetNextWindowSizeConstraints() with non-rounded positions making windows drift. (#2067, #2530) -- Popups: Closing a popup restores the focused/nav window in place at the time of the popup opening, - instead of restoring the window that was in the window stack at the time of the OpenPopup call. (#2517) - Among other things, this allows opening a popup while no window are focused, and pressing Escape to - clear the focus again. -- Popups: Fixed right-click from closing all popups instead of aiming at the hovered popup level - (regression in 1.67). -- Selectable: With ImGuiSelectableFlags_AllowDoubleClick doesn't return true on the mouse button release - following the double-click. Only first mouse release + second mouse down (double-click) returns true. - Likewise for internal ButtonBehavior() with both _PressedOnClickRelease | _PressedOnDoubleClick. (#2503) -- GetMouseDragDelta(): also returns the delta on the mouse button released frame. (#2419) -- GetMouseDragDelta(): verify that mouse positions are valid otherwise returns zero. -- Inputs: Also add support for horizontal scroll with Shift+Mouse Wheel. (#2424, #1463) [@LucaRood] -- PlotLines, PlotHistogram: Ignore NaN values when calculating min/max bounds. (#2485) -- Columns: Fixed boundary of clipping being off by 1 pixel within the left column. (#125) -- Separator: Declare its thickness (1.0f) to the layout, making items around separator more symmetrical. -- Combo, Slider, Scrollbar: Improve rendering in situation when there's only a few pixels available (<3 pixels). -- Nav: Fixed Drag/Slider functions going into text input mode when keyboard CTRL is held while pressing NavActivate. -- Drag and Drop: Fixed drag source with ImGuiDragDropFlags_SourceAllowNullID and null ID from receiving click - regardless of being covered by another window (it didn't honor correct hovering rules). (#2521) -- ImDrawList: Improved algorithm for mitre joints on thick lines, preserving correct thickness up to 90 degrees - angles, also faster to output. (#2518) [@rmitton] -- Misc: Added IM_MALLOC/IM_FREE macros mimicking IM_NEW/IM_DELETE so user doesn't need to revert - to using the ImGui::MemAlloc()/MemFree() calls directly. -- Misc: Made IMGUI_CHECKVERSION() macro also check for matching size of ImDrawIdx. -- Metrics: Added "Show windows rectangles" tool to visualize the different rectangles. -- Demo: Improved trees in columns demo. -- Examples: OpenGL: Added a test GL call + comments in ImGui_ImplOpenGL3_Init() to detect uninitialized - GL function loaders early, and help users understand what they are missing. (#2421) -- Examples: SDL: Added support for SDL_GameController gamepads (enable with ImGuiConfigFlags_NavEnableGamepad). (#2509) [@DJLink] -- Examples: Emscripten: Added Emscripten+SDL+GLES2 example. (#2494, #2492, #2351, #336) [@nicolasnoble, @redblobgames] -- Examples: Metal: Added Glfw+Metal example. (#2527) [@bear24rw] -- Examples: OpenGL3: Minor tweaks + not calling glBindBuffer more than necessary in the render loop. -- Examples: Vulkan: Fixed in-flight buffers issues when using multi-viewports. (#2461, #2348, #2378, #2097) -- Examples: Vulkan: Added missing support for 32-bit indices (#define ImDrawIdx unsigned int). -- Examples: Vulkan: Avoid passing negative coordinates to vkCmdSetScissor, which debug validation layers do not like. -- Examples: Vulkan: Added ImGui_ImplVulkan_SetMinImageCount() to change min image count at runtime. (#2071) [@nathanvoglsam] -- Examples: DirectX9: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). (#2454) -- Examples: DirectX10/11/12, Allegro, Marmalade: Render functions early out when display size is zero (minimized). (#2496) -- Examples: GLUT: Fixed existing FreeGLUT example to work with regular GLUT. (#2465) [@andrewwillmott] -- Examples: GLUT: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h. (#2465) [@andrewwillmott] -- Examples: GLUT: Made io.DeltaTime always > 0. (#2430) -- Examples: Visual Studio: Updated default platform toolset+sdk in vcproj files from v100+sdk7 (vs2010) - to v110+sdk8 (vs2012). This is mostly so we can remove reliance on DXSDK_DIR for the DX10/DX11 example, - which if existing and when switching to recent SDK ends up conflicting and creating warnings. - - ------------------------------------------------------------------------ - VERSION 1.69 (Released 2019-03-13) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.69 - -Breaking Changes: - -- Renamed ColorEdit/ColorPicker's ImGuiColorEditFlags_RGB/_HSV/_HEX flags to respectively - ImGuiColorEditFlags_DisplayRGB/_DisplayHSV/_DisplayHex. This is because the addition of - new flag ImGuiColorEditFlags_InputHSV makes the earlier one ambiguous. - Kept redirection enum values (will obsolete). (#2384) [@haldean] -- Renamed GetOverlayDrawList() to GetForegroundDrawList(). Kept redirection function (will obsolete). (#2391) - -Other Changes: - -- Added GetBackgroundDrawList() helper to quickly get access to a ImDrawList that will be rendered - behind every other windows. (#2391, #545) -- DragScalar, InputScalar, SliderScalar: Added support for u8/s8/u16/s16 data types (ImGuiDataType_S8, etc.) - We are reusing function instances of larger types to reduce code size. (#643, #320, #708, #1011) -- Added InputTextWithHint() to display a description/hint in the text box when no text - has been entered. (#2400) [@Organic-Code, @ocornut] -- Nav: Fixed a tap on AltGR (e.g. German keyboard) from navigating to the menu layer. -- Nav: Fixed Ctrl+Tab keeping active InputText() of a previous window active after the switch. (#2380) -- Fixed IsItemDeactivated()/IsItemDeactivatedAfterEdit() from not correctly returning true - when tabbing out of a focusable widget (Input/Slider/Drag) in most situations. (#2215, #1875) -- InputInt, InputFloat, InputScalar: Fix to keep the label of the +/- buttons centered when - style.FramePadding.x is abnormally larger than style.FramePadding.y. Since the buttons are - meant to be square (to align with e.g. color button) we always use FramePadding.y. (#2367) -- InputInt, InputScalar: +/- buttons now respects the natural type limits instead of - overflowing or underflowing the value. -- InputText: Fixed an edge case crash that would happen if another widget sharing the same ID - is being swapped with an InputText that has yet to be activated. -- InputText: Fixed various display corruption related to swapping the underlying buffer while - a input widget is active (both for writable and read-only paths). Often they would manifest - when manipulating the scrollbar of a multi-line input text. -- ColorEdit, ColorPicker, ColorButton: Added ImGuiColorEditFlags_InputHSV to manipulate color - values encoded as HSV (in order to avoid HSV<>RGB round trips and associated singularities). - (#2383, #2384) [@haldean] -- ColorPicker: Fixed a bug/assertion when displaying a color picker in a collapsed window - while dragging its title bar. (#2389) -- ColorEdit: Fixed tooltip not honoring the ImGuiColorEditFlags_NoAlpha contract of never - reading the 4th float in the array (value was read and discarded). (#2384) [@haldean] -- MenuItem, Selectable: Fixed disabled widget interfering with navigation (fix c2db7f63 in 1.67). -- TabBar: Fixed a crash when using many BeginTabBar() recursively (didn't affect docking). (#2371) -- TabBar: Added extra mis-usage error recovery. Past the assert, common mis-usage don't lead to - hard crashes any more, facilitating integration with scripting languages. (#1651) -- TabBar: Fixed ImGuiTabItemFlags_SetSelected being ignored if the tab is not visible (with - scrolling policy enabled) or if is currently appearing. -- TabBar: Fixed Tab tooltip code making drag and drop tooltip disappear during the frame where - the drag payload activate a tab. -- TabBar: Reworked scrolling policy (when ImGuiTabBarFlags_FittingPolicyScroll is set) to - teleport the view when aiming at a tab far away the visible section, and otherwise accelerate - the scrolling speed to cap the scrolling time to 0.3 seconds. -- Text: Fixed large Text/TextUnformatted calls not feeding their size into layout when starting - below the lower point of the current clipping rectangle. This bug has been there since v1.0! - It was hardly noticeable but would affect the scrolling range, which in turn would affect - some scrolling request functions when called during the appearing frame of a window. -- Plot: Fixed divide-by-zero in PlotLines() when passing a count of 1. (#2387) [@Lectem] -- Log/Capture: Fixed LogXXX functions emitting extraneous leading carriage return. -- Log/Capture: Fixed an issue when empty string on a new line would not emit a carriage return. -- Log/Capture: Fixed LogXXX functions 'auto_open_depth' parameter being treated as an absolute - tree depth instead of a relative one. -- Log/Capture: Fixed CollapsingHeader trailing ascii representation being "#" instead of "##". -- ImFont: Added GetGlyphRangesVietnamese() helper. (#2403) -- Misc: Asserting in NewFrame() if style.WindowMinSize is zero or smaller than (1.0f,1.0f). -- Demo: Using GetBackgroundDrawList() and GetForegroundDrawList() in "Custom Rendering" demo. -- Demo: InputText: Demonstrating use of ImGuiInputTextFlags_CallbackResize. (#2006, #1443, #1008). -- Examples: GLFW, SDL: Preserve DisplayFramebufferScale when main viewport is minimized. - (This is particularly useful for the viewport branch because we are not supporting per-viewport - frame-buffer scale. It fixes windows not refreshing when main viewport is minimized.) (#2416) -- Examples: OpenGL: Fix to be able to run on ES 2.0 / WebGL 1.0. [@rmitton, @gabrielcuvillier] -- Examples: OpenGL: Fix for OSX not supporting OpenGL 4.5, we don't try to read GL_CLIP_ORIGIN - even if the OpenGL headers/loader happens to define the value. (#2366, #2186) -- Examples: Allegro: Added support for touch events (emulating mouse). (#2219) [@dos1] -- Examples: DirectX9: Minor changes to match the other DirectX examples more closely. (#2394) - - ------------------------------------------------------------------------ - VERSION 1.68 (Released 2019-02-19) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.68 - -Breaking Changes: - -- Removed io.DisplayVisibleMin/DisplayVisibleMax (which were marked obsolete and removed from viewport/docking branch already). -- Made it illegal/assert when io.DisplayTime == 0.0f (with an exception for the first frame). - If for some reason your time step calculation gives you a zero value, replace it with a arbitrarily small value! - -Other Changes: - -- Added .editorconfig file for text editors to standardize using spaces. (#2038) [@kudaba] -- ImDrawData: Added FramebufferScale field (currently a copy of the value from io.DisplayFramebufferScale). - This is to allow render functions being written without pulling any data from ImGuiIO, allowing incoming - multi-viewport feature to behave on Retina display and with multiple displays. - If you are not using a custom backend, please update your render function code ahead of time, - and use draw_data->FramebufferScale instead of io.DisplayFramebufferScale. (#2306, #1676) -- Added IsItemActivated() as an extension to the IsItemDeactivated/IsItemDeactivatedAfterEdit functions - which are useful to implement variety of undo patterns. (#820, #956, #1875) -- InputText: Fixed a bug where ESCAPE would not restore the initial value in all situations. (#2321) [@relick] -- InputText: Fixed a bug where ESCAPE would be first captured by the Keyboard Navigation code. (#2321, #787) -- InputText: Fixed redo buffer exhaustion handling (rare) which could corrupt the undo character buffer. (#2333) - The way the redo/undo buffers work would have made it generally unnoticeable to the user. -- Fixed range-version of PushID() and GetID() not honoring the ### operator to restart from the seed value. -- Fixed CloseCurrentPopup() on a child-menu of a modal incorrectly closing the modal. (#2308) -- Tabs: Added ImGuiTabBarFlags_TabListPopupButton flag to show a popup button on manual tab bars. (#261, #351) -- Tabs: Removed ImGuiTabBarFlags_NoTabListPopupButton which was available in 1.67 but actually had zero use. -- Tabs: Fixed a minor clipping glitch when changing style's FramePadding from frame to frame. -- Tabs: Fixed border (when enabled) so it is aligned correctly mid-pixel and appears as bright as other borders. -- Style, Selectable: Added ImGuiStyle::SelectableTextAlign and ImGuiStyleVar_SelectableTextAlign. (#2347) [@haldean] -- Menus: Tweaked horizontal overlap between parent and child menu (to help convey relative depth) - from using style.ItemSpacing.x to style.ItemInnerSpacing.x, the later being expected to be smaller. (#1086) -- RadioButton: Fixed label horizontal alignment to precisely match Checkbox(). -- Window: When resizing from an edge, the border is more visible and better follow the rounded corners. -- Window: Fixed initial width of collapsed windows not taking account of contents width (broken in 1.67). (#2336, #176) -- Scrollbar: Fade out and disable interaction when too small, in order to facilitate using the resize grab on very - small window, as well as reducing visual noise/overlap. -- ListBox: Better optimized when clipped / non-visible. -- InputTextMultiline: Better optimized when clipped / non-visible. -- Font: Fixed high-level ImGui::CalcTextSize() used by most widgets from erroneously subtracting 1.0f*scale to - calculated text width. Among noticeable side-effects, it would make sequences of repeated Text/SameLine calls - not align the same as a single call, and create mismatch between high-level size calculation and those performed - with the lower-level ImDrawList api. (#792) [@SlNPacifist] -- Font: Fixed building atlas when specifying duplicate/overlapping ranges within a same font. (#2353, #2233) -- ImDrawList: Fixed AddCircle(), AddCircleFilled() angle step being off, which was visible when drawing a "circle" - with a small number of segments (e.g. an hexagon). (#2287) [@baktery] -- ImGuiTextBuffer: Added append() function (unformatted). -- ImFontAtlas: Added 0x2000-0x206F general punctuation range to default ChineseFull/ChineseSimplifiedCommon ranges. (#2093) -- ImFontAtlas: FreeType: Added support for imgui allocators + custom FreeType only SetAllocatorFunctions. (#2285) [@Vuhdo] -- ImFontAtlas: FreeType: Fixed using imgui_freetype.cpp in unity builds. (#2302) -- Demo: Fixed "Log" demo not initializing properly, leading to the first line not showing before a Clear. (#2318) [@bluescan] -- Demo: Added "Auto-scroll" option in Log/Console demos. (#2300) [@nicolasnoble, @ocornut] -- Examples: Metal, OpenGL2, OpenGL3, Vulkan: Fixed offsetting of clipping rectangle with ImDrawData::DisplayPos != (0,0) - when the display frame-buffer scale scale is not (1,1). While this doesn't make a difference when using master branch, - this is effectively fixing support for multi-viewport with Mac Retina Displays on those examples. (#2306) [@rasky, @ocornut] - Also using ImDrawData::FramebufferScale instead of io.DisplayFramebufferScale. -- Examples: Clarified the use the ImDrawData::DisplayPos to offset clipping rectangles. -- Examples: Win32: Using GetForegroundWindow()+IsChild() instead of GetActiveWindow() to be compatible with windows created - in a different thread or parent. (#1951, #2087, #2156, #2232) [many people] -- Examples: SDL: Using the SDL_WINDOW_ALLOW_HIGHDPI flag. (#2306, #1676) [@rasky] -- Examples: Win32: Added support for XInput gamepads (if ImGuiConfigFlags_NavEnableGamepad is enabled). -- Examples: Win32: Added support for mouse buttons 4 and 5 via WM_XBUTTON* messages. (#2264) -- Examples: DirectX9: Explicitly disable fog (D3DRS_FOGENABLE) before drawing in case user state has it set. (#2288, #2230) -- Examples: OpenGL2: Added #define GL_SILENCE_DEPRECATION to cope with newer XCode warnings. -- Examples: OpenGL3: Using GLSL 4.10 shaders for any GLSL version over 410 (e.g. 430, 450). (#2329) [@BrutPitt] - - ------------------------------------------------------------------------ - VERSION 1.67 (Released 2019-01-14) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.67 - -Breaking Changes: - -- Made it illegal to call Begin("") with an empty string. This somehow half-worked before but had various undesirable - side-effect because the window would have ID zero. In particular it is causing problems in viewport/docking branches. -- Renamed io.ConfigResizeWindowsFromEdges to io.ConfigWindowsResizeFromEdges and removed its [Beta] mark. - The addition of new configuration options in the Docking branch is pushing for a little reorganization of those names. -- Renamed ImFontAtlas::GlyphRangesBuilder to ImFontGlyphRangesBuilder. Kept redirection typedef (will obsolete). - -Other Changes: -- Added BETA api for Tab Bar/Tabs widgets: (#261, #351) - - Added BeginTabBar(), EndTabBar(), BeginTabItem(), EndTabItem(), SetTabItemClosed() API. - - Added ImGuiTabBarFlags flags for BeginTabBar(). - - Added ImGuiTabItemFlags flags for BeginTabItem(). - - Style: Added ImGuiCol_Tab, ImGuiCol_TabHovered, ImGuiCol_TabActive, ImGuiCol_TabUnfocused, ImGuiCol_TabUnfocusedActive colors. - - Demo: Added Layout->Tabs demo code. - - Demo: Added "Documents" example app showcasing possible use for tabs. - This feature was merged from the Docking branch in order to allow the use of regular tabs in your code. - (It does not provide the docking/splitting/merging of windows available in the Docking branch) -- Added ImGuiWindowFlags_UnsavedDocument window flag to append '*' to title without altering the ID, as a convenience - to avoid using the ### operator. In the Docking branch this also has an effect on tab closing behavior. -- Window, Focus, Popup: Fixed an issue where closing a popup by clicking another window with the _NoMove flag would refocus - the parent window of the popup instead of the newly clicked window. -- Window: Contents size is preserved while a window collapsed. Fix auto-resizing window losing their size for one frame when uncollapsed. -- Window: Contents size is preserved while a window contents is hidden (unless it is hidden for resizing purpose). -- Window: Resizing windows from edge is now enabled by default (io.ConfigWindowsResizeFromEdges=true). Note that - it only works _if_ the backend sets ImGuiBackendFlags_HasMouseCursors, which the standard backends do. -- Window: Added io.ConfigWindowsMoveFromTitleBarOnly option. This is ignored by window with no title bars (often popups). - This affects clamping window within the visible area: with this option enabled title bars need to be visible. (#899) -- Window: Fixed using SetNextWindowPos() on a child window (which wasn't really documented) position the cursor as expected - in the parent window, so there is no mismatch between the layout in parent and the position of the child window. -- InputFloat: When using ImGuiInputTextFlags_ReadOnly the step buttons are disabled. (#2257) -- DragFloat: Fixed broken mouse direction change with power!=1.0. (#2174, #2206) [@Joshhua5] -- Nav: Fixed an keyboard issue where holding Activate/Space for longer than two frames on a button would unnecessary - keep the focus on the parent window, which could steal it from newly appearing windows. (#787) -- Nav: Fixed animated window titles from being updated when displayed in the CTRL+Tab list. (#787) -- Error recovery: Extraneous/undesired calls to End() are now being caught by an assert in the End() function closer - to the user call site (instead of being reported in EndFrame). Past the assert, they don't lead to crashes any more. (#1651) - Missing calls to End(), past the assert, should not lead to crashes or to the fallback Debug window appearing on screen. - Those changes makes it easier to integrate dear imgui with a scripting language allowing, given asserts are redirected - into e.g. an error log and stopping the script execution. -- ImFontAtlas: Stb and FreeType: Atlas width is now properly based on total surface rather than glyph count (unless overridden with TexDesiredWidth). -- ImFontAtlas: Stb and FreeType: Fixed atlas builder so missing glyphs won't influence the atlas texture width. (#2233) -- ImFontAtlas: Stb and FreeType: Fixed atlas builder so duplicate glyphs (when merging fonts) won't be included in the rasterized atlas. -- ImFontAtlas: FreeType: Fixed abnormally high atlas height. -- ImFontAtlas: FreeType: Fixed support for any values of TexGlyphPadding (not just only 1). -- ImDrawList: Optimized some of the functions for performance of debug builds where non-inline function call cost are non-negligible. - (Our test UI scene on VS2015 Debug Win64 with /RTC1 went ~5.9 ms -> ~4.9 ms. In Release same scene stays at ~0.3 ms.) -- IO: Added BackendPlatformUserData, BackendRendererUserData, BackendLanguageUserData void* for storage use by backends. -- IO: Renamed InputCharacters[], marked internal as was always intended. Please don't access directly, and use AddInputCharacter() instead! -- IO: AddInputCharacter() goes into a queue which can receive as many characters as needed during the frame. This is useful - for automation to not have an upper limit on typing speed. Will later transition key/mouse to use the event queue later. -- Style: Tweaked default value of style.DisplayWindowPadding from (20,20) to (19,19) so the default style as a value - which is the same as the title bar height. -- Demo: "Simple Layout" and "Style Editor" are now using tabs. -- Demo: Added a few more things under "Child windows" (changing ImGuiCol_ChildBg, positioning child, using IsItemHovered after a child). -- Examples: DirectX10/11/12: Made imgui_impl_dx10/dx11/dx12.cpp link d3dcompiler.lib from the .cpp file to ease integration. -- Examples: Allegro 5: Properly destroy globals on shutdown to allow for restart. (#2262) [@DomRe] - - ------------------------------------------------------------------------ - VERSION 1.66b (Released 2018-12-01) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.66b - -Other Changes: - -- Fixed a text rendering/clipping bug introduced in 1.66 (on 2018-10-12, commit ede3a3b9) that affect single ImDrawList::AddText() - calls with single strings larger than 10k. Text/TextUnformatted() calls were not affected, but e.g. InputText() was. [@pdoane] -- When the focused window become inactive don't restore focus to a window with the ImGuiWindowFlags_NoInputs flag. (#2213) [@zzzyap] -- Separator: Fixed Separator() outputting an extraneous empty line when captured into clipboard/text/file. -- Demo: Added ShowAboutWindow() call, previously was only accessible from the demo window. -- Demo: ShowAboutWindow() now display various Build/Config Information (compiler, os, etc.) that can easily be copied into bug reports. -- Fixed build issue with osxcross and macOS. (#2218) [@dos1] -- Examples: Setting up 'io.BackendPlatformName'/'io.BackendRendererName' fields to the current backend can be displayed in the About window. -- Examples: SDL: changed the signature of ImGui_ImplSDL2_ProcessEvent() to use a const SDL_Event*. (#2187) - - ------------------------------------------------------------------------ - VERSION 1.66 (Released 2018-11-22) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.66 - -Breaking Changes: - -- Renamed SetScrollHere() to SetScrollHereY(). Kept redirection function (will obsolete). -- Renamed misc/stl/imgui_stl.* to misc/cpp/imgui_stdlib.* in prevision for other C++ helper files. (#2035, #2096) - -Other Changes: - -- Fixed calling SetNextWindowSize()/SetWindowSize() with non-integer values leading to - accidental alteration of window position. We now round the provided size. (#2067) -- Fixed calling DestroyContext() always saving .ini data with the current context instead - of the supplied context pointer. (#2066) -- Nav, Focus: Fixed ImGuiWindowFlags_NoBringToFrontOnFocus windows not being restoring focus - properly after the main menu bar or last focused window is deactivated. -- Nav: Fixed an assert in certain circumstance (mostly when using popups) when mouse positions stop being valid. (#2168) -- Nav: Fixed explicit directional input not re-highlighting current nav item if there is a single item in the window - and highlight has been previously disabled by the mouse. (#787) -- DragFloat: Fixed a situation where dragging with value rounding enabled or with a power curve - erroneously wrapped the value to one of the min/max edge. (#2024, #708, #320, #2075). -- DragFloat: Disabled using power curve when one edge is FLT_MAX (broken in 1.61). (#2024) -- DragFloat: Disabled setting a default drag speed when one edge is FLT_MAX. (#2024) -- SliderAngle: Added optional format argument to alter precision or localize the string. (#2150) [@podsvirov] -- Window: Resizing from edges (with io.ConfigResizeWindowsFromEdges Beta flag) extends the hit region - of root floating windows outside the window, making it easier to resize windows. Resize grips are also - extended accordingly so there are no discontinuity when hovering between borders and corners. (#1495, #822) -- Window: Added ImGuiWindowFlags_NoBackground flag to avoid rendering window background. This is mostly to allow - the creation of new flag combinations, as we could already use SetNextWindowBgAlpha(0.0f). (#1660) [@biojppm, @ocornut] -- Window: Added ImGuiWindowFlags_NoDecoration helper flag which is essentially NoTitleBar+NoResize+NoScrollbar+NoCollapse. -- Window: Added ImGuiWindowFlags_NoMouseInputs which is basically the old ImGuiWindowFlags_NoInputs (essentially - we have renamed ImGuiWindowFlags_NoInputs to ImGuiWindowFlags_NoMouseInputs). Made the new ImGuiWindowFlags_NoInputs - encompass both NoMouseInputs+NoNav, which is consistent with its description. (#1660, #787) -- Window, Inputs: Fixed resizing from edges when io.MousePos is not pixel-rounded by rounding mouse position input. (#2110) -- BeginChild(): Fixed BeginChild(const char*, ...) variation erroneously not applying the ID stack - to the provided string to uniquely identify the child window. This was undoing an intentional change - introduced in 1.50 and broken in 1.60. (#1698, #894, #713). -- TextUnformatted(): Fixed a case where large-text path would read bytes past the text_end marker depending - on the position of new lines in the buffer (it wasn't affecting the output but still not the right thing to do!) -- ListBox(): Fixed frame sizing when items_count==1 unnecessarily showing a scrollbar. (#2173) [@luk1337, @ocornut] -- ListBox(): Tweaked frame sizing so list boxes will look more consistent when FramePadding is far from ItemSpacing. -- RenderText(): Some optimization for very large text buffers, useful for non-optimized builds. -- BeginMenu(): Fixed menu popup horizontal offset being off the item in the menu bar when WindowPadding=0.0f. -- ArrowButton(): Fixed arrow shape being horizontally misaligned by (FramePadding.y-FramePadding.x) if they are different. -- Demo: Split the contents of ShowDemoWindow() into smaller functions as it appears to speed up link time with VS. (#2152) -- Drag and Drop: Added GetDragDropPayload() to peek directly into the payload (if any) from anywhere. (#143) -- ImGuiTextBuffer: Avoid heap allocation when empty. -- ImDrawList: Fixed AddConvexPolyFilled() undefined behavior when passing points_count smaller than 3, - in particular, points_count==0 could lead to a memory stomp if the draw list was previously empty. -- Examples: DirectX10, DirectX11: Removed seemingly unnecessary calls to invalidate and recreate device objects - in the WM_SIZE handler. (#2088) [@ice1000] -- Examples: GLFW: User previously installed GLFW callbacks are now saved and chain-called by the default callbacks. (#1759) -- Examples: OpenGL3: Added support for GL 4.5's glClipControl(GL_UPPER_LEFT). (#2186) -- Examples: OpenGL3+GLFW: Fixed error condition when using the GLAD loader. (#2157) [@blackball] -- Examples: OpenGL3+GLFW/SDL: Made main.cpp compile with IMGUI_IMPL_OPENGL_LOADER_CUSTOM (may be missing init). (#2178) [@doug-moen] -- Examples: SDL2+Vulkan: Fixed application shutdown which could deadlock on Linux + Xorg. (#2181) [@eRabbit0] - - ------------------------------------------------------------------------ - VERSION 1.65 (Released 2018-09-06) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.65 - -Breaking Changes: - -- Renamed stb_truetype.h to imstb_truetype.h, stb_textedit.h to imstb_textedit.h, and - stb_rect_pack.h to imstb_rectpack.h. If you were conveniently using the imgui copy of those - STB headers in your project, you will have to update your include paths. (#1718, #2036) - The reason for this change is to avoid conflicts for projects that may also be importing - their own copy of the STB libraries. Note that imgui's copy of stb_textedit.h is modified. -- Renamed io.ConfigCursorBlink to io.ConfigInputTextCursorBlink. (#1427) - -Other Changes: - -- This is a minor release following the 1.64 refactor, with a little more shuffling of code. -- Clarified and improved the source code sectioning in all files (easier to search or browse sections). -- Nav: Removed the [Beta] tag from various descriptions of the gamepad/keyboard navigation system. - Although it is not perfect and will keep being improved, it is fairly functional and used by many. (#787) -- Fixed a build issue with non-Cygwin GCC under Windows. -- Demo: Added a "Configuration" block to make io.ConfigFlags/io.BackendFlags more prominent. -- Examples: OpenGL3+SDL2: Fixed error condition when using the GLAD loader. (#2059, #2002) [@jiri] - - ------------------------------------------------------------------------ - VERSION 1.64 (Released 2018-08-31) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.64 - -Changes: - -- Moved README, CHANGELOG and TODO files to the docs/ folder. - If you are updating dear imgui by copying files, take the chance to delete the old files. -- Added imgui_widgets.cpp file, extracted and moved widgets code out of imgui.cpp into imgui_widgets.cpp. - Re-ordered some of the code remaining in imgui.cpp. - NONE OF THE FUNCTIONS HAVE CHANGED. THE CODE IS SEMANTICALLY 100% IDENTICAL, BUT _EVERY_ FUNCTIONS HAS BEEN MOVED. - Because of this, any local modifications to imgui.cpp will likely conflict when you update. - If you have any modifications to imgui.cpp, it is suggested that you first update to 1.63, then - isolate your patches. You can peak at imgui_widgets.cpp from 1.64 to get a sense of what is included in it, - then separate your changes into several patches that can more easily be applied to 1.64 on a per-file basis. - What I found worked nicely for me, was to open the diff of the old patches in an interactive merge/diff tool, - search for the corresponding function in the new code and apply the chunks manually. -- As a reminder, if you have any change to imgui.cpp it is a good habit to discuss them on the github, - so a solution applicable on the Master branch can be found. If your company has changes that you cannot - disclose you may also contact me privately. - - ------------------------------------------------------------------------ - VERSION 1.63 (Released 2018-08-29) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.63 - -Breaking Changes: - -- Style: Renamed ImGuiCol_ModalWindowDarkening to ImGuiCol_ModalWindowDimBg for consistency with other features. - Kept redirection enum (will obsolete). -- Changed ImGui::GetTime() return value from float to double to avoid accumulating floating point imprecision over time. -- Removed per-window ImGuiWindowFlags_ResizeFromAnySide Beta flag in favor `io.ConfigResizeWindowsFromEdges=true` to - enable the feature globally. (#1495) - The feature is not currently enabled by default because it is not satisfying enough, but will eventually be. -- InputText: Renamed ImGuiTextEditCallback to ImGuiInputTextCallback, ImGuiTextEditCallbackData to ImGuiInputTextCallbackData - for consistency. Kept redirection types (will obsolete). -- InputText: Removed ImGuiTextEditCallbackData::ReadOnly because it is a duplication of (::Flags & ImGuiInputTextFlags_ReadOnly). -- Renamed IsItemDeactivatedAfterChange() to IsItemDeactivatedAfterEdit() for consistency with new IsItemEdited() API. - Kept redirection function (will obsolete soonish as IsItemDeactivatedAfterChange() is very recent). -- Renamed io.OptCursorBlink to io.ConfigCursorBlink [-> io.ConfigInputTextCursorBlink in 1.65], io.OptMacOSXBehaviors to - io.ConfigMacOSXBehaviors for consistency. (#1427, #473) -- Removed obsolete redirection functions: CollapsingHeader() variation with 2 bools - marked obsolete in v1.49, May 2016. - -Other Changes: - -- ArrowButton: Fixed to honor PushButtonRepeat() setting (and internals' ImGuiItemFlags_ButtonRepeat). -- ArrowButton: Setup current line text baseline so that ArrowButton() + SameLine() + Text() are aligned properly. -- Nav: Added a CTRL+TAB window list and changed the highlight system accordingly. The change is motivated by upcoming - Docking features. (#787) -- Nav: Made CTRL+TAB skip menus + skip the current navigation window if is has the ImGuiWindow_NoNavFocus set. (#787) - While it was previously possible, you won't be able to CTRL-TAB out and immediately back in a window with the - ImGuiWindow_NoNavFocus flag. -- Window: Allow menu and popups windows from ignoring the style.WindowMinSize values so short menus/popups are not padded. (#1909) -- Window: Added global io.ConfigResizeWindowsFromEdges option to enable resizing windows from their edges and from - the lower-left corner. (#1495) -- Window: Collapse button shows hovering highlight + clicking and dragging on it allows to drag the window as well. -- Added IsItemEdited() to query if the last item modified its value (or was pressed). This is equivalent to the bool - returned by most widgets. - It is useful in some situation e.g. using InputText() with ImGuiInputTextFlags_EnterReturnsTrue. (#2034) -- InputText: Added support for buffer size/capacity changes via the ImGuiInputTextFlags_CallbackResize flag. (#2006, #1443, #1008). -- InputText: Fixed not tracking the cursor horizontally when modifying the text buffer through a callback. -- InputText: Fixed minor off-by-one issue when submitting a buffer size smaller than the initial zero-terminated buffer contents. -- InputText: Fixed a few pathological crash cases on single-line InputText widget with multiple millions characters worth of contents. - Because the current text drawing function reserve for a worst-case amount of vertices and how we handle horizontal clipping, - we currently just avoid displaying those single-line widgets when they are over a threshold of 2 millions characters, - until a better solution is found. -- Drag and Drop: Fixed an incorrect assert when dropping a source that is submitted after the target (bug introduced with 1.62 changes - related to the addition of IsItemDeactivated()). (#1875, #143) -- Drag and Drop: Fixed ImGuiDragDropFlags_SourceNoDisableHover to affect hovering state prior to calling IsItemHovered() + fixed description. (#143) -- Drag and Drop: Calling BeginTooltip() between a BeginDragSource()/EndDragSource() or BeginDropTarget()/EndDropTarget() uses adjusted tooltip - settings matching the one created when calling BeginDragSource() without the ImGuiDragDropFlags_SourceNoPreviewTooltip flag. (#143) -- Drag and Drop: Payload stays available and under the mouse if the source stops being submitted, however the tooltip is replaced by "...". (#1725) -- Drag and Drop: Added ImGuiDragDropFlags_SourceAutoExpirePayload flag to force payload to expire if the source stops being submitted. (#1725, #143). -- IsItemHovered(): Added ImGuiHoveredFlags_AllowWhenDisabled flag to query hovered status on disabled items. (#1940, #211) -- Selectable: Added ImGuiSelectableFlags_Disabled flag in the public API. (#211) -- ColorEdit4: Fixed a bug when text input or drag and drop leading to unsaturated HSV values would erroneously alter the resulting color. (#2050) -- Misc: Added optional misc/stl/imgui_stl.h wrapper to use with STL types (e.g. InputText with std::string). (#2006, #1443, #1008) - [*EDIT* renamed to misc/std/imgui_stdlib.h in 1.66] -- Misc: Added IMGUI_VERSION_NUM for easy compile-time testing. (#2025) -- Misc: Added ImGuiMouseCursor_Hand cursor enum + corresponding software cursor. (#1913, 1914) [@aiekick, @ocornut] -- Misc: Tweaked software mouse cursor offset to match the offset of the corresponding Windows 10 cursors. -- Made assertion more clear when trying to call Begin() outside of the NewFrame()..EndFrame() scope. (#1987) -- Fixed assertion when transitioning from an active ID to another within a group, affecting ColorPicker (broken in 1.62). (#2023, #820, #956, #1875). -- Fixed PushID() from keeping alive the new ID Stack top value (if a previously active widget shared the ID it would be erroneously kept alive). -- Fixed horizontal mouse wheel not forwarding the request to the parent window if ImGuiWindowFlags_NoScrollWithMouse is set. (#1463, #1380, #1502) -- Fixed a include build issue for Cygwin in non-POSIX (Win32) mode. (#1917, #1319, #276) -- ImDrawList: Improved handling for worst-case vertices reservation policy when large amount of text (e.g. 1+ million character strings) - are being submitted in a single call. It would typically have crashed InputTextMultiline(). (#200) -- OS/Windows: Fixed missing ImmReleaseContext() call in the default Win32 IME handler. (#1932) [@vby] -- Metrics: Changed io.MetricsActiveWindows to reflect the number of active windows (!= from visible windows), which is useful - for lazy/idle render mechanisms as new windows are typically not visible for one frame. -- Metrics: Added io.MetricsRenderWindow to reflect the number of visible windows. -- Metrics: Added io.MetricsActiveAllocations, moving away from the cross-context global counters than we previously used. (#1565, #1599, #586) -- Demo: Added basic Drag and Drop demo. (#143) -- Demo: Modified the Console example to use InsertChars() in the input text callback instead of poking directly into the buffer. - Although this won't make a difference in the example itself, using InsertChars() will honor the resizing callback properly. (#2006, #1443, #1008). -- Demo: Clarified the use of IsItemHovered()/IsItemActive() right after being in the "Active, Focused, Hovered & Focused Tests" section. -- Examples: Tweaked the main.cpp of each example. -- Examples: Metal: Added Metal rendering backend. (#1929, #1873) [@warrenm] -- Examples: OSX: Added early raw OSX platform backend. (#1873) [@pagghiu, @itamago, @ocornut] -- Examples: Added mac OSX & iOS + Metal example in example_apple_metal/. (#1929, #1873) [@warrenm] -- Examples: Added mac OSX + OpenGL2 example in example_apple_opengl2/. (#1873) -- Examples: OpenGL3: Added shaders more versions of GLSL. (#1938, #1941, #1900, #1513, #1466, etc.) -- Examples: OpenGL3: Tweaked the imgui_impl_opengl3.cpp to work as-is with Emscripten + WebGL 2.0. (#1941). [@o-micron] -- Examples: OpenGL3: Made the example app default to GL 3.0 + GLSL 130 (instead of GL 3.2 + GLSL 150) unless on Mac. -- Examples: OpenGL3: Added error output when shaders fail to compile/link. -- Examples: OpenGL3: Added support for glew and glad OpenGL loaders out of the box. (#2001, #2002) [@jdumas] -- Examples: OpenGL2: Disabling/restoring GL_LIGHTING and GL_COLOR_MATERIAL to increase compatibility with legacy OpenGL applications. (#1996) -- Examples: DirectX10, DirectX11: Fixed unreleased resources in Init and Shutdown functions. (#1944) -- Examples: DirectX11: Querying for IDXGIFactory instead of IDXGIFactory1 to increase compatibility. (#1989) [@matt77hias] -- Examples: Vulkan: Fixed handling of VkSurfaceCapabilitiesKHR::maxImageCount = 0 case. Tweaked present mode selections. -- Examples: Win32, Glfw, SDL: Added support for the ImGuiMouseCursor_Hand cursor. - - ------------------------------------------------------------------------ - VERSION 1.62 (Released 2018-06-22) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.62 - -Breaking Changes: - -- TreeNodeEx(): The helper ImGuiTreeNodeFlags_CollapsingHeader flag now include ImGuiTreeNodeFlags_NoTreePushOnOpen. - The flag was already set by CollapsingHeader(). - The only difference is if you were using TreeNodeEx() manually with ImGuiTreeNodeFlags_CollapsingHeader and without - ImGuiTreeNodeFlags_NoTreePushOnOpen. In this case you can remove the ImGuiTreeNodeFlags_NoTreePushOnOpen flag from - your call (ImGuiTreeNodeFlags_CollapsingHeader & ~ImGuiTreeNodeFlags_NoTreePushOnOpen). (#1864) - This also apply if you were using internal's TreeNodeBehavior() with the ImGuiTreeNodeFlags_CollapsingHeader flag directly. -- ImFontAtlas: Renamed GetGlyphRangesChinese() to GetGlyphRangesChineseFull() to distinguish new smaller variants and - discourage using the full set. (#1859) - -Other Changes: - -- Examples backends have been refactored to separate the platform code (e.g. Win32, Glfw, SDL2) from the renderer code (e.g. DirectX11, OpenGL3, Vulkan). - The "Platform" backends are in charge of: mouse/keyboard/gamepad inputs, cursor shape, timing, etc. - The "Renderer" backends are in charge of: creating the main font texture, rendering imgui draw data. - before: imgui_impl_dx11.cpp --> after: imgui_impl_win32.cpp + imgui_impl_dx11.cpp - before: imgui_impl_dx12.cpp --> after: imgui_impl_win32.cpp + imgui_impl_dx12.cpp - before: imgui_impl_glfw_gl3.cpp --> after: imgui_impl_glfw.cpp + imgui_impl_opengl2.cpp - before: imgui_impl_glfw_vulkan.cpp --> after: imgui_impl_glfw.cpp + imgui_impl_vulkan.cpp - before: imgui_impl_sdl_gl3.cpp --> after: imgui_impl_sdl2.cpp + imgui_impl_opengl2.cpp - before: imgui_impl_sdl_gl3.cpp --> after: imgui_impl_sdl2.cpp + imgui_impl_opengl3.cpp etc. - - The idea is what we can now easily combine and maintain backends and reduce code redundancy. Individual files are - smaller and more reusable. Integration of imgui into a new/custom engine may also be easier as there is less overlap - between "windowing / inputs" and "rendering" code, so you may study or grab one half of the code and not the other. - - This change was motivated by the fact that adding support for the upcoming multi-viewport feature requires more work - from the Platform and Renderer backends, and the amount of redundancy across files was becoming too difficult to - maintain. If you use default backends, you'll benefit from an easy update path to support multi-viewports later - (for future ImGui 1.7x). - - This is not strictly a breaking change if you keep your old backends, but when you'll want to fully update your backends, - expect to have to reshuffle a few things. - - Each example still has its own main.cpp which you may refer you to understand how to initialize and glue everything together. - - Some frameworks (such as the Allegro, Marmalade) handle both the "platform" and "rendering" part, and your custom engine may as well. - - Read examples/README.txt for details. -- Added IsItemDeactivated() to query if the last item was active previously and isn't anymore. Useful for Undo/Redo patterns. (#820, #956, #1875) -- Added IsItemDeactivatedAfterChange() [*EDIT* renamed to IsItemDeactivatedAfterEdit() in 1.63] if the last item was active previously, - is not anymore, and during its active state modified a value. Note that you may still get false positive (e.g. drag value and while - holding return on the same value). (#820, #956, #1875) -- Nav: Added support for PageUp/PageDown (explorer-style: first aim at bottom/top most item, when scroll a page worth of contents). (#787) -- Nav: To keep the navigated item in view we also attempt to scroll the parent window as well as the current window. (#787) -- ColorEdit3, ColorEdit4, ColorButton: Added ImGuiColorEditFlags_NoDragDrop flag to disable ColorEditX as drag target and ColorButton as drag source. (#1826) -- BeginDragDropSource(): Offset tooltip position so it is off the mouse cursor, but also closer to it than regular tooltips, - and not clamped by viewport. (#1739) -- BeginDragDropTarget(): Added ImGuiDragDropFlags_AcceptNoPreviewTooltip flag to request hiding the drag source tooltip - from the target site. (#143) -- BeginCombo(), BeginMainMenuBar(), BeginChildFrame(): Temporary style modification are restored at the end of BeginXXX - instead of EndXXX, to not affect tooltips and child windows. -- Popup: Improved handling of (erroneously) repeating calls to OpenPopup() to not close the popup's child popups. (#1497, #1533, #1865). -- InputTextMultiline(): Fixed double navigation highlight when scrollbar is active. (#787) -- InputText(): Fixed Undo corruption after pasting large amount of text (Redo will still fail when undo buffers are exhausted, - but text won't be corrupted). -- SliderFloat(): When using keyboard/gamepad and a zero precision format string (e.g. "%.0f"), always step in integer units. (#1866) -- ImFontConfig: Added GlyphMinAdvanceX/GlyphMaxAdvanceX settings useful to make a font appears monospaced, particularly useful - for icon fonts. (#1869) -- ImFontAtlas: Added GetGlyphRangesChineseSimplifiedCommon() helper that returns a list of ~2500 most common Simplified Chinese - characters. (#1859) [@JX-Master, @ocornut] -- Examples: OSX: Added imgui_impl_osx.mm backend to be used along with e.g. imgui_impl_opengl2.cpp. (#281, #1870) [@pagghiu, @itamago, @ocornut] -- Examples: GLFW: Made it possible to Shutdown/Init the backend again (by resetting the time storage properly). (#1827) [@ice1000] -- Examples: Win32: Fixed handling of mouse wheel messages to support sub-unit scrolling messages (typically sent by track-pads). (#1874) [@zx64] -- Examples: SDL+Vulkan: Added SDL+Vulkan example. -- Examples: Allegro5: Added support for ImGuiConfigFlags_NoMouseCursorChange flag. Added clipboard support. -- Examples: Allegro5: Unindexing buffers ourselves as Allegro indexed drawing primitives are buggy in the DirectX9 backend - (will be fixed in Allegro 5.2.5+). -- Examples: DirectX12: Moved the ID3D12GraphicsCommandList* parameter from ImGui_ImplDX12_NewFrame() to ImGui_ImplDX12_RenderDrawData() which makes a lots more sense. (#301) -- Examples: Vulkan: Reordered parameters ImGui_ImplVulkan_RenderDrawData() to be consistent with other backends, - a good occasion since we refactored the code. -- Examples: FreeGLUT: Added FreeGLUT backends. Added FreeGLUT+OpenGL2 example. (#801) -- Examples: The functions in imgui_impl_xxx.cpp are prefixed with IMGUI_IMPL_API (which defaults to IMGUI_API) to facilitate - some uses. (#1888) -- Examples: Fixed backends to use ImGuiMouseCursor_COUNT instead of old name ImGuiMouseCursor_Count_ so they can compile - with IMGUI_DISABLE_OBSOLETE_FUNCTIONS. (#1887) -- Misc: Updated stb_textedit from 1.09 + patches to 1.12 + minor patches. -- Internals: PushItemFlag() flags are inherited by BeginChild(). - - ------------------------------------------------------------------------ - VERSION 1.61 (Released 2018-05-14) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.61 - -Breaking Changes: - -- DragInt(): The default compile-time format string has been changed from "%.0f" to "%d", as we are not using integers internally - any more. If you used DragInt() with custom format strings, make sure you change them to use %d or an integer-compatible format. - To honor backward-compatibility, the DragInt() code will currently parse and modify format strings to replace %*f with %d, - giving time to users to upgrade their code. - If you have IMGUI_DISABLE_OBSOLETE_FUNCTIONS enabled, the code will instead assert! You may run a reg-exp search on your - codebase for e.g. "DragInt.*%f" to you find them. -- InputFloat(): Obsoleted InputFloat() functions taking an optional "int decimal_precision" in favor of an equivalent and more - flexible "const char* format", consistent with other functions. Kept redirection functions (will obsolete). -- Misc: IM_DELETE() helper function added in 1.60 doesn't set the input pointer to NULL, more consistent with standard - expectation and allows passing r-values. - -Other Changes: - -- Added DragScalar, DragScalarN: supports signed/unsigned, 32/64 bits, float/double data types. (#643, #320, #708, #1011) -- Added InputScalar, InputScalarN: supports signed/unsigned, 32/64 bits, float/double data types. (#643, #320, #708, #1011) -- Added SliderScalar, SliderScalarN: supports signed/unsigned, 32/64 bits, float/double data types. (#643, #320, #708, #1011) -- Window: Fixed pop-ups/tooltips/menus not honoring style.DisplaySafeAreaPadding as well as it should have (part of menus - displayed outside the safe area, etc.). -- Window: Fixed windows using the ImGuiWindowFlags_NoSavedSettings flag from not using the same default position as other windows. (#1760) -- Window: Relaxed the internal stack size checker to allow Push/Begin/Pop/.../End patterns to be used with PushStyleColor, PushStyleVar, PushFont without causing a false positive assert. (#1767) -- Window: Fixed the default proportional item width lagging by one frame on resize. -- Columns: Fixed a bug introduced in 1.51 where columns would affect the contents size of their container, often creating - feedback loops when ImGuiWindowFlags_AlwaysAutoResize was used. (#1760) -- Settings: Fixed saving an empty .ini file if CreateContext/DestroyContext are called without a single call to NewFrame(). (#1741) -- Settings: Added LoadIniSettingsFromDisk(), LoadIniSettingsFromMemory(), SaveIniSettingsToDisk(), SaveIniSettingsToMemory() - to manually load/save .ini settings. (#923, #993) -- Settings: Added io.WantSaveIniSettings flag, which is set to notify the application that e.g. SaveIniSettingsToMemory() - should be called. (#923, #993) -- Scrolling: Fixed a case where using SetScrollHere(1.0f) at the bottom of a window on the same frame the window height - has been growing would have the scroll clamped using the previous height. (#1804) -- MenuBar: Made BeginMainMenuBar() honor style.DisplaySafeAreaPadding so the text can be made visible on TV settings that - don't display all pixels. (#1439) [@dougbinks] -- InputText: On Mac OS X, filter out characters when the CMD modifier is held. (#1747) [@sivu] -- InputText: On Mac OS X, support CMD+SHIFT+Z for Redo. CMD+Y is also supported as major apps seems to default to support both. (#1765) [@lfnoise] -- InputText: Fixed returning true when edition is cancelled with ESC and the current buffer matches the initial value. -- InputFloat,InputFloat2,InputFloat3,InputFloat4: Added variations taking a more flexible and consistent optional - "const char* format" parameter instead of "int decimal_precision". This allow using custom formats to display values - in scientific notation, and is generally more consistent with other API. - Obsoleted functions using the optional "int decimal_precision" parameter. (#648, #712) -- DragFloat, DragInt: Cancel mouse tweak when current value is initially past the min/max boundaries and mouse is pushing - in the same direction (keyboard/gamepad version already did this). -- DragFloat, DragInt: Honor natural type limits (e.g. INT_MAX, FLT_MAX) instead of wrapping around. (#708, #320) -- DragFloat, SliderFloat: Fixes to allow input of scientific notation numbers when using CTRL+Click to input the value. (~#648, #1011) -- DragFloat, SliderFloat: Rounding-on-write uses the provided format string instead of parsing the precision from the string, - which allows for finer uses of %e %g etc. (#648, #642) -- DragFloat: Improved computation when using the power curve. Improved lost of input precision with very small steps. - Added an assert than power-curve requires a min/max range. (~#642) -- DragFloat: The 'power' parameter is only honored if the min/max parameter are also setup. -- DragInt, SliderInt: Fixed handling of large integers (we previously passed data around internally as float, which reduced - the range of valid integers). -- ColorEdit: Fixed not being able to pass the ImGuiColorEditFlags_NoAlpha or ImGuiColorEditFlags_HDR flags to SetColorEditOptions(). -- Nav: Fixed hovering a Selectable() with the mouse so that it update the navigation cursor (as it happened in the pre-1.60 navigation branch). (#787) -- Style: Changed default style.DisplaySafeAreaPadding values from (4,4) to (3,3) so it is smaller than FramePadding and has no effect on main menu bar on a computer. (#1439) -- Fonts: When building font atlas, glyphs that are missing in the fonts are not using the glyph slot to render the default glyph. Saves space and allow merging fonts with - overlapping font ranges such as FontAwesome5 which split out the Brands separately from the Solid fonts. (#1703, #1671) -- Misc: Added IMGUI_CHECKVERSION() macro to compare version string and data structure sizes in order to catch issues with mismatching compilation unit settings. (#1695, #1769) -- Misc: Added IMGUI_DISABLE_MATH_FUNCTIONS in imconfig.h to make it easier to redefine wrappers for std/crt math functions. -- Misc: Fix to allow compiling in unity builds where stb_rectpack/stb_truetype may be already included in the same compilation unit. -- Demo: Simple Overlay: Added a context menu item to enable freely moving the window. -- Demo: Added demo for DragScalar(), InputScalar(), SliderScalar(). (#643) -- Examples: Calling IMGUI_CHECKVERSION() in the main.cpp of every example application. -- Examples: Allegro 5: Added support for 32-bit indices setup via defining ImDrawIdx, to avoid an unnecessary conversion (Allegro 5 doesn't support 16-bit indices). -- Examples: Allegro 5: Renamed backend from imgui_impl_a5.cpp to imgui_impl_allegro5.cpp. -- Examples: DirectX 9: Saving/restoring Transform because they don't seem to be included in the StateBlock. Setting shading mode to Gouraud. (#1790, #1687) [@sr-tream] -- Examples: SDL: Fixed clipboard paste memory leak in the SDL backend code. (#1803) [@eliasdaler] -- Various minor fixes, tweaks, refactoring, comments. - - ------------------------------------------------------------------------ - VERSION 1.60 (Released 2018-04-07) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.60 - -The gamepad/keyboard navigation branch (which has been in the work since July 2016) has been merged. -Gamepad/keyboard navigation is still marked as Beta and has to be enabled explicitly. -Various internal refactoring have also been done, as part of the navigation work and as part of the upcoming viewport/docking work. - -Breaking Changes: - -- Obsoleted the io.RenderDrawListsFn callback, you can call your graphics engine render function after ImGui::Render(). - e.g. with example backends, call ImDrawData* draw_data = ImGui::GetDrawData(); ImGui_ImplXXXX_RenderDrawData(draw_data). -- Reorganized context handling to be more explicit: (#1599) - - YOU NOW NEED TO CALL ImGui::CreateContext() AT THE BEGINNING OF YOUR APP, AND CALL ImGui::DestroyContext() AT THE END. - - removed Shutdown() function, as DestroyContext() serve this purpose. If you are using an old backend from the examples/ folder, remove the line that calls Shutdown(). - - you may pass a ImFontAtlas* pointer to CreateContext() to share a font atlas between contexts. Otherwise CreateContext() will create its own font atlas instance. - - removed allocator parameters from CreateContext(), they are now setup with SetAllocatorFunctions(), and shared by all contexts. - - removed the default global context and font atlas instance, which were confusing for users of DLL reloading and users of multiple contexts. -- Renamed ImGuiStyleVar_Count_ to ImGuiStyleVar_COUNT and ImGuiMouseCursor_Count_ to ImGuiMouseCursor_COUNT for consistency with other public enums. -- Fonts: Moved sample TTF files from extra_fonts/ to misc/fonts/. If you loaded files directly from the imgui repo you may need to update your paths. -- Fonts: Changed ImFont::DisplayOffset.y to defaults to 0 instead of +1. Fixed vertical rounding of Ascent/Descent to match TrueType renderer. - If you were adding or subtracting (not assigning) to ImFont::DisplayOffset check if your fonts are correctly aligned vertically. (#1619) -- BeginDragDropSource(): temporarily removed the optional mouse_button=0 parameter because it is not really usable in many situations at the moment. -- Obsoleted IsAnyWindowHovered() in favor of IsWindowHovered(ImGuiHoveredFlags_AnyWindow). Kept redirection function (will obsolete). -- Obsoleted IsAnyWindowFocused() in favor of IsWindowFocused(ImGuiFocusedFlags_AnyWindow). Kept redirection function (will obsolete). -- Renamed io.WantMoveMouse to io.WantSetMousePos for consistency and ease of understanding (was added in 1.52, not used by core, and honored by some backend ahead of merging the Nav branch). -- Removed ImGuiCol_CloseButton, ImGuiCol_CloseButtonActive, ImGuiCol_CloseButtonHovered style colors as the closing cross uses regular button colors now. -- Renamed ImGuiSizeConstraintCallback to ImGuiSizeCallback, ImGuiSizeConstraintCallbackData to ImGuiSizeCallbackData. -- Removed CalcItemRectClosestPoint() which was weird and not really used by anyone except demo code. If you need it should be easy to replicate on your side (you can find the code in 1.53). -- [EDITED] Window: BeginChild() with an explicit name doesn't include the hash within the internal window name. (#1698) - This change was erroneously introduced, undoing the change done for #894, #713, and not documented properly in the original - 1.60 release Changelog. It was fixed on 2018-09-28 (1.66) and I wrote this paragraph the same day. - -Other Changes: - -- Doc: Added a Changelog file in the repository to ease comparing versions (it goes back to dear imgui 1.48), until now it was only on GitHub. -- Navigation: merged in the gamepad/keyboard navigation (about a million changes!). (#787, #323) - The initial focus was to support game controllers, but keyboard is becoming increasingly and decently usable. -- To use Gamepad Navigation: - - Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad to enable. - - Backend: Set io.BackendFlags |= ImGuiBackendFlags_HasGamepad + fill the io.NavInputs[] fields before calling NewFrame(). Read imgui.cpp for more details. - - See https://github.com/ocornut/imgui/issues/1599 for recommended gamepad mapping or download PNG/PSD at http://goo.gl/9LgVZW - - See 'enum ImGuiNavInput_' in imgui.h for a description of inputs. Read imgui.cpp for more details. -- To use Keyboard Navigation: - - Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard to enable. NewFrame() will automatically fill io.NavInputs[] based on your io.KeysDown[] + io.KeyMap[] arrays. - - Basic controls: arrows to navigate, Alt to enter menus, Space to activate item, Enter to edit text, Escape to cancel/close, Ctrl-Tab to focus windows, etc. - - When keyboard navigation is active (io.NavActive + ImGuiConfigFlags_NavEnableKeyboard), the io.WantCaptureKeyboard flag will be set. - For more advanced uses, you may want to read from io.NavActive or io.NavVisible. Read imgui.cpp for more details. -- Navigation: SetItemDefaultFocus() sets the navigation position in addition to scrolling. (#787) -- Navigation: Added IsItemFocused(), added IsAnyItemFocused(). (#787) -- Navigation: Added window flags: ImGuiWindowFlags_NoNav (== ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus). -- Navigation: Style: Added ImGuiCol_NavHighlight, ImGuiCol_NavWindowingHighlight colors. (#787) -- Navigation: TreeNode: Added ImGuiTreeNodeFlags_NavLeftJumpsBackHere flag to allow Nav Left direction to jump back to parent tree node from any of its child. (#1079) -- Navigation: IO: Added io.ConfigFlags (input), io.NavActive (output), io.NavVisible (output). (#787) -- Context: Removed the default global context and font atlas instances, which caused various problems to users of multiple contexts and DLL users. (#1565, #1599) - YOU NOW NEED TO CALL ImGui::CreateContext() AT THE BEGINNING OF YOUR APP, AND CALL ImGui::DestroyContext() AT THE END. Existing apps will assert/crash without it. -- Context: Added SetAllocatorFunctions() to rewire memory allocators (as a replacement to previous parameters to CreateContext()). Allocators are shared by all contexts and imgui helpers. (#1565, #586, #992, #1007, #1558) -- Context: You may pass a ImFontAtlas to CreateContext() to specify a font atlas to share. Shared font atlas are not owned by the context and not destroyed along with it. (#1599) -- Context: Added IMGUI_DISABLE_DEFAULT_ALLOCATORS to disable linking with malloc/free. (#1565, #586, #992, #1007, #1558) -- IO: Added io.ConfigFlags for user application to store settings for imgui and for the backend: - - ImGuiConfigFlags_NavEnableKeyboard: Enable keyboard navigation. - - ImGuiConfigFlags_NavEnableGamepad: Enable gamepad navigation (provided ImGuiBackendFlags_HasGamepad is also set by backend). - - ImGuiConfigFlags_NavEnableSetMousePos: Instruct navigation to move the mouse cursor. May be useful on TV/console systems where moving a virtual mouse is awkward. - - ImGuiConfigFlags_NoMouseCursorChange: Instruct backend to not alter mouse cursor shape and visibility (by default the example backend use mouse cursor API of the platform when available) - - ImGuiConfigFlags_NoMouse: Instruct imgui to clear mouse position/buttons in NewFrame(). This allows ignoring the mouse information passed by the backend. - - ImGuiConfigFlags_IsSRGB, ImGuiConfigFlags_IsTouchScreen: Flags for general application use. -- IO: Added io.BackendFlags for backend to store its capabilities (currently: _HasGamepad, _HasMouseCursors, _HasSetMousePos). This will be used more in the next version. -- IO: Added ImGuiKey_Insert, ImGuiKey_Space keys. Setup in all example backends. (#1541) -- IO: Added Horizontal Mouse Wheel support for horizontal scrolling. (#1463) [@tseeker] -- IO: Added IsAnyMouseDown() helper which is helpful for backends to handle mouse capturing. -- Window: Clicking on a window with the ImGuiWIndowFlags_NoMove flags takes an ActiveId so we can't hover something else when dragging afterwards. (#1381, #1337) -- Window: IsWindowHovered(): Added ImGuiHoveredFlags_AnyWindow, ImGuiFocusedFlags_AnyWindow flags (See Breaking Changes). Added to demo. (#1382) -- Window: Added SetNextWindowBgAlpha() helper. Particularly helpful since the legacy 5-parameters version of Begin() has been marked as obsolete in 1.53. (#1567) -- Window: Fixed SetNextWindowContentSize() with 0.0f on Y axis (or SetNextWindowContentWidth()) overwriting the contents size. Got broken on Dec 10 (1.53). (#1363) -- ArrowButton: Added ArrowButton() given a cardinal direction (e.g. ImGuiDir_Left). -- InputText: Added alternative clipboard shortcuts: Shift+Delete (cut), CTRL+Insert (copy), Shift+Insert (paste). (#1541) -- InputText: Fixed losing Cursor X position when clicking outside on an item that's submitted after the InputText(). It was only noticeable when restoring focus programmatically. (#1418, #1554) -- InputText: Added ImGuiInputTextFlags_CharsScientific flag to also allow 'e'/'E' for input of values using scientific notation. Automatically used by InputFloat. -- Style: Default style is now StyleColorsDark(), instead of the old StyleColorsClassic(). (#707) -- Style: Enable window border by default. (#707) -- Style: Exposed ImGuiStyleVar_WindowTitleAlign, ImGuiStyleVar_ScrollbarSize, ImGuiStyleVar_ScrollbarRounding, ImGuiStyleVar_GrabRounding + added an assert to reduce accidental breakage. (#1181) -- Style: Added style.MouseCursorScale help when using the software mouse cursor facility. (#939). -- Style: Close button nows display a cross before hovering. Fixed cross positioning being a little off. Uses button colors for highlight when hovering. (#707) -- Popup: OpenPopup() Always reopen existing pop-ups. (Removed imgui_internal.h's OpenPopupEx() which was used for this.) (#1497, #1533). -- Popup: BeginPopupContextItem(), BeginPopupContextWindow(), BeginPopupContextVoid(), OpenPopupOnItemClick() all react on mouse release instead of mouse press. (~#439) -- Popup: Better handling of user mistakenly calling OpenPopup() every frame (with reopen_existing option). The error will now be more visible and easier to understand. (#1497) -- Popup: BeginPopup(): Exposed extra_flags parameter that are passed through to Begin(). (#1533) -- Popup: BeginPopupModal: fixed the conditional test for SetNextWindowPos() which was polling the wrong window, which in practice made the test succeed all the time. -- Tooltip: BeginTooltip() sets ImGuiWindowFlags_NoInputs flag. -- Scrollbar: Fixed ScrollbarY enable test after ScrollbarX has been enabled being a little off (small regression from Nov 2017). (#1574) -- Scrollbar: Fixed ScrollbarX enable test subtracting WindowPadding.x (this has been there since the addition of horizontal scroll bar!). -- Columns: Clear offsets data when columns count changed. (#1525) -- Columns: Fixed a memory leak of ImGuiColumnsSet's Columns vector. (#1529) [@unprompted] -- Columns: Fixed resizing a window very small breaking some columns positioning (broken in 1.53). -- Columns: The available column extent takes consideration of the right-most clipped pixel, so the right-most column may look a little wider but will contain the same amount of visible contents. -- MenuBar: Fixed menu bar pushing a clipping rect outside of its allocated bound (usually unnoticeable). -- TreeNode: nodes with the ImGuiTreeNodeFlags_Leaf flag correctly disable highlight when DragDrop is active. (#143, #581) -- Drag and Drop: Increased payload type string to 32 characters instead of 8. (#143) -- Drag and Drop: TreeNode as drop target displays rectangle over full frame. (#1597, #143) -- DragFloat: Fix/workaround for backends which do not preserve a valid mouse position when dragged out of bounds. (#1559) -- InputFloat: Allow inputing value using scientific notation e.g. "1e+10". -- InputDouble: Added InputDouble() function. We use a format string instead of a decimal_precision parameter to also for "%e" and variants. (#1011) -- Slider, Combo: Use ImGuiCol_FrameBgHovered color when hovered. (#1456) [@stfx] -- Combo: BeginCombo(): Added ImGuiComboFlags_NoArrowButton to disable the arrow button and only display the wide value preview box. -- Combo: BeginCombo(): Added ImGuiComboFlags_NoPreview to disable the preview and only display a square arrow button. -- Combo: Arrow button isn't displayed over frame background so its blended color matches other buttons. Left side of the button isn't rounded. -- PlotLines: plot a flat line if scale_min==scale_max. (#1621) -- Fonts: Changed DisplayOffset.y to defaults to 0 instead of +1. Fixed rounding of Ascent/Descent to match TrueType renderer. - If you were adding or subtracting (not assigning) to ImFont::DisplayOffset check if your fonts are correctly aligned vertically. (#1619) -- Fonts: Updated stb_truetype from 1.14 to stb_truetype 1.19. (w/ include fix from some platforms #1622) -- Fonts: Added optional FreeType rasterizer in misc/freetype. Moved from imgui_club repo. (#618) [@Vuhdo, @mikesart, @ocornut] -- Fonts: Moved extra_fonts/ to misc/fonts/. -- ImFontAtlas: Fixed cfg.MergeMode not reusing existing glyphs if available (always overwrote). -- ImFontAtlas: Handle stb_truetype stbtt_InitFont() and stbtt_PackBegin() possible failures more gracefully, GetTexDataAsRGBA32() won't crash during conversion. (#1527) -- ImFontAtlas: Moved mouse cursor data out of ImGuiContext, fix drawing them with multiple contexts. Also remove the last remaining undesirable dependency on ImGui in imgui_draw.cpp. (#939) -- ImFontAtlas: Added ImFontAtlasFlags_NoPowerOfTwoHeight flag to disable padding font height to nearest power of two. (#1613) -- ImFontAtlas: Added ImFontAtlasFlags_NoMouseCursors flag to disable baking software mouse cursors, mostly to save texture memory on very low end hardware. (#1613) -- ImDrawList: Fixed AddRect() with anti-aliasing disabled (lower-right corner pixel was often missing, rounding looks a little better.) (#1646) -- ImDrawList: Added CloneOutput() helper to facilitate the cloning of ImDrawData or ImDrawList for multi-threaded rendering. -- Misc: Functions passed to libc qsort are explicitly marked cdecl to support compiling with vectorcall as the default calling convention. (#1230, #1611) [@RandyGaul] -- Misc: ImVec2: added [] operator. This is becoming desirable for some code working of either axes independently. Better adding it sooner than later. -- Misc: NewFrame(): Added an assert to detect incorrect filling of the io.KeyMap[] array earlier. (#1555) -- Misc: Added IM_OFFSETOF() helper in imgui.h (previously was in imgui_internal.h) -- Misc: Added IM_NEW(), IM_DELETE() helpers in imgui.h (previously were in imgui_internal.h) -- Misc: Added obsolete redirection function GetItemsLineHeightWithSpacing() (which redirects to GetFrameHeightWithSpacing()), as intended and stated in docs of 1.53. -- Misc: Added misc/natvis/imgui.natvis for visual studio debugger users to easily visualize imgui internal types. Added to examples projects. -- Misc: Added IMGUI_USER_CONFIG to define a custom configuration filename. (#255, #1573, #1144, #41) -- Misc: Added IMGUI_STB_TRUETYPE_FILENAME and IMGUI_STB_RECT_PACK_FILENAME compile time directives to use another version of the stb_ files. -- Misc: Updated stb_rect_pack from 0.10 to 0.11 (minor changes). - (Those flags are not used by ImGui itself, they only exists to make it easy for the engine/backend to pass information to the application in a standard manner.) -- Metrics: Added display of Columns state. -- Demo: Improved Selectable() examples. (#1528) -- Demo: Tweaked the Child demos, added a menu bar to the second child to test some navigation functions. -- Demo: Console: Using ImGuiCol_Text to be more friendly to color changes. -- Demo: Using IM_COL32() instead of ImColor() in ImDrawList centric contexts. Trying to phase out use of the ImColor helper whenever possible. -- Examples: Files in examples/ now include their own changelog so it is easier to occasionally update your backends if needed. -- Examples: Using Dark theme by default. (#707). Tweaked demo code. -- Examples: Added support for horizontal mouse wheel for API that allows it. (#1463) [@tseeker] -- Examples: All examples now setup the io.BackendFlags to signify they can honor mouse cursors, gamepad, etc. -- Examples: DirectX10: Fixed erroneous call to io.Fonts->ClearInputData() + ClearTexData() that was left in DX10 example but removed in 1.47 (Nov 2015) in every other backends. (#1733) -- Examples: DirectX12: Added DirectX 12 example. (#301) [@jdm3] -- Examples: OpenGL3+GLFW,SDL: Changed GLSL shader version from 330 to 150. (#1466, #1504) -- Examples: OpenGL3+GLFW,SDL: Added a way to override the GLSL version string in the Init function. (#1466, #1504). -- Examples: OpenGL3+GLFW,SDL: Creating VAO in the render function so it can be more easily used by multiple shared OpenGL contexts. (#1217) -- Examples: OpenGL3+GLFW: Using 3.2 context instead of 3.3. (#1466) -- Examples: OpenGL: Setting up glPixelStorei() explicitly before uploading texture. -- Examples: OpenGL: Calls to glPolygonMode() are casting parameters as GLEnum to not fail with more strict backends. (#1628) [@ilia-glushchenko] -- Examples: Win32 (DirectX9,10,11,12): Added support for mouse cursor shapes. (#1495) -- Examples: Win32 (DirectX9,10,11,12: Support for windows using the CS_DBLCLKS class flag by handling the double-click messages (WM_LBUTTONDBLCLK etc.). (#1538, #754) [@ndandoulakis] -- Examples: Win32 (DirectX9,10,11,12): Made the Win32 proc handlers not assert if there is no active context yet, to be more flexible with creation order. (#1565) -- Examples: GLFW: Added support for mouse cursor shapes (the diagonal resize cursors are unfortunately not supported by GLFW at the moment. (#1495) -- Examples: GLFW: Don't attempt to change the mouse cursor input mode if it is set to GLFW_CURSOR_DISABLED by the application. (#1202) [@PhilCK] -- Examples: SDL: Added support for mouse cursor shapes. (#1626) [@olls] -- Examples: SDL: Using SDL_CaptureMouse() to retrieve coordinates outside of client area when dragging (SDL 2.0.4+ only, otherwise using SDL_WINDOW_INPUT_FOCUS instead of previously SDL_WINDOW_MOUSE_FOCUS). (#1559) -- Examples: SDL: Enabled vsync by default so people don't come at us when the examples are running at 2000 FPS and burning a CPU core. -- Examples: SDL: Using SDL_GetPerformanceCounter() / SDL_GetPerformanceFrequency() to handle frame-rate over 1000 FPS properly. (#996) -- Examples: SDL: Using scan-code exclusively instead of a confusing mixture of scan-codes and key-codes. -- Examples: SDL: Visual Studio: Added .vcxproj file. Using %SDL2_DIR% in the default .vcxproj and build files instead of %SDL_DIR%, the earlier being more standard. -- Examples: Vulkan: Visual Studio: Added .vcxproj file. -- Examples: Apple: Fixed filenames in OSX xcode project. Various other Mac friendly fixes. [@gerryhernandez etc.] -- Examples: Visual Studio: Disabled extraneous function-level check in Release build. -- Various fixes, tweaks, internal refactoring, optimizations, comments. - - ------------------------------------------------------------------------ - VERSION 1.53 (Released 2017-12-25) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.53 - -Breaking Changes: - -- Renamed the emblematic `ShowTestWindow()` function to `ShowDemoWindow()`. Kept redirection function (will obsolete). -- Renamed `GetItemsLineHeightWithSpacing()` to `GetFrameHeightWithSpacing()` for consistency. Kept redirection function (will obsolete). -- Renamed `ImGuiTreeNodeFlags_AllowOverlapMode` flag to `ImGuiTreeNodeFlags_AllowItemOverlap`. Kept redirection enum (will obsolete). -- Obsoleted `IsRootWindowFocused()` in favor of using `IsWindowFocused(ImGuiFocusedFlags_RootWindow)`. Kept redirection function (will obsolete). (#1382) -- Obsoleted `IsRootWindowOrAnyChildFocused()` in favor of using `IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows)`. Kept redirection function (will obsolete). (#1382) -- Obsoleted `IsRootWindowOrAnyChildHovered()` in favor of using `IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows)`. Kept redirection function (will obsolete). (#1382) -- Obsoleted `SetNextWindowContentWidth() in favor of using `SetNextWindowContentSize()`. Kept redirection function (will obsolete). -- Renamed `ImGuiTextBuffer::append()` helper to `appendf()`, and `appendv()` to `appendfv()` for consistency. If you copied the 'Log' demo in your code, it uses appendv() so that needs to be renamed. -- ImDrawList: Removed 'bool anti_aliased = true' final parameter of `ImDrawList::AddPolyline()` and `ImDrawList::AddConvexPolyFilled()`. Prefer manipulating ImDrawList::Flags if you need to toggle them during the frame. -- Style, ImDrawList: Renamed `style.AntiAliasedShapes` to `style.AntiAliasedFill` for consistency and as a way to explicitly break code that manipulate those flag at runtime. You can now manipulate ImDrawList::Flags. -- Style, Begin: Removed `ImGuiWindowFlags_ShowBorders` window flag. Borders are now fully set up in the ImGuiStyle structure (see e.g. `style.FrameBorderSize`, `style.WindowBorderSize`, `style.PopupBorderSize`). - Use `ImGui::ShowStyleEditor()` to look them up. - Please note that the style system will keep evolving (hopefully stabilizing in Q1 2018), and so custom styles will probably subtly break over time. - It is recommended that you use the `StyleColorsClassic()`, `StyleColorsDark()`, `StyleColorsLight()` functions. Also see `ShowStyleSelector()`. -- Style: Removed `ImGuiCol_ComboBg` in favor of combo boxes using `ImGuiCol_PopupBg` for consistency. Combo are normal pop-ups. -- Style: Renamed `ImGuiCol_ChildWindowBg` to `ImGuiCol_ChildBg`. -- Style: Renamed `style.ChildWindowRounding` to `style.ChildRounding`, `ImGuiStyleVar_ChildWindowRounding` to `ImGuiStyleVar_ChildRounding`. -- Removed obsolete redirection functions: SetScrollPosHere() - marked obsolete in v1.42, July 2015. -- Removed obsolete redirection functions: GetWindowFont(), GetWindowFontSize() - marked obsolete in v1.48, March 2016. - -Other Changes: - -- Added `io.OptCursorBlink` option to allow disabling cursor blinking. (#1427) [renamed to io.ConfigCursorBlink in 1.63] -- Added `GetOverlayDrawList()` helper to quickly get access to a ImDrawList that will be rendered in front of every windows. -- Added `GetFrameHeight()` helper which returns `(FontSize + style.FramePadding.y * 2)`. -- Drag and Drop: Added Beta API to easily use drag and drop patterns between imgui widgets. - - Setup a source on a widget with `BeginDragDropSource()`, `SetDragDropPayload()`, `EndDragDropSource()` functions. - - Receive data with `BeginDragDropTarget()`, `AcceptDragDropPayload()`, `EndDragDropTarget()`. - - See ImGuiDragDropFlags for various options. - - The ColorEdit4() and ColorButton() widgets now support Drag and Drop. - - The API is tagged as Beta as it still may be subject to small changes. -- Drag and Drop: When drag and drop is active, tree nodes and collapsing header can be opened by hovering on them for 0.7 seconds. -- Renamed io.OSXBehaviors to io.OptMacOSXBehaviors. Should not affect users as the compile-time default is usually enough. (#473, #650) -- Style: Added StyleColorsDark() style. (#707) [@dougbinks] -- Style: Added StyleColorsLight() style. Best used with frame borders + thicker font than the default font. (#707) -- Style: Added style.PopupRounding setting. (#1112) -- Style: Added style.FrameBorderSize, style.WindowBorderSize, style.PopupBorderSize. Removed ImGuiWindowFlags_ShowBorders window flag! - Borders are now fully set up in the ImGuiStyle structure. Use ImGui::ShowStyleEditor() to look them up. (#707, fix #819, #1031) -- Style: Various small changes to the classic style (most noticeably, buttons are now using blue shades). (#707) -- Style: Renamed ImGuiCol_ChildWindowBg to ImGuiCol_ChildBg. -- Style: Renamed style.ChildWindowRounding to style.ChildRounding, ImGuiStyleVar_ChildWindowRounding to ImGuiStyleVar_ChildRounding. -- Style: Removed ImGuiCol_ComboBg in favor of combo boxes using ImGuiCol_PopupBg for consistency. (#707) -- Style: Made the ScaleAllSizes() helper rounds down every values so they are aligned on integers. -- Focus: Added SetItemDefaultFocus(), which in the current (master) branch behave the same as doing `if (IsWindowAppearing()) SetScrollHere()`. - In the navigation branch this will also set the default focus. Prefer using this when creating combo boxes with `BeginCombo()` so your code will be forward-compatible with gamepad/keyboard navigation features. (#787) -- Combo: Pop-up grows horizontally to accommodate for contents that is larger then the parent combo button. -- Combo: Added BeginCombo()/EndCombo() API which allows use to submit content of any form and manage your selection state without relying on indices. -- Combo: Added ImGuiComboFlags_PopupAlignLeft flag to BeginCombo() to prioritize keeping the pop-up on the left side (for small-button-looking combos). -- Combo: Added ImGuiComboFlags_HeightSmall, ImGuiComboFlags_HeightLarge, ImGuiComboFlags_HeightLargest to easily provide desired pop-up height. -- Combo: You can use SetNextWindowSizeConstraints() before BeginCombo() to specify specific pop-up width/height constraints. -- Combo: Offset popup position by border size so that a double border isn't so visible. (#707) -- Combo: Recycling windows by using a stack number instead of a unique id, wasting less memory (like menus do). -- InputText: Added ImGuiInputTextFlags_NoUndoRedo flag. (#1506, #1508) [@ibachar] -- Window: Fixed auto-resize allocating too much space for scrollbar when SizeContents is bigger than maximum window size (fixes c0547d3). (#1417) -- Window: Child windows with MenuBar use regular WindowPadding.y so layout look consistent as child or as a regular window. -- Window: Begin(): Fixed appending into a child window with a second Begin() from a different window stack querying the wrong window for the window->Collapsed test. -- Window: Calling IsItemActive(), IsItemHovered() etc. after a call to Begin() provides item data for the title bar, so you can easily test if the title bar is being hovered, etc. (#823) -- Window: Made it possible to use SetNextWindowPos() on a child window. -- Window: Fixed a one frame glitch. When an appearing window claimed the focus themselves, the title bar wouldn't use the focused color for one frame. -- Window: Added ImGuiWindowFlags_ResizeFromAnySide flag to resize from any borders or from the lower-left corner of a window. This requires your backend to honor GetMouseCursor() requests for full usability. (#822) -- Window: Sizing fixes when using SetNextWindowSize() on individual axises. -- Window: Hide new window for one frame until they calculate their size. Also fixes SetNextWindowPos() given a non-zero pivot. (#1694) -- Window: Made mouse wheel scrolling accommodate better to windows that are smaller than the scroll step. -- Window: SetNextWindowContentSize() adjust for the size of decorations (title bar/menu bar), but _not_ for borders are we consistently make borders not affect layout. - If you need a non-child window of an exact size with border enabled but zero window padding, you'll need to accommodate for the border size yourself. -- Window: Using the ImGuiWindowFlags_NoScrollWithMouse flag on a child window forwards the mouse wheel event to the parent window, unless either ImGuiWindowFlags_NoInputs or ImGuiWindowFlags_NoScrollbar are also set. (#1380, #1502) -- Window: Active Modal window always set the WantCaptureKeyboard flag. (#744) -- Window: Moving window doesn't use accumulating MouseDelta so straying out of imgui boundaries keeps moved imgui window at the same cursor-relative position. -- IsWindowFocused(): Added ImGuiFocusedFlags_ChildWindows flag to include child windows in the focused test. (#1382). -- IsWindowFocused(): Added ImGuiFocusedFlags_RootWindow flag to start focused test from the root (top-most) window. Obsolete IsRootWindowFocused(). (#1382) -- IsWindowHovered(): Added ImGuiHoveredFlags_ChildWindows flag to include child windows in the hovered test. (#1382). -- IsWindowHovered(): Added ImGuiHoveredFlags_RootWindow flag to start hovered test from the root (top-most) window. The combination of both flags obsoletes IsRootWindowOrAnyChildHovered(). (#1382) -- IsWindowHovered(): Fixed return value when an item is active to use the same logic as IsItemHovered(). (#1382, #1404) -- IsWindowHovered(): Always return true when current window is being moved. (#1382) -- Scrollbar: Fixed issues with vertical scrollbar flickering/appearing, typically when manually resizing and using a pattern of filling available height (e.g. full sized BeginChild). -- Scrollbar: Minor graphical fix for when scrollbar don't have enough visible space to display the full grab. -- Scrolling: Fixed padding and scrolling asymmetry where lower/right sides of a window wouldn't use WindowPadding properly + causing minor scrolling glitches. -- Tree: TreePush with zero arguments was ambiguous. Resolved by making it call TreePush(const void*). [@JasonWilkins] -- Tree: Renamed ImGuiTreeNodeFlags_AllowOverlapMode to ImGuiTreeNodeFlags_AllowItemOverlap. (#600, #1330) -- MenuBar: Fixed minor rendering issues on the right size when resizing a window very small and using rounded window corners. -- MenuBar: better software clipping to handle small windows, in particular child window don't have minimum constraints so we need to render clipped menus better. -- BeginMenu(): Tweaked the Arrow/Triangle displayed on child menu items. -- Columns: Clipping columns borders on Y axis on CPU because some Linux GPU drivers appears to be unhappy with triangle spanning large regions. (#125) -- Columns: Added ImGuiColumnsFlags_GrowParentContentsSize to internal API to restore old content sizes behavior (may be obsolete). (#1444, #125) -- Columns: Columns width is no longer lost when dragging a column to the right side of the window, until releasing the mouse button you have a chance to save them. (#1499, #125). [@ggtucker] -- Columns: Fixed dragging when using a same of columns multiple times in the frame. (#125) -- Indent(), Unindent(): Allow passing negative values. -- ColorEdit4(): Made IsItemActive() return true when picker pop-up is active. (#1489) -- ColorEdit4(): Tweaked tooltip so that the color button aligns more correctly with text. -- ColorEdit4(): Support drag and drop. Color buttons can be used as drag sources, and ColorEdit widgets as drag targets. (#143) -- ColorPicker4(): Fixed continuously returning true when holding mouse button on the sat/value/alpha locations. We only return true on value change. (#1489) -- NewFrame(): using literal strings in the most-frequently firing IM_ASSERT expressions to increase the odd of programmers seeing them (especially those who don't use a debugger). -- NewFrame() now asserts if neither Render or EndFrame have been called. Exposed EndFrame(). Made it legal to call EndFrame() more than one. (#1423) -- ImGuiStorage: Added BuildSortByKey() helper to rebuild storage from scratch. -- ImFont: Added GetDebugName() helper. -- ImFontAtlas: Added missing Thai punctuation in the GetGlyphRangesThai() ranges. (#1396) [@nProtect] -- ImDrawList: Removed 'bool anti_aliased = true' final parameter of ImDrawList::AddPolyline() and ImDrawList::AddConvexPolyFilled(). Anti-aliasing is controlled via the regular style.AntiAliased flags. -- ImDrawList: Added ImDrawList::AddImageRounded() helper. (#845) [@thedmd] -- ImDrawList: Refactored to make ImDrawList independent of ImGui. Removed static variable in PathArcToFast() which caused linking issues to some. -- ImDrawList: Exposed ImDrawCornerFlags, replaced occurrences of ~0 with an explicit ImDrawCornerFlags_All. NB: Inversed BotLeft (prev 1<<3, now 1<<2) and BotRight (prev 1<<2, now 1<<3). -- ImVector: Added ImVector::push_front() helper. -- ImVector: Added ImVector::contains() helper. -- ImVector: insert() uses grow_capacity() instead of using grow policy inconsistent with push_back(). -- Internals: Remove requirement to define IMGUI_DEFINE_PLACEMENT_NEW to use the IM_PLACEMENT_NEW macro. (#1103) -- Internals: ButtonBehavior: Fixed ImGuiButtonFlags_NoHoldingActiveID flag from incorrectly setting the ActiveIdClickOffset field. - This had no known effect within imgui code but could have affected custom drag and drop patterns. And it is more correct this way! (#1418) -- Internals: ButtonBehavior: Fixed ImGuiButtonFlags_AllowOverlapMode to avoid temporarily activating widgets on click before they have been correctly double-hovered. (#319, #600) -- Internals: Added SplitterBehavior() helper. (#319) -- Internals: Added IM_NEW(), IM_DELETE() helpers. (#484, #504, #1517) -- Internals: Basic refactor of the settings API which now allows external elements to be loaded/saved. -- Demo: Added ShowFontSelector() showing loaded fonts. -- Demo: Added ShowStyleSelector() to select among default styles. (#707) -- Demo: Renamed the emblematic ShowTestWindow() function to ShowDemoWindow(). -- Demo: Style Editor: Added a "Simplified settings" sections with check-boxes for border size and frame rounding. (#707, #1019) -- Demo: Style Editor: Added combo box to select stock styles and select current font when multiple are loaded. (#707) -- Demo: Style Editor: Using local storage so Save/Revert button makes more sense without code passing its storage. Added horizontal scroll bar. Fixed Save/Revert button to be always accessible. (#1211) -- Demo: Console: Fixed context menu issue. (#1404) -- Demo: Console: Fixed incorrect positioning which was hidden by a minor scroll issue (this would affect people who copied the Console code as is). -- Demo: Constrained Resize: Added more test cases. (#1417) -- Demo: Custom Rendering: Fixed clipping rectangle extruding out of parent window. -- Demo: Layout: Removed unnecessary and misleading BeginChild/EndChild calls. -- Demo: The "Color Picker with Palette" demo supports drag and drop. (#143) -- Demo: Display better mouse cursor info for debugging backends. -- Demo: Stopped using rand() function in demo code. -- Examples: Added a handful of extra comments (about fonts, third-party libraries used in the examples, etc.). -- Examples: DirectX9: Handle loss of D3D9 device (D3DERR_DEVICELOST). (#1464) -- Examples: Added null_example/ which is helpful for quick testing on multiple compilers/settings without relying on graphics library. -- Fix for using alloca() in "Clang with Microsoft Codechain" mode. -- Various fixes, optimizations, comments. - - ------------------------------------------------------------------------ - VERSION 1.52 (2017-10-27) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.52 - -Breaking Changes: - -- IO: `io.MousePos` needs to be set to ImVec2(-FLT_MAX,-FLT_MAX) when mouse is unavailable/missing, instead of ImVec2(-1,-1) as previously) This is needed so we can clear `io.MouseDelta` field when the mouse is made available again. -- Renamed `AlignFirstTextHeightToWidgets()` to `AlignTextToFramePadding()`. Kept inline redirection function (will obsolete). -- Obsoleted the legacy 5 parameters version of Begin(). Please avoid using it. If you need a transparent window background, uses `PushStyleColor()`. The old size parameter there was also misleading and equivalent to calling `SetNextWindowSize(size, ImGuiCond_FirstTimeEver)`. Kept inline redirection function (will obsolete). -- Obsoleted `IsItemHoveredRect()`, `IsMouseHoveringWindow()` in favor of using the newly introduced flags of `IsItemHovered()` and `IsWindowHovered()`. Kept inline redirection function (will obsolete). (#1382) -- Obsoleted 'SetNextWindowPosCenter()' in favor of using 1SetNextWindowPos()` with a pivot value which allows to do the same and more. Keep inline redirection function. -- Removed `IsItemRectHovered()`, `IsWindowRectHovered()` recently introduced in 1.51 which were merely the more consistent/correct names for the above functions which are now obsolete anyway. (#1382) -- Changed `IsWindowHovered()` default parameters behavior to return false if an item is active in another window (e.g. click-dragging item from another window to this window). You can use the newly introduced IsWindowHovered() flags to requests this specific behavior if you need it. (#1382) -- Renamed imconfig.h's `IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS`/`IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS` to `IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS`/`IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS` for consistency. -- Renamed ImFont::Glyph to ImFontGlyph. Kept redirection typedef (will obsolete). - -Other Changes: - -- ProgressBar: fixed rendering when straddling rounded area. (#1296) -- SliderFloat, DragFloat: Using scientific notation e.g. "%.1e" in the displayed format string doesn't mistakenly trigger rounding of the value. [@MomentsInGraphics] -- Combo, InputFloat, InputInt: Made the small button on the right side align properly with the equivalent colored button of ColorEdit4(). -- IO: Tweaked logic for `io.WantCaptureMouse` so it now outputs false when e.g. hovering over void while an InputText() is active. (#621) [@pdoane] -- IO: Fixed `io.WantTextInput` from mistakenly outputting true when an activated Drag or Slider was previously turned into an InputText(). (#1317) -- Misc: Added flags to `IsItemHovered()`, `IsWindowHovered()` to access advanced hovering-test behavior. Generally useful for pop-ups and drag and drop behaviors: (relates to ~#439, #1013, #143, #925) - - `ImGuiHoveredFlags_AllowWhenBlockedByPopup` - - `ImGuiHoveredFlags_AllowWhenBlockedByActiveItem` - - `ImGuiHoveredFlags_AllowWhenOverlapped` - - `ImGuiHoveredFlags_RectOnly` -- Input: Added `IsMousePosValid()` helper. -- Input: Added `GetKeyPressedAmount()` to easily measure press count when the repeat rate is faster than the frame rate. -- Input/Focus: Disabled TAB and Shift+TAB when CTRL key is held. -- CheckBox: Now rendering a tick mark instead of a full square. -- ColorEdit4: Added "Copy as..." option in context menu. (#346) -- ColorPicker: Improved ColorPicker hue wheel color interpolation. (#1313) [@thevaber] -- ColorButton: Reduced bordering artifact that would be particularly visible with an opaque Col_FrameBg and FrameRounding enabled. -- ColorButton: Fixed rendering color button with a checkerboard if the transparency comes from the global style.Alpha and not from the actual source color. -- TreeNode: Added `ImGuiTreeNodeFlags_FramePadding` flag to conveniently create a tree node with full padding at the beginning of a line, without having to call `AlignTextToFramePadding()`. -- Trees: Fixed calling `SetNextTreeNodeOpen()` on a collapsed window leaking to the first tree node item of the next frame. -- Layout: Horizontal layout is automatically enforced in a menu bar, so you can use non-MenuItem elements without calling SameLine(). -- Separator: Output a vertical separator when used inside a menu bar (or in general when horizontal layout is active, but that isn't exposed yet!). -- Window: Added `IsWindowAppearing()` helper (helpful e.g. as a condition before initializing some of your own things.). -- Window: Added pivot parameter to `SetNextWindowPos()`, making it possible to center or right align a window. Obsoleted `SetNextWindowPosCenter()`. -- Window: Fixed title bar color of top-most window under a modal window. -- Window: Fixed not being able to move a window by clicking on one of its child window. (#1337, #635) -- Window: Fixed `Begin()` auto-fit calculation code that predict the presence of a scrollbar so it works better when window size constraints are used. -- Window: Fixed calling `Begin()` more than once per frame setting `window_just_activated_by_user` which in turn would set enable the Appearing condition for that frame. -- Window: The implicit "Debug" window now uses a "Debug##Default" identifier instead of "Debug" to allow user creating a window called "Debug" without losing their custom flags. -- Window: Made the `ImGuiWindowFlags_NoMove` flag properly inherited from parent to child. In a setup with ParentWindow (no flag) -> Child (NoMove) -> SubChild (no flag), the user won't be able to move the parent window by clicking on SubChild. (#1381) -- Popups: Pop-ups can be closed with a right-click anywhere, without altering focus under the pop-up. (~#439) -- Popups: `BeginPopupContextItem()`, `BeginPopupContextWindow()` are now setup to allow reopening a context menu by right-clicking again. (~#439) -- Popups: `BeginPopupContextItem()` now supports a NULL string identifier and uses the last item ID if available. -- Popups: Added `OpenPopupOnItemClick()` helper which mimic `BeginPopupContextItem()` but doesn't do the BeginPopup(). -- MenuItem: Only activating on mouse release. [@Urmeli0815] (was already fixed in nav branch). -- MenuItem: Made tick mark thicker (thick mark?). -- MenuItem: Tweaks to be usable inside a menu bar (nb: it looks like a regular menu and thus is misleading, prefer using Button() and regular widgets in menu bar if you need to). (#1387) -- ImDrawList: Fixed a rare draw call merging bug which could lead to undisplayed triangles. (#1172, #1368) -- ImDrawList: Fixed a rare bug in `ChannelsMerge()` when all contents has been clipped, leading to an extraneous draw call being created. (#1172, #1368) -- ImFont: Added `AddGlyph()` building helper for use by custom atlas builders. -- ImFontAtlas: Added support for CustomRect API to submit custom rectangles to be packed into the atlas. You can map them as font glyphs, or use them for custom purposes. - After the atlas is built you can query the position of your rectangles in the texture and then copy your data there. You can use this features to create e.g. full color font-mapped icons. -- ImFontAtlas: Fixed fall-back handling when merging fonts, if a glyph was missing from the second font input it could have used a glyph from the first one. (#1349) [@inolen] -- ImFontAtlas: Fixed memory leak on build failure case when stbtt_InitFont failed (generally due to incorrect or supported font type). (#1391) (@Moka42) -- ImFontConfig: Added `RasterizerMultiply` option to alter the brightness of individual fonts at rasterization time, which may help increasing readability for some. -- ImFontConfig: Added `RasterizerFlags` to pass options to custom rasterizer (e.g. the [imgui_freetype](https://github.com/ocornut/imgui_club/tree/master/imgui_freetype) rasterizer in imgui_club has such options). -- ImVector: added resize() variant with initialization value. -- Misc: Changed the internal name formatting of child windows identifier to use slashes (instead of dots) as separator, more readable. -- Misc: Fixed compilation with `IMGUI_DISABLE_OBSOLETE_FUNCTIONS` defined. -- Misc: Marked all format+va_list functions with format attribute so GCC/Clang can warn about misuses. -- Misc: Fixed compilation on NetBSD due to missing alloca.h (#1319) [@RyuKojiro] -- Misc: Improved warnings compilation for newer versions of Clang. (#1324) (@waywardmonkeys) -- Misc: Added `io.WantMoveMouse flags` (from Nav branch) and honored in Examples applications. Currently unused but trying to spread Examples applications code that supports it. -- Misc: Added `IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS` support in imconfig.h to allow user reimplementing the `ImFormatString()` functions e.g. to use stb_printf(). (#1038) -- Misc: [Windows] Fixed default Win32 `SetClipboardText()` handler leaving the Win32 clipboard handler unclosed on failure. [@pdoane] -- Style: Added `ImGuiStyle::ScaleAllSizes(float)` helper to make it easier to have application transition e.g. from low to high DPI with a matching style. -- Metrics: Draw window bounding boxes when hovering Pos/Size; List all draw layers; Trimming empty commands like Render() does. -- Examples: OpenGL3: Save and restore sampler state. (#1145) [@nlguillemot] -- Examples: OpenGL2, OpenGL3: Save and restore polygon mode. (#1307) [@JJscott] -- Examples: DirectX11: Allow creating device with feature level 10 since we don't really need much for that example. (#1333) -- Examples: DirectX9/10/12: Using the Win32 SetCapture/ReleaseCapture API to read mouse coordinates when they are out of bounds. (#1375) [@Gargaj, @ocornut] -- Tools: Fixed binary_to_compressed_c tool to return 0 when successful. (#1350) [@benvanik] -- Internals: Exposed more helpers and unfinished features in imgui_internal.h. (use at your own risk!). -- Internals: A bunch of internal refactoring, hopefully haven't broken anything! Merged a bunch of internal changes from the upcoming Navigation branch. -- Various tweaks, fixes and documentation changes. - -Beta Navigation Branch: -(Lots of work has been done toward merging the Beta Gamepad/Keyboard Navigation branch (#787) in master.) -(Please note that this branch is always kept up to date with master. If you are using the navigation branch, some of the changes include:) -- Nav: Added `#define IMGUI_HAS_NAV` in imgui.h to ease sharing code between both branches. (#787) -- Nav: MainMenuBar now releases focus when user gets out of the menu layer. (#787) -- Nav: When applying focus to a window with only menus, the menu layer is automatically activated. (#787) -- Nav: Added `ImGuiNavInput_KeyMenu` (~Alt key) aside from ImGuiNavInput_PadMenu input as it is one differentiator of pad vs keyboard that was detrimental to the keyboard experience. Although isn't officially supported, it makes the current experience better. (#787) -- Nav: Move requests now wrap vertically inside Menus and Pop-ups. (#787) -- Nav: Allow to collapse tree nodes with NavLeft and open them with NavRight. (#787, #1079). -- Nav: It's now possible to navigate sibling of a menu-bar while navigating inside one of their child. If a Left<>Right navigation request fails to find a match we forward the request to the root menu. (#787, #126) -- Nav: Fixed `SetItemDefaultFocus` from stealing default focus when we are initializing default focus for a menu bar layer. (#787) -- Nav: Support for fall-back horizontal scrolling with PadLeft/PadRight (nb: fall-back scrolling is only used to navigate windows that have no interactive items). (#787) -- Nav: Fixed tool-tip from being selectable in the window selection list. (#787) -- Nav: `CollapsingHeader(bool*)` variant: fixed for `IsItemHovered()` not working properly in the nav branch. (#600, #787) -- Nav: InputText: Fixed using Up/Down history callback feature when Nav is enabled. (#787) -- Nav: InputTextMultiline: Fixed navigation/selection. Disabled selecting all when activating a multi-line text editor. (#787) -- Nav: More consistently drawing a (thin) navigation rectangle hover filled frames such as tree nodes, collapsing header, menus. (#787) -- Nav: Various internal refactoring. - - ------------------------------------------------------------------------ - VERSION 1.51 (2017-08-24) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.51 - -Breaking Changes: - -Work on dear imgui has been gradually resuming. It means that fixes and new features should be tackled at a faster rate than last year. However, in order to move forward with the library and get rid of some cruft, I have taken the liberty to be a little bit more aggressive than usual with API breaking changes. Read the details below and search for those names in your code! In the grand scheme of things, those changes are small and should not affect everyone, but this is technically our most aggressive release so far in term of API breakage. If you want to be extra forward-facing, you can enable `#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS` in your imconfig.h to disable the obsolete names/redirection. - -- Renamed `IsItemHoveredRect()` to `IsItemRectHovered()`. Kept inline redirection function (will obsolete). -- Renamed `IsMouseHoveringWindow()` to `IsWindowRectHovered()` for consistency. Kept inline redirection function (will obsolete). -- Renamed `IsMouseHoveringAnyWindow()` to `IsAnyWindowHovered()` for consistency. Kept inline redirection function (will obsolete). -- Renamed `ImGuiCol_Columns***` enums to `ImGuiCol_Separator***`. Kept redirection enums (will obsolete). -- Renamed `ImGuiSetCond***` types and enums to `ImGuiCond***`. Kept redirection enums (will obsolete). -- Renamed `GetStyleColName()` to `GetStyleColorName()` for consistency. Unlikely to be used by end-user! -- Added `PushStyleColor(ImGuiCol idx, ImU32 col)` overload, which _might_ cause an "ambiguous call" compilation error if you are using ImColor() with implicit cast. Cast to ImU32 or ImVec4 explicitly to fix. -- Marked the weird `IMGUI_ONCE_UPON_A_FRAME` helper macro as obsolete. Prefer using the more explicit `ImGuiOnceUponAFrame`. -- Changed `ColorEdit4(const char* label, float col[4], bool show_alpha = true)` signature to `ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flags = 0)`, where flags 0x01 is a safe no-op (hello dodgy backward compatibility!). The new `ColorEdit4`/`ColorPicker4` functions have lots of available flags! Check and run the demo window, under "Color/Picker Widgets", to understand the various new options. -- Changed signature of `ColorButton(ImVec4 col, bool small_height = false, bool outline_border = true)` to `ColorButton(const char* desc_id, ImVec4 col, ImGuiColorEditFlags flags = 0, ImVec2 size = ImVec2(0,0))`. This function was rarely used and was very dodgy (no explicit ID!). -- Changed `BeginPopupContextWindow(bool also_over_items=true, const char* str_id=NULL, int mouse_button=1)` signature to `(const char* str_id=NULL, int mouse_button=1, bool also_over_items=true)`. This is perhaps the most aggressive change in this update, but note that the majority of users relied on default parameters completely, so this will affect only a fraction of users of this already rarely used function. -- Removed `IsPosHoveringAnyWindow()`, which was partly broken and misleading. In the vast majority of cases, people using that function wanted to use `io.WantCaptureMouse` flag. Replaced with IM_ASSERT + comment redirecting user to `io.WantCaptureMouse`. (#1237) -- Removed the old `ValueColor()` helpers, they are equivalent to calling `Text(label)` + `SameLine()` + `ColorButton()`. -- Removed `ColorEditMode()` and `ImGuiColorEditMode` type in favor of `ImGuiColorEditFlags` and parameters to the various Color*() functions. The `SetColorEditOptions()` function allows to initialize default but the user can still change them with right-click context menu. Commenting out your old call to `ColorEditMode()` may just be fine! - -Other Changes: - -- Added flags to `ColorEdit3()`, `ColorEdit4()`. The color edit widget now has a context-menu and access to the color picker. (#346) -- Added flags to `ColorButton()`. (#346) -- Added `ColorPicker3()`, `ColorPicker4()`. The API along with those of the updated `ColorEdit4()` was designed so you may use them in various situation and hopefully compose your own picker if required. There are a bunch of available flags, check the Demo window and comment for `ImGuiColorEditFlags_`. Some of the options it supports are: two color picker types (hue bar + sat/val rectangle, hue wheel + rotating sat/val triangle), display as u8 or float, lifting 0.0..1.0 constraints (currently rgba only), context menus, alpha bar, background checkerboard options, preview tooltip, basic revert. For simple use, calling the existing `ColorEdit4()` function as you did before will be enough, as you can now open the color picker from there. (#346) [@r-lyeh, @nem0, @thennequin, @dariomanesku and @ocornut] -- Added `SetColorEditOptions()` to set default color options (e.g. if you want HSV over RGBA, float over u8, select a default picker mode etc. at startup time without a user intervention. Note that the user can still change options with the context menu unless disabled with `ImGuiColorFlags_NoOptions` or explicitly enforcing a display type/picker mode etc.). -- Added user-facing `IsPopupOpen()` function. (#891) [@mkeeter] -- Added `GetColorU32(u32)` variant that perform the style alpha multiply without a floating-point round trip, and helps makes code more consistent when using ImDrawList APIs. -- Added `PushStyleColor(ImGuiCol idx, ImU32 col)` overload. -- Added `GetStyleColorVec4(ImGuiCol idx)` which is equivalent to accessing `ImGui::GetStyle().Colors[idx]` (aka return the raw style color without alpha alteration). -- ImFontAtlas: Added `GlyphRangesBuilder` helper class, which makes it easier to build custom glyph ranges from your app/game localization data, or add into existing glyph ranges. -- ImFontAtlas: Added `TexGlyphPadding` option. (#1282) [@jadwallis] -- ImFontAtlas: Made it possible to override size of AddFontDefault() (even if it isn't really recommended!). -- ImDrawList: Added `GetClipRectMin()`, `GetClipRectMax()` helpers. -- Fixed Ini saving crash if the ImGuiWindowFlags_NoSavedSettings gets removed from a window after its creation (unlikely!). (#1000) -- Fixed `PushID()`/`PopID()` from marking parent window as Accessed (which needlessly woke up the root "Debug" window when used outside of a regular window). (#747) -- Fixed an assert when calling `CloseCurrentPopup()` twice in a row. [@nem0] -- Window size can be loaded from .ini data even if ImGuiWindowFlags_NoResize flag is set. (#1048, #1056) -- Columns: Added `SetColumnWidth()`. (#913) [@ggtucker] -- Columns: Dragging a column preserve its width by default. (#913) [@ggtucker] -- Columns: Fixed first column appearing wider than others. (#1266) -- Columns: Fixed allocating space on the right-most side with the assumption of a vertical scrollbar. The space is only allocated when needed. (#125, #913, #893, #1138) -- Columns: Fixed the right-most column from registering its content width to the parent window, which led to various issues when using auto-resizing window or e.g. horizontal scrolling. (#519, #125, #913) -- Columns: Refactored some of the columns code internally toward a better API (not yet exposed) + minor optimizations. (#913) [@ggtucker, @ocornut] -- Popups: Most pop-ups windows can be moved by the user after appearing (if they don't have explicit positions provided by caller, or e.g. sub-menu pop-up). The previous restriction was totally arbitrary. (#1252) -- Tooltip: `SetTooltip()` is expanded immediately into a window, honoring current font / styling setting. Add internal mechanism to override tooltips. (#862) -- PlotHistogram: bars are drawn based on zero-line, so negative values are going under. (#828) -- Scrolling: Fixed return values of `GetScrollMaxX()`, `GetScrollMaxY()` when both scrollbars were enabled. Tweak demo to display more data. (#1271) [@degracode] -- Scrolling: Fixes for Vertical Scrollbar not automatically getting enabled if enabled Horizontal Scrollbar straddle the vertical limit. (#1271, #246) -- Scrolling: `SetScrollHere()`, `SetScrollFromPosY()`: Fixed Y scroll aiming when Horizontal Scrollbar is enabled. (#665). -- [Windows] Clipboard: Fixed not closing Win32 clipboard on early open failure path. (#1264) -- Removed an unnecessary dependency on int64_t which failed on some older compilers. -- Demo: Rearranged everything under Widgets in a more consistent way. -- Demo: Columns: Added Horizontal Scrolling demo. Tweaked another Columns demo. (#519, #125, #913) -- Examples: OpenGL: Various makefiles for MINGW, Linux. (#1209, #1229, #1209) [@fr500, @acda] -- Examples: Enabled vsync by default in example applications, so it doesn't confuse people that the sample run at 2000+ fps and waste an entire CPU. (#1213, #1151). -- Various other small fixes, tweaks, comments, optimizations. - - ------------------------------------------------------------------------ - VERSION 1.50 (2017-06-02) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.50 - -Breaking Changes: - -- Added a void* user_data parameter to Clipboard function handlers. (#875) -- SameLine(x) with x>0.0f is now relative to left of column/group if any, and not always to left of window. This was sort of always the intent and hopefully breakage should be minimal. -- Renamed ImDrawList::PathFill() - rarely used directly - to ImDrawList::PathFillConvex() for clarity and consistency. -- Removed ImFontConfig::MergeGlyphCenterV in favor of a more multipurpose ImFontConfig::GlyphOffset. -- Style: style.WindowTitleAlign is now a ImVec2 (ImGuiAlign enum was removed). set to (0.5f,0.5f) for horizontal+vertical centering, (0.0f,0.0f) for upper-left, etc. -- BeginChild(const char*) now applies the stack id to the provided label, consistently with other functions as it should always have been. It shouldn't affect you unless (extremely unlikely) you were appending multiple times to a same child from different locations of the stack id. If that's the case, generate an id with GetId() and use it instead of passing string to BeginChild(). - -Other Changes: - -- InputText(): Added support for CTRL+Backspace (delete word). -- InputText(): OSX uses Super+Arrows for home/end. Add Shortcut+Backspace support. (#650) [@michaelbartnett] -- InputText(): Got rid of individual OSX-specific options in ImGuiIO, added a single io.OSXBehaviors flag. (#473, #650) -- InputText(): Fixed pressing home key on last character when it isn't a trailing \n (#588, #815) -- InputText(): Fixed state corruption/crash bug in stb_textedit.h redo logic when exhausting undo/redo char buffer. (#715. #681) -- InputTextMultiline(): Fixed CTRL+DownArrow moving scrolling out of bounds. -- InputTextMultiline(): Scrollbar fix for when input and latched internal buffers differs in a way that affects vertical scrollbar existence. (#725) -- ImFormatString(): Fixed an overflow handling bug with implementation of vsnprintf() that do not return -1. (#793) -- BeginChild(const char*) now applies stack id to provided label, consistent with other widgets. (#894, #713) -- SameLine() with explicit X position is relative to left of group/columns. (ref #746, #125, #630) -- SliderInt(), SliderFloat() supports reverse direction (where v_min > v_max). (#854) -- SliderInt(), SliderFloat() better support for when v_min==v_max. (#919) -- SliderInt(), SliderFloat() enforces writing back value when interacting, to be consistent with other widgets. (#919) -- SliderInt, SliderFloat(): Fixed edge case where style.GrabMinSize being bigger than slider width can lead to a division by zero. (#919) -- Added IsRectVisible() variation with explicit start-end positions. (#768) [@thedmd] -- Fixed TextUnformatted() clipping bug in the large-text path when horizontal scroll has been applied. (#692, #246) -- Fixed minor text clipping issue in window title when using font straying above usual line. (#699) -- Fixed SetCursorScreenPos() fixed not adjusting CursorMaxPos as well. -- Fixed scrolling offset when using SetScrollY(), SetScrollFromPosY(), SetScrollHere() with menu bar. -- Fixed using IsItemActive() after EndGroup() or any widget using groups. (#840, #479) -- Fixed IsItemActive() lagging by one frame on initial widget activation. (#840) -- Fixed Separator() zero-height bounding box resulting in clipping when laying exactly on top line of clipping rectangle (#860) -- Fixed PlotLines() PlotHistogram() calling with values_count == 0. -- Fixed clicking on a window's void while staying still overzealously marking .ini settings as dirty. (#923) -- Fixed assert triggering when a window has zero rendering but has a callback. (#810) -- Scrollbar: Fixed rendering when sizes are negative to reduce glitches (which can happen with certain style settings and zero WindowMinSize). -- EndGroup(): Made IsItemHovered() work when an item was activated within the group. (#849) -- BulletText(): Fixed stopping to display formatted string after the '##' mark. -- Closing the focused window restore focus to the first active root window in descending z-order .(part of #727) -- Word-wrapping: Fixed a bug where we never wrapped after a 1 character word. [@sronsse] -- Word-wrapping: Fixed TextWrapped() overriding wrap position if one is already set. (#690) -- Word-wrapping: Fixed incorrect testing for negative wrap coordinates, they are perfectly legal. (#706) -- ImGuiListClipper: Fixed automatic-height calc path dumbly having user display element 0 twice. (#661, #716) -- ImGuiListClipper: Fix to behave within column. (#661, #662, #716) -- ImDrawList: Renamed ImDrawList::PathFill() to ImDrawList::PathFillConvex() for clarity. (BREAKING API) -- Columns: End() avoid calling Columns(1) if no columns set is open, not sure why it wasn't the case already (pros: faster, cons: exercise less code). -- ColorButton(): Fix ColorButton showing wrong hex value for alpha. (#1068) [@codecat] -- ColorEdit4(): better preserve inputting value out of 0..255 range, display then clamped in Hexadecimal form. -- Shutdown() clear out some remaining pointers for sanity. (#836) -- Added IMGUI_USE_BGRA_PACKED_COLOR option in imconfig.h (#767, #844) [@thedmd] -- Style: Removed the inconsistent shadow under RenderCollapseTriangle() (~#707) -- Style: Added ButtonTextAlign, ImGuiStyleVar_ButtonTextAlign. (#842) -- ImFont: Allowing to use up to 0xFFFE glyphs in same font (increased from previous 0x8000). -- ImFont: Added GetGlyphRangesThai() helper. [@nProtect] -- ImFont: CalcWordWrapPositionA() fixed font scaling with fallback character. -- ImFont: Calculate and store the approximate texture surface to get an idea of how costly each source font is. -- ImFontConfig: Added GlyphOffset to explicitly offset glyphs at font build time, useful for merged fonts. Removed MergeGlyphCenterV. (BREAKING API) -- Clarified asserts in CheckStacksSize() when there is a stack mismatch. -- Context: Support for #define-ing GImGui and IMGUI_SET_CURRENT_CONTEXT_FUNC to enable custom thread-based hackery (#586) -- Updated stb_truetype.h to 1.14 (added OTF support, removed warnings). (#883, #976) -- Updated stb_rect_pack.h to 0.10 (removed warnings). (#883) -- Added ImGuiMouseCursor_None enum value for convenient usage by app/backends. -- Clipboard: Added a void* user_data parameter to Clipboard function handlers. (#875) (BREAKING API) -- Internals: Refactor internal text alignment options to use ImVec2, removed ImGuiAlign. (#842, #222) -- Internals: Renamed ImLoadFileToMemory to ImFileLoadToMemory to be consistent with ImFileOpen + fix mismatching .h name. (#917) -- OS/Windows: Fixed Windows default clipboard handler leaving its buffer unfreed on application's exit. (#714) -- OS/Windows: No default IME handler when compiling for Windows using GCC. (#738) -- OS/Windows: Now using _wfopen() instead of fopen() to allow passing in paths/filenames with UTF-8 characters. (#917) -- Tools: binary_to_compressed_c: Avoid ?? trigraphs sequences in string outputs which break some older compilers. (#839) -- Demo: Added an extra 3-way columns demo. -- Demo: ShowStyleEditor: show font character map / grid in more details. -- Demo: Console: Fixed a completion bug when multiple candidates are equals and match until the end. -- Demo: Fixed 1-byte off overflow in the ShowStyleEditor() combo usage. (#783) [@bear24rw] -- Examples: Accessing ImVector fields directly, feel less stl-ey. (#810) -- Examples: OpenGL*: Saving/restoring existing scissor rectangle for completeness. (#807) -- Examples: OpenGL*: Saving/restoring active texture number (the value modified by glActiveTexture). (#1087, #1088, #1116) -- Examples: OpenGL*: Saving/restoring separate color/alpha blend functions correctly. (#1120) [@greggman] -- Examples: OpenGL2: Uploading font texture as RGBA32 to increase compatibility with users shaders for beginners. (#824) -- Examples: Vulkan: Countless fixes and improvements. (#785, #804, #910, #1017, #1039, #1041, #1042, #1043, #1080) [@martty, @Loftilus, @ParticlePeter, @SaschaWillems] -- Examples: DirectX9/10/10: Only call SetCursor(NULL) is io.MouseDrawCursor is set. (#585, #909) -- Examples: DirectX9: Explicitly setting viewport to match that other examples are doing. (#937) -- Examples: GLFW+OpenGL3: Fixed Shutdown() calling GL functions with NULL parameters if NewFrame was never called. (#800) -- Examples: GLFW+OpenGL2: Renaming opengl_example/ to opengl2_example/ for clarity. -- Examples: SDL+OpenGL: explicitly setting GL_UNPACK_ROW_LENGTH to reduce issues because SDL changes it. (#752) -- Examples: SDL2: Added build .bat files for Win32. -- Added various links to language/engine bindings. -- Various other minor fixes, tweaks, comments, optimizations. - - ------------------------------------------------------------------------ - VERSION 1.49 (2016-05-09) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.49 - -Breaking Changes: - -- Renamed `SetNextTreeNodeOpened()` to `SetNextTreeNodeOpen()` for consistency, no redirection. -- Removed confusing set of `GetInternalState()`, `GetInternalStateSize()`, `SetInternalState()` functions. Now using `CreateContext()`, `DestroyContext()`, `GetCurrentContext()`, `SetCurrentContext()`. If you were using multiple contexts the change should be obvious and trivial. -- Obsoleted old signature of `CollapsingHeader(const char* label, const char* str_id = NULL, bool display_frame = true, bool default_open = false)`, as extra parameters were badly designed and rarely used. Most uses were using 1 parameter and shouldn't affect you. You can replace the "default_open = true" flag in new API with `CollapsingHeader(label, ImGuiTreeNodeFlags_DefaultOpen)`. -- Changed `ImDrawList::PushClipRect(ImVec4 rect)` to `ImDraw::PushClipRect(ImVec2 min,ImVec2 max,bool intersect_with_current_clip_rect=false)`. Note that higher-level `ImGui::PushClipRect()` is preferable because it will clip at logic/widget level, whereas `ImDrawList::PushClipRect()` only affect your renderer. -- Title bar (using ImGuiCol_TitleBg/ImGuiCol_TitleBgActive colors) isn't rendered over a window background (ImGuiCol_WindowBg color) anymore (see #655). If your TitleBg/TitleBgActive alpha was 1.0f or you are using the default theme it will not affect you. However if your TitleBg/TitleBgActive alpha was <1.0f you need to tweak your custom theme to readjust for the fact that we don't draw a WindowBg background behind the title bar. - This helper function will convert an old TitleBg/TitleBgActive color into a new one with the same visual output, given the OLD color and the OLD WindowBg color. (Or If this is confusing, just pick the RGB value from title bar from an old screenshot and apply this as TitleBg/TitleBgActive. Or you may just create TitleBgActive from a tweaked TitleBg color.) - - ImVec4 ConvertTitleBgCol(const ImVec4& win_bg_col, const ImVec4& title_bg_col) - { - float new_a = 1.0f - ((1.0f - win_bg_col.w) * (1.0f - title_bg_col.w)); - float k = title_bg_col.w / new_a; - return ImVec4((win_bg_col.x * win_bg_col.w + title_bg_col.x) * k, (win_bg_col.y * win_bg_col.w + title_bg_col.y) * k, (win_bg_col.z * win_bg_col.w + title_bg_col.z) * k, new_a); - } - -Other changes: - -- New version of ImGuiListClipper helper calculates item height automatically. See comments and demo code. (#662, #661, #660) -- Added SetNextWindowSizeConstraints() to enable basic min/max and programmatic size constraints on window. Added demo. (#668) -- Added PushClipRect()/PopClipRect() (previously part of imgui_internal.h). Changed ImDrawList::PushClipRect() prototype. (#610) -- Added IsRootWindowOrAnyChildHovered() helper. (#615) -- Added TreeNodeEx() functions. (#581, #600, #190) -- Added ImGuiTreeNodeFlags_Selected flag to display TreeNode as "selected". (#581, #190) -- Added ImGuiTreeNodeFlags_AllowOverlapMode flag. (#600) -- Added ImGuiTreeNodeFlags_NoTreePushOnOpen flag (#590). -- Added ImGuiTreeNodeFlags_NoAutoOpenOnLog flag (previously private). -- Added ImGuiTreeNodeFlags_DefaultOpen flag (previously private). -- Added ImGuiTreeNodeFlags_OpenOnDoubleClick flag. -- Added ImGuiTreeNodeFlags_OpenOnArrow flag. -- Added ImGuiTreeNodeFlags_Leaf flag, always opened, no arrow, for convenience. For simple use case prefer using TreeAdvanceToLabelPos()+Text(). -- Added ImGuiTreeNodeFlags_Bullet flag, to add a bullet to Leaf node or replace Arrow with a bullet. -- Added TreeAdvanceToLabelPos(), GetTreeNodeToLabelSpacing() helpers. (#581, #324) -- Added CreateContext()/DestroyContext()/GetCurrentContext()/SetCurrentContext(). Obsoleted nearly identical GetInternalState()/SetInternalState() functions. (#586, #269) -- Added NewLine() to undo a SameLine() and as a shy reminder that horizontal layout support hasn't been implemented yet. -- Added IsItemClicked() helper. (#581) -- Added CollapsingHeader() variant with close button. (#600) -- Fixed MenuBar missing lower border when borders are enabled. -- InputText(): Fixed clipping of cursor rendering in case it gets out of the box (which can be forced w/ ImGuiInputTextFlags_NoHorizontalScroll. (#601) -- Style: Changed default IndentSpacing from 22 to 21. (#581, #324) -- Style: Fixed TitleBg/TitleBgActive color being rendered above WindowBg color, which was inconsistent and causing visual artifact. (#655) - This broke the meaning of TitleBg and TitleBgActive. Only affect values where Alpha<1.0f. Fixed default theme. Read comments in "API BREAKING CHANGES" section to convert. -- Relative rendering of order of Child windows creation is preserved, to allow more control with overlapping children. (#595) -- Fixed GetWindowContentRegionMax() being off by ScrollbarSize amount when explicit SizeContents is set. -- Indent(), Unindent(): optional non-default indenting width. (#324, #581) -- Bullet(), BulletText(): Slightly bigger. Less polygons. -- ButtonBehavior(): fixed subtle old bug when a repeating button would also return true on mouse release (barely noticeable unless RepeatRate is set to be very slow). (#656) -- BeginMenu(): a menu that becomes disabled while open gets closed down, facilitate user's code. (#126) -- BeginGroup(): fixed using within Columns set. (#630) -- Fixed a lag in reading the currently hovered window when dragging a window. (#635) -- Obsoleted 4 parameters version of CollapsingHeader(). Refactored code into TreeNodeBehavior. (#600, #579) -- Scrollbar: minor fix for top-right rounding of scrollbar background when window has menu bar but no title bar. -- MenuItem(): the check mark renders in disabled color when menu item is disabled. -- Fixed clipping rectangle floating point representation to ensure renderer-side float point operations yield correct results in typical DirectX/GL settings. (#582, 597) -- Fixed GetFrontMostModalRootWindow(), fixing missing fade-out when a combo pop was used stacked over a modal window. (#604) -- ImDrawList: Added AddQuad(), AddQuadFilled() helpers. -- ImDrawList: AddText() refactor, moving some code to ImFont, reserving less unused vertices when large vertical clipping occurs. -- ImFont: Added RenderChar() helper. -- ImFont: Added AddRemapChar() helper. (#609) -- ImFontConfig: Clarified persistence requirement of GlyphRanges array. (#651) -- ImGuiStorage: Added bool helper functions for completeness. -- AddFontFromMemoryCompressedTTF(): Fix ImFontConfig propagation. (#587) -- Renamed majority of use of the word "opened" to "open" for clarity. Renamed SetNextTreeNodeOpened() to SetNextTreeNodeOpen(). (#625, #579) -- Examples: OpenGL3: Saving/restoring glActiveTexture() state. (#602) -- Examples: DirectX9: save/restore all device state. -- Examples: DirectX9: Removed dependency on d3dx9.h, d3dx9.lib, dxguid.lib so it can be used in a DirectXMath.h only environment. (#611) -- Examples: DirectX10/X11: Apply depth-stencil state (no use of depth buffer). (#640, #636) -- Examples: DirectX11/X11: Added comments on removing dependency on D3DCompiler. (#638) -- Examples: SDL: Initialize video+timer subsystem only. -- Examples: Apple/iOS: lowered XCode project deployment target from 10.7 to 10.11. (#598, #575) - - ------------------------------------------------------------------------ - VERSION 1.48 (2016-04-09) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.48 - -Breaking Changes: - -- Consistently honoring exact width passed to PushItemWidth() (when positive), previously it would add extra FramePadding.x*2 over that width. Some hand-tuned layout may be affected slightly. (#346) -- Style: removed `style.WindowFillAlphaDefault` which was confusing and redundant, baked alpha into `ImGuiCol_WindowBg` color. If you had a custom WindowBg color but didn't change WindowFillAlphaDefault, multiply WindowBg alpha component by 0.7. Renamed `ImGuiCol_TooltipBg` to `ImGuiCol_PopupBG`, applies to other types of pop-ups. `bg_alpha` parameter of 5-parameters version of Begin() is an override. (#337) -- InputText(): Added BufTextLen field in ImGuiTextEditCallbackData. Requesting user to update it if the buffer is modified in the callback. Added a temporary length-check assert to minimize panic for the 3 people using the callback. (#541) -- Renamed GetWindowFont() to GetFont(), GetWindowFontSize() to GetFontSize(). Kept inline redirection function (will obsolete). (#340) - -Other Changes: - -- Consistently honoring exact width passed to PushItemWidth(), previously it would add extra FramePadding.x*2 over that width. Some hand-tuned layout may be affected slightly. (#346) -- Fixed clipping of child windows within parent not taking account of child outer clipping boundaries (including scrollbar, etc.). (#506) -- TextUnformatted(): Fixed rare crash bug with large blurb of text (2k+) not finished with a '\n' and fully above the clipping Y line. (#535) -- IO: Added 'KeySuper' field to hold CMD keyboard modifiers for OS X. Updated all examples accordingly. (#473) -- Added ImGuiWindowFlags_ForceVerticalScrollbar, ImGuiWindowFlags_ForceHorizontalScrollbar flags. (#476) -- Added IM_COL32 macros to generate a U32 packed color, convenient for direct use of ImDrawList api. (#346) -- Added GetFontTexUvWhitePixel() helper, convenient for direct use of ImDrawList api. -- Selectable(): Added ImGuiSelectableFlags_AllowDoubleClick flag to allow user reacting on double-click. (@zapolnov) (#516) -- Begin(): made the close button explicitly set the boolean to false instead of toggling it. (#499) -- BeginChild()/EndChild(): fixed incorrect layout to allow widgets submitted after an auto-fitted child window. (#540) -- BeginChild(): Added ImGuiWindowFlags_AlwaysUseWindowPadding flag to ensure non-bordered child window uses window padding. (#462) -- Fixed InputTextMultiLine(), ListBox(), BeginChildFrame(), ProgressBar(): outer frame not honoring bordering. (#462, #503) -- Fixed Image(), ImageButtion() rendering a rectangle 1 px too large on each axis. (#457) -- SetItemAllowOverlap(): Promoted from imgui_internal.h to public imgui.h api. (#517) -- Combo(): Right-most button stays highlighted when pop-up is open. -- Combo(): Display pop-up above if there's isn't enough space below / or select largest side. (#505) -- DragFloat(), SliderFloat(), InputFloat(): fixed cases of erroneously returning true repeatedly after a text input modification (e.g. "0.0" --> "0.000" would keep returning true). (#564) -- DragFloat(): Always apply value when mouse is held/widget active, so that an always-resetting variable (e.g. non saved local) can be passed. -- InputText(): OS X friendly behaviors: Word movement uses ALT key; Shortcuts uses CMD key; Double-clicking text select a single word; Jumping to next word sets cursor to end of current word instead of beginning of current word. (@zhiayang), (#473) -- InputText(): Added BufTextLen in ImGuiTextEditCallbackData. Requesting user to maintain it if buffer is modified. Zero-ing structure properly before use. (#541) -- CheckboxFlags(): Added support for testing/setting multiple flags at the same time. (@DMartinek) (#555) -- TreeNode(), CollapsingHeader() fixed not being able to use "##" sequence in a formatted label. -- ColorEdit4(): Empty label doesn't add InnerSpacing.x, matching behavior of other widgets. (#346) -- ColorEdit4(): Removed unnecessary calls to scanf() when idle in hexadecimal edit mode. -- BeginPopupContextItem(), BeginPopupContextWindow(): added early out optimization. -- CaptureKeyboardFromApp() / CaptureMouseFromApp(): added argument to allow clearing the capture flag. (#533) -- ImDrawList: Fixed index-overflow check broken by AddText() casting current index back to ImDrawIdx. (#514) -- ImDrawList: Fixed incorrect removal of trailing draw command if it is a callback command. -- ImDrawList: Allow windows with only a callback only to be functional. (#524) -- ImDrawList: Fixed ImDrawList::AddRect() which used to render a rectangle 1 px too large on each axis. (#457) -- ImDrawList: Fixed ImDrawList::AddCircle() to fit precisely within bounding box like AddCircleFilled() and AddRectFilled(). (#457) -- ImDrawList: AddCircle(), AddRect() takes optional thickness parameter. -- ImDrawList: Added AddTriangle(). -- ImDrawList: Added PrimQuadUV() helper to ease custom rendering of textured quads (require primitive reserve). -- ImDrawList: Allow AddText(ImFont\* font, float font_size, ...) variant to take NULL/0.0f as default. -- ImFontAtlas: heuristic increase default texture width up for large number of glyphs. (#491) -- ImTextBuffer: Fixed empty() helper which was utterly broken. -- Metrics: allow to inspect individual triangles in draw calls. -- Demo: added more draw primitives in the Custom Rendering example. (#457) -- Demo: extra comments and example for PushItemWidth(-1) patterns. -- Demo: InputText password demo filters out blanks. (#515) -- Demo: Fixed malloc/free mismatch and leak when destructing demo console, if it has been used. (@fungos) (#536) -- Demo: plot code doesn't use ImVector to avoid heap allocation and be more friendly to custom allocator users. (#538) -- Fixed compilation on DragonFly BSD (@mneumann) (#563) -- Examples: Vulkan: Added a Vulkan example (@Loftilus) (#549) -- Examples: DX10, DX11: Saving/restoring most device state so dropping render function in your codebase shouldn't have DX device side-effects. (#570) -- Examples: DX10, DX11: Fixed ImGui_ImplDX??_NewFrame() from recreating device objects if render isn't called (g_pVB not set). -- Examples: OpenGL3: Fix BindVertexArray/BindBuffer order. (@nlguillemot) (#527) -- Examples: OpenGL: skip rendering and calling glViewport() if we have zero-fixed buffer. (#486) -- Examples: SDL2+OpenGL3: Fix context creation options. Made ImGui_ImplSdlGL3_NewFrame() signature match GL2 one. (#468, #463) -- Examples: SDL2+OpenGL2/3: Fix for high-dpi displays. (@nickgravelyn) -- Various extra comments and clarification in the code. -- Various other fixes and optimizations. - - ------------------------------------------------------------------------ - VERSION 1.47 (2015-12-25) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.47 - -Changes: - -- Rebranding "ImGui" -> "dear imgui" as an optional first name to reduce ambiguity with IMGUI term. (#21) -- Added ProgressBar(). (#333) -- InputText(): Added ImGuiInputTextFlags_Password mode: hide display, disable logging/copying to clipboard. (#237, #363, #374) -- Added GetColorU32() helper to retrieve color given enum with global alpha and extra applied. -- Added ImGuiIO::ClearInputCharacters() superfluous helper. -- Fixed ImDrawList draw command merging bug where using PopClipRect() along with PushTextureID()/PopTextureID() functions - would occasionally restore an incorrect clipping rectangle. -- Fixed ImDrawList draw command merging so PushTextureID(XXX)/PopTextureID()/PushTextureID(XXX) sequence are now properly merged. -- Fixed large popups positioning issues when their contents on either axis is larger than DisplaySize, - and WindowPadding < DisplaySafeAreaPadding. -- Fixed border rendering in various situations when using non-pixel aligned glyphs. -- Fixed border rendering of windows to always contain the border within the window. -- Fixed Shutdown() leaking font atlas data if NewFrame() was never called. (#396, #303) -- Fixed int>void\* warnings for 64-bit architectures with fancy warnings enabled. -- Renamed the dubious Color() helpers to ValueColor() - dangerously named, rarely used and probably to be made obsolete. -- InputText(): Fixed and better handling of using keyboard while mouse button if being held and dragging. (#429) -- InputText(): Replace OS IME (Input Method Editor) cursor on top-left when we are not text editing. -- TreeNode(), CollapsingHeader(), Bullet(), BulletText(): various sizing and layout fixes to better support laying out - multiple item with different height on same line. (#414, #282) -- Begin(): Initial window creation with ImGuiWindowFlags_NoBringToFrontOnFocus flag pushes it at the front of global window list. -- BeginPopupContextWindow() and BeginPopupContextVoid() reopen window on subsequent click. (#439) -- ColorEdit4(): Fixed broken tooltip on hovering the color button. (actually fixes #373, #380) -- ImageButton(): uses FrameRounding up to a maximum of available framing size. (#394) -- Columns: Fixed bug with indentation within columns, also making code a bit shorter/faster. (#414, #125) -- Columns: Columns set with no implicit id include the columns count within the id to reduce collisions. (#125) -- Columns: Removed one unnecessary allocation when columns are not used by a window. (#125) -- ImFontAtlas: Tweaked GetGlyphRangesJapanese() so it is easier to modify. -- ImFontAtlas: Updated stb_rect_pack.h to 0.08. -- Metrics: Fixed computing ImDrawCmd bounding box when the draw buffer have been unindexed. -- Demo: Added a simple "Property Editor" demo applet. (#125, #414) -- Demo: Fixed assertion in "Custom Rendering" demo when holding both mouse buttons. (#393) -- Demo: Lots of extra comments, fixes. -- Demo: Tweaks to Style Editor. -- Examples: Not clearing input data/tex data in atlas (will be required for dynamic atlas anyway). -- Examples: Added /Zi (output debug information) to Win32 batch files. -- Examples: Various fixes for resizing window and recreating graphic context. -- Examples: OpenGL2/3: Save/restore viewport as part of default render function. (#392, #441). -- Examples; OpenGL3: Fixed gl3w.c for Linux when compiled with a C++ compiler. (#411) -- Examples: DirectX: Removed assumption about Unicode build in example main.cpp. (#399) -- Examples: DirectX10: Added DirectX10 example. (#424) -- Examples: DirectX11: Downgraded requirement from shader model 5.0 to 4.0. (#420) -- Examples: DirectX11: Removed Debug flag from graphics context. (#415) -- Examples: Added SDL+OpenGL3 example. (#356) - - ------------------------------------------------------------------------ - VERSION 1.46 (2015-10-18) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.46 - -Changes: - -- Begin*(): added ImGuiWindowFlags_NoFocusOnAppearing flag. (#314) -- Begin*(): added ImGuiWindowFlags_NoBringToFrontOnFocus flag. -- Added GetDrawData() alternative to setting a Render function pointer in ImGuiIO structure. -- Added SetClipboardText(), GetClipboardText() helper shortcuts that user code can call directly without reading - from the ImGuiIO structure (to match MemAlloc/MemFree) -- Fixed handling of malformed UTF-8 at the end of a non-zero terminated string range. -- Fixed mouse click detection when passing DeltaTime 0.0. (#338) -- Fixed IsKeyReleased() and IsMouseReleased() returning true on the first frame. -- Fixed using SetNextWindow\* functions on Modal windows with a ImGuiSetCond_Appearing condition. (#377) -- IsMouseHoveringRect(): Added 'bool clip' parameter to disable clipping provided rectangle. (#316) -- InputText(): added ImGuiInputTextFlags_ReadOnly flag. (#211) -- InputText(): lose cursor/undo-stack when reactivating focus is buffer has changed size. -- InputText(): fixed ignoring text inputs when ALT or ALTGR are pressed. (#334) -- InputText(): fixed mouse-dragging not tracking the cursor when text doesn't fit. (#339) -- InputText(): fixed cursor pixel-perfect alignment when horizontally scrolling. -- InputText(): fixed crash when passing a buf_size==0 (which can be of use for read-only selectable text boxes). (#360) -- InputFloat() fixed explicit precision modifier, both display and input were broken. -- PlotHistogram(): improved rendering of histogram with a lot of values. -- Dummy(): creates an item so functions such as IsItemHovered() can be used. -- BeginChildFrame() helper: added the extra_flags parameter. -- Scrollbar: fixed rounding of background + child window consistenly have ChildWindowBg color under ScrollbarBg fill. (#355). -- Scrollbar: background color less translucent in default style so it works better when changing background color. -- Scrollbar: fixed minor rendering offset when borders are enabled. (#365) -- ImDrawList: fixed 1 leak per ImDrawList using the ChannelsSplit() API (via Columns). (#318) -- ImDrawList: fixed rectangle rendering glitches with width/height <= 1/2 and rounding enabled. -- ImDrawList: AddImage() uv parameters default to (0,0) and (1,1). -- ImFontAtlas: Added TexDesiredWidth and tweaked default cheapo best-width choice. (#327) -- ImFontAtlas: Added GetGlyphRangesKorean() helper to retrieve unicode ranges for Korean. (#348) -- ImGuiTextFilter::Draw() helper return bool and build when filter is modified. -- ImGuiTextBuffer: added c_str() helper. -- ColorEdit4(): fixed hovering the color button always showing 1.0 alpha. (#373) -- ColorConvertFloat4ToU32() round the floats instead of truncating them. -- Window: Fixed window lower-right clipping limit so it plays more friendly with both OpenGL and DirectX coordinates. -- Internal: Extracted a EndFrame() function out of Render() but kept it internal/private + clarified some asserts. (#335) -- Internal: Added missing IMGUI_API definitions in imgui_internal.h (#326) -- Internal: ImLoadFileToMemory() return void\* instead of taking void*\* + allow optional int\* file_size. -- Demo: Horizontal scrollbar demo allows to enable simultanaeous scrollbars on both axises. -- Tools: binary_to_compressed_c.cpp: added -nocompress option. -- Examples: Added example for the Marmalade platform. -- Examples: Added batch files to build Windows examples with VS. -- Examples: OpenGL3: Saving/restoring more GL state correctly. (#347) -- Examples: OpenGL2/3: Added msys2/mingw64 target to Makefiles. - - ------------------------------------------------------------------------ - VERSION 1.45 (2015-09-01) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.45 - -Breaking Changes: - -- With the addition of better horizontal scrolling primitives I had to make some consistency fixes. - `GetCursorPos()` `SetCursorPos()` `GetContentRegionMax()` `GetWindowContentRegionMin()` `GetWindowContentRegionMax()` - are now incorporating the scrolling amount. They were incorrectly not incorporating this amount previously. - It PROBABLY shouldn't break anything, but that depends on how you used them. Namely: - - If you always used SetCursorPos() with values relative to GetCursorPos() there shouldn't be a problem. - However if you used absolute coordinates, note that SetCursorPosY(100.0f) will put you at +100 from the initial Y position (which may be scrolled out of the view), NOT at +100 from the window top border. Since there wasn't any official scrolling value on X axis (past just manually moving the cursor) this can only affect you if you used to set absolute coordinates on the Y axis which is hopefully rare/unlikely, and trivial to fix. - - The value of GetWindowContentRegionMax() isn't necessarily close to GetWindowWidth() if horizontally scrolling. - Previously they were roughly interchangeable (roughly because the content region exclude window padding). - -Other Changes: - -- Added Horizontal Scrollbar via ImGuiWindowFlags_HorizontalScroll (#246). -- Added GetScrollX(), GetScrollX(), GetScrollMaxX() apis (#246). -- Added SetNextWindowContentSize(), SetNextWindowContentWidth() to explicitly set the content size of a window, which - define the range of scrollbar. When set explicitly it also define the base value from which widget width are derived. -- Added IO.WantTextInput telling when ImGui is expecting text input, so that e.g. OS on-screen keyboard can be enabled. -- Added printf attribute to printf-like text formatting functions (Clang/GCC). -- Added GetMousePosOnOpeningCurrentPopup() helper. -- Added GetContentRegionAvailWidth() helper. -- Malformed UTF-8 data don't terminate string, output 0xFFFD instead (#307). -- ImDrawList: Added AddBezierCurve(), PathBezierCurveTo() API for cubic bezier curves (#311). -- ImDrawList: Allow to override ImDrawIdx type (#292). -- ImDrawList: Added an assert on overflowing index value (#292). -- ImDrawList: Fixed issues with channels split/merge. Now functional without manually adding a draw cmd. Added comments. -- ImDrawData: Added ScaleClipRects() helper useful when rendering scaled. (#287). -- Fixed Bullet() inconsistent layout behaviour when clipped. -- Fixed IsWindowHovered() not taking account of window hoverability (may be disabled because of a popup). -- Fixed InvisibleButton() not honoring negative size consistently with other widgets that do so. -- Fixed OpenPopup() accessing current window, effectively opening "Debug" when called from an empty window stack. -- TreeNode(): Fixed IsItemHovered() result being inconsistent with interaction visuals (#282). -- TreeNode(): Fixed mouse interaction padding past the node label being accounted for in layout (#282). -- BeginChild(): Passing a ImGuiWindowFlags_NoMove inhibits moving parent window from this child. -- BeginChild() fixed missing rounding for child sizes which leaked into layout and have items misaligned. -- Begin(): Removed default name = "Debug" parameter. We already have a "Debug" window pushed to the stack in the first place so it's not really a useful default. -- Begin(): Minor fixes with windows main clipping rectangle (e.g. child window with border). -- Begin(): Window flags are only read on the first call of the frame. Subsequent calls ignore flags, which allows appending to a window without worryin about flags. -- InputText(): ignore character input when ctrl/alt are held. (Normally those text input are ignored by most wrappers.) (#279). -- Demo: Fixed incorrectly formed string passed to Combo (#298). -- Demo: Added simple Log demo. -- Demo: Added horizontal scrolling example + enabled in console, log and child examples (#246). -- Style: made scrollbars rounded by default. Because nice. Minor menu bar background alpha tweak. (#246) -- Metrics: display indices along with triangles count (#299) and some internal state. -- ImGuiTextFilter::PassFilter() supports string range. Added [] helper to ImGuiTextBuffer. -- ImGuiTextFilter::Draw() default parameter width=0.0f for no override, allow override with negative values. -- Examples: OpenGL2/OpenGL3: fix for retina displays. Default font current lack crispness. -- Examples: OpenGL2/OpenGL3: save/restore more GL state correctly. -- Examples: DirectX9/DirectX11: resizing buffers dynamically (#299). -- Examples: DirectX9/DirectX11: added missing middle mouse button to Windows event handler. -- Examples: DirectX11: fix for Visual Studio 2015 presumably shipping with an updated version of DX11. -- Examples: iOS: fixed missing files in project. - - ------------------------------------------------------------------------ - VERSION 1.44 (2015-08-08) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.44 - -Breaking Changes: - -- imgui.cpp has been split intro extra files: imgui_demo.cpp, imgui_draw.cpp, imgui_internal.h. - Add the two extra .cpp to your project or #include them from another .cpp file. (#219) - -Other Changes: - -- Internal data structure and several useful functions are now exposed in imgui_internal.h. This should make it easier - and more natural to extend ImGui. However please note that none of the content in imgui_internal.h is guaranteed - for forward-compatibility and code using those types/functions may occasionally break. (#219) -- All sample code is in imgui_demo.cpp. Please keep this file in your project and consider allowing your code to call - the ShowTestWindow() function as de-facto guide to ImGui features. It will be stripped out by the linker when unused. -- Added GetContentRegionAvail() helper (basically GetContentRegionMax() - GetCursorPos()). -- Added ImGuiWindowFlags_NoInputs for totally input-passthru window. -- Button(): honor negative size consistently with other widgets that do so (width -100 to align the button 100 pixels - before the right-most position of the contents region). -- InputTextMultiline(): honor negative size consistently with other widgets that do so. -- Combo() clamp popup to lower edge of visible area. -- InputInt(): value doesn't pass through an int>float>int casting chain, fix handling lost of precision with "large" integer. -- InputInt() allow hexadecimal input (awkwardly via ImGuiInputTextFlags_CharsHexadecimal but we will allow format - string in InputInt* later). -- Checkbox(), RadioButton(): fixed scaling of checkbox and radio button for the filling of "active" visual. -- Columns: never assume horizontal space for scrollbar if NoScrollbar flag is explicitly set. -- Slider: fixed using FramePadding between frame and grab visual. Scaling that spacing would look odd. -- Fixed lower-right resize grip hit box not scaling along with its rendered size (#287) -- ImDrawList: Fixed angles in ImDrawList::PathArcTo(), PathArcToFast() (v1.43) being off by an extra PI for no reason. -- ImDrawList: Added ImDrawList::AddText() shorthand helper. -- ImDrawList: Add missing support for anti-aliased thick-lines (#133, also ref #288) -- ImFontAtlas: Added AddFontFromMemoryCompressedBase85TTF() to load base85 encoded font string. Default font encoded - as base85 saves ~100 lines / 26 KB of source code. Added base85 output to the binary_to_compressed_c tool. -- Build fix for MinGW (#276). -- Examples: OpenGL3: Fixed running on script core profiles for OSX (#277). -- Examples: OpenGL3: Simplified code using glBufferData for vertices as well (#277, #278) -- Examples: DirectX11: Clear font texture view to ensure Release() doesn't get called twice (#290). -- Updated to stb_truetype 1.07 (back to vanilla version as our minor changes are now in master & fix unlikely assert - with odd fonts (#280) - - ------------------------------------------------------------------------ - VERSION 1.43 (2015-07-17) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.43 - -Breaking Changes: - -- This is a rather important release and we unfortunately had to break the rendering API. - ImGui now requires you to render indexed vertices instead of non-indexed ones. The fix should be very easy. - Sorry for that! This change is saving a fair amount of CPU/GPU and enables us to get anti-aliasing for a marginal cost. - Each ImDrawList now contains both a vertex buffer and an index buffer. For each command, render ElemCount/3 triangles - using indices from the index buffer. -- If you are using a vanilla copy of one of the imgui_impl_XXXX.cpp provided in the example, you just need to update - your copy and you can ignore the rest. -- The signature of the io.RenderDrawListsFn handler has changed - From: ImGui_XXXX_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_count) - To: ImGui_XXXX_RenderDrawLists(ImDrawData* draw_data) - With: argument 'cmd_lists' -> 'draw_data->CmdLists' - argument 'cmd_lists_count' -> 'draw_data->CmdListsCount' - ImDrawList 'commands' -> 'CmdBuffer' - ImDrawList 'vtx_buffer' -> 'VtxBuffer' - ImDrawList n/a -> 'IdxBuffer' (new) - ImDrawCmd 'vtx_count' -> 'ElemCount' - ImDrawCmd 'clip_rect' -> 'ClipRect' - ImDrawCmd 'user_callback' -> 'UserCallback' - ImDrawCmd 'texture_id' -> 'TextureId' -- If you REALLY cannot render indexed primitives, you can call the draw_data->DeIndexAllBuffers() method to de-index - the buffers. This is slow and a waste of CPU/GPU. Prefer using indexed rendering! - Refer to code in the examples/ folder or ask on the GitHub if you are unsure of how to upgrade. Please upgrade! - -Other Changes: - -- Added anti-aliasing on lines and shapes based on primitives by @MikkoMononen (#133). - Between the use of indexed-rendering and the fact that the entire rendering codebase has been optimized and massaged - enough, with anti-aliasing enabled ImGui 1.43 is now running FASTER than 1.41. - Made some extra effort in making the code run faster in your typical Debug build. -- Anti-aliasing can be disabled in the ImGuiStyle structure via the AntiAliasedLines/AntiAliasedShapes fields for further gains. -- ImDrawList: Added AddPolyline(), AddConvexPolyFilled() with optional anti-aliasing. -- ImDrawList: Added stateful path building and stroking API. PathLineTo(), PathArcTo(), PathRect(), PathFill(), PathStroke() - with optional anti-aliasing. -- ImDrawList: Added AddRectFilledMultiColor() helper. -- ImDrawList: Added multi-channel rendering so out of order elements can be rendered in separate channels and then merged - back together (used by columns). -- ImDrawList: Fixed merging draw commands when equal clip rectangles are in the two first commands. -- ImDrawList: Fixed window draw lists not destructed properly on Shutdown(). -- ImDrawData: Added DeIndexAllBuffers() helper. -- Added lots of new font options ImFontAtlas::AddFont() and the new ImFontConfig structure. - - Added support for oversampling (ImFontConfig: OversampleH, OversampleV) and sub-pixel positioning (ImFontConfig: PixelSnapH). - Oversampling allows sub-pixel positioning but can also be used as a way to get some leeway with scaling fonts without re-rasterizing. - - Added GlyphExtraSpacing option to add extra horizontal spacing between characters (#242). - - Added MergeMode option to merge glyphs from different font inputs into a same font (#182, #232). - - Added FontDataOwnedByAtlas option to keep ownership from the TTF data buffer and request the atlas to make a copy (#220). -- Updated to stb_truetype 1.06 (+ minor mods) with better font rasterization. -- InputText: Added ImGuiInputTextFlags_NoHorizontalScroll flag. -- InputText: Added ImGuiInputTextFlags_AlwaysInsertMode flag. -- InputText: Added HasSelection() helper in ImGuiTextEditCallbackData as a clarification. -- InputText: Fix for using END key on a multi-line text editor (#275) -- Columns: Dispatch render of each column in a sub-draw list and merge on closure, saving a lot of draw calls! (#125) -- Popups: Fixed Combo boxes inside menus. (#272) -- Style: Added GrabRounding setting to make the sliders etc. grabs rounded. -- Changed SameLine() parameters from int to float. -- Fixed incorrect assert triggering when code stole ActiveID from user moving a window by calling e.g. SetKeyboardFocusHere(). -- Fixed CollapsingHeader() label rendering outside its frame in columns context where ClipRect max isn't aligned with the - right-side of the header. -- Metrics window: calculate bounding box of actual vertices when hovering a draw list. -- Examples: Showing more information in the Fonts section. -- Examples: Added a gratuitous About window. -- Examples: Updated all examples code (OpenGL/DX9/DX11/SDL/Allegro/iOS) to use indexed rendering. -- Examples: Fixed the SDL2 example to support Unicode text input (#274). - - ------------------------------------------------------------------------ - VERSION 1.42 (2015-07-08) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.42 - -Breaking Changes: - -- Renamed SetScrollPosHere() to SetScrollHere(). Kept inline redirection function (will obsolete). -- Renamed GetScrollPosY() to GetScrollY(). Necessary to reduce confusion and make scrolling API consistent, - because positions (e.g. cursor position) are not equivalent to scrolling amount. -- Removed obsolete GetDefaultFontData() function that would assert anyway. - If you are updating from <1.30 you'll get a compile error instead of an assertion. (obsoleted 2015/01/11) - -Other Changes: - -- Added SDL2 example application (courtesy of @CedricGuillemet) -- Added iOS example application (courtesy of @joeld42) -- Added Allegro 5 example application (courtesy of @bggd) -- Added TitleBgActive color in style so focused window is made visible. (#253) -- Added CaptureKeyboardFromApp() / CaptureMouseFromApp() to manually enforce inputs capturing. -- Added DragFloatRange2() DragIntRange2() helpers. (#76) -- Added a Y centering ratio to SetScrollFromCursorPos() which can be used to aim the top or bottom of the window. (#150) -- Added SetScrollY(), SetScrollFromPos(), GetCursorStartPos() for manual scrolling manipulations. (#150). -- Added GetKeyIndex() helper for converting from ImGuiKey_\* enum to user's keycodes. Basically pulls from io.KeysMap[]. -- Added missing ImGuiKey_PageUp, ImGuiKey_PageDown so more UI code can be written without referring to implementation-side keycodes. -- MenuItem() can be activated on release. (#245) -- Allowing NewFrame() with DeltaTime==0.0f to not assert. -- Fixed IsMouseDragging(). (#260) -- Fixed PlotLines(), PlotHistogram() using incorrect hovering test so they would show their tooltip even when there is - a popup between mouse and the graph. -- Fixed window padding being reported incorrectly for child windows with borders when parent have no borders. -- Fixed a bug with TextUnformatted() clipping of long text blob when clipping y1 line sits on the first line of text. (#257) -- Fixed text baseline alignment of small button (no padding) after regular buttons. -- Fixed ListBoxHeader() not honoring negative sizes the same way as BeginChild() or BeginChildFrame(). (#263) -- Fixed warnings for more pedantic compiler settings (#258). -- ImVector<> cannot be re-defined anymore, cannot be replaced with std::vector<>. Allowed us to clean up and optimize - lots of code. Yeah! (#262) -- ImDrawList: store pointer to their owner name for easier auditing/debugging. -- Examples: added scroll tracking example with SetScrollFromCursorPos(). -- Examples: metrics windows render clip rectangle when hovering over a draw call. -- Lots of small optimization (particularly to run faster on unoptimized builds) and tidying up. -- Added font links in extra_fonts/ + instructions for using compressed fonts in C array. - - ------------------------------------------------------------------------ - VERSION 1.41 (2015-06-26) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.41 - -Breaking Changes: - -- Changed ImageButton() default bg_col parameter from (0,0,0,1) (black) to (0,0,0,0) (transparent). - Only makes a difference when texture have transparency. -- Changed Selectable() API from (label, selected, size) to (label, selected, flags, size). - Size override should be used very rarely so hopefully it doesn't affect many people. Sorry! - -Other Changes: - -- Added InputTextMultiline() multi-line text editor, vertical scrolling, selection, optimized enough to handle rather - big chunks of text in stateless context (thousands of lines are ok), option for allowing Tab to be input, option - for validating with Return or Ctrl+Return (#200). -- Added modal window API, BeginPopupModal(), follows the popup api scheme. Modal windows can be closed by clicking - outside. By default the rest of the screen is dimmed (using ImGuiCol_ModalWindowDarkening). Modal windows can be stacked. -- Added GetGlyphRangesCyrillic() helper (#237). -- Added SetNextWindowPosCenter() to center a window prior to knowing its size. (#249) -- Added IsWindowHovered() helper. -- Added IsMouseReleased(), IsKeyReleased() helpers to allow to user to avoid tracking them. (#248) -- Allow Set*WindowSize() calls to be used with popups. -- Window: AutoFit can be triggered on each axis separately via SetNextWindowSize(), etc. -- Window: fixed scrolling with mouse wheel while window was collapsed. -- Window: fixed mouse wheel scroll issues. -- DragFloat(), SliderFloat(): Fixed rounding of negative numbers which sometime made the negative lower bound unreachable. -- InputText(): lifted character count limit. -- InputText(): fixes in case of using per-window font scaling. -- Selectable(), MenuItem(): do not use frame rounding for hovering/selection. -- Selectable(): Added flag ImGuiSelectableFlags_DontClosePopups. -- Selectable(): Added flag ImGuiSelectableFlags_SpanAllColumns (#125). -- Combo(): Fixed issue with activating a Combo() not taking active id (#241). -- ColorButton(), ColorEdit4(): fix to ensure that the colored square stays square when non-default padding settings are used. -- BeginChildFrame(): returns bool like BeginChild() for clipping. -- SetScrollPosHere(): takes account of item height + more accurate centering + fixed precision issue. -- ImFont: ignoring '\r'. -- ImFont: added GetCharAdvance() helper. Exposed font Ascent and font Descent. -- ImFont: additional rendering optimizations. -- Metrics windows display storage size. - - ------------------------------------------------------------------------ - VERSION 1.40 (2015-05-31) ------------------------------------------------------------------------ - -Decorated log: https://github.com/ocornut/imgui/releases/tag/v1.40 - -Breaking Changes: - -- The BeginPopup() API (introduced in 1.37) had to be changed to allow for stacked popups and menus. - Use OpenPopup() to toggle the opened state and BeginPopup() to append.** -- The third parameter of Button(), 'repeat_if_held' has been removed. While it's been very rarely used, - some code will possibly break if you didn't rely on the default parameter. - Use PushButtonRepeat()/PopButtonRepeat() to configure repeat. -- Renamed IsRectClipped() to !IsRectVisible() for consistency (opposite return value!). Kept inline redirection function (will obsolete) -- Renamed GetWindowCollapsed() to IsWindowCollapsed() for consistency. Kept inline indirection function (will obsolete). - -Other Changes: - -- Menus: Added a menu system! Menus are typically populated with menu items and sub-menus, but you can add any sort of - widgets in them (buttons, text inputs, sliders, etc.). (#126) -- Menus: Added MenuItem() to append a menu item. Optional shortcut display, acts a button & toggle with checked/unchecked state, - disabled mode. Menu items can be used in any window. -- Menus: Added BeginMenu() to append a sub-menu. Note that you generally want to add sub-menu inside a popup or a menu-bar. - They will work inside a normal window but it will be a bit unusual. -- Menus: Added BeginMenuBar() to append to window menu-bar (set ImGuiWindowFlags_MenuBar to enable). -- Menus: Added BeginMainMenuBar() helper to append to a fullscreen main menu-bar. -- Popups: Support for stacked popups. Each popup level inhibit inputs to lower levels. The menus system is based on this. (#126). -- Popups: Added BeginPopupContextItem(), BeginPopupContextWindow(), BeginPopupContextVoid() to create a popup window on mouse-click. -- Popups: Popups have borders by default (#197), attenuated border alpha in default theme. -- Popups & Tooltip: Fit within display. Handling various positioning/sizing/scrolling edge cases. Better hysteresis when moving - in corners. Tooltip always tries to stay away from mouse-cursor. -- Added ImGuiStorage::GetVoidPtrRef() for manipulating stored void*. -- Added IsKeyDown() IsMouseDown() as convenience and for consistency with existing functions (instead of reading them from IO structures). -- Added Dummy() helper to advance layout by a given size. Unlike InvisibleButton() this doesn't catch any click. -- Added configurable io.KeyRepeatDelay, io.KeyRepeatRate keyboard and mouse repeat rate. -- Added PushButtonRepeat() / PopButtonRepeat() to enable hold-button-to-repeat press on any button. -- Removed the third 'repeat' parameter of Button(). -- Added IsAnyItemHovered() helper. -- Added GetItemsLineHeightWithSpacing() helper. -- Added ImGuiListClipper helper for clipping large list of evenly sized items, to avoid using CalcListClipping() directly. -- Separator: within group start on group horizontal offset. (#205) -- InputText: Fixed incorrect edit state after text buffer is appended to by user via the callback. (#206) -- InputText: CTRL+letter-key shortcuts (e.g. CTRL+C/V/X) makes sure only CTRL is pressed. (#214) -- InputText: Fixed cursor generating a zero-width wire-frame rectangle turning into a division by zero (would go unnoticed - unless you trapped exceptions). -- InputFloatN/InputIntN: Flags parameter added to match scalar versions. (#218) -- Selectable: Horizontal filling not declared to ItemSize() so Selectable(),SameLine() works and we can better auto-fit the window. -- Selectable: Handling text baseline alignment for line that aren't of text height. -- Combo: Empty label doesn't add ItemInnerSpacing alignment, matching other widgets. -- EndGroup: Carries the text base offset from the last line of the group (sort of incorrect but better than nothing, - should use the first line of the group, will implement in the future). -- Columns: distinguish columns-set ID from other widgets as a convenience, added asserts and sailors. -- ListBox: ListBox() function only use public API to encourage creating custom versions. ListBoxHeader() can return false. -- ListBox: Uses ImGuiListClipper and assume items of matching height, so large lists can be handled. -- Plot: overlay label clipped within frame when not fitting. -- Window: Added ImGuiSetCond_Appearing to test the hidden->visible transition in SetWindow***/SetNextWindow*** functions. -- Window: Auto-fitting cancel out one worth of vertical spacing for vertical symmetry (like what group and tooltip do). -- Window: Default item width for auto-resizing windows expressed as a factor of font height, scales better with different font. -- Window: Fixed auto-fit calculation mismatch of whether a scrollbar will be added by maximum height clamping. Also honor NoScrollBar in the case of height clamping, not adding extra horizontal space. -- Window: Hovering require to hover same child window. Reverted 860cf57 (December 3). Might break something if you have - child overlapping items in parent window. -- Window: Fixed appending multiple times to an existing child via multiple BeginChild/EndChild calls to same child name. - Allows a simple form of out-of-order appending. -- Window: Fixed auto-filling child window using WindowMinSize at their minimum size, irrelevant. -- Metrics: Added io.MetricsActiveWindows counter. (#213. -- Metrics: Added io.MetricsAllocs counter (number of active memory allocations). -- Metrics: ShowMetricsWindow() shows popups stack, allocations. -- Style: Added style.DisplayWindowPadding to prevent windows from reaching edges of display (similar to style.DisplaySafeAreaPadding which is still in effect and also affect popups/tooltips). -- Style: Removed style.AutoFitPadding, using style.WindowPadding makes more sense (the default values were already the same). -- Style: Added style.ScrollbarRounding. (#212) -- Style: Added ImGuiCol_TextDisabled for disabled text. Added TextDisabled() helper. -- Style: Added style.WindowTitleAlign alignment options, to e.g. center title on windows. (#222) -- ImVector: tweak growth strategy, matches vector from VS2010. -- ImFontAtlas: Added ClearFonts(), making the different clear funcs more explicit. (#224) -- ImFontAtlas: Fixed appending new fonts without clearing existing fonts. Clearing input data left to application. (#224) -- ImDrawList: Merge draw command better, cases of multiple Begin/End gets merged properly. -- Store common stacked settings contiguously in memory to avoid heap allocation for unused features, and reduce cache misses. -- Shutdown() tests for g.IO.Fonts not being NULL to ease use of multiple ImGui contexts. (#207) -- Added IMGUI_DISABLE_OBSOLETE_FUNCTIONS define to disable the functions that are meant to be removed. -- Examples: Added ? marks with tooltips next to various widgets. Added more comments in the demo window. -- Examples: Added Menu-bar example. -- Examples: Added Simple Layout example. -- Examples: AutoResize demo doesn't use TextWrapped(). -- Examples: Console example uses standard malloc/free, makes more sense as a copy & pastable example. -- Examples: DirectX9/11: Fixed key mapping for down arrow. -- Examples: DirectX9/11: hide OS cursor if ImGui is drawing it. (#155) -- Examples: DirectX11: explicitly set rasterizer state. -- Examples: OpenGL3: Add conditional compilation of forward compat as required by glfw on OSX. (#229) -- Fixed build with Visual Studio 2008 (possibly earlier versions as well). -- Other fixes, comments, tweaks. - - ------------------------------------------------------------------------ - -For older version, see https://github.com/ocornut/imgui/releases - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/docs/EXAMPLES.md b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/docs/EXAMPLES.md deleted file mode 100644 index 63b64d2..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/docs/EXAMPLES.md +++ /dev/null @@ -1,246 +0,0 @@ -_(You may browse this at https://github.com/ocornut/imgui/blob/master/docs/EXAMPLES.md or view this file with any Markdown viewer)_ - -## Dear ImGui: Examples - -**The [examples/](https://github.com/ocornut/imgui/blob/master/examples) folder example applications (standalone, ready-to-build) for variety of -platforms and graphics APIs.** They all use standard backends from the [backends/](https://github.com/ocornut/imgui/blob/master/backends) folder (see [BACKENDS.md](https://github.com/ocornut/imgui/blob/master/docs/BACKENDS.md)). - -The purpose of Examples is to showcase integration with backends, let you try Dear ImGui, and guide you toward -integrating Dear ImGui in your own application/game/engine. -**Once Dear ImGui is setup and running, run and refer to `ImGui::ShowDemoWindow()` in imgui_demo.cpp for usage of the end-user API.** - -You can find Windows binaries for some of those example applications at: - http://www.dearimgui.org/binaries - - -### Getting Started - -Integration in a typical existing application, should take <20 lines when using standard backends. - - At initialization: - call ImGui::CreateContext() - call ImGui_ImplXXXX_Init() for each backend. - - At the beginning of your frame: - call ImGui_ImplXXXX_NewFrame() for each backend. - call ImGui::NewFrame() - - At the end of your frame: - call ImGui::Render() - call ImGui_ImplXXXX_RenderDrawData() for your Renderer backend. - - At shutdown: - call ImGui_ImplXXXX_Shutdown() for each backend. - call ImGui::DestroyContext() - -Example (using [backends/imgui_impl_win32.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_win32.cpp) + [backends/imgui_impl_dx11.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_dx11.cpp)): - - // Create a Dear ImGui context, setup some options - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); - io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable some options - - // Initialize Platform + Renderer backends (here: using imgui_impl_win32.cpp + imgui_impl_dx11.cpp) - ImGui_ImplWin32_Init(my_hwnd); - ImGui_ImplDX11_Init(my_d3d_device, my_d3d_device_context); - - // Application main loop - while (true) - { - // Beginning of frame: update Renderer + Platform backend, start Dear ImGui frame - ImGui_ImplDX11_NewFrame(); - ImGui_ImplWin32_NewFrame(); - ImGui::NewFrame(); - - // Any application code here - ImGui::Text("Hello, world!"); - - // End of frame: render Dear ImGui - ImGui::Render(); - ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData()); - - // Swap - g_pSwapChain->Present(1, 0); - } - - // Shutdown - ImGui_ImplDX11_Shutdown(); - ImGui_ImplWin32_Shutdown(); - ImGui::DestroyContext(); - -Please read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup Dear ImGui in your codebase. -Please read the comments and instruction at the top of each file. -Please read FAQ at http://www.dearimgui.org/faq - -If you are using of the backend provided here, you can add the backends/imgui_impl_xxxx(.cpp,.h) -files to your project and use as-in. Each imgui_impl_xxxx.cpp file comes with its own individual -Changelog, so if you want to update them later it will be easier to catch up with what changed. - - -### Examples Applications - -[example_allegro5/](https://github.com/ocornut/imgui/blob/master/examples/example_allegro5/)
    -Allegro 5 example.
    -= main.cpp + imgui_impl_allegro5.cpp - -[example_android_opengl3/](https://github.com/ocornut/imgui/blob/master/examples/example_android_opengl3/)
    -Android + OpenGL3 (ES) example.
    -= main.cpp + imgui_impl_android.cpp + imgui_impl_opengl3.cpp - -[example_apple_metal/](https://github.com/ocornut/imgui/blob/master/examples/example_metal/)
    -OSX & iOS + Metal example.
    -= main.m + imgui_impl_osx.mm + imgui_impl_metal.mm
    -It is based on the "cross-platform" game template provided with Xcode as of Xcode 9. -(NB: imgui_impl_osx.mm is currently not as feature complete as other platforms backends. -You may prefer to use the GLFW Or SDL backends, which will also support Windows and Linux.) - -[example_apple_opengl2/](https://github.com/ocornut/imgui/blob/master/examples/example_apple_opengl2/)
    -OSX + OpenGL2 example.
    -= main.mm + imgui_impl_osx.mm + imgui_impl_opengl2.cpp
    -(NB: imgui_impl_osx.mm is currently not as feature complete as other platforms backends. - You may prefer to use the GLFW Or SDL backends, which will also support Windows and Linux.) - -[example_emscripten_opengl3/](https://github.com/ocornut/imgui/blob/master/examples/example_emscripten_opengl3/)
    -Emcripten + SDL2 + OpenGL3+/ES2/ES3 example.
    -= main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl3.cpp
    -Note that other examples based on SDL or GLFW + OpenGL could easily be modified to work with Emscripten. -We provide this to make the Emscripten differences obvious, and have them not pollute all other examples. - -[example_emscripten_wgpu/](https://github.com/ocornut/imgui/blob/master/examples/example_emscripten_wgpu/)
    -Emcripten + GLFW + WebGPU example.
    -= main.cpp + imgui_impl_glfw.cpp + imgui_impl_wgpu.cpp - -[example_glfw_metal/](https://github.com/ocornut/imgui/blob/master/examples/example_glfw_metal/)
    -GLFW (Mac) + Metal example.
    -= main.mm + imgui_impl_glfw.cpp + imgui_impl_metal.mm - -[example_glfw_opengl2/](https://github.com/ocornut/imgui/blob/master/examples/example_glfw_opengl2/)
    -GLFW + OpenGL2 example (legacy, fixed pipeline).
    -= main.cpp + imgui_impl_glfw.cpp + imgui_impl_opengl2.cpp
    -**DO NOT USE THIS IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
    -This code is mostly provided as a reference to learn about Dear ImGui integration, because it is shorter. -If your code is using GL3+ context or any semi modern OpenGL calls, using this renderer is likely to -make things more complicated, will require your code to reset many OpenGL attributes to their initial -state, and might confuse your GPU driver. One star, not recommended. - -[example_glfw_opengl3/](https://github.com/ocornut/imgui/blob/master/examples/example_glfw_opengl3/)
    -GLFW (Win32, Mac, Linux) + OpenGL3+/ES2/ES3 example (modern, programmable pipeline).
    -= main.cpp + imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
    -This uses more modern OpenGL calls and custom shaders.
    -This may actually also work with OpenGL 2.x contexts!
    -Prefer using that if you are using modern OpenGL in your application (anything with shaders). - -[example_glfw_vulkan/](https://github.com/ocornut/imgui/blob/master/examples/example_glfw_vulkan/)
    -GLFW (Win32, Mac, Linux) + Vulkan example.
    -= main.cpp + imgui_impl_glfw.cpp + imgui_impl_vulkan.cpp
    -This is quite long and tedious, because: Vulkan. -For this example, the main.cpp file exceptionally use helpers function from imgui_impl_vulkan.h/cpp. - -[example_glut_opengl2/](https://github.com/ocornut/imgui/blob/master/examples/example_glut_opengl2/)
    -GLUT (e.g., FreeGLUT on Linux/Windows, GLUT framework on OSX) + OpenGL2 example.
    -= main.cpp + imgui_impl_glut.cpp + imgui_impl_opengl2.cpp
    -Note that GLUT/FreeGLUT is largely obsolete software, prefer using GLFW or SDL. - -[example_marmalade/](https://github.com/ocornut/imgui/blob/master/examples/example_marmalade/)
    -Marmalade example using IwGx.
    -= main.cpp + imgui_impl_marmalade.cpp - -[example_null/](https://github.com/ocornut/imgui/blob/master/examples/example_null/)
    -Null example, compile and link imgui, create context, run headless with no inputs and no graphics output.
    -= main.cpp
    -This is used to quickly test compilation of core imgui files in as many setups as possible. -Because this application doesn't create a window nor a graphic context, there's no graphics output. - -[example_sdl_directx11/](https://github.com/ocornut/imgui/blob/master/examples/example_sdl_directx11/)
    -SDL2 + DirectX11 example, Windows only.
    -= main.cpp + imgui_impl_sdl.cpp + imgui_impl_dx11.cpp
    -This to demonstrate usage of DirectX with SDL. - -[example_sdl_metal/](https://github.com/ocornut/imgui/blob/master/examples/example_sdl_metal/)
    -SDL2 (Mac) + Metal example.
    -= main.mm + imgui_impl_sdl.cpp + imgui_impl_metal.mm - -[example_sdl_opengl2/](https://github.com/ocornut/imgui/blob/master/examples/example_sdl_opengl2/)
    -SDL2 (Win32, Mac, Linux etc.) + OpenGL example (legacy, fixed pipeline).
    -= main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl2.cpp
    -**DO NOT USE OPENGL2 CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
    -This code is mostly provided as a reference to learn about Dear ImGui integration, because it is shorter. -If your code is using GL3+ context or any semi modern OpenGL calls, using this renderer is likely to -make things more complicated, will require your code to reset many OpenGL attributes to their initial -state, and might confuse your GPU driver. One star, not recommended. - -[example_sdl_opengl3/](https://github.com/ocornut/imgui/blob/master/examples/example_sdl_opengl3/)
    -SDL2 (Win32, Mac, Linux, etc.) + OpenGL3+/ES2/ES3 example.
    -= main.cpp + imgui_impl_sdl.cpp + imgui_impl_opengl3.cpp
    -This uses more modern OpenGL calls and custom shaders.
    -This may actually also work with OpenGL 2.x contexts!
    - -[example_sdl_sdlrenderer/](https://github.com/ocornut/imgui/blob/master/examples/example_sdl_sdlrenderer/)
    -SDL2 (Win32, Mac, Linux, etc.) + SDL_Renderer (most graphics backends are supported underneath)
    -= main.cpp + imgui_impl_sdl.cpp + imgui_impl_sdlrenderer.cpp
    -This requires SDL 2.0.17+ (expected to release November 2021)
    -We do not really recommend using SDL_Renderer as it is a rather primitive API. - -[example_sdl_vulkan/](https://github.com/ocornut/imgui/blob/master/examples/example_sdl_vulkan/)
    -SDL2 (Win32, Mac, Linux, etc.) + Vulkan example.
    -= main.cpp + imgui_impl_sdl.cpp + imgui_impl_vulkan.cpp
    -This is quite long and tedious, because: Vulkan.
    -For this example, the main.cpp file exceptionally use helpers function from imgui_impl_vulkan.h/cpp. - -[example_win32_directx9/](https://github.com/ocornut/imgui/blob/master/examples/example_win32_directx9/)
    -DirectX9 example, Windows only.
    -= main.cpp + imgui_impl_win32.cpp + imgui_impl_dx9.cpp - -[example_win32_directx10/](https://github.com/ocornut/imgui/blob/master/examples/example_win32_directx10/)
    -DirectX10 example, Windows only.
    -= main.cpp + imgui_impl_win32.cpp + imgui_impl_dx10.cpp - -[example_win32_directx11/](https://github.com/ocornut/imgui/blob/master/examples/example_win32_directx11/)
    -DirectX11 example, Windows only.
    -= main.cpp + imgui_impl_win32.cpp + imgui_impl_dx11.cpp - -[example_win32_directx12/](https://github.com/ocornut/imgui/blob/master/examples/example_win32_directx12/)
    -DirectX12 example, Windows only.
    -= main.cpp + imgui_impl_win32.cpp + imgui_impl_dx12.cpp
    -This is quite long and tedious, because: DirectX12. - - -### Miscallaneous - -**Building** - -Unfortunately nowadays it is still tedious to create and maintain portable build files using external -libraries (the kind we're using here to create a window and render 3D triangles) without relying on -third party software and build systems. For most examples here we choose to provide: - - Makefiles for Linux/OSX - - Batch files for Visual Studio 2008+ - - A .sln project file for Visual Studio 2012+ - - Xcode project files for the Apple examples -Please let us know if they don't work with your setup! -You can probably just import the imgui_impl_xxx.cpp/.h files into your own codebase or compile those -directly with a command-line compiler. - -If you are interested in using Cmake to build and links examples, see: - https://github.com/ocornut/imgui/pull/1713 and https://github.com/ocornut/imgui/pull/3027 - -**About mouse cursor latency** - -Dear ImGui has no particular extra lag for most behaviors, -e.g. the value of 'io.MousePos' provided at the time of NewFrame() will result in windows being moved -to the right spot at the time of EndFrame()/Render(). At 60 FPS your experience should be pleasant. - -However, consider that OS mouse cursors are typically drawn through a very specific hardware accelerated -path and will feel smoother than the majority of contents rendered via regular graphics API (including, -but not limited to Dear ImGui windows). Because UI rendering and interaction happens on the same plane -as the mouse, that disconnect may be jarring to particularly sensitive users. -You may experiment with enabling the io.MouseDrawCursor flag to request Dear ImGui to draw a mouse cursor -using the regular graphics API, to help you visualize the difference between a "hardware" cursor and a -regularly rendered software cursor. -However, rendering a mouse cursor at 60 FPS will feel sluggish so you likely won't want to enable that at -all times. It might be beneficial for the user experience to switch to a software rendered cursor _only_ -when an interactive drag is in progress. - -Note that some setup or GPU drivers are likely to be causing extra display lag depending on their settings. -If you feel that dragging windows feels laggy and you are not sure what the cause is: try to build a simple -drawing a flat 2D shape directly under the mouse cursor! - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/docs/FAQ.md b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/docs/FAQ.md deleted file mode 100644 index 479bce0..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/docs/FAQ.md +++ /dev/null @@ -1,675 +0,0 @@ -# FAQ (Frequenty Asked Questions) - -You may link to this document using short form: - https://www.dearimgui.org/faq -or its real address: - https://github.com/ocornut/imgui/blob/master/docs/FAQ.md -or view this file with any Markdown viewer. - - -## Index - -| **Q&A: Basics** | -:---------------------------------------------------------- | -| [Where is the documentation?](#q-where-is-the-documentation) | -| [What is this library called?](#q-what-is-this-library-called) | -| [Which version should I get?](#q-which-version-should-i-get) | -| **Q&A: Integration** | -| **[How to get started?](#q-how-to-get-started)** | -| **[How can I tell whether to dispatch mouse/keyboard to Dear ImGui or my application?](#q-how-can-i-tell-whether-to-dispatch-mousekeyboard-to-dear-imgui-or-my-application)** | -| [How can I enable keyboard or gamepad controls?](#q-how-can-i-enable-keyboard-or-gamepad-controls) | -| [How can I use this on a machine without mouse, keyboard or screen? (input share, remote display)](#q-how-can-i-use-this-on-a-machine-without-mouse-keyboard-or-screen-input-share-remote-display) | -| [I integrated Dear ImGui in my engine and little squares are showing instead of text...](#q-i-integrated-dear-imgui-in-my-engine-and-little-squares-are-showing-instead-of-text) | -| [I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around...](#q-i-integrated-dear-imgui-in-my-engine-and-some-elements-are-clipping-or-disappearing-when-i-move-windows-around) | -| [I integrated Dear ImGui in my engine and some elements are displaying outside their expected windows boundaries...](#q-i-integrated-dear-imgui-in-my-engine-and-some-elements-are-displaying-outside-their-expected-windows-boundaries) | -| **Q&A: Usage** | -| **[About the ID Stack system..
    Why is my widget not reacting when I click on it?
    How can I have widgets with an empty label?
    How can I have multiple widgets with the same label?](#q-about-the-id-stack-system)** | -| [How can I display an image? What is ImTextureID, how does it work?](#q-how-can-i-display-an-image-what-is-imtextureid-how-does-it-work)| -| [How can I use my own math types instead of ImVec2/ImVec4?](#q-how-can-i-use-my-own-math-types-instead-of-imvec2imvec4) | -| [How can I interact with standard C++ types (such as std::string and std::vector)?](#q-how-can-i-interact-with-standard-c-types-such-as-stdstring-and-stdvector) | -| [How can I display custom shapes? (using low-level ImDrawList API)](#q-how-can-i-display-custom-shapes-using-low-level-imdrawlist-api) | -| **Q&A: Fonts, Text** | -| [How should I handle DPI in my application?](#q-how-should-i-handle-dpi-in-my-application) | -| [How can I load a different font than the default?](#q-how-can-i-load-a-different-font-than-the-default) | -| [How can I easily use icons in my application?](#q-how-can-i-easily-use-icons-in-my-application) | -| [How can I load multiple fonts?](#q-how-can-i-load-multiple-fonts) | -| [How can I display and input non-Latin characters such as Chinese, Japanese, Korean, Cyrillic?](#q-how-can-i-display-and-input-non-latin-characters-such-as-chinese-japanese-korean-cyrillic) | -| **Q&A: Concerns** | -| [Who uses Dear ImGui?](#q-who-uses-dear-imgui) | -| [Can you create elaborate/serious tools with Dear ImGui?](#q-can-you-create-elaborateserious-tools-with-dear-imgui) | -| [Can you reskin the look of Dear ImGui?](#q-can-you-reskin-the-look-of-dear-imgui) | -| [Why using C++ (as opposed to C)?](#q-why-using-c-as-opposed-to-c) | -| **Q&A: Community** | -| [How can I help?](#q-how-can-i-help) | - - -# Q&A: Basics - -### Q: Where is the documentation? - -**This library is poorly documented at the moment and expects the user to be acquainted with C/C++.** -- The [Wiki](https://github.com/ocornut/imgui/wiki) is a hub to many resources and links. -- Dozens of standalone example applications using e.g. OpenGL/DirectX are provided in the [examples/](https://github.com/ocornut/imgui/blob/master/examples/) folder to explain how to integrate Dear ImGui with your own engine/application. You can run those applications and explore them. -- See demo code in [imgui_demo.cpp](https://github.com/ocornut/imgui/blob/master/imgui_demo.cpp) and particularly the `ImGui::ShowDemoWindow()` function. The demo covers most features of Dear ImGui, so you can read the code and see its output. -- See documentation: [Backends](https://github.com/ocornut/imgui/blob/master/docs/BACKENDS.md), [Examples](https://github.com/ocornut/imgui/blob/master/docs/EXAMPLES.md), [Fonts](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md). -- See documentation and comments at the top of [imgui.cpp](https://github.com/ocornut/imgui/blob/master/imgui.cpp) + general API comments in [imgui.h](https://github.com/ocornut/imgui/blob/master/imgui.h). -- The [Glossary](https://github.com/ocornut/imgui/wiki/Glossary) page may be useful. -- The [Issues](https://github.com/ocornut/imgui/issues) and [Discussions](https://github.com/ocornut/imgui/discussions) sections can be searched for past questions and issues. -- Your programming IDE is your friend, find the type or function declaration to find comments associated with it. -- The `ImGui::ShowMetricsWindow()` function exposes lots of internal information and tools. Although it is primary designed as a debugging tool, having access to that information tends to help understands concepts. - -##### [Return to Index](#index) - ---- - -### Q. What is this library called? - -**This library is called Dear ImGui**. Please refer to it as Dear ImGui (not ImGui, not IMGUI). - -(The library misleadingly started its life in 2014 as "ImGui" due to the fact that I didn't give it a proper name when I released 1.0, and had no particular expectation that it would take off. However, the term IMGUI (immediate-mode graphical user interface) was coined before and is being used in variety of other situations e.g. Unity uses it own implementation of the IMGUI paradigm. To reduce the ambiguity without affecting existing code bases, I have decided in December 2015 a fully qualified name "Dear ImGui" for this library. - -##### [Return to Index](#index) - ---- - -### Q: Which version should I get? -I occasionally tag [Releases](https://github.com/ocornut/imgui/releases) but it is generally safe and recommended to sync to master/latest. The library is fairly stable and regressions tend to be fixed fast when reported. - -You may use the [docking](https://github.com/ocornut/imgui/tree/docking) branch which includes: -- [Docking features](https://github.com/ocornut/imgui/issues/2109) -- [Multi-viewport features](https://github.com/ocornut/imgui/issues/1542) - -Many projects are using this branch and it is kept in sync with master regularly. - -##### [Return to Index](#index) - ----- - -# Q&A: Integration - -### Q: How to get started? - -Read [EXAMPLES.md](https://github.com/ocornut/imgui/blob/master/docs/EXAMPLES.md).
    -Read [BACKENDS.md](https://github.com/ocornut/imgui/blob/master/docs/BACKENDS.md).
    -Read `PROGRAMMER GUIDE` section of [imgui.cpp](https://github.com/ocornut/imgui/blob/master/imgui.cpp).
    -The [Wiki](https://github.com/ocornut/imgui/wiki) is a hub to many resources and links. - -For first-time users having issues compiling/linking/running or issues loading fonts, please use [GitHub Discussions](https://github.com/ocornut/imgui/discussions). - -##### [Return to Index](#index) - ---- - -### Q: How can I tell whether to dispatch mouse/keyboard to Dear ImGui or my application? - -You can read the `io.WantCaptureMouse`, `io.WantCaptureKeyboard` and `io.WantTextInput` flags from the ImGuiIO structure. -- When `io.WantCaptureMouse` is set, you need to discard/hide the mouse inputs from your underlying application. -- When `io.WantCaptureKeyboard` is set, you need to discard/hide the keyboard inputs from your underlying application. -- When `io.WantTextInput` is set, you can notify your OS/engine to popup an on-screen keyboard, if available (e.g. on a mobile phone, or console OS). - -Important: you should always pass your mouse/keyboard inputs to Dear ImGui, regardless of the value `io.WantCaptureMouse`/`io.WantCaptureKeyboard`. This is because e.g. we need to detect that you clicked in the void to unfocus its own windows, and other reasons. - -```cpp -void MyLowLevelMouseButtonHandler(int button, bool down) -{ - // (1) ALWAYS forward mouse data to ImGui! This is automatic with default backends. With your own backend: - ImGuiIO& io = ImGui::GetIO(); - io.MouseDown[button] = down; - - // (2) ONLY forward mouse data to your underlying app/game. - if (!io.WantCaptureMouse) - my_game->HandleMouseData(...); -} -``` - - -**Note:** The `io.WantCaptureMouse` is more correct that any manual attempt to "check if the mouse is hovering a window" (don't do that!). It handle mouse dragging correctly (both dragging that started over your application or over a Dear ImGui window) and handle e.g. popup and modal windows blocking inputs. - -**Note:** Those flags are updated by `ImGui::NewFrame()`. However it is generally more correct and easier that you poll flags from the previous frame, then submit your inputs, then call `NewFrame()`. If you attempt to do the opposite (which is generally harder) you are likely going to submit your inputs after `NewFrame()`, and therefore too late. - -**Note:** If you are using a touch device, you may find use for an early call to `UpdateHoveredWindowAndCaptureFlags()` to correctly dispatch your initial touch. We will work on better out-of-the-box touch support in the future. - -**Note:** Text input widget releases focus on the "KeyDown" event of the Return key, so the subsequent "KeyUp" event that your application receive will typically have `io.WantCaptureKeyboard == false`. Depending on your application logic it may or not be inconvenient to receive that KeyUp event. You might want to track which key-downs were targeted for Dear ImGui, e.g. with an array of bool, and filter out the corresponding key-ups.) - -##### [Return to Index](#index) - ---- - -### Q: How can I enable keyboard or gamepad controls? -- The gamepad/keyboard navigation is fairly functional and keeps being improved. The initial focus was to support game controllers, but keyboard is becoming increasingly and decently usable. Gamepad support is particularly useful to use Dear ImGui on a game console (e.g. PS4, Switch, XB1) without a mouse connected! -- Keyboard: set `io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard` to enable. -- Gamepad: set `io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad` to enable (with a supporting backend). -- See [Control Sheets for Gamepads](http://www.dearimgui.org/controls_sheets) (reference PNG/PSD for for PS4, XB1, Switch gamepads). -- See `USING GAMEPAD/KEYBOARD NAVIGATION CONTROLS` section of [imgui.cpp](https://github.com/ocornut/imgui/blob/master/imgui.cpp) for more details. - -##### [Return to Index](#index) - ---- - -### Q: How can I use this on a machine without mouse, keyboard or screen? (input share, remote display) -- You can share your computer mouse seamlessly with your console/tablet/phone using solutions such as [Synergy](https://symless.com/synergy) -This is the preferred solution for developer productivity. -In particular, the [micro-synergy-client repository](https://github.com/symless/micro-synergy-client) has simple -and portable source code (uSynergy.c/.h) for a small embeddable client that you can use on any platform to connect -to your host computer, based on the Synergy 1.x protocol. Make sure you download the Synergy 1 server on your computer. -Console SDK also sometimes provide equivalent tooling or wrapper for Synergy-like protocols. -- Game console users: consider emulating a mouse cursor with DualShock4 touch pad or a spare analog stick as a mouse-emulation fallback. -- You may also use a third party solution such as [netImgui](https://github.com/sammyfreg/netImgui), [Remote ImGui](https://github.com/JordiRos/remoteimgui) or [imgui-ws](https://github.com/ggerganov/imgui-ws) which sends the vertices to render over the local network, allowing you to use Dear ImGui even on a screen-less machine. See [Wiki](https://github.com/ocornut/imgui/wiki) index for most details. -- For touch inputs, you can increase the hit box of widgets (via the `style.TouchPadding` setting) to accommodate for the lack of precision of touch inputs, but it is recommended you use a mouse or gamepad to allow optimizing for screen real-estate and precision. - -##### [Return to Index](#index) - ---- - -### Q: I integrated Dear ImGui in my engine and little squares are showing instead of text... -Your renderer is not using the font texture correctly or it hasn't been uploaded to the GPU. -- If this happens using the standard backends: A) have you modified the font atlas after `ImGui_ImplXXX_NewFrame()`? B) maybe the texture failed to upload, which could happens if for some reason your texture is too big. Also see [docs/FONTS.md](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md). -- If this happens with a custom backend: make sure you have uploaded the font texture to the GPU, that all shaders are rendering states are setup properly (e.g. texture is bound). Compare your code to existing backends and use a graphics debugger such as [RenderDoc](https://renderdoc.org) to debug your rendering states. - -##### [Return to Index](#index) - ---- - -### Q: I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around... -### Q: I integrated Dear ImGui in my engine and some elements are displaying outside their expected windows boundaries... -You are probably mishandling the clipping rectangles in your render function. -Each draw command needs the triangle rendered using the clipping rectangle provided in the ImDrawCmd structure (`ImDrawCmd->CllipRect`). -Rectangles provided by Dear ImGui are defined as -`(x1=left,y1=top,x2=right,y2=bottom)` -and **NOT** as -`(x1,y1,width,height)` -Refer to rendering backends in the [examples/](https://github.com/ocornut/imgui/tree/master/examples) folder for references of how to handle the `ClipRect` field. - -##### [Return to Index](#index) - ---- - -# Q&A: Usage - -### Q: About the ID Stack system... -### Q: Why is my widget not reacting when I click on it? -### Q: How can I have widgets with an empty label? -### Q: How can I have multiple widgets with the same label? - -A primer on labels and the ID Stack... - -Dear ImGui internally needs to uniquely identify UI elements. -Elements that are typically not clickable (such as calls to the Text functions) don't need an ID. -Interactive widgets (such as calls to Button buttons) need a unique ID. - -**Unique ID are used internally to track active widgets and occasionally associate state to widgets.
    -Unique ID are implicitly built from the hash of multiple elements that identify the "path" to the UI element.** - -Since Dear ImGui 1.85 you can use `Demo>Tools>Stack Tool` or call `ImGui::ShowStackToolWindow()`. The tool display intermediate values leading to the creation of a unique ID, making things easier to debug and understand. - -![Stack tool](https://user-images.githubusercontent.com/8225057/136235657-a0ea5665-dcd1-423f-9be6-dc3f8ced8f12.png) - -- Unique ID are often derived from a string label and at minimum scoped within their host window: -```cpp -Begin("MyWindow"); -Button("OK"); // Label = "OK", ID = hash of ("MyWindow", "OK") -Button("Cancel"); // Label = "Cancel", ID = hash of ("MyWindow", "Cancel") -End(); -``` -- Other elements such as tree nodes, etc. also pushes to the ID stack: -```cpp -Begin("MyWindow"); -if (TreeNode("MyTreeNode")) -{ - Button("OK"); // Label = "OK", ID = hash of ("MyWindow", "MyTreeNode", "OK") - TreePop(); -} -End(); -``` -- Two items labeled "OK" in different windows or different tree locations won't collide: -```cpp -Begin("MyFirstWindow"); -Button("OK"); // Label = "OK", ID = hash of ("MyFirstWindow", "OK") -End(); -Begin("MyOtherWindow"); -Button("OK"); // Label = "OK", ID = hash of ("MyOtherWindow", "OK") -End(); -``` - -- If you have a same ID twice in the same location, you'll have a conflict: -```cpp -Begin("MyWindow"); -Button("OK"); -Button("OK"); // ERROR: ID collision with the first button! Interacting with either button will trigger the first one. -Button(""); // ERROR: ID collision with Begin("MyWindow")! -End(); -``` -Fear not! this is easy to solve and there are many ways to solve it! - -- Solving ID conflict in a simple/local context: -When passing a label you can optionally specify extra ID information within string itself. -Use "##" to pass a complement to the ID that won't be visible to the end-user. -This helps solving the simple collision cases when you know e.g. at compilation time which items -are going to be created: -```cpp -Begin("MyWindow"); -Button("Play"); // Label = "Play", ID = hash of ("MyWindow", "Play") -Button("Play##foo1"); // Label = "Play", ID = hash of ("MyWindow", "Play##foo1") // Different from other buttons -Button("Play##foo2"); // Label = "Play", ID = hash of ("MyWindow", "Play##foo2") // Different from other buttons -Button("##foo"); // Label = "", ID = hash of ("MyWindow", "##foo") // Different from window -End(); -``` -- If you want to completely hide the label, but still need an ID: -```cpp -Checkbox("##On", &b); // Label = "", ID = hash of (..., "##On") // No visible label, just a checkbox! -``` -- Occasionally/rarely you might want change a label while preserving a constant ID. This allows -you to animate labels. For example you may want to include varying information in a window title bar, -but windows are uniquely identified by their ID. Use "###" to pass a label that isn't part of ID: -```cpp -Button("Hello###ID"); // Label = "Hello", ID = hash of (..., "###ID") -Button("World###ID"); // Label = "World", ID = hash of (..., "###ID") // Same ID, different label - -sprintf(buf, "My game (%f FPS)###MyGame", fps); -Begin(buf); // Variable title, ID = hash of "MyGame" -``` -- Solving ID conflict in a more general manner: -Use `PushID()` / `PopID()` to create scopes and manipulate the ID stack, as to avoid ID conflicts -within the same window. This is the most convenient way of distinguishing ID when iterating and -creating many UI elements programmatically. -You can push a pointer, a string or an integer value into the ID stack. -Remember that ID are formed from the concatenation of _everything_ pushed into the ID stack. -At each level of the stack we store the seed used for items at this level of the ID stack. -```cpp -Begin("Window"); -for (int i = 0; i < 100; i++) -{ - PushID(i); // Push i to the id tack - Button("Click"); // Label = "Click", ID = hash of ("Window", i, "Click") - PopID(); -} -for (int i = 0; i < 100; i++) -{ - MyObject* obj = Objects[i]; - PushID(obj); - Button("Click"); // Label = "Click", ID = hash of ("Window", obj pointer, "Click") - PopID(); -} -for (int i = 0; i < 100; i++) -{ - MyObject* obj = Objects[i]; - PushID(obj->Name); - Button("Click"); // Label = "Click", ID = hash of ("Window", obj->Name, "Click") - PopID(); -} -End(); -``` -- You can stack multiple prefixes into the ID stack: -```cpp -Button("Click"); // Label = "Click", ID = hash of (..., "Click") -PushID("node"); - Button("Click"); // Label = "Click", ID = hash of (..., "node", "Click") - PushID(my_ptr); - Button("Click"); // Label = "Click", ID = hash of (..., "node", my_ptr, "Click") - PopID(); -PopID(); -``` -- Tree nodes implicitly creates a scope for you by calling `PushID()`: -```cpp -Button("Click"); // Label = "Click", ID = hash of (..., "Click") -if (TreeNode("node")) // <-- this function call will do a PushID() for you (unless instructed not to, with a special flag) -{ - Button("Click"); // Label = "Click", ID = hash of (..., "node", "Click") - TreePop(); -} -``` - -When working with trees, ID are used to preserve the open/close state of each tree node. -Depending on your use cases you may want to use strings, indices or pointers as ID. -- e.g. when following a single pointer that may change over time, using a static string as ID -will preserve your node open/closed state when the targeted object change. -- e.g. when displaying a list of objects, using indices or pointers as ID will preserve the -node open/closed state differently. See what makes more sense in your situation! - -##### [Return to Index](#index) - ---- - -### Q: How can I display an image? What is ImTextureID, how does it work? - -Short explanation: -- Refer to [Image Loading and Displaying Examples](https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples) on the [Wiki](https://github.com/ocornut/imgui/wiki). -- You may use functions such as `ImGui::Image()`, `ImGui::ImageButton()` or lower-level `ImDrawList::AddImage()` to emit draw calls that will use your own textures. -- Actual textures are identified in a way that is up to the user/engine. Those identifiers are stored and passed as ImTextureID (void*) value. -- Loading image files from the disk and turning them into a texture is not within the scope of Dear ImGui (for a good reason). - -**Please read documentations or tutorials on your graphics API to understand how to display textures on the screen before moving onward.** - -Long explanation: -- Dear ImGui's job is to create "meshes", defined in a renderer-agnostic format made of draw commands and vertices. At the end of the frame those meshes (ImDrawList) will be displayed by your rendering function. They are made up of textured polygons and the code to render them is generally fairly short (a few dozen lines). In the examples/ folder we provide functions for popular graphics API (OpenGL, DirectX, etc.). -- Each rendering function decides on a data type to represent "textures". The concept of what is a "texture" is entirely tied to your underlying engine/graphics API. - We carry the information to identify a "texture" in the ImTextureID type. -ImTextureID is nothing more that a void*, aka 4/8 bytes worth of data: just enough to store 1 pointer or 1 integer of your choice. -Dear ImGui doesn't know or understand what you are storing in ImTextureID, it merely pass ImTextureID values until they reach your rendering function. -- In the [examples/](https://github.com/ocornut/imgui/tree/master/examples) backends, for each graphics API we decided on a type that is likely to be a good representation for specifying an image from the end-user perspective. This is what the _examples_ rendering functions are using: -```cpp -OpenGL: -- ImTextureID = GLuint -- See ImGui_ImplOpenGL3_RenderDrawData() function in imgui_impl_opengl3.cpp -``` -```cpp -DirectX9: -- ImTextureID = LPDIRECT3DTEXTURE9 -- See ImGui_ImplDX9_RenderDrawData() function in imgui_impl_dx9.cpp -``` -```cpp -DirectX11: -- ImTextureID = ID3D11ShaderResourceView* -- See ImGui_ImplDX11_RenderDrawData() function in imgui_impl_dx11.cpp -``` -```cpp -DirectX12: -- ImTextureID = D3D12_GPU_DESCRIPTOR_HANDLE -- See ImGui_ImplDX12_RenderDrawData() function in imgui_impl_dx12.cpp -``` -For example, in the OpenGL example backend we store raw OpenGL texture identifier (GLuint) inside ImTextureID. -Whereas in the DirectX11 example backend we store a pointer to ID3D11ShaderResourceView inside ImTextureID, which is a higher-level structure tying together both the texture and information about its format and how to read it. - -- If you have a custom engine built over e.g. OpenGL, instead of passing GLuint around you may decide to use a high-level data type to carry information about the texture as well as how to display it (shaders, etc.). The decision of what to use as ImTextureID can always be made better knowing how your codebase is designed. If your engine has high-level data types for "textures" and "material" then you may want to use them. -If you are starting with OpenGL or DirectX or Vulkan and haven't built much of a rendering engine over them, keeping the default ImTextureID representation suggested by the example backends is probably the best choice. -(Advanced users may also decide to keep a low-level type in ImTextureID, and use ImDrawList callback and pass information to their renderer) - -User code may do: -```cpp -// Cast our texture type to ImTextureID / void* -MyTexture* texture = g_CoffeeTableTexture; -ImGui::Image((void*)texture, ImVec2(texture->Width, texture->Height)); -``` -The renderer function called after ImGui::Render() will receive that same value that the user code passed: -```cpp -// Cast ImTextureID / void* stored in the draw command as our texture type -MyTexture* texture = (MyTexture*)pcmd->GetTexID(); -MyEngineBindTexture2D(texture); -``` -Once you understand this design you will understand that loading image files and turning them into displayable textures is not within the scope of Dear ImGui. -This is by design and is actually a good thing, because it means your code has full control over your data types and how you display them. -If you want to display an image file (e.g. PNG file) into the screen, please refer to documentation and tutorials for the graphics API you are using. - -Refer to [Image Loading and Displaying Examples](https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples) on the [Wiki](https://github.com/ocornut/imgui/wiki) to find simplified examples for loading textures with OpenGL, DirectX9 and DirectX11. - -C/C++ tip: a void* is pointer-sized storage. You may safely store any pointer or integer into it by casting your value to ImTextureID / void*, and vice-versa. -Because both end-points (user code and rendering function) are under your control, you know exactly what is stored inside the ImTextureID / void*. -Examples: -```cpp -GLuint my_tex = XXX; -void* my_void_ptr; -my_void_ptr = (void*)(intptr_t)my_tex; // cast a GLuint into a void* (we don't take its address! we literally store the value inside the pointer) -my_tex = (GLuint)(intptr_t)my_void_ptr; // cast a void* into a GLuint - -ID3D11ShaderResourceView* my_dx11_srv = XXX; -void* my_void_ptr; -my_void_ptr = (void*)my_dx11_srv; // cast a ID3D11ShaderResourceView* into an opaque void* -my_dx11_srv = (ID3D11ShaderResourceView*)my_void_ptr; // cast a void* into a ID3D11ShaderResourceView* -``` -Finally, you may call `ImGui::ShowMetricsWindow()` to explore/visualize/understand how the ImDrawList are generated. - -##### [Return to Index](#index) - ---- - -### Q: How can I use my own math types instead of ImVec2/ImVec4? - -You can edit [imconfig.h](https://github.com/ocornut/imgui/blob/master/imconfig.h) and setup the `IM_VEC2_CLASS_EXTRA`/`IM_VEC4_CLASS_EXTRA` macros to add implicit type conversions. -This way you'll be able to use your own types everywhere, e.g. passing `MyVector2` or `glm::vec2` to ImGui functions instead of `ImVec2`. - -##### [Return to Index](#index) - ---- - -### Q: How can I interact with standard C++ types (such as std::string and std::vector)? -- Being highly portable (backends/bindings for several languages, frameworks, programming style, obscure or older platforms/compilers), and aiming for compatibility & performance suitable for every modern real-time game engines, dear imgui does not use any of std C++ types. We use raw types (e.g. char* instead of std::string) because they adapt to more use cases. -- To use ImGui::InputText() with a std::string or any resizable string class, see [misc/cpp/imgui_stdlib.h](https://github.com/ocornut/imgui/blob/master/misc/cpp/imgui_stdlib.h). -- To use combo boxes and list boxes with `std::vector` or any other data structure: the `BeginCombo()/EndCombo()` API -lets you iterate and submit items yourself, so does the `ListBoxHeader()/ListBoxFooter()` API. -Prefer using them over the old and awkward `Combo()/ListBox()` api. -- Generally for most high-level types you should be able to access the underlying data type. -You may write your own one-liner wrappers to facilitate user code (tip: add new functions in ImGui:: namespace from your code). -- Dear ImGui applications often need to make intensive use of strings. It is expected that many of the strings you will pass -to the API are raw literals (free in C/C++) or allocated in a manner that won't incur a large cost on your application. -Please bear in mind that using `std::string` on applications with large amount of UI may incur unsatisfactory performances. -Modern implementations of `std::string` often include small-string optimization (which is often a local buffer) but those -are not configurable and not the same across implementations. -- If you are finding your UI traversal cost to be too large, make sure your string usage is not leading to excessive amount -of heap allocations. Consider using literals, statically sized buffers and your own helper functions. A common pattern -is that you will need to build lots of strings on the fly, and their maximum length can be easily be scoped ahead. -One possible implementation of a helper to facilitate printf-style building of strings: https://github.com/ocornut/Str -This is a small helper where you can instance strings with configurable local buffers length. Many game engines will -provide similar or better string helpers. - -##### [Return to Index](#index) - ---- - -### Q: How can I display custom shapes? (using low-level ImDrawList API) - -- You can use the low-level `ImDrawList` api to render shapes within a window. -```cpp -ImGui::Begin("My shapes"); - -ImDrawList* draw_list = ImGui::GetWindowDrawList(); - -// Get the current ImGui cursor position -ImVec2 p = ImGui::GetCursorScreenPos(); - -// Draw a red circle -draw_list->AddCircleFilled(ImVec2(p.x + 50, p.y + 50), 30.0f, IM_COL32(255, 0, 0, 255), 16); - -// Draw a 3 pixel thick yellow line -draw_list->AddLine(ImVec2(p.x, p.y), ImVec2(p.x + 100.0f, p.y + 100.0f), IM_COL32(255, 255, 0, 255), 3.0f); - -// Advance the ImGui cursor to claim space in the window (otherwise the window will appears small and needs to be resized) -ImGui::Dummy(ImVec2(200, 200)); - -ImGui::End(); -``` -![ImDrawList usage](https://raw.githubusercontent.com/wiki/ocornut/imgui/tutorials/CustomRendering01.png) - -- Refer to "Demo > Examples > Custom Rendering" in the demo window and read the code of `ShowExampleAppCustomRendering()` in `imgui_demo.cpp` from more examples. -- To generate colors: you can use the macro `IM_COL32(255,255,255,255)` to generate them at compile time, or use `ImGui::GetColorU32(IM_COL32(255,255,255,255))` or `ImGui::GetColorU32(ImVec4(1.0f,1.0f,1.0f,1.0f))` to generate a color that is multiplied by the current value of `style.Alpha`. -- Math operators: if you have setup `IM_VEC2_CLASS_EXTRA` in `imconfig.h` to bind your own math types, you can use your own math types and their natural operators instead of ImVec2. ImVec2 by default doesn't export any math operators in the public API. You may use `#define IMGUI_DEFINE_MATH_OPERATORS` `#include "imgui_internal.h"` to use the internally defined math operators, but instead prefer using your own math library and set it up in `imconfig.h`. -- You can use `ImGui::GetBackgroundDrawList()` or `ImGui::GetForegroundDrawList()` to access draw lists which will be displayed behind and over every other dear imgui windows (one bg/fg drawlist per viewport). This is very convenient if you need to quickly display something on the screen that is not associated to a dear imgui window. -- You can also create your own empty window and draw inside it. Call Begin() with the NoBackground | NoDecoration | NoSavedSettings | NoInputs flags (The `ImGuiWindowFlags_NoDecoration` flag itself is a shortcut for NoTitleBar | NoResize | NoScrollbar | NoCollapse). Then you can retrieve the ImDrawList* via `GetWindowDrawList()` and draw to it in any way you like. -`- You can create your own ImDrawList instance. You'll need to initialize them with `ImGui::GetDrawListSharedData()`, or create your own instancing ImDrawListSharedData`, and then call your renderer function with your own ImDrawList or ImDrawData data. -- Looking for fun? The [ImDrawList coding party 2020](https://github.com/ocornut/imgui/issues/3606) thread is full of "don't do this at home" extreme uses of the ImDrawList API. - -##### [Return to Index](#index) - ---- - -# Q&A: Fonts, Text - -### Q: How should I handle DPI in my application? - -The short answer is: obtain the desired DPI scale, load your fonts resized with that scale (always round down fonts size to nearest integer), and scale your Style structure accordingly using `style.ScaleAllSizes()`. - -Your application may want to detect DPI change and reload the fonts and reset style between frames. - -Your ui code should avoid using hardcoded constants for size and positioning. Prefer to express values as multiple of reference values such as `ImGui::GetFontSize()` or `ImGui::GetFrameHeight()`. So e.g. instead of seeing a hardcoded height of 500 for a given item/window, you may want to use `30*ImGui::GetFontSize()` instead. - -Down the line Dear ImGui will provide a variety of standardized reference values to facilitate using this. - -Applications in the `examples/` folder are not DPI aware partly because they are unable to load a custom font from the file-system (may change that in the future). - -The reason DPI is not auto-magically solved in stock examples is that we don't yet have a satisfying solution for the "multi-dpi" problem (using the `docking` branch: when multiple viewport windows are over multiple monitors using different DPI scale). The current way to handle this on the application side is: -- Create and maintain one font atlas per active DPI scale (e.g. by iterating `platform_io.Monitors[]` before `NewFrame()`). -- Hook `platform_io.OnChangedViewport()` to detect when a `Begin()` call makes a Dear ImGui window change monitor (and therefore DPI). -- In the hook: swap atlas, swap style with correctly sized one, remap the current font from one atlas to the other (may need to maintain a remapping table of your fonts at variying DPI scale). - -This approach is relatively easy and functional but come with two issues: -- It's not possibly to reliably size or position a window ahead of `Begin()` without knowing on which monitor it'll land. -- Style override may be lost during the `Begin()` call crossing monitor boundaries. You may need to do some custom scaling mumbo-jumbo if you want your `OnChangedViewport()` handler to preserve style overrides. - -Please note that if you are not using multi-viewports with multi-monitors using different DPI scale, you can ignore all of this and use the simpler technique recommended at the top. - -### Q: How can I load a different font than the default? -Use the font atlas to load the TTF/OTF file you want: - -```cpp -ImGuiIO& io = ImGui::GetIO(); -io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels); -io.Fonts->GetTexDataAsRGBA32() or GetTexDataAsAlpha8() -``` - -Default is ProggyClean.ttf, monospace, rendered at size 13, embedded in dear imgui's source code. - -(Tip: monospace fonts are convenient because they allow to facilitate horizontal alignment directly at the string level.) - -(Read the [docs/FONTS.md](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md) file for more details about font loading.) - -New programmers: remember that in C/C++ and most programming languages if you want to use a -backslash \ within a string literal, you need to write it double backslash "\\": - -```cpp -io.Fonts->AddFontFromFileTTF("MyFolder\MyFont.ttf", size); // WRONG (you are escaping the M here!) -io.Fonts->AddFontFromFileTTF("MyFolder\\MyFont.ttf", size; // CORRECT (Windows only) -io.Fonts->AddFontFromFileTTF("MyFolder/MyFont.ttf", size); // ALSO CORRECT -``` - -##### [Return to Index](#index) - ---- - -### Q: How can I easily use icons in my application? -The most convenient and practical way is to merge an icon font such as FontAwesome inside you -main font. Then you can refer to icons within your strings. -You may want to see `ImFontConfig::GlyphMinAdvanceX` to make your icon look monospace to facilitate alignment. -(Read the [docs/FONTS.md](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md) file for more details about icons font loading.) -With some extra effort, you may use colorful icon by registering custom rectangle space inside the font atlas, -and copying your own graphics data into it. See docs/FONTS.md about using the AddCustomRectFontGlyph API. - -##### [Return to Index](#index) - ---- - -### Q: How can I load multiple fonts? -Use the font atlas to pack them into a single texture: -(Read the [docs/FONTS.md](https://github.com/ocornut/imgui/blob/master/docs/FONTS.md) file and the code in ImFontAtlas for more details.) - -```cpp -ImGuiIO& io = ImGui::GetIO(); -ImFont* font0 = io.Fonts->AddFontDefault(); -ImFont* font1 = io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels); -ImFont* font2 = io.Fonts->AddFontFromFileTTF("myfontfile2.ttf", size_in_pixels); -io.Fonts->GetTexDataAsRGBA32() or GetTexDataAsAlpha8() -// the first loaded font gets used by default -// use ImGui::PushFont()/ImGui::PopFont() to change the font at runtime - -// Options -ImFontConfig config; -config.OversampleH = 2; -config.OversampleV = 1; -config.GlyphOffset.y -= 1.0f; // Move everything by 1 pixels up -config.GlyphExtraSpacing.x = 1.0f; // Increase spacing between characters -io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_pixels, &config); - -// Combine multiple fonts into one (e.g. for icon fonts) -static ImWchar ranges[] = { 0xf000, 0xf3ff, 0 }; -ImFontConfig config; -config.MergeMode = true; -io.Fonts->AddFontDefault(); -io.Fonts->AddFontFromFileTTF("fontawesome-webfont.ttf", 16.0f, &config, ranges); // Merge icon font -io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_pixels, NULL, &config, io.Fonts->GetGlyphRangesJapanese()); // Merge japanese glyphs -``` - -##### [Return to Index](#index) - ---- - -### Q: How can I display and input non-Latin characters such as Chinese, Japanese, Korean, Cyrillic? -When loading a font, pass custom Unicode ranges to specify the glyphs to load. - -```cpp -// Add default Japanese ranges -io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels, NULL, io.Fonts->GetGlyphRangesJapanese()); - -// Or create your own custom ranges (e.g. for a game you can feed your entire game script and only build the characters the game need) -ImVector ranges; -ImFontGlyphRangesBuilder builder; -builder.AddText("Hello world"); // Add a string (here "Hello world" contains 7 unique characters) -builder.AddChar(0x7262); // Add a specific character -builder.AddRanges(io.Fonts->GetGlyphRangesJapanese()); // Add one of the default ranges -builder.BuildRanges(&ranges); // Build the final result (ordered ranges with all the unique characters submitted) -io.Fonts->AddFontFromFileTTF("myfontfile.ttf", 16.0f, NULL, ranges.Data); -``` - -All your strings needs to use UTF-8 encoding. In C++11 you can encode a string literal in UTF-8 -by using the u8"hello" syntax. Specifying literal in your source code using a local code page -(such as CP-923 for Japanese or CP-1251 for Cyrillic) will NOT work! -Otherwise you can convert yourself to UTF-8 or load text data from file already saved as UTF-8. - -Text input: it is up to your application to pass the right character code by calling `io.AddInputCharacter()`. -The applications in examples/ are doing that. -Windows: you can use the WM_CHAR or WM_UNICHAR or WM_IME_CHAR message (depending if your app is built using Unicode or MultiByte mode). -You may also use MultiByteToWideChar() or ToUnicode() to retrieve Unicode codepoints from MultiByte characters or keyboard state. -Windows: if your language is relying on an Input Method Editor (IME), you copy the HWND of your window to io.ImeWindowHandle in order for -the default implementation of io.ImeSetInputScreenPosFn() to set your Microsoft IME position correctly. - -##### [Return to Index](#index) - ---- - -# Q&A: Concerns - -### Q: Who uses Dear ImGui? - -You may take a look at: - -- [Quotes](https://github.com/ocornut/imgui/wiki/Quotes) -- [Software using Dear ImGui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) -- [Sponsors](https://github.com/ocornut/imgui/wiki/Sponsors) -- [Gallery](https://github.com/ocornut/imgui/issues/4451) - -##### [Return to Index](#index) - ---- - -### Q: Can you create elaborate/serious tools with Dear ImGui? - -Yes. People have written game editors, data browsers, debuggers, profilers and all sort of non-trivial tools with the library. In my experience the simplicity of the API is very empowering. Your UI runs close to your live data. Make the tools always-on and everybody in the team will be inclined to create new tools (as opposed to more "offline" UI toolkits where only a fraction of your team effectively creates tools). The list of sponsors below is also an indicator that serious game teams have been using the library. - -Dear ImGui is very programmer centric and the immediate-mode GUI paradigm might require you to readjust some habits before you can realize its full potential. Dear ImGui is about making things that are simple, efficient and powerful. - -Dear ImGui is built to be efficient and scalable toward the needs for AAA-quality applications running all day. The IMGUI paradigm offers different opportunities for optimization that the more typical RMGUI paradigm. - -##### [Return to Index](#index) - ---- - -### Q: Can you reskin the look of Dear ImGui? - -Somehow. You can alter the look of the interface to some degree: changing colors, sizes, padding, rounding, fonts. However, as Dear ImGui is designed and optimized to create debug tools, the amount of skinning you can apply is limited. There is only so much you can stray away from the default look and feel of the interface. Dear ImGui is NOT designed to create user interface for games, although with ingenious use of the low-level API you can do it. - -A reasonably skinned application may look like (screenshot from [#2529](https://github.com/ocornut/imgui/issues/2529#issuecomment-524281119)) -![minipars](https://user-images.githubusercontent.com/314805/63589441-d9794f00-c5b1-11e9-8d96-cfc1b93702f7.png) - -##### [Return to Index](#index) - ---- - -### Q: Why using C++ (as opposed to C)? - -Dear ImGui takes advantage of a few C++ languages features for convenience but nothing anywhere Boost insanity/quagmire. Dear ImGui does NOT require C++11 so it can be used with most old C++ compilers. Dear ImGui doesn't use any C++ header file. Language-wise, function overloading and default parameters are used to make the API easier to use and code more terse. Doing so I believe the API is sitting on a sweet spot and giving up on those features would make the API more cumbersome. Other features such as namespace, constructors and templates (in the case of the ImVector<> class) are also relied on as a convenience. - -There is an auto-generated [c-api for Dear ImGui (cimgui)](https://github.com/cimgui/cimgui) by Sonoro1234 and Stephan Dilly. It is designed for creating bindings to other languages. If possible, I would suggest using your target language functionalities to try replicating the function overloading and default parameters used in C++ else the API may be harder to use. Also see [Bindings](https://github.com/ocornut/imgui/wiki/Bindings) for various third-party bindings. - -##### [Return to Index](#index) - ---- - -# Q&A: Community - -### Q: How can I help? -- Businesses: please reach out to `contact AT dearimgui.com` if you work in a place using Dear ImGui! We can discuss ways for your company to fund development via invoiced technical support, maintenance or sponsoring contacts. This is among the most useful thing you can do for Dear ImGui. With increased funding, we can hire more people working on this project. -- Individuals: you can support continued maintenance and development via PayPal donations. See [README](https://github.com/ocornut/imgui/blob/master/docs/README.md). -- If you are experienced with Dear ImGui and C++, look at [GitHub Issues](https://github.com/ocornut/imgui/issues), [GitHub Discussions](https://github.com/ocornut/imgui/discussions), the [Wiki](https://github.com/ocornut/imgui/wiki), read [docs/TODO.txt](https://github.com/ocornut/imgui/blob/master/docs/TODO.txt) and see how you want to help and can help! -- Disclose your usage of Dear ImGui via a dev blog post, a tweet, a screenshot, a mention somewhere etc. -You may post screenshot or links in the [gallery threads](https://github.com/ocornut/imgui/issues/4451). Visuals are ideal as they inspire other programmers. Disclosing your use of Dear ImGui helps the library grow credibility, and help other teams and programmers with taking decisions. -- If you have issues or if you need to hack into the library, even if you don't expect any support it is useful that you share your issues or sometimes incomplete PR. - -##### [Return to Index](#index) - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/docs/FONTS.md b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/docs/FONTS.md deleted file mode 100644 index 09c1cb9..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/docs/FONTS.md +++ /dev/null @@ -1,397 +0,0 @@ -_(You may browse this at https://github.com/ocornut/imgui/blob/master/docs/FONTS.md or view this file with any Markdown viewer)_ - -## Dear ImGui: Using Fonts - -The code in imgui.cpp embeds a copy of 'ProggyClean.ttf' (by Tristan Grimmer), -a 13 pixels high, pixel-perfect font used by default. We embed it in the source code so you can use Dear ImGui without any file system access. ProggyClean does not scale smoothly, therefore it is recommended that you load your own file when using Dear ImGui in an application aiming to look nice and wanting to support multiple resolutions. - -You may also load external .TTF/.OTF files. -In the [misc/fonts/](https://github.com/ocornut/imgui/tree/master/misc/fonts) folder you can find a few suggested fonts, provided as a convenience. - -**Also read the FAQ:** https://www.dearimgui.org/faq (there is a Fonts section!) - -## Index -- [Readme First](#readme-first) -- [How should I handle DPI in my application?](#how-should-i-handle-dpi-in-my-application) -- [Fonts Loading Instructions](#font-loading-instructions) -- [Using Icon Fonts](#using-icon-fonts) -- [Using FreeType Rasterizer (imgui_freetype)](#using-freetype-rasterizer-imgui_freetype) -- [Using Colorful Glyphs/Emojis](#using-colorful-glyphsemojis) -- [Using Custom Glyph Ranges](#using-custom-glyph-ranges) -- [Using Custom Colorful Icons](#using-custom-colorful-icons) -- [Using Font Data Embedded In Source Code](#using-font-data-embedded-in-source-code) -- [About filenames](#about-filenames) -- [Credits/Licenses For Fonts Included In Repository](#creditslicenses-for-fonts-included-in-repository) -- [Font Links](#font-links) - ---------------------------------------- - ## Readme First - -- You can use the `Metrics/Debugger` window (available in `Demo>Tools`) to browse your fonts and understand what's going on if you have an issue. You can also reach it in `Demo->Tools->Style Editor->Fonts`. The same information are also available in the Style Editor under Fonts. - -![imgui_capture_0008](https://user-images.githubusercontent.com/8225057/135429892-0e41ef8d-33c5-4991-bcf6-f997a0bcfd6b.png) - -- All loaded fonts glyphs are rendered into a single texture atlas ahead of time. Calling either of `io.Fonts->GetTexDataAsAlpha8()`, `io.Fonts->GetTexDataAsRGBA32()` or `io.Fonts->Build()` will build the atlas. - -- Make sure your font ranges data are persistent (available during the calls to `GetTexDataAsAlpha8()`/`GetTexDataAsRGBA32()/`Build()`. - -- Use C++11 u8"my text" syntax to encode literal strings as UTF-8. e.g.: -```cpp -u8"hello" -u8"こんにちは" // this will be encoded as UTF-8 -``` - -##### [Return to Index](#index) - -## How should I handle DPI in my application? - -See [FAQ entry](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md#q-how-should-i-handle-dpi-in-my-application). - -##### [Return to Index](#index) - - -## Font Loading Instructions - -**Load default font:** -```cpp -ImGuiIO& io = ImGui::GetIO(); -io.Fonts->AddFontDefault(); -``` - - -**Load .TTF/.OTF file with:** -```cpp -ImGuiIO& io = ImGui::GetIO(); -io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels); -``` -If you get an assert stating "Could not load font file!", your font filename is likely incorrect. Read "[About filenames](#about-filenames)" carefully. - - -**Load multiple fonts:** -```cpp -// Init -ImGuiIO& io = ImGui::GetIO(); -ImFont* font1 = io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels); -ImFont* font2 = io.Fonts->AddFontFromFileTTF("anotherfont.otf", size_pixels); -``` -```cpp -// In application loop: select font at runtime -ImGui::Text("Hello"); // use the default font (which is the first loaded font) -ImGui::PushFont(font2); -ImGui::Text("Hello with another font"); -ImGui::PopFont(); -``` - - -**For advanced options create a ImFontConfig structure and pass it to the AddFont() function (it will be copied internally):** -```cpp -ImFontConfig config; -config.OversampleH = 2; -config.OversampleV = 1; -config.GlyphExtraSpacing.x = 1.0f; -ImFont* font = io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels, &config); -``` - - -**Combine multiple fonts into one:** -```cpp -// Load a first font -ImFont* font = io.Fonts->AddFontDefault(); - -// Add character ranges and merge into the previous font -// The ranges array is not copied by the AddFont* functions and is used lazily -// so ensure it is available at the time of building or calling GetTexDataAsRGBA32(). -static const ImWchar icons_ranges[] = { 0xf000, 0xf3ff, 0 }; // Will not be copied by AddFont* so keep in scope. -ImFontConfig config; -config.MergeMode = true; -io.Fonts->AddFontFromFileTTF("DroidSans.ttf", 18.0f, &config, io.Fonts->GetGlyphRangesJapanese()); // Merge into first font -io.Fonts->AddFontFromFileTTF("fontawesome-webfont.ttf", 18.0f, &config, icons_ranges); // Merge into first font -io.Fonts->Build(); -``` - -**Add a fourth parameter to bake specific font ranges only:** - -```cpp -// Basic Latin, Extended Latin -io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels, NULL, io.Fonts->GetGlyphRangesDefault()); - -// Default + Selection of 2500 Ideographs used by Simplified Chinese -io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels, NULL, io.Fonts->GetGlyphRangesChineseSimplifiedCommon()); - -// Default + Hiragana, Katakana, Half-Width, Selection of 1946 Ideographs -io.Fonts->AddFontFromFileTTF("font.ttf", size_pixels, NULL, io.Fonts->GetGlyphRangesJapanese()); -``` -See [Using Custom Glyph Ranges](#using-custom-glyph-ranges) section to create your own ranges. - - -**Example loading and using a Japanese font:** - -```cpp -ImGuiIO& io = ImGui::GetIO(); -io.Fonts->AddFontFromFileTTF("NotoSansCJKjp-Medium.otf", 20.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); -``` -```cpp -ImGui::Text(u8"こんにちは!テスト %d", 123); -if (ImGui::Button(u8"ロード")) -{ - // do stuff -} -ImGui::InputText("string", buf, IM_ARRAYSIZE(buf)); -ImGui::SliderFloat("float", &f, 0.0f, 1.0f); -``` - -![sample code output](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v160/code_sample_02_jp.png) -
    _(settings: Dark style (left), Light style (right) / Font: NotoSansCJKjp-Medium, 20px / Rounding: 5)_ - -**Font Atlas too large?** - -- If you have very large number of glyphs or multiple fonts, the texture may become too big for your graphics API. The typical result of failing to upload a texture is if every glyphs appears as white rectangles. -- Mind the fact that some graphics drivers have texture size limitation. If you are building a PC application, mind the fact that your users may use hardware with lower limitations than yours. - -Some solutions: - -1. Reduce glyphs ranges by calculating them from source localization data. - You can use the `ImFontGlyphRangesBuilder` for this purpose and rebuilding your atlas between frames when new characters are needed. This will be the biggest win! -2. You may reduce oversampling, e.g. `font_config.OversampleH = 2`, this will largely reduce your texture size. - Note that while OversampleH = 2 looks visibly very close to 3 in most situations, with OversampleH = 1 the quality drop will be noticeable. -3. Set `io.Fonts.TexDesiredWidth` to specify a texture width to minimize texture height (see comment in `ImFontAtlas::Build()` function). -4. Set `io.Fonts.Flags |= ImFontAtlasFlags_NoPowerOfTwoHeight;` to disable rounding the texture height to the next power of two. -5. Read about oversampling [here](https://github.com/nothings/stb/blob/master/tests/oversample). -6. To support the extended range of unicode beyond 0xFFFF (e.g. emoticons, dingbats, symbols, shapes, ancient languages, etc...) add `#define IMGUI_USE_WCHAR32`in your `imconfig.h`. - -##### [Return to Index](#index) - -## Using Icon Fonts - -Using an icon font (such as [FontAwesome](http://fontawesome.io) or [OpenFontIcons](https://github.com/traverseda/OpenFontIcons)) is an easy and practical way to use icons in your Dear ImGui application. -A common pattern is to merge the icon font within your main font, so you can embed icons directly from your strings without having to change fonts back and forth. - -To refer to the icon UTF-8 codepoints from your C++ code, you may use those headers files created by Juliette Foucaut: https://github.com/juliettef/IconFontCppHeaders. - -So you can use `ICON_FA_SEARCH` as a string that will render as a "Search" icon. - -Example Setup: -```cpp -// Merge icons into default tool font -#include "IconsFontAwesome.h" -ImGuiIO& io = ImGui::GetIO(); -io.Fonts->AddFontDefault(); - -ImFontConfig config; -config.MergeMode = true; -config.GlyphMinAdvanceX = 13.0f; // Use if you want to make the icon monospaced -static const ImWchar icon_ranges[] = { ICON_MIN_FA, ICON_MAX_FA, 0 }; -io.Fonts->AddFontFromFileTTF("fonts/fontawesome-webfont.ttf", 13.0f, &config, icon_ranges); -``` -Example Usage: -```cpp -// Usage, e.g. -ImGui::Text("%s among %d items", ICON_FA_SEARCH, count); -ImGui::Button(ICON_FA_SEARCH " Search"); -// C string _literals_ can be concatenated at compilation time, e.g. "hello" " world" -// ICON_FA_SEARCH is defined as a string literal so this is the same as "A" "B" becoming "AB" -``` -See Links below for other icons fonts and related tools. - -Here's an application using icons ("Avoyd", https://www.avoyd.com): -![avoyd](https://user-images.githubusercontent.com/8225057/81696852-c15d9e80-9464-11ea-9cab-2a4d4fc84396.jpg) - -##### [Return to Index](#index) - -## Using FreeType Rasterizer (imgui_freetype) - -- Dear ImGui uses imstb\_truetype.h to rasterize fonts (with optional oversampling). This technique and its implementation are not ideal for fonts rendered at small sizes, which may appear a little blurry or hard to read. -- There is an implementation of the ImFontAtlas builder using FreeType that you can use in the [misc/freetype/](https://github.com/ocornut/imgui/tree/master/misc/freetype) folder. -- FreeType supports auto-hinting which tends to improve the readability of small fonts. -- Read documentation in the [misc/freetype/](https://github.com/ocornut/imgui/tree/master/misc/freetype) folder. -- Correct sRGB space blending will have an important effect on your font rendering quality. - -##### [Return to Index](#index) - -## Using Colorful Glyphs/Emojis - -- Rendering of colored emojis is only supported by imgui_freetype with FreeType 2.10+. -- You will need to load fonts with the `ImGuiFreeTypeBuilderFlags_LoadColor` flag. -- Emojis are frequently encoded in upper Unicode layers (character codes >0x10000) and will need dear imgui compiled with `IMGUI_USE_WCHAR32`. -- Not all types of color fonts are supported by FreeType at the moment. -- Stateful Unicode features such as skin tone modifiers are not supported by the text renderer. - -![colored glyphs](https://user-images.githubusercontent.com/8225057/106171241-9dc4ba80-6191-11eb-8a69-ca1467b206d1.png) - -```cpp -io.Fonts->AddFontFromFileTTF("../../../imgui_dev/data/fonts/NotoSans-Regular.ttf", 16.0f); -static ImWchar ranges[] = { 0x1, 0x1FFFF, 0 }; -static ImFontConfig cfg; -cfg.OversampleH = cfg.OversampleV = 1; -cfg.MergeMode = true; -cfg.FontBuilderFlags |= ImGuiFreeTypeBuilderFlags_LoadColor; -io.Fonts->AddFontFromFileTTF("C:\\Windows\\Fonts\\seguiemj.ttf", 16.0f, &cfg, ranges); -``` - -##### [Return to Index](#index) - -## Using Custom Glyph Ranges - -You can use the `ImFontGlyphRangesBuilder` helper to create glyph ranges based on text input. For example: for a game where your script is known, if you can feed your entire script to it and only build the characters the game needs. -```cpp -ImVector ranges; -ImFontGlyphRangesBuilder builder; -builder.AddText("Hello world"); // Add a string (here "Hello world" contains 7 unique characters) -builder.AddChar(0x7262); // Add a specific character -builder.AddRanges(io.Fonts->GetGlyphRangesJapanese()); // Add one of the default ranges -builder.BuildRanges(&ranges); // Build the final result (ordered ranges with all the unique characters submitted) - -io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels, NULL, ranges.Data); -io.Fonts->Build(); // Build the atlas while 'ranges' is still in scope and not deleted. -``` - -##### [Return to Index](#index) - -## Using Custom Colorful Icons - -As an alternative to rendering colorful glyphs using imgui_freetype with `ImGuiFreeTypeBuilderFlags_LoadColor`, you may allocate your own space in the texture atlas and write yourself into it. **(This is a BETA api, use if you are familiar with dear imgui and with your rendering backend)** - -- You can use the `ImFontAtlas::AddCustomRect()` and `ImFontAtlas::AddCustomRectFontGlyph()` api to register rectangles that will be packed into the font atlas texture. Register them before building the atlas, then call Build()`. -- You can then use `ImFontAtlas::GetCustomRectByIndex(int)` to query the position/size of your rectangle within the texture, and blit/copy any graphics data of your choice into those rectangles. -- This API is beta because it is likely to change in order to support multi-dpi (multiple viewports on multiple monitors with varying DPI scale). - -#### Pseudo-code: -```cpp -// Add font, then register two custom 13x13 rectangles mapped to glyph 'a' and 'b' of this font -ImFont* font = io.Fonts->AddFontDefault(); -int rect_ids[2]; -rect_ids[0] = io.Fonts->AddCustomRectFontGlyph(font, 'a', 13, 13, 13+1); -rect_ids[1] = io.Fonts->AddCustomRectFontGlyph(font, 'b', 13, 13, 13+1); - -// Build atlas -io.Fonts->Build(); - -// Retrieve texture in RGBA format -unsigned char* tex_pixels = NULL; -int tex_width, tex_height; -io.Fonts->GetTexDataAsRGBA32(&tex_pixels, &tex_width, &tex_height); - -for (int rect_n = 0; rect_n < IM_ARRAYSIZE(rect_ids); rect_n++) -{ - int rect_id = rects_ids[rect_n]; - if (const ImFontAtlas::CustomRect* rect = io.Fonts->GetCustomRectByIndex(rect_id)) - { - // Fill the custom rectangle with red pixels (in reality you would draw/copy your bitmap data here!) - for (int y = 0; y < rect->Height; y++) - { - ImU32* p = (ImU32*)tex_pixels + (rect->Y + y) * tex_width + (rect->X); - for (int x = rect->Width; x > 0; x--) - *p++ = IM_COL32(255, 0, 0, 255); - } - } -} -``` - -##### [Return to Index](#index) - -## Using Font Data Embedded In Source Code - -- Compile and use [binary_to_compressed_c.cpp](https://github.com/ocornut/imgui/blob/master/misc/fonts/binary_to_compressed_c.cpp) to create a compressed C style array that you can embed in source code. -- See the documentation in [binary_to_compressed_c.cpp](https://github.com/ocornut/imgui/blob/master/misc/fonts/binary_to_compressed_c.cpp) for instruction on how to use the tool. -- You may find a precompiled version binary_to_compressed_c.exe for Windows instead of demo binaries package (see [README](https://github.com/ocornut/imgui/blob/master/docs/README.md)). -- The tool can optionally output Base85 encoding to reduce the size of _source code_ but the read-only arrays in the actual binary will be about 20% bigger. - -Then load the font with: -```cpp -ImFont* font = io.Fonts->AddFontFromMemoryCompressedTTF(compressed_data, compressed_data_size, size_pixels, ...); -``` -or -```cpp -ImFont* font = io.Fonts->AddFontFromMemoryCompressedBase85TTF(compressed_data_base85, size_pixels, ...); -``` - -##### [Return to Index](#index) - -## About filenames - -**Please note that many new C/C++ users have issues their files _because the filename they provide is wrong_.** - -Two things to watch for: -- Make sure your IDE/debugger settings starts your executable from the right working directory. In Visual Studio you can change your working directory in project `Properties > General > Debugging > Working Directory`. People assume that their execution will start from the root folder of the project, where by default it oftens start from the folder where object or executable files are stored. -```cpp -// Relative filename depends on your Working Directory when running your program! -io.Fonts->AddFontFromFileTTF("MyImage01.jpg", ...); - -// Load from the parent folder of your Working Directory -io.Fonts->AddFontFromFileTTF("../MyImage01.jpg", ...); -``` -- In C/C++ and most programming languages if you want to use a backslash `\` within a string literal, you need to write it double backslash `\\`. At it happens, Windows uses backslashes as a path separator, so be mindful. -```cpp -io.Fonts->AddFontFromFileTTF("MyFiles\MyImage01.jpg", ...); // This is INCORRECT!! -io.Fonts->AddFontFromFileTTF("MyFiles\\MyImage01.jpg", ...); // This is CORRECT -``` -In some situations, you may also use `/` path separator under Windows. - -##### [Return to Index](#index) - -## Credits/Licenses For Fonts Included In Repository - -Some fonts files are available in the `misc/fonts/` folder: - -**Roboto-Medium.ttf**, by Christian Robetson -
    Apache License 2.0 -
    https://fonts.google.com/specimen/Roboto - -**Cousine-Regular.ttf**, by Steve Matteson -
    Digitized data copyright (c) 2010 Google Corporation. -
    Licensed under the SIL Open Font License, Version 1.1 -
    https://fonts.google.com/specimen/Cousine - -**DroidSans.ttf**, by Steve Matteson -
    Apache License 2.0 -
    https://www.fontsquirrel.com/fonts/droid-sans - -**ProggyClean.ttf**, by Tristan Grimmer -
    MIT License -
    (recommended loading setting: Size = 13.0, GlyphOffset.y = +1) -
    http://www.proggyfonts.net/ - -**ProggyTiny.ttf**, by Tristan Grimmer -
    MIT License -
    (recommended loading setting: Size = 10.0, GlyphOffset.y = +1) -
    http://www.proggyfonts.net/ - -**Karla-Regular.ttf**, by Jonathan Pinhorn -
    SIL OPEN FONT LICENSE Version 1.1 - -##### [Return to Index](#index) - -## Font Links - -#### ICON FONTS - -- C/C++ header for icon fonts (#define with code points to use in source code string literals) https://github.com/juliettef/IconFontCppHeaders -- FontAwesome https://fortawesome.github.io/Font-Awesome -- OpenFontIcons https://github.com/traverseda/OpenFontIcons -- Google Icon Fonts https://design.google.com/icons/ -- Kenney Icon Font (Game Controller Icons) https://github.com/nicodinh/kenney-icon-font -- IcoMoon - Custom Icon font builder https://icomoon.io/app - -#### REGULAR FONTS - -- Google Noto Fonts (worldwide languages) https://www.google.com/get/noto/ -- Open Sans Fonts https://fonts.google.com/specimen/Open+Sans -- (Japanese) M+ fonts by Coji Morishita http://mplus-fonts.sourceforge.jp/mplus-outline-fonts/index-en.html - -#### MONOSPACE FONTS - -Pixel Perfect: -- Proggy Fonts, by Tristan Grimmer http://www.proggyfonts.net or http://upperbounds.net -- Sweet16, Sweet16 Mono, by Martin Sedlak (Latin + Supplemental + Extended A) https://github.com/kmar/Sweet16Font (also include an .inl file to use directly in dear imgui.) - -Regular: -- Google Noto Mono Fonts https://www.google.com/get/noto/ -- Typefaces for source code beautification https://github.com/chrissimpkins/codeface -- Programmation fonts http://s9w.github.io/font_compare/ -- Inconsolata http://www.levien.com/type/myfonts/inconsolata.html -- Adobe Source Code Pro: Monospaced font family for ui & coding environments https://github.com/adobe-fonts/source-code-pro -- Monospace/Fixed Width Programmer's Fonts http://www.lowing.org/fonts/ - -Or use Arial Unicode or other Unicode fonts provided with Windows for full characters coverage (not sure of their licensing). - -##### [Return to Index](#index) diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/docs/README.md b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/docs/README.md deleted file mode 100644 index 9d6dc93..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/docs/README.md +++ /dev/null @@ -1,243 +0,0 @@ -Dear ImGui -===== -[![Build Status](https://github.com/ocornut/imgui/workflows/build/badge.svg)](https://github.com/ocornut/imgui/actions?workflow=build) [![Static Analysis Status](https://github.com/ocornut/imgui/workflows/static-analysis/badge.svg)](https://github.com/ocornut/imgui/actions?workflow=static-analysis) - - -(This library is available under a free and permissive license, but needs financial support to sustain its continued improvements. In addition to maintenance and stability there are many desirable features yet to be added. If your company is using Dear ImGui, please consider reaching out.) - -Businesses: support continued development and maintenance via invoiced technical support, maintenance, sponsoring contracts: -
      _E-mail: contact @ dearimgui dot com_ - -Individuals: support continued development and maintenance [here](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WGHNC6MBFLZ2S). - -Also see [Sponsors](https://github.com/ocornut/imgui/wiki/Sponsors) page. - ----- - -Dear ImGui is a **bloat-free graphical user interface library for C++**. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies). - -Dear ImGui is designed to **enable fast iterations** and to **empower programmers** to create **content creation tools and visualization / debug tools** (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and lacks certain features normally found in more high-level libraries. - -Dear ImGui is particularly suited to integration in games engine (for tooling), real-time 3D applications, fullscreen applications, embedded applications, or any applications on consoles platforms where operating system features are non-standard. - -| [Usage](#usage) - [How it works](#how-it-works) - [Releases & Changelogs](#releases--changelogs) - [Demo](#demo) - [Integration](#integration) | -:----------------------------------------------------------: | -| [Upcoming changes](#upcoming-changes) - [Gallery](#gallery) - [Support, FAQ](#support-frequently-asked-questions-faq) - [How to help](#how-to-help) - [Sponsors](#sponsors) - [Credits](#credits) - [License](#license) | -| [Wiki](https://github.com/ocornut/imgui/wiki) - [Languages & frameworks backends/bindings](https://github.com/ocornut/imgui/wiki/Bindings) - [Software using Dear ImGui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) - [User quotes](https://github.com/ocornut/imgui/wiki/Quotes) | - -### Usage - -**The core of Dear ImGui is self-contained within a few platform-agnostic files** which you can easily compile in your application/engine. They are all the files in the root folder of the repository (imgui*.cpp, imgui*.h). - -**No specific build process is required**. You can add the .cpp files to your existing project. - -You will need a backend to integrate Dear ImGui in your app. The backend passes mouse/keyboard/gamepad inputs and variety of settings to Dear ImGui, and is in charge of rendering the resulting vertices. - -**Backends for a variety of graphics api and rendering platforms** are provided in the [backends/](https://github.com/ocornut/imgui/tree/master/backends) folder, along with example applications in the [examples/](https://github.com/ocornut/imgui/tree/master/examples) folder. See the [Integration](#integration) section of this document for details. You may also create your own backend. Anywhere where you can render textured triangles, you can render Dear ImGui. - -After Dear ImGui is setup in your application, you can use it from \_anywhere\_ in your program loop: - -Code: -```cpp -ImGui::Text("Hello, world %d", 123); -if (ImGui::Button("Save")) - MySaveFunction(); -ImGui::InputText("string", buf, IM_ARRAYSIZE(buf)); -ImGui::SliderFloat("float", &f, 0.0f, 1.0f); -``` -Result: -
    ![sample code output (dark)](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v175/capture_readme_styles_0001.png) ![sample code output (light)](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v175/capture_readme_styles_0002.png) -
    _(settings: Dark style (left), Light style (right) / Font: Roboto-Medium, 16px)_ - -Code: -```cpp -// Create a window called "My First Tool", with a menu bar. -ImGui::Begin("My First Tool", &my_tool_active, ImGuiWindowFlags_MenuBar); -if (ImGui::BeginMenuBar()) -{ - if (ImGui::BeginMenu("File")) - { - if (ImGui::MenuItem("Open..", "Ctrl+O")) { /* Do stuff */ } - if (ImGui::MenuItem("Save", "Ctrl+S")) { /* Do stuff */ } - if (ImGui::MenuItem("Close", "Ctrl+W")) { my_tool_active = false; } - ImGui::EndMenu(); - } - ImGui::EndMenuBar(); -} - -// Edit a color (stored as ~4 floats) -ImGui::ColorEdit4("Color", my_color); - -// Plot some values -const float my_values[] = { 0.2f, 0.1f, 1.0f, 0.5f, 0.9f, 2.2f }; -ImGui::PlotLines("Frame Times", my_values, IM_ARRAYSIZE(my_values)); - -// Display contents in a scrolling region -ImGui::TextColored(ImVec4(1,1,0,1), "Important Stuff"); -ImGui::BeginChild("Scrolling"); -for (int n = 0; n < 50; n++) - ImGui::Text("%04d: Some text", n); -ImGui::EndChild(); -ImGui::End(); -``` -Result: -
    ![sample code output](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v180/code_sample_04_color.gif) - -Dear ImGui allows you to **create elaborate tools** as well as very short-lived ones. On the extreme side of short-livedness: using the Edit&Continue (hot code reload) feature of modern compilers you can add a few widgets to tweaks variables while your application is running, and remove the code a minute later! Dear ImGui is not just for tweaking values. You can use it to trace a running algorithm by just emitting text commands. You can use it along with your own reflection data to browse your dataset live. You can use it to expose the internals of a subsystem in your engine, to create a logger, an inspection tool, a profiler, a debugger, an entire game making editor/framework, etc. - -### How it works - -Check out the Wiki's [About the IMGUI paradigm](https://github.com/ocornut/imgui/wiki#about-the-imgui-paradigm) section if you want to understand the core principles behind the IMGUI paradigm. An IMGUI tries to minimize superfluous state duplication, state synchronization and state retention from the user's point of view. It is less error prone (less code and less bugs) than traditional retained-mode interfaces, and lends itself to create dynamic user interfaces. - -Dear ImGui outputs vertex buffers and command lists that you can easily render in your application. The number of draw calls and state changes required to render them is fairly small. Because Dear ImGui doesn't know or touch graphics state directly, you can call its functions anywhere in your code (e.g. in the middle of a running algorithm, or in the middle of your own rendering process). Refer to the sample applications in the examples/ folder for instructions on how to integrate Dear ImGui with your existing codebase. - -_A common misunderstanding is to mistake immediate mode gui for immediate mode rendering, which usually implies hammering your driver/GPU with a bunch of inefficient draw calls and state changes as the gui functions are called. This is NOT what Dear ImGui does. Dear ImGui outputs vertex buffers and a small list of draw calls batches. It never touches your GPU directly. The draw call batches are decently optimal and you can render them later, in your app or even remotely._ - -### Releases & Changelogs - -See [Releases](https://github.com/ocornut/imgui/releases) page. -Reading the changelogs is a good way to keep up to date with the things Dear ImGui has to offer, and maybe will give you ideas of some features that you've been ignoring until now! - -### Demo - -Calling the `ImGui::ShowDemoWindow()` function will create a demo window showcasing variety of features and examples. The code is always available for reference in `imgui_demo.cpp`. - -![screenshot demo](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v167/v167-misc.png) - -You should be able to build the examples from sources (tested on Windows/Mac/Linux). If you don't, let us know! If you want to have a quick look at some Dear ImGui features, you can download Windows binaries of the demo app here: -- [imgui-demo-binaries-20210331.zip](https://www.dearimgui.org/binaries/imgui-demo-binaries-20210331.zip) (Windows, 1.83 WIP, built 2021/03/31, master branch) or [older demo binaries](https://www.dearimgui.org/binaries). - -The demo applications are not DPI aware so expect some blurriness on a 4K screen. For DPI awareness in your application, you can load/reload your font at different scale, and scale your style with `style.ScaleAllSizes()` (see [FAQ](https://www.dearimgui.org/faq)). - -### Integration - -On most platforms and when using C++, **you should be able to use a combination of the [imgui_impl_xxxx](https://github.com/ocornut/imgui/tree/master/backends) backends without modification** (e.g. `imgui_impl_win32.cpp` + `imgui_impl_dx11.cpp`). If your engine supports multiple platforms, consider using more of the imgui_impl_xxxx files instead of rewriting them: this will be less work for you and you can get Dear ImGui running immediately. You can _later_ decide to rewrite a custom backend using your custom engine functions if you wish so. - -Integrating Dear ImGui within your custom engine is a matter of 1) wiring mouse/keyboard/gamepad inputs 2) uploading one texture to your GPU/render engine 3) providing a render function that can bind textures and render textured triangles. The [examples/](https://github.com/ocornut/imgui/tree/master/examples) folder is populated with applications doing just that. If you are an experienced programmer at ease with those concepts, it should take you less than two hours to integrate Dear ImGui in your custom engine. **Make sure to spend time reading the [FAQ](https://www.dearimgui.org/faq), comments, and some of the examples/ application!** - -Officially maintained backends/bindings (in repository): -- Renderers: DirectX9, DirectX10, DirectX11, DirectX12, Metal, OpenGL/ES/ES2, SDL_Renderer, Vulkan, WebGPU. -- Platforms: GLFW, SDL2, Win32, Glut, OSX, Android. -- Frameworks: Emscripten, Allegro5, Marmalade. - -[Third-party backends/bindings](https://github.com/ocornut/imgui/wiki/Bindings) wiki page: -- Languages: C, C# and: Beef, ChaiScript, Crystal, D, Go, Haskell, Haxe/hxcpp, Java, JavaScript, Julia, Kotlin, Lobster, Lua, Odin, Pascal, PureBasic, Python, Ruby, Rust, Swift... -- Frameworks: AGS/Adventure Game Studio, Amethyst, Blender, bsf, Cinder, Cocos2d-x, Diligent Engine, Flexium, GML/Game Maker Studio2, GLEQ, Godot, GTK3+OpenGL3, Irrlicht Engine, LÖVE+LUA, Magnum, Monogame, NanoRT, nCine, Nim Game Lib, Nintendo 3DS & Switch (homebrew), Ogre, openFrameworks, OSG/OpenSceneGraph, Orx, Photoshop, px_render, Qt/QtDirect3D, SDL_Renderer, SFML, Sokol, Unity, Unreal Engine 4, vtk, VulkanHpp, VulkanSceneGraph, Win32 GDI, WxWidgets. -- Note that C bindings ([cimgui](https://github.com/cimgui/cimgui)) are auto-generated, you can use its json/lua output to generate bindings for other languages. - -[Useful Extensions/Widgets](https://github.com/ocornut/imgui/wiki/Useful-Extensions) wiki page: -- Text editors, node editors, timeline editors, plotting, software renderers, remote network access, memory editors, gizmos etc. - -Also see [Wiki](https://github.com/ocornut/imgui/wiki) for more links and ideas. - -### Upcoming Changes - -Some of the goals for 2021 are: -- Work on Docking (see [#2109](https://github.com/ocornut/imgui/issues/2109), in public [docking](https://github.com/ocornut/imgui/tree/docking) branch) -- Work on Multi-Viewport / Multiple OS windows. (see [#1542](https://github.com/ocornut/imgui/issues/1542), in public [docking](https://github.com/ocornut/imgui/tree/docking) branch looking for feedback) -- Work on gamepad/keyboard controls. (see [#787](https://github.com/ocornut/imgui/issues/787)) -- Work on automation and testing system, both to test the library and end-user apps. (see [#435](https://github.com/ocornut/imgui/issues/435)) -- Make the examples look better, improve styles, improve font support, make the examples hi-DPI and multi-DPI aware. - -### Gallery - -For more user-submitted screenshots of projects using Dear ImGui, check out the [Gallery Threads](https://github.com/ocornut/imgui/issues/4451)! - -For a list of third-party widgets and extensions, check out the [Useful Extensions/Widgets](https://github.com/ocornut/imgui/wiki/Useful-Extensions) wiki page. - -Custom engine -[![screenshot game](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v149/gallery_TheDragonsTrap-01-thumb.jpg)](https://cloud.githubusercontent.com/assets/8225057/20628927/33e14cac-b329-11e6-80f6-9524e93b048a.png) - -Custom engine -[![screenshot tool](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v160/editor_white_preview.jpg)](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v160/editor_white.png) - -[Tracy Profiler](https://github.com/wolfpld/tracy) -![tracy profiler](https://raw.githubusercontent.com/wiki/ocornut/imgui/web/v176/tracy_profiler.png) - -### Support, Frequently Asked Questions (FAQ) - -See: [Frequently Asked Questions (FAQ)](https://github.com/ocornut/imgui/blob/master/docs/FAQ.md) where common questions are answered. - -See: [Wiki](https://github.com/ocornut/imgui/wiki) for many links, references, articles. - -See: [Articles about the IMGUI paradigm](https://github.com/ocornut/imgui/wiki#about-the-imgui-paradigm) to read/learn about the Immediate Mode GUI paradigm. - -Getting started? For first-time users having issues compiling/linking/running or issues loading fonts, please use [GitHub Discussions](https://github.com/ocornut/imgui/discussions). - -For other questions, bug reports, requests, feedback, you may post on [GitHub Issues](https://github.com/ocornut/imgui/issues). Please read and fill the New Issue template carefully. - -Private support is available for paying business customers (E-mail: _contact @ dearimgui dot com_). - -**Which version should I get?** - -We occasionally tag [Releases](https://github.com/ocornut/imgui/releases) but it is generally safe and recommended to sync to master/latest. The library is fairly stable and regressions tend to be fixed fast when reported. - -Advanced users may want to use the `docking` branch with [Multi-Viewport](https://github.com/ocornut/imgui/issues/1542) and [Docking](https://github.com/ocornut/imgui/issues/2109) features. This branch is kept in sync with master regularly. - -**Who uses Dear ImGui?** - -See the [Quotes](https://github.com/ocornut/imgui/wiki/Quotes), [Sponsors](https://github.com/ocornut/imgui/wiki/Sponsors), [Software using dear imgui](https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) Wiki pages for an idea of who is using Dear ImGui. Please add your game/software if you can! Also see the [Gallery Threads](https://github.com/ocornut/imgui/issues/4451)! - -How to help ------------ - -**How can I help?** - -- See [GitHub Forum/issues](https://github.com/ocornut/imgui/issues) and [Github Discussions](https://github.com/ocornut/imgui/discussions). -- You may help with development and submit pull requests! Please understand that by submitting a PR you are also submitting a request for the maintainer to review your code and then take over its maintenance forever. PR should be crafted both in the interest in the end-users and also to ease the maintainer into understanding and accepting it. -- See [Help wanted](https://github.com/ocornut/imgui/wiki/Help-Wanted) on the [Wiki](https://github.com/ocornut/imgui/wiki/) for some more ideas. -- Have your company financially support this project (please reach by e-mail) - -**How can I help financing further development of Dear ImGui?** - -See [Sponsors](https://github.com/ocornut/imgui/wiki/Sponsors) page. - -Sponsors --------- - -Ongoing Dear ImGui development is currently financially supported by users and private sponsors: - -*Platinum-chocolate sponsors* -- [Blizzard](https://careers.blizzard.com/en-us/openings/engineering/all/all/all/1) - -*Double-chocolate sponsors* -- [Google](https://github.com/google/filament), [Nvidia](https://developer.nvidia.com/nvidia-omniverse), [Ubisoft](https://montreal.ubisoft.com/en/ubisoft-sponsors-user-interface-library-for-c-dear-imgui) - -*Chocolate sponsors* -- [Activision](https://careers.activision.com/c/programmingsoftware-engineering-jobs), [Adobe](https://www.adobe.com/products/medium.html), [Aras Pranckevičius](https://aras-p.info), [Arkane Studios](https://www.arkane-studios.com), [Epic](https://www.unrealengine.com/en-US/megagrants), [RAD Game Tools](http://www.radgametools.com/) - -*Salty-caramel sponsors* -- [Framefield](http://framefield.com), [Grinding Gear Games](https://www.grindinggear.com), [Kylotonn](https://www.kylotonn.com), [Next Level Games](https://www.nextlevelgames.com), [O-Net Communications (USA)](http://en.o-netcom.com), [Supercell](https://supercell.com). - -Please see [detailed list of Dear ImGui supporters](https://github.com/ocornut/imgui/wiki/Sponsors) for past sponsors. -From November 2014 to December 2019, ongoing development has also been financially supported by its users on Patreon and through individual donations. - -**THANK YOU to all past and present supporters for helping to keep this project alive and thriving!** - -Dear ImGui is using software and services provided free of charge for open source projects: -- [PVS-Studio](https://www.viva64.com/en/b/0570/) for static analysis. -- [GitHub actions](https://github.com/features/actions) for continuous integration systems. -- [OpenCppCoverage](https://github.com/OpenCppCoverage/OpenCppCoverage) for code coverage analysis. - -Credits -------- - -Developed by [Omar Cornut](https://www.miracleworld.net) and every direct or indirect [contributors](https://github.com/ocornut/imgui/graphs/contributors) to the GitHub. The early version of this library was developed with the support of [Media Molecule](https://www.mediamolecule.com) and first used internally on the game [Tearaway](https://tearaway.mediamolecule.com) (PS Vita). - -Recurring contributors (2020): Omar Cornut [@ocornut](https://github.com/ocornut), Rokas Kupstys [@rokups](https://github.com/rokups), Ben Carter [@ShironekoBen](https://github.com/ShironekoBen). -A large portion of work on automation systems, regression tests and other features are currently unpublished. - -Sponsoring, support contracts and other B2B transactions are hosted and handled by [Lizardcube](https://www.lizardcube.com). - -Omar: "I first discovered the IMGUI paradigm at [Q-Games](https://www.q-games.com) where Atman Binstock had dropped his own simple implementation in the codebase, which I spent quite some time improving and thinking about. It turned out that Atman was exposed to the concept directly by working with Casey. When I moved to Media Molecule I rewrote a new library trying to overcome the flaws and limitations of the first one I've worked with. It became this library and since then I have spent an unreasonable amount of time iterating and improving it." - -Embeds [ProggyClean.ttf](http://upperbounds.net) font by Tristan Grimmer (MIT license). - -Embeds [stb_textedit.h, stb_truetype.h, stb_rect_pack.h](https://github.com/nothings/stb/) by Sean Barrett (public domain). - -Inspiration, feedback, and testing for early versions: Casey Muratori, Atman Binstock, Mikko Mononen, Emmanuel Briney, Stefan Kamoda, Anton Mikhailov, Matt Willis. Also thank you to everyone posting feedback, questions and patches on GitHub. - -License -------- - -Dear ImGui is licensed under the MIT License, see [LICENSE.txt](https://github.com/ocornut/imgui/blob/master/LICENSE.txt) for more information. diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/docs/TODO.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/docs/TODO.txt deleted file mode 100644 index 95a9326..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/docs/TODO.txt +++ /dev/null @@ -1,406 +0,0 @@ -dear imgui -ISSUES & TODO LIST - -Issue numbers (#) refer to github issues listed at https://github.com/ocornut/imgui/issues/XXXX -The list below consist mostly of ideas noted down before they are requested/discussed by users (at which point they usually exist on the github issue tracker). -It's mostly a bunch of personal notes, probably incomplete. Feel free to query if you have any questions. - - - doc/test: add a proper documentation+regression testing system (#435) - - doc/test: checklist app to verify backends/integration of imgui (test inputs, rendering, callback, etc.). - - doc/tips: tips of the day: website? applet in imgui_club? - - doc/wiki: work on the wiki https://github.com/ocornut/imgui/wiki - - - window: preserve/restore relative focus ordering (persistent or not) (#2304) -> also see docking reference to same #. - - window: calling SetNextWindowSize() every frame with <= 0 doesn't do anything, may be useful to allow (particularly when used for a single axis). (#690) - - window: add a way for very transient windows (non-saved, temporary overlay over hundreds of objects) to "clean" up from the global window list. perhaps a lightweight explicit cleanup pass. - - window: auto-fit feedback loop when user relies on any dynamic layout (window width multiplier, column) appears weird to end-user. clarify. - - window: begin with *p_open == false could return false. - - window: get size/pos helpers given names (see discussion in #249) - - window: a collapsed window can be stuck behind the main menu bar? - - window: when window is very small, prioritize resize button over close button. - - window: detect extra End() call that pop the "Debug" window out and assert at End() call site instead of at end of frame. - - window: increase minimum size of a window with menus or fix the menu rendering so that it doesn't look odd. - - window: double-clicking on title bar to minimize isn't consistent, perhaps move to single-click on left-most collapse icon? - - window: expose contents size. (#1045) - - window: using SetWindowPos() inside Begin() and moving the window with the mouse reacts a very ugly glitch. We should just defer the SetWindowPos() call. - - window: GetWindowSize() returns (0,0) when not calculated? (#1045) - - window: investigate better auto-positioning for new windows. - - window: top most window flag? (#2574) - - window/size: manually triggered auto-fit (double-click on grip) shouldn't resize window down to viewport size? - - window/size: how to allow to e.g. auto-size vertically to fit contents, but be horizontally resizable? Assuming SetNextWindowSize() is modified to treat -1.0f on each axis as "keep as-is" (would be good but might break erroneous code): Problem is UpdateWindowManualResize() and lots of code treat (window->AutoFitFramesX > 0 || window->AutoFitFramesY > 0) together. - - window/opt: freeze window flag: if not focused/hovered, return false, render with previous ImDrawList. and/or reduce refresh rate. -> this may require enforcing that it is illegal to submit contents if Begin returns false. - - window/child: background options for child windows, border option (disable rounding). - - window/child: allow resizing of child windows (possibly given min/max for each axis?.) - - window/child: the first draw command of a child window could be moved into the current draw command of the parent window (unless child+tooltip?). - - window/child: border could be emitted in parent as well. - - window/child: allow SetNextWindowContentSize() to work on child windows. - - window/clipping: some form of clipping when DisplaySize (or corresponding viewport) is zero. - - window/tabbing: add a way to signify that a window or docked window requires attention (e.g. blinking title bar). - - window/id_stack: add e.g. window->GetIDFromPath() with support for leading / and ../ (#1390, #331) - ! scrolling: exposing horizontal scrolling with Shift+Wheel even when scrollbar is disabled expose lots of issues (#2424, #1463) - - scrolling: while holding down a scrollbar, try to keep the same contents visible (at least while not moving mouse) - - scrolling: allow immediately effective change of scroll after Begin() if we haven't appended items yet. - - scrolling: forward mouse wheel scrolling to parent window when at the edge of scrolling limits? (useful for listbox,tables?) - - scrolling/clipping: separator on the initial position of a window is not visible (cursorpos.y <= clippos.y). (2017-08-20: can't repro) - - scrolling/style: shadows on scrollable areas to denote that there is more contents (see e.g. DaVinci Resolve ui) - - - drawdata: make it easy to clone (or swap?) a full ImDrawData so user can easily save that data if they use threaded rendering. (e.g. #2646) - ! drawlist: add calctextsize func to facilitate consistent code from user pov (currently need to use ImGui or ImFont alternatives!) - - drawlist: end-user probably can't call Clear() directly because we expect a texture to be pushed in the stack. - - drawlist: maintaining bounding box per command would allow to merge draw command when clipping isn't relied on (typical non-scrolling window or non-overflowing column would merge with previous command). - - drawlist: primitives/helpers to manipulate vertices post submission, so e.g. a quad/rect can be resized to fit later submitted content, _without_ using the ChannelSplit api - - drawlist: make it easier to toggle AA per primitive, so we can use e.g. non-AA fill + AA borders more naturally - - drawlist: non-AA strokes have gaps between points (#593, #288), glitch especially on RenderCheckmark() and ColorPicker4(). - - drawlist: would be good to be able to deep copy of ImDrawData (we have a deep copy of ImDrawList now). - - drawlist: rendering: provide a way for imgui to output to a single/global vertex buffer, re-order indices only at the end of the frame (ref: https://gist.github.com/floooh/10388a0afbe08fce9e617d8aefa7d302) - - drawlist: callback: add an extra void* in ImDrawCallback to allow passing render-local data to the callback (would break API). - - drawlist: AddRect vs AddLine position confusing (#2441) - - drawlist: channel splitter should be external helper and not stored in ImDrawList. - - drawlist: Add quadratic bezier curves? (#3127) - - drawlist/opt: store rounded corners in texture to use 1 quad per corner (filled and wireframe) to lower the cost of rounding. (#1962) - - drawlist/opt: AddRect() axis aligned pixel aligned (no-aa) could use 8 triangles instead of 16 and no normal calculation. - - drawlist/opt: thick AA line could be doable in same number of triangles as 1.0 AA line by storing gradient+full color in atlas. - - - main: find a way to preserve relative orders of multiple reappearing windows (so an app toggling between "modes" e.g. fullscreen vs all tools) won't lose relative ordering. - - main: IsItemHovered() make it more consistent for various type of widgets, widgets with multiple components, etc. also effectively IsHovered() region sometimes differs from hot region, e.g tree nodes - - main: IsItemHovered() info stored in a stack? so that 'if TreeNode() { Text; TreePop; } if IsHovered' return the hover state of the TreeNode? - - - widgets: display mode: widget-label, label-widget (aligned on column or using fixed size), label-newline-tab-widget etc. (#395) - - widgets: clean up widgets internal toward exposing everything and stabilizing imgui_internals.h. - - widgets: add visuals for Disabled/ReadOnly mode and expose publicly (#211) - - widgets: add always-allow-overlap mode. This should perhaps be the default? one problem is that highlight after mouse-wheel scrolling gets deferred, makes scrolling more flickery. - - widgets: start exposing PushItemFlag() and ImGuiItemFlags - - widgets: alignment options in style (e.g. center Selectable, Right-Align within Button, etc.) #1260 - - widgets: activate by identifier (trigger button, focus given id) - - widgets: a way to represent "mixed" values, so e.g. all values replaced with *, including check-boxes, colors, etc. with support for multi-components widgets (e.g. SliderFloat3, make only "Y" mixed) (#2644) - - widgets: checkbox: checkbox with custom glyph inside frame. - - widgets: coloredit: keep reporting as active when picker is on? - - widgets: group/scalarn functions: expose more per-component information. e.g. store NextItemData.ComponentIdx set by scalarn function, groups can expose them back somehow. - - selectable: using (size.x == 0.0f) and (SelectableTextAlign.x > 0.0f) followed by SameLine() is currently not supported. - - selectable: generic BeginSelectable()/EndSelectable() mechanism. - - selectable: a way to visualize partial/mixed selection (e.g. parent tree node has children with mixed selection) - - - input text: clean up the mess caused by converting UTF-8 <> wchar. the code is rather inefficient right now and super fragile. - - input text: preserve scrolling when unfocused? - - input text: reorganize event handling, allow CharFilter to modify buffers, allow multiple events? (#541) - - input text: expose CursorPos in char filter event (#816) - - input text: try usage idiom of using InputText with data only exposed through get/set accessors, without extraneous copy/alloc. (#3009) - - input text: access public fields via a non-callback API e.g. InputTextGetState("xxx") that may return NULL if not active. - - input text: flag to disable live update of the user buffer (also applies to float/int text input) (#701) - - input text: hover tooltip could show unclamped text - - input text: support for INSERT key to toggle overwrite mode. currently disabled because stb_textedit behavior is unsatisfactory on multi-line. (#2863) - - input text: option to Tab after an Enter validation. - - input text: add ImGuiInputTextFlags_EnterToApply? (off #218) - - input text: easier ways to update buffer (from source char*) while owned. preserve some sort of cursor position for multi-line text. - - input text: add flag (e.g. ImGuiInputTextFlags_EscapeClearsBuffer) to clear instead of revert. what to do with focus? (also see #2890) - - input text: add discard flag (e.g. ImGuiInputTextFlags_DiscardActiveBuffer) or make it easier to clear active focus for text replacement during edition (#725) - - input text: display bug when clicking a drag/slider after an input text in a different window has all-selected text (order dependent). actually a very old bug but no one appears to have noticed it. - - input text: allow centering/positioning text so that ctrl+clicking Drag or Slider keeps the textual value at the same pixel position. - - input text: decorrelate layout from inputs - e.g. what's the easiest way to implement a nice IP/Mac address input editor? - - input text: global callback system so user can plug in an expression evaluator easily. (#1691) - - input text: force scroll to end or scroll to a given line/contents (so user can implement a log or a search feature) - - input text: a way to preview completion (e.g. disabled text completing from the cursor) - - input text: a side bar that could e.g. preview where errors are. probably left to the user to draw but we'd need to give them the info there. - - input text: a way for the user to provide syntax coloring. - - input text: Shift+TAB with ImGuiInputTextFlags_AllowTabInput could eat preceding blanks, up to tab_count. - - input text: facilitate patterns like if (InputText(..., obj.get_string_ref()) { obj.set_string(...); } relying on internally held buffer. - - input text multi-line: don't directly call AddText() which does an unnecessary vertex reserve for character count prior to clipping. and/or more line-based clipping to AddText(). and/or reorganize TextUnformatted/RenderText for more efficiency for large text (e.g TextUnformatted could clip and log separately, etc). - - input text multi-line: support for cut/paste without selection (cut/paste the current line) - - input text multi-line: line numbers? status bar? (follow up on #200) - - input text multi-line: behave better when user changes input buffer while editing is active (even though it is illegal behavior). namely, the change of buffer can create a scrollbar glitch (#725) - - input text multi-line: better horizontal scrolling support (#383, #1224) - - input text multi-line: single call to AddText() should be coarse clipped on InputTextEx() end. - - input number: optional range min/max for Input*() functions - - input number: holding [-]/[+] buttons could increase the step speed non-linearly (or user-controlled) - - input number: use mouse wheel to step up/down - - input number: applying arithmetics ops (+,-,*,/) messes up with text edit undo stack. - - - layout: helper or a way to express ImGui::SameLine(ImGui::GetCursorStartPos().x + ImGui::CalcItemWidth() + ImGui::GetStyle().ItemInnerSpacing.x); in a simpler manner. - - layout, font: horizontal tab support, A) text mode: forward only tabs (e.g. every 4 characters/N pixels from pos x1), B) manual mode: explicit tab stops acting as mini columns, no clipping (for menu items, many kind of uses, also vaguely relate to #267, #395) - - layout: horizontal layout helper (#97) - - layout: horizontal flow until no space left (#404) - - layout: more generic alignment state (left/right/centered) for single items? - - layout: clean up the InputFloatN/SliderFloatN/ColorEdit4 layout code. item width should include frame padding. - - layout: vertical alignment of mixed height items (e.g. buttons) within a same line (#1284) - - layout: null layout mode were items are not rendered but user can query GetItemRectMin()/Max/Size. - - layout: (R&D) local multi-pass layout mode. - - layout: (R&D) bind authored layout data (created by an off-line tool), items fetch their pos/size at submission, self-optimize data structures to stable linear access. - - - group: BeginGroup() needs a border option. (~#1496) - - group: IsHovered() after EndGroup() covers whole aabb rather than the intersection of individual items. Is that desirable? - - group: merge deactivation/activation within same group (fwd WasEdited flag). (#2550) - -!- color: the color conversion helpers/types are a mess and needs sorting out. - - color: (api breaking) ImGui::ColorConvertXXX functions should be loose ImColorConvertXX to match imgui_internals.h - - - plot: full featured plot/graph api w/ scrolling, zooming etc. all bell & whistle. why not! - - plot: PlotLines() should use the polygon-stroke facilities, less vertices (currently issues with averaging normals) - - plot: make it easier for user to draw extra stuff into the graph (e.g: draw basis, highlight certain points, 2d plots, multiple plots) - - plot: "smooth" automatic scale over time, user give an input 0.0(full user scale) 1.0(full derived from value) - - plot: option/feature: draw the zero line - - plot: option/feature: draw grid, vertical markers - - plot: option/feature: draw unit - - plot: add a helper e.g. Plot(char* label, float value, float time_span=2.0f) that stores values and Plot them for you - probably another function name. and/or automatically allow to plot ANY displayed value (more reliance on stable ID) - - - clipper: ability to force display 1 item in the list would be convenient (for patterns where we need to set active id etc.) - - clipper: ability to disable the clipping through a simple flag/bool. - - clipper: ability to run without knowing full count in advance. - - clipper: horizontal clipping support. (#2580) - - - separator: expose flags (#759) - - separator: take indent into consideration (optional) - - separator: width, thickness, centering (#1643) - - splitter: formalize the splitter idiom into an official api (we want to handle n-way split) (#319) - - - dock: merge docking branch (#2109) - - dock: dock out from a collapsing header? would work nicely but need emitting window to keep submitting the code. - - - tabs: "there is currently a problem because TabItem() will try to submit their own tooltip after 0.50 second, and this will have the effect of making your tooltip flicker once." -> tooltip priority work - - tabs: close button tends to overlap unsaved-document star - - tabs: consider showing the star at the same spot as the close button, like VS Code does. - - tabs: make EndTabBar fail if users doesn't respect BeginTabBar return value, for consistency/future-proofing. - - tabs: persistent order/focus in BeginTabBar() api (#261, #351) - - tabs: TabItem could honor SetNextItemWidth()? - - tabs: explicit api (even if internal) to cleanly manipulate tab order. - - tabs: Mouse wheel over tab bar could scroll? (#2702) - - - image/image button: misalignment on padded/bordered button? - - image/image button: parameters are confusing, image() has tint_col,border_col whereas imagebutton() has bg_col/tint_col. Even thou they are different parameters ordering could be more consistent. can we fix that? - - image button: not taking an explicit id can be problematic. (#2464, #1390) - - button: provide a button that looks framed. (?) - - slider/drag: ctrl+click when format doesn't include a % character.. disable? display underlying value in default format? (see TempInputTextScalar) - - slider: allow using the [-]/[+] buttons used by InputFloat()/InputInt() - - slider: initial absolute click is imprecise. change to relative movement slider (same as scrollbar). (#1946) - - slider: add dragging-based widgets to edit values with mouse (on 2 axises), saving screen real-estate. - - slider: tint background based on value (e.g. v_min -> v_max, or use 0.0f either side of the sign) - - slider: relative dragging? + precision dragging - - slider: step option (#1183) - - slider: style: fill % of the bar instead of positioning a drag. - - knob: rotating knob widget (#942) - - drag float: support for reversed drags (min > max) (removed is_locked, also see fdc526e) - - drag float: up/down axis - - drag float: power != 0.0f with current value being outside the range keeps the value stuck. - - drag float: added leeway on edge (e.g. a few invisible steps past the clamp limits) - - - combo: use clipper: make it easier to disable clipper with a single flag. - - combo: flag for BeginCombo to not return true when unchanged (#1182) - - combo: a way/helper to customize the combo preview (#1658) -> exeperimental BeginComboPreview() - - combo/listbox: keyboard control. need InputText-like non-active focus + key handling. considering keyboard for custom listbox (pr #203) - - listbox: multiple selection. - - listbox: unselect option (#1208) - - listbox: make it easier/more natural to implement range-select (need some sort of info/ref about the last clicked/focused item that user can translate to an index?) (wip stash) - - listbox: user may want to initial scroll to focus on the one selected value? - - listbox: expose hovered item for a simplified ListBox api - - listbox: keyboard navigation. - - listbox: disable capturing mouse wheel if the listbox has no scrolling. (#1681) - - listbox: scrolling should track modified selection. - - listbox: future api should allow to enable horizontal scrolling (#2510) - -!- popups/menus: clarify usage of popups id, how MenuItem/Selectable closing parent popups affects the ID, etc. this is quite fishy needs improvement! (#331, #402) - - modals: make modal title bar blink when trying to click outside the modal - - modals: technically speaking, we could make Begin() with ImGuiWindowFlags_Modal work without involving popup. May help untangle a few things, as modals are more like regular windows than popups. - - popups: if the popup functions took explicit ImGuiID it would allow the user to manage the scope of those ID. (#331) - - popups: clicking outside (to close popup) and holding shouldn't drag window below. - - popups: add variant using global identifier similar to Begin/End (#402) - - popups: border options. richer api like BeginChild() perhaps? (#197) - - popups: flags could be reworked to allow both mouse buttons as index (0..5 and as flags using higher-bit) allowing to or them. - - popups/modals: although it is sometimes convenient that popups/modals lifetime is owned by imgui, we could also a bool-owned-by-user api as long as Begin() return value testing is enforced. - - - tooltip: drag and drop with tooltip near monitor edges lose/changes its last direction instead of locking one. The drag and drop tooltip should always follow without changing direction. - - tooltip: allow to set the width of a tooltip to allow TextWrapped() etc. while keeping the height automatic. - - tooltip: tooltips with delay timers? or general timer policy? (instantaneous vs timed): IsItemHovered() with timer + implicit aabb-id for items with no ID. (#1485) - - tooltip: drag tooltip hovering over source widget with IsItemHovered/SetTooltip flickers. - - - menus: menu bars inside modal windows are acting weird. - - status-bar: add a per-window status bar helper similar to what menu-bar does. - - shortcuts: local-style shortcut api, e.g. parse "&Save" - - shortcuts,menus: global-style shortcut api e.g. "Save (CTRL+S)" -> explicit flag for recursing into closed menu - - shortcuts: programmatically access shortcuts "Focus("&Save")) - - menus: hovering a disabled BeginMenu or MenuItem won't close another menu - - menus: menu-bar: main menu-bar could affect clamping of windows position (~ akin to modifying DisplayMin) - - menus: hovering from menu to menu on a menu-bar has 1 frame without any menu, which is a little annoying. ideally either 0 either longer. - - menus: could merge draw call in most cases (how about storing an optional aabb in ImDrawCmd to move the burden of merging in a single spot). - - menus: would be nice if the Selectable() supported horizontal alignment (must be given the equivalent of WorkRect.Max.x matching the position of the shortcut column) - - - tree node: add treenode/treepush int variants? not there because (void*) cast from int warns on some platforms/settings? - - tree node: try to apply scrolling at time of TreePop() if node was just opened and end of node is past scrolling limits? - - tree node / selectable render mismatch which is visible if you use them both next to each other (e.g. cf. property viewer) - - tree node: tweak color scheme to distinguish headers from selected tree node (#581) - - tree node: leaf/non-leaf highlight mismatch. - - tree node: flag to disable formatting and/or detect "%s" - - tree node/opt: could avoid formatting when clipped (flag assuming we don't care about width/height, assume single line height? format only %s/%c to be able to count height?) - - - settings: write more decent code to allow saving/loading new fields: columns, selected tree nodes? - - settings: api for per-tool simple persistent data (bool,int,float,columns sizes,etc.) in .ini file (#437) - - settings/persistence: helpers to make TreeNodeBehavior persist (even during dev!) - may need to store some semantic and/or data type in ImGuiStoragePair - - - style: better default styles. (#707) - - style: PushStyleVar: allow direct access to individual float X/Y elements. - - style: add a highlighted text color (for headers, etc.) - - style: border types: out-screen, in-screen, etc. (#447) - - style: add window shadow (fading away from the window. Paint-style calculation of vertices alpha after drawlist would be easier) - - style: a concept of "compact style" that the end-user can easily rely on (e.g. PushStyleCompact()?) that maps to other settings? avoid implementing duplicate helpers such as SmallCheckbox(), etc. - - style: try to make PushStyleVar() more robust to incorrect parameters (to be more friendly to edit & continues situation). - - style: global scale setting. - - style: FramePadding could be different for up vs down (#584) - - style: WindowPadding needs to be EVEN as the 0.5 multiplier used on this value probably have a subtle effect on clip rectangle - - style: have a more global HSV setter (e.g. alter hue on all elements). consider replacing active/hovered by offset in HSV space? (#438, #707, #1223) - - style: gradients fill (#1223) ~ 2 bg colors for each fill? tricky with rounded shapes and using textures for corners. - - style editor: color child window height expressed in multiple of line height. - - - log: improve logging of ArrowButton, ListBox, TabItem - - log: carry on indent / tree depth when opening a child window - - log: enabling log ends up pushing and growing vertices buffers because we don't distinguish layout vs render clipping - - log: have more control over the log scope (e.g. stop logging when leaving current tree node scope) - - log: be able to log anything (e.g. right-click on a window/tree-node, shows context menu? log into tty/file/clipboard) - - log: let user copy any window content to clipboard easily (CTRL+C on windows? while moving it? context menu?). code is commented because it fails with multiple Begin/End pairs. - - log: obsolete LogButtons() all together. - - log: LogButtons() options for specifying depth and/or hiding depth slider - - - filters: set a current filter that tree node can automatically query to hide themselves - - filters: handle wild-cards (with implicit leading/trailing *), reg-exprs - - filters: fuzzy matches (may use code at blog.forrestthewoods.com/4cffeed33fdb) - - - drag and drop: fix/support/options for overlapping drag sources. - - drag and drop: focus drag target window on hold (even without open) - - drag and drop: releasing a drop shows the "..." tooltip for one frame - since e13e598 (#1725) - - drag and drop: drag source on a group object (would need e.g. an invisible button covering group in EndGroup) https://twitter.com/paniq/status/1121446364909535233 - - drag and drop: have some way to know when a drag begin from BeginDragDropSource() pov. (see 2018/01/11 post in #143) - - drag and drop: allow preview tooltip to be submitted from a different place than the drag source. (#1725) - - drag and drop: allow using with other mouse buttons (where activeid won't be set). (#1637) - - drag and drop: make it easier and provide a demo to have tooltip both are source and target site, with a more detailed one on target site (tooltip ordering problem) - - drag and drop: demo with reordering nodes (in a list, or a tree node). (#143) - - drag and drop: test integrating with os drag and drop (make it easy to do a naive WM_DROPFILE integration) - - drag and drop: allow for multiple payload types. (#143) - - drag and drop: make payload optional? payload promise? (see 2018/01/11 post in #143) - - drag and drop: (#143) "both an in-process pointer and a promise to generate a serialized version, for whether the drag ends inside or outside the same process" - - drag and drop: feedback when hovering a region blocked by modal (mouse cursor "NO"?) - - - node/graph editors (#306) (also see https://github.com/ocornut/imgui/wiki#node-editors) - - pie menus patterns (#434) - - markup: simple markup language for color change? (#902) - - - text: selectable text (for copy) as a generic feature (ItemFlags?) - - text: proper alignment options in imgui_internal.h - - text: it's currently impossible to have a window title with "##". perhaps an official workaround would be nice. \ style inhibitor? non-visible ascii code to insert between #? - - text: provided a framed text helper, e.g. https://pastebin.com/1Laxy8bT - - text: refactor TextUnformatted (or underlying function) to more explicitly request if we need width measurement or not - - text/layout/tabs: \t pulling position from base pos + step, or offset array (e.g. could be used in text edit, menus for simple icon+text alignment, etc.) - - text link/url button: underlined. should api expose an ID or use text contents as ID? which colors enum to use? - - text/wrapped: should be a more first-class citizen, e.g. wrapped text within a Selectable with known width. - - text/wrapped: custom separator for text wrapping. (#3002) - - text/wrapped: figure out better way to use TextWrapped() in an always auto-resize context (tooltip, etc.) (#249) - - - font: arbitrary line spacing. (#2945) - - font: MergeMode: flags to select overwriting or not (this is now very easy with refactored ImFontAtlasBuildWithStbTruetype) - - font: free the Alpha buffer if user only requested RGBA. -!- font: better CalcTextSizeA() API, at least for simple use cases. current one is horrible (perhaps have simple vs extended versions). - - font: for the purpose of RenderTextEllipsis(), it might be useful that CalcTextSizeA() can ignore the trailing padding? - - font: a CalcTextHeight() helper could run faster than CalcTextSize().y - - font: enforce monospace through ImFontConfig (for icons?) + create dual ImFont output from same input, reusing rasterized data but with different glyphs/AdvanceX - - font: finish CustomRectRegister() to allow mapping Unicode codepoint to custom texture data - - font: remove ID from CustomRect registration, it seems unnecessary! - - font: make it easier to submit own bitmap font (same texture, another texture?). (#2127, #2575) - - font: PushFontSize API (#1018) - - font: MemoryTTF taking ownership confusing/not obvious, maybe default should be opposite? - - font: storing MinAdvanceX per font would allow us to skip calculating line width (under a threshold of character count) in loops looking for block width - - font/demo: add tools to show glyphs used by a text blob, display U16 value, list missing glyphs. - - font/demo: demonstrate use of ImFontGlyphRangesBuilder. - - font/atlas: add a missing Glyphs.reserve() - - font/atlas: incremental updates - - font/atlas: dynamic font atlas to avoid baking huge ranges into bitmap and make scaling easier. - - font/draw: vertical and/or rotated text renderer (#705) - vertical is easier clipping wise - - font/draw: need to be able to specify wrap start position. - - font/draw: better reserve policy for large horizontal block of text (shouldn't reserve for all clipped lines). also see #3349. - - font/draw: fix for drawing 16k+ visible characters in same call. - - font/draw: underline, squiggle line rendering helpers. - - font: optimization: for monospace font (like the default one) we can trim IndexXAdvance as long as trailing value is == FallbackXAdvance (need to make sure TAB is still correct), would save on cache line. - - font: add support for kerning, probably optional. A) perhaps default to (32..128)^2 matrix ~ 9K entries = 36KB, then hash for non-ascii?. B) or sparse lookup into per-char list? - - font: add a simpler CalcTextSizeA() api? current one ok but not welcome if user needs to call it directly (without going through ImGui::CalcTextSize) - - font: fix AddRemapChar() to work before atlas has been built. - - font: support for unicode codepoints higher than 0xFFFF? (pr #2815) - - font: (api breaking) remove "TTF" from symbol names. also because it now supports OTF. - - font/opt: Considering storing standalone AdvanceX table as 16-bit fixed point integer? - - font/opt: Glyph currently 40 bytes (2+9*4). Consider storing UV as 16 bits integer? (->32 bytes). X0/Y0/X1/Y1 as 16 fixed-point integers? Or X0/Y0 as float and X1/Y1 as fixed8_8? - - - nav: some features such as PageUp/Down/Home/End should probably work without ImGuiConfigFlags_NavEnableKeyboard? (where do we draw the line?) - - nav: configuration flag to disable global shortcuts (currently only CTRL-Tab) ? - ! nav: never clear NavId on some setup (e.g. gamepad centric) - - nav: scroll up/down if possible when move request fails - - nav: there's currently no way to completely clear focus with the keyboard. depending on patterns used by the application to dispatch inputs, it may be desirable. - - nav: code to focus child-window on restoring NavId appears to have issue: e.g. when focus change is implicit because of window closure. - - nav: Home/End behavior when navigable item is not fully visible at the edge of scrolling? should be backtrack to keep item into view? - - nav: NavScrollToBringItemIntoView() with item bigger than view should focus top-right? Repro: using Nav in "About Window" - - nav: wrap around logic to allow e.g. grid based layout (pressing NavRight on the right-most element would go to the next row, etc.). see internal's NavMoveRequestTryWrapping(). - - nav: patterns to make it possible for arrows key to update selection (see JustMovedTo in range_select branch) - - nav: restore/find nearest NavId when current one disappear (e.g. pressed a button that disappear, or perhaps auto restoring when current button change name) - - nav: SetItemDefaultFocus() level of priority, so widget like Selectable when inside a popup could claim a low-priority default focus on the first selected iem - - nav: NavFlattened: init requests don't work properly on flattened siblings. - - nav: NavFlattened: pageup/pagedown/home/end don't work properly on flattened siblings. - - nav: NavFlattened: ESC on a flattened child should select something. - - nav: NavFlattened: broken: in typical usage scenario, the items of a fully clipped child are currently not considered to enter into a NavFlattened child. - - nav: NavFlattened: cannot access menu-bar of a flattened child window with Alt/menu key (not a very common use case..). - - nav: simulate right-click or context activation? (SHIFT+F10) - - nav/tabbing: refactor old tabbing system and turn into navigation, should pass through all widgets (in submission order?). - - nav/popup: esc/enter default behavior for popups, e.g. be able to mark an "ok" or "cancel" button that would get triggered by those keys, default validation button, etc. - - nav/treenode: left within a tree node block as a fallback (ImGuiTreeNodeFlags_NavLeftJumpsBackHere by default?) - - nav/menus: pressing left-right on a vertically clipped menu bar tends to jump to the collapse/close buttons. - - nav/menus: allow pressing Menu to leave a sub-menu. - - nav/menus: a way to access the main menu bar with Alt? (currently needs CTRL+TAB) or last focused window menu bar? - - nav/menus: when using the main menu bar, even though we restore focus after, the underlying window loses its title bar highlight during menu manipulation. could we prevent it? - - nav/menus: main menu bar currently cannot restore a NULL focus. Could save NavWindow at the time of being focused, similarly to what popup do? - - nav/menus: Alt,Up could open the first menu (e.g. "File") currently it tends to nav into the window/collapse menu. Do do that we would need custom transition? - - nav/windowing: configure fade-in/fade-out delay on Ctrl+Tab? - - nav/windowing: when CTRL-Tab/windowing is active, the HoveredWindow detection doesn't take account of the window display re-ordering. - - nav/windowing: Resizing window will currently fail with certain types of resizing constraints/callback applied - - focus: preserve ActiveId/focus stack state, e.g. when opening a menu and close it, previously selected InputText() focus gets restored (#622) - - - inputs: we need an explicit flag about whether the imgui window is focused, to be able to distinguish focused key releases vs alt-tabbing all release behaviors. - - inputs: rework IO system to be able to pass actual ordered/timestamped events. use an event queue? (~#335, #71) - - inputs: support track pad style scrolling & slider edit. - - inputs/io: backspace and arrows in the context of a text input could use system repeat rate. - - inputs/io: clarify/standardize/expose repeat rate and repeat delays (#1808) - - inputs/scrolling: support for smooth scrolling (#2462, #2569) - - - misc: idle: expose "woken up" boolean (set by inputs) and/or animation time (for cursor blink) for backend to be able stop refreshing easily. - - misc: idle: if cursor blink if the _only_ visible animation, core imgui could rewrite vertex alpha to avoid CPU pass on ImGui:: calls. - - misc: idle: if cursor blink if the _only_ visible animation, could even expose a dirty rectangle that optionally can be leverage by some app to render in a smaller viewport, getting rid of much pixel shading cost. - - misc: no way to run a root-most GetID() with ImGui:: api since there's always a Debug window in the stack. (mentioned in #2960) - - misc: make the ImGuiCond values linear (non-power-of-two). internal storage for ImGuiWindow can use integers to combine into flags (Why?) - - misc: PushItemFlag(): add a flag to disable keyboard capture when used with mouse? (#1682) - - misc: use more size_t in public api? - - misc: possible compile-time support for string view/range instead of char* would e.g. facilitate usage with Rust (#683) - - misc: possible compile-time support for wchar_t instead of char*? - - - remote: make a system like RemoteImGui first-class citizen/project (#75) - - - demo: find a way to demonstrate textures in the examples application, as it such a common issue for new users. - - demo: demonstrate using PushStyleVar() in more details. - - demo: add vertical separator demo - - demo: add virtual scrolling example? - - demo: demonstrate Plot offset - - demo: window size constraint: square demo is broken when resizing from edges (#1975), would need to rework the callback system to solve this - - - examples: window minimize, maximize (#583) - - examples: provide a zero frame-rate/idle example. - - examples: dx11/dx12: try to use new swapchain blit models (#2970) - - backends: move to backends/ folder? - - backends: report it better when not able to create texture? - - backends: apple: example_apple should be using modern GL3. - - backends: glfw: could go idle when minimized? if (glfwGetWindowAttrib(window, GLFW_ICONIFIED)) { glfwWaitEvents(); continue; } // issue: DeltaTime will be super high on resume, perhaps provide a way to let impl know (#440) - - backends: opengl: rename imgui_impl_opengl2 to impl_opengl_legacy and imgui_impl_opengl3 to imgui_impl_opengl? (#1900) - - backends: opengl: could use a single vertex buffer and glBufferSubData for uploads? - - backends: opengl: explicitly disable GL_STENCIL_TEST in bindings. - - backends: vulkan: viewport: support for synchronized swapping of multiple swap chains. - - backends: bgfx: https://gist.github.com/RichardGale/6e2b74bc42b3005e08397236e4be0fd0 - - backends: mscriptem: with refactored examples, we could provide a direct imgui_impl_emscripten platform layer (see eg. https://github.com/floooh/sokol-samples/blob/master/html5/imgui-emsc.cc#L42) - - - bindings: ways to use clang ast dump to generate bindings or helpers for bindings? (e.g. clang++ -Xclang -ast-dump=json imgui.h) - - - optimization: replace vsnprintf with stb_printf? using IMGUI_USE_STB_SPRINTF.(#1038) - - optimization: add clipping for multi-component widgets (SliderFloatX, ColorEditX, etc.). one problem is that nav branch can't easily clip parent group when there is a move request. - - optimization: add a flag to disable most of rendering, for the case where the user expect to skip it (#335) - - optimization: fully covered window (covered by another with non-translucent bg + WindowRounding worth of padding) may want to clip rendering. - - optimization: use another hash function than crc32, e.g. FNV1a - - optimization/render: merge command-lists with same clip-rect into one even if they aren't sequential? (as long as in-between clip rectangle don't overlap)? - - optimization: turn some the various stack vectors into statically-sized arrays diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/README.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/README.txt deleted file mode 100644 index 6db2f3c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/README.txt +++ /dev/null @@ -1,9 +0,0 @@ -See BACKENDS and EXAMPLES files in the docs/ folder, or on the web at: https://github.com/ocornut/imgui/tree/master/docs - -Backends = Helper code to facilitate integration with platforms/graphics api (used by Examples + should be used by your app). -Examples = Standalone applications showcasing integration with platforms/graphics api. - -Some Examples have extra README files in their respective directory, please check them too! - -Once Dear ImGui is running (in either examples or your own application/game/engine), -run and refer to ImGui::ShowDemoWindow() in imgui_demo.cpp for the end-user API. diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_allegro5/README.md b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_allegro5/README.md deleted file mode 100644 index d6d812e..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_allegro5/README.md +++ /dev/null @@ -1,36 +0,0 @@ - -# Configuration - -Dear ImGui outputs 16-bit vertex indices by default. -Allegro doesn't support them natively, so we have two solutions: convert the indices manually in imgui_impl_allegro5.cpp, or compile dear imgui with 32-bit indices. -You can either modify imconfig.h that comes with Dear ImGui (easier), or set a C++ preprocessor option IMGUI_USER_CONFIG to find to a filename. -We are providing `imconfig_allegro5.h` that enables 32-bit indices. -Note that the backend supports _BOTH_ 16-bit and 32-bit indices, but 32-bit indices will be slightly faster as they won't require a manual conversion. - -# How to Build - -### On Ubuntu 14.04+ and macOS - -```bash -g++ -DIMGUI_USER_CONFIG=\"examples/example_allegro5/imconfig_allegro5.h\" -I .. -I ../.. main.cpp ../../backends/imgui_impl_allegro5.cpp ../../imgui*.cpp -lallegro -lallegro_main -lallegro_primitives -o allegro5_example -``` - -On macOS, install Allegro with homebrew: `brew install allegro`. - -### On Windows with Visual Studio's CLI - -You may install Allegro using vcpkg: -``` -git clone https://github.com/Microsoft/vcpkg -cd vcpkg -bootstrap-vcpkg.bat -vcpkg install allegro5 --triplet=x86-windows ; for win32 -vcpkg install allegro5 --triplet=x64-windows ; for win64 -vcpkg integrate install ; register include / libs in Visual Studio -``` - -Build: -``` -set ALLEGRODIR=path_to_your_allegro5_folder -cl /Zi /MD /I %ALLEGRODIR%\include /DIMGUI_USER_CONFIG=\"examples/example_allegro5/imconfig_allegro5.h\" /I .. /I ..\.. main.cpp ..\..\backends\imgui_impl_allegro5.cpp ..\..\imgui*.cpp /link /LIBPATH:%ALLEGRODIR%\lib allegro-5.0.10-monolith-md.lib user32.lib -``` diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_allegro5/example_allegro5.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_allegro5/example_allegro5.vcxproj deleted file mode 100644 index 69b0ece..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_allegro5/example_allegro5.vcxproj +++ /dev/null @@ -1,180 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {73F235B5-7D31-4FC6-8682-DDC5A097B9C1} - example_allegro5 - 8.1 - - - - Application - true - MultiByte - v140 - - - Application - true - MultiByte - v140 - - - Application - false - true - MultiByte - v140 - - - Application - false - true - MultiByte - v140 - - - - - - - - - - - - - - - - - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - - Level4 - Disabled - ..\..;..\..\backends;%(AdditionalIncludeDirectories) - - - true - %(AdditionalLibraryDirectories) - opengl32.lib;%(AdditionalDependencies) - Console - msvcrt.lib - - - - - Level4 - Disabled - ..\..;..\..\backends;%(AdditionalIncludeDirectories) - - - true - %(AdditionalLibraryDirectories) - opengl32.lib;%(AdditionalDependencies) - Console - msvcrt.lib - - - - - Level4 - MaxSpeed - true - true - ..\..;..\..\backends;%(AdditionalIncludeDirectories) - false - - - true - true - true - %(AdditionalLibraryDirectories) - opengl32.lib;%(AdditionalDependencies) - Console - - - - - - - Level4 - MaxSpeed - true - true - ..\..;..\..\backends;%(AdditionalIncludeDirectories) - false - - - true - true - true - %(AdditionalLibraryDirectories) - opengl32.lib;%(AdditionalDependencies) - Console - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_allegro5/example_allegro5.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_allegro5/example_allegro5.vcxproj.filters deleted file mode 100644 index 7fea78b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_allegro5/example_allegro5.vcxproj.filters +++ /dev/null @@ -1,58 +0,0 @@ - - - - - {20b90ce4-7fcb-4731-b9a0-075f875de82d} - - - {f18ab499-84e1-499f-8eff-9754361e0e52} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - imgui - - - imgui - - - imgui - - - sources - - - sources - - - sources - - - imgui - - - imgui - - - - - imgui - - - imgui - - - imgui - - - sources - - - - - - sources - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_allegro5/imconfig_allegro5.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_allegro5/imconfig_allegro5.h deleted file mode 100644 index 35afa67..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_allegro5/imconfig_allegro5.h +++ /dev/null @@ -1,11 +0,0 @@ -//----------------------------------------------------------------------------- -// COMPILE-TIME OPTIONS FOR DEAR IMGUI ALLEGRO 5 EXAMPLE -// See imconfig.h for the full template -// Because Allegro doesn't support 16-bit vertex indices, we enable the compile-time option of imgui to use 32-bit indices -//----------------------------------------------------------------------------- - -#pragma once - -// Use 32-bit vertex indices because Allegro doesn't support 16-bit ones -// This allows us to avoid converting vertices format at runtime -#define ImDrawIdx int diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_allegro5/main.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_allegro5/main.cpp deleted file mode 100644 index 4fd379a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_allegro5/main.cpp +++ /dev/null @@ -1,144 +0,0 @@ -// Dear ImGui: standalone example application for Allegro 5 -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -// On Windows, you can install Allegro5 using vcpkg: -// git clone https://github.com/Microsoft/vcpkg -// cd vcpkg -// bootstrap - vcpkg.bat -// vcpkg install allegro5 --triplet=x86-windows ; for win32 -// vcpkg install allegro5 --triplet=x64-windows ; for win64 -// vcpkg integrate install ; register include and libs in Visual Studio - -#include -#include -#include -#include "imgui.h" -#include "imgui_impl_allegro5.h" - -int main(int, char**) -{ - // Setup Allegro - al_init(); - al_install_keyboard(); - al_install_mouse(); - al_init_primitives_addon(); - al_set_new_display_flags(ALLEGRO_RESIZABLE); - ALLEGRO_DISPLAY* display = al_create_display(1280, 720); - al_set_window_title(display, "Dear ImGui Allegro 5 example"); - ALLEGRO_EVENT_QUEUE* queue = al_create_event_queue(); - al_register_event_source(queue, al_get_display_event_source(display)); - al_register_event_source(queue, al_get_keyboard_event_source()); - al_register_event_source(queue, al_get_mouse_event_source()); - - // Setup Dear ImGui context - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); (void)io; - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls - - // Setup Dear ImGui style - ImGui::StyleColorsDark(); - //ImGui::StyleColorsClassic(); - - // Setup Platform/Renderer backends - ImGui_ImplAllegro5_Init(display); - - // Load Fonts - // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. - // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. - // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). - // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call. - // - Read 'docs/FONTS.md' for more instructions and details. - // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! - //io.Fonts->AddFontDefault(); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f); - //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - //IM_ASSERT(font != NULL); - - bool show_demo_window = true; - bool show_another_window = false; - ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); - - // Main loop - bool running = true; - while (running) - { - // Poll and handle events (inputs, window resize, etc.) - // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. - // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. - // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. - // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. - ALLEGRO_EVENT ev; - while (al_get_next_event(queue, &ev)) - { - ImGui_ImplAllegro5_ProcessEvent(&ev); - if (ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) - running = false; - if (ev.type == ALLEGRO_EVENT_DISPLAY_RESIZE) - { - ImGui_ImplAllegro5_InvalidateDeviceObjects(); - al_acknowledge_resize(display); - ImGui_ImplAllegro5_CreateDeviceObjects(); - } - } - - // Start the Dear ImGui frame - ImGui_ImplAllegro5_NewFrame(); - ImGui::NewFrame(); - - // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). - if (show_demo_window) - ImGui::ShowDemoWindow(&show_demo_window); - - // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window. - { - static float f = 0.0f; - static int counter = 0; - - ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. - - ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) - ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state - ImGui::Checkbox("Another Window", &show_another_window); - - ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f - ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color - - if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) - counter++; - ImGui::SameLine(); - ImGui::Text("counter = %d", counter); - - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); - ImGui::End(); - } - - // 3. Show another simple window. - if (show_another_window) - { - ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked) - ImGui::Text("Hello from another window!"); - if (ImGui::Button("Close Me")) - show_another_window = false; - ImGui::End(); - } - - // Rendering - ImGui::Render(); - al_clear_to_color(al_map_rgba_f(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w)); - ImGui_ImplAllegro5_RenderDrawData(ImGui::GetDrawData()); - al_flip_display(); - } - - // Cleanup - ImGui_ImplAllegro5_Shutdown(); - ImGui::DestroyContext(); - al_destroy_event_queue(queue); - al_destroy_display(display); - - return 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_android_opengl3/CMakeLists.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_android_opengl3/CMakeLists.txt deleted file mode 100644 index 63531f4..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_android_opengl3/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -cmake_minimum_required(VERSION 3.6) - -project(ImGuiExample) - -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) - -add_library(${CMAKE_PROJECT_NAME} SHARED - ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../imgui.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../imgui_demo.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../imgui_draw.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../imgui_tables.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../imgui_widgets.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../backends/imgui_impl_android.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../../backends/imgui_impl_opengl3.cpp - ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c -) - -set(CMAKE_SHARED_LINKER_FLAGS - "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate" -) - -target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE - IMGUI_IMPL_OPENGL_ES3 -) - -target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/../.. - ${CMAKE_CURRENT_SOURCE_DIR}/../../backends - ${ANDROID_NDK}/sources/android/native_app_glue -) - -target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE - android - EGL - GLESv3 - log -) diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_android_opengl3/android/.gitignore b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_android_opengl3/android/.gitignore deleted file mode 100644 index 3c7a619..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_android_opengl3/android/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -.cxx -.externalNativeBuild -build/ -*.iml - -.idea -.gradle -local.properties - -# Android Studio puts a Gradle wrapper here, that we don't want: -gradle/ -gradlew* diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_android_opengl3/android/app/build.gradle b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_android_opengl3/android/app/build.gradle deleted file mode 100644 index aa7f0ea..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_android_opengl3/android/app/build.gradle +++ /dev/null @@ -1,34 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' - -android { - compileSdkVersion 29 - buildToolsVersion "30.0.3" - ndkVersion "21.4.7075529" - defaultConfig { - applicationId "imgui.example.android" - minSdkVersion 23 - targetSdkVersion 29 - versionCode 1 - versionName "1.0" - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt') - } - } - - externalNativeBuild { - cmake { - path "../../CMakeLists.txt" - } - } -} -repositories { - mavenCentral() -} -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_android_opengl3/android/app/src/main/AndroidManifest.xml b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_android_opengl3/android/app/src/main/AndroidManifest.xml deleted file mode 100644 index c4009e5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_android_opengl3/android/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_android_opengl3/android/app/src/main/java/MainActivity.kt b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_android_opengl3/android/app/src/main/java/MainActivity.kt deleted file mode 100644 index 896a88c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_android_opengl3/android/app/src/main/java/MainActivity.kt +++ /dev/null @@ -1,40 +0,0 @@ -package imgui.example.android - -import android.app.NativeActivity -import android.os.Bundle -import android.content.Context -import android.view.inputmethod.InputMethodManager -import android.view.KeyEvent -import java.util.concurrent.LinkedBlockingQueue - -class MainActivity : NativeActivity() { - public override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - } - - fun showSoftInput() { - val inputMethodManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager - inputMethodManager.showSoftInput(this.window.decorView, 0) - } - - fun hideSoftInput() { - val inputMethodManager = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager - inputMethodManager.hideSoftInputFromWindow(this.window.decorView.windowToken, 0) - } - - // Queue for the Unicode characters to be polled from native code (via pollUnicodeChar()) - private var unicodeCharacterQueue: LinkedBlockingQueue = LinkedBlockingQueue() - - // We assume dispatchKeyEvent() of the NativeActivity is actually called for every - // KeyEvent and not consumed by any View before it reaches here - override fun dispatchKeyEvent(event: KeyEvent): Boolean { - if (event.action == KeyEvent.ACTION_DOWN) { - unicodeCharacterQueue.offer(event.getUnicodeChar(event.metaState)) - } - return super.dispatchKeyEvent(event) - } - - fun pollUnicodeChar(): Int { - return unicodeCharacterQueue.poll() ?: 0 - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_android_opengl3/android/build.gradle b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_android_opengl3/android/build.gradle deleted file mode 100644 index 59f9c78..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_android_opengl3/android/build.gradle +++ /dev/null @@ -1,24 +0,0 @@ -buildscript { - ext.kotlin_version = '1.4.31' - repositories { - google() - mavenCentral() - - } - dependencies { - classpath 'com.android.tools.build:gradle:4.1.0' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - - } -} - -allprojects { - repositories { - google() - mavenCentral() - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_android_opengl3/android/settings.gradle b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_android_opengl3/android/settings.gradle deleted file mode 100644 index e7b4def..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_android_opengl3/android/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include ':app' diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_android_opengl3/main.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_android_opengl3/main.cpp deleted file mode 100644 index 5ab6903..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_android_opengl3/main.cpp +++ /dev/null @@ -1,369 +0,0 @@ -// dear imgui: standalone example application for Android + OpenGL ES 3 -// If you are new to dear imgui, see examples/README.txt and documentation at the top of imgui.cpp. - -#include "imgui.h" -#include "imgui_impl_android.h" -#include "imgui_impl_opengl3.h" -#include -#include -#include -#include -#include - -// Data -static EGLDisplay g_EglDisplay = EGL_NO_DISPLAY; -static EGLSurface g_EglSurface = EGL_NO_SURFACE; -static EGLContext g_EglContext = EGL_NO_CONTEXT; -static struct android_app* g_App = NULL; -static bool g_Initialized = false; -static char g_LogTag[] = "ImGuiExample"; - -// Forward declarations of helper functions -static int ShowSoftKeyboardInput(); -static int PollUnicodeChars(); -static int GetAssetData(const char* filename, void** out_data); - -void init(struct android_app* app) -{ - if (g_Initialized) - return; - - g_App = app; - ANativeWindow_acquire(g_App->window); - - // Initialize EGL - // This is mostly boilerplate code for EGL... - { - g_EglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); - if (g_EglDisplay == EGL_NO_DISPLAY) - __android_log_print(ANDROID_LOG_ERROR, g_LogTag, "%s", "eglGetDisplay(EGL_DEFAULT_DISPLAY) returned EGL_NO_DISPLAY"); - - if (eglInitialize(g_EglDisplay, 0, 0) != EGL_TRUE) - __android_log_print(ANDROID_LOG_ERROR, g_LogTag, "%s", "eglInitialize() returned with an error"); - - const EGLint egl_attributes[] = { EGL_BLUE_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_RED_SIZE, 8, EGL_DEPTH_SIZE, 24, EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_NONE }; - EGLint num_configs = 0; - if (eglChooseConfig(g_EglDisplay, egl_attributes, nullptr, 0, &num_configs) != EGL_TRUE) - __android_log_print(ANDROID_LOG_ERROR, g_LogTag, "%s", "eglChooseConfig() returned with an error"); - if (num_configs == 0) - __android_log_print(ANDROID_LOG_ERROR, g_LogTag, "%s", "eglChooseConfig() returned 0 matching config"); - - // Get the first matching config - EGLConfig egl_config; - eglChooseConfig(g_EglDisplay, egl_attributes, &egl_config, 1, &num_configs); - EGLint egl_format; - eglGetConfigAttrib(g_EglDisplay, egl_config, EGL_NATIVE_VISUAL_ID, &egl_format); - ANativeWindow_setBuffersGeometry(g_App->window, 0, 0, egl_format); - - const EGLint egl_context_attributes[] = { EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE }; - g_EglContext = eglCreateContext(g_EglDisplay, egl_config, EGL_NO_CONTEXT, egl_context_attributes); - - if (g_EglContext == EGL_NO_CONTEXT) - __android_log_print(ANDROID_LOG_ERROR, g_LogTag, "%s", "eglCreateContext() returned EGL_NO_CONTEXT"); - - g_EglSurface = eglCreateWindowSurface(g_EglDisplay, egl_config, g_App->window, NULL); - eglMakeCurrent(g_EglDisplay, g_EglSurface, g_EglSurface, g_EglContext); - } - - // Setup Dear ImGui context - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); - - // Disable loading/saving of .ini file from disk. - // FIXME: Consider using LoadIniSettingsFromMemory() / SaveIniSettingsToMemory() to save in appropriate location for Android. - io.IniFilename = NULL; - - // Setup Dear ImGui style - ImGui::StyleColorsDark(); - //ImGui::StyleColorsClassic(); - - // Setup Platform/Renderer backends - ImGui_ImplAndroid_Init(g_App->window); - ImGui_ImplOpenGL3_Init("#version 300 es"); - - // Load Fonts - // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. - // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). - // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call. - // - Read 'docs/FONTS.md' for more instructions and details. - // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! - // - Android: The TTF files have to be placed into the assets/ directory (android/app/src/main/assets), we use our GetAssetData() helper to retrieve them. - - // We load the default font with increased size to improve readability on many devices with "high" DPI. - // FIXME: Put some effort into DPI awareness. - // Important: when calling AddFontFromMemoryTTF(), ownership of font_data is transfered by Dear ImGui by default (deleted is handled by Dear ImGui), unless we set FontDataOwnedByAtlas=false in ImFontConfig - ImFontConfig font_cfg; - font_cfg.SizePixels = 22.0f; - io.Fonts->AddFontDefault(&font_cfg); - //void* font_data; - //int font_data_size; - //ImFont* font; - //font_data_size = GetAssetData("Roboto-Medium.ttf", &font_data); - //font = io.Fonts->AddFontFromMemoryTTF(font_data, font_data_size, 16.0f); - //IM_ASSERT(font != NULL); - //font_data_size = GetAssetData("Cousine-Regular.ttf", &font_data); - //font = io.Fonts->AddFontFromMemoryTTF(font_data, font_data_size, 15.0f); - //IM_ASSERT(font != NULL); - //font_data_size = GetAssetData("DroidSans.ttf", &font_data); - //font = io.Fonts->AddFontFromMemoryTTF(font_data, font_data_size, 16.0f); - //IM_ASSERT(font != NULL); - //font_data_size = GetAssetData("ProggyTiny.ttf", &font_data); - //font = io.Fonts->AddFontFromMemoryTTF(font_data, font_data_size, 10.0f); - //IM_ASSERT(font != NULL); - //font_data_size = GetAssetData("ArialUni.ttf", &font_data); - //font = io.Fonts->AddFontFromMemoryTTF(font_data, font_data_size, 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - //IM_ASSERT(font != NULL); - - // Arbitrary scale-up - // FIXME: Put some effort into DPI awareness - ImGui::GetStyle().ScaleAllSizes(3.0f); - - g_Initialized = true; -} - -void tick() -{ - ImGuiIO& io = ImGui::GetIO(); - if (g_EglDisplay == EGL_NO_DISPLAY) - return; - - // Our state - static bool show_demo_window = true; - static bool show_another_window = false; - static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); - - // Poll Unicode characters via JNI - // FIXME: do not call this every frame because of JNI overhead - PollUnicodeChars(); - - // Open on-screen (soft) input if requested by Dear ImGui - static bool WantTextInputLast = false; - if (io.WantTextInput && !WantTextInputLast) - ShowSoftKeyboardInput(); - WantTextInputLast = io.WantTextInput; - - // Start the Dear ImGui frame - ImGui_ImplOpenGL3_NewFrame(); - ImGui_ImplAndroid_NewFrame(); - ImGui::NewFrame(); - - // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). - if (show_demo_window) - ImGui::ShowDemoWindow(&show_demo_window); - - // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window. - { - static float f = 0.0f; - static int counter = 0; - - ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. - - ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) - ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state - ImGui::Checkbox("Another Window", &show_another_window); - - ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f - ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color - - if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) - counter++; - ImGui::SameLine(); - ImGui::Text("counter = %d", counter); - - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); - ImGui::End(); - } - - // 3. Show another simple window. - if (show_another_window) - { - ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked) - ImGui::Text("Hello from another window!"); - if (ImGui::Button("Close Me")) - show_another_window = false; - ImGui::End(); - } - - // Rendering - ImGui::Render(); - glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y); - glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w); - glClear(GL_COLOR_BUFFER_BIT); - ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); - eglSwapBuffers(g_EglDisplay, g_EglSurface); -} - -void shutdown() -{ - if (!g_Initialized) - return; - - // Cleanup - ImGui_ImplOpenGL3_Shutdown(); - ImGui_ImplAndroid_Shutdown(); - ImGui::DestroyContext(); - - if (g_EglDisplay != EGL_NO_DISPLAY) - { - eglMakeCurrent(g_EglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); - - if (g_EglContext != EGL_NO_CONTEXT) - eglDestroyContext(g_EglDisplay, g_EglContext); - - if (g_EglSurface != EGL_NO_SURFACE) - eglDestroySurface(g_EglDisplay, g_EglSurface); - - eglTerminate(g_EglDisplay); - } - - g_EglDisplay = EGL_NO_DISPLAY; - g_EglContext = EGL_NO_CONTEXT; - g_EglSurface = EGL_NO_SURFACE; - ANativeWindow_release(g_App->window); - - g_Initialized = false; -} - -static void handleAppCmd(struct android_app* app, int32_t appCmd) -{ - switch (appCmd) - { - case APP_CMD_SAVE_STATE: - break; - case APP_CMD_INIT_WINDOW: - init(app); - break; - case APP_CMD_TERM_WINDOW: - shutdown(); - break; - case APP_CMD_GAINED_FOCUS: - break; - case APP_CMD_LOST_FOCUS: - break; - } -} - -static int32_t handleInputEvent(struct android_app* app, AInputEvent* inputEvent) -{ - return ImGui_ImplAndroid_HandleInputEvent(inputEvent); -} - -void android_main(struct android_app* app) -{ - app->onAppCmd = handleAppCmd; - app->onInputEvent = handleInputEvent; - - while (true) - { - int out_events; - struct android_poll_source* out_data; - - // Poll all events. If the app is not visible, this loop blocks until g_Initialized == true. - while (ALooper_pollAll(g_Initialized ? 0 : -1, NULL, &out_events, (void**)&out_data) >= 0) - { - // Process one event - if (out_data != NULL) - out_data->process(app, out_data); - - // Exit the app by returning from within the infinite loop - if (app->destroyRequested != 0) - { - // shutdown() should have been called already while processing the - // app command APP_CMD_TERM_WINDOW. But we play save here - if (!g_Initialized) - shutdown(); - - return; - } - } - - // Initiate a new frame - tick(); - } -} - -// Unfortunately, there is no way to show the on-screen input from native code. -// Therefore, we call ShowSoftKeyboardInput() of the main activity implemented in MainActivity.kt via JNI. -static int ShowSoftKeyboardInput() -{ - JavaVM* java_vm = g_App->activity->vm; - JNIEnv* java_env = NULL; - - jint jni_return = java_vm->GetEnv((void**)&java_env, JNI_VERSION_1_6); - if (jni_return == JNI_ERR) - return -1; - - jni_return = java_vm->AttachCurrentThread(&java_env, NULL); - if (jni_return != JNI_OK) - return -2; - - jclass native_activity_clazz = java_env->GetObjectClass(g_App->activity->clazz); - if (native_activity_clazz == NULL) - return -3; - - jmethodID method_id = java_env->GetMethodID(native_activity_clazz, "showSoftInput", "()V"); - if (method_id == NULL) - return -4; - - java_env->CallVoidMethod(g_App->activity->clazz, method_id); - - jni_return = java_vm->DetachCurrentThread(); - if (jni_return != JNI_OK) - return -5; - - return 0; -} - -// Unfortunately, the native KeyEvent implementation has no getUnicodeChar() function. -// Therefore, we implement the processing of KeyEvents in MainActivity.kt and poll -// the resulting Unicode characters here via JNI and send them to Dear ImGui. -static int PollUnicodeChars() -{ - JavaVM* java_vm = g_App->activity->vm; - JNIEnv* java_env = NULL; - - jint jni_return = java_vm->GetEnv((void**)&java_env, JNI_VERSION_1_6); - if (jni_return == JNI_ERR) - return -1; - - jni_return = java_vm->AttachCurrentThread(&java_env, NULL); - if (jni_return != JNI_OK) - return -2; - - jclass native_activity_clazz = java_env->GetObjectClass(g_App->activity->clazz); - if (native_activity_clazz == NULL) - return -3; - - jmethodID method_id = java_env->GetMethodID(native_activity_clazz, "pollUnicodeChar", "()I"); - if (method_id == NULL) - return -4; - - // Send the actual characters to Dear ImGui - ImGuiIO& io = ImGui::GetIO(); - jint unicode_character; - while ((unicode_character = java_env->CallIntMethod(g_App->activity->clazz, method_id)) != 0) - io.AddInputCharacter(unicode_character); - - jni_return = java_vm->DetachCurrentThread(); - if (jni_return != JNI_OK) - return -5; - - return 0; -} - -// Helper to retrieve data placed into the assets/ directory (android/app/src/main/assets) -static int GetAssetData(const char* filename, void** outData) -{ - int num_bytes = 0; - AAsset* asset_descriptor = AAssetManager_open(g_App->activity->assetManager, filename, AASSET_MODE_BUFFER); - if (asset_descriptor) - { - num_bytes = AAsset_getLength(asset_descriptor); - *outData = IM_ALLOC(num_bytes); - int64_t num_bytes_read = AAsset_read(asset_descriptor, *outData, num_bytes); - AAsset_close(asset_descriptor); - IM_ASSERT(num_bytes_read == num_bytes); - } - return num_bytes; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_apple_metal/README.md b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_apple_metal/README.md deleted file mode 100644 index c13df2f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_apple_metal/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# iOS / OSX Metal example - -## Introduction - -This example shows how to integrate Dear ImGui with Metal. It is based on the "cross-platform" game template provided with Xcode as of Xcode 9. - -Consider basing your work off the example_glfw_metal/ or example_sdl_metal/ examples. They are better supported and will be portable unlike this one. - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_apple_metal/example_apple_metal.xcodeproj/project.pbxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_apple_metal/example_apple_metal.xcodeproj/project.pbxproj deleted file mode 100644 index 040fcd6..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_apple_metal/example_apple_metal.xcodeproj/project.pbxproj +++ /dev/null @@ -1,499 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 48; - objects = { - -/* Begin PBXBuildFile section */ - 07A82ED82139413D0078D120 /* imgui_widgets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07A82ED72139413C0078D120 /* imgui_widgets.cpp */; }; - 07A82ED92139418F0078D120 /* imgui_widgets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07A82ED72139413C0078D120 /* imgui_widgets.cpp */; }; - 5079822E257677DB0038A28D /* imgui_tables.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5079822D257677DB0038A28D /* imgui_tables.cpp */; }; - 8309BD8F253CCAAA0045E2A1 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8309BD8E253CCAAA0045E2A1 /* UIKit.framework */; }; - 8309BDA5253CCC070045E2A1 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8309BDA0253CCBC10045E2A1 /* main.mm */; }; - 8309BDA8253CCC080045E2A1 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8309BDA0253CCBC10045E2A1 /* main.mm */; }; - 8309BDBB253CCCAD0045E2A1 /* imgui_impl_metal.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8309BDB5253CCC9D0045E2A1 /* imgui_impl_metal.mm */; }; - 8309BDBE253CCCB60045E2A1 /* imgui_impl_metal.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8309BDB5253CCC9D0045E2A1 /* imgui_impl_metal.mm */; }; - 8309BDBF253CCCB60045E2A1 /* imgui_impl_osx.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8309BDB6253CCC9D0045E2A1 /* imgui_impl_osx.mm */; }; - 8309BDC6253CCCFE0045E2A1 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8309BDC5253CCCFE0045E2A1 /* AppKit.framework */; }; - 8309BDFC253CDAB30045E2A1 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8309BDF7253CDAAE0045E2A1 /* LaunchScreen.storyboard */; }; - 8309BE04253CDAB60045E2A1 /* MainMenu.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8309BDFA253CDAAE0045E2A1 /* MainMenu.storyboard */; }; - 83BBE9E520EB46B900295997 /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83BBE9E420EB46B900295997 /* Metal.framework */; }; - 83BBE9E720EB46BD00295997 /* MetalKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83BBE9E620EB46BD00295997 /* MetalKit.framework */; }; - 83BBE9EC20EB471700295997 /* MetalKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83BBE9EA20EB471700295997 /* MetalKit.framework */; }; - 83BBE9ED20EB471700295997 /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 83BBE9EB20EB471700295997 /* Metal.framework */; }; - 83BBEA0520EB54E700295997 /* imgui_draw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83BBEA0120EB54E700295997 /* imgui_draw.cpp */; }; - 83BBEA0620EB54E700295997 /* imgui_draw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83BBEA0120EB54E700295997 /* imgui_draw.cpp */; }; - 83BBEA0720EB54E700295997 /* imgui_demo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83BBEA0220EB54E700295997 /* imgui_demo.cpp */; }; - 83BBEA0820EB54E700295997 /* imgui_demo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83BBEA0220EB54E700295997 /* imgui_demo.cpp */; }; - 83BBEA0920EB54E700295997 /* imgui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83BBEA0320EB54E700295997 /* imgui.cpp */; }; - 83BBEA0A20EB54E700295997 /* imgui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 83BBEA0320EB54E700295997 /* imgui.cpp */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - 07A82ED62139413C0078D120 /* imgui_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_internal.h; path = ../../imgui_internal.h; sourceTree = ""; }; - 07A82ED72139413C0078D120 /* imgui_widgets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_widgets.cpp; path = ../../imgui_widgets.cpp; sourceTree = ""; }; - 5079822D257677DB0038A28D /* imgui_tables.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_tables.cpp; path = ../../imgui_tables.cpp; sourceTree = ""; }; - 8307E7C420E9F9C900473790 /* example_apple_metal.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = example_apple_metal.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 8307E7DA20E9F9C900473790 /* example_apple_metal.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = example_apple_metal.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 8309BD8E253CCAAA0045E2A1 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.0.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; - 8309BDA0253CCBC10045E2A1 /* main.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = ""; }; - 8309BDB5253CCC9D0045E2A1 /* imgui_impl_metal.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = imgui_impl_metal.mm; path = ../../backends/imgui_impl_metal.mm; sourceTree = ""; }; - 8309BDB6253CCC9D0045E2A1 /* imgui_impl_osx.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = imgui_impl_osx.mm; path = ../../backends/imgui_impl_osx.mm; sourceTree = ""; }; - 8309BDC5253CCCFE0045E2A1 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; - 8309BDF7253CDAAE0045E2A1 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = ""; }; - 8309BDF8253CDAAE0045E2A1 /* Info-iOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-iOS.plist"; sourceTree = ""; }; - 8309BDFA253CDAAE0045E2A1 /* MainMenu.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = MainMenu.storyboard; sourceTree = ""; }; - 8309BDFB253CDAAE0045E2A1 /* Info-macOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-macOS.plist"; sourceTree = ""; }; - 83BBE9E420EB46B900295997 /* Metal.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Metal.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/Metal.framework; sourceTree = DEVELOPER_DIR; }; - 83BBE9E620EB46BD00295997 /* MetalKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MetalKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/MetalKit.framework; sourceTree = DEVELOPER_DIR; }; - 83BBE9E820EB46C100295997 /* ModelIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ModelIO.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.4.sdk/System/Library/Frameworks/ModelIO.framework; sourceTree = DEVELOPER_DIR; }; - 83BBE9EA20EB471700295997 /* MetalKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MetalKit.framework; path = System/Library/Frameworks/MetalKit.framework; sourceTree = SDKROOT; }; - 83BBE9EB20EB471700295997 /* Metal.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Metal.framework; path = System/Library/Frameworks/Metal.framework; sourceTree = SDKROOT; }; - 83BBE9EE20EB471C00295997 /* ModelIO.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ModelIO.framework; path = System/Library/Frameworks/ModelIO.framework; sourceTree = SDKROOT; }; - 83BBEA0020EB54E700295997 /* imgui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui.h; path = ../../imgui.h; sourceTree = ""; }; - 83BBEA0120EB54E700295997 /* imgui_draw.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_draw.cpp; path = ../../imgui_draw.cpp; sourceTree = ""; }; - 83BBEA0220EB54E700295997 /* imgui_demo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_demo.cpp; path = ../../imgui_demo.cpp; sourceTree = ""; }; - 83BBEA0320EB54E700295997 /* imgui.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui.cpp; path = ../../imgui.cpp; sourceTree = ""; }; - 83BBEA0420EB54E700295997 /* imconfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imconfig.h; path = ../../imconfig.h; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 8307E7C120E9F9C900473790 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 8309BD8F253CCAAA0045E2A1 /* UIKit.framework in Frameworks */, - 83BBE9E720EB46BD00295997 /* MetalKit.framework in Frameworks */, - 83BBE9E520EB46B900295997 /* Metal.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 8307E7D720E9F9C900473790 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 8309BDC6253CCCFE0045E2A1 /* AppKit.framework in Frameworks */, - 83BBE9EC20EB471700295997 /* MetalKit.framework in Frameworks */, - 83BBE9ED20EB471700295997 /* Metal.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 8307E7B520E9F9C700473790 = { - isa = PBXGroup; - children = ( - 83BBE9F020EB544400295997 /* imgui */, - 8309BD9E253CCBA70045E2A1 /* example */, - 8307E7C520E9F9C900473790 /* Products */, - 83BBE9E320EB46B800295997 /* Frameworks */, - ); - sourceTree = ""; - }; - 8307E7C520E9F9C900473790 /* Products */ = { - isa = PBXGroup; - children = ( - 8307E7C420E9F9C900473790 /* example_apple_metal.app */, - 8307E7DA20E9F9C900473790 /* example_apple_metal.app */, - ); - name = Products; - sourceTree = ""; - }; - 8309BD9E253CCBA70045E2A1 /* example */ = { - isa = PBXGroup; - children = ( - 8309BDF6253CDAAE0045E2A1 /* iOS */, - 8309BDF9253CDAAE0045E2A1 /* macOS */, - 8309BDA0253CCBC10045E2A1 /* main.mm */, - ); - name = example; - sourceTree = ""; - }; - 8309BDF6253CDAAE0045E2A1 /* iOS */ = { - isa = PBXGroup; - children = ( - 8309BDF7253CDAAE0045E2A1 /* LaunchScreen.storyboard */, - 8309BDF8253CDAAE0045E2A1 /* Info-iOS.plist */, - ); - path = iOS; - sourceTree = ""; - }; - 8309BDF9253CDAAE0045E2A1 /* macOS */ = { - isa = PBXGroup; - children = ( - 8309BDFA253CDAAE0045E2A1 /* MainMenu.storyboard */, - 8309BDFB253CDAAE0045E2A1 /* Info-macOS.plist */, - ); - path = macOS; - sourceTree = ""; - }; - 83BBE9E320EB46B800295997 /* Frameworks */ = { - isa = PBXGroup; - children = ( - 8309BDC5253CCCFE0045E2A1 /* AppKit.framework */, - 8309BD8E253CCAAA0045E2A1 /* UIKit.framework */, - 83BBE9EE20EB471C00295997 /* ModelIO.framework */, - 83BBE9EB20EB471700295997 /* Metal.framework */, - 83BBE9EA20EB471700295997 /* MetalKit.framework */, - 83BBE9E820EB46C100295997 /* ModelIO.framework */, - 83BBE9E620EB46BD00295997 /* MetalKit.framework */, - 83BBE9E420EB46B900295997 /* Metal.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; - 83BBE9F020EB544400295997 /* imgui */ = { - isa = PBXGroup; - children = ( - 5079822D257677DB0038A28D /* imgui_tables.cpp */, - 8309BDB5253CCC9D0045E2A1 /* imgui_impl_metal.mm */, - 8309BDB6253CCC9D0045E2A1 /* imgui_impl_osx.mm */, - 83BBEA0420EB54E700295997 /* imconfig.h */, - 83BBEA0320EB54E700295997 /* imgui.cpp */, - 83BBEA0020EB54E700295997 /* imgui.h */, - 83BBEA0220EB54E700295997 /* imgui_demo.cpp */, - 83BBEA0120EB54E700295997 /* imgui_draw.cpp */, - 07A82ED62139413C0078D120 /* imgui_internal.h */, - 07A82ED72139413C0078D120 /* imgui_widgets.cpp */, - ); - name = imgui; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 8307E7C320E9F9C900473790 /* example_apple_metal_ios */ = { - isa = PBXNativeTarget; - buildConfigurationList = 8307E7F020E9F9C900473790 /* Build configuration list for PBXNativeTarget "example_apple_metal_ios" */; - buildPhases = ( - 8307E7C020E9F9C900473790 /* Sources */, - 8307E7C120E9F9C900473790 /* Frameworks */, - 8307E7C220E9F9C900473790 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = example_apple_metal_ios; - productName = "imguiex iOS"; - productReference = 8307E7C420E9F9C900473790 /* example_apple_metal.app */; - productType = "com.apple.product-type.application"; - }; - 8307E7D920E9F9C900473790 /* example_apple_metal_macos */ = { - isa = PBXNativeTarget; - buildConfigurationList = 8307E7F320E9F9C900473790 /* Build configuration list for PBXNativeTarget "example_apple_metal_macos" */; - buildPhases = ( - 8307E7D620E9F9C900473790 /* Sources */, - 8307E7D720E9F9C900473790 /* Frameworks */, - 8307E7D820E9F9C900473790 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = example_apple_metal_macos; - productName = "imguiex macOS"; - productReference = 8307E7DA20E9F9C900473790 /* example_apple_metal.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 8307E7B620E9F9C700473790 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 1200; - ORGANIZATIONNAME = "Warren Moore"; - TargetAttributes = { - 8307E7C320E9F9C900473790 = { - CreatedOnToolsVersion = 9.4.1; - ProvisioningStyle = Automatic; - }; - 8307E7D920E9F9C900473790 = { - CreatedOnToolsVersion = 9.4.1; - ProvisioningStyle = Automatic; - }; - }; - }; - buildConfigurationList = 8307E7B920E9F9C700473790 /* Build configuration list for PBXProject "example_apple_metal" */; - compatibilityVersion = "Xcode 8.0"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 8307E7B520E9F9C700473790; - productRefGroup = 8307E7C520E9F9C900473790 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 8307E7C320E9F9C900473790 /* example_apple_metal_ios */, - 8307E7D920E9F9C900473790 /* example_apple_metal_macos */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 8307E7C220E9F9C900473790 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 8309BDFC253CDAB30045E2A1 /* LaunchScreen.storyboard in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 8307E7D820E9F9C900473790 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 8309BE04253CDAB60045E2A1 /* MainMenu.storyboard in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 8307E7C020E9F9C900473790 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 8309BDBB253CCCAD0045E2A1 /* imgui_impl_metal.mm in Sources */, - 83BBEA0920EB54E700295997 /* imgui.cpp in Sources */, - 83BBEA0720EB54E700295997 /* imgui_demo.cpp in Sources */, - 83BBEA0520EB54E700295997 /* imgui_draw.cpp in Sources */, - 5079822E257677DB0038A28D /* imgui_tables.cpp in Sources */, - 07A82ED82139413D0078D120 /* imgui_widgets.cpp in Sources */, - 8309BDA5253CCC070045E2A1 /* main.mm in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 8307E7D620E9F9C900473790 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 8309BDBE253CCCB60045E2A1 /* imgui_impl_metal.mm in Sources */, - 8309BDBF253CCCB60045E2A1 /* imgui_impl_osx.mm in Sources */, - 83BBEA0A20EB54E700295997 /* imgui.cpp in Sources */, - 83BBEA0820EB54E700295997 /* imgui_demo.cpp in Sources */, - 83BBEA0620EB54E700295997 /* imgui_draw.cpp in Sources */, - 5079822E257677DB0038A28D /* imgui_tables.cpp in Sources */, - 07A82ED92139418F0078D120 /* imgui_widgets.cpp in Sources */, - 8309BDA8253CCC080045E2A1 /* main.mm in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 8307E7EE20E9F9C900473790 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - }; - name = Debug; - }; - 8307E7EF20E9F9C900473790 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MTL_ENABLE_DEBUG_INFO = NO; - }; - name = Release; - }; - 8307E7F120E9F9C900473790 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_IDENTITY = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = ""; - INFOPLIST_FILE = "$(SRCROOT)/iOS/Info-iOS.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "org.imgui.example.apple-metal-ios"; - PRODUCT_NAME = example_apple_metal; - SDKROOT = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; - USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../**"; - }; - name = Debug; - }; - 8307E7F220E9F9C900473790 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_IDENTITY = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = ""; - INFOPLIST_FILE = "$(SRCROOT)/iOS/Info-iOS.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 10.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = "org.imgui.example.apple-metal-ios"; - PRODUCT_NAME = example_apple_metal; - SDKROOT = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; - USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../**"; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - 8307E7F420E9F9C900473790 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_IDENTITY = "-"; - CODE_SIGN_STYLE = Automatic; - COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = ""; - INFOPLIST_FILE = "$(SRCROOT)/macOS/Info-macOS.plist"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.12; - PRODUCT_BUNDLE_IDENTIFIER = "org.imgui.example.apple-metal-macos"; - PRODUCT_NAME = example_apple_metal; - SDKROOT = macosx; - USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../**"; - }; - name = Debug; - }; - 8307E7F520E9F9C900473790 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_IDENTITY = "-"; - CODE_SIGN_STYLE = Automatic; - COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = ""; - INFOPLIST_FILE = "$(SRCROOT)/macOS/Info-macOS.plist"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.12; - PRODUCT_BUNDLE_IDENTIFIER = "org.imgui.example.apple-metal-macos"; - PRODUCT_NAME = example_apple_metal; - SDKROOT = macosx; - USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../**"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 8307E7B920E9F9C700473790 /* Build configuration list for PBXProject "example_apple_metal" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 8307E7EE20E9F9C900473790 /* Debug */, - 8307E7EF20E9F9C900473790 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 8307E7F020E9F9C900473790 /* Build configuration list for PBXNativeTarget "example_apple_metal_ios" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 8307E7F120E9F9C900473790 /* Debug */, - 8307E7F220E9F9C900473790 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 8307E7F320E9F9C900473790 /* Build configuration list for PBXNativeTarget "example_apple_metal_macos" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 8307E7F420E9F9C900473790 /* Debug */, - 8307E7F520E9F9C900473790 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 8307E7B620E9F9C700473790 /* Project object */; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_apple_metal/iOS/Info-iOS.plist b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_apple_metal/iOS/Info-iOS.plist deleted file mode 100644 index 93ef078..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_apple_metal/iOS/Info-iOS.plist +++ /dev/null @@ -1,49 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - imgui - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - LSRequiresIPhoneOS - - UILaunchStoryboardName - LaunchScreen - UIRequiredDeviceCapabilities - - armv7 - metal - - UIRequiresFullScreen - - UIStatusBarHidden - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - UIInterfaceOrientationPortraitUpsideDown - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_apple_metal/iOS/LaunchScreen.storyboard b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_apple_metal/iOS/LaunchScreen.storyboard deleted file mode 100644 index 12c52cf..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_apple_metal/iOS/LaunchScreen.storyboard +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_apple_metal/macOS/Info-macOS.plist b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_apple_metal/macOS/Info-macOS.plist deleted file mode 100644 index 6f4a2b2..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_apple_metal/macOS/Info-macOS.plist +++ /dev/null @@ -1,30 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIconFile - - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - imgui - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - LSMinimumSystemVersion - $(MACOSX_DEPLOYMENT_TARGET) - NSMainStoryboardFile - MainMenu - NSPrincipalClass - NSApplication - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_apple_metal/macOS/MainMenu.storyboard b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_apple_metal/macOS/MainMenu.storyboard deleted file mode 100644 index 38ad432..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_apple_metal/macOS/MainMenu.storyboard +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_apple_metal/main.mm b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_apple_metal/main.mm deleted file mode 100644 index 5d4b771..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_apple_metal/main.mm +++ /dev/null @@ -1,356 +0,0 @@ -// Dear ImGui: standalone example application for OSX + Metal. -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -#import - -#if TARGET_OS_OSX -#import -#else -#import -#endif - -#import -#import - -#include "imgui.h" -#include "imgui_impl_metal.h" -#if TARGET_OS_OSX -#include "imgui_impl_osx.h" -@interface AppViewController : NSViewController -@end -#else -@interface AppViewController : UIViewController -@end -#endif - -@interface AppViewController () -@property (nonatomic, readonly) MTKView *mtkView; -@property (nonatomic, strong) id device; -@property (nonatomic, strong) id commandQueue; -@end - -//----------------------------------------------------------------------------------- -// AppViewController -//----------------------------------------------------------------------------------- - -@implementation AppViewController - --(instancetype)initWithNibName:(nullable NSString *)nibNameOrNil bundle:(nullable NSBundle *)nibBundleOrNil -{ - self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; - - _device = MTLCreateSystemDefaultDevice(); - _commandQueue = [_device newCommandQueue]; - - if (!self.device) - { - NSLog(@"Metal is not supported"); - abort(); - } - - // Setup Dear ImGui context - // FIXME: This example doesn't have proper cleanup... - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); (void)io; - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls - - // Setup Dear ImGui style - ImGui::StyleColorsDark(); - //ImGui::StyleColorsClassic(); - - // Setup Renderer backend - ImGui_ImplMetal_Init(_device); - - // Load Fonts - // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. - // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. - // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). - // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call. - // - Read 'docs/FONTS.txt' for more instructions and details. - // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! - //io.Fonts->AddFontDefault(); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f); - //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - //IM_ASSERT(font != NULL); - - return self; -} - --(MTKView *)mtkView -{ - return (MTKView *)self.view; -} - --(void)loadView -{ - self.view = [[MTKView alloc] initWithFrame:CGRectMake(0, 0, 1200, 720)]; -} - --(void)viewDidLoad -{ - [super viewDidLoad]; - - self.mtkView.device = self.device; - self.mtkView.delegate = self; - -#if TARGET_OS_OSX - // Add a tracking area in order to receive mouse events whenever the mouse is within the bounds of our view - NSTrackingArea *trackingArea = [[NSTrackingArea alloc] initWithRect:NSZeroRect - options:NSTrackingMouseMoved | NSTrackingInVisibleRect | NSTrackingActiveAlways - owner:self - userInfo:nil]; - [self.view addTrackingArea:trackingArea]; - - // If we want to receive key events, we either need to be in the responder chain of the key view, - // or else we can install a local monitor. The consequence of this heavy-handed approach is that - // we receive events for all controls, not just Dear ImGui widgets. If we had native controls in our - // window, we'd want to be much more careful than just ingesting the complete event stream. - // To match the behavior of other backends, we pass every event down to the OS. - NSEventMask eventMask = NSEventMaskKeyDown | NSEventMaskKeyUp | NSEventMaskFlagsChanged; - [NSEvent addLocalMonitorForEventsMatchingMask:eventMask handler:^NSEvent * _Nullable(NSEvent *event) - { - ImGui_ImplOSX_HandleEvent(event, self.view); - return event; - }]; - - ImGui_ImplOSX_Init(); - -#endif -} - --(void)drawInMTKView:(MTKView*)view -{ - ImGuiIO& io = ImGui::GetIO(); - io.DisplaySize.x = view.bounds.size.width; - io.DisplaySize.y = view.bounds.size.height; - -#if TARGET_OS_OSX - CGFloat framebufferScale = view.window.screen.backingScaleFactor ?: NSScreen.mainScreen.backingScaleFactor; -#else - CGFloat framebufferScale = view.window.screen.scale ?: UIScreen.mainScreen.scale; -#endif - io.DisplayFramebufferScale = ImVec2(framebufferScale, framebufferScale); - - io.DeltaTime = 1 / float(view.preferredFramesPerSecond ?: 60); - - id commandBuffer = [self.commandQueue commandBuffer]; - - MTLRenderPassDescriptor* renderPassDescriptor = view.currentRenderPassDescriptor; - if (renderPassDescriptor == nil) - { - [commandBuffer commit]; - return; - } - - // Start the Dear ImGui frame - ImGui_ImplMetal_NewFrame(renderPassDescriptor); -#if TARGET_OS_OSX - ImGui_ImplOSX_NewFrame(view); -#endif - ImGui::NewFrame(); - - // Our state (make them static = more or less global) as a convenience to keep the example terse. - static bool show_demo_window = true; - static bool show_another_window = false; - static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); - - // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). - if (show_demo_window) - ImGui::ShowDemoWindow(&show_demo_window); - - // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window. - { - static float f = 0.0f; - static int counter = 0; - - ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. - - ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) - ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state - ImGui::Checkbox("Another Window", &show_another_window); - - ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f - ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color - - if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) - counter++; - ImGui::SameLine(); - ImGui::Text("counter = %d", counter); - - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); - ImGui::End(); - } - - // 3. Show another simple window. - if (show_another_window) - { - ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked) - ImGui::Text("Hello from another window!"); - if (ImGui::Button("Close Me")) - show_another_window = false; - ImGui::End(); - } - - // Rendering - ImGui::Render(); - ImDrawData* draw_data = ImGui::GetDrawData(); - - renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColorMake(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w); - id renderEncoder = [commandBuffer renderCommandEncoderWithDescriptor:renderPassDescriptor]; - [renderEncoder pushDebugGroup:@"Dear ImGui rendering"]; - ImGui_ImplMetal_RenderDrawData(draw_data, commandBuffer, renderEncoder); - [renderEncoder popDebugGroup]; - [renderEncoder endEncoding]; - - // Present - [commandBuffer presentDrawable:view.currentDrawable]; - [commandBuffer commit]; -} - --(void)mtkView:(MTKView*)view drawableSizeWillChange:(CGSize)size -{ -} - -//----------------------------------------------------------------------------------- -// Input processing -//----------------------------------------------------------------------------------- - -#if TARGET_OS_OSX - -// Forward Mouse/Keyboard events to Dear ImGui OSX backend. -// Other events are registered via addLocalMonitorForEventsMatchingMask() --(void)mouseDown:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self.view); } --(void)rightMouseDown:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self.view); } --(void)otherMouseDown:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self.view); } --(void)mouseUp:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self.view); } --(void)rightMouseUp:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self.view); } --(void)otherMouseUp:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self.view); } --(void)mouseMoved:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self.view); } --(void)mouseDragged:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self.view); } --(void)rightMouseMoved:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self.view); } --(void)rightMouseDragged:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self.view); } --(void)otherMouseMoved:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self.view); } --(void)otherMouseDragged:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self.view); } --(void)scrollWheel:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self.view); } - -#else - -// This touch mapping is super cheesy/hacky. We treat any touch on the screen -// as if it were a depressed left mouse button, and we don't bother handling -// multitouch correctly at all. This causes the "cursor" to behave very erratically -// when there are multiple active touches. But for demo purposes, single-touch -// interaction actually works surprisingly well. --(void)updateIOWithTouchEvent:(UIEvent *)event -{ - UITouch *anyTouch = event.allTouches.anyObject; - CGPoint touchLocation = [anyTouch locationInView:self.view]; - ImGuiIO &io = ImGui::GetIO(); - io.MousePos = ImVec2(touchLocation.x, touchLocation.y); - - BOOL hasActiveTouch = NO; - for (UITouch *touch in event.allTouches) - { - if (touch.phase != UITouchPhaseEnded && touch.phase != UITouchPhaseCancelled) - { - hasActiveTouch = YES; - break; - } - } - io.MouseDown[0] = hasActiveTouch; -} - --(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [self updateIOWithTouchEvent:event]; } --(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { [self updateIOWithTouchEvent:event]; } --(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { [self updateIOWithTouchEvent:event]; } --(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { [self updateIOWithTouchEvent:event]; } - -#endif - -@end - -//----------------------------------------------------------------------------------- -// AppDelegate -//----------------------------------------------------------------------------------- - -#if TARGET_OS_OSX - -@interface AppDelegate : NSObject -@property (nonatomic, strong) NSWindow *window; -@end - -@implementation AppDelegate - --(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender -{ - return YES; -} - --(instancetype)init -{ - if (self = [super init]) - { - NSViewController *rootViewController = [[AppViewController alloc] initWithNibName:nil bundle:nil]; - self.window = [[NSWindow alloc] initWithContentRect:NSZeroRect - styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskResizable | NSWindowStyleMaskMiniaturizable - backing:NSBackingStoreBuffered - defer:NO]; - self.window.contentViewController = rootViewController; - [self.window orderFront:self]; - [self.window center]; - [self.window becomeKeyWindow]; - } - return self; -} - -@end - -#else - -@interface AppDelegate : UIResponder -@property (strong, nonatomic) UIWindow *window; -@end - -@implementation AppDelegate - --(BOOL)application:(UIApplication *)application - didFinishLaunchingWithOptions:(NSDictionary *)launchOptions -{ - UIViewController *rootViewController = [[AppViewController alloc] init]; - self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds]; - self.window.rootViewController = rootViewController; - [self.window makeKeyAndVisible]; - return YES; -} - -@end - -#endif - -//----------------------------------------------------------------------------------- -// Application main() function -//----------------------------------------------------------------------------------- - -#if TARGET_OS_OSX - -int main(int argc, const char * argv[]) -{ - return NSApplicationMain(argc, argv); -} - -#else - -int main(int argc, char * argv[]) -{ - @autoreleasepool - { - return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); - } -} - -#endif diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_apple_opengl2/example_apple_opengl2.xcodeproj/project.pbxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_apple_opengl2/example_apple_opengl2.xcodeproj/project.pbxproj deleted file mode 100644 index 82fb267..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_apple_opengl2/example_apple_opengl2.xcodeproj/project.pbxproj +++ /dev/null @@ -1,328 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 48; - objects = { - -/* Begin PBXBuildFile section */ - 07A82EDB213941D00078D120 /* imgui_widgets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07A82EDA213941D00078D120 /* imgui_widgets.cpp */; }; - 4080A99820B02D340036BA46 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4080A98A20B02CD90036BA46 /* main.mm */; }; - 4080A9A220B034280036BA46 /* imgui_impl_opengl2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4080A99E20B034280036BA46 /* imgui_impl_opengl2.cpp */; }; - 4080A9AD20B0343C0036BA46 /* imgui_demo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4080A9A620B0343C0036BA46 /* imgui_demo.cpp */; }; - 4080A9AE20B0343C0036BA46 /* imgui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4080A9A720B0343C0036BA46 /* imgui.cpp */; }; - 4080A9AF20B0343C0036BA46 /* imgui_draw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4080A9AA20B0343C0036BA46 /* imgui_draw.cpp */; }; - 4080A9B020B0347A0036BA46 /* imgui_impl_osx.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4080A99F20B034280036BA46 /* imgui_impl_osx.mm */; }; - 4080A9B320B034E40036BA46 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4080A9B220B034E40036BA46 /* Cocoa.framework */; }; - 4080A9B520B034EA0036BA46 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4080A9B420B034EA0036BA46 /* OpenGL.framework */; }; - 50798230257677FD0038A28D /* imgui_tables.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5079822F257677FC0038A28D /* imgui_tables.cpp */; }; -/* End PBXBuildFile section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 4080A96920B029B00036BA46 /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = /usr/share/man/man1/; - dstSubfolderSpec = 0; - files = ( - ); - runOnlyForDeploymentPostprocessing = 1; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 07A82EDA213941D00078D120 /* imgui_widgets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_widgets.cpp; path = ../../imgui_widgets.cpp; sourceTree = ""; }; - 4080A96B20B029B00036BA46 /* example_osx_opengl2 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = example_osx_opengl2; sourceTree = BUILT_PRODUCTS_DIR; }; - 4080A98A20B02CD90036BA46 /* main.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = SOURCE_ROOT; }; - 4080A99E20B034280036BA46 /* imgui_impl_opengl2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_impl_opengl2.cpp; path = ../../backends/imgui_impl_opengl2.cpp; sourceTree = ""; }; - 4080A99F20B034280036BA46 /* imgui_impl_osx.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = imgui_impl_osx.mm; path = ../../backends/imgui_impl_osx.mm; sourceTree = ""; }; - 4080A9A020B034280036BA46 /* imgui_impl_opengl2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_opengl2.h; path = ../../backends/imgui_impl_opengl2.h; sourceTree = ""; }; - 4080A9A120B034280036BA46 /* imgui_impl_osx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_impl_osx.h; path = ../../backends/imgui_impl_osx.h; sourceTree = ""; }; - 4080A9A520B0343C0036BA46 /* imgui_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui_internal.h; path = ../../imgui_internal.h; sourceTree = ""; }; - 4080A9A620B0343C0036BA46 /* imgui_demo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_demo.cpp; path = ../../imgui_demo.cpp; sourceTree = ""; }; - 4080A9A720B0343C0036BA46 /* imgui.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui.cpp; path = ../../imgui.cpp; sourceTree = ""; }; - 4080A9A820B0343C0036BA46 /* imgui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imgui.h; path = ../../imgui.h; sourceTree = ""; }; - 4080A9AA20B0343C0036BA46 /* imgui_draw.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_draw.cpp; path = ../../imgui_draw.cpp; sourceTree = ""; }; - 4080A9AC20B0343C0036BA46 /* imconfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imconfig.h; path = ../../imconfig.h; sourceTree = ""; }; - 4080A9B220B034E40036BA46 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; - 4080A9B420B034EA0036BA46 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; }; - 5079822F257677FC0038A28D /* imgui_tables.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_tables.cpp; path = ../../imgui_tables.cpp; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 4080A96820B029B00036BA46 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 4080A9B520B034EA0036BA46 /* OpenGL.framework in Frameworks */, - 4080A9B320B034E40036BA46 /* Cocoa.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 4080A96220B029B00036BA46 = { - isa = PBXGroup; - children = ( - 5079822F257677FC0038A28D /* imgui_tables.cpp */, - 4080A9AC20B0343C0036BA46 /* imconfig.h */, - 4080A9A720B0343C0036BA46 /* imgui.cpp */, - 4080A9A820B0343C0036BA46 /* imgui.h */, - 07A82EDA213941D00078D120 /* imgui_widgets.cpp */, - 4080A9A620B0343C0036BA46 /* imgui_demo.cpp */, - 4080A9AA20B0343C0036BA46 /* imgui_draw.cpp */, - 4080A9A520B0343C0036BA46 /* imgui_internal.h */, - 4080A99E20B034280036BA46 /* imgui_impl_opengl2.cpp */, - 4080A9A020B034280036BA46 /* imgui_impl_opengl2.h */, - 4080A9A120B034280036BA46 /* imgui_impl_osx.h */, - 4080A99F20B034280036BA46 /* imgui_impl_osx.mm */, - 4080A98A20B02CD90036BA46 /* main.mm */, - 4080A96C20B029B00036BA46 /* Products */, - 4080A9B120B034E40036BA46 /* Frameworks */, - ); - sourceTree = ""; - }; - 4080A96C20B029B00036BA46 /* Products */ = { - isa = PBXGroup; - children = ( - 4080A96B20B029B00036BA46 /* example_osx_opengl2 */, - ); - name = Products; - sourceTree = ""; - }; - 4080A9B120B034E40036BA46 /* Frameworks */ = { - isa = PBXGroup; - children = ( - 4080A9B420B034EA0036BA46 /* OpenGL.framework */, - 4080A9B220B034E40036BA46 /* Cocoa.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 4080A96A20B029B00036BA46 /* example_osx_opengl2 */ = { - isa = PBXNativeTarget; - buildConfigurationList = 4080A97220B029B00036BA46 /* Build configuration list for PBXNativeTarget "example_osx_opengl2" */; - buildPhases = ( - 4080A96720B029B00036BA46 /* Sources */, - 4080A96820B029B00036BA46 /* Frameworks */, - 4080A96920B029B00036BA46 /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = example_osx_opengl2; - productName = example_osx_opengl2; - productReference = 4080A96B20B029B00036BA46 /* example_osx_opengl2 */; - productType = "com.apple.product-type.tool"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 4080A96320B029B00036BA46 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0930; - ORGANIZATIONNAME = ImGui; - TargetAttributes = { - 4080A96A20B029B00036BA46 = { - CreatedOnToolsVersion = 9.3.1; - ProvisioningStyle = Automatic; - }; - }; - }; - buildConfigurationList = 4080A96620B029B00036BA46 /* Build configuration list for PBXProject "example_apple_opengl2" */; - compatibilityVersion = "Xcode 8.0"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = 4080A96220B029B00036BA46; - productRefGroup = 4080A96C20B029B00036BA46 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 4080A96A20B029B00036BA46 /* example_osx_opengl2 */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXSourcesBuildPhase section */ - 4080A96720B029B00036BA46 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 4080A99820B02D340036BA46 /* main.mm in Sources */, - 4080A9AD20B0343C0036BA46 /* imgui_demo.cpp in Sources */, - 4080A9AF20B0343C0036BA46 /* imgui_draw.cpp in Sources */, - 4080A9A220B034280036BA46 /* imgui_impl_opengl2.cpp in Sources */, - 4080A9B020B0347A0036BA46 /* imgui_impl_osx.mm in Sources */, - 4080A9AE20B0343C0036BA46 /* imgui.cpp in Sources */, - 50798230257677FD0038A28D /* imgui_tables.cpp in Sources */, - 07A82EDB213941D00078D120 /* imgui_widgets.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 4080A97020B029B00036BA46 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "-"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.13; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = macosx; - }; - name = Debug; - }; - 4080A97120B029B00036BA46 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "-"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.13; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = macosx; - }; - name = Release; - }; - 4080A97320B029B00036BA46 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_STYLE = Automatic; - MACOSX_DEPLOYMENT_TARGET = 10.12; - PRODUCT_NAME = "$(TARGET_NAME)"; - USER_HEADER_SEARCH_PATHS = ../..; - }; - name = Debug; - }; - 4080A97420B029B00036BA46 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_STYLE = Automatic; - MACOSX_DEPLOYMENT_TARGET = 10.12; - PRODUCT_NAME = "$(TARGET_NAME)"; - USER_HEADER_SEARCH_PATHS = ../..; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 4080A96620B029B00036BA46 /* Build configuration list for PBXProject "example_apple_opengl2" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 4080A97020B029B00036BA46 /* Debug */, - 4080A97120B029B00036BA46 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 4080A97220B029B00036BA46 /* Build configuration list for PBXNativeTarget "example_osx_opengl2" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 4080A97320B029B00036BA46 /* Debug */, - 4080A97420B029B00036BA46 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 4080A96320B029B00036BA46 /* Project object */; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_apple_opengl2/main.mm b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_apple_opengl2/main.mm deleted file mode 100644 index 825c8a8..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_apple_opengl2/main.mm +++ /dev/null @@ -1,282 +0,0 @@ -// Dear ImGui: standalone example application for OSX + OpenGL2, using legacy fixed pipeline -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -#import -#import -#import - -#include "imgui.h" -#include "imgui_impl_opengl2.h" -#include "imgui_impl_osx.h" - -//----------------------------------------------------------------------------------- -// AppView -//----------------------------------------------------------------------------------- - -@interface AppView : NSOpenGLView -{ - NSTimer* animationTimer; -} -@end - -@implementation AppView - --(void)prepareOpenGL -{ - [super prepareOpenGL]; - -#ifndef DEBUG - GLint swapInterval = 1; - [[self openGLContext] setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval]; - if (swapInterval == 0) - NSLog(@"Error: Cannot set swap interval."); -#endif -} - --(void)initialize -{ - // Some events do not raise callbacks of AppView in some circumstances (for example when CMD key is held down). - // This monitor taps into global event stream and captures these events. - NSEventMask eventMask = NSEventMaskKeyDown | NSEventMaskKeyUp | NSEventMaskFlagsChanged; - [NSEvent addLocalMonitorForEventsMatchingMask:eventMask handler:^NSEvent * _Nullable(NSEvent *event) - { - ImGui_ImplOSX_HandleEvent(event, self); - return event; - }]; - - // Setup Dear ImGui context - // FIXME: This example doesn't have proper cleanup... - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); (void)io; - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls - - // Setup Dear ImGui style - ImGui::StyleColorsDark(); - //ImGui::StyleColorsClassic(); - - // Setup Platform/Renderer backends - ImGui_ImplOSX_Init(); - ImGui_ImplOpenGL2_Init(); - - // Load Fonts - // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. - // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. - // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). - // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call. - // - Read 'docs/FONTS.txt' for more instructions and details. - // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! - //io.Fonts->AddFontDefault(); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f); - //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - //IM_ASSERT(font != NULL); -} - --(void)updateAndDrawDemoView -{ - // Start the Dear ImGui frame - ImGui_ImplOpenGL2_NewFrame(); - ImGui_ImplOSX_NewFrame(self); - ImGui::NewFrame(); - - // Our state (make them static = more or less global) as a convenience to keep the example terse. - static bool show_demo_window = true; - static bool show_another_window = false; - static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); - - // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). - if (show_demo_window) - ImGui::ShowDemoWindow(&show_demo_window); - - // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window. - { - static float f = 0.0f; - static int counter = 0; - - ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. - - ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) - ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state - ImGui::Checkbox("Another Window", &show_another_window); - - ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f - ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color - - if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) - counter++; - ImGui::SameLine(); - ImGui::Text("counter = %d", counter); - - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); - ImGui::End(); - } - - // 3. Show another simple window. - if (show_another_window) - { - ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked) - ImGui::Text("Hello from another window!"); - if (ImGui::Button("Close Me")) - show_another_window = false; - ImGui::End(); - } - - // Rendering - ImGui::Render(); - ImDrawData* draw_data = ImGui::GetDrawData(); - - [[self openGLContext] makeCurrentContext]; - GLsizei width = (GLsizei)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x); - GLsizei height = (GLsizei)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y); - glViewport(0, 0, width, height); - glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w); - glClear(GL_COLOR_BUFFER_BIT); - - ImGui_ImplOpenGL2_RenderDrawData(draw_data); - - // Present - [[self openGLContext] flushBuffer]; - - if (!animationTimer) - animationTimer = [NSTimer scheduledTimerWithTimeInterval:0.017 target:self selector:@selector(animationTimerFired:) userInfo:nil repeats:YES]; -} - --(void)reshape { [[self openGLContext] update]; [self updateAndDrawDemoView]; } --(void)drawRect:(NSRect)bounds { [self updateAndDrawDemoView]; } --(void)animationTimerFired:(NSTimer*)timer { [self setNeedsDisplay:YES]; } --(BOOL)acceptsFirstResponder { return (YES); } --(BOOL)becomeFirstResponder { return (YES); } --(BOOL)resignFirstResponder { return (YES); } --(void)dealloc { animationTimer = nil; } - -//----------------------------------------------------------------------------------- -// Input processing -//----------------------------------------------------------------------------------- - -// Forward Mouse/Keyboard events to Dear ImGui OSX backend. -// Other events are registered via addLocalMonitorForEventsMatchingMask() --(void)mouseDown:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); } --(void)rightMouseDown:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); } --(void)otherMouseDown:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); } --(void)mouseUp:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); } --(void)rightMouseUp:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); } --(void)otherMouseUp:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); } --(void)mouseMoved:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); } --(void)mouseDragged:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); } --(void)rightMouseMoved:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); } --(void)rightMouseDragged:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); } --(void)otherMouseMoved:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); } --(void)otherMouseDragged:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); } --(void)scrollWheel:(NSEvent *)event { ImGui_ImplOSX_HandleEvent(event, self); } - -@end - -//----------------------------------------------------------------------------------- -// AppDelegate -//----------------------------------------------------------------------------------- - -@interface AppDelegate : NSObject -@property (nonatomic, readonly) NSWindow* window; -@end - -@implementation AppDelegate -@synthesize window = _window; - --(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication -{ - return YES; -} - --(NSWindow*)window -{ - if (_window != nil) - return (_window); - - NSRect viewRect = NSMakeRect(100.0, 100.0, 100.0 + 1280.0, 100 + 720.0); - - _window = [[NSWindow alloc] initWithContentRect:viewRect styleMask:NSWindowStyleMaskTitled|NSWindowStyleMaskMiniaturizable|NSWindowStyleMaskResizable|NSWindowStyleMaskClosable backing:NSBackingStoreBuffered defer:YES]; - [_window setTitle:@"Dear ImGui OSX+OpenGL2 Example"]; - [_window setAcceptsMouseMovedEvents:YES]; - [_window setOpaque:YES]; - [_window makeKeyAndOrderFront:NSApp]; - - return (_window); -} - --(void)setupMenu -{ - NSMenu* mainMenuBar = [[NSMenu alloc] init]; - NSMenu* appMenu; - NSMenuItem* menuItem; - - appMenu = [[NSMenu alloc] initWithTitle:@"Dear ImGui OSX+OpenGL2 Example"]; - menuItem = [appMenu addItemWithTitle:@"Quit Dear ImGui OSX+OpenGL2 Example" action:@selector(terminate:) keyEquivalent:@"q"]; - [menuItem setKeyEquivalentModifierMask:NSEventModifierFlagCommand]; - - menuItem = [[NSMenuItem alloc] init]; - [menuItem setSubmenu:appMenu]; - - [mainMenuBar addItem:menuItem]; - - appMenu = nil; - [NSApp setMainMenu:mainMenuBar]; -} - --(void)dealloc -{ - _window = nil; -} - --(void)applicationDidFinishLaunching:(NSNotification *)aNotification -{ - // Make the application a foreground application (else it won't receive keyboard events) - ProcessSerialNumber psn = {0, kCurrentProcess}; - TransformProcessType(&psn, kProcessTransformToForegroundApplication); - - // Menu - [self setupMenu]; - - NSOpenGLPixelFormatAttribute attrs[] = - { - NSOpenGLPFADoubleBuffer, - NSOpenGLPFADepthSize, 32, - 0 - }; - - NSOpenGLPixelFormat* format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs]; - AppView* view = [[AppView alloc] initWithFrame:self.window.frame pixelFormat:format]; - format = nil; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 - if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) - [view setWantsBestResolutionOpenGLSurface:YES]; -#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 - [self.window setContentView:view]; - - if ([view openGLContext] == nil) - NSLog(@"No OpenGL Context!"); - - [view initialize]; -} - -@end - -//----------------------------------------------------------------------------------- -// Application main() function -//----------------------------------------------------------------------------------- - -int main(int argc, const char* argv[]) -{ - @autoreleasepool - { - NSApp = [NSApplication sharedApplication]; - AppDelegate* delegate = [[AppDelegate alloc] init]; - [[NSApplication sharedApplication] setDelegate:delegate]; - [NSApp run]; - } - return NSApplicationMain(argc, argv); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_emscripten_opengl3/Makefile b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_emscripten_opengl3/Makefile deleted file mode 100644 index b2933e1..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_emscripten_opengl3/Makefile +++ /dev/null @@ -1,91 +0,0 @@ -# -# Makefile to use with emscripten -# See https://emscripten.org/docs/getting_started/downloads.html -# for installation instructions. -# -# This Makefile assumes you have loaded emscripten's environment. -# (On Windows, you may need to execute emsdk_env.bat or encmdprompt.bat ahead) -# -# Running `make` will produce three files: -# - web/index.html -# - web/index.js -# - web/index.wasm -# -# All three are needed to run the demo. - -CC = emcc -CXX = em++ -WEB_DIR = web -EXE = $(WEB_DIR)/index.html -IMGUI_DIR = ../.. -SOURCES = main.cpp -SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp -SOURCES += $(IMGUI_DIR)/backends/imgui_impl_sdl.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl3.cpp -OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) -UNAME_S := $(shell uname -s) -CPPFLAGS = -LDFLAGS = -EMS = - -##--------------------------------------------------------------------- -## EMSCRIPTEN OPTIONS -##--------------------------------------------------------------------- - -# ("EMS" options gets added to both CPPFLAGS and LDFLAGS, whereas some options are for linker only) -EMS += -s USE_SDL=2 -EMS += -s DISABLE_EXCEPTION_CATCHING=1 -LDFLAGS += -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s NO_EXIT_RUNTIME=0 -s ASSERTIONS=1 - -# Uncomment next line to fix possible rendering bugs with Emscripten version older then 1.39.0 (https://github.com/ocornut/imgui/issues/2877) -#EMS += -s BINARYEN_TRAP_MODE=clamp -#EMS += -s SAFE_HEAP=1 ## Adds overhead - -# Emscripten allows preloading a file or folder to be accessible at runtime. -# The Makefile for this example project suggests embedding the misc/fonts/ folder into our application, it will then be accessible as "/fonts" -# See documentation for more details: https://emscripten.org/docs/porting/files/packaging_files.html -# (Default value is 0. Set to 1 to enable file-system and include the misc/fonts/ folder as part of the build.) -USE_FILE_SYSTEM ?= 0 -ifeq ($(USE_FILE_SYSTEM), 0) -LDFLAGS += -s NO_FILESYSTEM=1 -CPPFLAGS += -DIMGUI_DISABLE_FILE_FUNCTIONS -endif -ifeq ($(USE_FILE_SYSTEM), 1) -LDFLAGS += --no-heap-copy --preload-file ../../misc/fonts@/fonts -endif - -##--------------------------------------------------------------------- -## FINAL BUILD FLAGS -##--------------------------------------------------------------------- - -CPPFLAGS += -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends -#CPPFLAGS += -g -CPPFLAGS += -Wall -Wformat -Os $(EMS) -LDFLAGS += --shell-file shell_minimal.html $(EMS) - -##--------------------------------------------------------------------- -## BUILD RULES -##--------------------------------------------------------------------- - -%.o:%.cpp - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $< - -%.o:$(IMGUI_DIR)/%.cpp - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $< - -%.o:$(IMGUI_DIR)/backends/%.cpp - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $< - -all: $(EXE) - @echo Build complete for $(EXE) - -$(WEB_DIR): - mkdir $@ - -serve: all - python3 -m http.server -d $(WEB_DIR) - -$(EXE): $(OBJS) $(WEB_DIR) - $(CXX) -o $@ $(OBJS) $(LDFLAGS) - -clean: - rm -rf $(OBJS) $(WEB_DIR) diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_emscripten_opengl3/README.md b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_emscripten_opengl3/README.md deleted file mode 100644 index fddd922..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_emscripten_opengl3/README.md +++ /dev/null @@ -1,22 +0,0 @@ -## How to Build - -- You need to install Emscripten from https://emscripten.org/docs/getting_started/downloads.html, and have the environment variables set, as described in https://emscripten.org/docs/getting_started/downloads.html#installation-instructions -- You may also refer to our [Continuous Integration setup](https://github.com/ocornut/imgui/tree/master/.github/workflows) for Emscripten setup. -- Depending on your configuration, in Windows you may need to run `emsdk/emsdk_env.bat` in your console to access the Emscripten command-line tools. -- Then build using `make` while in the `example_emscripten_opengl3/` directory. - -## How to Run - -To run on a local machine: -- `make serve` will use Python3 to spawn a local webserver, you can then browse http://localhost:8000 to access your build. -- Otherwise, generally you will need a local webserver: - - Quoting [https://emscripten.org/docs/getting_started](https://emscripten.org/docs/getting_started/Tutorial.html#generating-html):
    -_"Unfortunately several browsers (including Chrome, Safari, and Internet Explorer) do not support file:// [XHR](https://emscripten.org/docs/site/glossary.html#term-xhr) requests, and can’t load extra files needed by the HTML (like a .wasm file, or packaged file data as mentioned lower down). For these browsers you’ll need to serve the files using a [local webserver](https://emscripten.org/docs/getting_started/FAQ.html#faq-local-webserver) and then open http://localhost:8000/hello.html."_ - - Emscripten SDK has a handy `emrun` command: `emrun web/example_emscripten_opengl3.html --browser firefox` which will spawn a temporary local webserver (in Firefox). See https://emscripten.org/docs/compiling/Running-html-files-with-emrun.html for details. - - You may use Python 3 builtin webserver: `python -m http.server -d web` (this is what `make serve` uses). - - You may use Python 2 builtin webserver: `cd web && python -m SimpleHTTPServer`. - -## Obsolete features: - -- Emscripten 2.0 (August 2020) obsoleted the fastcomp backend, only llvm is supported. -- Emscripten 1.39.0 (October 2019) obsoleted the `BINARYEN_TRAP_MODE=clamp` compilation flag which was required with version older than 1.39.0 to avoid rendering artefacts. See [#2877](https://github.com/ocornut/imgui/issues/2877) for details. If you use an older version, uncomment this line in the Makefile: `#EMS += -s BINARYEN_TRAP_MODE=clamp` diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_emscripten_opengl3/main.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_emscripten_opengl3/main.cpp deleted file mode 100644 index be338a8..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_emscripten_opengl3/main.cpp +++ /dev/null @@ -1,174 +0,0 @@ -// Dear ImGui: standalone example application for Emscripten, using SDL2 + OpenGL3 -// (Emscripten is a C++-to-javascript compiler, used to publish executables for the web. See https://emscripten.org/) -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -// This is mostly the same code as the SDL2 + OpenGL3 example, simply with the modifications needed to run on Emscripten. -// It is possible to combine both code into a single source file that will compile properly on Desktop and using Emscripten. -// See https://github.com/ocornut/imgui/pull/2492 as an example on how to do just that. - -#include "imgui.h" -#include "imgui_impl_sdl.h" -#include "imgui_impl_opengl3.h" -#include -#include -#include -#include - -// Emscripten requires to have full control over the main loop. We're going to store our SDL book-keeping variables globally. -// Having a single function that acts as a loop prevents us to store state in the stack of said function. So we need some location for this. -SDL_Window* g_Window = NULL; -SDL_GLContext g_GLContext = NULL; - -// For clarity, our main loop code is declared at the end. -static void main_loop(void*); - -int main(int, char**) -{ - // Setup SDL - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) != 0) - { - printf("Error: %s\n", SDL_GetError()); - return -1; - } - - // For the browser using Emscripten, we are going to use WebGL1 with GL ES2. See the Makefile. for requirement details. - // It is very likely the generated file won't work in many browsers. Firefox is the only sure bet, but I have successfully - // run this code on Chrome for Android for example. - const char* glsl_version = "#version 100"; - //const char* glsl_version = "#version 300 es"; - SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, 0); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); - - // Create window with graphics context - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); - SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); - SDL_DisplayMode current; - SDL_GetCurrentDisplayMode(0, ¤t); - SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); - g_Window = SDL_CreateWindow("Dear ImGui Emscripten example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags); - g_GLContext = SDL_GL_CreateContext(g_Window); - if (!g_GLContext) - { - fprintf(stderr, "Failed to initialize WebGL context!\n"); - return 1; - } - SDL_GL_SetSwapInterval(1); // Enable vsync - - // Setup Dear ImGui context - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); (void)io; - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls - - // For an Emscripten build we are disabling file-system access, so let's not attempt to do a fopen() of the imgui.ini file. - // You may manually call LoadIniSettingsFromMemory() to load settings from your own storage. - io.IniFilename = NULL; - - // Setup Dear ImGui style - ImGui::StyleColorsDark(); - //ImGui::StyleColorsClassic(); - - // Setup Platform/Renderer backends - ImGui_ImplSDL2_InitForOpenGL(g_Window, g_GLContext); - ImGui_ImplOpenGL3_Init(glsl_version); - - // Load Fonts - // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. - // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. - // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). - // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call. - // - Read 'docs/FONTS.md' for more instructions and details. - // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! - // - Emscripten allows preloading a file or folder to be accessible at runtime. See Makefile for details. - //io.Fonts->AddFontDefault(); -#ifndef IMGUI_DISABLE_FILE_FUNCTIONS - io.Fonts->AddFontFromFileTTF("fonts/Roboto-Medium.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("fonts/Cousine-Regular.ttf", 15.0f); - //io.Fonts->AddFontFromFileTTF("fonts/DroidSans.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("fonts/ProggyTiny.ttf", 10.0f); - //ImFont* font = io.Fonts->AddFontFromFileTTF("fonts/ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - //IM_ASSERT(font != NULL); -#endif - - // This function call won't return, and will engage in an infinite loop, processing events from the browser, and dispatching them. - emscripten_set_main_loop_arg(main_loop, NULL, 0, true); -} - -static void main_loop(void* arg) -{ - ImGuiIO& io = ImGui::GetIO(); - IM_UNUSED(arg); // We can pass this argument as the second parameter of emscripten_set_main_loop_arg(), but we don't use that. - - // Our state (make them static = more or less global) as a convenience to keep the example terse. - static bool show_demo_window = true; - static bool show_another_window = false; - static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); - - // Poll and handle events (inputs, window resize, etc.) - // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. - // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. - // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. - // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. - SDL_Event event; - while (SDL_PollEvent(&event)) - { - ImGui_ImplSDL2_ProcessEvent(&event); - // Capture events here, based on io.WantCaptureMouse and io.WantCaptureKeyboard - } - - // Start the Dear ImGui frame - ImGui_ImplOpenGL3_NewFrame(); - ImGui_ImplSDL2_NewFrame(); - ImGui::NewFrame(); - - // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). - if (show_demo_window) - ImGui::ShowDemoWindow(&show_demo_window); - - // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window. - { - static float f = 0.0f; - static int counter = 0; - - ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. - - ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) - ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state - ImGui::Checkbox("Another Window", &show_another_window); - - ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f - ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color - - if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) - counter++; - ImGui::SameLine(); - ImGui::Text("counter = %d", counter); - - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); - ImGui::End(); - } - - // 3. Show another simple window. - if (show_another_window) - { - ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked) - ImGui::Text("Hello from another window!"); - if (ImGui::Button("Close Me")) - show_another_window = false; - ImGui::End(); - } - - // Rendering - ImGui::Render(); - SDL_GL_MakeCurrent(g_Window, g_GLContext); - glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y); - glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w); - glClear(GL_COLOR_BUFFER_BIT); - ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); - SDL_GL_SwapWindow(g_Window); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_emscripten_opengl3/shell_minimal.html b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_emscripten_opengl3/shell_minimal.html deleted file mode 100644 index 514385d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_emscripten_opengl3/shell_minimal.html +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - Dear ImGui Emscripten example - - - - - - {{{ SCRIPT }}} - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_emscripten_wgpu/Makefile b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_emscripten_wgpu/Makefile deleted file mode 100644 index 5c79f0c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_emscripten_wgpu/Makefile +++ /dev/null @@ -1,88 +0,0 @@ -# -# Makefile to use with emscripten -# See https://emscripten.org/docs/getting_started/downloads.html -# for installation instructions. -# -# This Makefile assumes you have loaded emscripten's environment. -# (On Windows, you may need to execute emsdk_env.bat or encmdprompt.bat ahead) -# -# Running `make` will produce three files: -# - web/index.html (current stored in the repository) -# - web/index.js -# - web/index.wasm -# -# All three are needed to run the demo. - -CC = emcc -CXX = em++ -WEB_DIR = web -EXE = $(WEB_DIR)/index.js -IMGUI_DIR = ../.. -SOURCES = main.cpp -SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp -SOURCES += $(IMGUI_DIR)/backends/imgui_impl_glfw.cpp $(IMGUI_DIR)/backends/imgui_impl_wgpu.cpp -OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) -UNAME_S := $(shell uname -s) -CPPFLAGS = -LDFLAGS = -EMS = - -##--------------------------------------------------------------------- -## EMSCRIPTEN OPTIONS -##--------------------------------------------------------------------- - -# ("EMS" options gets added to both CPPFLAGS and LDFLAGS, whereas some options are for linker only) -EMS += -s DISABLE_EXCEPTION_CATCHING=1 -LDFLAGS += -s USE_GLFW=3 -s USE_WEBGPU=1 -LDFLAGS += -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s NO_EXIT_RUNTIME=0 -s ASSERTIONS=1 - -# Emscripten allows preloading a file or folder to be accessible at runtime. -# The Makefile for this example project suggests embedding the misc/fonts/ folder into our application, it will then be accessible as "/fonts" -# See documentation for more details: https://emscripten.org/docs/porting/files/packaging_files.html -# (Default value is 0. Set to 1 to enable file-system and include the misc/fonts/ folder as part of the build.) -USE_FILE_SYSTEM ?= 0 -ifeq ($(USE_FILE_SYSTEM), 0) -LDFLAGS += -s NO_FILESYSTEM=1 -CPPFLAGS += -DIMGUI_DISABLE_FILE_FUNCTIONS -endif -ifeq ($(USE_FILE_SYSTEM), 1) -LDFLAGS += --no-heap-copy --preload-file ../../misc/fonts@/fonts -endif - -##--------------------------------------------------------------------- -## FINAL BUILD FLAGS -##--------------------------------------------------------------------- - -CPPFLAGS += -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends -#CPPFLAGS += -g -CPPFLAGS += -Wall -Wformat -Os $(EMS) -#LDFLAGS += --shell-file shell_minimal.html -LDFLAGS += $(EMS) - -##--------------------------------------------------------------------- -## BUILD RULES -##--------------------------------------------------------------------- - -%.o:%.cpp - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $< - -%.o:$(IMGUI_DIR)/%.cpp - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $< - -%.o:$(IMGUI_DIR)/backends/%.cpp - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $< - -all: $(EXE) - @echo Build complete for $(EXE) - -$(WEB_DIR): - mkdir $@ - -serve: all - python3 -m http.server -d $(WEB_DIR) - -$(EXE): $(OBJS) $(WEB_DIR) - $(CXX) -o $@ $(OBJS) $(LDFLAGS) - -clean: - rm -f $(EXE) $(OBJS) $(WEB_DIR)/*.js $(WEB_DIR)/*.wasm $(WEB_DIR)/*.wasm.pre diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_emscripten_wgpu/README.md b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_emscripten_wgpu/README.md deleted file mode 100644 index 73fabdd..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_emscripten_wgpu/README.md +++ /dev/null @@ -1,10 +0,0 @@ - -# How to Build - -- You need to install Emscripten from https://emscripten.org/docs/getting_started/downloads.html, and have the environment variables set, as described in https://emscripten.org/docs/getting_started/downloads.html#installation-instructions - -- Depending on your configuration, in Windows you may need to run `emsdk/emsdk_env.bat` in your console to access the Emscripten command-line tools. - -- Then build using `make` while in the `example_emscripten_wgpu/` directory. - -- Requires Emscripten 2.0.10 (December 2020) due to GLFW adaptations diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_emscripten_wgpu/main.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_emscripten_wgpu/main.cpp deleted file mode 100644 index d11d906..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_emscripten_wgpu/main.cpp +++ /dev/null @@ -1,245 +0,0 @@ -// Dear ImGui: standalone example application for Emscripten, using GLFW + WebGPU -// (Emscripten is a C++-to-javascript compiler, used to publish executables for the web. See https://emscripten.org/) -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -#include "imgui.h" -#include "imgui_impl_glfw.h" -#include "imgui_impl_wgpu.h" -#include -#include -#include -#include -#include -#include -#include - -// Global WebGPU required states -static WGPUDevice wgpu_device = NULL; -static WGPUSurface wgpu_surface = NULL; -static WGPUSwapChain wgpu_swap_chain = NULL; -static int wgpu_swap_chain_width = 0; -static int wgpu_swap_chain_height = 0; - -// States tracked across render frames -static bool show_demo_window = true; -static bool show_another_window = false; -static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); - -// Forward declarations -static bool init_wgpu(); -static void main_loop(void* window); -static void print_glfw_error(int error, const char* description); -static void print_wgpu_error(WGPUErrorType error_type, const char* message, void*); - -int main(int, char**) -{ - glfwSetErrorCallback(print_glfw_error); - if (!glfwInit()) - return 1; - - // Make sure GLFW does not initialize any graphics context. - // This needs to be done explicitly later - glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); - - GLFWwindow* window = glfwCreateWindow(1280, 720, "Dear ImGui GLFW+WebGPU example", NULL, NULL); - if (!window) - { - glfwTerminate(); - return 1; - } - - // Initialize the WebGPU environment - if (!init_wgpu()) - { - if (window) - glfwDestroyWindow(window); - glfwTerminate(); - return 1; - } - glfwShowWindow(window); - - // Setup Dear ImGui context - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); (void)io; - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls - - // For an Emscripten build we are disabling file-system access, so let's not attempt to do a fopen() of the imgui.ini file. - // You may manually call LoadIniSettingsFromMemory() to load settings from your own storage. - io.IniFilename = NULL; - - // Setup Dear ImGui style - ImGui::StyleColorsDark(); - //ImGui::StyleColorsClassic(); - - // Setup Platform/Renderer backends - ImGui_ImplGlfw_InitForOther(window, true); - ImGui_ImplWGPU_Init(wgpu_device, 3, WGPUTextureFormat_RGBA8Unorm); - - // Load Fonts - // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. - // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. - // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). - // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call. - // - Read 'docs/FONTS.md' for more instructions and details. - // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! - // - Emscripten allows preloading a file or folder to be accessible at runtime. See Makefile for details. - //io.Fonts->AddFontDefault(); -#ifndef IMGUI_DISABLE_FILE_FUNCTIONS - io.Fonts->AddFontFromFileTTF("fonts/Roboto-Medium.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("fonts/Cousine-Regular.ttf", 15.0f); - //io.Fonts->AddFontFromFileTTF("fonts/DroidSans.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("fonts/ProggyTiny.ttf", 10.0f); - //ImFont* font = io.Fonts->AddFontFromFileTTF("fonts/ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - //IM_ASSERT(font != NULL); -#endif - - // This function will directly return and exit the main function. - // Make sure that no required objects get cleaned up. - // This way we can use the browsers 'requestAnimationFrame' to control the rendering. - emscripten_set_main_loop_arg(main_loop, window, 0, false); - - return 0; -} - -static bool init_wgpu() -{ - wgpu_device = emscripten_webgpu_get_device(); - if (!wgpu_device) - return false; - - wgpuDeviceSetUncapturedErrorCallback(wgpu_device, print_wgpu_error, NULL); - - // Use C++ wrapper due to misbehavior in Emscripten. - // Some offset computation for wgpuInstanceCreateSurface in JavaScript - // seem to be inline with struct alignments in the C++ structure - wgpu::SurfaceDescriptorFromCanvasHTMLSelector html_surface_desc = {}; - html_surface_desc.selector = "#canvas"; - - wgpu::SurfaceDescriptor surface_desc = {}; - surface_desc.nextInChain = &html_surface_desc; - - // Use 'null' instance - wgpu::Instance instance = {}; - wgpu_surface = instance.CreateSurface(&surface_desc).Release(); - - return true; -} - -static void main_loop(void* window) -{ - glfwPollEvents(); - - int width, height; - glfwGetFramebufferSize((GLFWwindow*) window, &width, &height); - - // React to changes in screen size - if (width != wgpu_swap_chain_width && height != wgpu_swap_chain_height) - { - ImGui_ImplWGPU_InvalidateDeviceObjects(); - - if (wgpu_swap_chain) - wgpuSwapChainRelease(wgpu_swap_chain); - - wgpu_swap_chain_width = width; - wgpu_swap_chain_height = height; - - WGPUSwapChainDescriptor swap_chain_desc = {}; - swap_chain_desc.usage = WGPUTextureUsage_RenderAttachment; - swap_chain_desc.format = WGPUTextureFormat_RGBA8Unorm; - swap_chain_desc.width = width; - swap_chain_desc.height = height; - swap_chain_desc.presentMode = WGPUPresentMode_Fifo; - wgpu_swap_chain = wgpuDeviceCreateSwapChain(wgpu_device, wgpu_surface, &swap_chain_desc); - - ImGui_ImplWGPU_CreateDeviceObjects(); - } - - // Start the Dear ImGui frame - ImGui_ImplWGPU_NewFrame(); - ImGui_ImplGlfw_NewFrame(); - ImGui::NewFrame(); - - // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). - if (show_demo_window) - ImGui::ShowDemoWindow(&show_demo_window); - - // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window. - { - static float f = 0.0f; - static int counter = 0; - - ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. - - ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) - ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state - ImGui::Checkbox("Another Window", &show_another_window); - - ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f - ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color - - if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) - counter++; - ImGui::SameLine(); - ImGui::Text("counter = %d", counter); - - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); - ImGui::End(); - } - - // 3. Show another simple window. - if (show_another_window) - { - ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked) - ImGui::Text("Hello from another window!"); - if (ImGui::Button("Close Me")) - show_another_window = false; - ImGui::End(); - } - - // Rendering - ImGui::Render(); - - WGPURenderPassColorAttachment color_attachments = {}; - color_attachments.loadOp = WGPULoadOp_Clear; - color_attachments.storeOp = WGPUStoreOp_Store; - color_attachments.clearColor = { clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w }; - color_attachments.view = wgpuSwapChainGetCurrentTextureView(wgpu_swap_chain); - WGPURenderPassDescriptor render_pass_desc = {}; - render_pass_desc.colorAttachmentCount = 1; - render_pass_desc.colorAttachments = &color_attachments; - render_pass_desc.depthStencilAttachment = NULL; - - WGPUCommandEncoderDescriptor enc_desc = {}; - WGPUCommandEncoder encoder = wgpuDeviceCreateCommandEncoder(wgpu_device, &enc_desc); - - WGPURenderPassEncoder pass = wgpuCommandEncoderBeginRenderPass(encoder, &render_pass_desc); - ImGui_ImplWGPU_RenderDrawData(ImGui::GetDrawData(), pass); - wgpuRenderPassEncoderEndPass(pass); - - WGPUCommandBufferDescriptor cmd_buffer_desc = {}; - WGPUCommandBuffer cmd_buffer = wgpuCommandEncoderFinish(encoder, &cmd_buffer_desc); - WGPUQueue queue = wgpuDeviceGetQueue(wgpu_device); - wgpuQueueSubmit(queue, 1, &cmd_buffer); -} - -static void print_glfw_error(int error, const char* description) -{ - printf("Glfw Error %d: %s\n", error, description); -} - -static void print_wgpu_error(WGPUErrorType error_type, const char* message, void*) -{ - const char* error_type_lbl = ""; - switch (error_type) - { - case WGPUErrorType_Validation: error_type_lbl = "Validation"; break; - case WGPUErrorType_OutOfMemory: error_type_lbl = "Out of memory"; break; - case WGPUErrorType_Unknown: error_type_lbl = "Unknown"; break; - case WGPUErrorType_DeviceLost: error_type_lbl = "Device lost"; break; - default: error_type_lbl = "Unknown"; - } - printf("%s error: %s\n", error_type_lbl, message); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_metal/Makefile b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_metal/Makefile deleted file mode 100644 index a174bc8..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_metal/Makefile +++ /dev/null @@ -1,46 +0,0 @@ -# -# You will need GLFW (http://www.glfw.org): -# brew install glfw -# - -#CXX = g++ -#CXX = clang++ - -EXE = example_glfw_metal -IMGUI_DIR = ../.. -SOURCES = main.mm -SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp -SOURCES += $(IMGUI_DIR)/backends/imgui_impl_glfw.cpp $(IMGUI_DIR)/backends/imgui_impl_metal.mm -OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) - -LIBS = -framework Metal -framework MetalKit -framework Cocoa -framework IOKit -framework CoreVideo -framework QuartzCore -LIBS += -L/usr/local/lib -L/opt/homebrew/lib -LIBS += -lglfw - -CXXFLAGS = -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends -I/usr/local/include -I/opt/homebrew/include -CXXFLAGS += -Wall -Wformat -CFLAGS = $(CXXFLAGS) - -%.o:%.cpp - $(CXX) $(CXXFLAGS) -c -o $@ $< - -%.o:$(IMGUI_DIR)/%.cpp - $(CXX) $(CXXFLAGS) -c -o $@ $< - -%.o:$(IMGUI_DIR)/backends/%.cpp - $(CXX) $(CXXFLAGS) -c -o $@ $< - -%.o:%.mm - $(CXX) $(CXXFLAGS) -ObjC++ -fobjc-weak -fobjc-arc -c -o $@ $< - -%.o:$(IMGUI_DIR)/backends/%.mm - $(CXX) $(CXXFLAGS) -ObjC++ -fobjc-weak -fobjc-arc -c -o $@ $< - -all: $(EXE) - @echo Build complete - -$(EXE): $(OBJS) - $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS) - -clean: - rm -f $(EXE) $(OBJS) diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_metal/main.mm b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_metal/main.mm deleted file mode 100644 index 2776ba2..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_metal/main.mm +++ /dev/null @@ -1,172 +0,0 @@ -// Dear ImGui: standalone example application for GLFW + Metal, using programmable pipeline -// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.) -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -#include "imgui.h" -#include "imgui_impl_glfw.h" -#include "imgui_impl_metal.h" -#include - -#define GLFW_INCLUDE_NONE -#define GLFW_EXPOSE_NATIVE_COCOA -#include -#include - -#import -#import - -static void glfw_error_callback(int error, const char* description) -{ - fprintf(stderr, "Glfw Error %d: %s\n", error, description); -} - -int main(int, char**) -{ - // Setup Dear ImGui context - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); (void)io; - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls - - // Setup style - ImGui::StyleColorsDark(); - //ImGui::StyleColorsClassic(); - - // Load Fonts - // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. - // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. - // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). - // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call. - // - Read 'docs/FONTS.txt' for more instructions and details. - // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! - //io.Fonts->AddFontDefault(); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f); - //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - //IM_ASSERT(font != NULL); - - // Setup window - glfwSetErrorCallback(glfw_error_callback); - if (!glfwInit()) - return 1; - - // Create window with graphics context - glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); - GLFWwindow* window = glfwCreateWindow(1280, 720, "Dear ImGui GLFW+Metal example", NULL, NULL); - if (window == NULL) - return 1; - - id device = MTLCreateSystemDefaultDevice(); - id commandQueue = [device newCommandQueue]; - - // Setup Platform/Renderer backends - ImGui_ImplGlfw_InitForOpenGL(window, true); - ImGui_ImplMetal_Init(device); - - NSWindow *nswin = glfwGetCocoaWindow(window); - CAMetalLayer *layer = [CAMetalLayer layer]; - layer.device = device; - layer.pixelFormat = MTLPixelFormatBGRA8Unorm; - nswin.contentView.layer = layer; - nswin.contentView.wantsLayer = YES; - - MTLRenderPassDescriptor *renderPassDescriptor = [MTLRenderPassDescriptor new]; - - // Our state - bool show_demo_window = true; - bool show_another_window = false; - float clear_color[4] = {0.45f, 0.55f, 0.60f, 1.00f}; - - // Main loop - while (!glfwWindowShouldClose(window)) - { - @autoreleasepool - { - // Poll and handle events (inputs, window resize, etc.) - // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. - // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. - // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. - // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. - glfwPollEvents(); - - int width, height; - glfwGetFramebufferSize(window, &width, &height); - layer.drawableSize = CGSizeMake(width, height); - id drawable = [layer nextDrawable]; - - id commandBuffer = [commandQueue commandBuffer]; - renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColorMake(clear_color[0] * clear_color[3], clear_color[1] * clear_color[3], clear_color[2] * clear_color[3], clear_color[3]); - renderPassDescriptor.colorAttachments[0].texture = drawable.texture; - renderPassDescriptor.colorAttachments[0].loadAction = MTLLoadActionClear; - renderPassDescriptor.colorAttachments[0].storeAction = MTLStoreActionStore; - id renderEncoder = [commandBuffer renderCommandEncoderWithDescriptor:renderPassDescriptor]; - [renderEncoder pushDebugGroup:@"ImGui demo"]; - - // Start the Dear ImGui frame - ImGui_ImplMetal_NewFrame(renderPassDescriptor); - ImGui_ImplGlfw_NewFrame(); - ImGui::NewFrame(); - - // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). - if (show_demo_window) - ImGui::ShowDemoWindow(&show_demo_window); - - // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window. - { - static float f = 0.0f; - static int counter = 0; - - ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. - - ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) - ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state - ImGui::Checkbox("Another Window", &show_another_window); - - ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f - ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color - - if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) - counter++; - ImGui::SameLine(); - ImGui::Text("counter = %d", counter); - - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); - ImGui::End(); - } - - // 3. Show another simple window. - if (show_another_window) - { - ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked) - ImGui::Text("Hello from another window!"); - if (ImGui::Button("Close Me")) - show_another_window = false; - ImGui::End(); - } - - // Rendering - ImGui::Render(); - ImGui_ImplMetal_RenderDrawData(ImGui::GetDrawData(), commandBuffer, renderEncoder); - - [renderEncoder popDebugGroup]; - [renderEncoder endEncoding]; - - [commandBuffer presentDrawable:drawable]; - [commandBuffer commit]; - } - } - - // Cleanup - ImGui_ImplMetal_Shutdown(); - ImGui_ImplGlfw_Shutdown(); - ImGui::DestroyContext(); - - glfwDestroyWindow(window); - glfwTerminate(); - - return 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_opengl2/Makefile b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_opengl2/Makefile deleted file mode 100644 index 5c19a27..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_opengl2/Makefile +++ /dev/null @@ -1,81 +0,0 @@ -# -# Cross Platform Makefile -# Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X -# -# You will need GLFW (http://www.glfw.org): -# Linux: -# apt-get install libglfw-dev -# Mac OS X: -# brew install glfw -# MSYS2: -# pacman -S --noconfirm --needed mingw-w64-x86_64-toolchain mingw-w64-x86_64-glfw -# - -#CXX = g++ -#CXX = clang++ - -EXE = example_glfw_opengl2 -IMGUI_DIR = ../.. -SOURCES = main.cpp -SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp -SOURCES += $(IMGUI_DIR)/backends/imgui_impl_glfw.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl2.cpp -OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) -UNAME_S := $(shell uname -s) - -CXXFLAGS = -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends -CXXFLAGS += -g -Wall -Wformat -LIBS = - -##--------------------------------------------------------------------- -## BUILD FLAGS PER PLATFORM -##--------------------------------------------------------------------- - -ifeq ($(UNAME_S), Linux) #LINUX - ECHO_MESSAGE = "Linux" - LIBS += -lGL `pkg-config --static --libs glfw3` - - CXXFLAGS += `pkg-config --cflags glfw3` - CFLAGS = $(CXXFLAGS) -endif - -ifeq ($(UNAME_S), Darwin) #APPLE - ECHO_MESSAGE = "Mac OS X" - LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo - LIBS += -L/usr/local/lib -L/opt/local/lib -L/opt/homebrew/lib - #LIBS += -lglfw3 - LIBS += -lglfw - - CXXFLAGS += -I/usr/local/include -I/opt/local/include -I/opt/homebrew/include - CFLAGS = $(CXXFLAGS) -endif - -ifeq ($(OS), Windows_NT) - ECHO_MESSAGE = "MinGW" - LIBS += -lglfw3 -lgdi32 -lopengl32 -limm32 - - CXXFLAGS += `pkg-config --cflags glfw3` - CFLAGS = $(CXXFLAGS) -endif - -##--------------------------------------------------------------------- -## BUILD RULES -##--------------------------------------------------------------------- - -%.o:%.cpp - $(CXX) $(CXXFLAGS) -c -o $@ $< - -%.o:$(IMGUI_DIR)/%.cpp - $(CXX) $(CXXFLAGS) -c -o $@ $< - -%.o:$(IMGUI_DIR)/backends/%.cpp - $(CXX) $(CXXFLAGS) -c -o $@ $< - -all: $(EXE) - @echo Build complete for $(ECHO_MESSAGE) - -$(EXE): $(OBJS) - $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS) - -clean: - rm -f $(EXE) $(OBJS) - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_opengl2/build_win32.bat b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_opengl2/build_win32.bat deleted file mode 100644 index a0a75f9..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_opengl2/build_win32.bat +++ /dev/null @@ -1,8 +0,0 @@ -@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. -@set OUT_DIR=Debug -@set OUT_EXE=example_glfw_opengl2 -@set INCLUDES=/I..\.. /I..\..\backends /I..\libs\glfw\include -@set SOURCES=main.cpp ..\..\backends\imgui_impl_opengl2.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\imgui*.cpp -@set LIBS=/LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib -mkdir %OUT_DIR% -cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj deleted file mode 100644 index faf6d9a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj +++ /dev/null @@ -1,181 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {9CDA7840-B7A5-496D-A527-E95571496D18} - example_glfw_opengl2 - 8.1 - - - - Application - true - MultiByte - v140 - - - Application - true - MultiByte - v140 - - - Application - false - true - MultiByte - v140 - - - Application - false - true - MultiByte - v140 - - - - - - - - - - - - - - - - - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - - Level4 - Disabled - ..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories) - - - true - ..\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories) - opengl32.lib;glfw3.lib;%(AdditionalDependencies) - Console - msvcrt.lib - - - - - Level4 - Disabled - ..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories) - - - true - ..\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories) - opengl32.lib;glfw3.lib;%(AdditionalDependencies) - Console - msvcrt.lib - - - - - Level4 - MaxSpeed - true - true - ..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories) - false - - - true - true - true - ..\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories) - opengl32.lib;glfw3.lib;%(AdditionalDependencies) - Console - - - - - - - Level4 - MaxSpeed - true - true - ..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories) - false - - - true - true - true - ..\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories) - opengl32.lib;glfw3.lib;%(AdditionalDependencies) - Console - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj.filters deleted file mode 100644 index 69b285d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_opengl2/example_glfw_opengl2.vcxproj.filters +++ /dev/null @@ -1,61 +0,0 @@ - - - - - {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222} - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - sources - - - imgui - - - imgui - - - imgui - - - imgui - - - imgui - - - sources - - - sources - - - - - imgui - - - imgui - - - imgui - - - sources - - - sources - - - - - - sources - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_opengl2/main.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_opengl2/main.cpp deleted file mode 100644 index ee785b1..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_opengl2/main.cpp +++ /dev/null @@ -1,159 +0,0 @@ -// Dear ImGui: standalone example application for GLFW + OpenGL2, using legacy fixed pipeline -// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.) -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)** -// **Prefer using the code in the example_glfw_opengl2/ folder** -// See imgui_impl_glfw.cpp for details. - -#include "imgui.h" -#include "imgui_impl_glfw.h" -#include "imgui_impl_opengl2.h" -#include -#ifdef __APPLE__ -#define GL_SILENCE_DEPRECATION -#endif -#include - -// [Win32] Our example includes a copy of glfw3.lib pre-compiled with VS2010 to maximize ease of testing and compatibility with old VS compilers. -// To link with VS2010-era libraries, VS2015+ requires linking with legacy_stdio_definitions.lib, which we do using this pragma. -// Your own project should not be affected, as you are likely to link with a newer binary of GLFW that is adequate for your version of Visual Studio. -#if defined(_MSC_VER) && (_MSC_VER >= 1900) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) -#pragma comment(lib, "legacy_stdio_definitions") -#endif - -static void glfw_error_callback(int error, const char* description) -{ - fprintf(stderr, "Glfw Error %d: %s\n", error, description); -} - -int main(int, char**) -{ - // Setup window - glfwSetErrorCallback(glfw_error_callback); - if (!glfwInit()) - return 1; - GLFWwindow* window = glfwCreateWindow(1280, 720, "Dear ImGui GLFW+OpenGL2 example", NULL, NULL); - if (window == NULL) - return 1; - glfwMakeContextCurrent(window); - glfwSwapInterval(1); // Enable vsync - - // Setup Dear ImGui context - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); (void)io; - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls - - // Setup Dear ImGui style - ImGui::StyleColorsDark(); - //ImGui::StyleColorsClassic(); - - // Setup Platform/Renderer backends - ImGui_ImplGlfw_InitForOpenGL(window, true); - ImGui_ImplOpenGL2_Init(); - - // Load Fonts - // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. - // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. - // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). - // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call. - // - Read 'docs/FONTS.md' for more instructions and details. - // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! - //io.Fonts->AddFontDefault(); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f); - //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - //IM_ASSERT(font != NULL); - - // Our state - bool show_demo_window = true; - bool show_another_window = false; - ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); - - // Main loop - while (!glfwWindowShouldClose(window)) - { - // Poll and handle events (inputs, window resize, etc.) - // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. - // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. - // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. - // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. - glfwPollEvents(); - - // Start the Dear ImGui frame - ImGui_ImplOpenGL2_NewFrame(); - ImGui_ImplGlfw_NewFrame(); - ImGui::NewFrame(); - - // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). - if (show_demo_window) - ImGui::ShowDemoWindow(&show_demo_window); - - // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window. - { - static float f = 0.0f; - static int counter = 0; - - ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. - - ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) - ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state - ImGui::Checkbox("Another Window", &show_another_window); - - ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f - ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color - - if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) - counter++; - ImGui::SameLine(); - ImGui::Text("counter = %d", counter); - - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); - ImGui::End(); - } - - // 3. Show another simple window. - if (show_another_window) - { - ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked) - ImGui::Text("Hello from another window!"); - if (ImGui::Button("Close Me")) - show_another_window = false; - ImGui::End(); - } - - // Rendering - ImGui::Render(); - int display_w, display_h; - glfwGetFramebufferSize(window, &display_w, &display_h); - glViewport(0, 0, display_w, display_h); - glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w); - glClear(GL_COLOR_BUFFER_BIT); - - // If you are using this code with non-legacy OpenGL header/contexts (which you should not, prefer using imgui_impl_opengl3.cpp!!), - // you may need to backup/reset/restore other state, e.g. for current shader using the commented lines below. - //GLint last_program; - //glGetIntegerv(GL_CURRENT_PROGRAM, &last_program); - //glUseProgram(0); - ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData()); - //glUseProgram(last_program); - - glfwMakeContextCurrent(window); - glfwSwapBuffers(window); - } - - // Cleanup - ImGui_ImplOpenGL2_Shutdown(); - ImGui_ImplGlfw_Shutdown(); - ImGui::DestroyContext(); - - glfwDestroyWindow(window); - glfwTerminate(); - - return 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_opengl3/Makefile b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_opengl3/Makefile deleted file mode 100644 index 672a705..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_opengl3/Makefile +++ /dev/null @@ -1,89 +0,0 @@ -# -# Cross Platform Makefile -# Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X -# -# You will need GLFW (http://www.glfw.org): -# Linux: -# apt-get install libglfw-dev -# Mac OS X: -# brew install glfw -# MSYS2: -# pacman -S --noconfirm --needed mingw-w64-x86_64-toolchain mingw-w64-x86_64-glfw -# - -#CXX = g++ -#CXX = clang++ - -EXE = example_glfw_opengl3 -IMGUI_DIR = ../.. -SOURCES = main.cpp -SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp -SOURCES += $(IMGUI_DIR)/backends/imgui_impl_glfw.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl3.cpp -OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) -UNAME_S := $(shell uname -s) -LINUX_GL_LIBS = -lGL - -CXXFLAGS = -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends -CXXFLAGS += -g -Wall -Wformat -LIBS = - -##--------------------------------------------------------------------- -## OPENGL ES -##--------------------------------------------------------------------- - -## This assumes a GL ES library available in the system, e.g. libGLESv2.so -# CXXFLAGS += -DIMGUI_IMPL_OPENGL_ES2 -# LINUX_GL_LIBS = -lGLESv2 - -##--------------------------------------------------------------------- -## BUILD FLAGS PER PLATFORM -##--------------------------------------------------------------------- - -ifeq ($(UNAME_S), Linux) #LINUX - ECHO_MESSAGE = "Linux" - LIBS += $(LINUX_GL_LIBS) `pkg-config --static --libs glfw3` - - CXXFLAGS += `pkg-config --cflags glfw3` - CFLAGS = $(CXXFLAGS) -endif - -ifeq ($(UNAME_S), Darwin) #APPLE - ECHO_MESSAGE = "Mac OS X" - LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo - LIBS += -L/usr/local/lib -L/opt/local/lib -L/opt/homebrew/lib - #LIBS += -lglfw3 - LIBS += -lglfw - - CXXFLAGS += -I/usr/local/include -I/opt/local/include -I/opt/homebrew/include - CFLAGS = $(CXXFLAGS) -endif - -ifeq ($(OS), Windows_NT) - ECHO_MESSAGE = "MinGW" - LIBS += -lglfw3 -lgdi32 -lopengl32 -limm32 - - CXXFLAGS += `pkg-config --cflags glfw3` - CFLAGS = $(CXXFLAGS) -endif - -##--------------------------------------------------------------------- -## BUILD RULES -##--------------------------------------------------------------------- - -%.o:%.cpp - $(CXX) $(CXXFLAGS) -c -o $@ $< - -%.o:$(IMGUI_DIR)/%.cpp - $(CXX) $(CXXFLAGS) -c -o $@ $< - -%.o:$(IMGUI_DIR)/backends/%.cpp - $(CXX) $(CXXFLAGS) -c -o $@ $< - -all: $(EXE) - @echo Build complete for $(ECHO_MESSAGE) - -$(EXE): $(OBJS) - $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS) - -clean: - rm -f $(EXE) $(OBJS) diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_opengl3/build_win32.bat b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_opengl3/build_win32.bat deleted file mode 100644 index 4ba58d8..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_opengl3/build_win32.bat +++ /dev/null @@ -1,8 +0,0 @@ -@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. -@set OUT_DIR=Debug -@set OUT_EXE=example_glfw_opengl3 -@set INCLUDES=/I..\.. /I..\..\backends /I..\libs\glfw\include -@set SOURCES=main.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp -@set LIBS=/LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib -mkdir %OUT_DIR% -cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj deleted file mode 100644 index 7721c8f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj +++ /dev/null @@ -1,182 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {4a1fb5ea-22f5-42a8-ab92-1d2df5d47fb9} - example_glfw_opengl3 - 8.1 - - - - Application - true - MultiByte - v140 - - - Application - true - MultiByte - v140 - - - Application - false - true - MultiByte - v140 - - - Application - false - true - MultiByte - v140 - - - - - - - - - - - - - - - - - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - - Level4 - Disabled - ..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories) - - - true - ..\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories) - opengl32.lib;glfw3.lib;%(AdditionalDependencies) - Console - msvcrt.lib - - - - - Level4 - Disabled - ..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories) - - - true - ..\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories) - opengl32.lib;glfw3.lib;%(AdditionalDependencies) - Console - msvcrt.lib - - - - - Level4 - MaxSpeed - true - true - ..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories) - false - - - true - true - true - ..\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories) - opengl32.lib;glfw3.lib;%(AdditionalDependencies) - Console - - - - - - - Level4 - MaxSpeed - true - true - ..\..;..\..\backends;..\libs\glfw\include;%(AdditionalIncludeDirectories) - false - - - true - true - true - ..\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories) - opengl32.lib;glfw3.lib;%(AdditionalDependencies) - Console - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj.filters deleted file mode 100644 index fd2f807..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_opengl3/example_glfw_opengl3.vcxproj.filters +++ /dev/null @@ -1,64 +0,0 @@ - - - - - {20b90ce4-7fcb-4731-b9a0-075f875de82d} - - - {f18ab499-84e1-499f-8eff-9754361e0e52} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - sources - - - imgui - - - imgui - - - imgui - - - imgui - - - imgui - - - sources - - - sources - - - - - imgui - - - imgui - - - imgui - - - sources - - - sources - - - sources - - - - - - sources - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_opengl3/main.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_opengl3/main.cpp deleted file mode 100644 index f8e8a02..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_opengl3/main.cpp +++ /dev/null @@ -1,172 +0,0 @@ -// Dear ImGui: standalone example application for GLFW + OpenGL 3, using programmable pipeline -// (GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.) -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -#include "imgui.h" -#include "imgui_impl_glfw.h" -#include "imgui_impl_opengl3.h" -#include -#if defined(IMGUI_IMPL_OPENGL_ES2) -#include -#endif -#include // Will drag system OpenGL headers - -// [Win32] Our example includes a copy of glfw3.lib pre-compiled with VS2010 to maximize ease of testing and compatibility with old VS compilers. -// To link with VS2010-era libraries, VS2015+ requires linking with legacy_stdio_definitions.lib, which we do using this pragma. -// Your own project should not be affected, as you are likely to link with a newer binary of GLFW that is adequate for your version of Visual Studio. -#if defined(_MSC_VER) && (_MSC_VER >= 1900) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) -#pragma comment(lib, "legacy_stdio_definitions") -#endif - -static void glfw_error_callback(int error, const char* description) -{ - fprintf(stderr, "Glfw Error %d: %s\n", error, description); -} - -int main(int, char**) -{ - // Setup window - glfwSetErrorCallback(glfw_error_callback); - if (!glfwInit()) - return 1; - - // Decide GL+GLSL versions -#if defined(IMGUI_IMPL_OPENGL_ES2) - // GL ES 2.0 + GLSL 100 - const char* glsl_version = "#version 100"; - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); - glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API); -#elif defined(__APPLE__) - // GL 3.2 + GLSL 150 - const char* glsl_version = "#version 150"; - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); - glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // 3.2+ only - glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // Required on Mac -#else - // GL 3.0 + GLSL 130 - const char* glsl_version = "#version 130"; - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); - //glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // 3.2+ only - //glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // 3.0+ only -#endif - - // Create window with graphics context - GLFWwindow* window = glfwCreateWindow(1280, 720, "Dear ImGui GLFW+OpenGL3 example", NULL, NULL); - if (window == NULL) - return 1; - glfwMakeContextCurrent(window); - glfwSwapInterval(1); // Enable vsync - - // Setup Dear ImGui context - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); (void)io; - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls - - // Setup Dear ImGui style - ImGui::StyleColorsDark(); - //ImGui::StyleColorsClassic(); - - // Setup Platform/Renderer backends - ImGui_ImplGlfw_InitForOpenGL(window, true); - ImGui_ImplOpenGL3_Init(glsl_version); - - // Load Fonts - // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. - // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. - // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). - // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call. - // - Read 'docs/FONTS.md' for more instructions and details. - // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! - //io.Fonts->AddFontDefault(); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f); - //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - //IM_ASSERT(font != NULL); - - // Our state - bool show_demo_window = true; - bool show_another_window = false; - ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); - - // Main loop - while (!glfwWindowShouldClose(window)) - { - // Poll and handle events (inputs, window resize, etc.) - // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. - // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. - // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. - // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. - glfwPollEvents(); - - // Start the Dear ImGui frame - ImGui_ImplOpenGL3_NewFrame(); - ImGui_ImplGlfw_NewFrame(); - ImGui::NewFrame(); - - // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). - if (show_demo_window) - ImGui::ShowDemoWindow(&show_demo_window); - - // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window. - { - static float f = 0.0f; - static int counter = 0; - - ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. - - ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) - ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state - ImGui::Checkbox("Another Window", &show_another_window); - - ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f - ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color - - if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) - counter++; - ImGui::SameLine(); - ImGui::Text("counter = %d", counter); - - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); - ImGui::End(); - } - - // 3. Show another simple window. - if (show_another_window) - { - ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked) - ImGui::Text("Hello from another window!"); - if (ImGui::Button("Close Me")) - show_another_window = false; - ImGui::End(); - } - - // Rendering - ImGui::Render(); - int display_w, display_h; - glfwGetFramebufferSize(window, &display_w, &display_h); - glViewport(0, 0, display_w, display_h); - glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w); - glClear(GL_COLOR_BUFFER_BIT); - ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); - - glfwSwapBuffers(window); - } - - // Cleanup - ImGui_ImplOpenGL3_Shutdown(); - ImGui_ImplGlfw_Shutdown(); - ImGui::DestroyContext(); - - glfwDestroyWindow(window); - glfwTerminate(); - - return 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_vulkan/CMakeLists.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_vulkan/CMakeLists.txt deleted file mode 100644 index 05eab3b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_vulkan/CMakeLists.txt +++ /dev/null @@ -1,43 +0,0 @@ -# Example usage: -# mkdir build -# cd build -# cmake -g "Visual Studio 14 2015" .. - -cmake_minimum_required(VERSION 2.8) -project(imgui_example_glfw_vulkan C CXX) - -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE) -endif() - -set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DVK_PROTOTYPES") -set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVK_PROTOTYPES") - -# GLFW -set(GLFW_DIR ../../../glfw) # Set this to point to an up-to-date GLFW repo -option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" OFF) -option(GLFW_BUILD_TESTS "Build the GLFW test programs" OFF) -option(GLFW_BUILD_DOCS "Build the GLFW documentation" OFF) -option(GLFW_INSTALL "Generate installation target" OFF) -option(GLFW_DOCUMENT_INTERNALS "Include internals in documentation" OFF) -add_subdirectory(${GLFW_DIR} binary_dir EXCLUDE_FROM_ALL) -include_directories(${GLFW_DIR}/include) - -# Dear ImGui -set(IMGUI_DIR ../../) -include_directories(${IMGUI_DIR} ${IMGUI_DIR}/backends ..) - -# Libraries -find_package(Vulkan REQUIRED) -#find_library(VULKAN_LIBRARY - #NAMES vulkan vulkan-1) -#set(LIBRARIES "glfw;${VULKAN_LIBRARY}") -set(LIBRARIES "glfw;Vulkan::Vulkan") - -# Use vulkan headers from glfw: -include_directories(${GLFW_DIR}/deps) - -file(GLOB sources *.cpp) - -add_executable(example_glfw_vulkan ${sources} ${IMGUI_DIR}/backends/imgui_impl_glfw.cpp ${IMGUI_DIR}/backends/imgui_impl_vulkan.cpp ${IMGUI_DIR}/imgui.cpp ${IMGUI_DIR}/imgui_draw.cpp ${IMGUI_DIR}/imgui_demo.cpp ${IMGUI_DIR}/imgui_tables.cpp ${IMGUI_DIR}/imgui_widgets.cpp) -target_link_libraries(example_glfw_vulkan ${LIBRARIES}) diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_vulkan/build_win32.bat b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_vulkan/build_win32.bat deleted file mode 100644 index f49cbd7..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_vulkan/build_win32.bat +++ /dev/null @@ -1,14 +0,0 @@ -@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. - -@set OUT_EXE=example_glfw_vulkan -@set INCLUDES=/I..\.. /I..\..\backends /I..\libs\glfw\include /I %VULKAN_SDK%\include -@set SOURCES=main.cpp ..\..\backends\imgui_impl_vulkan.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\imgui*.cpp -@set LIBS=/LIBPATH:..\libs\glfw\lib-vc2010-32 /libpath:%VULKAN_SDK%\lib32 glfw3.lib opengl32.lib gdi32.lib shell32.lib vulkan-1.lib - -@set OUT_DIR=Debug -mkdir %OUT_DIR% -cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% - -@set OUT_DIR=Release -mkdir %OUT_DIR% -cl /nologo /Zi /MD /Ox /Oi %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_vulkan/build_win64.bat b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_vulkan/build_win64.bat deleted file mode 100644 index 893f296..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_vulkan/build_win64.bat +++ /dev/null @@ -1,13 +0,0 @@ -@REM Build for Visual Studio compiler. Run your copy of amd64/vcvars32.bat to setup 64-bit command-line compiler. - -@set INCLUDES=/I..\.. /I..\..\backends /I..\libs\glfw\include /I %VULKAN_SDK%\include -@set SOURCES=main.cpp ..\..\backends\imgui_impl_vulkan.cpp ..\..\backends\imgui_impl_glfw.cpp ..\..\imgui*.cpp -@set LIBS=/LIBPATH:..\libs\glfw\lib-vc2010-64 /libpath:%VULKAN_SDK%\lib glfw3.lib opengl32.lib gdi32.lib shell32.lib vulkan-1.lib - -@set OUT_DIR=Debug -mkdir %OUT_DIR% -cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% - -@set OUT_DIR=Release -mkdir %OUT_DIR% -cl /nologo /Zi /MD /Ox /Oi %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj deleted file mode 100644 index 34b3f21..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj +++ /dev/null @@ -1,181 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {57E2DF5A-6FC8-45BB-99DD-91A18C646E80} - example_glfw_vulkan - 8.1 - - - - Application - true - MultiByte - v140 - - - Application - true - MultiByte - v140 - - - Application - false - true - MultiByte - v140 - - - Application - false - true - MultiByte - v140 - - - - - - - - - - - - - - - - - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - - Level4 - Disabled - ..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories) - - - true - %VULKAN_SDK%\lib32;..\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories) - vulkan-1.lib;glfw3.lib;%(AdditionalDependencies) - Console - msvcrt.lib - - - - - Level4 - Disabled - ..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories) - - - true - %VULKAN_SDK%\lib;..\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories) - vulkan-1.lib;glfw3.lib;%(AdditionalDependencies) - Console - msvcrt.lib - - - - - Level4 - MaxSpeed - true - true - ..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories) - false - - - true - true - true - %VULKAN_SDK%\lib32;..\libs\glfw\lib-vc2010-32;%(AdditionalLibraryDirectories) - vulkan-1.lib;glfw3.lib;%(AdditionalDependencies) - Console - - - - - - - Level4 - MaxSpeed - true - true - ..\..;..\..\backends;%VULKAN_SDK%\include;..\libs\glfw\include;%(AdditionalIncludeDirectories) - false - - - true - true - true - %VULKAN_SDK%\lib;..\libs\glfw\lib-vc2010-64;%(AdditionalLibraryDirectories) - vulkan-1.lib;glfw3.lib;%(AdditionalDependencies) - Console - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj.filters deleted file mode 100644 index adc3365..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_vulkan/example_glfw_vulkan.vcxproj.filters +++ /dev/null @@ -1,61 +0,0 @@ - - - - - {20b90ce4-7fcb-4731-b9a0-075f875de82d} - - - {f18ab499-84e1-499f-8eff-9754361e0e52} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - sources - - - imgui - - - imgui - - - imgui - - - imgui - - - imgui - - - sources - - - sources - - - - - imgui - - - imgui - - - imgui - - - sources - - - sources - - - - - - sources - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_vulkan/main.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_vulkan/main.cpp deleted file mode 100644 index 615f2ee..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glfw_vulkan/main.cpp +++ /dev/null @@ -1,558 +0,0 @@ -// Dear ImGui: standalone example application for Glfw + Vulkan -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -// Important note to the reader who wish to integrate imgui_impl_vulkan.cpp/.h in their own engine/app. -// - Common ImGui_ImplVulkan_XXX functions and structures are used to interface with imgui_impl_vulkan.cpp/.h. -// You will use those if you want to use this rendering backend in your engine/app. -// - Helper ImGui_ImplVulkanH_XXX functions and structures are only used by this example (main.cpp) and by -// the backend itself (imgui_impl_vulkan.cpp), but should PROBABLY NOT be used by your own engine/app code. -// Read comments in imgui_impl_vulkan.h. - -#include "imgui.h" -#include "imgui_impl_glfw.h" -#include "imgui_impl_vulkan.h" -#include // printf, fprintf -#include // abort -#define GLFW_INCLUDE_NONE -#define GLFW_INCLUDE_VULKAN -#include -#include - -// [Win32] Our example includes a copy of glfw3.lib pre-compiled with VS2010 to maximize ease of testing and compatibility with old VS compilers. -// To link with VS2010-era libraries, VS2015+ requires linking with legacy_stdio_definitions.lib, which we do using this pragma. -// Your own project should not be affected, as you are likely to link with a newer binary of GLFW that is adequate for your version of Visual Studio. -#if defined(_MSC_VER) && (_MSC_VER >= 1900) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) -#pragma comment(lib, "legacy_stdio_definitions") -#endif - -//#define IMGUI_UNLIMITED_FRAME_RATE -#ifdef _DEBUG -#define IMGUI_VULKAN_DEBUG_REPORT -#endif - -static VkAllocationCallbacks* g_Allocator = NULL; -static VkInstance g_Instance = VK_NULL_HANDLE; -static VkPhysicalDevice g_PhysicalDevice = VK_NULL_HANDLE; -static VkDevice g_Device = VK_NULL_HANDLE; -static uint32_t g_QueueFamily = (uint32_t)-1; -static VkQueue g_Queue = VK_NULL_HANDLE; -static VkDebugReportCallbackEXT g_DebugReport = VK_NULL_HANDLE; -static VkPipelineCache g_PipelineCache = VK_NULL_HANDLE; -static VkDescriptorPool g_DescriptorPool = VK_NULL_HANDLE; - -static ImGui_ImplVulkanH_Window g_MainWindowData; -static int g_MinImageCount = 2; -static bool g_SwapChainRebuild = false; - -static void check_vk_result(VkResult err) -{ - if (err == 0) - return; - fprintf(stderr, "[vulkan] Error: VkResult = %d\n", err); - if (err < 0) - abort(); -} - -#ifdef IMGUI_VULKAN_DEBUG_REPORT -static VKAPI_ATTR VkBool32 VKAPI_CALL debug_report(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage, void* pUserData) -{ - (void)flags; (void)object; (void)location; (void)messageCode; (void)pUserData; (void)pLayerPrefix; // Unused arguments - fprintf(stderr, "[vulkan] Debug report from ObjectType: %i\nMessage: %s\n\n", objectType, pMessage); - return VK_FALSE; -} -#endif // IMGUI_VULKAN_DEBUG_REPORT - -static void SetupVulkan(const char** extensions, uint32_t extensions_count) -{ - VkResult err; - - // Create Vulkan Instance - { - VkInstanceCreateInfo create_info = {}; - create_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; - create_info.enabledExtensionCount = extensions_count; - create_info.ppEnabledExtensionNames = extensions; -#ifdef IMGUI_VULKAN_DEBUG_REPORT - // Enabling validation layers - const char* layers[] = { "VK_LAYER_KHRONOS_validation" }; - create_info.enabledLayerCount = 1; - create_info.ppEnabledLayerNames = layers; - - // Enable debug report extension (we need additional storage, so we duplicate the user array to add our new extension to it) - const char** extensions_ext = (const char**)malloc(sizeof(const char*) * (extensions_count + 1)); - memcpy(extensions_ext, extensions, extensions_count * sizeof(const char*)); - extensions_ext[extensions_count] = "VK_EXT_debug_report"; - create_info.enabledExtensionCount = extensions_count + 1; - create_info.ppEnabledExtensionNames = extensions_ext; - - // Create Vulkan Instance - err = vkCreateInstance(&create_info, g_Allocator, &g_Instance); - check_vk_result(err); - free(extensions_ext); - - // Get the function pointer (required for any extensions) - auto vkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkCreateDebugReportCallbackEXT"); - IM_ASSERT(vkCreateDebugReportCallbackEXT != NULL); - - // Setup the debug report callback - VkDebugReportCallbackCreateInfoEXT debug_report_ci = {}; - debug_report_ci.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT; - debug_report_ci.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT; - debug_report_ci.pfnCallback = debug_report; - debug_report_ci.pUserData = NULL; - err = vkCreateDebugReportCallbackEXT(g_Instance, &debug_report_ci, g_Allocator, &g_DebugReport); - check_vk_result(err); -#else - // Create Vulkan Instance without any debug feature - err = vkCreateInstance(&create_info, g_Allocator, &g_Instance); - check_vk_result(err); - IM_UNUSED(g_DebugReport); -#endif - } - - // Select GPU - { - uint32_t gpu_count; - err = vkEnumeratePhysicalDevices(g_Instance, &gpu_count, NULL); - check_vk_result(err); - IM_ASSERT(gpu_count > 0); - - VkPhysicalDevice* gpus = (VkPhysicalDevice*)malloc(sizeof(VkPhysicalDevice) * gpu_count); - err = vkEnumeratePhysicalDevices(g_Instance, &gpu_count, gpus); - check_vk_result(err); - - // If a number >1 of GPUs got reported, find discrete GPU if present, or use first one available. This covers - // most common cases (multi-gpu/integrated+dedicated graphics). Handling more complicated setups (multiple - // dedicated GPUs) is out of scope of this sample. - int use_gpu = 0; - for (int i = 0; i < (int)gpu_count; i++) - { - VkPhysicalDeviceProperties properties; - vkGetPhysicalDeviceProperties(gpus[i], &properties); - if (properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) - { - use_gpu = i; - break; - } - } - - g_PhysicalDevice = gpus[use_gpu]; - free(gpus); - } - - // Select graphics queue family - { - uint32_t count; - vkGetPhysicalDeviceQueueFamilyProperties(g_PhysicalDevice, &count, NULL); - VkQueueFamilyProperties* queues = (VkQueueFamilyProperties*)malloc(sizeof(VkQueueFamilyProperties) * count); - vkGetPhysicalDeviceQueueFamilyProperties(g_PhysicalDevice, &count, queues); - for (uint32_t i = 0; i < count; i++) - if (queues[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) - { - g_QueueFamily = i; - break; - } - free(queues); - IM_ASSERT(g_QueueFamily != (uint32_t)-1); - } - - // Create Logical Device (with 1 queue) - { - int device_extension_count = 1; - const char* device_extensions[] = { "VK_KHR_swapchain" }; - const float queue_priority[] = { 1.0f }; - VkDeviceQueueCreateInfo queue_info[1] = {}; - queue_info[0].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; - queue_info[0].queueFamilyIndex = g_QueueFamily; - queue_info[0].queueCount = 1; - queue_info[0].pQueuePriorities = queue_priority; - VkDeviceCreateInfo create_info = {}; - create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; - create_info.queueCreateInfoCount = sizeof(queue_info) / sizeof(queue_info[0]); - create_info.pQueueCreateInfos = queue_info; - create_info.enabledExtensionCount = device_extension_count; - create_info.ppEnabledExtensionNames = device_extensions; - err = vkCreateDevice(g_PhysicalDevice, &create_info, g_Allocator, &g_Device); - check_vk_result(err); - vkGetDeviceQueue(g_Device, g_QueueFamily, 0, &g_Queue); - } - - // Create Descriptor Pool - { - VkDescriptorPoolSize pool_sizes[] = - { - { VK_DESCRIPTOR_TYPE_SAMPLER, 1000 }, - { VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1000 }, - { VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 1000 }, - { VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1000 }, - { VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, 1000 }, - { VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, 1000 }, - { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1000 }, - { VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1000 }, - { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1000 }, - { VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, 1000 }, - { VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1000 } - }; - VkDescriptorPoolCreateInfo pool_info = {}; - pool_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; - pool_info.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT; - pool_info.maxSets = 1000 * IM_ARRAYSIZE(pool_sizes); - pool_info.poolSizeCount = (uint32_t)IM_ARRAYSIZE(pool_sizes); - pool_info.pPoolSizes = pool_sizes; - err = vkCreateDescriptorPool(g_Device, &pool_info, g_Allocator, &g_DescriptorPool); - check_vk_result(err); - } -} - -// All the ImGui_ImplVulkanH_XXX structures/functions are optional helpers used by the demo. -// Your real engine/app may not use them. -static void SetupVulkanWindow(ImGui_ImplVulkanH_Window* wd, VkSurfaceKHR surface, int width, int height) -{ - wd->Surface = surface; - - // Check for WSI support - VkBool32 res; - vkGetPhysicalDeviceSurfaceSupportKHR(g_PhysicalDevice, g_QueueFamily, wd->Surface, &res); - if (res != VK_TRUE) - { - fprintf(stderr, "Error no WSI support on physical device 0\n"); - exit(-1); - } - - // Select Surface Format - const VkFormat requestSurfaceImageFormat[] = { VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_B8G8R8_UNORM, VK_FORMAT_R8G8B8_UNORM }; - const VkColorSpaceKHR requestSurfaceColorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR; - wd->SurfaceFormat = ImGui_ImplVulkanH_SelectSurfaceFormat(g_PhysicalDevice, wd->Surface, requestSurfaceImageFormat, (size_t)IM_ARRAYSIZE(requestSurfaceImageFormat), requestSurfaceColorSpace); - - // Select Present Mode -#ifdef IMGUI_UNLIMITED_FRAME_RATE - VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_MAILBOX_KHR, VK_PRESENT_MODE_IMMEDIATE_KHR, VK_PRESENT_MODE_FIFO_KHR }; -#else - VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_FIFO_KHR }; -#endif - wd->PresentMode = ImGui_ImplVulkanH_SelectPresentMode(g_PhysicalDevice, wd->Surface, &present_modes[0], IM_ARRAYSIZE(present_modes)); - //printf("[vulkan] Selected PresentMode = %d\n", wd->PresentMode); - - // Create SwapChain, RenderPass, Framebuffer, etc. - IM_ASSERT(g_MinImageCount >= 2); - ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, wd, g_QueueFamily, g_Allocator, width, height, g_MinImageCount); -} - -static void CleanupVulkan() -{ - vkDestroyDescriptorPool(g_Device, g_DescriptorPool, g_Allocator); - -#ifdef IMGUI_VULKAN_DEBUG_REPORT - // Remove the debug report callback - auto vkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkDestroyDebugReportCallbackEXT"); - vkDestroyDebugReportCallbackEXT(g_Instance, g_DebugReport, g_Allocator); -#endif // IMGUI_VULKAN_DEBUG_REPORT - - vkDestroyDevice(g_Device, g_Allocator); - vkDestroyInstance(g_Instance, g_Allocator); -} - -static void CleanupVulkanWindow() -{ - ImGui_ImplVulkanH_DestroyWindow(g_Instance, g_Device, &g_MainWindowData, g_Allocator); -} - -static void FrameRender(ImGui_ImplVulkanH_Window* wd, ImDrawData* draw_data) -{ - VkResult err; - - VkSemaphore image_acquired_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].ImageAcquiredSemaphore; - VkSemaphore render_complete_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].RenderCompleteSemaphore; - err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex); - if (err == VK_ERROR_OUT_OF_DATE_KHR || err == VK_SUBOPTIMAL_KHR) - { - g_SwapChainRebuild = true; - return; - } - check_vk_result(err); - - ImGui_ImplVulkanH_Frame* fd = &wd->Frames[wd->FrameIndex]; - { - err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking - check_vk_result(err); - - err = vkResetFences(g_Device, 1, &fd->Fence); - check_vk_result(err); - } - { - err = vkResetCommandPool(g_Device, fd->CommandPool, 0); - check_vk_result(err); - VkCommandBufferBeginInfo info = {}; - info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; - info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; - err = vkBeginCommandBuffer(fd->CommandBuffer, &info); - check_vk_result(err); - } - { - VkRenderPassBeginInfo info = {}; - info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; - info.renderPass = wd->RenderPass; - info.framebuffer = fd->Framebuffer; - info.renderArea.extent.width = wd->Width; - info.renderArea.extent.height = wd->Height; - info.clearValueCount = 1; - info.pClearValues = &wd->ClearValue; - vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE); - } - - // Record dear imgui primitives into command buffer - ImGui_ImplVulkan_RenderDrawData(draw_data, fd->CommandBuffer); - - // Submit command buffer - vkCmdEndRenderPass(fd->CommandBuffer); - { - VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; - VkSubmitInfo info = {}; - info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; - info.waitSemaphoreCount = 1; - info.pWaitSemaphores = &image_acquired_semaphore; - info.pWaitDstStageMask = &wait_stage; - info.commandBufferCount = 1; - info.pCommandBuffers = &fd->CommandBuffer; - info.signalSemaphoreCount = 1; - info.pSignalSemaphores = &render_complete_semaphore; - - err = vkEndCommandBuffer(fd->CommandBuffer); - check_vk_result(err); - err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence); - check_vk_result(err); - } -} - -static void FramePresent(ImGui_ImplVulkanH_Window* wd) -{ - if (g_SwapChainRebuild) - return; - VkSemaphore render_complete_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].RenderCompleteSemaphore; - VkPresentInfoKHR info = {}; - info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; - info.waitSemaphoreCount = 1; - info.pWaitSemaphores = &render_complete_semaphore; - info.swapchainCount = 1; - info.pSwapchains = &wd->Swapchain; - info.pImageIndices = &wd->FrameIndex; - VkResult err = vkQueuePresentKHR(g_Queue, &info); - if (err == VK_ERROR_OUT_OF_DATE_KHR || err == VK_SUBOPTIMAL_KHR) - { - g_SwapChainRebuild = true; - return; - } - check_vk_result(err); - wd->SemaphoreIndex = (wd->SemaphoreIndex + 1) % wd->ImageCount; // Now we can use the next set of semaphores -} - -static void glfw_error_callback(int error, const char* description) -{ - fprintf(stderr, "Glfw Error %d: %s\n", error, description); -} - -int main(int, char**) -{ - // Setup GLFW window - glfwSetErrorCallback(glfw_error_callback); - if (!glfwInit()) - return 1; - - glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); - GLFWwindow* window = glfwCreateWindow(1280, 720, "Dear ImGui GLFW+Vulkan example", NULL, NULL); - - // Setup Vulkan - if (!glfwVulkanSupported()) - { - printf("GLFW: Vulkan Not Supported\n"); - return 1; - } - uint32_t extensions_count = 0; - const char** extensions = glfwGetRequiredInstanceExtensions(&extensions_count); - SetupVulkan(extensions, extensions_count); - - // Create Window Surface - VkSurfaceKHR surface; - VkResult err = glfwCreateWindowSurface(g_Instance, window, g_Allocator, &surface); - check_vk_result(err); - - // Create Framebuffers - int w, h; - glfwGetFramebufferSize(window, &w, &h); - ImGui_ImplVulkanH_Window* wd = &g_MainWindowData; - SetupVulkanWindow(wd, surface, w, h); - - // Setup Dear ImGui context - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); (void)io; - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls - - // Setup Dear ImGui style - ImGui::StyleColorsDark(); - //ImGui::StyleColorsClassic(); - - // Setup Platform/Renderer backends - ImGui_ImplGlfw_InitForVulkan(window, true); - ImGui_ImplVulkan_InitInfo init_info = {}; - init_info.Instance = g_Instance; - init_info.PhysicalDevice = g_PhysicalDevice; - init_info.Device = g_Device; - init_info.QueueFamily = g_QueueFamily; - init_info.Queue = g_Queue; - init_info.PipelineCache = g_PipelineCache; - init_info.DescriptorPool = g_DescriptorPool; - init_info.Allocator = g_Allocator; - init_info.MinImageCount = g_MinImageCount; - init_info.ImageCount = wd->ImageCount; - init_info.CheckVkResultFn = check_vk_result; - ImGui_ImplVulkan_Init(&init_info, wd->RenderPass); - - // Load Fonts - // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. - // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. - // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). - // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call. - // - Read 'docs/FONTS.md' for more instructions and details. - // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! - //io.Fonts->AddFontDefault(); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f); - //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - //IM_ASSERT(font != NULL); - - // Upload Fonts - { - // Use any command queue - VkCommandPool command_pool = wd->Frames[wd->FrameIndex].CommandPool; - VkCommandBuffer command_buffer = wd->Frames[wd->FrameIndex].CommandBuffer; - - err = vkResetCommandPool(g_Device, command_pool, 0); - check_vk_result(err); - VkCommandBufferBeginInfo begin_info = {}; - begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; - begin_info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; - err = vkBeginCommandBuffer(command_buffer, &begin_info); - check_vk_result(err); - - ImGui_ImplVulkan_CreateFontsTexture(command_buffer); - - VkSubmitInfo end_info = {}; - end_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; - end_info.commandBufferCount = 1; - end_info.pCommandBuffers = &command_buffer; - err = vkEndCommandBuffer(command_buffer); - check_vk_result(err); - err = vkQueueSubmit(g_Queue, 1, &end_info, VK_NULL_HANDLE); - check_vk_result(err); - - err = vkDeviceWaitIdle(g_Device); - check_vk_result(err); - ImGui_ImplVulkan_DestroyFontUploadObjects(); - } - - // Our state - bool show_demo_window = true; - bool show_another_window = false; - ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); - - // Main loop - while (!glfwWindowShouldClose(window)) - { - // Poll and handle events (inputs, window resize, etc.) - // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. - // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. - // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. - // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. - glfwPollEvents(); - - // Resize swap chain? - if (g_SwapChainRebuild) - { - int width, height; - glfwGetFramebufferSize(window, &width, &height); - if (width > 0 && height > 0) - { - ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount); - ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, &g_MainWindowData, g_QueueFamily, g_Allocator, width, height, g_MinImageCount); - g_MainWindowData.FrameIndex = 0; - g_SwapChainRebuild = false; - } - } - - // Start the Dear ImGui frame - ImGui_ImplVulkan_NewFrame(); - ImGui_ImplGlfw_NewFrame(); - ImGui::NewFrame(); - - // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). - if (show_demo_window) - ImGui::ShowDemoWindow(&show_demo_window); - - // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window. - { - static float f = 0.0f; - static int counter = 0; - - ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. - - ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) - ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state - ImGui::Checkbox("Another Window", &show_another_window); - - ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f - ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color - - if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) - counter++; - ImGui::SameLine(); - ImGui::Text("counter = %d", counter); - - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); - ImGui::End(); - } - - // 3. Show another simple window. - if (show_another_window) - { - ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked) - ImGui::Text("Hello from another window!"); - if (ImGui::Button("Close Me")) - show_another_window = false; - ImGui::End(); - } - - // Rendering - ImGui::Render(); - ImDrawData* draw_data = ImGui::GetDrawData(); - const bool is_minimized = (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f); - if (!is_minimized) - { - wd->ClearValue.color.float32[0] = clear_color.x * clear_color.w; - wd->ClearValue.color.float32[1] = clear_color.y * clear_color.w; - wd->ClearValue.color.float32[2] = clear_color.z * clear_color.w; - wd->ClearValue.color.float32[3] = clear_color.w; - FrameRender(wd, draw_data); - FramePresent(wd); - } - } - - // Cleanup - err = vkDeviceWaitIdle(g_Device); - check_vk_result(err); - ImGui_ImplVulkan_Shutdown(); - ImGui_ImplGlfw_Shutdown(); - ImGui::DestroyContext(); - - CleanupVulkanWindow(); - CleanupVulkan(); - - glfwDestroyWindow(window); - glfwTerminate(); - - return 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glut_opengl2/Makefile b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glut_opengl2/Makefile deleted file mode 100644 index a980f56..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glut_opengl2/Makefile +++ /dev/null @@ -1,75 +0,0 @@ -# -# Cross Platform Makefile -# Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X -# -# Linux: -# apt-get install freeglut3-dev -# - -#CXX = g++ -#CXX = clang++ - -EXE = example_glut_opengl2 -IMGUI_DIR = ../.. -SOURCES = main.cpp -SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp -SOURCES += $(IMGUI_DIR)/backends/imgui_impl_glut.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl2.cpp -OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) -UNAME_S := $(shell uname -s) - -CXXFLAGS = -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends -CXXFLAGS += -g -Wall -Wformat -LIBS = - -##--------------------------------------------------------------------- -## BUILD FLAGS PER PLATFORM -##--------------------------------------------------------------------- - -ifeq ($(UNAME_S), Linux) #LINUX - ECHO_MESSAGE = "Linux" - LIBS += -lGL -lglut - CFLAGS = $(CXXFLAGS) -endif - -ifeq ($(UNAME_S), Darwin) #APPLE - ECHO_MESSAGE = "Mac OS X" - LIBS += -framework OpenGL -framework GLUT - LIBS += -L/usr/local/lib -L/opt/local/lib - - CXXFLAGS += -I/usr/local/include -I/opt/local/include - CFLAGS = $(CXXFLAGS) -endif - -ifeq ($(OS), Windows_NT) - ECHO_MESSAGE = "MinGW" - LIBS += -lgdi32 -lopengl32 -limm32 -ifeq ($(shell pkg-config freeglut --exists 2> /dev/null && echo yes || echo no),yes) - CXXFLAGS += $(shell pkg-config freeglut --cflags) - LIBS += $(shell pkg-config freeglut --libs) -else - LIBS += -lglut -endif - CFLAGS = $(CXXFLAGS) -endif - -##--------------------------------------------------------------------- -## BUILD RULES -##--------------------------------------------------------------------- - -%.o:%.cpp - $(CXX) $(CXXFLAGS) -c -o $@ $< - -%.o:$(IMGUI_DIR)/%.cpp - $(CXX) $(CXXFLAGS) -c -o $@ $< - -%.o:$(IMGUI_DIR)/backends/%.cpp - $(CXX) $(CXXFLAGS) -c -o $@ $< - -all: $(EXE) - @echo Build complete for $(ECHO_MESSAGE) - -$(EXE): $(OBJS) - $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS) - -clean: - rm -f $(EXE) $(OBJS) diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glut_opengl2/example_glut_opengl2.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glut_opengl2/example_glut_opengl2.vcxproj deleted file mode 100644 index 4c9d00f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glut_opengl2/example_glut_opengl2.vcxproj +++ /dev/null @@ -1,181 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {F90D0333-5FB1-440D-918D-DD39A1B5187E} - example_glut_opengl2 - 8.1 - - - - Application - true - MultiByte - v140 - - - Application - true - MultiByte - v140 - - - Application - false - true - MultiByte - v140 - - - Application - false - true - MultiByte - v140 - - - - - - - - - - - - - - - - - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - - Level4 - Disabled - $(GLUT_INCLUDE_DIR);..\..;..\..\backends;%(AdditionalIncludeDirectories) - - - true - $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories) - opengl32.lib;freeglut.lib;%(AdditionalDependencies) - Console - msvcrt.lib - - - - - Level4 - Disabled - $(GLUT_INCLUDE_DIR);..\..;..\..\backends;%(AdditionalIncludeDirectories) - - - true - $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories) - opengl32.lib;freeglut.lib;%(AdditionalDependencies) - Console - msvcrt.lib - - - - - Level4 - MaxSpeed - true - true - $(GLUT_INCLUDE_DIR);..\..;..\..\backends;%(AdditionalIncludeDirectories) - false - - - true - true - true - $(GLUT_ROOT_PATH)/lib;%(AdditionalLibraryDirectories) - opengl32.lib;freeglut.lib;%(AdditionalDependencies) - Console - - - - - - - Level4 - MaxSpeed - true - true - $(GLUT_INCLUDE_DIR);..\..;..\..\backends;%(AdditionalIncludeDirectories) - false - - - true - true - true - $(GLUT_ROOT_PATH)/lib/x64;%(AdditionalLibraryDirectories) - opengl32.lib;freeglut.lib;%(AdditionalDependencies) - Console - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters deleted file mode 100644 index 3c017ba..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glut_opengl2/example_glut_opengl2.vcxproj.filters +++ /dev/null @@ -1,61 +0,0 @@ - - - - - {c336cfe3-f0c4-464c-9ef0-a9e17a7ff222} - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - sources - - - imgui - - - imgui - - - imgui - - - imgui - - - imgui - - - sources - - - sources - - - - - imgui - - - imgui - - - imgui - - - sources - - - sources - - - - - - sources - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glut_opengl2/main.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glut_opengl2/main.cpp deleted file mode 100644 index fed62b5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_glut_opengl2/main.cpp +++ /dev/null @@ -1,155 +0,0 @@ -// Dear ImGui: standalone example application for GLUT/FreeGLUT + OpenGL2, using legacy fixed pipeline -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -// !!! GLUT/FreeGLUT IS OBSOLETE PREHISTORIC SOFTWARE. Using GLUT is not recommended unless you really miss the 90's. !!! -// !!! If someone or something is teaching you GLUT today, you are being abused. Please show some resistance. !!! -// !!! Nowadays, prefer using GLFW or SDL instead! - -// On Windows, you can install Freeglut using vcpkg: -// git clone https://github.com/Microsoft/vcpkg -// cd vcpkg -// bootstrap - vcpkg.bat -// vcpkg install freeglut --triplet=x86-windows ; for win32 -// vcpkg install freeglut --triplet=x64-windows ; for win64 -// vcpkg integrate install ; register include and libs in Visual Studio - -#include "imgui.h" -#include "imgui_impl_glut.h" -#include "imgui_impl_opengl2.h" -#ifdef __APPLE__ - #include -#else - #include -#endif - -#ifdef _MSC_VER -#pragma warning (disable: 4505) // unreferenced local function has been removed -#endif - -// Our state -static bool show_demo_window = true; -static bool show_another_window = false; -static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); - -void my_display_code() -{ - // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). - if (show_demo_window) - ImGui::ShowDemoWindow(&show_demo_window); - - // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window. - { - static float f = 0.0f; - static int counter = 0; - - ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. - - ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) - ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state - ImGui::Checkbox("Another Window", &show_another_window); - - ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f - ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color - - if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) - counter++; - ImGui::SameLine(); - ImGui::Text("counter = %d", counter); - - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); - ImGui::End(); - } - - // 3. Show another simple window. - if (show_another_window) - { - ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked) - ImGui::Text("Hello from another window!"); - if (ImGui::Button("Close Me")) - show_another_window = false; - ImGui::End(); - } -} - -void glut_display_func() -{ - // Start the Dear ImGui frame - ImGui_ImplOpenGL2_NewFrame(); - ImGui_ImplGLUT_NewFrame(); - - my_display_code(); - - // Rendering - ImGui::Render(); - ImGuiIO& io = ImGui::GetIO(); - glViewport(0, 0, (GLsizei)io.DisplaySize.x, (GLsizei)io.DisplaySize.y); - glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w); - glClear(GL_COLOR_BUFFER_BIT); - //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound, but prefer using the GL3+ code. - ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData()); - - glutSwapBuffers(); - glutPostRedisplay(); -} - -// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. -// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. -// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. -// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. - -int main(int argc, char** argv) -{ - // Create GLUT window - glutInit(&argc, argv); -#ifdef __FREEGLUT_EXT_H__ - glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS); -#endif - glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_MULTISAMPLE); - glutInitWindowSize(1280, 720); - glutCreateWindow("Dear ImGui GLUT+OpenGL2 Example"); - - // Setup GLUT display function - // We will also call ImGui_ImplGLUT_InstallFuncs() to get all the other functions installed for us, - // otherwise it is possible to install our own functions and call the imgui_impl_glut.h functions ourselves. - glutDisplayFunc(glut_display_func); - - // Setup Dear ImGui context - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); (void)io; - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls - - // Setup Dear ImGui style - ImGui::StyleColorsDark(); - //ImGui::StyleColorsClassic(); - - // Setup Platform/Renderer backends - ImGui_ImplGLUT_Init(); - ImGui_ImplGLUT_InstallFuncs(); - ImGui_ImplOpenGL2_Init(); - - // Load Fonts - // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. - // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. - // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). - // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call. - // - Read 'docs/FONTS.md' for more instructions and details. - // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! - //io.Fonts->AddFontDefault(); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f); - //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - //IM_ASSERT(font != NULL); - - glutMainLoop(); - - // Cleanup - ImGui_ImplOpenGL2_Shutdown(); - ImGui_ImplGLUT_Shutdown(); - ImGui::DestroyContext(); - - return 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_marmalade/data/app.icf b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_marmalade/data/app.icf deleted file mode 100644 index fcd6585..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_marmalade/data/app.icf +++ /dev/null @@ -1,32 +0,0 @@ -# This file is for configuration settings for your -# application. -# -# The syntax is similar to windows .ini files ie -# -# [GroupName] -# Setting = Value -# -# Which can be read by your application using -# e.g s3eConfigGetString("GroupName", "Setting", string) -# -# All settings must be documented in .config.txt files. -# New settings specific to this application should be -# documented in app.config.txt -# -# Some conditional operations are also permitted, see the -# S3E documentation for details. - -[S3E] -MemSize=6000000 -MemSizeDebug=6000000 -DispFixRot=FixedLandscape - -# emulate iphone 5 resolution, change these settings to emulate other display resolution -WinWidth=1136 -WinHeight=640 - -[GX] -DataCacheSize=131070 - -[Util] -#MemoryBreakpoint=1282 diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_marmalade/main.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_marmalade/main.cpp deleted file mode 100644 index e97cb53..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_marmalade/main.cpp +++ /dev/null @@ -1,124 +0,0 @@ -// Dear ImGui: standalone example application for Marmalade -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -// Copyright (C) 2015 by Giovanni Zito -// This file is part of Dear ImGui - -#include "imgui.h" -#include "imgui_impl_marmalade.h" -#include - -#include -#include -#include - -int main(int, char**) -{ - IwGxInit(); - - // Setup Dear ImGui context - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); (void)io; - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls - - // Setup Dear ImGui style - ImGui::StyleColorsDark(); - //ImGui::StyleColorsClassic(); - - // Setup Platform/Renderer backends - ImGui_Marmalade_Init(true); - - // Load Fonts - // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. - // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. - // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). - // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call. - // - Read 'docs/FONTS.md' for more instructions and details. - // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! - //io.Fonts->AddFontDefault(); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f); - //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - //IM_ASSERT(font != NULL); - - // Our state - bool show_demo_window = true; - bool show_another_window = false; - ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); - - // Main loop - while (true) - { - if (s3eDeviceCheckQuitRequest()) - break; - - // Poll and handle inputs - // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. - // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. - // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. - // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. - s3eKeyboardUpdate(); - s3ePointerUpdate(); - - // Start the Dear ImGui frame - ImGui_Marmalade_NewFrame(); - ImGui::NewFrame(); - - // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). - if (show_demo_window) - ImGui::ShowDemoWindow(&show_demo_window); - - // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window. - { - static float f = 0.0f; - static int counter = 0; - - ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. - - ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) - ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state - ImGui::Checkbox("Another Window", &show_another_window); - - ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f - ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color - - if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) - counter++; - ImGui::SameLine(); - ImGui::Text("counter = %d", counter); - - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); - ImGui::End(); - } - - // 3. Show another simple window. - if (show_another_window) - { - ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked) - ImGui::Text("Hello from another window!"); - if (ImGui::Button("Close Me")) - show_another_window = false; - ImGui::End(); - } - - // Rendering - ImGui::Render(); - IwGxSetColClear(clear_color.x * 255, clear_color.y * 255, clear_color.z * 255, clear_color.w * 255); - IwGxClear(); - ImGui_Marmalade_RenderDrawData(ImGui::GetDrawData()); - IwGxSwapBuffers(); - - s3eDeviceYield(0); - } - - // Cleanup - ImGui_Marmalade_Shutdown(); - ImGui::DestroyContext(); - IwGxTerminate(); - - return 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_marmalade/marmalade_example.mkb b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_marmalade/marmalade_example.mkb deleted file mode 100644 index 4e765f1..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_marmalade/marmalade_example.mkb +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env mkb - -# ImGui - standalone example application for Marmalade -# Copyright (C) 2015 by Giovanni Zito -# This file is part of ImGui -# https://github.com/ocornut/imgui - -define IMGUI_DISABLE_INCLUDE_IMCONFIG_H -define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS -define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS -define _snprintf=snprintf - -options -{ - optimise-speed=1 -} - -includepaths -{ - ../.. - ../../backends -} - -subprojects -{ - iwgx -} - -files -{ - (.) - ["imgui"] - ../../imgui.cpp - ../../imgui_demo.cpp - ../../imgui_draw.cpp - ../../imgui_tables.cpp - ../../imgui_widgets.cpp - ../../imconfig.h - ../../imgui.h - ../../imgui_internal.h - - ["imgui","Marmalade backend"] - ../../backends/imgui_impl_marmalade.h - ../../backends/imgui_impl_marmalade.cpp - main.cpp - -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_null/Makefile b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_null/Makefile deleted file mode 100644 index 9208e8a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_null/Makefile +++ /dev/null @@ -1,92 +0,0 @@ -# -# Cross Platform Makefile -# Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X -# -# Important: This is a "null backend" application, with no visible output or interaction! -# This is used for testing purpose and continuous integration, and has little use for end-user. -# - -# Options -WITH_EXTRA_WARNINGS ?= 0 -WITH_FREETYPE ?= 0 - -EXE = example_null -IMGUI_DIR = ../.. -SOURCES = main.cpp -SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp -OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) -UNAME_S := $(shell uname -s) - -CXXFLAGS += -I$(IMGUI_DIR) -CXXFLAGS += -g -Wall -Wformat -LIBS = - -# We use the WITH_EXTRA_WARNINGS flag on our CI setup to eagerly catch zealous warnings -ifeq ($(WITH_EXTRA_WARNINGS), 1) - CXXFLAGS += -Wno-zero-as-null-pointer-constant -Wno-double-promotion -Wno-variadic-macros -endif - -# We use the WITH_FREETYPE flag on our CI setup to test compiling misc/freetype/imgui_freetype.cpp -# (only supported on Linux, and note that the imgui_freetype code currently won't be executed) -ifeq ($(WITH_FREETYPE), 1) - SOURCES += $(IMGUI_DIR)/misc/freetype/imgui_freetype.cpp - CXXFLAGS += $(shell pkg-config --cflags freetype2) - LIBS += $(shell pkg-config --libs freetype2) -endif - -##--------------------------------------------------------------------- -## BUILD FLAGS PER PLATFORM -##--------------------------------------------------------------------- - -ifeq ($(UNAME_S), Linux) #LINUX - ECHO_MESSAGE = "Linux" - ifeq ($(WITH_EXTRA_WARNINGS), 1) - CXXFLAGS += -Wextra -Wpedantic - ifeq ($(shell $(CXX) -v 2>&1 | grep -c "clang version"), 1) - CXXFLAGS += -Wshadow -Wsign-conversion - endif - endif - CFLAGS = $(CXXFLAGS) -endif - -ifeq ($(UNAME_S), Darwin) #APPLE - ECHO_MESSAGE = "Mac OS X" - ifeq ($(WITH_EXTRA_WARNINGS), 1) - CXXFLAGS += -Weverything -Wno-reserved-id-macro -Wno-c++98-compat-pedantic -Wno-padded -Wno-c++11-long-long -Wno-poison-system-directories - endif - CFLAGS = $(CXXFLAGS) -endif - -ifeq ($(OS), Windows_NT) - ECHO_MESSAGE = "MinGW" - ifeq ($(WITH_EXTRA_WARNINGS), 1) - CXXFLAGS += -Wextra -Wpedantic - endif - LIBS += -limm32 - CFLAGS = $(CXXFLAGS) -endif - -##--------------------------------------------------------------------- -## BUILD RULES -##--------------------------------------------------------------------- - -%.o:%.cpp - $(CXX) $(CXXFLAGS) -c -o $@ $< - -%.o:$(IMGUI_DIR)/%.cpp - $(CXX) $(CXXFLAGS) -c -o $@ $< - -%.o:$(IMGUI_DIR)/backends/%.cpp - $(CXX) $(CXXFLAGS) -c -o $@ $< - -%.o:$(IMGUI_DIR)/misc/freetype/%.cpp - $(CXX) $(CXXFLAGS) -c -o $@ $< - -all: $(EXE) - @echo Build complete for $(ECHO_MESSAGE) - -$(EXE): $(OBJS) - $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS) - -clean: - rm -f $(EXE) $(OBJS) diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_null/build_win32.bat b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_null/build_win32.bat deleted file mode 100644 index 0cdfdc9..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_null/build_win32.bat +++ /dev/null @@ -1,3 +0,0 @@ -@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. -mkdir Debug -cl /nologo /Zi /MD /I ..\.. %* *.cpp ..\..\*.cpp /FeDebug/example_null.exe /FoDebug/ /link gdi32.lib shell32.lib imm32.lib diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_null/main.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_null/main.cpp deleted file mode 100644 index 72381f0..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_null/main.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// dear imgui: "null" example application -// (compile and link imgui, create context, run headless with NO INPUTS, NO GRAPHICS OUTPUT) -// This is useful to test building, but you cannot interact with anything here! -#include "imgui.h" -#include - -int main(int, char**) -{ - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); - - // Build atlas - unsigned char* tex_pixels = NULL; - int tex_w, tex_h; - io.Fonts->GetTexDataAsRGBA32(&tex_pixels, &tex_w, &tex_h); - - for (int n = 0; n < 20; n++) - { - printf("NewFrame() %d\n", n); - io.DisplaySize = ImVec2(1920, 1080); - io.DeltaTime = 1.0f / 60.0f; - ImGui::NewFrame(); - - static float f = 0.0f; - ImGui::Text("Hello, world!"); - ImGui::SliderFloat("float", &f, 0.0f, 1.0f); - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate); - ImGui::ShowDemoWindow(NULL); - - ImGui::Render(); - } - - printf("DestroyContext()\n"); - ImGui::DestroyContext(); - return 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_directx11/build_win32.bat b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_directx11/build_win32.bat deleted file mode 100644 index b930827..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_directx11/build_win32.bat +++ /dev/null @@ -1,8 +0,0 @@ -@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. -@set OUT_DIR=Debug -@set OUT_EXE=example_sdl_directx11 -@set INCLUDES=/I..\.. /I..\..\backends /I%SDL2_DIR%\include /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /I "%DXSDK_DIR%Include" -@set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl.cpp ..\..\backends\imgui_impl_dx11.cpp ..\..\imgui*.cpp -@set LIBS=/LIBPATH:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib /LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d11.lib d3dcompiler.lib shell32.lib -mkdir %OUT_DIR% -cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_directx11/example_sdl_directx11.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_directx11/example_sdl_directx11.vcxproj deleted file mode 100644 index ac636d2..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_directx11/example_sdl_directx11.vcxproj +++ /dev/null @@ -1,182 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {9E1987E3-1F19-45CA-B9C9-D31E791836D8} - example_sdl_directx11 - 8.1 - example_sdl_directx11 - - - - Application - true - MultiByte - v140 - - - Application - true - MultiByte - v140 - - - Application - false - true - MultiByte - v140 - - - Application - false - true - MultiByte - v140 - - - - - - - - - - - - - - - - - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - - Level4 - Disabled - ..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories) - - - true - %SDL2_DIR%\lib\x86;$(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories) - SDL2.lib;SDL2main.lib;d3d11.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies) - Console - msvcrt.lib - - - - - Level4 - Disabled - ..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories) - - - true - %SDL2_DIR%\lib\x64;$(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories) - SDL2.lib;SDL2main.lib;d3d11.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies) - Console - msvcrt.lib - - - - - Level4 - MaxSpeed - true - true - ..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories) - false - - - true - true - true - %SDL2_DIR%\lib\x86;$(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories) - SDL2.lib;SDL2main.lib;d3d11.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies) - Console - - - - - - - Level4 - MaxSpeed - true - true - ..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories) - false - - - true - true - true - %SDL2_DIR%\lib\x64;$(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories) - SDL2.lib;SDL2main.lib;d3d11.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies) - Console - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_directx11/example_sdl_directx11.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_directx11/example_sdl_directx11.vcxproj.filters deleted file mode 100644 index 15fc853..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_directx11/example_sdl_directx11.vcxproj.filters +++ /dev/null @@ -1,60 +0,0 @@ - - - - - {0587d7a3-f2ce-4d56-b84f-a0005d3bfce6} - - - {08e36723-ce4f-4cff-9662-c40801cf1acf} - - - - - imgui - - - imgui - - - imgui - - - sources - - - sources - - - - - imgui - - - sources - - - imgui - - - imgui - - - imgui - - - imgui - - - sources - - - sources - - - - - - sources - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_directx11/main.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_directx11/main.cpp deleted file mode 100644 index fc51715..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_directx11/main.cpp +++ /dev/null @@ -1,230 +0,0 @@ -// Dear ImGui: standalone example application for SDL2 + DirectX 11 -// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.) -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -#include "imgui.h" -#include "imgui_impl_sdl.h" -#include "imgui_impl_dx11.h" -#include -#include -#include -#include - -// Data -static ID3D11Device* g_pd3dDevice = NULL; -static ID3D11DeviceContext* g_pd3dDeviceContext = NULL; -static IDXGISwapChain* g_pSwapChain = NULL; -static ID3D11RenderTargetView* g_mainRenderTargetView = NULL; - -// Forward declarations of helper functions -bool CreateDeviceD3D(HWND hWnd); -void CleanupDeviceD3D(); -void CreateRenderTarget(); -void CleanupRenderTarget(); - -// Main code -int main(int, char**) -{ - // Setup SDL - // (Some versions of SDL before <2.0.10 appears to have performance/stalling issues on a minority of Windows systems, - // depending on whether SDL_INIT_GAMECONTROLLER is enabled or disabled.. updating to latest version of SDL is recommended!) - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) != 0) - { - printf("Error: %s\n", SDL_GetError()); - return -1; - } - - // Setup window - SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); - SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+DirectX11 example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags); - SDL_SysWMinfo wmInfo; - SDL_VERSION(&wmInfo.version); - SDL_GetWindowWMInfo(window, &wmInfo); - HWND hwnd = (HWND)wmInfo.info.win.window; - - // Initialize Direct3D - if (!CreateDeviceD3D(hwnd)) - { - CleanupDeviceD3D(); - return 1; - } - - // Setup Dear ImGui context - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); (void)io; - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls - - // Setup Dear ImGui style - ImGui::StyleColorsDark(); - //ImGui::StyleColorsClassic(); - - // Setup Platform/Renderer backends - ImGui_ImplSDL2_InitForD3D(window); - ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext); - - // Load Fonts - // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. - // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. - // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). - // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call. - // - Read 'docs/FONTS.md' for more instructions and details. - // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! - //io.Fonts->AddFontDefault(); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f); - //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - //IM_ASSERT(font != NULL); - - // Our state - bool show_demo_window = true; - bool show_another_window = false; - ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); - - // Main loop - bool done = false; - while (!done) - { - // Poll and handle events (inputs, window resize, etc.) - // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. - // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. - // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. - // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. - SDL_Event event; - while (SDL_PollEvent(&event)) - { - ImGui_ImplSDL2_ProcessEvent(&event); - if (event.type == SDL_QUIT) - done = true; - if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE && event.window.windowID == SDL_GetWindowID(window)) - done = true; - if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_RESIZED && event.window.windowID == SDL_GetWindowID(window)) - { - // Release all outstanding references to the swap chain's buffers before resizing. - CleanupRenderTarget(); - g_pSwapChain->ResizeBuffers(0, 0, 0, DXGI_FORMAT_UNKNOWN, 0); - CreateRenderTarget(); - } - } - - // Start the Dear ImGui frame - ImGui_ImplDX11_NewFrame(); - ImGui_ImplSDL2_NewFrame(); - ImGui::NewFrame(); - - // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). - if (show_demo_window) - ImGui::ShowDemoWindow(&show_demo_window); - - // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window. - { - static float f = 0.0f; - static int counter = 0; - - ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. - - ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) - ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state - ImGui::Checkbox("Another Window", &show_another_window); - - ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f - ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color - - if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) - counter++; - ImGui::SameLine(); - ImGui::Text("counter = %d", counter); - - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); - ImGui::End(); - } - - // 3. Show another simple window. - if (show_another_window) - { - ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked) - ImGui::Text("Hello from another window!"); - if (ImGui::Button("Close Me")) - show_another_window = false; - ImGui::End(); - } - - // Rendering - ImGui::Render(); - const float clear_color_with_alpha[4] = { clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w }; - g_pd3dDeviceContext->OMSetRenderTargets(1, &g_mainRenderTargetView, NULL); - g_pd3dDeviceContext->ClearRenderTargetView(g_mainRenderTargetView, clear_color_with_alpha); - ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData()); - - g_pSwapChain->Present(1, 0); // Present with vsync - //g_pSwapChain->Present(0, 0); // Present without vsync - } - - // Cleanup - ImGui_ImplDX11_Shutdown(); - ImGui_ImplSDL2_Shutdown(); - ImGui::DestroyContext(); - - CleanupDeviceD3D(); - SDL_DestroyWindow(window); - SDL_Quit(); - - return 0; -} - -// Helper functions - -bool CreateDeviceD3D(HWND hWnd) -{ - // Setup swap chain - DXGI_SWAP_CHAIN_DESC sd; - ZeroMemory(&sd, sizeof(sd)); - sd.BufferCount = 2; - sd.BufferDesc.Width = 0; - sd.BufferDesc.Height = 0; - sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; - sd.BufferDesc.RefreshRate.Numerator = 60; - sd.BufferDesc.RefreshRate.Denominator = 1; - sd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; - sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; - sd.OutputWindow = hWnd; - sd.SampleDesc.Count = 1; - sd.SampleDesc.Quality = 0; - sd.Windowed = TRUE; - sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; - - UINT createDeviceFlags = 0; - //createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG; - D3D_FEATURE_LEVEL featureLevel; - const D3D_FEATURE_LEVEL featureLevelArray[2] = { D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_0, }; - if (D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, createDeviceFlags, featureLevelArray, 2, D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &featureLevel, &g_pd3dDeviceContext) != S_OK) - return false; - - CreateRenderTarget(); - return true; -} - -void CleanupDeviceD3D() -{ - CleanupRenderTarget(); - if (g_pSwapChain) { g_pSwapChain->Release(); g_pSwapChain = NULL; } - if (g_pd3dDeviceContext) { g_pd3dDeviceContext->Release(); g_pd3dDeviceContext = NULL; } - if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; } -} - -void CreateRenderTarget() -{ - ID3D11Texture2D* pBackBuffer; - g_pSwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer)); - g_pd3dDevice->CreateRenderTargetView(pBackBuffer, NULL, &g_mainRenderTargetView); - pBackBuffer->Release(); -} - -void CleanupRenderTarget() -{ - if (g_mainRenderTargetView) { g_mainRenderTargetView->Release(); g_mainRenderTargetView = NULL; } -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_metal/Makefile b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_metal/Makefile deleted file mode 100644 index 042bb04..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_metal/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -# -# You will need SDL2 (http://www.libsdl.org): -# brew install sdl2 -# - -#CXX = g++ -#CXX = clang++ - -EXE = example_sdl_metal -IMGUI_DIR = ../.. -SOURCES = main.mm -SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp -SOURCES += $(IMGUI_DIR)/backends/imgui_impl_sdl.cpp $(IMGUI_DIR)/backends/imgui_impl_metal.mm -OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) - -LIBS = -framework Metal -framework MetalKit -framework Cocoa -framework IOKit -framework CoreVideo -framework QuartzCore -LIBS += `sdl2-config --libs` -LIBS += -L/usr/local/lib - -CXXFLAGS = -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends -I/usr/local/include -CXXFLAGS += `sdl2-config --cflags` -CXXFLAGS += -Wall -Wformat -CFLAGS = $(CXXFLAGS) - -%.o:%.cpp - $(CXX) $(CXXFLAGS) -c -o $@ $< - -%.o:$(IMGUI_DIR)/%.cpp - $(CXX) $(CXXFLAGS) -c -o $@ $< - -%.o:$(IMGUI_DIR)/backends/%.cpp - $(CXX) $(CXXFLAGS) -c -o $@ $< - -%.o:%.mm - $(CXX) $(CXXFLAGS) -ObjC++ -fobjc-weak -fobjc-arc -c -o $@ $< - -%.o:$(IMGUI_DIR)/backends/%.mm - $(CXX) $(CXXFLAGS) -ObjC++ -fobjc-weak -fobjc-arc -c -o $@ $< - -all: $(EXE) - @echo Build complete - -$(EXE): $(OBJS) - $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS) - -clean: - rm -f $(EXE) $(OBJS) diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_metal/main.mm b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_metal/main.mm deleted file mode 100644 index caa86e6..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_metal/main.mm +++ /dev/null @@ -1,181 +0,0 @@ -// Dear ImGui: standalone example application for SDL2 + Metal -// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.) -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -#include "imgui.h" -#include "imgui_impl_sdl.h" -#include "imgui_impl_metal.h" -#include -#include - -#import -#import - -int main(int, char**) -{ - // Setup Dear ImGui context - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); (void)io; - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls - - // Setup style - ImGui::StyleColorsDark(); - //ImGui::StyleColorsClassic(); - - // Load Fonts - // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. - // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. - // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). - // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call. - // - Read 'docs/FONTS.txt' for more instructions and details. - // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! - //io.Fonts->AddFontDefault(); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f); - //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - //IM_ASSERT(font != NULL); - - // Setup SDL - // (Some versions of SDL before <2.0.10 appears to have performance/stalling issues on a minority of Windows systems, - // depending on whether SDL_INIT_GAMECONTROLLER is enabled or disabled.. updating to latest version of SDL is recommended!) - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) != 0) - { - printf("Error: %s\n", SDL_GetError()); - return -1; - } - - // Inform SDL that we will be using metal for rendering. Without this hint initialization of metal renderer may fail. - SDL_SetHint(SDL_HINT_RENDER_DRIVER, "metal"); - - SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL+Metal example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); - if (window == NULL) - { - printf("Error creating window: %s\n", SDL_GetError()); - return -2; - } - - SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); - if (renderer == NULL) - { - printf("Error creating renderer: %s\n", SDL_GetError()); - return -3; - } - - // Setup Platform/Renderer backends - CAMetalLayer* layer = (__bridge CAMetalLayer*)SDL_RenderGetMetalLayer(renderer); - layer.pixelFormat = MTLPixelFormatBGRA8Unorm; - ImGui_ImplMetal_Init(layer.device); - ImGui_ImplSDL2_InitForMetal(window); - - id commandQueue = [layer.device newCommandQueue]; - MTLRenderPassDescriptor* renderPassDescriptor = [MTLRenderPassDescriptor new]; - - // Our state - bool show_demo_window = true; - bool show_another_window = false; - float clear_color[4] = {0.45f, 0.55f, 0.60f, 1.00f}; - - // Main loop - bool done = false; - while (!done) - { - @autoreleasepool - { - // Poll and handle events (inputs, window resize, etc.) - // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. - // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. - // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. - // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. - SDL_Event event; - while (SDL_PollEvent(&event)) - { - ImGui_ImplSDL2_ProcessEvent(&event); - if (event.type == SDL_QUIT) - done = true; - if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE && event.window.windowID == SDL_GetWindowID(window)) - done = true; - } - - int width, height; - SDL_GetRendererOutputSize(renderer, &width, &height); - layer.drawableSize = CGSizeMake(width, height); - id drawable = [layer nextDrawable]; - - id commandBuffer = [commandQueue commandBuffer]; - renderPassDescriptor.colorAttachments[0].clearColor = MTLClearColorMake(clear_color[0] * clear_color[3], clear_color[1] * clear_color[3], clear_color[2] * clear_color[3], clear_color[3]); - renderPassDescriptor.colorAttachments[0].texture = drawable.texture; - renderPassDescriptor.colorAttachments[0].loadAction = MTLLoadActionClear; - renderPassDescriptor.colorAttachments[0].storeAction = MTLStoreActionStore; - id renderEncoder = [commandBuffer renderCommandEncoderWithDescriptor:renderPassDescriptor]; - [renderEncoder pushDebugGroup:@"ImGui demo"]; - - // Start the Dear ImGui frame - ImGui_ImplMetal_NewFrame(renderPassDescriptor); - ImGui_ImplSDL2_NewFrame(); - ImGui::NewFrame(); - - // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). - if (show_demo_window) - ImGui::ShowDemoWindow(&show_demo_window); - - // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window. - { - static float f = 0.0f; - static int counter = 0; - - ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. - - ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) - ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state - ImGui::Checkbox("Another Window", &show_another_window); - - ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f - ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color - - if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) - counter++; - ImGui::SameLine(); - ImGui::Text("counter = %d", counter); - - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); - ImGui::End(); - } - - // 3. Show another simple window. - if (show_another_window) - { - ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked) - ImGui::Text("Hello from another window!"); - if (ImGui::Button("Close Me")) - show_another_window = false; - ImGui::End(); - } - - // Rendering - ImGui::Render(); - ImGui_ImplMetal_RenderDrawData(ImGui::GetDrawData(), commandBuffer, renderEncoder); - - [renderEncoder popDebugGroup]; - [renderEncoder endEncoding]; - - [commandBuffer presentDrawable:drawable]; - [commandBuffer commit]; - } - } - - // Cleanup - ImGui_ImplMetal_Shutdown(); - ImGui_ImplSDL2_Shutdown(); - ImGui::DestroyContext(); - - SDL_DestroyRenderer(renderer); - SDL_DestroyWindow(window); - SDL_Quit(); - - return 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl2/Makefile b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl2/Makefile deleted file mode 100644 index 92e0554..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl2/Makefile +++ /dev/null @@ -1,79 +0,0 @@ -# -# Cross Platform Makefile -# Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X -# -# You will need SDL2 (http://www.libsdl.org): -# Linux: -# apt-get install libsdl2-dev -# Mac OS X: -# brew install sdl2 -# MSYS2: -# pacman -S mingw-w64-i686-SDL2 -# - -#CXX = g++ -#CXX = clang++ - -EXE = example_sdl_opengl2 -IMGUI_DIR = ../.. -SOURCES = main.cpp -SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp -SOURCES += $(IMGUI_DIR)/backends/imgui_impl_sdl.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl2.cpp -OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) -UNAME_S := $(shell uname -s) - -CXXFLAGS = -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends -CXXFLAGS += -g -Wall -Wformat -LIBS = - -##--------------------------------------------------------------------- -## BUILD FLAGS PER PLATFORM -##--------------------------------------------------------------------- - -ifeq ($(UNAME_S), Linux) #LINUX - ECHO_MESSAGE = "Linux" - LIBS += -lGL -ldl `sdl2-config --libs` - - CXXFLAGS += `sdl2-config --cflags` - CFLAGS = $(CXXFLAGS) -endif - -ifeq ($(UNAME_S), Darwin) #APPLE - ECHO_MESSAGE = "Mac OS X" - LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo `sdl2-config --libs` - LIBS += -L/usr/local/lib -L/opt/local/lib - - CXXFLAGS += `sdl2-config --cflags` - CXXFLAGS += -I/usr/local/include -I/opt/local/include - CFLAGS = $(CXXFLAGS) -endif - -ifeq ($(OS), Windows_NT) - ECHO_MESSAGE = "MinGW" - LIBS += -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2` - - CXXFLAGS += `pkg-config --cflags sdl2` - CFLAGS = $(CXXFLAGS) -endif - -##--------------------------------------------------------------------- -## BUILD RULES -##--------------------------------------------------------------------- - -%.o:%.cpp - $(CXX) $(CXXFLAGS) -c -o $@ $< - -%.o:$(IMGUI_DIR)/%.cpp - $(CXX) $(CXXFLAGS) -c -o $@ $< - -%.o:$(IMGUI_DIR)/backends/%.cpp - $(CXX) $(CXXFLAGS) -c -o $@ $< - -all: $(EXE) - @echo Build complete for $(ECHO_MESSAGE) - -$(EXE): $(OBJS) - $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS) - -clean: - rm -f $(EXE) $(OBJS) diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl2/README.md b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl2/README.md deleted file mode 100644 index 2bf4d03..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl2/README.md +++ /dev/null @@ -1,29 +0,0 @@ - -# How to Build - -- On Windows with Visual Studio's IDE - -Use the provided project file (.vcxproj). Add to solution (imgui_examples.sln) if necessary. - -- On Windows with Visual Studio's CLI - -``` -set SDL2_DIR=path_to_your_sdl2_folder -cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl.cpp ..\..\backends\imgui_impl_opengl2.cpp ..\..\imgui*.cpp /FeDebug/example_sdl_opengl2.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console -# ^^ include paths ^^ source files ^^ output exe ^^ output dir ^^ libraries -# or for 64-bit: -cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl.cpp ..\..\backends\imgui_impl_opengl2.cpp ..\..\imgui*.cpp /FeDebug/example_sdl_opengl2.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x64 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console -``` - -- On Linux and similar Unixes - -``` -c++ `sdl2-config --cflags` -I .. -I ../.. -I ../../backends main.cpp ../../backends/imgui_impl_sdl.cpp ../../backends/imgui_impl_opengl2.cpp ../../imgui*.cpp `sdl2-config --libs` -lGL -``` - -- On Mac OS X - -``` -brew install sdl2 -c++ `sdl2-config --cflags` -I .. -I ../.. -I ../../backends main.cpp ../../backends/imgui_impl_sdl.cpp ../../backends/imgui_impl_opengl2.cpp ../../imgui*.cpp `sdl2-config --libs` -framework OpenGl -``` diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl2/build_win32.bat b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl2/build_win32.bat deleted file mode 100644 index 47529e2..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl2/build_win32.bat +++ /dev/null @@ -1,8 +0,0 @@ -@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. -@set OUT_DIR=Debug -@set OUT_EXE=example_sdl_opengl2 -@set INCLUDES=/I..\.. /I..\..\backends /I%SDL2_DIR%\include -@set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl.cpp ..\..\backends\imgui_impl_opengl2.cpp ..\..\imgui*.cpp -@set LIBS=/LIBPATH:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib shell32.lib -mkdir %OUT_DIR% -cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj deleted file mode 100644 index d22a67b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj +++ /dev/null @@ -1,181 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {2AE17FDE-F7F3-4CAC-ADAB-0710EDA4F741} - example_sdl_opengl2 - 8.1 - - - - Application - true - MultiByte - v140 - - - Application - true - MultiByte - v140 - - - Application - false - true - MultiByte - v140 - - - Application - false - true - MultiByte - v140 - - - - - - - - - - - - - - - - - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - - Level4 - Disabled - ..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories) - - - true - %SDL2_DIR%\lib\x86;%(AdditionalLibraryDirectories) - opengl32.lib;SDL2.lib;SDL2main.lib;%(AdditionalDependencies) - Console - msvcrt.lib - - - - - Level4 - Disabled - ..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories) - - - true - %SDL2_DIR%\lib\x64;%(AdditionalLibraryDirectories) - opengl32.lib;SDL2.lib;SDL2main.lib;%(AdditionalDependencies) - Console - msvcrt.lib - - - - - Level4 - MaxSpeed - true - true - ..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories) - false - - - true - true - true - %SDL2_DIR%\lib\x86;%(AdditionalLibraryDirectories) - opengl32.lib;SDL2.lib;SDL2main.lib;%(AdditionalDependencies) - Console - - - - - - - Level4 - MaxSpeed - true - true - ..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories) - false - - - true - true - true - %SDL2_DIR%\lib\x64;%(AdditionalLibraryDirectories) - opengl32.lib;SDL2.lib;SDL2main.lib;%(AdditionalDependencies) - Console - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj.filters deleted file mode 100644 index 2253b86..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl2/example_sdl_opengl2.vcxproj.filters +++ /dev/null @@ -1,61 +0,0 @@ - - - - - {20b90ce4-7fcb-4731-b9a0-075f875de82d} - - - {f18ab499-84e1-499f-8eff-9754361e0e52} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - imgui - - - imgui - - - imgui - - - sources - - - imgui - - - imgui - - - sources - - - sources - - - - - imgui - - - imgui - - - imgui - - - sources - - - sources - - - - - - sources - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl2/main.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl2/main.cpp deleted file mode 100644 index a81f856..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl2/main.cpp +++ /dev/null @@ -1,157 +0,0 @@ -// Dear ImGui: standalone example application for SDL2 + OpenGL -// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.) -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)** -// **Prefer using the code in the example_sdl_opengl3/ folder** -// See imgui_impl_sdl.cpp for details. - -#include "imgui.h" -#include "imgui_impl_sdl.h" -#include "imgui_impl_opengl2.h" -#include -#include -#include - -// Main code -int main(int, char**) -{ - // Setup SDL - // (Some versions of SDL before <2.0.10 appears to have performance/stalling issues on a minority of Windows systems, - // depending on whether SDL_INIT_GAMECONTROLLER is enabled or disabled.. updating to latest version of SDL is recommended!) - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) != 0) - { - printf("Error: %s\n", SDL_GetError()); - return -1; - } - - // Setup window - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); - SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); - SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); - SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+OpenGL example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags); - SDL_GLContext gl_context = SDL_GL_CreateContext(window); - SDL_GL_MakeCurrent(window, gl_context); - SDL_GL_SetSwapInterval(1); // Enable vsync - - // Setup Dear ImGui context - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); (void)io; - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls - - // Setup Dear ImGui style - ImGui::StyleColorsDark(); - //ImGui::StyleColorsClassic(); - - // Setup Platform/Renderer backends - ImGui_ImplSDL2_InitForOpenGL(window, gl_context); - ImGui_ImplOpenGL2_Init(); - - // Load Fonts - // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. - // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. - // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). - // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call. - // - Read 'docs/FONTS.md' for more instructions and details. - // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! - //io.Fonts->AddFontDefault(); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f); - //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - //IM_ASSERT(font != NULL); - - // Our state - bool show_demo_window = true; - bool show_another_window = false; - ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); - - // Main loop - bool done = false; - while (!done) - { - // Poll and handle events (inputs, window resize, etc.) - // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. - // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. - // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. - // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. - SDL_Event event; - while (SDL_PollEvent(&event)) - { - ImGui_ImplSDL2_ProcessEvent(&event); - if (event.type == SDL_QUIT) - done = true; - if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE && event.window.windowID == SDL_GetWindowID(window)) - done = true; - } - - // Start the Dear ImGui frame - ImGui_ImplOpenGL2_NewFrame(); - ImGui_ImplSDL2_NewFrame(); - ImGui::NewFrame(); - - // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). - if (show_demo_window) - ImGui::ShowDemoWindow(&show_demo_window); - - // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window. - { - static float f = 0.0f; - static int counter = 0; - - ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. - - ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) - ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state - ImGui::Checkbox("Another Window", &show_another_window); - - ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f - ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color - - if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) - counter++; - ImGui::SameLine(); - ImGui::Text("counter = %d", counter); - - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); - ImGui::End(); - } - - // 3. Show another simple window. - if (show_another_window) - { - ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked) - ImGui::Text("Hello from another window!"); - if (ImGui::Button("Close Me")) - show_another_window = false; - ImGui::End(); - } - - // Rendering - ImGui::Render(); - glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y); - glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w); - glClear(GL_COLOR_BUFFER_BIT); - //glUseProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound - ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData()); - SDL_GL_SwapWindow(window); - } - - // Cleanup - ImGui_ImplOpenGL2_Shutdown(); - ImGui_ImplSDL2_Shutdown(); - ImGui::DestroyContext(); - - SDL_GL_DeleteContext(gl_context); - SDL_DestroyWindow(window); - SDL_Quit(); - - return 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl3/Makefile b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl3/Makefile deleted file mode 100644 index 1b8ab42..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl3/Makefile +++ /dev/null @@ -1,91 +0,0 @@ -# -# Cross Platform Makefile -# Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X -# -# You will need SDL2 (http://www.libsdl.org): -# Linux: -# apt-get install libsdl2-dev -# Mac OS X: -# brew install sdl2 -# MSYS2: -# pacman -S mingw-w64-i686-SDL2 -# - -#CXX = g++ -#CXX = clang++ - -EXE = example_sdl_opengl3 -IMGUI_DIR = ../.. -SOURCES = main.cpp -SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp -SOURCES += $(IMGUI_DIR)/backends/imgui_impl_sdl.cpp $(IMGUI_DIR)/backends/imgui_impl_opengl3.cpp -OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) -UNAME_S := $(shell uname -s) -LINUX_GL_LIBS = -lGL - -CXXFLAGS = -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends -CXXFLAGS += -g -Wall -Wformat -LIBS = - -##--------------------------------------------------------------------- -## OPENGL ES -##--------------------------------------------------------------------- - -## This assumes a GL ES library available in the system, e.g. libGLESv2.so -# CXXFLAGS += -DIMGUI_IMPL_OPENGL_ES2 -# LINUX_GL_LIBS = -lGLESv2 -## If you're on a Raspberry Pi and want to use the legacy drivers, -## use the following instead: -# LINUX_GL_LIBS = -L/opt/vc/lib -lbrcmGLESv2 - -##--------------------------------------------------------------------- -## BUILD FLAGS PER PLATFORM -##--------------------------------------------------------------------- - -ifeq ($(UNAME_S), Linux) #LINUX - ECHO_MESSAGE = "Linux" - LIBS += $(LINUX_GL_LIBS) -ldl `sdl2-config --libs` - - CXXFLAGS += `sdl2-config --cflags` - CFLAGS = $(CXXFLAGS) -endif - -ifeq ($(UNAME_S), Darwin) #APPLE - ECHO_MESSAGE = "Mac OS X" - LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo `sdl2-config --libs` - LIBS += -L/usr/local/lib -L/opt/local/lib - - CXXFLAGS += `sdl2-config --cflags` - CXXFLAGS += -I/usr/local/include -I/opt/local/include - CFLAGS = $(CXXFLAGS) -endif - -ifeq ($(OS), Windows_NT) - ECHO_MESSAGE = "MinGW" - LIBS += -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2` - - CXXFLAGS += `pkg-config --cflags sdl2` - CFLAGS = $(CXXFLAGS) -endif - -##--------------------------------------------------------------------- -## BUILD RULES -##--------------------------------------------------------------------- - -%.o:%.cpp - $(CXX) $(CXXFLAGS) -c -o $@ $< - -%.o:$(IMGUI_DIR)/%.cpp - $(CXX) $(CXXFLAGS) -c -o $@ $< - -%.o:$(IMGUI_DIR)/backends/%.cpp - $(CXX) $(CXXFLAGS) -c -o $@ $< - -all: $(EXE) - @echo Build complete for $(ECHO_MESSAGE) - -$(EXE): $(OBJS) - $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS) - -clean: - rm -f $(EXE) $(OBJS) diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl3/README.md b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl3/README.md deleted file mode 100644 index 06d4b2d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl3/README.md +++ /dev/null @@ -1,29 +0,0 @@ - -# How to Build - -- On Windows with Visual Studio's IDE - -Use the provided project file (.vcxproj). Add to solution (imgui_examples.sln) if necessary. - -- On Windows with Visual Studio's CLI - -``` -set SDL2_DIR=path_to_your_sdl2_folder -cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp /FeDebug/example_sdl_opengl3.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console -# ^^ include paths ^^ source files ^^ output exe ^^ output dir ^^ libraries -# or for 64-bit: -cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp /FeDebug/example_sdl_opengl3.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x64 SDL2.lib SDL2main.lib opengl32.lib /subsystem:console -``` - -- On Linux and similar Unixes - -``` -c++ `sdl2-config --cflags` -I .. -I ../.. -I ../../backends main.cpp ../../backends/imgui_impl_sdl.cpp ../../backends/imgui_impl_opengl3.cpp ../../imgui*.cpp `sdl2-config --libs` -lGL -ldl -``` - -- On Mac OS X - -``` -brew install sdl2 -c++ `sdl2-config --cflags` -I .. -I ../.. -I ../../backends main.cpp ../../backends/imgui_impl_sdl.cpp ../../backends/imgui_impl_opengl3.cpp ../../imgui*.cpp `sdl2-config --libs` -framework OpenGl -framework CoreFoundation -``` diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl3/build_win32.bat b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl3/build_win32.bat deleted file mode 100644 index 20851bf..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl3/build_win32.bat +++ /dev/null @@ -1,8 +0,0 @@ -@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. -@set OUT_DIR=Debug -@set OUT_EXE=example_sdl_opengl3 -@set INCLUDES=/I..\.. /I..\..\backends /I%SDL2_DIR%\include -@set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl.cpp ..\..\backends\imgui_impl_opengl3.cpp ..\..\imgui*.cpp -@set LIBS=/LIBPATH:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib opengl32.lib shell32.lib -mkdir %OUT_DIR% -cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj deleted file mode 100644 index ace041d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj +++ /dev/null @@ -1,182 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {BBAEB705-1669-40F3-8567-04CF6A991F4C} - example_sdl_opengl3 - 8.1 - - - - Application - true - MultiByte - v140 - - - Application - true - MultiByte - v140 - - - Application - false - true - MultiByte - v140 - - - Application - false - true - MultiByte - v140 - - - - - - - - - - - - - - - - - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - - Level4 - Disabled - ..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories) - - - true - %SDL2_DIR%\lib\x86;%(AdditionalLibraryDirectories) - opengl32.lib;SDL2.lib;SDL2main.lib;%(AdditionalDependencies) - Console - msvcrt.lib - - - - - Level4 - Disabled - ..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories) - - - true - %SDL2_DIR%\lib\x64;%(AdditionalLibraryDirectories) - opengl32.lib;SDL2.lib;SDL2main.lib;%(AdditionalDependencies) - Console - msvcrt.lib - - - - - Level4 - MaxSpeed - true - true - ..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories) - false - - - true - true - true - %SDL2_DIR%\lib\x86;%(AdditionalLibraryDirectories) - opengl32.lib;SDL2.lib;SDL2main.lib;%(AdditionalDependencies) - Console - - - - - - - Level4 - MaxSpeed - true - true - ..\..;..\..\backends;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories) - false - - - true - true - true - %SDL2_DIR%\lib\x64;%(AdditionalLibraryDirectories) - opengl32.lib;SDL2.lib;SDL2main.lib;%(AdditionalDependencies) - Console - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj.filters deleted file mode 100644 index c8dbeae..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl3/example_sdl_opengl3.vcxproj.filters +++ /dev/null @@ -1,64 +0,0 @@ - - - - - {20b90ce4-7fcb-4731-b9a0-075f875de82d} - - - {f18ab499-84e1-499f-8eff-9754361e0e52} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - imgui - - - imgui - - - imgui - - - sources - - - sources - - - sources - - - imgui - - - imgui - - - - - imgui - - - imgui - - - imgui - - - sources - - - sources - - - sources - - - - - - sources - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl3/main.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl3/main.cpp deleted file mode 100644 index a7e7fc0..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_opengl3/main.cpp +++ /dev/null @@ -1,178 +0,0 @@ -// Dear ImGui: standalone example application for SDL2 + OpenGL -// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.) -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -#include "imgui.h" -#include "imgui_impl_sdl.h" -#include "imgui_impl_opengl3.h" -#include -#include -#if defined(IMGUI_IMPL_OPENGL_ES2) -#include -#else -#include -#endif - -// Main code -int main(int, char**) -{ - // Setup SDL - // (Some versions of SDL before <2.0.10 appears to have performance/stalling issues on a minority of Windows systems, - // depending on whether SDL_INIT_GAMECONTROLLER is enabled or disabled.. updating to latest version of SDL is recommended!) - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) != 0) - { - printf("Error: %s\n", SDL_GetError()); - return -1; - } - - // Decide GL+GLSL versions -#if defined(IMGUI_IMPL_OPENGL_ES2) - // GL ES 2.0 + GLSL 100 - const char* glsl_version = "#version 100"; - SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, 0); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); -#elif defined(__APPLE__) - // GL 3.2 Core + GLSL 150 - const char* glsl_version = "#version 150"; - SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG); // Always required on Mac - SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); -#else - // GL 3.0 + GLSL 130 - const char* glsl_version = "#version 130"; - SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, 0); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); -#endif - - // Create window with graphics context - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); - SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); - SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); - SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+OpenGL3 example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags); - SDL_GLContext gl_context = SDL_GL_CreateContext(window); - SDL_GL_MakeCurrent(window, gl_context); - SDL_GL_SetSwapInterval(1); // Enable vsync - - // Setup Dear ImGui context - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); (void)io; - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls - - // Setup Dear ImGui style - ImGui::StyleColorsDark(); - //ImGui::StyleColorsClassic(); - - // Setup Platform/Renderer backends - ImGui_ImplSDL2_InitForOpenGL(window, gl_context); - ImGui_ImplOpenGL3_Init(glsl_version); - - // Load Fonts - // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. - // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. - // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). - // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call. - // - Read 'docs/FONTS.md' for more instructions and details. - // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! - //io.Fonts->AddFontDefault(); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f); - //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - //IM_ASSERT(font != NULL); - - // Our state - bool show_demo_window = true; - bool show_another_window = false; - ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); - - // Main loop - bool done = false; - while (!done) - { - // Poll and handle events (inputs, window resize, etc.) - // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. - // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. - // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. - // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. - SDL_Event event; - while (SDL_PollEvent(&event)) - { - ImGui_ImplSDL2_ProcessEvent(&event); - if (event.type == SDL_QUIT) - done = true; - if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE && event.window.windowID == SDL_GetWindowID(window)) - done = true; - } - - // Start the Dear ImGui frame - ImGui_ImplOpenGL3_NewFrame(); - ImGui_ImplSDL2_NewFrame(); - ImGui::NewFrame(); - - // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). - if (show_demo_window) - ImGui::ShowDemoWindow(&show_demo_window); - - // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window. - { - static float f = 0.0f; - static int counter = 0; - - ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. - - ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) - ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state - ImGui::Checkbox("Another Window", &show_another_window); - - ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f - ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color - - if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) - counter++; - ImGui::SameLine(); - ImGui::Text("counter = %d", counter); - - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); - ImGui::End(); - } - - // 3. Show another simple window. - if (show_another_window) - { - ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked) - ImGui::Text("Hello from another window!"); - if (ImGui::Button("Close Me")) - show_another_window = false; - ImGui::End(); - } - - // Rendering - ImGui::Render(); - glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y); - glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w); - glClear(GL_COLOR_BUFFER_BIT); - ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); - SDL_GL_SwapWindow(window); - } - - // Cleanup - ImGui_ImplOpenGL3_Shutdown(); - ImGui_ImplSDL2_Shutdown(); - ImGui::DestroyContext(); - - SDL_GL_DeleteContext(gl_context); - SDL_DestroyWindow(window); - SDL_Quit(); - - return 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_sdlrenderer/Makefile b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_sdlrenderer/Makefile deleted file mode 100644 index 5667789..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_sdlrenderer/Makefile +++ /dev/null @@ -1,79 +0,0 @@ -# -# Cross Platform Makefile -# Compatible with MSYS2/MINGW, Ubuntu 14.04.1 and Mac OS X -# -# You will need SDL2 (http://www.libsdl.org): -# Linux: -# apt-get install libsdl2-dev -# Mac OS X: -# brew install sdl2 -# MSYS2: -# pacman -S mingw-w64-i686-SDL2 -# - -#CXX = g++ -#CXX = clang++ - -EXE = example_sdl_sdlrenderer -IMGUI_DIR = ../.. -SOURCES = main.cpp -SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp -SOURCES += $(IMGUI_DIR)/backends/imgui_impl_sdl.cpp $(IMGUI_DIR)/backends/imgui_impl_sdlrenderer.cpp -OBJS = $(addsuffix .o, $(basename $(notdir $(SOURCES)))) -UNAME_S := $(shell uname -s) - -CXXFLAGS = -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends -CXXFLAGS += -g -Wall -Wformat -LIBS = - -##--------------------------------------------------------------------- -## BUILD FLAGS PER PLATFORM -##--------------------------------------------------------------------- - -ifeq ($(UNAME_S), Linux) #LINUX - ECHO_MESSAGE = "Linux" - LIBS += -lGL -ldl `sdl2-config --libs` - - CXXFLAGS += `sdl2-config --cflags` - CFLAGS = $(CXXFLAGS) -endif - -ifeq ($(UNAME_S), Darwin) #APPLE - ECHO_MESSAGE = "Mac OS X" - LIBS += -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo `sdl2-config --libs` - LIBS += -L/usr/local/lib -L/opt/local/lib - - CXXFLAGS += `sdl2-config --cflags` - CXXFLAGS += -I/usr/local/include -I/opt/local/include - CFLAGS = $(CXXFLAGS) -endif - -ifeq ($(OS), Windows_NT) - ECHO_MESSAGE = "MinGW" - LIBS += -lgdi32 -lopengl32 -limm32 `pkg-config --static --libs sdl2` - - CXXFLAGS += `pkg-config --cflags sdl2` - CFLAGS = $(CXXFLAGS) -endif - -##--------------------------------------------------------------------- -## BUILD RULES -##--------------------------------------------------------------------- - -%.o:%.cpp - $(CXX) $(CXXFLAGS) -c -o $@ $< - -%.o:$(IMGUI_DIR)/%.cpp - $(CXX) $(CXXFLAGS) -c -o $@ $< - -%.o:$(IMGUI_DIR)/backends/%.cpp - $(CXX) $(CXXFLAGS) -c -o $@ $< - -all: $(EXE) - @echo Build complete for $(ECHO_MESSAGE) - -$(EXE): $(OBJS) - $(CXX) -o $@ $^ $(CXXFLAGS) $(LIBS) - -clean: - rm -f $(EXE) $(OBJS) diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_sdlrenderer/README.md b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_sdlrenderer/README.md deleted file mode 100644 index 209f15a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_sdlrenderer/README.md +++ /dev/null @@ -1,25 +0,0 @@ - -# How to Build - -- On Windows with Visual Studio's CLI - -``` -set SDL2_DIR=path_to_your_sdl2_folder -cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl.cpp ..\..\backends\imgui_impl_sdlrenderer.cpp ..\..\imgui*.cpp /FeDebug/example_sdl_sdlrenderer.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib /subsystem:console -# ^^ include paths ^^ source files ^^ output exe ^^ output dir ^^ libraries -# or for 64-bit: -cl /Zi /MD /I.. /I..\.. /I%SDL2_DIR%\include main.cpp ..\..\backends\imgui_impl_sdl.cpp ..\..\backends\imgui_impl_sdlrenderer.cpp ..\..\imgui*.cpp /FeDebug/example_sdl_sdlrenderer.exe /FoDebug/ /link /libpath:%SDL2_DIR%\lib\x64 SDL2.lib SDL2main.lib /subsystem:console -``` - -- On Linux and similar Unixes - -``` -c++ `sdl2-config --cflags` -I .. -I ../.. main.cpp ../../backends/imgui_impl_sdl.cpp ../../backends/imgui_impl_sdlrenderer.cpp ../../imgui*.cpp `sdl2-config --libs` -lGL -``` - -- On Mac OS X - -``` -brew install sdl2 -c++ `sdl2-config --cflags` -I .. -I ../.. main.cpp ../../backends/imgui_impl_sdl.cpp ../../backends/imgui_impl_sdlrenderer.cpp ../../imgui*.cpp `sdl2-config --libs` -framework OpenGl -``` diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_sdlrenderer/build_win32.bat b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_sdlrenderer/build_win32.bat deleted file mode 100644 index 6c1b5fd..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_sdlrenderer/build_win32.bat +++ /dev/null @@ -1,8 +0,0 @@ -@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. -@set OUT_DIR=Debug -@set OUT_EXE=example_sdl_sdlrenderer_ -@set INCLUDES=/I..\.. /I..\..\backends /I%SDL2_DIR%\include -@set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl.cpp ..\..\backends\imgui_impl_sdlrenderer.cpp ..\..\imgui*.cpp -@set LIBS=/LIBPATH:%SDL2_DIR%\lib\x86 SDL2.lib SDL2main.lib -mkdir %OUT_DIR% -cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_sdlrenderer/example_sdl_sdlrenderer.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_sdlrenderer/example_sdl_sdlrenderer.vcxproj deleted file mode 100644 index 4d502ab..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_sdlrenderer/example_sdl_sdlrenderer.vcxproj +++ /dev/null @@ -1,181 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {2AE17FDE-F7F3-4CAC-ADAB-0710EDA4F741} - example_sdl_sdlrenderer - 8.1 - - - - Application - true - MultiByte - v140 - - - Application - true - MultiByte - v140 - - - Application - false - true - MultiByte - v140 - - - Application - false - true - MultiByte - v140 - - - - - - - - - - - - - - - - - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - - Level4 - Disabled - ..\..;..\..\backends;%SDL2_DIR%\include;%(AdditionalIncludeDirectories) - - - true - %SDL2_DIR%\lib\x86;%(AdditionalLibraryDirectories) - SDL2.lib;SDL2main.lib;%(AdditionalDependencies) - Console - msvcrt.lib - - - - - Level4 - Disabled - ..\..;..\..\backends;%SDL2_DIR%\include;%(AdditionalIncludeDirectories) - - - true - %SDL2_DIR%\lib\x64;%(AdditionalLibraryDirectories) - SDL2.lib;SDL2main.lib;%(AdditionalDependencies) - Console - msvcrt.lib - - - - - Level4 - MaxSpeed - true - true - ..\..;..\..\backends;%SDL2_DIR%\include;%(AdditionalIncludeDirectories) - false - - - true - true - true - %SDL2_DIR%\lib\x86;%(AdditionalLibraryDirectories) - SDL2.lib;SDL2main.lib;%(AdditionalDependencies) - Console - - - - - - - Level4 - MaxSpeed - true - true - ..\..;..\..\backends;%SDL2_DIR%\include;%(AdditionalIncludeDirectories) - false - - - true - true - true - %SDL2_DIR%\lib\x64;%(AdditionalLibraryDirectories) - SDL2.lib;SDL2main.lib;%(AdditionalDependencies) - Console - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_sdlrenderer/example_sdl_sdlrenderer.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_sdlrenderer/example_sdl_sdlrenderer.vcxproj.filters deleted file mode 100644 index 01e98fc..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_sdlrenderer/example_sdl_sdlrenderer.vcxproj.filters +++ /dev/null @@ -1,61 +0,0 @@ - - - - - {20b90ce4-7fcb-4731-b9a0-075f875de82d} - - - {f18ab499-84e1-499f-8eff-9754361e0e52} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - imgui - - - imgui - - - imgui - - - sources - - - imgui - - - imgui - - - sources - - - sources - - - - - imgui - - - imgui - - - imgui - - - sources - - - sources - - - - - - sources - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_sdlrenderer/main.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_sdlrenderer/main.cpp deleted file mode 100644 index aee4a78..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_sdlrenderer/main.cpp +++ /dev/null @@ -1,161 +0,0 @@ -// Dear ImGui: standalone example application for SDL2 + SDL_Renderer -// (SDL is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan/Metal graphics context creation, etc.) -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -// Important to understand: SDL_Renderer is an _optional_ component of SDL. We do not recommend you use SDL_Renderer -// because it provide a rather limited API to the end-user. We provide this backend for the sake of completeness. -// For a multi-platform app consider using e.g. SDL+DirectX on Windows and SDL+OpenGL on Linux/OSX. - -#include "imgui.h" -#include "imgui_impl_sdl.h" -#include "imgui_impl_sdlrenderer.h" -#include -#include - -#if !SDL_VERSION_ATLEAST(2,0,17) -#error This backend requires SDL 2.0.17+ because of SDL_RenderGeometry() function -#endif - -// Main code -int main(int, char**) -{ - // Setup SDL - // (Some versions of SDL before <2.0.10 appears to have performance/stalling issues on a minority of Windows systems, - // depending on whether SDL_INIT_GAMECONTROLLER is enabled or disabled.. updating to latest version of SDL is recommended!) - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) != 0) - { - printf("Error: %s\n", SDL_GetError()); - return -1; - } - - // Setup window - SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); - SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+SDL_Renderer example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags); - - // Setup SDL_Renderer instance - SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED); - if (renderer == NULL) - { - SDL_Log("Error creating SDL_Renderer!"); - return false; - } - //SDL_RendererInfo info; - //SDL_GetRendererInfo(renderer, &info); - //SDL_Log("Current SDL_Renderer: %s", info.name); - - // Setup Dear ImGui context - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); (void)io; - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls - - // Setup Dear ImGui style - ImGui::StyleColorsDark(); - //ImGui::StyleColorsClassic(); - - // Setup Platform/Renderer backends - ImGui_ImplSDL2_InitForSDLRenderer(window); - ImGui_ImplSDLRenderer_Init(renderer); - - // Load Fonts - // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. - // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. - // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). - // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call. - // - Read 'docs/FONTS.md' for more instructions and details. - // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! - //io.Fonts->AddFontDefault(); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f); - //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - //IM_ASSERT(font != NULL); - - // Our state - bool show_demo_window = true; - bool show_another_window = false; - ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); - - // Main loop - bool done = false; - while (!done) - { - // Poll and handle events (inputs, window resize, etc.) - // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. - // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. - // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. - // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. - SDL_Event event; - while (SDL_PollEvent(&event)) - { - ImGui_ImplSDL2_ProcessEvent(&event); - if (event.type == SDL_QUIT) - done = true; - if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE && event.window.windowID == SDL_GetWindowID(window)) - done = true; - } - - // Start the Dear ImGui frame - ImGui_ImplSDLRenderer_NewFrame(); - ImGui_ImplSDL2_NewFrame(window); - ImGui::NewFrame(); - - // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). - if (show_demo_window) - ImGui::ShowDemoWindow(&show_demo_window); - - // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window. - { - static float f = 0.0f; - static int counter = 0; - - ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. - - ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) - ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state - ImGui::Checkbox("Another Window", &show_another_window); - - ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f - ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color - - if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) - counter++; - ImGui::SameLine(); - ImGui::Text("counter = %d", counter); - - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); - ImGui::End(); - } - - // 3. Show another simple window. - if (show_another_window) - { - ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked) - ImGui::Text("Hello from another window!"); - if (ImGui::Button("Close Me")) - show_another_window = false; - ImGui::End(); - } - - // Rendering - ImGui::Render(); - SDL_SetRenderDrawColor(renderer, (Uint8)(clear_color.x * 255), (Uint8)(clear_color.y * 255), (Uint8)(clear_color.z * 255), (Uint8)(clear_color.w * 255)); - SDL_RenderClear(renderer); - ImGui_ImplSDLRenderer_RenderDrawData(ImGui::GetDrawData()); - SDL_RenderPresent(renderer); - } - - // Cleanup - ImGui_ImplSDLRenderer_Shutdown(); - ImGui_ImplSDL2_Shutdown(); - ImGui::DestroyContext(); - - SDL_DestroyRenderer(renderer); - SDL_DestroyWindow(window); - SDL_Quit(); - - return 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_vulkan/build_win32.bat b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_vulkan/build_win32.bat deleted file mode 100644 index 21b5ea3..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_vulkan/build_win32.bat +++ /dev/null @@ -1,10 +0,0 @@ -@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. - -@set OUT_EXE=example_sdl_vulkan -@set INCLUDES=/I..\.. /I..\..\backends /I%SDL2_DIR%\include /I %VULKAN_SDK%\include -@set SOURCES=main.cpp ..\..\backends\imgui_impl_sdl.cpp ..\..\backends\imgui_impl_vulkan.cpp ..\..\imgui*.cpp -@set LIBS=/LIBPATH:%SDL2_DIR%\lib\x86 /libpath:%VULKAN_SDK%\lib32 SDL2.lib SDL2main.lib shell32.lib vulkan-1.lib - -@set OUT_DIR=Debug -mkdir %OUT_DIR% -cl /nologo /Zi /MD %INCLUDES% %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% /subsystem:console diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj deleted file mode 100644 index 5cc3eab..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj +++ /dev/null @@ -1,181 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {BAE3D0B5-9695-4EB1-AD0F-75890EB4A3B3} - example_sdl_vulkan - 8.1 - - - - Application - true - MultiByte - v140 - - - Application - true - MultiByte - v140 - - - Application - false - true - MultiByte - v140 - - - Application - false - true - MultiByte - v140 - - - - - - - - - - - - - - - - - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - $(IncludePath) - - - - Level4 - Disabled - ..\..;..\..\backends;%VULKAN_SDK%\include;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories) - - - true - %VULKAN_SDK%\lib32;%SDL2_DIR%\lib\x86;%(AdditionalLibraryDirectories) - vulkan-1.lib;SDL2.lib;SDL2main.lib;%(AdditionalDependencies) - Console - msvcrt.lib - - - - - Level4 - Disabled - ..\..;..\..\backends;%VULKAN_SDK%\include;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories) - - - true - %VULKAN_SDK%\lib;%SDL2_DIR%\lib\x64;%(AdditionalLibraryDirectories) - vulkan-1.lib;SDL2.lib;SDL2main.lib;%(AdditionalDependencies) - Console - msvcrt.lib - - - - - Level4 - MaxSpeed - true - true - ..\..;..\..\backends;%VULKAN_SDK%\include;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories) - false - - - true - true - true - %VULKAN_SDK%\lib32;%SDL2_DIR%\lib\x86;%(AdditionalLibraryDirectories) - vulkan-1.lib;SDL2.lib;SDL2main.lib;%(AdditionalDependencies) - Console - - - - - - - Level4 - MaxSpeed - true - true - ..\..;..\..\backends;%VULKAN_SDK%\include;%SDL2_DIR%\include;$(VcpkgCurrentInstalledDir)include\SDL2;%(AdditionalIncludeDirectories) - false - - - true - true - true - %VULKAN_SDK%\lib;%SDL2_DIR%\lib\x64;%(AdditionalLibraryDirectories) - vulkan-1.lib;SDL2.lib;SDL2main.lib;%(AdditionalDependencies) - Console - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj.filters deleted file mode 100644 index 063a593..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_vulkan/example_sdl_vulkan.vcxproj.filters +++ /dev/null @@ -1,61 +0,0 @@ - - - - - {20b90ce4-7fcb-4731-b9a0-075f875de82d} - - - {f18ab499-84e1-499f-8eff-9754361e0e52} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - imgui - - - imgui - - - imgui - - - sources - - - sources - - - sources - - - imgui - - - sources - - - - - imgui - - - imgui - - - imgui - - - sources - - - sources - - - - - - sources - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_vulkan/main.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_vulkan/main.cpp deleted file mode 100644 index 2c01afe..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_sdl_vulkan/main.cpp +++ /dev/null @@ -1,559 +0,0 @@ -// Dear ImGui: standalone example application for SDL2 + Vulkan -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -// Important note to the reader who wish to integrate imgui_impl_vulkan.cpp/.h in their own engine/app. -// - Common ImGui_ImplVulkan_XXX functions and structures are used to interface with imgui_impl_vulkan.cpp/.h. -// You will use those if you want to use this rendering backend in your engine/app. -// - Helper ImGui_ImplVulkanH_XXX functions and structures are only used by this example (main.cpp) and by -// the backend itself (imgui_impl_vulkan.cpp), but should PROBABLY NOT be used by your own engine/app code. -// Read comments in imgui_impl_vulkan.h. - -#include "imgui.h" -#include "imgui_impl_sdl.h" -#include "imgui_impl_vulkan.h" -#include // printf, fprintf -#include // abort -#include -#include -#include - -//#define IMGUI_UNLIMITED_FRAME_RATE -#ifdef _DEBUG -#define IMGUI_VULKAN_DEBUG_REPORT -#endif - -static VkAllocationCallbacks* g_Allocator = NULL; -static VkInstance g_Instance = VK_NULL_HANDLE; -static VkPhysicalDevice g_PhysicalDevice = VK_NULL_HANDLE; -static VkDevice g_Device = VK_NULL_HANDLE; -static uint32_t g_QueueFamily = (uint32_t)-1; -static VkQueue g_Queue = VK_NULL_HANDLE; -static VkDebugReportCallbackEXT g_DebugReport = VK_NULL_HANDLE; -static VkPipelineCache g_PipelineCache = VK_NULL_HANDLE; -static VkDescriptorPool g_DescriptorPool = VK_NULL_HANDLE; - -static ImGui_ImplVulkanH_Window g_MainWindowData; -static uint32_t g_MinImageCount = 2; -static bool g_SwapChainRebuild = false; - -static void check_vk_result(VkResult err) -{ - if (err == 0) - return; - fprintf(stderr, "[vulkan] Error: VkResult = %d\n", err); - if (err < 0) - abort(); -} - -#ifdef IMGUI_VULKAN_DEBUG_REPORT -static VKAPI_ATTR VkBool32 VKAPI_CALL debug_report(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage, void* pUserData) -{ - (void)flags; (void)object; (void)location; (void)messageCode; (void)pUserData; (void)pLayerPrefix; // Unused arguments - fprintf(stderr, "[vulkan] Debug report from ObjectType: %i\nMessage: %s\n\n", objectType, pMessage); - return VK_FALSE; -} -#endif // IMGUI_VULKAN_DEBUG_REPORT - -static void SetupVulkan(const char** extensions, uint32_t extensions_count) -{ - VkResult err; - - // Create Vulkan Instance - { - VkInstanceCreateInfo create_info = {}; - create_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; - create_info.enabledExtensionCount = extensions_count; - create_info.ppEnabledExtensionNames = extensions; -#ifdef IMGUI_VULKAN_DEBUG_REPORT - // Enabling validation layers - const char* layers[] = { "VK_LAYER_KHRONOS_validation" }; - create_info.enabledLayerCount = 1; - create_info.ppEnabledLayerNames = layers; - - // Enable debug report extension (we need additional storage, so we duplicate the user array to add our new extension to it) - const char** extensions_ext = (const char**)malloc(sizeof(const char*) * (extensions_count + 1)); - memcpy(extensions_ext, extensions, extensions_count * sizeof(const char*)); - extensions_ext[extensions_count] = "VK_EXT_debug_report"; - create_info.enabledExtensionCount = extensions_count + 1; - create_info.ppEnabledExtensionNames = extensions_ext; - - // Create Vulkan Instance - err = vkCreateInstance(&create_info, g_Allocator, &g_Instance); - check_vk_result(err); - free(extensions_ext); - - // Get the function pointer (required for any extensions) - auto vkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkCreateDebugReportCallbackEXT"); - IM_ASSERT(vkCreateDebugReportCallbackEXT != NULL); - - // Setup the debug report callback - VkDebugReportCallbackCreateInfoEXT debug_report_ci = {}; - debug_report_ci.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT; - debug_report_ci.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT; - debug_report_ci.pfnCallback = debug_report; - debug_report_ci.pUserData = NULL; - err = vkCreateDebugReportCallbackEXT(g_Instance, &debug_report_ci, g_Allocator, &g_DebugReport); - check_vk_result(err); -#else - // Create Vulkan Instance without any debug feature - err = vkCreateInstance(&create_info, g_Allocator, &g_Instance); - check_vk_result(err); - IM_UNUSED(g_DebugReport); -#endif - } - - // Select GPU - { - uint32_t gpu_count; - err = vkEnumeratePhysicalDevices(g_Instance, &gpu_count, NULL); - check_vk_result(err); - IM_ASSERT(gpu_count > 0); - - VkPhysicalDevice* gpus = (VkPhysicalDevice*)malloc(sizeof(VkPhysicalDevice) * gpu_count); - err = vkEnumeratePhysicalDevices(g_Instance, &gpu_count, gpus); - check_vk_result(err); - - // If a number >1 of GPUs got reported, find discrete GPU if present, or use first one available. This covers - // most common cases (multi-gpu/integrated+dedicated graphics). Handling more complicated setups (multiple - // dedicated GPUs) is out of scope of this sample. - int use_gpu = 0; - for (int i = 0; i < (int)gpu_count; i++) - { - VkPhysicalDeviceProperties properties; - vkGetPhysicalDeviceProperties(gpus[i], &properties); - if (properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) - { - use_gpu = i; - break; - } - } - - g_PhysicalDevice = gpus[use_gpu]; - free(gpus); - } - - // Select graphics queue family - { - uint32_t count; - vkGetPhysicalDeviceQueueFamilyProperties(g_PhysicalDevice, &count, NULL); - VkQueueFamilyProperties* queues = (VkQueueFamilyProperties*)malloc(sizeof(VkQueueFamilyProperties) * count); - vkGetPhysicalDeviceQueueFamilyProperties(g_PhysicalDevice, &count, queues); - for (uint32_t i = 0; i < count; i++) - if (queues[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) - { - g_QueueFamily = i; - break; - } - free(queues); - IM_ASSERT(g_QueueFamily != (uint32_t)-1); - } - - // Create Logical Device (with 1 queue) - { - int device_extension_count = 1; - const char* device_extensions[] = { "VK_KHR_swapchain" }; - const float queue_priority[] = { 1.0f }; - VkDeviceQueueCreateInfo queue_info[1] = {}; - queue_info[0].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; - queue_info[0].queueFamilyIndex = g_QueueFamily; - queue_info[0].queueCount = 1; - queue_info[0].pQueuePriorities = queue_priority; - VkDeviceCreateInfo create_info = {}; - create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; - create_info.queueCreateInfoCount = sizeof(queue_info) / sizeof(queue_info[0]); - create_info.pQueueCreateInfos = queue_info; - create_info.enabledExtensionCount = device_extension_count; - create_info.ppEnabledExtensionNames = device_extensions; - err = vkCreateDevice(g_PhysicalDevice, &create_info, g_Allocator, &g_Device); - check_vk_result(err); - vkGetDeviceQueue(g_Device, g_QueueFamily, 0, &g_Queue); - } - - // Create Descriptor Pool - { - VkDescriptorPoolSize pool_sizes[] = - { - { VK_DESCRIPTOR_TYPE_SAMPLER, 1000 }, - { VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1000 }, - { VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 1000 }, - { VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 1000 }, - { VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, 1000 }, - { VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER, 1000 }, - { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1000 }, - { VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1000 }, - { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1000 }, - { VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, 1000 }, - { VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1000 } - }; - VkDescriptorPoolCreateInfo pool_info = {}; - pool_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; - pool_info.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT; - pool_info.maxSets = 1000 * IM_ARRAYSIZE(pool_sizes); - pool_info.poolSizeCount = (uint32_t)IM_ARRAYSIZE(pool_sizes); - pool_info.pPoolSizes = pool_sizes; - err = vkCreateDescriptorPool(g_Device, &pool_info, g_Allocator, &g_DescriptorPool); - check_vk_result(err); - } -} - -// All the ImGui_ImplVulkanH_XXX structures/functions are optional helpers used by the demo. -// Your real engine/app may not use them. -static void SetupVulkanWindow(ImGui_ImplVulkanH_Window* wd, VkSurfaceKHR surface, int width, int height) -{ - wd->Surface = surface; - - // Check for WSI support - VkBool32 res; - vkGetPhysicalDeviceSurfaceSupportKHR(g_PhysicalDevice, g_QueueFamily, wd->Surface, &res); - if (res != VK_TRUE) - { - fprintf(stderr, "Error no WSI support on physical device 0\n"); - exit(-1); - } - - // Select Surface Format - const VkFormat requestSurfaceImageFormat[] = { VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_B8G8R8_UNORM, VK_FORMAT_R8G8B8_UNORM }; - const VkColorSpaceKHR requestSurfaceColorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR; - wd->SurfaceFormat = ImGui_ImplVulkanH_SelectSurfaceFormat(g_PhysicalDevice, wd->Surface, requestSurfaceImageFormat, (size_t)IM_ARRAYSIZE(requestSurfaceImageFormat), requestSurfaceColorSpace); - - // Select Present Mode -#ifdef IMGUI_UNLIMITED_FRAME_RATE - VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_MAILBOX_KHR, VK_PRESENT_MODE_IMMEDIATE_KHR, VK_PRESENT_MODE_FIFO_KHR }; -#else - VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_FIFO_KHR }; -#endif - wd->PresentMode = ImGui_ImplVulkanH_SelectPresentMode(g_PhysicalDevice, wd->Surface, &present_modes[0], IM_ARRAYSIZE(present_modes)); - //printf("[vulkan] Selected PresentMode = %d\n", wd->PresentMode); - - // Create SwapChain, RenderPass, Framebuffer, etc. - IM_ASSERT(g_MinImageCount >= 2); - ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, wd, g_QueueFamily, g_Allocator, width, height, g_MinImageCount); -} - -static void CleanupVulkan() -{ - vkDestroyDescriptorPool(g_Device, g_DescriptorPool, g_Allocator); - -#ifdef IMGUI_VULKAN_DEBUG_REPORT - // Remove the debug report callback - auto vkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkDestroyDebugReportCallbackEXT"); - vkDestroyDebugReportCallbackEXT(g_Instance, g_DebugReport, g_Allocator); -#endif // IMGUI_VULKAN_DEBUG_REPORT - - vkDestroyDevice(g_Device, g_Allocator); - vkDestroyInstance(g_Instance, g_Allocator); -} - -static void CleanupVulkanWindow() -{ - ImGui_ImplVulkanH_DestroyWindow(g_Instance, g_Device, &g_MainWindowData, g_Allocator); -} - -static void FrameRender(ImGui_ImplVulkanH_Window* wd, ImDrawData* draw_data) -{ - VkResult err; - - VkSemaphore image_acquired_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].ImageAcquiredSemaphore; - VkSemaphore render_complete_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].RenderCompleteSemaphore; - err = vkAcquireNextImageKHR(g_Device, wd->Swapchain, UINT64_MAX, image_acquired_semaphore, VK_NULL_HANDLE, &wd->FrameIndex); - if (err == VK_ERROR_OUT_OF_DATE_KHR || err == VK_SUBOPTIMAL_KHR) - { - g_SwapChainRebuild = true; - return; - } - check_vk_result(err); - - ImGui_ImplVulkanH_Frame* fd = &wd->Frames[wd->FrameIndex]; - { - err = vkWaitForFences(g_Device, 1, &fd->Fence, VK_TRUE, UINT64_MAX); // wait indefinitely instead of periodically checking - check_vk_result(err); - - err = vkResetFences(g_Device, 1, &fd->Fence); - check_vk_result(err); - } - { - err = vkResetCommandPool(g_Device, fd->CommandPool, 0); - check_vk_result(err); - VkCommandBufferBeginInfo info = {}; - info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; - info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; - err = vkBeginCommandBuffer(fd->CommandBuffer, &info); - check_vk_result(err); - } - { - VkRenderPassBeginInfo info = {}; - info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; - info.renderPass = wd->RenderPass; - info.framebuffer = fd->Framebuffer; - info.renderArea.extent.width = wd->Width; - info.renderArea.extent.height = wd->Height; - info.clearValueCount = 1; - info.pClearValues = &wd->ClearValue; - vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE); - } - - // Record dear imgui primitives into command buffer - ImGui_ImplVulkan_RenderDrawData(draw_data, fd->CommandBuffer); - - // Submit command buffer - vkCmdEndRenderPass(fd->CommandBuffer); - { - VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; - VkSubmitInfo info = {}; - info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; - info.waitSemaphoreCount = 1; - info.pWaitSemaphores = &image_acquired_semaphore; - info.pWaitDstStageMask = &wait_stage; - info.commandBufferCount = 1; - info.pCommandBuffers = &fd->CommandBuffer; - info.signalSemaphoreCount = 1; - info.pSignalSemaphores = &render_complete_semaphore; - - err = vkEndCommandBuffer(fd->CommandBuffer); - check_vk_result(err); - err = vkQueueSubmit(g_Queue, 1, &info, fd->Fence); - check_vk_result(err); - } -} - -static void FramePresent(ImGui_ImplVulkanH_Window* wd) -{ - if (g_SwapChainRebuild) - return; - VkSemaphore render_complete_semaphore = wd->FrameSemaphores[wd->SemaphoreIndex].RenderCompleteSemaphore; - VkPresentInfoKHR info = {}; - info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; - info.waitSemaphoreCount = 1; - info.pWaitSemaphores = &render_complete_semaphore; - info.swapchainCount = 1; - info.pSwapchains = &wd->Swapchain; - info.pImageIndices = &wd->FrameIndex; - VkResult err = vkQueuePresentKHR(g_Queue, &info); - if (err == VK_ERROR_OUT_OF_DATE_KHR || err == VK_SUBOPTIMAL_KHR) - { - g_SwapChainRebuild = true; - return; - } - check_vk_result(err); - wd->SemaphoreIndex = (wd->SemaphoreIndex + 1) % wd->ImageCount; // Now we can use the next set of semaphores -} - -int main(int, char**) -{ - // Setup SDL - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) != 0) - { - printf("Error: %s\n", SDL_GetError()); - return -1; - } - - // Setup window - SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); - SDL_Window* window = SDL_CreateWindow("Dear ImGui SDL2+Vulkan example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, window_flags); - - // Setup Vulkan - uint32_t extensions_count = 0; - SDL_Vulkan_GetInstanceExtensions(window, &extensions_count, NULL); - const char** extensions = new const char*[extensions_count]; - SDL_Vulkan_GetInstanceExtensions(window, &extensions_count, extensions); - SetupVulkan(extensions, extensions_count); - delete[] extensions; - - // Create Window Surface - VkSurfaceKHR surface; - VkResult err; - if (SDL_Vulkan_CreateSurface(window, g_Instance, &surface) == 0) - { - printf("Failed to create Vulkan surface.\n"); - return 1; - } - - // Create Framebuffers - int w, h; - SDL_GetWindowSize(window, &w, &h); - ImGui_ImplVulkanH_Window* wd = &g_MainWindowData; - SetupVulkanWindow(wd, surface, w, h); - - // Setup Dear ImGui context - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); (void)io; - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls - - // Setup Dear ImGui style - ImGui::StyleColorsDark(); - //ImGui::StyleColorsClassic(); - - // Setup Platform/Renderer backends - ImGui_ImplSDL2_InitForVulkan(window); - ImGui_ImplVulkan_InitInfo init_info = {}; - init_info.Instance = g_Instance; - init_info.PhysicalDevice = g_PhysicalDevice; - init_info.Device = g_Device; - init_info.QueueFamily = g_QueueFamily; - init_info.Queue = g_Queue; - init_info.PipelineCache = g_PipelineCache; - init_info.DescriptorPool = g_DescriptorPool; - init_info.Allocator = g_Allocator; - init_info.MinImageCount = g_MinImageCount; - init_info.ImageCount = wd->ImageCount; - init_info.CheckVkResultFn = check_vk_result; - ImGui_ImplVulkan_Init(&init_info, wd->RenderPass); - - // Load Fonts - // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. - // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. - // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). - // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call. - // - Read 'docs/FONTS.md' for more instructions and details. - // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! - //io.Fonts->AddFontDefault(); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f); - //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - //IM_ASSERT(font != NULL); - - // Upload Fonts - { - // Use any command queue - VkCommandPool command_pool = wd->Frames[wd->FrameIndex].CommandPool; - VkCommandBuffer command_buffer = wd->Frames[wd->FrameIndex].CommandBuffer; - - err = vkResetCommandPool(g_Device, command_pool, 0); - check_vk_result(err); - VkCommandBufferBeginInfo begin_info = {}; - begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; - begin_info.flags |= VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; - err = vkBeginCommandBuffer(command_buffer, &begin_info); - check_vk_result(err); - - ImGui_ImplVulkan_CreateFontsTexture(command_buffer); - - VkSubmitInfo end_info = {}; - end_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; - end_info.commandBufferCount = 1; - end_info.pCommandBuffers = &command_buffer; - err = vkEndCommandBuffer(command_buffer); - check_vk_result(err); - err = vkQueueSubmit(g_Queue, 1, &end_info, VK_NULL_HANDLE); - check_vk_result(err); - - err = vkDeviceWaitIdle(g_Device); - check_vk_result(err); - ImGui_ImplVulkan_DestroyFontUploadObjects(); - } - - // Our state - bool show_demo_window = true; - bool show_another_window = false; - ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); - - // Main loop - bool done = false; - while (!done) - { - // Poll and handle events (inputs, window resize, etc.) - // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. - // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. - // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. - // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. - SDL_Event event; - while (SDL_PollEvent(&event)) - { - ImGui_ImplSDL2_ProcessEvent(&event); - if (event.type == SDL_QUIT) - done = true; - if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE && event.window.windowID == SDL_GetWindowID(window)) - done = true; - } - - // Resize swap chain? - if (g_SwapChainRebuild) - { - int width, height; - SDL_GetWindowSize(window, &width, &height); - if (width > 0 && height > 0) - { - ImGui_ImplVulkan_SetMinImageCount(g_MinImageCount); - ImGui_ImplVulkanH_CreateOrResizeWindow(g_Instance, g_PhysicalDevice, g_Device, &g_MainWindowData, g_QueueFamily, g_Allocator, width, height, g_MinImageCount); - g_MainWindowData.FrameIndex = 0; - g_SwapChainRebuild = false; - } - } - - // Start the Dear ImGui frame - ImGui_ImplVulkan_NewFrame(); - ImGui_ImplSDL2_NewFrame(); - ImGui::NewFrame(); - - // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). - if (show_demo_window) - ImGui::ShowDemoWindow(&show_demo_window); - - // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window. - { - static float f = 0.0f; - static int counter = 0; - - ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. - - ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) - ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state - ImGui::Checkbox("Another Window", &show_another_window); - - ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f - ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color - - if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) - counter++; - ImGui::SameLine(); - ImGui::Text("counter = %d", counter); - - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); - ImGui::End(); - } - - // 3. Show another simple window. - if (show_another_window) - { - ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked) - ImGui::Text("Hello from another window!"); - if (ImGui::Button("Close Me")) - show_another_window = false; - ImGui::End(); - } - - // Rendering - ImGui::Render(); - ImDrawData* draw_data = ImGui::GetDrawData(); - const bool is_minimized = (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f); - if (!is_minimized) - { - wd->ClearValue.color.float32[0] = clear_color.x * clear_color.w; - wd->ClearValue.color.float32[1] = clear_color.y * clear_color.w; - wd->ClearValue.color.float32[2] = clear_color.z * clear_color.w; - wd->ClearValue.color.float32[3] = clear_color.w; - FrameRender(wd, draw_data); - FramePresent(wd); - } - } - - // Cleanup - err = vkDeviceWaitIdle(g_Device); - check_vk_result(err); - ImGui_ImplVulkan_Shutdown(); - ImGui_ImplSDL2_Shutdown(); - ImGui::DestroyContext(); - - CleanupVulkanWindow(); - CleanupVulkan(); - - SDL_DestroyWindow(window); - SDL_Quit(); - - return 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx10/build_win32.bat b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx10/build_win32.bat deleted file mode 100644 index fd74223..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx10/build_win32.bat +++ /dev/null @@ -1,8 +0,0 @@ -@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. -@set OUT_DIR=Debug -@set OUT_EXE=example_win32_directx10 -@set INCLUDES=/I..\.. /I..\..\backends /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /I "%DXSDK_DIR%Include" -@set SOURCES=main.cpp ..\..\backends\imgui_impl_win32.cpp ..\..\backends\imgui_impl_dx10.cpp ..\..\imgui*.cpp -@set LIBS=/LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d10.lib d3dcompiler.lib -mkdir %OUT_DIR% -cl /nologo /Zi /MD %INCLUDES% /D UNICODE /D _UNICODE %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx10/example_win32_directx10.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx10/example_win32_directx10.vcxproj deleted file mode 100644 index e71cb0a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx10/example_win32_directx10.vcxproj +++ /dev/null @@ -1,171 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {345A953E-A004-4648-B442-DC5F9F11068C} - example_win32_directx10 - 8.1 - - - - Application - true - Unicode - v140 - - - Application - true - Unicode - v140 - - - Application - false - true - Unicode - v140 - - - Application - false - true - Unicode - v140 - - - - - - - - - - - - - - - - - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - - - - Level4 - Disabled - ..\..;..\..\backends;%(AdditionalIncludeDirectories); - - - true - d3d10.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies) - $(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories) - Console - - - - - Level4 - Disabled - ..\..;..\..\backends;%(AdditionalIncludeDirectories); - - - true - d3d10.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies) - $(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories) - Console - - - - - Level4 - MaxSpeed - true - true - ..\..;..\..\backends;%(AdditionalIncludeDirectories); - false - - - true - true - true - d3d10.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies) - $(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories) - Console - - - - - Level4 - MaxSpeed - true - true - ..\..;..\..\backends;%(AdditionalIncludeDirectories); - false - - - true - true - true - d3d10.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies) - $(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories) - Console - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx10/example_win32_directx10.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx10/example_win32_directx10.vcxproj.filters deleted file mode 100644 index 11ad8f9..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx10/example_win32_directx10.vcxproj.filters +++ /dev/null @@ -1,60 +0,0 @@ - - - - - {0587d7a3-f2ce-4d56-b84f-a0005d3bfce6} - - - {08e36723-ce4f-4cff-9662-c40801cf1acf} - - - - - imgui - - - imgui - - - imgui - - - sources - - - sources - - - - - imgui - - - sources - - - imgui - - - imgui - - - sources - - - sources - - - imgui - - - imgui - - - - - - sources - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx10/main.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx10/main.cpp deleted file mode 100644 index ad88d1e..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx10/main.cpp +++ /dev/null @@ -1,242 +0,0 @@ -// Dear ImGui: standalone example application for DirectX 10 -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -#include "imgui.h" -#include "imgui_impl_win32.h" -#include "imgui_impl_dx10.h" -#include -#include -#include - -// Data -static ID3D10Device* g_pd3dDevice = NULL; -static IDXGISwapChain* g_pSwapChain = NULL; -static ID3D10RenderTargetView* g_mainRenderTargetView = NULL; - -// Forward declarations of helper functions -bool CreateDeviceD3D(HWND hWnd); -void CleanupDeviceD3D(); -void CreateRenderTarget(); -void CleanupRenderTarget(); -LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); - -// Main code -int main(int, char**) -{ - // Create application window - //ImGui_ImplWin32_EnableDpiAwareness(); - WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, _T("ImGui Example"), NULL }; - ::RegisterClassEx(&wc); - HWND hwnd = ::CreateWindow(wc.lpszClassName, _T("Dear ImGui DirectX10 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL); - - // Initialize Direct3D - if (!CreateDeviceD3D(hwnd)) - { - CleanupDeviceD3D(); - ::UnregisterClass(wc.lpszClassName, wc.hInstance); - return 1; - } - - // Show the window - ::ShowWindow(hwnd, SW_SHOWDEFAULT); - ::UpdateWindow(hwnd); - - // Setup Dear ImGui context - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); (void)io; - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls - - // Setup Dear ImGui style - ImGui::StyleColorsDark(); - //ImGui::StyleColorsClassic(); - - // Setup Platform/Renderer backends - ImGui_ImplWin32_Init(hwnd); - ImGui_ImplDX10_Init(g_pd3dDevice); - - // Load Fonts - // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. - // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. - // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). - // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call. - // - Read 'docs/FONTS.md' for more instructions and details. - // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! - //io.Fonts->AddFontDefault(); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f); - //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - //IM_ASSERT(font != NULL); - - // Our state - bool show_demo_window = true; - bool show_another_window = false; - ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); - - // Main loop - bool done = false; - while (!done) - { - // Poll and handle messages (inputs, window resize, etc.) - // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. - // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. - // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. - // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. - MSG msg; - while (::PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) - { - ::TranslateMessage(&msg); - ::DispatchMessage(&msg); - if (msg.message == WM_QUIT) - done = true; - } - if (done) - break; - - // Start the Dear ImGui frame - ImGui_ImplDX10_NewFrame(); - ImGui_ImplWin32_NewFrame(); - ImGui::NewFrame(); - - // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). - if (show_demo_window) - ImGui::ShowDemoWindow(&show_demo_window); - - // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window. - { - static float f = 0.0f; - static int counter = 0; - - ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. - - ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) - ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state - ImGui::Checkbox("Another Window", &show_another_window); - - ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f - ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color - - if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) - counter++; - ImGui::SameLine(); - ImGui::Text("counter = %d", counter); - - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); - ImGui::End(); - } - - // 3. Show another simple window. - if (show_another_window) - { - ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked) - ImGui::Text("Hello from another window!"); - if (ImGui::Button("Close Me")) - show_another_window = false; - ImGui::End(); - } - - // Rendering - ImGui::Render(); - const float clear_color_with_alpha[4] = { clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w }; - g_pd3dDevice->OMSetRenderTargets(1, &g_mainRenderTargetView, NULL); - g_pd3dDevice->ClearRenderTargetView(g_mainRenderTargetView, clear_color_with_alpha); - ImGui_ImplDX10_RenderDrawData(ImGui::GetDrawData()); - - g_pSwapChain->Present(1, 0); // Present with vsync - //g_pSwapChain->Present(0, 0); // Present without vsync - } - - ImGui_ImplDX10_Shutdown(); - ImGui_ImplWin32_Shutdown(); - ImGui::DestroyContext(); - - CleanupDeviceD3D(); - ::DestroyWindow(hwnd); - ::UnregisterClass(wc.lpszClassName, wc.hInstance); - - return 0; -} - -// Helper functions - -bool CreateDeviceD3D(HWND hWnd) -{ - // Setup swap chain - DXGI_SWAP_CHAIN_DESC sd; - ZeroMemory(&sd, sizeof(sd)); - sd.BufferCount = 2; - sd.BufferDesc.Width = 0; - sd.BufferDesc.Height = 0; - sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; - sd.BufferDesc.RefreshRate.Numerator = 60; - sd.BufferDesc.RefreshRate.Denominator = 1; - sd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; - sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; - sd.OutputWindow = hWnd; - sd.SampleDesc.Count = 1; - sd.SampleDesc.Quality = 0; - sd.Windowed = TRUE; - sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; - - UINT createDeviceFlags = 0; - //createDeviceFlags |= D3D10_CREATE_DEVICE_DEBUG; - if (D3D10CreateDeviceAndSwapChain(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, createDeviceFlags, D3D10_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice) != S_OK) - return false; - - CreateRenderTarget(); - return true; -} - -void CleanupDeviceD3D() -{ - CleanupRenderTarget(); - if (g_pSwapChain) { g_pSwapChain->Release(); g_pSwapChain = NULL; } - if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; } -} - -void CreateRenderTarget() -{ - ID3D10Texture2D* pBackBuffer; - g_pSwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer)); - g_pd3dDevice->CreateRenderTargetView(pBackBuffer, NULL, &g_mainRenderTargetView); - pBackBuffer->Release(); -} - -void CleanupRenderTarget() -{ - if (g_mainRenderTargetView) { g_mainRenderTargetView->Release(); g_mainRenderTargetView = NULL; } -} - -// Forward declare message handler from imgui_impl_win32.cpp -extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); - -// Win32 message handler -LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam)) - return true; - - switch (msg) - { - case WM_SIZE: - if (g_pd3dDevice != NULL && wParam != SIZE_MINIMIZED) - { - CleanupRenderTarget(); - g_pSwapChain->ResizeBuffers(0, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam), DXGI_FORMAT_UNKNOWN, 0); - CreateRenderTarget(); - } - return 0; - case WM_SYSCOMMAND: - if ((wParam & 0xfff0) == SC_KEYMENU) // Disable ALT application menu - return 0; - break; - case WM_DESTROY: - ::PostQuitMessage(0); - return 0; - } - return ::DefWindowProc(hWnd, msg, wParam, lParam); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx11/build_win32.bat b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx11/build_win32.bat deleted file mode 100644 index b1cf7d1..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx11/build_win32.bat +++ /dev/null @@ -1,9 +0,0 @@ -@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. -@set OUT_DIR=Debug -@set OUT_EXE=example_win32_directx11 -@set INCLUDES=/I..\.. /I..\..\backends /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /I "%DXSDK_DIR%Include" -@set SOURCES=main.cpp ..\..\backends\imgui_impl_dx11.cpp ..\..\backends\imgui_impl_win32.cpp ..\..\imgui*.cpp -@set LIBS=/LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d11.lib d3dcompiler.lib -mkdir %OUT_DIR% -cl /nologo /Zi /MD %INCLUDES% /D UNICODE /D _UNICODE %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx11/example_win32_directx11.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx11/example_win32_directx11.vcxproj deleted file mode 100644 index 273d351..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx11/example_win32_directx11.vcxproj +++ /dev/null @@ -1,170 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {9F316E83-5AE5-4939-A723-305A94F48005} - example_win32_directx11 - - - - Application - true - Unicode - v140 - - - Application - true - Unicode - v140 - - - Application - false - true - Unicode - v140 - - - Application - false - true - Unicode - v140 - - - - - - - - - - - - - - - - - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - - - - Level4 - Disabled - ..\..;..\..\backends;%(AdditionalIncludeDirectories); - - - true - d3d11.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies) - $(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories) - Console - - - - - Level4 - Disabled - ..\..;..\..\backends;%(AdditionalIncludeDirectories); - - - true - d3d11.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies) - $(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories) - Console - - - - - Level4 - MaxSpeed - true - true - ..\..;..\..\backends;%(AdditionalIncludeDirectories); - false - - - true - true - true - d3d11.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies) - $(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories) - Console - - - - - Level4 - MaxSpeed - true - true - ..\..;..\..\backends;%(AdditionalIncludeDirectories); - false - - - true - true - true - d3d11.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies) - $(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories) - Console - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx11/example_win32_directx11.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx11/example_win32_directx11.vcxproj.filters deleted file mode 100644 index 02cf18c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx11/example_win32_directx11.vcxproj.filters +++ /dev/null @@ -1,60 +0,0 @@ - - - - - {0587d7a3-f2ce-4d56-b84f-a0005d3bfce6} - - - {08e36723-ce4f-4cff-9662-c40801cf1acf} - - - - - imgui - - - imgui - - - imgui - - - sources - - - sources - - - - - imgui - - - sources - - - imgui - - - imgui - - - imgui - - - sources - - - sources - - - imgui - - - - - - sources - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx11/main.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx11/main.cpp deleted file mode 100644 index 7f1b4b8..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx11/main.cpp +++ /dev/null @@ -1,246 +0,0 @@ -// Dear ImGui: standalone example application for DirectX 11 -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -#include "imgui.h" -#include "imgui_impl_win32.h" -#include "imgui_impl_dx11.h" -#include -#include - -// Data -static ID3D11Device* g_pd3dDevice = NULL; -static ID3D11DeviceContext* g_pd3dDeviceContext = NULL; -static IDXGISwapChain* g_pSwapChain = NULL; -static ID3D11RenderTargetView* g_mainRenderTargetView = NULL; - -// Forward declarations of helper functions -bool CreateDeviceD3D(HWND hWnd); -void CleanupDeviceD3D(); -void CreateRenderTarget(); -void CleanupRenderTarget(); -LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); - -// Main code -int main(int, char**) -{ - // Create application window - //ImGui_ImplWin32_EnableDpiAwareness(); - WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, _T("ImGui Example"), NULL }; - ::RegisterClassEx(&wc); - HWND hwnd = ::CreateWindow(wc.lpszClassName, _T("Dear ImGui DirectX11 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL); - - // Initialize Direct3D - if (!CreateDeviceD3D(hwnd)) - { - CleanupDeviceD3D(); - ::UnregisterClass(wc.lpszClassName, wc.hInstance); - return 1; - } - - // Show the window - ::ShowWindow(hwnd, SW_SHOWDEFAULT); - ::UpdateWindow(hwnd); - - // Setup Dear ImGui context - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); (void)io; - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls - - // Setup Dear ImGui style - ImGui::StyleColorsDark(); - //ImGui::StyleColorsClassic(); - - // Setup Platform/Renderer backends - ImGui_ImplWin32_Init(hwnd); - ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext); - - // Load Fonts - // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. - // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. - // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). - // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call. - // - Read 'docs/FONTS.md' for more instructions and details. - // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! - //io.Fonts->AddFontDefault(); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f); - //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - //IM_ASSERT(font != NULL); - - // Our state - bool show_demo_window = true; - bool show_another_window = false; - ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); - - // Main loop - bool done = false; - while (!done) - { - // Poll and handle messages (inputs, window resize, etc.) - // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. - // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. - // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. - // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. - MSG msg; - while (::PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) - { - ::TranslateMessage(&msg); - ::DispatchMessage(&msg); - if (msg.message == WM_QUIT) - done = true; - } - if (done) - break; - - // Start the Dear ImGui frame - ImGui_ImplDX11_NewFrame(); - ImGui_ImplWin32_NewFrame(); - ImGui::NewFrame(); - - // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). - if (show_demo_window) - ImGui::ShowDemoWindow(&show_demo_window); - - // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window. - { - static float f = 0.0f; - static int counter = 0; - - ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. - - ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) - ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state - ImGui::Checkbox("Another Window", &show_another_window); - - ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f - ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color - - if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) - counter++; - ImGui::SameLine(); - ImGui::Text("counter = %d", counter); - - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); - ImGui::End(); - } - - // 3. Show another simple window. - if (show_another_window) - { - ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked) - ImGui::Text("Hello from another window!"); - if (ImGui::Button("Close Me")) - show_another_window = false; - ImGui::End(); - } - - // Rendering - ImGui::Render(); - const float clear_color_with_alpha[4] = { clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w }; - g_pd3dDeviceContext->OMSetRenderTargets(1, &g_mainRenderTargetView, NULL); - g_pd3dDeviceContext->ClearRenderTargetView(g_mainRenderTargetView, clear_color_with_alpha); - ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData()); - - g_pSwapChain->Present(1, 0); // Present with vsync - //g_pSwapChain->Present(0, 0); // Present without vsync - } - - // Cleanup - ImGui_ImplDX11_Shutdown(); - ImGui_ImplWin32_Shutdown(); - ImGui::DestroyContext(); - - CleanupDeviceD3D(); - ::DestroyWindow(hwnd); - ::UnregisterClass(wc.lpszClassName, wc.hInstance); - - return 0; -} - -// Helper functions - -bool CreateDeviceD3D(HWND hWnd) -{ - // Setup swap chain - DXGI_SWAP_CHAIN_DESC sd; - ZeroMemory(&sd, sizeof(sd)); - sd.BufferCount = 2; - sd.BufferDesc.Width = 0; - sd.BufferDesc.Height = 0; - sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; - sd.BufferDesc.RefreshRate.Numerator = 60; - sd.BufferDesc.RefreshRate.Denominator = 1; - sd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; - sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; - sd.OutputWindow = hWnd; - sd.SampleDesc.Count = 1; - sd.SampleDesc.Quality = 0; - sd.Windowed = TRUE; - sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; - - UINT createDeviceFlags = 0; - //createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG; - D3D_FEATURE_LEVEL featureLevel; - const D3D_FEATURE_LEVEL featureLevelArray[2] = { D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_0, }; - if (D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, createDeviceFlags, featureLevelArray, 2, D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &featureLevel, &g_pd3dDeviceContext) != S_OK) - return false; - - CreateRenderTarget(); - return true; -} - -void CleanupDeviceD3D() -{ - CleanupRenderTarget(); - if (g_pSwapChain) { g_pSwapChain->Release(); g_pSwapChain = NULL; } - if (g_pd3dDeviceContext) { g_pd3dDeviceContext->Release(); g_pd3dDeviceContext = NULL; } - if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; } -} - -void CreateRenderTarget() -{ - ID3D11Texture2D* pBackBuffer; - g_pSwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer)); - g_pd3dDevice->CreateRenderTargetView(pBackBuffer, NULL, &g_mainRenderTargetView); - pBackBuffer->Release(); -} - -void CleanupRenderTarget() -{ - if (g_mainRenderTargetView) { g_mainRenderTargetView->Release(); g_mainRenderTargetView = NULL; } -} - -// Forward declare message handler from imgui_impl_win32.cpp -extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); - -// Win32 message handler -LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam)) - return true; - - switch (msg) - { - case WM_SIZE: - if (g_pd3dDevice != NULL && wParam != SIZE_MINIMIZED) - { - CleanupRenderTarget(); - g_pSwapChain->ResizeBuffers(0, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam), DXGI_FORMAT_UNKNOWN, 0); - CreateRenderTarget(); - } - return 0; - case WM_SYSCOMMAND: - if ((wParam & 0xfff0) == SC_KEYMENU) // Disable ALT application menu - return 0; - break; - case WM_DESTROY: - ::PostQuitMessage(0); - return 0; - } - return ::DefWindowProc(hWnd, msg, wParam, lParam); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx12/build_win32.bat b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx12/build_win32.bat deleted file mode 100644 index 48dadb2..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx12/build_win32.bat +++ /dev/null @@ -1,9 +0,0 @@ -@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. -@REM Important: to build on 32-bit systems, the DX12 backends needs '#define ImTextureID ImU64', so we pass it here. -@set OUT_DIR=Debug -@set OUT_EXE=example_win32_directx12 -@set INCLUDES=/I..\.. /I..\..\backends /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" -@set SOURCES=main.cpp ..\..\backends\imgui_impl_dx12.cpp ..\..\backends\imgui_impl_win32.cpp ..\..\imgui*.cpp -@set LIBS=d3d12.lib d3dcompiler.lib dxgi.lib -mkdir Debug -cl /nologo /Zi /MD %INCLUDES% /D ImTextureID=ImU64 /D UNICODE /D _UNICODE %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx12/example_win32_directx12.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx12/example_win32_directx12.vcxproj deleted file mode 100644 index 3fed30d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx12/example_win32_directx12.vcxproj +++ /dev/null @@ -1,172 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {b4cf9797-519d-4afe-a8f4-5141a6b521d3} - example_win32_directx12 - 10.0.18362.0 - - - - Application - true - Unicode - v140 - - - Application - true - Unicode - v140 - - - Application - false - true - Unicode - v140 - - - Application - false - true - Unicode - v140 - - - - - - - - - - - - - - - - - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - - - - Level4 - Disabled - ..\..;..\..\backends;%(AdditionalIncludeDirectories) - ImTextureID=ImU64;_UNICODE;UNICODE;%(PreprocessorDefinitions) - - - true - d3d12.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies) - %(AdditionalLibraryDirectories) - Console - - - - - Level4 - Disabled - ..\..;..\..\backends;%(AdditionalIncludeDirectories) - ImTextureID=ImU64;_UNICODE;UNICODE;%(PreprocessorDefinitions) - - - true - d3d12.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies) - %(AdditionalLibraryDirectories) - Console - - - - - Level4 - MaxSpeed - true - true - ..\..;..\..\backends;%(AdditionalIncludeDirectories) - ImTextureID=ImU64;_UNICODE;UNICODE;%(PreprocessorDefinitions) - - - true - true - true - d3d12.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies) - %(AdditionalLibraryDirectories) - Console - - - - - Level4 - MaxSpeed - true - true - ..\..;..\..\backends;%(AdditionalIncludeDirectories) - ImTextureID=ImU64;_UNICODE;UNICODE;%(PreprocessorDefinitions) - - - true - true - true - d3d12.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies) - %(AdditionalLibraryDirectories) - Console - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx12/example_win32_directx12.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx12/example_win32_directx12.vcxproj.filters deleted file mode 100644 index 91fc734..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx12/example_win32_directx12.vcxproj.filters +++ /dev/null @@ -1,57 +0,0 @@ - - - - - {fb3d294f-51ec-478e-a627-25831c80fefd} - - - {4f33ddea-9910-456d-b868-4267eb3c2b19} - - - - - imgui - - - imgui - - - imgui - - - sources - - - sources - - - - - imgui - - - sources - - - imgui - - - imgui - - - sources - - - sources - - - imgui - - - imgui - - - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx12/main.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx12/main.cpp deleted file mode 100644 index 74bfef3..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx12/main.cpp +++ /dev/null @@ -1,464 +0,0 @@ -// Dear ImGui: standalone example application for DirectX 12 -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -// Important: to compile on 32-bit systems, the DirectX12 backend requires code to be compiled with '#define ImTextureID ImU64'. -// This is because we need ImTextureID to carry a 64-bit value and by default ImTextureID is defined as void*. -// This define is set in the example .vcxproj file and need to be replicated in your app or by adding it to your imconfig.h file. - -#include "imgui.h" -#include "imgui_impl_win32.h" -#include "imgui_impl_dx12.h" -#include -#include -#include - -#ifdef _DEBUG -#define DX12_ENABLE_DEBUG_LAYER -#endif - -#ifdef DX12_ENABLE_DEBUG_LAYER -#include -#pragma comment(lib, "dxguid.lib") -#endif - -struct FrameContext -{ - ID3D12CommandAllocator* CommandAllocator; - UINT64 FenceValue; -}; - -// Data -static int const NUM_FRAMES_IN_FLIGHT = 3; -static FrameContext g_frameContext[NUM_FRAMES_IN_FLIGHT] = {}; -static UINT g_frameIndex = 0; - -static int const NUM_BACK_BUFFERS = 3; -static ID3D12Device* g_pd3dDevice = NULL; -static ID3D12DescriptorHeap* g_pd3dRtvDescHeap = NULL; -static ID3D12DescriptorHeap* g_pd3dSrvDescHeap = NULL; -static ID3D12CommandQueue* g_pd3dCommandQueue = NULL; -static ID3D12GraphicsCommandList* g_pd3dCommandList = NULL; -static ID3D12Fence* g_fence = NULL; -static HANDLE g_fenceEvent = NULL; -static UINT64 g_fenceLastSignaledValue = 0; -static IDXGISwapChain3* g_pSwapChain = NULL; -static HANDLE g_hSwapChainWaitableObject = NULL; -static ID3D12Resource* g_mainRenderTargetResource[NUM_BACK_BUFFERS] = {}; -static D3D12_CPU_DESCRIPTOR_HANDLE g_mainRenderTargetDescriptor[NUM_BACK_BUFFERS] = {}; - -// Forward declarations of helper functions -bool CreateDeviceD3D(HWND hWnd); -void CleanupDeviceD3D(); -void CreateRenderTarget(); -void CleanupRenderTarget(); -void WaitForLastSubmittedFrame(); -FrameContext* WaitForNextFrameResources(); -LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); - -// Main code -int main(int, char**) -{ - // Create application window - //ImGui_ImplWin32_EnableDpiAwareness(); - WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, _T("ImGui Example"), NULL }; - ::RegisterClassEx(&wc); - HWND hwnd = ::CreateWindow(wc.lpszClassName, _T("Dear ImGui DirectX12 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL); - - // Initialize Direct3D - if (!CreateDeviceD3D(hwnd)) - { - CleanupDeviceD3D(); - ::UnregisterClass(wc.lpszClassName, wc.hInstance); - return 1; - } - - // Show the window - ::ShowWindow(hwnd, SW_SHOWDEFAULT); - ::UpdateWindow(hwnd); - - // Setup Dear ImGui context - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); (void)io; - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls - - // Setup Dear ImGui style - ImGui::StyleColorsDark(); - //ImGui::StyleColorsClassic(); - - // Setup Platform/Renderer backends - ImGui_ImplWin32_Init(hwnd); - ImGui_ImplDX12_Init(g_pd3dDevice, NUM_FRAMES_IN_FLIGHT, - DXGI_FORMAT_R8G8B8A8_UNORM, g_pd3dSrvDescHeap, - g_pd3dSrvDescHeap->GetCPUDescriptorHandleForHeapStart(), - g_pd3dSrvDescHeap->GetGPUDescriptorHandleForHeapStart()); - - // Load Fonts - // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. - // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. - // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). - // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call. - // - Read 'docs/FONTS.md' for more instructions and details. - // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! - //io.Fonts->AddFontDefault(); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f); - //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - //IM_ASSERT(font != NULL); - - // Our state - bool show_demo_window = true; - bool show_another_window = false; - ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); - - // Main loop - bool done = false; - while (!done) - { - // Poll and handle messages (inputs, window resize, etc.) - // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. - // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. - // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. - // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. - MSG msg; - while (::PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) - { - ::TranslateMessage(&msg); - ::DispatchMessage(&msg); - if (msg.message == WM_QUIT) - done = true; - } - if (done) - break; - - // Start the Dear ImGui frame - ImGui_ImplDX12_NewFrame(); - ImGui_ImplWin32_NewFrame(); - ImGui::NewFrame(); - - // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). - if (show_demo_window) - ImGui::ShowDemoWindow(&show_demo_window); - - // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window. - { - static float f = 0.0f; - static int counter = 0; - - ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. - - ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) - ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state - ImGui::Checkbox("Another Window", &show_another_window); - - ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f - ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color - - if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) - counter++; - ImGui::SameLine(); - ImGui::Text("counter = %d", counter); - - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); - ImGui::End(); - } - - // 3. Show another simple window. - if (show_another_window) - { - ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked) - ImGui::Text("Hello from another window!"); - if (ImGui::Button("Close Me")) - show_another_window = false; - ImGui::End(); - } - - // Rendering - ImGui::Render(); - - FrameContext* frameCtx = WaitForNextFrameResources(); - UINT backBufferIdx = g_pSwapChain->GetCurrentBackBufferIndex(); - frameCtx->CommandAllocator->Reset(); - - D3D12_RESOURCE_BARRIER barrier = {}; - barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION; - barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE; - barrier.Transition.pResource = g_mainRenderTargetResource[backBufferIdx]; - barrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES; - barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_PRESENT; - barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_RENDER_TARGET; - g_pd3dCommandList->Reset(frameCtx->CommandAllocator, NULL); - g_pd3dCommandList->ResourceBarrier(1, &barrier); - - // Render Dear ImGui graphics - const float clear_color_with_alpha[4] = { clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w }; - g_pd3dCommandList->ClearRenderTargetView(g_mainRenderTargetDescriptor[backBufferIdx], clear_color_with_alpha, 0, NULL); - g_pd3dCommandList->OMSetRenderTargets(1, &g_mainRenderTargetDescriptor[backBufferIdx], FALSE, NULL); - g_pd3dCommandList->SetDescriptorHeaps(1, &g_pd3dSrvDescHeap); - ImGui_ImplDX12_RenderDrawData(ImGui::GetDrawData(), g_pd3dCommandList); - barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_RENDER_TARGET; - barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_PRESENT; - g_pd3dCommandList->ResourceBarrier(1, &barrier); - g_pd3dCommandList->Close(); - - g_pd3dCommandQueue->ExecuteCommandLists(1, (ID3D12CommandList* const*)&g_pd3dCommandList); - - g_pSwapChain->Present(1, 0); // Present with vsync - //g_pSwapChain->Present(0, 0); // Present without vsync - - UINT64 fenceValue = g_fenceLastSignaledValue + 1; - g_pd3dCommandQueue->Signal(g_fence, fenceValue); - g_fenceLastSignaledValue = fenceValue; - frameCtx->FenceValue = fenceValue; - } - - WaitForLastSubmittedFrame(); - - // Cleanup - ImGui_ImplDX12_Shutdown(); - ImGui_ImplWin32_Shutdown(); - ImGui::DestroyContext(); - - CleanupDeviceD3D(); - ::DestroyWindow(hwnd); - ::UnregisterClass(wc.lpszClassName, wc.hInstance); - - return 0; -} - -// Helper functions - -bool CreateDeviceD3D(HWND hWnd) -{ - // Setup swap chain - DXGI_SWAP_CHAIN_DESC1 sd; - { - ZeroMemory(&sd, sizeof(sd)); - sd.BufferCount = NUM_BACK_BUFFERS; - sd.Width = 0; - sd.Height = 0; - sd.Format = DXGI_FORMAT_R8G8B8A8_UNORM; - sd.Flags = DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT; - sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; - sd.SampleDesc.Count = 1; - sd.SampleDesc.Quality = 0; - sd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; - sd.AlphaMode = DXGI_ALPHA_MODE_UNSPECIFIED; - sd.Scaling = DXGI_SCALING_STRETCH; - sd.Stereo = FALSE; - } - - // [DEBUG] Enable debug interface -#ifdef DX12_ENABLE_DEBUG_LAYER - ID3D12Debug* pdx12Debug = NULL; - if (SUCCEEDED(D3D12GetDebugInterface(IID_PPV_ARGS(&pdx12Debug)))) - pdx12Debug->EnableDebugLayer(); -#endif - - // Create device - D3D_FEATURE_LEVEL featureLevel = D3D_FEATURE_LEVEL_11_0; - if (D3D12CreateDevice(NULL, featureLevel, IID_PPV_ARGS(&g_pd3dDevice)) != S_OK) - return false; - - // [DEBUG] Setup debug interface to break on any warnings/errors -#ifdef DX12_ENABLE_DEBUG_LAYER - if (pdx12Debug != NULL) - { - ID3D12InfoQueue* pInfoQueue = NULL; - g_pd3dDevice->QueryInterface(IID_PPV_ARGS(&pInfoQueue)); - pInfoQueue->SetBreakOnSeverity(D3D12_MESSAGE_SEVERITY_ERROR, true); - pInfoQueue->SetBreakOnSeverity(D3D12_MESSAGE_SEVERITY_CORRUPTION, true); - pInfoQueue->SetBreakOnSeverity(D3D12_MESSAGE_SEVERITY_WARNING, true); - pInfoQueue->Release(); - pdx12Debug->Release(); - } -#endif - - { - D3D12_DESCRIPTOR_HEAP_DESC desc = {}; - desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV; - desc.NumDescriptors = NUM_BACK_BUFFERS; - desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; - desc.NodeMask = 1; - if (g_pd3dDevice->CreateDescriptorHeap(&desc, IID_PPV_ARGS(&g_pd3dRtvDescHeap)) != S_OK) - return false; - - SIZE_T rtvDescriptorSize = g_pd3dDevice->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV); - D3D12_CPU_DESCRIPTOR_HANDLE rtvHandle = g_pd3dRtvDescHeap->GetCPUDescriptorHandleForHeapStart(); - for (UINT i = 0; i < NUM_BACK_BUFFERS; i++) - { - g_mainRenderTargetDescriptor[i] = rtvHandle; - rtvHandle.ptr += rtvDescriptorSize; - } - } - - { - D3D12_DESCRIPTOR_HEAP_DESC desc = {}; - desc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; - desc.NumDescriptors = 1; - desc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; - if (g_pd3dDevice->CreateDescriptorHeap(&desc, IID_PPV_ARGS(&g_pd3dSrvDescHeap)) != S_OK) - return false; - } - - { - D3D12_COMMAND_QUEUE_DESC desc = {}; - desc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT; - desc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE; - desc.NodeMask = 1; - if (g_pd3dDevice->CreateCommandQueue(&desc, IID_PPV_ARGS(&g_pd3dCommandQueue)) != S_OK) - return false; - } - - for (UINT i = 0; i < NUM_FRAMES_IN_FLIGHT; i++) - if (g_pd3dDevice->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&g_frameContext[i].CommandAllocator)) != S_OK) - return false; - - if (g_pd3dDevice->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, g_frameContext[0].CommandAllocator, NULL, IID_PPV_ARGS(&g_pd3dCommandList)) != S_OK || - g_pd3dCommandList->Close() != S_OK) - return false; - - if (g_pd3dDevice->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&g_fence)) != S_OK) - return false; - - g_fenceEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - if (g_fenceEvent == NULL) - return false; - - { - IDXGIFactory4* dxgiFactory = NULL; - IDXGISwapChain1* swapChain1 = NULL; - if (CreateDXGIFactory1(IID_PPV_ARGS(&dxgiFactory)) != S_OK) - return false; - if (dxgiFactory->CreateSwapChainForHwnd(g_pd3dCommandQueue, hWnd, &sd, NULL, NULL, &swapChain1) != S_OK) - return false; - if (swapChain1->QueryInterface(IID_PPV_ARGS(&g_pSwapChain)) != S_OK) - return false; - swapChain1->Release(); - dxgiFactory->Release(); - g_pSwapChain->SetMaximumFrameLatency(NUM_BACK_BUFFERS); - g_hSwapChainWaitableObject = g_pSwapChain->GetFrameLatencyWaitableObject(); - } - - CreateRenderTarget(); - return true; -} - -void CleanupDeviceD3D() -{ - CleanupRenderTarget(); - if (g_pSwapChain) { g_pSwapChain->SetFullscreenState(false, NULL); g_pSwapChain->Release(); g_pSwapChain = NULL; } - if (g_hSwapChainWaitableObject != NULL) { CloseHandle(g_hSwapChainWaitableObject); } - for (UINT i = 0; i < NUM_FRAMES_IN_FLIGHT; i++) - if (g_frameContext[i].CommandAllocator) { g_frameContext[i].CommandAllocator->Release(); g_frameContext[i].CommandAllocator = NULL; } - if (g_pd3dCommandQueue) { g_pd3dCommandQueue->Release(); g_pd3dCommandQueue = NULL; } - if (g_pd3dCommandList) { g_pd3dCommandList->Release(); g_pd3dCommandList = NULL; } - if (g_pd3dRtvDescHeap) { g_pd3dRtvDescHeap->Release(); g_pd3dRtvDescHeap = NULL; } - if (g_pd3dSrvDescHeap) { g_pd3dSrvDescHeap->Release(); g_pd3dSrvDescHeap = NULL; } - if (g_fence) { g_fence->Release(); g_fence = NULL; } - if (g_fenceEvent) { CloseHandle(g_fenceEvent); g_fenceEvent = NULL; } - if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; } - -#ifdef DX12_ENABLE_DEBUG_LAYER - IDXGIDebug1* pDebug = NULL; - if (SUCCEEDED(DXGIGetDebugInterface1(0, IID_PPV_ARGS(&pDebug)))) - { - pDebug->ReportLiveObjects(DXGI_DEBUG_ALL, DXGI_DEBUG_RLO_SUMMARY); - pDebug->Release(); - } -#endif -} - -void CreateRenderTarget() -{ - for (UINT i = 0; i < NUM_BACK_BUFFERS; i++) - { - ID3D12Resource* pBackBuffer = NULL; - g_pSwapChain->GetBuffer(i, IID_PPV_ARGS(&pBackBuffer)); - g_pd3dDevice->CreateRenderTargetView(pBackBuffer, NULL, g_mainRenderTargetDescriptor[i]); - g_mainRenderTargetResource[i] = pBackBuffer; - } -} - -void CleanupRenderTarget() -{ - WaitForLastSubmittedFrame(); - - for (UINT i = 0; i < NUM_BACK_BUFFERS; i++) - if (g_mainRenderTargetResource[i]) { g_mainRenderTargetResource[i]->Release(); g_mainRenderTargetResource[i] = NULL; } -} - -void WaitForLastSubmittedFrame() -{ - FrameContext* frameCtx = &g_frameContext[g_frameIndex % NUM_FRAMES_IN_FLIGHT]; - - UINT64 fenceValue = frameCtx->FenceValue; - if (fenceValue == 0) - return; // No fence was signaled - - frameCtx->FenceValue = 0; - if (g_fence->GetCompletedValue() >= fenceValue) - return; - - g_fence->SetEventOnCompletion(fenceValue, g_fenceEvent); - WaitForSingleObject(g_fenceEvent, INFINITE); -} - -FrameContext* WaitForNextFrameResources() -{ - UINT nextFrameIndex = g_frameIndex + 1; - g_frameIndex = nextFrameIndex; - - HANDLE waitableObjects[] = { g_hSwapChainWaitableObject, NULL }; - DWORD numWaitableObjects = 1; - - FrameContext* frameCtx = &g_frameContext[nextFrameIndex % NUM_FRAMES_IN_FLIGHT]; - UINT64 fenceValue = frameCtx->FenceValue; - if (fenceValue != 0) // means no fence was signaled - { - frameCtx->FenceValue = 0; - g_fence->SetEventOnCompletion(fenceValue, g_fenceEvent); - waitableObjects[1] = g_fenceEvent; - numWaitableObjects = 2; - } - - WaitForMultipleObjects(numWaitableObjects, waitableObjects, TRUE, INFINITE); - - return frameCtx; -} - -// Forward declare message handler from imgui_impl_win32.cpp -extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); - -// Win32 message handler -LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam)) - return true; - - switch (msg) - { - case WM_SIZE: - if (g_pd3dDevice != NULL && wParam != SIZE_MINIMIZED) - { - WaitForLastSubmittedFrame(); - CleanupRenderTarget(); - HRESULT result = g_pSwapChain->ResizeBuffers(0, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam), DXGI_FORMAT_UNKNOWN, DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT); - assert(SUCCEEDED(result) && "Failed to resize swapchain."); - CreateRenderTarget(); - } - return 0; - case WM_SYSCOMMAND: - if ((wParam & 0xfff0) == SC_KEYMENU) // Disable ALT application menu - return 0; - break; - case WM_DESTROY: - ::PostQuitMessage(0); - return 0; - } - return ::DefWindowProc(hWnd, msg, wParam, lParam); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx9/build_win32.bat b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx9/build_win32.bat deleted file mode 100644 index bbd4b13..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx9/build_win32.bat +++ /dev/null @@ -1,8 +0,0 @@ -@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. -@set OUT_DIR=Debug -@set OUT_EXE=example_win32_directx9 -@set INCLUDES=/I..\.. /I..\..\backends /I "%DXSDK_DIR%/Include" -@set SOURCES=main.cpp ..\..\backends\imgui_impl_dx9.cpp ..\..\backends\imgui_impl_win32.cpp ..\..\imgui*.cpp -@set LIBS=/LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d9.lib -mkdir %OUT_DIR% -cl /nologo /Zi /MD %INCLUDES% /D UNICODE /D _UNICODE %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS% diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx9/example_win32_directx9.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx9/example_win32_directx9.vcxproj deleted file mode 100644 index e01eca1..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx9/example_win32_directx9.vcxproj +++ /dev/null @@ -1,171 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {4165A294-21F2-44CA-9B38-E3F935ABADF5} - example_win32_directx9 - 8.1 - - - - Application - true - Unicode - v140 - - - Application - true - Unicode - v140 - - - Application - false - true - Unicode - v140 - - - Application - false - true - Unicode - v140 - - - - - - - - - - - - - - - - - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - - - $(ProjectDir)$(Configuration)\ - $(ProjectDir)$(Configuration)\ - - - - Level4 - Disabled - ..\..;..\..\backends;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include; - - - true - $(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories) - d3d9.lib;%(AdditionalDependencies) - Console - - - - - Level4 - Disabled - ..\..;..\..\backends;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include; - - - true - $(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories) - d3d9.lib;%(AdditionalDependencies) - Console - - - - - Level4 - MaxSpeed - true - true - ..\..;..\..\backends;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include; - false - - - true - true - true - $(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories) - d3d9.lib;%(AdditionalDependencies) - Console - - - - - Level4 - MaxSpeed - true - true - ..\..;..\..\backends;%(AdditionalIncludeDirectories);$(DXSDK_DIR)Include; - false - - - true - true - true - $(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories) - d3d9.lib;%(AdditionalDependencies) - Console - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx9/example_win32_directx9.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx9/example_win32_directx9.vcxproj.filters deleted file mode 100644 index 9493970..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx9/example_win32_directx9.vcxproj.filters +++ /dev/null @@ -1,61 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {a82cba23-9de0-45c2-b1e3-2eb1666702de} - - - - - sources - - - imgui - - - imgui - - - imgui - - - sources - - - sources - - - imgui - - - imgui - - - - - imgui - - - imgui - - - imgui - - - sources - - - sources - - - - - - sources - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx9/main.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx9/main.cpp deleted file mode 100644 index bdcd8b3..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/example_win32_directx9/main.cpp +++ /dev/null @@ -1,236 +0,0 @@ -// Dear ImGui: standalone example application for DirectX 9 -// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. -// Read online: https://github.com/ocornut/imgui/tree/master/docs - -#include "imgui.h" -#include "imgui_impl_dx9.h" -#include "imgui_impl_win32.h" -#include -#include - -// Data -static LPDIRECT3D9 g_pD3D = NULL; -static LPDIRECT3DDEVICE9 g_pd3dDevice = NULL; -static D3DPRESENT_PARAMETERS g_d3dpp = {}; - -// Forward declarations of helper functions -bool CreateDeviceD3D(HWND hWnd); -void CleanupDeviceD3D(); -void ResetDevice(); -LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); - -// Main code -int main(int, char**) -{ - // Create application window - //ImGui_ImplWin32_EnableDpiAwareness(); - WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, _T("ImGui Example"), NULL }; - ::RegisterClassEx(&wc); - HWND hwnd = ::CreateWindow(wc.lpszClassName, _T("Dear ImGui DirectX9 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL); - - // Initialize Direct3D - if (!CreateDeviceD3D(hwnd)) - { - CleanupDeviceD3D(); - ::UnregisterClass(wc.lpszClassName, wc.hInstance); - return 1; - } - - // Show the window - ::ShowWindow(hwnd, SW_SHOWDEFAULT); - ::UpdateWindow(hwnd); - - // Setup Dear ImGui context - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); (void)io; - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls - //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls - - // Setup Dear ImGui style - ImGui::StyleColorsDark(); - //ImGui::StyleColorsClassic(); - - // Setup Platform/Renderer backends - ImGui_ImplWin32_Init(hwnd); - ImGui_ImplDX9_Init(g_pd3dDevice); - - // Load Fonts - // - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them. - // - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple. - // - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit). - // - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call. - // - Read 'docs/FONTS.md' for more instructions and details. - // - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ ! - //io.Fonts->AddFontDefault(); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f); - //ImFont* font = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - //IM_ASSERT(font != NULL); - - // Our state - bool show_demo_window = true; - bool show_another_window = false; - ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); - - // Main loop - bool done = false; - while (!done) - { - // Poll and handle messages (inputs, window resize, etc.) - // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. - // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application. - // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application. - // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. - MSG msg; - while (::PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) - { - ::TranslateMessage(&msg); - ::DispatchMessage(&msg); - if (msg.message == WM_QUIT) - done = true; - } - if (done) - break; - - // Start the Dear ImGui frame - ImGui_ImplDX9_NewFrame(); - ImGui_ImplWin32_NewFrame(); - ImGui::NewFrame(); - - // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). - if (show_demo_window) - ImGui::ShowDemoWindow(&show_demo_window); - - // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window. - { - static float f = 0.0f; - static int counter = 0; - - ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. - - ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) - ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state - ImGui::Checkbox("Another Window", &show_another_window); - - ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f - ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color - - if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) - counter++; - ImGui::SameLine(); - ImGui::Text("counter = %d", counter); - - ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); - ImGui::End(); - } - - // 3. Show another simple window. - if (show_another_window) - { - ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked) - ImGui::Text("Hello from another window!"); - if (ImGui::Button("Close Me")) - show_another_window = false; - ImGui::End(); - } - - // Rendering - ImGui::EndFrame(); - g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, FALSE); - g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); - g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE); - D3DCOLOR clear_col_dx = D3DCOLOR_RGBA((int)(clear_color.x*clear_color.w*255.0f), (int)(clear_color.y*clear_color.w*255.0f), (int)(clear_color.z*clear_color.w*255.0f), (int)(clear_color.w*255.0f)); - g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, clear_col_dx, 1.0f, 0); - if (g_pd3dDevice->BeginScene() >= 0) - { - ImGui::Render(); - ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData()); - g_pd3dDevice->EndScene(); - } - HRESULT result = g_pd3dDevice->Present(NULL, NULL, NULL, NULL); - - // Handle loss of D3D9 device - if (result == D3DERR_DEVICELOST && g_pd3dDevice->TestCooperativeLevel() == D3DERR_DEVICENOTRESET) - ResetDevice(); - } - - ImGui_ImplDX9_Shutdown(); - ImGui_ImplWin32_Shutdown(); - ImGui::DestroyContext(); - - CleanupDeviceD3D(); - ::DestroyWindow(hwnd); - ::UnregisterClass(wc.lpszClassName, wc.hInstance); - - return 0; -} - -// Helper functions - -bool CreateDeviceD3D(HWND hWnd) -{ - if ((g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)) == NULL) - return false; - - // Create the D3DDevice - ZeroMemory(&g_d3dpp, sizeof(g_d3dpp)); - g_d3dpp.Windowed = TRUE; - g_d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; - g_d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; // Need to use an explicit format with alpha if needing per-pixel alpha composition. - g_d3dpp.EnableAutoDepthStencil = TRUE; - g_d3dpp.AutoDepthStencilFormat = D3DFMT_D16; - g_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE; // Present with vsync - //g_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; // Present without vsync, maximum unthrottled framerate - if (g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &g_d3dpp, &g_pd3dDevice) < 0) - return false; - - return true; -} - -void CleanupDeviceD3D() -{ - if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; } - if (g_pD3D) { g_pD3D->Release(); g_pD3D = NULL; } -} - -void ResetDevice() -{ - ImGui_ImplDX9_InvalidateDeviceObjects(); - HRESULT hr = g_pd3dDevice->Reset(&g_d3dpp); - if (hr == D3DERR_INVALIDCALL) - IM_ASSERT(0); - ImGui_ImplDX9_CreateDeviceObjects(); -} - -// Forward declare message handler from imgui_impl_win32.cpp -extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); - -// Win32 message handler -LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam)) - return true; - - switch (msg) - { - case WM_SIZE: - if (g_pd3dDevice != NULL && wParam != SIZE_MINIMIZED) - { - g_d3dpp.BackBufferWidth = LOWORD(lParam); - g_d3dpp.BackBufferHeight = HIWORD(lParam); - ResetDevice(); - } - return 0; - case WM_SYSCOMMAND: - if ((wParam & 0xfff0) == SC_KEYMENU) // Disable ALT application menu - return 0; - break; - case WM_DESTROY: - ::PostQuitMessage(0); - return 0; - } - return ::DefWindowProc(hWnd, msg, wParam, lParam); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/imgui_examples.sln b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/imgui_examples.sln deleted file mode 100644 index df1006d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/imgui_examples.sln +++ /dev/null @@ -1,88 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_win32_directx9", "example_win32_directx9\example_win32_directx9.vcxproj", "{4165A294-21F2-44CA-9B38-E3F935ABADF5}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_win32_directx10", "example_win32_directx10\example_win32_directx10.vcxproj", "{345A953E-A004-4648-B442-DC5F9F11068C}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_win32_directx11", "example_win32_directx11\example_win32_directx11.vcxproj", "{9F316E83-5AE5-4939-A723-305A94F48005}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_win32_directx12", "example_win32_directx12\example_win32_directx12.vcxproj", "{B4CF9797-519D-4AFE-A8F4-5141A6B521D3}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_glfw_opengl2", "example_glfw_opengl2\example_glfw_opengl2.vcxproj", "{9CDA7840-B7A5-496D-A527-E95571496D18}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_glfw_opengl3", "example_glfw_opengl3\example_glfw_opengl3.vcxproj", "{4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_glfw_vulkan", "example_glfw_vulkan\example_glfw_vulkan.vcxproj", "{57E2DF5A-6FC8-45BB-99DD-91A18C646E80}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4165A294-21F2-44CA-9B38-E3F935ABADF5}.Debug|Win32.ActiveCfg = Debug|Win32 - {4165A294-21F2-44CA-9B38-E3F935ABADF5}.Debug|Win32.Build.0 = Debug|Win32 - {4165A294-21F2-44CA-9B38-E3F935ABADF5}.Debug|x64.ActiveCfg = Debug|x64 - {4165A294-21F2-44CA-9B38-E3F935ABADF5}.Debug|x64.Build.0 = Debug|x64 - {4165A294-21F2-44CA-9B38-E3F935ABADF5}.Release|Win32.ActiveCfg = Release|Win32 - {4165A294-21F2-44CA-9B38-E3F935ABADF5}.Release|Win32.Build.0 = Release|Win32 - {4165A294-21F2-44CA-9B38-E3F935ABADF5}.Release|x64.ActiveCfg = Release|x64 - {4165A294-21F2-44CA-9B38-E3F935ABADF5}.Release|x64.Build.0 = Release|x64 - {345A953E-A004-4648-B442-DC5F9F11068C}.Debug|Win32.ActiveCfg = Debug|Win32 - {345A953E-A004-4648-B442-DC5F9F11068C}.Debug|Win32.Build.0 = Debug|Win32 - {345A953E-A004-4648-B442-DC5F9F11068C}.Debug|x64.ActiveCfg = Debug|x64 - {345A953E-A004-4648-B442-DC5F9F11068C}.Debug|x64.Build.0 = Debug|x64 - {345A953E-A004-4648-B442-DC5F9F11068C}.Release|Win32.ActiveCfg = Release|Win32 - {345A953E-A004-4648-B442-DC5F9F11068C}.Release|Win32.Build.0 = Release|Win32 - {345A953E-A004-4648-B442-DC5F9F11068C}.Release|x64.ActiveCfg = Release|x64 - {345A953E-A004-4648-B442-DC5F9F11068C}.Release|x64.Build.0 = Release|x64 - {9F316E83-5AE5-4939-A723-305A94F48005}.Debug|Win32.ActiveCfg = Debug|Win32 - {9F316E83-5AE5-4939-A723-305A94F48005}.Debug|Win32.Build.0 = Debug|Win32 - {9F316E83-5AE5-4939-A723-305A94F48005}.Debug|x64.ActiveCfg = Debug|x64 - {9F316E83-5AE5-4939-A723-305A94F48005}.Debug|x64.Build.0 = Debug|x64 - {9F316E83-5AE5-4939-A723-305A94F48005}.Release|Win32.ActiveCfg = Release|Win32 - {9F316E83-5AE5-4939-A723-305A94F48005}.Release|Win32.Build.0 = Release|Win32 - {9F316E83-5AE5-4939-A723-305A94F48005}.Release|x64.ActiveCfg = Release|x64 - {9F316E83-5AE5-4939-A723-305A94F48005}.Release|x64.Build.0 = Release|x64 - {B4CF9797-519D-4AFE-A8F4-5141A6B521D3}.Debug|Win32.ActiveCfg = Debug|Win32 - {B4CF9797-519D-4AFE-A8F4-5141A6B521D3}.Debug|Win32.Build.0 = Debug|Win32 - {B4CF9797-519D-4AFE-A8F4-5141A6B521D3}.Debug|x64.ActiveCfg = Debug|x64 - {B4CF9797-519D-4AFE-A8F4-5141A6B521D3}.Debug|x64.Build.0 = Debug|x64 - {B4CF9797-519D-4AFE-A8F4-5141A6B521D3}.Release|Win32.ActiveCfg = Release|Win32 - {B4CF9797-519D-4AFE-A8F4-5141A6B521D3}.Release|Win32.Build.0 = Release|Win32 - {B4CF9797-519D-4AFE-A8F4-5141A6B521D3}.Release|x64.ActiveCfg = Release|x64 - {B4CF9797-519D-4AFE-A8F4-5141A6B521D3}.Release|x64.Build.0 = Release|x64 - {9CDA7840-B7A5-496D-A527-E95571496D18}.Debug|Win32.ActiveCfg = Debug|Win32 - {9CDA7840-B7A5-496D-A527-E95571496D18}.Debug|Win32.Build.0 = Debug|Win32 - {9CDA7840-B7A5-496D-A527-E95571496D18}.Debug|x64.ActiveCfg = Debug|x64 - {9CDA7840-B7A5-496D-A527-E95571496D18}.Debug|x64.Build.0 = Debug|x64 - {9CDA7840-B7A5-496D-A527-E95571496D18}.Release|Win32.ActiveCfg = Release|Win32 - {9CDA7840-B7A5-496D-A527-E95571496D18}.Release|Win32.Build.0 = Release|Win32 - {9CDA7840-B7A5-496D-A527-E95571496D18}.Release|x64.ActiveCfg = Release|x64 - {9CDA7840-B7A5-496D-A527-E95571496D18}.Release|x64.Build.0 = Release|x64 - {4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Debug|Win32.ActiveCfg = Debug|Win32 - {4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Debug|Win32.Build.0 = Debug|Win32 - {4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Debug|x64.ActiveCfg = Debug|x64 - {4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Debug|x64.Build.0 = Debug|x64 - {4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Release|Win32.ActiveCfg = Release|Win32 - {4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Release|Win32.Build.0 = Release|Win32 - {4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Release|x64.ActiveCfg = Release|x64 - {4A1FB5EA-22F5-42A8-AB92-1D2DF5D47FB9}.Release|x64.Build.0 = Release|x64 - {57E2DF5A-6FC8-45BB-99DD-91A18C646E80}.Debug|Win32.ActiveCfg = Debug|Win32 - {57E2DF5A-6FC8-45BB-99DD-91A18C646E80}.Debug|Win32.Build.0 = Debug|Win32 - {57E2DF5A-6FC8-45BB-99DD-91A18C646E80}.Debug|x64.ActiveCfg = Debug|x64 - {57E2DF5A-6FC8-45BB-99DD-91A18C646E80}.Debug|x64.Build.0 = Debug|x64 - {57E2DF5A-6FC8-45BB-99DD-91A18C646E80}.Release|Win32.ActiveCfg = Release|Win32 - {57E2DF5A-6FC8-45BB-99DD-91A18C646E80}.Release|Win32.Build.0 = Release|Win32 - {57E2DF5A-6FC8-45BB-99DD-91A18C646E80}.Release|x64.ActiveCfg = Release|x64 - {57E2DF5A-6FC8-45BB-99DD-91A18C646E80}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/libs/glfw/COPYING.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/libs/glfw/COPYING.txt deleted file mode 100644 index b30c701..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/libs/glfw/COPYING.txt +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2002-2006 Marcus Geelnard -Copyright (c) 2006-2010 Camilla Berglund - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would - be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and must not - be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source - distribution. - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/libs/glfw/include/GLFW/glfw3.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/libs/glfw/include/GLFW/glfw3.h deleted file mode 100644 index f8ca3d6..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/libs/glfw/include/GLFW/glfw3.h +++ /dev/null @@ -1,4227 +0,0 @@ -/************************************************************************* - * GLFW 3.2 - www.glfw.org - * A library for OpenGL, window and input - *------------------------------------------------------------------------ - * Copyright (c) 2002-2006 Marcus Geelnard - * Copyright (c) 2006-2010 Camilla Berglund - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would - * be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must not - * be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - * - *************************************************************************/ - -#ifndef _glfw3_h_ -#define _glfw3_h_ - -#ifdef __cplusplus -extern "C" { -#endif - - -/************************************************************************* - * Doxygen documentation - *************************************************************************/ - -/*! @file glfw3.h - * @brief The header of the GLFW 3 API. - * - * This is the header file of the GLFW 3 API. It defines all its types and - * declares all its functions. - * - * For more information about how to use this file, see @ref build_include. - */ -/*! @defgroup context Context reference - * - * This is the reference documentation for OpenGL and OpenGL ES context related - * functions. For more task-oriented information, see the @ref context_guide. - */ -/*! @defgroup vulkan Vulkan reference - * - * This is the reference documentation for Vulkan related functions and types. - * For more task-oriented information, see the @ref vulkan_guide. - */ -/*! @defgroup init Initialization, version and error reference - * - * This is the reference documentation for initialization and termination of - * the library, version management and error handling. For more task-oriented - * information, see the @ref intro_guide. - */ -/*! @defgroup input Input reference - * - * This is the reference documentation for input related functions and types. - * For more task-oriented information, see the @ref input_guide. - */ -/*! @defgroup monitor Monitor reference - * - * This is the reference documentation for monitor related functions and types. - * For more task-oriented information, see the @ref monitor_guide. - */ -/*! @defgroup window Window reference - * - * This is the reference documentation for window related functions and types, - * including creation, deletion and event polling. For more task-oriented - * information, see the @ref window_guide. - */ - - -/************************************************************************* - * Compiler- and platform-specific preprocessor work - *************************************************************************/ - -/* If we are we on Windows, we want a single define for it. - */ -#if !defined(_WIN32) && (defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__)) - #define _WIN32 -#endif /* _WIN32 */ - -/* It is customary to use APIENTRY for OpenGL function pointer declarations on - * all platforms. Additionally, the Windows OpenGL header needs APIENTRY. - */ -#ifndef APIENTRY - #ifdef _WIN32 - #define APIENTRY __stdcall - #else - #define APIENTRY - #endif -#endif /* APIENTRY */ - -/* Some Windows OpenGL headers need this. - */ -#if !defined(WINGDIAPI) && defined(_WIN32) - #define WINGDIAPI __declspec(dllimport) - #define GLFW_WINGDIAPI_DEFINED -#endif /* WINGDIAPI */ - -/* Some Windows GLU headers need this. - */ -#if !defined(CALLBACK) && defined(_WIN32) - #define CALLBACK __stdcall - #define GLFW_CALLBACK_DEFINED -#endif /* CALLBACK */ - -/* Most Windows GLU headers need wchar_t. - * The OS X OpenGL header blocks the definition of ptrdiff_t by glext.h. - * Include it unconditionally to avoid surprising side-effects. - */ -#include -#include - -/* Include the chosen client API headers. - */ -#if defined(__APPLE__) - #if defined(GLFW_INCLUDE_GLCOREARB) - #include - #if defined(GLFW_INCLUDE_GLEXT) - #include - #endif - #elif !defined(GLFW_INCLUDE_NONE) - #if !defined(GLFW_INCLUDE_GLEXT) - #define GL_GLEXT_LEGACY - #endif - #include - #endif - #if defined(GLFW_INCLUDE_GLU) - #include - #endif -#else - #if defined(GLFW_INCLUDE_GLCOREARB) - #include - #elif defined(GLFW_INCLUDE_ES1) - #include - #if defined(GLFW_INCLUDE_GLEXT) - #include - #endif - #elif defined(GLFW_INCLUDE_ES2) - #include - #if defined(GLFW_INCLUDE_GLEXT) - #include - #endif - #elif defined(GLFW_INCLUDE_ES3) - #include - #if defined(GLFW_INCLUDE_GLEXT) - #include - #endif - #elif defined(GLFW_INCLUDE_ES31) - #include - #if defined(GLFW_INCLUDE_GLEXT) - #include - #endif - #elif defined(GLFW_INCLUDE_VULKAN) - #include - #elif !defined(GLFW_INCLUDE_NONE) - #include - #if defined(GLFW_INCLUDE_GLEXT) - #include - #endif - #endif - #if defined(GLFW_INCLUDE_GLU) - #include - #endif -#endif - -#if defined(GLFW_DLL) && defined(_GLFW_BUILD_DLL) - /* GLFW_DLL must be defined by applications that are linking against the DLL - * version of the GLFW library. _GLFW_BUILD_DLL is defined by the GLFW - * configuration header when compiling the DLL version of the library. - */ - #error "You must not have both GLFW_DLL and _GLFW_BUILD_DLL defined" -#endif - -/* GLFWAPI is used to declare public API functions for export - * from the DLL / shared library / dynamic library. - */ -#if defined(_WIN32) && defined(_GLFW_BUILD_DLL) - /* We are building GLFW as a Win32 DLL */ - #define GLFWAPI __declspec(dllexport) -#elif defined(_WIN32) && defined(GLFW_DLL) - /* We are calling GLFW as a Win32 DLL */ - #define GLFWAPI __declspec(dllimport) -#elif defined(__GNUC__) && defined(_GLFW_BUILD_DLL) - /* We are building GLFW as a shared / dynamic library */ - #define GLFWAPI __attribute__((visibility("default"))) -#else - /* We are building or calling GLFW as a static library */ - #define GLFWAPI -#endif - - -/************************************************************************* - * GLFW API tokens - *************************************************************************/ - -/*! @name GLFW version macros - * @{ */ -/*! @brief The major version number of the GLFW library. - * - * This is incremented when the API is changed in non-compatible ways. - * @ingroup init - */ -#define GLFW_VERSION_MAJOR 3 -/*! @brief The minor version number of the GLFW library. - * - * This is incremented when features are added to the API but it remains - * backward-compatible. - * @ingroup init - */ -#define GLFW_VERSION_MINOR 2 -/*! @brief The revision number of the GLFW library. - * - * This is incremented when a bug fix release is made that does not contain any - * API changes. - * @ingroup init - */ -#define GLFW_VERSION_REVISION 0 -/*! @} */ - -/*! @name Boolean values - * @{ */ -/*! @brief One. - * - * One. Seriously. You don't _need_ to use this symbol in your code. It's - * just semantic sugar for the number 1. You can use `1` or `true` or `_True` - * or `GL_TRUE` or whatever you want. - */ -#define GLFW_TRUE 1 -/*! @brief Zero. - * - * Zero. Seriously. You don't _need_ to use this symbol in your code. It's - * just just semantic sugar for the number 0. You can use `0` or `false` or - * `_False` or `GL_FALSE` or whatever you want. - */ -#define GLFW_FALSE 0 -/*! @} */ - -/*! @name Key and button actions - * @{ */ -/*! @brief The key or mouse button was released. - * - * The key or mouse button was released. - * - * @ingroup input - */ -#define GLFW_RELEASE 0 -/*! @brief The key or mouse button was pressed. - * - * The key or mouse button was pressed. - * - * @ingroup input - */ -#define GLFW_PRESS 1 -/*! @brief The key was held down until it repeated. - * - * The key was held down until it repeated. - * - * @ingroup input - */ -#define GLFW_REPEAT 2 -/*! @} */ - -/*! @defgroup keys Keyboard keys - * - * See [key input](@ref input_key) for how these are used. - * - * These key codes are inspired by the _USB HID Usage Tables v1.12_ (p. 53-60), - * but re-arranged to map to 7-bit ASCII for printable keys (function keys are - * put in the 256+ range). - * - * The naming of the key codes follow these rules: - * - The US keyboard layout is used - * - Names of printable alpha-numeric characters are used (e.g. "A", "R", - * "3", etc.) - * - For non-alphanumeric characters, Unicode:ish names are used (e.g. - * "COMMA", "LEFT_SQUARE_BRACKET", etc.). Note that some names do not - * correspond to the Unicode standard (usually for brevity) - * - Keys that lack a clear US mapping are named "WORLD_x" - * - For non-printable keys, custom names are used (e.g. "F4", - * "BACKSPACE", etc.) - * - * @ingroup input - * @{ - */ - -/* The unknown key */ -#define GLFW_KEY_UNKNOWN -1 - -/* Printable keys */ -#define GLFW_KEY_SPACE 32 -#define GLFW_KEY_APOSTROPHE 39 /* ' */ -#define GLFW_KEY_COMMA 44 /* , */ -#define GLFW_KEY_MINUS 45 /* - */ -#define GLFW_KEY_PERIOD 46 /* . */ -#define GLFW_KEY_SLASH 47 /* / */ -#define GLFW_KEY_0 48 -#define GLFW_KEY_1 49 -#define GLFW_KEY_2 50 -#define GLFW_KEY_3 51 -#define GLFW_KEY_4 52 -#define GLFW_KEY_5 53 -#define GLFW_KEY_6 54 -#define GLFW_KEY_7 55 -#define GLFW_KEY_8 56 -#define GLFW_KEY_9 57 -#define GLFW_KEY_SEMICOLON 59 /* ; */ -#define GLFW_KEY_EQUAL 61 /* = */ -#define GLFW_KEY_A 65 -#define GLFW_KEY_B 66 -#define GLFW_KEY_C 67 -#define GLFW_KEY_D 68 -#define GLFW_KEY_E 69 -#define GLFW_KEY_F 70 -#define GLFW_KEY_G 71 -#define GLFW_KEY_H 72 -#define GLFW_KEY_I 73 -#define GLFW_KEY_J 74 -#define GLFW_KEY_K 75 -#define GLFW_KEY_L 76 -#define GLFW_KEY_M 77 -#define GLFW_KEY_N 78 -#define GLFW_KEY_O 79 -#define GLFW_KEY_P 80 -#define GLFW_KEY_Q 81 -#define GLFW_KEY_R 82 -#define GLFW_KEY_S 83 -#define GLFW_KEY_T 84 -#define GLFW_KEY_U 85 -#define GLFW_KEY_V 86 -#define GLFW_KEY_W 87 -#define GLFW_KEY_X 88 -#define GLFW_KEY_Y 89 -#define GLFW_KEY_Z 90 -#define GLFW_KEY_LEFT_BRACKET 91 /* [ */ -#define GLFW_KEY_BACKSLASH 92 /* \ */ -#define GLFW_KEY_RIGHT_BRACKET 93 /* ] */ -#define GLFW_KEY_GRAVE_ACCENT 96 /* ` */ -#define GLFW_KEY_WORLD_1 161 /* non-US #1 */ -#define GLFW_KEY_WORLD_2 162 /* non-US #2 */ - -/* Function keys */ -#define GLFW_KEY_ESCAPE 256 -#define GLFW_KEY_ENTER 257 -#define GLFW_KEY_TAB 258 -#define GLFW_KEY_BACKSPACE 259 -#define GLFW_KEY_INSERT 260 -#define GLFW_KEY_DELETE 261 -#define GLFW_KEY_RIGHT 262 -#define GLFW_KEY_LEFT 263 -#define GLFW_KEY_DOWN 264 -#define GLFW_KEY_UP 265 -#define GLFW_KEY_PAGE_UP 266 -#define GLFW_KEY_PAGE_DOWN 267 -#define GLFW_KEY_HOME 268 -#define GLFW_KEY_END 269 -#define GLFW_KEY_CAPS_LOCK 280 -#define GLFW_KEY_SCROLL_LOCK 281 -#define GLFW_KEY_NUM_LOCK 282 -#define GLFW_KEY_PRINT_SCREEN 283 -#define GLFW_KEY_PAUSE 284 -#define GLFW_KEY_F1 290 -#define GLFW_KEY_F2 291 -#define GLFW_KEY_F3 292 -#define GLFW_KEY_F4 293 -#define GLFW_KEY_F5 294 -#define GLFW_KEY_F6 295 -#define GLFW_KEY_F7 296 -#define GLFW_KEY_F8 297 -#define GLFW_KEY_F9 298 -#define GLFW_KEY_F10 299 -#define GLFW_KEY_F11 300 -#define GLFW_KEY_F12 301 -#define GLFW_KEY_F13 302 -#define GLFW_KEY_F14 303 -#define GLFW_KEY_F15 304 -#define GLFW_KEY_F16 305 -#define GLFW_KEY_F17 306 -#define GLFW_KEY_F18 307 -#define GLFW_KEY_F19 308 -#define GLFW_KEY_F20 309 -#define GLFW_KEY_F21 310 -#define GLFW_KEY_F22 311 -#define GLFW_KEY_F23 312 -#define GLFW_KEY_F24 313 -#define GLFW_KEY_F25 314 -#define GLFW_KEY_KP_0 320 -#define GLFW_KEY_KP_1 321 -#define GLFW_KEY_KP_2 322 -#define GLFW_KEY_KP_3 323 -#define GLFW_KEY_KP_4 324 -#define GLFW_KEY_KP_5 325 -#define GLFW_KEY_KP_6 326 -#define GLFW_KEY_KP_7 327 -#define GLFW_KEY_KP_8 328 -#define GLFW_KEY_KP_9 329 -#define GLFW_KEY_KP_DECIMAL 330 -#define GLFW_KEY_KP_DIVIDE 331 -#define GLFW_KEY_KP_MULTIPLY 332 -#define GLFW_KEY_KP_SUBTRACT 333 -#define GLFW_KEY_KP_ADD 334 -#define GLFW_KEY_KP_ENTER 335 -#define GLFW_KEY_KP_EQUAL 336 -#define GLFW_KEY_LEFT_SHIFT 340 -#define GLFW_KEY_LEFT_CONTROL 341 -#define GLFW_KEY_LEFT_ALT 342 -#define GLFW_KEY_LEFT_SUPER 343 -#define GLFW_KEY_RIGHT_SHIFT 344 -#define GLFW_KEY_RIGHT_CONTROL 345 -#define GLFW_KEY_RIGHT_ALT 346 -#define GLFW_KEY_RIGHT_SUPER 347 -#define GLFW_KEY_MENU 348 - -#define GLFW_KEY_LAST GLFW_KEY_MENU - -/*! @} */ - -/*! @defgroup mods Modifier key flags - * - * See [key input](@ref input_key) for how these are used. - * - * @ingroup input - * @{ */ - -/*! @brief If this bit is set one or more Shift keys were held down. - */ -#define GLFW_MOD_SHIFT 0x0001 -/*! @brief If this bit is set one or more Control keys were held down. - */ -#define GLFW_MOD_CONTROL 0x0002 -/*! @brief If this bit is set one or more Alt keys were held down. - */ -#define GLFW_MOD_ALT 0x0004 -/*! @brief If this bit is set one or more Super keys were held down. - */ -#define GLFW_MOD_SUPER 0x0008 - -/*! @} */ - -/*! @defgroup buttons Mouse buttons - * - * See [mouse button input](@ref input_mouse_button) for how these are used. - * - * @ingroup input - * @{ */ -#define GLFW_MOUSE_BUTTON_1 0 -#define GLFW_MOUSE_BUTTON_2 1 -#define GLFW_MOUSE_BUTTON_3 2 -#define GLFW_MOUSE_BUTTON_4 3 -#define GLFW_MOUSE_BUTTON_5 4 -#define GLFW_MOUSE_BUTTON_6 5 -#define GLFW_MOUSE_BUTTON_7 6 -#define GLFW_MOUSE_BUTTON_8 7 -#define GLFW_MOUSE_BUTTON_LAST GLFW_MOUSE_BUTTON_8 -#define GLFW_MOUSE_BUTTON_LEFT GLFW_MOUSE_BUTTON_1 -#define GLFW_MOUSE_BUTTON_RIGHT GLFW_MOUSE_BUTTON_2 -#define GLFW_MOUSE_BUTTON_MIDDLE GLFW_MOUSE_BUTTON_3 -/*! @} */ - -/*! @defgroup joysticks Joysticks - * - * See [joystick input](@ref joystick) for how these are used. - * - * @ingroup input - * @{ */ -#define GLFW_JOYSTICK_1 0 -#define GLFW_JOYSTICK_2 1 -#define GLFW_JOYSTICK_3 2 -#define GLFW_JOYSTICK_4 3 -#define GLFW_JOYSTICK_5 4 -#define GLFW_JOYSTICK_6 5 -#define GLFW_JOYSTICK_7 6 -#define GLFW_JOYSTICK_8 7 -#define GLFW_JOYSTICK_9 8 -#define GLFW_JOYSTICK_10 9 -#define GLFW_JOYSTICK_11 10 -#define GLFW_JOYSTICK_12 11 -#define GLFW_JOYSTICK_13 12 -#define GLFW_JOYSTICK_14 13 -#define GLFW_JOYSTICK_15 14 -#define GLFW_JOYSTICK_16 15 -#define GLFW_JOYSTICK_LAST GLFW_JOYSTICK_16 -/*! @} */ - -/*! @defgroup errors Error codes - * - * See [error handling](@ref error_handling) for how these are used. - * - * @ingroup init - * @{ */ -/*! @brief GLFW has not been initialized. - * - * This occurs if a GLFW function was called that must not be called unless the - * library is [initialized](@ref intro_init). - * - * @analysis Application programmer error. Initialize GLFW before calling any - * function that requires initialization. - */ -#define GLFW_NOT_INITIALIZED 0x00010001 -/*! @brief No context is current for this thread. - * - * This occurs if a GLFW function was called that needs and operates on the - * current OpenGL or OpenGL ES context but no context is current on the calling - * thread. One such function is @ref glfwSwapInterval. - * - * @analysis Application programmer error. Ensure a context is current before - * calling functions that require a current context. - */ -#define GLFW_NO_CURRENT_CONTEXT 0x00010002 -/*! @brief One of the arguments to the function was an invalid enum value. - * - * One of the arguments to the function was an invalid enum value, for example - * requesting [GLFW_RED_BITS](@ref window_hints_fb) with @ref - * glfwGetWindowAttrib. - * - * @analysis Application programmer error. Fix the offending call. - */ -#define GLFW_INVALID_ENUM 0x00010003 -/*! @brief One of the arguments to the function was an invalid value. - * - * One of the arguments to the function was an invalid value, for example - * requesting a non-existent OpenGL or OpenGL ES version like 2.7. - * - * Requesting a valid but unavailable OpenGL or OpenGL ES version will instead - * result in a @ref GLFW_VERSION_UNAVAILABLE error. - * - * @analysis Application programmer error. Fix the offending call. - */ -#define GLFW_INVALID_VALUE 0x00010004 -/*! @brief A memory allocation failed. - * - * A memory allocation failed. - * - * @analysis A bug in GLFW or the underlying operating system. Report the bug - * to our [issue tracker](https://github.com/glfw/glfw/issues). - */ -#define GLFW_OUT_OF_MEMORY 0x00010005 -/*! @brief GLFW could not find support for the requested API on the system. - * - * GLFW could not find support for the requested API on the system. - * - * @analysis The installed graphics driver does not support the requested - * API, or does not support it via the chosen context creation backend. - * Below are a few examples. - * - * @par - * Some pre-installed Windows graphics drivers do not support OpenGL. AMD only - * supports OpenGL ES via EGL, while Nvidia and Intel only support it via - * a WGL or GLX extension. OS X does not provide OpenGL ES at all. The Mesa - * EGL, OpenGL and OpenGL ES libraries do not interface with the Nvidia binary - * driver. Older graphics drivers do not support Vulkan. - */ -#define GLFW_API_UNAVAILABLE 0x00010006 -/*! @brief The requested OpenGL or OpenGL ES version is not available. - * - * The requested OpenGL or OpenGL ES version (including any requested context - * or framebuffer hints) is not available on this machine. - * - * @analysis The machine does not support your requirements. If your - * application is sufficiently flexible, downgrade your requirements and try - * again. Otherwise, inform the user that their machine does not match your - * requirements. - * - * @par - * Future invalid OpenGL and OpenGL ES versions, for example OpenGL 4.8 if 5.0 - * comes out before the 4.x series gets that far, also fail with this error and - * not @ref GLFW_INVALID_VALUE, because GLFW cannot know what future versions - * will exist. - */ -#define GLFW_VERSION_UNAVAILABLE 0x00010007 -/*! @brief A platform-specific error occurred that does not match any of the - * more specific categories. - * - * A platform-specific error occurred that does not match any of the more - * specific categories. - * - * @analysis A bug or configuration error in GLFW, the underlying operating - * system or its drivers, or a lack of required resources. Report the issue to - * our [issue tracker](https://github.com/glfw/glfw/issues). - */ -#define GLFW_PLATFORM_ERROR 0x00010008 -/*! @brief The requested format is not supported or available. - * - * If emitted during window creation, the requested pixel format is not - * supported. - * - * If emitted when querying the clipboard, the contents of the clipboard could - * not be converted to the requested format. - * - * @analysis If emitted during window creation, one or more - * [hard constraints](@ref window_hints_hard) did not match any of the - * available pixel formats. If your application is sufficiently flexible, - * downgrade your requirements and try again. Otherwise, inform the user that - * their machine does not match your requirements. - * - * @par - * If emitted when querying the clipboard, ignore the error or report it to - * the user, as appropriate. - */ -#define GLFW_FORMAT_UNAVAILABLE 0x00010009 -/*! @brief The specified window does not have an OpenGL or OpenGL ES context. - * - * A window that does not have an OpenGL or OpenGL ES context was passed to - * a function that requires it to have one. - * - * @analysis Application programmer error. Fix the offending call. - */ -#define GLFW_NO_WINDOW_CONTEXT 0x0001000A -/*! @} */ - -#define GLFW_FOCUSED 0x00020001 -#define GLFW_ICONIFIED 0x00020002 -#define GLFW_RESIZABLE 0x00020003 -#define GLFW_VISIBLE 0x00020004 -#define GLFW_DECORATED 0x00020005 -#define GLFW_AUTO_ICONIFY 0x00020006 -#define GLFW_FLOATING 0x00020007 -#define GLFW_MAXIMIZED 0x00020008 - -#define GLFW_RED_BITS 0x00021001 -#define GLFW_GREEN_BITS 0x00021002 -#define GLFW_BLUE_BITS 0x00021003 -#define GLFW_ALPHA_BITS 0x00021004 -#define GLFW_DEPTH_BITS 0x00021005 -#define GLFW_STENCIL_BITS 0x00021006 -#define GLFW_ACCUM_RED_BITS 0x00021007 -#define GLFW_ACCUM_GREEN_BITS 0x00021008 -#define GLFW_ACCUM_BLUE_BITS 0x00021009 -#define GLFW_ACCUM_ALPHA_BITS 0x0002100A -#define GLFW_AUX_BUFFERS 0x0002100B -#define GLFW_STEREO 0x0002100C -#define GLFW_SAMPLES 0x0002100D -#define GLFW_SRGB_CAPABLE 0x0002100E -#define GLFW_REFRESH_RATE 0x0002100F -#define GLFW_DOUBLEBUFFER 0x00021010 - -#define GLFW_CLIENT_API 0x00022001 -#define GLFW_CONTEXT_VERSION_MAJOR 0x00022002 -#define GLFW_CONTEXT_VERSION_MINOR 0x00022003 -#define GLFW_CONTEXT_REVISION 0x00022004 -#define GLFW_CONTEXT_ROBUSTNESS 0x00022005 -#define GLFW_OPENGL_FORWARD_COMPAT 0x00022006 -#define GLFW_OPENGL_DEBUG_CONTEXT 0x00022007 -#define GLFW_OPENGL_PROFILE 0x00022008 -#define GLFW_CONTEXT_RELEASE_BEHAVIOR 0x00022009 -#define GLFW_CONTEXT_NO_ERROR 0x0002200A - -#define GLFW_NO_API 0 -#define GLFW_OPENGL_API 0x00030001 -#define GLFW_OPENGL_ES_API 0x00030002 - -#define GLFW_NO_ROBUSTNESS 0 -#define GLFW_NO_RESET_NOTIFICATION 0x00031001 -#define GLFW_LOSE_CONTEXT_ON_RESET 0x00031002 - -#define GLFW_OPENGL_ANY_PROFILE 0 -#define GLFW_OPENGL_CORE_PROFILE 0x00032001 -#define GLFW_OPENGL_COMPAT_PROFILE 0x00032002 - -#define GLFW_CURSOR 0x00033001 -#define GLFW_STICKY_KEYS 0x00033002 -#define GLFW_STICKY_MOUSE_BUTTONS 0x00033003 - -#define GLFW_CURSOR_NORMAL 0x00034001 -#define GLFW_CURSOR_HIDDEN 0x00034002 -#define GLFW_CURSOR_DISABLED 0x00034003 - -#define GLFW_ANY_RELEASE_BEHAVIOR 0 -#define GLFW_RELEASE_BEHAVIOR_FLUSH 0x00035001 -#define GLFW_RELEASE_BEHAVIOR_NONE 0x00035002 - -/*! @defgroup shapes Standard cursor shapes - * - * See [standard cursor creation](@ref cursor_standard) for how these are used. - * - * @ingroup input - * @{ */ - -/*! @brief The regular arrow cursor shape. - * - * The regular arrow cursor. - */ -#define GLFW_ARROW_CURSOR 0x00036001 -/*! @brief The text input I-beam cursor shape. - * - * The text input I-beam cursor shape. - */ -#define GLFW_IBEAM_CURSOR 0x00036002 -/*! @brief The crosshair shape. - * - * The crosshair shape. - */ -#define GLFW_CROSSHAIR_CURSOR 0x00036003 -/*! @brief The hand shape. - * - * The hand shape. - */ -#define GLFW_HAND_CURSOR 0x00036004 -/*! @brief The horizontal resize arrow shape. - * - * The horizontal resize arrow shape. - */ -#define GLFW_HRESIZE_CURSOR 0x00036005 -/*! @brief The vertical resize arrow shape. - * - * The vertical resize arrow shape. - */ -#define GLFW_VRESIZE_CURSOR 0x00036006 -/*! @} */ - -#define GLFW_CONNECTED 0x00040001 -#define GLFW_DISCONNECTED 0x00040002 - -#define GLFW_DONT_CARE -1 - - -/************************************************************************* - * GLFW API types - *************************************************************************/ - -/*! @brief Client API function pointer type. - * - * Generic function pointer used for returning client API function pointers - * without forcing a cast from a regular pointer. - * - * @sa @ref context_glext - * @sa glfwGetProcAddress - * - * @since Added in version 3.0. - - * @ingroup context - */ -typedef void (*GLFWglproc)(void); - -/*! @brief Vulkan API function pointer type. - * - * Generic function pointer used for returning Vulkan API function pointers - * without forcing a cast from a regular pointer. - * - * @sa @ref vulkan_proc - * @sa glfwGetInstanceProcAddress - * - * @since Added in version 3.2. - * - * @ingroup vulkan - */ -typedef void (*GLFWvkproc)(void); - -/*! @brief Opaque monitor object. - * - * Opaque monitor object. - * - * @see @ref monitor_object - * - * @since Added in version 3.0. - * - * @ingroup monitor - */ -typedef struct GLFWmonitor GLFWmonitor; - -/*! @brief Opaque window object. - * - * Opaque window object. - * - * @see @ref window_object - * - * @since Added in version 3.0. - * - * @ingroup window - */ -typedef struct GLFWwindow GLFWwindow; - -/*! @brief Opaque cursor object. - * - * Opaque cursor object. - * - * @see @ref cursor_object - * - * @since Added in version 3.1. - * - * @ingroup cursor - */ -typedef struct GLFWcursor GLFWcursor; - -/*! @brief The function signature for error callbacks. - * - * This is the function signature for error callback functions. - * - * @param[in] error An [error code](@ref errors). - * @param[in] description A UTF-8 encoded string describing the error. - * - * @sa @ref error_handling - * @sa glfwSetErrorCallback - * - * @since Added in version 3.0. - * - * @ingroup init - */ -typedef void (* GLFWerrorfun)(int,const char*); - -/*! @brief The function signature for window position callbacks. - * - * This is the function signature for window position callback functions. - * - * @param[in] window The window that was moved. - * @param[in] xpos The new x-coordinate, in screen coordinates, of the - * upper-left corner of the client area of the window. - * @param[in] ypos The new y-coordinate, in screen coordinates, of the - * upper-left corner of the client area of the window. - * - * @sa @ref window_pos - * @sa glfwSetWindowPosCallback - * - * @since Added in version 3.0. - * - * @ingroup window - */ -typedef void (* GLFWwindowposfun)(GLFWwindow*,int,int); - -/*! @brief The function signature for window resize callbacks. - * - * This is the function signature for window size callback functions. - * - * @param[in] window The window that was resized. - * @param[in] width The new width, in screen coordinates, of the window. - * @param[in] height The new height, in screen coordinates, of the window. - * - * @sa @ref window_size - * @sa glfwSetWindowSizeCallback - * - * @since Added in version 1.0. - * @glfw3 Added window handle parameter. - * - * @ingroup window - */ -typedef void (* GLFWwindowsizefun)(GLFWwindow*,int,int); - -/*! @brief The function signature for window close callbacks. - * - * This is the function signature for window close callback functions. - * - * @param[in] window The window that the user attempted to close. - * - * @sa @ref window_close - * @sa glfwSetWindowCloseCallback - * - * @since Added in version 2.5. - * @glfw3 Added window handle parameter. - * - * @ingroup window - */ -typedef void (* GLFWwindowclosefun)(GLFWwindow*); - -/*! @brief The function signature for window content refresh callbacks. - * - * This is the function signature for window refresh callback functions. - * - * @param[in] window The window whose content needs to be refreshed. - * - * @sa @ref window_refresh - * @sa glfwSetWindowRefreshCallback - * - * @since Added in version 2.5. - * @glfw3 Added window handle parameter. - * - * @ingroup window - */ -typedef void (* GLFWwindowrefreshfun)(GLFWwindow*); - -/*! @brief The function signature for window focus/defocus callbacks. - * - * This is the function signature for window focus callback functions. - * - * @param[in] window The window that gained or lost input focus. - * @param[in] focused `GLFW_TRUE` if the window was given input focus, or - * `GLFW_FALSE` if it lost it. - * - * @sa @ref window_focus - * @sa glfwSetWindowFocusCallback - * - * @since Added in version 3.0. - * - * @ingroup window - */ -typedef void (* GLFWwindowfocusfun)(GLFWwindow*,int); - -/*! @brief The function signature for window iconify/restore callbacks. - * - * This is the function signature for window iconify/restore callback - * functions. - * - * @param[in] window The window that was iconified or restored. - * @param[in] iconified `GLFW_TRUE` if the window was iconified, or - * `GLFW_FALSE` if it was restored. - * - * @sa @ref window_iconify - * @sa glfwSetWindowIconifyCallback - * - * @since Added in version 3.0. - * - * @ingroup window - */ -typedef void (* GLFWwindowiconifyfun)(GLFWwindow*,int); - -/*! @brief The function signature for framebuffer resize callbacks. - * - * This is the function signature for framebuffer resize callback - * functions. - * - * @param[in] window The window whose framebuffer was resized. - * @param[in] width The new width, in pixels, of the framebuffer. - * @param[in] height The new height, in pixels, of the framebuffer. - * - * @sa @ref window_fbsize - * @sa glfwSetFramebufferSizeCallback - * - * @since Added in version 3.0. - * - * @ingroup window - */ -typedef void (* GLFWframebuffersizefun)(GLFWwindow*,int,int); - -/*! @brief The function signature for mouse button callbacks. - * - * This is the function signature for mouse button callback functions. - * - * @param[in] window The window that received the event. - * @param[in] button The [mouse button](@ref buttons) that was pressed or - * released. - * @param[in] action One of `GLFW_PRESS` or `GLFW_RELEASE`. - * @param[in] mods Bit field describing which [modifier keys](@ref mods) were - * held down. - * - * @sa @ref input_mouse_button - * @sa glfwSetMouseButtonCallback - * - * @since Added in version 1.0. - * @glfw3 Added window handle and modifier mask parameters. - * - * @ingroup input - */ -typedef void (* GLFWmousebuttonfun)(GLFWwindow*,int,int,int); - -/*! @brief The function signature for cursor position callbacks. - * - * This is the function signature for cursor position callback functions. - * - * @param[in] window The window that received the event. - * @param[in] xpos The new cursor x-coordinate, relative to the left edge of - * the client area. - * @param[in] ypos The new cursor y-coordinate, relative to the top edge of the - * client area. - * - * @sa @ref cursor_pos - * @sa glfwSetCursorPosCallback - * - * @since Added in version 3.0. Replaces `GLFWmouseposfun`. - * - * @ingroup input - */ -typedef void (* GLFWcursorposfun)(GLFWwindow*,double,double); - -/*! @brief The function signature for cursor enter/leave callbacks. - * - * This is the function signature for cursor enter/leave callback functions. - * - * @param[in] window The window that received the event. - * @param[in] entered `GLFW_TRUE` if the cursor entered the window's client - * area, or `GLFW_FALSE` if it left it. - * - * @sa @ref cursor_enter - * @sa glfwSetCursorEnterCallback - * - * @since Added in version 3.0. - * - * @ingroup input - */ -typedef void (* GLFWcursorenterfun)(GLFWwindow*,int); - -/*! @brief The function signature for scroll callbacks. - * - * This is the function signature for scroll callback functions. - * - * @param[in] window The window that received the event. - * @param[in] xoffset The scroll offset along the x-axis. - * @param[in] yoffset The scroll offset along the y-axis. - * - * @sa @ref scrolling - * @sa glfwSetScrollCallback - * - * @since Added in version 3.0. Replaces `GLFWmousewheelfun`. - * - * @ingroup input - */ -typedef void (* GLFWscrollfun)(GLFWwindow*,double,double); - -/*! @brief The function signature for keyboard key callbacks. - * - * This is the function signature for keyboard key callback functions. - * - * @param[in] window The window that received the event. - * @param[in] key The [keyboard key](@ref keys) that was pressed or released. - * @param[in] scancode The system-specific scancode of the key. - * @param[in] action `GLFW_PRESS`, `GLFW_RELEASE` or `GLFW_REPEAT`. - * @param[in] mods Bit field describing which [modifier keys](@ref mods) were - * held down. - * - * @sa @ref input_key - * @sa glfwSetKeyCallback - * - * @since Added in version 1.0. - * @glfw3 Added window handle, scancode and modifier mask parameters. - * - * @ingroup input - */ -typedef void (* GLFWkeyfun)(GLFWwindow*,int,int,int,int); - -/*! @brief The function signature for Unicode character callbacks. - * - * This is the function signature for Unicode character callback functions. - * - * @param[in] window The window that received the event. - * @param[in] codepoint The Unicode code point of the character. - * - * @sa @ref input_char - * @sa glfwSetCharCallback - * - * @since Added in version 2.4. - * @glfw3 Added window handle parameter. - * - * @ingroup input - */ -typedef void (* GLFWcharfun)(GLFWwindow*,unsigned int); - -/*! @brief The function signature for Unicode character with modifiers - * callbacks. - * - * This is the function signature for Unicode character with modifiers callback - * functions. It is called for each input character, regardless of what - * modifier keys are held down. - * - * @param[in] window The window that received the event. - * @param[in] codepoint The Unicode code point of the character. - * @param[in] mods Bit field describing which [modifier keys](@ref mods) were - * held down. - * - * @sa @ref input_char - * @sa glfwSetCharModsCallback - * - * @since Added in version 3.1. - * - * @ingroup input - */ -typedef void (* GLFWcharmodsfun)(GLFWwindow*,unsigned int,int); - -/*! @brief The function signature for file drop callbacks. - * - * This is the function signature for file drop callbacks. - * - * @param[in] window The window that received the event. - * @param[in] count The number of dropped files. - * @param[in] paths The UTF-8 encoded file and/or directory path names. - * - * @sa @ref path_drop - * @sa glfwSetDropCallback - * - * @since Added in version 3.1. - * - * @ingroup input - */ -typedef void (* GLFWdropfun)(GLFWwindow*,int,const char**); - -/*! @brief The function signature for monitor configuration callbacks. - * - * This is the function signature for monitor configuration callback functions. - * - * @param[in] monitor The monitor that was connected or disconnected. - * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. - * - * @sa @ref monitor_event - * @sa glfwSetMonitorCallback - * - * @since Added in version 3.0. - * - * @ingroup monitor - */ -typedef void (* GLFWmonitorfun)(GLFWmonitor*,int); - -/*! @brief The function signature for joystick configuration callbacks. - * - * This is the function signature for joystick configuration callback - * functions. - * - * @param[in] joy The joystick that was connected or disconnected. - * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. - * - * @sa @ref joystick_event - * @sa glfwSetJoystickCallback - * - * @since Added in version 3.2. - * - * @ingroup input - */ -typedef void (* GLFWjoystickfun)(int,int); - -/*! @brief Video mode type. - * - * This describes a single video mode. - * - * @sa @ref monitor_modes - * @sa glfwGetVideoMode glfwGetVideoModes - * - * @since Added in version 1.0. - * @glfw3 Added refresh rate member. - * - * @ingroup monitor - */ -typedef struct GLFWvidmode -{ - /*! The width, in screen coordinates, of the video mode. - */ - int width; - /*! The height, in screen coordinates, of the video mode. - */ - int height; - /*! The bit depth of the red channel of the video mode. - */ - int redBits; - /*! The bit depth of the green channel of the video mode. - */ - int greenBits; - /*! The bit depth of the blue channel of the video mode. - */ - int blueBits; - /*! The refresh rate, in Hz, of the video mode. - */ - int refreshRate; -} GLFWvidmode; - -/*! @brief Gamma ramp. - * - * This describes the gamma ramp for a monitor. - * - * @sa @ref monitor_gamma - * @sa glfwGetGammaRamp glfwSetGammaRamp - * - * @since Added in version 3.0. - * - * @ingroup monitor - */ -typedef struct GLFWgammaramp -{ - /*! An array of value describing the response of the red channel. - */ - unsigned short* red; - /*! An array of value describing the response of the green channel. - */ - unsigned short* green; - /*! An array of value describing the response of the blue channel. - */ - unsigned short* blue; - /*! The number of elements in each array. - */ - unsigned int size; -} GLFWgammaramp; - -/*! @brief Image data. - * - * @sa @ref cursor_custom - * - * @since Added in version 2.1. - * @glfw3 Removed format and bytes-per-pixel members. - */ -typedef struct GLFWimage -{ - /*! The width, in pixels, of this image. - */ - int width; - /*! The height, in pixels, of this image. - */ - int height; - /*! The pixel data of this image, arranged left-to-right, top-to-bottom. - */ - unsigned char* pixels; -} GLFWimage; - - -/************************************************************************* - * GLFW API functions - *************************************************************************/ - -/*! @brief Initializes the GLFW library. - * - * This function initializes the GLFW library. Before most GLFW functions can - * be used, GLFW must be initialized, and before an application terminates GLFW - * should be terminated in order to free any resources allocated during or - * after initialization. - * - * If this function fails, it calls @ref glfwTerminate before returning. If it - * succeeds, you should call @ref glfwTerminate before the application exits. - * - * Additional calls to this function after successful initialization but before - * termination will return `GLFW_TRUE` immediately. - * - * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an - * [error](@ref error_handling) occurred. - * - * @errors Possible errors include @ref GLFW_PLATFORM_ERROR. - * - * @remark @osx This function will change the current directory of the - * application to the `Contents/Resources` subdirectory of the application's - * bundle, if present. This can be disabled with a - * [compile-time option](@ref compile_options_osx). - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref intro_init - * @sa glfwTerminate - * - * @since Added in version 1.0. - * - * @ingroup init - */ -GLFWAPI int glfwInit(void); - -/*! @brief Terminates the GLFW library. - * - * This function destroys all remaining windows and cursors, restores any - * modified gamma ramps and frees any other allocated resources. Once this - * function is called, you must again call @ref glfwInit successfully before - * you will be able to use most GLFW functions. - * - * If GLFW has been successfully initialized, this function should be called - * before the application exits. If initialization fails, there is no need to - * call this function, as it is called by @ref glfwInit before it returns - * failure. - * - * @errors Possible errors include @ref GLFW_PLATFORM_ERROR. - * - * @remark This function may be called before @ref glfwInit. - * - * @warning The contexts of any remaining windows must not be current on any - * other thread when this function is called. - * - * @reentrancy This function must not be called from a callback. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref intro_init - * @sa glfwInit - * - * @since Added in version 1.0. - * - * @ingroup init - */ -GLFWAPI void glfwTerminate(void); - -/*! @brief Retrieves the version of the GLFW library. - * - * This function retrieves the major, minor and revision numbers of the GLFW - * library. It is intended for when you are using GLFW as a shared library and - * want to ensure that you are using the minimum required version. - * - * Any or all of the version arguments may be `NULL`. - * - * @param[out] major Where to store the major version number, or `NULL`. - * @param[out] minor Where to store the minor version number, or `NULL`. - * @param[out] rev Where to store the revision number, or `NULL`. - * - * @errors None. - * - * @remark This function may be called before @ref glfwInit. - * - * @thread_safety This function may be called from any thread. - * - * @sa @ref intro_version - * @sa glfwGetVersionString - * - * @since Added in version 1.0. - * - * @ingroup init - */ -GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev); - -/*! @brief Returns a string describing the compile-time configuration. - * - * This function returns the compile-time generated - * [version string](@ref intro_version_string) of the GLFW library binary. It - * describes the version, platform, compiler and any platform-specific - * compile-time options. It should not be confused with the OpenGL or OpenGL - * ES version string, queried with `glGetString`. - * - * __Do not use the version string__ to parse the GLFW library version. The - * @ref glfwGetVersion function provides the version of the running library - * binary in numerical format. - * - * @return The ASCII encoded GLFW version string. - * - * @errors None. - * - * @remark This function may be called before @ref glfwInit. - * - * @pointer_lifetime The returned string is static and compile-time generated. - * - * @thread_safety This function may be called from any thread. - * - * @sa @ref intro_version - * @sa glfwGetVersion - * - * @since Added in version 3.0. - * - * @ingroup init - */ -GLFWAPI const char* glfwGetVersionString(void); - -/*! @brief Sets the error callback. - * - * This function sets the error callback, which is called with an error code - * and a human-readable description each time a GLFW error occurs. - * - * The error callback is called on the thread where the error occurred. If you - * are using GLFW from multiple threads, your error callback needs to be - * written accordingly. - * - * Because the description string may have been generated specifically for that - * error, it is not guaranteed to be valid after the callback has returned. If - * you wish to use it after the callback returns, you need to make a copy. - * - * Once set, the error callback remains set even after the library has been - * terminated. - * - * @param[in] cbfun The new callback, or `NULL` to remove the currently set - * callback. - * @return The previously set callback, or `NULL` if no callback was set. - * - * @errors None. - * - * @remark This function may be called before @ref glfwInit. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref error_handling - * - * @since Added in version 3.0. - * - * @ingroup init - */ -GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun); - -/*! @brief Returns the currently connected monitors. - * - * This function returns an array of handles for all currently connected - * monitors. The primary monitor is always first in the returned array. If no - * monitors were found, this function returns `NULL`. - * - * @param[out] count Where to store the number of monitors in the returned - * array. This is set to zero if an error occurred. - * @return An array of monitor handles, or `NULL` if no monitors were found or - * if an [error](@ref error_handling) occurred. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @pointer_lifetime The returned array is allocated and freed by GLFW. You - * should not free it yourself. It is guaranteed to be valid only until the - * monitor configuration changes or the library is terminated. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref monitor_monitors - * @sa @ref monitor_event - * @sa glfwGetPrimaryMonitor - * - * @since Added in version 3.0. - * - * @ingroup monitor - */ -GLFWAPI GLFWmonitor** glfwGetMonitors(int* count); - -/*! @brief Returns the primary monitor. - * - * This function returns the primary monitor. This is usually the monitor - * where elements like the task bar or global menu bar are located. - * - * @return The primary monitor, or `NULL` if no monitors were found or if an - * [error](@ref error_handling) occurred. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @thread_safety This function must only be called from the main thread. - * - * @remark The primary monitor is always first in the array returned by @ref - * glfwGetMonitors. - * - * @sa @ref monitor_monitors - * @sa glfwGetMonitors - * - * @since Added in version 3.0. - * - * @ingroup monitor - */ -GLFWAPI GLFWmonitor* glfwGetPrimaryMonitor(void); - -/*! @brief Returns the position of the monitor's viewport on the virtual screen. - * - * This function returns the position, in screen coordinates, of the upper-left - * corner of the specified monitor. - * - * Any or all of the position arguments may be `NULL`. If an error occurs, all - * non-`NULL` position arguments will be set to zero. - * - * @param[in] monitor The monitor to query. - * @param[out] xpos Where to store the monitor x-coordinate, or `NULL`. - * @param[out] ypos Where to store the monitor y-coordinate, or `NULL`. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref monitor_properties - * - * @since Added in version 3.0. - * - * @ingroup monitor - */ -GLFWAPI void glfwGetMonitorPos(GLFWmonitor* monitor, int* xpos, int* ypos); - -/*! @brief Returns the physical size of the monitor. - * - * This function returns the size, in millimetres, of the display area of the - * specified monitor. - * - * Some systems do not provide accurate monitor size information, either - * because the monitor - * [EDID](https://en.wikipedia.org/wiki/Extended_display_identification_data) - * data is incorrect or because the driver does not report it accurately. - * - * Any or all of the size arguments may be `NULL`. If an error occurs, all - * non-`NULL` size arguments will be set to zero. - * - * @param[in] monitor The monitor to query. - * @param[out] widthMM Where to store the width, in millimetres, of the - * monitor's display area, or `NULL`. - * @param[out] heightMM Where to store the height, in millimetres, of the - * monitor's display area, or `NULL`. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @remark @win32 calculates the returned physical size from the - * current resolution and system DPI instead of querying the monitor EDID data. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref monitor_properties - * - * @since Added in version 3.0. - * - * @ingroup monitor - */ -GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor* monitor, int* widthMM, int* heightMM); - -/*! @brief Returns the name of the specified monitor. - * - * This function returns a human-readable name, encoded as UTF-8, of the - * specified monitor. The name typically reflects the make and model of the - * monitor and is not guaranteed to be unique among the connected monitors. - * - * @param[in] monitor The monitor to query. - * @return The UTF-8 encoded name of the monitor, or `NULL` if an - * [error](@ref error_handling) occurred. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @pointer_lifetime The returned string is allocated and freed by GLFW. You - * should not free it yourself. It is valid until the specified monitor is - * disconnected or the library is terminated. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref monitor_properties - * - * @since Added in version 3.0. - * - * @ingroup monitor - */ -GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor); - -/*! @brief Sets the monitor configuration callback. - * - * This function sets the monitor configuration callback, or removes the - * currently set callback. This is called when a monitor is connected to or - * disconnected from the system. - * - * @param[in] cbfun The new callback, or `NULL` to remove the currently set - * callback. - * @return The previously set callback, or `NULL` if no callback was set or the - * library had not been [initialized](@ref intro_init). - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref monitor_event - * - * @since Added in version 3.0. - * - * @ingroup monitor - */ -GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun); - -/*! @brief Returns the available video modes for the specified monitor. - * - * This function returns an array of all video modes supported by the specified - * monitor. The returned array is sorted in ascending order, first by color - * bit depth (the sum of all channel depths) and then by resolution area (the - * product of width and height). - * - * @param[in] monitor The monitor to query. - * @param[out] count Where to store the number of video modes in the returned - * array. This is set to zero if an error occurred. - * @return An array of video modes, or `NULL` if an - * [error](@ref error_handling) occurred. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @pointer_lifetime The returned array is allocated and freed by GLFW. You - * should not free it yourself. It is valid until the specified monitor is - * disconnected, this function is called again for that monitor or the library - * is terminated. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref monitor_modes - * @sa glfwGetVideoMode - * - * @since Added in version 1.0. - * @glfw3 Changed to return an array of modes for a specific monitor. - * - * @ingroup monitor - */ -GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count); - -/*! @brief Returns the current mode of the specified monitor. - * - * This function returns the current video mode of the specified monitor. If - * you have created a full screen window for that monitor, the return value - * will depend on whether that window is iconified. - * - * @param[in] monitor The monitor to query. - * @return The current mode of the monitor, or `NULL` if an - * [error](@ref error_handling) occurred. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @pointer_lifetime The returned array is allocated and freed by GLFW. You - * should not free it yourself. It is valid until the specified monitor is - * disconnected or the library is terminated. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref monitor_modes - * @sa glfwGetVideoModes - * - * @since Added in version 3.0. Replaces `glfwGetDesktopMode`. - * - * @ingroup monitor - */ -GLFWAPI const GLFWvidmode* glfwGetVideoMode(GLFWmonitor* monitor); - -/*! @brief Generates a gamma ramp and sets it for the specified monitor. - * - * This function generates a 256-element gamma ramp from the specified exponent - * and then calls @ref glfwSetGammaRamp with it. The value must be a finite - * number greater than zero. - * - * @param[in] monitor The monitor whose gamma ramp to set. - * @param[in] gamma The desired exponent. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref monitor_gamma - * - * @since Added in version 3.0. - * - * @ingroup monitor - */ -GLFWAPI void glfwSetGamma(GLFWmonitor* monitor, float gamma); - -/*! @brief Returns the current gamma ramp for the specified monitor. - * - * This function returns the current gamma ramp of the specified monitor. - * - * @param[in] monitor The monitor to query. - * @return The current gamma ramp, or `NULL` if an - * [error](@ref error_handling) occurred. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @pointer_lifetime The returned structure and its arrays are allocated and - * freed by GLFW. You should not free them yourself. They are valid until the - * specified monitor is disconnected, this function is called again for that - * monitor or the library is terminated. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref monitor_gamma - * - * @since Added in version 3.0. - * - * @ingroup monitor - */ -GLFWAPI const GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor* monitor); - -/*! @brief Sets the current gamma ramp for the specified monitor. - * - * This function sets the current gamma ramp for the specified monitor. The - * original gamma ramp for that monitor is saved by GLFW the first time this - * function is called and is restored by @ref glfwTerminate. - * - * @param[in] monitor The monitor whose gamma ramp to set. - * @param[in] ramp The gamma ramp to use. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @remark Gamma ramp sizes other than 256 are not supported by all platforms - * or graphics hardware. - * - * @remark @win32 The gamma ramp size must be 256. - * - * @pointer_lifetime The specified gamma ramp is copied before this function - * returns. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref monitor_gamma - * - * @since Added in version 3.0. - * - * @ingroup monitor - */ -GLFWAPI void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp); - -/*! @brief Resets all window hints to their default values. - * - * This function resets all window hints to their - * [default values](@ref window_hints_values). - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref window_hints - * @sa glfwWindowHint - * - * @since Added in version 3.0. - * - * @ingroup window - */ -GLFWAPI void glfwDefaultWindowHints(void); - -/*! @brief Sets the specified window hint to the desired value. - * - * This function sets hints for the next call to @ref glfwCreateWindow. The - * hints, once set, retain their values until changed by a call to @ref - * glfwWindowHint or @ref glfwDefaultWindowHints, or until the library is - * terminated. - * - * This function does not check whether the specified hint values are valid. - * If you set hints to invalid values this will instead be reported by the next - * call to @ref glfwCreateWindow. - * - * @param[in] hint The [window hint](@ref window_hints) to set. - * @param[in] value The new value of the window hint. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_INVALID_ENUM. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref window_hints - * @sa glfwDefaultWindowHints - * - * @since Added in version 3.0. Replaces `glfwOpenWindowHint`. - * - * @ingroup window - */ -GLFWAPI void glfwWindowHint(int hint, int value); - -/*! @brief Creates a window and its associated context. - * - * This function creates a window and its associated OpenGL or OpenGL ES - * context. Most of the options controlling how the window and its context - * should be created are specified with [window hints](@ref window_hints). - * - * Successful creation does not change which context is current. Before you - * can use the newly created context, you need to - * [make it current](@ref context_current). For information about the `share` - * parameter, see @ref context_sharing. - * - * The created window, framebuffer and context may differ from what you - * requested, as not all parameters and hints are - * [hard constraints](@ref window_hints_hard). This includes the size of the - * window, especially for full screen windows. To query the actual attributes - * of the created window, framebuffer and context, see @ref - * glfwGetWindowAttrib, @ref glfwGetWindowSize and @ref glfwGetFramebufferSize. - * - * To create a full screen window, you need to specify the monitor the window - * will cover. If no monitor is specified, the window will be windowed mode. - * Unless you have a way for the user to choose a specific monitor, it is - * recommended that you pick the primary monitor. For more information on how - * to query connected monitors, see @ref monitor_monitors. - * - * For full screen windows, the specified size becomes the resolution of the - * window's _desired video mode_. As long as a full screen window is not - * iconified, the supported video mode most closely matching the desired video - * mode is set for the specified monitor. For more information about full - * screen windows, including the creation of so called _windowed full screen_ - * or _borderless full screen_ windows, see @ref window_windowed_full_screen. - * - * By default, newly created windows use the placement recommended by the - * window system. To create the window at a specific position, make it - * initially invisible using the [GLFW_VISIBLE](@ref window_hints_wnd) window - * hint, set its [position](@ref window_pos) and then [show](@ref window_hide) - * it. - * - * As long as at least one full screen window is not iconified, the screensaver - * is prohibited from starting. - * - * Window systems put limits on window sizes. Very large or very small window - * dimensions may be overridden by the window system on creation. Check the - * actual [size](@ref window_size) after creation. - * - * The [swap interval](@ref buffer_swap) is not set during window creation and - * the initial value may vary depending on driver settings and defaults. - * - * @param[in] width The desired width, in screen coordinates, of the window. - * This must be greater than zero. - * @param[in] height The desired height, in screen coordinates, of the window. - * This must be greater than zero. - * @param[in] title The initial, UTF-8 encoded window title. - * @param[in] monitor The monitor to use for full screen mode, or `NULL` for - * windowed mode. - * @param[in] share The window whose context to share resources with, or `NULL` - * to not share resources. - * @return The handle of the created window, or `NULL` if an - * [error](@ref error_handling) occurred. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_API_UNAVAILABLE, @ref - * GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE and @ref - * GLFW_PLATFORM_ERROR. - * - * @remark @win32 Window creation will fail if the Microsoft GDI software - * OpenGL implementation is the only one available. - * - * @remark @win32 If the executable has an icon resource named `GLFW_ICON,` - * it will be set as the icon for the window. If no such icon is present, the - * `IDI_WINLOGO` icon will be used instead. - * - * @remark @win32 The context to share resources with must not be current on - * any other thread. - * - * @remark @osx The GLFW window has no icon, as it is not a document - * window, but the dock icon will be the same as the application bundle's icon. - * For more information on bundles, see the - * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/) - * in the Mac Developer Library. - * - * @remark @osx The first time a window is created the menu bar is populated - * with common commands like Hide, Quit and About. The About entry opens - * a minimal about dialog with information from the application's bundle. The - * menu bar can be disabled with a - * [compile-time option](@ref compile_options_osx). - * - * @remark @osx On OS X 10.10 and later the window frame will not be rendered - * at full resolution on Retina displays unless the `NSHighResolutionCapable` - * key is enabled in the application bundle's `Info.plist`. For more - * information, see - * [High Resolution Guidelines for OS X](https://developer.apple.com/library/mac/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html) - * in the Mac Developer Library. The GLFW test and example programs use - * a custom `Info.plist` template for this, which can be found as - * `CMake/MacOSXBundleInfo.plist.in` in the source tree. - * - * @remark @x11 There is no mechanism for setting the window icon yet. - * - * @remark @x11 Some window managers will not respect the placement of - * initially hidden windows. - * - * @remark @x11 Due to the asynchronous nature of X11, it may take a moment for - * a window to reach its requested state. This means you may not be able to - * query the final size, position or other attributes directly after window - * creation. - * - * @reentrancy This function must not be called from a callback. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref window_creation - * @sa glfwDestroyWindow - * - * @since Added in version 3.0. Replaces `glfwOpenWindow`. - * - * @ingroup window - */ -GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, GLFWmonitor* monitor, GLFWwindow* share); - -/*! @brief Destroys the specified window and its context. - * - * This function destroys the specified window and its context. On calling - * this function, no further callbacks will be called for that window. - * - * If the context of the specified window is current on the main thread, it is - * detached before being destroyed. - * - * @param[in] window The window to destroy. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @note The context of the specified window must not be current on any other - * thread when this function is called. - * - * @reentrancy This function must not be called from a callback. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref window_creation - * @sa glfwCreateWindow - * - * @since Added in version 3.0. Replaces `glfwCloseWindow`. - * - * @ingroup window - */ -GLFWAPI void glfwDestroyWindow(GLFWwindow* window); - -/*! @brief Checks the close flag of the specified window. - * - * This function returns the value of the close flag of the specified window. - * - * @param[in] window The window to query. - * @return The value of the close flag. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @thread_safety This function may be called from any thread. Access is not - * synchronized. - * - * @sa @ref window_close - * - * @since Added in version 3.0. - * - * @ingroup window - */ -GLFWAPI int glfwWindowShouldClose(GLFWwindow* window); - -/*! @brief Sets the close flag of the specified window. - * - * This function sets the value of the close flag of the specified window. - * This can be used to override the user's attempt to close the window, or - * to signal that it should be closed. - * - * @param[in] window The window whose flag to change. - * @param[in] value The new value. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @thread_safety This function may be called from any thread. Access is not - * synchronized. - * - * @sa @ref window_close - * - * @since Added in version 3.0. - * - * @ingroup window - */ -GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value); - -/*! @brief Sets the title of the specified window. - * - * This function sets the window title, encoded as UTF-8, of the specified - * window. - * - * @param[in] window The window whose title to change. - * @param[in] title The UTF-8 encoded window title. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @remark @osx The window title will not be updated until the next time you - * process events. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref window_title - * - * @since Added in version 1.0. - * @glfw3 Added window handle parameter. - * - * @ingroup window - */ -GLFWAPI void glfwSetWindowTitle(GLFWwindow* window, const char* title); - -/*! @brief Sets the icon for the specified window. - * - * This function sets the icon of the specified window. If passed an array of - * candidate images, those of or closest to the sizes desired by the system are - * selected. If no images are specified, the window reverts to its default - * icon. - * - * The desired image sizes varies depending on platform and system settings. - * The selected images will be rescaled as needed. Good sizes include 16x16, - * 32x32 and 48x48. - * - * @param[in] window The window whose icon to set. - * @param[in] count The number of images in the specified array, or zero to - * revert to the default window icon. - * @param[in] images The images to create the icon from. This is ignored if - * count is zero. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @pointer_lifetime The specified image data is copied before this function - * returns. - * - * @remark @osx The GLFW window has no icon, as it is not a document - * window, but the dock icon will be the same as the application bundle's icon. - * For more information on bundles, see the - * [Bundle Programming Guide](https://developer.apple.com/library/mac/documentation/CoreFoundation/Conceptual/CFBundles/) - * in the Mac Developer Library. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref window_icon - * - * @since Added in version 3.2. - * - * @ingroup window - */ -GLFWAPI void glfwSetWindowIcon(GLFWwindow* window, int count, const GLFWimage* images); - -/*! @brief Retrieves the position of the client area of the specified window. - * - * This function retrieves the position, in screen coordinates, of the - * upper-left corner of the client area of the specified window. - * - * Any or all of the position arguments may be `NULL`. If an error occurs, all - * non-`NULL` position arguments will be set to zero. - * - * @param[in] window The window to query. - * @param[out] xpos Where to store the x-coordinate of the upper-left corner of - * the client area, or `NULL`. - * @param[out] ypos Where to store the y-coordinate of the upper-left corner of - * the client area, or `NULL`. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref window_pos - * @sa glfwSetWindowPos - * - * @since Added in version 3.0. - * - * @ingroup window - */ -GLFWAPI void glfwGetWindowPos(GLFWwindow* window, int* xpos, int* ypos); - -/*! @brief Sets the position of the client area of the specified window. - * - * This function sets the position, in screen coordinates, of the upper-left - * corner of the client area of the specified windowed mode window. If the - * window is a full screen window, this function does nothing. - * - * __Do not use this function__ to move an already visible window unless you - * have very good reasons for doing so, as it will confuse and annoy the user. - * - * The window manager may put limits on what positions are allowed. GLFW - * cannot and should not override these limits. - * - * @param[in] window The window to query. - * @param[in] xpos The x-coordinate of the upper-left corner of the client area. - * @param[in] ypos The y-coordinate of the upper-left corner of the client area. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref window_pos - * @sa glfwGetWindowPos - * - * @since Added in version 1.0. - * @glfw3 Added window handle parameter. - * - * @ingroup window - */ -GLFWAPI void glfwSetWindowPos(GLFWwindow* window, int xpos, int ypos); - -/*! @brief Retrieves the size of the client area of the specified window. - * - * This function retrieves the size, in screen coordinates, of the client area - * of the specified window. If you wish to retrieve the size of the - * framebuffer of the window in pixels, see @ref glfwGetFramebufferSize. - * - * Any or all of the size arguments may be `NULL`. If an error occurs, all - * non-`NULL` size arguments will be set to zero. - * - * @param[in] window The window whose size to retrieve. - * @param[out] width Where to store the width, in screen coordinates, of the - * client area, or `NULL`. - * @param[out] height Where to store the height, in screen coordinates, of the - * client area, or `NULL`. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref window_size - * @sa glfwSetWindowSize - * - * @since Added in version 1.0. - * @glfw3 Added window handle parameter. - * - * @ingroup window - */ -GLFWAPI void glfwGetWindowSize(GLFWwindow* window, int* width, int* height); - -/*! @brief Sets the size limits of the specified window. - * - * This function sets the size limits of the client area of the specified - * window. If the window is full screen, the size limits only take effect if - * once it is made windowed. If the window is not resizable, this function - * does nothing. - * - * The size limits are applied immediately to a windowed mode window and may - * cause it to be resized. - * - * @param[in] window The window to set limits for. - * @param[in] minwidth The minimum width, in screen coordinates, of the client - * area, or `GLFW_DONT_CARE`. - * @param[in] minheight The minimum height, in screen coordinates, of the - * client area, or `GLFW_DONT_CARE`. - * @param[in] maxwidth The maximum width, in screen coordinates, of the client - * area, or `GLFW_DONT_CARE`. - * @param[in] maxheight The maximum height, in screen coordinates, of the - * client area, or `GLFW_DONT_CARE`. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @remark If you set size limits and an aspect ratio that conflict, the - * results are undefined. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref window_sizelimits - * @sa glfwSetWindowAspectRatio - * - * @since Added in version 3.2. - * - * @ingroup window - */ -GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight); - -/*! @brief Sets the aspect ratio of the specified window. - * - * This function sets the required aspect ratio of the client area of the - * specified window. If the window is full screen, the aspect ratio only takes - * effect once it is made windowed. If the window is not resizable, this - * function does nothing. - * - * The aspect ratio is specified as a numerator and a denominator and both - * values must be greater than zero. For example, the common 16:9 aspect ratio - * is specified as 16 and 9, respectively. - * - * If the numerator and denominator is set to `GLFW_DONT_CARE` then the aspect - * ratio limit is disabled. - * - * The aspect ratio is applied immediately to a windowed mode window and may - * cause it to be resized. - * - * @param[in] window The window to set limits for. - * @param[in] numer The numerator of the desired aspect ratio, or - * `GLFW_DONT_CARE`. - * @param[in] denom The denominator of the desired aspect ratio, or - * `GLFW_DONT_CARE`. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR. - * - * @remark If you set size limits and an aspect ratio that conflict, the - * results are undefined. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref window_sizelimits - * @sa glfwSetWindowSizeLimits - * - * @since Added in version 3.2. - * - * @ingroup window - */ -GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* window, int numer, int denom); - -/*! @brief Sets the size of the client area of the specified window. - * - * This function sets the size, in screen coordinates, of the client area of - * the specified window. - * - * For full screen windows, this function updates the resolution of its desired - * video mode and switches to the video mode closest to it, without affecting - * the window's context. As the context is unaffected, the bit depths of the - * framebuffer remain unchanged. - * - * If you wish to update the refresh rate of the desired video mode in addition - * to its resolution, see @ref glfwSetWindowMonitor. - * - * The window manager may put limits on what sizes are allowed. GLFW cannot - * and should not override these limits. - * - * @param[in] window The window to resize. - * @param[in] width The desired width, in screen coordinates, of the window - * client area. - * @param[in] height The desired height, in screen coordinates, of the window - * client area. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref window_size - * @sa glfwGetWindowSize - * @sa glfwSetWindowMonitor - * - * @since Added in version 1.0. - * @glfw3 Added window handle parameter. - * - * @ingroup window - */ -GLFWAPI void glfwSetWindowSize(GLFWwindow* window, int width, int height); - -/*! @brief Retrieves the size of the framebuffer of the specified window. - * - * This function retrieves the size, in pixels, of the framebuffer of the - * specified window. If you wish to retrieve the size of the window in screen - * coordinates, see @ref glfwGetWindowSize. - * - * Any or all of the size arguments may be `NULL`. If an error occurs, all - * non-`NULL` size arguments will be set to zero. - * - * @param[in] window The window whose framebuffer to query. - * @param[out] width Where to store the width, in pixels, of the framebuffer, - * or `NULL`. - * @param[out] height Where to store the height, in pixels, of the framebuffer, - * or `NULL`. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref window_fbsize - * @sa glfwSetFramebufferSizeCallback - * - * @since Added in version 3.0. - * - * @ingroup window - */ -GLFWAPI void glfwGetFramebufferSize(GLFWwindow* window, int* width, int* height); - -/*! @brief Retrieves the size of the frame of the window. - * - * This function retrieves the size, in screen coordinates, of each edge of the - * frame of the specified window. This size includes the title bar, if the - * window has one. The size of the frame may vary depending on the - * [window-related hints](@ref window_hints_wnd) used to create it. - * - * Because this function retrieves the size of each window frame edge and not - * the offset along a particular coordinate axis, the retrieved values will - * always be zero or positive. - * - * Any or all of the size arguments may be `NULL`. If an error occurs, all - * non-`NULL` size arguments will be set to zero. - * - * @param[in] window The window whose frame size to query. - * @param[out] left Where to store the size, in screen coordinates, of the left - * edge of the window frame, or `NULL`. - * @param[out] top Where to store the size, in screen coordinates, of the top - * edge of the window frame, or `NULL`. - * @param[out] right Where to store the size, in screen coordinates, of the - * right edge of the window frame, or `NULL`. - * @param[out] bottom Where to store the size, in screen coordinates, of the - * bottom edge of the window frame, or `NULL`. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref window_size - * - * @since Added in version 3.1. - * - * @ingroup window - */ -GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* window, int* left, int* top, int* right, int* bottom); - -/*! @brief Iconifies the specified window. - * - * This function iconifies (minimizes) the specified window if it was - * previously restored. If the window is already iconified, this function does - * nothing. - * - * If the specified window is a full screen window, the original monitor - * resolution is restored until the window is restored. - * - * @param[in] window The window to iconify. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref window_iconify - * @sa glfwRestoreWindow - * @sa glfwMaximizeWindow - * - * @since Added in version 2.1. - * @glfw3 Added window handle parameter. - * - * @ingroup window - */ -GLFWAPI void glfwIconifyWindow(GLFWwindow* window); - -/*! @brief Restores the specified window. - * - * This function restores the specified window if it was previously iconified - * (minimized) or maximized. If the window is already restored, this function - * does nothing. - * - * If the specified window is a full screen window, the resolution chosen for - * the window is restored on the selected monitor. - * - * @param[in] window The window to restore. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref window_iconify - * @sa glfwIconifyWindow - * @sa glfwMaximizeWindow - * - * @since Added in version 2.1. - * @glfw3 Added window handle parameter. - * - * @ingroup window - */ -GLFWAPI void glfwRestoreWindow(GLFWwindow* window); - -/*! @brief Maximizes the specified window. - * - * This function maximizes the specified window if it was previously not - * maximized. If the window is already maximized, this function does nothing. - * - * If the specified window is a full screen window, this function does nothing. - * - * @param[in] window The window to maximize. - * - * @par Thread Safety - * This function may only be called from the main thread. - * - * @sa @ref window_iconify - * @sa glfwIconifyWindow - * @sa glfwRestoreWindow - * - * @since Added in GLFW 3.2. - * - * @ingroup window - */ -GLFWAPI void glfwMaximizeWindow(GLFWwindow* window); - -/*! @brief Makes the specified window visible. - * - * This function makes the specified window visible if it was previously - * hidden. If the window is already visible or is in full screen mode, this - * function does nothing. - * - * @param[in] window The window to make visible. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref window_hide - * @sa glfwHideWindow - * - * @since Added in version 3.0. - * - * @ingroup window - */ -GLFWAPI void glfwShowWindow(GLFWwindow* window); - -/*! @brief Hides the specified window. - * - * This function hides the specified window if it was previously visible. If - * the window is already hidden or is in full screen mode, this function does - * nothing. - * - * @param[in] window The window to hide. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref window_hide - * @sa glfwShowWindow - * - * @since Added in version 3.0. - * - * @ingroup window - */ -GLFWAPI void glfwHideWindow(GLFWwindow* window); - -/*! @brief Brings the specified window to front and sets input focus. - * - * This function brings the specified window to front and sets input focus. - * The window should already be visible and not iconified. - * - * By default, both windowed and full screen mode windows are focused when - * initially created. Set the [GLFW_FOCUSED](@ref window_hints_wnd) to disable - * this behavior. - * - * __Do not use this function__ to steal focus from other applications unless - * you are certain that is what the user wants. Focus stealing can be - * extremely disruptive. - * - * @param[in] window The window to give input focus. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref window_focus - * - * @since Added in version 3.2. - * - * @ingroup window - */ -GLFWAPI void glfwFocusWindow(GLFWwindow* window); - -/*! @brief Returns the monitor that the window uses for full screen mode. - * - * This function returns the handle of the monitor that the specified window is - * in full screen on. - * - * @param[in] window The window to query. - * @return The monitor, or `NULL` if the window is in windowed mode or an error - * occurred. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref window_monitor - * @sa glfwSetWindowMonitor - * - * @since Added in version 3.0. - * - * @ingroup window - */ -GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* window); - -/*! @brief Sets the mode, monitor, video mode and placement of a window. - * - * This function sets the monitor that the window uses for full screen mode or, - * if the monitor is `NULL`, makes it windowed mode. - * - * When setting a monitor, this function updates the width, height and refresh - * rate of the desired video mode and switches to the video mode closest to it. - * The window position is ignored when setting a monitor. - * - * When the monitor is `NULL`, the position, width and height are used to - * place the window client area. The refresh rate is ignored when no monitor - * is specified. - * - * If you only wish to update the resolution of a full screen window or the - * size of a windowed mode window, see @ref glfwSetWindowSize. - * - * When a window transitions from full screen to windowed mode, this function - * restores any previous window settings such as whether it is decorated, - * floating, resizable, has size or aspect ratio limits, etc.. - * - * @param[in] window The window whose monitor, size or video mode to set. - * @param[in] monitor The desired monitor, or `NULL` to set windowed mode. - * @param[in] xpos The desired x-coordinate of the upper-left corner of the - * client area. - * @param[in] ypos The desired y-coordinate of the upper-left corner of the - * client area. - * @param[in] width The desired with, in screen coordinates, of the client area - * or video mode. - * @param[in] height The desired height, in screen coordinates, of the client - * area or video mode. - * @param[in] refreshRate The desired refresh rate, in Hz, of the video mode. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref window_monitor - * @sa @ref window_full_screen - * @sa glfwGetWindowMonitor - * @sa glfwSetWindowSize - * - * @since Added in version 3.2. - * - * @ingroup window - */ -GLFWAPI void glfwSetWindowMonitor(GLFWwindow* window, GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate); - -/*! @brief Returns an attribute of the specified window. - * - * This function returns the value of an attribute of the specified window or - * its OpenGL or OpenGL ES context. - * - * @param[in] window The window to query. - * @param[in] attrib The [window attribute](@ref window_attribs) whose value to - * return. - * @return The value of the attribute, or zero if an - * [error](@ref error_handling) occurred. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR. - * - * @remark Framebuffer related hints are not window attributes. See @ref - * window_attribs_fb for more information. - * - * @remark Zero is a valid value for many window and context related - * attributes so you cannot use a return value of zero as an indication of - * errors. However, this function should not fail as long as it is passed - * valid arguments and the library has been [initialized](@ref intro_init). - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref window_attribs - * - * @since Added in version 3.0. Replaces `glfwGetWindowParam` and - * `glfwGetGLVersion`. - * - * @ingroup window - */ -GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib); - -/*! @brief Sets the user pointer of the specified window. - * - * This function sets the user-defined pointer of the specified window. The - * current value is retained until the window is destroyed. The initial value - * is `NULL`. - * - * @param[in] window The window whose pointer to set. - * @param[in] pointer The new value. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @thread_safety This function may be called from any thread. Access is not - * synchronized. - * - * @sa @ref window_userptr - * @sa glfwGetWindowUserPointer - * - * @since Added in version 3.0. - * - * @ingroup window - */ -GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* window, void* pointer); - -/*! @brief Returns the user pointer of the specified window. - * - * This function returns the current value of the user-defined pointer of the - * specified window. The initial value is `NULL`. - * - * @param[in] window The window whose pointer to return. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @thread_safety This function may be called from any thread. Access is not - * synchronized. - * - * @sa @ref window_userptr - * @sa glfwSetWindowUserPointer - * - * @since Added in version 3.0. - * - * @ingroup window - */ -GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window); - -/*! @brief Sets the position callback for the specified window. - * - * This function sets the position callback of the specified window, which is - * called when the window is moved. The callback is provided with the screen - * position of the upper-left corner of the client area of the window. - * - * @param[in] window The window whose callback to set. - * @param[in] cbfun The new callback, or `NULL` to remove the currently set - * callback. - * @return The previously set callback, or `NULL` if no callback was set or the - * library had not been [initialized](@ref intro_init). - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref window_pos - * - * @since Added in version 3.0. - * - * @ingroup window - */ -GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* window, GLFWwindowposfun cbfun); - -/*! @brief Sets the size callback for the specified window. - * - * This function sets the size callback of the specified window, which is - * called when the window is resized. The callback is provided with the size, - * in screen coordinates, of the client area of the window. - * - * @param[in] window The window whose callback to set. - * @param[in] cbfun The new callback, or `NULL` to remove the currently set - * callback. - * @return The previously set callback, or `NULL` if no callback was set or the - * library had not been [initialized](@ref intro_init). - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref window_size - * - * @since Added in version 1.0. - * @glfw3 Added window handle parameter and return value. - * - * @ingroup window - */ -GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun cbfun); - -/*! @brief Sets the close callback for the specified window. - * - * This function sets the close callback of the specified window, which is - * called when the user attempts to close the window, for example by clicking - * the close widget in the title bar. - * - * The close flag is set before this callback is called, but you can modify it - * at any time with @ref glfwSetWindowShouldClose. - * - * The close callback is not triggered by @ref glfwDestroyWindow. - * - * @param[in] window The window whose callback to set. - * @param[in] cbfun The new callback, or `NULL` to remove the currently set - * callback. - * @return The previously set callback, or `NULL` if no callback was set or the - * library had not been [initialized](@ref intro_init). - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @remark @osx Selecting Quit from the application menu will trigger the close - * callback for all windows. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref window_close - * - * @since Added in version 2.5. - * @glfw3 Added window handle parameter and return value. - * - * @ingroup window - */ -GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* window, GLFWwindowclosefun cbfun); - -/*! @brief Sets the refresh callback for the specified window. - * - * This function sets the refresh callback of the specified window, which is - * called when the client area of the window needs to be redrawn, for example - * if the window has been exposed after having been covered by another window. - * - * On compositing window systems such as Aero, Compiz or Aqua, where the window - * contents are saved off-screen, this callback may be called only very - * infrequently or never at all. - * - * @param[in] window The window whose callback to set. - * @param[in] cbfun The new callback, or `NULL` to remove the currently set - * callback. - * @return The previously set callback, or `NULL` if no callback was set or the - * library had not been [initialized](@ref intro_init). - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref window_refresh - * - * @since Added in version 2.5. - * @glfw3 Added window handle parameter and return value. - * - * @ingroup window - */ -GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* window, GLFWwindowrefreshfun cbfun); - -/*! @brief Sets the focus callback for the specified window. - * - * This function sets the focus callback of the specified window, which is - * called when the window gains or loses input focus. - * - * After the focus callback is called for a window that lost input focus, - * synthetic key and mouse button release events will be generated for all such - * that had been pressed. For more information, see @ref glfwSetKeyCallback - * and @ref glfwSetMouseButtonCallback. - * - * @param[in] window The window whose callback to set. - * @param[in] cbfun The new callback, or `NULL` to remove the currently set - * callback. - * @return The previously set callback, or `NULL` if no callback was set or the - * library had not been [initialized](@ref intro_init). - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref window_focus - * - * @since Added in version 3.0. - * - * @ingroup window - */ -GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* window, GLFWwindowfocusfun cbfun); - -/*! @brief Sets the iconify callback for the specified window. - * - * This function sets the iconification callback of the specified window, which - * is called when the window is iconified or restored. - * - * @param[in] window The window whose callback to set. - * @param[in] cbfun The new callback, or `NULL` to remove the currently set - * callback. - * @return The previously set callback, or `NULL` if no callback was set or the - * library had not been [initialized](@ref intro_init). - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref window_iconify - * - * @since Added in version 3.0. - * - * @ingroup window - */ -GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* window, GLFWwindowiconifyfun cbfun); - -/*! @brief Sets the framebuffer resize callback for the specified window. - * - * This function sets the framebuffer resize callback of the specified window, - * which is called when the framebuffer of the specified window is resized. - * - * @param[in] window The window whose callback to set. - * @param[in] cbfun The new callback, or `NULL` to remove the currently set - * callback. - * @return The previously set callback, or `NULL` if no callback was set or the - * library had not been [initialized](@ref intro_init). - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref window_fbsize - * - * @since Added in version 3.0. - * - * @ingroup window - */ -GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun cbfun); - -/*! @brief Processes all pending events. - * - * This function processes only those events that are already in the event - * queue and then returns immediately. Processing events will cause the window - * and input callbacks associated with those events to be called. - * - * On some platforms, a window move, resize or menu operation will cause event - * processing to block. This is due to how event processing is designed on - * those platforms. You can use the - * [window refresh callback](@ref window_refresh) to redraw the contents of - * your window when necessary during such operations. - * - * On some platforms, certain events are sent directly to the application - * without going through the event queue, causing callbacks to be called - * outside of a call to one of the event processing functions. - * - * Event processing is not required for joystick input to work. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @reentrancy This function must not be called from a callback. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref events - * @sa glfwWaitEvents - * @sa glfwWaitEventsTimeout - * - * @since Added in version 1.0. - * - * @ingroup window - */ -GLFWAPI void glfwPollEvents(void); - -/*! @brief Waits until events are queued and processes them. - * - * This function puts the calling thread to sleep until at least one event is - * available in the event queue. Once one or more events are available, - * it behaves exactly like @ref glfwPollEvents, i.e. the events in the queue - * are processed and the function then returns immediately. Processing events - * will cause the window and input callbacks associated with those events to be - * called. - * - * Since not all events are associated with callbacks, this function may return - * without a callback having been called even if you are monitoring all - * callbacks. - * - * On some platforms, a window move, resize or menu operation will cause event - * processing to block. This is due to how event processing is designed on - * those platforms. You can use the - * [window refresh callback](@ref window_refresh) to redraw the contents of - * your window when necessary during such operations. - * - * On some platforms, certain callbacks may be called outside of a call to one - * of the event processing functions. - * - * If no windows exist, this function returns immediately. For synchronization - * of threads in applications that do not create windows, use your threading - * library of choice. - * - * Event processing is not required for joystick input to work. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @reentrancy This function must not be called from a callback. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref events - * @sa glfwPollEvents - * @sa glfwWaitEventsTimeout - * - * @since Added in version 2.5. - * - * @ingroup window - */ -GLFWAPI void glfwWaitEvents(void); - -/*! @brief Waits with timeout until events are queued and processes them. - * - * This function puts the calling thread to sleep until at least one event is - * available in the event queue, or until the specified timeout is reached. If - * one or more events are available, it behaves exactly like @ref - * glfwPollEvents, i.e. the events in the queue are processed and the function - * then returns immediately. Processing events will cause the window and input - * callbacks associated with those events to be called. - * - * The timeout value must be a positive finite number. - * - * Since not all events are associated with callbacks, this function may return - * without a callback having been called even if you are monitoring all - * callbacks. - * - * On some platforms, a window move, resize or menu operation will cause event - * processing to block. This is due to how event processing is designed on - * those platforms. You can use the - * [window refresh callback](@ref window_refresh) to redraw the contents of - * your window when necessary during such operations. - * - * On some platforms, certain callbacks may be called outside of a call to one - * of the event processing functions. - * - * If no windows exist, this function returns immediately. For synchronization - * of threads in applications that do not create windows, use your threading - * library of choice. - * - * Event processing is not required for joystick input to work. - * - * @param[in] timeout The maximum amount of time, in seconds, to wait. - * - * @reentrancy This function must not be called from a callback. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref events - * @sa glfwPollEvents - * @sa glfwWaitEvents - * - * @since Added in version 3.2. - * - * @ingroup window - */ -GLFWAPI void glfwWaitEventsTimeout(double timeout); - -/*! @brief Posts an empty event to the event queue. - * - * This function posts an empty event from the current thread to the event - * queue, causing @ref glfwWaitEvents to return. - * - * If no windows exist, this function returns immediately. For synchronization - * of threads in applications that do not create windows, use your threading - * library of choice. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @thread_safety This function may be called from any thread. - * - * @sa @ref events - * @sa glfwWaitEvents - * - * @since Added in version 3.1. - * - * @ingroup window - */ -GLFWAPI void glfwPostEmptyEvent(void); - -/*! @brief Returns the value of an input option for the specified window. - * - * This function returns the value of an input option for the specified window. - * The mode must be one of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or - * `GLFW_STICKY_MOUSE_BUTTONS`. - * - * @param[in] window The window to query. - * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or - * `GLFW_STICKY_MOUSE_BUTTONS`. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_INVALID_ENUM. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa glfwSetInputMode - * - * @since Added in version 3.0. - * - * @ingroup input - */ -GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode); - -/*! @brief Sets an input option for the specified window. - * - * This function sets an input mode option for the specified window. The mode - * must be one of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or - * `GLFW_STICKY_MOUSE_BUTTONS`. - * - * If the mode is `GLFW_CURSOR`, the value must be one of the following cursor - * modes: - * - `GLFW_CURSOR_NORMAL` makes the cursor visible and behaving normally. - * - `GLFW_CURSOR_HIDDEN` makes the cursor invisible when it is over the client - * area of the window but does not restrict the cursor from leaving. - * - `GLFW_CURSOR_DISABLED` hides and grabs the cursor, providing virtual - * and unlimited cursor movement. This is useful for implementing for - * example 3D camera controls. - * - * If the mode is `GLFW_STICKY_KEYS`, the value must be either `GLFW_TRUE` to - * enable sticky keys, or `GLFW_FALSE` to disable it. If sticky keys are - * enabled, a key press will ensure that @ref glfwGetKey returns `GLFW_PRESS` - * the next time it is called even if the key had been released before the - * call. This is useful when you are only interested in whether keys have been - * pressed but not when or in which order. - * - * If the mode is `GLFW_STICKY_MOUSE_BUTTONS`, the value must be either - * `GLFW_TRUE` to enable sticky mouse buttons, or `GLFW_FALSE` to disable it. - * If sticky mouse buttons are enabled, a mouse button press will ensure that - * @ref glfwGetMouseButton returns `GLFW_PRESS` the next time it is called even - * if the mouse button had been released before the call. This is useful when - * you are only interested in whether mouse buttons have been pressed but not - * when or in which order. - * - * @param[in] window The window whose input mode to set. - * @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or - * `GLFW_STICKY_MOUSE_BUTTONS`. - * @param[in] value The new value of the specified input mode. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa glfwGetInputMode - * - * @since Added in version 3.0. Replaces `glfwEnable` and `glfwDisable`. - * - * @ingroup input - */ -GLFWAPI void glfwSetInputMode(GLFWwindow* window, int mode, int value); - -/*! @brief Returns the localized name of the specified printable key. - * - * This function returns the localized name of the specified printable key. - * This is intended for displaying key bindings to the user. - * - * If the key is `GLFW_KEY_UNKNOWN`, the scancode is used instead, otherwise - * the scancode is ignored. If a non-printable key or (if the key is - * `GLFW_KEY_UNKNOWN`) a scancode that maps to a non-printable key is - * specified, this function returns `NULL`. - * - * This behavior allows you to pass in the arguments passed to the - * [key callback](@ref input_key) without modification. - * - * The printable keys are: - * - `GLFW_KEY_APOSTROPHE` - * - `GLFW_KEY_COMMA` - * - `GLFW_KEY_MINUS` - * - `GLFW_KEY_PERIOD` - * - `GLFW_KEY_SLASH` - * - `GLFW_KEY_SEMICOLON` - * - `GLFW_KEY_EQUAL` - * - `GLFW_KEY_LEFT_BRACKET` - * - `GLFW_KEY_RIGHT_BRACKET` - * - `GLFW_KEY_BACKSLASH` - * - `GLFW_KEY_WORLD_1` - * - `GLFW_KEY_WORLD_2` - * - `GLFW_KEY_0` to `GLFW_KEY_9` - * - `GLFW_KEY_A` to `GLFW_KEY_Z` - * - `GLFW_KEY_KP_0` to `GLFW_KEY_KP_9` - * - `GLFW_KEY_KP_DECIMAL` - * - `GLFW_KEY_KP_DIVIDE` - * - `GLFW_KEY_KP_MULTIPLY` - * - `GLFW_KEY_KP_SUBTRACT` - * - `GLFW_KEY_KP_ADD` - * - `GLFW_KEY_KP_EQUAL` - * - * @param[in] key The key to query, or `GLFW_KEY_UNKNOWN`. - * @param[in] scancode The scancode of the key to query. - * @return The localized name of the key, or `NULL`. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @pointer_lifetime The returned string is allocated and freed by GLFW. You - * should not free it yourself. It is valid until the next call to @ref - * glfwGetKeyName, or until the library is terminated. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref input_key_name - * - * @since Added in version 3.2. - * - * @ingroup input - */ -GLFWAPI const char* glfwGetKeyName(int key, int scancode); - -/*! @brief Returns the last reported state of a keyboard key for the specified - * window. - * - * This function returns the last state reported for the specified key to the - * specified window. The returned state is one of `GLFW_PRESS` or - * `GLFW_RELEASE`. The higher-level action `GLFW_REPEAT` is only reported to - * the key callback. - * - * If the `GLFW_STICKY_KEYS` input mode is enabled, this function returns - * `GLFW_PRESS` the first time you call it for a key that was pressed, even if - * that key has already been released. - * - * The key functions deal with physical keys, with [key tokens](@ref keys) - * named after their use on the standard US keyboard layout. If you want to - * input text, use the Unicode character callback instead. - * - * The [modifier key bit masks](@ref mods) are not key tokens and cannot be - * used with this function. - * - * __Do not use this function__ to implement [text input](@ref input_char). - * - * @param[in] window The desired window. - * @param[in] key The desired [keyboard key](@ref keys). `GLFW_KEY_UNKNOWN` is - * not a valid key for this function. - * @return One of `GLFW_PRESS` or `GLFW_RELEASE`. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_INVALID_ENUM. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref input_key - * - * @since Added in version 1.0. - * @glfw3 Added window handle parameter. - * - * @ingroup input - */ -GLFWAPI int glfwGetKey(GLFWwindow* window, int key); - -/*! @brief Returns the last reported state of a mouse button for the specified - * window. - * - * This function returns the last state reported for the specified mouse button - * to the specified window. The returned state is one of `GLFW_PRESS` or - * `GLFW_RELEASE`. - * - * If the `GLFW_STICKY_MOUSE_BUTTONS` input mode is enabled, this function - * `GLFW_PRESS` the first time you call it for a mouse button that was pressed, - * even if that mouse button has already been released. - * - * @param[in] window The desired window. - * @param[in] button The desired [mouse button](@ref buttons). - * @return One of `GLFW_PRESS` or `GLFW_RELEASE`. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_INVALID_ENUM. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref input_mouse_button - * - * @since Added in version 1.0. - * @glfw3 Added window handle parameter. - * - * @ingroup input - */ -GLFWAPI int glfwGetMouseButton(GLFWwindow* window, int button); - -/*! @brief Retrieves the position of the cursor relative to the client area of - * the window. - * - * This function returns the position of the cursor, in screen coordinates, - * relative to the upper-left corner of the client area of the specified - * window. - * - * If the cursor is disabled (with `GLFW_CURSOR_DISABLED`) then the cursor - * position is unbounded and limited only by the minimum and maximum values of - * a `double`. - * - * The coordinate can be converted to their integer equivalents with the - * `floor` function. Casting directly to an integer type works for positive - * coordinates, but fails for negative ones. - * - * Any or all of the position arguments may be `NULL`. If an error occurs, all - * non-`NULL` position arguments will be set to zero. - * - * @param[in] window The desired window. - * @param[out] xpos Where to store the cursor x-coordinate, relative to the - * left edge of the client area, or `NULL`. - * @param[out] ypos Where to store the cursor y-coordinate, relative to the to - * top edge of the client area, or `NULL`. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref cursor_pos - * @sa glfwSetCursorPos - * - * @since Added in version 3.0. Replaces `glfwGetMousePos`. - * - * @ingroup input - */ -GLFWAPI void glfwGetCursorPos(GLFWwindow* window, double* xpos, double* ypos); - -/*! @brief Sets the position of the cursor, relative to the client area of the - * window. - * - * This function sets the position, in screen coordinates, of the cursor - * relative to the upper-left corner of the client area of the specified - * window. The window must have input focus. If the window does not have - * input focus when this function is called, it fails silently. - * - * __Do not use this function__ to implement things like camera controls. GLFW - * already provides the `GLFW_CURSOR_DISABLED` cursor mode that hides the - * cursor, transparently re-centers it and provides unconstrained cursor - * motion. See @ref glfwSetInputMode for more information. - * - * If the cursor mode is `GLFW_CURSOR_DISABLED` then the cursor position is - * unconstrained and limited only by the minimum and maximum values of - * a `double`. - * - * @param[in] window The desired window. - * @param[in] xpos The desired x-coordinate, relative to the left edge of the - * client area. - * @param[in] ypos The desired y-coordinate, relative to the top edge of the - * client area. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @remark @x11 Due to the asynchronous nature of X11, it may take a moment for - * the window focus event to arrive. This means you may not be able to set the - * cursor position directly after window creation. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref cursor_pos - * @sa glfwGetCursorPos - * - * @since Added in version 3.0. Replaces `glfwSetMousePos`. - * - * @ingroup input - */ -GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos); - -/*! @brief Creates a custom cursor. - * - * Creates a new custom cursor image that can be set for a window with @ref - * glfwSetCursor. The cursor can be destroyed with @ref glfwDestroyCursor. - * Any remaining cursors are destroyed by @ref glfwTerminate. - * - * The pixels are 32-bit, little-endian, non-premultiplied RGBA, i.e. eight - * bits per channel. They are arranged canonically as packed sequential rows, - * starting from the top-left corner. - * - * The cursor hotspot is specified in pixels, relative to the upper-left corner - * of the cursor image. Like all other coordinate systems in GLFW, the X-axis - * points to the right and the Y-axis points down. - * - * @param[in] image The desired cursor image. - * @param[in] xhot The desired x-coordinate, in pixels, of the cursor hotspot. - * @param[in] yhot The desired y-coordinate, in pixels, of the cursor hotspot. - * @return The handle of the created cursor, or `NULL` if an - * [error](@ref error_handling) occurred. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @pointer_lifetime The specified image data is copied before this function - * returns. - * - * @reentrancy This function must not be called from a callback. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref cursor_object - * @sa glfwDestroyCursor - * @sa glfwCreateStandardCursor - * - * @since Added in version 3.1. - * - * @ingroup input - */ -GLFWAPI GLFWcursor* glfwCreateCursor(const GLFWimage* image, int xhot, int yhot); - -/*! @brief Creates a cursor with a standard shape. - * - * Returns a cursor with a [standard shape](@ref shapes), that can be set for - * a window with @ref glfwSetCursor. - * - * @param[in] shape One of the [standard shapes](@ref shapes). - * @return A new cursor ready to use or `NULL` if an - * [error](@ref error_handling) occurred. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR. - * - * @reentrancy This function must not be called from a callback. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref cursor_object - * @sa glfwCreateCursor - * - * @since Added in version 3.1. - * - * @ingroup input - */ -GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape); - -/*! @brief Destroys a cursor. - * - * This function destroys a cursor previously created with @ref - * glfwCreateCursor. Any remaining cursors will be destroyed by @ref - * glfwTerminate. - * - * @param[in] cursor The cursor object to destroy. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @reentrancy This function must not be called from a callback. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref cursor_object - * @sa glfwCreateCursor - * - * @since Added in version 3.1. - * - * @ingroup input - */ -GLFWAPI void glfwDestroyCursor(GLFWcursor* cursor); - -/*! @brief Sets the cursor for the window. - * - * This function sets the cursor image to be used when the cursor is over the - * client area of the specified window. The set cursor will only be visible - * when the [cursor mode](@ref cursor_mode) of the window is - * `GLFW_CURSOR_NORMAL`. - * - * On some platforms, the set cursor may not be visible unless the window also - * has input focus. - * - * @param[in] window The window to set the cursor for. - * @param[in] cursor The cursor to set, or `NULL` to switch back to the default - * arrow cursor. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref cursor_object - * - * @since Added in version 3.1. - * - * @ingroup input - */ -GLFWAPI void glfwSetCursor(GLFWwindow* window, GLFWcursor* cursor); - -/*! @brief Sets the key callback. - * - * This function sets the key callback of the specified window, which is called - * when a key is pressed, repeated or released. - * - * The key functions deal with physical keys, with layout independent - * [key tokens](@ref keys) named after their values in the standard US keyboard - * layout. If you want to input text, use the - * [character callback](@ref glfwSetCharCallback) instead. - * - * When a window loses input focus, it will generate synthetic key release - * events for all pressed keys. You can tell these events from user-generated - * events by the fact that the synthetic ones are generated after the focus - * loss event has been processed, i.e. after the - * [window focus callback](@ref glfwSetWindowFocusCallback) has been called. - * - * The scancode of a key is specific to that platform or sometimes even to that - * machine. Scancodes are intended to allow users to bind keys that don't have - * a GLFW key token. Such keys have `key` set to `GLFW_KEY_UNKNOWN`, their - * state is not saved and so it cannot be queried with @ref glfwGetKey. - * - * Sometimes GLFW needs to generate synthetic key events, in which case the - * scancode may be zero. - * - * @param[in] window The window whose callback to set. - * @param[in] cbfun The new key callback, or `NULL` to remove the currently - * set callback. - * @return The previously set callback, or `NULL` if no callback was set or the - * library had not been [initialized](@ref intro_init). - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref input_key - * - * @since Added in version 1.0. - * @glfw3 Added window handle parameter and return value. - * - * @ingroup input - */ -GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow* window, GLFWkeyfun cbfun); - -/*! @brief Sets the Unicode character callback. - * - * This function sets the character callback of the specified window, which is - * called when a Unicode character is input. - * - * The character callback is intended for Unicode text input. As it deals with - * characters, it is keyboard layout dependent, whereas the - * [key callback](@ref glfwSetKeyCallback) is not. Characters do not map 1:1 - * to physical keys, as a key may produce zero, one or more characters. If you - * want to know whether a specific physical key was pressed or released, see - * the key callback instead. - * - * The character callback behaves as system text input normally does and will - * not be called if modifier keys are held down that would prevent normal text - * input on that platform, for example a Super (Command) key on OS X or Alt key - * on Windows. There is a - * [character with modifiers callback](@ref glfwSetCharModsCallback) that - * receives these events. - * - * @param[in] window The window whose callback to set. - * @param[in] cbfun The new callback, or `NULL` to remove the currently set - * callback. - * @return The previously set callback, or `NULL` if no callback was set or the - * library had not been [initialized](@ref intro_init). - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref input_char - * - * @since Added in version 2.4. - * @glfw3 Added window handle parameter and return value. - * - * @ingroup input - */ -GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow* window, GLFWcharfun cbfun); - -/*! @brief Sets the Unicode character with modifiers callback. - * - * This function sets the character with modifiers callback of the specified - * window, which is called when a Unicode character is input regardless of what - * modifier keys are used. - * - * The character with modifiers callback is intended for implementing custom - * Unicode character input. For regular Unicode text input, see the - * [character callback](@ref glfwSetCharCallback). Like the character - * callback, the character with modifiers callback deals with characters and is - * keyboard layout dependent. Characters do not map 1:1 to physical keys, as - * a key may produce zero, one or more characters. If you want to know whether - * a specific physical key was pressed or released, see the - * [key callback](@ref glfwSetKeyCallback) instead. - * - * @param[in] window The window whose callback to set. - * @param[in] cbfun The new callback, or `NULL` to remove the currently set - * callback. - * @return The previously set callback, or `NULL` if no callback was set or an - * error occurred. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref input_char - * - * @since Added in version 3.1. - * - * @ingroup input - */ -GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmodsfun cbfun); - -/*! @brief Sets the mouse button callback. - * - * This function sets the mouse button callback of the specified window, which - * is called when a mouse button is pressed or released. - * - * When a window loses input focus, it will generate synthetic mouse button - * release events for all pressed mouse buttons. You can tell these events - * from user-generated events by the fact that the synthetic ones are generated - * after the focus loss event has been processed, i.e. after the - * [window focus callback](@ref glfwSetWindowFocusCallback) has been called. - * - * @param[in] window The window whose callback to set. - * @param[in] cbfun The new callback, or `NULL` to remove the currently set - * callback. - * @return The previously set callback, or `NULL` if no callback was set or the - * library had not been [initialized](@ref intro_init). - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref input_mouse_button - * - * @since Added in version 1.0. - * @glfw3 Added window handle parameter and return value. - * - * @ingroup input - */ -GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow* window, GLFWmousebuttonfun cbfun); - -/*! @brief Sets the cursor position callback. - * - * This function sets the cursor position callback of the specified window, - * which is called when the cursor is moved. The callback is provided with the - * position, in screen coordinates, relative to the upper-left corner of the - * client area of the window. - * - * @param[in] window The window whose callback to set. - * @param[in] cbfun The new callback, or `NULL` to remove the currently set - * callback. - * @return The previously set callback, or `NULL` if no callback was set or the - * library had not been [initialized](@ref intro_init). - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref cursor_pos - * - * @since Added in version 3.0. Replaces `glfwSetMousePosCallback`. - * - * @ingroup input - */ -GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow* window, GLFWcursorposfun cbfun); - -/*! @brief Sets the cursor enter/exit callback. - * - * This function sets the cursor boundary crossing callback of the specified - * window, which is called when the cursor enters or leaves the client area of - * the window. - * - * @param[in] window The window whose callback to set. - * @param[in] cbfun The new callback, or `NULL` to remove the currently set - * callback. - * @return The previously set callback, or `NULL` if no callback was set or the - * library had not been [initialized](@ref intro_init). - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref cursor_enter - * - * @since Added in version 3.0. - * - * @ingroup input - */ -GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcursorenterfun cbfun); - -/*! @brief Sets the scroll callback. - * - * This function sets the scroll callback of the specified window, which is - * called when a scrolling device is used, such as a mouse wheel or scrolling - * area of a touchpad. - * - * The scroll callback receives all scrolling input, like that from a mouse - * wheel or a touchpad scrolling area. - * - * @param[in] window The window whose callback to set. - * @param[in] cbfun The new scroll callback, or `NULL` to remove the currently - * set callback. - * @return The previously set callback, or `NULL` if no callback was set or the - * library had not been [initialized](@ref intro_init). - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref scrolling - * - * @since Added in version 3.0. Replaces `glfwSetMouseWheelCallback`. - * - * @ingroup input - */ -GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun cbfun); - -/*! @brief Sets the file drop callback. - * - * This function sets the file drop callback of the specified window, which is - * called when one or more dragged files are dropped on the window. - * - * Because the path array and its strings may have been generated specifically - * for that event, they are not guaranteed to be valid after the callback has - * returned. If you wish to use them after the callback returns, you need to - * make a deep copy. - * - * @param[in] window The window whose callback to set. - * @param[in] cbfun The new file drop callback, or `NULL` to remove the - * currently set callback. - * @return The previously set callback, or `NULL` if no callback was set or the - * library had not been [initialized](@ref intro_init). - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref path_drop - * - * @since Added in version 3.1. - * - * @ingroup input - */ -GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* window, GLFWdropfun cbfun); - -/*! @brief Returns whether the specified joystick is present. - * - * This function returns whether the specified joystick is present. - * - * @param[in] joy The [joystick](@ref joysticks) to query. - * @return `GLFW_TRUE` if the joystick is present, or `GLFW_FALSE` otherwise. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref joystick - * - * @since Added in version 3.0. Replaces `glfwGetJoystickParam`. - * - * @ingroup input - */ -GLFWAPI int glfwJoystickPresent(int joy); - -/*! @brief Returns the values of all axes of the specified joystick. - * - * This function returns the values of all axes of the specified joystick. - * Each element in the array is a value between -1.0 and 1.0. - * - * Querying a joystick slot with no device present is not an error, but will - * cause this function to return `NULL`. Call @ref glfwJoystickPresent to - * check device presence. - * - * @param[in] joy The [joystick](@ref joysticks) to query. - * @param[out] count Where to store the number of axis values in the returned - * array. This is set to zero if an error occurred. - * @return An array of axis values, or `NULL` if the joystick is not present. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR. - * - * @pointer_lifetime The returned array is allocated and freed by GLFW. You - * should not free it yourself. It is valid until the specified joystick is - * disconnected, this function is called again for that joystick or the library - * is terminated. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref joystick_axis - * - * @since Added in version 3.0. Replaces `glfwGetJoystickPos`. - * - * @ingroup input - */ -GLFWAPI const float* glfwGetJoystickAxes(int joy, int* count); - -/*! @brief Returns the state of all buttons of the specified joystick. - * - * This function returns the state of all buttons of the specified joystick. - * Each element in the array is either `GLFW_PRESS` or `GLFW_RELEASE`. - * - * Querying a joystick slot with no device present is not an error, but will - * cause this function to return `NULL`. Call @ref glfwJoystickPresent to - * check device presence. - * - * @param[in] joy The [joystick](@ref joysticks) to query. - * @param[out] count Where to store the number of button states in the returned - * array. This is set to zero if an error occurred. - * @return An array of button states, or `NULL` if the joystick is not present. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR. - * - * @pointer_lifetime The returned array is allocated and freed by GLFW. You - * should not free it yourself. It is valid until the specified joystick is - * disconnected, this function is called again for that joystick or the library - * is terminated. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref joystick_button - * - * @since Added in version 2.2. - * @glfw3 Changed to return a dynamic array. - * - * @ingroup input - */ -GLFWAPI const unsigned char* glfwGetJoystickButtons(int joy, int* count); - -/*! @brief Returns the name of the specified joystick. - * - * This function returns the name, encoded as UTF-8, of the specified joystick. - * The returned string is allocated and freed by GLFW. You should not free it - * yourself. - * - * Querying a joystick slot with no device present is not an error, but will - * cause this function to return `NULL`. Call @ref glfwJoystickPresent to - * check device presence. - * - * @param[in] joy The [joystick](@ref joysticks) to query. - * @return The UTF-8 encoded name of the joystick, or `NULL` if the joystick - * is not present. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_INVALID_ENUM and @ref GLFW_PLATFORM_ERROR. - * - * @pointer_lifetime The returned string is allocated and freed by GLFW. You - * should not free it yourself. It is valid until the specified joystick is - * disconnected, this function is called again for that joystick or the library - * is terminated. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref joystick_name - * - * @since Added in version 3.0. - * - * @ingroup input - */ -GLFWAPI const char* glfwGetJoystickName(int joy); - -/*! @brief Sets the joystick configuration callback. - * - * This function sets the joystick configuration callback, or removes the - * currently set callback. This is called when a joystick is connected to or - * disconnected from the system. - * - * @param[in] cbfun The new callback, or `NULL` to remove the currently set - * callback. - * @return The previously set callback, or `NULL` if no callback was set or the - * library had not been [initialized](@ref intro_init). - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref joystick_event - * - * @since Added in version 3.2. - * - * @ingroup input - */ -GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun cbfun); - -/*! @brief Sets the clipboard to the specified string. - * - * This function sets the system clipboard to the specified, UTF-8 encoded - * string. - * - * @param[in] window The window that will own the clipboard contents. - * @param[in] string A UTF-8 encoded string. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @pointer_lifetime The specified string is copied before this function - * returns. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref clipboard - * @sa glfwGetClipboardString - * - * @since Added in version 3.0. - * - * @ingroup input - */ -GLFWAPI void glfwSetClipboardString(GLFWwindow* window, const char* string); - -/*! @brief Returns the contents of the clipboard as a string. - * - * This function returns the contents of the system clipboard, if it contains - * or is convertible to a UTF-8 encoded string. If the clipboard is empty or - * if its contents cannot be converted, `NULL` is returned and a @ref - * GLFW_FORMAT_UNAVAILABLE error is generated. - * - * @param[in] window The window that will request the clipboard contents. - * @return The contents of the clipboard as a UTF-8 encoded string, or `NULL` - * if an [error](@ref error_handling) occurred. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_PLATFORM_ERROR. - * - * @pointer_lifetime The returned string is allocated and freed by GLFW. You - * should not free it yourself. It is valid until the next call to @ref - * glfwGetClipboardString or @ref glfwSetClipboardString, or until the library - * is terminated. - * - * @thread_safety This function must only be called from the main thread. - * - * @sa @ref clipboard - * @sa glfwSetClipboardString - * - * @since Added in version 3.0. - * - * @ingroup input - */ -GLFWAPI const char* glfwGetClipboardString(GLFWwindow* window); - -/*! @brief Returns the value of the GLFW timer. - * - * This function returns the value of the GLFW timer. Unless the timer has - * been set using @ref glfwSetTime, the timer measures time elapsed since GLFW - * was initialized. - * - * The resolution of the timer is system dependent, but is usually on the order - * of a few micro- or nanoseconds. It uses the highest-resolution monotonic - * time source on each supported platform. - * - * @return The current value, in seconds, or zero if an - * [error](@ref error_handling) occurred. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @thread_safety This function may be called from any thread. Reading of the - * internal timer offset is not atomic. - * - * @sa @ref time - * - * @since Added in version 1.0. - * - * @ingroup input - */ -GLFWAPI double glfwGetTime(void); - -/*! @brief Sets the GLFW timer. - * - * This function sets the value of the GLFW timer. It then continues to count - * up from that value. The value must be a positive finite number less than - * or equal to 18446744073.0, which is approximately 584.5 years. - * - * @param[in] time The new value, in seconds. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_INVALID_VALUE. - * - * @remark The upper limit of the timer is calculated as - * floor((264 - 1) / 109) and is due to implementations - * storing nanoseconds in 64 bits. The limit may be increased in the future. - * - * @thread_safety This function may be called from any thread. Writing of the - * internal timer offset is not atomic. - * - * @sa @ref time - * - * @since Added in version 2.2. - * - * @ingroup input - */ -GLFWAPI void glfwSetTime(double time); - -/*! @brief Returns the current value of the raw timer. - * - * This function returns the current value of the raw timer, measured in - * 1 / frequency seconds. To get the frequency, call @ref - * glfwGetTimerFrequency. - * - * @return The value of the timer, or zero if an - * [error](@ref error_handling) occurred. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @thread_safety This function may be called from any thread. - * - * @sa @ref time - * @sa glfwGetTimerFrequency - * - * @since Added in version 3.2. - * - * @ingroup input - */ -GLFWAPI uint64_t glfwGetTimerValue(void); - -/*! @brief Returns the frequency, in Hz, of the raw timer. - * - * This function returns the frequency, in Hz, of the raw timer. - * - * @return The frequency of the timer, in Hz, or zero if an - * [error](@ref error_handling) occurred. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @thread_safety This function may be called from any thread. - * - * @sa @ref time - * @sa glfwGetTimerValue - * - * @since Added in version 3.2. - * - * @ingroup input - */ -GLFWAPI uint64_t glfwGetTimerFrequency(void); - -/*! @brief Makes the context of the specified window current for the calling - * thread. - * - * This function makes the OpenGL or OpenGL ES context of the specified window - * current on the calling thread. A context can only be made current on - * a single thread at a time and each thread can have only a single current - * context at a time. - * - * By default, making a context non-current implicitly forces a pipeline flush. - * On machines that support `GL_KHR_context_flush_control`, you can control - * whether a context performs this flush by setting the - * [GLFW_CONTEXT_RELEASE_BEHAVIOR](@ref window_hints_ctx) window hint. - * - * The specified window must have an OpenGL or OpenGL ES context. Specifying - * a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT - * error. - * - * @param[in] window The window whose context to make current, or `NULL` to - * detach the current context. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR. - * - * @thread_safety This function may be called from any thread. - * - * @sa @ref context_current - * @sa glfwGetCurrentContext - * - * @since Added in version 3.0. - * - * @ingroup context - */ -GLFWAPI void glfwMakeContextCurrent(GLFWwindow* window); - -/*! @brief Returns the window whose context is current on the calling thread. - * - * This function returns the window whose OpenGL or OpenGL ES context is - * current on the calling thread. - * - * @return The window whose context is current, or `NULL` if no window's - * context is current. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @thread_safety This function may be called from any thread. - * - * @sa @ref context_current - * @sa glfwMakeContextCurrent - * - * @since Added in version 3.0. - * - * @ingroup context - */ -GLFWAPI GLFWwindow* glfwGetCurrentContext(void); - -/*! @brief Swaps the front and back buffers of the specified window. - * - * This function swaps the front and back buffers of the specified window when - * rendering with OpenGL or OpenGL ES. If the swap interval is greater than - * zero, the GPU driver waits the specified number of screen updates before - * swapping the buffers. - * - * The specified window must have an OpenGL or OpenGL ES context. Specifying - * a window without a context will generate a @ref GLFW_NO_WINDOW_CONTEXT - * error. - * - * This function does not apply to Vulkan. If you are rendering with Vulkan, - * see `vkQueuePresentKHR` instead. - * - * @param[in] window The window whose buffers to swap. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR. - * - * @remark __EGL:__ The context of the specified window must be current on the - * calling thread. - * - * @thread_safety This function may be called from any thread. - * - * @sa @ref buffer_swap - * @sa glfwSwapInterval - * - * @since Added in version 1.0. - * @glfw3 Added window handle parameter. - * - * @ingroup window - */ -GLFWAPI void glfwSwapBuffers(GLFWwindow* window); - -/*! @brief Sets the swap interval for the current context. - * - * This function sets the swap interval for the current OpenGL or OpenGL ES - * context, i.e. the number of screen updates to wait from the time @ref - * glfwSwapBuffers was called before swapping the buffers and returning. This - * is sometimes called _vertical synchronization_, _vertical retrace - * synchronization_ or just _vsync_. - * - * Contexts that support either of the `WGL_EXT_swap_control_tear` and - * `GLX_EXT_swap_control_tear` extensions also accept negative swap intervals, - * which allow the driver to swap even if a frame arrives a little bit late. - * You can check for the presence of these extensions using @ref - * glfwExtensionSupported. For more information about swap tearing, see the - * extension specifications. - * - * A context must be current on the calling thread. Calling this function - * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error. - * - * This function does not apply to Vulkan. If you are rendering with Vulkan, - * see the present mode of your swapchain instead. - * - * @param[in] interval The minimum number of screen updates to wait for - * until the buffers are swapped by @ref glfwSwapBuffers. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR. - * - * @remark This function is not called during context creation, leaving the - * swap interval set to whatever is the default on that platform. This is done - * because some swap interval extensions used by GLFW do not allow the swap - * interval to be reset to zero once it has been set to a non-zero value. - * - * @remark Some GPU drivers do not honor the requested swap interval, either - * because of a user setting that overrides the application's request or due to - * bugs in the driver. - * - * @thread_safety This function may be called from any thread. - * - * @sa @ref buffer_swap - * @sa glfwSwapBuffers - * - * @since Added in version 1.0. - * - * @ingroup context - */ -GLFWAPI void glfwSwapInterval(int interval); - -/*! @brief Returns whether the specified extension is available. - * - * This function returns whether the specified - * [API extension](@ref context_glext) is supported by the current OpenGL or - * OpenGL ES context. It searches both for client API extension and context - * creation API extensions. - * - * A context must be current on the calling thread. Calling this function - * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error. - * - * As this functions retrieves and searches one or more extension strings each - * call, it is recommended that you cache its results if it is going to be used - * frequently. The extension strings will not change during the lifetime of - * a context, so there is no danger in doing this. - * - * This function does not apply to Vulkan. If you are using Vulkan, see @ref - * glfwGetRequiredInstanceExtensions, `vkEnumerateInstanceExtensionProperties` - * and `vkEnumerateDeviceExtensionProperties` instead. - * - * @param[in] extension The ASCII encoded name of the extension. - * @return `GLFW_TRUE` if the extension is available, or `GLFW_FALSE` - * otherwise. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_NO_CURRENT_CONTEXT, @ref GLFW_INVALID_VALUE and @ref - * GLFW_PLATFORM_ERROR. - * - * @thread_safety This function may be called from any thread. - * - * @sa @ref context_glext - * @sa glfwGetProcAddress - * - * @since Added in version 1.0. - * - * @ingroup context - */ -GLFWAPI int glfwExtensionSupported(const char* extension); - -/*! @brief Returns the address of the specified function for the current - * context. - * - * This function returns the address of the specified OpenGL or OpenGL ES - * [core or extension function](@ref context_glext), if it is supported - * by the current context. - * - * A context must be current on the calling thread. Calling this function - * without a current context will cause a @ref GLFW_NO_CURRENT_CONTEXT error. - * - * This function does not apply to Vulkan. If you are rendering with Vulkan, - * see @ref glfwGetInstanceProcAddress, `vkGetInstanceProcAddr` and - * `vkGetDeviceProcAddr` instead. - * - * @param[in] procname The ASCII encoded name of the function. - * @return The address of the function, or `NULL` if an - * [error](@ref error_handling) occurred. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_NO_CURRENT_CONTEXT and @ref GLFW_PLATFORM_ERROR. - * - * @remark The address of a given function is not guaranteed to be the same - * between contexts. - * - * @remark This function may return a non-`NULL` address despite the - * associated version or extension not being available. Always check the - * context version or extension string first. - * - * @pointer_lifetime The returned function pointer is valid until the context - * is destroyed or the library is terminated. - * - * @thread_safety This function may be called from any thread. - * - * @sa @ref context_glext - * @sa glfwExtensionSupported - * - * @since Added in version 1.0. - * - * @ingroup context - */ -GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname); - -/*! @brief Returns whether the Vulkan loader has been found. - * - * This function returns whether the Vulkan loader has been found. This check - * is performed by @ref glfwInit. - * - * The availability of a Vulkan loader does not by itself guarantee that window - * surface creation or even device creation is possible. Call @ref - * glfwGetRequiredInstanceExtensions to check whether the extensions necessary - * for Vulkan surface creation are available and @ref - * glfwGetPhysicalDevicePresentationSupport to check whether a queue family of - * a physical device supports image presentation. - * - * @return `GLFW_TRUE` if Vulkan is available, or `GLFW_FALSE` otherwise. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED. - * - * @thread_safety This function may be called from any thread. - * - * @sa @ref vulkan_support - * - * @since Added in version 3.2. - * - * @ingroup vulkan - */ -GLFWAPI int glfwVulkanSupported(void); - -/*! @brief Returns the Vulkan instance extensions required by GLFW. - * - * This function returns an array of names of Vulkan instance extensions required - * by GLFW for creating Vulkan surfaces for GLFW windows. If successful, the - * list will always contains `VK_KHR_surface`, so if you don't require any - * additional extensions you can pass this list directly to the - * `VkInstanceCreateInfo` struct. - * - * If Vulkan is not available on the machine, this function returns `NULL` and - * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported - * to check whether Vulkan is available. - * - * If Vulkan is available but no set of extensions allowing window surface - * creation was found, this function returns `NULL`. You may still use Vulkan - * for off-screen rendering and compute work. - * - * @param[out] count Where to store the number of extensions in the returned - * array. This is set to zero if an error occurred. - * @return An array of ASCII encoded extension names, or `NULL` if an - * [error](@ref error_handling) occurred. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_API_UNAVAILABLE. - * - * @remarks Additional extensions may be required by future versions of GLFW. - * You should check if any extensions you wish to enable are already in the - * returned array, as it is an error to specify an extension more than once in - * the `VkInstanceCreateInfo` struct. - * - * @pointer_lifetime The returned array is allocated and freed by GLFW. You - * should not free it yourself. It is guaranteed to be valid only until the - * library is terminated. - * - * @thread_safety This function may be called from any thread. - * - * @sa @ref vulkan_ext - * @sa glfwCreateWindowSurface - * - * @since Added in version 3.2. - * - * @ingroup vulkan - */ -GLFWAPI const char** glfwGetRequiredInstanceExtensions(uint32_t* count); - -#if defined(VK_VERSION_1_0) - -/*! @brief Returns the address of the specified Vulkan instance function. - * - * This function returns the address of the specified Vulkan core or extension - * function for the specified instance. If instance is set to `NULL` it can - * return any function exported from the Vulkan loader, including at least the - * following functions: - * - * - `vkEnumerateInstanceExtensionProperties` - * - `vkEnumerateInstanceLayerProperties` - * - `vkCreateInstance` - * - `vkGetInstanceProcAddr` - * - * If Vulkan is not available on the machine, this function returns `NULL` and - * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported - * to check whether Vulkan is available. - * - * This function is equivalent to calling `vkGetInstanceProcAddr` with - * a platform-specific query of the Vulkan loader as a fallback. - * - * @param[in] instance The Vulkan instance to query, or `NULL` to retrieve - * functions related to instance creation. - * @param[in] procname The ASCII encoded name of the function. - * @return The address of the function, or `NULL` if an - * [error](@ref error_handling) occurred. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref - * GLFW_API_UNAVAILABLE. - * - * @pointer_lifetime The returned function pointer is valid until the library - * is terminated. - * - * @thread_safety This function may be called from any thread. - * - * @sa @ref vulkan_proc - * - * @since Added in version 3.2. - * - * @ingroup vulkan - */ -GLFWAPI GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, const char* procname); - -/*! @brief Returns whether the specified queue family can present images. - * - * This function returns whether the specified queue family of the specified - * physical device supports presentation to the platform GLFW was built for. - * - * If Vulkan or the required window surface creation instance extensions are - * not available on the machine, or if the specified instance was not created - * with the required extensions, this function returns `GLFW_FALSE` and - * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref glfwVulkanSupported - * to check whether Vulkan is available and @ref - * glfwGetRequiredInstanceExtensions to check what instance extensions are - * required. - * - * @param[in] instance The instance that the physical device belongs to. - * @param[in] device The physical device that the queue family belongs to. - * @param[in] queuefamily The index of the queue family to query. - * @return `GLFW_TRUE` if the queue family supports presentation, or - * `GLFW_FALSE` otherwise. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR. - * - * @thread_safety This function may be called from any thread. For - * synchronization details of Vulkan objects, see the Vulkan specification. - * - * @sa @ref vulkan_present - * - * @since Added in version 3.2. - * - * @ingroup vulkan - */ -GLFWAPI int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily); - -/*! @brief Creates a Vulkan surface for the specified window. - * - * This function creates a Vulkan surface for the specified window. - * - * If the Vulkan loader was not found at initialization, this function returns - * `VK_ERROR_INITIALIZATION_FAILED` and generates a @ref GLFW_API_UNAVAILABLE - * error. Call @ref glfwVulkanSupported to check whether the Vulkan loader was - * found. - * - * If the required window surface creation instance extensions are not - * available or if the specified instance was not created with these extensions - * enabled, this function returns `VK_ERROR_EXTENSION_NOT_PRESENT` and - * generates a @ref GLFW_API_UNAVAILABLE error. Call @ref - * glfwGetRequiredInstanceExtensions to check what instance extensions are - * required. - * - * The window surface must be destroyed before the specified Vulkan instance. - * It is the responsibility of the caller to destroy the window surface. GLFW - * does not destroy it for you. Call `vkDestroySurfaceKHR` to destroy the - * surface. - * - * @param[in] instance The Vulkan instance to create the surface in. - * @param[in] window The window to create the surface for. - * @param[in] allocator The allocator to use, or `NULL` to use the default - * allocator. - * @param[out] surface Where to store the handle of the surface. This is set - * to `VK_NULL_HANDLE` if an error occurred. - * @return `VK_SUCCESS` if successful, or a Vulkan error code if an - * [error](@ref error_handling) occurred. - * - * @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref - * GLFW_API_UNAVAILABLE and @ref GLFW_PLATFORM_ERROR. - * - * @remarks If an error occurs before the creation call is made, GLFW returns - * the Vulkan error code most appropriate for the error. Appropriate use of - * @ref glfwVulkanSupported and @ref glfwGetRequiredInstanceExtensions should - * eliminate almost all occurrences of these errors. - * - * @thread_safety This function may be called from any thread. For - * synchronization details of Vulkan objects, see the Vulkan specification. - * - * @sa @ref vulkan_surface - * @sa glfwGetRequiredInstanceExtensions - * - * @since Added in version 3.2. - * - * @ingroup vulkan - */ -GLFWAPI VkResult glfwCreateWindowSurface(VkInstance instance, GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface); - -#endif /*VK_VERSION_1_0*/ - - -/************************************************************************* - * Global definition cleanup - *************************************************************************/ - -/* ------------------- BEGIN SYSTEM/COMPILER SPECIFIC -------------------- */ - -#ifdef GLFW_WINGDIAPI_DEFINED - #undef WINGDIAPI - #undef GLFW_WINGDIAPI_DEFINED -#endif - -#ifdef GLFW_CALLBACK_DEFINED - #undef CALLBACK - #undef GLFW_CALLBACK_DEFINED -#endif - -/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */ - - -#ifdef __cplusplus -} -#endif - -#endif /* _glfw3_h_ */ - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/libs/glfw/include/GLFW/glfw3native.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/libs/glfw/include/GLFW/glfw3native.h deleted file mode 100644 index 9fa955e..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/libs/glfw/include/GLFW/glfw3native.h +++ /dev/null @@ -1,456 +0,0 @@ -/************************************************************************* - * GLFW 3.2 - www.glfw.org - * A library for OpenGL, window and input - *------------------------------------------------------------------------ - * Copyright (c) 2002-2006 Marcus Geelnard - * Copyright (c) 2006-2010 Camilla Berglund - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would - * be appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must not - * be misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. - * - *************************************************************************/ - -#ifndef _glfw3_native_h_ -#define _glfw3_native_h_ - -#ifdef __cplusplus -extern "C" { -#endif - - -/************************************************************************* - * Doxygen documentation - *************************************************************************/ - -/*! @file glfw3native.h - * @brief The header of the native access functions. - * - * This is the header file of the native access functions. See @ref native for - * more information. - */ -/*! @defgroup native Native access - * - * **By using the native access functions you assert that you know what you're - * doing and how to fix problems caused by using them. If you don't, you - * shouldn't be using them.** - * - * Before the inclusion of @ref glfw3native.h, you may define exactly one - * window system API macro and zero or more context creation API macros. - * - * The chosen backends must match those the library was compiled for. Failure - * to do this will cause a link-time error. - * - * The available window API macros are: - * * `GLFW_EXPOSE_NATIVE_WIN32` - * * `GLFW_EXPOSE_NATIVE_COCOA` - * * `GLFW_EXPOSE_NATIVE_X11` - * * `GLFW_EXPOSE_NATIVE_WAYLAND` - * * `GLFW_EXPOSE_NATIVE_MIR` - * - * The available context API macros are: - * * `GLFW_EXPOSE_NATIVE_WGL` - * * `GLFW_EXPOSE_NATIVE_NSGL` - * * `GLFW_EXPOSE_NATIVE_GLX` - * * `GLFW_EXPOSE_NATIVE_EGL` - * - * These macros select which of the native access functions that are declared - * and which platform-specific headers to include. It is then up your (by - * definition platform-specific) code to handle which of these should be - * defined. - */ - - -/************************************************************************* - * System headers and types - *************************************************************************/ - -#if defined(GLFW_EXPOSE_NATIVE_WIN32) - // This is a workaround for the fact that glfw3.h needs to export APIENTRY (for - // example to allow applications to correctly declare a GL_ARB_debug_output - // callback) but windows.h assumes no one will define APIENTRY before it does - #undef APIENTRY - #include -#elif defined(GLFW_EXPOSE_NATIVE_COCOA) - #include - #if defined(__OBJC__) - #import - #else - typedef void* id; - #endif -#elif defined(GLFW_EXPOSE_NATIVE_X11) - #include - #include -#elif defined(GLFW_EXPOSE_NATIVE_WAYLAND) - #include -#elif defined(GLFW_EXPOSE_NATIVE_MIR) - #include -#endif - -#if defined(GLFW_EXPOSE_NATIVE_WGL) - /* WGL is declared by windows.h */ -#endif -#if defined(GLFW_EXPOSE_NATIVE_NSGL) - /* NSGL is declared by Cocoa.h */ -#endif -#if defined(GLFW_EXPOSE_NATIVE_GLX) - #include -#endif -#if defined(GLFW_EXPOSE_NATIVE_EGL) - #include -#endif - - -/************************************************************************* - * Functions - *************************************************************************/ - -#if defined(GLFW_EXPOSE_NATIVE_WIN32) -/*! @brief Returns the adapter device name of the specified monitor. - * - * @return The UTF-8 encoded adapter device name (for example `\\.\DISPLAY1`) - * of the specified monitor, or `NULL` if an [error](@ref error_handling) - * occurred. - * - * @thread_safety This function may be called from any thread. Access is not - * synchronized. - * - * @since Added in version 3.1. - * - * @ingroup native - */ -GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* monitor); - -/*! @brief Returns the display device name of the specified monitor. - * - * @return The UTF-8 encoded display device name (for example - * `\\.\DISPLAY1\Monitor0`) of the specified monitor, or `NULL` if an - * [error](@ref error_handling) occurred. - * - * @thread_safety This function may be called from any thread. Access is not - * synchronized. - * - * @since Added in version 3.1. - * - * @ingroup native - */ -GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor); - -/*! @brief Returns the `HWND` of the specified window. - * - * @return The `HWND` of the specified window, or `NULL` if an - * [error](@ref error_handling) occurred. - * - * @thread_safety This function may be called from any thread. Access is not - * synchronized. - * - * @since Added in version 3.0. - * - * @ingroup native - */ -GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window); -#endif - -#if defined(GLFW_EXPOSE_NATIVE_WGL) -/*! @brief Returns the `HGLRC` of the specified window. - * - * @return The `HGLRC` of the specified window, or `NULL` if an - * [error](@ref error_handling) occurred. - * - * @thread_safety This function may be called from any thread. Access is not - * synchronized. - * - * @since Added in version 3.0. - * - * @ingroup native - */ -GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window); -#endif - -#if defined(GLFW_EXPOSE_NATIVE_COCOA) -/*! @brief Returns the `CGDirectDisplayID` of the specified monitor. - * - * @return The `CGDirectDisplayID` of the specified monitor, or - * `kCGNullDirectDisplay` if an [error](@ref error_handling) occurred. - * - * @thread_safety This function may be called from any thread. Access is not - * synchronized. - * - * @since Added in version 3.1. - * - * @ingroup native - */ -GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor); - -/*! @brief Returns the `NSWindow` of the specified window. - * - * @return The `NSWindow` of the specified window, or `nil` if an - * [error](@ref error_handling) occurred. - * - * @thread_safety This function may be called from any thread. Access is not - * synchronized. - * - * @since Added in version 3.0. - * - * @ingroup native - */ -GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window); -#endif - -#if defined(GLFW_EXPOSE_NATIVE_NSGL) -/*! @brief Returns the `NSOpenGLContext` of the specified window. - * - * @return The `NSOpenGLContext` of the specified window, or `nil` if an - * [error](@ref error_handling) occurred. - * - * @thread_safety This function may be called from any thread. Access is not - * synchronized. - * - * @since Added in version 3.0. - * - * @ingroup native - */ -GLFWAPI id glfwGetNSGLContext(GLFWwindow* window); -#endif - -#if defined(GLFW_EXPOSE_NATIVE_X11) -/*! @brief Returns the `Display` used by GLFW. - * - * @return The `Display` used by GLFW, or `NULL` if an - * [error](@ref error_handling) occurred. - * - * @thread_safety This function may be called from any thread. Access is not - * synchronized. - * - * @since Added in version 3.0. - * - * @ingroup native - */ -GLFWAPI Display* glfwGetX11Display(void); - -/*! @brief Returns the `RRCrtc` of the specified monitor. - * - * @return The `RRCrtc` of the specified monitor, or `None` if an - * [error](@ref error_handling) occurred. - * - * @thread_safety This function may be called from any thread. Access is not - * synchronized. - * - * @since Added in version 3.1. - * - * @ingroup native - */ -GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor); - -/*! @brief Returns the `RROutput` of the specified monitor. - * - * @return The `RROutput` of the specified monitor, or `None` if an - * [error](@ref error_handling) occurred. - * - * @thread_safety This function may be called from any thread. Access is not - * synchronized. - * - * @since Added in version 3.1. - * - * @ingroup native - */ -GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* monitor); - -/*! @brief Returns the `Window` of the specified window. - * - * @return The `Window` of the specified window, or `None` if an - * [error](@ref error_handling) occurred. - * - * @thread_safety This function may be called from any thread. Access is not - * synchronized. - * - * @since Added in version 3.0. - * - * @ingroup native - */ -GLFWAPI Window glfwGetX11Window(GLFWwindow* window); -#endif - -#if defined(GLFW_EXPOSE_NATIVE_GLX) -/*! @brief Returns the `GLXContext` of the specified window. - * - * @return The `GLXContext` of the specified window, or `NULL` if an - * [error](@ref error_handling) occurred. - * - * @thread_safety This function may be called from any thread. Access is not - * synchronized. - * - * @since Added in version 3.0. - * - * @ingroup native - */ -GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window); - -/*! @brief Returns the `GLXWindow` of the specified window. - * - * @return The `GLXWindow` of the specified window, or `None` if an - * [error](@ref error_handling) occurred. - * - * @thread_safety This function may be called from any thread. Access is not - * synchronized. - * - * @since Added in version 3.2. - * - * @ingroup native - */ -GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* window); -#endif - -#if defined(GLFW_EXPOSE_NATIVE_WAYLAND) -/*! @brief Returns the `struct wl_display*` used by GLFW. - * - * @return The `struct wl_display*` used by GLFW, or `NULL` if an - * [error](@ref error_handling) occurred. - * - * @thread_safety This function may be called from any thread. Access is not - * synchronized. - * - * @since Added in version 3.2. - * - * @ingroup native - */ -GLFWAPI struct wl_display* glfwGetWaylandDisplay(void); - -/*! @brief Returns the `struct wl_output*` of the specified monitor. - * - * @return The `struct wl_output*` of the specified monitor, or `NULL` if an - * [error](@ref error_handling) occurred. - * - * @thread_safety This function may be called from any thread. Access is not - * synchronized. - * - * @since Added in version 3.2. - * - * @ingroup native - */ -GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* monitor); - -/*! @brief Returns the main `struct wl_surface*` of the specified window. - * - * @return The main `struct wl_surface*` of the specified window, or `NULL` if - * an [error](@ref error_handling) occurred. - * - * @thread_safety This function may be called from any thread. Access is not - * synchronized. - * - * @since Added in version 3.2. - * - * @ingroup native - */ -GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* window); -#endif - -#if defined(GLFW_EXPOSE_NATIVE_MIR) -/*! @brief Returns the `MirConnection*` used by GLFW. - * - * @return The `MirConnection*` used by GLFW, or `NULL` if an - * [error](@ref error_handling) occurred. - * - * @thread_safety This function may be called from any thread. Access is not - * synchronized. - * - * @since Added in version 3.2. - * - * @ingroup native - */ -GLFWAPI MirConnection* glfwGetMirDisplay(void); - -/*! @brief Returns the Mir output ID of the specified monitor. - * - * @return The Mir output ID of the specified monitor, or zero if an - * [error](@ref error_handling) occurred. - * - * @thread_safety This function may be called from any thread. Access is not - * synchronized. - * - * @since Added in version 3.2. - * - * @ingroup native - */ -GLFWAPI int glfwGetMirMonitor(GLFWmonitor* monitor); - -/*! @brief Returns the `MirSurface*` of the specified window. - * - * @return The `MirSurface*` of the specified window, or `NULL` if an - * [error](@ref error_handling) occurred. - * - * @thread_safety This function may be called from any thread. Access is not - * synchronized. - * - * @since Added in version 3.2. - * - * @ingroup native - */ -GLFWAPI MirSurface* glfwGetMirWindow(GLFWwindow* window); -#endif - -#if defined(GLFW_EXPOSE_NATIVE_EGL) -/*! @brief Returns the `EGLDisplay` used by GLFW. - * - * @return The `EGLDisplay` used by GLFW, or `EGL_NO_DISPLAY` if an - * [error](@ref error_handling) occurred. - * - * @thread_safety This function may be called from any thread. Access is not - * synchronized. - * - * @since Added in version 3.0. - * - * @ingroup native - */ -GLFWAPI EGLDisplay glfwGetEGLDisplay(void); - -/*! @brief Returns the `EGLContext` of the specified window. - * - * @return The `EGLContext` of the specified window, or `EGL_NO_CONTEXT` if an - * [error](@ref error_handling) occurred. - * - * @thread_safety This function may be called from any thread. Access is not - * synchronized. - * - * @since Added in version 3.0. - * - * @ingroup native - */ -GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window); - -/*! @brief Returns the `EGLSurface` of the specified window. - * - * @return The `EGLSurface` of the specified window, or `EGL_NO_SURFACE` if an - * [error](@ref error_handling) occurred. - * - * @thread_safety This function may be called from any thread. Access is not - * synchronized. - * - * @since Added in version 3.0. - * - * @ingroup native - */ -GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window); -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _glfw3_native_h_ */ - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/libs/usynergy/README.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/libs/usynergy/README.txt deleted file mode 100644 index c86b909..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/libs/usynergy/README.txt +++ /dev/null @@ -1,8 +0,0 @@ - -uSynergy client -- Implementation for the embedded Synergy client library -version 1.0.0, July 7th, 2012 -Copyright (c) 2012 Alex Evans - -This is a copy of the files once found at: - https://github.com/symless/synergy-core/tree/790d108a56ada9caad8e56ff777d444485a69da9/src/micro - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/libs/usynergy/uSynergy.c b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/libs/usynergy/uSynergy.c deleted file mode 100644 index 8dce47b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/libs/usynergy/uSynergy.c +++ /dev/null @@ -1,636 +0,0 @@ -/* -uSynergy client -- Implementation for the embedded Synergy client library - version 1.0.0, July 7th, 2012 - -Copyright (c) 2012 Alex Evans - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ -#include "uSynergy.h" -#include -#include - - - -//--------------------------------------------------------------------------------------------------------------------- -// Internal helpers -//--------------------------------------------------------------------------------------------------------------------- - - - -/** -@brief Read 16 bit integer in network byte order and convert to native byte order -**/ -static int16_t sNetToNative16(const unsigned char *value) -{ -#ifdef USYNERGY_LITTLE_ENDIAN - return value[1] | (value[0] << 8); -#else - return value[0] | (value[1] << 8); -#endif -} - - - -/** -@brief Read 32 bit integer in network byte order and convert to native byte order -**/ -static int32_t sNetToNative32(const unsigned char *value) -{ -#ifdef USYNERGY_LITTLE_ENDIAN - return value[3] | (value[2] << 8) | (value[1] << 16) | (value[0] << 24); -#else - return value[0] | (value[1] << 8) | (value[2] << 16) | (value[3] << 24); -#endif -} - - - -/** -@brief Trace text to client -**/ -static void sTrace(uSynergyContext *context, const char* text) -{ - // Don't trace if we don't have a trace function - if (context->m_traceFunc != 0L) - context->m_traceFunc(context->m_cookie, text); -} - - - -/** -@brief Add string to reply packet -**/ -static void sAddString(uSynergyContext *context, const char *string) -{ - size_t len = strlen(string); - memcpy(context->m_replyCur, string, len); - context->m_replyCur += len; -} - - - -/** -@brief Add uint8 to reply packet -**/ -static void sAddUInt8(uSynergyContext *context, uint8_t value) -{ - *context->m_replyCur++ = value; -} - - - -/** -@brief Add uint16 to reply packet -**/ -static void sAddUInt16(uSynergyContext *context, uint16_t value) -{ - uint8_t *reply = context->m_replyCur; - *reply++ = (uint8_t)(value >> 8); - *reply++ = (uint8_t)value; - context->m_replyCur = reply; -} - - - -/** -@brief Add uint32 to reply packet -**/ -static void sAddUInt32(uSynergyContext *context, uint32_t value) -{ - uint8_t *reply = context->m_replyCur; - *reply++ = (uint8_t)(value >> 24); - *reply++ = (uint8_t)(value >> 16); - *reply++ = (uint8_t)(value >> 8); - *reply++ = (uint8_t)value; - context->m_replyCur = reply; -} - - - -/** -@brief Send reply packet -**/ -static uSynergyBool sSendReply(uSynergyContext *context) -{ - // Set header size - uint8_t *reply_buf = context->m_replyBuffer; - uint32_t reply_len = (uint32_t)(context->m_replyCur - reply_buf); /* Total size of reply */ - uint32_t body_len = reply_len - 4; /* Size of body */ - uSynergyBool ret; - reply_buf[0] = (uint8_t)(body_len >> 24); - reply_buf[1] = (uint8_t)(body_len >> 16); - reply_buf[2] = (uint8_t)(body_len >> 8); - reply_buf[3] = (uint8_t)body_len; - - // Send reply - ret = context->m_sendFunc(context->m_cookie, context->m_replyBuffer, reply_len); - - // Reset reply buffer write pointer - context->m_replyCur = context->m_replyBuffer+4; - return ret; -} - - - -/** -@brief Call mouse callback after a mouse event -**/ -static void sSendMouseCallback(uSynergyContext *context) -{ - // Skip if no callback is installed - if (context->m_mouseCallback == 0L) - return; - - // Send callback - context->m_mouseCallback(context->m_cookie, context->m_mouseX, context->m_mouseY, context->m_mouseWheelX, - context->m_mouseWheelY, context->m_mouseButtonLeft, context->m_mouseButtonRight, context->m_mouseButtonMiddle); -} - - - -/** -@brief Send keyboard callback when a key has been pressed or released -**/ -static void sSendKeyboardCallback(uSynergyContext *context, uint16_t key, uint16_t modifiers, uSynergyBool down, uSynergyBool repeat) -{ - // Skip if no callback is installed - if (context->m_keyboardCallback == 0L) - return; - - // Send callback - context->m_keyboardCallback(context->m_cookie, key, modifiers, down, repeat); -} - - - -/** -@brief Send joystick callback -**/ -static void sSendJoystickCallback(uSynergyContext *context, uint8_t joyNum) -{ - int8_t *sticks; - - // Skip if no callback is installed - if (context->m_joystickCallback == 0L) - return; - - // Send callback - sticks = context->m_joystickSticks[joyNum]; - context->m_joystickCallback(context->m_cookie, joyNum, context->m_joystickButtons[joyNum], sticks[0], sticks[1], sticks[2], sticks[3]); -} - - - -/** -@brief Parse a single client message, update state, send callbacks and send replies -**/ -#define USYNERGY_IS_PACKET(pkt_id) memcmp(message+4, pkt_id, 4)==0 -static void sProcessMessage(uSynergyContext *context, const uint8_t *message) -{ - // We have a packet! - if (memcmp(message+4, "Synergy", 7)==0) - { - // Welcome message - // kMsgHello = "Synergy%2i%2i" - // kMsgHelloBack = "Synergy%2i%2i%s" - sAddString(context, "Synergy"); - sAddUInt16(context, USYNERGY_PROTOCOL_MAJOR); - sAddUInt16(context, USYNERGY_PROTOCOL_MINOR); - sAddUInt32(context, (uint32_t)strlen(context->m_clientName)); - sAddString(context, context->m_clientName); - if (!sSendReply(context)) - { - // Send reply failed, let's try to reconnect - sTrace(context, "SendReply failed, trying to reconnect in a second"); - context->m_connected = USYNERGY_FALSE; - context->m_sleepFunc(context->m_cookie, 1000); - } - else - { - // Let's assume we're connected - char buffer[256+1]; - sprintf(buffer, "Connected as client \"%s\"", context->m_clientName); - sTrace(context, buffer); - context->m_hasReceivedHello = USYNERGY_TRUE; - } - return; - } - else if (USYNERGY_IS_PACKET("QINF")) - { - // Screen info. Reply with DINF - // kMsgQInfo = "QINF" - // kMsgDInfo = "DINF%2i%2i%2i%2i%2i%2i%2i" - uint16_t x = 0, y = 0, warp = 0; - sAddString(context, "DINF"); - sAddUInt16(context, x); - sAddUInt16(context, y); - sAddUInt16(context, context->m_clientWidth); - sAddUInt16(context, context->m_clientHeight); - sAddUInt16(context, warp); - sAddUInt16(context, 0); // mx? - sAddUInt16(context, 0); // my? - sSendReply(context); - return; - } - else if (USYNERGY_IS_PACKET("CIAK")) - { - // Do nothing? - // kMsgCInfoAck = "CIAK" - return; - } - else if (USYNERGY_IS_PACKET("CROP")) - { - // Do nothing? - // kMsgCResetOptions = "CROP" - return; - } - else if (USYNERGY_IS_PACKET("CINN")) - { - // Screen enter. Reply with CNOP - // kMsgCEnter = "CINN%2i%2i%4i%2i" - - // Obtain the Synergy sequence number - context->m_sequenceNumber = sNetToNative32(message + 12); - context->m_isCaptured = USYNERGY_TRUE; - - // Call callback - if (context->m_screenActiveCallback != 0L) - context->m_screenActiveCallback(context->m_cookie, USYNERGY_TRUE); - } - else if (USYNERGY_IS_PACKET("COUT")) - { - // Screen leave - // kMsgCLeave = "COUT" - context->m_isCaptured = USYNERGY_FALSE; - - // Call callback - if (context->m_screenActiveCallback != 0L) - context->m_screenActiveCallback(context->m_cookie, USYNERGY_FALSE); - } - else if (USYNERGY_IS_PACKET("DMDN")) - { - // Mouse down - // kMsgDMouseDown = "DMDN%1i" - char btn = message[8]-1; - if (btn==2) - context->m_mouseButtonRight = USYNERGY_TRUE; - else if (btn==1) - context->m_mouseButtonMiddle = USYNERGY_TRUE; - else - context->m_mouseButtonLeft = USYNERGY_TRUE; - sSendMouseCallback(context); - } - else if (USYNERGY_IS_PACKET("DMUP")) - { - // Mouse up - // kMsgDMouseUp = "DMUP%1i" - char btn = message[8]-1; - if (btn==2) - context->m_mouseButtonRight = USYNERGY_FALSE; - else if (btn==1) - context->m_mouseButtonMiddle = USYNERGY_FALSE; - else - context->m_mouseButtonLeft = USYNERGY_FALSE; - sSendMouseCallback(context); - } - else if (USYNERGY_IS_PACKET("DMMV")) - { - // Mouse move. Reply with CNOP - // kMsgDMouseMove = "DMMV%2i%2i" - context->m_mouseX = sNetToNative16(message+8); - context->m_mouseY = sNetToNative16(message+10); - sSendMouseCallback(context); - } - else if (USYNERGY_IS_PACKET("DMWM")) - { - // Mouse wheel - // kMsgDMouseWheel = "DMWM%2i%2i" - // kMsgDMouseWheel1_0 = "DMWM%2i" - context->m_mouseWheelX += sNetToNative16(message+8); - context->m_mouseWheelY += sNetToNative16(message+10); - sSendMouseCallback(context); - } - else if (USYNERGY_IS_PACKET("DKDN")) - { - // Key down - // kMsgDKeyDown = "DKDN%2i%2i%2i" - // kMsgDKeyDown1_0 = "DKDN%2i%2i" - //uint16_t id = sNetToNative16(message+8); - uint16_t mod = sNetToNative16(message+10); - uint16_t key = sNetToNative16(message+12); - sSendKeyboardCallback(context, key, mod, USYNERGY_TRUE, USYNERGY_FALSE); - } - else if (USYNERGY_IS_PACKET("DKRP")) - { - // Key repeat - // kMsgDKeyRepeat = "DKRP%2i%2i%2i%2i" - // kMsgDKeyRepeat1_0 = "DKRP%2i%2i%2i" - uint16_t mod = sNetToNative16(message+10); -// uint16_t count = sNetToNative16(message+12); - uint16_t key = sNetToNative16(message+14); - sSendKeyboardCallback(context, key, mod, USYNERGY_TRUE, USYNERGY_TRUE); - } - else if (USYNERGY_IS_PACKET("DKUP")) - { - // Key up - // kMsgDKeyUp = "DKUP%2i%2i%2i" - // kMsgDKeyUp1_0 = "DKUP%2i%2i" - //uint16 id=Endian::sNetToNative(sbuf[4]); - uint16_t mod = sNetToNative16(message+10); - uint16_t key = sNetToNative16(message+12); - sSendKeyboardCallback(context, key, mod, USYNERGY_FALSE, USYNERGY_FALSE); - } - else if (USYNERGY_IS_PACKET("DGBT")) - { - // Joystick buttons - // kMsgDGameButtons = "DGBT%1i%2i"; - uint8_t joy_num = message[8]; - if (joy_numm_joystickButtons[joy_num] = (message[9] << 8) | message[10]; - sSendJoystickCallback(context, joy_num); - } - } - else if (USYNERGY_IS_PACKET("DGST")) - { - // Joystick sticks - // kMsgDGameSticks = "DGST%1i%1i%1i%1i%1i"; - uint8_t joy_num = message[8]; - if (joy_numm_joystickSticks[joy_num], message+9, 4); - sSendJoystickCallback(context, joy_num); - } - } - else if (USYNERGY_IS_PACKET("DSOP")) - { - // Set options - // kMsgDSetOptions = "DSOP%4I" - } - else if (USYNERGY_IS_PACKET("CALV")) - { - // Keepalive, reply with CALV and then CNOP - // kMsgCKeepAlive = "CALV" - sAddString(context, "CALV"); - sSendReply(context); - // now reply with CNOP - } - else if (USYNERGY_IS_PACKET("DCLP")) - { - // Clipboard message - // kMsgDClipboard = "DCLP%1i%4i%s" - // - // The clipboard message contains: - // 1 uint32: The size of the message - // 4 chars: The identifier ("DCLP") - // 1 uint8: The clipboard index - // 1 uint32: The sequence number. It's zero, because this message is always coming from the server? - // 1 uint32: The total size of the remaining 'string' (as per the Synergy %s string format (which is 1 uint32 for size followed by a char buffer (not necessarily null terminated)). - // 1 uint32: The number of formats present in the message - // And then 'number of formats' times the following: - // 1 uint32: The format of the clipboard data - // 1 uint32: The size n of the clipboard data - // n uint8: The clipboard data - const uint8_t * parse_msg = message+17; - uint32_t num_formats = sNetToNative32(parse_msg); - parse_msg += 4; - for (; num_formats; num_formats--) - { - // Parse clipboard format header - uint32_t format = sNetToNative32(parse_msg); - uint32_t size = sNetToNative32(parse_msg+4); - parse_msg += 8; - - // Call callback - if (context->m_clipboardCallback) - context->m_clipboardCallback(context->m_cookie, format, parse_msg, size); - - parse_msg += size; - } - } - else - { - // Unknown packet, could be any of these - // kMsgCNoop = "CNOP" - // kMsgCClose = "CBYE" - // kMsgCClipboard = "CCLP%1i%4i" - // kMsgCScreenSaver = "CSEC%1i" - // kMsgDKeyRepeat = "DKRP%2i%2i%2i%2i" - // kMsgDKeyRepeat1_0 = "DKRP%2i%2i%2i" - // kMsgDMouseRelMove = "DMRM%2i%2i" - // kMsgEIncompatible = "EICV%2i%2i" - // kMsgEBusy = "EBSY" - // kMsgEUnknown = "EUNK" - // kMsgEBad = "EBAD" - char buffer[64]; - sprintf(buffer, "Unknown packet '%c%c%c%c'", message[4], message[5], message[6], message[7]); - sTrace(context, buffer); - return; - } - - // Reply with CNOP maybe? - sAddString(context, "CNOP"); - sSendReply(context); -} -#undef USYNERGY_IS_PACKET - - - -/** -@brief Mark context as being disconnected -**/ -static void sSetDisconnected(uSynergyContext *context) -{ - context->m_connected = USYNERGY_FALSE; - context->m_hasReceivedHello = USYNERGY_FALSE; - context->m_isCaptured = USYNERGY_FALSE; - context->m_replyCur = context->m_replyBuffer + 4; - context->m_sequenceNumber = 0; -} - - - -/** -@brief Update a connected context -**/ -static void sUpdateContext(uSynergyContext *context) -{ - /* Receive data (blocking) */ - int receive_size = USYNERGY_RECEIVE_BUFFER_SIZE - context->m_receiveOfs; - int num_received = 0; - int packlen = 0; - if (context->m_receiveFunc(context->m_cookie, context->m_receiveBuffer + context->m_receiveOfs, receive_size, &num_received) == USYNERGY_FALSE) - { - /* Receive failed, let's try to reconnect */ - char buffer[128]; - sprintf(buffer, "Receive failed (%d bytes asked, %d bytes received), trying to reconnect in a second", receive_size, num_received); - sTrace(context, buffer); - sSetDisconnected(context); - context->m_sleepFunc(context->m_cookie, 1000); - return; - } - context->m_receiveOfs += num_received; - - /* If we didn't receive any data then we're probably still polling to get connected and - therefore not getting any data back. To avoid overloading the system with a Synergy - thread that would hammer on polling, we let it rest for a bit if there's no data. */ - if (num_received == 0) - context->m_sleepFunc(context->m_cookie, 500); - - /* Check for timeouts */ - if (context->m_hasReceivedHello) - { - uint32_t cur_time = context->m_getTimeFunc(); - if (num_received == 0) - { - /* Timeout after 2 secs of inactivity (we received no CALV) */ - if ((cur_time - context->m_lastMessageTime) > USYNERGY_IDLE_TIMEOUT) - sSetDisconnected(context); - } - else - context->m_lastMessageTime = cur_time; - } - - /* Eat packets */ - for (;;) - { - /* Grab packet length and bail out if the packet goes beyond the end of the buffer */ - packlen = sNetToNative32(context->m_receiveBuffer); - if (packlen+4 > context->m_receiveOfs) - break; - - /* Process message */ - sProcessMessage(context, context->m_receiveBuffer); - - /* Move packet to front of buffer */ - memmove(context->m_receiveBuffer, context->m_receiveBuffer+packlen+4, context->m_receiveOfs-packlen-4); - context->m_receiveOfs -= packlen+4; - } - - /* Throw away over-sized packets */ - if (packlen > USYNERGY_RECEIVE_BUFFER_SIZE) - { - /* Oversized packet, ditch tail end */ - char buffer[128]; - sprintf(buffer, "Oversized packet: '%c%c%c%c' (length %d)", context->m_receiveBuffer[4], context->m_receiveBuffer[5], context->m_receiveBuffer[6], context->m_receiveBuffer[7], packlen); - sTrace(context, buffer); - num_received = context->m_receiveOfs-4; // 4 bytes for the size field - while (num_received != packlen) - { - int buffer_left = packlen - num_received; - int to_receive = buffer_left < USYNERGY_RECEIVE_BUFFER_SIZE ? buffer_left : USYNERGY_RECEIVE_BUFFER_SIZE; - int ditch_received = 0; - if (context->m_receiveFunc(context->m_cookie, context->m_receiveBuffer, to_receive, &ditch_received) == USYNERGY_FALSE) - { - /* Receive failed, let's try to reconnect */ - sTrace(context, "Receive failed, trying to reconnect in a second"); - sSetDisconnected(context); - context->m_sleepFunc(context->m_cookie, 1000); - break; - } - else - { - num_received += ditch_received; - } - } - context->m_receiveOfs = 0; - } -} - - -//--------------------------------------------------------------------------------------------------------------------- -// Public interface -//--------------------------------------------------------------------------------------------------------------------- - - - -/** -@brief Initialize uSynergy context -**/ -void uSynergyInit(uSynergyContext *context) -{ - /* Zero memory */ - memset(context, 0, sizeof(uSynergyContext)); - - /* Initialize to default state */ - sSetDisconnected(context); -} - - -/** -@brief Update uSynergy -**/ -void uSynergyUpdate(uSynergyContext *context) -{ - if (context->m_connected) - { - /* Update context, receive data, call callbacks */ - sUpdateContext(context); - } - else - { - /* Try to connect */ - if (context->m_connectFunc(context->m_cookie)) - context->m_connected = USYNERGY_TRUE; - } -} - - - -/** -@brief Send clipboard data -**/ -void uSynergySendClipboard(uSynergyContext *context, const char *text) -{ - // Calculate maximum size that will fit in a reply packet - uint32_t overhead_size = 4 + /* Message size */ - 4 + /* Message ID */ - 1 + /* Clipboard index */ - 4 + /* Sequence number */ - 4 + /* Rest of message size (because it's a Synergy string from here on) */ - 4 + /* Number of clipboard formats */ - 4 + /* Clipboard format */ - 4; /* Clipboard data length */ - uint32_t max_length = USYNERGY_REPLY_BUFFER_SIZE - overhead_size; - - // Clip text to max length - uint32_t text_length = (uint32_t)strlen(text); - if (text_length > max_length) - { - char buffer[128]; - sprintf(buffer, "Clipboard buffer too small, clipboard truncated at %d characters", max_length); - sTrace(context, buffer); - text_length = max_length; - } - - // Assemble packet - sAddString(context, "DCLP"); - sAddUInt8(context, 0); /* Clipboard index */ - sAddUInt32(context, context->m_sequenceNumber); - sAddUInt32(context, 4+4+4+text_length); /* Rest of message size: numFormats, format, length, data */ - sAddUInt32(context, 1); /* Number of formats (only text for now) */ - sAddUInt32(context, USYNERGY_CLIPBOARD_FORMAT_TEXT); - sAddUInt32(context, text_length); - sAddString(context, text); - sSendReply(context); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/libs/usynergy/uSynergy.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/libs/usynergy/uSynergy.h deleted file mode 100644 index cedc387..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/examples/libs/usynergy/uSynergy.h +++ /dev/null @@ -1,420 +0,0 @@ -/* -uSynergy client -- Interface for the embedded Synergy client library - version 1.0.0, July 7th, 2012 - -Copyright (C) 2012 Synergy Si Ltd. -Copyright (c) 2012 Alex Evans - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. -*/ -#include - -#ifdef __cplusplus -extern "C" { -#endif - - - -//--------------------------------------------------------------------------------------------------------------------- -// Configuration -//--------------------------------------------------------------------------------------------------------------------- - - - -/** -@brief Determine endianness -**/ -#if defined(USYNERGY_LITTLE_ENDIAN) && defined(USYNERGY_BIG_ENDIAN) - /* Ambiguous: both endians specified */ - #error "Can't define both USYNERGY_LITTLE_ENDIAN and USYNERGY_BIG_ENDIAN" -#elif !defined(USYNERGY_LITTLE_ENDIAN) && !defined(USYNERGY_BIG_ENDIAN) - /* Attempt to auto detect */ - #if defined(__LITTLE_ENDIAN__) || defined(LITTLE_ENDIAN) || (_BYTE_ORDER == _LITTLE_ENDIAN) - #define USYNERGY_LITTLE_ENDIAN - #elif defined(__BIG_ENDIAN__) || defined(BIG_ENDIAN) || (_BYTE_ORDER == _BIG_ENDIAN) - #define USYNERGY_BIG_ENDIAN - #else - #error "Can't detect endian-nes, please defined either USYNERGY_LITTLE_ENDIAN or USYNERGY_BIG_ENDIAN"; - #endif -#else - /* User-specified endian-nes, nothing to do for us */ -#endif - - - -//--------------------------------------------------------------------------------------------------------------------- -// Types and Constants -//--------------------------------------------------------------------------------------------------------------------- - - - -/** -@brief Boolean type -**/ -typedef int uSynergyBool; -#define USYNERGY_FALSE 0 /* False value */ -#define USYNERGY_TRUE 1 /* True value */ - - -/** -@brief User context type - -The uSynergyCookie type is an opaque type that is used by uSynergy to communicate to the client. It is passed along to -callback functions as context. -**/ -typedef struct { int ignored; } * uSynergyCookie; - - - -/** -@brief Clipboard types -**/ -enum uSynergyClipboardFormat -{ - USYNERGY_CLIPBOARD_FORMAT_TEXT = 0, /* Text format, UTF-8, newline is LF */ - USYNERGY_CLIPBOARD_FORMAT_BITMAP = 1, /* Bitmap format, BMP 24/32bpp, BI_RGB */ - USYNERGY_CLIPBOARD_FORMAT_HTML = 2, /* HTML format, HTML fragment, UTF-8, newline is LF */ -}; - - - -/** -@brief Constants and limits -**/ -#define USYNERGY_NUM_JOYSTICKS 4 /* Maximum number of supported joysticks */ - -#define USYNERGY_PROTOCOL_MAJOR 1 /* Major protocol version */ -#define USYNERGY_PROTOCOL_MINOR 4 /* Minor protocol version */ - -#define USYNERGY_IDLE_TIMEOUT 2000 /* Timeout in milliseconds before reconnecting */ - -#define USYNERGY_TRACE_BUFFER_SIZE 1024 /* Maximum length of traced message */ -#define USYNERGY_REPLY_BUFFER_SIZE 1024 /* Maximum size of a reply packet */ -#define USYNERGY_RECEIVE_BUFFER_SIZE 4096 /* Maximum size of an incoming packet */ - - - -/** -@brief Keyboard constants -**/ -#define USYNERGY_MODIFIER_SHIFT 0x0001 /* Shift key modifier */ -#define USYNERGY_MODIFIER_CTRL 0x0002 /* Ctrl key modifier */ -#define USYNERGY_MODIFIER_ALT 0x0004 /* Alt key modifier */ -#define USYNERGY_MODIFIER_META 0x0008 /* Meta key modifier */ -#define USYNERGY_MODIFIER_WIN 0x0010 /* Windows key modifier */ -#define USYNERGY_MODIFIER_ALT_GR 0x0020 /* AltGr key modifier */ -#define USYNERGY_MODIFIER_LEVEL5LOCK 0x0040 /* Level5Lock key modifier */ -#define USYNERGY_MODIFIER_CAPSLOCK 0x1000 /* CapsLock key modifier */ -#define USYNERGY_MODIFIER_NUMLOCK 0x2000 /* NumLock key modifier */ -#define USYNERGY_MODIFIER_SCROLLOCK 0x4000 /* ScrollLock key modifier */ - - - - -//--------------------------------------------------------------------------------------------------------------------- -// Functions and Callbacks -//--------------------------------------------------------------------------------------------------------------------- - - - -/** -@brief Connect function - -This function is called when uSynergy needs to connect to the host. It doesn't imply a network implementation or -destination address, that must all be handled on the user side. The function should return USYNERGY_TRUE if a -connection was established or USYNERGY_FALSE if it could not connect. - -When network errors occur (e.g. uSynergySend or uSynergyReceive fail) then the connect call will be called again -so the implementation of the function must close any old connections and clean up resources before retrying. - -@param cookie Cookie supplied in the Synergy context -**/ -typedef uSynergyBool (*uSynergyConnectFunc)(uSynergyCookie cookie); - - - -/** -@brief Send function - -This function is called when uSynergy needs to send something over the default connection. It should return -USYNERGY_TRUE if sending succeeded and USYNERGY_FALSE otherwise. This function should block until the send -operation is completed. - -@param cookie Cookie supplied in the Synergy context -@param buffer Address of buffer to send -@param length Length of buffer to send -**/ -typedef uSynergyBool (*uSynergySendFunc)(uSynergyCookie cookie, const uint8_t *buffer, int length); - - - -/** -@brief Receive function - -This function is called when uSynergy needs to receive data from the default connection. It should return -USYNERGY_TRUE if receiving data succeeded and USYNERGY_FALSE otherwise. This function should block until data -has been received and wait for data to become available. If @a outLength is set to 0 upon completion it is -assumed that the connection is alive, but still in a connecting state and needs time to settle. - -@param cookie Cookie supplied in the Synergy context -@param buffer Address of buffer to receive data into -@param maxLength Maximum amount of bytes to write into the receive buffer -@param outLength Address of integer that receives the actual amount of bytes written into @a buffer -**/ -typedef uSynergyBool (*uSynergyReceiveFunc)(uSynergyCookie cookie, uint8_t *buffer, int maxLength, int* outLength); - - - -/** -@brief Thread sleep function - -This function is called when uSynergy wants to suspend operation for a while before retrying an operation. It -is mostly used when a socket times out or disconnect occurs to prevent uSynergy from continuously hammering a -network connection in case the network is down. - -@param cookie Cookie supplied in the Synergy context -@param timeMs Time to sleep the current thread (in milliseconds) -**/ -typedef void (*uSynergySleepFunc)(uSynergyCookie cookie, int timeMs); - - - -/** -@brief Get time function - -This function is called when uSynergy needs to know the current time. This is used to determine when timeouts -have occured. The time base should be a cyclic millisecond time value. - -@returns Time value in milliseconds -**/ -typedef uint32_t (*uSynergyGetTimeFunc)(); - - - -/** -@brief Trace function - -This function is called when uSynergy wants to trace something. It is optional to show these messages, but they -are often useful when debugging. uSynergy only traces major events like connecting and disconnecting. Usually -only a single trace is shown when the connection is established and no more trace are called. - -@param cookie Cookie supplied in the Synergy context -@param text Text to be traced -**/ -typedef void (*uSynergyTraceFunc)(uSynergyCookie cookie, const char *text); - - - -/** -@brief Screen active callback - -This callback is called when Synergy makes the screen active or inactive. This -callback is usually sent when the mouse enters or leaves the screen. - -@param cookie Cookie supplied in the Synergy context -@param active Activation flag, 1 if the screen has become active, 0 if the screen has become inactive -**/ -typedef void (*uSynergyScreenActiveCallback)(uSynergyCookie cookie, uSynergyBool active); - - - -/** -@brief Mouse callback - -This callback is called when a mouse events happens. The mouse X and Y position, -wheel and button state is communicated in the message. It's up to the user to -interpret if this is a mouse up, down, double-click or other message. - -@param cookie Cookie supplied in the Synergy context -@param x Mouse X position -@param y Mouse Y position -@param wheelX Mouse wheel X position -@param wheelY Mouse wheel Y position -@param buttonLeft Left button pressed status, 0 for released, 1 for pressed -@param buttonMiddle Middle button pressed status, 0 for released, 1 for pressed -@param buttonRight Right button pressed status, 0 for released, 1 for pressed -**/ -typedef void (*uSynergyMouseCallback)(uSynergyCookie cookie, uint16_t x, uint16_t y, int16_t wheelX, int16_t wheelY, uSynergyBool buttonLeft, uSynergyBool buttonRight, uSynergyBool buttonMiddle); - - - -/** -@brief Key event callback - -This callback is called when a key is pressed or released. - -@param cookie Cookie supplied in the Synergy context -@param key Key code of key that was pressed or released -@param modifiers Status of modifier keys (alt, shift, etc.) -@param down Down or up status, 1 is key is pressed down, 0 if key is released (up) -@param repeat Repeat flag, 1 if the key is down because the key is repeating, 0 if the key is initially pressed by the user -**/ -typedef void (*uSynergyKeyboardCallback)(uSynergyCookie cookie, uint16_t key, uint16_t modifiers, uSynergyBool down, uSynergyBool repeat); - - - -/** -@brief Joystick event callback - -This callback is called when a joystick stick or button changes. It is possible that multiple callbacks are -fired when different sticks or buttons change as these are individual messages in the packet stream. Each -callback will contain all the valid state for the different axes and buttons. The last callback received will -represent the most current joystick state. - -@param cookie Cookie supplied in the Synergy context -@param joyNum Joystick number, always in the range [0 ... USYNERGY_NUM_JOYSTICKS> -@param buttons Button pressed mask -@param leftStickX Left stick X position, in range [-127 ... 127] -@param leftStickY Left stick Y position, in range [-127 ... 127] -@param rightStickX Right stick X position, in range [-127 ... 127] -@param rightStickY Right stick Y position, in range [-127 ... 127] -**/ -typedef void (*uSynergyJoystickCallback)(uSynergyCookie cookie, uint8_t joyNum, uint16_t buttons, int8_t leftStickX, int8_t leftStickY, int8_t rightStickX, int8_t rightStickY); - - - -/** -@brief Clipboard event callback - -This callback is called when something is placed on the clipboard. Multiple callbacks may be fired for -multiple clipboard formats if they are supported. The data provided is read-only and may not be modified -by the application. - -@param cookie Cookie supplied in the Synergy context -@param format Clipboard format -@param data Memory area containing the clipboard raw data -@param size Size of clipboard data -**/ -typedef void (*uSynergyClipboardCallback)(uSynergyCookie cookie, enum uSynergyClipboardFormat format, const uint8_t *data, uint32_t size); - - - -//--------------------------------------------------------------------------------------------------------------------- -// Context -//--------------------------------------------------------------------------------------------------------------------- - - - -/** -@brief uSynergy context -**/ -typedef struct -{ - /* Mandatory configuration data, filled in by client */ - uSynergyConnectFunc m_connectFunc; /* Connect function */ - uSynergySendFunc m_sendFunc; /* Send data function */ - uSynergyReceiveFunc m_receiveFunc; /* Receive data function */ - uSynergySleepFunc m_sleepFunc; /* Thread sleep function */ - uSynergyGetTimeFunc m_getTimeFunc; /* Get current time function */ - const char* m_clientName; /* Name of Synergy Screen / Client */ - uint16_t m_clientWidth; /* Width of screen */ - uint16_t m_clientHeight; /* Height of screen */ - - /* Optional configuration data, filled in by client */ - uSynergyCookie m_cookie; /* Cookie pointer passed to callback functions (can be NULL) */ - uSynergyTraceFunc m_traceFunc; /* Function for tracing status (can be NULL) */ - uSynergyScreenActiveCallback m_screenActiveCallback; /* Callback for entering and leaving screen */ - uSynergyMouseCallback m_mouseCallback; /* Callback for mouse events */ - uSynergyKeyboardCallback m_keyboardCallback; /* Callback for keyboard events */ - uSynergyJoystickCallback m_joystickCallback; /* Callback for joystick events */ - uSynergyClipboardCallback m_clipboardCallback; /* Callback for clipboard events */ - - /* State data, used internall by client, initialized by uSynergyInit() */ - uSynergyBool m_connected; /* Is our socket connected? */ - uSynergyBool m_hasReceivedHello; /* Have we received a 'Hello' from the server? */ - uSynergyBool m_isCaptured; /* Is Synergy active (i.e. this client is receiving input messages?) */ - uint32_t m_lastMessageTime; /* Time at which last message was received */ - uint32_t m_sequenceNumber; /* Packet sequence number */ - uint8_t m_receiveBuffer[USYNERGY_RECEIVE_BUFFER_SIZE]; /* Receive buffer */ - int m_receiveOfs; /* Receive buffer offset */ - uint8_t m_replyBuffer[USYNERGY_REPLY_BUFFER_SIZE]; /* Reply buffer */ - uint8_t* m_replyCur; /* Write offset into reply buffer */ - uint16_t m_mouseX; /* Mouse X position */ - uint16_t m_mouseY; /* Mouse Y position */ - int16_t m_mouseWheelX; /* Mouse wheel X position */ - int16_t m_mouseWheelY; /* Mouse wheel Y position */ - uSynergyBool m_mouseButtonLeft; /* Mouse left button */ - uSynergyBool m_mouseButtonRight; /* Mouse right button */ - uSynergyBool m_mouseButtonMiddle; /* Mouse middle button */ - int8_t m_joystickSticks[USYNERGY_NUM_JOYSTICKS][4]; /* Joystick stick position in 2 axes for 2 sticks */ - uint16_t m_joystickButtons[USYNERGY_NUM_JOYSTICKS]; /* Joystick button state */ -} uSynergyContext; - - - -//--------------------------------------------------------------------------------------------------------------------- -// Interface -//--------------------------------------------------------------------------------------------------------------------- - - - -/** -@brief Initialize uSynergy context - -This function initializes @a context for use. Call this function directly after -creating the context, before filling in any configuration data in it. Not calling -this function will cause undefined behavior. - -@param context Context to be initialized -**/ -extern void uSynergyInit(uSynergyContext *context); - - - -/** -@brief Update uSynergy - -This function updates uSynergy and does the bulk of the work. It does connection management, -receiving data, reconnecting after errors or timeouts and so on. It assumes that networking -operations are blocking and it can suspend the current thread if it needs to wait. It is -best practice to call uSynergyUpdate from a background thread so it is responsive. - -Because uSynergy relies mostly on blocking calls it will mostly stay in thread sleep state -waiting for system mutexes and won't eat much memory. - -uSynergyUpdate doesn't do any memory allocations or have any side effects beyond those of -the callbacks it calls. - -@param context Context to be updated -**/ -extern void uSynergyUpdate(uSynergyContext *context); - - - -/** -@brief Send clipboard data - -This function sets new clipboard data and sends it to the server. Use this function if -your client cuts or copies data onto the clipboard that it needs to share with the -server. - -Currently there is only support for plaintext, but HTML and image data could be -supported with some effort. - -@param context Context to send clipboard data to -@param text Text to set to the clipboard -**/ -extern void uSynergySendClipboard(uSynergyContext *context, const char *text); - - - -#ifdef __cplusplus -}; -#endif diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imconfig.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imconfig.h deleted file mode 100644 index 7082c55..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imconfig.h +++ /dev/null @@ -1,123 +0,0 @@ -//----------------------------------------------------------------------------- -// COMPILE-TIME OPTIONS FOR DEAR IMGUI -// Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure. -// You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions. -//----------------------------------------------------------------------------- -// A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/rebased branch with your modifications to it) -// B) or '#define IMGUI_USER_CONFIG "my_imgui_config.h"' in your project and then add directives in your own file without touching this template. -//----------------------------------------------------------------------------- -// You need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include the imgui*.cpp -// files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures. -// Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts. -// Call IMGUI_CHECKVERSION() from your .cpp files to verify that the data structures your files are using are matching the ones imgui.cpp is using. -//----------------------------------------------------------------------------- - -#pragma once - -//---- Define assertion handler. Defaults to calling assert(). -// If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement. -//#define IM_ASSERT(_EXPR) MyAssert(_EXPR) -//#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts - -//---- Define attributes of all API symbols declarations, e.g. for DLL under Windows -// Using Dear ImGui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility. -// DLL users: heaps and globals are not shared across DLL boundaries! You will need to call SetCurrentContext() + SetAllocatorFunctions() -// for each static/DLL boundary you are calling from. Read "Context and Memory Allocators" section of imgui.cpp for more details. -//#define IMGUI_API __declspec( dllexport ) -//#define IMGUI_API __declspec( dllimport ) - -//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names. -//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS - -//---- Disable all of Dear ImGui or don't implement standard windows. -// It is very strongly recommended to NOT disable the demo windows during development. Please read comments in imgui_demo.cpp. -//#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty. -//#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty. Not recommended. -//#define IMGUI_DISABLE_METRICS_WINDOW // Disable metrics/debugger and other debug tools: ShowMetricsWindow() and ShowStackToolWindow() will be empty. - -//---- Don't implement some functions to reduce linkage requirements. -//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. (user32.lib/.a, kernel32.lib/.a) -//#define IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with Visual Studio] Implement default IME handler (require imm32.lib/.a, auto-link for Visual Studio, -limm32 on command-line for MinGW) -//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with non-Visual Studio compilers] Don't implement default IME handler (won't require imm32.lib/.a) -//#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, ime). -//#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default). -//#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf) -//#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself. -//#define IMGUI_DISABLE_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle at all (replace them with dummies) -//#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function. -//#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions(). -//#define IMGUI_DISABLE_SSE // Disable use of SSE intrinsics even if available - -//---- Include imgui_user.h at the end of imgui.h as a convenience -//#define IMGUI_INCLUDE_IMGUI_USER_H - -//---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another) -//#define IMGUI_USE_BGRA_PACKED_COLOR - -//---- Use 32-bit for ImWchar (default is 16-bit) to support unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...) -//#define IMGUI_USE_WCHAR32 - -//---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version -// By default the embedded implementations are declared static and not available outside of Dear ImGui sources files. -//#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h" -//#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h" -//#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION -//#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION - -//---- Use stb_printf's faster implementation of vsnprintf instead of the one from libc (unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined) -// Requires 'stb_sprintf.h' to be available in the include path. Compatibility checks of arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by STB sprintf. -// #define IMGUI_USE_STB_SPRINTF - -//---- Use FreeType to build and rasterize the font atlas (instead of stb_truetype which is embedded by default in Dear ImGui) -// Requires FreeType headers to be available in the include path. Requires program to be compiled with 'misc/freetype/imgui_freetype.cpp' (in this repository) + the FreeType library (not provided). -// On Windows you may use vcpkg with 'vcpkg install freetype --triplet=x64-windows' + 'vcpkg integrate install'. -//#define IMGUI_ENABLE_FREETYPE - -//---- Use stb_truetype to build and rasterize the font atlas (default) -// The only purpose of this define is if you want force compilation of the stb_truetype backend ALONG with the FreeType backend. -//#define IMGUI_ENABLE_STB_TRUETYPE - -//---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4. -// This will be inlined as part of ImVec2 and ImVec4 class declarations. -/* -#define IM_VEC2_CLASS_EXTRA \ - ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \ - operator MyVec2() const { return MyVec2(x,y); } - -#define IM_VEC4_CLASS_EXTRA \ - ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \ - operator MyVec4() const { return MyVec4(x,y,z,w); } -*/ - -//---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices. -// Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices). -// Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer. -// Read about ImGuiBackendFlags_RendererHasVtxOffset for details. -//#define ImDrawIdx unsigned int - -//---- Override ImDrawCallback signature (will need to modify renderer backends accordingly) -//struct ImDrawList; -//struct ImDrawCmd; -//typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data); -//#define ImDrawCallback MyImDrawCallback - -//---- Debug Tools: Macro to break in Debugger -// (use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.) -//#define IM_DEBUG_BREAK IM_ASSERT(0) -//#define IM_DEBUG_BREAK __debugbreak() - -//---- Debug Tools: Have the Item Picker break in the ItemAdd() function instead of ItemHoverable(), -// (which comes earlier in the code, will catch a few extra items, allow picking items other than Hovered one.) -// This adds a small runtime cost which is why it is not enabled by default. -//#define IMGUI_DEBUG_TOOL_ITEM_PICKER_EX - -//---- Debug Tools: Enable slower asserts -//#define IMGUI_DEBUG_PARANOID - -//---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files. -/* -namespace ImGui -{ - void MyFunction(const char* name, const MyMatrix44& v); -} -*/ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imgui.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imgui.cpp deleted file mode 100644 index e6f206e..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imgui.cpp +++ /dev/null @@ -1,12255 +0,0 @@ -// dear imgui, v1.85 -// (main code and documentation) - -// Help: -// - Read FAQ at http://dearimgui.org/faq -// - Newcomers, read 'Programmer guide' below for notes on how to setup Dear ImGui in your codebase. -// - Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp. All applications in examples/ are doing that. -// Read imgui.cpp for details, links and comments. - -// Resources: -// - FAQ http://dearimgui.org/faq -// - Homepage & latest https://github.com/ocornut/imgui -// - Releases & changelog https://github.com/ocornut/imgui/releases -// - Gallery https://github.com/ocornut/imgui/issues/4451 (please post your screenshots/video there!) -// - Wiki https://github.com/ocornut/imgui/wiki (lots of good stuff there) -// - Glossary https://github.com/ocornut/imgui/wiki/Glossary -// - Issues & support https://github.com/ocornut/imgui/issues - -// Getting Started? -// - For first-time users having issues compiling/linking/running or issues loading fonts: -// please post in https://github.com/ocornut/imgui/discussions if you cannot find a solution in resources above. - -// Developed by Omar Cornut and every direct or indirect contributors to the GitHub. -// See LICENSE.txt for copyright and licensing details (standard MIT License). -// This library is free but needs your support to sustain development and maintenance. -// Businesses: you can support continued development via invoiced technical support, maintenance and sponsoring contracts. Please reach out to "contact AT dearimgui.com". -// Individuals: you can support continued development via donations. See docs/README or web page. - -// It is recommended that you don't modify imgui.cpp! It will become difficult for you to update the library. -// Note that 'ImGui::' being a namespace, you can add functions into the namespace from your own source files, without -// modifying imgui.h or imgui.cpp. You may include imgui_internal.h to access internal data structures, but it doesn't -// come with any guarantee of forward compatibility. Discussing your changes on the GitHub Issue Tracker may lead you -// to a better solution or official support for them. - -/* - -Index of this file: - -DOCUMENTATION - -- MISSION STATEMENT -- END-USER GUIDE -- PROGRAMMER GUIDE - - READ FIRST - - HOW TO UPDATE TO A NEWER VERSION OF DEAR IMGUI - - GETTING STARTED WITH INTEGRATING DEAR IMGUI IN YOUR CODE/ENGINE - - HOW A SIMPLE APPLICATION MAY LOOK LIKE - - HOW A SIMPLE RENDERING FUNCTION MAY LOOK LIKE - - USING GAMEPAD/KEYBOARD NAVIGATION CONTROLS -- API BREAKING CHANGES (read me when you update!) -- FREQUENTLY ASKED QUESTIONS (FAQ) - - Read all answers online: https://www.dearimgui.org/faq, or in docs/FAQ.md (with a Markdown viewer) - -CODE -(search for "[SECTION]" in the code to find them) - -// [SECTION] INCLUDES -// [SECTION] FORWARD DECLARATIONS -// [SECTION] CONTEXT AND MEMORY ALLOCATORS -// [SECTION] USER FACING STRUCTURES (ImGuiStyle, ImGuiIO) -// [SECTION] MISC HELPERS/UTILITIES (Geometry functions) -// [SECTION] MISC HELPERS/UTILITIES (String, Format, Hash functions) -// [SECTION] MISC HELPERS/UTILITIES (File functions) -// [SECTION] MISC HELPERS/UTILITIES (ImText* functions) -// [SECTION] MISC HELPERS/UTILITIES (Color functions) -// [SECTION] ImGuiStorage -// [SECTION] ImGuiTextFilter -// [SECTION] ImGuiTextBuffer -// [SECTION] ImGuiListClipper -// [SECTION] STYLING -// [SECTION] RENDER HELPERS -// [SECTION] MAIN CODE (most of the code! lots of stuff, needs tidying up!) -// [SECTION] ERROR CHECKING -// [SECTION] LAYOUT -// [SECTION] SCROLLING -// [SECTION] TOOLTIPS -// [SECTION] POPUPS -// [SECTION] KEYBOARD/GAMEPAD NAVIGATION -// [SECTION] DRAG AND DROP -// [SECTION] LOGGING/CAPTURING -// [SECTION] SETTINGS -// [SECTION] VIEWPORTS -// [SECTION] PLATFORM DEPENDENT HELPERS -// [SECTION] METRICS/DEBUGGER WINDOW -// [SECTION] OTHER DEBUG TOOLS (ITEM PICKER, STACK TOOL) - -*/ - -//----------------------------------------------------------------------------- -// DOCUMENTATION -//----------------------------------------------------------------------------- - -/* - - MISSION STATEMENT - ================= - - - Easy to use to create code-driven and data-driven tools. - - Easy to use to create ad hoc short-lived tools and long-lived, more elaborate tools. - - Easy to hack and improve. - - Minimize setup and maintenance. - - Minimize state storage on user side. - - Portable, minimize dependencies, run on target (consoles, phones, etc.). - - Efficient runtime and memory consumption. - - Designed for developers and content-creators, not the typical end-user! Some of the current weaknesses includes: - - - Doesn't look fancy, doesn't animate. - - Limited layout features, intricate layouts are typically crafted in code. - - - END-USER GUIDE - ============== - - - Double-click on title bar to collapse window. - - Click upper right corner to close a window, available when 'bool* p_open' is passed to ImGui::Begin(). - - Click and drag on lower right corner to resize window (double-click to auto fit window to its contents). - - Click and drag on any empty space to move window. - - TAB/SHIFT+TAB to cycle through keyboard editable fields. - - CTRL+Click on a slider or drag box to input value as text. - - Use mouse wheel to scroll. - - Text editor: - - Hold SHIFT or use mouse to select text. - - CTRL+Left/Right to word jump. - - CTRL+Shift+Left/Right to select words. - - CTRL+A our Double-Click to select all. - - CTRL+X,CTRL+C,CTRL+V to use OS clipboard/ - - CTRL+Z,CTRL+Y to undo/redo. - - ESCAPE to revert text to its original value. - - You can apply arithmetic operators +,*,/ on numerical values. Use +- to subtract (because - would set a negative value!) - - Controls are automatically adjusted for OSX to match standard OSX text editing operations. - - General Keyboard controls: enable with ImGuiConfigFlags_NavEnableKeyboard. - - General Gamepad controls: enable with ImGuiConfigFlags_NavEnableGamepad. See suggested mappings in imgui.h ImGuiNavInput_ + download PNG/PSD at http://dearimgui.org/controls_sheets - - - PROGRAMMER GUIDE - ================ - - READ FIRST - ---------- - - Remember to check the wonderful Wiki (https://github.com/ocornut/imgui/wiki) - - Your code creates the UI, if your code doesn't run the UI is gone! The UI can be highly dynamic, there are no construction or - destruction steps, less superfluous data retention on your side, less state duplication, less state synchronization, fewer bugs. - - Call and read ImGui::ShowDemoWindow() for demo code demonstrating most features. - - The library is designed to be built from sources. Avoid pre-compiled binaries and packaged versions. See imconfig.h to configure your build. - - Dear ImGui is an implementation of the IMGUI paradigm (immediate-mode graphical user interface, a term coined by Casey Muratori). - You can learn about IMGUI principles at http://www.johno.se/book/imgui.html, http://mollyrocket.com/861 & more links in Wiki. - - Dear ImGui is a "single pass" rasterizing implementation of the IMGUI paradigm, aimed at ease of use and high-performances. - For every application frame, your UI code will be called only once. This is in contrast to e.g. Unity's implementation of an IMGUI, - where the UI code is called multiple times ("multiple passes") from a single entry point. There are pros and cons to both approaches. - - Our origin is on the top-left. In axis aligned bounding boxes, Min = top-left, Max = bottom-right. - - This codebase is also optimized to yield decent performances with typical "Debug" builds settings. - - Please make sure you have asserts enabled (IM_ASSERT redirects to assert() by default, but can be redirected). - If you get an assert, read the messages and comments around the assert. - - C++: this is a very C-ish codebase: we don't rely on C++11, we don't include any C++ headers, and ImGui:: is a namespace. - - C++: ImVec2/ImVec4 do not expose math operators by default, because it is expected that you use your own math types. - See FAQ "How can I use my own math types instead of ImVec2/ImVec4?" for details about setting up imconfig.h for that. - However, imgui_internal.h can optionally export math operators for ImVec2/ImVec4, which we use in this codebase. - - C++: pay attention that ImVector<> manipulates plain-old-data and does not honor construction/destruction (avoid using it in your code!). - - - HOW TO UPDATE TO A NEWER VERSION OF DEAR IMGUI - ---------------------------------------------- - - Overwrite all the sources files except for imconfig.h (if you have modified your copy of imconfig.h) - - Or maintain your own branch where you have imconfig.h modified as a top-most commit which you can regularly rebase over "master". - - You can also use '#define IMGUI_USER_CONFIG "my_config_file.h" to redirect configuration to your own file. - - Read the "API BREAKING CHANGES" section (below). This is where we list occasional API breaking changes. - If a function/type has been renamed / or marked obsolete, try to fix the name in your code before it is permanently removed - from the public API. If you have a problem with a missing function/symbols, search for its name in the code, there will - likely be a comment about it. Please report any issue to the GitHub page! - - To find out usage of old API, you can add '#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS' in your configuration file. - - Try to keep your copy of Dear ImGui reasonably up to date. - - - GETTING STARTED WITH INTEGRATING DEAR IMGUI IN YOUR CODE/ENGINE - --------------------------------------------------------------- - - Run and study the examples and demo in imgui_demo.cpp to get acquainted with the library. - - In the majority of cases you should be able to use unmodified backends files available in the backends/ folder. - - Add the Dear ImGui source files + selected backend source files to your projects or using your preferred build system. - It is recommended you build and statically link the .cpp files as part of your project and NOT as a shared library (DLL). - - You can later customize the imconfig.h file to tweak some compile-time behavior, such as integrating Dear ImGui types with your own maths types. - - When using Dear ImGui, your programming IDE is your friend: follow the declaration of variables, functions and types to find comments about them. - - Dear ImGui never touches or knows about your GPU state. The only function that knows about GPU is the draw function that you provide. - Effectively it means you can create widgets at any time in your code, regardless of considerations of being in "update" vs "render" - phases of your own application. All rendering information is stored into command-lists that you will retrieve after calling ImGui::Render(). - - Refer to the backends and demo applications in the examples/ folder for instruction on how to setup your code. - - If you are running over a standard OS with a common graphics API, you should be able to use unmodified imgui_impl_*** files from the examples/ folder. - - - HOW A SIMPLE APPLICATION MAY LOOK LIKE - -------------------------------------- - EXHIBIT 1: USING THE EXAMPLE BACKENDS (= imgui_impl_XXX.cpp files from the backends/ folder). - The sub-folders in examples/ contain examples applications following this structure. - - // Application init: create a dear imgui context, setup some options, load fonts - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); - // TODO: Set optional io.ConfigFlags values, e.g. 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard' to enable keyboard controls. - // TODO: Fill optional fields of the io structure later. - // TODO: Load TTF/OTF fonts if you don't want to use the default font. - - // Initialize helper Platform and Renderer backends (here we are using imgui_impl_win32.cpp and imgui_impl_dx11.cpp) - ImGui_ImplWin32_Init(hwnd); - ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext); - - // Application main loop - while (true) - { - // Feed inputs to dear imgui, start new frame - ImGui_ImplDX11_NewFrame(); - ImGui_ImplWin32_NewFrame(); - ImGui::NewFrame(); - - // Any application code here - ImGui::Text("Hello, world!"); - - // Render dear imgui into screen - ImGui::Render(); - ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData()); - g_pSwapChain->Present(1, 0); - } - - // Shutdown - ImGui_ImplDX11_Shutdown(); - ImGui_ImplWin32_Shutdown(); - ImGui::DestroyContext(); - - EXHIBIT 2: IMPLEMENTING CUSTOM BACKEND / CUSTOM ENGINE - - // Application init: create a dear imgui context, setup some options, load fonts - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); - // TODO: Set optional io.ConfigFlags values, e.g. 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard' to enable keyboard controls. - // TODO: Fill optional fields of the io structure later. - // TODO: Load TTF/OTF fonts if you don't want to use the default font. - - // Build and load the texture atlas into a texture - // (In the examples/ app this is usually done within the ImGui_ImplXXX_Init() function from one of the demo Renderer) - int width, height; - unsigned char* pixels = NULL; - io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); - - // At this point you've got the texture data and you need to upload that to your graphic system: - // After we have created the texture, store its pointer/identifier (_in whichever format your engine uses_) in 'io.Fonts->TexID'. - // This will be passed back to your via the renderer. Basically ImTextureID == void*. Read FAQ for details about ImTextureID. - MyTexture* texture = MyEngine::CreateTextureFromMemoryPixels(pixels, width, height, TEXTURE_TYPE_RGBA32) - io.Fonts->SetTexID((void*)texture); - - // Application main loop - while (true) - { - // Setup low-level inputs, e.g. on Win32: calling GetKeyboardState(), or write to those fields from your Windows message handlers, etc. - // (In the examples/ app this is usually done within the ImGui_ImplXXX_NewFrame() function from one of the demo Platform Backends) - io.DeltaTime = 1.0f/60.0f; // set the time elapsed since the previous frame (in seconds) - io.DisplaySize.x = 1920.0f; // set the current display width - io.DisplaySize.y = 1280.0f; // set the current display height here - io.MousePos = my_mouse_pos; // set the mouse position - io.MouseDown[0] = my_mouse_buttons[0]; // set the mouse button states - io.MouseDown[1] = my_mouse_buttons[1]; - - // Call NewFrame(), after this point you can use ImGui::* functions anytime - // (So you want to try calling NewFrame() as early as you can in your main loop to be able to use Dear ImGui everywhere) - ImGui::NewFrame(); - - // Most of your application code here - ImGui::Text("Hello, world!"); - MyGameUpdate(); // may use any Dear ImGui functions, e.g. ImGui::Begin("My window"); ImGui::Text("Hello, world!"); ImGui::End(); - MyGameRender(); // may use any Dear ImGui functions as well! - - // Render dear imgui, swap buffers - // (You want to try calling EndFrame/Render as late as you can, to be able to use Dear ImGui in your own game rendering code) - ImGui::EndFrame(); - ImGui::Render(); - ImDrawData* draw_data = ImGui::GetDrawData(); - MyImGuiRenderFunction(draw_data); - SwapBuffers(); - } - - // Shutdown - ImGui::DestroyContext(); - - To decide whether to dispatch mouse/keyboard inputs to Dear ImGui to the rest of your application, - you should read the 'io.WantCaptureMouse', 'io.WantCaptureKeyboard' and 'io.WantTextInput' flags! - Please read the FAQ and example applications for details about this! - - - HOW A SIMPLE RENDERING FUNCTION MAY LOOK LIKE - --------------------------------------------- - The backends in impl_impl_XXX.cpp files contain many working implementations of a rendering function. - - void void MyImGuiRenderFunction(ImDrawData* draw_data) - { - // TODO: Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled - // TODO: Setup viewport covering draw_data->DisplayPos to draw_data->DisplayPos + draw_data->DisplaySize - // TODO: Setup orthographic projection matrix cover draw_data->DisplayPos to draw_data->DisplayPos + draw_data->DisplaySize - // TODO: Setup shader: vertex { float2 pos, float2 uv, u32 color }, fragment shader sample color from 1 texture, multiply by vertex color. - for (int n = 0; n < draw_data->CmdListsCount; n++) - { - const ImDrawList* cmd_list = draw_data->CmdLists[n]; - const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data; // vertex buffer generated by Dear ImGui - const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data; // index buffer generated by Dear ImGui - for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) - { - const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; - if (pcmd->UserCallback) - { - pcmd->UserCallback(cmd_list, pcmd); - } - else - { - // The texture for the draw call is specified by pcmd->GetTexID(). - // The vast majority of draw calls will use the Dear ImGui texture atlas, which value you have set yourself during initialization. - MyEngineBindTexture((MyTexture*)pcmd->GetTexID()); - - // We are using scissoring to clip some objects. All low-level graphics API should support it. - // - If your engine doesn't support scissoring yet, you may ignore this at first. You will get some small glitches - // (some elements visible outside their bounds) but you can fix that once everything else works! - // - Clipping coordinates are provided in imgui coordinates space: - // - For a given viewport, draw_data->DisplayPos == viewport->Pos and draw_data->DisplaySize == viewport->Size - // - In a single viewport application, draw_data->DisplayPos == (0,0) and draw_data->DisplaySize == io.DisplaySize, but always use GetMainViewport()->Pos/Size instead of hardcoding those values. - // - In the interest of supporting multi-viewport applications (see 'docking' branch on github), - // always subtract draw_data->DisplayPos from clipping bounds to convert them to your viewport space. - // - Note that pcmd->ClipRect contains Min+Max bounds. Some graphics API may use Min+Max, other may use Min+Size (size being Max-Min) - ImVec2 pos = draw_data->DisplayPos; - MyEngineScissor((int)(pcmd->ClipRect.x - pos.x), (int)(pcmd->ClipRect.y - pos.y), (int)(pcmd->ClipRect.z - pos.x), (int)(pcmd->ClipRect.w - pos.y)); - - // Render 'pcmd->ElemCount/3' indexed triangles. - // By default the indices ImDrawIdx are 16-bit, you can change them to 32-bit in imconfig.h if your engine doesn't support 16-bit indices. - MyEngineDrawIndexedTriangles(pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer, vtx_buffer); - } - idx_buffer += pcmd->ElemCount; - } - } - } - - - USING GAMEPAD/KEYBOARD NAVIGATION CONTROLS - ------------------------------------------ - - The gamepad/keyboard navigation is fairly functional and keeps being improved. - - Gamepad support is particularly useful to use Dear ImGui on a console system (e.g. PS4, Switch, XB1) without a mouse! - - You can ask questions and report issues at https://github.com/ocornut/imgui/issues/787 - - The initial focus was to support game controllers, but keyboard is becoming increasingly and decently usable. - - Keyboard: - - Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard to enable. - NewFrame() will automatically fill io.NavInputs[] based on your io.KeysDown[] + io.KeyMap[] arrays. - - When keyboard navigation is active (io.NavActive + ImGuiConfigFlags_NavEnableKeyboard), the io.WantCaptureKeyboard flag - will be set. For more advanced uses, you may want to read from: - - io.NavActive: true when a window is focused and it doesn't have the ImGuiWindowFlags_NoNavInputs flag set. - - io.NavVisible: true when the navigation cursor is visible (and usually goes false when mouse is used). - - or query focus information with e.g. IsWindowFocused(ImGuiFocusedFlags_AnyWindow), IsItemFocused() etc. functions. - Please reach out if you think the game vs navigation input sharing could be improved. - - Gamepad: - - Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad to enable. - - Backend: Set io.BackendFlags |= ImGuiBackendFlags_HasGamepad + fill the io.NavInputs[] fields before calling NewFrame(). - Note that io.NavInputs[] is cleared by EndFrame(). - - See 'enum ImGuiNavInput_' in imgui.h for a description of inputs. For each entry of io.NavInputs[], set the following values: - 0.0f= not held. 1.0f= fully held. Pass intermediate 0.0f..1.0f values for analog triggers/sticks. - - We use a simple >0.0f test for activation testing, and won't attempt to test for a dead-zone. - Your code will probably need to transform your raw inputs (such as e.g. remapping your 0.2..0.9 raw input range to 0.0..1.0 imgui range, etc.). - - You can download PNG/PSD files depicting the gamepad controls for common controllers at: http://dearimgui.org/controls_sheets - - If you need to share inputs between your game and the imgui parts, the easiest approach is to go all-or-nothing, with a buttons combo - to toggle the target. Please reach out if you think the game vs navigation input sharing could be improved. - - Mouse: - - PS4 users: Consider emulating a mouse cursor with DualShock4 touch pad or a spare analog stick as a mouse-emulation fallback. - - Consoles/Tablet/Phone users: Consider using a Synergy 1.x server (on your PC) + uSynergy.c (on your console/tablet/phone app) to share your PC mouse/keyboard. - - On a TV/console system where readability may be lower or mouse inputs may be awkward, you may want to set the ImGuiConfigFlags_NavEnableSetMousePos flag. - Enabling ImGuiConfigFlags_NavEnableSetMousePos + ImGuiBackendFlags_HasSetMousePos instructs dear imgui to move your mouse cursor along with navigation movements. - When enabled, the NewFrame() function may alter 'io.MousePos' and set 'io.WantSetMousePos' to notify you that it wants the mouse cursor to be moved. - When that happens your backend NEEDS to move the OS or underlying mouse cursor on the next frame. Some of the backends in examples/ do that. - (If you set the NavEnableSetMousePos flag but don't honor 'io.WantSetMousePos' properly, imgui will misbehave as it will see your mouse moving back and forth!) - (In a setup when you may not have easy control over the mouse cursor, e.g. uSynergy.c doesn't expose moving remote mouse cursor, you may want - to set a boolean to ignore your other external mouse positions until the external source is moved again.) - - - API BREAKING CHANGES - ==================== - - Occasionally introducing changes that are breaking the API. We try to make the breakage minor and easy to fix. - Below is a change-log of API breaking changes only. If you are using one of the functions listed, expect to have to fix some code. - When you are not sure about an old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files. - You can read releases logs https://github.com/ocornut/imgui/releases for more details. - - - 2021/08/23 (1.85) - removed GetWindowContentRegionWidth() function. keep inline redirection helper. can use 'GetWindowContentRegionMax().x - GetWindowContentRegionMin().x' instead for generally 'GetContentRegionAvail().x' is more useful. - - 2021/07/26 (1.84) - commented out redirecting functions/enums names that were marked obsolete in 1.67 and 1.69 (March 2019): - - ImGui::GetOverlayDrawList() -> use ImGui::GetForegroundDrawList() - - ImFont::GlyphRangesBuilder -> use ImFontGlyphRangesBuilder - - 2021/05/19 (1.83) - backends: obsoleted direct access to ImDrawCmd::TextureId in favor of calling ImDrawCmd::GetTexID(). - - if you are using official backends from the source tree: you have nothing to do. - - if you have copied old backend code or using your own: change access to draw_cmd->TextureId to draw_cmd->GetTexID(). - - 2021/03/12 (1.82) - upgraded ImDrawList::AddRect(), AddRectFilled(), PathRect() to use ImDrawFlags instead of ImDrawCornersFlags. - - ImDrawCornerFlags_TopLeft -> use ImDrawFlags_RoundCornersTopLeft - - ImDrawCornerFlags_BotRight -> use ImDrawFlags_RoundCornersBottomRight - - ImDrawCornerFlags_None -> use ImDrawFlags_RoundCornersNone etc. - flags now sanely defaults to 0 instead of 0x0F, consistent with all other flags in the API. - breaking: the default with rounding > 0.0f is now "round all corners" vs old implicit "round no corners": - - rounding == 0.0f + flags == 0 --> meant no rounding --> unchanged (common use) - - rounding > 0.0f + flags != 0 --> meant rounding --> unchanged (common use) - - rounding == 0.0f + flags != 0 --> meant no rounding --> unchanged (unlikely use) - - rounding > 0.0f + flags == 0 --> meant no rounding --> BREAKING (unlikely use): will now round all corners --> use ImDrawFlags_RoundCornersNone or rounding == 0.0f. - this ONLY matters for hard coded use of 0 + rounding > 0.0f. Use of named ImDrawFlags_RoundCornersNone (new) or ImDrawCornerFlags_None (old) are ok. - the old ImDrawCornersFlags used awkward default values of ~0 or 0xF (4 lower bits set) to signify "round all corners" and we sometimes encouraged using them as shortcuts. - legacy path still support use of hard coded ~0 or any value from 0x1 or 0xF. They will behave the same with legacy paths enabled (will assert otherwise). - - 2021/03/11 (1.82) - removed redirecting functions/enums names that were marked obsolete in 1.66 (September 2018): - - ImGui::SetScrollHere() -> use ImGui::SetScrollHereY() - - 2021/03/11 (1.82) - clarified that ImDrawList::PathArcTo(), ImDrawList::PathArcToFast() won't render with radius < 0.0f. Previously it sorts of accidentally worked but would generally lead to counter-clockwise paths and have an effect on anti-aliasing. - - 2021/03/10 (1.82) - upgraded ImDrawList::AddPolyline() and PathStroke() "bool closed" parameter to "ImDrawFlags flags". The matching ImDrawFlags_Closed value is guaranteed to always stay == 1 in the future. - - 2021/02/22 (1.82) - (*undone in 1.84*) win32+mingw: Re-enabled IME functions by default even under MinGW. In July 2016, issue #738 had me incorrectly disable those default functions for MinGW. MinGW users should: either link with -limm32, either set their imconfig file with '#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS'. - - 2021/02/17 (1.82) - renamed rarely used style.CircleSegmentMaxError (old default = 1.60f) to style.CircleTessellationMaxError (new default = 0.30f) as the meaning of the value changed. - - 2021/02/03 (1.81) - renamed ListBoxHeader(const char* label, ImVec2 size) to BeginListBox(). Kept inline redirection function (will obsolete). - - removed ListBoxHeader(const char* label, int items_count, int height_in_items = -1) in favor of specifying size. Kept inline redirection function (will obsolete). - - renamed ListBoxFooter() to EndListBox(). Kept inline redirection function (will obsolete). - - 2021/01/26 (1.81) - removed ImGuiFreeType::BuildFontAtlas(). Kept inline redirection function. Prefer using '#define IMGUI_ENABLE_FREETYPE', but there's a runtime selection path available too. The shared extra flags parameters (very rarely used) are now stored in ImFontAtlas::FontBuilderFlags. - - renamed ImFontConfig::RasterizerFlags (used by FreeType) to ImFontConfig::FontBuilderFlags. - - renamed ImGuiFreeType::XXX flags to ImGuiFreeTypeBuilderFlags_XXX for consistency with other API. - - 2020/10/12 (1.80) - removed redirecting functions/enums that were marked obsolete in 1.63 (August 2018): - - ImGui::IsItemDeactivatedAfterChange() -> use ImGui::IsItemDeactivatedAfterEdit(). - - ImGuiCol_ModalWindowDarkening -> use ImGuiCol_ModalWindowDimBg - - ImGuiInputTextCallback -> use ImGuiTextEditCallback - - ImGuiInputTextCallbackData -> use ImGuiTextEditCallbackData - - 2020/12/21 (1.80) - renamed ImDrawList::AddBezierCurve() to AddBezierCubic(), and PathBezierCurveTo() to PathBezierCubicCurveTo(). Kept inline redirection function (will obsolete). - - 2020/12/04 (1.80) - added imgui_tables.cpp file! Manually constructed project files will need the new file added! - - 2020/11/18 (1.80) - renamed undocumented/internals ImGuiColumnsFlags_* to ImGuiOldColumnFlags_* in prevision of incoming Tables API. - - 2020/11/03 (1.80) - renamed io.ConfigWindowsMemoryCompactTimer to io.ConfigMemoryCompactTimer as the feature will apply to other data structures - - 2020/10/14 (1.80) - backends: moved all backends files (imgui_impl_XXXX.cpp, imgui_impl_XXXX.h) from examples/ to backends/. - - 2020/10/12 (1.80) - removed redirecting functions/enums that were marked obsolete in 1.60 (April 2018): - - io.RenderDrawListsFn pointer -> use ImGui::GetDrawData() value and call the render function of your backend - - ImGui::IsAnyWindowFocused() -> use ImGui::IsWindowFocused(ImGuiFocusedFlags_AnyWindow) - - ImGui::IsAnyWindowHovered() -> use ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow) - - ImGuiStyleVar_Count_ -> use ImGuiStyleVar_COUNT - - ImGuiMouseCursor_Count_ -> use ImGuiMouseCursor_COUNT - - removed redirecting functions names that were marked obsolete in 1.61 (May 2018): - - InputFloat (... int decimal_precision ...) -> use InputFloat (... const char* format ...) with format = "%.Xf" where X is your value for decimal_precision. - - same for InputFloat2()/InputFloat3()/InputFloat4() variants taking a `int decimal_precision` parameter. - - 2020/10/05 (1.79) - removed ImGuiListClipper: Renamed constructor parameters which created an ambiguous alternative to using the ImGuiListClipper::Begin() function, with misleading edge cases (note: imgui_memory_editor <0.40 from imgui_club/ used this old clipper API. Update your copy if needed). - - 2020/09/25 (1.79) - renamed ImGuiSliderFlags_ClampOnInput to ImGuiSliderFlags_AlwaysClamp. Kept redirection enum (will obsolete sooner because previous name was added recently). - - 2020/09/25 (1.79) - renamed style.TabMinWidthForUnselectedCloseButton to style.TabMinWidthForCloseButton. - - 2020/09/21 (1.79) - renamed OpenPopupContextItem() back to OpenPopupOnItemClick(), reverting the change from 1.77. For varieties of reason this is more self-explanatory. - - 2020/09/21 (1.79) - removed return value from OpenPopupOnItemClick() - returned true on mouse release on an item - because it is inconsistent with other popup APIs and makes others misleading. It's also and unnecessary: you can use IsWindowAppearing() after BeginPopup() for a similar result. - - 2020/09/17 (1.79) - removed ImFont::DisplayOffset in favor of ImFontConfig::GlyphOffset. DisplayOffset was applied after scaling and not very meaningful/useful outside of being needed by the default ProggyClean font. If you scaled this value after calling AddFontDefault(), this is now done automatically. It was also getting in the way of better font scaling, so let's get rid of it now! - - 2020/08/17 (1.78) - obsoleted use of the trailing 'float power=1.0f' parameter for DragFloat(), DragFloat2(), DragFloat3(), DragFloat4(), DragFloatRange2(), DragScalar(), DragScalarN(), SliderFloat(), SliderFloat2(), SliderFloat3(), SliderFloat4(), SliderScalar(), SliderScalarN(), VSliderFloat() and VSliderScalar(). - replaced the 'float power=1.0f' argument with integer-based flags defaulting to 0 (as with all our flags). - worked out a backward-compatibility scheme so hopefully most C++ codebase should not be affected. in short, when calling those functions: - - if you omitted the 'power' parameter (likely!), you are not affected. - - if you set the 'power' parameter to 1.0f (same as previous default value): 1/ your compiler may warn on float>int conversion, 2/ everything else will work. 3/ you can replace the 1.0f value with 0 to fix the warning, and be technically correct. - - if you set the 'power' parameter to >1.0f (to enable non-linear editing): 1/ your compiler may warn on float>int conversion, 2/ code will assert at runtime, 3/ in case asserts are disabled, the code will not crash and enable the _Logarithmic flag. 4/ you can replace the >1.0f value with ImGuiSliderFlags_Logarithmic to fix the warning/assert and get a _similar_ effect as previous uses of power >1.0f. - see https://github.com/ocornut/imgui/issues/3361 for all details. - kept inline redirection functions (will obsolete) apart for: DragFloatRange2(), VSliderFloat(), VSliderScalar(). For those three the 'float power=1.0f' version was removed directly as they were most unlikely ever used. - for shared code, you can version check at compile-time with `#if IMGUI_VERSION_NUM >= 17704`. - - obsoleted use of v_min > v_max in DragInt, DragFloat, DragScalar to lock edits (introduced in 1.73, was not demoed nor documented very), will be replaced by a more generic ReadOnly feature. You may use the ImGuiSliderFlags_ReadOnly internal flag in the meantime. - - 2020/06/23 (1.77) - removed BeginPopupContextWindow(const char*, int mouse_button, bool also_over_items) in favor of BeginPopupContextWindow(const char*, ImGuiPopupFlags flags) with ImGuiPopupFlags_NoOverItems. - - 2020/06/15 (1.77) - renamed OpenPopupOnItemClick() to OpenPopupContextItem(). Kept inline redirection function (will obsolete). [NOTE: THIS WAS REVERTED IN 1.79] - - 2020/06/15 (1.77) - removed CalcItemRectClosestPoint() entry point which was made obsolete and asserting in December 2017. - - 2020/04/23 (1.77) - removed unnecessary ID (first arg) of ImFontAtlas::AddCustomRectRegular(). - - 2020/01/22 (1.75) - ImDrawList::AddCircle()/AddCircleFilled() functions don't accept negative radius any more. - - 2019/12/17 (1.75) - [undid this change in 1.76] made Columns() limited to 64 columns by asserting above that limit. While the current code technically supports it, future code may not so we're putting the restriction ahead. - - 2019/12/13 (1.75) - [imgui_internal.h] changed ImRect() default constructor initializes all fields to 0.0f instead of (FLT_MAX,FLT_MAX,-FLT_MAX,-FLT_MAX). If you used ImRect::Add() to create bounding boxes by adding multiple points into it, you may need to fix your initial value. - - 2019/12/08 (1.75) - removed redirecting functions/enums that were marked obsolete in 1.53 (December 2017): - - ShowTestWindow() -> use ShowDemoWindow() - - IsRootWindowFocused() -> use IsWindowFocused(ImGuiFocusedFlags_RootWindow) - - IsRootWindowOrAnyChildFocused() -> use IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows) - - SetNextWindowContentWidth(w) -> use SetNextWindowContentSize(ImVec2(w, 0.0f) - - GetItemsLineHeightWithSpacing() -> use GetFrameHeightWithSpacing() - - ImGuiCol_ChildWindowBg -> use ImGuiCol_ChildBg - - ImGuiStyleVar_ChildWindowRounding -> use ImGuiStyleVar_ChildRounding - - ImGuiTreeNodeFlags_AllowOverlapMode -> use ImGuiTreeNodeFlags_AllowItemOverlap - - IMGUI_DISABLE_TEST_WINDOWS -> use IMGUI_DISABLE_DEMO_WINDOWS - - 2019/12/08 (1.75) - obsoleted calling ImDrawList::PrimReserve() with a negative count (which was vaguely documented and rarely if ever used). Instead, we added an explicit PrimUnreserve() API. - - 2019/12/06 (1.75) - removed implicit default parameter to IsMouseDragging(int button = 0) to be consistent with other mouse functions (none of the other functions have it). - - 2019/11/21 (1.74) - ImFontAtlas::AddCustomRectRegular() now requires an ID larger than 0x110000 (instead of 0x10000) to conform with supporting Unicode planes 1-16 in a future update. ID below 0x110000 will now assert. - - 2019/11/19 (1.74) - renamed IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS to IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS for consistency. - - 2019/11/19 (1.74) - renamed IMGUI_DISABLE_MATH_FUNCTIONS to IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS for consistency. - - 2019/10/22 (1.74) - removed redirecting functions/enums that were marked obsolete in 1.52 (October 2017): - - Begin() [old 5 args version] -> use Begin() [3 args], use SetNextWindowSize() SetNextWindowBgAlpha() if needed - - IsRootWindowOrAnyChildHovered() -> use IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows) - - AlignFirstTextHeightToWidgets() -> use AlignTextToFramePadding() - - SetNextWindowPosCenter() -> use SetNextWindowPos() with a pivot of (0.5f, 0.5f) - - ImFont::Glyph -> use ImFontGlyph - - 2019/10/14 (1.74) - inputs: Fixed a miscalculation in the keyboard/mouse "typematic" repeat delay/rate calculation, used by keys and e.g. repeating mouse buttons as well as the GetKeyPressedAmount() function. - if you were using a non-default value for io.KeyRepeatRate (previous default was 0.250), you can add +io.KeyRepeatDelay to it to compensate for the fix. - The function was triggering on: 0.0 and (delay+rate*N) where (N>=1). Fixed formula responds to (N>=0). Effectively it made io.KeyRepeatRate behave like it was set to (io.KeyRepeatRate + io.KeyRepeatDelay). - If you never altered io.KeyRepeatRate nor used GetKeyPressedAmount() this won't affect you. - - 2019/07/15 (1.72) - removed TreeAdvanceToLabelPos() which is rarely used and only does SetCursorPosX(GetCursorPosX() + GetTreeNodeToLabelSpacing()). Kept redirection function (will obsolete). - - 2019/07/12 (1.72) - renamed ImFontAtlas::CustomRect to ImFontAtlasCustomRect. Kept redirection typedef (will obsolete). - - 2019/06/14 (1.72) - removed redirecting functions/enums names that were marked obsolete in 1.51 (June 2017): ImGuiCol_Column*, ImGuiSetCond_*, IsItemHoveredRect(), IsPosHoveringAnyWindow(), IsMouseHoveringAnyWindow(), IsMouseHoveringWindow(), IMGUI_ONCE_UPON_A_FRAME. Grep this log for details and new names, or see how they were implemented until 1.71. - - 2019/06/07 (1.71) - rendering of child window outer decorations (bg color, border, scrollbars) is now performed as part of the parent window. If you have - overlapping child windows in a same parent, and relied on their relative z-order to be mapped to their submission order, this will affect your rendering. - This optimization is disabled if the parent window has no visual output, because it appears to be the most common situation leading to the creation of overlapping child windows. - Please reach out if you are affected. - - 2019/05/13 (1.71) - renamed SetNextTreeNodeOpen() to SetNextItemOpen(). Kept inline redirection function (will obsolete). - - 2019/05/11 (1.71) - changed io.AddInputCharacter(unsigned short c) signature to io.AddInputCharacter(unsigned int c). - - 2019/04/29 (1.70) - improved ImDrawList thick strokes (>1.0f) preserving correct thickness up to 90 degrees angles (e.g. rectangles). If you have custom rendering using thick lines, they will appear thicker now. - - 2019/04/29 (1.70) - removed GetContentRegionAvailWidth(), use GetContentRegionAvail().x instead. Kept inline redirection function (will obsolete). - - 2019/03/04 (1.69) - renamed GetOverlayDrawList() to GetForegroundDrawList(). Kept redirection function (will obsolete). - - 2019/02/26 (1.69) - renamed ImGuiColorEditFlags_RGB/ImGuiColorEditFlags_HSV/ImGuiColorEditFlags_HEX to ImGuiColorEditFlags_DisplayRGB/ImGuiColorEditFlags_DisplayHSV/ImGuiColorEditFlags_DisplayHex. Kept redirection enums (will obsolete). - - 2019/02/14 (1.68) - made it illegal/assert when io.DisplayTime == 0.0f (with an exception for the first frame). If for some reason your time step calculation gives you a zero value, replace it with an arbitrarily small value! - - 2019/02/01 (1.68) - removed io.DisplayVisibleMin/DisplayVisibleMax (which were marked obsolete and removed from viewport/docking branch already). - - 2019/01/06 (1.67) - renamed io.InputCharacters[], marked internal as was always intended. Please don't access directly, and use AddInputCharacter() instead! - - 2019/01/06 (1.67) - renamed ImFontAtlas::GlyphRangesBuilder to ImFontGlyphRangesBuilder. Kept redirection typedef (will obsolete). - - 2018/12/20 (1.67) - made it illegal to call Begin("") with an empty string. This somehow half-worked before but had various undesirable side-effects. - - 2018/12/10 (1.67) - renamed io.ConfigResizeWindowsFromEdges to io.ConfigWindowsResizeFromEdges as we are doing a large pass on configuration flags. - - 2018/10/12 (1.66) - renamed misc/stl/imgui_stl.* to misc/cpp/imgui_stdlib.* in prevision for other C++ helper files. - - 2018/09/28 (1.66) - renamed SetScrollHere() to SetScrollHereY(). Kept redirection function (will obsolete). - - 2018/09/06 (1.65) - renamed stb_truetype.h to imstb_truetype.h, stb_textedit.h to imstb_textedit.h, and stb_rect_pack.h to imstb_rectpack.h. - If you were conveniently using the imgui copy of those STB headers in your project you will have to update your include paths. - - 2018/09/05 (1.65) - renamed io.OptCursorBlink/io.ConfigCursorBlink to io.ConfigInputTextCursorBlink. (#1427) - - 2018/08/31 (1.64) - added imgui_widgets.cpp file, extracted and moved widgets code out of imgui.cpp into imgui_widgets.cpp. Re-ordered some of the code remaining in imgui.cpp. - NONE OF THE FUNCTIONS HAVE CHANGED. THE CODE IS SEMANTICALLY 100% IDENTICAL, BUT _EVERY_ FUNCTION HAS BEEN MOVED. - Because of this, any local modifications to imgui.cpp will likely conflict when you update. Read docs/CHANGELOG.txt for suggestions. - - 2018/08/22 (1.63) - renamed IsItemDeactivatedAfterChange() to IsItemDeactivatedAfterEdit() for consistency with new IsItemEdited() API. Kept redirection function (will obsolete soonish as IsItemDeactivatedAfterChange() is very recent). - - 2018/08/21 (1.63) - renamed ImGuiTextEditCallback to ImGuiInputTextCallback, ImGuiTextEditCallbackData to ImGuiInputTextCallbackData for consistency. Kept redirection types (will obsolete). - - 2018/08/21 (1.63) - removed ImGuiInputTextCallbackData::ReadOnly since it is a duplication of (ImGuiInputTextCallbackData::Flags & ImGuiInputTextFlags_ReadOnly). - - 2018/08/01 (1.63) - removed per-window ImGuiWindowFlags_ResizeFromAnySide beta flag in favor of a global io.ConfigResizeWindowsFromEdges [update 1.67 renamed to ConfigWindowsResizeFromEdges] to enable the feature. - - 2018/08/01 (1.63) - renamed io.OptCursorBlink to io.ConfigCursorBlink [-> io.ConfigInputTextCursorBlink in 1.65], io.OptMacOSXBehaviors to ConfigMacOSXBehaviors for consistency. - - 2018/07/22 (1.63) - changed ImGui::GetTime() return value from float to double to avoid accumulating floating point imprecisions over time. - - 2018/07/08 (1.63) - style: renamed ImGuiCol_ModalWindowDarkening to ImGuiCol_ModalWindowDimBg for consistency with other features. Kept redirection enum (will obsolete). - - 2018/06/08 (1.62) - examples: the imgui_impl_XXX files have been split to separate platform (Win32, GLFW, SDL2, etc.) from renderer (DX11, OpenGL, Vulkan, etc.). - old backends will still work as is, however prefer using the separated backends as they will be updated to support multi-viewports. - when adopting new backends follow the main.cpp code of your preferred examples/ folder to know which functions to call. - in particular, note that old backends called ImGui::NewFrame() at the end of their ImGui_ImplXXXX_NewFrame() function. - - 2018/06/06 (1.62) - renamed GetGlyphRangesChinese() to GetGlyphRangesChineseFull() to distinguish other variants and discourage using the full set. - - 2018/06/06 (1.62) - TreeNodeEx()/TreeNodeBehavior(): the ImGuiTreeNodeFlags_CollapsingHeader helper now include the ImGuiTreeNodeFlags_NoTreePushOnOpen flag. See Changelog for details. - - 2018/05/03 (1.61) - DragInt(): the default compile-time format string has been changed from "%.0f" to "%d", as we are not using integers internally any more. - If you used DragInt() with custom format strings, make sure you change them to use %d or an integer-compatible format. - To honor backward-compatibility, the DragInt() code will currently parse and modify format strings to replace %*f with %d, giving time to users to upgrade their code. - If you have IMGUI_DISABLE_OBSOLETE_FUNCTIONS enabled, the code will instead assert! You may run a reg-exp search on your codebase for e.g. "DragInt.*%f" to help you find them. - - 2018/04/28 (1.61) - obsoleted InputFloat() functions taking an optional "int decimal_precision" in favor of an equivalent and more flexible "const char* format", - consistent with other functions. Kept redirection functions (will obsolete). - - 2018/04/09 (1.61) - IM_DELETE() helper function added in 1.60 doesn't clear the input _pointer_ reference, more consistent with expectation and allows passing r-value. - - 2018/03/20 (1.60) - renamed io.WantMoveMouse to io.WantSetMousePos for consistency and ease of understanding (was added in 1.52, _not_ used by core and only honored by some backend ahead of merging the Nav branch). - - 2018/03/12 (1.60) - removed ImGuiCol_CloseButton, ImGuiCol_CloseButtonActive, ImGuiCol_CloseButtonHovered as the closing cross uses regular button colors now. - - 2018/03/08 (1.60) - changed ImFont::DisplayOffset.y to default to 0 instead of +1. Fixed rounding of Ascent/Descent to match TrueType renderer. If you were adding or subtracting to ImFont::DisplayOffset check if your fonts are correctly aligned vertically. - - 2018/03/03 (1.60) - renamed ImGuiStyleVar_Count_ to ImGuiStyleVar_COUNT and ImGuiMouseCursor_Count_ to ImGuiMouseCursor_COUNT for consistency with other public enums. - - 2018/02/18 (1.60) - BeginDragDropSource(): temporarily removed the optional mouse_button=0 parameter because it is not really usable in many situations at the moment. - - 2018/02/16 (1.60) - obsoleted the io.RenderDrawListsFn callback, you can call your graphics engine render function after ImGui::Render(). Use ImGui::GetDrawData() to retrieve the ImDrawData* to display. - - 2018/02/07 (1.60) - reorganized context handling to be more explicit, - - YOU NOW NEED TO CALL ImGui::CreateContext() AT THE BEGINNING OF YOUR APP, AND CALL ImGui::DestroyContext() AT THE END. - - removed Shutdown() function, as DestroyContext() serve this purpose. - - you may pass a ImFontAtlas* pointer to CreateContext() to share a font atlas between contexts. Otherwise CreateContext() will create its own font atlas instance. - - removed allocator parameters from CreateContext(), they are now setup with SetAllocatorFunctions(), and shared by all contexts. - - removed the default global context and font atlas instance, which were confusing for users of DLL reloading and users of multiple contexts. - - 2018/01/31 (1.60) - moved sample TTF files from extra_fonts/ to misc/fonts/. If you loaded files directly from the imgui repo you may need to update your paths. - - 2018/01/11 (1.60) - obsoleted IsAnyWindowHovered() in favor of IsWindowHovered(ImGuiHoveredFlags_AnyWindow). Kept redirection function (will obsolete). - - 2018/01/11 (1.60) - obsoleted IsAnyWindowFocused() in favor of IsWindowFocused(ImGuiFocusedFlags_AnyWindow). Kept redirection function (will obsolete). - - 2018/01/03 (1.60) - renamed ImGuiSizeConstraintCallback to ImGuiSizeCallback, ImGuiSizeConstraintCallbackData to ImGuiSizeCallbackData. - - 2017/12/29 (1.60) - removed CalcItemRectClosestPoint() which was weird and not really used by anyone except demo code. If you need it it's easy to replicate on your side. - - 2017/12/24 (1.53) - renamed the emblematic ShowTestWindow() function to ShowDemoWindow(). Kept redirection function (will obsolete). - - 2017/12/21 (1.53) - ImDrawList: renamed style.AntiAliasedShapes to style.AntiAliasedFill for consistency and as a way to explicitly break code that manipulate those flag at runtime. You can now manipulate ImDrawList::Flags - - 2017/12/21 (1.53) - ImDrawList: removed 'bool anti_aliased = true' final parameter of ImDrawList::AddPolyline() and ImDrawList::AddConvexPolyFilled(). Prefer manipulating ImDrawList::Flags if you need to toggle them during the frame. - - 2017/12/14 (1.53) - using the ImGuiWindowFlags_NoScrollWithMouse flag on a child window forwards the mouse wheel event to the parent window, unless either ImGuiWindowFlags_NoInputs or ImGuiWindowFlags_NoScrollbar are also set. - - 2017/12/13 (1.53) - renamed GetItemsLineHeightWithSpacing() to GetFrameHeightWithSpacing(). Kept redirection function (will obsolete). - - 2017/12/13 (1.53) - obsoleted IsRootWindowFocused() in favor of using IsWindowFocused(ImGuiFocusedFlags_RootWindow). Kept redirection function (will obsolete). - - obsoleted IsRootWindowOrAnyChildFocused() in favor of using IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows). Kept redirection function (will obsolete). - - 2017/12/12 (1.53) - renamed ImGuiTreeNodeFlags_AllowOverlapMode to ImGuiTreeNodeFlags_AllowItemOverlap. Kept redirection enum (will obsolete). - - 2017/12/10 (1.53) - removed SetNextWindowContentWidth(), prefer using SetNextWindowContentSize(). Kept redirection function (will obsolete). - - 2017/11/27 (1.53) - renamed ImGuiTextBuffer::append() helper to appendf(), appendv() to appendfv(). If you copied the 'Log' demo in your code, it uses appendv() so that needs to be renamed. - - 2017/11/18 (1.53) - Style, Begin: removed ImGuiWindowFlags_ShowBorders window flag. Borders are now fully set up in the ImGuiStyle structure (see e.g. style.FrameBorderSize, style.WindowBorderSize). Use ImGui::ShowStyleEditor() to look them up. - Please note that the style system will keep evolving (hopefully stabilizing in Q1 2018), and so custom styles will probably subtly break over time. It is recommended you use the StyleColorsClassic(), StyleColorsDark(), StyleColorsLight() functions. - - 2017/11/18 (1.53) - Style: removed ImGuiCol_ComboBg in favor of combo boxes using ImGuiCol_PopupBg for consistency. - - 2017/11/18 (1.53) - Style: renamed ImGuiCol_ChildWindowBg to ImGuiCol_ChildBg. - - 2017/11/18 (1.53) - Style: renamed style.ChildWindowRounding to style.ChildRounding, ImGuiStyleVar_ChildWindowRounding to ImGuiStyleVar_ChildRounding. - - 2017/11/02 (1.53) - obsoleted IsRootWindowOrAnyChildHovered() in favor of using IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows); - - 2017/10/24 (1.52) - renamed IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS/IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS to IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS/IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS for consistency. - - 2017/10/20 (1.52) - changed IsWindowHovered() default parameters behavior to return false if an item is active in another window (e.g. click-dragging item from another window to this window). You can use the newly introduced IsWindowHovered() flags to requests this specific behavior if you need it. - - 2017/10/20 (1.52) - marked IsItemHoveredRect()/IsMouseHoveringWindow() as obsolete, in favor of using the newly introduced flags for IsItemHovered() and IsWindowHovered(). See https://github.com/ocornut/imgui/issues/1382 for details. - removed the IsItemRectHovered()/IsWindowRectHovered() names introduced in 1.51 since they were merely more consistent names for the two functions we are now obsoleting. - IsItemHoveredRect() --> IsItemHovered(ImGuiHoveredFlags_RectOnly) - IsMouseHoveringAnyWindow() --> IsWindowHovered(ImGuiHoveredFlags_AnyWindow) - IsMouseHoveringWindow() --> IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem) [weird, old behavior] - - 2017/10/17 (1.52) - marked the old 5-parameters version of Begin() as obsolete (still available). Use SetNextWindowSize()+Begin() instead! - - 2017/10/11 (1.52) - renamed AlignFirstTextHeightToWidgets() to AlignTextToFramePadding(). Kept inline redirection function (will obsolete). - - 2017/09/26 (1.52) - renamed ImFont::Glyph to ImFontGlyph. Kept redirection typedef (will obsolete). - - 2017/09/25 (1.52) - removed SetNextWindowPosCenter() because SetNextWindowPos() now has the optional pivot information to do the same and more. Kept redirection function (will obsolete). - - 2017/08/25 (1.52) - io.MousePos needs to be set to ImVec2(-FLT_MAX,-FLT_MAX) when mouse is unavailable/missing. Previously ImVec2(-1,-1) was enough but we now accept negative mouse coordinates. In your backend if you need to support unavailable mouse, make sure to replace "io.MousePos = ImVec2(-1,-1)" with "io.MousePos = ImVec2(-FLT_MAX,-FLT_MAX)". - - 2017/08/22 (1.51) - renamed IsItemHoveredRect() to IsItemRectHovered(). Kept inline redirection function (will obsolete). -> (1.52) use IsItemHovered(ImGuiHoveredFlags_RectOnly)! - - renamed IsMouseHoveringAnyWindow() to IsAnyWindowHovered() for consistency. Kept inline redirection function (will obsolete). - - renamed IsMouseHoveringWindow() to IsWindowRectHovered() for consistency. Kept inline redirection function (will obsolete). - - 2017/08/20 (1.51) - renamed GetStyleColName() to GetStyleColorName() for consistency. - - 2017/08/20 (1.51) - added PushStyleColor(ImGuiCol idx, ImU32 col) overload, which _might_ cause an "ambiguous call" compilation error if you are using ImColor() with implicit cast. Cast to ImU32 or ImVec4 explicily to fix. - - 2017/08/15 (1.51) - marked the weird IMGUI_ONCE_UPON_A_FRAME helper macro as obsolete. prefer using the more explicit ImGuiOnceUponAFrame type. - - 2017/08/15 (1.51) - changed parameter order for BeginPopupContextWindow() from (const char*,int buttons,bool also_over_items) to (const char*,int buttons,bool also_over_items). Note that most calls relied on default parameters completely. - - 2017/08/13 (1.51) - renamed ImGuiCol_Column to ImGuiCol_Separator, ImGuiCol_ColumnHovered to ImGuiCol_SeparatorHovered, ImGuiCol_ColumnActive to ImGuiCol_SeparatorActive. Kept redirection enums (will obsolete). - - 2017/08/11 (1.51) - renamed ImGuiSetCond_Always to ImGuiCond_Always, ImGuiSetCond_Once to ImGuiCond_Once, ImGuiSetCond_FirstUseEver to ImGuiCond_FirstUseEver, ImGuiSetCond_Appearing to ImGuiCond_Appearing. Kept redirection enums (will obsolete). - - 2017/08/09 (1.51) - removed ValueColor() helpers, they are equivalent to calling Text(label) + SameLine() + ColorButton(). - - 2017/08/08 (1.51) - removed ColorEditMode() and ImGuiColorEditMode in favor of ImGuiColorEditFlags and parameters to the various Color*() functions. The SetColorEditOptions() allows to initialize default but the user can still change them with right-click context menu. - - changed prototype of 'ColorEdit4(const char* label, float col[4], bool show_alpha = true)' to 'ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flags = 0)', where passing flags = 0x01 is a safe no-op (hello dodgy backward compatibility!). - check and run the demo window, under "Color/Picker Widgets", to understand the various new options. - - changed prototype of rarely used 'ColorButton(ImVec4 col, bool small_height = false, bool outline_border = true)' to 'ColorButton(const char* desc_id, ImVec4 col, ImGuiColorEditFlags flags = 0, ImVec2 size = ImVec2(0, 0))' - - 2017/07/20 (1.51) - removed IsPosHoveringAnyWindow(ImVec2), which was partly broken and misleading. ASSERT + redirect user to io.WantCaptureMouse - - 2017/05/26 (1.50) - removed ImFontConfig::MergeGlyphCenterV in favor of a more multipurpose ImFontConfig::GlyphOffset. - - 2017/05/01 (1.50) - renamed ImDrawList::PathFill() (rarely used directly) to ImDrawList::PathFillConvex() for clarity. - - 2016/11/06 (1.50) - BeginChild(const char*) now applies the stack id to the provided label, consistently with other functions as it should always have been. It shouldn't affect you unless (extremely unlikely) you were appending multiple times to a same child from different locations of the stack id. If that's the case, generate an id with GetID() and use it instead of passing string to BeginChild(). - - 2016/10/15 (1.50) - avoid 'void* user_data' parameter to io.SetClipboardTextFn/io.GetClipboardTextFn pointers. We pass io.ClipboardUserData to it. - - 2016/09/25 (1.50) - style.WindowTitleAlign is now a ImVec2 (ImGuiAlign enum was removed). set to (0.5f,0.5f) for horizontal+vertical centering, (0.0f,0.0f) for upper-left, etc. - - 2016/07/30 (1.50) - SameLine(x) with x>0.0f is now relative to left of column/group if any, and not always to left of window. This was sort of always the intent and hopefully, breakage should be minimal. - - 2016/05/12 (1.49) - title bar (using ImGuiCol_TitleBg/ImGuiCol_TitleBgActive colors) isn't rendered over a window background (ImGuiCol_WindowBg color) anymore. - If your TitleBg/TitleBgActive alpha was 1.0f or you are using the default theme it will not affect you, otherwise if <1.0f you need to tweak your custom theme to readjust for the fact that we don't draw a WindowBg background behind the title bar. - This helper function will convert an old TitleBg/TitleBgActive color into a new one with the same visual output, given the OLD color and the OLD WindowBg color: - ImVec4 ConvertTitleBgCol(const ImVec4& win_bg_col, const ImVec4& title_bg_col) { float new_a = 1.0f - ((1.0f - win_bg_col.w) * (1.0f - title_bg_col.w)), k = title_bg_col.w / new_a; return ImVec4((win_bg_col.x * win_bg_col.w + title_bg_col.x) * k, (win_bg_col.y * win_bg_col.w + title_bg_col.y) * k, (win_bg_col.z * win_bg_col.w + title_bg_col.z) * k, new_a); } - If this is confusing, pick the RGB value from title bar from an old screenshot and apply this as TitleBg/TitleBgActive. Or you may just create TitleBgActive from a tweaked TitleBg color. - - 2016/05/07 (1.49) - removed confusing set of GetInternalState(), GetInternalStateSize(), SetInternalState() functions. Now using CreateContext(), DestroyContext(), GetCurrentContext(), SetCurrentContext(). - - 2016/05/02 (1.49) - renamed SetNextTreeNodeOpened() to SetNextTreeNodeOpen(), no redirection. - - 2016/05/01 (1.49) - obsoleted old signature of CollapsingHeader(const char* label, const char* str_id = NULL, bool display_frame = true, bool default_open = false) as extra parameters were badly designed and rarely used. You can replace the "default_open = true" flag in new API with CollapsingHeader(label, ImGuiTreeNodeFlags_DefaultOpen). - - 2016/04/26 (1.49) - changed ImDrawList::PushClipRect(ImVec4 rect) to ImDrawList::PushClipRect(Imvec2 min,ImVec2 max,bool intersect_with_current_clip_rect=false). Note that higher-level ImGui::PushClipRect() is preferable because it will clip at logic/widget level, whereas ImDrawList::PushClipRect() only affect your renderer. - - 2016/04/03 (1.48) - removed style.WindowFillAlphaDefault setting which was redundant. Bake default BG alpha inside style.Colors[ImGuiCol_WindowBg] and all other Bg color values. (ref GitHub issue #337). - - 2016/04/03 (1.48) - renamed ImGuiCol_TooltipBg to ImGuiCol_PopupBg, used by popups/menus and tooltips. popups/menus were previously using ImGuiCol_WindowBg. (ref github issue #337) - - 2016/03/21 (1.48) - renamed GetWindowFont() to GetFont(), GetWindowFontSize() to GetFontSize(). Kept inline redirection function (will obsolete). - - 2016/03/02 (1.48) - InputText() completion/history/always callbacks: if you modify the text buffer manually (without using DeleteChars()/InsertChars() helper) you need to maintain the BufTextLen field. added an assert. - - 2016/01/23 (1.48) - fixed not honoring exact width passed to PushItemWidth(), previously it would add extra FramePadding.x*2 over that width. if you had manual pixel-perfect alignment in place it might affect you. - - 2015/12/27 (1.48) - fixed ImDrawList::AddRect() which used to render a rectangle 1 px too large on each axis. - - 2015/12/04 (1.47) - renamed Color() helpers to ValueColor() - dangerously named, rarely used and probably to be made obsolete. - - 2015/08/29 (1.45) - with the addition of horizontal scrollbar we made various fixes to inconsistencies with dealing with cursor position. - GetCursorPos()/SetCursorPos() functions now include the scrolled amount. It shouldn't affect the majority of users, but take note that SetCursorPosX(100.0f) puts you at +100 from the starting x position which may include scrolling, not at +100 from the window left side. - GetContentRegionMax()/GetWindowContentRegionMin()/GetWindowContentRegionMax() functions allow include the scrolled amount. Typically those were used in cases where no scrolling would happen so it may not be a problem, but watch out! - - 2015/08/29 (1.45) - renamed style.ScrollbarWidth to style.ScrollbarSize - - 2015/08/05 (1.44) - split imgui.cpp into extra files: imgui_demo.cpp imgui_draw.cpp imgui_internal.h that you need to add to your project. - - 2015/07/18 (1.44) - fixed angles in ImDrawList::PathArcTo(), PathArcToFast() (introduced in 1.43) being off by an extra PI for no justifiable reason - - 2015/07/14 (1.43) - add new ImFontAtlas::AddFont() API. For the old AddFont***, moved the 'font_no' parameter of ImFontAtlas::AddFont** functions to the ImFontConfig structure. - you need to render your textured triangles with bilinear filtering to benefit from sub-pixel positioning of text. - - 2015/07/08 (1.43) - switched rendering data to use indexed rendering. this is saving a fair amount of CPU/GPU and enables us to get anti-aliasing for a marginal cost. - this necessary change will break your rendering function! the fix should be very easy. sorry for that :( - - if you are using a vanilla copy of one of the imgui_impl_XXX.cpp provided in the example, you just need to update your copy and you can ignore the rest. - - the signature of the io.RenderDrawListsFn handler has changed! - old: ImGui_XXXX_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_count) - new: ImGui_XXXX_RenderDrawLists(ImDrawData* draw_data). - parameters: 'cmd_lists' becomes 'draw_data->CmdLists', 'cmd_lists_count' becomes 'draw_data->CmdListsCount' - ImDrawList: 'commands' becomes 'CmdBuffer', 'vtx_buffer' becomes 'VtxBuffer', 'IdxBuffer' is new. - ImDrawCmd: 'vtx_count' becomes 'ElemCount', 'clip_rect' becomes 'ClipRect', 'user_callback' becomes 'UserCallback', 'texture_id' becomes 'TextureId'. - - each ImDrawList now contains both a vertex buffer and an index buffer. For each command, render ElemCount/3 triangles using indices from the index buffer. - - if you REALLY cannot render indexed primitives, you can call the draw_data->DeIndexAllBuffers() method to de-index the buffers. This is slow and a waste of CPU/GPU. Prefer using indexed rendering! - - refer to code in the examples/ folder or ask on the GitHub if you are unsure of how to upgrade. please upgrade! - - 2015/07/10 (1.43) - changed SameLine() parameters from int to float. - - 2015/07/02 (1.42) - renamed SetScrollPosHere() to SetScrollFromCursorPos(). Kept inline redirection function (will obsolete). - - 2015/07/02 (1.42) - renamed GetScrollPosY() to GetScrollY(). Necessary to reduce confusion along with other scrolling functions, because positions (e.g. cursor position) are not equivalent to scrolling amount. - - 2015/06/14 (1.41) - changed ImageButton() default bg_col parameter from (0,0,0,1) (black) to (0,0,0,0) (transparent) - makes a difference when texture have transparence - - 2015/06/14 (1.41) - changed Selectable() API from (label, selected, size) to (label, selected, flags, size). Size override should have been rarely used. Sorry! - - 2015/05/31 (1.40) - renamed GetWindowCollapsed() to IsWindowCollapsed() for consistency. Kept inline redirection function (will obsolete). - - 2015/05/31 (1.40) - renamed IsRectClipped() to IsRectVisible() for consistency. Note that return value is opposite! Kept inline redirection function (will obsolete). - - 2015/05/27 (1.40) - removed the third 'repeat_if_held' parameter from Button() - sorry! it was rarely used and inconsistent. Use PushButtonRepeat(true) / PopButtonRepeat() to enable repeat on desired buttons. - - 2015/05/11 (1.40) - changed BeginPopup() API, takes a string identifier instead of a bool. ImGui needs to manage the open/closed state of popups. Call OpenPopup() to actually set the "open" state of a popup. BeginPopup() returns true if the popup is opened. - - 2015/05/03 (1.40) - removed style.AutoFitPadding, using style.WindowPadding makes more sense (the default values were already the same). - - 2015/04/13 (1.38) - renamed IsClipped() to IsRectClipped(). Kept inline redirection function until 1.50. - - 2015/04/09 (1.38) - renamed ImDrawList::AddArc() to ImDrawList::AddArcFast() for compatibility with future API - - 2015/04/03 (1.38) - removed ImGuiCol_CheckHovered, ImGuiCol_CheckActive, replaced with the more general ImGuiCol_FrameBgHovered, ImGuiCol_FrameBgActive. - - 2014/04/03 (1.38) - removed support for passing -FLT_MAX..+FLT_MAX as the range for a SliderFloat(). Use DragFloat() or Inputfloat() instead. - - 2015/03/17 (1.36) - renamed GetItemBoxMin()/GetItemBoxMax()/IsMouseHoveringBox() to GetItemRectMin()/GetItemRectMax()/IsMouseHoveringRect(). Kept inline redirection function until 1.50. - - 2015/03/15 (1.36) - renamed style.TreeNodeSpacing to style.IndentSpacing, ImGuiStyleVar_TreeNodeSpacing to ImGuiStyleVar_IndentSpacing - - 2015/03/13 (1.36) - renamed GetWindowIsFocused() to IsWindowFocused(). Kept inline redirection function until 1.50. - - 2015/03/08 (1.35) - renamed style.ScrollBarWidth to style.ScrollbarWidth (casing) - - 2015/02/27 (1.34) - renamed OpenNextNode(bool) to SetNextTreeNodeOpened(bool, ImGuiSetCond). Kept inline redirection function until 1.50. - - 2015/02/27 (1.34) - renamed ImGuiSetCondition_*** to ImGuiSetCond_***, and _FirstUseThisSession becomes _Once. - - 2015/02/11 (1.32) - changed text input callback ImGuiTextEditCallback return type from void-->int. reserved for future use, return 0 for now. - - 2015/02/10 (1.32) - renamed GetItemWidth() to CalcItemWidth() to clarify its evolving behavior - - 2015/02/08 (1.31) - renamed GetTextLineSpacing() to GetTextLineHeightWithSpacing() - - 2015/02/01 (1.31) - removed IO.MemReallocFn (unused) - - 2015/01/19 (1.30) - renamed ImGuiStorage::GetIntPtr()/GetFloatPtr() to GetIntRef()/GetIntRef() because Ptr was conflicting with actual pointer storage functions. - - 2015/01/11 (1.30) - big font/image API change! now loads TTF file. allow for multiple fonts. no need for a PNG loader. - - 2015/01/11 (1.30) - removed GetDefaultFontData(). uses io.Fonts->GetTextureData*() API to retrieve uncompressed pixels. - - old: const void* png_data; unsigned int png_size; ImGui::GetDefaultFontData(NULL, NULL, &png_data, &png_size); [..Upload texture to GPU..]; - - new: unsigned char* pixels; int width, height; io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); [..Upload texture to GPU..]; io.Fonts->SetTexID(YourTexIdentifier); - you now have more flexibility to load multiple TTF fonts and manage the texture buffer for internal needs. It is now recommended that you sample the font texture with bilinear interpolation. - - 2015/01/11 (1.30) - added texture identifier in ImDrawCmd passed to your render function (we can now render images). make sure to call io.Fonts->SetTexID() - - 2015/01/11 (1.30) - removed IO.PixelCenterOffset (unnecessary, can be handled in user projection matrix) - - 2015/01/11 (1.30) - removed ImGui::IsItemFocused() in favor of ImGui::IsItemActive() which handles all widgets - - 2014/12/10 (1.18) - removed SetNewWindowDefaultPos() in favor of new generic API SetNextWindowPos(pos, ImGuiSetCondition_FirstUseEver) - - 2014/11/28 (1.17) - moved IO.Font*** options to inside the IO.Font-> structure (FontYOffset, FontTexUvForWhite, FontBaseScale, FontFallbackGlyph) - - 2014/11/26 (1.17) - reworked syntax of IMGUI_ONCE_UPON_A_FRAME helper macro to increase compiler compatibility - - 2014/11/07 (1.15) - renamed IsHovered() to IsItemHovered() - - 2014/10/02 (1.14) - renamed IMGUI_INCLUDE_IMGUI_USER_CPP to IMGUI_INCLUDE_IMGUI_USER_INL and imgui_user.cpp to imgui_user.inl (more IDE friendly) - - 2014/09/25 (1.13) - removed 'text_end' parameter from IO.SetClipboardTextFn (the string is now always zero-terminated for simplicity) - - 2014/09/24 (1.12) - renamed SetFontScale() to SetWindowFontScale() - - 2014/09/24 (1.12) - moved IM_MALLOC/IM_REALLOC/IM_FREE preprocessor defines to IO.MemAllocFn/IO.MemReallocFn/IO.MemFreeFn - - 2014/08/30 (1.09) - removed IO.FontHeight (now computed automatically) - - 2014/08/30 (1.09) - moved IMGUI_FONT_TEX_UV_FOR_WHITE preprocessor define to IO.FontTexUvForWhite - - 2014/08/28 (1.09) - changed the behavior of IO.PixelCenterOffset following various rendering fixes - - - FREQUENTLY ASKED QUESTIONS (FAQ) - ================================ - - Read all answers online: - https://www.dearimgui.org/faq or https://github.com/ocornut/imgui/blob/master/docs/FAQ.md (same url) - Read all answers locally (with a text editor or ideally a Markdown viewer): - docs/FAQ.md - Some answers are copied down here to facilitate searching in code. - - Q&A: Basics - =========== - - Q: Where is the documentation? - A: This library is poorly documented at the moment and expects the user to be acquainted with C/C++. - - Run the examples/ and explore them. - - See demo code in imgui_demo.cpp and particularly the ImGui::ShowDemoWindow() function. - - The demo covers most features of Dear ImGui, so you can read the code and see its output. - - See documentation and comments at the top of imgui.cpp + effectively imgui.h. - - Dozens of standalone example applications using e.g. OpenGL/DirectX are provided in the - examples/ folder to explain how to integrate Dear ImGui with your own engine/application. - - The Wiki (https://github.com/ocornut/imgui/wiki) has many resources and links. - - The Glossary (https://github.com/ocornut/imgui/wiki/Glossary) page also may be useful. - - Your programming IDE is your friend, find the type or function declaration to find comments - associated with it. - - Q: What is this library called? - Q: Which version should I get? - >> This library is called "Dear ImGui", please don't call it "ImGui" :) - >> See https://www.dearimgui.org/faq for details. - - Q&A: Integration - ================ - - Q: How to get started? - A: Read 'PROGRAMMER GUIDE' above. Read examples/README.txt. - - Q: How can I tell whether to dispatch mouse/keyboard to Dear ImGui or my application? - A: You should read the 'io.WantCaptureMouse', 'io.WantCaptureKeyboard' and 'io.WantTextInput' flags! - >> See https://www.dearimgui.org/faq for a fully detailed answer. You really want to read this. - - Q. How can I enable keyboard controls? - Q: How can I use this without a mouse, without a keyboard or without a screen? (gamepad, input share, remote display) - Q: I integrated Dear ImGui in my engine and little squares are showing instead of text... - Q: I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around... - Q: I integrated Dear ImGui in my engine and some elements are displaying outside their expected windows boundaries... - >> See https://www.dearimgui.org/faq - - Q&A: Usage - ---------- - - Q: Why is my widget not reacting when I click on it? - Q: How can I have widgets with an empty label? - Q: How can I have multiple widgets with the same label? - Q: How can I display an image? What is ImTextureID, how does it works? - Q: How can I use my own math types instead of ImVec2/ImVec4? - Q: How can I interact with standard C++ types (such as std::string and std::vector)? - Q: How can I display custom shapes? (using low-level ImDrawList API) - >> See https://www.dearimgui.org/faq - - Q&A: Fonts, Text - ================ - - Q: How should I handle DPI in my application? - Q: How can I load a different font than the default? - Q: How can I easily use icons in my application? - Q: How can I load multiple fonts? - Q: How can I display and input non-Latin characters such as Chinese, Japanese, Korean, Cyrillic? - >> See https://www.dearimgui.org/faq and https://github.com/ocornut/imgui/edit/master/docs/FONTS.md - - Q&A: Concerns - ============= - - Q: Who uses Dear ImGui? - Q: Can you create elaborate/serious tools with Dear ImGui? - Q: Can you reskin the look of Dear ImGui? - Q: Why using C++ (as opposed to C)? - >> See https://www.dearimgui.org/faq - - Q&A: Community - ============== - - Q: How can I help? - A: - Businesses: please reach out to "contact AT dearimgui.com" if you work in a place using Dear ImGui! - We can discuss ways for your company to fund development via invoiced technical support, maintenance or sponsoring contacts. - This is among the most useful thing you can do for Dear ImGui. With increased funding, we can hire more people working on this project. - - Individuals: you can support continued development via PayPal donations. See README. - - If you are experienced with Dear ImGui and C++, look at the GitHub issues, look at the Wiki, read docs/TODO.txt - and see how you want to help and can help! - - Disclose your usage of Dear ImGui via a dev blog post, a tweet, a screenshot, a mention somewhere etc. - You may post screenshot or links in the gallery threads. Visuals are ideal as they inspire other programmers. - But even without visuals, disclosing your use of dear imgui helps the library grow credibility, and help other teams and programmers with taking decisions. - - If you have issues or if you need to hack into the library, even if you don't expect any support it is useful that you share your issues (on GitHub or privately). - -*/ - -//------------------------------------------------------------------------- -// [SECTION] INCLUDES -//------------------------------------------------------------------------- - -#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) -#define _CRT_SECURE_NO_WARNINGS -#endif - -#include "imgui.h" -#ifndef IMGUI_DISABLE - -#ifndef IMGUI_DEFINE_MATH_OPERATORS -#define IMGUI_DEFINE_MATH_OPERATORS -#endif -#include "imgui_internal.h" - -// System includes -#include // toupper -#include // vsnprintf, sscanf, printf -#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier -#include // intptr_t -#else -#include // intptr_t -#endif - -// [Windows] On non-Visual Studio compilers, we default to IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS unless explicitly enabled -#if defined(_WIN32) && !defined(_MSC_VER) && !defined(IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS) -#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS -#endif - -// [Windows] OS specific includes (optional) -#if defined(_WIN32) && defined(IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS) && defined(IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS) && defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) -#define IMGUI_DISABLE_WIN32_FUNCTIONS -#endif -#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif -#ifndef NOMINMAX -#define NOMINMAX -#endif -#ifndef __MINGW32__ -#include // _wfopen, OpenClipboard -#else -#include -#endif -#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) // UWP doesn't have all Win32 functions -#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS -#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS -#endif -#endif - -// [Apple] OS specific includes -#if defined(__APPLE__) -#include -#endif - -// Visual Studio warnings -#ifdef _MSC_VER -#pragma warning (disable: 4127) // condition expression is constant -#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen -#if defined(_MSC_VER) && _MSC_VER >= 1922 // MSVC 2019 16.2 or later -#pragma warning (disable: 5054) // operator '|': deprecated between enumerations of different types -#endif -#pragma warning (disable: 26451) // [Static Analyzer] Arithmetic overflow : Using operator 'xxx' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator 'xxx' to avoid overflow(io.2). -#pragma warning (disable: 26495) // [Static Analyzer] Variable 'XXX' is uninitialized. Always initialize a member variable (type.6). -#pragma warning (disable: 26812) // [Static Analyzer] The enum type 'xxx' is unscoped. Prefer 'enum class' over 'enum' (Enum.3). -#endif - -// Clang/GCC warnings with -Weverything -#if defined(__clang__) -#if __has_warning("-Wunknown-warning-option") -#pragma clang diagnostic ignored "-Wunknown-warning-option" // warning: unknown warning group 'xxx' // not all warnings are known by all Clang versions and they tend to be rename-happy.. so ignoring warnings triggers new warnings on some configuration. Great! -#endif -#pragma clang diagnostic ignored "-Wunknown-pragmas" // warning: unknown warning group 'xxx' -#pragma clang diagnostic ignored "-Wold-style-cast" // warning: use of old-style cast // yes, they are more terse. -#pragma clang diagnostic ignored "-Wfloat-equal" // warning: comparing floating point with == or != is unsafe // storing and comparing against same constants (typically 0.0f) is ok. -#pragma clang diagnostic ignored "-Wformat-nonliteral" // warning: format string is not a string literal // passing non-literal to vsnformat(). yes, user passing incorrect format strings can crash the code. -#pragma clang diagnostic ignored "-Wexit-time-destructors" // warning: declaration requires an exit-time destructor // exit-time destruction order is undefined. if MemFree() leads to users code that has been disabled before exit it might cause problems. ImGui coding style welcomes static/globals. -#pragma clang diagnostic ignored "-Wglobal-constructors" // warning: declaration requires a global destructor // similar to above, not sure what the exact difference is. -#pragma clang diagnostic ignored "-Wsign-conversion" // warning: implicit conversion changes signedness -#pragma clang diagnostic ignored "-Wformat-pedantic" // warning: format specifies type 'void *' but the argument has type 'xxxx *' // unreasonable, would lead to casting every %p arg to void*. probably enabled by -pedantic. -#pragma clang diagnostic ignored "-Wint-to-void-pointer-cast" // warning: cast to 'void *' from smaller integer type 'int' -#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" // warning: zero as null pointer constant // some standard header variations use #define NULL 0 -#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double. -#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision -#elif defined(__GNUC__) -// We disable -Wpragmas because GCC doesn't provide an has_warning equivalent and some forks/patches may not following the warning/version association. -#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind -#pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used -#pragma GCC diagnostic ignored "-Wint-to-pointer-cast" // warning: cast to pointer from integer of different size -#pragma GCC diagnostic ignored "-Wformat" // warning: format '%p' expects argument of type 'void*', but argument 6 has type 'ImGuiWindow*' -#pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function -#pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value -#pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked -#pragma GCC diagnostic ignored "-Wstrict-overflow" // warning: assuming signed overflow does not occur when assuming that (X - c) > X is always false -#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead -#endif - -// Debug options -#define IMGUI_DEBUG_NAV_SCORING 0 // Display navigation scoring preview when hovering items. Display last moving direction matches when holding CTRL -#define IMGUI_DEBUG_NAV_RECTS 0 // Display the reference navigation rectangle for each window -#define IMGUI_DEBUG_INI_SETTINGS 0 // Save additional comments in .ini file (particularly helps for Docking, but makes saving slower) - -// When using CTRL+TAB (or Gamepad Square+L/R) we delay the visual a little in order to reduce visual noise doing a fast switch. -static const float NAV_WINDOWING_HIGHLIGHT_DELAY = 0.20f; // Time before the highlight and screen dimming starts fading in -static const float NAV_WINDOWING_LIST_APPEAR_DELAY = 0.15f; // Time before the window list starts to appear - -// Window resizing from edges (when io.ConfigWindowsResizeFromEdges = true and ImGuiBackendFlags_HasMouseCursors is set in io.BackendFlags by backend) -static const float WINDOWS_HOVER_PADDING = 4.0f; // Extend outside window for hovering/resizing (maxxed with TouchPadding) and inside windows for borders. Affect FindHoveredWindow(). -static const float WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER = 0.04f; // Reduce visual noise by only highlighting the border after a certain time. -static const float WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER = 2.00f; // Lock scrolled window (so it doesn't pick child windows that are scrolling through) for a certain time, unless mouse moved. - -//------------------------------------------------------------------------- -// [SECTION] FORWARD DECLARATIONS -//------------------------------------------------------------------------- - -static void SetCurrentWindow(ImGuiWindow* window); -static void FindHoveredWindow(); -static ImGuiWindow* CreateNewWindow(const char* name, ImGuiWindowFlags flags); -static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window); - -static void AddDrawListToDrawData(ImVector* out_list, ImDrawList* draw_list); -static void AddWindowToSortBuffer(ImVector* out_sorted_windows, ImGuiWindow* window); - -// Settings -static void WindowSettingsHandler_ClearAll(ImGuiContext*, ImGuiSettingsHandler*); -static void* WindowSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name); -static void WindowSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line); -static void WindowSettingsHandler_ApplyAll(ImGuiContext*, ImGuiSettingsHandler*); -static void WindowSettingsHandler_WriteAll(ImGuiContext*, ImGuiSettingsHandler*, ImGuiTextBuffer* buf); - -// Platform Dependents default implementation for IO functions -static const char* GetClipboardTextFn_DefaultImpl(void* user_data); -static void SetClipboardTextFn_DefaultImpl(void* user_data, const char* text); -static void ImeSetInputScreenPosFn_DefaultImpl(int x, int y); - -namespace ImGui -{ -// Navigation -static void NavUpdate(); -static void NavUpdateWindowing(); -static void NavUpdateWindowingOverlay(); -static void NavUpdateCancelRequest(); -static void NavUpdateCreateMoveRequest(); -static float NavUpdatePageUpPageDown(); -static inline void NavUpdateAnyRequestFlag(); -static void NavEndFrame(); -static bool NavScoreItem(ImGuiNavItemData* result); -static void NavApplyItemToResult(ImGuiNavItemData* result); -static void NavProcessItem(); -static ImVec2 NavCalcPreferredRefPos(); -static void NavSaveLastChildNavWindowIntoParent(ImGuiWindow* nav_window); -static ImGuiWindow* NavRestoreLastChildNavWindow(ImGuiWindow* window); -static void NavRestoreLayer(ImGuiNavLayer layer); -static int FindWindowFocusIndex(ImGuiWindow* window); - -// Error Checking and Debug Tools -static void ErrorCheckNewFrameSanityChecks(); -static void ErrorCheckEndFrameSanityChecks(); -static void UpdateDebugToolItemPicker(); -static void UpdateDebugToolStackQueries(); - -// Misc -static void UpdateSettings(); -static void UpdateMouseInputs(); -static void UpdateMouseWheel(); -static void UpdateTabFocus(); -static bool UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4], const ImRect& visibility_rect); -static void RenderWindowOuterBorders(ImGuiWindow* window); -static void RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar_rect, bool title_bar_is_highlight, int resize_grip_count, const ImU32 resize_grip_col[4], float resize_grip_draw_size); -static void RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& title_bar_rect, const char* name, bool* p_open); - -// Viewports -static void UpdateViewportsNewFrame(); - -} - -//----------------------------------------------------------------------------- -// [SECTION] CONTEXT AND MEMORY ALLOCATORS -//----------------------------------------------------------------------------- - -// DLL users: -// - Heaps and globals are not shared across DLL boundaries! -// - You will need to call SetCurrentContext() + SetAllocatorFunctions() for each static/DLL boundary you are calling from. -// - Same applies for hot-reloading mechanisms that are reliant on reloading DLL (note that many hot-reloading mechanisms work without DLL). -// - Using Dear ImGui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility. -// - Confused? In a debugger: add GImGui to your watch window and notice how its value changes depending on your current location (which DLL boundary you are in). - -// Current context pointer. Implicitly used by all Dear ImGui functions. Always assumed to be != NULL. -// - ImGui::CreateContext() will automatically set this pointer if it is NULL. -// Change to a different context by calling ImGui::SetCurrentContext(). -// - Important: Dear ImGui functions are not thread-safe because of this pointer. -// If you want thread-safety to allow N threads to access N different contexts: -// - Change this variable to use thread local storage so each thread can refer to a different context, in your imconfig.h: -// struct ImGuiContext; -// extern thread_local ImGuiContext* MyImGuiTLS; -// #define GImGui MyImGuiTLS -// And then define MyImGuiTLS in one of your cpp files. Note that thread_local is a C++11 keyword, earlier C++ uses compiler-specific keyword. -// - Future development aims to make this context pointer explicit to all calls. Also read https://github.com/ocornut/imgui/issues/586 -// - If you need a finite number of contexts, you may compile and use multiple instances of the ImGui code from a different namespace. -// - DLL users: read comments above. -#ifndef GImGui -ImGuiContext* GImGui = NULL; -#endif - -// Memory Allocator functions. Use SetAllocatorFunctions() to change them. -// - You probably don't want to modify that mid-program, and if you use global/static e.g. ImVector<> instances you may need to keep them accessible during program destruction. -// - DLL users: read comments above. -#ifndef IMGUI_DISABLE_DEFAULT_ALLOCATORS -static void* MallocWrapper(size_t size, void* user_data) { IM_UNUSED(user_data); return malloc(size); } -static void FreeWrapper(void* ptr, void* user_data) { IM_UNUSED(user_data); free(ptr); } -#else -static void* MallocWrapper(size_t size, void* user_data) { IM_UNUSED(user_data); IM_UNUSED(size); IM_ASSERT(0); return NULL; } -static void FreeWrapper(void* ptr, void* user_data) { IM_UNUSED(user_data); IM_UNUSED(ptr); IM_ASSERT(0); } -#endif -static ImGuiMemAllocFunc GImAllocatorAllocFunc = MallocWrapper; -static ImGuiMemFreeFunc GImAllocatorFreeFunc = FreeWrapper; -static void* GImAllocatorUserData = NULL; - -//----------------------------------------------------------------------------- -// [SECTION] USER FACING STRUCTURES (ImGuiStyle, ImGuiIO) -//----------------------------------------------------------------------------- - -ImGuiStyle::ImGuiStyle() -{ - Alpha = 1.0f; // Global alpha applies to everything in Dear ImGui. - DisabledAlpha = 0.60f; // Additional alpha multiplier applied by BeginDisabled(). Multiply over current value of Alpha. - WindowPadding = ImVec2(8,8); // Padding within a window - WindowRounding = 0.0f; // Radius of window corners rounding. Set to 0.0f to have rectangular windows. Large values tend to lead to variety of artifacts and are not recommended. - WindowBorderSize = 1.0f; // Thickness of border around windows. Generally set to 0.0f or 1.0f. Other values not well tested. - WindowMinSize = ImVec2(32,32); // Minimum window size - WindowTitleAlign = ImVec2(0.0f,0.5f);// Alignment for title bar text - WindowMenuButtonPosition= ImGuiDir_Left; // Position of the collapsing/docking button in the title bar (left/right). Defaults to ImGuiDir_Left. - ChildRounding = 0.0f; // Radius of child window corners rounding. Set to 0.0f to have rectangular child windows - ChildBorderSize = 1.0f; // Thickness of border around child windows. Generally set to 0.0f or 1.0f. Other values not well tested. - PopupRounding = 0.0f; // Radius of popup window corners rounding. Set to 0.0f to have rectangular child windows - PopupBorderSize = 1.0f; // Thickness of border around popup or tooltip windows. Generally set to 0.0f or 1.0f. Other values not well tested. - FramePadding = ImVec2(4,3); // Padding within a framed rectangle (used by most widgets) - FrameRounding = 0.0f; // Radius of frame corners rounding. Set to 0.0f to have rectangular frames (used by most widgets). - FrameBorderSize = 0.0f; // Thickness of border around frames. Generally set to 0.0f or 1.0f. Other values not well tested. - ItemSpacing = ImVec2(8,4); // Horizontal and vertical spacing between widgets/lines - ItemInnerSpacing = ImVec2(4,4); // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label) - CellPadding = ImVec2(4,2); // Padding within a table cell - TouchExtraPadding = ImVec2(0,0); // Expand reactive bounding box for touch-based system where touch position is not accurate enough. Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much! - IndentSpacing = 21.0f; // Horizontal spacing when e.g. entering a tree node. Generally == (FontSize + FramePadding.x*2). - ColumnsMinSpacing = 6.0f; // Minimum horizontal spacing between two columns. Preferably > (FramePadding.x + 1). - ScrollbarSize = 14.0f; // Width of the vertical scrollbar, Height of the horizontal scrollbar - ScrollbarRounding = 9.0f; // Radius of grab corners rounding for scrollbar - GrabMinSize = 10.0f; // Minimum width/height of a grab box for slider/scrollbar - GrabRounding = 0.0f; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs. - LogSliderDeadzone = 4.0f; // The size in pixels of the dead-zone around zero on logarithmic sliders that cross zero. - TabRounding = 4.0f; // Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs. - TabBorderSize = 0.0f; // Thickness of border around tabs. - TabMinWidthForCloseButton = 0.0f; // Minimum width for close button to appears on an unselected tab when hovered. Set to 0.0f to always show when hovering, set to FLT_MAX to never show close button unless selected. - ColorButtonPosition = ImGuiDir_Right; // Side of the color button in the ColorEdit4 widget (left/right). Defaults to ImGuiDir_Right. - ButtonTextAlign = ImVec2(0.5f,0.5f);// Alignment of button text when button is larger than text. - SelectableTextAlign = ImVec2(0.0f,0.0f);// Alignment of selectable text. Defaults to (0.0f, 0.0f) (top-left aligned). It's generally important to keep this left-aligned if you want to lay multiple items on a same line. - DisplayWindowPadding = ImVec2(19,19); // Window position are clamped to be visible within the display area or monitors by at least this amount. Only applies to regular windows. - DisplaySafeAreaPadding = ImVec2(3,3); // If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows. - MouseCursorScale = 1.0f; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). May be removed later. - AntiAliasedLines = true; // Enable anti-aliased lines/borders. Disable if you are really tight on CPU/GPU. - AntiAliasedLinesUseTex = true; // Enable anti-aliased lines/borders using textures where possible. Require backend to render with bilinear filtering. - AntiAliasedFill = true; // Enable anti-aliased filled shapes (rounded rectangles, circles, etc.). - CurveTessellationTol = 1.25f; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality. - CircleTessellationMaxError = 0.30f; // Maximum error (in pixels) allowed when using AddCircle()/AddCircleFilled() or drawing rounded corner rectangles with no explicit segment count specified. Decrease for higher quality but more geometry. - - // Default theme - ImGui::StyleColorsDark(this); -} - -// To scale your entire UI (e.g. if you want your app to use High DPI or generally be DPI aware) you may use this helper function. Scaling the fonts is done separately and is up to you. -// Important: This operation is lossy because we round all sizes to integer. If you need to change your scale multiples, call this over a freshly initialized ImGuiStyle structure rather than scaling multiple times. -void ImGuiStyle::ScaleAllSizes(float scale_factor) -{ - WindowPadding = ImFloor(WindowPadding * scale_factor); - WindowRounding = ImFloor(WindowRounding * scale_factor); - WindowMinSize = ImFloor(WindowMinSize * scale_factor); - ChildRounding = ImFloor(ChildRounding * scale_factor); - PopupRounding = ImFloor(PopupRounding * scale_factor); - FramePadding = ImFloor(FramePadding * scale_factor); - FrameRounding = ImFloor(FrameRounding * scale_factor); - ItemSpacing = ImFloor(ItemSpacing * scale_factor); - ItemInnerSpacing = ImFloor(ItemInnerSpacing * scale_factor); - CellPadding = ImFloor(CellPadding * scale_factor); - TouchExtraPadding = ImFloor(TouchExtraPadding * scale_factor); - IndentSpacing = ImFloor(IndentSpacing * scale_factor); - ColumnsMinSpacing = ImFloor(ColumnsMinSpacing * scale_factor); - ScrollbarSize = ImFloor(ScrollbarSize * scale_factor); - ScrollbarRounding = ImFloor(ScrollbarRounding * scale_factor); - GrabMinSize = ImFloor(GrabMinSize * scale_factor); - GrabRounding = ImFloor(GrabRounding * scale_factor); - LogSliderDeadzone = ImFloor(LogSliderDeadzone * scale_factor); - TabRounding = ImFloor(TabRounding * scale_factor); - TabMinWidthForCloseButton = (TabMinWidthForCloseButton != FLT_MAX) ? ImFloor(TabMinWidthForCloseButton * scale_factor) : FLT_MAX; - DisplayWindowPadding = ImFloor(DisplayWindowPadding * scale_factor); - DisplaySafeAreaPadding = ImFloor(DisplaySafeAreaPadding * scale_factor); - MouseCursorScale = ImFloor(MouseCursorScale * scale_factor); -} - -ImGuiIO::ImGuiIO() -{ - // Most fields are initialized with zero - memset(this, 0, sizeof(*this)); - IM_ASSERT(IM_ARRAYSIZE(ImGuiIO::MouseDown) == ImGuiMouseButton_COUNT && IM_ARRAYSIZE(ImGuiIO::MouseClicked) == ImGuiMouseButton_COUNT); // Our pre-C++11 IM_STATIC_ASSERT() macros triggers warning on modern compilers so we don't use it here. - - // Settings - ConfigFlags = ImGuiConfigFlags_None; - BackendFlags = ImGuiBackendFlags_None; - DisplaySize = ImVec2(-1.0f, -1.0f); - DeltaTime = 1.0f / 60.0f; - IniSavingRate = 5.0f; - IniFilename = "imgui.ini"; // Important: "imgui.ini" is relative to current working dir, most apps will want to lock this to an absolute path (e.g. same path as executables). - LogFilename = "imgui_log.txt"; - MouseDoubleClickTime = 0.30f; - MouseDoubleClickMaxDist = 6.0f; - for (int i = 0; i < ImGuiKey_COUNT; i++) - KeyMap[i] = -1; - KeyRepeatDelay = 0.275f; - KeyRepeatRate = 0.050f; - UserData = NULL; - - Fonts = NULL; - FontGlobalScale = 1.0f; - FontDefault = NULL; - FontAllowUserScaling = false; - DisplayFramebufferScale = ImVec2(1.0f, 1.0f); - - // Miscellaneous options - MouseDrawCursor = false; -#ifdef __APPLE__ - ConfigMacOSXBehaviors = true; // Set Mac OS X style defaults based on __APPLE__ compile time flag -#else - ConfigMacOSXBehaviors = false; -#endif - ConfigInputTextCursorBlink = true; - ConfigWindowsResizeFromEdges = true; - ConfigWindowsMoveFromTitleBarOnly = false; - ConfigMemoryCompactTimer = 60.0f; - - // Platform Functions - BackendPlatformName = BackendRendererName = NULL; - BackendPlatformUserData = BackendRendererUserData = BackendLanguageUserData = NULL; - GetClipboardTextFn = GetClipboardTextFn_DefaultImpl; // Platform dependent default implementations - SetClipboardTextFn = SetClipboardTextFn_DefaultImpl; - ClipboardUserData = NULL; - ImeSetInputScreenPosFn = ImeSetInputScreenPosFn_DefaultImpl; - ImeWindowHandle = NULL; - - // Input (NB: we already have memset zero the entire structure!) - MousePos = ImVec2(-FLT_MAX, -FLT_MAX); - MousePosPrev = ImVec2(-FLT_MAX, -FLT_MAX); - MouseDragThreshold = 6.0f; - for (int i = 0; i < IM_ARRAYSIZE(MouseDownDuration); i++) MouseDownDuration[i] = MouseDownDurationPrev[i] = -1.0f; - for (int i = 0; i < IM_ARRAYSIZE(KeysDownDuration); i++) KeysDownDuration[i] = KeysDownDurationPrev[i] = -1.0f; - for (int i = 0; i < IM_ARRAYSIZE(NavInputsDownDuration); i++) NavInputsDownDuration[i] = -1.0f; -} - -// Pass in translated ASCII characters for text input. -// - with glfw you can get those from the callback set in glfwSetCharCallback() -// - on Windows you can get those using ToAscii+keyboard state, or via the WM_CHAR message -void ImGuiIO::AddInputCharacter(unsigned int c) -{ - if (c != 0) - InputQueueCharacters.push_back(c <= IM_UNICODE_CODEPOINT_MAX ? (ImWchar)c : IM_UNICODE_CODEPOINT_INVALID); -} - -// UTF16 strings use surrogate pairs to encode codepoints >= 0x10000, so -// we should save the high surrogate. -void ImGuiIO::AddInputCharacterUTF16(ImWchar16 c) -{ - if (c == 0 && InputQueueSurrogate == 0) - return; - - if ((c & 0xFC00) == 0xD800) // High surrogate, must save - { - if (InputQueueSurrogate != 0) - InputQueueCharacters.push_back(IM_UNICODE_CODEPOINT_INVALID); - InputQueueSurrogate = c; - return; - } - - ImWchar cp = c; - if (InputQueueSurrogate != 0) - { - if ((c & 0xFC00) != 0xDC00) // Invalid low surrogate - { - InputQueueCharacters.push_back(IM_UNICODE_CODEPOINT_INVALID); - } - else - { -#if IM_UNICODE_CODEPOINT_MAX == 0xFFFF - cp = IM_UNICODE_CODEPOINT_INVALID; // Codepoint will not fit in ImWchar -#else - cp = (ImWchar)(((InputQueueSurrogate - 0xD800) << 10) + (c - 0xDC00) + 0x10000); -#endif - } - - InputQueueSurrogate = 0; - } - InputQueueCharacters.push_back(cp); -} - -void ImGuiIO::AddInputCharactersUTF8(const char* utf8_chars) -{ - while (*utf8_chars != 0) - { - unsigned int c = 0; - utf8_chars += ImTextCharFromUtf8(&c, utf8_chars, NULL); - if (c != 0) - InputQueueCharacters.push_back((ImWchar)c); - } -} - -void ImGuiIO::ClearInputCharacters() -{ - InputQueueCharacters.resize(0); -} - -void ImGuiIO::ClearInputKeys() -{ - memset(KeysDown, 0, sizeof(KeysDown)); - for (int n = 0; n < IM_ARRAYSIZE(KeysDownDuration); n++) - KeysDownDuration[n] = KeysDownDurationPrev[n] = -1.0f; - KeyCtrl = KeyShift = KeyAlt = KeySuper = false; - KeyMods = KeyModsPrev = ImGuiKeyModFlags_None; - for (int n = 0; n < IM_ARRAYSIZE(NavInputsDownDuration); n++) - NavInputsDownDuration[n] = NavInputsDownDurationPrev[n] = -1.0f; -} - -void ImGuiIO::AddFocusEvent(bool focused) -{ - // We intentionally overwrite this and process in NewFrame(), in order to give a chance - // to multi-viewports backends to queue AddFocusEvent(false),AddFocusEvent(true) in same frame. - AppFocusLost = !focused; -} - -//----------------------------------------------------------------------------- -// [SECTION] MISC HELPERS/UTILITIES (Geometry functions) -//----------------------------------------------------------------------------- - -ImVec2 ImBezierCubicClosestPoint(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, int num_segments) -{ - IM_ASSERT(num_segments > 0); // Use ImBezierCubicClosestPointCasteljau() - ImVec2 p_last = p1; - ImVec2 p_closest; - float p_closest_dist2 = FLT_MAX; - float t_step = 1.0f / (float)num_segments; - for (int i_step = 1; i_step <= num_segments; i_step++) - { - ImVec2 p_current = ImBezierCubicCalc(p1, p2, p3, p4, t_step * i_step); - ImVec2 p_line = ImLineClosestPoint(p_last, p_current, p); - float dist2 = ImLengthSqr(p - p_line); - if (dist2 < p_closest_dist2) - { - p_closest = p_line; - p_closest_dist2 = dist2; - } - p_last = p_current; - } - return p_closest; -} - -// Closely mimics PathBezierToCasteljau() in imgui_draw.cpp -static void ImBezierCubicClosestPointCasteljauStep(const ImVec2& p, ImVec2& p_closest, ImVec2& p_last, float& p_closest_dist2, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float tess_tol, int level) -{ - float dx = x4 - x1; - float dy = y4 - y1; - float d2 = ((x2 - x4) * dy - (y2 - y4) * dx); - float d3 = ((x3 - x4) * dy - (y3 - y4) * dx); - d2 = (d2 >= 0) ? d2 : -d2; - d3 = (d3 >= 0) ? d3 : -d3; - if ((d2 + d3) * (d2 + d3) < tess_tol * (dx * dx + dy * dy)) - { - ImVec2 p_current(x4, y4); - ImVec2 p_line = ImLineClosestPoint(p_last, p_current, p); - float dist2 = ImLengthSqr(p - p_line); - if (dist2 < p_closest_dist2) - { - p_closest = p_line; - p_closest_dist2 = dist2; - } - p_last = p_current; - } - else if (level < 10) - { - float x12 = (x1 + x2)*0.5f, y12 = (y1 + y2)*0.5f; - float x23 = (x2 + x3)*0.5f, y23 = (y2 + y3)*0.5f; - float x34 = (x3 + x4)*0.5f, y34 = (y3 + y4)*0.5f; - float x123 = (x12 + x23)*0.5f, y123 = (y12 + y23)*0.5f; - float x234 = (x23 + x34)*0.5f, y234 = (y23 + y34)*0.5f; - float x1234 = (x123 + x234)*0.5f, y1234 = (y123 + y234)*0.5f; - ImBezierCubicClosestPointCasteljauStep(p, p_closest, p_last, p_closest_dist2, x1, y1, x12, y12, x123, y123, x1234, y1234, tess_tol, level + 1); - ImBezierCubicClosestPointCasteljauStep(p, p_closest, p_last, p_closest_dist2, x1234, y1234, x234, y234, x34, y34, x4, y4, tess_tol, level + 1); - } -} - -// tess_tol is generally the same value you would find in ImGui::GetStyle().CurveTessellationTol -// Because those ImXXX functions are lower-level than ImGui:: we cannot access this value automatically. -ImVec2 ImBezierCubicClosestPointCasteljau(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, float tess_tol) -{ - IM_ASSERT(tess_tol > 0.0f); - ImVec2 p_last = p1; - ImVec2 p_closest; - float p_closest_dist2 = FLT_MAX; - ImBezierCubicClosestPointCasteljauStep(p, p_closest, p_last, p_closest_dist2, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, tess_tol, 0); - return p_closest; -} - -ImVec2 ImLineClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& p) -{ - ImVec2 ap = p - a; - ImVec2 ab_dir = b - a; - float dot = ap.x * ab_dir.x + ap.y * ab_dir.y; - if (dot < 0.0f) - return a; - float ab_len_sqr = ab_dir.x * ab_dir.x + ab_dir.y * ab_dir.y; - if (dot > ab_len_sqr) - return b; - return a + ab_dir * dot / ab_len_sqr; -} - -bool ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p) -{ - bool b1 = ((p.x - b.x) * (a.y - b.y) - (p.y - b.y) * (a.x - b.x)) < 0.0f; - bool b2 = ((p.x - c.x) * (b.y - c.y) - (p.y - c.y) * (b.x - c.x)) < 0.0f; - bool b3 = ((p.x - a.x) * (c.y - a.y) - (p.y - a.y) * (c.x - a.x)) < 0.0f; - return ((b1 == b2) && (b2 == b3)); -} - -void ImTriangleBarycentricCoords(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p, float& out_u, float& out_v, float& out_w) -{ - ImVec2 v0 = b - a; - ImVec2 v1 = c - a; - ImVec2 v2 = p - a; - const float denom = v0.x * v1.y - v1.x * v0.y; - out_v = (v2.x * v1.y - v1.x * v2.y) / denom; - out_w = (v0.x * v2.y - v2.x * v0.y) / denom; - out_u = 1.0f - out_v - out_w; -} - -ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p) -{ - ImVec2 proj_ab = ImLineClosestPoint(a, b, p); - ImVec2 proj_bc = ImLineClosestPoint(b, c, p); - ImVec2 proj_ca = ImLineClosestPoint(c, a, p); - float dist2_ab = ImLengthSqr(p - proj_ab); - float dist2_bc = ImLengthSqr(p - proj_bc); - float dist2_ca = ImLengthSqr(p - proj_ca); - float m = ImMin(dist2_ab, ImMin(dist2_bc, dist2_ca)); - if (m == dist2_ab) - return proj_ab; - if (m == dist2_bc) - return proj_bc; - return proj_ca; -} - -//----------------------------------------------------------------------------- -// [SECTION] MISC HELPERS/UTILITIES (String, Format, Hash functions) -//----------------------------------------------------------------------------- - -// Consider using _stricmp/_strnicmp under Windows or strcasecmp/strncasecmp. We don't actually use either ImStricmp/ImStrnicmp in the codebase any more. -int ImStricmp(const char* str1, const char* str2) -{ - int d; - while ((d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; } - return d; -} - -int ImStrnicmp(const char* str1, const char* str2, size_t count) -{ - int d = 0; - while (count > 0 && (d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; count--; } - return d; -} - -void ImStrncpy(char* dst, const char* src, size_t count) -{ - if (count < 1) - return; - if (count > 1) - strncpy(dst, src, count - 1); - dst[count - 1] = 0; -} - -char* ImStrdup(const char* str) -{ - size_t len = strlen(str); - void* buf = IM_ALLOC(len + 1); - return (char*)memcpy(buf, (const void*)str, len + 1); -} - -char* ImStrdupcpy(char* dst, size_t* p_dst_size, const char* src) -{ - size_t dst_buf_size = p_dst_size ? *p_dst_size : strlen(dst) + 1; - size_t src_size = strlen(src) + 1; - if (dst_buf_size < src_size) - { - IM_FREE(dst); - dst = (char*)IM_ALLOC(src_size); - if (p_dst_size) - *p_dst_size = src_size; - } - return (char*)memcpy(dst, (const void*)src, src_size); -} - -const char* ImStrchrRange(const char* str, const char* str_end, char c) -{ - const char* p = (const char*)memchr(str, (int)c, str_end - str); - return p; -} - -int ImStrlenW(const ImWchar* str) -{ - //return (int)wcslen((const wchar_t*)str); // FIXME-OPT: Could use this when wchar_t are 16-bit - int n = 0; - while (*str++) n++; - return n; -} - -// Find end-of-line. Return pointer will point to either first \n, either str_end. -const char* ImStreolRange(const char* str, const char* str_end) -{ - const char* p = (const char*)memchr(str, '\n', str_end - str); - return p ? p : str_end; -} - -const ImWchar* ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin) // find beginning-of-line -{ - while (buf_mid_line > buf_begin && buf_mid_line[-1] != '\n') - buf_mid_line--; - return buf_mid_line; -} - -const char* ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end) -{ - if (!needle_end) - needle_end = needle + strlen(needle); - - const char un0 = (char)toupper(*needle); - while ((!haystack_end && *haystack) || (haystack_end && haystack < haystack_end)) - { - if (toupper(*haystack) == un0) - { - const char* b = needle + 1; - for (const char* a = haystack + 1; b < needle_end; a++, b++) - if (toupper(*a) != toupper(*b)) - break; - if (b == needle_end) - return haystack; - } - haystack++; - } - return NULL; -} - -// Trim str by offsetting contents when there's leading data + writing a \0 at the trailing position. We use this in situation where the cost is negligible. -void ImStrTrimBlanks(char* buf) -{ - char* p = buf; - while (p[0] == ' ' || p[0] == '\t') // Leading blanks - p++; - char* p_start = p; - while (*p != 0) // Find end of string - p++; - while (p > p_start && (p[-1] == ' ' || p[-1] == '\t')) // Trailing blanks - p--; - if (p_start != buf) // Copy memory if we had leading blanks - memmove(buf, p_start, p - p_start); - buf[p - p_start] = 0; // Zero terminate -} - -const char* ImStrSkipBlank(const char* str) -{ - while (str[0] == ' ' || str[0] == '\t') - str++; - return str; -} - -// A) MSVC version appears to return -1 on overflow, whereas glibc appears to return total count (which may be >= buf_size). -// Ideally we would test for only one of those limits at runtime depending on the behavior the vsnprintf(), but trying to deduct it at compile time sounds like a pandora can of worm. -// B) When buf==NULL vsnprintf() will return the output size. -#ifndef IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS - -// We support stb_sprintf which is much faster (see: https://github.com/nothings/stb/blob/master/stb_sprintf.h) -// You may set IMGUI_USE_STB_SPRINTF to use our default wrapper, or set IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS -// and setup the wrapper yourself. (FIXME-OPT: Some of our high-level operations such as ImGuiTextBuffer::appendfv() are -// designed using two-passes worst case, which probably could be improved using the stbsp_vsprintfcb() function.) -#ifdef IMGUI_USE_STB_SPRINTF -#define STB_SPRINTF_IMPLEMENTATION -#include "stb_sprintf.h" -#endif - -#if defined(_MSC_VER) && !defined(vsnprintf) -#define vsnprintf _vsnprintf -#endif - -int ImFormatString(char* buf, size_t buf_size, const char* fmt, ...) -{ - va_list args; - va_start(args, fmt); -#ifdef IMGUI_USE_STB_SPRINTF - int w = stbsp_vsnprintf(buf, (int)buf_size, fmt, args); -#else - int w = vsnprintf(buf, buf_size, fmt, args); -#endif - va_end(args); - if (buf == NULL) - return w; - if (w == -1 || w >= (int)buf_size) - w = (int)buf_size - 1; - buf[w] = 0; - return w; -} - -int ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args) -{ -#ifdef IMGUI_USE_STB_SPRINTF - int w = stbsp_vsnprintf(buf, (int)buf_size, fmt, args); -#else - int w = vsnprintf(buf, buf_size, fmt, args); -#endif - if (buf == NULL) - return w; - if (w == -1 || w >= (int)buf_size) - w = (int)buf_size - 1; - buf[w] = 0; - return w; -} -#endif // #ifdef IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS - -// CRC32 needs a 1KB lookup table (not cache friendly) -// Although the code to generate the table is simple and shorter than the table itself, using a const table allows us to easily: -// - avoid an unnecessary branch/memory tap, - keep the ImHashXXX functions usable by static constructors, - make it thread-safe. -static const ImU32 GCrc32LookupTable[256] = -{ - 0x00000000,0x77073096,0xEE0E612C,0x990951BA,0x076DC419,0x706AF48F,0xE963A535,0x9E6495A3,0x0EDB8832,0x79DCB8A4,0xE0D5E91E,0x97D2D988,0x09B64C2B,0x7EB17CBD,0xE7B82D07,0x90BF1D91, - 0x1DB71064,0x6AB020F2,0xF3B97148,0x84BE41DE,0x1ADAD47D,0x6DDDE4EB,0xF4D4B551,0x83D385C7,0x136C9856,0x646BA8C0,0xFD62F97A,0x8A65C9EC,0x14015C4F,0x63066CD9,0xFA0F3D63,0x8D080DF5, - 0x3B6E20C8,0x4C69105E,0xD56041E4,0xA2677172,0x3C03E4D1,0x4B04D447,0xD20D85FD,0xA50AB56B,0x35B5A8FA,0x42B2986C,0xDBBBC9D6,0xACBCF940,0x32D86CE3,0x45DF5C75,0xDCD60DCF,0xABD13D59, - 0x26D930AC,0x51DE003A,0xC8D75180,0xBFD06116,0x21B4F4B5,0x56B3C423,0xCFBA9599,0xB8BDA50F,0x2802B89E,0x5F058808,0xC60CD9B2,0xB10BE924,0x2F6F7C87,0x58684C11,0xC1611DAB,0xB6662D3D, - 0x76DC4190,0x01DB7106,0x98D220BC,0xEFD5102A,0x71B18589,0x06B6B51F,0x9FBFE4A5,0xE8B8D433,0x7807C9A2,0x0F00F934,0x9609A88E,0xE10E9818,0x7F6A0DBB,0x086D3D2D,0x91646C97,0xE6635C01, - 0x6B6B51F4,0x1C6C6162,0x856530D8,0xF262004E,0x6C0695ED,0x1B01A57B,0x8208F4C1,0xF50FC457,0x65B0D9C6,0x12B7E950,0x8BBEB8EA,0xFCB9887C,0x62DD1DDF,0x15DA2D49,0x8CD37CF3,0xFBD44C65, - 0x4DB26158,0x3AB551CE,0xA3BC0074,0xD4BB30E2,0x4ADFA541,0x3DD895D7,0xA4D1C46D,0xD3D6F4FB,0x4369E96A,0x346ED9FC,0xAD678846,0xDA60B8D0,0x44042D73,0x33031DE5,0xAA0A4C5F,0xDD0D7CC9, - 0x5005713C,0x270241AA,0xBE0B1010,0xC90C2086,0x5768B525,0x206F85B3,0xB966D409,0xCE61E49F,0x5EDEF90E,0x29D9C998,0xB0D09822,0xC7D7A8B4,0x59B33D17,0x2EB40D81,0xB7BD5C3B,0xC0BA6CAD, - 0xEDB88320,0x9ABFB3B6,0x03B6E20C,0x74B1D29A,0xEAD54739,0x9DD277AF,0x04DB2615,0x73DC1683,0xE3630B12,0x94643B84,0x0D6D6A3E,0x7A6A5AA8,0xE40ECF0B,0x9309FF9D,0x0A00AE27,0x7D079EB1, - 0xF00F9344,0x8708A3D2,0x1E01F268,0x6906C2FE,0xF762575D,0x806567CB,0x196C3671,0x6E6B06E7,0xFED41B76,0x89D32BE0,0x10DA7A5A,0x67DD4ACC,0xF9B9DF6F,0x8EBEEFF9,0x17B7BE43,0x60B08ED5, - 0xD6D6A3E8,0xA1D1937E,0x38D8C2C4,0x4FDFF252,0xD1BB67F1,0xA6BC5767,0x3FB506DD,0x48B2364B,0xD80D2BDA,0xAF0A1B4C,0x36034AF6,0x41047A60,0xDF60EFC3,0xA867DF55,0x316E8EEF,0x4669BE79, - 0xCB61B38C,0xBC66831A,0x256FD2A0,0x5268E236,0xCC0C7795,0xBB0B4703,0x220216B9,0x5505262F,0xC5BA3BBE,0xB2BD0B28,0x2BB45A92,0x5CB36A04,0xC2D7FFA7,0xB5D0CF31,0x2CD99E8B,0x5BDEAE1D, - 0x9B64C2B0,0xEC63F226,0x756AA39C,0x026D930A,0x9C0906A9,0xEB0E363F,0x72076785,0x05005713,0x95BF4A82,0xE2B87A14,0x7BB12BAE,0x0CB61B38,0x92D28E9B,0xE5D5BE0D,0x7CDCEFB7,0x0BDBDF21, - 0x86D3D2D4,0xF1D4E242,0x68DDB3F8,0x1FDA836E,0x81BE16CD,0xF6B9265B,0x6FB077E1,0x18B74777,0x88085AE6,0xFF0F6A70,0x66063BCA,0x11010B5C,0x8F659EFF,0xF862AE69,0x616BFFD3,0x166CCF45, - 0xA00AE278,0xD70DD2EE,0x4E048354,0x3903B3C2,0xA7672661,0xD06016F7,0x4969474D,0x3E6E77DB,0xAED16A4A,0xD9D65ADC,0x40DF0B66,0x37D83BF0,0xA9BCAE53,0xDEBB9EC5,0x47B2CF7F,0x30B5FFE9, - 0xBDBDF21C,0xCABAC28A,0x53B39330,0x24B4A3A6,0xBAD03605,0xCDD70693,0x54DE5729,0x23D967BF,0xB3667A2E,0xC4614AB8,0x5D681B02,0x2A6F2B94,0xB40BBE37,0xC30C8EA1,0x5A05DF1B,0x2D02EF8D, -}; - -// Known size hash -// It is ok to call ImHashData on a string with known length but the ### operator won't be supported. -// FIXME-OPT: Replace with e.g. FNV1a hash? CRC32 pretty much randomly access 1KB. Need to do proper measurements. -ImGuiID ImHashData(const void* data_p, size_t data_size, ImU32 seed) -{ - ImU32 crc = ~seed; - const unsigned char* data = (const unsigned char*)data_p; - const ImU32* crc32_lut = GCrc32LookupTable; - while (data_size-- != 0) - crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ *data++]; - return ~crc; -} - -// Zero-terminated string hash, with support for ### to reset back to seed value -// We support a syntax of "label###id" where only "###id" is included in the hash, and only "label" gets displayed. -// Because this syntax is rarely used we are optimizing for the common case. -// - If we reach ### in the string we discard the hash so far and reset to the seed. -// - We don't do 'current += 2; continue;' after handling ### to keep the code smaller/faster (measured ~10% diff in Debug build) -// FIXME-OPT: Replace with e.g. FNV1a hash? CRC32 pretty much randomly access 1KB. Need to do proper measurements. -ImGuiID ImHashStr(const char* data_p, size_t data_size, ImU32 seed) -{ - seed = ~seed; - ImU32 crc = seed; - const unsigned char* data = (const unsigned char*)data_p; - const ImU32* crc32_lut = GCrc32LookupTable; - if (data_size != 0) - { - while (data_size-- != 0) - { - unsigned char c = *data++; - if (c == '#' && data_size >= 2 && data[0] == '#' && data[1] == '#') - crc = seed; - crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c]; - } - } - else - { - while (unsigned char c = *data++) - { - if (c == '#' && data[0] == '#' && data[1] == '#') - crc = seed; - crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c]; - } - } - return ~crc; -} - -//----------------------------------------------------------------------------- -// [SECTION] MISC HELPERS/UTILITIES (File functions) -//----------------------------------------------------------------------------- - -// Default file functions -#ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS - -ImFileHandle ImFileOpen(const char* filename, const char* mode) -{ -#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(__CYGWIN__) && !defined(__GNUC__) - // We need a fopen() wrapper because MSVC/Windows fopen doesn't handle UTF-8 filenames. - // Previously we used ImTextCountCharsFromUtf8/ImTextStrFromUtf8 here but we now need to support ImWchar16 and ImWchar32! - const int filename_wsize = ::MultiByteToWideChar(CP_UTF8, 0, filename, -1, NULL, 0); - const int mode_wsize = ::MultiByteToWideChar(CP_UTF8, 0, mode, -1, NULL, 0); - ImVector buf; - buf.resize(filename_wsize + mode_wsize); - ::MultiByteToWideChar(CP_UTF8, 0, filename, -1, (wchar_t*)&buf[0], filename_wsize); - ::MultiByteToWideChar(CP_UTF8, 0, mode, -1, (wchar_t*)&buf[filename_wsize], mode_wsize); - return ::_wfopen((const wchar_t*)&buf[0], (const wchar_t*)&buf[filename_wsize]); -#else - return fopen(filename, mode); -#endif -} - -// We should in theory be using fseeko()/ftello() with off_t and _fseeki64()/_ftelli64() with __int64, waiting for the PR that does that in a very portable pre-C++11 zero-warnings way. -bool ImFileClose(ImFileHandle f) { return fclose(f) == 0; } -ImU64 ImFileGetSize(ImFileHandle f) { long off = 0, sz = 0; return ((off = ftell(f)) != -1 && !fseek(f, 0, SEEK_END) && (sz = ftell(f)) != -1 && !fseek(f, off, SEEK_SET)) ? (ImU64)sz : (ImU64)-1; } -ImU64 ImFileRead(void* data, ImU64 sz, ImU64 count, ImFileHandle f) { return fread(data, (size_t)sz, (size_t)count, f); } -ImU64 ImFileWrite(const void* data, ImU64 sz, ImU64 count, ImFileHandle f) { return fwrite(data, (size_t)sz, (size_t)count, f); } -#endif // #ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS - -// Helper: Load file content into memory -// Memory allocated with IM_ALLOC(), must be freed by user using IM_FREE() == ImGui::MemFree() -// This can't really be used with "rt" because fseek size won't match read size. -void* ImFileLoadToMemory(const char* filename, const char* mode, size_t* out_file_size, int padding_bytes) -{ - IM_ASSERT(filename && mode); - if (out_file_size) - *out_file_size = 0; - - ImFileHandle f; - if ((f = ImFileOpen(filename, mode)) == NULL) - return NULL; - - size_t file_size = (size_t)ImFileGetSize(f); - if (file_size == (size_t)-1) - { - ImFileClose(f); - return NULL; - } - - void* file_data = IM_ALLOC(file_size + padding_bytes); - if (file_data == NULL) - { - ImFileClose(f); - return NULL; - } - if (ImFileRead(file_data, 1, file_size, f) != file_size) - { - ImFileClose(f); - IM_FREE(file_data); - return NULL; - } - if (padding_bytes > 0) - memset((void*)(((char*)file_data) + file_size), 0, (size_t)padding_bytes); - - ImFileClose(f); - if (out_file_size) - *out_file_size = file_size; - - return file_data; -} - -//----------------------------------------------------------------------------- -// [SECTION] MISC HELPERS/UTILITIES (ImText* functions) -//----------------------------------------------------------------------------- - -// Convert UTF-8 to 32-bit character, process single character input. -// A nearly-branchless UTF-8 decoder, based on work of Christopher Wellons (https://github.com/skeeto/branchless-utf8). -// We handle UTF-8 decoding error by skipping forward. -int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end) -{ - static const char lengths[32] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 3, 3, 4, 0 }; - static const int masks[] = { 0x00, 0x7f, 0x1f, 0x0f, 0x07 }; - static const uint32_t mins[] = { 0x400000, 0, 0x80, 0x800, 0x10000 }; - static const int shiftc[] = { 0, 18, 12, 6, 0 }; - static const int shifte[] = { 0, 6, 4, 2, 0 }; - int len = lengths[*(const unsigned char*)in_text >> 3]; - int wanted = len + !len; - - if (in_text_end == NULL) - in_text_end = in_text + wanted; // Max length, nulls will be taken into account. - - // Copy at most 'len' bytes, stop copying at 0 or past in_text_end. Branch predictor does a good job here, - // so it is fast even with excessive branching. - unsigned char s[4]; - s[0] = in_text + 0 < in_text_end ? in_text[0] : 0; - s[1] = in_text + 1 < in_text_end ? in_text[1] : 0; - s[2] = in_text + 2 < in_text_end ? in_text[2] : 0; - s[3] = in_text + 3 < in_text_end ? in_text[3] : 0; - - // Assume a four-byte character and load four bytes. Unused bits are shifted out. - *out_char = (uint32_t)(s[0] & masks[len]) << 18; - *out_char |= (uint32_t)(s[1] & 0x3f) << 12; - *out_char |= (uint32_t)(s[2] & 0x3f) << 6; - *out_char |= (uint32_t)(s[3] & 0x3f) << 0; - *out_char >>= shiftc[len]; - - // Accumulate the various error conditions. - int e = 0; - e = (*out_char < mins[len]) << 6; // non-canonical encoding - e |= ((*out_char >> 11) == 0x1b) << 7; // surrogate half? - e |= (*out_char > IM_UNICODE_CODEPOINT_MAX) << 8; // out of range? - e |= (s[1] & 0xc0) >> 2; - e |= (s[2] & 0xc0) >> 4; - e |= (s[3] ) >> 6; - e ^= 0x2a; // top two bits of each tail byte correct? - e >>= shifte[len]; - - if (e) - { - // No bytes are consumed when *in_text == 0 || in_text == in_text_end. - // One byte is consumed in case of invalid first byte of in_text. - // All available bytes (at most `len` bytes) are consumed on incomplete/invalid second to last bytes. - // Invalid or incomplete input may consume less bytes than wanted, therefore every byte has to be inspected in s. - wanted = ImMin(wanted, !!s[0] + !!s[1] + !!s[2] + !!s[3]); - *out_char = IM_UNICODE_CODEPOINT_INVALID; - } - - return wanted; -} - -int ImTextStrFromUtf8(ImWchar* buf, int buf_size, const char* in_text, const char* in_text_end, const char** in_text_remaining) -{ - ImWchar* buf_out = buf; - ImWchar* buf_end = buf + buf_size; - while (buf_out < buf_end - 1 && (!in_text_end || in_text < in_text_end) && *in_text) - { - unsigned int c; - in_text += ImTextCharFromUtf8(&c, in_text, in_text_end); - if (c == 0) - break; - *buf_out++ = (ImWchar)c; - } - *buf_out = 0; - if (in_text_remaining) - *in_text_remaining = in_text; - return (int)(buf_out - buf); -} - -int ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end) -{ - int char_count = 0; - while ((!in_text_end || in_text < in_text_end) && *in_text) - { - unsigned int c; - in_text += ImTextCharFromUtf8(&c, in_text, in_text_end); - if (c == 0) - break; - char_count++; - } - return char_count; -} - -// Based on stb_to_utf8() from github.com/nothings/stb/ -static inline int ImTextCharToUtf8_inline(char* buf, int buf_size, unsigned int c) -{ - if (c < 0x80) - { - buf[0] = (char)c; - return 1; - } - if (c < 0x800) - { - if (buf_size < 2) return 0; - buf[0] = (char)(0xc0 + (c >> 6)); - buf[1] = (char)(0x80 + (c & 0x3f)); - return 2; - } - if (c < 0x10000) - { - if (buf_size < 3) return 0; - buf[0] = (char)(0xe0 + (c >> 12)); - buf[1] = (char)(0x80 + ((c >> 6) & 0x3f)); - buf[2] = (char)(0x80 + ((c ) & 0x3f)); - return 3; - } - if (c <= 0x10FFFF) - { - if (buf_size < 4) return 0; - buf[0] = (char)(0xf0 + (c >> 18)); - buf[1] = (char)(0x80 + ((c >> 12) & 0x3f)); - buf[2] = (char)(0x80 + ((c >> 6) & 0x3f)); - buf[3] = (char)(0x80 + ((c ) & 0x3f)); - return 4; - } - // Invalid code point, the max unicode is 0x10FFFF - return 0; -} - -const char* ImTextCharToUtf8(char out_buf[5], unsigned int c) -{ - int count = ImTextCharToUtf8_inline(out_buf, 5, c); - out_buf[count] = 0; - return out_buf; -} - -// Not optimal but we very rarely use this function. -int ImTextCountUtf8BytesFromChar(const char* in_text, const char* in_text_end) -{ - unsigned int unused = 0; - return ImTextCharFromUtf8(&unused, in_text, in_text_end); -} - -static inline int ImTextCountUtf8BytesFromChar(unsigned int c) -{ - if (c < 0x80) return 1; - if (c < 0x800) return 2; - if (c < 0x10000) return 3; - if (c <= 0x10FFFF) return 4; - return 3; -} - -int ImTextStrToUtf8(char* out_buf, int out_buf_size, const ImWchar* in_text, const ImWchar* in_text_end) -{ - char* buf_p = out_buf; - const char* buf_end = out_buf + out_buf_size; - while (buf_p < buf_end - 1 && (!in_text_end || in_text < in_text_end) && *in_text) - { - unsigned int c = (unsigned int)(*in_text++); - if (c < 0x80) - *buf_p++ = (char)c; - else - buf_p += ImTextCharToUtf8_inline(buf_p, (int)(buf_end - buf_p - 1), c); - } - *buf_p = 0; - return (int)(buf_p - out_buf); -} - -int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end) -{ - int bytes_count = 0; - while ((!in_text_end || in_text < in_text_end) && *in_text) - { - unsigned int c = (unsigned int)(*in_text++); - if (c < 0x80) - bytes_count++; - else - bytes_count += ImTextCountUtf8BytesFromChar(c); - } - return bytes_count; -} - -//----------------------------------------------------------------------------- -// [SECTION] MISC HELPERS/UTILITIES (Color functions) -// Note: The Convert functions are early design which are not consistent with other API. -//----------------------------------------------------------------------------- - -IMGUI_API ImU32 ImAlphaBlendColors(ImU32 col_a, ImU32 col_b) -{ - float t = ((col_b >> IM_COL32_A_SHIFT) & 0xFF) / 255.f; - int r = ImLerp((int)(col_a >> IM_COL32_R_SHIFT) & 0xFF, (int)(col_b >> IM_COL32_R_SHIFT) & 0xFF, t); - int g = ImLerp((int)(col_a >> IM_COL32_G_SHIFT) & 0xFF, (int)(col_b >> IM_COL32_G_SHIFT) & 0xFF, t); - int b = ImLerp((int)(col_a >> IM_COL32_B_SHIFT) & 0xFF, (int)(col_b >> IM_COL32_B_SHIFT) & 0xFF, t); - return IM_COL32(r, g, b, 0xFF); -} - -ImVec4 ImGui::ColorConvertU32ToFloat4(ImU32 in) -{ - float s = 1.0f / 255.0f; - return ImVec4( - ((in >> IM_COL32_R_SHIFT) & 0xFF) * s, - ((in >> IM_COL32_G_SHIFT) & 0xFF) * s, - ((in >> IM_COL32_B_SHIFT) & 0xFF) * s, - ((in >> IM_COL32_A_SHIFT) & 0xFF) * s); -} - -ImU32 ImGui::ColorConvertFloat4ToU32(const ImVec4& in) -{ - ImU32 out; - out = ((ImU32)IM_F32_TO_INT8_SAT(in.x)) << IM_COL32_R_SHIFT; - out |= ((ImU32)IM_F32_TO_INT8_SAT(in.y)) << IM_COL32_G_SHIFT; - out |= ((ImU32)IM_F32_TO_INT8_SAT(in.z)) << IM_COL32_B_SHIFT; - out |= ((ImU32)IM_F32_TO_INT8_SAT(in.w)) << IM_COL32_A_SHIFT; - return out; -} - -// Convert rgb floats ([0-1],[0-1],[0-1]) to hsv floats ([0-1],[0-1],[0-1]), from Foley & van Dam p592 -// Optimized http://lolengine.net/blog/2013/01/13/fast-rgb-to-hsv -void ImGui::ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v) -{ - float K = 0.f; - if (g < b) - { - ImSwap(g, b); - K = -1.f; - } - if (r < g) - { - ImSwap(r, g); - K = -2.f / 6.f - K; - } - - const float chroma = r - (g < b ? g : b); - out_h = ImFabs(K + (g - b) / (6.f * chroma + 1e-20f)); - out_s = chroma / (r + 1e-20f); - out_v = r; -} - -// Convert hsv floats ([0-1],[0-1],[0-1]) to rgb floats ([0-1],[0-1],[0-1]), from Foley & van Dam p593 -// also http://en.wikipedia.org/wiki/HSL_and_HSV -void ImGui::ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b) -{ - if (s == 0.0f) - { - // gray - out_r = out_g = out_b = v; - return; - } - - h = ImFmod(h, 1.0f) / (60.0f / 360.0f); - int i = (int)h; - float f = h - (float)i; - float p = v * (1.0f - s); - float q = v * (1.0f - s * f); - float t = v * (1.0f - s * (1.0f - f)); - - switch (i) - { - case 0: out_r = v; out_g = t; out_b = p; break; - case 1: out_r = q; out_g = v; out_b = p; break; - case 2: out_r = p; out_g = v; out_b = t; break; - case 3: out_r = p; out_g = q; out_b = v; break; - case 4: out_r = t; out_g = p; out_b = v; break; - case 5: default: out_r = v; out_g = p; out_b = q; break; - } -} - -//----------------------------------------------------------------------------- -// [SECTION] ImGuiStorage -// Helper: Key->value storage -//----------------------------------------------------------------------------- - -// std::lower_bound but without the bullshit -static ImGuiStorage::ImGuiStoragePair* LowerBound(ImVector& data, ImGuiID key) -{ - ImGuiStorage::ImGuiStoragePair* first = data.Data; - ImGuiStorage::ImGuiStoragePair* last = data.Data + data.Size; - size_t count = (size_t)(last - first); - while (count > 0) - { - size_t count2 = count >> 1; - ImGuiStorage::ImGuiStoragePair* mid = first + count2; - if (mid->key < key) - { - first = ++mid; - count -= count2 + 1; - } - else - { - count = count2; - } - } - return first; -} - -// For quicker full rebuild of a storage (instead of an incremental one), you may add all your contents and then sort once. -void ImGuiStorage::BuildSortByKey() -{ - struct StaticFunc - { - static int IMGUI_CDECL PairCompareByID(const void* lhs, const void* rhs) - { - // We can't just do a subtraction because qsort uses signed integers and subtracting our ID doesn't play well with that. - if (((const ImGuiStoragePair*)lhs)->key > ((const ImGuiStoragePair*)rhs)->key) return +1; - if (((const ImGuiStoragePair*)lhs)->key < ((const ImGuiStoragePair*)rhs)->key) return -1; - return 0; - } - }; - if (Data.Size > 1) - ImQsort(Data.Data, (size_t)Data.Size, sizeof(ImGuiStoragePair), StaticFunc::PairCompareByID); -} - -int ImGuiStorage::GetInt(ImGuiID key, int default_val) const -{ - ImGuiStoragePair* it = LowerBound(const_cast&>(Data), key); - if (it == Data.end() || it->key != key) - return default_val; - return it->val_i; -} - -bool ImGuiStorage::GetBool(ImGuiID key, bool default_val) const -{ - return GetInt(key, default_val ? 1 : 0) != 0; -} - -float ImGuiStorage::GetFloat(ImGuiID key, float default_val) const -{ - ImGuiStoragePair* it = LowerBound(const_cast&>(Data), key); - if (it == Data.end() || it->key != key) - return default_val; - return it->val_f; -} - -void* ImGuiStorage::GetVoidPtr(ImGuiID key) const -{ - ImGuiStoragePair* it = LowerBound(const_cast&>(Data), key); - if (it == Data.end() || it->key != key) - return NULL; - return it->val_p; -} - -// References are only valid until a new value is added to the storage. Calling a Set***() function or a Get***Ref() function invalidates the pointer. -int* ImGuiStorage::GetIntRef(ImGuiID key, int default_val) -{ - ImGuiStoragePair* it = LowerBound(Data, key); - if (it == Data.end() || it->key != key) - it = Data.insert(it, ImGuiStoragePair(key, default_val)); - return &it->val_i; -} - -bool* ImGuiStorage::GetBoolRef(ImGuiID key, bool default_val) -{ - return (bool*)GetIntRef(key, default_val ? 1 : 0); -} - -float* ImGuiStorage::GetFloatRef(ImGuiID key, float default_val) -{ - ImGuiStoragePair* it = LowerBound(Data, key); - if (it == Data.end() || it->key != key) - it = Data.insert(it, ImGuiStoragePair(key, default_val)); - return &it->val_f; -} - -void** ImGuiStorage::GetVoidPtrRef(ImGuiID key, void* default_val) -{ - ImGuiStoragePair* it = LowerBound(Data, key); - if (it == Data.end() || it->key != key) - it = Data.insert(it, ImGuiStoragePair(key, default_val)); - return &it->val_p; -} - -// FIXME-OPT: Need a way to reuse the result of lower_bound when doing GetInt()/SetInt() - not too bad because it only happens on explicit interaction (maximum one a frame) -void ImGuiStorage::SetInt(ImGuiID key, int val) -{ - ImGuiStoragePair* it = LowerBound(Data, key); - if (it == Data.end() || it->key != key) - { - Data.insert(it, ImGuiStoragePair(key, val)); - return; - } - it->val_i = val; -} - -void ImGuiStorage::SetBool(ImGuiID key, bool val) -{ - SetInt(key, val ? 1 : 0); -} - -void ImGuiStorage::SetFloat(ImGuiID key, float val) -{ - ImGuiStoragePair* it = LowerBound(Data, key); - if (it == Data.end() || it->key != key) - { - Data.insert(it, ImGuiStoragePair(key, val)); - return; - } - it->val_f = val; -} - -void ImGuiStorage::SetVoidPtr(ImGuiID key, void* val) -{ - ImGuiStoragePair* it = LowerBound(Data, key); - if (it == Data.end() || it->key != key) - { - Data.insert(it, ImGuiStoragePair(key, val)); - return; - } - it->val_p = val; -} - -void ImGuiStorage::SetAllInt(int v) -{ - for (int i = 0; i < Data.Size; i++) - Data[i].val_i = v; -} - -//----------------------------------------------------------------------------- -// [SECTION] ImGuiTextFilter -//----------------------------------------------------------------------------- - -// Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]" -ImGuiTextFilter::ImGuiTextFilter(const char* default_filter) -{ - if (default_filter) - { - ImStrncpy(InputBuf, default_filter, IM_ARRAYSIZE(InputBuf)); - Build(); - } - else - { - InputBuf[0] = 0; - CountGrep = 0; - } -} - -bool ImGuiTextFilter::Draw(const char* label, float width) -{ - if (width != 0.0f) - ImGui::SetNextItemWidth(width); - bool value_changed = ImGui::InputText(label, InputBuf, IM_ARRAYSIZE(InputBuf)); - if (value_changed) - Build(); - return value_changed; -} - -void ImGuiTextFilter::ImGuiTextRange::split(char separator, ImVector* out) const -{ - out->resize(0); - const char* wb = b; - const char* we = wb; - while (we < e) - { - if (*we == separator) - { - out->push_back(ImGuiTextRange(wb, we)); - wb = we + 1; - } - we++; - } - if (wb != we) - out->push_back(ImGuiTextRange(wb, we)); -} - -void ImGuiTextFilter::Build() -{ - Filters.resize(0); - ImGuiTextRange input_range(InputBuf, InputBuf + strlen(InputBuf)); - input_range.split(',', &Filters); - - CountGrep = 0; - for (int i = 0; i != Filters.Size; i++) - { - ImGuiTextRange& f = Filters[i]; - while (f.b < f.e && ImCharIsBlankA(f.b[0])) - f.b++; - while (f.e > f.b && ImCharIsBlankA(f.e[-1])) - f.e--; - if (f.empty()) - continue; - if (Filters[i].b[0] != '-') - CountGrep += 1; - } -} - -bool ImGuiTextFilter::PassFilter(const char* text, const char* text_end) const -{ - if (Filters.empty()) - return true; - - if (text == NULL) - text = ""; - - for (int i = 0; i != Filters.Size; i++) - { - const ImGuiTextRange& f = Filters[i]; - if (f.empty()) - continue; - if (f.b[0] == '-') - { - // Subtract - if (ImStristr(text, text_end, f.b + 1, f.e) != NULL) - return false; - } - else - { - // Grep - if (ImStristr(text, text_end, f.b, f.e) != NULL) - return true; - } - } - - // Implicit * grep - if (CountGrep == 0) - return true; - - return false; -} - -//----------------------------------------------------------------------------- -// [SECTION] ImGuiTextBuffer -//----------------------------------------------------------------------------- - -// On some platform vsnprintf() takes va_list by reference and modifies it. -// va_copy is the 'correct' way to copy a va_list but Visual Studio prior to 2013 doesn't have it. -#ifndef va_copy -#if defined(__GNUC__) || defined(__clang__) -#define va_copy(dest, src) __builtin_va_copy(dest, src) -#else -#define va_copy(dest, src) (dest = src) -#endif -#endif - -char ImGuiTextBuffer::EmptyString[1] = { 0 }; - -void ImGuiTextBuffer::append(const char* str, const char* str_end) -{ - int len = str_end ? (int)(str_end - str) : (int)strlen(str); - - // Add zero-terminator the first time - const int write_off = (Buf.Size != 0) ? Buf.Size : 1; - const int needed_sz = write_off + len; - if (write_off + len >= Buf.Capacity) - { - int new_capacity = Buf.Capacity * 2; - Buf.reserve(needed_sz > new_capacity ? needed_sz : new_capacity); - } - - Buf.resize(needed_sz); - memcpy(&Buf[write_off - 1], str, (size_t)len); - Buf[write_off - 1 + len] = 0; -} - -void ImGuiTextBuffer::appendf(const char* fmt, ...) -{ - va_list args; - va_start(args, fmt); - appendfv(fmt, args); - va_end(args); -} - -// Helper: Text buffer for logging/accumulating text -void ImGuiTextBuffer::appendfv(const char* fmt, va_list args) -{ - va_list args_copy; - va_copy(args_copy, args); - - int len = ImFormatStringV(NULL, 0, fmt, args); // FIXME-OPT: could do a first pass write attempt, likely successful on first pass. - if (len <= 0) - { - va_end(args_copy); - return; - } - - // Add zero-terminator the first time - const int write_off = (Buf.Size != 0) ? Buf.Size : 1; - const int needed_sz = write_off + len; - if (write_off + len >= Buf.Capacity) - { - int new_capacity = Buf.Capacity * 2; - Buf.reserve(needed_sz > new_capacity ? needed_sz : new_capacity); - } - - Buf.resize(needed_sz); - ImFormatStringV(&Buf[write_off - 1], (size_t)len + 1, fmt, args_copy); - va_end(args_copy); -} - -//----------------------------------------------------------------------------- -// [SECTION] ImGuiListClipper -// This is currently not as flexible/powerful as it should be and really confusing/spaghetti, mostly because we changed -// the API mid-way through development and support two ways to using the clipper, needs some rework (see TODO) -//----------------------------------------------------------------------------- - -// FIXME-TABLE: This prevents us from using ImGuiListClipper _inside_ a table cell. -// The problem we have is that without a Begin/End scheme for rows using the clipper is ambiguous. -static bool GetSkipItemForListClipping() -{ - ImGuiContext& g = *GImGui; - return (g.CurrentTable ? g.CurrentTable->HostSkipItems : g.CurrentWindow->SkipItems); -} - -// Helper to calculate coarse clipping of large list of evenly sized items. -// NB: Prefer using the ImGuiListClipper higher-level helper if you can! Read comments and instructions there on how those use this sort of pattern. -// NB: 'items_count' is only used to clamp the result, if you don't know your count you can use INT_MAX -void ImGui::CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - if (g.LogEnabled) - { - // If logging is active, do not perform any clipping - *out_items_display_start = 0; - *out_items_display_end = items_count; - return; - } - if (GetSkipItemForListClipping()) - { - *out_items_display_start = *out_items_display_end = 0; - return; - } - - // We create the union of the ClipRect and the scoring rect which at worst should be 1 page away from ClipRect - ImRect unclipped_rect = window->ClipRect; - if (g.NavMoveScoringItems) - unclipped_rect.Add(g.NavScoringRect); - if (g.NavJustMovedToId && window->NavLastIds[0] == g.NavJustMovedToId) - unclipped_rect.Add(ImRect(window->Pos + window->NavRectRel[0].Min, window->Pos + window->NavRectRel[0].Max)); // Could store and use NavJustMovedToRectRel - - const ImVec2 pos = window->DC.CursorPos; - int start = (int)((unclipped_rect.Min.y - pos.y) / items_height); - int end = (int)((unclipped_rect.Max.y - pos.y) / items_height); - - // When performing a navigation request, ensure we have one item extra in the direction we are moving to - if (g.NavMoveScoringItems && g.NavMoveClipDir == ImGuiDir_Up) - start--; - if (g.NavMoveScoringItems && g.NavMoveClipDir == ImGuiDir_Down) - end++; - - start = ImClamp(start, 0, items_count); - end = ImClamp(end + 1, start, items_count); - *out_items_display_start = start; - *out_items_display_end = end; -} - -static void SetCursorPosYAndSetupForPrevLine(float pos_y, float line_height) -{ - // Set cursor position and a few other things so that SetScrollHereY() and Columns() can work when seeking cursor. - // FIXME: It is problematic that we have to do that here, because custom/equivalent end-user code would stumble on the same issue. - // The clipper should probably have a 4th step to display the last item in a regular manner. - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - float off_y = pos_y - window->DC.CursorPos.y; - window->DC.CursorPos.y = pos_y; - window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, pos_y); - window->DC.CursorPosPrevLine.y = window->DC.CursorPos.y - line_height; // Setting those fields so that SetScrollHereY() can properly function after the end of our clipper usage. - window->DC.PrevLineSize.y = (line_height - g.Style.ItemSpacing.y); // If we end up needing more accurate data (to e.g. use SameLine) we may as well make the clipper have a fourth step to let user process and display the last item in their list. - if (ImGuiOldColumns* columns = window->DC.CurrentColumns) - columns->LineMinY = window->DC.CursorPos.y; // Setting this so that cell Y position are set properly - if (ImGuiTable* table = g.CurrentTable) - { - if (table->IsInsideRow) - ImGui::TableEndRow(table); - table->RowPosY2 = window->DC.CursorPos.y; - const int row_increase = (int)((off_y / line_height) + 0.5f); - //table->CurrentRow += row_increase; // Can't do without fixing TableEndRow() - table->RowBgColorCounter += row_increase; - } -} - -ImGuiListClipper::ImGuiListClipper() -{ - memset(this, 0, sizeof(*this)); - ItemsCount = -1; -} - -ImGuiListClipper::~ImGuiListClipper() -{ - IM_ASSERT(ItemsCount == -1 && "Forgot to call End(), or to Step() until false?"); -} - -// Use case A: Begin() called from constructor with items_height<0, then called again from Step() in StepNo 1 -// Use case B: Begin() called from constructor with items_height>0 -// FIXME-LEGACY: Ideally we should remove the Begin/End functions but they are part of the legacy API we still support. This is why some of the code in Step() calling Begin() and reassign some fields, spaghetti style. -void ImGuiListClipper::Begin(int items_count, float items_height) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - - if (ImGuiTable* table = g.CurrentTable) - if (table->IsInsideRow) - ImGui::TableEndRow(table); - - StartPosY = window->DC.CursorPos.y; - ItemsHeight = items_height; - ItemsCount = items_count; - ItemsFrozen = 0; - StepNo = 0; - DisplayStart = -1; - DisplayEnd = 0; -} - -void ImGuiListClipper::End() -{ - if (ItemsCount < 0) // Already ended - return; - - // In theory here we should assert that ImGui::GetCursorPosY() == StartPosY + DisplayEnd * ItemsHeight, but it feels saner to just seek at the end and not assert/crash the user. - if (ItemsCount < INT_MAX && DisplayStart >= 0) - SetCursorPosYAndSetupForPrevLine(StartPosY + (ItemsCount - ItemsFrozen) * ItemsHeight, ItemsHeight); - ItemsCount = -1; - StepNo = 3; -} - -bool ImGuiListClipper::Step() -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - - ImGuiTable* table = g.CurrentTable; - if (table && table->IsInsideRow) - ImGui::TableEndRow(table); - - // No items - if (ItemsCount == 0 || GetSkipItemForListClipping()) - { - End(); - return false; - } - - // Step 0: Let you process the first element (regardless of it being visible or not, so we can measure the element height) - if (StepNo == 0) - { - // While we are in frozen row state, keep displaying items one by one, unclipped - // FIXME: Could be stored as a table-agnostic state. - if (table != NULL && !table->IsUnfrozenRows) - { - DisplayStart = ItemsFrozen; - DisplayEnd = ItemsFrozen + 1; - ItemsFrozen++; - return true; - } - - StartPosY = window->DC.CursorPos.y; - if (ItemsHeight <= 0.0f) - { - // Submit the first item so we can measure its height (generally it is 0..1) - DisplayStart = ItemsFrozen; - DisplayEnd = ItemsFrozen + 1; - StepNo = 1; - return true; - } - - // Already has item height (given by user in Begin): skip to calculating step - DisplayStart = DisplayEnd; - StepNo = 2; - } - - // Step 1: the clipper infer height from first element - if (StepNo == 1) - { - IM_ASSERT(ItemsHeight <= 0.0f); - if (table) - { - const float pos_y1 = table->RowPosY1; // Using this instead of StartPosY to handle clipper straddling the frozen row - const float pos_y2 = table->RowPosY2; // Using this instead of CursorPos.y to take account of tallest cell. - ItemsHeight = pos_y2 - pos_y1; - window->DC.CursorPos.y = pos_y2; - } - else - { - ItemsHeight = window->DC.CursorPos.y - StartPosY; - } - IM_ASSERT(ItemsHeight > 0.0f && "Unable to calculate item height! First item hasn't moved the cursor vertically!"); - StepNo = 2; - } - - // Reached end of list - if (DisplayEnd >= ItemsCount) - { - End(); - return false; - } - - // Step 2: calculate the actual range of elements to display, and position the cursor before the first element - if (StepNo == 2) - { - IM_ASSERT(ItemsHeight > 0.0f); - - int already_submitted = DisplayEnd; - ImGui::CalcListClipping(ItemsCount - already_submitted, ItemsHeight, &DisplayStart, &DisplayEnd); - DisplayStart += already_submitted; - DisplayEnd += already_submitted; - - // Seek cursor - if (DisplayStart > already_submitted) - SetCursorPosYAndSetupForPrevLine(StartPosY + (DisplayStart - ItemsFrozen) * ItemsHeight, ItemsHeight); - - StepNo = 3; - return true; - } - - // Step 3: the clipper validate that we have reached the expected Y position (corresponding to element DisplayEnd), - // Advance the cursor to the end of the list and then returns 'false' to end the loop. - if (StepNo == 3) - { - // Seek cursor - if (ItemsCount < INT_MAX) - SetCursorPosYAndSetupForPrevLine(StartPosY + (ItemsCount - ItemsFrozen) * ItemsHeight, ItemsHeight); // advance cursor - ItemsCount = -1; - return false; - } - - IM_ASSERT(0); - return false; -} - -//----------------------------------------------------------------------------- -// [SECTION] STYLING -//----------------------------------------------------------------------------- - -ImGuiStyle& ImGui::GetStyle() -{ - IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?"); - return GImGui->Style; -} - -ImU32 ImGui::GetColorU32(ImGuiCol idx, float alpha_mul) -{ - ImGuiStyle& style = GImGui->Style; - ImVec4 c = style.Colors[idx]; - c.w *= style.Alpha * alpha_mul; - return ColorConvertFloat4ToU32(c); -} - -ImU32 ImGui::GetColorU32(const ImVec4& col) -{ - ImGuiStyle& style = GImGui->Style; - ImVec4 c = col; - c.w *= style.Alpha; - return ColorConvertFloat4ToU32(c); -} - -const ImVec4& ImGui::GetStyleColorVec4(ImGuiCol idx) -{ - ImGuiStyle& style = GImGui->Style; - return style.Colors[idx]; -} - -ImU32 ImGui::GetColorU32(ImU32 col) -{ - ImGuiStyle& style = GImGui->Style; - if (style.Alpha >= 1.0f) - return col; - ImU32 a = (col & IM_COL32_A_MASK) >> IM_COL32_A_SHIFT; - a = (ImU32)(a * style.Alpha); // We don't need to clamp 0..255 because Style.Alpha is in 0..1 range. - return (col & ~IM_COL32_A_MASK) | (a << IM_COL32_A_SHIFT); -} - -// FIXME: This may incur a round-trip (if the end user got their data from a float4) but eventually we aim to store the in-flight colors as ImU32 -void ImGui::PushStyleColor(ImGuiCol idx, ImU32 col) -{ - ImGuiContext& g = *GImGui; - ImGuiColorMod backup; - backup.Col = idx; - backup.BackupValue = g.Style.Colors[idx]; - g.ColorStack.push_back(backup); - g.Style.Colors[idx] = ColorConvertU32ToFloat4(col); -} - -void ImGui::PushStyleColor(ImGuiCol idx, const ImVec4& col) -{ - ImGuiContext& g = *GImGui; - ImGuiColorMod backup; - backup.Col = idx; - backup.BackupValue = g.Style.Colors[idx]; - g.ColorStack.push_back(backup); - g.Style.Colors[idx] = col; -} - -void ImGui::PopStyleColor(int count) -{ - ImGuiContext& g = *GImGui; - while (count > 0) - { - ImGuiColorMod& backup = g.ColorStack.back(); - g.Style.Colors[backup.Col] = backup.BackupValue; - g.ColorStack.pop_back(); - count--; - } -} - -struct ImGuiStyleVarInfo -{ - ImGuiDataType Type; - ImU32 Count; - ImU32 Offset; - void* GetVarPtr(ImGuiStyle* style) const { return (void*)((unsigned char*)style + Offset); } -}; - -static const ImGuiStyleVarInfo GStyleVarInfo[] = -{ - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, Alpha) }, // ImGuiStyleVar_Alpha - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, DisabledAlpha) }, // ImGuiStyleVar_DisabledAlpha - { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowPadding) }, // ImGuiStyleVar_WindowPadding - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowRounding) }, // ImGuiStyleVar_WindowRounding - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowBorderSize) }, // ImGuiStyleVar_WindowBorderSize - { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowMinSize) }, // ImGuiStyleVar_WindowMinSize - { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowTitleAlign) }, // ImGuiStyleVar_WindowTitleAlign - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildRounding) }, // ImGuiStyleVar_ChildRounding - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildBorderSize) }, // ImGuiStyleVar_ChildBorderSize - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, PopupRounding) }, // ImGuiStyleVar_PopupRounding - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, PopupBorderSize) }, // ImGuiStyleVar_PopupBorderSize - { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, FramePadding) }, // ImGuiStyleVar_FramePadding - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameRounding) }, // ImGuiStyleVar_FrameRounding - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameBorderSize) }, // ImGuiStyleVar_FrameBorderSize - { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemSpacing) }, // ImGuiStyleVar_ItemSpacing - { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemInnerSpacing) }, // ImGuiStyleVar_ItemInnerSpacing - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, IndentSpacing) }, // ImGuiStyleVar_IndentSpacing - { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, CellPadding) }, // ImGuiStyleVar_CellPadding - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ScrollbarSize) }, // ImGuiStyleVar_ScrollbarSize - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ScrollbarRounding) }, // ImGuiStyleVar_ScrollbarRounding - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabMinSize) }, // ImGuiStyleVar_GrabMinSize - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabRounding) }, // ImGuiStyleVar_GrabRounding - { ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, TabRounding) }, // ImGuiStyleVar_TabRounding - { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ButtonTextAlign) }, // ImGuiStyleVar_ButtonTextAlign - { ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, SelectableTextAlign) }, // ImGuiStyleVar_SelectableTextAlign -}; - -static const ImGuiStyleVarInfo* GetStyleVarInfo(ImGuiStyleVar idx) -{ - IM_ASSERT(idx >= 0 && idx < ImGuiStyleVar_COUNT); - IM_ASSERT(IM_ARRAYSIZE(GStyleVarInfo) == ImGuiStyleVar_COUNT); - return &GStyleVarInfo[idx]; -} - -void ImGui::PushStyleVar(ImGuiStyleVar idx, float val) -{ - const ImGuiStyleVarInfo* var_info = GetStyleVarInfo(idx); - if (var_info->Type == ImGuiDataType_Float && var_info->Count == 1) - { - ImGuiContext& g = *GImGui; - float* pvar = (float*)var_info->GetVarPtr(&g.Style); - g.StyleVarStack.push_back(ImGuiStyleMod(idx, *pvar)); - *pvar = val; - return; - } - IM_ASSERT(0 && "Called PushStyleVar() float variant but variable is not a float!"); -} - -void ImGui::PushStyleVar(ImGuiStyleVar idx, const ImVec2& val) -{ - const ImGuiStyleVarInfo* var_info = GetStyleVarInfo(idx); - if (var_info->Type == ImGuiDataType_Float && var_info->Count == 2) - { - ImGuiContext& g = *GImGui; - ImVec2* pvar = (ImVec2*)var_info->GetVarPtr(&g.Style); - g.StyleVarStack.push_back(ImGuiStyleMod(idx, *pvar)); - *pvar = val; - return; - } - IM_ASSERT(0 && "Called PushStyleVar() ImVec2 variant but variable is not a ImVec2!"); -} - -void ImGui::PopStyleVar(int count) -{ - ImGuiContext& g = *GImGui; - while (count > 0) - { - // We avoid a generic memcpy(data, &backup.Backup.., GDataTypeSize[info->Type] * info->Count), the overhead in Debug is not worth it. - ImGuiStyleMod& backup = g.StyleVarStack.back(); - const ImGuiStyleVarInfo* info = GetStyleVarInfo(backup.VarIdx); - void* data = info->GetVarPtr(&g.Style); - if (info->Type == ImGuiDataType_Float && info->Count == 1) { ((float*)data)[0] = backup.BackupFloat[0]; } - else if (info->Type == ImGuiDataType_Float && info->Count == 2) { ((float*)data)[0] = backup.BackupFloat[0]; ((float*)data)[1] = backup.BackupFloat[1]; } - g.StyleVarStack.pop_back(); - count--; - } -} - -const char* ImGui::GetStyleColorName(ImGuiCol idx) -{ - // Create switch-case from enum with regexp: ImGuiCol_{.*}, --> case ImGuiCol_\1: return "\1"; - switch (idx) - { - case ImGuiCol_Text: return "Text"; - case ImGuiCol_TextDisabled: return "TextDisabled"; - case ImGuiCol_WindowBg: return "WindowBg"; - case ImGuiCol_ChildBg: return "ChildBg"; - case ImGuiCol_PopupBg: return "PopupBg"; - case ImGuiCol_Border: return "Border"; - case ImGuiCol_BorderShadow: return "BorderShadow"; - case ImGuiCol_FrameBg: return "FrameBg"; - case ImGuiCol_FrameBgHovered: return "FrameBgHovered"; - case ImGuiCol_FrameBgActive: return "FrameBgActive"; - case ImGuiCol_TitleBg: return "TitleBg"; - case ImGuiCol_TitleBgActive: return "TitleBgActive"; - case ImGuiCol_TitleBgCollapsed: return "TitleBgCollapsed"; - case ImGuiCol_MenuBarBg: return "MenuBarBg"; - case ImGuiCol_ScrollbarBg: return "ScrollbarBg"; - case ImGuiCol_ScrollbarGrab: return "ScrollbarGrab"; - case ImGuiCol_ScrollbarGrabHovered: return "ScrollbarGrabHovered"; - case ImGuiCol_ScrollbarGrabActive: return "ScrollbarGrabActive"; - case ImGuiCol_CheckMark: return "CheckMark"; - case ImGuiCol_SliderGrab: return "SliderGrab"; - case ImGuiCol_SliderGrabActive: return "SliderGrabActive"; - case ImGuiCol_Button: return "Button"; - case ImGuiCol_ButtonHovered: return "ButtonHovered"; - case ImGuiCol_ButtonActive: return "ButtonActive"; - case ImGuiCol_Header: return "Header"; - case ImGuiCol_HeaderHovered: return "HeaderHovered"; - case ImGuiCol_HeaderActive: return "HeaderActive"; - case ImGuiCol_Separator: return "Separator"; - case ImGuiCol_SeparatorHovered: return "SeparatorHovered"; - case ImGuiCol_SeparatorActive: return "SeparatorActive"; - case ImGuiCol_ResizeGrip: return "ResizeGrip"; - case ImGuiCol_ResizeGripHovered: return "ResizeGripHovered"; - case ImGuiCol_ResizeGripActive: return "ResizeGripActive"; - case ImGuiCol_Tab: return "Tab"; - case ImGuiCol_TabHovered: return "TabHovered"; - case ImGuiCol_TabActive: return "TabActive"; - case ImGuiCol_TabUnfocused: return "TabUnfocused"; - case ImGuiCol_TabUnfocusedActive: return "TabUnfocusedActive"; - case ImGuiCol_PlotLines: return "PlotLines"; - case ImGuiCol_PlotLinesHovered: return "PlotLinesHovered"; - case ImGuiCol_PlotHistogram: return "PlotHistogram"; - case ImGuiCol_PlotHistogramHovered: return "PlotHistogramHovered"; - case ImGuiCol_TableHeaderBg: return "TableHeaderBg"; - case ImGuiCol_TableBorderStrong: return "TableBorderStrong"; - case ImGuiCol_TableBorderLight: return "TableBorderLight"; - case ImGuiCol_TableRowBg: return "TableRowBg"; - case ImGuiCol_TableRowBgAlt: return "TableRowBgAlt"; - case ImGuiCol_TextSelectedBg: return "TextSelectedBg"; - case ImGuiCol_DragDropTarget: return "DragDropTarget"; - case ImGuiCol_NavHighlight: return "NavHighlight"; - case ImGuiCol_NavWindowingHighlight: return "NavWindowingHighlight"; - case ImGuiCol_NavWindowingDimBg: return "NavWindowingDimBg"; - case ImGuiCol_ModalWindowDimBg: return "ModalWindowDimBg"; - } - IM_ASSERT(0); - return "Unknown"; -} - - -//----------------------------------------------------------------------------- -// [SECTION] RENDER HELPERS -// Some of those (internal) functions are currently quite a legacy mess - their signature and behavior will change, -// we need a nicer separation between low-level functions and high-level functions relying on the ImGui context. -// Also see imgui_draw.cpp for some more which have been reworked to not rely on ImGui:: context. -//----------------------------------------------------------------------------- - -const char* ImGui::FindRenderedTextEnd(const char* text, const char* text_end) -{ - const char* text_display_end = text; - if (!text_end) - text_end = (const char*)-1; - - while (text_display_end < text_end && *text_display_end != '\0' && (text_display_end[0] != '#' || text_display_end[1] != '#')) - text_display_end++; - return text_display_end; -} - -// Internal ImGui functions to render text -// RenderText***() functions calls ImDrawList::AddText() calls ImBitmapFont::RenderText() -void ImGui::RenderText(ImVec2 pos, const char* text, const char* text_end, bool hide_text_after_hash) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - - // Hide anything after a '##' string - const char* text_display_end; - if (hide_text_after_hash) - { - text_display_end = FindRenderedTextEnd(text, text_end); - } - else - { - if (!text_end) - text_end = text + strlen(text); // FIXME-OPT - text_display_end = text_end; - } - - if (text != text_display_end) - { - window->DrawList->AddText(g.Font, g.FontSize, pos, GetColorU32(ImGuiCol_Text), text, text_display_end); - if (g.LogEnabled) - LogRenderedText(&pos, text, text_display_end); - } -} - -void ImGui::RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - - if (!text_end) - text_end = text + strlen(text); // FIXME-OPT - - if (text != text_end) - { - window->DrawList->AddText(g.Font, g.FontSize, pos, GetColorU32(ImGuiCol_Text), text, text_end, wrap_width); - if (g.LogEnabled) - LogRenderedText(&pos, text, text_end); - } -} - -// Default clip_rect uses (pos_min,pos_max) -// Handle clipping on CPU immediately (vs typically let the GPU clip the triangles that are overlapping the clipping rectangle edges) -void ImGui::RenderTextClippedEx(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_display_end, const ImVec2* text_size_if_known, const ImVec2& align, const ImRect* clip_rect) -{ - // Perform CPU side clipping for single clipped element to avoid using scissor state - ImVec2 pos = pos_min; - const ImVec2 text_size = text_size_if_known ? *text_size_if_known : CalcTextSize(text, text_display_end, false, 0.0f); - - const ImVec2* clip_min = clip_rect ? &clip_rect->Min : &pos_min; - const ImVec2* clip_max = clip_rect ? &clip_rect->Max : &pos_max; - bool need_clipping = (pos.x + text_size.x >= clip_max->x) || (pos.y + text_size.y >= clip_max->y); - if (clip_rect) // If we had no explicit clipping rectangle then pos==clip_min - need_clipping |= (pos.x < clip_min->x) || (pos.y < clip_min->y); - - // Align whole block. We should defer that to the better rendering function when we'll have support for individual line alignment. - if (align.x > 0.0f) pos.x = ImMax(pos.x, pos.x + (pos_max.x - pos.x - text_size.x) * align.x); - if (align.y > 0.0f) pos.y = ImMax(pos.y, pos.y + (pos_max.y - pos.y - text_size.y) * align.y); - - // Render - if (need_clipping) - { - ImVec4 fine_clip_rect(clip_min->x, clip_min->y, clip_max->x, clip_max->y); - draw_list->AddText(NULL, 0.0f, pos, GetColorU32(ImGuiCol_Text), text, text_display_end, 0.0f, &fine_clip_rect); - } - else - { - draw_list->AddText(NULL, 0.0f, pos, GetColorU32(ImGuiCol_Text), text, text_display_end, 0.0f, NULL); - } -} - -void ImGui::RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align, const ImRect* clip_rect) -{ - // Hide anything after a '##' string - const char* text_display_end = FindRenderedTextEnd(text, text_end); - const int text_len = (int)(text_display_end - text); - if (text_len == 0) - return; - - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - RenderTextClippedEx(window->DrawList, pos_min, pos_max, text, text_display_end, text_size_if_known, align, clip_rect); - if (g.LogEnabled) - LogRenderedText(&pos_min, text, text_display_end); -} - - -// Another overly complex function until we reorganize everything into a nice all-in-one helper. -// This is made more complex because we have dissociated the layout rectangle (pos_min..pos_max) which define _where_ the ellipsis is, from actual clipping of text and limit of the ellipsis display. -// This is because in the context of tabs we selectively hide part of the text when the Close Button appears, but we don't want the ellipsis to move. -void ImGui::RenderTextEllipsis(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, float clip_max_x, float ellipsis_max_x, const char* text, const char* text_end_full, const ImVec2* text_size_if_known) -{ - ImGuiContext& g = *GImGui; - if (text_end_full == NULL) - text_end_full = FindRenderedTextEnd(text); - const ImVec2 text_size = text_size_if_known ? *text_size_if_known : CalcTextSize(text, text_end_full, false, 0.0f); - - //draw_list->AddLine(ImVec2(pos_max.x, pos_min.y - 4), ImVec2(pos_max.x, pos_max.y + 4), IM_COL32(0, 0, 255, 255)); - //draw_list->AddLine(ImVec2(ellipsis_max_x, pos_min.y-2), ImVec2(ellipsis_max_x, pos_max.y+2), IM_COL32(0, 255, 0, 255)); - //draw_list->AddLine(ImVec2(clip_max_x, pos_min.y), ImVec2(clip_max_x, pos_max.y), IM_COL32(255, 0, 0, 255)); - // FIXME: We could technically remove (last_glyph->AdvanceX - last_glyph->X1) from text_size.x here and save a few pixels. - if (text_size.x > pos_max.x - pos_min.x) - { - // Hello wo... - // | | | - // min max ellipsis_max - // <-> this is generally some padding value - - const ImFont* font = draw_list->_Data->Font; - const float font_size = draw_list->_Data->FontSize; - const char* text_end_ellipsis = NULL; - - ImWchar ellipsis_char = font->EllipsisChar; - int ellipsis_char_count = 1; - if (ellipsis_char == (ImWchar)-1) - { - ellipsis_char = font->DotChar; - ellipsis_char_count = 3; - } - const ImFontGlyph* glyph = font->FindGlyph(ellipsis_char); - - float ellipsis_glyph_width = glyph->X1; // Width of the glyph with no padding on either side - float ellipsis_total_width = ellipsis_glyph_width; // Full width of entire ellipsis - - if (ellipsis_char_count > 1) - { - // Full ellipsis size without free spacing after it. - const float spacing_between_dots = 1.0f * (draw_list->_Data->FontSize / font->FontSize); - ellipsis_glyph_width = glyph->X1 - glyph->X0 + spacing_between_dots; - ellipsis_total_width = ellipsis_glyph_width * (float)ellipsis_char_count - spacing_between_dots; - } - - // We can now claim the space between pos_max.x and ellipsis_max.x - const float text_avail_width = ImMax((ImMax(pos_max.x, ellipsis_max_x) - ellipsis_total_width) - pos_min.x, 1.0f); - float text_size_clipped_x = font->CalcTextSizeA(font_size, text_avail_width, 0.0f, text, text_end_full, &text_end_ellipsis).x; - if (text == text_end_ellipsis && text_end_ellipsis < text_end_full) - { - // Always display at least 1 character if there's no room for character + ellipsis - text_end_ellipsis = text + ImTextCountUtf8BytesFromChar(text, text_end_full); - text_size_clipped_x = font->CalcTextSizeA(font_size, FLT_MAX, 0.0f, text, text_end_ellipsis).x; - } - while (text_end_ellipsis > text && ImCharIsBlankA(text_end_ellipsis[-1])) - { - // Trim trailing space before ellipsis (FIXME: Supporting non-ascii blanks would be nice, for this we need a function to backtrack in UTF-8 text) - text_end_ellipsis--; - text_size_clipped_x -= font->CalcTextSizeA(font_size, FLT_MAX, 0.0f, text_end_ellipsis, text_end_ellipsis + 1).x; // Ascii blanks are always 1 byte - } - - // Render text, render ellipsis - RenderTextClippedEx(draw_list, pos_min, ImVec2(clip_max_x, pos_max.y), text, text_end_ellipsis, &text_size, ImVec2(0.0f, 0.0f)); - float ellipsis_x = pos_min.x + text_size_clipped_x; - if (ellipsis_x + ellipsis_total_width <= ellipsis_max_x) - for (int i = 0; i < ellipsis_char_count; i++) - { - font->RenderChar(draw_list, font_size, ImVec2(ellipsis_x, pos_min.y), GetColorU32(ImGuiCol_Text), ellipsis_char); - ellipsis_x += ellipsis_glyph_width; - } - } - else - { - RenderTextClippedEx(draw_list, pos_min, ImVec2(clip_max_x, pos_max.y), text, text_end_full, &text_size, ImVec2(0.0f, 0.0f)); - } - - if (g.LogEnabled) - LogRenderedText(&pos_min, text, text_end_full); -} - -// Render a rectangle shaped with optional rounding and borders -void ImGui::RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border, float rounding) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - window->DrawList->AddRectFilled(p_min, p_max, fill_col, rounding); - const float border_size = g.Style.FrameBorderSize; - if (border && border_size > 0.0f) - { - window->DrawList->AddRect(p_min + ImVec2(1, 1), p_max + ImVec2(1, 1), GetColorU32(ImGuiCol_BorderShadow), rounding, 0, border_size); - window->DrawList->AddRect(p_min, p_max, GetColorU32(ImGuiCol_Border), rounding, 0, border_size); - } -} - -void ImGui::RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - const float border_size = g.Style.FrameBorderSize; - if (border_size > 0.0f) - { - window->DrawList->AddRect(p_min + ImVec2(1, 1), p_max + ImVec2(1, 1), GetColorU32(ImGuiCol_BorderShadow), rounding, 0, border_size); - window->DrawList->AddRect(p_min, p_max, GetColorU32(ImGuiCol_Border), rounding, 0, border_size); - } -} - -void ImGui::RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFlags flags) -{ - ImGuiContext& g = *GImGui; - if (id != g.NavId) - return; - if (g.NavDisableHighlight && !(flags & ImGuiNavHighlightFlags_AlwaysDraw)) - return; - ImGuiWindow* window = g.CurrentWindow; - if (window->DC.NavHideHighlightOneFrame) - return; - - float rounding = (flags & ImGuiNavHighlightFlags_NoRounding) ? 0.0f : g.Style.FrameRounding; - ImRect display_rect = bb; - display_rect.ClipWith(window->ClipRect); - if (flags & ImGuiNavHighlightFlags_TypeDefault) - { - const float THICKNESS = 2.0f; - const float DISTANCE = 3.0f + THICKNESS * 0.5f; - display_rect.Expand(ImVec2(DISTANCE, DISTANCE)); - bool fully_visible = window->ClipRect.Contains(display_rect); - if (!fully_visible) - window->DrawList->PushClipRect(display_rect.Min, display_rect.Max); - window->DrawList->AddRect(display_rect.Min + ImVec2(THICKNESS * 0.5f, THICKNESS * 0.5f), display_rect.Max - ImVec2(THICKNESS * 0.5f, THICKNESS * 0.5f), GetColorU32(ImGuiCol_NavHighlight), rounding, 0, THICKNESS); - if (!fully_visible) - window->DrawList->PopClipRect(); - } - if (flags & ImGuiNavHighlightFlags_TypeThin) - { - window->DrawList->AddRect(display_rect.Min, display_rect.Max, GetColorU32(ImGuiCol_NavHighlight), rounding, 0, 1.0f); - } -} - -//----------------------------------------------------------------------------- -// [SECTION] MAIN CODE (most of the code! lots of stuff, needs tidying up!) -//----------------------------------------------------------------------------- - -// ImGuiWindow is mostly a dumb struct. It merely has a constructor and a few helper methods -ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name) : DrawListInst(NULL) -{ - memset(this, 0, sizeof(*this)); - Name = ImStrdup(name); - NameBufLen = (int)strlen(name) + 1; - ID = ImHashStr(name); - IDStack.push_back(ID); - MoveId = GetID("#MOVE"); - ScrollTarget = ImVec2(FLT_MAX, FLT_MAX); - ScrollTargetCenterRatio = ImVec2(0.5f, 0.5f); - AutoFitFramesX = AutoFitFramesY = -1; - AutoPosLastDirection = ImGuiDir_None; - SetWindowPosAllowFlags = SetWindowSizeAllowFlags = SetWindowCollapsedAllowFlags = ImGuiCond_Always | ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing; - SetWindowPosVal = SetWindowPosPivot = ImVec2(FLT_MAX, FLT_MAX); - LastFrameActive = -1; - LastTimeActive = -1.0f; - FontWindowScale = 1.0f; - SettingsOffset = -1; - DrawList = &DrawListInst; - DrawList->_Data = &context->DrawListSharedData; - DrawList->_OwnerName = Name; -} - -ImGuiWindow::~ImGuiWindow() -{ - IM_ASSERT(DrawList == &DrawListInst); - IM_DELETE(Name); - ColumnsStorage.clear_destruct(); -} - -ImGuiID ImGuiWindow::GetID(const char* str, const char* str_end) -{ - ImGuiID seed = IDStack.back(); - ImGuiID id = ImHashStr(str, str_end ? (str_end - str) : 0, seed); - ImGui::KeepAliveID(id); - ImGuiContext& g = *GImGui; - if (g.DebugHookIdInfo == id) - ImGui::DebugHookIdInfo(id, ImGuiDataType_String, str, str_end); - return id; -} - -ImGuiID ImGuiWindow::GetID(const void* ptr) -{ - ImGuiID seed = IDStack.back(); - ImGuiID id = ImHashData(&ptr, sizeof(void*), seed); - ImGui::KeepAliveID(id); - ImGuiContext& g = *GImGui; - if (g.DebugHookIdInfo == id) - ImGui::DebugHookIdInfo(id, ImGuiDataType_Pointer, ptr, NULL); - return id; -} - -ImGuiID ImGuiWindow::GetID(int n) -{ - ImGuiID seed = IDStack.back(); - ImGuiID id = ImHashData(&n, sizeof(n), seed); - ImGui::KeepAliveID(id); - ImGuiContext& g = *GImGui; - if (g.DebugHookIdInfo == id) - ImGui::DebugHookIdInfo(id, ImGuiDataType_S32, (void*)(intptr_t)n, NULL); - return id; -} - -ImGuiID ImGuiWindow::GetIDNoKeepAlive(const char* str, const char* str_end) -{ - ImGuiID seed = IDStack.back(); - ImGuiID id = ImHashStr(str, str_end ? (str_end - str) : 0, seed); - ImGuiContext& g = *GImGui; - if (g.DebugHookIdInfo == id) - ImGui::DebugHookIdInfo(id, ImGuiDataType_String, str, str_end); - return id; -} - -ImGuiID ImGuiWindow::GetIDNoKeepAlive(const void* ptr) -{ - ImGuiID seed = IDStack.back(); - ImGuiID id = ImHashData(&ptr, sizeof(void*), seed); - ImGuiContext& g = *GImGui; - if (g.DebugHookIdInfo == id) - ImGui::DebugHookIdInfo(id, ImGuiDataType_Pointer, ptr, NULL); - return id; -} - -ImGuiID ImGuiWindow::GetIDNoKeepAlive(int n) -{ - ImGuiID seed = IDStack.back(); - ImGuiID id = ImHashData(&n, sizeof(n), seed); - ImGuiContext& g = *GImGui; - if (g.DebugHookIdInfo == id) - ImGui::DebugHookIdInfo(id, ImGuiDataType_S32, (void*)(intptr_t)n, NULL); - return id; -} - -// This is only used in rare/specific situations to manufacture an ID out of nowhere. -ImGuiID ImGuiWindow::GetIDFromRectangle(const ImRect& r_abs) -{ - ImGuiID seed = IDStack.back(); - const int r_rel[4] = { (int)(r_abs.Min.x - Pos.x), (int)(r_abs.Min.y - Pos.y), (int)(r_abs.Max.x - Pos.x), (int)(r_abs.Max.y - Pos.y) }; - ImGuiID id = ImHashData(&r_rel, sizeof(r_rel), seed); - ImGui::KeepAliveID(id); - return id; -} - -static void SetCurrentWindow(ImGuiWindow* window) -{ - ImGuiContext& g = *GImGui; - g.CurrentWindow = window; - g.CurrentTable = window && window->DC.CurrentTableIdx != -1 ? g.Tables.GetByIndex(window->DC.CurrentTableIdx) : NULL; - if (window) - g.FontSize = g.DrawListSharedData.FontSize = window->CalcFontSize(); -} - -void ImGui::GcCompactTransientMiscBuffers() -{ - ImGuiContext& g = *GImGui; - g.ItemFlagsStack.clear(); - g.GroupStack.clear(); - TableGcCompactSettings(); -} - -// Free up/compact internal window buffers, we can use this when a window becomes unused. -// Not freed: -// - ImGuiWindow, ImGuiWindowSettings, Name, StateStorage, ColumnsStorage (may hold useful data) -// This should have no noticeable visual effect. When the window reappear however, expect new allocation/buffer growth/copy cost. -void ImGui::GcCompactTransientWindowBuffers(ImGuiWindow* window) -{ - window->MemoryCompacted = true; - window->MemoryDrawListIdxCapacity = window->DrawList->IdxBuffer.Capacity; - window->MemoryDrawListVtxCapacity = window->DrawList->VtxBuffer.Capacity; - window->IDStack.clear(); - window->DrawList->_ClearFreeMemory(); - window->DC.ChildWindows.clear(); - window->DC.ItemWidthStack.clear(); - window->DC.TextWrapPosStack.clear(); -} - -void ImGui::GcAwakeTransientWindowBuffers(ImGuiWindow* window) -{ - // We stored capacity of the ImDrawList buffer to reduce growth-caused allocation/copy when awakening. - // The other buffers tends to amortize much faster. - window->MemoryCompacted = false; - window->DrawList->IdxBuffer.reserve(window->MemoryDrawListIdxCapacity); - window->DrawList->VtxBuffer.reserve(window->MemoryDrawListVtxCapacity); - window->MemoryDrawListIdxCapacity = window->MemoryDrawListVtxCapacity = 0; -} - -void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window) -{ - ImGuiContext& g = *GImGui; - g.ActiveIdIsJustActivated = (g.ActiveId != id); - if (g.ActiveIdIsJustActivated) - { - g.ActiveIdTimer = 0.0f; - g.ActiveIdHasBeenPressedBefore = false; - g.ActiveIdHasBeenEditedBefore = false; - g.ActiveIdMouseButton = -1; - if (id != 0) - { - g.LastActiveId = id; - g.LastActiveIdTimer = 0.0f; - } - } - g.ActiveId = id; - g.ActiveIdAllowOverlap = false; - g.ActiveIdNoClearOnFocusLoss = false; - g.ActiveIdWindow = window; - g.ActiveIdHasBeenEditedThisFrame = false; - if (id) - { - g.ActiveIdIsAlive = id; - g.ActiveIdSource = (g.NavActivateId == id || g.NavActivateInputId == id || g.NavJustTabbedId == id || g.NavJustMovedToId == id) ? ImGuiInputSource_Nav : ImGuiInputSource_Mouse; - } - - // Clear declaration of inputs claimed by the widget - // (Please note that this is WIP and not all keys/inputs are thoroughly declared by all widgets yet) - g.ActiveIdUsingMouseWheel = false; - g.ActiveIdUsingNavDirMask = 0x00; - g.ActiveIdUsingNavInputMask = 0x00; - g.ActiveIdUsingKeyInputMask = 0x00; -} - -void ImGui::ClearActiveID() -{ - SetActiveID(0, NULL); // g.ActiveId = 0; -} - -void ImGui::SetHoveredID(ImGuiID id) -{ - ImGuiContext& g = *GImGui; - g.HoveredId = id; - g.HoveredIdAllowOverlap = false; - g.HoveredIdUsingMouseWheel = false; - if (id != 0 && g.HoveredIdPreviousFrame != id) - g.HoveredIdTimer = g.HoveredIdNotActiveTimer = 0.0f; -} - -ImGuiID ImGui::GetHoveredID() -{ - ImGuiContext& g = *GImGui; - return g.HoveredId ? g.HoveredId : g.HoveredIdPreviousFrame; -} - -void ImGui::KeepAliveID(ImGuiID id) -{ - ImGuiContext& g = *GImGui; - if (g.ActiveId == id) - g.ActiveIdIsAlive = id; - if (g.ActiveIdPreviousFrame == id) - g.ActiveIdPreviousFrameIsAlive = true; -} - -void ImGui::MarkItemEdited(ImGuiID id) -{ - // This marking is solely to be able to provide info for IsItemDeactivatedAfterEdit(). - // ActiveId might have been released by the time we call this (as in the typical press/release button behavior) but still need need to fill the data. - ImGuiContext& g = *GImGui; - IM_ASSERT(g.ActiveId == id || g.ActiveId == 0 || g.DragDropActive); - IM_UNUSED(id); // Avoid unused variable warnings when asserts are compiled out. - //IM_ASSERT(g.CurrentWindow->DC.LastItemId == id); - g.ActiveIdHasBeenEditedThisFrame = true; - g.ActiveIdHasBeenEditedBefore = true; - g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_Edited; -} - -static inline bool IsWindowContentHoverable(ImGuiWindow* window, ImGuiHoveredFlags flags) -{ - // An active popup disable hovering on other windows (apart from its own children) - // FIXME-OPT: This could be cached/stored within the window. - ImGuiContext& g = *GImGui; - if (g.NavWindow) - if (ImGuiWindow* focused_root_window = g.NavWindow->RootWindow) - if (focused_root_window->WasActive && focused_root_window != window->RootWindow) - { - // For the purpose of those flags we differentiate "standard popup" from "modal popup" - // NB: The order of those two tests is important because Modal windows are also Popups. - if (focused_root_window->Flags & ImGuiWindowFlags_Modal) - return false; - if ((focused_root_window->Flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiHoveredFlags_AllowWhenBlockedByPopup)) - return false; - } - return true; -} - -// This is roughly matching the behavior of internal-facing ItemHoverable() -// - we allow hovering to be true when ActiveId==window->MoveID, so that clicking on non-interactive items such as a Text() item still returns true with IsItemHovered() -// - this should work even for non-interactive items that have no ID, so we cannot use LastItemId -bool ImGui::IsItemHovered(ImGuiHoveredFlags flags) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - if (g.NavDisableMouseHover && !g.NavDisableHighlight) - { - if ((g.LastItemData.InFlags & ImGuiItemFlags_Disabled) && !(flags & ImGuiHoveredFlags_AllowWhenDisabled)) - return false; - return IsItemFocused(); - } - - // Test for bounding box overlap, as updated as ItemAdd() - ImGuiItemStatusFlags status_flags = g.LastItemData.StatusFlags; - if (!(status_flags & ImGuiItemStatusFlags_HoveredRect)) - return false; - IM_ASSERT((flags & (ImGuiHoveredFlags_AnyWindow | ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_NoPopupHierarchy)) == 0); // Flags not supported by this function - - // Test if we are hovering the right window (our window could be behind another window) - // [2021/03/02] Reworked / reverted the revert, finally. Note we want e.g. BeginGroup/ItemAdd/EndGroup to work as well. (#3851) - // [2017/10/16] Reverted commit 344d48be3 and testing RootWindow instead. I believe it is correct to NOT test for RootWindow but this leaves us unable - // to use IsItemHovered() after EndChild() itself. Until a solution is found I believe reverting to the test from 2017/09/27 is safe since this was - // the test that has been running for a long while. - if (g.HoveredWindow != window && (status_flags & ImGuiItemStatusFlags_HoveredWindow) == 0) - if ((flags & ImGuiHoveredFlags_AllowWhenOverlapped) == 0) - return false; - - // Test if another item is active (e.g. being dragged) - if ((flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem) == 0) - if (g.ActiveId != 0 && g.ActiveId != g.LastItemData.ID && !g.ActiveIdAllowOverlap && g.ActiveId != window->MoveId) - return false; - - // Test if interactions on this window are blocked by an active popup or modal. - // The ImGuiHoveredFlags_AllowWhenBlockedByPopup flag will be tested here. - if (!IsWindowContentHoverable(window, flags)) - return false; - - // Test if the item is disabled - if ((g.LastItemData.InFlags & ImGuiItemFlags_Disabled) && !(flags & ImGuiHoveredFlags_AllowWhenDisabled)) - return false; - - // Special handling for calling after Begin() which represent the title bar or tab. - // When the window is collapsed (SkipItems==true) that last item will never be overwritten so we need to detect the case. - if (g.LastItemData.ID == window->MoveId && window->WriteAccessed) - return false; - return true; -} - -// Internal facing ItemHoverable() used when submitting widgets. Differs slightly from IsItemHovered(). -bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id) -{ - ImGuiContext& g = *GImGui; - if (g.HoveredId != 0 && g.HoveredId != id && !g.HoveredIdAllowOverlap) - return false; - - ImGuiWindow* window = g.CurrentWindow; - if (g.HoveredWindow != window) - return false; - if (g.ActiveId != 0 && g.ActiveId != id && !g.ActiveIdAllowOverlap) - return false; - if (!IsMouseHoveringRect(bb.Min, bb.Max)) - return false; - if (g.NavDisableMouseHover) - return false; - if (!IsWindowContentHoverable(window, ImGuiHoveredFlags_None)) - { - g.HoveredIdDisabled = true; - return false; - } - - // We exceptionally allow this function to be called with id==0 to allow using it for easy high-level - // hover test in widgets code. We could also decide to split this function is two. - if (id != 0) - SetHoveredID(id); - - // When disabled we'll return false but still set HoveredId - ImGuiItemFlags item_flags = (g.LastItemData.ID == id ? g.LastItemData.InFlags : g.CurrentItemFlags); - if (item_flags & ImGuiItemFlags_Disabled) - { - // Release active id if turning disabled - if (g.ActiveId == id) - ClearActiveID(); - g.HoveredIdDisabled = true; - return false; - } - - if (id != 0) - { - // [DEBUG] Item Picker tool! - // We perform the check here because SetHoveredID() is not frequently called (1~ time a frame), making - // the cost of this tool near-zero. We can get slightly better call-stack and support picking non-hovered - // items if we perform the test in ItemAdd(), but that would incur a small runtime cost. - // #define IMGUI_DEBUG_TOOL_ITEM_PICKER_EX in imconfig.h if you want this check to also be performed in ItemAdd(). - if (g.DebugItemPickerActive && g.HoveredIdPreviousFrame == id) - GetForegroundDrawList()->AddRect(bb.Min, bb.Max, IM_COL32(255, 255, 0, 255)); - if (g.DebugItemPickerBreakId == id) - IM_DEBUG_BREAK(); - } - - return true; -} - -bool ImGui::IsClippedEx(const ImRect& bb, ImGuiID id) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - if (!bb.Overlaps(window->ClipRect)) - if (id == 0 || (id != g.ActiveId && id != g.NavId)) - if (!g.LogEnabled) - return true; - return false; -} - -// Called by ItemAdd() -// Process TAB/Shift+TAB. Be mindful that this function may _clear_ the ActiveID when tabbing out. -// [WIP] This will eventually be refactored and moved into NavProcessItem() -void ImGui::ItemInputable(ImGuiWindow* window, ImGuiID id) -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(id != 0 && id == g.LastItemData.ID); - - // Increment counters - // FIXME: ImGuiItemFlags_Disabled should disable more. - const bool is_tab_stop = (g.LastItemData.InFlags & (ImGuiItemFlags_NoTabStop | ImGuiItemFlags_Disabled)) == 0; - if (is_tab_stop) - { - window->DC.FocusCounterTabStop++; - if (g.NavId == id) - g.NavIdTabCounter = window->DC.FocusCounterTabStop; - } - - // Process TAB/Shift-TAB to tab *OUT* of the currently focused item. - // (Note that we can always TAB out of a widget that doesn't allow tabbing in) - if (g.ActiveId == id && g.TabFocusPressed && g.TabFocusRequestNextWindow == NULL) - { - g.TabFocusRequestNextWindow = window; - g.TabFocusRequestNextCounterTabStop = window->DC.FocusCounterTabStop + (g.IO.KeyShift ? (is_tab_stop ? -1 : 0) : +1); // Modulo on index will be applied at the end of frame once we've got the total counter of items. - } - - // Handle focus requests - if (g.TabFocusRequestCurrWindow == window) - { - if (is_tab_stop && window->DC.FocusCounterTabStop == g.TabFocusRequestCurrCounterTabStop) - { - g.NavJustTabbedId = id; // FIXME-NAV: aim to eventually set in NavUpdate() once we finish the refactor - g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_FocusedByTabbing; - return; - } - - // If another item is about to be focused, we clear our own active id - if (g.ActiveId == id) - ClearActiveID(); - } -} - -float ImGui::CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x) -{ - if (wrap_pos_x < 0.0f) - return 0.0f; - - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - if (wrap_pos_x == 0.0f) - { - // We could decide to setup a default wrapping max point for auto-resizing windows, - // or have auto-wrap (with unspecified wrapping pos) behave as a ContentSize extending function? - //if (window->Hidden && (window->Flags & ImGuiWindowFlags_AlwaysAutoResize)) - // wrap_pos_x = ImMax(window->WorkRect.Min.x + g.FontSize * 10.0f, window->WorkRect.Max.x); - //else - wrap_pos_x = window->WorkRect.Max.x; - } - else if (wrap_pos_x > 0.0f) - { - wrap_pos_x += window->Pos.x - window->Scroll.x; // wrap_pos_x is provided is window local space - } - - return ImMax(wrap_pos_x - pos.x, 1.0f); -} - -// IM_ALLOC() == ImGui::MemAlloc() -void* ImGui::MemAlloc(size_t size) -{ - if (ImGuiContext* ctx = GImGui) - ctx->IO.MetricsActiveAllocations++; - return (*GImAllocatorAllocFunc)(size, GImAllocatorUserData); -} - -// IM_FREE() == ImGui::MemFree() -void ImGui::MemFree(void* ptr) -{ - if (ptr) - if (ImGuiContext* ctx = GImGui) - ctx->IO.MetricsActiveAllocations--; - return (*GImAllocatorFreeFunc)(ptr, GImAllocatorUserData); -} - -const char* ImGui::GetClipboardText() -{ - ImGuiContext& g = *GImGui; - return g.IO.GetClipboardTextFn ? g.IO.GetClipboardTextFn(g.IO.ClipboardUserData) : ""; -} - -void ImGui::SetClipboardText(const char* text) -{ - ImGuiContext& g = *GImGui; - if (g.IO.SetClipboardTextFn) - g.IO.SetClipboardTextFn(g.IO.ClipboardUserData, text); -} - -const char* ImGui::GetVersion() -{ - return IMGUI_VERSION; -} - -// Internal state access - if you want to share Dear ImGui state between modules (e.g. DLL) or allocate it yourself -// Note that we still point to some static data and members (such as GFontAtlas), so the state instance you end up using will point to the static data within its module -ImGuiContext* ImGui::GetCurrentContext() -{ - return GImGui; -} - -void ImGui::SetCurrentContext(ImGuiContext* ctx) -{ -#ifdef IMGUI_SET_CURRENT_CONTEXT_FUNC - IMGUI_SET_CURRENT_CONTEXT_FUNC(ctx); // For custom thread-based hackery you may want to have control over this. -#else - GImGui = ctx; -#endif -} - -void ImGui::SetAllocatorFunctions(ImGuiMemAllocFunc alloc_func, ImGuiMemFreeFunc free_func, void* user_data) -{ - GImAllocatorAllocFunc = alloc_func; - GImAllocatorFreeFunc = free_func; - GImAllocatorUserData = user_data; -} - -// This is provided to facilitate copying allocators from one static/DLL boundary to another (e.g. retrieve default allocator of your executable address space) -void ImGui::GetAllocatorFunctions(ImGuiMemAllocFunc* p_alloc_func, ImGuiMemFreeFunc* p_free_func, void** p_user_data) -{ - *p_alloc_func = GImAllocatorAllocFunc; - *p_free_func = GImAllocatorFreeFunc; - *p_user_data = GImAllocatorUserData; -} - -ImGuiContext* ImGui::CreateContext(ImFontAtlas* shared_font_atlas) -{ - ImGuiContext* ctx = IM_NEW(ImGuiContext)(shared_font_atlas); - if (GImGui == NULL) - SetCurrentContext(ctx); - Initialize(ctx); - return ctx; -} - -void ImGui::DestroyContext(ImGuiContext* ctx) -{ - if (ctx == NULL) - ctx = GImGui; - Shutdown(ctx); - if (GImGui == ctx) - SetCurrentContext(NULL); - IM_DELETE(ctx); -} - -// No specific ordering/dependency support, will see as needed -ImGuiID ImGui::AddContextHook(ImGuiContext* ctx, const ImGuiContextHook* hook) -{ - ImGuiContext& g = *ctx; - IM_ASSERT(hook->Callback != NULL && hook->HookId == 0 && hook->Type != ImGuiContextHookType_PendingRemoval_); - g.Hooks.push_back(*hook); - g.Hooks.back().HookId = ++g.HookIdNext; - return g.HookIdNext; -} - -// Deferred removal, avoiding issue with changing vector while iterating it -void ImGui::RemoveContextHook(ImGuiContext* ctx, ImGuiID hook_id) -{ - ImGuiContext& g = *ctx; - IM_ASSERT(hook_id != 0); - for (int n = 0; n < g.Hooks.Size; n++) - if (g.Hooks[n].HookId == hook_id) - g.Hooks[n].Type = ImGuiContextHookType_PendingRemoval_; -} - -// Call context hooks (used by e.g. test engine) -// We assume a small number of hooks so all stored in same array -void ImGui::CallContextHooks(ImGuiContext* ctx, ImGuiContextHookType hook_type) -{ - ImGuiContext& g = *ctx; - for (int n = 0; n < g.Hooks.Size; n++) - if (g.Hooks[n].Type == hook_type) - g.Hooks[n].Callback(&g, &g.Hooks[n]); -} - -ImGuiIO& ImGui::GetIO() -{ - IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?"); - return GImGui->IO; -} - -// Pass this to your backend rendering function! Valid after Render() and until the next call to NewFrame() -ImDrawData* ImGui::GetDrawData() -{ - ImGuiContext& g = *GImGui; - ImGuiViewportP* viewport = g.Viewports[0]; - return viewport->DrawDataP.Valid ? &viewport->DrawDataP : NULL; -} - -double ImGui::GetTime() -{ - return GImGui->Time; -} - -int ImGui::GetFrameCount() -{ - return GImGui->FrameCount; -} - -static ImDrawList* GetViewportDrawList(ImGuiViewportP* viewport, size_t drawlist_no, const char* drawlist_name) -{ - // Create the draw list on demand, because they are not frequently used for all viewports - ImGuiContext& g = *GImGui; - IM_ASSERT(drawlist_no < IM_ARRAYSIZE(viewport->DrawLists)); - ImDrawList* draw_list = viewport->DrawLists[drawlist_no]; - if (draw_list == NULL) - { - draw_list = IM_NEW(ImDrawList)(&g.DrawListSharedData); - draw_list->_OwnerName = drawlist_name; - viewport->DrawLists[drawlist_no] = draw_list; - } - - // Our ImDrawList system requires that there is always a command - if (viewport->DrawListsLastFrame[drawlist_no] != g.FrameCount) - { - draw_list->_ResetForNewFrame(); - draw_list->PushTextureID(g.IO.Fonts->TexID); - draw_list->PushClipRect(viewport->Pos, viewport->Pos + viewport->Size, false); - viewport->DrawListsLastFrame[drawlist_no] = g.FrameCount; - } - return draw_list; -} - -ImDrawList* ImGui::GetBackgroundDrawList(ImGuiViewport* viewport) -{ - return GetViewportDrawList((ImGuiViewportP*)viewport, 0, "##Background"); -} - -ImDrawList* ImGui::GetBackgroundDrawList() -{ - ImGuiContext& g = *GImGui; - return GetBackgroundDrawList(g.Viewports[0]); -} - -ImDrawList* ImGui::GetForegroundDrawList(ImGuiViewport* viewport) -{ - return GetViewportDrawList((ImGuiViewportP*)viewport, 1, "##Foreground"); -} - -ImDrawList* ImGui::GetForegroundDrawList() -{ - ImGuiContext& g = *GImGui; - return GetForegroundDrawList(g.Viewports[0]); -} - -ImDrawListSharedData* ImGui::GetDrawListSharedData() -{ - return &GImGui->DrawListSharedData; -} - -void ImGui::StartMouseMovingWindow(ImGuiWindow* window) -{ - // Set ActiveId even if the _NoMove flag is set. Without it, dragging away from a window with _NoMove would activate hover on other windows. - // We _also_ call this when clicking in a window empty space when io.ConfigWindowsMoveFromTitleBarOnly is set, but clear g.MovingWindow afterward. - // This is because we want ActiveId to be set even when the window is not permitted to move. - ImGuiContext& g = *GImGui; - FocusWindow(window); - SetActiveID(window->MoveId, window); - g.NavDisableHighlight = true; - g.ActiveIdClickOffset = g.IO.MouseClickedPos[0] - window->RootWindow->Pos; - g.ActiveIdNoClearOnFocusLoss = true; - SetActiveIdUsingNavAndKeys(); - - bool can_move_window = true; - if ((window->Flags & ImGuiWindowFlags_NoMove) || (window->RootWindow->Flags & ImGuiWindowFlags_NoMove)) - can_move_window = false; - if (can_move_window) - g.MovingWindow = window; -} - -// Handle mouse moving window -// Note: moving window with the navigation keys (Square + d-pad / CTRL+TAB + Arrows) are processed in NavUpdateWindowing() -// FIXME: We don't have strong guarantee that g.MovingWindow stay synched with g.ActiveId == g.MovingWindow->MoveId. -// This is currently enforced by the fact that BeginDragDropSource() is setting all g.ActiveIdUsingXXXX flags to inhibit navigation inputs, -// but if we should more thoroughly test cases where g.ActiveId or g.MovingWindow gets changed and not the other. -void ImGui::UpdateMouseMovingWindowNewFrame() -{ - ImGuiContext& g = *GImGui; - if (g.MovingWindow != NULL) - { - // We actually want to move the root window. g.MovingWindow == window we clicked on (could be a child window). - // We track it to preserve Focus and so that generally ActiveIdWindow == MovingWindow and ActiveId == MovingWindow->MoveId for consistency. - KeepAliveID(g.ActiveId); - IM_ASSERT(g.MovingWindow && g.MovingWindow->RootWindow); - ImGuiWindow* moving_window = g.MovingWindow->RootWindow; - if (g.IO.MouseDown[0] && IsMousePosValid(&g.IO.MousePos)) - { - ImVec2 pos = g.IO.MousePos - g.ActiveIdClickOffset; - if (moving_window->Pos.x != pos.x || moving_window->Pos.y != pos.y) - { - MarkIniSettingsDirty(moving_window); - SetWindowPos(moving_window, pos, ImGuiCond_Always); - } - FocusWindow(g.MovingWindow); - } - else - { - g.MovingWindow = NULL; - ClearActiveID(); - } - } - else - { - // When clicking/dragging from a window that has the _NoMove flag, we still set the ActiveId in order to prevent hovering others. - if (g.ActiveIdWindow && g.ActiveIdWindow->MoveId == g.ActiveId) - { - KeepAliveID(g.ActiveId); - if (!g.IO.MouseDown[0]) - ClearActiveID(); - } - } -} - -// Initiate moving window when clicking on empty space or title bar. -// Handle left-click and right-click focus. -void ImGui::UpdateMouseMovingWindowEndFrame() -{ - ImGuiContext& g = *GImGui; - if (g.ActiveId != 0 || g.HoveredId != 0) - return; - - // Unless we just made a window/popup appear - if (g.NavWindow && g.NavWindow->Appearing) - return; - - // Click on empty space to focus window and start moving - // (after we're done with all our widgets) - if (g.IO.MouseClicked[0]) - { - // Handle the edge case of a popup being closed while clicking in its empty space. - // If we try to focus it, FocusWindow() > ClosePopupsOverWindow() will accidentally close any parent popups because they are not linked together any more. - ImGuiWindow* root_window = g.HoveredWindow ? g.HoveredWindow->RootWindow : NULL; - const bool is_closed_popup = root_window && (root_window->Flags & ImGuiWindowFlags_Popup) && !IsPopupOpen(root_window->PopupId, ImGuiPopupFlags_AnyPopupLevel); - - if (root_window != NULL && !is_closed_popup) - { - StartMouseMovingWindow(g.HoveredWindow); //-V595 - - // Cancel moving if clicked outside of title bar - if (g.IO.ConfigWindowsMoveFromTitleBarOnly && !(root_window->Flags & ImGuiWindowFlags_NoTitleBar)) - if (!root_window->TitleBarRect().Contains(g.IO.MouseClickedPos[0])) - g.MovingWindow = NULL; - - // Cancel moving if clicked over an item which was disabled or inhibited by popups (note that we know HoveredId == 0 already) - if (g.HoveredIdDisabled) - g.MovingWindow = NULL; - } - else if (root_window == NULL && g.NavWindow != NULL && GetTopMostPopupModal() == NULL) - { - // Clicking on void disable focus - FocusWindow(NULL); - } - } - - // With right mouse button we close popups without changing focus based on where the mouse is aimed - // Instead, focus will be restored to the window under the bottom-most closed popup. - // (The left mouse button path calls FocusWindow on the hovered window, which will lead NewFrame->ClosePopupsOverWindow to trigger) - if (g.IO.MouseClicked[1]) - { - // Find the top-most window between HoveredWindow and the top-most Modal Window. - // This is where we can trim the popup stack. - ImGuiWindow* modal = GetTopMostPopupModal(); - bool hovered_window_above_modal = g.HoveredWindow && IsWindowAbove(g.HoveredWindow, modal); - ClosePopupsOverWindow(hovered_window_above_modal ? g.HoveredWindow : modal, true); - } -} - -static bool IsWindowActiveAndVisible(ImGuiWindow* window) -{ - return (window->Active) && (!window->Hidden); -} - -static void ImGui::UpdateMouseInputs() -{ - ImGuiContext& g = *GImGui; - - // Round mouse position to avoid spreading non-rounded position (e.g. UpdateManualResize doesn't support them well) - if (IsMousePosValid(&g.IO.MousePos)) - g.IO.MousePos = g.MouseLastValidPos = ImFloor(g.IO.MousePos); - - // If mouse just appeared or disappeared (usually denoted by -FLT_MAX components) we cancel out movement in MouseDelta - if (IsMousePosValid(&g.IO.MousePos) && IsMousePosValid(&g.IO.MousePosPrev)) - g.IO.MouseDelta = g.IO.MousePos - g.IO.MousePosPrev; - else - g.IO.MouseDelta = ImVec2(0.0f, 0.0f); - - // If mouse moved we re-enable mouse hovering in case it was disabled by gamepad/keyboard. In theory should use a >0.0f threshold but would need to reset in everywhere we set this to true. - if (g.IO.MouseDelta.x != 0.0f || g.IO.MouseDelta.y != 0.0f) - g.NavDisableMouseHover = false; - - g.IO.MousePosPrev = g.IO.MousePos; - for (int i = 0; i < IM_ARRAYSIZE(g.IO.MouseDown); i++) - { - g.IO.MouseClicked[i] = g.IO.MouseDown[i] && g.IO.MouseDownDuration[i] < 0.0f; - g.IO.MouseReleased[i] = !g.IO.MouseDown[i] && g.IO.MouseDownDuration[i] >= 0.0f; - g.IO.MouseDownDurationPrev[i] = g.IO.MouseDownDuration[i]; - g.IO.MouseDownDuration[i] = g.IO.MouseDown[i] ? (g.IO.MouseDownDuration[i] < 0.0f ? 0.0f : g.IO.MouseDownDuration[i] + g.IO.DeltaTime) : -1.0f; - g.IO.MouseDoubleClicked[i] = false; - if (g.IO.MouseClicked[i]) - { - if ((float)(g.Time - g.IO.MouseClickedTime[i]) < g.IO.MouseDoubleClickTime) - { - ImVec2 delta_from_click_pos = IsMousePosValid(&g.IO.MousePos) ? (g.IO.MousePos - g.IO.MouseClickedPos[i]) : ImVec2(0.0f, 0.0f); - if (ImLengthSqr(delta_from_click_pos) < g.IO.MouseDoubleClickMaxDist * g.IO.MouseDoubleClickMaxDist) - g.IO.MouseDoubleClicked[i] = true; - g.IO.MouseClickedTime[i] = -g.IO.MouseDoubleClickTime * 2.0f; // Mark as "old enough" so the third click isn't turned into a double-click - } - else - { - g.IO.MouseClickedTime[i] = g.Time; - } - g.IO.MouseClickedPos[i] = g.IO.MousePos; - g.IO.MouseDownWasDoubleClick[i] = g.IO.MouseDoubleClicked[i]; - g.IO.MouseDragMaxDistanceAbs[i] = ImVec2(0.0f, 0.0f); - g.IO.MouseDragMaxDistanceSqr[i] = 0.0f; - } - else if (g.IO.MouseDown[i]) - { - // Maintain the maximum distance we reaching from the initial click position, which is used with dragging threshold - ImVec2 delta_from_click_pos = IsMousePosValid(&g.IO.MousePos) ? (g.IO.MousePos - g.IO.MouseClickedPos[i]) : ImVec2(0.0f, 0.0f); - g.IO.MouseDragMaxDistanceSqr[i] = ImMax(g.IO.MouseDragMaxDistanceSqr[i], ImLengthSqr(delta_from_click_pos)); - g.IO.MouseDragMaxDistanceAbs[i].x = ImMax(g.IO.MouseDragMaxDistanceAbs[i].x, delta_from_click_pos.x < 0.0f ? -delta_from_click_pos.x : delta_from_click_pos.x); - g.IO.MouseDragMaxDistanceAbs[i].y = ImMax(g.IO.MouseDragMaxDistanceAbs[i].y, delta_from_click_pos.y < 0.0f ? -delta_from_click_pos.y : delta_from_click_pos.y); - } - if (!g.IO.MouseDown[i] && !g.IO.MouseReleased[i]) - g.IO.MouseDownWasDoubleClick[i] = false; - if (g.IO.MouseClicked[i]) // Clicking any mouse button reactivate mouse hovering which may have been deactivated by gamepad/keyboard navigation - g.NavDisableMouseHover = false; - } -} - -static void StartLockWheelingWindow(ImGuiWindow* window) -{ - ImGuiContext& g = *GImGui; - if (g.WheelingWindow == window) - return; - g.WheelingWindow = window; - g.WheelingWindowRefMousePos = g.IO.MousePos; - g.WheelingWindowTimer = WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER; -} - -void ImGui::UpdateMouseWheel() -{ - ImGuiContext& g = *GImGui; - - // Reset the locked window if we move the mouse or after the timer elapses - if (g.WheelingWindow != NULL) - { - g.WheelingWindowTimer -= g.IO.DeltaTime; - if (IsMousePosValid() && ImLengthSqr(g.IO.MousePos - g.WheelingWindowRefMousePos) > g.IO.MouseDragThreshold * g.IO.MouseDragThreshold) - g.WheelingWindowTimer = 0.0f; - if (g.WheelingWindowTimer <= 0.0f) - { - g.WheelingWindow = NULL; - g.WheelingWindowTimer = 0.0f; - } - } - - if (g.IO.MouseWheel == 0.0f && g.IO.MouseWheelH == 0.0f) - return; - - if ((g.ActiveId != 0 && g.ActiveIdUsingMouseWheel) || (g.HoveredIdPreviousFrame != 0 && g.HoveredIdPreviousFrameUsingMouseWheel)) - return; - - ImGuiWindow* window = g.WheelingWindow ? g.WheelingWindow : g.HoveredWindow; - if (!window || window->Collapsed) - return; - - // Zoom / Scale window - // FIXME-OBSOLETE: This is an old feature, it still works but pretty much nobody is using it and may be best redesigned. - if (g.IO.MouseWheel != 0.0f && g.IO.KeyCtrl && g.IO.FontAllowUserScaling) - { - StartLockWheelingWindow(window); - const float new_font_scale = ImClamp(window->FontWindowScale + g.IO.MouseWheel * 0.10f, 0.50f, 2.50f); - const float scale = new_font_scale / window->FontWindowScale; - window->FontWindowScale = new_font_scale; - if (window == window->RootWindow) - { - const ImVec2 offset = window->Size * (1.0f - scale) * (g.IO.MousePos - window->Pos) / window->Size; - SetWindowPos(window, window->Pos + offset, 0); - window->Size = ImFloor(window->Size * scale); - window->SizeFull = ImFloor(window->SizeFull * scale); - } - return; - } - - // Mouse wheel scrolling - // If a child window has the ImGuiWindowFlags_NoScrollWithMouse flag, we give a chance to scroll its parent - if (g.IO.KeyCtrl) - return; - - // As a standard behavior holding SHIFT while using Vertical Mouse Wheel triggers Horizontal scroll instead - // (we avoid doing it on OSX as it the OS input layer handles this already) - const bool swap_axis = g.IO.KeyShift && !g.IO.ConfigMacOSXBehaviors; - const float wheel_y = swap_axis ? 0.0f : g.IO.MouseWheel; - const float wheel_x = swap_axis ? g.IO.MouseWheel : g.IO.MouseWheelH; - - // Vertical Mouse Wheel scrolling - if (wheel_y != 0.0f) - { - StartLockWheelingWindow(window); - while ((window->Flags & ImGuiWindowFlags_ChildWindow) && ((window->ScrollMax.y == 0.0f) || ((window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs)))) - window = window->ParentWindow; - if (!(window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs)) - { - float max_step = window->InnerRect.GetHeight() * 0.67f; - float scroll_step = ImFloor(ImMin(5 * window->CalcFontSize(), max_step)); - SetScrollY(window, window->Scroll.y - wheel_y * scroll_step); - } - } - - // Horizontal Mouse Wheel scrolling, or Vertical Mouse Wheel w/ Shift held - if (wheel_x != 0.0f) - { - StartLockWheelingWindow(window); - while ((window->Flags & ImGuiWindowFlags_ChildWindow) && ((window->ScrollMax.x == 0.0f) || ((window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs)))) - window = window->ParentWindow; - if (!(window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs)) - { - float max_step = window->InnerRect.GetWidth() * 0.67f; - float scroll_step = ImFloor(ImMin(2 * window->CalcFontSize(), max_step)); - SetScrollX(window, window->Scroll.x - wheel_x * scroll_step); - } - } -} - -void ImGui::UpdateTabFocus() -{ - ImGuiContext& g = *GImGui; - - // Pressing TAB activate widget focus - g.TabFocusPressed = false; - if (g.NavWindow && g.NavWindow->Active && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs)) - if (!g.IO.KeyCtrl && !g.IO.KeyAlt && IsKeyPressedMap(ImGuiKey_Tab) && !IsActiveIdUsingKey(ImGuiKey_Tab)) - g.TabFocusPressed = true; - if (g.ActiveId == 0 && g.TabFocusPressed) - { - // - This path is only taken when no widget are active/tabbed-into yet. - // Subsequent tabbing will be processed by FocusableItemRegister() - // - Note that SetKeyboardFocusHere() sets the Next fields mid-frame. To be consistent we also - // manipulate the Next fields here even though they will be turned into Curr fields below. - g.TabFocusRequestNextWindow = g.NavWindow; - if (g.NavId != 0 && g.NavIdTabCounter != INT_MAX) - g.TabFocusRequestNextCounterTabStop = g.NavIdTabCounter + (g.IO.KeyShift ? -1 : 0); - else - g.TabFocusRequestNextCounterTabStop = g.IO.KeyShift ? -1 : 0; - } - - // Turn queued focus request into current one - g.TabFocusRequestCurrWindow = NULL; - g.TabFocusRequestCurrCounterTabStop = INT_MAX; - if (g.TabFocusRequestNextWindow != NULL) - { - ImGuiWindow* window = g.TabFocusRequestNextWindow; - g.TabFocusRequestCurrWindow = window; - if (g.TabFocusRequestNextCounterTabStop != INT_MAX && window->DC.FocusCounterTabStop != -1) - g.TabFocusRequestCurrCounterTabStop = ImModPositive(g.TabFocusRequestNextCounterTabStop, window->DC.FocusCounterTabStop + 1); - g.TabFocusRequestNextWindow = NULL; - g.TabFocusRequestNextCounterTabStop = INT_MAX; - } - - g.NavIdTabCounter = INT_MAX; -} - -// The reason this is exposed in imgui_internal.h is: on touch-based system that don't have hovering, we want to dispatch inputs to the right target (imgui vs imgui+app) -void ImGui::UpdateHoveredWindowAndCaptureFlags() -{ - ImGuiContext& g = *GImGui; - ImGuiIO& io = g.IO; - g.WindowsHoverPadding = ImMax(g.Style.TouchExtraPadding, ImVec2(WINDOWS_HOVER_PADDING, WINDOWS_HOVER_PADDING)); - - // Find the window hovered by mouse: - // - Child windows can extend beyond the limit of their parent so we need to derive HoveredRootWindow from HoveredWindow. - // - When moving a window we can skip the search, which also conveniently bypasses the fact that window->WindowRectClipped is lagging as this point of the frame. - // - We also support the moved window toggling the NoInputs flag after moving has started in order to be able to detect windows below it, which is useful for e.g. docking mechanisms. - bool clear_hovered_windows = false; - FindHoveredWindow(); - - // Modal windows prevents mouse from hovering behind them. - ImGuiWindow* modal_window = GetTopMostPopupModal(); - if (modal_window && g.HoveredWindow && !IsWindowChildOf(g.HoveredWindow->RootWindow, modal_window, true)) - clear_hovered_windows = true; - - // Disabled mouse? - if (io.ConfigFlags & ImGuiConfigFlags_NoMouse) - clear_hovered_windows = true; - - // We track click ownership. When clicked outside of a window the click is owned by the application and - // won't report hovering nor request capture even while dragging over our windows afterward. - const bool has_open_popup = (g.OpenPopupStack.Size > 0); - const bool has_open_modal = (modal_window != NULL); - int mouse_earliest_down = -1; - bool mouse_any_down = false; - for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) - { - if (io.MouseClicked[i]) - { - io.MouseDownOwned[i] = (g.HoveredWindow != NULL) || has_open_popup; - io.MouseDownOwnedUnlessPopupClose[i] = (g.HoveredWindow != NULL) || has_open_modal; - } - mouse_any_down |= io.MouseDown[i]; - if (io.MouseDown[i]) - if (mouse_earliest_down == -1 || io.MouseClickedTime[i] < io.MouseClickedTime[mouse_earliest_down]) - mouse_earliest_down = i; - } - const bool mouse_avail = (mouse_earliest_down == -1) || io.MouseDownOwned[mouse_earliest_down]; - const bool mouse_avail_unless_popup_close = (mouse_earliest_down == -1) || io.MouseDownOwnedUnlessPopupClose[mouse_earliest_down]; - - // If mouse was first clicked outside of ImGui bounds we also cancel out hovering. - // FIXME: For patterns of drag and drop across OS windows, we may need to rework/remove this test (first committed 311c0ca9 on 2015/02) - const bool mouse_dragging_extern_payload = g.DragDropActive && (g.DragDropSourceFlags & ImGuiDragDropFlags_SourceExtern) != 0; - if (!mouse_avail && !mouse_dragging_extern_payload) - clear_hovered_windows = true; - - if (clear_hovered_windows) - g.HoveredWindow = g.HoveredWindowUnderMovingWindow = NULL; - - // Update io.WantCaptureMouse for the user application (true = dispatch mouse info to Dear ImGui only, false = dispatch mouse to Dear ImGui + underlying app) - // Update io.WantCaptureMouseAllowPopupClose (experimental) to give a chance for app to react to popup closure with a drag - if (g.WantCaptureMouseNextFrame != -1) - { - io.WantCaptureMouse = io.WantCaptureMouseUnlessPopupClose = (g.WantCaptureMouseNextFrame != 0); - } - else - { - io.WantCaptureMouse = (mouse_avail && (g.HoveredWindow != NULL || mouse_any_down)) || has_open_popup; - io.WantCaptureMouseUnlessPopupClose = (mouse_avail_unless_popup_close && (g.HoveredWindow != NULL || mouse_any_down)) || has_open_modal; - } - - // Update io.WantCaptureKeyboard for the user application (true = dispatch keyboard info to Dear ImGui only, false = dispatch keyboard info to Dear ImGui + underlying app) - if (g.WantCaptureKeyboardNextFrame != -1) - io.WantCaptureKeyboard = (g.WantCaptureKeyboardNextFrame != 0); - else - io.WantCaptureKeyboard = (g.ActiveId != 0) || (modal_window != NULL); - if (io.NavActive && (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) && !(io.ConfigFlags & ImGuiConfigFlags_NavNoCaptureKeyboard)) - io.WantCaptureKeyboard = true; - - // Update io.WantTextInput flag, this is to allow systems without a keyboard (e.g. mobile, hand-held) to show a software keyboard if possible - io.WantTextInput = (g.WantTextInputNextFrame != -1) ? (g.WantTextInputNextFrame != 0) : false; -} - -ImGuiKeyModFlags ImGui::GetMergedKeyModFlags() -{ - ImGuiContext& g = *GImGui; - ImGuiKeyModFlags key_mod_flags = ImGuiKeyModFlags_None; - if (g.IO.KeyCtrl) { key_mod_flags |= ImGuiKeyModFlags_Ctrl; } - if (g.IO.KeyShift) { key_mod_flags |= ImGuiKeyModFlags_Shift; } - if (g.IO.KeyAlt) { key_mod_flags |= ImGuiKeyModFlags_Alt; } - if (g.IO.KeySuper) { key_mod_flags |= ImGuiKeyModFlags_Super; } - return key_mod_flags; -} - -void ImGui::NewFrame() -{ - IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?"); - ImGuiContext& g = *GImGui; - - // Remove pending delete hooks before frame start. - // This deferred removal avoid issues of removal while iterating the hook vector - for (int n = g.Hooks.Size - 1; n >= 0; n--) - if (g.Hooks[n].Type == ImGuiContextHookType_PendingRemoval_) - g.Hooks.erase(&g.Hooks[n]); - - CallContextHooks(&g, ImGuiContextHookType_NewFramePre); - - // Check and assert for various common IO and Configuration mistakes - ErrorCheckNewFrameSanityChecks(); - - // Load settings on first frame, save settings when modified (after a delay) - UpdateSettings(); - - g.Time += g.IO.DeltaTime; - g.WithinFrameScope = true; - g.FrameCount += 1; - g.TooltipOverrideCount = 0; - g.WindowsActiveCount = 0; - g.MenusIdSubmittedThisFrame.resize(0); - - // Calculate frame-rate for the user, as a purely luxurious feature - g.FramerateSecPerFrameAccum += g.IO.DeltaTime - g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx]; - g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx] = g.IO.DeltaTime; - g.FramerateSecPerFrameIdx = (g.FramerateSecPerFrameIdx + 1) % IM_ARRAYSIZE(g.FramerateSecPerFrame); - g.FramerateSecPerFrameCount = ImMin(g.FramerateSecPerFrameCount + 1, IM_ARRAYSIZE(g.FramerateSecPerFrame)); - g.IO.Framerate = (g.FramerateSecPerFrameAccum > 0.0f) ? (1.0f / (g.FramerateSecPerFrameAccum / (float)g.FramerateSecPerFrameCount)) : FLT_MAX; - - UpdateViewportsNewFrame(); - - // Setup current font and draw list shared data - g.IO.Fonts->Locked = true; - SetCurrentFont(GetDefaultFont()); - IM_ASSERT(g.Font->IsLoaded()); - ImRect virtual_space(FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX); - for (int n = 0; n < g.Viewports.Size; n++) - virtual_space.Add(g.Viewports[n]->GetMainRect()); - g.DrawListSharedData.ClipRectFullscreen = virtual_space.ToVec4(); - g.DrawListSharedData.CurveTessellationTol = g.Style.CurveTessellationTol; - g.DrawListSharedData.SetCircleTessellationMaxError(g.Style.CircleTessellationMaxError); - g.DrawListSharedData.InitialFlags = ImDrawListFlags_None; - if (g.Style.AntiAliasedLines) - g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AntiAliasedLines; - if (g.Style.AntiAliasedLinesUseTex && !(g.Font->ContainerAtlas->Flags & ImFontAtlasFlags_NoBakedLines)) - g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AntiAliasedLinesUseTex; - if (g.Style.AntiAliasedFill) - g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AntiAliasedFill; - if (g.IO.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset) - g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AllowVtxOffset; - - // Mark rendering data as invalid to prevent user who may have a handle on it to use it. - for (int n = 0; n < g.Viewports.Size; n++) - { - ImGuiViewportP* viewport = g.Viewports[n]; - viewport->DrawDataP.Clear(); - } - - // Drag and drop keep the source ID alive so even if the source disappear our state is consistent - if (g.DragDropActive && g.DragDropPayload.SourceId == g.ActiveId) - KeepAliveID(g.DragDropPayload.SourceId); - - // Update HoveredId data - if (!g.HoveredIdPreviousFrame) - g.HoveredIdTimer = 0.0f; - if (!g.HoveredIdPreviousFrame || (g.HoveredId && g.ActiveId == g.HoveredId)) - g.HoveredIdNotActiveTimer = 0.0f; - if (g.HoveredId) - g.HoveredIdTimer += g.IO.DeltaTime; - if (g.HoveredId && g.ActiveId != g.HoveredId) - g.HoveredIdNotActiveTimer += g.IO.DeltaTime; - g.HoveredIdPreviousFrame = g.HoveredId; - g.HoveredIdPreviousFrameUsingMouseWheel = g.HoveredIdUsingMouseWheel; - g.HoveredId = 0; - g.HoveredIdAllowOverlap = false; - g.HoveredIdUsingMouseWheel = false; - g.HoveredIdDisabled = false; - - // Update ActiveId data (clear reference to active widget if the widget isn't alive anymore) - if (g.ActiveIdIsAlive != g.ActiveId && g.ActiveIdPreviousFrame == g.ActiveId && g.ActiveId != 0) - ClearActiveID(); - if (g.ActiveId) - g.ActiveIdTimer += g.IO.DeltaTime; - g.LastActiveIdTimer += g.IO.DeltaTime; - g.ActiveIdPreviousFrame = g.ActiveId; - g.ActiveIdPreviousFrameWindow = g.ActiveIdWindow; - g.ActiveIdPreviousFrameHasBeenEditedBefore = g.ActiveIdHasBeenEditedBefore; - g.ActiveIdIsAlive = 0; - g.ActiveIdHasBeenEditedThisFrame = false; - g.ActiveIdPreviousFrameIsAlive = false; - g.ActiveIdIsJustActivated = false; - if (g.TempInputId != 0 && g.ActiveId != g.TempInputId) - g.TempInputId = 0; - if (g.ActiveId == 0) - { - g.ActiveIdUsingNavDirMask = 0x00; - g.ActiveIdUsingNavInputMask = 0x00; - g.ActiveIdUsingKeyInputMask = 0x00; - } - - // Drag and drop - g.DragDropAcceptIdPrev = g.DragDropAcceptIdCurr; - g.DragDropAcceptIdCurr = 0; - g.DragDropAcceptIdCurrRectSurface = FLT_MAX; - g.DragDropWithinSource = false; - g.DragDropWithinTarget = false; - g.DragDropHoldJustPressedId = 0; - - // Close popups on focus lost (currently wip/opt-in) - //if (g.IO.AppFocusLost) - // ClosePopupsExceptModals(); - - // Clear buttons state when focus is lost - // (this is useful so e.g. releasing Alt after focus loss on Alt-Tab doesn't trigger the Alt menu toggle) - if (g.IO.AppFocusLost) - { - g.IO.ClearInputKeys(); - g.IO.AppFocusLost = false; - } - - // Update keyboard input state - // Synchronize io.KeyMods with individual modifiers io.KeyXXX bools - g.IO.KeyMods = GetMergedKeyModFlags(); - memcpy(g.IO.KeysDownDurationPrev, g.IO.KeysDownDuration, sizeof(g.IO.KeysDownDuration)); - for (int i = 0; i < IM_ARRAYSIZE(g.IO.KeysDown); i++) - g.IO.KeysDownDuration[i] = g.IO.KeysDown[i] ? (g.IO.KeysDownDuration[i] < 0.0f ? 0.0f : g.IO.KeysDownDuration[i] + g.IO.DeltaTime) : -1.0f; - - // Update gamepad/keyboard navigation - NavUpdate(); - - // Update mouse input state - UpdateMouseInputs(); - - // Find hovered window - // (needs to be before UpdateMouseMovingWindowNewFrame so we fill g.HoveredWindowUnderMovingWindow on the mouse release frame) - UpdateHoveredWindowAndCaptureFlags(); - - // Handle user moving window with mouse (at the beginning of the frame to avoid input lag or sheering) - UpdateMouseMovingWindowNewFrame(); - - // Background darkening/whitening - if (GetTopMostPopupModal() != NULL || (g.NavWindowingTarget != NULL && g.NavWindowingHighlightAlpha > 0.0f)) - g.DimBgRatio = ImMin(g.DimBgRatio + g.IO.DeltaTime * 6.0f, 1.0f); - else - g.DimBgRatio = ImMax(g.DimBgRatio - g.IO.DeltaTime * 10.0f, 0.0f); - - g.MouseCursor = ImGuiMouseCursor_Arrow; - g.WantCaptureMouseNextFrame = g.WantCaptureKeyboardNextFrame = g.WantTextInputNextFrame = -1; - g.PlatformImePos = ImVec2(1.0f, 1.0f); // OS Input Method Editor showing on top-left of our window by default - - // Mouse wheel scrolling, scale - UpdateMouseWheel(); - - // Update legacy TAB focus - UpdateTabFocus(); - - // Mark all windows as not visible and compact unused memory. - IM_ASSERT(g.WindowsFocusOrder.Size <= g.Windows.Size); - const float memory_compact_start_time = (g.GcCompactAll || g.IO.ConfigMemoryCompactTimer < 0.0f) ? FLT_MAX : (float)g.Time - g.IO.ConfigMemoryCompactTimer; - for (int i = 0; i != g.Windows.Size; i++) - { - ImGuiWindow* window = g.Windows[i]; - window->WasActive = window->Active; - window->BeginCount = 0; - window->Active = false; - window->WriteAccessed = false; - - // Garbage collect transient buffers of recently unused windows - if (!window->WasActive && !window->MemoryCompacted && window->LastTimeActive < memory_compact_start_time) - GcCompactTransientWindowBuffers(window); - } - - // Garbage collect transient buffers of recently unused tables - for (int i = 0; i < g.TablesLastTimeActive.Size; i++) - if (g.TablesLastTimeActive[i] >= 0.0f && g.TablesLastTimeActive[i] < memory_compact_start_time) - TableGcCompactTransientBuffers(g.Tables.GetByIndex(i)); - for (int i = 0; i < g.TablesTempDataStack.Size; i++) - if (g.TablesTempDataStack[i].LastTimeActive >= 0.0f && g.TablesTempDataStack[i].LastTimeActive < memory_compact_start_time) - TableGcCompactTransientBuffers(&g.TablesTempDataStack[i]); - if (g.GcCompactAll) - GcCompactTransientMiscBuffers(); - g.GcCompactAll = false; - - // Closing the focused window restore focus to the first active root window in descending z-order - if (g.NavWindow && !g.NavWindow->WasActive) - FocusTopMostWindowUnderOne(NULL, NULL); - - // No window should be open at the beginning of the frame. - // But in order to allow the user to call NewFrame() multiple times without calling Render(), we are doing an explicit clear. - g.CurrentWindowStack.resize(0); - g.BeginPopupStack.resize(0); - g.ItemFlagsStack.resize(0); - g.ItemFlagsStack.push_back(ImGuiItemFlags_None); - g.GroupStack.resize(0); - - // [DEBUG] Update debug features - UpdateDebugToolItemPicker(); - UpdateDebugToolStackQueries(); - - // Create implicit/fallback window - which we will only render it if the user has added something to it. - // We don't use "Debug" to avoid colliding with user trying to create a "Debug" window with custom flags. - // This fallback is particularly important as it avoid ImGui:: calls from crashing. - g.WithinFrameScopeWithImplicitWindow = true; - SetNextWindowSize(ImVec2(400, 400), ImGuiCond_FirstUseEver); - Begin("Debug##Default"); - IM_ASSERT(g.CurrentWindow->IsFallbackWindow == true); - - CallContextHooks(&g, ImGuiContextHookType_NewFramePost); -} - -void ImGui::Initialize(ImGuiContext* context) -{ - ImGuiContext& g = *context; - IM_ASSERT(!g.Initialized && !g.SettingsLoaded); - - // Add .ini handle for ImGuiWindow type - { - ImGuiSettingsHandler ini_handler; - ini_handler.TypeName = "Window"; - ini_handler.TypeHash = ImHashStr("Window"); - ini_handler.ClearAllFn = WindowSettingsHandler_ClearAll; - ini_handler.ReadOpenFn = WindowSettingsHandler_ReadOpen; - ini_handler.ReadLineFn = WindowSettingsHandler_ReadLine; - ini_handler.ApplyAllFn = WindowSettingsHandler_ApplyAll; - ini_handler.WriteAllFn = WindowSettingsHandler_WriteAll; - g.SettingsHandlers.push_back(ini_handler); - } - - // Add .ini handle for ImGuiTable type - TableSettingsInstallHandler(context); - - // Create default viewport - ImGuiViewportP* viewport = IM_NEW(ImGuiViewportP)(); - g.Viewports.push_back(viewport); - -#ifdef IMGUI_HAS_DOCK -#endif - - g.Initialized = true; -} - -// This function is merely here to free heap allocations. -void ImGui::Shutdown(ImGuiContext* context) -{ - // The fonts atlas can be used prior to calling NewFrame(), so we clear it even if g.Initialized is FALSE (which would happen if we never called NewFrame) - ImGuiContext& g = *context; - if (g.IO.Fonts && g.FontAtlasOwnedByContext) - { - g.IO.Fonts->Locked = false; - IM_DELETE(g.IO.Fonts); - } - g.IO.Fonts = NULL; - - // Cleanup of other data are conditional on actually having initialized Dear ImGui. - if (!g.Initialized) - return; - - // Save settings (unless we haven't attempted to load them: CreateContext/DestroyContext without a call to NewFrame shouldn't save an empty file) - if (g.SettingsLoaded && g.IO.IniFilename != NULL) - { - ImGuiContext* backup_context = GImGui; - SetCurrentContext(&g); - SaveIniSettingsToDisk(g.IO.IniFilename); - SetCurrentContext(backup_context); - } - - CallContextHooks(&g, ImGuiContextHookType_Shutdown); - - // Clear everything else - g.Windows.clear_delete(); - g.WindowsFocusOrder.clear(); - g.WindowsTempSortBuffer.clear(); - g.CurrentWindow = NULL; - g.CurrentWindowStack.clear(); - g.WindowsById.Clear(); - g.NavWindow = NULL; - g.HoveredWindow = g.HoveredWindowUnderMovingWindow = NULL; - g.ActiveIdWindow = g.ActiveIdPreviousFrameWindow = NULL; - g.MovingWindow = NULL; - g.ColorStack.clear(); - g.StyleVarStack.clear(); - g.FontStack.clear(); - g.OpenPopupStack.clear(); - g.BeginPopupStack.clear(); - - g.Viewports.clear_delete(); - - g.TabBars.Clear(); - g.CurrentTabBarStack.clear(); - g.ShrinkWidthBuffer.clear(); - - g.Tables.Clear(); - g.TablesTempDataStack.clear_destruct(); - g.DrawChannelsTempMergeBuffer.clear(); - - g.ClipboardHandlerData.clear(); - g.MenusIdSubmittedThisFrame.clear(); - g.InputTextState.ClearFreeMemory(); - - g.SettingsWindows.clear(); - g.SettingsHandlers.clear(); - - if (g.LogFile) - { -#ifndef IMGUI_DISABLE_TTY_FUNCTIONS - if (g.LogFile != stdout) -#endif - ImFileClose(g.LogFile); - g.LogFile = NULL; - } - g.LogBuffer.clear(); - - g.Initialized = false; -} - -// FIXME: Add a more explicit sort order in the window structure. -static int IMGUI_CDECL ChildWindowComparer(const void* lhs, const void* rhs) -{ - const ImGuiWindow* const a = *(const ImGuiWindow* const *)lhs; - const ImGuiWindow* const b = *(const ImGuiWindow* const *)rhs; - if (int d = (a->Flags & ImGuiWindowFlags_Popup) - (b->Flags & ImGuiWindowFlags_Popup)) - return d; - if (int d = (a->Flags & ImGuiWindowFlags_Tooltip) - (b->Flags & ImGuiWindowFlags_Tooltip)) - return d; - return (a->BeginOrderWithinParent - b->BeginOrderWithinParent); -} - -static void AddWindowToSortBuffer(ImVector* out_sorted_windows, ImGuiWindow* window) -{ - out_sorted_windows->push_back(window); - if (window->Active) - { - int count = window->DC.ChildWindows.Size; - if (count > 1) - ImQsort(window->DC.ChildWindows.Data, (size_t)count, sizeof(ImGuiWindow*), ChildWindowComparer); - for (int i = 0; i < count; i++) - { - ImGuiWindow* child = window->DC.ChildWindows[i]; - if (child->Active) - AddWindowToSortBuffer(out_sorted_windows, child); - } - } -} - -static void AddDrawListToDrawData(ImVector* out_list, ImDrawList* draw_list) -{ - // Remove trailing command if unused. - // Technically we could return directly instead of popping, but this make things looks neat in Metrics/Debugger window as well. - draw_list->_PopUnusedDrawCmd(); - if (draw_list->CmdBuffer.Size == 0) - return; - - // Draw list sanity check. Detect mismatch between PrimReserve() calls and incrementing _VtxCurrentIdx, _VtxWritePtr etc. - // May trigger for you if you are using PrimXXX functions incorrectly. - IM_ASSERT(draw_list->VtxBuffer.Size == 0 || draw_list->_VtxWritePtr == draw_list->VtxBuffer.Data + draw_list->VtxBuffer.Size); - IM_ASSERT(draw_list->IdxBuffer.Size == 0 || draw_list->_IdxWritePtr == draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size); - if (!(draw_list->Flags & ImDrawListFlags_AllowVtxOffset)) - IM_ASSERT((int)draw_list->_VtxCurrentIdx == draw_list->VtxBuffer.Size); - - // Check that draw_list doesn't use more vertices than indexable (default ImDrawIdx = unsigned short = 2 bytes = 64K vertices per ImDrawList = per window) - // If this assert triggers because you are drawing lots of stuff manually: - // - First, make sure you are coarse clipping yourself and not trying to draw many things outside visible bounds. - // Be mindful that the ImDrawList API doesn't filter vertices. Use the Metrics/Debugger window to inspect draw list contents. - // - If you want large meshes with more than 64K vertices, you can either: - // (A) Handle the ImDrawCmd::VtxOffset value in your renderer backend, and set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset'. - // Most example backends already support this from 1.71. Pre-1.71 backends won't. - // Some graphics API such as GL ES 1/2 don't have a way to offset the starting vertex so it is not supported for them. - // (B) Or handle 32-bit indices in your renderer backend, and uncomment '#define ImDrawIdx unsigned int' line in imconfig.h. - // Most example backends already support this. For example, the OpenGL example code detect index size at compile-time: - // glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer_offset); - // Your own engine or render API may use different parameters or function calls to specify index sizes. - // 2 and 4 bytes indices are generally supported by most graphics API. - // - If for some reason neither of those solutions works for you, a workaround is to call BeginChild()/EndChild() before reaching - // the 64K limit to split your draw commands in multiple draw lists. - if (sizeof(ImDrawIdx) == 2) - IM_ASSERT(draw_list->_VtxCurrentIdx < (1 << 16) && "Too many vertices in ImDrawList using 16-bit indices. Read comment above"); - - out_list->push_back(draw_list); -} - -static void AddWindowToDrawData(ImGuiWindow* window, int layer) -{ - ImGuiContext& g = *GImGui; - ImGuiViewportP* viewport = g.Viewports[0]; - g.IO.MetricsRenderWindows++; - AddDrawListToDrawData(&viewport->DrawDataBuilder.Layers[layer], window->DrawList); - for (int i = 0; i < window->DC.ChildWindows.Size; i++) - { - ImGuiWindow* child = window->DC.ChildWindows[i]; - if (IsWindowActiveAndVisible(child)) // Clipped children may have been marked not active - AddWindowToDrawData(child, layer); - } -} - -// Layer is locked for the root window, however child windows may use a different viewport (e.g. extruding menu) -static void AddRootWindowToDrawData(ImGuiWindow* window) -{ - int layer = (window->Flags & ImGuiWindowFlags_Tooltip) ? 1 : 0; - AddWindowToDrawData(window, layer); -} - -void ImDrawDataBuilder::FlattenIntoSingleLayer() -{ - int n = Layers[0].Size; - int size = n; - for (int i = 1; i < IM_ARRAYSIZE(Layers); i++) - size += Layers[i].Size; - Layers[0].resize(size); - for (int layer_n = 1; layer_n < IM_ARRAYSIZE(Layers); layer_n++) - { - ImVector& layer = Layers[layer_n]; - if (layer.empty()) - continue; - memcpy(&Layers[0][n], &layer[0], layer.Size * sizeof(ImDrawList*)); - n += layer.Size; - layer.resize(0); - } -} - -static void SetupViewportDrawData(ImGuiViewportP* viewport, ImVector* draw_lists) -{ - ImGuiIO& io = ImGui::GetIO(); - ImDrawData* draw_data = &viewport->DrawDataP; - draw_data->Valid = true; - draw_data->CmdLists = (draw_lists->Size > 0) ? draw_lists->Data : NULL; - draw_data->CmdListsCount = draw_lists->Size; - draw_data->TotalVtxCount = draw_data->TotalIdxCount = 0; - draw_data->DisplayPos = viewport->Pos; - draw_data->DisplaySize = viewport->Size; - draw_data->FramebufferScale = io.DisplayFramebufferScale; - for (int n = 0; n < draw_lists->Size; n++) - { - draw_data->TotalVtxCount += draw_lists->Data[n]->VtxBuffer.Size; - draw_data->TotalIdxCount += draw_lists->Data[n]->IdxBuffer.Size; - } -} - -// Push a clipping rectangle for both ImGui logic (hit-testing etc.) and low-level ImDrawList rendering. -// - When using this function it is sane to ensure that float are perfectly rounded to integer values, -// so that e.g. (int)(max.x-min.x) in user's render produce correct result. -// - If the code here changes, may need to update code of functions like NextColumn() and PushColumnClipRect(): -// some frequently called functions which to modify both channels and clipping simultaneously tend to use the -// more specialized SetWindowClipRectBeforeSetChannel() to avoid extraneous updates of underlying ImDrawCmds. -void ImGui::PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_current_clip_rect) -{ - ImGuiWindow* window = GetCurrentWindow(); - window->DrawList->PushClipRect(clip_rect_min, clip_rect_max, intersect_with_current_clip_rect); - window->ClipRect = window->DrawList->_ClipRectStack.back(); -} - -void ImGui::PopClipRect() -{ - ImGuiWindow* window = GetCurrentWindow(); - window->DrawList->PopClipRect(); - window->ClipRect = window->DrawList->_ClipRectStack.back(); -} - -// This is normally called by Render(). You may want to call it directly if you want to avoid calling Render() but the gain will be very minimal. -void ImGui::EndFrame() -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(g.Initialized); - - // Don't process EndFrame() multiple times. - if (g.FrameCountEnded == g.FrameCount) - return; - IM_ASSERT(g.WithinFrameScope && "Forgot to call ImGui::NewFrame()?"); - - CallContextHooks(&g, ImGuiContextHookType_EndFramePre); - - ErrorCheckEndFrameSanityChecks(); - - // Notify OS when our Input Method Editor cursor has moved (e.g. CJK inputs using Microsoft IME) - if (g.IO.ImeSetInputScreenPosFn && (g.PlatformImeLastPos.x == FLT_MAX || ImLengthSqr(g.PlatformImeLastPos - g.PlatformImePos) > 0.0001f)) - { - g.IO.ImeSetInputScreenPosFn((int)g.PlatformImePos.x, (int)g.PlatformImePos.y); - g.PlatformImeLastPos = g.PlatformImePos; - } - - // Hide implicit/fallback "Debug" window if it hasn't been used - g.WithinFrameScopeWithImplicitWindow = false; - if (g.CurrentWindow && !g.CurrentWindow->WriteAccessed) - g.CurrentWindow->Active = false; - End(); - - // Update navigation: CTRL+Tab, wrap-around requests - NavEndFrame(); - - // Drag and Drop: Elapse payload (if delivered, or if source stops being submitted) - if (g.DragDropActive) - { - bool is_delivered = g.DragDropPayload.Delivery; - bool is_elapsed = (g.DragDropPayload.DataFrameCount + 1 < g.FrameCount) && ((g.DragDropSourceFlags & ImGuiDragDropFlags_SourceAutoExpirePayload) || !IsMouseDown(g.DragDropMouseButton)); - if (is_delivered || is_elapsed) - ClearDragDrop(); - } - - // Drag and Drop: Fallback for source tooltip. This is not ideal but better than nothing. - if (g.DragDropActive && g.DragDropSourceFrameCount < g.FrameCount && !(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoPreviewTooltip)) - { - g.DragDropWithinSource = true; - SetTooltip("..."); - g.DragDropWithinSource = false; - } - - // End frame - g.WithinFrameScope = false; - g.FrameCountEnded = g.FrameCount; - - // Initiate moving window + handle left-click and right-click focus - UpdateMouseMovingWindowEndFrame(); - - // Sort the window list so that all child windows are after their parent - // We cannot do that on FocusWindow() because children may not exist yet - g.WindowsTempSortBuffer.resize(0); - g.WindowsTempSortBuffer.reserve(g.Windows.Size); - for (int i = 0; i != g.Windows.Size; i++) - { - ImGuiWindow* window = g.Windows[i]; - if (window->Active && (window->Flags & ImGuiWindowFlags_ChildWindow)) // if a child is active its parent will add it - continue; - AddWindowToSortBuffer(&g.WindowsTempSortBuffer, window); - } - - // This usually assert if there is a mismatch between the ImGuiWindowFlags_ChildWindow / ParentWindow values and DC.ChildWindows[] in parents, aka we've done something wrong. - IM_ASSERT(g.Windows.Size == g.WindowsTempSortBuffer.Size); - g.Windows.swap(g.WindowsTempSortBuffer); - g.IO.MetricsActiveWindows = g.WindowsActiveCount; - - // Unlock font atlas - g.IO.Fonts->Locked = false; - - // Clear Input data for next frame - g.IO.MouseWheel = g.IO.MouseWheelH = 0.0f; - g.IO.InputQueueCharacters.resize(0); - g.IO.KeyModsPrev = g.IO.KeyMods; // doing it here is better than in NewFrame() as we'll tolerate backend writing to KeyMods. If we want to firmly disallow it we should detect it. - memset(g.IO.NavInputs, 0, sizeof(g.IO.NavInputs)); - - CallContextHooks(&g, ImGuiContextHookType_EndFramePost); -} - -// Prepare the data for rendering so you can call GetDrawData() -// (As with anything within the ImGui:: namspace this doesn't touch your GPU or graphics API at all: -// it is the role of the ImGui_ImplXXXX_RenderDrawData() function provided by the renderer backend) -void ImGui::Render() -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(g.Initialized); - - if (g.FrameCountEnded != g.FrameCount) - EndFrame(); - g.FrameCountRendered = g.FrameCount; - g.IO.MetricsRenderWindows = 0; - - CallContextHooks(&g, ImGuiContextHookType_RenderPre); - - // Add background ImDrawList (for each active viewport) - for (int n = 0; n != g.Viewports.Size; n++) - { - ImGuiViewportP* viewport = g.Viewports[n]; - viewport->DrawDataBuilder.Clear(); - if (viewport->DrawLists[0] != NULL) - AddDrawListToDrawData(&viewport->DrawDataBuilder.Layers[0], GetBackgroundDrawList(viewport)); - } - - // Add ImDrawList to render - ImGuiWindow* windows_to_render_top_most[2]; - windows_to_render_top_most[0] = (g.NavWindowingTarget && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus)) ? g.NavWindowingTarget->RootWindow : NULL; - windows_to_render_top_most[1] = (g.NavWindowingTarget ? g.NavWindowingListWindow : NULL); - for (int n = 0; n != g.Windows.Size; n++) - { - ImGuiWindow* window = g.Windows[n]; - IM_MSVC_WARNING_SUPPRESS(6011); // Static Analysis false positive "warning C6011: Dereferencing NULL pointer 'window'" - if (IsWindowActiveAndVisible(window) && (window->Flags & ImGuiWindowFlags_ChildWindow) == 0 && window != windows_to_render_top_most[0] && window != windows_to_render_top_most[1]) - AddRootWindowToDrawData(window); - } - for (int n = 0; n < IM_ARRAYSIZE(windows_to_render_top_most); n++) - if (windows_to_render_top_most[n] && IsWindowActiveAndVisible(windows_to_render_top_most[n])) // NavWindowingTarget is always temporarily displayed as the top-most window - AddRootWindowToDrawData(windows_to_render_top_most[n]); - - // Setup ImDrawData structures for end-user - g.IO.MetricsRenderVertices = g.IO.MetricsRenderIndices = 0; - for (int n = 0; n < g.Viewports.Size; n++) - { - ImGuiViewportP* viewport = g.Viewports[n]; - viewport->DrawDataBuilder.FlattenIntoSingleLayer(); - - // Draw software mouse cursor if requested by io.MouseDrawCursor flag - if (g.IO.MouseDrawCursor) - RenderMouseCursor(GetForegroundDrawList(viewport), g.IO.MousePos, g.Style.MouseCursorScale, g.MouseCursor, IM_COL32_WHITE, IM_COL32_BLACK, IM_COL32(0, 0, 0, 48)); - - // Add foreground ImDrawList (for each active viewport) - if (viewport->DrawLists[1] != NULL) - AddDrawListToDrawData(&viewport->DrawDataBuilder.Layers[0], GetForegroundDrawList(viewport)); - - SetupViewportDrawData(viewport, &viewport->DrawDataBuilder.Layers[0]); - ImDrawData* draw_data = &viewport->DrawDataP; - g.IO.MetricsRenderVertices += draw_data->TotalVtxCount; - g.IO.MetricsRenderIndices += draw_data->TotalIdxCount; - } - - CallContextHooks(&g, ImGuiContextHookType_RenderPost); -} - -// Calculate text size. Text can be multi-line. Optionally ignore text after a ## marker. -// CalcTextSize("") should return ImVec2(0.0f, g.FontSize) -ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_text_after_double_hash, float wrap_width) -{ - ImGuiContext& g = *GImGui; - - const char* text_display_end; - if (hide_text_after_double_hash) - text_display_end = FindRenderedTextEnd(text, text_end); // Hide anything after a '##' string - else - text_display_end = text_end; - - ImFont* font = g.Font; - const float font_size = g.FontSize; - if (text == text_display_end) - return ImVec2(0.0f, font_size); - ImVec2 text_size = font->CalcTextSizeA(font_size, FLT_MAX, wrap_width, text, text_display_end, NULL); - - // Round - // FIXME: This has been here since Dec 2015 (7b0bf230) but down the line we want this out. - // FIXME: Investigate using ceilf or e.g. - // - https://git.musl-libc.org/cgit/musl/tree/src/math/ceilf.c - // - https://embarkstudios.github.io/rust-gpu/api/src/libm/math/ceilf.rs.html - text_size.x = IM_FLOOR(text_size.x + 0.99999f); - - return text_size; -} - -// Find window given position, search front-to-back -// FIXME: Note that we have an inconsequential lag here: OuterRectClipped is updated in Begin(), so windows moved programmatically -// with SetWindowPos() and not SetNextWindowPos() will have that rectangle lagging by a frame at the time FindHoveredWindow() is -// called, aka before the next Begin(). Moving window isn't affected. -static void FindHoveredWindow() -{ - ImGuiContext& g = *GImGui; - - ImGuiWindow* hovered_window = NULL; - ImGuiWindow* hovered_window_ignoring_moving_window = NULL; - if (g.MovingWindow && !(g.MovingWindow->Flags & ImGuiWindowFlags_NoMouseInputs)) - hovered_window = g.MovingWindow; - - ImVec2 padding_regular = g.Style.TouchExtraPadding; - ImVec2 padding_for_resize = g.IO.ConfigWindowsResizeFromEdges ? g.WindowsHoverPadding : padding_regular; - for (int i = g.Windows.Size - 1; i >= 0; i--) - { - ImGuiWindow* window = g.Windows[i]; - IM_MSVC_WARNING_SUPPRESS(28182); // [Static Analyzer] Dereferencing NULL pointer. - if (!window->Active || window->Hidden) - continue; - if (window->Flags & ImGuiWindowFlags_NoMouseInputs) - continue; - - // Using the clipped AABB, a child window will typically be clipped by its parent (not always) - ImRect bb(window->OuterRectClipped); - if (window->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize)) - bb.Expand(padding_regular); - else - bb.Expand(padding_for_resize); - if (!bb.Contains(g.IO.MousePos)) - continue; - - // Support for one rectangular hole in any given window - // FIXME: Consider generalizing hit-testing override (with more generic data, callback, etc.) (#1512) - if (window->HitTestHoleSize.x != 0) - { - ImVec2 hole_pos(window->Pos.x + (float)window->HitTestHoleOffset.x, window->Pos.y + (float)window->HitTestHoleOffset.y); - ImVec2 hole_size((float)window->HitTestHoleSize.x, (float)window->HitTestHoleSize.y); - if (ImRect(hole_pos, hole_pos + hole_size).Contains(g.IO.MousePos)) - continue; - } - - if (hovered_window == NULL) - hovered_window = window; - IM_MSVC_WARNING_SUPPRESS(28182); // [Static Analyzer] Dereferencing NULL pointer. - if (hovered_window_ignoring_moving_window == NULL && (!g.MovingWindow || window->RootWindow != g.MovingWindow->RootWindow)) - hovered_window_ignoring_moving_window = window; - if (hovered_window && hovered_window_ignoring_moving_window) - break; - } - - g.HoveredWindow = hovered_window; - g.HoveredWindowUnderMovingWindow = hovered_window_ignoring_moving_window; -} - -// Test if mouse cursor is hovering given rectangle -// NB- Rectangle is clipped by our current clip setting -// NB- Expand the rectangle to be generous on imprecise inputs systems (g.Style.TouchExtraPadding) -bool ImGui::IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip) -{ - ImGuiContext& g = *GImGui; - - // Clip - ImRect rect_clipped(r_min, r_max); - if (clip) - rect_clipped.ClipWith(g.CurrentWindow->ClipRect); - - // Expand for touch input - const ImRect rect_for_touch(rect_clipped.Min - g.Style.TouchExtraPadding, rect_clipped.Max + g.Style.TouchExtraPadding); - if (!rect_for_touch.Contains(g.IO.MousePos)) - return false; - return true; -} - -int ImGui::GetKeyIndex(ImGuiKey imgui_key) -{ - IM_ASSERT(imgui_key >= 0 && imgui_key < ImGuiKey_COUNT); - ImGuiContext& g = *GImGui; - return g.IO.KeyMap[imgui_key]; -} - -// Note that dear imgui doesn't know the semantic of each entry of io.KeysDown[]! -// Use your own indices/enums according to how your backend/engine stored them into io.KeysDown[]! -bool ImGui::IsKeyDown(int user_key_index) -{ - if (user_key_index < 0) - return false; - ImGuiContext& g = *GImGui; - IM_ASSERT(user_key_index >= 0 && user_key_index < IM_ARRAYSIZE(g.IO.KeysDown)); - return g.IO.KeysDown[user_key_index]; -} - -// t0 = previous time (e.g.: g.Time - g.IO.DeltaTime) -// t1 = current time (e.g.: g.Time) -// An event is triggered at: -// t = 0.0f t = repeat_delay, t = repeat_delay + repeat_rate*N -int ImGui::CalcTypematicRepeatAmount(float t0, float t1, float repeat_delay, float repeat_rate) -{ - if (t1 == 0.0f) - return 1; - if (t0 >= t1) - return 0; - if (repeat_rate <= 0.0f) - return (t0 < repeat_delay) && (t1 >= repeat_delay); - const int count_t0 = (t0 < repeat_delay) ? -1 : (int)((t0 - repeat_delay) / repeat_rate); - const int count_t1 = (t1 < repeat_delay) ? -1 : (int)((t1 - repeat_delay) / repeat_rate); - const int count = count_t1 - count_t0; - return count; -} - -int ImGui::GetKeyPressedAmount(int key_index, float repeat_delay, float repeat_rate) -{ - ImGuiContext& g = *GImGui; - if (key_index < 0) - return 0; - IM_ASSERT(key_index >= 0 && key_index < IM_ARRAYSIZE(g.IO.KeysDown)); - const float t = g.IO.KeysDownDuration[key_index]; - return CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, repeat_delay, repeat_rate); -} - -bool ImGui::IsKeyPressed(int user_key_index, bool repeat) -{ - ImGuiContext& g = *GImGui; - if (user_key_index < 0) - return false; - IM_ASSERT(user_key_index >= 0 && user_key_index < IM_ARRAYSIZE(g.IO.KeysDown)); - const float t = g.IO.KeysDownDuration[user_key_index]; - if (t == 0.0f) - return true; - if (repeat && t > g.IO.KeyRepeatDelay) - return GetKeyPressedAmount(user_key_index, g.IO.KeyRepeatDelay, g.IO.KeyRepeatRate) > 0; - return false; -} - -bool ImGui::IsKeyReleased(int user_key_index) -{ - ImGuiContext& g = *GImGui; - if (user_key_index < 0) return false; - IM_ASSERT(user_key_index >= 0 && user_key_index < IM_ARRAYSIZE(g.IO.KeysDown)); - return g.IO.KeysDownDurationPrev[user_key_index] >= 0.0f && !g.IO.KeysDown[user_key_index]; -} - -bool ImGui::IsMouseDown(ImGuiMouseButton button) -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); - return g.IO.MouseDown[button]; -} - -bool ImGui::IsMouseClicked(ImGuiMouseButton button, bool repeat) -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); - const float t = g.IO.MouseDownDuration[button]; - if (t == 0.0f) - return true; - - if (repeat && t > g.IO.KeyRepeatDelay) - { - // FIXME: 2019/05/03: Our old repeat code was wrong here and led to doubling the repeat rate, which made it an ok rate for repeat on mouse hold. - int amount = CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, g.IO.KeyRepeatDelay, g.IO.KeyRepeatRate * 0.50f); - if (amount > 0) - return true; - } - return false; -} - -bool ImGui::IsMouseReleased(ImGuiMouseButton button) -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); - return g.IO.MouseReleased[button]; -} - -bool ImGui::IsMouseDoubleClicked(ImGuiMouseButton button) -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); - return g.IO.MouseDoubleClicked[button]; -} - -// Return if a mouse click/drag went past the given threshold. Valid to call during the MouseReleased frame. -// [Internal] This doesn't test if the button is pressed -bool ImGui::IsMouseDragPastThreshold(ImGuiMouseButton button, float lock_threshold) -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); - if (lock_threshold < 0.0f) - lock_threshold = g.IO.MouseDragThreshold; - return g.IO.MouseDragMaxDistanceSqr[button] >= lock_threshold * lock_threshold; -} - -bool ImGui::IsMouseDragging(ImGuiMouseButton button, float lock_threshold) -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); - if (!g.IO.MouseDown[button]) - return false; - return IsMouseDragPastThreshold(button, lock_threshold); -} - -ImVec2 ImGui::GetMousePos() -{ - ImGuiContext& g = *GImGui; - return g.IO.MousePos; -} - -// NB: prefer to call right after BeginPopup(). At the time Selectable/MenuItem is activated, the popup is already closed! -ImVec2 ImGui::GetMousePosOnOpeningCurrentPopup() -{ - ImGuiContext& g = *GImGui; - if (g.BeginPopupStack.Size > 0) - return g.OpenPopupStack[g.BeginPopupStack.Size - 1].OpenMousePos; - return g.IO.MousePos; -} - -// We typically use ImVec2(-FLT_MAX,-FLT_MAX) to denote an invalid mouse position. -bool ImGui::IsMousePosValid(const ImVec2* mouse_pos) -{ - // The assert is only to silence a false-positive in XCode Static Analysis. - // Because GImGui is not dereferenced in every code path, the static analyzer assume that it may be NULL (which it doesn't for other functions). - IM_ASSERT(GImGui != NULL); - const float MOUSE_INVALID = -256000.0f; - ImVec2 p = mouse_pos ? *mouse_pos : GImGui->IO.MousePos; - return p.x >= MOUSE_INVALID && p.y >= MOUSE_INVALID; -} - -bool ImGui::IsAnyMouseDown() -{ - ImGuiContext& g = *GImGui; - for (int n = 0; n < IM_ARRAYSIZE(g.IO.MouseDown); n++) - if (g.IO.MouseDown[n]) - return true; - return false; -} - -// Return the delta from the initial clicking position while the mouse button is clicked or was just released. -// This is locked and return 0.0f until the mouse moves past a distance threshold at least once. -// NB: This is only valid if IsMousePosValid(). backends in theory should always keep mouse position valid when dragging even outside the client window. -ImVec2 ImGui::GetMouseDragDelta(ImGuiMouseButton button, float lock_threshold) -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); - if (lock_threshold < 0.0f) - lock_threshold = g.IO.MouseDragThreshold; - if (g.IO.MouseDown[button] || g.IO.MouseReleased[button]) - if (g.IO.MouseDragMaxDistanceSqr[button] >= lock_threshold * lock_threshold) - if (IsMousePosValid(&g.IO.MousePos) && IsMousePosValid(&g.IO.MouseClickedPos[button])) - return g.IO.MousePos - g.IO.MouseClickedPos[button]; - return ImVec2(0.0f, 0.0f); -} - -void ImGui::ResetMouseDragDelta(ImGuiMouseButton button) -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown)); - // NB: We don't need to reset g.IO.MouseDragMaxDistanceSqr - g.IO.MouseClickedPos[button] = g.IO.MousePos; -} - -ImGuiMouseCursor ImGui::GetMouseCursor() -{ - return GImGui->MouseCursor; -} - -void ImGui::SetMouseCursor(ImGuiMouseCursor cursor_type) -{ - GImGui->MouseCursor = cursor_type; -} - -void ImGui::CaptureKeyboardFromApp(bool capture) -{ - GImGui->WantCaptureKeyboardNextFrame = capture ? 1 : 0; -} - -void ImGui::CaptureMouseFromApp(bool capture) -{ - GImGui->WantCaptureMouseNextFrame = capture ? 1 : 0; -} - -bool ImGui::IsItemActive() -{ - ImGuiContext& g = *GImGui; - if (g.ActiveId) - return g.ActiveId == g.LastItemData.ID; - return false; -} - -bool ImGui::IsItemActivated() -{ - ImGuiContext& g = *GImGui; - if (g.ActiveId) - if (g.ActiveId == g.LastItemData.ID && g.ActiveIdPreviousFrame != g.LastItemData.ID) - return true; - return false; -} - -bool ImGui::IsItemDeactivated() -{ - ImGuiContext& g = *GImGui; - if (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HasDeactivated) - return (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_Deactivated) != 0; - return (g.ActiveIdPreviousFrame == g.LastItemData.ID && g.ActiveIdPreviousFrame != 0 && g.ActiveId != g.LastItemData.ID); -} - -bool ImGui::IsItemDeactivatedAfterEdit() -{ - ImGuiContext& g = *GImGui; - return IsItemDeactivated() && (g.ActiveIdPreviousFrameHasBeenEditedBefore || (g.ActiveId == 0 && g.ActiveIdHasBeenEditedBefore)); -} - -// == GetItemID() == GetFocusID() -bool ImGui::IsItemFocused() -{ - ImGuiContext& g = *GImGui; - if (g.NavId != g.LastItemData.ID || g.NavId == 0) - return false; - return true; -} - -// Important: this can be useful but it is NOT equivalent to the behavior of e.g.Button()! -// Most widgets have specific reactions based on mouse-up/down state, mouse position etc. -bool ImGui::IsItemClicked(ImGuiMouseButton mouse_button) -{ - return IsMouseClicked(mouse_button) && IsItemHovered(ImGuiHoveredFlags_None); -} - -bool ImGui::IsItemToggledOpen() -{ - ImGuiContext& g = *GImGui; - return (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_ToggledOpen) ? true : false; -} - -bool ImGui::IsItemToggledSelection() -{ - ImGuiContext& g = *GImGui; - return (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_ToggledSelection) ? true : false; -} - -bool ImGui::IsAnyItemHovered() -{ - ImGuiContext& g = *GImGui; - return g.HoveredId != 0 || g.HoveredIdPreviousFrame != 0; -} - -bool ImGui::IsAnyItemActive() -{ - ImGuiContext& g = *GImGui; - return g.ActiveId != 0; -} - -bool ImGui::IsAnyItemFocused() -{ - ImGuiContext& g = *GImGui; - return g.NavId != 0 && !g.NavDisableHighlight; -} - -bool ImGui::IsItemVisible() -{ - ImGuiContext& g = *GImGui; - return g.CurrentWindow->ClipRect.Overlaps(g.LastItemData.Rect); -} - -bool ImGui::IsItemEdited() -{ - ImGuiContext& g = *GImGui; - return (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_Edited) != 0; -} - -// Allow last item to be overlapped by a subsequent item. Both may be activated during the same frame before the later one takes priority. -// FIXME: Although this is exposed, its interaction and ideal idiom with using ImGuiButtonFlags_AllowItemOverlap flag are extremely confusing, need rework. -void ImGui::SetItemAllowOverlap() -{ - ImGuiContext& g = *GImGui; - ImGuiID id = g.LastItemData.ID; - if (g.HoveredId == id) - g.HoveredIdAllowOverlap = true; - if (g.ActiveId == id) - g.ActiveIdAllowOverlap = true; -} - -void ImGui::SetItemUsingMouseWheel() -{ - ImGuiContext& g = *GImGui; - ImGuiID id = g.LastItemData.ID; - if (g.HoveredId == id) - g.HoveredIdUsingMouseWheel = true; - if (g.ActiveId == id) - g.ActiveIdUsingMouseWheel = true; -} - -void ImGui::SetActiveIdUsingNavAndKeys() -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(g.ActiveId != 0); - g.ActiveIdUsingNavDirMask = ~(ImU32)0; - g.ActiveIdUsingNavInputMask = ~(ImU32)0; - g.ActiveIdUsingKeyInputMask = ~(ImU64)0; - NavMoveRequestCancel(); -} - -ImVec2 ImGui::GetItemRectMin() -{ - ImGuiContext& g = *GImGui; - return g.LastItemData.Rect.Min; -} - -ImVec2 ImGui::GetItemRectMax() -{ - ImGuiContext& g = *GImGui; - return g.LastItemData.Rect.Max; -} - -ImVec2 ImGui::GetItemRectSize() -{ - ImGuiContext& g = *GImGui; - return g.LastItemData.Rect.GetSize(); -} - -bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags flags) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* parent_window = g.CurrentWindow; - - flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_ChildWindow; - flags |= (parent_window->Flags & ImGuiWindowFlags_NoMove); // Inherit the NoMove flag - - // Size - const ImVec2 content_avail = GetContentRegionAvail(); - ImVec2 size = ImFloor(size_arg); - const int auto_fit_axises = ((size.x == 0.0f) ? (1 << ImGuiAxis_X) : 0x00) | ((size.y == 0.0f) ? (1 << ImGuiAxis_Y) : 0x00); - if (size.x <= 0.0f) - size.x = ImMax(content_avail.x + size.x, 4.0f); // Arbitrary minimum child size (0.0f causing too much issues) - if (size.y <= 0.0f) - size.y = ImMax(content_avail.y + size.y, 4.0f); - SetNextWindowSize(size); - - // Build up name. If you need to append to a same child from multiple location in the ID stack, use BeginChild(ImGuiID id) with a stable value. - if (name) - ImFormatString(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), "%s/%s_%08X", parent_window->Name, name, id); - else - ImFormatString(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), "%s/%08X", parent_window->Name, id); - - const float backup_border_size = g.Style.ChildBorderSize; - if (!border) - g.Style.ChildBorderSize = 0.0f; - bool ret = Begin(g.TempBuffer, NULL, flags); - g.Style.ChildBorderSize = backup_border_size; - - ImGuiWindow* child_window = g.CurrentWindow; - child_window->ChildId = id; - child_window->AutoFitChildAxises = (ImS8)auto_fit_axises; - - // Set the cursor to handle case where the user called SetNextWindowPos()+BeginChild() manually. - // While this is not really documented/defined, it seems that the expected thing to do. - if (child_window->BeginCount == 1) - parent_window->DC.CursorPos = child_window->Pos; - - // Process navigation-in immediately so NavInit can run on first frame - if (g.NavActivateId == id && !(flags & ImGuiWindowFlags_NavFlattened) && (child_window->DC.NavLayersActiveMask != 0 || child_window->DC.NavHasScroll)) - { - FocusWindow(child_window); - NavInitWindow(child_window, false); - SetActiveID(id + 1, child_window); // Steal ActiveId with another arbitrary id so that key-press won't activate child item - g.ActiveIdSource = ImGuiInputSource_Nav; - } - return ret; -} - -bool ImGui::BeginChild(const char* str_id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags) -{ - ImGuiWindow* window = GetCurrentWindow(); - return BeginChildEx(str_id, window->GetID(str_id), size_arg, border, extra_flags); -} - -bool ImGui::BeginChild(ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags) -{ - IM_ASSERT(id != 0); - return BeginChildEx(NULL, id, size_arg, border, extra_flags); -} - -void ImGui::EndChild() -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - - IM_ASSERT(g.WithinEndChild == false); - IM_ASSERT(window->Flags & ImGuiWindowFlags_ChildWindow); // Mismatched BeginChild()/EndChild() calls - - g.WithinEndChild = true; - if (window->BeginCount > 1) - { - End(); - } - else - { - ImVec2 sz = window->Size; - if (window->AutoFitChildAxises & (1 << ImGuiAxis_X)) // Arbitrary minimum zero-ish child size of 4.0f causes less trouble than a 0.0f - sz.x = ImMax(4.0f, sz.x); - if (window->AutoFitChildAxises & (1 << ImGuiAxis_Y)) - sz.y = ImMax(4.0f, sz.y); - End(); - - ImGuiWindow* parent_window = g.CurrentWindow; - ImRect bb(parent_window->DC.CursorPos, parent_window->DC.CursorPos + sz); - ItemSize(sz); - if ((window->DC.NavLayersActiveMask != 0 || window->DC.NavHasScroll) && !(window->Flags & ImGuiWindowFlags_NavFlattened)) - { - ItemAdd(bb, window->ChildId); - RenderNavHighlight(bb, window->ChildId); - - // When browsing a window that has no activable items (scroll only) we keep a highlight on the child (pass g.NavId to trick into always displaying) - if (window->DC.NavLayersActiveMask == 0 && window == g.NavWindow) - RenderNavHighlight(ImRect(bb.Min - ImVec2(2, 2), bb.Max + ImVec2(2, 2)), g.NavId, ImGuiNavHighlightFlags_TypeThin); - } - else - { - // Not navigable into - ItemAdd(bb, 0); - } - if (g.HoveredWindow == window) - g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HoveredWindow; - } - g.WithinEndChild = false; - g.LogLinePosY = -FLT_MAX; // To enforce a carriage return -} - -// Helper to create a child window / scrolling region that looks like a normal widget frame. -bool ImGui::BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags extra_flags) -{ - ImGuiContext& g = *GImGui; - const ImGuiStyle& style = g.Style; - PushStyleColor(ImGuiCol_ChildBg, style.Colors[ImGuiCol_FrameBg]); - PushStyleVar(ImGuiStyleVar_ChildRounding, style.FrameRounding); - PushStyleVar(ImGuiStyleVar_ChildBorderSize, style.FrameBorderSize); - PushStyleVar(ImGuiStyleVar_WindowPadding, style.FramePadding); - bool ret = BeginChild(id, size, true, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysUseWindowPadding | extra_flags); - PopStyleVar(3); - PopStyleColor(); - return ret; -} - -void ImGui::EndChildFrame() -{ - EndChild(); -} - -static void SetWindowConditionAllowFlags(ImGuiWindow* window, ImGuiCond flags, bool enabled) -{ - window->SetWindowPosAllowFlags = enabled ? (window->SetWindowPosAllowFlags | flags) : (window->SetWindowPosAllowFlags & ~flags); - window->SetWindowSizeAllowFlags = enabled ? (window->SetWindowSizeAllowFlags | flags) : (window->SetWindowSizeAllowFlags & ~flags); - window->SetWindowCollapsedAllowFlags = enabled ? (window->SetWindowCollapsedAllowFlags | flags) : (window->SetWindowCollapsedAllowFlags & ~flags); -} - -ImGuiWindow* ImGui::FindWindowByID(ImGuiID id) -{ - ImGuiContext& g = *GImGui; - return (ImGuiWindow*)g.WindowsById.GetVoidPtr(id); -} - -ImGuiWindow* ImGui::FindWindowByName(const char* name) -{ - ImGuiID id = ImHashStr(name); - return FindWindowByID(id); -} - -static void ApplyWindowSettings(ImGuiWindow* window, ImGuiWindowSettings* settings) -{ - window->Pos = ImFloor(ImVec2(settings->Pos.x, settings->Pos.y)); - if (settings->Size.x > 0 && settings->Size.y > 0) - window->Size = window->SizeFull = ImFloor(ImVec2(settings->Size.x, settings->Size.y)); - window->Collapsed = settings->Collapsed; -} - -static ImGuiWindow* CreateNewWindow(const char* name, ImGuiWindowFlags flags) -{ - ImGuiContext& g = *GImGui; - //IMGUI_DEBUG_LOG("CreateNewWindow '%s', flags = 0x%08X\n", name, flags); - - // Create window the first time - ImGuiWindow* window = IM_NEW(ImGuiWindow)(&g, name); - window->Flags = flags; - g.WindowsById.SetVoidPtr(window->ID, window); - - // Default/arbitrary window position. Use SetNextWindowPos() with the appropriate condition flag to change the initial position of a window. - const ImGuiViewport* main_viewport = ImGui::GetMainViewport(); - window->Pos = main_viewport->Pos + ImVec2(60, 60); - - // User can disable loading and saving of settings. Tooltip and child windows also don't store settings. - if (!(flags & ImGuiWindowFlags_NoSavedSettings)) - if (ImGuiWindowSettings* settings = ImGui::FindWindowSettings(window->ID)) - { - // Retrieve settings from .ini file - window->SettingsOffset = g.SettingsWindows.offset_from_ptr(settings); - SetWindowConditionAllowFlags(window, ImGuiCond_FirstUseEver, false); - ApplyWindowSettings(window, settings); - } - window->DC.CursorStartPos = window->DC.CursorMaxPos = window->Pos; // So first call to CalcContentSize() doesn't return crazy values - - if ((flags & ImGuiWindowFlags_AlwaysAutoResize) != 0) - { - window->AutoFitFramesX = window->AutoFitFramesY = 2; - window->AutoFitOnlyGrows = false; - } - else - { - if (window->Size.x <= 0.0f) - window->AutoFitFramesX = 2; - if (window->Size.y <= 0.0f) - window->AutoFitFramesY = 2; - window->AutoFitOnlyGrows = (window->AutoFitFramesX > 0) || (window->AutoFitFramesY > 0); - } - - if (!(flags & ImGuiWindowFlags_ChildWindow)) - { - g.WindowsFocusOrder.push_back(window); - window->FocusOrder = (short)(g.WindowsFocusOrder.Size - 1); - } - - if (flags & ImGuiWindowFlags_NoBringToFrontOnFocus) - g.Windows.push_front(window); // Quite slow but rare and only once - else - g.Windows.push_back(window); - return window; -} - -static ImVec2 CalcWindowSizeAfterConstraint(ImGuiWindow* window, const ImVec2& size_desired) -{ - ImGuiContext& g = *GImGui; - ImVec2 new_size = size_desired; - if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSizeConstraint) - { - // Using -1,-1 on either X/Y axis to preserve the current size. - ImRect cr = g.NextWindowData.SizeConstraintRect; - new_size.x = (cr.Min.x >= 0 && cr.Max.x >= 0) ? ImClamp(new_size.x, cr.Min.x, cr.Max.x) : window->SizeFull.x; - new_size.y = (cr.Min.y >= 0 && cr.Max.y >= 0) ? ImClamp(new_size.y, cr.Min.y, cr.Max.y) : window->SizeFull.y; - if (g.NextWindowData.SizeCallback) - { - ImGuiSizeCallbackData data; - data.UserData = g.NextWindowData.SizeCallbackUserData; - data.Pos = window->Pos; - data.CurrentSize = window->SizeFull; - data.DesiredSize = new_size; - g.NextWindowData.SizeCallback(&data); - new_size = data.DesiredSize; - } - new_size.x = IM_FLOOR(new_size.x); - new_size.y = IM_FLOOR(new_size.y); - } - - // Minimum size - if (!(window->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_AlwaysAutoResize))) - { - ImGuiWindow* window_for_height = window; - const float decoration_up_height = window_for_height->TitleBarHeight() + window_for_height->MenuBarHeight(); - new_size = ImMax(new_size, g.Style.WindowMinSize); - new_size.y = ImMax(new_size.y, decoration_up_height + ImMax(0.0f, g.Style.WindowRounding - 1.0f)); // Reduce artifacts with very small windows - } - return new_size; -} - -static void CalcWindowContentSizes(ImGuiWindow* window, ImVec2* content_size_current, ImVec2* content_size_ideal) -{ - bool preserve_old_content_sizes = false; - if (window->Collapsed && window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0) - preserve_old_content_sizes = true; - else if (window->Hidden && window->HiddenFramesCannotSkipItems == 0 && window->HiddenFramesCanSkipItems > 0) - preserve_old_content_sizes = true; - if (preserve_old_content_sizes) - { - *content_size_current = window->ContentSize; - *content_size_ideal = window->ContentSizeIdeal; - return; - } - - content_size_current->x = (window->ContentSizeExplicit.x != 0.0f) ? window->ContentSizeExplicit.x : IM_FLOOR(window->DC.CursorMaxPos.x - window->DC.CursorStartPos.x); - content_size_current->y = (window->ContentSizeExplicit.y != 0.0f) ? window->ContentSizeExplicit.y : IM_FLOOR(window->DC.CursorMaxPos.y - window->DC.CursorStartPos.y); - content_size_ideal->x = (window->ContentSizeExplicit.x != 0.0f) ? window->ContentSizeExplicit.x : IM_FLOOR(ImMax(window->DC.CursorMaxPos.x, window->DC.IdealMaxPos.x) - window->DC.CursorStartPos.x); - content_size_ideal->y = (window->ContentSizeExplicit.y != 0.0f) ? window->ContentSizeExplicit.y : IM_FLOOR(ImMax(window->DC.CursorMaxPos.y, window->DC.IdealMaxPos.y) - window->DC.CursorStartPos.y); -} - -static ImVec2 CalcWindowAutoFitSize(ImGuiWindow* window, const ImVec2& size_contents) -{ - ImGuiContext& g = *GImGui; - ImGuiStyle& style = g.Style; - const float decoration_up_height = window->TitleBarHeight() + window->MenuBarHeight(); - ImVec2 size_pad = window->WindowPadding * 2.0f; - ImVec2 size_desired = size_contents + size_pad + ImVec2(0.0f, decoration_up_height); - if (window->Flags & ImGuiWindowFlags_Tooltip) - { - // Tooltip always resize - return size_desired; - } - else - { - // Maximum window size is determined by the viewport size or monitor size - const bool is_popup = (window->Flags & ImGuiWindowFlags_Popup) != 0; - const bool is_menu = (window->Flags & ImGuiWindowFlags_ChildMenu) != 0; - ImVec2 size_min = style.WindowMinSize; - if (is_popup || is_menu) // Popups and menus bypass style.WindowMinSize by default, but we give then a non-zero minimum size to facilitate understanding problematic cases (e.g. empty popups) - size_min = ImMin(size_min, ImVec2(4.0f, 4.0f)); - - // FIXME-VIEWPORT-WORKAREA: May want to use GetWorkSize() instead of Size depending on the type of windows? - ImVec2 avail_size = ImGui::GetMainViewport()->Size; - ImVec2 size_auto_fit = ImClamp(size_desired, size_min, ImMax(size_min, avail_size - style.DisplaySafeAreaPadding * 2.0f)); - - // When the window cannot fit all contents (either because of constraints, either because screen is too small), - // we are growing the size on the other axis to compensate for expected scrollbar. FIXME: Might turn bigger than ViewportSize-WindowPadding. - ImVec2 size_auto_fit_after_constraint = CalcWindowSizeAfterConstraint(window, size_auto_fit); - bool will_have_scrollbar_x = (size_auto_fit_after_constraint.x - size_pad.x - 0.0f < size_contents.x && !(window->Flags & ImGuiWindowFlags_NoScrollbar) && (window->Flags & ImGuiWindowFlags_HorizontalScrollbar)) || (window->Flags & ImGuiWindowFlags_AlwaysHorizontalScrollbar); - bool will_have_scrollbar_y = (size_auto_fit_after_constraint.y - size_pad.y - decoration_up_height < size_contents.y && !(window->Flags & ImGuiWindowFlags_NoScrollbar)) || (window->Flags & ImGuiWindowFlags_AlwaysVerticalScrollbar); - if (will_have_scrollbar_x) - size_auto_fit.y += style.ScrollbarSize; - if (will_have_scrollbar_y) - size_auto_fit.x += style.ScrollbarSize; - return size_auto_fit; - } -} - -ImVec2 ImGui::CalcWindowNextAutoFitSize(ImGuiWindow* window) -{ - ImVec2 size_contents_current; - ImVec2 size_contents_ideal; - CalcWindowContentSizes(window, &size_contents_current, &size_contents_ideal); - ImVec2 size_auto_fit = CalcWindowAutoFitSize(window, size_contents_ideal); - ImVec2 size_final = CalcWindowSizeAfterConstraint(window, size_auto_fit); - return size_final; -} - -static ImGuiCol GetWindowBgColorIdxFromFlags(ImGuiWindowFlags flags) -{ - if (flags & (ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_Popup)) - return ImGuiCol_PopupBg; - if (flags & ImGuiWindowFlags_ChildWindow) - return ImGuiCol_ChildBg; - return ImGuiCol_WindowBg; -} - -static void CalcResizePosSizeFromAnyCorner(ImGuiWindow* window, const ImVec2& corner_target, const ImVec2& corner_norm, ImVec2* out_pos, ImVec2* out_size) -{ - ImVec2 pos_min = ImLerp(corner_target, window->Pos, corner_norm); // Expected window upper-left - ImVec2 pos_max = ImLerp(window->Pos + window->Size, corner_target, corner_norm); // Expected window lower-right - ImVec2 size_expected = pos_max - pos_min; - ImVec2 size_constrained = CalcWindowSizeAfterConstraint(window, size_expected); - *out_pos = pos_min; - if (corner_norm.x == 0.0f) - out_pos->x -= (size_constrained.x - size_expected.x); - if (corner_norm.y == 0.0f) - out_pos->y -= (size_constrained.y - size_expected.y); - *out_size = size_constrained; -} - -// Data for resizing from corner -struct ImGuiResizeGripDef -{ - ImVec2 CornerPosN; - ImVec2 InnerDir; - int AngleMin12, AngleMax12; -}; -static const ImGuiResizeGripDef resize_grip_def[4] = -{ - { ImVec2(1, 1), ImVec2(-1, -1), 0, 3 }, // Lower-right - { ImVec2(0, 1), ImVec2(+1, -1), 3, 6 }, // Lower-left - { ImVec2(0, 0), ImVec2(+1, +1), 6, 9 }, // Upper-left (Unused) - { ImVec2(1, 0), ImVec2(-1, +1), 9, 12 } // Upper-right (Unused) -}; - -// Data for resizing from borders -struct ImGuiResizeBorderDef -{ - ImVec2 InnerDir; - ImVec2 SegmentN1, SegmentN2; - float OuterAngle; -}; -static const ImGuiResizeBorderDef resize_border_def[4] = -{ - { ImVec2(+1, 0), ImVec2(0, 1), ImVec2(0, 0), IM_PI * 1.00f }, // Left - { ImVec2(-1, 0), ImVec2(1, 0), ImVec2(1, 1), IM_PI * 0.00f }, // Right - { ImVec2(0, +1), ImVec2(0, 0), ImVec2(1, 0), IM_PI * 1.50f }, // Up - { ImVec2(0, -1), ImVec2(1, 1), ImVec2(0, 1), IM_PI * 0.50f } // Down -}; - -static ImRect GetResizeBorderRect(ImGuiWindow* window, int border_n, float perp_padding, float thickness) -{ - ImRect rect = window->Rect(); - if (thickness == 0.0f) - rect.Max -= ImVec2(1, 1); - if (border_n == ImGuiDir_Left) { return ImRect(rect.Min.x - thickness, rect.Min.y + perp_padding, rect.Min.x + thickness, rect.Max.y - perp_padding); } - if (border_n == ImGuiDir_Right) { return ImRect(rect.Max.x - thickness, rect.Min.y + perp_padding, rect.Max.x + thickness, rect.Max.y - perp_padding); } - if (border_n == ImGuiDir_Up) { return ImRect(rect.Min.x + perp_padding, rect.Min.y - thickness, rect.Max.x - perp_padding, rect.Min.y + thickness); } - if (border_n == ImGuiDir_Down) { return ImRect(rect.Min.x + perp_padding, rect.Max.y - thickness, rect.Max.x - perp_padding, rect.Max.y + thickness); } - IM_ASSERT(0); - return ImRect(); -} - -// 0..3: corners (Lower-right, Lower-left, Unused, Unused) -ImGuiID ImGui::GetWindowResizeCornerID(ImGuiWindow* window, int n) -{ - IM_ASSERT(n >= 0 && n < 4); - ImGuiID id = window->ID; - id = ImHashStr("#RESIZE", 0, id); - id = ImHashData(&n, sizeof(int), id); - return id; -} - -// Borders (Left, Right, Up, Down) -ImGuiID ImGui::GetWindowResizeBorderID(ImGuiWindow* window, ImGuiDir dir) -{ - IM_ASSERT(dir >= 0 && dir < 4); - int n = (int)dir + 4; - ImGuiID id = window->ID; - id = ImHashStr("#RESIZE", 0, id); - id = ImHashData(&n, sizeof(int), id); - return id; -} - -// Handle resize for: Resize Grips, Borders, Gamepad -// Return true when using auto-fit (double click on resize grip) -static bool ImGui::UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4], const ImRect& visibility_rect) -{ - ImGuiContext& g = *GImGui; - ImGuiWindowFlags flags = window->Flags; - - if ((flags & ImGuiWindowFlags_NoResize) || (flags & ImGuiWindowFlags_AlwaysAutoResize) || window->AutoFitFramesX > 0 || window->AutoFitFramesY > 0) - return false; - if (window->WasActive == false) // Early out to avoid running this code for e.g. an hidden implicit/fallback Debug window. - return false; - - bool ret_auto_fit = false; - const int resize_border_count = g.IO.ConfigWindowsResizeFromEdges ? 4 : 0; - const float grip_draw_size = IM_FLOOR(ImMax(g.FontSize * 1.35f, window->WindowRounding + 1.0f + g.FontSize * 0.2f)); - const float grip_hover_inner_size = IM_FLOOR(grip_draw_size * 0.75f); - const float grip_hover_outer_size = g.IO.ConfigWindowsResizeFromEdges ? WINDOWS_HOVER_PADDING : 0.0f; - - ImVec2 pos_target(FLT_MAX, FLT_MAX); - ImVec2 size_target(FLT_MAX, FLT_MAX); - - // Resize grips and borders are on layer 1 - window->DC.NavLayerCurrent = ImGuiNavLayer_Menu; - - // Manual resize grips - PushID("#RESIZE"); - for (int resize_grip_n = 0; resize_grip_n < resize_grip_count; resize_grip_n++) - { - const ImGuiResizeGripDef& def = resize_grip_def[resize_grip_n]; - const ImVec2 corner = ImLerp(window->Pos, window->Pos + window->Size, def.CornerPosN); - - // Using the FlattenChilds button flag we make the resize button accessible even if we are hovering over a child window - bool hovered, held; - ImRect resize_rect(corner - def.InnerDir * grip_hover_outer_size, corner + def.InnerDir * grip_hover_inner_size); - if (resize_rect.Min.x > resize_rect.Max.x) ImSwap(resize_rect.Min.x, resize_rect.Max.x); - if (resize_rect.Min.y > resize_rect.Max.y) ImSwap(resize_rect.Min.y, resize_rect.Max.y); - ImGuiID resize_grip_id = window->GetID(resize_grip_n); // == GetWindowResizeCornerID() - ButtonBehavior(resize_rect, resize_grip_id, &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_NoNavFocus); - //GetForegroundDrawList(window)->AddRect(resize_rect.Min, resize_rect.Max, IM_COL32(255, 255, 0, 255)); - if (hovered || held) - g.MouseCursor = (resize_grip_n & 1) ? ImGuiMouseCursor_ResizeNESW : ImGuiMouseCursor_ResizeNWSE; - - if (held && g.IO.MouseDoubleClicked[0] && resize_grip_n == 0) - { - // Manual auto-fit when double-clicking - size_target = CalcWindowSizeAfterConstraint(window, size_auto_fit); - ret_auto_fit = true; - ClearActiveID(); - } - else if (held) - { - // Resize from any of the four corners - // We don't use an incremental MouseDelta but rather compute an absolute target size based on mouse position - ImVec2 clamp_min = ImVec2(def.CornerPosN.x == 1.0f ? visibility_rect.Min.x : -FLT_MAX, def.CornerPosN.y == 1.0f ? visibility_rect.Min.y : -FLT_MAX); - ImVec2 clamp_max = ImVec2(def.CornerPosN.x == 0.0f ? visibility_rect.Max.x : +FLT_MAX, def.CornerPosN.y == 0.0f ? visibility_rect.Max.y : +FLT_MAX); - ImVec2 corner_target = g.IO.MousePos - g.ActiveIdClickOffset + ImLerp(def.InnerDir * grip_hover_outer_size, def.InnerDir * -grip_hover_inner_size, def.CornerPosN); // Corner of the window corresponding to our corner grip - corner_target = ImClamp(corner_target, clamp_min, clamp_max); - CalcResizePosSizeFromAnyCorner(window, corner_target, def.CornerPosN, &pos_target, &size_target); - } - - // Only lower-left grip is visible before hovering/activating - if (resize_grip_n == 0 || held || hovered) - resize_grip_col[resize_grip_n] = GetColorU32(held ? ImGuiCol_ResizeGripActive : hovered ? ImGuiCol_ResizeGripHovered : ImGuiCol_ResizeGrip); - } - for (int border_n = 0; border_n < resize_border_count; border_n++) - { - const ImGuiResizeBorderDef& def = resize_border_def[border_n]; - const ImGuiAxis axis = (border_n == ImGuiDir_Left || border_n == ImGuiDir_Right) ? ImGuiAxis_X : ImGuiAxis_Y; - - bool hovered, held; - ImRect border_rect = GetResizeBorderRect(window, border_n, grip_hover_inner_size, WINDOWS_HOVER_PADDING); - ImGuiID border_id = window->GetID(border_n + 4); // == GetWindowResizeBorderID() - ButtonBehavior(border_rect, border_id, &hovered, &held, ImGuiButtonFlags_FlattenChildren); - //GetForegroundDrawLists(window)->AddRect(border_rect.Min, border_rect.Max, IM_COL32(255, 255, 0, 255)); - if ((hovered && g.HoveredIdTimer > WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER) || held) - { - g.MouseCursor = (axis == ImGuiAxis_X) ? ImGuiMouseCursor_ResizeEW : ImGuiMouseCursor_ResizeNS; - if (held) - *border_held = border_n; - } - if (held) - { - ImVec2 clamp_min(border_n == ImGuiDir_Right ? visibility_rect.Min.x : -FLT_MAX, border_n == ImGuiDir_Down ? visibility_rect.Min.y : -FLT_MAX); - ImVec2 clamp_max(border_n == ImGuiDir_Left ? visibility_rect.Max.x : +FLT_MAX, border_n == ImGuiDir_Up ? visibility_rect.Max.y : +FLT_MAX); - ImVec2 border_target = window->Pos; - border_target[axis] = g.IO.MousePos[axis] - g.ActiveIdClickOffset[axis] + WINDOWS_HOVER_PADDING; - border_target = ImClamp(border_target, clamp_min, clamp_max); - CalcResizePosSizeFromAnyCorner(window, border_target, ImMin(def.SegmentN1, def.SegmentN2), &pos_target, &size_target); - } - } - PopID(); - - // Restore nav layer - window->DC.NavLayerCurrent = ImGuiNavLayer_Main; - - // Navigation resize (keyboard/gamepad) - if (g.NavWindowingTarget && g.NavWindowingTarget->RootWindow == window) - { - ImVec2 nav_resize_delta; - if (g.NavInputSource == ImGuiInputSource_Keyboard && g.IO.KeyShift) - nav_resize_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard, ImGuiInputReadMode_Down); - if (g.NavInputSource == ImGuiInputSource_Gamepad) - nav_resize_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadDPad, ImGuiInputReadMode_Down); - if (nav_resize_delta.x != 0.0f || nav_resize_delta.y != 0.0f) - { - const float NAV_RESIZE_SPEED = 600.0f; - nav_resize_delta *= ImFloor(NAV_RESIZE_SPEED * g.IO.DeltaTime * ImMin(g.IO.DisplayFramebufferScale.x, g.IO.DisplayFramebufferScale.y)); - nav_resize_delta = ImMax(nav_resize_delta, visibility_rect.Min - window->Pos - window->Size); - g.NavWindowingToggleLayer = false; - g.NavDisableMouseHover = true; - resize_grip_col[0] = GetColorU32(ImGuiCol_ResizeGripActive); - // FIXME-NAV: Should store and accumulate into a separate size buffer to handle sizing constraints properly, right now a constraint will make us stuck. - size_target = CalcWindowSizeAfterConstraint(window, window->SizeFull + nav_resize_delta); - } - } - - // Apply back modified position/size to window - if (size_target.x != FLT_MAX) - { - window->SizeFull = size_target; - MarkIniSettingsDirty(window); - } - if (pos_target.x != FLT_MAX) - { - window->Pos = ImFloor(pos_target); - MarkIniSettingsDirty(window); - } - - window->Size = window->SizeFull; - return ret_auto_fit; -} - -static inline void ClampWindowRect(ImGuiWindow* window, const ImRect& visibility_rect) -{ - ImGuiContext& g = *GImGui; - ImVec2 size_for_clamping = window->Size; - if (g.IO.ConfigWindowsMoveFromTitleBarOnly && !(window->Flags & ImGuiWindowFlags_NoTitleBar)) - size_for_clamping.y = window->TitleBarHeight(); - window->Pos = ImClamp(window->Pos, visibility_rect.Min - size_for_clamping, visibility_rect.Max); -} - -static void ImGui::RenderWindowOuterBorders(ImGuiWindow* window) -{ - ImGuiContext& g = *GImGui; - float rounding = window->WindowRounding; - float border_size = window->WindowBorderSize; - if (border_size > 0.0f && !(window->Flags & ImGuiWindowFlags_NoBackground)) - window->DrawList->AddRect(window->Pos, window->Pos + window->Size, GetColorU32(ImGuiCol_Border), rounding, 0, border_size); - - int border_held = window->ResizeBorderHeld; - if (border_held != -1) - { - const ImGuiResizeBorderDef& def = resize_border_def[border_held]; - ImRect border_r = GetResizeBorderRect(window, border_held, rounding, 0.0f); - window->DrawList->PathArcTo(ImLerp(border_r.Min, border_r.Max, def.SegmentN1) + ImVec2(0.5f, 0.5f) + def.InnerDir * rounding, rounding, def.OuterAngle - IM_PI * 0.25f, def.OuterAngle); - window->DrawList->PathArcTo(ImLerp(border_r.Min, border_r.Max, def.SegmentN2) + ImVec2(0.5f, 0.5f) + def.InnerDir * rounding, rounding, def.OuterAngle, def.OuterAngle + IM_PI * 0.25f); - window->DrawList->PathStroke(GetColorU32(ImGuiCol_SeparatorActive), 0, ImMax(2.0f, border_size)); // Thicker than usual - } - if (g.Style.FrameBorderSize > 0 && !(window->Flags & ImGuiWindowFlags_NoTitleBar)) - { - float y = window->Pos.y + window->TitleBarHeight() - 1; - window->DrawList->AddLine(ImVec2(window->Pos.x + border_size, y), ImVec2(window->Pos.x + window->Size.x - border_size, y), GetColorU32(ImGuiCol_Border), g.Style.FrameBorderSize); - } -} - -// Draw background and borders -// Draw and handle scrollbars -void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar_rect, bool title_bar_is_highlight, int resize_grip_count, const ImU32 resize_grip_col[4], float resize_grip_draw_size) -{ - ImGuiContext& g = *GImGui; - ImGuiStyle& style = g.Style; - ImGuiWindowFlags flags = window->Flags; - - // Ensure that ScrollBar doesn't read last frame's SkipItems - IM_ASSERT(window->BeginCount == 0); - window->SkipItems = false; - - // Draw window + handle manual resize - // As we highlight the title bar when want_focus is set, multiple reappearing windows will have have their title bar highlighted on their reappearing frame. - const float window_rounding = window->WindowRounding; - const float window_border_size = window->WindowBorderSize; - if (window->Collapsed) - { - // Title bar only - float backup_border_size = style.FrameBorderSize; - g.Style.FrameBorderSize = window->WindowBorderSize; - ImU32 title_bar_col = GetColorU32((title_bar_is_highlight && !g.NavDisableHighlight) ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBgCollapsed); - RenderFrame(title_bar_rect.Min, title_bar_rect.Max, title_bar_col, true, window_rounding); - g.Style.FrameBorderSize = backup_border_size; - } - else - { - // Window background - if (!(flags & ImGuiWindowFlags_NoBackground)) - { - ImU32 bg_col = GetColorU32(GetWindowBgColorIdxFromFlags(flags)); - bool override_alpha = false; - float alpha = 1.0f; - if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasBgAlpha) - { - alpha = g.NextWindowData.BgAlphaVal; - override_alpha = true; - } - if (override_alpha) - bg_col = (bg_col & ~IM_COL32_A_MASK) | (IM_F32_TO_INT8_SAT(alpha) << IM_COL32_A_SHIFT); - window->DrawList->AddRectFilled(window->Pos + ImVec2(0, window->TitleBarHeight()), window->Pos + window->Size, bg_col, window_rounding, (flags & ImGuiWindowFlags_NoTitleBar) ? 0 : ImDrawFlags_RoundCornersBottom); - } - - // Title bar - if (!(flags & ImGuiWindowFlags_NoTitleBar)) - { - ImU32 title_bar_col = GetColorU32(title_bar_is_highlight ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBg); - window->DrawList->AddRectFilled(title_bar_rect.Min, title_bar_rect.Max, title_bar_col, window_rounding, ImDrawFlags_RoundCornersTop); - } - - // Menu bar - if (flags & ImGuiWindowFlags_MenuBar) - { - ImRect menu_bar_rect = window->MenuBarRect(); - menu_bar_rect.ClipWith(window->Rect()); // Soft clipping, in particular child window don't have minimum size covering the menu bar so this is useful for them. - window->DrawList->AddRectFilled(menu_bar_rect.Min + ImVec2(window_border_size, 0), menu_bar_rect.Max - ImVec2(window_border_size, 0), GetColorU32(ImGuiCol_MenuBarBg), (flags & ImGuiWindowFlags_NoTitleBar) ? window_rounding : 0.0f, ImDrawFlags_RoundCornersTop); - if (style.FrameBorderSize > 0.0f && menu_bar_rect.Max.y < window->Pos.y + window->Size.y) - window->DrawList->AddLine(menu_bar_rect.GetBL(), menu_bar_rect.GetBR(), GetColorU32(ImGuiCol_Border), style.FrameBorderSize); - } - - // Scrollbars - if (window->ScrollbarX) - Scrollbar(ImGuiAxis_X); - if (window->ScrollbarY) - Scrollbar(ImGuiAxis_Y); - - // Render resize grips (after their input handling so we don't have a frame of latency) - if (!(flags & ImGuiWindowFlags_NoResize)) - { - for (int resize_grip_n = 0; resize_grip_n < resize_grip_count; resize_grip_n++) - { - const ImGuiResizeGripDef& grip = resize_grip_def[resize_grip_n]; - const ImVec2 corner = ImLerp(window->Pos, window->Pos + window->Size, grip.CornerPosN); - window->DrawList->PathLineTo(corner + grip.InnerDir * ((resize_grip_n & 1) ? ImVec2(window_border_size, resize_grip_draw_size) : ImVec2(resize_grip_draw_size, window_border_size))); - window->DrawList->PathLineTo(corner + grip.InnerDir * ((resize_grip_n & 1) ? ImVec2(resize_grip_draw_size, window_border_size) : ImVec2(window_border_size, resize_grip_draw_size))); - window->DrawList->PathArcToFast(ImVec2(corner.x + grip.InnerDir.x * (window_rounding + window_border_size), corner.y + grip.InnerDir.y * (window_rounding + window_border_size)), window_rounding, grip.AngleMin12, grip.AngleMax12); - window->DrawList->PathFillConvex(resize_grip_col[resize_grip_n]); - } - } - - // Borders - RenderWindowOuterBorders(window); - } -} - -// Render title text, collapse button, close button -void ImGui::RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& title_bar_rect, const char* name, bool* p_open) -{ - ImGuiContext& g = *GImGui; - ImGuiStyle& style = g.Style; - ImGuiWindowFlags flags = window->Flags; - - const bool has_close_button = (p_open != NULL); - const bool has_collapse_button = !(flags & ImGuiWindowFlags_NoCollapse) && (style.WindowMenuButtonPosition != ImGuiDir_None); - - // Close & Collapse button are on the Menu NavLayer and don't default focus (unless there's nothing else on that layer) - const ImGuiItemFlags item_flags_backup = g.CurrentItemFlags; - g.CurrentItemFlags |= ImGuiItemFlags_NoNavDefaultFocus; - window->DC.NavLayerCurrent = ImGuiNavLayer_Menu; - - // Layout buttons - // FIXME: Would be nice to generalize the subtleties expressed here into reusable code. - float pad_l = style.FramePadding.x; - float pad_r = style.FramePadding.x; - float button_sz = g.FontSize; - ImVec2 close_button_pos; - ImVec2 collapse_button_pos; - if (has_close_button) - { - pad_r += button_sz; - close_button_pos = ImVec2(title_bar_rect.Max.x - pad_r - style.FramePadding.x, title_bar_rect.Min.y); - } - if (has_collapse_button && style.WindowMenuButtonPosition == ImGuiDir_Right) - { - pad_r += button_sz; - collapse_button_pos = ImVec2(title_bar_rect.Max.x - pad_r - style.FramePadding.x, title_bar_rect.Min.y); - } - if (has_collapse_button && style.WindowMenuButtonPosition == ImGuiDir_Left) - { - collapse_button_pos = ImVec2(title_bar_rect.Min.x + pad_l - style.FramePadding.x, title_bar_rect.Min.y); - pad_l += button_sz; - } - - // Collapse button (submitting first so it gets priority when choosing a navigation init fallback) - if (has_collapse_button) - if (CollapseButton(window->GetID("#COLLAPSE"), collapse_button_pos)) - window->WantCollapseToggle = true; // Defer actual collapsing to next frame as we are too far in the Begin() function - - // Close button - if (has_close_button) - if (CloseButton(window->GetID("#CLOSE"), close_button_pos)) - *p_open = false; - - window->DC.NavLayerCurrent = ImGuiNavLayer_Main; - g.CurrentItemFlags = item_flags_backup; - - // Title bar text (with: horizontal alignment, avoiding collapse/close button, optional "unsaved document" marker) - // FIXME: Refactor text alignment facilities along with RenderText helpers, this is WAY too much messy code.. - const float marker_size_x = (flags & ImGuiWindowFlags_UnsavedDocument) ? button_sz * 0.80f : 0.0f; - const ImVec2 text_size = CalcTextSize(name, NULL, true) + ImVec2(marker_size_x, 0.0f); - - // As a nice touch we try to ensure that centered title text doesn't get affected by visibility of Close/Collapse button, - // while uncentered title text will still reach edges correctly. - if (pad_l > style.FramePadding.x) - pad_l += g.Style.ItemInnerSpacing.x; - if (pad_r > style.FramePadding.x) - pad_r += g.Style.ItemInnerSpacing.x; - if (style.WindowTitleAlign.x > 0.0f && style.WindowTitleAlign.x < 1.0f) - { - float centerness = ImSaturate(1.0f - ImFabs(style.WindowTitleAlign.x - 0.5f) * 2.0f); // 0.0f on either edges, 1.0f on center - float pad_extend = ImMin(ImMax(pad_l, pad_r), title_bar_rect.GetWidth() - pad_l - pad_r - text_size.x); - pad_l = ImMax(pad_l, pad_extend * centerness); - pad_r = ImMax(pad_r, pad_extend * centerness); - } - - ImRect layout_r(title_bar_rect.Min.x + pad_l, title_bar_rect.Min.y, title_bar_rect.Max.x - pad_r, title_bar_rect.Max.y); - ImRect clip_r(layout_r.Min.x, layout_r.Min.y, ImMin(layout_r.Max.x + g.Style.ItemInnerSpacing.x, title_bar_rect.Max.x), layout_r.Max.y); - if (flags & ImGuiWindowFlags_UnsavedDocument) - { - ImVec2 marker_pos; - marker_pos.x = ImClamp(layout_r.Min.x + (layout_r.GetWidth() - text_size.x) * style.WindowTitleAlign.x + text_size.x, layout_r.Min.x, layout_r.Max.x); - marker_pos.y = (layout_r.Min.y + layout_r.Max.y) * 0.5f; - if (marker_pos.x > layout_r.Min.x) - { - RenderBullet(window->DrawList, marker_pos, GetColorU32(ImGuiCol_Text)); - clip_r.Max.x = ImMin(clip_r.Max.x, marker_pos.x - (int)(marker_size_x * 0.5f)); - } - } - //if (g.IO.KeyShift) window->DrawList->AddRect(layout_r.Min, layout_r.Max, IM_COL32(255, 128, 0, 255)); // [DEBUG] - //if (g.IO.KeyCtrl) window->DrawList->AddRect(clip_r.Min, clip_r.Max, IM_COL32(255, 128, 0, 255)); // [DEBUG] - RenderTextClipped(layout_r.Min, layout_r.Max, name, NULL, &text_size, style.WindowTitleAlign, &clip_r); -} - -void ImGui::UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags flags, ImGuiWindow* parent_window) -{ - window->ParentWindow = parent_window; - window->RootWindow = window->RootWindowPopupTree = window->RootWindowForTitleBarHighlight = window->RootWindowForNav = window; - if (parent_window && (flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Tooltip)) - window->RootWindow = parent_window->RootWindow; - if (parent_window && (flags & ImGuiWindowFlags_Popup)) - window->RootWindowPopupTree = parent_window->RootWindowPopupTree; - if (parent_window && !(flags & ImGuiWindowFlags_Modal) && (flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup))) - window->RootWindowForTitleBarHighlight = parent_window->RootWindowForTitleBarHighlight; - while (window->RootWindowForNav->Flags & ImGuiWindowFlags_NavFlattened) - { - IM_ASSERT(window->RootWindowForNav->ParentWindow != NULL); - window->RootWindowForNav = window->RootWindowForNav->ParentWindow; - } -} - -// Push a new Dear ImGui window to add widgets to. -// - A default window called "Debug" is automatically stacked at the beginning of every frame so you can use widgets without explicitly calling a Begin/End pair. -// - Begin/End can be called multiple times during the frame with the same window name to append content. -// - The window name is used as a unique identifier to preserve window information across frames (and save rudimentary information to the .ini file). -// You can use the "##" or "###" markers to use the same label with different id, or same id with different label. See documentation at the top of this file. -// - Return false when window is collapsed, so you can early out in your code. You always need to call ImGui::End() even if false is returned. -// - Passing 'bool* p_open' displays a Close button on the upper-right corner of the window, the pointed value will be set to false when the button is pressed. -bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) -{ - ImGuiContext& g = *GImGui; - const ImGuiStyle& style = g.Style; - IM_ASSERT(name != NULL && name[0] != '\0'); // Window name required - IM_ASSERT(g.WithinFrameScope); // Forgot to call ImGui::NewFrame() - IM_ASSERT(g.FrameCountEnded != g.FrameCount); // Called ImGui::Render() or ImGui::EndFrame() and haven't called ImGui::NewFrame() again yet - - // Find or create - ImGuiWindow* window = FindWindowByName(name); - const bool window_just_created = (window == NULL); - if (window_just_created) - window = CreateNewWindow(name, flags); - - // Automatically disable manual moving/resizing when NoInputs is set - if ((flags & ImGuiWindowFlags_NoInputs) == ImGuiWindowFlags_NoInputs) - flags |= ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize; - - if (flags & ImGuiWindowFlags_NavFlattened) - IM_ASSERT(flags & ImGuiWindowFlags_ChildWindow); - - const int current_frame = g.FrameCount; - const bool first_begin_of_the_frame = (window->LastFrameActive != current_frame); - window->IsFallbackWindow = (g.CurrentWindowStack.Size == 0 && g.WithinFrameScopeWithImplicitWindow); - - // Update the Appearing flag - bool window_just_activated_by_user = (window->LastFrameActive < current_frame - 1); // Not using !WasActive because the implicit "Debug" window would always toggle off->on - if (flags & ImGuiWindowFlags_Popup) - { - ImGuiPopupData& popup_ref = g.OpenPopupStack[g.BeginPopupStack.Size]; - window_just_activated_by_user |= (window->PopupId != popup_ref.PopupId); // We recycle popups so treat window as activated if popup id changed - window_just_activated_by_user |= (window != popup_ref.Window); - } - window->Appearing = window_just_activated_by_user; - if (window->Appearing) - SetWindowConditionAllowFlags(window, ImGuiCond_Appearing, true); - - // Update Flags, LastFrameActive, BeginOrderXXX fields - if (first_begin_of_the_frame) - { - window->Flags = (ImGuiWindowFlags)flags; - window->LastFrameActive = current_frame; - window->LastTimeActive = (float)g.Time; - window->BeginOrderWithinParent = 0; - window->BeginOrderWithinContext = (short)(g.WindowsActiveCount++); - } - else - { - flags = window->Flags; - } - - // Parent window is latched only on the first call to Begin() of the frame, so further append-calls can be done from a different window stack - ImGuiWindow* parent_window_in_stack = g.CurrentWindowStack.empty() ? NULL : g.CurrentWindowStack.back().Window; - ImGuiWindow* parent_window = first_begin_of_the_frame ? ((flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup)) ? parent_window_in_stack : NULL) : window->ParentWindow; - IM_ASSERT(parent_window != NULL || !(flags & ImGuiWindowFlags_ChildWindow)); - - // We allow window memory to be compacted so recreate the base stack when needed. - if (window->IDStack.Size == 0) - window->IDStack.push_back(window->ID); - - // Add to stack - // We intentionally set g.CurrentWindow to NULL to prevent usage until when the viewport is set, then will call SetCurrentWindow() - g.CurrentWindow = window; - ImGuiWindowStackData window_stack_data; - window_stack_data.Window = window; - window_stack_data.ParentLastItemDataBackup = g.LastItemData; - window_stack_data.StackSizesOnBegin.SetToCurrentState(); - g.CurrentWindowStack.push_back(window_stack_data); - g.CurrentWindow = NULL; - - if (flags & ImGuiWindowFlags_Popup) - { - ImGuiPopupData& popup_ref = g.OpenPopupStack[g.BeginPopupStack.Size]; - popup_ref.Window = window; - g.BeginPopupStack.push_back(popup_ref); - window->PopupId = popup_ref.PopupId; - } - - // Update ->RootWindow and others pointers (before any possible call to FocusWindow) - if (first_begin_of_the_frame) - UpdateWindowParentAndRootLinks(window, flags, parent_window); - - // Process SetNextWindow***() calls - // (FIXME: Consider splitting the HasXXX flags into X/Y components - bool window_pos_set_by_api = false; - bool window_size_x_set_by_api = false, window_size_y_set_by_api = false; - if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasPos) - { - window_pos_set_by_api = (window->SetWindowPosAllowFlags & g.NextWindowData.PosCond) != 0; - if (window_pos_set_by_api && ImLengthSqr(g.NextWindowData.PosPivotVal) > 0.00001f) - { - // May be processed on the next frame if this is our first frame and we are measuring size - // FIXME: Look into removing the branch so everything can go through this same code path for consistency. - window->SetWindowPosVal = g.NextWindowData.PosVal; - window->SetWindowPosPivot = g.NextWindowData.PosPivotVal; - window->SetWindowPosAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing); - } - else - { - SetWindowPos(window, g.NextWindowData.PosVal, g.NextWindowData.PosCond); - } - } - if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSize) - { - window_size_x_set_by_api = (window->SetWindowSizeAllowFlags & g.NextWindowData.SizeCond) != 0 && (g.NextWindowData.SizeVal.x > 0.0f); - window_size_y_set_by_api = (window->SetWindowSizeAllowFlags & g.NextWindowData.SizeCond) != 0 && (g.NextWindowData.SizeVal.y > 0.0f); - SetWindowSize(window, g.NextWindowData.SizeVal, g.NextWindowData.SizeCond); - } - if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasScroll) - { - if (g.NextWindowData.ScrollVal.x >= 0.0f) - { - window->ScrollTarget.x = g.NextWindowData.ScrollVal.x; - window->ScrollTargetCenterRatio.x = 0.0f; - } - if (g.NextWindowData.ScrollVal.y >= 0.0f) - { - window->ScrollTarget.y = g.NextWindowData.ScrollVal.y; - window->ScrollTargetCenterRatio.y = 0.0f; - } - } - if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasContentSize) - window->ContentSizeExplicit = g.NextWindowData.ContentSizeVal; - else if (first_begin_of_the_frame) - window->ContentSizeExplicit = ImVec2(0.0f, 0.0f); - if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasCollapsed) - SetWindowCollapsed(window, g.NextWindowData.CollapsedVal, g.NextWindowData.CollapsedCond); - if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasFocus) - FocusWindow(window); - if (window->Appearing) - SetWindowConditionAllowFlags(window, ImGuiCond_Appearing, false); - - // When reusing window again multiple times a frame, just append content (don't need to setup again) - if (first_begin_of_the_frame) - { - // Initialize - const bool window_is_child_tooltip = (flags & ImGuiWindowFlags_ChildWindow) && (flags & ImGuiWindowFlags_Tooltip); // FIXME-WIP: Undocumented behavior of Child+Tooltip for pinned tooltip (#1345) - window->Active = true; - window->HasCloseButton = (p_open != NULL); - window->ClipRect = ImVec4(-FLT_MAX, -FLT_MAX, +FLT_MAX, +FLT_MAX); - window->IDStack.resize(1); - window->DrawList->_ResetForNewFrame(); - window->DC.CurrentTableIdx = -1; - - // Restore buffer capacity when woken from a compacted state, to avoid - if (window->MemoryCompacted) - GcAwakeTransientWindowBuffers(window); - - // Update stored window name when it changes (which can _only_ happen with the "###" operator, so the ID would stay unchanged). - // The title bar always display the 'name' parameter, so we only update the string storage if it needs to be visible to the end-user elsewhere. - bool window_title_visible_elsewhere = false; - if (g.NavWindowingListWindow != NULL && (window->Flags & ImGuiWindowFlags_NoNavFocus) == 0) // Window titles visible when using CTRL+TAB - window_title_visible_elsewhere = true; - if (window_title_visible_elsewhere && !window_just_created && strcmp(name, window->Name) != 0) - { - size_t buf_len = (size_t)window->NameBufLen; - window->Name = ImStrdupcpy(window->Name, &buf_len, name); - window->NameBufLen = (int)buf_len; - } - - // UPDATE CONTENTS SIZE, UPDATE HIDDEN STATUS - - // Update contents size from last frame for auto-fitting (or use explicit size) - const bool window_just_appearing_after_hidden_for_resize = (window->HiddenFramesCannotSkipItems > 0); - CalcWindowContentSizes(window, &window->ContentSize, &window->ContentSizeIdeal); - if (window->HiddenFramesCanSkipItems > 0) - window->HiddenFramesCanSkipItems--; - if (window->HiddenFramesCannotSkipItems > 0) - window->HiddenFramesCannotSkipItems--; - if (window->HiddenFramesForRenderOnly > 0) - window->HiddenFramesForRenderOnly--; - - // Hide new windows for one frame until they calculate their size - if (window_just_created && (!window_size_x_set_by_api || !window_size_y_set_by_api)) - window->HiddenFramesCannotSkipItems = 1; - - // Hide popup/tooltip window when re-opening while we measure size (because we recycle the windows) - // We reset Size/ContentSize for reappearing popups/tooltips early in this function, so further code won't be tempted to use the old size. - if (window_just_activated_by_user && (flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_Tooltip)) != 0) - { - window->HiddenFramesCannotSkipItems = 1; - if (flags & ImGuiWindowFlags_AlwaysAutoResize) - { - if (!window_size_x_set_by_api) - window->Size.x = window->SizeFull.x = 0.f; - if (!window_size_y_set_by_api) - window->Size.y = window->SizeFull.y = 0.f; - window->ContentSize = window->ContentSizeIdeal = ImVec2(0.f, 0.f); - } - } - - // SELECT VIEWPORT - // FIXME-VIEWPORT: In the docking/viewport branch, this is the point where we select the current viewport (which may affect the style) - SetCurrentWindow(window); - - // LOCK BORDER SIZE AND PADDING FOR THE FRAME (so that altering them doesn't cause inconsistencies) - - if (flags & ImGuiWindowFlags_ChildWindow) - window->WindowBorderSize = style.ChildBorderSize; - else - window->WindowBorderSize = ((flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_Tooltip)) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupBorderSize : style.WindowBorderSize; - window->WindowPadding = style.WindowPadding; - if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & (ImGuiWindowFlags_AlwaysUseWindowPadding | ImGuiWindowFlags_Popup)) && window->WindowBorderSize == 0.0f) - window->WindowPadding = ImVec2(0.0f, (flags & ImGuiWindowFlags_MenuBar) ? style.WindowPadding.y : 0.0f); - - // Lock menu offset so size calculation can use it as menu-bar windows need a minimum size. - window->DC.MenuBarOffset.x = ImMax(ImMax(window->WindowPadding.x, style.ItemSpacing.x), g.NextWindowData.MenuBarOffsetMinVal.x); - window->DC.MenuBarOffset.y = g.NextWindowData.MenuBarOffsetMinVal.y; - - // Collapse window by double-clicking on title bar - // At this point we don't have a clipping rectangle setup yet, so we can use the title bar area for hit detection and drawing - if (!(flags & ImGuiWindowFlags_NoTitleBar) && !(flags & ImGuiWindowFlags_NoCollapse)) - { - // We don't use a regular button+id to test for double-click on title bar (mostly due to legacy reason, could be fixed), so verify that we don't have items over the title bar. - ImRect title_bar_rect = window->TitleBarRect(); - if (g.HoveredWindow == window && g.HoveredId == 0 && g.HoveredIdPreviousFrame == 0 && IsMouseHoveringRect(title_bar_rect.Min, title_bar_rect.Max) && g.IO.MouseDoubleClicked[0]) - window->WantCollapseToggle = true; - if (window->WantCollapseToggle) - { - window->Collapsed = !window->Collapsed; - MarkIniSettingsDirty(window); - } - } - else - { - window->Collapsed = false; - } - window->WantCollapseToggle = false; - - // SIZE - - // Calculate auto-fit size, handle automatic resize - const ImVec2 size_auto_fit = CalcWindowAutoFitSize(window, window->ContentSizeIdeal); - bool use_current_size_for_scrollbar_x = window_just_created; - bool use_current_size_for_scrollbar_y = window_just_created; - if ((flags & ImGuiWindowFlags_AlwaysAutoResize) && !window->Collapsed) - { - // Using SetNextWindowSize() overrides ImGuiWindowFlags_AlwaysAutoResize, so it can be used on tooltips/popups, etc. - if (!window_size_x_set_by_api) - { - window->SizeFull.x = size_auto_fit.x; - use_current_size_for_scrollbar_x = true; - } - if (!window_size_y_set_by_api) - { - window->SizeFull.y = size_auto_fit.y; - use_current_size_for_scrollbar_y = true; - } - } - else if (window->AutoFitFramesX > 0 || window->AutoFitFramesY > 0) - { - // Auto-fit may only grow window during the first few frames - // We still process initial auto-fit on collapsed windows to get a window width, but otherwise don't honor ImGuiWindowFlags_AlwaysAutoResize when collapsed. - if (!window_size_x_set_by_api && window->AutoFitFramesX > 0) - { - window->SizeFull.x = window->AutoFitOnlyGrows ? ImMax(window->SizeFull.x, size_auto_fit.x) : size_auto_fit.x; - use_current_size_for_scrollbar_x = true; - } - if (!window_size_y_set_by_api && window->AutoFitFramesY > 0) - { - window->SizeFull.y = window->AutoFitOnlyGrows ? ImMax(window->SizeFull.y, size_auto_fit.y) : size_auto_fit.y; - use_current_size_for_scrollbar_y = true; - } - if (!window->Collapsed) - MarkIniSettingsDirty(window); - } - - // Apply minimum/maximum window size constraints and final size - window->SizeFull = CalcWindowSizeAfterConstraint(window, window->SizeFull); - window->Size = window->Collapsed && !(flags & ImGuiWindowFlags_ChildWindow) ? window->TitleBarRect().GetSize() : window->SizeFull; - - // Decoration size - const float decoration_up_height = window->TitleBarHeight() + window->MenuBarHeight(); - - // POSITION - - // Popup latch its initial position, will position itself when it appears next frame - if (window_just_activated_by_user) - { - window->AutoPosLastDirection = ImGuiDir_None; - if ((flags & ImGuiWindowFlags_Popup) != 0 && !(flags & ImGuiWindowFlags_Modal) && !window_pos_set_by_api) // FIXME: BeginPopup() could use SetNextWindowPos() - window->Pos = g.BeginPopupStack.back().OpenPopupPos; - } - - // Position child window - if (flags & ImGuiWindowFlags_ChildWindow) - { - IM_ASSERT(parent_window && parent_window->Active); - window->BeginOrderWithinParent = (short)parent_window->DC.ChildWindows.Size; - parent_window->DC.ChildWindows.push_back(window); - if (!(flags & ImGuiWindowFlags_Popup) && !window_pos_set_by_api && !window_is_child_tooltip) - window->Pos = parent_window->DC.CursorPos; - } - - const bool window_pos_with_pivot = (window->SetWindowPosVal.x != FLT_MAX && window->HiddenFramesCannotSkipItems == 0); - if (window_pos_with_pivot) - SetWindowPos(window, window->SetWindowPosVal - window->Size * window->SetWindowPosPivot, 0); // Position given a pivot (e.g. for centering) - else if ((flags & ImGuiWindowFlags_ChildMenu) != 0) - window->Pos = FindBestWindowPosForPopup(window); - else if ((flags & ImGuiWindowFlags_Popup) != 0 && !window_pos_set_by_api && window_just_appearing_after_hidden_for_resize) - window->Pos = FindBestWindowPosForPopup(window); - else if ((flags & ImGuiWindowFlags_Tooltip) != 0 && !window_pos_set_by_api && !window_is_child_tooltip) - window->Pos = FindBestWindowPosForPopup(window); - - // Calculate the range of allowed position for that window (to be movable and visible past safe area padding) - // When clamping to stay visible, we will enforce that window->Pos stays inside of visibility_rect. - ImGuiViewportP* viewport = (ImGuiViewportP*)(void*)GetMainViewport(); - ImRect viewport_rect(viewport->GetMainRect()); - ImRect viewport_work_rect(viewport->GetWorkRect()); - ImVec2 visibility_padding = ImMax(style.DisplayWindowPadding, style.DisplaySafeAreaPadding); - ImRect visibility_rect(viewport_work_rect.Min + visibility_padding, viewport_work_rect.Max - visibility_padding); - - // Clamp position/size so window stays visible within its viewport or monitor - // Ignore zero-sized display explicitly to avoid losing positions if a window manager reports zero-sized window when initializing or minimizing. - if (!window_pos_set_by_api && !(flags & ImGuiWindowFlags_ChildWindow) && window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0) - if (viewport_rect.GetWidth() > 0.0f && viewport_rect.GetHeight() > 0.0f) - ClampWindowRect(window, visibility_rect); - window->Pos = ImFloor(window->Pos); - - // Lock window rounding for the frame (so that altering them doesn't cause inconsistencies) - // Large values tend to lead to variety of artifacts and are not recommended. - window->WindowRounding = (flags & ImGuiWindowFlags_ChildWindow) ? style.ChildRounding : ((flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupRounding : style.WindowRounding; - - // For windows with title bar or menu bar, we clamp to FrameHeight(FontSize + FramePadding.y * 2.0f) to completely hide artifacts. - //if ((window->Flags & ImGuiWindowFlags_MenuBar) || !(window->Flags & ImGuiWindowFlags_NoTitleBar)) - // window->WindowRounding = ImMin(window->WindowRounding, g.FontSize + style.FramePadding.y * 2.0f); - - // Apply window focus (new and reactivated windows are moved to front) - bool want_focus = false; - if (window_just_activated_by_user && !(flags & ImGuiWindowFlags_NoFocusOnAppearing)) - { - if (flags & ImGuiWindowFlags_Popup) - want_focus = true; - else if ((flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Tooltip)) == 0) - want_focus = true; - } - - // Handle manual resize: Resize Grips, Borders, Gamepad - int border_held = -1; - ImU32 resize_grip_col[4] = {}; - const int resize_grip_count = g.IO.ConfigWindowsResizeFromEdges ? 2 : 1; // Allow resize from lower-left if we have the mouse cursor feedback for it. - const float resize_grip_draw_size = IM_FLOOR(ImMax(g.FontSize * 1.10f, window->WindowRounding + 1.0f + g.FontSize * 0.2f)); - if (!window->Collapsed) - if (UpdateWindowManualResize(window, size_auto_fit, &border_held, resize_grip_count, &resize_grip_col[0], visibility_rect)) - use_current_size_for_scrollbar_x = use_current_size_for_scrollbar_y = true; - window->ResizeBorderHeld = (signed char)border_held; - - // SCROLLBAR VISIBILITY - - // Update scrollbar visibility (based on the Size that was effective during last frame or the auto-resized Size). - if (!window->Collapsed) - { - // When reading the current size we need to read it after size constraints have been applied. - // When we use InnerRect here we are intentionally reading last frame size, same for ScrollbarSizes values before we set them again. - ImVec2 avail_size_from_current_frame = ImVec2(window->SizeFull.x, window->SizeFull.y - decoration_up_height); - ImVec2 avail_size_from_last_frame = window->InnerRect.GetSize() + window->ScrollbarSizes; - ImVec2 needed_size_from_last_frame = window_just_created ? ImVec2(0, 0) : window->ContentSize + window->WindowPadding * 2.0f; - float size_x_for_scrollbars = use_current_size_for_scrollbar_x ? avail_size_from_current_frame.x : avail_size_from_last_frame.x; - float size_y_for_scrollbars = use_current_size_for_scrollbar_y ? avail_size_from_current_frame.y : avail_size_from_last_frame.y; - //bool scrollbar_y_from_last_frame = window->ScrollbarY; // FIXME: May want to use that in the ScrollbarX expression? How many pros vs cons? - window->ScrollbarY = (flags & ImGuiWindowFlags_AlwaysVerticalScrollbar) || ((needed_size_from_last_frame.y > size_y_for_scrollbars) && !(flags & ImGuiWindowFlags_NoScrollbar)); - window->ScrollbarX = (flags & ImGuiWindowFlags_AlwaysHorizontalScrollbar) || ((needed_size_from_last_frame.x > size_x_for_scrollbars - (window->ScrollbarY ? style.ScrollbarSize : 0.0f)) && !(flags & ImGuiWindowFlags_NoScrollbar) && (flags & ImGuiWindowFlags_HorizontalScrollbar)); - if (window->ScrollbarX && !window->ScrollbarY) - window->ScrollbarY = (needed_size_from_last_frame.y > size_y_for_scrollbars) && !(flags & ImGuiWindowFlags_NoScrollbar); - window->ScrollbarSizes = ImVec2(window->ScrollbarY ? style.ScrollbarSize : 0.0f, window->ScrollbarX ? style.ScrollbarSize : 0.0f); - } - - // UPDATE RECTANGLES (1- THOSE NOT AFFECTED BY SCROLLING) - // Update various regions. Variables they depends on should be set above in this function. - // We set this up after processing the resize grip so that our rectangles doesn't lag by a frame. - - // Outer rectangle - // Not affected by window border size. Used by: - // - FindHoveredWindow() (w/ extra padding when border resize is enabled) - // - Begin() initial clipping rect for drawing window background and borders. - // - Begin() clipping whole child - const ImRect host_rect = ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Popup) && !window_is_child_tooltip) ? parent_window->ClipRect : viewport_rect; - const ImRect outer_rect = window->Rect(); - const ImRect title_bar_rect = window->TitleBarRect(); - window->OuterRectClipped = outer_rect; - window->OuterRectClipped.ClipWith(host_rect); - - // Inner rectangle - // Not affected by window border size. Used by: - // - InnerClipRect - // - ScrollToBringRectIntoView() - // - NavUpdatePageUpPageDown() - // - Scrollbar() - window->InnerRect.Min.x = window->Pos.x; - window->InnerRect.Min.y = window->Pos.y + decoration_up_height; - window->InnerRect.Max.x = window->Pos.x + window->Size.x - window->ScrollbarSizes.x; - window->InnerRect.Max.y = window->Pos.y + window->Size.y - window->ScrollbarSizes.y; - - // Inner clipping rectangle. - // Will extend a little bit outside the normal work region. - // This is to allow e.g. Selectable or CollapsingHeader or some separators to cover that space. - // Force round operator last to ensure that e.g. (int)(max.x-min.x) in user's render code produce correct result. - // Note that if our window is collapsed we will end up with an inverted (~null) clipping rectangle which is the correct behavior. - // Affected by window/frame border size. Used by: - // - Begin() initial clip rect - float top_border_size = (((flags & ImGuiWindowFlags_MenuBar) || !(flags & ImGuiWindowFlags_NoTitleBar)) ? style.FrameBorderSize : window->WindowBorderSize); - window->InnerClipRect.Min.x = ImFloor(0.5f + window->InnerRect.Min.x + ImMax(ImFloor(window->WindowPadding.x * 0.5f), window->WindowBorderSize)); - window->InnerClipRect.Min.y = ImFloor(0.5f + window->InnerRect.Min.y + top_border_size); - window->InnerClipRect.Max.x = ImFloor(0.5f + window->InnerRect.Max.x - ImMax(ImFloor(window->WindowPadding.x * 0.5f), window->WindowBorderSize)); - window->InnerClipRect.Max.y = ImFloor(0.5f + window->InnerRect.Max.y - window->WindowBorderSize); - window->InnerClipRect.ClipWithFull(host_rect); - - // Default item width. Make it proportional to window size if window manually resizes - if (window->Size.x > 0.0f && !(flags & ImGuiWindowFlags_Tooltip) && !(flags & ImGuiWindowFlags_AlwaysAutoResize)) - window->ItemWidthDefault = ImFloor(window->Size.x * 0.65f); - else - window->ItemWidthDefault = ImFloor(g.FontSize * 16.0f); - - // SCROLLING - - // Lock down maximum scrolling - // The value of ScrollMax are ahead from ScrollbarX/ScrollbarY which is intentionally using InnerRect from previous rect in order to accommodate - // for right/bottom aligned items without creating a scrollbar. - window->ScrollMax.x = ImMax(0.0f, window->ContentSize.x + window->WindowPadding.x * 2.0f - window->InnerRect.GetWidth()); - window->ScrollMax.y = ImMax(0.0f, window->ContentSize.y + window->WindowPadding.y * 2.0f - window->InnerRect.GetHeight()); - - // Apply scrolling - window->Scroll = CalcNextScrollFromScrollTargetAndClamp(window); - window->ScrollTarget = ImVec2(FLT_MAX, FLT_MAX); - - // DRAWING - - // Setup draw list and outer clipping rectangle - IM_ASSERT(window->DrawList->CmdBuffer.Size == 1 && window->DrawList->CmdBuffer[0].ElemCount == 0); - window->DrawList->PushTextureID(g.Font->ContainerAtlas->TexID); - PushClipRect(host_rect.Min, host_rect.Max, false); - - // Draw modal window background (darkens what is behind them, all viewports) - const bool dim_bg_for_modal = (flags & ImGuiWindowFlags_Modal) && window == GetTopMostPopupModal() && window->HiddenFramesCannotSkipItems <= 0; - const bool dim_bg_for_window_list = g.NavWindowingTargetAnim && (window == g.NavWindowingTargetAnim->RootWindow); - if (dim_bg_for_modal || dim_bg_for_window_list) - { - const ImU32 dim_bg_col = GetColorU32(dim_bg_for_modal ? ImGuiCol_ModalWindowDimBg : ImGuiCol_NavWindowingDimBg, g.DimBgRatio); - window->DrawList->AddRectFilled(viewport_rect.Min, viewport_rect.Max, dim_bg_col); - } - - // Draw navigation selection/windowing rectangle background - if (dim_bg_for_window_list && window == g.NavWindowingTargetAnim) - { - ImRect bb = window->Rect(); - bb.Expand(g.FontSize); - if (!bb.Contains(viewport_rect)) // Avoid drawing if the window covers all the viewport anyway - window->DrawList->AddRectFilled(bb.Min, bb.Max, GetColorU32(ImGuiCol_NavWindowingHighlight, g.NavWindowingHighlightAlpha * 0.25f), g.Style.WindowRounding); - } - - // Child windows can render their decoration (bg color, border, scrollbars, etc.) within their parent to save a draw call (since 1.71) - // When using overlapping child windows, this will break the assumption that child z-order is mapped to submission order. - // FIXME: User code may rely on explicit sorting of overlapping child window and would need to disable this somehow. Please get in contact if you are affected (github #4493) - { - bool render_decorations_in_parent = false; - if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Popup) && !window_is_child_tooltip) - { - // - We test overlap with the previous child window only (testing all would end up being O(log N) not a good investment here) - // - We disable this when the parent window has zero vertices, which is a common pattern leading to laying out multiple overlapping childs - ImGuiWindow* previous_child = parent_window->DC.ChildWindows.Size >= 2 ? parent_window->DC.ChildWindows[parent_window->DC.ChildWindows.Size - 2] : NULL; - bool previous_child_overlapping = previous_child ? previous_child->Rect().Overlaps(window->Rect()) : false; - bool parent_is_empty = parent_window->DrawList->VtxBuffer.Size > 0; - if (window->DrawList->CmdBuffer.back().ElemCount == 0 && parent_is_empty && !previous_child_overlapping) - render_decorations_in_parent = true; - } - if (render_decorations_in_parent) - window->DrawList = parent_window->DrawList; - - // Handle title bar, scrollbar, resize grips and resize borders - const ImGuiWindow* window_to_highlight = g.NavWindowingTarget ? g.NavWindowingTarget : g.NavWindow; - const bool title_bar_is_highlight = want_focus || (window_to_highlight && window->RootWindowForTitleBarHighlight == window_to_highlight->RootWindowForTitleBarHighlight); - RenderWindowDecorations(window, title_bar_rect, title_bar_is_highlight, resize_grip_count, resize_grip_col, resize_grip_draw_size); - - if (render_decorations_in_parent) - window->DrawList = &window->DrawListInst; - } - - // Draw navigation selection/windowing rectangle border - if (g.NavWindowingTargetAnim == window) - { - float rounding = ImMax(window->WindowRounding, g.Style.WindowRounding); - ImRect bb = window->Rect(); - bb.Expand(g.FontSize); - if (bb.Contains(viewport_rect)) // If a window fits the entire viewport, adjust its highlight inward - { - bb.Expand(-g.FontSize - 1.0f); - rounding = window->WindowRounding; - } - window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_NavWindowingHighlight, g.NavWindowingHighlightAlpha), rounding, 0, 3.0f); - } - - // UPDATE RECTANGLES (2- THOSE AFFECTED BY SCROLLING) - - // Work rectangle. - // Affected by window padding and border size. Used by: - // - Columns() for right-most edge - // - TreeNode(), CollapsingHeader() for right-most edge - // - BeginTabBar() for right-most edge - const bool allow_scrollbar_x = !(flags & ImGuiWindowFlags_NoScrollbar) && (flags & ImGuiWindowFlags_HorizontalScrollbar); - const bool allow_scrollbar_y = !(flags & ImGuiWindowFlags_NoScrollbar); - const float work_rect_size_x = (window->ContentSizeExplicit.x != 0.0f ? window->ContentSizeExplicit.x : ImMax(allow_scrollbar_x ? window->ContentSize.x : 0.0f, window->Size.x - window->WindowPadding.x * 2.0f - window->ScrollbarSizes.x)); - const float work_rect_size_y = (window->ContentSizeExplicit.y != 0.0f ? window->ContentSizeExplicit.y : ImMax(allow_scrollbar_y ? window->ContentSize.y : 0.0f, window->Size.y - window->WindowPadding.y * 2.0f - decoration_up_height - window->ScrollbarSizes.y)); - window->WorkRect.Min.x = ImFloor(window->InnerRect.Min.x - window->Scroll.x + ImMax(window->WindowPadding.x, window->WindowBorderSize)); - window->WorkRect.Min.y = ImFloor(window->InnerRect.Min.y - window->Scroll.y + ImMax(window->WindowPadding.y, window->WindowBorderSize)); - window->WorkRect.Max.x = window->WorkRect.Min.x + work_rect_size_x; - window->WorkRect.Max.y = window->WorkRect.Min.y + work_rect_size_y; - window->ParentWorkRect = window->WorkRect; - - // [LEGACY] Content Region - // FIXME-OBSOLETE: window->ContentRegionRect.Max is currently very misleading / partly faulty, but some BeginChild() patterns relies on it. - // Used by: - // - Mouse wheel scrolling + many other things - window->ContentRegionRect.Min.x = window->Pos.x - window->Scroll.x + window->WindowPadding.x; - window->ContentRegionRect.Min.y = window->Pos.y - window->Scroll.y + window->WindowPadding.y + decoration_up_height; - window->ContentRegionRect.Max.x = window->ContentRegionRect.Min.x + (window->ContentSizeExplicit.x != 0.0f ? window->ContentSizeExplicit.x : (window->Size.x - window->WindowPadding.x * 2.0f - window->ScrollbarSizes.x)); - window->ContentRegionRect.Max.y = window->ContentRegionRect.Min.y + (window->ContentSizeExplicit.y != 0.0f ? window->ContentSizeExplicit.y : (window->Size.y - window->WindowPadding.y * 2.0f - decoration_up_height - window->ScrollbarSizes.y)); - - // Setup drawing context - // (NB: That term "drawing context / DC" lost its meaning a long time ago. Initially was meant to hold transient data only. Nowadays difference between window-> and window->DC-> is dubious.) - window->DC.Indent.x = 0.0f + window->WindowPadding.x - window->Scroll.x; - window->DC.GroupOffset.x = 0.0f; - window->DC.ColumnsOffset.x = 0.0f; - window->DC.CursorStartPos = window->Pos + ImVec2(window->DC.Indent.x + window->DC.ColumnsOffset.x, decoration_up_height + window->WindowPadding.y - window->Scroll.y); - window->DC.CursorPos = window->DC.CursorStartPos; - window->DC.CursorPosPrevLine = window->DC.CursorPos; - window->DC.CursorMaxPos = window->DC.CursorStartPos; - window->DC.IdealMaxPos = window->DC.CursorStartPos; - window->DC.CurrLineSize = window->DC.PrevLineSize = ImVec2(0.0f, 0.0f); - window->DC.CurrLineTextBaseOffset = window->DC.PrevLineTextBaseOffset = 0.0f; - - window->DC.NavLayerCurrent = ImGuiNavLayer_Main; - window->DC.NavLayersActiveMask = window->DC.NavLayersActiveMaskNext; - window->DC.NavLayersActiveMaskNext = 0x00; - window->DC.NavHideHighlightOneFrame = false; - window->DC.NavHasScroll = (window->ScrollMax.y > 0.0f); - - window->DC.MenuBarAppending = false; - window->DC.MenuColumns.Update(style.ItemSpacing.x, window_just_activated_by_user); - window->DC.TreeDepth = 0; - window->DC.TreeJumpToParentOnPopMask = 0x00; - window->DC.ChildWindows.resize(0); - window->DC.StateStorage = &window->StateStorage; - window->DC.CurrentColumns = NULL; - window->DC.LayoutType = ImGuiLayoutType_Vertical; - window->DC.ParentLayoutType = parent_window ? parent_window->DC.LayoutType : ImGuiLayoutType_Vertical; - window->DC.FocusCounterTabStop = -1; - - window->DC.ItemWidth = window->ItemWidthDefault; - window->DC.TextWrapPos = -1.0f; // disabled - window->DC.ItemWidthStack.resize(0); - window->DC.TextWrapPosStack.resize(0); - - if (window->AutoFitFramesX > 0) - window->AutoFitFramesX--; - if (window->AutoFitFramesY > 0) - window->AutoFitFramesY--; - - // Apply focus (we need to call FocusWindow() AFTER setting DC.CursorStartPos so our initial navigation reference rectangle can start around there) - if (want_focus) - { - FocusWindow(window); - NavInitWindow(window, false); // <-- this is in the way for us to be able to defer and sort reappearing FocusWindow() calls - } - - // Title bar - if (!(flags & ImGuiWindowFlags_NoTitleBar)) - RenderWindowTitleBarContents(window, ImRect(title_bar_rect.Min.x + window->WindowBorderSize, title_bar_rect.Min.y, title_bar_rect.Max.x - window->WindowBorderSize, title_bar_rect.Max.y), name, p_open); - - // Clear hit test shape every frame - window->HitTestHoleSize.x = window->HitTestHoleSize.y = 0; - - // Pressing CTRL+C while holding on a window copy its content to the clipboard - // This works but 1. doesn't handle multiple Begin/End pairs, 2. recursing into another Begin/End pair - so we need to work that out and add better logging scope. - // Maybe we can support CTRL+C on every element? - /* - //if (g.NavWindow == window && g.ActiveId == 0) - if (g.ActiveId == window->MoveId) - if (g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_C)) - LogToClipboard(); - */ - - // We fill last item data based on Title Bar/Tab, in order for IsItemHovered() and IsItemActive() to be usable after Begin(). - // This is useful to allow creating context menus on title bar only, etc. - g.LastItemData.ID = window->MoveId; - g.LastItemData.InFlags = g.CurrentItemFlags; - g.LastItemData.StatusFlags = IsMouseHoveringRect(title_bar_rect.Min, title_bar_rect.Max, false) ? ImGuiItemStatusFlags_HoveredRect : 0; - g.LastItemData.Rect = title_bar_rect; - -#ifdef IMGUI_ENABLE_TEST_ENGINE - if (!(window->Flags & ImGuiWindowFlags_NoTitleBar)) - IMGUI_TEST_ENGINE_ITEM_ADD(g.LastItemData.Rect, g.LastItemData.ID); -#endif - } - else - { - // Append - SetCurrentWindow(window); - } - - // Pull/inherit current state - window->DC.NavFocusScopeIdCurrent = (flags & ImGuiWindowFlags_ChildWindow) ? parent_window->DC.NavFocusScopeIdCurrent : window->GetID("#FOCUSSCOPE"); // Inherit from parent only // -V595 - - PushClipRect(window->InnerClipRect.Min, window->InnerClipRect.Max, true); - - // Clear 'accessed' flag last thing (After PushClipRect which will set the flag. We want the flag to stay false when the default "Debug" window is unused) - window->WriteAccessed = false; - window->BeginCount++; - g.NextWindowData.ClearFlags(); - - // Update visibility - if (first_begin_of_the_frame) - { - if (flags & ImGuiWindowFlags_ChildWindow) - { - // Child window can be out of sight and have "negative" clip windows. - // Mark them as collapsed so commands are skipped earlier (we can't manually collapse them because they have no title bar). - IM_ASSERT((flags & ImGuiWindowFlags_NoTitleBar) != 0); - if (!(flags & ImGuiWindowFlags_AlwaysAutoResize) && window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0) // FIXME: Doesn't make sense for ChildWindow?? - if (!g.LogEnabled) - if (window->OuterRectClipped.Min.x >= window->OuterRectClipped.Max.x || window->OuterRectClipped.Min.y >= window->OuterRectClipped.Max.y) - window->HiddenFramesCanSkipItems = 1; - - // Hide along with parent or if parent is collapsed - if (parent_window && (parent_window->Collapsed || parent_window->HiddenFramesCanSkipItems > 0)) - window->HiddenFramesCanSkipItems = 1; - if (parent_window && (parent_window->Collapsed || parent_window->HiddenFramesCannotSkipItems > 0)) - window->HiddenFramesCannotSkipItems = 1; - } - - // Don't render if style alpha is 0.0 at the time of Begin(). This is arbitrary and inconsistent but has been there for a long while (may remove at some point) - if (style.Alpha <= 0.0f) - window->HiddenFramesCanSkipItems = 1; - - // Update the Hidden flag - window->Hidden = (window->HiddenFramesCanSkipItems > 0) || (window->HiddenFramesCannotSkipItems > 0) || (window->HiddenFramesForRenderOnly > 0); - - // Disable inputs for requested number of frames - if (window->DisableInputsFrames > 0) - { - window->DisableInputsFrames--; - window->Flags |= ImGuiWindowFlags_NoInputs; - } - - // Update the SkipItems flag, used to early out of all items functions (no layout required) - bool skip_items = false; - if (window->Collapsed || !window->Active || window->Hidden) - if (window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0 && window->HiddenFramesCannotSkipItems <= 0) - skip_items = true; - window->SkipItems = skip_items; - } - - return !window->SkipItems; -} - -void ImGui::End() -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - - // Error checking: verify that user hasn't called End() too many times! - if (g.CurrentWindowStack.Size <= 1 && g.WithinFrameScopeWithImplicitWindow) - { - IM_ASSERT_USER_ERROR(g.CurrentWindowStack.Size > 1, "Calling End() too many times!"); - return; - } - IM_ASSERT(g.CurrentWindowStack.Size > 0); - - // Error checking: verify that user doesn't directly call End() on a child window. - if (window->Flags & ImGuiWindowFlags_ChildWindow) - IM_ASSERT_USER_ERROR(g.WithinEndChild, "Must call EndChild() and not End()!"); - - // Close anything that is open - if (window->DC.CurrentColumns) - EndColumns(); - PopClipRect(); // Inner window clip rectangle - - // Stop logging - if (!(window->Flags & ImGuiWindowFlags_ChildWindow)) // FIXME: add more options for scope of logging - LogFinish(); - - // Pop from window stack - g.LastItemData = g.CurrentWindowStack.back().ParentLastItemDataBackup; - if (window->Flags & ImGuiWindowFlags_Popup) - g.BeginPopupStack.pop_back(); - g.CurrentWindowStack.back().StackSizesOnBegin.CompareWithCurrentState(); - g.CurrentWindowStack.pop_back(); - SetCurrentWindow(g.CurrentWindowStack.Size == 0 ? NULL : g.CurrentWindowStack.back().Window); -} - -void ImGui::BringWindowToFocusFront(ImGuiWindow* window) -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(window == window->RootWindow); - - const int cur_order = window->FocusOrder; - IM_ASSERT(g.WindowsFocusOrder[cur_order] == window); - if (g.WindowsFocusOrder.back() == window) - return; - - const int new_order = g.WindowsFocusOrder.Size - 1; - for (int n = cur_order; n < new_order; n++) - { - g.WindowsFocusOrder[n] = g.WindowsFocusOrder[n + 1]; - g.WindowsFocusOrder[n]->FocusOrder--; - IM_ASSERT(g.WindowsFocusOrder[n]->FocusOrder == n); - } - g.WindowsFocusOrder[new_order] = window; - window->FocusOrder = (short)new_order; -} - -void ImGui::BringWindowToDisplayFront(ImGuiWindow* window) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* current_front_window = g.Windows.back(); - if (current_front_window == window || current_front_window->RootWindow == window) // Cheap early out (could be better) - return; - for (int i = g.Windows.Size - 2; i >= 0; i--) // We can ignore the top-most window - if (g.Windows[i] == window) - { - memmove(&g.Windows[i], &g.Windows[i + 1], (size_t)(g.Windows.Size - i - 1) * sizeof(ImGuiWindow*)); - g.Windows[g.Windows.Size - 1] = window; - break; - } -} - -void ImGui::BringWindowToDisplayBack(ImGuiWindow* window) -{ - ImGuiContext& g = *GImGui; - if (g.Windows[0] == window) - return; - for (int i = 0; i < g.Windows.Size; i++) - if (g.Windows[i] == window) - { - memmove(&g.Windows[1], &g.Windows[0], (size_t)i * sizeof(ImGuiWindow*)); - g.Windows[0] = window; - break; - } -} - -// Moving window to front of display and set focus (which happens to be back of our sorted list) -void ImGui::FocusWindow(ImGuiWindow* window) -{ - ImGuiContext& g = *GImGui; - - if (g.NavWindow != window) - { - g.NavWindow = window; - if (window && g.NavDisableMouseHover) - g.NavMousePosDirty = true; - g.NavId = window ? window->NavLastIds[0] : 0; // Restore NavId - g.NavFocusScopeId = 0; - g.NavIdIsAlive = false; - g.NavLayer = ImGuiNavLayer_Main; - g.NavInitRequest = g.NavMoveSubmitted = g.NavMoveScoringItems = false; - NavUpdateAnyRequestFlag(); - //IMGUI_DEBUG_LOG("FocusWindow(\"%s\")\n", window ? window->Name : NULL); - } - - // Close popups if any - ClosePopupsOverWindow(window, false); - - // Move the root window to the top of the pile - IM_ASSERT(window == NULL || window->RootWindow != NULL); - ImGuiWindow* focus_front_window = window ? window->RootWindow : NULL; // NB: In docking branch this is window->RootWindowDockStop - ImGuiWindow* display_front_window = window ? window->RootWindow : NULL; - - // Steal active widgets. Some of the cases it triggers includes: - // - Focus a window while an InputText in another window is active, if focus happens before the old InputText can run. - // - When using Nav to activate menu items (due to timing of activating on press->new window appears->losing ActiveId) - if (g.ActiveId != 0 && g.ActiveIdWindow && g.ActiveIdWindow->RootWindow != focus_front_window) - if (!g.ActiveIdNoClearOnFocusLoss) - ClearActiveID(); - - // Passing NULL allow to disable keyboard focus - if (!window) - return; - - // Bring to front - BringWindowToFocusFront(focus_front_window); - if (((window->Flags | display_front_window->Flags) & ImGuiWindowFlags_NoBringToFrontOnFocus) == 0) - BringWindowToDisplayFront(display_front_window); -} - -void ImGui::FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWindow* ignore_window) -{ - ImGuiContext& g = *GImGui; - int start_idx = g.WindowsFocusOrder.Size - 1; - if (under_this_window != NULL) - { - // Aim at root window behind us, if we are in a child window that's our own root (see #4640) - int offset = -1; - while (under_this_window->Flags & ImGuiWindowFlags_ChildWindow) - { - under_this_window = under_this_window->ParentWindow; - offset = 0; - } - start_idx = FindWindowFocusIndex(under_this_window) + offset; - } - for (int i = start_idx; i >= 0; i--) - { - // We may later decide to test for different NoXXXInputs based on the active navigation input (mouse vs nav) but that may feel more confusing to the user. - ImGuiWindow* window = g.WindowsFocusOrder[i]; - IM_ASSERT(window == window->RootWindow); - if (window != ignore_window && window->WasActive) - if ((window->Flags & (ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs)) != (ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs)) - { - ImGuiWindow* focus_window = NavRestoreLastChildNavWindow(window); - FocusWindow(focus_window); - return; - } - } - FocusWindow(NULL); -} - -// Important: this alone doesn't alter current ImDrawList state. This is called by PushFont/PopFont only. -void ImGui::SetCurrentFont(ImFont* font) -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(font && font->IsLoaded()); // Font Atlas not created. Did you call io.Fonts->GetTexDataAsRGBA32 / GetTexDataAsAlpha8 ? - IM_ASSERT(font->Scale > 0.0f); - g.Font = font; - g.FontBaseSize = ImMax(1.0f, g.IO.FontGlobalScale * g.Font->FontSize * g.Font->Scale); - g.FontSize = g.CurrentWindow ? g.CurrentWindow->CalcFontSize() : 0.0f; - - ImFontAtlas* atlas = g.Font->ContainerAtlas; - g.DrawListSharedData.TexUvWhitePixel = atlas->TexUvWhitePixel; - g.DrawListSharedData.TexUvLines = atlas->TexUvLines; - g.DrawListSharedData.Font = g.Font; - g.DrawListSharedData.FontSize = g.FontSize; -} - -void ImGui::PushFont(ImFont* font) -{ - ImGuiContext& g = *GImGui; - if (!font) - font = GetDefaultFont(); - SetCurrentFont(font); - g.FontStack.push_back(font); - g.CurrentWindow->DrawList->PushTextureID(font->ContainerAtlas->TexID); -} - -void ImGui::PopFont() -{ - ImGuiContext& g = *GImGui; - g.CurrentWindow->DrawList->PopTextureID(); - g.FontStack.pop_back(); - SetCurrentFont(g.FontStack.empty() ? GetDefaultFont() : g.FontStack.back()); -} - -void ImGui::PushItemFlag(ImGuiItemFlags option, bool enabled) -{ - ImGuiContext& g = *GImGui; - ImGuiItemFlags item_flags = g.CurrentItemFlags; - IM_ASSERT(item_flags == g.ItemFlagsStack.back()); - if (enabled) - item_flags |= option; - else - item_flags &= ~option; - g.CurrentItemFlags = item_flags; - g.ItemFlagsStack.push_back(item_flags); -} - -void ImGui::PopItemFlag() -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(g.ItemFlagsStack.Size > 1); // Too many calls to PopItemFlag() - we always leave a 0 at the bottom of the stack. - g.ItemFlagsStack.pop_back(); - g.CurrentItemFlags = g.ItemFlagsStack.back(); -} - -// BeginDisabled()/EndDisabled() -// - Those can be nested but it cannot be used to enable an already disabled section (a single BeginDisabled(true) in the stack is enough to keep everything disabled) -// - Visually this is currently altering alpha, but it is expected that in a future styling system this would work differently. -// - Feedback welcome at https://github.com/ocornut/imgui/issues/211 -// - BeginDisabled(false) essentially does nothing useful but is provided to facilitate use of boolean expressions. If you can avoid calling BeginDisabled(False)/EndDisabled() best to avoid it. -// - Optimized shortcuts instead of PushStyleVar() + PushItemFlag() -void ImGui::BeginDisabled(bool disabled) -{ - ImGuiContext& g = *GImGui; - bool was_disabled = (g.CurrentItemFlags & ImGuiItemFlags_Disabled) != 0; - if (!was_disabled && disabled) - { - g.DisabledAlphaBackup = g.Style.Alpha; - g.Style.Alpha *= g.Style.DisabledAlpha; // PushStyleVar(ImGuiStyleVar_Alpha, g.Style.Alpha * g.Style.DisabledAlpha); - } - if (was_disabled || disabled) - g.CurrentItemFlags |= ImGuiItemFlags_Disabled; - g.ItemFlagsStack.push_back(g.CurrentItemFlags); - g.DisabledStackSize++; -} - -void ImGui::EndDisabled() -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(g.DisabledStackSize > 0); - g.DisabledStackSize--; - bool was_disabled = (g.CurrentItemFlags & ImGuiItemFlags_Disabled) != 0; - //PopItemFlag(); - g.ItemFlagsStack.pop_back(); - g.CurrentItemFlags = g.ItemFlagsStack.back(); - if (was_disabled && (g.CurrentItemFlags & ImGuiItemFlags_Disabled) == 0) - g.Style.Alpha = g.DisabledAlphaBackup; //PopStyleVar(); -} - -// FIXME: Look into renaming this once we have settled the new Focus/Activation/TabStop system. -void ImGui::PushAllowKeyboardFocus(bool allow_keyboard_focus) -{ - PushItemFlag(ImGuiItemFlags_NoTabStop, !allow_keyboard_focus); -} - -void ImGui::PopAllowKeyboardFocus() -{ - PopItemFlag(); -} - -void ImGui::PushButtonRepeat(bool repeat) -{ - PushItemFlag(ImGuiItemFlags_ButtonRepeat, repeat); -} - -void ImGui::PopButtonRepeat() -{ - PopItemFlag(); -} - -void ImGui::PushTextWrapPos(float wrap_pos_x) -{ - ImGuiWindow* window = GetCurrentWindow(); - window->DC.TextWrapPosStack.push_back(window->DC.TextWrapPos); - window->DC.TextWrapPos = wrap_pos_x; -} - -void ImGui::PopTextWrapPos() -{ - ImGuiWindow* window = GetCurrentWindow(); - window->DC.TextWrapPos = window->DC.TextWrapPosStack.back(); - window->DC.TextWrapPosStack.pop_back(); -} - -static ImGuiWindow* GetCombinedRootWindow(ImGuiWindow* window, bool popup_hierarchy) -{ - window = window->RootWindow; - if (popup_hierarchy) - window = window->RootWindowPopupTree; - return window; -} - -bool ImGui::IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent, bool popup_hierarchy) -{ - ImGuiWindow* window_root = GetCombinedRootWindow(window, popup_hierarchy); - if (window_root == potential_parent) - return true; - while (window != NULL) - { - if (window == potential_parent) - return true; - if (window == window_root) // end of chain - return false; - window = window->ParentWindow; - } - return false; -} - -bool ImGui::IsWindowAbove(ImGuiWindow* potential_above, ImGuiWindow* potential_below) -{ - ImGuiContext& g = *GImGui; - for (int i = g.Windows.Size - 1; i >= 0; i--) - { - ImGuiWindow* candidate_window = g.Windows[i]; - if (candidate_window == potential_above) - return true; - if (candidate_window == potential_below) - return false; - } - return false; -} - -bool ImGui::IsWindowHovered(ImGuiHoveredFlags flags) -{ - IM_ASSERT((flags & (ImGuiHoveredFlags_AllowWhenOverlapped | ImGuiHoveredFlags_AllowWhenDisabled)) == 0); // Flags not supported by this function - ImGuiContext& g = *GImGui; - ImGuiWindow* ref_window = g.HoveredWindow; - ImGuiWindow* cur_window = g.CurrentWindow; - if (ref_window == NULL) - return false; - - if ((flags & ImGuiHoveredFlags_AnyWindow) == 0) - { - IM_ASSERT(cur_window); // Not inside a Begin()/End() - const bool popup_hierarchy = (flags & ImGuiHoveredFlags_NoPopupHierarchy) == 0; - if (flags & ImGuiHoveredFlags_RootWindow) - cur_window = GetCombinedRootWindow(cur_window, popup_hierarchy); - - bool result; - if (flags & ImGuiHoveredFlags_ChildWindows) - result = IsWindowChildOf(ref_window, cur_window, popup_hierarchy); - else - result = (ref_window == cur_window); - if (!result) - return false; - } - - if (!IsWindowContentHoverable(ref_window, flags)) - return false; - if (!(flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) - if (g.ActiveId != 0 && !g.ActiveIdAllowOverlap && g.ActiveId != ref_window->MoveId) - return false; - return true; -} - -bool ImGui::IsWindowFocused(ImGuiFocusedFlags flags) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* ref_window = g.NavWindow; - ImGuiWindow* cur_window = g.CurrentWindow; - - if (ref_window == NULL) - return false; - if (flags & ImGuiFocusedFlags_AnyWindow) - return true; - IM_ASSERT(cur_window); // Not inside a Begin()/End() - - const bool popup_hierarchy = (flags & ImGuiFocusedFlags_NoPopupHierarchy) == 0; - if (flags & ImGuiHoveredFlags_RootWindow) - cur_window = GetCombinedRootWindow(cur_window, popup_hierarchy); - - if (flags & ImGuiHoveredFlags_ChildWindows) - return IsWindowChildOf(ref_window, cur_window, popup_hierarchy); - else - return (ref_window == cur_window); -} - -// Can we focus this window with CTRL+TAB (or PadMenu + PadFocusPrev/PadFocusNext) -// Note that NoNavFocus makes the window not reachable with CTRL+TAB but it can still be focused with mouse or programmatically. -// If you want a window to never be focused, you may use the e.g. NoInputs flag. -bool ImGui::IsWindowNavFocusable(ImGuiWindow* window) -{ - return window->WasActive && window == window->RootWindow && !(window->Flags & ImGuiWindowFlags_NoNavFocus); -} - -float ImGui::GetWindowWidth() -{ - ImGuiWindow* window = GImGui->CurrentWindow; - return window->Size.x; -} - -float ImGui::GetWindowHeight() -{ - ImGuiWindow* window = GImGui->CurrentWindow; - return window->Size.y; -} - -ImVec2 ImGui::GetWindowPos() -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - return window->Pos; -} - -void ImGui::SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond) -{ - // Test condition (NB: bit 0 is always true) and clear flags for next time - if (cond && (window->SetWindowPosAllowFlags & cond) == 0) - return; - - IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags. - window->SetWindowPosAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing); - window->SetWindowPosVal = ImVec2(FLT_MAX, FLT_MAX); - - // Set - const ImVec2 old_pos = window->Pos; - window->Pos = ImFloor(pos); - ImVec2 offset = window->Pos - old_pos; - window->DC.CursorPos += offset; // As we happen to move the window while it is being appended to (which is a bad idea - will smear) let's at least offset the cursor - window->DC.CursorMaxPos += offset; // And more importantly we need to offset CursorMaxPos/CursorStartPos this so ContentSize calculation doesn't get affected. - window->DC.IdealMaxPos += offset; - window->DC.CursorStartPos += offset; -} - -void ImGui::SetWindowPos(const ImVec2& pos, ImGuiCond cond) -{ - ImGuiWindow* window = GetCurrentWindowRead(); - SetWindowPos(window, pos, cond); -} - -void ImGui::SetWindowPos(const char* name, const ImVec2& pos, ImGuiCond cond) -{ - if (ImGuiWindow* window = FindWindowByName(name)) - SetWindowPos(window, pos, cond); -} - -ImVec2 ImGui::GetWindowSize() -{ - ImGuiWindow* window = GetCurrentWindowRead(); - return window->Size; -} - -void ImGui::SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond cond) -{ - // Test condition (NB: bit 0 is always true) and clear flags for next time - if (cond && (window->SetWindowSizeAllowFlags & cond) == 0) - return; - - IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags. - window->SetWindowSizeAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing); - - // Set - if (size.x > 0.0f) - { - window->AutoFitFramesX = 0; - window->SizeFull.x = IM_FLOOR(size.x); - } - else - { - window->AutoFitFramesX = 2; - window->AutoFitOnlyGrows = false; - } - if (size.y > 0.0f) - { - window->AutoFitFramesY = 0; - window->SizeFull.y = IM_FLOOR(size.y); - } - else - { - window->AutoFitFramesY = 2; - window->AutoFitOnlyGrows = false; - } -} - -void ImGui::SetWindowSize(const ImVec2& size, ImGuiCond cond) -{ - SetWindowSize(GImGui->CurrentWindow, size, cond); -} - -void ImGui::SetWindowSize(const char* name, const ImVec2& size, ImGuiCond cond) -{ - if (ImGuiWindow* window = FindWindowByName(name)) - SetWindowSize(window, size, cond); -} - -void ImGui::SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond) -{ - // Test condition (NB: bit 0 is always true) and clear flags for next time - if (cond && (window->SetWindowCollapsedAllowFlags & cond) == 0) - return; - window->SetWindowCollapsedAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing); - - // Set - window->Collapsed = collapsed; -} - -void ImGui::SetWindowHitTestHole(ImGuiWindow* window, const ImVec2& pos, const ImVec2& size) -{ - IM_ASSERT(window->HitTestHoleSize.x == 0); // We don't support multiple holes/hit test filters - window->HitTestHoleSize = ImVec2ih(size); - window->HitTestHoleOffset = ImVec2ih(pos - window->Pos); -} - -void ImGui::SetWindowCollapsed(bool collapsed, ImGuiCond cond) -{ - SetWindowCollapsed(GImGui->CurrentWindow, collapsed, cond); -} - -bool ImGui::IsWindowCollapsed() -{ - ImGuiWindow* window = GetCurrentWindowRead(); - return window->Collapsed; -} - -bool ImGui::IsWindowAppearing() -{ - ImGuiWindow* window = GetCurrentWindowRead(); - return window->Appearing; -} - -void ImGui::SetWindowCollapsed(const char* name, bool collapsed, ImGuiCond cond) -{ - if (ImGuiWindow* window = FindWindowByName(name)) - SetWindowCollapsed(window, collapsed, cond); -} - -void ImGui::SetWindowFocus() -{ - FocusWindow(GImGui->CurrentWindow); -} - -void ImGui::SetWindowFocus(const char* name) -{ - if (name) - { - if (ImGuiWindow* window = FindWindowByName(name)) - FocusWindow(window); - } - else - { - FocusWindow(NULL); - } -} - -void ImGui::SetNextWindowPos(const ImVec2& pos, ImGuiCond cond, const ImVec2& pivot) -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags. - g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasPos; - g.NextWindowData.PosVal = pos; - g.NextWindowData.PosPivotVal = pivot; - g.NextWindowData.PosCond = cond ? cond : ImGuiCond_Always; -} - -void ImGui::SetNextWindowSize(const ImVec2& size, ImGuiCond cond) -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags. - g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasSize; - g.NextWindowData.SizeVal = size; - g.NextWindowData.SizeCond = cond ? cond : ImGuiCond_Always; -} - -void ImGui::SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeCallback custom_callback, void* custom_callback_user_data) -{ - ImGuiContext& g = *GImGui; - g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasSizeConstraint; - g.NextWindowData.SizeConstraintRect = ImRect(size_min, size_max); - g.NextWindowData.SizeCallback = custom_callback; - g.NextWindowData.SizeCallbackUserData = custom_callback_user_data; -} - -// Content size = inner scrollable rectangle, padded with WindowPadding. -// SetNextWindowContentSize(ImVec2(100,100) + ImGuiWindowFlags_AlwaysAutoResize will always allow submitting a 100x100 item. -void ImGui::SetNextWindowContentSize(const ImVec2& size) -{ - ImGuiContext& g = *GImGui; - g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasContentSize; - g.NextWindowData.ContentSizeVal = ImFloor(size); -} - -void ImGui::SetNextWindowScroll(const ImVec2& scroll) -{ - ImGuiContext& g = *GImGui; - g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasScroll; - g.NextWindowData.ScrollVal = scroll; -} - -void ImGui::SetNextWindowCollapsed(bool collapsed, ImGuiCond cond) -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags. - g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasCollapsed; - g.NextWindowData.CollapsedVal = collapsed; - g.NextWindowData.CollapsedCond = cond ? cond : ImGuiCond_Always; -} - -void ImGui::SetNextWindowFocus() -{ - ImGuiContext& g = *GImGui; - g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasFocus; -} - -void ImGui::SetNextWindowBgAlpha(float alpha) -{ - ImGuiContext& g = *GImGui; - g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasBgAlpha; - g.NextWindowData.BgAlphaVal = alpha; -} - -ImDrawList* ImGui::GetWindowDrawList() -{ - ImGuiWindow* window = GetCurrentWindow(); - return window->DrawList; -} - -ImFont* ImGui::GetFont() -{ - return GImGui->Font; -} - -float ImGui::GetFontSize() -{ - return GImGui->FontSize; -} - -ImVec2 ImGui::GetFontTexUvWhitePixel() -{ - return GImGui->DrawListSharedData.TexUvWhitePixel; -} - -void ImGui::SetWindowFontScale(float scale) -{ - IM_ASSERT(scale > 0.0f); - ImGuiContext& g = *GImGui; - ImGuiWindow* window = GetCurrentWindow(); - window->FontWindowScale = scale; - g.FontSize = g.DrawListSharedData.FontSize = window->CalcFontSize(); -} - -void ImGui::ActivateItem(ImGuiID id) -{ - ImGuiContext& g = *GImGui; - g.NavNextActivateId = id; - g.NavNextActivateFlags = ImGuiActivateFlags_None; -} - -void ImGui::PushFocusScope(ImGuiID id) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - g.FocusScopeStack.push_back(window->DC.NavFocusScopeIdCurrent); - window->DC.NavFocusScopeIdCurrent = id; -} - -void ImGui::PopFocusScope() -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - IM_ASSERT(g.FocusScopeStack.Size > 0); // Too many PopFocusScope() ? - window->DC.NavFocusScopeIdCurrent = g.FocusScopeStack.back(); - g.FocusScopeStack.pop_back(); -} - -void ImGui::SetKeyboardFocusHere(int offset) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - IM_ASSERT(offset >= -1); // -1 is allowed but not below - g.NavWindow = window; - ImGuiScrollFlags scroll_flags = window->Appearing ? ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_AlwaysCenterY : ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_KeepVisibleEdgeY; - NavMoveRequestSubmit(ImGuiDir_None, ImGuiDir_None, ImGuiNavMoveFlags_Tabbing, scroll_flags); // FIXME-NAV: Once we refactor tabbing, add LegacyApi flag to not activate non-inputable. - if (offset == -1) - NavMoveRequestResolveWithLastItem(); - else - g.NavTabbingInputableRemaining = offset + 1; -} - -void ImGui::SetItemDefaultFocus() -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - if (!window->Appearing) - return; - if (g.NavWindow != window->RootWindowForNav || (!g.NavInitRequest && g.NavInitResultId == 0) || g.NavLayer != window->DC.NavLayerCurrent) - return; - - g.NavInitRequest = false; - g.NavInitResultId = g.LastItemData.ID; - g.NavInitResultRectRel = ImRect(g.LastItemData.Rect.Min - window->Pos, g.LastItemData.Rect.Max - window->Pos); - NavUpdateAnyRequestFlag(); - - // Scroll could be done in NavInitRequestApplyResult() via a opt-in flag (we however don't want regular init requests to scroll) - if (!IsItemVisible()) - ScrollToRectEx(window, g.LastItemData.Rect, ImGuiScrollFlags_None); -} - -void ImGui::SetStateStorage(ImGuiStorage* tree) -{ - ImGuiWindow* window = GImGui->CurrentWindow; - window->DC.StateStorage = tree ? tree : &window->StateStorage; -} - -ImGuiStorage* ImGui::GetStateStorage() -{ - ImGuiWindow* window = GImGui->CurrentWindow; - return window->DC.StateStorage; -} - -void ImGui::PushID(const char* str_id) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - ImGuiID id = window->GetIDNoKeepAlive(str_id); - window->IDStack.push_back(id); -} - -void ImGui::PushID(const char* str_id_begin, const char* str_id_end) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - ImGuiID id = window->GetIDNoKeepAlive(str_id_begin, str_id_end); - window->IDStack.push_back(id); -} - -void ImGui::PushID(const void* ptr_id) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - ImGuiID id = window->GetIDNoKeepAlive(ptr_id); - window->IDStack.push_back(id); -} - -void ImGui::PushID(int int_id) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - ImGuiID id = window->GetIDNoKeepAlive(int_id); - window->IDStack.push_back(id); -} - -// Push a given id value ignoring the ID stack as a seed. -void ImGui::PushOverrideID(ImGuiID id) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - if (g.DebugHookIdInfo == id) - DebugHookIdInfo(id, ImGuiDataType_ID, NULL, NULL); - window->IDStack.push_back(id); -} - -// Helper to avoid a common series of PushOverrideID -> GetID() -> PopID() call -// (note that when using this pattern, TestEngine's "Stack Tool" will tend to not display the intermediate stack level. -// for that to work we would need to do PushOverrideID() -> ItemAdd() -> PopID() which would alter widget code a little more) -ImGuiID ImGui::GetIDWithSeed(const char* str, const char* str_end, ImGuiID seed) -{ - ImGuiID id = ImHashStr(str, str_end ? (str_end - str) : 0, seed); - KeepAliveID(id); - ImGuiContext& g = *GImGui; - if (g.DebugHookIdInfo == id) - DebugHookIdInfo(id, ImGuiDataType_String, str, str_end); - return id; -} - -void ImGui::PopID() -{ - ImGuiWindow* window = GImGui->CurrentWindow; - IM_ASSERT(window->IDStack.Size > 1); // Too many PopID(), or could be popping in a wrong/different window? - window->IDStack.pop_back(); -} - -ImGuiID ImGui::GetID(const char* str_id) -{ - ImGuiWindow* window = GImGui->CurrentWindow; - return window->GetID(str_id); -} - -ImGuiID ImGui::GetID(const char* str_id_begin, const char* str_id_end) -{ - ImGuiWindow* window = GImGui->CurrentWindow; - return window->GetID(str_id_begin, str_id_end); -} - -ImGuiID ImGui::GetID(const void* ptr_id) -{ - ImGuiWindow* window = GImGui->CurrentWindow; - return window->GetID(ptr_id); -} - -bool ImGui::IsRectVisible(const ImVec2& size) -{ - ImGuiWindow* window = GImGui->CurrentWindow; - return window->ClipRect.Overlaps(ImRect(window->DC.CursorPos, window->DC.CursorPos + size)); -} - -bool ImGui::IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max) -{ - ImGuiWindow* window = GImGui->CurrentWindow; - return window->ClipRect.Overlaps(ImRect(rect_min, rect_max)); -} - - -//----------------------------------------------------------------------------- -// [SECTION] ERROR CHECKING -//----------------------------------------------------------------------------- - -// Helper function to verify ABI compatibility between caller code and compiled version of Dear ImGui. -// Verify that the type sizes are matching between the calling file's compilation unit and imgui.cpp's compilation unit -// If the user has inconsistent compilation settings, imgui configuration #define, packing pragma, etc. your user code -// may see different structures than what imgui.cpp sees, which is problematic. -// We usually require settings to be in imconfig.h to make sure that they are accessible to all compilation units involved with Dear ImGui. -bool ImGui::DebugCheckVersionAndDataLayout(const char* version, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_vert, size_t sz_idx) -{ - bool error = false; - if (strcmp(version, IMGUI_VERSION) != 0) { error = true; IM_ASSERT(strcmp(version, IMGUI_VERSION) == 0 && "Mismatched version string!"); } - if (sz_io != sizeof(ImGuiIO)) { error = true; IM_ASSERT(sz_io == sizeof(ImGuiIO) && "Mismatched struct layout!"); } - if (sz_style != sizeof(ImGuiStyle)) { error = true; IM_ASSERT(sz_style == sizeof(ImGuiStyle) && "Mismatched struct layout!"); } - if (sz_vec2 != sizeof(ImVec2)) { error = true; IM_ASSERT(sz_vec2 == sizeof(ImVec2) && "Mismatched struct layout!"); } - if (sz_vec4 != sizeof(ImVec4)) { error = true; IM_ASSERT(sz_vec4 == sizeof(ImVec4) && "Mismatched struct layout!"); } - if (sz_vert != sizeof(ImDrawVert)) { error = true; IM_ASSERT(sz_vert == sizeof(ImDrawVert) && "Mismatched struct layout!"); } - if (sz_idx != sizeof(ImDrawIdx)) { error = true; IM_ASSERT(sz_idx == sizeof(ImDrawIdx) && "Mismatched struct layout!"); } - return !error; -} - -static void ImGui::ErrorCheckNewFrameSanityChecks() -{ - ImGuiContext& g = *GImGui; - - // Check user IM_ASSERT macro - // (IF YOU GET A WARNING OR COMPILE ERROR HERE: it means your assert macro is incorrectly defined! - // If your macro uses multiple statements, it NEEDS to be surrounded by a 'do { ... } while (0)' block. - // This is a common C/C++ idiom to allow multiple statements macros to be used in control flow blocks.) - // #define IM_ASSERT(EXPR) if (SomeCode(EXPR)) SomeMoreCode(); // Wrong! - // #define IM_ASSERT(EXPR) do { if (SomeCode(EXPR)) SomeMoreCode(); } while (0) // Correct! - if (true) IM_ASSERT(1); else IM_ASSERT(0); - - // Check user data - // (We pass an error message in the assert expression to make it visible to programmers who are not using a debugger, as most assert handlers display their argument) - IM_ASSERT(g.Initialized); - IM_ASSERT((g.IO.DeltaTime > 0.0f || g.FrameCount == 0) && "Need a positive DeltaTime!"); - IM_ASSERT((g.FrameCount == 0 || g.FrameCountEnded == g.FrameCount) && "Forgot to call Render() or EndFrame() at the end of the previous frame?"); - IM_ASSERT(g.IO.DisplaySize.x >= 0.0f && g.IO.DisplaySize.y >= 0.0f && "Invalid DisplaySize value!"); - IM_ASSERT(g.IO.Fonts->IsBuilt() && "Font Atlas not built! Make sure you called ImGui_ImplXXXX_NewFrame() function for renderer backend, which should call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8()"); - IM_ASSERT(g.Style.CurveTessellationTol > 0.0f && "Invalid style setting!"); - IM_ASSERT(g.Style.CircleTessellationMaxError > 0.0f && "Invalid style setting!"); - IM_ASSERT(g.Style.Alpha >= 0.0f && g.Style.Alpha <= 1.0f && "Invalid style setting!"); // Allows us to avoid a few clamps in color computations - IM_ASSERT(g.Style.WindowMinSize.x >= 1.0f && g.Style.WindowMinSize.y >= 1.0f && "Invalid style setting."); - IM_ASSERT(g.Style.WindowMenuButtonPosition == ImGuiDir_None || g.Style.WindowMenuButtonPosition == ImGuiDir_Left || g.Style.WindowMenuButtonPosition == ImGuiDir_Right); - for (int n = 0; n < ImGuiKey_COUNT; n++) - IM_ASSERT(g.IO.KeyMap[n] >= -1 && g.IO.KeyMap[n] < IM_ARRAYSIZE(g.IO.KeysDown) && "io.KeyMap[] contains an out of bound value (need to be 0..512, or -1 for unmapped key)"); - - // Check: required key mapping (we intentionally do NOT check all keys to not pressure user into setting up everything, but Space is required and was only added in 1.60 WIP) - if (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) - IM_ASSERT(g.IO.KeyMap[ImGuiKey_Space] != -1 && "ImGuiKey_Space is not mapped, required for keyboard navigation."); - - // Check: the io.ConfigWindowsResizeFromEdges option requires backend to honor mouse cursor changes and set the ImGuiBackendFlags_HasMouseCursors flag accordingly. - if (g.IO.ConfigWindowsResizeFromEdges && !(g.IO.BackendFlags & ImGuiBackendFlags_HasMouseCursors)) - g.IO.ConfigWindowsResizeFromEdges = false; -} - -static void ImGui::ErrorCheckEndFrameSanityChecks() -{ - ImGuiContext& g = *GImGui; - - // Verify that io.KeyXXX fields haven't been tampered with. Key mods should not be modified between NewFrame() and EndFrame() - // One possible reason leading to this assert is that your backends update inputs _AFTER_ NewFrame(). - // It is known that when some modal native windows called mid-frame takes focus away, some backends such as GLFW will - // send key release events mid-frame. This would normally trigger this assertion and lead to sheared inputs. - // We silently accommodate for this case by ignoring/ the case where all io.KeyXXX modifiers were released (aka key_mod_flags == 0), - // while still correctly asserting on mid-frame key press events. - const ImGuiKeyModFlags key_mod_flags = GetMergedKeyModFlags(); - IM_ASSERT((key_mod_flags == 0 || g.IO.KeyMods == key_mod_flags) && "Mismatching io.KeyCtrl/io.KeyShift/io.KeyAlt/io.KeySuper vs io.KeyMods"); - IM_UNUSED(key_mod_flags); - - // Recover from errors - //ErrorCheckEndFrameRecover(); - - // Report when there is a mismatch of Begin/BeginChild vs End/EndChild calls. Important: Remember that the Begin/BeginChild API requires you - // to always call End/EndChild even if Begin/BeginChild returns false! (this is unfortunately inconsistent with most other Begin* API). - if (g.CurrentWindowStack.Size != 1) - { - if (g.CurrentWindowStack.Size > 1) - { - IM_ASSERT_USER_ERROR(g.CurrentWindowStack.Size == 1, "Mismatched Begin/BeginChild vs End/EndChild calls: did you forget to call End/EndChild?"); - while (g.CurrentWindowStack.Size > 1) - End(); - } - else - { - IM_ASSERT_USER_ERROR(g.CurrentWindowStack.Size == 1, "Mismatched Begin/BeginChild vs End/EndChild calls: did you call End/EndChild too much?"); - } - } - - IM_ASSERT_USER_ERROR(g.GroupStack.Size == 0, "Missing EndGroup call!"); -} - -// Experimental recovery from incorrect usage of BeginXXX/EndXXX/PushXXX/PopXXX calls. -// Must be called during or before EndFrame(). -// This is generally flawed as we are not necessarily End/Popping things in the right order. -// FIXME: Can't recover from inside BeginTabItem/EndTabItem yet. -// FIXME: Can't recover from interleaved BeginTabBar/Begin -void ImGui::ErrorCheckEndFrameRecover(ImGuiErrorLogCallback log_callback, void* user_data) -{ - // PVS-Studio V1044 is "Loop break conditions do not depend on the number of iterations" - ImGuiContext& g = *GImGui; - while (g.CurrentWindowStack.Size > 0) //-V1044 - { - ErrorCheckEndWindowRecover(log_callback, user_data); - ImGuiWindow* window = g.CurrentWindow; - if (g.CurrentWindowStack.Size == 1) - { - IM_ASSERT(window->IsFallbackWindow); - break; - } - IM_ASSERT(window == g.CurrentWindow); - if (window->Flags & ImGuiWindowFlags_ChildWindow) - { - if (log_callback) log_callback(user_data, "Recovered from missing EndChild() for '%s'", window->Name); - EndChild(); - } - else - { - if (log_callback) log_callback(user_data, "Recovered from missing End() for '%s'", window->Name); - End(); - } - } -} - -// Must be called before End()/EndChild() -void ImGui::ErrorCheckEndWindowRecover(ImGuiErrorLogCallback log_callback, void* user_data) -{ - ImGuiContext& g = *GImGui; - while (g.CurrentTable && (g.CurrentTable->OuterWindow == g.CurrentWindow || g.CurrentTable->InnerWindow == g.CurrentWindow)) - { - if (log_callback) log_callback(user_data, "Recovered from missing EndTable() in '%s'", g.CurrentTable->OuterWindow->Name); - EndTable(); - } - - ImGuiWindow* window = g.CurrentWindow; - ImGuiStackSizes* stack_sizes = &g.CurrentWindowStack.back().StackSizesOnBegin; - IM_ASSERT(window != NULL); - while (g.CurrentTabBar != NULL) //-V1044 - { - if (log_callback) log_callback(user_data, "Recovered from missing EndTabBar() in '%s'", window->Name); - EndTabBar(); - } - while (window->DC.TreeDepth > 0) - { - if (log_callback) log_callback(user_data, "Recovered from missing TreePop() in '%s'", window->Name); - TreePop(); - } - while (g.GroupStack.Size > stack_sizes->SizeOfGroupStack) //-V1044 - { - if (log_callback) log_callback(user_data, "Recovered from missing EndGroup() in '%s'", window->Name); - EndGroup(); - } - while (window->IDStack.Size > 1) - { - if (log_callback) log_callback(user_data, "Recovered from missing PopID() in '%s'", window->Name); - PopID(); - } - while (g.DisabledStackSize > stack_sizes->SizeOfDisabledStack) //-V1044 - { - if (log_callback) log_callback(user_data, "Recovered from missing EndDisabled() in '%s'", window->Name); - EndDisabled(); - } - while (g.ColorStack.Size > stack_sizes->SizeOfColorStack) - { - if (log_callback) log_callback(user_data, "Recovered from missing PopStyleColor() in '%s' for ImGuiCol_%s", window->Name, GetStyleColorName(g.ColorStack.back().Col)); - PopStyleColor(); - } - while (g.ItemFlagsStack.Size > stack_sizes->SizeOfItemFlagsStack) //-V1044 - { - if (log_callback) log_callback(user_data, "Recovered from missing PopItemFlag() in '%s'", window->Name); - PopItemFlag(); - } - while (g.StyleVarStack.Size > stack_sizes->SizeOfStyleVarStack) //-V1044 - { - if (log_callback) log_callback(user_data, "Recovered from missing PopStyleVar() in '%s'", window->Name); - PopStyleVar(); - } - while (g.FocusScopeStack.Size > stack_sizes->SizeOfFocusScopeStack) //-V1044 - { - if (log_callback) log_callback(user_data, "Recovered from missing PopFocusScope() in '%s'", window->Name); - PopFocusScope(); - } -} - -// Save current stack sizes for later compare -void ImGuiStackSizes::SetToCurrentState() -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - SizeOfIDStack = (short)window->IDStack.Size; - SizeOfColorStack = (short)g.ColorStack.Size; - SizeOfStyleVarStack = (short)g.StyleVarStack.Size; - SizeOfFontStack = (short)g.FontStack.Size; - SizeOfFocusScopeStack = (short)g.FocusScopeStack.Size; - SizeOfGroupStack = (short)g.GroupStack.Size; - SizeOfItemFlagsStack = (short)g.ItemFlagsStack.Size; - SizeOfBeginPopupStack = (short)g.BeginPopupStack.Size; - SizeOfDisabledStack = (short)g.DisabledStackSize; -} - -// Compare to detect usage errors -void ImGuiStackSizes::CompareWithCurrentState() -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - IM_UNUSED(window); - - // Window stacks - // NOT checking: DC.ItemWidth, DC.TextWrapPos (per window) to allow user to conveniently push once and not pop (they are cleared on Begin) - IM_ASSERT(SizeOfIDStack == window->IDStack.Size && "PushID/PopID or TreeNode/TreePop Mismatch!"); - - // Global stacks - // For color, style and font stacks there is an incentive to use Push/Begin/Pop/.../End patterns, so we relax our checks a little to allow them. - IM_ASSERT(SizeOfGroupStack == g.GroupStack.Size && "BeginGroup/EndGroup Mismatch!"); - IM_ASSERT(SizeOfBeginPopupStack == g.BeginPopupStack.Size && "BeginPopup/EndPopup or BeginMenu/EndMenu Mismatch!"); - IM_ASSERT(SizeOfDisabledStack == g.DisabledStackSize && "BeginDisabled/EndDisabled Mismatch!"); - IM_ASSERT(SizeOfItemFlagsStack >= g.ItemFlagsStack.Size && "PushItemFlag/PopItemFlag Mismatch!"); - IM_ASSERT(SizeOfColorStack >= g.ColorStack.Size && "PushStyleColor/PopStyleColor Mismatch!"); - IM_ASSERT(SizeOfStyleVarStack >= g.StyleVarStack.Size && "PushStyleVar/PopStyleVar Mismatch!"); - IM_ASSERT(SizeOfFontStack >= g.FontStack.Size && "PushFont/PopFont Mismatch!"); - IM_ASSERT(SizeOfFocusScopeStack == g.FocusScopeStack.Size && "PushFocusScope/PopFocusScope Mismatch!"); -} - - -//----------------------------------------------------------------------------- -// [SECTION] LAYOUT -//----------------------------------------------------------------------------- -// - ItemSize() -// - ItemAdd() -// - SameLine() -// - GetCursorScreenPos() -// - SetCursorScreenPos() -// - GetCursorPos(), GetCursorPosX(), GetCursorPosY() -// - SetCursorPos(), SetCursorPosX(), SetCursorPosY() -// - GetCursorStartPos() -// - Indent() -// - Unindent() -// - SetNextItemWidth() -// - PushItemWidth() -// - PushMultiItemsWidths() -// - PopItemWidth() -// - CalcItemWidth() -// - CalcItemSize() -// - GetTextLineHeight() -// - GetTextLineHeightWithSpacing() -// - GetFrameHeight() -// - GetFrameHeightWithSpacing() -// - GetContentRegionMax() -// - GetContentRegionMaxAbs() [Internal] -// - GetContentRegionAvail(), -// - GetWindowContentRegionMin(), GetWindowContentRegionMax() -// - BeginGroup() -// - EndGroup() -// Also see in imgui_widgets: tab bars, columns. -//----------------------------------------------------------------------------- - -// Advance cursor given item size for layout. -// Register minimum needed size so it can extend the bounding box used for auto-fit calculation. -// See comments in ItemAdd() about how/why the size provided to ItemSize() vs ItemAdd() may often different. -void ImGui::ItemSize(const ImVec2& size, float text_baseline_y) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - if (window->SkipItems) - return; - - // We increase the height in this function to accommodate for baseline offset. - // In theory we should be offsetting the starting position (window->DC.CursorPos), that will be the topic of a larger refactor, - // but since ItemSize() is not yet an API that moves the cursor (to handle e.g. wrapping) enlarging the height has the same effect. - const float offset_to_match_baseline_y = (text_baseline_y >= 0) ? ImMax(0.0f, window->DC.CurrLineTextBaseOffset - text_baseline_y) : 0.0f; - const float line_height = ImMax(window->DC.CurrLineSize.y, size.y + offset_to_match_baseline_y); - - // Always align ourselves on pixel boundaries - //if (g.IO.KeyAlt) window->DrawList->AddRect(window->DC.CursorPos, window->DC.CursorPos + ImVec2(size.x, line_height), IM_COL32(255,0,0,200)); // [DEBUG] - window->DC.CursorPosPrevLine.x = window->DC.CursorPos.x + size.x; - window->DC.CursorPosPrevLine.y = window->DC.CursorPos.y; - window->DC.CursorPos.x = IM_FLOOR(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x); // Next line - window->DC.CursorPos.y = IM_FLOOR(window->DC.CursorPos.y + line_height + g.Style.ItemSpacing.y); // Next line - window->DC.CursorMaxPos.x = ImMax(window->DC.CursorMaxPos.x, window->DC.CursorPosPrevLine.x); - window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, window->DC.CursorPos.y - g.Style.ItemSpacing.y); - //if (g.IO.KeyAlt) window->DrawList->AddCircle(window->DC.CursorMaxPos, 3.0f, IM_COL32(255,0,0,255), 4); // [DEBUG] - - window->DC.PrevLineSize.y = line_height; - window->DC.CurrLineSize.y = 0.0f; - window->DC.PrevLineTextBaseOffset = ImMax(window->DC.CurrLineTextBaseOffset, text_baseline_y); - window->DC.CurrLineTextBaseOffset = 0.0f; - - // Horizontal layout mode - if (window->DC.LayoutType == ImGuiLayoutType_Horizontal) - SameLine(); -} - -void ImGui::ItemSize(const ImRect& bb, float text_baseline_y) -{ - ItemSize(bb.GetSize(), text_baseline_y); -} - -// Declare item bounding box for clipping and interaction. -// Note that the size can be different than the one provided to ItemSize(). Typically, widgets that spread over available surface -// declare their minimum size requirement to ItemSize() and provide a larger region to ItemAdd() which is used drawing/interaction. -bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg, ImGuiItemFlags extra_flags) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - - // Set item data - // (DisplayRect is left untouched, made valid when ImGuiItemStatusFlags_HasDisplayRect is set) - g.LastItemData.ID = id; - g.LastItemData.Rect = bb; - g.LastItemData.NavRect = nav_bb_arg ? *nav_bb_arg : bb; - g.LastItemData.InFlags = g.CurrentItemFlags | extra_flags; - g.LastItemData.StatusFlags = ImGuiItemStatusFlags_None; - - // Directional navigation processing - if (id != 0) - { - // Runs prior to clipping early-out - // (a) So that NavInitRequest can be honored, for newly opened windows to select a default widget - // (b) So that we can scroll up/down past clipped items. This adds a small O(N) cost to regular navigation requests - // unfortunately, but it is still limited to one window. It may not scale very well for windows with ten of - // thousands of item, but at least NavMoveRequest is only set on user interaction, aka maximum once a frame. - // We could early out with "if (is_clipped && !g.NavInitRequest) return false;" but when we wouldn't be able - // to reach unclipped widgets. This would work if user had explicit scrolling control (e.g. mapped on a stick). - // We intentionally don't check if g.NavWindow != NULL because g.NavAnyRequest should only be set when it is non null. - // If we crash on a NULL g.NavWindow we need to fix the bug elsewhere. - window->DC.NavLayersActiveMaskNext |= (1 << window->DC.NavLayerCurrent); - if (g.NavId == id || g.NavAnyRequest) - if (g.NavWindow->RootWindowForNav == window->RootWindowForNav) - if (window == g.NavWindow || ((window->Flags | g.NavWindow->Flags) & ImGuiWindowFlags_NavFlattened)) - NavProcessItem(); - - // [DEBUG] Item Picker tool, when enabling the "extended" version we perform the check in ItemAdd() -#ifdef IMGUI_DEBUG_TOOL_ITEM_PICKER_EX - if (id == g.DebugItemPickerBreakId) - { - IM_DEBUG_BREAK(); - g.DebugItemPickerBreakId = 0; - } -#endif - } - g.NextItemData.Flags = ImGuiNextItemDataFlags_None; - -#ifdef IMGUI_ENABLE_TEST_ENGINE - if (id != 0) - IMGUI_TEST_ENGINE_ITEM_ADD(nav_bb_arg ? *nav_bb_arg : bb, id); -#endif - - // Clipping test - const bool is_clipped = IsClippedEx(bb, id); - if (is_clipped) - return false; - //if (g.IO.KeyAlt) window->DrawList->AddRect(bb.Min, bb.Max, IM_COL32(255,255,0,120)); // [DEBUG] - - // [WIP] Tab stop handling (previously was using internal FocusableItemRegister() api) - // FIXME-NAV: We would now want to move this before the clipping test, but this would require being able to scroll and currently this would mean an extra frame. (#4079, #343) - if (extra_flags & ImGuiItemFlags_Inputable) - ItemInputable(window, id); - - // We need to calculate this now to take account of the current clipping rectangle (as items like Selectable may change them) - if (IsMouseHoveringRect(bb.Min, bb.Max)) - g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HoveredRect; - return true; -} - -// Gets back to previous line and continue with horizontal layout -// offset_from_start_x == 0 : follow right after previous item -// offset_from_start_x != 0 : align to specified x position (relative to window/group left) -// spacing_w < 0 : use default spacing if pos_x == 0, no spacing if pos_x != 0 -// spacing_w >= 0 : enforce spacing amount -void ImGui::SameLine(float offset_from_start_x, float spacing_w) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return; - - ImGuiContext& g = *GImGui; - if (offset_from_start_x != 0.0f) - { - if (spacing_w < 0.0f) spacing_w = 0.0f; - window->DC.CursorPos.x = window->Pos.x - window->Scroll.x + offset_from_start_x + spacing_w + window->DC.GroupOffset.x + window->DC.ColumnsOffset.x; - window->DC.CursorPos.y = window->DC.CursorPosPrevLine.y; - } - else - { - if (spacing_w < 0.0f) spacing_w = g.Style.ItemSpacing.x; - window->DC.CursorPos.x = window->DC.CursorPosPrevLine.x + spacing_w; - window->DC.CursorPos.y = window->DC.CursorPosPrevLine.y; - } - window->DC.CurrLineSize = window->DC.PrevLineSize; - window->DC.CurrLineTextBaseOffset = window->DC.PrevLineTextBaseOffset; -} - -ImVec2 ImGui::GetCursorScreenPos() -{ - ImGuiWindow* window = GetCurrentWindowRead(); - return window->DC.CursorPos; -} - -void ImGui::SetCursorScreenPos(const ImVec2& pos) -{ - ImGuiWindow* window = GetCurrentWindow(); - window->DC.CursorPos = pos; - window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos); -} - -// User generally sees positions in window coordinates. Internally we store CursorPos in absolute screen coordinates because it is more convenient. -// Conversion happens as we pass the value to user, but it makes our naming convention confusing because GetCursorPos() == (DC.CursorPos - window.Pos). May want to rename 'DC.CursorPos'. -ImVec2 ImGui::GetCursorPos() -{ - ImGuiWindow* window = GetCurrentWindowRead(); - return window->DC.CursorPos - window->Pos + window->Scroll; -} - -float ImGui::GetCursorPosX() -{ - ImGuiWindow* window = GetCurrentWindowRead(); - return window->DC.CursorPos.x - window->Pos.x + window->Scroll.x; -} - -float ImGui::GetCursorPosY() -{ - ImGuiWindow* window = GetCurrentWindowRead(); - return window->DC.CursorPos.y - window->Pos.y + window->Scroll.y; -} - -void ImGui::SetCursorPos(const ImVec2& local_pos) -{ - ImGuiWindow* window = GetCurrentWindow(); - window->DC.CursorPos = window->Pos - window->Scroll + local_pos; - window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos); -} - -void ImGui::SetCursorPosX(float x) -{ - ImGuiWindow* window = GetCurrentWindow(); - window->DC.CursorPos.x = window->Pos.x - window->Scroll.x + x; - window->DC.CursorMaxPos.x = ImMax(window->DC.CursorMaxPos.x, window->DC.CursorPos.x); -} - -void ImGui::SetCursorPosY(float y) -{ - ImGuiWindow* window = GetCurrentWindow(); - window->DC.CursorPos.y = window->Pos.y - window->Scroll.y + y; - window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, window->DC.CursorPos.y); -} - -ImVec2 ImGui::GetCursorStartPos() -{ - ImGuiWindow* window = GetCurrentWindowRead(); - return window->DC.CursorStartPos - window->Pos; -} - -void ImGui::Indent(float indent_w) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = GetCurrentWindow(); - window->DC.Indent.x += (indent_w != 0.0f) ? indent_w : g.Style.IndentSpacing; - window->DC.CursorPos.x = window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x; -} - -void ImGui::Unindent(float indent_w) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = GetCurrentWindow(); - window->DC.Indent.x -= (indent_w != 0.0f) ? indent_w : g.Style.IndentSpacing; - window->DC.CursorPos.x = window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x; -} - -// Affect large frame+labels widgets only. -void ImGui::SetNextItemWidth(float item_width) -{ - ImGuiContext& g = *GImGui; - g.NextItemData.Flags |= ImGuiNextItemDataFlags_HasWidth; - g.NextItemData.Width = item_width; -} - -// FIXME: Remove the == 0.0f behavior? -void ImGui::PushItemWidth(float item_width) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - window->DC.ItemWidthStack.push_back(window->DC.ItemWidth); // Backup current width - window->DC.ItemWidth = (item_width == 0.0f ? window->ItemWidthDefault : item_width); - g.NextItemData.Flags &= ~ImGuiNextItemDataFlags_HasWidth; -} - -void ImGui::PushMultiItemsWidths(int components, float w_full) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - const ImGuiStyle& style = g.Style; - const float w_item_one = ImMax(1.0f, IM_FLOOR((w_full - (style.ItemInnerSpacing.x) * (components - 1)) / (float)components)); - const float w_item_last = ImMax(1.0f, IM_FLOOR(w_full - (w_item_one + style.ItemInnerSpacing.x) * (components - 1))); - window->DC.ItemWidthStack.push_back(window->DC.ItemWidth); // Backup current width - window->DC.ItemWidthStack.push_back(w_item_last); - for (int i = 0; i < components - 2; i++) - window->DC.ItemWidthStack.push_back(w_item_one); - window->DC.ItemWidth = (components == 1) ? w_item_last : w_item_one; - g.NextItemData.Flags &= ~ImGuiNextItemDataFlags_HasWidth; -} - -void ImGui::PopItemWidth() -{ - ImGuiWindow* window = GetCurrentWindow(); - window->DC.ItemWidth = window->DC.ItemWidthStack.back(); - window->DC.ItemWidthStack.pop_back(); -} - -// Calculate default item width given value passed to PushItemWidth() or SetNextItemWidth(). -// The SetNextItemWidth() data is generally cleared/consumed by ItemAdd() or NextItemData.ClearFlags() -float ImGui::CalcItemWidth() -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - float w; - if (g.NextItemData.Flags & ImGuiNextItemDataFlags_HasWidth) - w = g.NextItemData.Width; - else - w = window->DC.ItemWidth; - if (w < 0.0f) - { - float region_max_x = GetContentRegionMaxAbs().x; - w = ImMax(1.0f, region_max_x - window->DC.CursorPos.x + w); - } - w = IM_FLOOR(w); - return w; -} - -// [Internal] Calculate full item size given user provided 'size' parameter and default width/height. Default width is often == CalcItemWidth(). -// Those two functions CalcItemWidth vs CalcItemSize are awkwardly named because they are not fully symmetrical. -// Note that only CalcItemWidth() is publicly exposed. -// The 4.0f here may be changed to match CalcItemWidth() and/or BeginChild() (right now we have a mismatch which is harmless but undesirable) -ImVec2 ImGui::CalcItemSize(ImVec2 size, float default_w, float default_h) -{ - ImGuiWindow* window = GImGui->CurrentWindow; - - ImVec2 region_max; - if (size.x < 0.0f || size.y < 0.0f) - region_max = GetContentRegionMaxAbs(); - - if (size.x == 0.0f) - size.x = default_w; - else if (size.x < 0.0f) - size.x = ImMax(4.0f, region_max.x - window->DC.CursorPos.x + size.x); - - if (size.y == 0.0f) - size.y = default_h; - else if (size.y < 0.0f) - size.y = ImMax(4.0f, region_max.y - window->DC.CursorPos.y + size.y); - - return size; -} - -float ImGui::GetTextLineHeight() -{ - ImGuiContext& g = *GImGui; - return g.FontSize; -} - -float ImGui::GetTextLineHeightWithSpacing() -{ - ImGuiContext& g = *GImGui; - return g.FontSize + g.Style.ItemSpacing.y; -} - -float ImGui::GetFrameHeight() -{ - ImGuiContext& g = *GImGui; - return g.FontSize + g.Style.FramePadding.y * 2.0f; -} - -float ImGui::GetFrameHeightWithSpacing() -{ - ImGuiContext& g = *GImGui; - return g.FontSize + g.Style.FramePadding.y * 2.0f + g.Style.ItemSpacing.y; -} - -// FIXME: All the Contents Region function are messy or misleading. WE WILL AIM TO OBSOLETE ALL OF THEM WITH A NEW "WORK RECT" API. Thanks for your patience! - -// FIXME: This is in window space (not screen space!). -ImVec2 ImGui::GetContentRegionMax() -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - ImVec2 mx = window->ContentRegionRect.Max - window->Pos; - if (window->DC.CurrentColumns || g.CurrentTable) - mx.x = window->WorkRect.Max.x - window->Pos.x; - return mx; -} - -// [Internal] Absolute coordinate. Saner. This is not exposed until we finishing refactoring work rect features. -ImVec2 ImGui::GetContentRegionMaxAbs() -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - ImVec2 mx = window->ContentRegionRect.Max; - if (window->DC.CurrentColumns || g.CurrentTable) - mx.x = window->WorkRect.Max.x; - return mx; -} - -ImVec2 ImGui::GetContentRegionAvail() -{ - ImGuiWindow* window = GImGui->CurrentWindow; - return GetContentRegionMaxAbs() - window->DC.CursorPos; -} - -// In window space (not screen space!) -ImVec2 ImGui::GetWindowContentRegionMin() -{ - ImGuiWindow* window = GImGui->CurrentWindow; - return window->ContentRegionRect.Min - window->Pos; -} - -ImVec2 ImGui::GetWindowContentRegionMax() -{ - ImGuiWindow* window = GImGui->CurrentWindow; - return window->ContentRegionRect.Max - window->Pos; -} - -// Lock horizontal starting position + capture group bounding box into one "item" (so you can use IsItemHovered() or layout primitives such as SameLine() on whole group, etc.) -// Groups are currently a mishmash of functionalities which should perhaps be clarified and separated. -// FIXME-OPT: Could we safely early out on ->SkipItems? -void ImGui::BeginGroup() -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - - g.GroupStack.resize(g.GroupStack.Size + 1); - ImGuiGroupData& group_data = g.GroupStack.back(); - group_data.WindowID = window->ID; - group_data.BackupCursorPos = window->DC.CursorPos; - group_data.BackupCursorMaxPos = window->DC.CursorMaxPos; - group_data.BackupIndent = window->DC.Indent; - group_data.BackupGroupOffset = window->DC.GroupOffset; - group_data.BackupCurrLineSize = window->DC.CurrLineSize; - group_data.BackupCurrLineTextBaseOffset = window->DC.CurrLineTextBaseOffset; - group_data.BackupActiveIdIsAlive = g.ActiveIdIsAlive; - group_data.BackupHoveredIdIsAlive = g.HoveredId != 0; - group_data.BackupActiveIdPreviousFrameIsAlive = g.ActiveIdPreviousFrameIsAlive; - group_data.EmitItem = true; - - window->DC.GroupOffset.x = window->DC.CursorPos.x - window->Pos.x - window->DC.ColumnsOffset.x; - window->DC.Indent = window->DC.GroupOffset; - window->DC.CursorMaxPos = window->DC.CursorPos; - window->DC.CurrLineSize = ImVec2(0.0f, 0.0f); - if (g.LogEnabled) - g.LogLinePosY = -FLT_MAX; // To enforce a carriage return -} - -void ImGui::EndGroup() -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - IM_ASSERT(g.GroupStack.Size > 0); // Mismatched BeginGroup()/EndGroup() calls - - ImGuiGroupData& group_data = g.GroupStack.back(); - IM_ASSERT(group_data.WindowID == window->ID); // EndGroup() in wrong window? - - ImRect group_bb(group_data.BackupCursorPos, ImMax(window->DC.CursorMaxPos, group_data.BackupCursorPos)); - - window->DC.CursorPos = group_data.BackupCursorPos; - window->DC.CursorMaxPos = ImMax(group_data.BackupCursorMaxPos, window->DC.CursorMaxPos); - window->DC.Indent = group_data.BackupIndent; - window->DC.GroupOffset = group_data.BackupGroupOffset; - window->DC.CurrLineSize = group_data.BackupCurrLineSize; - window->DC.CurrLineTextBaseOffset = group_data.BackupCurrLineTextBaseOffset; - if (g.LogEnabled) - g.LogLinePosY = -FLT_MAX; // To enforce a carriage return - - if (!group_data.EmitItem) - { - g.GroupStack.pop_back(); - return; - } - - window->DC.CurrLineTextBaseOffset = ImMax(window->DC.PrevLineTextBaseOffset, group_data.BackupCurrLineTextBaseOffset); // FIXME: Incorrect, we should grab the base offset from the *first line* of the group but it is hard to obtain now. - ItemSize(group_bb.GetSize()); - ItemAdd(group_bb, 0); - - // If the current ActiveId was declared within the boundary of our group, we copy it to LastItemId so IsItemActive(), IsItemDeactivated() etc. will be functional on the entire group. - // It would be be neater if we replaced window.DC.LastItemId by e.g. 'bool LastItemIsActive', but would put a little more burden on individual widgets. - // Also if you grep for LastItemId you'll notice it is only used in that context. - // (The two tests not the same because ActiveIdIsAlive is an ID itself, in order to be able to handle ActiveId being overwritten during the frame.) - const bool group_contains_curr_active_id = (group_data.BackupActiveIdIsAlive != g.ActiveId) && (g.ActiveIdIsAlive == g.ActiveId) && g.ActiveId; - const bool group_contains_prev_active_id = (group_data.BackupActiveIdPreviousFrameIsAlive == false) && (g.ActiveIdPreviousFrameIsAlive == true); - if (group_contains_curr_active_id) - g.LastItemData.ID = g.ActiveId; - else if (group_contains_prev_active_id) - g.LastItemData.ID = g.ActiveIdPreviousFrame; - g.LastItemData.Rect = group_bb; - - // Forward Hovered flag - const bool group_contains_curr_hovered_id = (group_data.BackupHoveredIdIsAlive == false) && g.HoveredId != 0; - if (group_contains_curr_hovered_id) - g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HoveredWindow; - - // Forward Edited flag - if (group_contains_curr_active_id && g.ActiveIdHasBeenEditedThisFrame) - g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_Edited; - - // Forward Deactivated flag - g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HasDeactivated; - if (group_contains_prev_active_id && g.ActiveId != g.ActiveIdPreviousFrame) - g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_Deactivated; - - g.GroupStack.pop_back(); - //window->DrawList->AddRect(group_bb.Min, group_bb.Max, IM_COL32(255,0,255,255)); // [Debug] -} - - -//----------------------------------------------------------------------------- -// [SECTION] SCROLLING -//----------------------------------------------------------------------------- - -// Helper to snap on edges when aiming at an item very close to the edge, -// So the difference between WindowPadding and ItemSpacing will be in the visible area after scrolling. -// When we refactor the scrolling API this may be configurable with a flag? -// Note that the effect for this won't be visible on X axis with default Style settings as WindowPadding.x == ItemSpacing.x by default. -static float CalcScrollEdgeSnap(float target, float snap_min, float snap_max, float snap_threshold, float center_ratio) -{ - if (target <= snap_min + snap_threshold) - return ImLerp(snap_min, target, center_ratio); - if (target >= snap_max - snap_threshold) - return ImLerp(target, snap_max, center_ratio); - return target; -} - -static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window) -{ - ImVec2 scroll = window->Scroll; - if (window->ScrollTarget.x < FLT_MAX) - { - float decoration_total_width = window->ScrollbarSizes.x; - float center_x_ratio = window->ScrollTargetCenterRatio.x; - float scroll_target_x = window->ScrollTarget.x; - if (window->ScrollTargetEdgeSnapDist.x > 0.0f) - { - float snap_x_min = 0.0f; - float snap_x_max = window->ScrollMax.x + window->SizeFull.x - decoration_total_width; - scroll_target_x = CalcScrollEdgeSnap(scroll_target_x, snap_x_min, snap_x_max, window->ScrollTargetEdgeSnapDist.x, center_x_ratio); - } - scroll.x = scroll_target_x - center_x_ratio * (window->SizeFull.x - decoration_total_width); - } - if (window->ScrollTarget.y < FLT_MAX) - { - float decoration_total_height = window->TitleBarHeight() + window->MenuBarHeight() + window->ScrollbarSizes.y; - float center_y_ratio = window->ScrollTargetCenterRatio.y; - float scroll_target_y = window->ScrollTarget.y; - if (window->ScrollTargetEdgeSnapDist.y > 0.0f) - { - float snap_y_min = 0.0f; - float snap_y_max = window->ScrollMax.y + window->SizeFull.y - decoration_total_height; - scroll_target_y = CalcScrollEdgeSnap(scroll_target_y, snap_y_min, snap_y_max, window->ScrollTargetEdgeSnapDist.y, center_y_ratio); - } - scroll.y = scroll_target_y - center_y_ratio * (window->SizeFull.y - decoration_total_height); - } - scroll.x = IM_FLOOR(ImMax(scroll.x, 0.0f)); - scroll.y = IM_FLOOR(ImMax(scroll.y, 0.0f)); - if (!window->Collapsed && !window->SkipItems) - { - scroll.x = ImMin(scroll.x, window->ScrollMax.x); - scroll.y = ImMin(scroll.y, window->ScrollMax.y); - } - return scroll; -} - -void ImGui::ScrollToItem(ImGuiScrollFlags flags) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - ScrollToRectEx(window, g.LastItemData.NavRect, flags); -} - -void ImGui::ScrollToRect(ImGuiWindow* window, const ImRect& item_rect, ImGuiScrollFlags flags) -{ - ScrollToRectEx(window, item_rect, flags); -} - -// Scroll to keep newly navigated item fully into view -ImVec2 ImGui::ScrollToRectEx(ImGuiWindow* window, const ImRect& item_rect, ImGuiScrollFlags flags) -{ - ImGuiContext& g = *GImGui; - ImRect window_rect(window->InnerRect.Min - ImVec2(1, 1), window->InnerRect.Max + ImVec2(1, 1)); - //GetForegroundDrawList(window)->AddRect(window_rect.Min, window_rect.Max, IM_COL32_WHITE); // [DEBUG] - - // Check that only one behavior is selected per axis - IM_ASSERT((flags & ImGuiScrollFlags_MaskX_) == 0 || ImIsPowerOfTwo(flags & ImGuiScrollFlags_MaskX_)); - IM_ASSERT((flags & ImGuiScrollFlags_MaskY_) == 0 || ImIsPowerOfTwo(flags & ImGuiScrollFlags_MaskY_)); - - // Defaults - ImGuiScrollFlags in_flags = flags; - if ((flags & ImGuiScrollFlags_MaskX_) == 0 && window->ScrollbarX) - flags |= ImGuiScrollFlags_KeepVisibleEdgeX; - if ((flags & ImGuiScrollFlags_MaskY_) == 0) - flags |= window->Appearing ? ImGuiScrollFlags_AlwaysCenterY : ImGuiScrollFlags_KeepVisibleEdgeY; - - const bool fully_visible_x = item_rect.Min.x >= window_rect.Min.x && item_rect.Max.x <= window_rect.Max.x; - const bool fully_visible_y = item_rect.Min.y >= window_rect.Min.y && item_rect.Max.y <= window_rect.Max.y; - const bool can_be_fully_visible_x = item_rect.GetWidth() <= window_rect.GetWidth(); - const bool can_be_fully_visible_y = item_rect.GetHeight() <= window_rect.GetHeight(); - - if ((flags & ImGuiScrollFlags_KeepVisibleEdgeX) && !fully_visible_x) - { - if (item_rect.Min.x < window_rect.Min.x || !can_be_fully_visible_x) - SetScrollFromPosX(window, item_rect.Min.x - g.Style.ItemSpacing.x - window->Pos.x, 0.0f); - else if (item_rect.Max.x >= window_rect.Max.x) - SetScrollFromPosX(window, item_rect.Max.x + g.Style.ItemSpacing.x - window->Pos.x, 1.0f); - } - else if (((flags & ImGuiScrollFlags_KeepVisibleCenterX) && !fully_visible_x) || (flags & ImGuiScrollFlags_AlwaysCenterX)) - { - float target_x = can_be_fully_visible_x ? ImFloor((item_rect.Min.x + item_rect.Max.x - window->InnerRect.GetWidth()) * 0.5f) : item_rect.Min.x; - SetScrollFromPosX(window, target_x - window->Pos.x, 0.0f); - } - - if ((flags & ImGuiScrollFlags_KeepVisibleEdgeY) && !fully_visible_y) - { - if (item_rect.Min.y < window_rect.Min.y || !can_be_fully_visible_y) - SetScrollFromPosY(window, item_rect.Min.y - g.Style.ItemSpacing.y - window->Pos.y, 0.0f); - else if (item_rect.Max.y >= window_rect.Max.y) - SetScrollFromPosY(window, item_rect.Max.y + g.Style.ItemSpacing.y - window->Pos.y, 1.0f); - } - else if (((flags & ImGuiScrollFlags_KeepVisibleCenterY) && !fully_visible_y) || (flags & ImGuiScrollFlags_AlwaysCenterY)) - { - float target_y = can_be_fully_visible_y ? ImFloor((item_rect.Min.y + item_rect.Max.y - window->InnerRect.GetHeight()) * 0.5f) : item_rect.Min.y; - SetScrollFromPosY(window, target_y - window->Pos.y, 0.0f); - } - - ImVec2 next_scroll = CalcNextScrollFromScrollTargetAndClamp(window); - ImVec2 delta_scroll = next_scroll - window->Scroll; - - // Also scroll parent window to keep us into view if necessary - if (!(flags & ImGuiScrollFlags_NoScrollParent) && (window->Flags & ImGuiWindowFlags_ChildWindow)) - { - // FIXME-SCROLL: May be an option? - if ((in_flags & (ImGuiScrollFlags_AlwaysCenterX | ImGuiScrollFlags_KeepVisibleCenterX)) != 0) - in_flags = (in_flags & ~ImGuiScrollFlags_MaskX_) | ImGuiScrollFlags_KeepVisibleEdgeX; - if ((in_flags & (ImGuiScrollFlags_AlwaysCenterY | ImGuiScrollFlags_KeepVisibleCenterY)) != 0) - in_flags = (in_flags & ~ImGuiScrollFlags_MaskY_) | ImGuiScrollFlags_KeepVisibleEdgeY; - delta_scroll += ScrollToRectEx(window->ParentWindow, ImRect(item_rect.Min - delta_scroll, item_rect.Max - delta_scroll), in_flags); - } - - return delta_scroll; -} - -float ImGui::GetScrollX() -{ - ImGuiWindow* window = GImGui->CurrentWindow; - return window->Scroll.x; -} - -float ImGui::GetScrollY() -{ - ImGuiWindow* window = GImGui->CurrentWindow; - return window->Scroll.y; -} - -float ImGui::GetScrollMaxX() -{ - ImGuiWindow* window = GImGui->CurrentWindow; - return window->ScrollMax.x; -} - -float ImGui::GetScrollMaxY() -{ - ImGuiWindow* window = GImGui->CurrentWindow; - return window->ScrollMax.y; -} - -void ImGui::SetScrollX(ImGuiWindow* window, float scroll_x) -{ - window->ScrollTarget.x = scroll_x; - window->ScrollTargetCenterRatio.x = 0.0f; - window->ScrollTargetEdgeSnapDist.x = 0.0f; -} - -void ImGui::SetScrollY(ImGuiWindow* window, float scroll_y) -{ - window->ScrollTarget.y = scroll_y; - window->ScrollTargetCenterRatio.y = 0.0f; - window->ScrollTargetEdgeSnapDist.y = 0.0f; -} - -void ImGui::SetScrollX(float scroll_x) -{ - ImGuiContext& g = *GImGui; - SetScrollX(g.CurrentWindow, scroll_x); -} - -void ImGui::SetScrollY(float scroll_y) -{ - ImGuiContext& g = *GImGui; - SetScrollY(g.CurrentWindow, scroll_y); -} - -// Note that a local position will vary depending on initial scroll value, -// This is a little bit confusing so bear with us: -// - local_pos = (absolution_pos - window->Pos) -// - So local_x/local_y are 0.0f for a position at the upper-left corner of a window, -// and generally local_x/local_y are >(padding+decoration) && <(size-padding-decoration) when in the visible area. -// - They mostly exists because of legacy API. -// Following the rules above, when trying to work with scrolling code, consider that: -// - SetScrollFromPosY(0.0f) == SetScrollY(0.0f + scroll.y) == has no effect! -// - SetScrollFromPosY(-scroll.y) == SetScrollY(-scroll.y + scroll.y) == SetScrollY(0.0f) == reset scroll. Of course writing SetScrollY(0.0f) directly then makes more sense -// We store a target position so centering and clamping can occur on the next frame when we are guaranteed to have a known window size -void ImGui::SetScrollFromPosX(ImGuiWindow* window, float local_x, float center_x_ratio) -{ - IM_ASSERT(center_x_ratio >= 0.0f && center_x_ratio <= 1.0f); - window->ScrollTarget.x = IM_FLOOR(local_x + window->Scroll.x); // Convert local position to scroll offset - window->ScrollTargetCenterRatio.x = center_x_ratio; - window->ScrollTargetEdgeSnapDist.x = 0.0f; -} - -void ImGui::SetScrollFromPosY(ImGuiWindow* window, float local_y, float center_y_ratio) -{ - IM_ASSERT(center_y_ratio >= 0.0f && center_y_ratio <= 1.0f); - const float decoration_up_height = window->TitleBarHeight() + window->MenuBarHeight(); // FIXME: Would be nice to have a more standardized access to our scrollable/client rect; - local_y -= decoration_up_height; - window->ScrollTarget.y = IM_FLOOR(local_y + window->Scroll.y); // Convert local position to scroll offset - window->ScrollTargetCenterRatio.y = center_y_ratio; - window->ScrollTargetEdgeSnapDist.y = 0.0f; -} - -void ImGui::SetScrollFromPosX(float local_x, float center_x_ratio) -{ - ImGuiContext& g = *GImGui; - SetScrollFromPosX(g.CurrentWindow, local_x, center_x_ratio); -} - -void ImGui::SetScrollFromPosY(float local_y, float center_y_ratio) -{ - ImGuiContext& g = *GImGui; - SetScrollFromPosY(g.CurrentWindow, local_y, center_y_ratio); -} - -// center_x_ratio: 0.0f left of last item, 0.5f horizontal center of last item, 1.0f right of last item. -void ImGui::SetScrollHereX(float center_x_ratio) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - float spacing_x = ImMax(window->WindowPadding.x, g.Style.ItemSpacing.x); - float target_pos_x = ImLerp(g.LastItemData.Rect.Min.x - spacing_x, g.LastItemData.Rect.Max.x + spacing_x, center_x_ratio); - SetScrollFromPosX(window, target_pos_x - window->Pos.x, center_x_ratio); // Convert from absolute to local pos - - // Tweak: snap on edges when aiming at an item very close to the edge - window->ScrollTargetEdgeSnapDist.x = ImMax(0.0f, window->WindowPadding.x - spacing_x); -} - -// center_y_ratio: 0.0f top of last item, 0.5f vertical center of last item, 1.0f bottom of last item. -void ImGui::SetScrollHereY(float center_y_ratio) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - float spacing_y = ImMax(window->WindowPadding.y, g.Style.ItemSpacing.y); - float target_pos_y = ImLerp(window->DC.CursorPosPrevLine.y - spacing_y, window->DC.CursorPosPrevLine.y + window->DC.PrevLineSize.y + spacing_y, center_y_ratio); - SetScrollFromPosY(window, target_pos_y - window->Pos.y, center_y_ratio); // Convert from absolute to local pos - - // Tweak: snap on edges when aiming at an item very close to the edge - window->ScrollTargetEdgeSnapDist.y = ImMax(0.0f, window->WindowPadding.y - spacing_y); -} - -//----------------------------------------------------------------------------- -// [SECTION] TOOLTIPS -//----------------------------------------------------------------------------- - -void ImGui::BeginTooltip() -{ - BeginTooltipEx(ImGuiWindowFlags_None, ImGuiTooltipFlags_None); -} - -void ImGui::BeginTooltipEx(ImGuiWindowFlags extra_flags, ImGuiTooltipFlags tooltip_flags) -{ - ImGuiContext& g = *GImGui; - - if (g.DragDropWithinSource || g.DragDropWithinTarget) - { - // The default tooltip position is a little offset to give space to see the context menu (it's also clamped within the current viewport/monitor) - // In the context of a dragging tooltip we try to reduce that offset and we enforce following the cursor. - // Whatever we do we want to call SetNextWindowPos() to enforce a tooltip position and disable clipping the tooltip without our display area, like regular tooltip do. - //ImVec2 tooltip_pos = g.IO.MousePos - g.ActiveIdClickOffset - g.Style.WindowPadding; - ImVec2 tooltip_pos = g.IO.MousePos + ImVec2(16 * g.Style.MouseCursorScale, 8 * g.Style.MouseCursorScale); - SetNextWindowPos(tooltip_pos); - SetNextWindowBgAlpha(g.Style.Colors[ImGuiCol_PopupBg].w * 0.60f); - //PushStyleVar(ImGuiStyleVar_Alpha, g.Style.Alpha * 0.60f); // This would be nice but e.g ColorButton with checkboard has issue with transparent colors :( - tooltip_flags |= ImGuiTooltipFlags_OverridePreviousTooltip; - } - - char window_name[16]; - ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip_%02d", g.TooltipOverrideCount); - if (tooltip_flags & ImGuiTooltipFlags_OverridePreviousTooltip) - if (ImGuiWindow* window = FindWindowByName(window_name)) - if (window->Active) - { - // Hide previous tooltip from being displayed. We can't easily "reset" the content of a window so we create a new one. - window->Hidden = true; - window->HiddenFramesCanSkipItems = 1; // FIXME: This may not be necessary? - ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip_%02d", ++g.TooltipOverrideCount); - } - ImGuiWindowFlags flags = ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_AlwaysAutoResize; - Begin(window_name, NULL, flags | extra_flags); -} - -void ImGui::EndTooltip() -{ - IM_ASSERT(GetCurrentWindowRead()->Flags & ImGuiWindowFlags_Tooltip); // Mismatched BeginTooltip()/EndTooltip() calls - End(); -} - -void ImGui::SetTooltipV(const char* fmt, va_list args) -{ - BeginTooltipEx(0, ImGuiTooltipFlags_OverridePreviousTooltip); - TextV(fmt, args); - EndTooltip(); -} - -void ImGui::SetTooltip(const char* fmt, ...) -{ - va_list args; - va_start(args, fmt); - SetTooltipV(fmt, args); - va_end(args); -} - -//----------------------------------------------------------------------------- -// [SECTION] POPUPS -//----------------------------------------------------------------------------- - -// Supported flags: ImGuiPopupFlags_AnyPopupId, ImGuiPopupFlags_AnyPopupLevel -bool ImGui::IsPopupOpen(ImGuiID id, ImGuiPopupFlags popup_flags) -{ - ImGuiContext& g = *GImGui; - if (popup_flags & ImGuiPopupFlags_AnyPopupId) - { - // Return true if any popup is open at the current BeginPopup() level of the popup stack - // This may be used to e.g. test for another popups already opened to handle popups priorities at the same level. - IM_ASSERT(id == 0); - if (popup_flags & ImGuiPopupFlags_AnyPopupLevel) - return g.OpenPopupStack.Size > 0; - else - return g.OpenPopupStack.Size > g.BeginPopupStack.Size; - } - else - { - if (popup_flags & ImGuiPopupFlags_AnyPopupLevel) - { - // Return true if the popup is open anywhere in the popup stack - for (int n = 0; n < g.OpenPopupStack.Size; n++) - if (g.OpenPopupStack[n].PopupId == id) - return true; - return false; - } - else - { - // Return true if the popup is open at the current BeginPopup() level of the popup stack (this is the most-common query) - return g.OpenPopupStack.Size > g.BeginPopupStack.Size && g.OpenPopupStack[g.BeginPopupStack.Size].PopupId == id; - } - } -} - -bool ImGui::IsPopupOpen(const char* str_id, ImGuiPopupFlags popup_flags) -{ - ImGuiContext& g = *GImGui; - ImGuiID id = (popup_flags & ImGuiPopupFlags_AnyPopupId) ? 0 : g.CurrentWindow->GetID(str_id); - if ((popup_flags & ImGuiPopupFlags_AnyPopupLevel) && id != 0) - IM_ASSERT(0 && "Cannot use IsPopupOpen() with a string id and ImGuiPopupFlags_AnyPopupLevel."); // But non-string version is legal and used internally - return IsPopupOpen(id, popup_flags); -} - -ImGuiWindow* ImGui::GetTopMostPopupModal() -{ - ImGuiContext& g = *GImGui; - for (int n = g.OpenPopupStack.Size - 1; n >= 0; n--) - if (ImGuiWindow* popup = g.OpenPopupStack.Data[n].Window) - if (popup->Flags & ImGuiWindowFlags_Modal) - return popup; - return NULL; -} - -void ImGui::OpenPopup(const char* str_id, ImGuiPopupFlags popup_flags) -{ - ImGuiContext& g = *GImGui; - OpenPopupEx(g.CurrentWindow->GetID(str_id), popup_flags); -} - -void ImGui::OpenPopup(ImGuiID id, ImGuiPopupFlags popup_flags) -{ - OpenPopupEx(id, popup_flags); -} - -// Mark popup as open (toggle toward open state). -// Popups are closed when user click outside, or activate a pressable item, or CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block. -// Popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level). -// One open popup per level of the popup hierarchy (NB: when assigning we reset the Window member of ImGuiPopupRef to NULL) -void ImGui::OpenPopupEx(ImGuiID id, ImGuiPopupFlags popup_flags) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* parent_window = g.CurrentWindow; - const int current_stack_size = g.BeginPopupStack.Size; - - if (popup_flags & ImGuiPopupFlags_NoOpenOverExistingPopup) - if (IsPopupOpen(0u, ImGuiPopupFlags_AnyPopupId)) - return; - - ImGuiPopupData popup_ref; // Tagged as new ref as Window will be set back to NULL if we write this into OpenPopupStack. - popup_ref.PopupId = id; - popup_ref.Window = NULL; - popup_ref.SourceWindow = g.NavWindow; - popup_ref.OpenFrameCount = g.FrameCount; - popup_ref.OpenParentId = parent_window->IDStack.back(); - popup_ref.OpenPopupPos = NavCalcPreferredRefPos(); - popup_ref.OpenMousePos = IsMousePosValid(&g.IO.MousePos) ? g.IO.MousePos : popup_ref.OpenPopupPos; - - IMGUI_DEBUG_LOG_POPUP("OpenPopupEx(0x%08X)\n", id); - if (g.OpenPopupStack.Size < current_stack_size + 1) - { - g.OpenPopupStack.push_back(popup_ref); - } - else - { - // Gently handle the user mistakenly calling OpenPopup() every frame. It is a programming mistake! However, if we were to run the regular code path, the ui - // would become completely unusable because the popup will always be in hidden-while-calculating-size state _while_ claiming focus. Which would be a very confusing - // situation for the programmer. Instead, we silently allow the popup to proceed, it will keep reappearing and the programming error will be more obvious to understand. - if (g.OpenPopupStack[current_stack_size].PopupId == id && g.OpenPopupStack[current_stack_size].OpenFrameCount == g.FrameCount - 1) - { - g.OpenPopupStack[current_stack_size].OpenFrameCount = popup_ref.OpenFrameCount; - } - else - { - // Close child popups if any, then flag popup for open/reopen - ClosePopupToLevel(current_stack_size, false); - g.OpenPopupStack.push_back(popup_ref); - } - - // When reopening a popup we first refocus its parent, otherwise if its parent is itself a popup it would get closed by ClosePopupsOverWindow(). - // This is equivalent to what ClosePopupToLevel() does. - //if (g.OpenPopupStack[current_stack_size].PopupId == id) - // FocusWindow(parent_window); - } -} - -// When popups are stacked, clicking on a lower level popups puts focus back to it and close popups above it. -// This function closes any popups that are over 'ref_window'. -void ImGui::ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to_window_under_popup) -{ - ImGuiContext& g = *GImGui; - if (g.OpenPopupStack.Size == 0) - return; - - // Don't close our own child popup windows. - int popup_count_to_keep = 0; - if (ref_window) - { - // Find the highest popup which is a descendant of the reference window (generally reference window = NavWindow) - for (; popup_count_to_keep < g.OpenPopupStack.Size; popup_count_to_keep++) - { - ImGuiPopupData& popup = g.OpenPopupStack[popup_count_to_keep]; - if (!popup.Window) - continue; - IM_ASSERT((popup.Window->Flags & ImGuiWindowFlags_Popup) != 0); - if (popup.Window->Flags & ImGuiWindowFlags_ChildWindow) - continue; - - // Trim the stack unless the popup is a direct parent of the reference window (the reference window is often the NavWindow) - // - With this stack of window, clicking/focusing Popup1 will close Popup2 and Popup3: - // Window -> Popup1 -> Popup2 -> Popup3 - // - Each popups may contain child windows, which is why we compare ->RootWindow! - // Window -> Popup1 -> Popup1_Child -> Popup2 -> Popup2_Child - bool ref_window_is_descendent_of_popup = false; - for (int n = popup_count_to_keep; n < g.OpenPopupStack.Size; n++) - if (ImGuiWindow* popup_window = g.OpenPopupStack[n].Window) - if (popup_window->RootWindow == ref_window->RootWindow) - { - ref_window_is_descendent_of_popup = true; - break; - } - if (!ref_window_is_descendent_of_popup) - break; - } - } - if (popup_count_to_keep < g.OpenPopupStack.Size) // This test is not required but it allows to set a convenient breakpoint on the statement below - { - IMGUI_DEBUG_LOG_POPUP("ClosePopupsOverWindow(\"%s\") -> ClosePopupToLevel(%d)\n", ref_window->Name, popup_count_to_keep); - ClosePopupToLevel(popup_count_to_keep, restore_focus_to_window_under_popup); - } -} - -void ImGui::ClosePopupsExceptModals() -{ - ImGuiContext& g = *GImGui; - - int popup_count_to_keep; - for (popup_count_to_keep = g.OpenPopupStack.Size; popup_count_to_keep > 0; popup_count_to_keep--) - { - ImGuiWindow* window = g.OpenPopupStack[popup_count_to_keep - 1].Window; - if (!window || window->Flags & ImGuiWindowFlags_Modal) - break; - } - if (popup_count_to_keep < g.OpenPopupStack.Size) // This test is not required but it allows to set a convenient breakpoint on the statement below - ClosePopupToLevel(popup_count_to_keep, true); -} - -void ImGui::ClosePopupToLevel(int remaining, bool restore_focus_to_window_under_popup) -{ - ImGuiContext& g = *GImGui; - IMGUI_DEBUG_LOG_POPUP("ClosePopupToLevel(%d), restore_focus_to_window_under_popup=%d\n", remaining, restore_focus_to_window_under_popup); - IM_ASSERT(remaining >= 0 && remaining < g.OpenPopupStack.Size); - - // Trim open popup stack - ImGuiWindow* focus_window = g.OpenPopupStack[remaining].SourceWindow; - ImGuiWindow* popup_window = g.OpenPopupStack[remaining].Window; - g.OpenPopupStack.resize(remaining); - - if (restore_focus_to_window_under_popup) - { - if (focus_window && !focus_window->WasActive && popup_window) - { - // Fallback - FocusTopMostWindowUnderOne(popup_window, NULL); - } - else - { - if (g.NavLayer == ImGuiNavLayer_Main && focus_window) - focus_window = NavRestoreLastChildNavWindow(focus_window); - FocusWindow(focus_window); - } - } -} - -// Close the popup we have begin-ed into. -void ImGui::CloseCurrentPopup() -{ - ImGuiContext& g = *GImGui; - int popup_idx = g.BeginPopupStack.Size - 1; - if (popup_idx < 0 || popup_idx >= g.OpenPopupStack.Size || g.BeginPopupStack[popup_idx].PopupId != g.OpenPopupStack[popup_idx].PopupId) - return; - - // Closing a menu closes its top-most parent popup (unless a modal) - while (popup_idx > 0) - { - ImGuiWindow* popup_window = g.OpenPopupStack[popup_idx].Window; - ImGuiWindow* parent_popup_window = g.OpenPopupStack[popup_idx - 1].Window; - bool close_parent = false; - if (popup_window && (popup_window->Flags & ImGuiWindowFlags_ChildMenu)) - if (parent_popup_window == NULL || !(parent_popup_window->Flags & ImGuiWindowFlags_Modal)) - close_parent = true; - if (!close_parent) - break; - popup_idx--; - } - IMGUI_DEBUG_LOG_POPUP("CloseCurrentPopup %d -> %d\n", g.BeginPopupStack.Size - 1, popup_idx); - ClosePopupToLevel(popup_idx, true); - - // A common pattern is to close a popup when selecting a menu item/selectable that will open another window. - // To improve this usage pattern, we avoid nav highlight for a single frame in the parent window. - // Similarly, we could avoid mouse hover highlight in this window but it is less visually problematic. - if (ImGuiWindow* window = g.NavWindow) - window->DC.NavHideHighlightOneFrame = true; -} - -// Attention! BeginPopup() adds default flags which BeginPopupEx()! -bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags flags) -{ - ImGuiContext& g = *GImGui; - if (!IsPopupOpen(id, ImGuiPopupFlags_None)) - { - g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values - return false; - } - - char name[20]; - if (flags & ImGuiWindowFlags_ChildMenu) - ImFormatString(name, IM_ARRAYSIZE(name), "##Menu_%02d", g.BeginPopupStack.Size); // Recycle windows based on depth - else - ImFormatString(name, IM_ARRAYSIZE(name), "##Popup_%08x", id); // Not recycling, so we can close/open during the same frame - - flags |= ImGuiWindowFlags_Popup; - bool is_open = Begin(name, NULL, flags); - if (!is_open) // NB: Begin can return false when the popup is completely clipped (e.g. zero size display) - EndPopup(); - - return is_open; -} - -bool ImGui::BeginPopup(const char* str_id, ImGuiWindowFlags flags) -{ - ImGuiContext& g = *GImGui; - if (g.OpenPopupStack.Size <= g.BeginPopupStack.Size) // Early out for performance - { - g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values - return false; - } - flags |= ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings; - return BeginPopupEx(g.CurrentWindow->GetID(str_id), flags); -} - -// If 'p_open' is specified for a modal popup window, the popup will have a regular close button which will close the popup. -// Note that popup visibility status is owned by Dear ImGui (and manipulated with e.g. OpenPopup) so the actual value of *p_open is meaningless here. -bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags flags) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - const ImGuiID id = window->GetID(name); - if (!IsPopupOpen(id, ImGuiPopupFlags_None)) - { - g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values - return false; - } - - // Center modal windows by default for increased visibility - // (this won't really last as settings will kick in, and is mostly for backward compatibility. user may do the same themselves) - // FIXME: Should test for (PosCond & window->SetWindowPosAllowFlags) with the upcoming window. - if ((g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasPos) == 0) - { - const ImGuiViewport* viewport = GetMainViewport(); - SetNextWindowPos(viewport->GetCenter(), ImGuiCond_FirstUseEver, ImVec2(0.5f, 0.5f)); - } - - flags |= ImGuiWindowFlags_Popup | ImGuiWindowFlags_Modal | ImGuiWindowFlags_NoCollapse; - const bool is_open = Begin(name, p_open, flags); - if (!is_open || (p_open && !*p_open)) // NB: is_open can be 'false' when the popup is completely clipped (e.g. zero size display) - { - EndPopup(); - if (is_open) - ClosePopupToLevel(g.BeginPopupStack.Size, true); - return false; - } - return is_open; -} - -void ImGui::EndPopup() -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - IM_ASSERT(window->Flags & ImGuiWindowFlags_Popup); // Mismatched BeginPopup()/EndPopup() calls - IM_ASSERT(g.BeginPopupStack.Size > 0); - - // Make all menus and popups wrap around for now, may need to expose that policy (e.g. focus scope could include wrap/loop policy flags used by new move requests) - if (g.NavWindow == window) - NavMoveRequestTryWrapping(window, ImGuiNavMoveFlags_LoopY); - - // Child-popups don't need to be laid out - IM_ASSERT(g.WithinEndChild == false); - if (window->Flags & ImGuiWindowFlags_ChildWindow) - g.WithinEndChild = true; - End(); - g.WithinEndChild = false; -} - -// Helper to open a popup if mouse button is released over the item -// - This is essentially the same as BeginPopupContextItem() but without the trailing BeginPopup() -void ImGui::OpenPopupOnItemClick(const char* str_id, ImGuiPopupFlags popup_flags) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - int mouse_button = (popup_flags & ImGuiPopupFlags_MouseButtonMask_); - if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup)) - { - ImGuiID id = str_id ? window->GetID(str_id) : g.LastItemData.ID; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict! - IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item) - OpenPopupEx(id, popup_flags); - } -} - -// This is a helper to handle the simplest case of associating one named popup to one given widget. -// - To create a popup associated to the last item, you generally want to pass a NULL value to str_id. -// - To create a popup with a specific identifier, pass it in str_id. -// - This is useful when using using BeginPopupContextItem() on an item which doesn't have an identifier, e.g. a Text() call. -// - This is useful when multiple code locations may want to manipulate/open the same popup, given an explicit id. -// - You may want to handle the whole on user side if you have specific needs (e.g. tweaking IsItemHovered() parameters). -// This is essentially the same as: -// id = str_id ? GetID(str_id) : GetItemID(); -// OpenPopupOnItemClick(str_id); -// return BeginPopup(id); -// Which is essentially the same as: -// id = str_id ? GetID(str_id) : GetItemID(); -// if (IsItemHovered() && IsMouseReleased(ImGuiMouseButton_Right)) -// OpenPopup(id); -// return BeginPopup(id); -// The main difference being that this is tweaked to avoid computing the ID twice. -bool ImGui::BeginPopupContextItem(const char* str_id, ImGuiPopupFlags popup_flags) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - if (window->SkipItems) - return false; - ImGuiID id = str_id ? window->GetID(str_id) : g.LastItemData.ID; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict! - IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item) - int mouse_button = (popup_flags & ImGuiPopupFlags_MouseButtonMask_); - if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup)) - OpenPopupEx(id, popup_flags); - return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings); -} - -bool ImGui::BeginPopupContextWindow(const char* str_id, ImGuiPopupFlags popup_flags) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - if (!str_id) - str_id = "window_context"; - ImGuiID id = window->GetID(str_id); - int mouse_button = (popup_flags & ImGuiPopupFlags_MouseButtonMask_); - if (IsMouseReleased(mouse_button) && IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup)) - if (!(popup_flags & ImGuiPopupFlags_NoOpenOverItems) || !IsAnyItemHovered()) - OpenPopupEx(id, popup_flags); - return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings); -} - -bool ImGui::BeginPopupContextVoid(const char* str_id, ImGuiPopupFlags popup_flags) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - if (!str_id) - str_id = "void_context"; - ImGuiID id = window->GetID(str_id); - int mouse_button = (popup_flags & ImGuiPopupFlags_MouseButtonMask_); - if (IsMouseReleased(mouse_button) && !IsWindowHovered(ImGuiHoveredFlags_AnyWindow)) - if (GetTopMostPopupModal() == NULL) - OpenPopupEx(id, popup_flags); - return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings); -} - -// r_avoid = the rectangle to avoid (e.g. for tooltip it is a rectangle around the mouse cursor which we want to avoid. for popups it's a small point around the cursor.) -// r_outer = the visible area rectangle, minus safe area padding. If our popup size won't fit because of safe area padding we ignore it. -// (r_outer is usually equivalent to the viewport rectangle minus padding, but when multi-viewports are enabled and monitor -// information are available, it may represent the entire platform monitor from the frame of reference of the current viewport. -// this allows us to have tooltips/popups displayed out of the parent viewport.) -ImVec2 ImGui::FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy) -{ - ImVec2 base_pos_clamped = ImClamp(ref_pos, r_outer.Min, r_outer.Max - size); - //GetForegroundDrawList()->AddRect(r_avoid.Min, r_avoid.Max, IM_COL32(255,0,0,255)); - //GetForegroundDrawList()->AddRect(r_outer.Min, r_outer.Max, IM_COL32(0,255,0,255)); - - // Combo Box policy (we want a connecting edge) - if (policy == ImGuiPopupPositionPolicy_ComboBox) - { - const ImGuiDir dir_prefered_order[ImGuiDir_COUNT] = { ImGuiDir_Down, ImGuiDir_Right, ImGuiDir_Left, ImGuiDir_Up }; - for (int n = (*last_dir != ImGuiDir_None) ? -1 : 0; n < ImGuiDir_COUNT; n++) - { - const ImGuiDir dir = (n == -1) ? *last_dir : dir_prefered_order[n]; - if (n != -1 && dir == *last_dir) // Already tried this direction? - continue; - ImVec2 pos; - if (dir == ImGuiDir_Down) pos = ImVec2(r_avoid.Min.x, r_avoid.Max.y); // Below, Toward Right (default) - if (dir == ImGuiDir_Right) pos = ImVec2(r_avoid.Min.x, r_avoid.Min.y - size.y); // Above, Toward Right - if (dir == ImGuiDir_Left) pos = ImVec2(r_avoid.Max.x - size.x, r_avoid.Max.y); // Below, Toward Left - if (dir == ImGuiDir_Up) pos = ImVec2(r_avoid.Max.x - size.x, r_avoid.Min.y - size.y); // Above, Toward Left - if (!r_outer.Contains(ImRect(pos, pos + size))) - continue; - *last_dir = dir; - return pos; - } - } - - // Tooltip and Default popup policy - // (Always first try the direction we used on the last frame, if any) - if (policy == ImGuiPopupPositionPolicy_Tooltip || policy == ImGuiPopupPositionPolicy_Default) - { - const ImGuiDir dir_prefered_order[ImGuiDir_COUNT] = { ImGuiDir_Right, ImGuiDir_Down, ImGuiDir_Up, ImGuiDir_Left }; - for (int n = (*last_dir != ImGuiDir_None) ? -1 : 0; n < ImGuiDir_COUNT; n++) - { - const ImGuiDir dir = (n == -1) ? *last_dir : dir_prefered_order[n]; - if (n != -1 && dir == *last_dir) // Already tried this direction? - continue; - - const float avail_w = (dir == ImGuiDir_Left ? r_avoid.Min.x : r_outer.Max.x) - (dir == ImGuiDir_Right ? r_avoid.Max.x : r_outer.Min.x); - const float avail_h = (dir == ImGuiDir_Up ? r_avoid.Min.y : r_outer.Max.y) - (dir == ImGuiDir_Down ? r_avoid.Max.y : r_outer.Min.y); - - // If there not enough room on one axis, there's no point in positioning on a side on this axis (e.g. when not enough width, use a top/bottom position to maximize available width) - if (avail_w < size.x && (dir == ImGuiDir_Left || dir == ImGuiDir_Right)) - continue; - if (avail_h < size.y && (dir == ImGuiDir_Up || dir == ImGuiDir_Down)) - continue; - - ImVec2 pos; - pos.x = (dir == ImGuiDir_Left) ? r_avoid.Min.x - size.x : (dir == ImGuiDir_Right) ? r_avoid.Max.x : base_pos_clamped.x; - pos.y = (dir == ImGuiDir_Up) ? r_avoid.Min.y - size.y : (dir == ImGuiDir_Down) ? r_avoid.Max.y : base_pos_clamped.y; - - // Clamp top-left corner of popup - pos.x = ImMax(pos.x, r_outer.Min.x); - pos.y = ImMax(pos.y, r_outer.Min.y); - - *last_dir = dir; - return pos; - } - } - - // Fallback when not enough room: - *last_dir = ImGuiDir_None; - - // For tooltip we prefer avoiding the cursor at all cost even if it means that part of the tooltip won't be visible. - if (policy == ImGuiPopupPositionPolicy_Tooltip) - return ref_pos + ImVec2(2, 2); - - // Otherwise try to keep within display - ImVec2 pos = ref_pos; - pos.x = ImMax(ImMin(pos.x + size.x, r_outer.Max.x) - size.x, r_outer.Min.x); - pos.y = ImMax(ImMin(pos.y + size.y, r_outer.Max.y) - size.y, r_outer.Min.y); - return pos; -} - -// Note that this is used for popups, which can overlap the non work-area of individual viewports. -ImRect ImGui::GetPopupAllowedExtentRect(ImGuiWindow* window) -{ - ImGuiContext& g = *GImGui; - IM_UNUSED(window); - ImRect r_screen = ((ImGuiViewportP*)(void*)GetMainViewport())->GetMainRect(); - ImVec2 padding = g.Style.DisplaySafeAreaPadding; - r_screen.Expand(ImVec2((r_screen.GetWidth() > padding.x * 2) ? -padding.x : 0.0f, (r_screen.GetHeight() > padding.y * 2) ? -padding.y : 0.0f)); - return r_screen; -} - -ImVec2 ImGui::FindBestWindowPosForPopup(ImGuiWindow* window) -{ - ImGuiContext& g = *GImGui; - - ImRect r_outer = GetPopupAllowedExtentRect(window); - if (window->Flags & ImGuiWindowFlags_ChildMenu) - { - // Child menus typically request _any_ position within the parent menu item, and then we move the new menu outside the parent bounds. - // This is how we end up with child menus appearing (most-commonly) on the right of the parent menu. - IM_ASSERT(g.CurrentWindow == window); - ImGuiWindow* parent_window = g.CurrentWindowStack[g.CurrentWindowStack.Size - 2].Window; - float horizontal_overlap = g.Style.ItemInnerSpacing.x; // We want some overlap to convey the relative depth of each menu (currently the amount of overlap is hard-coded to style.ItemSpacing.x). - ImRect r_avoid; - if (parent_window->DC.MenuBarAppending) - r_avoid = ImRect(-FLT_MAX, parent_window->ClipRect.Min.y, FLT_MAX, parent_window->ClipRect.Max.y); // Avoid parent menu-bar. If we wanted multi-line menu-bar, we may instead want to have the calling window setup e.g. a NextWindowData.PosConstraintAvoidRect field - else - r_avoid = ImRect(parent_window->Pos.x + horizontal_overlap, -FLT_MAX, parent_window->Pos.x + parent_window->Size.x - horizontal_overlap - parent_window->ScrollbarSizes.x, FLT_MAX); - return FindBestWindowPosForPopupEx(window->Pos, window->Size, &window->AutoPosLastDirection, r_outer, r_avoid, ImGuiPopupPositionPolicy_Default); - } - if (window->Flags & ImGuiWindowFlags_Popup) - { - ImRect r_avoid = ImRect(window->Pos.x - 1, window->Pos.y - 1, window->Pos.x + 1, window->Pos.y + 1); - return FindBestWindowPosForPopupEx(window->Pos, window->Size, &window->AutoPosLastDirection, r_outer, r_avoid, ImGuiPopupPositionPolicy_Default); - } - if (window->Flags & ImGuiWindowFlags_Tooltip) - { - // Position tooltip (always follows mouse) - float sc = g.Style.MouseCursorScale; - ImVec2 ref_pos = NavCalcPreferredRefPos(); - ImRect r_avoid; - if (!g.NavDisableHighlight && g.NavDisableMouseHover && !(g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos)) - r_avoid = ImRect(ref_pos.x - 16, ref_pos.y - 8, ref_pos.x + 16, ref_pos.y + 8); - else - r_avoid = ImRect(ref_pos.x - 16, ref_pos.y - 8, ref_pos.x + 24 * sc, ref_pos.y + 24 * sc); // FIXME: Hard-coded based on mouse cursor shape expectation. Exact dimension not very important. - return FindBestWindowPosForPopupEx(ref_pos, window->Size, &window->AutoPosLastDirection, r_outer, r_avoid, ImGuiPopupPositionPolicy_Tooltip); - } - IM_ASSERT(0); - return window->Pos; -} - -//----------------------------------------------------------------------------- -// [SECTION] KEYBOARD/GAMEPAD NAVIGATION -//----------------------------------------------------------------------------- - -// FIXME-NAV: The existence of SetNavID vs SetFocusID properly needs to be clarified/reworked. -// In our terminology those should be interchangeable. Those two functions are merely a legacy artifact, so at minimum naming should be clarified. -void ImGui::SetNavID(ImGuiID id, ImGuiNavLayer nav_layer, ImGuiID focus_scope_id, const ImRect& rect_rel) -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(g.NavWindow != NULL); - IM_ASSERT(nav_layer == ImGuiNavLayer_Main || nav_layer == ImGuiNavLayer_Menu); - g.NavId = id; - g.NavLayer = nav_layer; - g.NavFocusScopeId = focus_scope_id; - g.NavWindow->NavLastIds[nav_layer] = id; - g.NavWindow->NavRectRel[nav_layer] = rect_rel; - //g.NavDisableHighlight = false; - //g.NavDisableMouseHover = g.NavMousePosDirty = true; -} - -void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window) -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(id != 0); - - // Assume that SetFocusID() is called in the context where its window->DC.NavLayerCurrent and window->DC.NavFocusScopeIdCurrent are valid. - // Note that window may be != g.CurrentWindow (e.g. SetFocusID call in InputTextEx for multi-line text) - const ImGuiNavLayer nav_layer = window->DC.NavLayerCurrent; - if (g.NavWindow != window) - g.NavInitRequest = false; - g.NavWindow = window; - g.NavId = id; - g.NavLayer = nav_layer; - g.NavFocusScopeId = window->DC.NavFocusScopeIdCurrent; - window->NavLastIds[nav_layer] = id; - if (g.LastItemData.ID == id) - window->NavRectRel[nav_layer] = ImRect(g.LastItemData.NavRect.Min - window->Pos, g.LastItemData.NavRect.Max - window->Pos); - - if (g.ActiveIdSource == ImGuiInputSource_Nav) - g.NavDisableMouseHover = true; - else - g.NavDisableHighlight = true; -} - -ImGuiDir ImGetDirQuadrantFromDelta(float dx, float dy) -{ - if (ImFabs(dx) > ImFabs(dy)) - return (dx > 0.0f) ? ImGuiDir_Right : ImGuiDir_Left; - return (dy > 0.0f) ? ImGuiDir_Down : ImGuiDir_Up; -} - -static float inline NavScoreItemDistInterval(float a0, float a1, float b0, float b1) -{ - if (a1 < b0) - return a1 - b0; - if (b1 < a0) - return a0 - b1; - return 0.0f; -} - -static void inline NavClampRectToVisibleAreaForMoveDir(ImGuiDir move_dir, ImRect& r, const ImRect& clip_rect) -{ - if (move_dir == ImGuiDir_Left || move_dir == ImGuiDir_Right) - { - r.Min.y = ImClamp(r.Min.y, clip_rect.Min.y, clip_rect.Max.y); - r.Max.y = ImClamp(r.Max.y, clip_rect.Min.y, clip_rect.Max.y); - } - else // FIXME: PageUp/PageDown are leaving move_dir == None - { - r.Min.x = ImClamp(r.Min.x, clip_rect.Min.x, clip_rect.Max.x); - r.Max.x = ImClamp(r.Max.x, clip_rect.Min.x, clip_rect.Max.x); - } -} - -// Scoring function for gamepad/keyboard directional navigation. Based on https://gist.github.com/rygorous/6981057 -static bool ImGui::NavScoreItem(ImGuiNavItemData* result) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - if (g.NavLayer != window->DC.NavLayerCurrent) - return false; - - // FIXME: Those are not good variables names - ImRect cand = g.LastItemData.NavRect; // Current item nav rectangle - const ImRect curr = g.NavScoringRect; // Current modified source rect (NB: we've applied Max.x = Min.x in NavUpdate() to inhibit the effect of having varied item width) - g.NavScoringDebugCount++; - - // When entering through a NavFlattened border, we consider child window items as fully clipped for scoring - if (window->ParentWindow == g.NavWindow) - { - IM_ASSERT((window->Flags | g.NavWindow->Flags) & ImGuiWindowFlags_NavFlattened); - if (!window->ClipRect.Overlaps(cand)) - return false; - cand.ClipWithFull(window->ClipRect); // This allows the scored item to not overlap other candidates in the parent window - } - - // We perform scoring on items bounding box clipped by the current clipping rectangle on the other axis (clipping on our movement axis would give us equal scores for all clipped items) - // For example, this ensure that items in one column are not reached when moving vertically from items in another column. - NavClampRectToVisibleAreaForMoveDir(g.NavMoveClipDir, cand, window->ClipRect); - - // Compute distance between boxes - // FIXME-NAV: Introducing biases for vertical navigation, needs to be removed. - float dbx = NavScoreItemDistInterval(cand.Min.x, cand.Max.x, curr.Min.x, curr.Max.x); - float dby = NavScoreItemDistInterval(ImLerp(cand.Min.y, cand.Max.y, 0.2f), ImLerp(cand.Min.y, cand.Max.y, 0.8f), ImLerp(curr.Min.y, curr.Max.y, 0.2f), ImLerp(curr.Min.y, curr.Max.y, 0.8f)); // Scale down on Y to keep using box-distance for vertically touching items - if (dby != 0.0f && dbx != 0.0f) - dbx = (dbx / 1000.0f) + ((dbx > 0.0f) ? +1.0f : -1.0f); - float dist_box = ImFabs(dbx) + ImFabs(dby); - - // Compute distance between centers (this is off by a factor of 2, but we only compare center distances with each other so it doesn't matter) - float dcx = (cand.Min.x + cand.Max.x) - (curr.Min.x + curr.Max.x); - float dcy = (cand.Min.y + cand.Max.y) - (curr.Min.y + curr.Max.y); - float dist_center = ImFabs(dcx) + ImFabs(dcy); // L1 metric (need this for our connectedness guarantee) - - // Determine which quadrant of 'curr' our candidate item 'cand' lies in based on distance - ImGuiDir quadrant; - float dax = 0.0f, day = 0.0f, dist_axial = 0.0f; - if (dbx != 0.0f || dby != 0.0f) - { - // For non-overlapping boxes, use distance between boxes - dax = dbx; - day = dby; - dist_axial = dist_box; - quadrant = ImGetDirQuadrantFromDelta(dbx, dby); - } - else if (dcx != 0.0f || dcy != 0.0f) - { - // For overlapping boxes with different centers, use distance between centers - dax = dcx; - day = dcy; - dist_axial = dist_center; - quadrant = ImGetDirQuadrantFromDelta(dcx, dcy); - } - else - { - // Degenerate case: two overlapping buttons with same center, break ties arbitrarily (note that LastItemId here is really the _previous_ item order, but it doesn't matter) - quadrant = (g.LastItemData.ID < g.NavId) ? ImGuiDir_Left : ImGuiDir_Right; - } - -#if IMGUI_DEBUG_NAV_SCORING - char buf[128]; - if (IsMouseHoveringRect(cand.Min, cand.Max)) - { - ImFormatString(buf, IM_ARRAYSIZE(buf), "dbox (%.2f,%.2f->%.4f)\ndcen (%.2f,%.2f->%.4f)\nd (%.2f,%.2f->%.4f)\nnav %c, quadrant %c", dbx, dby, dist_box, dcx, dcy, dist_center, dax, day, dist_axial, "WENS"[g.NavMoveDir], "WENS"[quadrant]); - ImDrawList* draw_list = GetForegroundDrawList(window); - draw_list->AddRect(curr.Min, curr.Max, IM_COL32(255,200,0,100)); - draw_list->AddRect(cand.Min, cand.Max, IM_COL32(255,255,0,200)); - draw_list->AddRectFilled(cand.Max - ImVec2(4, 4), cand.Max + CalcTextSize(buf) + ImVec2(4, 4), IM_COL32(40,0,0,150)); - draw_list->AddText(cand.Max, ~0U, buf); - } - else if (g.IO.KeyCtrl) // Hold to preview score in matching quadrant. Press C to rotate. - { - if (quadrant == g.NavMoveDir) - { - ImFormatString(buf, IM_ARRAYSIZE(buf), "%.0f/%.0f", dist_box, dist_center); - ImDrawList* draw_list = GetForegroundDrawList(window); - draw_list->AddRectFilled(cand.Min, cand.Max, IM_COL32(255, 0, 0, 200)); - draw_list->AddText(cand.Min, IM_COL32(255, 255, 255, 255), buf); - } - } -#endif - - // Is it in the quadrant we're interesting in moving to? - bool new_best = false; - const ImGuiDir move_dir = g.NavMoveDir; - if (quadrant == move_dir) - { - // Does it beat the current best candidate? - if (dist_box < result->DistBox) - { - result->DistBox = dist_box; - result->DistCenter = dist_center; - return true; - } - if (dist_box == result->DistBox) - { - // Try using distance between center points to break ties - if (dist_center < result->DistCenter) - { - result->DistCenter = dist_center; - new_best = true; - } - else if (dist_center == result->DistCenter) - { - // Still tied! we need to be extra-careful to make sure everything gets linked properly. We consistently break ties by symbolically moving "later" items - // (with higher index) to the right/downwards by an infinitesimal amount since we the current "best" button already (so it must have a lower index), - // this is fairly easy. This rule ensures that all buttons with dx==dy==0 will end up being linked in order of appearance along the x axis. - if (((move_dir == ImGuiDir_Up || move_dir == ImGuiDir_Down) ? dby : dbx) < 0.0f) // moving bj to the right/down decreases distance - new_best = true; - } - } - } - - // Axial check: if 'curr' has no link at all in some direction and 'cand' lies roughly in that direction, add a tentative link. This will only be kept if no "real" matches - // are found, so it only augments the graph produced by the above method using extra links. (important, since it doesn't guarantee strong connectedness) - // This is just to avoid buttons having no links in a particular direction when there's a suitable neighbor. you get good graphs without this too. - // 2017/09/29: FIXME: This now currently only enabled inside menu bars, ideally we'd disable it everywhere. Menus in particular need to catch failure. For general navigation it feels awkward. - // Disabling it may lead to disconnected graphs when nodes are very spaced out on different axis. Perhaps consider offering this as an option? - if (result->DistBox == FLT_MAX && dist_axial < result->DistAxial) // Check axial match - if (g.NavLayer == ImGuiNavLayer_Menu && !(g.NavWindow->Flags & ImGuiWindowFlags_ChildMenu)) - if ((move_dir == ImGuiDir_Left && dax < 0.0f) || (move_dir == ImGuiDir_Right && dax > 0.0f) || (move_dir == ImGuiDir_Up && day < 0.0f) || (move_dir == ImGuiDir_Down && day > 0.0f)) - { - result->DistAxial = dist_axial; - new_best = true; - } - - return new_best; -} - -static void ImGui::NavApplyItemToResult(ImGuiNavItemData* result) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - result->Window = window; - result->ID = g.LastItemData.ID; - result->FocusScopeId = window->DC.NavFocusScopeIdCurrent; - result->InFlags = g.LastItemData.InFlags; - result->RectRel = ImRect(g.LastItemData.NavRect.Min - window->Pos, g.LastItemData.NavRect.Max - window->Pos); -} - -// We get there when either NavId == id, or when g.NavAnyRequest is set (which is updated by NavUpdateAnyRequestFlag above) -// This is called after LastItemData is set. -static void ImGui::NavProcessItem() -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - const ImGuiID id = g.LastItemData.ID; - const ImRect nav_bb = g.LastItemData.NavRect; - const ImGuiItemFlags item_flags = g.LastItemData.InFlags; - - // Process Init Request - if (g.NavInitRequest && g.NavLayer == window->DC.NavLayerCurrent) - { - // Even if 'ImGuiItemFlags_NoNavDefaultFocus' is on (typically collapse/close button) we record the first ResultId so they can be used as a fallback - const bool candidate_for_nav_default_focus = (item_flags & (ImGuiItemFlags_NoNavDefaultFocus | ImGuiItemFlags_Disabled)) == 0; - if (candidate_for_nav_default_focus || g.NavInitResultId == 0) - { - g.NavInitResultId = id; - g.NavInitResultRectRel = ImRect(nav_bb.Min - window->Pos, nav_bb.Max - window->Pos); - } - if (candidate_for_nav_default_focus) - { - g.NavInitRequest = false; // Found a match, clear request - NavUpdateAnyRequestFlag(); - } - } - - // Process Move Request (scoring for navigation) - // FIXME-NAV: Consider policy for double scoring (scoring from NavScoringRect + scoring from a rect wrapped according to current wrapping policy) - if (g.NavMoveScoringItems) - { - if (item_flags & ImGuiItemFlags_Inputable) - g.NavTabbingInputableRemaining--; - - if ((g.NavId != id || (g.NavMoveFlags & ImGuiNavMoveFlags_AllowCurrentNavId)) && !(item_flags & (ImGuiItemFlags_Disabled | ImGuiItemFlags_NoNav))) - { - ImGuiNavItemData* result = (window == g.NavWindow) ? &g.NavMoveResultLocal : &g.NavMoveResultOther; - - if (g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing) - { - if (g.NavTabbingInputableRemaining == 0) - NavMoveRequestResolveWithLastItem(); - } - else - { - if (NavScoreItem(result)) - NavApplyItemToResult(result); - - // Features like PageUp/PageDown need to maintain a separate score for the visible set of items. - const float VISIBLE_RATIO = 0.70f; - if ((g.NavMoveFlags & ImGuiNavMoveFlags_AlsoScoreVisibleSet) && window->ClipRect.Overlaps(nav_bb)) - if (ImClamp(nav_bb.Max.y, window->ClipRect.Min.y, window->ClipRect.Max.y) - ImClamp(nav_bb.Min.y, window->ClipRect.Min.y, window->ClipRect.Max.y) >= (nav_bb.Max.y - nav_bb.Min.y) * VISIBLE_RATIO) - if (NavScoreItem(&g.NavMoveResultLocalVisible)) - NavApplyItemToResult(&g.NavMoveResultLocalVisible); - } - } - } - - // Update window-relative bounding box of navigated item - if (g.NavId == id) - { - g.NavWindow = window; // Always refresh g.NavWindow, because some operations such as FocusItem() don't have a window. - g.NavLayer = window->DC.NavLayerCurrent; - g.NavFocusScopeId = window->DC.NavFocusScopeIdCurrent; - g.NavIdIsAlive = true; - window->NavRectRel[window->DC.NavLayerCurrent] = ImRect(nav_bb.Min - window->Pos, nav_bb.Max - window->Pos); // Store item bounding box (relative to window position) - } -} - -bool ImGui::NavMoveRequestButNoResultYet() -{ - ImGuiContext& g = *GImGui; - return g.NavMoveScoringItems && g.NavMoveResultLocal.ID == 0 && g.NavMoveResultOther.ID == 0; -} - -// FIXME: ScoringRect is not set -void ImGui::NavMoveRequestSubmit(ImGuiDir move_dir, ImGuiDir clip_dir, ImGuiNavMoveFlags move_flags, ImGuiScrollFlags scroll_flags) -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(g.NavWindow != NULL); - - if (move_flags & ImGuiNavMoveFlags_Tabbing) - move_flags |= ImGuiNavMoveFlags_AllowCurrentNavId; - - g.NavMoveSubmitted = g.NavMoveScoringItems = true; - g.NavMoveDir = move_dir; - g.NavMoveDirForDebug = move_dir; - g.NavMoveClipDir = clip_dir; - g.NavMoveFlags = move_flags; - g.NavMoveScrollFlags = scroll_flags; - g.NavMoveForwardToNextFrame = false; - g.NavMoveKeyMods = g.IO.KeyMods; - g.NavTabbingInputableRemaining = 0; - g.NavMoveResultLocal.Clear(); - g.NavMoveResultLocalVisible.Clear(); - g.NavMoveResultOther.Clear(); - NavUpdateAnyRequestFlag(); -} - -void ImGui::NavMoveRequestResolveWithLastItem() -{ - ImGuiContext& g = *GImGui; - g.NavMoveScoringItems = false; // Ensure request doesn't need more processing - NavApplyItemToResult(&g.NavMoveResultLocal); - NavUpdateAnyRequestFlag(); -} - -void ImGui::NavMoveRequestCancel() -{ - ImGuiContext& g = *GImGui; - g.NavMoveSubmitted = g.NavMoveScoringItems = false; - NavUpdateAnyRequestFlag(); -} - -// Forward will reuse the move request again on the next frame (generally with modifications done to it) -void ImGui::NavMoveRequestForward(ImGuiDir move_dir, ImGuiDir clip_dir, ImGuiNavMoveFlags move_flags, ImGuiScrollFlags scroll_flags) -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(g.NavMoveForwardToNextFrame == false); - NavMoveRequestCancel(); - g.NavMoveForwardToNextFrame = true; - g.NavMoveDir = move_dir; - g.NavMoveClipDir = clip_dir; - g.NavMoveFlags = move_flags | ImGuiNavMoveFlags_Forwarded; - g.NavMoveScrollFlags = scroll_flags; -} - -// Navigation wrap-around logic is delayed to the end of the frame because this operation is only valid after entire -// popup is assembled and in case of appended popups it is not clear which EndPopup() call is final. -void ImGui::NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags wrap_flags) -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(wrap_flags != 0); // Call with _WrapX, _WrapY, _LoopX, _LoopY - // In theory we should test for NavMoveRequestButNoResultYet() but there's no point doing it, NavEndFrame() will do the same test - if (g.NavWindow == window && g.NavMoveScoringItems && g.NavLayer == ImGuiNavLayer_Main) - g.NavMoveFlags |= wrap_flags; -} - -// FIXME: This could be replaced by updating a frame number in each window when (window == NavWindow) and (NavLayer == 0). -// This way we could find the last focused window among our children. It would be much less confusing this way? -static void ImGui::NavSaveLastChildNavWindowIntoParent(ImGuiWindow* nav_window) -{ - ImGuiWindow* parent = nav_window; - while (parent && parent->RootWindow != parent && (parent->Flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_ChildMenu)) == 0) - parent = parent->ParentWindow; - if (parent && parent != nav_window) - parent->NavLastChildNavWindow = nav_window; -} - -// Restore the last focused child. -// Call when we are expected to land on the Main Layer (0) after FocusWindow() -static ImGuiWindow* ImGui::NavRestoreLastChildNavWindow(ImGuiWindow* window) -{ - if (window->NavLastChildNavWindow && window->NavLastChildNavWindow->WasActive) - return window->NavLastChildNavWindow; - return window; -} - -void ImGui::NavRestoreLayer(ImGuiNavLayer layer) -{ - ImGuiContext& g = *GImGui; - if (layer == ImGuiNavLayer_Main) - g.NavWindow = NavRestoreLastChildNavWindow(g.NavWindow); - ImGuiWindow* window = g.NavWindow; - if (window->NavLastIds[layer] != 0) - { - SetNavID(window->NavLastIds[layer], layer, 0, window->NavRectRel[layer]); - } - else - { - g.NavLayer = layer; - NavInitWindow(window, true); - } - g.NavDisableHighlight = false; - g.NavDisableMouseHover = g.NavMousePosDirty = true; -} - -static inline void ImGui::NavUpdateAnyRequestFlag() -{ - ImGuiContext& g = *GImGui; - g.NavAnyRequest = g.NavMoveScoringItems || g.NavInitRequest || (IMGUI_DEBUG_NAV_SCORING && g.NavWindow != NULL); - if (g.NavAnyRequest) - IM_ASSERT(g.NavWindow != NULL); -} - -// This needs to be called before we submit any widget (aka in or before Begin) -void ImGui::NavInitWindow(ImGuiWindow* window, bool force_reinit) -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(window == g.NavWindow); - - if (window->Flags & ImGuiWindowFlags_NoNavInputs) - { - g.NavId = g.NavFocusScopeId = 0; - return; - } - - bool init_for_nav = false; - if (window == window->RootWindow || (window->Flags & ImGuiWindowFlags_Popup) || (window->NavLastIds[0] == 0) || force_reinit) - init_for_nav = true; - IMGUI_DEBUG_LOG_NAV("[nav] NavInitRequest: from NavInitWindow(), init_for_nav=%d, window=\"%s\", layer=%d\n", init_for_nav, window->Name, g.NavLayer); - if (init_for_nav) - { - SetNavID(0, g.NavLayer, 0, ImRect()); - g.NavInitRequest = true; - g.NavInitRequestFromMove = false; - g.NavInitResultId = 0; - g.NavInitResultRectRel = ImRect(); - NavUpdateAnyRequestFlag(); - } - else - { - g.NavId = window->NavLastIds[0]; - g.NavFocusScopeId = 0; - } -} - -static ImVec2 ImGui::NavCalcPreferredRefPos() -{ - ImGuiContext& g = *GImGui; - if (g.NavDisableHighlight || !g.NavDisableMouseHover || !g.NavWindow) - { - // Mouse (we need a fallback in case the mouse becomes invalid after being used) - if (IsMousePosValid(&g.IO.MousePos)) - return g.IO.MousePos; - return g.MouseLastValidPos; - } - else - { - // When navigation is active and mouse is disabled, decide on an arbitrary position around the bottom left of the currently navigated item. - const ImRect& rect_rel = g.NavWindow->NavRectRel[g.NavLayer]; - ImVec2 pos = g.NavWindow->Pos + ImVec2(rect_rel.Min.x + ImMin(g.Style.FramePadding.x * 4, rect_rel.GetWidth()), rect_rel.Max.y - ImMin(g.Style.FramePadding.y, rect_rel.GetHeight())); - ImGuiViewport* viewport = GetMainViewport(); - return ImFloor(ImClamp(pos, viewport->Pos, viewport->Pos + viewport->Size)); // ImFloor() is important because non-integer mouse position application in backend might be lossy and result in undesirable non-zero delta. - } -} - -float ImGui::GetNavInputAmount(ImGuiNavInput n, ImGuiInputReadMode mode) -{ - ImGuiContext& g = *GImGui; - if (mode == ImGuiInputReadMode_Down) - return g.IO.NavInputs[n]; // Instant, read analog input (0.0f..1.0f, as provided by user) - - const float t = g.IO.NavInputsDownDuration[n]; - if (t < 0.0f && mode == ImGuiInputReadMode_Released) // Return 1.0f when just released, no repeat, ignore analog input. - return (g.IO.NavInputsDownDurationPrev[n] >= 0.0f ? 1.0f : 0.0f); - if (t < 0.0f) - return 0.0f; - if (mode == ImGuiInputReadMode_Pressed) // Return 1.0f when just pressed, no repeat, ignore analog input. - return (t == 0.0f) ? 1.0f : 0.0f; - if (mode == ImGuiInputReadMode_Repeat) - return (float)CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, g.IO.KeyRepeatDelay * 0.72f, g.IO.KeyRepeatRate * 0.80f); - if (mode == ImGuiInputReadMode_RepeatSlow) - return (float)CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, g.IO.KeyRepeatDelay * 1.25f, g.IO.KeyRepeatRate * 2.00f); - if (mode == ImGuiInputReadMode_RepeatFast) - return (float)CalcTypematicRepeatAmount(t - g.IO.DeltaTime, t, g.IO.KeyRepeatDelay * 0.72f, g.IO.KeyRepeatRate * 0.30f); - return 0.0f; -} - -ImVec2 ImGui::GetNavInputAmount2d(ImGuiNavDirSourceFlags dir_sources, ImGuiInputReadMode mode, float slow_factor, float fast_factor) -{ - ImVec2 delta(0.0f, 0.0f); - if (dir_sources & ImGuiNavDirSourceFlags_Keyboard) - delta += ImVec2(GetNavInputAmount(ImGuiNavInput_KeyRight_, mode) - GetNavInputAmount(ImGuiNavInput_KeyLeft_, mode), GetNavInputAmount(ImGuiNavInput_KeyDown_, mode) - GetNavInputAmount(ImGuiNavInput_KeyUp_, mode)); - if (dir_sources & ImGuiNavDirSourceFlags_PadDPad) - delta += ImVec2(GetNavInputAmount(ImGuiNavInput_DpadRight, mode) - GetNavInputAmount(ImGuiNavInput_DpadLeft, mode), GetNavInputAmount(ImGuiNavInput_DpadDown, mode) - GetNavInputAmount(ImGuiNavInput_DpadUp, mode)); - if (dir_sources & ImGuiNavDirSourceFlags_PadLStick) - delta += ImVec2(GetNavInputAmount(ImGuiNavInput_LStickRight, mode) - GetNavInputAmount(ImGuiNavInput_LStickLeft, mode), GetNavInputAmount(ImGuiNavInput_LStickDown, mode) - GetNavInputAmount(ImGuiNavInput_LStickUp, mode)); - if (slow_factor != 0.0f && IsNavInputDown(ImGuiNavInput_TweakSlow)) - delta *= slow_factor; - if (fast_factor != 0.0f && IsNavInputDown(ImGuiNavInput_TweakFast)) - delta *= fast_factor; - return delta; -} - -static void ImGui::NavUpdate() -{ - ImGuiContext& g = *GImGui; - ImGuiIO& io = g.IO; - - io.WantSetMousePos = false; - //if (g.NavScoringDebugCount > 0) IMGUI_DEBUG_LOG("NavScoringDebugCount %d for '%s' layer %d (Init:%d, Move:%d)\n", g.NavScoringDebugCount, g.NavWindow ? g.NavWindow->Name : "NULL", g.NavLayer, g.NavInitRequest || g.NavInitResultId != 0, g.NavMoveRequest); - - // Set input source as Gamepad when buttons are pressed (as some features differs when used with Gamepad vs Keyboard) - // (do it before we map Keyboard input!) - const bool nav_keyboard_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0; - const bool nav_gamepad_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (io.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0; - if (nav_gamepad_active && g.NavInputSource != ImGuiInputSource_Gamepad) - { - if (io.NavInputs[ImGuiNavInput_Activate] > 0.0f || io.NavInputs[ImGuiNavInput_Input] > 0.0f || io.NavInputs[ImGuiNavInput_Cancel] > 0.0f || io.NavInputs[ImGuiNavInput_Menu] > 0.0f - || io.NavInputs[ImGuiNavInput_DpadLeft] > 0.0f || io.NavInputs[ImGuiNavInput_DpadRight] > 0.0f || io.NavInputs[ImGuiNavInput_DpadUp] > 0.0f || io.NavInputs[ImGuiNavInput_DpadDown] > 0.0f) - g.NavInputSource = ImGuiInputSource_Gamepad; - } - - // Update Keyboard->Nav inputs mapping - if (nav_keyboard_active) - { - #define NAV_MAP_KEY(_KEY, _NAV_INPUT) do { if (IsKeyDown(io.KeyMap[_KEY])) { io.NavInputs[_NAV_INPUT] = 1.0f; g.NavInputSource = ImGuiInputSource_Keyboard; } } while (0) - NAV_MAP_KEY(ImGuiKey_Space, ImGuiNavInput_Activate ); - NAV_MAP_KEY(ImGuiKey_Enter, ImGuiNavInput_Input ); - NAV_MAP_KEY(ImGuiKey_Escape, ImGuiNavInput_Cancel ); - NAV_MAP_KEY(ImGuiKey_LeftArrow, ImGuiNavInput_KeyLeft_ ); - NAV_MAP_KEY(ImGuiKey_RightArrow,ImGuiNavInput_KeyRight_); - NAV_MAP_KEY(ImGuiKey_UpArrow, ImGuiNavInput_KeyUp_ ); - NAV_MAP_KEY(ImGuiKey_DownArrow, ImGuiNavInput_KeyDown_ ); - if (io.KeyCtrl) - io.NavInputs[ImGuiNavInput_TweakSlow] = 1.0f; - if (io.KeyShift) - io.NavInputs[ImGuiNavInput_TweakFast] = 1.0f; - #undef NAV_MAP_KEY - } - memcpy(io.NavInputsDownDurationPrev, io.NavInputsDownDuration, sizeof(io.NavInputsDownDuration)); - for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++) - io.NavInputsDownDuration[i] = (io.NavInputs[i] > 0.0f) ? (io.NavInputsDownDuration[i] < 0.0f ? 0.0f : io.NavInputsDownDuration[i] + io.DeltaTime) : -1.0f; - - // Process navigation init request (select first/default focus) - if (g.NavInitResultId != 0) - NavInitRequestApplyResult(); - g.NavInitRequest = false; - g.NavInitRequestFromMove = false; - g.NavInitResultId = 0; - g.NavJustMovedToId = 0; - - // Process navigation move request - if (g.NavMoveSubmitted) - NavMoveRequestApplyResult(); - g.NavTabbingInputableRemaining = 0; - g.NavMoveSubmitted = g.NavMoveScoringItems = false; - - // Apply application mouse position movement, after we had a chance to process move request result. - if (g.NavMousePosDirty && g.NavIdIsAlive) - { - // Set mouse position given our knowledge of the navigated item position from last frame - if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) && (io.BackendFlags & ImGuiBackendFlags_HasSetMousePos)) - if (!g.NavDisableHighlight && g.NavDisableMouseHover && g.NavWindow) - { - io.MousePos = io.MousePosPrev = NavCalcPreferredRefPos(); - io.WantSetMousePos = true; - //IMGUI_DEBUG_LOG("SetMousePos: (%.1f,%.1f)\n", io.MousePos.x, io.MousePos.y); - } - g.NavMousePosDirty = false; - } - g.NavIdIsAlive = false; - g.NavJustTabbedId = 0; - IM_ASSERT(g.NavLayer == ImGuiNavLayer_Main || g.NavLayer == ImGuiNavLayer_Menu); - - // Store our return window (for returning from Menu Layer to Main Layer) and clear it as soon as we step back in our own Layer 0 - if (g.NavWindow) - NavSaveLastChildNavWindowIntoParent(g.NavWindow); - if (g.NavWindow && g.NavWindow->NavLastChildNavWindow != NULL && g.NavLayer == ImGuiNavLayer_Main) - g.NavWindow->NavLastChildNavWindow = NULL; - - // Update CTRL+TAB and Windowing features (hold Square to move/resize/etc.) - NavUpdateWindowing(); - - // Set output flags for user application - io.NavActive = (nav_keyboard_active || nav_gamepad_active) && g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs); - io.NavVisible = (io.NavActive && g.NavId != 0 && !g.NavDisableHighlight) || (g.NavWindowingTarget != NULL); - - // Process NavCancel input (to close a popup, get back to parent, clear focus) - NavUpdateCancelRequest(); - - // Process manual activation request - g.NavActivateId = g.NavActivateDownId = g.NavActivatePressedId = g.NavActivateInputId = 0; - g.NavActivateFlags = ImGuiActivateFlags_None; - if (g.NavId != 0 && !g.NavDisableHighlight && !g.NavWindowingTarget && g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs)) - { - bool activate_down = IsNavInputDown(ImGuiNavInput_Activate); - bool input_down = IsNavInputDown(ImGuiNavInput_Input); - bool activate_pressed = activate_down && IsNavInputTest(ImGuiNavInput_Activate, ImGuiInputReadMode_Pressed); - bool input_pressed = input_down && IsNavInputTest(ImGuiNavInput_Input, ImGuiInputReadMode_Pressed); - if (g.ActiveId == 0 && activate_pressed) - { - g.NavActivateId = g.NavId; - g.NavActivateFlags = ImGuiActivateFlags_PreferTweak; - } - if ((g.ActiveId == 0 || g.ActiveId == g.NavId) && input_pressed) - { - g.NavActivateInputId = g.NavId; - g.NavActivateFlags = ImGuiActivateFlags_PreferInput; - } - if ((g.ActiveId == 0 || g.ActiveId == g.NavId) && activate_down) - g.NavActivateDownId = g.NavId; - if ((g.ActiveId == 0 || g.ActiveId == g.NavId) && activate_pressed) - g.NavActivatePressedId = g.NavId; - } - if (g.NavWindow && (g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs)) - g.NavDisableHighlight = true; - if (g.NavActivateId != 0) - IM_ASSERT(g.NavActivateDownId == g.NavActivateId); - - // Process programmatic activation request - // FIXME-NAV: Those should eventually be queued (unlike focus they don't cancel each others) - if (g.NavNextActivateId != 0) - { - if (g.NavNextActivateFlags & ImGuiActivateFlags_PreferInput) - g.NavActivateInputId = g.NavNextActivateId; - else - g.NavActivateId = g.NavActivateDownId = g.NavActivatePressedId = g.NavNextActivateId; - g.NavActivateFlags = g.NavNextActivateFlags; - } - g.NavNextActivateId = 0; - - // Process move requests - NavUpdateCreateMoveRequest(); - NavUpdateAnyRequestFlag(); - - // Scrolling - if (g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs) && !g.NavWindowingTarget) - { - // *Fallback* manual-scroll with Nav directional keys when window has no navigable item - ImGuiWindow* window = g.NavWindow; - const float scroll_speed = IM_ROUND(window->CalcFontSize() * 100 * io.DeltaTime); // We need round the scrolling speed because sub-pixel scroll isn't reliably supported. - const ImGuiDir move_dir = g.NavMoveDir; - if (window->DC.NavLayersActiveMask == 0x00 && window->DC.NavHasScroll && move_dir != ImGuiDir_None) - { - if (move_dir == ImGuiDir_Left || move_dir == ImGuiDir_Right) - SetScrollX(window, ImFloor(window->Scroll.x + ((move_dir == ImGuiDir_Left) ? -1.0f : +1.0f) * scroll_speed)); - if (move_dir == ImGuiDir_Up || move_dir == ImGuiDir_Down) - SetScrollY(window, ImFloor(window->Scroll.y + ((move_dir == ImGuiDir_Up) ? -1.0f : +1.0f) * scroll_speed)); - } - - // *Normal* Manual scroll with NavScrollXXX keys - // Next movement request will clamp the NavId reference rectangle to the visible area, so navigation will resume within those bounds. - ImVec2 scroll_dir = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadLStick, ImGuiInputReadMode_Down, 1.0f / 10.0f, 10.0f); - if (scroll_dir.x != 0.0f && window->ScrollbarX) - SetScrollX(window, ImFloor(window->Scroll.x + scroll_dir.x * scroll_speed)); - if (scroll_dir.y != 0.0f) - SetScrollY(window, ImFloor(window->Scroll.y + scroll_dir.y * scroll_speed)); - } - - // Always prioritize mouse highlight if navigation is disabled - if (!nav_keyboard_active && !nav_gamepad_active) - { - g.NavDisableHighlight = true; - g.NavDisableMouseHover = g.NavMousePosDirty = false; - } - - // [DEBUG] - g.NavScoringDebugCount = 0; -#if IMGUI_DEBUG_NAV_RECTS - if (g.NavWindow) - { - ImDrawList* draw_list = GetForegroundDrawList(g.NavWindow); - if (1) { for (int layer = 0; layer < 2; layer++) draw_list->AddRect(g.NavWindow->Pos + g.NavWindow->NavRectRel[layer].Min, g.NavWindow->Pos + g.NavWindow->NavRectRel[layer].Max, IM_COL32(255,200,0,255)); } // [DEBUG] - if (1) { ImU32 col = (!g.NavWindow->Hidden) ? IM_COL32(255,0,255,255) : IM_COL32(255,0,0,255); ImVec2 p = NavCalcPreferredRefPos(); char buf[32]; ImFormatString(buf, 32, "%d", g.NavLayer); draw_list->AddCircleFilled(p, 3.0f, col); draw_list->AddText(NULL, 13.0f, p + ImVec2(8,-4), col, buf); } - } -#endif -} - -void ImGui::NavInitRequestApplyResult() -{ - // In very rare cases g.NavWindow may be null (e.g. clearing focus after requesting an init request, which does happen when releasing Alt while clicking on void) - ImGuiContext& g = *GImGui; - if (!g.NavWindow) - return; - - // Apply result from previous navigation init request (will typically select the first item, unless SetItemDefaultFocus() has been called) - // FIXME-NAV: On _NavFlattened windows, g.NavWindow will only be updated during subsequent frame. Not a problem currently. - IMGUI_DEBUG_LOG_NAV("[nav] NavInitRequest: result NavID 0x%08X in Layer %d Window \"%s\"\n", g.NavInitResultId, g.NavLayer, g.NavWindow->Name); - SetNavID(g.NavInitResultId, g.NavLayer, 0, g.NavInitResultRectRel); - g.NavIdIsAlive = true; // Mark as alive from previous frame as we got a result - if (g.NavInitRequestFromMove) - { - g.NavDisableHighlight = false; - g.NavDisableMouseHover = g.NavMousePosDirty = true; - } -} - -void ImGui::NavUpdateCreateMoveRequest() -{ - ImGuiContext& g = *GImGui; - ImGuiIO& io = g.IO; - ImGuiWindow* window = g.NavWindow; - - if (g.NavMoveForwardToNextFrame && window != NULL) - { - // Forwarding previous request (which has been modified, e.g. wrap around menus rewrite the requests with a starting rectangle at the other side of the window) - // (preserve most state, which were already set by the NavMoveRequestForward() function) - IM_ASSERT(g.NavMoveDir != ImGuiDir_None && g.NavMoveClipDir != ImGuiDir_None); - IM_ASSERT(g.NavMoveFlags & ImGuiNavMoveFlags_Forwarded); - IMGUI_DEBUG_LOG_NAV("[nav] NavMoveRequestForward %d\n", g.NavMoveDir); - } - else - { - // Initiate directional inputs request - g.NavMoveDir = ImGuiDir_None; - g.NavMoveFlags = ImGuiNavMoveFlags_None; - g.NavMoveScrollFlags = ImGuiScrollFlags_None; - if (window && !g.NavWindowingTarget && !(window->Flags & ImGuiWindowFlags_NoNavInputs)) - { - const ImGuiInputReadMode read_mode = ImGuiInputReadMode_Repeat; - if (!IsActiveIdUsingNavDir(ImGuiDir_Left) && (IsNavInputTest(ImGuiNavInput_DpadLeft, read_mode) || IsNavInputTest(ImGuiNavInput_KeyLeft_, read_mode))) { g.NavMoveDir = ImGuiDir_Left; } - if (!IsActiveIdUsingNavDir(ImGuiDir_Right) && (IsNavInputTest(ImGuiNavInput_DpadRight, read_mode) || IsNavInputTest(ImGuiNavInput_KeyRight_, read_mode))) { g.NavMoveDir = ImGuiDir_Right; } - if (!IsActiveIdUsingNavDir(ImGuiDir_Up) && (IsNavInputTest(ImGuiNavInput_DpadUp, read_mode) || IsNavInputTest(ImGuiNavInput_KeyUp_, read_mode))) { g.NavMoveDir = ImGuiDir_Up; } - if (!IsActiveIdUsingNavDir(ImGuiDir_Down) && (IsNavInputTest(ImGuiNavInput_DpadDown, read_mode) || IsNavInputTest(ImGuiNavInput_KeyDown_, read_mode))) { g.NavMoveDir = ImGuiDir_Down; } - } - g.NavMoveClipDir = g.NavMoveDir; - } - - // Update PageUp/PageDown/Home/End scroll - // FIXME-NAV: Consider enabling those keys even without the master ImGuiConfigFlags_NavEnableKeyboard flag? - const bool nav_keyboard_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0; - float scoring_rect_offset_y = 0.0f; - if (window && g.NavMoveDir == ImGuiDir_None && nav_keyboard_active) - scoring_rect_offset_y = NavUpdatePageUpPageDown(); - - // [DEBUG] Always send a request -#if IMGUI_DEBUG_NAV_SCORING - if (io.KeyCtrl && IsKeyPressedMap(ImGuiKey_C)) - g.NavMoveDirForDebug = (ImGuiDir)((g.NavMoveDirForDebug + 1) & 3); - if (io.KeyCtrl && g.NavMoveDir == ImGuiDir_None) - { - g.NavMoveDir = g.NavMoveDirForDebug; - g.NavMoveFlags |= ImGuiNavMoveFlags_DebugNoResult; - } -#endif - - // Submit - g.NavMoveForwardToNextFrame = false; - if (g.NavMoveDir != ImGuiDir_None) - NavMoveRequestSubmit(g.NavMoveDir, g.NavMoveClipDir, g.NavMoveFlags, g.NavMoveScrollFlags); - - // Moving with no reference triggers a init request (will be used as a fallback if the direction fails to find a match) - if (g.NavMoveSubmitted && g.NavId == 0) - { - IMGUI_DEBUG_LOG_NAV("[nav] NavInitRequest: from move, window \"%s\", layer=%d\n", g.NavWindow->Name, g.NavLayer); - g.NavInitRequest = g.NavInitRequestFromMove = true; - g.NavInitResultId = 0; - g.NavDisableHighlight = false; - } - - // When using gamepad, we project the reference nav bounding box into window visible area. - // This is to allow resuming navigation inside the visible area after doing a large amount of scrolling, since with gamepad every movements are relative - // (can't focus a visible object like we can with the mouse). - if (g.NavMoveSubmitted && g.NavInputSource == ImGuiInputSource_Gamepad && g.NavLayer == ImGuiNavLayer_Main && window != NULL) - { - ImRect window_rect_rel(window->InnerRect.Min - window->Pos - ImVec2(1, 1), window->InnerRect.Max - window->Pos + ImVec2(1, 1)); - if (!window_rect_rel.Contains(window->NavRectRel[g.NavLayer])) - { - IMGUI_DEBUG_LOG_NAV("[nav] NavMoveRequest: clamp NavRectRel\n"); - float pad = window->CalcFontSize() * 0.5f; - window_rect_rel.Expand(ImVec2(-ImMin(window_rect_rel.GetWidth(), pad), -ImMin(window_rect_rel.GetHeight(), pad))); // Terrible approximation for the intent of starting navigation from first fully visible item - window->NavRectRel[g.NavLayer].ClipWithFull(window_rect_rel); - g.NavId = g.NavFocusScopeId = 0; - } - } - - // For scoring we use a single segment on the left side our current item bounding box (not touching the edge to avoid box overlap with zero-spaced items) - ImRect scoring_rect; - if (window != NULL) - { - ImRect nav_rect_rel = !window->NavRectRel[g.NavLayer].IsInverted() ? window->NavRectRel[g.NavLayer] : ImRect(0, 0, 0, 0); - scoring_rect = ImRect(window->Pos + nav_rect_rel.Min, window->Pos + nav_rect_rel.Max); - scoring_rect.TranslateY(scoring_rect_offset_y); - scoring_rect.Min.x = ImMin(scoring_rect.Min.x + 1.0f, scoring_rect.Max.x); - scoring_rect.Max.x = scoring_rect.Min.x; - IM_ASSERT(!scoring_rect.IsInverted()); // Ensure if we have a finite, non-inverted bounding box here will allows us to remove extraneous ImFabs() calls in NavScoreItem(). - //GetForegroundDrawList()->AddRect(scoring_rect.Min, scoring_rect.Max, IM_COL32(255,200,0,255)); // [DEBUG] - } - g.NavScoringRect = scoring_rect; -} - -// Apply result from previous frame navigation directional move request. Always called from NavUpdate() -void ImGui::NavMoveRequestApplyResult() -{ - ImGuiContext& g = *GImGui; -#if IMGUI_DEBUG_NAV_SCORING - if (g.NavMoveFlags & ImGuiNavMoveFlags_DebugNoResult) // [DEBUG] Scoring all items in NavWindow at all times - return; -#endif - - // Select which result to use - ImGuiNavItemData* result = (g.NavMoveResultLocal.ID != 0) ? &g.NavMoveResultLocal : (g.NavMoveResultOther.ID != 0) ? &g.NavMoveResultOther : NULL; - - // In a situation when there is no results but NavId != 0, re-enable the Navigation highlight (because g.NavId is not considered as a possible result) - if (result == NULL) - { - if (g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing) - g.NavMoveFlags |= ImGuiNavMoveFlags_DontSetNavHighlight; - if (g.NavId != 0 && (g.NavMoveFlags & ImGuiNavMoveFlags_DontSetNavHighlight) == 0) - { - g.NavDisableHighlight = false; - g.NavDisableMouseHover = true; - } - return; - } - - // PageUp/PageDown behavior first jumps to the bottom/top mostly visible item, _otherwise_ use the result from the previous/next page. - if (g.NavMoveFlags & ImGuiNavMoveFlags_AlsoScoreVisibleSet) - if (g.NavMoveResultLocalVisible.ID != 0 && g.NavMoveResultLocalVisible.ID != g.NavId) - result = &g.NavMoveResultLocalVisible; - - // Maybe entering a flattened child from the outside? In this case solve the tie using the regular scoring rules. - if (result != &g.NavMoveResultOther && g.NavMoveResultOther.ID != 0 && g.NavMoveResultOther.Window->ParentWindow == g.NavWindow) - if ((g.NavMoveResultOther.DistBox < result->DistBox) || (g.NavMoveResultOther.DistBox == result->DistBox && g.NavMoveResultOther.DistCenter < result->DistCenter)) - result = &g.NavMoveResultOther; - IM_ASSERT(g.NavWindow && result->Window); - - // Scroll to keep newly navigated item fully into view. - if (g.NavLayer == ImGuiNavLayer_Main) - { - ImVec2 delta_scroll; - if (g.NavMoveFlags & ImGuiNavMoveFlags_ScrollToEdgeY) - { - // FIXME: Should remove this - float scroll_target = (g.NavMoveDir == ImGuiDir_Up) ? result->Window->ScrollMax.y : 0.0f; - delta_scroll.y = result->Window->Scroll.y - scroll_target; - SetScrollY(result->Window, scroll_target); - } - else - { - ImRect rect_abs = ImRect(result->RectRel.Min + result->Window->Pos, result->RectRel.Max + result->Window->Pos); - delta_scroll = ScrollToRectEx(result->Window, rect_abs, g.NavMoveScrollFlags); - } - - // Offset our result position so mouse position can be applied immediately after in NavUpdate() - result->RectRel.TranslateX(-delta_scroll.x); - result->RectRel.TranslateY(-delta_scroll.y); - } - - ClearActiveID(); - g.NavWindow = result->Window; - if (g.NavId != result->ID) - { - // Don't set NavJustMovedToId if just landed on the same spot (which may happen with ImGuiNavMoveFlags_AllowCurrentNavId) - g.NavJustMovedToId = result->ID; - g.NavJustMovedToFocusScopeId = result->FocusScopeId; - g.NavJustMovedToKeyMods = g.NavMoveKeyMods; - } - - // Focus - IMGUI_DEBUG_LOG_NAV("[nav] NavMoveRequest: result NavID 0x%08X in Layer %d Window \"%s\"\n", result->ID, g.NavLayer, g.NavWindow->Name); - SetNavID(result->ID, g.NavLayer, result->FocusScopeId, result->RectRel); - - // Tabbing: Activates Inputable or Focus non-Inputable - if ((g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing) && (result->InFlags & ImGuiItemFlags_Inputable)) - { - g.NavNextActivateId = result->ID; - g.NavNextActivateFlags = ImGuiActivateFlags_PreferInput | ImGuiActivateFlags_TryToPreserveState; - g.NavMoveFlags |= ImGuiNavMoveFlags_DontSetNavHighlight; - } - - // Activate - if (g.NavMoveFlags & ImGuiNavMoveFlags_Activate) - { - g.NavNextActivateId = result->ID; - g.NavNextActivateFlags = ImGuiActivateFlags_None; - } - - // Enable nav highlight - if ((g.NavMoveFlags & ImGuiNavMoveFlags_DontSetNavHighlight) == 0) - { - g.NavDisableHighlight = false; - g.NavDisableMouseHover = g.NavMousePosDirty = true; - } -} - -// Process NavCancel input (to close a popup, get back to parent, clear focus) -// FIXME: In order to support e.g. Escape to clear a selection we'll need: -// - either to store the equivalent of ActiveIdUsingKeyInputMask for a FocusScope and test for it. -// - either to move most/all of those tests to the epilogue/end functions of the scope they are dealing with (e.g. exit child window in EndChild()) or in EndFrame(), to allow an earlier intercept -static void ImGui::NavUpdateCancelRequest() -{ - ImGuiContext& g = *GImGui; - if (!IsNavInputTest(ImGuiNavInput_Cancel, ImGuiInputReadMode_Pressed)) - return; - - IMGUI_DEBUG_LOG_NAV("[nav] ImGuiNavInput_Cancel\n"); - if (g.ActiveId != 0) - { - if (!IsActiveIdUsingNavInput(ImGuiNavInput_Cancel)) - ClearActiveID(); - } - else if (g.NavLayer != ImGuiNavLayer_Main) - { - // Leave the "menu" layer - NavRestoreLayer(ImGuiNavLayer_Main); - } - else if (g.NavWindow && g.NavWindow != g.NavWindow->RootWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_Popup) && g.NavWindow->ParentWindow) - { - // Exit child window - ImGuiWindow* child_window = g.NavWindow; - ImGuiWindow* parent_window = g.NavWindow->ParentWindow; - IM_ASSERT(child_window->ChildId != 0); - ImRect child_rect = child_window->Rect(); - FocusWindow(parent_window); - SetNavID(child_window->ChildId, ImGuiNavLayer_Main, 0, ImRect(child_rect.Min - parent_window->Pos, child_rect.Max - parent_window->Pos)); - } - else if (g.OpenPopupStack.Size > 0) - { - // Close open popup/menu - if (!(g.OpenPopupStack.back().Window->Flags & ImGuiWindowFlags_Modal)) - ClosePopupToLevel(g.OpenPopupStack.Size - 1, true); - } - else - { - // Clear NavLastId for popups but keep it for regular child window so we can leave one and come back where we were - if (g.NavWindow && ((g.NavWindow->Flags & ImGuiWindowFlags_Popup) || !(g.NavWindow->Flags & ImGuiWindowFlags_ChildWindow))) - g.NavWindow->NavLastIds[0] = 0; - g.NavId = g.NavFocusScopeId = 0; - } -} - -// Handle PageUp/PageDown/Home/End keys -// Called from NavUpdateCreateMoveRequest() which will use our output to create a move request -// FIXME-NAV: This doesn't work properly with NavFlattened siblings as we use NavWindow rectangle for reference -// FIXME-NAV: how to get Home/End to aim at the beginning/end of a 2D grid? -static float ImGui::NavUpdatePageUpPageDown() -{ - ImGuiContext& g = *GImGui; - ImGuiIO& io = g.IO; - - ImGuiWindow* window = g.NavWindow; - if ((window->Flags & ImGuiWindowFlags_NoNavInputs) || g.NavWindowingTarget != NULL || g.NavLayer != ImGuiNavLayer_Main) - return 0.0f; - - const bool page_up_held = IsKeyDown(io.KeyMap[ImGuiKey_PageUp]) && !IsActiveIdUsingKey(ImGuiKey_PageUp); - const bool page_down_held = IsKeyDown(io.KeyMap[ImGuiKey_PageDown]) && !IsActiveIdUsingKey(ImGuiKey_PageDown); - const bool home_pressed = IsKeyPressed(io.KeyMap[ImGuiKey_Home]) && !IsActiveIdUsingKey(ImGuiKey_Home); - const bool end_pressed = IsKeyPressed(io.KeyMap[ImGuiKey_End]) && !IsActiveIdUsingKey(ImGuiKey_End); - if (page_up_held == page_down_held && home_pressed == end_pressed) // Proceed if either (not both) are pressed, otherwise early out - return 0.0f; - - if (window->DC.NavLayersActiveMask == 0x00 && window->DC.NavHasScroll) - { - // Fallback manual-scroll when window has no navigable item - if (IsKeyPressed(io.KeyMap[ImGuiKey_PageUp], true)) - SetScrollY(window, window->Scroll.y - window->InnerRect.GetHeight()); - else if (IsKeyPressed(io.KeyMap[ImGuiKey_PageDown], true)) - SetScrollY(window, window->Scroll.y + window->InnerRect.GetHeight()); - else if (home_pressed) - SetScrollY(window, 0.0f); - else if (end_pressed) - SetScrollY(window, window->ScrollMax.y); - } - else - { - ImRect& nav_rect_rel = window->NavRectRel[g.NavLayer]; - const float page_offset_y = ImMax(0.0f, window->InnerRect.GetHeight() - window->CalcFontSize() * 1.0f + nav_rect_rel.GetHeight()); - float nav_scoring_rect_offset_y = 0.0f; - if (IsKeyPressed(io.KeyMap[ImGuiKey_PageUp], true)) - { - nav_scoring_rect_offset_y = -page_offset_y; - g.NavMoveDir = ImGuiDir_Down; // Because our scoring rect is offset up, we request the down direction (so we can always land on the last item) - g.NavMoveClipDir = ImGuiDir_Up; - g.NavMoveFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet; - } - else if (IsKeyPressed(io.KeyMap[ImGuiKey_PageDown], true)) - { - nav_scoring_rect_offset_y = +page_offset_y; - g.NavMoveDir = ImGuiDir_Up; // Because our scoring rect is offset down, we request the up direction (so we can always land on the last item) - g.NavMoveClipDir = ImGuiDir_Down; - g.NavMoveFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet; - } - else if (home_pressed) - { - // FIXME-NAV: handling of Home/End is assuming that the top/bottom most item will be visible with Scroll.y == 0/ScrollMax.y - // Scrolling will be handled via the ImGuiNavMoveFlags_ScrollToEdgeY flag, we don't scroll immediately to avoid scrolling happening before nav result. - // Preserve current horizontal position if we have any. - nav_rect_rel.Min.y = nav_rect_rel.Max.y = -window->Scroll.y; - if (nav_rect_rel.IsInverted()) - nav_rect_rel.Min.x = nav_rect_rel.Max.x = 0.0f; - g.NavMoveDir = ImGuiDir_Down; - g.NavMoveFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_ScrollToEdgeY; - // FIXME-NAV: MoveClipDir left to _None, intentional? - } - else if (end_pressed) - { - nav_rect_rel.Min.y = nav_rect_rel.Max.y = window->ScrollMax.y + window->SizeFull.y - window->Scroll.y; - if (nav_rect_rel.IsInverted()) - nav_rect_rel.Min.x = nav_rect_rel.Max.x = 0.0f; - g.NavMoveDir = ImGuiDir_Up; - g.NavMoveFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_ScrollToEdgeY; - // FIXME-NAV: MoveClipDir left to _None, intentional? - } - return nav_scoring_rect_offset_y; - } - return 0.0f; -} - -static void ImGui::NavEndFrame() -{ - ImGuiContext& g = *GImGui; - - // Show CTRL+TAB list window - if (g.NavWindowingTarget != NULL) - NavUpdateWindowingOverlay(); - - // Perform wrap-around in menus - // FIXME-NAV: Wrap (not Loop) support could be handled by the scoring function and then WrapX would function without an extra frame. - ImGuiWindow* window = g.NavWindow; - const ImGuiNavMoveFlags move_flags = g.NavMoveFlags; - const ImGuiNavMoveFlags wanted_flags = ImGuiNavMoveFlags_WrapX | ImGuiNavMoveFlags_LoopX | ImGuiNavMoveFlags_WrapY | ImGuiNavMoveFlags_LoopY; - if (window && NavMoveRequestButNoResultYet() && (g.NavMoveFlags & wanted_flags) && (g.NavMoveFlags & ImGuiNavMoveFlags_Forwarded) == 0) - { - bool do_forward = false; - ImRect bb_rel = window->NavRectRel[g.NavLayer]; - ImGuiDir clip_dir = g.NavMoveDir; - if (g.NavMoveDir == ImGuiDir_Left && (move_flags & (ImGuiNavMoveFlags_WrapX | ImGuiNavMoveFlags_LoopX))) - { - bb_rel.Min.x = bb_rel.Max.x = - ImMax(window->SizeFull.x, window->ContentSize.x + window->WindowPadding.x * 2.0f) - window->Scroll.x; - if (move_flags & ImGuiNavMoveFlags_WrapX) - { - bb_rel.TranslateY(-bb_rel.GetHeight()); - clip_dir = ImGuiDir_Up; - } - do_forward = true; - } - if (g.NavMoveDir == ImGuiDir_Right && (move_flags & (ImGuiNavMoveFlags_WrapX | ImGuiNavMoveFlags_LoopX))) - { - bb_rel.Min.x = bb_rel.Max.x = -window->Scroll.x; - if (move_flags & ImGuiNavMoveFlags_WrapX) - { - bb_rel.TranslateY(+bb_rel.GetHeight()); - clip_dir = ImGuiDir_Down; - } - do_forward = true; - } - const float decoration_up_height = window->TitleBarHeight() + window->MenuBarHeight(); - if (g.NavMoveDir == ImGuiDir_Up && (move_flags & (ImGuiNavMoveFlags_WrapY | ImGuiNavMoveFlags_LoopY))) - { - bb_rel.Min.y = bb_rel.Max.y = - ImMax(window->SizeFull.y, window->ContentSize.y + window->WindowPadding.y * 2.0f) - window->Scroll.y + decoration_up_height; - if (move_flags & ImGuiNavMoveFlags_WrapY) - { - bb_rel.TranslateX(-bb_rel.GetWidth()); - clip_dir = ImGuiDir_Left; - } - do_forward = true; - } - if (g.NavMoveDir == ImGuiDir_Down && (move_flags & (ImGuiNavMoveFlags_WrapY | ImGuiNavMoveFlags_LoopY))) - { - bb_rel.Min.y = bb_rel.Max.y = -window->Scroll.y + decoration_up_height; - if (move_flags & ImGuiNavMoveFlags_WrapY) - { - bb_rel.TranslateX(+bb_rel.GetWidth()); - clip_dir = ImGuiDir_Right; - } - do_forward = true; - } - if (do_forward) - { - window->NavRectRel[g.NavLayer] = bb_rel; - NavMoveRequestForward(g.NavMoveDir, clip_dir, move_flags, g.NavMoveScrollFlags); - } - } -} - -static int ImGui::FindWindowFocusIndex(ImGuiWindow* window) -{ - ImGuiContext& g = *GImGui; - IM_UNUSED(g); - int order = window->FocusOrder; - IM_ASSERT(window->RootWindow == window); // No child window (not testing _ChildWindow because of docking) - IM_ASSERT(g.WindowsFocusOrder[order] == window); - return order; -} - -static ImGuiWindow* FindWindowNavFocusable(int i_start, int i_stop, int dir) // FIXME-OPT O(N) -{ - ImGuiContext& g = *GImGui; - for (int i = i_start; i >= 0 && i < g.WindowsFocusOrder.Size && i != i_stop; i += dir) - if (ImGui::IsWindowNavFocusable(g.WindowsFocusOrder[i])) - return g.WindowsFocusOrder[i]; - return NULL; -} - -static void NavUpdateWindowingHighlightWindow(int focus_change_dir) -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(g.NavWindowingTarget); - if (g.NavWindowingTarget->Flags & ImGuiWindowFlags_Modal) - return; - - const int i_current = ImGui::FindWindowFocusIndex(g.NavWindowingTarget); - ImGuiWindow* window_target = FindWindowNavFocusable(i_current + focus_change_dir, -INT_MAX, focus_change_dir); - if (!window_target) - window_target = FindWindowNavFocusable((focus_change_dir < 0) ? (g.WindowsFocusOrder.Size - 1) : 0, i_current, focus_change_dir); - if (window_target) // Don't reset windowing target if there's a single window in the list - g.NavWindowingTarget = g.NavWindowingTargetAnim = window_target; - g.NavWindowingToggleLayer = false; -} - -// Windowing management mode -// Keyboard: CTRL+Tab (change focus/move/resize), Alt (toggle menu layer) -// Gamepad: Hold Menu/Square (change focus/move/resize), Tap Menu/Square (toggle menu layer) -static void ImGui::NavUpdateWindowing() -{ - ImGuiContext& g = *GImGui; - ImGuiIO& io = g.IO; - - ImGuiWindow* apply_focus_window = NULL; - bool apply_toggle_layer = false; - - ImGuiWindow* modal_window = GetTopMostPopupModal(); - bool allow_windowing = (modal_window == NULL); - if (!allow_windowing) - g.NavWindowingTarget = NULL; - - // Fade out - if (g.NavWindowingTargetAnim && g.NavWindowingTarget == NULL) - { - g.NavWindowingHighlightAlpha = ImMax(g.NavWindowingHighlightAlpha - io.DeltaTime * 10.0f, 0.0f); - if (g.DimBgRatio <= 0.0f && g.NavWindowingHighlightAlpha <= 0.0f) - g.NavWindowingTargetAnim = NULL; - } - - // Start CTRL-TAB or Square+L/R window selection - const bool nav_keyboard_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0; - const bool start_windowing_with_gamepad = allow_windowing && !g.NavWindowingTarget && IsNavInputTest(ImGuiNavInput_Menu, ImGuiInputReadMode_Pressed); - const bool start_windowing_with_keyboard = allow_windowing && !g.NavWindowingTarget && nav_keyboard_active && io.KeyCtrl && IsKeyPressedMap(ImGuiKey_Tab); - if (start_windowing_with_gamepad || start_windowing_with_keyboard) - if (ImGuiWindow* window = g.NavWindow ? g.NavWindow : FindWindowNavFocusable(g.WindowsFocusOrder.Size - 1, -INT_MAX, -1)) - { - g.NavWindowingTarget = g.NavWindowingTargetAnim = window->RootWindow; - g.NavWindowingTimer = g.NavWindowingHighlightAlpha = 0.0f; - g.NavWindowingToggleLayer = start_windowing_with_gamepad ? true : false; // Gamepad starts toggling layer - g.NavInputSource = start_windowing_with_keyboard ? ImGuiInputSource_Keyboard : ImGuiInputSource_Gamepad; - } - - // Gamepad update - g.NavWindowingTimer += io.DeltaTime; - if (g.NavWindowingTarget && g.NavInputSource == ImGuiInputSource_Gamepad) - { - // Highlight only appears after a brief time holding the button, so that a fast tap on PadMenu (to toggle NavLayer) doesn't add visual noise - g.NavWindowingHighlightAlpha = ImMax(g.NavWindowingHighlightAlpha, ImSaturate((g.NavWindowingTimer - NAV_WINDOWING_HIGHLIGHT_DELAY) / 0.05f)); - - // Select window to focus - const int focus_change_dir = (int)IsNavInputTest(ImGuiNavInput_FocusPrev, ImGuiInputReadMode_RepeatSlow) - (int)IsNavInputTest(ImGuiNavInput_FocusNext, ImGuiInputReadMode_RepeatSlow); - if (focus_change_dir != 0) - { - NavUpdateWindowingHighlightWindow(focus_change_dir); - g.NavWindowingHighlightAlpha = 1.0f; - } - - // Single press toggles NavLayer, long press with L/R apply actual focus on release (until then the window was merely rendered top-most) - if (!IsNavInputDown(ImGuiNavInput_Menu)) - { - g.NavWindowingToggleLayer &= (g.NavWindowingHighlightAlpha < 1.0f); // Once button was held long enough we don't consider it a tap-to-toggle-layer press anymore. - if (g.NavWindowingToggleLayer && g.NavWindow) - apply_toggle_layer = true; - else if (!g.NavWindowingToggleLayer) - apply_focus_window = g.NavWindowingTarget; - g.NavWindowingTarget = NULL; - } - } - - // Keyboard: Focus - if (g.NavWindowingTarget && g.NavInputSource == ImGuiInputSource_Keyboard) - { - // Visuals only appears after a brief time after pressing TAB the first time, so that a fast CTRL+TAB doesn't add visual noise - g.NavWindowingHighlightAlpha = ImMax(g.NavWindowingHighlightAlpha, ImSaturate((g.NavWindowingTimer - NAV_WINDOWING_HIGHLIGHT_DELAY) / 0.05f)); // 1.0f - if (IsKeyPressedMap(ImGuiKey_Tab, true)) - NavUpdateWindowingHighlightWindow(io.KeyShift ? +1 : -1); - if (!io.KeyCtrl) - apply_focus_window = g.NavWindowingTarget; - } - - // Keyboard: Press and Release ALT to toggle menu layer - // - Testing that only Alt is tested prevents Alt+Shift or AltGR from toggling menu layer. - // - AltGR is normally Alt+Ctrl but we can't reliably detect it (not all backends/systems/layout emit it as Alt+Ctrl). But even on keyboards without AltGR we don't want Alt+Ctrl to open menu anyway. - if (nav_keyboard_active && io.KeyMods == ImGuiKeyModFlags_Alt && (io.KeyModsPrev & ImGuiKeyModFlags_Alt) == 0) - { - g.NavWindowingToggleLayer = true; - g.NavInputSource = ImGuiInputSource_Keyboard; - } - if (g.NavWindowingToggleLayer && g.NavInputSource == ImGuiInputSource_Keyboard) - { - // We cancel toggling nav layer when any text has been typed (generally while holding Alt). (See #370) - // We cancel toggling nav layer when other modifiers are pressed. (See #4439) - if (io.InputQueueCharacters.Size > 0 || io.KeyCtrl || io.KeyShift || io.KeySuper) - g.NavWindowingToggleLayer = false; - - // Apply layer toggle on release - // Important: we don't assume that Alt was previously held in order to handle loss of focus when backend calls io.AddFocusEvent(false) - // Important: as before version <18314 we lacked an explicit IO event for focus gain/loss, we also compare mouse validity to detect old backends clearing mouse pos on focus loss. - if (!(io.KeyMods & ImGuiKeyModFlags_Alt) && (io.KeyModsPrev & ImGuiKeyModFlags_Alt) && g.NavWindowingToggleLayer) - if (g.ActiveId == 0 || g.ActiveIdAllowOverlap) - if (IsMousePosValid(&io.MousePos) == IsMousePosValid(&io.MousePosPrev)) - apply_toggle_layer = true; - if (!io.KeyAlt) - g.NavWindowingToggleLayer = false; - } - - // Move window - if (g.NavWindowingTarget && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_NoMove)) - { - ImVec2 move_delta; - if (g.NavInputSource == ImGuiInputSource_Keyboard && !io.KeyShift) - move_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard, ImGuiInputReadMode_Down); - if (g.NavInputSource == ImGuiInputSource_Gamepad) - move_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadLStick, ImGuiInputReadMode_Down); - if (move_delta.x != 0.0f || move_delta.y != 0.0f) - { - const float NAV_MOVE_SPEED = 800.0f; - const float move_speed = ImFloor(NAV_MOVE_SPEED * io.DeltaTime * ImMin(io.DisplayFramebufferScale.x, io.DisplayFramebufferScale.y)); // FIXME: Doesn't handle variable framerate very well - ImGuiWindow* moving_window = g.NavWindowingTarget->RootWindow; - SetWindowPos(moving_window, moving_window->Pos + move_delta * move_speed, ImGuiCond_Always); - MarkIniSettingsDirty(moving_window); - g.NavDisableMouseHover = true; - } - } - - // Apply final focus - if (apply_focus_window && (g.NavWindow == NULL || apply_focus_window != g.NavWindow->RootWindow)) - { - ClearActiveID(); - g.NavDisableHighlight = false; - g.NavDisableMouseHover = true; - apply_focus_window = NavRestoreLastChildNavWindow(apply_focus_window); - ClosePopupsOverWindow(apply_focus_window, false); - FocusWindow(apply_focus_window); - if (apply_focus_window->NavLastIds[0] == 0) - NavInitWindow(apply_focus_window, false); - - // If the window has ONLY a menu layer (no main layer), select it directly - // Use NavLayersActiveMaskNext since windows didn't have a chance to be Begin()-ed on this frame, - // so CTRL+Tab where the keys are only held for 1 frame will be able to use correct layers mask since - // the target window as already been previewed once. - // FIXME-NAV: This should be done in NavInit.. or in FocusWindow... However in both of those cases, - // we won't have a guarantee that windows has been visible before and therefore NavLayersActiveMask* - // won't be valid. - if (apply_focus_window->DC.NavLayersActiveMaskNext == (1 << ImGuiNavLayer_Menu)) - g.NavLayer = ImGuiNavLayer_Menu; - } - if (apply_focus_window) - g.NavWindowingTarget = NULL; - - // Apply menu/layer toggle - if (apply_toggle_layer && g.NavWindow) - { - ClearActiveID(); - - // Move to parent menu if necessary - ImGuiWindow* new_nav_window = g.NavWindow; - while (new_nav_window->ParentWindow - && (new_nav_window->DC.NavLayersActiveMask & (1 << ImGuiNavLayer_Menu)) == 0 - && (new_nav_window->Flags & ImGuiWindowFlags_ChildWindow) != 0 - && (new_nav_window->Flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_ChildMenu)) == 0) - new_nav_window = new_nav_window->ParentWindow; - if (new_nav_window != g.NavWindow) - { - ImGuiWindow* old_nav_window = g.NavWindow; - FocusWindow(new_nav_window); - new_nav_window->NavLastChildNavWindow = old_nav_window; - } - - // Toggle layer - const ImGuiNavLayer new_nav_layer = (g.NavWindow->DC.NavLayersActiveMask & (1 << ImGuiNavLayer_Menu)) ? (ImGuiNavLayer)((int)g.NavLayer ^ 1) : ImGuiNavLayer_Main; - if (new_nav_layer != g.NavLayer) - { - // Reinitialize navigation when entering menu bar with the Alt key (FIXME: could be a properly of the layer?) - if (new_nav_layer == ImGuiNavLayer_Menu) - g.NavWindow->NavLastIds[new_nav_layer] = 0; - NavRestoreLayer(new_nav_layer); - } - } -} - -// Window has already passed the IsWindowNavFocusable() -static const char* GetFallbackWindowNameForWindowingList(ImGuiWindow* window) -{ - if (window->Flags & ImGuiWindowFlags_Popup) - return "(Popup)"; - if ((window->Flags & ImGuiWindowFlags_MenuBar) && strcmp(window->Name, "##MainMenuBar") == 0) - return "(Main menu bar)"; - return "(Untitled)"; -} - -// Overlay displayed when using CTRL+TAB. Called by EndFrame(). -void ImGui::NavUpdateWindowingOverlay() -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(g.NavWindowingTarget != NULL); - - if (g.NavWindowingTimer < NAV_WINDOWING_LIST_APPEAR_DELAY) - return; - - if (g.NavWindowingListWindow == NULL) - g.NavWindowingListWindow = FindWindowByName("###NavWindowingList"); - const ImGuiViewport* viewport = GetMainViewport(); - SetNextWindowSizeConstraints(ImVec2(viewport->Size.x * 0.20f, viewport->Size.y * 0.20f), ImVec2(FLT_MAX, FLT_MAX)); - SetNextWindowPos(viewport->GetCenter(), ImGuiCond_Always, ImVec2(0.5f, 0.5f)); - PushStyleVar(ImGuiStyleVar_WindowPadding, g.Style.WindowPadding * 2.0f); - Begin("###NavWindowingList", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings); - for (int n = g.WindowsFocusOrder.Size - 1; n >= 0; n--) - { - ImGuiWindow* window = g.WindowsFocusOrder[n]; - IM_ASSERT(window != NULL); // Fix static analyzers - if (!IsWindowNavFocusable(window)) - continue; - const char* label = window->Name; - if (label == FindRenderedTextEnd(label)) - label = GetFallbackWindowNameForWindowingList(window); - Selectable(label, g.NavWindowingTarget == window); - } - End(); - PopStyleVar(); -} - - -//----------------------------------------------------------------------------- -// [SECTION] DRAG AND DROP -//----------------------------------------------------------------------------- - -void ImGui::ClearDragDrop() -{ - ImGuiContext& g = *GImGui; - g.DragDropActive = false; - g.DragDropPayload.Clear(); - g.DragDropAcceptFlags = ImGuiDragDropFlags_None; - g.DragDropAcceptIdCurr = g.DragDropAcceptIdPrev = 0; - g.DragDropAcceptIdCurrRectSurface = FLT_MAX; - g.DragDropAcceptFrameCount = -1; - - g.DragDropPayloadBufHeap.clear(); - memset(&g.DragDropPayloadBufLocal, 0, sizeof(g.DragDropPayloadBufLocal)); -} - -// When this returns true you need to: a) call SetDragDropPayload() exactly once, b) you may render the payload visual/description, c) call EndDragDropSource() -// If the item has an identifier: -// - This assume/require the item to be activated (typically via ButtonBehavior). -// - Therefore if you want to use this with a mouse button other than left mouse button, it is up to the item itself to activate with another button. -// - We then pull and use the mouse button that was used to activate the item and use it to carry on the drag. -// If the item has no identifier: -// - Currently always assume left mouse button. -bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - - // FIXME-DRAGDROP: While in the common-most "drag from non-zero active id" case we can tell the mouse button, - // in both SourceExtern and id==0 cases we may requires something else (explicit flags or some heuristic). - ImGuiMouseButton mouse_button = ImGuiMouseButton_Left; - - bool source_drag_active = false; - ImGuiID source_id = 0; - ImGuiID source_parent_id = 0; - if (!(flags & ImGuiDragDropFlags_SourceExtern)) - { - source_id = g.LastItemData.ID; - if (source_id != 0) - { - // Common path: items with ID - if (g.ActiveId != source_id) - return false; - if (g.ActiveIdMouseButton != -1) - mouse_button = g.ActiveIdMouseButton; - if (g.IO.MouseDown[mouse_button] == false || window->SkipItems) - return false; - g.ActiveIdAllowOverlap = false; - } - else - { - // Uncommon path: items without ID - if (g.IO.MouseDown[mouse_button] == false || window->SkipItems) - return false; - if ((g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HoveredRect) == 0 && (g.ActiveId == 0 || g.ActiveIdWindow != window)) - return false; - - // If you want to use BeginDragDropSource() on an item with no unique identifier for interaction, such as Text() or Image(), you need to: - // A) Read the explanation below, B) Use the ImGuiDragDropFlags_SourceAllowNullID flag, C) Swallow your programmer pride. - if (!(flags & ImGuiDragDropFlags_SourceAllowNullID)) - { - IM_ASSERT(0); - return false; - } - - // Magic fallback (=somehow reprehensible) to handle items with no assigned ID, e.g. Text(), Image() - // We build a throwaway ID based on current ID stack + relative AABB of items in window. - // THE IDENTIFIER WON'T SURVIVE ANY REPOSITIONING OF THE WIDGET, so if your widget moves your dragging operation will be canceled. - // We don't need to maintain/call ClearActiveID() as releasing the button will early out this function and trigger !ActiveIdIsAlive. - // Rely on keeping other window->LastItemXXX fields intact. - source_id = g.LastItemData.ID = window->GetIDFromRectangle(g.LastItemData.Rect); - bool is_hovered = ItemHoverable(g.LastItemData.Rect, source_id); - if (is_hovered && g.IO.MouseClicked[mouse_button]) - { - SetActiveID(source_id, window); - FocusWindow(window); - } - if (g.ActiveId == source_id) // Allow the underlying widget to display/return hovered during the mouse release frame, else we would get a flicker. - g.ActiveIdAllowOverlap = is_hovered; - } - if (g.ActiveId != source_id) - return false; - source_parent_id = window->IDStack.back(); - source_drag_active = IsMouseDragging(mouse_button); - - // Disable navigation and key inputs while dragging + cancel existing request if any - SetActiveIdUsingNavAndKeys(); - } - else - { - window = NULL; - source_id = ImHashStr("#SourceExtern"); - source_drag_active = true; - } - - if (source_drag_active) - { - if (!g.DragDropActive) - { - IM_ASSERT(source_id != 0); - ClearDragDrop(); - ImGuiPayload& payload = g.DragDropPayload; - payload.SourceId = source_id; - payload.SourceParentId = source_parent_id; - g.DragDropActive = true; - g.DragDropSourceFlags = flags; - g.DragDropMouseButton = mouse_button; - if (payload.SourceId == g.ActiveId) - g.ActiveIdNoClearOnFocusLoss = true; - } - g.DragDropSourceFrameCount = g.FrameCount; - g.DragDropWithinSource = true; - - if (!(flags & ImGuiDragDropFlags_SourceNoPreviewTooltip)) - { - // Target can request the Source to not display its tooltip (we use a dedicated flag to make this request explicit) - // We unfortunately can't just modify the source flags and skip the call to BeginTooltip, as caller may be emitting contents. - BeginTooltip(); - if (g.DragDropAcceptIdPrev && (g.DragDropAcceptFlags & ImGuiDragDropFlags_AcceptNoPreviewTooltip)) - { - ImGuiWindow* tooltip_window = g.CurrentWindow; - tooltip_window->Hidden = tooltip_window->SkipItems = true; - tooltip_window->HiddenFramesCanSkipItems = 1; - } - } - - if (!(flags & ImGuiDragDropFlags_SourceNoDisableHover) && !(flags & ImGuiDragDropFlags_SourceExtern)) - g.LastItemData.StatusFlags &= ~ImGuiItemStatusFlags_HoveredRect; - - return true; - } - return false; -} - -void ImGui::EndDragDropSource() -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(g.DragDropActive); - IM_ASSERT(g.DragDropWithinSource && "Not after a BeginDragDropSource()?"); - - if (!(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoPreviewTooltip)) - EndTooltip(); - - // Discard the drag if have not called SetDragDropPayload() - if (g.DragDropPayload.DataFrameCount == -1) - ClearDragDrop(); - g.DragDropWithinSource = false; -} - -// Use 'cond' to choose to submit payload on drag start or every frame -bool ImGui::SetDragDropPayload(const char* type, const void* data, size_t data_size, ImGuiCond cond) -{ - ImGuiContext& g = *GImGui; - ImGuiPayload& payload = g.DragDropPayload; - if (cond == 0) - cond = ImGuiCond_Always; - - IM_ASSERT(type != NULL); - IM_ASSERT(strlen(type) < IM_ARRAYSIZE(payload.DataType) && "Payload type can be at most 32 characters long"); - IM_ASSERT((data != NULL && data_size > 0) || (data == NULL && data_size == 0)); - IM_ASSERT(cond == ImGuiCond_Always || cond == ImGuiCond_Once); - IM_ASSERT(payload.SourceId != 0); // Not called between BeginDragDropSource() and EndDragDropSource() - - if (cond == ImGuiCond_Always || payload.DataFrameCount == -1) - { - // Copy payload - ImStrncpy(payload.DataType, type, IM_ARRAYSIZE(payload.DataType)); - g.DragDropPayloadBufHeap.resize(0); - if (data_size > sizeof(g.DragDropPayloadBufLocal)) - { - // Store in heap - g.DragDropPayloadBufHeap.resize((int)data_size); - payload.Data = g.DragDropPayloadBufHeap.Data; - memcpy(payload.Data, data, data_size); - } - else if (data_size > 0) - { - // Store locally - memset(&g.DragDropPayloadBufLocal, 0, sizeof(g.DragDropPayloadBufLocal)); - payload.Data = g.DragDropPayloadBufLocal; - memcpy(payload.Data, data, data_size); - } - else - { - payload.Data = NULL; - } - payload.DataSize = (int)data_size; - } - payload.DataFrameCount = g.FrameCount; - - return (g.DragDropAcceptFrameCount == g.FrameCount) || (g.DragDropAcceptFrameCount == g.FrameCount - 1); -} - -bool ImGui::BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id) -{ - ImGuiContext& g = *GImGui; - if (!g.DragDropActive) - return false; - - ImGuiWindow* window = g.CurrentWindow; - ImGuiWindow* hovered_window = g.HoveredWindowUnderMovingWindow; - if (hovered_window == NULL || window->RootWindow != hovered_window->RootWindow) - return false; - IM_ASSERT(id != 0); - if (!IsMouseHoveringRect(bb.Min, bb.Max) || (id == g.DragDropPayload.SourceId)) - return false; - if (window->SkipItems) - return false; - - IM_ASSERT(g.DragDropWithinTarget == false); - g.DragDropTargetRect = bb; - g.DragDropTargetId = id; - g.DragDropWithinTarget = true; - return true; -} - -// We don't use BeginDragDropTargetCustom() and duplicate its code because: -// 1) we use LastItemRectHoveredRect which handles items that pushes a temporarily clip rectangle in their code. Calling BeginDragDropTargetCustom(LastItemRect) would not handle them. -// 2) and it's faster. as this code may be very frequently called, we want to early out as fast as we can. -// Also note how the HoveredWindow test is positioned differently in both functions (in both functions we optimize for the cheapest early out case) -bool ImGui::BeginDragDropTarget() -{ - ImGuiContext& g = *GImGui; - if (!g.DragDropActive) - return false; - - ImGuiWindow* window = g.CurrentWindow; - if (!(g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HoveredRect)) - return false; - ImGuiWindow* hovered_window = g.HoveredWindowUnderMovingWindow; - if (hovered_window == NULL || window->RootWindow != hovered_window->RootWindow || window->SkipItems) - return false; - - const ImRect& display_rect = (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HasDisplayRect) ? g.LastItemData.DisplayRect : g.LastItemData.Rect; - ImGuiID id = g.LastItemData.ID; - if (id == 0) - id = window->GetIDFromRectangle(display_rect); - if (g.DragDropPayload.SourceId == id) - return false; - - IM_ASSERT(g.DragDropWithinTarget == false); - g.DragDropTargetRect = display_rect; - g.DragDropTargetId = id; - g.DragDropWithinTarget = true; - return true; -} - -bool ImGui::IsDragDropPayloadBeingAccepted() -{ - ImGuiContext& g = *GImGui; - return g.DragDropActive && g.DragDropAcceptIdPrev != 0; -} - -const ImGuiPayload* ImGui::AcceptDragDropPayload(const char* type, ImGuiDragDropFlags flags) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - ImGuiPayload& payload = g.DragDropPayload; - IM_ASSERT(g.DragDropActive); // Not called between BeginDragDropTarget() and EndDragDropTarget() ? - IM_ASSERT(payload.DataFrameCount != -1); // Forgot to call EndDragDropTarget() ? - if (type != NULL && !payload.IsDataType(type)) - return NULL; - - // Accept smallest drag target bounding box, this allows us to nest drag targets conveniently without ordering constraints. - // NB: We currently accept NULL id as target. However, overlapping targets requires a unique ID to function! - const bool was_accepted_previously = (g.DragDropAcceptIdPrev == g.DragDropTargetId); - ImRect r = g.DragDropTargetRect; - float r_surface = r.GetWidth() * r.GetHeight(); - if (r_surface <= g.DragDropAcceptIdCurrRectSurface) - { - g.DragDropAcceptFlags = flags; - g.DragDropAcceptIdCurr = g.DragDropTargetId; - g.DragDropAcceptIdCurrRectSurface = r_surface; - } - - // Render default drop visuals - // FIXME-DRAGDROP: Settle on a proper default visuals for drop target. - payload.Preview = was_accepted_previously; - flags |= (g.DragDropSourceFlags & ImGuiDragDropFlags_AcceptNoDrawDefaultRect); // Source can also inhibit the preview (useful for external sources that lives for 1 frame) - if (!(flags & ImGuiDragDropFlags_AcceptNoDrawDefaultRect) && payload.Preview) - window->DrawList->AddRect(r.Min - ImVec2(3.5f,3.5f), r.Max + ImVec2(3.5f, 3.5f), GetColorU32(ImGuiCol_DragDropTarget), 0.0f, 0, 2.0f); - - g.DragDropAcceptFrameCount = g.FrameCount; - payload.Delivery = was_accepted_previously && !IsMouseDown(g.DragDropMouseButton); // For extern drag sources affecting os window focus, it's easier to just test !IsMouseDown() instead of IsMouseReleased() - if (!payload.Delivery && !(flags & ImGuiDragDropFlags_AcceptBeforeDelivery)) - return NULL; - - return &payload; -} - -const ImGuiPayload* ImGui::GetDragDropPayload() -{ - ImGuiContext& g = *GImGui; - return g.DragDropActive ? &g.DragDropPayload : NULL; -} - -// We don't really use/need this now, but added it for the sake of consistency and because we might need it later. -void ImGui::EndDragDropTarget() -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(g.DragDropActive); - IM_ASSERT(g.DragDropWithinTarget); - g.DragDropWithinTarget = false; -} - -//----------------------------------------------------------------------------- -// [SECTION] LOGGING/CAPTURING -//----------------------------------------------------------------------------- -// All text output from the interface can be captured into tty/file/clipboard. -// By default, tree nodes are automatically opened during logging. -//----------------------------------------------------------------------------- - -// Pass text data straight to log (without being displayed) -static inline void LogTextV(ImGuiContext& g, const char* fmt, va_list args) -{ - if (g.LogFile) - { - g.LogBuffer.Buf.resize(0); - g.LogBuffer.appendfv(fmt, args); - ImFileWrite(g.LogBuffer.c_str(), sizeof(char), (ImU64)g.LogBuffer.size(), g.LogFile); - } - else - { - g.LogBuffer.appendfv(fmt, args); - } -} - -void ImGui::LogText(const char* fmt, ...) -{ - ImGuiContext& g = *GImGui; - if (!g.LogEnabled) - return; - - va_list args; - va_start(args, fmt); - LogTextV(g, fmt, args); - va_end(args); -} - -void ImGui::LogTextV(const char* fmt, va_list args) -{ - ImGuiContext& g = *GImGui; - if (!g.LogEnabled) - return; - - LogTextV(g, fmt, args); -} - -// Internal version that takes a position to decide on newline placement and pad items according to their depth. -// We split text into individual lines to add current tree level padding -// FIXME: This code is a little complicated perhaps, considering simplifying the whole system. -void ImGui::LogRenderedText(const ImVec2* ref_pos, const char* text, const char* text_end) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - - const char* prefix = g.LogNextPrefix; - const char* suffix = g.LogNextSuffix; - g.LogNextPrefix = g.LogNextSuffix = NULL; - - if (!text_end) - text_end = FindRenderedTextEnd(text, text_end); - - const bool log_new_line = ref_pos && (ref_pos->y > g.LogLinePosY + g.Style.FramePadding.y + 1); - if (ref_pos) - g.LogLinePosY = ref_pos->y; - if (log_new_line) - { - LogText(IM_NEWLINE); - g.LogLineFirstItem = true; - } - - if (prefix) - LogRenderedText(ref_pos, prefix, prefix + strlen(prefix)); // Calculate end ourself to ensure "##" are included here. - - // Re-adjust padding if we have popped out of our starting depth - if (g.LogDepthRef > window->DC.TreeDepth) - g.LogDepthRef = window->DC.TreeDepth; - const int tree_depth = (window->DC.TreeDepth - g.LogDepthRef); - - const char* text_remaining = text; - for (;;) - { - // Split the string. Each new line (after a '\n') is followed by indentation corresponding to the current depth of our log entry. - // We don't add a trailing \n yet to allow a subsequent item on the same line to be captured. - const char* line_start = text_remaining; - const char* line_end = ImStreolRange(line_start, text_end); - const bool is_last_line = (line_end == text_end); - if (line_start != line_end || !is_last_line) - { - const int line_length = (int)(line_end - line_start); - const int indentation = g.LogLineFirstItem ? tree_depth * 4 : 1; - LogText("%*s%.*s", indentation, "", line_length, line_start); - g.LogLineFirstItem = false; - if (*line_end == '\n') - { - LogText(IM_NEWLINE); - g.LogLineFirstItem = true; - } - } - if (is_last_line) - break; - text_remaining = line_end + 1; - } - - if (suffix) - LogRenderedText(ref_pos, suffix, suffix + strlen(suffix)); -} - -// Start logging/capturing text output -void ImGui::LogBegin(ImGuiLogType type, int auto_open_depth) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - IM_ASSERT(g.LogEnabled == false); - IM_ASSERT(g.LogFile == NULL); - IM_ASSERT(g.LogBuffer.empty()); - g.LogEnabled = true; - g.LogType = type; - g.LogNextPrefix = g.LogNextSuffix = NULL; - g.LogDepthRef = window->DC.TreeDepth; - g.LogDepthToExpand = ((auto_open_depth >= 0) ? auto_open_depth : g.LogDepthToExpandDefault); - g.LogLinePosY = FLT_MAX; - g.LogLineFirstItem = true; -} - -// Important: doesn't copy underlying data, use carefully (prefix/suffix must be in scope at the time of the next LogRenderedText) -void ImGui::LogSetNextTextDecoration(const char* prefix, const char* suffix) -{ - ImGuiContext& g = *GImGui; - g.LogNextPrefix = prefix; - g.LogNextSuffix = suffix; -} - -void ImGui::LogToTTY(int auto_open_depth) -{ - ImGuiContext& g = *GImGui; - if (g.LogEnabled) - return; - IM_UNUSED(auto_open_depth); -#ifndef IMGUI_DISABLE_TTY_FUNCTIONS - LogBegin(ImGuiLogType_TTY, auto_open_depth); - g.LogFile = stdout; -#endif -} - -// Start logging/capturing text output to given file -void ImGui::LogToFile(int auto_open_depth, const char* filename) -{ - ImGuiContext& g = *GImGui; - if (g.LogEnabled) - return; - - // FIXME: We could probably open the file in text mode "at", however note that clipboard/buffer logging will still - // be subject to outputting OS-incompatible carriage return if within strings the user doesn't use IM_NEWLINE. - // By opening the file in binary mode "ab" we have consistent output everywhere. - if (!filename) - filename = g.IO.LogFilename; - if (!filename || !filename[0]) - return; - ImFileHandle f = ImFileOpen(filename, "ab"); - if (!f) - { - IM_ASSERT(0); - return; - } - - LogBegin(ImGuiLogType_File, auto_open_depth); - g.LogFile = f; -} - -// Start logging/capturing text output to clipboard -void ImGui::LogToClipboard(int auto_open_depth) -{ - ImGuiContext& g = *GImGui; - if (g.LogEnabled) - return; - LogBegin(ImGuiLogType_Clipboard, auto_open_depth); -} - -void ImGui::LogToBuffer(int auto_open_depth) -{ - ImGuiContext& g = *GImGui; - if (g.LogEnabled) - return; - LogBegin(ImGuiLogType_Buffer, auto_open_depth); -} - -void ImGui::LogFinish() -{ - ImGuiContext& g = *GImGui; - if (!g.LogEnabled) - return; - - LogText(IM_NEWLINE); - switch (g.LogType) - { - case ImGuiLogType_TTY: -#ifndef IMGUI_DISABLE_TTY_FUNCTIONS - fflush(g.LogFile); -#endif - break; - case ImGuiLogType_File: - ImFileClose(g.LogFile); - break; - case ImGuiLogType_Buffer: - break; - case ImGuiLogType_Clipboard: - if (!g.LogBuffer.empty()) - SetClipboardText(g.LogBuffer.begin()); - break; - case ImGuiLogType_None: - IM_ASSERT(0); - break; - } - - g.LogEnabled = false; - g.LogType = ImGuiLogType_None; - g.LogFile = NULL; - g.LogBuffer.clear(); -} - -// Helper to display logging buttons -// FIXME-OBSOLETE: We should probably obsolete this and let the user have their own helper (this is one of the oldest function alive!) -void ImGui::LogButtons() -{ - ImGuiContext& g = *GImGui; - - PushID("LogButtons"); -#ifndef IMGUI_DISABLE_TTY_FUNCTIONS - const bool log_to_tty = Button("Log To TTY"); SameLine(); -#else - const bool log_to_tty = false; -#endif - const bool log_to_file = Button("Log To File"); SameLine(); - const bool log_to_clipboard = Button("Log To Clipboard"); SameLine(); - PushAllowKeyboardFocus(false); - SetNextItemWidth(80.0f); - SliderInt("Default Depth", &g.LogDepthToExpandDefault, 0, 9, NULL); - PopAllowKeyboardFocus(); - PopID(); - - // Start logging at the end of the function so that the buttons don't appear in the log - if (log_to_tty) - LogToTTY(); - if (log_to_file) - LogToFile(); - if (log_to_clipboard) - LogToClipboard(); -} - - -//----------------------------------------------------------------------------- -// [SECTION] SETTINGS -//----------------------------------------------------------------------------- -// - UpdateSettings() [Internal] -// - MarkIniSettingsDirty() [Internal] -// - CreateNewWindowSettings() [Internal] -// - FindWindowSettings() [Internal] -// - FindOrCreateWindowSettings() [Internal] -// - FindSettingsHandler() [Internal] -// - ClearIniSettings() [Internal] -// - LoadIniSettingsFromDisk() -// - LoadIniSettingsFromMemory() -// - SaveIniSettingsToDisk() -// - SaveIniSettingsToMemory() -// - WindowSettingsHandler_***() [Internal] -//----------------------------------------------------------------------------- - -// Called by NewFrame() -void ImGui::UpdateSettings() -{ - // Load settings on first frame (if not explicitly loaded manually before) - ImGuiContext& g = *GImGui; - if (!g.SettingsLoaded) - { - IM_ASSERT(g.SettingsWindows.empty()); - if (g.IO.IniFilename) - LoadIniSettingsFromDisk(g.IO.IniFilename); - g.SettingsLoaded = true; - } - - // Save settings (with a delay after the last modification, so we don't spam disk too much) - if (g.SettingsDirtyTimer > 0.0f) - { - g.SettingsDirtyTimer -= g.IO.DeltaTime; - if (g.SettingsDirtyTimer <= 0.0f) - { - if (g.IO.IniFilename != NULL) - SaveIniSettingsToDisk(g.IO.IniFilename); - else - g.IO.WantSaveIniSettings = true; // Let user know they can call SaveIniSettingsToMemory(). user will need to clear io.WantSaveIniSettings themselves. - g.SettingsDirtyTimer = 0.0f; - } - } -} - -void ImGui::MarkIniSettingsDirty() -{ - ImGuiContext& g = *GImGui; - if (g.SettingsDirtyTimer <= 0.0f) - g.SettingsDirtyTimer = g.IO.IniSavingRate; -} - -void ImGui::MarkIniSettingsDirty(ImGuiWindow* window) -{ - ImGuiContext& g = *GImGui; - if (!(window->Flags & ImGuiWindowFlags_NoSavedSettings)) - if (g.SettingsDirtyTimer <= 0.0f) - g.SettingsDirtyTimer = g.IO.IniSavingRate; -} - -ImGuiWindowSettings* ImGui::CreateNewWindowSettings(const char* name) -{ - ImGuiContext& g = *GImGui; - -#if !IMGUI_DEBUG_INI_SETTINGS - // Skip to the "###" marker if any. We don't skip past to match the behavior of GetID() - // Preserve the full string when IMGUI_DEBUG_INI_SETTINGS is set to make .ini inspection easier. - if (const char* p = strstr(name, "###")) - name = p; -#endif - const size_t name_len = strlen(name); - - // Allocate chunk - const size_t chunk_size = sizeof(ImGuiWindowSettings) + name_len + 1; - ImGuiWindowSettings* settings = g.SettingsWindows.alloc_chunk(chunk_size); - IM_PLACEMENT_NEW(settings) ImGuiWindowSettings(); - settings->ID = ImHashStr(name, name_len); - memcpy(settings->GetName(), name, name_len + 1); // Store with zero terminator - - return settings; -} - -ImGuiWindowSettings* ImGui::FindWindowSettings(ImGuiID id) -{ - ImGuiContext& g = *GImGui; - for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) - if (settings->ID == id) - return settings; - return NULL; -} - -ImGuiWindowSettings* ImGui::FindOrCreateWindowSettings(const char* name) -{ - if (ImGuiWindowSettings* settings = FindWindowSettings(ImHashStr(name))) - return settings; - return CreateNewWindowSettings(name); -} - -ImGuiSettingsHandler* ImGui::FindSettingsHandler(const char* type_name) -{ - ImGuiContext& g = *GImGui; - const ImGuiID type_hash = ImHashStr(type_name); - for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++) - if (g.SettingsHandlers[handler_n].TypeHash == type_hash) - return &g.SettingsHandlers[handler_n]; - return NULL; -} - -void ImGui::ClearIniSettings() -{ - ImGuiContext& g = *GImGui; - g.SettingsIniData.clear(); - for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++) - if (g.SettingsHandlers[handler_n].ClearAllFn) - g.SettingsHandlers[handler_n].ClearAllFn(&g, &g.SettingsHandlers[handler_n]); -} - -void ImGui::LoadIniSettingsFromDisk(const char* ini_filename) -{ - size_t file_data_size = 0; - char* file_data = (char*)ImFileLoadToMemory(ini_filename, "rb", &file_data_size); - if (!file_data) - return; - LoadIniSettingsFromMemory(file_data, (size_t)file_data_size); - IM_FREE(file_data); -} - -// Zero-tolerance, no error reporting, cheap .ini parsing -void ImGui::LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size) -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(g.Initialized); - //IM_ASSERT(!g.WithinFrameScope && "Cannot be called between NewFrame() and EndFrame()"); - //IM_ASSERT(g.SettingsLoaded == false && g.FrameCount == 0); - - // For user convenience, we allow passing a non zero-terminated string (hence the ini_size parameter). - // For our convenience and to make the code simpler, we'll also write zero-terminators within the buffer. So let's create a writable copy.. - if (ini_size == 0) - ini_size = strlen(ini_data); - g.SettingsIniData.Buf.resize((int)ini_size + 1); - char* const buf = g.SettingsIniData.Buf.Data; - char* const buf_end = buf + ini_size; - memcpy(buf, ini_data, ini_size); - buf_end[0] = 0; - - // Call pre-read handlers - // Some types will clear their data (e.g. dock information) some types will allow merge/override (window) - for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++) - if (g.SettingsHandlers[handler_n].ReadInitFn) - g.SettingsHandlers[handler_n].ReadInitFn(&g, &g.SettingsHandlers[handler_n]); - - void* entry_data = NULL; - ImGuiSettingsHandler* entry_handler = NULL; - - char* line_end = NULL; - for (char* line = buf; line < buf_end; line = line_end + 1) - { - // Skip new lines markers, then find end of the line - while (*line == '\n' || *line == '\r') - line++; - line_end = line; - while (line_end < buf_end && *line_end != '\n' && *line_end != '\r') - line_end++; - line_end[0] = 0; - if (line[0] == ';') - continue; - if (line[0] == '[' && line_end > line && line_end[-1] == ']') - { - // Parse "[Type][Name]". Note that 'Name' can itself contains [] characters, which is acceptable with the current format and parsing code. - line_end[-1] = 0; - const char* name_end = line_end - 1; - const char* type_start = line + 1; - char* type_end = (char*)(void*)ImStrchrRange(type_start, name_end, ']'); - const char* name_start = type_end ? ImStrchrRange(type_end + 1, name_end, '[') : NULL; - if (!type_end || !name_start) - continue; - *type_end = 0; // Overwrite first ']' - name_start++; // Skip second '[' - entry_handler = FindSettingsHandler(type_start); - entry_data = entry_handler ? entry_handler->ReadOpenFn(&g, entry_handler, name_start) : NULL; - } - else if (entry_handler != NULL && entry_data != NULL) - { - // Let type handler parse the line - entry_handler->ReadLineFn(&g, entry_handler, entry_data, line); - } - } - g.SettingsLoaded = true; - - // [DEBUG] Restore untouched copy so it can be browsed in Metrics (not strictly necessary) - memcpy(buf, ini_data, ini_size); - - // Call post-read handlers - for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++) - if (g.SettingsHandlers[handler_n].ApplyAllFn) - g.SettingsHandlers[handler_n].ApplyAllFn(&g, &g.SettingsHandlers[handler_n]); -} - -void ImGui::SaveIniSettingsToDisk(const char* ini_filename) -{ - ImGuiContext& g = *GImGui; - g.SettingsDirtyTimer = 0.0f; - if (!ini_filename) - return; - - size_t ini_data_size = 0; - const char* ini_data = SaveIniSettingsToMemory(&ini_data_size); - ImFileHandle f = ImFileOpen(ini_filename, "wt"); - if (!f) - return; - ImFileWrite(ini_data, sizeof(char), ini_data_size, f); - ImFileClose(f); -} - -// Call registered handlers (e.g. SettingsHandlerWindow_WriteAll() + custom handlers) to write their stuff into a text buffer -const char* ImGui::SaveIniSettingsToMemory(size_t* out_size) -{ - ImGuiContext& g = *GImGui; - g.SettingsDirtyTimer = 0.0f; - g.SettingsIniData.Buf.resize(0); - g.SettingsIniData.Buf.push_back(0); - for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++) - { - ImGuiSettingsHandler* handler = &g.SettingsHandlers[handler_n]; - handler->WriteAllFn(&g, handler, &g.SettingsIniData); - } - if (out_size) - *out_size = (size_t)g.SettingsIniData.size(); - return g.SettingsIniData.c_str(); -} - -static void WindowSettingsHandler_ClearAll(ImGuiContext* ctx, ImGuiSettingsHandler*) -{ - ImGuiContext& g = *ctx; - for (int i = 0; i != g.Windows.Size; i++) - g.Windows[i]->SettingsOffset = -1; - g.SettingsWindows.clear(); -} - -static void* WindowSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name) -{ - ImGuiWindowSettings* settings = ImGui::FindOrCreateWindowSettings(name); - ImGuiID id = settings->ID; - *settings = ImGuiWindowSettings(); // Clear existing if recycling previous entry - settings->ID = id; - settings->WantApply = true; - return (void*)settings; -} - -static void WindowSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line) -{ - ImGuiWindowSettings* settings = (ImGuiWindowSettings*)entry; - int x, y; - int i; - if (sscanf(line, "Pos=%i,%i", &x, &y) == 2) { settings->Pos = ImVec2ih((short)x, (short)y); } - else if (sscanf(line, "Size=%i,%i", &x, &y) == 2) { settings->Size = ImVec2ih((short)x, (short)y); } - else if (sscanf(line, "Collapsed=%d", &i) == 1) { settings->Collapsed = (i != 0); } -} - -// Apply to existing windows (if any) -static void WindowSettingsHandler_ApplyAll(ImGuiContext* ctx, ImGuiSettingsHandler*) -{ - ImGuiContext& g = *ctx; - for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) - if (settings->WantApply) - { - if (ImGuiWindow* window = ImGui::FindWindowByID(settings->ID)) - ApplyWindowSettings(window, settings); - settings->WantApply = false; - } -} - -static void WindowSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf) -{ - // Gather data from windows that were active during this session - // (if a window wasn't opened in this session we preserve its settings) - ImGuiContext& g = *ctx; - for (int i = 0; i != g.Windows.Size; i++) - { - ImGuiWindow* window = g.Windows[i]; - if (window->Flags & ImGuiWindowFlags_NoSavedSettings) - continue; - - ImGuiWindowSettings* settings = (window->SettingsOffset != -1) ? g.SettingsWindows.ptr_from_offset(window->SettingsOffset) : ImGui::FindWindowSettings(window->ID); - if (!settings) - { - settings = ImGui::CreateNewWindowSettings(window->Name); - window->SettingsOffset = g.SettingsWindows.offset_from_ptr(settings); - } - IM_ASSERT(settings->ID == window->ID); - settings->Pos = ImVec2ih(window->Pos); - settings->Size = ImVec2ih(window->SizeFull); - - settings->Collapsed = window->Collapsed; - } - - // Write to text buffer - buf->reserve(buf->size() + g.SettingsWindows.size() * 6); // ballpark reserve - for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) - { - const char* settings_name = settings->GetName(); - buf->appendf("[%s][%s]\n", handler->TypeName, settings_name); - buf->appendf("Pos=%d,%d\n", settings->Pos.x, settings->Pos.y); - buf->appendf("Size=%d,%d\n", settings->Size.x, settings->Size.y); - buf->appendf("Collapsed=%d\n", settings->Collapsed); - buf->append("\n"); - } -} - - -//----------------------------------------------------------------------------- -// [SECTION] VIEWPORTS, PLATFORM WINDOWS -//----------------------------------------------------------------------------- -// - GetMainViewport() -// - UpdateViewportsNewFrame() [Internal] -// (this section is more complete in the 'docking' branch) -//----------------------------------------------------------------------------- - -ImGuiViewport* ImGui::GetMainViewport() -{ - ImGuiContext& g = *GImGui; - return g.Viewports[0]; -} - -// Update viewports and monitor infos -static void ImGui::UpdateViewportsNewFrame() -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(g.Viewports.Size == 1); - - // Update main viewport with current platform position. - // FIXME-VIEWPORT: Size is driven by backend/user code for backward-compatibility but we should aim to make this more consistent. - ImGuiViewportP* main_viewport = g.Viewports[0]; - main_viewport->Flags = ImGuiViewportFlags_IsPlatformWindow | ImGuiViewportFlags_OwnedByApp; - main_viewport->Pos = ImVec2(0.0f, 0.0f); - main_viewport->Size = g.IO.DisplaySize; - - for (int n = 0; n < g.Viewports.Size; n++) - { - ImGuiViewportP* viewport = g.Viewports[n]; - - // Lock down space taken by menu bars and status bars, reset the offset for fucntions like BeginMainMenuBar() to alter them again. - viewport->WorkOffsetMin = viewport->BuildWorkOffsetMin; - viewport->WorkOffsetMax = viewport->BuildWorkOffsetMax; - viewport->BuildWorkOffsetMin = viewport->BuildWorkOffsetMax = ImVec2(0.0f, 0.0f); - viewport->UpdateWorkRect(); - } -} - -//----------------------------------------------------------------------------- -// [SECTION] DOCKING -//----------------------------------------------------------------------------- - -// (this section is filled in the 'docking' branch) - - -//----------------------------------------------------------------------------- -// [SECTION] PLATFORM DEPENDENT HELPERS -//----------------------------------------------------------------------------- - -#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS) - -#ifdef _MSC_VER -#pragma comment(lib, "user32") -#pragma comment(lib, "kernel32") -#endif - -// Win32 clipboard implementation -// We use g.ClipboardHandlerData for temporary storage to ensure it is freed on Shutdown() -static const char* GetClipboardTextFn_DefaultImpl(void*) -{ - ImGuiContext& g = *GImGui; - g.ClipboardHandlerData.clear(); - if (!::OpenClipboard(NULL)) - return NULL; - HANDLE wbuf_handle = ::GetClipboardData(CF_UNICODETEXT); - if (wbuf_handle == NULL) - { - ::CloseClipboard(); - return NULL; - } - if (const WCHAR* wbuf_global = (const WCHAR*)::GlobalLock(wbuf_handle)) - { - int buf_len = ::WideCharToMultiByte(CP_UTF8, 0, wbuf_global, -1, NULL, 0, NULL, NULL); - g.ClipboardHandlerData.resize(buf_len); - ::WideCharToMultiByte(CP_UTF8, 0, wbuf_global, -1, g.ClipboardHandlerData.Data, buf_len, NULL, NULL); - } - ::GlobalUnlock(wbuf_handle); - ::CloseClipboard(); - return g.ClipboardHandlerData.Data; -} - -static void SetClipboardTextFn_DefaultImpl(void*, const char* text) -{ - if (!::OpenClipboard(NULL)) - return; - const int wbuf_length = ::MultiByteToWideChar(CP_UTF8, 0, text, -1, NULL, 0); - HGLOBAL wbuf_handle = ::GlobalAlloc(GMEM_MOVEABLE, (SIZE_T)wbuf_length * sizeof(WCHAR)); - if (wbuf_handle == NULL) - { - ::CloseClipboard(); - return; - } - WCHAR* wbuf_global = (WCHAR*)::GlobalLock(wbuf_handle); - ::MultiByteToWideChar(CP_UTF8, 0, text, -1, wbuf_global, wbuf_length); - ::GlobalUnlock(wbuf_handle); - ::EmptyClipboard(); - if (::SetClipboardData(CF_UNICODETEXT, wbuf_handle) == NULL) - ::GlobalFree(wbuf_handle); - ::CloseClipboard(); -} - -#elif defined(__APPLE__) && TARGET_OS_OSX && defined(IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS) - -#include // Use old API to avoid need for separate .mm file -static PasteboardRef main_clipboard = 0; - -// OSX clipboard implementation -// If you enable this you will need to add '-framework ApplicationServices' to your linker command-line! -static void SetClipboardTextFn_DefaultImpl(void*, const char* text) -{ - if (!main_clipboard) - PasteboardCreate(kPasteboardClipboard, &main_clipboard); - PasteboardClear(main_clipboard); - CFDataRef cf_data = CFDataCreate(kCFAllocatorDefault, (const UInt8*)text, strlen(text)); - if (cf_data) - { - PasteboardPutItemFlavor(main_clipboard, (PasteboardItemID)1, CFSTR("public.utf8-plain-text"), cf_data, 0); - CFRelease(cf_data); - } -} - -static const char* GetClipboardTextFn_DefaultImpl(void*) -{ - if (!main_clipboard) - PasteboardCreate(kPasteboardClipboard, &main_clipboard); - PasteboardSynchronize(main_clipboard); - - ItemCount item_count = 0; - PasteboardGetItemCount(main_clipboard, &item_count); - for (ItemCount i = 0; i < item_count; i++) - { - PasteboardItemID item_id = 0; - PasteboardGetItemIdentifier(main_clipboard, i + 1, &item_id); - CFArrayRef flavor_type_array = 0; - PasteboardCopyItemFlavors(main_clipboard, item_id, &flavor_type_array); - for (CFIndex j = 0, nj = CFArrayGetCount(flavor_type_array); j < nj; j++) - { - CFDataRef cf_data; - if (PasteboardCopyItemFlavorData(main_clipboard, item_id, CFSTR("public.utf8-plain-text"), &cf_data) == noErr) - { - ImGuiContext& g = *GImGui; - g.ClipboardHandlerData.clear(); - int length = (int)CFDataGetLength(cf_data); - g.ClipboardHandlerData.resize(length + 1); - CFDataGetBytes(cf_data, CFRangeMake(0, length), (UInt8*)g.ClipboardHandlerData.Data); - g.ClipboardHandlerData[length] = 0; - CFRelease(cf_data); - return g.ClipboardHandlerData.Data; - } - } - } - return NULL; -} - -#else - -// Local Dear ImGui-only clipboard implementation, if user hasn't defined better clipboard handlers. -static const char* GetClipboardTextFn_DefaultImpl(void*) -{ - ImGuiContext& g = *GImGui; - return g.ClipboardHandlerData.empty() ? NULL : g.ClipboardHandlerData.begin(); -} - -static void SetClipboardTextFn_DefaultImpl(void*, const char* text) -{ - ImGuiContext& g = *GImGui; - g.ClipboardHandlerData.clear(); - const char* text_end = text + strlen(text); - g.ClipboardHandlerData.resize((int)(text_end - text) + 1); - memcpy(&g.ClipboardHandlerData[0], text, (size_t)(text_end - text)); - g.ClipboardHandlerData[(int)(text_end - text)] = 0; -} - -#endif - -// Win32 API IME support (for Asian languages, etc.) -#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS) - -#include -#ifdef _MSC_VER -#pragma comment(lib, "imm32") -#endif - -static void ImeSetInputScreenPosFn_DefaultImpl(int x, int y) -{ - // Notify OS Input Method Editor of text input position - ImGuiIO& io = ImGui::GetIO(); - if (HWND hwnd = (HWND)io.ImeWindowHandle) - if (HIMC himc = ::ImmGetContext(hwnd)) - { - COMPOSITIONFORM cf; - cf.ptCurrentPos.x = x; - cf.ptCurrentPos.y = y; - cf.dwStyle = CFS_FORCE_POSITION; - ::ImmSetCompositionWindow(himc, &cf); - ::ImmReleaseContext(hwnd, himc); - } -} - -#else - -static void ImeSetInputScreenPosFn_DefaultImpl(int, int) {} - -#endif - -//----------------------------------------------------------------------------- -// [SECTION] METRICS/DEBUGGER WINDOW -//----------------------------------------------------------------------------- -// - RenderViewportThumbnail() [Internal] -// - RenderViewportsThumbnails() [Internal] -// - MetricsHelpMarker() [Internal] -// - ShowMetricsWindow() -// - DebugNodeColumns() [Internal] -// - DebugNodeDrawList() [Internal] -// - DebugNodeDrawCmdShowMeshAndBoundingBox() [Internal] -// - DebugNodeStorage() [Internal] -// - DebugNodeTabBar() [Internal] -// - DebugNodeViewport() [Internal] -// - DebugNodeWindow() [Internal] -// - DebugNodeWindowSettings() [Internal] -// - DebugNodeWindowsList() [Internal] -//----------------------------------------------------------------------------- - -#ifndef IMGUI_DISABLE_METRICS_WINDOW - -void ImGui::DebugRenderViewportThumbnail(ImDrawList* draw_list, ImGuiViewportP* viewport, const ImRect& bb) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - - ImVec2 scale = bb.GetSize() / viewport->Size; - ImVec2 off = bb.Min - viewport->Pos * scale; - float alpha_mul = 1.0f; - window->DrawList->AddRectFilled(bb.Min, bb.Max, GetColorU32(ImGuiCol_Border, alpha_mul * 0.40f)); - for (int i = 0; i != g.Windows.Size; i++) - { - ImGuiWindow* thumb_window = g.Windows[i]; - if (!thumb_window->WasActive || (thumb_window->Flags & ImGuiWindowFlags_ChildWindow)) - continue; - - ImRect thumb_r = thumb_window->Rect(); - ImRect title_r = thumb_window->TitleBarRect(); - thumb_r = ImRect(ImFloor(off + thumb_r.Min * scale), ImFloor(off + thumb_r.Max * scale)); - title_r = ImRect(ImFloor(off + title_r.Min * scale), ImFloor(off + ImVec2(title_r.Max.x, title_r.Min.y) * scale) + ImVec2(0,5)); // Exaggerate title bar height - thumb_r.ClipWithFull(bb); - title_r.ClipWithFull(bb); - const bool window_is_focused = (g.NavWindow && thumb_window->RootWindowForTitleBarHighlight == g.NavWindow->RootWindowForTitleBarHighlight); - window->DrawList->AddRectFilled(thumb_r.Min, thumb_r.Max, GetColorU32(ImGuiCol_WindowBg, alpha_mul)); - window->DrawList->AddRectFilled(title_r.Min, title_r.Max, GetColorU32(window_is_focused ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBg, alpha_mul)); - window->DrawList->AddRect(thumb_r.Min, thumb_r.Max, GetColorU32(ImGuiCol_Border, alpha_mul)); - window->DrawList->AddText(g.Font, g.FontSize * 1.0f, title_r.Min, GetColorU32(ImGuiCol_Text, alpha_mul), thumb_window->Name, FindRenderedTextEnd(thumb_window->Name)); - } - draw_list->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_Border, alpha_mul)); -} - -static void RenderViewportsThumbnails() -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - - // We don't display full monitor bounds (we could, but it often looks awkward), instead we display just enough to cover all of our viewports. - float SCALE = 1.0f / 8.0f; - ImRect bb_full(FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX); - for (int n = 0; n < g.Viewports.Size; n++) - bb_full.Add(g.Viewports[n]->GetMainRect()); - ImVec2 p = window->DC.CursorPos; - ImVec2 off = p - bb_full.Min * SCALE; - for (int n = 0; n < g.Viewports.Size; n++) - { - ImGuiViewportP* viewport = g.Viewports[n]; - ImRect viewport_draw_bb(off + (viewport->Pos) * SCALE, off + (viewport->Pos + viewport->Size) * SCALE); - ImGui::DebugRenderViewportThumbnail(window->DrawList, viewport, viewport_draw_bb); - } - ImGui::Dummy(bb_full.GetSize() * SCALE); -} - -// Avoid naming collision with imgui_demo.cpp's HelpMarker() for unity builds. -static void MetricsHelpMarker(const char* desc) -{ - ImGui::TextDisabled("(?)"); - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f); - ImGui::TextUnformatted(desc); - ImGui::PopTextWrapPos(); - ImGui::EndTooltip(); - } -} - -#ifndef IMGUI_DISABLE_DEMO_WINDOWS -namespace ImGui { void ShowFontAtlas(ImFontAtlas* atlas); } -#endif - -void ImGui::ShowMetricsWindow(bool* p_open) -{ - ImGuiContext& g = *GImGui; - ImGuiIO& io = g.IO; - ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig; - if (cfg->ShowStackTool) - ShowStackToolWindow(&cfg->ShowStackTool); - - if (!Begin("Dear ImGui Metrics/Debugger", p_open) || GetCurrentWindow()->BeginCount > 1) - { - End(); - return; - } - - // Basic info - Text("Dear ImGui %s", GetVersion()); - Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate); - Text("%d vertices, %d indices (%d triangles)", io.MetricsRenderVertices, io.MetricsRenderIndices, io.MetricsRenderIndices / 3); - Text("%d visible windows, %d active allocations", io.MetricsRenderWindows, io.MetricsActiveAllocations); - //SameLine(); if (SmallButton("GC")) { g.GcCompactAll = true; } - - Separator(); - - // Debugging enums - enum { WRT_OuterRect, WRT_OuterRectClipped, WRT_InnerRect, WRT_InnerClipRect, WRT_WorkRect, WRT_Content, WRT_ContentIdeal, WRT_ContentRegionRect, WRT_Count }; // Windows Rect Type - const char* wrt_rects_names[WRT_Count] = { "OuterRect", "OuterRectClipped", "InnerRect", "InnerClipRect", "WorkRect", "Content", "ContentIdeal", "ContentRegionRect" }; - enum { TRT_OuterRect, TRT_InnerRect, TRT_WorkRect, TRT_HostClipRect, TRT_InnerClipRect, TRT_BackgroundClipRect, TRT_ColumnsRect, TRT_ColumnsWorkRect, TRT_ColumnsClipRect, TRT_ColumnsContentHeadersUsed, TRT_ColumnsContentHeadersIdeal, TRT_ColumnsContentFrozen, TRT_ColumnsContentUnfrozen, TRT_Count }; // Tables Rect Type - const char* trt_rects_names[TRT_Count] = { "OuterRect", "InnerRect", "WorkRect", "HostClipRect", "InnerClipRect", "BackgroundClipRect", "ColumnsRect", "ColumnsWorkRect", "ColumnsClipRect", "ColumnsContentHeadersUsed", "ColumnsContentHeadersIdeal", "ColumnsContentFrozen", "ColumnsContentUnfrozen" }; - if (cfg->ShowWindowsRectsType < 0) - cfg->ShowWindowsRectsType = WRT_WorkRect; - if (cfg->ShowTablesRectsType < 0) - cfg->ShowTablesRectsType = TRT_WorkRect; - - struct Funcs - { - static ImRect GetTableRect(ImGuiTable* table, int rect_type, int n) - { - if (rect_type == TRT_OuterRect) { return table->OuterRect; } - else if (rect_type == TRT_InnerRect) { return table->InnerRect; } - else if (rect_type == TRT_WorkRect) { return table->WorkRect; } - else if (rect_type == TRT_HostClipRect) { return table->HostClipRect; } - else if (rect_type == TRT_InnerClipRect) { return table->InnerClipRect; } - else if (rect_type == TRT_BackgroundClipRect) { return table->BgClipRect; } - else if (rect_type == TRT_ColumnsRect) { ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->MinX, table->InnerClipRect.Min.y, c->MaxX, table->InnerClipRect.Min.y + table->LastOuterHeight); } - else if (rect_type == TRT_ColumnsWorkRect) { ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->WorkMinX, table->WorkRect.Min.y, c->WorkMaxX, table->WorkRect.Max.y); } - else if (rect_type == TRT_ColumnsClipRect) { ImGuiTableColumn* c = &table->Columns[n]; return c->ClipRect; } - else if (rect_type == TRT_ColumnsContentHeadersUsed){ ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->WorkMinX, table->InnerClipRect.Min.y, c->ContentMaxXHeadersUsed, table->InnerClipRect.Min.y + table->LastFirstRowHeight); } // Note: y1/y2 not always accurate - else if (rect_type == TRT_ColumnsContentHeadersIdeal){ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->WorkMinX, table->InnerClipRect.Min.y, c->ContentMaxXHeadersIdeal, table->InnerClipRect.Min.y + table->LastFirstRowHeight); } - else if (rect_type == TRT_ColumnsContentFrozen) { ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->WorkMinX, table->InnerClipRect.Min.y, c->ContentMaxXFrozen, table->InnerClipRect.Min.y + table->LastFirstRowHeight); } - else if (rect_type == TRT_ColumnsContentUnfrozen) { ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->WorkMinX, table->InnerClipRect.Min.y + table->LastFirstRowHeight, c->ContentMaxXUnfrozen, table->InnerClipRect.Max.y); } - IM_ASSERT(0); - return ImRect(); - } - - static ImRect GetWindowRect(ImGuiWindow* window, int rect_type) - { - if (rect_type == WRT_OuterRect) { return window->Rect(); } - else if (rect_type == WRT_OuterRectClipped) { return window->OuterRectClipped; } - else if (rect_type == WRT_InnerRect) { return window->InnerRect; } - else if (rect_type == WRT_InnerClipRect) { return window->InnerClipRect; } - else if (rect_type == WRT_WorkRect) { return window->WorkRect; } - else if (rect_type == WRT_Content) { ImVec2 min = window->InnerRect.Min - window->Scroll + window->WindowPadding; return ImRect(min, min + window->ContentSize); } - else if (rect_type == WRT_ContentIdeal) { ImVec2 min = window->InnerRect.Min - window->Scroll + window->WindowPadding; return ImRect(min, min + window->ContentSizeIdeal); } - else if (rect_type == WRT_ContentRegionRect) { return window->ContentRegionRect; } - IM_ASSERT(0); - return ImRect(); - } - }; - - // Tools - if (TreeNode("Tools")) - { - // Stack Tool is your best friend! - Checkbox("Show stack tool", &cfg->ShowStackTool); - SameLine(); - MetricsHelpMarker("You can also call ImGui::ShowStackToolWindow() from your code."); - - Checkbox("Show windows begin order", &cfg->ShowWindowsBeginOrder); - Checkbox("Show windows rectangles", &cfg->ShowWindowsRects); - SameLine(); - SetNextItemWidth(GetFontSize() * 12); - cfg->ShowWindowsRects |= Combo("##show_windows_rect_type", &cfg->ShowWindowsRectsType, wrt_rects_names, WRT_Count, WRT_Count); - if (cfg->ShowWindowsRects && g.NavWindow != NULL) - { - BulletText("'%s':", g.NavWindow->Name); - Indent(); - for (int rect_n = 0; rect_n < WRT_Count; rect_n++) - { - ImRect r = Funcs::GetWindowRect(g.NavWindow, rect_n); - Text("(%6.1f,%6.1f) (%6.1f,%6.1f) Size (%6.1f,%6.1f) %s", r.Min.x, r.Min.y, r.Max.x, r.Max.y, r.GetWidth(), r.GetHeight(), wrt_rects_names[rect_n]); - } - Unindent(); - } - - Checkbox("Show tables rectangles", &cfg->ShowTablesRects); - SameLine(); - SetNextItemWidth(GetFontSize() * 12); - cfg->ShowTablesRects |= Combo("##show_table_rects_type", &cfg->ShowTablesRectsType, trt_rects_names, TRT_Count, TRT_Count); - if (cfg->ShowTablesRects && g.NavWindow != NULL) - { - for (int table_n = 0; table_n < g.Tables.GetMapSize(); table_n++) - { - ImGuiTable* table = g.Tables.TryGetMapData(table_n); - if (table == NULL || table->LastFrameActive < g.FrameCount - 1 || (table->OuterWindow != g.NavWindow && table->InnerWindow != g.NavWindow)) - continue; - - BulletText("Table 0x%08X (%d columns, in '%s')", table->ID, table->ColumnsCount, table->OuterWindow->Name); - if (IsItemHovered()) - GetForegroundDrawList()->AddRect(table->OuterRect.Min - ImVec2(1, 1), table->OuterRect.Max + ImVec2(1, 1), IM_COL32(255, 255, 0, 255), 0.0f, 0, 2.0f); - Indent(); - char buf[128]; - for (int rect_n = 0; rect_n < TRT_Count; rect_n++) - { - if (rect_n >= TRT_ColumnsRect) - { - if (rect_n != TRT_ColumnsRect && rect_n != TRT_ColumnsClipRect) - continue; - for (int column_n = 0; column_n < table->ColumnsCount; column_n++) - { - ImRect r = Funcs::GetTableRect(table, rect_n, column_n); - ImFormatString(buf, IM_ARRAYSIZE(buf), "(%6.1f,%6.1f) (%6.1f,%6.1f) Size (%6.1f,%6.1f) Col %d %s", r.Min.x, r.Min.y, r.Max.x, r.Max.y, r.GetWidth(), r.GetHeight(), column_n, trt_rects_names[rect_n]); - Selectable(buf); - if (IsItemHovered()) - GetForegroundDrawList()->AddRect(r.Min - ImVec2(1, 1), r.Max + ImVec2(1, 1), IM_COL32(255, 255, 0, 255), 0.0f, 0, 2.0f); - } - } - else - { - ImRect r = Funcs::GetTableRect(table, rect_n, -1); - ImFormatString(buf, IM_ARRAYSIZE(buf), "(%6.1f,%6.1f) (%6.1f,%6.1f) Size (%6.1f,%6.1f) %s", r.Min.x, r.Min.y, r.Max.x, r.Max.y, r.GetWidth(), r.GetHeight(), trt_rects_names[rect_n]); - Selectable(buf); - if (IsItemHovered()) - GetForegroundDrawList()->AddRect(r.Min - ImVec2(1, 1), r.Max + ImVec2(1, 1), IM_COL32(255, 255, 0, 255), 0.0f, 0, 2.0f); - } - } - Unindent(); - } - } - - // The Item Picker tool is super useful to visually select an item and break into the call-stack of where it was submitted. - if (Button("Item Picker..")) - DebugStartItemPicker(); - SameLine(); - MetricsHelpMarker("Will call the IM_DEBUG_BREAK() macro to break in debugger.\nWarning: If you don't have a debugger attached, this will probably crash."); - - TreePop(); - } - - // Windows - DebugNodeWindowsList(&g.Windows, "Windows"); - //DebugNodeWindowsList(&g.WindowsFocusOrder, "WindowsFocusOrder"); - - // DrawLists - int drawlist_count = 0; - for (int viewport_i = 0; viewport_i < g.Viewports.Size; viewport_i++) - drawlist_count += g.Viewports[viewport_i]->DrawDataBuilder.GetDrawListCount(); - if (TreeNode("DrawLists", "DrawLists (%d)", drawlist_count)) - { - Checkbox("Show ImDrawCmd mesh when hovering", &cfg->ShowDrawCmdMesh); - Checkbox("Show ImDrawCmd bounding boxes when hovering", &cfg->ShowDrawCmdBoundingBoxes); - for (int viewport_i = 0; viewport_i < g.Viewports.Size; viewport_i++) - { - ImGuiViewportP* viewport = g.Viewports[viewport_i]; - for (int layer_i = 0; layer_i < IM_ARRAYSIZE(viewport->DrawDataBuilder.Layers); layer_i++) - for (int draw_list_i = 0; draw_list_i < viewport->DrawDataBuilder.Layers[layer_i].Size; draw_list_i++) - DebugNodeDrawList(NULL, viewport->DrawDataBuilder.Layers[layer_i][draw_list_i], "DrawList"); - } - TreePop(); - } - - // Viewports - if (TreeNode("Viewports", "Viewports (%d)", g.Viewports.Size)) - { - Indent(GetTreeNodeToLabelSpacing()); - RenderViewportsThumbnails(); - Unindent(GetTreeNodeToLabelSpacing()); - for (int i = 0; i < g.Viewports.Size; i++) - DebugNodeViewport(g.Viewports[i]); - TreePop(); - } - - // Details for Popups - if (TreeNode("Popups", "Popups (%d)", g.OpenPopupStack.Size)) - { - for (int i = 0; i < g.OpenPopupStack.Size; i++) - { - ImGuiWindow* window = g.OpenPopupStack[i].Window; - BulletText("PopupID: %08x, Window: '%s'%s%s", g.OpenPopupStack[i].PopupId, window ? window->Name : "NULL", window && (window->Flags & ImGuiWindowFlags_ChildWindow) ? " ChildWindow" : "", window && (window->Flags & ImGuiWindowFlags_ChildMenu) ? " ChildMenu" : ""); - } - TreePop(); - } - - // Details for TabBars - if (TreeNode("TabBars", "Tab Bars (%d)", g.TabBars.GetAliveCount())) - { - for (int n = 0; n < g.TabBars.GetMapSize(); n++) - if (ImGuiTabBar* tab_bar = g.TabBars.TryGetMapData(n)) - { - PushID(tab_bar); - DebugNodeTabBar(tab_bar, "TabBar"); - PopID(); - } - TreePop(); - } - - // Details for Tables - if (TreeNode("Tables", "Tables (%d)", g.Tables.GetAliveCount())) - { - for (int n = 0; n < g.Tables.GetMapSize(); n++) - if (ImGuiTable* table = g.Tables.TryGetMapData(n)) - DebugNodeTable(table); - TreePop(); - } - - // Details for Fonts -#ifndef IMGUI_DISABLE_DEMO_WINDOWS - ImFontAtlas* atlas = g.IO.Fonts; - if (TreeNode("Fonts", "Fonts (%d)", atlas->Fonts.Size)) - { - ShowFontAtlas(atlas); - TreePop(); - } -#endif - - // Details for Docking -#ifdef IMGUI_HAS_DOCK - if (TreeNode("Docking")) - { - TreePop(); - } -#endif // #ifdef IMGUI_HAS_DOCK - - // Settings - if (TreeNode("Settings")) - { - if (SmallButton("Clear")) - ClearIniSettings(); - SameLine(); - if (SmallButton("Save to memory")) - SaveIniSettingsToMemory(); - SameLine(); - if (SmallButton("Save to disk")) - SaveIniSettingsToDisk(g.IO.IniFilename); - SameLine(); - if (g.IO.IniFilename) - Text("\"%s\"", g.IO.IniFilename); - else - TextUnformatted(""); - Text("SettingsDirtyTimer %.2f", g.SettingsDirtyTimer); - if (TreeNode("SettingsHandlers", "Settings handlers: (%d)", g.SettingsHandlers.Size)) - { - for (int n = 0; n < g.SettingsHandlers.Size; n++) - BulletText("%s", g.SettingsHandlers[n].TypeName); - TreePop(); - } - if (TreeNode("SettingsWindows", "Settings packed data: Windows: %d bytes", g.SettingsWindows.size())) - { - for (ImGuiWindowSettings* settings = g.SettingsWindows.begin(); settings != NULL; settings = g.SettingsWindows.next_chunk(settings)) - DebugNodeWindowSettings(settings); - TreePop(); - } - - if (TreeNode("SettingsTables", "Settings packed data: Tables: %d bytes", g.SettingsTables.size())) - { - for (ImGuiTableSettings* settings = g.SettingsTables.begin(); settings != NULL; settings = g.SettingsTables.next_chunk(settings)) - DebugNodeTableSettings(settings); - TreePop(); - } - -#ifdef IMGUI_HAS_DOCK -#endif // #ifdef IMGUI_HAS_DOCK - - if (TreeNode("SettingsIniData", "Settings unpacked data (.ini): %d bytes", g.SettingsIniData.size())) - { - InputTextMultiline("##Ini", (char*)(void*)g.SettingsIniData.c_str(), g.SettingsIniData.Buf.Size, ImVec2(-FLT_MIN, GetTextLineHeight() * 20), ImGuiInputTextFlags_ReadOnly); - TreePop(); - } - TreePop(); - } - - // Misc Details - if (TreeNode("Internal state")) - { - const char* input_source_names[] = { "None", "Mouse", "Keyboard", "Gamepad", "Nav", "Clipboard" }; IM_ASSERT(IM_ARRAYSIZE(input_source_names) == ImGuiInputSource_COUNT); - - Text("WINDOWING"); - Indent(); - Text("HoveredWindow: '%s'", g.HoveredWindow ? g.HoveredWindow->Name : "NULL"); - Text("HoveredWindow->Root: '%s'", g.HoveredWindow ? g.HoveredWindow->RootWindow->Name : "NULL"); - Text("HoveredWindowUnderMovingWindow: '%s'", g.HoveredWindowUnderMovingWindow ? g.HoveredWindowUnderMovingWindow->Name : "NULL"); - Text("MovingWindow: '%s'", g.MovingWindow ? g.MovingWindow->Name : "NULL"); - Unindent(); - - Text("ITEMS"); - Indent(); - Text("ActiveId: 0x%08X/0x%08X (%.2f sec), AllowOverlap: %d, Source: %s", g.ActiveId, g.ActiveIdPreviousFrame, g.ActiveIdTimer, g.ActiveIdAllowOverlap, input_source_names[g.ActiveIdSource]); - Text("ActiveIdWindow: '%s'", g.ActiveIdWindow ? g.ActiveIdWindow->Name : "NULL"); - Text("ActiveIdUsing: Wheel: %d, NavDirMask: %X, NavInputMask: %X, KeyInputMask: %llX", g.ActiveIdUsingMouseWheel, g.ActiveIdUsingNavDirMask, g.ActiveIdUsingNavInputMask, g.ActiveIdUsingKeyInputMask); - Text("HoveredId: 0x%08X (%.2f sec), AllowOverlap: %d", g.HoveredIdPreviousFrame, g.HoveredIdTimer, g.HoveredIdAllowOverlap); // Not displaying g.HoveredId as it is update mid-frame - Text("DragDrop: %d, SourceId = 0x%08X, Payload \"%s\" (%d bytes)", g.DragDropActive, g.DragDropPayload.SourceId, g.DragDropPayload.DataType, g.DragDropPayload.DataSize); - Unindent(); - - Text("NAV,FOCUS"); - Indent(); - Text("NavWindow: '%s'", g.NavWindow ? g.NavWindow->Name : "NULL"); - Text("NavId: 0x%08X, NavLayer: %d", g.NavId, g.NavLayer); - Text("NavInputSource: %s", input_source_names[g.NavInputSource]); - Text("NavActive: %d, NavVisible: %d", g.IO.NavActive, g.IO.NavVisible); - Text("NavActivateId/DownId/PressedId/InputId: %08X/%08X/%08X/%08X", g.NavActivateId, g.NavActivateDownId, g.NavActivatePressedId, g.NavActivateInputId); - Text("NavActivateFlags: %04X", g.NavActivateFlags); - Text("NavDisableHighlight: %d, NavDisableMouseHover: %d", g.NavDisableHighlight, g.NavDisableMouseHover); - Text("NavFocusScopeId = 0x%08X", g.NavFocusScopeId); - Text("NavWindowingTarget: '%s'", g.NavWindowingTarget ? g.NavWindowingTarget->Name : "NULL"); - Unindent(); - - TreePop(); - } - - // Overlay: Display windows Rectangles and Begin Order - if (cfg->ShowWindowsRects || cfg->ShowWindowsBeginOrder) - { - for (int n = 0; n < g.Windows.Size; n++) - { - ImGuiWindow* window = g.Windows[n]; - if (!window->WasActive) - continue; - ImDrawList* draw_list = GetForegroundDrawList(window); - if (cfg->ShowWindowsRects) - { - ImRect r = Funcs::GetWindowRect(window, cfg->ShowWindowsRectsType); - draw_list->AddRect(r.Min, r.Max, IM_COL32(255, 0, 128, 255)); - } - if (cfg->ShowWindowsBeginOrder && !(window->Flags & ImGuiWindowFlags_ChildWindow)) - { - char buf[32]; - ImFormatString(buf, IM_ARRAYSIZE(buf), "%d", window->BeginOrderWithinContext); - float font_size = GetFontSize(); - draw_list->AddRectFilled(window->Pos, window->Pos + ImVec2(font_size, font_size), IM_COL32(200, 100, 100, 255)); - draw_list->AddText(window->Pos, IM_COL32(255, 255, 255, 255), buf); - } - } - } - - // Overlay: Display Tables Rectangles - if (cfg->ShowTablesRects) - { - for (int table_n = 0; table_n < g.Tables.GetMapSize(); table_n++) - { - ImGuiTable* table = g.Tables.TryGetMapData(table_n); - if (table == NULL || table->LastFrameActive < g.FrameCount - 1) - continue; - ImDrawList* draw_list = GetForegroundDrawList(table->OuterWindow); - if (cfg->ShowTablesRectsType >= TRT_ColumnsRect) - { - for (int column_n = 0; column_n < table->ColumnsCount; column_n++) - { - ImRect r = Funcs::GetTableRect(table, cfg->ShowTablesRectsType, column_n); - ImU32 col = (table->HoveredColumnBody == column_n) ? IM_COL32(255, 255, 128, 255) : IM_COL32(255, 0, 128, 255); - float thickness = (table->HoveredColumnBody == column_n) ? 3.0f : 1.0f; - draw_list->AddRect(r.Min, r.Max, col, 0.0f, 0, thickness); - } - } - else - { - ImRect r = Funcs::GetTableRect(table, cfg->ShowTablesRectsType, -1); - draw_list->AddRect(r.Min, r.Max, IM_COL32(255, 0, 128, 255)); - } - } - } - -#ifdef IMGUI_HAS_DOCK - // Overlay: Display Docking info - if (show_docking_nodes && g.IO.KeyCtrl) - { - } -#endif // #ifdef IMGUI_HAS_DOCK - - End(); -} - -// [DEBUG] List fonts in a font atlas and display its texture -void ImGui::ShowFontAtlas(ImFontAtlas* atlas) -{ - for (int i = 0; i < atlas->Fonts.Size; i++) - { - ImFont* font = atlas->Fonts[i]; - PushID(font); - DebugNodeFont(font); - PopID(); - } - if (TreeNode("Atlas texture", "Atlas texture (%dx%d pixels)", atlas->TexWidth, atlas->TexHeight)) - { - ImVec4 tint_col = ImVec4(1.0f, 1.0f, 1.0f, 1.0f); - ImVec4 border_col = ImVec4(1.0f, 1.0f, 1.0f, 0.5f); - Image(atlas->TexID, ImVec2((float)atlas->TexWidth, (float)atlas->TexHeight), ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f), tint_col, border_col); - TreePop(); - } -} - -// [DEBUG] Display contents of Columns -void ImGui::DebugNodeColumns(ImGuiOldColumns* columns) -{ - if (!TreeNode((void*)(uintptr_t)columns->ID, "Columns Id: 0x%08X, Count: %d, Flags: 0x%04X", columns->ID, columns->Count, columns->Flags)) - return; - BulletText("Width: %.1f (MinX: %.1f, MaxX: %.1f)", columns->OffMaxX - columns->OffMinX, columns->OffMinX, columns->OffMaxX); - for (int column_n = 0; column_n < columns->Columns.Size; column_n++) - BulletText("Column %02d: OffsetNorm %.3f (= %.1f px)", column_n, columns->Columns[column_n].OffsetNorm, GetColumnOffsetFromNorm(columns, columns->Columns[column_n].OffsetNorm)); - TreePop(); -} - -// [DEBUG] Display contents of ImDrawList -void ImGui::DebugNodeDrawList(ImGuiWindow* window, const ImDrawList* draw_list, const char* label) -{ - ImGuiContext& g = *GImGui; - ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig; - int cmd_count = draw_list->CmdBuffer.Size; - if (cmd_count > 0 && draw_list->CmdBuffer.back().ElemCount == 0 && draw_list->CmdBuffer.back().UserCallback == NULL) - cmd_count--; - bool node_open = TreeNode(draw_list, "%s: '%s' %d vtx, %d indices, %d cmds", label, draw_list->_OwnerName ? draw_list->_OwnerName : "", draw_list->VtxBuffer.Size, draw_list->IdxBuffer.Size, cmd_count); - if (draw_list == GetWindowDrawList()) - { - SameLine(); - TextColored(ImVec4(1.0f, 0.4f, 0.4f, 1.0f), "CURRENTLY APPENDING"); // Can't display stats for active draw list! (we don't have the data double-buffered) - if (node_open) - TreePop(); - return; - } - - ImDrawList* fg_draw_list = GetForegroundDrawList(window); // Render additional visuals into the top-most draw list - if (window && IsItemHovered()) - fg_draw_list->AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255, 255, 0, 255)); - if (!node_open) - return; - - if (window && !window->WasActive) - TextDisabled("Warning: owning Window is inactive. This DrawList is not being rendered!"); - - for (const ImDrawCmd* pcmd = draw_list->CmdBuffer.Data; pcmd < draw_list->CmdBuffer.Data + cmd_count; pcmd++) - { - if (pcmd->UserCallback) - { - BulletText("Callback %p, user_data %p", pcmd->UserCallback, pcmd->UserCallbackData); - continue; - } - - char buf[300]; - ImFormatString(buf, IM_ARRAYSIZE(buf), "DrawCmd:%5d tris, Tex 0x%p, ClipRect (%4.0f,%4.0f)-(%4.0f,%4.0f)", - pcmd->ElemCount / 3, (void*)(intptr_t)pcmd->TextureId, - pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w); - bool pcmd_node_open = TreeNode((void*)(pcmd - draw_list->CmdBuffer.begin()), "%s", buf); - if (IsItemHovered() && (cfg->ShowDrawCmdMesh || cfg->ShowDrawCmdBoundingBoxes) && fg_draw_list) - DebugNodeDrawCmdShowMeshAndBoundingBox(fg_draw_list, draw_list, pcmd, cfg->ShowDrawCmdMesh, cfg->ShowDrawCmdBoundingBoxes); - if (!pcmd_node_open) - continue; - - // Calculate approximate coverage area (touched pixel count) - // This will be in pixels squared as long there's no post-scaling happening to the renderer output. - const ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL; - const ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data + pcmd->VtxOffset; - float total_area = 0.0f; - for (unsigned int idx_n = pcmd->IdxOffset; idx_n < pcmd->IdxOffset + pcmd->ElemCount; ) - { - ImVec2 triangle[3]; - for (int n = 0; n < 3; n++, idx_n++) - triangle[n] = vtx_buffer[idx_buffer ? idx_buffer[idx_n] : idx_n].pos; - total_area += ImTriangleArea(triangle[0], triangle[1], triangle[2]); - } - - // Display vertex information summary. Hover to get all triangles drawn in wire-frame - ImFormatString(buf, IM_ARRAYSIZE(buf), "Mesh: ElemCount: %d, VtxOffset: +%d, IdxOffset: +%d, Area: ~%0.f px", pcmd->ElemCount, pcmd->VtxOffset, pcmd->IdxOffset, total_area); - Selectable(buf); - if (IsItemHovered() && fg_draw_list) - DebugNodeDrawCmdShowMeshAndBoundingBox(fg_draw_list, draw_list, pcmd, true, false); - - // Display individual triangles/vertices. Hover on to get the corresponding triangle highlighted. - ImGuiListClipper clipper; - clipper.Begin(pcmd->ElemCount / 3); // Manually coarse clip our print out of individual vertices to save CPU, only items that may be visible. - while (clipper.Step()) - for (int prim = clipper.DisplayStart, idx_i = pcmd->IdxOffset + clipper.DisplayStart * 3; prim < clipper.DisplayEnd; prim++) - { - char* buf_p = buf, * buf_end = buf + IM_ARRAYSIZE(buf); - ImVec2 triangle[3]; - for (int n = 0; n < 3; n++, idx_i++) - { - const ImDrawVert& v = vtx_buffer[idx_buffer ? idx_buffer[idx_i] : idx_i]; - triangle[n] = v.pos; - buf_p += ImFormatString(buf_p, buf_end - buf_p, "%s %04d: pos (%8.2f,%8.2f), uv (%.6f,%.6f), col %08X\n", - (n == 0) ? "Vert:" : " ", idx_i, v.pos.x, v.pos.y, v.uv.x, v.uv.y, v.col); - } - - Selectable(buf, false); - if (fg_draw_list && IsItemHovered()) - { - ImDrawListFlags backup_flags = fg_draw_list->Flags; - fg_draw_list->Flags &= ~ImDrawListFlags_AntiAliasedLines; // Disable AA on triangle outlines is more readable for very large and thin triangles. - fg_draw_list->AddPolyline(triangle, 3, IM_COL32(255, 255, 0, 255), ImDrawFlags_Closed, 1.0f); - fg_draw_list->Flags = backup_flags; - } - } - TreePop(); - } - TreePop(); -} - -// [DEBUG] Display mesh/aabb of a ImDrawCmd -void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, const ImDrawList* draw_list, const ImDrawCmd* draw_cmd, bool show_mesh, bool show_aabb) -{ - IM_ASSERT(show_mesh || show_aabb); - - // Draw wire-frame version of all triangles - ImRect clip_rect = draw_cmd->ClipRect; - ImRect vtxs_rect(FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX); - ImDrawListFlags backup_flags = out_draw_list->Flags; - out_draw_list->Flags &= ~ImDrawListFlags_AntiAliasedLines; // Disable AA on triangle outlines is more readable for very large and thin triangles. - for (unsigned int idx_n = draw_cmd->IdxOffset, idx_end = draw_cmd->IdxOffset + draw_cmd->ElemCount; idx_n < idx_end; ) - { - ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL; // We don't hold on those pointers past iterations as ->AddPolyline() may invalidate them if out_draw_list==draw_list - ImDrawVert* vtx_buffer = draw_list->VtxBuffer.Data + draw_cmd->VtxOffset; - - ImVec2 triangle[3]; - for (int n = 0; n < 3; n++, idx_n++) - vtxs_rect.Add((triangle[n] = vtx_buffer[idx_buffer ? idx_buffer[idx_n] : idx_n].pos)); - if (show_mesh) - out_draw_list->AddPolyline(triangle, 3, IM_COL32(255, 255, 0, 255), ImDrawFlags_Closed, 1.0f); // In yellow: mesh triangles - } - // Draw bounding boxes - if (show_aabb) - { - out_draw_list->AddRect(ImFloor(clip_rect.Min), ImFloor(clip_rect.Max), IM_COL32(255, 0, 255, 255)); // In pink: clipping rectangle submitted to GPU - out_draw_list->AddRect(ImFloor(vtxs_rect.Min), ImFloor(vtxs_rect.Max), IM_COL32(0, 255, 255, 255)); // In cyan: bounding box of triangles - } - out_draw_list->Flags = backup_flags; -} - -// [DEBUG] Display details for a single font, called by ShowStyleEditor(). -void ImGui::DebugNodeFont(ImFont* font) -{ - bool opened = TreeNode(font, "Font: \"%s\"\n%.2f px, %d glyphs, %d file(s)", - font->ConfigData ? font->ConfigData[0].Name : "", font->FontSize, font->Glyphs.Size, font->ConfigDataCount); - SameLine(); - if (SmallButton("Set as default")) - GetIO().FontDefault = font; - if (!opened) - return; - - // Display preview text - PushFont(font); - Text("The quick brown fox jumps over the lazy dog"); - PopFont(); - - // Display details - SetNextItemWidth(GetFontSize() * 8); - DragFloat("Font scale", &font->Scale, 0.005f, 0.3f, 2.0f, "%.1f"); - SameLine(); MetricsHelpMarker( - "Note than the default embedded font is NOT meant to be scaled.\n\n" - "Font are currently rendered into bitmaps at a given size at the time of building the atlas. " - "You may oversample them to get some flexibility with scaling. " - "You can also render at multiple sizes and select which one to use at runtime.\n\n" - "(Glimmer of hope: the atlas system will be rewritten in the future to make scaling more flexible.)"); - Text("Ascent: %f, Descent: %f, Height: %f", font->Ascent, font->Descent, font->Ascent - font->Descent); - char c_str[5]; - Text("Fallback character: '%s' (U+%04X)", ImTextCharToUtf8(c_str, font->FallbackChar), font->FallbackChar); - Text("Ellipsis character: '%s' (U+%04X)", ImTextCharToUtf8(c_str, font->EllipsisChar), font->EllipsisChar); - const int surface_sqrt = (int)ImSqrt((float)font->MetricsTotalSurface); - Text("Texture Area: about %d px ~%dx%d px", font->MetricsTotalSurface, surface_sqrt, surface_sqrt); - for (int config_i = 0; config_i < font->ConfigDataCount; config_i++) - if (font->ConfigData) - if (const ImFontConfig* cfg = &font->ConfigData[config_i]) - BulletText("Input %d: \'%s\', Oversample: (%d,%d), PixelSnapH: %d, Offset: (%.1f,%.1f)", - config_i, cfg->Name, cfg->OversampleH, cfg->OversampleV, cfg->PixelSnapH, cfg->GlyphOffset.x, cfg->GlyphOffset.y); - - // Display all glyphs of the fonts in separate pages of 256 characters - if (TreeNode("Glyphs", "Glyphs (%d)", font->Glyphs.Size)) - { - ImDrawList* draw_list = GetWindowDrawList(); - const ImU32 glyph_col = GetColorU32(ImGuiCol_Text); - const float cell_size = font->FontSize * 1; - const float cell_spacing = GetStyle().ItemSpacing.y; - for (unsigned int base = 0; base <= IM_UNICODE_CODEPOINT_MAX; base += 256) - { - // Skip ahead if a large bunch of glyphs are not present in the font (test in chunks of 4k) - // This is only a small optimization to reduce the number of iterations when IM_UNICODE_MAX_CODEPOINT - // is large // (if ImWchar==ImWchar32 we will do at least about 272 queries here) - if (!(base & 4095) && font->IsGlyphRangeUnused(base, base + 4095)) - { - base += 4096 - 256; - continue; - } - - int count = 0; - for (unsigned int n = 0; n < 256; n++) - if (font->FindGlyphNoFallback((ImWchar)(base + n))) - count++; - if (count <= 0) - continue; - if (!TreeNode((void*)(intptr_t)base, "U+%04X..U+%04X (%d %s)", base, base + 255, count, count > 1 ? "glyphs" : "glyph")) - continue; - - // Draw a 16x16 grid of glyphs - ImVec2 base_pos = GetCursorScreenPos(); - for (unsigned int n = 0; n < 256; n++) - { - // We use ImFont::RenderChar as a shortcut because we don't have UTF-8 conversion functions - // available here and thus cannot easily generate a zero-terminated UTF-8 encoded string. - ImVec2 cell_p1(base_pos.x + (n % 16) * (cell_size + cell_spacing), base_pos.y + (n / 16) * (cell_size + cell_spacing)); - ImVec2 cell_p2(cell_p1.x + cell_size, cell_p1.y + cell_size); - const ImFontGlyph* glyph = font->FindGlyphNoFallback((ImWchar)(base + n)); - draw_list->AddRect(cell_p1, cell_p2, glyph ? IM_COL32(255, 255, 255, 100) : IM_COL32(255, 255, 255, 50)); - if (glyph) - font->RenderChar(draw_list, cell_size, cell_p1, glyph_col, (ImWchar)(base + n)); - if (glyph && IsMouseHoveringRect(cell_p1, cell_p2)) - { - BeginTooltip(); - Text("Codepoint: U+%04X", base + n); - Separator(); - Text("Visible: %d", glyph->Visible); - Text("AdvanceX: %.1f", glyph->AdvanceX); - Text("Pos: (%.2f,%.2f)->(%.2f,%.2f)", glyph->X0, glyph->Y0, glyph->X1, glyph->Y1); - Text("UV: (%.3f,%.3f)->(%.3f,%.3f)", glyph->U0, glyph->V0, glyph->U1, glyph->V1); - EndTooltip(); - } - } - Dummy(ImVec2((cell_size + cell_spacing) * 16, (cell_size + cell_spacing) * 16)); - TreePop(); - } - TreePop(); - } - TreePop(); -} - -// [DEBUG] Display contents of ImGuiStorage -void ImGui::DebugNodeStorage(ImGuiStorage* storage, const char* label) -{ - if (!TreeNode(label, "%s: %d entries, %d bytes", label, storage->Data.Size, storage->Data.size_in_bytes())) - return; - for (int n = 0; n < storage->Data.Size; n++) - { - const ImGuiStorage::ImGuiStoragePair& p = storage->Data[n]; - BulletText("Key 0x%08X Value { i: %d }", p.key, p.val_i); // Important: we currently don't store a type, real value may not be integer. - } - TreePop(); -} - -// [DEBUG] Display contents of ImGuiTabBar -void ImGui::DebugNodeTabBar(ImGuiTabBar* tab_bar, const char* label) -{ - // Standalone tab bars (not associated to docking/windows functionality) currently hold no discernible strings. - char buf[256]; - char* p = buf; - const char* buf_end = buf + IM_ARRAYSIZE(buf); - const bool is_active = (tab_bar->PrevFrameVisible >= GetFrameCount() - 2); - p += ImFormatString(p, buf_end - p, "%s 0x%08X (%d tabs)%s", label, tab_bar->ID, tab_bar->Tabs.Size, is_active ? "" : " *Inactive*"); - p += ImFormatString(p, buf_end - p, " { "); - for (int tab_n = 0; tab_n < ImMin(tab_bar->Tabs.Size, 3); tab_n++) - { - ImGuiTabItem* tab = &tab_bar->Tabs[tab_n]; - p += ImFormatString(p, buf_end - p, "%s'%s'", - tab_n > 0 ? ", " : "", (tab->NameOffset != -1) ? tab_bar->GetTabName(tab) : "???"); - } - p += ImFormatString(p, buf_end - p, (tab_bar->Tabs.Size > 3) ? " ... }" : " } "); - if (!is_active) { PushStyleColor(ImGuiCol_Text, GetStyleColorVec4(ImGuiCol_TextDisabled)); } - bool open = TreeNode(label, "%s", buf); - if (!is_active) { PopStyleColor(); } - if (is_active && IsItemHovered()) - { - ImDrawList* draw_list = GetForegroundDrawList(); - draw_list->AddRect(tab_bar->BarRect.Min, tab_bar->BarRect.Max, IM_COL32(255, 255, 0, 255)); - draw_list->AddLine(ImVec2(tab_bar->ScrollingRectMinX, tab_bar->BarRect.Min.y), ImVec2(tab_bar->ScrollingRectMinX, tab_bar->BarRect.Max.y), IM_COL32(0, 255, 0, 255)); - draw_list->AddLine(ImVec2(tab_bar->ScrollingRectMaxX, tab_bar->BarRect.Min.y), ImVec2(tab_bar->ScrollingRectMaxX, tab_bar->BarRect.Max.y), IM_COL32(0, 255, 0, 255)); - } - if (open) - { - for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++) - { - const ImGuiTabItem* tab = &tab_bar->Tabs[tab_n]; - PushID(tab); - if (SmallButton("<")) { TabBarQueueReorder(tab_bar, tab, -1); } SameLine(0, 2); - if (SmallButton(">")) { TabBarQueueReorder(tab_bar, tab, +1); } SameLine(); - Text("%02d%c Tab 0x%08X '%s' Offset: %.1f, Width: %.1f/%.1f", - tab_n, (tab->ID == tab_bar->SelectedTabId) ? '*' : ' ', tab->ID, (tab->NameOffset != -1) ? tab_bar->GetTabName(tab) : "???", tab->Offset, tab->Width, tab->ContentWidth); - PopID(); - } - TreePop(); - } -} - -void ImGui::DebugNodeViewport(ImGuiViewportP* viewport) -{ - SetNextItemOpen(true, ImGuiCond_Once); - if (TreeNode("viewport0", "Viewport #%d", 0)) - { - ImGuiWindowFlags flags = viewport->Flags; - BulletText("Main Pos: (%.0f,%.0f), Size: (%.0f,%.0f)\nWorkArea Offset Left: %.0f Top: %.0f, Right: %.0f, Bottom: %.0f", - viewport->Pos.x, viewport->Pos.y, viewport->Size.x, viewport->Size.y, - viewport->WorkOffsetMin.x, viewport->WorkOffsetMin.y, viewport->WorkOffsetMax.x, viewport->WorkOffsetMax.y); - BulletText("Flags: 0x%04X =%s%s%s", viewport->Flags, - (flags & ImGuiViewportFlags_IsPlatformWindow) ? " IsPlatformWindow" : "", - (flags & ImGuiViewportFlags_IsPlatformMonitor) ? " IsPlatformMonitor" : "", - (flags & ImGuiViewportFlags_OwnedByApp) ? " OwnedByApp" : ""); - for (int layer_i = 0; layer_i < IM_ARRAYSIZE(viewport->DrawDataBuilder.Layers); layer_i++) - for (int draw_list_i = 0; draw_list_i < viewport->DrawDataBuilder.Layers[layer_i].Size; draw_list_i++) - DebugNodeDrawList(NULL, viewport->DrawDataBuilder.Layers[layer_i][draw_list_i], "DrawList"); - TreePop(); - } -} - -void ImGui::DebugNodeWindow(ImGuiWindow* window, const char* label) -{ - if (window == NULL) - { - BulletText("%s: NULL", label); - return; - } - - ImGuiContext& g = *GImGui; - const bool is_active = window->WasActive; - ImGuiTreeNodeFlags tree_node_flags = (window == g.NavWindow) ? ImGuiTreeNodeFlags_Selected : ImGuiTreeNodeFlags_None; - if (!is_active) { PushStyleColor(ImGuiCol_Text, GetStyleColorVec4(ImGuiCol_TextDisabled)); } - const bool open = TreeNodeEx(label, tree_node_flags, "%s '%s'%s", label, window->Name, is_active ? "" : " *Inactive*"); - if (!is_active) { PopStyleColor(); } - if (IsItemHovered() && is_active) - GetForegroundDrawList(window)->AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255, 255, 0, 255)); - if (!open) - return; - - if (window->MemoryCompacted) - TextDisabled("Note: some memory buffers have been compacted/freed."); - - ImGuiWindowFlags flags = window->Flags; - DebugNodeDrawList(window, window->DrawList, "DrawList"); - BulletText("Pos: (%.1f,%.1f), Size: (%.1f,%.1f), ContentSize (%.1f,%.1f) Ideal (%.1f,%.1f)", window->Pos.x, window->Pos.y, window->Size.x, window->Size.y, window->ContentSize.x, window->ContentSize.y, window->ContentSizeIdeal.x, window->ContentSizeIdeal.y); - BulletText("Flags: 0x%08X (%s%s%s%s%s%s%s%s%s..)", flags, - (flags & ImGuiWindowFlags_ChildWindow) ? "Child " : "", (flags & ImGuiWindowFlags_Tooltip) ? "Tooltip " : "", (flags & ImGuiWindowFlags_Popup) ? "Popup " : "", - (flags & ImGuiWindowFlags_Modal) ? "Modal " : "", (flags & ImGuiWindowFlags_ChildMenu) ? "ChildMenu " : "", (flags & ImGuiWindowFlags_NoSavedSettings) ? "NoSavedSettings " : "", - (flags & ImGuiWindowFlags_NoMouseInputs)? "NoMouseInputs":"", (flags & ImGuiWindowFlags_NoNavInputs) ? "NoNavInputs" : "", (flags & ImGuiWindowFlags_AlwaysAutoResize) ? "AlwaysAutoResize" : ""); - BulletText("Scroll: (%.2f/%.2f,%.2f/%.2f) Scrollbar:%s%s", window->Scroll.x, window->ScrollMax.x, window->Scroll.y, window->ScrollMax.y, window->ScrollbarX ? "X" : "", window->ScrollbarY ? "Y" : ""); - BulletText("Active: %d/%d, WriteAccessed: %d, BeginOrderWithinContext: %d", window->Active, window->WasActive, window->WriteAccessed, (window->Active || window->WasActive) ? window->BeginOrderWithinContext : -1); - BulletText("Appearing: %d, Hidden: %d (CanSkip %d Cannot %d), SkipItems: %d", window->Appearing, window->Hidden, window->HiddenFramesCanSkipItems, window->HiddenFramesCannotSkipItems, window->SkipItems); - for (int layer = 0; layer < ImGuiNavLayer_COUNT; layer++) - { - ImRect r = window->NavRectRel[layer]; - if (r.Min.x >= r.Max.y && r.Min.y >= r.Max.y) - { - BulletText("NavLastIds[%d]: 0x%08X", layer, window->NavLastIds[layer]); - continue; - } - BulletText("NavLastIds[%d]: 0x%08X at +(%.1f,%.1f)(%.1f,%.1f)", layer, window->NavLastIds[layer], r.Min.x, r.Min.y, r.Max.x, r.Max.y); - if (IsItemHovered()) - GetForegroundDrawList(window)->AddRect(r.Min + window->Pos, r.Max + window->Pos, IM_COL32(255, 255, 0, 255)); - } - BulletText("NavLayersActiveMask: %X, NavLastChildNavWindow: %s", window->DC.NavLayersActiveMask, window->NavLastChildNavWindow ? window->NavLastChildNavWindow->Name : "NULL"); - if (window->RootWindow != window) { DebugNodeWindow(window->RootWindow, "RootWindow"); } - if (window->ParentWindow != NULL) { DebugNodeWindow(window->ParentWindow, "ParentWindow"); } - if (window->DC.ChildWindows.Size > 0) { DebugNodeWindowsList(&window->DC.ChildWindows, "ChildWindows"); } - if (window->ColumnsStorage.Size > 0 && TreeNode("Columns", "Columns sets (%d)", window->ColumnsStorage.Size)) - { - for (int n = 0; n < window->ColumnsStorage.Size; n++) - DebugNodeColumns(&window->ColumnsStorage[n]); - TreePop(); - } - DebugNodeStorage(&window->StateStorage, "Storage"); - TreePop(); -} - -void ImGui::DebugNodeWindowSettings(ImGuiWindowSettings* settings) -{ - Text("0x%08X \"%s\" Pos (%d,%d) Size (%d,%d) Collapsed=%d", - settings->ID, settings->GetName(), settings->Pos.x, settings->Pos.y, settings->Size.x, settings->Size.y, settings->Collapsed); -} - -void ImGui::DebugNodeWindowsList(ImVector* windows, const char* label) -{ - if (!TreeNode(label, "%s (%d)", label, windows->Size)) - return; - Text("(In front-to-back order:)"); - for (int i = windows->Size - 1; i >= 0; i--) // Iterate front to back - { - PushID((*windows)[i]); - DebugNodeWindow((*windows)[i], "Window"); - PopID(); - } - TreePop(); -} - -//----------------------------------------------------------------------------- -// [SECTION] OTHER DEBUG TOOLS (ITEM PICKER, STACK TOOL) -//----------------------------------------------------------------------------- - -// [DEBUG] Item picker tool - start with DebugStartItemPicker() - useful to visually select an item and break into its call-stack. -void ImGui::UpdateDebugToolItemPicker() -{ - ImGuiContext& g = *GImGui; - g.DebugItemPickerBreakId = 0; - if (!g.DebugItemPickerActive) - return; - - const ImGuiID hovered_id = g.HoveredIdPreviousFrame; - SetMouseCursor(ImGuiMouseCursor_Hand); - if (IsKeyPressedMap(ImGuiKey_Escape)) - g.DebugItemPickerActive = false; - if (IsMouseClicked(0) && hovered_id) - { - g.DebugItemPickerBreakId = hovered_id; - g.DebugItemPickerActive = false; - } - SetNextWindowBgAlpha(0.60f); - BeginTooltip(); - Text("HoveredId: 0x%08X", hovered_id); - Text("Press ESC to abort picking."); - TextColored(GetStyleColorVec4(hovered_id ? ImGuiCol_Text : ImGuiCol_TextDisabled), "Click to break in debugger!"); - EndTooltip(); -} - -// [DEBUG] Stack Tool: update queries. Called by NewFrame() -void ImGui::UpdateDebugToolStackQueries() -{ - ImGuiContext& g = *GImGui; - ImGuiStackTool* tool = &g.DebugStackTool; - - // Clear hook when stack tool is not visible - g.DebugHookIdInfo = 0; - if (g.FrameCount != tool->LastActiveFrame + 1) - return; - - // Update queries. The steps are: -1: query Stack, >= 0: query each stack item - // We can only perform 1 ID Info query every frame. This is designed so the GetID() tests are cheap and constant-time - const ImGuiID query_id = g.ActiveId ? g.ActiveId : g.HoveredIdPreviousFrame; - if (tool->QueryId != query_id) - { - tool->QueryId = query_id; - tool->StackLevel = -1; - tool->Results.resize(0); - } - if (query_id == 0) - return; - - // Advance to next stack level when we got our result, or after 2 frames (in case we never get a result) - int stack_level = tool->StackLevel; - if (stack_level >= 0 && stack_level < tool->Results.Size) - if (tool->Results[stack_level].QuerySuccess || tool->Results[stack_level].QueryFrameCount > 2) - tool->StackLevel++; - - // Update hook - stack_level = tool->StackLevel; - if (stack_level == -1) - g.DebugHookIdInfo = query_id; - if (stack_level >= 0 && stack_level < tool->Results.Size) - { - g.DebugHookIdInfo = tool->Results[stack_level].ID; - tool->Results[stack_level].QueryFrameCount++; - } -} - -// [DEBUG] Stack tool: hooks called by GetID() family functions -void ImGui::DebugHookIdInfo(ImGuiID id, ImGuiDataType data_type, const void* data_id, const void* data_id_end) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - ImGuiStackTool* tool = &g.DebugStackTool; - - // Step 0: stack query - // This assume that the ID was computed with the current ID stack, which tends to be the case for our widget. - if (tool->StackLevel == -1) - { - tool->StackLevel++; - tool->Results.resize(window->IDStack.Size + 1, ImGuiStackLevelInfo()); - for (int n = 0; n < window->IDStack.Size + 1; n++) - tool->Results[n].ID = (n < window->IDStack.Size) ? window->IDStack[n] : id; - return; - } - - // Step 1+: query for individual level - IM_ASSERT(tool->StackLevel >= 0); - if (tool->StackLevel != window->IDStack.Size) - return; - ImGuiStackLevelInfo* info = &tool->Results[tool->StackLevel]; - IM_ASSERT(info->ID == id && info->QueryFrameCount > 0); - - int data_len; - switch (data_type) - { - case ImGuiDataType_S32: - ImFormatString(info->Desc, IM_ARRAYSIZE(info->Desc), "%d", (int)(intptr_t)data_id); - break; - case ImGuiDataType_String: - data_len = data_id_end ? (int)((const char*)data_id_end - (const char*)data_id) : (int)strlen((const char*)data_id); - ImFormatString(info->Desc, IM_ARRAYSIZE(info->Desc), "\"%.*s\"", data_len, (const char*)data_id); - break; - case ImGuiDataType_Pointer: - ImFormatString(info->Desc, IM_ARRAYSIZE(info->Desc), "(void*)0x%p", data_id); - break; - case ImGuiDataType_ID: - if (info->Desc[0] == 0) // PushOverrideID() is often used to avoid hashing twice, which would lead to 2 calls to DebugHookIdInfo(). We prioritize the first one. - ImFormatString(info->Desc, IM_ARRAYSIZE(info->Desc), "0x%08X [override]", id); - break; - default: - IM_ASSERT(0); - } - info->QuerySuccess = true; -} - -// Stack Tool: Display UI -void ImGui::ShowStackToolWindow(bool* p_open) -{ - if (!Begin("Dear ImGui Stack Tool", p_open) || GetCurrentWindow()->BeginCount > 1) - { - End(); - return; - } - - // Display hovered/active status - ImGuiContext& g = *GImGui; - const ImGuiID hovered_id = g.HoveredIdPreviousFrame; - const ImGuiID active_id = g.ActiveId; -#ifdef IMGUI_ENABLE_TEST_ENGINE - Text("HoveredId: 0x%08X (\"%s\"), ActiveId: 0x%08X (\"%s\")", hovered_id, hovered_id ? ImGuiTestEngine_FindItemDebugLabel(&g, hovered_id) : "", active_id, active_id ? ImGuiTestEngine_FindItemDebugLabel(&g, active_id) : ""); -#else - Text("HoveredId: 0x%08X, ActiveId: 0x%08X", hovered_id, active_id); -#endif - SameLine(); - MetricsHelpMarker("Hover an item with the mouse to display elements of the ID Stack leading to the item's final ID.\nEach level of the stack correspond to a PushID() call.\nAll levels of the stack are hashed together to make the final ID of a widget (ID displayed at the bottom level of the stack).\nRead FAQ entry about the ID stack for details."); - - // Display decorated stack - ImGuiStackTool* tool = &g.DebugStackTool; - tool->LastActiveFrame = g.FrameCount; - if (tool->Results.Size > 0 && BeginTable("##table", 3, ImGuiTableFlags_Borders)) - { - const float id_width = CalcTextSize("0xDDDDDDDD").x; - TableSetupColumn("Seed", ImGuiTableColumnFlags_WidthFixed, id_width); - TableSetupColumn("PushID", ImGuiTableColumnFlags_WidthStretch); - TableSetupColumn("Result", ImGuiTableColumnFlags_WidthFixed, id_width); - TableHeadersRow(); - for (int n = 0; n < tool->Results.Size; n++) - { - ImGuiStackLevelInfo* info = &tool->Results[n]; - TableNextColumn(); - Text("0x%08X", (n > 0) ? tool->Results[n - 1].ID : 0); - - TableNextColumn(); - ImGuiWindow* window = (info->Desc[0] == 0 && n == 0) ? FindWindowByID(info->ID) : NULL; - if (window) // Source: window name (because the root ID don't call GetID() and so doesn't get hooked) - Text("\"%s\" [window]", window->Name); - else if (info->QuerySuccess) // Source: GetID() hooks (prioritize over ItemInfo() because we frequently use patterns like: PushID(str), Button("") where they both have same id) - TextUnformatted(info->Desc); - else if (tool->StackLevel >= tool->Results.Size) // Only start using fallback below when all queries are done, so during queries we don't flickering ??? markers. - { -#ifdef IMGUI_ENABLE_TEST_ENGINE - if (const char* label = ImGuiTestEngine_FindItemDebugLabel(&g, info->ID)) // Source: ImGuiTestEngine's ItemInfo() - Text("??? \"%s\"", label); - else -#endif - TextUnformatted("???"); - } - - TableNextColumn(); - Text("0x%08X", info->ID); - if (n == tool->Results.Size - 1) - TableSetBgColor(ImGuiTableBgTarget_CellBg, GetColorU32(ImGuiCol_Header)); - } - EndTable(); - } - End(); -} - -#else - -void ImGui::ShowMetricsWindow(bool*) {} -void ImGui::ShowFontAtlas(ImFontAtlas*) {} -void ImGui::DebugNodeColumns(ImGuiOldColumns*) {} -void ImGui::DebugNodeDrawList(ImGuiWindow*, const ImDrawList*, const char*) {} -void ImGui::DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList*, const ImDrawList*, const ImDrawCmd*, bool, bool) {} -void ImGui::DebugNodeFont(ImFont*) {} -void ImGui::DebugNodeStorage(ImGuiStorage*, const char*) {} -void ImGui::DebugNodeTabBar(ImGuiTabBar*, const char*) {} -void ImGui::DebugNodeWindow(ImGuiWindow*, const char*) {} -void ImGui::DebugNodeWindowSettings(ImGuiWindowSettings*) {} -void ImGui::DebugNodeWindowsList(ImVector*, const char*) {} -void ImGui::DebugNodeViewport(ImGuiViewportP*) {} - -void ImGui::ShowStackToolWindow(bool*) {} -void ImGui::DebugHookIdInfo(ImGuiID, ImGuiDataType, const void*, const void*) {} -void ImGui::UpdateDebugToolItemPicker() {} -void ImGui::UpdateDebugToolStackQueries() {} - -#endif // #ifndef IMGUI_DISABLE_METRICS_WINDOW - -//----------------------------------------------------------------------------- - -// Include imgui_user.inl at the end of imgui.cpp to access private data/functions that aren't exposed. -// Prefer just including imgui_internal.h from your code rather than using this define. If a declaration is missing from imgui_internal.h add it or request it on the github. -#ifdef IMGUI_INCLUDE_IMGUI_USER_INL -#include "imgui_user.inl" -#endif - -//----------------------------------------------------------------------------- - -#endif // #ifndef IMGUI_DISABLE diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imgui.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imgui.h deleted file mode 100644 index f260639..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imgui.h +++ /dev/null @@ -1,2911 +0,0 @@ -// dear imgui, v1.85 -// (headers) - -// Help: -// - Read FAQ at http://dearimgui.org/faq -// - Newcomers, read 'Programmer guide' in imgui.cpp for notes on how to setup Dear ImGui in your codebase. -// - Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp. All applications in examples/ are doing that. -// Read imgui.cpp for details, links and comments. - -// Resources: -// - FAQ http://dearimgui.org/faq -// - Homepage & latest https://github.com/ocornut/imgui -// - Releases & changelog https://github.com/ocornut/imgui/releases -// - Gallery https://github.com/ocornut/imgui/issues/4451 (please post your screenshots/video there!) -// - Wiki https://github.com/ocornut/imgui/wiki (lots of good stuff there) -// - Glossary https://github.com/ocornut/imgui/wiki/Glossary -// - Issues & support https://github.com/ocornut/imgui/issues - -// Getting Started? -// - For first-time users having issues compiling/linking/running or issues loading fonts: -// please post in https://github.com/ocornut/imgui/discussions if you cannot find a solution in resources above. - -/* - -Index of this file: -// [SECTION] Header mess -// [SECTION] Forward declarations and basic types -// [SECTION] Dear ImGui end-user API functions -// [SECTION] Flags & Enumerations -// [SECTION] Helpers: Memory allocations macros, ImVector<> -// [SECTION] ImGuiStyle -// [SECTION] ImGuiIO -// [SECTION] Misc data structures (ImGuiInputTextCallbackData, ImGuiSizeCallbackData, ImGuiPayload, ImGuiTableSortSpecs, ImGuiTableColumnSortSpecs) -// [SECTION] Helpers (ImGuiOnceUponAFrame, ImGuiTextFilter, ImGuiTextBuffer, ImGuiStorage, ImGuiListClipper, ImColor) -// [SECTION] Drawing API (ImDrawCallback, ImDrawCmd, ImDrawIdx, ImDrawVert, ImDrawChannel, ImDrawListSplitter, ImDrawFlags, ImDrawListFlags, ImDrawList, ImDrawData) -// [SECTION] Font API (ImFontConfig, ImFontGlyph, ImFontGlyphRangesBuilder, ImFontAtlasFlags, ImFontAtlas, ImFont) -// [SECTION] Viewports (ImGuiViewportFlags, ImGuiViewport) -// [SECTION] Obsolete functions and types - -*/ - -#pragma once - -// Configuration file with compile-time options (edit imconfig.h or '#define IMGUI_USER_CONFIG "myfilename.h" from your build system') -#ifdef IMGUI_USER_CONFIG -#include IMGUI_USER_CONFIG -#endif -#if !defined(IMGUI_DISABLE_INCLUDE_IMCONFIG_H) || defined(IMGUI_INCLUDE_IMCONFIG_H) -#include "imconfig.h" -#endif - -#ifndef IMGUI_DISABLE - -//----------------------------------------------------------------------------- -// [SECTION] Header mess -//----------------------------------------------------------------------------- - -// Includes -#include // FLT_MIN, FLT_MAX -#include // va_list, va_start, va_end -#include // ptrdiff_t, NULL -#include // memset, memmove, memcpy, strlen, strchr, strcpy, strcmp - -// Version -// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens) -#define IMGUI_VERSION "1.85" -#define IMGUI_VERSION_NUM 18500 -#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx)) -#define IMGUI_HAS_TABLE - -// Define attributes of all API symbols declarations (e.g. for DLL under Windows) -// IMGUI_API is used for core imgui functions, IMGUI_IMPL_API is used for the default backends files (imgui_impl_xxx.h) -// Using dear imgui via a shared library is not recommended, because we don't guarantee backward nor forward ABI compatibility (also function call overhead, as dear imgui is a call-heavy API) -#ifndef IMGUI_API -#define IMGUI_API -#endif -#ifndef IMGUI_IMPL_API -#define IMGUI_IMPL_API IMGUI_API -#endif - -// Helper Macros -#ifndef IM_ASSERT -#include -#define IM_ASSERT(_EXPR) assert(_EXPR) // You can override the default assert handler by editing imconfig.h -#endif -#define IM_ARRAYSIZE(_ARR) ((int)(sizeof(_ARR) / sizeof(*(_ARR)))) // Size of a static C-style array. Don't use on pointers! -#define IM_UNUSED(_VAR) ((void)(_VAR)) // Used to silence "unused variable warnings". Often useful as asserts may be stripped out from final builds. -#if (__cplusplus >= 201100) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201100) -#define IM_OFFSETOF(_TYPE,_MEMBER) offsetof(_TYPE, _MEMBER) // Offset of _MEMBER within _TYPE. Standardized as offsetof() in C++11 -#else -#define IM_OFFSETOF(_TYPE,_MEMBER) ((size_t)&(((_TYPE*)0)->_MEMBER)) // Offset of _MEMBER within _TYPE. Old style macro. -#endif - -// Helper Macros - IM_FMTARGS, IM_FMTLIST: Apply printf-style warnings to our formatting functions. -#if !defined(IMGUI_USE_STB_SPRINTF) && defined(__MINGW32__) && !defined(__clang__) -#define IM_FMTARGS(FMT) __attribute__((format(gnu_printf, FMT, FMT+1))) -#define IM_FMTLIST(FMT) __attribute__((format(gnu_printf, FMT, 0))) -#elif !defined(IMGUI_USE_STB_SPRINTF) && (defined(__clang__) || defined(__GNUC__)) -#define IM_FMTARGS(FMT) __attribute__((format(printf, FMT, FMT+1))) -#define IM_FMTLIST(FMT) __attribute__((format(printf, FMT, 0))) -#else -#define IM_FMTARGS(FMT) -#define IM_FMTLIST(FMT) -#endif - -// Disable some of MSVC most aggressive Debug runtime checks in function header/footer (used in some simple/low-level functions) -#if defined(_MSC_VER) && !defined(__clang__) && !defined(IMGUI_DEBUG_PARANOID) -#define IM_MSVC_RUNTIME_CHECKS_OFF __pragma(runtime_checks("",off)) __pragma(check_stack(off)) __pragma(strict_gs_check(push,off)) -#define IM_MSVC_RUNTIME_CHECKS_RESTORE __pragma(runtime_checks("",restore)) __pragma(check_stack()) __pragma(strict_gs_check(pop)) -#else -#define IM_MSVC_RUNTIME_CHECKS_OFF -#define IM_MSVC_RUNTIME_CHECKS_RESTORE -#endif - -// Warnings -#ifdef _MSC_VER -#pragma warning (push) -#pragma warning (disable: 26495) // [Static Analyzer] Variable 'XXX' is uninitialized. Always initialize a member variable (type.6). -#endif -#if defined(__clang__) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wold-style-cast" -#if __has_warning("-Wzero-as-null-pointer-constant") -#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" -#endif -#elif defined(__GNUC__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind -#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead -#endif - -//----------------------------------------------------------------------------- -// [SECTION] Forward declarations and basic types -//----------------------------------------------------------------------------- - -// Forward declarations -struct ImDrawChannel; // Temporary storage to output draw commands out of order, used by ImDrawListSplitter and ImDrawList::ChannelsSplit() -struct ImDrawCmd; // A single draw command within a parent ImDrawList (generally maps to 1 GPU draw call, unless it is a callback) -struct ImDrawData; // All draw command lists required to render the frame + pos/size coordinates to use for the projection matrix. -struct ImDrawList; // A single draw command list (generally one per window, conceptually you may see this as a dynamic "mesh" builder) -struct ImDrawListSharedData; // Data shared among multiple draw lists (typically owned by parent ImGui context, but you may create one yourself) -struct ImDrawListSplitter; // Helper to split a draw list into different layers which can be drawn into out of order, then flattened back. -struct ImDrawVert; // A single vertex (pos + uv + col = 20 bytes by default. Override layout with IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT) -struct ImFont; // Runtime data for a single font within a parent ImFontAtlas -struct ImFontAtlas; // Runtime data for multiple fonts, bake multiple fonts into a single texture, TTF/OTF font loader -struct ImFontBuilderIO; // Opaque interface to a font builder (stb_truetype or FreeType). -struct ImFontConfig; // Configuration data when adding a font or merging fonts -struct ImFontGlyph; // A single font glyph (code point + coordinates within in ImFontAtlas + offset) -struct ImFontGlyphRangesBuilder; // Helper to build glyph ranges from text/string data -struct ImColor; // Helper functions to create a color that can be converted to either u32 or float4 (*OBSOLETE* please avoid using) -struct ImGuiContext; // Dear ImGui context (opaque structure, unless including imgui_internal.h) -struct ImGuiIO; // Main configuration and I/O between your application and ImGui -struct ImGuiInputTextCallbackData; // Shared state of InputText() when using custom ImGuiInputTextCallback (rare/advanced use) -struct ImGuiListClipper; // Helper to manually clip large list of items -struct ImGuiOnceUponAFrame; // Helper for running a block of code not more than once a frame, used by IMGUI_ONCE_UPON_A_FRAME macro -struct ImGuiPayload; // User data payload for drag and drop operations -struct ImGuiSizeCallbackData; // Callback data when using SetNextWindowSizeConstraints() (rare/advanced use) -struct ImGuiStorage; // Helper for key->value storage -struct ImGuiStyle; // Runtime data for styling/colors -struct ImGuiTableSortSpecs; // Sorting specifications for a table (often handling sort specs for a single column, occasionally more) -struct ImGuiTableColumnSortSpecs; // Sorting specification for one column of a table -struct ImGuiTextBuffer; // Helper to hold and append into a text buffer (~string builder) -struct ImGuiTextFilter; // Helper to parse and apply text filters (e.g. "aaaaa[,bbbbb][,ccccc]") -struct ImGuiViewport; // A Platform Window (always only one in 'master' branch), in the future may represent Platform Monitor - -// Enums/Flags (declared as int for compatibility with old C++, to allow using as flags without overhead, and to not pollute the top of this file) -// - Tip: Use your programming IDE navigation facilities on the names in the _central column_ below to find the actual flags/enum lists! -// In Visual Studio IDE: CTRL+comma ("Edit.NavigateTo") can follow symbols in comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot. -// With Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols in comments. -typedef int ImGuiCol; // -> enum ImGuiCol_ // Enum: A color identifier for styling -typedef int ImGuiCond; // -> enum ImGuiCond_ // Enum: A condition for many Set*() functions -typedef int ImGuiDataType; // -> enum ImGuiDataType_ // Enum: A primary data type -typedef int ImGuiDir; // -> enum ImGuiDir_ // Enum: A cardinal direction -typedef int ImGuiKey; // -> enum ImGuiKey_ // Enum: A key identifier (ImGui-side enum) -typedef int ImGuiNavInput; // -> enum ImGuiNavInput_ // Enum: An input identifier for navigation -typedef int ImGuiMouseButton; // -> enum ImGuiMouseButton_ // Enum: A mouse button identifier (0=left, 1=right, 2=middle) -typedef int ImGuiMouseCursor; // -> enum ImGuiMouseCursor_ // Enum: A mouse cursor identifier -typedef int ImGuiSortDirection; // -> enum ImGuiSortDirection_ // Enum: A sorting direction (ascending or descending) -typedef int ImGuiStyleVar; // -> enum ImGuiStyleVar_ // Enum: A variable identifier for styling -typedef int ImGuiTableBgTarget; // -> enum ImGuiTableBgTarget_ // Enum: A color target for TableSetBgColor() -typedef int ImDrawFlags; // -> enum ImDrawFlags_ // Flags: for ImDrawList functions -typedef int ImDrawListFlags; // -> enum ImDrawListFlags_ // Flags: for ImDrawList instance -typedef int ImFontAtlasFlags; // -> enum ImFontAtlasFlags_ // Flags: for ImFontAtlas build -typedef int ImGuiBackendFlags; // -> enum ImGuiBackendFlags_ // Flags: for io.BackendFlags -typedef int ImGuiButtonFlags; // -> enum ImGuiButtonFlags_ // Flags: for InvisibleButton() -typedef int ImGuiColorEditFlags; // -> enum ImGuiColorEditFlags_ // Flags: for ColorEdit4(), ColorPicker4() etc. -typedef int ImGuiConfigFlags; // -> enum ImGuiConfigFlags_ // Flags: for io.ConfigFlags -typedef int ImGuiComboFlags; // -> enum ImGuiComboFlags_ // Flags: for BeginCombo() -typedef int ImGuiDragDropFlags; // -> enum ImGuiDragDropFlags_ // Flags: for BeginDragDropSource(), AcceptDragDropPayload() -typedef int ImGuiFocusedFlags; // -> enum ImGuiFocusedFlags_ // Flags: for IsWindowFocused() -typedef int ImGuiHoveredFlags; // -> enum ImGuiHoveredFlags_ // Flags: for IsItemHovered(), IsWindowHovered() etc. -typedef int ImGuiInputTextFlags; // -> enum ImGuiInputTextFlags_ // Flags: for InputText(), InputTextMultiline() -typedef int ImGuiKeyModFlags; // -> enum ImGuiKeyModFlags_ // Flags: for io.KeyMods (Ctrl/Shift/Alt/Super) -typedef int ImGuiPopupFlags; // -> enum ImGuiPopupFlags_ // Flags: for OpenPopup*(), BeginPopupContext*(), IsPopupOpen() -typedef int ImGuiSelectableFlags; // -> enum ImGuiSelectableFlags_ // Flags: for Selectable() -typedef int ImGuiSliderFlags; // -> enum ImGuiSliderFlags_ // Flags: for DragFloat(), DragInt(), SliderFloat(), SliderInt() etc. -typedef int ImGuiTabBarFlags; // -> enum ImGuiTabBarFlags_ // Flags: for BeginTabBar() -typedef int ImGuiTabItemFlags; // -> enum ImGuiTabItemFlags_ // Flags: for BeginTabItem() -typedef int ImGuiTableFlags; // -> enum ImGuiTableFlags_ // Flags: For BeginTable() -typedef int ImGuiTableColumnFlags; // -> enum ImGuiTableColumnFlags_// Flags: For TableSetupColumn() -typedef int ImGuiTableRowFlags; // -> enum ImGuiTableRowFlags_ // Flags: For TableNextRow() -typedef int ImGuiTreeNodeFlags; // -> enum ImGuiTreeNodeFlags_ // Flags: for TreeNode(), TreeNodeEx(), CollapsingHeader() -typedef int ImGuiViewportFlags; // -> enum ImGuiViewportFlags_ // Flags: for ImGuiViewport -typedef int ImGuiWindowFlags; // -> enum ImGuiWindowFlags_ // Flags: for Begin(), BeginChild() - -// ImTexture: user data for renderer backend to identify a texture [Compile-time configurable type] -// - To use something else than an opaque void* pointer: override with e.g. '#define ImTextureID MyTextureType*' in your imconfig.h file. -// - This can be whatever to you want it to be! read the FAQ about ImTextureID for details. -#ifndef ImTextureID -typedef void* ImTextureID; // Default: store a pointer or an integer fitting in a pointer (most renderer backends are ok with that) -#endif - -// ImDrawIdx: vertex index. [Compile-time configurable type] -// - To use 16-bit indices + allow large meshes: backend need to set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset' and handle ImDrawCmd::VtxOffset (recommended). -// - To use 32-bit indices: override with '#define ImDrawIdx unsigned int' in your imconfig.h file. -#ifndef ImDrawIdx -typedef unsigned short ImDrawIdx; // Default: 16-bit (for maximum compatibility with renderer backends) -#endif - -// Scalar data types -typedef unsigned int ImGuiID;// A unique ID used by widgets (typically the result of hashing a stack of string) -typedef signed char ImS8; // 8-bit signed integer -typedef unsigned char ImU8; // 8-bit unsigned integer -typedef signed short ImS16; // 16-bit signed integer -typedef unsigned short ImU16; // 16-bit unsigned integer -typedef signed int ImS32; // 32-bit signed integer == int -typedef unsigned int ImU32; // 32-bit unsigned integer (often used to store packed colors) -#if defined(_MSC_VER) && !defined(__clang__) -typedef signed __int64 ImS64; // 64-bit signed integer (pre and post C++11 with Visual Studio) -typedef unsigned __int64 ImU64; // 64-bit unsigned integer (pre and post C++11 with Visual Studio) -#elif (defined(__clang__) || defined(__GNUC__)) && (__cplusplus < 201100) -#include -typedef int64_t ImS64; // 64-bit signed integer (pre C++11) -typedef uint64_t ImU64; // 64-bit unsigned integer (pre C++11) -#else -typedef signed long long ImS64; // 64-bit signed integer (post C++11) -typedef unsigned long long ImU64; // 64-bit unsigned integer (post C++11) -#endif - -// Character types -// (we generally use UTF-8 encoded string in the API. This is storage specifically for a decoded character used for keyboard input and display) -typedef unsigned short ImWchar16; // A single decoded U16 character/code point. We encode them as multi bytes UTF-8 when used in strings. -typedef unsigned int ImWchar32; // A single decoded U32 character/code point. We encode them as multi bytes UTF-8 when used in strings. -#ifdef IMGUI_USE_WCHAR32 // ImWchar [configurable type: override in imconfig.h with '#define IMGUI_USE_WCHAR32' to support Unicode planes 1-16] -typedef ImWchar32 ImWchar; -#else -typedef ImWchar16 ImWchar; -#endif - -// Callback and functions types -typedef int (*ImGuiInputTextCallback)(ImGuiInputTextCallbackData* data); // Callback function for ImGui::InputText() -typedef void (*ImGuiSizeCallback)(ImGuiSizeCallbackData* data); // Callback function for ImGui::SetNextWindowSizeConstraints() -typedef void* (*ImGuiMemAllocFunc)(size_t sz, void* user_data); // Function signature for ImGui::SetAllocatorFunctions() -typedef void (*ImGuiMemFreeFunc)(void* ptr, void* user_data); // Function signature for ImGui::SetAllocatorFunctions() - -// ImVec2: 2D vector used to store positions, sizes etc. [Compile-time configurable type] -// This is a frequently used type in the API. Consider using IM_VEC2_CLASS_EXTRA to create implicit cast from/to our preferred type. -IM_MSVC_RUNTIME_CHECKS_OFF -struct ImVec2 -{ - float x, y; - ImVec2() { x = y = 0.0f; } - ImVec2(float _x, float _y) { x = _x; y = _y; } - float operator[] (size_t idx) const { IM_ASSERT(idx <= 1); return (&x)[idx]; } // We very rarely use this [] operator, the assert overhead is fine. - float& operator[] (size_t idx) { IM_ASSERT(idx <= 1); return (&x)[idx]; } // We very rarely use this [] operator, the assert overhead is fine. -#ifdef IM_VEC2_CLASS_EXTRA - IM_VEC2_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between your math types and ImVec2. -#endif -}; - -// ImVec4: 4D vector used to store clipping rectangles, colors etc. [Compile-time configurable type] -struct ImVec4 -{ - float x, y, z, w; - ImVec4() { x = y = z = w = 0.0f; } - ImVec4(float _x, float _y, float _z, float _w) { x = _x; y = _y; z = _z; w = _w; } -#ifdef IM_VEC4_CLASS_EXTRA - IM_VEC4_CLASS_EXTRA // Define additional constructors and implicit cast operators in imconfig.h to convert back and forth between your math types and ImVec4. -#endif -}; -IM_MSVC_RUNTIME_CHECKS_RESTORE - -//----------------------------------------------------------------------------- -// [SECTION] Dear ImGui end-user API functions -// (Note that ImGui:: being a namespace, you can add extra ImGui:: functions in your own separate file. Please don't modify imgui source files!) -//----------------------------------------------------------------------------- - -namespace ImGui -{ - // Context creation and access - // - Each context create its own ImFontAtlas by default. You may instance one yourself and pass it to CreateContext() to share a font atlas between contexts. - // - DLL users: heaps and globals are not shared across DLL boundaries! You will need to call SetCurrentContext() + SetAllocatorFunctions() - // for each static/DLL boundary you are calling from. Read "Context and Memory Allocators" section of imgui.cpp for details. - IMGUI_API ImGuiContext* CreateContext(ImFontAtlas* shared_font_atlas = NULL); - IMGUI_API void DestroyContext(ImGuiContext* ctx = NULL); // NULL = destroy current context - IMGUI_API ImGuiContext* GetCurrentContext(); - IMGUI_API void SetCurrentContext(ImGuiContext* ctx); - - // Main - IMGUI_API ImGuiIO& GetIO(); // access the IO structure (mouse/keyboard/gamepad inputs, time, various configuration options/flags) - IMGUI_API ImGuiStyle& GetStyle(); // access the Style structure (colors, sizes). Always use PushStyleCol(), PushStyleVar() to modify style mid-frame! - IMGUI_API void NewFrame(); // start a new Dear ImGui frame, you can submit any command from this point until Render()/EndFrame(). - IMGUI_API void EndFrame(); // ends the Dear ImGui frame. automatically called by Render(). If you don't need to render data (skipping rendering) you may call EndFrame() without Render()... but you'll have wasted CPU already! If you don't need to render, better to not create any windows and not call NewFrame() at all! - IMGUI_API void Render(); // ends the Dear ImGui frame, finalize the draw data. You can then get call GetDrawData(). - IMGUI_API ImDrawData* GetDrawData(); // valid after Render() and until the next call to NewFrame(). this is what you have to render. - - // Demo, Debug, Information - IMGUI_API void ShowDemoWindow(bool* p_open = NULL); // create Demo window. demonstrate most ImGui features. call this to learn about the library! try to make it always available in your application! - IMGUI_API void ShowMetricsWindow(bool* p_open = NULL); // create Metrics/Debugger window. display Dear ImGui internals: windows, draw commands, various internal state, etc. - IMGUI_API void ShowStackToolWindow(bool* p_open = NULL); // create Stack Tool window. hover items with mouse to query information about the source of their unique ID. - IMGUI_API void ShowAboutWindow(bool* p_open = NULL); // create About window. display Dear ImGui version, credits and build/system information. - IMGUI_API void ShowStyleEditor(ImGuiStyle* ref = NULL); // add style editor block (not a window). you can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it uses the default style) - IMGUI_API bool ShowStyleSelector(const char* label); // add style selector block (not a window), essentially a combo listing the default styles. - IMGUI_API void ShowFontSelector(const char* label); // add font selector block (not a window), essentially a combo listing the loaded fonts. - IMGUI_API void ShowUserGuide(); // add basic help/info block (not a window): how to manipulate ImGui as a end-user (mouse/keyboard controls). - IMGUI_API const char* GetVersion(); // get the compiled version string e.g. "1.80 WIP" (essentially the value for IMGUI_VERSION from the compiled version of imgui.cpp) - - // Styles - IMGUI_API void StyleColorsDark(ImGuiStyle* dst = NULL); // new, recommended style (default) - IMGUI_API void StyleColorsLight(ImGuiStyle* dst = NULL); // best used with borders and a custom, thicker font - IMGUI_API void StyleColorsClassic(ImGuiStyle* dst = NULL); // classic imgui style - - // Windows - // - Begin() = push window to the stack and start appending to it. End() = pop window from the stack. - // - Passing 'bool* p_open != NULL' shows a window-closing widget in the upper-right corner of the window, - // which clicking will set the boolean to false when clicked. - // - You may append multiple times to the same window during the same frame by calling Begin()/End() pairs multiple times. - // Some information such as 'flags' or 'p_open' will only be considered by the first call to Begin(). - // - Begin() return false to indicate the window is collapsed or fully clipped, so you may early out and omit submitting - // anything to the window. Always call a matching End() for each Begin() call, regardless of its return value! - // [Important: due to legacy reason, this is inconsistent with most other functions such as BeginMenu/EndMenu, - // BeginPopup/EndPopup, etc. where the EndXXX call should only be called if the corresponding BeginXXX function - // returned true. Begin and BeginChild are the only odd ones out. Will be fixed in a future update.] - // - Note that the bottom of window stack always contains a window called "Debug". - IMGUI_API bool Begin(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0); - IMGUI_API void End(); - - // Child Windows - // - Use child windows to begin into a self-contained independent scrolling/clipping regions within a host window. Child windows can embed their own child. - // - For each independent axis of 'size': ==0.0f: use remaining host window size / >0.0f: fixed size / <0.0f: use remaining window size minus abs(size) / Each axis can use a different mode, e.g. ImVec2(0,400). - // - BeginChild() returns false to indicate the window is collapsed or fully clipped, so you may early out and omit submitting anything to the window. - // Always call a matching EndChild() for each BeginChild() call, regardless of its return value. - // [Important: due to legacy reason, this is inconsistent with most other functions such as BeginMenu/EndMenu, - // BeginPopup/EndPopup, etc. where the EndXXX call should only be called if the corresponding BeginXXX function - // returned true. Begin and BeginChild are the only odd ones out. Will be fixed in a future update.] - IMGUI_API bool BeginChild(const char* str_id, const ImVec2& size = ImVec2(0, 0), bool border = false, ImGuiWindowFlags flags = 0); - IMGUI_API bool BeginChild(ImGuiID id, const ImVec2& size = ImVec2(0, 0), bool border = false, ImGuiWindowFlags flags = 0); - IMGUI_API void EndChild(); - - // Windows Utilities - // - 'current window' = the window we are appending into while inside a Begin()/End() block. 'next window' = next window we will Begin() into. - IMGUI_API bool IsWindowAppearing(); - IMGUI_API bool IsWindowCollapsed(); - IMGUI_API bool IsWindowFocused(ImGuiFocusedFlags flags=0); // is current window focused? or its root/child, depending on flags. see flags for options. - IMGUI_API bool IsWindowHovered(ImGuiHoveredFlags flags=0); // is current window hovered (and typically: not blocked by a popup/modal)? see flags for options. NB: If you are trying to check whether your mouse should be dispatched to imgui or to your app, you should use the 'io.WantCaptureMouse' boolean for that! Please read the FAQ! - IMGUI_API ImDrawList* GetWindowDrawList(); // get draw list associated to the current window, to append your own drawing primitives - IMGUI_API ImVec2 GetWindowPos(); // get current window position in screen space (useful if you want to do your own drawing via the DrawList API) - IMGUI_API ImVec2 GetWindowSize(); // get current window size - IMGUI_API float GetWindowWidth(); // get current window width (shortcut for GetWindowSize().x) - IMGUI_API float GetWindowHeight(); // get current window height (shortcut for GetWindowSize().y) - - // Window manipulation - // - Prefer using SetNextXXX functions (before Begin) rather that SetXXX functions (after Begin). - IMGUI_API void SetNextWindowPos(const ImVec2& pos, ImGuiCond cond = 0, const ImVec2& pivot = ImVec2(0, 0)); // set next window position. call before Begin(). use pivot=(0.5f,0.5f) to center on given point, etc. - IMGUI_API void SetNextWindowSize(const ImVec2& size, ImGuiCond cond = 0); // set next window size. set axis to 0.0f to force an auto-fit on this axis. call before Begin() - IMGUI_API void SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeCallback custom_callback = NULL, void* custom_callback_data = NULL); // set next window size limits. use -1,-1 on either X/Y axis to preserve the current size. Sizes will be rounded down. Use callback to apply non-trivial programmatic constraints. - IMGUI_API void SetNextWindowContentSize(const ImVec2& size); // set next window content size (~ scrollable client area, which enforce the range of scrollbars). Not including window decorations (title bar, menu bar, etc.) nor WindowPadding. set an axis to 0.0f to leave it automatic. call before Begin() - IMGUI_API void SetNextWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // set next window collapsed state. call before Begin() - IMGUI_API void SetNextWindowFocus(); // set next window to be focused / top-most. call before Begin() - IMGUI_API void SetNextWindowBgAlpha(float alpha); // set next window background color alpha. helper to easily override the Alpha component of ImGuiCol_WindowBg/ChildBg/PopupBg. you may also use ImGuiWindowFlags_NoBackground. - IMGUI_API void SetWindowPos(const ImVec2& pos, ImGuiCond cond = 0); // (not recommended) set current window position - call within Begin()/End(). prefer using SetNextWindowPos(), as this may incur tearing and side-effects. - IMGUI_API void SetWindowSize(const ImVec2& size, ImGuiCond cond = 0); // (not recommended) set current window size - call within Begin()/End(). set to ImVec2(0, 0) to force an auto-fit. prefer using SetNextWindowSize(), as this may incur tearing and minor side-effects. - IMGUI_API void SetWindowCollapsed(bool collapsed, ImGuiCond cond = 0); // (not recommended) set current window collapsed state. prefer using SetNextWindowCollapsed(). - IMGUI_API void SetWindowFocus(); // (not recommended) set current window to be focused / top-most. prefer using SetNextWindowFocus(). - IMGUI_API void SetWindowFontScale(float scale); // [OBSOLETE] set font scale. Adjust IO.FontGlobalScale if you want to scale all windows. This is an old API! For correct scaling, prefer to reload font + rebuild ImFontAtlas + call style.ScaleAllSizes(). - IMGUI_API void SetWindowPos(const char* name, const ImVec2& pos, ImGuiCond cond = 0); // set named window position. - IMGUI_API void SetWindowSize(const char* name, const ImVec2& size, ImGuiCond cond = 0); // set named window size. set axis to 0.0f to force an auto-fit on this axis. - IMGUI_API void SetWindowCollapsed(const char* name, bool collapsed, ImGuiCond cond = 0); // set named window collapsed state - IMGUI_API void SetWindowFocus(const char* name); // set named window to be focused / top-most. use NULL to remove focus. - - // Content region - // - Retrieve available space from a given point. GetContentRegionAvail() is frequently useful. - // - Those functions are bound to be redesigned (they are confusing, incomplete and the Min/Max return values are in local window coordinates which increases confusion) - IMGUI_API ImVec2 GetContentRegionAvail(); // == GetContentRegionMax() - GetCursorPos() - IMGUI_API ImVec2 GetContentRegionMax(); // current content boundaries (typically window boundaries including scrolling, or current column boundaries), in windows coordinates - IMGUI_API ImVec2 GetWindowContentRegionMin(); // content boundaries min for the full window (roughly (0,0)-Scroll), in window coordinates - IMGUI_API ImVec2 GetWindowContentRegionMax(); // content boundaries max for the full window (roughly (0,0)+Size-Scroll) where Size can be override with SetNextWindowContentSize(), in window coordinates - - // Windows Scrolling - IMGUI_API float GetScrollX(); // get scrolling amount [0 .. GetScrollMaxX()] - IMGUI_API float GetScrollY(); // get scrolling amount [0 .. GetScrollMaxY()] - IMGUI_API void SetScrollX(float scroll_x); // set scrolling amount [0 .. GetScrollMaxX()] - IMGUI_API void SetScrollY(float scroll_y); // set scrolling amount [0 .. GetScrollMaxY()] - IMGUI_API float GetScrollMaxX(); // get maximum scrolling amount ~~ ContentSize.x - WindowSize.x - DecorationsSize.x - IMGUI_API float GetScrollMaxY(); // get maximum scrolling amount ~~ ContentSize.y - WindowSize.y - DecorationsSize.y - IMGUI_API void SetScrollHereX(float center_x_ratio = 0.5f); // adjust scrolling amount to make current cursor position visible. center_x_ratio=0.0: left, 0.5: center, 1.0: right. When using to make a "default/current item" visible, consider using SetItemDefaultFocus() instead. - IMGUI_API void SetScrollHereY(float center_y_ratio = 0.5f); // adjust scrolling amount to make current cursor position visible. center_y_ratio=0.0: top, 0.5: center, 1.0: bottom. When using to make a "default/current item" visible, consider using SetItemDefaultFocus() instead. - IMGUI_API void SetScrollFromPosX(float local_x, float center_x_ratio = 0.5f); // adjust scrolling amount to make given position visible. Generally GetCursorStartPos() + offset to compute a valid position. - IMGUI_API void SetScrollFromPosY(float local_y, float center_y_ratio = 0.5f); // adjust scrolling amount to make given position visible. Generally GetCursorStartPos() + offset to compute a valid position. - - // Parameters stacks (shared) - IMGUI_API void PushFont(ImFont* font); // use NULL as a shortcut to push default font - IMGUI_API void PopFont(); - IMGUI_API void PushStyleColor(ImGuiCol idx, ImU32 col); // modify a style color. always use this if you modify the style after NewFrame(). - IMGUI_API void PushStyleColor(ImGuiCol idx, const ImVec4& col); - IMGUI_API void PopStyleColor(int count = 1); - IMGUI_API void PushStyleVar(ImGuiStyleVar idx, float val); // modify a style float variable. always use this if you modify the style after NewFrame(). - IMGUI_API void PushStyleVar(ImGuiStyleVar idx, const ImVec2& val); // modify a style ImVec2 variable. always use this if you modify the style after NewFrame(). - IMGUI_API void PopStyleVar(int count = 1); - IMGUI_API void PushAllowKeyboardFocus(bool allow_keyboard_focus); // == tab stop enable. Allow focusing using TAB/Shift-TAB, enabled by default but you can disable it for certain widgets - IMGUI_API void PopAllowKeyboardFocus(); - IMGUI_API void PushButtonRepeat(bool repeat); // in 'repeat' mode, Button*() functions return repeated true in a typematic manner (using io.KeyRepeatDelay/io.KeyRepeatRate setting). Note that you can call IsItemActive() after any Button() to tell if the button is held in the current frame. - IMGUI_API void PopButtonRepeat(); - - // Parameters stacks (current window) - IMGUI_API void PushItemWidth(float item_width); // push width of items for common large "item+label" widgets. >0.0f: width in pixels, <0.0f align xx pixels to the right of window (so -FLT_MIN always align width to the right side). - IMGUI_API void PopItemWidth(); - IMGUI_API void SetNextItemWidth(float item_width); // set width of the _next_ common large "item+label" widget. >0.0f: width in pixels, <0.0f align xx pixels to the right of window (so -FLT_MIN always align width to the right side) - IMGUI_API float CalcItemWidth(); // width of item given pushed settings and current cursor position. NOT necessarily the width of last item unlike most 'Item' functions. - IMGUI_API void PushTextWrapPos(float wrap_local_pos_x = 0.0f); // push word-wrapping position for Text*() commands. < 0.0f: no wrapping; 0.0f: wrap to end of window (or column); > 0.0f: wrap at 'wrap_pos_x' position in window local space - IMGUI_API void PopTextWrapPos(); - - // Style read access - // - Use the style editor (ShowStyleEditor() function) to interactively see what the colors are) - IMGUI_API ImFont* GetFont(); // get current font - IMGUI_API float GetFontSize(); // get current font size (= height in pixels) of current font with current scale applied - IMGUI_API ImVec2 GetFontTexUvWhitePixel(); // get UV coordinate for a while pixel, useful to draw custom shapes via the ImDrawList API - IMGUI_API ImU32 GetColorU32(ImGuiCol idx, float alpha_mul = 1.0f); // retrieve given style color with style alpha applied and optional extra alpha multiplier, packed as a 32-bit value suitable for ImDrawList - IMGUI_API ImU32 GetColorU32(const ImVec4& col); // retrieve given color with style alpha applied, packed as a 32-bit value suitable for ImDrawList - IMGUI_API ImU32 GetColorU32(ImU32 col); // retrieve given color with style alpha applied, packed as a 32-bit value suitable for ImDrawList - IMGUI_API const ImVec4& GetStyleColorVec4(ImGuiCol idx); // retrieve style color as stored in ImGuiStyle structure. use to feed back into PushStyleColor(), otherwise use GetColorU32() to get style color with style alpha baked in. - - // Cursor / Layout - // - By "cursor" we mean the current output position. - // - The typical widget behavior is to output themselves at the current cursor position, then move the cursor one line down. - // - You can call SameLine() between widgets to undo the last carriage return and output at the right of the preceding widget. - // - Attention! We currently have inconsistencies between window-local and absolute positions we will aim to fix with future API: - // Window-local coordinates: SameLine(), GetCursorPos(), SetCursorPos(), GetCursorStartPos(), GetContentRegionMax(), GetWindowContentRegion*(), PushTextWrapPos() - // Absolute coordinate: GetCursorScreenPos(), SetCursorScreenPos(), all ImDrawList:: functions. - IMGUI_API void Separator(); // separator, generally horizontal. inside a menu bar or in horizontal layout mode, this becomes a vertical separator. - IMGUI_API void SameLine(float offset_from_start_x=0.0f, float spacing=-1.0f); // call between widgets or groups to layout them horizontally. X position given in window coordinates. - IMGUI_API void NewLine(); // undo a SameLine() or force a new line when in an horizontal-layout context. - IMGUI_API void Spacing(); // add vertical spacing. - IMGUI_API void Dummy(const ImVec2& size); // add a dummy item of given size. unlike InvisibleButton(), Dummy() won't take the mouse click or be navigable into. - IMGUI_API void Indent(float indent_w = 0.0f); // move content position toward the right, by indent_w, or style.IndentSpacing if indent_w <= 0 - IMGUI_API void Unindent(float indent_w = 0.0f); // move content position back to the left, by indent_w, or style.IndentSpacing if indent_w <= 0 - IMGUI_API void BeginGroup(); // lock horizontal starting position - IMGUI_API void EndGroup(); // unlock horizontal starting position + capture the whole group bounding box into one "item" (so you can use IsItemHovered() or layout primitives such as SameLine() on whole group, etc.) - IMGUI_API ImVec2 GetCursorPos(); // cursor position in window coordinates (relative to window position) - IMGUI_API float GetCursorPosX(); // (some functions are using window-relative coordinates, such as: GetCursorPos, GetCursorStartPos, GetContentRegionMax, GetWindowContentRegion* etc. - IMGUI_API float GetCursorPosY(); // other functions such as GetCursorScreenPos or everything in ImDrawList:: - IMGUI_API void SetCursorPos(const ImVec2& local_pos); // are using the main, absolute coordinate system. - IMGUI_API void SetCursorPosX(float local_x); // GetWindowPos() + GetCursorPos() == GetCursorScreenPos() etc.) - IMGUI_API void SetCursorPosY(float local_y); // - IMGUI_API ImVec2 GetCursorStartPos(); // initial cursor position in window coordinates - IMGUI_API ImVec2 GetCursorScreenPos(); // cursor position in absolute coordinates (useful to work with ImDrawList API). generally top-left == GetMainViewport()->Pos == (0,0) in single viewport mode, and bottom-right == GetMainViewport()->Pos+Size == io.DisplaySize in single-viewport mode. - IMGUI_API void SetCursorScreenPos(const ImVec2& pos); // cursor position in absolute coordinates - IMGUI_API void AlignTextToFramePadding(); // vertically align upcoming text baseline to FramePadding.y so that it will align properly to regularly framed items (call if you have text on a line before a framed item) - IMGUI_API float GetTextLineHeight(); // ~ FontSize - IMGUI_API float GetTextLineHeightWithSpacing(); // ~ FontSize + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of text) - IMGUI_API float GetFrameHeight(); // ~ FontSize + style.FramePadding.y * 2 - IMGUI_API float GetFrameHeightWithSpacing(); // ~ FontSize + style.FramePadding.y * 2 + style.ItemSpacing.y (distance in pixels between 2 consecutive lines of framed widgets) - - // ID stack/scopes - // Read the FAQ (docs/FAQ.md or http://dearimgui.org/faq) for more details about how ID are handled in dear imgui. - // - Those questions are answered and impacted by understanding of the ID stack system: - // - "Q: Why is my widget not reacting when I click on it?" - // - "Q: How can I have widgets with an empty label?" - // - "Q: How can I have multiple widgets with the same label?" - // - Short version: ID are hashes of the entire ID stack. If you are creating widgets in a loop you most likely - // want to push a unique identifier (e.g. object pointer, loop index) to uniquely differentiate them. - // - You can also use the "Label##foobar" syntax within widget label to distinguish them from each others. - // - In this header file we use the "label"/"name" terminology to denote a string that will be displayed + used as an ID, - // whereas "str_id" denote a string that is only used as an ID and not normally displayed. - IMGUI_API void PushID(const char* str_id); // push string into the ID stack (will hash string). - IMGUI_API void PushID(const char* str_id_begin, const char* str_id_end); // push string into the ID stack (will hash string). - IMGUI_API void PushID(const void* ptr_id); // push pointer into the ID stack (will hash pointer). - IMGUI_API void PushID(int int_id); // push integer into the ID stack (will hash integer). - IMGUI_API void PopID(); // pop from the ID stack. - IMGUI_API ImGuiID GetID(const char* str_id); // calculate unique ID (hash of whole ID stack + given parameter). e.g. if you want to query into ImGuiStorage yourself - IMGUI_API ImGuiID GetID(const char* str_id_begin, const char* str_id_end); - IMGUI_API ImGuiID GetID(const void* ptr_id); - - // Widgets: Text - IMGUI_API void TextUnformatted(const char* text, const char* text_end = NULL); // raw text without formatting. Roughly equivalent to Text("%s", text) but: A) doesn't require null terminated string if 'text_end' is specified, B) it's faster, no memory copy is done, no buffer size limits, recommended for long chunks of text. - IMGUI_API void Text(const char* fmt, ...) IM_FMTARGS(1); // formatted text - IMGUI_API void TextV(const char* fmt, va_list args) IM_FMTLIST(1); - IMGUI_API void TextColored(const ImVec4& col, const char* fmt, ...) IM_FMTARGS(2); // shortcut for PushStyleColor(ImGuiCol_Text, col); Text(fmt, ...); PopStyleColor(); - IMGUI_API void TextColoredV(const ImVec4& col, const char* fmt, va_list args) IM_FMTLIST(2); - IMGUI_API void TextDisabled(const char* fmt, ...) IM_FMTARGS(1); // shortcut for PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]); Text(fmt, ...); PopStyleColor(); - IMGUI_API void TextDisabledV(const char* fmt, va_list args) IM_FMTLIST(1); - IMGUI_API void TextWrapped(const char* fmt, ...) IM_FMTARGS(1); // shortcut for PushTextWrapPos(0.0f); Text(fmt, ...); PopTextWrapPos();. Note that this won't work on an auto-resizing window if there's no other widgets to extend the window width, yoy may need to set a size using SetNextWindowSize(). - IMGUI_API void TextWrappedV(const char* fmt, va_list args) IM_FMTLIST(1); - IMGUI_API void LabelText(const char* label, const char* fmt, ...) IM_FMTARGS(2); // display text+label aligned the same way as value+label widgets - IMGUI_API void LabelTextV(const char* label, const char* fmt, va_list args) IM_FMTLIST(2); - IMGUI_API void BulletText(const char* fmt, ...) IM_FMTARGS(1); // shortcut for Bullet()+Text() - IMGUI_API void BulletTextV(const char* fmt, va_list args) IM_FMTLIST(1); - - // Widgets: Main - // - Most widgets return true when the value has been changed or when pressed/selected - // - You may also use one of the many IsItemXXX functions (e.g. IsItemActive, IsItemHovered, etc.) to query widget state. - IMGUI_API bool Button(const char* label, const ImVec2& size = ImVec2(0, 0)); // button - IMGUI_API bool SmallButton(const char* label); // button with FramePadding=(0,0) to easily embed within text - IMGUI_API bool InvisibleButton(const char* str_id, const ImVec2& size, ImGuiButtonFlags flags = 0); // flexible button behavior without the visuals, frequently useful to build custom behaviors using the public api (along with IsItemActive, IsItemHovered, etc.) - IMGUI_API bool ArrowButton(const char* str_id, ImGuiDir dir); // square button with an arrow shape - IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1,1), const ImVec4& tint_col = ImVec4(1,1,1,1), const ImVec4& border_col = ImVec4(0,0,0,0)); - IMGUI_API bool ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1,1), int frame_padding = -1, const ImVec4& bg_col = ImVec4(0,0,0,0), const ImVec4& tint_col = ImVec4(1,1,1,1)); // <0 frame_padding uses default frame padding settings. 0 for no padding - IMGUI_API bool Checkbox(const char* label, bool* v); - IMGUI_API bool CheckboxFlags(const char* label, int* flags, int flags_value); - IMGUI_API bool CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value); - IMGUI_API bool RadioButton(const char* label, bool active); // use with e.g. if (RadioButton("one", my_value==1)) { my_value = 1; } - IMGUI_API bool RadioButton(const char* label, int* v, int v_button); // shortcut to handle the above pattern when value is an integer - IMGUI_API void ProgressBar(float fraction, const ImVec2& size_arg = ImVec2(-FLT_MIN, 0), const char* overlay = NULL); - IMGUI_API void Bullet(); // draw a small circle + keep the cursor on the same line. advance cursor x position by GetTreeNodeToLabelSpacing(), same distance that TreeNode() uses - - // Widgets: Combo Box - // - The BeginCombo()/EndCombo() api allows you to manage your contents and selection state however you want it, by creating e.g. Selectable() items. - // - The old Combo() api are helpers over BeginCombo()/EndCombo() which are kept available for convenience purpose. This is analogous to how ListBox are created. - IMGUI_API bool BeginCombo(const char* label, const char* preview_value, ImGuiComboFlags flags = 0); - IMGUI_API void EndCombo(); // only call EndCombo() if BeginCombo() returns true! - IMGUI_API bool Combo(const char* label, int* current_item, const char* const items[], int items_count, int popup_max_height_in_items = -1); - IMGUI_API bool Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int popup_max_height_in_items = -1); // Separate items with \0 within a string, end item-list with \0\0. e.g. "One\0Two\0Three\0" - IMGUI_API bool Combo(const char* label, int* current_item, bool(*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int popup_max_height_in_items = -1); - - // Widgets: Drag Sliders - // - CTRL+Click on any drag box to turn them into an input box. Manually input values aren't clamped by default and can go off-bounds. Use ImGuiSliderFlags_AlwaysClamp to always clamp. - // - For all the Float2/Float3/Float4/Int2/Int3/Int4 versions of every functions, note that a 'float v[X]' function argument is the same as 'float* v', the array syntax is just a way to document the number of elements that are expected to be accessible. You can pass address of your first element out of a contiguous set, e.g. &myvector.x - // - Adjust format string to decorate the value with a prefix, a suffix, or adapt the editing and display precision e.g. "%.3f" -> 1.234; "%5.2f secs" -> 01.23 secs; "Biscuit: %.0f" -> Biscuit: 1; etc. - // - Format string may also be set to NULL or use the default format ("%f" or "%d"). - // - Speed are per-pixel of mouse movement (v_speed=0.2f: mouse needs to move by 5 pixels to increase value by 1). For gamepad/keyboard navigation, minimum speed is Max(v_speed, minimum_step_at_given_precision). - // - Use v_min < v_max to clamp edits to given limits. Note that CTRL+Click manual input can override those limits if ImGuiSliderFlags_AlwaysClamp is not used. - // - Use v_max = FLT_MAX / INT_MAX etc to avoid clamping to a maximum, same with v_min = -FLT_MAX / INT_MIN to avoid clamping to a minimum. - // - We use the same sets of flags for DragXXX() and SliderXXX() functions as the features are the same and it makes it easier to swap them. - // - Legacy: Pre-1.78 there are DragXXX() function signatures that takes a final `float power=1.0f' argument instead of the `ImGuiSliderFlags flags=0' argument. - // If you get a warning converting a float to ImGuiSliderFlags, read https://github.com/ocornut/imgui/issues/3361 - IMGUI_API bool DragFloat(const char* label, float* v, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); // If v_min >= v_max we have no bound - IMGUI_API bool DragFloat2(const char* label, float v[2], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); - IMGUI_API bool DragFloat3(const char* label, float v[3], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); - IMGUI_API bool DragFloat4(const char* label, float v[4], float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", ImGuiSliderFlags flags = 0); - IMGUI_API bool DragFloatRange2(const char* label, float* v_current_min, float* v_current_max, float v_speed = 1.0f, float v_min = 0.0f, float v_max = 0.0f, const char* format = "%.3f", const char* format_max = NULL, ImGuiSliderFlags flags = 0); - IMGUI_API bool DragInt(const char* label, int* v, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", ImGuiSliderFlags flags = 0); // If v_min >= v_max we have no bound - IMGUI_API bool DragInt2(const char* label, int v[2], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", ImGuiSliderFlags flags = 0); - IMGUI_API bool DragInt3(const char* label, int v[3], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", ImGuiSliderFlags flags = 0); - IMGUI_API bool DragInt4(const char* label, int v[4], float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", ImGuiSliderFlags flags = 0); - IMGUI_API bool DragIntRange2(const char* label, int* v_current_min, int* v_current_max, float v_speed = 1.0f, int v_min = 0, int v_max = 0, const char* format = "%d", const char* format_max = NULL, ImGuiSliderFlags flags = 0); - IMGUI_API bool DragScalar(const char* label, ImGuiDataType data_type, void* p_data, float v_speed = 1.0f, const void* p_min = NULL, const void* p_max = NULL, const char* format = NULL, ImGuiSliderFlags flags = 0); - IMGUI_API bool DragScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, float v_speed = 1.0f, const void* p_min = NULL, const void* p_max = NULL, const char* format = NULL, ImGuiSliderFlags flags = 0); - - // Widgets: Regular Sliders - // - CTRL+Click on any slider to turn them into an input box. Manually input values aren't clamped by default and can go off-bounds. Use ImGuiSliderFlags_AlwaysClamp to always clamp. - // - Adjust format string to decorate the value with a prefix, a suffix, or adapt the editing and display precision e.g. "%.3f" -> 1.234; "%5.2f secs" -> 01.23 secs; "Biscuit: %.0f" -> Biscuit: 1; etc. - // - Format string may also be set to NULL or use the default format ("%f" or "%d"). - // - Legacy: Pre-1.78 there are SliderXXX() function signatures that takes a final `float power=1.0f' argument instead of the `ImGuiSliderFlags flags=0' argument. - // If you get a warning converting a float to ImGuiSliderFlags, read https://github.com/ocornut/imgui/issues/3361 - IMGUI_API bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0); // adjust format to decorate the value with a prefix or a suffix for in-slider labels or unit display. - IMGUI_API bool SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0); - IMGUI_API bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0); - IMGUI_API bool SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0); - IMGUI_API bool SliderAngle(const char* label, float* v_rad, float v_degrees_min = -360.0f, float v_degrees_max = +360.0f, const char* format = "%.0f deg", ImGuiSliderFlags flags = 0); - IMGUI_API bool SliderInt(const char* label, int* v, int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0); - IMGUI_API bool SliderInt2(const char* label, int v[2], int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0); - IMGUI_API bool SliderInt3(const char* label, int v[3], int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0); - IMGUI_API bool SliderInt4(const char* label, int v[4], int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0); - IMGUI_API bool SliderScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format = NULL, ImGuiSliderFlags flags = 0); - IMGUI_API bool SliderScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, const void* p_min, const void* p_max, const char* format = NULL, ImGuiSliderFlags flags = 0); - IMGUI_API bool VSliderFloat(const char* label, const ImVec2& size, float* v, float v_min, float v_max, const char* format = "%.3f", ImGuiSliderFlags flags = 0); - IMGUI_API bool VSliderInt(const char* label, const ImVec2& size, int* v, int v_min, int v_max, const char* format = "%d", ImGuiSliderFlags flags = 0); - IMGUI_API bool VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format = NULL, ImGuiSliderFlags flags = 0); - - // Widgets: Input with Keyboard - // - If you want to use InputText() with std::string or any custom dynamic string type, see misc/cpp/imgui_stdlib.h and comments in imgui_demo.cpp. - // - Most of the ImGuiInputTextFlags flags are only useful for InputText() and not for InputFloatX, InputIntX, InputDouble etc. - IMGUI_API bool InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); - IMGUI_API bool InputTextMultiline(const char* label, char* buf, size_t buf_size, const ImVec2& size = ImVec2(0, 0), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); - IMGUI_API bool InputTextWithHint(const char* label, const char* hint, char* buf, size_t buf_size, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); - IMGUI_API bool InputFloat(const char* label, float* v, float step = 0.0f, float step_fast = 0.0f, const char* format = "%.3f", ImGuiInputTextFlags flags = 0); - IMGUI_API bool InputFloat2(const char* label, float v[2], const char* format = "%.3f", ImGuiInputTextFlags flags = 0); - IMGUI_API bool InputFloat3(const char* label, float v[3], const char* format = "%.3f", ImGuiInputTextFlags flags = 0); - IMGUI_API bool InputFloat4(const char* label, float v[4], const char* format = "%.3f", ImGuiInputTextFlags flags = 0); - IMGUI_API bool InputInt(const char* label, int* v, int step = 1, int step_fast = 100, ImGuiInputTextFlags flags = 0); - IMGUI_API bool InputInt2(const char* label, int v[2], ImGuiInputTextFlags flags = 0); - IMGUI_API bool InputInt3(const char* label, int v[3], ImGuiInputTextFlags flags = 0); - IMGUI_API bool InputInt4(const char* label, int v[4], ImGuiInputTextFlags flags = 0); - IMGUI_API bool InputDouble(const char* label, double* v, double step = 0.0, double step_fast = 0.0, const char* format = "%.6f", ImGuiInputTextFlags flags = 0); - IMGUI_API bool InputScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_step = NULL, const void* p_step_fast = NULL, const char* format = NULL, ImGuiInputTextFlags flags = 0); - IMGUI_API bool InputScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, const void* p_step = NULL, const void* p_step_fast = NULL, const char* format = NULL, ImGuiInputTextFlags flags = 0); - - // Widgets: Color Editor/Picker (tip: the ColorEdit* functions have a little color square that can be left-clicked to open a picker, and right-clicked to open an option menu.) - // - Note that in C++ a 'float v[X]' function argument is the _same_ as 'float* v', the array syntax is just a way to document the number of elements that are expected to be accessible. - // - You can pass the address of a first float element out of a contiguous structure, e.g. &myvector.x - IMGUI_API bool ColorEdit3(const char* label, float col[3], ImGuiColorEditFlags flags = 0); - IMGUI_API bool ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flags = 0); - IMGUI_API bool ColorPicker3(const char* label, float col[3], ImGuiColorEditFlags flags = 0); - IMGUI_API bool ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags flags = 0, const float* ref_col = NULL); - IMGUI_API bool ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFlags flags = 0, ImVec2 size = ImVec2(0, 0)); // display a color square/button, hover for details, return true when pressed. - IMGUI_API void SetColorEditOptions(ImGuiColorEditFlags flags); // initialize current options (generally on application startup) if you want to select a default format, picker type, etc. User will be able to change many settings, unless you pass the _NoOptions flag to your calls. - - // Widgets: Trees - // - TreeNode functions return true when the node is open, in which case you need to also call TreePop() when you are finished displaying the tree node contents. - IMGUI_API bool TreeNode(const char* label); - IMGUI_API bool TreeNode(const char* str_id, const char* fmt, ...) IM_FMTARGS(2); // helper variation to easily decorelate the id from the displayed string. Read the FAQ about why and how to use ID. to align arbitrary text at the same level as a TreeNode() you can use Bullet(). - IMGUI_API bool TreeNode(const void* ptr_id, const char* fmt, ...) IM_FMTARGS(2); // " - IMGUI_API bool TreeNodeV(const char* str_id, const char* fmt, va_list args) IM_FMTLIST(2); - IMGUI_API bool TreeNodeV(const void* ptr_id, const char* fmt, va_list args) IM_FMTLIST(2); - IMGUI_API bool TreeNodeEx(const char* label, ImGuiTreeNodeFlags flags = 0); - IMGUI_API bool TreeNodeEx(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) IM_FMTARGS(3); - IMGUI_API bool TreeNodeEx(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) IM_FMTARGS(3); - IMGUI_API bool TreeNodeExV(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) IM_FMTLIST(3); - IMGUI_API bool TreeNodeExV(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) IM_FMTLIST(3); - IMGUI_API void TreePush(const char* str_id); // ~ Indent()+PushId(). Already called by TreeNode() when returning true, but you can call TreePush/TreePop yourself if desired. - IMGUI_API void TreePush(const void* ptr_id = NULL); // " - IMGUI_API void TreePop(); // ~ Unindent()+PopId() - IMGUI_API float GetTreeNodeToLabelSpacing(); // horizontal distance preceding label when using TreeNode*() or Bullet() == (g.FontSize + style.FramePadding.x*2) for a regular unframed TreeNode - IMGUI_API bool CollapsingHeader(const char* label, ImGuiTreeNodeFlags flags = 0); // if returning 'true' the header is open. doesn't indent nor push on ID stack. user doesn't have to call TreePop(). - IMGUI_API bool CollapsingHeader(const char* label, bool* p_visible, ImGuiTreeNodeFlags flags = 0); // when 'p_visible != NULL': if '*p_visible==true' display an additional small close button on upper right of the header which will set the bool to false when clicked, if '*p_visible==false' don't display the header. - IMGUI_API void SetNextItemOpen(bool is_open, ImGuiCond cond = 0); // set next TreeNode/CollapsingHeader open state. - - // Widgets: Selectables - // - A selectable highlights when hovered, and can display another color when selected. - // - Neighbors selectable extend their highlight bounds in order to leave no gap between them. This is so a series of selected Selectable appear contiguous. - IMGUI_API bool Selectable(const char* label, bool selected = false, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0, 0)); // "bool selected" carry the selection state (read-only). Selectable() is clicked is returns true so you can modify your selection state. size.x==0.0: use remaining width, size.x>0.0: specify width. size.y==0.0: use label height, size.y>0.0: specify height - IMGUI_API bool Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0, 0)); // "bool* p_selected" point to the selection state (read-write), as a convenient helper. - - // Widgets: List Boxes - // - This is essentially a thin wrapper to using BeginChild/EndChild with some stylistic changes. - // - The BeginListBox()/EndListBox() api allows you to manage your contents and selection state however you want it, by creating e.g. Selectable() or any items. - // - The simplified/old ListBox() api are helpers over BeginListBox()/EndListBox() which are kept available for convenience purpose. This is analoguous to how Combos are created. - // - Choose frame width: size.x > 0.0f: custom / size.x < 0.0f or -FLT_MIN: right-align / size.x = 0.0f (default): use current ItemWidth - // - Choose frame height: size.y > 0.0f: custom / size.y < 0.0f or -FLT_MIN: bottom-align / size.y = 0.0f (default): arbitrary default height which can fit ~7 items - IMGUI_API bool BeginListBox(const char* label, const ImVec2& size = ImVec2(0, 0)); // open a framed scrolling region - IMGUI_API void EndListBox(); // only call EndListBox() if BeginListBox() returned true! - IMGUI_API bool ListBox(const char* label, int* current_item, const char* const items[], int items_count, int height_in_items = -1); - IMGUI_API bool ListBox(const char* label, int* current_item, bool (*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int height_in_items = -1); - - // Widgets: Data Plotting - // - Consider using ImPlot (https://github.com/epezent/implot) which is much better! - IMGUI_API void PlotLines(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0), int stride = sizeof(float)); - IMGUI_API void PlotLines(const char* label, float(*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0)); - IMGUI_API void PlotHistogram(const char* label, const float* values, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0), int stride = sizeof(float)); - IMGUI_API void PlotHistogram(const char* label, float(*values_getter)(void* data, int idx), void* data, int values_count, int values_offset = 0, const char* overlay_text = NULL, float scale_min = FLT_MAX, float scale_max = FLT_MAX, ImVec2 graph_size = ImVec2(0, 0)); - - // Widgets: Value() Helpers. - // - Those are merely shortcut to calling Text() with a format string. Output single value in "name: value" format (tip: freely declare more in your code to handle your types. you can add functions to the ImGui namespace) - IMGUI_API void Value(const char* prefix, bool b); - IMGUI_API void Value(const char* prefix, int v); - IMGUI_API void Value(const char* prefix, unsigned int v); - IMGUI_API void Value(const char* prefix, float v, const char* float_format = NULL); - - // Widgets: Menus - // - Use BeginMenuBar() on a window ImGuiWindowFlags_MenuBar to append to its menu bar. - // - Use BeginMainMenuBar() to create a menu bar at the top of the screen and append to it. - // - Use BeginMenu() to create a menu. You can call BeginMenu() multiple time with the same identifier to append more items to it. - // - Not that MenuItem() keyboardshortcuts are displayed as a convenience but _not processed_ by Dear ImGui at the moment. - IMGUI_API bool BeginMenuBar(); // append to menu-bar of current window (requires ImGuiWindowFlags_MenuBar flag set on parent window). - IMGUI_API void EndMenuBar(); // only call EndMenuBar() if BeginMenuBar() returns true! - IMGUI_API bool BeginMainMenuBar(); // create and append to a full screen menu-bar. - IMGUI_API void EndMainMenuBar(); // only call EndMainMenuBar() if BeginMainMenuBar() returns true! - IMGUI_API bool BeginMenu(const char* label, bool enabled = true); // create a sub-menu entry. only call EndMenu() if this returns true! - IMGUI_API void EndMenu(); // only call EndMenu() if BeginMenu() returns true! - IMGUI_API bool MenuItem(const char* label, const char* shortcut = NULL, bool selected = false, bool enabled = true); // return true when activated. - IMGUI_API bool MenuItem(const char* label, const char* shortcut, bool* p_selected, bool enabled = true); // return true when activated + toggle (*p_selected) if p_selected != NULL - - // Tooltips - // - Tooltip are windows following the mouse. They do not take focus away. - IMGUI_API void BeginTooltip(); // begin/append a tooltip window. to create full-featured tooltip (with any kind of items). - IMGUI_API void EndTooltip(); - IMGUI_API void SetTooltip(const char* fmt, ...) IM_FMTARGS(1); // set a text-only tooltip, typically use with ImGui::IsItemHovered(). override any previous call to SetTooltip(). - IMGUI_API void SetTooltipV(const char* fmt, va_list args) IM_FMTLIST(1); - - // Popups, Modals - // - They block normal mouse hovering detection (and therefore most mouse interactions) behind them. - // - If not modal: they can be closed by clicking anywhere outside them, or by pressing ESCAPE. - // - Their visibility state (~bool) is held internally instead of being held by the programmer as we are used to with regular Begin*() calls. - // - The 3 properties above are related: we need to retain popup visibility state in the library because popups may be closed as any time. - // - You can bypass the hovering restriction by using ImGuiHoveredFlags_AllowWhenBlockedByPopup when calling IsItemHovered() or IsWindowHovered(). - // - IMPORTANT: Popup identifiers are relative to the current ID stack, so OpenPopup and BeginPopup generally needs to be at the same level of the stack. - // This is sometimes leading to confusing mistakes. May rework this in the future. - - // Popups: begin/end functions - // - BeginPopup(): query popup state, if open start appending into the window. Call EndPopup() afterwards. ImGuiWindowFlags are forwarded to the window. - // - BeginPopupModal(): block every interactions behind the window, cannot be closed by user, add a dimming background, has a title bar. - IMGUI_API bool BeginPopup(const char* str_id, ImGuiWindowFlags flags = 0); // return true if the popup is open, and you can start outputting to it. - IMGUI_API bool BeginPopupModal(const char* name, bool* p_open = NULL, ImGuiWindowFlags flags = 0); // return true if the modal is open, and you can start outputting to it. - IMGUI_API void EndPopup(); // only call EndPopup() if BeginPopupXXX() returns true! - - // Popups: open/close functions - // - OpenPopup(): set popup state to open. ImGuiPopupFlags are available for opening options. - // - If not modal: they can be closed by clicking anywhere outside them, or by pressing ESCAPE. - // - CloseCurrentPopup(): use inside the BeginPopup()/EndPopup() scope to close manually. - // - CloseCurrentPopup() is called by default by Selectable()/MenuItem() when activated (FIXME: need some options). - // - Use ImGuiPopupFlags_NoOpenOverExistingPopup to avoid opening a popup if there's already one at the same level. This is equivalent to e.g. testing for !IsAnyPopupOpen() prior to OpenPopup(). - // - Use IsWindowAppearing() after BeginPopup() to tell if a window just opened. - IMGUI_API void OpenPopup(const char* str_id, ImGuiPopupFlags popup_flags = 0); // call to mark popup as open (don't call every frame!). - IMGUI_API void OpenPopup(ImGuiID id, ImGuiPopupFlags popup_flags = 0); // id overload to facilitate calling from nested stacks - IMGUI_API void OpenPopupOnItemClick(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // helper to open popup when clicked on last item. Default to ImGuiPopupFlags_MouseButtonRight == 1. (note: actually triggers on the mouse _released_ event to be consistent with popup behaviors) - IMGUI_API void CloseCurrentPopup(); // manually close the popup we have begin-ed into. - - // Popups: open+begin combined functions helpers - // - Helpers to do OpenPopup+BeginPopup where the Open action is triggered by e.g. hovering an item and right-clicking. - // - They are convenient to easily create context menus, hence the name. - // - IMPORTANT: Notice that BeginPopupContextXXX takes ImGuiPopupFlags just like OpenPopup() and unlike BeginPopup(). For full consistency, we may add ImGuiWindowFlags to the BeginPopupContextXXX functions in the future. - // - IMPORTANT: we exceptionally default their flags to 1 (== ImGuiPopupFlags_MouseButtonRight) for backward compatibility with older API taking 'int mouse_button = 1' parameter, so if you add other flags remember to re-add the ImGuiPopupFlags_MouseButtonRight. - IMGUI_API bool BeginPopupContextItem(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // open+begin popup when clicked on last item. Use str_id==NULL to associate the popup to previous item. If you want to use that on a non-interactive item such as Text() you need to pass in an explicit ID here. read comments in .cpp! - IMGUI_API bool BeginPopupContextWindow(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1);// open+begin popup when clicked on current window. - IMGUI_API bool BeginPopupContextVoid(const char* str_id = NULL, ImGuiPopupFlags popup_flags = 1); // open+begin popup when clicked in void (where there are no windows). - - // Popups: query functions - // - IsPopupOpen(): return true if the popup is open at the current BeginPopup() level of the popup stack. - // - IsPopupOpen() with ImGuiPopupFlags_AnyPopupId: return true if any popup is open at the current BeginPopup() level of the popup stack. - // - IsPopupOpen() with ImGuiPopupFlags_AnyPopupId + ImGuiPopupFlags_AnyPopupLevel: return true if any popup is open. - IMGUI_API bool IsPopupOpen(const char* str_id, ImGuiPopupFlags flags = 0); // return true if the popup is open. - - // Tables - // [BETA API] API may evolve slightly! If you use this, please update to the next version when it comes out! - // - Full-featured replacement for old Columns API. - // - See Demo->Tables for demo code. - // - See top of imgui_tables.cpp for general commentary. - // - See ImGuiTableFlags_ and ImGuiTableColumnFlags_ enums for a description of available flags. - // The typical call flow is: - // - 1. Call BeginTable(). - // - 2. Optionally call TableSetupColumn() to submit column name/flags/defaults. - // - 3. Optionally call TableSetupScrollFreeze() to request scroll freezing of columns/rows. - // - 4. Optionally call TableHeadersRow() to submit a header row. Names are pulled from TableSetupColumn() data. - // - 5. Populate contents: - // - In most situations you can use TableNextRow() + TableSetColumnIndex(N) to start appending into a column. - // - If you are using tables as a sort of grid, where every columns is holding the same type of contents, - // you may prefer using TableNextColumn() instead of TableNextRow() + TableSetColumnIndex(). - // TableNextColumn() will automatically wrap-around into the next row if needed. - // - IMPORTANT: Comparatively to the old Columns() API, we need to call TableNextColumn() for the first column! - // - Summary of possible call flow: - // -------------------------------------------------------------------------------------------------------- - // TableNextRow() -> TableSetColumnIndex(0) -> Text("Hello 0") -> TableSetColumnIndex(1) -> Text("Hello 1") // OK - // TableNextRow() -> TableNextColumn() -> Text("Hello 0") -> TableNextColumn() -> Text("Hello 1") // OK - // TableNextColumn() -> Text("Hello 0") -> TableNextColumn() -> Text("Hello 1") // OK: TableNextColumn() automatically gets to next row! - // TableNextRow() -> Text("Hello 0") // Not OK! Missing TableSetColumnIndex() or TableNextColumn()! Text will not appear! - // -------------------------------------------------------------------------------------------------------- - // - 5. Call EndTable() - IMGUI_API bool BeginTable(const char* str_id, int column, ImGuiTableFlags flags = 0, const ImVec2& outer_size = ImVec2(0.0f, 0.0f), float inner_width = 0.0f); - IMGUI_API void EndTable(); // only call EndTable() if BeginTable() returns true! - IMGUI_API void TableNextRow(ImGuiTableRowFlags row_flags = 0, float min_row_height = 0.0f); // append into the first cell of a new row. - IMGUI_API bool TableNextColumn(); // append into the next column (or first column of next row if currently in last column). Return true when column is visible. - IMGUI_API bool TableSetColumnIndex(int column_n); // append into the specified column. Return true when column is visible. - - // Tables: Headers & Columns declaration - // - Use TableSetupColumn() to specify label, resizing policy, default width/weight, id, various other flags etc. - // - Use TableHeadersRow() to create a header row and automatically submit a TableHeader() for each column. - // Headers are required to perform: reordering, sorting, and opening the context menu. - // The context menu can also be made available in columns body using ImGuiTableFlags_ContextMenuInBody. - // - You may manually submit headers using TableNextRow() + TableHeader() calls, but this is only useful in - // some advanced use cases (e.g. adding custom widgets in header row). - // - Use TableSetupScrollFreeze() to lock columns/rows so they stay visible when scrolled. - IMGUI_API void TableSetupColumn(const char* label, ImGuiTableColumnFlags flags = 0, float init_width_or_weight = 0.0f, ImGuiID user_id = 0); - IMGUI_API void TableSetupScrollFreeze(int cols, int rows); // lock columns/rows so they stay visible when scrolled. - IMGUI_API void TableHeadersRow(); // submit all headers cells based on data provided to TableSetupColumn() + submit context menu - IMGUI_API void TableHeader(const char* label); // submit one header cell manually (rarely used) - - // Tables: Sorting - // - Call TableGetSortSpecs() to retrieve latest sort specs for the table. NULL when not sorting. - // - When 'SpecsDirty == true' you should sort your data. It will be true when sorting specs have changed - // since last call, or the first time. Make sure to set 'SpecsDirty = false' after sorting, else you may - // wastefully sort your data every frame! - // - Lifetime: don't hold on this pointer over multiple frames or past any subsequent call to BeginTable(). - IMGUI_API ImGuiTableSortSpecs* TableGetSortSpecs(); // get latest sort specs for the table (NULL if not sorting). - - // Tables: Miscellaneous functions - // - Functions args 'int column_n' treat the default value of -1 as the same as passing the current column index. - IMGUI_API int TableGetColumnCount(); // return number of columns (value passed to BeginTable) - IMGUI_API int TableGetColumnIndex(); // return current column index. - IMGUI_API int TableGetRowIndex(); // return current row index. - IMGUI_API const char* TableGetColumnName(int column_n = -1); // return "" if column didn't have a name declared by TableSetupColumn(). Pass -1 to use current column. - IMGUI_API ImGuiTableColumnFlags TableGetColumnFlags(int column_n = -1); // return column flags so you can query their Enabled/Visible/Sorted/Hovered status flags. Pass -1 to use current column. - IMGUI_API void TableSetColumnEnabled(int column_n, bool v);// change user accessible enabled/disabled state of a column. Set to false to hide the column. User can use the context menu to change this themselves (right-click in headers, or right-click in columns body with ImGuiTableFlags_ContextMenuInBody) - IMGUI_API void TableSetBgColor(ImGuiTableBgTarget target, ImU32 color, int column_n = -1); // change the color of a cell, row, or column. See ImGuiTableBgTarget_ flags for details. - - // Legacy Columns API (prefer using Tables!) - // - You can also use SameLine(pos_x) to mimic simplified columns. - IMGUI_API void Columns(int count = 1, const char* id = NULL, bool border = true); - IMGUI_API void NextColumn(); // next column, defaults to current row or next row if the current row is finished - IMGUI_API int GetColumnIndex(); // get current column index - IMGUI_API float GetColumnWidth(int column_index = -1); // get column width (in pixels). pass -1 to use current column - IMGUI_API void SetColumnWidth(int column_index, float width); // set column width (in pixels). pass -1 to use current column - IMGUI_API float GetColumnOffset(int column_index = -1); // get position of column line (in pixels, from the left side of the contents region). pass -1 to use current column, otherwise 0..GetColumnsCount() inclusive. column 0 is typically 0.0f - IMGUI_API void SetColumnOffset(int column_index, float offset_x); // set position of column line (in pixels, from the left side of the contents region). pass -1 to use current column - IMGUI_API int GetColumnsCount(); - - // Tab Bars, Tabs - IMGUI_API bool BeginTabBar(const char* str_id, ImGuiTabBarFlags flags = 0); // create and append into a TabBar - IMGUI_API void EndTabBar(); // only call EndTabBar() if BeginTabBar() returns true! - IMGUI_API bool BeginTabItem(const char* label, bool* p_open = NULL, ImGuiTabItemFlags flags = 0); // create a Tab. Returns true if the Tab is selected. - IMGUI_API void EndTabItem(); // only call EndTabItem() if BeginTabItem() returns true! - IMGUI_API bool TabItemButton(const char* label, ImGuiTabItemFlags flags = 0); // create a Tab behaving like a button. return true when clicked. cannot be selected in the tab bar. - IMGUI_API void SetTabItemClosed(const char* tab_or_docked_window_label); // notify TabBar or Docking system of a closed tab/window ahead (useful to reduce visual flicker on reorderable tab bars). For tab-bar: call after BeginTabBar() and before Tab submissions. Otherwise call with a window name. - - // Logging/Capture - // - All text output from the interface can be captured into tty/file/clipboard. By default, tree nodes are automatically opened during logging. - IMGUI_API void LogToTTY(int auto_open_depth = -1); // start logging to tty (stdout) - IMGUI_API void LogToFile(int auto_open_depth = -1, const char* filename = NULL); // start logging to file - IMGUI_API void LogToClipboard(int auto_open_depth = -1); // start logging to OS clipboard - IMGUI_API void LogFinish(); // stop logging (close file, etc.) - IMGUI_API void LogButtons(); // helper to display buttons for logging to tty/file/clipboard - IMGUI_API void LogText(const char* fmt, ...) IM_FMTARGS(1); // pass text data straight to log (without being displayed) - IMGUI_API void LogTextV(const char* fmt, va_list args) IM_FMTLIST(1); - - // Drag and Drop - // - On source items, call BeginDragDropSource(), if it returns true also call SetDragDropPayload() + EndDragDropSource(). - // - On target candidates, call BeginDragDropTarget(), if it returns true also call AcceptDragDropPayload() + EndDragDropTarget(). - // - If you stop calling BeginDragDropSource() the payload is preserved however it won't have a preview tooltip (we currently display a fallback "..." tooltip, see #1725) - // - An item can be both drag source and drop target. - IMGUI_API bool BeginDragDropSource(ImGuiDragDropFlags flags = 0); // call after submitting an item which may be dragged. when this return true, you can call SetDragDropPayload() + EndDragDropSource() - IMGUI_API bool SetDragDropPayload(const char* type, const void* data, size_t sz, ImGuiCond cond = 0); // type is a user defined string of maximum 32 characters. Strings starting with '_' are reserved for dear imgui internal types. Data is copied and held by imgui. - IMGUI_API void EndDragDropSource(); // only call EndDragDropSource() if BeginDragDropSource() returns true! - IMGUI_API bool BeginDragDropTarget(); // call after submitting an item that may receive a payload. If this returns true, you can call AcceptDragDropPayload() + EndDragDropTarget() - IMGUI_API const ImGuiPayload* AcceptDragDropPayload(const char* type, ImGuiDragDropFlags flags = 0); // accept contents of a given type. If ImGuiDragDropFlags_AcceptBeforeDelivery is set you can peek into the payload before the mouse button is released. - IMGUI_API void EndDragDropTarget(); // only call EndDragDropTarget() if BeginDragDropTarget() returns true! - IMGUI_API const ImGuiPayload* GetDragDropPayload(); // peek directly into the current payload from anywhere. may return NULL. use ImGuiPayload::IsDataType() to test for the payload type. - - // Disabling [BETA API] - // - Disable all user interactions and dim items visuals (applying style.DisabledAlpha over current colors) - // - Those can be nested but it cannot be used to enable an already disabled section (a single BeginDisabled(true) in the stack is enough to keep everything disabled) - // - BeginDisabled(false) essentially does nothing useful but is provided to facilitate use of boolean expressions. If you can avoid calling BeginDisabled(False)/EndDisabled() best to avoid it. - IMGUI_API void BeginDisabled(bool disabled = true); - IMGUI_API void EndDisabled(); - - // Clipping - // - Mouse hovering is affected by ImGui::PushClipRect() calls, unlike direct calls to ImDrawList::PushClipRect() which are render only. - IMGUI_API void PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_current_clip_rect); - IMGUI_API void PopClipRect(); - - // Focus, Activation - // - Prefer using "SetItemDefaultFocus()" over "if (IsWindowAppearing()) SetScrollHereY()" when applicable to signify "this is the default item" - IMGUI_API void SetItemDefaultFocus(); // make last item the default focused item of a window. - IMGUI_API void SetKeyboardFocusHere(int offset = 0); // focus keyboard on the next widget. Use positive 'offset' to access sub components of a multiple component widget. Use -1 to access previous widget. - - // Item/Widgets Utilities and Query Functions - // - Most of the functions are referring to the previous Item that has been submitted. - // - See Demo Window under "Widgets->Querying Status" for an interactive visualization of most of those functions. - IMGUI_API bool IsItemHovered(ImGuiHoveredFlags flags = 0); // is the last item hovered? (and usable, aka not blocked by a popup, etc.). See ImGuiHoveredFlags for more options. - IMGUI_API bool IsItemActive(); // is the last item active? (e.g. button being held, text field being edited. This will continuously return true while holding mouse button on an item. Items that don't interact will always return false) - IMGUI_API bool IsItemFocused(); // is the last item focused for keyboard/gamepad navigation? - IMGUI_API bool IsItemClicked(ImGuiMouseButton mouse_button = 0); // is the last item hovered and mouse clicked on? (**) == IsMouseClicked(mouse_button) && IsItemHovered()Important. (**) this it NOT equivalent to the behavior of e.g. Button(). Read comments in function definition. - IMGUI_API bool IsItemVisible(); // is the last item visible? (items may be out of sight because of clipping/scrolling) - IMGUI_API bool IsItemEdited(); // did the last item modify its underlying value this frame? or was pressed? This is generally the same as the "bool" return value of many widgets. - IMGUI_API bool IsItemActivated(); // was the last item just made active (item was previously inactive). - IMGUI_API bool IsItemDeactivated(); // was the last item just made inactive (item was previously active). Useful for Undo/Redo patterns with widgets that requires continuous editing. - IMGUI_API bool IsItemDeactivatedAfterEdit(); // was the last item just made inactive and made a value change when it was active? (e.g. Slider/Drag moved). Useful for Undo/Redo patterns with widgets that requires continuous editing. Note that you may get false positives (some widgets such as Combo()/ListBox()/Selectable() will return true even when clicking an already selected item). - IMGUI_API bool IsItemToggledOpen(); // was the last item open state toggled? set by TreeNode(). - IMGUI_API bool IsAnyItemHovered(); // is any item hovered? - IMGUI_API bool IsAnyItemActive(); // is any item active? - IMGUI_API bool IsAnyItemFocused(); // is any item focused? - IMGUI_API ImVec2 GetItemRectMin(); // get upper-left bounding rectangle of the last item (screen space) - IMGUI_API ImVec2 GetItemRectMax(); // get lower-right bounding rectangle of the last item (screen space) - IMGUI_API ImVec2 GetItemRectSize(); // get size of last item - IMGUI_API void SetItemAllowOverlap(); // allow last item to be overlapped by a subsequent item. sometimes useful with invisible buttons, selectables, etc. to catch unused area. - - // Viewports - // - Currently represents the Platform Window created by the application which is hosting our Dear ImGui windows. - // - In 'docking' branch with multi-viewport enabled, we extend this concept to have multiple active viewports. - // - In the future we will extend this concept further to also represent Platform Monitor and support a "no main platform window" operation mode. - IMGUI_API ImGuiViewport* GetMainViewport(); // return primary/default viewport. This can never be NULL. - - // Miscellaneous Utilities - IMGUI_API bool IsRectVisible(const ImVec2& size); // test if rectangle (of given size, starting from cursor position) is visible / not clipped. - IMGUI_API bool IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max); // test if rectangle (in screen space) is visible / not clipped. to perform coarse clipping on user's side. - IMGUI_API double GetTime(); // get global imgui time. incremented by io.DeltaTime every frame. - IMGUI_API int GetFrameCount(); // get global imgui frame count. incremented by 1 every frame. - IMGUI_API ImDrawList* GetBackgroundDrawList(); // this draw list will be the first rendering one. Useful to quickly draw shapes/text behind dear imgui contents. - IMGUI_API ImDrawList* GetForegroundDrawList(); // this draw list will be the last rendered one. Useful to quickly draw shapes/text over dear imgui contents. - IMGUI_API ImDrawListSharedData* GetDrawListSharedData(); // you may use this when creating your own ImDrawList instances. - IMGUI_API const char* GetStyleColorName(ImGuiCol idx); // get a string corresponding to the enum value (for display, saving, etc.). - IMGUI_API void SetStateStorage(ImGuiStorage* storage); // replace current window storage with our own (if you want to manipulate it yourself, typically clear subsection of it) - IMGUI_API ImGuiStorage* GetStateStorage(); - IMGUI_API void CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end); // calculate coarse clipping for large list of evenly sized items. Prefer using the ImGuiListClipper higher-level helper if you can. - IMGUI_API bool BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags flags = 0); // helper to create a child window / scrolling region that looks like a normal widget frame - IMGUI_API void EndChildFrame(); // always call EndChildFrame() regardless of BeginChildFrame() return values (which indicates a collapsed/clipped window) - - // Text Utilities - IMGUI_API ImVec2 CalcTextSize(const char* text, const char* text_end = NULL, bool hide_text_after_double_hash = false, float wrap_width = -1.0f); - - // Color Utilities - IMGUI_API ImVec4 ColorConvertU32ToFloat4(ImU32 in); - IMGUI_API ImU32 ColorConvertFloat4ToU32(const ImVec4& in); - IMGUI_API void ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v); - IMGUI_API void ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b); - - // Inputs Utilities: Keyboard - // - For 'int user_key_index' you can use your own indices/enums according to how your backend/engine stored them in io.KeysDown[]. - // - We don't know the meaning of those value. You can use GetKeyIndex() to map a ImGuiKey_ value into the user index. - IMGUI_API int GetKeyIndex(ImGuiKey imgui_key); // map ImGuiKey_* values into user's key index. == io.KeyMap[key] - IMGUI_API bool IsKeyDown(int user_key_index); // is key being held. == io.KeysDown[user_key_index]. - IMGUI_API bool IsKeyPressed(int user_key_index, bool repeat = true); // was key pressed (went from !Down to Down)? if repeat=true, uses io.KeyRepeatDelay / KeyRepeatRate - IMGUI_API bool IsKeyReleased(int user_key_index); // was key released (went from Down to !Down)? - IMGUI_API int GetKeyPressedAmount(int key_index, float repeat_delay, float rate); // uses provided repeat rate/delay. return a count, most often 0 or 1 but might be >1 if RepeatRate is small enough that DeltaTime > RepeatRate - IMGUI_API void CaptureKeyboardFromApp(bool want_capture_keyboard_value = true); // attention: misleading name! manually override io.WantCaptureKeyboard flag next frame (said flag is entirely left for your application to handle). e.g. force capture keyboard when your widget is being hovered. This is equivalent to setting "io.WantCaptureKeyboard = want_capture_keyboard_value"; after the next NewFrame() call. - - // Inputs Utilities: Mouse - // - To refer to a mouse button, you may use named enums in your code e.g. ImGuiMouseButton_Left, ImGuiMouseButton_Right. - // - You can also use regular integer: it is forever guaranteed that 0=Left, 1=Right, 2=Middle. - // - Dragging operations are only reported after mouse has moved a certain distance away from the initial clicking position (see 'lock_threshold' and 'io.MouseDraggingThreshold') - IMGUI_API bool IsMouseDown(ImGuiMouseButton button); // is mouse button held? - IMGUI_API bool IsMouseClicked(ImGuiMouseButton button, bool repeat = false); // did mouse button clicked? (went from !Down to Down) - IMGUI_API bool IsMouseReleased(ImGuiMouseButton button); // did mouse button released? (went from Down to !Down) - IMGUI_API bool IsMouseDoubleClicked(ImGuiMouseButton button); // did mouse button double-clicked? (note that a double-click will also report IsMouseClicked() == true) - IMGUI_API bool IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip = true);// is mouse hovering given bounding rect (in screen space). clipped by current clipping settings, but disregarding of other consideration of focus/window ordering/popup-block. - IMGUI_API bool IsMousePosValid(const ImVec2* mouse_pos = NULL); // by convention we use (-FLT_MAX,-FLT_MAX) to denote that there is no mouse available - IMGUI_API bool IsAnyMouseDown(); // is any mouse button held? - IMGUI_API ImVec2 GetMousePos(); // shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls - IMGUI_API ImVec2 GetMousePosOnOpeningCurrentPopup(); // retrieve mouse position at the time of opening popup we have BeginPopup() into (helper to avoid user backing that value themselves) - IMGUI_API bool IsMouseDragging(ImGuiMouseButton button, float lock_threshold = -1.0f); // is mouse dragging? (if lock_threshold < -1.0f, uses io.MouseDraggingThreshold) - IMGUI_API ImVec2 GetMouseDragDelta(ImGuiMouseButton button = 0, float lock_threshold = -1.0f); // return the delta from the initial clicking position while the mouse button is pressed or was just released. This is locked and return 0.0f until the mouse moves past a distance threshold at least once (if lock_threshold < -1.0f, uses io.MouseDraggingThreshold) - IMGUI_API void ResetMouseDragDelta(ImGuiMouseButton button = 0); // - IMGUI_API ImGuiMouseCursor GetMouseCursor(); // get desired cursor type, reset in ImGui::NewFrame(), this is updated during the frame. valid before Render(). If you use software rendering by setting io.MouseDrawCursor ImGui will render those for you - IMGUI_API void SetMouseCursor(ImGuiMouseCursor cursor_type); // set desired cursor type - IMGUI_API void CaptureMouseFromApp(bool want_capture_mouse_value = true); // attention: misleading name! manually override io.WantCaptureMouse flag next frame (said flag is entirely left for your application to handle). This is equivalent to setting "io.WantCaptureMouse = want_capture_mouse_value;" after the next NewFrame() call. - - // Clipboard Utilities - // - Also see the LogToClipboard() function to capture GUI into clipboard, or easily output text data to the clipboard. - IMGUI_API const char* GetClipboardText(); - IMGUI_API void SetClipboardText(const char* text); - - // Settings/.Ini Utilities - // - The disk functions are automatically called if io.IniFilename != NULL (default is "imgui.ini"). - // - Set io.IniFilename to NULL to load/save manually. Read io.WantSaveIniSettings description about handling .ini saving manually. - // - Important: default value "imgui.ini" is relative to current working dir! Most apps will want to lock this to an absolute path (e.g. same path as executables). - IMGUI_API void LoadIniSettingsFromDisk(const char* ini_filename); // call after CreateContext() and before the first call to NewFrame(). NewFrame() automatically calls LoadIniSettingsFromDisk(io.IniFilename). - IMGUI_API void LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size=0); // call after CreateContext() and before the first call to NewFrame() to provide .ini data from your own data source. - IMGUI_API void SaveIniSettingsToDisk(const char* ini_filename); // this is automatically called (if io.IniFilename is not empty) a few seconds after any modification that should be reflected in the .ini file (and also by DestroyContext). - IMGUI_API const char* SaveIniSettingsToMemory(size_t* out_ini_size = NULL); // return a zero-terminated string with the .ini data which you can save by your own mean. call when io.WantSaveIniSettings is set, then save data by your own mean and clear io.WantSaveIniSettings. - - // Debug Utilities - // - This is used by the IMGUI_CHECKVERSION() macro. - IMGUI_API bool DebugCheckVersionAndDataLayout(const char* version_str, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_drawvert, size_t sz_drawidx); // This is called by IMGUI_CHECKVERSION() macro. - - // Memory Allocators - // - Those functions are not reliant on the current context. - // - DLL users: heaps and globals are not shared across DLL boundaries! You will need to call SetCurrentContext() + SetAllocatorFunctions() - // for each static/DLL boundary you are calling from. Read "Context and Memory Allocators" section of imgui.cpp for more details. - IMGUI_API void SetAllocatorFunctions(ImGuiMemAllocFunc alloc_func, ImGuiMemFreeFunc free_func, void* user_data = NULL); - IMGUI_API void GetAllocatorFunctions(ImGuiMemAllocFunc* p_alloc_func, ImGuiMemFreeFunc* p_free_func, void** p_user_data); - IMGUI_API void* MemAlloc(size_t size); - IMGUI_API void MemFree(void* ptr); - -} // namespace ImGui - -//----------------------------------------------------------------------------- -// [SECTION] Flags & Enumerations -//----------------------------------------------------------------------------- - -// Flags for ImGui::Begin() -enum ImGuiWindowFlags_ -{ - ImGuiWindowFlags_None = 0, - ImGuiWindowFlags_NoTitleBar = 1 << 0, // Disable title-bar - ImGuiWindowFlags_NoResize = 1 << 1, // Disable user resizing with the lower-right grip - ImGuiWindowFlags_NoMove = 1 << 2, // Disable user moving the window - ImGuiWindowFlags_NoScrollbar = 1 << 3, // Disable scrollbars (window can still scroll with mouse or programmatically) - ImGuiWindowFlags_NoScrollWithMouse = 1 << 4, // Disable user vertically scrolling with mouse wheel. On child window, mouse wheel will be forwarded to the parent unless NoScrollbar is also set. - ImGuiWindowFlags_NoCollapse = 1 << 5, // Disable user collapsing window by double-clicking on it - ImGuiWindowFlags_AlwaysAutoResize = 1 << 6, // Resize every window to its content every frame - ImGuiWindowFlags_NoBackground = 1 << 7, // Disable drawing background color (WindowBg, etc.) and outside border. Similar as using SetNextWindowBgAlpha(0.0f). - ImGuiWindowFlags_NoSavedSettings = 1 << 8, // Never load/save settings in .ini file - ImGuiWindowFlags_NoMouseInputs = 1 << 9, // Disable catching mouse, hovering test with pass through. - ImGuiWindowFlags_MenuBar = 1 << 10, // Has a menu-bar - ImGuiWindowFlags_HorizontalScrollbar = 1 << 11, // Allow horizontal scrollbar to appear (off by default). You may use SetNextWindowContentSize(ImVec2(width,0.0f)); prior to calling Begin() to specify width. Read code in imgui_demo in the "Horizontal Scrolling" section. - ImGuiWindowFlags_NoFocusOnAppearing = 1 << 12, // Disable taking focus when transitioning from hidden to visible state - ImGuiWindowFlags_NoBringToFrontOnFocus = 1 << 13, // Disable bringing window to front when taking focus (e.g. clicking on it or programmatically giving it focus) - ImGuiWindowFlags_AlwaysVerticalScrollbar= 1 << 14, // Always show vertical scrollbar (even if ContentSize.y < Size.y) - ImGuiWindowFlags_AlwaysHorizontalScrollbar=1<< 15, // Always show horizontal scrollbar (even if ContentSize.x < Size.x) - ImGuiWindowFlags_AlwaysUseWindowPadding = 1 << 16, // Ensure child windows without border uses style.WindowPadding (ignored by default for non-bordered child windows, because more convenient) - ImGuiWindowFlags_NoNavInputs = 1 << 18, // No gamepad/keyboard navigation within the window - ImGuiWindowFlags_NoNavFocus = 1 << 19, // No focusing toward this window with gamepad/keyboard navigation (e.g. skipped by CTRL+TAB) - ImGuiWindowFlags_UnsavedDocument = 1 << 20, // Display a dot next to the title. When used in a tab/docking context, tab is selected when clicking the X + closure is not assumed (will wait for user to stop submitting the tab). Otherwise closure is assumed when pressing the X, so if you keep submitting the tab may reappear at end of tab bar. - ImGuiWindowFlags_NoNav = ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus, - ImGuiWindowFlags_NoDecoration = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse, - ImGuiWindowFlags_NoInputs = ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus, - - // [Internal] - ImGuiWindowFlags_NavFlattened = 1 << 23, // [BETA] Allow gamepad/keyboard navigation to cross over parent border to this child (only use on child that have no scrolling!) - ImGuiWindowFlags_ChildWindow = 1 << 24, // Don't use! For internal use by BeginChild() - ImGuiWindowFlags_Tooltip = 1 << 25, // Don't use! For internal use by BeginTooltip() - ImGuiWindowFlags_Popup = 1 << 26, // Don't use! For internal use by BeginPopup() - ImGuiWindowFlags_Modal = 1 << 27, // Don't use! For internal use by BeginPopupModal() - ImGuiWindowFlags_ChildMenu = 1 << 28 // Don't use! For internal use by BeginMenu() - - // [Obsolete] - //ImGuiWindowFlags_ResizeFromAnySide = 1 << 17, // --> Set io.ConfigWindowsResizeFromEdges=true and make sure mouse cursors are supported by backend (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) -}; - -// Flags for ImGui::InputText() -enum ImGuiInputTextFlags_ -{ - ImGuiInputTextFlags_None = 0, - ImGuiInputTextFlags_CharsDecimal = 1 << 0, // Allow 0123456789.+-*/ - ImGuiInputTextFlags_CharsHexadecimal = 1 << 1, // Allow 0123456789ABCDEFabcdef - ImGuiInputTextFlags_CharsUppercase = 1 << 2, // Turn a..z into A..Z - ImGuiInputTextFlags_CharsNoBlank = 1 << 3, // Filter out spaces, tabs - ImGuiInputTextFlags_AutoSelectAll = 1 << 4, // Select entire text when first taking mouse focus - ImGuiInputTextFlags_EnterReturnsTrue = 1 << 5, // Return 'true' when Enter is pressed (as opposed to every time the value was modified). Consider looking at the IsItemDeactivatedAfterEdit() function. - ImGuiInputTextFlags_CallbackCompletion = 1 << 6, // Callback on pressing TAB (for completion handling) - ImGuiInputTextFlags_CallbackHistory = 1 << 7, // Callback on pressing Up/Down arrows (for history handling) - ImGuiInputTextFlags_CallbackAlways = 1 << 8, // Callback on each iteration. User code may query cursor position, modify text buffer. - ImGuiInputTextFlags_CallbackCharFilter = 1 << 9, // Callback on character inputs to replace or discard them. Modify 'EventChar' to replace or discard, or return 1 in callback to discard. - ImGuiInputTextFlags_AllowTabInput = 1 << 10, // Pressing TAB input a '\t' character into the text field - ImGuiInputTextFlags_CtrlEnterForNewLine = 1 << 11, // In multi-line mode, unfocus with Enter, add new line with Ctrl+Enter (default is opposite: unfocus with Ctrl+Enter, add line with Enter). - ImGuiInputTextFlags_NoHorizontalScroll = 1 << 12, // Disable following the cursor horizontally - ImGuiInputTextFlags_AlwaysOverwrite = 1 << 13, // Overwrite mode - ImGuiInputTextFlags_ReadOnly = 1 << 14, // Read-only mode - ImGuiInputTextFlags_Password = 1 << 15, // Password mode, display all characters as '*' - ImGuiInputTextFlags_NoUndoRedo = 1 << 16, // Disable undo/redo. Note that input text owns the text data while active, if you want to provide your own undo/redo stack you need e.g. to call ClearActiveID(). - ImGuiInputTextFlags_CharsScientific = 1 << 17, // Allow 0123456789.+-*/eE (Scientific notation input) - ImGuiInputTextFlags_CallbackResize = 1 << 18, // Callback on buffer capacity changes request (beyond 'buf_size' parameter value), allowing the string to grow. Notify when the string wants to be resized (for string types which hold a cache of their Size). You will be provided a new BufSize in the callback and NEED to honor it. (see misc/cpp/imgui_stdlib.h for an example of using this) - ImGuiInputTextFlags_CallbackEdit = 1 << 19 // Callback on any edit (note that InputText() already returns true on edit, the callback is useful mainly to manipulate the underlying buffer while focus is active) - - // Obsolete names (will be removed soon) -#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS - , ImGuiInputTextFlags_AlwaysInsertMode = ImGuiInputTextFlags_AlwaysOverwrite // [renamed in 1.82] name was not matching behavior -#endif -}; - -// Flags for ImGui::TreeNodeEx(), ImGui::CollapsingHeader*() -enum ImGuiTreeNodeFlags_ -{ - ImGuiTreeNodeFlags_None = 0, - ImGuiTreeNodeFlags_Selected = 1 << 0, // Draw as selected - ImGuiTreeNodeFlags_Framed = 1 << 1, // Draw frame with background (e.g. for CollapsingHeader) - ImGuiTreeNodeFlags_AllowItemOverlap = 1 << 2, // Hit testing to allow subsequent widgets to overlap this one - ImGuiTreeNodeFlags_NoTreePushOnOpen = 1 << 3, // Don't do a TreePush() when open (e.g. for CollapsingHeader) = no extra indent nor pushing on ID stack - ImGuiTreeNodeFlags_NoAutoOpenOnLog = 1 << 4, // Don't automatically and temporarily open node when Logging is active (by default logging will automatically open tree nodes) - ImGuiTreeNodeFlags_DefaultOpen = 1 << 5, // Default node to be open - ImGuiTreeNodeFlags_OpenOnDoubleClick = 1 << 6, // Need double-click to open node - ImGuiTreeNodeFlags_OpenOnArrow = 1 << 7, // Only open when clicking on the arrow part. If ImGuiTreeNodeFlags_OpenOnDoubleClick is also set, single-click arrow or double-click all box to open. - ImGuiTreeNodeFlags_Leaf = 1 << 8, // No collapsing, no arrow (use as a convenience for leaf nodes). - ImGuiTreeNodeFlags_Bullet = 1 << 9, // Display a bullet instead of arrow - ImGuiTreeNodeFlags_FramePadding = 1 << 10, // Use FramePadding (even for an unframed text node) to vertically align text baseline to regular widget height. Equivalent to calling AlignTextToFramePadding(). - ImGuiTreeNodeFlags_SpanAvailWidth = 1 << 11, // Extend hit box to the right-most edge, even if not framed. This is not the default in order to allow adding other items on the same line. In the future we may refactor the hit system to be front-to-back, allowing natural overlaps and then this can become the default. - ImGuiTreeNodeFlags_SpanFullWidth = 1 << 12, // Extend hit box to the left-most and right-most edges (bypass the indented area). - ImGuiTreeNodeFlags_NavLeftJumpsBackHere = 1 << 13, // (WIP) Nav: left direction may move to this TreeNode() from any of its child (items submitted between TreeNode and TreePop) - //ImGuiTreeNodeFlags_NoScrollOnOpen = 1 << 14, // FIXME: TODO: Disable automatic scroll on TreePop() if node got just open and contents is not visible - ImGuiTreeNodeFlags_CollapsingHeader = ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_NoAutoOpenOnLog -}; - -// Flags for OpenPopup*(), BeginPopupContext*(), IsPopupOpen() functions. -// - To be backward compatible with older API which took an 'int mouse_button = 1' argument, we need to treat -// small flags values as a mouse button index, so we encode the mouse button in the first few bits of the flags. -// It is therefore guaranteed to be legal to pass a mouse button index in ImGuiPopupFlags. -// - For the same reason, we exceptionally default the ImGuiPopupFlags argument of BeginPopupContextXXX functions to 1 instead of 0. -// IMPORTANT: because the default parameter is 1 (==ImGuiPopupFlags_MouseButtonRight), if you rely on the default parameter -// and want to another another flag, you need to pass in the ImGuiPopupFlags_MouseButtonRight flag. -// - Multiple buttons currently cannot be combined/or-ed in those functions (we could allow it later). -enum ImGuiPopupFlags_ -{ - ImGuiPopupFlags_None = 0, - ImGuiPopupFlags_MouseButtonLeft = 0, // For BeginPopupContext*(): open on Left Mouse release. Guaranteed to always be == 0 (same as ImGuiMouseButton_Left) - ImGuiPopupFlags_MouseButtonRight = 1, // For BeginPopupContext*(): open on Right Mouse release. Guaranteed to always be == 1 (same as ImGuiMouseButton_Right) - ImGuiPopupFlags_MouseButtonMiddle = 2, // For BeginPopupContext*(): open on Middle Mouse release. Guaranteed to always be == 2 (same as ImGuiMouseButton_Middle) - ImGuiPopupFlags_MouseButtonMask_ = 0x1F, - ImGuiPopupFlags_MouseButtonDefault_ = 1, - ImGuiPopupFlags_NoOpenOverExistingPopup = 1 << 5, // For OpenPopup*(), BeginPopupContext*(): don't open if there's already a popup at the same level of the popup stack - ImGuiPopupFlags_NoOpenOverItems = 1 << 6, // For BeginPopupContextWindow(): don't return true when hovering items, only when hovering empty space - ImGuiPopupFlags_AnyPopupId = 1 << 7, // For IsPopupOpen(): ignore the ImGuiID parameter and test for any popup. - ImGuiPopupFlags_AnyPopupLevel = 1 << 8, // For IsPopupOpen(): search/test at any level of the popup stack (default test in the current level) - ImGuiPopupFlags_AnyPopup = ImGuiPopupFlags_AnyPopupId | ImGuiPopupFlags_AnyPopupLevel -}; - -// Flags for ImGui::Selectable() -enum ImGuiSelectableFlags_ -{ - ImGuiSelectableFlags_None = 0, - ImGuiSelectableFlags_DontClosePopups = 1 << 0, // Clicking this don't close parent popup window - ImGuiSelectableFlags_SpanAllColumns = 1 << 1, // Selectable frame can span all columns (text will still fit in current column) - ImGuiSelectableFlags_AllowDoubleClick = 1 << 2, // Generate press events on double clicks too - ImGuiSelectableFlags_Disabled = 1 << 3, // Cannot be selected, display grayed out text - ImGuiSelectableFlags_AllowItemOverlap = 1 << 4 // (WIP) Hit testing to allow subsequent widgets to overlap this one -}; - -// Flags for ImGui::BeginCombo() -enum ImGuiComboFlags_ -{ - ImGuiComboFlags_None = 0, - ImGuiComboFlags_PopupAlignLeft = 1 << 0, // Align the popup toward the left by default - ImGuiComboFlags_HeightSmall = 1 << 1, // Max ~4 items visible. Tip: If you want your combo popup to be a specific size you can use SetNextWindowSizeConstraints() prior to calling BeginCombo() - ImGuiComboFlags_HeightRegular = 1 << 2, // Max ~8 items visible (default) - ImGuiComboFlags_HeightLarge = 1 << 3, // Max ~20 items visible - ImGuiComboFlags_HeightLargest = 1 << 4, // As many fitting items as possible - ImGuiComboFlags_NoArrowButton = 1 << 5, // Display on the preview box without the square arrow button - ImGuiComboFlags_NoPreview = 1 << 6, // Display only a square arrow button - ImGuiComboFlags_HeightMask_ = ImGuiComboFlags_HeightSmall | ImGuiComboFlags_HeightRegular | ImGuiComboFlags_HeightLarge | ImGuiComboFlags_HeightLargest -}; - -// Flags for ImGui::BeginTabBar() -enum ImGuiTabBarFlags_ -{ - ImGuiTabBarFlags_None = 0, - ImGuiTabBarFlags_Reorderable = 1 << 0, // Allow manually dragging tabs to re-order them + New tabs are appended at the end of list - ImGuiTabBarFlags_AutoSelectNewTabs = 1 << 1, // Automatically select new tabs when they appear - ImGuiTabBarFlags_TabListPopupButton = 1 << 2, // Disable buttons to open the tab list popup - ImGuiTabBarFlags_NoCloseWithMiddleMouseButton = 1 << 3, // Disable behavior of closing tabs (that are submitted with p_open != NULL) with middle mouse button. You can still repro this behavior on user's side with if (IsItemHovered() && IsMouseClicked(2)) *p_open = false. - ImGuiTabBarFlags_NoTabListScrollingButtons = 1 << 4, // Disable scrolling buttons (apply when fitting policy is ImGuiTabBarFlags_FittingPolicyScroll) - ImGuiTabBarFlags_NoTooltip = 1 << 5, // Disable tooltips when hovering a tab - ImGuiTabBarFlags_FittingPolicyResizeDown = 1 << 6, // Resize tabs when they don't fit - ImGuiTabBarFlags_FittingPolicyScroll = 1 << 7, // Add scroll buttons when tabs don't fit - ImGuiTabBarFlags_FittingPolicyMask_ = ImGuiTabBarFlags_FittingPolicyResizeDown | ImGuiTabBarFlags_FittingPolicyScroll, - ImGuiTabBarFlags_FittingPolicyDefault_ = ImGuiTabBarFlags_FittingPolicyResizeDown -}; - -// Flags for ImGui::BeginTabItem() -enum ImGuiTabItemFlags_ -{ - ImGuiTabItemFlags_None = 0, - ImGuiTabItemFlags_UnsavedDocument = 1 << 0, // Display a dot next to the title + tab is selected when clicking the X + closure is not assumed (will wait for user to stop submitting the tab). Otherwise closure is assumed when pressing the X, so if you keep submitting the tab may reappear at end of tab bar. - ImGuiTabItemFlags_SetSelected = 1 << 1, // Trigger flag to programmatically make the tab selected when calling BeginTabItem() - ImGuiTabItemFlags_NoCloseWithMiddleMouseButton = 1 << 2, // Disable behavior of closing tabs (that are submitted with p_open != NULL) with middle mouse button. You can still repro this behavior on user's side with if (IsItemHovered() && IsMouseClicked(2)) *p_open = false. - ImGuiTabItemFlags_NoPushId = 1 << 3, // Don't call PushID(tab->ID)/PopID() on BeginTabItem()/EndTabItem() - ImGuiTabItemFlags_NoTooltip = 1 << 4, // Disable tooltip for the given tab - ImGuiTabItemFlags_NoReorder = 1 << 5, // Disable reordering this tab or having another tab cross over this tab - ImGuiTabItemFlags_Leading = 1 << 6, // Enforce the tab position to the left of the tab bar (after the tab list popup button) - ImGuiTabItemFlags_Trailing = 1 << 7 // Enforce the tab position to the right of the tab bar (before the scrolling buttons) -}; - -// Flags for ImGui::BeginTable() -// [BETA API] API may evolve slightly! If you use this, please update to the next version when it comes out! -// - Important! Sizing policies have complex and subtle side effects, more so than you would expect. -// Read comments/demos carefully + experiment with live demos to get acquainted with them. -// - The DEFAULT sizing policies are: -// - Default to ImGuiTableFlags_SizingFixedFit if ScrollX is on, or if host window has ImGuiWindowFlags_AlwaysAutoResize. -// - Default to ImGuiTableFlags_SizingStretchSame if ScrollX is off. -// - When ScrollX is off: -// - Table defaults to ImGuiTableFlags_SizingStretchSame -> all Columns defaults to ImGuiTableColumnFlags_WidthStretch with same weight. -// - Columns sizing policy allowed: Stretch (default), Fixed/Auto. -// - Fixed Columns will generally obtain their requested width (unless the table cannot fit them all). -// - Stretch Columns will share the remaining width. -// - Mixed Fixed/Stretch columns is possible but has various side-effects on resizing behaviors. -// The typical use of mixing sizing policies is: any number of LEADING Fixed columns, followed by one or two TRAILING Stretch columns. -// (this is because the visible order of columns have subtle but necessary effects on how they react to manual resizing). -// - When ScrollX is on: -// - Table defaults to ImGuiTableFlags_SizingFixedFit -> all Columns defaults to ImGuiTableColumnFlags_WidthFixed -// - Columns sizing policy allowed: Fixed/Auto mostly. -// - Fixed Columns can be enlarged as needed. Table will show an horizontal scrollbar if needed. -// - When using auto-resizing (non-resizable) fixed columns, querying the content width to use item right-alignment e.g. SetNextItemWidth(-FLT_MIN) doesn't make sense, would create a feedback loop. -// - Using Stretch columns OFTEN DOES NOT MAKE SENSE if ScrollX is on, UNLESS you have specified a value for 'inner_width' in BeginTable(). -// If you specify a value for 'inner_width' then effectively the scrolling space is known and Stretch or mixed Fixed/Stretch columns become meaningful again. -// - Read on documentation at the top of imgui_tables.cpp for details. -enum ImGuiTableFlags_ -{ - // Features - ImGuiTableFlags_None = 0, - ImGuiTableFlags_Resizable = 1 << 0, // Enable resizing columns. - ImGuiTableFlags_Reorderable = 1 << 1, // Enable reordering columns in header row (need calling TableSetupColumn() + TableHeadersRow() to display headers) - ImGuiTableFlags_Hideable = 1 << 2, // Enable hiding/disabling columns in context menu. - ImGuiTableFlags_Sortable = 1 << 3, // Enable sorting. Call TableGetSortSpecs() to obtain sort specs. Also see ImGuiTableFlags_SortMulti and ImGuiTableFlags_SortTristate. - ImGuiTableFlags_NoSavedSettings = 1 << 4, // Disable persisting columns order, width and sort settings in the .ini file. - ImGuiTableFlags_ContextMenuInBody = 1 << 5, // Right-click on columns body/contents will display table context menu. By default it is available in TableHeadersRow(). - // Decorations - ImGuiTableFlags_RowBg = 1 << 6, // Set each RowBg color with ImGuiCol_TableRowBg or ImGuiCol_TableRowBgAlt (equivalent of calling TableSetBgColor with ImGuiTableBgFlags_RowBg0 on each row manually) - ImGuiTableFlags_BordersInnerH = 1 << 7, // Draw horizontal borders between rows. - ImGuiTableFlags_BordersOuterH = 1 << 8, // Draw horizontal borders at the top and bottom. - ImGuiTableFlags_BordersInnerV = 1 << 9, // Draw vertical borders between columns. - ImGuiTableFlags_BordersOuterV = 1 << 10, // Draw vertical borders on the left and right sides. - ImGuiTableFlags_BordersH = ImGuiTableFlags_BordersInnerH | ImGuiTableFlags_BordersOuterH, // Draw horizontal borders. - ImGuiTableFlags_BordersV = ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_BordersOuterV, // Draw vertical borders. - ImGuiTableFlags_BordersInner = ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_BordersInnerH, // Draw inner borders. - ImGuiTableFlags_BordersOuter = ImGuiTableFlags_BordersOuterV | ImGuiTableFlags_BordersOuterH, // Draw outer borders. - ImGuiTableFlags_Borders = ImGuiTableFlags_BordersInner | ImGuiTableFlags_BordersOuter, // Draw all borders. - ImGuiTableFlags_NoBordersInBody = 1 << 11, // [ALPHA] Disable vertical borders in columns Body (borders will always appears in Headers). -> May move to style - ImGuiTableFlags_NoBordersInBodyUntilResize = 1 << 12, // [ALPHA] Disable vertical borders in columns Body until hovered for resize (borders will always appears in Headers). -> May move to style - // Sizing Policy (read above for defaults) - ImGuiTableFlags_SizingFixedFit = 1 << 13, // Columns default to _WidthFixed or _WidthAuto (if resizable or not resizable), matching contents width. - ImGuiTableFlags_SizingFixedSame = 2 << 13, // Columns default to _WidthFixed or _WidthAuto (if resizable or not resizable), matching the maximum contents width of all columns. Implicitly enable ImGuiTableFlags_NoKeepColumnsVisible. - ImGuiTableFlags_SizingStretchProp = 3 << 13, // Columns default to _WidthStretch with default weights proportional to each columns contents widths. - ImGuiTableFlags_SizingStretchSame = 4 << 13, // Columns default to _WidthStretch with default weights all equal, unless overridden by TableSetupColumn(). - // Sizing Extra Options - ImGuiTableFlags_NoHostExtendX = 1 << 16, // Make outer width auto-fit to columns, overriding outer_size.x value. Only available when ScrollX/ScrollY are disabled and Stretch columns are not used. - ImGuiTableFlags_NoHostExtendY = 1 << 17, // Make outer height stop exactly at outer_size.y (prevent auto-extending table past the limit). Only available when ScrollX/ScrollY are disabled. Data below the limit will be clipped and not visible. - ImGuiTableFlags_NoKeepColumnsVisible = 1 << 18, // Disable keeping column always minimally visible when ScrollX is off and table gets too small. Not recommended if columns are resizable. - ImGuiTableFlags_PreciseWidths = 1 << 19, // Disable distributing remainder width to stretched columns (width allocation on a 100-wide table with 3 columns: Without this flag: 33,33,34. With this flag: 33,33,33). With larger number of columns, resizing will appear to be less smooth. - // Clipping - ImGuiTableFlags_NoClip = 1 << 20, // Disable clipping rectangle for every individual columns (reduce draw command count, items will be able to overflow into other columns). Generally incompatible with TableSetupScrollFreeze(). - // Padding - ImGuiTableFlags_PadOuterX = 1 << 21, // Default if BordersOuterV is on. Enable outer-most padding. Generally desirable if you have headers. - ImGuiTableFlags_NoPadOuterX = 1 << 22, // Default if BordersOuterV is off. Disable outer-most padding. - ImGuiTableFlags_NoPadInnerX = 1 << 23, // Disable inner padding between columns (double inner padding if BordersOuterV is on, single inner padding if BordersOuterV is off). - // Scrolling - ImGuiTableFlags_ScrollX = 1 << 24, // Enable horizontal scrolling. Require 'outer_size' parameter of BeginTable() to specify the container size. Changes default sizing policy. Because this create a child window, ScrollY is currently generally recommended when using ScrollX. - ImGuiTableFlags_ScrollY = 1 << 25, // Enable vertical scrolling. Require 'outer_size' parameter of BeginTable() to specify the container size. - // Sorting - ImGuiTableFlags_SortMulti = 1 << 26, // Hold shift when clicking headers to sort on multiple column. TableGetSortSpecs() may return specs where (SpecsCount > 1). - ImGuiTableFlags_SortTristate = 1 << 27, // Allow no sorting, disable default sorting. TableGetSortSpecs() may return specs where (SpecsCount == 0). - - // [Internal] Combinations and masks - ImGuiTableFlags_SizingMask_ = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_SizingFixedSame | ImGuiTableFlags_SizingStretchProp | ImGuiTableFlags_SizingStretchSame - - // Obsolete names (will be removed soon) -#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS - //, ImGuiTableFlags_ColumnsWidthFixed = ImGuiTableFlags_SizingFixedFit, ImGuiTableFlags_ColumnsWidthStretch = ImGuiTableFlags_SizingStretchSame // WIP Tables 2020/12 - //, ImGuiTableFlags_SizingPolicyFixed = ImGuiTableFlags_SizingFixedFit, ImGuiTableFlags_SizingPolicyStretch = ImGuiTableFlags_SizingStretchSame // WIP Tables 2021/01 -#endif -}; - -// Flags for ImGui::TableSetupColumn() -enum ImGuiTableColumnFlags_ -{ - // Input configuration flags - ImGuiTableColumnFlags_None = 0, - ImGuiTableColumnFlags_Disabled = 1 << 0, // Overriding/master disable flag: hide column, won't show in context menu (unlike calling TableSetColumnEnabled() which manipulates the user accessible state) - ImGuiTableColumnFlags_DefaultHide = 1 << 1, // Default as a hidden/disabled column. - ImGuiTableColumnFlags_DefaultSort = 1 << 2, // Default as a sorting column. - ImGuiTableColumnFlags_WidthStretch = 1 << 3, // Column will stretch. Preferable with horizontal scrolling disabled (default if table sizing policy is _SizingStretchSame or _SizingStretchProp). - ImGuiTableColumnFlags_WidthFixed = 1 << 4, // Column will not stretch. Preferable with horizontal scrolling enabled (default if table sizing policy is _SizingFixedFit and table is resizable). - ImGuiTableColumnFlags_NoResize = 1 << 5, // Disable manual resizing. - ImGuiTableColumnFlags_NoReorder = 1 << 6, // Disable manual reordering this column, this will also prevent other columns from crossing over this column. - ImGuiTableColumnFlags_NoHide = 1 << 7, // Disable ability to hide/disable this column. - ImGuiTableColumnFlags_NoClip = 1 << 8, // Disable clipping for this column (all NoClip columns will render in a same draw command). - ImGuiTableColumnFlags_NoSort = 1 << 9, // Disable ability to sort on this field (even if ImGuiTableFlags_Sortable is set on the table). - ImGuiTableColumnFlags_NoSortAscending = 1 << 10, // Disable ability to sort in the ascending direction. - ImGuiTableColumnFlags_NoSortDescending = 1 << 11, // Disable ability to sort in the descending direction. - ImGuiTableColumnFlags_NoHeaderLabel = 1 << 12, // TableHeadersRow() will not submit label for this column. Convenient for some small columns. Name will still appear in context menu. - ImGuiTableColumnFlags_NoHeaderWidth = 1 << 13, // Disable header text width contribution to automatic column width. - ImGuiTableColumnFlags_PreferSortAscending = 1 << 14, // Make the initial sort direction Ascending when first sorting on this column (default). - ImGuiTableColumnFlags_PreferSortDescending = 1 << 15, // Make the initial sort direction Descending when first sorting on this column. - ImGuiTableColumnFlags_IndentEnable = 1 << 16, // Use current Indent value when entering cell (default for column 0). - ImGuiTableColumnFlags_IndentDisable = 1 << 17, // Ignore current Indent value when entering cell (default for columns > 0). Indentation changes _within_ the cell will still be honored. - - // Output status flags, read-only via TableGetColumnFlags() - ImGuiTableColumnFlags_IsEnabled = 1 << 24, // Status: is enabled == not hidden by user/api (referred to as "Hide" in _DefaultHide and _NoHide) flags. - ImGuiTableColumnFlags_IsVisible = 1 << 25, // Status: is visible == is enabled AND not clipped by scrolling. - ImGuiTableColumnFlags_IsSorted = 1 << 26, // Status: is currently part of the sort specs - ImGuiTableColumnFlags_IsHovered = 1 << 27, // Status: is hovered by mouse - - // [Internal] Combinations and masks - ImGuiTableColumnFlags_WidthMask_ = ImGuiTableColumnFlags_WidthStretch | ImGuiTableColumnFlags_WidthFixed, - ImGuiTableColumnFlags_IndentMask_ = ImGuiTableColumnFlags_IndentEnable | ImGuiTableColumnFlags_IndentDisable, - ImGuiTableColumnFlags_StatusMask_ = ImGuiTableColumnFlags_IsEnabled | ImGuiTableColumnFlags_IsVisible | ImGuiTableColumnFlags_IsSorted | ImGuiTableColumnFlags_IsHovered, - ImGuiTableColumnFlags_NoDirectResize_ = 1 << 30 // [Internal] Disable user resizing this column directly (it may however we resized indirectly from its left edge) - - // Obsolete names (will be removed soon) -#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS - //ImGuiTableColumnFlags_WidthAuto = ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_NoResize, // Column will not stretch and keep resizing based on submitted contents. -#endif -}; - -// Flags for ImGui::TableNextRow() -enum ImGuiTableRowFlags_ -{ - ImGuiTableRowFlags_None = 0, - ImGuiTableRowFlags_Headers = 1 << 0 // Identify header row (set default background color + width of its contents accounted different for auto column width) -}; - -// Enum for ImGui::TableSetBgColor() -// Background colors are rendering in 3 layers: -// - Layer 0: draw with RowBg0 color if set, otherwise draw with ColumnBg0 if set. -// - Layer 1: draw with RowBg1 color if set, otherwise draw with ColumnBg1 if set. -// - Layer 2: draw with CellBg color if set. -// The purpose of the two row/columns layers is to let you decide if a background color changes should override or blend with the existing color. -// When using ImGuiTableFlags_RowBg on the table, each row has the RowBg0 color automatically set for odd/even rows. -// If you set the color of RowBg0 target, your color will override the existing RowBg0 color. -// If you set the color of RowBg1 or ColumnBg1 target, your color will blend over the RowBg0 color. -enum ImGuiTableBgTarget_ -{ - ImGuiTableBgTarget_None = 0, - ImGuiTableBgTarget_RowBg0 = 1, // Set row background color 0 (generally used for background, automatically set when ImGuiTableFlags_RowBg is used) - ImGuiTableBgTarget_RowBg1 = 2, // Set row background color 1 (generally used for selection marking) - ImGuiTableBgTarget_CellBg = 3 // Set cell background color (top-most color) -}; - -// Flags for ImGui::IsWindowFocused() -enum ImGuiFocusedFlags_ -{ - ImGuiFocusedFlags_None = 0, - ImGuiFocusedFlags_ChildWindows = 1 << 0, // Return true if any children of the window is focused - ImGuiFocusedFlags_RootWindow = 1 << 1, // Test from root window (top most parent of the current hierarchy) - ImGuiFocusedFlags_AnyWindow = 1 << 2, // Return true if any window is focused. Important: If you are trying to tell how to dispatch your low-level inputs, do NOT use this. Use 'io.WantCaptureMouse' instead! Please read the FAQ! - ImGuiFocusedFlags_NoPopupHierarchy = 1 << 3, // Do not consider popup hierarchy (do not treat popup emitter as parent of popup) (when used with _ChildWindows or _RootWindow) - //ImGuiFocusedFlags_DockHierarchy = 1 << 4, // Consider docking hierarchy (treat dockspace host as parent of docked window) (when used with _ChildWindows or _RootWindow) - ImGuiFocusedFlags_RootAndChildWindows = ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows -}; - -// Flags for ImGui::IsItemHovered(), ImGui::IsWindowHovered() -// Note: if you are trying to check whether your mouse should be dispatched to Dear ImGui or to your app, you should use 'io.WantCaptureMouse' instead! Please read the FAQ! -// Note: windows with the ImGuiWindowFlags_NoInputs flag are ignored by IsWindowHovered() calls. -enum ImGuiHoveredFlags_ -{ - ImGuiHoveredFlags_None = 0, // Return true if directly over the item/window, not obstructed by another window, not obstructed by an active popup or modal blocking inputs under them. - ImGuiHoveredFlags_ChildWindows = 1 << 0, // IsWindowHovered() only: Return true if any children of the window is hovered - ImGuiHoveredFlags_RootWindow = 1 << 1, // IsWindowHovered() only: Test from root window (top most parent of the current hierarchy) - ImGuiHoveredFlags_AnyWindow = 1 << 2, // IsWindowHovered() only: Return true if any window is hovered - ImGuiHoveredFlags_NoPopupHierarchy = 1 << 3, // IsWindowHovered() only: Do not consider popup hierarchy (do not treat popup emitter as parent of popup) (when used with _ChildWindows or _RootWindow) - //ImGuiHoveredFlags_DockHierarchy = 1 << 4, // IsWindowHovered() only: Consider docking hierarchy (treat dockspace host as parent of docked window) (when used with _ChildWindows or _RootWindow) - ImGuiHoveredFlags_AllowWhenBlockedByPopup = 1 << 5, // Return true even if a popup window is normally blocking access to this item/window - //ImGuiHoveredFlags_AllowWhenBlockedByModal = 1 << 6, // Return true even if a modal popup window is normally blocking access to this item/window. FIXME-TODO: Unavailable yet. - ImGuiHoveredFlags_AllowWhenBlockedByActiveItem = 1 << 7, // Return true even if an active item is blocking access to this item/window. Useful for Drag and Drop patterns. - ImGuiHoveredFlags_AllowWhenOverlapped = 1 << 8, // IsItemHovered() only: Return true even if the position is obstructed or overlapped by another window - ImGuiHoveredFlags_AllowWhenDisabled = 1 << 9, // IsItemHovered() only: Return true even if the item is disabled - ImGuiHoveredFlags_RectOnly = ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem | ImGuiHoveredFlags_AllowWhenOverlapped, - ImGuiHoveredFlags_RootAndChildWindows = ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows -}; - -// Flags for ImGui::BeginDragDropSource(), ImGui::AcceptDragDropPayload() -enum ImGuiDragDropFlags_ -{ - ImGuiDragDropFlags_None = 0, - // BeginDragDropSource() flags - ImGuiDragDropFlags_SourceNoPreviewTooltip = 1 << 0, // By default, a successful call to BeginDragDropSource opens a tooltip so you can display a preview or description of the source contents. This flag disable this behavior. - ImGuiDragDropFlags_SourceNoDisableHover = 1 << 1, // By default, when dragging we clear data so that IsItemHovered() will return false, to avoid subsequent user code submitting tooltips. This flag disable this behavior so you can still call IsItemHovered() on the source item. - ImGuiDragDropFlags_SourceNoHoldToOpenOthers = 1 << 2, // Disable the behavior that allows to open tree nodes and collapsing header by holding over them while dragging a source item. - ImGuiDragDropFlags_SourceAllowNullID = 1 << 3, // Allow items such as Text(), Image() that have no unique identifier to be used as drag source, by manufacturing a temporary identifier based on their window-relative position. This is extremely unusual within the dear imgui ecosystem and so we made it explicit. - ImGuiDragDropFlags_SourceExtern = 1 << 4, // External source (from outside of dear imgui), won't attempt to read current item/window info. Will always return true. Only one Extern source can be active simultaneously. - ImGuiDragDropFlags_SourceAutoExpirePayload = 1 << 5, // Automatically expire the payload if the source cease to be submitted (otherwise payloads are persisting while being dragged) - // AcceptDragDropPayload() flags - ImGuiDragDropFlags_AcceptBeforeDelivery = 1 << 10, // AcceptDragDropPayload() will returns true even before the mouse button is released. You can then call IsDelivery() to test if the payload needs to be delivered. - ImGuiDragDropFlags_AcceptNoDrawDefaultRect = 1 << 11, // Do not draw the default highlight rectangle when hovering over target. - ImGuiDragDropFlags_AcceptNoPreviewTooltip = 1 << 12, // Request hiding the BeginDragDropSource tooltip from the BeginDragDropTarget site. - ImGuiDragDropFlags_AcceptPeekOnly = ImGuiDragDropFlags_AcceptBeforeDelivery | ImGuiDragDropFlags_AcceptNoDrawDefaultRect // For peeking ahead and inspecting the payload before delivery. -}; - -// Standard Drag and Drop payload types. You can define you own payload types using short strings. Types starting with '_' are defined by Dear ImGui. -#define IMGUI_PAYLOAD_TYPE_COLOR_3F "_COL3F" // float[3]: Standard type for colors, without alpha. User code may use this type. -#define IMGUI_PAYLOAD_TYPE_COLOR_4F "_COL4F" // float[4]: Standard type for colors. User code may use this type. - -// A primary data type -enum ImGuiDataType_ -{ - ImGuiDataType_S8, // signed char / char (with sensible compilers) - ImGuiDataType_U8, // unsigned char - ImGuiDataType_S16, // short - ImGuiDataType_U16, // unsigned short - ImGuiDataType_S32, // int - ImGuiDataType_U32, // unsigned int - ImGuiDataType_S64, // long long / __int64 - ImGuiDataType_U64, // unsigned long long / unsigned __int64 - ImGuiDataType_Float, // float - ImGuiDataType_Double, // double - ImGuiDataType_COUNT -}; - -// A cardinal direction -enum ImGuiDir_ -{ - ImGuiDir_None = -1, - ImGuiDir_Left = 0, - ImGuiDir_Right = 1, - ImGuiDir_Up = 2, - ImGuiDir_Down = 3, - ImGuiDir_COUNT -}; - -// A sorting direction -enum ImGuiSortDirection_ -{ - ImGuiSortDirection_None = 0, - ImGuiSortDirection_Ascending = 1, // Ascending = 0->9, A->Z etc. - ImGuiSortDirection_Descending = 2 // Descending = 9->0, Z->A etc. -}; - -// User fill ImGuiIO.KeyMap[] array with indices into the ImGuiIO.KeysDown[512] array -enum ImGuiKey_ -{ - ImGuiKey_Tab, - ImGuiKey_LeftArrow, - ImGuiKey_RightArrow, - ImGuiKey_UpArrow, - ImGuiKey_DownArrow, - ImGuiKey_PageUp, - ImGuiKey_PageDown, - ImGuiKey_Home, - ImGuiKey_End, - ImGuiKey_Insert, - ImGuiKey_Delete, - ImGuiKey_Backspace, - ImGuiKey_Space, - ImGuiKey_Enter, - ImGuiKey_Escape, - ImGuiKey_KeyPadEnter, - ImGuiKey_A, // for text edit CTRL+A: select all - ImGuiKey_C, // for text edit CTRL+C: copy - ImGuiKey_V, // for text edit CTRL+V: paste - ImGuiKey_X, // for text edit CTRL+X: cut - ImGuiKey_Y, // for text edit CTRL+Y: redo - ImGuiKey_Z, // for text edit CTRL+Z: undo - ImGuiKey_COUNT -}; - -// To test io.KeyMods (which is a combination of individual fields io.KeyCtrl, io.KeyShift, io.KeyAlt set by user/backend) -enum ImGuiKeyModFlags_ -{ - ImGuiKeyModFlags_None = 0, - ImGuiKeyModFlags_Ctrl = 1 << 0, - ImGuiKeyModFlags_Shift = 1 << 1, - ImGuiKeyModFlags_Alt = 1 << 2, - ImGuiKeyModFlags_Super = 1 << 3 -}; - -// Gamepad/Keyboard navigation -// Keyboard: Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard to enable. NewFrame() will automatically fill io.NavInputs[] based on your io.KeysDown[] + io.KeyMap[] arrays. -// Gamepad: Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad to enable. Backend: set ImGuiBackendFlags_HasGamepad and fill the io.NavInputs[] fields before calling NewFrame(). Note that io.NavInputs[] is cleared by EndFrame(). -// Read instructions in imgui.cpp for more details. Download PNG/PSD at http://dearimgui.org/controls_sheets. -enum ImGuiNavInput_ -{ - // Gamepad Mapping - ImGuiNavInput_Activate, // activate / open / toggle / tweak value // e.g. Cross (PS4), A (Xbox), A (Switch), Space (Keyboard) - ImGuiNavInput_Cancel, // cancel / close / exit // e.g. Circle (PS4), B (Xbox), B (Switch), Escape (Keyboard) - ImGuiNavInput_Input, // text input / on-screen keyboard // e.g. Triang.(PS4), Y (Xbox), X (Switch), Return (Keyboard) - ImGuiNavInput_Menu, // tap: toggle menu / hold: focus, move, resize // e.g. Square (PS4), X (Xbox), Y (Switch), Alt (Keyboard) - ImGuiNavInput_DpadLeft, // move / tweak / resize window (w/ PadMenu) // e.g. D-pad Left/Right/Up/Down (Gamepads), Arrow keys (Keyboard) - ImGuiNavInput_DpadRight, // - ImGuiNavInput_DpadUp, // - ImGuiNavInput_DpadDown, // - ImGuiNavInput_LStickLeft, // scroll / move window (w/ PadMenu) // e.g. Left Analog Stick Left/Right/Up/Down - ImGuiNavInput_LStickRight, // - ImGuiNavInput_LStickUp, // - ImGuiNavInput_LStickDown, // - ImGuiNavInput_FocusPrev, // next window (w/ PadMenu) // e.g. L1 or L2 (PS4), LB or LT (Xbox), L or ZL (Switch) - ImGuiNavInput_FocusNext, // prev window (w/ PadMenu) // e.g. R1 or R2 (PS4), RB or RT (Xbox), R or ZL (Switch) - ImGuiNavInput_TweakSlow, // slower tweaks // e.g. L1 or L2 (PS4), LB or LT (Xbox), L or ZL (Switch) - ImGuiNavInput_TweakFast, // faster tweaks // e.g. R1 or R2 (PS4), RB or RT (Xbox), R or ZL (Switch) - - // [Internal] Don't use directly! This is used internally to differentiate keyboard from gamepad inputs for behaviors that require to differentiate them. - // Keyboard behavior that have no corresponding gamepad mapping (e.g. CTRL+TAB) will be directly reading from io.KeysDown[] instead of io.NavInputs[]. - ImGuiNavInput_KeyLeft_, // move left // = Arrow keys - ImGuiNavInput_KeyRight_, // move right - ImGuiNavInput_KeyUp_, // move up - ImGuiNavInput_KeyDown_, // move down - ImGuiNavInput_COUNT, - ImGuiNavInput_InternalStart_ = ImGuiNavInput_KeyLeft_ -}; - -// Configuration flags stored in io.ConfigFlags. Set by user/application. -enum ImGuiConfigFlags_ -{ - ImGuiConfigFlags_None = 0, - ImGuiConfigFlags_NavEnableKeyboard = 1 << 0, // Master keyboard navigation enable flag. NewFrame() will automatically fill io.NavInputs[] based on io.KeysDown[]. - ImGuiConfigFlags_NavEnableGamepad = 1 << 1, // Master gamepad navigation enable flag. This is mostly to instruct your imgui backend to fill io.NavInputs[]. Backend also needs to set ImGuiBackendFlags_HasGamepad. - ImGuiConfigFlags_NavEnableSetMousePos = 1 << 2, // Instruct navigation to move the mouse cursor. May be useful on TV/console systems where moving a virtual mouse is awkward. Will update io.MousePos and set io.WantSetMousePos=true. If enabled you MUST honor io.WantSetMousePos requests in your backend, otherwise ImGui will react as if the mouse is jumping around back and forth. - ImGuiConfigFlags_NavNoCaptureKeyboard = 1 << 3, // Instruct navigation to not set the io.WantCaptureKeyboard flag when io.NavActive is set. - ImGuiConfigFlags_NoMouse = 1 << 4, // Instruct imgui to clear mouse position/buttons in NewFrame(). This allows ignoring the mouse information set by the backend. - ImGuiConfigFlags_NoMouseCursorChange = 1 << 5, // Instruct backend to not alter mouse cursor shape and visibility. Use if the backend cursor changes are interfering with yours and you don't want to use SetMouseCursor() to change mouse cursor. You may want to honor requests from imgui by reading GetMouseCursor() yourself instead. - - // User storage (to allow your backend/engine to communicate to code that may be shared between multiple projects. Those flags are not used by core Dear ImGui) - ImGuiConfigFlags_IsSRGB = 1 << 20, // Application is SRGB-aware. - ImGuiConfigFlags_IsTouchScreen = 1 << 21 // Application is using a touch screen instead of a mouse. -}; - -// Backend capabilities flags stored in io.BackendFlags. Set by imgui_impl_xxx or custom backend. -enum ImGuiBackendFlags_ -{ - ImGuiBackendFlags_None = 0, - ImGuiBackendFlags_HasGamepad = 1 << 0, // Backend Platform supports gamepad and currently has one connected. - ImGuiBackendFlags_HasMouseCursors = 1 << 1, // Backend Platform supports honoring GetMouseCursor() value to change the OS cursor shape. - ImGuiBackendFlags_HasSetMousePos = 1 << 2, // Backend Platform supports io.WantSetMousePos requests to reposition the OS mouse position (only used if ImGuiConfigFlags_NavEnableSetMousePos is set). - ImGuiBackendFlags_RendererHasVtxOffset = 1 << 3 // Backend Renderer supports ImDrawCmd::VtxOffset. This enables output of large meshes (64K+ vertices) while still using 16-bit indices. -}; - -// Enumeration for PushStyleColor() / PopStyleColor() -enum ImGuiCol_ -{ - ImGuiCol_Text, - ImGuiCol_TextDisabled, - ImGuiCol_WindowBg, // Background of normal windows - ImGuiCol_ChildBg, // Background of child windows - ImGuiCol_PopupBg, // Background of popups, menus, tooltips windows - ImGuiCol_Border, - ImGuiCol_BorderShadow, - ImGuiCol_FrameBg, // Background of checkbox, radio button, plot, slider, text input - ImGuiCol_FrameBgHovered, - ImGuiCol_FrameBgActive, - ImGuiCol_TitleBg, - ImGuiCol_TitleBgActive, - ImGuiCol_TitleBgCollapsed, - ImGuiCol_MenuBarBg, - ImGuiCol_ScrollbarBg, - ImGuiCol_ScrollbarGrab, - ImGuiCol_ScrollbarGrabHovered, - ImGuiCol_ScrollbarGrabActive, - ImGuiCol_CheckMark, - ImGuiCol_SliderGrab, - ImGuiCol_SliderGrabActive, - ImGuiCol_Button, - ImGuiCol_ButtonHovered, - ImGuiCol_ButtonActive, - ImGuiCol_Header, // Header* colors are used for CollapsingHeader, TreeNode, Selectable, MenuItem - ImGuiCol_HeaderHovered, - ImGuiCol_HeaderActive, - ImGuiCol_Separator, - ImGuiCol_SeparatorHovered, - ImGuiCol_SeparatorActive, - ImGuiCol_ResizeGrip, - ImGuiCol_ResizeGripHovered, - ImGuiCol_ResizeGripActive, - ImGuiCol_Tab, - ImGuiCol_TabHovered, - ImGuiCol_TabActive, - ImGuiCol_TabUnfocused, - ImGuiCol_TabUnfocusedActive, - ImGuiCol_PlotLines, - ImGuiCol_PlotLinesHovered, - ImGuiCol_PlotHistogram, - ImGuiCol_PlotHistogramHovered, - ImGuiCol_TableHeaderBg, // Table header background - ImGuiCol_TableBorderStrong, // Table outer and header borders (prefer using Alpha=1.0 here) - ImGuiCol_TableBorderLight, // Table inner borders (prefer using Alpha=1.0 here) - ImGuiCol_TableRowBg, // Table row background (even rows) - ImGuiCol_TableRowBgAlt, // Table row background (odd rows) - ImGuiCol_TextSelectedBg, - ImGuiCol_DragDropTarget, - ImGuiCol_NavHighlight, // Gamepad/keyboard: current highlighted item - ImGuiCol_NavWindowingHighlight, // Highlight window when using CTRL+TAB - ImGuiCol_NavWindowingDimBg, // Darken/colorize entire screen behind the CTRL+TAB window list, when active - ImGuiCol_ModalWindowDimBg, // Darken/colorize entire screen behind a modal window, when one is active - ImGuiCol_COUNT -}; - -// Enumeration for PushStyleVar() / PopStyleVar() to temporarily modify the ImGuiStyle structure. -// - The enum only refers to fields of ImGuiStyle which makes sense to be pushed/popped inside UI code. -// During initialization or between frames, feel free to just poke into ImGuiStyle directly. -// - Tip: Use your programming IDE navigation facilities on the names in the _second column_ below to find the actual members and their description. -// In Visual Studio IDE: CTRL+comma ("Edit.NavigateTo") can follow symbols in comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot. -// With Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols in comments. -// - When changing this enum, you need to update the associated internal table GStyleVarInfo[] accordingly. This is where we link enum values to members offset/type. -enum ImGuiStyleVar_ -{ - // Enum name --------------------- // Member in ImGuiStyle structure (see ImGuiStyle for descriptions) - ImGuiStyleVar_Alpha, // float Alpha - ImGuiStyleVar_DisabledAlpha, // float DisabledAlpha - ImGuiStyleVar_WindowPadding, // ImVec2 WindowPadding - ImGuiStyleVar_WindowRounding, // float WindowRounding - ImGuiStyleVar_WindowBorderSize, // float WindowBorderSize - ImGuiStyleVar_WindowMinSize, // ImVec2 WindowMinSize - ImGuiStyleVar_WindowTitleAlign, // ImVec2 WindowTitleAlign - ImGuiStyleVar_ChildRounding, // float ChildRounding - ImGuiStyleVar_ChildBorderSize, // float ChildBorderSize - ImGuiStyleVar_PopupRounding, // float PopupRounding - ImGuiStyleVar_PopupBorderSize, // float PopupBorderSize - ImGuiStyleVar_FramePadding, // ImVec2 FramePadding - ImGuiStyleVar_FrameRounding, // float FrameRounding - ImGuiStyleVar_FrameBorderSize, // float FrameBorderSize - ImGuiStyleVar_ItemSpacing, // ImVec2 ItemSpacing - ImGuiStyleVar_ItemInnerSpacing, // ImVec2 ItemInnerSpacing - ImGuiStyleVar_IndentSpacing, // float IndentSpacing - ImGuiStyleVar_CellPadding, // ImVec2 CellPadding - ImGuiStyleVar_ScrollbarSize, // float ScrollbarSize - ImGuiStyleVar_ScrollbarRounding, // float ScrollbarRounding - ImGuiStyleVar_GrabMinSize, // float GrabMinSize - ImGuiStyleVar_GrabRounding, // float GrabRounding - ImGuiStyleVar_TabRounding, // float TabRounding - ImGuiStyleVar_ButtonTextAlign, // ImVec2 ButtonTextAlign - ImGuiStyleVar_SelectableTextAlign, // ImVec2 SelectableTextAlign - ImGuiStyleVar_COUNT -}; - -// Flags for InvisibleButton() [extended in imgui_internal.h] -enum ImGuiButtonFlags_ -{ - ImGuiButtonFlags_None = 0, - ImGuiButtonFlags_MouseButtonLeft = 1 << 0, // React on left mouse button (default) - ImGuiButtonFlags_MouseButtonRight = 1 << 1, // React on right mouse button - ImGuiButtonFlags_MouseButtonMiddle = 1 << 2, // React on center mouse button - - // [Internal] - ImGuiButtonFlags_MouseButtonMask_ = ImGuiButtonFlags_MouseButtonLeft | ImGuiButtonFlags_MouseButtonRight | ImGuiButtonFlags_MouseButtonMiddle, - ImGuiButtonFlags_MouseButtonDefault_ = ImGuiButtonFlags_MouseButtonLeft -}; - -// Flags for ColorEdit3() / ColorEdit4() / ColorPicker3() / ColorPicker4() / ColorButton() -enum ImGuiColorEditFlags_ -{ - ImGuiColorEditFlags_None = 0, - ImGuiColorEditFlags_NoAlpha = 1 << 1, // // ColorEdit, ColorPicker, ColorButton: ignore Alpha component (will only read 3 components from the input pointer). - ImGuiColorEditFlags_NoPicker = 1 << 2, // // ColorEdit: disable picker when clicking on color square. - ImGuiColorEditFlags_NoOptions = 1 << 3, // // ColorEdit: disable toggling options menu when right-clicking on inputs/small preview. - ImGuiColorEditFlags_NoSmallPreview = 1 << 4, // // ColorEdit, ColorPicker: disable color square preview next to the inputs. (e.g. to show only the inputs) - ImGuiColorEditFlags_NoInputs = 1 << 5, // // ColorEdit, ColorPicker: disable inputs sliders/text widgets (e.g. to show only the small preview color square). - ImGuiColorEditFlags_NoTooltip = 1 << 6, // // ColorEdit, ColorPicker, ColorButton: disable tooltip when hovering the preview. - ImGuiColorEditFlags_NoLabel = 1 << 7, // // ColorEdit, ColorPicker: disable display of inline text label (the label is still forwarded to the tooltip and picker). - ImGuiColorEditFlags_NoSidePreview = 1 << 8, // // ColorPicker: disable bigger color preview on right side of the picker, use small color square preview instead. - ImGuiColorEditFlags_NoDragDrop = 1 << 9, // // ColorEdit: disable drag and drop target. ColorButton: disable drag and drop source. - ImGuiColorEditFlags_NoBorder = 1 << 10, // // ColorButton: disable border (which is enforced by default) - - // User Options (right-click on widget to change some of them). - ImGuiColorEditFlags_AlphaBar = 1 << 16, // // ColorEdit, ColorPicker: show vertical alpha bar/gradient in picker. - ImGuiColorEditFlags_AlphaPreview = 1 << 17, // // ColorEdit, ColorPicker, ColorButton: display preview as a transparent color over a checkerboard, instead of opaque. - ImGuiColorEditFlags_AlphaPreviewHalf= 1 << 18, // // ColorEdit, ColorPicker, ColorButton: display half opaque / half checkerboard, instead of opaque. - ImGuiColorEditFlags_HDR = 1 << 19, // // (WIP) ColorEdit: Currently only disable 0.0f..1.0f limits in RGBA edition (note: you probably want to use ImGuiColorEditFlags_Float flag as well). - ImGuiColorEditFlags_DisplayRGB = 1 << 20, // [Display] // ColorEdit: override _display_ type among RGB/HSV/Hex. ColorPicker: select any combination using one or more of RGB/HSV/Hex. - ImGuiColorEditFlags_DisplayHSV = 1 << 21, // [Display] // " - ImGuiColorEditFlags_DisplayHex = 1 << 22, // [Display] // " - ImGuiColorEditFlags_Uint8 = 1 << 23, // [DataType] // ColorEdit, ColorPicker, ColorButton: _display_ values formatted as 0..255. - ImGuiColorEditFlags_Float = 1 << 24, // [DataType] // ColorEdit, ColorPicker, ColorButton: _display_ values formatted as 0.0f..1.0f floats instead of 0..255 integers. No round-trip of value via integers. - ImGuiColorEditFlags_PickerHueBar = 1 << 25, // [Picker] // ColorPicker: bar for Hue, rectangle for Sat/Value. - ImGuiColorEditFlags_PickerHueWheel = 1 << 26, // [Picker] // ColorPicker: wheel for Hue, triangle for Sat/Value. - ImGuiColorEditFlags_InputRGB = 1 << 27, // [Input] // ColorEdit, ColorPicker: input and output data in RGB format. - ImGuiColorEditFlags_InputHSV = 1 << 28, // [Input] // ColorEdit, ColorPicker: input and output data in HSV format. - - // Defaults Options. You can set application defaults using SetColorEditOptions(). The intent is that you probably don't want to - // override them in most of your calls. Let the user choose via the option menu and/or call SetColorEditOptions() once during startup. - ImGuiColorEditFlags_DefaultOptions_ = ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_InputRGB | ImGuiColorEditFlags_PickerHueBar, - - // [Internal] Masks - ImGuiColorEditFlags_DisplayMask_ = ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_DisplayHSV | ImGuiColorEditFlags_DisplayHex, - ImGuiColorEditFlags_DataTypeMask_ = ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_Float, - ImGuiColorEditFlags_PickerMask_ = ImGuiColorEditFlags_PickerHueWheel | ImGuiColorEditFlags_PickerHueBar, - ImGuiColorEditFlags_InputMask_ = ImGuiColorEditFlags_InputRGB | ImGuiColorEditFlags_InputHSV - - // Obsolete names (will be removed) -#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS - , ImGuiColorEditFlags_RGB = ImGuiColorEditFlags_DisplayRGB, ImGuiColorEditFlags_HSV = ImGuiColorEditFlags_DisplayHSV, ImGuiColorEditFlags_HEX = ImGuiColorEditFlags_DisplayHex // [renamed in 1.69] -#endif -}; - -// Flags for DragFloat(), DragInt(), SliderFloat(), SliderInt() etc. -// We use the same sets of flags for DragXXX() and SliderXXX() functions as the features are the same and it makes it easier to swap them. -enum ImGuiSliderFlags_ -{ - ImGuiSliderFlags_None = 0, - ImGuiSliderFlags_AlwaysClamp = 1 << 4, // Clamp value to min/max bounds when input manually with CTRL+Click. By default CTRL+Click allows going out of bounds. - ImGuiSliderFlags_Logarithmic = 1 << 5, // Make the widget logarithmic (linear otherwise). Consider using ImGuiSliderFlags_NoRoundToFormat with this if using a format-string with small amount of digits. - ImGuiSliderFlags_NoRoundToFormat = 1 << 6, // Disable rounding underlying value to match precision of the display format string (e.g. %.3f values are rounded to those 3 digits) - ImGuiSliderFlags_NoInput = 1 << 7, // Disable CTRL+Click or Enter key allowing to input text directly into the widget - ImGuiSliderFlags_InvalidMask_ = 0x7000000F // [Internal] We treat using those bits as being potentially a 'float power' argument from the previous API that has got miscast to this enum, and will trigger an assert if needed. - - // Obsolete names (will be removed) -#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS - , ImGuiSliderFlags_ClampOnInput = ImGuiSliderFlags_AlwaysClamp // [renamed in 1.79] -#endif -}; - -// Identify a mouse button. -// Those values are guaranteed to be stable and we frequently use 0/1 directly. Named enums provided for convenience. -enum ImGuiMouseButton_ -{ - ImGuiMouseButton_Left = 0, - ImGuiMouseButton_Right = 1, - ImGuiMouseButton_Middle = 2, - ImGuiMouseButton_COUNT = 5 -}; - -// Enumeration for GetMouseCursor() -// User code may request backend to display given cursor by calling SetMouseCursor(), which is why we have some cursors that are marked unused here -enum ImGuiMouseCursor_ -{ - ImGuiMouseCursor_None = -1, - ImGuiMouseCursor_Arrow = 0, - ImGuiMouseCursor_TextInput, // When hovering over InputText, etc. - ImGuiMouseCursor_ResizeAll, // (Unused by Dear ImGui functions) - ImGuiMouseCursor_ResizeNS, // When hovering over an horizontal border - ImGuiMouseCursor_ResizeEW, // When hovering over a vertical border or a column - ImGuiMouseCursor_ResizeNESW, // When hovering over the bottom-left corner of a window - ImGuiMouseCursor_ResizeNWSE, // When hovering over the bottom-right corner of a window - ImGuiMouseCursor_Hand, // (Unused by Dear ImGui functions. Use for e.g. hyperlinks) - ImGuiMouseCursor_NotAllowed, // When hovering something with disallowed interaction. Usually a crossed circle. - ImGuiMouseCursor_COUNT -}; - -// Enumeration for ImGui::SetWindow***(), SetNextWindow***(), SetNextItem***() functions -// Represent a condition. -// Important: Treat as a regular enum! Do NOT combine multiple values using binary operators! All the functions above treat 0 as a shortcut to ImGuiCond_Always. -enum ImGuiCond_ -{ - ImGuiCond_None = 0, // No condition (always set the variable), same as _Always - ImGuiCond_Always = 1 << 0, // No condition (always set the variable) - ImGuiCond_Once = 1 << 1, // Set the variable once per runtime session (only the first call will succeed) - ImGuiCond_FirstUseEver = 1 << 2, // Set the variable if the object/window has no persistently saved data (no entry in .ini file) - ImGuiCond_Appearing = 1 << 3 // Set the variable if the object/window is appearing after being hidden/inactive (or the first time) -}; - -//----------------------------------------------------------------------------- -// [SECTION] Helpers: Memory allocations macros, ImVector<> -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// IM_MALLOC(), IM_FREE(), IM_NEW(), IM_PLACEMENT_NEW(), IM_DELETE() -// We call C++ constructor on own allocated memory via the placement "new(ptr) Type()" syntax. -// Defining a custom placement new() with a custom parameter allows us to bypass including which on some platforms complains when user has disabled exceptions. -//----------------------------------------------------------------------------- - -struct ImNewWrapper {}; -inline void* operator new(size_t, ImNewWrapper, void* ptr) { return ptr; } -inline void operator delete(void*, ImNewWrapper, void*) {} // This is only required so we can use the symmetrical new() -#define IM_ALLOC(_SIZE) ImGui::MemAlloc(_SIZE) -#define IM_FREE(_PTR) ImGui::MemFree(_PTR) -#define IM_PLACEMENT_NEW(_PTR) new(ImNewWrapper(), _PTR) -#define IM_NEW(_TYPE) new(ImNewWrapper(), ImGui::MemAlloc(sizeof(_TYPE))) _TYPE -template void IM_DELETE(T* p) { if (p) { p->~T(); ImGui::MemFree(p); } } - -//----------------------------------------------------------------------------- -// ImVector<> -// Lightweight std::vector<>-like class to avoid dragging dependencies (also, some implementations of STL with debug enabled are absurdly slow, we bypass it so our code runs fast in debug). -//----------------------------------------------------------------------------- -// - You generally do NOT need to care or use this ever. But we need to make it available in imgui.h because some of our public structures are relying on it. -// - We use std-like naming convention here, which is a little unusual for this codebase. -// - Important: clear() frees memory, resize(0) keep the allocated buffer. We use resize(0) a lot to intentionally recycle allocated buffers across frames and amortize our costs. -// - Important: our implementation does NOT call C++ constructors/destructors, we treat everything as raw data! This is intentional but be extra mindful of that, -// Do NOT use this class as a std::vector replacement in your own code! Many of the structures used by dear imgui can be safely initialized by a zero-memset. -//----------------------------------------------------------------------------- - -IM_MSVC_RUNTIME_CHECKS_OFF -template -struct ImVector -{ - int Size; - int Capacity; - T* Data; - - // Provide standard typedefs but we don't use them ourselves. - typedef T value_type; - typedef value_type* iterator; - typedef const value_type* const_iterator; - - // Constructors, destructor - inline ImVector() { Size = Capacity = 0; Data = NULL; } - inline ImVector(const ImVector& src) { Size = Capacity = 0; Data = NULL; operator=(src); } - inline ImVector& operator=(const ImVector& src) { clear(); resize(src.Size); memcpy(Data, src.Data, (size_t)Size * sizeof(T)); return *this; } - inline ~ImVector() { if (Data) IM_FREE(Data); } // Important: does not destruct anything - - inline void clear() { if (Data) { Size = Capacity = 0; IM_FREE(Data); Data = NULL; } } // Important: does not destruct anything - inline void clear_delete() { for (int n = 0; n < Size; n++) IM_DELETE(Data[n]); clear(); } // Important: never called automatically! always explicit. - inline void clear_destruct() { for (int n = 0; n < Size; n++) Data[n].~T(); clear(); } // Important: never called automatically! always explicit. - - inline bool empty() const { return Size == 0; } - inline int size() const { return Size; } - inline int size_in_bytes() const { return Size * (int)sizeof(T); } - inline int max_size() const { return 0x7FFFFFFF / (int)sizeof(T); } - inline int capacity() const { return Capacity; } - inline T& operator[](int i) { IM_ASSERT(i >= 0 && i < Size); return Data[i]; } - inline const T& operator[](int i) const { IM_ASSERT(i >= 0 && i < Size); return Data[i]; } - - inline T* begin() { return Data; } - inline const T* begin() const { return Data; } - inline T* end() { return Data + Size; } - inline const T* end() const { return Data + Size; } - inline T& front() { IM_ASSERT(Size > 0); return Data[0]; } - inline const T& front() const { IM_ASSERT(Size > 0); return Data[0]; } - inline T& back() { IM_ASSERT(Size > 0); return Data[Size - 1]; } - inline const T& back() const { IM_ASSERT(Size > 0); return Data[Size - 1]; } - inline void swap(ImVector& rhs) { int rhs_size = rhs.Size; rhs.Size = Size; Size = rhs_size; int rhs_cap = rhs.Capacity; rhs.Capacity = Capacity; Capacity = rhs_cap; T* rhs_data = rhs.Data; rhs.Data = Data; Data = rhs_data; } - - inline int _grow_capacity(int sz) const { int new_capacity = Capacity ? (Capacity + Capacity / 2) : 8; return new_capacity > sz ? new_capacity : sz; } - inline void resize(int new_size) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); Size = new_size; } - inline void resize(int new_size, const T& v) { if (new_size > Capacity) reserve(_grow_capacity(new_size)); if (new_size > Size) for (int n = Size; n < new_size; n++) memcpy(&Data[n], &v, sizeof(v)); Size = new_size; } - inline void shrink(int new_size) { IM_ASSERT(new_size <= Size); Size = new_size; } // Resize a vector to a smaller size, guaranteed not to cause a reallocation - inline void reserve(int new_capacity) { if (new_capacity <= Capacity) return; T* new_data = (T*)IM_ALLOC((size_t)new_capacity * sizeof(T)); if (Data) { memcpy(new_data, Data, (size_t)Size * sizeof(T)); IM_FREE(Data); } Data = new_data; Capacity = new_capacity; } - - // NB: It is illegal to call push_back/push_front/insert with a reference pointing inside the ImVector data itself! e.g. v.push_back(v[10]) is forbidden. - inline void push_back(const T& v) { if (Size == Capacity) reserve(_grow_capacity(Size + 1)); memcpy(&Data[Size], &v, sizeof(v)); Size++; } - inline void pop_back() { IM_ASSERT(Size > 0); Size--; } - inline void push_front(const T& v) { if (Size == 0) push_back(v); else insert(Data, v); } - inline T* erase(const T* it) { IM_ASSERT(it >= Data && it < Data + Size); const ptrdiff_t off = it - Data; memmove(Data + off, Data + off + 1, ((size_t)Size - (size_t)off - 1) * sizeof(T)); Size--; return Data + off; } - inline T* erase(const T* it, const T* it_last){ IM_ASSERT(it >= Data && it < Data + Size && it_last > it && it_last <= Data + Size); const ptrdiff_t count = it_last - it; const ptrdiff_t off = it - Data; memmove(Data + off, Data + off + count, ((size_t)Size - (size_t)off - count) * sizeof(T)); Size -= (int)count; return Data + off; } - inline T* erase_unsorted(const T* it) { IM_ASSERT(it >= Data && it < Data + Size); const ptrdiff_t off = it - Data; if (it < Data + Size - 1) memcpy(Data + off, Data + Size - 1, sizeof(T)); Size--; return Data + off; } - inline T* insert(const T* it, const T& v) { IM_ASSERT(it >= Data && it <= Data + Size); const ptrdiff_t off = it - Data; if (Size == Capacity) reserve(_grow_capacity(Size + 1)); if (off < (int)Size) memmove(Data + off + 1, Data + off, ((size_t)Size - (size_t)off) * sizeof(T)); memcpy(&Data[off], &v, sizeof(v)); Size++; return Data + off; } - inline bool contains(const T& v) const { const T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data++ == v) return true; return false; } - inline T* find(const T& v) { T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data == v) break; else ++data; return data; } - inline const T* find(const T& v) const { const T* data = Data; const T* data_end = Data + Size; while (data < data_end) if (*data == v) break; else ++data; return data; } - inline bool find_erase(const T& v) { const T* it = find(v); if (it < Data + Size) { erase(it); return true; } return false; } - inline bool find_erase_unsorted(const T& v) { const T* it = find(v); if (it < Data + Size) { erase_unsorted(it); return true; } return false; } - inline int index_from_ptr(const T* it) const { IM_ASSERT(it >= Data && it < Data + Size); const ptrdiff_t off = it - Data; return (int)off; } -}; -IM_MSVC_RUNTIME_CHECKS_RESTORE - -//----------------------------------------------------------------------------- -// [SECTION] ImGuiStyle -//----------------------------------------------------------------------------- -// You may modify the ImGui::GetStyle() main instance during initialization and before NewFrame(). -// During the frame, use ImGui::PushStyleVar(ImGuiStyleVar_XXXX)/PopStyleVar() to alter the main style values, -// and ImGui::PushStyleColor(ImGuiCol_XXX)/PopStyleColor() for colors. -//----------------------------------------------------------------------------- - -struct ImGuiStyle -{ - float Alpha; // Global alpha applies to everything in Dear ImGui. - float DisabledAlpha; // Additional alpha multiplier applied by BeginDisabled(). Multiply over current value of Alpha. - ImVec2 WindowPadding; // Padding within a window. - float WindowRounding; // Radius of window corners rounding. Set to 0.0f to have rectangular windows. Large values tend to lead to variety of artifacts and are not recommended. - float WindowBorderSize; // Thickness of border around windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly). - ImVec2 WindowMinSize; // Minimum window size. This is a global setting. If you want to constraint individual windows, use SetNextWindowSizeConstraints(). - ImVec2 WindowTitleAlign; // Alignment for title bar text. Defaults to (0.0f,0.5f) for left-aligned,vertically centered. - ImGuiDir WindowMenuButtonPosition; // Side of the collapsing/docking button in the title bar (None/Left/Right). Defaults to ImGuiDir_Left. - float ChildRounding; // Radius of child window corners rounding. Set to 0.0f to have rectangular windows. - float ChildBorderSize; // Thickness of border around child windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly). - float PopupRounding; // Radius of popup window corners rounding. (Note that tooltip windows use WindowRounding) - float PopupBorderSize; // Thickness of border around popup/tooltip windows. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly). - ImVec2 FramePadding; // Padding within a framed rectangle (used by most widgets). - float FrameRounding; // Radius of frame corners rounding. Set to 0.0f to have rectangular frame (used by most widgets). - float FrameBorderSize; // Thickness of border around frames. Generally set to 0.0f or 1.0f. (Other values are not well tested and more CPU/GPU costly). - ImVec2 ItemSpacing; // Horizontal and vertical spacing between widgets/lines. - ImVec2 ItemInnerSpacing; // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label). - ImVec2 CellPadding; // Padding within a table cell - ImVec2 TouchExtraPadding; // Expand reactive bounding box for touch-based system where touch position is not accurate enough. Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much! - float IndentSpacing; // Horizontal indentation when e.g. entering a tree node. Generally == (FontSize + FramePadding.x*2). - float ColumnsMinSpacing; // Minimum horizontal spacing between two columns. Preferably > (FramePadding.x + 1). - float ScrollbarSize; // Width of the vertical scrollbar, Height of the horizontal scrollbar. - float ScrollbarRounding; // Radius of grab corners for scrollbar. - float GrabMinSize; // Minimum width/height of a grab box for slider/scrollbar. - float GrabRounding; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs. - float LogSliderDeadzone; // The size in pixels of the dead-zone around zero on logarithmic sliders that cross zero. - float TabRounding; // Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs. - float TabBorderSize; // Thickness of border around tabs. - float TabMinWidthForCloseButton; // Minimum width for close button to appears on an unselected tab when hovered. Set to 0.0f to always show when hovering, set to FLT_MAX to never show close button unless selected. - ImGuiDir ColorButtonPosition; // Side of the color button in the ColorEdit4 widget (left/right). Defaults to ImGuiDir_Right. - ImVec2 ButtonTextAlign; // Alignment of button text when button is larger than text. Defaults to (0.5f, 0.5f) (centered). - ImVec2 SelectableTextAlign; // Alignment of selectable text. Defaults to (0.0f, 0.0f) (top-left aligned). It's generally important to keep this left-aligned if you want to lay multiple items on a same line. - ImVec2 DisplayWindowPadding; // Window position are clamped to be visible within the display area or monitors by at least this amount. Only applies to regular windows. - ImVec2 DisplaySafeAreaPadding; // If you cannot see the edges of your screen (e.g. on a TV) increase the safe area padding. Apply to popups/tooltips as well regular windows. NB: Prefer configuring your TV sets correctly! - float MouseCursorScale; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). May be removed later. - bool AntiAliasedLines; // Enable anti-aliased lines/borders. Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame (copied to ImDrawList). - bool AntiAliasedLinesUseTex; // Enable anti-aliased lines/borders using textures where possible. Require backend to render with bilinear filtering. Latched at the beginning of the frame (copied to ImDrawList). - bool AntiAliasedFill; // Enable anti-aliased edges around filled shapes (rounded rectangles, circles, etc.). Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame (copied to ImDrawList). - float CurveTessellationTol; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality. - float CircleTessellationMaxError; // Maximum error (in pixels) allowed when using AddCircle()/AddCircleFilled() or drawing rounded corner rectangles with no explicit segment count specified. Decrease for higher quality but more geometry. - ImVec4 Colors[ImGuiCol_COUNT]; - - IMGUI_API ImGuiStyle(); - IMGUI_API void ScaleAllSizes(float scale_factor); -}; - -//----------------------------------------------------------------------------- -// [SECTION] ImGuiIO -//----------------------------------------------------------------------------- -// Communicate most settings and inputs/outputs to Dear ImGui using this structure. -// Access via ImGui::GetIO(). Read 'Programmer guide' section in .cpp file for general usage. -//----------------------------------------------------------------------------- - -struct ImGuiIO -{ - //------------------------------------------------------------------ - // Configuration (fill once) // Default value - //------------------------------------------------------------------ - - ImGuiConfigFlags ConfigFlags; // = 0 // See ImGuiConfigFlags_ enum. Set by user/application. Gamepad/keyboard navigation options, etc. - ImGuiBackendFlags BackendFlags; // = 0 // See ImGuiBackendFlags_ enum. Set by backend (imgui_impl_xxx files or custom backend) to communicate features supported by the backend. - ImVec2 DisplaySize; // // Main display size, in pixels (generally == GetMainViewport()->Size) - float DeltaTime; // = 1.0f/60.0f // Time elapsed since last frame, in seconds. - float IniSavingRate; // = 5.0f // Minimum time between saving positions/sizes to .ini file, in seconds. - const char* IniFilename; // = "imgui.ini" // Path to .ini file (important: default "imgui.ini" is relative to current working dir!). Set NULL to disable automatic .ini loading/saving or if you want to manually call LoadIniSettingsXXX() / SaveIniSettingsXXX() functions. - const char* LogFilename; // = "imgui_log.txt"// Path to .log file (default parameter to ImGui::LogToFile when no file is specified). - float MouseDoubleClickTime; // = 0.30f // Time for a double-click, in seconds. - float MouseDoubleClickMaxDist; // = 6.0f // Distance threshold to stay in to validate a double-click, in pixels. - float MouseDragThreshold; // = 6.0f // Distance threshold before considering we are dragging. - int KeyMap[ImGuiKey_COUNT]; // // Map of indices into the KeysDown[512] entries array which represent your "native" keyboard state. - float KeyRepeatDelay; // = 0.250f // When holding a key/button, time before it starts repeating, in seconds (for buttons in Repeat mode, etc.). - float KeyRepeatRate; // = 0.050f // When holding a key/button, rate at which it repeats, in seconds. - void* UserData; // = NULL // Store your own data for retrieval by callbacks. - - ImFontAtlas*Fonts; // // Font atlas: load, rasterize and pack one or more fonts into a single texture. - float FontGlobalScale; // = 1.0f // Global scale all fonts - bool FontAllowUserScaling; // = false // Allow user scaling text of individual window with CTRL+Wheel. - ImFont* FontDefault; // = NULL // Font to use on NewFrame(). Use NULL to uses Fonts->Fonts[0]. - ImVec2 DisplayFramebufferScale; // = (1, 1) // For retina display or other situations where window coordinates are different from framebuffer coordinates. This generally ends up in ImDrawData::FramebufferScale. - - // Miscellaneous options - bool MouseDrawCursor; // = false // Request ImGui to draw a mouse cursor for you (if you are on a platform without a mouse cursor). Cannot be easily renamed to 'io.ConfigXXX' because this is frequently used by backend implementations. - bool ConfigMacOSXBehaviors; // = defined(__APPLE__) // OS X style: Text editing cursor movement using Alt instead of Ctrl, Shortcuts using Cmd/Super instead of Ctrl, Line/Text Start and End using Cmd+Arrows instead of Home/End, Double click selects by word instead of selecting whole text, Multi-selection in lists uses Cmd/Super instead of Ctrl. - bool ConfigInputTextCursorBlink; // = true // Enable blinking cursor (optional as some users consider it to be distracting). - bool ConfigDragClickToInputText; // = false // [BETA] Enable turning DragXXX widgets into text input with a simple mouse click-release (without moving). Not desirable on devices without a keyboard. - bool ConfigWindowsResizeFromEdges; // = true // Enable resizing of windows from their edges and from the lower-left corner. This requires (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) because it needs mouse cursor feedback. (This used to be a per-window ImGuiWindowFlags_ResizeFromAnySide flag) - bool ConfigWindowsMoveFromTitleBarOnly; // = false // Enable allowing to move windows only when clicking on their title bar. Does not apply to windows without a title bar. - float ConfigMemoryCompactTimer; // = 60.0f // Timer (in seconds) to free transient windows/tables memory buffers when unused. Set to -1.0f to disable. - - //------------------------------------------------------------------ - // Platform Functions - // (the imgui_impl_xxxx backend files are setting those up for you) - //------------------------------------------------------------------ - - // Optional: Platform/Renderer backend name (informational only! will be displayed in About Window) + User data for backend/wrappers to store their own stuff. - const char* BackendPlatformName; // = NULL - const char* BackendRendererName; // = NULL - void* BackendPlatformUserData; // = NULL // User data for platform backend - void* BackendRendererUserData; // = NULL // User data for renderer backend - void* BackendLanguageUserData; // = NULL // User data for non C++ programming language backend - - // Optional: Access OS clipboard - // (default to use native Win32 clipboard on Windows, otherwise uses a private clipboard. Override to access OS clipboard on other architectures) - const char* (*GetClipboardTextFn)(void* user_data); - void (*SetClipboardTextFn)(void* user_data, const char* text); - void* ClipboardUserData; - - // Optional: Notify OS Input Method Editor of the screen position of your cursor for text input position (e.g. when using Japanese/Chinese IME on Windows) - // (default to use native imm32 api on Windows) - void (*ImeSetInputScreenPosFn)(int x, int y); - void* ImeWindowHandle; // = NULL // (Windows) Set this to your HWND to get automatic IME cursor positioning. - - //------------------------------------------------------------------ - // Input - Fill before calling NewFrame() - //------------------------------------------------------------------ - - ImVec2 MousePos; // Mouse position, in pixels. Set to ImVec2(-FLT_MAX, -FLT_MAX) if mouse is unavailable (on another screen, etc.) - bool MouseDown[5]; // Mouse buttons: 0=left, 1=right, 2=middle + extras (ImGuiMouseButton_COUNT == 5). Dear ImGui mostly uses left and right buttons. Others buttons allows us to track if the mouse is being used by your application + available to user as a convenience via IsMouse** API. - float MouseWheel; // Mouse wheel Vertical: 1 unit scrolls about 5 lines text. - float MouseWheelH; // Mouse wheel Horizontal. Most users don't have a mouse with an horizontal wheel, may not be filled by all backends. - bool KeyCtrl; // Keyboard modifier pressed: Control - bool KeyShift; // Keyboard modifier pressed: Shift - bool KeyAlt; // Keyboard modifier pressed: Alt - bool KeySuper; // Keyboard modifier pressed: Cmd/Super/Windows - bool KeysDown[512]; // Keyboard keys that are pressed (ideally left in the "native" order your engine has access to keyboard keys, so you can use your own defines/enums for keys). - float NavInputs[ImGuiNavInput_COUNT]; // Gamepad inputs. Cleared back to zero by EndFrame(). Keyboard keys will be auto-mapped and be written here by NewFrame(). - - // Functions - IMGUI_API void AddInputCharacter(unsigned int c); // Queue new character input - IMGUI_API void AddInputCharacterUTF16(ImWchar16 c); // Queue new character input from an UTF-16 character, it can be a surrogate - IMGUI_API void AddInputCharactersUTF8(const char* str); // Queue new characters input from an UTF-8 string - IMGUI_API void AddFocusEvent(bool focused); // Notifies Dear ImGui when hosting platform windows lose or gain input focus - IMGUI_API void ClearInputCharacters(); // [Internal] Clear the text input buffer manually - IMGUI_API void ClearInputKeys(); // [Internal] Release all keys - - //------------------------------------------------------------------ - // Output - Updated by NewFrame() or EndFrame()/Render() - // (when reading from the io.WantCaptureMouse, io.WantCaptureKeyboard flags to dispatch your inputs, it is - // generally easier and more correct to use their state BEFORE calling NewFrame(). See FAQ for details!) - //------------------------------------------------------------------ - - bool WantCaptureMouse; // Set when Dear ImGui will use mouse inputs, in this case do not dispatch them to your main game/application (either way, always pass on mouse inputs to imgui). (e.g. unclicked mouse is hovering over an imgui window, widget is active, mouse was clicked over an imgui window, etc.). - bool WantCaptureKeyboard; // Set when Dear ImGui will use keyboard inputs, in this case do not dispatch them to your main game/application (either way, always pass keyboard inputs to imgui). (e.g. InputText active, or an imgui window is focused and navigation is enabled, etc.). - bool WantTextInput; // Mobile/console: when set, you may display an on-screen keyboard. This is set by Dear ImGui when it wants textual keyboard input to happen (e.g. when a InputText widget is active). - bool WantSetMousePos; // MousePos has been altered, backend should reposition mouse on next frame. Rarely used! Set only when ImGuiConfigFlags_NavEnableSetMousePos flag is enabled. - bool WantSaveIniSettings; // When manual .ini load/save is active (io.IniFilename == NULL), this will be set to notify your application that you can call SaveIniSettingsToMemory() and save yourself. Important: clear io.WantSaveIniSettings yourself after saving! - bool NavActive; // Keyboard/Gamepad navigation is currently allowed (will handle ImGuiKey_NavXXX events) = a window is focused and it doesn't use the ImGuiWindowFlags_NoNavInputs flag. - bool NavVisible; // Keyboard/Gamepad navigation is visible and allowed (will handle ImGuiKey_NavXXX events). - float Framerate; // Rough estimate of application framerate, in frame per second. Solely for convenience. Rolling average estimation based on io.DeltaTime over 120 frames. - int MetricsRenderVertices; // Vertices output during last call to Render() - int MetricsRenderIndices; // Indices output during last call to Render() = number of triangles * 3 - int MetricsRenderWindows; // Number of visible windows - int MetricsActiveWindows; // Number of active windows - int MetricsActiveAllocations; // Number of active allocations, updated by MemAlloc/MemFree based on current context. May be off if you have multiple imgui contexts. - ImVec2 MouseDelta; // Mouse delta. Note that this is zero if either current or previous position are invalid (-FLT_MAX,-FLT_MAX), so a disappearing/reappearing mouse won't have a huge delta. - - //------------------------------------------------------------------ - // [Internal] Dear ImGui will maintain those fields. Forward compatibility not guaranteed! - //------------------------------------------------------------------ - - bool WantCaptureMouseUnlessPopupClose;// Alternative to WantCaptureMouse: (WantCaptureMouse == true && WantCaptureMouseUnlessPopupClose == false) when a click over void is expected to close a popup. - ImGuiKeyModFlags KeyMods; // Key mods flags (same as io.KeyCtrl/KeyShift/KeyAlt/KeySuper but merged into flags), updated by NewFrame() - ImGuiKeyModFlags KeyModsPrev; // Previous key mods - ImVec2 MousePosPrev; // Previous mouse position (note that MouseDelta is not necessary == MousePos-MousePosPrev, in case either position is invalid) - ImVec2 MouseClickedPos[5]; // Position at time of clicking - double MouseClickedTime[5]; // Time of last click (used to figure out double-click) - bool MouseClicked[5]; // Mouse button went from !Down to Down - bool MouseDoubleClicked[5]; // Has mouse button been double-clicked? - bool MouseReleased[5]; // Mouse button went from Down to !Down - bool MouseDownOwned[5]; // Track if button was clicked inside a dear imgui window or over void blocked by a popup. We don't request mouse capture from the application if click started outside ImGui bounds. - bool MouseDownOwnedUnlessPopupClose[5];//Track if button was clicked inside a dear imgui window. - bool MouseDownWasDoubleClick[5]; // Track if button down was a double-click - float MouseDownDuration[5]; // Duration the mouse button has been down (0.0f == just clicked) - float MouseDownDurationPrev[5]; // Previous time the mouse button has been down - ImVec2 MouseDragMaxDistanceAbs[5]; // Maximum distance, absolute, on each axis, of how much mouse has traveled from the clicking point - float MouseDragMaxDistanceSqr[5]; // Squared maximum distance of how much mouse has traveled from the clicking point - float KeysDownDuration[512]; // Duration the keyboard key has been down (0.0f == just pressed) - float KeysDownDurationPrev[512]; // Previous duration the key has been down - float NavInputsDownDuration[ImGuiNavInput_COUNT]; - float NavInputsDownDurationPrev[ImGuiNavInput_COUNT]; - float PenPressure; // Touch/Pen pressure (0.0f to 1.0f, should be >0.0f only when MouseDown[0] == true). Helper storage currently unused by Dear ImGui. - bool AppFocusLost; - ImWchar16 InputQueueSurrogate; // For AddInputCharacterUTF16 - ImVector InputQueueCharacters; // Queue of _characters_ input (obtained by platform backend). Fill using AddInputCharacter() helper. - - IMGUI_API ImGuiIO(); -}; - -//----------------------------------------------------------------------------- -// [SECTION] Misc data structures -//----------------------------------------------------------------------------- - -// Shared state of InputText(), passed as an argument to your callback when a ImGuiInputTextFlags_Callback* flag is used. -// The callback function should return 0 by default. -// Callbacks (follow a flag name and see comments in ImGuiInputTextFlags_ declarations for more details) -// - ImGuiInputTextFlags_CallbackEdit: Callback on buffer edit (note that InputText() already returns true on edit, the callback is useful mainly to manipulate the underlying buffer while focus is active) -// - ImGuiInputTextFlags_CallbackAlways: Callback on each iteration -// - ImGuiInputTextFlags_CallbackCompletion: Callback on pressing TAB -// - ImGuiInputTextFlags_CallbackHistory: Callback on pressing Up/Down arrows -// - ImGuiInputTextFlags_CallbackCharFilter: Callback on character inputs to replace or discard them. Modify 'EventChar' to replace or discard, or return 1 in callback to discard. -// - ImGuiInputTextFlags_CallbackResize: Callback on buffer capacity changes request (beyond 'buf_size' parameter value), allowing the string to grow. -struct ImGuiInputTextCallbackData -{ - ImGuiInputTextFlags EventFlag; // One ImGuiInputTextFlags_Callback* // Read-only - ImGuiInputTextFlags Flags; // What user passed to InputText() // Read-only - void* UserData; // What user passed to InputText() // Read-only - - // Arguments for the different callback events - // - To modify the text buffer in a callback, prefer using the InsertChars() / DeleteChars() function. InsertChars() will take care of calling the resize callback if necessary. - // - If you know your edits are not going to resize the underlying buffer allocation, you may modify the contents of 'Buf[]' directly. You need to update 'BufTextLen' accordingly (0 <= BufTextLen < BufSize) and set 'BufDirty'' to true so InputText can update its internal state. - ImWchar EventChar; // Character input // Read-write // [CharFilter] Replace character with another one, or set to zero to drop. return 1 is equivalent to setting EventChar=0; - ImGuiKey EventKey; // Key pressed (Up/Down/TAB) // Read-only // [Completion,History] - char* Buf; // Text buffer // Read-write // [Resize] Can replace pointer / [Completion,History,Always] Only write to pointed data, don't replace the actual pointer! - int BufTextLen; // Text length (in bytes) // Read-write // [Resize,Completion,History,Always] Exclude zero-terminator storage. In C land: == strlen(some_text), in C++ land: string.length() - int BufSize; // Buffer size (in bytes) = capacity+1 // Read-only // [Resize,Completion,History,Always] Include zero-terminator storage. In C land == ARRAYSIZE(my_char_array), in C++ land: string.capacity()+1 - bool BufDirty; // Set if you modify Buf/BufTextLen! // Write // [Completion,History,Always] - int CursorPos; // // Read-write // [Completion,History,Always] - int SelectionStart; // // Read-write // [Completion,History,Always] == to SelectionEnd when no selection) - int SelectionEnd; // // Read-write // [Completion,History,Always] - - // Helper functions for text manipulation. - // Use those function to benefit from the CallbackResize behaviors. Calling those function reset the selection. - IMGUI_API ImGuiInputTextCallbackData(); - IMGUI_API void DeleteChars(int pos, int bytes_count); - IMGUI_API void InsertChars(int pos, const char* text, const char* text_end = NULL); - void SelectAll() { SelectionStart = 0; SelectionEnd = BufTextLen; } - void ClearSelection() { SelectionStart = SelectionEnd = BufTextLen; } - bool HasSelection() const { return SelectionStart != SelectionEnd; } -}; - -// Resizing callback data to apply custom constraint. As enabled by SetNextWindowSizeConstraints(). Callback is called during the next Begin(). -// NB: For basic min/max size constraint on each axis you don't need to use the callback! The SetNextWindowSizeConstraints() parameters are enough. -struct ImGuiSizeCallbackData -{ - void* UserData; // Read-only. What user passed to SetNextWindowSizeConstraints() - ImVec2 Pos; // Read-only. Window position, for reference. - ImVec2 CurrentSize; // Read-only. Current window size. - ImVec2 DesiredSize; // Read-write. Desired size, based on user's mouse position. Write to this field to restrain resizing. -}; - -// Data payload for Drag and Drop operations: AcceptDragDropPayload(), GetDragDropPayload() -struct ImGuiPayload -{ - // Members - void* Data; // Data (copied and owned by dear imgui) - int DataSize; // Data size - - // [Internal] - ImGuiID SourceId; // Source item id - ImGuiID SourceParentId; // Source parent id (if available) - int DataFrameCount; // Data timestamp - char DataType[32 + 1]; // Data type tag (short user-supplied string, 32 characters max) - bool Preview; // Set when AcceptDragDropPayload() was called and mouse has been hovering the target item (nb: handle overlapping drag targets) - bool Delivery; // Set when AcceptDragDropPayload() was called and mouse button is released over the target item. - - ImGuiPayload() { Clear(); } - void Clear() { SourceId = SourceParentId = 0; Data = NULL; DataSize = 0; memset(DataType, 0, sizeof(DataType)); DataFrameCount = -1; Preview = Delivery = false; } - bool IsDataType(const char* type) const { return DataFrameCount != -1 && strcmp(type, DataType) == 0; } - bool IsPreview() const { return Preview; } - bool IsDelivery() const { return Delivery; } -}; - -// Sorting specification for one column of a table (sizeof == 12 bytes) -struct ImGuiTableColumnSortSpecs -{ - ImGuiID ColumnUserID; // User id of the column (if specified by a TableSetupColumn() call) - ImS16 ColumnIndex; // Index of the column - ImS16 SortOrder; // Index within parent ImGuiTableSortSpecs (always stored in order starting from 0, tables sorted on a single criteria will always have a 0 here) - ImGuiSortDirection SortDirection : 8; // ImGuiSortDirection_Ascending or ImGuiSortDirection_Descending (you can use this or SortSign, whichever is more convenient for your sort function) - - ImGuiTableColumnSortSpecs() { memset(this, 0, sizeof(*this)); } -}; - -// Sorting specifications for a table (often handling sort specs for a single column, occasionally more) -// Obtained by calling TableGetSortSpecs(). -// When 'SpecsDirty == true' you can sort your data. It will be true with sorting specs have changed since last call, or the first time. -// Make sure to set 'SpecsDirty = false' after sorting, else you may wastefully sort your data every frame! -struct ImGuiTableSortSpecs -{ - const ImGuiTableColumnSortSpecs* Specs; // Pointer to sort spec array. - int SpecsCount; // Sort spec count. Most often 1. May be > 1 when ImGuiTableFlags_SortMulti is enabled. May be == 0 when ImGuiTableFlags_SortTristate is enabled. - bool SpecsDirty; // Set to true when specs have changed since last time! Use this to sort again, then clear the flag. - - ImGuiTableSortSpecs() { memset(this, 0, sizeof(*this)); } -}; - -//----------------------------------------------------------------------------- -// [SECTION] Helpers (ImGuiOnceUponAFrame, ImGuiTextFilter, ImGuiTextBuffer, ImGuiStorage, ImGuiListClipper, ImColor) -//----------------------------------------------------------------------------- - -// Helper: Unicode defines -#define IM_UNICODE_CODEPOINT_INVALID 0xFFFD // Invalid Unicode code point (standard value). -#ifdef IMGUI_USE_WCHAR32 -#define IM_UNICODE_CODEPOINT_MAX 0x10FFFF // Maximum Unicode code point supported by this build. -#else -#define IM_UNICODE_CODEPOINT_MAX 0xFFFF // Maximum Unicode code point supported by this build. -#endif - -// Helper: Execute a block of code at maximum once a frame. Convenient if you want to quickly create an UI within deep-nested code that runs multiple times every frame. -// Usage: static ImGuiOnceUponAFrame oaf; if (oaf) ImGui::Text("This will be called only once per frame"); -struct ImGuiOnceUponAFrame -{ - ImGuiOnceUponAFrame() { RefFrame = -1; } - mutable int RefFrame; - operator bool() const { int current_frame = ImGui::GetFrameCount(); if (RefFrame == current_frame) return false; RefFrame = current_frame; return true; } -}; - -// Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]" -struct ImGuiTextFilter -{ - IMGUI_API ImGuiTextFilter(const char* default_filter = ""); - IMGUI_API bool Draw(const char* label = "Filter (inc,-exc)", float width = 0.0f); // Helper calling InputText+Build - IMGUI_API bool PassFilter(const char* text, const char* text_end = NULL) const; - IMGUI_API void Build(); - void Clear() { InputBuf[0] = 0; Build(); } - bool IsActive() const { return !Filters.empty(); } - - // [Internal] - struct ImGuiTextRange - { - const char* b; - const char* e; - - ImGuiTextRange() { b = e = NULL; } - ImGuiTextRange(const char* _b, const char* _e) { b = _b; e = _e; } - bool empty() const { return b == e; } - IMGUI_API void split(char separator, ImVector* out) const; - }; - char InputBuf[256]; - ImVectorFilters; - int CountGrep; -}; - -// Helper: Growable text buffer for logging/accumulating text -// (this could be called 'ImGuiTextBuilder' / 'ImGuiStringBuilder') -struct ImGuiTextBuffer -{ - ImVector Buf; - IMGUI_API static char EmptyString[1]; - - ImGuiTextBuffer() { } - inline char operator[](int i) const { IM_ASSERT(Buf.Data != NULL); return Buf.Data[i]; } - const char* begin() const { return Buf.Data ? &Buf.front() : EmptyString; } - const char* end() const { return Buf.Data ? &Buf.back() : EmptyString; } // Buf is zero-terminated, so end() will point on the zero-terminator - int size() const { return Buf.Size ? Buf.Size - 1 : 0; } - bool empty() const { return Buf.Size <= 1; } - void clear() { Buf.clear(); } - void reserve(int capacity) { Buf.reserve(capacity); } - const char* c_str() const { return Buf.Data ? Buf.Data : EmptyString; } - IMGUI_API void append(const char* str, const char* str_end = NULL); - IMGUI_API void appendf(const char* fmt, ...) IM_FMTARGS(2); - IMGUI_API void appendfv(const char* fmt, va_list args) IM_FMTLIST(2); -}; - -// Helper: Key->Value storage -// Typically you don't have to worry about this since a storage is held within each Window. -// We use it to e.g. store collapse state for a tree (Int 0/1) -// This is optimized for efficient lookup (dichotomy into a contiguous buffer) and rare insertion (typically tied to user interactions aka max once a frame) -// You can use it as custom user storage for temporary values. Declare your own storage if, for example: -// - You want to manipulate the open/close state of a particular sub-tree in your interface (tree node uses Int 0/1 to store their state). -// - You want to store custom debug data easily without adding or editing structures in your code (probably not efficient, but convenient) -// Types are NOT stored, so it is up to you to make sure your Key don't collide with different types. -struct ImGuiStorage -{ - // [Internal] - struct ImGuiStoragePair - { - ImGuiID key; - union { int val_i; float val_f; void* val_p; }; - ImGuiStoragePair(ImGuiID _key, int _val_i) { key = _key; val_i = _val_i; } - ImGuiStoragePair(ImGuiID _key, float _val_f) { key = _key; val_f = _val_f; } - ImGuiStoragePair(ImGuiID _key, void* _val_p) { key = _key; val_p = _val_p; } - }; - - ImVector Data; - - // - Get***() functions find pair, never add/allocate. Pairs are sorted so a query is O(log N) - // - Set***() functions find pair, insertion on demand if missing. - // - Sorted insertion is costly, paid once. A typical frame shouldn't need to insert any new pair. - void Clear() { Data.clear(); } - IMGUI_API int GetInt(ImGuiID key, int default_val = 0) const; - IMGUI_API void SetInt(ImGuiID key, int val); - IMGUI_API bool GetBool(ImGuiID key, bool default_val = false) const; - IMGUI_API void SetBool(ImGuiID key, bool val); - IMGUI_API float GetFloat(ImGuiID key, float default_val = 0.0f) const; - IMGUI_API void SetFloat(ImGuiID key, float val); - IMGUI_API void* GetVoidPtr(ImGuiID key) const; // default_val is NULL - IMGUI_API void SetVoidPtr(ImGuiID key, void* val); - - // - Get***Ref() functions finds pair, insert on demand if missing, return pointer. Useful if you intend to do Get+Set. - // - References are only valid until a new value is added to the storage. Calling a Set***() function or a Get***Ref() function invalidates the pointer. - // - A typical use case where this is convenient for quick hacking (e.g. add storage during a live Edit&Continue session if you can't modify existing struct) - // float* pvar = ImGui::GetFloatRef(key); ImGui::SliderFloat("var", pvar, 0, 100.0f); some_var += *pvar; - IMGUI_API int* GetIntRef(ImGuiID key, int default_val = 0); - IMGUI_API bool* GetBoolRef(ImGuiID key, bool default_val = false); - IMGUI_API float* GetFloatRef(ImGuiID key, float default_val = 0.0f); - IMGUI_API void** GetVoidPtrRef(ImGuiID key, void* default_val = NULL); - - // Use on your own storage if you know only integer are being stored (open/close all tree nodes) - IMGUI_API void SetAllInt(int val); - - // For quicker full rebuild of a storage (instead of an incremental one), you may add all your contents and then sort once. - IMGUI_API void BuildSortByKey(); -}; - -// Helper: Manually clip large list of items. -// If you are submitting lots of evenly spaced items and you have a random access to the list, you can perform coarse -// clipping based on visibility to save yourself from processing those items at all. -// The clipper calculates the range of visible items and advance the cursor to compensate for the non-visible items we have skipped. -// (Dear ImGui already clip items based on their bounds but it needs to measure text size to do so, whereas manual coarse clipping before submission makes this cost and your own data fetching/submission cost almost null) -// Usage: -// ImGuiListClipper clipper; -// clipper.Begin(1000); // We have 1000 elements, evenly spaced. -// while (clipper.Step()) -// for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) -// ImGui::Text("line number %d", i); -// Generally what happens is: -// - Clipper lets you process the first element (DisplayStart = 0, DisplayEnd = 1) regardless of it being visible or not. -// - User code submit one element. -// - Clipper can measure the height of the first element -// - Clipper calculate the actual range of elements to display based on the current clipping rectangle, position the cursor before the first visible element. -// - User code submit visible elements. -struct ImGuiListClipper -{ - int DisplayStart; - int DisplayEnd; - - // [Internal] - int ItemsCount; - int StepNo; - int ItemsFrozen; - float ItemsHeight; - float StartPosY; - - IMGUI_API ImGuiListClipper(); - IMGUI_API ~ImGuiListClipper(); - - // items_count: Use INT_MAX if you don't know how many items you have (in which case the cursor won't be advanced in the final step) - // items_height: Use -1.0f to be calculated automatically on first step. Otherwise pass in the distance between your items, typically GetTextLineHeightWithSpacing() or GetFrameHeightWithSpacing(). - IMGUI_API void Begin(int items_count, float items_height = -1.0f); // Automatically called by constructor if you passed 'items_count' or by Step() in Step 1. - IMGUI_API void End(); // Automatically called on the last call of Step() that returns false. - IMGUI_API bool Step(); // Call until it returns false. The DisplayStart/DisplayEnd fields will be set and you can process/draw those items. - -#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS - inline ImGuiListClipper(int items_count, float items_height = -1.0f) { memset(this, 0, sizeof(*this)); ItemsCount = -1; Begin(items_count, items_height); } // [removed in 1.79] -#endif -}; - -// Helpers macros to generate 32-bit encoded colors -#ifdef IMGUI_USE_BGRA_PACKED_COLOR -#define IM_COL32_R_SHIFT 16 -#define IM_COL32_G_SHIFT 8 -#define IM_COL32_B_SHIFT 0 -#define IM_COL32_A_SHIFT 24 -#define IM_COL32_A_MASK 0xFF000000 -#else -#define IM_COL32_R_SHIFT 0 -#define IM_COL32_G_SHIFT 8 -#define IM_COL32_B_SHIFT 16 -#define IM_COL32_A_SHIFT 24 -#define IM_COL32_A_MASK 0xFF000000 -#endif -#define IM_COL32(R,G,B,A) (((ImU32)(A)<> IM_COL32_R_SHIFT) & 0xFF) * sc; Value.y = (float)((rgba >> IM_COL32_G_SHIFT) & 0xFF) * sc; Value.z = (float)((rgba >> IM_COL32_B_SHIFT) & 0xFF) * sc; Value.w = (float)((rgba >> IM_COL32_A_SHIFT) & 0xFF) * sc; } - ImColor(float r, float g, float b, float a = 1.0f) { Value.x = r; Value.y = g; Value.z = b; Value.w = a; } - ImColor(const ImVec4& col) { Value = col; } - inline operator ImU32() const { return ImGui::ColorConvertFloat4ToU32(Value); } - inline operator ImVec4() const { return Value; } - - // FIXME-OBSOLETE: May need to obsolete/cleanup those helpers. - inline void SetHSV(float h, float s, float v, float a = 1.0f){ ImGui::ColorConvertHSVtoRGB(h, s, v, Value.x, Value.y, Value.z); Value.w = a; } - static ImColor HSV(float h, float s, float v, float a = 1.0f) { float r, g, b; ImGui::ColorConvertHSVtoRGB(h, s, v, r, g, b); return ImColor(r, g, b, a); } -}; - -//----------------------------------------------------------------------------- -// [SECTION] Drawing API (ImDrawCmd, ImDrawIdx, ImDrawVert, ImDrawChannel, ImDrawListSplitter, ImDrawListFlags, ImDrawList, ImDrawData) -// Hold a series of drawing commands. The user provides a renderer for ImDrawData which essentially contains an array of ImDrawList. -//----------------------------------------------------------------------------- - -// The maximum line width to bake anti-aliased textures for. Build atlas with ImFontAtlasFlags_NoBakedLines to disable baking. -#ifndef IM_DRAWLIST_TEX_LINES_WIDTH_MAX -#define IM_DRAWLIST_TEX_LINES_WIDTH_MAX (63) -#endif - -// ImDrawCallback: Draw callbacks for advanced uses [configurable type: override in imconfig.h] -// NB: You most likely do NOT need to use draw callbacks just to create your own widget or customized UI rendering, -// you can poke into the draw list for that! Draw callback may be useful for example to: -// A) Change your GPU render state, -// B) render a complex 3D scene inside a UI element without an intermediate texture/render target, etc. -// The expected behavior from your rendering function is 'if (cmd.UserCallback != NULL) { cmd.UserCallback(parent_list, cmd); } else { RenderTriangles() }' -// If you want to override the signature of ImDrawCallback, you can simply use e.g. '#define ImDrawCallback MyDrawCallback' (in imconfig.h) + update rendering backend accordingly. -#ifndef ImDrawCallback -typedef void (*ImDrawCallback)(const ImDrawList* parent_list, const ImDrawCmd* cmd); -#endif - -// Special Draw callback value to request renderer backend to reset the graphics/render state. -// The renderer backend needs to handle this special value, otherwise it will crash trying to call a function at this address. -// This is useful for example if you submitted callbacks which you know have altered the render state and you want it to be restored. -// It is not done by default because they are many perfectly useful way of altering render state for imgui contents (e.g. changing shader/blending settings before an Image call). -#define ImDrawCallback_ResetRenderState (ImDrawCallback)(-1) - -// Typically, 1 command = 1 GPU draw call (unless command is a callback) -// - VtxOffset/IdxOffset: When 'io.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset' is enabled, -// those fields allow us to render meshes larger than 64K vertices while keeping 16-bit indices. -// Pre-1.71 backends will typically ignore the VtxOffset/IdxOffset fields. -// - The ClipRect/TextureId/VtxOffset fields must be contiguous as we memcmp() them together (this is asserted for). -struct ImDrawCmd -{ - ImVec4 ClipRect; // 4*4 // Clipping rectangle (x1, y1, x2, y2). Subtract ImDrawData->DisplayPos to get clipping rectangle in "viewport" coordinates - ImTextureID TextureId; // 4-8 // User-provided texture ID. Set by user in ImfontAtlas::SetTexID() for fonts or passed to Image*() functions. Ignore if never using images or multiple fonts atlas. - unsigned int VtxOffset; // 4 // Start offset in vertex buffer. ImGuiBackendFlags_RendererHasVtxOffset: always 0, otherwise may be >0 to support meshes larger than 64K vertices with 16-bit indices. - unsigned int IdxOffset; // 4 // Start offset in index buffer. Always equal to sum of ElemCount drawn so far. - unsigned int ElemCount; // 4 // Number of indices (multiple of 3) to be rendered as triangles. Vertices are stored in the callee ImDrawList's vtx_buffer[] array, indices in idx_buffer[]. - ImDrawCallback UserCallback; // 4-8 // If != NULL, call the function instead of rendering the vertices. clip_rect and texture_id will be set normally. - void* UserCallbackData; // 4-8 // The draw callback code can access this. - - ImDrawCmd() { memset(this, 0, sizeof(*this)); } // Also ensure our padding fields are zeroed - - // Since 1.83: returns ImTextureID associated with this draw call. Warning: DO NOT assume this is always same as 'TextureId' (we will change this function for an upcoming feature) - inline ImTextureID GetTexID() const { return TextureId; } -}; - -// Vertex layout -#ifndef IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT -struct ImDrawVert -{ - ImVec2 pos; - ImVec2 uv; - ImU32 col; -}; -#else -// You can override the vertex format layout by defining IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT in imconfig.h -// The code expect ImVec2 pos (8 bytes), ImVec2 uv (8 bytes), ImU32 col (4 bytes), but you can re-order them or add other fields as needed to simplify integration in your engine. -// The type has to be described within the macro (you can either declare the struct or use a typedef). This is because ImVec2/ImU32 are likely not declared a the time you'd want to set your type up. -// NOTE: IMGUI DOESN'T CLEAR THE STRUCTURE AND DOESN'T CALL A CONSTRUCTOR SO ANY CUSTOM FIELD WILL BE UNINITIALIZED. IF YOU ADD EXTRA FIELDS (SUCH AS A 'Z' COORDINATES) YOU WILL NEED TO CLEAR THEM DURING RENDER OR TO IGNORE THEM. -IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT; -#endif - -// [Internal] For use by ImDrawList -struct ImDrawCmdHeader -{ - ImVec4 ClipRect; - ImTextureID TextureId; - unsigned int VtxOffset; -}; - -// [Internal] For use by ImDrawListSplitter -struct ImDrawChannel -{ - ImVector _CmdBuffer; - ImVector _IdxBuffer; -}; - - -// Split/Merge functions are used to split the draw list into different layers which can be drawn into out of order. -// This is used by the Columns/Tables API, so items of each column can be batched together in a same draw call. -struct ImDrawListSplitter -{ - int _Current; // Current channel number (0) - int _Count; // Number of active channels (1+) - ImVector _Channels; // Draw channels (not resized down so _Count might be < Channels.Size) - - inline ImDrawListSplitter() { memset(this, 0, sizeof(*this)); } - inline ~ImDrawListSplitter() { ClearFreeMemory(); } - inline void Clear() { _Current = 0; _Count = 1; } // Do not clear Channels[] so our allocations are reused next frame - IMGUI_API void ClearFreeMemory(); - IMGUI_API void Split(ImDrawList* draw_list, int count); - IMGUI_API void Merge(ImDrawList* draw_list); - IMGUI_API void SetCurrentChannel(ImDrawList* draw_list, int channel_idx); -}; - -// Flags for ImDrawList functions -// (Legacy: bit 0 must always correspond to ImDrawFlags_Closed to be backward compatible with old API using a bool. Bits 1..3 must be unused) -enum ImDrawFlags_ -{ - ImDrawFlags_None = 0, - ImDrawFlags_Closed = 1 << 0, // PathStroke(), AddPolyline(): specify that shape should be closed (Important: this is always == 1 for legacy reason) - ImDrawFlags_RoundCornersTopLeft = 1 << 4, // AddRect(), AddRectFilled(), PathRect(): enable rounding top-left corner only (when rounding > 0.0f, we default to all corners). Was 0x01. - ImDrawFlags_RoundCornersTopRight = 1 << 5, // AddRect(), AddRectFilled(), PathRect(): enable rounding top-right corner only (when rounding > 0.0f, we default to all corners). Was 0x02. - ImDrawFlags_RoundCornersBottomLeft = 1 << 6, // AddRect(), AddRectFilled(), PathRect(): enable rounding bottom-left corner only (when rounding > 0.0f, we default to all corners). Was 0x04. - ImDrawFlags_RoundCornersBottomRight = 1 << 7, // AddRect(), AddRectFilled(), PathRect(): enable rounding bottom-right corner only (when rounding > 0.0f, we default to all corners). Wax 0x08. - ImDrawFlags_RoundCornersNone = 1 << 8, // AddRect(), AddRectFilled(), PathRect(): disable rounding on all corners (when rounding > 0.0f). This is NOT zero, NOT an implicit flag! - ImDrawFlags_RoundCornersTop = ImDrawFlags_RoundCornersTopLeft | ImDrawFlags_RoundCornersTopRight, - ImDrawFlags_RoundCornersBottom = ImDrawFlags_RoundCornersBottomLeft | ImDrawFlags_RoundCornersBottomRight, - ImDrawFlags_RoundCornersLeft = ImDrawFlags_RoundCornersBottomLeft | ImDrawFlags_RoundCornersTopLeft, - ImDrawFlags_RoundCornersRight = ImDrawFlags_RoundCornersBottomRight | ImDrawFlags_RoundCornersTopRight, - ImDrawFlags_RoundCornersAll = ImDrawFlags_RoundCornersTopLeft | ImDrawFlags_RoundCornersTopRight | ImDrawFlags_RoundCornersBottomLeft | ImDrawFlags_RoundCornersBottomRight, - ImDrawFlags_RoundCornersDefault_ = ImDrawFlags_RoundCornersAll, // Default to ALL corners if none of the _RoundCornersXX flags are specified. - ImDrawFlags_RoundCornersMask_ = ImDrawFlags_RoundCornersAll | ImDrawFlags_RoundCornersNone -}; - -// Flags for ImDrawList instance. Those are set automatically by ImGui:: functions from ImGuiIO settings, and generally not manipulated directly. -// It is however possible to temporarily alter flags between calls to ImDrawList:: functions. -enum ImDrawListFlags_ -{ - ImDrawListFlags_None = 0, - ImDrawListFlags_AntiAliasedLines = 1 << 0, // Enable anti-aliased lines/borders (*2 the number of triangles for 1.0f wide line or lines thin enough to be drawn using textures, otherwise *3 the number of triangles) - ImDrawListFlags_AntiAliasedLinesUseTex = 1 << 1, // Enable anti-aliased lines/borders using textures when possible. Require backend to render with bilinear filtering. - ImDrawListFlags_AntiAliasedFill = 1 << 2, // Enable anti-aliased edge around filled shapes (rounded rectangles, circles). - ImDrawListFlags_AllowVtxOffset = 1 << 3 // Can emit 'VtxOffset > 0' to allow large meshes. Set when 'ImGuiBackendFlags_RendererHasVtxOffset' is enabled. -}; - -// Draw command list -// This is the low-level list of polygons that ImGui:: functions are filling. At the end of the frame, -// all command lists are passed to your ImGuiIO::RenderDrawListFn function for rendering. -// Each dear imgui window contains its own ImDrawList. You can use ImGui::GetWindowDrawList() to -// access the current window draw list and draw custom primitives. -// You can interleave normal ImGui:: calls and adding primitives to the current draw list. -// In single viewport mode, top-left is == GetMainViewport()->Pos (generally 0,0), bottom-right is == GetMainViewport()->Pos+Size (generally io.DisplaySize). -// You are totally free to apply whatever transformation matrix to want to the data (depending on the use of the transformation you may want to apply it to ClipRect as well!) -// Important: Primitives are always added to the list and not culled (culling is done at higher-level by ImGui:: functions), if you use this API a lot consider coarse culling your drawn objects. -struct ImDrawList -{ - // This is what you have to render - ImVector CmdBuffer; // Draw commands. Typically 1 command = 1 GPU draw call, unless the command is a callback. - ImVector IdxBuffer; // Index buffer. Each command consume ImDrawCmd::ElemCount of those - ImVector VtxBuffer; // Vertex buffer. - ImDrawListFlags Flags; // Flags, you may poke into these to adjust anti-aliasing settings per-primitive. - - // [Internal, used while building lists] - unsigned int _VtxCurrentIdx; // [Internal] generally == VtxBuffer.Size unless we are past 64K vertices, in which case this gets reset to 0. - const ImDrawListSharedData* _Data; // Pointer to shared draw data (you can use ImGui::GetDrawListSharedData() to get the one from current ImGui context) - const char* _OwnerName; // Pointer to owner window's name for debugging - ImDrawVert* _VtxWritePtr; // [Internal] point within VtxBuffer.Data after each add command (to avoid using the ImVector<> operators too much) - ImDrawIdx* _IdxWritePtr; // [Internal] point within IdxBuffer.Data after each add command (to avoid using the ImVector<> operators too much) - ImVector _ClipRectStack; // [Internal] - ImVector _TextureIdStack; // [Internal] - ImVector _Path; // [Internal] current path building - ImDrawCmdHeader _CmdHeader; // [Internal] template of active commands. Fields should match those of CmdBuffer.back(). - ImDrawListSplitter _Splitter; // [Internal] for channels api (note: prefer using your own persistent instance of ImDrawListSplitter!) - float _FringeScale; // [Internal] anti-alias fringe is scaled by this value, this helps to keep things sharp while zooming at vertex buffer content - - // If you want to create ImDrawList instances, pass them ImGui::GetDrawListSharedData() or create and use your own ImDrawListSharedData (so you can use ImDrawList without ImGui) - ImDrawList(const ImDrawListSharedData* shared_data) { memset(this, 0, sizeof(*this)); _Data = shared_data; } - - ~ImDrawList() { _ClearFreeMemory(); } - IMGUI_API void PushClipRect(ImVec2 clip_rect_min, ImVec2 clip_rect_max, bool intersect_with_current_clip_rect = false); // Render-level scissoring. This is passed down to your render function but not used for CPU-side coarse clipping. Prefer using higher-level ImGui::PushClipRect() to affect logic (hit-testing and widget culling) - IMGUI_API void PushClipRectFullScreen(); - IMGUI_API void PopClipRect(); - IMGUI_API void PushTextureID(ImTextureID texture_id); - IMGUI_API void PopTextureID(); - inline ImVec2 GetClipRectMin() const { const ImVec4& cr = _ClipRectStack.back(); return ImVec2(cr.x, cr.y); } - inline ImVec2 GetClipRectMax() const { const ImVec4& cr = _ClipRectStack.back(); return ImVec2(cr.z, cr.w); } - - // Primitives - // - For rectangular primitives, "p_min" and "p_max" represent the upper-left and lower-right corners. - // - For circle primitives, use "num_segments == 0" to automatically calculate tessellation (preferred). - // In older versions (until Dear ImGui 1.77) the AddCircle functions defaulted to num_segments == 12. - // In future versions we will use textures to provide cheaper and higher-quality circles. - // Use AddNgon() and AddNgonFilled() functions if you need to guaranteed a specific number of sides. - IMGUI_API void AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float thickness = 1.0f); - IMGUI_API void AddRect(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding = 0.0f, ImDrawFlags flags = 0, float thickness = 1.0f); // a: upper-left, b: lower-right (== upper-left + size) - IMGUI_API void AddRectFilled(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding = 0.0f, ImDrawFlags flags = 0); // a: upper-left, b: lower-right (== upper-left + size) - IMGUI_API void AddRectFilledMultiColor(const ImVec2& p_min, const ImVec2& p_max, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left); - IMGUI_API void AddQuad(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness = 1.0f); - IMGUI_API void AddQuadFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col); - IMGUI_API void AddTriangle(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col, float thickness = 1.0f); - IMGUI_API void AddTriangleFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col); - IMGUI_API void AddCircle(const ImVec2& center, float radius, ImU32 col, int num_segments = 0, float thickness = 1.0f); - IMGUI_API void AddCircleFilled(const ImVec2& center, float radius, ImU32 col, int num_segments = 0); - IMGUI_API void AddNgon(const ImVec2& center, float radius, ImU32 col, int num_segments, float thickness = 1.0f); - IMGUI_API void AddNgonFilled(const ImVec2& center, float radius, ImU32 col, int num_segments); - IMGUI_API void AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL); - IMGUI_API void AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end = NULL, float wrap_width = 0.0f, const ImVec4* cpu_fine_clip_rect = NULL); - IMGUI_API void AddPolyline(const ImVec2* points, int num_points, ImU32 col, ImDrawFlags flags, float thickness); - IMGUI_API void AddConvexPolyFilled(const ImVec2* points, int num_points, ImU32 col); // Note: Anti-aliased filling requires points to be in clockwise order. - IMGUI_API void AddBezierCubic(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness, int num_segments = 0); // Cubic Bezier (4 control points) - IMGUI_API void AddBezierQuadratic(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col, float thickness, int num_segments = 0); // Quadratic Bezier (3 control points) - - // Image primitives - // - Read FAQ to understand what ImTextureID is. - // - "p_min" and "p_max" represent the upper-left and lower-right corners of the rectangle. - // - "uv_min" and "uv_max" represent the normalized texture coordinates to use for those corners. Using (0,0)->(1,1) texture coordinates will generally display the entire texture. - IMGUI_API void AddImage(ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min = ImVec2(0, 0), const ImVec2& uv_max = ImVec2(1, 1), ImU32 col = IM_COL32_WHITE); - IMGUI_API void AddImageQuad(ImTextureID user_texture_id, const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& uv1 = ImVec2(0, 0), const ImVec2& uv2 = ImVec2(1, 0), const ImVec2& uv3 = ImVec2(1, 1), const ImVec2& uv4 = ImVec2(0, 1), ImU32 col = IM_COL32_WHITE); - IMGUI_API void AddImageRounded(ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, ImU32 col, float rounding, ImDrawFlags flags = 0); - - // Stateful path API, add points then finish with PathFillConvex() or PathStroke() - inline void PathClear() { _Path.Size = 0; } - inline void PathLineTo(const ImVec2& pos) { _Path.push_back(pos); } - inline void PathLineToMergeDuplicate(const ImVec2& pos) { if (_Path.Size == 0 || memcmp(&_Path.Data[_Path.Size - 1], &pos, 8) != 0) _Path.push_back(pos); } - inline void PathFillConvex(ImU32 col) { AddConvexPolyFilled(_Path.Data, _Path.Size, col); _Path.Size = 0; } // Note: Anti-aliased filling requires points to be in clockwise order. - inline void PathStroke(ImU32 col, ImDrawFlags flags = 0, float thickness = 1.0f) { AddPolyline(_Path.Data, _Path.Size, col, flags, thickness); _Path.Size = 0; } - IMGUI_API void PathArcTo(const ImVec2& center, float radius, float a_min, float a_max, int num_segments = 0); - IMGUI_API void PathArcToFast(const ImVec2& center, float radius, int a_min_of_12, int a_max_of_12); // Use precomputed angles for a 12 steps circle - IMGUI_API void PathBezierCubicCurveTo(const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, int num_segments = 0); // Cubic Bezier (4 control points) - IMGUI_API void PathBezierQuadraticCurveTo(const ImVec2& p2, const ImVec2& p3, int num_segments = 0); // Quadratic Bezier (3 control points) - IMGUI_API void PathRect(const ImVec2& rect_min, const ImVec2& rect_max, float rounding = 0.0f, ImDrawFlags flags = 0); - - // Advanced - IMGUI_API void AddCallback(ImDrawCallback callback, void* callback_data); // Your rendering function must check for 'UserCallback' in ImDrawCmd and call the function instead of rendering triangles. - IMGUI_API void AddDrawCmd(); // This is useful if you need to forcefully create a new draw call (to allow for dependent rendering / blending). Otherwise primitives are merged into the same draw-call as much as possible - IMGUI_API ImDrawList* CloneOutput() const; // Create a clone of the CmdBuffer/IdxBuffer/VtxBuffer. - - // Advanced: Channels - // - Use to split render into layers. By switching channels to can render out-of-order (e.g. submit FG primitives before BG primitives) - // - Use to minimize draw calls (e.g. if going back-and-forth between multiple clipping rectangles, prefer to append into separate channels then merge at the end) - // - FIXME-OBSOLETE: This API shouldn't have been in ImDrawList in the first place! - // Prefer using your own persistent instance of ImDrawListSplitter as you can stack them. - // Using the ImDrawList::ChannelsXXXX you cannot stack a split over another. - inline void ChannelsSplit(int count) { _Splitter.Split(this, count); } - inline void ChannelsMerge() { _Splitter.Merge(this); } - inline void ChannelsSetCurrent(int n) { _Splitter.SetCurrentChannel(this, n); } - - // Advanced: Primitives allocations - // - We render triangles (three vertices) - // - All primitives needs to be reserved via PrimReserve() beforehand. - IMGUI_API void PrimReserve(int idx_count, int vtx_count); - IMGUI_API void PrimUnreserve(int idx_count, int vtx_count); - IMGUI_API void PrimRect(const ImVec2& a, const ImVec2& b, ImU32 col); // Axis aligned rectangle (composed of two triangles) - IMGUI_API void PrimRectUV(const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col); - IMGUI_API void PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a, const ImVec2& uv_b, const ImVec2& uv_c, const ImVec2& uv_d, ImU32 col); - inline void PrimWriteVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col) { _VtxWritePtr->pos = pos; _VtxWritePtr->uv = uv; _VtxWritePtr->col = col; _VtxWritePtr++; _VtxCurrentIdx++; } - inline void PrimWriteIdx(ImDrawIdx idx) { *_IdxWritePtr = idx; _IdxWritePtr++; } - inline void PrimVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col) { PrimWriteIdx((ImDrawIdx)_VtxCurrentIdx); PrimWriteVtx(pos, uv, col); } // Write vertex with unique index - -#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS - inline void AddBezierCurve(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness, int num_segments = 0) { AddBezierCubic(p1, p2, p3, p4, col, thickness, num_segments); } - inline void PathBezierCurveTo(const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, int num_segments = 0) { PathBezierCubicCurveTo(p2, p3, p4, num_segments); } -#endif - - // [Internal helpers] - IMGUI_API void _ResetForNewFrame(); - IMGUI_API void _ClearFreeMemory(); - IMGUI_API void _PopUnusedDrawCmd(); - IMGUI_API void _TryMergeDrawCmds(); - IMGUI_API void _OnChangedClipRect(); - IMGUI_API void _OnChangedTextureID(); - IMGUI_API void _OnChangedVtxOffset(); - IMGUI_API int _CalcCircleAutoSegmentCount(float radius) const; - IMGUI_API void _PathArcToFastEx(const ImVec2& center, float radius, int a_min_sample, int a_max_sample, int a_step); - IMGUI_API void _PathArcToN(const ImVec2& center, float radius, float a_min, float a_max, int num_segments); -}; - -// All draw data to render a Dear ImGui frame -// (NB: the style and the naming convention here is a little inconsistent, we currently preserve them for backward compatibility purpose, -// as this is one of the oldest structure exposed by the library! Basically, ImDrawList == CmdList) -struct ImDrawData -{ - bool Valid; // Only valid after Render() is called and before the next NewFrame() is called. - int CmdListsCount; // Number of ImDrawList* to render - int TotalIdxCount; // For convenience, sum of all ImDrawList's IdxBuffer.Size - int TotalVtxCount; // For convenience, sum of all ImDrawList's VtxBuffer.Size - ImDrawList** CmdLists; // Array of ImDrawList* to render. The ImDrawList are owned by ImGuiContext and only pointed to from here. - ImVec2 DisplayPos; // Top-left position of the viewport to render (== top-left of the orthogonal projection matrix to use) (== GetMainViewport()->Pos for the main viewport, == (0.0) in most single-viewport applications) - ImVec2 DisplaySize; // Size of the viewport to render (== GetMainViewport()->Size for the main viewport, == io.DisplaySize in most single-viewport applications) - ImVec2 FramebufferScale; // Amount of pixels for each unit of DisplaySize. Based on io.DisplayFramebufferScale. Generally (1,1) on normal display, (2,2) on OSX with Retina display. - - // Functions - ImDrawData() { Clear(); } - void Clear() { memset(this, 0, sizeof(*this)); } // The ImDrawList are owned by ImGuiContext! - IMGUI_API void DeIndexAllBuffers(); // Helper to convert all buffers from indexed to non-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering! - IMGUI_API void ScaleClipRects(const ImVec2& fb_scale); // Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than Dear ImGui expects, or if there is a difference between your window resolution and framebuffer resolution. -}; - -//----------------------------------------------------------------------------- -// [SECTION] Font API (ImFontConfig, ImFontGlyph, ImFontAtlasFlags, ImFontAtlas, ImFontGlyphRangesBuilder, ImFont) -//----------------------------------------------------------------------------- - -struct ImFontConfig -{ - void* FontData; // // TTF/OTF data - int FontDataSize; // // TTF/OTF data size - bool FontDataOwnedByAtlas; // true // TTF/OTF data ownership taken by the container ImFontAtlas (will delete memory itself). - int FontNo; // 0 // Index of font within TTF/OTF file - float SizePixels; // // Size in pixels for rasterizer (more or less maps to the resulting font height). - int OversampleH; // 3 // Rasterize at higher quality for sub-pixel positioning. Note the difference between 2 and 3 is minimal so you can reduce this to 2 to save memory. Read https://github.com/nothings/stb/blob/master/tests/oversample/README.md for details. - int OversampleV; // 1 // Rasterize at higher quality for sub-pixel positioning. This is not really useful as we don't use sub-pixel positions on the Y axis. - bool PixelSnapH; // false // Align every glyph to pixel boundary. Useful e.g. if you are merging a non-pixel aligned font with the default font. If enabled, you can set OversampleH/V to 1. - ImVec2 GlyphExtraSpacing; // 0, 0 // Extra spacing (in pixels) between glyphs. Only X axis is supported for now. - ImVec2 GlyphOffset; // 0, 0 // Offset all glyphs from this font input. - const ImWchar* GlyphRanges; // NULL // Pointer to a user-provided list of Unicode range (2 value per range, values are inclusive, zero-terminated list). THE ARRAY DATA NEEDS TO PERSIST AS LONG AS THE FONT IS ALIVE. - float GlyphMinAdvanceX; // 0 // Minimum AdvanceX for glyphs, set Min to align font icons, set both Min/Max to enforce mono-space font - float GlyphMaxAdvanceX; // FLT_MAX // Maximum AdvanceX for glyphs - bool MergeMode; // false // Merge into previous ImFont, so you can combine multiple inputs font into one ImFont (e.g. ASCII font + icons + Japanese glyphs). You may want to use GlyphOffset.y when merge font of different heights. - unsigned int FontBuilderFlags; // 0 // Settings for custom font builder. THIS IS BUILDER IMPLEMENTATION DEPENDENT. Leave as zero if unsure. - float RasterizerMultiply; // 1.0f // Brighten (>1.0f) or darken (<1.0f) font output. Brightening small fonts may be a good workaround to make them more readable. - ImWchar EllipsisChar; // -1 // Explicitly specify unicode codepoint of ellipsis character. When fonts are being merged first specified ellipsis will be used. - - // [Internal] - char Name[40]; // Name (strictly to ease debugging) - ImFont* DstFont; - - IMGUI_API ImFontConfig(); -}; - -// Hold rendering data for one glyph. -// (Note: some language parsers may fail to convert the 31+1 bitfield members, in this case maybe drop store a single u32 or we can rework this) -struct ImFontGlyph -{ - unsigned int Colored : 1; // Flag to indicate glyph is colored and should generally ignore tinting (make it usable with no shift on little-endian as this is used in loops) - unsigned int Visible : 1; // Flag to indicate glyph has no visible pixels (e.g. space). Allow early out when rendering. - unsigned int Codepoint : 30; // 0x0000..0x10FFFF - float AdvanceX; // Distance to next character (= data from font + ImFontConfig::GlyphExtraSpacing.x baked in) - float X0, Y0, X1, Y1; // Glyph corners - float U0, V0, U1, V1; // Texture coordinates -}; - -// Helper to build glyph ranges from text/string data. Feed your application strings/characters to it then call BuildRanges(). -// This is essentially a tightly packed of vector of 64k booleans = 8KB storage. -struct ImFontGlyphRangesBuilder -{ - ImVector UsedChars; // Store 1-bit per Unicode code point (0=unused, 1=used) - - ImFontGlyphRangesBuilder() { Clear(); } - inline void Clear() { int size_in_bytes = (IM_UNICODE_CODEPOINT_MAX + 1) / 8; UsedChars.resize(size_in_bytes / (int)sizeof(ImU32)); memset(UsedChars.Data, 0, (size_t)size_in_bytes); } - inline bool GetBit(size_t n) const { int off = (int)(n >> 5); ImU32 mask = 1u << (n & 31); return (UsedChars[off] & mask) != 0; } // Get bit n in the array - inline void SetBit(size_t n) { int off = (int)(n >> 5); ImU32 mask = 1u << (n & 31); UsedChars[off] |= mask; } // Set bit n in the array - inline void AddChar(ImWchar c) { SetBit(c); } // Add character - IMGUI_API void AddText(const char* text, const char* text_end = NULL); // Add string (each character of the UTF-8 string are added) - IMGUI_API void AddRanges(const ImWchar* ranges); // Add ranges, e.g. builder.AddRanges(ImFontAtlas::GetGlyphRangesDefault()) to force add all of ASCII/Latin+Ext - IMGUI_API void BuildRanges(ImVector* out_ranges); // Output new ranges -}; - -// See ImFontAtlas::AddCustomRectXXX functions. -struct ImFontAtlasCustomRect -{ - unsigned short Width, Height; // Input // Desired rectangle dimension - unsigned short X, Y; // Output // Packed position in Atlas - unsigned int GlyphID; // Input // For custom font glyphs only (ID < 0x110000) - float GlyphAdvanceX; // Input // For custom font glyphs only: glyph xadvance - ImVec2 GlyphOffset; // Input // For custom font glyphs only: glyph display offset - ImFont* Font; // Input // For custom font glyphs only: target font - ImFontAtlasCustomRect() { Width = Height = 0; X = Y = 0xFFFF; GlyphID = 0; GlyphAdvanceX = 0.0f; GlyphOffset = ImVec2(0, 0); Font = NULL; } - bool IsPacked() const { return X != 0xFFFF; } -}; - -// Flags for ImFontAtlas build -enum ImFontAtlasFlags_ -{ - ImFontAtlasFlags_None = 0, - ImFontAtlasFlags_NoPowerOfTwoHeight = 1 << 0, // Don't round the height to next power of two - ImFontAtlasFlags_NoMouseCursors = 1 << 1, // Don't build software mouse cursors into the atlas (save a little texture memory) - ImFontAtlasFlags_NoBakedLines = 1 << 2 // Don't build thick line textures into the atlas (save a little texture memory). The AntiAliasedLinesUseTex features uses them, otherwise they will be rendered using polygons (more expensive for CPU/GPU). -}; - -// Load and rasterize multiple TTF/OTF fonts into a same texture. The font atlas will build a single texture holding: -// - One or more fonts. -// - Custom graphics data needed to render the shapes needed by Dear ImGui. -// - Mouse cursor shapes for software cursor rendering (unless setting 'Flags |= ImFontAtlasFlags_NoMouseCursors' in the font atlas). -// It is the user-code responsibility to setup/build the atlas, then upload the pixel data into a texture accessible by your graphics api. -// - Optionally, call any of the AddFont*** functions. If you don't call any, the default font embedded in the code will be loaded for you. -// - Call GetTexDataAsAlpha8() or GetTexDataAsRGBA32() to build and retrieve pixels data. -// - Upload the pixels data into a texture within your graphics system (see imgui_impl_xxxx.cpp examples) -// - Call SetTexID(my_tex_id); and pass the pointer/identifier to your texture in a format natural to your graphics API. -// This value will be passed back to you during rendering to identify the texture. Read FAQ entry about ImTextureID for more details. -// Common pitfalls: -// - If you pass a 'glyph_ranges' array to AddFont*** functions, you need to make sure that your array persist up until the -// atlas is build (when calling GetTexData*** or Build()). We only copy the pointer, not the data. -// - Important: By default, AddFontFromMemoryTTF() takes ownership of the data. Even though we are not writing to it, we will free the pointer on destruction. -// You can set font_cfg->FontDataOwnedByAtlas=false to keep ownership of your data and it won't be freed, -// - Even though many functions are suffixed with "TTF", OTF data is supported just as well. -// - This is an old API and it is currently awkward for those and and various other reasons! We will address them in the future! -struct ImFontAtlas -{ - IMGUI_API ImFontAtlas(); - IMGUI_API ~ImFontAtlas(); - IMGUI_API ImFont* AddFont(const ImFontConfig* font_cfg); - IMGUI_API ImFont* AddFontDefault(const ImFontConfig* font_cfg = NULL); - IMGUI_API ImFont* AddFontFromFileTTF(const char* filename, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); - IMGUI_API ImFont* AddFontFromMemoryTTF(void* font_data, int font_size, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); // Note: Transfer ownership of 'ttf_data' to ImFontAtlas! Will be deleted after destruction of the atlas. Set font_cfg->FontDataOwnedByAtlas=false to keep ownership of your data and it won't be freed. - IMGUI_API ImFont* AddFontFromMemoryCompressedTTF(const void* compressed_font_data, int compressed_font_size, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); // 'compressed_font_data' still owned by caller. Compress with binary_to_compressed_c.cpp. - IMGUI_API ImFont* AddFontFromMemoryCompressedBase85TTF(const char* compressed_font_data_base85, float size_pixels, const ImFontConfig* font_cfg = NULL, const ImWchar* glyph_ranges = NULL); // 'compressed_font_data_base85' still owned by caller. Compress with binary_to_compressed_c.cpp with -base85 parameter. - IMGUI_API void ClearInputData(); // Clear input data (all ImFontConfig structures including sizes, TTF data, glyph ranges, etc.) = all the data used to build the texture and fonts. - IMGUI_API void ClearTexData(); // Clear output texture data (CPU side). Saves RAM once the texture has been copied to graphics memory. - IMGUI_API void ClearFonts(); // Clear output font data (glyphs storage, UV coordinates). - IMGUI_API void Clear(); // Clear all input and output. - - // Build atlas, retrieve pixel data. - // User is in charge of copying the pixels into graphics memory (e.g. create a texture with your engine). Then store your texture handle with SetTexID(). - // The pitch is always = Width * BytesPerPixels (1 or 4) - // Building in RGBA32 format is provided for convenience and compatibility, but note that unless you manually manipulate or copy color data into - // the texture (e.g. when using the AddCustomRect*** api), then the RGB pixels emitted will always be white (~75% of memory/bandwidth waste. - IMGUI_API bool Build(); // Build pixels data. This is called automatically for you by the GetTexData*** functions. - IMGUI_API void GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 1 byte per-pixel - IMGUI_API void GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 4 bytes-per-pixel - bool IsBuilt() const { return Fonts.Size > 0 && TexReady; } // Bit ambiguous: used to detect when user didn't built texture but effectively we should check TexID != 0 except that would be backend dependent... - void SetTexID(ImTextureID id) { TexID = id; } - - //------------------------------------------- - // Glyph Ranges - //------------------------------------------- - - // Helpers to retrieve list of common Unicode ranges (2 value per range, values are inclusive, zero-terminated list) - // NB: Make sure that your string are UTF-8 and NOT in your local code page. In C++11, you can create UTF-8 string literal using the u8"Hello world" syntax. See FAQ for details. - // NB: Consider using ImFontGlyphRangesBuilder to build glyph ranges from textual data. - IMGUI_API const ImWchar* GetGlyphRangesDefault(); // Basic Latin, Extended Latin - IMGUI_API const ImWchar* GetGlyphRangesKorean(); // Default + Korean characters - IMGUI_API const ImWchar* GetGlyphRangesJapanese(); // Default + Hiragana, Katakana, Half-Width, Selection of 2999 Ideographs - IMGUI_API const ImWchar* GetGlyphRangesChineseFull(); // Default + Half-Width + Japanese Hiragana/Katakana + full set of about 21000 CJK Unified Ideographs - IMGUI_API const ImWchar* GetGlyphRangesChineseSimplifiedCommon();// Default + Half-Width + Japanese Hiragana/Katakana + set of 2500 CJK Unified Ideographs for common simplified Chinese - IMGUI_API const ImWchar* GetGlyphRangesCyrillic(); // Default + about 400 Cyrillic characters - IMGUI_API const ImWchar* GetGlyphRangesThai(); // Default + Thai characters - IMGUI_API const ImWchar* GetGlyphRangesVietnamese(); // Default + Vietnamese characters - - //------------------------------------------- - // [BETA] Custom Rectangles/Glyphs API - //------------------------------------------- - - // You can request arbitrary rectangles to be packed into the atlas, for your own purposes. - // - After calling Build(), you can query the rectangle position and render your pixels. - // - If you render colored output, set 'atlas->TexPixelsUseColors = true' as this may help some backends decide of prefered texture format. - // - You can also request your rectangles to be mapped as font glyph (given a font + Unicode point), - // so you can render e.g. custom colorful icons and use them as regular glyphs. - // - Read docs/FONTS.md for more details about using colorful icons. - // - Note: this API may be redesigned later in order to support multi-monitor varying DPI settings. - IMGUI_API int AddCustomRectRegular(int width, int height); - IMGUI_API int AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int height, float advance_x, const ImVec2& offset = ImVec2(0, 0)); - ImFontAtlasCustomRect* GetCustomRectByIndex(int index) { IM_ASSERT(index >= 0); return &CustomRects[index]; } - - // [Internal] - IMGUI_API void CalcCustomRectUV(const ImFontAtlasCustomRect* rect, ImVec2* out_uv_min, ImVec2* out_uv_max) const; - IMGUI_API bool GetMouseCursorTexData(ImGuiMouseCursor cursor, ImVec2* out_offset, ImVec2* out_size, ImVec2 out_uv_border[2], ImVec2 out_uv_fill[2]); - - //------------------------------------------- - // Members - //------------------------------------------- - - ImFontAtlasFlags Flags; // Build flags (see ImFontAtlasFlags_) - ImTextureID TexID; // User data to refer to the texture once it has been uploaded to user's graphic systems. It is passed back to you during rendering via the ImDrawCmd structure. - int TexDesiredWidth; // Texture width desired by user before Build(). Must be a power-of-two. If have many glyphs your graphics API have texture size restrictions you may want to increase texture width to decrease height. - int TexGlyphPadding; // Padding between glyphs within texture in pixels. Defaults to 1. If your rendering method doesn't rely on bilinear filtering you may set this to 0. - bool Locked; // Marked as Locked by ImGui::NewFrame() so attempt to modify the atlas will assert. - - // [Internal] - // NB: Access texture data via GetTexData*() calls! Which will setup a default font for you. - bool TexReady; // Set when texture was built matching current font input - bool TexPixelsUseColors; // Tell whether our texture data is known to use colors (rather than just alpha channel), in order to help backend select a format. - unsigned char* TexPixelsAlpha8; // 1 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight - unsigned int* TexPixelsRGBA32; // 4 component per pixel, each component is unsigned 8-bit. Total size = TexWidth * TexHeight * 4 - int TexWidth; // Texture width calculated during Build(). - int TexHeight; // Texture height calculated during Build(). - ImVec2 TexUvScale; // = (1.0f/TexWidth, 1.0f/TexHeight) - ImVec2 TexUvWhitePixel; // Texture coordinates to a white pixel - ImVector Fonts; // Hold all the fonts returned by AddFont*. Fonts[0] is the default font upon calling ImGui::NewFrame(), use ImGui::PushFont()/PopFont() to change the current font. - ImVector CustomRects; // Rectangles for packing custom texture data into the atlas. - ImVector ConfigData; // Configuration data - ImVec4 TexUvLines[IM_DRAWLIST_TEX_LINES_WIDTH_MAX + 1]; // UVs for baked anti-aliased lines - - // [Internal] Font builder - const ImFontBuilderIO* FontBuilderIO; // Opaque interface to a font builder (default to stb_truetype, can be changed to use FreeType by defining IMGUI_ENABLE_FREETYPE). - unsigned int FontBuilderFlags; // Shared flags (for all fonts) for custom font builder. THIS IS BUILD IMPLEMENTATION DEPENDENT. Per-font override is also available in ImFontConfig. - - // [Internal] Packing data - int PackIdMouseCursors; // Custom texture rectangle ID for white pixel and mouse cursors - int PackIdLines; // Custom texture rectangle ID for baked anti-aliased lines - -#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS - typedef ImFontAtlasCustomRect CustomRect; // OBSOLETED in 1.72+ - //typedef ImFontGlyphRangesBuilder GlyphRangesBuilder; // OBSOLETED in 1.67+ -#endif -}; - -// Font runtime data and rendering -// ImFontAtlas automatically loads a default embedded font for you when you call GetTexDataAsAlpha8() or GetTexDataAsRGBA32(). -struct ImFont -{ - // Members: Hot ~20/24 bytes (for CalcTextSize) - ImVector IndexAdvanceX; // 12-16 // out // // Sparse. Glyphs->AdvanceX in a directly indexable way (cache-friendly for CalcTextSize functions which only this this info, and are often bottleneck in large UI). - float FallbackAdvanceX; // 4 // out // = FallbackGlyph->AdvanceX - float FontSize; // 4 // in // // Height of characters/line, set during loading (don't change after loading) - - // Members: Hot ~28/40 bytes (for CalcTextSize + render loop) - ImVector IndexLookup; // 12-16 // out // // Sparse. Index glyphs by Unicode code-point. - ImVector Glyphs; // 12-16 // out // // All glyphs. - const ImFontGlyph* FallbackGlyph; // 4-8 // out // = FindGlyph(FontFallbackChar) - - // Members: Cold ~32/40 bytes - ImFontAtlas* ContainerAtlas; // 4-8 // out // // What we has been loaded into - const ImFontConfig* ConfigData; // 4-8 // in // // Pointer within ContainerAtlas->ConfigData - short ConfigDataCount; // 2 // in // ~ 1 // Number of ImFontConfig involved in creating this font. Bigger than 1 when merging multiple font sources into one ImFont. - ImWchar FallbackChar; // 2 // out // = FFFD/'?' // Character used if a glyph isn't found. - ImWchar EllipsisChar; // 2 // out // = '...' // Character used for ellipsis rendering. - ImWchar DotChar; // 2 // out // = '.' // Character used for ellipsis rendering (if a single '...' character isn't found) - bool DirtyLookupTables; // 1 // out // - float Scale; // 4 // in // = 1.f // Base font scale, multiplied by the per-window font scale which you can adjust with SetWindowFontScale() - float Ascent, Descent; // 4+4 // out // // Ascent: distance from top to bottom of e.g. 'A' [0..FontSize] - int MetricsTotalSurface;// 4 // out // // Total surface in pixels to get an idea of the font rasterization/texture cost (not exact, we approximate the cost of padding between glyphs) - ImU8 Used4kPagesMap[(IM_UNICODE_CODEPOINT_MAX+1)/4096/8]; // 2 bytes if ImWchar=ImWchar16, 34 bytes if ImWchar==ImWchar32. Store 1-bit for each block of 4K codepoints that has one active glyph. This is mainly used to facilitate iterations across all used codepoints. - - // Methods - IMGUI_API ImFont(); - IMGUI_API ~ImFont(); - IMGUI_API const ImFontGlyph*FindGlyph(ImWchar c) const; - IMGUI_API const ImFontGlyph*FindGlyphNoFallback(ImWchar c) const; - float GetCharAdvance(ImWchar c) const { return ((int)c < IndexAdvanceX.Size) ? IndexAdvanceX[(int)c] : FallbackAdvanceX; } - bool IsLoaded() const { return ContainerAtlas != NULL; } - const char* GetDebugName() const { return ConfigData ? ConfigData->Name : ""; } - - // 'max_width' stops rendering after a certain width (could be turned into a 2d size). FLT_MAX to disable. - // 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable. - IMGUI_API ImVec2 CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end = NULL, const char** remaining = NULL) const; // utf8 - IMGUI_API const char* CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) const; - IMGUI_API void RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, ImWchar c) const; - IMGUI_API void RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width = 0.0f, bool cpu_fine_clip = false) const; - - // [Internal] Don't use! - IMGUI_API void BuildLookupTable(); - IMGUI_API void ClearOutputData(); - IMGUI_API void GrowIndex(int new_size); - IMGUI_API void AddGlyph(const ImFontConfig* src_cfg, ImWchar c, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x); - IMGUI_API void AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst = true); // Makes 'dst' character/glyph points to 'src' character/glyph. Currently needs to be called AFTER fonts have been built. - IMGUI_API void SetGlyphVisible(ImWchar c, bool visible); - IMGUI_API bool IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last); -}; - -//----------------------------------------------------------------------------- -// [SECTION] Viewports -//----------------------------------------------------------------------------- - -// Flags stored in ImGuiViewport::Flags, giving indications to the platform backends. -enum ImGuiViewportFlags_ -{ - ImGuiViewportFlags_None = 0, - ImGuiViewportFlags_IsPlatformWindow = 1 << 0, // Represent a Platform Window - ImGuiViewportFlags_IsPlatformMonitor = 1 << 1, // Represent a Platform Monitor (unused yet) - ImGuiViewportFlags_OwnedByApp = 1 << 2 // Platform Window: is created/managed by the application (rather than a dear imgui backend) -}; - -// - Currently represents the Platform Window created by the application which is hosting our Dear ImGui windows. -// - In 'docking' branch with multi-viewport enabled, we extend this concept to have multiple active viewports. -// - In the future we will extend this concept further to also represent Platform Monitor and support a "no main platform window" operation mode. -// - About Main Area vs Work Area: -// - Main Area = entire viewport. -// - Work Area = entire viewport minus sections used by main menu bars (for platform windows), or by task bar (for platform monitor). -// - Windows are generally trying to stay within the Work Area of their host viewport. -struct ImGuiViewport -{ - ImGuiViewportFlags Flags; // See ImGuiViewportFlags_ - ImVec2 Pos; // Main Area: Position of the viewport (Dear ImGui coordinates are the same as OS desktop/native coordinates) - ImVec2 Size; // Main Area: Size of the viewport. - ImVec2 WorkPos; // Work Area: Position of the viewport minus task bars, menus bars, status bars (>= Pos) - ImVec2 WorkSize; // Work Area: Size of the viewport minus task bars, menu bars, status bars (<= Size) - - ImGuiViewport() { memset(this, 0, sizeof(*this)); } - - // Helpers - ImVec2 GetCenter() const { return ImVec2(Pos.x + Size.x * 0.5f, Pos.y + Size.y * 0.5f); } - ImVec2 GetWorkCenter() const { return ImVec2(WorkPos.x + WorkSize.x * 0.5f, WorkPos.y + WorkSize.y * 0.5f); } -}; - -//----------------------------------------------------------------------------- -// [SECTION] Obsolete functions and types -// (Will be removed! Read 'API BREAKING CHANGES' section in imgui.cpp for details) -// Please keep your copy of dear imgui up to date! Occasionally set '#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS' in imconfig.h to stay ahead. -//----------------------------------------------------------------------------- - -#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS -namespace ImGui -{ - // OBSOLETED in 1.85 (from August 2021) - static inline float GetWindowContentRegionWidth() { return GetWindowContentRegionMax().x - GetWindowContentRegionMin().x; } - // OBSOLETED in 1.81 (from February 2021) - IMGUI_API bool ListBoxHeader(const char* label, int items_count, int height_in_items = -1); // Helper to calculate size from items_count and height_in_items - static inline bool ListBoxHeader(const char* label, const ImVec2& size = ImVec2(0, 0)) { return BeginListBox(label, size); } - static inline void ListBoxFooter() { EndListBox(); } - // OBSOLETED in 1.79 (from August 2020) - static inline void OpenPopupContextItem(const char* str_id = NULL, ImGuiMouseButton mb = 1) { OpenPopupOnItemClick(str_id, mb); } // Bool return value removed. Use IsWindowAppearing() in BeginPopup() instead. Renamed in 1.77, renamed back in 1.79. Sorry! - // OBSOLETED in 1.78 (from June 2020) - // Old drag/sliders functions that took a 'float power = 1.0' argument instead of flags. - // For shared code, you can version check at compile-time with `#if IMGUI_VERSION_NUM >= 17704`. - IMGUI_API bool DragScalar(const char* label, ImGuiDataType data_type, void* p_data, float v_speed, const void* p_min, const void* p_max, const char* format, float power); - IMGUI_API bool DragScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, float v_speed, const void* p_min, const void* p_max, const char* format, float power); - static inline bool DragFloat(const char* label, float* v, float v_speed, float v_min, float v_max, const char* format, float power) { return DragScalar(label, ImGuiDataType_Float, v, v_speed, &v_min, &v_max, format, power); } - static inline bool DragFloat2(const char* label, float v[2], float v_speed, float v_min, float v_max, const char* format, float power) { return DragScalarN(label, ImGuiDataType_Float, v, 2, v_speed, &v_min, &v_max, format, power); } - static inline bool DragFloat3(const char* label, float v[3], float v_speed, float v_min, float v_max, const char* format, float power) { return DragScalarN(label, ImGuiDataType_Float, v, 3, v_speed, &v_min, &v_max, format, power); } - static inline bool DragFloat4(const char* label, float v[4], float v_speed, float v_min, float v_max, const char* format, float power) { return DragScalarN(label, ImGuiDataType_Float, v, 4, v_speed, &v_min, &v_max, format, power); } - IMGUI_API bool SliderScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format, float power); - IMGUI_API bool SliderScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, const void* p_min, const void* p_max, const char* format, float power); - static inline bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* format, float power) { return SliderScalar(label, ImGuiDataType_Float, v, &v_min, &v_max, format, power); } - static inline bool SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* format, float power) { return SliderScalarN(label, ImGuiDataType_Float, v, 2, &v_min, &v_max, format, power); } - static inline bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* format, float power) { return SliderScalarN(label, ImGuiDataType_Float, v, 3, &v_min, &v_max, format, power); } - static inline bool SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* format, float power) { return SliderScalarN(label, ImGuiDataType_Float, v, 4, &v_min, &v_max, format, power); } - // OBSOLETED in 1.77 (from June 2020) - static inline bool BeginPopupContextWindow(const char* str_id, ImGuiMouseButton mb, bool over_items) { return BeginPopupContextWindow(str_id, mb | (over_items ? 0 : ImGuiPopupFlags_NoOpenOverItems)); } - // OBSOLETED in 1.72 (from April 2019) - static inline void TreeAdvanceToLabelPos() { SetCursorPosX(GetCursorPosX() + GetTreeNodeToLabelSpacing()); } - // OBSOLETED in 1.71 (from June 2019) - static inline void SetNextTreeNodeOpen(bool open, ImGuiCond cond = 0) { SetNextItemOpen(open, cond); } - // OBSOLETED in 1.70 (from May 2019) - static inline float GetContentRegionAvailWidth() { return GetContentRegionAvail().x; } - - // Some of the older obsolete names along with their replacement (commented out so they are not reported in IDE) - //static inline ImDrawList* GetOverlayDrawList() { return GetForegroundDrawList(); } // OBSOLETED in 1.69 (from Mar 2019) - //static inline void SetScrollHere(float ratio = 0.5f) { SetScrollHereY(ratio); } // OBSOLETED in 1.66 (from Nov 2018) - //static inline bool IsItemDeactivatedAfterChange() { return IsItemDeactivatedAfterEdit(); } // OBSOLETED in 1.63 (from Aug 2018) - //static inline bool IsAnyWindowFocused() { return IsWindowFocused(ImGuiFocusedFlags_AnyWindow); } // OBSOLETED in 1.60 (from Apr 2018) - //static inline bool IsAnyWindowHovered() { return IsWindowHovered(ImGuiHoveredFlags_AnyWindow); } // OBSOLETED in 1.60 (between Dec 2017 and Apr 2018) - //static inline void ShowTestWindow() { return ShowDemoWindow(); } // OBSOLETED in 1.53 (between Oct 2017 and Dec 2017) - //static inline bool IsRootWindowFocused() { return IsWindowFocused(ImGuiFocusedFlags_RootWindow); } // OBSOLETED in 1.53 (between Oct 2017 and Dec 2017) - //static inline bool IsRootWindowOrAnyChildFocused() { return IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows); } // OBSOLETED in 1.53 (between Oct 2017 and Dec 2017) - //static inline void SetNextWindowContentWidth(float w) { SetNextWindowContentSize(ImVec2(w, 0.0f)); } // OBSOLETED in 1.53 (between Oct 2017 and Dec 2017) - //static inline float GetItemsLineHeightWithSpacing() { return GetFrameHeightWithSpacing(); } // OBSOLETED in 1.53 (between Oct 2017 and Dec 2017) -} - -// OBSOLETED in 1.82 (from Mars 2021): flags for AddRect(), AddRectFilled(), AddImageRounded(), PathRect() -typedef ImDrawFlags ImDrawCornerFlags; -enum ImDrawCornerFlags_ -{ - ImDrawCornerFlags_None = ImDrawFlags_RoundCornersNone, // Was == 0 prior to 1.82, this is now == ImDrawFlags_RoundCornersNone which is != 0 and not implicit - ImDrawCornerFlags_TopLeft = ImDrawFlags_RoundCornersTopLeft, // Was == 0x01 (1 << 0) prior to 1.82. Order matches ImDrawFlags_NoRoundCorner* flag (we exploit this internally). - ImDrawCornerFlags_TopRight = ImDrawFlags_RoundCornersTopRight, // Was == 0x02 (1 << 1) prior to 1.82. - ImDrawCornerFlags_BotLeft = ImDrawFlags_RoundCornersBottomLeft, // Was == 0x04 (1 << 2) prior to 1.82. - ImDrawCornerFlags_BotRight = ImDrawFlags_RoundCornersBottomRight, // Was == 0x08 (1 << 3) prior to 1.82. - ImDrawCornerFlags_All = ImDrawFlags_RoundCornersAll, // Was == 0x0F prior to 1.82 - ImDrawCornerFlags_Top = ImDrawCornerFlags_TopLeft | ImDrawCornerFlags_TopRight, - ImDrawCornerFlags_Bot = ImDrawCornerFlags_BotLeft | ImDrawCornerFlags_BotRight, - ImDrawCornerFlags_Left = ImDrawCornerFlags_TopLeft | ImDrawCornerFlags_BotLeft, - ImDrawCornerFlags_Right = ImDrawCornerFlags_TopRight | ImDrawCornerFlags_BotRight -}; - -#endif // #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS - -//----------------------------------------------------------------------------- - -#if defined(__clang__) -#pragma clang diagnostic pop -#elif defined(__GNUC__) -#pragma GCC diagnostic pop -#endif - -#ifdef _MSC_VER -#pragma warning (pop) -#endif - -// Include imgui_user.h at the end of imgui.h (convenient for user to only explicitly include vanilla imgui.h) -#ifdef IMGUI_INCLUDE_IMGUI_USER_H -#include "imgui_user.h" -#endif - -#endif // #ifndef IMGUI_DISABLE diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imgui_demo.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imgui_demo.cpp deleted file mode 100644 index d4bac48..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imgui_demo.cpp +++ /dev/null @@ -1,7675 +0,0 @@ -// dear imgui, v1.85 -// (demo code) - -// Help: -// - Read FAQ at http://dearimgui.org/faq -// - Newcomers, read 'Programmer guide' in imgui.cpp for notes on how to setup Dear ImGui in your codebase. -// - Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp. All applications in examples/ are doing that. -// Read imgui.cpp for more details, documentation and comments. -// Get the latest version at https://github.com/ocornut/imgui - -// Message to the person tempted to delete this file when integrating Dear ImGui into their codebase: -// Do NOT remove this file from your project! Think again! It is the most useful reference code that you and other -// coders will want to refer to and call. Have the ImGui::ShowDemoWindow() function wired in an always-available -// debug menu of your game/app! Removing this file from your project is hindering access to documentation for everyone -// in your team, likely leading you to poorer usage of the library. -// Everything in this file will be stripped out by the linker if you don't call ImGui::ShowDemoWindow(). -// If you want to link core Dear ImGui in your shipped builds but want a thorough guarantee that the demo will not be -// linked, you can setup your imconfig.h with #define IMGUI_DISABLE_DEMO_WINDOWS and those functions will be empty. -// In another situation, whenever you have Dear ImGui available you probably want this to be available for reference. -// Thank you, -// -Your beloved friend, imgui_demo.cpp (which you won't delete) - -// Message to beginner C/C++ programmers about the meaning of the 'static' keyword: -// In this demo code, we frequently use 'static' variables inside functions. A static variable persists across calls, -// so it is essentially like a global variable but declared inside the scope of the function. We do this as a way to -// gather code and data in the same place, to make the demo source code faster to read, faster to write, and smaller -// in size. It also happens to be a convenient way of storing simple UI related information as long as your function -// doesn't need to be reentrant or used in multiple threads. This might be a pattern you will want to use in your code, -// but most of the real data you would be editing is likely going to be stored outside your functions. - -// The Demo code in this file is designed to be easy to copy-and-paste into your application! -// Because of this: -// - We never omit the ImGui:: prefix when calling functions, even though most code here is in the same namespace. -// - We try to declare static variables in the local scope, as close as possible to the code using them. -// - We never use any of the helpers/facilities used internally by Dear ImGui, unless available in the public API. -// - We never use maths operators on ImVec2/ImVec4. For our other sources files we use them, and they are provided -// by imgui_internal.h using the IMGUI_DEFINE_MATH_OPERATORS define. For your own sources file they are optional -// and require you either enable those, either provide your own via IM_VEC2_CLASS_EXTRA in imconfig.h. -// Because we can't assume anything about your support of maths operators, we cannot use them in imgui_demo.cpp. - -// Navigating this file: -// - In Visual Studio IDE: CTRL+comma ("Edit.NavigateTo") can follow symbols in comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot. -// - With Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols in comments. - -/* - -Index of this file: - -// [SECTION] Forward Declarations, Helpers -// [SECTION] Demo Window / ShowDemoWindow() -// - sub section: ShowDemoWindowWidgets() -// - sub section: ShowDemoWindowLayout() -// - sub section: ShowDemoWindowPopups() -// - sub section: ShowDemoWindowTables() -// - sub section: ShowDemoWindowMisc() -// [SECTION] About Window / ShowAboutWindow() -// [SECTION] Style Editor / ShowStyleEditor() -// [SECTION] Example App: Main Menu Bar / ShowExampleAppMainMenuBar() -// [SECTION] Example App: Debug Console / ShowExampleAppConsole() -// [SECTION] Example App: Debug Log / ShowExampleAppLog() -// [SECTION] Example App: Simple Layout / ShowExampleAppLayout() -// [SECTION] Example App: Property Editor / ShowExampleAppPropertyEditor() -// [SECTION] Example App: Long Text / ShowExampleAppLongText() -// [SECTION] Example App: Auto Resize / ShowExampleAppAutoResize() -// [SECTION] Example App: Constrained Resize / ShowExampleAppConstrainedResize() -// [SECTION] Example App: Simple overlay / ShowExampleAppSimpleOverlay() -// [SECTION] Example App: Fullscreen window / ShowExampleAppFullscreen() -// [SECTION] Example App: Manipulating window titles / ShowExampleAppWindowTitles() -// [SECTION] Example App: Custom Rendering using ImDrawList API / ShowExampleAppCustomRendering() -// [SECTION] Example App: Documents Handling / ShowExampleAppDocuments() - -*/ - -#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) -#define _CRT_SECURE_NO_WARNINGS -#endif - -#include "imgui.h" -#ifndef IMGUI_DISABLE - -// System includes -#include // toupper -#include // INT_MIN, INT_MAX -#include // sqrtf, powf, cosf, sinf, floorf, ceilf -#include // vsnprintf, sscanf, printf -#include // NULL, malloc, free, atoi -#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier -#include // intptr_t -#else -#include // intptr_t -#endif - -// Visual Studio warnings -#ifdef _MSC_VER -#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen -#pragma warning (disable: 26451) // [Static Analyzer] Arithmetic overflow : Using operator 'xxx' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator 'xxx' to avoid overflow(io.2). -#endif - -// Clang/GCC warnings with -Weverything -#if defined(__clang__) -#if __has_warning("-Wunknown-warning-option") -#pragma clang diagnostic ignored "-Wunknown-warning-option" // warning: unknown warning group 'xxx' // not all warnings are known by all Clang versions and they tend to be rename-happy.. so ignoring warnings triggers new warnings on some configuration. Great! -#endif -#pragma clang diagnostic ignored "-Wunknown-pragmas" // warning: unknown warning group 'xxx' -#pragma clang diagnostic ignored "-Wold-style-cast" // warning: use of old-style cast // yes, they are more terse. -#pragma clang diagnostic ignored "-Wdeprecated-declarations" // warning: 'xx' is deprecated: The POSIX name for this.. // for strdup used in demo code (so user can copy & paste the code) -#pragma clang diagnostic ignored "-Wint-to-void-pointer-cast" // warning: cast to 'void *' from smaller integer type -#pragma clang diagnostic ignored "-Wformat-security" // warning: format string is not a string literal -#pragma clang diagnostic ignored "-Wexit-time-destructors" // warning: declaration requires an exit-time destructor // exit-time destruction order is undefined. if MemFree() leads to users code that has been disabled before exit it might cause problems. ImGui coding style welcomes static/globals. -#pragma clang diagnostic ignored "-Wunused-macros" // warning: macro is not used // we define snprintf/vsnprintf on Windows so they are available, but not always used. -#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" // warning: zero as null pointer constant // some standard header variations use #define NULL 0 -#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double. -#pragma clang diagnostic ignored "-Wreserved-id-macro" // warning: macro name is a reserved identifier -#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision -#elif defined(__GNUC__) -#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind -#pragma GCC diagnostic ignored "-Wint-to-pointer-cast" // warning: cast to pointer from integer of different size -#pragma GCC diagnostic ignored "-Wformat-security" // warning: format string is not a string literal (potentially insecure) -#pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function -#pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value -#pragma GCC diagnostic ignored "-Wmisleading-indentation" // [__GNUC__ >= 6] warning: this 'if' clause does not guard this statement // GCC 6.0+ only. See #883 on GitHub. -#endif - -// Play it nice with Windows users (Update: May 2018, Notepad now supports Unix-style carriage returns!) -#ifdef _WIN32 -#define IM_NEWLINE "\r\n" -#else -#define IM_NEWLINE "\n" -#endif - -// Helpers -#if defined(_MSC_VER) && !defined(snprintf) -#define snprintf _snprintf -#endif -#if defined(_MSC_VER) && !defined(vsnprintf) -#define vsnprintf _vsnprintf -#endif - -// Format specifiers, printing 64-bit hasn't been decently standardized... -// In a real application you should be using PRId64 and PRIu64 from (non-windows) and on Windows define them yourself. -#ifdef _MSC_VER -#define IM_PRId64 "I64d" -#define IM_PRIu64 "I64u" -#else -#define IM_PRId64 "lld" -#define IM_PRIu64 "llu" -#endif - -// Helpers macros -// We normally try to not use many helpers in imgui_demo.cpp in order to make code easier to copy and paste, -// but making an exception here as those are largely simplifying code... -// In other imgui sources we can use nicer internal functions from imgui_internal.h (ImMin/ImMax) but not in the demo. -#define IM_MIN(A, B) (((A) < (B)) ? (A) : (B)) -#define IM_MAX(A, B) (((A) >= (B)) ? (A) : (B)) -#define IM_CLAMP(V, MN, MX) ((V) < (MN) ? (MN) : (V) > (MX) ? (MX) : (V)) - -// Enforce cdecl calling convention for functions called by the standard library, in case compilation settings changed the default to e.g. __vectorcall -#ifndef IMGUI_CDECL -#ifdef _MSC_VER -#define IMGUI_CDECL __cdecl -#else -#define IMGUI_CDECL -#endif -#endif - -//----------------------------------------------------------------------------- -// [SECTION] Forward Declarations, Helpers -//----------------------------------------------------------------------------- - -#if !defined(IMGUI_DISABLE_DEMO_WINDOWS) - -// Forward Declarations -static void ShowExampleAppDocuments(bool* p_open); -static void ShowExampleAppMainMenuBar(); -static void ShowExampleAppConsole(bool* p_open); -static void ShowExampleAppLog(bool* p_open); -static void ShowExampleAppLayout(bool* p_open); -static void ShowExampleAppPropertyEditor(bool* p_open); -static void ShowExampleAppLongText(bool* p_open); -static void ShowExampleAppAutoResize(bool* p_open); -static void ShowExampleAppConstrainedResize(bool* p_open); -static void ShowExampleAppSimpleOverlay(bool* p_open); -static void ShowExampleAppFullscreen(bool* p_open); -static void ShowExampleAppWindowTitles(bool* p_open); -static void ShowExampleAppCustomRendering(bool* p_open); -static void ShowExampleMenuFile(); - -// Helper to display a little (?) mark which shows a tooltip when hovered. -// In your own code you may want to display an actual icon if you are using a merged icon fonts (see docs/FONTS.md) -static void HelpMarker(const char* desc) -{ - ImGui::TextDisabled("(?)"); - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f); - ImGui::TextUnformatted(desc); - ImGui::PopTextWrapPos(); - ImGui::EndTooltip(); - } -} - -// Helper to display basic user controls. -void ImGui::ShowUserGuide() -{ - ImGuiIO& io = ImGui::GetIO(); - ImGui::BulletText("Double-click on title bar to collapse window."); - ImGui::BulletText( - "Click and drag on lower corner to resize window\n" - "(double-click to auto fit window to its contents)."); - ImGui::BulletText("CTRL+Click on a slider or drag box to input value as text."); - ImGui::BulletText("TAB/SHIFT+TAB to cycle through keyboard editable fields."); - if (io.FontAllowUserScaling) - ImGui::BulletText("CTRL+Mouse Wheel to zoom window contents."); - ImGui::BulletText("While inputing text:\n"); - ImGui::Indent(); - ImGui::BulletText("CTRL+Left/Right to word jump."); - ImGui::BulletText("CTRL+A or double-click to select all."); - ImGui::BulletText("CTRL+X/C/V to use clipboard cut/copy/paste."); - ImGui::BulletText("CTRL+Z,CTRL+Y to undo/redo."); - ImGui::BulletText("ESCAPE to revert."); - ImGui::BulletText("You can apply arithmetic operators +,*,/ on numerical values.\nUse +- to subtract."); - ImGui::Unindent(); - ImGui::BulletText("With keyboard navigation enabled:"); - ImGui::Indent(); - ImGui::BulletText("Arrow keys to navigate."); - ImGui::BulletText("Space to activate a widget."); - ImGui::BulletText("Return to input text into a widget."); - ImGui::BulletText("Escape to deactivate a widget, close popup, exit child window."); - ImGui::BulletText("Alt to jump to the menu layer of a window."); - ImGui::BulletText("CTRL+Tab to select a window."); - ImGui::Unindent(); -} - -//----------------------------------------------------------------------------- -// [SECTION] Demo Window / ShowDemoWindow() -//----------------------------------------------------------------------------- -// - ShowDemoWindowWidgets() -// - ShowDemoWindowLayout() -// - ShowDemoWindowPopups() -// - ShowDemoWindowTables() -// - ShowDemoWindowColumns() -// - ShowDemoWindowMisc() -//----------------------------------------------------------------------------- - -// We split the contents of the big ShowDemoWindow() function into smaller functions -// (because the link time of very large functions grow non-linearly) -static void ShowDemoWindowWidgets(); -static void ShowDemoWindowLayout(); -static void ShowDemoWindowPopups(); -static void ShowDemoWindowTables(); -static void ShowDemoWindowColumns(); -static void ShowDemoWindowMisc(); - -// Demonstrate most Dear ImGui features (this is big function!) -// You may execute this function to experiment with the UI and understand what it does. -// You may then search for keywords in the code when you are interested by a specific feature. -void ImGui::ShowDemoWindow(bool* p_open) -{ - // Exceptionally add an extra assert here for people confused about initial Dear ImGui setup - // Most ImGui functions would normally just crash if the context is missing. - IM_ASSERT(ImGui::GetCurrentContext() != NULL && "Missing dear imgui context. Refer to examples app!"); - - // Examples Apps (accessible from the "Examples" menu) - static bool show_app_main_menu_bar = false; - static bool show_app_documents = false; - - static bool show_app_console = false; - static bool show_app_log = false; - static bool show_app_layout = false; - static bool show_app_property_editor = false; - static bool show_app_long_text = false; - static bool show_app_auto_resize = false; - static bool show_app_constrained_resize = false; - static bool show_app_simple_overlay = false; - static bool show_app_fullscreen = false; - static bool show_app_window_titles = false; - static bool show_app_custom_rendering = false; - - if (show_app_main_menu_bar) ShowExampleAppMainMenuBar(); - if (show_app_documents) ShowExampleAppDocuments(&show_app_documents); - - if (show_app_console) ShowExampleAppConsole(&show_app_console); - if (show_app_log) ShowExampleAppLog(&show_app_log); - if (show_app_layout) ShowExampleAppLayout(&show_app_layout); - if (show_app_property_editor) ShowExampleAppPropertyEditor(&show_app_property_editor); - if (show_app_long_text) ShowExampleAppLongText(&show_app_long_text); - if (show_app_auto_resize) ShowExampleAppAutoResize(&show_app_auto_resize); - if (show_app_constrained_resize) ShowExampleAppConstrainedResize(&show_app_constrained_resize); - if (show_app_simple_overlay) ShowExampleAppSimpleOverlay(&show_app_simple_overlay); - if (show_app_fullscreen) ShowExampleAppFullscreen(&show_app_fullscreen); - if (show_app_window_titles) ShowExampleAppWindowTitles(&show_app_window_titles); - if (show_app_custom_rendering) ShowExampleAppCustomRendering(&show_app_custom_rendering); - - // Dear ImGui Apps (accessible from the "Tools" menu) - static bool show_app_metrics = false; - static bool show_app_stack_tool = false; - static bool show_app_style_editor = false; - static bool show_app_about = false; - - if (show_app_metrics) { ImGui::ShowMetricsWindow(&show_app_metrics); } - if (show_app_stack_tool) { ImGui::ShowStackToolWindow(&show_app_stack_tool); } - if (show_app_about) { ImGui::ShowAboutWindow(&show_app_about); } - if (show_app_style_editor) - { - ImGui::Begin("Dear ImGui Style Editor", &show_app_style_editor); - ImGui::ShowStyleEditor(); - ImGui::End(); - } - - // Demonstrate the various window flags. Typically you would just use the default! - static bool no_titlebar = false; - static bool no_scrollbar = false; - static bool no_menu = false; - static bool no_move = false; - static bool no_resize = false; - static bool no_collapse = false; - static bool no_close = false; - static bool no_nav = false; - static bool no_background = false; - static bool no_bring_to_front = false; - static bool unsaved_document = false; - - ImGuiWindowFlags window_flags = 0; - if (no_titlebar) window_flags |= ImGuiWindowFlags_NoTitleBar; - if (no_scrollbar) window_flags |= ImGuiWindowFlags_NoScrollbar; - if (!no_menu) window_flags |= ImGuiWindowFlags_MenuBar; - if (no_move) window_flags |= ImGuiWindowFlags_NoMove; - if (no_resize) window_flags |= ImGuiWindowFlags_NoResize; - if (no_collapse) window_flags |= ImGuiWindowFlags_NoCollapse; - if (no_nav) window_flags |= ImGuiWindowFlags_NoNav; - if (no_background) window_flags |= ImGuiWindowFlags_NoBackground; - if (no_bring_to_front) window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus; - if (unsaved_document) window_flags |= ImGuiWindowFlags_UnsavedDocument; - if (no_close) p_open = NULL; // Don't pass our bool* to Begin - - // We specify a default position/size in case there's no data in the .ini file. - // We only do it to make the demo applications a little more welcoming, but typically this isn't required. - const ImGuiViewport* main_viewport = ImGui::GetMainViewport(); - ImGui::SetNextWindowPos(ImVec2(main_viewport->WorkPos.x + 650, main_viewport->WorkPos.y + 20), ImGuiCond_FirstUseEver); - ImGui::SetNextWindowSize(ImVec2(550, 680), ImGuiCond_FirstUseEver); - - // Main body of the Demo window starts here. - if (!ImGui::Begin("Dear ImGui Demo", p_open, window_flags)) - { - // Early out if the window is collapsed, as an optimization. - ImGui::End(); - return; - } - - // Most "big" widgets share a common width settings by default. See 'Demo->Layout->Widgets Width' for details. - - // e.g. Use 2/3 of the space for widgets and 1/3 for labels (right align) - //ImGui::PushItemWidth(-ImGui::GetWindowWidth() * 0.35f); - - // e.g. Leave a fixed amount of width for labels (by passing a negative value), the rest goes to widgets. - ImGui::PushItemWidth(ImGui::GetFontSize() * -12); - - // Menu Bar - if (ImGui::BeginMenuBar()) - { - if (ImGui::BeginMenu("Menu")) - { - ShowExampleMenuFile(); - ImGui::EndMenu(); - } - if (ImGui::BeginMenu("Examples")) - { - ImGui::MenuItem("Main menu bar", NULL, &show_app_main_menu_bar); - ImGui::MenuItem("Console", NULL, &show_app_console); - ImGui::MenuItem("Log", NULL, &show_app_log); - ImGui::MenuItem("Simple layout", NULL, &show_app_layout); - ImGui::MenuItem("Property editor", NULL, &show_app_property_editor); - ImGui::MenuItem("Long text display", NULL, &show_app_long_text); - ImGui::MenuItem("Auto-resizing window", NULL, &show_app_auto_resize); - ImGui::MenuItem("Constrained-resizing window", NULL, &show_app_constrained_resize); - ImGui::MenuItem("Simple overlay", NULL, &show_app_simple_overlay); - ImGui::MenuItem("Fullscreen window", NULL, &show_app_fullscreen); - ImGui::MenuItem("Manipulating window titles", NULL, &show_app_window_titles); - ImGui::MenuItem("Custom rendering", NULL, &show_app_custom_rendering); - ImGui::MenuItem("Documents", NULL, &show_app_documents); - ImGui::EndMenu(); - } - //if (ImGui::MenuItem("MenuItem")) {} // You can also use MenuItem() inside a menu bar! - if (ImGui::BeginMenu("Tools")) - { -#ifndef IMGUI_DISABLE_METRICS_WINDOW - ImGui::MenuItem("Metrics/Debugger", NULL, &show_app_metrics); - ImGui::MenuItem("Stack Tool", NULL, &show_app_stack_tool); -#endif - ImGui::MenuItem("Style Editor", NULL, &show_app_style_editor); - ImGui::MenuItem("About Dear ImGui", NULL, &show_app_about); - ImGui::EndMenu(); - } - ImGui::EndMenuBar(); - } - - ImGui::Text("dear imgui says hello. (%s)", IMGUI_VERSION); - ImGui::Spacing(); - - if (ImGui::CollapsingHeader("Help")) - { - ImGui::Text("ABOUT THIS DEMO:"); - ImGui::BulletText("Sections below are demonstrating many aspects of the library."); - ImGui::BulletText("The \"Examples\" menu above leads to more demo contents."); - ImGui::BulletText("The \"Tools\" menu above gives access to: About Box, Style Editor,\n" - "and Metrics/Debugger (general purpose Dear ImGui debugging tool)."); - ImGui::Separator(); - - ImGui::Text("PROGRAMMER GUIDE:"); - ImGui::BulletText("See the ShowDemoWindow() code in imgui_demo.cpp. <- you are here!"); - ImGui::BulletText("See comments in imgui.cpp."); - ImGui::BulletText("See example applications in the examples/ folder."); - ImGui::BulletText("Read the FAQ at http://www.dearimgui.org/faq/"); - ImGui::BulletText("Set 'io.ConfigFlags |= NavEnableKeyboard' for keyboard controls."); - ImGui::BulletText("Set 'io.ConfigFlags |= NavEnableGamepad' for gamepad controls."); - ImGui::Separator(); - - ImGui::Text("USER GUIDE:"); - ImGui::ShowUserGuide(); - } - - if (ImGui::CollapsingHeader("Configuration")) - { - ImGuiIO& io = ImGui::GetIO(); - - if (ImGui::TreeNode("Configuration##2")) - { - ImGui::CheckboxFlags("io.ConfigFlags: NavEnableKeyboard", &io.ConfigFlags, ImGuiConfigFlags_NavEnableKeyboard); - ImGui::SameLine(); HelpMarker("Enable keyboard controls."); - ImGui::CheckboxFlags("io.ConfigFlags: NavEnableGamepad", &io.ConfigFlags, ImGuiConfigFlags_NavEnableGamepad); - ImGui::SameLine(); HelpMarker("Enable gamepad controls. Require backend to set io.BackendFlags |= ImGuiBackendFlags_HasGamepad.\n\nRead instructions in imgui.cpp for details."); - ImGui::CheckboxFlags("io.ConfigFlags: NavEnableSetMousePos", &io.ConfigFlags, ImGuiConfigFlags_NavEnableSetMousePos); - ImGui::SameLine(); HelpMarker("Instruct navigation to move the mouse cursor. See comment for ImGuiConfigFlags_NavEnableSetMousePos."); - ImGui::CheckboxFlags("io.ConfigFlags: NoMouse", &io.ConfigFlags, ImGuiConfigFlags_NoMouse); - if (io.ConfigFlags & ImGuiConfigFlags_NoMouse) - { - // The "NoMouse" option can get us stuck with a disabled mouse! Let's provide an alternative way to fix it: - if (fmodf((float)ImGui::GetTime(), 0.40f) < 0.20f) - { - ImGui::SameLine(); - ImGui::Text("<>"); - } - if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_Space))) - io.ConfigFlags &= ~ImGuiConfigFlags_NoMouse; - } - ImGui::CheckboxFlags("io.ConfigFlags: NoMouseCursorChange", &io.ConfigFlags, ImGuiConfigFlags_NoMouseCursorChange); - ImGui::SameLine(); HelpMarker("Instruct backend to not alter mouse cursor shape and visibility."); - ImGui::Checkbox("io.ConfigInputTextCursorBlink", &io.ConfigInputTextCursorBlink); - ImGui::SameLine(); HelpMarker("Enable blinking cursor (optional as some users consider it to be distracting)"); - ImGui::Checkbox("io.ConfigDragClickToInputText", &io.ConfigDragClickToInputText); - ImGui::SameLine(); HelpMarker("Enable turning DragXXX widgets into text input with a simple mouse click-release (without moving)."); - ImGui::Checkbox("io.ConfigWindowsResizeFromEdges", &io.ConfigWindowsResizeFromEdges); - ImGui::SameLine(); HelpMarker("Enable resizing of windows from their edges and from the lower-left corner.\nThis requires (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) because it needs mouse cursor feedback."); - ImGui::Checkbox("io.ConfigWindowsMoveFromTitleBarOnly", &io.ConfigWindowsMoveFromTitleBarOnly); - ImGui::Checkbox("io.MouseDrawCursor", &io.MouseDrawCursor); - ImGui::SameLine(); HelpMarker("Instruct Dear ImGui to render a mouse cursor itself. Note that a mouse cursor rendered via your application GPU rendering path will feel more laggy than hardware cursor, but will be more in sync with your other visuals.\n\nSome desktop applications may use both kinds of cursors (e.g. enable software cursor only when resizing/dragging something)."); - ImGui::Text("Also see Style->Rendering for rendering options."); - ImGui::TreePop(); - ImGui::Separator(); - } - - if (ImGui::TreeNode("Backend Flags")) - { - HelpMarker( - "Those flags are set by the backends (imgui_impl_xxx files) to specify their capabilities.\n" - "Here we expose them as read-only fields to avoid breaking interactions with your backend."); - - // Make a local copy to avoid modifying actual backend flags. - ImGuiBackendFlags backend_flags = io.BackendFlags; - ImGui::CheckboxFlags("io.BackendFlags: HasGamepad", &backend_flags, ImGuiBackendFlags_HasGamepad); - ImGui::CheckboxFlags("io.BackendFlags: HasMouseCursors", &backend_flags, ImGuiBackendFlags_HasMouseCursors); - ImGui::CheckboxFlags("io.BackendFlags: HasSetMousePos", &backend_flags, ImGuiBackendFlags_HasSetMousePos); - ImGui::CheckboxFlags("io.BackendFlags: RendererHasVtxOffset", &backend_flags, ImGuiBackendFlags_RendererHasVtxOffset); - ImGui::TreePop(); - ImGui::Separator(); - } - - if (ImGui::TreeNode("Style")) - { - HelpMarker("The same contents can be accessed in 'Tools->Style Editor' or by calling the ShowStyleEditor() function."); - ImGui::ShowStyleEditor(); - ImGui::TreePop(); - ImGui::Separator(); - } - - if (ImGui::TreeNode("Capture/Logging")) - { - HelpMarker( - "The logging API redirects all text output so you can easily capture the content of " - "a window or a block. Tree nodes can be automatically expanded.\n" - "Try opening any of the contents below in this window and then click one of the \"Log To\" button."); - ImGui::LogButtons(); - - HelpMarker("You can also call ImGui::LogText() to output directly to the log without a visual output."); - if (ImGui::Button("Copy \"Hello, world!\" to clipboard")) - { - ImGui::LogToClipboard(); - ImGui::LogText("Hello, world!"); - ImGui::LogFinish(); - } - ImGui::TreePop(); - } - } - - if (ImGui::CollapsingHeader("Window options")) - { - if (ImGui::BeginTable("split", 3)) - { - ImGui::TableNextColumn(); ImGui::Checkbox("No titlebar", &no_titlebar); - ImGui::TableNextColumn(); ImGui::Checkbox("No scrollbar", &no_scrollbar); - ImGui::TableNextColumn(); ImGui::Checkbox("No menu", &no_menu); - ImGui::TableNextColumn(); ImGui::Checkbox("No move", &no_move); - ImGui::TableNextColumn(); ImGui::Checkbox("No resize", &no_resize); - ImGui::TableNextColumn(); ImGui::Checkbox("No collapse", &no_collapse); - ImGui::TableNextColumn(); ImGui::Checkbox("No close", &no_close); - ImGui::TableNextColumn(); ImGui::Checkbox("No nav", &no_nav); - ImGui::TableNextColumn(); ImGui::Checkbox("No background", &no_background); - ImGui::TableNextColumn(); ImGui::Checkbox("No bring to front", &no_bring_to_front); - ImGui::TableNextColumn(); ImGui::Checkbox("Unsaved document", &unsaved_document); - ImGui::EndTable(); - } - } - - // All demo contents - ShowDemoWindowWidgets(); - ShowDemoWindowLayout(); - ShowDemoWindowPopups(); - ShowDemoWindowTables(); - ShowDemoWindowMisc(); - - // End of ShowDemoWindow() - ImGui::PopItemWidth(); - ImGui::End(); -} - -static void ShowDemoWindowWidgets() -{ - if (!ImGui::CollapsingHeader("Widgets")) - return; - - static bool disable_all = false; // The Checkbox for that is inside the "Disabled" section at the bottom - if (disable_all) - ImGui::BeginDisabled(); - - if (ImGui::TreeNode("Basic")) - { - static int clicked = 0; - if (ImGui::Button("Button")) - clicked++; - if (clicked & 1) - { - ImGui::SameLine(); - ImGui::Text("Thanks for clicking me!"); - } - - static bool check = true; - ImGui::Checkbox("checkbox", &check); - - static int e = 0; - ImGui::RadioButton("radio a", &e, 0); ImGui::SameLine(); - ImGui::RadioButton("radio b", &e, 1); ImGui::SameLine(); - ImGui::RadioButton("radio c", &e, 2); - - // Color buttons, demonstrate using PushID() to add unique identifier in the ID stack, and changing style. - for (int i = 0; i < 7; i++) - { - if (i > 0) - ImGui::SameLine(); - ImGui::PushID(i); - ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor::HSV(i / 7.0f, 0.6f, 0.6f)); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(i / 7.0f, 0.7f, 0.7f)); - ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV(i / 7.0f, 0.8f, 0.8f)); - ImGui::Button("Click"); - ImGui::PopStyleColor(3); - ImGui::PopID(); - } - - // Use AlignTextToFramePadding() to align text baseline to the baseline of framed widgets elements - // (otherwise a Text+SameLine+Button sequence will have the text a little too high by default!) - // See 'Demo->Layout->Text Baseline Alignment' for details. - ImGui::AlignTextToFramePadding(); - ImGui::Text("Hold to repeat:"); - ImGui::SameLine(); - - // Arrow buttons with Repeater - static int counter = 0; - float spacing = ImGui::GetStyle().ItemInnerSpacing.x; - ImGui::PushButtonRepeat(true); - if (ImGui::ArrowButton("##left", ImGuiDir_Left)) { counter--; } - ImGui::SameLine(0.0f, spacing); - if (ImGui::ArrowButton("##right", ImGuiDir_Right)) { counter++; } - ImGui::PopButtonRepeat(); - ImGui::SameLine(); - ImGui::Text("%d", counter); - - ImGui::Text("Hover over me"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("I am a tooltip"); - - ImGui::SameLine(); - ImGui::Text("- or me"); - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - ImGui::Text("I am a fancy tooltip"); - static float arr[] = { 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f }; - ImGui::PlotLines("Curve", arr, IM_ARRAYSIZE(arr)); - ImGui::EndTooltip(); - } - - ImGui::Separator(); - - ImGui::LabelText("label", "Value"); - - { - // Using the _simplified_ one-liner Combo() api here - // See "Combo" section for examples of how to use the more flexible BeginCombo()/EndCombo() api. - const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD", "EEEE", "FFFF", "GGGG", "HHHH", "IIIIIII", "JJJJ", "KKKKKKK" }; - static int item_current = 0; - ImGui::Combo("combo", &item_current, items, IM_ARRAYSIZE(items)); - ImGui::SameLine(); HelpMarker( - "Using the simplified one-liner Combo API here.\nRefer to the \"Combo\" section below for an explanation of how to use the more flexible and general BeginCombo/EndCombo API."); - } - - { - // To wire InputText() with std::string or any other custom string type, - // see the "Text Input > Resize Callback" section of this demo, and the misc/cpp/imgui_stdlib.h file. - static char str0[128] = "Hello, world!"; - ImGui::InputText("input text", str0, IM_ARRAYSIZE(str0)); - ImGui::SameLine(); HelpMarker( - "USER:\n" - "Hold SHIFT or use mouse to select text.\n" - "CTRL+Left/Right to word jump.\n" - "CTRL+A or double-click to select all.\n" - "CTRL+X,CTRL+C,CTRL+V clipboard.\n" - "CTRL+Z,CTRL+Y undo/redo.\n" - "ESCAPE to revert.\n\n" - "PROGRAMMER:\n" - "You can use the ImGuiInputTextFlags_CallbackResize facility if you need to wire InputText() " - "to a dynamic string type. See misc/cpp/imgui_stdlib.h for an example (this is not demonstrated " - "in imgui_demo.cpp)."); - - static char str1[128] = ""; - ImGui::InputTextWithHint("input text (w/ hint)", "enter text here", str1, IM_ARRAYSIZE(str1)); - - static int i0 = 123; - ImGui::InputInt("input int", &i0); - ImGui::SameLine(); HelpMarker( - "You can apply arithmetic operators +,*,/ on numerical values.\n" - " e.g. [ 100 ], input \'*2\', result becomes [ 200 ]\n" - "Use +- to subtract."); - - static float f0 = 0.001f; - ImGui::InputFloat("input float", &f0, 0.01f, 1.0f, "%.3f"); - - static double d0 = 999999.00000001; - ImGui::InputDouble("input double", &d0, 0.01f, 1.0f, "%.8f"); - - static float f1 = 1.e10f; - ImGui::InputFloat("input scientific", &f1, 0.0f, 0.0f, "%e"); - ImGui::SameLine(); HelpMarker( - "You can input value using the scientific notation,\n" - " e.g. \"1e+8\" becomes \"100000000\"."); - - static float vec4a[4] = { 0.10f, 0.20f, 0.30f, 0.44f }; - ImGui::InputFloat3("input float3", vec4a); - } - - { - static int i1 = 50, i2 = 42; - ImGui::DragInt("drag int", &i1, 1); - ImGui::SameLine(); HelpMarker( - "Click and drag to edit value.\n" - "Hold SHIFT/ALT for faster/slower edit.\n" - "Double-click or CTRL+click to input value."); - - ImGui::DragInt("drag int 0..100", &i2, 1, 0, 100, "%d%%", ImGuiSliderFlags_AlwaysClamp); - - static float f1 = 1.00f, f2 = 0.0067f; - ImGui::DragFloat("drag float", &f1, 0.005f); - ImGui::DragFloat("drag small float", &f2, 0.0001f, 0.0f, 0.0f, "%.06f ns"); - } - - { - static int i1 = 0; - ImGui::SliderInt("slider int", &i1, -1, 3); - ImGui::SameLine(); HelpMarker("CTRL+click to input value."); - - static float f1 = 0.123f, f2 = 0.0f; - ImGui::SliderFloat("slider float", &f1, 0.0f, 1.0f, "ratio = %.3f"); - ImGui::SliderFloat("slider float (log)", &f2, -10.0f, 10.0f, "%.4f", ImGuiSliderFlags_Logarithmic); - - static float angle = 0.0f; - ImGui::SliderAngle("slider angle", &angle); - - // Using the format string to display a name instead of an integer. - // Here we completely omit '%d' from the format string, so it'll only display a name. - // This technique can also be used with DragInt(). - enum Element { Element_Fire, Element_Earth, Element_Air, Element_Water, Element_COUNT }; - static int elem = Element_Fire; - const char* elems_names[Element_COUNT] = { "Fire", "Earth", "Air", "Water" }; - const char* elem_name = (elem >= 0 && elem < Element_COUNT) ? elems_names[elem] : "Unknown"; - ImGui::SliderInt("slider enum", &elem, 0, Element_COUNT - 1, elem_name); - ImGui::SameLine(); HelpMarker("Using the format string parameter to display a name instead of the underlying integer."); - } - - { - static float col1[3] = { 1.0f, 0.0f, 0.2f }; - static float col2[4] = { 0.4f, 0.7f, 0.0f, 0.5f }; - ImGui::ColorEdit3("color 1", col1); - ImGui::SameLine(); HelpMarker( - "Click on the color square to open a color picker.\n" - "Click and hold to use drag and drop.\n" - "Right-click on the color square to show options.\n" - "CTRL+click on individual component to input value.\n"); - - ImGui::ColorEdit4("color 2", col2); - } - - { - // Using the _simplified_ one-liner ListBox() api here - // See "List boxes" section for examples of how to use the more flexible BeginListBox()/EndListBox() api. - const char* items[] = { "Apple", "Banana", "Cherry", "Kiwi", "Mango", "Orange", "Pineapple", "Strawberry", "Watermelon" }; - static int item_current = 1; - ImGui::ListBox("listbox", &item_current, items, IM_ARRAYSIZE(items), 4); - ImGui::SameLine(); HelpMarker( - "Using the simplified one-liner ListBox API here.\nRefer to the \"List boxes\" section below for an explanation of how to use the more flexible and general BeginListBox/EndListBox API."); - } - - ImGui::TreePop(); - } - - // Testing ImGuiOnceUponAFrame helper. - //static ImGuiOnceUponAFrame once; - //for (int i = 0; i < 5; i++) - // if (once) - // ImGui::Text("This will be displayed only once."); - - if (ImGui::TreeNode("Trees")) - { - if (ImGui::TreeNode("Basic trees")) - { - for (int i = 0; i < 5; i++) - { - // Use SetNextItemOpen() so set the default state of a node to be open. We could - // also use TreeNodeEx() with the ImGuiTreeNodeFlags_DefaultOpen flag to achieve the same thing! - if (i == 0) - ImGui::SetNextItemOpen(true, ImGuiCond_Once); - - if (ImGui::TreeNode((void*)(intptr_t)i, "Child %d", i)) - { - ImGui::Text("blah blah"); - ImGui::SameLine(); - if (ImGui::SmallButton("button")) {} - ImGui::TreePop(); - } - } - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Advanced, with Selectable nodes")) - { - HelpMarker( - "This is a more typical looking tree with selectable nodes.\n" - "Click to select, CTRL+Click to toggle, click on arrows or double-click to open."); - static ImGuiTreeNodeFlags base_flags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_SpanAvailWidth; - static bool align_label_with_current_x_position = false; - static bool test_drag_and_drop = false; - ImGui::CheckboxFlags("ImGuiTreeNodeFlags_OpenOnArrow", &base_flags, ImGuiTreeNodeFlags_OpenOnArrow); - ImGui::CheckboxFlags("ImGuiTreeNodeFlags_OpenOnDoubleClick", &base_flags, ImGuiTreeNodeFlags_OpenOnDoubleClick); - ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanAvailWidth", &base_flags, ImGuiTreeNodeFlags_SpanAvailWidth); ImGui::SameLine(); HelpMarker("Extend hit area to all available width instead of allowing more items to be laid out after the node."); - ImGui::CheckboxFlags("ImGuiTreeNodeFlags_SpanFullWidth", &base_flags, ImGuiTreeNodeFlags_SpanFullWidth); - ImGui::Checkbox("Align label with current X position", &align_label_with_current_x_position); - ImGui::Checkbox("Test tree node as drag source", &test_drag_and_drop); - ImGui::Text("Hello!"); - if (align_label_with_current_x_position) - ImGui::Unindent(ImGui::GetTreeNodeToLabelSpacing()); - - // 'selection_mask' is dumb representation of what may be user-side selection state. - // You may retain selection state inside or outside your objects in whatever format you see fit. - // 'node_clicked' is temporary storage of what node we have clicked to process selection at the end - /// of the loop. May be a pointer to your own node type, etc. - static int selection_mask = (1 << 2); - int node_clicked = -1; - for (int i = 0; i < 6; i++) - { - // Disable the default "open on single-click behavior" + set Selected flag according to our selection. - ImGuiTreeNodeFlags node_flags = base_flags; - const bool is_selected = (selection_mask & (1 << i)) != 0; - if (is_selected) - node_flags |= ImGuiTreeNodeFlags_Selected; - if (i < 3) - { - // Items 0..2 are Tree Node - bool node_open = ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags, "Selectable Node %d", i); - if (ImGui::IsItemClicked()) - node_clicked = i; - if (test_drag_and_drop && ImGui::BeginDragDropSource()) - { - ImGui::SetDragDropPayload("_TREENODE", NULL, 0); - ImGui::Text("This is a drag and drop source"); - ImGui::EndDragDropSource(); - } - if (node_open) - { - ImGui::BulletText("Blah blah\nBlah Blah"); - ImGui::TreePop(); - } - } - else - { - // Items 3..5 are Tree Leaves - // The only reason we use TreeNode at all is to allow selection of the leaf. Otherwise we can - // use BulletText() or advance the cursor by GetTreeNodeToLabelSpacing() and call Text(). - node_flags |= ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen; // ImGuiTreeNodeFlags_Bullet - ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags, "Selectable Leaf %d", i); - if (ImGui::IsItemClicked()) - node_clicked = i; - if (test_drag_and_drop && ImGui::BeginDragDropSource()) - { - ImGui::SetDragDropPayload("_TREENODE", NULL, 0); - ImGui::Text("This is a drag and drop source"); - ImGui::EndDragDropSource(); - } - } - } - if (node_clicked != -1) - { - // Update selection state - // (process outside of tree loop to avoid visual inconsistencies during the clicking frame) - if (ImGui::GetIO().KeyCtrl) - selection_mask ^= (1 << node_clicked); // CTRL+click to toggle - else //if (!(selection_mask & (1 << node_clicked))) // Depending on selection behavior you want, may want to preserve selection when clicking on item that is part of the selection - selection_mask = (1 << node_clicked); // Click to single-select - } - if (align_label_with_current_x_position) - ImGui::Indent(ImGui::GetTreeNodeToLabelSpacing()); - ImGui::TreePop(); - } - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Collapsing Headers")) - { - static bool closable_group = true; - ImGui::Checkbox("Show 2nd header", &closable_group); - if (ImGui::CollapsingHeader("Header", ImGuiTreeNodeFlags_None)) - { - ImGui::Text("IsItemHovered: %d", ImGui::IsItemHovered()); - for (int i = 0; i < 5; i++) - ImGui::Text("Some content %d", i); - } - if (ImGui::CollapsingHeader("Header with a close button", &closable_group)) - { - ImGui::Text("IsItemHovered: %d", ImGui::IsItemHovered()); - for (int i = 0; i < 5; i++) - ImGui::Text("More content %d", i); - } - /* - if (ImGui::CollapsingHeader("Header with a bullet", ImGuiTreeNodeFlags_Bullet)) - ImGui::Text("IsItemHovered: %d", ImGui::IsItemHovered()); - */ - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Bullets")) - { - ImGui::BulletText("Bullet point 1"); - ImGui::BulletText("Bullet point 2\nOn multiple lines"); - if (ImGui::TreeNode("Tree node")) - { - ImGui::BulletText("Another bullet point"); - ImGui::TreePop(); - } - ImGui::Bullet(); ImGui::Text("Bullet point 3 (two calls)"); - ImGui::Bullet(); ImGui::SmallButton("Button"); - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Text")) - { - if (ImGui::TreeNode("Colorful Text")) - { - // Using shortcut. You can use PushStyleColor()/PopStyleColor() for more flexibility. - ImGui::TextColored(ImVec4(1.0f, 0.0f, 1.0f, 1.0f), "Pink"); - ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "Yellow"); - ImGui::TextDisabled("Disabled"); - ImGui::SameLine(); HelpMarker("The TextDisabled color is stored in ImGuiStyle."); - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Word Wrapping")) - { - // Using shortcut. You can use PushTextWrapPos()/PopTextWrapPos() for more flexibility. - ImGui::TextWrapped( - "This text should automatically wrap on the edge of the window. The current implementation " - "for text wrapping follows simple rules suitable for English and possibly other languages."); - ImGui::Spacing(); - - static float wrap_width = 200.0f; - ImGui::SliderFloat("Wrap width", &wrap_width, -20, 600, "%.0f"); - - ImDrawList* draw_list = ImGui::GetWindowDrawList(); - for (int n = 0; n < 2; n++) - { - ImGui::Text("Test paragraph %d:", n); - ImVec2 pos = ImGui::GetCursorScreenPos(); - ImVec2 marker_min = ImVec2(pos.x + wrap_width, pos.y); - ImVec2 marker_max = ImVec2(pos.x + wrap_width + 10, pos.y + ImGui::GetTextLineHeight()); - ImGui::PushTextWrapPos(ImGui::GetCursorPos().x + wrap_width); - if (n == 0) - ImGui::Text("The lazy dog is a good dog. This paragraph should fit within %.0f pixels. Testing a 1 character word. The quick brown fox jumps over the lazy dog.", wrap_width); - else - ImGui::Text("aaaaaaaa bbbbbbbb, c cccccccc,dddddddd. d eeeeeeee ffffffff. gggggggg!hhhhhhhh"); - - // Draw actual text bounding box, following by marker of our expected limit (should not overlap!) - draw_list->AddRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), IM_COL32(255, 255, 0, 255)); - draw_list->AddRectFilled(marker_min, marker_max, IM_COL32(255, 0, 255, 255)); - ImGui::PopTextWrapPos(); - } - - ImGui::TreePop(); - } - - if (ImGui::TreeNode("UTF-8 Text")) - { - // UTF-8 test with Japanese characters - // (Needs a suitable font? Try "Google Noto" or "Arial Unicode". See docs/FONTS.md for details.) - // - From C++11 you can use the u8"my text" syntax to encode literal strings as UTF-8 - // - For earlier compiler, you may be able to encode your sources as UTF-8 (e.g. in Visual Studio, you - // can save your source files as 'UTF-8 without signature'). - // - FOR THIS DEMO FILE ONLY, BECAUSE WE WANT TO SUPPORT OLD COMPILERS, WE ARE *NOT* INCLUDING RAW UTF-8 - // CHARACTERS IN THIS SOURCE FILE. Instead we are encoding a few strings with hexadecimal constants. - // Don't do this in your application! Please use u8"text in any language" in your application! - // Note that characters values are preserved even by InputText() if the font cannot be displayed, - // so you can safely copy & paste garbled characters into another application. - ImGui::TextWrapped( - "CJK text will only appears if the font was loaded with the appropriate CJK character ranges. " - "Call io.Fonts->AddFontFromFileTTF() manually to load extra character ranges. " - "Read docs/FONTS.md for details."); - ImGui::Text("Hiragana: \xe3\x81\x8b\xe3\x81\x8d\xe3\x81\x8f\xe3\x81\x91\xe3\x81\x93 (kakikukeko)"); // Normally we would use u8"blah blah" with the proper characters directly in the string. - ImGui::Text("Kanjis: \xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e (nihongo)"); - static char buf[32] = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e"; - //static char buf[32] = u8"NIHONGO"; // <- this is how you would write it with C++11, using real kanjis - ImGui::InputText("UTF-8 input", buf, IM_ARRAYSIZE(buf)); - ImGui::TreePop(); - } - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Images")) - { - ImGuiIO& io = ImGui::GetIO(); - ImGui::TextWrapped( - "Below we are displaying the font texture (which is the only texture we have access to in this demo). " - "Use the 'ImTextureID' type as storage to pass pointers or identifier to your own texture data. " - "Hover the texture for a zoomed view!"); - - // Below we are displaying the font texture because it is the only texture we have access to inside the demo! - // Remember that ImTextureID is just storage for whatever you want it to be. It is essentially a value that - // will be passed to the rendering backend via the ImDrawCmd structure. - // If you use one of the default imgui_impl_XXXX.cpp rendering backend, they all have comments at the top - // of their respective source file to specify what they expect to be stored in ImTextureID, for example: - // - The imgui_impl_dx11.cpp renderer expect a 'ID3D11ShaderResourceView*' pointer - // - The imgui_impl_opengl3.cpp renderer expect a GLuint OpenGL texture identifier, etc. - // More: - // - If you decided that ImTextureID = MyEngineTexture*, then you can pass your MyEngineTexture* pointers - // to ImGui::Image(), and gather width/height through your own functions, etc. - // - You can use ShowMetricsWindow() to inspect the draw data that are being passed to your renderer, - // it will help you debug issues if you are confused about it. - // - Consider using the lower-level ImDrawList::AddImage() API, via ImGui::GetWindowDrawList()->AddImage(). - // - Read https://github.com/ocornut/imgui/blob/master/docs/FAQ.md - // - Read https://github.com/ocornut/imgui/wiki/Image-Loading-and-Displaying-Examples - ImTextureID my_tex_id = io.Fonts->TexID; - float my_tex_w = (float)io.Fonts->TexWidth; - float my_tex_h = (float)io.Fonts->TexHeight; - { - ImGui::Text("%.0fx%.0f", my_tex_w, my_tex_h); - ImVec2 pos = ImGui::GetCursorScreenPos(); - ImVec2 uv_min = ImVec2(0.0f, 0.0f); // Top-left - ImVec2 uv_max = ImVec2(1.0f, 1.0f); // Lower-right - ImVec4 tint_col = ImVec4(1.0f, 1.0f, 1.0f, 1.0f); // No tint - ImVec4 border_col = ImVec4(1.0f, 1.0f, 1.0f, 0.5f); // 50% opaque white - ImGui::Image(my_tex_id, ImVec2(my_tex_w, my_tex_h), uv_min, uv_max, tint_col, border_col); - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - float region_sz = 32.0f; - float region_x = io.MousePos.x - pos.x - region_sz * 0.5f; - float region_y = io.MousePos.y - pos.y - region_sz * 0.5f; - float zoom = 4.0f; - if (region_x < 0.0f) { region_x = 0.0f; } - else if (region_x > my_tex_w - region_sz) { region_x = my_tex_w - region_sz; } - if (region_y < 0.0f) { region_y = 0.0f; } - else if (region_y > my_tex_h - region_sz) { region_y = my_tex_h - region_sz; } - ImGui::Text("Min: (%.2f, %.2f)", region_x, region_y); - ImGui::Text("Max: (%.2f, %.2f)", region_x + region_sz, region_y + region_sz); - ImVec2 uv0 = ImVec2((region_x) / my_tex_w, (region_y) / my_tex_h); - ImVec2 uv1 = ImVec2((region_x + region_sz) / my_tex_w, (region_y + region_sz) / my_tex_h); - ImGui::Image(my_tex_id, ImVec2(region_sz * zoom, region_sz * zoom), uv0, uv1, tint_col, border_col); - ImGui::EndTooltip(); - } - } - ImGui::TextWrapped("And now some textured buttons.."); - static int pressed_count = 0; - for (int i = 0; i < 8; i++) - { - ImGui::PushID(i); - int frame_padding = -1 + i; // -1 == uses default padding (style.FramePadding) - ImVec2 size = ImVec2(32.0f, 32.0f); // Size of the image we want to make visible - ImVec2 uv0 = ImVec2(0.0f, 0.0f); // UV coordinates for lower-left - ImVec2 uv1 = ImVec2(32.0f / my_tex_w, 32.0f / my_tex_h);// UV coordinates for (32,32) in our texture - ImVec4 bg_col = ImVec4(0.0f, 0.0f, 0.0f, 1.0f); // Black background - ImVec4 tint_col = ImVec4(1.0f, 1.0f, 1.0f, 1.0f); // No tint - if (ImGui::ImageButton(my_tex_id, size, uv0, uv1, frame_padding, bg_col, tint_col)) - pressed_count += 1; - ImGui::PopID(); - ImGui::SameLine(); - } - ImGui::NewLine(); - ImGui::Text("Pressed %d times.", pressed_count); - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Combo")) - { - // Expose flags as checkbox for the demo - static ImGuiComboFlags flags = 0; - ImGui::CheckboxFlags("ImGuiComboFlags_PopupAlignLeft", &flags, ImGuiComboFlags_PopupAlignLeft); - ImGui::SameLine(); HelpMarker("Only makes a difference if the popup is larger than the combo"); - if (ImGui::CheckboxFlags("ImGuiComboFlags_NoArrowButton", &flags, ImGuiComboFlags_NoArrowButton)) - flags &= ~ImGuiComboFlags_NoPreview; // Clear the other flag, as we cannot combine both - if (ImGui::CheckboxFlags("ImGuiComboFlags_NoPreview", &flags, ImGuiComboFlags_NoPreview)) - flags &= ~ImGuiComboFlags_NoArrowButton; // Clear the other flag, as we cannot combine both - - // Using the generic BeginCombo() API, you have full control over how to display the combo contents. - // (your selection data could be an index, a pointer to the object, an id for the object, a flag intrusively - // stored in the object itself, etc.) - const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD", "EEEE", "FFFF", "GGGG", "HHHH", "IIII", "JJJJ", "KKKK", "LLLLLLL", "MMMM", "OOOOOOO" }; - static int item_current_idx = 0; // Here we store our selection data as an index. - const char* combo_preview_value = items[item_current_idx]; // Pass in the preview value visible before opening the combo (it could be anything) - if (ImGui::BeginCombo("combo 1", combo_preview_value, flags)) - { - for (int n = 0; n < IM_ARRAYSIZE(items); n++) - { - const bool is_selected = (item_current_idx == n); - if (ImGui::Selectable(items[n], is_selected)) - item_current_idx = n; - - // Set the initial focus when opening the combo (scrolling + keyboard navigation focus) - if (is_selected) - ImGui::SetItemDefaultFocus(); - } - ImGui::EndCombo(); - } - - // Simplified one-liner Combo() API, using values packed in a single constant string - // This is a convenience for when the selection set is small and known at compile-time. - static int item_current_2 = 0; - ImGui::Combo("combo 2 (one-liner)", &item_current_2, "aaaa\0bbbb\0cccc\0dddd\0eeee\0\0"); - - // Simplified one-liner Combo() using an array of const char* - // This is not very useful (may obsolete): prefer using BeginCombo()/EndCombo() for full control. - static int item_current_3 = -1; // If the selection isn't within 0..count, Combo won't display a preview - ImGui::Combo("combo 3 (array)", &item_current_3, items, IM_ARRAYSIZE(items)); - - // Simplified one-liner Combo() using an accessor function - struct Funcs { static bool ItemGetter(void* data, int n, const char** out_str) { *out_str = ((const char**)data)[n]; return true; } }; - static int item_current_4 = 0; - ImGui::Combo("combo 4 (function)", &item_current_4, &Funcs::ItemGetter, items, IM_ARRAYSIZE(items)); - - ImGui::TreePop(); - } - - if (ImGui::TreeNode("List boxes")) - { - // Using the generic BeginListBox() API, you have full control over how to display the combo contents. - // (your selection data could be an index, a pointer to the object, an id for the object, a flag intrusively - // stored in the object itself, etc.) - const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD", "EEEE", "FFFF", "GGGG", "HHHH", "IIII", "JJJJ", "KKKK", "LLLLLLL", "MMMM", "OOOOOOO" }; - static int item_current_idx = 0; // Here we store our selection data as an index. - if (ImGui::BeginListBox("listbox 1")) - { - for (int n = 0; n < IM_ARRAYSIZE(items); n++) - { - const bool is_selected = (item_current_idx == n); - if (ImGui::Selectable(items[n], is_selected)) - item_current_idx = n; - - // Set the initial focus when opening the combo (scrolling + keyboard navigation focus) - if (is_selected) - ImGui::SetItemDefaultFocus(); - } - ImGui::EndListBox(); - } - - // Custom size: use all width, 5 items tall - ImGui::Text("Full-width:"); - if (ImGui::BeginListBox("##listbox 2", ImVec2(-FLT_MIN, 5 * ImGui::GetTextLineHeightWithSpacing()))) - { - for (int n = 0; n < IM_ARRAYSIZE(items); n++) - { - const bool is_selected = (item_current_idx == n); - if (ImGui::Selectable(items[n], is_selected)) - item_current_idx = n; - - // Set the initial focus when opening the combo (scrolling + keyboard navigation focus) - if (is_selected) - ImGui::SetItemDefaultFocus(); - } - ImGui::EndListBox(); - } - - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Selectables")) - { - // Selectable() has 2 overloads: - // - The one taking "bool selected" as a read-only selection information. - // When Selectable() has been clicked it returns true and you can alter selection state accordingly. - // - The one taking "bool* p_selected" as a read-write selection information (convenient in some cases) - // The earlier is more flexible, as in real application your selection may be stored in many different ways - // and not necessarily inside a bool value (e.g. in flags within objects, as an external list, etc). - if (ImGui::TreeNode("Basic")) - { - static bool selection[5] = { false, true, false, false, false }; - ImGui::Selectable("1. I am selectable", &selection[0]); - ImGui::Selectable("2. I am selectable", &selection[1]); - ImGui::Text("(I am not selectable)"); - ImGui::Selectable("4. I am selectable", &selection[3]); - if (ImGui::Selectable("5. I am double clickable", selection[4], ImGuiSelectableFlags_AllowDoubleClick)) - if (ImGui::IsMouseDoubleClicked(0)) - selection[4] = !selection[4]; - ImGui::TreePop(); - } - if (ImGui::TreeNode("Selection State: Single Selection")) - { - static int selected = -1; - for (int n = 0; n < 5; n++) - { - char buf[32]; - sprintf(buf, "Object %d", n); - if (ImGui::Selectable(buf, selected == n)) - selected = n; - } - ImGui::TreePop(); - } - if (ImGui::TreeNode("Selection State: Multiple Selection")) - { - HelpMarker("Hold CTRL and click to select multiple items."); - static bool selection[5] = { false, false, false, false, false }; - for (int n = 0; n < 5; n++) - { - char buf[32]; - sprintf(buf, "Object %d", n); - if (ImGui::Selectable(buf, selection[n])) - { - if (!ImGui::GetIO().KeyCtrl) // Clear selection when CTRL is not held - memset(selection, 0, sizeof(selection)); - selection[n] ^= 1; - } - } - ImGui::TreePop(); - } - if (ImGui::TreeNode("Rendering more text into the same line")) - { - // Using the Selectable() override that takes "bool* p_selected" parameter, - // this function toggle your bool value automatically. - static bool selected[3] = { false, false, false }; - ImGui::Selectable("main.c", &selected[0]); ImGui::SameLine(300); ImGui::Text(" 2,345 bytes"); - ImGui::Selectable("Hello.cpp", &selected[1]); ImGui::SameLine(300); ImGui::Text("12,345 bytes"); - ImGui::Selectable("Hello.h", &selected[2]); ImGui::SameLine(300); ImGui::Text(" 2,345 bytes"); - ImGui::TreePop(); - } - if (ImGui::TreeNode("In columns")) - { - static bool selected[10] = {}; - - if (ImGui::BeginTable("split1", 3, ImGuiTableFlags_Resizable | ImGuiTableFlags_NoSavedSettings | ImGuiTableFlags_Borders)) - { - for (int i = 0; i < 10; i++) - { - char label[32]; - sprintf(label, "Item %d", i); - ImGui::TableNextColumn(); - ImGui::Selectable(label, &selected[i]); // FIXME-TABLE: Selection overlap - } - ImGui::EndTable(); - } - ImGui::Spacing(); - if (ImGui::BeginTable("split2", 3, ImGuiTableFlags_Resizable | ImGuiTableFlags_NoSavedSettings | ImGuiTableFlags_Borders)) - { - for (int i = 0; i < 10; i++) - { - char label[32]; - sprintf(label, "Item %d", i); - ImGui::TableNextRow(); - ImGui::TableNextColumn(); - ImGui::Selectable(label, &selected[i], ImGuiSelectableFlags_SpanAllColumns); - ImGui::TableNextColumn(); - ImGui::Text("Some other contents"); - ImGui::TableNextColumn(); - ImGui::Text("123456"); - } - ImGui::EndTable(); - } - ImGui::TreePop(); - } - if (ImGui::TreeNode("Grid")) - { - static char selected[4][4] = { { 1, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 1 } }; - - // Add in a bit of silly fun... - const float time = (float)ImGui::GetTime(); - const bool winning_state = memchr(selected, 0, sizeof(selected)) == NULL; // If all cells are selected... - if (winning_state) - ImGui::PushStyleVar(ImGuiStyleVar_SelectableTextAlign, ImVec2(0.5f + 0.5f * cosf(time * 2.0f), 0.5f + 0.5f * sinf(time * 3.0f))); - - for (int y = 0; y < 4; y++) - for (int x = 0; x < 4; x++) - { - if (x > 0) - ImGui::SameLine(); - ImGui::PushID(y * 4 + x); - if (ImGui::Selectable("Sailor", selected[y][x] != 0, 0, ImVec2(50, 50))) - { - // Toggle clicked cell + toggle neighbors - selected[y][x] ^= 1; - if (x > 0) { selected[y][x - 1] ^= 1; } - if (x < 3) { selected[y][x + 1] ^= 1; } - if (y > 0) { selected[y - 1][x] ^= 1; } - if (y < 3) { selected[y + 1][x] ^= 1; } - } - ImGui::PopID(); - } - - if (winning_state) - ImGui::PopStyleVar(); - ImGui::TreePop(); - } - if (ImGui::TreeNode("Alignment")) - { - HelpMarker( - "By default, Selectables uses style.SelectableTextAlign but it can be overridden on a per-item " - "basis using PushStyleVar(). You'll probably want to always keep your default situation to " - "left-align otherwise it becomes difficult to layout multiple items on a same line"); - static bool selected[3 * 3] = { true, false, true, false, true, false, true, false, true }; - for (int y = 0; y < 3; y++) - { - for (int x = 0; x < 3; x++) - { - ImVec2 alignment = ImVec2((float)x / 2.0f, (float)y / 2.0f); - char name[32]; - sprintf(name, "(%.1f,%.1f)", alignment.x, alignment.y); - if (x > 0) ImGui::SameLine(); - ImGui::PushStyleVar(ImGuiStyleVar_SelectableTextAlign, alignment); - ImGui::Selectable(name, &selected[3 * y + x], ImGuiSelectableFlags_None, ImVec2(80, 80)); - ImGui::PopStyleVar(); - } - } - ImGui::TreePop(); - } - ImGui::TreePop(); - } - - // To wire InputText() with std::string or any other custom string type, - // see the "Text Input > Resize Callback" section of this demo, and the misc/cpp/imgui_stdlib.h file. - if (ImGui::TreeNode("Text Input")) - { - if (ImGui::TreeNode("Multi-line Text Input")) - { - // Note: we are using a fixed-sized buffer for simplicity here. See ImGuiInputTextFlags_CallbackResize - // and the code in misc/cpp/imgui_stdlib.h for how to setup InputText() for dynamically resizing strings. - static char text[1024 * 16] = - "/*\n" - " The Pentium F00F bug, shorthand for F0 0F C7 C8,\n" - " the hexadecimal encoding of one offending instruction,\n" - " more formally, the invalid operand with locked CMPXCHG8B\n" - " instruction bug, is a design flaw in the majority of\n" - " Intel Pentium, Pentium MMX, and Pentium OverDrive\n" - " processors (all in the P5 microarchitecture).\n" - "*/\n\n" - "label:\n" - "\tlock cmpxchg8b eax\n"; - - static ImGuiInputTextFlags flags = ImGuiInputTextFlags_AllowTabInput; - HelpMarker("You can use the ImGuiInputTextFlags_CallbackResize facility if you need to wire InputTextMultiline() to a dynamic string type. See misc/cpp/imgui_stdlib.h for an example. (This is not demonstrated in imgui_demo.cpp because we don't want to include in here)"); - ImGui::CheckboxFlags("ImGuiInputTextFlags_ReadOnly", &flags, ImGuiInputTextFlags_ReadOnly); - ImGui::CheckboxFlags("ImGuiInputTextFlags_AllowTabInput", &flags, ImGuiInputTextFlags_AllowTabInput); - ImGui::CheckboxFlags("ImGuiInputTextFlags_CtrlEnterForNewLine", &flags, ImGuiInputTextFlags_CtrlEnterForNewLine); - ImGui::InputTextMultiline("##source", text, IM_ARRAYSIZE(text), ImVec2(-FLT_MIN, ImGui::GetTextLineHeight() * 16), flags); - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Filtered Text Input")) - { - struct TextFilters - { - // Return 0 (pass) if the character is 'i' or 'm' or 'g' or 'u' or 'i' - static int FilterImGuiLetters(ImGuiInputTextCallbackData* data) - { - if (data->EventChar < 256 && strchr("imgui", (char)data->EventChar)) - return 0; - return 1; - } - }; - - static char buf1[64] = ""; ImGui::InputText("default", buf1, 64); - static char buf2[64] = ""; ImGui::InputText("decimal", buf2, 64, ImGuiInputTextFlags_CharsDecimal); - static char buf3[64] = ""; ImGui::InputText("hexadecimal", buf3, 64, ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase); - static char buf4[64] = ""; ImGui::InputText("uppercase", buf4, 64, ImGuiInputTextFlags_CharsUppercase); - static char buf5[64] = ""; ImGui::InputText("no blank", buf5, 64, ImGuiInputTextFlags_CharsNoBlank); - static char buf6[64] = ""; ImGui::InputText("\"imgui\" letters", buf6, 64, ImGuiInputTextFlags_CallbackCharFilter, TextFilters::FilterImGuiLetters); - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Password Input")) - { - static char password[64] = "password123"; - ImGui::InputText("password", password, IM_ARRAYSIZE(password), ImGuiInputTextFlags_Password); - ImGui::SameLine(); HelpMarker("Display all characters as '*'.\nDisable clipboard cut and copy.\nDisable logging.\n"); - ImGui::InputTextWithHint("password (w/ hint)", "", password, IM_ARRAYSIZE(password), ImGuiInputTextFlags_Password); - ImGui::InputText("password (clear)", password, IM_ARRAYSIZE(password)); - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Completion, History, Edit Callbacks")) - { - struct Funcs - { - static int MyCallback(ImGuiInputTextCallbackData* data) - { - if (data->EventFlag == ImGuiInputTextFlags_CallbackCompletion) - { - data->InsertChars(data->CursorPos, ".."); - } - else if (data->EventFlag == ImGuiInputTextFlags_CallbackHistory) - { - if (data->EventKey == ImGuiKey_UpArrow) - { - data->DeleteChars(0, data->BufTextLen); - data->InsertChars(0, "Pressed Up!"); - data->SelectAll(); - } - else if (data->EventKey == ImGuiKey_DownArrow) - { - data->DeleteChars(0, data->BufTextLen); - data->InsertChars(0, "Pressed Down!"); - data->SelectAll(); - } - } - else if (data->EventFlag == ImGuiInputTextFlags_CallbackEdit) - { - // Toggle casing of first character - char c = data->Buf[0]; - if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) data->Buf[0] ^= 32; - data->BufDirty = true; - - // Increment a counter - int* p_int = (int*)data->UserData; - *p_int = *p_int + 1; - } - return 0; - } - }; - static char buf1[64]; - ImGui::InputText("Completion", buf1, 64, ImGuiInputTextFlags_CallbackCompletion, Funcs::MyCallback); - ImGui::SameLine(); HelpMarker("Here we append \"..\" each time Tab is pressed. See 'Examples>Console' for a more meaningful demonstration of using this callback."); - - static char buf2[64]; - ImGui::InputText("History", buf2, 64, ImGuiInputTextFlags_CallbackHistory, Funcs::MyCallback); - ImGui::SameLine(); HelpMarker("Here we replace and select text each time Up/Down are pressed. See 'Examples>Console' for a more meaningful demonstration of using this callback."); - - static char buf3[64]; - static int edit_count = 0; - ImGui::InputText("Edit", buf3, 64, ImGuiInputTextFlags_CallbackEdit, Funcs::MyCallback, (void*)&edit_count); - ImGui::SameLine(); HelpMarker("Here we toggle the casing of the first character on every edits + count edits."); - ImGui::SameLine(); ImGui::Text("(%d)", edit_count); - - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Resize Callback")) - { - // To wire InputText() with std::string or any other custom string type, - // you can use the ImGuiInputTextFlags_CallbackResize flag + create a custom ImGui::InputText() wrapper - // using your preferred type. See misc/cpp/imgui_stdlib.h for an implementation of this using std::string. - HelpMarker( - "Using ImGuiInputTextFlags_CallbackResize to wire your custom string type to InputText().\n\n" - "See misc/cpp/imgui_stdlib.h for an implementation of this for std::string."); - struct Funcs - { - static int MyResizeCallback(ImGuiInputTextCallbackData* data) - { - if (data->EventFlag == ImGuiInputTextFlags_CallbackResize) - { - ImVector* my_str = (ImVector*)data->UserData; - IM_ASSERT(my_str->begin() == data->Buf); - my_str->resize(data->BufSize); // NB: On resizing calls, generally data->BufSize == data->BufTextLen + 1 - data->Buf = my_str->begin(); - } - return 0; - } - - // Note: Because ImGui:: is a namespace you would typically add your own function into the namespace. - // For example, you code may declare a function 'ImGui::InputText(const char* label, MyString* my_str)' - static bool MyInputTextMultiline(const char* label, ImVector* my_str, const ImVec2& size = ImVec2(0, 0), ImGuiInputTextFlags flags = 0) - { - IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0); - return ImGui::InputTextMultiline(label, my_str->begin(), (size_t)my_str->size(), size, flags | ImGuiInputTextFlags_CallbackResize, Funcs::MyResizeCallback, (void*)my_str); - } - }; - - // For this demo we are using ImVector as a string container. - // Note that because we need to store a terminating zero character, our size/capacity are 1 more - // than usually reported by a typical string class. - static ImVector my_str; - if (my_str.empty()) - my_str.push_back(0); - Funcs::MyInputTextMultiline("##MyStr", &my_str, ImVec2(-FLT_MIN, ImGui::GetTextLineHeight() * 16)); - ImGui::Text("Data: %p\nSize: %d\nCapacity: %d", (void*)my_str.begin(), my_str.size(), my_str.capacity()); - ImGui::TreePop(); - } - - ImGui::TreePop(); - } - - // Tabs - if (ImGui::TreeNode("Tabs")) - { - if (ImGui::TreeNode("Basic")) - { - ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_None; - if (ImGui::BeginTabBar("MyTabBar", tab_bar_flags)) - { - if (ImGui::BeginTabItem("Avocado")) - { - ImGui::Text("This is the Avocado tab!\nblah blah blah blah blah"); - ImGui::EndTabItem(); - } - if (ImGui::BeginTabItem("Broccoli")) - { - ImGui::Text("This is the Broccoli tab!\nblah blah blah blah blah"); - ImGui::EndTabItem(); - } - if (ImGui::BeginTabItem("Cucumber")) - { - ImGui::Text("This is the Cucumber tab!\nblah blah blah blah blah"); - ImGui::EndTabItem(); - } - ImGui::EndTabBar(); - } - ImGui::Separator(); - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Advanced & Close Button")) - { - // Expose a couple of the available flags. In most cases you may just call BeginTabBar() with no flags (0). - static ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_Reorderable; - ImGui::CheckboxFlags("ImGuiTabBarFlags_Reorderable", &tab_bar_flags, ImGuiTabBarFlags_Reorderable); - ImGui::CheckboxFlags("ImGuiTabBarFlags_AutoSelectNewTabs", &tab_bar_flags, ImGuiTabBarFlags_AutoSelectNewTabs); - ImGui::CheckboxFlags("ImGuiTabBarFlags_TabListPopupButton", &tab_bar_flags, ImGuiTabBarFlags_TabListPopupButton); - ImGui::CheckboxFlags("ImGuiTabBarFlags_NoCloseWithMiddleMouseButton", &tab_bar_flags, ImGuiTabBarFlags_NoCloseWithMiddleMouseButton); - if ((tab_bar_flags & ImGuiTabBarFlags_FittingPolicyMask_) == 0) - tab_bar_flags |= ImGuiTabBarFlags_FittingPolicyDefault_; - if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyResizeDown", &tab_bar_flags, ImGuiTabBarFlags_FittingPolicyResizeDown)) - tab_bar_flags &= ~(ImGuiTabBarFlags_FittingPolicyMask_ ^ ImGuiTabBarFlags_FittingPolicyResizeDown); - if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyScroll", &tab_bar_flags, ImGuiTabBarFlags_FittingPolicyScroll)) - tab_bar_flags &= ~(ImGuiTabBarFlags_FittingPolicyMask_ ^ ImGuiTabBarFlags_FittingPolicyScroll); - - // Tab Bar - const char* names[4] = { "Artichoke", "Beetroot", "Celery", "Daikon" }; - static bool opened[4] = { true, true, true, true }; // Persistent user state - for (int n = 0; n < IM_ARRAYSIZE(opened); n++) - { - if (n > 0) { ImGui::SameLine(); } - ImGui::Checkbox(names[n], &opened[n]); - } - - // Passing a bool* to BeginTabItem() is similar to passing one to Begin(): - // the underlying bool will be set to false when the tab is closed. - if (ImGui::BeginTabBar("MyTabBar", tab_bar_flags)) - { - for (int n = 0; n < IM_ARRAYSIZE(opened); n++) - if (opened[n] && ImGui::BeginTabItem(names[n], &opened[n], ImGuiTabItemFlags_None)) - { - ImGui::Text("This is the %s tab!", names[n]); - if (n & 1) - ImGui::Text("I am an odd tab."); - ImGui::EndTabItem(); - } - ImGui::EndTabBar(); - } - ImGui::Separator(); - ImGui::TreePop(); - } - - if (ImGui::TreeNode("TabItemButton & Leading/Trailing flags")) - { - static ImVector active_tabs; - static int next_tab_id = 0; - if (next_tab_id == 0) // Initialize with some default tabs - for (int i = 0; i < 3; i++) - active_tabs.push_back(next_tab_id++); - - // TabItemButton() and Leading/Trailing flags are distinct features which we will demo together. - // (It is possible to submit regular tabs with Leading/Trailing flags, or TabItemButton tabs without Leading/Trailing flags... - // but they tend to make more sense together) - static bool show_leading_button = true; - static bool show_trailing_button = true; - ImGui::Checkbox("Show Leading TabItemButton()", &show_leading_button); - ImGui::Checkbox("Show Trailing TabItemButton()", &show_trailing_button); - - // Expose some other flags which are useful to showcase how they interact with Leading/Trailing tabs - static ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_AutoSelectNewTabs | ImGuiTabBarFlags_Reorderable | ImGuiTabBarFlags_FittingPolicyResizeDown; - ImGui::CheckboxFlags("ImGuiTabBarFlags_TabListPopupButton", &tab_bar_flags, ImGuiTabBarFlags_TabListPopupButton); - if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyResizeDown", &tab_bar_flags, ImGuiTabBarFlags_FittingPolicyResizeDown)) - tab_bar_flags &= ~(ImGuiTabBarFlags_FittingPolicyMask_ ^ ImGuiTabBarFlags_FittingPolicyResizeDown); - if (ImGui::CheckboxFlags("ImGuiTabBarFlags_FittingPolicyScroll", &tab_bar_flags, ImGuiTabBarFlags_FittingPolicyScroll)) - tab_bar_flags &= ~(ImGuiTabBarFlags_FittingPolicyMask_ ^ ImGuiTabBarFlags_FittingPolicyScroll); - - if (ImGui::BeginTabBar("MyTabBar", tab_bar_flags)) - { - // Demo a Leading TabItemButton(): click the "?" button to open a menu - if (show_leading_button) - if (ImGui::TabItemButton("?", ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_NoTooltip)) - ImGui::OpenPopup("MyHelpMenu"); - if (ImGui::BeginPopup("MyHelpMenu")) - { - ImGui::Selectable("Hello!"); - ImGui::EndPopup(); - } - - // Demo Trailing Tabs: click the "+" button to add a new tab (in your app you may want to use a font icon instead of the "+") - // Note that we submit it before the regular tabs, but because of the ImGuiTabItemFlags_Trailing flag it will always appear at the end. - if (show_trailing_button) - if (ImGui::TabItemButton("+", ImGuiTabItemFlags_Trailing | ImGuiTabItemFlags_NoTooltip)) - active_tabs.push_back(next_tab_id++); // Add new tab - - // Submit our regular tabs - for (int n = 0; n < active_tabs.Size; ) - { - bool open = true; - char name[16]; - snprintf(name, IM_ARRAYSIZE(name), "%04d", active_tabs[n]); - if (ImGui::BeginTabItem(name, &open, ImGuiTabItemFlags_None)) - { - ImGui::Text("This is the %s tab!", name); - ImGui::EndTabItem(); - } - - if (!open) - active_tabs.erase(active_tabs.Data + n); - else - n++; - } - - ImGui::EndTabBar(); - } - ImGui::Separator(); - ImGui::TreePop(); - } - ImGui::TreePop(); - } - - // Plot/Graph widgets are not very good. - // Consider using a third-party library such as ImPlot: https://github.com/epezent/implot - // (see others https://github.com/ocornut/imgui/wiki/Useful-Extensions) - if (ImGui::TreeNode("Plots Widgets")) - { - static bool animate = true; - ImGui::Checkbox("Animate", &animate); - - // Plot as lines and plot as histogram - static float arr[] = { 0.6f, 0.1f, 1.0f, 0.5f, 0.92f, 0.1f, 0.2f }; - ImGui::PlotLines("Frame Times", arr, IM_ARRAYSIZE(arr)); - ImGui::PlotHistogram("Histogram", arr, IM_ARRAYSIZE(arr), 0, NULL, 0.0f, 1.0f, ImVec2(0, 80.0f)); - - // Fill an array of contiguous float values to plot - // Tip: If your float aren't contiguous but part of a structure, you can pass a pointer to your first float - // and the sizeof() of your structure in the "stride" parameter. - static float values[90] = {}; - static int values_offset = 0; - static double refresh_time = 0.0; - if (!animate || refresh_time == 0.0) - refresh_time = ImGui::GetTime(); - while (refresh_time < ImGui::GetTime()) // Create data at fixed 60 Hz rate for the demo - { - static float phase = 0.0f; - values[values_offset] = cosf(phase); - values_offset = (values_offset + 1) % IM_ARRAYSIZE(values); - phase += 0.10f * values_offset; - refresh_time += 1.0f / 60.0f; - } - - // Plots can display overlay texts - // (in this example, we will display an average value) - { - float average = 0.0f; - for (int n = 0; n < IM_ARRAYSIZE(values); n++) - average += values[n]; - average /= (float)IM_ARRAYSIZE(values); - char overlay[32]; - sprintf(overlay, "avg %f", average); - ImGui::PlotLines("Lines", values, IM_ARRAYSIZE(values), values_offset, overlay, -1.0f, 1.0f, ImVec2(0, 80.0f)); - } - - // Use functions to generate output - // FIXME: This is rather awkward because current plot API only pass in indices. - // We probably want an API passing floats and user provide sample rate/count. - struct Funcs - { - static float Sin(void*, int i) { return sinf(i * 0.1f); } - static float Saw(void*, int i) { return (i & 1) ? 1.0f : -1.0f; } - }; - static int func_type = 0, display_count = 70; - ImGui::Separator(); - ImGui::SetNextItemWidth(ImGui::GetFontSize() * 8); - ImGui::Combo("func", &func_type, "Sin\0Saw\0"); - ImGui::SameLine(); - ImGui::SliderInt("Sample count", &display_count, 1, 400); - float (*func)(void*, int) = (func_type == 0) ? Funcs::Sin : Funcs::Saw; - ImGui::PlotLines("Lines", func, NULL, display_count, 0, NULL, -1.0f, 1.0f, ImVec2(0, 80)); - ImGui::PlotHistogram("Histogram", func, NULL, display_count, 0, NULL, -1.0f, 1.0f, ImVec2(0, 80)); - ImGui::Separator(); - - // Animate a simple progress bar - static float progress = 0.0f, progress_dir = 1.0f; - if (animate) - { - progress += progress_dir * 0.4f * ImGui::GetIO().DeltaTime; - if (progress >= +1.1f) { progress = +1.1f; progress_dir *= -1.0f; } - if (progress <= -0.1f) { progress = -0.1f; progress_dir *= -1.0f; } - } - - // Typically we would use ImVec2(-1.0f,0.0f) or ImVec2(-FLT_MIN,0.0f) to use all available width, - // or ImVec2(width,0.0f) for a specified width. ImVec2(0.0f,0.0f) uses ItemWidth. - ImGui::ProgressBar(progress, ImVec2(0.0f, 0.0f)); - ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x); - ImGui::Text("Progress Bar"); - - float progress_saturated = IM_CLAMP(progress, 0.0f, 1.0f); - char buf[32]; - sprintf(buf, "%d/%d", (int)(progress_saturated * 1753), 1753); - ImGui::ProgressBar(progress, ImVec2(0.f, 0.f), buf); - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Color/Picker Widgets")) - { - static ImVec4 color = ImVec4(114.0f / 255.0f, 144.0f / 255.0f, 154.0f / 255.0f, 200.0f / 255.0f); - - static bool alpha_preview = true; - static bool alpha_half_preview = false; - static bool drag_and_drop = true; - static bool options_menu = true; - static bool hdr = false; - ImGui::Checkbox("With Alpha Preview", &alpha_preview); - ImGui::Checkbox("With Half Alpha Preview", &alpha_half_preview); - ImGui::Checkbox("With Drag and Drop", &drag_and_drop); - ImGui::Checkbox("With Options Menu", &options_menu); ImGui::SameLine(); HelpMarker("Right-click on the individual color widget to show options."); - ImGui::Checkbox("With HDR", &hdr); ImGui::SameLine(); HelpMarker("Currently all this does is to lift the 0..1 limits on dragging widgets."); - ImGuiColorEditFlags misc_flags = (hdr ? ImGuiColorEditFlags_HDR : 0) | (drag_and_drop ? 0 : ImGuiColorEditFlags_NoDragDrop) | (alpha_half_preview ? ImGuiColorEditFlags_AlphaPreviewHalf : (alpha_preview ? ImGuiColorEditFlags_AlphaPreview : 0)) | (options_menu ? 0 : ImGuiColorEditFlags_NoOptions); - - ImGui::Text("Color widget:"); - ImGui::SameLine(); HelpMarker( - "Click on the color square to open a color picker.\n" - "CTRL+click on individual component to input value.\n"); - ImGui::ColorEdit3("MyColor##1", (float*)&color, misc_flags); - - ImGui::Text("Color widget HSV with Alpha:"); - ImGui::ColorEdit4("MyColor##2", (float*)&color, ImGuiColorEditFlags_DisplayHSV | misc_flags); - - ImGui::Text("Color widget with Float Display:"); - ImGui::ColorEdit4("MyColor##2f", (float*)&color, ImGuiColorEditFlags_Float | misc_flags); - - ImGui::Text("Color button with Picker:"); - ImGui::SameLine(); HelpMarker( - "With the ImGuiColorEditFlags_NoInputs flag you can hide all the slider/text inputs.\n" - "With the ImGuiColorEditFlags_NoLabel flag you can pass a non-empty label which will only " - "be used for the tooltip and picker popup."); - ImGui::ColorEdit4("MyColor##3", (float*)&color, ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoLabel | misc_flags); - - ImGui::Text("Color button with Custom Picker Popup:"); - - // Generate a default palette. The palette will persist and can be edited. - static bool saved_palette_init = true; - static ImVec4 saved_palette[32] = {}; - if (saved_palette_init) - { - for (int n = 0; n < IM_ARRAYSIZE(saved_palette); n++) - { - ImGui::ColorConvertHSVtoRGB(n / 31.0f, 0.8f, 0.8f, - saved_palette[n].x, saved_palette[n].y, saved_palette[n].z); - saved_palette[n].w = 1.0f; // Alpha - } - saved_palette_init = false; - } - - static ImVec4 backup_color; - bool open_popup = ImGui::ColorButton("MyColor##3b", color, misc_flags); - ImGui::SameLine(0, ImGui::GetStyle().ItemInnerSpacing.x); - open_popup |= ImGui::Button("Palette"); - if (open_popup) - { - ImGui::OpenPopup("mypicker"); - backup_color = color; - } - if (ImGui::BeginPopup("mypicker")) - { - ImGui::Text("MY CUSTOM COLOR PICKER WITH AN AMAZING PALETTE!"); - ImGui::Separator(); - ImGui::ColorPicker4("##picker", (float*)&color, misc_flags | ImGuiColorEditFlags_NoSidePreview | ImGuiColorEditFlags_NoSmallPreview); - ImGui::SameLine(); - - ImGui::BeginGroup(); // Lock X position - ImGui::Text("Current"); - ImGui::ColorButton("##current", color, ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_AlphaPreviewHalf, ImVec2(60, 40)); - ImGui::Text("Previous"); - if (ImGui::ColorButton("##previous", backup_color, ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_AlphaPreviewHalf, ImVec2(60, 40))) - color = backup_color; - ImGui::Separator(); - ImGui::Text("Palette"); - for (int n = 0; n < IM_ARRAYSIZE(saved_palette); n++) - { - ImGui::PushID(n); - if ((n % 8) != 0) - ImGui::SameLine(0.0f, ImGui::GetStyle().ItemSpacing.y); - - ImGuiColorEditFlags palette_button_flags = ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoPicker | ImGuiColorEditFlags_NoTooltip; - if (ImGui::ColorButton("##palette", saved_palette[n], palette_button_flags, ImVec2(20, 20))) - color = ImVec4(saved_palette[n].x, saved_palette[n].y, saved_palette[n].z, color.w); // Preserve alpha! - - // Allow user to drop colors into each palette entry. Note that ColorButton() is already a - // drag source by default, unless specifying the ImGuiColorEditFlags_NoDragDrop flag. - if (ImGui::BeginDragDropTarget()) - { - if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_3F)) - memcpy((float*)&saved_palette[n], payload->Data, sizeof(float) * 3); - if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F)) - memcpy((float*)&saved_palette[n], payload->Data, sizeof(float) * 4); - ImGui::EndDragDropTarget(); - } - - ImGui::PopID(); - } - ImGui::EndGroup(); - ImGui::EndPopup(); - } - - ImGui::Text("Color button only:"); - static bool no_border = false; - ImGui::Checkbox("ImGuiColorEditFlags_NoBorder", &no_border); - ImGui::ColorButton("MyColor##3c", *(ImVec4*)&color, misc_flags | (no_border ? ImGuiColorEditFlags_NoBorder : 0), ImVec2(80, 80)); - - ImGui::Text("Color picker:"); - static bool alpha = true; - static bool alpha_bar = true; - static bool side_preview = true; - static bool ref_color = false; - static ImVec4 ref_color_v(1.0f, 0.0f, 1.0f, 0.5f); - static int display_mode = 0; - static int picker_mode = 0; - ImGui::Checkbox("With Alpha", &alpha); - ImGui::Checkbox("With Alpha Bar", &alpha_bar); - ImGui::Checkbox("With Side Preview", &side_preview); - if (side_preview) - { - ImGui::SameLine(); - ImGui::Checkbox("With Ref Color", &ref_color); - if (ref_color) - { - ImGui::SameLine(); - ImGui::ColorEdit4("##RefColor", &ref_color_v.x, ImGuiColorEditFlags_NoInputs | misc_flags); - } - } - ImGui::Combo("Display Mode", &display_mode, "Auto/Current\0None\0RGB Only\0HSV Only\0Hex Only\0"); - ImGui::SameLine(); HelpMarker( - "ColorEdit defaults to displaying RGB inputs if you don't specify a display mode, " - "but the user can change it with a right-click.\n\nColorPicker defaults to displaying RGB+HSV+Hex " - "if you don't specify a display mode.\n\nYou can change the defaults using SetColorEditOptions()."); - ImGui::Combo("Picker Mode", &picker_mode, "Auto/Current\0Hue bar + SV rect\0Hue wheel + SV triangle\0"); - ImGui::SameLine(); HelpMarker("User can right-click the picker to change mode."); - ImGuiColorEditFlags flags = misc_flags; - if (!alpha) flags |= ImGuiColorEditFlags_NoAlpha; // This is by default if you call ColorPicker3() instead of ColorPicker4() - if (alpha_bar) flags |= ImGuiColorEditFlags_AlphaBar; - if (!side_preview) flags |= ImGuiColorEditFlags_NoSidePreview; - if (picker_mode == 1) flags |= ImGuiColorEditFlags_PickerHueBar; - if (picker_mode == 2) flags |= ImGuiColorEditFlags_PickerHueWheel; - if (display_mode == 1) flags |= ImGuiColorEditFlags_NoInputs; // Disable all RGB/HSV/Hex displays - if (display_mode == 2) flags |= ImGuiColorEditFlags_DisplayRGB; // Override display mode - if (display_mode == 3) flags |= ImGuiColorEditFlags_DisplayHSV; - if (display_mode == 4) flags |= ImGuiColorEditFlags_DisplayHex; - ImGui::ColorPicker4("MyColor##4", (float*)&color, flags, ref_color ? &ref_color_v.x : NULL); - - ImGui::Text("Set defaults in code:"); - ImGui::SameLine(); HelpMarker( - "SetColorEditOptions() is designed to allow you to set boot-time default.\n" - "We don't have Push/Pop functions because you can force options on a per-widget basis if needed," - "and the user can change non-forced ones with the options menu.\nWe don't have a getter to avoid" - "encouraging you to persistently save values that aren't forward-compatible."); - if (ImGui::Button("Default: Uint8 + HSV + Hue Bar")) - ImGui::SetColorEditOptions(ImGuiColorEditFlags_Uint8 | ImGuiColorEditFlags_DisplayHSV | ImGuiColorEditFlags_PickerHueBar); - if (ImGui::Button("Default: Float + HDR + Hue Wheel")) - ImGui::SetColorEditOptions(ImGuiColorEditFlags_Float | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_PickerHueWheel); - - // HSV encoded support (to avoid RGB<>HSV round trips and singularities when S==0 or V==0) - static ImVec4 color_hsv(0.23f, 1.0f, 1.0f, 1.0f); // Stored as HSV! - ImGui::Spacing(); - ImGui::Text("HSV encoded colors"); - ImGui::SameLine(); HelpMarker( - "By default, colors are given to ColorEdit and ColorPicker in RGB, but ImGuiColorEditFlags_InputHSV" - "allows you to store colors as HSV and pass them to ColorEdit and ColorPicker as HSV. This comes with the" - "added benefit that you can manipulate hue values with the picker even when saturation or value are zero."); - ImGui::Text("Color widget with InputHSV:"); - ImGui::ColorEdit4("HSV shown as RGB##1", (float*)&color_hsv, ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_InputHSV | ImGuiColorEditFlags_Float); - ImGui::ColorEdit4("HSV shown as HSV##1", (float*)&color_hsv, ImGuiColorEditFlags_DisplayHSV | ImGuiColorEditFlags_InputHSV | ImGuiColorEditFlags_Float); - ImGui::DragFloat4("Raw HSV values", (float*)&color_hsv, 0.01f, 0.0f, 1.0f); - - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Drag/Slider Flags")) - { - // Demonstrate using advanced flags for DragXXX and SliderXXX functions. Note that the flags are the same! - static ImGuiSliderFlags flags = ImGuiSliderFlags_None; - ImGui::CheckboxFlags("ImGuiSliderFlags_AlwaysClamp", &flags, ImGuiSliderFlags_AlwaysClamp); - ImGui::SameLine(); HelpMarker("Always clamp value to min/max bounds (if any) when input manually with CTRL+Click."); - ImGui::CheckboxFlags("ImGuiSliderFlags_Logarithmic", &flags, ImGuiSliderFlags_Logarithmic); - ImGui::SameLine(); HelpMarker("Enable logarithmic editing (more precision for small values)."); - ImGui::CheckboxFlags("ImGuiSliderFlags_NoRoundToFormat", &flags, ImGuiSliderFlags_NoRoundToFormat); - ImGui::SameLine(); HelpMarker("Disable rounding underlying value to match precision of the format string (e.g. %.3f values are rounded to those 3 digits)."); - ImGui::CheckboxFlags("ImGuiSliderFlags_NoInput", &flags, ImGuiSliderFlags_NoInput); - ImGui::SameLine(); HelpMarker("Disable CTRL+Click or Enter key allowing to input text directly into the widget."); - - // Drags - static float drag_f = 0.5f; - static int drag_i = 50; - ImGui::Text("Underlying float value: %f", drag_f); - ImGui::DragFloat("DragFloat (0 -> 1)", &drag_f, 0.005f, 0.0f, 1.0f, "%.3f", flags); - ImGui::DragFloat("DragFloat (0 -> +inf)", &drag_f, 0.005f, 0.0f, FLT_MAX, "%.3f", flags); - ImGui::DragFloat("DragFloat (-inf -> 1)", &drag_f, 0.005f, -FLT_MAX, 1.0f, "%.3f", flags); - ImGui::DragFloat("DragFloat (-inf -> +inf)", &drag_f, 0.005f, -FLT_MAX, +FLT_MAX, "%.3f", flags); - ImGui::DragInt("DragInt (0 -> 100)", &drag_i, 0.5f, 0, 100, "%d", flags); - - // Sliders - static float slider_f = 0.5f; - static int slider_i = 50; - ImGui::Text("Underlying float value: %f", slider_f); - ImGui::SliderFloat("SliderFloat (0 -> 1)", &slider_f, 0.0f, 1.0f, "%.3f", flags); - ImGui::SliderInt("SliderInt (0 -> 100)", &slider_i, 0, 100, "%d", flags); - - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Range Widgets")) - { - static float begin = 10, end = 90; - static int begin_i = 100, end_i = 1000; - ImGui::DragFloatRange2("range float", &begin, &end, 0.25f, 0.0f, 100.0f, "Min: %.1f %%", "Max: %.1f %%", ImGuiSliderFlags_AlwaysClamp); - ImGui::DragIntRange2("range int", &begin_i, &end_i, 5, 0, 1000, "Min: %d units", "Max: %d units"); - ImGui::DragIntRange2("range int (no bounds)", &begin_i, &end_i, 5, 0, 0, "Min: %d units", "Max: %d units"); - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Data Types")) - { - // DragScalar/InputScalar/SliderScalar functions allow various data types - // - signed/unsigned - // - 8/16/32/64-bits - // - integer/float/double - // To avoid polluting the public API with all possible combinations, we use the ImGuiDataType enum - // to pass the type, and passing all arguments by pointer. - // This is the reason the test code below creates local variables to hold "zero" "one" etc. for each types. - // In practice, if you frequently use a given type that is not covered by the normal API entry points, - // you can wrap it yourself inside a 1 line function which can take typed argument as value instead of void*, - // and then pass their address to the generic function. For example: - // bool MySliderU64(const char *label, u64* value, u64 min = 0, u64 max = 0, const char* format = "%lld") - // { - // return SliderScalar(label, ImGuiDataType_U64, value, &min, &max, format); - // } - - // Setup limits (as helper variables so we can take their address, as explained above) - // Note: SliderScalar() functions have a maximum usable range of half the natural type maximum, hence the /2. - #ifndef LLONG_MIN - ImS64 LLONG_MIN = -9223372036854775807LL - 1; - ImS64 LLONG_MAX = 9223372036854775807LL; - ImU64 ULLONG_MAX = (2ULL * 9223372036854775807LL + 1); - #endif - const char s8_zero = 0, s8_one = 1, s8_fifty = 50, s8_min = -128, s8_max = 127; - const ImU8 u8_zero = 0, u8_one = 1, u8_fifty = 50, u8_min = 0, u8_max = 255; - const short s16_zero = 0, s16_one = 1, s16_fifty = 50, s16_min = -32768, s16_max = 32767; - const ImU16 u16_zero = 0, u16_one = 1, u16_fifty = 50, u16_min = 0, u16_max = 65535; - const ImS32 s32_zero = 0, s32_one = 1, s32_fifty = 50, s32_min = INT_MIN/2, s32_max = INT_MAX/2, s32_hi_a = INT_MAX/2 - 100, s32_hi_b = INT_MAX/2; - const ImU32 u32_zero = 0, u32_one = 1, u32_fifty = 50, u32_min = 0, u32_max = UINT_MAX/2, u32_hi_a = UINT_MAX/2 - 100, u32_hi_b = UINT_MAX/2; - const ImS64 s64_zero = 0, s64_one = 1, s64_fifty = 50, s64_min = LLONG_MIN/2, s64_max = LLONG_MAX/2, s64_hi_a = LLONG_MAX/2 - 100, s64_hi_b = LLONG_MAX/2; - const ImU64 u64_zero = 0, u64_one = 1, u64_fifty = 50, u64_min = 0, u64_max = ULLONG_MAX/2, u64_hi_a = ULLONG_MAX/2 - 100, u64_hi_b = ULLONG_MAX/2; - const float f32_zero = 0.f, f32_one = 1.f, f32_lo_a = -10000000000.0f, f32_hi_a = +10000000000.0f; - const double f64_zero = 0., f64_one = 1., f64_lo_a = -1000000000000000.0, f64_hi_a = +1000000000000000.0; - - // State - static char s8_v = 127; - static ImU8 u8_v = 255; - static short s16_v = 32767; - static ImU16 u16_v = 65535; - static ImS32 s32_v = -1; - static ImU32 u32_v = (ImU32)-1; - static ImS64 s64_v = -1; - static ImU64 u64_v = (ImU64)-1; - static float f32_v = 0.123f; - static double f64_v = 90000.01234567890123456789; - - const float drag_speed = 0.2f; - static bool drag_clamp = false; - ImGui::Text("Drags:"); - ImGui::Checkbox("Clamp integers to 0..50", &drag_clamp); - ImGui::SameLine(); HelpMarker( - "As with every widgets in dear imgui, we never modify values unless there is a user interaction.\n" - "You can override the clamping limits by using CTRL+Click to input a value."); - ImGui::DragScalar("drag s8", ImGuiDataType_S8, &s8_v, drag_speed, drag_clamp ? &s8_zero : NULL, drag_clamp ? &s8_fifty : NULL); - ImGui::DragScalar("drag u8", ImGuiDataType_U8, &u8_v, drag_speed, drag_clamp ? &u8_zero : NULL, drag_clamp ? &u8_fifty : NULL, "%u ms"); - ImGui::DragScalar("drag s16", ImGuiDataType_S16, &s16_v, drag_speed, drag_clamp ? &s16_zero : NULL, drag_clamp ? &s16_fifty : NULL); - ImGui::DragScalar("drag u16", ImGuiDataType_U16, &u16_v, drag_speed, drag_clamp ? &u16_zero : NULL, drag_clamp ? &u16_fifty : NULL, "%u ms"); - ImGui::DragScalar("drag s32", ImGuiDataType_S32, &s32_v, drag_speed, drag_clamp ? &s32_zero : NULL, drag_clamp ? &s32_fifty : NULL); - ImGui::DragScalar("drag u32", ImGuiDataType_U32, &u32_v, drag_speed, drag_clamp ? &u32_zero : NULL, drag_clamp ? &u32_fifty : NULL, "%u ms"); - ImGui::DragScalar("drag s64", ImGuiDataType_S64, &s64_v, drag_speed, drag_clamp ? &s64_zero : NULL, drag_clamp ? &s64_fifty : NULL); - ImGui::DragScalar("drag u64", ImGuiDataType_U64, &u64_v, drag_speed, drag_clamp ? &u64_zero : NULL, drag_clamp ? &u64_fifty : NULL); - ImGui::DragScalar("drag float", ImGuiDataType_Float, &f32_v, 0.005f, &f32_zero, &f32_one, "%f"); - ImGui::DragScalar("drag float log", ImGuiDataType_Float, &f32_v, 0.005f, &f32_zero, &f32_one, "%f", ImGuiSliderFlags_Logarithmic); - ImGui::DragScalar("drag double", ImGuiDataType_Double, &f64_v, 0.0005f, &f64_zero, NULL, "%.10f grams"); - ImGui::DragScalar("drag double log",ImGuiDataType_Double, &f64_v, 0.0005f, &f64_zero, &f64_one, "0 < %.10f < 1", ImGuiSliderFlags_Logarithmic); - - ImGui::Text("Sliders"); - ImGui::SliderScalar("slider s8 full", ImGuiDataType_S8, &s8_v, &s8_min, &s8_max, "%d"); - ImGui::SliderScalar("slider u8 full", ImGuiDataType_U8, &u8_v, &u8_min, &u8_max, "%u"); - ImGui::SliderScalar("slider s16 full", ImGuiDataType_S16, &s16_v, &s16_min, &s16_max, "%d"); - ImGui::SliderScalar("slider u16 full", ImGuiDataType_U16, &u16_v, &u16_min, &u16_max, "%u"); - ImGui::SliderScalar("slider s32 low", ImGuiDataType_S32, &s32_v, &s32_zero, &s32_fifty,"%d"); - ImGui::SliderScalar("slider s32 high", ImGuiDataType_S32, &s32_v, &s32_hi_a, &s32_hi_b, "%d"); - ImGui::SliderScalar("slider s32 full", ImGuiDataType_S32, &s32_v, &s32_min, &s32_max, "%d"); - ImGui::SliderScalar("slider u32 low", ImGuiDataType_U32, &u32_v, &u32_zero, &u32_fifty,"%u"); - ImGui::SliderScalar("slider u32 high", ImGuiDataType_U32, &u32_v, &u32_hi_a, &u32_hi_b, "%u"); - ImGui::SliderScalar("slider u32 full", ImGuiDataType_U32, &u32_v, &u32_min, &u32_max, "%u"); - ImGui::SliderScalar("slider s64 low", ImGuiDataType_S64, &s64_v, &s64_zero, &s64_fifty,"%" IM_PRId64); - ImGui::SliderScalar("slider s64 high", ImGuiDataType_S64, &s64_v, &s64_hi_a, &s64_hi_b, "%" IM_PRId64); - ImGui::SliderScalar("slider s64 full", ImGuiDataType_S64, &s64_v, &s64_min, &s64_max, "%" IM_PRId64); - ImGui::SliderScalar("slider u64 low", ImGuiDataType_U64, &u64_v, &u64_zero, &u64_fifty,"%" IM_PRIu64 " ms"); - ImGui::SliderScalar("slider u64 high", ImGuiDataType_U64, &u64_v, &u64_hi_a, &u64_hi_b, "%" IM_PRIu64 " ms"); - ImGui::SliderScalar("slider u64 full", ImGuiDataType_U64, &u64_v, &u64_min, &u64_max, "%" IM_PRIu64 " ms"); - ImGui::SliderScalar("slider float low", ImGuiDataType_Float, &f32_v, &f32_zero, &f32_one); - ImGui::SliderScalar("slider float low log", ImGuiDataType_Float, &f32_v, &f32_zero, &f32_one, "%.10f", ImGuiSliderFlags_Logarithmic); - ImGui::SliderScalar("slider float high", ImGuiDataType_Float, &f32_v, &f32_lo_a, &f32_hi_a, "%e"); - ImGui::SliderScalar("slider double low", ImGuiDataType_Double, &f64_v, &f64_zero, &f64_one, "%.10f grams"); - ImGui::SliderScalar("slider double low log",ImGuiDataType_Double, &f64_v, &f64_zero, &f64_one, "%.10f", ImGuiSliderFlags_Logarithmic); - ImGui::SliderScalar("slider double high", ImGuiDataType_Double, &f64_v, &f64_lo_a, &f64_hi_a, "%e grams"); - - ImGui::Text("Sliders (reverse)"); - ImGui::SliderScalar("slider s8 reverse", ImGuiDataType_S8, &s8_v, &s8_max, &s8_min, "%d"); - ImGui::SliderScalar("slider u8 reverse", ImGuiDataType_U8, &u8_v, &u8_max, &u8_min, "%u"); - ImGui::SliderScalar("slider s32 reverse", ImGuiDataType_S32, &s32_v, &s32_fifty, &s32_zero, "%d"); - ImGui::SliderScalar("slider u32 reverse", ImGuiDataType_U32, &u32_v, &u32_fifty, &u32_zero, "%u"); - ImGui::SliderScalar("slider s64 reverse", ImGuiDataType_S64, &s64_v, &s64_fifty, &s64_zero, "%" IM_PRId64); - ImGui::SliderScalar("slider u64 reverse", ImGuiDataType_U64, &u64_v, &u64_fifty, &u64_zero, "%" IM_PRIu64 " ms"); - - static bool inputs_step = true; - ImGui::Text("Inputs"); - ImGui::Checkbox("Show step buttons", &inputs_step); - ImGui::InputScalar("input s8", ImGuiDataType_S8, &s8_v, inputs_step ? &s8_one : NULL, NULL, "%d"); - ImGui::InputScalar("input u8", ImGuiDataType_U8, &u8_v, inputs_step ? &u8_one : NULL, NULL, "%u"); - ImGui::InputScalar("input s16", ImGuiDataType_S16, &s16_v, inputs_step ? &s16_one : NULL, NULL, "%d"); - ImGui::InputScalar("input u16", ImGuiDataType_U16, &u16_v, inputs_step ? &u16_one : NULL, NULL, "%u"); - ImGui::InputScalar("input s32", ImGuiDataType_S32, &s32_v, inputs_step ? &s32_one : NULL, NULL, "%d"); - ImGui::InputScalar("input s32 hex", ImGuiDataType_S32, &s32_v, inputs_step ? &s32_one : NULL, NULL, "%08X", ImGuiInputTextFlags_CharsHexadecimal); - ImGui::InputScalar("input u32", ImGuiDataType_U32, &u32_v, inputs_step ? &u32_one : NULL, NULL, "%u"); - ImGui::InputScalar("input u32 hex", ImGuiDataType_U32, &u32_v, inputs_step ? &u32_one : NULL, NULL, "%08X", ImGuiInputTextFlags_CharsHexadecimal); - ImGui::InputScalar("input s64", ImGuiDataType_S64, &s64_v, inputs_step ? &s64_one : NULL); - ImGui::InputScalar("input u64", ImGuiDataType_U64, &u64_v, inputs_step ? &u64_one : NULL); - ImGui::InputScalar("input float", ImGuiDataType_Float, &f32_v, inputs_step ? &f32_one : NULL); - ImGui::InputScalar("input double", ImGuiDataType_Double, &f64_v, inputs_step ? &f64_one : NULL); - - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Multi-component Widgets")) - { - static float vec4f[4] = { 0.10f, 0.20f, 0.30f, 0.44f }; - static int vec4i[4] = { 1, 5, 100, 255 }; - - ImGui::InputFloat2("input float2", vec4f); - ImGui::DragFloat2("drag float2", vec4f, 0.01f, 0.0f, 1.0f); - ImGui::SliderFloat2("slider float2", vec4f, 0.0f, 1.0f); - ImGui::InputInt2("input int2", vec4i); - ImGui::DragInt2("drag int2", vec4i, 1, 0, 255); - ImGui::SliderInt2("slider int2", vec4i, 0, 255); - ImGui::Spacing(); - - ImGui::InputFloat3("input float3", vec4f); - ImGui::DragFloat3("drag float3", vec4f, 0.01f, 0.0f, 1.0f); - ImGui::SliderFloat3("slider float3", vec4f, 0.0f, 1.0f); - ImGui::InputInt3("input int3", vec4i); - ImGui::DragInt3("drag int3", vec4i, 1, 0, 255); - ImGui::SliderInt3("slider int3", vec4i, 0, 255); - ImGui::Spacing(); - - ImGui::InputFloat4("input float4", vec4f); - ImGui::DragFloat4("drag float4", vec4f, 0.01f, 0.0f, 1.0f); - ImGui::SliderFloat4("slider float4", vec4f, 0.0f, 1.0f); - ImGui::InputInt4("input int4", vec4i); - ImGui::DragInt4("drag int4", vec4i, 1, 0, 255); - ImGui::SliderInt4("slider int4", vec4i, 0, 255); - - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Vertical Sliders")) - { - const float spacing = 4; - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(spacing, spacing)); - - static int int_value = 0; - ImGui::VSliderInt("##int", ImVec2(18, 160), &int_value, 0, 5); - ImGui::SameLine(); - - static float values[7] = { 0.0f, 0.60f, 0.35f, 0.9f, 0.70f, 0.20f, 0.0f }; - ImGui::PushID("set1"); - for (int i = 0; i < 7; i++) - { - if (i > 0) ImGui::SameLine(); - ImGui::PushID(i); - ImGui::PushStyleColor(ImGuiCol_FrameBg, (ImVec4)ImColor::HSV(i / 7.0f, 0.5f, 0.5f)); - ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, (ImVec4)ImColor::HSV(i / 7.0f, 0.6f, 0.5f)); - ImGui::PushStyleColor(ImGuiCol_FrameBgActive, (ImVec4)ImColor::HSV(i / 7.0f, 0.7f, 0.5f)); - ImGui::PushStyleColor(ImGuiCol_SliderGrab, (ImVec4)ImColor::HSV(i / 7.0f, 0.9f, 0.9f)); - ImGui::VSliderFloat("##v", ImVec2(18, 160), &values[i], 0.0f, 1.0f, ""); - if (ImGui::IsItemActive() || ImGui::IsItemHovered()) - ImGui::SetTooltip("%.3f", values[i]); - ImGui::PopStyleColor(4); - ImGui::PopID(); - } - ImGui::PopID(); - - ImGui::SameLine(); - ImGui::PushID("set2"); - static float values2[4] = { 0.20f, 0.80f, 0.40f, 0.25f }; - const int rows = 3; - const ImVec2 small_slider_size(18, (float)(int)((160.0f - (rows - 1) * spacing) / rows)); - for (int nx = 0; nx < 4; nx++) - { - if (nx > 0) ImGui::SameLine(); - ImGui::BeginGroup(); - for (int ny = 0; ny < rows; ny++) - { - ImGui::PushID(nx * rows + ny); - ImGui::VSliderFloat("##v", small_slider_size, &values2[nx], 0.0f, 1.0f, ""); - if (ImGui::IsItemActive() || ImGui::IsItemHovered()) - ImGui::SetTooltip("%.3f", values2[nx]); - ImGui::PopID(); - } - ImGui::EndGroup(); - } - ImGui::PopID(); - - ImGui::SameLine(); - ImGui::PushID("set3"); - for (int i = 0; i < 4; i++) - { - if (i > 0) ImGui::SameLine(); - ImGui::PushID(i); - ImGui::PushStyleVar(ImGuiStyleVar_GrabMinSize, 40); - ImGui::VSliderFloat("##v", ImVec2(40, 160), &values[i], 0.0f, 1.0f, "%.2f\nsec"); - ImGui::PopStyleVar(); - ImGui::PopID(); - } - ImGui::PopID(); - ImGui::PopStyleVar(); - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Drag and Drop")) - { - if (ImGui::TreeNode("Drag and drop in standard widgets")) - { - // ColorEdit widgets automatically act as drag source and drag target. - // They are using standardized payload strings IMGUI_PAYLOAD_TYPE_COLOR_3F and IMGUI_PAYLOAD_TYPE_COLOR_4F - // to allow your own widgets to use colors in their drag and drop interaction. - // Also see 'Demo->Widgets->Color/Picker Widgets->Palette' demo. - HelpMarker("You can drag from the color squares."); - static float col1[3] = { 1.0f, 0.0f, 0.2f }; - static float col2[4] = { 0.4f, 0.7f, 0.0f, 0.5f }; - ImGui::ColorEdit3("color 1", col1); - ImGui::ColorEdit4("color 2", col2); - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Drag and drop to copy/swap items")) - { - enum Mode - { - Mode_Copy, - Mode_Move, - Mode_Swap - }; - static int mode = 0; - if (ImGui::RadioButton("Copy", mode == Mode_Copy)) { mode = Mode_Copy; } ImGui::SameLine(); - if (ImGui::RadioButton("Move", mode == Mode_Move)) { mode = Mode_Move; } ImGui::SameLine(); - if (ImGui::RadioButton("Swap", mode == Mode_Swap)) { mode = Mode_Swap; } - static const char* names[9] = - { - "Bobby", "Beatrice", "Betty", - "Brianna", "Barry", "Bernard", - "Bibi", "Blaine", "Bryn" - }; - for (int n = 0; n < IM_ARRAYSIZE(names); n++) - { - ImGui::PushID(n); - if ((n % 3) != 0) - ImGui::SameLine(); - ImGui::Button(names[n], ImVec2(60, 60)); - - // Our buttons are both drag sources and drag targets here! - if (ImGui::BeginDragDropSource(ImGuiDragDropFlags_None)) - { - // Set payload to carry the index of our item (could be anything) - ImGui::SetDragDropPayload("DND_DEMO_CELL", &n, sizeof(int)); - - // Display preview (could be anything, e.g. when dragging an image we could decide to display - // the filename and a small preview of the image, etc.) - if (mode == Mode_Copy) { ImGui::Text("Copy %s", names[n]); } - if (mode == Mode_Move) { ImGui::Text("Move %s", names[n]); } - if (mode == Mode_Swap) { ImGui::Text("Swap %s", names[n]); } - ImGui::EndDragDropSource(); - } - if (ImGui::BeginDragDropTarget()) - { - if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("DND_DEMO_CELL")) - { - IM_ASSERT(payload->DataSize == sizeof(int)); - int payload_n = *(const int*)payload->Data; - if (mode == Mode_Copy) - { - names[n] = names[payload_n]; - } - if (mode == Mode_Move) - { - names[n] = names[payload_n]; - names[payload_n] = ""; - } - if (mode == Mode_Swap) - { - const char* tmp = names[n]; - names[n] = names[payload_n]; - names[payload_n] = tmp; - } - } - ImGui::EndDragDropTarget(); - } - ImGui::PopID(); - } - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Drag to reorder items (simple)")) - { - // Simple reordering - HelpMarker( - "We don't use the drag and drop api at all here! " - "Instead we query when the item is held but not hovered, and order items accordingly."); - static const char* item_names[] = { "Item One", "Item Two", "Item Three", "Item Four", "Item Five" }; - for (int n = 0; n < IM_ARRAYSIZE(item_names); n++) - { - const char* item = item_names[n]; - ImGui::Selectable(item); - - if (ImGui::IsItemActive() && !ImGui::IsItemHovered()) - { - int n_next = n + (ImGui::GetMouseDragDelta(0).y < 0.f ? -1 : 1); - if (n_next >= 0 && n_next < IM_ARRAYSIZE(item_names)) - { - item_names[n] = item_names[n_next]; - item_names[n_next] = item; - ImGui::ResetMouseDragDelta(); - } - } - } - ImGui::TreePop(); - } - - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Querying Item Status (Edited/Active/Hovered etc.)")) - { - // Select an item type - const char* item_names[] = - { - "Text", "Button", "Button (w/ repeat)", "Checkbox", "SliderFloat", "InputText", "InputFloat", - "InputFloat3", "ColorEdit4", "Selectable", "MenuItem", "TreeNode", "TreeNode (w/ double-click)", "Combo", "ListBox" - }; - static int item_type = 4; - static bool item_disabled = false; - ImGui::Combo("Item Type", &item_type, item_names, IM_ARRAYSIZE(item_names), IM_ARRAYSIZE(item_names)); - ImGui::SameLine(); - HelpMarker("Testing how various types of items are interacting with the IsItemXXX functions. Note that the bool return value of most ImGui function is generally equivalent to calling ImGui::IsItemHovered()."); - ImGui::Checkbox("Item Disabled", &item_disabled); - - // Submit selected item item so we can query their status in the code following it. - bool ret = false; - static bool b = false; - static float col4f[4] = { 1.0f, 0.5, 0.0f, 1.0f }; - static char str[16] = {}; - if (item_disabled) - ImGui::BeginDisabled(true); - if (item_type == 0) { ImGui::Text("ITEM: Text"); } // Testing text items with no identifier/interaction - if (item_type == 1) { ret = ImGui::Button("ITEM: Button"); } // Testing button - if (item_type == 2) { ImGui::PushButtonRepeat(true); ret = ImGui::Button("ITEM: Button"); ImGui::PopButtonRepeat(); } // Testing button (with repeater) - if (item_type == 3) { ret = ImGui::Checkbox("ITEM: Checkbox", &b); } // Testing checkbox - if (item_type == 4) { ret = ImGui::SliderFloat("ITEM: SliderFloat", &col4f[0], 0.0f, 1.0f); } // Testing basic item - if (item_type == 5) { ret = ImGui::InputText("ITEM: InputText", &str[0], IM_ARRAYSIZE(str)); } // Testing input text (which handles tabbing) - if (item_type == 6) { ret = ImGui::InputFloat("ITEM: InputFloat", col4f, 1.0f); } // Testing +/- buttons on scalar input - if (item_type == 7) { ret = ImGui::InputFloat3("ITEM: InputFloat3", col4f); } // Testing multi-component items (IsItemXXX flags are reported merged) - if (item_type == 8) { ret = ImGui::ColorEdit4("ITEM: ColorEdit4", col4f); } // Testing multi-component items (IsItemXXX flags are reported merged) - if (item_type == 9) { ret = ImGui::Selectable("ITEM: Selectable"); } // Testing selectable item - if (item_type == 10){ ret = ImGui::MenuItem("ITEM: MenuItem"); } // Testing menu item (they use ImGuiButtonFlags_PressedOnRelease button policy) - if (item_type == 11){ ret = ImGui::TreeNode("ITEM: TreeNode"); if (ret) ImGui::TreePop(); } // Testing tree node - if (item_type == 12){ ret = ImGui::TreeNodeEx("ITEM: TreeNode w/ ImGuiTreeNodeFlags_OpenOnDoubleClick", ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_NoTreePushOnOpen); } // Testing tree node with ImGuiButtonFlags_PressedOnDoubleClick button policy. - if (item_type == 13){ const char* items[] = { "Apple", "Banana", "Cherry", "Kiwi" }; static int current = 1; ret = ImGui::Combo("ITEM: Combo", ¤t, items, IM_ARRAYSIZE(items)); } - if (item_type == 14){ const char* items[] = { "Apple", "Banana", "Cherry", "Kiwi" }; static int current = 1; ret = ImGui::ListBox("ITEM: ListBox", ¤t, items, IM_ARRAYSIZE(items), IM_ARRAYSIZE(items)); } - - // Display the values of IsItemHovered() and other common item state functions. - // Note that the ImGuiHoveredFlags_XXX flags can be combined. - // Because BulletText is an item itself and that would affect the output of IsItemXXX functions, - // we query every state in a single call to avoid storing them and to simplify the code. - ImGui::BulletText( - "Return value = %d\n" - "IsItemFocused() = %d\n" - "IsItemHovered() = %d\n" - "IsItemHovered(_AllowWhenBlockedByPopup) = %d\n" - "IsItemHovered(_AllowWhenBlockedByActiveItem) = %d\n" - "IsItemHovered(_AllowWhenOverlapped) = %d\n" - "IsItemHovered(_AllowWhenDisabled) = %d\n" - "IsItemHovered(_RectOnly) = %d\n" - "IsItemActive() = %d\n" - "IsItemEdited() = %d\n" - "IsItemActivated() = %d\n" - "IsItemDeactivated() = %d\n" - "IsItemDeactivatedAfterEdit() = %d\n" - "IsItemVisible() = %d\n" - "IsItemClicked() = %d\n" - "IsItemToggledOpen() = %d\n" - "GetItemRectMin() = (%.1f, %.1f)\n" - "GetItemRectMax() = (%.1f, %.1f)\n" - "GetItemRectSize() = (%.1f, %.1f)", - ret, - ImGui::IsItemFocused(), - ImGui::IsItemHovered(), - ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup), - ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem), - ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenOverlapped), - ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled), - ImGui::IsItemHovered(ImGuiHoveredFlags_RectOnly), - ImGui::IsItemActive(), - ImGui::IsItemEdited(), - ImGui::IsItemActivated(), - ImGui::IsItemDeactivated(), - ImGui::IsItemDeactivatedAfterEdit(), - ImGui::IsItemVisible(), - ImGui::IsItemClicked(), - ImGui::IsItemToggledOpen(), - ImGui::GetItemRectMin().x, ImGui::GetItemRectMin().y, - ImGui::GetItemRectMax().x, ImGui::GetItemRectMax().y, - ImGui::GetItemRectSize().x, ImGui::GetItemRectSize().y - ); - - if (item_disabled) - ImGui::EndDisabled(); - - char buf[1] = ""; - ImGui::InputText("unused", buf, IM_ARRAYSIZE(buf), ImGuiInputTextFlags_ReadOnly); - ImGui::SameLine(); - HelpMarker("This widget is only here to be able to tab-out of the widgets above and see e.g. Deactivated() status."); - - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Querying Window Status (Focused/Hovered etc.)")) - { - static bool embed_all_inside_a_child_window = false; - ImGui::Checkbox("Embed everything inside a child window for testing _RootWindow flag.", &embed_all_inside_a_child_window); - if (embed_all_inside_a_child_window) - ImGui::BeginChild("outer_child", ImVec2(0, ImGui::GetFontSize() * 20.0f), true); - - // Testing IsWindowFocused() function with its various flags. - ImGui::BulletText( - "IsWindowFocused() = %d\n" - "IsWindowFocused(_ChildWindows) = %d\n" - "IsWindowFocused(_ChildWindows|_NoPopupHierarchy) = %d\n" - "IsWindowFocused(_ChildWindows|_RootWindow) = %d\n" - "IsWindowFocused(_ChildWindows|_RootWindow|_NoPopupHierarchy) = %d\n" - "IsWindowFocused(_RootWindow) = %d\n" - "IsWindowFocused(_RootWindow|_NoPopupHierarchy) = %d\n" - "IsWindowFocused(_AnyWindow) = %d\n", - ImGui::IsWindowFocused(), - ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows), - ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows | ImGuiFocusedFlags_NoPopupHierarchy), - ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows | ImGuiFocusedFlags_RootWindow), - ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows | ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_NoPopupHierarchy), - ImGui::IsWindowFocused(ImGuiFocusedFlags_RootWindow), - ImGui::IsWindowFocused(ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_NoPopupHierarchy), - ImGui::IsWindowFocused(ImGuiFocusedFlags_AnyWindow)); - - // Testing IsWindowHovered() function with its various flags. - ImGui::BulletText( - "IsWindowHovered() = %d\n" - "IsWindowHovered(_AllowWhenBlockedByPopup) = %d\n" - "IsWindowHovered(_AllowWhenBlockedByActiveItem) = %d\n" - "IsWindowHovered(_ChildWindows) = %d\n" - "IsWindowHovered(_ChildWindows|_NoPopupHierarchy) = %d\n" - "IsWindowHovered(_ChildWindows|_RootWindow) = %d\n" - "IsWindowHovered(_ChildWindows|_RootWindow|_NoPopupHierarchy) = %d\n" - "IsWindowHovered(_RootWindow) = %d\n" - "IsWindowHovered(_RootWindow|_NoPopupHierarchy) = %d\n" - "IsWindowHovered(_ChildWindows|_AllowWhenBlockedByPopup) = %d\n" - "IsWindowHovered(_AnyWindow) = %d\n", - ImGui::IsWindowHovered(), - ImGui::IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup), - ImGui::IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem), - ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows), - ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_NoPopupHierarchy), - ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_RootWindow), - ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_NoPopupHierarchy), - ImGui::IsWindowHovered(ImGuiHoveredFlags_RootWindow), - ImGui::IsWindowHovered(ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_NoPopupHierarchy), - ImGui::IsWindowHovered(ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_AllowWhenBlockedByPopup), - ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow)); - - ImGui::BeginChild("child", ImVec2(0, 50), true); - ImGui::Text("This is another child window for testing the _ChildWindows flag."); - ImGui::EndChild(); - if (embed_all_inside_a_child_window) - ImGui::EndChild(); - - // Calling IsItemHovered() after begin returns the hovered status of the title bar. - // This is useful in particular if you want to create a context menu associated to the title bar of a window. - static bool test_window = false; - ImGui::Checkbox("Hovered/Active tests after Begin() for title bar testing", &test_window); - if (test_window) - { - ImGui::Begin("Title bar Hovered/Active tests", &test_window); - if (ImGui::BeginPopupContextItem()) // <-- This is using IsItemHovered() - { - if (ImGui::MenuItem("Close")) { test_window = false; } - ImGui::EndPopup(); - } - ImGui::Text( - "IsItemHovered() after begin = %d (== is title bar hovered)\n" - "IsItemActive() after begin = %d (== is window being clicked/moved)\n", - ImGui::IsItemHovered(), ImGui::IsItemActive()); - ImGui::End(); - } - - ImGui::TreePop(); - } - - // Demonstrate BeginDisabled/EndDisabled using a checkbox located at the bottom of the section (which is a bit odd: - // logically we'd have this checkbox at the top of the section, but we don't want this feature to steal that space) - if (disable_all) - ImGui::EndDisabled(); - - if (ImGui::TreeNode("Disable block")) - { - ImGui::Checkbox("Disable entire section above", &disable_all); - ImGui::SameLine(); HelpMarker("Demonstrate using BeginDisabled()/EndDisabled() across this section."); - ImGui::TreePop(); - } -} - -static void ShowDemoWindowLayout() -{ - if (!ImGui::CollapsingHeader("Layout & Scrolling")) - return; - - if (ImGui::TreeNode("Child windows")) - { - HelpMarker("Use child windows to begin into a self-contained independent scrolling/clipping regions within a host window."); - static bool disable_mouse_wheel = false; - static bool disable_menu = false; - ImGui::Checkbox("Disable Mouse Wheel", &disable_mouse_wheel); - ImGui::Checkbox("Disable Menu", &disable_menu); - - // Child 1: no border, enable horizontal scrollbar - { - ImGuiWindowFlags window_flags = ImGuiWindowFlags_HorizontalScrollbar; - if (disable_mouse_wheel) - window_flags |= ImGuiWindowFlags_NoScrollWithMouse; - ImGui::BeginChild("ChildL", ImVec2(ImGui::GetContentRegionAvail().x * 0.5f, 260), false, window_flags); - for (int i = 0; i < 100; i++) - ImGui::Text("%04d: scrollable region", i); - ImGui::EndChild(); - } - - ImGui::SameLine(); - - // Child 2: rounded border - { - ImGuiWindowFlags window_flags = ImGuiWindowFlags_None; - if (disable_mouse_wheel) - window_flags |= ImGuiWindowFlags_NoScrollWithMouse; - if (!disable_menu) - window_flags |= ImGuiWindowFlags_MenuBar; - ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f); - ImGui::BeginChild("ChildR", ImVec2(0, 260), true, window_flags); - if (!disable_menu && ImGui::BeginMenuBar()) - { - if (ImGui::BeginMenu("Menu")) - { - ShowExampleMenuFile(); - ImGui::EndMenu(); - } - ImGui::EndMenuBar(); - } - if (ImGui::BeginTable("split", 2, ImGuiTableFlags_Resizable | ImGuiTableFlags_NoSavedSettings)) - { - for (int i = 0; i < 100; i++) - { - char buf[32]; - sprintf(buf, "%03d", i); - ImGui::TableNextColumn(); - ImGui::Button(buf, ImVec2(-FLT_MIN, 0.0f)); - } - ImGui::EndTable(); - } - ImGui::EndChild(); - ImGui::PopStyleVar(); - } - - ImGui::Separator(); - - // Demonstrate a few extra things - // - Changing ImGuiCol_ChildBg (which is transparent black in default styles) - // - Using SetCursorPos() to position child window (the child window is an item from the POV of parent window) - // You can also call SetNextWindowPos() to position the child window. The parent window will effectively - // layout from this position. - // - Using ImGui::GetItemRectMin/Max() to query the "item" state (because the child window is an item from - // the POV of the parent window). See 'Demo->Querying Status (Edited/Active/Hovered etc.)' for details. - { - static int offset_x = 0; - ImGui::SetNextItemWidth(ImGui::GetFontSize() * 8); - ImGui::DragInt("Offset X", &offset_x, 1.0f, -1000, 1000); - - ImGui::SetCursorPosX(ImGui::GetCursorPosX() + (float)offset_x); - ImGui::PushStyleColor(ImGuiCol_ChildBg, IM_COL32(255, 0, 0, 100)); - ImGui::BeginChild("Red", ImVec2(200, 100), true, ImGuiWindowFlags_None); - for (int n = 0; n < 50; n++) - ImGui::Text("Some test %d", n); - ImGui::EndChild(); - bool child_is_hovered = ImGui::IsItemHovered(); - ImVec2 child_rect_min = ImGui::GetItemRectMin(); - ImVec2 child_rect_max = ImGui::GetItemRectMax(); - ImGui::PopStyleColor(); - ImGui::Text("Hovered: %d", child_is_hovered); - ImGui::Text("Rect of child window is: (%.0f,%.0f) (%.0f,%.0f)", child_rect_min.x, child_rect_min.y, child_rect_max.x, child_rect_max.y); - } - - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Widgets Width")) - { - static float f = 0.0f; - static bool show_indented_items = true; - ImGui::Checkbox("Show indented items", &show_indented_items); - - // Use SetNextItemWidth() to set the width of a single upcoming item. - // Use PushItemWidth()/PopItemWidth() to set the width of a group of items. - // In real code use you'll probably want to choose width values that are proportional to your font size - // e.g. Using '20.0f * GetFontSize()' as width instead of '200.0f', etc. - - ImGui::Text("SetNextItemWidth/PushItemWidth(100)"); - ImGui::SameLine(); HelpMarker("Fixed width."); - ImGui::PushItemWidth(100); - ImGui::DragFloat("float##1b", &f); - if (show_indented_items) - { - ImGui::Indent(); - ImGui::DragFloat("float (indented)##1b", &f); - ImGui::Unindent(); - } - ImGui::PopItemWidth(); - - ImGui::Text("SetNextItemWidth/PushItemWidth(-100)"); - ImGui::SameLine(); HelpMarker("Align to right edge minus 100"); - ImGui::PushItemWidth(-100); - ImGui::DragFloat("float##2a", &f); - if (show_indented_items) - { - ImGui::Indent(); - ImGui::DragFloat("float (indented)##2b", &f); - ImGui::Unindent(); - } - ImGui::PopItemWidth(); - - ImGui::Text("SetNextItemWidth/PushItemWidth(GetContentRegionAvail().x * 0.5f)"); - ImGui::SameLine(); HelpMarker("Half of available width.\n(~ right-cursor_pos)\n(works within a column set)"); - ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x * 0.5f); - ImGui::DragFloat("float##3a", &f); - if (show_indented_items) - { - ImGui::Indent(); - ImGui::DragFloat("float (indented)##3b", &f); - ImGui::Unindent(); - } - ImGui::PopItemWidth(); - - ImGui::Text("SetNextItemWidth/PushItemWidth(-GetContentRegionAvail().x * 0.5f)"); - ImGui::SameLine(); HelpMarker("Align to right edge minus half"); - ImGui::PushItemWidth(-ImGui::GetContentRegionAvail().x * 0.5f); - ImGui::DragFloat("float##4a", &f); - if (show_indented_items) - { - ImGui::Indent(); - ImGui::DragFloat("float (indented)##4b", &f); - ImGui::Unindent(); - } - ImGui::PopItemWidth(); - - // Demonstrate using PushItemWidth to surround three items. - // Calling SetNextItemWidth() before each of them would have the same effect. - ImGui::Text("SetNextItemWidth/PushItemWidth(-FLT_MIN)"); - ImGui::SameLine(); HelpMarker("Align to right edge"); - ImGui::PushItemWidth(-FLT_MIN); - ImGui::DragFloat("##float5a", &f); - if (show_indented_items) - { - ImGui::Indent(); - ImGui::DragFloat("float (indented)##5b", &f); - ImGui::Unindent(); - } - ImGui::PopItemWidth(); - - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Basic Horizontal Layout")) - { - ImGui::TextWrapped("(Use ImGui::SameLine() to keep adding items to the right of the preceding item)"); - - // Text - ImGui::Text("Two items: Hello"); ImGui::SameLine(); - ImGui::TextColored(ImVec4(1,1,0,1), "Sailor"); - - // Adjust spacing - ImGui::Text("More spacing: Hello"); ImGui::SameLine(0, 20); - ImGui::TextColored(ImVec4(1,1,0,1), "Sailor"); - - // Button - ImGui::AlignTextToFramePadding(); - ImGui::Text("Normal buttons"); ImGui::SameLine(); - ImGui::Button("Banana"); ImGui::SameLine(); - ImGui::Button("Apple"); ImGui::SameLine(); - ImGui::Button("Corniflower"); - - // Button - ImGui::Text("Small buttons"); ImGui::SameLine(); - ImGui::SmallButton("Like this one"); ImGui::SameLine(); - ImGui::Text("can fit within a text block."); - - // Aligned to arbitrary position. Easy/cheap column. - ImGui::Text("Aligned"); - ImGui::SameLine(150); ImGui::Text("x=150"); - ImGui::SameLine(300); ImGui::Text("x=300"); - ImGui::Text("Aligned"); - ImGui::SameLine(150); ImGui::SmallButton("x=150"); - ImGui::SameLine(300); ImGui::SmallButton("x=300"); - - // Checkbox - static bool c1 = false, c2 = false, c3 = false, c4 = false; - ImGui::Checkbox("My", &c1); ImGui::SameLine(); - ImGui::Checkbox("Tailor", &c2); ImGui::SameLine(); - ImGui::Checkbox("Is", &c3); ImGui::SameLine(); - ImGui::Checkbox("Rich", &c4); - - // Various - static float f0 = 1.0f, f1 = 2.0f, f2 = 3.0f; - ImGui::PushItemWidth(80); - const char* items[] = { "AAAA", "BBBB", "CCCC", "DDDD" }; - static int item = -1; - ImGui::Combo("Combo", &item, items, IM_ARRAYSIZE(items)); ImGui::SameLine(); - ImGui::SliderFloat("X", &f0, 0.0f, 5.0f); ImGui::SameLine(); - ImGui::SliderFloat("Y", &f1, 0.0f, 5.0f); ImGui::SameLine(); - ImGui::SliderFloat("Z", &f2, 0.0f, 5.0f); - ImGui::PopItemWidth(); - - ImGui::PushItemWidth(80); - ImGui::Text("Lists:"); - static int selection[4] = { 0, 1, 2, 3 }; - for (int i = 0; i < 4; i++) - { - if (i > 0) ImGui::SameLine(); - ImGui::PushID(i); - ImGui::ListBox("", &selection[i], items, IM_ARRAYSIZE(items)); - ImGui::PopID(); - //if (ImGui::IsItemHovered()) ImGui::SetTooltip("ListBox %d hovered", i); - } - ImGui::PopItemWidth(); - - // Dummy - ImVec2 button_sz(40, 40); - ImGui::Button("A", button_sz); ImGui::SameLine(); - ImGui::Dummy(button_sz); ImGui::SameLine(); - ImGui::Button("B", button_sz); - - // Manually wrapping - // (we should eventually provide this as an automatic layout feature, but for now you can do it manually) - ImGui::Text("Manually wrapping:"); - ImGuiStyle& style = ImGui::GetStyle(); - int buttons_count = 20; - float window_visible_x2 = ImGui::GetWindowPos().x + ImGui::GetWindowContentRegionMax().x; - for (int n = 0; n < buttons_count; n++) - { - ImGui::PushID(n); - ImGui::Button("Box", button_sz); - float last_button_x2 = ImGui::GetItemRectMax().x; - float next_button_x2 = last_button_x2 + style.ItemSpacing.x + button_sz.x; // Expected position if next button was on same line - if (n + 1 < buttons_count && next_button_x2 < window_visible_x2) - ImGui::SameLine(); - ImGui::PopID(); - } - - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Groups")) - { - HelpMarker( - "BeginGroup() basically locks the horizontal position for new line. " - "EndGroup() bundles the whole group so that you can use \"item\" functions such as " - "IsItemHovered()/IsItemActive() or SameLine() etc. on the whole group."); - ImGui::BeginGroup(); - { - ImGui::BeginGroup(); - ImGui::Button("AAA"); - ImGui::SameLine(); - ImGui::Button("BBB"); - ImGui::SameLine(); - ImGui::BeginGroup(); - ImGui::Button("CCC"); - ImGui::Button("DDD"); - ImGui::EndGroup(); - ImGui::SameLine(); - ImGui::Button("EEE"); - ImGui::EndGroup(); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("First group hovered"); - } - // Capture the group size and create widgets using the same size - ImVec2 size = ImGui::GetItemRectSize(); - const float values[5] = { 0.5f, 0.20f, 0.80f, 0.60f, 0.25f }; - ImGui::PlotHistogram("##values", values, IM_ARRAYSIZE(values), 0, NULL, 0.0f, 1.0f, size); - - ImGui::Button("ACTION", ImVec2((size.x - ImGui::GetStyle().ItemSpacing.x) * 0.5f, size.y)); - ImGui::SameLine(); - ImGui::Button("REACTION", ImVec2((size.x - ImGui::GetStyle().ItemSpacing.x) * 0.5f, size.y)); - ImGui::EndGroup(); - ImGui::SameLine(); - - ImGui::Button("LEVERAGE\nBUZZWORD", size); - ImGui::SameLine(); - - if (ImGui::BeginListBox("List", size)) - { - ImGui::Selectable("Selected", true); - ImGui::Selectable("Not Selected", false); - ImGui::EndListBox(); - } - - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Text Baseline Alignment")) - { - { - ImGui::BulletText("Text baseline:"); - ImGui::SameLine(); HelpMarker( - "This is testing the vertical alignment that gets applied on text to keep it aligned with widgets. " - "Lines only composed of text or \"small\" widgets use less vertical space than lines with framed widgets."); - ImGui::Indent(); - - ImGui::Text("KO Blahblah"); ImGui::SameLine(); - ImGui::Button("Some framed item"); ImGui::SameLine(); - HelpMarker("Baseline of button will look misaligned with text.."); - - // If your line starts with text, call AlignTextToFramePadding() to align text to upcoming widgets. - // (because we don't know what's coming after the Text() statement, we need to move the text baseline - // down by FramePadding.y ahead of time) - ImGui::AlignTextToFramePadding(); - ImGui::Text("OK Blahblah"); ImGui::SameLine(); - ImGui::Button("Some framed item"); ImGui::SameLine(); - HelpMarker("We call AlignTextToFramePadding() to vertically align the text baseline by +FramePadding.y"); - - // SmallButton() uses the same vertical padding as Text - ImGui::Button("TEST##1"); ImGui::SameLine(); - ImGui::Text("TEST"); ImGui::SameLine(); - ImGui::SmallButton("TEST##2"); - - // If your line starts with text, call AlignTextToFramePadding() to align text to upcoming widgets. - ImGui::AlignTextToFramePadding(); - ImGui::Text("Text aligned to framed item"); ImGui::SameLine(); - ImGui::Button("Item##1"); ImGui::SameLine(); - ImGui::Text("Item"); ImGui::SameLine(); - ImGui::SmallButton("Item##2"); ImGui::SameLine(); - ImGui::Button("Item##3"); - - ImGui::Unindent(); - } - - ImGui::Spacing(); - - { - ImGui::BulletText("Multi-line text:"); - ImGui::Indent(); - ImGui::Text("One\nTwo\nThree"); ImGui::SameLine(); - ImGui::Text("Hello\nWorld"); ImGui::SameLine(); - ImGui::Text("Banana"); - - ImGui::Text("Banana"); ImGui::SameLine(); - ImGui::Text("Hello\nWorld"); ImGui::SameLine(); - ImGui::Text("One\nTwo\nThree"); - - ImGui::Button("HOP##1"); ImGui::SameLine(); - ImGui::Text("Banana"); ImGui::SameLine(); - ImGui::Text("Hello\nWorld"); ImGui::SameLine(); - ImGui::Text("Banana"); - - ImGui::Button("HOP##2"); ImGui::SameLine(); - ImGui::Text("Hello\nWorld"); ImGui::SameLine(); - ImGui::Text("Banana"); - ImGui::Unindent(); - } - - ImGui::Spacing(); - - { - ImGui::BulletText("Misc items:"); - ImGui::Indent(); - - // SmallButton() sets FramePadding to zero. Text baseline is aligned to match baseline of previous Button. - ImGui::Button("80x80", ImVec2(80, 80)); - ImGui::SameLine(); - ImGui::Button("50x50", ImVec2(50, 50)); - ImGui::SameLine(); - ImGui::Button("Button()"); - ImGui::SameLine(); - ImGui::SmallButton("SmallButton()"); - - // Tree - const float spacing = ImGui::GetStyle().ItemInnerSpacing.x; - ImGui::Button("Button##1"); - ImGui::SameLine(0.0f, spacing); - if (ImGui::TreeNode("Node##1")) - { - // Placeholder tree data - for (int i = 0; i < 6; i++) - ImGui::BulletText("Item %d..", i); - ImGui::TreePop(); - } - - // Vertically align text node a bit lower so it'll be vertically centered with upcoming widget. - // Otherwise you can use SmallButton() (smaller fit). - ImGui::AlignTextToFramePadding(); - - // Common mistake to avoid: if we want to SameLine after TreeNode we need to do it before we add - // other contents below the node. - bool node_open = ImGui::TreeNode("Node##2"); - ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##2"); - if (node_open) - { - // Placeholder tree data - for (int i = 0; i < 6; i++) - ImGui::BulletText("Item %d..", i); - ImGui::TreePop(); - } - - // Bullet - ImGui::Button("Button##3"); - ImGui::SameLine(0.0f, spacing); - ImGui::BulletText("Bullet text"); - - ImGui::AlignTextToFramePadding(); - ImGui::BulletText("Node"); - ImGui::SameLine(0.0f, spacing); ImGui::Button("Button##4"); - ImGui::Unindent(); - } - - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Scrolling")) - { - // Vertical scroll functions - HelpMarker("Use SetScrollHereY() or SetScrollFromPosY() to scroll to a given vertical position."); - - static int track_item = 50; - static bool enable_track = true; - static bool enable_extra_decorations = false; - static float scroll_to_off_px = 0.0f; - static float scroll_to_pos_px = 200.0f; - - ImGui::Checkbox("Decoration", &enable_extra_decorations); - - ImGui::Checkbox("Track", &enable_track); - ImGui::PushItemWidth(100); - ImGui::SameLine(140); enable_track |= ImGui::DragInt("##item", &track_item, 0.25f, 0, 99, "Item = %d"); - - bool scroll_to_off = ImGui::Button("Scroll Offset"); - ImGui::SameLine(140); scroll_to_off |= ImGui::DragFloat("##off", &scroll_to_off_px, 1.00f, 0, FLT_MAX, "+%.0f px"); - - bool scroll_to_pos = ImGui::Button("Scroll To Pos"); - ImGui::SameLine(140); scroll_to_pos |= ImGui::DragFloat("##pos", &scroll_to_pos_px, 1.00f, -10, FLT_MAX, "X/Y = %.0f px"); - ImGui::PopItemWidth(); - - if (scroll_to_off || scroll_to_pos) - enable_track = false; - - ImGuiStyle& style = ImGui::GetStyle(); - float child_w = (ImGui::GetContentRegionAvail().x - 4 * style.ItemSpacing.x) / 5; - if (child_w < 1.0f) - child_w = 1.0f; - ImGui::PushID("##VerticalScrolling"); - for (int i = 0; i < 5; i++) - { - if (i > 0) ImGui::SameLine(); - ImGui::BeginGroup(); - const char* names[] = { "Top", "25%", "Center", "75%", "Bottom" }; - ImGui::TextUnformatted(names[i]); - - const ImGuiWindowFlags child_flags = enable_extra_decorations ? ImGuiWindowFlags_MenuBar : 0; - const ImGuiID child_id = ImGui::GetID((void*)(intptr_t)i); - const bool child_is_visible = ImGui::BeginChild(child_id, ImVec2(child_w, 200.0f), true, child_flags); - if (ImGui::BeginMenuBar()) - { - ImGui::TextUnformatted("abc"); - ImGui::EndMenuBar(); - } - if (scroll_to_off) - ImGui::SetScrollY(scroll_to_off_px); - if (scroll_to_pos) - ImGui::SetScrollFromPosY(ImGui::GetCursorStartPos().y + scroll_to_pos_px, i * 0.25f); - if (child_is_visible) // Avoid calling SetScrollHereY when running with culled items - { - for (int item = 0; item < 100; item++) - { - if (enable_track && item == track_item) - { - ImGui::TextColored(ImVec4(1, 1, 0, 1), "Item %d", item); - ImGui::SetScrollHereY(i * 0.25f); // 0.0f:top, 0.5f:center, 1.0f:bottom - } - else - { - ImGui::Text("Item %d", item); - } - } - } - float scroll_y = ImGui::GetScrollY(); - float scroll_max_y = ImGui::GetScrollMaxY(); - ImGui::EndChild(); - ImGui::Text("%.0f/%.0f", scroll_y, scroll_max_y); - ImGui::EndGroup(); - } - ImGui::PopID(); - - // Horizontal scroll functions - ImGui::Spacing(); - HelpMarker( - "Use SetScrollHereX() or SetScrollFromPosX() to scroll to a given horizontal position.\n\n" - "Because the clipping rectangle of most window hides half worth of WindowPadding on the " - "left/right, using SetScrollFromPosX(+1) will usually result in clipped text whereas the " - "equivalent SetScrollFromPosY(+1) wouldn't."); - ImGui::PushID("##HorizontalScrolling"); - for (int i = 0; i < 5; i++) - { - float child_height = ImGui::GetTextLineHeight() + style.ScrollbarSize + style.WindowPadding.y * 2.0f; - ImGuiWindowFlags child_flags = ImGuiWindowFlags_HorizontalScrollbar | (enable_extra_decorations ? ImGuiWindowFlags_AlwaysVerticalScrollbar : 0); - ImGuiID child_id = ImGui::GetID((void*)(intptr_t)i); - bool child_is_visible = ImGui::BeginChild(child_id, ImVec2(-100, child_height), true, child_flags); - if (scroll_to_off) - ImGui::SetScrollX(scroll_to_off_px); - if (scroll_to_pos) - ImGui::SetScrollFromPosX(ImGui::GetCursorStartPos().x + scroll_to_pos_px, i * 0.25f); - if (child_is_visible) // Avoid calling SetScrollHereY when running with culled items - { - for (int item = 0; item < 100; item++) - { - if (item > 0) - ImGui::SameLine(); - if (enable_track && item == track_item) - { - ImGui::TextColored(ImVec4(1, 1, 0, 1), "Item %d", item); - ImGui::SetScrollHereX(i * 0.25f); // 0.0f:left, 0.5f:center, 1.0f:right - } - else - { - ImGui::Text("Item %d", item); - } - } - } - float scroll_x = ImGui::GetScrollX(); - float scroll_max_x = ImGui::GetScrollMaxX(); - ImGui::EndChild(); - ImGui::SameLine(); - const char* names[] = { "Left", "25%", "Center", "75%", "Right" }; - ImGui::Text("%s\n%.0f/%.0f", names[i], scroll_x, scroll_max_x); - ImGui::Spacing(); - } - ImGui::PopID(); - - // Miscellaneous Horizontal Scrolling Demo - HelpMarker( - "Horizontal scrolling for a window is enabled via the ImGuiWindowFlags_HorizontalScrollbar flag.\n\n" - "You may want to also explicitly specify content width by using SetNextWindowContentWidth() before Begin()."); - static int lines = 7; - ImGui::SliderInt("Lines", &lines, 1, 15); - ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2.0f, 1.0f)); - ImVec2 scrolling_child_size = ImVec2(0, ImGui::GetFrameHeightWithSpacing() * 7 + 30); - ImGui::BeginChild("scrolling", scrolling_child_size, true, ImGuiWindowFlags_HorizontalScrollbar); - for (int line = 0; line < lines; line++) - { - // Display random stuff. For the sake of this trivial demo we are using basic Button() + SameLine() - // If you want to create your own time line for a real application you may be better off manipulating - // the cursor position yourself, aka using SetCursorPos/SetCursorScreenPos to position the widgets - // yourself. You may also want to use the lower-level ImDrawList API. - int num_buttons = 10 + ((line & 1) ? line * 9 : line * 3); - for (int n = 0; n < num_buttons; n++) - { - if (n > 0) ImGui::SameLine(); - ImGui::PushID(n + line * 1000); - char num_buf[16]; - sprintf(num_buf, "%d", n); - const char* label = (!(n % 15)) ? "FizzBuzz" : (!(n % 3)) ? "Fizz" : (!(n % 5)) ? "Buzz" : num_buf; - float hue = n * 0.05f; - ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor::HSV(hue, 0.6f, 0.6f)); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(hue, 0.7f, 0.7f)); - ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV(hue, 0.8f, 0.8f)); - ImGui::Button(label, ImVec2(40.0f + sinf((float)(line + n)) * 20.0f, 0.0f)); - ImGui::PopStyleColor(3); - ImGui::PopID(); - } - } - float scroll_x = ImGui::GetScrollX(); - float scroll_max_x = ImGui::GetScrollMaxX(); - ImGui::EndChild(); - ImGui::PopStyleVar(2); - float scroll_x_delta = 0.0f; - ImGui::SmallButton("<<"); - if (ImGui::IsItemActive()) - scroll_x_delta = -ImGui::GetIO().DeltaTime * 1000.0f; - ImGui::SameLine(); - ImGui::Text("Scroll from code"); ImGui::SameLine(); - ImGui::SmallButton(">>"); - if (ImGui::IsItemActive()) - scroll_x_delta = +ImGui::GetIO().DeltaTime * 1000.0f; - ImGui::SameLine(); - ImGui::Text("%.0f/%.0f", scroll_x, scroll_max_x); - if (scroll_x_delta != 0.0f) - { - // Demonstrate a trick: you can use Begin to set yourself in the context of another window - // (here we are already out of your child window) - ImGui::BeginChild("scrolling"); - ImGui::SetScrollX(ImGui::GetScrollX() + scroll_x_delta); - ImGui::EndChild(); - } - ImGui::Spacing(); - - static bool show_horizontal_contents_size_demo_window = false; - ImGui::Checkbox("Show Horizontal contents size demo window", &show_horizontal_contents_size_demo_window); - - if (show_horizontal_contents_size_demo_window) - { - static bool show_h_scrollbar = true; - static bool show_button = true; - static bool show_tree_nodes = true; - static bool show_text_wrapped = false; - static bool show_columns = true; - static bool show_tab_bar = true; - static bool show_child = false; - static bool explicit_content_size = false; - static float contents_size_x = 300.0f; - if (explicit_content_size) - ImGui::SetNextWindowContentSize(ImVec2(contents_size_x, 0.0f)); - ImGui::Begin("Horizontal contents size demo window", &show_horizontal_contents_size_demo_window, show_h_scrollbar ? ImGuiWindowFlags_HorizontalScrollbar : 0); - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(2, 0)); - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2, 0)); - HelpMarker("Test of different widgets react and impact the work rectangle growing when horizontal scrolling is enabled.\n\nUse 'Metrics->Tools->Show windows rectangles' to visualize rectangles."); - ImGui::Checkbox("H-scrollbar", &show_h_scrollbar); - ImGui::Checkbox("Button", &show_button); // Will grow contents size (unless explicitly overwritten) - ImGui::Checkbox("Tree nodes", &show_tree_nodes); // Will grow contents size and display highlight over full width - ImGui::Checkbox("Text wrapped", &show_text_wrapped);// Will grow and use contents size - ImGui::Checkbox("Columns", &show_columns); // Will use contents size - ImGui::Checkbox("Tab bar", &show_tab_bar); // Will use contents size - ImGui::Checkbox("Child", &show_child); // Will grow and use contents size - ImGui::Checkbox("Explicit content size", &explicit_content_size); - ImGui::Text("Scroll %.1f/%.1f %.1f/%.1f", ImGui::GetScrollX(), ImGui::GetScrollMaxX(), ImGui::GetScrollY(), ImGui::GetScrollMaxY()); - if (explicit_content_size) - { - ImGui::SameLine(); - ImGui::SetNextItemWidth(100); - ImGui::DragFloat("##csx", &contents_size_x); - ImVec2 p = ImGui::GetCursorScreenPos(); - ImGui::GetWindowDrawList()->AddRectFilled(p, ImVec2(p.x + 10, p.y + 10), IM_COL32_WHITE); - ImGui::GetWindowDrawList()->AddRectFilled(ImVec2(p.x + contents_size_x - 10, p.y), ImVec2(p.x + contents_size_x, p.y + 10), IM_COL32_WHITE); - ImGui::Dummy(ImVec2(0, 10)); - } - ImGui::PopStyleVar(2); - ImGui::Separator(); - if (show_button) - { - ImGui::Button("this is a 300-wide button", ImVec2(300, 0)); - } - if (show_tree_nodes) - { - bool open = true; - if (ImGui::TreeNode("this is a tree node")) - { - if (ImGui::TreeNode("another one of those tree node...")) - { - ImGui::Text("Some tree contents"); - ImGui::TreePop(); - } - ImGui::TreePop(); - } - ImGui::CollapsingHeader("CollapsingHeader", &open); - } - if (show_text_wrapped) - { - ImGui::TextWrapped("This text should automatically wrap on the edge of the work rectangle."); - } - if (show_columns) - { - ImGui::Text("Tables:"); - if (ImGui::BeginTable("table", 4, ImGuiTableFlags_Borders)) - { - for (int n = 0; n < 4; n++) - { - ImGui::TableNextColumn(); - ImGui::Text("Width %.2f", ImGui::GetContentRegionAvail().x); - } - ImGui::EndTable(); - } - ImGui::Text("Columns:"); - ImGui::Columns(4); - for (int n = 0; n < 4; n++) - { - ImGui::Text("Width %.2f", ImGui::GetColumnWidth()); - ImGui::NextColumn(); - } - ImGui::Columns(1); - } - if (show_tab_bar && ImGui::BeginTabBar("Hello")) - { - if (ImGui::BeginTabItem("OneOneOne")) { ImGui::EndTabItem(); } - if (ImGui::BeginTabItem("TwoTwoTwo")) { ImGui::EndTabItem(); } - if (ImGui::BeginTabItem("ThreeThreeThree")) { ImGui::EndTabItem(); } - if (ImGui::BeginTabItem("FourFourFour")) { ImGui::EndTabItem(); } - ImGui::EndTabBar(); - } - if (show_child) - { - ImGui::BeginChild("child", ImVec2(0, 0), true); - ImGui::EndChild(); - } - ImGui::End(); - } - - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Clipping")) - { - static ImVec2 size(100.0f, 100.0f); - static ImVec2 offset(30.0f, 30.0f); - ImGui::DragFloat2("size", (float*)&size, 0.5f, 1.0f, 200.0f, "%.0f"); - ImGui::TextWrapped("(Click and drag to scroll)"); - - for (int n = 0; n < 3; n++) - { - if (n > 0) - ImGui::SameLine(); - ImGui::PushID(n); - ImGui::BeginGroup(); // Lock X position - - ImGui::InvisibleButton("##empty", size); - if (ImGui::IsItemActive() && ImGui::IsMouseDragging(ImGuiMouseButton_Left)) - { - offset.x += ImGui::GetIO().MouseDelta.x; - offset.y += ImGui::GetIO().MouseDelta.y; - } - const ImVec2 p0 = ImGui::GetItemRectMin(); - const ImVec2 p1 = ImGui::GetItemRectMax(); - const char* text_str = "Line 1 hello\nLine 2 clip me!"; - const ImVec2 text_pos = ImVec2(p0.x + offset.x, p0.y + offset.y); - ImDrawList* draw_list = ImGui::GetWindowDrawList(); - - switch (n) - { - case 0: - HelpMarker( - "Using ImGui::PushClipRect():\n" - "Will alter ImGui hit-testing logic + ImDrawList rendering.\n" - "(use this if you want your clipping rectangle to affect interactions)"); - ImGui::PushClipRect(p0, p1, true); - draw_list->AddRectFilled(p0, p1, IM_COL32(90, 90, 120, 255)); - draw_list->AddText(text_pos, IM_COL32_WHITE, text_str); - ImGui::PopClipRect(); - break; - case 1: - HelpMarker( - "Using ImDrawList::PushClipRect():\n" - "Will alter ImDrawList rendering only.\n" - "(use this as a shortcut if you are only using ImDrawList calls)"); - draw_list->PushClipRect(p0, p1, true); - draw_list->AddRectFilled(p0, p1, IM_COL32(90, 90, 120, 255)); - draw_list->AddText(text_pos, IM_COL32_WHITE, text_str); - draw_list->PopClipRect(); - break; - case 2: - HelpMarker( - "Using ImDrawList::AddText() with a fine ClipRect:\n" - "Will alter only this specific ImDrawList::AddText() rendering.\n" - "(this is often used internally to avoid altering the clipping rectangle and minimize draw calls)"); - ImVec4 clip_rect(p0.x, p0.y, p1.x, p1.y); // AddText() takes a ImVec4* here so let's convert. - draw_list->AddRectFilled(p0, p1, IM_COL32(90, 90, 120, 255)); - draw_list->AddText(ImGui::GetFont(), ImGui::GetFontSize(), text_pos, IM_COL32_WHITE, text_str, NULL, 0.0f, &clip_rect); - break; - } - ImGui::EndGroup(); - ImGui::PopID(); - } - - ImGui::TreePop(); - } -} - -static void ShowDemoWindowPopups() -{ - if (!ImGui::CollapsingHeader("Popups & Modal windows")) - return; - - // The properties of popups windows are: - // - They block normal mouse hovering detection outside them. (*) - // - Unless modal, they can be closed by clicking anywhere outside them, or by pressing ESCAPE. - // - Their visibility state (~bool) is held internally by Dear ImGui instead of being held by the programmer as - // we are used to with regular Begin() calls. User can manipulate the visibility state by calling OpenPopup(). - // (*) One can use IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup) to bypass it and detect hovering even - // when normally blocked by a popup. - // Those three properties are connected. The library needs to hold their visibility state BECAUSE it can close - // popups at any time. - - // Typical use for regular windows: - // bool my_tool_is_active = false; if (ImGui::Button("Open")) my_tool_is_active = true; [...] if (my_tool_is_active) Begin("My Tool", &my_tool_is_active) { [...] } End(); - // Typical use for popups: - // if (ImGui::Button("Open")) ImGui::OpenPopup("MyPopup"); if (ImGui::BeginPopup("MyPopup") { [...] EndPopup(); } - - // With popups we have to go through a library call (here OpenPopup) to manipulate the visibility state. - // This may be a bit confusing at first but it should quickly make sense. Follow on the examples below. - - if (ImGui::TreeNode("Popups")) - { - ImGui::TextWrapped( - "When a popup is active, it inhibits interacting with windows that are behind the popup. " - "Clicking outside the popup closes it."); - - static int selected_fish = -1; - const char* names[] = { "Bream", "Haddock", "Mackerel", "Pollock", "Tilefish" }; - static bool toggles[] = { true, false, false, false, false }; - - // Simple selection popup (if you want to show the current selection inside the Button itself, - // you may want to build a string using the "###" operator to preserve a constant ID with a variable label) - if (ImGui::Button("Select..")) - ImGui::OpenPopup("my_select_popup"); - ImGui::SameLine(); - ImGui::TextUnformatted(selected_fish == -1 ? "" : names[selected_fish]); - if (ImGui::BeginPopup("my_select_popup")) - { - ImGui::Text("Aquarium"); - ImGui::Separator(); - for (int i = 0; i < IM_ARRAYSIZE(names); i++) - if (ImGui::Selectable(names[i])) - selected_fish = i; - ImGui::EndPopup(); - } - - // Showing a menu with toggles - if (ImGui::Button("Toggle..")) - ImGui::OpenPopup("my_toggle_popup"); - if (ImGui::BeginPopup("my_toggle_popup")) - { - for (int i = 0; i < IM_ARRAYSIZE(names); i++) - ImGui::MenuItem(names[i], "", &toggles[i]); - if (ImGui::BeginMenu("Sub-menu")) - { - ImGui::MenuItem("Click me"); - ImGui::EndMenu(); - } - - ImGui::Separator(); - ImGui::Text("Tooltip here"); - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("I am a tooltip over a popup"); - - if (ImGui::Button("Stacked Popup")) - ImGui::OpenPopup("another popup"); - if (ImGui::BeginPopup("another popup")) - { - for (int i = 0; i < IM_ARRAYSIZE(names); i++) - ImGui::MenuItem(names[i], "", &toggles[i]); - if (ImGui::BeginMenu("Sub-menu")) - { - ImGui::MenuItem("Click me"); - if (ImGui::Button("Stacked Popup")) - ImGui::OpenPopup("another popup"); - if (ImGui::BeginPopup("another popup")) - { - ImGui::Text("I am the last one here."); - ImGui::EndPopup(); - } - ImGui::EndMenu(); - } - ImGui::EndPopup(); - } - ImGui::EndPopup(); - } - - // Call the more complete ShowExampleMenuFile which we use in various places of this demo - if (ImGui::Button("File Menu..")) - ImGui::OpenPopup("my_file_popup"); - if (ImGui::BeginPopup("my_file_popup")) - { - ShowExampleMenuFile(); - ImGui::EndPopup(); - } - - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Context menus")) - { - HelpMarker("\"Context\" functions are simple helpers to associate a Popup to a given Item or Window identifier."); - - // BeginPopupContextItem() is a helper to provide common/simple popup behavior of essentially doing: - // if (id == 0) - // id = GetItemID(); // Use last item id - // if (IsItemHovered() && IsMouseReleased(ImGuiMouseButton_Right)) - // OpenPopup(id); - // return BeginPopup(id); - // For advanced advanced uses you may want to replicate and customize this code. - // See more details in BeginPopupContextItem(). - - // Example 1 - // When used after an item that has an ID (e.g. Button), we can skip providing an ID to BeginPopupContextItem(), - // and BeginPopupContextItem() will use the last item ID as the popup ID. - { - const char* names[5] = { "Label1", "Label2", "Label3", "Label4", "Label5" }; - for (int n = 0; n < 5; n++) - { - ImGui::Selectable(names[n]); - if (ImGui::BeginPopupContextItem()) // <-- use last item id as popup id - { - ImGui::Text("This a popup for \"%s\"!", names[n]); - if (ImGui::Button("Close")) - ImGui::CloseCurrentPopup(); - ImGui::EndPopup(); - } - if (ImGui::IsItemHovered()) - ImGui::SetTooltip("Right-click to open popup"); - } - } - - // Example 2 - // Popup on a Text() element which doesn't have an identifier: we need to provide an identifier to BeginPopupContextItem(). - // Using an explicit identifier is also convenient if you want to activate the popups from different locations. - { - HelpMarker("Text() elements don't have stable identifiers so we need to provide one."); - static float value = 0.5f; - ImGui::Text("Value = %.3f <-- (1) right-click this value", value); - if (ImGui::BeginPopupContextItem("my popup")) - { - if (ImGui::Selectable("Set to zero")) value = 0.0f; - if (ImGui::Selectable("Set to PI")) value = 3.1415f; - ImGui::SetNextItemWidth(-FLT_MIN); - ImGui::DragFloat("##Value", &value, 0.1f, 0.0f, 0.0f); - ImGui::EndPopup(); - } - - // We can also use OpenPopupOnItemClick() to toggle the visibility of a given popup. - // Here we make it that right-clicking this other text element opens the same popup as above. - // The popup itself will be submitted by the code above. - ImGui::Text("(2) Or right-click this text"); - ImGui::OpenPopupOnItemClick("my popup", ImGuiPopupFlags_MouseButtonRight); - - // Back to square one: manually open the same popup. - if (ImGui::Button("(3) Or click this button")) - ImGui::OpenPopup("my popup"); - } - - // Example 3 - // When using BeginPopupContextItem() with an implicit identifier (NULL == use last item ID), - // we need to make sure your item identifier is stable. - // In this example we showcase altering the item label while preserving its identifier, using the ### operator (see FAQ). - { - HelpMarker("Showcase using a popup ID linked to item ID, with the item having a changing label + stable ID using the ### operator."); - static char name[32] = "Label1"; - char buf[64]; - sprintf(buf, "Button: %s###Button", name); // ### operator override ID ignoring the preceding label - ImGui::Button(buf); - if (ImGui::BeginPopupContextItem()) - { - ImGui::Text("Edit name:"); - ImGui::InputText("##edit", name, IM_ARRAYSIZE(name)); - if (ImGui::Button("Close")) - ImGui::CloseCurrentPopup(); - ImGui::EndPopup(); - } - ImGui::SameLine(); ImGui::Text("(<-- right-click here)"); - } - - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Modals")) - { - ImGui::TextWrapped("Modal windows are like popups but the user cannot close them by clicking outside."); - - if (ImGui::Button("Delete..")) - ImGui::OpenPopup("Delete?"); - - // Always center this window when appearing - ImVec2 center = ImGui::GetMainViewport()->GetCenter(); - ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f)); - - if (ImGui::BeginPopupModal("Delete?", NULL, ImGuiWindowFlags_AlwaysAutoResize)) - { - ImGui::Text("All those beautiful files will be deleted.\nThis operation cannot be undone!\n\n"); - ImGui::Separator(); - - //static int unused_i = 0; - //ImGui::Combo("Combo", &unused_i, "Delete\0Delete harder\0"); - - static bool dont_ask_me_next_time = false; - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0)); - ImGui::Checkbox("Don't ask me next time", &dont_ask_me_next_time); - ImGui::PopStyleVar(); - - if (ImGui::Button("OK", ImVec2(120, 0))) { ImGui::CloseCurrentPopup(); } - ImGui::SetItemDefaultFocus(); - ImGui::SameLine(); - if (ImGui::Button("Cancel", ImVec2(120, 0))) { ImGui::CloseCurrentPopup(); } - ImGui::EndPopup(); - } - - if (ImGui::Button("Stacked modals..")) - ImGui::OpenPopup("Stacked 1"); - if (ImGui::BeginPopupModal("Stacked 1", NULL, ImGuiWindowFlags_MenuBar)) - { - if (ImGui::BeginMenuBar()) - { - if (ImGui::BeginMenu("File")) - { - if (ImGui::MenuItem("Some menu item")) {} - ImGui::EndMenu(); - } - ImGui::EndMenuBar(); - } - ImGui::Text("Hello from Stacked The First\nUsing style.Colors[ImGuiCol_ModalWindowDimBg] behind it."); - - // Testing behavior of widgets stacking their own regular popups over the modal. - static int item = 1; - static float color[4] = { 0.4f, 0.7f, 0.0f, 0.5f }; - ImGui::Combo("Combo", &item, "aaaa\0bbbb\0cccc\0dddd\0eeee\0\0"); - ImGui::ColorEdit4("color", color); - - if (ImGui::Button("Add another modal..")) - ImGui::OpenPopup("Stacked 2"); - - // Also demonstrate passing a bool* to BeginPopupModal(), this will create a regular close button which - // will close the popup. Note that the visibility state of popups is owned by imgui, so the input value - // of the bool actually doesn't matter here. - bool unused_open = true; - if (ImGui::BeginPopupModal("Stacked 2", &unused_open)) - { - ImGui::Text("Hello from Stacked The Second!"); - if (ImGui::Button("Close")) - ImGui::CloseCurrentPopup(); - ImGui::EndPopup(); - } - - if (ImGui::Button("Close")) - ImGui::CloseCurrentPopup(); - ImGui::EndPopup(); - } - - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Menus inside a regular window")) - { - ImGui::TextWrapped("Below we are testing adding menu items to a regular window. It's rather unusual but should work!"); - ImGui::Separator(); - - // Note: As a quirk in this very specific example, we want to differentiate the parent of this menu from the - // parent of the various popup menus above. To do so we are encloding the items in a PushID()/PopID() block - // to make them two different menusets. If we don't, opening any popup above and hovering our menu here would - // open it. This is because once a menu is active, we allow to switch to a sibling menu by just hovering on it, - // which is the desired behavior for regular menus. - ImGui::PushID("foo"); - ImGui::MenuItem("Menu item", "CTRL+M"); - if (ImGui::BeginMenu("Menu inside a regular window")) - { - ShowExampleMenuFile(); - ImGui::EndMenu(); - } - ImGui::PopID(); - ImGui::Separator(); - ImGui::TreePop(); - } -} - -// Dummy data structure that we use for the Table demo. -// (pre-C++11 doesn't allow us to instantiate ImVector template if this structure if defined inside the demo function) -namespace -{ -// We are passing our own identifier to TableSetupColumn() to facilitate identifying columns in the sorting code. -// This identifier will be passed down into ImGuiTableSortSpec::ColumnUserID. -// But it is possible to omit the user id parameter of TableSetupColumn() and just use the column index instead! (ImGuiTableSortSpec::ColumnIndex) -// If you don't use sorting, you will generally never care about giving column an ID! -enum MyItemColumnID -{ - MyItemColumnID_ID, - MyItemColumnID_Name, - MyItemColumnID_Action, - MyItemColumnID_Quantity, - MyItemColumnID_Description -}; - -struct MyItem -{ - int ID; - const char* Name; - int Quantity; - - // We have a problem which is affecting _only this demo_ and should not affect your code: - // As we don't rely on std:: or other third-party library to compile dear imgui, we only have reliable access to qsort(), - // however qsort doesn't allow passing user data to comparing function. - // As a workaround, we are storing the sort specs in a static/global for the comparing function to access. - // In your own use case you would probably pass the sort specs to your sorting/comparing functions directly and not use a global. - // We could technically call ImGui::TableGetSortSpecs() in CompareWithSortSpecs(), but considering that this function is called - // very often by the sorting algorithm it would be a little wasteful. - static const ImGuiTableSortSpecs* s_current_sort_specs; - - // Compare function to be used by qsort() - static int IMGUI_CDECL CompareWithSortSpecs(const void* lhs, const void* rhs) - { - const MyItem* a = (const MyItem*)lhs; - const MyItem* b = (const MyItem*)rhs; - for (int n = 0; n < s_current_sort_specs->SpecsCount; n++) - { - // Here we identify columns using the ColumnUserID value that we ourselves passed to TableSetupColumn() - // We could also choose to identify columns based on their index (sort_spec->ColumnIndex), which is simpler! - const ImGuiTableColumnSortSpecs* sort_spec = &s_current_sort_specs->Specs[n]; - int delta = 0; - switch (sort_spec->ColumnUserID) - { - case MyItemColumnID_ID: delta = (a->ID - b->ID); break; - case MyItemColumnID_Name: delta = (strcmp(a->Name, b->Name)); break; - case MyItemColumnID_Quantity: delta = (a->Quantity - b->Quantity); break; - case MyItemColumnID_Description: delta = (strcmp(a->Name, b->Name)); break; - default: IM_ASSERT(0); break; - } - if (delta > 0) - return (sort_spec->SortDirection == ImGuiSortDirection_Ascending) ? +1 : -1; - if (delta < 0) - return (sort_spec->SortDirection == ImGuiSortDirection_Ascending) ? -1 : +1; - } - - // qsort() is instable so always return a way to differenciate items. - // Your own compare function may want to avoid fallback on implicit sort specs e.g. a Name compare if it wasn't already part of the sort specs. - return (a->ID - b->ID); - } -}; -const ImGuiTableSortSpecs* MyItem::s_current_sort_specs = NULL; -} - -// Make the UI compact because there are so many fields -static void PushStyleCompact() -{ - ImGuiStyle& style = ImGui::GetStyle(); - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(style.FramePadding.x, (float)(int)(style.FramePadding.y * 0.60f))); - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(style.ItemSpacing.x, (float)(int)(style.ItemSpacing.y * 0.60f))); -} - -static void PopStyleCompact() -{ - ImGui::PopStyleVar(2); -} - -// Show a combo box with a choice of sizing policies -static void EditTableSizingFlags(ImGuiTableFlags* p_flags) -{ - struct EnumDesc { ImGuiTableFlags Value; const char* Name; const char* Tooltip; }; - static const EnumDesc policies[] = - { - { ImGuiTableFlags_None, "Default", "Use default sizing policy:\n- ImGuiTableFlags_SizingFixedFit if ScrollX is on or if host window has ImGuiWindowFlags_AlwaysAutoResize.\n- ImGuiTableFlags_SizingStretchSame otherwise." }, - { ImGuiTableFlags_SizingFixedFit, "ImGuiTableFlags_SizingFixedFit", "Columns default to _WidthFixed (if resizable) or _WidthAuto (if not resizable), matching contents width." }, - { ImGuiTableFlags_SizingFixedSame, "ImGuiTableFlags_SizingFixedSame", "Columns are all the same width, matching the maximum contents width.\nImplicitly disable ImGuiTableFlags_Resizable and enable ImGuiTableFlags_NoKeepColumnsVisible." }, - { ImGuiTableFlags_SizingStretchProp, "ImGuiTableFlags_SizingStretchProp", "Columns default to _WidthStretch with weights proportional to their widths." }, - { ImGuiTableFlags_SizingStretchSame, "ImGuiTableFlags_SizingStretchSame", "Columns default to _WidthStretch with same weights." } - }; - int idx; - for (idx = 0; idx < IM_ARRAYSIZE(policies); idx++) - if (policies[idx].Value == (*p_flags & ImGuiTableFlags_SizingMask_)) - break; - const char* preview_text = (idx < IM_ARRAYSIZE(policies)) ? policies[idx].Name + (idx > 0 ? strlen("ImGuiTableFlags") : 0) : ""; - if (ImGui::BeginCombo("Sizing Policy", preview_text)) - { - for (int n = 0; n < IM_ARRAYSIZE(policies); n++) - if (ImGui::Selectable(policies[n].Name, idx == n)) - *p_flags = (*p_flags & ~ImGuiTableFlags_SizingMask_) | policies[n].Value; - ImGui::EndCombo(); - } - ImGui::SameLine(); - ImGui::TextDisabled("(?)"); - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - ImGui::PushTextWrapPos(ImGui::GetFontSize() * 50.0f); - for (int m = 0; m < IM_ARRAYSIZE(policies); m++) - { - ImGui::Separator(); - ImGui::Text("%s:", policies[m].Name); - ImGui::Separator(); - ImGui::SetCursorPosX(ImGui::GetCursorPosX() + ImGui::GetStyle().IndentSpacing * 0.5f); - ImGui::TextUnformatted(policies[m].Tooltip); - } - ImGui::PopTextWrapPos(); - ImGui::EndTooltip(); - } -} - -static void EditTableColumnsFlags(ImGuiTableColumnFlags* p_flags) -{ - ImGui::CheckboxFlags("_Disabled", p_flags, ImGuiTableColumnFlags_Disabled); ImGui::SameLine(); HelpMarker("Master disable flag (also hide from context menu)"); - ImGui::CheckboxFlags("_DefaultHide", p_flags, ImGuiTableColumnFlags_DefaultHide); - ImGui::CheckboxFlags("_DefaultSort", p_flags, ImGuiTableColumnFlags_DefaultSort); - if (ImGui::CheckboxFlags("_WidthStretch", p_flags, ImGuiTableColumnFlags_WidthStretch)) - *p_flags &= ~(ImGuiTableColumnFlags_WidthMask_ ^ ImGuiTableColumnFlags_WidthStretch); - if (ImGui::CheckboxFlags("_WidthFixed", p_flags, ImGuiTableColumnFlags_WidthFixed)) - *p_flags &= ~(ImGuiTableColumnFlags_WidthMask_ ^ ImGuiTableColumnFlags_WidthFixed); - ImGui::CheckboxFlags("_NoResize", p_flags, ImGuiTableColumnFlags_NoResize); - ImGui::CheckboxFlags("_NoReorder", p_flags, ImGuiTableColumnFlags_NoReorder); - ImGui::CheckboxFlags("_NoHide", p_flags, ImGuiTableColumnFlags_NoHide); - ImGui::CheckboxFlags("_NoClip", p_flags, ImGuiTableColumnFlags_NoClip); - ImGui::CheckboxFlags("_NoSort", p_flags, ImGuiTableColumnFlags_NoSort); - ImGui::CheckboxFlags("_NoSortAscending", p_flags, ImGuiTableColumnFlags_NoSortAscending); - ImGui::CheckboxFlags("_NoSortDescending", p_flags, ImGuiTableColumnFlags_NoSortDescending); - ImGui::CheckboxFlags("_NoHeaderLabel", p_flags, ImGuiTableColumnFlags_NoHeaderLabel); - ImGui::CheckboxFlags("_NoHeaderWidth", p_flags, ImGuiTableColumnFlags_NoHeaderWidth); - ImGui::CheckboxFlags("_PreferSortAscending", p_flags, ImGuiTableColumnFlags_PreferSortAscending); - ImGui::CheckboxFlags("_PreferSortDescending", p_flags, ImGuiTableColumnFlags_PreferSortDescending); - ImGui::CheckboxFlags("_IndentEnable", p_flags, ImGuiTableColumnFlags_IndentEnable); ImGui::SameLine(); HelpMarker("Default for column 0"); - ImGui::CheckboxFlags("_IndentDisable", p_flags, ImGuiTableColumnFlags_IndentDisable); ImGui::SameLine(); HelpMarker("Default for column >0"); -} - -static void ShowTableColumnsStatusFlags(ImGuiTableColumnFlags flags) -{ - ImGui::CheckboxFlags("_IsEnabled", &flags, ImGuiTableColumnFlags_IsEnabled); - ImGui::CheckboxFlags("_IsVisible", &flags, ImGuiTableColumnFlags_IsVisible); - ImGui::CheckboxFlags("_IsSorted", &flags, ImGuiTableColumnFlags_IsSorted); - ImGui::CheckboxFlags("_IsHovered", &flags, ImGuiTableColumnFlags_IsHovered); -} - -static void ShowDemoWindowTables() -{ - //ImGui::SetNextItemOpen(true, ImGuiCond_Once); - if (!ImGui::CollapsingHeader("Tables & Columns")) - return; - - // Using those as a base value to create width/height that are factor of the size of our font - const float TEXT_BASE_WIDTH = ImGui::CalcTextSize("A").x; - const float TEXT_BASE_HEIGHT = ImGui::GetTextLineHeightWithSpacing(); - - ImGui::PushID("Tables"); - - int open_action = -1; - if (ImGui::Button("Open all")) - open_action = 1; - ImGui::SameLine(); - if (ImGui::Button("Close all")) - open_action = 0; - ImGui::SameLine(); - - // Options - static bool disable_indent = false; - ImGui::Checkbox("Disable tree indentation", &disable_indent); - ImGui::SameLine(); - HelpMarker("Disable the indenting of tree nodes so demo tables can use the full window width."); - ImGui::Separator(); - if (disable_indent) - ImGui::PushStyleVar(ImGuiStyleVar_IndentSpacing, 0.0f); - - // About Styling of tables - // Most settings are configured on a per-table basis via the flags passed to BeginTable() and TableSetupColumns APIs. - // There are however a few settings that a shared and part of the ImGuiStyle structure: - // style.CellPadding // Padding within each cell - // style.Colors[ImGuiCol_TableHeaderBg] // Table header background - // style.Colors[ImGuiCol_TableBorderStrong] // Table outer and header borders - // style.Colors[ImGuiCol_TableBorderLight] // Table inner borders - // style.Colors[ImGuiCol_TableRowBg] // Table row background when ImGuiTableFlags_RowBg is enabled (even rows) - // style.Colors[ImGuiCol_TableRowBgAlt] // Table row background when ImGuiTableFlags_RowBg is enabled (odds rows) - - // Demos - if (open_action != -1) - ImGui::SetNextItemOpen(open_action != 0); - if (ImGui::TreeNode("Basic")) - { - // Here we will showcase three different ways to output a table. - // They are very simple variations of a same thing! - - // [Method 1] Using TableNextRow() to create a new row, and TableSetColumnIndex() to select the column. - // In many situations, this is the most flexible and easy to use pattern. - HelpMarker("Using TableNextRow() + calling TableSetColumnIndex() _before_ each cell, in a loop."); - if (ImGui::BeginTable("table1", 3)) - { - for (int row = 0; row < 4; row++) - { - ImGui::TableNextRow(); - for (int column = 0; column < 3; column++) - { - ImGui::TableSetColumnIndex(column); - ImGui::Text("Row %d Column %d", row, column); - } - } - ImGui::EndTable(); - } - - // [Method 2] Using TableNextColumn() called multiple times, instead of using a for loop + TableSetColumnIndex(). - // This is generally more convenient when you have code manually submitting the contents of each columns. - HelpMarker("Using TableNextRow() + calling TableNextColumn() _before_ each cell, manually."); - if (ImGui::BeginTable("table2", 3)) - { - for (int row = 0; row < 4; row++) - { - ImGui::TableNextRow(); - ImGui::TableNextColumn(); - ImGui::Text("Row %d", row); - ImGui::TableNextColumn(); - ImGui::Text("Some contents"); - ImGui::TableNextColumn(); - ImGui::Text("123.456"); - } - ImGui::EndTable(); - } - - // [Method 3] We call TableNextColumn() _before_ each cell. We never call TableNextRow(), - // as TableNextColumn() will automatically wrap around and create new roes as needed. - // This is generally more convenient when your cells all contains the same type of data. - HelpMarker( - "Only using TableNextColumn(), which tends to be convenient for tables where every cells contains the same type of contents.\n" - "This is also more similar to the old NextColumn() function of the Columns API, and provided to facilitate the Columns->Tables API transition."); - if (ImGui::BeginTable("table3", 3)) - { - for (int item = 0; item < 14; item++) - { - ImGui::TableNextColumn(); - ImGui::Text("Item %d", item); - } - ImGui::EndTable(); - } - - ImGui::TreePop(); - } - - if (open_action != -1) - ImGui::SetNextItemOpen(open_action != 0); - if (ImGui::TreeNode("Borders, background")) - { - // Expose a few Borders related flags interactively - enum ContentsType { CT_Text, CT_FillButton }; - static ImGuiTableFlags flags = ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg; - static bool display_headers = false; - static int contents_type = CT_Text; - - PushStyleCompact(); - ImGui::CheckboxFlags("ImGuiTableFlags_RowBg", &flags, ImGuiTableFlags_RowBg); - ImGui::CheckboxFlags("ImGuiTableFlags_Borders", &flags, ImGuiTableFlags_Borders); - ImGui::SameLine(); HelpMarker("ImGuiTableFlags_Borders\n = ImGuiTableFlags_BordersInnerV\n | ImGuiTableFlags_BordersOuterV\n | ImGuiTableFlags_BordersInnerV\n | ImGuiTableFlags_BordersOuterH"); - ImGui::Indent(); - - ImGui::CheckboxFlags("ImGuiTableFlags_BordersH", &flags, ImGuiTableFlags_BordersH); - ImGui::Indent(); - ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterH", &flags, ImGuiTableFlags_BordersOuterH); - ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerH", &flags, ImGuiTableFlags_BordersInnerH); - ImGui::Unindent(); - - ImGui::CheckboxFlags("ImGuiTableFlags_BordersV", &flags, ImGuiTableFlags_BordersV); - ImGui::Indent(); - ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterV", &flags, ImGuiTableFlags_BordersOuterV); - ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerV", &flags, ImGuiTableFlags_BordersInnerV); - ImGui::Unindent(); - - ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuter", &flags, ImGuiTableFlags_BordersOuter); - ImGui::CheckboxFlags("ImGuiTableFlags_BordersInner", &flags, ImGuiTableFlags_BordersInner); - ImGui::Unindent(); - - ImGui::AlignTextToFramePadding(); ImGui::Text("Cell contents:"); - ImGui::SameLine(); ImGui::RadioButton("Text", &contents_type, CT_Text); - ImGui::SameLine(); ImGui::RadioButton("FillButton", &contents_type, CT_FillButton); - ImGui::Checkbox("Display headers", &display_headers); - ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBody", &flags, ImGuiTableFlags_NoBordersInBody); ImGui::SameLine(); HelpMarker("Disable vertical borders in columns Body (borders will always appears in Headers"); - PopStyleCompact(); - - if (ImGui::BeginTable("table1", 3, flags)) - { - // Display headers so we can inspect their interaction with borders. - // (Headers are not the main purpose of this section of the demo, so we are not elaborating on them too much. See other sections for details) - if (display_headers) - { - ImGui::TableSetupColumn("One"); - ImGui::TableSetupColumn("Two"); - ImGui::TableSetupColumn("Three"); - ImGui::TableHeadersRow(); - } - - for (int row = 0; row < 5; row++) - { - ImGui::TableNextRow(); - for (int column = 0; column < 3; column++) - { - ImGui::TableSetColumnIndex(column); - char buf[32]; - sprintf(buf, "Hello %d,%d", column, row); - if (contents_type == CT_Text) - ImGui::TextUnformatted(buf); - else if (contents_type) - ImGui::Button(buf, ImVec2(-FLT_MIN, 0.0f)); - } - } - ImGui::EndTable(); - } - ImGui::TreePop(); - } - - if (open_action != -1) - ImGui::SetNextItemOpen(open_action != 0); - if (ImGui::TreeNode("Resizable, stretch")) - { - // By default, if we don't enable ScrollX the sizing policy for each columns is "Stretch" - // Each columns maintain a sizing weight, and they will occupy all available width. - static ImGuiTableFlags flags = ImGuiTableFlags_SizingStretchSame | ImGuiTableFlags_Resizable | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_ContextMenuInBody; - PushStyleCompact(); - ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags, ImGuiTableFlags_Resizable); - ImGui::CheckboxFlags("ImGuiTableFlags_BordersV", &flags, ImGuiTableFlags_BordersV); - ImGui::SameLine(); HelpMarker("Using the _Resizable flag automatically enables the _BordersInnerV flag as well, this is why the resize borders are still showing when unchecking this."); - PopStyleCompact(); - - if (ImGui::BeginTable("table1", 3, flags)) - { - for (int row = 0; row < 5; row++) - { - ImGui::TableNextRow(); - for (int column = 0; column < 3; column++) - { - ImGui::TableSetColumnIndex(column); - ImGui::Text("Hello %d,%d", column, row); - } - } - ImGui::EndTable(); - } - ImGui::TreePop(); - } - - if (open_action != -1) - ImGui::SetNextItemOpen(open_action != 0); - if (ImGui::TreeNode("Resizable, fixed")) - { - // Here we use ImGuiTableFlags_SizingFixedFit (even though _ScrollX is not set) - // So columns will adopt the "Fixed" policy and will maintain a fixed width regardless of the whole available width (unless table is small) - // If there is not enough available width to fit all columns, they will however be resized down. - // FIXME-TABLE: Providing a stretch-on-init would make sense especially for tables which don't have saved settings - HelpMarker( - "Using _Resizable + _SizingFixedFit flags.\n" - "Fixed-width columns generally makes more sense if you want to use horizontal scrolling.\n\n" - "Double-click a column border to auto-fit the column to its contents."); - PushStyleCompact(); - static ImGuiTableFlags flags = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Resizable | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_ContextMenuInBody; - ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendX", &flags, ImGuiTableFlags_NoHostExtendX); - PopStyleCompact(); - - if (ImGui::BeginTable("table1", 3, flags)) - { - for (int row = 0; row < 5; row++) - { - ImGui::TableNextRow(); - for (int column = 0; column < 3; column++) - { - ImGui::TableSetColumnIndex(column); - ImGui::Text("Hello %d,%d", column, row); - } - } - ImGui::EndTable(); - } - ImGui::TreePop(); - } - - if (open_action != -1) - ImGui::SetNextItemOpen(open_action != 0); - if (ImGui::TreeNode("Resizable, mixed")) - { - HelpMarker( - "Using TableSetupColumn() to alter resizing policy on a per-column basis.\n\n" - "When combining Fixed and Stretch columns, generally you only want one, maybe two trailing columns to use _WidthStretch."); - static ImGuiTableFlags flags = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_RowBg | ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable; - - if (ImGui::BeginTable("table1", 3, flags)) - { - ImGui::TableSetupColumn("AAA", ImGuiTableColumnFlags_WidthFixed); - ImGui::TableSetupColumn("BBB", ImGuiTableColumnFlags_WidthFixed); - ImGui::TableSetupColumn("CCC", ImGuiTableColumnFlags_WidthStretch); - ImGui::TableHeadersRow(); - for (int row = 0; row < 5; row++) - { - ImGui::TableNextRow(); - for (int column = 0; column < 3; column++) - { - ImGui::TableSetColumnIndex(column); - ImGui::Text("%s %d,%d", (column == 2) ? "Stretch" : "Fixed", column, row); - } - } - ImGui::EndTable(); - } - if (ImGui::BeginTable("table2", 6, flags)) - { - ImGui::TableSetupColumn("AAA", ImGuiTableColumnFlags_WidthFixed); - ImGui::TableSetupColumn("BBB", ImGuiTableColumnFlags_WidthFixed); - ImGui::TableSetupColumn("CCC", ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_DefaultHide); - ImGui::TableSetupColumn("DDD", ImGuiTableColumnFlags_WidthStretch); - ImGui::TableSetupColumn("EEE", ImGuiTableColumnFlags_WidthStretch); - ImGui::TableSetupColumn("FFF", ImGuiTableColumnFlags_WidthStretch | ImGuiTableColumnFlags_DefaultHide); - ImGui::TableHeadersRow(); - for (int row = 0; row < 5; row++) - { - ImGui::TableNextRow(); - for (int column = 0; column < 6; column++) - { - ImGui::TableSetColumnIndex(column); - ImGui::Text("%s %d,%d", (column >= 3) ? "Stretch" : "Fixed", column, row); - } - } - ImGui::EndTable(); - } - ImGui::TreePop(); - } - - if (open_action != -1) - ImGui::SetNextItemOpen(open_action != 0); - if (ImGui::TreeNode("Reorderable, hideable, with headers")) - { - HelpMarker( - "Click and drag column headers to reorder columns.\n\n" - "Right-click on a header to open a context menu."); - static ImGuiTableFlags flags = ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV; - PushStyleCompact(); - ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags, ImGuiTableFlags_Resizable); - ImGui::CheckboxFlags("ImGuiTableFlags_Reorderable", &flags, ImGuiTableFlags_Reorderable); - ImGui::CheckboxFlags("ImGuiTableFlags_Hideable", &flags, ImGuiTableFlags_Hideable); - ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBody", &flags, ImGuiTableFlags_NoBordersInBody); - ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBodyUntilResize", &flags, ImGuiTableFlags_NoBordersInBodyUntilResize); ImGui::SameLine(); HelpMarker("Disable vertical borders in columns Body until hovered for resize (borders will always appears in Headers)"); - PopStyleCompact(); - - if (ImGui::BeginTable("table1", 3, flags)) - { - // Submit columns name with TableSetupColumn() and call TableHeadersRow() to create a row with a header in each column. - // (Later we will show how TableSetupColumn() has other uses, optional flags, sizing weight etc.) - ImGui::TableSetupColumn("One"); - ImGui::TableSetupColumn("Two"); - ImGui::TableSetupColumn("Three"); - ImGui::TableHeadersRow(); - for (int row = 0; row < 6; row++) - { - ImGui::TableNextRow(); - for (int column = 0; column < 3; column++) - { - ImGui::TableSetColumnIndex(column); - ImGui::Text("Hello %d,%d", column, row); - } - } - ImGui::EndTable(); - } - - // Use outer_size.x == 0.0f instead of default to make the table as tight as possible (only valid when no scrolling and no stretch column) - if (ImGui::BeginTable("table2", 3, flags | ImGuiTableFlags_SizingFixedFit, ImVec2(0.0f, 0.0f))) - { - ImGui::TableSetupColumn("One"); - ImGui::TableSetupColumn("Two"); - ImGui::TableSetupColumn("Three"); - ImGui::TableHeadersRow(); - for (int row = 0; row < 6; row++) - { - ImGui::TableNextRow(); - for (int column = 0; column < 3; column++) - { - ImGui::TableSetColumnIndex(column); - ImGui::Text("Fixed %d,%d", column, row); - } - } - ImGui::EndTable(); - } - ImGui::TreePop(); - } - - if (open_action != -1) - ImGui::SetNextItemOpen(open_action != 0); - if (ImGui::TreeNode("Padding")) - { - // First example: showcase use of padding flags and effect of BorderOuterV/BorderInnerV on X padding. - // We don't expose BorderOuterH/BorderInnerH here because they have no effect on X padding. - HelpMarker( - "We often want outer padding activated when any using features which makes the edges of a column visible:\n" - "e.g.:\n" - "- BorderOuterV\n" - "- any form of row selection\n" - "Because of this, activating BorderOuterV sets the default to PadOuterX. Using PadOuterX or NoPadOuterX you can override the default.\n\n" - "Actual padding values are using style.CellPadding.\n\n" - "In this demo we don't show horizontal borders to emphasis how they don't affect default horizontal padding."); - - static ImGuiTableFlags flags1 = ImGuiTableFlags_BordersV; - PushStyleCompact(); - ImGui::CheckboxFlags("ImGuiTableFlags_PadOuterX", &flags1, ImGuiTableFlags_PadOuterX); - ImGui::SameLine(); HelpMarker("Enable outer-most padding (default if ImGuiTableFlags_BordersOuterV is set)"); - ImGui::CheckboxFlags("ImGuiTableFlags_NoPadOuterX", &flags1, ImGuiTableFlags_NoPadOuterX); - ImGui::SameLine(); HelpMarker("Disable outer-most padding (default if ImGuiTableFlags_BordersOuterV is not set)"); - ImGui::CheckboxFlags("ImGuiTableFlags_NoPadInnerX", &flags1, ImGuiTableFlags_NoPadInnerX); - ImGui::SameLine(); HelpMarker("Disable inner padding between columns (double inner padding if BordersOuterV is on, single inner padding if BordersOuterV is off)"); - ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterV", &flags1, ImGuiTableFlags_BordersOuterV); - ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerV", &flags1, ImGuiTableFlags_BordersInnerV); - static bool show_headers = false; - ImGui::Checkbox("show_headers", &show_headers); - PopStyleCompact(); - - if (ImGui::BeginTable("table_padding", 3, flags1)) - { - if (show_headers) - { - ImGui::TableSetupColumn("One"); - ImGui::TableSetupColumn("Two"); - ImGui::TableSetupColumn("Three"); - ImGui::TableHeadersRow(); - } - - for (int row = 0; row < 5; row++) - { - ImGui::TableNextRow(); - for (int column = 0; column < 3; column++) - { - ImGui::TableSetColumnIndex(column); - if (row == 0) - { - ImGui::Text("Avail %.2f", ImGui::GetContentRegionAvail().x); - } - else - { - char buf[32]; - sprintf(buf, "Hello %d,%d", column, row); - ImGui::Button(buf, ImVec2(-FLT_MIN, 0.0f)); - } - //if (ImGui::TableGetColumnFlags() & ImGuiTableColumnFlags_IsHovered) - // ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, IM_COL32(0, 100, 0, 255)); - } - } - ImGui::EndTable(); - } - - // Second example: set style.CellPadding to (0.0) or a custom value. - // FIXME-TABLE: Vertical border effectively not displayed the same way as horizontal one... - HelpMarker("Setting style.CellPadding to (0,0) or a custom value."); - static ImGuiTableFlags flags2 = ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg; - static ImVec2 cell_padding(0.0f, 0.0f); - static bool show_widget_frame_bg = true; - - PushStyleCompact(); - ImGui::CheckboxFlags("ImGuiTableFlags_Borders", &flags2, ImGuiTableFlags_Borders); - ImGui::CheckboxFlags("ImGuiTableFlags_BordersH", &flags2, ImGuiTableFlags_BordersH); - ImGui::CheckboxFlags("ImGuiTableFlags_BordersV", &flags2, ImGuiTableFlags_BordersV); - ImGui::CheckboxFlags("ImGuiTableFlags_BordersInner", &flags2, ImGuiTableFlags_BordersInner); - ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuter", &flags2, ImGuiTableFlags_BordersOuter); - ImGui::CheckboxFlags("ImGuiTableFlags_RowBg", &flags2, ImGuiTableFlags_RowBg); - ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags2, ImGuiTableFlags_Resizable); - ImGui::Checkbox("show_widget_frame_bg", &show_widget_frame_bg); - ImGui::SliderFloat2("CellPadding", &cell_padding.x, 0.0f, 10.0f, "%.0f"); - PopStyleCompact(); - - ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, cell_padding); - if (ImGui::BeginTable("table_padding_2", 3, flags2)) - { - static char text_bufs[3 * 5][16]; // Mini text storage for 3x5 cells - static bool init = true; - if (!show_widget_frame_bg) - ImGui::PushStyleColor(ImGuiCol_FrameBg, 0); - for (int cell = 0; cell < 3 * 5; cell++) - { - ImGui::TableNextColumn(); - if (init) - strcpy(text_bufs[cell], "edit me"); - ImGui::SetNextItemWidth(-FLT_MIN); - ImGui::PushID(cell); - ImGui::InputText("##cell", text_bufs[cell], IM_ARRAYSIZE(text_bufs[cell])); - ImGui::PopID(); - } - if (!show_widget_frame_bg) - ImGui::PopStyleColor(); - init = false; - ImGui::EndTable(); - } - ImGui::PopStyleVar(); - - ImGui::TreePop(); - } - - if (open_action != -1) - ImGui::SetNextItemOpen(open_action != 0); - if (ImGui::TreeNode("Sizing policies")) - { - static ImGuiTableFlags flags1 = ImGuiTableFlags_BordersV | ImGuiTableFlags_BordersOuterH | ImGuiTableFlags_RowBg | ImGuiTableFlags_ContextMenuInBody; - PushStyleCompact(); - ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags1, ImGuiTableFlags_Resizable); - ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendX", &flags1, ImGuiTableFlags_NoHostExtendX); - PopStyleCompact(); - - static ImGuiTableFlags sizing_policy_flags[4] = { ImGuiTableFlags_SizingFixedFit, ImGuiTableFlags_SizingFixedSame, ImGuiTableFlags_SizingStretchProp, ImGuiTableFlags_SizingStretchSame }; - for (int table_n = 0; table_n < 4; table_n++) - { - ImGui::PushID(table_n); - ImGui::SetNextItemWidth(TEXT_BASE_WIDTH * 30); - EditTableSizingFlags(&sizing_policy_flags[table_n]); - - // To make it easier to understand the different sizing policy, - // For each policy: we display one table where the columns have equal contents width, and one where the columns have different contents width. - if (ImGui::BeginTable("table1", 3, sizing_policy_flags[table_n] | flags1)) - { - for (int row = 0; row < 3; row++) - { - ImGui::TableNextRow(); - ImGui::TableNextColumn(); ImGui::Text("Oh dear"); - ImGui::TableNextColumn(); ImGui::Text("Oh dear"); - ImGui::TableNextColumn(); ImGui::Text("Oh dear"); - } - ImGui::EndTable(); - } - if (ImGui::BeginTable("table2", 3, sizing_policy_flags[table_n] | flags1)) - { - for (int row = 0; row < 3; row++) - { - ImGui::TableNextRow(); - ImGui::TableNextColumn(); ImGui::Text("AAAA"); - ImGui::TableNextColumn(); ImGui::Text("BBBBBBBB"); - ImGui::TableNextColumn(); ImGui::Text("CCCCCCCCCCCC"); - } - ImGui::EndTable(); - } - ImGui::PopID(); - } - - ImGui::Spacing(); - ImGui::TextUnformatted("Advanced"); - ImGui::SameLine(); - HelpMarker("This section allows you to interact and see the effect of various sizing policies depending on whether Scroll is enabled and the contents of your columns."); - - enum ContentsType { CT_ShowWidth, CT_ShortText, CT_LongText, CT_Button, CT_FillButton, CT_InputText }; - static ImGuiTableFlags flags = ImGuiTableFlags_ScrollY | ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_Resizable; - static int contents_type = CT_ShowWidth; - static int column_count = 3; - - PushStyleCompact(); - ImGui::PushID("Advanced"); - ImGui::PushItemWidth(TEXT_BASE_WIDTH * 30); - EditTableSizingFlags(&flags); - ImGui::Combo("Contents", &contents_type, "Show width\0Short Text\0Long Text\0Button\0Fill Button\0InputText\0"); - if (contents_type == CT_FillButton) - { - ImGui::SameLine(); - HelpMarker("Be mindful that using right-alignment (e.g. size.x = -FLT_MIN) creates a feedback loop where contents width can feed into auto-column width can feed into contents width."); - } - ImGui::DragInt("Columns", &column_count, 0.1f, 1, 64, "%d", ImGuiSliderFlags_AlwaysClamp); - ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags, ImGuiTableFlags_Resizable); - ImGui::CheckboxFlags("ImGuiTableFlags_PreciseWidths", &flags, ImGuiTableFlags_PreciseWidths); - ImGui::SameLine(); HelpMarker("Disable distributing remainder width to stretched columns (width allocation on a 100-wide table with 3 columns: Without this flag: 33,33,34. With this flag: 33,33,33). With larger number of columns, resizing will appear to be less smooth."); - ImGui::CheckboxFlags("ImGuiTableFlags_ScrollX", &flags, ImGuiTableFlags_ScrollX); - ImGui::CheckboxFlags("ImGuiTableFlags_ScrollY", &flags, ImGuiTableFlags_ScrollY); - ImGui::CheckboxFlags("ImGuiTableFlags_NoClip", &flags, ImGuiTableFlags_NoClip); - ImGui::PopItemWidth(); - ImGui::PopID(); - PopStyleCompact(); - - if (ImGui::BeginTable("table2", column_count, flags, ImVec2(0.0f, TEXT_BASE_HEIGHT * 7))) - { - for (int cell = 0; cell < 10 * column_count; cell++) - { - ImGui::TableNextColumn(); - int column = ImGui::TableGetColumnIndex(); - int row = ImGui::TableGetRowIndex(); - - ImGui::PushID(cell); - char label[32]; - static char text_buf[32] = ""; - sprintf(label, "Hello %d,%d", column, row); - switch (contents_type) - { - case CT_ShortText: ImGui::TextUnformatted(label); break; - case CT_LongText: ImGui::Text("Some %s text %d,%d\nOver two lines..", column == 0 ? "long" : "longeeer", column, row); break; - case CT_ShowWidth: ImGui::Text("W: %.1f", ImGui::GetContentRegionAvail().x); break; - case CT_Button: ImGui::Button(label); break; - case CT_FillButton: ImGui::Button(label, ImVec2(-FLT_MIN, 0.0f)); break; - case CT_InputText: ImGui::SetNextItemWidth(-FLT_MIN); ImGui::InputText("##", text_buf, IM_ARRAYSIZE(text_buf)); break; - } - ImGui::PopID(); - } - ImGui::EndTable(); - } - ImGui::TreePop(); - } - - if (open_action != -1) - ImGui::SetNextItemOpen(open_action != 0); - if (ImGui::TreeNode("Vertical scrolling, with clipping")) - { - HelpMarker("Here we activate ScrollY, which will create a child window container to allow hosting scrollable contents.\n\nWe also demonstrate using ImGuiListClipper to virtualize the submission of many items."); - static ImGuiTableFlags flags = ImGuiTableFlags_ScrollY | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable; - - PushStyleCompact(); - ImGui::CheckboxFlags("ImGuiTableFlags_ScrollY", &flags, ImGuiTableFlags_ScrollY); - PopStyleCompact(); - - // When using ScrollX or ScrollY we need to specify a size for our table container! - // Otherwise by default the table will fit all available space, like a BeginChild() call. - ImVec2 outer_size = ImVec2(0.0f, TEXT_BASE_HEIGHT * 8); - if (ImGui::BeginTable("table_scrolly", 3, flags, outer_size)) - { - ImGui::TableSetupScrollFreeze(0, 1); // Make top row always visible - ImGui::TableSetupColumn("One", ImGuiTableColumnFlags_None); - ImGui::TableSetupColumn("Two", ImGuiTableColumnFlags_None); - ImGui::TableSetupColumn("Three", ImGuiTableColumnFlags_None); - ImGui::TableHeadersRow(); - - // Demonstrate using clipper for large vertical lists - ImGuiListClipper clipper; - clipper.Begin(1000); - while (clipper.Step()) - { - for (int row = clipper.DisplayStart; row < clipper.DisplayEnd; row++) - { - ImGui::TableNextRow(); - for (int column = 0; column < 3; column++) - { - ImGui::TableSetColumnIndex(column); - ImGui::Text("Hello %d,%d", column, row); - } - } - } - ImGui::EndTable(); - } - ImGui::TreePop(); - } - - if (open_action != -1) - ImGui::SetNextItemOpen(open_action != 0); - if (ImGui::TreeNode("Horizontal scrolling")) - { - HelpMarker( - "When ScrollX is enabled, the default sizing policy becomes ImGuiTableFlags_SizingFixedFit, " - "as automatically stretching columns doesn't make much sense with horizontal scrolling.\n\n" - "Also note that as of the current version, you will almost always want to enable ScrollY along with ScrollX," - "because the container window won't automatically extend vertically to fix contents (this may be improved in future versions)."); - static ImGuiTableFlags flags = ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable; - static int freeze_cols = 1; - static int freeze_rows = 1; - - PushStyleCompact(); - ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags, ImGuiTableFlags_Resizable); - ImGui::CheckboxFlags("ImGuiTableFlags_ScrollX", &flags, ImGuiTableFlags_ScrollX); - ImGui::CheckboxFlags("ImGuiTableFlags_ScrollY", &flags, ImGuiTableFlags_ScrollY); - ImGui::SetNextItemWidth(ImGui::GetFrameHeight()); - ImGui::DragInt("freeze_cols", &freeze_cols, 0.2f, 0, 9, NULL, ImGuiSliderFlags_NoInput); - ImGui::SetNextItemWidth(ImGui::GetFrameHeight()); - ImGui::DragInt("freeze_rows", &freeze_rows, 0.2f, 0, 9, NULL, ImGuiSliderFlags_NoInput); - PopStyleCompact(); - - // When using ScrollX or ScrollY we need to specify a size for our table container! - // Otherwise by default the table will fit all available space, like a BeginChild() call. - ImVec2 outer_size = ImVec2(0.0f, TEXT_BASE_HEIGHT * 8); - if (ImGui::BeginTable("table_scrollx", 7, flags, outer_size)) - { - ImGui::TableSetupScrollFreeze(freeze_cols, freeze_rows); - ImGui::TableSetupColumn("Line #", ImGuiTableColumnFlags_NoHide); // Make the first column not hideable to match our use of TableSetupScrollFreeze() - ImGui::TableSetupColumn("One"); - ImGui::TableSetupColumn("Two"); - ImGui::TableSetupColumn("Three"); - ImGui::TableSetupColumn("Four"); - ImGui::TableSetupColumn("Five"); - ImGui::TableSetupColumn("Six"); - ImGui::TableHeadersRow(); - for (int row = 0; row < 20; row++) - { - ImGui::TableNextRow(); - for (int column = 0; column < 7; column++) - { - // Both TableNextColumn() and TableSetColumnIndex() return true when a column is visible or performing width measurement. - // Because here we know that: - // - A) all our columns are contributing the same to row height - // - B) column 0 is always visible, - // We only always submit this one column and can skip others. - // More advanced per-column clipping behaviors may benefit from polling the status flags via TableGetColumnFlags(). - if (!ImGui::TableSetColumnIndex(column) && column > 0) - continue; - if (column == 0) - ImGui::Text("Line %d", row); - else - ImGui::Text("Hello world %d,%d", column, row); - } - } - ImGui::EndTable(); - } - - ImGui::Spacing(); - ImGui::TextUnformatted("Stretch + ScrollX"); - ImGui::SameLine(); - HelpMarker( - "Showcase using Stretch columns + ScrollX together: " - "this is rather unusual and only makes sense when specifying an 'inner_width' for the table!\n" - "Without an explicit value, inner_width is == outer_size.x and therefore using Stretch columns + ScrollX together doesn't make sense."); - static ImGuiTableFlags flags2 = ImGuiTableFlags_SizingStretchSame | ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_RowBg | ImGuiTableFlags_ContextMenuInBody; - static float inner_width = 1000.0f; - PushStyleCompact(); - ImGui::PushID("flags3"); - ImGui::PushItemWidth(TEXT_BASE_WIDTH * 30); - ImGui::CheckboxFlags("ImGuiTableFlags_ScrollX", &flags2, ImGuiTableFlags_ScrollX); - ImGui::DragFloat("inner_width", &inner_width, 1.0f, 0.0f, FLT_MAX, "%.1f"); - ImGui::PopItemWidth(); - ImGui::PopID(); - PopStyleCompact(); - if (ImGui::BeginTable("table2", 7, flags2, outer_size, inner_width)) - { - for (int cell = 0; cell < 20 * 7; cell++) - { - ImGui::TableNextColumn(); - ImGui::Text("Hello world %d,%d", ImGui::TableGetColumnIndex(), ImGui::TableGetRowIndex()); - } - ImGui::EndTable(); - } - ImGui::TreePop(); - } - - if (open_action != -1) - ImGui::SetNextItemOpen(open_action != 0); - if (ImGui::TreeNode("Columns flags")) - { - // Create a first table just to show all the options/flags we want to make visible in our example! - const int column_count = 3; - const char* column_names[column_count] = { "One", "Two", "Three" }; - static ImGuiTableColumnFlags column_flags[column_count] = { ImGuiTableColumnFlags_DefaultSort, ImGuiTableColumnFlags_None, ImGuiTableColumnFlags_DefaultHide }; - static ImGuiTableColumnFlags column_flags_out[column_count] = { 0, 0, 0 }; // Output from TableGetColumnFlags() - - if (ImGui::BeginTable("table_columns_flags_checkboxes", column_count, ImGuiTableFlags_None)) - { - PushStyleCompact(); - for (int column = 0; column < column_count; column++) - { - ImGui::TableNextColumn(); - ImGui::PushID(column); - ImGui::AlignTextToFramePadding(); // FIXME-TABLE: Workaround for wrong text baseline propagation - ImGui::Text("'%s'", column_names[column]); - ImGui::Spacing(); - ImGui::Text("Input flags:"); - EditTableColumnsFlags(&column_flags[column]); - ImGui::Spacing(); - ImGui::Text("Output flags:"); - ShowTableColumnsStatusFlags(column_flags_out[column]); - ImGui::PopID(); - } - PopStyleCompact(); - ImGui::EndTable(); - } - - // Create the real table we care about for the example! - // We use a scrolling table to be able to showcase the difference between the _IsEnabled and _IsVisible flags above, otherwise in - // a non-scrolling table columns are always visible (unless using ImGuiTableFlags_NoKeepColumnsVisible + resizing the parent window down) - const ImGuiTableFlags flags - = ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY - | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV - | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Sortable; - ImVec2 outer_size = ImVec2(0.0f, TEXT_BASE_HEIGHT * 9); - if (ImGui::BeginTable("table_columns_flags", column_count, flags, outer_size)) - { - for (int column = 0; column < column_count; column++) - ImGui::TableSetupColumn(column_names[column], column_flags[column]); - ImGui::TableHeadersRow(); - for (int column = 0; column < column_count; column++) - column_flags_out[column] = ImGui::TableGetColumnFlags(column); - float indent_step = (float)((int)TEXT_BASE_WIDTH / 2); - for (int row = 0; row < 8; row++) - { - ImGui::Indent(indent_step); // Add some indentation to demonstrate usage of per-column IndentEnable/IndentDisable flags. - ImGui::TableNextRow(); - for (int column = 0; column < column_count; column++) - { - ImGui::TableSetColumnIndex(column); - ImGui::Text("%s %s", (column == 0) ? "Indented" : "Hello", ImGui::TableGetColumnName(column)); - } - } - ImGui::Unindent(indent_step * 8.0f); - - ImGui::EndTable(); - } - ImGui::TreePop(); - } - - if (open_action != -1) - ImGui::SetNextItemOpen(open_action != 0); - if (ImGui::TreeNode("Columns widths")) - { - HelpMarker("Using TableSetupColumn() to setup default width."); - - static ImGuiTableFlags flags1 = ImGuiTableFlags_Borders | ImGuiTableFlags_NoBordersInBodyUntilResize; - PushStyleCompact(); - ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags1, ImGuiTableFlags_Resizable); - ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBodyUntilResize", &flags1, ImGuiTableFlags_NoBordersInBodyUntilResize); - PopStyleCompact(); - if (ImGui::BeginTable("table1", 3, flags1)) - { - // We could also set ImGuiTableFlags_SizingFixedFit on the table and all columns will default to ImGuiTableColumnFlags_WidthFixed. - ImGui::TableSetupColumn("one", ImGuiTableColumnFlags_WidthFixed, 100.0f); // Default to 100.0f - ImGui::TableSetupColumn("two", ImGuiTableColumnFlags_WidthFixed, 200.0f); // Default to 200.0f - ImGui::TableSetupColumn("three", ImGuiTableColumnFlags_WidthFixed); // Default to auto - ImGui::TableHeadersRow(); - for (int row = 0; row < 4; row++) - { - ImGui::TableNextRow(); - for (int column = 0; column < 3; column++) - { - ImGui::TableSetColumnIndex(column); - if (row == 0) - ImGui::Text("(w: %5.1f)", ImGui::GetContentRegionAvail().x); - else - ImGui::Text("Hello %d,%d", column, row); - } - } - ImGui::EndTable(); - } - - HelpMarker("Using TableSetupColumn() to setup explicit width.\n\nUnless _NoKeepColumnsVisible is set, fixed columns with set width may still be shrunk down if there's not enough space in the host."); - - static ImGuiTableFlags flags2 = ImGuiTableFlags_None; - PushStyleCompact(); - ImGui::CheckboxFlags("ImGuiTableFlags_NoKeepColumnsVisible", &flags2, ImGuiTableFlags_NoKeepColumnsVisible); - ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerV", &flags2, ImGuiTableFlags_BordersInnerV); - ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterV", &flags2, ImGuiTableFlags_BordersOuterV); - PopStyleCompact(); - if (ImGui::BeginTable("table2", 4, flags2)) - { - // We could also set ImGuiTableFlags_SizingFixedFit on the table and all columns will default to ImGuiTableColumnFlags_WidthFixed. - ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, 100.0f); - ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 15.0f); - ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 30.0f); - ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 15.0f); - for (int row = 0; row < 5; row++) - { - ImGui::TableNextRow(); - for (int column = 0; column < 4; column++) - { - ImGui::TableSetColumnIndex(column); - if (row == 0) - ImGui::Text("(w: %5.1f)", ImGui::GetContentRegionAvail().x); - else - ImGui::Text("Hello %d,%d", column, row); - } - } - ImGui::EndTable(); - } - ImGui::TreePop(); - } - - if (open_action != -1) - ImGui::SetNextItemOpen(open_action != 0); - if (ImGui::TreeNode("Nested tables")) - { - HelpMarker("This demonstrate embedding a table into another table cell."); - - if (ImGui::BeginTable("table_nested1", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable)) - { - ImGui::TableSetupColumn("A0"); - ImGui::TableSetupColumn("A1"); - ImGui::TableHeadersRow(); - - ImGui::TableNextColumn(); - ImGui::Text("A0 Row 0"); - { - float rows_height = TEXT_BASE_HEIGHT * 2; - if (ImGui::BeginTable("table_nested2", 2, ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable)) - { - ImGui::TableSetupColumn("B0"); - ImGui::TableSetupColumn("B1"); - ImGui::TableHeadersRow(); - - ImGui::TableNextRow(ImGuiTableRowFlags_None, rows_height); - ImGui::TableNextColumn(); - ImGui::Text("B0 Row 0"); - ImGui::TableNextColumn(); - ImGui::Text("B1 Row 0"); - ImGui::TableNextRow(ImGuiTableRowFlags_None, rows_height); - ImGui::TableNextColumn(); - ImGui::Text("B0 Row 1"); - ImGui::TableNextColumn(); - ImGui::Text("B1 Row 1"); - - ImGui::EndTable(); - } - } - ImGui::TableNextColumn(); ImGui::Text("A1 Row 0"); - ImGui::TableNextColumn(); ImGui::Text("A0 Row 1"); - ImGui::TableNextColumn(); ImGui::Text("A1 Row 1"); - ImGui::EndTable(); - } - ImGui::TreePop(); - } - - if (open_action != -1) - ImGui::SetNextItemOpen(open_action != 0); - if (ImGui::TreeNode("Row height")) - { - HelpMarker("You can pass a 'min_row_height' to TableNextRow().\n\nRows are padded with 'style.CellPadding.y' on top and bottom, so effectively the minimum row height will always be >= 'style.CellPadding.y * 2.0f'.\n\nWe cannot honor a _maximum_ row height as that would requires a unique clipping rectangle per row."); - if (ImGui::BeginTable("table_row_height", 1, ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersInnerV)) - { - for (int row = 0; row < 10; row++) - { - float min_row_height = (float)(int)(TEXT_BASE_HEIGHT * 0.30f * row); - ImGui::TableNextRow(ImGuiTableRowFlags_None, min_row_height); - ImGui::TableNextColumn(); - ImGui::Text("min_row_height = %.2f", min_row_height); - } - ImGui::EndTable(); - } - ImGui::TreePop(); - } - - if (open_action != -1) - ImGui::SetNextItemOpen(open_action != 0); - if (ImGui::TreeNode("Outer size")) - { - // Showcasing use of ImGuiTableFlags_NoHostExtendX and ImGuiTableFlags_NoHostExtendY - // Important to that note how the two flags have slightly different behaviors! - ImGui::Text("Using NoHostExtendX and NoHostExtendY:"); - PushStyleCompact(); - static ImGuiTableFlags flags = ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable | ImGuiTableFlags_ContextMenuInBody | ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_NoHostExtendX; - ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendX", &flags, ImGuiTableFlags_NoHostExtendX); - ImGui::SameLine(); HelpMarker("Make outer width auto-fit to columns, overriding outer_size.x value.\n\nOnly available when ScrollX/ScrollY are disabled and Stretch columns are not used."); - ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendY", &flags, ImGuiTableFlags_NoHostExtendY); - ImGui::SameLine(); HelpMarker("Make outer height stop exactly at outer_size.y (prevent auto-extending table past the limit).\n\nOnly available when ScrollX/ScrollY are disabled. Data below the limit will be clipped and not visible."); - PopStyleCompact(); - - ImVec2 outer_size = ImVec2(0.0f, TEXT_BASE_HEIGHT * 5.5f); - if (ImGui::BeginTable("table1", 3, flags, outer_size)) - { - for (int row = 0; row < 10; row++) - { - ImGui::TableNextRow(); - for (int column = 0; column < 3; column++) - { - ImGui::TableNextColumn(); - ImGui::Text("Cell %d,%d", column, row); - } - } - ImGui::EndTable(); - } - ImGui::SameLine(); - ImGui::Text("Hello!"); - - ImGui::Spacing(); - - ImGui::Text("Using explicit size:"); - if (ImGui::BeginTable("table2", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg, ImVec2(TEXT_BASE_WIDTH * 30, 0.0f))) - { - for (int row = 0; row < 5; row++) - { - ImGui::TableNextRow(); - for (int column = 0; column < 3; column++) - { - ImGui::TableNextColumn(); - ImGui::Text("Cell %d,%d", column, row); - } - } - ImGui::EndTable(); - } - ImGui::SameLine(); - if (ImGui::BeginTable("table3", 3, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg, ImVec2(TEXT_BASE_WIDTH * 30, 0.0f))) - { - for (int row = 0; row < 3; row++) - { - ImGui::TableNextRow(0, TEXT_BASE_HEIGHT * 1.5f); - for (int column = 0; column < 3; column++) - { - ImGui::TableNextColumn(); - ImGui::Text("Cell %d,%d", column, row); - } - } - ImGui::EndTable(); - } - - ImGui::TreePop(); - } - - if (open_action != -1) - ImGui::SetNextItemOpen(open_action != 0); - if (ImGui::TreeNode("Background color")) - { - static ImGuiTableFlags flags = ImGuiTableFlags_RowBg; - static int row_bg_type = 1; - static int row_bg_target = 1; - static int cell_bg_type = 1; - - PushStyleCompact(); - ImGui::CheckboxFlags("ImGuiTableFlags_Borders", &flags, ImGuiTableFlags_Borders); - ImGui::CheckboxFlags("ImGuiTableFlags_RowBg", &flags, ImGuiTableFlags_RowBg); - ImGui::SameLine(); HelpMarker("ImGuiTableFlags_RowBg automatically sets RowBg0 to alternative colors pulled from the Style."); - ImGui::Combo("row bg type", (int*)&row_bg_type, "None\0Red\0Gradient\0"); - ImGui::Combo("row bg target", (int*)&row_bg_target, "RowBg0\0RowBg1\0"); ImGui::SameLine(); HelpMarker("Target RowBg0 to override the alternating odd/even colors,\nTarget RowBg1 to blend with them."); - ImGui::Combo("cell bg type", (int*)&cell_bg_type, "None\0Blue\0"); ImGui::SameLine(); HelpMarker("We are colorizing cells to B1->C2 here."); - IM_ASSERT(row_bg_type >= 0 && row_bg_type <= 2); - IM_ASSERT(row_bg_target >= 0 && row_bg_target <= 1); - IM_ASSERT(cell_bg_type >= 0 && cell_bg_type <= 1); - PopStyleCompact(); - - if (ImGui::BeginTable("table1", 5, flags)) - { - for (int row = 0; row < 6; row++) - { - ImGui::TableNextRow(); - - // Demonstrate setting a row background color with 'ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBgX, ...)' - // We use a transparent color so we can see the one behind in case our target is RowBg1 and RowBg0 was already targeted by the ImGuiTableFlags_RowBg flag. - if (row_bg_type != 0) - { - ImU32 row_bg_color = ImGui::GetColorU32(row_bg_type == 1 ? ImVec4(0.7f, 0.3f, 0.3f, 0.65f) : ImVec4(0.2f + row * 0.1f, 0.2f, 0.2f, 0.65f)); // Flat or Gradient? - ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg0 + row_bg_target, row_bg_color); - } - - // Fill cells - for (int column = 0; column < 5; column++) - { - ImGui::TableSetColumnIndex(column); - ImGui::Text("%c%c", 'A' + row, '0' + column); - - // Change background of Cells B1->C2 - // Demonstrate setting a cell background color with 'ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, ...)' - // (the CellBg color will be blended over the RowBg and ColumnBg colors) - // We can also pass a column number as a third parameter to TableSetBgColor() and do this outside the column loop. - if (row >= 1 && row <= 2 && column >= 1 && column <= 2 && cell_bg_type == 1) - { - ImU32 cell_bg_color = ImGui::GetColorU32(ImVec4(0.3f, 0.3f, 0.7f, 0.65f)); - ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, cell_bg_color); - } - } - } - ImGui::EndTable(); - } - ImGui::TreePop(); - } - - if (open_action != -1) - ImGui::SetNextItemOpen(open_action != 0); - if (ImGui::TreeNode("Tree view")) - { - static ImGuiTableFlags flags = ImGuiTableFlags_BordersV | ImGuiTableFlags_BordersOuterH | ImGuiTableFlags_Resizable | ImGuiTableFlags_RowBg | ImGuiTableFlags_NoBordersInBody; - - if (ImGui::BeginTable("3ways", 3, flags)) - { - // The first column will use the default _WidthStretch when ScrollX is Off and _WidthFixed when ScrollX is On - ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_NoHide); - ImGui::TableSetupColumn("Size", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 12.0f); - ImGui::TableSetupColumn("Type", ImGuiTableColumnFlags_WidthFixed, TEXT_BASE_WIDTH * 18.0f); - ImGui::TableHeadersRow(); - - // Simple storage to output a dummy file-system. - struct MyTreeNode - { - const char* Name; - const char* Type; - int Size; - int ChildIdx; - int ChildCount; - static void DisplayNode(const MyTreeNode* node, const MyTreeNode* all_nodes) - { - ImGui::TableNextRow(); - ImGui::TableNextColumn(); - const bool is_folder = (node->ChildCount > 0); - if (is_folder) - { - bool open = ImGui::TreeNodeEx(node->Name, ImGuiTreeNodeFlags_SpanFullWidth); - ImGui::TableNextColumn(); - ImGui::TextDisabled("--"); - ImGui::TableNextColumn(); - ImGui::TextUnformatted(node->Type); - if (open) - { - for (int child_n = 0; child_n < node->ChildCount; child_n++) - DisplayNode(&all_nodes[node->ChildIdx + child_n], all_nodes); - ImGui::TreePop(); - } - } - else - { - ImGui::TreeNodeEx(node->Name, ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_Bullet | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_SpanFullWidth); - ImGui::TableNextColumn(); - ImGui::Text("%d", node->Size); - ImGui::TableNextColumn(); - ImGui::TextUnformatted(node->Type); - } - } - }; - static const MyTreeNode nodes[] = - { - { "Root", "Folder", -1, 1, 3 }, // 0 - { "Music", "Folder", -1, 4, 2 }, // 1 - { "Textures", "Folder", -1, 6, 3 }, // 2 - { "desktop.ini", "System file", 1024, -1,-1 }, // 3 - { "File1_a.wav", "Audio file", 123000, -1,-1 }, // 4 - { "File1_b.wav", "Audio file", 456000, -1,-1 }, // 5 - { "Image001.png", "Image file", 203128, -1,-1 }, // 6 - { "Copy of Image001.png", "Image file", 203256, -1,-1 }, // 7 - { "Copy of Image001 (Final2).png","Image file", 203512, -1,-1 }, // 8 - }; - - MyTreeNode::DisplayNode(&nodes[0], nodes); - - ImGui::EndTable(); - } - ImGui::TreePop(); - } - - if (open_action != -1) - ImGui::SetNextItemOpen(open_action != 0); - if (ImGui::TreeNode("Item width")) - { - HelpMarker( - "Showcase using PushItemWidth() and how it is preserved on a per-column basis.\n\n" - "Note that on auto-resizing non-resizable fixed columns, querying the content width for e.g. right-alignment doesn't make sense."); - if (ImGui::BeginTable("table_item_width", 3, ImGuiTableFlags_Borders)) - { - ImGui::TableSetupColumn("small"); - ImGui::TableSetupColumn("half"); - ImGui::TableSetupColumn("right-align"); - ImGui::TableHeadersRow(); - - for (int row = 0; row < 3; row++) - { - ImGui::TableNextRow(); - if (row == 0) - { - // Setup ItemWidth once (instead of setting up every time, which is also possible but less efficient) - ImGui::TableSetColumnIndex(0); - ImGui::PushItemWidth(TEXT_BASE_WIDTH * 3.0f); // Small - ImGui::TableSetColumnIndex(1); - ImGui::PushItemWidth(-ImGui::GetContentRegionAvail().x * 0.5f); - ImGui::TableSetColumnIndex(2); - ImGui::PushItemWidth(-FLT_MIN); // Right-aligned - } - - // Draw our contents - static float dummy_f = 0.0f; - ImGui::PushID(row); - ImGui::TableSetColumnIndex(0); - ImGui::SliderFloat("float0", &dummy_f, 0.0f, 1.0f); - ImGui::TableSetColumnIndex(1); - ImGui::SliderFloat("float1", &dummy_f, 0.0f, 1.0f); - ImGui::TableSetColumnIndex(2); - ImGui::SliderFloat("float2", &dummy_f, 0.0f, 1.0f); - ImGui::PopID(); - } - ImGui::EndTable(); - } - ImGui::TreePop(); - } - - // Demonstrate using TableHeader() calls instead of TableHeadersRow() - if (open_action != -1) - ImGui::SetNextItemOpen(open_action != 0); - if (ImGui::TreeNode("Custom headers")) - { - const int COLUMNS_COUNT = 3; - if (ImGui::BeginTable("table_custom_headers", COLUMNS_COUNT, ImGuiTableFlags_Borders | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable)) - { - ImGui::TableSetupColumn("Apricot"); - ImGui::TableSetupColumn("Banana"); - ImGui::TableSetupColumn("Cherry"); - - // Dummy entire-column selection storage - // FIXME: It would be nice to actually demonstrate full-featured selection using those checkbox. - static bool column_selected[3] = {}; - - // Instead of calling TableHeadersRow() we'll submit custom headers ourselves - ImGui::TableNextRow(ImGuiTableRowFlags_Headers); - for (int column = 0; column < COLUMNS_COUNT; column++) - { - ImGui::TableSetColumnIndex(column); - const char* column_name = ImGui::TableGetColumnName(column); // Retrieve name passed to TableSetupColumn() - ImGui::PushID(column); - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0)); - ImGui::Checkbox("##checkall", &column_selected[column]); - ImGui::PopStyleVar(); - ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x); - ImGui::TableHeader(column_name); - ImGui::PopID(); - } - - for (int row = 0; row < 5; row++) - { - ImGui::TableNextRow(); - for (int column = 0; column < 3; column++) - { - char buf[32]; - sprintf(buf, "Cell %d,%d", column, row); - ImGui::TableSetColumnIndex(column); - ImGui::Selectable(buf, column_selected[column]); - } - } - ImGui::EndTable(); - } - ImGui::TreePop(); - } - - // Demonstrate creating custom context menus inside columns, while playing it nice with context menus provided by TableHeadersRow()/TableHeader() - if (open_action != -1) - ImGui::SetNextItemOpen(open_action != 0); - if (ImGui::TreeNode("Context menus")) - { - HelpMarker("By default, right-clicking over a TableHeadersRow()/TableHeader() line will open the default context-menu.\nUsing ImGuiTableFlags_ContextMenuInBody we also allow right-clicking over columns body."); - static ImGuiTableFlags flags1 = ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Borders | ImGuiTableFlags_ContextMenuInBody; - - PushStyleCompact(); - ImGui::CheckboxFlags("ImGuiTableFlags_ContextMenuInBody", &flags1, ImGuiTableFlags_ContextMenuInBody); - PopStyleCompact(); - - // Context Menus: first example - // [1.1] Right-click on the TableHeadersRow() line to open the default table context menu. - // [1.2] Right-click in columns also open the default table context menu (if ImGuiTableFlags_ContextMenuInBody is set) - const int COLUMNS_COUNT = 3; - if (ImGui::BeginTable("table_context_menu", COLUMNS_COUNT, flags1)) - { - ImGui::TableSetupColumn("One"); - ImGui::TableSetupColumn("Two"); - ImGui::TableSetupColumn("Three"); - - // [1.1]] Right-click on the TableHeadersRow() line to open the default table context menu. - ImGui::TableHeadersRow(); - - // Submit dummy contents - for (int row = 0; row < 4; row++) - { - ImGui::TableNextRow(); - for (int column = 0; column < COLUMNS_COUNT; column++) - { - ImGui::TableSetColumnIndex(column); - ImGui::Text("Cell %d,%d", column, row); - } - } - ImGui::EndTable(); - } - - // Context Menus: second example - // [2.1] Right-click on the TableHeadersRow() line to open the default table context menu. - // [2.2] Right-click on the ".." to open a custom popup - // [2.3] Right-click in columns to open another custom popup - HelpMarker("Demonstrate mixing table context menu (over header), item context button (over button) and custom per-colum context menu (over column body)."); - ImGuiTableFlags flags2 = ImGuiTableFlags_Resizable | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Borders; - if (ImGui::BeginTable("table_context_menu_2", COLUMNS_COUNT, flags2)) - { - ImGui::TableSetupColumn("One"); - ImGui::TableSetupColumn("Two"); - ImGui::TableSetupColumn("Three"); - - // [2.1] Right-click on the TableHeadersRow() line to open the default table context menu. - ImGui::TableHeadersRow(); - for (int row = 0; row < 4; row++) - { - ImGui::TableNextRow(); - for (int column = 0; column < COLUMNS_COUNT; column++) - { - // Submit dummy contents - ImGui::TableSetColumnIndex(column); - ImGui::Text("Cell %d,%d", column, row); - ImGui::SameLine(); - - // [2.2] Right-click on the ".." to open a custom popup - ImGui::PushID(row * COLUMNS_COUNT + column); - ImGui::SmallButton(".."); - if (ImGui::BeginPopupContextItem()) - { - ImGui::Text("This is the popup for Button(\"..\") in Cell %d,%d", column, row); - if (ImGui::Button("Close")) - ImGui::CloseCurrentPopup(); - ImGui::EndPopup(); - } - ImGui::PopID(); - } - } - - // [2.3] Right-click anywhere in columns to open another custom popup - // (instead of testing for !IsAnyItemHovered() we could also call OpenPopup() with ImGuiPopupFlags_NoOpenOverExistingPopup - // to manage popup priority as the popups triggers, here "are we hovering a column" are overlapping) - int hovered_column = -1; - for (int column = 0; column < COLUMNS_COUNT + 1; column++) - { - ImGui::PushID(column); - if (ImGui::TableGetColumnFlags(column) & ImGuiTableColumnFlags_IsHovered) - hovered_column = column; - if (hovered_column == column && !ImGui::IsAnyItemHovered() && ImGui::IsMouseReleased(1)) - ImGui::OpenPopup("MyPopup"); - if (ImGui::BeginPopup("MyPopup")) - { - if (column == COLUMNS_COUNT) - ImGui::Text("This is a custom popup for unused space after the last column."); - else - ImGui::Text("This is a custom popup for Column %d", column); - if (ImGui::Button("Close")) - ImGui::CloseCurrentPopup(); - ImGui::EndPopup(); - } - ImGui::PopID(); - } - - ImGui::EndTable(); - ImGui::Text("Hovered column: %d", hovered_column); - } - ImGui::TreePop(); - } - - // Demonstrate creating multiple tables with the same ID - if (open_action != -1) - ImGui::SetNextItemOpen(open_action != 0); - if (ImGui::TreeNode("Synced instances")) - { - HelpMarker("Multiple tables with the same identifier will share their settings, width, visibility, order etc."); - for (int n = 0; n < 3; n++) - { - char buf[32]; - sprintf(buf, "Synced Table %d", n); - bool open = ImGui::CollapsingHeader(buf, ImGuiTreeNodeFlags_DefaultOpen); - if (open && ImGui::BeginTable("Table", 3, ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Borders | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_NoSavedSettings)) - { - ImGui::TableSetupColumn("One"); - ImGui::TableSetupColumn("Two"); - ImGui::TableSetupColumn("Three"); - ImGui::TableHeadersRow(); - for (int cell = 0; cell < 9; cell++) - { - ImGui::TableNextColumn(); - ImGui::Text("this cell %d", cell); - } - ImGui::EndTable(); - } - } - ImGui::TreePop(); - } - - // Demonstrate using Sorting facilities - // This is a simplified version of the "Advanced" example, where we mostly focus on the code necessary to handle sorting. - // Note that the "Advanced" example also showcase manually triggering a sort (e.g. if item quantities have been modified) - static const char* template_items_names[] = - { - "Banana", "Apple", "Cherry", "Watermelon", "Grapefruit", "Strawberry", "Mango", - "Kiwi", "Orange", "Pineapple", "Blueberry", "Plum", "Coconut", "Pear", "Apricot" - }; - if (open_action != -1) - ImGui::SetNextItemOpen(open_action != 0); - if (ImGui::TreeNode("Sorting")) - { - // Create item list - static ImVector items; - if (items.Size == 0) - { - items.resize(50, MyItem()); - for (int n = 0; n < items.Size; n++) - { - const int template_n = n % IM_ARRAYSIZE(template_items_names); - MyItem& item = items[n]; - item.ID = n; - item.Name = template_items_names[template_n]; - item.Quantity = (n * n - n) % 20; // Assign default quantities - } - } - - // Options - static ImGuiTableFlags flags = - ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Sortable | ImGuiTableFlags_SortMulti - | ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_BordersV | ImGuiTableFlags_NoBordersInBody - | ImGuiTableFlags_ScrollY; - PushStyleCompact(); - ImGui::CheckboxFlags("ImGuiTableFlags_SortMulti", &flags, ImGuiTableFlags_SortMulti); - ImGui::SameLine(); HelpMarker("When sorting is enabled: hold shift when clicking headers to sort on multiple column. TableGetSortSpecs() may return specs where (SpecsCount > 1)."); - ImGui::CheckboxFlags("ImGuiTableFlags_SortTristate", &flags, ImGuiTableFlags_SortTristate); - ImGui::SameLine(); HelpMarker("When sorting is enabled: allow no sorting, disable default sorting. TableGetSortSpecs() may return specs where (SpecsCount == 0)."); - PopStyleCompact(); - - if (ImGui::BeginTable("table_sorting", 4, flags, ImVec2(0.0f, TEXT_BASE_HEIGHT * 15), 0.0f)) - { - // Declare columns - // We use the "user_id" parameter of TableSetupColumn() to specify a user id that will be stored in the sort specifications. - // This is so our sort function can identify a column given our own identifier. We could also identify them based on their index! - // Demonstrate using a mixture of flags among available sort-related flags: - // - ImGuiTableColumnFlags_DefaultSort - // - ImGuiTableColumnFlags_NoSort / ImGuiTableColumnFlags_NoSortAscending / ImGuiTableColumnFlags_NoSortDescending - // - ImGuiTableColumnFlags_PreferSortAscending / ImGuiTableColumnFlags_PreferSortDescending - ImGui::TableSetupColumn("ID", ImGuiTableColumnFlags_DefaultSort | ImGuiTableColumnFlags_WidthFixed, 0.0f, MyItemColumnID_ID); - ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthFixed, 0.0f, MyItemColumnID_Name); - ImGui::TableSetupColumn("Action", ImGuiTableColumnFlags_NoSort | ImGuiTableColumnFlags_WidthFixed, 0.0f, MyItemColumnID_Action); - ImGui::TableSetupColumn("Quantity", ImGuiTableColumnFlags_PreferSortDescending | ImGuiTableColumnFlags_WidthStretch, 0.0f, MyItemColumnID_Quantity); - ImGui::TableSetupScrollFreeze(0, 1); // Make row always visible - ImGui::TableHeadersRow(); - - // Sort our data if sort specs have been changed! - if (ImGuiTableSortSpecs* sorts_specs = ImGui::TableGetSortSpecs()) - if (sorts_specs->SpecsDirty) - { - MyItem::s_current_sort_specs = sorts_specs; // Store in variable accessible by the sort function. - if (items.Size > 1) - qsort(&items[0], (size_t)items.Size, sizeof(items[0]), MyItem::CompareWithSortSpecs); - MyItem::s_current_sort_specs = NULL; - sorts_specs->SpecsDirty = false; - } - - // Demonstrate using clipper for large vertical lists - ImGuiListClipper clipper; - clipper.Begin(items.Size); - while (clipper.Step()) - for (int row_n = clipper.DisplayStart; row_n < clipper.DisplayEnd; row_n++) - { - // Display a data item - MyItem* item = &items[row_n]; - ImGui::PushID(item->ID); - ImGui::TableNextRow(); - ImGui::TableNextColumn(); - ImGui::Text("%04d", item->ID); - ImGui::TableNextColumn(); - ImGui::TextUnformatted(item->Name); - ImGui::TableNextColumn(); - ImGui::SmallButton("None"); - ImGui::TableNextColumn(); - ImGui::Text("%d", item->Quantity); - ImGui::PopID(); - } - ImGui::EndTable(); - } - ImGui::TreePop(); - } - - // In this example we'll expose most table flags and settings. - // For specific flags and settings refer to the corresponding section for more detailed explanation. - // This section is mostly useful to experiment with combining certain flags or settings with each others. - //ImGui::SetNextItemOpen(true, ImGuiCond_Once); // [DEBUG] - if (open_action != -1) - ImGui::SetNextItemOpen(open_action != 0); - if (ImGui::TreeNode("Advanced")) - { - static ImGuiTableFlags flags = - ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable - | ImGuiTableFlags_Sortable | ImGuiTableFlags_SortMulti - | ImGuiTableFlags_RowBg | ImGuiTableFlags_Borders | ImGuiTableFlags_NoBordersInBody - | ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY - | ImGuiTableFlags_SizingFixedFit; - - enum ContentsType { CT_Text, CT_Button, CT_SmallButton, CT_FillButton, CT_Selectable, CT_SelectableSpanRow }; - static int contents_type = CT_SelectableSpanRow; - const char* contents_type_names[] = { "Text", "Button", "SmallButton", "FillButton", "Selectable", "Selectable (span row)" }; - static int freeze_cols = 1; - static int freeze_rows = 1; - static int items_count = IM_ARRAYSIZE(template_items_names) * 2; - static ImVec2 outer_size_value = ImVec2(0.0f, TEXT_BASE_HEIGHT * 12); - static float row_min_height = 0.0f; // Auto - static float inner_width_with_scroll = 0.0f; // Auto-extend - static bool outer_size_enabled = true; - static bool show_headers = true; - static bool show_wrapped_text = false; - //static ImGuiTextFilter filter; - //ImGui::SetNextItemOpen(true, ImGuiCond_Once); // FIXME-TABLE: Enabling this results in initial clipped first pass on table which tend to affects column sizing - if (ImGui::TreeNode("Options")) - { - // Make the UI compact because there are so many fields - PushStyleCompact(); - ImGui::PushItemWidth(TEXT_BASE_WIDTH * 28.0f); - - if (ImGui::TreeNodeEx("Features:", ImGuiTreeNodeFlags_DefaultOpen)) - { - ImGui::CheckboxFlags("ImGuiTableFlags_Resizable", &flags, ImGuiTableFlags_Resizable); - ImGui::CheckboxFlags("ImGuiTableFlags_Reorderable", &flags, ImGuiTableFlags_Reorderable); - ImGui::CheckboxFlags("ImGuiTableFlags_Hideable", &flags, ImGuiTableFlags_Hideable); - ImGui::CheckboxFlags("ImGuiTableFlags_Sortable", &flags, ImGuiTableFlags_Sortable); - ImGui::CheckboxFlags("ImGuiTableFlags_NoSavedSettings", &flags, ImGuiTableFlags_NoSavedSettings); - ImGui::CheckboxFlags("ImGuiTableFlags_ContextMenuInBody", &flags, ImGuiTableFlags_ContextMenuInBody); - ImGui::TreePop(); - } - - if (ImGui::TreeNodeEx("Decorations:", ImGuiTreeNodeFlags_DefaultOpen)) - { - ImGui::CheckboxFlags("ImGuiTableFlags_RowBg", &flags, ImGuiTableFlags_RowBg); - ImGui::CheckboxFlags("ImGuiTableFlags_BordersV", &flags, ImGuiTableFlags_BordersV); - ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterV", &flags, ImGuiTableFlags_BordersOuterV); - ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerV", &flags, ImGuiTableFlags_BordersInnerV); - ImGui::CheckboxFlags("ImGuiTableFlags_BordersH", &flags, ImGuiTableFlags_BordersH); - ImGui::CheckboxFlags("ImGuiTableFlags_BordersOuterH", &flags, ImGuiTableFlags_BordersOuterH); - ImGui::CheckboxFlags("ImGuiTableFlags_BordersInnerH", &flags, ImGuiTableFlags_BordersInnerH); - ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBody", &flags, ImGuiTableFlags_NoBordersInBody); ImGui::SameLine(); HelpMarker("Disable vertical borders in columns Body (borders will always appears in Headers"); - ImGui::CheckboxFlags("ImGuiTableFlags_NoBordersInBodyUntilResize", &flags, ImGuiTableFlags_NoBordersInBodyUntilResize); ImGui::SameLine(); HelpMarker("Disable vertical borders in columns Body until hovered for resize (borders will always appears in Headers)"); - ImGui::TreePop(); - } - - if (ImGui::TreeNodeEx("Sizing:", ImGuiTreeNodeFlags_DefaultOpen)) - { - EditTableSizingFlags(&flags); - ImGui::SameLine(); HelpMarker("In the Advanced demo we override the policy of each column so those table-wide settings have less effect that typical."); - ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendX", &flags, ImGuiTableFlags_NoHostExtendX); - ImGui::SameLine(); HelpMarker("Make outer width auto-fit to columns, overriding outer_size.x value.\n\nOnly available when ScrollX/ScrollY are disabled and Stretch columns are not used."); - ImGui::CheckboxFlags("ImGuiTableFlags_NoHostExtendY", &flags, ImGuiTableFlags_NoHostExtendY); - ImGui::SameLine(); HelpMarker("Make outer height stop exactly at outer_size.y (prevent auto-extending table past the limit).\n\nOnly available when ScrollX/ScrollY are disabled. Data below the limit will be clipped and not visible."); - ImGui::CheckboxFlags("ImGuiTableFlags_NoKeepColumnsVisible", &flags, ImGuiTableFlags_NoKeepColumnsVisible); - ImGui::SameLine(); HelpMarker("Only available if ScrollX is disabled."); - ImGui::CheckboxFlags("ImGuiTableFlags_PreciseWidths", &flags, ImGuiTableFlags_PreciseWidths); - ImGui::SameLine(); HelpMarker("Disable distributing remainder width to stretched columns (width allocation on a 100-wide table with 3 columns: Without this flag: 33,33,34. With this flag: 33,33,33). With larger number of columns, resizing will appear to be less smooth."); - ImGui::CheckboxFlags("ImGuiTableFlags_NoClip", &flags, ImGuiTableFlags_NoClip); - ImGui::SameLine(); HelpMarker("Disable clipping rectangle for every individual columns (reduce draw command count, items will be able to overflow into other columns). Generally incompatible with ScrollFreeze options."); - ImGui::TreePop(); - } - - if (ImGui::TreeNodeEx("Padding:", ImGuiTreeNodeFlags_DefaultOpen)) - { - ImGui::CheckboxFlags("ImGuiTableFlags_PadOuterX", &flags, ImGuiTableFlags_PadOuterX); - ImGui::CheckboxFlags("ImGuiTableFlags_NoPadOuterX", &flags, ImGuiTableFlags_NoPadOuterX); - ImGui::CheckboxFlags("ImGuiTableFlags_NoPadInnerX", &flags, ImGuiTableFlags_NoPadInnerX); - ImGui::TreePop(); - } - - if (ImGui::TreeNodeEx("Scrolling:", ImGuiTreeNodeFlags_DefaultOpen)) - { - ImGui::CheckboxFlags("ImGuiTableFlags_ScrollX", &flags, ImGuiTableFlags_ScrollX); - ImGui::SameLine(); - ImGui::SetNextItemWidth(ImGui::GetFrameHeight()); - ImGui::DragInt("freeze_cols", &freeze_cols, 0.2f, 0, 9, NULL, ImGuiSliderFlags_NoInput); - ImGui::CheckboxFlags("ImGuiTableFlags_ScrollY", &flags, ImGuiTableFlags_ScrollY); - ImGui::SameLine(); - ImGui::SetNextItemWidth(ImGui::GetFrameHeight()); - ImGui::DragInt("freeze_rows", &freeze_rows, 0.2f, 0, 9, NULL, ImGuiSliderFlags_NoInput); - ImGui::TreePop(); - } - - if (ImGui::TreeNodeEx("Sorting:", ImGuiTreeNodeFlags_DefaultOpen)) - { - ImGui::CheckboxFlags("ImGuiTableFlags_SortMulti", &flags, ImGuiTableFlags_SortMulti); - ImGui::SameLine(); HelpMarker("When sorting is enabled: hold shift when clicking headers to sort on multiple column. TableGetSortSpecs() may return specs where (SpecsCount > 1)."); - ImGui::CheckboxFlags("ImGuiTableFlags_SortTristate", &flags, ImGuiTableFlags_SortTristate); - ImGui::SameLine(); HelpMarker("When sorting is enabled: allow no sorting, disable default sorting. TableGetSortSpecs() may return specs where (SpecsCount == 0)."); - ImGui::TreePop(); - } - - if (ImGui::TreeNodeEx("Other:", ImGuiTreeNodeFlags_DefaultOpen)) - { - ImGui::Checkbox("show_headers", &show_headers); - ImGui::Checkbox("show_wrapped_text", &show_wrapped_text); - - ImGui::DragFloat2("##OuterSize", &outer_size_value.x); - ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x); - ImGui::Checkbox("outer_size", &outer_size_enabled); - ImGui::SameLine(); - HelpMarker("If scrolling is disabled (ScrollX and ScrollY not set):\n" - "- The table is output directly in the parent window.\n" - "- OuterSize.x < 0.0f will right-align the table.\n" - "- OuterSize.x = 0.0f will narrow fit the table unless there are any Stretch column.\n" - "- OuterSize.y then becomes the minimum size for the table, which will extend vertically if there are more rows (unless NoHostExtendY is set)."); - - // From a user point of view we will tend to use 'inner_width' differently depending on whether our table is embedding scrolling. - // To facilitate toying with this demo we will actually pass 0.0f to the BeginTable() when ScrollX is disabled. - ImGui::DragFloat("inner_width (when ScrollX active)", &inner_width_with_scroll, 1.0f, 0.0f, FLT_MAX); - - ImGui::DragFloat("row_min_height", &row_min_height, 1.0f, 0.0f, FLT_MAX); - ImGui::SameLine(); HelpMarker("Specify height of the Selectable item."); - - ImGui::DragInt("items_count", &items_count, 0.1f, 0, 9999); - ImGui::Combo("items_type (first column)", &contents_type, contents_type_names, IM_ARRAYSIZE(contents_type_names)); - //filter.Draw("filter"); - ImGui::TreePop(); - } - - ImGui::PopItemWidth(); - PopStyleCompact(); - ImGui::Spacing(); - ImGui::TreePop(); - } - - // Update item list if we changed the number of items - static ImVector items; - static ImVector selection; - static bool items_need_sort = false; - if (items.Size != items_count) - { - items.resize(items_count, MyItem()); - for (int n = 0; n < items_count; n++) - { - const int template_n = n % IM_ARRAYSIZE(template_items_names); - MyItem& item = items[n]; - item.ID = n; - item.Name = template_items_names[template_n]; - item.Quantity = (template_n == 3) ? 10 : (template_n == 4) ? 20 : 0; // Assign default quantities - } - } - - const ImDrawList* parent_draw_list = ImGui::GetWindowDrawList(); - const int parent_draw_list_draw_cmd_count = parent_draw_list->CmdBuffer.Size; - ImVec2 table_scroll_cur, table_scroll_max; // For debug display - const ImDrawList* table_draw_list = NULL; // " - - // Submit table - const float inner_width_to_use = (flags & ImGuiTableFlags_ScrollX) ? inner_width_with_scroll : 0.0f; - if (ImGui::BeginTable("table_advanced", 6, flags, outer_size_enabled ? outer_size_value : ImVec2(0, 0), inner_width_to_use)) - { - // Declare columns - // We use the "user_id" parameter of TableSetupColumn() to specify a user id that will be stored in the sort specifications. - // This is so our sort function can identify a column given our own identifier. We could also identify them based on their index! - ImGui::TableSetupColumn("ID", ImGuiTableColumnFlags_DefaultSort | ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_NoHide, 0.0f, MyItemColumnID_ID); - ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthFixed, 0.0f, MyItemColumnID_Name); - ImGui::TableSetupColumn("Action", ImGuiTableColumnFlags_NoSort | ImGuiTableColumnFlags_WidthFixed, 0.0f, MyItemColumnID_Action); - ImGui::TableSetupColumn("Quantity", ImGuiTableColumnFlags_PreferSortDescending, 0.0f, MyItemColumnID_Quantity); - ImGui::TableSetupColumn("Description", (flags & ImGuiTableFlags_NoHostExtendX) ? 0 : ImGuiTableColumnFlags_WidthStretch, 0.0f, MyItemColumnID_Description); - ImGui::TableSetupColumn("Hidden", ImGuiTableColumnFlags_DefaultHide | ImGuiTableColumnFlags_NoSort); - ImGui::TableSetupScrollFreeze(freeze_cols, freeze_rows); - - // Sort our data if sort specs have been changed! - ImGuiTableSortSpecs* sorts_specs = ImGui::TableGetSortSpecs(); - if (sorts_specs && sorts_specs->SpecsDirty) - items_need_sort = true; - if (sorts_specs && items_need_sort && items.Size > 1) - { - MyItem::s_current_sort_specs = sorts_specs; // Store in variable accessible by the sort function. - qsort(&items[0], (size_t)items.Size, sizeof(items[0]), MyItem::CompareWithSortSpecs); - MyItem::s_current_sort_specs = NULL; - sorts_specs->SpecsDirty = false; - } - items_need_sort = false; - - // Take note of whether we are currently sorting based on the Quantity field, - // we will use this to trigger sorting when we know the data of this column has been modified. - const bool sorts_specs_using_quantity = (ImGui::TableGetColumnFlags(3) & ImGuiTableColumnFlags_IsSorted) != 0; - - // Show headers - if (show_headers) - ImGui::TableHeadersRow(); - - // Show data - // FIXME-TABLE FIXME-NAV: How we can get decent up/down even though we have the buttons here? - ImGui::PushButtonRepeat(true); -#if 1 - // Demonstrate using clipper for large vertical lists - ImGuiListClipper clipper; - clipper.Begin(items.Size); - while (clipper.Step()) - { - for (int row_n = clipper.DisplayStart; row_n < clipper.DisplayEnd; row_n++) -#else - // Without clipper - { - for (int row_n = 0; row_n < items.Size; row_n++) -#endif - { - MyItem* item = &items[row_n]; - //if (!filter.PassFilter(item->Name)) - // continue; - - const bool item_is_selected = selection.contains(item->ID); - ImGui::PushID(item->ID); - ImGui::TableNextRow(ImGuiTableRowFlags_None, row_min_height); - - // For the demo purpose we can select among different type of items submitted in the first column - ImGui::TableSetColumnIndex(0); - char label[32]; - sprintf(label, "%04d", item->ID); - if (contents_type == CT_Text) - ImGui::TextUnformatted(label); - else if (contents_type == CT_Button) - ImGui::Button(label); - else if (contents_type == CT_SmallButton) - ImGui::SmallButton(label); - else if (contents_type == CT_FillButton) - ImGui::Button(label, ImVec2(-FLT_MIN, 0.0f)); - else if (contents_type == CT_Selectable || contents_type == CT_SelectableSpanRow) - { - ImGuiSelectableFlags selectable_flags = (contents_type == CT_SelectableSpanRow) ? ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowItemOverlap : ImGuiSelectableFlags_None; - if (ImGui::Selectable(label, item_is_selected, selectable_flags, ImVec2(0, row_min_height))) - { - if (ImGui::GetIO().KeyCtrl) - { - if (item_is_selected) - selection.find_erase_unsorted(item->ID); - else - selection.push_back(item->ID); - } - else - { - selection.clear(); - selection.push_back(item->ID); - } - } - } - - if (ImGui::TableSetColumnIndex(1)) - ImGui::TextUnformatted(item->Name); - - // Here we demonstrate marking our data set as needing to be sorted again if we modified a quantity, - // and we are currently sorting on the column showing the Quantity. - // To avoid triggering a sort while holding the button, we only trigger it when the button has been released. - // You will probably need a more advanced system in your code if you want to automatically sort when a specific entry changes. - if (ImGui::TableSetColumnIndex(2)) - { - if (ImGui::SmallButton("Chop")) { item->Quantity += 1; } - if (sorts_specs_using_quantity && ImGui::IsItemDeactivated()) { items_need_sort = true; } - ImGui::SameLine(); - if (ImGui::SmallButton("Eat")) { item->Quantity -= 1; } - if (sorts_specs_using_quantity && ImGui::IsItemDeactivated()) { items_need_sort = true; } - } - - if (ImGui::TableSetColumnIndex(3)) - ImGui::Text("%d", item->Quantity); - - ImGui::TableSetColumnIndex(4); - if (show_wrapped_text) - ImGui::TextWrapped("Lorem ipsum dolor sit amet"); - else - ImGui::Text("Lorem ipsum dolor sit amet"); - - if (ImGui::TableSetColumnIndex(5)) - ImGui::Text("1234"); - - ImGui::PopID(); - } - } - ImGui::PopButtonRepeat(); - - // Store some info to display debug details below - table_scroll_cur = ImVec2(ImGui::GetScrollX(), ImGui::GetScrollY()); - table_scroll_max = ImVec2(ImGui::GetScrollMaxX(), ImGui::GetScrollMaxY()); - table_draw_list = ImGui::GetWindowDrawList(); - ImGui::EndTable(); - } - static bool show_debug_details = false; - ImGui::Checkbox("Debug details", &show_debug_details); - if (show_debug_details && table_draw_list) - { - ImGui::SameLine(0.0f, 0.0f); - const int table_draw_list_draw_cmd_count = table_draw_list->CmdBuffer.Size; - if (table_draw_list == parent_draw_list) - ImGui::Text(": DrawCmd: +%d (in same window)", - table_draw_list_draw_cmd_count - parent_draw_list_draw_cmd_count); - else - ImGui::Text(": DrawCmd: +%d (in child window), Scroll: (%.f/%.f) (%.f/%.f)", - table_draw_list_draw_cmd_count - 1, table_scroll_cur.x, table_scroll_max.x, table_scroll_cur.y, table_scroll_max.y); - } - ImGui::TreePop(); - } - - ImGui::PopID(); - - ShowDemoWindowColumns(); - - if (disable_indent) - ImGui::PopStyleVar(); -} - -// Demonstrate old/legacy Columns API! -// [2020: Columns are under-featured and not maintained. Prefer using the more flexible and powerful BeginTable() API!] -static void ShowDemoWindowColumns() -{ - bool open = ImGui::TreeNode("Legacy Columns API"); - ImGui::SameLine(); - HelpMarker("Columns() is an old API! Prefer using the more flexible and powerful BeginTable() API!"); - if (!open) - return; - - // Basic columns - if (ImGui::TreeNode("Basic")) - { - ImGui::Text("Without border:"); - ImGui::Columns(3, "mycolumns3", false); // 3-ways, no border - ImGui::Separator(); - for (int n = 0; n < 14; n++) - { - char label[32]; - sprintf(label, "Item %d", n); - if (ImGui::Selectable(label)) {} - //if (ImGui::Button(label, ImVec2(-FLT_MIN,0.0f))) {} - ImGui::NextColumn(); - } - ImGui::Columns(1); - ImGui::Separator(); - - ImGui::Text("With border:"); - ImGui::Columns(4, "mycolumns"); // 4-ways, with border - ImGui::Separator(); - ImGui::Text("ID"); ImGui::NextColumn(); - ImGui::Text("Name"); ImGui::NextColumn(); - ImGui::Text("Path"); ImGui::NextColumn(); - ImGui::Text("Hovered"); ImGui::NextColumn(); - ImGui::Separator(); - const char* names[3] = { "One", "Two", "Three" }; - const char* paths[3] = { "/path/one", "/path/two", "/path/three" }; - static int selected = -1; - for (int i = 0; i < 3; i++) - { - char label[32]; - sprintf(label, "%04d", i); - if (ImGui::Selectable(label, selected == i, ImGuiSelectableFlags_SpanAllColumns)) - selected = i; - bool hovered = ImGui::IsItemHovered(); - ImGui::NextColumn(); - ImGui::Text(names[i]); ImGui::NextColumn(); - ImGui::Text(paths[i]); ImGui::NextColumn(); - ImGui::Text("%d", hovered); ImGui::NextColumn(); - } - ImGui::Columns(1); - ImGui::Separator(); - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Borders")) - { - // NB: Future columns API should allow automatic horizontal borders. - static bool h_borders = true; - static bool v_borders = true; - static int columns_count = 4; - const int lines_count = 3; - ImGui::SetNextItemWidth(ImGui::GetFontSize() * 8); - ImGui::DragInt("##columns_count", &columns_count, 0.1f, 2, 10, "%d columns"); - if (columns_count < 2) - columns_count = 2; - ImGui::SameLine(); - ImGui::Checkbox("horizontal", &h_borders); - ImGui::SameLine(); - ImGui::Checkbox("vertical", &v_borders); - ImGui::Columns(columns_count, NULL, v_borders); - for (int i = 0; i < columns_count * lines_count; i++) - { - if (h_borders && ImGui::GetColumnIndex() == 0) - ImGui::Separator(); - ImGui::Text("%c%c%c", 'a' + i, 'a' + i, 'a' + i); - ImGui::Text("Width %.2f", ImGui::GetColumnWidth()); - ImGui::Text("Avail %.2f", ImGui::GetContentRegionAvail().x); - ImGui::Text("Offset %.2f", ImGui::GetColumnOffset()); - ImGui::Text("Long text that is likely to clip"); - ImGui::Button("Button", ImVec2(-FLT_MIN, 0.0f)); - ImGui::NextColumn(); - } - ImGui::Columns(1); - if (h_borders) - ImGui::Separator(); - ImGui::TreePop(); - } - - // Create multiple items in a same cell before switching to next column - if (ImGui::TreeNode("Mixed items")) - { - ImGui::Columns(3, "mixed"); - ImGui::Separator(); - - ImGui::Text("Hello"); - ImGui::Button("Banana"); - ImGui::NextColumn(); - - ImGui::Text("ImGui"); - ImGui::Button("Apple"); - static float foo = 1.0f; - ImGui::InputFloat("red", &foo, 0.05f, 0, "%.3f"); - ImGui::Text("An extra line here."); - ImGui::NextColumn(); - - ImGui::Text("Sailor"); - ImGui::Button("Corniflower"); - static float bar = 1.0f; - ImGui::InputFloat("blue", &bar, 0.05f, 0, "%.3f"); - ImGui::NextColumn(); - - if (ImGui::CollapsingHeader("Category A")) { ImGui::Text("Blah blah blah"); } ImGui::NextColumn(); - if (ImGui::CollapsingHeader("Category B")) { ImGui::Text("Blah blah blah"); } ImGui::NextColumn(); - if (ImGui::CollapsingHeader("Category C")) { ImGui::Text("Blah blah blah"); } ImGui::NextColumn(); - ImGui::Columns(1); - ImGui::Separator(); - ImGui::TreePop(); - } - - // Word wrapping - if (ImGui::TreeNode("Word-wrapping")) - { - ImGui::Columns(2, "word-wrapping"); - ImGui::Separator(); - ImGui::TextWrapped("The quick brown fox jumps over the lazy dog."); - ImGui::TextWrapped("Hello Left"); - ImGui::NextColumn(); - ImGui::TextWrapped("The quick brown fox jumps over the lazy dog."); - ImGui::TextWrapped("Hello Right"); - ImGui::Columns(1); - ImGui::Separator(); - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Horizontal Scrolling")) - { - ImGui::SetNextWindowContentSize(ImVec2(1500.0f, 0.0f)); - ImVec2 child_size = ImVec2(0, ImGui::GetFontSize() * 20.0f); - ImGui::BeginChild("##ScrollingRegion", child_size, false, ImGuiWindowFlags_HorizontalScrollbar); - ImGui::Columns(10); - - // Also demonstrate using clipper for large vertical lists - int ITEMS_COUNT = 2000; - ImGuiListClipper clipper; - clipper.Begin(ITEMS_COUNT); - while (clipper.Step()) - { - for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) - for (int j = 0; j < 10; j++) - { - ImGui::Text("Line %d Column %d...", i, j); - ImGui::NextColumn(); - } - } - ImGui::Columns(1); - ImGui::EndChild(); - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Tree")) - { - ImGui::Columns(2, "tree", true); - for (int x = 0; x < 3; x++) - { - bool open1 = ImGui::TreeNode((void*)(intptr_t)x, "Node%d", x); - ImGui::NextColumn(); - ImGui::Text("Node contents"); - ImGui::NextColumn(); - if (open1) - { - for (int y = 0; y < 3; y++) - { - bool open2 = ImGui::TreeNode((void*)(intptr_t)y, "Node%d.%d", x, y); - ImGui::NextColumn(); - ImGui::Text("Node contents"); - if (open2) - { - ImGui::Text("Even more contents"); - if (ImGui::TreeNode("Tree in column")) - { - ImGui::Text("The quick brown fox jumps over the lazy dog"); - ImGui::TreePop(); - } - } - ImGui::NextColumn(); - if (open2) - ImGui::TreePop(); - } - ImGui::TreePop(); - } - } - ImGui::Columns(1); - ImGui::TreePop(); - } - - ImGui::TreePop(); -} - -static void ShowDemoWindowMisc() -{ - if (ImGui::CollapsingHeader("Filtering")) - { - // Helper class to easy setup a text filter. - // You may want to implement a more feature-full filtering scheme in your own application. - static ImGuiTextFilter filter; - ImGui::Text("Filter usage:\n" - " \"\" display all lines\n" - " \"xxx\" display lines containing \"xxx\"\n" - " \"xxx,yyy\" display lines containing \"xxx\" or \"yyy\"\n" - " \"-xxx\" hide lines containing \"xxx\""); - filter.Draw(); - const char* lines[] = { "aaa1.c", "bbb1.c", "ccc1.c", "aaa2.cpp", "bbb2.cpp", "ccc2.cpp", "abc.h", "hello, world" }; - for (int i = 0; i < IM_ARRAYSIZE(lines); i++) - if (filter.PassFilter(lines[i])) - ImGui::BulletText("%s", lines[i]); - } - - if (ImGui::CollapsingHeader("Inputs, Navigation & Focus")) - { - ImGuiIO& io = ImGui::GetIO(); - - // Display ImGuiIO output flags - ImGui::Text("WantCaptureMouse: %d", io.WantCaptureMouse); - ImGui::Text("WantCaptureMouseUnlessPopupClose: %d", io.WantCaptureMouseUnlessPopupClose); - ImGui::Text("WantCaptureKeyboard: %d", io.WantCaptureKeyboard); - ImGui::Text("WantTextInput: %d", io.WantTextInput); - ImGui::Text("WantSetMousePos: %d", io.WantSetMousePos); - ImGui::Text("NavActive: %d, NavVisible: %d", io.NavActive, io.NavVisible); - - // Display Mouse state - if (ImGui::TreeNode("Mouse State")) - { - if (ImGui::IsMousePosValid()) - ImGui::Text("Mouse pos: (%g, %g)", io.MousePos.x, io.MousePos.y); - else - ImGui::Text("Mouse pos: "); - ImGui::Text("Mouse delta: (%g, %g)", io.MouseDelta.x, io.MouseDelta.y); - ImGui::Text("Mouse down:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseDown(i)) { ImGui::SameLine(); ImGui::Text("b%d (%.02f secs)", i, io.MouseDownDuration[i]); } - ImGui::Text("Mouse clicked:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseClicked(i)) { ImGui::SameLine(); ImGui::Text("b%d", i); } - ImGui::Text("Mouse dblclick:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseDoubleClicked(i)){ ImGui::SameLine(); ImGui::Text("b%d", i); } - ImGui::Text("Mouse released:"); for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++) if (ImGui::IsMouseReleased(i)) { ImGui::SameLine(); ImGui::Text("b%d", i); } - ImGui::Text("Mouse wheel: %.1f", io.MouseWheel); - ImGui::Text("Pen Pressure: %.1f", io.PenPressure); // Note: currently unused - ImGui::TreePop(); - } - - // Display Keyboard/Mouse state - if (ImGui::TreeNode("Keyboard & Navigation State")) - { - ImGui::Text("Keys down:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (ImGui::IsKeyDown(i)) { ImGui::SameLine(); ImGui::Text("%d (0x%X) (%.02f secs)", i, i, io.KeysDownDuration[i]); } - ImGui::Text("Keys pressed:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (ImGui::IsKeyPressed(i)) { ImGui::SameLine(); ImGui::Text("%d (0x%X)", i, i); } - ImGui::Text("Keys release:"); for (int i = 0; i < IM_ARRAYSIZE(io.KeysDown); i++) if (ImGui::IsKeyReleased(i)) { ImGui::SameLine(); ImGui::Text("%d (0x%X)", i, i); } - ImGui::Text("Keys mods: %s%s%s%s", io.KeyCtrl ? "CTRL " : "", io.KeyShift ? "SHIFT " : "", io.KeyAlt ? "ALT " : "", io.KeySuper ? "SUPER " : ""); - ImGui::Text("Chars queue:"); for (int i = 0; i < io.InputQueueCharacters.Size; i++) { ImWchar c = io.InputQueueCharacters[i]; ImGui::SameLine(); ImGui::Text("\'%c\' (0x%04X)", (c > ' ' && c <= 255) ? (char)c : '?', c); } // FIXME: We should convert 'c' to UTF-8 here but the functions are not public. - - ImGui::Text("NavInputs down:"); for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++) if (io.NavInputs[i] > 0.0f) { ImGui::SameLine(); ImGui::Text("[%d] %.2f (%.02f secs)", i, io.NavInputs[i], io.NavInputsDownDuration[i]); } - ImGui::Text("NavInputs pressed:"); for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++) if (io.NavInputsDownDuration[i] == 0.0f) { ImGui::SameLine(); ImGui::Text("[%d]", i); } - - ImGui::Button("Hovering me sets the\nkeyboard capture flag"); - if (ImGui::IsItemHovered()) - ImGui::CaptureKeyboardFromApp(true); - ImGui::SameLine(); - ImGui::Button("Holding me clears the\nthe keyboard capture flag"); - if (ImGui::IsItemActive()) - ImGui::CaptureKeyboardFromApp(false); - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Tabbing")) - { - ImGui::Text("Use TAB/SHIFT+TAB to cycle through keyboard editable fields."); - static char buf[32] = "hello"; - ImGui::InputText("1", buf, IM_ARRAYSIZE(buf)); - ImGui::InputText("2", buf, IM_ARRAYSIZE(buf)); - ImGui::InputText("3", buf, IM_ARRAYSIZE(buf)); - ImGui::PushAllowKeyboardFocus(false); - ImGui::InputText("4 (tab skip)", buf, IM_ARRAYSIZE(buf)); - ImGui::SameLine(); HelpMarker("Item won't be cycled through when using TAB or Shift+Tab."); - ImGui::PopAllowKeyboardFocus(); - ImGui::InputText("5", buf, IM_ARRAYSIZE(buf)); - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Focus from code")) - { - bool focus_1 = ImGui::Button("Focus on 1"); ImGui::SameLine(); - bool focus_2 = ImGui::Button("Focus on 2"); ImGui::SameLine(); - bool focus_3 = ImGui::Button("Focus on 3"); - int has_focus = 0; - static char buf[128] = "click on a button to set focus"; - - if (focus_1) ImGui::SetKeyboardFocusHere(); - ImGui::InputText("1", buf, IM_ARRAYSIZE(buf)); - if (ImGui::IsItemActive()) has_focus = 1; - - if (focus_2) ImGui::SetKeyboardFocusHere(); - ImGui::InputText("2", buf, IM_ARRAYSIZE(buf)); - if (ImGui::IsItemActive()) has_focus = 2; - - ImGui::PushAllowKeyboardFocus(false); - if (focus_3) ImGui::SetKeyboardFocusHere(); - ImGui::InputText("3 (tab skip)", buf, IM_ARRAYSIZE(buf)); - if (ImGui::IsItemActive()) has_focus = 3; - ImGui::SameLine(); HelpMarker("Item won't be cycled through when using TAB or Shift+Tab."); - ImGui::PopAllowKeyboardFocus(); - - if (has_focus) - ImGui::Text("Item with focus: %d", has_focus); - else - ImGui::Text("Item with focus: "); - - // Use >= 0 parameter to SetKeyboardFocusHere() to focus an upcoming item - static float f3[3] = { 0.0f, 0.0f, 0.0f }; - int focus_ahead = -1; - if (ImGui::Button("Focus on X")) { focus_ahead = 0; } ImGui::SameLine(); - if (ImGui::Button("Focus on Y")) { focus_ahead = 1; } ImGui::SameLine(); - if (ImGui::Button("Focus on Z")) { focus_ahead = 2; } - if (focus_ahead != -1) ImGui::SetKeyboardFocusHere(focus_ahead); - ImGui::SliderFloat3("Float3", &f3[0], 0.0f, 1.0f); - - ImGui::TextWrapped("NB: Cursor & selection are preserved when refocusing last used item in code."); - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Dragging")) - { - ImGui::TextWrapped("You can use ImGui::GetMouseDragDelta(0) to query for the dragged amount on any widget."); - for (int button = 0; button < 3; button++) - { - ImGui::Text("IsMouseDragging(%d):", button); - ImGui::Text(" w/ default threshold: %d,", ImGui::IsMouseDragging(button)); - ImGui::Text(" w/ zero threshold: %d,", ImGui::IsMouseDragging(button, 0.0f)); - ImGui::Text(" w/ large threshold: %d,", ImGui::IsMouseDragging(button, 20.0f)); - } - - ImGui::Button("Drag Me"); - if (ImGui::IsItemActive()) - ImGui::GetForegroundDrawList()->AddLine(io.MouseClickedPos[0], io.MousePos, ImGui::GetColorU32(ImGuiCol_Button), 4.0f); // Draw a line between the button and the mouse cursor - - // Drag operations gets "unlocked" when the mouse has moved past a certain threshold - // (the default threshold is stored in io.MouseDragThreshold). You can request a lower or higher - // threshold using the second parameter of IsMouseDragging() and GetMouseDragDelta(). - ImVec2 value_raw = ImGui::GetMouseDragDelta(0, 0.0f); - ImVec2 value_with_lock_threshold = ImGui::GetMouseDragDelta(0); - ImVec2 mouse_delta = io.MouseDelta; - ImGui::Text("GetMouseDragDelta(0):"); - ImGui::Text(" w/ default threshold: (%.1f, %.1f)", value_with_lock_threshold.x, value_with_lock_threshold.y); - ImGui::Text(" w/ zero threshold: (%.1f, %.1f)", value_raw.x, value_raw.y); - ImGui::Text("io.MouseDelta: (%.1f, %.1f)", mouse_delta.x, mouse_delta.y); - ImGui::TreePop(); - } - - if (ImGui::TreeNode("Mouse cursors")) - { - const char* mouse_cursors_names[] = { "Arrow", "TextInput", "ResizeAll", "ResizeNS", "ResizeEW", "ResizeNESW", "ResizeNWSE", "Hand", "NotAllowed" }; - IM_ASSERT(IM_ARRAYSIZE(mouse_cursors_names) == ImGuiMouseCursor_COUNT); - - ImGuiMouseCursor current = ImGui::GetMouseCursor(); - ImGui::Text("Current mouse cursor = %d: %s", current, mouse_cursors_names[current]); - ImGui::Text("Hover to see mouse cursors:"); - ImGui::SameLine(); HelpMarker( - "Your application can render a different mouse cursor based on what ImGui::GetMouseCursor() returns. " - "If software cursor rendering (io.MouseDrawCursor) is set ImGui will draw the right cursor for you, " - "otherwise your backend needs to handle it."); - for (int i = 0; i < ImGuiMouseCursor_COUNT; i++) - { - char label[32]; - sprintf(label, "Mouse cursor %d: %s", i, mouse_cursors_names[i]); - ImGui::Bullet(); ImGui::Selectable(label, false); - if (ImGui::IsItemHovered()) - ImGui::SetMouseCursor(i); - } - ImGui::TreePop(); - } - } -} - -//----------------------------------------------------------------------------- -// [SECTION] About Window / ShowAboutWindow() -// Access from Dear ImGui Demo -> Tools -> About -//----------------------------------------------------------------------------- - -void ImGui::ShowAboutWindow(bool* p_open) -{ - if (!ImGui::Begin("About Dear ImGui", p_open, ImGuiWindowFlags_AlwaysAutoResize)) - { - ImGui::End(); - return; - } - ImGui::Text("Dear ImGui %s", ImGui::GetVersion()); - ImGui::Separator(); - ImGui::Text("By Omar Cornut and all Dear ImGui contributors."); - ImGui::Text("Dear ImGui is licensed under the MIT License, see LICENSE for more information."); - - static bool show_config_info = false; - ImGui::Checkbox("Config/Build Information", &show_config_info); - if (show_config_info) - { - ImGuiIO& io = ImGui::GetIO(); - ImGuiStyle& style = ImGui::GetStyle(); - - bool copy_to_clipboard = ImGui::Button("Copy to clipboard"); - ImVec2 child_size = ImVec2(0, ImGui::GetTextLineHeightWithSpacing() * 18); - ImGui::BeginChildFrame(ImGui::GetID("cfg_infos"), child_size, ImGuiWindowFlags_NoMove); - if (copy_to_clipboard) - { - ImGui::LogToClipboard(); - ImGui::LogText("```\n"); // Back quotes will make text appears without formatting when pasting on GitHub - } - - ImGui::Text("Dear ImGui %s (%d)", IMGUI_VERSION, IMGUI_VERSION_NUM); - ImGui::Separator(); - ImGui::Text("sizeof(size_t): %d, sizeof(ImDrawIdx): %d, sizeof(ImDrawVert): %d", (int)sizeof(size_t), (int)sizeof(ImDrawIdx), (int)sizeof(ImDrawVert)); - ImGui::Text("define: __cplusplus=%d", (int)__cplusplus); -#ifdef IMGUI_DISABLE_OBSOLETE_FUNCTIONS - ImGui::Text("define: IMGUI_DISABLE_OBSOLETE_FUNCTIONS"); -#endif -#ifdef IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS - ImGui::Text("define: IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS"); -#endif -#ifdef IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS - ImGui::Text("define: IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS"); -#endif -#ifdef IMGUI_DISABLE_WIN32_FUNCTIONS - ImGui::Text("define: IMGUI_DISABLE_WIN32_FUNCTIONS"); -#endif -#ifdef IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS - ImGui::Text("define: IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS"); -#endif -#ifdef IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS - ImGui::Text("define: IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS"); -#endif -#ifdef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS - ImGui::Text("define: IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS"); -#endif -#ifdef IMGUI_DISABLE_FILE_FUNCTIONS - ImGui::Text("define: IMGUI_DISABLE_FILE_FUNCTIONS"); -#endif -#ifdef IMGUI_DISABLE_DEFAULT_ALLOCATORS - ImGui::Text("define: IMGUI_DISABLE_DEFAULT_ALLOCATORS"); -#endif -#ifdef IMGUI_USE_BGRA_PACKED_COLOR - ImGui::Text("define: IMGUI_USE_BGRA_PACKED_COLOR"); -#endif -#ifdef _WIN32 - ImGui::Text("define: _WIN32"); -#endif -#ifdef _WIN64 - ImGui::Text("define: _WIN64"); -#endif -#ifdef __linux__ - ImGui::Text("define: __linux__"); -#endif -#ifdef __APPLE__ - ImGui::Text("define: __APPLE__"); -#endif -#ifdef _MSC_VER - ImGui::Text("define: _MSC_VER=%d", _MSC_VER); -#endif -#ifdef _MSVC_LANG - ImGui::Text("define: _MSVC_LANG=%d", (int)_MSVC_LANG); -#endif -#ifdef __MINGW32__ - ImGui::Text("define: __MINGW32__"); -#endif -#ifdef __MINGW64__ - ImGui::Text("define: __MINGW64__"); -#endif -#ifdef __GNUC__ - ImGui::Text("define: __GNUC__=%d", (int)__GNUC__); -#endif -#ifdef __clang_version__ - ImGui::Text("define: __clang_version__=%s", __clang_version__); -#endif - ImGui::Separator(); - ImGui::Text("io.BackendPlatformName: %s", io.BackendPlatformName ? io.BackendPlatformName : "NULL"); - ImGui::Text("io.BackendRendererName: %s", io.BackendRendererName ? io.BackendRendererName : "NULL"); - ImGui::Text("io.ConfigFlags: 0x%08X", io.ConfigFlags); - if (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) ImGui::Text(" NavEnableKeyboard"); - if (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) ImGui::Text(" NavEnableGamepad"); - if (io.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) ImGui::Text(" NavEnableSetMousePos"); - if (io.ConfigFlags & ImGuiConfigFlags_NavNoCaptureKeyboard) ImGui::Text(" NavNoCaptureKeyboard"); - if (io.ConfigFlags & ImGuiConfigFlags_NoMouse) ImGui::Text(" NoMouse"); - if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) ImGui::Text(" NoMouseCursorChange"); - if (io.MouseDrawCursor) ImGui::Text("io.MouseDrawCursor"); - if (io.ConfigMacOSXBehaviors) ImGui::Text("io.ConfigMacOSXBehaviors"); - if (io.ConfigInputTextCursorBlink) ImGui::Text("io.ConfigInputTextCursorBlink"); - if (io.ConfigWindowsResizeFromEdges) ImGui::Text("io.ConfigWindowsResizeFromEdges"); - if (io.ConfigWindowsMoveFromTitleBarOnly) ImGui::Text("io.ConfigWindowsMoveFromTitleBarOnly"); - if (io.ConfigMemoryCompactTimer >= 0.0f) ImGui::Text("io.ConfigMemoryCompactTimer = %.1f", io.ConfigMemoryCompactTimer); - ImGui::Text("io.BackendFlags: 0x%08X", io.BackendFlags); - if (io.BackendFlags & ImGuiBackendFlags_HasGamepad) ImGui::Text(" HasGamepad"); - if (io.BackendFlags & ImGuiBackendFlags_HasMouseCursors) ImGui::Text(" HasMouseCursors"); - if (io.BackendFlags & ImGuiBackendFlags_HasSetMousePos) ImGui::Text(" HasSetMousePos"); - if (io.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset) ImGui::Text(" RendererHasVtxOffset"); - ImGui::Separator(); - ImGui::Text("io.Fonts: %d fonts, Flags: 0x%08X, TexSize: %d,%d", io.Fonts->Fonts.Size, io.Fonts->Flags, io.Fonts->TexWidth, io.Fonts->TexHeight); - ImGui::Text("io.DisplaySize: %.2f,%.2f", io.DisplaySize.x, io.DisplaySize.y); - ImGui::Text("io.DisplayFramebufferScale: %.2f,%.2f", io.DisplayFramebufferScale.x, io.DisplayFramebufferScale.y); - ImGui::Separator(); - ImGui::Text("style.WindowPadding: %.2f,%.2f", style.WindowPadding.x, style.WindowPadding.y); - ImGui::Text("style.WindowBorderSize: %.2f", style.WindowBorderSize); - ImGui::Text("style.FramePadding: %.2f,%.2f", style.FramePadding.x, style.FramePadding.y); - ImGui::Text("style.FrameRounding: %.2f", style.FrameRounding); - ImGui::Text("style.FrameBorderSize: %.2f", style.FrameBorderSize); - ImGui::Text("style.ItemSpacing: %.2f,%.2f", style.ItemSpacing.x, style.ItemSpacing.y); - ImGui::Text("style.ItemInnerSpacing: %.2f,%.2f", style.ItemInnerSpacing.x, style.ItemInnerSpacing.y); - - if (copy_to_clipboard) - { - ImGui::LogText("\n```\n"); - ImGui::LogFinish(); - } - ImGui::EndChildFrame(); - } - ImGui::End(); -} - -//----------------------------------------------------------------------------- -// [SECTION] Style Editor / ShowStyleEditor() -//----------------------------------------------------------------------------- -// - ShowFontSelector() -// - ShowStyleSelector() -// - ShowStyleEditor() -//----------------------------------------------------------------------------- - -// Forward declare ShowFontAtlas() which isn't worth putting in public API yet -namespace ImGui { IMGUI_API void ShowFontAtlas(ImFontAtlas* atlas); } - -// Demo helper function to select among loaded fonts. -// Here we use the regular BeginCombo()/EndCombo() api which is more the more flexible one. -void ImGui::ShowFontSelector(const char* label) -{ - ImGuiIO& io = ImGui::GetIO(); - ImFont* font_current = ImGui::GetFont(); - if (ImGui::BeginCombo(label, font_current->GetDebugName())) - { - for (int n = 0; n < io.Fonts->Fonts.Size; n++) - { - ImFont* font = io.Fonts->Fonts[n]; - ImGui::PushID((void*)font); - if (ImGui::Selectable(font->GetDebugName(), font == font_current)) - io.FontDefault = font; - ImGui::PopID(); - } - ImGui::EndCombo(); - } - ImGui::SameLine(); - HelpMarker( - "- Load additional fonts with io.Fonts->AddFontFromFileTTF().\n" - "- The font atlas is built when calling io.Fonts->GetTexDataAsXXXX() or io.Fonts->Build().\n" - "- Read FAQ and docs/FONTS.md for more details.\n" - "- If you need to add/remove fonts at runtime (e.g. for DPI change), do it before calling NewFrame()."); -} - -// Demo helper function to select among default colors. See ShowStyleEditor() for more advanced options. -// Here we use the simplified Combo() api that packs items into a single literal string. -// Useful for quick combo boxes where the choices are known locally. -bool ImGui::ShowStyleSelector(const char* label) -{ - static int style_idx = -1; - if (ImGui::Combo(label, &style_idx, "Dark\0Light\0Classic\0")) - { - switch (style_idx) - { - case 0: ImGui::StyleColorsDark(); break; - case 1: ImGui::StyleColorsLight(); break; - case 2: ImGui::StyleColorsClassic(); break; - } - return true; - } - return false; -} - -void ImGui::ShowStyleEditor(ImGuiStyle* ref) -{ - // You can pass in a reference ImGuiStyle structure to compare to, revert to and save to - // (without a reference style pointer, we will use one compared locally as a reference) - ImGuiStyle& style = ImGui::GetStyle(); - static ImGuiStyle ref_saved_style; - - // Default to using internal storage as reference - static bool init = true; - if (init && ref == NULL) - ref_saved_style = style; - init = false; - if (ref == NULL) - ref = &ref_saved_style; - - ImGui::PushItemWidth(ImGui::GetWindowWidth() * 0.50f); - - if (ImGui::ShowStyleSelector("Colors##Selector")) - ref_saved_style = style; - ImGui::ShowFontSelector("Fonts##Selector"); - - // Simplified Settings (expose floating-pointer border sizes as boolean representing 0.0f or 1.0f) - if (ImGui::SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f")) - style.GrabRounding = style.FrameRounding; // Make GrabRounding always the same value as FrameRounding - { bool border = (style.WindowBorderSize > 0.0f); if (ImGui::Checkbox("WindowBorder", &border)) { style.WindowBorderSize = border ? 1.0f : 0.0f; } } - ImGui::SameLine(); - { bool border = (style.FrameBorderSize > 0.0f); if (ImGui::Checkbox("FrameBorder", &border)) { style.FrameBorderSize = border ? 1.0f : 0.0f; } } - ImGui::SameLine(); - { bool border = (style.PopupBorderSize > 0.0f); if (ImGui::Checkbox("PopupBorder", &border)) { style.PopupBorderSize = border ? 1.0f : 0.0f; } } - - // Save/Revert button - if (ImGui::Button("Save Ref")) - *ref = ref_saved_style = style; - ImGui::SameLine(); - if (ImGui::Button("Revert Ref")) - style = *ref; - ImGui::SameLine(); - HelpMarker( - "Save/Revert in local non-persistent storage. Default Colors definition are not affected. " - "Use \"Export\" below to save them somewhere."); - - ImGui::Separator(); - - if (ImGui::BeginTabBar("##tabs", ImGuiTabBarFlags_None)) - { - if (ImGui::BeginTabItem("Sizes")) - { - ImGui::Text("Main"); - ImGui::SliderFloat2("WindowPadding", (float*)&style.WindowPadding, 0.0f, 20.0f, "%.0f"); - ImGui::SliderFloat2("FramePadding", (float*)&style.FramePadding, 0.0f, 20.0f, "%.0f"); - ImGui::SliderFloat2("CellPadding", (float*)&style.CellPadding, 0.0f, 20.0f, "%.0f"); - ImGui::SliderFloat2("ItemSpacing", (float*)&style.ItemSpacing, 0.0f, 20.0f, "%.0f"); - ImGui::SliderFloat2("ItemInnerSpacing", (float*)&style.ItemInnerSpacing, 0.0f, 20.0f, "%.0f"); - ImGui::SliderFloat2("TouchExtraPadding", (float*)&style.TouchExtraPadding, 0.0f, 10.0f, "%.0f"); - ImGui::SliderFloat("IndentSpacing", &style.IndentSpacing, 0.0f, 30.0f, "%.0f"); - ImGui::SliderFloat("ScrollbarSize", &style.ScrollbarSize, 1.0f, 20.0f, "%.0f"); - ImGui::SliderFloat("GrabMinSize", &style.GrabMinSize, 1.0f, 20.0f, "%.0f"); - ImGui::Text("Borders"); - ImGui::SliderFloat("WindowBorderSize", &style.WindowBorderSize, 0.0f, 1.0f, "%.0f"); - ImGui::SliderFloat("ChildBorderSize", &style.ChildBorderSize, 0.0f, 1.0f, "%.0f"); - ImGui::SliderFloat("PopupBorderSize", &style.PopupBorderSize, 0.0f, 1.0f, "%.0f"); - ImGui::SliderFloat("FrameBorderSize", &style.FrameBorderSize, 0.0f, 1.0f, "%.0f"); - ImGui::SliderFloat("TabBorderSize", &style.TabBorderSize, 0.0f, 1.0f, "%.0f"); - ImGui::Text("Rounding"); - ImGui::SliderFloat("WindowRounding", &style.WindowRounding, 0.0f, 12.0f, "%.0f"); - ImGui::SliderFloat("ChildRounding", &style.ChildRounding, 0.0f, 12.0f, "%.0f"); - ImGui::SliderFloat("FrameRounding", &style.FrameRounding, 0.0f, 12.0f, "%.0f"); - ImGui::SliderFloat("PopupRounding", &style.PopupRounding, 0.0f, 12.0f, "%.0f"); - ImGui::SliderFloat("ScrollbarRounding", &style.ScrollbarRounding, 0.0f, 12.0f, "%.0f"); - ImGui::SliderFloat("GrabRounding", &style.GrabRounding, 0.0f, 12.0f, "%.0f"); - ImGui::SliderFloat("LogSliderDeadzone", &style.LogSliderDeadzone, 0.0f, 12.0f, "%.0f"); - ImGui::SliderFloat("TabRounding", &style.TabRounding, 0.0f, 12.0f, "%.0f"); - ImGui::Text("Alignment"); - ImGui::SliderFloat2("WindowTitleAlign", (float*)&style.WindowTitleAlign, 0.0f, 1.0f, "%.2f"); - int window_menu_button_position = style.WindowMenuButtonPosition + 1; - if (ImGui::Combo("WindowMenuButtonPosition", (int*)&window_menu_button_position, "None\0Left\0Right\0")) - style.WindowMenuButtonPosition = window_menu_button_position - 1; - ImGui::Combo("ColorButtonPosition", (int*)&style.ColorButtonPosition, "Left\0Right\0"); - ImGui::SliderFloat2("ButtonTextAlign", (float*)&style.ButtonTextAlign, 0.0f, 1.0f, "%.2f"); - ImGui::SameLine(); HelpMarker("Alignment applies when a button is larger than its text content."); - ImGui::SliderFloat2("SelectableTextAlign", (float*)&style.SelectableTextAlign, 0.0f, 1.0f, "%.2f"); - ImGui::SameLine(); HelpMarker("Alignment applies when a selectable is larger than its text content."); - ImGui::Text("Safe Area Padding"); - ImGui::SameLine(); HelpMarker("Adjust if you cannot see the edges of your screen (e.g. on a TV where scaling has not been configured)."); - ImGui::SliderFloat2("DisplaySafeAreaPadding", (float*)&style.DisplaySafeAreaPadding, 0.0f, 30.0f, "%.0f"); - ImGui::EndTabItem(); - } - - if (ImGui::BeginTabItem("Colors")) - { - static int output_dest = 0; - static bool output_only_modified = true; - if (ImGui::Button("Export")) - { - if (output_dest == 0) - ImGui::LogToClipboard(); - else - ImGui::LogToTTY(); - ImGui::LogText("ImVec4* colors = ImGui::GetStyle().Colors;" IM_NEWLINE); - for (int i = 0; i < ImGuiCol_COUNT; i++) - { - const ImVec4& col = style.Colors[i]; - const char* name = ImGui::GetStyleColorName(i); - if (!output_only_modified || memcmp(&col, &ref->Colors[i], sizeof(ImVec4)) != 0) - ImGui::LogText("colors[ImGuiCol_%s]%*s= ImVec4(%.2ff, %.2ff, %.2ff, %.2ff);" IM_NEWLINE, - name, 23 - (int)strlen(name), "", col.x, col.y, col.z, col.w); - } - ImGui::LogFinish(); - } - ImGui::SameLine(); ImGui::SetNextItemWidth(120); ImGui::Combo("##output_type", &output_dest, "To Clipboard\0To TTY\0"); - ImGui::SameLine(); ImGui::Checkbox("Only Modified Colors", &output_only_modified); - - static ImGuiTextFilter filter; - filter.Draw("Filter colors", ImGui::GetFontSize() * 16); - - static ImGuiColorEditFlags alpha_flags = 0; - if (ImGui::RadioButton("Opaque", alpha_flags == ImGuiColorEditFlags_None)) { alpha_flags = ImGuiColorEditFlags_None; } ImGui::SameLine(); - if (ImGui::RadioButton("Alpha", alpha_flags == ImGuiColorEditFlags_AlphaPreview)) { alpha_flags = ImGuiColorEditFlags_AlphaPreview; } ImGui::SameLine(); - if (ImGui::RadioButton("Both", alpha_flags == ImGuiColorEditFlags_AlphaPreviewHalf)) { alpha_flags = ImGuiColorEditFlags_AlphaPreviewHalf; } ImGui::SameLine(); - HelpMarker( - "In the color list:\n" - "Left-click on color square to open color picker,\n" - "Right-click to open edit options menu."); - - ImGui::BeginChild("##colors", ImVec2(0, 0), true, ImGuiWindowFlags_AlwaysVerticalScrollbar | ImGuiWindowFlags_AlwaysHorizontalScrollbar | ImGuiWindowFlags_NavFlattened); - ImGui::PushItemWidth(-160); - for (int i = 0; i < ImGuiCol_COUNT; i++) - { - const char* name = ImGui::GetStyleColorName(i); - if (!filter.PassFilter(name)) - continue; - ImGui::PushID(i); - ImGui::ColorEdit4("##color", (float*)&style.Colors[i], ImGuiColorEditFlags_AlphaBar | alpha_flags); - if (memcmp(&style.Colors[i], &ref->Colors[i], sizeof(ImVec4)) != 0) - { - // Tips: in a real user application, you may want to merge and use an icon font into the main font, - // so instead of "Save"/"Revert" you'd use icons! - // Read the FAQ and docs/FONTS.md about using icon fonts. It's really easy and super convenient! - ImGui::SameLine(0.0f, style.ItemInnerSpacing.x); if (ImGui::Button("Save")) { ref->Colors[i] = style.Colors[i]; } - ImGui::SameLine(0.0f, style.ItemInnerSpacing.x); if (ImGui::Button("Revert")) { style.Colors[i] = ref->Colors[i]; } - } - ImGui::SameLine(0.0f, style.ItemInnerSpacing.x); - ImGui::TextUnformatted(name); - ImGui::PopID(); - } - ImGui::PopItemWidth(); - ImGui::EndChild(); - - ImGui::EndTabItem(); - } - - if (ImGui::BeginTabItem("Fonts")) - { - ImGuiIO& io = ImGui::GetIO(); - ImFontAtlas* atlas = io.Fonts; - HelpMarker("Read FAQ and docs/FONTS.md for details on font loading."); - ImGui::ShowFontAtlas(atlas); - - // Post-baking font scaling. Note that this is NOT the nice way of scaling fonts, read below. - // (we enforce hard clamping manually as by default DragFloat/SliderFloat allows CTRL+Click text to get out of bounds). - const float MIN_SCALE = 0.3f; - const float MAX_SCALE = 2.0f; - HelpMarker( - "Those are old settings provided for convenience.\n" - "However, the _correct_ way of scaling your UI is currently to reload your font at the designed size, " - "rebuild the font atlas, and call style.ScaleAllSizes() on a reference ImGuiStyle structure.\n" - "Using those settings here will give you poor quality results."); - static float window_scale = 1.0f; - ImGui::PushItemWidth(ImGui::GetFontSize() * 8); - if (ImGui::DragFloat("window scale", &window_scale, 0.005f, MIN_SCALE, MAX_SCALE, "%.2f", ImGuiSliderFlags_AlwaysClamp)) // Scale only this window - ImGui::SetWindowFontScale(window_scale); - ImGui::DragFloat("global scale", &io.FontGlobalScale, 0.005f, MIN_SCALE, MAX_SCALE, "%.2f", ImGuiSliderFlags_AlwaysClamp); // Scale everything - ImGui::PopItemWidth(); - - ImGui::EndTabItem(); - } - - if (ImGui::BeginTabItem("Rendering")) - { - ImGui::Checkbox("Anti-aliased lines", &style.AntiAliasedLines); - ImGui::SameLine(); - HelpMarker("When disabling anti-aliasing lines, you'll probably want to disable borders in your style as well."); - - ImGui::Checkbox("Anti-aliased lines use texture", &style.AntiAliasedLinesUseTex); - ImGui::SameLine(); - HelpMarker("Faster lines using texture data. Require backend to render with bilinear filtering (not point/nearest filtering)."); - - ImGui::Checkbox("Anti-aliased fill", &style.AntiAliasedFill); - ImGui::PushItemWidth(ImGui::GetFontSize() * 8); - ImGui::DragFloat("Curve Tessellation Tolerance", &style.CurveTessellationTol, 0.02f, 0.10f, 10.0f, "%.2f"); - if (style.CurveTessellationTol < 0.10f) style.CurveTessellationTol = 0.10f; - - // When editing the "Circle Segment Max Error" value, draw a preview of its effect on auto-tessellated circles. - ImGui::DragFloat("Circle Tessellation Max Error", &style.CircleTessellationMaxError , 0.005f, 0.10f, 5.0f, "%.2f", ImGuiSliderFlags_AlwaysClamp); - if (ImGui::IsItemActive()) - { - ImGui::SetNextWindowPos(ImGui::GetCursorScreenPos()); - ImGui::BeginTooltip(); - ImGui::TextUnformatted("(R = radius, N = number of segments)"); - ImGui::Spacing(); - ImDrawList* draw_list = ImGui::GetWindowDrawList(); - const float min_widget_width = ImGui::CalcTextSize("N: MMM\nR: MMM").x; - for (int n = 0; n < 8; n++) - { - const float RAD_MIN = 5.0f; - const float RAD_MAX = 70.0f; - const float rad = RAD_MIN + (RAD_MAX - RAD_MIN) * (float)n / (8.0f - 1.0f); - - ImGui::BeginGroup(); - - ImGui::Text("R: %.f\nN: %d", rad, draw_list->_CalcCircleAutoSegmentCount(rad)); - - const float canvas_width = IM_MAX(min_widget_width, rad * 2.0f); - const float offset_x = floorf(canvas_width * 0.5f); - const float offset_y = floorf(RAD_MAX); - - const ImVec2 p1 = ImGui::GetCursorScreenPos(); - draw_list->AddCircle(ImVec2(p1.x + offset_x, p1.y + offset_y), rad, ImGui::GetColorU32(ImGuiCol_Text)); - ImGui::Dummy(ImVec2(canvas_width, RAD_MAX * 2)); - - /* - const ImVec2 p2 = ImGui::GetCursorScreenPos(); - draw_list->AddCircleFilled(ImVec2(p2.x + offset_x, p2.y + offset_y), rad, ImGui::GetColorU32(ImGuiCol_Text)); - ImGui::Dummy(ImVec2(canvas_width, RAD_MAX * 2)); - */ - - ImGui::EndGroup(); - ImGui::SameLine(); - } - ImGui::EndTooltip(); - } - ImGui::SameLine(); - HelpMarker("When drawing circle primitives with \"num_segments == 0\" tesselation will be calculated automatically."); - - ImGui::DragFloat("Global Alpha", &style.Alpha, 0.005f, 0.20f, 1.0f, "%.2f"); // Not exposing zero here so user doesn't "lose" the UI (zero alpha clips all widgets). But application code could have a toggle to switch between zero and non-zero. - ImGui::DragFloat("Disabled Alpha", &style.DisabledAlpha, 0.005f, 0.0f, 1.0f, "%.2f"); ImGui::SameLine(); HelpMarker("Additional alpha multiplier for disabled items (multiply over current value of Alpha)."); - ImGui::PopItemWidth(); - - ImGui::EndTabItem(); - } - - ImGui::EndTabBar(); - } - - ImGui::PopItemWidth(); -} - -//----------------------------------------------------------------------------- -// [SECTION] Example App: Main Menu Bar / ShowExampleAppMainMenuBar() -//----------------------------------------------------------------------------- -// - ShowExampleAppMainMenuBar() -// - ShowExampleMenuFile() -//----------------------------------------------------------------------------- - -// Demonstrate creating a "main" fullscreen menu bar and populating it. -// Note the difference between BeginMainMenuBar() and BeginMenuBar(): -// - BeginMenuBar() = menu-bar inside current window (which needs the ImGuiWindowFlags_MenuBar flag!) -// - BeginMainMenuBar() = helper to create menu-bar-sized window at the top of the main viewport + call BeginMenuBar() into it. -static void ShowExampleAppMainMenuBar() -{ - if (ImGui::BeginMainMenuBar()) - { - if (ImGui::BeginMenu("File")) - { - ShowExampleMenuFile(); - ImGui::EndMenu(); - } - if (ImGui::BeginMenu("Edit")) - { - if (ImGui::MenuItem("Undo", "CTRL+Z")) {} - if (ImGui::MenuItem("Redo", "CTRL+Y", false, false)) {} // Disabled item - ImGui::Separator(); - if (ImGui::MenuItem("Cut", "CTRL+X")) {} - if (ImGui::MenuItem("Copy", "CTRL+C")) {} - if (ImGui::MenuItem("Paste", "CTRL+V")) {} - ImGui::EndMenu(); - } - ImGui::EndMainMenuBar(); - } -} - -// Note that shortcuts are currently provided for display only -// (future version will add explicit flags to BeginMenu() to request processing shortcuts) -static void ShowExampleMenuFile() -{ - ImGui::MenuItem("(demo menu)", NULL, false, false); - if (ImGui::MenuItem("New")) {} - if (ImGui::MenuItem("Open", "Ctrl+O")) {} - if (ImGui::BeginMenu("Open Recent")) - { - ImGui::MenuItem("fish_hat.c"); - ImGui::MenuItem("fish_hat.inl"); - ImGui::MenuItem("fish_hat.h"); - if (ImGui::BeginMenu("More..")) - { - ImGui::MenuItem("Hello"); - ImGui::MenuItem("Sailor"); - if (ImGui::BeginMenu("Recurse..")) - { - ShowExampleMenuFile(); - ImGui::EndMenu(); - } - ImGui::EndMenu(); - } - ImGui::EndMenu(); - } - if (ImGui::MenuItem("Save", "Ctrl+S")) {} - if (ImGui::MenuItem("Save As..")) {} - - ImGui::Separator(); - if (ImGui::BeginMenu("Options")) - { - static bool enabled = true; - ImGui::MenuItem("Enabled", "", &enabled); - ImGui::BeginChild("child", ImVec2(0, 60), true); - for (int i = 0; i < 10; i++) - ImGui::Text("Scrolling Text %d", i); - ImGui::EndChild(); - static float f = 0.5f; - static int n = 0; - ImGui::SliderFloat("Value", &f, 0.0f, 1.0f); - ImGui::InputFloat("Input", &f, 0.1f); - ImGui::Combo("Combo", &n, "Yes\0No\0Maybe\0\0"); - ImGui::EndMenu(); - } - - if (ImGui::BeginMenu("Colors")) - { - float sz = ImGui::GetTextLineHeight(); - for (int i = 0; i < ImGuiCol_COUNT; i++) - { - const char* name = ImGui::GetStyleColorName((ImGuiCol)i); - ImVec2 p = ImGui::GetCursorScreenPos(); - ImGui::GetWindowDrawList()->AddRectFilled(p, ImVec2(p.x + sz, p.y + sz), ImGui::GetColorU32((ImGuiCol)i)); - ImGui::Dummy(ImVec2(sz, sz)); - ImGui::SameLine(); - ImGui::MenuItem(name); - } - ImGui::EndMenu(); - } - - // Here we demonstrate appending again to the "Options" menu (which we already created above) - // Of course in this demo it is a little bit silly that this function calls BeginMenu("Options") twice. - // In a real code-base using it would make senses to use this feature from very different code locations. - if (ImGui::BeginMenu("Options")) // <-- Append! - { - static bool b = true; - ImGui::Checkbox("SomeOption", &b); - ImGui::EndMenu(); - } - - if (ImGui::BeginMenu("Disabled", false)) // Disabled - { - IM_ASSERT(0); - } - if (ImGui::MenuItem("Checked", NULL, true)) {} - if (ImGui::MenuItem("Quit", "Alt+F4")) {} -} - -//----------------------------------------------------------------------------- -// [SECTION] Example App: Debug Console / ShowExampleAppConsole() -//----------------------------------------------------------------------------- - -// Demonstrate creating a simple console window, with scrolling, filtering, completion and history. -// For the console example, we are using a more C++ like approach of declaring a class to hold both data and functions. -struct ExampleAppConsole -{ - char InputBuf[256]; - ImVector Items; - ImVector Commands; - ImVector History; - int HistoryPos; // -1: new line, 0..History.Size-1 browsing history. - ImGuiTextFilter Filter; - bool AutoScroll; - bool ScrollToBottom; - - ExampleAppConsole() - { - ClearLog(); - memset(InputBuf, 0, sizeof(InputBuf)); - HistoryPos = -1; - - // "CLASSIFY" is here to provide the test case where "C"+[tab] completes to "CL" and display multiple matches. - Commands.push_back("HELP"); - Commands.push_back("HISTORY"); - Commands.push_back("CLEAR"); - Commands.push_back("CLASSIFY"); - AutoScroll = true; - ScrollToBottom = false; - AddLog("Welcome to Dear ImGui!"); - } - ~ExampleAppConsole() - { - ClearLog(); - for (int i = 0; i < History.Size; i++) - free(History[i]); - } - - // Portable helpers - static int Stricmp(const char* s1, const char* s2) { int d; while ((d = toupper(*s2) - toupper(*s1)) == 0 && *s1) { s1++; s2++; } return d; } - static int Strnicmp(const char* s1, const char* s2, int n) { int d = 0; while (n > 0 && (d = toupper(*s2) - toupper(*s1)) == 0 && *s1) { s1++; s2++; n--; } return d; } - static char* Strdup(const char* s) { IM_ASSERT(s); size_t len = strlen(s) + 1; void* buf = malloc(len); IM_ASSERT(buf); return (char*)memcpy(buf, (const void*)s, len); } - static void Strtrim(char* s) { char* str_end = s + strlen(s); while (str_end > s && str_end[-1] == ' ') str_end--; *str_end = 0; } - - void ClearLog() - { - for (int i = 0; i < Items.Size; i++) - free(Items[i]); - Items.clear(); - } - - void AddLog(const char* fmt, ...) IM_FMTARGS(2) - { - // FIXME-OPT - char buf[1024]; - va_list args; - va_start(args, fmt); - vsnprintf(buf, IM_ARRAYSIZE(buf), fmt, args); - buf[IM_ARRAYSIZE(buf)-1] = 0; - va_end(args); - Items.push_back(Strdup(buf)); - } - - void Draw(const char* title, bool* p_open) - { - ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver); - if (!ImGui::Begin(title, p_open)) - { - ImGui::End(); - return; - } - - // As a specific feature guaranteed by the library, after calling Begin() the last Item represent the title bar. - // So e.g. IsItemHovered() will return true when hovering the title bar. - // Here we create a context menu only available from the title bar. - if (ImGui::BeginPopupContextItem()) - { - if (ImGui::MenuItem("Close Console")) - *p_open = false; - ImGui::EndPopup(); - } - - ImGui::TextWrapped( - "This example implements a console with basic coloring, completion (TAB key) and history (Up/Down keys). A more elaborate " - "implementation may want to store entries along with extra data such as timestamp, emitter, etc."); - ImGui::TextWrapped("Enter 'HELP' for help."); - - // TODO: display items starting from the bottom - - if (ImGui::SmallButton("Add Debug Text")) { AddLog("%d some text", Items.Size); AddLog("some more text"); AddLog("display very important message here!"); } - ImGui::SameLine(); - if (ImGui::SmallButton("Add Debug Error")) { AddLog("[error] something went wrong"); } - ImGui::SameLine(); - if (ImGui::SmallButton("Clear")) { ClearLog(); } - ImGui::SameLine(); - bool copy_to_clipboard = ImGui::SmallButton("Copy"); - //static float t = 0.0f; if (ImGui::GetTime() - t > 0.02f) { t = ImGui::GetTime(); AddLog("Spam %f", t); } - - ImGui::Separator(); - - // Options menu - if (ImGui::BeginPopup("Options")) - { - ImGui::Checkbox("Auto-scroll", &AutoScroll); - ImGui::EndPopup(); - } - - // Options, Filter - if (ImGui::Button("Options")) - ImGui::OpenPopup("Options"); - ImGui::SameLine(); - Filter.Draw("Filter (\"incl,-excl\") (\"error\")", 180); - ImGui::Separator(); - - // Reserve enough left-over height for 1 separator + 1 input text - const float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing(); - ImGui::BeginChild("ScrollingRegion", ImVec2(0, -footer_height_to_reserve), false, ImGuiWindowFlags_HorizontalScrollbar); - if (ImGui::BeginPopupContextWindow()) - { - if (ImGui::Selectable("Clear")) ClearLog(); - ImGui::EndPopup(); - } - - // Display every line as a separate entry so we can change their color or add custom widgets. - // If you only want raw text you can use ImGui::TextUnformatted(log.begin(), log.end()); - // NB- if you have thousands of entries this approach may be too inefficient and may require user-side clipping - // to only process visible items. The clipper will automatically measure the height of your first item and then - // "seek" to display only items in the visible area. - // To use the clipper we can replace your standard loop: - // for (int i = 0; i < Items.Size; i++) - // With: - // ImGuiListClipper clipper; - // clipper.Begin(Items.Size); - // while (clipper.Step()) - // for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) - // - That your items are evenly spaced (same height) - // - That you have cheap random access to your elements (you can access them given their index, - // without processing all the ones before) - // You cannot this code as-is if a filter is active because it breaks the 'cheap random-access' property. - // We would need random-access on the post-filtered list. - // A typical application wanting coarse clipping and filtering may want to pre-compute an array of indices - // or offsets of items that passed the filtering test, recomputing this array when user changes the filter, - // and appending newly elements as they are inserted. This is left as a task to the user until we can manage - // to improve this example code! - // If your items are of variable height: - // - Split them into same height items would be simpler and facilitate random-seeking into your list. - // - Consider using manual call to IsRectVisible() and skipping extraneous decoration from your items. - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4, 1)); // Tighten spacing - if (copy_to_clipboard) - ImGui::LogToClipboard(); - for (int i = 0; i < Items.Size; i++) - { - const char* item = Items[i]; - if (!Filter.PassFilter(item)) - continue; - - // Normally you would store more information in your item than just a string. - // (e.g. make Items[] an array of structure, store color/type etc.) - ImVec4 color; - bool has_color = false; - if (strstr(item, "[error]")) { color = ImVec4(1.0f, 0.4f, 0.4f, 1.0f); has_color = true; } - else if (strncmp(item, "# ", 2) == 0) { color = ImVec4(1.0f, 0.8f, 0.6f, 1.0f); has_color = true; } - if (has_color) - ImGui::PushStyleColor(ImGuiCol_Text, color); - ImGui::TextUnformatted(item); - if (has_color) - ImGui::PopStyleColor(); - } - if (copy_to_clipboard) - ImGui::LogFinish(); - - if (ScrollToBottom || (AutoScroll && ImGui::GetScrollY() >= ImGui::GetScrollMaxY())) - ImGui::SetScrollHereY(1.0f); - ScrollToBottom = false; - - ImGui::PopStyleVar(); - ImGui::EndChild(); - ImGui::Separator(); - - // Command-line - bool reclaim_focus = false; - ImGuiInputTextFlags input_text_flags = ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_CallbackHistory; - if (ImGui::InputText("Input", InputBuf, IM_ARRAYSIZE(InputBuf), input_text_flags, &TextEditCallbackStub, (void*)this)) - { - char* s = InputBuf; - Strtrim(s); - if (s[0]) - ExecCommand(s); - strcpy(s, ""); - reclaim_focus = true; - } - - // Auto-focus on window apparition - ImGui::SetItemDefaultFocus(); - if (reclaim_focus) - ImGui::SetKeyboardFocusHere(-1); // Auto focus previous widget - - ImGui::End(); - } - - void ExecCommand(const char* command_line) - { - AddLog("# %s\n", command_line); - - // Insert into history. First find match and delete it so it can be pushed to the back. - // This isn't trying to be smart or optimal. - HistoryPos = -1; - for (int i = History.Size - 1; i >= 0; i--) - if (Stricmp(History[i], command_line) == 0) - { - free(History[i]); - History.erase(History.begin() + i); - break; - } - History.push_back(Strdup(command_line)); - - // Process command - if (Stricmp(command_line, "CLEAR") == 0) - { - ClearLog(); - } - else if (Stricmp(command_line, "HELP") == 0) - { - AddLog("Commands:"); - for (int i = 0; i < Commands.Size; i++) - AddLog("- %s", Commands[i]); - } - else if (Stricmp(command_line, "HISTORY") == 0) - { - int first = History.Size - 10; - for (int i = first > 0 ? first : 0; i < History.Size; i++) - AddLog("%3d: %s\n", i, History[i]); - } - else - { - AddLog("Unknown command: '%s'\n", command_line); - } - - // On command input, we scroll to bottom even if AutoScroll==false - ScrollToBottom = true; - } - - // In C++11 you'd be better off using lambdas for this sort of forwarding callbacks - static int TextEditCallbackStub(ImGuiInputTextCallbackData* data) - { - ExampleAppConsole* console = (ExampleAppConsole*)data->UserData; - return console->TextEditCallback(data); - } - - int TextEditCallback(ImGuiInputTextCallbackData* data) - { - //AddLog("cursor: %d, selection: %d-%d", data->CursorPos, data->SelectionStart, data->SelectionEnd); - switch (data->EventFlag) - { - case ImGuiInputTextFlags_CallbackCompletion: - { - // Example of TEXT COMPLETION - - // Locate beginning of current word - const char* word_end = data->Buf + data->CursorPos; - const char* word_start = word_end; - while (word_start > data->Buf) - { - const char c = word_start[-1]; - if (c == ' ' || c == '\t' || c == ',' || c == ';') - break; - word_start--; - } - - // Build a list of candidates - ImVector candidates; - for (int i = 0; i < Commands.Size; i++) - if (Strnicmp(Commands[i], word_start, (int)(word_end - word_start)) == 0) - candidates.push_back(Commands[i]); - - if (candidates.Size == 0) - { - // No match - AddLog("No match for \"%.*s\"!\n", (int)(word_end - word_start), word_start); - } - else if (candidates.Size == 1) - { - // Single match. Delete the beginning of the word and replace it entirely so we've got nice casing. - data->DeleteChars((int)(word_start - data->Buf), (int)(word_end - word_start)); - data->InsertChars(data->CursorPos, candidates[0]); - data->InsertChars(data->CursorPos, " "); - } - else - { - // Multiple matches. Complete as much as we can.. - // So inputing "C"+Tab will complete to "CL" then display "CLEAR" and "CLASSIFY" as matches. - int match_len = (int)(word_end - word_start); - for (;;) - { - int c = 0; - bool all_candidates_matches = true; - for (int i = 0; i < candidates.Size && all_candidates_matches; i++) - if (i == 0) - c = toupper(candidates[i][match_len]); - else if (c == 0 || c != toupper(candidates[i][match_len])) - all_candidates_matches = false; - if (!all_candidates_matches) - break; - match_len++; - } - - if (match_len > 0) - { - data->DeleteChars((int)(word_start - data->Buf), (int)(word_end - word_start)); - data->InsertChars(data->CursorPos, candidates[0], candidates[0] + match_len); - } - - // List matches - AddLog("Possible matches:\n"); - for (int i = 0; i < candidates.Size; i++) - AddLog("- %s\n", candidates[i]); - } - - break; - } - case ImGuiInputTextFlags_CallbackHistory: - { - // Example of HISTORY - const int prev_history_pos = HistoryPos; - if (data->EventKey == ImGuiKey_UpArrow) - { - if (HistoryPos == -1) - HistoryPos = History.Size - 1; - else if (HistoryPos > 0) - HistoryPos--; - } - else if (data->EventKey == ImGuiKey_DownArrow) - { - if (HistoryPos != -1) - if (++HistoryPos >= History.Size) - HistoryPos = -1; - } - - // A better implementation would preserve the data on the current input line along with cursor position. - if (prev_history_pos != HistoryPos) - { - const char* history_str = (HistoryPos >= 0) ? History[HistoryPos] : ""; - data->DeleteChars(0, data->BufTextLen); - data->InsertChars(0, history_str); - } - } - } - return 0; - } -}; - -static void ShowExampleAppConsole(bool* p_open) -{ - static ExampleAppConsole console; - console.Draw("Example: Console", p_open); -} - -//----------------------------------------------------------------------------- -// [SECTION] Example App: Debug Log / ShowExampleAppLog() -//----------------------------------------------------------------------------- - -// Usage: -// static ExampleAppLog my_log; -// my_log.AddLog("Hello %d world\n", 123); -// my_log.Draw("title"); -struct ExampleAppLog -{ - ImGuiTextBuffer Buf; - ImGuiTextFilter Filter; - ImVector LineOffsets; // Index to lines offset. We maintain this with AddLog() calls. - bool AutoScroll; // Keep scrolling if already at the bottom. - - ExampleAppLog() - { - AutoScroll = true; - Clear(); - } - - void Clear() - { - Buf.clear(); - LineOffsets.clear(); - LineOffsets.push_back(0); - } - - void AddLog(const char* fmt, ...) IM_FMTARGS(2) - { - int old_size = Buf.size(); - va_list args; - va_start(args, fmt); - Buf.appendfv(fmt, args); - va_end(args); - for (int new_size = Buf.size(); old_size < new_size; old_size++) - if (Buf[old_size] == '\n') - LineOffsets.push_back(old_size + 1); - } - - void Draw(const char* title, bool* p_open = NULL) - { - if (!ImGui::Begin(title, p_open)) - { - ImGui::End(); - return; - } - - // Options menu - if (ImGui::BeginPopup("Options")) - { - ImGui::Checkbox("Auto-scroll", &AutoScroll); - ImGui::EndPopup(); - } - - // Main window - if (ImGui::Button("Options")) - ImGui::OpenPopup("Options"); - ImGui::SameLine(); - bool clear = ImGui::Button("Clear"); - ImGui::SameLine(); - bool copy = ImGui::Button("Copy"); - ImGui::SameLine(); - Filter.Draw("Filter", -100.0f); - - ImGui::Separator(); - ImGui::BeginChild("scrolling", ImVec2(0, 0), false, ImGuiWindowFlags_HorizontalScrollbar); - - if (clear) - Clear(); - if (copy) - ImGui::LogToClipboard(); - - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); - const char* buf = Buf.begin(); - const char* buf_end = Buf.end(); - if (Filter.IsActive()) - { - // In this example we don't use the clipper when Filter is enabled. - // This is because we don't have a random access on the result on our filter. - // A real application processing logs with ten of thousands of entries may want to store the result of - // search/filter.. especially if the filtering function is not trivial (e.g. reg-exp). - for (int line_no = 0; line_no < LineOffsets.Size; line_no++) - { - const char* line_start = buf + LineOffsets[line_no]; - const char* line_end = (line_no + 1 < LineOffsets.Size) ? (buf + LineOffsets[line_no + 1] - 1) : buf_end; - if (Filter.PassFilter(line_start, line_end)) - ImGui::TextUnformatted(line_start, line_end); - } - } - else - { - // The simplest and easy way to display the entire buffer: - // ImGui::TextUnformatted(buf_begin, buf_end); - // And it'll just work. TextUnformatted() has specialization for large blob of text and will fast-forward - // to skip non-visible lines. Here we instead demonstrate using the clipper to only process lines that are - // within the visible area. - // If you have tens of thousands of items and their processing cost is non-negligible, coarse clipping them - // on your side is recommended. Using ImGuiListClipper requires - // - A) random access into your data - // - B) items all being the same height, - // both of which we can handle since we an array pointing to the beginning of each line of text. - // When using the filter (in the block of code above) we don't have random access into the data to display - // anymore, which is why we don't use the clipper. Storing or skimming through the search result would make - // it possible (and would be recommended if you want to search through tens of thousands of entries). - ImGuiListClipper clipper; - clipper.Begin(LineOffsets.Size); - while (clipper.Step()) - { - for (int line_no = clipper.DisplayStart; line_no < clipper.DisplayEnd; line_no++) - { - const char* line_start = buf + LineOffsets[line_no]; - const char* line_end = (line_no + 1 < LineOffsets.Size) ? (buf + LineOffsets[line_no + 1] - 1) : buf_end; - ImGui::TextUnformatted(line_start, line_end); - } - } - clipper.End(); - } - ImGui::PopStyleVar(); - - if (AutoScroll && ImGui::GetScrollY() >= ImGui::GetScrollMaxY()) - ImGui::SetScrollHereY(1.0f); - - ImGui::EndChild(); - ImGui::End(); - } -}; - -// Demonstrate creating a simple log window with basic filtering. -static void ShowExampleAppLog(bool* p_open) -{ - static ExampleAppLog log; - - // For the demo: add a debug button _BEFORE_ the normal log window contents - // We take advantage of a rarely used feature: multiple calls to Begin()/End() are appending to the _same_ window. - // Most of the contents of the window will be added by the log.Draw() call. - ImGui::SetNextWindowSize(ImVec2(500, 400), ImGuiCond_FirstUseEver); - ImGui::Begin("Example: Log", p_open); - if (ImGui::SmallButton("[Debug] Add 5 entries")) - { - static int counter = 0; - const char* categories[3] = { "info", "warn", "error" }; - const char* words[] = { "Bumfuzzled", "Cattywampus", "Snickersnee", "Abibliophobia", "Absquatulate", "Nincompoop", "Pauciloquent" }; - for (int n = 0; n < 5; n++) - { - const char* category = categories[counter % IM_ARRAYSIZE(categories)]; - const char* word = words[counter % IM_ARRAYSIZE(words)]; - log.AddLog("[%05d] [%s] Hello, current time is %.1f, here's a word: '%s'\n", - ImGui::GetFrameCount(), category, ImGui::GetTime(), word); - counter++; - } - } - ImGui::End(); - - // Actually call in the regular Log helper (which will Begin() into the same window as we just did) - log.Draw("Example: Log", p_open); -} - -//----------------------------------------------------------------------------- -// [SECTION] Example App: Simple Layout / ShowExampleAppLayout() -//----------------------------------------------------------------------------- - -// Demonstrate create a window with multiple child windows. -static void ShowExampleAppLayout(bool* p_open) -{ - ImGui::SetNextWindowSize(ImVec2(500, 440), ImGuiCond_FirstUseEver); - if (ImGui::Begin("Example: Simple layout", p_open, ImGuiWindowFlags_MenuBar)) - { - if (ImGui::BeginMenuBar()) - { - if (ImGui::BeginMenu("File")) - { - if (ImGui::MenuItem("Close")) *p_open = false; - ImGui::EndMenu(); - } - ImGui::EndMenuBar(); - } - - // Left - static int selected = 0; - { - ImGui::BeginChild("left pane", ImVec2(150, 0), true); - for (int i = 0; i < 100; i++) - { - // FIXME: Good candidate to use ImGuiSelectableFlags_SelectOnNav - char label[128]; - sprintf(label, "MyObject %d", i); - if (ImGui::Selectable(label, selected == i)) - selected = i; - } - ImGui::EndChild(); - } - ImGui::SameLine(); - - // Right - { - ImGui::BeginGroup(); - ImGui::BeginChild("item view", ImVec2(0, -ImGui::GetFrameHeightWithSpacing())); // Leave room for 1 line below us - ImGui::Text("MyObject: %d", selected); - ImGui::Separator(); - if (ImGui::BeginTabBar("##Tabs", ImGuiTabBarFlags_None)) - { - if (ImGui::BeginTabItem("Description")) - { - ImGui::TextWrapped("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "); - ImGui::EndTabItem(); - } - if (ImGui::BeginTabItem("Details")) - { - ImGui::Text("ID: 0123456789"); - ImGui::EndTabItem(); - } - ImGui::EndTabBar(); - } - ImGui::EndChild(); - if (ImGui::Button("Revert")) {} - ImGui::SameLine(); - if (ImGui::Button("Save")) {} - ImGui::EndGroup(); - } - } - ImGui::End(); -} - -//----------------------------------------------------------------------------- -// [SECTION] Example App: Property Editor / ShowExampleAppPropertyEditor() -//----------------------------------------------------------------------------- - -static void ShowPlaceholderObject(const char* prefix, int uid) -{ - // Use object uid as identifier. Most commonly you could also use the object pointer as a base ID. - ImGui::PushID(uid); - - // Text and Tree nodes are less high than framed widgets, using AlignTextToFramePadding() we add vertical spacing to make the tree lines equal high. - ImGui::TableNextRow(); - ImGui::TableSetColumnIndex(0); - ImGui::AlignTextToFramePadding(); - bool node_open = ImGui::TreeNode("Object", "%s_%u", prefix, uid); - ImGui::TableSetColumnIndex(1); - ImGui::Text("my sailor is rich"); - - if (node_open) - { - static float placeholder_members[8] = { 0.0f, 0.0f, 1.0f, 3.1416f, 100.0f, 999.0f }; - for (int i = 0; i < 8; i++) - { - ImGui::PushID(i); // Use field index as identifier. - if (i < 2) - { - ShowPlaceholderObject("Child", 424242); - } - else - { - // Here we use a TreeNode to highlight on hover (we could use e.g. Selectable as well) - ImGui::TableNextRow(); - ImGui::TableSetColumnIndex(0); - ImGui::AlignTextToFramePadding(); - ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_Bullet; - ImGui::TreeNodeEx("Field", flags, "Field_%d", i); - - ImGui::TableSetColumnIndex(1); - ImGui::SetNextItemWidth(-FLT_MIN); - if (i >= 5) - ImGui::InputFloat("##value", &placeholder_members[i], 1.0f); - else - ImGui::DragFloat("##value", &placeholder_members[i], 0.01f); - ImGui::NextColumn(); - } - ImGui::PopID(); - } - ImGui::TreePop(); - } - ImGui::PopID(); -} - -// Demonstrate create a simple property editor. -static void ShowExampleAppPropertyEditor(bool* p_open) -{ - ImGui::SetNextWindowSize(ImVec2(430, 450), ImGuiCond_FirstUseEver); - if (!ImGui::Begin("Example: Property editor", p_open)) - { - ImGui::End(); - return; - } - - HelpMarker( - "This example shows how you may implement a property editor using two columns.\n" - "All objects/fields data are dummies here.\n" - "Remember that in many simple cases, you can use ImGui::SameLine(xxx) to position\n" - "your cursor horizontally instead of using the Columns() API."); - - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(2, 2)); - if (ImGui::BeginTable("split", 2, ImGuiTableFlags_BordersOuter | ImGuiTableFlags_Resizable)) - { - // Iterate placeholder objects (all the same data) - for (int obj_i = 0; obj_i < 4; obj_i++) - { - ShowPlaceholderObject("Object", obj_i); - //ImGui::Separator(); - } - ImGui::EndTable(); - } - ImGui::PopStyleVar(); - ImGui::End(); -} - -//----------------------------------------------------------------------------- -// [SECTION] Example App: Long Text / ShowExampleAppLongText() -//----------------------------------------------------------------------------- - -// Demonstrate/test rendering huge amount of text, and the incidence of clipping. -static void ShowExampleAppLongText(bool* p_open) -{ - ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver); - if (!ImGui::Begin("Example: Long text display", p_open)) - { - ImGui::End(); - return; - } - - static int test_type = 0; - static ImGuiTextBuffer log; - static int lines = 0; - ImGui::Text("Printing unusually long amount of text."); - ImGui::Combo("Test type", &test_type, - "Single call to TextUnformatted()\0" - "Multiple calls to Text(), clipped\0" - "Multiple calls to Text(), not clipped (slow)\0"); - ImGui::Text("Buffer contents: %d lines, %d bytes", lines, log.size()); - if (ImGui::Button("Clear")) { log.clear(); lines = 0; } - ImGui::SameLine(); - if (ImGui::Button("Add 1000 lines")) - { - for (int i = 0; i < 1000; i++) - log.appendf("%i The quick brown fox jumps over the lazy dog\n", lines + i); - lines += 1000; - } - ImGui::BeginChild("Log"); - switch (test_type) - { - case 0: - // Single call to TextUnformatted() with a big buffer - ImGui::TextUnformatted(log.begin(), log.end()); - break; - case 1: - { - // Multiple calls to Text(), manually coarsely clipped - demonstrate how to use the ImGuiListClipper helper. - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); - ImGuiListClipper clipper; - clipper.Begin(lines); - while (clipper.Step()) - for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) - ImGui::Text("%i The quick brown fox jumps over the lazy dog", i); - ImGui::PopStyleVar(); - break; - } - case 2: - // Multiple calls to Text(), not clipped (slow) - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); - for (int i = 0; i < lines; i++) - ImGui::Text("%i The quick brown fox jumps over the lazy dog", i); - ImGui::PopStyleVar(); - break; - } - ImGui::EndChild(); - ImGui::End(); -} - -//----------------------------------------------------------------------------- -// [SECTION] Example App: Auto Resize / ShowExampleAppAutoResize() -//----------------------------------------------------------------------------- - -// Demonstrate creating a window which gets auto-resized according to its content. -static void ShowExampleAppAutoResize(bool* p_open) -{ - if (!ImGui::Begin("Example: Auto-resizing window", p_open, ImGuiWindowFlags_AlwaysAutoResize)) - { - ImGui::End(); - return; - } - - static int lines = 10; - ImGui::TextUnformatted( - "Window will resize every-frame to the size of its content.\n" - "Note that you probably don't want to query the window size to\n" - "output your content because that would create a feedback loop."); - ImGui::SliderInt("Number of lines", &lines, 1, 20); - for (int i = 0; i < lines; i++) - ImGui::Text("%*sThis is line %d", i * 4, "", i); // Pad with space to extend size horizontally - ImGui::End(); -} - -//----------------------------------------------------------------------------- -// [SECTION] Example App: Constrained Resize / ShowExampleAppConstrainedResize() -//----------------------------------------------------------------------------- - -// Demonstrate creating a window with custom resize constraints. -static void ShowExampleAppConstrainedResize(bool* p_open) -{ - struct CustomConstraints - { - // Helper functions to demonstrate programmatic constraints - static void Square(ImGuiSizeCallbackData* data) { data->DesiredSize.x = data->DesiredSize.y = IM_MAX(data->DesiredSize.x, data->DesiredSize.y); } - static void Step(ImGuiSizeCallbackData* data) { float step = (float)(int)(intptr_t)data->UserData; data->DesiredSize = ImVec2((int)(data->DesiredSize.x / step + 0.5f) * step, (int)(data->DesiredSize.y / step + 0.5f) * step); } - }; - - const char* test_desc[] = - { - "Resize vertical only", - "Resize horizontal only", - "Width > 100, Height > 100", - "Width 400-500", - "Height 400-500", - "Custom: Always Square", - "Custom: Fixed Steps (100)", - }; - - static bool auto_resize = false; - static int type = 0; - static int display_lines = 10; - if (type == 0) ImGui::SetNextWindowSizeConstraints(ImVec2(-1, 0), ImVec2(-1, FLT_MAX)); // Vertical only - if (type == 1) ImGui::SetNextWindowSizeConstraints(ImVec2(0, -1), ImVec2(FLT_MAX, -1)); // Horizontal only - if (type == 2) ImGui::SetNextWindowSizeConstraints(ImVec2(100, 100), ImVec2(FLT_MAX, FLT_MAX)); // Width > 100, Height > 100 - if (type == 3) ImGui::SetNextWindowSizeConstraints(ImVec2(400, -1), ImVec2(500, -1)); // Width 400-500 - if (type == 4) ImGui::SetNextWindowSizeConstraints(ImVec2(-1, 400), ImVec2(-1, 500)); // Height 400-500 - if (type == 5) ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::Square); // Always Square - if (type == 6) ImGui::SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, FLT_MAX), CustomConstraints::Step, (void*)(intptr_t)100); // Fixed Step - - ImGuiWindowFlags flags = auto_resize ? ImGuiWindowFlags_AlwaysAutoResize : 0; - if (ImGui::Begin("Example: Constrained Resize", p_open, flags)) - { - if (ImGui::Button("200x200")) { ImGui::SetWindowSize(ImVec2(200, 200)); } ImGui::SameLine(); - if (ImGui::Button("500x500")) { ImGui::SetWindowSize(ImVec2(500, 500)); } ImGui::SameLine(); - if (ImGui::Button("800x200")) { ImGui::SetWindowSize(ImVec2(800, 200)); } - ImGui::SetNextItemWidth(200); - ImGui::Combo("Constraint", &type, test_desc, IM_ARRAYSIZE(test_desc)); - ImGui::SetNextItemWidth(200); - ImGui::DragInt("Lines", &display_lines, 0.2f, 1, 100); - ImGui::Checkbox("Auto-resize", &auto_resize); - for (int i = 0; i < display_lines; i++) - ImGui::Text("%*sHello, sailor! Making this line long enough for the example.", i * 4, ""); - } - ImGui::End(); -} - -//----------------------------------------------------------------------------- -// [SECTION] Example App: Simple overlay / ShowExampleAppSimpleOverlay() -//----------------------------------------------------------------------------- - -// Demonstrate creating a simple static window with no decoration -// + a context-menu to choose which corner of the screen to use. -static void ShowExampleAppSimpleOverlay(bool* p_open) -{ - static int corner = 0; - ImGuiIO& io = ImGui::GetIO(); - ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav; - if (corner != -1) - { - const float PAD = 10.0f; - const ImGuiViewport* viewport = ImGui::GetMainViewport(); - ImVec2 work_pos = viewport->WorkPos; // Use work area to avoid menu-bar/task-bar, if any! - ImVec2 work_size = viewport->WorkSize; - ImVec2 window_pos, window_pos_pivot; - window_pos.x = (corner & 1) ? (work_pos.x + work_size.x - PAD) : (work_pos.x + PAD); - window_pos.y = (corner & 2) ? (work_pos.y + work_size.y - PAD) : (work_pos.y + PAD); - window_pos_pivot.x = (corner & 1) ? 1.0f : 0.0f; - window_pos_pivot.y = (corner & 2) ? 1.0f : 0.0f; - ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot); - window_flags |= ImGuiWindowFlags_NoMove; - } - ImGui::SetNextWindowBgAlpha(0.35f); // Transparent background - if (ImGui::Begin("Example: Simple overlay", p_open, window_flags)) - { - ImGui::Text("Simple overlay\n" "in the corner of the screen.\n" "(right-click to change position)"); - ImGui::Separator(); - if (ImGui::IsMousePosValid()) - ImGui::Text("Mouse Position: (%.1f,%.1f)", io.MousePos.x, io.MousePos.y); - else - ImGui::Text("Mouse Position: "); - if (ImGui::BeginPopupContextWindow()) - { - if (ImGui::MenuItem("Custom", NULL, corner == -1)) corner = -1; - if (ImGui::MenuItem("Top-left", NULL, corner == 0)) corner = 0; - if (ImGui::MenuItem("Top-right", NULL, corner == 1)) corner = 1; - if (ImGui::MenuItem("Bottom-left", NULL, corner == 2)) corner = 2; - if (ImGui::MenuItem("Bottom-right", NULL, corner == 3)) corner = 3; - if (p_open && ImGui::MenuItem("Close")) *p_open = false; - ImGui::EndPopup(); - } - } - ImGui::End(); -} - -//----------------------------------------------------------------------------- -// [SECTION] Example App: Fullscreen window / ShowExampleAppFullscreen() -//----------------------------------------------------------------------------- - -// Demonstrate creating a window covering the entire screen/viewport -static void ShowExampleAppFullscreen(bool* p_open) -{ - static bool use_work_area = true; - static ImGuiWindowFlags flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings; - - // We demonstrate using the full viewport area or the work area (without menu-bars, task-bars etc.) - // Based on your use case you may want one of the other. - const ImGuiViewport* viewport = ImGui::GetMainViewport(); - ImGui::SetNextWindowPos(use_work_area ? viewport->WorkPos : viewport->Pos); - ImGui::SetNextWindowSize(use_work_area ? viewport->WorkSize : viewport->Size); - - if (ImGui::Begin("Example: Fullscreen window", p_open, flags)) - { - ImGui::Checkbox("Use work area instead of main area", &use_work_area); - ImGui::SameLine(); - HelpMarker("Main Area = entire viewport,\nWork Area = entire viewport minus sections used by the main menu bars, task bars etc.\n\nEnable the main-menu bar in Examples menu to see the difference."); - - ImGui::CheckboxFlags("ImGuiWindowFlags_NoBackground", &flags, ImGuiWindowFlags_NoBackground); - ImGui::CheckboxFlags("ImGuiWindowFlags_NoDecoration", &flags, ImGuiWindowFlags_NoDecoration); - ImGui::Indent(); - ImGui::CheckboxFlags("ImGuiWindowFlags_NoTitleBar", &flags, ImGuiWindowFlags_NoTitleBar); - ImGui::CheckboxFlags("ImGuiWindowFlags_NoCollapse", &flags, ImGuiWindowFlags_NoCollapse); - ImGui::CheckboxFlags("ImGuiWindowFlags_NoScrollbar", &flags, ImGuiWindowFlags_NoScrollbar); - ImGui::Unindent(); - - if (p_open && ImGui::Button("Close this window")) - *p_open = false; - } - ImGui::End(); -} - -//----------------------------------------------------------------------------- -// [SECTION] Example App: Manipulating Window Titles / ShowExampleAppWindowTitles() -//----------------------------------------------------------------------------- - -// Demonstrate using "##" and "###" in identifiers to manipulate ID generation. -// This apply to all regular items as well. -// Read FAQ section "How can I have multiple widgets with the same label?" for details. -static void ShowExampleAppWindowTitles(bool*) -{ - const ImGuiViewport* viewport = ImGui::GetMainViewport(); - const ImVec2 base_pos = viewport->Pos; - - // By default, Windows are uniquely identified by their title. - // You can use the "##" and "###" markers to manipulate the display/ID. - - // Using "##" to display same title but have unique identifier. - ImGui::SetNextWindowPos(ImVec2(base_pos.x + 100, base_pos.y + 100), ImGuiCond_FirstUseEver); - ImGui::Begin("Same title as another window##1"); - ImGui::Text("This is window 1.\nMy title is the same as window 2, but my identifier is unique."); - ImGui::End(); - - ImGui::SetNextWindowPos(ImVec2(base_pos.x + 100, base_pos.y + 200), ImGuiCond_FirstUseEver); - ImGui::Begin("Same title as another window##2"); - ImGui::Text("This is window 2.\nMy title is the same as window 1, but my identifier is unique."); - ImGui::End(); - - // Using "###" to display a changing title but keep a static identifier "AnimatedTitle" - char buf[128]; - sprintf(buf, "Animated title %c %d###AnimatedTitle", "|/-\\"[(int)(ImGui::GetTime() / 0.25f) & 3], ImGui::GetFrameCount()); - ImGui::SetNextWindowPos(ImVec2(base_pos.x + 100, base_pos.y + 300), ImGuiCond_FirstUseEver); - ImGui::Begin(buf); - ImGui::Text("This window has a changing title."); - ImGui::End(); -} - -//----------------------------------------------------------------------------- -// [SECTION] Example App: Custom Rendering using ImDrawList API / ShowExampleAppCustomRendering() -//----------------------------------------------------------------------------- - -// Demonstrate using the low-level ImDrawList to draw custom shapes. -static void ShowExampleAppCustomRendering(bool* p_open) -{ - if (!ImGui::Begin("Example: Custom rendering", p_open)) - { - ImGui::End(); - return; - } - - // Tip: If you do a lot of custom rendering, you probably want to use your own geometrical types and benefit of - // overloaded operators, etc. Define IM_VEC2_CLASS_EXTRA in imconfig.h to create implicit conversions between your - // types and ImVec2/ImVec4. Dear ImGui defines overloaded operators but they are internal to imgui.cpp and not - // exposed outside (to avoid messing with your types) In this example we are not using the maths operators! - - if (ImGui::BeginTabBar("##TabBar")) - { - if (ImGui::BeginTabItem("Primitives")) - { - ImGui::PushItemWidth(-ImGui::GetFontSize() * 15); - ImDrawList* draw_list = ImGui::GetWindowDrawList(); - - // Draw gradients - // (note that those are currently exacerbating our sRGB/Linear issues) - // Calling ImGui::GetColorU32() multiplies the given colors by the current Style Alpha, but you may pass the IM_COL32() directly as well.. - ImGui::Text("Gradients"); - ImVec2 gradient_size = ImVec2(ImGui::CalcItemWidth(), ImGui::GetFrameHeight()); - { - ImVec2 p0 = ImGui::GetCursorScreenPos(); - ImVec2 p1 = ImVec2(p0.x + gradient_size.x, p0.y + gradient_size.y); - ImU32 col_a = ImGui::GetColorU32(IM_COL32(0, 0, 0, 255)); - ImU32 col_b = ImGui::GetColorU32(IM_COL32(255, 255, 255, 255)); - draw_list->AddRectFilledMultiColor(p0, p1, col_a, col_b, col_b, col_a); - ImGui::InvisibleButton("##gradient1", gradient_size); - } - { - ImVec2 p0 = ImGui::GetCursorScreenPos(); - ImVec2 p1 = ImVec2(p0.x + gradient_size.x, p0.y + gradient_size.y); - ImU32 col_a = ImGui::GetColorU32(IM_COL32(0, 255, 0, 255)); - ImU32 col_b = ImGui::GetColorU32(IM_COL32(255, 0, 0, 255)); - draw_list->AddRectFilledMultiColor(p0, p1, col_a, col_b, col_b, col_a); - ImGui::InvisibleButton("##gradient2", gradient_size); - } - - // Draw a bunch of primitives - ImGui::Text("All primitives"); - static float sz = 36.0f; - static float thickness = 3.0f; - static int ngon_sides = 6; - static bool circle_segments_override = false; - static int circle_segments_override_v = 12; - static bool curve_segments_override = false; - static int curve_segments_override_v = 8; - static ImVec4 colf = ImVec4(1.0f, 1.0f, 0.4f, 1.0f); - ImGui::DragFloat("Size", &sz, 0.2f, 2.0f, 100.0f, "%.0f"); - ImGui::DragFloat("Thickness", &thickness, 0.05f, 1.0f, 8.0f, "%.02f"); - ImGui::SliderInt("N-gon sides", &ngon_sides, 3, 12); - ImGui::Checkbox("##circlesegmentoverride", &circle_segments_override); - ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x); - circle_segments_override |= ImGui::SliderInt("Circle segments override", &circle_segments_override_v, 3, 40); - ImGui::Checkbox("##curvessegmentoverride", &curve_segments_override); - ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x); - curve_segments_override |= ImGui::SliderInt("Curves segments override", &curve_segments_override_v, 3, 40); - ImGui::ColorEdit4("Color", &colf.x); - - const ImVec2 p = ImGui::GetCursorScreenPos(); - const ImU32 col = ImColor(colf); - const float spacing = 10.0f; - const ImDrawFlags corners_tl_br = ImDrawFlags_RoundCornersTopLeft | ImDrawFlags_RoundCornersBottomRight; - const float rounding = sz / 5.0f; - const int circle_segments = circle_segments_override ? circle_segments_override_v : 0; - const int curve_segments = curve_segments_override ? curve_segments_override_v : 0; - float x = p.x + 4.0f; - float y = p.y + 4.0f; - for (int n = 0; n < 2; n++) - { - // First line uses a thickness of 1.0f, second line uses the configurable thickness - float th = (n == 0) ? 1.0f : thickness; - draw_list->AddNgon(ImVec2(x + sz*0.5f, y + sz*0.5f), sz*0.5f, col, ngon_sides, th); x += sz + spacing; // N-gon - draw_list->AddCircle(ImVec2(x + sz*0.5f, y + sz*0.5f), sz*0.5f, col, circle_segments, th); x += sz + spacing; // Circle - draw_list->AddRect(ImVec2(x, y), ImVec2(x + sz, y + sz), col, 0.0f, ImDrawFlags_None, th); x += sz + spacing; // Square - draw_list->AddRect(ImVec2(x, y), ImVec2(x + sz, y + sz), col, rounding, ImDrawFlags_None, th); x += sz + spacing; // Square with all rounded corners - draw_list->AddRect(ImVec2(x, y), ImVec2(x + sz, y + sz), col, rounding, corners_tl_br, th); x += sz + spacing; // Square with two rounded corners - draw_list->AddTriangle(ImVec2(x+sz*0.5f,y), ImVec2(x+sz, y+sz-0.5f), ImVec2(x, y+sz-0.5f), col, th);x += sz + spacing; // Triangle - //draw_list->AddTriangle(ImVec2(x+sz*0.2f,y), ImVec2(x, y+sz-0.5f), ImVec2(x+sz*0.4f, y+sz-0.5f), col, th);x+= sz*0.4f + spacing; // Thin triangle - draw_list->AddLine(ImVec2(x, y), ImVec2(x + sz, y), col, th); x += sz + spacing; // Horizontal line (note: drawing a filled rectangle will be faster!) - draw_list->AddLine(ImVec2(x, y), ImVec2(x, y + sz), col, th); x += spacing; // Vertical line (note: drawing a filled rectangle will be faster!) - draw_list->AddLine(ImVec2(x, y), ImVec2(x + sz, y + sz), col, th); x += sz + spacing; // Diagonal line - - // Quadratic Bezier Curve (3 control points) - ImVec2 cp3[3] = { ImVec2(x, y + sz * 0.6f), ImVec2(x + sz * 0.5f, y - sz * 0.4f), ImVec2(x + sz, y + sz) }; - draw_list->AddBezierQuadratic(cp3[0], cp3[1], cp3[2], col, th, curve_segments); x += sz + spacing; - - // Cubic Bezier Curve (4 control points) - ImVec2 cp4[4] = { ImVec2(x, y), ImVec2(x + sz * 1.3f, y + sz * 0.3f), ImVec2(x + sz - sz * 1.3f, y + sz - sz * 0.3f), ImVec2(x + sz, y + sz) }; - draw_list->AddBezierCubic(cp4[0], cp4[1], cp4[2], cp4[3], col, th, curve_segments); - - x = p.x + 4; - y += sz + spacing; - } - draw_list->AddNgonFilled(ImVec2(x + sz * 0.5f, y + sz * 0.5f), sz*0.5f, col, ngon_sides); x += sz + spacing; // N-gon - draw_list->AddCircleFilled(ImVec2(x + sz*0.5f, y + sz*0.5f), sz*0.5f, col, circle_segments); x += sz + spacing; // Circle - draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + sz, y + sz), col); x += sz + spacing; // Square - draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + sz, y + sz), col, 10.0f); x += sz + spacing; // Square with all rounded corners - draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + sz, y + sz), col, 10.0f, corners_tl_br); x += sz + spacing; // Square with two rounded corners - draw_list->AddTriangleFilled(ImVec2(x+sz*0.5f,y), ImVec2(x+sz, y+sz-0.5f), ImVec2(x, y+sz-0.5f), col); x += sz + spacing; // Triangle - //draw_list->AddTriangleFilled(ImVec2(x+sz*0.2f,y), ImVec2(x, y+sz-0.5f), ImVec2(x+sz*0.4f, y+sz-0.5f), col); x += sz*0.4f + spacing; // Thin triangle - draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + sz, y + thickness), col); x += sz + spacing; // Horizontal line (faster than AddLine, but only handle integer thickness) - draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + thickness, y + sz), col); x += spacing * 2.0f;// Vertical line (faster than AddLine, but only handle integer thickness) - draw_list->AddRectFilled(ImVec2(x, y), ImVec2(x + 1, y + 1), col); x += sz; // Pixel (faster than AddLine) - draw_list->AddRectFilledMultiColor(ImVec2(x, y), ImVec2(x + sz, y + sz), IM_COL32(0, 0, 0, 255), IM_COL32(255, 0, 0, 255), IM_COL32(255, 255, 0, 255), IM_COL32(0, 255, 0, 255)); - - ImGui::Dummy(ImVec2((sz + spacing) * 10.2f, (sz + spacing) * 3.0f)); - ImGui::PopItemWidth(); - ImGui::EndTabItem(); - } - - if (ImGui::BeginTabItem("Canvas")) - { - static ImVector points; - static ImVec2 scrolling(0.0f, 0.0f); - static bool opt_enable_grid = true; - static bool opt_enable_context_menu = true; - static bool adding_line = false; - - ImGui::Checkbox("Enable grid", &opt_enable_grid); - ImGui::Checkbox("Enable context menu", &opt_enable_context_menu); - ImGui::Text("Mouse Left: drag to add lines,\nMouse Right: drag to scroll, click for context menu."); - - // Typically you would use a BeginChild()/EndChild() pair to benefit from a clipping region + own scrolling. - // Here we demonstrate that this can be replaced by simple offsetting + custom drawing + PushClipRect/PopClipRect() calls. - // To use a child window instead we could use, e.g: - // ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0)); // Disable padding - // ImGui::PushStyleColor(ImGuiCol_ChildBg, IM_COL32(50, 50, 50, 255)); // Set a background color - // ImGui::BeginChild("canvas", ImVec2(0.0f, 0.0f), true, ImGuiWindowFlags_NoMove); - // ImGui::PopStyleColor(); - // ImGui::PopStyleVar(); - // [...] - // ImGui::EndChild(); - - // Using InvisibleButton() as a convenience 1) it will advance the layout cursor and 2) allows us to use IsItemHovered()/IsItemActive() - ImVec2 canvas_p0 = ImGui::GetCursorScreenPos(); // ImDrawList API uses screen coordinates! - ImVec2 canvas_sz = ImGui::GetContentRegionAvail(); // Resize canvas to what's available - if (canvas_sz.x < 50.0f) canvas_sz.x = 50.0f; - if (canvas_sz.y < 50.0f) canvas_sz.y = 50.0f; - ImVec2 canvas_p1 = ImVec2(canvas_p0.x + canvas_sz.x, canvas_p0.y + canvas_sz.y); - - // Draw border and background color - ImGuiIO& io = ImGui::GetIO(); - ImDrawList* draw_list = ImGui::GetWindowDrawList(); - draw_list->AddRectFilled(canvas_p0, canvas_p1, IM_COL32(50, 50, 50, 255)); - draw_list->AddRect(canvas_p0, canvas_p1, IM_COL32(255, 255, 255, 255)); - - // This will catch our interactions - ImGui::InvisibleButton("canvas", canvas_sz, ImGuiButtonFlags_MouseButtonLeft | ImGuiButtonFlags_MouseButtonRight); - const bool is_hovered = ImGui::IsItemHovered(); // Hovered - const bool is_active = ImGui::IsItemActive(); // Held - const ImVec2 origin(canvas_p0.x + scrolling.x, canvas_p0.y + scrolling.y); // Lock scrolled origin - const ImVec2 mouse_pos_in_canvas(io.MousePos.x - origin.x, io.MousePos.y - origin.y); - - // Add first and second point - if (is_hovered && !adding_line && ImGui::IsMouseClicked(ImGuiMouseButton_Left)) - { - points.push_back(mouse_pos_in_canvas); - points.push_back(mouse_pos_in_canvas); - adding_line = true; - } - if (adding_line) - { - points.back() = mouse_pos_in_canvas; - if (!ImGui::IsMouseDown(ImGuiMouseButton_Left)) - adding_line = false; - } - - // Pan (we use a zero mouse threshold when there's no context menu) - // You may decide to make that threshold dynamic based on whether the mouse is hovering something etc. - const float mouse_threshold_for_pan = opt_enable_context_menu ? -1.0f : 0.0f; - if (is_active && ImGui::IsMouseDragging(ImGuiMouseButton_Right, mouse_threshold_for_pan)) - { - scrolling.x += io.MouseDelta.x; - scrolling.y += io.MouseDelta.y; - } - - // Context menu (under default mouse threshold) - ImVec2 drag_delta = ImGui::GetMouseDragDelta(ImGuiMouseButton_Right); - if (opt_enable_context_menu && ImGui::IsMouseReleased(ImGuiMouseButton_Right) && drag_delta.x == 0.0f && drag_delta.y == 0.0f) - ImGui::OpenPopupOnItemClick("context"); - if (ImGui::BeginPopup("context")) - { - if (adding_line) - points.resize(points.size() - 2); - adding_line = false; - if (ImGui::MenuItem("Remove one", NULL, false, points.Size > 0)) { points.resize(points.size() - 2); } - if (ImGui::MenuItem("Remove all", NULL, false, points.Size > 0)) { points.clear(); } - ImGui::EndPopup(); - } - - // Draw grid + all lines in the canvas - draw_list->PushClipRect(canvas_p0, canvas_p1, true); - if (opt_enable_grid) - { - const float GRID_STEP = 64.0f; - for (float x = fmodf(scrolling.x, GRID_STEP); x < canvas_sz.x; x += GRID_STEP) - draw_list->AddLine(ImVec2(canvas_p0.x + x, canvas_p0.y), ImVec2(canvas_p0.x + x, canvas_p1.y), IM_COL32(200, 200, 200, 40)); - for (float y = fmodf(scrolling.y, GRID_STEP); y < canvas_sz.y; y += GRID_STEP) - draw_list->AddLine(ImVec2(canvas_p0.x, canvas_p0.y + y), ImVec2(canvas_p1.x, canvas_p0.y + y), IM_COL32(200, 200, 200, 40)); - } - for (int n = 0; n < points.Size; n += 2) - draw_list->AddLine(ImVec2(origin.x + points[n].x, origin.y + points[n].y), ImVec2(origin.x + points[n + 1].x, origin.y + points[n + 1].y), IM_COL32(255, 255, 0, 255), 2.0f); - draw_list->PopClipRect(); - - ImGui::EndTabItem(); - } - - if (ImGui::BeginTabItem("BG/FG draw lists")) - { - static bool draw_bg = true; - static bool draw_fg = true; - ImGui::Checkbox("Draw in Background draw list", &draw_bg); - ImGui::SameLine(); HelpMarker("The Background draw list will be rendered below every Dear ImGui windows."); - ImGui::Checkbox("Draw in Foreground draw list", &draw_fg); - ImGui::SameLine(); HelpMarker("The Foreground draw list will be rendered over every Dear ImGui windows."); - ImVec2 window_pos = ImGui::GetWindowPos(); - ImVec2 window_size = ImGui::GetWindowSize(); - ImVec2 window_center = ImVec2(window_pos.x + window_size.x * 0.5f, window_pos.y + window_size.y * 0.5f); - if (draw_bg) - ImGui::GetBackgroundDrawList()->AddCircle(window_center, window_size.x * 0.6f, IM_COL32(255, 0, 0, 200), 0, 10 + 4); - if (draw_fg) - ImGui::GetForegroundDrawList()->AddCircle(window_center, window_size.y * 0.6f, IM_COL32(0, 255, 0, 200), 0, 10); - ImGui::EndTabItem(); - } - - ImGui::EndTabBar(); - } - - ImGui::End(); -} - -//----------------------------------------------------------------------------- -// [SECTION] Example App: Documents Handling / ShowExampleAppDocuments() -//----------------------------------------------------------------------------- - -// Simplified structure to mimic a Document model -struct MyDocument -{ - const char* Name; // Document title - bool Open; // Set when open (we keep an array of all available documents to simplify demo code!) - bool OpenPrev; // Copy of Open from last update. - bool Dirty; // Set when the document has been modified - bool WantClose; // Set when the document - ImVec4 Color; // An arbitrary variable associated to the document - - MyDocument(const char* name, bool open = true, const ImVec4& color = ImVec4(1.0f, 1.0f, 1.0f, 1.0f)) - { - Name = name; - Open = OpenPrev = open; - Dirty = false; - WantClose = false; - Color = color; - } - void DoOpen() { Open = true; } - void DoQueueClose() { WantClose = true; } - void DoForceClose() { Open = false; Dirty = false; } - void DoSave() { Dirty = false; } - - // Display placeholder contents for the Document - static void DisplayContents(MyDocument* doc) - { - ImGui::PushID(doc); - ImGui::Text("Document \"%s\"", doc->Name); - ImGui::PushStyleColor(ImGuiCol_Text, doc->Color); - ImGui::TextWrapped("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."); - ImGui::PopStyleColor(); - if (ImGui::Button("Modify", ImVec2(100, 0))) - doc->Dirty = true; - ImGui::SameLine(); - if (ImGui::Button("Save", ImVec2(100, 0))) - doc->DoSave(); - ImGui::ColorEdit3("color", &doc->Color.x); // Useful to test drag and drop and hold-dragged-to-open-tab behavior. - ImGui::PopID(); - } - - // Display context menu for the Document - static void DisplayContextMenu(MyDocument* doc) - { - if (!ImGui::BeginPopupContextItem()) - return; - - char buf[256]; - sprintf(buf, "Save %s", doc->Name); - if (ImGui::MenuItem(buf, "CTRL+S", false, doc->Open)) - doc->DoSave(); - if (ImGui::MenuItem("Close", "CTRL+W", false, doc->Open)) - doc->DoQueueClose(); - ImGui::EndPopup(); - } -}; - -struct ExampleAppDocuments -{ - ImVector Documents; - - ExampleAppDocuments() - { - Documents.push_back(MyDocument("Lettuce", true, ImVec4(0.4f, 0.8f, 0.4f, 1.0f))); - Documents.push_back(MyDocument("Eggplant", true, ImVec4(0.8f, 0.5f, 1.0f, 1.0f))); - Documents.push_back(MyDocument("Carrot", true, ImVec4(1.0f, 0.8f, 0.5f, 1.0f))); - Documents.push_back(MyDocument("Tomato", false, ImVec4(1.0f, 0.3f, 0.4f, 1.0f))); - Documents.push_back(MyDocument("A Rather Long Title", false)); - Documents.push_back(MyDocument("Some Document", false)); - } -}; - -// [Optional] Notify the system of Tabs/Windows closure that happened outside the regular tab interface. -// If a tab has been closed programmatically (aka closed from another source such as the Checkbox() in the demo, -// as opposed to clicking on the regular tab closing button) and stops being submitted, it will take a frame for -// the tab bar to notice its absence. During this frame there will be a gap in the tab bar, and if the tab that has -// disappeared was the selected one, the tab bar will report no selected tab during the frame. This will effectively -// give the impression of a flicker for one frame. -// We call SetTabItemClosed() to manually notify the Tab Bar or Docking system of removed tabs to avoid this glitch. -// Note that this completely optional, and only affect tab bars with the ImGuiTabBarFlags_Reorderable flag. -static void NotifyOfDocumentsClosedElsewhere(ExampleAppDocuments& app) -{ - for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++) - { - MyDocument* doc = &app.Documents[doc_n]; - if (!doc->Open && doc->OpenPrev) - ImGui::SetTabItemClosed(doc->Name); - doc->OpenPrev = doc->Open; - } -} - -void ShowExampleAppDocuments(bool* p_open) -{ - static ExampleAppDocuments app; - - // Options - static bool opt_reorderable = true; - static ImGuiTabBarFlags opt_fitting_flags = ImGuiTabBarFlags_FittingPolicyDefault_; - - bool window_contents_visible = ImGui::Begin("Example: Documents", p_open, ImGuiWindowFlags_MenuBar); - if (!window_contents_visible) - { - ImGui::End(); - return; - } - - // Menu - if (ImGui::BeginMenuBar()) - { - if (ImGui::BeginMenu("File")) - { - int open_count = 0; - for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++) - open_count += app.Documents[doc_n].Open ? 1 : 0; - - if (ImGui::BeginMenu("Open", open_count < app.Documents.Size)) - { - for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++) - { - MyDocument* doc = &app.Documents[doc_n]; - if (!doc->Open) - if (ImGui::MenuItem(doc->Name)) - doc->DoOpen(); - } - ImGui::EndMenu(); - } - if (ImGui::MenuItem("Close All Documents", NULL, false, open_count > 0)) - for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++) - app.Documents[doc_n].DoQueueClose(); - if (ImGui::MenuItem("Exit", "Alt+F4")) {} - ImGui::EndMenu(); - } - ImGui::EndMenuBar(); - } - - // [Debug] List documents with one checkbox for each - for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++) - { - MyDocument* doc = &app.Documents[doc_n]; - if (doc_n > 0) - ImGui::SameLine(); - ImGui::PushID(doc); - if (ImGui::Checkbox(doc->Name, &doc->Open)) - if (!doc->Open) - doc->DoForceClose(); - ImGui::PopID(); - } - - ImGui::Separator(); - - // About the ImGuiWindowFlags_UnsavedDocument / ImGuiTabItemFlags_UnsavedDocument flags. - // They have multiple effects: - // - Display a dot next to the title. - // - Tab is selected when clicking the X close button. - // - Closure is not assumed (will wait for user to stop submitting the tab). - // Otherwise closure is assumed when pressing the X, so if you keep submitting the tab may reappear at end of tab bar. - // We need to assume closure by default otherwise waiting for "lack of submission" on the next frame would leave an empty - // hole for one-frame, both in the tab-bar and in tab-contents when closing a tab/window. - // The rarely used SetTabItemClosed() function is a way to notify of programmatic closure to avoid the one-frame hole. - - // Submit Tab Bar and Tabs - { - ImGuiTabBarFlags tab_bar_flags = (opt_fitting_flags) | (opt_reorderable ? ImGuiTabBarFlags_Reorderable : 0); - if (ImGui::BeginTabBar("##tabs", tab_bar_flags)) - { - if (opt_reorderable) - NotifyOfDocumentsClosedElsewhere(app); - - // [DEBUG] Stress tests - //if ((ImGui::GetFrameCount() % 30) == 0) docs[1].Open ^= 1; // [DEBUG] Automatically show/hide a tab. Test various interactions e.g. dragging with this on. - //if (ImGui::GetIO().KeyCtrl) ImGui::SetTabItemSelected(docs[1].Name); // [DEBUG] Test SetTabItemSelected(), probably not very useful as-is anyway.. - - // Submit Tabs - for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++) - { - MyDocument* doc = &app.Documents[doc_n]; - if (!doc->Open) - continue; - - ImGuiTabItemFlags tab_flags = (doc->Dirty ? ImGuiTabItemFlags_UnsavedDocument : 0); - bool visible = ImGui::BeginTabItem(doc->Name, &doc->Open, tab_flags); - - // Cancel attempt to close when unsaved add to save queue so we can display a popup. - if (!doc->Open && doc->Dirty) - { - doc->Open = true; - doc->DoQueueClose(); - } - - MyDocument::DisplayContextMenu(doc); - if (visible) - { - MyDocument::DisplayContents(doc); - ImGui::EndTabItem(); - } - } - - ImGui::EndTabBar(); - } - } - - // Update closing queue - static ImVector close_queue; - if (close_queue.empty()) - { - // Close queue is locked once we started a popup - for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++) - { - MyDocument* doc = &app.Documents[doc_n]; - if (doc->WantClose) - { - doc->WantClose = false; - close_queue.push_back(doc); - } - } - } - - // Display closing confirmation UI - if (!close_queue.empty()) - { - int close_queue_unsaved_documents = 0; - for (int n = 0; n < close_queue.Size; n++) - if (close_queue[n]->Dirty) - close_queue_unsaved_documents++; - - if (close_queue_unsaved_documents == 0) - { - // Close documents when all are unsaved - for (int n = 0; n < close_queue.Size; n++) - close_queue[n]->DoForceClose(); - close_queue.clear(); - } - else - { - if (!ImGui::IsPopupOpen("Save?")) - ImGui::OpenPopup("Save?"); - if (ImGui::BeginPopupModal("Save?", NULL, ImGuiWindowFlags_AlwaysAutoResize)) - { - ImGui::Text("Save change to the following items?"); - float item_height = ImGui::GetTextLineHeightWithSpacing(); - if (ImGui::BeginChildFrame(ImGui::GetID("frame"), ImVec2(-FLT_MIN, 6.25f * item_height))) - { - for (int n = 0; n < close_queue.Size; n++) - if (close_queue[n]->Dirty) - ImGui::Text("%s", close_queue[n]->Name); - ImGui::EndChildFrame(); - } - - ImVec2 button_size(ImGui::GetFontSize() * 7.0f, 0.0f); - if (ImGui::Button("Yes", button_size)) - { - for (int n = 0; n < close_queue.Size; n++) - { - if (close_queue[n]->Dirty) - close_queue[n]->DoSave(); - close_queue[n]->DoForceClose(); - } - close_queue.clear(); - ImGui::CloseCurrentPopup(); - } - ImGui::SameLine(); - if (ImGui::Button("No", button_size)) - { - for (int n = 0; n < close_queue.Size; n++) - close_queue[n]->DoForceClose(); - close_queue.clear(); - ImGui::CloseCurrentPopup(); - } - ImGui::SameLine(); - if (ImGui::Button("Cancel", button_size)) - { - close_queue.clear(); - ImGui::CloseCurrentPopup(); - } - ImGui::EndPopup(); - } - } - } - - ImGui::End(); -} - -// End of Demo code -#else - -void ImGui::ShowAboutWindow(bool*) {} -void ImGui::ShowDemoWindow(bool*) {} -void ImGui::ShowUserGuide() {} -void ImGui::ShowStyleEditor(ImGuiStyle*) {} - -#endif - -#endif // #ifndef IMGUI_DISABLE diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imgui_draw.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imgui_draw.cpp deleted file mode 100644 index 30b100b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imgui_draw.cpp +++ /dev/null @@ -1,4177 +0,0 @@ -// dear imgui, v1.85 -// (drawing and font code) - -/* - -Index of this file: - -// [SECTION] STB libraries implementation -// [SECTION] Style functions -// [SECTION] ImDrawList -// [SECTION] ImDrawListSplitter -// [SECTION] ImDrawData -// [SECTION] Helpers ShadeVertsXXX functions -// [SECTION] ImFontConfig -// [SECTION] ImFontAtlas -// [SECTION] ImFontAtlas glyph ranges helpers -// [SECTION] ImFontGlyphRangesBuilder -// [SECTION] ImFont -// [SECTION] ImGui Internal Render Helpers -// [SECTION] Decompression code -// [SECTION] Default font data (ProggyClean.ttf) - -*/ - -#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) -#define _CRT_SECURE_NO_WARNINGS -#endif - -#include "imgui.h" -#ifndef IMGUI_DISABLE - -#ifndef IMGUI_DEFINE_MATH_OPERATORS -#define IMGUI_DEFINE_MATH_OPERATORS -#endif - -#include "imgui_internal.h" -#ifdef IMGUI_ENABLE_FREETYPE -#include "misc/freetype/imgui_freetype.h" -#endif - -#include // vsnprintf, sscanf, printf -#if !defined(alloca) -#if defined(__GLIBC__) || defined(__sun) || defined(__APPLE__) || defined(__NEWLIB__) -#include // alloca (glibc uses . Note that Cygwin may have _WIN32 defined, so the order matters here) -#elif defined(_WIN32) -#include // alloca -#if !defined(alloca) -#define alloca _alloca // for clang with MS Codegen -#endif -#else -#include // alloca -#endif -#endif - -// Visual Studio warnings -#ifdef _MSC_VER -#pragma warning (disable: 4127) // condition expression is constant -#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff) -#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen -#pragma warning (disable: 6255) // [Static Analyzer] _alloca indicates failure by raising a stack overflow exception. Consider using _malloca instead. -#pragma warning (disable: 26451) // [Static Analyzer] Arithmetic overflow : Using operator 'xxx' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator 'xxx' to avoid overflow(io.2). -#pragma warning (disable: 26812) // [Static Analyzer] The enum type 'xxx' is unscoped. Prefer 'enum class' over 'enum' (Enum.3). [MSVC Static Analyzer) -#endif - -// Clang/GCC warnings with -Weverything -#if defined(__clang__) -#if __has_warning("-Wunknown-warning-option") -#pragma clang diagnostic ignored "-Wunknown-warning-option" // warning: unknown warning group 'xxx' // not all warnings are known by all Clang versions and they tend to be rename-happy.. so ignoring warnings triggers new warnings on some configuration. Great! -#endif -#if __has_warning("-Walloca") -#pragma clang diagnostic ignored "-Walloca" // warning: use of function '__builtin_alloca' is discouraged -#endif -#pragma clang diagnostic ignored "-Wunknown-pragmas" // warning: unknown warning group 'xxx' -#pragma clang diagnostic ignored "-Wold-style-cast" // warning: use of old-style cast // yes, they are more terse. -#pragma clang diagnostic ignored "-Wfloat-equal" // warning: comparing floating point with == or != is unsafe // storing and comparing against same constants ok. -#pragma clang diagnostic ignored "-Wglobal-constructors" // warning: declaration requires a global destructor // similar to above, not sure what the exact difference is. -#pragma clang diagnostic ignored "-Wsign-conversion" // warning: implicit conversion changes signedness -#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" // warning: zero as null pointer constant // some standard header variations use #define NULL 0 -#pragma clang diagnostic ignored "-Wcomma" // warning: possible misuse of comma operator here -#pragma clang diagnostic ignored "-Wreserved-id-macro" // warning: macro name is a reserved identifier -#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double. -#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision -#elif defined(__GNUC__) -#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind -#pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used -#pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function -#pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value -#pragma GCC diagnostic ignored "-Wstack-protector" // warning: stack protector not protecting local variables: variable length buffer -#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead -#endif - -//------------------------------------------------------------------------- -// [SECTION] STB libraries implementation -//------------------------------------------------------------------------- - -// Compile time options: -//#define IMGUI_STB_NAMESPACE ImStb -//#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h" -//#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h" -//#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION -//#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION - -#ifdef IMGUI_STB_NAMESPACE -namespace IMGUI_STB_NAMESPACE -{ -#endif - -#ifdef _MSC_VER -#pragma warning (push) -#pragma warning (disable: 4456) // declaration of 'xx' hides previous local declaration -#pragma warning (disable: 6011) // (stb_rectpack) Dereferencing NULL pointer 'cur->next'. -#pragma warning (disable: 6385) // (stb_truetype) Reading invalid data from 'buffer': the readable size is '_Old_3`kernel_width' bytes, but '3' bytes may be read. -#pragma warning (disable: 28182) // (stb_rectpack) Dereferencing NULL pointer. 'cur' contains the same NULL value as 'cur->next' did. -#endif - -#if defined(__clang__) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunused-function" -#pragma clang diagnostic ignored "-Wmissing-prototypes" -#pragma clang diagnostic ignored "-Wimplicit-fallthrough" -#pragma clang diagnostic ignored "-Wcast-qual" // warning: cast from 'const xxxx *' to 'xxx *' drops const qualifier -#endif - -#if defined(__GNUC__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wtype-limits" // warning: comparison is always true due to limited range of data type [-Wtype-limits] -#pragma GCC diagnostic ignored "-Wcast-qual" // warning: cast from type 'const xxxx *' to type 'xxxx *' casts away qualifiers -#endif - -#ifndef STB_RECT_PACK_IMPLEMENTATION // in case the user already have an implementation in the _same_ compilation unit (e.g. unity builds) -#ifndef IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION // in case the user already have an implementation in another compilation unit -#define STBRP_STATIC -#define STBRP_ASSERT(x) do { IM_ASSERT(x); } while (0) -#define STBRP_SORT ImQsort -#define STB_RECT_PACK_IMPLEMENTATION -#endif -#ifdef IMGUI_STB_RECT_PACK_FILENAME -#include IMGUI_STB_RECT_PACK_FILENAME -#else -#include "imstb_rectpack.h" -#endif -#endif - -#ifdef IMGUI_ENABLE_STB_TRUETYPE -#ifndef STB_TRUETYPE_IMPLEMENTATION // in case the user already have an implementation in the _same_ compilation unit (e.g. unity builds) -#ifndef IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION // in case the user already have an implementation in another compilation unit -#define STBTT_malloc(x,u) ((void)(u), IM_ALLOC(x)) -#define STBTT_free(x,u) ((void)(u), IM_FREE(x)) -#define STBTT_assert(x) do { IM_ASSERT(x); } while(0) -#define STBTT_fmod(x,y) ImFmod(x,y) -#define STBTT_sqrt(x) ImSqrt(x) -#define STBTT_pow(x,y) ImPow(x,y) -#define STBTT_fabs(x) ImFabs(x) -#define STBTT_ifloor(x) ((int)ImFloorSigned(x)) -#define STBTT_iceil(x) ((int)ImCeil(x)) -#define STBTT_STATIC -#define STB_TRUETYPE_IMPLEMENTATION -#else -#define STBTT_DEF extern -#endif -#ifdef IMGUI_STB_TRUETYPE_FILENAME -#include IMGUI_STB_TRUETYPE_FILENAME -#else -#include "imstb_truetype.h" -#endif -#endif -#endif // IMGUI_ENABLE_STB_TRUETYPE - -#if defined(__GNUC__) -#pragma GCC diagnostic pop -#endif - -#if defined(__clang__) -#pragma clang diagnostic pop -#endif - -#if defined(_MSC_VER) -#pragma warning (pop) -#endif - -#ifdef IMGUI_STB_NAMESPACE -} // namespace ImStb -using namespace IMGUI_STB_NAMESPACE; -#endif - -//----------------------------------------------------------------------------- -// [SECTION] Style functions -//----------------------------------------------------------------------------- - -void ImGui::StyleColorsDark(ImGuiStyle* dst) -{ - ImGuiStyle* style = dst ? dst : &ImGui::GetStyle(); - ImVec4* colors = style->Colors; - - colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); - colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f); - colors[ImGuiCol_WindowBg] = ImVec4(0.06f, 0.06f, 0.06f, 0.94f); - colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); - colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f); - colors[ImGuiCol_Border] = ImVec4(0.43f, 0.43f, 0.50f, 0.50f); - colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); - colors[ImGuiCol_FrameBg] = ImVec4(0.16f, 0.29f, 0.48f, 0.54f); - colors[ImGuiCol_FrameBgHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f); - colors[ImGuiCol_FrameBgActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); - colors[ImGuiCol_TitleBg] = ImVec4(0.04f, 0.04f, 0.04f, 1.00f); - colors[ImGuiCol_TitleBgActive] = ImVec4(0.16f, 0.29f, 0.48f, 1.00f); - colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f); - colors[ImGuiCol_MenuBarBg] = ImVec4(0.14f, 0.14f, 0.14f, 1.00f); - colors[ImGuiCol_ScrollbarBg] = ImVec4(0.02f, 0.02f, 0.02f, 0.53f); - colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.31f, 0.31f, 0.31f, 1.00f); - colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.41f, 0.41f, 0.41f, 1.00f); - colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.51f, 0.51f, 0.51f, 1.00f); - colors[ImGuiCol_CheckMark] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); - colors[ImGuiCol_SliderGrab] = ImVec4(0.24f, 0.52f, 0.88f, 1.00f); - colors[ImGuiCol_SliderGrabActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); - colors[ImGuiCol_Button] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f); - colors[ImGuiCol_ButtonHovered] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); - colors[ImGuiCol_ButtonActive] = ImVec4(0.06f, 0.53f, 0.98f, 1.00f); - colors[ImGuiCol_Header] = ImVec4(0.26f, 0.59f, 0.98f, 0.31f); - colors[ImGuiCol_HeaderHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f); - colors[ImGuiCol_HeaderActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); - colors[ImGuiCol_Separator] = colors[ImGuiCol_Border]; - colors[ImGuiCol_SeparatorHovered] = ImVec4(0.10f, 0.40f, 0.75f, 0.78f); - colors[ImGuiCol_SeparatorActive] = ImVec4(0.10f, 0.40f, 0.75f, 1.00f); - colors[ImGuiCol_ResizeGrip] = ImVec4(0.26f, 0.59f, 0.98f, 0.20f); - colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); - colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f); - colors[ImGuiCol_Tab] = ImLerp(colors[ImGuiCol_Header], colors[ImGuiCol_TitleBgActive], 0.80f); - colors[ImGuiCol_TabHovered] = colors[ImGuiCol_HeaderHovered]; - colors[ImGuiCol_TabActive] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f); - colors[ImGuiCol_TabUnfocused] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f); - colors[ImGuiCol_TabUnfocusedActive] = ImLerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f); - colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f); - colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); - colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); - colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f); - colors[ImGuiCol_TableHeaderBg] = ImVec4(0.19f, 0.19f, 0.20f, 1.00f); - colors[ImGuiCol_TableBorderStrong] = ImVec4(0.31f, 0.31f, 0.35f, 1.00f); // Prefer using Alpha=1.0 here - colors[ImGuiCol_TableBorderLight] = ImVec4(0.23f, 0.23f, 0.25f, 1.00f); // Prefer using Alpha=1.0 here - colors[ImGuiCol_TableRowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); - colors[ImGuiCol_TableRowBgAlt] = ImVec4(1.00f, 1.00f, 1.00f, 0.06f); - colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f); - colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f); - colors[ImGuiCol_NavHighlight] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); - colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f); - colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f); - colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f); -} - -void ImGui::StyleColorsClassic(ImGuiStyle* dst) -{ - ImGuiStyle* style = dst ? dst : &ImGui::GetStyle(); - ImVec4* colors = style->Colors; - - colors[ImGuiCol_Text] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f); - colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f); - colors[ImGuiCol_WindowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.85f); - colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); - colors[ImGuiCol_PopupBg] = ImVec4(0.11f, 0.11f, 0.14f, 0.92f); - colors[ImGuiCol_Border] = ImVec4(0.50f, 0.50f, 0.50f, 0.50f); - colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); - colors[ImGuiCol_FrameBg] = ImVec4(0.43f, 0.43f, 0.43f, 0.39f); - colors[ImGuiCol_FrameBgHovered] = ImVec4(0.47f, 0.47f, 0.69f, 0.40f); - colors[ImGuiCol_FrameBgActive] = ImVec4(0.42f, 0.41f, 0.64f, 0.69f); - colors[ImGuiCol_TitleBg] = ImVec4(0.27f, 0.27f, 0.54f, 0.83f); - colors[ImGuiCol_TitleBgActive] = ImVec4(0.32f, 0.32f, 0.63f, 0.87f); - colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.40f, 0.40f, 0.80f, 0.20f); - colors[ImGuiCol_MenuBarBg] = ImVec4(0.40f, 0.40f, 0.55f, 0.80f); - colors[ImGuiCol_ScrollbarBg] = ImVec4(0.20f, 0.25f, 0.30f, 0.60f); - colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.40f, 0.40f, 0.80f, 0.30f); - colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.40f, 0.40f, 0.80f, 0.40f); - colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.41f, 0.39f, 0.80f, 0.60f); - colors[ImGuiCol_CheckMark] = ImVec4(0.90f, 0.90f, 0.90f, 0.50f); - colors[ImGuiCol_SliderGrab] = ImVec4(1.00f, 1.00f, 1.00f, 0.30f); - colors[ImGuiCol_SliderGrabActive] = ImVec4(0.41f, 0.39f, 0.80f, 0.60f); - colors[ImGuiCol_Button] = ImVec4(0.35f, 0.40f, 0.61f, 0.62f); - colors[ImGuiCol_ButtonHovered] = ImVec4(0.40f, 0.48f, 0.71f, 0.79f); - colors[ImGuiCol_ButtonActive] = ImVec4(0.46f, 0.54f, 0.80f, 1.00f); - colors[ImGuiCol_Header] = ImVec4(0.40f, 0.40f, 0.90f, 0.45f); - colors[ImGuiCol_HeaderHovered] = ImVec4(0.45f, 0.45f, 0.90f, 0.80f); - colors[ImGuiCol_HeaderActive] = ImVec4(0.53f, 0.53f, 0.87f, 0.80f); - colors[ImGuiCol_Separator] = ImVec4(0.50f, 0.50f, 0.50f, 0.60f); - colors[ImGuiCol_SeparatorHovered] = ImVec4(0.60f, 0.60f, 0.70f, 1.00f); - colors[ImGuiCol_SeparatorActive] = ImVec4(0.70f, 0.70f, 0.90f, 1.00f); - colors[ImGuiCol_ResizeGrip] = ImVec4(1.00f, 1.00f, 1.00f, 0.10f); - colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.78f, 0.82f, 1.00f, 0.60f); - colors[ImGuiCol_ResizeGripActive] = ImVec4(0.78f, 0.82f, 1.00f, 0.90f); - colors[ImGuiCol_Tab] = ImLerp(colors[ImGuiCol_Header], colors[ImGuiCol_TitleBgActive], 0.80f); - colors[ImGuiCol_TabHovered] = colors[ImGuiCol_HeaderHovered]; - colors[ImGuiCol_TabActive] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f); - colors[ImGuiCol_TabUnfocused] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f); - colors[ImGuiCol_TabUnfocusedActive] = ImLerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f); - colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); - colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); - colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); - colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f); - colors[ImGuiCol_TableHeaderBg] = ImVec4(0.27f, 0.27f, 0.38f, 1.00f); - colors[ImGuiCol_TableBorderStrong] = ImVec4(0.31f, 0.31f, 0.45f, 1.00f); // Prefer using Alpha=1.0 here - colors[ImGuiCol_TableBorderLight] = ImVec4(0.26f, 0.26f, 0.28f, 1.00f); // Prefer using Alpha=1.0 here - colors[ImGuiCol_TableRowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); - colors[ImGuiCol_TableRowBgAlt] = ImVec4(1.00f, 1.00f, 1.00f, 0.07f); - colors[ImGuiCol_TextSelectedBg] = ImVec4(0.00f, 0.00f, 1.00f, 0.35f); - colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f); - colors[ImGuiCol_NavHighlight] = colors[ImGuiCol_HeaderHovered]; - colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f); - colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f); - colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f); -} - -// Those light colors are better suited with a thicker font than the default one + FrameBorder -void ImGui::StyleColorsLight(ImGuiStyle* dst) -{ - ImGuiStyle* style = dst ? dst : &ImGui::GetStyle(); - ImVec4* colors = style->Colors; - - colors[ImGuiCol_Text] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f); - colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f); - colors[ImGuiCol_WindowBg] = ImVec4(0.94f, 0.94f, 0.94f, 1.00f); - colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); - colors[ImGuiCol_PopupBg] = ImVec4(1.00f, 1.00f, 1.00f, 0.98f); - colors[ImGuiCol_Border] = ImVec4(0.00f, 0.00f, 0.00f, 0.30f); - colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); - colors[ImGuiCol_FrameBg] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f); - colors[ImGuiCol_FrameBgHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f); - colors[ImGuiCol_FrameBgActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); - colors[ImGuiCol_TitleBg] = ImVec4(0.96f, 0.96f, 0.96f, 1.00f); - colors[ImGuiCol_TitleBgActive] = ImVec4(0.82f, 0.82f, 0.82f, 1.00f); - colors[ImGuiCol_TitleBgCollapsed] = ImVec4(1.00f, 1.00f, 1.00f, 0.51f); - colors[ImGuiCol_MenuBarBg] = ImVec4(0.86f, 0.86f, 0.86f, 1.00f); - colors[ImGuiCol_ScrollbarBg] = ImVec4(0.98f, 0.98f, 0.98f, 0.53f); - colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.69f, 0.69f, 0.69f, 0.80f); - colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.49f, 0.49f, 0.49f, 0.80f); - colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.49f, 0.49f, 0.49f, 1.00f); - colors[ImGuiCol_CheckMark] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); - colors[ImGuiCol_SliderGrab] = ImVec4(0.26f, 0.59f, 0.98f, 0.78f); - colors[ImGuiCol_SliderGrabActive] = ImVec4(0.46f, 0.54f, 0.80f, 0.60f); - colors[ImGuiCol_Button] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f); - colors[ImGuiCol_ButtonHovered] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); - colors[ImGuiCol_ButtonActive] = ImVec4(0.06f, 0.53f, 0.98f, 1.00f); - colors[ImGuiCol_Header] = ImVec4(0.26f, 0.59f, 0.98f, 0.31f); - colors[ImGuiCol_HeaderHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f); - colors[ImGuiCol_HeaderActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); - colors[ImGuiCol_Separator] = ImVec4(0.39f, 0.39f, 0.39f, 0.62f); - colors[ImGuiCol_SeparatorHovered] = ImVec4(0.14f, 0.44f, 0.80f, 0.78f); - colors[ImGuiCol_SeparatorActive] = ImVec4(0.14f, 0.44f, 0.80f, 1.00f); - colors[ImGuiCol_ResizeGrip] = ImVec4(0.35f, 0.35f, 0.35f, 0.17f); - colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); - colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f); - colors[ImGuiCol_Tab] = ImLerp(colors[ImGuiCol_Header], colors[ImGuiCol_TitleBgActive], 0.90f); - colors[ImGuiCol_TabHovered] = colors[ImGuiCol_HeaderHovered]; - colors[ImGuiCol_TabActive] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f); - colors[ImGuiCol_TabUnfocused] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f); - colors[ImGuiCol_TabUnfocusedActive] = ImLerp(colors[ImGuiCol_TabActive], colors[ImGuiCol_TitleBg], 0.40f); - colors[ImGuiCol_PlotLines] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f); - colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); - colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); - colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.45f, 0.00f, 1.00f); - colors[ImGuiCol_TableHeaderBg] = ImVec4(0.78f, 0.87f, 0.98f, 1.00f); - colors[ImGuiCol_TableBorderStrong] = ImVec4(0.57f, 0.57f, 0.64f, 1.00f); // Prefer using Alpha=1.0 here - colors[ImGuiCol_TableBorderLight] = ImVec4(0.68f, 0.68f, 0.74f, 1.00f); // Prefer using Alpha=1.0 here - colors[ImGuiCol_TableRowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); - colors[ImGuiCol_TableRowBgAlt] = ImVec4(0.30f, 0.30f, 0.30f, 0.09f); - colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f); - colors[ImGuiCol_DragDropTarget] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f); - colors[ImGuiCol_NavHighlight] = colors[ImGuiCol_HeaderHovered]; - colors[ImGuiCol_NavWindowingHighlight] = ImVec4(0.70f, 0.70f, 0.70f, 0.70f); - colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.20f); - colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f); -} - -//----------------------------------------------------------------------------- -// [SECTION] ImDrawList -//----------------------------------------------------------------------------- - -ImDrawListSharedData::ImDrawListSharedData() -{ - memset(this, 0, sizeof(*this)); - for (int i = 0; i < IM_ARRAYSIZE(ArcFastVtx); i++) - { - const float a = ((float)i * 2 * IM_PI) / (float)IM_ARRAYSIZE(ArcFastVtx); - ArcFastVtx[i] = ImVec2(ImCos(a), ImSin(a)); - } - ArcFastRadiusCutoff = IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC_R(IM_DRAWLIST_ARCFAST_SAMPLE_MAX, CircleSegmentMaxError); -} - -void ImDrawListSharedData::SetCircleTessellationMaxError(float max_error) -{ - if (CircleSegmentMaxError == max_error) - return; - - IM_ASSERT(max_error > 0.0f); - CircleSegmentMaxError = max_error; - for (int i = 0; i < IM_ARRAYSIZE(CircleSegmentCounts); i++) - { - const float radius = (float)i; - CircleSegmentCounts[i] = (ImU8)((i > 0) ? IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(radius, CircleSegmentMaxError) : 0); - } - ArcFastRadiusCutoff = IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC_R(IM_DRAWLIST_ARCFAST_SAMPLE_MAX, CircleSegmentMaxError); -} - -// Initialize before use in a new frame. We always have a command ready in the buffer. -void ImDrawList::_ResetForNewFrame() -{ - // Verify that the ImDrawCmd fields we want to memcmp() are contiguous in memory. - // (those should be IM_STATIC_ASSERT() in theory but with our pre C++11 setup the whole check doesn't compile with GCC) - IM_ASSERT(IM_OFFSETOF(ImDrawCmd, ClipRect) == 0); - IM_ASSERT(IM_OFFSETOF(ImDrawCmd, TextureId) == sizeof(ImVec4)); - IM_ASSERT(IM_OFFSETOF(ImDrawCmd, VtxOffset) == sizeof(ImVec4) + sizeof(ImTextureID)); - - CmdBuffer.resize(0); - IdxBuffer.resize(0); - VtxBuffer.resize(0); - Flags = _Data->InitialFlags; - memset(&_CmdHeader, 0, sizeof(_CmdHeader)); - _VtxCurrentIdx = 0; - _VtxWritePtr = NULL; - _IdxWritePtr = NULL; - _ClipRectStack.resize(0); - _TextureIdStack.resize(0); - _Path.resize(0); - _Splitter.Clear(); - CmdBuffer.push_back(ImDrawCmd()); - _FringeScale = 1.0f; -} - -void ImDrawList::_ClearFreeMemory() -{ - CmdBuffer.clear(); - IdxBuffer.clear(); - VtxBuffer.clear(); - Flags = ImDrawListFlags_None; - _VtxCurrentIdx = 0; - _VtxWritePtr = NULL; - _IdxWritePtr = NULL; - _ClipRectStack.clear(); - _TextureIdStack.clear(); - _Path.clear(); - _Splitter.ClearFreeMemory(); -} - -ImDrawList* ImDrawList::CloneOutput() const -{ - ImDrawList* dst = IM_NEW(ImDrawList(_Data)); - dst->CmdBuffer = CmdBuffer; - dst->IdxBuffer = IdxBuffer; - dst->VtxBuffer = VtxBuffer; - dst->Flags = Flags; - return dst; -} - -void ImDrawList::AddDrawCmd() -{ - ImDrawCmd draw_cmd; - draw_cmd.ClipRect = _CmdHeader.ClipRect; // Same as calling ImDrawCmd_HeaderCopy() - draw_cmd.TextureId = _CmdHeader.TextureId; - draw_cmd.VtxOffset = _CmdHeader.VtxOffset; - draw_cmd.IdxOffset = IdxBuffer.Size; - - IM_ASSERT(draw_cmd.ClipRect.x <= draw_cmd.ClipRect.z && draw_cmd.ClipRect.y <= draw_cmd.ClipRect.w); - CmdBuffer.push_back(draw_cmd); -} - -// Pop trailing draw command (used before merging or presenting to user) -// Note that this leaves the ImDrawList in a state unfit for further commands, as most code assume that CmdBuffer.Size > 0 && CmdBuffer.back().UserCallback == NULL -void ImDrawList::_PopUnusedDrawCmd() -{ - if (CmdBuffer.Size == 0) - return; - ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1]; - if (curr_cmd->ElemCount == 0 && curr_cmd->UserCallback == NULL) - CmdBuffer.pop_back(); -} - -void ImDrawList::AddCallback(ImDrawCallback callback, void* callback_data) -{ - ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1]; - IM_ASSERT(curr_cmd->UserCallback == NULL); - if (curr_cmd->ElemCount != 0) - { - AddDrawCmd(); - curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1]; - } - curr_cmd->UserCallback = callback; - curr_cmd->UserCallbackData = callback_data; - - AddDrawCmd(); // Force a new command after us (see comment below) -} - -// Compare ClipRect, TextureId and VtxOffset with a single memcmp() -#define ImDrawCmd_HeaderSize (IM_OFFSETOF(ImDrawCmd, VtxOffset) + sizeof(unsigned int)) -#define ImDrawCmd_HeaderCompare(CMD_LHS, CMD_RHS) (memcmp(CMD_LHS, CMD_RHS, ImDrawCmd_HeaderSize)) // Compare ClipRect, TextureId, VtxOffset -#define ImDrawCmd_HeaderCopy(CMD_DST, CMD_SRC) (memcpy(CMD_DST, CMD_SRC, ImDrawCmd_HeaderSize)) // Copy ClipRect, TextureId, VtxOffset - -// Try to merge two last draw commands -void ImDrawList::_TryMergeDrawCmds() -{ - ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1]; - ImDrawCmd* prev_cmd = curr_cmd - 1; - if (ImDrawCmd_HeaderCompare(curr_cmd, prev_cmd) == 0 && curr_cmd->UserCallback == NULL && prev_cmd->UserCallback == NULL) - { - prev_cmd->ElemCount += curr_cmd->ElemCount; - CmdBuffer.pop_back(); - } -} - -// Our scheme may appears a bit unusual, basically we want the most-common calls AddLine AddRect etc. to not have to perform any check so we always have a command ready in the stack. -// The cost of figuring out if a new command has to be added or if we can merge is paid in those Update** functions only. -void ImDrawList::_OnChangedClipRect() -{ - // If current command is used with different settings we need to add a new command - ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1]; - if (curr_cmd->ElemCount != 0 && memcmp(&curr_cmd->ClipRect, &_CmdHeader.ClipRect, sizeof(ImVec4)) != 0) - { - AddDrawCmd(); - return; - } - IM_ASSERT(curr_cmd->UserCallback == NULL); - - // Try to merge with previous command if it matches, else use current command - ImDrawCmd* prev_cmd = curr_cmd - 1; - if (curr_cmd->ElemCount == 0 && CmdBuffer.Size > 1 && ImDrawCmd_HeaderCompare(&_CmdHeader, prev_cmd) == 0 && prev_cmd->UserCallback == NULL) - { - CmdBuffer.pop_back(); - return; - } - - curr_cmd->ClipRect = _CmdHeader.ClipRect; -} - -void ImDrawList::_OnChangedTextureID() -{ - // If current command is used with different settings we need to add a new command - ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1]; - if (curr_cmd->ElemCount != 0 && curr_cmd->TextureId != _CmdHeader.TextureId) - { - AddDrawCmd(); - return; - } - IM_ASSERT(curr_cmd->UserCallback == NULL); - - // Try to merge with previous command if it matches, else use current command - ImDrawCmd* prev_cmd = curr_cmd - 1; - if (curr_cmd->ElemCount == 0 && CmdBuffer.Size > 1 && ImDrawCmd_HeaderCompare(&_CmdHeader, prev_cmd) == 0 && prev_cmd->UserCallback == NULL) - { - CmdBuffer.pop_back(); - return; - } - - curr_cmd->TextureId = _CmdHeader.TextureId; -} - -void ImDrawList::_OnChangedVtxOffset() -{ - // We don't need to compare curr_cmd->VtxOffset != _CmdHeader.VtxOffset because we know it'll be different at the time we call this. - _VtxCurrentIdx = 0; - ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1]; - //IM_ASSERT(curr_cmd->VtxOffset != _CmdHeader.VtxOffset); // See #3349 - if (curr_cmd->ElemCount != 0) - { - AddDrawCmd(); - return; - } - IM_ASSERT(curr_cmd->UserCallback == NULL); - curr_cmd->VtxOffset = _CmdHeader.VtxOffset; -} - -int ImDrawList::_CalcCircleAutoSegmentCount(float radius) const -{ - // Automatic segment count - const int radius_idx = (int)(radius + 0.999999f); // ceil to never reduce accuracy - if (radius_idx < IM_ARRAYSIZE(_Data->CircleSegmentCounts)) - return _Data->CircleSegmentCounts[radius_idx]; // Use cached value - else - return IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(radius, _Data->CircleSegmentMaxError); -} - -// Render-level scissoring. This is passed down to your render function but not used for CPU-side coarse clipping. Prefer using higher-level ImGui::PushClipRect() to affect logic (hit-testing and widget culling) -void ImDrawList::PushClipRect(ImVec2 cr_min, ImVec2 cr_max, bool intersect_with_current_clip_rect) -{ - ImVec4 cr(cr_min.x, cr_min.y, cr_max.x, cr_max.y); - if (intersect_with_current_clip_rect) - { - ImVec4 current = _CmdHeader.ClipRect; - if (cr.x < current.x) cr.x = current.x; - if (cr.y < current.y) cr.y = current.y; - if (cr.z > current.z) cr.z = current.z; - if (cr.w > current.w) cr.w = current.w; - } - cr.z = ImMax(cr.x, cr.z); - cr.w = ImMax(cr.y, cr.w); - - _ClipRectStack.push_back(cr); - _CmdHeader.ClipRect = cr; - _OnChangedClipRect(); -} - -void ImDrawList::PushClipRectFullScreen() -{ - PushClipRect(ImVec2(_Data->ClipRectFullscreen.x, _Data->ClipRectFullscreen.y), ImVec2(_Data->ClipRectFullscreen.z, _Data->ClipRectFullscreen.w)); -} - -void ImDrawList::PopClipRect() -{ - _ClipRectStack.pop_back(); - _CmdHeader.ClipRect = (_ClipRectStack.Size == 0) ? _Data->ClipRectFullscreen : _ClipRectStack.Data[_ClipRectStack.Size - 1]; - _OnChangedClipRect(); -} - -void ImDrawList::PushTextureID(ImTextureID texture_id) -{ - _TextureIdStack.push_back(texture_id); - _CmdHeader.TextureId = texture_id; - _OnChangedTextureID(); -} - -void ImDrawList::PopTextureID() -{ - _TextureIdStack.pop_back(); - _CmdHeader.TextureId = (_TextureIdStack.Size == 0) ? (ImTextureID)NULL : _TextureIdStack.Data[_TextureIdStack.Size - 1]; - _OnChangedTextureID(); -} - -// Reserve space for a number of vertices and indices. -// You must finish filling your reserved data before calling PrimReserve() again, as it may reallocate or -// submit the intermediate results. PrimUnreserve() can be used to release unused allocations. -void ImDrawList::PrimReserve(int idx_count, int vtx_count) -{ - // Large mesh support (when enabled) - IM_ASSERT_PARANOID(idx_count >= 0 && vtx_count >= 0); - if (sizeof(ImDrawIdx) == 2 && (_VtxCurrentIdx + vtx_count >= (1 << 16)) && (Flags & ImDrawListFlags_AllowVtxOffset)) - { - // FIXME: In theory we should be testing that vtx_count <64k here. - // In practice, RenderText() relies on reserving ahead for a worst case scenario so it is currently useful for us - // to not make that check until we rework the text functions to handle clipping and large horizontal lines better. - _CmdHeader.VtxOffset = VtxBuffer.Size; - _OnChangedVtxOffset(); - } - - ImDrawCmd* draw_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1]; - draw_cmd->ElemCount += idx_count; - - int vtx_buffer_old_size = VtxBuffer.Size; - VtxBuffer.resize(vtx_buffer_old_size + vtx_count); - _VtxWritePtr = VtxBuffer.Data + vtx_buffer_old_size; - - int idx_buffer_old_size = IdxBuffer.Size; - IdxBuffer.resize(idx_buffer_old_size + idx_count); - _IdxWritePtr = IdxBuffer.Data + idx_buffer_old_size; -} - -// Release the a number of reserved vertices/indices from the end of the last reservation made with PrimReserve(). -void ImDrawList::PrimUnreserve(int idx_count, int vtx_count) -{ - IM_ASSERT_PARANOID(idx_count >= 0 && vtx_count >= 0); - - ImDrawCmd* draw_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1]; - draw_cmd->ElemCount -= idx_count; - VtxBuffer.shrink(VtxBuffer.Size - vtx_count); - IdxBuffer.shrink(IdxBuffer.Size - idx_count); -} - -// Fully unrolled with inline call to keep our debug builds decently fast. -void ImDrawList::PrimRect(const ImVec2& a, const ImVec2& c, ImU32 col) -{ - ImVec2 b(c.x, a.y), d(a.x, c.y), uv(_Data->TexUvWhitePixel); - ImDrawIdx idx = (ImDrawIdx)_VtxCurrentIdx; - _IdxWritePtr[0] = idx; _IdxWritePtr[1] = (ImDrawIdx)(idx+1); _IdxWritePtr[2] = (ImDrawIdx)(idx+2); - _IdxWritePtr[3] = idx; _IdxWritePtr[4] = (ImDrawIdx)(idx+2); _IdxWritePtr[5] = (ImDrawIdx)(idx+3); - _VtxWritePtr[0].pos = a; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col; - _VtxWritePtr[1].pos = b; _VtxWritePtr[1].uv = uv; _VtxWritePtr[1].col = col; - _VtxWritePtr[2].pos = c; _VtxWritePtr[2].uv = uv; _VtxWritePtr[2].col = col; - _VtxWritePtr[3].pos = d; _VtxWritePtr[3].uv = uv; _VtxWritePtr[3].col = col; - _VtxWritePtr += 4; - _VtxCurrentIdx += 4; - _IdxWritePtr += 6; -} - -void ImDrawList::PrimRectUV(const ImVec2& a, const ImVec2& c, const ImVec2& uv_a, const ImVec2& uv_c, ImU32 col) -{ - ImVec2 b(c.x, a.y), d(a.x, c.y), uv_b(uv_c.x, uv_a.y), uv_d(uv_a.x, uv_c.y); - ImDrawIdx idx = (ImDrawIdx)_VtxCurrentIdx; - _IdxWritePtr[0] = idx; _IdxWritePtr[1] = (ImDrawIdx)(idx+1); _IdxWritePtr[2] = (ImDrawIdx)(idx+2); - _IdxWritePtr[3] = idx; _IdxWritePtr[4] = (ImDrawIdx)(idx+2); _IdxWritePtr[5] = (ImDrawIdx)(idx+3); - _VtxWritePtr[0].pos = a; _VtxWritePtr[0].uv = uv_a; _VtxWritePtr[0].col = col; - _VtxWritePtr[1].pos = b; _VtxWritePtr[1].uv = uv_b; _VtxWritePtr[1].col = col; - _VtxWritePtr[2].pos = c; _VtxWritePtr[2].uv = uv_c; _VtxWritePtr[2].col = col; - _VtxWritePtr[3].pos = d; _VtxWritePtr[3].uv = uv_d; _VtxWritePtr[3].col = col; - _VtxWritePtr += 4; - _VtxCurrentIdx += 4; - _IdxWritePtr += 6; -} - -void ImDrawList::PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a, const ImVec2& uv_b, const ImVec2& uv_c, const ImVec2& uv_d, ImU32 col) -{ - ImDrawIdx idx = (ImDrawIdx)_VtxCurrentIdx; - _IdxWritePtr[0] = idx; _IdxWritePtr[1] = (ImDrawIdx)(idx+1); _IdxWritePtr[2] = (ImDrawIdx)(idx+2); - _IdxWritePtr[3] = idx; _IdxWritePtr[4] = (ImDrawIdx)(idx+2); _IdxWritePtr[5] = (ImDrawIdx)(idx+3); - _VtxWritePtr[0].pos = a; _VtxWritePtr[0].uv = uv_a; _VtxWritePtr[0].col = col; - _VtxWritePtr[1].pos = b; _VtxWritePtr[1].uv = uv_b; _VtxWritePtr[1].col = col; - _VtxWritePtr[2].pos = c; _VtxWritePtr[2].uv = uv_c; _VtxWritePtr[2].col = col; - _VtxWritePtr[3].pos = d; _VtxWritePtr[3].uv = uv_d; _VtxWritePtr[3].col = col; - _VtxWritePtr += 4; - _VtxCurrentIdx += 4; - _IdxWritePtr += 6; -} - -// On AddPolyline() and AddConvexPolyFilled() we intentionally avoid using ImVec2 and superfluous function calls to optimize debug/non-inlined builds. -// - Those macros expects l-values and need to be used as their own statement. -// - Those macros are intentionally not surrounded by the 'do {} while (0)' idiom because even that translates to runtime with debug compilers. -#define IM_NORMALIZE2F_OVER_ZERO(VX,VY) { float d2 = VX*VX + VY*VY; if (d2 > 0.0f) { float inv_len = ImRsqrt(d2); VX *= inv_len; VY *= inv_len; } } (void)0 -#define IM_FIXNORMAL2F_MAX_INVLEN2 100.0f // 500.0f (see #4053, #3366) -#define IM_FIXNORMAL2F(VX,VY) { float d2 = VX*VX + VY*VY; if (d2 > 0.000001f) { float inv_len2 = 1.0f / d2; if (inv_len2 > IM_FIXNORMAL2F_MAX_INVLEN2) inv_len2 = IM_FIXNORMAL2F_MAX_INVLEN2; VX *= inv_len2; VY *= inv_len2; } } (void)0 - -// TODO: Thickness anti-aliased lines cap are missing their AA fringe. -// We avoid using the ImVec2 math operators here to reduce cost to a minimum for debug/non-inlined builds. -void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32 col, ImDrawFlags flags, float thickness) -{ - if (points_count < 2) - return; - - const bool closed = (flags & ImDrawFlags_Closed) != 0; - const ImVec2 opaque_uv = _Data->TexUvWhitePixel; - const int count = closed ? points_count : points_count - 1; // The number of line segments we need to draw - const bool thick_line = (thickness > _FringeScale); - - if (Flags & ImDrawListFlags_AntiAliasedLines) - { - // Anti-aliased stroke - const float AA_SIZE = _FringeScale; - const ImU32 col_trans = col & ~IM_COL32_A_MASK; - - // Thicknesses <1.0 should behave like thickness 1.0 - thickness = ImMax(thickness, 1.0f); - const int integer_thickness = (int)thickness; - const float fractional_thickness = thickness - integer_thickness; - - // Do we want to draw this line using a texture? - // - For now, only draw integer-width lines using textures to avoid issues with the way scaling occurs, could be improved. - // - If AA_SIZE is not 1.0f we cannot use the texture path. - const bool use_texture = (Flags & ImDrawListFlags_AntiAliasedLinesUseTex) && (integer_thickness < IM_DRAWLIST_TEX_LINES_WIDTH_MAX) && (fractional_thickness <= 0.00001f) && (AA_SIZE == 1.0f); - - // We should never hit this, because NewFrame() doesn't set ImDrawListFlags_AntiAliasedLinesUseTex unless ImFontAtlasFlags_NoBakedLines is off - IM_ASSERT_PARANOID(!use_texture || !(_Data->Font->ContainerAtlas->Flags & ImFontAtlasFlags_NoBakedLines)); - - const int idx_count = use_texture ? (count * 6) : (thick_line ? count * 18 : count * 12); - const int vtx_count = use_texture ? (points_count * 2) : (thick_line ? points_count * 4 : points_count * 3); - PrimReserve(idx_count, vtx_count); - - // Temporary buffer - // The first items are normals at each line point, then after that there are either 2 or 4 temp points for each line point - ImVec2* temp_normals = (ImVec2*)alloca(points_count * ((use_texture || !thick_line) ? 3 : 5) * sizeof(ImVec2)); //-V630 - ImVec2* temp_points = temp_normals + points_count; - - // Calculate normals (tangents) for each line segment - for (int i1 = 0; i1 < count; i1++) - { - const int i2 = (i1 + 1) == points_count ? 0 : i1 + 1; - float dx = points[i2].x - points[i1].x; - float dy = points[i2].y - points[i1].y; - IM_NORMALIZE2F_OVER_ZERO(dx, dy); - temp_normals[i1].x = dy; - temp_normals[i1].y = -dx; - } - if (!closed) - temp_normals[points_count - 1] = temp_normals[points_count - 2]; - - // If we are drawing a one-pixel-wide line without a texture, or a textured line of any width, we only need 2 or 3 vertices per point - if (use_texture || !thick_line) - { - // [PATH 1] Texture-based lines (thick or non-thick) - // [PATH 2] Non texture-based lines (non-thick) - - // The width of the geometry we need to draw - this is essentially pixels for the line itself, plus "one pixel" for AA. - // - In the texture-based path, we don't use AA_SIZE here because the +1 is tied to the generated texture - // (see ImFontAtlasBuildRenderLinesTexData() function), and so alternate values won't work without changes to that code. - // - In the non texture-based paths, we would allow AA_SIZE to potentially be != 1.0f with a patch (e.g. fringe_scale patch to - // allow scaling geometry while preserving one-screen-pixel AA fringe). - const float half_draw_size = use_texture ? ((thickness * 0.5f) + 1) : AA_SIZE; - - // If line is not closed, the first and last points need to be generated differently as there are no normals to blend - if (!closed) - { - temp_points[0] = points[0] + temp_normals[0] * half_draw_size; - temp_points[1] = points[0] - temp_normals[0] * half_draw_size; - temp_points[(points_count-1)*2+0] = points[points_count-1] + temp_normals[points_count-1] * half_draw_size; - temp_points[(points_count-1)*2+1] = points[points_count-1] - temp_normals[points_count-1] * half_draw_size; - } - - // Generate the indices to form a number of triangles for each line segment, and the vertices for the line edges - // This takes points n and n+1 and writes into n+1, with the first point in a closed line being generated from the final one (as n+1 wraps) - // FIXME-OPT: Merge the different loops, possibly remove the temporary buffer. - unsigned int idx1 = _VtxCurrentIdx; // Vertex index for start of line segment - for (int i1 = 0; i1 < count; i1++) // i1 is the first point of the line segment - { - const int i2 = (i1 + 1) == points_count ? 0 : i1 + 1; // i2 is the second point of the line segment - const unsigned int idx2 = ((i1 + 1) == points_count) ? _VtxCurrentIdx : (idx1 + (use_texture ? 2 : 3)); // Vertex index for end of segment - - // Average normals - float dm_x = (temp_normals[i1].x + temp_normals[i2].x) * 0.5f; - float dm_y = (temp_normals[i1].y + temp_normals[i2].y) * 0.5f; - IM_FIXNORMAL2F(dm_x, dm_y); - dm_x *= half_draw_size; // dm_x, dm_y are offset to the outer edge of the AA area - dm_y *= half_draw_size; - - // Add temporary vertexes for the outer edges - ImVec2* out_vtx = &temp_points[i2 * 2]; - out_vtx[0].x = points[i2].x + dm_x; - out_vtx[0].y = points[i2].y + dm_y; - out_vtx[1].x = points[i2].x - dm_x; - out_vtx[1].y = points[i2].y - dm_y; - - if (use_texture) - { - // Add indices for two triangles - _IdxWritePtr[0] = (ImDrawIdx)(idx2 + 0); _IdxWritePtr[1] = (ImDrawIdx)(idx1 + 0); _IdxWritePtr[2] = (ImDrawIdx)(idx1 + 1); // Right tri - _IdxWritePtr[3] = (ImDrawIdx)(idx2 + 1); _IdxWritePtr[4] = (ImDrawIdx)(idx1 + 1); _IdxWritePtr[5] = (ImDrawIdx)(idx2 + 0); // Left tri - _IdxWritePtr += 6; - } - else - { - // Add indexes for four triangles - _IdxWritePtr[0] = (ImDrawIdx)(idx2 + 0); _IdxWritePtr[1] = (ImDrawIdx)(idx1 + 0); _IdxWritePtr[2] = (ImDrawIdx)(idx1 + 2); // Right tri 1 - _IdxWritePtr[3] = (ImDrawIdx)(idx1 + 2); _IdxWritePtr[4] = (ImDrawIdx)(idx2 + 2); _IdxWritePtr[5] = (ImDrawIdx)(idx2 + 0); // Right tri 2 - _IdxWritePtr[6] = (ImDrawIdx)(idx2 + 1); _IdxWritePtr[7] = (ImDrawIdx)(idx1 + 1); _IdxWritePtr[8] = (ImDrawIdx)(idx1 + 0); // Left tri 1 - _IdxWritePtr[9] = (ImDrawIdx)(idx1 + 0); _IdxWritePtr[10] = (ImDrawIdx)(idx2 + 0); _IdxWritePtr[11] = (ImDrawIdx)(idx2 + 1); // Left tri 2 - _IdxWritePtr += 12; - } - - idx1 = idx2; - } - - // Add vertexes for each point on the line - if (use_texture) - { - // If we're using textures we only need to emit the left/right edge vertices - ImVec4 tex_uvs = _Data->TexUvLines[integer_thickness]; - /*if (fractional_thickness != 0.0f) // Currently always zero when use_texture==false! - { - const ImVec4 tex_uvs_1 = _Data->TexUvLines[integer_thickness + 1]; - tex_uvs.x = tex_uvs.x + (tex_uvs_1.x - tex_uvs.x) * fractional_thickness; // inlined ImLerp() - tex_uvs.y = tex_uvs.y + (tex_uvs_1.y - tex_uvs.y) * fractional_thickness; - tex_uvs.z = tex_uvs.z + (tex_uvs_1.z - tex_uvs.z) * fractional_thickness; - tex_uvs.w = tex_uvs.w + (tex_uvs_1.w - tex_uvs.w) * fractional_thickness; - }*/ - ImVec2 tex_uv0(tex_uvs.x, tex_uvs.y); - ImVec2 tex_uv1(tex_uvs.z, tex_uvs.w); - for (int i = 0; i < points_count; i++) - { - _VtxWritePtr[0].pos = temp_points[i * 2 + 0]; _VtxWritePtr[0].uv = tex_uv0; _VtxWritePtr[0].col = col; // Left-side outer edge - _VtxWritePtr[1].pos = temp_points[i * 2 + 1]; _VtxWritePtr[1].uv = tex_uv1; _VtxWritePtr[1].col = col; // Right-side outer edge - _VtxWritePtr += 2; - } - } - else - { - // If we're not using a texture, we need the center vertex as well - for (int i = 0; i < points_count; i++) - { - _VtxWritePtr[0].pos = points[i]; _VtxWritePtr[0].uv = opaque_uv; _VtxWritePtr[0].col = col; // Center of line - _VtxWritePtr[1].pos = temp_points[i * 2 + 0]; _VtxWritePtr[1].uv = opaque_uv; _VtxWritePtr[1].col = col_trans; // Left-side outer edge - _VtxWritePtr[2].pos = temp_points[i * 2 + 1]; _VtxWritePtr[2].uv = opaque_uv; _VtxWritePtr[2].col = col_trans; // Right-side outer edge - _VtxWritePtr += 3; - } - } - } - else - { - // [PATH 2] Non texture-based lines (thick): we need to draw the solid line core and thus require four vertices per point - const float half_inner_thickness = (thickness - AA_SIZE) * 0.5f; - - // If line is not closed, the first and last points need to be generated differently as there are no normals to blend - if (!closed) - { - const int points_last = points_count - 1; - temp_points[0] = points[0] + temp_normals[0] * (half_inner_thickness + AA_SIZE); - temp_points[1] = points[0] + temp_normals[0] * (half_inner_thickness); - temp_points[2] = points[0] - temp_normals[0] * (half_inner_thickness); - temp_points[3] = points[0] - temp_normals[0] * (half_inner_thickness + AA_SIZE); - temp_points[points_last * 4 + 0] = points[points_last] + temp_normals[points_last] * (half_inner_thickness + AA_SIZE); - temp_points[points_last * 4 + 1] = points[points_last] + temp_normals[points_last] * (half_inner_thickness); - temp_points[points_last * 4 + 2] = points[points_last] - temp_normals[points_last] * (half_inner_thickness); - temp_points[points_last * 4 + 3] = points[points_last] - temp_normals[points_last] * (half_inner_thickness + AA_SIZE); - } - - // Generate the indices to form a number of triangles for each line segment, and the vertices for the line edges - // This takes points n and n+1 and writes into n+1, with the first point in a closed line being generated from the final one (as n+1 wraps) - // FIXME-OPT: Merge the different loops, possibly remove the temporary buffer. - unsigned int idx1 = _VtxCurrentIdx; // Vertex index for start of line segment - for (int i1 = 0; i1 < count; i1++) // i1 is the first point of the line segment - { - const int i2 = (i1 + 1) == points_count ? 0 : (i1 + 1); // i2 is the second point of the line segment - const unsigned int idx2 = (i1 + 1) == points_count ? _VtxCurrentIdx : (idx1 + 4); // Vertex index for end of segment - - // Average normals - float dm_x = (temp_normals[i1].x + temp_normals[i2].x) * 0.5f; - float dm_y = (temp_normals[i1].y + temp_normals[i2].y) * 0.5f; - IM_FIXNORMAL2F(dm_x, dm_y); - float dm_out_x = dm_x * (half_inner_thickness + AA_SIZE); - float dm_out_y = dm_y * (half_inner_thickness + AA_SIZE); - float dm_in_x = dm_x * half_inner_thickness; - float dm_in_y = dm_y * half_inner_thickness; - - // Add temporary vertices - ImVec2* out_vtx = &temp_points[i2 * 4]; - out_vtx[0].x = points[i2].x + dm_out_x; - out_vtx[0].y = points[i2].y + dm_out_y; - out_vtx[1].x = points[i2].x + dm_in_x; - out_vtx[1].y = points[i2].y + dm_in_y; - out_vtx[2].x = points[i2].x - dm_in_x; - out_vtx[2].y = points[i2].y - dm_in_y; - out_vtx[3].x = points[i2].x - dm_out_x; - out_vtx[3].y = points[i2].y - dm_out_y; - - // Add indexes - _IdxWritePtr[0] = (ImDrawIdx)(idx2 + 1); _IdxWritePtr[1] = (ImDrawIdx)(idx1 + 1); _IdxWritePtr[2] = (ImDrawIdx)(idx1 + 2); - _IdxWritePtr[3] = (ImDrawIdx)(idx1 + 2); _IdxWritePtr[4] = (ImDrawIdx)(idx2 + 2); _IdxWritePtr[5] = (ImDrawIdx)(idx2 + 1); - _IdxWritePtr[6] = (ImDrawIdx)(idx2 + 1); _IdxWritePtr[7] = (ImDrawIdx)(idx1 + 1); _IdxWritePtr[8] = (ImDrawIdx)(idx1 + 0); - _IdxWritePtr[9] = (ImDrawIdx)(idx1 + 0); _IdxWritePtr[10] = (ImDrawIdx)(idx2 + 0); _IdxWritePtr[11] = (ImDrawIdx)(idx2 + 1); - _IdxWritePtr[12] = (ImDrawIdx)(idx2 + 2); _IdxWritePtr[13] = (ImDrawIdx)(idx1 + 2); _IdxWritePtr[14] = (ImDrawIdx)(idx1 + 3); - _IdxWritePtr[15] = (ImDrawIdx)(idx1 + 3); _IdxWritePtr[16] = (ImDrawIdx)(idx2 + 3); _IdxWritePtr[17] = (ImDrawIdx)(idx2 + 2); - _IdxWritePtr += 18; - - idx1 = idx2; - } - - // Add vertices - for (int i = 0; i < points_count; i++) - { - _VtxWritePtr[0].pos = temp_points[i * 4 + 0]; _VtxWritePtr[0].uv = opaque_uv; _VtxWritePtr[0].col = col_trans; - _VtxWritePtr[1].pos = temp_points[i * 4 + 1]; _VtxWritePtr[1].uv = opaque_uv; _VtxWritePtr[1].col = col; - _VtxWritePtr[2].pos = temp_points[i * 4 + 2]; _VtxWritePtr[2].uv = opaque_uv; _VtxWritePtr[2].col = col; - _VtxWritePtr[3].pos = temp_points[i * 4 + 3]; _VtxWritePtr[3].uv = opaque_uv; _VtxWritePtr[3].col = col_trans; - _VtxWritePtr += 4; - } - } - _VtxCurrentIdx += (ImDrawIdx)vtx_count; - } - else - { - // [PATH 4] Non texture-based, Non anti-aliased lines - const int idx_count = count * 6; - const int vtx_count = count * 4; // FIXME-OPT: Not sharing edges - PrimReserve(idx_count, vtx_count); - - for (int i1 = 0; i1 < count; i1++) - { - const int i2 = (i1 + 1) == points_count ? 0 : i1 + 1; - const ImVec2& p1 = points[i1]; - const ImVec2& p2 = points[i2]; - - float dx = p2.x - p1.x; - float dy = p2.y - p1.y; - IM_NORMALIZE2F_OVER_ZERO(dx, dy); - dx *= (thickness * 0.5f); - dy *= (thickness * 0.5f); - - _VtxWritePtr[0].pos.x = p1.x + dy; _VtxWritePtr[0].pos.y = p1.y - dx; _VtxWritePtr[0].uv = opaque_uv; _VtxWritePtr[0].col = col; - _VtxWritePtr[1].pos.x = p2.x + dy; _VtxWritePtr[1].pos.y = p2.y - dx; _VtxWritePtr[1].uv = opaque_uv; _VtxWritePtr[1].col = col; - _VtxWritePtr[2].pos.x = p2.x - dy; _VtxWritePtr[2].pos.y = p2.y + dx; _VtxWritePtr[2].uv = opaque_uv; _VtxWritePtr[2].col = col; - _VtxWritePtr[3].pos.x = p1.x - dy; _VtxWritePtr[3].pos.y = p1.y + dx; _VtxWritePtr[3].uv = opaque_uv; _VtxWritePtr[3].col = col; - _VtxWritePtr += 4; - - _IdxWritePtr[0] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[1] = (ImDrawIdx)(_VtxCurrentIdx + 1); _IdxWritePtr[2] = (ImDrawIdx)(_VtxCurrentIdx + 2); - _IdxWritePtr[3] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[4] = (ImDrawIdx)(_VtxCurrentIdx + 2); _IdxWritePtr[5] = (ImDrawIdx)(_VtxCurrentIdx + 3); - _IdxWritePtr += 6; - _VtxCurrentIdx += 4; - } - } -} - -// We intentionally avoid using ImVec2 and its math operators here to reduce cost to a minimum for debug/non-inlined builds. -void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_count, ImU32 col) -{ - if (points_count < 3) - return; - - const ImVec2 uv = _Data->TexUvWhitePixel; - - if (Flags & ImDrawListFlags_AntiAliasedFill) - { - // Anti-aliased Fill - const float AA_SIZE = _FringeScale; - const ImU32 col_trans = col & ~IM_COL32_A_MASK; - const int idx_count = (points_count - 2)*3 + points_count * 6; - const int vtx_count = (points_count * 2); - PrimReserve(idx_count, vtx_count); - - // Add indexes for fill - unsigned int vtx_inner_idx = _VtxCurrentIdx; - unsigned int vtx_outer_idx = _VtxCurrentIdx + 1; - for (int i = 2; i < points_count; i++) - { - _IdxWritePtr[0] = (ImDrawIdx)(vtx_inner_idx); _IdxWritePtr[1] = (ImDrawIdx)(vtx_inner_idx + ((i - 1) << 1)); _IdxWritePtr[2] = (ImDrawIdx)(vtx_inner_idx + (i << 1)); - _IdxWritePtr += 3; - } - - // Compute normals - ImVec2* temp_normals = (ImVec2*)alloca(points_count * sizeof(ImVec2)); //-V630 - for (int i0 = points_count - 1, i1 = 0; i1 < points_count; i0 = i1++) - { - const ImVec2& p0 = points[i0]; - const ImVec2& p1 = points[i1]; - float dx = p1.x - p0.x; - float dy = p1.y - p0.y; - IM_NORMALIZE2F_OVER_ZERO(dx, dy); - temp_normals[i0].x = dy; - temp_normals[i0].y = -dx; - } - - for (int i0 = points_count - 1, i1 = 0; i1 < points_count; i0 = i1++) - { - // Average normals - const ImVec2& n0 = temp_normals[i0]; - const ImVec2& n1 = temp_normals[i1]; - float dm_x = (n0.x + n1.x) * 0.5f; - float dm_y = (n0.y + n1.y) * 0.5f; - IM_FIXNORMAL2F(dm_x, dm_y); - dm_x *= AA_SIZE * 0.5f; - dm_y *= AA_SIZE * 0.5f; - - // Add vertices - _VtxWritePtr[0].pos.x = (points[i1].x - dm_x); _VtxWritePtr[0].pos.y = (points[i1].y - dm_y); _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col; // Inner - _VtxWritePtr[1].pos.x = (points[i1].x + dm_x); _VtxWritePtr[1].pos.y = (points[i1].y + dm_y); _VtxWritePtr[1].uv = uv; _VtxWritePtr[1].col = col_trans; // Outer - _VtxWritePtr += 2; - - // Add indexes for fringes - _IdxWritePtr[0] = (ImDrawIdx)(vtx_inner_idx + (i1 << 1)); _IdxWritePtr[1] = (ImDrawIdx)(vtx_inner_idx + (i0 << 1)); _IdxWritePtr[2] = (ImDrawIdx)(vtx_outer_idx + (i0 << 1)); - _IdxWritePtr[3] = (ImDrawIdx)(vtx_outer_idx + (i0 << 1)); _IdxWritePtr[4] = (ImDrawIdx)(vtx_outer_idx + (i1 << 1)); _IdxWritePtr[5] = (ImDrawIdx)(vtx_inner_idx + (i1 << 1)); - _IdxWritePtr += 6; - } - _VtxCurrentIdx += (ImDrawIdx)vtx_count; - } - else - { - // Non Anti-aliased Fill - const int idx_count = (points_count - 2)*3; - const int vtx_count = points_count; - PrimReserve(idx_count, vtx_count); - for (int i = 0; i < vtx_count; i++) - { - _VtxWritePtr[0].pos = points[i]; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col; - _VtxWritePtr++; - } - for (int i = 2; i < points_count; i++) - { - _IdxWritePtr[0] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[1] = (ImDrawIdx)(_VtxCurrentIdx + i - 1); _IdxWritePtr[2] = (ImDrawIdx)(_VtxCurrentIdx + i); - _IdxWritePtr += 3; - } - _VtxCurrentIdx += (ImDrawIdx)vtx_count; - } -} - -void ImDrawList::_PathArcToFastEx(const ImVec2& center, float radius, int a_min_sample, int a_max_sample, int a_step) -{ - if (radius <= 0.0f) - { - _Path.push_back(center); - return; - } - - // Calculate arc auto segment step size - if (a_step <= 0) - a_step = IM_DRAWLIST_ARCFAST_SAMPLE_MAX / _CalcCircleAutoSegmentCount(radius); - - // Make sure we never do steps larger than one quarter of the circle - a_step = ImClamp(a_step, 1, IM_DRAWLIST_ARCFAST_TABLE_SIZE / 4); - - const int sample_range = ImAbs(a_max_sample - a_min_sample); - const int a_next_step = a_step; - - int samples = sample_range + 1; - bool extra_max_sample = false; - if (a_step > 1) - { - samples = sample_range / a_step + 1; - const int overstep = sample_range % a_step; - - if (overstep > 0) - { - extra_max_sample = true; - samples++; - - // When we have overstep to avoid awkwardly looking one long line and one tiny one at the end, - // distribute first step range evenly between them by reducing first step size. - if (sample_range > 0) - a_step -= (a_step - overstep) / 2; - } - } - - _Path.resize(_Path.Size + samples); - ImVec2* out_ptr = _Path.Data + (_Path.Size - samples); - - int sample_index = a_min_sample; - if (sample_index < 0 || sample_index >= IM_DRAWLIST_ARCFAST_SAMPLE_MAX) - { - sample_index = sample_index % IM_DRAWLIST_ARCFAST_SAMPLE_MAX; - if (sample_index < 0) - sample_index += IM_DRAWLIST_ARCFAST_SAMPLE_MAX; - } - - if (a_max_sample >= a_min_sample) - { - for (int a = a_min_sample; a <= a_max_sample; a += a_step, sample_index += a_step, a_step = a_next_step) - { - // a_step is clamped to IM_DRAWLIST_ARCFAST_SAMPLE_MAX, so we have guaranteed that it will not wrap over range twice or more - if (sample_index >= IM_DRAWLIST_ARCFAST_SAMPLE_MAX) - sample_index -= IM_DRAWLIST_ARCFAST_SAMPLE_MAX; - - const ImVec2 s = _Data->ArcFastVtx[sample_index]; - out_ptr->x = center.x + s.x * radius; - out_ptr->y = center.y + s.y * radius; - out_ptr++; - } - } - else - { - for (int a = a_min_sample; a >= a_max_sample; a -= a_step, sample_index -= a_step, a_step = a_next_step) - { - // a_step is clamped to IM_DRAWLIST_ARCFAST_SAMPLE_MAX, so we have guaranteed that it will not wrap over range twice or more - if (sample_index < 0) - sample_index += IM_DRAWLIST_ARCFAST_SAMPLE_MAX; - - const ImVec2 s = _Data->ArcFastVtx[sample_index]; - out_ptr->x = center.x + s.x * radius; - out_ptr->y = center.y + s.y * radius; - out_ptr++; - } - } - - if (extra_max_sample) - { - int normalized_max_sample = a_max_sample % IM_DRAWLIST_ARCFAST_SAMPLE_MAX; - if (normalized_max_sample < 0) - normalized_max_sample += IM_DRAWLIST_ARCFAST_SAMPLE_MAX; - - const ImVec2 s = _Data->ArcFastVtx[normalized_max_sample]; - out_ptr->x = center.x + s.x * radius; - out_ptr->y = center.y + s.y * radius; - out_ptr++; - } - - IM_ASSERT_PARANOID(_Path.Data + _Path.Size == out_ptr); -} - -void ImDrawList::_PathArcToN(const ImVec2& center, float radius, float a_min, float a_max, int num_segments) -{ - if (radius <= 0.0f) - { - _Path.push_back(center); - return; - } - - // Note that we are adding a point at both a_min and a_max. - // If you are trying to draw a full closed circle you don't want the overlapping points! - _Path.reserve(_Path.Size + (num_segments + 1)); - for (int i = 0; i <= num_segments; i++) - { - const float a = a_min + ((float)i / (float)num_segments) * (a_max - a_min); - _Path.push_back(ImVec2(center.x + ImCos(a) * radius, center.y + ImSin(a) * radius)); - } -} - -// 0: East, 3: South, 6: West, 9: North, 12: East -void ImDrawList::PathArcToFast(const ImVec2& center, float radius, int a_min_of_12, int a_max_of_12) -{ - if (radius <= 0.0f) - { - _Path.push_back(center); - return; - } - _PathArcToFastEx(center, radius, a_min_of_12 * IM_DRAWLIST_ARCFAST_SAMPLE_MAX / 12, a_max_of_12 * IM_DRAWLIST_ARCFAST_SAMPLE_MAX / 12, 0); -} - -void ImDrawList::PathArcTo(const ImVec2& center, float radius, float a_min, float a_max, int num_segments) -{ - if (radius <= 0.0f) - { - _Path.push_back(center); - return; - } - - if (num_segments > 0) - { - _PathArcToN(center, radius, a_min, a_max, num_segments); - return; - } - - // Automatic segment count - if (radius <= _Data->ArcFastRadiusCutoff) - { - const bool a_is_reverse = a_max < a_min; - - // We are going to use precomputed values for mid samples. - // Determine first and last sample in lookup table that belong to the arc. - const float a_min_sample_f = IM_DRAWLIST_ARCFAST_SAMPLE_MAX * a_min / (IM_PI * 2.0f); - const float a_max_sample_f = IM_DRAWLIST_ARCFAST_SAMPLE_MAX * a_max / (IM_PI * 2.0f); - - const int a_min_sample = a_is_reverse ? (int)ImFloorSigned(a_min_sample_f) : (int)ImCeil(a_min_sample_f); - const int a_max_sample = a_is_reverse ? (int)ImCeil(a_max_sample_f) : (int)ImFloorSigned(a_max_sample_f); - const int a_mid_samples = a_is_reverse ? ImMax(a_min_sample - a_max_sample, 0) : ImMax(a_max_sample - a_min_sample, 0); - - const float a_min_segment_angle = a_min_sample * IM_PI * 2.0f / IM_DRAWLIST_ARCFAST_SAMPLE_MAX; - const float a_max_segment_angle = a_max_sample * IM_PI * 2.0f / IM_DRAWLIST_ARCFAST_SAMPLE_MAX; - const bool a_emit_start = (a_min_segment_angle - a_min) != 0.0f; - const bool a_emit_end = (a_max - a_max_segment_angle) != 0.0f; - - _Path.reserve(_Path.Size + (a_mid_samples + 1 + (a_emit_start ? 1 : 0) + (a_emit_end ? 1 : 0))); - if (a_emit_start) - _Path.push_back(ImVec2(center.x + ImCos(a_min) * radius, center.y + ImSin(a_min) * radius)); - if (a_mid_samples > 0) - _PathArcToFastEx(center, radius, a_min_sample, a_max_sample, 0); - if (a_emit_end) - _Path.push_back(ImVec2(center.x + ImCos(a_max) * radius, center.y + ImSin(a_max) * radius)); - } - else - { - const float arc_length = ImAbs(a_max - a_min); - const int circle_segment_count = _CalcCircleAutoSegmentCount(radius); - const int arc_segment_count = ImMax((int)ImCeil(circle_segment_count * arc_length / (IM_PI * 2.0f)), (int)(2.0f * IM_PI / arc_length)); - _PathArcToN(center, radius, a_min, a_max, arc_segment_count); - } -} - -ImVec2 ImBezierCubicCalc(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, float t) -{ - float u = 1.0f - t; - float w1 = u * u * u; - float w2 = 3 * u * u * t; - float w3 = 3 * u * t * t; - float w4 = t * t * t; - return ImVec2(w1 * p1.x + w2 * p2.x + w3 * p3.x + w4 * p4.x, w1 * p1.y + w2 * p2.y + w3 * p3.y + w4 * p4.y); -} - -ImVec2 ImBezierQuadraticCalc(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, float t) -{ - float u = 1.0f - t; - float w1 = u * u; - float w2 = 2 * u * t; - float w3 = t * t; - return ImVec2(w1 * p1.x + w2 * p2.x + w3 * p3.x, w1 * p1.y + w2 * p2.y + w3 * p3.y); -} - -// Closely mimics ImBezierCubicClosestPointCasteljau() in imgui.cpp -static void PathBezierCubicCurveToCasteljau(ImVector* path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float tess_tol, int level) -{ - float dx = x4 - x1; - float dy = y4 - y1; - float d2 = (x2 - x4) * dy - (y2 - y4) * dx; - float d3 = (x3 - x4) * dy - (y3 - y4) * dx; - d2 = (d2 >= 0) ? d2 : -d2; - d3 = (d3 >= 0) ? d3 : -d3; - if ((d2 + d3) * (d2 + d3) < tess_tol * (dx * dx + dy * dy)) - { - path->push_back(ImVec2(x4, y4)); - } - else if (level < 10) - { - float x12 = (x1 + x2) * 0.5f, y12 = (y1 + y2) * 0.5f; - float x23 = (x2 + x3) * 0.5f, y23 = (y2 + y3) * 0.5f; - float x34 = (x3 + x4) * 0.5f, y34 = (y3 + y4) * 0.5f; - float x123 = (x12 + x23) * 0.5f, y123 = (y12 + y23) * 0.5f; - float x234 = (x23 + x34) * 0.5f, y234 = (y23 + y34) * 0.5f; - float x1234 = (x123 + x234) * 0.5f, y1234 = (y123 + y234) * 0.5f; - PathBezierCubicCurveToCasteljau(path, x1, y1, x12, y12, x123, y123, x1234, y1234, tess_tol, level + 1); - PathBezierCubicCurveToCasteljau(path, x1234, y1234, x234, y234, x34, y34, x4, y4, tess_tol, level + 1); - } -} - -static void PathBezierQuadraticCurveToCasteljau(ImVector* path, float x1, float y1, float x2, float y2, float x3, float y3, float tess_tol, int level) -{ - float dx = x3 - x1, dy = y3 - y1; - float det = (x2 - x3) * dy - (y2 - y3) * dx; - if (det * det * 4.0f < tess_tol * (dx * dx + dy * dy)) - { - path->push_back(ImVec2(x3, y3)); - } - else if (level < 10) - { - float x12 = (x1 + x2) * 0.5f, y12 = (y1 + y2) * 0.5f; - float x23 = (x2 + x3) * 0.5f, y23 = (y2 + y3) * 0.5f; - float x123 = (x12 + x23) * 0.5f, y123 = (y12 + y23) * 0.5f; - PathBezierQuadraticCurveToCasteljau(path, x1, y1, x12, y12, x123, y123, tess_tol, level + 1); - PathBezierQuadraticCurveToCasteljau(path, x123, y123, x23, y23, x3, y3, tess_tol, level + 1); - } -} - -void ImDrawList::PathBezierCubicCurveTo(const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, int num_segments) -{ - ImVec2 p1 = _Path.back(); - if (num_segments == 0) - { - PathBezierCubicCurveToCasteljau(&_Path, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, _Data->CurveTessellationTol, 0); // Auto-tessellated - } - else - { - float t_step = 1.0f / (float)num_segments; - for (int i_step = 1; i_step <= num_segments; i_step++) - _Path.push_back(ImBezierCubicCalc(p1, p2, p3, p4, t_step * i_step)); - } -} - -void ImDrawList::PathBezierQuadraticCurveTo(const ImVec2& p2, const ImVec2& p3, int num_segments) -{ - ImVec2 p1 = _Path.back(); - if (num_segments == 0) - { - PathBezierQuadraticCurveToCasteljau(&_Path, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, _Data->CurveTessellationTol, 0);// Auto-tessellated - } - else - { - float t_step = 1.0f / (float)num_segments; - for (int i_step = 1; i_step <= num_segments; i_step++) - _Path.push_back(ImBezierQuadraticCalc(p1, p2, p3, t_step * i_step)); - } -} - -IM_STATIC_ASSERT(ImDrawFlags_RoundCornersTopLeft == (1 << 4)); -static inline ImDrawFlags FixRectCornerFlags(ImDrawFlags flags) -{ -#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS - // Legacy Support for hard coded ~0 (used to be a suggested equivalent to ImDrawCornerFlags_All) - // ~0 --> ImDrawFlags_RoundCornersAll or 0 - if (flags == ~0) - return ImDrawFlags_RoundCornersAll; - - // Legacy Support for hard coded 0x01 to 0x0F (matching 15 out of 16 old flags combinations) - // 0x01 --> ImDrawFlags_RoundCornersTopLeft (VALUE 0x01 OVERLAPS ImDrawFlags_Closed but ImDrawFlags_Closed is never valid in this path!) - // 0x02 --> ImDrawFlags_RoundCornersTopRight - // 0x03 --> ImDrawFlags_RoundCornersTopLeft | ImDrawFlags_RoundCornersTopRight - // 0x04 --> ImDrawFlags_RoundCornersBotLeft - // 0x05 --> ImDrawFlags_RoundCornersTopLeft | ImDrawFlags_RoundCornersBotLeft - // ... - // 0x0F --> ImDrawFlags_RoundCornersAll or 0 - // (See all values in ImDrawCornerFlags_) - if (flags >= 0x01 && flags <= 0x0F) - return (flags << 4); - - // We cannot support hard coded 0x00 with 'float rounding > 0.0f' --> replace with ImDrawFlags_RoundCornersNone or use 'float rounding = 0.0f' -#endif - - // If this triggers, please update your code replacing hardcoded values with new ImDrawFlags_RoundCorners* values. - // Note that ImDrawFlags_Closed (== 0x01) is an invalid flag for AddRect(), AddRectFilled(), PathRect() etc... - IM_ASSERT((flags & 0x0F) == 0 && "Misuse of legacy hardcoded ImDrawCornerFlags values!"); - - if ((flags & ImDrawFlags_RoundCornersMask_) == 0) - flags |= ImDrawFlags_RoundCornersAll; - - return flags; -} - -void ImDrawList::PathRect(const ImVec2& a, const ImVec2& b, float rounding, ImDrawFlags flags) -{ - flags = FixRectCornerFlags(flags); - rounding = ImMin(rounding, ImFabs(b.x - a.x) * ( ((flags & ImDrawFlags_RoundCornersTop) == ImDrawFlags_RoundCornersTop) || ((flags & ImDrawFlags_RoundCornersBottom) == ImDrawFlags_RoundCornersBottom) ? 0.5f : 1.0f ) - 1.0f); - rounding = ImMin(rounding, ImFabs(b.y - a.y) * ( ((flags & ImDrawFlags_RoundCornersLeft) == ImDrawFlags_RoundCornersLeft) || ((flags & ImDrawFlags_RoundCornersRight) == ImDrawFlags_RoundCornersRight) ? 0.5f : 1.0f ) - 1.0f); - - if (rounding <= 0.0f || (flags & ImDrawFlags_RoundCornersMask_) == ImDrawFlags_RoundCornersNone) - { - PathLineTo(a); - PathLineTo(ImVec2(b.x, a.y)); - PathLineTo(b); - PathLineTo(ImVec2(a.x, b.y)); - } - else - { - const float rounding_tl = (flags & ImDrawFlags_RoundCornersTopLeft) ? rounding : 0.0f; - const float rounding_tr = (flags & ImDrawFlags_RoundCornersTopRight) ? rounding : 0.0f; - const float rounding_br = (flags & ImDrawFlags_RoundCornersBottomRight) ? rounding : 0.0f; - const float rounding_bl = (flags & ImDrawFlags_RoundCornersBottomLeft) ? rounding : 0.0f; - PathArcToFast(ImVec2(a.x + rounding_tl, a.y + rounding_tl), rounding_tl, 6, 9); - PathArcToFast(ImVec2(b.x - rounding_tr, a.y + rounding_tr), rounding_tr, 9, 12); - PathArcToFast(ImVec2(b.x - rounding_br, b.y - rounding_br), rounding_br, 0, 3); - PathArcToFast(ImVec2(a.x + rounding_bl, b.y - rounding_bl), rounding_bl, 3, 6); - } -} - -void ImDrawList::AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float thickness) -{ - if ((col & IM_COL32_A_MASK) == 0) - return; - PathLineTo(p1 + ImVec2(0.5f, 0.5f)); - PathLineTo(p2 + ImVec2(0.5f, 0.5f)); - PathStroke(col, 0, thickness); -} - -// p_min = upper-left, p_max = lower-right -// Note we don't render 1 pixels sized rectangles properly. -void ImDrawList::AddRect(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding, ImDrawFlags flags, float thickness) -{ - if ((col & IM_COL32_A_MASK) == 0) - return; - if (Flags & ImDrawListFlags_AntiAliasedLines) - PathRect(p_min + ImVec2(0.50f, 0.50f), p_max - ImVec2(0.50f, 0.50f), rounding, flags); - else - PathRect(p_min + ImVec2(0.50f, 0.50f), p_max - ImVec2(0.49f, 0.49f), rounding, flags); // Better looking lower-right corner and rounded non-AA shapes. - PathStroke(col, ImDrawFlags_Closed, thickness); -} - -void ImDrawList::AddRectFilled(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding, ImDrawFlags flags) -{ - if ((col & IM_COL32_A_MASK) == 0) - return; - if (rounding <= 0.0f || (flags & ImDrawFlags_RoundCornersMask_) == ImDrawFlags_RoundCornersNone) - { - PrimReserve(6, 4); - PrimRect(p_min, p_max, col); - } - else - { - PathRect(p_min, p_max, rounding, flags); - PathFillConvex(col); - } -} - -// p_min = upper-left, p_max = lower-right -void ImDrawList::AddRectFilledMultiColor(const ImVec2& p_min, const ImVec2& p_max, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left) -{ - if (((col_upr_left | col_upr_right | col_bot_right | col_bot_left) & IM_COL32_A_MASK) == 0) - return; - - const ImVec2 uv = _Data->TexUvWhitePixel; - PrimReserve(6, 4); - PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx + 1)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx + 2)); - PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx + 2)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx + 3)); - PrimWriteVtx(p_min, uv, col_upr_left); - PrimWriteVtx(ImVec2(p_max.x, p_min.y), uv, col_upr_right); - PrimWriteVtx(p_max, uv, col_bot_right); - PrimWriteVtx(ImVec2(p_min.x, p_max.y), uv, col_bot_left); -} - -void ImDrawList::AddQuad(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness) -{ - if ((col & IM_COL32_A_MASK) == 0) - return; - - PathLineTo(p1); - PathLineTo(p2); - PathLineTo(p3); - PathLineTo(p4); - PathStroke(col, ImDrawFlags_Closed, thickness); -} - -void ImDrawList::AddQuadFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col) -{ - if ((col & IM_COL32_A_MASK) == 0) - return; - - PathLineTo(p1); - PathLineTo(p2); - PathLineTo(p3); - PathLineTo(p4); - PathFillConvex(col); -} - -void ImDrawList::AddTriangle(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col, float thickness) -{ - if ((col & IM_COL32_A_MASK) == 0) - return; - - PathLineTo(p1); - PathLineTo(p2); - PathLineTo(p3); - PathStroke(col, ImDrawFlags_Closed, thickness); -} - -void ImDrawList::AddTriangleFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col) -{ - if ((col & IM_COL32_A_MASK) == 0) - return; - - PathLineTo(p1); - PathLineTo(p2); - PathLineTo(p3); - PathFillConvex(col); -} - -void ImDrawList::AddCircle(const ImVec2& center, float radius, ImU32 col, int num_segments, float thickness) -{ - if ((col & IM_COL32_A_MASK) == 0 || radius <= 0.0f) - return; - - if (num_segments <= 0) - { - // Use arc with automatic segment count - _PathArcToFastEx(center, radius - 0.5f, 0, IM_DRAWLIST_ARCFAST_SAMPLE_MAX, 0); - _Path.Size--; - } - else - { - // Explicit segment count (still clamp to avoid drawing insanely tessellated shapes) - num_segments = ImClamp(num_segments, 3, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX); - - // Because we are filling a closed shape we remove 1 from the count of segments/points - const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments; - PathArcTo(center, radius - 0.5f, 0.0f, a_max, num_segments - 1); - } - - PathStroke(col, ImDrawFlags_Closed, thickness); -} - -void ImDrawList::AddCircleFilled(const ImVec2& center, float radius, ImU32 col, int num_segments) -{ - if ((col & IM_COL32_A_MASK) == 0 || radius <= 0.0f) - return; - - if (num_segments <= 0) - { - // Use arc with automatic segment count - _PathArcToFastEx(center, radius, 0, IM_DRAWLIST_ARCFAST_SAMPLE_MAX, 0); - _Path.Size--; - } - else - { - // Explicit segment count (still clamp to avoid drawing insanely tessellated shapes) - num_segments = ImClamp(num_segments, 3, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX); - - // Because we are filling a closed shape we remove 1 from the count of segments/points - const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments; - PathArcTo(center, radius, 0.0f, a_max, num_segments - 1); - } - - PathFillConvex(col); -} - -// Guaranteed to honor 'num_segments' -void ImDrawList::AddNgon(const ImVec2& center, float radius, ImU32 col, int num_segments, float thickness) -{ - if ((col & IM_COL32_A_MASK) == 0 || num_segments <= 2) - return; - - // Because we are filling a closed shape we remove 1 from the count of segments/points - const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments; - PathArcTo(center, radius - 0.5f, 0.0f, a_max, num_segments - 1); - PathStroke(col, ImDrawFlags_Closed, thickness); -} - -// Guaranteed to honor 'num_segments' -void ImDrawList::AddNgonFilled(const ImVec2& center, float radius, ImU32 col, int num_segments) -{ - if ((col & IM_COL32_A_MASK) == 0 || num_segments <= 2) - return; - - // Because we are filling a closed shape we remove 1 from the count of segments/points - const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments; - PathArcTo(center, radius, 0.0f, a_max, num_segments - 1); - PathFillConvex(col); -} - -// Cubic Bezier takes 4 controls points -void ImDrawList::AddBezierCubic(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness, int num_segments) -{ - if ((col & IM_COL32_A_MASK) == 0) - return; - - PathLineTo(p1); - PathBezierCubicCurveTo(p2, p3, p4, num_segments); - PathStroke(col, 0, thickness); -} - -// Quadratic Bezier takes 3 controls points -void ImDrawList::AddBezierQuadratic(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col, float thickness, int num_segments) -{ - if ((col & IM_COL32_A_MASK) == 0) - return; - - PathLineTo(p1); - PathBezierQuadraticCurveTo(p2, p3, num_segments); - PathStroke(col, 0, thickness); -} - -void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end, float wrap_width, const ImVec4* cpu_fine_clip_rect) -{ - if ((col & IM_COL32_A_MASK) == 0) - return; - - if (text_end == NULL) - text_end = text_begin + strlen(text_begin); - if (text_begin == text_end) - return; - - // Pull default font/size from the shared ImDrawListSharedData instance - if (font == NULL) - font = _Data->Font; - if (font_size == 0.0f) - font_size = _Data->FontSize; - - IM_ASSERT(font->ContainerAtlas->TexID == _CmdHeader.TextureId); // Use high-level ImGui::PushFont() or low-level ImDrawList::PushTextureId() to change font. - - ImVec4 clip_rect = _CmdHeader.ClipRect; - if (cpu_fine_clip_rect) - { - clip_rect.x = ImMax(clip_rect.x, cpu_fine_clip_rect->x); - clip_rect.y = ImMax(clip_rect.y, cpu_fine_clip_rect->y); - clip_rect.z = ImMin(clip_rect.z, cpu_fine_clip_rect->z); - clip_rect.w = ImMin(clip_rect.w, cpu_fine_clip_rect->w); - } - font->RenderText(this, font_size, pos, col, clip_rect, text_begin, text_end, wrap_width, cpu_fine_clip_rect != NULL); -} - -void ImDrawList::AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end) -{ - AddText(NULL, 0.0f, pos, col, text_begin, text_end); -} - -void ImDrawList::AddImage(ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, ImU32 col) -{ - if ((col & IM_COL32_A_MASK) == 0) - return; - - const bool push_texture_id = user_texture_id != _CmdHeader.TextureId; - if (push_texture_id) - PushTextureID(user_texture_id); - - PrimReserve(6, 4); - PrimRectUV(p_min, p_max, uv_min, uv_max, col); - - if (push_texture_id) - PopTextureID(); -} - -void ImDrawList::AddImageQuad(ImTextureID user_texture_id, const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& uv1, const ImVec2& uv2, const ImVec2& uv3, const ImVec2& uv4, ImU32 col) -{ - if ((col & IM_COL32_A_MASK) == 0) - return; - - const bool push_texture_id = user_texture_id != _CmdHeader.TextureId; - if (push_texture_id) - PushTextureID(user_texture_id); - - PrimReserve(6, 4); - PrimQuadUV(p1, p2, p3, p4, uv1, uv2, uv3, uv4, col); - - if (push_texture_id) - PopTextureID(); -} - -void ImDrawList::AddImageRounded(ImTextureID user_texture_id, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, ImU32 col, float rounding, ImDrawFlags flags) -{ - if ((col & IM_COL32_A_MASK) == 0) - return; - - flags = FixRectCornerFlags(flags); - if (rounding <= 0.0f || (flags & ImDrawFlags_RoundCornersMask_) == ImDrawFlags_RoundCornersNone) - { - AddImage(user_texture_id, p_min, p_max, uv_min, uv_max, col); - return; - } - - const bool push_texture_id = user_texture_id != _CmdHeader.TextureId; - if (push_texture_id) - PushTextureID(user_texture_id); - - int vert_start_idx = VtxBuffer.Size; - PathRect(p_min, p_max, rounding, flags); - PathFillConvex(col); - int vert_end_idx = VtxBuffer.Size; - ImGui::ShadeVertsLinearUV(this, vert_start_idx, vert_end_idx, p_min, p_max, uv_min, uv_max, true); - - if (push_texture_id) - PopTextureID(); -} - - -//----------------------------------------------------------------------------- -// [SECTION] ImDrawListSplitter -//----------------------------------------------------------------------------- -// FIXME: This may be a little confusing, trying to be a little too low-level/optimal instead of just doing vector swap.. -//----------------------------------------------------------------------------- - -void ImDrawListSplitter::ClearFreeMemory() -{ - for (int i = 0; i < _Channels.Size; i++) - { - if (i == _Current) - memset(&_Channels[i], 0, sizeof(_Channels[i])); // Current channel is a copy of CmdBuffer/IdxBuffer, don't destruct again - _Channels[i]._CmdBuffer.clear(); - _Channels[i]._IdxBuffer.clear(); - } - _Current = 0; - _Count = 1; - _Channels.clear(); -} - -void ImDrawListSplitter::Split(ImDrawList* draw_list, int channels_count) -{ - IM_UNUSED(draw_list); - IM_ASSERT(_Current == 0 && _Count <= 1 && "Nested channel splitting is not supported. Please use separate instances of ImDrawListSplitter."); - int old_channels_count = _Channels.Size; - if (old_channels_count < channels_count) - { - _Channels.reserve(channels_count); // Avoid over reserving since this is likely to stay stable - _Channels.resize(channels_count); - } - _Count = channels_count; - - // Channels[] (24/32 bytes each) hold storage that we'll swap with draw_list->_CmdBuffer/_IdxBuffer - // The content of Channels[0] at this point doesn't matter. We clear it to make state tidy in a debugger but we don't strictly need to. - // When we switch to the next channel, we'll copy draw_list->_CmdBuffer/_IdxBuffer into Channels[0] and then Channels[1] into draw_list->CmdBuffer/_IdxBuffer - memset(&_Channels[0], 0, sizeof(ImDrawChannel)); - for (int i = 1; i < channels_count; i++) - { - if (i >= old_channels_count) - { - IM_PLACEMENT_NEW(&_Channels[i]) ImDrawChannel(); - } - else - { - _Channels[i]._CmdBuffer.resize(0); - _Channels[i]._IdxBuffer.resize(0); - } - } -} - -void ImDrawListSplitter::Merge(ImDrawList* draw_list) -{ - // Note that we never use or rely on _Channels.Size because it is merely a buffer that we never shrink back to 0 to keep all sub-buffers ready for use. - if (_Count <= 1) - return; - - SetCurrentChannel(draw_list, 0); - draw_list->_PopUnusedDrawCmd(); - - // Calculate our final buffer sizes. Also fix the incorrect IdxOffset values in each command. - int new_cmd_buffer_count = 0; - int new_idx_buffer_count = 0; - ImDrawCmd* last_cmd = (_Count > 0 && draw_list->CmdBuffer.Size > 0) ? &draw_list->CmdBuffer.back() : NULL; - int idx_offset = last_cmd ? last_cmd->IdxOffset + last_cmd->ElemCount : 0; - for (int i = 1; i < _Count; i++) - { - ImDrawChannel& ch = _Channels[i]; - - // Equivalent of PopUnusedDrawCmd() for this channel's cmdbuffer and except we don't need to test for UserCallback. - if (ch._CmdBuffer.Size > 0 && ch._CmdBuffer.back().ElemCount == 0) - ch._CmdBuffer.pop_back(); - - if (ch._CmdBuffer.Size > 0 && last_cmd != NULL) - { - ImDrawCmd* next_cmd = &ch._CmdBuffer[0]; - if (ImDrawCmd_HeaderCompare(last_cmd, next_cmd) == 0 && last_cmd->UserCallback == NULL && next_cmd->UserCallback == NULL) - { - // Merge previous channel last draw command with current channel first draw command if matching. - last_cmd->ElemCount += next_cmd->ElemCount; - idx_offset += next_cmd->ElemCount; - ch._CmdBuffer.erase(ch._CmdBuffer.Data); // FIXME-OPT: Improve for multiple merges. - } - } - if (ch._CmdBuffer.Size > 0) - last_cmd = &ch._CmdBuffer.back(); - new_cmd_buffer_count += ch._CmdBuffer.Size; - new_idx_buffer_count += ch._IdxBuffer.Size; - for (int cmd_n = 0; cmd_n < ch._CmdBuffer.Size; cmd_n++) - { - ch._CmdBuffer.Data[cmd_n].IdxOffset = idx_offset; - idx_offset += ch._CmdBuffer.Data[cmd_n].ElemCount; - } - } - draw_list->CmdBuffer.resize(draw_list->CmdBuffer.Size + new_cmd_buffer_count); - draw_list->IdxBuffer.resize(draw_list->IdxBuffer.Size + new_idx_buffer_count); - - // Write commands and indices in order (they are fairly small structures, we don't copy vertices only indices) - ImDrawCmd* cmd_write = draw_list->CmdBuffer.Data + draw_list->CmdBuffer.Size - new_cmd_buffer_count; - ImDrawIdx* idx_write = draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size - new_idx_buffer_count; - for (int i = 1; i < _Count; i++) - { - ImDrawChannel& ch = _Channels[i]; - if (int sz = ch._CmdBuffer.Size) { memcpy(cmd_write, ch._CmdBuffer.Data, sz * sizeof(ImDrawCmd)); cmd_write += sz; } - if (int sz = ch._IdxBuffer.Size) { memcpy(idx_write, ch._IdxBuffer.Data, sz * sizeof(ImDrawIdx)); idx_write += sz; } - } - draw_list->_IdxWritePtr = idx_write; - - // Ensure there's always a non-callback draw command trailing the command-buffer - if (draw_list->CmdBuffer.Size == 0 || draw_list->CmdBuffer.back().UserCallback != NULL) - draw_list->AddDrawCmd(); - - // If current command is used with different settings we need to add a new command - ImDrawCmd* curr_cmd = &draw_list->CmdBuffer.Data[draw_list->CmdBuffer.Size - 1]; - if (curr_cmd->ElemCount == 0) - ImDrawCmd_HeaderCopy(curr_cmd, &draw_list->_CmdHeader); // Copy ClipRect, TextureId, VtxOffset - else if (ImDrawCmd_HeaderCompare(curr_cmd, &draw_list->_CmdHeader) != 0) - draw_list->AddDrawCmd(); - - _Count = 1; -} - -void ImDrawListSplitter::SetCurrentChannel(ImDrawList* draw_list, int idx) -{ - IM_ASSERT(idx >= 0 && idx < _Count); - if (_Current == idx) - return; - - // Overwrite ImVector (12/16 bytes), four times. This is merely a silly optimization instead of doing .swap() - memcpy(&_Channels.Data[_Current]._CmdBuffer, &draw_list->CmdBuffer, sizeof(draw_list->CmdBuffer)); - memcpy(&_Channels.Data[_Current]._IdxBuffer, &draw_list->IdxBuffer, sizeof(draw_list->IdxBuffer)); - _Current = idx; - memcpy(&draw_list->CmdBuffer, &_Channels.Data[idx]._CmdBuffer, sizeof(draw_list->CmdBuffer)); - memcpy(&draw_list->IdxBuffer, &_Channels.Data[idx]._IdxBuffer, sizeof(draw_list->IdxBuffer)); - draw_list->_IdxWritePtr = draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size; - - // If current command is used with different settings we need to add a new command - ImDrawCmd* curr_cmd = (draw_list->CmdBuffer.Size == 0) ? NULL : &draw_list->CmdBuffer.Data[draw_list->CmdBuffer.Size - 1]; - if (curr_cmd == NULL) - draw_list->AddDrawCmd(); - else if (curr_cmd->ElemCount == 0) - ImDrawCmd_HeaderCopy(curr_cmd, &draw_list->_CmdHeader); // Copy ClipRect, TextureId, VtxOffset - else if (ImDrawCmd_HeaderCompare(curr_cmd, &draw_list->_CmdHeader) != 0) - draw_list->AddDrawCmd(); -} - -//----------------------------------------------------------------------------- -// [SECTION] ImDrawData -//----------------------------------------------------------------------------- - -// For backward compatibility: convert all buffers from indexed to de-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering! -void ImDrawData::DeIndexAllBuffers() -{ - ImVector new_vtx_buffer; - TotalVtxCount = TotalIdxCount = 0; - for (int i = 0; i < CmdListsCount; i++) - { - ImDrawList* cmd_list = CmdLists[i]; - if (cmd_list->IdxBuffer.empty()) - continue; - new_vtx_buffer.resize(cmd_list->IdxBuffer.Size); - for (int j = 0; j < cmd_list->IdxBuffer.Size; j++) - new_vtx_buffer[j] = cmd_list->VtxBuffer[cmd_list->IdxBuffer[j]]; - cmd_list->VtxBuffer.swap(new_vtx_buffer); - cmd_list->IdxBuffer.resize(0); - TotalVtxCount += cmd_list->VtxBuffer.Size; - } -} - -// Helper to scale the ClipRect field of each ImDrawCmd. -// Use if your final output buffer is at a different scale than draw_data->DisplaySize, -// or if there is a difference between your window resolution and framebuffer resolution. -void ImDrawData::ScaleClipRects(const ImVec2& fb_scale) -{ - for (int i = 0; i < CmdListsCount; i++) - { - ImDrawList* cmd_list = CmdLists[i]; - for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) - { - ImDrawCmd* cmd = &cmd_list->CmdBuffer[cmd_i]; - cmd->ClipRect = ImVec4(cmd->ClipRect.x * fb_scale.x, cmd->ClipRect.y * fb_scale.y, cmd->ClipRect.z * fb_scale.x, cmd->ClipRect.w * fb_scale.y); - } - } -} - -//----------------------------------------------------------------------------- -// [SECTION] Helpers ShadeVertsXXX functions -//----------------------------------------------------------------------------- - -// Generic linear color gradient, write to RGB fields, leave A untouched. -void ImGui::ShadeVertsLinearColorGradientKeepAlpha(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, ImVec2 gradient_p0, ImVec2 gradient_p1, ImU32 col0, ImU32 col1) -{ - ImVec2 gradient_extent = gradient_p1 - gradient_p0; - float gradient_inv_length2 = 1.0f / ImLengthSqr(gradient_extent); - ImDrawVert* vert_start = draw_list->VtxBuffer.Data + vert_start_idx; - ImDrawVert* vert_end = draw_list->VtxBuffer.Data + vert_end_idx; - const int col0_r = (int)(col0 >> IM_COL32_R_SHIFT) & 0xFF; - const int col0_g = (int)(col0 >> IM_COL32_G_SHIFT) & 0xFF; - const int col0_b = (int)(col0 >> IM_COL32_B_SHIFT) & 0xFF; - const int col_delta_r = ((int)(col1 >> IM_COL32_R_SHIFT) & 0xFF) - col0_r; - const int col_delta_g = ((int)(col1 >> IM_COL32_G_SHIFT) & 0xFF) - col0_g; - const int col_delta_b = ((int)(col1 >> IM_COL32_B_SHIFT) & 0xFF) - col0_b; - for (ImDrawVert* vert = vert_start; vert < vert_end; vert++) - { - float d = ImDot(vert->pos - gradient_p0, gradient_extent); - float t = ImClamp(d * gradient_inv_length2, 0.0f, 1.0f); - int r = (int)(col0_r + col_delta_r * t); - int g = (int)(col0_g + col_delta_g * t); - int b = (int)(col0_b + col_delta_b * t); - vert->col = (r << IM_COL32_R_SHIFT) | (g << IM_COL32_G_SHIFT) | (b << IM_COL32_B_SHIFT) | (vert->col & IM_COL32_A_MASK); - } -} - -// Distribute UV over (a, b) rectangle -void ImGui::ShadeVertsLinearUV(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, bool clamp) -{ - const ImVec2 size = b - a; - const ImVec2 uv_size = uv_b - uv_a; - const ImVec2 scale = ImVec2( - size.x != 0.0f ? (uv_size.x / size.x) : 0.0f, - size.y != 0.0f ? (uv_size.y / size.y) : 0.0f); - - ImDrawVert* vert_start = draw_list->VtxBuffer.Data + vert_start_idx; - ImDrawVert* vert_end = draw_list->VtxBuffer.Data + vert_end_idx; - if (clamp) - { - const ImVec2 min = ImMin(uv_a, uv_b); - const ImVec2 max = ImMax(uv_a, uv_b); - for (ImDrawVert* vertex = vert_start; vertex < vert_end; ++vertex) - vertex->uv = ImClamp(uv_a + ImMul(ImVec2(vertex->pos.x, vertex->pos.y) - a, scale), min, max); - } - else - { - for (ImDrawVert* vertex = vert_start; vertex < vert_end; ++vertex) - vertex->uv = uv_a + ImMul(ImVec2(vertex->pos.x, vertex->pos.y) - a, scale); - } -} - -//----------------------------------------------------------------------------- -// [SECTION] ImFontConfig -//----------------------------------------------------------------------------- - -ImFontConfig::ImFontConfig() -{ - memset(this, 0, sizeof(*this)); - FontDataOwnedByAtlas = true; - OversampleH = 3; // FIXME: 2 may be a better default? - OversampleV = 1; - GlyphMaxAdvanceX = FLT_MAX; - RasterizerMultiply = 1.0f; - EllipsisChar = (ImWchar)-1; -} - -//----------------------------------------------------------------------------- -// [SECTION] ImFontAtlas -//----------------------------------------------------------------------------- - -// A work of art lies ahead! (. = white layer, X = black layer, others are blank) -// The 2x2 white texels on the top left are the ones we'll use everywhere in Dear ImGui to render filled shapes. -const int FONT_ATLAS_DEFAULT_TEX_DATA_W = 108; // Actual texture will be 2 times that + 1 spacing. -const int FONT_ATLAS_DEFAULT_TEX_DATA_H = 27; -static const char FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[FONT_ATLAS_DEFAULT_TEX_DATA_W * FONT_ATLAS_DEFAULT_TEX_DATA_H + 1] = -{ - "..- -XXXXXXX- X - X -XXXXXXX - XXXXXXX- XX " - "..- -X.....X- X.X - X.X -X.....X - X.....X- X..X " - "--- -XXX.XXX- X...X - X...X -X....X - X....X- X..X " - "X - X.X - X.....X - X.....X -X...X - X...X- X..X " - "XX - X.X -X.......X- X.......X -X..X.X - X.X..X- X..X " - "X.X - X.X -XXXX.XXXX- XXXX.XXXX -X.X X.X - X.X X.X- X..XXX " - "X..X - X.X - X.X - X.X -XX X.X - X.X XX- X..X..XXX " - "X...X - X.X - X.X - XX X.X XX - X.X - X.X - X..X..X..XX " - "X....X - X.X - X.X - X.X X.X X.X - X.X - X.X - X..X..X..X.X " - "X.....X - X.X - X.X - X..X X.X X..X - X.X - X.X -XXX X..X..X..X..X" - "X......X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X XX-XX X.X -X..XX........X..X" - "X.......X - X.X - X.X -X.....................X- X.X X.X-X.X X.X -X...X...........X" - "X........X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X..X-X..X.X - X..............X" - "X.........X -XXX.XXX- X.X - X..X X.X X..X - X...X-X...X - X.............X" - "X..........X-X.....X- X.X - X.X X.X X.X - X....X-X....X - X.............X" - "X......XXXXX-XXXXXXX- X.X - XX X.X XX - X.....X-X.....X - X............X" - "X...X..X --------- X.X - X.X - XXXXXXX-XXXXXXX - X...........X " - "X..X X..X - -XXXX.XXXX- XXXX.XXXX ------------------------------------- X..........X " - "X.X X..X - -X.......X- X.......X - XX XX - - X..........X " - "XX X..X - - X.....X - X.....X - X.X X.X - - X........X " - " X..X - X...X - X...X - X..X X..X - - X........X " - " XX - X.X - X.X - X...XXXXXXXXXXXXX...X - - XXXXXXXXXX " - "------------ - X - X -X.....................X- ------------------" - " ----------------------------------- X...XXXXXXXXXXXXX...X - " - " - X..X X..X - " - " - X.X X.X - " - " - XX XX - " -}; - -static const ImVec2 FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[ImGuiMouseCursor_COUNT][3] = -{ - // Pos ........ Size ......... Offset ...... - { ImVec2( 0,3), ImVec2(12,19), ImVec2( 0, 0) }, // ImGuiMouseCursor_Arrow - { ImVec2(13,0), ImVec2( 7,16), ImVec2( 1, 8) }, // ImGuiMouseCursor_TextInput - { ImVec2(31,0), ImVec2(23,23), ImVec2(11,11) }, // ImGuiMouseCursor_ResizeAll - { ImVec2(21,0), ImVec2( 9,23), ImVec2( 4,11) }, // ImGuiMouseCursor_ResizeNS - { ImVec2(55,18),ImVec2(23, 9), ImVec2(11, 4) }, // ImGuiMouseCursor_ResizeEW - { ImVec2(73,0), ImVec2(17,17), ImVec2( 8, 8) }, // ImGuiMouseCursor_ResizeNESW - { ImVec2(55,0), ImVec2(17,17), ImVec2( 8, 8) }, // ImGuiMouseCursor_ResizeNWSE - { ImVec2(91,0), ImVec2(17,22), ImVec2( 5, 0) }, // ImGuiMouseCursor_Hand -}; - -ImFontAtlas::ImFontAtlas() -{ - memset(this, 0, sizeof(*this)); - TexGlyphPadding = 1; - PackIdMouseCursors = PackIdLines = -1; -} - -ImFontAtlas::~ImFontAtlas() -{ - IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!"); - Clear(); -} - -void ImFontAtlas::ClearInputData() -{ - IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!"); - for (int i = 0; i < ConfigData.Size; i++) - if (ConfigData[i].FontData && ConfigData[i].FontDataOwnedByAtlas) - { - IM_FREE(ConfigData[i].FontData); - ConfigData[i].FontData = NULL; - } - - // When clearing this we lose access to the font name and other information used to build the font. - for (int i = 0; i < Fonts.Size; i++) - if (Fonts[i]->ConfigData >= ConfigData.Data && Fonts[i]->ConfigData < ConfigData.Data + ConfigData.Size) - { - Fonts[i]->ConfigData = NULL; - Fonts[i]->ConfigDataCount = 0; - } - ConfigData.clear(); - CustomRects.clear(); - PackIdMouseCursors = PackIdLines = -1; - // Important: we leave TexReady untouched -} - -void ImFontAtlas::ClearTexData() -{ - IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!"); - if (TexPixelsAlpha8) - IM_FREE(TexPixelsAlpha8); - if (TexPixelsRGBA32) - IM_FREE(TexPixelsRGBA32); - TexPixelsAlpha8 = NULL; - TexPixelsRGBA32 = NULL; - TexPixelsUseColors = false; - // Important: we leave TexReady untouched -} - -void ImFontAtlas::ClearFonts() -{ - IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!"); - Fonts.clear_delete(); - TexReady = false; -} - -void ImFontAtlas::Clear() -{ - ClearInputData(); - ClearTexData(); - ClearFonts(); -} - -void ImFontAtlas::GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel) -{ - // Build atlas on demand - if (TexPixelsAlpha8 == NULL) - Build(); - - *out_pixels = TexPixelsAlpha8; - if (out_width) *out_width = TexWidth; - if (out_height) *out_height = TexHeight; - if (out_bytes_per_pixel) *out_bytes_per_pixel = 1; -} - -void ImFontAtlas::GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel) -{ - // Convert to RGBA32 format on demand - // Although it is likely to be the most commonly used format, our font rendering is 1 channel / 8 bpp - if (!TexPixelsRGBA32) - { - unsigned char* pixels = NULL; - GetTexDataAsAlpha8(&pixels, NULL, NULL); - if (pixels) - { - TexPixelsRGBA32 = (unsigned int*)IM_ALLOC((size_t)TexWidth * (size_t)TexHeight * 4); - const unsigned char* src = pixels; - unsigned int* dst = TexPixelsRGBA32; - for (int n = TexWidth * TexHeight; n > 0; n--) - *dst++ = IM_COL32(255, 255, 255, (unsigned int)(*src++)); - } - } - - *out_pixels = (unsigned char*)TexPixelsRGBA32; - if (out_width) *out_width = TexWidth; - if (out_height) *out_height = TexHeight; - if (out_bytes_per_pixel) *out_bytes_per_pixel = 4; -} - -ImFont* ImFontAtlas::AddFont(const ImFontConfig* font_cfg) -{ - IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!"); - IM_ASSERT(font_cfg->FontData != NULL && font_cfg->FontDataSize > 0); - IM_ASSERT(font_cfg->SizePixels > 0.0f); - - // Create new font - if (!font_cfg->MergeMode) - Fonts.push_back(IM_NEW(ImFont)); - else - IM_ASSERT(!Fonts.empty() && "Cannot use MergeMode for the first font"); // When using MergeMode make sure that a font has already been added before. You can use ImGui::GetIO().Fonts->AddFontDefault() to add the default imgui font. - - ConfigData.push_back(*font_cfg); - ImFontConfig& new_font_cfg = ConfigData.back(); - if (new_font_cfg.DstFont == NULL) - new_font_cfg.DstFont = Fonts.back(); - if (!new_font_cfg.FontDataOwnedByAtlas) - { - new_font_cfg.FontData = IM_ALLOC(new_font_cfg.FontDataSize); - new_font_cfg.FontDataOwnedByAtlas = true; - memcpy(new_font_cfg.FontData, font_cfg->FontData, (size_t)new_font_cfg.FontDataSize); - } - - if (new_font_cfg.DstFont->EllipsisChar == (ImWchar)-1) - new_font_cfg.DstFont->EllipsisChar = font_cfg->EllipsisChar; - - // Invalidate texture - TexReady = false; - ClearTexData(); - return new_font_cfg.DstFont; -} - -// Default font TTF is compressed with stb_compress then base85 encoded (see misc/fonts/binary_to_compressed_c.cpp for encoder) -static unsigned int stb_decompress_length(const unsigned char* input); -static unsigned int stb_decompress(unsigned char* output, const unsigned char* input, unsigned int length); -static const char* GetDefaultCompressedFontDataTTFBase85(); -static unsigned int Decode85Byte(char c) { return c >= '\\' ? c-36 : c-35; } -static void Decode85(const unsigned char* src, unsigned char* dst) -{ - while (*src) - { - unsigned int tmp = Decode85Byte(src[0]) + 85 * (Decode85Byte(src[1]) + 85 * (Decode85Byte(src[2]) + 85 * (Decode85Byte(src[3]) + 85 * Decode85Byte(src[4])))); - dst[0] = ((tmp >> 0) & 0xFF); dst[1] = ((tmp >> 8) & 0xFF); dst[2] = ((tmp >> 16) & 0xFF); dst[3] = ((tmp >> 24) & 0xFF); // We can't assume little-endianness. - src += 5; - dst += 4; - } -} - -// Load embedded ProggyClean.ttf at size 13, disable oversampling -ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg_template) -{ - ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig(); - if (!font_cfg_template) - { - font_cfg.OversampleH = font_cfg.OversampleV = 1; - font_cfg.PixelSnapH = true; - } - if (font_cfg.SizePixels <= 0.0f) - font_cfg.SizePixels = 13.0f * 1.0f; - if (font_cfg.Name[0] == '\0') - ImFormatString(font_cfg.Name, IM_ARRAYSIZE(font_cfg.Name), "ProggyClean.ttf, %dpx", (int)font_cfg.SizePixels); - font_cfg.EllipsisChar = (ImWchar)0x0085; - font_cfg.GlyphOffset.y = 1.0f * IM_FLOOR(font_cfg.SizePixels / 13.0f); // Add +1 offset per 13 units - - const char* ttf_compressed_base85 = GetDefaultCompressedFontDataTTFBase85(); - const ImWchar* glyph_ranges = font_cfg.GlyphRanges != NULL ? font_cfg.GlyphRanges : GetGlyphRangesDefault(); - ImFont* font = AddFontFromMemoryCompressedBase85TTF(ttf_compressed_base85, font_cfg.SizePixels, &font_cfg, glyph_ranges); - return font; -} - -ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges) -{ - IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!"); - size_t data_size = 0; - void* data = ImFileLoadToMemory(filename, "rb", &data_size, 0); - if (!data) - { - IM_ASSERT_USER_ERROR(0, "Could not load font file!"); - return NULL; - } - ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig(); - if (font_cfg.Name[0] == '\0') - { - // Store a short copy of filename into into the font name for convenience - const char* p; - for (p = filename + strlen(filename); p > filename && p[-1] != '/' && p[-1] != '\\'; p--) {} - ImFormatString(font_cfg.Name, IM_ARRAYSIZE(font_cfg.Name), "%s, %.0fpx", p, size_pixels); - } - return AddFontFromMemoryTTF(data, (int)data_size, size_pixels, &font_cfg, glyph_ranges); -} - -// NB: Transfer ownership of 'ttf_data' to ImFontAtlas, unless font_cfg_template->FontDataOwnedByAtlas == false. Owned TTF buffer will be deleted after Build(). -ImFont* ImFontAtlas::AddFontFromMemoryTTF(void* ttf_data, int ttf_size, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges) -{ - IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!"); - ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig(); - IM_ASSERT(font_cfg.FontData == NULL); - font_cfg.FontData = ttf_data; - font_cfg.FontDataSize = ttf_size; - font_cfg.SizePixels = size_pixels > 0.0f ? size_pixels : font_cfg.SizePixels; - if (glyph_ranges) - font_cfg.GlyphRanges = glyph_ranges; - return AddFont(&font_cfg); -} - -ImFont* ImFontAtlas::AddFontFromMemoryCompressedTTF(const void* compressed_ttf_data, int compressed_ttf_size, float size_pixels, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges) -{ - const unsigned int buf_decompressed_size = stb_decompress_length((const unsigned char*)compressed_ttf_data); - unsigned char* buf_decompressed_data = (unsigned char*)IM_ALLOC(buf_decompressed_size); - stb_decompress(buf_decompressed_data, (const unsigned char*)compressed_ttf_data, (unsigned int)compressed_ttf_size); - - ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig(); - IM_ASSERT(font_cfg.FontData == NULL); - font_cfg.FontDataOwnedByAtlas = true; - return AddFontFromMemoryTTF(buf_decompressed_data, (int)buf_decompressed_size, size_pixels, &font_cfg, glyph_ranges); -} - -ImFont* ImFontAtlas::AddFontFromMemoryCompressedBase85TTF(const char* compressed_ttf_data_base85, float size_pixels, const ImFontConfig* font_cfg, const ImWchar* glyph_ranges) -{ - int compressed_ttf_size = (((int)strlen(compressed_ttf_data_base85) + 4) / 5) * 4; - void* compressed_ttf = IM_ALLOC((size_t)compressed_ttf_size); - Decode85((const unsigned char*)compressed_ttf_data_base85, (unsigned char*)compressed_ttf); - ImFont* font = AddFontFromMemoryCompressedTTF(compressed_ttf, compressed_ttf_size, size_pixels, font_cfg, glyph_ranges); - IM_FREE(compressed_ttf); - return font; -} - -int ImFontAtlas::AddCustomRectRegular(int width, int height) -{ - IM_ASSERT(width > 0 && width <= 0xFFFF); - IM_ASSERT(height > 0 && height <= 0xFFFF); - ImFontAtlasCustomRect r; - r.Width = (unsigned short)width; - r.Height = (unsigned short)height; - CustomRects.push_back(r); - return CustomRects.Size - 1; // Return index -} - -int ImFontAtlas::AddCustomRectFontGlyph(ImFont* font, ImWchar id, int width, int height, float advance_x, const ImVec2& offset) -{ -#ifdef IMGUI_USE_WCHAR32 - IM_ASSERT(id <= IM_UNICODE_CODEPOINT_MAX); -#endif - IM_ASSERT(font != NULL); - IM_ASSERT(width > 0 && width <= 0xFFFF); - IM_ASSERT(height > 0 && height <= 0xFFFF); - ImFontAtlasCustomRect r; - r.Width = (unsigned short)width; - r.Height = (unsigned short)height; - r.GlyphID = id; - r.GlyphAdvanceX = advance_x; - r.GlyphOffset = offset; - r.Font = font; - CustomRects.push_back(r); - return CustomRects.Size - 1; // Return index -} - -void ImFontAtlas::CalcCustomRectUV(const ImFontAtlasCustomRect* rect, ImVec2* out_uv_min, ImVec2* out_uv_max) const -{ - IM_ASSERT(TexWidth > 0 && TexHeight > 0); // Font atlas needs to be built before we can calculate UV coordinates - IM_ASSERT(rect->IsPacked()); // Make sure the rectangle has been packed - *out_uv_min = ImVec2((float)rect->X * TexUvScale.x, (float)rect->Y * TexUvScale.y); - *out_uv_max = ImVec2((float)(rect->X + rect->Width) * TexUvScale.x, (float)(rect->Y + rect->Height) * TexUvScale.y); -} - -bool ImFontAtlas::GetMouseCursorTexData(ImGuiMouseCursor cursor_type, ImVec2* out_offset, ImVec2* out_size, ImVec2 out_uv_border[2], ImVec2 out_uv_fill[2]) -{ - if (cursor_type <= ImGuiMouseCursor_None || cursor_type >= ImGuiMouseCursor_COUNT) - return false; - if (Flags & ImFontAtlasFlags_NoMouseCursors) - return false; - - IM_ASSERT(PackIdMouseCursors != -1); - ImFontAtlasCustomRect* r = GetCustomRectByIndex(PackIdMouseCursors); - ImVec2 pos = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][0] + ImVec2((float)r->X, (float)r->Y); - ImVec2 size = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][1]; - *out_size = size; - *out_offset = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][2]; - out_uv_border[0] = (pos) * TexUvScale; - out_uv_border[1] = (pos + size) * TexUvScale; - pos.x += FONT_ATLAS_DEFAULT_TEX_DATA_W + 1; - out_uv_fill[0] = (pos) * TexUvScale; - out_uv_fill[1] = (pos + size) * TexUvScale; - return true; -} - -bool ImFontAtlas::Build() -{ - IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas between NewFrame() and EndFrame/Render()!"); - - // Default font is none are specified - if (ConfigData.Size == 0) - AddFontDefault(); - - // Select builder - // - Note that we do not reassign to atlas->FontBuilderIO, since it is likely to point to static data which - // may mess with some hot-reloading schemes. If you need to assign to this (for dynamic selection) AND are - // using a hot-reloading scheme that messes up static data, store your own instance of ImFontBuilderIO somewhere - // and point to it instead of pointing directly to return value of the GetBuilderXXX functions. - const ImFontBuilderIO* builder_io = FontBuilderIO; - if (builder_io == NULL) - { -#ifdef IMGUI_ENABLE_FREETYPE - builder_io = ImGuiFreeType::GetBuilderForFreeType(); -#elif defined(IMGUI_ENABLE_STB_TRUETYPE) - builder_io = ImFontAtlasGetBuilderForStbTruetype(); -#else - IM_ASSERT(0); // Invalid Build function -#endif - } - - // Build - return builder_io->FontBuilder_Build(this); -} - -void ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256], float in_brighten_factor) -{ - for (unsigned int i = 0; i < 256; i++) - { - unsigned int value = (unsigned int)(i * in_brighten_factor); - out_table[i] = value > 255 ? 255 : (value & 0xFF); - } -} - -void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256], unsigned char* pixels, int x, int y, int w, int h, int stride) -{ - unsigned char* data = pixels + x + y * stride; - for (int j = h; j > 0; j--, data += stride) - for (int i = 0; i < w; i++) - data[i] = table[data[i]]; -} - -#ifdef IMGUI_ENABLE_STB_TRUETYPE -// Temporary data for one source font (multiple source fonts can be merged into one destination ImFont) -// (C++03 doesn't allow instancing ImVector<> with function-local types so we declare the type here.) -struct ImFontBuildSrcData -{ - stbtt_fontinfo FontInfo; - stbtt_pack_range PackRange; // Hold the list of codepoints to pack (essentially points to Codepoints.Data) - stbrp_rect* Rects; // Rectangle to pack. We first fill in their size and the packer will give us their position. - stbtt_packedchar* PackedChars; // Output glyphs - const ImWchar* SrcRanges; // Ranges as requested by user (user is allowed to request too much, e.g. 0x0020..0xFFFF) - int DstIndex; // Index into atlas->Fonts[] and dst_tmp_array[] - int GlyphsHighest; // Highest requested codepoint - int GlyphsCount; // Glyph count (excluding missing glyphs and glyphs already set by an earlier source font) - ImBitVector GlyphsSet; // Glyph bit map (random access, 1-bit per codepoint. This will be a maximum of 8KB) - ImVector GlyphsList; // Glyph codepoints list (flattened version of GlyphsMap) -}; - -// Temporary data for one destination ImFont* (multiple source fonts can be merged into one destination ImFont) -struct ImFontBuildDstData -{ - int SrcCount; // Number of source fonts targeting this destination font. - int GlyphsHighest; - int GlyphsCount; - ImBitVector GlyphsSet; // This is used to resolve collision when multiple sources are merged into a same destination font. -}; - -static void UnpackBitVectorToFlatIndexList(const ImBitVector* in, ImVector* out) -{ - IM_ASSERT(sizeof(in->Storage.Data[0]) == sizeof(int)); - const ImU32* it_begin = in->Storage.begin(); - const ImU32* it_end = in->Storage.end(); - for (const ImU32* it = it_begin; it < it_end; it++) - if (ImU32 entries_32 = *it) - for (ImU32 bit_n = 0; bit_n < 32; bit_n++) - if (entries_32 & ((ImU32)1 << bit_n)) - out->push_back((int)(((it - it_begin) << 5) + bit_n)); -} - -static bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas) -{ - IM_ASSERT(atlas->ConfigData.Size > 0); - - ImFontAtlasBuildInit(atlas); - - // Clear atlas - atlas->TexID = (ImTextureID)NULL; - atlas->TexWidth = atlas->TexHeight = 0; - atlas->TexUvScale = ImVec2(0.0f, 0.0f); - atlas->TexUvWhitePixel = ImVec2(0.0f, 0.0f); - atlas->ClearTexData(); - - // Temporary storage for building - ImVector src_tmp_array; - ImVector dst_tmp_array; - src_tmp_array.resize(atlas->ConfigData.Size); - dst_tmp_array.resize(atlas->Fonts.Size); - memset(src_tmp_array.Data, 0, (size_t)src_tmp_array.size_in_bytes()); - memset(dst_tmp_array.Data, 0, (size_t)dst_tmp_array.size_in_bytes()); - - // 1. Initialize font loading structure, check font data validity - for (int src_i = 0; src_i < atlas->ConfigData.Size; src_i++) - { - ImFontBuildSrcData& src_tmp = src_tmp_array[src_i]; - ImFontConfig& cfg = atlas->ConfigData[src_i]; - IM_ASSERT(cfg.DstFont && (!cfg.DstFont->IsLoaded() || cfg.DstFont->ContainerAtlas == atlas)); - - // Find index from cfg.DstFont (we allow the user to set cfg.DstFont. Also it makes casual debugging nicer than when storing indices) - src_tmp.DstIndex = -1; - for (int output_i = 0; output_i < atlas->Fonts.Size && src_tmp.DstIndex == -1; output_i++) - if (cfg.DstFont == atlas->Fonts[output_i]) - src_tmp.DstIndex = output_i; - if (src_tmp.DstIndex == -1) - { - IM_ASSERT(src_tmp.DstIndex != -1); // cfg.DstFont not pointing within atlas->Fonts[] array? - return false; - } - // Initialize helper structure for font loading and verify that the TTF/OTF data is correct - const int font_offset = stbtt_GetFontOffsetForIndex((unsigned char*)cfg.FontData, cfg.FontNo); - IM_ASSERT(font_offset >= 0 && "FontData is incorrect, or FontNo cannot be found."); - if (!stbtt_InitFont(&src_tmp.FontInfo, (unsigned char*)cfg.FontData, font_offset)) - return false; - - // Measure highest codepoints - ImFontBuildDstData& dst_tmp = dst_tmp_array[src_tmp.DstIndex]; - src_tmp.SrcRanges = cfg.GlyphRanges ? cfg.GlyphRanges : atlas->GetGlyphRangesDefault(); - for (const ImWchar* src_range = src_tmp.SrcRanges; src_range[0] && src_range[1]; src_range += 2) - src_tmp.GlyphsHighest = ImMax(src_tmp.GlyphsHighest, (int)src_range[1]); - dst_tmp.SrcCount++; - dst_tmp.GlyphsHighest = ImMax(dst_tmp.GlyphsHighest, src_tmp.GlyphsHighest); - } - - // 2. For every requested codepoint, check for their presence in the font data, and handle redundancy or overlaps between source fonts to avoid unused glyphs. - int total_glyphs_count = 0; - for (int src_i = 0; src_i < src_tmp_array.Size; src_i++) - { - ImFontBuildSrcData& src_tmp = src_tmp_array[src_i]; - ImFontBuildDstData& dst_tmp = dst_tmp_array[src_tmp.DstIndex]; - src_tmp.GlyphsSet.Create(src_tmp.GlyphsHighest + 1); - if (dst_tmp.GlyphsSet.Storage.empty()) - dst_tmp.GlyphsSet.Create(dst_tmp.GlyphsHighest + 1); - - for (const ImWchar* src_range = src_tmp.SrcRanges; src_range[0] && src_range[1]; src_range += 2) - for (unsigned int codepoint = src_range[0]; codepoint <= src_range[1]; codepoint++) - { - if (dst_tmp.GlyphsSet.TestBit(codepoint)) // Don't overwrite existing glyphs. We could make this an option for MergeMode (e.g. MergeOverwrite==true) - continue; - if (!stbtt_FindGlyphIndex(&src_tmp.FontInfo, codepoint)) // It is actually in the font? - continue; - - // Add to avail set/counters - src_tmp.GlyphsCount++; - dst_tmp.GlyphsCount++; - src_tmp.GlyphsSet.SetBit(codepoint); - dst_tmp.GlyphsSet.SetBit(codepoint); - total_glyphs_count++; - } - } - - // 3. Unpack our bit map into a flat list (we now have all the Unicode points that we know are requested _and_ available _and_ not overlapping another) - for (int src_i = 0; src_i < src_tmp_array.Size; src_i++) - { - ImFontBuildSrcData& src_tmp = src_tmp_array[src_i]; - src_tmp.GlyphsList.reserve(src_tmp.GlyphsCount); - UnpackBitVectorToFlatIndexList(&src_tmp.GlyphsSet, &src_tmp.GlyphsList); - src_tmp.GlyphsSet.Clear(); - IM_ASSERT(src_tmp.GlyphsList.Size == src_tmp.GlyphsCount); - } - for (int dst_i = 0; dst_i < dst_tmp_array.Size; dst_i++) - dst_tmp_array[dst_i].GlyphsSet.Clear(); - dst_tmp_array.clear(); - - // Allocate packing character data and flag packed characters buffer as non-packed (x0=y0=x1=y1=0) - // (We technically don't need to zero-clear buf_rects, but let's do it for the sake of sanity) - ImVector buf_rects; - ImVector buf_packedchars; - buf_rects.resize(total_glyphs_count); - buf_packedchars.resize(total_glyphs_count); - memset(buf_rects.Data, 0, (size_t)buf_rects.size_in_bytes()); - memset(buf_packedchars.Data, 0, (size_t)buf_packedchars.size_in_bytes()); - - // 4. Gather glyphs sizes so we can pack them in our virtual canvas. - int total_surface = 0; - int buf_rects_out_n = 0; - int buf_packedchars_out_n = 0; - for (int src_i = 0; src_i < src_tmp_array.Size; src_i++) - { - ImFontBuildSrcData& src_tmp = src_tmp_array[src_i]; - if (src_tmp.GlyphsCount == 0) - continue; - - src_tmp.Rects = &buf_rects[buf_rects_out_n]; - src_tmp.PackedChars = &buf_packedchars[buf_packedchars_out_n]; - buf_rects_out_n += src_tmp.GlyphsCount; - buf_packedchars_out_n += src_tmp.GlyphsCount; - - // Convert our ranges in the format stb_truetype wants - ImFontConfig& cfg = atlas->ConfigData[src_i]; - src_tmp.PackRange.font_size = cfg.SizePixels; - src_tmp.PackRange.first_unicode_codepoint_in_range = 0; - src_tmp.PackRange.array_of_unicode_codepoints = src_tmp.GlyphsList.Data; - src_tmp.PackRange.num_chars = src_tmp.GlyphsList.Size; - src_tmp.PackRange.chardata_for_range = src_tmp.PackedChars; - src_tmp.PackRange.h_oversample = (unsigned char)cfg.OversampleH; - src_tmp.PackRange.v_oversample = (unsigned char)cfg.OversampleV; - - // Gather the sizes of all rectangles we will need to pack (this loop is based on stbtt_PackFontRangesGatherRects) - const float scale = (cfg.SizePixels > 0) ? stbtt_ScaleForPixelHeight(&src_tmp.FontInfo, cfg.SizePixels) : stbtt_ScaleForMappingEmToPixels(&src_tmp.FontInfo, -cfg.SizePixels); - const int padding = atlas->TexGlyphPadding; - for (int glyph_i = 0; glyph_i < src_tmp.GlyphsList.Size; glyph_i++) - { - int x0, y0, x1, y1; - const int glyph_index_in_font = stbtt_FindGlyphIndex(&src_tmp.FontInfo, src_tmp.GlyphsList[glyph_i]); - IM_ASSERT(glyph_index_in_font != 0); - stbtt_GetGlyphBitmapBoxSubpixel(&src_tmp.FontInfo, glyph_index_in_font, scale * cfg.OversampleH, scale * cfg.OversampleV, 0, 0, &x0, &y0, &x1, &y1); - src_tmp.Rects[glyph_i].w = (stbrp_coord)(x1 - x0 + padding + cfg.OversampleH - 1); - src_tmp.Rects[glyph_i].h = (stbrp_coord)(y1 - y0 + padding + cfg.OversampleV - 1); - total_surface += src_tmp.Rects[glyph_i].w * src_tmp.Rects[glyph_i].h; - } - } - - // We need a width for the skyline algorithm, any width! - // The exact width doesn't really matter much, but some API/GPU have texture size limitations and increasing width can decrease height. - // User can override TexDesiredWidth and TexGlyphPadding if they wish, otherwise we use a simple heuristic to select the width based on expected surface. - const int surface_sqrt = (int)ImSqrt((float)total_surface) + 1; - atlas->TexHeight = 0; - if (atlas->TexDesiredWidth > 0) - atlas->TexWidth = atlas->TexDesiredWidth; - else - atlas->TexWidth = (surface_sqrt >= 4096 * 0.7f) ? 4096 : (surface_sqrt >= 2048 * 0.7f) ? 2048 : (surface_sqrt >= 1024 * 0.7f) ? 1024 : 512; - - // 5. Start packing - // Pack our extra data rectangles first, so it will be on the upper-left corner of our texture (UV will have small values). - const int TEX_HEIGHT_MAX = 1024 * 32; - stbtt_pack_context spc = {}; - stbtt_PackBegin(&spc, NULL, atlas->TexWidth, TEX_HEIGHT_MAX, 0, atlas->TexGlyphPadding, NULL); - ImFontAtlasBuildPackCustomRects(atlas, spc.pack_info); - - // 6. Pack each source font. No rendering yet, we are working with rectangles in an infinitely tall texture at this point. - for (int src_i = 0; src_i < src_tmp_array.Size; src_i++) - { - ImFontBuildSrcData& src_tmp = src_tmp_array[src_i]; - if (src_tmp.GlyphsCount == 0) - continue; - - stbrp_pack_rects((stbrp_context*)spc.pack_info, src_tmp.Rects, src_tmp.GlyphsCount); - - // Extend texture height and mark missing glyphs as non-packed so we won't render them. - // FIXME: We are not handling packing failure here (would happen if we got off TEX_HEIGHT_MAX or if a single if larger than TexWidth?) - for (int glyph_i = 0; glyph_i < src_tmp.GlyphsCount; glyph_i++) - if (src_tmp.Rects[glyph_i].was_packed) - atlas->TexHeight = ImMax(atlas->TexHeight, src_tmp.Rects[glyph_i].y + src_tmp.Rects[glyph_i].h); - } - - // 7. Allocate texture - atlas->TexHeight = (atlas->Flags & ImFontAtlasFlags_NoPowerOfTwoHeight) ? (atlas->TexHeight + 1) : ImUpperPowerOfTwo(atlas->TexHeight); - atlas->TexUvScale = ImVec2(1.0f / atlas->TexWidth, 1.0f / atlas->TexHeight); - atlas->TexPixelsAlpha8 = (unsigned char*)IM_ALLOC(atlas->TexWidth * atlas->TexHeight); - memset(atlas->TexPixelsAlpha8, 0, atlas->TexWidth * atlas->TexHeight); - spc.pixels = atlas->TexPixelsAlpha8; - spc.height = atlas->TexHeight; - - // 8. Render/rasterize font characters into the texture - for (int src_i = 0; src_i < src_tmp_array.Size; src_i++) - { - ImFontConfig& cfg = atlas->ConfigData[src_i]; - ImFontBuildSrcData& src_tmp = src_tmp_array[src_i]; - if (src_tmp.GlyphsCount == 0) - continue; - - stbtt_PackFontRangesRenderIntoRects(&spc, &src_tmp.FontInfo, &src_tmp.PackRange, 1, src_tmp.Rects); - - // Apply multiply operator - if (cfg.RasterizerMultiply != 1.0f) - { - unsigned char multiply_table[256]; - ImFontAtlasBuildMultiplyCalcLookupTable(multiply_table, cfg.RasterizerMultiply); - stbrp_rect* r = &src_tmp.Rects[0]; - for (int glyph_i = 0; glyph_i < src_tmp.GlyphsCount; glyph_i++, r++) - if (r->was_packed) - ImFontAtlasBuildMultiplyRectAlpha8(multiply_table, atlas->TexPixelsAlpha8, r->x, r->y, r->w, r->h, atlas->TexWidth * 1); - } - src_tmp.Rects = NULL; - } - - // End packing - stbtt_PackEnd(&spc); - buf_rects.clear(); - - // 9. Setup ImFont and glyphs for runtime - for (int src_i = 0; src_i < src_tmp_array.Size; src_i++) - { - ImFontBuildSrcData& src_tmp = src_tmp_array[src_i]; - if (src_tmp.GlyphsCount == 0) - continue; - - // When merging fonts with MergeMode=true: - // - We can have multiple input fonts writing into a same destination font. - // - dst_font->ConfigData is != from cfg which is our source configuration. - ImFontConfig& cfg = atlas->ConfigData[src_i]; - ImFont* dst_font = cfg.DstFont; - - const float font_scale = stbtt_ScaleForPixelHeight(&src_tmp.FontInfo, cfg.SizePixels); - int unscaled_ascent, unscaled_descent, unscaled_line_gap; - stbtt_GetFontVMetrics(&src_tmp.FontInfo, &unscaled_ascent, &unscaled_descent, &unscaled_line_gap); - - const float ascent = ImFloor(unscaled_ascent * font_scale + ((unscaled_ascent > 0.0f) ? +1 : -1)); - const float descent = ImFloor(unscaled_descent * font_scale + ((unscaled_descent > 0.0f) ? +1 : -1)); - ImFontAtlasBuildSetupFont(atlas, dst_font, &cfg, ascent, descent); - const float font_off_x = cfg.GlyphOffset.x; - const float font_off_y = cfg.GlyphOffset.y + IM_ROUND(dst_font->Ascent); - - for (int glyph_i = 0; glyph_i < src_tmp.GlyphsCount; glyph_i++) - { - // Register glyph - const int codepoint = src_tmp.GlyphsList[glyph_i]; - const stbtt_packedchar& pc = src_tmp.PackedChars[glyph_i]; - stbtt_aligned_quad q; - float unused_x = 0.0f, unused_y = 0.0f; - stbtt_GetPackedQuad(src_tmp.PackedChars, atlas->TexWidth, atlas->TexHeight, glyph_i, &unused_x, &unused_y, &q, 0); - dst_font->AddGlyph(&cfg, (ImWchar)codepoint, q.x0 + font_off_x, q.y0 + font_off_y, q.x1 + font_off_x, q.y1 + font_off_y, q.s0, q.t0, q.s1, q.t1, pc.xadvance); - } - } - - // Cleanup - src_tmp_array.clear_destruct(); - - ImFontAtlasBuildFinish(atlas); - return true; -} - -const ImFontBuilderIO* ImFontAtlasGetBuilderForStbTruetype() -{ - static ImFontBuilderIO io; - io.FontBuilder_Build = ImFontAtlasBuildWithStbTruetype; - return &io; -} - -#endif // IMGUI_ENABLE_STB_TRUETYPE - -void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent) -{ - if (!font_config->MergeMode) - { - font->ClearOutputData(); - font->FontSize = font_config->SizePixels; - font->ConfigData = font_config; - font->ConfigDataCount = 0; - font->ContainerAtlas = atlas; - font->Ascent = ascent; - font->Descent = descent; - } - font->ConfigDataCount++; -} - -void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* stbrp_context_opaque) -{ - stbrp_context* pack_context = (stbrp_context*)stbrp_context_opaque; - IM_ASSERT(pack_context != NULL); - - ImVector& user_rects = atlas->CustomRects; - IM_ASSERT(user_rects.Size >= 1); // We expect at least the default custom rects to be registered, else something went wrong. - - ImVector pack_rects; - pack_rects.resize(user_rects.Size); - memset(pack_rects.Data, 0, (size_t)pack_rects.size_in_bytes()); - for (int i = 0; i < user_rects.Size; i++) - { - pack_rects[i].w = user_rects[i].Width; - pack_rects[i].h = user_rects[i].Height; - } - stbrp_pack_rects(pack_context, &pack_rects[0], pack_rects.Size); - for (int i = 0; i < pack_rects.Size; i++) - if (pack_rects[i].was_packed) - { - user_rects[i].X = pack_rects[i].x; - user_rects[i].Y = pack_rects[i].y; - IM_ASSERT(pack_rects[i].w == user_rects[i].Width && pack_rects[i].h == user_rects[i].Height); - atlas->TexHeight = ImMax(atlas->TexHeight, pack_rects[i].y + pack_rects[i].h); - } -} - -void ImFontAtlasBuildRender8bppRectFromString(ImFontAtlas* atlas, int x, int y, int w, int h, const char* in_str, char in_marker_char, unsigned char in_marker_pixel_value) -{ - IM_ASSERT(x >= 0 && x + w <= atlas->TexWidth); - IM_ASSERT(y >= 0 && y + h <= atlas->TexHeight); - unsigned char* out_pixel = atlas->TexPixelsAlpha8 + x + (y * atlas->TexWidth); - for (int off_y = 0; off_y < h; off_y++, out_pixel += atlas->TexWidth, in_str += w) - for (int off_x = 0; off_x < w; off_x++) - out_pixel[off_x] = (in_str[off_x] == in_marker_char) ? in_marker_pixel_value : 0x00; -} - -void ImFontAtlasBuildRender32bppRectFromString(ImFontAtlas* atlas, int x, int y, int w, int h, const char* in_str, char in_marker_char, unsigned int in_marker_pixel_value) -{ - IM_ASSERT(x >= 0 && x + w <= atlas->TexWidth); - IM_ASSERT(y >= 0 && y + h <= atlas->TexHeight); - unsigned int* out_pixel = atlas->TexPixelsRGBA32 + x + (y * atlas->TexWidth); - for (int off_y = 0; off_y < h; off_y++, out_pixel += atlas->TexWidth, in_str += w) - for (int off_x = 0; off_x < w; off_x++) - out_pixel[off_x] = (in_str[off_x] == in_marker_char) ? in_marker_pixel_value : IM_COL32_BLACK_TRANS; -} - -static void ImFontAtlasBuildRenderDefaultTexData(ImFontAtlas* atlas) -{ - ImFontAtlasCustomRect* r = atlas->GetCustomRectByIndex(atlas->PackIdMouseCursors); - IM_ASSERT(r->IsPacked()); - - const int w = atlas->TexWidth; - if (!(atlas->Flags & ImFontAtlasFlags_NoMouseCursors)) - { - // Render/copy pixels - IM_ASSERT(r->Width == FONT_ATLAS_DEFAULT_TEX_DATA_W * 2 + 1 && r->Height == FONT_ATLAS_DEFAULT_TEX_DATA_H); - const int x_for_white = r->X; - const int x_for_black = r->X + FONT_ATLAS_DEFAULT_TEX_DATA_W + 1; - if (atlas->TexPixelsAlpha8 != NULL) - { - ImFontAtlasBuildRender8bppRectFromString(atlas, x_for_white, r->Y, FONT_ATLAS_DEFAULT_TEX_DATA_W, FONT_ATLAS_DEFAULT_TEX_DATA_H, FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS, '.', 0xFF); - ImFontAtlasBuildRender8bppRectFromString(atlas, x_for_black, r->Y, FONT_ATLAS_DEFAULT_TEX_DATA_W, FONT_ATLAS_DEFAULT_TEX_DATA_H, FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS, 'X', 0xFF); - } - else - { - ImFontAtlasBuildRender32bppRectFromString(atlas, x_for_white, r->Y, FONT_ATLAS_DEFAULT_TEX_DATA_W, FONT_ATLAS_DEFAULT_TEX_DATA_H, FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS, '.', IM_COL32_WHITE); - ImFontAtlasBuildRender32bppRectFromString(atlas, x_for_black, r->Y, FONT_ATLAS_DEFAULT_TEX_DATA_W, FONT_ATLAS_DEFAULT_TEX_DATA_H, FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS, 'X', IM_COL32_WHITE); - } - } - else - { - // Render 4 white pixels - IM_ASSERT(r->Width == 2 && r->Height == 2); - const int offset = (int)r->X + (int)r->Y * w; - if (atlas->TexPixelsAlpha8 != NULL) - { - atlas->TexPixelsAlpha8[offset] = atlas->TexPixelsAlpha8[offset + 1] = atlas->TexPixelsAlpha8[offset + w] = atlas->TexPixelsAlpha8[offset + w + 1] = 0xFF; - } - else - { - atlas->TexPixelsRGBA32[offset] = atlas->TexPixelsRGBA32[offset + 1] = atlas->TexPixelsRGBA32[offset + w] = atlas->TexPixelsRGBA32[offset + w + 1] = IM_COL32_WHITE; - } - } - atlas->TexUvWhitePixel = ImVec2((r->X + 0.5f) * atlas->TexUvScale.x, (r->Y + 0.5f) * atlas->TexUvScale.y); -} - -static void ImFontAtlasBuildRenderLinesTexData(ImFontAtlas* atlas) -{ - if (atlas->Flags & ImFontAtlasFlags_NoBakedLines) - return; - - // This generates a triangular shape in the texture, with the various line widths stacked on top of each other to allow interpolation between them - ImFontAtlasCustomRect* r = atlas->GetCustomRectByIndex(atlas->PackIdLines); - IM_ASSERT(r->IsPacked()); - for (unsigned int n = 0; n < IM_DRAWLIST_TEX_LINES_WIDTH_MAX + 1; n++) // +1 because of the zero-width row - { - // Each line consists of at least two empty pixels at the ends, with a line of solid pixels in the middle - unsigned int y = n; - unsigned int line_width = n; - unsigned int pad_left = (r->Width - line_width) / 2; - unsigned int pad_right = r->Width - (pad_left + line_width); - - // Write each slice - IM_ASSERT(pad_left + line_width + pad_right == r->Width && y < r->Height); // Make sure we're inside the texture bounds before we start writing pixels - if (atlas->TexPixelsAlpha8 != NULL) - { - unsigned char* write_ptr = &atlas->TexPixelsAlpha8[r->X + ((r->Y + y) * atlas->TexWidth)]; - for (unsigned int i = 0; i < pad_left; i++) - *(write_ptr + i) = 0x00; - - for (unsigned int i = 0; i < line_width; i++) - *(write_ptr + pad_left + i) = 0xFF; - - for (unsigned int i = 0; i < pad_right; i++) - *(write_ptr + pad_left + line_width + i) = 0x00; - } - else - { - unsigned int* write_ptr = &atlas->TexPixelsRGBA32[r->X + ((r->Y + y) * atlas->TexWidth)]; - for (unsigned int i = 0; i < pad_left; i++) - *(write_ptr + i) = IM_COL32_BLACK_TRANS; - - for (unsigned int i = 0; i < line_width; i++) - *(write_ptr + pad_left + i) = IM_COL32_WHITE; - - for (unsigned int i = 0; i < pad_right; i++) - *(write_ptr + pad_left + line_width + i) = IM_COL32_BLACK_TRANS; - } - - // Calculate UVs for this line - ImVec2 uv0 = ImVec2((float)(r->X + pad_left - 1), (float)(r->Y + y)) * atlas->TexUvScale; - ImVec2 uv1 = ImVec2((float)(r->X + pad_left + line_width + 1), (float)(r->Y + y + 1)) * atlas->TexUvScale; - float half_v = (uv0.y + uv1.y) * 0.5f; // Calculate a constant V in the middle of the row to avoid sampling artifacts - atlas->TexUvLines[n] = ImVec4(uv0.x, half_v, uv1.x, half_v); - } -} - -// Note: this is called / shared by both the stb_truetype and the FreeType builder -void ImFontAtlasBuildInit(ImFontAtlas* atlas) -{ - // Register texture region for mouse cursors or standard white pixels - if (atlas->PackIdMouseCursors < 0) - { - if (!(atlas->Flags & ImFontAtlasFlags_NoMouseCursors)) - atlas->PackIdMouseCursors = atlas->AddCustomRectRegular(FONT_ATLAS_DEFAULT_TEX_DATA_W * 2 + 1, FONT_ATLAS_DEFAULT_TEX_DATA_H); - else - atlas->PackIdMouseCursors = atlas->AddCustomRectRegular(2, 2); - } - - // Register texture region for thick lines - // The +2 here is to give space for the end caps, whilst height +1 is to accommodate the fact we have a zero-width row - if (atlas->PackIdLines < 0) - { - if (!(atlas->Flags & ImFontAtlasFlags_NoBakedLines)) - atlas->PackIdLines = atlas->AddCustomRectRegular(IM_DRAWLIST_TEX_LINES_WIDTH_MAX + 2, IM_DRAWLIST_TEX_LINES_WIDTH_MAX + 1); - } -} - -// This is called/shared by both the stb_truetype and the FreeType builder. -void ImFontAtlasBuildFinish(ImFontAtlas* atlas) -{ - // Render into our custom data blocks - IM_ASSERT(atlas->TexPixelsAlpha8 != NULL || atlas->TexPixelsRGBA32 != NULL); - ImFontAtlasBuildRenderDefaultTexData(atlas); - ImFontAtlasBuildRenderLinesTexData(atlas); - - // Register custom rectangle glyphs - for (int i = 0; i < atlas->CustomRects.Size; i++) - { - const ImFontAtlasCustomRect* r = &atlas->CustomRects[i]; - if (r->Font == NULL || r->GlyphID == 0) - continue; - - // Will ignore ImFontConfig settings: GlyphMinAdvanceX, GlyphMinAdvanceY, GlyphExtraSpacing, PixelSnapH - IM_ASSERT(r->Font->ContainerAtlas == atlas); - ImVec2 uv0, uv1; - atlas->CalcCustomRectUV(r, &uv0, &uv1); - r->Font->AddGlyph(NULL, (ImWchar)r->GlyphID, r->GlyphOffset.x, r->GlyphOffset.y, r->GlyphOffset.x + r->Width, r->GlyphOffset.y + r->Height, uv0.x, uv0.y, uv1.x, uv1.y, r->GlyphAdvanceX); - } - - // Build all fonts lookup tables - for (int i = 0; i < atlas->Fonts.Size; i++) - if (atlas->Fonts[i]->DirtyLookupTables) - atlas->Fonts[i]->BuildLookupTable(); - - atlas->TexReady = true; -} - -// Retrieve list of range (2 int per range, values are inclusive) -const ImWchar* ImFontAtlas::GetGlyphRangesDefault() -{ - static const ImWchar ranges[] = - { - 0x0020, 0x00FF, // Basic Latin + Latin Supplement - 0, - }; - return &ranges[0]; -} - -const ImWchar* ImFontAtlas::GetGlyphRangesKorean() -{ - static const ImWchar ranges[] = - { - 0x0020, 0x00FF, // Basic Latin + Latin Supplement - 0x3131, 0x3163, // Korean alphabets - 0xAC00, 0xD7A3, // Korean characters - 0xFFFD, 0xFFFD, // Invalid - 0, - }; - return &ranges[0]; -} - -const ImWchar* ImFontAtlas::GetGlyphRangesChineseFull() -{ - static const ImWchar ranges[] = - { - 0x0020, 0x00FF, // Basic Latin + Latin Supplement - 0x2000, 0x206F, // General Punctuation - 0x3000, 0x30FF, // CJK Symbols and Punctuations, Hiragana, Katakana - 0x31F0, 0x31FF, // Katakana Phonetic Extensions - 0xFF00, 0xFFEF, // Half-width characters - 0xFFFD, 0xFFFD, // Invalid - 0x4e00, 0x9FAF, // CJK Ideograms - 0, - }; - return &ranges[0]; -} - -static void UnpackAccumulativeOffsetsIntoRanges(int base_codepoint, const short* accumulative_offsets, int accumulative_offsets_count, ImWchar* out_ranges) -{ - for (int n = 0; n < accumulative_offsets_count; n++, out_ranges += 2) - { - out_ranges[0] = out_ranges[1] = (ImWchar)(base_codepoint + accumulative_offsets[n]); - base_codepoint += accumulative_offsets[n]; - } - out_ranges[0] = 0; -} - -//------------------------------------------------------------------------- -// [SECTION] ImFontAtlas glyph ranges helpers -//------------------------------------------------------------------------- - -const ImWchar* ImFontAtlas::GetGlyphRangesChineseSimplifiedCommon() -{ - // Store 2500 regularly used characters for Simplified Chinese. - // Sourced from https://zh.wiktionary.org/wiki/%E9%99%84%E5%BD%95:%E7%8E%B0%E4%BB%A3%E6%B1%89%E8%AF%AD%E5%B8%B8%E7%94%A8%E5%AD%97%E8%A1%A8 - // This table covers 97.97% of all characters used during the month in July, 1987. - // You can use ImFontGlyphRangesBuilder to create your own ranges derived from this, by merging existing ranges or adding new characters. - // (Stored as accumulative offsets from the initial unicode codepoint 0x4E00. This encoding is designed to helps us compact the source code size.) - static const short accumulative_offsets_from_0x4E00[] = - { - 0,1,2,4,1,1,1,1,2,1,3,2,1,2,2,1,1,1,1,1,5,2,1,2,3,3,3,2,2,4,1,1,1,2,1,5,2,3,1,2,1,2,1,1,2,1,1,2,2,1,4,1,1,1,1,5,10,1,2,19,2,1,2,1,2,1,2,1,2, - 1,5,1,6,3,2,1,2,2,1,1,1,4,8,5,1,1,4,1,1,3,1,2,1,5,1,2,1,1,1,10,1,1,5,2,4,6,1,4,2,2,2,12,2,1,1,6,1,1,1,4,1,1,4,6,5,1,4,2,2,4,10,7,1,1,4,2,4, - 2,1,4,3,6,10,12,5,7,2,14,2,9,1,1,6,7,10,4,7,13,1,5,4,8,4,1,1,2,28,5,6,1,1,5,2,5,20,2,2,9,8,11,2,9,17,1,8,6,8,27,4,6,9,20,11,27,6,68,2,2,1,1, - 1,2,1,2,2,7,6,11,3,3,1,1,3,1,2,1,1,1,1,1,3,1,1,8,3,4,1,5,7,2,1,4,4,8,4,2,1,2,1,1,4,5,6,3,6,2,12,3,1,3,9,2,4,3,4,1,5,3,3,1,3,7,1,5,1,1,1,1,2, - 3,4,5,2,3,2,6,1,1,2,1,7,1,7,3,4,5,15,2,2,1,5,3,22,19,2,1,1,1,1,2,5,1,1,1,6,1,1,12,8,2,9,18,22,4,1,1,5,1,16,1,2,7,10,15,1,1,6,2,4,1,2,4,1,6, - 1,1,3,2,4,1,6,4,5,1,2,1,1,2,1,10,3,1,3,2,1,9,3,2,5,7,2,19,4,3,6,1,1,1,1,1,4,3,2,1,1,1,2,5,3,1,1,1,2,2,1,1,2,1,1,2,1,3,1,1,1,3,7,1,4,1,1,2,1, - 1,2,1,2,4,4,3,8,1,1,1,2,1,3,5,1,3,1,3,4,6,2,2,14,4,6,6,11,9,1,15,3,1,28,5,2,5,5,3,1,3,4,5,4,6,14,3,2,3,5,21,2,7,20,10,1,2,19,2,4,28,28,2,3, - 2,1,14,4,1,26,28,42,12,40,3,52,79,5,14,17,3,2,2,11,3,4,6,3,1,8,2,23,4,5,8,10,4,2,7,3,5,1,1,6,3,1,2,2,2,5,28,1,1,7,7,20,5,3,29,3,17,26,1,8,4, - 27,3,6,11,23,5,3,4,6,13,24,16,6,5,10,25,35,7,3,2,3,3,14,3,6,2,6,1,4,2,3,8,2,1,1,3,3,3,4,1,1,13,2,2,4,5,2,1,14,14,1,2,2,1,4,5,2,3,1,14,3,12, - 3,17,2,16,5,1,2,1,8,9,3,19,4,2,2,4,17,25,21,20,28,75,1,10,29,103,4,1,2,1,1,4,2,4,1,2,3,24,2,2,2,1,1,2,1,3,8,1,1,1,2,1,1,3,1,1,1,6,1,5,3,1,1, - 1,3,4,1,1,5,2,1,5,6,13,9,16,1,1,1,1,3,2,3,2,4,5,2,5,2,2,3,7,13,7,2,2,1,1,1,1,2,3,3,2,1,6,4,9,2,1,14,2,14,2,1,18,3,4,14,4,11,41,15,23,15,23, - 176,1,3,4,1,1,1,1,5,3,1,2,3,7,3,1,1,2,1,2,4,4,6,2,4,1,9,7,1,10,5,8,16,29,1,1,2,2,3,1,3,5,2,4,5,4,1,1,2,2,3,3,7,1,6,10,1,17,1,44,4,6,2,1,1,6, - 5,4,2,10,1,6,9,2,8,1,24,1,2,13,7,8,8,2,1,4,1,3,1,3,3,5,2,5,10,9,4,9,12,2,1,6,1,10,1,1,7,7,4,10,8,3,1,13,4,3,1,6,1,3,5,2,1,2,17,16,5,2,16,6, - 1,4,2,1,3,3,6,8,5,11,11,1,3,3,2,4,6,10,9,5,7,4,7,4,7,1,1,4,2,1,3,6,8,7,1,6,11,5,5,3,24,9,4,2,7,13,5,1,8,82,16,61,1,1,1,4,2,2,16,10,3,8,1,1, - 6,4,2,1,3,1,1,1,4,3,8,4,2,2,1,1,1,1,1,6,3,5,1,1,4,6,9,2,1,1,1,2,1,7,2,1,6,1,5,4,4,3,1,8,1,3,3,1,3,2,2,2,2,3,1,6,1,2,1,2,1,3,7,1,8,2,1,2,1,5, - 2,5,3,5,10,1,2,1,1,3,2,5,11,3,9,3,5,1,1,5,9,1,2,1,5,7,9,9,8,1,3,3,3,6,8,2,3,2,1,1,32,6,1,2,15,9,3,7,13,1,3,10,13,2,14,1,13,10,2,1,3,10,4,15, - 2,15,15,10,1,3,9,6,9,32,25,26,47,7,3,2,3,1,6,3,4,3,2,8,5,4,1,9,4,2,2,19,10,6,2,3,8,1,2,2,4,2,1,9,4,4,4,6,4,8,9,2,3,1,1,1,1,3,5,5,1,3,8,4,6, - 2,1,4,12,1,5,3,7,13,2,5,8,1,6,1,2,5,14,6,1,5,2,4,8,15,5,1,23,6,62,2,10,1,1,8,1,2,2,10,4,2,2,9,2,1,1,3,2,3,1,5,3,3,2,1,3,8,1,1,1,11,3,1,1,4, - 3,7,1,14,1,2,3,12,5,2,5,1,6,7,5,7,14,11,1,3,1,8,9,12,2,1,11,8,4,4,2,6,10,9,13,1,1,3,1,5,1,3,2,4,4,1,18,2,3,14,11,4,29,4,2,7,1,3,13,9,2,2,5, - 3,5,20,7,16,8,5,72,34,6,4,22,12,12,28,45,36,9,7,39,9,191,1,1,1,4,11,8,4,9,2,3,22,1,1,1,1,4,17,1,7,7,1,11,31,10,2,4,8,2,3,2,1,4,2,16,4,32,2, - 3,19,13,4,9,1,5,2,14,8,1,1,3,6,19,6,5,1,16,6,2,10,8,5,1,2,3,1,5,5,1,11,6,6,1,3,3,2,6,3,8,1,1,4,10,7,5,7,7,5,8,9,2,1,3,4,1,1,3,1,3,3,2,6,16, - 1,4,6,3,1,10,6,1,3,15,2,9,2,10,25,13,9,16,6,2,2,10,11,4,3,9,1,2,6,6,5,4,30,40,1,10,7,12,14,33,6,3,6,7,3,1,3,1,11,14,4,9,5,12,11,49,18,51,31, - 140,31,2,2,1,5,1,8,1,10,1,4,4,3,24,1,10,1,3,6,6,16,3,4,5,2,1,4,2,57,10,6,22,2,22,3,7,22,6,10,11,36,18,16,33,36,2,5,5,1,1,1,4,10,1,4,13,2,7, - 5,2,9,3,4,1,7,43,3,7,3,9,14,7,9,1,11,1,1,3,7,4,18,13,1,14,1,3,6,10,73,2,2,30,6,1,11,18,19,13,22,3,46,42,37,89,7,3,16,34,2,2,3,9,1,7,1,1,1,2, - 2,4,10,7,3,10,3,9,5,28,9,2,6,13,7,3,1,3,10,2,7,2,11,3,6,21,54,85,2,1,4,2,2,1,39,3,21,2,2,5,1,1,1,4,1,1,3,4,15,1,3,2,4,4,2,3,8,2,20,1,8,7,13, - 4,1,26,6,2,9,34,4,21,52,10,4,4,1,5,12,2,11,1,7,2,30,12,44,2,30,1,1,3,6,16,9,17,39,82,2,2,24,7,1,7,3,16,9,14,44,2,1,2,1,2,3,5,2,4,1,6,7,5,3, - 2,6,1,11,5,11,2,1,18,19,8,1,3,24,29,2,1,3,5,2,2,1,13,6,5,1,46,11,3,5,1,1,5,8,2,10,6,12,6,3,7,11,2,4,16,13,2,5,1,1,2,2,5,2,28,5,2,23,10,8,4, - 4,22,39,95,38,8,14,9,5,1,13,5,4,3,13,12,11,1,9,1,27,37,2,5,4,4,63,211,95,2,2,2,1,3,5,2,1,1,2,2,1,1,1,3,2,4,1,2,1,1,5,2,2,1,1,2,3,1,3,1,1,1, - 3,1,4,2,1,3,6,1,1,3,7,15,5,3,2,5,3,9,11,4,2,22,1,6,3,8,7,1,4,28,4,16,3,3,25,4,4,27,27,1,4,1,2,2,7,1,3,5,2,28,8,2,14,1,8,6,16,25,3,3,3,14,3, - 3,1,1,2,1,4,6,3,8,4,1,1,1,2,3,6,10,6,2,3,18,3,2,5,5,4,3,1,5,2,5,4,23,7,6,12,6,4,17,11,9,5,1,1,10,5,12,1,1,11,26,33,7,3,6,1,17,7,1,5,12,1,11, - 2,4,1,8,14,17,23,1,2,1,7,8,16,11,9,6,5,2,6,4,16,2,8,14,1,11,8,9,1,1,1,9,25,4,11,19,7,2,15,2,12,8,52,7,5,19,2,16,4,36,8,1,16,8,24,26,4,6,2,9, - 5,4,36,3,28,12,25,15,37,27,17,12,59,38,5,32,127,1,2,9,17,14,4,1,2,1,1,8,11,50,4,14,2,19,16,4,17,5,4,5,26,12,45,2,23,45,104,30,12,8,3,10,2,2, - 3,3,1,4,20,7,2,9,6,15,2,20,1,3,16,4,11,15,6,134,2,5,59,1,2,2,2,1,9,17,3,26,137,10,211,59,1,2,4,1,4,1,1,1,2,6,2,3,1,1,2,3,2,3,1,3,4,4,2,3,3, - 1,4,3,1,7,2,2,3,1,2,1,3,3,3,2,2,3,2,1,3,14,6,1,3,2,9,6,15,27,9,34,145,1,1,2,1,1,1,1,2,1,1,1,1,2,2,2,3,1,2,1,1,1,2,3,5,8,3,5,2,4,1,3,2,2,2,12, - 4,1,1,1,10,4,5,1,20,4,16,1,15,9,5,12,2,9,2,5,4,2,26,19,7,1,26,4,30,12,15,42,1,6,8,172,1,1,4,2,1,1,11,2,2,4,2,1,2,1,10,8,1,2,1,4,5,1,2,5,1,8, - 4,1,3,4,2,1,6,2,1,3,4,1,2,1,1,1,1,12,5,7,2,4,3,1,1,1,3,3,6,1,2,2,3,3,3,2,1,2,12,14,11,6,6,4,12,2,8,1,7,10,1,35,7,4,13,15,4,3,23,21,28,52,5, - 26,5,6,1,7,10,2,7,53,3,2,1,1,1,2,163,532,1,10,11,1,3,3,4,8,2,8,6,2,2,23,22,4,2,2,4,2,1,3,1,3,3,5,9,8,2,1,2,8,1,10,2,12,21,20,15,105,2,3,1,1, - 3,2,3,1,1,2,5,1,4,15,11,19,1,1,1,1,5,4,5,1,1,2,5,3,5,12,1,2,5,1,11,1,1,15,9,1,4,5,3,26,8,2,1,3,1,1,15,19,2,12,1,2,5,2,7,2,19,2,20,6,26,7,5, - 2,2,7,34,21,13,70,2,128,1,1,2,1,1,2,1,1,3,2,2,2,15,1,4,1,3,4,42,10,6,1,49,85,8,1,2,1,1,4,4,2,3,6,1,5,7,4,3,211,4,1,2,1,2,5,1,2,4,2,2,6,5,6, - 10,3,4,48,100,6,2,16,296,5,27,387,2,2,3,7,16,8,5,38,15,39,21,9,10,3,7,59,13,27,21,47,5,21,6 - }; - static ImWchar base_ranges[] = // not zero-terminated - { - 0x0020, 0x00FF, // Basic Latin + Latin Supplement - 0x2000, 0x206F, // General Punctuation - 0x3000, 0x30FF, // CJK Symbols and Punctuations, Hiragana, Katakana - 0x31F0, 0x31FF, // Katakana Phonetic Extensions - 0xFF00, 0xFFEF, // Half-width characters - 0xFFFD, 0xFFFD // Invalid - }; - static ImWchar full_ranges[IM_ARRAYSIZE(base_ranges) + IM_ARRAYSIZE(accumulative_offsets_from_0x4E00) * 2 + 1] = { 0 }; - if (!full_ranges[0]) - { - memcpy(full_ranges, base_ranges, sizeof(base_ranges)); - UnpackAccumulativeOffsetsIntoRanges(0x4E00, accumulative_offsets_from_0x4E00, IM_ARRAYSIZE(accumulative_offsets_from_0x4E00), full_ranges + IM_ARRAYSIZE(base_ranges)); - } - return &full_ranges[0]; -} - -const ImWchar* ImFontAtlas::GetGlyphRangesJapanese() -{ - // 2999 ideograms code points for Japanese - // - 2136 Joyo (meaning "for regular use" or "for common use") Kanji code points - // - 863 Jinmeiyo (meaning "for personal name") Kanji code points - // - Sourced from the character information database of the Information-technology Promotion Agency, Japan - // - https://mojikiban.ipa.go.jp/mji/ - // - Available under the terms of the Creative Commons Attribution-ShareAlike 2.1 Japan (CC BY-SA 2.1 JP). - // - https://creativecommons.org/licenses/by-sa/2.1/jp/deed.en - // - https://creativecommons.org/licenses/by-sa/2.1/jp/legalcode - // - You can generate this code by the script at: - // - https://github.com/vaiorabbit/everyday_use_kanji - // - References: - // - List of Joyo Kanji - // - (Official list by the Agency for Cultural Affairs) https://www.bunka.go.jp/kokugo_nihongo/sisaku/joho/joho/kakuki/14/tosin02/index.html - // - (Wikipedia) https://en.wikipedia.org/wiki/List_of_j%C5%8Dy%C5%8D_kanji - // - List of Jinmeiyo Kanji - // - (Official list by the Ministry of Justice) http://www.moj.go.jp/MINJI/minji86.html - // - (Wikipedia) https://en.wikipedia.org/wiki/Jinmeiy%C5%8D_kanji - // - Missing 1 Joyo Kanji: U+20B9F (Kun'yomi: Shikaru, On'yomi: Shitsu,shichi), see https://github.com/ocornut/imgui/pull/3627 for details. - // You can use ImFontGlyphRangesBuilder to create your own ranges derived from this, by merging existing ranges or adding new characters. - // (Stored as accumulative offsets from the initial unicode codepoint 0x4E00. This encoding is designed to helps us compact the source code size.) - static const short accumulative_offsets_from_0x4E00[] = - { - 0,1,2,4,1,1,1,1,2,1,3,3,2,2,1,5,3,5,7,5,6,1,2,1,7,2,6,3,1,8,1,1,4,1,1,18,2,11,2,6,2,1,2,1,5,1,2,1,3,1,2,1,2,3,3,1,1,2,3,1,1,1,12,7,9,1,4,5,1, - 1,2,1,10,1,1,9,2,2,4,5,6,9,3,1,1,1,1,9,3,18,5,2,2,2,2,1,6,3,7,1,1,1,1,2,2,4,2,1,23,2,10,4,3,5,2,4,10,2,4,13,1,6,1,9,3,1,1,6,6,7,6,3,1,2,11,3, - 2,2,3,2,15,2,2,5,4,3,6,4,1,2,5,2,12,16,6,13,9,13,2,1,1,7,16,4,7,1,19,1,5,1,2,2,7,7,8,2,6,5,4,9,18,7,4,5,9,13,11,8,15,2,1,1,1,2,1,2,2,1,2,2,8, - 2,9,3,3,1,1,4,4,1,1,1,4,9,1,4,3,5,5,2,7,5,3,4,8,2,1,13,2,3,3,1,14,1,1,4,5,1,3,6,1,5,2,1,1,3,3,3,3,1,1,2,7,6,6,7,1,4,7,6,1,1,1,1,1,12,3,3,9,5, - 2,6,1,5,6,1,2,3,18,2,4,14,4,1,3,6,1,1,6,3,5,5,3,2,2,2,2,12,3,1,4,2,3,2,3,11,1,7,4,1,2,1,3,17,1,9,1,24,1,1,4,2,2,4,1,2,7,1,1,1,3,1,2,2,4,15,1, - 1,2,1,1,2,1,5,2,5,20,2,5,9,1,10,8,7,6,1,1,1,1,1,1,6,2,1,2,8,1,1,1,1,5,1,1,3,1,1,1,1,3,1,1,12,4,1,3,1,1,1,1,1,10,3,1,7,5,13,1,2,3,4,6,1,1,30, - 2,9,9,1,15,38,11,3,1,8,24,7,1,9,8,10,2,1,9,31,2,13,6,2,9,4,49,5,2,15,2,1,10,2,1,1,1,2,2,6,15,30,35,3,14,18,8,1,16,10,28,12,19,45,38,1,3,2,3, - 13,2,1,7,3,6,5,3,4,3,1,5,7,8,1,5,3,18,5,3,6,1,21,4,24,9,24,40,3,14,3,21,3,2,1,2,4,2,3,1,15,15,6,5,1,1,3,1,5,6,1,9,7,3,3,2,1,4,3,8,21,5,16,4, - 5,2,10,11,11,3,6,3,2,9,3,6,13,1,2,1,1,1,1,11,12,6,6,1,4,2,6,5,2,1,1,3,3,6,13,3,1,1,5,1,2,3,3,14,2,1,2,2,2,5,1,9,5,1,1,6,12,3,12,3,4,13,2,14, - 2,8,1,17,5,1,16,4,2,2,21,8,9,6,23,20,12,25,19,9,38,8,3,21,40,25,33,13,4,3,1,4,1,2,4,1,2,5,26,2,1,1,2,1,3,6,2,1,1,1,1,1,1,2,3,1,1,1,9,2,3,1,1, - 1,3,6,3,2,1,1,6,6,1,8,2,2,2,1,4,1,2,3,2,7,3,2,4,1,2,1,2,2,1,1,1,1,1,3,1,2,5,4,10,9,4,9,1,1,1,1,1,1,5,3,2,1,6,4,9,6,1,10,2,31,17,8,3,7,5,40,1, - 7,7,1,6,5,2,10,7,8,4,15,39,25,6,28,47,18,10,7,1,3,1,1,2,1,1,1,3,3,3,1,1,1,3,4,2,1,4,1,3,6,10,7,8,6,2,2,1,3,3,2,5,8,7,9,12,2,15,1,1,4,1,2,1,1, - 1,3,2,1,3,3,5,6,2,3,2,10,1,4,2,8,1,1,1,11,6,1,21,4,16,3,1,3,1,4,2,3,6,5,1,3,1,1,3,3,4,6,1,1,10,4,2,7,10,4,7,4,2,9,4,3,1,1,1,4,1,8,3,4,1,3,1, - 6,1,4,2,1,4,7,2,1,8,1,4,5,1,1,2,2,4,6,2,7,1,10,1,1,3,4,11,10,8,21,4,6,1,3,5,2,1,2,28,5,5,2,3,13,1,2,3,1,4,2,1,5,20,3,8,11,1,3,3,3,1,8,10,9,2, - 10,9,2,3,1,1,2,4,1,8,3,6,1,7,8,6,11,1,4,29,8,4,3,1,2,7,13,1,4,1,6,2,6,12,12,2,20,3,2,3,6,4,8,9,2,7,34,5,1,18,6,1,1,4,4,5,7,9,1,2,2,4,3,4,1,7, - 2,2,2,6,2,3,25,5,3,6,1,4,6,7,4,2,1,4,2,13,6,4,4,3,1,5,3,4,4,3,2,1,1,4,1,2,1,1,3,1,11,1,6,3,1,7,3,6,2,8,8,6,9,3,4,11,3,2,10,12,2,5,11,1,6,4,5, - 3,1,8,5,4,6,6,3,5,1,1,3,2,1,2,2,6,17,12,1,10,1,6,12,1,6,6,19,9,6,16,1,13,4,4,15,7,17,6,11,9,15,12,6,7,2,1,2,2,15,9,3,21,4,6,49,18,7,3,2,3,1, - 6,8,2,2,6,2,9,1,3,6,4,4,1,2,16,2,5,2,1,6,2,3,5,3,1,2,5,1,2,1,9,3,1,8,6,4,8,11,3,1,1,1,1,3,1,13,8,4,1,3,2,2,1,4,1,11,1,5,2,1,5,2,5,8,6,1,1,7, - 4,3,8,3,2,7,2,1,5,1,5,2,4,7,6,2,8,5,1,11,4,5,3,6,18,1,2,13,3,3,1,21,1,1,4,1,4,1,1,1,8,1,2,2,7,1,2,4,2,2,9,2,1,1,1,4,3,6,3,12,5,1,1,1,5,6,3,2, - 4,8,2,2,4,2,7,1,8,9,5,2,3,2,1,3,2,13,7,14,6,5,1,1,2,1,4,2,23,2,1,1,6,3,1,4,1,15,3,1,7,3,9,14,1,3,1,4,1,1,5,8,1,3,8,3,8,15,11,4,14,4,4,2,5,5, - 1,7,1,6,14,7,7,8,5,15,4,8,6,5,6,2,1,13,1,20,15,11,9,2,5,6,2,11,2,6,2,5,1,5,8,4,13,19,25,4,1,1,11,1,34,2,5,9,14,6,2,2,6,1,1,14,1,3,14,13,1,6, - 12,21,14,14,6,32,17,8,32,9,28,1,2,4,11,8,3,1,14,2,5,15,1,1,1,1,3,6,4,1,3,4,11,3,1,1,11,30,1,5,1,4,1,5,8,1,1,3,2,4,3,17,35,2,6,12,17,3,1,6,2, - 1,1,12,2,7,3,3,2,1,16,2,8,3,6,5,4,7,3,3,8,1,9,8,5,1,2,1,3,2,8,1,2,9,12,1,1,2,3,8,3,24,12,4,3,7,5,8,3,3,3,3,3,3,1,23,10,3,1,2,2,6,3,1,16,1,16, - 22,3,10,4,11,6,9,7,7,3,6,2,2,2,4,10,2,1,1,2,8,7,1,6,4,1,3,3,3,5,10,12,12,2,3,12,8,15,1,1,16,6,6,1,5,9,11,4,11,4,2,6,12,1,17,5,13,1,4,9,5,1,11, - 2,1,8,1,5,7,28,8,3,5,10,2,17,3,38,22,1,2,18,12,10,4,38,18,1,4,44,19,4,1,8,4,1,12,1,4,31,12,1,14,7,75,7,5,10,6,6,13,3,2,11,11,3,2,5,28,15,6,18, - 18,5,6,4,3,16,1,7,18,7,36,3,5,3,1,7,1,9,1,10,7,2,4,2,6,2,9,7,4,3,32,12,3,7,10,2,23,16,3,1,12,3,31,4,11,1,3,8,9,5,1,30,15,6,12,3,2,2,11,19,9, - 14,2,6,2,3,19,13,17,5,3,3,25,3,14,1,1,1,36,1,3,2,19,3,13,36,9,13,31,6,4,16,34,2,5,4,2,3,3,5,1,1,1,4,3,1,17,3,2,3,5,3,1,3,2,3,5,6,3,12,11,1,3, - 1,2,26,7,12,7,2,14,3,3,7,7,11,25,25,28,16,4,36,1,2,1,6,2,1,9,3,27,17,4,3,4,13,4,1,3,2,2,1,10,4,2,4,6,3,8,2,1,18,1,1,24,2,2,4,33,2,3,63,7,1,6, - 40,7,3,4,4,2,4,15,18,1,16,1,1,11,2,41,14,1,3,18,13,3,2,4,16,2,17,7,15,24,7,18,13,44,2,2,3,6,1,1,7,5,1,7,1,4,3,3,5,10,8,2,3,1,8,1,1,27,4,2,1, - 12,1,2,1,10,6,1,6,7,5,2,3,7,11,5,11,3,6,6,2,3,15,4,9,1,1,2,1,2,11,2,8,12,8,5,4,2,3,1,5,2,2,1,14,1,12,11,4,1,11,17,17,4,3,2,5,5,7,3,1,5,9,9,8, - 2,5,6,6,13,13,2,1,2,6,1,2,2,49,4,9,1,2,10,16,7,8,4,3,2,23,4,58,3,29,1,14,19,19,11,11,2,7,5,1,3,4,6,2,18,5,12,12,17,17,3,3,2,4,1,6,2,3,4,3,1, - 1,1,1,5,1,1,9,1,3,1,3,6,1,8,1,1,2,6,4,14,3,1,4,11,4,1,3,32,1,2,4,13,4,1,2,4,2,1,3,1,11,1,4,2,1,4,4,6,3,5,1,6,5,7,6,3,23,3,5,3,5,3,3,13,3,9,10, - 1,12,10,2,3,18,13,7,160,52,4,2,2,3,2,14,5,4,12,4,6,4,1,20,4,11,6,2,12,27,1,4,1,2,2,7,4,5,2,28,3,7,25,8,3,19,3,6,10,2,2,1,10,2,5,4,1,3,4,1,5, - 3,2,6,9,3,6,2,16,3,3,16,4,5,5,3,2,1,2,16,15,8,2,6,21,2,4,1,22,5,8,1,1,21,11,2,1,11,11,19,13,12,4,2,3,2,3,6,1,8,11,1,4,2,9,5,2,1,11,2,9,1,1,2, - 14,31,9,3,4,21,14,4,8,1,7,2,2,2,5,1,4,20,3,3,4,10,1,11,9,8,2,1,4,5,14,12,14,2,17,9,6,31,4,14,1,20,13,26,5,2,7,3,6,13,2,4,2,19,6,2,2,18,9,3,5, - 12,12,14,4,6,2,3,6,9,5,22,4,5,25,6,4,8,5,2,6,27,2,35,2,16,3,7,8,8,6,6,5,9,17,2,20,6,19,2,13,3,1,1,1,4,17,12,2,14,7,1,4,18,12,38,33,2,10,1,1, - 2,13,14,17,11,50,6,33,20,26,74,16,23,45,50,13,38,33,6,6,7,4,4,2,1,3,2,5,8,7,8,9,3,11,21,9,13,1,3,10,6,7,1,2,2,18,5,5,1,9,9,2,68,9,19,13,2,5, - 1,4,4,7,4,13,3,9,10,21,17,3,26,2,1,5,2,4,5,4,1,7,4,7,3,4,2,1,6,1,1,20,4,1,9,2,2,1,3,3,2,3,2,1,1,1,20,2,3,1,6,2,3,6,2,4,8,1,3,2,10,3,5,3,4,4, - 3,4,16,1,6,1,10,2,4,2,1,1,2,10,11,2,2,3,1,24,31,4,10,10,2,5,12,16,164,15,4,16,7,9,15,19,17,1,2,1,1,5,1,1,1,1,1,3,1,4,3,1,3,1,3,1,2,1,1,3,3,7, - 2,8,1,2,2,2,1,3,4,3,7,8,12,92,2,10,3,1,3,14,5,25,16,42,4,7,7,4,2,21,5,27,26,27,21,25,30,31,2,1,5,13,3,22,5,6,6,11,9,12,1,5,9,7,5,5,22,60,3,5, - 13,1,1,8,1,1,3,3,2,1,9,3,3,18,4,1,2,3,7,6,3,1,2,3,9,1,3,1,3,2,1,3,1,1,1,2,1,11,3,1,6,9,1,3,2,3,1,2,1,5,1,1,4,3,4,1,2,2,4,4,1,7,2,1,2,2,3,5,13, - 18,3,4,14,9,9,4,16,3,7,5,8,2,6,48,28,3,1,1,4,2,14,8,2,9,2,1,15,2,4,3,2,10,16,12,8,7,1,1,3,1,1,1,2,7,4,1,6,4,38,39,16,23,7,15,15,3,2,12,7,21, - 37,27,6,5,4,8,2,10,8,8,6,5,1,2,1,3,24,1,16,17,9,23,10,17,6,1,51,55,44,13,294,9,3,6,2,4,2,2,15,1,1,1,13,21,17,68,14,8,9,4,1,4,9,3,11,7,1,1,1, - 5,6,3,2,1,1,1,2,3,8,1,2,2,4,1,5,5,2,1,4,3,7,13,4,1,4,1,3,1,1,1,5,5,10,1,6,1,5,2,1,5,2,4,1,4,5,7,3,18,2,9,11,32,4,3,3,2,4,7,11,16,9,11,8,13,38, - 32,8,4,2,1,1,2,1,2,4,4,1,1,1,4,1,21,3,11,1,16,1,1,6,1,3,2,4,9,8,57,7,44,1,3,3,13,3,10,1,1,7,5,2,7,21,47,63,3,15,4,7,1,16,1,1,2,8,2,3,42,15,4, - 1,29,7,22,10,3,78,16,12,20,18,4,67,11,5,1,3,15,6,21,31,32,27,18,13,71,35,5,142,4,10,1,2,50,19,33,16,35,37,16,19,27,7,1,133,19,1,4,8,7,20,1,4, - 4,1,10,3,1,6,1,2,51,5,40,15,24,43,22928,11,1,13,154,70,3,1,1,7,4,10,1,2,1,1,2,1,2,1,2,2,1,1,2,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1, - 3,2,1,1,1,1,2,1,1, - }; - static ImWchar base_ranges[] = // not zero-terminated - { - 0x0020, 0x00FF, // Basic Latin + Latin Supplement - 0x3000, 0x30FF, // CJK Symbols and Punctuations, Hiragana, Katakana - 0x31F0, 0x31FF, // Katakana Phonetic Extensions - 0xFF00, 0xFFEF, // Half-width characters - 0xFFFD, 0xFFFD // Invalid - }; - static ImWchar full_ranges[IM_ARRAYSIZE(base_ranges) + IM_ARRAYSIZE(accumulative_offsets_from_0x4E00)*2 + 1] = { 0 }; - if (!full_ranges[0]) - { - memcpy(full_ranges, base_ranges, sizeof(base_ranges)); - UnpackAccumulativeOffsetsIntoRanges(0x4E00, accumulative_offsets_from_0x4E00, IM_ARRAYSIZE(accumulative_offsets_from_0x4E00), full_ranges + IM_ARRAYSIZE(base_ranges)); - } - return &full_ranges[0]; -} - -const ImWchar* ImFontAtlas::GetGlyphRangesCyrillic() -{ - static const ImWchar ranges[] = - { - 0x0020, 0x00FF, // Basic Latin + Latin Supplement - 0x0400, 0x052F, // Cyrillic + Cyrillic Supplement - 0x2DE0, 0x2DFF, // Cyrillic Extended-A - 0xA640, 0xA69F, // Cyrillic Extended-B - 0, - }; - return &ranges[0]; -} - -const ImWchar* ImFontAtlas::GetGlyphRangesThai() -{ - static const ImWchar ranges[] = - { - 0x0020, 0x00FF, // Basic Latin - 0x2010, 0x205E, // Punctuations - 0x0E00, 0x0E7F, // Thai - 0, - }; - return &ranges[0]; -} - -const ImWchar* ImFontAtlas::GetGlyphRangesVietnamese() -{ - static const ImWchar ranges[] = - { - 0x0020, 0x00FF, // Basic Latin - 0x0102, 0x0103, - 0x0110, 0x0111, - 0x0128, 0x0129, - 0x0168, 0x0169, - 0x01A0, 0x01A1, - 0x01AF, 0x01B0, - 0x1EA0, 0x1EF9, - 0, - }; - return &ranges[0]; -} - -//----------------------------------------------------------------------------- -// [SECTION] ImFontGlyphRangesBuilder -//----------------------------------------------------------------------------- - -void ImFontGlyphRangesBuilder::AddText(const char* text, const char* text_end) -{ - while (text_end ? (text < text_end) : *text) - { - unsigned int c = 0; - int c_len = ImTextCharFromUtf8(&c, text, text_end); - text += c_len; - if (c_len == 0) - break; - AddChar((ImWchar)c); - } -} - -void ImFontGlyphRangesBuilder::AddRanges(const ImWchar* ranges) -{ - for (; ranges[0]; ranges += 2) - for (ImWchar c = ranges[0]; c <= ranges[1]; c++) - AddChar(c); -} - -void ImFontGlyphRangesBuilder::BuildRanges(ImVector* out_ranges) -{ - const int max_codepoint = IM_UNICODE_CODEPOINT_MAX; - for (int n = 0; n <= max_codepoint; n++) - if (GetBit(n)) - { - out_ranges->push_back((ImWchar)n); - while (n < max_codepoint && GetBit(n + 1)) - n++; - out_ranges->push_back((ImWchar)n); - } - out_ranges->push_back(0); -} - -//----------------------------------------------------------------------------- -// [SECTION] ImFont -//----------------------------------------------------------------------------- - -ImFont::ImFont() -{ - FontSize = 0.0f; - FallbackAdvanceX = 0.0f; - FallbackChar = (ImWchar)-1; - EllipsisChar = (ImWchar)-1; - DotChar = (ImWchar)-1; - FallbackGlyph = NULL; - ContainerAtlas = NULL; - ConfigData = NULL; - ConfigDataCount = 0; - DirtyLookupTables = false; - Scale = 1.0f; - Ascent = Descent = 0.0f; - MetricsTotalSurface = 0; - memset(Used4kPagesMap, 0, sizeof(Used4kPagesMap)); -} - -ImFont::~ImFont() -{ - ClearOutputData(); -} - -void ImFont::ClearOutputData() -{ - FontSize = 0.0f; - FallbackAdvanceX = 0.0f; - Glyphs.clear(); - IndexAdvanceX.clear(); - IndexLookup.clear(); - FallbackGlyph = NULL; - ContainerAtlas = NULL; - DirtyLookupTables = true; - Ascent = Descent = 0.0f; - MetricsTotalSurface = 0; -} - -static ImWchar FindFirstExistingGlyph(ImFont* font, const ImWchar* candidate_chars, int candidate_chars_count) -{ - for (int n = 0; n < candidate_chars_count; n++) - if (font->FindGlyphNoFallback(candidate_chars[n]) != NULL) - return candidate_chars[n]; - return (ImWchar)-1; -} - -void ImFont::BuildLookupTable() -{ - int max_codepoint = 0; - for (int i = 0; i != Glyphs.Size; i++) - max_codepoint = ImMax(max_codepoint, (int)Glyphs[i].Codepoint); - - // Build lookup table - IM_ASSERT(Glyphs.Size < 0xFFFF); // -1 is reserved - IndexAdvanceX.clear(); - IndexLookup.clear(); - DirtyLookupTables = false; - memset(Used4kPagesMap, 0, sizeof(Used4kPagesMap)); - GrowIndex(max_codepoint + 1); - for (int i = 0; i < Glyphs.Size; i++) - { - int codepoint = (int)Glyphs[i].Codepoint; - IndexAdvanceX[codepoint] = Glyphs[i].AdvanceX; - IndexLookup[codepoint] = (ImWchar)i; - - // Mark 4K page as used - const int page_n = codepoint / 4096; - Used4kPagesMap[page_n >> 3] |= 1 << (page_n & 7); - } - - // Create a glyph to handle TAB - // FIXME: Needs proper TAB handling but it needs to be contextualized (or we could arbitrary say that each string starts at "column 0" ?) - if (FindGlyph((ImWchar)' ')) - { - if (Glyphs.back().Codepoint != '\t') // So we can call this function multiple times (FIXME: Flaky) - Glyphs.resize(Glyphs.Size + 1); - ImFontGlyph& tab_glyph = Glyphs.back(); - tab_glyph = *FindGlyph((ImWchar)' '); - tab_glyph.Codepoint = '\t'; - tab_glyph.AdvanceX *= IM_TABSIZE; - IndexAdvanceX[(int)tab_glyph.Codepoint] = (float)tab_glyph.AdvanceX; - IndexLookup[(int)tab_glyph.Codepoint] = (ImWchar)(Glyphs.Size - 1); - } - - // Mark special glyphs as not visible (note that AddGlyph already mark as non-visible glyphs with zero-size polygons) - SetGlyphVisible((ImWchar)' ', false); - SetGlyphVisible((ImWchar)'\t', false); - - // Ellipsis character is required for rendering elided text. We prefer using U+2026 (horizontal ellipsis). - // However some old fonts may contain ellipsis at U+0085. Here we auto-detect most suitable ellipsis character. - // FIXME: Note that 0x2026 is rarely included in our font ranges. Because of this we are more likely to use three individual dots. - const ImWchar ellipsis_chars[] = { (ImWchar)0x2026, (ImWchar)0x0085 }; - const ImWchar dots_chars[] = { (ImWchar)'.', (ImWchar)0xFF0E }; - if (EllipsisChar == (ImWchar)-1) - EllipsisChar = FindFirstExistingGlyph(this, ellipsis_chars, IM_ARRAYSIZE(ellipsis_chars)); - if (DotChar == (ImWchar)-1) - DotChar = FindFirstExistingGlyph(this, dots_chars, IM_ARRAYSIZE(dots_chars)); - - // Setup fallback character - const ImWchar fallback_chars[] = { (ImWchar)IM_UNICODE_CODEPOINT_INVALID, (ImWchar)'?', (ImWchar)' ' }; - FallbackGlyph = FindGlyphNoFallback(FallbackChar); - if (FallbackGlyph == NULL) - { - FallbackChar = FindFirstExistingGlyph(this, fallback_chars, IM_ARRAYSIZE(fallback_chars)); - FallbackGlyph = FindGlyphNoFallback(FallbackChar); - if (FallbackGlyph == NULL) - { - FallbackGlyph = &Glyphs.back(); - FallbackChar = (ImWchar)FallbackGlyph->Codepoint; - } - } - - FallbackAdvanceX = FallbackGlyph->AdvanceX; - for (int i = 0; i < max_codepoint + 1; i++) - if (IndexAdvanceX[i] < 0.0f) - IndexAdvanceX[i] = FallbackAdvanceX; -} - -// API is designed this way to avoid exposing the 4K page size -// e.g. use with IsGlyphRangeUnused(0, 255) -bool ImFont::IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last) -{ - unsigned int page_begin = (c_begin / 4096); - unsigned int page_last = (c_last / 4096); - for (unsigned int page_n = page_begin; page_n <= page_last; page_n++) - if ((page_n >> 3) < sizeof(Used4kPagesMap)) - if (Used4kPagesMap[page_n >> 3] & (1 << (page_n & 7))) - return false; - return true; -} - -void ImFont::SetGlyphVisible(ImWchar c, bool visible) -{ - if (ImFontGlyph* glyph = (ImFontGlyph*)(void*)FindGlyph((ImWchar)c)) - glyph->Visible = visible ? 1 : 0; -} - -void ImFont::GrowIndex(int new_size) -{ - IM_ASSERT(IndexAdvanceX.Size == IndexLookup.Size); - if (new_size <= IndexLookup.Size) - return; - IndexAdvanceX.resize(new_size, -1.0f); - IndexLookup.resize(new_size, (ImWchar)-1); -} - -// x0/y0/x1/y1 are offset from the character upper-left layout position, in pixels. Therefore x0/y0 are often fairly close to zero. -// Not to be mistaken with texture coordinates, which are held by u0/v0/u1/v1 in normalized format (0.0..1.0 on each texture axis). -// 'cfg' is not necessarily == 'this->ConfigData' because multiple source fonts+configs can be used to build one target font. -void ImFont::AddGlyph(const ImFontConfig* cfg, ImWchar codepoint, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x) -{ - if (cfg != NULL) - { - // Clamp & recenter if needed - const float advance_x_original = advance_x; - advance_x = ImClamp(advance_x, cfg->GlyphMinAdvanceX, cfg->GlyphMaxAdvanceX); - if (advance_x != advance_x_original) - { - float char_off_x = cfg->PixelSnapH ? ImFloor((advance_x - advance_x_original) * 0.5f) : (advance_x - advance_x_original) * 0.5f; - x0 += char_off_x; - x1 += char_off_x; - } - - // Snap to pixel - if (cfg->PixelSnapH) - advance_x = IM_ROUND(advance_x); - - // Bake spacing - advance_x += cfg->GlyphExtraSpacing.x; - } - - Glyphs.resize(Glyphs.Size + 1); - ImFontGlyph& glyph = Glyphs.back(); - glyph.Codepoint = (unsigned int)codepoint; - glyph.Visible = (x0 != x1) && (y0 != y1); - glyph.Colored = false; - glyph.X0 = x0; - glyph.Y0 = y0; - glyph.X1 = x1; - glyph.Y1 = y1; - glyph.U0 = u0; - glyph.V0 = v0; - glyph.U1 = u1; - glyph.V1 = v1; - glyph.AdvanceX = advance_x; - - // Compute rough surface usage metrics (+1 to account for average padding, +0.99 to round) - // We use (U1-U0)*TexWidth instead of X1-X0 to account for oversampling. - float pad = ContainerAtlas->TexGlyphPadding + 0.99f; - DirtyLookupTables = true; - MetricsTotalSurface += (int)((glyph.U1 - glyph.U0) * ContainerAtlas->TexWidth + pad) * (int)((glyph.V1 - glyph.V0) * ContainerAtlas->TexHeight + pad); -} - -void ImFont::AddRemapChar(ImWchar dst, ImWchar src, bool overwrite_dst) -{ - IM_ASSERT(IndexLookup.Size > 0); // Currently this can only be called AFTER the font has been built, aka after calling ImFontAtlas::GetTexDataAs*() function. - unsigned int index_size = (unsigned int)IndexLookup.Size; - - if (dst < index_size && IndexLookup.Data[dst] == (ImWchar)-1 && !overwrite_dst) // 'dst' already exists - return; - if (src >= index_size && dst >= index_size) // both 'dst' and 'src' don't exist -> no-op - return; - - GrowIndex(dst + 1); - IndexLookup[dst] = (src < index_size) ? IndexLookup.Data[src] : (ImWchar)-1; - IndexAdvanceX[dst] = (src < index_size) ? IndexAdvanceX.Data[src] : 1.0f; -} - -const ImFontGlyph* ImFont::FindGlyph(ImWchar c) const -{ - if (c >= (size_t)IndexLookup.Size) - return FallbackGlyph; - const ImWchar i = IndexLookup.Data[c]; - if (i == (ImWchar)-1) - return FallbackGlyph; - return &Glyphs.Data[i]; -} - -const ImFontGlyph* ImFont::FindGlyphNoFallback(ImWchar c) const -{ - if (c >= (size_t)IndexLookup.Size) - return NULL; - const ImWchar i = IndexLookup.Data[c]; - if (i == (ImWchar)-1) - return NULL; - return &Glyphs.Data[i]; -} - -const char* ImFont::CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) const -{ - // Simple word-wrapping for English, not full-featured. Please submit failing cases! - // FIXME: Much possible improvements (don't cut things like "word !", "word!!!" but cut within "word,,,,", more sensible support for punctuations, support for Unicode punctuations, etc.) - - // For references, possible wrap point marked with ^ - // "aaa bbb, ccc,ddd. eee fff. ggg!" - // ^ ^ ^ ^ ^__ ^ ^ - - // List of hardcoded separators: .,;!?'" - - // Skip extra blanks after a line returns (that includes not counting them in width computation) - // e.g. "Hello world" --> "Hello" "World" - - // Cut words that cannot possibly fit within one line. - // e.g.: "The tropical fish" with ~5 characters worth of width --> "The tr" "opical" "fish" - - float line_width = 0.0f; - float word_width = 0.0f; - float blank_width = 0.0f; - wrap_width /= scale; // We work with unscaled widths to avoid scaling every characters - - const char* word_end = text; - const char* prev_word_end = NULL; - bool inside_word = true; - - const char* s = text; - while (s < text_end) - { - unsigned int c = (unsigned int)*s; - const char* next_s; - if (c < 0x80) - next_s = s + 1; - else - next_s = s + ImTextCharFromUtf8(&c, s, text_end); - if (c == 0) - break; - - if (c < 32) - { - if (c == '\n') - { - line_width = word_width = blank_width = 0.0f; - inside_word = true; - s = next_s; - continue; - } - if (c == '\r') - { - s = next_s; - continue; - } - } - - const float char_width = ((int)c < IndexAdvanceX.Size ? IndexAdvanceX.Data[c] : FallbackAdvanceX); - if (ImCharIsBlankW(c)) - { - if (inside_word) - { - line_width += blank_width; - blank_width = 0.0f; - word_end = s; - } - blank_width += char_width; - inside_word = false; - } - else - { - word_width += char_width; - if (inside_word) - { - word_end = next_s; - } - else - { - prev_word_end = word_end; - line_width += word_width + blank_width; - word_width = blank_width = 0.0f; - } - - // Allow wrapping after punctuation. - inside_word = (c != '.' && c != ',' && c != ';' && c != '!' && c != '?' && c != '\"'); - } - - // We ignore blank width at the end of the line (they can be skipped) - if (line_width + word_width > wrap_width) - { - // Words that cannot possibly fit within an entire line will be cut anywhere. - if (word_width < wrap_width) - s = prev_word_end ? prev_word_end : word_end; - break; - } - - s = next_s; - } - - return s; -} - -ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end, const char** remaining) const -{ - if (!text_end) - text_end = text_begin + strlen(text_begin); // FIXME-OPT: Need to avoid this. - - const float line_height = size; - const float scale = size / FontSize; - - ImVec2 text_size = ImVec2(0, 0); - float line_width = 0.0f; - - const bool word_wrap_enabled = (wrap_width > 0.0f); - const char* word_wrap_eol = NULL; - - const char* s = text_begin; - while (s < text_end) - { - if (word_wrap_enabled) - { - // Calculate how far we can render. Requires two passes on the string data but keeps the code simple and not intrusive for what's essentially an uncommon feature. - if (!word_wrap_eol) - { - word_wrap_eol = CalcWordWrapPositionA(scale, s, text_end, wrap_width - line_width); - if (word_wrap_eol == s) // Wrap_width is too small to fit anything. Force displaying 1 character to minimize the height discontinuity. - word_wrap_eol++; // +1 may not be a character start point in UTF-8 but it's ok because we use s >= word_wrap_eol below - } - - if (s >= word_wrap_eol) - { - if (text_size.x < line_width) - text_size.x = line_width; - text_size.y += line_height; - line_width = 0.0f; - word_wrap_eol = NULL; - - // Wrapping skips upcoming blanks - while (s < text_end) - { - const char c = *s; - if (ImCharIsBlankA(c)) { s++; } else if (c == '\n') { s++; break; } else { break; } - } - continue; - } - } - - // Decode and advance source - const char* prev_s = s; - unsigned int c = (unsigned int)*s; - if (c < 0x80) - { - s += 1; - } - else - { - s += ImTextCharFromUtf8(&c, s, text_end); - if (c == 0) // Malformed UTF-8? - break; - } - - if (c < 32) - { - if (c == '\n') - { - text_size.x = ImMax(text_size.x, line_width); - text_size.y += line_height; - line_width = 0.0f; - continue; - } - if (c == '\r') - continue; - } - - const float char_width = ((int)c < IndexAdvanceX.Size ? IndexAdvanceX.Data[c] : FallbackAdvanceX) * scale; - if (line_width + char_width >= max_width) - { - s = prev_s; - break; - } - - line_width += char_width; - } - - if (text_size.x < line_width) - text_size.x = line_width; - - if (line_width > 0 || text_size.y == 0.0f) - text_size.y += line_height; - - if (remaining) - *remaining = s; - - return text_size; -} - -// Note: as with every ImDrawList drawing function, this expects that the font atlas texture is bound. -void ImFont::RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, ImWchar c) const -{ - const ImFontGlyph* glyph = FindGlyph(c); - if (!glyph || !glyph->Visible) - return; - if (glyph->Colored) - col |= ~IM_COL32_A_MASK; - float scale = (size >= 0.0f) ? (size / FontSize) : 1.0f; - pos.x = IM_FLOOR(pos.x); - pos.y = IM_FLOOR(pos.y); - draw_list->PrimReserve(6, 4); - draw_list->PrimRectUV(ImVec2(pos.x + glyph->X0 * scale, pos.y + glyph->Y0 * scale), ImVec2(pos.x + glyph->X1 * scale, pos.y + glyph->Y1 * scale), ImVec2(glyph->U0, glyph->V0), ImVec2(glyph->U1, glyph->V1), col); -} - -// Note: as with every ImDrawList drawing function, this expects that the font atlas texture is bound. -void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width, bool cpu_fine_clip) const -{ - if (!text_end) - text_end = text_begin + strlen(text_begin); // ImGui:: functions generally already provides a valid text_end, so this is merely to handle direct calls. - - // Align to be pixel perfect - pos.x = IM_FLOOR(pos.x); - pos.y = IM_FLOOR(pos.y); - float x = pos.x; - float y = pos.y; - if (y > clip_rect.w) - return; - - const float scale = size / FontSize; - const float line_height = FontSize * scale; - const bool word_wrap_enabled = (wrap_width > 0.0f); - const char* word_wrap_eol = NULL; - - // Fast-forward to first visible line - const char* s = text_begin; - if (y + line_height < clip_rect.y && !word_wrap_enabled) - while (y + line_height < clip_rect.y && s < text_end) - { - s = (const char*)memchr(s, '\n', text_end - s); - s = s ? s + 1 : text_end; - y += line_height; - } - - // For large text, scan for the last visible line in order to avoid over-reserving in the call to PrimReserve() - // Note that very large horizontal line will still be affected by the issue (e.g. a one megabyte string buffer without a newline will likely crash atm) - if (text_end - s > 10000 && !word_wrap_enabled) - { - const char* s_end = s; - float y_end = y; - while (y_end < clip_rect.w && s_end < text_end) - { - s_end = (const char*)memchr(s_end, '\n', text_end - s_end); - s_end = s_end ? s_end + 1 : text_end; - y_end += line_height; - } - text_end = s_end; - } - if (s == text_end) - return; - - // Reserve vertices for remaining worse case (over-reserving is useful and easily amortized) - const int vtx_count_max = (int)(text_end - s) * 4; - const int idx_count_max = (int)(text_end - s) * 6; - const int idx_expected_size = draw_list->IdxBuffer.Size + idx_count_max; - draw_list->PrimReserve(idx_count_max, vtx_count_max); - - ImDrawVert* vtx_write = draw_list->_VtxWritePtr; - ImDrawIdx* idx_write = draw_list->_IdxWritePtr; - unsigned int vtx_current_idx = draw_list->_VtxCurrentIdx; - - const ImU32 col_untinted = col | ~IM_COL32_A_MASK; - - while (s < text_end) - { - if (word_wrap_enabled) - { - // Calculate how far we can render. Requires two passes on the string data but keeps the code simple and not intrusive for what's essentially an uncommon feature. - if (!word_wrap_eol) - { - word_wrap_eol = CalcWordWrapPositionA(scale, s, text_end, wrap_width - (x - pos.x)); - if (word_wrap_eol == s) // Wrap_width is too small to fit anything. Force displaying 1 character to minimize the height discontinuity. - word_wrap_eol++; // +1 may not be a character start point in UTF-8 but it's ok because we use s >= word_wrap_eol below - } - - if (s >= word_wrap_eol) - { - x = pos.x; - y += line_height; - word_wrap_eol = NULL; - - // Wrapping skips upcoming blanks - while (s < text_end) - { - const char c = *s; - if (ImCharIsBlankA(c)) { s++; } else if (c == '\n') { s++; break; } else { break; } - } - continue; - } - } - - // Decode and advance source - unsigned int c = (unsigned int)*s; - if (c < 0x80) - { - s += 1; - } - else - { - s += ImTextCharFromUtf8(&c, s, text_end); - if (c == 0) // Malformed UTF-8? - break; - } - - if (c < 32) - { - if (c == '\n') - { - x = pos.x; - y += line_height; - if (y > clip_rect.w) - break; // break out of main loop - continue; - } - if (c == '\r') - continue; - } - - const ImFontGlyph* glyph = FindGlyph((ImWchar)c); - if (glyph == NULL) - continue; - - float char_width = glyph->AdvanceX * scale; - if (glyph->Visible) - { - // We don't do a second finer clipping test on the Y axis as we've already skipped anything before clip_rect.y and exit once we pass clip_rect.w - float x1 = x + glyph->X0 * scale; - float x2 = x + glyph->X1 * scale; - float y1 = y + glyph->Y0 * scale; - float y2 = y + glyph->Y1 * scale; - if (x1 <= clip_rect.z && x2 >= clip_rect.x) - { - // Render a character - float u1 = glyph->U0; - float v1 = glyph->V0; - float u2 = glyph->U1; - float v2 = glyph->V1; - - // CPU side clipping used to fit text in their frame when the frame is too small. Only does clipping for axis aligned quads. - if (cpu_fine_clip) - { - if (x1 < clip_rect.x) - { - u1 = u1 + (1.0f - (x2 - clip_rect.x) / (x2 - x1)) * (u2 - u1); - x1 = clip_rect.x; - } - if (y1 < clip_rect.y) - { - v1 = v1 + (1.0f - (y2 - clip_rect.y) / (y2 - y1)) * (v2 - v1); - y1 = clip_rect.y; - } - if (x2 > clip_rect.z) - { - u2 = u1 + ((clip_rect.z - x1) / (x2 - x1)) * (u2 - u1); - x2 = clip_rect.z; - } - if (y2 > clip_rect.w) - { - v2 = v1 + ((clip_rect.w - y1) / (y2 - y1)) * (v2 - v1); - y2 = clip_rect.w; - } - if (y1 >= y2) - { - x += char_width; - continue; - } - } - - // Support for untinted glyphs - ImU32 glyph_col = glyph->Colored ? col_untinted : col; - - // We are NOT calling PrimRectUV() here because non-inlined causes too much overhead in a debug builds. Inlined here: - { - idx_write[0] = (ImDrawIdx)(vtx_current_idx); idx_write[1] = (ImDrawIdx)(vtx_current_idx+1); idx_write[2] = (ImDrawIdx)(vtx_current_idx+2); - idx_write[3] = (ImDrawIdx)(vtx_current_idx); idx_write[4] = (ImDrawIdx)(vtx_current_idx+2); idx_write[5] = (ImDrawIdx)(vtx_current_idx+3); - vtx_write[0].pos.x = x1; vtx_write[0].pos.y = y1; vtx_write[0].col = glyph_col; vtx_write[0].uv.x = u1; vtx_write[0].uv.y = v1; - vtx_write[1].pos.x = x2; vtx_write[1].pos.y = y1; vtx_write[1].col = glyph_col; vtx_write[1].uv.x = u2; vtx_write[1].uv.y = v1; - vtx_write[2].pos.x = x2; vtx_write[2].pos.y = y2; vtx_write[2].col = glyph_col; vtx_write[2].uv.x = u2; vtx_write[2].uv.y = v2; - vtx_write[3].pos.x = x1; vtx_write[3].pos.y = y2; vtx_write[3].col = glyph_col; vtx_write[3].uv.x = u1; vtx_write[3].uv.y = v2; - vtx_write += 4; - vtx_current_idx += 4; - idx_write += 6; - } - } - } - x += char_width; - } - - // Give back unused vertices (clipped ones, blanks) ~ this is essentially a PrimUnreserve() action. - draw_list->VtxBuffer.Size = (int)(vtx_write - draw_list->VtxBuffer.Data); // Same as calling shrink() - draw_list->IdxBuffer.Size = (int)(idx_write - draw_list->IdxBuffer.Data); - draw_list->CmdBuffer[draw_list->CmdBuffer.Size - 1].ElemCount -= (idx_expected_size - draw_list->IdxBuffer.Size); - draw_list->_VtxWritePtr = vtx_write; - draw_list->_IdxWritePtr = idx_write; - draw_list->_VtxCurrentIdx = vtx_current_idx; -} - -//----------------------------------------------------------------------------- -// [SECTION] ImGui Internal Render Helpers -//----------------------------------------------------------------------------- -// Vaguely redesigned to stop accessing ImGui global state: -// - RenderArrow() -// - RenderBullet() -// - RenderCheckMark() -// - RenderMouseCursor() -// - RenderArrowPointingAt() -// - RenderRectFilledRangeH() -// - RenderRectFilledWithHole() -//----------------------------------------------------------------------------- -// Function in need of a redesign (legacy mess) -// - RenderColorRectWithAlphaCheckerboard() -//----------------------------------------------------------------------------- - -// Render an arrow aimed to be aligned with text (p_min is a position in the same space text would be positioned). To e.g. denote expanded/collapsed state -void ImGui::RenderArrow(ImDrawList* draw_list, ImVec2 pos, ImU32 col, ImGuiDir dir, float scale) -{ - const float h = draw_list->_Data->FontSize * 1.00f; - float r = h * 0.40f * scale; - ImVec2 center = pos + ImVec2(h * 0.50f, h * 0.50f * scale); - - ImVec2 a, b, c; - switch (dir) - { - case ImGuiDir_Up: - case ImGuiDir_Down: - if (dir == ImGuiDir_Up) r = -r; - a = ImVec2(+0.000f, +0.750f) * r; - b = ImVec2(-0.866f, -0.750f) * r; - c = ImVec2(+0.866f, -0.750f) * r; - break; - case ImGuiDir_Left: - case ImGuiDir_Right: - if (dir == ImGuiDir_Left) r = -r; - a = ImVec2(+0.750f, +0.000f) * r; - b = ImVec2(-0.750f, +0.866f) * r; - c = ImVec2(-0.750f, -0.866f) * r; - break; - case ImGuiDir_None: - case ImGuiDir_COUNT: - IM_ASSERT(0); - break; - } - draw_list->AddTriangleFilled(center + a, center + b, center + c, col); -} - -void ImGui::RenderBullet(ImDrawList* draw_list, ImVec2 pos, ImU32 col) -{ - draw_list->AddCircleFilled(pos, draw_list->_Data->FontSize * 0.20f, col, 8); -} - -void ImGui::RenderCheckMark(ImDrawList* draw_list, ImVec2 pos, ImU32 col, float sz) -{ - float thickness = ImMax(sz / 5.0f, 1.0f); - sz -= thickness * 0.5f; - pos += ImVec2(thickness * 0.25f, thickness * 0.25f); - - float third = sz / 3.0f; - float bx = pos.x + third; - float by = pos.y + sz - third * 0.5f; - draw_list->PathLineTo(ImVec2(bx - third, by - third)); - draw_list->PathLineTo(ImVec2(bx, by)); - draw_list->PathLineTo(ImVec2(bx + third * 2.0f, by - third * 2.0f)); - draw_list->PathStroke(col, 0, thickness); -} - -void ImGui::RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow) -{ - if (mouse_cursor == ImGuiMouseCursor_None) - return; - IM_ASSERT(mouse_cursor > ImGuiMouseCursor_None && mouse_cursor < ImGuiMouseCursor_COUNT); - - ImFontAtlas* font_atlas = draw_list->_Data->Font->ContainerAtlas; - ImVec2 offset, size, uv[4]; - if (font_atlas->GetMouseCursorTexData(mouse_cursor, &offset, &size, &uv[0], &uv[2])) - { - pos -= offset; - ImTextureID tex_id = font_atlas->TexID; - draw_list->PushTextureID(tex_id); - draw_list->AddImage(tex_id, pos + ImVec2(1, 0) * scale, pos + (ImVec2(1, 0) + size) * scale, uv[2], uv[3], col_shadow); - draw_list->AddImage(tex_id, pos + ImVec2(2, 0) * scale, pos + (ImVec2(2, 0) + size) * scale, uv[2], uv[3], col_shadow); - draw_list->AddImage(tex_id, pos, pos + size * scale, uv[2], uv[3], col_border); - draw_list->AddImage(tex_id, pos, pos + size * scale, uv[0], uv[1], col_fill); - draw_list->PopTextureID(); - } -} - -// Render an arrow. 'pos' is position of the arrow tip. half_sz.x is length from base to tip. half_sz.y is length on each side. -void ImGui::RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGuiDir direction, ImU32 col) -{ - switch (direction) - { - case ImGuiDir_Left: draw_list->AddTriangleFilled(ImVec2(pos.x + half_sz.x, pos.y - half_sz.y), ImVec2(pos.x + half_sz.x, pos.y + half_sz.y), pos, col); return; - case ImGuiDir_Right: draw_list->AddTriangleFilled(ImVec2(pos.x - half_sz.x, pos.y + half_sz.y), ImVec2(pos.x - half_sz.x, pos.y - half_sz.y), pos, col); return; - case ImGuiDir_Up: draw_list->AddTriangleFilled(ImVec2(pos.x + half_sz.x, pos.y + half_sz.y), ImVec2(pos.x - half_sz.x, pos.y + half_sz.y), pos, col); return; - case ImGuiDir_Down: draw_list->AddTriangleFilled(ImVec2(pos.x - half_sz.x, pos.y - half_sz.y), ImVec2(pos.x + half_sz.x, pos.y - half_sz.y), pos, col); return; - case ImGuiDir_None: case ImGuiDir_COUNT: break; // Fix warnings - } -} - -static inline float ImAcos01(float x) -{ - if (x <= 0.0f) return IM_PI * 0.5f; - if (x >= 1.0f) return 0.0f; - return ImAcos(x); - //return (-0.69813170079773212f * x * x - 0.87266462599716477f) * x + 1.5707963267948966f; // Cheap approximation, may be enough for what we do. -} - -// FIXME: Cleanup and move code to ImDrawList. -void ImGui::RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding) -{ - if (x_end_norm == x_start_norm) - return; - if (x_start_norm > x_end_norm) - ImSwap(x_start_norm, x_end_norm); - - ImVec2 p0 = ImVec2(ImLerp(rect.Min.x, rect.Max.x, x_start_norm), rect.Min.y); - ImVec2 p1 = ImVec2(ImLerp(rect.Min.x, rect.Max.x, x_end_norm), rect.Max.y); - if (rounding == 0.0f) - { - draw_list->AddRectFilled(p0, p1, col, 0.0f); - return; - } - - rounding = ImClamp(ImMin((rect.Max.x - rect.Min.x) * 0.5f, (rect.Max.y - rect.Min.y) * 0.5f) - 1.0f, 0.0f, rounding); - const float inv_rounding = 1.0f / rounding; - const float arc0_b = ImAcos01(1.0f - (p0.x - rect.Min.x) * inv_rounding); - const float arc0_e = ImAcos01(1.0f - (p1.x - rect.Min.x) * inv_rounding); - const float half_pi = IM_PI * 0.5f; // We will == compare to this because we know this is the exact value ImAcos01 can return. - const float x0 = ImMax(p0.x, rect.Min.x + rounding); - if (arc0_b == arc0_e) - { - draw_list->PathLineTo(ImVec2(x0, p1.y)); - draw_list->PathLineTo(ImVec2(x0, p0.y)); - } - else if (arc0_b == 0.0f && arc0_e == half_pi) - { - draw_list->PathArcToFast(ImVec2(x0, p1.y - rounding), rounding, 3, 6); // BL - draw_list->PathArcToFast(ImVec2(x0, p0.y + rounding), rounding, 6, 9); // TR - } - else - { - draw_list->PathArcTo(ImVec2(x0, p1.y - rounding), rounding, IM_PI - arc0_e, IM_PI - arc0_b, 3); // BL - draw_list->PathArcTo(ImVec2(x0, p0.y + rounding), rounding, IM_PI + arc0_b, IM_PI + arc0_e, 3); // TR - } - if (p1.x > rect.Min.x + rounding) - { - const float arc1_b = ImAcos01(1.0f - (rect.Max.x - p1.x) * inv_rounding); - const float arc1_e = ImAcos01(1.0f - (rect.Max.x - p0.x) * inv_rounding); - const float x1 = ImMin(p1.x, rect.Max.x - rounding); - if (arc1_b == arc1_e) - { - draw_list->PathLineTo(ImVec2(x1, p0.y)); - draw_list->PathLineTo(ImVec2(x1, p1.y)); - } - else if (arc1_b == 0.0f && arc1_e == half_pi) - { - draw_list->PathArcToFast(ImVec2(x1, p0.y + rounding), rounding, 9, 12); // TR - draw_list->PathArcToFast(ImVec2(x1, p1.y - rounding), rounding, 0, 3); // BR - } - else - { - draw_list->PathArcTo(ImVec2(x1, p0.y + rounding), rounding, -arc1_e, -arc1_b, 3); // TR - draw_list->PathArcTo(ImVec2(x1, p1.y - rounding), rounding, +arc1_b, +arc1_e, 3); // BR - } - } - draw_list->PathFillConvex(col); -} - -void ImGui::RenderRectFilledWithHole(ImDrawList* draw_list, ImRect outer, ImRect inner, ImU32 col, float rounding) -{ - const bool fill_L = (inner.Min.x > outer.Min.x); - const bool fill_R = (inner.Max.x < outer.Max.x); - const bool fill_U = (inner.Min.y > outer.Min.y); - const bool fill_D = (inner.Max.y < outer.Max.y); - if (fill_L) draw_list->AddRectFilled(ImVec2(outer.Min.x, inner.Min.y), ImVec2(inner.Min.x, inner.Max.y), col, rounding, (fill_U ? 0 : ImDrawFlags_RoundCornersTopLeft) | (fill_D ? 0 : ImDrawFlags_RoundCornersBottomLeft)); - if (fill_R) draw_list->AddRectFilled(ImVec2(inner.Max.x, inner.Min.y), ImVec2(outer.Max.x, inner.Max.y), col, rounding, (fill_U ? 0 : ImDrawFlags_RoundCornersTopRight) | (fill_D ? 0 : ImDrawFlags_RoundCornersBottomRight)); - if (fill_U) draw_list->AddRectFilled(ImVec2(inner.Min.x, outer.Min.y), ImVec2(inner.Max.x, inner.Min.y), col, rounding, (fill_L ? 0 : ImDrawFlags_RoundCornersTopLeft) | (fill_R ? 0 : ImDrawFlags_RoundCornersTopRight)); - if (fill_D) draw_list->AddRectFilled(ImVec2(inner.Min.x, inner.Max.y), ImVec2(inner.Max.x, outer.Max.y), col, rounding, (fill_L ? 0 : ImDrawFlags_RoundCornersBottomLeft) | (fill_R ? 0 : ImDrawFlags_RoundCornersBottomRight)); - if (fill_L && fill_U) draw_list->AddRectFilled(ImVec2(outer.Min.x, outer.Min.y), ImVec2(inner.Min.x, inner.Min.y), col, rounding, ImDrawFlags_RoundCornersTopLeft); - if (fill_R && fill_U) draw_list->AddRectFilled(ImVec2(inner.Max.x, outer.Min.y), ImVec2(outer.Max.x, inner.Min.y), col, rounding, ImDrawFlags_RoundCornersTopRight); - if (fill_L && fill_D) draw_list->AddRectFilled(ImVec2(outer.Min.x, inner.Max.y), ImVec2(inner.Min.x, outer.Max.y), col, rounding, ImDrawFlags_RoundCornersBottomLeft); - if (fill_R && fill_D) draw_list->AddRectFilled(ImVec2(inner.Max.x, inner.Max.y), ImVec2(outer.Max.x, outer.Max.y), col, rounding, ImDrawFlags_RoundCornersBottomRight); -} - -// Helper for ColorPicker4() -// NB: This is rather brittle and will show artifact when rounding this enabled if rounded corners overlap multiple cells. Caller currently responsible for avoiding that. -// Spent a non reasonable amount of time trying to getting this right for ColorButton with rounding+anti-aliasing+ImGuiColorEditFlags_HalfAlphaPreview flag + various grid sizes and offsets, and eventually gave up... probably more reasonable to disable rounding altogether. -// FIXME: uses ImGui::GetColorU32 -void ImGui::RenderColorRectWithAlphaCheckerboard(ImDrawList* draw_list, ImVec2 p_min, ImVec2 p_max, ImU32 col, float grid_step, ImVec2 grid_off, float rounding, ImDrawFlags flags) -{ - if ((flags & ImDrawFlags_RoundCornersMask_) == 0) - flags = ImDrawFlags_RoundCornersDefault_; - if (((col & IM_COL32_A_MASK) >> IM_COL32_A_SHIFT) < 0xFF) - { - ImU32 col_bg1 = GetColorU32(ImAlphaBlendColors(IM_COL32(204, 204, 204, 255), col)); - ImU32 col_bg2 = GetColorU32(ImAlphaBlendColors(IM_COL32(128, 128, 128, 255), col)); - draw_list->AddRectFilled(p_min, p_max, col_bg1, rounding, flags); - - int yi = 0; - for (float y = p_min.y + grid_off.y; y < p_max.y; y += grid_step, yi++) - { - float y1 = ImClamp(y, p_min.y, p_max.y), y2 = ImMin(y + grid_step, p_max.y); - if (y2 <= y1) - continue; - for (float x = p_min.x + grid_off.x + (yi & 1) * grid_step; x < p_max.x; x += grid_step * 2.0f) - { - float x1 = ImClamp(x, p_min.x, p_max.x), x2 = ImMin(x + grid_step, p_max.x); - if (x2 <= x1) - continue; - ImDrawFlags cell_flags = ImDrawFlags_RoundCornersNone; - if (y1 <= p_min.y) { if (x1 <= p_min.x) cell_flags |= ImDrawFlags_RoundCornersTopLeft; if (x2 >= p_max.x) cell_flags |= ImDrawFlags_RoundCornersTopRight; } - if (y2 >= p_max.y) { if (x1 <= p_min.x) cell_flags |= ImDrawFlags_RoundCornersBottomLeft; if (x2 >= p_max.x) cell_flags |= ImDrawFlags_RoundCornersBottomRight; } - - // Combine flags - cell_flags = (flags == ImDrawFlags_RoundCornersNone || cell_flags == ImDrawFlags_RoundCornersNone) ? ImDrawFlags_RoundCornersNone : (cell_flags & flags); - draw_list->AddRectFilled(ImVec2(x1, y1), ImVec2(x2, y2), col_bg2, rounding, cell_flags); - } - } - } - else - { - draw_list->AddRectFilled(p_min, p_max, col, rounding, flags); - } -} - -//----------------------------------------------------------------------------- -// [SECTION] Decompression code -//----------------------------------------------------------------------------- -// Compressed with stb_compress() then converted to a C array and encoded as base85. -// Use the program in misc/fonts/binary_to_compressed_c.cpp to create the array from a TTF file. -// The purpose of encoding as base85 instead of "0x00,0x01,..." style is only save on _source code_ size. -// Decompression from stb.h (public domain) by Sean Barrett https://github.com/nothings/stb/blob/master/stb.h -//----------------------------------------------------------------------------- - -static unsigned int stb_decompress_length(const unsigned char *input) -{ - return (input[8] << 24) + (input[9] << 16) + (input[10] << 8) + input[11]; -} - -static unsigned char *stb__barrier_out_e, *stb__barrier_out_b; -static const unsigned char *stb__barrier_in_b; -static unsigned char *stb__dout; -static void stb__match(const unsigned char *data, unsigned int length) -{ - // INVERSE of memmove... write each byte before copying the next... - IM_ASSERT(stb__dout + length <= stb__barrier_out_e); - if (stb__dout + length > stb__barrier_out_e) { stb__dout += length; return; } - if (data < stb__barrier_out_b) { stb__dout = stb__barrier_out_e+1; return; } - while (length--) *stb__dout++ = *data++; -} - -static void stb__lit(const unsigned char *data, unsigned int length) -{ - IM_ASSERT(stb__dout + length <= stb__barrier_out_e); - if (stb__dout + length > stb__barrier_out_e) { stb__dout += length; return; } - if (data < stb__barrier_in_b) { stb__dout = stb__barrier_out_e+1; return; } - memcpy(stb__dout, data, length); - stb__dout += length; -} - -#define stb__in2(x) ((i[x] << 8) + i[(x)+1]) -#define stb__in3(x) ((i[x] << 16) + stb__in2((x)+1)) -#define stb__in4(x) ((i[x] << 24) + stb__in3((x)+1)) - -static const unsigned char *stb_decompress_token(const unsigned char *i) -{ - if (*i >= 0x20) { // use fewer if's for cases that expand small - if (*i >= 0x80) stb__match(stb__dout-i[1]-1, i[0] - 0x80 + 1), i += 2; - else if (*i >= 0x40) stb__match(stb__dout-(stb__in2(0) - 0x4000 + 1), i[2]+1), i += 3; - else /* *i >= 0x20 */ stb__lit(i+1, i[0] - 0x20 + 1), i += 1 + (i[0] - 0x20 + 1); - } else { // more ifs for cases that expand large, since overhead is amortized - if (*i >= 0x18) stb__match(stb__dout-(stb__in3(0) - 0x180000 + 1), i[3]+1), i += 4; - else if (*i >= 0x10) stb__match(stb__dout-(stb__in3(0) - 0x100000 + 1), stb__in2(3)+1), i += 5; - else if (*i >= 0x08) stb__lit(i+2, stb__in2(0) - 0x0800 + 1), i += 2 + (stb__in2(0) - 0x0800 + 1); - else if (*i == 0x07) stb__lit(i+3, stb__in2(1) + 1), i += 3 + (stb__in2(1) + 1); - else if (*i == 0x06) stb__match(stb__dout-(stb__in3(1)+1), i[4]+1), i += 5; - else if (*i == 0x04) stb__match(stb__dout-(stb__in3(1)+1), stb__in2(4)+1), i += 6; - } - return i; -} - -static unsigned int stb_adler32(unsigned int adler32, unsigned char *buffer, unsigned int buflen) -{ - const unsigned long ADLER_MOD = 65521; - unsigned long s1 = adler32 & 0xffff, s2 = adler32 >> 16; - unsigned long blocklen = buflen % 5552; - - unsigned long i; - while (buflen) { - for (i=0; i + 7 < blocklen; i += 8) { - s1 += buffer[0], s2 += s1; - s1 += buffer[1], s2 += s1; - s1 += buffer[2], s2 += s1; - s1 += buffer[3], s2 += s1; - s1 += buffer[4], s2 += s1; - s1 += buffer[5], s2 += s1; - s1 += buffer[6], s2 += s1; - s1 += buffer[7], s2 += s1; - - buffer += 8; - } - - for (; i < blocklen; ++i) - s1 += *buffer++, s2 += s1; - - s1 %= ADLER_MOD, s2 %= ADLER_MOD; - buflen -= blocklen; - blocklen = 5552; - } - return (unsigned int)(s2 << 16) + (unsigned int)s1; -} - -static unsigned int stb_decompress(unsigned char *output, const unsigned char *i, unsigned int /*length*/) -{ - if (stb__in4(0) != 0x57bC0000) return 0; - if (stb__in4(4) != 0) return 0; // error! stream is > 4GB - const unsigned int olen = stb_decompress_length(i); - stb__barrier_in_b = i; - stb__barrier_out_e = output + olen; - stb__barrier_out_b = output; - i += 16; - - stb__dout = output; - for (;;) { - const unsigned char *old_i = i; - i = stb_decompress_token(i); - if (i == old_i) { - if (*i == 0x05 && i[1] == 0xfa) { - IM_ASSERT(stb__dout == output + olen); - if (stb__dout != output + olen) return 0; - if (stb_adler32(1, output, olen) != (unsigned int) stb__in4(2)) - return 0; - return olen; - } else { - IM_ASSERT(0); /* NOTREACHED */ - return 0; - } - } - IM_ASSERT(stb__dout <= output + olen); - if (stb__dout > output + olen) - return 0; - } -} - -//----------------------------------------------------------------------------- -// [SECTION] Default font data (ProggyClean.ttf) -//----------------------------------------------------------------------------- -// ProggyClean.ttf -// Copyright (c) 2004, 2005 Tristan Grimmer -// MIT license (see License.txt in http://www.upperbounds.net/download/ProggyClean.ttf.zip) -// Download and more information at http://upperbounds.net -//----------------------------------------------------------------------------- -// File: 'ProggyClean.ttf' (41208 bytes) -// Exported using misc/fonts/binary_to_compressed_c.cpp (with compression + base85 string encoding). -// The purpose of encoding as base85 instead of "0x00,0x01,..." style is only save on _source code_ size. -//----------------------------------------------------------------------------- -static const char proggy_clean_ttf_compressed_data_base85[11980 + 1] = - "7])#######hV0qs'/###[),##/l:$#Q6>##5[n42>c-TH`->>#/e>11NNV=Bv(*:.F?uu#(gRU.o0XGH`$vhLG1hxt9?W`#,5LsCp#-i>.r$<$6pD>Lb';9Crc6tgXmKVeU2cD4Eo3R/" - "2*>]b(MC;$jPfY.;h^`IWM9Qo#t'X#(v#Y9w0#1D$CIf;W'#pWUPXOuxXuU(H9M(1=Ke$$'5F%)]0^#0X@U.a$FBjVQTSDgEKnIS7EM9>ZY9w0#L;>>#Mx&4Mvt//L[MkA#W@lK.N'[0#7RL_&#w+F%HtG9M#XL`N&.,GM4Pg;--VsM.M0rJfLH2eTM`*oJMHRC`N" - "kfimM2J,W-jXS:)r0wK#@Fge$U>`w'N7G#$#fB#$E^$#:9:hk+eOe--6x)F7*E%?76%^GMHePW-Z5l'&GiF#$956:rS?dA#fiK:)Yr+`�j@'DbG&#^$PG.Ll+DNa&VZ>1i%h1S9u5o@YaaW$e+bROPOpxTO7Stwi1::iB1q)C_=dV26J;2,]7op$]uQr@_V7$q^%lQwtuHY]=DX,n3L#0PHDO4f9>dC@O>HBuKPpP*E,N+b3L#lpR/MrTEH.IAQk.a>D[.e;mc." - "x]Ip.PH^'/aqUO/$1WxLoW0[iLAw=4h(9.`G" - "CRUxHPeR`5Mjol(dUWxZa(>STrPkrJiWx`5U7F#.g*jrohGg`cg:lSTvEY/EV_7H4Q9[Z%cnv;JQYZ5q.l7Zeas:HOIZOB?Ggv:[7MI2k).'2($5FNP&EQ(,)" - "U]W]+fh18.vsai00);D3@4ku5P?DP8aJt+;qUM]=+b'8@;mViBKx0DE[-auGl8:PJ&Dj+M6OC]O^((##]`0i)drT;-7X`=-H3[igUnPG-NZlo.#k@h#=Ork$m>a>$-?Tm$UV(?#P6YY#" - "'/###xe7q.73rI3*pP/$1>s9)W,JrM7SN]'/4C#v$U`0#V.[0>xQsH$fEmPMgY2u7Kh(G%siIfLSoS+MK2eTM$=5,M8p`A.;_R%#u[K#$x4AG8.kK/HSB==-'Ie/QTtG?-.*^N-4B/ZM" - "_3YlQC7(p7q)&](`6_c)$/*JL(L-^(]$wIM`dPtOdGA,U3:w2M-0+WomX2u7lqM2iEumMTcsF?-aT=Z-97UEnXglEn1K-bnEO`gu" - "Ft(c%=;Am_Qs@jLooI&NX;]0#j4#F14;gl8-GQpgwhrq8'=l_f-b49'UOqkLu7-##oDY2L(te+Mch&gLYtJ,MEtJfLh'x'M=$CS-ZZ%P]8bZ>#S?YY#%Q&q'3^Fw&?D)UDNrocM3A76/" - "/oL?#h7gl85[qW/NDOk%16ij;+:1a'iNIdb-ou8.P*w,v5#EI$TWS>Pot-R*H'-SEpA:g)f+O$%%`kA#G=8RMmG1&O`>to8bC]T&$,n.LoO>29sp3dt-52U%VM#q7'DHpg+#Z9%H[Ket`e;)f#Km8&+DC$I46>#Kr]]u-[=99tts1.qb#q72g1WJO81q+eN'03'eM>&1XxY-caEnO" - "j%2n8)),?ILR5^.Ibn<-X-Mq7[a82Lq:F&#ce+S9wsCK*x`569E8ew'He]h:sI[2LM$[guka3ZRd6:t%IG:;$%YiJ:Nq=?eAw;/:nnDq0(CYcMpG)qLN4$##&J-XTt,%OVU4)S1+R-#dg0/Nn?Ku1^0f$B*P:Rowwm-`0PKjYDDM'3]d39VZHEl4,.j']Pk-M.h^&:0FACm$maq-&sgw0t7/6(^xtk%" - "LuH88Fj-ekm>GA#_>568x6(OFRl-IZp`&b,_P'$MhLbxfc$mj`,O;&%W2m`Zh:/)Uetw:aJ%]K9h:TcF]u_-Sj9,VK3M.*'&0D[Ca]J9gp8,kAW]" - "%(?A%R$f<->Zts'^kn=-^@c4%-pY6qI%J%1IGxfLU9CP8cbPlXv);C=b),<2mOvP8up,UVf3839acAWAW-W?#ao/^#%KYo8fRULNd2.>%m]UK:n%r$'sw]J;5pAoO_#2mO3n,'=H5(et" - "Hg*`+RLgv>=4U8guD$I%D:W>-r5V*%j*W:Kvej.Lp$'?;++O'>()jLR-^u68PHm8ZFWe+ej8h:9r6L*0//c&iH&R8pRbA#Kjm%upV1g:" - "a_#Ur7FuA#(tRh#.Y5K+@?3<-8m0$PEn;J:rh6?I6uG<-`wMU'ircp0LaE_OtlMb&1#6T.#FDKu#1Lw%u%+GM+X'e?YLfjM[VO0MbuFp7;>Q&#WIo)0@F%q7c#4XAXN-U&VBpqB>0ie&jhZ[?iLR@@_AvA-iQC(=ksRZRVp7`.=+NpBC%rh&3]R:8XDmE5^V8O(x<-+k?'(^](H.aREZSi,#1:[IXaZFOm<-ui#qUq2$##Ri;u75OK#(RtaW-K-F`S+cF]uN`-KMQ%rP/Xri.LRcB##=YL3BgM/3M" - "D?@f&1'BW-)Ju#bmmWCMkk&#TR`C,5d>g)F;t,4:@_l8G/5h4vUd%&%950:VXD'QdWoY-F$BtUwmfe$YqL'8(PWX(" - "P?^@Po3$##`MSs?DWBZ/S>+4%>fX,VWv/w'KD`LP5IbH;rTV>n3cEK8U#bX]l-/V+^lj3;vlMb&[5YQ8#pekX9JP3XUC72L,,?+Ni&co7ApnO*5NK,((W-i:$,kp'UDAO(G0Sq7MVjJs" - "bIu)'Z,*[>br5fX^:FPAWr-m2KgLQ_nN6'8uTGT5g)uLv:873UpTLgH+#FgpH'_o1780Ph8KmxQJ8#H72L4@768@Tm&Q" - "h4CB/5OvmA&,Q&QbUoi$a_%3M01H)4x7I^&KQVgtFnV+;[Pc>[m4k//,]1?#`VY[Jr*3&&slRfLiVZJ:]?=K3Sw=[$=uRB?3xk48@aege0jT6'N#(q%.O=?2S]u*(m<-" - "V8J'(1)G][68hW$5'q[GC&5j`TE?m'esFGNRM)j,ffZ?-qx8;->g4t*:CIP/[Qap7/9'#(1sao7w-.qNUdkJ)tCF&#B^;xGvn2r9FEPFFFcL@.iFNkTve$m%#QvQS8U@)2Z+3K:AKM5i" - "sZ88+dKQ)W6>J%CL`.d*(B`-n8D9oK-XV1q['-5k'cAZ69e;D_?$ZPP&s^+7])$*$#@QYi9,5P r+$%CE=68>K8r0=dSC%%(@p7" - ".m7jilQ02'0-VWAgTlGW'b)Tq7VT9q^*^$$.:&N@@" - "$&)WHtPm*5_rO0&e%K&#-30j(E4#'Zb.o/(Tpm$>K'f@[PvFl,hfINTNU6u'0pao7%XUp9]5.>%h`8_=VYbxuel.NTSsJfLacFu3B'lQSu/m6-Oqem8T+oE--$0a/k]uj9EwsG>%veR*" - "hv^BFpQj:K'#SJ,sB-'#](j.Lg92rTw-*n%@/;39rrJF,l#qV%OrtBeC6/,;qB3ebNW[?,Hqj2L.1NP&GjUR=1D8QaS3Up&@*9wP?+lo7b?@%'k4`p0Z$22%K3+iCZj?XJN4Nm&+YF]u" - "@-W$U%VEQ/,,>>#)D#%8cY#YZ?=,`Wdxu/ae&#" - "w6)R89tI#6@s'(6Bf7a&?S=^ZI_kS&ai`&=tE72L_D,;^R)7[$so8lKN%5/$(vdfq7+ebA#" - "u1p]ovUKW&Y%q]'>$1@-[xfn$7ZTp7mM,G,Ko7a&Gu%G[RMxJs[0MM%wci.LFDK)(%:_i2B5CsR8&9Z&#=mPEnm0f`<&c)QL5uJ#%u%lJj+D-r;BoFDoS97h5g)E#o:&S4weDF,9^Hoe`h*L+_a*NrLW-1pG_&2UdB8" - "6e%B/:=>)N4xeW.*wft-;$'58-ESqr#U`'6AQ]m&6/`Z>#S?YY#Vc;r7U2&326d=w&H####?TZ`*4?&.MK?LP8Vxg>$[QXc%QJv92.(Db*B)gb*BM9dM*hJMAo*c&#" - "b0v=Pjer]$gG&JXDf->'StvU7505l9$AFvgYRI^&<^b68?j#q9QX4SM'RO#&sL1IM.rJfLUAj221]d##DW=m83u5;'bYx,*Sl0hL(W;;$doB&O/TQ:(Z^xBdLjLV#*8U_72Lh+2Q8Cj0i:6hp&$C/:p(HK>T8Y[gHQ4`4)'$Ab(Nof%V'8hL&#SfD07&6D@M.*J:;$-rv29'M]8qMv-tLp,'886iaC=Hb*YJoKJ,(j%K=H`K.v9HggqBIiZu'QvBT.#=)0ukruV&.)3=(^1`o*Pj4<-#MJ+gLq9-##@HuZPN0]u:h7.T..G:;$/Usj(T7`Q8tT72LnYl<-qx8;-HV7Q-&Xdx%1a,hC=0u+HlsV>nuIQL-5" - "_>@kXQtMacfD.m-VAb8;IReM3$wf0''hra*so568'Ip&vRs849'MRYSp%:t:h5qSgwpEr$B>Q,;s(C#$)`svQuF$##-D,##,g68@2[T;.XSdN9Qe)rpt._K-#5wF)sP'##p#C0c%-Gb%" - "hd+<-j'Ai*x&&HMkT]C'OSl##5RG[JXaHN;d'uA#x._U;.`PU@(Z3dt4r152@:v,'R.Sj'w#0<-;kPI)FfJ&#AYJ&#//)>-k=m=*XnK$>=)72L]0I%>.G690a:$##<,);?;72#?x9+d;" - "^V'9;jY@;)br#q^YQpx:X#Te$Z^'=-=bGhLf:D6&bNwZ9-ZD#n^9HhLMr5G;']d&6'wYmTFmLq9wI>P(9mI[>kC-ekLC/R&CH+s'B;K-M6$EB%is00:" - "+A4[7xks.LrNk0&E)wILYF@2L'0Nb$+pv<(2.768/FrY&h$^3i&@+G%JT'<-,v`3;_)I9M^AE]CN?Cl2AZg+%4iTpT3$U4O]GKx'm9)b@p7YsvK3w^YR-" - "CdQ*:Ir<($u&)#(&?L9Rg3H)4fiEp^iI9O8KnTj,]H?D*r7'M;PwZ9K0E^k&-cpI;.p/6_vwoFMV<->#%Xi.LxVnrU(4&8/P+:hLSKj$#U%]49t'I:rgMi'FL@a:0Y-uA[39',(vbma*" - "hU%<-SRF`Tt:542R_VV$p@[p8DV[A,?1839FWdFTi1O*H&#(AL8[_P%.M>v^-))qOT*F5Cq0`Ye%+$B6i:7@0IXSsDiWP,##P`%/L-" - "S(qw%sf/@%#B6;/U7K]uZbi^Oc^2n%t<)'mEVE''n`WnJra$^TKvX5B>;_aSEK',(hwa0:i4G?.Bci.(X[?b*($,=-n<.Q%`(X=?+@Am*Js0&=3bh8K]mL69=Lb,OcZV/);TTm8VI;?%OtJ<(b4mq7M6:u?KRdFl*:xP?Yb.5)%w_I?7uk5JC+FS(m#i'k.'a0i)9<7b'fs'59hq$*5Uhv##pi^8+hIEBF`nvo`;'l0.^S1<-wUK2/Coh58KKhLj" - "M=SO*rfO`+qC`W-On.=AJ56>>i2@2LH6A:&5q`?9I3@@'04&p2/LVa*T-4<-i3;M9UvZd+N7>b*eIwg:CC)c<>nO&#$(>.Z-I&J(Q0Hd5Q%7Co-b`-cP)hI;*_F]u`Rb[.j8_Q/<&>uu+VsH$sM9TA%?)(vmJ80),P7E>)tjD%2L=-t#fK[%`v=Q8WlA2);Sa" - ">gXm8YB`1d@K#n]76-a$U,mF%Ul:#/'xoFM9QX-$.QN'>" - "[%$Z$uF6pA6Ki2O5:8w*vP1<-1`[G,)-m#>0`P&#eb#.3i)rtB61(o'$?X3B2Qft^ae_5tKL9MUe9b*sLEQ95C&`=G?@Mj=wh*'3E>=-<)Gt*Iw)'QG:`@I" - "wOf7&]1i'S01B+Ev/Nac#9S;=;YQpg_6U`*kVY39xK,[/6Aj7:'1Bm-_1EYfa1+o&o4hp7KN_Q(OlIo@S%;jVdn0'1h19w,WQhLI)3S#f$2(eb,jr*b;3Vw]*7NH%$c4Vs,eD9>XW8?N]o+(*pgC%/72LV-uW%iewS8W6m2rtCpo'RS1R84=@paTKt)>=%&1[)*vp'u+x,VrwN;&]kuO9JDbg=pO$J*.jVe;u'm0dr9l,<*wMK*Oe=g8lV_KEBFkO'oU]^=[-792#ok,)" - "i]lR8qQ2oA8wcRCZ^7w/Njh;?.stX?Q1>S1q4Bn$)K1<-rGdO'$Wr.Lc.CG)$/*JL4tNR/,SVO3,aUw'DJN:)Ss;wGn9A32ijw%FL+Z0Fn.U9;reSq)bmI32U==5ALuG&#Vf1398/pVo" - "1*c-(aY168o<`JsSbk-,1N;$>0:OUas(3:8Z972LSfF8eb=c-;>SPw7.6hn3m`9^Xkn(r.qS[0;T%&Qc=+STRxX'q1BNk3&*eu2;&8q$&x>Q#Q7^Tf+6<(d%ZVmj2bDi%.3L2n+4W'$P" - "iDDG)g,r%+?,$@?uou5tSe2aN_AQU*'IAO" - "URQ##V^Fv-XFbGM7Fl(N<3DhLGF%q.1rC$#:T__&Pi68%0xi_&[qFJ(77j_&JWoF.V735&T,[R*:xFR*K5>>#`bW-?4Ne_&6Ne_&6Ne_&n`kr-#GJcM6X;uM6X;uM(.a..^2TkL%oR(#" - ";u.T%fAr%4tJ8&><1=GHZ_+m9/#H1F^R#SC#*N=BA9(D?v[UiFY>>^8p,KKF.W]L29uLkLlu/+4T" - "w$)F./^n3+rlo+DB;5sIYGNk+i1t-69Jg--0pao7Sm#K)pdHW&;LuDNH@H>#/X-TI(;P>#,Gc>#0Su>#4`1?#8lC?#xL$#B.`$#F:r$#JF.%#NR@%#R_R%#Vke%#Zww%#_-4^Rh%Sflr-k'MS.o?.5/sWel/wpEM0%3'/1)K^f1-d>G21&v(35>V`39V7A4=onx4" - "A1OY5EI0;6Ibgr6M$HS7Q<)58C5w,;WoA*#[%T*#`1g*#d=#+#hI5+#lUG+#pbY+#tnl+#x$),#&1;,#*=M,#.I`,#2Ur,#6b.-#;w[H#iQtA#m^0B#qjBB#uvTB##-hB#'9$C#+E6C#" - "/QHC#3^ZC#7jmC#;v)D#?,)4kMYD4lVu`4m`:&5niUA5@(A5BA1]PBB:xlBCC=2CDLXMCEUtiCf&0g2'tN?PGT4CPGT4CPGT4CPGT4CPGT4CPGT4CPGT4CP" - "GT4CPGT4CPGT4CPGT4CPGT4CPGT4CP-qekC`.9kEg^+F$kwViFJTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5KTB&5o,^<-28ZI'O?;xp" - "O?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xpO?;xp;7q-#lLYI:xvD=#"; - -static const char* GetDefaultCompressedFontDataTTFBase85() -{ - return proggy_clean_ttf_compressed_data_base85; -} - -#endif // #ifndef IMGUI_DISABLE diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imgui_internal.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imgui_internal.h deleted file mode 100644 index fa5dec3..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imgui_internal.h +++ /dev/null @@ -1,2810 +0,0 @@ -// dear imgui, v1.85 -// (internal structures/api) - -// You may use this file to debug, understand or extend ImGui features but we don't provide any guarantee of forward compatibility! -// Set: -// #define IMGUI_DEFINE_MATH_OPERATORS -// To implement maths operators for ImVec2 (disabled by default to not collide with using IM_VEC2_CLASS_EXTRA along with your own math types+operators) - -/* - -Index of this file: - -// [SECTION] Header mess -// [SECTION] Forward declarations -// [SECTION] Context pointer -// [SECTION] STB libraries includes -// [SECTION] Macros -// [SECTION] Generic helpers -// [SECTION] ImDrawList support -// [SECTION] Widgets support: flags, enums, data structures -// [SECTION] Navigation support -// [SECTION] Columns support -// [SECTION] Multi-select support -// [SECTION] Docking support -// [SECTION] Viewport support -// [SECTION] Settings support -// [SECTION] Metrics, Debug tools -// [SECTION] Generic context hooks -// [SECTION] ImGuiContext (main imgui context) -// [SECTION] ImGuiWindowTempData, ImGuiWindow -// [SECTION] Tab bar, Tab item support -// [SECTION] Table support -// [SECTION] ImGui internal API -// [SECTION] ImFontAtlas internal API -// [SECTION] Test Engine specific hooks (imgui_test_engine) - -*/ - -#pragma once -#ifndef IMGUI_DISABLE - -//----------------------------------------------------------------------------- -// [SECTION] Header mess -//----------------------------------------------------------------------------- - -#ifndef IMGUI_VERSION -#include "imgui.h" -#endif - -#include // FILE*, sscanf -#include // NULL, malloc, free, qsort, atoi, atof -#include // sqrtf, fabsf, fmodf, powf, floorf, ceilf, cosf, sinf -#include // INT_MIN, INT_MAX - -// Enable SSE intrinsics if available -#if (defined __SSE__ || defined __x86_64__ || defined _M_X64) && !defined(IMGUI_DISABLE_SSE) -#define IMGUI_ENABLE_SSE -#include -#endif - -// Visual Studio warnings -#ifdef _MSC_VER -#pragma warning (push) -#pragma warning (disable: 4251) // class 'xxx' needs to have dll-interface to be used by clients of struct 'xxx' // when IMGUI_API is set to__declspec(dllexport) -#pragma warning (disable: 26812) // The enum type 'xxx' is unscoped. Prefer 'enum class' over 'enum' (Enum.3). [MSVC Static Analyzer) -#pragma warning (disable: 26495) // [Static Analyzer] Variable 'XXX' is uninitialized. Always initialize a member variable (type.6). -#if defined(_MSC_VER) && _MSC_VER >= 1922 // MSVC 2019 16.2 or later -#pragma warning (disable: 5054) // operator '|': deprecated between enumerations of different types -#endif -#endif - -// Clang/GCC warnings with -Weverything -#if defined(__clang__) -#pragma clang diagnostic push -#if __has_warning("-Wunknown-warning-option") -#pragma clang diagnostic ignored "-Wunknown-warning-option" // warning: unknown warning group 'xxx' -#endif -#pragma clang diagnostic ignored "-Wunknown-pragmas" // warning: unknown warning group 'xxx' -#pragma clang diagnostic ignored "-Wfloat-equal" // warning: comparing floating point with == or != is unsafe // storing and comparing against same constants ok, for ImFloorSigned() -#pragma clang diagnostic ignored "-Wunused-function" // for stb_textedit.h -#pragma clang diagnostic ignored "-Wmissing-prototypes" // for stb_textedit.h -#pragma clang diagnostic ignored "-Wold-style-cast" -#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" -#pragma clang diagnostic ignored "-Wdouble-promotion" -#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision -#pragma clang diagnostic ignored "-Wmissing-noreturn" // warning: function 'xxx' could be declared with attribute 'noreturn' -#elif defined(__GNUC__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind -#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead -#endif - -// Legacy defines -#ifdef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS // Renamed in 1.74 -#error Use IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS -#endif -#ifdef IMGUI_DISABLE_MATH_FUNCTIONS // Renamed in 1.74 -#error Use IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS -#endif - -// Enable stb_truetype by default unless FreeType is enabled. -// You can compile with both by defining both IMGUI_ENABLE_FREETYPE and IMGUI_ENABLE_STB_TRUETYPE together. -#ifndef IMGUI_ENABLE_FREETYPE -#define IMGUI_ENABLE_STB_TRUETYPE -#endif - -//----------------------------------------------------------------------------- -// [SECTION] Forward declarations -//----------------------------------------------------------------------------- - -struct ImBitVector; // Store 1-bit per value -struct ImRect; // An axis-aligned rectangle (2 points) -struct ImDrawDataBuilder; // Helper to build a ImDrawData instance -struct ImDrawListSharedData; // Data shared between all ImDrawList instances -struct ImGuiColorMod; // Stacked color modifier, backup of modified data so we can restore it -struct ImGuiContext; // Main Dear ImGui context -struct ImGuiContextHook; // Hook for extensions like ImGuiTestEngine -struct ImGuiDataTypeInfo; // Type information associated to a ImGuiDataType enum -struct ImGuiGroupData; // Stacked storage data for BeginGroup()/EndGroup() -struct ImGuiInputTextState; // Internal state of the currently focused/edited text input box -struct ImGuiLastItemData; // Status storage for last submitted items -struct ImGuiMenuColumns; // Simple column measurement, currently used for MenuItem() only -struct ImGuiNavItemData; // Result of a gamepad/keyboard directional navigation move query result -struct ImGuiMetricsConfig; // Storage for ShowMetricsWindow() and DebugNodeXXX() functions -struct ImGuiNextWindowData; // Storage for SetNextWindow** functions -struct ImGuiNextItemData; // Storage for SetNextItem** functions -struct ImGuiOldColumnData; // Storage data for a single column for legacy Columns() api -struct ImGuiOldColumns; // Storage data for a columns set for legacy Columns() api -struct ImGuiPopupData; // Storage for current popup stack -struct ImGuiSettingsHandler; // Storage for one type registered in the .ini file -struct ImGuiStackSizes; // Storage of stack sizes for debugging/asserting -struct ImGuiStyleMod; // Stacked style modifier, backup of modified data so we can restore it -struct ImGuiTabBar; // Storage for a tab bar -struct ImGuiTabItem; // Storage for a tab item (within a tab bar) -struct ImGuiTable; // Storage for a table -struct ImGuiTableColumn; // Storage for one column of a table -struct ImGuiTableTempData; // Temporary storage for one table (one per table in the stack), shared between tables. -struct ImGuiTableSettings; // Storage for a table .ini settings -struct ImGuiTableColumnsSettings; // Storage for a column .ini settings -struct ImGuiWindow; // Storage for one window -struct ImGuiWindowTempData; // Temporary storage for one window (that's the data which in theory we could ditch at the end of the frame, in practice we currently keep it for each window) -struct ImGuiWindowSettings; // Storage for a window .ini settings (we keep one of those even if the actual window wasn't instanced during this session) - -// Use your programming IDE "Go to definition" facility on the names of the center columns to find the actual flags/enum lists. -typedef int ImGuiLayoutType; // -> enum ImGuiLayoutType_ // Enum: Horizontal or vertical -typedef int ImGuiActivateFlags; // -> enum ImGuiActivateFlags_ // Flags: for navigation/focus function (will be for ActivateItem() later) -typedef int ImGuiItemFlags; // -> enum ImGuiItemFlags_ // Flags: for PushItemFlag() -typedef int ImGuiItemStatusFlags; // -> enum ImGuiItemStatusFlags_ // Flags: for DC.LastItemStatusFlags -typedef int ImGuiOldColumnFlags; // -> enum ImGuiOldColumnFlags_ // Flags: for BeginColumns() -typedef int ImGuiNavHighlightFlags; // -> enum ImGuiNavHighlightFlags_ // Flags: for RenderNavHighlight() -typedef int ImGuiNavDirSourceFlags; // -> enum ImGuiNavDirSourceFlags_ // Flags: for GetNavInputAmount2d() -typedef int ImGuiNavMoveFlags; // -> enum ImGuiNavMoveFlags_ // Flags: for navigation requests -typedef int ImGuiNextItemDataFlags; // -> enum ImGuiNextItemDataFlags_ // Flags: for SetNextItemXXX() functions -typedef int ImGuiNextWindowDataFlags; // -> enum ImGuiNextWindowDataFlags_// Flags: for SetNextWindowXXX() functions -typedef int ImGuiScrollFlags; // -> enum ImGuiScrollFlags_ // Flags: for ScrollToItem() and navigation requests -typedef int ImGuiSeparatorFlags; // -> enum ImGuiSeparatorFlags_ // Flags: for SeparatorEx() -typedef int ImGuiTextFlags; // -> enum ImGuiTextFlags_ // Flags: for TextEx() -typedef int ImGuiTooltipFlags; // -> enum ImGuiTooltipFlags_ // Flags: for BeginTooltipEx() - -typedef void (*ImGuiErrorLogCallback)(void* user_data, const char* fmt, ...); - -//----------------------------------------------------------------------------- -// [SECTION] Context pointer -// See implementation of this variable in imgui.cpp for comments and details. -//----------------------------------------------------------------------------- - -#ifndef GImGui -extern IMGUI_API ImGuiContext* GImGui; // Current implicit context pointer -#endif - -//------------------------------------------------------------------------- -// [SECTION] STB libraries includes -//------------------------------------------------------------------------- - -namespace ImStb -{ - -#undef STB_TEXTEDIT_STRING -#undef STB_TEXTEDIT_CHARTYPE -#define STB_TEXTEDIT_STRING ImGuiInputTextState -#define STB_TEXTEDIT_CHARTYPE ImWchar -#define STB_TEXTEDIT_GETWIDTH_NEWLINE (-1.0f) -#define STB_TEXTEDIT_UNDOSTATECOUNT 99 -#define STB_TEXTEDIT_UNDOCHARCOUNT 999 -#include "imstb_textedit.h" - -} // namespace ImStb - -//----------------------------------------------------------------------------- -// [SECTION] Macros -//----------------------------------------------------------------------------- - -// Debug Logging -#ifndef IMGUI_DEBUG_LOG -#define IMGUI_DEBUG_LOG(_FMT,...) printf("[%05d] " _FMT, GImGui->FrameCount, __VA_ARGS__) -#endif - -// Debug Logging for selected systems. Remove the '((void)0) //' to enable. -//#define IMGUI_DEBUG_LOG_POPUP IMGUI_DEBUG_LOG // Enable log -//#define IMGUI_DEBUG_LOG_NAV IMGUI_DEBUG_LOG // Enable log -#define IMGUI_DEBUG_LOG_POPUP(...) ((void)0) // Disable log -#define IMGUI_DEBUG_LOG_NAV(...) ((void)0) // Disable log - -// Static Asserts -#if (__cplusplus >= 201100) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201100) -#define IM_STATIC_ASSERT(_COND) static_assert(_COND, "") -#else -#define IM_STATIC_ASSERT(_COND) typedef char static_assertion_##__line__[(_COND)?1:-1] -#endif - -// "Paranoid" Debug Asserts are meant to only be enabled during specific debugging/work, otherwise would slow down the code too much. -// We currently don't have many of those so the effect is currently negligible, but onward intent to add more aggressive ones in the code. -//#define IMGUI_DEBUG_PARANOID -#ifdef IMGUI_DEBUG_PARANOID -#define IM_ASSERT_PARANOID(_EXPR) IM_ASSERT(_EXPR) -#else -#define IM_ASSERT_PARANOID(_EXPR) -#endif - -// Error handling -// Down the line in some frameworks/languages we would like to have a way to redirect those to the programmer and recover from more faults. -#ifndef IM_ASSERT_USER_ERROR -#define IM_ASSERT_USER_ERROR(_EXP,_MSG) IM_ASSERT((_EXP) && _MSG) // Recoverable User Error -#endif - -// Misc Macros -#define IM_PI 3.14159265358979323846f -#ifdef _WIN32 -#define IM_NEWLINE "\r\n" // Play it nice with Windows users (Update: since 2018-05, Notepad finally appears to support Unix-style carriage returns!) -#else -#define IM_NEWLINE "\n" -#endif -#define IM_TABSIZE (4) -#define IM_MEMALIGN(_OFF,_ALIGN) (((_OFF) + (_ALIGN - 1)) & ~(_ALIGN - 1)) // Memory align e.g. IM_ALIGN(0,4)=0, IM_ALIGN(1,4)=4, IM_ALIGN(4,4)=4, IM_ALIGN(5,4)=8 -#define IM_F32_TO_INT8_UNBOUND(_VAL) ((int)((_VAL) * 255.0f + ((_VAL)>=0 ? 0.5f : -0.5f))) // Unsaturated, for display purpose -#define IM_F32_TO_INT8_SAT(_VAL) ((int)(ImSaturate(_VAL) * 255.0f + 0.5f)) // Saturated, always output 0..255 -#define IM_FLOOR(_VAL) ((float)(int)(_VAL)) // ImFloor() is not inlined in MSVC debug builds -#define IM_ROUND(_VAL) ((float)(int)((_VAL) + 0.5f)) // - -// Enforce cdecl calling convention for functions called by the standard library, in case compilation settings changed the default to e.g. __vectorcall -#ifdef _MSC_VER -#define IMGUI_CDECL __cdecl -#else -#define IMGUI_CDECL -#endif - -// Warnings -#if defined(_MSC_VER) && !defined(__clang__) -#define IM_MSVC_WARNING_SUPPRESS(XXXX) __pragma(warning(suppress: XXXX)) -#else -#define IM_MSVC_WARNING_SUPPRESS(XXXX) -#endif - -// Debug Tools -// Use 'Metrics->Tools->Item Picker' to break into the call-stack of a specific item. -#ifndef IM_DEBUG_BREAK -#if defined(__clang__) -#define IM_DEBUG_BREAK() __builtin_debugtrap() -#elif defined (_MSC_VER) -#define IM_DEBUG_BREAK() __debugbreak() -#else -#define IM_DEBUG_BREAK() IM_ASSERT(0) // It is expected that you define IM_DEBUG_BREAK() into something that will break nicely in a debugger! -#endif -#endif // #ifndef IM_DEBUG_BREAK - -//----------------------------------------------------------------------------- -// [SECTION] Generic helpers -// Note that the ImXXX helpers functions are lower-level than ImGui functions. -// ImGui functions or the ImGui context are never called/used from other ImXXX functions. -//----------------------------------------------------------------------------- -// - Helpers: Hashing -// - Helpers: Sorting -// - Helpers: Bit manipulation -// - Helpers: String, Formatting -// - Helpers: UTF-8 <> wchar conversions -// - Helpers: ImVec2/ImVec4 operators -// - Helpers: Maths -// - Helpers: Geometry -// - Helper: ImVec1 -// - Helper: ImVec2ih -// - Helper: ImRect -// - Helper: ImBitArray -// - Helper: ImBitVector -// - Helper: ImSpan<>, ImSpanAllocator<> -// - Helper: ImPool<> -// - Helper: ImChunkStream<> -//----------------------------------------------------------------------------- - -// Helpers: Hashing -IMGUI_API ImGuiID ImHashData(const void* data, size_t data_size, ImU32 seed = 0); -IMGUI_API ImGuiID ImHashStr(const char* data, size_t data_size = 0, ImU32 seed = 0); -#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS -static inline ImGuiID ImHash(const void* data, int size, ImU32 seed = 0) { return size ? ImHashData(data, (size_t)size, seed) : ImHashStr((const char*)data, 0, seed); } // [moved to ImHashStr/ImHashData in 1.68] -#endif - -// Helpers: Sorting -#define ImQsort qsort - -// Helpers: Color Blending -IMGUI_API ImU32 ImAlphaBlendColors(ImU32 col_a, ImU32 col_b); - -// Helpers: Bit manipulation -static inline bool ImIsPowerOfTwo(int v) { return v != 0 && (v & (v - 1)) == 0; } -static inline bool ImIsPowerOfTwo(ImU64 v) { return v != 0 && (v & (v - 1)) == 0; } -static inline int ImUpperPowerOfTwo(int v) { v--; v |= v >> 1; v |= v >> 2; v |= v >> 4; v |= v >> 8; v |= v >> 16; v++; return v; } - -// Helpers: String, Formatting -IMGUI_API int ImStricmp(const char* str1, const char* str2); -IMGUI_API int ImStrnicmp(const char* str1, const char* str2, size_t count); -IMGUI_API void ImStrncpy(char* dst, const char* src, size_t count); -IMGUI_API char* ImStrdup(const char* str); -IMGUI_API char* ImStrdupcpy(char* dst, size_t* p_dst_size, const char* str); -IMGUI_API const char* ImStrchrRange(const char* str_begin, const char* str_end, char c); -IMGUI_API int ImStrlenW(const ImWchar* str); -IMGUI_API const char* ImStreolRange(const char* str, const char* str_end); // End end-of-line -IMGUI_API const ImWchar*ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin); // Find beginning-of-line -IMGUI_API const char* ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end); -IMGUI_API void ImStrTrimBlanks(char* str); -IMGUI_API const char* ImStrSkipBlank(const char* str); -IMGUI_API int ImFormatString(char* buf, size_t buf_size, const char* fmt, ...) IM_FMTARGS(3); -IMGUI_API int ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args) IM_FMTLIST(3); -IMGUI_API const char* ImParseFormatFindStart(const char* format); -IMGUI_API const char* ImParseFormatFindEnd(const char* format); -IMGUI_API const char* ImParseFormatTrimDecorations(const char* format, char* buf, size_t buf_size); -IMGUI_API int ImParseFormatPrecision(const char* format, int default_value); -static inline bool ImCharIsBlankA(char c) { return c == ' ' || c == '\t'; } -static inline bool ImCharIsBlankW(unsigned int c) { return c == ' ' || c == '\t' || c == 0x3000; } - -// Helpers: UTF-8 <> wchar conversions -IMGUI_API const char* ImTextCharToUtf8(char out_buf[5], unsigned int c); // return out_buf -IMGUI_API int ImTextStrToUtf8(char* out_buf, int out_buf_size, const ImWchar* in_text, const ImWchar* in_text_end); // return output UTF-8 bytes count -IMGUI_API int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end); // read one character. return input UTF-8 bytes count -IMGUI_API int ImTextStrFromUtf8(ImWchar* out_buf, int out_buf_size, const char* in_text, const char* in_text_end, const char** in_remaining = NULL); // return input UTF-8 bytes count -IMGUI_API int ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end); // return number of UTF-8 code-points (NOT bytes count) -IMGUI_API int ImTextCountUtf8BytesFromChar(const char* in_text, const char* in_text_end); // return number of bytes to express one char in UTF-8 -IMGUI_API int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end); // return number of bytes to express string in UTF-8 - -// Helpers: ImVec2/ImVec4 operators -// We are keeping those disabled by default so they don't leak in user space, to allow user enabling implicit cast operators between ImVec2 and their own types (using IM_VEC2_CLASS_EXTRA etc.) -// We unfortunately don't have a unary- operator for ImVec2 because this would needs to be defined inside the class itself. -#ifdef IMGUI_DEFINE_MATH_OPERATORS -IM_MSVC_RUNTIME_CHECKS_OFF -static inline ImVec2 operator*(const ImVec2& lhs, const float rhs) { return ImVec2(lhs.x * rhs, lhs.y * rhs); } -static inline ImVec2 operator/(const ImVec2& lhs, const float rhs) { return ImVec2(lhs.x / rhs, lhs.y / rhs); } -static inline ImVec2 operator+(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x + rhs.x, lhs.y + rhs.y); } -static inline ImVec2 operator-(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x - rhs.x, lhs.y - rhs.y); } -static inline ImVec2 operator*(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x * rhs.x, lhs.y * rhs.y); } -static inline ImVec2 operator/(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x / rhs.x, lhs.y / rhs.y); } -static inline ImVec2& operator*=(ImVec2& lhs, const float rhs) { lhs.x *= rhs; lhs.y *= rhs; return lhs; } -static inline ImVec2& operator/=(ImVec2& lhs, const float rhs) { lhs.x /= rhs; lhs.y /= rhs; return lhs; } -static inline ImVec2& operator+=(ImVec2& lhs, const ImVec2& rhs) { lhs.x += rhs.x; lhs.y += rhs.y; return lhs; } -static inline ImVec2& operator-=(ImVec2& lhs, const ImVec2& rhs) { lhs.x -= rhs.x; lhs.y -= rhs.y; return lhs; } -static inline ImVec2& operator*=(ImVec2& lhs, const ImVec2& rhs) { lhs.x *= rhs.x; lhs.y *= rhs.y; return lhs; } -static inline ImVec2& operator/=(ImVec2& lhs, const ImVec2& rhs) { lhs.x /= rhs.x; lhs.y /= rhs.y; return lhs; } -static inline ImVec4 operator+(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z, lhs.w + rhs.w); } -static inline ImVec4 operator-(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z, lhs.w - rhs.w); } -static inline ImVec4 operator*(const ImVec4& lhs, const ImVec4& rhs) { return ImVec4(lhs.x * rhs.x, lhs.y * rhs.y, lhs.z * rhs.z, lhs.w * rhs.w); } -IM_MSVC_RUNTIME_CHECKS_RESTORE -#endif - -// Helpers: File System -#ifdef IMGUI_DISABLE_FILE_FUNCTIONS -#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS -typedef void* ImFileHandle; -static inline ImFileHandle ImFileOpen(const char*, const char*) { return NULL; } -static inline bool ImFileClose(ImFileHandle) { return false; } -static inline ImU64 ImFileGetSize(ImFileHandle) { return (ImU64)-1; } -static inline ImU64 ImFileRead(void*, ImU64, ImU64, ImFileHandle) { return 0; } -static inline ImU64 ImFileWrite(const void*, ImU64, ImU64, ImFileHandle) { return 0; } -#endif -#ifndef IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS -typedef FILE* ImFileHandle; -IMGUI_API ImFileHandle ImFileOpen(const char* filename, const char* mode); -IMGUI_API bool ImFileClose(ImFileHandle file); -IMGUI_API ImU64 ImFileGetSize(ImFileHandle file); -IMGUI_API ImU64 ImFileRead(void* data, ImU64 size, ImU64 count, ImFileHandle file); -IMGUI_API ImU64 ImFileWrite(const void* data, ImU64 size, ImU64 count, ImFileHandle file); -#else -#define IMGUI_DISABLE_TTY_FUNCTIONS // Can't use stdout, fflush if we are not using default file functions -#endif -IMGUI_API void* ImFileLoadToMemory(const char* filename, const char* mode, size_t* out_file_size = NULL, int padding_bytes = 0); - -// Helpers: Maths -IM_MSVC_RUNTIME_CHECKS_OFF -// - Wrapper for standard libs functions. (Note that imgui_demo.cpp does _not_ use them to keep the code easy to copy) -#ifndef IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS -#define ImFabs(X) fabsf(X) -#define ImSqrt(X) sqrtf(X) -#define ImFmod(X, Y) fmodf((X), (Y)) -#define ImCos(X) cosf(X) -#define ImSin(X) sinf(X) -#define ImAcos(X) acosf(X) -#define ImAtan2(Y, X) atan2f((Y), (X)) -#define ImAtof(STR) atof(STR) -//#define ImFloorStd(X) floorf(X) // We use our own, see ImFloor() and ImFloorSigned() -#define ImCeil(X) ceilf(X) -static inline float ImPow(float x, float y) { return powf(x, y); } // DragBehaviorT/SliderBehaviorT uses ImPow with either float/double and need the precision -static inline double ImPow(double x, double y) { return pow(x, y); } -static inline float ImLog(float x) { return logf(x); } // DragBehaviorT/SliderBehaviorT uses ImLog with either float/double and need the precision -static inline double ImLog(double x) { return log(x); } -static inline int ImAbs(int x) { return x < 0 ? -x : x; } -static inline float ImAbs(float x) { return fabsf(x); } -static inline double ImAbs(double x) { return fabs(x); } -static inline float ImSign(float x) { return (x < 0.0f) ? -1.0f : ((x > 0.0f) ? 1.0f : 0.0f); } // Sign operator - returns -1, 0 or 1 based on sign of argument -static inline double ImSign(double x) { return (x < 0.0) ? -1.0 : ((x > 0.0) ? 1.0 : 0.0); } -#ifdef IMGUI_ENABLE_SSE -static inline float ImRsqrt(float x) { return _mm_cvtss_f32(_mm_rsqrt_ss(_mm_set_ss(x))); } -#else -static inline float ImRsqrt(float x) { return 1.0f / sqrtf(x); } -#endif -static inline double ImRsqrt(double x) { return 1.0 / sqrt(x); } -#endif -// - ImMin/ImMax/ImClamp/ImLerp/ImSwap are used by widgets which support variety of types: signed/unsigned int/long long float/double -// (Exceptionally using templates here but we could also redefine them for those types) -template static inline T ImMin(T lhs, T rhs) { return lhs < rhs ? lhs : rhs; } -template static inline T ImMax(T lhs, T rhs) { return lhs >= rhs ? lhs : rhs; } -template static inline T ImClamp(T v, T mn, T mx) { return (v < mn) ? mn : (v > mx) ? mx : v; } -template static inline T ImLerp(T a, T b, float t) { return (T)(a + (b - a) * t); } -template static inline void ImSwap(T& a, T& b) { T tmp = a; a = b; b = tmp; } -template static inline T ImAddClampOverflow(T a, T b, T mn, T mx) { if (b < 0 && (a < mn - b)) return mn; if (b > 0 && (a > mx - b)) return mx; return a + b; } -template static inline T ImSubClampOverflow(T a, T b, T mn, T mx) { if (b > 0 && (a < mn + b)) return mn; if (b < 0 && (a > mx + b)) return mx; return a - b; } -// - Misc maths helpers -static inline ImVec2 ImMin(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x < rhs.x ? lhs.x : rhs.x, lhs.y < rhs.y ? lhs.y : rhs.y); } -static inline ImVec2 ImMax(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x >= rhs.x ? lhs.x : rhs.x, lhs.y >= rhs.y ? lhs.y : rhs.y); } -static inline ImVec2 ImClamp(const ImVec2& v, const ImVec2& mn, ImVec2 mx) { return ImVec2((v.x < mn.x) ? mn.x : (v.x > mx.x) ? mx.x : v.x, (v.y < mn.y) ? mn.y : (v.y > mx.y) ? mx.y : v.y); } -static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, float t) { return ImVec2(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t); } -static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, const ImVec2& t) { return ImVec2(a.x + (b.x - a.x) * t.x, a.y + (b.y - a.y) * t.y); } -static inline ImVec4 ImLerp(const ImVec4& a, const ImVec4& b, float t) { return ImVec4(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, a.w + (b.w - a.w) * t); } -static inline float ImSaturate(float f) { return (f < 0.0f) ? 0.0f : (f > 1.0f) ? 1.0f : f; } -static inline float ImLengthSqr(const ImVec2& lhs) { return (lhs.x * lhs.x) + (lhs.y * lhs.y); } -static inline float ImLengthSqr(const ImVec4& lhs) { return (lhs.x * lhs.x) + (lhs.y * lhs.y) + (lhs.z * lhs.z) + (lhs.w * lhs.w); } -static inline float ImInvLength(const ImVec2& lhs, float fail_value) { float d = (lhs.x * lhs.x) + (lhs.y * lhs.y); if (d > 0.0f) return ImRsqrt(d); return fail_value; } -static inline float ImFloor(float f) { return (float)(int)(f); } -static inline float ImFloorSigned(float f) { return (float)((f >= 0 || (int)f == f) ? (int)f : (int)f - 1); } // Decent replacement for floorf() -static inline ImVec2 ImFloor(const ImVec2& v) { return ImVec2((float)(int)(v.x), (float)(int)(v.y)); } -static inline int ImModPositive(int a, int b) { return (a + b) % b; } -static inline float ImDot(const ImVec2& a, const ImVec2& b) { return a.x * b.x + a.y * b.y; } -static inline ImVec2 ImRotate(const ImVec2& v, float cos_a, float sin_a) { return ImVec2(v.x * cos_a - v.y * sin_a, v.x * sin_a + v.y * cos_a); } -static inline float ImLinearSweep(float current, float target, float speed) { if (current < target) return ImMin(current + speed, target); if (current > target) return ImMax(current - speed, target); return current; } -static inline ImVec2 ImMul(const ImVec2& lhs, const ImVec2& rhs) { return ImVec2(lhs.x * rhs.x, lhs.y * rhs.y); } -IM_MSVC_RUNTIME_CHECKS_RESTORE - -// Helpers: Geometry -IMGUI_API ImVec2 ImBezierCubicCalc(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, float t); -IMGUI_API ImVec2 ImBezierCubicClosestPoint(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, int num_segments); // For curves with explicit number of segments -IMGUI_API ImVec2 ImBezierCubicClosestPointCasteljau(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& p, float tess_tol);// For auto-tessellated curves you can use tess_tol = style.CurveTessellationTol -IMGUI_API ImVec2 ImBezierQuadraticCalc(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, float t); -IMGUI_API ImVec2 ImLineClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& p); -IMGUI_API bool ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p); -IMGUI_API ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p); -IMGUI_API void ImTriangleBarycentricCoords(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p, float& out_u, float& out_v, float& out_w); -inline float ImTriangleArea(const ImVec2& a, const ImVec2& b, const ImVec2& c) { return ImFabs((a.x * (b.y - c.y)) + (b.x * (c.y - a.y)) + (c.x * (a.y - b.y))) * 0.5f; } -IMGUI_API ImGuiDir ImGetDirQuadrantFromDelta(float dx, float dy); - -// Helper: ImVec1 (1D vector) -// (this odd construct is used to facilitate the transition between 1D and 2D, and the maintenance of some branches/patches) -IM_MSVC_RUNTIME_CHECKS_OFF -struct ImVec1 -{ - float x; - ImVec1() { x = 0.0f; } - ImVec1(float _x) { x = _x; } -}; - -// Helper: ImVec2ih (2D vector, half-size integer, for long-term packed storage) -struct ImVec2ih -{ - short x, y; - ImVec2ih() { x = y = 0; } - ImVec2ih(short _x, short _y) { x = _x; y = _y; } - explicit ImVec2ih(const ImVec2& rhs) { x = (short)rhs.x; y = (short)rhs.y; } -}; - -// Helper: ImRect (2D axis aligned bounding-box) -// NB: we can't rely on ImVec2 math operators being available here! -struct IMGUI_API ImRect -{ - ImVec2 Min; // Upper-left - ImVec2 Max; // Lower-right - - ImRect() : Min(0.0f, 0.0f), Max(0.0f, 0.0f) {} - ImRect(const ImVec2& min, const ImVec2& max) : Min(min), Max(max) {} - ImRect(const ImVec4& v) : Min(v.x, v.y), Max(v.z, v.w) {} - ImRect(float x1, float y1, float x2, float y2) : Min(x1, y1), Max(x2, y2) {} - - ImVec2 GetCenter() const { return ImVec2((Min.x + Max.x) * 0.5f, (Min.y + Max.y) * 0.5f); } - ImVec2 GetSize() const { return ImVec2(Max.x - Min.x, Max.y - Min.y); } - float GetWidth() const { return Max.x - Min.x; } - float GetHeight() const { return Max.y - Min.y; } - float GetArea() const { return (Max.x - Min.x) * (Max.y - Min.y); } - ImVec2 GetTL() const { return Min; } // Top-left - ImVec2 GetTR() const { return ImVec2(Max.x, Min.y); } // Top-right - ImVec2 GetBL() const { return ImVec2(Min.x, Max.y); } // Bottom-left - ImVec2 GetBR() const { return Max; } // Bottom-right - bool Contains(const ImVec2& p) const { return p.x >= Min.x && p.y >= Min.y && p.x < Max.x && p.y < Max.y; } - bool Contains(const ImRect& r) const { return r.Min.x >= Min.x && r.Min.y >= Min.y && r.Max.x <= Max.x && r.Max.y <= Max.y; } - bool Overlaps(const ImRect& r) const { return r.Min.y < Max.y && r.Max.y > Min.y && r.Min.x < Max.x && r.Max.x > Min.x; } - void Add(const ImVec2& p) { if (Min.x > p.x) Min.x = p.x; if (Min.y > p.y) Min.y = p.y; if (Max.x < p.x) Max.x = p.x; if (Max.y < p.y) Max.y = p.y; } - void Add(const ImRect& r) { if (Min.x > r.Min.x) Min.x = r.Min.x; if (Min.y > r.Min.y) Min.y = r.Min.y; if (Max.x < r.Max.x) Max.x = r.Max.x; if (Max.y < r.Max.y) Max.y = r.Max.y; } - void Expand(const float amount) { Min.x -= amount; Min.y -= amount; Max.x += amount; Max.y += amount; } - void Expand(const ImVec2& amount) { Min.x -= amount.x; Min.y -= amount.y; Max.x += amount.x; Max.y += amount.y; } - void Translate(const ImVec2& d) { Min.x += d.x; Min.y += d.y; Max.x += d.x; Max.y += d.y; } - void TranslateX(float dx) { Min.x += dx; Max.x += dx; } - void TranslateY(float dy) { Min.y += dy; Max.y += dy; } - void ClipWith(const ImRect& r) { Min = ImMax(Min, r.Min); Max = ImMin(Max, r.Max); } // Simple version, may lead to an inverted rectangle, which is fine for Contains/Overlaps test but not for display. - void ClipWithFull(const ImRect& r) { Min = ImClamp(Min, r.Min, r.Max); Max = ImClamp(Max, r.Min, r.Max); } // Full version, ensure both points are fully clipped. - void Floor() { Min.x = IM_FLOOR(Min.x); Min.y = IM_FLOOR(Min.y); Max.x = IM_FLOOR(Max.x); Max.y = IM_FLOOR(Max.y); } - bool IsInverted() const { return Min.x > Max.x || Min.y > Max.y; } - ImVec4 ToVec4() const { return ImVec4(Min.x, Min.y, Max.x, Max.y); } -}; -IM_MSVC_RUNTIME_CHECKS_RESTORE - -// Helper: ImBitArray -inline bool ImBitArrayTestBit(const ImU32* arr, int n) { ImU32 mask = (ImU32)1 << (n & 31); return (arr[n >> 5] & mask) != 0; } -inline void ImBitArrayClearBit(ImU32* arr, int n) { ImU32 mask = (ImU32)1 << (n & 31); arr[n >> 5] &= ~mask; } -inline void ImBitArraySetBit(ImU32* arr, int n) { ImU32 mask = (ImU32)1 << (n & 31); arr[n >> 5] |= mask; } -inline void ImBitArraySetBitRange(ImU32* arr, int n, int n2) // Works on range [n..n2) -{ - n2--; - while (n <= n2) - { - int a_mod = (n & 31); - int b_mod = (n2 > (n | 31) ? 31 : (n2 & 31)) + 1; - ImU32 mask = (ImU32)(((ImU64)1 << b_mod) - 1) & ~(ImU32)(((ImU64)1 << a_mod) - 1); - arr[n >> 5] |= mask; - n = (n + 32) & ~31; - } -} - -// Helper: ImBitArray class (wrapper over ImBitArray functions) -// Store 1-bit per value. -template -struct IMGUI_API ImBitArray -{ - ImU32 Storage[(BITCOUNT + 31) >> 5]; - ImBitArray() { ClearAllBits(); } - void ClearAllBits() { memset(Storage, 0, sizeof(Storage)); } - void SetAllBits() { memset(Storage, 255, sizeof(Storage)); } - bool TestBit(int n) const { IM_ASSERT(n < BITCOUNT); return ImBitArrayTestBit(Storage, n); } - void SetBit(int n) { IM_ASSERT(n < BITCOUNT); ImBitArraySetBit(Storage, n); } - void ClearBit(int n) { IM_ASSERT(n < BITCOUNT); ImBitArrayClearBit(Storage, n); } - void SetBitRange(int n, int n2) { ImBitArraySetBitRange(Storage, n, n2); } // Works on range [n..n2) -}; - -// Helper: ImBitVector -// Store 1-bit per value. -struct IMGUI_API ImBitVector -{ - ImVector Storage; - void Create(int sz) { Storage.resize((sz + 31) >> 5); memset(Storage.Data, 0, (size_t)Storage.Size * sizeof(Storage.Data[0])); } - void Clear() { Storage.clear(); } - bool TestBit(int n) const { IM_ASSERT(n < (Storage.Size << 5)); return ImBitArrayTestBit(Storage.Data, n); } - void SetBit(int n) { IM_ASSERT(n < (Storage.Size << 5)); ImBitArraySetBit(Storage.Data, n); } - void ClearBit(int n) { IM_ASSERT(n < (Storage.Size << 5)); ImBitArrayClearBit(Storage.Data, n); } -}; - -// Helper: ImSpan<> -// Pointing to a span of data we don't own. -template -struct ImSpan -{ - T* Data; - T* DataEnd; - - // Constructors, destructor - inline ImSpan() { Data = DataEnd = NULL; } - inline ImSpan(T* data, int size) { Data = data; DataEnd = data + size; } - inline ImSpan(T* data, T* data_end) { Data = data; DataEnd = data_end; } - - inline void set(T* data, int size) { Data = data; DataEnd = data + size; } - inline void set(T* data, T* data_end) { Data = data; DataEnd = data_end; } - inline int size() const { return (int)(ptrdiff_t)(DataEnd - Data); } - inline int size_in_bytes() const { return (int)(ptrdiff_t)(DataEnd - Data) * (int)sizeof(T); } - inline T& operator[](int i) { T* p = Data + i; IM_ASSERT(p >= Data && p < DataEnd); return *p; } - inline const T& operator[](int i) const { const T* p = Data + i; IM_ASSERT(p >= Data && p < DataEnd); return *p; } - - inline T* begin() { return Data; } - inline const T* begin() const { return Data; } - inline T* end() { return DataEnd; } - inline const T* end() const { return DataEnd; } - - // Utilities - inline int index_from_ptr(const T* it) const { IM_ASSERT(it >= Data && it < DataEnd); const ptrdiff_t off = it - Data; return (int)off; } -}; - -// Helper: ImSpanAllocator<> -// Facilitate storing multiple chunks into a single large block (the "arena") -// - Usage: call Reserve() N times, allocate GetArenaSizeInBytes() worth, pass it to SetArenaBasePtr(), call GetSpan() N times to retrieve the aligned ranges. -template -struct ImSpanAllocator -{ - char* BasePtr; - int CurrOff; - int CurrIdx; - int Offsets[CHUNKS]; - int Sizes[CHUNKS]; - - ImSpanAllocator() { memset(this, 0, sizeof(*this)); } - inline void Reserve(int n, size_t sz, int a=4) { IM_ASSERT(n == CurrIdx && n < CHUNKS); CurrOff = IM_MEMALIGN(CurrOff, a); Offsets[n] = CurrOff; Sizes[n] = (int)sz; CurrIdx++; CurrOff += (int)sz; } - inline int GetArenaSizeInBytes() { return CurrOff; } - inline void SetArenaBasePtr(void* base_ptr) { BasePtr = (char*)base_ptr; } - inline void* GetSpanPtrBegin(int n) { IM_ASSERT(n >= 0 && n < CHUNKS && CurrIdx == CHUNKS); return (void*)(BasePtr + Offsets[n]); } - inline void* GetSpanPtrEnd(int n) { IM_ASSERT(n >= 0 && n < CHUNKS && CurrIdx == CHUNKS); return (void*)(BasePtr + Offsets[n] + Sizes[n]); } - template - inline void GetSpan(int n, ImSpan* span) { span->set((T*)GetSpanPtrBegin(n), (T*)GetSpanPtrEnd(n)); } -}; - -// Helper: ImPool<> -// Basic keyed storage for contiguous instances, slow/amortized insertion, O(1) indexable, O(Log N) queries by ID over a dense/hot buffer, -// Honor constructor/destructor. Add/remove invalidate all pointers. Indexes have the same lifetime as the associated object. -typedef int ImPoolIdx; -template -struct IMGUI_API ImPool -{ - ImVector Buf; // Contiguous data - ImGuiStorage Map; // ID->Index - ImPoolIdx FreeIdx; // Next free idx to use - ImPoolIdx AliveCount; // Number of active/alive items (for display purpose) - - ImPool() { FreeIdx = AliveCount = 0; } - ~ImPool() { Clear(); } - T* GetByKey(ImGuiID key) { int idx = Map.GetInt(key, -1); return (idx != -1) ? &Buf[idx] : NULL; } - T* GetByIndex(ImPoolIdx n) { return &Buf[n]; } - ImPoolIdx GetIndex(const T* p) const { IM_ASSERT(p >= Buf.Data && p < Buf.Data + Buf.Size); return (ImPoolIdx)(p - Buf.Data); } - T* GetOrAddByKey(ImGuiID key) { int* p_idx = Map.GetIntRef(key, -1); if (*p_idx != -1) return &Buf[*p_idx]; *p_idx = FreeIdx; return Add(); } - bool Contains(const T* p) const { return (p >= Buf.Data && p < Buf.Data + Buf.Size); } - void Clear() { for (int n = 0; n < Map.Data.Size; n++) { int idx = Map.Data[n].val_i; if (idx != -1) Buf[idx].~T(); } Map.Clear(); Buf.clear(); FreeIdx = AliveCount = 0; } - T* Add() { int idx = FreeIdx; if (idx == Buf.Size) { Buf.resize(Buf.Size + 1); FreeIdx++; } else { FreeIdx = *(int*)&Buf[idx]; } IM_PLACEMENT_NEW(&Buf[idx]) T(); AliveCount++; return &Buf[idx]; } - void Remove(ImGuiID key, const T* p) { Remove(key, GetIndex(p)); } - void Remove(ImGuiID key, ImPoolIdx idx) { Buf[idx].~T(); *(int*)&Buf[idx] = FreeIdx; FreeIdx = idx; Map.SetInt(key, -1); AliveCount--; } - void Reserve(int capacity) { Buf.reserve(capacity); Map.Data.reserve(capacity); } - - // To iterate a ImPool: for (int n = 0; n < pool.GetMapSize(); n++) if (T* t = pool.TryGetMapData(n)) { ... } - // Can be avoided if you know .Remove() has never been called on the pool, or AliveCount == GetMapSize() - int GetAliveCount() const { return AliveCount; } // Number of active/alive items in the pool (for display purpose) - int GetBufSize() const { return Buf.Size; } - int GetMapSize() const { return Map.Data.Size; } // It is the map we need iterate to find valid items, since we don't have "alive" storage anywhere - T* TryGetMapData(ImPoolIdx n) { int idx = Map.Data[n].val_i; if (idx == -1) return NULL; return GetByIndex(idx); } -#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS - int GetSize() { return GetMapSize(); } // For ImPlot: should use GetMapSize() from (IMGUI_VERSION_NUM >= 18304) -#endif -}; - -// Helper: ImChunkStream<> -// Build and iterate a contiguous stream of variable-sized structures. -// This is used by Settings to store persistent data while reducing allocation count. -// We store the chunk size first, and align the final size on 4 bytes boundaries. -// The tedious/zealous amount of casting is to avoid -Wcast-align warnings. -template -struct IMGUI_API ImChunkStream -{ - ImVector Buf; - - void clear() { Buf.clear(); } - bool empty() const { return Buf.Size == 0; } - int size() const { return Buf.Size; } - T* alloc_chunk(size_t sz) { size_t HDR_SZ = 4; sz = IM_MEMALIGN(HDR_SZ + sz, 4u); int off = Buf.Size; Buf.resize(off + (int)sz); ((int*)(void*)(Buf.Data + off))[0] = (int)sz; return (T*)(void*)(Buf.Data + off + (int)HDR_SZ); } - T* begin() { size_t HDR_SZ = 4; if (!Buf.Data) return NULL; return (T*)(void*)(Buf.Data + HDR_SZ); } - T* next_chunk(T* p) { size_t HDR_SZ = 4; IM_ASSERT(p >= begin() && p < end()); p = (T*)(void*)((char*)(void*)p + chunk_size(p)); if (p == (T*)(void*)((char*)end() + HDR_SZ)) return (T*)0; IM_ASSERT(p < end()); return p; } - int chunk_size(const T* p) { return ((const int*)p)[-1]; } - T* end() { return (T*)(void*)(Buf.Data + Buf.Size); } - int offset_from_ptr(const T* p) { IM_ASSERT(p >= begin() && p < end()); const ptrdiff_t off = (const char*)p - Buf.Data; return (int)off; } - T* ptr_from_offset(int off) { IM_ASSERT(off >= 4 && off < Buf.Size); return (T*)(void*)(Buf.Data + off); } - void swap(ImChunkStream& rhs) { rhs.Buf.swap(Buf); } - -}; - -//----------------------------------------------------------------------------- -// [SECTION] ImDrawList support -//----------------------------------------------------------------------------- - -// ImDrawList: Helper function to calculate a circle's segment count given its radius and a "maximum error" value. -// Estimation of number of circle segment based on error is derived using method described in https://stackoverflow.com/a/2244088/15194693 -// Number of segments (N) is calculated using equation: -// N = ceil ( pi / acos(1 - error / r) ) where r > 0, error <= r -// Our equation is significantly simpler that one in the post thanks for choosing segment that is -// perpendicular to X axis. Follow steps in the article from this starting condition and you will -// will get this result. -// -// Rendering circles with an odd number of segments, while mathematically correct will produce -// asymmetrical results on the raster grid. Therefore we're rounding N to next even number (7->8, 8->8, 9->10 etc.) -// -#define IM_ROUNDUP_TO_EVEN(_V) ((((_V) + 1) / 2) * 2) -#define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MIN 4 -#define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX 512 -#define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(_RAD,_MAXERROR) ImClamp(IM_ROUNDUP_TO_EVEN((int)ImCeil(IM_PI / ImAcos(1 - ImMin((_MAXERROR), (_RAD)) / (_RAD)))), IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MIN, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX) - -// Raw equation from IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC rewritten for 'r' and 'error'. -#define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC_R(_N,_MAXERROR) ((_MAXERROR) / (1 - ImCos(IM_PI / ImMax((float)(_N), IM_PI)))) -#define IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC_ERROR(_N,_RAD) ((1 - ImCos(IM_PI / ImMax((float)(_N), IM_PI))) / (_RAD)) - -// ImDrawList: Lookup table size for adaptive arc drawing, cover full circle. -#ifndef IM_DRAWLIST_ARCFAST_TABLE_SIZE -#define IM_DRAWLIST_ARCFAST_TABLE_SIZE 48 // Number of samples in lookup table. -#endif -#define IM_DRAWLIST_ARCFAST_SAMPLE_MAX IM_DRAWLIST_ARCFAST_TABLE_SIZE // Sample index _PathArcToFastEx() for 360 angle. - -// Data shared between all ImDrawList instances -// You may want to create your own instance of this if you want to use ImDrawList completely without ImGui. In that case, watch out for future changes to this structure. -struct IMGUI_API ImDrawListSharedData -{ - ImVec2 TexUvWhitePixel; // UV of white pixel in the atlas - ImFont* Font; // Current/default font (optional, for simplified AddText overload) - float FontSize; // Current/default font size (optional, for simplified AddText overload) - float CurveTessellationTol; // Tessellation tolerance when using PathBezierCurveTo() - float CircleSegmentMaxError; // Number of circle segments to use per pixel of radius for AddCircle() etc - ImVec4 ClipRectFullscreen; // Value for PushClipRectFullscreen() - ImDrawListFlags InitialFlags; // Initial flags at the beginning of the frame (it is possible to alter flags on a per-drawlist basis afterwards) - - // [Internal] Lookup tables - ImVec2 ArcFastVtx[IM_DRAWLIST_ARCFAST_TABLE_SIZE]; // Sample points on the quarter of the circle. - float ArcFastRadiusCutoff; // Cutoff radius after which arc drawing will fallback to slower PathArcTo() - ImU8 CircleSegmentCounts[64]; // Precomputed segment count for given radius before we calculate it dynamically (to avoid calculation overhead) - const ImVec4* TexUvLines; // UV of anti-aliased lines in the atlas - - ImDrawListSharedData(); - void SetCircleTessellationMaxError(float max_error); -}; - -struct ImDrawDataBuilder -{ - ImVector Layers[2]; // Global layers for: regular, tooltip - - void Clear() { for (int n = 0; n < IM_ARRAYSIZE(Layers); n++) Layers[n].resize(0); } - void ClearFreeMemory() { for (int n = 0; n < IM_ARRAYSIZE(Layers); n++) Layers[n].clear(); } - int GetDrawListCount() const { int count = 0; for (int n = 0; n < IM_ARRAYSIZE(Layers); n++) count += Layers[n].Size; return count; } - IMGUI_API void FlattenIntoSingleLayer(); -}; - -//----------------------------------------------------------------------------- -// [SECTION] Widgets support: flags, enums, data structures -//----------------------------------------------------------------------------- - -// Transient per-window flags, reset at the beginning of the frame. For child window, inherited from parent on first Begin(). -// This is going to be exposed in imgui.h when stabilized enough. -enum ImGuiItemFlags_ -{ - ImGuiItemFlags_None = 0, - ImGuiItemFlags_NoTabStop = 1 << 0, // false // Disable keyboard tabbing (FIXME: should merge with _NoNav) - ImGuiItemFlags_ButtonRepeat = 1 << 1, // false // Button() will return true multiple times based on io.KeyRepeatDelay and io.KeyRepeatRate settings. - ImGuiItemFlags_Disabled = 1 << 2, // false // Disable interactions but doesn't affect visuals. See BeginDisabled()/EndDisabled(). See github.com/ocornut/imgui/issues/211 - ImGuiItemFlags_NoNav = 1 << 3, // false // Disable keyboard/gamepad directional navigation (FIXME: should merge with _NoTabStop) - ImGuiItemFlags_NoNavDefaultFocus = 1 << 4, // false // Disable item being a candidate for default focus (e.g. used by title bar items) - ImGuiItemFlags_SelectableDontClosePopup = 1 << 5, // false // Disable MenuItem/Selectable() automatically closing their popup window - ImGuiItemFlags_MixedValue = 1 << 6, // false // [BETA] Represent a mixed/indeterminate value, generally multi-selection where values differ. Currently only supported by Checkbox() (later should support all sorts of widgets) - ImGuiItemFlags_ReadOnly = 1 << 7, // false // [ALPHA] Allow hovering interactions but underlying value is not changed. - ImGuiItemFlags_Inputable = 1 << 8 // false // [WIP] Auto-activate input mode when tab focused. Currently only used and supported by a few items before it becomes a generic feature. -}; - -// Storage for LastItem data -enum ImGuiItemStatusFlags_ -{ - ImGuiItemStatusFlags_None = 0, - ImGuiItemStatusFlags_HoveredRect = 1 << 0, // Mouse position is within item rectangle (does NOT mean that the window is in correct z-order and can be hovered!, this is only one part of the most-common IsItemHovered test) - ImGuiItemStatusFlags_HasDisplayRect = 1 << 1, // g.LastItemData.DisplayRect is valid - ImGuiItemStatusFlags_Edited = 1 << 2, // Value exposed by item was edited in the current frame (should match the bool return value of most widgets) - ImGuiItemStatusFlags_ToggledSelection = 1 << 3, // Set when Selectable(), TreeNode() reports toggling a selection. We can't report "Selected", only state changes, in order to easily handle clipping with less issues. - ImGuiItemStatusFlags_ToggledOpen = 1 << 4, // Set when TreeNode() reports toggling their open state. - ImGuiItemStatusFlags_HasDeactivated = 1 << 5, // Set if the widget/group is able to provide data for the ImGuiItemStatusFlags_Deactivated flag. - ImGuiItemStatusFlags_Deactivated = 1 << 6, // Only valid if ImGuiItemStatusFlags_HasDeactivated is set. - ImGuiItemStatusFlags_HoveredWindow = 1 << 7, // Override the HoveredWindow test to allow cross-window hover testing. - ImGuiItemStatusFlags_FocusedByTabbing = 1 << 8 // Set when the Focusable item just got focused by Tabbing (FIXME: to be removed soon) - -#ifdef IMGUI_ENABLE_TEST_ENGINE - , // [imgui_tests only] - ImGuiItemStatusFlags_Openable = 1 << 20, // - ImGuiItemStatusFlags_Opened = 1 << 21, // - ImGuiItemStatusFlags_Checkable = 1 << 22, // - ImGuiItemStatusFlags_Checked = 1 << 23 // -#endif -}; - -// Extend ImGuiInputTextFlags_ -enum ImGuiInputTextFlagsPrivate_ -{ - // [Internal] - ImGuiInputTextFlags_Multiline = 1 << 26, // For internal use by InputTextMultiline() - ImGuiInputTextFlags_NoMarkEdited = 1 << 27, // For internal use by functions using InputText() before reformatting data - ImGuiInputTextFlags_MergedItem = 1 << 28 // For internal use by TempInputText(), will skip calling ItemAdd(). Require bounding-box to strictly match. -}; - -// Extend ImGuiButtonFlags_ -enum ImGuiButtonFlagsPrivate_ -{ - ImGuiButtonFlags_PressedOnClick = 1 << 4, // return true on click (mouse down event) - ImGuiButtonFlags_PressedOnClickRelease = 1 << 5, // [Default] return true on click + release on same item <-- this is what the majority of Button are using - ImGuiButtonFlags_PressedOnClickReleaseAnywhere = 1 << 6, // return true on click + release even if the release event is not done while hovering the item - ImGuiButtonFlags_PressedOnRelease = 1 << 7, // return true on release (default requires click+release) - ImGuiButtonFlags_PressedOnDoubleClick = 1 << 8, // return true on double-click (default requires click+release) - ImGuiButtonFlags_PressedOnDragDropHold = 1 << 9, // return true when held into while we are drag and dropping another item (used by e.g. tree nodes, collapsing headers) - ImGuiButtonFlags_Repeat = 1 << 10, // hold to repeat - ImGuiButtonFlags_FlattenChildren = 1 << 11, // allow interactions even if a child window is overlapping - ImGuiButtonFlags_AllowItemOverlap = 1 << 12, // require previous frame HoveredId to either match id or be null before being usable, use along with SetItemAllowOverlap() - ImGuiButtonFlags_DontClosePopups = 1 << 13, // disable automatically closing parent popup on press // [UNUSED] - //ImGuiButtonFlags_Disabled = 1 << 14, // disable interactions -> use BeginDisabled() or ImGuiItemFlags_Disabled - ImGuiButtonFlags_AlignTextBaseLine = 1 << 15, // vertically align button to match text baseline - ButtonEx() only // FIXME: Should be removed and handled by SmallButton(), not possible currently because of DC.CursorPosPrevLine - ImGuiButtonFlags_NoKeyModifiers = 1 << 16, // disable mouse interaction if a key modifier is held - ImGuiButtonFlags_NoHoldingActiveId = 1 << 17, // don't set ActiveId while holding the mouse (ImGuiButtonFlags_PressedOnClick only) - ImGuiButtonFlags_NoNavFocus = 1 << 18, // don't override navigation focus when activated - ImGuiButtonFlags_NoHoveredOnFocus = 1 << 19, // don't report as hovered when nav focus is on this item - ImGuiButtonFlags_PressedOnMask_ = ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnClickReleaseAnywhere | ImGuiButtonFlags_PressedOnRelease | ImGuiButtonFlags_PressedOnDoubleClick | ImGuiButtonFlags_PressedOnDragDropHold, - ImGuiButtonFlags_PressedOnDefault_ = ImGuiButtonFlags_PressedOnClickRelease -}; - -// Extend ImGuiComboFlags_ -enum ImGuiComboFlagsPrivate_ -{ - ImGuiComboFlags_CustomPreview = 1 << 20 // enable BeginComboPreview() -}; - -// Extend ImGuiSliderFlags_ -enum ImGuiSliderFlagsPrivate_ -{ - ImGuiSliderFlags_Vertical = 1 << 20, // Should this slider be orientated vertically? - ImGuiSliderFlags_ReadOnly = 1 << 21 -}; - -// Extend ImGuiSelectableFlags_ -enum ImGuiSelectableFlagsPrivate_ -{ - // NB: need to be in sync with last value of ImGuiSelectableFlags_ - ImGuiSelectableFlags_NoHoldingActiveID = 1 << 20, - ImGuiSelectableFlags_SelectOnNav = 1 << 21, // (WIP) Auto-select when moved into. This is not exposed in public API as to handle multi-select and modifiers we will need user to explicitly control focus scope. May be replaced with a BeginSelection() API. - ImGuiSelectableFlags_SelectOnClick = 1 << 22, // Override button behavior to react on Click (default is Click+Release) - ImGuiSelectableFlags_SelectOnRelease = 1 << 23, // Override button behavior to react on Release (default is Click+Release) - ImGuiSelectableFlags_SpanAvailWidth = 1 << 24, // Span all avail width even if we declared less for layout purpose. FIXME: We may be able to remove this (added in 6251d379, 2bcafc86 for menus) - ImGuiSelectableFlags_DrawHoveredWhenHeld = 1 << 25, // Always show active when held, even is not hovered. This concept could probably be renamed/formalized somehow. - ImGuiSelectableFlags_SetNavIdOnHover = 1 << 26, // Set Nav/Focus ID on mouse hover (used by MenuItem) - ImGuiSelectableFlags_NoPadWithHalfSpacing = 1 << 27 // Disable padding each side with ItemSpacing * 0.5f -}; - -// Extend ImGuiTreeNodeFlags_ -enum ImGuiTreeNodeFlagsPrivate_ -{ - ImGuiTreeNodeFlags_ClipLabelForTrailingButton = 1 << 20 -}; - -enum ImGuiSeparatorFlags_ -{ - ImGuiSeparatorFlags_None = 0, - ImGuiSeparatorFlags_Horizontal = 1 << 0, // Axis default to current layout type, so generally Horizontal unless e.g. in a menu bar - ImGuiSeparatorFlags_Vertical = 1 << 1, - ImGuiSeparatorFlags_SpanAllColumns = 1 << 2 -}; - -enum ImGuiTextFlags_ -{ - ImGuiTextFlags_None = 0, - ImGuiTextFlags_NoWidthForLargeClippedText = 1 << 0 -}; - -enum ImGuiTooltipFlags_ -{ - ImGuiTooltipFlags_None = 0, - ImGuiTooltipFlags_OverridePreviousTooltip = 1 << 0 // Override will clear/ignore previously submitted tooltip (defaults to append) -}; - -// FIXME: this is in development, not exposed/functional as a generic feature yet. -// Horizontal/Vertical enums are fixed to 0/1 so they may be used to index ImVec2 -enum ImGuiLayoutType_ -{ - ImGuiLayoutType_Horizontal = 0, - ImGuiLayoutType_Vertical = 1 -}; - -enum ImGuiLogType -{ - ImGuiLogType_None = 0, - ImGuiLogType_TTY, - ImGuiLogType_File, - ImGuiLogType_Buffer, - ImGuiLogType_Clipboard -}; - -// X/Y enums are fixed to 0/1 so they may be used to index ImVec2 -enum ImGuiAxis -{ - ImGuiAxis_None = -1, - ImGuiAxis_X = 0, - ImGuiAxis_Y = 1 -}; - -enum ImGuiPlotType -{ - ImGuiPlotType_Lines, - ImGuiPlotType_Histogram -}; - -enum ImGuiInputSource -{ - ImGuiInputSource_None = 0, - ImGuiInputSource_Mouse, - ImGuiInputSource_Keyboard, - ImGuiInputSource_Gamepad, - ImGuiInputSource_Nav, // Stored in g.ActiveIdSource only - ImGuiInputSource_Clipboard, // Currently only used by InputText() - ImGuiInputSource_COUNT -}; - -// FIXME-NAV: Clarify/expose various repeat delay/rate -enum ImGuiInputReadMode -{ - ImGuiInputReadMode_Down, - ImGuiInputReadMode_Pressed, - ImGuiInputReadMode_Released, - ImGuiInputReadMode_Repeat, - ImGuiInputReadMode_RepeatSlow, - ImGuiInputReadMode_RepeatFast -}; - -enum ImGuiPopupPositionPolicy -{ - ImGuiPopupPositionPolicy_Default, - ImGuiPopupPositionPolicy_ComboBox, - ImGuiPopupPositionPolicy_Tooltip -}; - -struct ImGuiDataTypeTempStorage -{ - ImU8 Data[8]; // Can fit any data up to ImGuiDataType_COUNT -}; - -// Type information associated to one ImGuiDataType. Retrieve with DataTypeGetInfo(). -struct ImGuiDataTypeInfo -{ - size_t Size; // Size in bytes - const char* Name; // Short descriptive name for the type, for debugging - const char* PrintFmt; // Default printf format for the type - const char* ScanFmt; // Default scanf format for the type -}; - -// Extend ImGuiDataType_ -enum ImGuiDataTypePrivate_ -{ - ImGuiDataType_String = ImGuiDataType_COUNT + 1, - ImGuiDataType_Pointer, - ImGuiDataType_ID -}; - -// Stacked color modifier, backup of modified data so we can restore it -struct ImGuiColorMod -{ - ImGuiCol Col; - ImVec4 BackupValue; -}; - -// Stacked style modifier, backup of modified data so we can restore it. Data type inferred from the variable. -struct ImGuiStyleMod -{ - ImGuiStyleVar VarIdx; - union { int BackupInt[2]; float BackupFloat[2]; }; - ImGuiStyleMod(ImGuiStyleVar idx, int v) { VarIdx = idx; BackupInt[0] = v; } - ImGuiStyleMod(ImGuiStyleVar idx, float v) { VarIdx = idx; BackupFloat[0] = v; } - ImGuiStyleMod(ImGuiStyleVar idx, ImVec2 v) { VarIdx = idx; BackupFloat[0] = v.x; BackupFloat[1] = v.y; } -}; - -// Storage data for BeginComboPreview()/EndComboPreview() -struct IMGUI_API ImGuiComboPreviewData -{ - ImRect PreviewRect; - ImVec2 BackupCursorPos; - ImVec2 BackupCursorMaxPos; - ImVec2 BackupCursorPosPrevLine; - float BackupPrevLineTextBaseOffset; - ImGuiLayoutType BackupLayout; - - ImGuiComboPreviewData() { memset(this, 0, sizeof(*this)); } -}; - -// Stacked storage data for BeginGroup()/EndGroup() -struct IMGUI_API ImGuiGroupData -{ - ImGuiID WindowID; - ImVec2 BackupCursorPos; - ImVec2 BackupCursorMaxPos; - ImVec1 BackupIndent; - ImVec1 BackupGroupOffset; - ImVec2 BackupCurrLineSize; - float BackupCurrLineTextBaseOffset; - ImGuiID BackupActiveIdIsAlive; - bool BackupActiveIdPreviousFrameIsAlive; - bool BackupHoveredIdIsAlive; - bool EmitItem; -}; - -// Simple column measurement, currently used for MenuItem() only.. This is very short-sighted/throw-away code and NOT a generic helper. -struct IMGUI_API ImGuiMenuColumns -{ - ImU32 TotalWidth; - ImU32 NextTotalWidth; - ImU16 Spacing; - ImU16 OffsetIcon; // Always zero for now - ImU16 OffsetLabel; // Offsets are locked in Update() - ImU16 OffsetShortcut; - ImU16 OffsetMark; - ImU16 Widths[4]; // Width of: Icon, Label, Shortcut, Mark (accumulators for current frame) - - ImGuiMenuColumns() { memset(this, 0, sizeof(*this)); } - void Update(float spacing, bool window_reappearing); - float DeclColumns(float w_icon, float w_label, float w_shortcut, float w_mark); - void CalcNextTotalWidth(bool update_offsets); -}; - -// Internal state of the currently focused/edited text input box -// For a given item ID, access with ImGui::GetInputTextState() -struct IMGUI_API ImGuiInputTextState -{ - ImGuiID ID; // widget id owning the text state - int CurLenW, CurLenA; // we need to maintain our buffer length in both UTF-8 and wchar format. UTF-8 length is valid even if TextA is not. - ImVector TextW; // edit buffer, we need to persist but can't guarantee the persistence of the user-provided buffer. so we copy into own buffer. - ImVector TextA; // temporary UTF8 buffer for callbacks and other operations. this is not updated in every code-path! size=capacity. - ImVector InitialTextA; // backup of end-user buffer at the time of focus (in UTF-8, unaltered) - bool TextAIsValid; // temporary UTF8 buffer is not initially valid before we make the widget active (until then we pull the data from user argument) - int BufCapacityA; // end-user buffer capacity - float ScrollX; // horizontal scrolling/offset - ImStb::STB_TexteditState Stb; // state for stb_textedit.h - float CursorAnim; // timer for cursor blink, reset on every user action so the cursor reappears immediately - bool CursorFollow; // set when we want scrolling to follow the current cursor position (not always!) - bool SelectedAllMouseLock; // after a double-click to select all, we ignore further mouse drags to update selection - bool Edited; // edited this frame - ImGuiInputTextFlags Flags; // copy of InputText() flags - ImGuiInputTextCallback UserCallback; // " - void* UserCallbackData; // " - - ImGuiInputTextState() { memset(this, 0, sizeof(*this)); } - void ClearText() { CurLenW = CurLenA = 0; TextW[0] = 0; TextA[0] = 0; CursorClamp(); } - void ClearFreeMemory() { TextW.clear(); TextA.clear(); InitialTextA.clear(); } - int GetUndoAvailCount() const { return Stb.undostate.undo_point; } - int GetRedoAvailCount() const { return STB_TEXTEDIT_UNDOSTATECOUNT - Stb.undostate.redo_point; } - void OnKeyPressed(int key); // Cannot be inline because we call in code in stb_textedit.h implementation - - // Cursor & Selection - void CursorAnimReset() { CursorAnim = -0.30f; } // After a user-input the cursor stays on for a while without blinking - void CursorClamp() { Stb.cursor = ImMin(Stb.cursor, CurLenW); Stb.select_start = ImMin(Stb.select_start, CurLenW); Stb.select_end = ImMin(Stb.select_end, CurLenW); } - bool HasSelection() const { return Stb.select_start != Stb.select_end; } - void ClearSelection() { Stb.select_start = Stb.select_end = Stb.cursor; } - int GetCursorPos() const { return Stb.cursor; } - int GetSelectionStart() const { return Stb.select_start; } - int GetSelectionEnd() const { return Stb.select_end; } - void SelectAll() { Stb.select_start = 0; Stb.cursor = Stb.select_end = CurLenW; Stb.has_preferred_x = 0; } -}; - -// Storage for current popup stack -struct ImGuiPopupData -{ - ImGuiID PopupId; // Set on OpenPopup() - ImGuiWindow* Window; // Resolved on BeginPopup() - may stay unresolved if user never calls OpenPopup() - ImGuiWindow* SourceWindow; // Set on OpenPopup() copy of NavWindow at the time of opening the popup - int OpenFrameCount; // Set on OpenPopup() - ImGuiID OpenParentId; // Set on OpenPopup(), we need this to differentiate multiple menu sets from each others (e.g. inside menu bar vs loose menu items) - ImVec2 OpenPopupPos; // Set on OpenPopup(), preferred popup position (typically == OpenMousePos when using mouse) - ImVec2 OpenMousePos; // Set on OpenPopup(), copy of mouse position at the time of opening popup - - ImGuiPopupData() { memset(this, 0, sizeof(*this)); OpenFrameCount = -1; } -}; - -enum ImGuiNextWindowDataFlags_ -{ - ImGuiNextWindowDataFlags_None = 0, - ImGuiNextWindowDataFlags_HasPos = 1 << 0, - ImGuiNextWindowDataFlags_HasSize = 1 << 1, - ImGuiNextWindowDataFlags_HasContentSize = 1 << 2, - ImGuiNextWindowDataFlags_HasCollapsed = 1 << 3, - ImGuiNextWindowDataFlags_HasSizeConstraint = 1 << 4, - ImGuiNextWindowDataFlags_HasFocus = 1 << 5, - ImGuiNextWindowDataFlags_HasBgAlpha = 1 << 6, - ImGuiNextWindowDataFlags_HasScroll = 1 << 7 -}; - -// Storage for SetNexWindow** functions -struct ImGuiNextWindowData -{ - ImGuiNextWindowDataFlags Flags; - ImGuiCond PosCond; - ImGuiCond SizeCond; - ImGuiCond CollapsedCond; - ImVec2 PosVal; - ImVec2 PosPivotVal; - ImVec2 SizeVal; - ImVec2 ContentSizeVal; - ImVec2 ScrollVal; - bool CollapsedVal; - ImRect SizeConstraintRect; - ImGuiSizeCallback SizeCallback; - void* SizeCallbackUserData; - float BgAlphaVal; // Override background alpha - ImVec2 MenuBarOffsetMinVal; // (Always on) This is not exposed publicly, so we don't clear it and it doesn't have a corresponding flag (could we? for consistency?) - - ImGuiNextWindowData() { memset(this, 0, sizeof(*this)); } - inline void ClearFlags() { Flags = ImGuiNextWindowDataFlags_None; } -}; - -enum ImGuiNextItemDataFlags_ -{ - ImGuiNextItemDataFlags_None = 0, - ImGuiNextItemDataFlags_HasWidth = 1 << 0, - ImGuiNextItemDataFlags_HasOpen = 1 << 1 -}; - -struct ImGuiNextItemData -{ - ImGuiNextItemDataFlags Flags; - float Width; // Set by SetNextItemWidth() - ImGuiID FocusScopeId; // Set by SetNextItemMultiSelectData() (!= 0 signify value has been set, so it's an alternate version of HasSelectionData, we don't use Flags for this because they are cleared too early. This is mostly used for debugging) - ImGuiCond OpenCond; - bool OpenVal; // Set by SetNextItemOpen() - - ImGuiNextItemData() { memset(this, 0, sizeof(*this)); } - inline void ClearFlags() { Flags = ImGuiNextItemDataFlags_None; } // Also cleared manually by ItemAdd()! -}; - -// Status storage for the last submitted item -struct ImGuiLastItemData -{ - ImGuiID ID; - ImGuiItemFlags InFlags; // See ImGuiItemFlags_ - ImGuiItemStatusFlags StatusFlags; // See ImGuiItemStatusFlags_ - ImRect Rect; // Full rectangle - ImRect NavRect; // Navigation scoring rectangle (not displayed) - ImRect DisplayRect; // Display rectangle (only if ImGuiItemStatusFlags_HasDisplayRect is set) - - ImGuiLastItemData() { memset(this, 0, sizeof(*this)); } -}; - -struct IMGUI_API ImGuiStackSizes -{ - short SizeOfIDStack; - short SizeOfColorStack; - short SizeOfStyleVarStack; - short SizeOfFontStack; - short SizeOfFocusScopeStack; - short SizeOfGroupStack; - short SizeOfItemFlagsStack; - short SizeOfBeginPopupStack; - short SizeOfDisabledStack; - - ImGuiStackSizes() { memset(this, 0, sizeof(*this)); } - void SetToCurrentState(); - void CompareWithCurrentState(); -}; - -// Data saved for each window pushed into the stack -struct ImGuiWindowStackData -{ - ImGuiWindow* Window; - ImGuiLastItemData ParentLastItemDataBackup; - ImGuiStackSizes StackSizesOnBegin; // Store size of various stacks for asserting -}; - -struct ImGuiShrinkWidthItem -{ - int Index; - float Width; -}; - -struct ImGuiPtrOrIndex -{ - void* Ptr; // Either field can be set, not both. e.g. Dock node tab bars are loose while BeginTabBar() ones are in a pool. - int Index; // Usually index in a main pool. - - ImGuiPtrOrIndex(void* ptr) { Ptr = ptr; Index = -1; } - ImGuiPtrOrIndex(int index) { Ptr = NULL; Index = index; } -}; - -//----------------------------------------------------------------------------- -// [SECTION] Navigation support -//----------------------------------------------------------------------------- - -enum ImGuiActivateFlags_ -{ - ImGuiActivateFlags_None = 0, - ImGuiActivateFlags_PreferInput = 1 << 0, // Favor activation that requires keyboard text input (e.g. for Slider/Drag). Default if keyboard is available. - ImGuiActivateFlags_PreferTweak = 1 << 1, // Favor activation for tweaking with arrows or gamepad (e.g. for Slider/Drag). Default if keyboard is not available. - ImGuiActivateFlags_TryToPreserveState = 1 << 2 // Request widget to preserve state if it can (e.g. InputText will try to preserve cursor/selection) -}; - -// Early work-in-progress API for ScrollToItem() -enum ImGuiScrollFlags_ -{ - ImGuiScrollFlags_None = 0, - ImGuiScrollFlags_KeepVisibleEdgeX = 1 << 0, // If item is not visible: scroll as little as possible on X axis to bring item back into view [default for X axis] - ImGuiScrollFlags_KeepVisibleEdgeY = 1 << 1, // If item is not visible: scroll as little as possible on Y axis to bring item back into view [default for Y axis for windows that are already visible] - ImGuiScrollFlags_KeepVisibleCenterX = 1 << 2, // If item is not visible: scroll to make the item centered on X axis [rarely used] - ImGuiScrollFlags_KeepVisibleCenterY = 1 << 3, // If item is not visible: scroll to make the item centered on Y axis - ImGuiScrollFlags_AlwaysCenterX = 1 << 4, // Always center the result item on X axis [rarely used] - ImGuiScrollFlags_AlwaysCenterY = 1 << 5, // Always center the result item on Y axis [default for Y axis for appearing window) - ImGuiScrollFlags_NoScrollParent = 1 << 6, // Disable forwarding scrolling to parent window if required to keep item/rect visible (only scroll window the function was applied to). - ImGuiScrollFlags_MaskX_ = ImGuiScrollFlags_KeepVisibleEdgeX | ImGuiScrollFlags_KeepVisibleCenterX | ImGuiScrollFlags_AlwaysCenterX, - ImGuiScrollFlags_MaskY_ = ImGuiScrollFlags_KeepVisibleEdgeY | ImGuiScrollFlags_KeepVisibleCenterY | ImGuiScrollFlags_AlwaysCenterY -}; - -enum ImGuiNavHighlightFlags_ -{ - ImGuiNavHighlightFlags_None = 0, - ImGuiNavHighlightFlags_TypeDefault = 1 << 0, - ImGuiNavHighlightFlags_TypeThin = 1 << 1, - ImGuiNavHighlightFlags_AlwaysDraw = 1 << 2, // Draw rectangular highlight if (g.NavId == id) _even_ when using the mouse. - ImGuiNavHighlightFlags_NoRounding = 1 << 3 -}; - -enum ImGuiNavDirSourceFlags_ -{ - ImGuiNavDirSourceFlags_None = 0, - ImGuiNavDirSourceFlags_Keyboard = 1 << 0, - ImGuiNavDirSourceFlags_PadDPad = 1 << 1, - ImGuiNavDirSourceFlags_PadLStick = 1 << 2 -}; - -enum ImGuiNavMoveFlags_ -{ - ImGuiNavMoveFlags_None = 0, - ImGuiNavMoveFlags_LoopX = 1 << 0, // On failed request, restart from opposite side - ImGuiNavMoveFlags_LoopY = 1 << 1, - ImGuiNavMoveFlags_WrapX = 1 << 2, // On failed request, request from opposite side one line down (when NavDir==right) or one line up (when NavDir==left) - ImGuiNavMoveFlags_WrapY = 1 << 3, // This is not super useful but provided for completeness - ImGuiNavMoveFlags_AllowCurrentNavId = 1 << 4, // Allow scoring and considering the current NavId as a move target candidate. This is used when the move source is offset (e.g. pressing PageDown actually needs to send a Up move request, if we are pressing PageDown from the bottom-most item we need to stay in place) - ImGuiNavMoveFlags_AlsoScoreVisibleSet = 1 << 5, // Store alternate result in NavMoveResultLocalVisible that only comprise elements that are already fully visible (used by PageUp/PageDown) - ImGuiNavMoveFlags_ScrollToEdgeY = 1 << 6, // Force scrolling to min/max (used by Home/End) // FIXME-NAV: Aim to remove or reword, probably unnecessary - ImGuiNavMoveFlags_Forwarded = 1 << 7, - ImGuiNavMoveFlags_DebugNoResult = 1 << 8, // Dummy scoring for debug purpose, don't apply result - ImGuiNavMoveFlags_Tabbing = 1 << 9, // == Focus + Activate if item is Inputable + DontChangeNavHighlight - ImGuiNavMoveFlags_Activate = 1 << 10, - ImGuiNavMoveFlags_DontSetNavHighlight = 1 << 11 // Do not alter the visible state of keyboard vs mouse nav highlight -}; - -enum ImGuiNavLayer -{ - ImGuiNavLayer_Main = 0, // Main scrolling layer - ImGuiNavLayer_Menu = 1, // Menu layer (access with Alt/ImGuiNavInput_Menu) - ImGuiNavLayer_COUNT -}; - -struct ImGuiNavItemData -{ - ImGuiWindow* Window; // Init,Move // Best candidate window (result->ItemWindow->RootWindowForNav == request->Window) - ImGuiID ID; // Init,Move // Best candidate item ID - ImGuiID FocusScopeId; // Init,Move // Best candidate focus scope ID - ImRect RectRel; // Init,Move // Best candidate bounding box in window relative space - ImGuiItemFlags InFlags; // ????,Move // Best candidate item flags - float DistBox; // Move // Best candidate box distance to current NavId - float DistCenter; // Move // Best candidate center distance to current NavId - float DistAxial; // Move // Best candidate axial distance to current NavId - - ImGuiNavItemData() { Clear(); } - void Clear() { Window = NULL; ID = FocusScopeId = 0; InFlags = 0; DistBox = DistCenter = DistAxial = FLT_MAX; } -}; - -//----------------------------------------------------------------------------- -// [SECTION] Columns support -//----------------------------------------------------------------------------- - -// Flags for internal's BeginColumns(). Prefix using BeginTable() nowadays! -enum ImGuiOldColumnFlags_ -{ - ImGuiOldColumnFlags_None = 0, - ImGuiOldColumnFlags_NoBorder = 1 << 0, // Disable column dividers - ImGuiOldColumnFlags_NoResize = 1 << 1, // Disable resizing columns when clicking on the dividers - ImGuiOldColumnFlags_NoPreserveWidths = 1 << 2, // Disable column width preservation when adjusting columns - ImGuiOldColumnFlags_NoForceWithinWindow = 1 << 3, // Disable forcing columns to fit within window - ImGuiOldColumnFlags_GrowParentContentsSize = 1 << 4 // (WIP) Restore pre-1.51 behavior of extending the parent window contents size but _without affecting the columns width at all_. Will eventually remove. - - // Obsolete names (will be removed) -#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS - , ImGuiColumnsFlags_None = ImGuiOldColumnFlags_None, - ImGuiColumnsFlags_NoBorder = ImGuiOldColumnFlags_NoBorder, - ImGuiColumnsFlags_NoResize = ImGuiOldColumnFlags_NoResize, - ImGuiColumnsFlags_NoPreserveWidths = ImGuiOldColumnFlags_NoPreserveWidths, - ImGuiColumnsFlags_NoForceWithinWindow = ImGuiOldColumnFlags_NoForceWithinWindow, - ImGuiColumnsFlags_GrowParentContentsSize = ImGuiOldColumnFlags_GrowParentContentsSize -#endif -}; - -struct ImGuiOldColumnData -{ - float OffsetNorm; // Column start offset, normalized 0.0 (far left) -> 1.0 (far right) - float OffsetNormBeforeResize; - ImGuiOldColumnFlags Flags; // Not exposed - ImRect ClipRect; - - ImGuiOldColumnData() { memset(this, 0, sizeof(*this)); } -}; - -struct ImGuiOldColumns -{ - ImGuiID ID; - ImGuiOldColumnFlags Flags; - bool IsFirstFrame; - bool IsBeingResized; - int Current; - int Count; - float OffMinX, OffMaxX; // Offsets from HostWorkRect.Min.x - float LineMinY, LineMaxY; - float HostCursorPosY; // Backup of CursorPos at the time of BeginColumns() - float HostCursorMaxPosX; // Backup of CursorMaxPos at the time of BeginColumns() - ImRect HostInitialClipRect; // Backup of ClipRect at the time of BeginColumns() - ImRect HostBackupClipRect; // Backup of ClipRect during PushColumnsBackground()/PopColumnsBackground() - ImRect HostBackupParentWorkRect;//Backup of WorkRect at the time of BeginColumns() - ImVector Columns; - ImDrawListSplitter Splitter; - - ImGuiOldColumns() { memset(this, 0, sizeof(*this)); } -}; - -//----------------------------------------------------------------------------- -// [SECTION] Multi-select support -//----------------------------------------------------------------------------- - -#ifdef IMGUI_HAS_MULTI_SELECT -// -#endif // #ifdef IMGUI_HAS_MULTI_SELECT - -//----------------------------------------------------------------------------- -// [SECTION] Docking support -//----------------------------------------------------------------------------- - -#ifdef IMGUI_HAS_DOCK -// -#endif // #ifdef IMGUI_HAS_DOCK - -//----------------------------------------------------------------------------- -// [SECTION] Viewport support -//----------------------------------------------------------------------------- - -// ImGuiViewport Private/Internals fields (cardinal sin: we are using inheritance!) -// Every instance of ImGuiViewport is in fact a ImGuiViewportP. -struct ImGuiViewportP : public ImGuiViewport -{ - int DrawListsLastFrame[2]; // Last frame number the background (0) and foreground (1) draw lists were used - ImDrawList* DrawLists[2]; // Convenience background (0) and foreground (1) draw lists. We use them to draw software mouser cursor when io.MouseDrawCursor is set and to draw most debug overlays. - ImDrawData DrawDataP; - ImDrawDataBuilder DrawDataBuilder; - - ImVec2 WorkOffsetMin; // Work Area: Offset from Pos to top-left corner of Work Area. Generally (0,0) or (0,+main_menu_bar_height). Work Area is Full Area but without menu-bars/status-bars (so WorkArea always fit inside Pos/Size!) - ImVec2 WorkOffsetMax; // Work Area: Offset from Pos+Size to bottom-right corner of Work Area. Generally (0,0) or (0,-status_bar_height). - ImVec2 BuildWorkOffsetMin; // Work Area: Offset being built during current frame. Generally >= 0.0f. - ImVec2 BuildWorkOffsetMax; // Work Area: Offset being built during current frame. Generally <= 0.0f. - - ImGuiViewportP() { DrawListsLastFrame[0] = DrawListsLastFrame[1] = -1; DrawLists[0] = DrawLists[1] = NULL; } - ~ImGuiViewportP() { if (DrawLists[0]) IM_DELETE(DrawLists[0]); if (DrawLists[1]) IM_DELETE(DrawLists[1]); } - - // Calculate work rect pos/size given a set of offset (we have 1 pair of offset for rect locked from last frame data, and 1 pair for currently building rect) - ImVec2 CalcWorkRectPos(const ImVec2& off_min) const { return ImVec2(Pos.x + off_min.x, Pos.y + off_min.y); } - ImVec2 CalcWorkRectSize(const ImVec2& off_min, const ImVec2& off_max) const { return ImVec2(ImMax(0.0f, Size.x - off_min.x + off_max.x), ImMax(0.0f, Size.y - off_min.y + off_max.y)); } - void UpdateWorkRect() { WorkPos = CalcWorkRectPos(WorkOffsetMin); WorkSize = CalcWorkRectSize(WorkOffsetMin, WorkOffsetMax); } // Update public fields - - // Helpers to retrieve ImRect (we don't need to store BuildWorkRect as every access tend to change it, hence the code asymmetry) - ImRect GetMainRect() const { return ImRect(Pos.x, Pos.y, Pos.x + Size.x, Pos.y + Size.y); } - ImRect GetWorkRect() const { return ImRect(WorkPos.x, WorkPos.y, WorkPos.x + WorkSize.x, WorkPos.y + WorkSize.y); } - ImRect GetBuildWorkRect() const { ImVec2 pos = CalcWorkRectPos(BuildWorkOffsetMin); ImVec2 size = CalcWorkRectSize(BuildWorkOffsetMin, BuildWorkOffsetMax); return ImRect(pos.x, pos.y, pos.x + size.x, pos.y + size.y); } -}; - -//----------------------------------------------------------------------------- -// [SECTION] Settings support -//----------------------------------------------------------------------------- - -// Windows data saved in imgui.ini file -// Because we never destroy or rename ImGuiWindowSettings, we can store the names in a separate buffer easily. -// (this is designed to be stored in a ImChunkStream buffer, with the variable-length Name following our structure) -struct ImGuiWindowSettings -{ - ImGuiID ID; - ImVec2ih Pos; - ImVec2ih Size; - bool Collapsed; - bool WantApply; // Set when loaded from .ini data (to enable merging/loading .ini data into an already running context) - - ImGuiWindowSettings() { memset(this, 0, sizeof(*this)); } - char* GetName() { return (char*)(this + 1); } -}; - -struct ImGuiSettingsHandler -{ - const char* TypeName; // Short description stored in .ini file. Disallowed characters: '[' ']' - ImGuiID TypeHash; // == ImHashStr(TypeName) - void (*ClearAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler); // Clear all settings data - void (*ReadInitFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler); // Read: Called before reading (in registration order) - void* (*ReadOpenFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, const char* name); // Read: Called when entering into a new ini entry e.g. "[Window][Name]" - void (*ReadLineFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, void* entry, const char* line); // Read: Called for every line of text within an ini entry - void (*ApplyAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler); // Read: Called after reading (in registration order) - void (*WriteAllFn)(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* out_buf); // Write: Output every entries into 'out_buf' - void* UserData; - - ImGuiSettingsHandler() { memset(this, 0, sizeof(*this)); } -}; - -//----------------------------------------------------------------------------- -// [SECTION] Metrics, Debug Tools -//----------------------------------------------------------------------------- - -struct ImGuiMetricsConfig -{ - bool ShowStackTool; - bool ShowWindowsRects; - bool ShowWindowsBeginOrder; - bool ShowTablesRects; - bool ShowDrawCmdMesh; - bool ShowDrawCmdBoundingBoxes; - int ShowWindowsRectsType; - int ShowTablesRectsType; - - ImGuiMetricsConfig() - { - ShowStackTool = false; - ShowWindowsRects = false; - ShowWindowsBeginOrder = false; - ShowTablesRects = false; - ShowDrawCmdMesh = true; - ShowDrawCmdBoundingBoxes = true; - ShowWindowsRectsType = -1; - ShowTablesRectsType = -1; - } -}; - -struct ImGuiStackLevelInfo -{ - ImGuiID ID; - ImS8 QueryFrameCount; // >= 1: Query in progress - bool QuerySuccess; // Obtained result from DebugHookIdInfo() - char Desc[58]; // Arbitrarily sized buffer to hold a result (FIXME: could replace Results[] with a chunk stream?) - - ImGuiStackLevelInfo() { memset(this, 0, sizeof(*this)); } -}; - -// State for Stack tool queries -struct ImGuiStackTool -{ - int LastActiveFrame; - int StackLevel; // -1: query stack and resize Results, >= 0: individual stack level - ImGuiID QueryId; // ID to query details for - ImVector Results; - - ImGuiStackTool() { memset(this, 0, sizeof(*this)); } -}; - -//----------------------------------------------------------------------------- -// [SECTION] Generic context hooks -//----------------------------------------------------------------------------- - -typedef void (*ImGuiContextHookCallback)(ImGuiContext* ctx, ImGuiContextHook* hook); -enum ImGuiContextHookType { ImGuiContextHookType_NewFramePre, ImGuiContextHookType_NewFramePost, ImGuiContextHookType_EndFramePre, ImGuiContextHookType_EndFramePost, ImGuiContextHookType_RenderPre, ImGuiContextHookType_RenderPost, ImGuiContextHookType_Shutdown, ImGuiContextHookType_PendingRemoval_ }; - -struct ImGuiContextHook -{ - ImGuiID HookId; // A unique ID assigned by AddContextHook() - ImGuiContextHookType Type; - ImGuiID Owner; - ImGuiContextHookCallback Callback; - void* UserData; - - ImGuiContextHook() { memset(this, 0, sizeof(*this)); } -}; - -//----------------------------------------------------------------------------- -// [SECTION] ImGuiContext (main imgui context) -//----------------------------------------------------------------------------- - -struct ImGuiContext -{ - bool Initialized; - bool FontAtlasOwnedByContext; // IO.Fonts-> is owned by the ImGuiContext and will be destructed along with it. - ImGuiIO IO; - ImGuiStyle Style; - ImFont* Font; // (Shortcut) == FontStack.empty() ? IO.Font : FontStack.back() - float FontSize; // (Shortcut) == FontBaseSize * g.CurrentWindow->FontWindowScale == window->FontSize(). Text height for current window. - float FontBaseSize; // (Shortcut) == IO.FontGlobalScale * Font->Scale * Font->FontSize. Base text height. - ImDrawListSharedData DrawListSharedData; - double Time; - int FrameCount; - int FrameCountEnded; - int FrameCountRendered; - bool WithinFrameScope; // Set by NewFrame(), cleared by EndFrame() - bool WithinFrameScopeWithImplicitWindow; // Set by NewFrame(), cleared by EndFrame() when the implicit debug window has been pushed - bool WithinEndChild; // Set within EndChild() - bool GcCompactAll; // Request full GC - bool TestEngineHookItems; // Will call test engine hooks: ImGuiTestEngineHook_ItemAdd(), ImGuiTestEngineHook_ItemInfo(), ImGuiTestEngineHook_Log() - void* TestEngine; // Test engine user data - - // Windows state - ImVector Windows; // Windows, sorted in display order, back to front - ImVector WindowsFocusOrder; // Root windows, sorted in focus order, back to front. - ImVector WindowsTempSortBuffer; // Temporary buffer used in EndFrame() to reorder windows so parents are kept before their child - ImVector CurrentWindowStack; - ImGuiStorage WindowsById; // Map window's ImGuiID to ImGuiWindow* - int WindowsActiveCount; // Number of unique windows submitted by frame - ImVec2 WindowsHoverPadding; // Padding around resizable windows for which hovering on counts as hovering the window == ImMax(style.TouchExtraPadding, WINDOWS_HOVER_PADDING) - ImGuiWindow* CurrentWindow; // Window being drawn into - ImGuiWindow* HoveredWindow; // Window the mouse is hovering. Will typically catch mouse inputs. - ImGuiWindow* HoveredWindowUnderMovingWindow; // Hovered window ignoring MovingWindow. Only set if MovingWindow is set. - ImGuiWindow* MovingWindow; // Track the window we clicked on (in order to preserve focus). The actual window that is moved is generally MovingWindow->RootWindow. - ImGuiWindow* WheelingWindow; // Track the window we started mouse-wheeling on. Until a timer elapse or mouse has moved, generally keep scrolling the same window even if during the course of scrolling the mouse ends up hovering a child window. - ImVec2 WheelingWindowRefMousePos; - float WheelingWindowTimer; - - // Item/widgets state and tracking information - ImGuiID DebugHookIdInfo; // Will call core hooks: DebugHookIdInfo() from GetID functions, used by Stack Tool [next HoveredId/ActiveId to not pull in an extra cache-line] - ImGuiID HoveredId; // Hovered widget, filled during the frame - ImGuiID HoveredIdPreviousFrame; - bool HoveredIdAllowOverlap; - bool HoveredIdUsingMouseWheel; // Hovered widget will use mouse wheel. Blocks scrolling the underlying window. - bool HoveredIdPreviousFrameUsingMouseWheel; - bool HoveredIdDisabled; // At least one widget passed the rect test, but has been discarded by disabled flag or popup inhibit. May be true even if HoveredId == 0. - float HoveredIdTimer; // Measure contiguous hovering time - float HoveredIdNotActiveTimer; // Measure contiguous hovering time where the item has not been active - ImGuiID ActiveId; // Active widget - ImGuiID ActiveIdIsAlive; // Active widget has been seen this frame (we can't use a bool as the ActiveId may change within the frame) - float ActiveIdTimer; - bool ActiveIdIsJustActivated; // Set at the time of activation for one frame - bool ActiveIdAllowOverlap; // Active widget allows another widget to steal active id (generally for overlapping widgets, but not always) - bool ActiveIdNoClearOnFocusLoss; // Disable losing active id if the active id window gets unfocused. - bool ActiveIdHasBeenPressedBefore; // Track whether the active id led to a press (this is to allow changing between PressOnClick and PressOnRelease without pressing twice). Used by range_select branch. - bool ActiveIdHasBeenEditedBefore; // Was the value associated to the widget Edited over the course of the Active state. - bool ActiveIdHasBeenEditedThisFrame; - bool ActiveIdUsingMouseWheel; // Active widget will want to read mouse wheel. Blocks scrolling the underlying window. - ImU32 ActiveIdUsingNavDirMask; // Active widget will want to read those nav move requests (e.g. can activate a button and move away from it) - ImU32 ActiveIdUsingNavInputMask; // Active widget will want to read those nav inputs. - ImU64 ActiveIdUsingKeyInputMask; // Active widget will want to read those key inputs. When we grow the ImGuiKey enum we'll need to either to order the enum to make useful keys come first, either redesign this into e.g. a small array. - ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior) - ImGuiWindow* ActiveIdWindow; - ImGuiInputSource ActiveIdSource; // Activating with mouse or nav (gamepad/keyboard) - int ActiveIdMouseButton; - ImGuiID ActiveIdPreviousFrame; - bool ActiveIdPreviousFrameIsAlive; - bool ActiveIdPreviousFrameHasBeenEditedBefore; - ImGuiWindow* ActiveIdPreviousFrameWindow; - ImGuiID LastActiveId; // Store the last non-zero ActiveId, useful for animation. - float LastActiveIdTimer; // Store the last non-zero ActiveId timer since the beginning of activation, useful for animation. - - // Next window/item data - ImGuiItemFlags CurrentItemFlags; // == g.ItemFlagsStack.back() - ImGuiNextItemData NextItemData; // Storage for SetNextItem** functions - ImGuiLastItemData LastItemData; // Storage for last submitted item (setup by ItemAdd) - ImGuiNextWindowData NextWindowData; // Storage for SetNextWindow** functions - - // Shared stacks - ImVector ColorStack; // Stack for PushStyleColor()/PopStyleColor() - inherited by Begin() - ImVector StyleVarStack; // Stack for PushStyleVar()/PopStyleVar() - inherited by Begin() - ImVector FontStack; // Stack for PushFont()/PopFont() - inherited by Begin() - ImVector FocusScopeStack; // Stack for PushFocusScope()/PopFocusScope() - not inherited by Begin(), unless child window - ImVectorItemFlagsStack; // Stack for PushItemFlag()/PopItemFlag() - inherited by Begin() - ImVectorGroupStack; // Stack for BeginGroup()/EndGroup() - not inherited by Begin() - ImVectorOpenPopupStack; // Which popups are open (persistent) - ImVectorBeginPopupStack; // Which level of BeginPopup() we are in (reset every frame) - - // Viewports - ImVector Viewports; // Active viewports (Size==1 in 'master' branch). Each viewports hold their copy of ImDrawData. - - // Gamepad/keyboard Navigation - ImGuiWindow* NavWindow; // Focused window for navigation. Could be called 'FocusWindow' - ImGuiID NavId; // Focused item for navigation - ImGuiID NavFocusScopeId; // Identify a selection scope (selection code often wants to "clear other items" when landing on an item of the selection set) - ImGuiID NavActivateId; // ~~ (g.ActiveId == 0) && IsNavInputPressed(ImGuiNavInput_Activate) ? NavId : 0, also set when calling ActivateItem() - ImGuiID NavActivateDownId; // ~~ IsNavInputDown(ImGuiNavInput_Activate) ? NavId : 0 - ImGuiID NavActivatePressedId; // ~~ IsNavInputPressed(ImGuiNavInput_Activate) ? NavId : 0 - ImGuiID NavActivateInputId; // ~~ IsNavInputPressed(ImGuiNavInput_Input) ? NavId : 0; ImGuiActivateFlags_PreferInput will be set and NavActivateId will be 0. - ImGuiActivateFlags NavActivateFlags; - ImGuiID NavJustTabbedId; // Just tabbed to this id. - ImGuiID NavJustMovedToId; // Just navigated to this id (result of a successfully MoveRequest). - ImGuiID NavJustMovedToFocusScopeId; // Just navigated to this focus scope id (result of a successfully MoveRequest). - ImGuiKeyModFlags NavJustMovedToKeyMods; - ImGuiID NavNextActivateId; // Set by ActivateItem(), queued until next frame. - ImGuiActivateFlags NavNextActivateFlags; - ImGuiInputSource NavInputSource; // Keyboard or Gamepad mode? THIS WILL ONLY BE None or NavGamepad or NavKeyboard. - ImGuiNavLayer NavLayer; // Layer we are navigating on. For now the system is hard-coded for 0=main contents and 1=menu/title bar, may expose layers later. - int NavIdTabCounter; // == NavWindow->DC.FocusIdxTabCounter at time of NavId processing - bool NavIdIsAlive; // Nav widget has been seen this frame ~~ NavRectRel is valid - bool NavMousePosDirty; // When set we will update mouse position if (io.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) if set (NB: this not enabled by default) - bool NavDisableHighlight; // When user starts using mouse, we hide gamepad/keyboard highlight (NB: but they are still available, which is why NavDisableHighlight isn't always != NavDisableMouseHover) - bool NavDisableMouseHover; // When user starts using gamepad/keyboard, we hide mouse hovering highlight until mouse is touched again. - - // Navigation: Init & Move Requests - bool NavAnyRequest; // ~~ NavMoveRequest || NavInitRequest this is to perform early out in ItemAdd() - bool NavInitRequest; // Init request for appearing window to select first item - bool NavInitRequestFromMove; - ImGuiID NavInitResultId; // Init request result (first item of the window, or one for which SetItemDefaultFocus() was called) - ImRect NavInitResultRectRel; // Init request result rectangle (relative to parent window) - bool NavMoveSubmitted; // Move request submitted, will process result on next NewFrame() - bool NavMoveScoringItems; // Move request submitted, still scoring incoming items - bool NavMoveForwardToNextFrame; - ImGuiNavMoveFlags NavMoveFlags; - ImGuiScrollFlags NavMoveScrollFlags; - ImGuiKeyModFlags NavMoveKeyMods; - ImGuiDir NavMoveDir; // Direction of the move request (left/right/up/down) - ImGuiDir NavMoveDirForDebug; - ImGuiDir NavMoveClipDir; // FIXME-NAV: Describe the purpose of this better. Might want to rename? - ImRect NavScoringRect; // Rectangle used for scoring, in screen space. Based of window->NavRectRel[], modified for directional navigation scoring. - int NavScoringDebugCount; // Metrics for debugging - int NavTabbingInputableRemaining; // >0 when counting items for tabbing - ImGuiNavItemData NavMoveResultLocal; // Best move request candidate within NavWindow - ImGuiNavItemData NavMoveResultLocalVisible; // Best move request candidate within NavWindow that are mostly visible (when using ImGuiNavMoveFlags_AlsoScoreVisibleSet flag) - ImGuiNavItemData NavMoveResultOther; // Best move request candidate within NavWindow's flattened hierarchy (when using ImGuiWindowFlags_NavFlattened flag) - - // Navigation: Windowing (CTRL+TAB for list, or Menu button + keys or directional pads to move/resize) - ImGuiWindow* NavWindowingTarget; // Target window when doing CTRL+Tab (or Pad Menu + FocusPrev/Next), this window is temporarily displayed top-most! - ImGuiWindow* NavWindowingTargetAnim; // Record of last valid NavWindowingTarget until DimBgRatio and NavWindowingHighlightAlpha becomes 0.0f, so the fade-out can stay on it. - ImGuiWindow* NavWindowingListWindow; // Internal window actually listing the CTRL+Tab contents - float NavWindowingTimer; - float NavWindowingHighlightAlpha; - bool NavWindowingToggleLayer; - - // Legacy Focus/Tabbing system (older than Nav, active even if Nav is disabled, misnamed. FIXME-NAV: This needs a redesign!) - ImGuiWindow* TabFocusRequestCurrWindow; // - ImGuiWindow* TabFocusRequestNextWindow; // - int TabFocusRequestCurrCounterTabStop; // Tab item being requested for focus, stored as an index - int TabFocusRequestNextCounterTabStop; // " - bool TabFocusPressed; // Set in NewFrame() when user pressed Tab - - // Render - float DimBgRatio; // 0.0..1.0 animation when fading in a dimming background (for modal window and CTRL+TAB list) - ImGuiMouseCursor MouseCursor; - - // Drag and Drop - bool DragDropActive; - bool DragDropWithinSource; // Set when within a BeginDragDropXXX/EndDragDropXXX block for a drag source. - bool DragDropWithinTarget; // Set when within a BeginDragDropXXX/EndDragDropXXX block for a drag target. - ImGuiDragDropFlags DragDropSourceFlags; - int DragDropSourceFrameCount; - int DragDropMouseButton; - ImGuiPayload DragDropPayload; - ImRect DragDropTargetRect; // Store rectangle of current target candidate (we favor small targets when overlapping) - ImGuiID DragDropTargetId; - ImGuiDragDropFlags DragDropAcceptFlags; - float DragDropAcceptIdCurrRectSurface; // Target item surface (we resolve overlapping targets by prioritizing the smaller surface) - ImGuiID DragDropAcceptIdCurr; // Target item id (set at the time of accepting the payload) - ImGuiID DragDropAcceptIdPrev; // Target item id from previous frame (we need to store this to allow for overlapping drag and drop targets) - int DragDropAcceptFrameCount; // Last time a target expressed a desire to accept the source - ImGuiID DragDropHoldJustPressedId; // Set when holding a payload just made ButtonBehavior() return a press. - ImVector DragDropPayloadBufHeap; // We don't expose the ImVector<> directly, ImGuiPayload only holds pointer+size - unsigned char DragDropPayloadBufLocal[16]; // Local buffer for small payloads - - // Table - ImGuiTable* CurrentTable; - int CurrentTableStackIdx; - ImPool Tables; - ImVector TablesTempDataStack; - ImVector TablesLastTimeActive; // Last used timestamp of each tables (SOA, for efficient GC) - ImVector DrawChannelsTempMergeBuffer; - - // Tab bars - ImGuiTabBar* CurrentTabBar; - ImPool TabBars; - ImVector CurrentTabBarStack; - ImVector ShrinkWidthBuffer; - - // Widget state - ImVec2 MouseLastValidPos; - ImGuiInputTextState InputTextState; - ImFont InputTextPasswordFont; - ImGuiID TempInputId; // Temporary text input when CTRL+clicking on a slider, etc. - ImGuiColorEditFlags ColorEditOptions; // Store user options for color edit widgets - float ColorEditLastHue; // Backup of last Hue associated to LastColor, so we can restore Hue in lossy RGB<>HSV round trips - float ColorEditLastSat; // Backup of last Saturation associated to LastColor, so we can restore Saturation in lossy RGB<>HSV round trips - ImU32 ColorEditLastColor; // RGB value with alpha set to 0. - ImVec4 ColorPickerRef; // Initial/reference color at the time of opening the color picker. - ImGuiComboPreviewData ComboPreviewData; - float SliderCurrentAccum; // Accumulated slider delta when using navigation controls. - bool SliderCurrentAccumDirty; // Has the accumulated slider delta changed since last time we tried to apply it? - bool DragCurrentAccumDirty; - float DragCurrentAccum; // Accumulator for dragging modification. Always high-precision, not rounded by end-user precision settings - float DragSpeedDefaultRatio; // If speed == 0.0f, uses (max-min) * DragSpeedDefaultRatio - float ScrollbarClickDeltaToGrabCenter; // Distance between mouse and center of grab box, normalized in parent space. Use storage? - float DisabledAlphaBackup; // Backup for style.Alpha for BeginDisabled() - short DisabledStackSize; - short TooltipOverrideCount; - float TooltipSlowDelay; // Time before slow tooltips appears (FIXME: This is temporary until we merge in tooltip timer+priority work) - ImVector ClipboardHandlerData; // If no custom clipboard handler is defined - ImVector MenusIdSubmittedThisFrame; // A list of menu IDs that were rendered at least once - - // Platform support - ImVec2 PlatformImePos; // Cursor position request & last passed to the OS Input Method Editor - ImVec2 PlatformImeLastPos; - char PlatformLocaleDecimalPoint; // '.' or *localeconv()->decimal_point - - // Settings - bool SettingsLoaded; - float SettingsDirtyTimer; // Save .ini Settings to memory when time reaches zero - ImGuiTextBuffer SettingsIniData; // In memory .ini settings - ImVector SettingsHandlers; // List of .ini settings handlers - ImChunkStream SettingsWindows; // ImGuiWindow .ini settings entries - ImChunkStream SettingsTables; // ImGuiTable .ini settings entries - ImVector Hooks; // Hooks for extensions (e.g. test engine) - ImGuiID HookIdNext; // Next available HookId - - // Capture/Logging - bool LogEnabled; // Currently capturing - ImGuiLogType LogType; // Capture target - ImFileHandle LogFile; // If != NULL log to stdout/ file - ImGuiTextBuffer LogBuffer; // Accumulation buffer when log to clipboard. This is pointer so our GImGui static constructor doesn't call heap allocators. - const char* LogNextPrefix; - const char* LogNextSuffix; - float LogLinePosY; - bool LogLineFirstItem; - int LogDepthRef; - int LogDepthToExpand; - int LogDepthToExpandDefault; // Default/stored value for LogDepthMaxExpand if not specified in the LogXXX function call. - - // Debug Tools - bool DebugItemPickerActive; // Item picker is active (started with DebugStartItemPicker()) - ImGuiID DebugItemPickerBreakId; // Will call IM_DEBUG_BREAK() when encountering this ID - ImGuiMetricsConfig DebugMetricsConfig; - ImGuiStackTool DebugStackTool; - - // Misc - float FramerateSecPerFrame[120]; // Calculate estimate of framerate for user over the last 2 seconds. - int FramerateSecPerFrameIdx; - int FramerateSecPerFrameCount; - float FramerateSecPerFrameAccum; - int WantCaptureMouseNextFrame; // Explicit capture via CaptureKeyboardFromApp()/CaptureMouseFromApp() sets those flags - int WantCaptureKeyboardNextFrame; - int WantTextInputNextFrame; - char TempBuffer[1024 * 3 + 1]; // Temporary text buffer - - ImGuiContext(ImFontAtlas* shared_font_atlas) - { - Initialized = false; - FontAtlasOwnedByContext = shared_font_atlas ? false : true; - Font = NULL; - FontSize = FontBaseSize = 0.0f; - IO.Fonts = shared_font_atlas ? shared_font_atlas : IM_NEW(ImFontAtlas)(); - Time = 0.0f; - FrameCount = 0; - FrameCountEnded = FrameCountRendered = -1; - WithinFrameScope = WithinFrameScopeWithImplicitWindow = WithinEndChild = false; - GcCompactAll = false; - TestEngineHookItems = false; - TestEngine = NULL; - - WindowsActiveCount = 0; - CurrentWindow = NULL; - HoveredWindow = NULL; - HoveredWindowUnderMovingWindow = NULL; - MovingWindow = NULL; - WheelingWindow = NULL; - WheelingWindowTimer = 0.0f; - - DebugHookIdInfo = 0; - HoveredId = HoveredIdPreviousFrame = 0; - HoveredIdAllowOverlap = false; - HoveredIdUsingMouseWheel = HoveredIdPreviousFrameUsingMouseWheel = false; - HoveredIdDisabled = false; - HoveredIdTimer = HoveredIdNotActiveTimer = 0.0f; - ActiveId = 0; - ActiveIdIsAlive = 0; - ActiveIdTimer = 0.0f; - ActiveIdIsJustActivated = false; - ActiveIdAllowOverlap = false; - ActiveIdNoClearOnFocusLoss = false; - ActiveIdHasBeenPressedBefore = false; - ActiveIdHasBeenEditedBefore = false; - ActiveIdHasBeenEditedThisFrame = false; - ActiveIdUsingMouseWheel = false; - ActiveIdUsingNavDirMask = 0x00; - ActiveIdUsingNavInputMask = 0x00; - ActiveIdUsingKeyInputMask = 0x00; - ActiveIdClickOffset = ImVec2(-1, -1); - ActiveIdWindow = NULL; - ActiveIdSource = ImGuiInputSource_None; - ActiveIdMouseButton = -1; - ActiveIdPreviousFrame = 0; - ActiveIdPreviousFrameIsAlive = false; - ActiveIdPreviousFrameHasBeenEditedBefore = false; - ActiveIdPreviousFrameWindow = NULL; - LastActiveId = 0; - LastActiveIdTimer = 0.0f; - - CurrentItemFlags = ImGuiItemFlags_None; - - NavWindow = NULL; - NavId = NavFocusScopeId = NavActivateId = NavActivateDownId = NavActivatePressedId = NavActivateInputId = 0; - NavJustTabbedId = NavJustMovedToId = NavJustMovedToFocusScopeId = NavNextActivateId = 0; - NavActivateFlags = NavNextActivateFlags = ImGuiActivateFlags_None; - NavJustMovedToKeyMods = ImGuiKeyModFlags_None; - NavInputSource = ImGuiInputSource_None; - NavLayer = ImGuiNavLayer_Main; - NavIdTabCounter = INT_MAX; - NavIdIsAlive = false; - NavMousePosDirty = false; - NavDisableHighlight = true; - NavDisableMouseHover = false; - NavAnyRequest = false; - NavInitRequest = false; - NavInitRequestFromMove = false; - NavInitResultId = 0; - NavMoveSubmitted = false; - NavMoveScoringItems = false; - NavMoveForwardToNextFrame = false; - NavMoveFlags = ImGuiNavMoveFlags_None; - NavMoveScrollFlags = ImGuiScrollFlags_None; - NavMoveKeyMods = ImGuiKeyModFlags_None; - NavMoveDir = NavMoveDirForDebug = NavMoveClipDir = ImGuiDir_None; - NavScoringDebugCount = 0; - NavTabbingInputableRemaining = 0; - - NavWindowingTarget = NavWindowingTargetAnim = NavWindowingListWindow = NULL; - NavWindowingTimer = NavWindowingHighlightAlpha = 0.0f; - NavWindowingToggleLayer = false; - - TabFocusRequestCurrWindow = TabFocusRequestNextWindow = NULL; - TabFocusRequestCurrCounterTabStop = INT_MAX; - TabFocusRequestNextCounterTabStop = INT_MAX; - TabFocusPressed = false; - - DimBgRatio = 0.0f; - MouseCursor = ImGuiMouseCursor_Arrow; - - DragDropActive = DragDropWithinSource = DragDropWithinTarget = false; - DragDropSourceFlags = ImGuiDragDropFlags_None; - DragDropSourceFrameCount = -1; - DragDropMouseButton = -1; - DragDropTargetId = 0; - DragDropAcceptFlags = ImGuiDragDropFlags_None; - DragDropAcceptIdCurrRectSurface = 0.0f; - DragDropAcceptIdPrev = DragDropAcceptIdCurr = 0; - DragDropAcceptFrameCount = -1; - DragDropHoldJustPressedId = 0; - memset(DragDropPayloadBufLocal, 0, sizeof(DragDropPayloadBufLocal)); - - CurrentTable = NULL; - CurrentTableStackIdx = -1; - CurrentTabBar = NULL; - - TempInputId = 0; - ColorEditOptions = ImGuiColorEditFlags_DefaultOptions_; - ColorEditLastHue = ColorEditLastSat = 0.0f; - ColorEditLastColor = 0; - SliderCurrentAccum = 0.0f; - SliderCurrentAccumDirty = false; - DragCurrentAccumDirty = false; - DragCurrentAccum = 0.0f; - DragSpeedDefaultRatio = 1.0f / 100.0f; - DisabledAlphaBackup = 0.0f; - DisabledStackSize = 0; - ScrollbarClickDeltaToGrabCenter = 0.0f; - TooltipOverrideCount = 0; - TooltipSlowDelay = 0.50f; - - PlatformImePos = PlatformImeLastPos = ImVec2(FLT_MAX, FLT_MAX); - PlatformLocaleDecimalPoint = '.'; - - SettingsLoaded = false; - SettingsDirtyTimer = 0.0f; - HookIdNext = 0; - - LogEnabled = false; - LogType = ImGuiLogType_None; - LogNextPrefix = LogNextSuffix = NULL; - LogFile = NULL; - LogLinePosY = FLT_MAX; - LogLineFirstItem = false; - LogDepthRef = 0; - LogDepthToExpand = LogDepthToExpandDefault = 2; - - DebugItemPickerActive = false; - DebugItemPickerBreakId = 0; - - memset(FramerateSecPerFrame, 0, sizeof(FramerateSecPerFrame)); - FramerateSecPerFrameIdx = FramerateSecPerFrameCount = 0; - FramerateSecPerFrameAccum = 0.0f; - WantCaptureMouseNextFrame = WantCaptureKeyboardNextFrame = WantTextInputNextFrame = -1; - memset(TempBuffer, 0, sizeof(TempBuffer)); - } -}; - -//----------------------------------------------------------------------------- -// [SECTION] ImGuiWindowTempData, ImGuiWindow -//----------------------------------------------------------------------------- - -// Transient per-window data, reset at the beginning of the frame. This used to be called ImGuiDrawContext, hence the DC variable name in ImGuiWindow. -// (That's theory, in practice the delimitation between ImGuiWindow and ImGuiWindowTempData is quite tenuous and could be reconsidered..) -// (This doesn't need a constructor because we zero-clear it as part of ImGuiWindow and all frame-temporary data are setup on Begin) -struct IMGUI_API ImGuiWindowTempData -{ - // Layout - ImVec2 CursorPos; // Current emitting position, in absolute coordinates. - ImVec2 CursorPosPrevLine; - ImVec2 CursorStartPos; // Initial position after Begin(), generally ~ window position + WindowPadding. - ImVec2 CursorMaxPos; // Used to implicitly calculate ContentSize at the beginning of next frame, for scrolling range and auto-resize. Always growing during the frame. - ImVec2 IdealMaxPos; // Used to implicitly calculate ContentSizeIdeal at the beginning of next frame, for auto-resize only. Always growing during the frame. - ImVec2 CurrLineSize; - ImVec2 PrevLineSize; - float CurrLineTextBaseOffset; // Baseline offset (0.0f by default on a new line, generally == style.FramePadding.y when a framed item has been added). - float PrevLineTextBaseOffset; - ImVec1 Indent; // Indentation / start position from left of window (increased by TreePush/TreePop, etc.) - ImVec1 ColumnsOffset; // Offset to the current column (if ColumnsCurrent > 0). FIXME: This and the above should be a stack to allow use cases like Tree->Column->Tree. Need revamp columns API. - ImVec1 GroupOffset; - - // Keyboard/Gamepad navigation - ImGuiNavLayer NavLayerCurrent; // Current layer, 0..31 (we currently only use 0..1) - short NavLayersActiveMask; // Which layers have been written to (result from previous frame) - short NavLayersActiveMaskNext;// Which layers have been written to (accumulator for current frame) - ImGuiID NavFocusScopeIdCurrent; // Current focus scope ID while appending - bool NavHideHighlightOneFrame; - bool NavHasScroll; // Set when scrolling can be used (ScrollMax > 0.0f) - - // Miscellaneous - bool MenuBarAppending; // FIXME: Remove this - ImVec2 MenuBarOffset; // MenuBarOffset.x is sort of equivalent of a per-layer CursorPos.x, saved/restored as we switch to the menu bar. The only situation when MenuBarOffset.y is > 0 if when (SafeAreaPadding.y > FramePadding.y), often used on TVs. - ImGuiMenuColumns MenuColumns; // Simplified columns storage for menu items measurement - int TreeDepth; // Current tree depth. - ImU32 TreeJumpToParentOnPopMask; // Store a copy of !g.NavIdIsAlive for TreeDepth 0..31.. Could be turned into a ImU64 if necessary. - ImVector ChildWindows; - ImGuiStorage* StateStorage; // Current persistent per-window storage (store e.g. tree node open/close state) - ImGuiOldColumns* CurrentColumns; // Current columns set - int CurrentTableIdx; // Current table index (into g.Tables) - ImGuiLayoutType LayoutType; - ImGuiLayoutType ParentLayoutType; // Layout type of parent window at the time of Begin() - int FocusCounterTabStop; // (Legacy Focus/Tabbing system) Same, but only count widgets which you can Tab through. - - // Local parameters stacks - // We store the current settings outside of the vectors to increase memory locality (reduce cache misses). The vectors are rarely modified. Also it allows us to not heap allocate for short-lived windows which are not using those settings. - float ItemWidth; // Current item width (>0.0: width in pixels, <0.0: align xx pixels to the right of window). - float TextWrapPos; // Current text wrap pos. - ImVector ItemWidthStack; // Store item widths to restore (attention: .back() is not == ItemWidth) - ImVector TextWrapPosStack; // Store text wrap pos to restore (attention: .back() is not == TextWrapPos) -}; - -// Storage for one window -struct IMGUI_API ImGuiWindow -{ - char* Name; // Window name, owned by the window. - ImGuiID ID; // == ImHashStr(Name) - ImGuiWindowFlags Flags; // See enum ImGuiWindowFlags_ - ImVec2 Pos; // Position (always rounded-up to nearest pixel) - ImVec2 Size; // Current size (==SizeFull or collapsed title bar size) - ImVec2 SizeFull; // Size when non collapsed - ImVec2 ContentSize; // Size of contents/scrollable client area (calculated from the extents reach of the cursor) from previous frame. Does not include window decoration or window padding. - ImVec2 ContentSizeIdeal; - ImVec2 ContentSizeExplicit; // Size of contents/scrollable client area explicitly request by the user via SetNextWindowContentSize(). - ImVec2 WindowPadding; // Window padding at the time of Begin(). - float WindowRounding; // Window rounding at the time of Begin(). May be clamped lower to avoid rendering artifacts with title bar, menu bar etc. - float WindowBorderSize; // Window border size at the time of Begin(). - int NameBufLen; // Size of buffer storing Name. May be larger than strlen(Name)! - ImGuiID MoveId; // == window->GetID("#MOVE") - ImGuiID ChildId; // ID of corresponding item in parent window (for navigation to return from child window to parent window) - ImVec2 Scroll; - ImVec2 ScrollMax; - ImVec2 ScrollTarget; // target scroll position. stored as cursor position with scrolling canceled out, so the highest point is always 0.0f. (FLT_MAX for no change) - ImVec2 ScrollTargetCenterRatio; // 0.0f = scroll so that target position is at top, 0.5f = scroll so that target position is centered - ImVec2 ScrollTargetEdgeSnapDist; // 0.0f = no snapping, >0.0f snapping threshold - ImVec2 ScrollbarSizes; // Size taken by each scrollbars on their smaller axis. Pay attention! ScrollbarSizes.x == width of the vertical scrollbar, ScrollbarSizes.y = height of the horizontal scrollbar. - bool ScrollbarX, ScrollbarY; // Are scrollbars visible? - bool Active; // Set to true on Begin(), unless Collapsed - bool WasActive; - bool WriteAccessed; // Set to true when any widget access the current window - bool Collapsed; // Set when collapsing window to become only title-bar - bool WantCollapseToggle; - bool SkipItems; // Set when items can safely be all clipped (e.g. window not visible or collapsed) - bool Appearing; // Set during the frame where the window is appearing (or re-appearing) - bool Hidden; // Do not display (== HiddenFrames*** > 0) - bool IsFallbackWindow; // Set on the "Debug##Default" window. - bool HasCloseButton; // Set when the window has a close button (p_open != NULL) - signed char ResizeBorderHeld; // Current border being held for resize (-1: none, otherwise 0-3) - short BeginCount; // Number of Begin() during the current frame (generally 0 or 1, 1+ if appending via multiple Begin/End pairs) - short BeginOrderWithinParent; // Begin() order within immediate parent window, if we are a child window. Otherwise 0. - short BeginOrderWithinContext; // Begin() order within entire imgui context. This is mostly used for debugging submission order related issues. - short FocusOrder; // Order within WindowsFocusOrder[], altered when windows are focused. - ImGuiID PopupId; // ID in the popup stack when this window is used as a popup/menu (because we use generic Name/ID for recycling) - ImS8 AutoFitFramesX, AutoFitFramesY; - ImS8 AutoFitChildAxises; - bool AutoFitOnlyGrows; - ImGuiDir AutoPosLastDirection; - ImS8 HiddenFramesCanSkipItems; // Hide the window for N frames - ImS8 HiddenFramesCannotSkipItems; // Hide the window for N frames while allowing items to be submitted so we can measure their size - ImS8 HiddenFramesForRenderOnly; // Hide the window until frame N at Render() time only - ImS8 DisableInputsFrames; // Disable window interactions for N frames - ImGuiCond SetWindowPosAllowFlags : 8; // store acceptable condition flags for SetNextWindowPos() use. - ImGuiCond SetWindowSizeAllowFlags : 8; // store acceptable condition flags for SetNextWindowSize() use. - ImGuiCond SetWindowCollapsedAllowFlags : 8; // store acceptable condition flags for SetNextWindowCollapsed() use. - ImVec2 SetWindowPosVal; // store window position when using a non-zero Pivot (position set needs to be processed when we know the window size) - ImVec2 SetWindowPosPivot; // store window pivot for positioning. ImVec2(0, 0) when positioning from top-left corner; ImVec2(0.5f, 0.5f) for centering; ImVec2(1, 1) for bottom right. - - ImVector IDStack; // ID stack. ID are hashes seeded with the value at the top of the stack. (In theory this should be in the TempData structure) - ImGuiWindowTempData DC; // Temporary per-window data, reset at the beginning of the frame. This used to be called ImGuiDrawContext, hence the "DC" variable name. - - // The best way to understand what those rectangles are is to use the 'Metrics->Tools->Show Windows Rectangles' viewer. - // The main 'OuterRect', omitted as a field, is window->Rect(). - ImRect OuterRectClipped; // == Window->Rect() just after setup in Begin(). == window->Rect() for root window. - ImRect InnerRect; // Inner rectangle (omit title bar, menu bar, scroll bar) - ImRect InnerClipRect; // == InnerRect shrunk by WindowPadding*0.5f on each side, clipped within viewport or parent clip rect. - ImRect WorkRect; // Initially covers the whole scrolling region. Reduced by containers e.g columns/tables when active. Shrunk by WindowPadding*1.0f on each side. This is meant to replace ContentRegionRect over time (from 1.71+ onward). - ImRect ParentWorkRect; // Backup of WorkRect before entering a container such as columns/tables. Used by e.g. SpanAllColumns functions to easily access. Stacked containers are responsible for maintaining this. // FIXME-WORKRECT: Could be a stack? - ImRect ClipRect; // Current clipping/scissoring rectangle, evolve as we are using PushClipRect(), etc. == DrawList->clip_rect_stack.back(). - ImRect ContentRegionRect; // FIXME: This is currently confusing/misleading. It is essentially WorkRect but not handling of scrolling. We currently rely on it as right/bottom aligned sizing operation need some size to rely on. - ImVec2ih HitTestHoleSize; // Define an optional rectangular hole where mouse will pass-through the window. - ImVec2ih HitTestHoleOffset; - - int LastFrameActive; // Last frame number the window was Active. - float LastTimeActive; // Last timestamp the window was Active (using float as we don't need high precision there) - float ItemWidthDefault; - ImGuiStorage StateStorage; - ImVector ColumnsStorage; - float FontWindowScale; // User scale multiplier per-window, via SetWindowFontScale() - int SettingsOffset; // Offset into SettingsWindows[] (offsets are always valid as we only grow the array from the back) - - ImDrawList* DrawList; // == &DrawListInst (for backward compatibility reason with code using imgui_internal.h we keep this a pointer) - ImDrawList DrawListInst; - ImGuiWindow* ParentWindow; // If we are a child _or_ popup _or_ docked window, this is pointing to our parent. Otherwise NULL. - ImGuiWindow* RootWindow; // Point to ourself or first ancestor that is not a child window. Doesn't cross through popups/dock nodes. - ImGuiWindow* RootWindowPopupTree; // Point to ourself or first ancestor that is not a child window. Cross through popups parent<>child. - ImGuiWindow* RootWindowForTitleBarHighlight; // Point to ourself or first ancestor which will display TitleBgActive color when this window is active. - ImGuiWindow* RootWindowForNav; // Point to ourself or first ancestor which doesn't have the NavFlattened flag. - - ImGuiWindow* NavLastChildNavWindow; // When going to the menu bar, we remember the child window we came from. (This could probably be made implicit if we kept g.Windows sorted by last focused including child window.) - ImGuiID NavLastIds[ImGuiNavLayer_COUNT]; // Last known NavId for this window, per layer (0/1) - ImRect NavRectRel[ImGuiNavLayer_COUNT]; // Reference rectangle, in window relative space - - int MemoryDrawListIdxCapacity; // Backup of last idx/vtx count, so when waking up the window we can preallocate and avoid iterative alloc/copy - int MemoryDrawListVtxCapacity; - bool MemoryCompacted; // Set when window extraneous data have been garbage collected - -public: - ImGuiWindow(ImGuiContext* context, const char* name); - ~ImGuiWindow(); - - ImGuiID GetID(const char* str, const char* str_end = NULL); - ImGuiID GetID(const void* ptr); - ImGuiID GetID(int n); - ImGuiID GetIDNoKeepAlive(const char* str, const char* str_end = NULL); - ImGuiID GetIDNoKeepAlive(const void* ptr); - ImGuiID GetIDNoKeepAlive(int n); - ImGuiID GetIDFromRectangle(const ImRect& r_abs); - - // We don't use g.FontSize because the window may be != g.CurrentWidow. - ImRect Rect() const { return ImRect(Pos.x, Pos.y, Pos.x + Size.x, Pos.y + Size.y); } - float CalcFontSize() const { ImGuiContext& g = *GImGui; float scale = g.FontBaseSize * FontWindowScale; if (ParentWindow) scale *= ParentWindow->FontWindowScale; return scale; } - float TitleBarHeight() const { ImGuiContext& g = *GImGui; return (Flags & ImGuiWindowFlags_NoTitleBar) ? 0.0f : CalcFontSize() + g.Style.FramePadding.y * 2.0f; } - ImRect TitleBarRect() const { return ImRect(Pos, ImVec2(Pos.x + SizeFull.x, Pos.y + TitleBarHeight())); } - float MenuBarHeight() const { ImGuiContext& g = *GImGui; return (Flags & ImGuiWindowFlags_MenuBar) ? DC.MenuBarOffset.y + CalcFontSize() + g.Style.FramePadding.y * 2.0f : 0.0f; } - ImRect MenuBarRect() const { float y1 = Pos.y + TitleBarHeight(); return ImRect(Pos.x, y1, Pos.x + SizeFull.x, y1 + MenuBarHeight()); } -}; - -//----------------------------------------------------------------------------- -// [SECTION] Tab bar, Tab item support -//----------------------------------------------------------------------------- - -// Extend ImGuiTabBarFlags_ -enum ImGuiTabBarFlagsPrivate_ -{ - ImGuiTabBarFlags_DockNode = 1 << 20, // Part of a dock node [we don't use this in the master branch but it facilitate branch syncing to keep this around] - ImGuiTabBarFlags_IsFocused = 1 << 21, - ImGuiTabBarFlags_SaveSettings = 1 << 22 // FIXME: Settings are handled by the docking system, this only request the tab bar to mark settings dirty when reordering tabs -}; - -// Extend ImGuiTabItemFlags_ -enum ImGuiTabItemFlagsPrivate_ -{ - ImGuiTabItemFlags_SectionMask_ = ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_Trailing, - ImGuiTabItemFlags_NoCloseButton = 1 << 20, // Track whether p_open was set or not (we'll need this info on the next frame to recompute ContentWidth during layout) - ImGuiTabItemFlags_Button = 1 << 21 // Used by TabItemButton, change the tab item behavior to mimic a button -}; - -// Storage for one active tab item (sizeof() 40 bytes) -struct ImGuiTabItem -{ - ImGuiID ID; - ImGuiTabItemFlags Flags; - int LastFrameVisible; - int LastFrameSelected; // This allows us to infer an ordered list of the last activated tabs with little maintenance - float Offset; // Position relative to beginning of tab - float Width; // Width currently displayed - float ContentWidth; // Width of label, stored during BeginTabItem() call - ImS32 NameOffset; // When Window==NULL, offset to name within parent ImGuiTabBar::TabsNames - ImS16 BeginOrder; // BeginTabItem() order, used to re-order tabs after toggling ImGuiTabBarFlags_Reorderable - ImS16 IndexDuringLayout; // Index only used during TabBarLayout() - bool WantClose; // Marked as closed by SetTabItemClosed() - - ImGuiTabItem() { memset(this, 0, sizeof(*this)); LastFrameVisible = LastFrameSelected = -1; NameOffset = -1; BeginOrder = IndexDuringLayout = -1; } -}; - -// Storage for a tab bar (sizeof() 152 bytes) -struct ImGuiTabBar -{ - ImVector Tabs; - ImGuiTabBarFlags Flags; - ImGuiID ID; // Zero for tab-bars used by docking - ImGuiID SelectedTabId; // Selected tab/window - ImGuiID NextSelectedTabId; // Next selected tab/window. Will also trigger a scrolling animation - ImGuiID VisibleTabId; // Can occasionally be != SelectedTabId (e.g. when previewing contents for CTRL+TAB preview) - int CurrFrameVisible; - int PrevFrameVisible; - ImRect BarRect; - float CurrTabsContentsHeight; - float PrevTabsContentsHeight; // Record the height of contents submitted below the tab bar - float WidthAllTabs; // Actual width of all tabs (locked during layout) - float WidthAllTabsIdeal; // Ideal width if all tabs were visible and not clipped - float ScrollingAnim; - float ScrollingTarget; - float ScrollingTargetDistToVisibility; - float ScrollingSpeed; - float ScrollingRectMinX; - float ScrollingRectMaxX; - ImGuiID ReorderRequestTabId; - ImS16 ReorderRequestOffset; - ImS8 BeginCount; - bool WantLayout; - bool VisibleTabWasSubmitted; - bool TabsAddedNew; // Set to true when a new tab item or button has been added to the tab bar during last frame - ImS16 TabsActiveCount; // Number of tabs submitted this frame. - ImS16 LastTabItemIdx; // Index of last BeginTabItem() tab for use by EndTabItem() - float ItemSpacingY; - ImVec2 FramePadding; // style.FramePadding locked at the time of BeginTabBar() - ImVec2 BackupCursorPos; - ImGuiTextBuffer TabsNames; // For non-docking tab bar we re-append names in a contiguous buffer. - - ImGuiTabBar(); - int GetTabOrder(const ImGuiTabItem* tab) const { return Tabs.index_from_ptr(tab); } - const char* GetTabName(const ImGuiTabItem* tab) const - { - IM_ASSERT(tab->NameOffset != -1 && tab->NameOffset < TabsNames.Buf.Size); - return TabsNames.Buf.Data + tab->NameOffset; - } -}; - -//----------------------------------------------------------------------------- -// [SECTION] Table support -//----------------------------------------------------------------------------- - -#define IM_COL32_DISABLE IM_COL32(0,0,0,1) // Special sentinel code which cannot be used as a regular color. -#define IMGUI_TABLE_MAX_COLUMNS 64 // sizeof(ImU64) * 8. This is solely because we frequently encode columns set in a ImU64. -#define IMGUI_TABLE_MAX_DRAW_CHANNELS (4 + 64 * 2) // See TableSetupDrawChannels() - -// Our current column maximum is 64 but we may raise that in the future. -typedef ImS8 ImGuiTableColumnIdx; -typedef ImU8 ImGuiTableDrawChannelIdx; - -// [Internal] sizeof() ~ 104 -// We use the terminology "Enabled" to refer to a column that is not Hidden by user/api. -// We use the terminology "Clipped" to refer to a column that is out of sight because of scrolling/clipping. -// This is in contrast with some user-facing api such as IsItemVisible() / IsRectVisible() which use "Visible" to mean "not clipped". -struct ImGuiTableColumn -{ - ImGuiTableColumnFlags Flags; // Flags after some patching (not directly same as provided by user). See ImGuiTableColumnFlags_ - float WidthGiven; // Final/actual width visible == (MaxX - MinX), locked in TableUpdateLayout(). May be > WidthRequest to honor minimum width, may be < WidthRequest to honor shrinking columns down in tight space. - float MinX; // Absolute positions - float MaxX; - float WidthRequest; // Master width absolute value when !(Flags & _WidthStretch). When Stretch this is derived every frame from StretchWeight in TableUpdateLayout() - float WidthAuto; // Automatic width - float StretchWeight; // Master width weight when (Flags & _WidthStretch). Often around ~1.0f initially. - float InitStretchWeightOrWidth; // Value passed to TableSetupColumn(). For Width it is a content width (_without padding_). - ImRect ClipRect; // Clipping rectangle for the column - ImGuiID UserID; // Optional, value passed to TableSetupColumn() - float WorkMinX; // Contents region min ~(MinX + CellPaddingX + CellSpacingX1) == cursor start position when entering column - float WorkMaxX; // Contents region max ~(MaxX - CellPaddingX - CellSpacingX2) - float ItemWidth; // Current item width for the column, preserved across rows - float ContentMaxXFrozen; // Contents maximum position for frozen rows (apart from headers), from which we can infer content width. - float ContentMaxXUnfrozen; - float ContentMaxXHeadersUsed; // Contents maximum position for headers rows (regardless of freezing). TableHeader() automatically softclip itself + report ideal desired size, to avoid creating extraneous draw calls - float ContentMaxXHeadersIdeal; - ImS16 NameOffset; // Offset into parent ColumnsNames[] - ImGuiTableColumnIdx DisplayOrder; // Index within Table's IndexToDisplayOrder[] (column may be reordered by users) - ImGuiTableColumnIdx IndexWithinEnabledSet; // Index within enabled/visible set (<= IndexToDisplayOrder) - ImGuiTableColumnIdx PrevEnabledColumn; // Index of prev enabled/visible column within Columns[], -1 if first enabled/visible column - ImGuiTableColumnIdx NextEnabledColumn; // Index of next enabled/visible column within Columns[], -1 if last enabled/visible column - ImGuiTableColumnIdx SortOrder; // Index of this column within sort specs, -1 if not sorting on this column, 0 for single-sort, may be >0 on multi-sort - ImGuiTableDrawChannelIdx DrawChannelCurrent; // Index within DrawSplitter.Channels[] - ImGuiTableDrawChannelIdx DrawChannelFrozen; // Draw channels for frozen rows (often headers) - ImGuiTableDrawChannelIdx DrawChannelUnfrozen; // Draw channels for unfrozen rows - bool IsEnabled; // IsUserEnabled && (Flags & ImGuiTableColumnFlags_Disabled) == 0 - bool IsUserEnabled; // Is the column not marked Hidden by the user? (unrelated to being off view, e.g. clipped by scrolling). - bool IsUserEnabledNextFrame; - bool IsVisibleX; // Is actually in view (e.g. overlapping the host window clipping rectangle, not scrolled). - bool IsVisibleY; - bool IsRequestOutput; // Return value for TableSetColumnIndex() / TableNextColumn(): whether we request user to output contents or not. - bool IsSkipItems; // Do we want item submissions to this column to be completely ignored (no layout will happen). - bool IsPreserveWidthAuto; - ImS8 NavLayerCurrent; // ImGuiNavLayer in 1 byte - ImU8 AutoFitQueue; // Queue of 8 values for the next 8 frames to request auto-fit - ImU8 CannotSkipItemsQueue; // Queue of 8 values for the next 8 frames to disable Clipped/SkipItem - ImU8 SortDirection : 2; // ImGuiSortDirection_Ascending or ImGuiSortDirection_Descending - ImU8 SortDirectionsAvailCount : 2; // Number of available sort directions (0 to 3) - ImU8 SortDirectionsAvailMask : 4; // Mask of available sort directions (1-bit each) - ImU8 SortDirectionsAvailList; // Ordered of available sort directions (2-bits each) - - ImGuiTableColumn() - { - memset(this, 0, sizeof(*this)); - StretchWeight = WidthRequest = -1.0f; - NameOffset = -1; - DisplayOrder = IndexWithinEnabledSet = -1; - PrevEnabledColumn = NextEnabledColumn = -1; - SortOrder = -1; - SortDirection = ImGuiSortDirection_None; - DrawChannelCurrent = DrawChannelFrozen = DrawChannelUnfrozen = (ImU8)-1; - } -}; - -// Transient cell data stored per row. -// sizeof() ~ 6 -struct ImGuiTableCellData -{ - ImU32 BgColor; // Actual color - ImGuiTableColumnIdx Column; // Column number -}; - -// FIXME-TABLE: more transient data could be stored in a per-stacked table structure: DrawSplitter, SortSpecs, incoming RowData -struct ImGuiTable -{ - ImGuiID ID; - ImGuiTableFlags Flags; - void* RawData; // Single allocation to hold Columns[], DisplayOrderToIndex[] and RowCellData[] - ImGuiTableTempData* TempData; // Transient data while table is active. Point within g.CurrentTableStack[] - ImSpan Columns; // Point within RawData[] - ImSpan DisplayOrderToIndex; // Point within RawData[]. Store display order of columns (when not reordered, the values are 0...Count-1) - ImSpan RowCellData; // Point within RawData[]. Store cells background requests for current row. - ImU64 EnabledMaskByDisplayOrder; // Column DisplayOrder -> IsEnabled map - ImU64 EnabledMaskByIndex; // Column Index -> IsEnabled map (== not hidden by user/api) in a format adequate for iterating column without touching cold data - ImU64 VisibleMaskByIndex; // Column Index -> IsVisibleX|IsVisibleY map (== not hidden by user/api && not hidden by scrolling/cliprect) - ImU64 RequestOutputMaskByIndex; // Column Index -> IsVisible || AutoFit (== expect user to submit items) - ImGuiTableFlags SettingsLoadedFlags; // Which data were loaded from the .ini file (e.g. when order is not altered we won't save order) - int SettingsOffset; // Offset in g.SettingsTables - int LastFrameActive; - int ColumnsCount; // Number of columns declared in BeginTable() - int CurrentRow; - int CurrentColumn; - ImS16 InstanceCurrent; // Count of BeginTable() calls with same ID in the same frame (generally 0). This is a little bit similar to BeginCount for a window, but multiple table with same ID look are multiple tables, they are just synched. - ImS16 InstanceInteracted; // Mark which instance (generally 0) of the same ID is being interacted with - float RowPosY1; - float RowPosY2; - float RowMinHeight; // Height submitted to TableNextRow() - float RowTextBaseline; - float RowIndentOffsetX; - ImGuiTableRowFlags RowFlags : 16; // Current row flags, see ImGuiTableRowFlags_ - ImGuiTableRowFlags LastRowFlags : 16; - int RowBgColorCounter; // Counter for alternating background colors (can be fast-forwarded by e.g clipper), not same as CurrentRow because header rows typically don't increase this. - ImU32 RowBgColor[2]; // Background color override for current row. - ImU32 BorderColorStrong; - ImU32 BorderColorLight; - float BorderX1; - float BorderX2; - float HostIndentX; - float MinColumnWidth; - float OuterPaddingX; - float CellPaddingX; // Padding from each borders - float CellPaddingY; - float CellSpacingX1; // Spacing between non-bordered cells - float CellSpacingX2; - float LastOuterHeight; // Outer height from last frame - float LastFirstRowHeight; // Height of first row from last frame - float InnerWidth; // User value passed to BeginTable(), see comments at the top of BeginTable() for details. - float ColumnsGivenWidth; // Sum of current column width - float ColumnsAutoFitWidth; // Sum of ideal column width in order nothing to be clipped, used for auto-fitting and content width submission in outer window - float ResizedColumnNextWidth; - float ResizeLockMinContentsX2; // Lock minimum contents width while resizing down in order to not create feedback loops. But we allow growing the table. - float RefScale; // Reference scale to be able to rescale columns on font/dpi changes. - ImRect OuterRect; // Note: for non-scrolling table, OuterRect.Max.y is often FLT_MAX until EndTable(), unless a height has been specified in BeginTable(). - ImRect InnerRect; // InnerRect but without decoration. As with OuterRect, for non-scrolling tables, InnerRect.Max.y is - ImRect WorkRect; - ImRect InnerClipRect; - ImRect BgClipRect; // We use this to cpu-clip cell background color fill - ImRect Bg0ClipRectForDrawCmd; // Actual ImDrawCmd clip rect for BG0/1 channel. This tends to be == OuterWindow->ClipRect at BeginTable() because output in BG0/BG1 is cpu-clipped - ImRect Bg2ClipRectForDrawCmd; // Actual ImDrawCmd clip rect for BG2 channel. This tends to be a correct, tight-fit, because output to BG2 are done by widgets relying on regular ClipRect. - ImRect HostClipRect; // This is used to check if we can eventually merge our columns draw calls into the current draw call of the current window. - ImRect HostBackupInnerClipRect; // Backup of InnerWindow->ClipRect during PushTableBackground()/PopTableBackground() - ImGuiWindow* OuterWindow; // Parent window for the table - ImGuiWindow* InnerWindow; // Window holding the table data (== OuterWindow or a child window) - ImGuiTextBuffer ColumnsNames; // Contiguous buffer holding columns names - ImDrawListSplitter* DrawSplitter; // Shortcut to TempData->DrawSplitter while in table. Isolate draw commands per columns to avoid switching clip rect constantly - ImGuiTableColumnSortSpecs SortSpecsSingle; - ImVector SortSpecsMulti; // FIXME-OPT: Using a small-vector pattern would be good. - ImGuiTableSortSpecs SortSpecs; // Public facing sorts specs, this is what we return in TableGetSortSpecs() - ImGuiTableColumnIdx SortSpecsCount; - ImGuiTableColumnIdx ColumnsEnabledCount; // Number of enabled columns (<= ColumnsCount) - ImGuiTableColumnIdx ColumnsEnabledFixedCount; // Number of enabled columns (<= ColumnsCount) - ImGuiTableColumnIdx DeclColumnsCount; // Count calls to TableSetupColumn() - ImGuiTableColumnIdx HoveredColumnBody; // Index of column whose visible region is being hovered. Important: == ColumnsCount when hovering empty region after the right-most column! - ImGuiTableColumnIdx HoveredColumnBorder; // Index of column whose right-border is being hovered (for resizing). - ImGuiTableColumnIdx AutoFitSingleColumn; // Index of single column requesting auto-fit. - ImGuiTableColumnIdx ResizedColumn; // Index of column being resized. Reset when InstanceCurrent==0. - ImGuiTableColumnIdx LastResizedColumn; // Index of column being resized from previous frame. - ImGuiTableColumnIdx HeldHeaderColumn; // Index of column header being held. - ImGuiTableColumnIdx ReorderColumn; // Index of column being reordered. (not cleared) - ImGuiTableColumnIdx ReorderColumnDir; // -1 or +1 - ImGuiTableColumnIdx LeftMostEnabledColumn; // Index of left-most non-hidden column. - ImGuiTableColumnIdx RightMostEnabledColumn; // Index of right-most non-hidden column. - ImGuiTableColumnIdx LeftMostStretchedColumn; // Index of left-most stretched column. - ImGuiTableColumnIdx RightMostStretchedColumn; // Index of right-most stretched column. - ImGuiTableColumnIdx ContextPopupColumn; // Column right-clicked on, of -1 if opening context menu from a neutral/empty spot - ImGuiTableColumnIdx FreezeRowsRequest; // Requested frozen rows count - ImGuiTableColumnIdx FreezeRowsCount; // Actual frozen row count (== FreezeRowsRequest, or == 0 when no scrolling offset) - ImGuiTableColumnIdx FreezeColumnsRequest; // Requested frozen columns count - ImGuiTableColumnIdx FreezeColumnsCount; // Actual frozen columns count (== FreezeColumnsRequest, or == 0 when no scrolling offset) - ImGuiTableColumnIdx RowCellDataCurrent; // Index of current RowCellData[] entry in current row - ImGuiTableDrawChannelIdx DummyDrawChannel; // Redirect non-visible columns here. - ImGuiTableDrawChannelIdx Bg2DrawChannelCurrent; // For Selectable() and other widgets drawing across columns after the freezing line. Index within DrawSplitter.Channels[] - ImGuiTableDrawChannelIdx Bg2DrawChannelUnfrozen; - bool IsLayoutLocked; // Set by TableUpdateLayout() which is called when beginning the first row. - bool IsInsideRow; // Set when inside TableBeginRow()/TableEndRow(). - bool IsInitializing; - bool IsSortSpecsDirty; - bool IsUsingHeaders; // Set when the first row had the ImGuiTableRowFlags_Headers flag. - bool IsContextPopupOpen; // Set when default context menu is open (also see: ContextPopupColumn, InstanceInteracted). - bool IsSettingsRequestLoad; - bool IsSettingsDirty; // Set when table settings have changed and needs to be reported into ImGuiTableSetttings data. - bool IsDefaultDisplayOrder; // Set when display order is unchanged from default (DisplayOrder contains 0...Count-1) - bool IsResetAllRequest; - bool IsResetDisplayOrderRequest; - bool IsUnfrozenRows; // Set when we got past the frozen row. - bool IsDefaultSizingPolicy; // Set if user didn't explicitly set a sizing policy in BeginTable() - bool MemoryCompacted; - bool HostSkipItems; // Backup of InnerWindow->SkipItem at the end of BeginTable(), because we will overwrite InnerWindow->SkipItem on a per-column basis - - IMGUI_API ImGuiTable() { memset(this, 0, sizeof(*this)); LastFrameActive = -1; } - IMGUI_API ~ImGuiTable() { IM_FREE(RawData); } -}; - -// Transient data that are only needed between BeginTable() and EndTable(), those buffers are shared (1 per level of stacked table). -// - Accessing those requires chasing an extra pointer so for very frequently used data we leave them in the main table structure. -// - We also leave out of this structure data that tend to be particularly useful for debugging/metrics. -struct ImGuiTableTempData -{ - int TableIndex; // Index in g.Tables.Buf[] pool - float LastTimeActive; // Last timestamp this structure was used - - ImVec2 UserOuterSize; // outer_size.x passed to BeginTable() - ImDrawListSplitter DrawSplitter; - - ImRect HostBackupWorkRect; // Backup of InnerWindow->WorkRect at the end of BeginTable() - ImRect HostBackupParentWorkRect; // Backup of InnerWindow->ParentWorkRect at the end of BeginTable() - ImVec2 HostBackupPrevLineSize; // Backup of InnerWindow->DC.PrevLineSize at the end of BeginTable() - ImVec2 HostBackupCurrLineSize; // Backup of InnerWindow->DC.CurrLineSize at the end of BeginTable() - ImVec2 HostBackupCursorMaxPos; // Backup of InnerWindow->DC.CursorMaxPos at the end of BeginTable() - ImVec1 HostBackupColumnsOffset; // Backup of OuterWindow->DC.ColumnsOffset at the end of BeginTable() - float HostBackupItemWidth; // Backup of OuterWindow->DC.ItemWidth at the end of BeginTable() - int HostBackupItemWidthStackSize;//Backup of OuterWindow->DC.ItemWidthStack.Size at the end of BeginTable() - - IMGUI_API ImGuiTableTempData() { memset(this, 0, sizeof(*this)); LastTimeActive = -1.0f; } -}; - -// sizeof() ~ 12 -struct ImGuiTableColumnSettings -{ - float WidthOrWeight; - ImGuiID UserID; - ImGuiTableColumnIdx Index; - ImGuiTableColumnIdx DisplayOrder; - ImGuiTableColumnIdx SortOrder; - ImU8 SortDirection : 2; - ImU8 IsEnabled : 1; // "Visible" in ini file - ImU8 IsStretch : 1; - - ImGuiTableColumnSettings() - { - WidthOrWeight = 0.0f; - UserID = 0; - Index = -1; - DisplayOrder = SortOrder = -1; - SortDirection = ImGuiSortDirection_None; - IsEnabled = 1; - IsStretch = 0; - } -}; - -// This is designed to be stored in a single ImChunkStream (1 header followed by N ImGuiTableColumnSettings, etc.) -struct ImGuiTableSettings -{ - ImGuiID ID; // Set to 0 to invalidate/delete the setting - ImGuiTableFlags SaveFlags; // Indicate data we want to save using the Resizable/Reorderable/Sortable/Hideable flags (could be using its own flags..) - float RefScale; // Reference scale to be able to rescale columns on font/dpi changes. - ImGuiTableColumnIdx ColumnsCount; - ImGuiTableColumnIdx ColumnsCountMax; // Maximum number of columns this settings instance can store, we can recycle a settings instance with lower number of columns but not higher - bool WantApply; // Set when loaded from .ini data (to enable merging/loading .ini data into an already running context) - - ImGuiTableSettings() { memset(this, 0, sizeof(*this)); } - ImGuiTableColumnSettings* GetColumnSettings() { return (ImGuiTableColumnSettings*)(this + 1); } -}; - -//----------------------------------------------------------------------------- -// [SECTION] ImGui internal API -// No guarantee of forward compatibility here! -//----------------------------------------------------------------------------- - -namespace ImGui -{ - // Windows - // We should always have a CurrentWindow in the stack (there is an implicit "Debug" window) - // If this ever crash because g.CurrentWindow is NULL it means that either - // - ImGui::NewFrame() has never been called, which is illegal. - // - You are calling ImGui functions after ImGui::EndFrame()/ImGui::Render() and before the next ImGui::NewFrame(), which is also illegal. - inline ImGuiWindow* GetCurrentWindowRead() { ImGuiContext& g = *GImGui; return g.CurrentWindow; } - inline ImGuiWindow* GetCurrentWindow() { ImGuiContext& g = *GImGui; g.CurrentWindow->WriteAccessed = true; return g.CurrentWindow; } - IMGUI_API ImGuiWindow* FindWindowByID(ImGuiID id); - IMGUI_API ImGuiWindow* FindWindowByName(const char* name); - IMGUI_API void UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags flags, ImGuiWindow* parent_window); - IMGUI_API ImVec2 CalcWindowNextAutoFitSize(ImGuiWindow* window); - IMGUI_API bool IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent, bool popup_hierarchy); - IMGUI_API bool IsWindowAbove(ImGuiWindow* potential_above, ImGuiWindow* potential_below); - IMGUI_API bool IsWindowNavFocusable(ImGuiWindow* window); - IMGUI_API void SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond = 0); - IMGUI_API void SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond cond = 0); - IMGUI_API void SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond = 0); - IMGUI_API void SetWindowHitTestHole(ImGuiWindow* window, const ImVec2& pos, const ImVec2& size); - - // Windows: Display Order and Focus Order - IMGUI_API void FocusWindow(ImGuiWindow* window); - IMGUI_API void FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWindow* ignore_window); - IMGUI_API void BringWindowToFocusFront(ImGuiWindow* window); - IMGUI_API void BringWindowToDisplayFront(ImGuiWindow* window); - IMGUI_API void BringWindowToDisplayBack(ImGuiWindow* window); - - // Fonts, drawing - IMGUI_API void SetCurrentFont(ImFont* font); - inline ImFont* GetDefaultFont() { ImGuiContext& g = *GImGui; return g.IO.FontDefault ? g.IO.FontDefault : g.IO.Fonts->Fonts[0]; } - inline ImDrawList* GetForegroundDrawList(ImGuiWindow* window) { IM_UNUSED(window); return GetForegroundDrawList(); } // This seemingly unnecessary wrapper simplifies compatibility between the 'master' and 'docking' branches. - IMGUI_API ImDrawList* GetBackgroundDrawList(ImGuiViewport* viewport); // get background draw list for the given viewport. this draw list will be the first rendering one. Useful to quickly draw shapes/text behind dear imgui contents. - IMGUI_API ImDrawList* GetForegroundDrawList(ImGuiViewport* viewport); // get foreground draw list for the given viewport. this draw list will be the last rendered one. Useful to quickly draw shapes/text over dear imgui contents. - - // Init - IMGUI_API void Initialize(ImGuiContext* context); - IMGUI_API void Shutdown(ImGuiContext* context); // Since 1.60 this is a _private_ function. You can call DestroyContext() to destroy the context created by CreateContext(). - - // NewFrame - IMGUI_API void UpdateHoveredWindowAndCaptureFlags(); - IMGUI_API void StartMouseMovingWindow(ImGuiWindow* window); - IMGUI_API void UpdateMouseMovingWindowNewFrame(); - IMGUI_API void UpdateMouseMovingWindowEndFrame(); - - // Generic context hooks - IMGUI_API ImGuiID AddContextHook(ImGuiContext* context, const ImGuiContextHook* hook); - IMGUI_API void RemoveContextHook(ImGuiContext* context, ImGuiID hook_to_remove); - IMGUI_API void CallContextHooks(ImGuiContext* context, ImGuiContextHookType type); - - // Settings - IMGUI_API void MarkIniSettingsDirty(); - IMGUI_API void MarkIniSettingsDirty(ImGuiWindow* window); - IMGUI_API void ClearIniSettings(); - IMGUI_API ImGuiWindowSettings* CreateNewWindowSettings(const char* name); - IMGUI_API ImGuiWindowSettings* FindWindowSettings(ImGuiID id); - IMGUI_API ImGuiWindowSettings* FindOrCreateWindowSettings(const char* name); - IMGUI_API ImGuiSettingsHandler* FindSettingsHandler(const char* type_name); - - // Scrolling - IMGUI_API void SetNextWindowScroll(const ImVec2& scroll); // Use -1.0f on one axis to leave as-is - IMGUI_API void SetScrollX(ImGuiWindow* window, float scroll_x); - IMGUI_API void SetScrollY(ImGuiWindow* window, float scroll_y); - IMGUI_API void SetScrollFromPosX(ImGuiWindow* window, float local_x, float center_x_ratio); - IMGUI_API void SetScrollFromPosY(ImGuiWindow* window, float local_y, float center_y_ratio); - - // Early work-in-progress API (ScrollToItem() will become public) - IMGUI_API void ScrollToItem(ImGuiScrollFlags flags = 0); - IMGUI_API void ScrollToRect(ImGuiWindow* window, const ImRect& rect, ImGuiScrollFlags flags = 0); - IMGUI_API ImVec2 ScrollToRectEx(ImGuiWindow* window, const ImRect& rect, ImGuiScrollFlags flags = 0); -//#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS - inline void ScrollToBringRectIntoView(ImGuiWindow* window, const ImRect& rect) { ScrollToRect(window, rect, ImGuiScrollFlags_KeepVisibleEdgeY); } -//#endif - - // Basic Accessors - inline ImGuiID GetItemID() { ImGuiContext& g = *GImGui; return g.LastItemData.ID; } // Get ID of last item (~~ often same ImGui::GetID(label) beforehand) - inline ImGuiItemStatusFlags GetItemStatusFlags(){ ImGuiContext& g = *GImGui; return g.LastItemData.StatusFlags; } - inline ImGuiItemFlags GetItemFlags() { ImGuiContext& g = *GImGui; return g.LastItemData.InFlags; } - inline ImGuiID GetActiveID() { ImGuiContext& g = *GImGui; return g.ActiveId; } - inline ImGuiID GetFocusID() { ImGuiContext& g = *GImGui; return g.NavId; } - IMGUI_API void SetActiveID(ImGuiID id, ImGuiWindow* window); - IMGUI_API void SetFocusID(ImGuiID id, ImGuiWindow* window); - IMGUI_API void ClearActiveID(); - IMGUI_API ImGuiID GetHoveredID(); - IMGUI_API void SetHoveredID(ImGuiID id); - IMGUI_API void KeepAliveID(ImGuiID id); - IMGUI_API void MarkItemEdited(ImGuiID id); // Mark data associated to given item as "edited", used by IsItemDeactivatedAfterEdit() function. - IMGUI_API void PushOverrideID(ImGuiID id); // Push given value as-is at the top of the ID stack (whereas PushID combines old and new hashes) - IMGUI_API ImGuiID GetIDWithSeed(const char* str_id_begin, const char* str_id_end, ImGuiID seed); - - // Basic Helpers for widget code - IMGUI_API void ItemSize(const ImVec2& size, float text_baseline_y = -1.0f); - IMGUI_API void ItemSize(const ImRect& bb, float text_baseline_y = -1.0f); - IMGUI_API bool ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb = NULL, ImGuiItemFlags extra_flags = 0); - IMGUI_API bool ItemHoverable(const ImRect& bb, ImGuiID id); - IMGUI_API void ItemInputable(ImGuiWindow* window, ImGuiID id); - IMGUI_API bool IsClippedEx(const ImRect& bb, ImGuiID id); - IMGUI_API ImVec2 CalcItemSize(ImVec2 size, float default_w, float default_h); - IMGUI_API float CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x); - IMGUI_API void PushMultiItemsWidths(int components, float width_full); - IMGUI_API bool IsItemToggledSelection(); // Was the last item selection toggled? (after Selectable(), TreeNode() etc. We only returns toggle _event_ in order to handle clipping correctly) - IMGUI_API ImVec2 GetContentRegionMaxAbs(); - IMGUI_API void ShrinkWidths(ImGuiShrinkWidthItem* items, int count, float width_excess); - - // Parameter stacks - IMGUI_API void PushItemFlag(ImGuiItemFlags option, bool enabled); - IMGUI_API void PopItemFlag(); - -#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS - // Currently refactoring focus/nav/tabbing system - // If you have old/custom copy-and-pasted widgets that used FocusableItemRegister(): - // (Old) IMGUI_VERSION_NUM < 18209: using 'ItemAdd(....)' and 'bool tab_focused = FocusableItemRegister(...)' - // (Old) IMGUI_VERSION_NUM >= 18209: using 'ItemAdd(..., ImGuiItemAddFlags_Focusable)' and 'bool tab_focused = (GetItemStatusFlags() & ImGuiItemStatusFlags_Focused) != 0' - // (New) IMGUI_VERSION_NUM >= 18413: using 'ItemAdd(..., ImGuiItemFlags_Inputable)' and 'bool tab_focused = (GetItemStatusFlags() & ImGuiItemStatusFlags_FocusedTabbing) != 0 || g.NavActivateInputId == id' (WIP) - // Widget code are simplified as there's no need to call FocusableItemUnregister() while managing the transition from regular widget to TempInputText() - inline bool FocusableItemRegister(ImGuiWindow* window, ImGuiID id) { IM_ASSERT(0); IM_UNUSED(window); IM_UNUSED(id); return false; } // -> pass ImGuiItemAddFlags_Inputable flag to ItemAdd() - inline void FocusableItemUnregister(ImGuiWindow* window) { IM_ASSERT(0); IM_UNUSED(window); } // -> unnecessary: TempInputText() uses ImGuiInputTextFlags_MergedItem -#endif - - // Logging/Capture - IMGUI_API void LogBegin(ImGuiLogType type, int auto_open_depth); // -> BeginCapture() when we design v2 api, for now stay under the radar by using the old name. - IMGUI_API void LogToBuffer(int auto_open_depth = -1); // Start logging/capturing to internal buffer - IMGUI_API void LogRenderedText(const ImVec2* ref_pos, const char* text, const char* text_end = NULL); - IMGUI_API void LogSetNextTextDecoration(const char* prefix, const char* suffix); - - // Popups, Modals, Tooltips - IMGUI_API bool BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags flags); - IMGUI_API void OpenPopupEx(ImGuiID id, ImGuiPopupFlags popup_flags = ImGuiPopupFlags_None); - IMGUI_API void ClosePopupToLevel(int remaining, bool restore_focus_to_window_under_popup); - IMGUI_API void ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to_window_under_popup); - IMGUI_API void ClosePopupsExceptModals(); - IMGUI_API bool IsPopupOpen(ImGuiID id, ImGuiPopupFlags popup_flags); - IMGUI_API bool BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags); - IMGUI_API void BeginTooltipEx(ImGuiWindowFlags extra_flags, ImGuiTooltipFlags tooltip_flags); - IMGUI_API ImRect GetPopupAllowedExtentRect(ImGuiWindow* window); - IMGUI_API ImGuiWindow* GetTopMostPopupModal(); - IMGUI_API ImVec2 FindBestWindowPosForPopup(ImGuiWindow* window); - IMGUI_API ImVec2 FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy); - - // Menus - IMGUI_API bool BeginViewportSideBar(const char* name, ImGuiViewport* viewport, ImGuiDir dir, float size, ImGuiWindowFlags window_flags); - IMGUI_API bool BeginMenuEx(const char* label, const char* icon, bool enabled = true); - IMGUI_API bool MenuItemEx(const char* label, const char* icon, const char* shortcut = NULL, bool selected = false, bool enabled = true); - - // Combos - IMGUI_API bool BeginComboPopup(ImGuiID popup_id, const ImRect& bb, ImGuiComboFlags flags); - IMGUI_API bool BeginComboPreview(); - IMGUI_API void EndComboPreview(); - - // Gamepad/Keyboard Navigation - IMGUI_API void NavInitWindow(ImGuiWindow* window, bool force_reinit); - IMGUI_API void NavInitRequestApplyResult(); - IMGUI_API bool NavMoveRequestButNoResultYet(); - IMGUI_API void NavMoveRequestSubmit(ImGuiDir move_dir, ImGuiDir clip_dir, ImGuiNavMoveFlags move_flags, ImGuiScrollFlags scroll_flags); - IMGUI_API void NavMoveRequestForward(ImGuiDir move_dir, ImGuiDir clip_dir, ImGuiNavMoveFlags move_flags, ImGuiScrollFlags scroll_flags); - IMGUI_API void NavMoveRequestResolveWithLastItem(); - IMGUI_API void NavMoveRequestCancel(); - IMGUI_API void NavMoveRequestApplyResult(); - IMGUI_API void NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags move_flags); - IMGUI_API float GetNavInputAmount(ImGuiNavInput n, ImGuiInputReadMode mode); - IMGUI_API ImVec2 GetNavInputAmount2d(ImGuiNavDirSourceFlags dir_sources, ImGuiInputReadMode mode, float slow_factor = 0.0f, float fast_factor = 0.0f); - IMGUI_API int CalcTypematicRepeatAmount(float t0, float t1, float repeat_delay, float repeat_rate); - IMGUI_API void ActivateItem(ImGuiID id); // Remotely activate a button, checkbox, tree node etc. given its unique ID. activation is queued and processed on the next frame when the item is encountered again. - IMGUI_API void SetNavID(ImGuiID id, ImGuiNavLayer nav_layer, ImGuiID focus_scope_id, const ImRect& rect_rel); - - // Focus Scope (WIP) - // This is generally used to identify a selection set (multiple of which may be in the same window), as selection - // patterns generally need to react (e.g. clear selection) when landing on an item of the set. - IMGUI_API void PushFocusScope(ImGuiID id); - IMGUI_API void PopFocusScope(); - inline ImGuiID GetFocusedFocusScope() { ImGuiContext& g = *GImGui; return g.NavFocusScopeId; } // Focus scope which is actually active - inline ImGuiID GetFocusScope() { ImGuiContext& g = *GImGui; return g.CurrentWindow->DC.NavFocusScopeIdCurrent; } // Focus scope we are outputting into, set by PushFocusScope() - - // Inputs - // FIXME: Eventually we should aim to move e.g. IsActiveIdUsingKey() into IsKeyXXX functions. - IMGUI_API void SetItemUsingMouseWheel(); - IMGUI_API void SetActiveIdUsingNavAndKeys(); - inline bool IsActiveIdUsingNavDir(ImGuiDir dir) { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavDirMask & (1 << dir)) != 0; } - inline bool IsActiveIdUsingNavInput(ImGuiNavInput input) { ImGuiContext& g = *GImGui; return (g.ActiveIdUsingNavInputMask & (1 << input)) != 0; } - inline bool IsActiveIdUsingKey(ImGuiKey key) { ImGuiContext& g = *GImGui; IM_ASSERT(key < 64); return (g.ActiveIdUsingKeyInputMask & ((ImU64)1 << key)) != 0; } - IMGUI_API bool IsMouseDragPastThreshold(ImGuiMouseButton button, float lock_threshold = -1.0f); - inline bool IsKeyPressedMap(ImGuiKey key, bool repeat = true) { ImGuiContext& g = *GImGui; const int key_index = g.IO.KeyMap[key]; return (key_index >= 0) ? IsKeyPressed(key_index, repeat) : false; } - inline bool IsNavInputDown(ImGuiNavInput n) { ImGuiContext& g = *GImGui; return g.IO.NavInputs[n] > 0.0f; } - inline bool IsNavInputTest(ImGuiNavInput n, ImGuiInputReadMode rm) { return (GetNavInputAmount(n, rm) > 0.0f); } - IMGUI_API ImGuiKeyModFlags GetMergedKeyModFlags(); - - // Drag and Drop - IMGUI_API bool BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id); - IMGUI_API void ClearDragDrop(); - IMGUI_API bool IsDragDropPayloadBeingAccepted(); - - // Internal Columns API (this is not exposed because we will encourage transitioning to the Tables API) - IMGUI_API void SetWindowClipRectBeforeSetChannel(ImGuiWindow* window, const ImRect& clip_rect); - IMGUI_API void BeginColumns(const char* str_id, int count, ImGuiOldColumnFlags flags = 0); // setup number of columns. use an identifier to distinguish multiple column sets. close with EndColumns(). - IMGUI_API void EndColumns(); // close columns - IMGUI_API void PushColumnClipRect(int column_index); - IMGUI_API void PushColumnsBackground(); - IMGUI_API void PopColumnsBackground(); - IMGUI_API ImGuiID GetColumnsID(const char* str_id, int count); - IMGUI_API ImGuiOldColumns* FindOrCreateColumns(ImGuiWindow* window, ImGuiID id); - IMGUI_API float GetColumnOffsetFromNorm(const ImGuiOldColumns* columns, float offset_norm); - IMGUI_API float GetColumnNormFromOffset(const ImGuiOldColumns* columns, float offset); - - // Tables: Candidates for public API - IMGUI_API void TableOpenContextMenu(int column_n = -1); - IMGUI_API void TableSetColumnWidth(int column_n, float width); - IMGUI_API void TableSetColumnSortDirection(int column_n, ImGuiSortDirection sort_direction, bool append_to_sort_specs); - IMGUI_API int TableGetHoveredColumn(); // May use (TableGetColumnFlags() & ImGuiTableColumnFlags_IsHovered) instead. Return hovered column. return -1 when table is not hovered. return columns_count if the unused space at the right of visible columns is hovered. - IMGUI_API float TableGetHeaderRowHeight(); - IMGUI_API void TablePushBackgroundChannel(); - IMGUI_API void TablePopBackgroundChannel(); - - // Tables: Internals - inline ImGuiTable* GetCurrentTable() { ImGuiContext& g = *GImGui; return g.CurrentTable; } - IMGUI_API ImGuiTable* TableFindByID(ImGuiID id); - IMGUI_API bool BeginTableEx(const char* name, ImGuiID id, int columns_count, ImGuiTableFlags flags = 0, const ImVec2& outer_size = ImVec2(0, 0), float inner_width = 0.0f); - IMGUI_API void TableBeginInitMemory(ImGuiTable* table, int columns_count); - IMGUI_API void TableBeginApplyRequests(ImGuiTable* table); - IMGUI_API void TableSetupDrawChannels(ImGuiTable* table); - IMGUI_API void TableUpdateLayout(ImGuiTable* table); - IMGUI_API void TableUpdateBorders(ImGuiTable* table); - IMGUI_API void TableUpdateColumnsWeightFromWidth(ImGuiTable* table); - IMGUI_API void TableDrawBorders(ImGuiTable* table); - IMGUI_API void TableDrawContextMenu(ImGuiTable* table); - IMGUI_API void TableMergeDrawChannels(ImGuiTable* table); - IMGUI_API void TableSortSpecsSanitize(ImGuiTable* table); - IMGUI_API void TableSortSpecsBuild(ImGuiTable* table); - IMGUI_API ImGuiSortDirection TableGetColumnNextSortDirection(ImGuiTableColumn* column); - IMGUI_API void TableFixColumnSortDirection(ImGuiTable* table, ImGuiTableColumn* column); - IMGUI_API float TableGetColumnWidthAuto(ImGuiTable* table, ImGuiTableColumn* column); - IMGUI_API void TableBeginRow(ImGuiTable* table); - IMGUI_API void TableEndRow(ImGuiTable* table); - IMGUI_API void TableBeginCell(ImGuiTable* table, int column_n); - IMGUI_API void TableEndCell(ImGuiTable* table); - IMGUI_API ImRect TableGetCellBgRect(const ImGuiTable* table, int column_n); - IMGUI_API const char* TableGetColumnName(const ImGuiTable* table, int column_n); - IMGUI_API ImGuiID TableGetColumnResizeID(const ImGuiTable* table, int column_n, int instance_no = 0); - IMGUI_API float TableGetMaxColumnWidth(const ImGuiTable* table, int column_n); - IMGUI_API void TableSetColumnWidthAutoSingle(ImGuiTable* table, int column_n); - IMGUI_API void TableSetColumnWidthAutoAll(ImGuiTable* table); - IMGUI_API void TableRemove(ImGuiTable* table); - IMGUI_API void TableGcCompactTransientBuffers(ImGuiTable* table); - IMGUI_API void TableGcCompactTransientBuffers(ImGuiTableTempData* table); - IMGUI_API void TableGcCompactSettings(); - - // Tables: Settings - IMGUI_API void TableLoadSettings(ImGuiTable* table); - IMGUI_API void TableSaveSettings(ImGuiTable* table); - IMGUI_API void TableResetSettings(ImGuiTable* table); - IMGUI_API ImGuiTableSettings* TableGetBoundSettings(ImGuiTable* table); - IMGUI_API void TableSettingsInstallHandler(ImGuiContext* context); - IMGUI_API ImGuiTableSettings* TableSettingsCreate(ImGuiID id, int columns_count); - IMGUI_API ImGuiTableSettings* TableSettingsFindByID(ImGuiID id); - - // Tab Bars - IMGUI_API bool BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& bb, ImGuiTabBarFlags flags); - IMGUI_API ImGuiTabItem* TabBarFindTabByID(ImGuiTabBar* tab_bar, ImGuiID tab_id); - IMGUI_API void TabBarRemoveTab(ImGuiTabBar* tab_bar, ImGuiID tab_id); - IMGUI_API void TabBarCloseTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab); - IMGUI_API void TabBarQueueReorder(ImGuiTabBar* tab_bar, const ImGuiTabItem* tab, int offset); - IMGUI_API void TabBarQueueReorderFromMousePos(ImGuiTabBar* tab_bar, const ImGuiTabItem* tab, ImVec2 mouse_pos); - IMGUI_API bool TabBarProcessReorder(ImGuiTabBar* tab_bar); - IMGUI_API bool TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, ImGuiTabItemFlags flags); - IMGUI_API ImVec2 TabItemCalcSize(const char* label, bool has_close_button); - IMGUI_API void TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImU32 col); - IMGUI_API void TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImVec2 frame_padding, const char* label, ImGuiID tab_id, ImGuiID close_button_id, bool is_contents_visible, bool* out_just_closed, bool* out_text_clipped); - - // Render helpers - // AVOID USING OUTSIDE OF IMGUI.CPP! NOT FOR PUBLIC CONSUMPTION. THOSE FUNCTIONS ARE A MESS. THEIR SIGNATURE AND BEHAVIOR WILL CHANGE, THEY NEED TO BE REFACTORED INTO SOMETHING DECENT. - // NB: All position are in absolute pixels coordinates (we are never using window coordinates internally) - IMGUI_API void RenderText(ImVec2 pos, const char* text, const char* text_end = NULL, bool hide_text_after_hash = true); - IMGUI_API void RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width); - IMGUI_API void RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align = ImVec2(0, 0), const ImRect* clip_rect = NULL); - IMGUI_API void RenderTextClippedEx(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align = ImVec2(0, 0), const ImRect* clip_rect = NULL); - IMGUI_API void RenderTextEllipsis(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, float clip_max_x, float ellipsis_max_x, const char* text, const char* text_end, const ImVec2* text_size_if_known); - IMGUI_API void RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border = true, float rounding = 0.0f); - IMGUI_API void RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding = 0.0f); - IMGUI_API void RenderColorRectWithAlphaCheckerboard(ImDrawList* draw_list, ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, float grid_step, ImVec2 grid_off, float rounding = 0.0f, ImDrawFlags flags = 0); - IMGUI_API void RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFlags flags = ImGuiNavHighlightFlags_TypeDefault); // Navigation highlight - IMGUI_API const char* FindRenderedTextEnd(const char* text, const char* text_end = NULL); // Find the optional ## from which we stop displaying text. - - // Render helpers (those functions don't access any ImGui state!) - IMGUI_API void RenderArrow(ImDrawList* draw_list, ImVec2 pos, ImU32 col, ImGuiDir dir, float scale = 1.0f); - IMGUI_API void RenderBullet(ImDrawList* draw_list, ImVec2 pos, ImU32 col); - IMGUI_API void RenderCheckMark(ImDrawList* draw_list, ImVec2 pos, ImU32 col, float sz); - IMGUI_API void RenderMouseCursor(ImDrawList* draw_list, ImVec2 pos, float scale, ImGuiMouseCursor mouse_cursor, ImU32 col_fill, ImU32 col_border, ImU32 col_shadow); - IMGUI_API void RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGuiDir direction, ImU32 col); - IMGUI_API void RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding); - IMGUI_API void RenderRectFilledWithHole(ImDrawList* draw_list, ImRect outer, ImRect inner, ImU32 col, float rounding); - -#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS - // [1.71: 2019/06/07: Updating prototypes of some of the internal functions. Leaving those for reference for a short while] - inline void RenderArrow(ImVec2 pos, ImGuiDir dir, float scale=1.0f) { ImGuiWindow* window = GetCurrentWindow(); RenderArrow(window->DrawList, pos, GetColorU32(ImGuiCol_Text), dir, scale); } - inline void RenderBullet(ImVec2 pos) { ImGuiWindow* window = GetCurrentWindow(); RenderBullet(window->DrawList, pos, GetColorU32(ImGuiCol_Text)); } -#endif - - // Widgets - IMGUI_API void TextEx(const char* text, const char* text_end = NULL, ImGuiTextFlags flags = 0); - IMGUI_API bool ButtonEx(const char* label, const ImVec2& size_arg = ImVec2(0, 0), ImGuiButtonFlags flags = 0); - IMGUI_API bool CloseButton(ImGuiID id, const ImVec2& pos); - IMGUI_API bool CollapseButton(ImGuiID id, const ImVec2& pos); - IMGUI_API bool ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size_arg, ImGuiButtonFlags flags = 0); - IMGUI_API void Scrollbar(ImGuiAxis axis); - IMGUI_API bool ScrollbarEx(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float* p_scroll_v, float avail_v, float contents_v, ImDrawFlags flags); - IMGUI_API bool ImageButtonEx(ImGuiID id, ImTextureID texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, const ImVec2& padding, const ImVec4& bg_col, const ImVec4& tint_col); - IMGUI_API ImRect GetWindowScrollbarRect(ImGuiWindow* window, ImGuiAxis axis); - IMGUI_API ImGuiID GetWindowScrollbarID(ImGuiWindow* window, ImGuiAxis axis); - IMGUI_API ImGuiID GetWindowResizeCornerID(ImGuiWindow* window, int n); // 0..3: corners - IMGUI_API ImGuiID GetWindowResizeBorderID(ImGuiWindow* window, ImGuiDir dir); - IMGUI_API void SeparatorEx(ImGuiSeparatorFlags flags); - IMGUI_API bool CheckboxFlags(const char* label, ImS64* flags, ImS64 flags_value); - IMGUI_API bool CheckboxFlags(const char* label, ImU64* flags, ImU64 flags_value); - - // Widgets low-level behaviors - IMGUI_API bool ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags = 0); - IMGUI_API bool DragBehavior(ImGuiID id, ImGuiDataType data_type, void* p_v, float v_speed, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags); - IMGUI_API bool SliderBehavior(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, void* p_v, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags, ImRect* out_grab_bb); - IMGUI_API bool SplitterBehavior(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float* size1, float* size2, float min_size1, float min_size2, float hover_extend = 0.0f, float hover_visibility_delay = 0.0f); - IMGUI_API bool TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end = NULL); - IMGUI_API bool TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags = 0); // Consume previous SetNextItemOpen() data, if any. May return true when logging - IMGUI_API void TreePushOverrideID(ImGuiID id); - - // Template functions are instantiated in imgui_widgets.cpp for a finite number of types. - // To use them externally (for custom widget) you may need an "extern template" statement in your code in order to link to existing instances and silence Clang warnings (see #2036). - // e.g. " extern template IMGUI_API float RoundScalarWithFormatT(const char* format, ImGuiDataType data_type, float v); " - template IMGUI_API float ScaleRatioFromValueT(ImGuiDataType data_type, T v, T v_min, T v_max, bool is_logarithmic, float logarithmic_zero_epsilon, float zero_deadzone_size); - template IMGUI_API T ScaleValueFromRatioT(ImGuiDataType data_type, float t, T v_min, T v_max, bool is_logarithmic, float logarithmic_zero_epsilon, float zero_deadzone_size); - template IMGUI_API bool DragBehaviorT(ImGuiDataType data_type, T* v, float v_speed, T v_min, T v_max, const char* format, ImGuiSliderFlags flags); - template IMGUI_API bool SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, T* v, T v_min, T v_max, const char* format, ImGuiSliderFlags flags, ImRect* out_grab_bb); - template IMGUI_API T RoundScalarWithFormatT(const char* format, ImGuiDataType data_type, T v); - template IMGUI_API bool CheckboxFlagsT(const char* label, T* flags, T flags_value); - - // Data type helpers - IMGUI_API const ImGuiDataTypeInfo* DataTypeGetInfo(ImGuiDataType data_type); - IMGUI_API int DataTypeFormatString(char* buf, int buf_size, ImGuiDataType data_type, const void* p_data, const char* format); - IMGUI_API void DataTypeApplyOp(ImGuiDataType data_type, int op, void* output, const void* arg_1, const void* arg_2); - IMGUI_API bool DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* p_data, const char* format); - IMGUI_API int DataTypeCompare(ImGuiDataType data_type, const void* arg_1, const void* arg_2); - IMGUI_API bool DataTypeClamp(ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max); - - // InputText - IMGUI_API bool InputTextEx(const char* label, const char* hint, char* buf, int buf_size, const ImVec2& size_arg, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); - IMGUI_API bool TempInputText(const ImRect& bb, ImGuiID id, const char* label, char* buf, int buf_size, ImGuiInputTextFlags flags); - IMGUI_API bool TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* p_data, const char* format, const void* p_clamp_min = NULL, const void* p_clamp_max = NULL); - inline bool TempInputIsActive(ImGuiID id) { ImGuiContext& g = *GImGui; return (g.ActiveId == id && g.TempInputId == id); } - inline ImGuiInputTextState* GetInputTextState(ImGuiID id) { ImGuiContext& g = *GImGui; return (g.InputTextState.ID == id) ? &g.InputTextState : NULL; } // Get input text state if active - - // Color - IMGUI_API void ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags flags); - IMGUI_API void ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags); - IMGUI_API void ColorPickerOptionsPopup(const float* ref_col, ImGuiColorEditFlags flags); - - // Plot - IMGUI_API int PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 frame_size); - - // Shade functions (write over already created vertices) - IMGUI_API void ShadeVertsLinearColorGradientKeepAlpha(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, ImVec2 gradient_p0, ImVec2 gradient_p1, ImU32 col0, ImU32 col1); - IMGUI_API void ShadeVertsLinearUV(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, bool clamp); - - // Garbage collection - IMGUI_API void GcCompactTransientMiscBuffers(); - IMGUI_API void GcCompactTransientWindowBuffers(ImGuiWindow* window); - IMGUI_API void GcAwakeTransientWindowBuffers(ImGuiWindow* window); - - // Debug Tools - IMGUI_API void ErrorCheckEndFrameRecover(ImGuiErrorLogCallback log_callback, void* user_data = NULL); - IMGUI_API void ErrorCheckEndWindowRecover(ImGuiErrorLogCallback log_callback, void* user_data = NULL); - inline void DebugDrawItemRect(ImU32 col = IM_COL32(255,0,0,255)) { ImGuiContext& g = *GImGui; ImGuiWindow* window = g.CurrentWindow; GetForegroundDrawList(window)->AddRect(g.LastItemData.Rect.Min, g.LastItemData.Rect.Max, col); } - inline void DebugStartItemPicker() { ImGuiContext& g = *GImGui; g.DebugItemPickerActive = true; } - - IMGUI_API void ShowFontAtlas(ImFontAtlas* atlas); - IMGUI_API void DebugHookIdInfo(ImGuiID id, ImGuiDataType data_type, const void* data_id, const void* data_id_end); - IMGUI_API void DebugNodeColumns(ImGuiOldColumns* columns); - IMGUI_API void DebugNodeDrawList(ImGuiWindow* window, const ImDrawList* draw_list, const char* label); - IMGUI_API void DebugNodeDrawCmdShowMeshAndBoundingBox(ImDrawList* out_draw_list, const ImDrawList* draw_list, const ImDrawCmd* draw_cmd, bool show_mesh, bool show_aabb); - IMGUI_API void DebugNodeFont(ImFont* font); - IMGUI_API void DebugNodeStorage(ImGuiStorage* storage, const char* label); - IMGUI_API void DebugNodeTabBar(ImGuiTabBar* tab_bar, const char* label); - IMGUI_API void DebugNodeTable(ImGuiTable* table); - IMGUI_API void DebugNodeTableSettings(ImGuiTableSettings* settings); - IMGUI_API void DebugNodeWindow(ImGuiWindow* window, const char* label); - IMGUI_API void DebugNodeWindowSettings(ImGuiWindowSettings* settings); - IMGUI_API void DebugNodeWindowsList(ImVector* windows, const char* label); - IMGUI_API void DebugNodeViewport(ImGuiViewportP* viewport); - IMGUI_API void DebugRenderViewportThumbnail(ImDrawList* draw_list, ImGuiViewportP* viewport, const ImRect& bb); - -} // namespace ImGui - - -//----------------------------------------------------------------------------- -// [SECTION] ImFontAtlas internal API -//----------------------------------------------------------------------------- - -// This structure is likely to evolve as we add support for incremental atlas updates -struct ImFontBuilderIO -{ - bool (*FontBuilder_Build)(ImFontAtlas* atlas); -}; - -// Helper for font builder -IMGUI_API const ImFontBuilderIO* ImFontAtlasGetBuilderForStbTruetype(); -IMGUI_API void ImFontAtlasBuildInit(ImFontAtlas* atlas); -IMGUI_API void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent); -IMGUI_API void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* stbrp_context_opaque); -IMGUI_API void ImFontAtlasBuildFinish(ImFontAtlas* atlas); -IMGUI_API void ImFontAtlasBuildRender8bppRectFromString(ImFontAtlas* atlas, int x, int y, int w, int h, const char* in_str, char in_marker_char, unsigned char in_marker_pixel_value); -IMGUI_API void ImFontAtlasBuildRender32bppRectFromString(ImFontAtlas* atlas, int x, int y, int w, int h, const char* in_str, char in_marker_char, unsigned int in_marker_pixel_value); -IMGUI_API void ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256], float in_multiply_factor); -IMGUI_API void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256], unsigned char* pixels, int x, int y, int w, int h, int stride); - -//----------------------------------------------------------------------------- -// [SECTION] Test Engine specific hooks (imgui_test_engine) -//----------------------------------------------------------------------------- - -#ifdef IMGUI_ENABLE_TEST_ENGINE -extern void ImGuiTestEngineHook_ItemAdd(ImGuiContext* ctx, const ImRect& bb, ImGuiID id); -extern void ImGuiTestEngineHook_ItemInfo(ImGuiContext* ctx, ImGuiID id, const char* label, ImGuiItemStatusFlags flags); -extern void ImGuiTestEngineHook_Log(ImGuiContext* ctx, const char* fmt, ...); -extern const char* ImGuiTestEngine_FindItemDebugLabel(ImGuiContext* ctx, ImGuiID id); - -#define IMGUI_TEST_ENGINE_ITEM_ADD(_BB,_ID) if (g.TestEngineHookItems) ImGuiTestEngineHook_ItemAdd(&g, _BB, _ID) // Register item bounding box -#define IMGUI_TEST_ENGINE_ITEM_INFO(_ID,_LABEL,_FLAGS) if (g.TestEngineHookItems) ImGuiTestEngineHook_ItemInfo(&g, _ID, _LABEL, _FLAGS) // Register item label and status flags (optional) -#define IMGUI_TEST_ENGINE_LOG(_FMT,...) if (g.TestEngineHookItems) ImGuiTestEngineHook_Log(&g, _FMT, __VA_ARGS__) // Custom log entry from user land into test log -#else -#define IMGUI_TEST_ENGINE_ITEM_INFO(_ID,_LABEL,_FLAGS) ((void)0) -#endif - -//----------------------------------------------------------------------------- - -#if defined(__clang__) -#pragma clang diagnostic pop -#elif defined(__GNUC__) -#pragma GCC diagnostic pop -#endif - -#ifdef _MSC_VER -#pragma warning (pop) -#endif - -#endif // #ifndef IMGUI_DISABLE diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imgui_tables.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imgui_tables.cpp deleted file mode 100644 index 56056ae..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imgui_tables.cpp +++ /dev/null @@ -1,4051 +0,0 @@ -// dear imgui, v1.85 -// (tables and columns code) - -/* - -Index of this file: - -// [SECTION] Commentary -// [SECTION] Header mess -// [SECTION] Tables: Main code -// [SECTION] Tables: Simple accessors -// [SECTION] Tables: Row changes -// [SECTION] Tables: Columns changes -// [SECTION] Tables: Columns width management -// [SECTION] Tables: Drawing -// [SECTION] Tables: Sorting -// [SECTION] Tables: Headers -// [SECTION] Tables: Context Menu -// [SECTION] Tables: Settings (.ini data) -// [SECTION] Tables: Garbage Collection -// [SECTION] Tables: Debugging -// [SECTION] Columns, BeginColumns, EndColumns, etc. - -*/ - -// Navigating this file: -// - In Visual Studio IDE: CTRL+comma ("Edit.NavigateTo") can follow symbols in comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot. -// - With Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols in comments. - -//----------------------------------------------------------------------------- -// [SECTION] Commentary -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// Typical tables call flow: (root level is generally public API): -//----------------------------------------------------------------------------- -// - BeginTable() user begin into a table -// | BeginChild() - (if ScrollX/ScrollY is set) -// | TableBeginInitMemory() - first time table is used -// | TableResetSettings() - on settings reset -// | TableLoadSettings() - on settings load -// | TableBeginApplyRequests() - apply queued resizing/reordering/hiding requests -// | - TableSetColumnWidth() - apply resizing width (for mouse resize, often requested by previous frame) -// | - TableUpdateColumnsWeightFromWidth()- recompute columns weights (of stretch columns) from their respective width -// - TableSetupColumn() user submit columns details (optional) -// - TableSetupScrollFreeze() user submit scroll freeze information (optional) -//----------------------------------------------------------------------------- -// - TableUpdateLayout() [Internal] followup to BeginTable(): setup everything: widths, columns positions, clipping rectangles. Automatically called by the FIRST call to TableNextRow() or TableHeadersRow(). -// | TableSetupDrawChannels() - setup ImDrawList channels -// | TableUpdateBorders() - detect hovering columns for resize, ahead of contents submission -// | TableDrawContextMenu() - draw right-click context menu -//----------------------------------------------------------------------------- -// - TableHeadersRow() or TableHeader() user submit a headers row (optional) -// | TableSortSpecsClickColumn() - when left-clicked: alter sort order and sort direction -// | TableOpenContextMenu() - when right-clicked: trigger opening of the default context menu -// - TableGetSortSpecs() user queries updated sort specs (optional, generally after submitting headers) -// - TableNextRow() user begin into a new row (also automatically called by TableHeadersRow()) -// | TableEndRow() - finish existing row -// | TableBeginRow() - add a new row -// - TableSetColumnIndex() / TableNextColumn() user begin into a cell -// | TableEndCell() - close existing column/cell -// | TableBeginCell() - enter into current column/cell -// - [...] user emit contents -//----------------------------------------------------------------------------- -// - EndTable() user ends the table -// | TableDrawBorders() - draw outer borders, inner vertical borders -// | TableMergeDrawChannels() - merge draw channels if clipping isn't required -// | EndChild() - (if ScrollX/ScrollY is set) -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// TABLE SIZING -//----------------------------------------------------------------------------- -// (Read carefully because this is subtle but it does make sense!) -//----------------------------------------------------------------------------- -// About 'outer_size': -// Its meaning needs to differ slightly depending on if we are using ScrollX/ScrollY flags. -// Default value is ImVec2(0.0f, 0.0f). -// X -// - outer_size.x <= 0.0f -> Right-align from window/work-rect right-most edge. With -FLT_MIN or 0.0f will align exactly on right-most edge. -// - outer_size.x > 0.0f -> Set Fixed width. -// Y with ScrollX/ScrollY disabled: we output table directly in current window -// - outer_size.y < 0.0f -> Bottom-align (but will auto extend, unless _NoHostExtendY is set). Not meaningful is parent window can vertically scroll. -// - outer_size.y = 0.0f -> No minimum height (but will auto extend, unless _NoHostExtendY is set) -// - outer_size.y > 0.0f -> Set Minimum height (but will auto extend, unless _NoHostExtenY is set) -// Y with ScrollX/ScrollY enabled: using a child window for scrolling -// - outer_size.y < 0.0f -> Bottom-align. Not meaningful is parent window can vertically scroll. -// - outer_size.y = 0.0f -> Bottom-align, consistent with BeginChild(). Not recommended unless table is last item in parent window. -// - outer_size.y > 0.0f -> Set Exact height. Recommended when using Scrolling on any axis. -//----------------------------------------------------------------------------- -// Outer size is also affected by the NoHostExtendX/NoHostExtendY flags. -// Important to that note how the two flags have slightly different behaviors! -// - ImGuiTableFlags_NoHostExtendX -> Make outer width auto-fit to columns (overriding outer_size.x value). Only available when ScrollX/ScrollY are disabled and Stretch columns are not used. -// - ImGuiTableFlags_NoHostExtendY -> Make outer height stop exactly at outer_size.y (prevent auto-extending table past the limit). Only available when ScrollX/ScrollY is disabled. Data below the limit will be clipped and not visible. -// In theory ImGuiTableFlags_NoHostExtendY could be the default and any non-scrolling tables with outer_size.y != 0.0f would use exact height. -// This would be consistent but perhaps less useful and more confusing (as vertically clipped items are not easily noticeable) -//----------------------------------------------------------------------------- -// About 'inner_width': -// With ScrollX disabled: -// - inner_width -> *ignored* -// With ScrollX enabled: -// - inner_width < 0.0f -> *illegal* fit in known width (right align from outer_size.x) <-- weird -// - inner_width = 0.0f -> fit in outer_width: Fixed size columns will take space they need (if avail, otherwise shrink down), Stretch columns becomes Fixed columns. -// - inner_width > 0.0f -> override scrolling width, generally to be larger than outer_size.x. Fixed column take space they need (if avail, otherwise shrink down), Stretch columns share remaining space! -//----------------------------------------------------------------------------- -// Details: -// - If you want to use Stretch columns with ScrollX, you generally need to specify 'inner_width' otherwise the concept -// of "available space" doesn't make sense. -// - Even if not really useful, we allow 'inner_width < outer_size.x' for consistency and to facilitate understanding -// of what the value does. -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// COLUMNS SIZING POLICIES -//----------------------------------------------------------------------------- -// About overriding column sizing policy and width/weight with TableSetupColumn(): -// We use a default parameter of 'init_width_or_weight == -1'. -// - with ImGuiTableColumnFlags_WidthFixed, init_width <= 0 (default) --> width is automatic -// - with ImGuiTableColumnFlags_WidthFixed, init_width > 0 (explicit) --> width is custom -// - with ImGuiTableColumnFlags_WidthStretch, init_weight <= 0 (default) --> weight is 1.0f -// - with ImGuiTableColumnFlags_WidthStretch, init_weight > 0 (explicit) --> weight is custom -// Widths are specified _without_ CellPadding. If you specify a width of 100.0f, the column will be cover (100.0f + Padding * 2.0f) -// and you can fit a 100.0f wide item in it without clipping and with full padding. -//----------------------------------------------------------------------------- -// About default sizing policy (if you don't specify a ImGuiTableColumnFlags_WidthXXXX flag) -// - with Table policy ImGuiTableFlags_SizingFixedFit --> default Column policy is ImGuiTableColumnFlags_WidthFixed, default Width is equal to contents width -// - with Table policy ImGuiTableFlags_SizingFixedSame --> default Column policy is ImGuiTableColumnFlags_WidthFixed, default Width is max of all contents width -// - with Table policy ImGuiTableFlags_SizingStretchSame --> default Column policy is ImGuiTableColumnFlags_WidthStretch, default Weight is 1.0f -// - with Table policy ImGuiTableFlags_SizingStretchWeight --> default Column policy is ImGuiTableColumnFlags_WidthStretch, default Weight is proportional to contents -// Default Width and default Weight can be overridden when calling TableSetupColumn(). -//----------------------------------------------------------------------------- -// About mixing Fixed/Auto and Stretch columns together: -// - the typical use of mixing sizing policies is: any number of LEADING Fixed columns, followed by one or two TRAILING Stretch columns. -// - using mixed policies with ScrollX does not make much sense, as using Stretch columns with ScrollX does not make much sense in the first place! -// that is, unless 'inner_width' is passed to BeginTable() to explicitly provide a total width to layout columns in. -// - when using ImGuiTableFlags_SizingFixedSame with mixed columns, only the Fixed/Auto columns will match their widths to the width of the maximum contents. -// - when using ImGuiTableFlags_SizingStretchSame with mixed columns, only the Stretch columns will match their weight/widths. -//----------------------------------------------------------------------------- -// About using column width: -// If a column is manual resizable or has a width specified with TableSetupColumn(): -// - you may use GetContentRegionAvail().x to query the width available in a given column. -// - right-side alignment features such as SetNextItemWidth(-x) or PushItemWidth(-x) will rely on this width. -// If the column is not resizable and has no width specified with TableSetupColumn(): -// - its width will be automatic and be set to the max of items submitted. -// - therefore you generally cannot have ALL items of the columns use e.g. SetNextItemWidth(-FLT_MIN). -// - but if the column has one or more items of known/fixed size, this will become the reference width used by SetNextItemWidth(-FLT_MIN). -//----------------------------------------------------------------------------- - - -//----------------------------------------------------------------------------- -// TABLES CLIPPING/CULLING -//----------------------------------------------------------------------------- -// About clipping/culling of Rows in Tables: -// - For large numbers of rows, it is recommended you use ImGuiListClipper to only submit visible rows. -// ImGuiListClipper is reliant on the fact that rows are of equal height. -// See 'Demo->Tables->Vertical Scrolling' or 'Demo->Tables->Advanced' for a demo of using the clipper. -// - Note that auto-resizing columns don't play well with using the clipper. -// By default a table with _ScrollX but without _Resizable will have column auto-resize. -// So, if you want to use the clipper, make sure to either enable _Resizable, either setup columns width explicitly with _WidthFixed. -//----------------------------------------------------------------------------- -// About clipping/culling of Columns in Tables: -// - Both TableSetColumnIndex() and TableNextColumn() return true when the column is visible or performing -// width measurements. Otherwise, you may skip submitting the contents of a cell/column, BUT ONLY if you know -// it is not going to contribute to row height. -// In many situations, you may skip submitting contents for every column but one (e.g. the first one). -// - Case A: column is not hidden by user, and at least partially in sight (most common case). -// - Case B: column is clipped / out of sight (because of scrolling or parent ClipRect): TableNextColumn() return false as a hint but we still allow layout output. -// - Case C: column is hidden explicitly by the user (e.g. via the context menu, or _DefaultHide column flag, etc.). -// -// [A] [B] [C] -// TableNextColumn(): true false false -> [userland] when TableNextColumn() / TableSetColumnIndex() return false, user can skip submitting items but only if the column doesn't contribute to row height. -// SkipItems: false false true -> [internal] when SkipItems is true, most widgets will early out if submitted, resulting is no layout output. -// ClipRect: normal zero-width zero-width -> [internal] when ClipRect is zero, ItemAdd() will return false and most widgets will early out mid-way. -// ImDrawList output: normal dummy dummy -> [internal] when using the dummy channel, ImDrawList submissions (if any) will be wasted (because cliprect is zero-width anyway). -// -// - We need to distinguish those cases because non-hidden columns that are clipped outside of scrolling bounds should still contribute their height to the row. -// However, in the majority of cases, the contribution to row height is the same for all columns, or the tallest cells are known by the programmer. -//----------------------------------------------------------------------------- -// About clipping/culling of whole Tables: -// - Scrolling tables with a known outer size can be clipped earlier as BeginTable() will return false. -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// [SECTION] Header mess -//----------------------------------------------------------------------------- - -#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) -#define _CRT_SECURE_NO_WARNINGS -#endif - -#include "imgui.h" -#ifndef IMGUI_DISABLE - -#ifndef IMGUI_DEFINE_MATH_OPERATORS -#define IMGUI_DEFINE_MATH_OPERATORS -#endif -#include "imgui_internal.h" - -// System includes -#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier -#include // intptr_t -#else -#include // intptr_t -#endif - -// Visual Studio warnings -#ifdef _MSC_VER -#pragma warning (disable: 4127) // condition expression is constant -#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen -#if defined(_MSC_VER) && _MSC_VER >= 1922 // MSVC 2019 16.2 or later -#pragma warning (disable: 5054) // operator '|': deprecated between enumerations of different types -#endif -#pragma warning (disable: 26451) // [Static Analyzer] Arithmetic overflow : Using operator 'xxx' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator 'xxx' to avoid overflow(io.2). -#pragma warning (disable: 26812) // [Static Analyzer] The enum type 'xxx' is unscoped. Prefer 'enum class' over 'enum' (Enum.3). -#endif - -// Clang/GCC warnings with -Weverything -#if defined(__clang__) -#if __has_warning("-Wunknown-warning-option") -#pragma clang diagnostic ignored "-Wunknown-warning-option" // warning: unknown warning group 'xxx' // not all warnings are known by all Clang versions and they tend to be rename-happy.. so ignoring warnings triggers new warnings on some configuration. Great! -#endif -#pragma clang diagnostic ignored "-Wunknown-pragmas" // warning: unknown warning group 'xxx' -#pragma clang diagnostic ignored "-Wold-style-cast" // warning: use of old-style cast // yes, they are more terse. -#pragma clang diagnostic ignored "-Wfloat-equal" // warning: comparing floating point with == or != is unsafe // storing and comparing against same constants (typically 0.0f) is ok. -#pragma clang diagnostic ignored "-Wformat-nonliteral" // warning: format string is not a string literal // passing non-literal to vsnformat(). yes, user passing incorrect format strings can crash the code. -#pragma clang diagnostic ignored "-Wsign-conversion" // warning: implicit conversion changes signedness -#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" // warning: zero as null pointer constant // some standard header variations use #define NULL 0 -#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double. -#pragma clang diagnostic ignored "-Wenum-enum-conversion" // warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') -#pragma clang diagnostic ignored "-Wdeprecated-enum-enum-conversion"// warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') is deprecated -#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision -#elif defined(__GNUC__) -#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind -#pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked -#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead -#endif - -//----------------------------------------------------------------------------- -// [SECTION] Tables: Main code -//----------------------------------------------------------------------------- -// - TableFixFlags() [Internal] -// - TableFindByID() [Internal] -// - BeginTable() -// - BeginTableEx() [Internal] -// - TableBeginInitMemory() [Internal] -// - TableBeginApplyRequests() [Internal] -// - TableSetupColumnFlags() [Internal] -// - TableUpdateLayout() [Internal] -// - TableUpdateBorders() [Internal] -// - EndTable() -// - TableSetupColumn() -// - TableSetupScrollFreeze() -//----------------------------------------------------------------------------- - -// Configuration -static const int TABLE_DRAW_CHANNEL_BG0 = 0; -static const int TABLE_DRAW_CHANNEL_BG2_FROZEN = 1; -static const int TABLE_DRAW_CHANNEL_NOCLIP = 2; // When using ImGuiTableFlags_NoClip (this becomes the last visible channel) -static const float TABLE_BORDER_SIZE = 1.0f; // FIXME-TABLE: Currently hard-coded because of clipping assumptions with outer borders rendering. -static const float TABLE_RESIZE_SEPARATOR_HALF_THICKNESS = 4.0f; // Extend outside inner borders. -static const float TABLE_RESIZE_SEPARATOR_FEEDBACK_TIMER = 0.06f; // Delay/timer before making the hover feedback (color+cursor) visible because tables/columns tends to be more cramped. - -// Helper -inline ImGuiTableFlags TableFixFlags(ImGuiTableFlags flags, ImGuiWindow* outer_window) -{ - // Adjust flags: set default sizing policy - if ((flags & ImGuiTableFlags_SizingMask_) == 0) - flags |= ((flags & ImGuiTableFlags_ScrollX) || (outer_window->Flags & ImGuiWindowFlags_AlwaysAutoResize)) ? ImGuiTableFlags_SizingFixedFit : ImGuiTableFlags_SizingStretchSame; - - // Adjust flags: enable NoKeepColumnsVisible when using ImGuiTableFlags_SizingFixedSame - if ((flags & ImGuiTableFlags_SizingMask_) == ImGuiTableFlags_SizingFixedSame) - flags |= ImGuiTableFlags_NoKeepColumnsVisible; - - // Adjust flags: enforce borders when resizable - if (flags & ImGuiTableFlags_Resizable) - flags |= ImGuiTableFlags_BordersInnerV; - - // Adjust flags: disable NoHostExtendX/NoHostExtendY if we have any scrolling going on - if (flags & (ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY)) - flags &= ~(ImGuiTableFlags_NoHostExtendX | ImGuiTableFlags_NoHostExtendY); - - // Adjust flags: NoBordersInBodyUntilResize takes priority over NoBordersInBody - if (flags & ImGuiTableFlags_NoBordersInBodyUntilResize) - flags &= ~ImGuiTableFlags_NoBordersInBody; - - // Adjust flags: disable saved settings if there's nothing to save - if ((flags & (ImGuiTableFlags_Resizable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Sortable)) == 0) - flags |= ImGuiTableFlags_NoSavedSettings; - - // Inherit _NoSavedSettings from top-level window (child windows always have _NoSavedSettings set) - if (outer_window->RootWindow->Flags & ImGuiWindowFlags_NoSavedSettings) - flags |= ImGuiTableFlags_NoSavedSettings; - - return flags; -} - -ImGuiTable* ImGui::TableFindByID(ImGuiID id) -{ - ImGuiContext& g = *GImGui; - return g.Tables.GetByKey(id); -} - -// Read about "TABLE SIZING" at the top of this file. -bool ImGui::BeginTable(const char* str_id, int columns_count, ImGuiTableFlags flags, const ImVec2& outer_size, float inner_width) -{ - ImGuiID id = GetID(str_id); - return BeginTableEx(str_id, id, columns_count, flags, outer_size, inner_width); -} - -bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImGuiTableFlags flags, const ImVec2& outer_size, float inner_width) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* outer_window = GetCurrentWindow(); - if (outer_window->SkipItems) // Consistent with other tables + beneficial side effect that assert on miscalling EndTable() will be more visible. - return false; - - // Sanity checks - IM_ASSERT(columns_count > 0 && columns_count <= IMGUI_TABLE_MAX_COLUMNS && "Only 1..64 columns allowed!"); - if (flags & ImGuiTableFlags_ScrollX) - IM_ASSERT(inner_width >= 0.0f); - - // If an outer size is specified ahead we will be able to early out when not visible. Exact clipping rules may evolve. - const bool use_child_window = (flags & (ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY)) != 0; - const ImVec2 avail_size = GetContentRegionAvail(); - ImVec2 actual_outer_size = CalcItemSize(outer_size, ImMax(avail_size.x, 1.0f), use_child_window ? ImMax(avail_size.y, 1.0f) : 0.0f); - ImRect outer_rect(outer_window->DC.CursorPos, outer_window->DC.CursorPos + actual_outer_size); - if (use_child_window && IsClippedEx(outer_rect, 0)) - { - ItemSize(outer_rect); - return false; - } - - // Acquire storage for the table - ImGuiTable* table = g.Tables.GetOrAddByKey(id); - const int instance_no = (table->LastFrameActive != g.FrameCount) ? 0 : table->InstanceCurrent + 1; - const ImGuiID instance_id = id + instance_no; - const ImGuiTableFlags table_last_flags = table->Flags; - if (instance_no > 0) - IM_ASSERT(table->ColumnsCount == columns_count && "BeginTable(): Cannot change columns count mid-frame while preserving same ID"); - - // Acquire temporary buffers - const int table_idx = g.Tables.GetIndex(table); - g.CurrentTableStackIdx++; - if (g.CurrentTableStackIdx + 1 > g.TablesTempDataStack.Size) - g.TablesTempDataStack.resize(g.CurrentTableStackIdx + 1, ImGuiTableTempData()); - ImGuiTableTempData* temp_data = table->TempData = &g.TablesTempDataStack[g.CurrentTableStackIdx]; - temp_data->TableIndex = table_idx; - table->DrawSplitter = &table->TempData->DrawSplitter; - table->DrawSplitter->Clear(); - - // Fix flags - table->IsDefaultSizingPolicy = (flags & ImGuiTableFlags_SizingMask_) == 0; - flags = TableFixFlags(flags, outer_window); - - // Initialize - table->ID = id; - table->Flags = flags; - table->InstanceCurrent = (ImS16)instance_no; - table->LastFrameActive = g.FrameCount; - table->OuterWindow = table->InnerWindow = outer_window; - table->ColumnsCount = columns_count; - table->IsLayoutLocked = false; - table->InnerWidth = inner_width; - temp_data->UserOuterSize = outer_size; - - // When not using a child window, WorkRect.Max will grow as we append contents. - if (use_child_window) - { - // Ensure no vertical scrollbar appears if we only want horizontal one, to make flag consistent - // (we have no other way to disable vertical scrollbar of a window while keeping the horizontal one showing) - ImVec2 override_content_size(FLT_MAX, FLT_MAX); - if ((flags & ImGuiTableFlags_ScrollX) && !(flags & ImGuiTableFlags_ScrollY)) - override_content_size.y = FLT_MIN; - - // Ensure specified width (when not specified, Stretched columns will act as if the width == OuterWidth and - // never lead to any scrolling). We don't handle inner_width < 0.0f, we could potentially use it to right-align - // based on the right side of the child window work rect, which would require knowing ahead if we are going to - // have decoration taking horizontal spaces (typically a vertical scrollbar). - if ((flags & ImGuiTableFlags_ScrollX) && inner_width > 0.0f) - override_content_size.x = inner_width; - - if (override_content_size.x != FLT_MAX || override_content_size.y != FLT_MAX) - SetNextWindowContentSize(ImVec2(override_content_size.x != FLT_MAX ? override_content_size.x : 0.0f, override_content_size.y != FLT_MAX ? override_content_size.y : 0.0f)); - - // Reset scroll if we are reactivating it - if ((table_last_flags & (ImGuiTableFlags_ScrollX | ImGuiTableFlags_ScrollY)) == 0) - SetNextWindowScroll(ImVec2(0.0f, 0.0f)); - - // Create scrolling region (without border and zero window padding) - ImGuiWindowFlags child_flags = (flags & ImGuiTableFlags_ScrollX) ? ImGuiWindowFlags_HorizontalScrollbar : ImGuiWindowFlags_None; - BeginChildEx(name, instance_id, outer_rect.GetSize(), false, child_flags); - table->InnerWindow = g.CurrentWindow; - table->WorkRect = table->InnerWindow->WorkRect; - table->OuterRect = table->InnerWindow->Rect(); - table->InnerRect = table->InnerWindow->InnerRect; - IM_ASSERT(table->InnerWindow->WindowPadding.x == 0.0f && table->InnerWindow->WindowPadding.y == 0.0f && table->InnerWindow->WindowBorderSize == 0.0f); - } - else - { - // For non-scrolling tables, WorkRect == OuterRect == InnerRect. - // But at this point we do NOT have a correct value for .Max.y (unless a height has been explicitly passed in). It will only be updated in EndTable(). - table->WorkRect = table->OuterRect = table->InnerRect = outer_rect; - } - - // Push a standardized ID for both child-using and not-child-using tables - PushOverrideID(instance_id); - - // Backup a copy of host window members we will modify - ImGuiWindow* inner_window = table->InnerWindow; - table->HostIndentX = inner_window->DC.Indent.x; - table->HostClipRect = inner_window->ClipRect; - table->HostSkipItems = inner_window->SkipItems; - temp_data->HostBackupWorkRect = inner_window->WorkRect; - temp_data->HostBackupParentWorkRect = inner_window->ParentWorkRect; - temp_data->HostBackupColumnsOffset = outer_window->DC.ColumnsOffset; - temp_data->HostBackupPrevLineSize = inner_window->DC.PrevLineSize; - temp_data->HostBackupCurrLineSize = inner_window->DC.CurrLineSize; - temp_data->HostBackupCursorMaxPos = inner_window->DC.CursorMaxPos; - temp_data->HostBackupItemWidth = outer_window->DC.ItemWidth; - temp_data->HostBackupItemWidthStackSize = outer_window->DC.ItemWidthStack.Size; - inner_window->DC.PrevLineSize = inner_window->DC.CurrLineSize = ImVec2(0.0f, 0.0f); - - // Padding and Spacing - // - None ........Content..... Pad .....Content........ - // - PadOuter | Pad ..Content..... Pad .....Content.. Pad | - // - PadInner ........Content.. Pad | Pad ..Content........ - // - PadOuter+PadInner | Pad ..Content.. Pad | Pad ..Content.. Pad | - const bool pad_outer_x = (flags & ImGuiTableFlags_NoPadOuterX) ? false : (flags & ImGuiTableFlags_PadOuterX) ? true : (flags & ImGuiTableFlags_BordersOuterV) != 0; - const bool pad_inner_x = (flags & ImGuiTableFlags_NoPadInnerX) ? false : true; - const float inner_spacing_for_border = (flags & ImGuiTableFlags_BordersInnerV) ? TABLE_BORDER_SIZE : 0.0f; - const float inner_spacing_explicit = (pad_inner_x && (flags & ImGuiTableFlags_BordersInnerV) == 0) ? g.Style.CellPadding.x : 0.0f; - const float inner_padding_explicit = (pad_inner_x && (flags & ImGuiTableFlags_BordersInnerV) != 0) ? g.Style.CellPadding.x : 0.0f; - table->CellSpacingX1 = inner_spacing_explicit + inner_spacing_for_border; - table->CellSpacingX2 = inner_spacing_explicit; - table->CellPaddingX = inner_padding_explicit; - table->CellPaddingY = g.Style.CellPadding.y; - - const float outer_padding_for_border = (flags & ImGuiTableFlags_BordersOuterV) ? TABLE_BORDER_SIZE : 0.0f; - const float outer_padding_explicit = pad_outer_x ? g.Style.CellPadding.x : 0.0f; - table->OuterPaddingX = (outer_padding_for_border + outer_padding_explicit) - table->CellPaddingX; - - table->CurrentColumn = -1; - table->CurrentRow = -1; - table->RowBgColorCounter = 0; - table->LastRowFlags = ImGuiTableRowFlags_None; - table->InnerClipRect = (inner_window == outer_window) ? table->WorkRect : inner_window->ClipRect; - table->InnerClipRect.ClipWith(table->WorkRect); // We need this to honor inner_width - table->InnerClipRect.ClipWithFull(table->HostClipRect); - table->InnerClipRect.Max.y = (flags & ImGuiTableFlags_NoHostExtendY) ? ImMin(table->InnerClipRect.Max.y, inner_window->WorkRect.Max.y) : inner_window->ClipRect.Max.y; - - table->RowPosY1 = table->RowPosY2 = table->WorkRect.Min.y; // This is needed somehow - table->RowTextBaseline = 0.0f; // This will be cleared again by TableBeginRow() - table->FreezeRowsRequest = table->FreezeRowsCount = 0; // This will be setup by TableSetupScrollFreeze(), if any - table->FreezeColumnsRequest = table->FreezeColumnsCount = 0; - table->IsUnfrozenRows = true; - table->DeclColumnsCount = 0; - - // Using opaque colors facilitate overlapping elements of the grid - table->BorderColorStrong = GetColorU32(ImGuiCol_TableBorderStrong); - table->BorderColorLight = GetColorU32(ImGuiCol_TableBorderLight); - - // Make table current - g.CurrentTable = table; - outer_window->DC.CurrentTableIdx = table_idx; - if (inner_window != outer_window) // So EndChild() within the inner window can restore the table properly. - inner_window->DC.CurrentTableIdx = table_idx; - - if ((table_last_flags & ImGuiTableFlags_Reorderable) && (flags & ImGuiTableFlags_Reorderable) == 0) - table->IsResetDisplayOrderRequest = true; - - // Mark as used - if (table_idx >= g.TablesLastTimeActive.Size) - g.TablesLastTimeActive.resize(table_idx + 1, -1.0f); - g.TablesLastTimeActive[table_idx] = (float)g.Time; - temp_data->LastTimeActive = (float)g.Time; - table->MemoryCompacted = false; - - // Setup memory buffer (clear data if columns count changed) - ImGuiTableColumn* old_columns_to_preserve = NULL; - void* old_columns_raw_data = NULL; - const int old_columns_count = table->Columns.size(); - if (old_columns_count != 0 && old_columns_count != columns_count) - { - // Attempt to preserve width on column count change (#4046) - old_columns_to_preserve = table->Columns.Data; - old_columns_raw_data = table->RawData; - table->RawData = NULL; - } - if (table->RawData == NULL) - { - TableBeginInitMemory(table, columns_count); - table->IsInitializing = table->IsSettingsRequestLoad = true; - } - if (table->IsResetAllRequest) - TableResetSettings(table); - if (table->IsInitializing) - { - // Initialize - table->SettingsOffset = -1; - table->IsSortSpecsDirty = true; - table->InstanceInteracted = -1; - table->ContextPopupColumn = -1; - table->ReorderColumn = table->ResizedColumn = table->LastResizedColumn = -1; - table->AutoFitSingleColumn = -1; - table->HoveredColumnBody = table->HoveredColumnBorder = -1; - for (int n = 0; n < columns_count; n++) - { - ImGuiTableColumn* column = &table->Columns[n]; - if (old_columns_to_preserve && n < old_columns_count) - { - // FIXME: We don't attempt to preserve column order in this path. - *column = old_columns_to_preserve[n]; - } - else - { - float width_auto = column->WidthAuto; - *column = ImGuiTableColumn(); - column->WidthAuto = width_auto; - column->IsPreserveWidthAuto = true; // Preserve WidthAuto when reinitializing a live table: not technically necessary but remove a visible flicker - column->IsEnabled = column->IsUserEnabled = column->IsUserEnabledNextFrame = true; - } - column->DisplayOrder = table->DisplayOrderToIndex[n] = (ImGuiTableColumnIdx)n; - } - } - if (old_columns_raw_data) - IM_FREE(old_columns_raw_data); - - // Load settings - if (table->IsSettingsRequestLoad) - TableLoadSettings(table); - - // Handle DPI/font resize - // This is designed to facilitate DPI changes with the assumption that e.g. style.CellPadding has been scaled as well. - // It will also react to changing fonts with mixed results. It doesn't need to be perfect but merely provide a decent transition. - // FIXME-DPI: Provide consistent standards for reference size. Perhaps using g.CurrentDpiScale would be more self explanatory. - // This is will lead us to non-rounded WidthRequest in columns, which should work but is a poorly tested path. - const float new_ref_scale_unit = g.FontSize; // g.Font->GetCharAdvance('A') ? - if (table->RefScale != 0.0f && table->RefScale != new_ref_scale_unit) - { - const float scale_factor = new_ref_scale_unit / table->RefScale; - //IMGUI_DEBUG_LOG("[table] %08X RefScaleUnit %.3f -> %.3f, scaling width by %.3f\n", table->ID, table->RefScaleUnit, new_ref_scale_unit, scale_factor); - for (int n = 0; n < columns_count; n++) - table->Columns[n].WidthRequest = table->Columns[n].WidthRequest * scale_factor; - } - table->RefScale = new_ref_scale_unit; - - // Disable output until user calls TableNextRow() or TableNextColumn() leading to the TableUpdateLayout() call.. - // This is not strictly necessary but will reduce cases were "out of table" output will be misleading to the user. - // Because we cannot safely assert in EndTable() when no rows have been created, this seems like our best option. - inner_window->SkipItems = true; - - // Clear names - // At this point the ->NameOffset field of each column will be invalid until TableUpdateLayout() or the first call to TableSetupColumn() - if (table->ColumnsNames.Buf.Size > 0) - table->ColumnsNames.Buf.resize(0); - - // Apply queued resizing/reordering/hiding requests - TableBeginApplyRequests(table); - - return true; -} - -// For reference, the average total _allocation count_ for a table is: -// + 0 (for ImGuiTable instance, we are pooling allocations in g.Tables) -// + 1 (for table->RawData allocated below) -// + 1 (for table->ColumnsNames, if names are used) -// Shared allocations per number of nested tables -// + 1 (for table->Splitter._Channels) -// + 2 * active_channels_count (for ImDrawCmd and ImDrawIdx buffers inside channels) -// Where active_channels_count is variable but often == columns_count or columns_count + 1, see TableSetupDrawChannels() for details. -// Unused channels don't perform their +2 allocations. -void ImGui::TableBeginInitMemory(ImGuiTable* table, int columns_count) -{ - // Allocate single buffer for our arrays - ImSpanAllocator<3> span_allocator; - span_allocator.Reserve(0, columns_count * sizeof(ImGuiTableColumn)); - span_allocator.Reserve(1, columns_count * sizeof(ImGuiTableColumnIdx)); - span_allocator.Reserve(2, columns_count * sizeof(ImGuiTableCellData), 4); - table->RawData = IM_ALLOC(span_allocator.GetArenaSizeInBytes()); - memset(table->RawData, 0, span_allocator.GetArenaSizeInBytes()); - span_allocator.SetArenaBasePtr(table->RawData); - span_allocator.GetSpan(0, &table->Columns); - span_allocator.GetSpan(1, &table->DisplayOrderToIndex); - span_allocator.GetSpan(2, &table->RowCellData); -} - -// Apply queued resizing/reordering/hiding requests -void ImGui::TableBeginApplyRequests(ImGuiTable* table) -{ - // Handle resizing request - // (We process this at the first TableBegin of the frame) - // FIXME-TABLE: Contains columns if our work area doesn't allow for scrolling? - if (table->InstanceCurrent == 0) - { - if (table->ResizedColumn != -1 && table->ResizedColumnNextWidth != FLT_MAX) - TableSetColumnWidth(table->ResizedColumn, table->ResizedColumnNextWidth); - table->LastResizedColumn = table->ResizedColumn; - table->ResizedColumnNextWidth = FLT_MAX; - table->ResizedColumn = -1; - - // Process auto-fit for single column, which is a special case for stretch columns and fixed columns with FixedSame policy. - // FIXME-TABLE: Would be nice to redistribute available stretch space accordingly to other weights, instead of giving it all to siblings. - if (table->AutoFitSingleColumn != -1) - { - TableSetColumnWidth(table->AutoFitSingleColumn, table->Columns[table->AutoFitSingleColumn].WidthAuto); - table->AutoFitSingleColumn = -1; - } - } - - // Handle reordering request - // Note: we don't clear ReorderColumn after handling the request. - if (table->InstanceCurrent == 0) - { - if (table->HeldHeaderColumn == -1 && table->ReorderColumn != -1) - table->ReorderColumn = -1; - table->HeldHeaderColumn = -1; - if (table->ReorderColumn != -1 && table->ReorderColumnDir != 0) - { - // We need to handle reordering across hidden columns. - // In the configuration below, moving C to the right of E will lead to: - // ... C [D] E ---> ... [D] E C (Column name/index) - // ... 2 3 4 ... 2 3 4 (Display order) - const int reorder_dir = table->ReorderColumnDir; - IM_ASSERT(reorder_dir == -1 || reorder_dir == +1); - IM_ASSERT(table->Flags & ImGuiTableFlags_Reorderable); - ImGuiTableColumn* src_column = &table->Columns[table->ReorderColumn]; - ImGuiTableColumn* dst_column = &table->Columns[(reorder_dir == -1) ? src_column->PrevEnabledColumn : src_column->NextEnabledColumn]; - IM_UNUSED(dst_column); - const int src_order = src_column->DisplayOrder; - const int dst_order = dst_column->DisplayOrder; - src_column->DisplayOrder = (ImGuiTableColumnIdx)dst_order; - for (int order_n = src_order + reorder_dir; order_n != dst_order + reorder_dir; order_n += reorder_dir) - table->Columns[table->DisplayOrderToIndex[order_n]].DisplayOrder -= (ImGuiTableColumnIdx)reorder_dir; - IM_ASSERT(dst_column->DisplayOrder == dst_order - reorder_dir); - - // Display order is stored in both columns->IndexDisplayOrder and table->DisplayOrder[], - // rebuild the later from the former. - for (int column_n = 0; column_n < table->ColumnsCount; column_n++) - table->DisplayOrderToIndex[table->Columns[column_n].DisplayOrder] = (ImGuiTableColumnIdx)column_n; - table->ReorderColumnDir = 0; - table->IsSettingsDirty = true; - } - } - - // Handle display order reset request - if (table->IsResetDisplayOrderRequest) - { - for (int n = 0; n < table->ColumnsCount; n++) - table->DisplayOrderToIndex[n] = table->Columns[n].DisplayOrder = (ImGuiTableColumnIdx)n; - table->IsResetDisplayOrderRequest = false; - table->IsSettingsDirty = true; - } -} - -// Adjust flags: default width mode + stretch columns are not allowed when auto extending -static void TableSetupColumnFlags(ImGuiTable* table, ImGuiTableColumn* column, ImGuiTableColumnFlags flags_in) -{ - ImGuiTableColumnFlags flags = flags_in; - - // Sizing Policy - if ((flags & ImGuiTableColumnFlags_WidthMask_) == 0) - { - const ImGuiTableFlags table_sizing_policy = (table->Flags & ImGuiTableFlags_SizingMask_); - if (table_sizing_policy == ImGuiTableFlags_SizingFixedFit || table_sizing_policy == ImGuiTableFlags_SizingFixedSame) - flags |= ImGuiTableColumnFlags_WidthFixed; - else - flags |= ImGuiTableColumnFlags_WidthStretch; - } - else - { - IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiTableColumnFlags_WidthMask_)); // Check that only 1 of each set is used. - } - - // Resize - if ((table->Flags & ImGuiTableFlags_Resizable) == 0) - flags |= ImGuiTableColumnFlags_NoResize; - - // Sorting - if ((flags & ImGuiTableColumnFlags_NoSortAscending) && (flags & ImGuiTableColumnFlags_NoSortDescending)) - flags |= ImGuiTableColumnFlags_NoSort; - - // Indentation - if ((flags & ImGuiTableColumnFlags_IndentMask_) == 0) - flags |= (table->Columns.index_from_ptr(column) == 0) ? ImGuiTableColumnFlags_IndentEnable : ImGuiTableColumnFlags_IndentDisable; - - // Alignment - //if ((flags & ImGuiTableColumnFlags_AlignMask_) == 0) - // flags |= ImGuiTableColumnFlags_AlignCenter; - //IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiTableColumnFlags_AlignMask_)); // Check that only 1 of each set is used. - - // Preserve status flags - column->Flags = flags | (column->Flags & ImGuiTableColumnFlags_StatusMask_); - - // Build an ordered list of available sort directions - column->SortDirectionsAvailCount = column->SortDirectionsAvailMask = column->SortDirectionsAvailList = 0; - if (table->Flags & ImGuiTableFlags_Sortable) - { - int count = 0, mask = 0, list = 0; - if ((flags & ImGuiTableColumnFlags_PreferSortAscending) != 0 && (flags & ImGuiTableColumnFlags_NoSortAscending) == 0) { mask |= 1 << ImGuiSortDirection_Ascending; list |= ImGuiSortDirection_Ascending << (count << 1); count++; } - if ((flags & ImGuiTableColumnFlags_PreferSortDescending) != 0 && (flags & ImGuiTableColumnFlags_NoSortDescending) == 0) { mask |= 1 << ImGuiSortDirection_Descending; list |= ImGuiSortDirection_Descending << (count << 1); count++; } - if ((flags & ImGuiTableColumnFlags_PreferSortAscending) == 0 && (flags & ImGuiTableColumnFlags_NoSortAscending) == 0) { mask |= 1 << ImGuiSortDirection_Ascending; list |= ImGuiSortDirection_Ascending << (count << 1); count++; } - if ((flags & ImGuiTableColumnFlags_PreferSortDescending) == 0 && (flags & ImGuiTableColumnFlags_NoSortDescending) == 0) { mask |= 1 << ImGuiSortDirection_Descending; list |= ImGuiSortDirection_Descending << (count << 1); count++; } - if ((table->Flags & ImGuiTableFlags_SortTristate) || count == 0) { mask |= 1 << ImGuiSortDirection_None; count++; } - column->SortDirectionsAvailList = (ImU8)list; - column->SortDirectionsAvailMask = (ImU8)mask; - column->SortDirectionsAvailCount = (ImU8)count; - ImGui::TableFixColumnSortDirection(table, column); - } -} - -// Layout columns for the frame. This is in essence the followup to BeginTable(). -// Runs on the first call to TableNextRow(), to give a chance for TableSetupColumn() to be called first. -// FIXME-TABLE: Our width (and therefore our WorkRect) will be minimal in the first frame for _WidthAuto columns. -// Increase feedback side-effect with widgets relying on WorkRect.Max.x... Maybe provide a default distribution for _WidthAuto columns? -void ImGui::TableUpdateLayout(ImGuiTable* table) -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(table->IsLayoutLocked == false); - - const ImGuiTableFlags table_sizing_policy = (table->Flags & ImGuiTableFlags_SizingMask_); - table->IsDefaultDisplayOrder = true; - table->ColumnsEnabledCount = 0; - table->EnabledMaskByIndex = 0x00; - table->EnabledMaskByDisplayOrder = 0x00; - table->LeftMostEnabledColumn = -1; - table->MinColumnWidth = ImMax(1.0f, g.Style.FramePadding.x * 1.0f); // g.Style.ColumnsMinSpacing; // FIXME-TABLE - - // [Part 1] Apply/lock Enabled and Order states. Calculate auto/ideal width for columns. Count fixed/stretch columns. - // Process columns in their visible orders as we are building the Prev/Next indices. - int count_fixed = 0; // Number of columns that have fixed sizing policies - int count_stretch = 0; // Number of columns that have stretch sizing policies - int prev_visible_column_idx = -1; - bool has_auto_fit_request = false; - bool has_resizable = false; - float stretch_sum_width_auto = 0.0f; - float fixed_max_width_auto = 0.0f; - for (int order_n = 0; order_n < table->ColumnsCount; order_n++) - { - const int column_n = table->DisplayOrderToIndex[order_n]; - if (column_n != order_n) - table->IsDefaultDisplayOrder = false; - ImGuiTableColumn* column = &table->Columns[column_n]; - - // Clear column setup if not submitted by user. Currently we make it mandatory to call TableSetupColumn() every frame. - // It would easily work without but we're not ready to guarantee it since e.g. names need resubmission anyway. - // We take a slight shortcut but in theory we could be calling TableSetupColumn() here with dummy values, it should yield the same effect. - if (table->DeclColumnsCount <= column_n) - { - TableSetupColumnFlags(table, column, ImGuiTableColumnFlags_None); - column->NameOffset = -1; - column->UserID = 0; - column->InitStretchWeightOrWidth = -1.0f; - } - - // Update Enabled state, mark settings and sort specs dirty - if (!(table->Flags & ImGuiTableFlags_Hideable) || (column->Flags & ImGuiTableColumnFlags_NoHide)) - column->IsUserEnabledNextFrame = true; - if (column->IsUserEnabled != column->IsUserEnabledNextFrame) - { - column->IsUserEnabled = column->IsUserEnabledNextFrame; - table->IsSettingsDirty = true; - } - column->IsEnabled = column->IsUserEnabled && (column->Flags & ImGuiTableColumnFlags_Disabled) == 0; - - if (column->SortOrder != -1 && !column->IsEnabled) - table->IsSortSpecsDirty = true; - if (column->SortOrder > 0 && !(table->Flags & ImGuiTableFlags_SortMulti)) - table->IsSortSpecsDirty = true; - - // Auto-fit unsized columns - const bool start_auto_fit = (column->Flags & ImGuiTableColumnFlags_WidthFixed) ? (column->WidthRequest < 0.0f) : (column->StretchWeight < 0.0f); - if (start_auto_fit) - column->AutoFitQueue = column->CannotSkipItemsQueue = (1 << 3) - 1; // Fit for three frames - - if (!column->IsEnabled) - { - column->IndexWithinEnabledSet = -1; - continue; - } - - // Mark as enabled and link to previous/next enabled column - column->PrevEnabledColumn = (ImGuiTableColumnIdx)prev_visible_column_idx; - column->NextEnabledColumn = -1; - if (prev_visible_column_idx != -1) - table->Columns[prev_visible_column_idx].NextEnabledColumn = (ImGuiTableColumnIdx)column_n; - else - table->LeftMostEnabledColumn = (ImGuiTableColumnIdx)column_n; - column->IndexWithinEnabledSet = table->ColumnsEnabledCount++; - table->EnabledMaskByIndex |= (ImU64)1 << column_n; - table->EnabledMaskByDisplayOrder |= (ImU64)1 << column->DisplayOrder; - prev_visible_column_idx = column_n; - IM_ASSERT(column->IndexWithinEnabledSet <= column->DisplayOrder); - - // Calculate ideal/auto column width (that's the width required for all contents to be visible without clipping) - // Combine width from regular rows + width from headers unless requested not to. - if (!column->IsPreserveWidthAuto) - column->WidthAuto = TableGetColumnWidthAuto(table, column); - - // Non-resizable columns keep their requested width (apply user value regardless of IsPreserveWidthAuto) - const bool column_is_resizable = (column->Flags & ImGuiTableColumnFlags_NoResize) == 0; - if (column_is_resizable) - has_resizable = true; - if ((column->Flags & ImGuiTableColumnFlags_WidthFixed) && column->InitStretchWeightOrWidth > 0.0f && !column_is_resizable) - column->WidthAuto = column->InitStretchWeightOrWidth; - - if (column->AutoFitQueue != 0x00) - has_auto_fit_request = true; - if (column->Flags & ImGuiTableColumnFlags_WidthStretch) - { - stretch_sum_width_auto += column->WidthAuto; - count_stretch++; - } - else - { - fixed_max_width_auto = ImMax(fixed_max_width_auto, column->WidthAuto); - count_fixed++; - } - } - if ((table->Flags & ImGuiTableFlags_Sortable) && table->SortSpecsCount == 0 && !(table->Flags & ImGuiTableFlags_SortTristate)) - table->IsSortSpecsDirty = true; - table->RightMostEnabledColumn = (ImGuiTableColumnIdx)prev_visible_column_idx; - IM_ASSERT(table->LeftMostEnabledColumn >= 0 && table->RightMostEnabledColumn >= 0); - - // [Part 2] Disable child window clipping while fitting columns. This is not strictly necessary but makes it possible - // to avoid the column fitting having to wait until the first visible frame of the child container (may or not be a good thing). - // FIXME-TABLE: for always auto-resizing columns may not want to do that all the time. - if (has_auto_fit_request && table->OuterWindow != table->InnerWindow) - table->InnerWindow->SkipItems = false; - if (has_auto_fit_request) - table->IsSettingsDirty = true; - - // [Part 3] Fix column flags and record a few extra information. - float sum_width_requests = 0.0f; // Sum of all width for fixed and auto-resize columns, excluding width contributed by Stretch columns but including spacing/padding. - float stretch_sum_weights = 0.0f; // Sum of all weights for stretch columns. - table->LeftMostStretchedColumn = table->RightMostStretchedColumn = -1; - for (int column_n = 0; column_n < table->ColumnsCount; column_n++) - { - if (!(table->EnabledMaskByIndex & ((ImU64)1 << column_n))) - continue; - ImGuiTableColumn* column = &table->Columns[column_n]; - - const bool column_is_resizable = (column->Flags & ImGuiTableColumnFlags_NoResize) == 0; - if (column->Flags & ImGuiTableColumnFlags_WidthFixed) - { - // Apply same widths policy - float width_auto = column->WidthAuto; - if (table_sizing_policy == ImGuiTableFlags_SizingFixedSame && (column->AutoFitQueue != 0x00 || !column_is_resizable)) - width_auto = fixed_max_width_auto; - - // Apply automatic width - // Latch initial size for fixed columns and update it constantly for auto-resizing column (unless clipped!) - if (column->AutoFitQueue != 0x00) - column->WidthRequest = width_auto; - else if ((column->Flags & ImGuiTableColumnFlags_WidthFixed) && !column_is_resizable && (table->RequestOutputMaskByIndex & ((ImU64)1 << column_n))) - column->WidthRequest = width_auto; - - // FIXME-TABLE: Increase minimum size during init frame to avoid biasing auto-fitting widgets - // (e.g. TextWrapped) too much. Otherwise what tends to happen is that TextWrapped would output a very - // large height (= first frame scrollbar display very off + clipper would skip lots of items). - // This is merely making the side-effect less extreme, but doesn't properly fixes it. - // FIXME: Move this to ->WidthGiven to avoid temporary lossyless? - // FIXME: This break IsPreserveWidthAuto from not flickering if the stored WidthAuto was smaller. - if (column->AutoFitQueue > 0x01 && table->IsInitializing && !column->IsPreserveWidthAuto) - column->WidthRequest = ImMax(column->WidthRequest, table->MinColumnWidth * 4.0f); // FIXME-TABLE: Another constant/scale? - sum_width_requests += column->WidthRequest; - } - else - { - // Initialize stretch weight - if (column->AutoFitQueue != 0x00 || column->StretchWeight < 0.0f || !column_is_resizable) - { - if (column->InitStretchWeightOrWidth > 0.0f) - column->StretchWeight = column->InitStretchWeightOrWidth; - else if (table_sizing_policy == ImGuiTableFlags_SizingStretchProp) - column->StretchWeight = (column->WidthAuto / stretch_sum_width_auto) * count_stretch; - else - column->StretchWeight = 1.0f; - } - - stretch_sum_weights += column->StretchWeight; - if (table->LeftMostStretchedColumn == -1 || table->Columns[table->LeftMostStretchedColumn].DisplayOrder > column->DisplayOrder) - table->LeftMostStretchedColumn = (ImGuiTableColumnIdx)column_n; - if (table->RightMostStretchedColumn == -1 || table->Columns[table->RightMostStretchedColumn].DisplayOrder < column->DisplayOrder) - table->RightMostStretchedColumn = (ImGuiTableColumnIdx)column_n; - } - column->IsPreserveWidthAuto = false; - sum_width_requests += table->CellPaddingX * 2.0f; - } - table->ColumnsEnabledFixedCount = (ImGuiTableColumnIdx)count_fixed; - - // [Part 4] Apply final widths based on requested widths - const ImRect work_rect = table->WorkRect; - const float width_spacings = (table->OuterPaddingX * 2.0f) + (table->CellSpacingX1 + table->CellSpacingX2) * (table->ColumnsEnabledCount - 1); - const float width_avail = ((table->Flags & ImGuiTableFlags_ScrollX) && table->InnerWidth == 0.0f) ? table->InnerClipRect.GetWidth() : work_rect.GetWidth(); - const float width_avail_for_stretched_columns = width_avail - width_spacings - sum_width_requests; - float width_remaining_for_stretched_columns = width_avail_for_stretched_columns; - table->ColumnsGivenWidth = width_spacings + (table->CellPaddingX * 2.0f) * table->ColumnsEnabledCount; - for (int column_n = 0; column_n < table->ColumnsCount; column_n++) - { - if (!(table->EnabledMaskByIndex & ((ImU64)1 << column_n))) - continue; - ImGuiTableColumn* column = &table->Columns[column_n]; - - // Allocate width for stretched/weighted columns (StretchWeight gets converted into WidthRequest) - if (column->Flags & ImGuiTableColumnFlags_WidthStretch) - { - float weight_ratio = column->StretchWeight / stretch_sum_weights; - column->WidthRequest = IM_FLOOR(ImMax(width_avail_for_stretched_columns * weight_ratio, table->MinColumnWidth) + 0.01f); - width_remaining_for_stretched_columns -= column->WidthRequest; - } - - // [Resize Rule 1] The right-most Visible column is not resizable if there is at least one Stretch column - // See additional comments in TableSetColumnWidth(). - if (column->NextEnabledColumn == -1 && table->LeftMostStretchedColumn != -1) - column->Flags |= ImGuiTableColumnFlags_NoDirectResize_; - - // Assign final width, record width in case we will need to shrink - column->WidthGiven = ImFloor(ImMax(column->WidthRequest, table->MinColumnWidth)); - table->ColumnsGivenWidth += column->WidthGiven; - } - - // [Part 5] Redistribute stretch remainder width due to rounding (remainder width is < 1.0f * number of Stretch column). - // Using right-to-left distribution (more likely to match resizing cursor). - if (width_remaining_for_stretched_columns >= 1.0f && !(table->Flags & ImGuiTableFlags_PreciseWidths)) - for (int order_n = table->ColumnsCount - 1; stretch_sum_weights > 0.0f && width_remaining_for_stretched_columns >= 1.0f && order_n >= 0; order_n--) - { - if (!(table->EnabledMaskByDisplayOrder & ((ImU64)1 << order_n))) - continue; - ImGuiTableColumn* column = &table->Columns[table->DisplayOrderToIndex[order_n]]; - if (!(column->Flags & ImGuiTableColumnFlags_WidthStretch)) - continue; - column->WidthRequest += 1.0f; - column->WidthGiven += 1.0f; - width_remaining_for_stretched_columns -= 1.0f; - } - - table->HoveredColumnBody = -1; - table->HoveredColumnBorder = -1; - const ImRect mouse_hit_rect(table->OuterRect.Min.x, table->OuterRect.Min.y, table->OuterRect.Max.x, ImMax(table->OuterRect.Max.y, table->OuterRect.Min.y + table->LastOuterHeight)); - const bool is_hovering_table = ItemHoverable(mouse_hit_rect, 0); - - // [Part 6] Setup final position, offset, skip/clip states and clipping rectangles, detect hovered column - // Process columns in their visible orders as we are comparing the visible order and adjusting host_clip_rect while looping. - int visible_n = 0; - bool offset_x_frozen = (table->FreezeColumnsCount > 0); - float offset_x = ((table->FreezeColumnsCount > 0) ? table->OuterRect.Min.x : work_rect.Min.x) + table->OuterPaddingX - table->CellSpacingX1; - ImRect host_clip_rect = table->InnerClipRect; - //host_clip_rect.Max.x += table->CellPaddingX + table->CellSpacingX2; - table->VisibleMaskByIndex = 0x00; - table->RequestOutputMaskByIndex = 0x00; - for (int order_n = 0; order_n < table->ColumnsCount; order_n++) - { - const int column_n = table->DisplayOrderToIndex[order_n]; - ImGuiTableColumn* column = &table->Columns[column_n]; - - column->NavLayerCurrent = (ImS8)((table->FreezeRowsCount > 0 || column_n < table->FreezeColumnsCount) ? ImGuiNavLayer_Menu : ImGuiNavLayer_Main); - - if (offset_x_frozen && table->FreezeColumnsCount == visible_n) - { - offset_x += work_rect.Min.x - table->OuterRect.Min.x; - offset_x_frozen = false; - } - - // Clear status flags - column->Flags &= ~ImGuiTableColumnFlags_StatusMask_; - - if ((table->EnabledMaskByDisplayOrder & ((ImU64)1 << order_n)) == 0) - { - // Hidden column: clear a few fields and we are done with it for the remainder of the function. - // We set a zero-width clip rect but set Min.y/Max.y properly to not interfere with the clipper. - column->MinX = column->MaxX = column->WorkMinX = column->ClipRect.Min.x = column->ClipRect.Max.x = offset_x; - column->WidthGiven = 0.0f; - column->ClipRect.Min.y = work_rect.Min.y; - column->ClipRect.Max.y = FLT_MAX; - column->ClipRect.ClipWithFull(host_clip_rect); - column->IsVisibleX = column->IsVisibleY = column->IsRequestOutput = false; - column->IsSkipItems = true; - column->ItemWidth = 1.0f; - continue; - } - - // Detect hovered column - if (is_hovering_table && g.IO.MousePos.x >= column->ClipRect.Min.x && g.IO.MousePos.x < column->ClipRect.Max.x) - table->HoveredColumnBody = (ImGuiTableColumnIdx)column_n; - - // Lock start position - column->MinX = offset_x; - - // Lock width based on start position and minimum/maximum width for this position - float max_width = TableGetMaxColumnWidth(table, column_n); - column->WidthGiven = ImMin(column->WidthGiven, max_width); - column->WidthGiven = ImMax(column->WidthGiven, ImMin(column->WidthRequest, table->MinColumnWidth)); - column->MaxX = offset_x + column->WidthGiven + table->CellSpacingX1 + table->CellSpacingX2 + table->CellPaddingX * 2.0f; - - // Lock other positions - // - ClipRect.Min.x: Because merging draw commands doesn't compare min boundaries, we make ClipRect.Min.x match left bounds to be consistent regardless of merging. - // - ClipRect.Max.x: using WorkMaxX instead of MaxX (aka including padding) makes things more consistent when resizing down, tho slightly detrimental to visibility in very-small column. - // - ClipRect.Max.x: using MaxX makes it easier for header to receive hover highlight with no discontinuity and display sorting arrow. - // - FIXME-TABLE: We want equal width columns to have equal (ClipRect.Max.x - WorkMinX) width, which means ClipRect.max.x cannot stray off host_clip_rect.Max.x else right-most column may appear shorter. - column->WorkMinX = column->MinX + table->CellPaddingX + table->CellSpacingX1; - column->WorkMaxX = column->MaxX - table->CellPaddingX - table->CellSpacingX2; // Expected max - column->ItemWidth = ImFloor(column->WidthGiven * 0.65f); - column->ClipRect.Min.x = column->MinX; - column->ClipRect.Min.y = work_rect.Min.y; - column->ClipRect.Max.x = column->MaxX; //column->WorkMaxX; - column->ClipRect.Max.y = FLT_MAX; - column->ClipRect.ClipWithFull(host_clip_rect); - - // Mark column as Clipped (not in sight) - // Note that scrolling tables (where inner_window != outer_window) handle Y clipped earlier in BeginTable() so IsVisibleY really only applies to non-scrolling tables. - // FIXME-TABLE: Because InnerClipRect.Max.y is conservatively ==outer_window->ClipRect.Max.y, we never can mark columns _Above_ the scroll line as not IsVisibleY. - // Taking advantage of LastOuterHeight would yield good results there... - // FIXME-TABLE: Y clipping is disabled because it effectively means not submitting will reduce contents width which is fed to outer_window->DC.CursorMaxPos.x, - // and this may be used (e.g. typically by outer_window using AlwaysAutoResize or outer_window's horizontal scrollbar, but could be something else). - // Possible solution to preserve last known content width for clipped column. Test 'table_reported_size' fails when enabling Y clipping and window is resized small. - column->IsVisibleX = (column->ClipRect.Max.x > column->ClipRect.Min.x); - column->IsVisibleY = true; // (column->ClipRect.Max.y > column->ClipRect.Min.y); - const bool is_visible = column->IsVisibleX; //&& column->IsVisibleY; - if (is_visible) - table->VisibleMaskByIndex |= ((ImU64)1 << column_n); - - // Mark column as requesting output from user. Note that fixed + non-resizable sets are auto-fitting at all times and therefore always request output. - column->IsRequestOutput = is_visible || column->AutoFitQueue != 0 || column->CannotSkipItemsQueue != 0; - if (column->IsRequestOutput) - table->RequestOutputMaskByIndex |= ((ImU64)1 << column_n); - - // Mark column as SkipItems (ignoring all items/layout) - column->IsSkipItems = !column->IsEnabled || table->HostSkipItems; - if (column->IsSkipItems) - IM_ASSERT(!is_visible); - - // Update status flags - column->Flags |= ImGuiTableColumnFlags_IsEnabled; - if (is_visible) - column->Flags |= ImGuiTableColumnFlags_IsVisible; - if (column->SortOrder != -1) - column->Flags |= ImGuiTableColumnFlags_IsSorted; - if (table->HoveredColumnBody == column_n) - column->Flags |= ImGuiTableColumnFlags_IsHovered; - - // Alignment - // FIXME-TABLE: This align based on the whole column width, not per-cell, and therefore isn't useful in - // many cases (to be able to honor this we might be able to store a log of cells width, per row, for - // visible rows, but nav/programmatic scroll would have visible artifacts.) - //if (column->Flags & ImGuiTableColumnFlags_AlignRight) - // column->WorkMinX = ImMax(column->WorkMinX, column->MaxX - column->ContentWidthRowsUnfrozen); - //else if (column->Flags & ImGuiTableColumnFlags_AlignCenter) - // column->WorkMinX = ImLerp(column->WorkMinX, ImMax(column->StartX, column->MaxX - column->ContentWidthRowsUnfrozen), 0.5f); - - // Reset content width variables - column->ContentMaxXFrozen = column->ContentMaxXUnfrozen = column->WorkMinX; - column->ContentMaxXHeadersUsed = column->ContentMaxXHeadersIdeal = column->WorkMinX; - - // Don't decrement auto-fit counters until container window got a chance to submit its items - if (table->HostSkipItems == false) - { - column->AutoFitQueue >>= 1; - column->CannotSkipItemsQueue >>= 1; - } - - if (visible_n < table->FreezeColumnsCount) - host_clip_rect.Min.x = ImClamp(column->MaxX + TABLE_BORDER_SIZE, host_clip_rect.Min.x, host_clip_rect.Max.x); - - offset_x += column->WidthGiven + table->CellSpacingX1 + table->CellSpacingX2 + table->CellPaddingX * 2.0f; - visible_n++; - } - - // [Part 7] Detect/store when we are hovering the unused space after the right-most column (so e.g. context menus can react on it) - // Clear Resizable flag if none of our column are actually resizable (either via an explicit _NoResize flag, either - // because of using _WidthAuto/_WidthStretch). This will hide the resizing option from the context menu. - const float unused_x1 = ImMax(table->WorkRect.Min.x, table->Columns[table->RightMostEnabledColumn].ClipRect.Max.x); - if (is_hovering_table && table->HoveredColumnBody == -1) - { - if (g.IO.MousePos.x >= unused_x1) - table->HoveredColumnBody = (ImGuiTableColumnIdx)table->ColumnsCount; - } - if (has_resizable == false && (table->Flags & ImGuiTableFlags_Resizable)) - table->Flags &= ~ImGuiTableFlags_Resizable; - - // [Part 8] Lock actual OuterRect/WorkRect right-most position. - // This is done late to handle the case of fixed-columns tables not claiming more widths that they need. - // Because of this we are careful with uses of WorkRect and InnerClipRect before this point. - if (table->RightMostStretchedColumn != -1) - table->Flags &= ~ImGuiTableFlags_NoHostExtendX; - if (table->Flags & ImGuiTableFlags_NoHostExtendX) - { - table->OuterRect.Max.x = table->WorkRect.Max.x = unused_x1; - table->InnerClipRect.Max.x = ImMin(table->InnerClipRect.Max.x, unused_x1); - } - table->InnerWindow->ParentWorkRect = table->WorkRect; - table->BorderX1 = table->InnerClipRect.Min.x;// +((table->Flags & ImGuiTableFlags_BordersOuter) ? 0.0f : -1.0f); - table->BorderX2 = table->InnerClipRect.Max.x;// +((table->Flags & ImGuiTableFlags_BordersOuter) ? 0.0f : +1.0f); - - // [Part 9] Allocate draw channels and setup background cliprect - TableSetupDrawChannels(table); - - // [Part 10] Hit testing on borders - if (table->Flags & ImGuiTableFlags_Resizable) - TableUpdateBorders(table); - table->LastFirstRowHeight = 0.0f; - table->IsLayoutLocked = true; - table->IsUsingHeaders = false; - - // [Part 11] Context menu - if (table->IsContextPopupOpen && table->InstanceCurrent == table->InstanceInteracted) - { - const ImGuiID context_menu_id = ImHashStr("##ContextMenu", 0, table->ID); - if (BeginPopupEx(context_menu_id, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings)) - { - TableDrawContextMenu(table); - EndPopup(); - } - else - { - table->IsContextPopupOpen = false; - } - } - - // [Part 13] Sanitize and build sort specs before we have a change to use them for display. - // This path will only be exercised when sort specs are modified before header rows (e.g. init or visibility change) - if (table->IsSortSpecsDirty && (table->Flags & ImGuiTableFlags_Sortable)) - TableSortSpecsBuild(table); - - // Initial state - ImGuiWindow* inner_window = table->InnerWindow; - if (table->Flags & ImGuiTableFlags_NoClip) - table->DrawSplitter->SetCurrentChannel(inner_window->DrawList, TABLE_DRAW_CHANNEL_NOCLIP); - else - inner_window->DrawList->PushClipRect(inner_window->ClipRect.Min, inner_window->ClipRect.Max, false); -} - -// Process hit-testing on resizing borders. Actual size change will be applied in EndTable() -// - Set table->HoveredColumnBorder with a short delay/timer to reduce feedback noise -// - Submit ahead of table contents and header, use ImGuiButtonFlags_AllowItemOverlap to prioritize widgets -// overlapping the same area. -void ImGui::TableUpdateBorders(ImGuiTable* table) -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(table->Flags & ImGuiTableFlags_Resizable); - - // At this point OuterRect height may be zero or under actual final height, so we rely on temporal coherency and - // use the final height from last frame. Because this is only affecting _interaction_ with columns, it is not - // really problematic (whereas the actual visual will be displayed in EndTable() and using the current frame height). - // Actual columns highlight/render will be performed in EndTable() and not be affected. - const float hit_half_width = TABLE_RESIZE_SEPARATOR_HALF_THICKNESS; - const float hit_y1 = table->OuterRect.Min.y; - const float hit_y2_body = ImMax(table->OuterRect.Max.y, hit_y1 + table->LastOuterHeight); - const float hit_y2_head = hit_y1 + table->LastFirstRowHeight; - - for (int order_n = 0; order_n < table->ColumnsCount; order_n++) - { - if (!(table->EnabledMaskByDisplayOrder & ((ImU64)1 << order_n))) - continue; - - const int column_n = table->DisplayOrderToIndex[order_n]; - ImGuiTableColumn* column = &table->Columns[column_n]; - if (column->Flags & (ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_NoDirectResize_)) - continue; - - // ImGuiTableFlags_NoBordersInBodyUntilResize will be honored in TableDrawBorders() - const float border_y2_hit = (table->Flags & ImGuiTableFlags_NoBordersInBody) ? hit_y2_head : hit_y2_body; - if ((table->Flags & ImGuiTableFlags_NoBordersInBody) && table->IsUsingHeaders == false) - continue; - - if (!column->IsVisibleX && table->LastResizedColumn != column_n) - continue; - - ImGuiID column_id = TableGetColumnResizeID(table, column_n, table->InstanceCurrent); - ImRect hit_rect(column->MaxX - hit_half_width, hit_y1, column->MaxX + hit_half_width, border_y2_hit); - //GetForegroundDrawList()->AddRect(hit_rect.Min, hit_rect.Max, IM_COL32(255, 0, 0, 100)); - KeepAliveID(column_id); - - bool hovered = false, held = false; - bool pressed = ButtonBehavior(hit_rect, column_id, &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_AllowItemOverlap | ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_PressedOnDoubleClick | ImGuiButtonFlags_NoNavFocus); - if (pressed && IsMouseDoubleClicked(0)) - { - TableSetColumnWidthAutoSingle(table, column_n); - ClearActiveID(); - held = hovered = false; - } - if (held) - { - if (table->LastResizedColumn == -1) - table->ResizeLockMinContentsX2 = table->RightMostEnabledColumn != -1 ? table->Columns[table->RightMostEnabledColumn].MaxX : -FLT_MAX; - table->ResizedColumn = (ImGuiTableColumnIdx)column_n; - table->InstanceInteracted = table->InstanceCurrent; - } - if ((hovered && g.HoveredIdTimer > TABLE_RESIZE_SEPARATOR_FEEDBACK_TIMER) || held) - { - table->HoveredColumnBorder = (ImGuiTableColumnIdx)column_n; - SetMouseCursor(ImGuiMouseCursor_ResizeEW); - } - } -} - -void ImGui::EndTable() -{ - ImGuiContext& g = *GImGui; - ImGuiTable* table = g.CurrentTable; - IM_ASSERT(table != NULL && "Only call EndTable() if BeginTable() returns true!"); - - // This assert would be very useful to catch a common error... unfortunately it would probably trigger in some - // cases, and for consistency user may sometimes output empty tables (and still benefit from e.g. outer border) - //IM_ASSERT(table->IsLayoutLocked && "Table unused: never called TableNextRow(), is that the intent?"); - - // If the user never got to call TableNextRow() or TableNextColumn(), we call layout ourselves to ensure all our - // code paths are consistent (instead of just hoping that TableBegin/TableEnd will work), get borders drawn, etc. - if (!table->IsLayoutLocked) - TableUpdateLayout(table); - - const ImGuiTableFlags flags = table->Flags; - ImGuiWindow* inner_window = table->InnerWindow; - ImGuiWindow* outer_window = table->OuterWindow; - ImGuiTableTempData* temp_data = table->TempData; - IM_ASSERT(inner_window == g.CurrentWindow); - IM_ASSERT(outer_window == inner_window || outer_window == inner_window->ParentWindow); - - if (table->IsInsideRow) - TableEndRow(table); - - // Context menu in columns body - if (flags & ImGuiTableFlags_ContextMenuInBody) - if (table->HoveredColumnBody != -1 && !IsAnyItemHovered() && IsMouseReleased(ImGuiMouseButton_Right)) - TableOpenContextMenu((int)table->HoveredColumnBody); - - // Finalize table height - inner_window->DC.PrevLineSize = temp_data->HostBackupPrevLineSize; - inner_window->DC.CurrLineSize = temp_data->HostBackupCurrLineSize; - inner_window->DC.CursorMaxPos = temp_data->HostBackupCursorMaxPos; - const float inner_content_max_y = table->RowPosY2; - IM_ASSERT(table->RowPosY2 == inner_window->DC.CursorPos.y); - if (inner_window != outer_window) - inner_window->DC.CursorMaxPos.y = inner_content_max_y; - else if (!(flags & ImGuiTableFlags_NoHostExtendY)) - table->OuterRect.Max.y = table->InnerRect.Max.y = ImMax(table->OuterRect.Max.y, inner_content_max_y); // Patch OuterRect/InnerRect height - table->WorkRect.Max.y = ImMax(table->WorkRect.Max.y, table->OuterRect.Max.y); - table->LastOuterHeight = table->OuterRect.GetHeight(); - - // Setup inner scrolling range - // FIXME: This ideally should be done earlier, in BeginTable() SetNextWindowContentSize call, just like writing to inner_window->DC.CursorMaxPos.y, - // but since the later is likely to be impossible to do we'd rather update both axises together. - if (table->Flags & ImGuiTableFlags_ScrollX) - { - const float outer_padding_for_border = (table->Flags & ImGuiTableFlags_BordersOuterV) ? TABLE_BORDER_SIZE : 0.0f; - float max_pos_x = table->InnerWindow->DC.CursorMaxPos.x; - if (table->RightMostEnabledColumn != -1) - max_pos_x = ImMax(max_pos_x, table->Columns[table->RightMostEnabledColumn].WorkMaxX + table->CellPaddingX + table->OuterPaddingX - outer_padding_for_border); - if (table->ResizedColumn != -1) - max_pos_x = ImMax(max_pos_x, table->ResizeLockMinContentsX2); - table->InnerWindow->DC.CursorMaxPos.x = max_pos_x; - } - - // Pop clipping rect - if (!(flags & ImGuiTableFlags_NoClip)) - inner_window->DrawList->PopClipRect(); - inner_window->ClipRect = inner_window->DrawList->_ClipRectStack.back(); - - // Draw borders - if ((flags & ImGuiTableFlags_Borders) != 0) - TableDrawBorders(table); - -#if 0 - // Strip out dummy channel draw calls - // We have no way to prevent user submitting direct ImDrawList calls into a hidden column (but ImGui:: calls will be clipped out) - // Pros: remove draw calls which will have no effect. since they'll have zero-size cliprect they may be early out anyway. - // Cons: making it harder for users watching metrics/debugger to spot the wasted vertices. - if (table->DummyDrawChannel != (ImGuiTableColumnIdx)-1) - { - ImDrawChannel* dummy_channel = &table->DrawSplitter._Channels[table->DummyDrawChannel]; - dummy_channel->_CmdBuffer.resize(0); - dummy_channel->_IdxBuffer.resize(0); - } -#endif - - // Flatten channels and merge draw calls - ImDrawListSplitter* splitter = table->DrawSplitter; - splitter->SetCurrentChannel(inner_window->DrawList, 0); - if ((table->Flags & ImGuiTableFlags_NoClip) == 0) - TableMergeDrawChannels(table); - splitter->Merge(inner_window->DrawList); - - // Update ColumnsAutoFitWidth to get us ahead for host using our size to auto-resize without waiting for next BeginTable() - const float width_spacings = (table->OuterPaddingX * 2.0f) + (table->CellSpacingX1 + table->CellSpacingX2) * (table->ColumnsEnabledCount - 1); - table->ColumnsAutoFitWidth = width_spacings + (table->CellPaddingX * 2.0f) * table->ColumnsEnabledCount; - for (int column_n = 0; column_n < table->ColumnsCount; column_n++) - if (table->EnabledMaskByIndex & ((ImU64)1 << column_n)) - { - ImGuiTableColumn* column = &table->Columns[column_n]; - if ((column->Flags & ImGuiTableColumnFlags_WidthFixed) && !(column->Flags & ImGuiTableColumnFlags_NoResize)) - table->ColumnsAutoFitWidth += column->WidthRequest; - else - table->ColumnsAutoFitWidth += TableGetColumnWidthAuto(table, column); - } - - // Update scroll - if ((table->Flags & ImGuiTableFlags_ScrollX) == 0 && inner_window != outer_window) - { - inner_window->Scroll.x = 0.0f; - } - else if (table->LastResizedColumn != -1 && table->ResizedColumn == -1 && inner_window->ScrollbarX && table->InstanceInteracted == table->InstanceCurrent) - { - // When releasing a column being resized, scroll to keep the resulting column in sight - const float neighbor_width_to_keep_visible = table->MinColumnWidth + table->CellPaddingX * 2.0f; - ImGuiTableColumn* column = &table->Columns[table->LastResizedColumn]; - if (column->MaxX < table->InnerClipRect.Min.x) - SetScrollFromPosX(inner_window, column->MaxX - inner_window->Pos.x - neighbor_width_to_keep_visible, 1.0f); - else if (column->MaxX > table->InnerClipRect.Max.x) - SetScrollFromPosX(inner_window, column->MaxX - inner_window->Pos.x + neighbor_width_to_keep_visible, 1.0f); - } - - // Apply resizing/dragging at the end of the frame - if (table->ResizedColumn != -1 && table->InstanceCurrent == table->InstanceInteracted) - { - ImGuiTableColumn* column = &table->Columns[table->ResizedColumn]; - const float new_x2 = (g.IO.MousePos.x - g.ActiveIdClickOffset.x + TABLE_RESIZE_SEPARATOR_HALF_THICKNESS); - const float new_width = ImFloor(new_x2 - column->MinX - table->CellSpacingX1 - table->CellPaddingX * 2.0f); - table->ResizedColumnNextWidth = new_width; - } - - // Pop from id stack - IM_ASSERT_USER_ERROR(inner_window->IDStack.back() == table->ID + table->InstanceCurrent, "Mismatching PushID/PopID!"); - IM_ASSERT_USER_ERROR(outer_window->DC.ItemWidthStack.Size >= temp_data->HostBackupItemWidthStackSize, "Too many PopItemWidth!"); - PopID(); - - // Restore window data that we modified - const ImVec2 backup_outer_max_pos = outer_window->DC.CursorMaxPos; - inner_window->WorkRect = temp_data->HostBackupWorkRect; - inner_window->ParentWorkRect = temp_data->HostBackupParentWorkRect; - inner_window->SkipItems = table->HostSkipItems; - outer_window->DC.CursorPos = table->OuterRect.Min; - outer_window->DC.ItemWidth = temp_data->HostBackupItemWidth; - outer_window->DC.ItemWidthStack.Size = temp_data->HostBackupItemWidthStackSize; - outer_window->DC.ColumnsOffset = temp_data->HostBackupColumnsOffset; - - // Layout in outer window - // (FIXME: To allow auto-fit and allow desirable effect of SameLine() we dissociate 'used' vs 'ideal' size by overriding - // CursorPosPrevLine and CursorMaxPos manually. That should be a more general layout feature, see same problem e.g. #3414) - if (inner_window != outer_window) - { - EndChild(); - } - else - { - ItemSize(table->OuterRect.GetSize()); - ItemAdd(table->OuterRect, 0); - } - - // Override declared contents width/height to enable auto-resize while not needlessly adding a scrollbar - if (table->Flags & ImGuiTableFlags_NoHostExtendX) - { - // FIXME-TABLE: Could we remove this section? - // ColumnsAutoFitWidth may be one frame ahead here since for Fixed+NoResize is calculated from latest contents - IM_ASSERT((table->Flags & ImGuiTableFlags_ScrollX) == 0); - outer_window->DC.CursorMaxPos.x = ImMax(backup_outer_max_pos.x, table->OuterRect.Min.x + table->ColumnsAutoFitWidth); - } - else if (temp_data->UserOuterSize.x <= 0.0f) - { - const float decoration_size = (table->Flags & ImGuiTableFlags_ScrollX) ? inner_window->ScrollbarSizes.x : 0.0f; - outer_window->DC.IdealMaxPos.x = ImMax(outer_window->DC.IdealMaxPos.x, table->OuterRect.Min.x + table->ColumnsAutoFitWidth + decoration_size - temp_data->UserOuterSize.x); - outer_window->DC.CursorMaxPos.x = ImMax(backup_outer_max_pos.x, ImMin(table->OuterRect.Max.x, table->OuterRect.Min.x + table->ColumnsAutoFitWidth)); - } - else - { - outer_window->DC.CursorMaxPos.x = ImMax(backup_outer_max_pos.x, table->OuterRect.Max.x); - } - if (temp_data->UserOuterSize.y <= 0.0f) - { - const float decoration_size = (table->Flags & ImGuiTableFlags_ScrollY) ? inner_window->ScrollbarSizes.y : 0.0f; - outer_window->DC.IdealMaxPos.y = ImMax(outer_window->DC.IdealMaxPos.y, inner_content_max_y + decoration_size - temp_data->UserOuterSize.y); - outer_window->DC.CursorMaxPos.y = ImMax(backup_outer_max_pos.y, ImMin(table->OuterRect.Max.y, inner_content_max_y)); - } - else - { - // OuterRect.Max.y may already have been pushed downward from the initial value (unless ImGuiTableFlags_NoHostExtendY is set) - outer_window->DC.CursorMaxPos.y = ImMax(backup_outer_max_pos.y, table->OuterRect.Max.y); - } - - // Save settings - if (table->IsSettingsDirty) - TableSaveSettings(table); - table->IsInitializing = false; - - // Clear or restore current table, if any - IM_ASSERT(g.CurrentWindow == outer_window && g.CurrentTable == table); - IM_ASSERT(g.CurrentTableStackIdx >= 0); - g.CurrentTableStackIdx--; - temp_data = g.CurrentTableStackIdx >= 0 ? &g.TablesTempDataStack[g.CurrentTableStackIdx] : NULL; - g.CurrentTable = temp_data ? g.Tables.GetByIndex(temp_data->TableIndex) : NULL; - if (g.CurrentTable) - { - g.CurrentTable->TempData = temp_data; - g.CurrentTable->DrawSplitter = &temp_data->DrawSplitter; - } - outer_window->DC.CurrentTableIdx = g.CurrentTable ? g.Tables.GetIndex(g.CurrentTable) : -1; -} - -// See "COLUMN SIZING POLICIES" comments at the top of this file -// If (init_width_or_weight <= 0.0f) it is ignored -void ImGui::TableSetupColumn(const char* label, ImGuiTableColumnFlags flags, float init_width_or_weight, ImGuiID user_id) -{ - ImGuiContext& g = *GImGui; - ImGuiTable* table = g.CurrentTable; - IM_ASSERT(table != NULL && "Need to call TableSetupColumn() after BeginTable()!"); - IM_ASSERT(table->IsLayoutLocked == false && "Need to call call TableSetupColumn() before first row!"); - IM_ASSERT((flags & ImGuiTableColumnFlags_StatusMask_) == 0 && "Illegal to pass StatusMask values to TableSetupColumn()"); - if (table->DeclColumnsCount >= table->ColumnsCount) - { - IM_ASSERT_USER_ERROR(table->DeclColumnsCount < table->ColumnsCount, "Called TableSetupColumn() too many times!"); - return; - } - - ImGuiTableColumn* column = &table->Columns[table->DeclColumnsCount]; - table->DeclColumnsCount++; - - // Assert when passing a width or weight if policy is entirely left to default, to avoid storing width into weight and vice-versa. - // Give a grace to users of ImGuiTableFlags_ScrollX. - if (table->IsDefaultSizingPolicy && (flags & ImGuiTableColumnFlags_WidthMask_) == 0 && (flags & ImGuiTableFlags_ScrollX) == 0) - IM_ASSERT(init_width_or_weight <= 0.0f && "Can only specify width/weight if sizing policy is set explicitly in either Table or Column."); - - // When passing a width automatically enforce WidthFixed policy - // (whereas TableSetupColumnFlags would default to WidthAuto if table is not Resizable) - if ((flags & ImGuiTableColumnFlags_WidthMask_) == 0 && init_width_or_weight > 0.0f) - if ((table->Flags & ImGuiTableFlags_SizingMask_) == ImGuiTableFlags_SizingFixedFit || (table->Flags & ImGuiTableFlags_SizingMask_) == ImGuiTableFlags_SizingFixedSame) - flags |= ImGuiTableColumnFlags_WidthFixed; - - TableSetupColumnFlags(table, column, flags); - column->UserID = user_id; - flags = column->Flags; - - // Initialize defaults - column->InitStretchWeightOrWidth = init_width_or_weight; - if (table->IsInitializing) - { - // Init width or weight - if (column->WidthRequest < 0.0f && column->StretchWeight < 0.0f) - { - if ((flags & ImGuiTableColumnFlags_WidthFixed) && init_width_or_weight > 0.0f) - column->WidthRequest = init_width_or_weight; - if (flags & ImGuiTableColumnFlags_WidthStretch) - column->StretchWeight = (init_width_or_weight > 0.0f) ? init_width_or_weight : -1.0f; - - // Disable auto-fit if an explicit width/weight has been specified - if (init_width_or_weight > 0.0f) - column->AutoFitQueue = 0x00; - } - - // Init default visibility/sort state - if ((flags & ImGuiTableColumnFlags_DefaultHide) && (table->SettingsLoadedFlags & ImGuiTableFlags_Hideable) == 0) - column->IsUserEnabled = column->IsUserEnabledNextFrame = false; - if (flags & ImGuiTableColumnFlags_DefaultSort && (table->SettingsLoadedFlags & ImGuiTableFlags_Sortable) == 0) - { - column->SortOrder = 0; // Multiple columns using _DefaultSort will be reassigned unique SortOrder values when building the sort specs. - column->SortDirection = (column->Flags & ImGuiTableColumnFlags_PreferSortDescending) ? (ImS8)ImGuiSortDirection_Descending : (ImU8)(ImGuiSortDirection_Ascending); - } - } - - // Store name (append with zero-terminator in contiguous buffer) - column->NameOffset = -1; - if (label != NULL && label[0] != 0) - { - column->NameOffset = (ImS16)table->ColumnsNames.size(); - table->ColumnsNames.append(label, label + strlen(label) + 1); - } -} - -// [Public] -void ImGui::TableSetupScrollFreeze(int columns, int rows) -{ - ImGuiContext& g = *GImGui; - ImGuiTable* table = g.CurrentTable; - IM_ASSERT(table != NULL && "Need to call TableSetupColumn() after BeginTable()!"); - IM_ASSERT(table->IsLayoutLocked == false && "Need to call TableSetupColumn() before first row!"); - IM_ASSERT(columns >= 0 && columns < IMGUI_TABLE_MAX_COLUMNS); - IM_ASSERT(rows >= 0 && rows < 128); // Arbitrary limit - - table->FreezeColumnsRequest = (table->Flags & ImGuiTableFlags_ScrollX) ? (ImGuiTableColumnIdx)ImMin(columns, table->ColumnsCount) : 0; - table->FreezeColumnsCount = (table->InnerWindow->Scroll.x != 0.0f) ? table->FreezeColumnsRequest : 0; - table->FreezeRowsRequest = (table->Flags & ImGuiTableFlags_ScrollY) ? (ImGuiTableColumnIdx)rows : 0; - table->FreezeRowsCount = (table->InnerWindow->Scroll.y != 0.0f) ? table->FreezeRowsRequest : 0; - table->IsUnfrozenRows = (table->FreezeRowsCount == 0); // Make sure this is set before TableUpdateLayout() so ImGuiListClipper can benefit from it.b - - // Ensure frozen columns are ordered in their section. We still allow multiple frozen columns to be reordered. - // FIXME-TABLE: This work for preserving 2143 into 21|43. How about 4321 turning into 21|43? (preserve relative order in each section) - for (int column_n = 0; column_n < table->FreezeColumnsRequest; column_n++) - { - int order_n = table->DisplayOrderToIndex[column_n]; - if (order_n != column_n && order_n >= table->FreezeColumnsRequest) - { - ImSwap(table->Columns[table->DisplayOrderToIndex[order_n]].DisplayOrder, table->Columns[table->DisplayOrderToIndex[column_n]].DisplayOrder); - ImSwap(table->DisplayOrderToIndex[order_n], table->DisplayOrderToIndex[column_n]); - } - } -} - -//----------------------------------------------------------------------------- -// [SECTION] Tables: Simple accessors -//----------------------------------------------------------------------------- -// - TableGetColumnCount() -// - TableGetColumnName() -// - TableGetColumnName() [Internal] -// - TableSetColumnEnabled() -// - TableGetColumnFlags() -// - TableGetCellBgRect() [Internal] -// - TableGetColumnResizeID() [Internal] -// - TableGetHoveredColumn() [Internal] -// - TableSetBgColor() -//----------------------------------------------------------------------------- - -int ImGui::TableGetColumnCount() -{ - ImGuiContext& g = *GImGui; - ImGuiTable* table = g.CurrentTable; - return table ? table->ColumnsCount : 0; -} - -const char* ImGui::TableGetColumnName(int column_n) -{ - ImGuiContext& g = *GImGui; - ImGuiTable* table = g.CurrentTable; - if (!table) - return NULL; - if (column_n < 0) - column_n = table->CurrentColumn; - return TableGetColumnName(table, column_n); -} - -const char* ImGui::TableGetColumnName(const ImGuiTable* table, int column_n) -{ - if (table->IsLayoutLocked == false && column_n >= table->DeclColumnsCount) - return ""; // NameOffset is invalid at this point - const ImGuiTableColumn* column = &table->Columns[column_n]; - if (column->NameOffset == -1) - return ""; - return &table->ColumnsNames.Buf[column->NameOffset]; -} - -// Change user accessible enabled/disabled state of a column (often perceived as "showing/hiding" from users point of view) -// Note that end-user can use the context menu to change this themselves (right-click in headers, or right-click in columns body with ImGuiTableFlags_ContextMenuInBody) -// - Require table to have the ImGuiTableFlags_Hideable flag because we are manipulating user accessible state. -// - Request will be applied during next layout, which happens on the first call to TableNextRow() after BeginTable(). -// - For the getter you can test (TableGetColumnFlags() & ImGuiTableColumnFlags_IsEnabled) != 0. -// - Alternative: the ImGuiTableColumnFlags_Disabled is an overriding/master disable flag which will also hide the column from context menu. -void ImGui::TableSetColumnEnabled(int column_n, bool enabled) -{ - ImGuiContext& g = *GImGui; - ImGuiTable* table = g.CurrentTable; - IM_ASSERT(table != NULL); - if (!table) - return; - IM_ASSERT(table->Flags & ImGuiTableFlags_Hideable); // See comments above - if (column_n < 0) - column_n = table->CurrentColumn; - IM_ASSERT(column_n >= 0 && column_n < table->ColumnsCount); - ImGuiTableColumn* column = &table->Columns[column_n]; - column->IsUserEnabledNextFrame = enabled; -} - -// We allow querying for an extra column in order to poll the IsHovered state of the right-most section -ImGuiTableColumnFlags ImGui::TableGetColumnFlags(int column_n) -{ - ImGuiContext& g = *GImGui; - ImGuiTable* table = g.CurrentTable; - if (!table) - return ImGuiTableColumnFlags_None; - if (column_n < 0) - column_n = table->CurrentColumn; - if (column_n == table->ColumnsCount) - return (table->HoveredColumnBody == column_n) ? ImGuiTableColumnFlags_IsHovered : ImGuiTableColumnFlags_None; - return table->Columns[column_n].Flags; -} - -// Return the cell rectangle based on currently known height. -// - Important: we generally don't know our row height until the end of the row, so Max.y will be incorrect in many situations. -// The only case where this is correct is if we provided a min_row_height to TableNextRow() and don't go below it. -// - Important: if ImGuiTableFlags_PadOuterX is set but ImGuiTableFlags_PadInnerX is not set, the outer-most left and right -// columns report a small offset so their CellBgRect can extend up to the outer border. -ImRect ImGui::TableGetCellBgRect(const ImGuiTable* table, int column_n) -{ - const ImGuiTableColumn* column = &table->Columns[column_n]; - float x1 = column->MinX; - float x2 = column->MaxX; - if (column->PrevEnabledColumn == -1) - x1 -= table->CellSpacingX1; - if (column->NextEnabledColumn == -1) - x2 += table->CellSpacingX2; - return ImRect(x1, table->RowPosY1, x2, table->RowPosY2); -} - -// Return the resizing ID for the right-side of the given column. -ImGuiID ImGui::TableGetColumnResizeID(const ImGuiTable* table, int column_n, int instance_no) -{ - IM_ASSERT(column_n >= 0 && column_n < table->ColumnsCount); - ImGuiID id = table->ID + 1 + (instance_no * table->ColumnsCount) + column_n; - return id; -} - -// Return -1 when table is not hovered. return columns_count if the unused space at the right of visible columns is hovered. -int ImGui::TableGetHoveredColumn() -{ - ImGuiContext& g = *GImGui; - ImGuiTable* table = g.CurrentTable; - if (!table) - return -1; - return (int)table->HoveredColumnBody; -} - -void ImGui::TableSetBgColor(ImGuiTableBgTarget target, ImU32 color, int column_n) -{ - ImGuiContext& g = *GImGui; - ImGuiTable* table = g.CurrentTable; - IM_ASSERT(target != ImGuiTableBgTarget_None); - - if (color == IM_COL32_DISABLE) - color = 0; - - // We cannot draw neither the cell or row background immediately as we don't know the row height at this point in time. - switch (target) - { - case ImGuiTableBgTarget_CellBg: - { - if (table->RowPosY1 > table->InnerClipRect.Max.y) // Discard - return; - if (column_n == -1) - column_n = table->CurrentColumn; - if ((table->VisibleMaskByIndex & ((ImU64)1 << column_n)) == 0) - return; - if (table->RowCellDataCurrent < 0 || table->RowCellData[table->RowCellDataCurrent].Column != column_n) - table->RowCellDataCurrent++; - ImGuiTableCellData* cell_data = &table->RowCellData[table->RowCellDataCurrent]; - cell_data->BgColor = color; - cell_data->Column = (ImGuiTableColumnIdx)column_n; - break; - } - case ImGuiTableBgTarget_RowBg0: - case ImGuiTableBgTarget_RowBg1: - { - if (table->RowPosY1 > table->InnerClipRect.Max.y) // Discard - return; - IM_ASSERT(column_n == -1); - int bg_idx = (target == ImGuiTableBgTarget_RowBg1) ? 1 : 0; - table->RowBgColor[bg_idx] = color; - break; - } - default: - IM_ASSERT(0); - } -} - -//------------------------------------------------------------------------- -// [SECTION] Tables: Row changes -//------------------------------------------------------------------------- -// - TableGetRowIndex() -// - TableNextRow() -// - TableBeginRow() [Internal] -// - TableEndRow() [Internal] -//------------------------------------------------------------------------- - -// [Public] Note: for row coloring we use ->RowBgColorCounter which is the same value without counting header rows -int ImGui::TableGetRowIndex() -{ - ImGuiContext& g = *GImGui; - ImGuiTable* table = g.CurrentTable; - if (!table) - return 0; - return table->CurrentRow; -} - -// [Public] Starts into the first cell of a new row -void ImGui::TableNextRow(ImGuiTableRowFlags row_flags, float row_min_height) -{ - ImGuiContext& g = *GImGui; - ImGuiTable* table = g.CurrentTable; - - if (!table->IsLayoutLocked) - TableUpdateLayout(table); - if (table->IsInsideRow) - TableEndRow(table); - - table->LastRowFlags = table->RowFlags; - table->RowFlags = row_flags; - table->RowMinHeight = row_min_height; - TableBeginRow(table); - - // We honor min_row_height requested by user, but cannot guarantee per-row maximum height, - // because that would essentially require a unique clipping rectangle per-cell. - table->RowPosY2 += table->CellPaddingY * 2.0f; - table->RowPosY2 = ImMax(table->RowPosY2, table->RowPosY1 + row_min_height); - - // Disable output until user calls TableNextColumn() - table->InnerWindow->SkipItems = true; -} - -// [Internal] Called by TableNextRow() -void ImGui::TableBeginRow(ImGuiTable* table) -{ - ImGuiWindow* window = table->InnerWindow; - IM_ASSERT(!table->IsInsideRow); - - // New row - table->CurrentRow++; - table->CurrentColumn = -1; - table->RowBgColor[0] = table->RowBgColor[1] = IM_COL32_DISABLE; - table->RowCellDataCurrent = -1; - table->IsInsideRow = true; - - // Begin frozen rows - float next_y1 = table->RowPosY2; - if (table->CurrentRow == 0 && table->FreezeRowsCount > 0) - next_y1 = window->DC.CursorPos.y = table->OuterRect.Min.y; - - table->RowPosY1 = table->RowPosY2 = next_y1; - table->RowTextBaseline = 0.0f; - table->RowIndentOffsetX = window->DC.Indent.x - table->HostIndentX; // Lock indent - window->DC.PrevLineTextBaseOffset = 0.0f; - window->DC.CursorMaxPos.y = next_y1; - - // Making the header BG color non-transparent will allow us to overlay it multiple times when handling smooth dragging. - if (table->RowFlags & ImGuiTableRowFlags_Headers) - { - TableSetBgColor(ImGuiTableBgTarget_RowBg0, GetColorU32(ImGuiCol_TableHeaderBg)); - if (table->CurrentRow == 0) - table->IsUsingHeaders = true; - } -} - -// [Internal] Called by TableNextRow() -void ImGui::TableEndRow(ImGuiTable* table) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - IM_ASSERT(window == table->InnerWindow); - IM_ASSERT(table->IsInsideRow); - - if (table->CurrentColumn != -1) - TableEndCell(table); - - // Logging - if (g.LogEnabled) - LogRenderedText(NULL, "|"); - - // Position cursor at the bottom of our row so it can be used for e.g. clipping calculation. However it is - // likely that the next call to TableBeginCell() will reposition the cursor to take account of vertical padding. - window->DC.CursorPos.y = table->RowPosY2; - - // Row background fill - const float bg_y1 = table->RowPosY1; - const float bg_y2 = table->RowPosY2; - const bool unfreeze_rows_actual = (table->CurrentRow + 1 == table->FreezeRowsCount); - const bool unfreeze_rows_request = (table->CurrentRow + 1 == table->FreezeRowsRequest); - if (table->CurrentRow == 0) - table->LastFirstRowHeight = bg_y2 - bg_y1; - - const bool is_visible = (bg_y2 >= table->InnerClipRect.Min.y && bg_y1 <= table->InnerClipRect.Max.y); - if (is_visible) - { - // Decide of background color for the row - ImU32 bg_col0 = 0; - ImU32 bg_col1 = 0; - if (table->RowBgColor[0] != IM_COL32_DISABLE) - bg_col0 = table->RowBgColor[0]; - else if (table->Flags & ImGuiTableFlags_RowBg) - bg_col0 = GetColorU32((table->RowBgColorCounter & 1) ? ImGuiCol_TableRowBgAlt : ImGuiCol_TableRowBg); - if (table->RowBgColor[1] != IM_COL32_DISABLE) - bg_col1 = table->RowBgColor[1]; - - // Decide of top border color - ImU32 border_col = 0; - const float border_size = TABLE_BORDER_SIZE; - if (table->CurrentRow > 0 || table->InnerWindow == table->OuterWindow) - if (table->Flags & ImGuiTableFlags_BordersInnerH) - border_col = (table->LastRowFlags & ImGuiTableRowFlags_Headers) ? table->BorderColorStrong : table->BorderColorLight; - - const bool draw_cell_bg_color = table->RowCellDataCurrent >= 0; - const bool draw_strong_bottom_border = unfreeze_rows_actual; - if ((bg_col0 | bg_col1 | border_col) != 0 || draw_strong_bottom_border || draw_cell_bg_color) - { - // In theory we could call SetWindowClipRectBeforeSetChannel() but since we know TableEndRow() is - // always followed by a change of clipping rectangle we perform the smallest overwrite possible here. - if ((table->Flags & ImGuiTableFlags_NoClip) == 0) - window->DrawList->_CmdHeader.ClipRect = table->Bg0ClipRectForDrawCmd.ToVec4(); - table->DrawSplitter->SetCurrentChannel(window->DrawList, TABLE_DRAW_CHANNEL_BG0); - } - - // Draw row background - // We soft/cpu clip this so all backgrounds and borders can share the same clipping rectangle - if (bg_col0 || bg_col1) - { - ImRect row_rect(table->WorkRect.Min.x, bg_y1, table->WorkRect.Max.x, bg_y2); - row_rect.ClipWith(table->BgClipRect); - if (bg_col0 != 0 && row_rect.Min.y < row_rect.Max.y) - window->DrawList->AddRectFilled(row_rect.Min, row_rect.Max, bg_col0); - if (bg_col1 != 0 && row_rect.Min.y < row_rect.Max.y) - window->DrawList->AddRectFilled(row_rect.Min, row_rect.Max, bg_col1); - } - - // Draw cell background color - if (draw_cell_bg_color) - { - ImGuiTableCellData* cell_data_end = &table->RowCellData[table->RowCellDataCurrent]; - for (ImGuiTableCellData* cell_data = &table->RowCellData[0]; cell_data <= cell_data_end; cell_data++) - { - const ImGuiTableColumn* column = &table->Columns[cell_data->Column]; - ImRect cell_bg_rect = TableGetCellBgRect(table, cell_data->Column); - cell_bg_rect.ClipWith(table->BgClipRect); - cell_bg_rect.Min.x = ImMax(cell_bg_rect.Min.x, column->ClipRect.Min.x); // So that first column after frozen one gets clipped - cell_bg_rect.Max.x = ImMin(cell_bg_rect.Max.x, column->MaxX); - window->DrawList->AddRectFilled(cell_bg_rect.Min, cell_bg_rect.Max, cell_data->BgColor); - } - } - - // Draw top border - if (border_col && bg_y1 >= table->BgClipRect.Min.y && bg_y1 < table->BgClipRect.Max.y) - window->DrawList->AddLine(ImVec2(table->BorderX1, bg_y1), ImVec2(table->BorderX2, bg_y1), border_col, border_size); - - // Draw bottom border at the row unfreezing mark (always strong) - if (draw_strong_bottom_border && bg_y2 >= table->BgClipRect.Min.y && bg_y2 < table->BgClipRect.Max.y) - window->DrawList->AddLine(ImVec2(table->BorderX1, bg_y2), ImVec2(table->BorderX2, bg_y2), table->BorderColorStrong, border_size); - } - - // End frozen rows (when we are past the last frozen row line, teleport cursor and alter clipping rectangle) - // We need to do that in TableEndRow() instead of TableBeginRow() so the list clipper can mark end of row and - // get the new cursor position. - if (unfreeze_rows_request) - for (int column_n = 0; column_n < table->ColumnsCount; column_n++) - { - ImGuiTableColumn* column = &table->Columns[column_n]; - column->NavLayerCurrent = (ImS8)((column_n < table->FreezeColumnsCount) ? ImGuiNavLayer_Menu : ImGuiNavLayer_Main); - } - if (unfreeze_rows_actual) - { - IM_ASSERT(table->IsUnfrozenRows == false); - table->IsUnfrozenRows = true; - - // BgClipRect starts as table->InnerClipRect, reduce it now and make BgClipRectForDrawCmd == BgClipRect - float y0 = ImMax(table->RowPosY2 + 1, window->InnerClipRect.Min.y); - table->BgClipRect.Min.y = table->Bg2ClipRectForDrawCmd.Min.y = ImMin(y0, window->InnerClipRect.Max.y); - table->BgClipRect.Max.y = table->Bg2ClipRectForDrawCmd.Max.y = window->InnerClipRect.Max.y; - table->Bg2DrawChannelCurrent = table->Bg2DrawChannelUnfrozen; - IM_ASSERT(table->Bg2ClipRectForDrawCmd.Min.y <= table->Bg2ClipRectForDrawCmd.Max.y); - - float row_height = table->RowPosY2 - table->RowPosY1; - table->RowPosY2 = window->DC.CursorPos.y = table->WorkRect.Min.y + table->RowPosY2 - table->OuterRect.Min.y; - table->RowPosY1 = table->RowPosY2 - row_height; - for (int column_n = 0; column_n < table->ColumnsCount; column_n++) - { - ImGuiTableColumn* column = &table->Columns[column_n]; - column->DrawChannelCurrent = column->DrawChannelUnfrozen; - column->ClipRect.Min.y = table->Bg2ClipRectForDrawCmd.Min.y; - } - - // Update cliprect ahead of TableBeginCell() so clipper can access to new ClipRect->Min.y - SetWindowClipRectBeforeSetChannel(window, table->Columns[0].ClipRect); - table->DrawSplitter->SetCurrentChannel(window->DrawList, table->Columns[0].DrawChannelCurrent); - } - - if (!(table->RowFlags & ImGuiTableRowFlags_Headers)) - table->RowBgColorCounter++; - table->IsInsideRow = false; -} - -//------------------------------------------------------------------------- -// [SECTION] Tables: Columns changes -//------------------------------------------------------------------------- -// - TableGetColumnIndex() -// - TableSetColumnIndex() -// - TableNextColumn() -// - TableBeginCell() [Internal] -// - TableEndCell() [Internal] -//------------------------------------------------------------------------- - -int ImGui::TableGetColumnIndex() -{ - ImGuiContext& g = *GImGui; - ImGuiTable* table = g.CurrentTable; - if (!table) - return 0; - return table->CurrentColumn; -} - -// [Public] Append into a specific column -bool ImGui::TableSetColumnIndex(int column_n) -{ - ImGuiContext& g = *GImGui; - ImGuiTable* table = g.CurrentTable; - if (!table) - return false; - - if (table->CurrentColumn != column_n) - { - if (table->CurrentColumn != -1) - TableEndCell(table); - IM_ASSERT(column_n >= 0 && table->ColumnsCount); - TableBeginCell(table, column_n); - } - - // Return whether the column is visible. User may choose to skip submitting items based on this return value, - // however they shouldn't skip submitting for columns that may have the tallest contribution to row height. - return (table->RequestOutputMaskByIndex & ((ImU64)1 << column_n)) != 0; -} - -// [Public] Append into the next column, wrap and create a new row when already on last column -bool ImGui::TableNextColumn() -{ - ImGuiContext& g = *GImGui; - ImGuiTable* table = g.CurrentTable; - if (!table) - return false; - - if (table->IsInsideRow && table->CurrentColumn + 1 < table->ColumnsCount) - { - if (table->CurrentColumn != -1) - TableEndCell(table); - TableBeginCell(table, table->CurrentColumn + 1); - } - else - { - TableNextRow(); - TableBeginCell(table, 0); - } - - // Return whether the column is visible. User may choose to skip submitting items based on this return value, - // however they shouldn't skip submitting for columns that may have the tallest contribution to row height. - int column_n = table->CurrentColumn; - return (table->RequestOutputMaskByIndex & ((ImU64)1 << column_n)) != 0; -} - - -// [Internal] Called by TableSetColumnIndex()/TableNextColumn() -// This is called very frequently, so we need to be mindful of unnecessary overhead. -// FIXME-TABLE FIXME-OPT: Could probably shortcut some things for non-active or clipped columns. -void ImGui::TableBeginCell(ImGuiTable* table, int column_n) -{ - ImGuiTableColumn* column = &table->Columns[column_n]; - ImGuiWindow* window = table->InnerWindow; - table->CurrentColumn = column_n; - - // Start position is roughly ~~ CellRect.Min + CellPadding + Indent - float start_x = column->WorkMinX; - if (column->Flags & ImGuiTableColumnFlags_IndentEnable) - start_x += table->RowIndentOffsetX; // ~~ += window.DC.Indent.x - table->HostIndentX, except we locked it for the row. - - window->DC.CursorPos.x = start_x; - window->DC.CursorPos.y = table->RowPosY1 + table->CellPaddingY; - window->DC.CursorMaxPos.x = window->DC.CursorPos.x; - window->DC.ColumnsOffset.x = start_x - window->Pos.x - window->DC.Indent.x; // FIXME-WORKRECT - window->DC.CurrLineTextBaseOffset = table->RowTextBaseline; - window->DC.NavLayerCurrent = (ImGuiNavLayer)column->NavLayerCurrent; - - window->WorkRect.Min.y = window->DC.CursorPos.y; - window->WorkRect.Min.x = column->WorkMinX; - window->WorkRect.Max.x = column->WorkMaxX; - window->DC.ItemWidth = column->ItemWidth; - - // To allow ImGuiListClipper to function we propagate our row height - if (!column->IsEnabled) - window->DC.CursorPos.y = ImMax(window->DC.CursorPos.y, table->RowPosY2); - - window->SkipItems = column->IsSkipItems; - if (column->IsSkipItems) - { - ImGuiContext& g = *GImGui; - g.LastItemData.ID = 0; - g.LastItemData.StatusFlags = 0; - } - - if (table->Flags & ImGuiTableFlags_NoClip) - { - // FIXME: if we end up drawing all borders/bg in EndTable, could remove this and just assert that channel hasn't changed. - table->DrawSplitter->SetCurrentChannel(window->DrawList, TABLE_DRAW_CHANNEL_NOCLIP); - //IM_ASSERT(table->DrawSplitter._Current == TABLE_DRAW_CHANNEL_NOCLIP); - } - else - { - // FIXME-TABLE: Could avoid this if draw channel is dummy channel? - SetWindowClipRectBeforeSetChannel(window, column->ClipRect); - table->DrawSplitter->SetCurrentChannel(window->DrawList, column->DrawChannelCurrent); - } - - // Logging - ImGuiContext& g = *GImGui; - if (g.LogEnabled && !column->IsSkipItems) - { - LogRenderedText(&window->DC.CursorPos, "|"); - g.LogLinePosY = FLT_MAX; - } -} - -// [Internal] Called by TableNextRow()/TableSetColumnIndex()/TableNextColumn() -void ImGui::TableEndCell(ImGuiTable* table) -{ - ImGuiTableColumn* column = &table->Columns[table->CurrentColumn]; - ImGuiWindow* window = table->InnerWindow; - - // Report maximum position so we can infer content size per column. - float* p_max_pos_x; - if (table->RowFlags & ImGuiTableRowFlags_Headers) - p_max_pos_x = &column->ContentMaxXHeadersUsed; // Useful in case user submit contents in header row that is not a TableHeader() call - else - p_max_pos_x = table->IsUnfrozenRows ? &column->ContentMaxXUnfrozen : &column->ContentMaxXFrozen; - *p_max_pos_x = ImMax(*p_max_pos_x, window->DC.CursorMaxPos.x); - table->RowPosY2 = ImMax(table->RowPosY2, window->DC.CursorMaxPos.y + table->CellPaddingY); - column->ItemWidth = window->DC.ItemWidth; - - // Propagate text baseline for the entire row - // FIXME-TABLE: Here we propagate text baseline from the last line of the cell.. instead of the first one. - table->RowTextBaseline = ImMax(table->RowTextBaseline, window->DC.PrevLineTextBaseOffset); -} - -//------------------------------------------------------------------------- -// [SECTION] Tables: Columns width management -//------------------------------------------------------------------------- -// - TableGetMaxColumnWidth() [Internal] -// - TableGetColumnWidthAuto() [Internal] -// - TableSetColumnWidth() -// - TableSetColumnWidthAutoSingle() [Internal] -// - TableSetColumnWidthAutoAll() [Internal] -// - TableUpdateColumnsWeightFromWidth() [Internal] -//------------------------------------------------------------------------- - -// Maximum column content width given current layout. Use column->MinX so this value on a per-column basis. -float ImGui::TableGetMaxColumnWidth(const ImGuiTable* table, int column_n) -{ - const ImGuiTableColumn* column = &table->Columns[column_n]; - float max_width = FLT_MAX; - const float min_column_distance = table->MinColumnWidth + table->CellPaddingX * 2.0f + table->CellSpacingX1 + table->CellSpacingX2; - if (table->Flags & ImGuiTableFlags_ScrollX) - { - // Frozen columns can't reach beyond visible width else scrolling will naturally break. - // (we use DisplayOrder as within a set of multiple frozen column reordering is possible) - if (column->DisplayOrder < table->FreezeColumnsRequest) - { - max_width = (table->InnerClipRect.Max.x - (table->FreezeColumnsRequest - column->DisplayOrder) * min_column_distance) - column->MinX; - max_width = max_width - table->OuterPaddingX - table->CellPaddingX - table->CellSpacingX2; - } - } - else if ((table->Flags & ImGuiTableFlags_NoKeepColumnsVisible) == 0) - { - // If horizontal scrolling if disabled, we apply a final lossless shrinking of columns in order to make - // sure they are all visible. Because of this we also know that all of the columns will always fit in - // table->WorkRect and therefore in table->InnerRect (because ScrollX is off) - // FIXME-TABLE: This is solved incorrectly but also quite a difficult problem to fix as we also want ClipRect width to match. - // See "table_width_distrib" and "table_width_keep_visible" tests - max_width = table->WorkRect.Max.x - (table->ColumnsEnabledCount - column->IndexWithinEnabledSet - 1) * min_column_distance - column->MinX; - //max_width -= table->CellSpacingX1; - max_width -= table->CellSpacingX2; - max_width -= table->CellPaddingX * 2.0f; - max_width -= table->OuterPaddingX; - } - return max_width; -} - -// Note this is meant to be stored in column->WidthAuto, please generally use the WidthAuto field -float ImGui::TableGetColumnWidthAuto(ImGuiTable* table, ImGuiTableColumn* column) -{ - const float content_width_body = ImMax(column->ContentMaxXFrozen, column->ContentMaxXUnfrozen) - column->WorkMinX; - const float content_width_headers = column->ContentMaxXHeadersIdeal - column->WorkMinX; - float width_auto = content_width_body; - if (!(column->Flags & ImGuiTableColumnFlags_NoHeaderWidth)) - width_auto = ImMax(width_auto, content_width_headers); - - // Non-resizable fixed columns preserve their requested width - if ((column->Flags & ImGuiTableColumnFlags_WidthFixed) && column->InitStretchWeightOrWidth > 0.0f) - if (!(table->Flags & ImGuiTableFlags_Resizable) || (column->Flags & ImGuiTableColumnFlags_NoResize)) - width_auto = column->InitStretchWeightOrWidth; - - return ImMax(width_auto, table->MinColumnWidth); -} - -// 'width' = inner column width, without padding -void ImGui::TableSetColumnWidth(int column_n, float width) -{ - ImGuiContext& g = *GImGui; - ImGuiTable* table = g.CurrentTable; - IM_ASSERT(table != NULL && table->IsLayoutLocked == false); - IM_ASSERT(column_n >= 0 && column_n < table->ColumnsCount); - ImGuiTableColumn* column_0 = &table->Columns[column_n]; - float column_0_width = width; - - // Apply constraints early - // Compare both requested and actual given width to avoid overwriting requested width when column is stuck (minimum size, bounded) - IM_ASSERT(table->MinColumnWidth > 0.0f); - const float min_width = table->MinColumnWidth; - const float max_width = ImMax(min_width, TableGetMaxColumnWidth(table, column_n)); - column_0_width = ImClamp(column_0_width, min_width, max_width); - if (column_0->WidthGiven == column_0_width || column_0->WidthRequest == column_0_width) - return; - - //IMGUI_DEBUG_LOG("TableSetColumnWidth(%d, %.1f->%.1f)\n", column_0_idx, column_0->WidthGiven, column_0_width); - ImGuiTableColumn* column_1 = (column_0->NextEnabledColumn != -1) ? &table->Columns[column_0->NextEnabledColumn] : NULL; - - // In this surprisingly not simple because of how we support mixing Fixed and multiple Stretch columns. - // - All fixed: easy. - // - All stretch: easy. - // - One or more fixed + one stretch: easy. - // - One or more fixed + more than one stretch: tricky. - // Qt when manual resize is enabled only support a single _trailing_ stretch column. - - // When forwarding resize from Wn| to Fn+1| we need to be considerate of the _NoResize flag on Fn+1. - // FIXME-TABLE: Find a way to rewrite all of this so interactions feel more consistent for the user. - // Scenarios: - // - F1 F2 F3 resize from F1| or F2| --> ok: alter ->WidthRequested of Fixed column. Subsequent columns will be offset. - // - F1 F2 F3 resize from F3| --> ok: alter ->WidthRequested of Fixed column. If active, ScrollX extent can be altered. - // - F1 F2 W3 resize from F1| or F2| --> ok: alter ->WidthRequested of Fixed column. If active, ScrollX extent can be altered, but it doesn't make much sense as the Stretch column will always be minimal size. - // - F1 F2 W3 resize from W3| --> ok: no-op (disabled by Resize Rule 1) - // - W1 W2 W3 resize from W1| or W2| --> ok - // - W1 W2 W3 resize from W3| --> ok: no-op (disabled by Resize Rule 1) - // - W1 F2 F3 resize from F3| --> ok: no-op (disabled by Resize Rule 1) - // - W1 F2 resize from F2| --> ok: no-op (disabled by Resize Rule 1) - // - W1 W2 F3 resize from W1| or W2| --> ok - // - W1 F2 W3 resize from W1| or F2| --> ok - // - F1 W2 F3 resize from W2| --> ok - // - F1 W3 F2 resize from W3| --> ok - // - W1 F2 F3 resize from W1| --> ok: equivalent to resizing |F2. F3 will not move. - // - W1 F2 F3 resize from F2| --> ok - // All resizes from a Wx columns are locking other columns. - - // Possible improvements: - // - W1 W2 W3 resize W1| --> to not be stuck, both W2 and W3 would stretch down. Seems possible to fix. Would be most beneficial to simplify resize of all-weighted columns. - // - W3 F1 F2 resize W3| --> to not be stuck past F1|, both F1 and F2 would need to stretch down, which would be lossy or ambiguous. Seems hard to fix. - - // [Resize Rule 1] Can't resize from right of right-most visible column if there is any Stretch column. Implemented in TableUpdateLayout(). - - // If we have all Fixed columns OR resizing a Fixed column that doesn't come after a Stretch one, we can do an offsetting resize. - // This is the preferred resize path - if (column_0->Flags & ImGuiTableColumnFlags_WidthFixed) - if (!column_1 || table->LeftMostStretchedColumn == -1 || table->Columns[table->LeftMostStretchedColumn].DisplayOrder >= column_0->DisplayOrder) - { - column_0->WidthRequest = column_0_width; - table->IsSettingsDirty = true; - return; - } - - // We can also use previous column if there's no next one (this is used when doing an auto-fit on the right-most stretch column) - if (column_1 == NULL) - column_1 = (column_0->PrevEnabledColumn != -1) ? &table->Columns[column_0->PrevEnabledColumn] : NULL; - if (column_1 == NULL) - return; - - // Resizing from right-side of a Stretch column before a Fixed column forward sizing to left-side of fixed column. - // (old_a + old_b == new_a + new_b) --> (new_a == old_a + old_b - new_b) - float column_1_width = ImMax(column_1->WidthRequest - (column_0_width - column_0->WidthRequest), min_width); - column_0_width = column_0->WidthRequest + column_1->WidthRequest - column_1_width; - IM_ASSERT(column_0_width > 0.0f && column_1_width > 0.0f); - column_0->WidthRequest = column_0_width; - column_1->WidthRequest = column_1_width; - if ((column_0->Flags | column_1->Flags) & ImGuiTableColumnFlags_WidthStretch) - TableUpdateColumnsWeightFromWidth(table); - table->IsSettingsDirty = true; -} - -// Disable clipping then auto-fit, will take 2 frames -// (we don't take a shortcut for unclipped columns to reduce inconsistencies when e.g. resizing multiple columns) -void ImGui::TableSetColumnWidthAutoSingle(ImGuiTable* table, int column_n) -{ - // Single auto width uses auto-fit - ImGuiTableColumn* column = &table->Columns[column_n]; - if (!column->IsEnabled) - return; - column->CannotSkipItemsQueue = (1 << 0); - table->AutoFitSingleColumn = (ImGuiTableColumnIdx)column_n; -} - -void ImGui::TableSetColumnWidthAutoAll(ImGuiTable* table) -{ - for (int column_n = 0; column_n < table->ColumnsCount; column_n++) - { - ImGuiTableColumn* column = &table->Columns[column_n]; - if (!column->IsEnabled && !(column->Flags & ImGuiTableColumnFlags_WidthStretch)) // Cannot reset weight of hidden stretch column - continue; - column->CannotSkipItemsQueue = (1 << 0); - column->AutoFitQueue = (1 << 1); - } -} - -void ImGui::TableUpdateColumnsWeightFromWidth(ImGuiTable* table) -{ - IM_ASSERT(table->LeftMostStretchedColumn != -1 && table->RightMostStretchedColumn != -1); - - // Measure existing quantity - float visible_weight = 0.0f; - float visible_width = 0.0f; - for (int column_n = 0; column_n < table->ColumnsCount; column_n++) - { - ImGuiTableColumn* column = &table->Columns[column_n]; - if (!column->IsEnabled || !(column->Flags & ImGuiTableColumnFlags_WidthStretch)) - continue; - IM_ASSERT(column->StretchWeight > 0.0f); - visible_weight += column->StretchWeight; - visible_width += column->WidthRequest; - } - IM_ASSERT(visible_weight > 0.0f && visible_width > 0.0f); - - // Apply new weights - for (int column_n = 0; column_n < table->ColumnsCount; column_n++) - { - ImGuiTableColumn* column = &table->Columns[column_n]; - if (!column->IsEnabled || !(column->Flags & ImGuiTableColumnFlags_WidthStretch)) - continue; - column->StretchWeight = (column->WidthRequest / visible_width) * visible_weight; - IM_ASSERT(column->StretchWeight > 0.0f); - } -} - -//------------------------------------------------------------------------- -// [SECTION] Tables: Drawing -//------------------------------------------------------------------------- -// - TablePushBackgroundChannel() [Internal] -// - TablePopBackgroundChannel() [Internal] -// - TableSetupDrawChannels() [Internal] -// - TableMergeDrawChannels() [Internal] -// - TableDrawBorders() [Internal] -//------------------------------------------------------------------------- - -// Bg2 is used by Selectable (and possibly other widgets) to render to the background. -// Unlike our Bg0/1 channel which we uses for RowBg/CellBg/Borders and where we guarantee all shapes to be CPU-clipped, the Bg2 channel being widgets-facing will rely on regular ClipRect. -void ImGui::TablePushBackgroundChannel() -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - ImGuiTable* table = g.CurrentTable; - - // Optimization: avoid SetCurrentChannel() + PushClipRect() - table->HostBackupInnerClipRect = window->ClipRect; - SetWindowClipRectBeforeSetChannel(window, table->Bg2ClipRectForDrawCmd); - table->DrawSplitter->SetCurrentChannel(window->DrawList, table->Bg2DrawChannelCurrent); -} - -void ImGui::TablePopBackgroundChannel() -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - ImGuiTable* table = g.CurrentTable; - ImGuiTableColumn* column = &table->Columns[table->CurrentColumn]; - - // Optimization: avoid PopClipRect() + SetCurrentChannel() - SetWindowClipRectBeforeSetChannel(window, table->HostBackupInnerClipRect); - table->DrawSplitter->SetCurrentChannel(window->DrawList, column->DrawChannelCurrent); -} - -// Allocate draw channels. Called by TableUpdateLayout() -// - We allocate them following storage order instead of display order so reordering columns won't needlessly -// increase overall dormant memory cost. -// - We isolate headers draw commands in their own channels instead of just altering clip rects. -// This is in order to facilitate merging of draw commands. -// - After crossing FreezeRowsCount, all columns see their current draw channel changed to a second set of channels. -// - We only use the dummy draw channel so we can push a null clipping rectangle into it without affecting other -// channels, while simplifying per-row/per-cell overhead. It will be empty and discarded when merged. -// - We allocate 1 or 2 background draw channels. This is because we know TablePushBackgroundChannel() is only used for -// horizontal spanning. If we allowed vertical spanning we'd need one background draw channel per merge group (1-4). -// Draw channel allocation (before merging): -// - NoClip --> 2+D+1 channels: bg0/1 + bg2 + foreground (same clip rect == always 1 draw call) -// - Clip --> 2+D+N channels -// - FreezeRows --> 2+D+N*2 (unless scrolling value is zero) -// - FreezeRows || FreezeColunns --> 3+D+N*2 (unless scrolling value is zero) -// Where D is 1 if any column is clipped or hidden (dummy channel) otherwise 0. -void ImGui::TableSetupDrawChannels(ImGuiTable* table) -{ - const int freeze_row_multiplier = (table->FreezeRowsCount > 0) ? 2 : 1; - const int channels_for_row = (table->Flags & ImGuiTableFlags_NoClip) ? 1 : table->ColumnsEnabledCount; - const int channels_for_bg = 1 + 1 * freeze_row_multiplier; - const int channels_for_dummy = (table->ColumnsEnabledCount < table->ColumnsCount || table->VisibleMaskByIndex != table->EnabledMaskByIndex) ? +1 : 0; - const int channels_total = channels_for_bg + (channels_for_row * freeze_row_multiplier) + channels_for_dummy; - table->DrawSplitter->Split(table->InnerWindow->DrawList, channels_total); - table->DummyDrawChannel = (ImGuiTableDrawChannelIdx)((channels_for_dummy > 0) ? channels_total - 1 : -1); - table->Bg2DrawChannelCurrent = TABLE_DRAW_CHANNEL_BG2_FROZEN; - table->Bg2DrawChannelUnfrozen = (ImGuiTableDrawChannelIdx)((table->FreezeRowsCount > 0) ? 2 + channels_for_row : TABLE_DRAW_CHANNEL_BG2_FROZEN); - - int draw_channel_current = 2; - for (int column_n = 0; column_n < table->ColumnsCount; column_n++) - { - ImGuiTableColumn* column = &table->Columns[column_n]; - if (column->IsVisibleX && column->IsVisibleY) - { - column->DrawChannelFrozen = (ImGuiTableDrawChannelIdx)(draw_channel_current); - column->DrawChannelUnfrozen = (ImGuiTableDrawChannelIdx)(draw_channel_current + (table->FreezeRowsCount > 0 ? channels_for_row + 1 : 0)); - if (!(table->Flags & ImGuiTableFlags_NoClip)) - draw_channel_current++; - } - else - { - column->DrawChannelFrozen = column->DrawChannelUnfrozen = table->DummyDrawChannel; - } - column->DrawChannelCurrent = column->DrawChannelFrozen; - } - - // Initial draw cmd starts with a BgClipRect that matches the one of its host, to facilitate merge draw commands by default. - // All our cell highlight are manually clipped with BgClipRect. When unfreezing it will be made smaller to fit scrolling rect. - // (This technically isn't part of setting up draw channels, but is reasonably related to be done here) - table->BgClipRect = table->InnerClipRect; - table->Bg0ClipRectForDrawCmd = table->OuterWindow->ClipRect; - table->Bg2ClipRectForDrawCmd = table->HostClipRect; - IM_ASSERT(table->BgClipRect.Min.y <= table->BgClipRect.Max.y); -} - -// This function reorder draw channels based on matching clip rectangle, to facilitate merging them. Called by EndTable(). -// For simplicity we call it TableMergeDrawChannels() but in fact it only reorder channels + overwrite ClipRect, -// actual merging is done by table->DrawSplitter.Merge() which is called right after TableMergeDrawChannels(). -// -// Columns where the contents didn't stray off their local clip rectangle can be merged. To achieve -// this we merge their clip rect and make them contiguous in the channel list, so they can be merged -// by the call to DrawSplitter.Merge() following to the call to this function. -// We reorder draw commands by arranging them into a maximum of 4 distinct groups: -// -// 1 group: 2 groups: 2 groups: 4 groups: -// [ 0. ] no freeze [ 0. ] row freeze [ 01 ] col freeze [ 01 ] row+col freeze -// [ .. ] or no scroll [ 2. ] and v-scroll [ .. ] and h-scroll [ 23 ] and v+h-scroll -// -// Each column itself can use 1 channel (row freeze disabled) or 2 channels (row freeze enabled). -// When the contents of a column didn't stray off its limit, we move its channels into the corresponding group -// based on its position (within frozen rows/columns groups or not). -// At the end of the operation our 1-4 groups will each have a ImDrawCmd using the same ClipRect. -// This function assume that each column are pointing to a distinct draw channel, -// otherwise merge_group->ChannelsCount will not match set bit count of merge_group->ChannelsMask. -// -// Column channels will not be merged into one of the 1-4 groups in the following cases: -// - The contents stray off its clipping rectangle (we only compare the MaxX value, not the MinX value). -// Direct ImDrawList calls won't be taken into account by default, if you use them make sure the ImGui:: bounds -// matches, by e.g. calling SetCursorScreenPos(). -// - The channel uses more than one draw command itself. We drop all our attempt at merging stuff here.. -// we could do better but it's going to be rare and probably not worth the hassle. -// Columns for which the draw channel(s) haven't been merged with other will use their own ImDrawCmd. -// -// This function is particularly tricky to understand.. take a breath. -void ImGui::TableMergeDrawChannels(ImGuiTable* table) -{ - ImGuiContext& g = *GImGui; - ImDrawListSplitter* splitter = table->DrawSplitter; - const bool has_freeze_v = (table->FreezeRowsCount > 0); - const bool has_freeze_h = (table->FreezeColumnsCount > 0); - IM_ASSERT(splitter->_Current == 0); - - // Track which groups we are going to attempt to merge, and which channels goes into each group. - struct MergeGroup - { - ImRect ClipRect; - int ChannelsCount; - ImBitArray ChannelsMask; - - MergeGroup() { ChannelsCount = 0; } - }; - int merge_group_mask = 0x00; - MergeGroup merge_groups[4]; - - // 1. Scan channels and take note of those which can be merged - for (int column_n = 0; column_n < table->ColumnsCount; column_n++) - { - if ((table->VisibleMaskByIndex & ((ImU64)1 << column_n)) == 0) - continue; - ImGuiTableColumn* column = &table->Columns[column_n]; - - const int merge_group_sub_count = has_freeze_v ? 2 : 1; - for (int merge_group_sub_n = 0; merge_group_sub_n < merge_group_sub_count; merge_group_sub_n++) - { - const int channel_no = (merge_group_sub_n == 0) ? column->DrawChannelFrozen : column->DrawChannelUnfrozen; - - // Don't attempt to merge if there are multiple draw calls within the column - ImDrawChannel* src_channel = &splitter->_Channels[channel_no]; - if (src_channel->_CmdBuffer.Size > 0 && src_channel->_CmdBuffer.back().ElemCount == 0) - src_channel->_CmdBuffer.pop_back(); - if (src_channel->_CmdBuffer.Size != 1) - continue; - - // Find out the width of this merge group and check if it will fit in our column - // (note that we assume that rendering didn't stray on the left direction. we should need a CursorMinPos to detect it) - if (!(column->Flags & ImGuiTableColumnFlags_NoClip)) - { - float content_max_x; - if (!has_freeze_v) - content_max_x = ImMax(column->ContentMaxXUnfrozen, column->ContentMaxXHeadersUsed); // No row freeze - else if (merge_group_sub_n == 0) - content_max_x = ImMax(column->ContentMaxXFrozen, column->ContentMaxXHeadersUsed); // Row freeze: use width before freeze - else - content_max_x = column->ContentMaxXUnfrozen; // Row freeze: use width after freeze - if (content_max_x > column->ClipRect.Max.x) - continue; - } - - const int merge_group_n = (has_freeze_h && column_n < table->FreezeColumnsCount ? 0 : 1) + (has_freeze_v && merge_group_sub_n == 0 ? 0 : 2); - IM_ASSERT(channel_no < IMGUI_TABLE_MAX_DRAW_CHANNELS); - MergeGroup* merge_group = &merge_groups[merge_group_n]; - if (merge_group->ChannelsCount == 0) - merge_group->ClipRect = ImRect(+FLT_MAX, +FLT_MAX, -FLT_MAX, -FLT_MAX); - merge_group->ChannelsMask.SetBit(channel_no); - merge_group->ChannelsCount++; - merge_group->ClipRect.Add(src_channel->_CmdBuffer[0].ClipRect); - merge_group_mask |= (1 << merge_group_n); - } - - // Invalidate current draw channel - // (we don't clear DrawChannelFrozen/DrawChannelUnfrozen solely to facilitate debugging/later inspection of data) - column->DrawChannelCurrent = (ImGuiTableDrawChannelIdx)-1; - } - - // [DEBUG] Display merge groups -#if 0 - if (g.IO.KeyShift) - for (int merge_group_n = 0; merge_group_n < IM_ARRAYSIZE(merge_groups); merge_group_n++) - { - MergeGroup* merge_group = &merge_groups[merge_group_n]; - if (merge_group->ChannelsCount == 0) - continue; - char buf[32]; - ImFormatString(buf, 32, "MG%d:%d", merge_group_n, merge_group->ChannelsCount); - ImVec2 text_pos = merge_group->ClipRect.Min + ImVec2(4, 4); - ImVec2 text_size = CalcTextSize(buf, NULL); - GetForegroundDrawList()->AddRectFilled(text_pos, text_pos + text_size, IM_COL32(0, 0, 0, 255)); - GetForegroundDrawList()->AddText(text_pos, IM_COL32(255, 255, 0, 255), buf, NULL); - GetForegroundDrawList()->AddRect(merge_group->ClipRect.Min, merge_group->ClipRect.Max, IM_COL32(255, 255, 0, 255)); - } -#endif - - // 2. Rewrite channel list in our preferred order - if (merge_group_mask != 0) - { - // We skip channel 0 (Bg0/Bg1) and 1 (Bg2 frozen) from the shuffling since they won't move - see channels allocation in TableSetupDrawChannels(). - const int LEADING_DRAW_CHANNELS = 2; - g.DrawChannelsTempMergeBuffer.resize(splitter->_Count - LEADING_DRAW_CHANNELS); // Use shared temporary storage so the allocation gets amortized - ImDrawChannel* dst_tmp = g.DrawChannelsTempMergeBuffer.Data; - ImBitArray remaining_mask; // We need 132-bit of storage - remaining_mask.SetBitRange(LEADING_DRAW_CHANNELS, splitter->_Count); - remaining_mask.ClearBit(table->Bg2DrawChannelUnfrozen); - IM_ASSERT(has_freeze_v == false || table->Bg2DrawChannelUnfrozen != TABLE_DRAW_CHANNEL_BG2_FROZEN); - int remaining_count = splitter->_Count - (has_freeze_v ? LEADING_DRAW_CHANNELS + 1 : LEADING_DRAW_CHANNELS); - //ImRect host_rect = (table->InnerWindow == table->OuterWindow) ? table->InnerClipRect : table->HostClipRect; - ImRect host_rect = table->HostClipRect; - for (int merge_group_n = 0; merge_group_n < IM_ARRAYSIZE(merge_groups); merge_group_n++) - { - if (int merge_channels_count = merge_groups[merge_group_n].ChannelsCount) - { - MergeGroup* merge_group = &merge_groups[merge_group_n]; - ImRect merge_clip_rect = merge_group->ClipRect; - - // Extend outer-most clip limits to match those of host, so draw calls can be merged even if - // outer-most columns have some outer padding offsetting them from their parent ClipRect. - // The principal cases this is dealing with are: - // - On a same-window table (not scrolling = single group), all fitting columns ClipRect -> will extend and match host ClipRect -> will merge - // - Columns can use padding and have left-most ClipRect.Min.x and right-most ClipRect.Max.x != from host ClipRect -> will extend and match host ClipRect -> will merge - // FIXME-TABLE FIXME-WORKRECT: We are wasting a merge opportunity on tables without scrolling if column doesn't fit - // within host clip rect, solely because of the half-padding difference between window->WorkRect and window->InnerClipRect. - if ((merge_group_n & 1) == 0 || !has_freeze_h) - merge_clip_rect.Min.x = ImMin(merge_clip_rect.Min.x, host_rect.Min.x); - if ((merge_group_n & 2) == 0 || !has_freeze_v) - merge_clip_rect.Min.y = ImMin(merge_clip_rect.Min.y, host_rect.Min.y); - if ((merge_group_n & 1) != 0) - merge_clip_rect.Max.x = ImMax(merge_clip_rect.Max.x, host_rect.Max.x); - if ((merge_group_n & 2) != 0 && (table->Flags & ImGuiTableFlags_NoHostExtendY) == 0) - merge_clip_rect.Max.y = ImMax(merge_clip_rect.Max.y, host_rect.Max.y); -#if 0 - GetOverlayDrawList()->AddRect(merge_group->ClipRect.Min, merge_group->ClipRect.Max, IM_COL32(255, 0, 0, 200), 0.0f, 0, 1.0f); - GetOverlayDrawList()->AddLine(merge_group->ClipRect.Min, merge_clip_rect.Min, IM_COL32(255, 100, 0, 200)); - GetOverlayDrawList()->AddLine(merge_group->ClipRect.Max, merge_clip_rect.Max, IM_COL32(255, 100, 0, 200)); -#endif - remaining_count -= merge_group->ChannelsCount; - for (int n = 0; n < IM_ARRAYSIZE(remaining_mask.Storage); n++) - remaining_mask.Storage[n] &= ~merge_group->ChannelsMask.Storage[n]; - for (int n = 0; n < splitter->_Count && merge_channels_count != 0; n++) - { - // Copy + overwrite new clip rect - if (!merge_group->ChannelsMask.TestBit(n)) - continue; - merge_group->ChannelsMask.ClearBit(n); - merge_channels_count--; - - ImDrawChannel* channel = &splitter->_Channels[n]; - IM_ASSERT(channel->_CmdBuffer.Size == 1 && merge_clip_rect.Contains(ImRect(channel->_CmdBuffer[0].ClipRect))); - channel->_CmdBuffer[0].ClipRect = merge_clip_rect.ToVec4(); - memcpy(dst_tmp++, channel, sizeof(ImDrawChannel)); - } - } - - // Make sure Bg2DrawChannelUnfrozen appears in the middle of our groups (whereas Bg0/Bg1 and Bg2 frozen are fixed to 0 and 1) - if (merge_group_n == 1 && has_freeze_v) - memcpy(dst_tmp++, &splitter->_Channels[table->Bg2DrawChannelUnfrozen], sizeof(ImDrawChannel)); - } - - // Append unmergeable channels that we didn't reorder at the end of the list - for (int n = 0; n < splitter->_Count && remaining_count != 0; n++) - { - if (!remaining_mask.TestBit(n)) - continue; - ImDrawChannel* channel = &splitter->_Channels[n]; - memcpy(dst_tmp++, channel, sizeof(ImDrawChannel)); - remaining_count--; - } - IM_ASSERT(dst_tmp == g.DrawChannelsTempMergeBuffer.Data + g.DrawChannelsTempMergeBuffer.Size); - memcpy(splitter->_Channels.Data + LEADING_DRAW_CHANNELS, g.DrawChannelsTempMergeBuffer.Data, (splitter->_Count - LEADING_DRAW_CHANNELS) * sizeof(ImDrawChannel)); - } -} - -// FIXME-TABLE: This is a mess, need to redesign how we render borders (as some are also done in TableEndRow) -void ImGui::TableDrawBorders(ImGuiTable* table) -{ - ImGuiWindow* inner_window = table->InnerWindow; - if (!table->OuterWindow->ClipRect.Overlaps(table->OuterRect)) - return; - - ImDrawList* inner_drawlist = inner_window->DrawList; - table->DrawSplitter->SetCurrentChannel(inner_drawlist, TABLE_DRAW_CHANNEL_BG0); - inner_drawlist->PushClipRect(table->Bg0ClipRectForDrawCmd.Min, table->Bg0ClipRectForDrawCmd.Max, false); - - // Draw inner border and resizing feedback - const float border_size = TABLE_BORDER_SIZE; - const float draw_y1 = table->InnerRect.Min.y; - const float draw_y2_body = table->InnerRect.Max.y; - const float draw_y2_head = table->IsUsingHeaders ? ImMin(table->InnerRect.Max.y, (table->FreezeRowsCount >= 1 ? table->InnerRect.Min.y : table->WorkRect.Min.y) + table->LastFirstRowHeight) : draw_y1; - if (table->Flags & ImGuiTableFlags_BordersInnerV) - { - for (int order_n = 0; order_n < table->ColumnsCount; order_n++) - { - if (!(table->EnabledMaskByDisplayOrder & ((ImU64)1 << order_n))) - continue; - - const int column_n = table->DisplayOrderToIndex[order_n]; - ImGuiTableColumn* column = &table->Columns[column_n]; - const bool is_hovered = (table->HoveredColumnBorder == column_n); - const bool is_resized = (table->ResizedColumn == column_n) && (table->InstanceInteracted == table->InstanceCurrent); - const bool is_resizable = (column->Flags & (ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_NoDirectResize_)) == 0; - const bool is_frozen_separator = (table->FreezeColumnsCount == order_n + 1); - if (column->MaxX > table->InnerClipRect.Max.x && !is_resized) - continue; - - // Decide whether right-most column is visible - if (column->NextEnabledColumn == -1 && !is_resizable) - if ((table->Flags & ImGuiTableFlags_SizingMask_) != ImGuiTableFlags_SizingFixedSame || (table->Flags & ImGuiTableFlags_NoHostExtendX)) - continue; - if (column->MaxX <= column->ClipRect.Min.x) // FIXME-TABLE FIXME-STYLE: Assume BorderSize==1, this is problematic if we want to increase the border size.. - continue; - - // Draw in outer window so right-most column won't be clipped - // Always draw full height border when being resized/hovered, or on the delimitation of frozen column scrolling. - ImU32 col; - float draw_y2; - if (is_hovered || is_resized || is_frozen_separator) - { - draw_y2 = draw_y2_body; - col = is_resized ? GetColorU32(ImGuiCol_SeparatorActive) : is_hovered ? GetColorU32(ImGuiCol_SeparatorHovered) : table->BorderColorStrong; - } - else - { - draw_y2 = (table->Flags & (ImGuiTableFlags_NoBordersInBody | ImGuiTableFlags_NoBordersInBodyUntilResize)) ? draw_y2_head : draw_y2_body; - col = (table->Flags & (ImGuiTableFlags_NoBordersInBody | ImGuiTableFlags_NoBordersInBodyUntilResize)) ? table->BorderColorStrong : table->BorderColorLight; - } - - if (draw_y2 > draw_y1) - inner_drawlist->AddLine(ImVec2(column->MaxX, draw_y1), ImVec2(column->MaxX, draw_y2), col, border_size); - } - } - - // Draw outer border - // FIXME: could use AddRect or explicit VLine/HLine helper? - if (table->Flags & ImGuiTableFlags_BordersOuter) - { - // Display outer border offset by 1 which is a simple way to display it without adding an extra draw call - // (Without the offset, in outer_window it would be rendered behind cells, because child windows are above their - // parent. In inner_window, it won't reach out over scrollbars. Another weird solution would be to display part - // of it in inner window, and the part that's over scrollbars in the outer window..) - // Either solution currently won't allow us to use a larger border size: the border would clipped. - const ImRect outer_border = table->OuterRect; - const ImU32 outer_col = table->BorderColorStrong; - if ((table->Flags & ImGuiTableFlags_BordersOuter) == ImGuiTableFlags_BordersOuter) - { - inner_drawlist->AddRect(outer_border.Min, outer_border.Max, outer_col, 0.0f, 0, border_size); - } - else if (table->Flags & ImGuiTableFlags_BordersOuterV) - { - inner_drawlist->AddLine(outer_border.Min, ImVec2(outer_border.Min.x, outer_border.Max.y), outer_col, border_size); - inner_drawlist->AddLine(ImVec2(outer_border.Max.x, outer_border.Min.y), outer_border.Max, outer_col, border_size); - } - else if (table->Flags & ImGuiTableFlags_BordersOuterH) - { - inner_drawlist->AddLine(outer_border.Min, ImVec2(outer_border.Max.x, outer_border.Min.y), outer_col, border_size); - inner_drawlist->AddLine(ImVec2(outer_border.Min.x, outer_border.Max.y), outer_border.Max, outer_col, border_size); - } - } - if ((table->Flags & ImGuiTableFlags_BordersInnerH) && table->RowPosY2 < table->OuterRect.Max.y) - { - // Draw bottom-most row border - const float border_y = table->RowPosY2; - if (border_y >= table->BgClipRect.Min.y && border_y < table->BgClipRect.Max.y) - inner_drawlist->AddLine(ImVec2(table->BorderX1, border_y), ImVec2(table->BorderX2, border_y), table->BorderColorLight, border_size); - } - - inner_drawlist->PopClipRect(); -} - -//------------------------------------------------------------------------- -// [SECTION] Tables: Sorting -//------------------------------------------------------------------------- -// - TableGetSortSpecs() -// - TableFixColumnSortDirection() [Internal] -// - TableGetColumnNextSortDirection() [Internal] -// - TableSetColumnSortDirection() [Internal] -// - TableSortSpecsSanitize() [Internal] -// - TableSortSpecsBuild() [Internal] -//------------------------------------------------------------------------- - -// Return NULL if no sort specs (most often when ImGuiTableFlags_Sortable is not set) -// You can sort your data again when 'SpecsChanged == true'. It will be true with sorting specs have changed since -// last call, or the first time. -// Lifetime: don't hold on this pointer over multiple frames or past any subsequent call to BeginTable()! -ImGuiTableSortSpecs* ImGui::TableGetSortSpecs() -{ - ImGuiContext& g = *GImGui; - ImGuiTable* table = g.CurrentTable; - IM_ASSERT(table != NULL); - - if (!(table->Flags & ImGuiTableFlags_Sortable)) - return NULL; - - // Require layout (in case TableHeadersRow() hasn't been called) as it may alter IsSortSpecsDirty in some paths. - if (!table->IsLayoutLocked) - TableUpdateLayout(table); - - TableSortSpecsBuild(table); - - return &table->SortSpecs; -} - -static inline ImGuiSortDirection TableGetColumnAvailSortDirection(ImGuiTableColumn* column, int n) -{ - IM_ASSERT(n < column->SortDirectionsAvailCount); - return (column->SortDirectionsAvailList >> (n << 1)) & 0x03; -} - -// Fix sort direction if currently set on a value which is unavailable (e.g. activating NoSortAscending/NoSortDescending) -void ImGui::TableFixColumnSortDirection(ImGuiTable* table, ImGuiTableColumn* column) -{ - if (column->SortOrder == -1 || (column->SortDirectionsAvailMask & (1 << column->SortDirection)) != 0) - return; - column->SortDirection = (ImU8)TableGetColumnAvailSortDirection(column, 0); - table->IsSortSpecsDirty = true; -} - -// Calculate next sort direction that would be set after clicking the column -// - If the PreferSortDescending flag is set, we will default to a Descending direction on the first click. -// - Note that the PreferSortAscending flag is never checked, it is essentially the default and therefore a no-op. -IM_STATIC_ASSERT(ImGuiSortDirection_None == 0 && ImGuiSortDirection_Ascending == 1 && ImGuiSortDirection_Descending == 2); -ImGuiSortDirection ImGui::TableGetColumnNextSortDirection(ImGuiTableColumn* column) -{ - IM_ASSERT(column->SortDirectionsAvailCount > 0); - if (column->SortOrder == -1) - return TableGetColumnAvailSortDirection(column, 0); - for (int n = 0; n < 3; n++) - if (column->SortDirection == TableGetColumnAvailSortDirection(column, n)) - return TableGetColumnAvailSortDirection(column, (n + 1) % column->SortDirectionsAvailCount); - IM_ASSERT(0); - return ImGuiSortDirection_None; -} - -// Note that the NoSortAscending/NoSortDescending flags are processed in TableSortSpecsSanitize(), and they may change/revert -// the value of SortDirection. We could technically also do it here but it would be unnecessary and duplicate code. -void ImGui::TableSetColumnSortDirection(int column_n, ImGuiSortDirection sort_direction, bool append_to_sort_specs) -{ - ImGuiContext& g = *GImGui; - ImGuiTable* table = g.CurrentTable; - - if (!(table->Flags & ImGuiTableFlags_SortMulti)) - append_to_sort_specs = false; - if (!(table->Flags & ImGuiTableFlags_SortTristate)) - IM_ASSERT(sort_direction != ImGuiSortDirection_None); - - ImGuiTableColumnIdx sort_order_max = 0; - if (append_to_sort_specs) - for (int other_column_n = 0; other_column_n < table->ColumnsCount; other_column_n++) - sort_order_max = ImMax(sort_order_max, table->Columns[other_column_n].SortOrder); - - ImGuiTableColumn* column = &table->Columns[column_n]; - column->SortDirection = (ImU8)sort_direction; - if (column->SortDirection == ImGuiSortDirection_None) - column->SortOrder = -1; - else if (column->SortOrder == -1 || !append_to_sort_specs) - column->SortOrder = append_to_sort_specs ? sort_order_max + 1 : 0; - - for (int other_column_n = 0; other_column_n < table->ColumnsCount; other_column_n++) - { - ImGuiTableColumn* other_column = &table->Columns[other_column_n]; - if (other_column != column && !append_to_sort_specs) - other_column->SortOrder = -1; - TableFixColumnSortDirection(table, other_column); - } - table->IsSettingsDirty = true; - table->IsSortSpecsDirty = true; -} - -void ImGui::TableSortSpecsSanitize(ImGuiTable* table) -{ - IM_ASSERT(table->Flags & ImGuiTableFlags_Sortable); - - // Clear SortOrder from hidden column and verify that there's no gap or duplicate. - int sort_order_count = 0; - ImU64 sort_order_mask = 0x00; - for (int column_n = 0; column_n < table->ColumnsCount; column_n++) - { - ImGuiTableColumn* column = &table->Columns[column_n]; - if (column->SortOrder != -1 && !column->IsEnabled) - column->SortOrder = -1; - if (column->SortOrder == -1) - continue; - sort_order_count++; - sort_order_mask |= ((ImU64)1 << column->SortOrder); - IM_ASSERT(sort_order_count < (int)sizeof(sort_order_mask) * 8); - } - - const bool need_fix_linearize = ((ImU64)1 << sort_order_count) != (sort_order_mask + 1); - const bool need_fix_single_sort_order = (sort_order_count > 1) && !(table->Flags & ImGuiTableFlags_SortMulti); - if (need_fix_linearize || need_fix_single_sort_order) - { - ImU64 fixed_mask = 0x00; - for (int sort_n = 0; sort_n < sort_order_count; sort_n++) - { - // Fix: Rewrite sort order fields if needed so they have no gap or duplicate. - // (e.g. SortOrder 0 disappeared, SortOrder 1..2 exists --> rewrite then as SortOrder 0..1) - int column_with_smallest_sort_order = -1; - for (int column_n = 0; column_n < table->ColumnsCount; column_n++) - if ((fixed_mask & ((ImU64)1 << (ImU64)column_n)) == 0 && table->Columns[column_n].SortOrder != -1) - if (column_with_smallest_sort_order == -1 || table->Columns[column_n].SortOrder < table->Columns[column_with_smallest_sort_order].SortOrder) - column_with_smallest_sort_order = column_n; - IM_ASSERT(column_with_smallest_sort_order != -1); - fixed_mask |= ((ImU64)1 << column_with_smallest_sort_order); - table->Columns[column_with_smallest_sort_order].SortOrder = (ImGuiTableColumnIdx)sort_n; - - // Fix: Make sure only one column has a SortOrder if ImGuiTableFlags_MultiSortable is not set. - if (need_fix_single_sort_order) - { - sort_order_count = 1; - for (int column_n = 0; column_n < table->ColumnsCount; column_n++) - if (column_n != column_with_smallest_sort_order) - table->Columns[column_n].SortOrder = -1; - break; - } - } - } - - // Fallback default sort order (if no column had the ImGuiTableColumnFlags_DefaultSort flag) - if (sort_order_count == 0 && !(table->Flags & ImGuiTableFlags_SortTristate)) - for (int column_n = 0; column_n < table->ColumnsCount; column_n++) - { - ImGuiTableColumn* column = &table->Columns[column_n]; - if (column->IsEnabled && !(column->Flags & ImGuiTableColumnFlags_NoSort)) - { - sort_order_count = 1; - column->SortOrder = 0; - column->SortDirection = (ImU8)TableGetColumnAvailSortDirection(column, 0); - break; - } - } - - table->SortSpecsCount = (ImGuiTableColumnIdx)sort_order_count; -} - -void ImGui::TableSortSpecsBuild(ImGuiTable* table) -{ - bool dirty = table->IsSortSpecsDirty; - if (dirty) - { - TableSortSpecsSanitize(table); - table->SortSpecsMulti.resize(table->SortSpecsCount <= 1 ? 0 : table->SortSpecsCount); - table->SortSpecs.SpecsDirty = true; // Mark as dirty for user - table->IsSortSpecsDirty = false; // Mark as not dirty for us - } - - // Write output - ImGuiTableColumnSortSpecs* sort_specs = (table->SortSpecsCount == 0) ? NULL : (table->SortSpecsCount == 1) ? &table->SortSpecsSingle : table->SortSpecsMulti.Data; - if (dirty && sort_specs != NULL) - for (int column_n = 0; column_n < table->ColumnsCount; column_n++) - { - ImGuiTableColumn* column = &table->Columns[column_n]; - if (column->SortOrder == -1) - continue; - IM_ASSERT(column->SortOrder < table->SortSpecsCount); - ImGuiTableColumnSortSpecs* sort_spec = &sort_specs[column->SortOrder]; - sort_spec->ColumnUserID = column->UserID; - sort_spec->ColumnIndex = (ImGuiTableColumnIdx)column_n; - sort_spec->SortOrder = (ImGuiTableColumnIdx)column->SortOrder; - sort_spec->SortDirection = column->SortDirection; - } - - table->SortSpecs.Specs = sort_specs; - table->SortSpecs.SpecsCount = table->SortSpecsCount; -} - -//------------------------------------------------------------------------- -// [SECTION] Tables: Headers -//------------------------------------------------------------------------- -// - TableGetHeaderRowHeight() [Internal] -// - TableHeadersRow() -// - TableHeader() -//------------------------------------------------------------------------- - -float ImGui::TableGetHeaderRowHeight() -{ - // Caring for a minor edge case: - // Calculate row height, for the unlikely case that some labels may be taller than others. - // If we didn't do that, uneven header height would highlight but smaller one before the tallest wouldn't catch input for all height. - // In your custom header row you may omit this all together and just call TableNextRow() without a height... - float row_height = GetTextLineHeight(); - int columns_count = TableGetColumnCount(); - for (int column_n = 0; column_n < columns_count; column_n++) - { - ImGuiTableColumnFlags flags = TableGetColumnFlags(column_n); - if ((flags & ImGuiTableColumnFlags_IsEnabled) && !(flags & ImGuiTableColumnFlags_NoHeaderLabel)) - row_height = ImMax(row_height, CalcTextSize(TableGetColumnName(column_n)).y); - } - row_height += GetStyle().CellPadding.y * 2.0f; - return row_height; -} - -// [Public] This is a helper to output TableHeader() calls based on the column names declared in TableSetupColumn(). -// The intent is that advanced users willing to create customized headers would not need to use this helper -// and can create their own! For example: TableHeader() may be preceeded by Checkbox() or other custom widgets. -// See 'Demo->Tables->Custom headers' for a demonstration of implementing a custom version of this. -// This code is constructed to not make much use of internal functions, as it is intended to be a template to copy. -// FIXME-TABLE: TableOpenContextMenu() and TableGetHeaderRowHeight() are not public. -void ImGui::TableHeadersRow() -{ - ImGuiContext& g = *GImGui; - ImGuiTable* table = g.CurrentTable; - IM_ASSERT(table != NULL && "Need to call TableHeadersRow() after BeginTable()!"); - - // Layout if not already done (this is automatically done by TableNextRow, we do it here solely to facilitate stepping in debugger as it is frequent to step in TableUpdateLayout) - if (!table->IsLayoutLocked) - TableUpdateLayout(table); - - // Open row - const float row_y1 = GetCursorScreenPos().y; - const float row_height = TableGetHeaderRowHeight(); - TableNextRow(ImGuiTableRowFlags_Headers, row_height); - if (table->HostSkipItems) // Merely an optimization, you may skip in your own code. - return; - - const int columns_count = TableGetColumnCount(); - for (int column_n = 0; column_n < columns_count; column_n++) - { - if (!TableSetColumnIndex(column_n)) - continue; - - // Push an id to allow unnamed labels (generally accidental, but let's behave nicely with them) - // - in your own code you may omit the PushID/PopID all-together, provided you know they won't collide - // - table->InstanceCurrent is only >0 when we use multiple BeginTable/EndTable calls with same identifier. - const char* name = (TableGetColumnFlags(column_n) & ImGuiTableColumnFlags_NoHeaderLabel) ? "" : TableGetColumnName(column_n); - PushID(table->InstanceCurrent * table->ColumnsCount + column_n); - TableHeader(name); - PopID(); - } - - // Allow opening popup from the right-most section after the last column. - ImVec2 mouse_pos = ImGui::GetMousePos(); - if (IsMouseReleased(1) && TableGetHoveredColumn() == columns_count) - if (mouse_pos.y >= row_y1 && mouse_pos.y < row_y1 + row_height) - TableOpenContextMenu(-1); // Will open a non-column-specific popup. -} - -// Emit a column header (text + optional sort order) -// We cpu-clip text here so that all columns headers can be merged into a same draw call. -// Note that because of how we cpu-clip and display sorting indicators, you _cannot_ use SameLine() after a TableHeader() -void ImGui::TableHeader(const char* label) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - if (window->SkipItems) - return; - - ImGuiTable* table = g.CurrentTable; - IM_ASSERT(table != NULL && "Need to call TableHeader() after BeginTable()!"); - IM_ASSERT(table->CurrentColumn != -1); - const int column_n = table->CurrentColumn; - ImGuiTableColumn* column = &table->Columns[column_n]; - - // Label - if (label == NULL) - label = ""; - const char* label_end = FindRenderedTextEnd(label); - ImVec2 label_size = CalcTextSize(label, label_end, true); - ImVec2 label_pos = window->DC.CursorPos; - - // If we already got a row height, there's use that. - // FIXME-TABLE: Padding problem if the correct outer-padding CellBgRect strays off our ClipRect? - ImRect cell_r = TableGetCellBgRect(table, column_n); - float label_height = ImMax(label_size.y, table->RowMinHeight - table->CellPaddingY * 2.0f); - - // Calculate ideal size for sort order arrow - float w_arrow = 0.0f; - float w_sort_text = 0.0f; - char sort_order_suf[4] = ""; - const float ARROW_SCALE = 0.65f; - if ((table->Flags & ImGuiTableFlags_Sortable) && !(column->Flags & ImGuiTableColumnFlags_NoSort)) - { - w_arrow = ImFloor(g.FontSize * ARROW_SCALE + g.Style.FramePadding.x); - if (column->SortOrder > 0) - { - ImFormatString(sort_order_suf, IM_ARRAYSIZE(sort_order_suf), "%d", column->SortOrder + 1); - w_sort_text = g.Style.ItemInnerSpacing.x + CalcTextSize(sort_order_suf).x; - } - } - - // We feed our unclipped width to the column without writing on CursorMaxPos, so that column is still considering for merging. - float max_pos_x = label_pos.x + label_size.x + w_sort_text + w_arrow; - column->ContentMaxXHeadersUsed = ImMax(column->ContentMaxXHeadersUsed, column->WorkMaxX); - column->ContentMaxXHeadersIdeal = ImMax(column->ContentMaxXHeadersIdeal, max_pos_x); - - // Keep header highlighted when context menu is open. - const bool selected = (table->IsContextPopupOpen && table->ContextPopupColumn == column_n && table->InstanceInteracted == table->InstanceCurrent); - ImGuiID id = window->GetID(label); - ImRect bb(cell_r.Min.x, cell_r.Min.y, cell_r.Max.x, ImMax(cell_r.Max.y, cell_r.Min.y + label_height + g.Style.CellPadding.y * 2.0f)); - ItemSize(ImVec2(0.0f, label_height)); // Don't declare unclipped width, it'll be fed ContentMaxPosHeadersIdeal - if (!ItemAdd(bb, id)) - return; - - //GetForegroundDrawList()->AddRect(cell_r.Min, cell_r.Max, IM_COL32(255, 0, 0, 255)); // [DEBUG] - //GetForegroundDrawList()->AddRect(bb.Min, bb.Max, IM_COL32(255, 0, 0, 255)); // [DEBUG] - - // Using AllowItemOverlap mode because we cover the whole cell, and we want user to be able to submit subsequent items. - bool hovered, held; - bool pressed = ButtonBehavior(bb, id, &hovered, &held, ImGuiButtonFlags_AllowItemOverlap); - if (g.ActiveId != id) - SetItemAllowOverlap(); - if (held || hovered || selected) - { - const ImU32 col = GetColorU32(held ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header); - //RenderFrame(bb.Min, bb.Max, col, false, 0.0f); - TableSetBgColor(ImGuiTableBgTarget_CellBg, col, table->CurrentColumn); - } - else - { - // Submit single cell bg color in the case we didn't submit a full header row - if ((table->RowFlags & ImGuiTableRowFlags_Headers) == 0) - TableSetBgColor(ImGuiTableBgTarget_CellBg, GetColorU32(ImGuiCol_TableHeaderBg), table->CurrentColumn); - } - RenderNavHighlight(bb, id, ImGuiNavHighlightFlags_TypeThin | ImGuiNavHighlightFlags_NoRounding); - if (held) - table->HeldHeaderColumn = (ImGuiTableColumnIdx)column_n; - window->DC.CursorPos.y -= g.Style.ItemSpacing.y * 0.5f; - - // Drag and drop to re-order columns. - // FIXME-TABLE: Scroll request while reordering a column and it lands out of the scrolling zone. - if (held && (table->Flags & ImGuiTableFlags_Reorderable) && IsMouseDragging(0) && !g.DragDropActive) - { - // While moving a column it will jump on the other side of the mouse, so we also test for MouseDelta.x - table->ReorderColumn = (ImGuiTableColumnIdx)column_n; - table->InstanceInteracted = table->InstanceCurrent; - - // We don't reorder: through the frozen<>unfrozen line, or through a column that is marked with ImGuiTableColumnFlags_NoReorder. - if (g.IO.MouseDelta.x < 0.0f && g.IO.MousePos.x < cell_r.Min.x) - if (ImGuiTableColumn* prev_column = (column->PrevEnabledColumn != -1) ? &table->Columns[column->PrevEnabledColumn] : NULL) - if (!((column->Flags | prev_column->Flags) & ImGuiTableColumnFlags_NoReorder)) - if ((column->IndexWithinEnabledSet < table->FreezeColumnsRequest) == (prev_column->IndexWithinEnabledSet < table->FreezeColumnsRequest)) - table->ReorderColumnDir = -1; - if (g.IO.MouseDelta.x > 0.0f && g.IO.MousePos.x > cell_r.Max.x) - if (ImGuiTableColumn* next_column = (column->NextEnabledColumn != -1) ? &table->Columns[column->NextEnabledColumn] : NULL) - if (!((column->Flags | next_column->Flags) & ImGuiTableColumnFlags_NoReorder)) - if ((column->IndexWithinEnabledSet < table->FreezeColumnsRequest) == (next_column->IndexWithinEnabledSet < table->FreezeColumnsRequest)) - table->ReorderColumnDir = +1; - } - - // Sort order arrow - const float ellipsis_max = cell_r.Max.x - w_arrow - w_sort_text; - if ((table->Flags & ImGuiTableFlags_Sortable) && !(column->Flags & ImGuiTableColumnFlags_NoSort)) - { - if (column->SortOrder != -1) - { - float x = ImMax(cell_r.Min.x, cell_r.Max.x - w_arrow - w_sort_text); - float y = label_pos.y; - if (column->SortOrder > 0) - { - PushStyleColor(ImGuiCol_Text, GetColorU32(ImGuiCol_Text, 0.70f)); - RenderText(ImVec2(x + g.Style.ItemInnerSpacing.x, y), sort_order_suf); - PopStyleColor(); - x += w_sort_text; - } - RenderArrow(window->DrawList, ImVec2(x, y), GetColorU32(ImGuiCol_Text), column->SortDirection == ImGuiSortDirection_Ascending ? ImGuiDir_Up : ImGuiDir_Down, ARROW_SCALE); - } - - // Handle clicking on column header to adjust Sort Order - if (pressed && table->ReorderColumn != column_n) - { - ImGuiSortDirection sort_direction = TableGetColumnNextSortDirection(column); - TableSetColumnSortDirection(column_n, sort_direction, g.IO.KeyShift); - } - } - - // Render clipped label. Clipping here ensure that in the majority of situations, all our header cells will - // be merged into a single draw call. - //window->DrawList->AddCircleFilled(ImVec2(ellipsis_max, label_pos.y), 40, IM_COL32_WHITE); - RenderTextEllipsis(window->DrawList, label_pos, ImVec2(ellipsis_max, label_pos.y + label_height + g.Style.FramePadding.y), ellipsis_max, ellipsis_max, label, label_end, &label_size); - - const bool text_clipped = label_size.x > (ellipsis_max - label_pos.x); - if (text_clipped && hovered && g.HoveredIdNotActiveTimer > g.TooltipSlowDelay) - SetTooltip("%.*s", (int)(label_end - label), label); - - // We don't use BeginPopupContextItem() because we want the popup to stay up even after the column is hidden - if (IsMouseReleased(1) && IsItemHovered()) - TableOpenContextMenu(column_n); -} - -//------------------------------------------------------------------------- -// [SECTION] Tables: Context Menu -//------------------------------------------------------------------------- -// - TableOpenContextMenu() [Internal] -// - TableDrawContextMenu() [Internal] -//------------------------------------------------------------------------- - -// Use -1 to open menu not specific to a given column. -void ImGui::TableOpenContextMenu(int column_n) -{ - ImGuiContext& g = *GImGui; - ImGuiTable* table = g.CurrentTable; - if (column_n == -1 && table->CurrentColumn != -1) // When called within a column automatically use this one (for consistency) - column_n = table->CurrentColumn; - if (column_n == table->ColumnsCount) // To facilitate using with TableGetHoveredColumn() - column_n = -1; - IM_ASSERT(column_n >= -1 && column_n < table->ColumnsCount); - if (table->Flags & (ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable)) - { - table->IsContextPopupOpen = true; - table->ContextPopupColumn = (ImGuiTableColumnIdx)column_n; - table->InstanceInteracted = table->InstanceCurrent; - const ImGuiID context_menu_id = ImHashStr("##ContextMenu", 0, table->ID); - OpenPopupEx(context_menu_id, ImGuiPopupFlags_None); - } -} - -// Output context menu into current window (generally a popup) -// FIXME-TABLE: Ideally this should be writable by the user. Full programmatic access to that data? -void ImGui::TableDrawContextMenu(ImGuiTable* table) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - if (window->SkipItems) - return; - - bool want_separator = false; - const int column_n = (table->ContextPopupColumn >= 0 && table->ContextPopupColumn < table->ColumnsCount) ? table->ContextPopupColumn : -1; - ImGuiTableColumn* column = (column_n != -1) ? &table->Columns[column_n] : NULL; - - // Sizing - if (table->Flags & ImGuiTableFlags_Resizable) - { - if (column != NULL) - { - const bool can_resize = !(column->Flags & ImGuiTableColumnFlags_NoResize) && column->IsEnabled; - if (MenuItem("Size column to fit###SizeOne", NULL, false, can_resize)) - TableSetColumnWidthAutoSingle(table, column_n); - } - - const char* size_all_desc; - if (table->ColumnsEnabledFixedCount == table->ColumnsEnabledCount && (table->Flags & ImGuiTableFlags_SizingMask_) != ImGuiTableFlags_SizingFixedSame) - size_all_desc = "Size all columns to fit###SizeAll"; // All fixed - else - size_all_desc = "Size all columns to default###SizeAll"; // All stretch or mixed - if (MenuItem(size_all_desc, NULL)) - TableSetColumnWidthAutoAll(table); - want_separator = true; - } - - // Ordering - if (table->Flags & ImGuiTableFlags_Reorderable) - { - if (MenuItem("Reset order", NULL, false, !table->IsDefaultDisplayOrder)) - table->IsResetDisplayOrderRequest = true; - want_separator = true; - } - - // Reset all (should work but seems unnecessary/noisy to expose?) - //if (MenuItem("Reset all")) - // table->IsResetAllRequest = true; - - // Sorting - // (modify TableOpenContextMenu() to add _Sortable flag if enabling this) -#if 0 - if ((table->Flags & ImGuiTableFlags_Sortable) && column != NULL && (column->Flags & ImGuiTableColumnFlags_NoSort) == 0) - { - if (want_separator) - Separator(); - want_separator = true; - - bool append_to_sort_specs = g.IO.KeyShift; - if (MenuItem("Sort in Ascending Order", NULL, column->SortOrder != -1 && column->SortDirection == ImGuiSortDirection_Ascending, (column->Flags & ImGuiTableColumnFlags_NoSortAscending) == 0)) - TableSetColumnSortDirection(table, column_n, ImGuiSortDirection_Ascending, append_to_sort_specs); - if (MenuItem("Sort in Descending Order", NULL, column->SortOrder != -1 && column->SortDirection == ImGuiSortDirection_Descending, (column->Flags & ImGuiTableColumnFlags_NoSortDescending) == 0)) - TableSetColumnSortDirection(table, column_n, ImGuiSortDirection_Descending, append_to_sort_specs); - } -#endif - - // Hiding / Visibility - if (table->Flags & ImGuiTableFlags_Hideable) - { - if (want_separator) - Separator(); - want_separator = true; - - PushItemFlag(ImGuiItemFlags_SelectableDontClosePopup, true); - for (int other_column_n = 0; other_column_n < table->ColumnsCount; other_column_n++) - { - ImGuiTableColumn* other_column = &table->Columns[other_column_n]; - if (other_column->Flags & ImGuiTableColumnFlags_Disabled) - continue; - - const char* name = TableGetColumnName(table, other_column_n); - if (name == NULL || name[0] == 0) - name = ""; - - // Make sure we can't hide the last active column - bool menu_item_active = (other_column->Flags & ImGuiTableColumnFlags_NoHide) ? false : true; - if (other_column->IsUserEnabled && table->ColumnsEnabledCount <= 1) - menu_item_active = false; - if (MenuItem(name, NULL, other_column->IsUserEnabled, menu_item_active)) - other_column->IsUserEnabledNextFrame = !other_column->IsUserEnabled; - } - PopItemFlag(); - } -} - -//------------------------------------------------------------------------- -// [SECTION] Tables: Settings (.ini data) -//------------------------------------------------------------------------- -// FIXME: The binding/finding/creating flow are too confusing. -//------------------------------------------------------------------------- -// - TableSettingsInit() [Internal] -// - TableSettingsCalcChunkSize() [Internal] -// - TableSettingsCreate() [Internal] -// - TableSettingsFindByID() [Internal] -// - TableGetBoundSettings() [Internal] -// - TableResetSettings() -// - TableSaveSettings() [Internal] -// - TableLoadSettings() [Internal] -// - TableSettingsHandler_ClearAll() [Internal] -// - TableSettingsHandler_ApplyAll() [Internal] -// - TableSettingsHandler_ReadOpen() [Internal] -// - TableSettingsHandler_ReadLine() [Internal] -// - TableSettingsHandler_WriteAll() [Internal] -// - TableSettingsInstallHandler() [Internal] -//------------------------------------------------------------------------- -// [Init] 1: TableSettingsHandler_ReadXXXX() Load and parse .ini file into TableSettings. -// [Main] 2: TableLoadSettings() When table is created, bind Table to TableSettings, serialize TableSettings data into Table. -// [Main] 3: TableSaveSettings() When table properties are modified, serialize Table data into bound or new TableSettings, mark .ini as dirty. -// [Main] 4: TableSettingsHandler_WriteAll() When .ini file is dirty (which can come from other source), save TableSettings into .ini file. -//------------------------------------------------------------------------- - -// Clear and initialize empty settings instance -static void TableSettingsInit(ImGuiTableSettings* settings, ImGuiID id, int columns_count, int columns_count_max) -{ - IM_PLACEMENT_NEW(settings) ImGuiTableSettings(); - ImGuiTableColumnSettings* settings_column = settings->GetColumnSettings(); - for (int n = 0; n < columns_count_max; n++, settings_column++) - IM_PLACEMENT_NEW(settings_column) ImGuiTableColumnSettings(); - settings->ID = id; - settings->ColumnsCount = (ImGuiTableColumnIdx)columns_count; - settings->ColumnsCountMax = (ImGuiTableColumnIdx)columns_count_max; - settings->WantApply = true; -} - -static size_t TableSettingsCalcChunkSize(int columns_count) -{ - return sizeof(ImGuiTableSettings) + (size_t)columns_count * sizeof(ImGuiTableColumnSettings); -} - -ImGuiTableSettings* ImGui::TableSettingsCreate(ImGuiID id, int columns_count) -{ - ImGuiContext& g = *GImGui; - ImGuiTableSettings* settings = g.SettingsTables.alloc_chunk(TableSettingsCalcChunkSize(columns_count)); - TableSettingsInit(settings, id, columns_count, columns_count); - return settings; -} - -// Find existing settings -ImGuiTableSettings* ImGui::TableSettingsFindByID(ImGuiID id) -{ - // FIXME-OPT: Might want to store a lookup map for this? - ImGuiContext& g = *GImGui; - for (ImGuiTableSettings* settings = g.SettingsTables.begin(); settings != NULL; settings = g.SettingsTables.next_chunk(settings)) - if (settings->ID == id) - return settings; - return NULL; -} - -// Get settings for a given table, NULL if none -ImGuiTableSettings* ImGui::TableGetBoundSettings(ImGuiTable* table) -{ - if (table->SettingsOffset != -1) - { - ImGuiContext& g = *GImGui; - ImGuiTableSettings* settings = g.SettingsTables.ptr_from_offset(table->SettingsOffset); - IM_ASSERT(settings->ID == table->ID); - if (settings->ColumnsCountMax >= table->ColumnsCount) - return settings; // OK - settings->ID = 0; // Invalidate storage, we won't fit because of a count change - } - return NULL; -} - -// Restore initial state of table (with or without saved settings) -void ImGui::TableResetSettings(ImGuiTable* table) -{ - table->IsInitializing = table->IsSettingsDirty = true; - table->IsResetAllRequest = false; - table->IsSettingsRequestLoad = false; // Don't reload from ini - table->SettingsLoadedFlags = ImGuiTableFlags_None; // Mark as nothing loaded so our initialized data becomes authoritative -} - -void ImGui::TableSaveSettings(ImGuiTable* table) -{ - table->IsSettingsDirty = false; - if (table->Flags & ImGuiTableFlags_NoSavedSettings) - return; - - // Bind or create settings data - ImGuiContext& g = *GImGui; - ImGuiTableSettings* settings = TableGetBoundSettings(table); - if (settings == NULL) - { - settings = TableSettingsCreate(table->ID, table->ColumnsCount); - table->SettingsOffset = g.SettingsTables.offset_from_ptr(settings); - } - settings->ColumnsCount = (ImGuiTableColumnIdx)table->ColumnsCount; - - // Serialize ImGuiTable/ImGuiTableColumn into ImGuiTableSettings/ImGuiTableColumnSettings - IM_ASSERT(settings->ID == table->ID); - IM_ASSERT(settings->ColumnsCount == table->ColumnsCount && settings->ColumnsCountMax >= settings->ColumnsCount); - ImGuiTableColumn* column = table->Columns.Data; - ImGuiTableColumnSettings* column_settings = settings->GetColumnSettings(); - - bool save_ref_scale = false; - settings->SaveFlags = ImGuiTableFlags_None; - for (int n = 0; n < table->ColumnsCount; n++, column++, column_settings++) - { - const float width_or_weight = (column->Flags & ImGuiTableColumnFlags_WidthStretch) ? column->StretchWeight : column->WidthRequest; - column_settings->WidthOrWeight = width_or_weight; - column_settings->Index = (ImGuiTableColumnIdx)n; - column_settings->DisplayOrder = column->DisplayOrder; - column_settings->SortOrder = column->SortOrder; - column_settings->SortDirection = column->SortDirection; - column_settings->IsEnabled = column->IsUserEnabled; - column_settings->IsStretch = (column->Flags & ImGuiTableColumnFlags_WidthStretch) ? 1 : 0; - if ((column->Flags & ImGuiTableColumnFlags_WidthStretch) == 0) - save_ref_scale = true; - - // We skip saving some data in the .ini file when they are unnecessary to restore our state. - // Note that fixed width where initial width was derived from auto-fit will always be saved as InitStretchWeightOrWidth will be 0.0f. - // FIXME-TABLE: We don't have logic to easily compare SortOrder to DefaultSortOrder yet so it's always saved when present. - if (width_or_weight != column->InitStretchWeightOrWidth) - settings->SaveFlags |= ImGuiTableFlags_Resizable; - if (column->DisplayOrder != n) - settings->SaveFlags |= ImGuiTableFlags_Reorderable; - if (column->SortOrder != -1) - settings->SaveFlags |= ImGuiTableFlags_Sortable; - if (column->IsUserEnabled != ((column->Flags & ImGuiTableColumnFlags_DefaultHide) == 0)) - settings->SaveFlags |= ImGuiTableFlags_Hideable; - } - settings->SaveFlags &= table->Flags; - settings->RefScale = save_ref_scale ? table->RefScale : 0.0f; - - MarkIniSettingsDirty(); -} - -void ImGui::TableLoadSettings(ImGuiTable* table) -{ - ImGuiContext& g = *GImGui; - table->IsSettingsRequestLoad = false; - if (table->Flags & ImGuiTableFlags_NoSavedSettings) - return; - - // Bind settings - ImGuiTableSettings* settings; - if (table->SettingsOffset == -1) - { - settings = TableSettingsFindByID(table->ID); - if (settings == NULL) - return; - if (settings->ColumnsCount != table->ColumnsCount) // Allow settings if columns count changed. We could otherwise decide to return... - table->IsSettingsDirty = true; - table->SettingsOffset = g.SettingsTables.offset_from_ptr(settings); - } - else - { - settings = TableGetBoundSettings(table); - } - - table->SettingsLoadedFlags = settings->SaveFlags; - table->RefScale = settings->RefScale; - - // Serialize ImGuiTableSettings/ImGuiTableColumnSettings into ImGuiTable/ImGuiTableColumn - ImGuiTableColumnSettings* column_settings = settings->GetColumnSettings(); - ImU64 display_order_mask = 0; - for (int data_n = 0; data_n < settings->ColumnsCount; data_n++, column_settings++) - { - int column_n = column_settings->Index; - if (column_n < 0 || column_n >= table->ColumnsCount) - continue; - - ImGuiTableColumn* column = &table->Columns[column_n]; - if (settings->SaveFlags & ImGuiTableFlags_Resizable) - { - if (column_settings->IsStretch) - column->StretchWeight = column_settings->WidthOrWeight; - else - column->WidthRequest = column_settings->WidthOrWeight; - column->AutoFitQueue = 0x00; - } - if (settings->SaveFlags & ImGuiTableFlags_Reorderable) - column->DisplayOrder = column_settings->DisplayOrder; - else - column->DisplayOrder = (ImGuiTableColumnIdx)column_n; - display_order_mask |= (ImU64)1 << column->DisplayOrder; - column->IsUserEnabled = column->IsUserEnabledNextFrame = column_settings->IsEnabled; - column->SortOrder = column_settings->SortOrder; - column->SortDirection = column_settings->SortDirection; - } - - // Validate and fix invalid display order data - const ImU64 expected_display_order_mask = (settings->ColumnsCount == 64) ? ~0 : ((ImU64)1 << settings->ColumnsCount) - 1; - if (display_order_mask != expected_display_order_mask) - for (int column_n = 0; column_n < table->ColumnsCount; column_n++) - table->Columns[column_n].DisplayOrder = (ImGuiTableColumnIdx)column_n; - - // Rebuild index - for (int column_n = 0; column_n < table->ColumnsCount; column_n++) - table->DisplayOrderToIndex[table->Columns[column_n].DisplayOrder] = (ImGuiTableColumnIdx)column_n; -} - -static void TableSettingsHandler_ClearAll(ImGuiContext* ctx, ImGuiSettingsHandler*) -{ - ImGuiContext& g = *ctx; - for (int i = 0; i != g.Tables.GetMapSize(); i++) - if (ImGuiTable* table = g.Tables.TryGetMapData(i)) - table->SettingsOffset = -1; - g.SettingsTables.clear(); -} - -// Apply to existing windows (if any) -static void TableSettingsHandler_ApplyAll(ImGuiContext* ctx, ImGuiSettingsHandler*) -{ - ImGuiContext& g = *ctx; - for (int i = 0; i != g.Tables.GetMapSize(); i++) - if (ImGuiTable* table = g.Tables.TryGetMapData(i)) - { - table->IsSettingsRequestLoad = true; - table->SettingsOffset = -1; - } -} - -static void* TableSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name) -{ - ImGuiID id = 0; - int columns_count = 0; - if (sscanf(name, "0x%08X,%d", &id, &columns_count) < 2) - return NULL; - - if (ImGuiTableSettings* settings = ImGui::TableSettingsFindByID(id)) - { - if (settings->ColumnsCountMax >= columns_count) - { - TableSettingsInit(settings, id, columns_count, settings->ColumnsCountMax); // Recycle - return settings; - } - settings->ID = 0; // Invalidate storage, we won't fit because of a count change - } - return ImGui::TableSettingsCreate(id, columns_count); -} - -static void TableSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line) -{ - // "Column 0 UserID=0x42AD2D21 Width=100 Visible=1 Order=0 Sort=0v" - ImGuiTableSettings* settings = (ImGuiTableSettings*)entry; - float f = 0.0f; - int column_n = 0, r = 0, n = 0; - - if (sscanf(line, "RefScale=%f", &f) == 1) { settings->RefScale = f; return; } - - if (sscanf(line, "Column %d%n", &column_n, &r) == 1) - { - if (column_n < 0 || column_n >= settings->ColumnsCount) - return; - line = ImStrSkipBlank(line + r); - char c = 0; - ImGuiTableColumnSettings* column = settings->GetColumnSettings() + column_n; - column->Index = (ImGuiTableColumnIdx)column_n; - if (sscanf(line, "UserID=0x%08X%n", (ImU32*)&n, &r)==1) { line = ImStrSkipBlank(line + r); column->UserID = (ImGuiID)n; } - if (sscanf(line, "Width=%d%n", &n, &r) == 1) { line = ImStrSkipBlank(line + r); column->WidthOrWeight = (float)n; column->IsStretch = 0; settings->SaveFlags |= ImGuiTableFlags_Resizable; } - if (sscanf(line, "Weight=%f%n", &f, &r) == 1) { line = ImStrSkipBlank(line + r); column->WidthOrWeight = f; column->IsStretch = 1; settings->SaveFlags |= ImGuiTableFlags_Resizable; } - if (sscanf(line, "Visible=%d%n", &n, &r) == 1) { line = ImStrSkipBlank(line + r); column->IsEnabled = (ImU8)n; settings->SaveFlags |= ImGuiTableFlags_Hideable; } - if (sscanf(line, "Order=%d%n", &n, &r) == 1) { line = ImStrSkipBlank(line + r); column->DisplayOrder = (ImGuiTableColumnIdx)n; settings->SaveFlags |= ImGuiTableFlags_Reorderable; } - if (sscanf(line, "Sort=%d%c%n", &n, &c, &r) == 2) { line = ImStrSkipBlank(line + r); column->SortOrder = (ImGuiTableColumnIdx)n; column->SortDirection = (c == '^') ? ImGuiSortDirection_Descending : ImGuiSortDirection_Ascending; settings->SaveFlags |= ImGuiTableFlags_Sortable; } - } -} - -static void TableSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf) -{ - ImGuiContext& g = *ctx; - for (ImGuiTableSettings* settings = g.SettingsTables.begin(); settings != NULL; settings = g.SettingsTables.next_chunk(settings)) - { - if (settings->ID == 0) // Skip ditched settings - continue; - - // TableSaveSettings() may clear some of those flags when we establish that the data can be stripped - // (e.g. Order was unchanged) - const bool save_size = (settings->SaveFlags & ImGuiTableFlags_Resizable) != 0; - const bool save_visible = (settings->SaveFlags & ImGuiTableFlags_Hideable) != 0; - const bool save_order = (settings->SaveFlags & ImGuiTableFlags_Reorderable) != 0; - const bool save_sort = (settings->SaveFlags & ImGuiTableFlags_Sortable) != 0; - if (!save_size && !save_visible && !save_order && !save_sort) - continue; - - buf->reserve(buf->size() + 30 + settings->ColumnsCount * 50); // ballpark reserve - buf->appendf("[%s][0x%08X,%d]\n", handler->TypeName, settings->ID, settings->ColumnsCount); - if (settings->RefScale != 0.0f) - buf->appendf("RefScale=%g\n", settings->RefScale); - ImGuiTableColumnSettings* column = settings->GetColumnSettings(); - for (int column_n = 0; column_n < settings->ColumnsCount; column_n++, column++) - { - // "Column 0 UserID=0x42AD2D21 Width=100 Visible=1 Order=0 Sort=0v" - bool save_column = column->UserID != 0 || save_size || save_visible || save_order || (save_sort && column->SortOrder != -1); - if (!save_column) - continue; - buf->appendf("Column %-2d", column_n); - if (column->UserID != 0) buf->appendf(" UserID=%08X", column->UserID); - if (save_size && column->IsStretch) buf->appendf(" Weight=%.4f", column->WidthOrWeight); - if (save_size && !column->IsStretch) buf->appendf(" Width=%d", (int)column->WidthOrWeight); - if (save_visible) buf->appendf(" Visible=%d", column->IsEnabled); - if (save_order) buf->appendf(" Order=%d", column->DisplayOrder); - if (save_sort && column->SortOrder != -1) buf->appendf(" Sort=%d%c", column->SortOrder, (column->SortDirection == ImGuiSortDirection_Ascending) ? 'v' : '^'); - buf->append("\n"); - } - buf->append("\n"); - } -} - -void ImGui::TableSettingsInstallHandler(ImGuiContext* context) -{ - ImGuiContext& g = *context; - ImGuiSettingsHandler ini_handler; - ini_handler.TypeName = "Table"; - ini_handler.TypeHash = ImHashStr("Table"); - ini_handler.ClearAllFn = TableSettingsHandler_ClearAll; - ini_handler.ReadOpenFn = TableSettingsHandler_ReadOpen; - ini_handler.ReadLineFn = TableSettingsHandler_ReadLine; - ini_handler.ApplyAllFn = TableSettingsHandler_ApplyAll; - ini_handler.WriteAllFn = TableSettingsHandler_WriteAll; - g.SettingsHandlers.push_back(ini_handler); -} - -//------------------------------------------------------------------------- -// [SECTION] Tables: Garbage Collection -//------------------------------------------------------------------------- -// - TableRemove() [Internal] -// - TableGcCompactTransientBuffers() [Internal] -// - TableGcCompactSettings() [Internal] -//------------------------------------------------------------------------- - -// Remove Table (currently only used by TestEngine) -void ImGui::TableRemove(ImGuiTable* table) -{ - //IMGUI_DEBUG_LOG("TableRemove() id=0x%08X\n", table->ID); - ImGuiContext& g = *GImGui; - int table_idx = g.Tables.GetIndex(table); - //memset(table->RawData.Data, 0, table->RawData.size_in_bytes()); - //memset(table, 0, sizeof(ImGuiTable)); - g.Tables.Remove(table->ID, table); - g.TablesLastTimeActive[table_idx] = -1.0f; -} - -// Free up/compact internal Table buffers for when it gets unused -void ImGui::TableGcCompactTransientBuffers(ImGuiTable* table) -{ - //IMGUI_DEBUG_LOG("TableGcCompactTransientBuffers() id=0x%08X\n", table->ID); - ImGuiContext& g = *GImGui; - IM_ASSERT(table->MemoryCompacted == false); - table->SortSpecs.Specs = NULL; - table->SortSpecsMulti.clear(); - table->IsSortSpecsDirty = true; // FIXME: shouldn't have to leak into user performing a sort - table->ColumnsNames.clear(); - table->MemoryCompacted = true; - for (int n = 0; n < table->ColumnsCount; n++) - table->Columns[n].NameOffset = -1; - g.TablesLastTimeActive[g.Tables.GetIndex(table)] = -1.0f; -} - -void ImGui::TableGcCompactTransientBuffers(ImGuiTableTempData* temp_data) -{ - temp_data->DrawSplitter.ClearFreeMemory(); - temp_data->LastTimeActive = -1.0f; -} - -// Compact and remove unused settings data (currently only used by TestEngine) -void ImGui::TableGcCompactSettings() -{ - ImGuiContext& g = *GImGui; - int required_memory = 0; - for (ImGuiTableSettings* settings = g.SettingsTables.begin(); settings != NULL; settings = g.SettingsTables.next_chunk(settings)) - if (settings->ID != 0) - required_memory += (int)TableSettingsCalcChunkSize(settings->ColumnsCount); - if (required_memory == g.SettingsTables.Buf.Size) - return; - ImChunkStream new_chunk_stream; - new_chunk_stream.Buf.reserve(required_memory); - for (ImGuiTableSettings* settings = g.SettingsTables.begin(); settings != NULL; settings = g.SettingsTables.next_chunk(settings)) - if (settings->ID != 0) - memcpy(new_chunk_stream.alloc_chunk(TableSettingsCalcChunkSize(settings->ColumnsCount)), settings, TableSettingsCalcChunkSize(settings->ColumnsCount)); - g.SettingsTables.swap(new_chunk_stream); -} - - -//------------------------------------------------------------------------- -// [SECTION] Tables: Debugging -//------------------------------------------------------------------------- -// - DebugNodeTable() [Internal] -//------------------------------------------------------------------------- - -#ifndef IMGUI_DISABLE_METRICS_WINDOW - -static const char* DebugNodeTableGetSizingPolicyDesc(ImGuiTableFlags sizing_policy) -{ - sizing_policy &= ImGuiTableFlags_SizingMask_; - if (sizing_policy == ImGuiTableFlags_SizingFixedFit) { return "FixedFit"; } - if (sizing_policy == ImGuiTableFlags_SizingFixedSame) { return "FixedSame"; } - if (sizing_policy == ImGuiTableFlags_SizingStretchProp) { return "StretchProp"; } - if (sizing_policy == ImGuiTableFlags_SizingStretchSame) { return "StretchSame"; } - return "N/A"; -} - -void ImGui::DebugNodeTable(ImGuiTable* table) -{ - char buf[512]; - char* p = buf; - const char* buf_end = buf + IM_ARRAYSIZE(buf); - const bool is_active = (table->LastFrameActive >= ImGui::GetFrameCount() - 2); // Note that fully clipped early out scrolling tables will appear as inactive here. - ImFormatString(p, buf_end - p, "Table 0x%08X (%d columns, in '%s')%s", table->ID, table->ColumnsCount, table->OuterWindow->Name, is_active ? "" : " *Inactive*"); - if (!is_active) { PushStyleColor(ImGuiCol_Text, GetStyleColorVec4(ImGuiCol_TextDisabled)); } - bool open = TreeNode(table, "%s", buf); - if (!is_active) { PopStyleColor(); } - if (IsItemHovered()) - GetForegroundDrawList()->AddRect(table->OuterRect.Min, table->OuterRect.Max, IM_COL32(255, 255, 0, 255)); - if (IsItemVisible() && table->HoveredColumnBody != -1) - GetForegroundDrawList()->AddRect(GetItemRectMin(), GetItemRectMax(), IM_COL32(255, 255, 0, 255)); - if (!open) - return; - bool clear_settings = SmallButton("Clear settings"); - BulletText("OuterRect: Pos: (%.1f,%.1f) Size: (%.1f,%.1f) Sizing: '%s'", table->OuterRect.Min.x, table->OuterRect.Min.y, table->OuterRect.GetWidth(), table->OuterRect.GetHeight(), DebugNodeTableGetSizingPolicyDesc(table->Flags)); - BulletText("ColumnsGivenWidth: %.1f, ColumnsAutoFitWidth: %.1f, InnerWidth: %.1f%s", table->ColumnsGivenWidth, table->ColumnsAutoFitWidth, table->InnerWidth, table->InnerWidth == 0.0f ? " (auto)" : ""); - BulletText("CellPaddingX: %.1f, CellSpacingX: %.1f/%.1f, OuterPaddingX: %.1f", table->CellPaddingX, table->CellSpacingX1, table->CellSpacingX2, table->OuterPaddingX); - BulletText("HoveredColumnBody: %d, HoveredColumnBorder: %d", table->HoveredColumnBody, table->HoveredColumnBorder); - BulletText("ResizedColumn: %d, ReorderColumn: %d, HeldHeaderColumn: %d", table->ResizedColumn, table->ReorderColumn, table->HeldHeaderColumn); - //BulletText("BgDrawChannels: %d/%d", 0, table->BgDrawChannelUnfrozen); - float sum_weights = 0.0f; - for (int n = 0; n < table->ColumnsCount; n++) - if (table->Columns[n].Flags & ImGuiTableColumnFlags_WidthStretch) - sum_weights += table->Columns[n].StretchWeight; - for (int n = 0; n < table->ColumnsCount; n++) - { - ImGuiTableColumn* column = &table->Columns[n]; - const char* name = TableGetColumnName(table, n); - ImFormatString(buf, IM_ARRAYSIZE(buf), - "Column %d order %d '%s': offset %+.2f to %+.2f%s\n" - "Enabled: %d, VisibleX/Y: %d/%d, RequestOutput: %d, SkipItems: %d, DrawChannels: %d,%d\n" - "WidthGiven: %.1f, Request/Auto: %.1f/%.1f, StretchWeight: %.3f (%.1f%%)\n" - "MinX: %.1f, MaxX: %.1f (%+.1f), ClipRect: %.1f to %.1f (+%.1f)\n" - "ContentWidth: %.1f,%.1f, HeadersUsed/Ideal %.1f/%.1f\n" - "Sort: %d%s, UserID: 0x%08X, Flags: 0x%04X: %s%s%s..", - n, column->DisplayOrder, name, column->MinX - table->WorkRect.Min.x, column->MaxX - table->WorkRect.Min.x, (n < table->FreezeColumnsRequest) ? " (Frozen)" : "", - column->IsEnabled, column->IsVisibleX, column->IsVisibleY, column->IsRequestOutput, column->IsSkipItems, column->DrawChannelFrozen, column->DrawChannelUnfrozen, - column->WidthGiven, column->WidthRequest, column->WidthAuto, column->StretchWeight, column->StretchWeight > 0.0f ? (column->StretchWeight / sum_weights) * 100.0f : 0.0f, - column->MinX, column->MaxX, column->MaxX - column->MinX, column->ClipRect.Min.x, column->ClipRect.Max.x, column->ClipRect.Max.x - column->ClipRect.Min.x, - column->ContentMaxXFrozen - column->WorkMinX, column->ContentMaxXUnfrozen - column->WorkMinX, column->ContentMaxXHeadersUsed - column->WorkMinX, column->ContentMaxXHeadersIdeal - column->WorkMinX, - column->SortOrder, (column->SortDirection == ImGuiSortDirection_Ascending) ? " (Asc)" : (column->SortDirection == ImGuiSortDirection_Descending) ? " (Des)" : "", column->UserID, column->Flags, - (column->Flags & ImGuiTableColumnFlags_WidthStretch) ? "WidthStretch " : "", - (column->Flags & ImGuiTableColumnFlags_WidthFixed) ? "WidthFixed " : "", - (column->Flags & ImGuiTableColumnFlags_NoResize) ? "NoResize " : ""); - Bullet(); - Selectable(buf); - if (IsItemHovered()) - { - ImRect r(column->MinX, table->OuterRect.Min.y, column->MaxX, table->OuterRect.Max.y); - GetForegroundDrawList()->AddRect(r.Min, r.Max, IM_COL32(255, 255, 0, 255)); - } - } - if (ImGuiTableSettings* settings = TableGetBoundSettings(table)) - DebugNodeTableSettings(settings); - if (clear_settings) - table->IsResetAllRequest = true; - TreePop(); -} - -void ImGui::DebugNodeTableSettings(ImGuiTableSettings* settings) -{ - if (!TreeNode((void*)(intptr_t)settings->ID, "Settings 0x%08X (%d columns)", settings->ID, settings->ColumnsCount)) - return; - BulletText("SaveFlags: 0x%08X", settings->SaveFlags); - BulletText("ColumnsCount: %d (max %d)", settings->ColumnsCount, settings->ColumnsCountMax); - for (int n = 0; n < settings->ColumnsCount; n++) - { - ImGuiTableColumnSettings* column_settings = &settings->GetColumnSettings()[n]; - ImGuiSortDirection sort_dir = (column_settings->SortOrder != -1) ? (ImGuiSortDirection)column_settings->SortDirection : ImGuiSortDirection_None; - BulletText("Column %d Order %d SortOrder %d %s Vis %d %s %7.3f UserID 0x%08X", - n, column_settings->DisplayOrder, column_settings->SortOrder, - (sort_dir == ImGuiSortDirection_Ascending) ? "Asc" : (sort_dir == ImGuiSortDirection_Descending) ? "Des" : "---", - column_settings->IsEnabled, column_settings->IsStretch ? "Weight" : "Width ", column_settings->WidthOrWeight, column_settings->UserID); - } - TreePop(); -} - -#else // #ifndef IMGUI_DISABLE_METRICS_WINDOW - -void ImGui::DebugNodeTable(ImGuiTable*) {} -void ImGui::DebugNodeTableSettings(ImGuiTableSettings*) {} - -#endif - - -//------------------------------------------------------------------------- -// [SECTION] Columns, BeginColumns, EndColumns, etc. -// (This is a legacy API, prefer using BeginTable/EndTable!) -//------------------------------------------------------------------------- -// FIXME: sizing is lossy when columns width is very small (default width may turn negative etc.) -//------------------------------------------------------------------------- -// - SetWindowClipRectBeforeSetChannel() [Internal] -// - GetColumnIndex() -// - GetColumnsCount() -// - GetColumnOffset() -// - GetColumnWidth() -// - SetColumnOffset() -// - SetColumnWidth() -// - PushColumnClipRect() [Internal] -// - PushColumnsBackground() [Internal] -// - PopColumnsBackground() [Internal] -// - FindOrCreateColumns() [Internal] -// - GetColumnsID() [Internal] -// - BeginColumns() -// - NextColumn() -// - EndColumns() -// - Columns() -//------------------------------------------------------------------------- - -// [Internal] Small optimization to avoid calls to PopClipRect/SetCurrentChannel/PushClipRect in sequences, -// they would meddle many times with the underlying ImDrawCmd. -// Instead, we do a preemptive overwrite of clipping rectangle _without_ altering the command-buffer and let -// the subsequent single call to SetCurrentChannel() does it things once. -void ImGui::SetWindowClipRectBeforeSetChannel(ImGuiWindow* window, const ImRect& clip_rect) -{ - ImVec4 clip_rect_vec4 = clip_rect.ToVec4(); - window->ClipRect = clip_rect; - window->DrawList->_CmdHeader.ClipRect = clip_rect_vec4; - window->DrawList->_ClipRectStack.Data[window->DrawList->_ClipRectStack.Size - 1] = clip_rect_vec4; -} - -int ImGui::GetColumnIndex() -{ - ImGuiWindow* window = GetCurrentWindowRead(); - return window->DC.CurrentColumns ? window->DC.CurrentColumns->Current : 0; -} - -int ImGui::GetColumnsCount() -{ - ImGuiWindow* window = GetCurrentWindowRead(); - return window->DC.CurrentColumns ? window->DC.CurrentColumns->Count : 1; -} - -float ImGui::GetColumnOffsetFromNorm(const ImGuiOldColumns* columns, float offset_norm) -{ - return offset_norm * (columns->OffMaxX - columns->OffMinX); -} - -float ImGui::GetColumnNormFromOffset(const ImGuiOldColumns* columns, float offset) -{ - return offset / (columns->OffMaxX - columns->OffMinX); -} - -static const float COLUMNS_HIT_RECT_HALF_WIDTH = 4.0f; - -static float GetDraggedColumnOffset(ImGuiOldColumns* columns, int column_index) -{ - // Active (dragged) column always follow mouse. The reason we need this is that dragging a column to the right edge of an auto-resizing - // window creates a feedback loop because we store normalized positions. So while dragging we enforce absolute positioning. - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - IM_ASSERT(column_index > 0); // We are not supposed to drag column 0. - IM_ASSERT(g.ActiveId == columns->ID + ImGuiID(column_index)); - - float x = g.IO.MousePos.x - g.ActiveIdClickOffset.x + COLUMNS_HIT_RECT_HALF_WIDTH - window->Pos.x; - x = ImMax(x, ImGui::GetColumnOffset(column_index - 1) + g.Style.ColumnsMinSpacing); - if ((columns->Flags & ImGuiOldColumnFlags_NoPreserveWidths)) - x = ImMin(x, ImGui::GetColumnOffset(column_index + 1) - g.Style.ColumnsMinSpacing); - - return x; -} - -float ImGui::GetColumnOffset(int column_index) -{ - ImGuiWindow* window = GetCurrentWindowRead(); - ImGuiOldColumns* columns = window->DC.CurrentColumns; - if (columns == NULL) - return 0.0f; - - if (column_index < 0) - column_index = columns->Current; - IM_ASSERT(column_index < columns->Columns.Size); - - const float t = columns->Columns[column_index].OffsetNorm; - const float x_offset = ImLerp(columns->OffMinX, columns->OffMaxX, t); - return x_offset; -} - -static float GetColumnWidthEx(ImGuiOldColumns* columns, int column_index, bool before_resize = false) -{ - if (column_index < 0) - column_index = columns->Current; - - float offset_norm; - if (before_resize) - offset_norm = columns->Columns[column_index + 1].OffsetNormBeforeResize - columns->Columns[column_index].OffsetNormBeforeResize; - else - offset_norm = columns->Columns[column_index + 1].OffsetNorm - columns->Columns[column_index].OffsetNorm; - return ImGui::GetColumnOffsetFromNorm(columns, offset_norm); -} - -float ImGui::GetColumnWidth(int column_index) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - ImGuiOldColumns* columns = window->DC.CurrentColumns; - if (columns == NULL) - return GetContentRegionAvail().x; - - if (column_index < 0) - column_index = columns->Current; - return GetColumnOffsetFromNorm(columns, columns->Columns[column_index + 1].OffsetNorm - columns->Columns[column_index].OffsetNorm); -} - -void ImGui::SetColumnOffset(int column_index, float offset) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - ImGuiOldColumns* columns = window->DC.CurrentColumns; - IM_ASSERT(columns != NULL); - - if (column_index < 0) - column_index = columns->Current; - IM_ASSERT(column_index < columns->Columns.Size); - - const bool preserve_width = !(columns->Flags & ImGuiOldColumnFlags_NoPreserveWidths) && (column_index < columns->Count - 1); - const float width = preserve_width ? GetColumnWidthEx(columns, column_index, columns->IsBeingResized) : 0.0f; - - if (!(columns->Flags & ImGuiOldColumnFlags_NoForceWithinWindow)) - offset = ImMin(offset, columns->OffMaxX - g.Style.ColumnsMinSpacing * (columns->Count - column_index)); - columns->Columns[column_index].OffsetNorm = GetColumnNormFromOffset(columns, offset - columns->OffMinX); - - if (preserve_width) - SetColumnOffset(column_index + 1, offset + ImMax(g.Style.ColumnsMinSpacing, width)); -} - -void ImGui::SetColumnWidth(int column_index, float width) -{ - ImGuiWindow* window = GetCurrentWindowRead(); - ImGuiOldColumns* columns = window->DC.CurrentColumns; - IM_ASSERT(columns != NULL); - - if (column_index < 0) - column_index = columns->Current; - SetColumnOffset(column_index + 1, GetColumnOffset(column_index) + width); -} - -void ImGui::PushColumnClipRect(int column_index) -{ - ImGuiWindow* window = GetCurrentWindowRead(); - ImGuiOldColumns* columns = window->DC.CurrentColumns; - if (column_index < 0) - column_index = columns->Current; - - ImGuiOldColumnData* column = &columns->Columns[column_index]; - PushClipRect(column->ClipRect.Min, column->ClipRect.Max, false); -} - -// Get into the columns background draw command (which is generally the same draw command as before we called BeginColumns) -void ImGui::PushColumnsBackground() -{ - ImGuiWindow* window = GetCurrentWindowRead(); - ImGuiOldColumns* columns = window->DC.CurrentColumns; - if (columns->Count == 1) - return; - - // Optimization: avoid SetCurrentChannel() + PushClipRect() - columns->HostBackupClipRect = window->ClipRect; - SetWindowClipRectBeforeSetChannel(window, columns->HostInitialClipRect); - columns->Splitter.SetCurrentChannel(window->DrawList, 0); -} - -void ImGui::PopColumnsBackground() -{ - ImGuiWindow* window = GetCurrentWindowRead(); - ImGuiOldColumns* columns = window->DC.CurrentColumns; - if (columns->Count == 1) - return; - - // Optimization: avoid PopClipRect() + SetCurrentChannel() - SetWindowClipRectBeforeSetChannel(window, columns->HostBackupClipRect); - columns->Splitter.SetCurrentChannel(window->DrawList, columns->Current + 1); -} - -ImGuiOldColumns* ImGui::FindOrCreateColumns(ImGuiWindow* window, ImGuiID id) -{ - // We have few columns per window so for now we don't need bother much with turning this into a faster lookup. - for (int n = 0; n < window->ColumnsStorage.Size; n++) - if (window->ColumnsStorage[n].ID == id) - return &window->ColumnsStorage[n]; - - window->ColumnsStorage.push_back(ImGuiOldColumns()); - ImGuiOldColumns* columns = &window->ColumnsStorage.back(); - columns->ID = id; - return columns; -} - -ImGuiID ImGui::GetColumnsID(const char* str_id, int columns_count) -{ - ImGuiWindow* window = GetCurrentWindow(); - - // Differentiate column ID with an arbitrary prefix for cases where users name their columns set the same as another widget. - // In addition, when an identifier isn't explicitly provided we include the number of columns in the hash to make it uniquer. - PushID(0x11223347 + (str_id ? 0 : columns_count)); - ImGuiID id = window->GetID(str_id ? str_id : "columns"); - PopID(); - - return id; -} - -void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiOldColumnFlags flags) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = GetCurrentWindow(); - - IM_ASSERT(columns_count >= 1); - IM_ASSERT(window->DC.CurrentColumns == NULL); // Nested columns are currently not supported - - // Acquire storage for the columns set - ImGuiID id = GetColumnsID(str_id, columns_count); - ImGuiOldColumns* columns = FindOrCreateColumns(window, id); - IM_ASSERT(columns->ID == id); - columns->Current = 0; - columns->Count = columns_count; - columns->Flags = flags; - window->DC.CurrentColumns = columns; - - columns->HostCursorPosY = window->DC.CursorPos.y; - columns->HostCursorMaxPosX = window->DC.CursorMaxPos.x; - columns->HostInitialClipRect = window->ClipRect; - columns->HostBackupParentWorkRect = window->ParentWorkRect; - window->ParentWorkRect = window->WorkRect; - - // Set state for first column - // We aim so that the right-most column will have the same clipping width as other after being clipped by parent ClipRect - const float column_padding = g.Style.ItemSpacing.x; - const float half_clip_extend_x = ImFloor(ImMax(window->WindowPadding.x * 0.5f, window->WindowBorderSize)); - const float max_1 = window->WorkRect.Max.x + column_padding - ImMax(column_padding - window->WindowPadding.x, 0.0f); - const float max_2 = window->WorkRect.Max.x + half_clip_extend_x; - columns->OffMinX = window->DC.Indent.x - column_padding + ImMax(column_padding - window->WindowPadding.x, 0.0f); - columns->OffMaxX = ImMax(ImMin(max_1, max_2) - window->Pos.x, columns->OffMinX + 1.0f); - columns->LineMinY = columns->LineMaxY = window->DC.CursorPos.y; - - // Clear data if columns count changed - if (columns->Columns.Size != 0 && columns->Columns.Size != columns_count + 1) - columns->Columns.resize(0); - - // Initialize default widths - columns->IsFirstFrame = (columns->Columns.Size == 0); - if (columns->Columns.Size == 0) - { - columns->Columns.reserve(columns_count + 1); - for (int n = 0; n < columns_count + 1; n++) - { - ImGuiOldColumnData column; - column.OffsetNorm = n / (float)columns_count; - columns->Columns.push_back(column); - } - } - - for (int n = 0; n < columns_count; n++) - { - // Compute clipping rectangle - ImGuiOldColumnData* column = &columns->Columns[n]; - float clip_x1 = IM_ROUND(window->Pos.x + GetColumnOffset(n)); - float clip_x2 = IM_ROUND(window->Pos.x + GetColumnOffset(n + 1) - 1.0f); - column->ClipRect = ImRect(clip_x1, -FLT_MAX, clip_x2, +FLT_MAX); - column->ClipRect.ClipWithFull(window->ClipRect); - } - - if (columns->Count > 1) - { - columns->Splitter.Split(window->DrawList, 1 + columns->Count); - columns->Splitter.SetCurrentChannel(window->DrawList, 1); - PushColumnClipRect(0); - } - - // We don't generally store Indent.x inside ColumnsOffset because it may be manipulated by the user. - float offset_0 = GetColumnOffset(columns->Current); - float offset_1 = GetColumnOffset(columns->Current + 1); - float width = offset_1 - offset_0; - PushItemWidth(width * 0.65f); - window->DC.ColumnsOffset.x = ImMax(column_padding - window->WindowPadding.x, 0.0f); - window->DC.CursorPos.x = IM_FLOOR(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x); - window->WorkRect.Max.x = window->Pos.x + offset_1 - column_padding; -} - -void ImGui::NextColumn() -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems || window->DC.CurrentColumns == NULL) - return; - - ImGuiContext& g = *GImGui; - ImGuiOldColumns* columns = window->DC.CurrentColumns; - - if (columns->Count == 1) - { - window->DC.CursorPos.x = IM_FLOOR(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x); - IM_ASSERT(columns->Current == 0); - return; - } - - // Next column - if (++columns->Current == columns->Count) - columns->Current = 0; - - PopItemWidth(); - - // Optimization: avoid PopClipRect() + SetCurrentChannel() + PushClipRect() - // (which would needlessly attempt to update commands in the wrong channel, then pop or overwrite them), - ImGuiOldColumnData* column = &columns->Columns[columns->Current]; - SetWindowClipRectBeforeSetChannel(window, column->ClipRect); - columns->Splitter.SetCurrentChannel(window->DrawList, columns->Current + 1); - - const float column_padding = g.Style.ItemSpacing.x; - columns->LineMaxY = ImMax(columns->LineMaxY, window->DC.CursorPos.y); - if (columns->Current > 0) - { - // Columns 1+ ignore IndentX (by canceling it out) - // FIXME-COLUMNS: Unnecessary, could be locked? - window->DC.ColumnsOffset.x = GetColumnOffset(columns->Current) - window->DC.Indent.x + column_padding; - } - else - { - // New row/line: column 0 honor IndentX. - window->DC.ColumnsOffset.x = ImMax(column_padding - window->WindowPadding.x, 0.0f); - columns->LineMinY = columns->LineMaxY; - } - window->DC.CursorPos.x = IM_FLOOR(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x); - window->DC.CursorPos.y = columns->LineMinY; - window->DC.CurrLineSize = ImVec2(0.0f, 0.0f); - window->DC.CurrLineTextBaseOffset = 0.0f; - - // FIXME-COLUMNS: Share code with BeginColumns() - move code on columns setup. - float offset_0 = GetColumnOffset(columns->Current); - float offset_1 = GetColumnOffset(columns->Current + 1); - float width = offset_1 - offset_0; - PushItemWidth(width * 0.65f); - window->WorkRect.Max.x = window->Pos.x + offset_1 - column_padding; -} - -void ImGui::EndColumns() -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = GetCurrentWindow(); - ImGuiOldColumns* columns = window->DC.CurrentColumns; - IM_ASSERT(columns != NULL); - - PopItemWidth(); - if (columns->Count > 1) - { - PopClipRect(); - columns->Splitter.Merge(window->DrawList); - } - - const ImGuiOldColumnFlags flags = columns->Flags; - columns->LineMaxY = ImMax(columns->LineMaxY, window->DC.CursorPos.y); - window->DC.CursorPos.y = columns->LineMaxY; - if (!(flags & ImGuiOldColumnFlags_GrowParentContentsSize)) - window->DC.CursorMaxPos.x = columns->HostCursorMaxPosX; // Restore cursor max pos, as columns don't grow parent - - // Draw columns borders and handle resize - // The IsBeingResized flag ensure we preserve pre-resize columns width so back-and-forth are not lossy - bool is_being_resized = false; - if (!(flags & ImGuiOldColumnFlags_NoBorder) && !window->SkipItems) - { - // We clip Y boundaries CPU side because very long triangles are mishandled by some GPU drivers. - const float y1 = ImMax(columns->HostCursorPosY, window->ClipRect.Min.y); - const float y2 = ImMin(window->DC.CursorPos.y, window->ClipRect.Max.y); - int dragging_column = -1; - for (int n = 1; n < columns->Count; n++) - { - ImGuiOldColumnData* column = &columns->Columns[n]; - float x = window->Pos.x + GetColumnOffset(n); - const ImGuiID column_id = columns->ID + ImGuiID(n); - const float column_hit_hw = COLUMNS_HIT_RECT_HALF_WIDTH; - const ImRect column_hit_rect(ImVec2(x - column_hit_hw, y1), ImVec2(x + column_hit_hw, y2)); - KeepAliveID(column_id); - if (IsClippedEx(column_hit_rect, column_id)) // FIXME: Can be removed or replaced with a lower-level test - continue; - - bool hovered = false, held = false; - if (!(flags & ImGuiOldColumnFlags_NoResize)) - { - ButtonBehavior(column_hit_rect, column_id, &hovered, &held); - if (hovered || held) - g.MouseCursor = ImGuiMouseCursor_ResizeEW; - if (held && !(column->Flags & ImGuiOldColumnFlags_NoResize)) - dragging_column = n; - } - - // Draw column - const ImU32 col = GetColorU32(held ? ImGuiCol_SeparatorActive : hovered ? ImGuiCol_SeparatorHovered : ImGuiCol_Separator); - const float xi = IM_FLOOR(x); - window->DrawList->AddLine(ImVec2(xi, y1 + 1.0f), ImVec2(xi, y2), col); - } - - // Apply dragging after drawing the column lines, so our rendered lines are in sync with how items were displayed during the frame. - if (dragging_column != -1) - { - if (!columns->IsBeingResized) - for (int n = 0; n < columns->Count + 1; n++) - columns->Columns[n].OffsetNormBeforeResize = columns->Columns[n].OffsetNorm; - columns->IsBeingResized = is_being_resized = true; - float x = GetDraggedColumnOffset(columns, dragging_column); - SetColumnOffset(dragging_column, x); - } - } - columns->IsBeingResized = is_being_resized; - - window->WorkRect = window->ParentWorkRect; - window->ParentWorkRect = columns->HostBackupParentWorkRect; - window->DC.CurrentColumns = NULL; - window->DC.ColumnsOffset.x = 0.0f; - window->DC.CursorPos.x = IM_FLOOR(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x); -} - -void ImGui::Columns(int columns_count, const char* id, bool border) -{ - ImGuiWindow* window = GetCurrentWindow(); - IM_ASSERT(columns_count >= 1); - - ImGuiOldColumnFlags flags = (border ? 0 : ImGuiOldColumnFlags_NoBorder); - //flags |= ImGuiOldColumnFlags_NoPreserveWidths; // NB: Legacy behavior - ImGuiOldColumns* columns = window->DC.CurrentColumns; - if (columns != NULL && columns->Count == columns_count && columns->Flags == flags) - return; - - if (columns != NULL) - EndColumns(); - - if (columns_count != 1) - BeginColumns(id, columns_count, flags); -} - -//------------------------------------------------------------------------- - -#endif // #ifndef IMGUI_DISABLE diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imgui_widgets.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imgui_widgets.cpp deleted file mode 100644 index 7da069b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imgui_widgets.cpp +++ /dev/null @@ -1,8218 +0,0 @@ -// dear imgui, v1.85 -// (widgets code) - -/* - -Index of this file: - -// [SECTION] Forward Declarations -// [SECTION] Widgets: Text, etc. -// [SECTION] Widgets: Main (Button, Image, Checkbox, RadioButton, ProgressBar, Bullet, etc.) -// [SECTION] Widgets: Low-level Layout helpers (Spacing, Dummy, NewLine, Separator, etc.) -// [SECTION] Widgets: ComboBox -// [SECTION] Data Type and Data Formatting Helpers -// [SECTION] Widgets: DragScalar, DragFloat, DragInt, etc. -// [SECTION] Widgets: SliderScalar, SliderFloat, SliderInt, etc. -// [SECTION] Widgets: InputScalar, InputFloat, InputInt, etc. -// [SECTION] Widgets: InputText, InputTextMultiline -// [SECTION] Widgets: ColorEdit, ColorPicker, ColorButton, etc. -// [SECTION] Widgets: TreeNode, CollapsingHeader, etc. -// [SECTION] Widgets: Selectable -// [SECTION] Widgets: ListBox -// [SECTION] Widgets: PlotLines, PlotHistogram -// [SECTION] Widgets: Value helpers -// [SECTION] Widgets: MenuItem, BeginMenu, EndMenu, etc. -// [SECTION] Widgets: BeginTabBar, EndTabBar, etc. -// [SECTION] Widgets: BeginTabItem, EndTabItem, etc. -// [SECTION] Widgets: Columns, BeginColumns, EndColumns, etc. - -*/ - -#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) -#define _CRT_SECURE_NO_WARNINGS -#endif - -#include "imgui.h" -#ifndef IMGUI_DISABLE - -#ifndef IMGUI_DEFINE_MATH_OPERATORS -#define IMGUI_DEFINE_MATH_OPERATORS -#endif -#include "imgui_internal.h" - -// System includes -#include // toupper -#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier -#include // intptr_t -#else -#include // intptr_t -#endif - -//------------------------------------------------------------------------- -// Warnings -//------------------------------------------------------------------------- - -// Visual Studio warnings -#ifdef _MSC_VER -#pragma warning (disable: 4127) // condition expression is constant -#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen -#if defined(_MSC_VER) && _MSC_VER >= 1922 // MSVC 2019 16.2 or later -#pragma warning (disable: 5054) // operator '|': deprecated between enumerations of different types -#endif -#pragma warning (disable: 26451) // [Static Analyzer] Arithmetic overflow : Using operator 'xxx' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator 'xxx' to avoid overflow(io.2). -#pragma warning (disable: 26812) // [Static Analyzer] The enum type 'xxx' is unscoped. Prefer 'enum class' over 'enum' (Enum.3). -#endif - -// Clang/GCC warnings with -Weverything -#if defined(__clang__) -#if __has_warning("-Wunknown-warning-option") -#pragma clang diagnostic ignored "-Wunknown-warning-option" // warning: unknown warning group 'xxx' // not all warnings are known by all Clang versions and they tend to be rename-happy.. so ignoring warnings triggers new warnings on some configuration. Great! -#endif -#pragma clang diagnostic ignored "-Wunknown-pragmas" // warning: unknown warning group 'xxx' -#pragma clang diagnostic ignored "-Wold-style-cast" // warning: use of old-style cast // yes, they are more terse. -#pragma clang diagnostic ignored "-Wfloat-equal" // warning: comparing floating point with == or != is unsafe // storing and comparing against same constants (typically 0.0f) is ok. -#pragma clang diagnostic ignored "-Wformat-nonliteral" // warning: format string is not a string literal // passing non-literal to vsnformat(). yes, user passing incorrect format strings can crash the code. -#pragma clang diagnostic ignored "-Wsign-conversion" // warning: implicit conversion changes signedness -#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" // warning: zero as null pointer constant // some standard header variations use #define NULL 0 -#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double. -#pragma clang diagnostic ignored "-Wenum-enum-conversion" // warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') -#pragma clang diagnostic ignored "-Wdeprecated-enum-enum-conversion"// warning: bitwise operation between different enumeration types ('XXXFlags_' and 'XXXFlagsPrivate_') is deprecated -#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision -#elif defined(__GNUC__) -#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind -#pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked -#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead -#endif - -//------------------------------------------------------------------------- -// Data -//------------------------------------------------------------------------- - -// Widgets -static const float DRAGDROP_HOLD_TO_OPEN_TIMER = 0.70f; // Time for drag-hold to activate items accepting the ImGuiButtonFlags_PressedOnDragDropHold button behavior. -static const float DRAG_MOUSE_THRESHOLD_FACTOR = 0.50f; // Multiplier for the default value of io.MouseDragThreshold to make DragFloat/DragInt react faster to mouse drags. - -// Those MIN/MAX values are not define because we need to point to them -static const signed char IM_S8_MIN = -128; -static const signed char IM_S8_MAX = 127; -static const unsigned char IM_U8_MIN = 0; -static const unsigned char IM_U8_MAX = 0xFF; -static const signed short IM_S16_MIN = -32768; -static const signed short IM_S16_MAX = 32767; -static const unsigned short IM_U16_MIN = 0; -static const unsigned short IM_U16_MAX = 0xFFFF; -static const ImS32 IM_S32_MIN = INT_MIN; // (-2147483647 - 1), (0x80000000); -static const ImS32 IM_S32_MAX = INT_MAX; // (2147483647), (0x7FFFFFFF) -static const ImU32 IM_U32_MIN = 0; -static const ImU32 IM_U32_MAX = UINT_MAX; // (0xFFFFFFFF) -#ifdef LLONG_MIN -static const ImS64 IM_S64_MIN = LLONG_MIN; // (-9223372036854775807ll - 1ll); -static const ImS64 IM_S64_MAX = LLONG_MAX; // (9223372036854775807ll); -#else -static const ImS64 IM_S64_MIN = -9223372036854775807LL - 1; -static const ImS64 IM_S64_MAX = 9223372036854775807LL; -#endif -static const ImU64 IM_U64_MIN = 0; -#ifdef ULLONG_MAX -static const ImU64 IM_U64_MAX = ULLONG_MAX; // (0xFFFFFFFFFFFFFFFFull); -#else -static const ImU64 IM_U64_MAX = (2ULL * 9223372036854775807LL + 1); -#endif - -//------------------------------------------------------------------------- -// [SECTION] Forward Declarations -//------------------------------------------------------------------------- - -// For InputTextEx() -static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data, ImGuiInputSource input_source); -static int InputTextCalcTextLenAndLineCount(const char* text_begin, const char** out_text_end); -static ImVec2 InputTextCalcTextSizeW(const ImWchar* text_begin, const ImWchar* text_end, const ImWchar** remaining = NULL, ImVec2* out_offset = NULL, bool stop_on_new_line = false); - -//------------------------------------------------------------------------- -// [SECTION] Widgets: Text, etc. -//------------------------------------------------------------------------- -// - TextEx() [Internal] -// - TextUnformatted() -// - Text() -// - TextV() -// - TextColored() -// - TextColoredV() -// - TextDisabled() -// - TextDisabledV() -// - TextWrapped() -// - TextWrappedV() -// - LabelText() -// - LabelTextV() -// - BulletText() -// - BulletTextV() -//------------------------------------------------------------------------- - -void ImGui::TextEx(const char* text, const char* text_end, ImGuiTextFlags flags) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return; - ImGuiContext& g = *GImGui; - - // Accept null ranges - if (text == text_end) - text = text_end = ""; - - // Calculate length - const char* text_begin = text; - if (text_end == NULL) - text_end = text + strlen(text); // FIXME-OPT - - const ImVec2 text_pos(window->DC.CursorPos.x, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset); - const float wrap_pos_x = window->DC.TextWrapPos; - const bool wrap_enabled = (wrap_pos_x >= 0.0f); - if (text_end - text > 2000 && !wrap_enabled) - { - // Long text! - // Perform manual coarse clipping to optimize for long multi-line text - // - From this point we will only compute the width of lines that are visible. Optimization only available when word-wrapping is disabled. - // - We also don't vertically center the text within the line full height, which is unlikely to matter because we are likely the biggest and only item on the line. - // - We use memchr(), pay attention that well optimized versions of those str/mem functions are much faster than a casually written loop. - const char* line = text; - const float line_height = GetTextLineHeight(); - ImVec2 text_size(0, 0); - - // Lines to skip (can't skip when logging text) - ImVec2 pos = text_pos; - if (!g.LogEnabled) - { - int lines_skippable = (int)((window->ClipRect.Min.y - text_pos.y) / line_height); - if (lines_skippable > 0) - { - int lines_skipped = 0; - while (line < text_end && lines_skipped < lines_skippable) - { - const char* line_end = (const char*)memchr(line, '\n', text_end - line); - if (!line_end) - line_end = text_end; - if ((flags & ImGuiTextFlags_NoWidthForLargeClippedText) == 0) - text_size.x = ImMax(text_size.x, CalcTextSize(line, line_end).x); - line = line_end + 1; - lines_skipped++; - } - pos.y += lines_skipped * line_height; - } - } - - // Lines to render - if (line < text_end) - { - ImRect line_rect(pos, pos + ImVec2(FLT_MAX, line_height)); - while (line < text_end) - { - if (IsClippedEx(line_rect, 0)) - break; - - const char* line_end = (const char*)memchr(line, '\n', text_end - line); - if (!line_end) - line_end = text_end; - text_size.x = ImMax(text_size.x, CalcTextSize(line, line_end).x); - RenderText(pos, line, line_end, false); - line = line_end + 1; - line_rect.Min.y += line_height; - line_rect.Max.y += line_height; - pos.y += line_height; - } - - // Count remaining lines - int lines_skipped = 0; - while (line < text_end) - { - const char* line_end = (const char*)memchr(line, '\n', text_end - line); - if (!line_end) - line_end = text_end; - if ((flags & ImGuiTextFlags_NoWidthForLargeClippedText) == 0) - text_size.x = ImMax(text_size.x, CalcTextSize(line, line_end).x); - line = line_end + 1; - lines_skipped++; - } - pos.y += lines_skipped * line_height; - } - text_size.y = (pos - text_pos).y; - - ImRect bb(text_pos, text_pos + text_size); - ItemSize(text_size, 0.0f); - ItemAdd(bb, 0); - } - else - { - const float wrap_width = wrap_enabled ? CalcWrapWidthForPos(window->DC.CursorPos, wrap_pos_x) : 0.0f; - const ImVec2 text_size = CalcTextSize(text_begin, text_end, false, wrap_width); - - ImRect bb(text_pos, text_pos + text_size); - ItemSize(text_size, 0.0f); - if (!ItemAdd(bb, 0)) - return; - - // Render (we don't hide text after ## in this end-user function) - RenderTextWrapped(bb.Min, text_begin, text_end, wrap_width); - } -} - -void ImGui::TextUnformatted(const char* text, const char* text_end) -{ - TextEx(text, text_end, ImGuiTextFlags_NoWidthForLargeClippedText); -} - -void ImGui::Text(const char* fmt, ...) -{ - va_list args; - va_start(args, fmt); - TextV(fmt, args); - va_end(args); -} - -void ImGui::TextV(const char* fmt, va_list args) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return; - - // FIXME-OPT: Handle the %s shortcut? - ImGuiContext& g = *GImGui; - const char* text_end = g.TempBuffer + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args); - TextEx(g.TempBuffer, text_end, ImGuiTextFlags_NoWidthForLargeClippedText); -} - -void ImGui::TextColored(const ImVec4& col, const char* fmt, ...) -{ - va_list args; - va_start(args, fmt); - TextColoredV(col, fmt, args); - va_end(args); -} - -void ImGui::TextColoredV(const ImVec4& col, const char* fmt, va_list args) -{ - PushStyleColor(ImGuiCol_Text, col); - if (fmt[0] == '%' && fmt[1] == 's' && fmt[2] == 0) - TextEx(va_arg(args, const char*), NULL, ImGuiTextFlags_NoWidthForLargeClippedText); // Skip formatting - else - TextV(fmt, args); - PopStyleColor(); -} - -void ImGui::TextDisabled(const char* fmt, ...) -{ - va_list args; - va_start(args, fmt); - TextDisabledV(fmt, args); - va_end(args); -} - -void ImGui::TextDisabledV(const char* fmt, va_list args) -{ - ImGuiContext& g = *GImGui; - PushStyleColor(ImGuiCol_Text, g.Style.Colors[ImGuiCol_TextDisabled]); - if (fmt[0] == '%' && fmt[1] == 's' && fmt[2] == 0) - TextEx(va_arg(args, const char*), NULL, ImGuiTextFlags_NoWidthForLargeClippedText); // Skip formatting - else - TextV(fmt, args); - PopStyleColor(); -} - -void ImGui::TextWrapped(const char* fmt, ...) -{ - va_list args; - va_start(args, fmt); - TextWrappedV(fmt, args); - va_end(args); -} - -void ImGui::TextWrappedV(const char* fmt, va_list args) -{ - ImGuiContext& g = *GImGui; - bool need_backup = (g.CurrentWindow->DC.TextWrapPos < 0.0f); // Keep existing wrap position if one is already set - if (need_backup) - PushTextWrapPos(0.0f); - if (fmt[0] == '%' && fmt[1] == 's' && fmt[2] == 0) - TextEx(va_arg(args, const char*), NULL, ImGuiTextFlags_NoWidthForLargeClippedText); // Skip formatting - else - TextV(fmt, args); - if (need_backup) - PopTextWrapPos(); -} - -void ImGui::LabelText(const char* label, const char* fmt, ...) -{ - va_list args; - va_start(args, fmt); - LabelTextV(label, fmt, args); - va_end(args); -} - -// Add a label+text combo aligned to other label+value widgets -void ImGui::LabelTextV(const char* label, const char* fmt, va_list args) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return; - - ImGuiContext& g = *GImGui; - const ImGuiStyle& style = g.Style; - const float w = CalcItemWidth(); - - const char* value_text_begin = &g.TempBuffer[0]; - const char* value_text_end = value_text_begin + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args); - const ImVec2 value_size = CalcTextSize(value_text_begin, value_text_end, false); - const ImVec2 label_size = CalcTextSize(label, NULL, true); - - const ImVec2 pos = window->DC.CursorPos; - const ImRect value_bb(pos, pos + ImVec2(w, value_size.y + style.FramePadding.y * 2)); - const ImRect total_bb(pos, pos + ImVec2(w + (label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f), ImMax(value_size.y, label_size.y) + style.FramePadding.y * 2)); - ItemSize(total_bb, style.FramePadding.y); - if (!ItemAdd(total_bb, 0)) - return; - - // Render - RenderTextClipped(value_bb.Min + style.FramePadding, value_bb.Max, value_text_begin, value_text_end, &value_size, ImVec2(0.0f, 0.0f)); - if (label_size.x > 0.0f) - RenderText(ImVec2(value_bb.Max.x + style.ItemInnerSpacing.x, value_bb.Min.y + style.FramePadding.y), label); -} - -void ImGui::BulletText(const char* fmt, ...) -{ - va_list args; - va_start(args, fmt); - BulletTextV(fmt, args); - va_end(args); -} - -// Text with a little bullet aligned to the typical tree node. -void ImGui::BulletTextV(const char* fmt, va_list args) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return; - - ImGuiContext& g = *GImGui; - const ImGuiStyle& style = g.Style; - - const char* text_begin = g.TempBuffer; - const char* text_end = text_begin + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args); - const ImVec2 label_size = CalcTextSize(text_begin, text_end, false); - const ImVec2 total_size = ImVec2(g.FontSize + (label_size.x > 0.0f ? (label_size.x + style.FramePadding.x * 2) : 0.0f), label_size.y); // Empty text doesn't add padding - ImVec2 pos = window->DC.CursorPos; - pos.y += window->DC.CurrLineTextBaseOffset; - ItemSize(total_size, 0.0f); - const ImRect bb(pos, pos + total_size); - if (!ItemAdd(bb, 0)) - return; - - // Render - ImU32 text_col = GetColorU32(ImGuiCol_Text); - RenderBullet(window->DrawList, bb.Min + ImVec2(style.FramePadding.x + g.FontSize * 0.5f, g.FontSize * 0.5f), text_col); - RenderText(bb.Min + ImVec2(g.FontSize + style.FramePadding.x * 2, 0.0f), text_begin, text_end, false); -} - -//------------------------------------------------------------------------- -// [SECTION] Widgets: Main -//------------------------------------------------------------------------- -// - ButtonBehavior() [Internal] -// - Button() -// - SmallButton() -// - InvisibleButton() -// - ArrowButton() -// - CloseButton() [Internal] -// - CollapseButton() [Internal] -// - GetWindowScrollbarID() [Internal] -// - GetWindowScrollbarRect() [Internal] -// - Scrollbar() [Internal] -// - ScrollbarEx() [Internal] -// - Image() -// - ImageButton() -// - Checkbox() -// - CheckboxFlagsT() [Internal] -// - CheckboxFlags() -// - RadioButton() -// - ProgressBar() -// - Bullet() -//------------------------------------------------------------------------- - -// The ButtonBehavior() function is key to many interactions and used by many/most widgets. -// Because we handle so many cases (keyboard/gamepad navigation, drag and drop) and many specific behavior (via ImGuiButtonFlags_), -// this code is a little complex. -// By far the most common path is interacting with the Mouse using the default ImGuiButtonFlags_PressedOnClickRelease button behavior. -// See the series of events below and the corresponding state reported by dear imgui: -//------------------------------------------------------------------------------------------------------------------------------------------------ -// with PressedOnClickRelease: return-value IsItemHovered() IsItemActive() IsItemActivated() IsItemDeactivated() IsItemClicked() -// Frame N+0 (mouse is outside bb) - - - - - - -// Frame N+1 (mouse moves inside bb) - true - - - - -// Frame N+2 (mouse button is down) - true true true - true -// Frame N+3 (mouse button is down) - true true - - - -// Frame N+4 (mouse moves outside bb) - - true - - - -// Frame N+5 (mouse moves inside bb) - true true - - - -// Frame N+6 (mouse button is released) true true - - true - -// Frame N+7 (mouse button is released) - true - - - - -// Frame N+8 (mouse moves outside bb) - - - - - - -//------------------------------------------------------------------------------------------------------------------------------------------------ -// with PressedOnClick: return-value IsItemHovered() IsItemActive() IsItemActivated() IsItemDeactivated() IsItemClicked() -// Frame N+2 (mouse button is down) true true true true - true -// Frame N+3 (mouse button is down) - true true - - - -// Frame N+6 (mouse button is released) - true - - true - -// Frame N+7 (mouse button is released) - true - - - - -//------------------------------------------------------------------------------------------------------------------------------------------------ -// with PressedOnRelease: return-value IsItemHovered() IsItemActive() IsItemActivated() IsItemDeactivated() IsItemClicked() -// Frame N+2 (mouse button is down) - true - - - true -// Frame N+3 (mouse button is down) - true - - - - -// Frame N+6 (mouse button is released) true true - - - - -// Frame N+7 (mouse button is released) - true - - - - -//------------------------------------------------------------------------------------------------------------------------------------------------ -// with PressedOnDoubleClick: return-value IsItemHovered() IsItemActive() IsItemActivated() IsItemDeactivated() IsItemClicked() -// Frame N+0 (mouse button is down) - true - - - true -// Frame N+1 (mouse button is down) - true - - - - -// Frame N+2 (mouse button is released) - true - - - - -// Frame N+3 (mouse button is released) - true - - - - -// Frame N+4 (mouse button is down) true true true true - true -// Frame N+5 (mouse button is down) - true true - - - -// Frame N+6 (mouse button is released) - true - - true - -// Frame N+7 (mouse button is released) - true - - - - -//------------------------------------------------------------------------------------------------------------------------------------------------ -// Note that some combinations are supported, -// - PressedOnDragDropHold can generally be associated with any flag. -// - PressedOnDoubleClick can be associated by PressedOnClickRelease/PressedOnRelease, in which case the second release event won't be reported. -//------------------------------------------------------------------------------------------------------------------------------------------------ -// The behavior of the return-value changes when ImGuiButtonFlags_Repeat is set: -// Repeat+ Repeat+ Repeat+ Repeat+ -// PressedOnClickRelease PressedOnClick PressedOnRelease PressedOnDoubleClick -//------------------------------------------------------------------------------------------------------------------------------------------------- -// Frame N+0 (mouse button is down) - true - true -// ... - - - - -// Frame N + RepeatDelay true true - true -// ... - - - - -// Frame N + RepeatDelay + RepeatRate*N true true - true -//------------------------------------------------------------------------------------------------------------------------------------------------- - -bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = GetCurrentWindow(); - - // Default only reacts to left mouse button - if ((flags & ImGuiButtonFlags_MouseButtonMask_) == 0) - flags |= ImGuiButtonFlags_MouseButtonDefault_; - - // Default behavior requires click + release inside bounding box - if ((flags & ImGuiButtonFlags_PressedOnMask_) == 0) - flags |= ImGuiButtonFlags_PressedOnDefault_; - - ImGuiWindow* backup_hovered_window = g.HoveredWindow; - const bool flatten_hovered_children = (flags & ImGuiButtonFlags_FlattenChildren) && g.HoveredWindow && g.HoveredWindow->RootWindow == window; - if (flatten_hovered_children) - g.HoveredWindow = window; - -#ifdef IMGUI_ENABLE_TEST_ENGINE - if (id != 0 && g.LastItemData.ID != id) - IMGUI_TEST_ENGINE_ITEM_ADD(bb, id); -#endif - - bool pressed = false; - bool hovered = ItemHoverable(bb, id); - - // Drag source doesn't report as hovered - if (hovered && g.DragDropActive && g.DragDropPayload.SourceId == id && !(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoDisableHover)) - hovered = false; - - // Special mode for Drag and Drop where holding button pressed for a long time while dragging another item triggers the button - if (g.DragDropActive && (flags & ImGuiButtonFlags_PressedOnDragDropHold) && !(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoHoldToOpenOthers)) - if (IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) - { - hovered = true; - SetHoveredID(id); - if (g.HoveredIdTimer - g.IO.DeltaTime <= DRAGDROP_HOLD_TO_OPEN_TIMER && g.HoveredIdTimer >= DRAGDROP_HOLD_TO_OPEN_TIMER) - { - pressed = true; - g.DragDropHoldJustPressedId = id; - FocusWindow(window); - } - } - - if (flatten_hovered_children) - g.HoveredWindow = backup_hovered_window; - - // AllowOverlap mode (rarely used) requires previous frame HoveredId to be null or to match. This allows using patterns where a later submitted widget overlaps a previous one. - if (hovered && (flags & ImGuiButtonFlags_AllowItemOverlap) && (g.HoveredIdPreviousFrame != id && g.HoveredIdPreviousFrame != 0)) - hovered = false; - - // Mouse handling - if (hovered) - { - if (!(flags & ImGuiButtonFlags_NoKeyModifiers) || (!g.IO.KeyCtrl && !g.IO.KeyShift && !g.IO.KeyAlt)) - { - // Poll buttons - int mouse_button_clicked = -1; - int mouse_button_released = -1; - if ((flags & ImGuiButtonFlags_MouseButtonLeft) && g.IO.MouseClicked[0]) { mouse_button_clicked = 0; } - else if ((flags & ImGuiButtonFlags_MouseButtonRight) && g.IO.MouseClicked[1]) { mouse_button_clicked = 1; } - else if ((flags & ImGuiButtonFlags_MouseButtonMiddle) && g.IO.MouseClicked[2]) { mouse_button_clicked = 2; } - if ((flags & ImGuiButtonFlags_MouseButtonLeft) && g.IO.MouseReleased[0]) { mouse_button_released = 0; } - else if ((flags & ImGuiButtonFlags_MouseButtonRight) && g.IO.MouseReleased[1]) { mouse_button_released = 1; } - else if ((flags & ImGuiButtonFlags_MouseButtonMiddle) && g.IO.MouseReleased[2]) { mouse_button_released = 2; } - - if (mouse_button_clicked != -1 && g.ActiveId != id) - { - if (flags & (ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnClickReleaseAnywhere)) - { - SetActiveID(id, window); - g.ActiveIdMouseButton = mouse_button_clicked; - if (!(flags & ImGuiButtonFlags_NoNavFocus)) - SetFocusID(id, window); - FocusWindow(window); - } - if ((flags & ImGuiButtonFlags_PressedOnClick) || ((flags & ImGuiButtonFlags_PressedOnDoubleClick) && g.IO.MouseDoubleClicked[mouse_button_clicked])) - { - pressed = true; - if (flags & ImGuiButtonFlags_NoHoldingActiveId) - ClearActiveID(); - else - SetActiveID(id, window); // Hold on ID - if (!(flags & ImGuiButtonFlags_NoNavFocus)) - SetFocusID(id, window); - g.ActiveIdMouseButton = mouse_button_clicked; - FocusWindow(window); - } - } - if ((flags & ImGuiButtonFlags_PressedOnRelease) && mouse_button_released != -1) - { - // Repeat mode trumps on release behavior - const bool has_repeated_at_least_once = (flags & ImGuiButtonFlags_Repeat) && g.IO.MouseDownDurationPrev[mouse_button_released] >= g.IO.KeyRepeatDelay; - if (!has_repeated_at_least_once) - pressed = true; - if (!(flags & ImGuiButtonFlags_NoNavFocus)) - SetFocusID(id, window); - ClearActiveID(); - } - - // 'Repeat' mode acts when held regardless of _PressedOn flags (see table above). - // Relies on repeat logic of IsMouseClicked() but we may as well do it ourselves if we end up exposing finer RepeatDelay/RepeatRate settings. - if (g.ActiveId == id && (flags & ImGuiButtonFlags_Repeat)) - if (g.IO.MouseDownDuration[g.ActiveIdMouseButton] > 0.0f && IsMouseClicked(g.ActiveIdMouseButton, true)) - pressed = true; - } - - if (pressed) - g.NavDisableHighlight = true; - } - - // Gamepad/Keyboard navigation - // We report navigated item as hovered but we don't set g.HoveredId to not interfere with mouse. - if (g.NavId == id && !g.NavDisableHighlight && g.NavDisableMouseHover && (g.ActiveId == 0 || g.ActiveId == id || g.ActiveId == window->MoveId)) - if (!(flags & ImGuiButtonFlags_NoHoveredOnFocus)) - hovered = true; - if (g.NavActivateDownId == id) - { - bool nav_activated_by_code = (g.NavActivateId == id); - bool nav_activated_by_inputs = IsNavInputTest(ImGuiNavInput_Activate, (flags & ImGuiButtonFlags_Repeat) ? ImGuiInputReadMode_Repeat : ImGuiInputReadMode_Pressed); - if (nav_activated_by_code || nav_activated_by_inputs) - { - // Set active id so it can be queried by user via IsItemActive(), equivalent of holding the mouse button. - pressed = true; - SetActiveID(id, window); - g.ActiveIdSource = ImGuiInputSource_Nav; - if (!(flags & ImGuiButtonFlags_NoNavFocus)) - SetFocusID(id, window); - } - } - - // Process while held - bool held = false; - if (g.ActiveId == id) - { - if (g.ActiveIdSource == ImGuiInputSource_Mouse) - { - if (g.ActiveIdIsJustActivated) - g.ActiveIdClickOffset = g.IO.MousePos - bb.Min; - - const int mouse_button = g.ActiveIdMouseButton; - IM_ASSERT(mouse_button >= 0 && mouse_button < ImGuiMouseButton_COUNT); - if (g.IO.MouseDown[mouse_button]) - { - held = true; - } - else - { - bool release_in = hovered && (flags & ImGuiButtonFlags_PressedOnClickRelease) != 0; - bool release_anywhere = (flags & ImGuiButtonFlags_PressedOnClickReleaseAnywhere) != 0; - if ((release_in || release_anywhere) && !g.DragDropActive) - { - // Report as pressed when releasing the mouse (this is the most common path) - bool is_double_click_release = (flags & ImGuiButtonFlags_PressedOnDoubleClick) && g.IO.MouseDownWasDoubleClick[mouse_button]; - bool is_repeating_already = (flags & ImGuiButtonFlags_Repeat) && g.IO.MouseDownDurationPrev[mouse_button] >= g.IO.KeyRepeatDelay; // Repeat mode trumps - if (!is_double_click_release && !is_repeating_already) - pressed = true; - } - ClearActiveID(); - } - if (!(flags & ImGuiButtonFlags_NoNavFocus)) - g.NavDisableHighlight = true; - } - else if (g.ActiveIdSource == ImGuiInputSource_Nav) - { - // When activated using Nav, we hold on the ActiveID until activation button is released - if (g.NavActivateDownId != id) - ClearActiveID(); - } - if (pressed) - g.ActiveIdHasBeenPressedBefore = true; - } - - if (out_hovered) *out_hovered = hovered; - if (out_held) *out_held = held; - - return pressed; -} - -bool ImGui::ButtonEx(const char* label, const ImVec2& size_arg, ImGuiButtonFlags flags) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - - ImGuiContext& g = *GImGui; - const ImGuiStyle& style = g.Style; - const ImGuiID id = window->GetID(label); - const ImVec2 label_size = CalcTextSize(label, NULL, true); - - ImVec2 pos = window->DC.CursorPos; - if ((flags & ImGuiButtonFlags_AlignTextBaseLine) && style.FramePadding.y < window->DC.CurrLineTextBaseOffset) // Try to vertically align buttons that are smaller/have no padding so that text baseline matches (bit hacky, since it shouldn't be a flag) - pos.y += window->DC.CurrLineTextBaseOffset - style.FramePadding.y; - ImVec2 size = CalcItemSize(size_arg, label_size.x + style.FramePadding.x * 2.0f, label_size.y + style.FramePadding.y * 2.0f); - - const ImRect bb(pos, pos + size); - ItemSize(size, style.FramePadding.y); - if (!ItemAdd(bb, id)) - return false; - - if (g.LastItemData.InFlags & ImGuiItemFlags_ButtonRepeat) - flags |= ImGuiButtonFlags_Repeat; - - bool hovered, held; - bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags); - - // Render - const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); - RenderNavHighlight(bb, id); - RenderFrame(bb.Min, bb.Max, col, true, style.FrameRounding); - - if (g.LogEnabled) - LogSetNextTextDecoration("[", "]"); - RenderTextClipped(bb.Min + style.FramePadding, bb.Max - style.FramePadding, label, NULL, &label_size, style.ButtonTextAlign, &bb); - - // Automatically close popups - //if (pressed && !(flags & ImGuiButtonFlags_DontClosePopups) && (window->Flags & ImGuiWindowFlags_Popup)) - // CloseCurrentPopup(); - - IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags); - return pressed; -} - -bool ImGui::Button(const char* label, const ImVec2& size_arg) -{ - return ButtonEx(label, size_arg, ImGuiButtonFlags_None); -} - -// Small buttons fits within text without additional vertical spacing. -bool ImGui::SmallButton(const char* label) -{ - ImGuiContext& g = *GImGui; - float backup_padding_y = g.Style.FramePadding.y; - g.Style.FramePadding.y = 0.0f; - bool pressed = ButtonEx(label, ImVec2(0, 0), ImGuiButtonFlags_AlignTextBaseLine); - g.Style.FramePadding.y = backup_padding_y; - return pressed; -} - -// Tip: use ImGui::PushID()/PopID() to push indices or pointers in the ID stack. -// Then you can keep 'str_id' empty or the same for all your buttons (instead of creating a string based on a non-string id) -bool ImGui::InvisibleButton(const char* str_id, const ImVec2& size_arg, ImGuiButtonFlags flags) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - - // Cannot use zero-size for InvisibleButton(). Unlike Button() there is not way to fallback using the label size. - IM_ASSERT(size_arg.x != 0.0f && size_arg.y != 0.0f); - - const ImGuiID id = window->GetID(str_id); - ImVec2 size = CalcItemSize(size_arg, 0.0f, 0.0f); - const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size); - ItemSize(size); - if (!ItemAdd(bb, id)) - return false; - - bool hovered, held; - bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags); - - return pressed; -} - -bool ImGui::ArrowButtonEx(const char* str_id, ImGuiDir dir, ImVec2 size, ImGuiButtonFlags flags) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - - ImGuiContext& g = *GImGui; - const ImGuiID id = window->GetID(str_id); - const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size); - const float default_size = GetFrameHeight(); - ItemSize(size, (size.y >= default_size) ? g.Style.FramePadding.y : -1.0f); - if (!ItemAdd(bb, id)) - return false; - - if (g.LastItemData.InFlags & ImGuiItemFlags_ButtonRepeat) - flags |= ImGuiButtonFlags_Repeat; - - bool hovered, held; - bool pressed = ButtonBehavior(bb, id, &hovered, &held, flags); - - // Render - const ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); - const ImU32 text_col = GetColorU32(ImGuiCol_Text); - RenderNavHighlight(bb, id); - RenderFrame(bb.Min, bb.Max, bg_col, true, g.Style.FrameRounding); - RenderArrow(window->DrawList, bb.Min + ImVec2(ImMax(0.0f, (size.x - g.FontSize) * 0.5f), ImMax(0.0f, (size.y - g.FontSize) * 0.5f)), text_col, dir); - - return pressed; -} - -bool ImGui::ArrowButton(const char* str_id, ImGuiDir dir) -{ - float sz = GetFrameHeight(); - return ArrowButtonEx(str_id, dir, ImVec2(sz, sz), ImGuiButtonFlags_None); -} - -// Button to close a window -bool ImGui::CloseButton(ImGuiID id, const ImVec2& pos) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - - // Tweak 1: Shrink hit-testing area if button covers an abnormally large proportion of the visible region. That's in order to facilitate moving the window away. (#3825) - // This may better be applied as a general hit-rect reduction mechanism for all widgets to ensure the area to move window is always accessible? - const ImRect bb(pos, pos + ImVec2(g.FontSize, g.FontSize) + g.Style.FramePadding * 2.0f); - ImRect bb_interact = bb; - const float area_to_visible_ratio = window->OuterRectClipped.GetArea() / bb.GetArea(); - if (area_to_visible_ratio < 1.5f) - bb_interact.Expand(ImFloor(bb_interact.GetSize() * -0.25f)); - - // Tweak 2: We intentionally allow interaction when clipped so that a mechanical Alt,Right,Activate sequence can always close a window. - // (this isn't the regular behavior of buttons, but it doesn't affect the user much because navigation tends to keep items visible). - bool is_clipped = !ItemAdd(bb_interact, id); - - bool hovered, held; - bool pressed = ButtonBehavior(bb_interact, id, &hovered, &held); - if (is_clipped) - return pressed; - - // Render - // FIXME: Clarify this mess - ImU32 col = GetColorU32(held ? ImGuiCol_ButtonActive : ImGuiCol_ButtonHovered); - ImVec2 center = bb.GetCenter(); - if (hovered) - window->DrawList->AddCircleFilled(center, ImMax(2.0f, g.FontSize * 0.5f + 1.0f), col, 12); - - float cross_extent = g.FontSize * 0.5f * 0.7071f - 1.0f; - ImU32 cross_col = GetColorU32(ImGuiCol_Text); - center -= ImVec2(0.5f, 0.5f); - window->DrawList->AddLine(center + ImVec2(+cross_extent, +cross_extent), center + ImVec2(-cross_extent, -cross_extent), cross_col, 1.0f); - window->DrawList->AddLine(center + ImVec2(+cross_extent, -cross_extent), center + ImVec2(-cross_extent, +cross_extent), cross_col, 1.0f); - - return pressed; -} - -bool ImGui::CollapseButton(ImGuiID id, const ImVec2& pos) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - - ImRect bb(pos, pos + ImVec2(g.FontSize, g.FontSize) + g.Style.FramePadding * 2.0f); - ItemAdd(bb, id); - bool hovered, held; - bool pressed = ButtonBehavior(bb, id, &hovered, &held, ImGuiButtonFlags_None); - - // Render - ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); - ImU32 text_col = GetColorU32(ImGuiCol_Text); - ImVec2 center = bb.GetCenter(); - if (hovered || held) - window->DrawList->AddCircleFilled(center/*+ ImVec2(0.0f, -0.5f)*/, g.FontSize * 0.5f + 1.0f, bg_col, 12); - RenderArrow(window->DrawList, bb.Min + g.Style.FramePadding, text_col, window->Collapsed ? ImGuiDir_Right : ImGuiDir_Down, 1.0f); - - // Switch to moving the window after mouse is moved beyond the initial drag threshold - if (IsItemActive() && IsMouseDragging(0)) - StartMouseMovingWindow(window); - - return pressed; -} - -ImGuiID ImGui::GetWindowScrollbarID(ImGuiWindow* window, ImGuiAxis axis) -{ - return window->GetIDNoKeepAlive(axis == ImGuiAxis_X ? "#SCROLLX" : "#SCROLLY"); -} - -// Return scrollbar rectangle, must only be called for corresponding axis if window->ScrollbarX/Y is set. -ImRect ImGui::GetWindowScrollbarRect(ImGuiWindow* window, ImGuiAxis axis) -{ - const ImRect outer_rect = window->Rect(); - const ImRect inner_rect = window->InnerRect; - const float border_size = window->WindowBorderSize; - const float scrollbar_size = window->ScrollbarSizes[axis ^ 1]; // (ScrollbarSizes.x = width of Y scrollbar; ScrollbarSizes.y = height of X scrollbar) - IM_ASSERT(scrollbar_size > 0.0f); - if (axis == ImGuiAxis_X) - return ImRect(inner_rect.Min.x, ImMax(outer_rect.Min.y, outer_rect.Max.y - border_size - scrollbar_size), inner_rect.Max.x, outer_rect.Max.y); - else - return ImRect(ImMax(outer_rect.Min.x, outer_rect.Max.x - border_size - scrollbar_size), inner_rect.Min.y, outer_rect.Max.x, inner_rect.Max.y); -} - -void ImGui::Scrollbar(ImGuiAxis axis) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - - const ImGuiID id = GetWindowScrollbarID(window, axis); - KeepAliveID(id); - - // Calculate scrollbar bounding box - ImRect bb = GetWindowScrollbarRect(window, axis); - ImDrawFlags rounding_corners = ImDrawFlags_RoundCornersNone; - if (axis == ImGuiAxis_X) - { - rounding_corners |= ImDrawFlags_RoundCornersBottomLeft; - if (!window->ScrollbarY) - rounding_corners |= ImDrawFlags_RoundCornersBottomRight; - } - else - { - if ((window->Flags & ImGuiWindowFlags_NoTitleBar) && !(window->Flags & ImGuiWindowFlags_MenuBar)) - rounding_corners |= ImDrawFlags_RoundCornersTopRight; - if (!window->ScrollbarX) - rounding_corners |= ImDrawFlags_RoundCornersBottomRight; - } - float size_avail = window->InnerRect.Max[axis] - window->InnerRect.Min[axis]; - float size_contents = window->ContentSize[axis] + window->WindowPadding[axis] * 2.0f; - ScrollbarEx(bb, id, axis, &window->Scroll[axis], size_avail, size_contents, rounding_corners); -} - -// Vertical/Horizontal scrollbar -// The entire piece of code below is rather confusing because: -// - We handle absolute seeking (when first clicking outside the grab) and relative manipulation (afterward or when clicking inside the grab) -// - We store values as normalized ratio and in a form that allows the window content to change while we are holding on a scrollbar -// - We handle both horizontal and vertical scrollbars, which makes the terminology not ideal. -// Still, the code should probably be made simpler.. -bool ImGui::ScrollbarEx(const ImRect& bb_frame, ImGuiID id, ImGuiAxis axis, float* p_scroll_v, float size_avail_v, float size_contents_v, ImDrawFlags flags) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - if (window->SkipItems) - return false; - - const float bb_frame_width = bb_frame.GetWidth(); - const float bb_frame_height = bb_frame.GetHeight(); - if (bb_frame_width <= 0.0f || bb_frame_height <= 0.0f) - return false; - - // When we are too small, start hiding and disabling the grab (this reduce visual noise on very small window and facilitate using the window resize grab) - float alpha = 1.0f; - if ((axis == ImGuiAxis_Y) && bb_frame_height < g.FontSize + g.Style.FramePadding.y * 2.0f) - alpha = ImSaturate((bb_frame_height - g.FontSize) / (g.Style.FramePadding.y * 2.0f)); - if (alpha <= 0.0f) - return false; - - const ImGuiStyle& style = g.Style; - const bool allow_interaction = (alpha >= 1.0f); - - ImRect bb = bb_frame; - bb.Expand(ImVec2(-ImClamp(IM_FLOOR((bb_frame_width - 2.0f) * 0.5f), 0.0f, 3.0f), -ImClamp(IM_FLOOR((bb_frame_height - 2.0f) * 0.5f), 0.0f, 3.0f))); - - // V denote the main, longer axis of the scrollbar (= height for a vertical scrollbar) - const float scrollbar_size_v = (axis == ImGuiAxis_X) ? bb.GetWidth() : bb.GetHeight(); - - // Calculate the height of our grabbable box. It generally represent the amount visible (vs the total scrollable amount) - // But we maintain a minimum size in pixel to allow for the user to still aim inside. - IM_ASSERT(ImMax(size_contents_v, size_avail_v) > 0.0f); // Adding this assert to check if the ImMax(XXX,1.0f) is still needed. PLEASE CONTACT ME if this triggers. - const float win_size_v = ImMax(ImMax(size_contents_v, size_avail_v), 1.0f); - const float grab_h_pixels = ImClamp(scrollbar_size_v * (size_avail_v / win_size_v), style.GrabMinSize, scrollbar_size_v); - const float grab_h_norm = grab_h_pixels / scrollbar_size_v; - - // Handle input right away. None of the code of Begin() is relying on scrolling position before calling Scrollbar(). - bool held = false; - bool hovered = false; - ButtonBehavior(bb, id, &hovered, &held, ImGuiButtonFlags_NoNavFocus); - - float scroll_max = ImMax(1.0f, size_contents_v - size_avail_v); - float scroll_ratio = ImSaturate(*p_scroll_v / scroll_max); - float grab_v_norm = scroll_ratio * (scrollbar_size_v - grab_h_pixels) / scrollbar_size_v; // Grab position in normalized space - if (held && allow_interaction && grab_h_norm < 1.0f) - { - float scrollbar_pos_v = bb.Min[axis]; - float mouse_pos_v = g.IO.MousePos[axis]; - - // Click position in scrollbar normalized space (0.0f->1.0f) - const float clicked_v_norm = ImSaturate((mouse_pos_v - scrollbar_pos_v) / scrollbar_size_v); - SetHoveredID(id); - - bool seek_absolute = false; - if (g.ActiveIdIsJustActivated) - { - // On initial click calculate the distance between mouse and the center of the grab - seek_absolute = (clicked_v_norm < grab_v_norm || clicked_v_norm > grab_v_norm + grab_h_norm); - if (seek_absolute) - g.ScrollbarClickDeltaToGrabCenter = 0.0f; - else - g.ScrollbarClickDeltaToGrabCenter = clicked_v_norm - grab_v_norm - grab_h_norm * 0.5f; - } - - // Apply scroll (p_scroll_v will generally point on one member of window->Scroll) - // It is ok to modify Scroll here because we are being called in Begin() after the calculation of ContentSize and before setting up our starting position - const float scroll_v_norm = ImSaturate((clicked_v_norm - g.ScrollbarClickDeltaToGrabCenter - grab_h_norm * 0.5f) / (1.0f - grab_h_norm)); - *p_scroll_v = IM_ROUND(scroll_v_norm * scroll_max);//(win_size_contents_v - win_size_v)); - - // Update values for rendering - scroll_ratio = ImSaturate(*p_scroll_v / scroll_max); - grab_v_norm = scroll_ratio * (scrollbar_size_v - grab_h_pixels) / scrollbar_size_v; - - // Update distance to grab now that we have seeked and saturated - if (seek_absolute) - g.ScrollbarClickDeltaToGrabCenter = clicked_v_norm - grab_v_norm - grab_h_norm * 0.5f; - } - - // Render - const ImU32 bg_col = GetColorU32(ImGuiCol_ScrollbarBg); - const ImU32 grab_col = GetColorU32(held ? ImGuiCol_ScrollbarGrabActive : hovered ? ImGuiCol_ScrollbarGrabHovered : ImGuiCol_ScrollbarGrab, alpha); - window->DrawList->AddRectFilled(bb_frame.Min, bb_frame.Max, bg_col, window->WindowRounding, flags); - ImRect grab_rect; - if (axis == ImGuiAxis_X) - grab_rect = ImRect(ImLerp(bb.Min.x, bb.Max.x, grab_v_norm), bb.Min.y, ImLerp(bb.Min.x, bb.Max.x, grab_v_norm) + grab_h_pixels, bb.Max.y); - else - grab_rect = ImRect(bb.Min.x, ImLerp(bb.Min.y, bb.Max.y, grab_v_norm), bb.Max.x, ImLerp(bb.Min.y, bb.Max.y, grab_v_norm) + grab_h_pixels); - window->DrawList->AddRectFilled(grab_rect.Min, grab_rect.Max, grab_col, style.ScrollbarRounding); - - return held; -} - -void ImGui::Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, const ImVec4& tint_col, const ImVec4& border_col) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return; - - ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size); - if (border_col.w > 0.0f) - bb.Max += ImVec2(2, 2); - ItemSize(bb); - if (!ItemAdd(bb, 0)) - return; - - if (border_col.w > 0.0f) - { - window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(border_col), 0.0f); - window->DrawList->AddImage(user_texture_id, bb.Min + ImVec2(1, 1), bb.Max - ImVec2(1, 1), uv0, uv1, GetColorU32(tint_col)); - } - else - { - window->DrawList->AddImage(user_texture_id, bb.Min, bb.Max, uv0, uv1, GetColorU32(tint_col)); - } -} - -// ImageButton() is flawed as 'id' is always derived from 'texture_id' (see #2464 #1390) -// We provide this internal helper to write your own variant while we figure out how to redesign the public ImageButton() API. -bool ImGui::ImageButtonEx(ImGuiID id, ImTextureID texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, const ImVec2& padding, const ImVec4& bg_col, const ImVec4& tint_col) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - - const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size + padding * 2); - ItemSize(bb); - if (!ItemAdd(bb, id)) - return false; - - bool hovered, held; - bool pressed = ButtonBehavior(bb, id, &hovered, &held); - - // Render - const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); - RenderNavHighlight(bb, id); - RenderFrame(bb.Min, bb.Max, col, true, ImClamp((float)ImMin(padding.x, padding.y), 0.0f, g.Style.FrameRounding)); - if (bg_col.w > 0.0f) - window->DrawList->AddRectFilled(bb.Min + padding, bb.Max - padding, GetColorU32(bg_col)); - window->DrawList->AddImage(texture_id, bb.Min + padding, bb.Max - padding, uv0, uv1, GetColorU32(tint_col)); - - return pressed; -} - -// frame_padding < 0: uses FramePadding from style (default) -// frame_padding = 0: no framing -// frame_padding > 0: set framing size -bool ImGui::ImageButton(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0, const ImVec2& uv1, int frame_padding, const ImVec4& bg_col, const ImVec4& tint_col) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - if (window->SkipItems) - return false; - - // Default to using texture ID as ID. User can still push string/integer prefixes. - PushID((void*)(intptr_t)user_texture_id); - const ImGuiID id = window->GetID("#image"); - PopID(); - - const ImVec2 padding = (frame_padding >= 0) ? ImVec2((float)frame_padding, (float)frame_padding) : g.Style.FramePadding; - return ImageButtonEx(id, user_texture_id, size, uv0, uv1, padding, bg_col, tint_col); -} - -bool ImGui::Checkbox(const char* label, bool* v) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - - ImGuiContext& g = *GImGui; - const ImGuiStyle& style = g.Style; - const ImGuiID id = window->GetID(label); - const ImVec2 label_size = CalcTextSize(label, NULL, true); - - const float square_sz = GetFrameHeight(); - const ImVec2 pos = window->DC.CursorPos; - const ImRect total_bb(pos, pos + ImVec2(square_sz + (label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f), label_size.y + style.FramePadding.y * 2.0f)); - ItemSize(total_bb, style.FramePadding.y); - if (!ItemAdd(total_bb, id)) - { - IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Checkable | (*v ? ImGuiItemStatusFlags_Checked : 0)); - return false; - } - - bool hovered, held; - bool pressed = ButtonBehavior(total_bb, id, &hovered, &held); - if (pressed) - { - *v = !(*v); - MarkItemEdited(id); - } - - const ImRect check_bb(pos, pos + ImVec2(square_sz, square_sz)); - RenderNavHighlight(total_bb, id); - RenderFrame(check_bb.Min, check_bb.Max, GetColorU32((held && hovered) ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg), true, style.FrameRounding); - ImU32 check_col = GetColorU32(ImGuiCol_CheckMark); - bool mixed_value = (g.LastItemData.InFlags & ImGuiItemFlags_MixedValue) != 0; - if (mixed_value) - { - // Undocumented tristate/mixed/indeterminate checkbox (#2644) - // This may seem awkwardly designed because the aim is to make ImGuiItemFlags_MixedValue supported by all widgets (not just checkbox) - ImVec2 pad(ImMax(1.0f, IM_FLOOR(square_sz / 3.6f)), ImMax(1.0f, IM_FLOOR(square_sz / 3.6f))); - window->DrawList->AddRectFilled(check_bb.Min + pad, check_bb.Max - pad, check_col, style.FrameRounding); - } - else if (*v) - { - const float pad = ImMax(1.0f, IM_FLOOR(square_sz / 6.0f)); - RenderCheckMark(window->DrawList, check_bb.Min + ImVec2(pad, pad), check_col, square_sz - pad * 2.0f); - } - - ImVec2 label_pos = ImVec2(check_bb.Max.x + style.ItemInnerSpacing.x, check_bb.Min.y + style.FramePadding.y); - if (g.LogEnabled) - LogRenderedText(&label_pos, mixed_value ? "[~]" : *v ? "[x]" : "[ ]"); - if (label_size.x > 0.0f) - RenderText(label_pos, label); - - IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Checkable | (*v ? ImGuiItemStatusFlags_Checked : 0)); - return pressed; -} - -template -bool ImGui::CheckboxFlagsT(const char* label, T* flags, T flags_value) -{ - bool all_on = (*flags & flags_value) == flags_value; - bool any_on = (*flags & flags_value) != 0; - bool pressed; - if (!all_on && any_on) - { - ImGuiContext& g = *GImGui; - ImGuiItemFlags backup_item_flags = g.CurrentItemFlags; - g.CurrentItemFlags |= ImGuiItemFlags_MixedValue; - pressed = Checkbox(label, &all_on); - g.CurrentItemFlags = backup_item_flags; - } - else - { - pressed = Checkbox(label, &all_on); - - } - if (pressed) - { - if (all_on) - *flags |= flags_value; - else - *flags &= ~flags_value; - } - return pressed; -} - -bool ImGui::CheckboxFlags(const char* label, int* flags, int flags_value) -{ - return CheckboxFlagsT(label, flags, flags_value); -} - -bool ImGui::CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value) -{ - return CheckboxFlagsT(label, flags, flags_value); -} - -bool ImGui::CheckboxFlags(const char* label, ImS64* flags, ImS64 flags_value) -{ - return CheckboxFlagsT(label, flags, flags_value); -} - -bool ImGui::CheckboxFlags(const char* label, ImU64* flags, ImU64 flags_value) -{ - return CheckboxFlagsT(label, flags, flags_value); -} - -bool ImGui::RadioButton(const char* label, bool active) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - - ImGuiContext& g = *GImGui; - const ImGuiStyle& style = g.Style; - const ImGuiID id = window->GetID(label); - const ImVec2 label_size = CalcTextSize(label, NULL, true); - - const float square_sz = GetFrameHeight(); - const ImVec2 pos = window->DC.CursorPos; - const ImRect check_bb(pos, pos + ImVec2(square_sz, square_sz)); - const ImRect total_bb(pos, pos + ImVec2(square_sz + (label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f), label_size.y + style.FramePadding.y * 2.0f)); - ItemSize(total_bb, style.FramePadding.y); - if (!ItemAdd(total_bb, id)) - return false; - - ImVec2 center = check_bb.GetCenter(); - center.x = IM_ROUND(center.x); - center.y = IM_ROUND(center.y); - const float radius = (square_sz - 1.0f) * 0.5f; - - bool hovered, held; - bool pressed = ButtonBehavior(total_bb, id, &hovered, &held); - if (pressed) - MarkItemEdited(id); - - RenderNavHighlight(total_bb, id); - window->DrawList->AddCircleFilled(center, radius, GetColorU32((held && hovered) ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg), 16); - if (active) - { - const float pad = ImMax(1.0f, IM_FLOOR(square_sz / 6.0f)); - window->DrawList->AddCircleFilled(center, radius - pad, GetColorU32(ImGuiCol_CheckMark), 16); - } - - if (style.FrameBorderSize > 0.0f) - { - window->DrawList->AddCircle(center + ImVec2(1, 1), radius, GetColorU32(ImGuiCol_BorderShadow), 16, style.FrameBorderSize); - window->DrawList->AddCircle(center, radius, GetColorU32(ImGuiCol_Border), 16, style.FrameBorderSize); - } - - ImVec2 label_pos = ImVec2(check_bb.Max.x + style.ItemInnerSpacing.x, check_bb.Min.y + style.FramePadding.y); - if (g.LogEnabled) - LogRenderedText(&label_pos, active ? "(x)" : "( )"); - if (label_size.x > 0.0f) - RenderText(label_pos, label); - - IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags); - return pressed; -} - -// FIXME: This would work nicely if it was a public template, e.g. 'template RadioButton(const char* label, T* v, T v_button)', but I'm not sure how we would expose it.. -bool ImGui::RadioButton(const char* label, int* v, int v_button) -{ - const bool pressed = RadioButton(label, *v == v_button); - if (pressed) - *v = v_button; - return pressed; -} - -// size_arg (for each axis) < 0.0f: align to end, 0.0f: auto, > 0.0f: specified size -void ImGui::ProgressBar(float fraction, const ImVec2& size_arg, const char* overlay) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return; - - ImGuiContext& g = *GImGui; - const ImGuiStyle& style = g.Style; - - ImVec2 pos = window->DC.CursorPos; - ImVec2 size = CalcItemSize(size_arg, CalcItemWidth(), g.FontSize + style.FramePadding.y * 2.0f); - ImRect bb(pos, pos + size); - ItemSize(size, style.FramePadding.y); - if (!ItemAdd(bb, 0)) - return; - - // Render - fraction = ImSaturate(fraction); - RenderFrame(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding); - bb.Expand(ImVec2(-style.FrameBorderSize, -style.FrameBorderSize)); - const ImVec2 fill_br = ImVec2(ImLerp(bb.Min.x, bb.Max.x, fraction), bb.Max.y); - RenderRectFilledRangeH(window->DrawList, bb, GetColorU32(ImGuiCol_PlotHistogram), 0.0f, fraction, style.FrameRounding); - - // Default displaying the fraction as percentage string, but user can override it - char overlay_buf[32]; - if (!overlay) - { - ImFormatString(overlay_buf, IM_ARRAYSIZE(overlay_buf), "%.0f%%", fraction * 100 + 0.01f); - overlay = overlay_buf; - } - - ImVec2 overlay_size = CalcTextSize(overlay, NULL); - if (overlay_size.x > 0.0f) - RenderTextClipped(ImVec2(ImClamp(fill_br.x + style.ItemSpacing.x, bb.Min.x, bb.Max.x - overlay_size.x - style.ItemInnerSpacing.x), bb.Min.y), bb.Max, overlay, NULL, &overlay_size, ImVec2(0.0f, 0.5f), &bb); -} - -void ImGui::Bullet() -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return; - - ImGuiContext& g = *GImGui; - const ImGuiStyle& style = g.Style; - const float line_height = ImMax(ImMin(window->DC.CurrLineSize.y, g.FontSize + g.Style.FramePadding.y * 2), g.FontSize); - const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(g.FontSize, line_height)); - ItemSize(bb); - if (!ItemAdd(bb, 0)) - { - SameLine(0, style.FramePadding.x * 2); - return; - } - - // Render and stay on same line - ImU32 text_col = GetColorU32(ImGuiCol_Text); - RenderBullet(window->DrawList, bb.Min + ImVec2(style.FramePadding.x + g.FontSize * 0.5f, line_height * 0.5f), text_col); - SameLine(0, style.FramePadding.x * 2.0f); -} - -//------------------------------------------------------------------------- -// [SECTION] Widgets: Low-level Layout helpers -//------------------------------------------------------------------------- -// - Spacing() -// - Dummy() -// - NewLine() -// - AlignTextToFramePadding() -// - SeparatorEx() [Internal] -// - Separator() -// - SplitterBehavior() [Internal] -// - ShrinkWidths() [Internal] -//------------------------------------------------------------------------- - -void ImGui::Spacing() -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return; - ItemSize(ImVec2(0, 0)); -} - -void ImGui::Dummy(const ImVec2& size) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return; - - const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size); - ItemSize(size); - ItemAdd(bb, 0); -} - -void ImGui::NewLine() -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return; - - ImGuiContext& g = *GImGui; - const ImGuiLayoutType backup_layout_type = window->DC.LayoutType; - window->DC.LayoutType = ImGuiLayoutType_Vertical; - if (window->DC.CurrLineSize.y > 0.0f) // In the event that we are on a line with items that is smaller that FontSize high, we will preserve its height. - ItemSize(ImVec2(0, 0)); - else - ItemSize(ImVec2(0.0f, g.FontSize)); - window->DC.LayoutType = backup_layout_type; -} - -void ImGui::AlignTextToFramePadding() -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return; - - ImGuiContext& g = *GImGui; - window->DC.CurrLineSize.y = ImMax(window->DC.CurrLineSize.y, g.FontSize + g.Style.FramePadding.y * 2); - window->DC.CurrLineTextBaseOffset = ImMax(window->DC.CurrLineTextBaseOffset, g.Style.FramePadding.y); -} - -// Horizontal/vertical separating line -void ImGui::SeparatorEx(ImGuiSeparatorFlags flags) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return; - - ImGuiContext& g = *GImGui; - IM_ASSERT(ImIsPowerOfTwo(flags & (ImGuiSeparatorFlags_Horizontal | ImGuiSeparatorFlags_Vertical))); // Check that only 1 option is selected - - float thickness_draw = 1.0f; - float thickness_layout = 0.0f; - if (flags & ImGuiSeparatorFlags_Vertical) - { - // Vertical separator, for menu bars (use current line height). Not exposed because it is misleading and it doesn't have an effect on regular layout. - float y1 = window->DC.CursorPos.y; - float y2 = window->DC.CursorPos.y + window->DC.CurrLineSize.y; - const ImRect bb(ImVec2(window->DC.CursorPos.x, y1), ImVec2(window->DC.CursorPos.x + thickness_draw, y2)); - ItemSize(ImVec2(thickness_layout, 0.0f)); - if (!ItemAdd(bb, 0)) - return; - - // Draw - window->DrawList->AddLine(ImVec2(bb.Min.x, bb.Min.y), ImVec2(bb.Min.x, bb.Max.y), GetColorU32(ImGuiCol_Separator)); - if (g.LogEnabled) - LogText(" |"); - } - else if (flags & ImGuiSeparatorFlags_Horizontal) - { - // Horizontal Separator - float x1 = window->Pos.x; - float x2 = window->Pos.x + window->Size.x; - - // FIXME-WORKRECT: old hack (#205) until we decide of consistent behavior with WorkRect/Indent and Separator - if (g.GroupStack.Size > 0 && g.GroupStack.back().WindowID == window->ID) - x1 += window->DC.Indent.x; - - ImGuiOldColumns* columns = (flags & ImGuiSeparatorFlags_SpanAllColumns) ? window->DC.CurrentColumns : NULL; - if (columns) - PushColumnsBackground(); - - // We don't provide our width to the layout so that it doesn't get feed back into AutoFit - const ImRect bb(ImVec2(x1, window->DC.CursorPos.y), ImVec2(x2, window->DC.CursorPos.y + thickness_draw)); - ItemSize(ImVec2(0.0f, thickness_layout)); - const bool item_visible = ItemAdd(bb, 0); - if (item_visible) - { - // Draw - window->DrawList->AddLine(bb.Min, ImVec2(bb.Max.x, bb.Min.y), GetColorU32(ImGuiCol_Separator)); - if (g.LogEnabled) - LogRenderedText(&bb.Min, "--------------------------------\n"); - - } - if (columns) - { - PopColumnsBackground(); - columns->LineMinY = window->DC.CursorPos.y; - } - } -} - -void ImGui::Separator() -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - if (window->SkipItems) - return; - - // Those flags should eventually be overridable by the user - ImGuiSeparatorFlags flags = (window->DC.LayoutType == ImGuiLayoutType_Horizontal) ? ImGuiSeparatorFlags_Vertical : ImGuiSeparatorFlags_Horizontal; - flags |= ImGuiSeparatorFlags_SpanAllColumns; - SeparatorEx(flags); -} - -// Using 'hover_visibility_delay' allows us to hide the highlight and mouse cursor for a short time, which can be convenient to reduce visual noise. -bool ImGui::SplitterBehavior(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float* size1, float* size2, float min_size1, float min_size2, float hover_extend, float hover_visibility_delay) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - - const ImGuiItemFlags item_flags_backup = g.CurrentItemFlags; - g.CurrentItemFlags |= ImGuiItemFlags_NoNav | ImGuiItemFlags_NoNavDefaultFocus; - bool item_add = ItemAdd(bb, id); - g.CurrentItemFlags = item_flags_backup; - if (!item_add) - return false; - - bool hovered, held; - ImRect bb_interact = bb; - bb_interact.Expand(axis == ImGuiAxis_Y ? ImVec2(0.0f, hover_extend) : ImVec2(hover_extend, 0.0f)); - ButtonBehavior(bb_interact, id, &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_AllowItemOverlap); - if (hovered) - g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HoveredRect; // for IsItemHovered(), because bb_interact is larger than bb - if (g.ActiveId != id) - SetItemAllowOverlap(); - - if (held || (hovered && g.HoveredIdPreviousFrame == id && g.HoveredIdTimer >= hover_visibility_delay)) - SetMouseCursor(axis == ImGuiAxis_Y ? ImGuiMouseCursor_ResizeNS : ImGuiMouseCursor_ResizeEW); - - ImRect bb_render = bb; - if (held) - { - ImVec2 mouse_delta_2d = g.IO.MousePos - g.ActiveIdClickOffset - bb_interact.Min; - float mouse_delta = (axis == ImGuiAxis_Y) ? mouse_delta_2d.y : mouse_delta_2d.x; - - // Minimum pane size - float size_1_maximum_delta = ImMax(0.0f, *size1 - min_size1); - float size_2_maximum_delta = ImMax(0.0f, *size2 - min_size2); - if (mouse_delta < -size_1_maximum_delta) - mouse_delta = -size_1_maximum_delta; - if (mouse_delta > size_2_maximum_delta) - mouse_delta = size_2_maximum_delta; - - // Apply resize - if (mouse_delta != 0.0f) - { - if (mouse_delta < 0.0f) - IM_ASSERT(*size1 + mouse_delta >= min_size1); - if (mouse_delta > 0.0f) - IM_ASSERT(*size2 - mouse_delta >= min_size2); - *size1 += mouse_delta; - *size2 -= mouse_delta; - bb_render.Translate((axis == ImGuiAxis_X) ? ImVec2(mouse_delta, 0.0f) : ImVec2(0.0f, mouse_delta)); - MarkItemEdited(id); - } - } - - // Render - const ImU32 col = GetColorU32(held ? ImGuiCol_SeparatorActive : (hovered && g.HoveredIdTimer >= hover_visibility_delay) ? ImGuiCol_SeparatorHovered : ImGuiCol_Separator); - window->DrawList->AddRectFilled(bb_render.Min, bb_render.Max, col, 0.0f); - - return held; -} - -static int IMGUI_CDECL ShrinkWidthItemComparer(const void* lhs, const void* rhs) -{ - const ImGuiShrinkWidthItem* a = (const ImGuiShrinkWidthItem*)lhs; - const ImGuiShrinkWidthItem* b = (const ImGuiShrinkWidthItem*)rhs; - if (int d = (int)(b->Width - a->Width)) - return d; - return (b->Index - a->Index); -} - -// Shrink excess width from a set of item, by removing width from the larger items first. -// Set items Width to -1.0f to disable shrinking this item. -void ImGui::ShrinkWidths(ImGuiShrinkWidthItem* items, int count, float width_excess) -{ - if (count == 1) - { - if (items[0].Width >= 0.0f) - items[0].Width = ImMax(items[0].Width - width_excess, 1.0f); - return; - } - ImQsort(items, (size_t)count, sizeof(ImGuiShrinkWidthItem), ShrinkWidthItemComparer); - int count_same_width = 1; - while (width_excess > 0.0f && count_same_width < count) - { - while (count_same_width < count && items[0].Width <= items[count_same_width].Width) - count_same_width++; - float max_width_to_remove_per_item = (count_same_width < count && items[count_same_width].Width >= 0.0f) ? (items[0].Width - items[count_same_width].Width) : (items[0].Width - 1.0f); - if (max_width_to_remove_per_item <= 0.0f) - break; - float width_to_remove_per_item = ImMin(width_excess / count_same_width, max_width_to_remove_per_item); - for (int item_n = 0; item_n < count_same_width; item_n++) - items[item_n].Width -= width_to_remove_per_item; - width_excess -= width_to_remove_per_item * count_same_width; - } - - // Round width and redistribute remainder left-to-right (could make it an option of the function?) - // Ensure that e.g. the right-most tab of a shrunk tab-bar always reaches exactly at the same distance from the right-most edge of the tab bar separator. - width_excess = 0.0f; - for (int n = 0; n < count; n++) - { - float width_rounded = ImFloor(items[n].Width); - width_excess += items[n].Width - width_rounded; - items[n].Width = width_rounded; - } - if (width_excess > 0.0f) - for (int n = 0; n < count; n++) - if (items[n].Index < (int)(width_excess + 0.01f)) - items[n].Width += 1.0f; -} - -//------------------------------------------------------------------------- -// [SECTION] Widgets: ComboBox -//------------------------------------------------------------------------- -// - CalcMaxPopupHeightFromItemCount() [Internal] -// - BeginCombo() -// - BeginComboPopup() [Internal] -// - EndCombo() -// - BeginComboPreview() [Internal] -// - EndComboPreview() [Internal] -// - Combo() -//------------------------------------------------------------------------- - -static float CalcMaxPopupHeightFromItemCount(int items_count) -{ - ImGuiContext& g = *GImGui; - if (items_count <= 0) - return FLT_MAX; - return (g.FontSize + g.Style.ItemSpacing.y) * items_count - g.Style.ItemSpacing.y + (g.Style.WindowPadding.y * 2); -} - -bool ImGui::BeginCombo(const char* label, const char* preview_value, ImGuiComboFlags flags) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = GetCurrentWindow(); - - ImGuiNextWindowDataFlags backup_next_window_data_flags = g.NextWindowData.Flags; - g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values - if (window->SkipItems) - return false; - - const ImGuiStyle& style = g.Style; - const ImGuiID id = window->GetID(label); - IM_ASSERT((flags & (ImGuiComboFlags_NoArrowButton | ImGuiComboFlags_NoPreview)) != (ImGuiComboFlags_NoArrowButton | ImGuiComboFlags_NoPreview)); // Can't use both flags together - - const float arrow_size = (flags & ImGuiComboFlags_NoArrowButton) ? 0.0f : GetFrameHeight(); - const ImVec2 label_size = CalcTextSize(label, NULL, true); - const float w = (flags & ImGuiComboFlags_NoPreview) ? arrow_size : CalcItemWidth(); - const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y * 2.0f)); - const ImRect total_bb(bb.Min, bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f)); - ItemSize(total_bb, style.FramePadding.y); - if (!ItemAdd(total_bb, id, &bb)) - return false; - - // Open on click - bool hovered, held; - bool pressed = ButtonBehavior(bb, id, &hovered, &held); - const ImGuiID popup_id = ImHashStr("##ComboPopup", 0, id); - bool popup_open = IsPopupOpen(popup_id, ImGuiPopupFlags_None); - if (pressed && !popup_open) - { - OpenPopupEx(popup_id, ImGuiPopupFlags_None); - popup_open = true; - } - - // Render shape - const ImU32 frame_col = GetColorU32(hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg); - const float value_x2 = ImMax(bb.Min.x, bb.Max.x - arrow_size); - RenderNavHighlight(bb, id); - if (!(flags & ImGuiComboFlags_NoPreview)) - window->DrawList->AddRectFilled(bb.Min, ImVec2(value_x2, bb.Max.y), frame_col, style.FrameRounding, (flags & ImGuiComboFlags_NoArrowButton) ? ImDrawFlags_RoundCornersAll : ImDrawFlags_RoundCornersLeft); - if (!(flags & ImGuiComboFlags_NoArrowButton)) - { - ImU32 bg_col = GetColorU32((popup_open || hovered) ? ImGuiCol_ButtonHovered : ImGuiCol_Button); - ImU32 text_col = GetColorU32(ImGuiCol_Text); - window->DrawList->AddRectFilled(ImVec2(value_x2, bb.Min.y), bb.Max, bg_col, style.FrameRounding, (w <= arrow_size) ? ImDrawFlags_RoundCornersAll : ImDrawFlags_RoundCornersRight); - if (value_x2 + arrow_size - style.FramePadding.x <= bb.Max.x) - RenderArrow(window->DrawList, ImVec2(value_x2 + style.FramePadding.y, bb.Min.y + style.FramePadding.y), text_col, ImGuiDir_Down, 1.0f); - } - RenderFrameBorder(bb.Min, bb.Max, style.FrameRounding); - - // Custom preview - if (flags & ImGuiComboFlags_CustomPreview) - { - g.ComboPreviewData.PreviewRect = ImRect(bb.Min.x, bb.Min.y, value_x2, bb.Max.y); - IM_ASSERT(preview_value == NULL || preview_value[0] == 0); - preview_value = NULL; - } - - // Render preview and label - if (preview_value != NULL && !(flags & ImGuiComboFlags_NoPreview)) - { - if (g.LogEnabled) - LogSetNextTextDecoration("{", "}"); - RenderTextClipped(bb.Min + style.FramePadding, ImVec2(value_x2, bb.Max.y), preview_value, NULL, NULL); - } - if (label_size.x > 0) - RenderText(ImVec2(bb.Max.x + style.ItemInnerSpacing.x, bb.Min.y + style.FramePadding.y), label); - - if (!popup_open) - return false; - - g.NextWindowData.Flags = backup_next_window_data_flags; - return BeginComboPopup(popup_id, bb, flags); -} - -bool ImGui::BeginComboPopup(ImGuiID popup_id, const ImRect& bb, ImGuiComboFlags flags) -{ - ImGuiContext& g = *GImGui; - if (!IsPopupOpen(popup_id, ImGuiPopupFlags_None)) - { - g.NextWindowData.ClearFlags(); - return false; - } - - // Set popup size - float w = bb.GetWidth(); - if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSizeConstraint) - { - g.NextWindowData.SizeConstraintRect.Min.x = ImMax(g.NextWindowData.SizeConstraintRect.Min.x, w); - } - else - { - if ((flags & ImGuiComboFlags_HeightMask_) == 0) - flags |= ImGuiComboFlags_HeightRegular; - IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiComboFlags_HeightMask_)); // Only one - int popup_max_height_in_items = -1; - if (flags & ImGuiComboFlags_HeightRegular) popup_max_height_in_items = 8; - else if (flags & ImGuiComboFlags_HeightSmall) popup_max_height_in_items = 4; - else if (flags & ImGuiComboFlags_HeightLarge) popup_max_height_in_items = 20; - SetNextWindowSizeConstraints(ImVec2(w, 0.0f), ImVec2(FLT_MAX, CalcMaxPopupHeightFromItemCount(popup_max_height_in_items))); - } - - // This is essentially a specialized version of BeginPopupEx() - char name[16]; - ImFormatString(name, IM_ARRAYSIZE(name), "##Combo_%02d", g.BeginPopupStack.Size); // Recycle windows based on depth - - // Set position given a custom constraint (peak into expected window size so we can position it) - // FIXME: This might be easier to express with an hypothetical SetNextWindowPosConstraints() function? - // FIXME: This might be moved to Begin() or at least around the same spot where Tooltips and other Popups are calling FindBestWindowPosForPopupEx()? - if (ImGuiWindow* popup_window = FindWindowByName(name)) - if (popup_window->WasActive) - { - // Always override 'AutoPosLastDirection' to not leave a chance for a past value to affect us. - ImVec2 size_expected = CalcWindowNextAutoFitSize(popup_window); - popup_window->AutoPosLastDirection = (flags & ImGuiComboFlags_PopupAlignLeft) ? ImGuiDir_Left : ImGuiDir_Down; // Left = "Below, Toward Left", Down = "Below, Toward Right (default)" - ImRect r_outer = GetPopupAllowedExtentRect(popup_window); - ImVec2 pos = FindBestWindowPosForPopupEx(bb.GetBL(), size_expected, &popup_window->AutoPosLastDirection, r_outer, bb, ImGuiPopupPositionPolicy_ComboBox); - SetNextWindowPos(pos); - } - - // We don't use BeginPopupEx() solely because we have a custom name string, which we could make an argument to BeginPopupEx() - ImGuiWindowFlags window_flags = ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_Popup | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoMove; - PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(g.Style.FramePadding.x, g.Style.WindowPadding.y)); // Horizontally align ourselves with the framed text - bool ret = Begin(name, NULL, window_flags); - PopStyleVar(); - if (!ret) - { - EndPopup(); - IM_ASSERT(0); // This should never happen as we tested for IsPopupOpen() above - return false; - } - return true; -} - -void ImGui::EndCombo() -{ - EndPopup(); -} - -// Call directly after the BeginCombo/EndCombo block. The preview is designed to only host non-interactive elements -// (Experimental, see GitHub issues: #1658, #4168) -bool ImGui::BeginComboPreview() -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - ImGuiComboPreviewData* preview_data = &g.ComboPreviewData; - - if (window->SkipItems || !window->ClipRect.Overlaps(g.LastItemData.Rect)) // FIXME: Because we don't have a ImGuiItemStatusFlags_Visible flag to test last ItemAdd() result - return false; - IM_ASSERT(g.LastItemData.Rect.Min.x == preview_data->PreviewRect.Min.x && g.LastItemData.Rect.Min.y == preview_data->PreviewRect.Min.y); // Didn't call after BeginCombo/EndCombo block or forgot to pass ImGuiComboFlags_CustomPreview flag? - if (!window->ClipRect.Contains(preview_data->PreviewRect)) // Narrower test (optional) - return false; - - // FIXME: This could be contained in a PushWorkRect() api - preview_data->BackupCursorPos = window->DC.CursorPos; - preview_data->BackupCursorMaxPos = window->DC.CursorMaxPos; - preview_data->BackupCursorPosPrevLine = window->DC.CursorPosPrevLine; - preview_data->BackupPrevLineTextBaseOffset = window->DC.PrevLineTextBaseOffset; - preview_data->BackupLayout = window->DC.LayoutType; - window->DC.CursorPos = preview_data->PreviewRect.Min + g.Style.FramePadding; - window->DC.CursorMaxPos = window->DC.CursorPos; - window->DC.LayoutType = ImGuiLayoutType_Horizontal; - PushClipRect(preview_data->PreviewRect.Min, preview_data->PreviewRect.Max, true); - - return true; -} - -void ImGui::EndComboPreview() -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - ImGuiComboPreviewData* preview_data = &g.ComboPreviewData; - - // FIXME: Using CursorMaxPos approximation instead of correct AABB which we will store in ImDrawCmd in the future - ImDrawList* draw_list = window->DrawList; - if (window->DC.CursorMaxPos.x < preview_data->PreviewRect.Max.x && window->DC.CursorMaxPos.y < preview_data->PreviewRect.Max.y) - if (draw_list->CmdBuffer.Size > 1) // Unlikely case that the PushClipRect() didn't create a command - { - draw_list->_CmdHeader.ClipRect = draw_list->CmdBuffer[draw_list->CmdBuffer.Size - 1].ClipRect = draw_list->CmdBuffer[draw_list->CmdBuffer.Size - 2].ClipRect; - draw_list->_TryMergeDrawCmds(); - } - PopClipRect(); - window->DC.CursorPos = preview_data->BackupCursorPos; - window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, preview_data->BackupCursorMaxPos); - window->DC.CursorPosPrevLine = preview_data->BackupCursorPosPrevLine; - window->DC.PrevLineTextBaseOffset = preview_data->BackupPrevLineTextBaseOffset; - window->DC.LayoutType = preview_data->BackupLayout; - preview_data->PreviewRect = ImRect(); -} - -// Getter for the old Combo() API: const char*[] -static bool Items_ArrayGetter(void* data, int idx, const char** out_text) -{ - const char* const* items = (const char* const*)data; - if (out_text) - *out_text = items[idx]; - return true; -} - -// Getter for the old Combo() API: "item1\0item2\0item3\0" -static bool Items_SingleStringGetter(void* data, int idx, const char** out_text) -{ - // FIXME-OPT: we could pre-compute the indices to fasten this. But only 1 active combo means the waste is limited. - const char* items_separated_by_zeros = (const char*)data; - int items_count = 0; - const char* p = items_separated_by_zeros; - while (*p) - { - if (idx == items_count) - break; - p += strlen(p) + 1; - items_count++; - } - if (!*p) - return false; - if (out_text) - *out_text = p; - return true; -} - -// Old API, prefer using BeginCombo() nowadays if you can. -bool ImGui::Combo(const char* label, int* current_item, bool (*items_getter)(void*, int, const char**), void* data, int items_count, int popup_max_height_in_items) -{ - ImGuiContext& g = *GImGui; - - // Call the getter to obtain the preview string which is a parameter to BeginCombo() - const char* preview_value = NULL; - if (*current_item >= 0 && *current_item < items_count) - items_getter(data, *current_item, &preview_value); - - // The old Combo() API exposed "popup_max_height_in_items". The new more general BeginCombo() API doesn't have/need it, but we emulate it here. - if (popup_max_height_in_items != -1 && !(g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSizeConstraint)) - SetNextWindowSizeConstraints(ImVec2(0, 0), ImVec2(FLT_MAX, CalcMaxPopupHeightFromItemCount(popup_max_height_in_items))); - - if (!BeginCombo(label, preview_value, ImGuiComboFlags_None)) - return false; - - // Display items - // FIXME-OPT: Use clipper (but we need to disable it on the appearing frame to make sure our call to SetItemDefaultFocus() is processed) - bool value_changed = false; - for (int i = 0; i < items_count; i++) - { - PushID(i); - const bool item_selected = (i == *current_item); - const char* item_text; - if (!items_getter(data, i, &item_text)) - item_text = "*Unknown item*"; - if (Selectable(item_text, item_selected)) - { - value_changed = true; - *current_item = i; - } - if (item_selected) - SetItemDefaultFocus(); - PopID(); - } - - EndCombo(); - - if (value_changed) - MarkItemEdited(g.LastItemData.ID); - - return value_changed; -} - -// Combo box helper allowing to pass an array of strings. -bool ImGui::Combo(const char* label, int* current_item, const char* const items[], int items_count, int height_in_items) -{ - const bool value_changed = Combo(label, current_item, Items_ArrayGetter, (void*)items, items_count, height_in_items); - return value_changed; -} - -// Combo box helper allowing to pass all items in a single string literal holding multiple zero-terminated items "item1\0item2\0" -bool ImGui::Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int height_in_items) -{ - int items_count = 0; - const char* p = items_separated_by_zeros; // FIXME-OPT: Avoid computing this, or at least only when combo is open - while (*p) - { - p += strlen(p) + 1; - items_count++; - } - bool value_changed = Combo(label, current_item, Items_SingleStringGetter, (void*)items_separated_by_zeros, items_count, height_in_items); - return value_changed; -} - -//------------------------------------------------------------------------- -// [SECTION] Data Type and Data Formatting Helpers [Internal] -//------------------------------------------------------------------------- -// - PatchFormatStringFloatToInt() -// - DataTypeGetInfo() -// - DataTypeFormatString() -// - DataTypeApplyOp() -// - DataTypeApplyOpFromText() -// - DataTypeClamp() -// - GetMinimumStepAtDecimalPrecision -// - RoundScalarWithFormat<>() -//------------------------------------------------------------------------- - -static const ImGuiDataTypeInfo GDataTypeInfo[] = -{ - { sizeof(char), "S8", "%d", "%d" }, // ImGuiDataType_S8 - { sizeof(unsigned char), "U8", "%u", "%u" }, - { sizeof(short), "S16", "%d", "%d" }, // ImGuiDataType_S16 - { sizeof(unsigned short), "U16", "%u", "%u" }, - { sizeof(int), "S32", "%d", "%d" }, // ImGuiDataType_S32 - { sizeof(unsigned int), "U32", "%u", "%u" }, -#ifdef _MSC_VER - { sizeof(ImS64), "S64", "%I64d","%I64d" }, // ImGuiDataType_S64 - { sizeof(ImU64), "U64", "%I64u","%I64u" }, -#else - { sizeof(ImS64), "S64", "%lld", "%lld" }, // ImGuiDataType_S64 - { sizeof(ImU64), "U64", "%llu", "%llu" }, -#endif - { sizeof(float), "float", "%.3f","%f" }, // ImGuiDataType_Float (float are promoted to double in va_arg) - { sizeof(double), "double","%f", "%lf" }, // ImGuiDataType_Double -}; -IM_STATIC_ASSERT(IM_ARRAYSIZE(GDataTypeInfo) == ImGuiDataType_COUNT); - -// FIXME-LEGACY: Prior to 1.61 our DragInt() function internally used floats and because of this the compile-time default value for format was "%.0f". -// Even though we changed the compile-time default, we expect users to have carried %f around, which would break the display of DragInt() calls. -// To honor backward compatibility we are rewriting the format string, unless IMGUI_DISABLE_OBSOLETE_FUNCTIONS is enabled. What could possibly go wrong?! -static const char* PatchFormatStringFloatToInt(const char* fmt) -{ - if (fmt[0] == '%' && fmt[1] == '.' && fmt[2] == '0' && fmt[3] == 'f' && fmt[4] == 0) // Fast legacy path for "%.0f" which is expected to be the most common case. - return "%d"; - const char* fmt_start = ImParseFormatFindStart(fmt); // Find % (if any, and ignore %%) - const char* fmt_end = ImParseFormatFindEnd(fmt_start); // Find end of format specifier, which itself is an exercise of confidence/recklessness (because snprintf is dependent on libc or user). - if (fmt_end > fmt_start && fmt_end[-1] == 'f') - { -#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS - if (fmt_start == fmt && fmt_end[0] == 0) - return "%d"; - ImGuiContext& g = *GImGui; - ImFormatString(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), "%.*s%%d%s", (int)(fmt_start - fmt), fmt, fmt_end); // Honor leading and trailing decorations, but lose alignment/precision. - return g.TempBuffer; -#else - IM_ASSERT(0 && "DragInt(): Invalid format string!"); // Old versions used a default parameter of "%.0f", please replace with e.g. "%d" -#endif - } - return fmt; -} - -const ImGuiDataTypeInfo* ImGui::DataTypeGetInfo(ImGuiDataType data_type) -{ - IM_ASSERT(data_type >= 0 && data_type < ImGuiDataType_COUNT); - return &GDataTypeInfo[data_type]; -} - -int ImGui::DataTypeFormatString(char* buf, int buf_size, ImGuiDataType data_type, const void* p_data, const char* format) -{ - // Signedness doesn't matter when pushing integer arguments - if (data_type == ImGuiDataType_S32 || data_type == ImGuiDataType_U32) - return ImFormatString(buf, buf_size, format, *(const ImU32*)p_data); - if (data_type == ImGuiDataType_S64 || data_type == ImGuiDataType_U64) - return ImFormatString(buf, buf_size, format, *(const ImU64*)p_data); - if (data_type == ImGuiDataType_Float) - return ImFormatString(buf, buf_size, format, *(const float*)p_data); - if (data_type == ImGuiDataType_Double) - return ImFormatString(buf, buf_size, format, *(const double*)p_data); - if (data_type == ImGuiDataType_S8) - return ImFormatString(buf, buf_size, format, *(const ImS8*)p_data); - if (data_type == ImGuiDataType_U8) - return ImFormatString(buf, buf_size, format, *(const ImU8*)p_data); - if (data_type == ImGuiDataType_S16) - return ImFormatString(buf, buf_size, format, *(const ImS16*)p_data); - if (data_type == ImGuiDataType_U16) - return ImFormatString(buf, buf_size, format, *(const ImU16*)p_data); - IM_ASSERT(0); - return 0; -} - -void ImGui::DataTypeApplyOp(ImGuiDataType data_type, int op, void* output, const void* arg1, const void* arg2) -{ - IM_ASSERT(op == '+' || op == '-'); - switch (data_type) - { - case ImGuiDataType_S8: - if (op == '+') { *(ImS8*)output = ImAddClampOverflow(*(const ImS8*)arg1, *(const ImS8*)arg2, IM_S8_MIN, IM_S8_MAX); } - if (op == '-') { *(ImS8*)output = ImSubClampOverflow(*(const ImS8*)arg1, *(const ImS8*)arg2, IM_S8_MIN, IM_S8_MAX); } - return; - case ImGuiDataType_U8: - if (op == '+') { *(ImU8*)output = ImAddClampOverflow(*(const ImU8*)arg1, *(const ImU8*)arg2, IM_U8_MIN, IM_U8_MAX); } - if (op == '-') { *(ImU8*)output = ImSubClampOverflow(*(const ImU8*)arg1, *(const ImU8*)arg2, IM_U8_MIN, IM_U8_MAX); } - return; - case ImGuiDataType_S16: - if (op == '+') { *(ImS16*)output = ImAddClampOverflow(*(const ImS16*)arg1, *(const ImS16*)arg2, IM_S16_MIN, IM_S16_MAX); } - if (op == '-') { *(ImS16*)output = ImSubClampOverflow(*(const ImS16*)arg1, *(const ImS16*)arg2, IM_S16_MIN, IM_S16_MAX); } - return; - case ImGuiDataType_U16: - if (op == '+') { *(ImU16*)output = ImAddClampOverflow(*(const ImU16*)arg1, *(const ImU16*)arg2, IM_U16_MIN, IM_U16_MAX); } - if (op == '-') { *(ImU16*)output = ImSubClampOverflow(*(const ImU16*)arg1, *(const ImU16*)arg2, IM_U16_MIN, IM_U16_MAX); } - return; - case ImGuiDataType_S32: - if (op == '+') { *(ImS32*)output = ImAddClampOverflow(*(const ImS32*)arg1, *(const ImS32*)arg2, IM_S32_MIN, IM_S32_MAX); } - if (op == '-') { *(ImS32*)output = ImSubClampOverflow(*(const ImS32*)arg1, *(const ImS32*)arg2, IM_S32_MIN, IM_S32_MAX); } - return; - case ImGuiDataType_U32: - if (op == '+') { *(ImU32*)output = ImAddClampOverflow(*(const ImU32*)arg1, *(const ImU32*)arg2, IM_U32_MIN, IM_U32_MAX); } - if (op == '-') { *(ImU32*)output = ImSubClampOverflow(*(const ImU32*)arg1, *(const ImU32*)arg2, IM_U32_MIN, IM_U32_MAX); } - return; - case ImGuiDataType_S64: - if (op == '+') { *(ImS64*)output = ImAddClampOverflow(*(const ImS64*)arg1, *(const ImS64*)arg2, IM_S64_MIN, IM_S64_MAX); } - if (op == '-') { *(ImS64*)output = ImSubClampOverflow(*(const ImS64*)arg1, *(const ImS64*)arg2, IM_S64_MIN, IM_S64_MAX); } - return; - case ImGuiDataType_U64: - if (op == '+') { *(ImU64*)output = ImAddClampOverflow(*(const ImU64*)arg1, *(const ImU64*)arg2, IM_U64_MIN, IM_U64_MAX); } - if (op == '-') { *(ImU64*)output = ImSubClampOverflow(*(const ImU64*)arg1, *(const ImU64*)arg2, IM_U64_MIN, IM_U64_MAX); } - return; - case ImGuiDataType_Float: - if (op == '+') { *(float*)output = *(const float*)arg1 + *(const float*)arg2; } - if (op == '-') { *(float*)output = *(const float*)arg1 - *(const float*)arg2; } - return; - case ImGuiDataType_Double: - if (op == '+') { *(double*)output = *(const double*)arg1 + *(const double*)arg2; } - if (op == '-') { *(double*)output = *(const double*)arg1 - *(const double*)arg2; } - return; - case ImGuiDataType_COUNT: break; - } - IM_ASSERT(0); -} - -// User can input math operators (e.g. +100) to edit a numerical values. -// NB: This is _not_ a full expression evaluator. We should probably add one and replace this dumb mess.. -bool ImGui::DataTypeApplyOpFromText(const char* buf, const char* initial_value_buf, ImGuiDataType data_type, void* p_data, const char* format) -{ - while (ImCharIsBlankA(*buf)) - buf++; - - // We don't support '-' op because it would conflict with inputing negative value. - // Instead you can use +-100 to subtract from an existing value - char op = buf[0]; - if (op == '+' || op == '*' || op == '/') - { - buf++; - while (ImCharIsBlankA(*buf)) - buf++; - } - else - { - op = 0; - } - if (!buf[0]) - return false; - - // Copy the value in an opaque buffer so we can compare at the end of the function if it changed at all. - const ImGuiDataTypeInfo* type_info = DataTypeGetInfo(data_type); - ImGuiDataTypeTempStorage data_backup; - memcpy(&data_backup, p_data, type_info->Size); - - if (format == NULL) - format = type_info->ScanFmt; - - // FIXME-LEGACY: The aim is to remove those operators and write a proper expression evaluator at some point.. - int arg1i = 0; - if (data_type == ImGuiDataType_S32) - { - int* v = (int*)p_data; - int arg0i = *v; - float arg1f = 0.0f; - if (op && sscanf(initial_value_buf, format, &arg0i) < 1) - return false; - // Store operand in a float so we can use fractional value for multipliers (*1.1), but constant always parsed as integer so we can fit big integers (e.g. 2000000003) past float precision - if (op == '+') { if (sscanf(buf, "%d", &arg1i)) *v = (int)(arg0i + arg1i); } // Add (use "+-" to subtract) - else if (op == '*') { if (sscanf(buf, "%f", &arg1f)) *v = (int)(arg0i * arg1f); } // Multiply - else if (op == '/') { if (sscanf(buf, "%f", &arg1f) && arg1f != 0.0f) *v = (int)(arg0i / arg1f); } // Divide - else { if (sscanf(buf, format, &arg1i) == 1) *v = arg1i; } // Assign constant - } - else if (data_type == ImGuiDataType_Float) - { - // For floats we have to ignore format with precision (e.g. "%.2f") because sscanf doesn't take them in - format = "%f"; - float* v = (float*)p_data; - float arg0f = *v, arg1f = 0.0f; - if (op && sscanf(initial_value_buf, format, &arg0f) < 1) - return false; - if (sscanf(buf, format, &arg1f) < 1) - return false; - if (op == '+') { *v = arg0f + arg1f; } // Add (use "+-" to subtract) - else if (op == '*') { *v = arg0f * arg1f; } // Multiply - else if (op == '/') { if (arg1f != 0.0f) *v = arg0f / arg1f; } // Divide - else { *v = arg1f; } // Assign constant - } - else if (data_type == ImGuiDataType_Double) - { - format = "%lf"; // scanf differentiate float/double unlike printf which forces everything to double because of ellipsis - double* v = (double*)p_data; - double arg0f = *v, arg1f = 0.0; - if (op && sscanf(initial_value_buf, format, &arg0f) < 1) - return false; - if (sscanf(buf, format, &arg1f) < 1) - return false; - if (op == '+') { *v = arg0f + arg1f; } // Add (use "+-" to subtract) - else if (op == '*') { *v = arg0f * arg1f; } // Multiply - else if (op == '/') { if (arg1f != 0.0f) *v = arg0f / arg1f; } // Divide - else { *v = arg1f; } // Assign constant - } - else if (data_type == ImGuiDataType_U32 || data_type == ImGuiDataType_S64 || data_type == ImGuiDataType_U64) - { - // All other types assign constant - // We don't bother handling support for legacy operators since they are a little too crappy. Instead we will later implement a proper expression evaluator in the future. - if (sscanf(buf, format, p_data) < 1) - return false; - } - else - { - // Small types need a 32-bit buffer to receive the result from scanf() - int v32; - if (sscanf(buf, format, &v32) < 1) - return false; - if (data_type == ImGuiDataType_S8) - *(ImS8*)p_data = (ImS8)ImClamp(v32, (int)IM_S8_MIN, (int)IM_S8_MAX); - else if (data_type == ImGuiDataType_U8) - *(ImU8*)p_data = (ImU8)ImClamp(v32, (int)IM_U8_MIN, (int)IM_U8_MAX); - else if (data_type == ImGuiDataType_S16) - *(ImS16*)p_data = (ImS16)ImClamp(v32, (int)IM_S16_MIN, (int)IM_S16_MAX); - else if (data_type == ImGuiDataType_U16) - *(ImU16*)p_data = (ImU16)ImClamp(v32, (int)IM_U16_MIN, (int)IM_U16_MAX); - else - IM_ASSERT(0); - } - - return memcmp(&data_backup, p_data, type_info->Size) != 0; -} - -template -static int DataTypeCompareT(const T* lhs, const T* rhs) -{ - if (*lhs < *rhs) return -1; - if (*lhs > *rhs) return +1; - return 0; -} - -int ImGui::DataTypeCompare(ImGuiDataType data_type, const void* arg_1, const void* arg_2) -{ - switch (data_type) - { - case ImGuiDataType_S8: return DataTypeCompareT((const ImS8* )arg_1, (const ImS8* )arg_2); - case ImGuiDataType_U8: return DataTypeCompareT((const ImU8* )arg_1, (const ImU8* )arg_2); - case ImGuiDataType_S16: return DataTypeCompareT((const ImS16* )arg_1, (const ImS16* )arg_2); - case ImGuiDataType_U16: return DataTypeCompareT((const ImU16* )arg_1, (const ImU16* )arg_2); - case ImGuiDataType_S32: return DataTypeCompareT((const ImS32* )arg_1, (const ImS32* )arg_2); - case ImGuiDataType_U32: return DataTypeCompareT((const ImU32* )arg_1, (const ImU32* )arg_2); - case ImGuiDataType_S64: return DataTypeCompareT((const ImS64* )arg_1, (const ImS64* )arg_2); - case ImGuiDataType_U64: return DataTypeCompareT((const ImU64* )arg_1, (const ImU64* )arg_2); - case ImGuiDataType_Float: return DataTypeCompareT((const float* )arg_1, (const float* )arg_2); - case ImGuiDataType_Double: return DataTypeCompareT((const double*)arg_1, (const double*)arg_2); - case ImGuiDataType_COUNT: break; - } - IM_ASSERT(0); - return 0; -} - -template -static bool DataTypeClampT(T* v, const T* v_min, const T* v_max) -{ - // Clamp, both sides are optional, return true if modified - if (v_min && *v < *v_min) { *v = *v_min; return true; } - if (v_max && *v > *v_max) { *v = *v_max; return true; } - return false; -} - -bool ImGui::DataTypeClamp(ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max) -{ - switch (data_type) - { - case ImGuiDataType_S8: return DataTypeClampT((ImS8* )p_data, (const ImS8* )p_min, (const ImS8* )p_max); - case ImGuiDataType_U8: return DataTypeClampT((ImU8* )p_data, (const ImU8* )p_min, (const ImU8* )p_max); - case ImGuiDataType_S16: return DataTypeClampT((ImS16* )p_data, (const ImS16* )p_min, (const ImS16* )p_max); - case ImGuiDataType_U16: return DataTypeClampT((ImU16* )p_data, (const ImU16* )p_min, (const ImU16* )p_max); - case ImGuiDataType_S32: return DataTypeClampT((ImS32* )p_data, (const ImS32* )p_min, (const ImS32* )p_max); - case ImGuiDataType_U32: return DataTypeClampT((ImU32* )p_data, (const ImU32* )p_min, (const ImU32* )p_max); - case ImGuiDataType_S64: return DataTypeClampT((ImS64* )p_data, (const ImS64* )p_min, (const ImS64* )p_max); - case ImGuiDataType_U64: return DataTypeClampT((ImU64* )p_data, (const ImU64* )p_min, (const ImU64* )p_max); - case ImGuiDataType_Float: return DataTypeClampT((float* )p_data, (const float* )p_min, (const float* )p_max); - case ImGuiDataType_Double: return DataTypeClampT((double*)p_data, (const double*)p_min, (const double*)p_max); - case ImGuiDataType_COUNT: break; - } - IM_ASSERT(0); - return false; -} - -static float GetMinimumStepAtDecimalPrecision(int decimal_precision) -{ - static const float min_steps[10] = { 1.0f, 0.1f, 0.01f, 0.001f, 0.0001f, 0.00001f, 0.000001f, 0.0000001f, 0.00000001f, 0.000000001f }; - if (decimal_precision < 0) - return FLT_MIN; - return (decimal_precision < IM_ARRAYSIZE(min_steps)) ? min_steps[decimal_precision] : ImPow(10.0f, (float)-decimal_precision); -} - -template -static const char* ImAtoi(const char* src, TYPE* output) -{ - int negative = 0; - if (*src == '-') { negative = 1; src++; } - if (*src == '+') { src++; } - TYPE v = 0; - while (*src >= '0' && *src <= '9') - v = (v * 10) + (*src++ - '0'); - *output = negative ? -v : v; - return src; -} - -// Sanitize format -// - Zero terminate so extra characters after format (e.g. "%f123") don't confuse atof/atoi -// - stb_sprintf.h supports several new modifiers which format numbers in a way that also makes them incompatible atof/atoi. -static void SanitizeFormatString(const char* fmt, char* fmt_out, size_t fmt_out_size) -{ - IM_UNUSED(fmt_out_size); - const char* fmt_end = ImParseFormatFindEnd(fmt); - IM_ASSERT((size_t)(fmt_end - fmt + 1) < fmt_out_size); // Format is too long, let us know if this happens to you! - while (fmt < fmt_end) - { - char c = *(fmt++); - if (c != '\'' && c != '$' && c != '_') // Custom flags provided by stb_sprintf.h. POSIX 2008 also supports '. - *(fmt_out++) = c; - } - *fmt_out = 0; // Zero-terminate -} - -template -TYPE ImGui::RoundScalarWithFormatT(const char* format, ImGuiDataType data_type, TYPE v) -{ - const char* fmt_start = ImParseFormatFindStart(format); - if (fmt_start[0] != '%' || fmt_start[1] == '%') // Don't apply if the value is not visible in the format string - return v; - - // Sanitize format - char fmt_sanitized[32]; - SanitizeFormatString(fmt_start, fmt_sanitized, IM_ARRAYSIZE(fmt_sanitized)); - fmt_start = fmt_sanitized; - - // Format value with our rounding, and read back - char v_str[64]; - ImFormatString(v_str, IM_ARRAYSIZE(v_str), fmt_start, v); - const char* p = v_str; - while (*p == ' ') - p++; - if (data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double) - v = (TYPE)ImAtof(p); - else - ImAtoi(p, (SIGNEDTYPE*)&v); - return v; -} - -//------------------------------------------------------------------------- -// [SECTION] Widgets: DragScalar, DragFloat, DragInt, etc. -//------------------------------------------------------------------------- -// - DragBehaviorT<>() [Internal] -// - DragBehavior() [Internal] -// - DragScalar() -// - DragScalarN() -// - DragFloat() -// - DragFloat2() -// - DragFloat3() -// - DragFloat4() -// - DragFloatRange2() -// - DragInt() -// - DragInt2() -// - DragInt3() -// - DragInt4() -// - DragIntRange2() -//------------------------------------------------------------------------- - -// This is called by DragBehavior() when the widget is active (held by mouse or being manipulated with Nav controls) -template -bool ImGui::DragBehaviorT(ImGuiDataType data_type, TYPE* v, float v_speed, const TYPE v_min, const TYPE v_max, const char* format, ImGuiSliderFlags flags) -{ - ImGuiContext& g = *GImGui; - const ImGuiAxis axis = (flags & ImGuiSliderFlags_Vertical) ? ImGuiAxis_Y : ImGuiAxis_X; - const bool is_clamped = (v_min < v_max); - const bool is_logarithmic = (flags & ImGuiSliderFlags_Logarithmic) != 0; - const bool is_floating_point = (data_type == ImGuiDataType_Float) || (data_type == ImGuiDataType_Double); - - // Default tweak speed - if (v_speed == 0.0f && is_clamped && (v_max - v_min < FLT_MAX)) - v_speed = (float)((v_max - v_min) * g.DragSpeedDefaultRatio); - - // Inputs accumulates into g.DragCurrentAccum, which is flushed into the current value as soon as it makes a difference with our precision settings - float adjust_delta = 0.0f; - if (g.ActiveIdSource == ImGuiInputSource_Mouse && IsMousePosValid() && IsMouseDragPastThreshold(0, g.IO.MouseDragThreshold * DRAG_MOUSE_THRESHOLD_FACTOR)) - { - adjust_delta = g.IO.MouseDelta[axis]; - if (g.IO.KeyAlt) - adjust_delta *= 1.0f / 100.0f; - if (g.IO.KeyShift) - adjust_delta *= 10.0f; - } - else if (g.ActiveIdSource == ImGuiInputSource_Nav) - { - const int decimal_precision = is_floating_point ? ImParseFormatPrecision(format, 3) : 0; - adjust_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard | ImGuiNavDirSourceFlags_PadDPad, ImGuiInputReadMode_RepeatFast, 1.0f / 10.0f, 10.0f)[axis]; - v_speed = ImMax(v_speed, GetMinimumStepAtDecimalPrecision(decimal_precision)); - } - adjust_delta *= v_speed; - - // For vertical drag we currently assume that Up=higher value (like we do with vertical sliders). This may become a parameter. - if (axis == ImGuiAxis_Y) - adjust_delta = -adjust_delta; - - // For logarithmic use our range is effectively 0..1 so scale the delta into that range - if (is_logarithmic && (v_max - v_min < FLT_MAX) && ((v_max - v_min) > 0.000001f)) // Epsilon to avoid /0 - adjust_delta /= (float)(v_max - v_min); - - // Clear current value on activation - // Avoid altering values and clamping when we are _already_ past the limits and heading in the same direction, so e.g. if range is 0..255, current value is 300 and we are pushing to the right side, keep the 300. - bool is_just_activated = g.ActiveIdIsJustActivated; - bool is_already_past_limits_and_pushing_outward = is_clamped && ((*v >= v_max && adjust_delta > 0.0f) || (*v <= v_min && adjust_delta < 0.0f)); - if (is_just_activated || is_already_past_limits_and_pushing_outward) - { - g.DragCurrentAccum = 0.0f; - g.DragCurrentAccumDirty = false; - } - else if (adjust_delta != 0.0f) - { - g.DragCurrentAccum += adjust_delta; - g.DragCurrentAccumDirty = true; - } - - if (!g.DragCurrentAccumDirty) - return false; - - TYPE v_cur = *v; - FLOATTYPE v_old_ref_for_accum_remainder = (FLOATTYPE)0.0f; - - float logarithmic_zero_epsilon = 0.0f; // Only valid when is_logarithmic is true - const float zero_deadzone_halfsize = 0.0f; // Drag widgets have no deadzone (as it doesn't make sense) - if (is_logarithmic) - { - // When using logarithmic sliders, we need to clamp to avoid hitting zero, but our choice of clamp value greatly affects slider precision. We attempt to use the specified precision to estimate a good lower bound. - const int decimal_precision = is_floating_point ? ImParseFormatPrecision(format, 3) : 1; - logarithmic_zero_epsilon = ImPow(0.1f, (float)decimal_precision); - - // Convert to parametric space, apply delta, convert back - float v_old_parametric = ScaleRatioFromValueT(data_type, v_cur, v_min, v_max, is_logarithmic, logarithmic_zero_epsilon, zero_deadzone_halfsize); - float v_new_parametric = v_old_parametric + g.DragCurrentAccum; - v_cur = ScaleValueFromRatioT(data_type, v_new_parametric, v_min, v_max, is_logarithmic, logarithmic_zero_epsilon, zero_deadzone_halfsize); - v_old_ref_for_accum_remainder = v_old_parametric; - } - else - { - v_cur += (SIGNEDTYPE)g.DragCurrentAccum; - } - - // Round to user desired precision based on format string - if (!(flags & ImGuiSliderFlags_NoRoundToFormat)) - v_cur = RoundScalarWithFormatT(format, data_type, v_cur); - - // Preserve remainder after rounding has been applied. This also allow slow tweaking of values. - g.DragCurrentAccumDirty = false; - if (is_logarithmic) - { - // Convert to parametric space, apply delta, convert back - float v_new_parametric = ScaleRatioFromValueT(data_type, v_cur, v_min, v_max, is_logarithmic, logarithmic_zero_epsilon, zero_deadzone_halfsize); - g.DragCurrentAccum -= (float)(v_new_parametric - v_old_ref_for_accum_remainder); - } - else - { - g.DragCurrentAccum -= (float)((SIGNEDTYPE)v_cur - (SIGNEDTYPE)*v); - } - - // Lose zero sign for float/double - if (v_cur == (TYPE)-0) - v_cur = (TYPE)0; - - // Clamp values (+ handle overflow/wrap-around for integer types) - if (*v != v_cur && is_clamped) - { - if (v_cur < v_min || (v_cur > *v && adjust_delta < 0.0f && !is_floating_point)) - v_cur = v_min; - if (v_cur > v_max || (v_cur < *v && adjust_delta > 0.0f && !is_floating_point)) - v_cur = v_max; - } - - // Apply result - if (*v == v_cur) - return false; - *v = v_cur; - return true; -} - -bool ImGui::DragBehavior(ImGuiID id, ImGuiDataType data_type, void* p_v, float v_speed, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags) -{ - // Read imgui.cpp "API BREAKING CHANGES" section for 1.78 if you hit this assert. - IM_ASSERT((flags == 1 || (flags & ImGuiSliderFlags_InvalidMask_) == 0) && "Invalid ImGuiSliderFlags flags! Has the 'float power' argument been mistakenly cast to flags? Call function with ImGuiSliderFlags_Logarithmic flags instead."); - - ImGuiContext& g = *GImGui; - if (g.ActiveId == id) - { - if (g.ActiveIdSource == ImGuiInputSource_Mouse && !g.IO.MouseDown[0]) - ClearActiveID(); - else if (g.ActiveIdSource == ImGuiInputSource_Nav && g.NavActivatePressedId == id && !g.ActiveIdIsJustActivated) - ClearActiveID(); - } - if (g.ActiveId != id) - return false; - if ((g.LastItemData.InFlags & ImGuiItemFlags_ReadOnly) || (flags & ImGuiSliderFlags_ReadOnly)) - return false; - - switch (data_type) - { - case ImGuiDataType_S8: { ImS32 v32 = (ImS32)*(ImS8*)p_v; bool r = DragBehaviorT(ImGuiDataType_S32, &v32, v_speed, p_min ? *(const ImS8*) p_min : IM_S8_MIN, p_max ? *(const ImS8*)p_max : IM_S8_MAX, format, flags); if (r) *(ImS8*)p_v = (ImS8)v32; return r; } - case ImGuiDataType_U8: { ImU32 v32 = (ImU32)*(ImU8*)p_v; bool r = DragBehaviorT(ImGuiDataType_U32, &v32, v_speed, p_min ? *(const ImU8*) p_min : IM_U8_MIN, p_max ? *(const ImU8*)p_max : IM_U8_MAX, format, flags); if (r) *(ImU8*)p_v = (ImU8)v32; return r; } - case ImGuiDataType_S16: { ImS32 v32 = (ImS32)*(ImS16*)p_v; bool r = DragBehaviorT(ImGuiDataType_S32, &v32, v_speed, p_min ? *(const ImS16*)p_min : IM_S16_MIN, p_max ? *(const ImS16*)p_max : IM_S16_MAX, format, flags); if (r) *(ImS16*)p_v = (ImS16)v32; return r; } - case ImGuiDataType_U16: { ImU32 v32 = (ImU32)*(ImU16*)p_v; bool r = DragBehaviorT(ImGuiDataType_U32, &v32, v_speed, p_min ? *(const ImU16*)p_min : IM_U16_MIN, p_max ? *(const ImU16*)p_max : IM_U16_MAX, format, flags); if (r) *(ImU16*)p_v = (ImU16)v32; return r; } - case ImGuiDataType_S32: return DragBehaviorT(data_type, (ImS32*)p_v, v_speed, p_min ? *(const ImS32* )p_min : IM_S32_MIN, p_max ? *(const ImS32* )p_max : IM_S32_MAX, format, flags); - case ImGuiDataType_U32: return DragBehaviorT(data_type, (ImU32*)p_v, v_speed, p_min ? *(const ImU32* )p_min : IM_U32_MIN, p_max ? *(const ImU32* )p_max : IM_U32_MAX, format, flags); - case ImGuiDataType_S64: return DragBehaviorT(data_type, (ImS64*)p_v, v_speed, p_min ? *(const ImS64* )p_min : IM_S64_MIN, p_max ? *(const ImS64* )p_max : IM_S64_MAX, format, flags); - case ImGuiDataType_U64: return DragBehaviorT(data_type, (ImU64*)p_v, v_speed, p_min ? *(const ImU64* )p_min : IM_U64_MIN, p_max ? *(const ImU64* )p_max : IM_U64_MAX, format, flags); - case ImGuiDataType_Float: return DragBehaviorT(data_type, (float*)p_v, v_speed, p_min ? *(const float* )p_min : -FLT_MAX, p_max ? *(const float* )p_max : FLT_MAX, format, flags); - case ImGuiDataType_Double: return DragBehaviorT(data_type, (double*)p_v, v_speed, p_min ? *(const double*)p_min : -DBL_MAX, p_max ? *(const double*)p_max : DBL_MAX, format, flags); - case ImGuiDataType_COUNT: break; - } - IM_ASSERT(0); - return false; -} - -// Note: p_data, p_min and p_max are _pointers_ to a memory address holding the data. For a Drag widget, p_min and p_max are optional. -// Read code of e.g. DragFloat(), DragInt() etc. or examples in 'Demo->Widgets->Data Types' to understand how to use this function directly. -bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* p_data, float v_speed, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - - ImGuiContext& g = *GImGui; - const ImGuiStyle& style = g.Style; - const ImGuiID id = window->GetID(label); - const float w = CalcItemWidth(); - - const ImVec2 label_size = CalcTextSize(label, NULL, true); - const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y * 2.0f)); - const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f)); - - const bool temp_input_allowed = (flags & ImGuiSliderFlags_NoInput) == 0; - ItemSize(total_bb, style.FramePadding.y); - if (!ItemAdd(total_bb, id, &frame_bb, temp_input_allowed ? ImGuiItemFlags_Inputable : 0)) - return false; - - // Default format string when passing NULL - if (format == NULL) - format = DataTypeGetInfo(data_type)->PrintFmt; - else if (data_type == ImGuiDataType_S32 && strcmp(format, "%d") != 0) // (FIXME-LEGACY: Patch old "%.0f" format string to use "%d", read function more details.) - format = PatchFormatStringFloatToInt(format); - - // Tabbing or CTRL-clicking on Drag turns it into an InputText - const bool hovered = ItemHoverable(frame_bb, id); - bool temp_input_is_active = temp_input_allowed && TempInputIsActive(id); - if (!temp_input_is_active) - { - const bool input_requested_by_tabbing = temp_input_allowed && (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_FocusedByTabbing) != 0; - const bool clicked = (hovered && g.IO.MouseClicked[0]); - const bool double_clicked = (hovered && g.IO.MouseDoubleClicked[0]); - if (input_requested_by_tabbing || clicked || double_clicked || g.NavActivateId == id || g.NavActivateInputId == id) - { - SetActiveID(id, window); - SetFocusID(id, window); - FocusWindow(window); - g.ActiveIdUsingNavDirMask = (1 << ImGuiDir_Left) | (1 << ImGuiDir_Right); - if (temp_input_allowed) - if (input_requested_by_tabbing || (clicked && g.IO.KeyCtrl) || double_clicked || g.NavActivateInputId == id) - temp_input_is_active = true; - } - - // Experimental: simple click (without moving) turns Drag into an InputText - if (g.IO.ConfigDragClickToInputText && temp_input_allowed && !temp_input_is_active) - if (g.ActiveId == id && hovered && g.IO.MouseReleased[0] && !IsMouseDragPastThreshold(0, g.IO.MouseDragThreshold * DRAG_MOUSE_THRESHOLD_FACTOR)) - { - g.NavActivateId = g.NavActivateInputId = id; - g.NavActivateFlags = ImGuiActivateFlags_PreferInput; - temp_input_is_active = true; - } - } - - if (temp_input_is_active) - { - // Only clamp CTRL+Click input when ImGuiSliderFlags_AlwaysClamp is set - const bool is_clamp_input = (flags & ImGuiSliderFlags_AlwaysClamp) != 0 && (p_min == NULL || p_max == NULL || DataTypeCompare(data_type, p_min, p_max) < 0); - return TempInputScalar(frame_bb, id, label, data_type, p_data, format, is_clamp_input ? p_min : NULL, is_clamp_input ? p_max : NULL); - } - - // Draw frame - const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg); - RenderNavHighlight(frame_bb, id); - RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, true, style.FrameRounding); - - // Drag behavior - const bool value_changed = DragBehavior(id, data_type, p_data, v_speed, p_min, p_max, format, flags); - if (value_changed) - MarkItemEdited(id); - - // Display value using user-provided display format so user can add prefix/suffix/decorations to the value. - char value_buf[64]; - const char* value_buf_end = value_buf + DataTypeFormatString(value_buf, IM_ARRAYSIZE(value_buf), data_type, p_data, format); - if (g.LogEnabled) - LogSetNextTextDecoration("{", "}"); - RenderTextClipped(frame_bb.Min, frame_bb.Max, value_buf, value_buf_end, NULL, ImVec2(0.5f, 0.5f)); - - if (label_size.x > 0.0f) - RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label); - - IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags); - return value_changed; -} - -bool ImGui::DragScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, float v_speed, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - - ImGuiContext& g = *GImGui; - bool value_changed = false; - BeginGroup(); - PushID(label); - PushMultiItemsWidths(components, CalcItemWidth()); - size_t type_size = GDataTypeInfo[data_type].Size; - for (int i = 0; i < components; i++) - { - PushID(i); - if (i > 0) - SameLine(0, g.Style.ItemInnerSpacing.x); - value_changed |= DragScalar("", data_type, p_data, v_speed, p_min, p_max, format, flags); - PopID(); - PopItemWidth(); - p_data = (void*)((char*)p_data + type_size); - } - PopID(); - - const char* label_end = FindRenderedTextEnd(label); - if (label != label_end) - { - SameLine(0, g.Style.ItemInnerSpacing.x); - TextEx(label, label_end); - } - - EndGroup(); - return value_changed; -} - -bool ImGui::DragFloat(const char* label, float* v, float v_speed, float v_min, float v_max, const char* format, ImGuiSliderFlags flags) -{ - return DragScalar(label, ImGuiDataType_Float, v, v_speed, &v_min, &v_max, format, flags); -} - -bool ImGui::DragFloat2(const char* label, float v[2], float v_speed, float v_min, float v_max, const char* format, ImGuiSliderFlags flags) -{ - return DragScalarN(label, ImGuiDataType_Float, v, 2, v_speed, &v_min, &v_max, format, flags); -} - -bool ImGui::DragFloat3(const char* label, float v[3], float v_speed, float v_min, float v_max, const char* format, ImGuiSliderFlags flags) -{ - return DragScalarN(label, ImGuiDataType_Float, v, 3, v_speed, &v_min, &v_max, format, flags); -} - -bool ImGui::DragFloat4(const char* label, float v[4], float v_speed, float v_min, float v_max, const char* format, ImGuiSliderFlags flags) -{ - return DragScalarN(label, ImGuiDataType_Float, v, 4, v_speed, &v_min, &v_max, format, flags); -} - -// NB: You likely want to specify the ImGuiSliderFlags_AlwaysClamp when using this. -bool ImGui::DragFloatRange2(const char* label, float* v_current_min, float* v_current_max, float v_speed, float v_min, float v_max, const char* format, const char* format_max, ImGuiSliderFlags flags) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - - ImGuiContext& g = *GImGui; - PushID(label); - BeginGroup(); - PushMultiItemsWidths(2, CalcItemWidth()); - - float min_min = (v_min >= v_max) ? -FLT_MAX : v_min; - float min_max = (v_min >= v_max) ? *v_current_max : ImMin(v_max, *v_current_max); - ImGuiSliderFlags min_flags = flags | ((min_min == min_max) ? ImGuiSliderFlags_ReadOnly : 0); - bool value_changed = DragScalar("##min", ImGuiDataType_Float, v_current_min, v_speed, &min_min, &min_max, format, min_flags); - PopItemWidth(); - SameLine(0, g.Style.ItemInnerSpacing.x); - - float max_min = (v_min >= v_max) ? *v_current_min : ImMax(v_min, *v_current_min); - float max_max = (v_min >= v_max) ? FLT_MAX : v_max; - ImGuiSliderFlags max_flags = flags | ((max_min == max_max) ? ImGuiSliderFlags_ReadOnly : 0); - value_changed |= DragScalar("##max", ImGuiDataType_Float, v_current_max, v_speed, &max_min, &max_max, format_max ? format_max : format, max_flags); - PopItemWidth(); - SameLine(0, g.Style.ItemInnerSpacing.x); - - TextEx(label, FindRenderedTextEnd(label)); - EndGroup(); - PopID(); - - return value_changed; -} - -// NB: v_speed is float to allow adjusting the drag speed with more precision -bool ImGui::DragInt(const char* label, int* v, float v_speed, int v_min, int v_max, const char* format, ImGuiSliderFlags flags) -{ - return DragScalar(label, ImGuiDataType_S32, v, v_speed, &v_min, &v_max, format, flags); -} - -bool ImGui::DragInt2(const char* label, int v[2], float v_speed, int v_min, int v_max, const char* format, ImGuiSliderFlags flags) -{ - return DragScalarN(label, ImGuiDataType_S32, v, 2, v_speed, &v_min, &v_max, format, flags); -} - -bool ImGui::DragInt3(const char* label, int v[3], float v_speed, int v_min, int v_max, const char* format, ImGuiSliderFlags flags) -{ - return DragScalarN(label, ImGuiDataType_S32, v, 3, v_speed, &v_min, &v_max, format, flags); -} - -bool ImGui::DragInt4(const char* label, int v[4], float v_speed, int v_min, int v_max, const char* format, ImGuiSliderFlags flags) -{ - return DragScalarN(label, ImGuiDataType_S32, v, 4, v_speed, &v_min, &v_max, format, flags); -} - -// NB: You likely want to specify the ImGuiSliderFlags_AlwaysClamp when using this. -bool ImGui::DragIntRange2(const char* label, int* v_current_min, int* v_current_max, float v_speed, int v_min, int v_max, const char* format, const char* format_max, ImGuiSliderFlags flags) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - - ImGuiContext& g = *GImGui; - PushID(label); - BeginGroup(); - PushMultiItemsWidths(2, CalcItemWidth()); - - int min_min = (v_min >= v_max) ? INT_MIN : v_min; - int min_max = (v_min >= v_max) ? *v_current_max : ImMin(v_max, *v_current_max); - ImGuiSliderFlags min_flags = flags | ((min_min == min_max) ? ImGuiSliderFlags_ReadOnly : 0); - bool value_changed = DragInt("##min", v_current_min, v_speed, min_min, min_max, format, min_flags); - PopItemWidth(); - SameLine(0, g.Style.ItemInnerSpacing.x); - - int max_min = (v_min >= v_max) ? *v_current_min : ImMax(v_min, *v_current_min); - int max_max = (v_min >= v_max) ? INT_MAX : v_max; - ImGuiSliderFlags max_flags = flags | ((max_min == max_max) ? ImGuiSliderFlags_ReadOnly : 0); - value_changed |= DragInt("##max", v_current_max, v_speed, max_min, max_max, format_max ? format_max : format, max_flags); - PopItemWidth(); - SameLine(0, g.Style.ItemInnerSpacing.x); - - TextEx(label, FindRenderedTextEnd(label)); - EndGroup(); - PopID(); - - return value_changed; -} - -#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS - -// Obsolete versions with power parameter. See https://github.com/ocornut/imgui/issues/3361 for details. -bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* p_data, float v_speed, const void* p_min, const void* p_max, const char* format, float power) -{ - ImGuiSliderFlags drag_flags = ImGuiSliderFlags_None; - if (power != 1.0f) - { - IM_ASSERT(power == 1.0f && "Call function with ImGuiSliderFlags_Logarithmic flags instead of using the old 'float power' function!"); - IM_ASSERT(p_min != NULL && p_max != NULL); // When using a power curve the drag needs to have known bounds - drag_flags |= ImGuiSliderFlags_Logarithmic; // Fallback for non-asserting paths - } - return DragScalar(label, data_type, p_data, v_speed, p_min, p_max, format, drag_flags); -} - -bool ImGui::DragScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, float v_speed, const void* p_min, const void* p_max, const char* format, float power) -{ - ImGuiSliderFlags drag_flags = ImGuiSliderFlags_None; - if (power != 1.0f) - { - IM_ASSERT(power == 1.0f && "Call function with ImGuiSliderFlags_Logarithmic flags instead of using the old 'float power' function!"); - IM_ASSERT(p_min != NULL && p_max != NULL); // When using a power curve the drag needs to have known bounds - drag_flags |= ImGuiSliderFlags_Logarithmic; // Fallback for non-asserting paths - } - return DragScalarN(label, data_type, p_data, components, v_speed, p_min, p_max, format, drag_flags); -} - -#endif // IMGUI_DISABLE_OBSOLETE_FUNCTIONS - -//------------------------------------------------------------------------- -// [SECTION] Widgets: SliderScalar, SliderFloat, SliderInt, etc. -//------------------------------------------------------------------------- -// - ScaleRatioFromValueT<> [Internal] -// - ScaleValueFromRatioT<> [Internal] -// - SliderBehaviorT<>() [Internal] -// - SliderBehavior() [Internal] -// - SliderScalar() -// - SliderScalarN() -// - SliderFloat() -// - SliderFloat2() -// - SliderFloat3() -// - SliderFloat4() -// - SliderAngle() -// - SliderInt() -// - SliderInt2() -// - SliderInt3() -// - SliderInt4() -// - VSliderScalar() -// - VSliderFloat() -// - VSliderInt() -//------------------------------------------------------------------------- - -// Convert a value v in the output space of a slider into a parametric position on the slider itself (the logical opposite of ScaleValueFromRatioT) -template -float ImGui::ScaleRatioFromValueT(ImGuiDataType data_type, TYPE v, TYPE v_min, TYPE v_max, bool is_logarithmic, float logarithmic_zero_epsilon, float zero_deadzone_halfsize) -{ - if (v_min == v_max) - return 0.0f; - IM_UNUSED(data_type); - - const TYPE v_clamped = (v_min < v_max) ? ImClamp(v, v_min, v_max) : ImClamp(v, v_max, v_min); - if (is_logarithmic) - { - bool flipped = v_max < v_min; - - if (flipped) // Handle the case where the range is backwards - ImSwap(v_min, v_max); - - // Fudge min/max to avoid getting close to log(0) - FLOATTYPE v_min_fudged = (ImAbs((FLOATTYPE)v_min) < logarithmic_zero_epsilon) ? ((v_min < 0.0f) ? -logarithmic_zero_epsilon : logarithmic_zero_epsilon) : (FLOATTYPE)v_min; - FLOATTYPE v_max_fudged = (ImAbs((FLOATTYPE)v_max) < logarithmic_zero_epsilon) ? ((v_max < 0.0f) ? -logarithmic_zero_epsilon : logarithmic_zero_epsilon) : (FLOATTYPE)v_max; - - // Awkward special cases - we need ranges of the form (-100 .. 0) to convert to (-100 .. -epsilon), not (-100 .. epsilon) - if ((v_min == 0.0f) && (v_max < 0.0f)) - v_min_fudged = -logarithmic_zero_epsilon; - else if ((v_max == 0.0f) && (v_min < 0.0f)) - v_max_fudged = -logarithmic_zero_epsilon; - - float result; - - if (v_clamped <= v_min_fudged) - result = 0.0f; // Workaround for values that are in-range but below our fudge - else if (v_clamped >= v_max_fudged) - result = 1.0f; // Workaround for values that are in-range but above our fudge - else if ((v_min * v_max) < 0.0f) // Range crosses zero, so split into two portions - { - float zero_point_center = (-(float)v_min) / ((float)v_max - (float)v_min); // The zero point in parametric space. There's an argument we should take the logarithmic nature into account when calculating this, but for now this should do (and the most common case of a symmetrical range works fine) - float zero_point_snap_L = zero_point_center - zero_deadzone_halfsize; - float zero_point_snap_R = zero_point_center + zero_deadzone_halfsize; - if (v == 0.0f) - result = zero_point_center; // Special case for exactly zero - else if (v < 0.0f) - result = (1.0f - (float)(ImLog(-(FLOATTYPE)v_clamped / logarithmic_zero_epsilon) / ImLog(-v_min_fudged / logarithmic_zero_epsilon))) * zero_point_snap_L; - else - result = zero_point_snap_R + ((float)(ImLog((FLOATTYPE)v_clamped / logarithmic_zero_epsilon) / ImLog(v_max_fudged / logarithmic_zero_epsilon)) * (1.0f - zero_point_snap_R)); - } - else if ((v_min < 0.0f) || (v_max < 0.0f)) // Entirely negative slider - result = 1.0f - (float)(ImLog(-(FLOATTYPE)v_clamped / -v_max_fudged) / ImLog(-v_min_fudged / -v_max_fudged)); - else - result = (float)(ImLog((FLOATTYPE)v_clamped / v_min_fudged) / ImLog(v_max_fudged / v_min_fudged)); - - return flipped ? (1.0f - result) : result; - } - - // Linear slider - return (float)((FLOATTYPE)(SIGNEDTYPE)(v_clamped - v_min) / (FLOATTYPE)(SIGNEDTYPE)(v_max - v_min)); -} - -// Convert a parametric position on a slider into a value v in the output space (the logical opposite of ScaleRatioFromValueT) -template -TYPE ImGui::ScaleValueFromRatioT(ImGuiDataType data_type, float t, TYPE v_min, TYPE v_max, bool is_logarithmic, float logarithmic_zero_epsilon, float zero_deadzone_halfsize) -{ - if (v_min == v_max) - return v_min; - const bool is_floating_point = (data_type == ImGuiDataType_Float) || (data_type == ImGuiDataType_Double); - - TYPE result; - if (is_logarithmic) - { - // We special-case the extents because otherwise our fudging can lead to "mathematically correct" but non-intuitive behaviors like a fully-left slider not actually reaching the minimum value - if (t <= 0.0f) - result = v_min; - else if (t >= 1.0f) - result = v_max; - else - { - bool flipped = v_max < v_min; // Check if range is "backwards" - - // Fudge min/max to avoid getting silly results close to zero - FLOATTYPE v_min_fudged = (ImAbs((FLOATTYPE)v_min) < logarithmic_zero_epsilon) ? ((v_min < 0.0f) ? -logarithmic_zero_epsilon : logarithmic_zero_epsilon) : (FLOATTYPE)v_min; - FLOATTYPE v_max_fudged = (ImAbs((FLOATTYPE)v_max) < logarithmic_zero_epsilon) ? ((v_max < 0.0f) ? -logarithmic_zero_epsilon : logarithmic_zero_epsilon) : (FLOATTYPE)v_max; - - if (flipped) - ImSwap(v_min_fudged, v_max_fudged); - - // Awkward special case - we need ranges of the form (-100 .. 0) to convert to (-100 .. -epsilon), not (-100 .. epsilon) - if ((v_max == 0.0f) && (v_min < 0.0f)) - v_max_fudged = -logarithmic_zero_epsilon; - - float t_with_flip = flipped ? (1.0f - t) : t; // t, but flipped if necessary to account for us flipping the range - - if ((v_min * v_max) < 0.0f) // Range crosses zero, so we have to do this in two parts - { - float zero_point_center = (-(float)ImMin(v_min, v_max)) / ImAbs((float)v_max - (float)v_min); // The zero point in parametric space - float zero_point_snap_L = zero_point_center - zero_deadzone_halfsize; - float zero_point_snap_R = zero_point_center + zero_deadzone_halfsize; - if (t_with_flip >= zero_point_snap_L && t_with_flip <= zero_point_snap_R) - result = (TYPE)0.0f; // Special case to make getting exactly zero possible (the epsilon prevents it otherwise) - else if (t_with_flip < zero_point_center) - result = (TYPE)-(logarithmic_zero_epsilon * ImPow(-v_min_fudged / logarithmic_zero_epsilon, (FLOATTYPE)(1.0f - (t_with_flip / zero_point_snap_L)))); - else - result = (TYPE)(logarithmic_zero_epsilon * ImPow(v_max_fudged / logarithmic_zero_epsilon, (FLOATTYPE)((t_with_flip - zero_point_snap_R) / (1.0f - zero_point_snap_R)))); - } - else if ((v_min < 0.0f) || (v_max < 0.0f)) // Entirely negative slider - result = (TYPE)-(-v_max_fudged * ImPow(-v_min_fudged / -v_max_fudged, (FLOATTYPE)(1.0f - t_with_flip))); - else - result = (TYPE)(v_min_fudged * ImPow(v_max_fudged / v_min_fudged, (FLOATTYPE)t_with_flip)); - } - } - else - { - // Linear slider - if (is_floating_point) - { - result = ImLerp(v_min, v_max, t); - } - else - { - // - For integer values we want the clicking position to match the grab box so we round above - // This code is carefully tuned to work with large values (e.g. high ranges of U64) while preserving this property.. - // - Not doing a *1.0 multiply at the end of a range as it tends to be lossy. While absolute aiming at a large s64/u64 - // range is going to be imprecise anyway, with this check we at least make the edge values matches expected limits. - if (t < 1.0) - { - FLOATTYPE v_new_off_f = (SIGNEDTYPE)(v_max - v_min) * t; - result = (TYPE)((SIGNEDTYPE)v_min + (SIGNEDTYPE)(v_new_off_f + (FLOATTYPE)(v_min > v_max ? -0.5 : 0.5))); - } - else - { - result = v_max; - } - } - } - - return result; -} - -// FIXME: Move more of the code into SliderBehavior() -template -bool ImGui::SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, TYPE* v, const TYPE v_min, const TYPE v_max, const char* format, ImGuiSliderFlags flags, ImRect* out_grab_bb) -{ - ImGuiContext& g = *GImGui; - const ImGuiStyle& style = g.Style; - - const ImGuiAxis axis = (flags & ImGuiSliderFlags_Vertical) ? ImGuiAxis_Y : ImGuiAxis_X; - const bool is_logarithmic = (flags & ImGuiSliderFlags_Logarithmic) != 0; - const bool is_floating_point = (data_type == ImGuiDataType_Float) || (data_type == ImGuiDataType_Double); - - const float grab_padding = 2.0f; - const float slider_sz = (bb.Max[axis] - bb.Min[axis]) - grab_padding * 2.0f; - float grab_sz = style.GrabMinSize; - SIGNEDTYPE v_range = (v_min < v_max ? v_max - v_min : v_min - v_max); - if (!is_floating_point && v_range >= 0) // v_range < 0 may happen on integer overflows - grab_sz = ImMax((float)(slider_sz / (v_range + 1)), style.GrabMinSize); // For integer sliders: if possible have the grab size represent 1 unit - grab_sz = ImMin(grab_sz, slider_sz); - const float slider_usable_sz = slider_sz - grab_sz; - const float slider_usable_pos_min = bb.Min[axis] + grab_padding + grab_sz * 0.5f; - const float slider_usable_pos_max = bb.Max[axis] - grab_padding - grab_sz * 0.5f; - - float logarithmic_zero_epsilon = 0.0f; // Only valid when is_logarithmic is true - float zero_deadzone_halfsize = 0.0f; // Only valid when is_logarithmic is true - if (is_logarithmic) - { - // When using logarithmic sliders, we need to clamp to avoid hitting zero, but our choice of clamp value greatly affects slider precision. We attempt to use the specified precision to estimate a good lower bound. - const int decimal_precision = is_floating_point ? ImParseFormatPrecision(format, 3) : 1; - logarithmic_zero_epsilon = ImPow(0.1f, (float)decimal_precision); - zero_deadzone_halfsize = (style.LogSliderDeadzone * 0.5f) / ImMax(slider_usable_sz, 1.0f); - } - - // Process interacting with the slider - bool value_changed = false; - if (g.ActiveId == id) - { - bool set_new_value = false; - float clicked_t = 0.0f; - if (g.ActiveIdSource == ImGuiInputSource_Mouse) - { - if (!g.IO.MouseDown[0]) - { - ClearActiveID(); - } - else - { - const float mouse_abs_pos = g.IO.MousePos[axis]; - clicked_t = (slider_usable_sz > 0.0f) ? ImClamp((mouse_abs_pos - slider_usable_pos_min) / slider_usable_sz, 0.0f, 1.0f) : 0.0f; - if (axis == ImGuiAxis_Y) - clicked_t = 1.0f - clicked_t; - set_new_value = true; - } - } - else if (g.ActiveIdSource == ImGuiInputSource_Nav) - { - if (g.ActiveIdIsJustActivated) - { - g.SliderCurrentAccum = 0.0f; // Reset any stored nav delta upon activation - g.SliderCurrentAccumDirty = false; - } - - const ImVec2 input_delta2 = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard | ImGuiNavDirSourceFlags_PadDPad, ImGuiInputReadMode_RepeatFast, 0.0f, 0.0f); - float input_delta = (axis == ImGuiAxis_X) ? input_delta2.x : -input_delta2.y; - if (input_delta != 0.0f) - { - const int decimal_precision = is_floating_point ? ImParseFormatPrecision(format, 3) : 0; - if (decimal_precision > 0) - { - input_delta /= 100.0f; // Gamepad/keyboard tweak speeds in % of slider bounds - if (IsNavInputDown(ImGuiNavInput_TweakSlow)) - input_delta /= 10.0f; - } - else - { - if ((v_range >= -100.0f && v_range <= 100.0f) || IsNavInputDown(ImGuiNavInput_TweakSlow)) - input_delta = ((input_delta < 0.0f) ? -1.0f : +1.0f) / (float)v_range; // Gamepad/keyboard tweak speeds in integer steps - else - input_delta /= 100.0f; - } - if (IsNavInputDown(ImGuiNavInput_TweakFast)) - input_delta *= 10.0f; - - g.SliderCurrentAccum += input_delta; - g.SliderCurrentAccumDirty = true; - } - - float delta = g.SliderCurrentAccum; - if (g.NavActivatePressedId == id && !g.ActiveIdIsJustActivated) - { - ClearActiveID(); - } - else if (g.SliderCurrentAccumDirty) - { - clicked_t = ScaleRatioFromValueT(data_type, *v, v_min, v_max, is_logarithmic, logarithmic_zero_epsilon, zero_deadzone_halfsize); - - if ((clicked_t >= 1.0f && delta > 0.0f) || (clicked_t <= 0.0f && delta < 0.0f)) // This is to avoid applying the saturation when already past the limits - { - set_new_value = false; - g.SliderCurrentAccum = 0.0f; // If pushing up against the limits, don't continue to accumulate - } - else - { - set_new_value = true; - float old_clicked_t = clicked_t; - clicked_t = ImSaturate(clicked_t + delta); - - // Calculate what our "new" clicked_t will be, and thus how far we actually moved the slider, and subtract this from the accumulator - TYPE v_new = ScaleValueFromRatioT(data_type, clicked_t, v_min, v_max, is_logarithmic, logarithmic_zero_epsilon, zero_deadzone_halfsize); - if (!(flags & ImGuiSliderFlags_NoRoundToFormat)) - v_new = RoundScalarWithFormatT(format, data_type, v_new); - float new_clicked_t = ScaleRatioFromValueT(data_type, v_new, v_min, v_max, is_logarithmic, logarithmic_zero_epsilon, zero_deadzone_halfsize); - - if (delta > 0) - g.SliderCurrentAccum -= ImMin(new_clicked_t - old_clicked_t, delta); - else - g.SliderCurrentAccum -= ImMax(new_clicked_t - old_clicked_t, delta); - } - - g.SliderCurrentAccumDirty = false; - } - } - - if (set_new_value) - { - TYPE v_new = ScaleValueFromRatioT(data_type, clicked_t, v_min, v_max, is_logarithmic, logarithmic_zero_epsilon, zero_deadzone_halfsize); - - // Round to user desired precision based on format string - if (!(flags & ImGuiSliderFlags_NoRoundToFormat)) - v_new = RoundScalarWithFormatT(format, data_type, v_new); - - // Apply result - if (*v != v_new) - { - *v = v_new; - value_changed = true; - } - } - } - - if (slider_sz < 1.0f) - { - *out_grab_bb = ImRect(bb.Min, bb.Min); - } - else - { - // Output grab position so it can be displayed by the caller - float grab_t = ScaleRatioFromValueT(data_type, *v, v_min, v_max, is_logarithmic, logarithmic_zero_epsilon, zero_deadzone_halfsize); - if (axis == ImGuiAxis_Y) - grab_t = 1.0f - grab_t; - const float grab_pos = ImLerp(slider_usable_pos_min, slider_usable_pos_max, grab_t); - if (axis == ImGuiAxis_X) - *out_grab_bb = ImRect(grab_pos - grab_sz * 0.5f, bb.Min.y + grab_padding, grab_pos + grab_sz * 0.5f, bb.Max.y - grab_padding); - else - *out_grab_bb = ImRect(bb.Min.x + grab_padding, grab_pos - grab_sz * 0.5f, bb.Max.x - grab_padding, grab_pos + grab_sz * 0.5f); - } - - return value_changed; -} - -// For 32-bit and larger types, slider bounds are limited to half the natural type range. -// So e.g. an integer Slider between INT_MAX-10 and INT_MAX will fail, but an integer Slider between INT_MAX/2-10 and INT_MAX/2 will be ok. -// It would be possible to lift that limitation with some work but it doesn't seem to be worth it for sliders. -bool ImGui::SliderBehavior(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, void* p_v, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags, ImRect* out_grab_bb) -{ - // Read imgui.cpp "API BREAKING CHANGES" section for 1.78 if you hit this assert. - IM_ASSERT((flags == 1 || (flags & ImGuiSliderFlags_InvalidMask_) == 0) && "Invalid ImGuiSliderFlags flag! Has the 'float power' argument been mistakenly cast to flags? Call function with ImGuiSliderFlags_Logarithmic flags instead."); - - ImGuiContext& g = *GImGui; - if ((g.LastItemData.InFlags & ImGuiItemFlags_ReadOnly) || (flags & ImGuiSliderFlags_ReadOnly)) - return false; - - switch (data_type) - { - case ImGuiDataType_S8: { ImS32 v32 = (ImS32)*(ImS8*)p_v; bool r = SliderBehaviorT(bb, id, ImGuiDataType_S32, &v32, *(const ImS8*)p_min, *(const ImS8*)p_max, format, flags, out_grab_bb); if (r) *(ImS8*)p_v = (ImS8)v32; return r; } - case ImGuiDataType_U8: { ImU32 v32 = (ImU32)*(ImU8*)p_v; bool r = SliderBehaviorT(bb, id, ImGuiDataType_U32, &v32, *(const ImU8*)p_min, *(const ImU8*)p_max, format, flags, out_grab_bb); if (r) *(ImU8*)p_v = (ImU8)v32; return r; } - case ImGuiDataType_S16: { ImS32 v32 = (ImS32)*(ImS16*)p_v; bool r = SliderBehaviorT(bb, id, ImGuiDataType_S32, &v32, *(const ImS16*)p_min, *(const ImS16*)p_max, format, flags, out_grab_bb); if (r) *(ImS16*)p_v = (ImS16)v32; return r; } - case ImGuiDataType_U16: { ImU32 v32 = (ImU32)*(ImU16*)p_v; bool r = SliderBehaviorT(bb, id, ImGuiDataType_U32, &v32, *(const ImU16*)p_min, *(const ImU16*)p_max, format, flags, out_grab_bb); if (r) *(ImU16*)p_v = (ImU16)v32; return r; } - case ImGuiDataType_S32: - IM_ASSERT(*(const ImS32*)p_min >= IM_S32_MIN / 2 && *(const ImS32*)p_max <= IM_S32_MAX / 2); - return SliderBehaviorT(bb, id, data_type, (ImS32*)p_v, *(const ImS32*)p_min, *(const ImS32*)p_max, format, flags, out_grab_bb); - case ImGuiDataType_U32: - IM_ASSERT(*(const ImU32*)p_max <= IM_U32_MAX / 2); - return SliderBehaviorT(bb, id, data_type, (ImU32*)p_v, *(const ImU32*)p_min, *(const ImU32*)p_max, format, flags, out_grab_bb); - case ImGuiDataType_S64: - IM_ASSERT(*(const ImS64*)p_min >= IM_S64_MIN / 2 && *(const ImS64*)p_max <= IM_S64_MAX / 2); - return SliderBehaviorT(bb, id, data_type, (ImS64*)p_v, *(const ImS64*)p_min, *(const ImS64*)p_max, format, flags, out_grab_bb); - case ImGuiDataType_U64: - IM_ASSERT(*(const ImU64*)p_max <= IM_U64_MAX / 2); - return SliderBehaviorT(bb, id, data_type, (ImU64*)p_v, *(const ImU64*)p_min, *(const ImU64*)p_max, format, flags, out_grab_bb); - case ImGuiDataType_Float: - IM_ASSERT(*(const float*)p_min >= -FLT_MAX / 2.0f && *(const float*)p_max <= FLT_MAX / 2.0f); - return SliderBehaviorT(bb, id, data_type, (float*)p_v, *(const float*)p_min, *(const float*)p_max, format, flags, out_grab_bb); - case ImGuiDataType_Double: - IM_ASSERT(*(const double*)p_min >= -DBL_MAX / 2.0f && *(const double*)p_max <= DBL_MAX / 2.0f); - return SliderBehaviorT(bb, id, data_type, (double*)p_v, *(const double*)p_min, *(const double*)p_max, format, flags, out_grab_bb); - case ImGuiDataType_COUNT: break; - } - IM_ASSERT(0); - return false; -} - -// Note: p_data, p_min and p_max are _pointers_ to a memory address holding the data. For a slider, they are all required. -// Read code of e.g. SliderFloat(), SliderInt() etc. or examples in 'Demo->Widgets->Data Types' to understand how to use this function directly. -bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - - ImGuiContext& g = *GImGui; - const ImGuiStyle& style = g.Style; - const ImGuiID id = window->GetID(label); - const float w = CalcItemWidth(); - - const ImVec2 label_size = CalcTextSize(label, NULL, true); - const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y * 2.0f)); - const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f)); - - const bool temp_input_allowed = (flags & ImGuiSliderFlags_NoInput) == 0; - ItemSize(total_bb, style.FramePadding.y); - if (!ItemAdd(total_bb, id, &frame_bb, temp_input_allowed ? ImGuiItemFlags_Inputable : 0)) - return false; - - // Default format string when passing NULL - if (format == NULL) - format = DataTypeGetInfo(data_type)->PrintFmt; - else if (data_type == ImGuiDataType_S32 && strcmp(format, "%d") != 0) // (FIXME-LEGACY: Patch old "%.0f" format string to use "%d", read function more details.) - format = PatchFormatStringFloatToInt(format); - - // Tabbing or CTRL-clicking on Slider turns it into an input box - const bool hovered = ItemHoverable(frame_bb, id); - bool temp_input_is_active = temp_input_allowed && TempInputIsActive(id); - if (!temp_input_is_active) - { - const bool input_requested_by_tabbing = temp_input_allowed && (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_FocusedByTabbing) != 0; - const bool clicked = (hovered && g.IO.MouseClicked[0]); - if (input_requested_by_tabbing || clicked || g.NavActivateId == id || g.NavActivateInputId == id) - { - SetActiveID(id, window); - SetFocusID(id, window); - FocusWindow(window); - g.ActiveIdUsingNavDirMask |= (1 << ImGuiDir_Left) | (1 << ImGuiDir_Right); - if (temp_input_allowed && (input_requested_by_tabbing || (clicked && g.IO.KeyCtrl) || g.NavActivateInputId == id)) - temp_input_is_active = true; - } - } - - if (temp_input_is_active) - { - // Only clamp CTRL+Click input when ImGuiSliderFlags_AlwaysClamp is set - const bool is_clamp_input = (flags & ImGuiSliderFlags_AlwaysClamp) != 0; - return TempInputScalar(frame_bb, id, label, data_type, p_data, format, is_clamp_input ? p_min : NULL, is_clamp_input ? p_max : NULL); - } - - // Draw frame - const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg); - RenderNavHighlight(frame_bb, id); - RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, true, g.Style.FrameRounding); - - // Slider behavior - ImRect grab_bb; - const bool value_changed = SliderBehavior(frame_bb, id, data_type, p_data, p_min, p_max, format, flags, &grab_bb); - if (value_changed) - MarkItemEdited(id); - - // Render grab - if (grab_bb.Max.x > grab_bb.Min.x) - window->DrawList->AddRectFilled(grab_bb.Min, grab_bb.Max, GetColorU32(g.ActiveId == id ? ImGuiCol_SliderGrabActive : ImGuiCol_SliderGrab), style.GrabRounding); - - // Display value using user-provided display format so user can add prefix/suffix/decorations to the value. - char value_buf[64]; - const char* value_buf_end = value_buf + DataTypeFormatString(value_buf, IM_ARRAYSIZE(value_buf), data_type, p_data, format); - if (g.LogEnabled) - LogSetNextTextDecoration("{", "}"); - RenderTextClipped(frame_bb.Min, frame_bb.Max, value_buf, value_buf_end, NULL, ImVec2(0.5f, 0.5f)); - - if (label_size.x > 0.0f) - RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label); - - IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags); - return value_changed; -} - -// Add multiple sliders on 1 line for compact edition of multiple components -bool ImGui::SliderScalarN(const char* label, ImGuiDataType data_type, void* v, int components, const void* v_min, const void* v_max, const char* format, ImGuiSliderFlags flags) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - - ImGuiContext& g = *GImGui; - bool value_changed = false; - BeginGroup(); - PushID(label); - PushMultiItemsWidths(components, CalcItemWidth()); - size_t type_size = GDataTypeInfo[data_type].Size; - for (int i = 0; i < components; i++) - { - PushID(i); - if (i > 0) - SameLine(0, g.Style.ItemInnerSpacing.x); - value_changed |= SliderScalar("", data_type, v, v_min, v_max, format, flags); - PopID(); - PopItemWidth(); - v = (void*)((char*)v + type_size); - } - PopID(); - - const char* label_end = FindRenderedTextEnd(label); - if (label != label_end) - { - SameLine(0, g.Style.ItemInnerSpacing.x); - TextEx(label, label_end); - } - - EndGroup(); - return value_changed; -} - -bool ImGui::SliderFloat(const char* label, float* v, float v_min, float v_max, const char* format, ImGuiSliderFlags flags) -{ - return SliderScalar(label, ImGuiDataType_Float, v, &v_min, &v_max, format, flags); -} - -bool ImGui::SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* format, ImGuiSliderFlags flags) -{ - return SliderScalarN(label, ImGuiDataType_Float, v, 2, &v_min, &v_max, format, flags); -} - -bool ImGui::SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* format, ImGuiSliderFlags flags) -{ - return SliderScalarN(label, ImGuiDataType_Float, v, 3, &v_min, &v_max, format, flags); -} - -bool ImGui::SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* format, ImGuiSliderFlags flags) -{ - return SliderScalarN(label, ImGuiDataType_Float, v, 4, &v_min, &v_max, format, flags); -} - -bool ImGui::SliderAngle(const char* label, float* v_rad, float v_degrees_min, float v_degrees_max, const char* format, ImGuiSliderFlags flags) -{ - if (format == NULL) - format = "%.0f deg"; - float v_deg = (*v_rad) * 360.0f / (2 * IM_PI); - bool value_changed = SliderFloat(label, &v_deg, v_degrees_min, v_degrees_max, format, flags); - *v_rad = v_deg * (2 * IM_PI) / 360.0f; - return value_changed; -} - -bool ImGui::SliderInt(const char* label, int* v, int v_min, int v_max, const char* format, ImGuiSliderFlags flags) -{ - return SliderScalar(label, ImGuiDataType_S32, v, &v_min, &v_max, format, flags); -} - -bool ImGui::SliderInt2(const char* label, int v[2], int v_min, int v_max, const char* format, ImGuiSliderFlags flags) -{ - return SliderScalarN(label, ImGuiDataType_S32, v, 2, &v_min, &v_max, format, flags); -} - -bool ImGui::SliderInt3(const char* label, int v[3], int v_min, int v_max, const char* format, ImGuiSliderFlags flags) -{ - return SliderScalarN(label, ImGuiDataType_S32, v, 3, &v_min, &v_max, format, flags); -} - -bool ImGui::SliderInt4(const char* label, int v[4], int v_min, int v_max, const char* format, ImGuiSliderFlags flags) -{ - return SliderScalarN(label, ImGuiDataType_S32, v, 4, &v_min, &v_max, format, flags); -} - -bool ImGui::VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - - ImGuiContext& g = *GImGui; - const ImGuiStyle& style = g.Style; - const ImGuiID id = window->GetID(label); - - const ImVec2 label_size = CalcTextSize(label, NULL, true); - const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + size); - const ImRect bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f)); - - ItemSize(bb, style.FramePadding.y); - if (!ItemAdd(frame_bb, id)) - return false; - - // Default format string when passing NULL - if (format == NULL) - format = DataTypeGetInfo(data_type)->PrintFmt; - else if (data_type == ImGuiDataType_S32 && strcmp(format, "%d") != 0) // (FIXME-LEGACY: Patch old "%.0f" format string to use "%d", read function more details.) - format = PatchFormatStringFloatToInt(format); - - const bool hovered = ItemHoverable(frame_bb, id); - if ((hovered && g.IO.MouseClicked[0]) || g.NavActivateId == id || g.NavActivateInputId == id) - { - SetActiveID(id, window); - SetFocusID(id, window); - FocusWindow(window); - g.ActiveIdUsingNavDirMask |= (1 << ImGuiDir_Up) | (1 << ImGuiDir_Down); - } - - // Draw frame - const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg); - RenderNavHighlight(frame_bb, id); - RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, true, g.Style.FrameRounding); - - // Slider behavior - ImRect grab_bb; - const bool value_changed = SliderBehavior(frame_bb, id, data_type, p_data, p_min, p_max, format, flags | ImGuiSliderFlags_Vertical, &grab_bb); - if (value_changed) - MarkItemEdited(id); - - // Render grab - if (grab_bb.Max.y > grab_bb.Min.y) - window->DrawList->AddRectFilled(grab_bb.Min, grab_bb.Max, GetColorU32(g.ActiveId == id ? ImGuiCol_SliderGrabActive : ImGuiCol_SliderGrab), style.GrabRounding); - - // Display value using user-provided display format so user can add prefix/suffix/decorations to the value. - // For the vertical slider we allow centered text to overlap the frame padding - char value_buf[64]; - const char* value_buf_end = value_buf + DataTypeFormatString(value_buf, IM_ARRAYSIZE(value_buf), data_type, p_data, format); - RenderTextClipped(ImVec2(frame_bb.Min.x, frame_bb.Min.y + style.FramePadding.y), frame_bb.Max, value_buf, value_buf_end, NULL, ImVec2(0.5f, 0.0f)); - if (label_size.x > 0.0f) - RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label); - - return value_changed; -} - -bool ImGui::VSliderFloat(const char* label, const ImVec2& size, float* v, float v_min, float v_max, const char* format, ImGuiSliderFlags flags) -{ - return VSliderScalar(label, size, ImGuiDataType_Float, v, &v_min, &v_max, format, flags); -} - -bool ImGui::VSliderInt(const char* label, const ImVec2& size, int* v, int v_min, int v_max, const char* format, ImGuiSliderFlags flags) -{ - return VSliderScalar(label, size, ImGuiDataType_S32, v, &v_min, &v_max, format, flags); -} - -#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS - -// Obsolete versions with power parameter. See https://github.com/ocornut/imgui/issues/3361 for details. -bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format, float power) -{ - ImGuiSliderFlags slider_flags = ImGuiSliderFlags_None; - if (power != 1.0f) - { - IM_ASSERT(power == 1.0f && "Call function with ImGuiSliderFlags_Logarithmic flags instead of using the old 'float power' function!"); - slider_flags |= ImGuiSliderFlags_Logarithmic; // Fallback for non-asserting paths - } - return SliderScalar(label, data_type, p_data, p_min, p_max, format, slider_flags); -} - -bool ImGui::SliderScalarN(const char* label, ImGuiDataType data_type, void* v, int components, const void* v_min, const void* v_max, const char* format, float power) -{ - ImGuiSliderFlags slider_flags = ImGuiSliderFlags_None; - if (power != 1.0f) - { - IM_ASSERT(power == 1.0f && "Call function with ImGuiSliderFlags_Logarithmic flags instead of using the old 'float power' function!"); - slider_flags |= ImGuiSliderFlags_Logarithmic; // Fallback for non-asserting paths - } - return SliderScalarN(label, data_type, v, components, v_min, v_max, format, slider_flags); -} - -#endif // IMGUI_DISABLE_OBSOLETE_FUNCTIONS - -//------------------------------------------------------------------------- -// [SECTION] Widgets: InputScalar, InputFloat, InputInt, etc. -//------------------------------------------------------------------------- -// - ImParseFormatFindStart() [Internal] -// - ImParseFormatFindEnd() [Internal] -// - ImParseFormatTrimDecorations() [Internal] -// - ImParseFormatPrecision() [Internal] -// - TempInputTextScalar() [Internal] -// - InputScalar() -// - InputScalarN() -// - InputFloat() -// - InputFloat2() -// - InputFloat3() -// - InputFloat4() -// - InputInt() -// - InputInt2() -// - InputInt3() -// - InputInt4() -// - InputDouble() -//------------------------------------------------------------------------- - -// We don't use strchr() because our strings are usually very short and often start with '%' -const char* ImParseFormatFindStart(const char* fmt) -{ - while (char c = fmt[0]) - { - if (c == '%' && fmt[1] != '%') - return fmt; - else if (c == '%') - fmt++; - fmt++; - } - return fmt; -} - -const char* ImParseFormatFindEnd(const char* fmt) -{ - // Printf/scanf types modifiers: I/L/h/j/l/t/w/z. Other uppercase letters qualify as types aka end of the format. - if (fmt[0] != '%') - return fmt; - const unsigned int ignored_uppercase_mask = (1 << ('I'-'A')) | (1 << ('L'-'A')); - const unsigned int ignored_lowercase_mask = (1 << ('h'-'a')) | (1 << ('j'-'a')) | (1 << ('l'-'a')) | (1 << ('t'-'a')) | (1 << ('w'-'a')) | (1 << ('z'-'a')); - for (char c; (c = *fmt) != 0; fmt++) - { - if (c >= 'A' && c <= 'Z' && ((1 << (c - 'A')) & ignored_uppercase_mask) == 0) - return fmt + 1; - if (c >= 'a' && c <= 'z' && ((1 << (c - 'a')) & ignored_lowercase_mask) == 0) - return fmt + 1; - } - return fmt; -} - -// Extract the format out of a format string with leading or trailing decorations -// fmt = "blah blah" -> return fmt -// fmt = "%.3f" -> return fmt -// fmt = "hello %.3f" -> return fmt + 6 -// fmt = "%.3f hello" -> return buf written with "%.3f" -const char* ImParseFormatTrimDecorations(const char* fmt, char* buf, size_t buf_size) -{ - const char* fmt_start = ImParseFormatFindStart(fmt); - if (fmt_start[0] != '%') - return fmt; - const char* fmt_end = ImParseFormatFindEnd(fmt_start); - if (fmt_end[0] == 0) // If we only have leading decoration, we don't need to copy the data. - return fmt_start; - ImStrncpy(buf, fmt_start, ImMin((size_t)(fmt_end - fmt_start) + 1, buf_size)); - return buf; -} - -// Parse display precision back from the display format string -// FIXME: This is still used by some navigation code path to infer a minimum tweak step, but we should aim to rework widgets so it isn't needed. -int ImParseFormatPrecision(const char* fmt, int default_precision) -{ - fmt = ImParseFormatFindStart(fmt); - if (fmt[0] != '%') - return default_precision; - fmt++; - while (*fmt >= '0' && *fmt <= '9') - fmt++; - int precision = INT_MAX; - if (*fmt == '.') - { - fmt = ImAtoi(fmt + 1, &precision); - if (precision < 0 || precision > 99) - precision = default_precision; - } - if (*fmt == 'e' || *fmt == 'E') // Maximum precision with scientific notation - precision = -1; - if ((*fmt == 'g' || *fmt == 'G') && precision == INT_MAX) - precision = -1; - return (precision == INT_MAX) ? default_precision : precision; -} - -// Create text input in place of another active widget (e.g. used when doing a CTRL+Click on drag/slider widgets) -// FIXME: Facilitate using this in variety of other situations. -bool ImGui::TempInputText(const ImRect& bb, ImGuiID id, const char* label, char* buf, int buf_size, ImGuiInputTextFlags flags) -{ - // On the first frame, g.TempInputTextId == 0, then on subsequent frames it becomes == id. - // We clear ActiveID on the first frame to allow the InputText() taking it back. - ImGuiContext& g = *GImGui; - const bool init = (g.TempInputId != id); - if (init) - ClearActiveID(); - - g.CurrentWindow->DC.CursorPos = bb.Min; - bool value_changed = InputTextEx(label, NULL, buf, buf_size, bb.GetSize(), flags | ImGuiInputTextFlags_MergedItem); - if (init) - { - // First frame we started displaying the InputText widget, we expect it to take the active id. - IM_ASSERT(g.ActiveId == id); - g.TempInputId = g.ActiveId; - } - return value_changed; -} - -// Note that Drag/Slider functions are only forwarding the min/max values clamping values if the ImGuiSliderFlags_AlwaysClamp flag is set! -// This is intended: this way we allow CTRL+Click manual input to set a value out of bounds, for maximum flexibility. -// However this may not be ideal for all uses, as some user code may break on out of bound values. -bool ImGui::TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImGuiDataType data_type, void* p_data, const char* format, const void* p_clamp_min, const void* p_clamp_max) -{ - ImGuiContext& g = *GImGui; - - char fmt_buf[32]; - char data_buf[32]; - format = ImParseFormatTrimDecorations(format, fmt_buf, IM_ARRAYSIZE(fmt_buf)); - DataTypeFormatString(data_buf, IM_ARRAYSIZE(data_buf), data_type, p_data, format); - ImStrTrimBlanks(data_buf); - - ImGuiInputTextFlags flags = ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_NoMarkEdited; - flags |= ((data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double) ? ImGuiInputTextFlags_CharsScientific : ImGuiInputTextFlags_CharsDecimal); - bool value_changed = false; - if (TempInputText(bb, id, label, data_buf, IM_ARRAYSIZE(data_buf), flags)) - { - // Backup old value - size_t data_type_size = DataTypeGetInfo(data_type)->Size; - ImGuiDataTypeTempStorage data_backup; - memcpy(&data_backup, p_data, data_type_size); - - // Apply new value (or operations) then clamp - DataTypeApplyOpFromText(data_buf, g.InputTextState.InitialTextA.Data, data_type, p_data, NULL); - if (p_clamp_min || p_clamp_max) - { - if (p_clamp_min && p_clamp_max && DataTypeCompare(data_type, p_clamp_min, p_clamp_max) > 0) - ImSwap(p_clamp_min, p_clamp_max); - DataTypeClamp(data_type, p_data, p_clamp_min, p_clamp_max); - } - - // Only mark as edited if new value is different - value_changed = memcmp(&data_backup, p_data, data_type_size) != 0; - if (value_changed) - MarkItemEdited(id); - } - return value_changed; -} - -// Note: p_data, p_step, p_step_fast are _pointers_ to a memory address holding the data. For an Input widget, p_step and p_step_fast are optional. -// Read code of e.g. InputFloat(), InputInt() etc. or examples in 'Demo->Widgets->Data Types' to understand how to use this function directly. -bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_step, const void* p_step_fast, const char* format, ImGuiInputTextFlags flags) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - - ImGuiContext& g = *GImGui; - ImGuiStyle& style = g.Style; - - if (format == NULL) - format = DataTypeGetInfo(data_type)->PrintFmt; - - char buf[64]; - DataTypeFormatString(buf, IM_ARRAYSIZE(buf), data_type, p_data, format); - - bool value_changed = false; - if ((flags & (ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsScientific)) == 0) - flags |= ImGuiInputTextFlags_CharsDecimal; - flags |= ImGuiInputTextFlags_AutoSelectAll; - flags |= ImGuiInputTextFlags_NoMarkEdited; // We call MarkItemEdited() ourselves by comparing the actual data rather than the string. - - if (p_step != NULL) - { - const float button_size = GetFrameHeight(); - - BeginGroup(); // The only purpose of the group here is to allow the caller to query item data e.g. IsItemActive() - PushID(label); - SetNextItemWidth(ImMax(1.0f, CalcItemWidth() - (button_size + style.ItemInnerSpacing.x) * 2)); - if (InputText("", buf, IM_ARRAYSIZE(buf), flags)) // PushId(label) + "" gives us the expected ID from outside point of view - value_changed = DataTypeApplyOpFromText(buf, g.InputTextState.InitialTextA.Data, data_type, p_data, format); - - // Step buttons - const ImVec2 backup_frame_padding = style.FramePadding; - style.FramePadding.x = style.FramePadding.y; - ImGuiButtonFlags button_flags = ImGuiButtonFlags_Repeat | ImGuiButtonFlags_DontClosePopups; - if (flags & ImGuiInputTextFlags_ReadOnly) - BeginDisabled(); - SameLine(0, style.ItemInnerSpacing.x); - if (ButtonEx("-", ImVec2(button_size, button_size), button_flags)) - { - DataTypeApplyOp(data_type, '-', p_data, p_data, g.IO.KeyCtrl && p_step_fast ? p_step_fast : p_step); - value_changed = true; - } - SameLine(0, style.ItemInnerSpacing.x); - if (ButtonEx("+", ImVec2(button_size, button_size), button_flags)) - { - DataTypeApplyOp(data_type, '+', p_data, p_data, g.IO.KeyCtrl && p_step_fast ? p_step_fast : p_step); - value_changed = true; - } - if (flags & ImGuiInputTextFlags_ReadOnly) - EndDisabled(); - - const char* label_end = FindRenderedTextEnd(label); - if (label != label_end) - { - SameLine(0, style.ItemInnerSpacing.x); - TextEx(label, label_end); - } - style.FramePadding = backup_frame_padding; - - PopID(); - EndGroup(); - } - else - { - if (InputText(label, buf, IM_ARRAYSIZE(buf), flags)) - value_changed = DataTypeApplyOpFromText(buf, g.InputTextState.InitialTextA.Data, data_type, p_data, format); - } - if (value_changed) - MarkItemEdited(g.LastItemData.ID); - - return value_changed; -} - -bool ImGui::InputScalarN(const char* label, ImGuiDataType data_type, void* p_data, int components, const void* p_step, const void* p_step_fast, const char* format, ImGuiInputTextFlags flags) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - - ImGuiContext& g = *GImGui; - bool value_changed = false; - BeginGroup(); - PushID(label); - PushMultiItemsWidths(components, CalcItemWidth()); - size_t type_size = GDataTypeInfo[data_type].Size; - for (int i = 0; i < components; i++) - { - PushID(i); - if (i > 0) - SameLine(0, g.Style.ItemInnerSpacing.x); - value_changed |= InputScalar("", data_type, p_data, p_step, p_step_fast, format, flags); - PopID(); - PopItemWidth(); - p_data = (void*)((char*)p_data + type_size); - } - PopID(); - - const char* label_end = FindRenderedTextEnd(label); - if (label != label_end) - { - SameLine(0.0f, g.Style.ItemInnerSpacing.x); - TextEx(label, label_end); - } - - EndGroup(); - return value_changed; -} - -bool ImGui::InputFloat(const char* label, float* v, float step, float step_fast, const char* format, ImGuiInputTextFlags flags) -{ - flags |= ImGuiInputTextFlags_CharsScientific; - return InputScalar(label, ImGuiDataType_Float, (void*)v, (void*)(step > 0.0f ? &step : NULL), (void*)(step_fast > 0.0f ? &step_fast : NULL), format, flags); -} - -bool ImGui::InputFloat2(const char* label, float v[2], const char* format, ImGuiInputTextFlags flags) -{ - return InputScalarN(label, ImGuiDataType_Float, v, 2, NULL, NULL, format, flags); -} - -bool ImGui::InputFloat3(const char* label, float v[3], const char* format, ImGuiInputTextFlags flags) -{ - return InputScalarN(label, ImGuiDataType_Float, v, 3, NULL, NULL, format, flags); -} - -bool ImGui::InputFloat4(const char* label, float v[4], const char* format, ImGuiInputTextFlags flags) -{ - return InputScalarN(label, ImGuiDataType_Float, v, 4, NULL, NULL, format, flags); -} - -bool ImGui::InputInt(const char* label, int* v, int step, int step_fast, ImGuiInputTextFlags flags) -{ - // Hexadecimal input provided as a convenience but the flag name is awkward. Typically you'd use InputText() to parse your own data, if you want to handle prefixes. - const char* format = (flags & ImGuiInputTextFlags_CharsHexadecimal) ? "%08X" : "%d"; - return InputScalar(label, ImGuiDataType_S32, (void*)v, (void*)(step > 0 ? &step : NULL), (void*)(step_fast > 0 ? &step_fast : NULL), format, flags); -} - -bool ImGui::InputInt2(const char* label, int v[2], ImGuiInputTextFlags flags) -{ - return InputScalarN(label, ImGuiDataType_S32, v, 2, NULL, NULL, "%d", flags); -} - -bool ImGui::InputInt3(const char* label, int v[3], ImGuiInputTextFlags flags) -{ - return InputScalarN(label, ImGuiDataType_S32, v, 3, NULL, NULL, "%d", flags); -} - -bool ImGui::InputInt4(const char* label, int v[4], ImGuiInputTextFlags flags) -{ - return InputScalarN(label, ImGuiDataType_S32, v, 4, NULL, NULL, "%d", flags); -} - -bool ImGui::InputDouble(const char* label, double* v, double step, double step_fast, const char* format, ImGuiInputTextFlags flags) -{ - flags |= ImGuiInputTextFlags_CharsScientific; - return InputScalar(label, ImGuiDataType_Double, (void*)v, (void*)(step > 0.0 ? &step : NULL), (void*)(step_fast > 0.0 ? &step_fast : NULL), format, flags); -} - -//------------------------------------------------------------------------- -// [SECTION] Widgets: InputText, InputTextMultiline, InputTextWithHint -//------------------------------------------------------------------------- -// - InputText() -// - InputTextWithHint() -// - InputTextMultiline() -// - InputTextEx() [Internal] -//------------------------------------------------------------------------- - -bool ImGui::InputText(const char* label, char* buf, size_t buf_size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) -{ - IM_ASSERT(!(flags & ImGuiInputTextFlags_Multiline)); // call InputTextMultiline() - return InputTextEx(label, NULL, buf, (int)buf_size, ImVec2(0, 0), flags, callback, user_data); -} - -bool ImGui::InputTextMultiline(const char* label, char* buf, size_t buf_size, const ImVec2& size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) -{ - return InputTextEx(label, NULL, buf, (int)buf_size, size, flags | ImGuiInputTextFlags_Multiline, callback, user_data); -} - -bool ImGui::InputTextWithHint(const char* label, const char* hint, char* buf, size_t buf_size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) -{ - IM_ASSERT(!(flags & ImGuiInputTextFlags_Multiline)); // call InputTextMultiline() - return InputTextEx(label, hint, buf, (int)buf_size, ImVec2(0, 0), flags, callback, user_data); -} - -static int InputTextCalcTextLenAndLineCount(const char* text_begin, const char** out_text_end) -{ - int line_count = 0; - const char* s = text_begin; - while (char c = *s++) // We are only matching for \n so we can ignore UTF-8 decoding - if (c == '\n') - line_count++; - s--; - if (s[0] != '\n' && s[0] != '\r') - line_count++; - *out_text_end = s; - return line_count; -} - -static ImVec2 InputTextCalcTextSizeW(const ImWchar* text_begin, const ImWchar* text_end, const ImWchar** remaining, ImVec2* out_offset, bool stop_on_new_line) -{ - ImGuiContext& g = *GImGui; - ImFont* font = g.Font; - const float line_height = g.FontSize; - const float scale = line_height / font->FontSize; - - ImVec2 text_size = ImVec2(0, 0); - float line_width = 0.0f; - - const ImWchar* s = text_begin; - while (s < text_end) - { - unsigned int c = (unsigned int)(*s++); - if (c == '\n') - { - text_size.x = ImMax(text_size.x, line_width); - text_size.y += line_height; - line_width = 0.0f; - if (stop_on_new_line) - break; - continue; - } - if (c == '\r') - continue; - - const float char_width = font->GetCharAdvance((ImWchar)c) * scale; - line_width += char_width; - } - - if (text_size.x < line_width) - text_size.x = line_width; - - if (out_offset) - *out_offset = ImVec2(line_width, text_size.y + line_height); // offset allow for the possibility of sitting after a trailing \n - - if (line_width > 0 || text_size.y == 0.0f) // whereas size.y will ignore the trailing \n - text_size.y += line_height; - - if (remaining) - *remaining = s; - - return text_size; -} - -// Wrapper for stb_textedit.h to edit text (our wrapper is for: statically sized buffer, single-line, wchar characters. InputText converts between UTF-8 and wchar) -namespace ImStb -{ - -static int STB_TEXTEDIT_STRINGLEN(const ImGuiInputTextState* obj) { return obj->CurLenW; } -static ImWchar STB_TEXTEDIT_GETCHAR(const ImGuiInputTextState* obj, int idx) { return obj->TextW[idx]; } -static float STB_TEXTEDIT_GETWIDTH(ImGuiInputTextState* obj, int line_start_idx, int char_idx) { ImWchar c = obj->TextW[line_start_idx + char_idx]; if (c == '\n') return STB_TEXTEDIT_GETWIDTH_NEWLINE; ImGuiContext& g = *GImGui; return g.Font->GetCharAdvance(c) * (g.FontSize / g.Font->FontSize); } -static int STB_TEXTEDIT_KEYTOTEXT(int key) { return key >= 0x200000 ? 0 : key; } -static ImWchar STB_TEXTEDIT_NEWLINE = '\n'; -static void STB_TEXTEDIT_LAYOUTROW(StbTexteditRow* r, ImGuiInputTextState* obj, int line_start_idx) -{ - const ImWchar* text = obj->TextW.Data; - const ImWchar* text_remaining = NULL; - const ImVec2 size = InputTextCalcTextSizeW(text + line_start_idx, text + obj->CurLenW, &text_remaining, NULL, true); - r->x0 = 0.0f; - r->x1 = size.x; - r->baseline_y_delta = size.y; - r->ymin = 0.0f; - r->ymax = size.y; - r->num_chars = (int)(text_remaining - (text + line_start_idx)); -} - -// When ImGuiInputTextFlags_Password is set, we don't want actions such as CTRL+Arrow to leak the fact that underlying data are blanks or separators. -static bool is_separator(unsigned int c) { return ImCharIsBlankW(c) || c==',' || c==';' || c=='(' || c==')' || c=='{' || c=='}' || c=='[' || c==']' || c=='|'; } -static int is_word_boundary_from_right(ImGuiInputTextState* obj, int idx) { if (obj->Flags & ImGuiInputTextFlags_Password) return 0; return idx > 0 ? (is_separator(obj->TextW[idx - 1]) && !is_separator(obj->TextW[idx]) ) : 1; } -static int STB_TEXTEDIT_MOVEWORDLEFT_IMPL(ImGuiInputTextState* obj, int idx) { idx--; while (idx >= 0 && !is_word_boundary_from_right(obj, idx)) idx--; return idx < 0 ? 0 : idx; } -#ifdef __APPLE__ // FIXME: Move setting to IO structure -static int is_word_boundary_from_left(ImGuiInputTextState* obj, int idx) { if (obj->Flags & ImGuiInputTextFlags_Password) return 0; return idx > 0 ? (!is_separator(obj->TextW[idx - 1]) && is_separator(obj->TextW[idx]) ) : 1; } -static int STB_TEXTEDIT_MOVEWORDRIGHT_IMPL(ImGuiInputTextState* obj, int idx) { idx++; int len = obj->CurLenW; while (idx < len && !is_word_boundary_from_left(obj, idx)) idx++; return idx > len ? len : idx; } -#else -static int STB_TEXTEDIT_MOVEWORDRIGHT_IMPL(ImGuiInputTextState* obj, int idx) { idx++; int len = obj->CurLenW; while (idx < len && !is_word_boundary_from_right(obj, idx)) idx++; return idx > len ? len : idx; } -#endif -#define STB_TEXTEDIT_MOVEWORDLEFT STB_TEXTEDIT_MOVEWORDLEFT_IMPL // They need to be #define for stb_textedit.h -#define STB_TEXTEDIT_MOVEWORDRIGHT STB_TEXTEDIT_MOVEWORDRIGHT_IMPL - -static void STB_TEXTEDIT_DELETECHARS(ImGuiInputTextState* obj, int pos, int n) -{ - ImWchar* dst = obj->TextW.Data + pos; - - // We maintain our buffer length in both UTF-8 and wchar formats - obj->Edited = true; - obj->CurLenA -= ImTextCountUtf8BytesFromStr(dst, dst + n); - obj->CurLenW -= n; - - // Offset remaining text (FIXME-OPT: Use memmove) - const ImWchar* src = obj->TextW.Data + pos + n; - while (ImWchar c = *src++) - *dst++ = c; - *dst = '\0'; -} - -static bool STB_TEXTEDIT_INSERTCHARS(ImGuiInputTextState* obj, int pos, const ImWchar* new_text, int new_text_len) -{ - const bool is_resizable = (obj->Flags & ImGuiInputTextFlags_CallbackResize) != 0; - const int text_len = obj->CurLenW; - IM_ASSERT(pos <= text_len); - - const int new_text_len_utf8 = ImTextCountUtf8BytesFromStr(new_text, new_text + new_text_len); - if (!is_resizable && (new_text_len_utf8 + obj->CurLenA + 1 > obj->BufCapacityA)) - return false; - - // Grow internal buffer if needed - if (new_text_len + text_len + 1 > obj->TextW.Size) - { - if (!is_resizable) - return false; - IM_ASSERT(text_len < obj->TextW.Size); - obj->TextW.resize(text_len + ImClamp(new_text_len * 4, 32, ImMax(256, new_text_len)) + 1); - } - - ImWchar* text = obj->TextW.Data; - if (pos != text_len) - memmove(text + pos + new_text_len, text + pos, (size_t)(text_len - pos) * sizeof(ImWchar)); - memcpy(text + pos, new_text, (size_t)new_text_len * sizeof(ImWchar)); - - obj->Edited = true; - obj->CurLenW += new_text_len; - obj->CurLenA += new_text_len_utf8; - obj->TextW[obj->CurLenW] = '\0'; - - return true; -} - -// We don't use an enum so we can build even with conflicting symbols (if another user of stb_textedit.h leak their STB_TEXTEDIT_K_* symbols) -#define STB_TEXTEDIT_K_LEFT 0x200000 // keyboard input to move cursor left -#define STB_TEXTEDIT_K_RIGHT 0x200001 // keyboard input to move cursor right -#define STB_TEXTEDIT_K_UP 0x200002 // keyboard input to move cursor up -#define STB_TEXTEDIT_K_DOWN 0x200003 // keyboard input to move cursor down -#define STB_TEXTEDIT_K_LINESTART 0x200004 // keyboard input to move cursor to start of line -#define STB_TEXTEDIT_K_LINEEND 0x200005 // keyboard input to move cursor to end of line -#define STB_TEXTEDIT_K_TEXTSTART 0x200006 // keyboard input to move cursor to start of text -#define STB_TEXTEDIT_K_TEXTEND 0x200007 // keyboard input to move cursor to end of text -#define STB_TEXTEDIT_K_DELETE 0x200008 // keyboard input to delete selection or character under cursor -#define STB_TEXTEDIT_K_BACKSPACE 0x200009 // keyboard input to delete selection or character left of cursor -#define STB_TEXTEDIT_K_UNDO 0x20000A // keyboard input to perform undo -#define STB_TEXTEDIT_K_REDO 0x20000B // keyboard input to perform redo -#define STB_TEXTEDIT_K_WORDLEFT 0x20000C // keyboard input to move cursor left one word -#define STB_TEXTEDIT_K_WORDRIGHT 0x20000D // keyboard input to move cursor right one word -#define STB_TEXTEDIT_K_PGUP 0x20000E // keyboard input to move cursor up a page -#define STB_TEXTEDIT_K_PGDOWN 0x20000F // keyboard input to move cursor down a page -#define STB_TEXTEDIT_K_SHIFT 0x400000 - -#define STB_TEXTEDIT_IMPLEMENTATION -#include "imstb_textedit.h" - -// stb_textedit internally allows for a single undo record to do addition and deletion, but somehow, calling -// the stb_textedit_paste() function creates two separate records, so we perform it manually. (FIXME: Report to nothings/stb?) -static void stb_textedit_replace(ImGuiInputTextState* str, STB_TexteditState* state, const STB_TEXTEDIT_CHARTYPE* text, int text_len) -{ - stb_text_makeundo_replace(str, state, 0, str->CurLenW, text_len); - ImStb::STB_TEXTEDIT_DELETECHARS(str, 0, str->CurLenW); - if (text_len <= 0) - return; - if (ImStb::STB_TEXTEDIT_INSERTCHARS(str, 0, text, text_len)) - { - state->cursor = text_len; - state->has_preferred_x = 0; - return; - } - IM_ASSERT(0); // Failed to insert character, normally shouldn't happen because of how we currently use stb_textedit_replace() -} - -} // namespace ImStb - -void ImGuiInputTextState::OnKeyPressed(int key) -{ - stb_textedit_key(this, &Stb, key); - CursorFollow = true; - CursorAnimReset(); -} - -ImGuiInputTextCallbackData::ImGuiInputTextCallbackData() -{ - memset(this, 0, sizeof(*this)); -} - -// Public API to manipulate UTF-8 text -// We expose UTF-8 to the user (unlike the STB_TEXTEDIT_* functions which are manipulating wchar) -// FIXME: The existence of this rarely exercised code path is a bit of a nuisance. -void ImGuiInputTextCallbackData::DeleteChars(int pos, int bytes_count) -{ - IM_ASSERT(pos + bytes_count <= BufTextLen); - char* dst = Buf + pos; - const char* src = Buf + pos + bytes_count; - while (char c = *src++) - *dst++ = c; - *dst = '\0'; - - if (CursorPos >= pos + bytes_count) - CursorPos -= bytes_count; - else if (CursorPos >= pos) - CursorPos = pos; - SelectionStart = SelectionEnd = CursorPos; - BufDirty = true; - BufTextLen -= bytes_count; -} - -void ImGuiInputTextCallbackData::InsertChars(int pos, const char* new_text, const char* new_text_end) -{ - const bool is_resizable = (Flags & ImGuiInputTextFlags_CallbackResize) != 0; - const int new_text_len = new_text_end ? (int)(new_text_end - new_text) : (int)strlen(new_text); - if (new_text_len + BufTextLen >= BufSize) - { - if (!is_resizable) - return; - - // Contrary to STB_TEXTEDIT_INSERTCHARS() this is working in the UTF8 buffer, hence the mildly similar code (until we remove the U16 buffer altogether!) - ImGuiContext& g = *GImGui; - ImGuiInputTextState* edit_state = &g.InputTextState; - IM_ASSERT(edit_state->ID != 0 && g.ActiveId == edit_state->ID); - IM_ASSERT(Buf == edit_state->TextA.Data); - int new_buf_size = BufTextLen + ImClamp(new_text_len * 4, 32, ImMax(256, new_text_len)) + 1; - edit_state->TextA.reserve(new_buf_size + 1); - Buf = edit_state->TextA.Data; - BufSize = edit_state->BufCapacityA = new_buf_size; - } - - if (BufTextLen != pos) - memmove(Buf + pos + new_text_len, Buf + pos, (size_t)(BufTextLen - pos)); - memcpy(Buf + pos, new_text, (size_t)new_text_len * sizeof(char)); - Buf[BufTextLen + new_text_len] = '\0'; - - if (CursorPos >= pos) - CursorPos += new_text_len; - SelectionStart = SelectionEnd = CursorPos; - BufDirty = true; - BufTextLen += new_text_len; -} - -// Return false to discard a character. -static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data, ImGuiInputSource input_source) -{ - IM_ASSERT(input_source == ImGuiInputSource_Keyboard || input_source == ImGuiInputSource_Clipboard); - unsigned int c = *p_char; - - // Filter non-printable (NB: isprint is unreliable! see #2467) - bool apply_named_filters = true; - if (c < 0x20) - { - bool pass = false; - pass |= (c == '\n' && (flags & ImGuiInputTextFlags_Multiline)); - pass |= (c == '\t' && (flags & ImGuiInputTextFlags_AllowTabInput)); - if (!pass) - return false; - apply_named_filters = false; // Override named filters below so newline and tabs can still be inserted. - } - - if (input_source != ImGuiInputSource_Clipboard) - { - // We ignore Ascii representation of delete (emitted from Backspace on OSX, see #2578, #2817) - if (c == 127) - return false; - - // Filter private Unicode range. GLFW on OSX seems to send private characters for special keys like arrow keys (FIXME) - if (c >= 0xE000 && c <= 0xF8FF) - return false; - } - - // Filter Unicode ranges we are not handling in this build - if (c > IM_UNICODE_CODEPOINT_MAX) - return false; - - // Generic named filters - if (apply_named_filters && (flags & (ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase | ImGuiInputTextFlags_CharsNoBlank | ImGuiInputTextFlags_CharsScientific))) - { - // The libc allows overriding locale, with e.g. 'setlocale(LC_NUMERIC, "de_DE.UTF-8");' which affect the output/input of printf/scanf. - // The standard mandate that programs starts in the "C" locale where the decimal point is '.'. - // We don't really intend to provide widespread support for it, but out of empathy for people stuck with using odd API, we support the bare minimum aka overriding the decimal point. - // Change the default decimal_point with: - // ImGui::GetCurrentContext()->PlatformLocaleDecimalPoint = *localeconv()->decimal_point; - ImGuiContext& g = *GImGui; - const unsigned c_decimal_point = (unsigned int)g.PlatformLocaleDecimalPoint; - - // Allow 0-9 . - + * / - if (flags & ImGuiInputTextFlags_CharsDecimal) - if (!(c >= '0' && c <= '9') && (c != c_decimal_point) && (c != '-') && (c != '+') && (c != '*') && (c != '/')) - return false; - - // Allow 0-9 . - + * / e E - if (flags & ImGuiInputTextFlags_CharsScientific) - if (!(c >= '0' && c <= '9') && (c != c_decimal_point) && (c != '-') && (c != '+') && (c != '*') && (c != '/') && (c != 'e') && (c != 'E')) - return false; - - // Allow 0-9 a-F A-F - if (flags & ImGuiInputTextFlags_CharsHexadecimal) - if (!(c >= '0' && c <= '9') && !(c >= 'a' && c <= 'f') && !(c >= 'A' && c <= 'F')) - return false; - - // Turn a-z into A-Z - if (flags & ImGuiInputTextFlags_CharsUppercase) - if (c >= 'a' && c <= 'z') - *p_char = (c += (unsigned int)('A' - 'a')); - - if (flags & ImGuiInputTextFlags_CharsNoBlank) - if (ImCharIsBlankW(c)) - return false; - } - - // Custom callback filter - if (flags & ImGuiInputTextFlags_CallbackCharFilter) - { - ImGuiInputTextCallbackData callback_data; - memset(&callback_data, 0, sizeof(ImGuiInputTextCallbackData)); - callback_data.EventFlag = ImGuiInputTextFlags_CallbackCharFilter; - callback_data.EventChar = (ImWchar)c; - callback_data.Flags = flags; - callback_data.UserData = user_data; - if (callback(&callback_data) != 0) - return false; - *p_char = callback_data.EventChar; - if (!callback_data.EventChar) - return false; - } - - return true; -} - -// Edit a string of text -// - buf_size account for the zero-terminator, so a buf_size of 6 can hold "Hello" but not "Hello!". -// This is so we can easily call InputText() on static arrays using ARRAYSIZE() and to match -// Note that in std::string world, capacity() would omit 1 byte used by the zero-terminator. -// - When active, hold on a privately held copy of the text (and apply back to 'buf'). So changing 'buf' while the InputText is active has no effect. -// - If you want to use ImGui::InputText() with std::string, see misc/cpp/imgui_stdlib.h -// (FIXME: Rather confusing and messy function, among the worse part of our codebase, expecting to rewrite a V2 at some point.. Partly because we are -// doing UTF8 > U16 > UTF8 conversions on the go to easily interface with stb_textedit. Ideally should stay in UTF-8 all the time. See https://github.com/nothings/stb/issues/188) -bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_size, const ImVec2& size_arg, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* callback_user_data) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - - IM_ASSERT(buf != NULL && buf_size >= 0); - IM_ASSERT(!((flags & ImGuiInputTextFlags_CallbackHistory) && (flags & ImGuiInputTextFlags_Multiline))); // Can't use both together (they both use up/down keys) - IM_ASSERT(!((flags & ImGuiInputTextFlags_CallbackCompletion) && (flags & ImGuiInputTextFlags_AllowTabInput))); // Can't use both together (they both use tab key) - - ImGuiContext& g = *GImGui; - ImGuiIO& io = g.IO; - const ImGuiStyle& style = g.Style; - - const bool RENDER_SELECTION_WHEN_INACTIVE = false; - const bool is_multiline = (flags & ImGuiInputTextFlags_Multiline) != 0; - const bool is_readonly = (flags & ImGuiInputTextFlags_ReadOnly) != 0; - const bool is_password = (flags & ImGuiInputTextFlags_Password) != 0; - const bool is_undoable = (flags & ImGuiInputTextFlags_NoUndoRedo) == 0; - const bool is_resizable = (flags & ImGuiInputTextFlags_CallbackResize) != 0; - if (is_resizable) - IM_ASSERT(callback != NULL); // Must provide a callback if you set the ImGuiInputTextFlags_CallbackResize flag! - - if (is_multiline) // Open group before calling GetID() because groups tracks id created within their scope, - BeginGroup(); - const ImGuiID id = window->GetID(label); - const ImVec2 label_size = CalcTextSize(label, NULL, true); - const ImVec2 frame_size = CalcItemSize(size_arg, CalcItemWidth(), (is_multiline ? g.FontSize * 8.0f : label_size.y) + style.FramePadding.y * 2.0f); // Arbitrary default of 8 lines high for multi-line - const ImVec2 total_size = ImVec2(frame_size.x + (label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f), frame_size.y); - - const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + frame_size); - const ImRect total_bb(frame_bb.Min, frame_bb.Min + total_size); - - ImGuiWindow* draw_window = window; - ImVec2 inner_size = frame_size; - ImGuiItemStatusFlags item_status_flags = 0; - if (is_multiline) - { - ImVec2 backup_pos = window->DC.CursorPos; - ItemSize(total_bb, style.FramePadding.y); - if (!ItemAdd(total_bb, id, &frame_bb, ImGuiItemFlags_Inputable)) - { - EndGroup(); - return false; - } - item_status_flags = g.LastItemData.StatusFlags; - window->DC.CursorPos = backup_pos; - - // We reproduce the contents of BeginChildFrame() in order to provide 'label' so our window internal data are easier to read/debug. - // FIXME-NAV: Pressing NavActivate will trigger general child activation right before triggering our own below. Harmless but bizarre. - PushStyleColor(ImGuiCol_ChildBg, style.Colors[ImGuiCol_FrameBg]); - PushStyleVar(ImGuiStyleVar_ChildRounding, style.FrameRounding); - PushStyleVar(ImGuiStyleVar_ChildBorderSize, style.FrameBorderSize); - bool child_visible = BeginChildEx(label, id, frame_bb.GetSize(), true, ImGuiWindowFlags_NoMove); - PopStyleVar(2); - PopStyleColor(); - if (!child_visible) - { - EndChild(); - EndGroup(); - return false; - } - draw_window = g.CurrentWindow; // Child window - draw_window->DC.NavLayersActiveMaskNext |= (1 << draw_window->DC.NavLayerCurrent); // This is to ensure that EndChild() will display a navigation highlight so we can "enter" into it. - draw_window->DC.CursorPos += style.FramePadding; - inner_size.x -= draw_window->ScrollbarSizes.x; - } - else - { - // Support for internal ImGuiInputTextFlags_MergedItem flag, which could be redesigned as an ItemFlags if needed (with test performed in ItemAdd) - ItemSize(total_bb, style.FramePadding.y); - if (!(flags & ImGuiInputTextFlags_MergedItem)) - if (!ItemAdd(total_bb, id, &frame_bb, ImGuiItemFlags_Inputable)) - return false; - item_status_flags = g.LastItemData.StatusFlags; - } - const bool hovered = ItemHoverable(frame_bb, id); - if (hovered) - g.MouseCursor = ImGuiMouseCursor_TextInput; - - // We are only allowed to access the state if we are already the active widget. - ImGuiInputTextState* state = GetInputTextState(id); - - const bool input_requested_by_tabbing = (item_status_flags & ImGuiItemStatusFlags_FocusedByTabbing) != 0; - const bool input_requested_by_nav = (g.ActiveId != id) && ((g.NavActivateInputId == id) || (g.NavActivateId == id && g.NavInputSource == ImGuiInputSource_Keyboard)); - - const bool user_clicked = hovered && io.MouseClicked[0]; - const bool user_scroll_finish = is_multiline && state != NULL && g.ActiveId == 0 && g.ActiveIdPreviousFrame == GetWindowScrollbarID(draw_window, ImGuiAxis_Y); - const bool user_scroll_active = is_multiline && state != NULL && g.ActiveId == GetWindowScrollbarID(draw_window, ImGuiAxis_Y); - bool clear_active_id = false; - bool select_all = false; - - float scroll_y = is_multiline ? draw_window->Scroll.y : FLT_MAX; - - const bool init_changed_specs = (state != NULL && state->Stb.single_line != !is_multiline); - const bool init_make_active = (user_clicked || user_scroll_finish || input_requested_by_nav || input_requested_by_tabbing); - const bool init_state = (init_make_active || user_scroll_active); - if ((init_state && g.ActiveId != id) || init_changed_specs) - { - // Access state even if we don't own it yet. - state = &g.InputTextState; - state->CursorAnimReset(); - - // Take a copy of the initial buffer value (both in original UTF-8 format and converted to wchar) - // From the moment we focused we are ignoring the content of 'buf' (unless we are in read-only mode) - const int buf_len = (int)strlen(buf); - state->InitialTextA.resize(buf_len + 1); // UTF-8. we use +1 to make sure that .Data is always pointing to at least an empty string. - memcpy(state->InitialTextA.Data, buf, buf_len + 1); - - // Start edition - const char* buf_end = NULL; - state->TextW.resize(buf_size + 1); // wchar count <= UTF-8 count. we use +1 to make sure that .Data is always pointing to at least an empty string. - state->TextA.resize(0); - state->TextAIsValid = false; // TextA is not valid yet (we will display buf until then) - state->CurLenW = ImTextStrFromUtf8(state->TextW.Data, buf_size, buf, NULL, &buf_end); - state->CurLenA = (int)(buf_end - buf); // We can't get the result from ImStrncpy() above because it is not UTF-8 aware. Here we'll cut off malformed UTF-8. - - // Preserve cursor position and undo/redo stack if we come back to same widget - // FIXME: For non-readonly widgets we might be able to require that TextAIsValid && TextA == buf ? (untested) and discard undo stack if user buffer has changed. - const bool recycle_state = (state->ID == id && !init_changed_specs); - if (recycle_state) - { - // Recycle existing cursor/selection/undo stack but clamp position - // Note a single mouse click will override the cursor/position immediately by calling stb_textedit_click handler. - state->CursorClamp(); - } - else - { - state->ID = id; - state->ScrollX = 0.0f; - stb_textedit_initialize_state(&state->Stb, !is_multiline); - } - - if (!is_multiline) - { - if (flags & ImGuiInputTextFlags_AutoSelectAll) - select_all = true; - if (input_requested_by_nav && (!recycle_state || !(g.NavActivateFlags & ImGuiActivateFlags_TryToPreserveState))) - select_all = true; - if (input_requested_by_tabbing || (user_clicked && io.KeyCtrl)) - select_all = true; - } - - if (flags & ImGuiInputTextFlags_AlwaysOverwrite) - state->Stb.insert_mode = 1; // stb field name is indeed incorrect (see #2863) - } - - if (g.ActiveId != id && init_make_active) - { - IM_ASSERT(state && state->ID == id); - SetActiveID(id, window); - SetFocusID(id, window); - FocusWindow(window); - - // Declare our inputs - IM_ASSERT(ImGuiNavInput_COUNT < 32); - g.ActiveIdUsingNavDirMask |= (1 << ImGuiDir_Left) | (1 << ImGuiDir_Right); - if (is_multiline || (flags & ImGuiInputTextFlags_CallbackHistory)) - g.ActiveIdUsingNavDirMask |= (1 << ImGuiDir_Up) | (1 << ImGuiDir_Down); - g.ActiveIdUsingNavInputMask |= (1 << ImGuiNavInput_Cancel); - g.ActiveIdUsingKeyInputMask |= ((ImU64)1 << ImGuiKey_Home) | ((ImU64)1 << ImGuiKey_End); - if (is_multiline) - g.ActiveIdUsingKeyInputMask |= ((ImU64)1 << ImGuiKey_PageUp) | ((ImU64)1 << ImGuiKey_PageDown); - if (flags & (ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_AllowTabInput)) // Disable keyboard tabbing out as we will use the \t character. - g.ActiveIdUsingKeyInputMask |= ((ImU64)1 << ImGuiKey_Tab); - } - - // We have an edge case if ActiveId was set through another widget (e.g. widget being swapped), clear id immediately (don't wait until the end of the function) - if (g.ActiveId == id && state == NULL) - ClearActiveID(); - - // Release focus when we click outside - if (g.ActiveId == id && io.MouseClicked[0] && !init_state && !init_make_active) //-V560 - clear_active_id = true; - - // Lock the decision of whether we are going to take the path displaying the cursor or selection - const bool render_cursor = (g.ActiveId == id) || (state && user_scroll_active); - bool render_selection = state && (state->HasSelection() || select_all) && (RENDER_SELECTION_WHEN_INACTIVE || render_cursor); - bool value_changed = false; - bool enter_pressed = false; - - // When read-only we always use the live data passed to the function - // FIXME-OPT: Because our selection/cursor code currently needs the wide text we need to convert it when active, which is not ideal :( - if (is_readonly && state != NULL && (render_cursor || render_selection)) - { - const char* buf_end = NULL; - state->TextW.resize(buf_size + 1); - state->CurLenW = ImTextStrFromUtf8(state->TextW.Data, state->TextW.Size, buf, NULL, &buf_end); - state->CurLenA = (int)(buf_end - buf); - state->CursorClamp(); - render_selection &= state->HasSelection(); - } - - // Select the buffer to render. - const bool buf_display_from_state = (render_cursor || render_selection || g.ActiveId == id) && !is_readonly && state && state->TextAIsValid; - const bool is_displaying_hint = (hint != NULL && (buf_display_from_state ? state->TextA.Data : buf)[0] == 0); - - // Password pushes a temporary font with only a fallback glyph - if (is_password && !is_displaying_hint) - { - const ImFontGlyph* glyph = g.Font->FindGlyph('*'); - ImFont* password_font = &g.InputTextPasswordFont; - password_font->FontSize = g.Font->FontSize; - password_font->Scale = g.Font->Scale; - password_font->Ascent = g.Font->Ascent; - password_font->Descent = g.Font->Descent; - password_font->ContainerAtlas = g.Font->ContainerAtlas; - password_font->FallbackGlyph = glyph; - password_font->FallbackAdvanceX = glyph->AdvanceX; - IM_ASSERT(password_font->Glyphs.empty() && password_font->IndexAdvanceX.empty() && password_font->IndexLookup.empty()); - PushFont(password_font); - } - - // Process mouse inputs and character inputs - int backup_current_text_length = 0; - if (g.ActiveId == id) - { - IM_ASSERT(state != NULL); - backup_current_text_length = state->CurLenA; - state->Edited = false; - state->BufCapacityA = buf_size; - state->Flags = flags; - state->UserCallback = callback; - state->UserCallbackData = callback_user_data; - - // Although we are active we don't prevent mouse from hovering other elements unless we are interacting right now with the widget. - // Down the line we should have a cleaner library-wide concept of Selected vs Active. - g.ActiveIdAllowOverlap = !io.MouseDown[0]; - g.WantTextInputNextFrame = 1; - - // Edit in progress - const float mouse_x = (io.MousePos.x - frame_bb.Min.x - style.FramePadding.x) + state->ScrollX; - const float mouse_y = (is_multiline ? (io.MousePos.y - draw_window->DC.CursorPos.y) : (g.FontSize * 0.5f)); - - const bool is_osx = io.ConfigMacOSXBehaviors; - if (select_all || (hovered && !is_osx && io.MouseDoubleClicked[0])) - { - state->SelectAll(); - state->SelectedAllMouseLock = true; - } - else if (hovered && is_osx && io.MouseDoubleClicked[0]) - { - // Double-click select a word only, OS X style (by simulating keystrokes) - state->OnKeyPressed(STB_TEXTEDIT_K_WORDLEFT); - state->OnKeyPressed(STB_TEXTEDIT_K_WORDRIGHT | STB_TEXTEDIT_K_SHIFT); - } - else if (io.MouseClicked[0] && !state->SelectedAllMouseLock) - { - if (hovered) - { - stb_textedit_click(state, &state->Stb, mouse_x, mouse_y); - state->CursorAnimReset(); - } - } - else if (io.MouseDown[0] && !state->SelectedAllMouseLock && (io.MouseDelta.x != 0.0f || io.MouseDelta.y != 0.0f)) - { - stb_textedit_drag(state, &state->Stb, mouse_x, mouse_y); - state->CursorAnimReset(); - state->CursorFollow = true; - } - if (state->SelectedAllMouseLock && !io.MouseDown[0]) - state->SelectedAllMouseLock = false; - - // It is ill-defined whether the backend needs to send a \t character when pressing the TAB keys. - // Win32 and GLFW naturally do it but not SDL. - const bool ignore_char_inputs = (io.KeyCtrl && !io.KeyAlt) || (is_osx && io.KeySuper); - if ((flags & ImGuiInputTextFlags_AllowTabInput) && IsKeyPressedMap(ImGuiKey_Tab) && !ignore_char_inputs && !io.KeyShift && !is_readonly) - if (!io.InputQueueCharacters.contains('\t')) - { - unsigned int c = '\t'; // Insert TAB - if (InputTextFilterCharacter(&c, flags, callback, callback_user_data, ImGuiInputSource_Keyboard)) - state->OnKeyPressed((int)c); - } - - // Process regular text input (before we check for Return because using some IME will effectively send a Return?) - // We ignore CTRL inputs, but need to allow ALT+CTRL as some keyboards (e.g. German) use AltGR (which _is_ Alt+Ctrl) to input certain characters. - if (io.InputQueueCharacters.Size > 0) - { - if (!ignore_char_inputs && !is_readonly && !input_requested_by_nav) - for (int n = 0; n < io.InputQueueCharacters.Size; n++) - { - // Insert character if they pass filtering - unsigned int c = (unsigned int)io.InputQueueCharacters[n]; - if (c == '\t' && io.KeyShift) - continue; - if (InputTextFilterCharacter(&c, flags, callback, callback_user_data, ImGuiInputSource_Keyboard)) - state->OnKeyPressed((int)c); - } - - // Consume characters - io.InputQueueCharacters.resize(0); - } - } - - // Process other shortcuts/key-presses - bool cancel_edit = false; - if (g.ActiveId == id && !g.ActiveIdIsJustActivated && !clear_active_id) - { - IM_ASSERT(state != NULL); - IM_ASSERT(io.KeyMods == GetMergedKeyModFlags() && "Mismatching io.KeyCtrl/io.KeyShift/io.KeyAlt/io.KeySuper vs io.KeyMods"); // We rarely do this check, but if anything let's do it here. - - const int row_count_per_page = ImMax((int)((inner_size.y - style.FramePadding.y) / g.FontSize), 1); - state->Stb.row_count_per_page = row_count_per_page; - - const int k_mask = (io.KeyShift ? STB_TEXTEDIT_K_SHIFT : 0); - const bool is_osx = io.ConfigMacOSXBehaviors; - const bool is_osx_shift_shortcut = is_osx && (io.KeyMods == (ImGuiKeyModFlags_Super | ImGuiKeyModFlags_Shift)); - const bool is_wordmove_key_down = is_osx ? io.KeyAlt : io.KeyCtrl; // OS X style: Text editing cursor movement using Alt instead of Ctrl - const bool is_startend_key_down = is_osx && io.KeySuper && !io.KeyCtrl && !io.KeyAlt; // OS X style: Line/Text Start and End using Cmd+Arrows instead of Home/End - const bool is_ctrl_key_only = (io.KeyMods == ImGuiKeyModFlags_Ctrl); - const bool is_shift_key_only = (io.KeyMods == ImGuiKeyModFlags_Shift); - const bool is_shortcut_key = g.IO.ConfigMacOSXBehaviors ? (io.KeyMods == ImGuiKeyModFlags_Super) : (io.KeyMods == ImGuiKeyModFlags_Ctrl); - - const bool is_cut = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_X)) || (is_shift_key_only && IsKeyPressedMap(ImGuiKey_Delete))) && !is_readonly && !is_password && (!is_multiline || state->HasSelection()); - const bool is_copy = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_C)) || (is_ctrl_key_only && IsKeyPressedMap(ImGuiKey_Insert))) && !is_password && (!is_multiline || state->HasSelection()); - const bool is_paste = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_V)) || (is_shift_key_only && IsKeyPressedMap(ImGuiKey_Insert))) && !is_readonly; - const bool is_undo = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_Z)) && !is_readonly && is_undoable); - const bool is_redo = ((is_shortcut_key && IsKeyPressedMap(ImGuiKey_Y)) || (is_osx_shift_shortcut && IsKeyPressedMap(ImGuiKey_Z))) && !is_readonly && is_undoable; - - // We allow validate/cancel with Nav source (gamepad) to makes it easier to undo an accidental NavInput press with no keyboard wired, but otherwise it isn't very useful. - const bool is_validate_enter = IsKeyPressedMap(ImGuiKey_Enter) || IsKeyPressedMap(ImGuiKey_KeyPadEnter); - const bool is_validate_nav = (IsNavInputTest(ImGuiNavInput_Activate, ImGuiInputReadMode_Pressed) && !IsKeyPressedMap(ImGuiKey_Space)) || IsNavInputTest(ImGuiNavInput_Input, ImGuiInputReadMode_Pressed); - const bool is_cancel = IsKeyPressedMap(ImGuiKey_Escape) || IsNavInputTest(ImGuiNavInput_Cancel, ImGuiInputReadMode_Pressed); - - if (IsKeyPressedMap(ImGuiKey_LeftArrow)) { state->OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_LINESTART : is_wordmove_key_down ? STB_TEXTEDIT_K_WORDLEFT : STB_TEXTEDIT_K_LEFT) | k_mask); } - else if (IsKeyPressedMap(ImGuiKey_RightArrow)) { state->OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_LINEEND : is_wordmove_key_down ? STB_TEXTEDIT_K_WORDRIGHT : STB_TEXTEDIT_K_RIGHT) | k_mask); } - else if (IsKeyPressedMap(ImGuiKey_UpArrow) && is_multiline) { if (io.KeyCtrl) SetScrollY(draw_window, ImMax(draw_window->Scroll.y - g.FontSize, 0.0f)); else state->OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_TEXTSTART : STB_TEXTEDIT_K_UP) | k_mask); } - else if (IsKeyPressedMap(ImGuiKey_DownArrow) && is_multiline) { if (io.KeyCtrl) SetScrollY(draw_window, ImMin(draw_window->Scroll.y + g.FontSize, GetScrollMaxY())); else state->OnKeyPressed((is_startend_key_down ? STB_TEXTEDIT_K_TEXTEND : STB_TEXTEDIT_K_DOWN) | k_mask); } - else if (IsKeyPressedMap(ImGuiKey_PageUp) && is_multiline) { state->OnKeyPressed(STB_TEXTEDIT_K_PGUP | k_mask); scroll_y -= row_count_per_page * g.FontSize; } - else if (IsKeyPressedMap(ImGuiKey_PageDown) && is_multiline) { state->OnKeyPressed(STB_TEXTEDIT_K_PGDOWN | k_mask); scroll_y += row_count_per_page * g.FontSize; } - else if (IsKeyPressedMap(ImGuiKey_Home)) { state->OnKeyPressed(io.KeyCtrl ? STB_TEXTEDIT_K_TEXTSTART | k_mask : STB_TEXTEDIT_K_LINESTART | k_mask); } - else if (IsKeyPressedMap(ImGuiKey_End)) { state->OnKeyPressed(io.KeyCtrl ? STB_TEXTEDIT_K_TEXTEND | k_mask : STB_TEXTEDIT_K_LINEEND | k_mask); } - else if (IsKeyPressedMap(ImGuiKey_Delete) && !is_readonly) { state->OnKeyPressed(STB_TEXTEDIT_K_DELETE | k_mask); } - else if (IsKeyPressedMap(ImGuiKey_Backspace) && !is_readonly) - { - if (!state->HasSelection()) - { - if (is_wordmove_key_down) - state->OnKeyPressed(STB_TEXTEDIT_K_WORDLEFT | STB_TEXTEDIT_K_SHIFT); - else if (is_osx && io.KeySuper && !io.KeyAlt && !io.KeyCtrl) - state->OnKeyPressed(STB_TEXTEDIT_K_LINESTART | STB_TEXTEDIT_K_SHIFT); - } - state->OnKeyPressed(STB_TEXTEDIT_K_BACKSPACE | k_mask); - } - else if (is_validate_enter) - { - bool ctrl_enter_for_new_line = (flags & ImGuiInputTextFlags_CtrlEnterForNewLine) != 0; - if (!is_multiline || (ctrl_enter_for_new_line && !io.KeyCtrl) || (!ctrl_enter_for_new_line && io.KeyCtrl)) - { - enter_pressed = clear_active_id = true; - } - else if (!is_readonly) - { - unsigned int c = '\n'; // Insert new line - if (InputTextFilterCharacter(&c, flags, callback, callback_user_data, ImGuiInputSource_Keyboard)) - state->OnKeyPressed((int)c); - } - } - else if (is_validate_nav) - { - IM_ASSERT(!is_validate_enter); - enter_pressed = clear_active_id = true; - } - else if (is_cancel) - { - clear_active_id = cancel_edit = true; - } - else if (is_undo || is_redo) - { - state->OnKeyPressed(is_undo ? STB_TEXTEDIT_K_UNDO : STB_TEXTEDIT_K_REDO); - state->ClearSelection(); - } - else if (is_shortcut_key && IsKeyPressedMap(ImGuiKey_A)) - { - state->SelectAll(); - state->CursorFollow = true; - } - else if (is_cut || is_copy) - { - // Cut, Copy - if (io.SetClipboardTextFn) - { - const int ib = state->HasSelection() ? ImMin(state->Stb.select_start, state->Stb.select_end) : 0; - const int ie = state->HasSelection() ? ImMax(state->Stb.select_start, state->Stb.select_end) : state->CurLenW; - const int clipboard_data_len = ImTextCountUtf8BytesFromStr(state->TextW.Data + ib, state->TextW.Data + ie) + 1; - char* clipboard_data = (char*)IM_ALLOC(clipboard_data_len * sizeof(char)); - ImTextStrToUtf8(clipboard_data, clipboard_data_len, state->TextW.Data + ib, state->TextW.Data + ie); - SetClipboardText(clipboard_data); - MemFree(clipboard_data); - } - if (is_cut) - { - if (!state->HasSelection()) - state->SelectAll(); - state->CursorFollow = true; - stb_textedit_cut(state, &state->Stb); - } - } - else if (is_paste) - { - if (const char* clipboard = GetClipboardText()) - { - // Filter pasted buffer - const int clipboard_len = (int)strlen(clipboard); - ImWchar* clipboard_filtered = (ImWchar*)IM_ALLOC((clipboard_len + 1) * sizeof(ImWchar)); - int clipboard_filtered_len = 0; - for (const char* s = clipboard; *s; ) - { - unsigned int c; - s += ImTextCharFromUtf8(&c, s, NULL); - if (c == 0) - break; - if (!InputTextFilterCharacter(&c, flags, callback, callback_user_data, ImGuiInputSource_Clipboard)) - continue; - clipboard_filtered[clipboard_filtered_len++] = (ImWchar)c; - } - clipboard_filtered[clipboard_filtered_len] = 0; - if (clipboard_filtered_len > 0) // If everything was filtered, ignore the pasting operation - { - stb_textedit_paste(state, &state->Stb, clipboard_filtered, clipboard_filtered_len); - state->CursorFollow = true; - } - MemFree(clipboard_filtered); - } - } - - // Update render selection flag after events have been handled, so selection highlight can be displayed during the same frame. - render_selection |= state->HasSelection() && (RENDER_SELECTION_WHEN_INACTIVE || render_cursor); - } - - // Process callbacks and apply result back to user's buffer. - if (g.ActiveId == id) - { - IM_ASSERT(state != NULL); - const char* apply_new_text = NULL; - int apply_new_text_length = 0; - if (cancel_edit) - { - // Restore initial value. Only return true if restoring to the initial value changes the current buffer contents. - if (!is_readonly && strcmp(buf, state->InitialTextA.Data) != 0) - { - // Push records into the undo stack so we can CTRL+Z the revert operation itself - apply_new_text = state->InitialTextA.Data; - apply_new_text_length = state->InitialTextA.Size - 1; - ImVector w_text; - if (apply_new_text_length > 0) - { - w_text.resize(ImTextCountCharsFromUtf8(apply_new_text, apply_new_text + apply_new_text_length) + 1); - ImTextStrFromUtf8(w_text.Data, w_text.Size, apply_new_text, apply_new_text + apply_new_text_length); - } - stb_textedit_replace(state, &state->Stb, w_text.Data, (apply_new_text_length > 0) ? (w_text.Size - 1) : 0); - } - } - - // When using 'ImGuiInputTextFlags_EnterReturnsTrue' as a special case we reapply the live buffer back to the input buffer before clearing ActiveId, even though strictly speaking it wasn't modified on this frame. - // If we didn't do that, code like InputInt() with ImGuiInputTextFlags_EnterReturnsTrue would fail. - // This also allows the user to use InputText() with ImGuiInputTextFlags_EnterReturnsTrue without maintaining any user-side storage (please note that if you use this property along ImGuiInputTextFlags_CallbackResize you can end up with your temporary string object unnecessarily allocating once a frame, either store your string data, either if you don't then don't use ImGuiInputTextFlags_CallbackResize). - bool apply_edit_back_to_user_buffer = !cancel_edit || (enter_pressed && (flags & ImGuiInputTextFlags_EnterReturnsTrue) != 0); - if (apply_edit_back_to_user_buffer) - { - // Apply new value immediately - copy modified buffer back - // Note that as soon as the input box is active, the in-widget value gets priority over any underlying modification of the input buffer - // FIXME: We actually always render 'buf' when calling DrawList->AddText, making the comment above incorrect. - // FIXME-OPT: CPU waste to do this every time the widget is active, should mark dirty state from the stb_textedit callbacks. - if (!is_readonly) - { - state->TextAIsValid = true; - state->TextA.resize(state->TextW.Size * 4 + 1); - ImTextStrToUtf8(state->TextA.Data, state->TextA.Size, state->TextW.Data, NULL); - } - - // User callback - if ((flags & (ImGuiInputTextFlags_CallbackCompletion | ImGuiInputTextFlags_CallbackHistory | ImGuiInputTextFlags_CallbackEdit | ImGuiInputTextFlags_CallbackAlways)) != 0) - { - IM_ASSERT(callback != NULL); - - // The reason we specify the usage semantic (Completion/History) is that Completion needs to disable keyboard TABBING at the moment. - ImGuiInputTextFlags event_flag = 0; - ImGuiKey event_key = ImGuiKey_COUNT; - if ((flags & ImGuiInputTextFlags_CallbackCompletion) != 0 && IsKeyPressedMap(ImGuiKey_Tab)) - { - event_flag = ImGuiInputTextFlags_CallbackCompletion; - event_key = ImGuiKey_Tab; - } - else if ((flags & ImGuiInputTextFlags_CallbackHistory) != 0 && IsKeyPressedMap(ImGuiKey_UpArrow)) - { - event_flag = ImGuiInputTextFlags_CallbackHistory; - event_key = ImGuiKey_UpArrow; - } - else if ((flags & ImGuiInputTextFlags_CallbackHistory) != 0 && IsKeyPressedMap(ImGuiKey_DownArrow)) - { - event_flag = ImGuiInputTextFlags_CallbackHistory; - event_key = ImGuiKey_DownArrow; - } - else if ((flags & ImGuiInputTextFlags_CallbackEdit) && state->Edited) - { - event_flag = ImGuiInputTextFlags_CallbackEdit; - } - else if (flags & ImGuiInputTextFlags_CallbackAlways) - { - event_flag = ImGuiInputTextFlags_CallbackAlways; - } - - if (event_flag) - { - ImGuiInputTextCallbackData callback_data; - memset(&callback_data, 0, sizeof(ImGuiInputTextCallbackData)); - callback_data.EventFlag = event_flag; - callback_data.Flags = flags; - callback_data.UserData = callback_user_data; - - callback_data.EventKey = event_key; - callback_data.Buf = state->TextA.Data; - callback_data.BufTextLen = state->CurLenA; - callback_data.BufSize = state->BufCapacityA; - callback_data.BufDirty = false; - - // We have to convert from wchar-positions to UTF-8-positions, which can be pretty slow (an incentive to ditch the ImWchar buffer, see https://github.com/nothings/stb/issues/188) - ImWchar* text = state->TextW.Data; - const int utf8_cursor_pos = callback_data.CursorPos = ImTextCountUtf8BytesFromStr(text, text + state->Stb.cursor); - const int utf8_selection_start = callback_data.SelectionStart = ImTextCountUtf8BytesFromStr(text, text + state->Stb.select_start); - const int utf8_selection_end = callback_data.SelectionEnd = ImTextCountUtf8BytesFromStr(text, text + state->Stb.select_end); - - // Call user code - callback(&callback_data); - - // Read back what user may have modified - IM_ASSERT(callback_data.Buf == state->TextA.Data); // Invalid to modify those fields - IM_ASSERT(callback_data.BufSize == state->BufCapacityA); - IM_ASSERT(callback_data.Flags == flags); - const bool buf_dirty = callback_data.BufDirty; - if (callback_data.CursorPos != utf8_cursor_pos || buf_dirty) { state->Stb.cursor = ImTextCountCharsFromUtf8(callback_data.Buf, callback_data.Buf + callback_data.CursorPos); state->CursorFollow = true; } - if (callback_data.SelectionStart != utf8_selection_start || buf_dirty) { state->Stb.select_start = (callback_data.SelectionStart == callback_data.CursorPos) ? state->Stb.cursor : ImTextCountCharsFromUtf8(callback_data.Buf, callback_data.Buf + callback_data.SelectionStart); } - if (callback_data.SelectionEnd != utf8_selection_end || buf_dirty) { state->Stb.select_end = (callback_data.SelectionEnd == callback_data.SelectionStart) ? state->Stb.select_start : ImTextCountCharsFromUtf8(callback_data.Buf, callback_data.Buf + callback_data.SelectionEnd); } - if (buf_dirty) - { - IM_ASSERT(callback_data.BufTextLen == (int)strlen(callback_data.Buf)); // You need to maintain BufTextLen if you change the text! - if (callback_data.BufTextLen > backup_current_text_length && is_resizable) - state->TextW.resize(state->TextW.Size + (callback_data.BufTextLen - backup_current_text_length)); - state->CurLenW = ImTextStrFromUtf8(state->TextW.Data, state->TextW.Size, callback_data.Buf, NULL); - state->CurLenA = callback_data.BufTextLen; // Assume correct length and valid UTF-8 from user, saves us an extra strlen() - state->CursorAnimReset(); - } - } - } - - // Will copy result string if modified - if (!is_readonly && strcmp(state->TextA.Data, buf) != 0) - { - apply_new_text = state->TextA.Data; - apply_new_text_length = state->CurLenA; - } - } - - // Copy result to user buffer - if (apply_new_text) - { - // We cannot test for 'backup_current_text_length != apply_new_text_length' here because we have no guarantee that the size - // of our owned buffer matches the size of the string object held by the user, and by design we allow InputText() to be used - // without any storage on user's side. - IM_ASSERT(apply_new_text_length >= 0); - if (is_resizable) - { - ImGuiInputTextCallbackData callback_data; - callback_data.EventFlag = ImGuiInputTextFlags_CallbackResize; - callback_data.Flags = flags; - callback_data.Buf = buf; - callback_data.BufTextLen = apply_new_text_length; - callback_data.BufSize = ImMax(buf_size, apply_new_text_length + 1); - callback_data.UserData = callback_user_data; - callback(&callback_data); - buf = callback_data.Buf; - buf_size = callback_data.BufSize; - apply_new_text_length = ImMin(callback_data.BufTextLen, buf_size - 1); - IM_ASSERT(apply_new_text_length <= buf_size); - } - //IMGUI_DEBUG_LOG("InputText(\"%s\"): apply_new_text length %d\n", label, apply_new_text_length); - - // If the underlying buffer resize was denied or not carried to the next frame, apply_new_text_length+1 may be >= buf_size. - ImStrncpy(buf, apply_new_text, ImMin(apply_new_text_length + 1, buf_size)); - value_changed = true; - } - - // Clear temporary user storage - state->Flags = ImGuiInputTextFlags_None; - state->UserCallback = NULL; - state->UserCallbackData = NULL; - } - - // Release active ID at the end of the function (so e.g. pressing Return still does a final application of the value) - if (clear_active_id && g.ActiveId == id) - ClearActiveID(); - - // Render frame - if (!is_multiline) - { - RenderNavHighlight(frame_bb, id); - RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding); - } - - const ImVec4 clip_rect(frame_bb.Min.x, frame_bb.Min.y, frame_bb.Min.x + inner_size.x, frame_bb.Min.y + inner_size.y); // Not using frame_bb.Max because we have adjusted size - ImVec2 draw_pos = is_multiline ? draw_window->DC.CursorPos : frame_bb.Min + style.FramePadding; - ImVec2 text_size(0.0f, 0.0f); - - // Set upper limit of single-line InputTextEx() at 2 million characters strings. The current pathological worst case is a long line - // without any carriage return, which would makes ImFont::RenderText() reserve too many vertices and probably crash. Avoid it altogether. - // Note that we only use this limit on single-line InputText(), so a pathologically large line on a InputTextMultiline() would still crash. - const int buf_display_max_length = 2 * 1024 * 1024; - const char* buf_display = buf_display_from_state ? state->TextA.Data : buf; //-V595 - const char* buf_display_end = NULL; // We have specialized paths below for setting the length - if (is_displaying_hint) - { - buf_display = hint; - buf_display_end = hint + strlen(hint); - } - - // Render text. We currently only render selection when the widget is active or while scrolling. - // FIXME: We could remove the '&& render_cursor' to keep rendering selection when inactive. - if (render_cursor || render_selection) - { - IM_ASSERT(state != NULL); - if (!is_displaying_hint) - buf_display_end = buf_display + state->CurLenA; - - // Render text (with cursor and selection) - // This is going to be messy. We need to: - // - Display the text (this alone can be more easily clipped) - // - Handle scrolling, highlight selection, display cursor (those all requires some form of 1d->2d cursor position calculation) - // - Measure text height (for scrollbar) - // We are attempting to do most of that in **one main pass** to minimize the computation cost (non-negligible for large amount of text) + 2nd pass for selection rendering (we could merge them by an extra refactoring effort) - // FIXME: This should occur on buf_display but we'd need to maintain cursor/select_start/select_end for UTF-8. - const ImWchar* text_begin = state->TextW.Data; - ImVec2 cursor_offset, select_start_offset; - - { - // Find lines numbers straddling 'cursor' (slot 0) and 'select_start' (slot 1) positions. - const ImWchar* searches_input_ptr[2] = { NULL, NULL }; - int searches_result_line_no[2] = { -1000, -1000 }; - int searches_remaining = 0; - if (render_cursor) - { - searches_input_ptr[0] = text_begin + state->Stb.cursor; - searches_result_line_no[0] = -1; - searches_remaining++; - } - if (render_selection) - { - searches_input_ptr[1] = text_begin + ImMin(state->Stb.select_start, state->Stb.select_end); - searches_result_line_no[1] = -1; - searches_remaining++; - } - - // Iterate all lines to find our line numbers - // In multi-line mode, we never exit the loop until all lines are counted, so add one extra to the searches_remaining counter. - searches_remaining += is_multiline ? 1 : 0; - int line_count = 0; - //for (const ImWchar* s = text_begin; (s = (const ImWchar*)wcschr((const wchar_t*)s, (wchar_t)'\n')) != NULL; s++) // FIXME-OPT: Could use this when wchar_t are 16-bit - for (const ImWchar* s = text_begin; *s != 0; s++) - if (*s == '\n') - { - line_count++; - if (searches_result_line_no[0] == -1 && s >= searches_input_ptr[0]) { searches_result_line_no[0] = line_count; if (--searches_remaining <= 0) break; } - if (searches_result_line_no[1] == -1 && s >= searches_input_ptr[1]) { searches_result_line_no[1] = line_count; if (--searches_remaining <= 0) break; } - } - line_count++; - if (searches_result_line_no[0] == -1) - searches_result_line_no[0] = line_count; - if (searches_result_line_no[1] == -1) - searches_result_line_no[1] = line_count; - - // Calculate 2d position by finding the beginning of the line and measuring distance - cursor_offset.x = InputTextCalcTextSizeW(ImStrbolW(searches_input_ptr[0], text_begin), searches_input_ptr[0]).x; - cursor_offset.y = searches_result_line_no[0] * g.FontSize; - if (searches_result_line_no[1] >= 0) - { - select_start_offset.x = InputTextCalcTextSizeW(ImStrbolW(searches_input_ptr[1], text_begin), searches_input_ptr[1]).x; - select_start_offset.y = searches_result_line_no[1] * g.FontSize; - } - - // Store text height (note that we haven't calculated text width at all, see GitHub issues #383, #1224) - if (is_multiline) - text_size = ImVec2(inner_size.x, line_count * g.FontSize); - } - - // Scroll - if (render_cursor && state->CursorFollow) - { - // Horizontal scroll in chunks of quarter width - if (!(flags & ImGuiInputTextFlags_NoHorizontalScroll)) - { - const float scroll_increment_x = inner_size.x * 0.25f; - const float visible_width = inner_size.x - style.FramePadding.x; - if (cursor_offset.x < state->ScrollX) - state->ScrollX = IM_FLOOR(ImMax(0.0f, cursor_offset.x - scroll_increment_x)); - else if (cursor_offset.x - visible_width >= state->ScrollX) - state->ScrollX = IM_FLOOR(cursor_offset.x - visible_width + scroll_increment_x); - } - else - { - state->ScrollX = 0.0f; - } - - // Vertical scroll - if (is_multiline) - { - // Test if cursor is vertically visible - if (cursor_offset.y - g.FontSize < scroll_y) - scroll_y = ImMax(0.0f, cursor_offset.y - g.FontSize); - else if (cursor_offset.y - inner_size.y >= scroll_y) - scroll_y = cursor_offset.y - inner_size.y + style.FramePadding.y * 2.0f; - const float scroll_max_y = ImMax((text_size.y + style.FramePadding.y * 2.0f) - inner_size.y, 0.0f); - scroll_y = ImClamp(scroll_y, 0.0f, scroll_max_y); - draw_pos.y += (draw_window->Scroll.y - scroll_y); // Manipulate cursor pos immediately avoid a frame of lag - draw_window->Scroll.y = scroll_y; - } - - state->CursorFollow = false; - } - - // Draw selection - const ImVec2 draw_scroll = ImVec2(state->ScrollX, 0.0f); - if (render_selection) - { - const ImWchar* text_selected_begin = text_begin + ImMin(state->Stb.select_start, state->Stb.select_end); - const ImWchar* text_selected_end = text_begin + ImMax(state->Stb.select_start, state->Stb.select_end); - - ImU32 bg_color = GetColorU32(ImGuiCol_TextSelectedBg, render_cursor ? 1.0f : 0.6f); // FIXME: current code flow mandate that render_cursor is always true here, we are leaving the transparent one for tests. - float bg_offy_up = is_multiline ? 0.0f : -1.0f; // FIXME: those offsets should be part of the style? they don't play so well with multi-line selection. - float bg_offy_dn = is_multiline ? 0.0f : 2.0f; - ImVec2 rect_pos = draw_pos + select_start_offset - draw_scroll; - for (const ImWchar* p = text_selected_begin; p < text_selected_end; ) - { - if (rect_pos.y > clip_rect.w + g.FontSize) - break; - if (rect_pos.y < clip_rect.y) - { - //p = (const ImWchar*)wmemchr((const wchar_t*)p, '\n', text_selected_end - p); // FIXME-OPT: Could use this when wchar_t are 16-bit - //p = p ? p + 1 : text_selected_end; - while (p < text_selected_end) - if (*p++ == '\n') - break; - } - else - { - ImVec2 rect_size = InputTextCalcTextSizeW(p, text_selected_end, &p, NULL, true); - if (rect_size.x <= 0.0f) rect_size.x = IM_FLOOR(g.Font->GetCharAdvance((ImWchar)' ') * 0.50f); // So we can see selected empty lines - ImRect rect(rect_pos + ImVec2(0.0f, bg_offy_up - g.FontSize), rect_pos + ImVec2(rect_size.x, bg_offy_dn)); - rect.ClipWith(clip_rect); - if (rect.Overlaps(clip_rect)) - draw_window->DrawList->AddRectFilled(rect.Min, rect.Max, bg_color); - } - rect_pos.x = draw_pos.x - draw_scroll.x; - rect_pos.y += g.FontSize; - } - } - - // We test for 'buf_display_max_length' as a way to avoid some pathological cases (e.g. single-line 1 MB string) which would make ImDrawList crash. - if (is_multiline || (buf_display_end - buf_display) < buf_display_max_length) - { - ImU32 col = GetColorU32(is_displaying_hint ? ImGuiCol_TextDisabled : ImGuiCol_Text); - draw_window->DrawList->AddText(g.Font, g.FontSize, draw_pos - draw_scroll, col, buf_display, buf_display_end, 0.0f, is_multiline ? NULL : &clip_rect); - } - - // Draw blinking cursor - if (render_cursor) - { - state->CursorAnim += io.DeltaTime; - bool cursor_is_visible = (!g.IO.ConfigInputTextCursorBlink) || (state->CursorAnim <= 0.0f) || ImFmod(state->CursorAnim, 1.20f) <= 0.80f; - ImVec2 cursor_screen_pos = ImFloor(draw_pos + cursor_offset - draw_scroll); - ImRect cursor_screen_rect(cursor_screen_pos.x, cursor_screen_pos.y - g.FontSize + 0.5f, cursor_screen_pos.x + 1.0f, cursor_screen_pos.y - 1.5f); - if (cursor_is_visible && cursor_screen_rect.Overlaps(clip_rect)) - draw_window->DrawList->AddLine(cursor_screen_rect.Min, cursor_screen_rect.GetBL(), GetColorU32(ImGuiCol_Text)); - - // Notify OS of text input position for advanced IME (-1 x offset so that Windows IME can cover our cursor. Bit of an extra nicety.) - if (!is_readonly) - g.PlatformImePos = ImVec2(cursor_screen_pos.x - 1.0f, cursor_screen_pos.y - g.FontSize); - } - } - else - { - // Render text only (no selection, no cursor) - if (is_multiline) - text_size = ImVec2(inner_size.x, InputTextCalcTextLenAndLineCount(buf_display, &buf_display_end) * g.FontSize); // We don't need width - else if (!is_displaying_hint && g.ActiveId == id) - buf_display_end = buf_display + state->CurLenA; - else if (!is_displaying_hint) - buf_display_end = buf_display + strlen(buf_display); - - if (is_multiline || (buf_display_end - buf_display) < buf_display_max_length) - { - ImU32 col = GetColorU32(is_displaying_hint ? ImGuiCol_TextDisabled : ImGuiCol_Text); - draw_window->DrawList->AddText(g.Font, g.FontSize, draw_pos, col, buf_display, buf_display_end, 0.0f, is_multiline ? NULL : &clip_rect); - } - } - - if (is_password && !is_displaying_hint) - PopFont(); - - if (is_multiline) - { - Dummy(ImVec2(text_size.x, text_size.y + style.FramePadding.y)); - EndChild(); - EndGroup(); - } - - // Log as text - if (g.LogEnabled && (!is_password || is_displaying_hint)) - { - LogSetNextTextDecoration("{", "}"); - LogRenderedText(&draw_pos, buf_display, buf_display_end); - } - - if (label_size.x > 0) - RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label); - - if (value_changed && !(flags & ImGuiInputTextFlags_NoMarkEdited)) - MarkItemEdited(id); - - IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags); - if ((flags & ImGuiInputTextFlags_EnterReturnsTrue) != 0) - return enter_pressed; - else - return value_changed; -} - -//------------------------------------------------------------------------- -// [SECTION] Widgets: ColorEdit, ColorPicker, ColorButton, etc. -//------------------------------------------------------------------------- -// - ColorEdit3() -// - ColorEdit4() -// - ColorPicker3() -// - RenderColorRectWithAlphaCheckerboard() [Internal] -// - ColorPicker4() -// - ColorButton() -// - SetColorEditOptions() -// - ColorTooltip() [Internal] -// - ColorEditOptionsPopup() [Internal] -// - ColorPickerOptionsPopup() [Internal] -//------------------------------------------------------------------------- - -bool ImGui::ColorEdit3(const char* label, float col[3], ImGuiColorEditFlags flags) -{ - return ColorEdit4(label, col, flags | ImGuiColorEditFlags_NoAlpha); -} - -// ColorEdit supports RGB and HSV inputs. In case of RGB input resulting color may have undefined hue and/or saturation. -// Since widget displays both RGB and HSV values we must preserve hue and saturation to prevent these values resetting. -static void ColorEditRestoreHS(const float* col, float* H, float* S, float* V) -{ - // This check is optional. Suppose we have two color widgets side by side, both widgets display different colors, but both colors have hue and/or saturation undefined. - // With color check: hue/saturation is preserved in one widget. Editing color in one widget would reset hue/saturation in another one. - // Without color check: common hue/saturation would be displayed in all widgets that have hue/saturation undefined. - // g.ColorEditLastColor is stored as ImU32 RGB value: this essentially gives us color equality check with reduced precision. - // Tiny external color changes would not be detected and this check would still pass. This is OK, since we only restore hue/saturation _only_ if they are undefined, - // therefore this change flipping hue/saturation from undefined to a very tiny value would still be represented in color picker. - ImGuiContext& g = *GImGui; - if (g.ColorEditLastColor != ImGui::ColorConvertFloat4ToU32(ImVec4(col[0], col[1], col[2], 0))) - return; - - // When S == 0, H is undefined. - // When H == 1 it wraps around to 0. - if (*S == 0.0f || (*H == 0.0f && g.ColorEditLastHue == 1)) - *H = g.ColorEditLastHue; - - // When V == 0, S is undefined. - if (*V == 0.0f) - *S = g.ColorEditLastSat; -} - -// Edit colors components (each component in 0.0f..1.0f range). -// See enum ImGuiColorEditFlags_ for available options. e.g. Only access 3 floats if ImGuiColorEditFlags_NoAlpha flag is set. -// With typical options: Left-click on color square to open color picker. Right-click to open option menu. CTRL-Click over input fields to edit them and TAB to go to next item. -bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flags) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - - ImGuiContext& g = *GImGui; - const ImGuiStyle& style = g.Style; - const float square_sz = GetFrameHeight(); - const float w_full = CalcItemWidth(); - const float w_button = (flags & ImGuiColorEditFlags_NoSmallPreview) ? 0.0f : (square_sz + style.ItemInnerSpacing.x); - const float w_inputs = w_full - w_button; - const char* label_display_end = FindRenderedTextEnd(label); - g.NextItemData.ClearFlags(); - - BeginGroup(); - PushID(label); - - // If we're not showing any slider there's no point in doing any HSV conversions - const ImGuiColorEditFlags flags_untouched = flags; - if (flags & ImGuiColorEditFlags_NoInputs) - flags = (flags & (~ImGuiColorEditFlags_DisplayMask_)) | ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_NoOptions; - - // Context menu: display and modify options (before defaults are applied) - if (!(flags & ImGuiColorEditFlags_NoOptions)) - ColorEditOptionsPopup(col, flags); - - // Read stored options - if (!(flags & ImGuiColorEditFlags_DisplayMask_)) - flags |= (g.ColorEditOptions & ImGuiColorEditFlags_DisplayMask_); - if (!(flags & ImGuiColorEditFlags_DataTypeMask_)) - flags |= (g.ColorEditOptions & ImGuiColorEditFlags_DataTypeMask_); - if (!(flags & ImGuiColorEditFlags_PickerMask_)) - flags |= (g.ColorEditOptions & ImGuiColorEditFlags_PickerMask_); - if (!(flags & ImGuiColorEditFlags_InputMask_)) - flags |= (g.ColorEditOptions & ImGuiColorEditFlags_InputMask_); - flags |= (g.ColorEditOptions & ~(ImGuiColorEditFlags_DisplayMask_ | ImGuiColorEditFlags_DataTypeMask_ | ImGuiColorEditFlags_PickerMask_ | ImGuiColorEditFlags_InputMask_)); - IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiColorEditFlags_DisplayMask_)); // Check that only 1 is selected - IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiColorEditFlags_InputMask_)); // Check that only 1 is selected - - const bool alpha = (flags & ImGuiColorEditFlags_NoAlpha) == 0; - const bool hdr = (flags & ImGuiColorEditFlags_HDR) != 0; - const int components = alpha ? 4 : 3; - - // Convert to the formats we need - float f[4] = { col[0], col[1], col[2], alpha ? col[3] : 1.0f }; - if ((flags & ImGuiColorEditFlags_InputHSV) && (flags & ImGuiColorEditFlags_DisplayRGB)) - ColorConvertHSVtoRGB(f[0], f[1], f[2], f[0], f[1], f[2]); - else if ((flags & ImGuiColorEditFlags_InputRGB) && (flags & ImGuiColorEditFlags_DisplayHSV)) - { - // Hue is lost when converting from greyscale rgb (saturation=0). Restore it. - ColorConvertRGBtoHSV(f[0], f[1], f[2], f[0], f[1], f[2]); - ColorEditRestoreHS(col, &f[0], &f[1], &f[2]); - } - int i[4] = { IM_F32_TO_INT8_UNBOUND(f[0]), IM_F32_TO_INT8_UNBOUND(f[1]), IM_F32_TO_INT8_UNBOUND(f[2]), IM_F32_TO_INT8_UNBOUND(f[3]) }; - - bool value_changed = false; - bool value_changed_as_float = false; - - const ImVec2 pos = window->DC.CursorPos; - const float inputs_offset_x = (style.ColorButtonPosition == ImGuiDir_Left) ? w_button : 0.0f; - window->DC.CursorPos.x = pos.x + inputs_offset_x; - - if ((flags & (ImGuiColorEditFlags_DisplayRGB | ImGuiColorEditFlags_DisplayHSV)) != 0 && (flags & ImGuiColorEditFlags_NoInputs) == 0) - { - // RGB/HSV 0..255 Sliders - const float w_item_one = ImMax(1.0f, IM_FLOOR((w_inputs - (style.ItemInnerSpacing.x) * (components - 1)) / (float)components)); - const float w_item_last = ImMax(1.0f, IM_FLOOR(w_inputs - (w_item_one + style.ItemInnerSpacing.x) * (components - 1))); - - const bool hide_prefix = (w_item_one <= CalcTextSize((flags & ImGuiColorEditFlags_Float) ? "M:0.000" : "M:000").x); - static const char* ids[4] = { "##X", "##Y", "##Z", "##W" }; - static const char* fmt_table_int[3][4] = - { - { "%3d", "%3d", "%3d", "%3d" }, // Short display - { "R:%3d", "G:%3d", "B:%3d", "A:%3d" }, // Long display for RGBA - { "H:%3d", "S:%3d", "V:%3d", "A:%3d" } // Long display for HSVA - }; - static const char* fmt_table_float[3][4] = - { - { "%0.3f", "%0.3f", "%0.3f", "%0.3f" }, // Short display - { "R:%0.3f", "G:%0.3f", "B:%0.3f", "A:%0.3f" }, // Long display for RGBA - { "H:%0.3f", "S:%0.3f", "V:%0.3f", "A:%0.3f" } // Long display for HSVA - }; - const int fmt_idx = hide_prefix ? 0 : (flags & ImGuiColorEditFlags_DisplayHSV) ? 2 : 1; - - for (int n = 0; n < components; n++) - { - if (n > 0) - SameLine(0, style.ItemInnerSpacing.x); - SetNextItemWidth((n + 1 < components) ? w_item_one : w_item_last); - - // FIXME: When ImGuiColorEditFlags_HDR flag is passed HS values snap in weird ways when SV values go below 0. - if (flags & ImGuiColorEditFlags_Float) - { - value_changed |= DragFloat(ids[n], &f[n], 1.0f / 255.0f, 0.0f, hdr ? 0.0f : 1.0f, fmt_table_float[fmt_idx][n]); - value_changed_as_float |= value_changed; - } - else - { - value_changed |= DragInt(ids[n], &i[n], 1.0f, 0, hdr ? 0 : 255, fmt_table_int[fmt_idx][n]); - } - if (!(flags & ImGuiColorEditFlags_NoOptions)) - OpenPopupOnItemClick("context"); - } - } - else if ((flags & ImGuiColorEditFlags_DisplayHex) != 0 && (flags & ImGuiColorEditFlags_NoInputs) == 0) - { - // RGB Hexadecimal Input - char buf[64]; - if (alpha) - ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X%02X", ImClamp(i[0], 0, 255), ImClamp(i[1], 0, 255), ImClamp(i[2], 0, 255), ImClamp(i[3], 0, 255)); - else - ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X", ImClamp(i[0], 0, 255), ImClamp(i[1], 0, 255), ImClamp(i[2], 0, 255)); - SetNextItemWidth(w_inputs); - if (InputText("##Text", buf, IM_ARRAYSIZE(buf), ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase)) - { - value_changed = true; - char* p = buf; - while (*p == '#' || ImCharIsBlankA(*p)) - p++; - i[0] = i[1] = i[2] = 0; - i[3] = 0xFF; // alpha default to 255 is not parsed by scanf (e.g. inputting #FFFFFF omitting alpha) - int r; - if (alpha) - r = sscanf(p, "%02X%02X%02X%02X", (unsigned int*)&i[0], (unsigned int*)&i[1], (unsigned int*)&i[2], (unsigned int*)&i[3]); // Treat at unsigned (%X is unsigned) - else - r = sscanf(p, "%02X%02X%02X", (unsigned int*)&i[0], (unsigned int*)&i[1], (unsigned int*)&i[2]); - IM_UNUSED(r); // Fixes C6031: Return value ignored: 'sscanf'. - } - if (!(flags & ImGuiColorEditFlags_NoOptions)) - OpenPopupOnItemClick("context"); - } - - ImGuiWindow* picker_active_window = NULL; - if (!(flags & ImGuiColorEditFlags_NoSmallPreview)) - { - const float button_offset_x = ((flags & ImGuiColorEditFlags_NoInputs) || (style.ColorButtonPosition == ImGuiDir_Left)) ? 0.0f : w_inputs + style.ItemInnerSpacing.x; - window->DC.CursorPos = ImVec2(pos.x + button_offset_x, pos.y); - - const ImVec4 col_v4(col[0], col[1], col[2], alpha ? col[3] : 1.0f); - if (ColorButton("##ColorButton", col_v4, flags)) - { - if (!(flags & ImGuiColorEditFlags_NoPicker)) - { - // Store current color and open a picker - g.ColorPickerRef = col_v4; - OpenPopup("picker"); - SetNextWindowPos(g.LastItemData.Rect.GetBL() + ImVec2(-1, style.ItemSpacing.y)); - } - } - if (!(flags & ImGuiColorEditFlags_NoOptions)) - OpenPopupOnItemClick("context"); - - if (BeginPopup("picker")) - { - picker_active_window = g.CurrentWindow; - if (label != label_display_end) - { - TextEx(label, label_display_end); - Spacing(); - } - ImGuiColorEditFlags picker_flags_to_forward = ImGuiColorEditFlags_DataTypeMask_ | ImGuiColorEditFlags_PickerMask_ | ImGuiColorEditFlags_InputMask_ | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaBar; - ImGuiColorEditFlags picker_flags = (flags_untouched & picker_flags_to_forward) | ImGuiColorEditFlags_DisplayMask_ | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_AlphaPreviewHalf; - SetNextItemWidth(square_sz * 12.0f); // Use 256 + bar sizes? - value_changed |= ColorPicker4("##picker", col, picker_flags, &g.ColorPickerRef.x); - EndPopup(); - } - } - - if (label != label_display_end && !(flags & ImGuiColorEditFlags_NoLabel)) - { - const float text_offset_x = (flags & ImGuiColorEditFlags_NoInputs) ? w_button : w_full + style.ItemInnerSpacing.x; - window->DC.CursorPos = ImVec2(pos.x + text_offset_x, pos.y + style.FramePadding.y); - TextEx(label, label_display_end); - } - - // Convert back - if (value_changed && picker_active_window == NULL) - { - if (!value_changed_as_float) - for (int n = 0; n < 4; n++) - f[n] = i[n] / 255.0f; - if ((flags & ImGuiColorEditFlags_DisplayHSV) && (flags & ImGuiColorEditFlags_InputRGB)) - { - g.ColorEditLastHue = f[0]; - g.ColorEditLastSat = f[1]; - ColorConvertHSVtoRGB(f[0], f[1], f[2], f[0], f[1], f[2]); - g.ColorEditLastColor = ColorConvertFloat4ToU32(ImVec4(f[0], f[1], f[2], 0)); - } - if ((flags & ImGuiColorEditFlags_DisplayRGB) && (flags & ImGuiColorEditFlags_InputHSV)) - ColorConvertRGBtoHSV(f[0], f[1], f[2], f[0], f[1], f[2]); - - col[0] = f[0]; - col[1] = f[1]; - col[2] = f[2]; - if (alpha) - col[3] = f[3]; - } - - PopID(); - EndGroup(); - - // Drag and Drop Target - // NB: The flag test is merely an optional micro-optimization, BeginDragDropTarget() does the same test. - if ((g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HoveredRect) && !(flags & ImGuiColorEditFlags_NoDragDrop) && BeginDragDropTarget()) - { - bool accepted_drag_drop = false; - if (const ImGuiPayload* payload = AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_3F)) - { - memcpy((float*)col, payload->Data, sizeof(float) * 3); // Preserve alpha if any //-V512 - value_changed = accepted_drag_drop = true; - } - if (const ImGuiPayload* payload = AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F)) - { - memcpy((float*)col, payload->Data, sizeof(float) * components); - value_changed = accepted_drag_drop = true; - } - - // Drag-drop payloads are always RGB - if (accepted_drag_drop && (flags & ImGuiColorEditFlags_InputHSV)) - ColorConvertRGBtoHSV(col[0], col[1], col[2], col[0], col[1], col[2]); - EndDragDropTarget(); - } - - // When picker is being actively used, use its active id so IsItemActive() will function on ColorEdit4(). - if (picker_active_window && g.ActiveId != 0 && g.ActiveIdWindow == picker_active_window) - g.LastItemData.ID = g.ActiveId; - - if (value_changed) - MarkItemEdited(g.LastItemData.ID); - - return value_changed; -} - -bool ImGui::ColorPicker3(const char* label, float col[3], ImGuiColorEditFlags flags) -{ - float col4[4] = { col[0], col[1], col[2], 1.0f }; - if (!ColorPicker4(label, col4, flags | ImGuiColorEditFlags_NoAlpha)) - return false; - col[0] = col4[0]; col[1] = col4[1]; col[2] = col4[2]; - return true; -} - -// Helper for ColorPicker4() -static void RenderArrowsForVerticalBar(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, float bar_w, float alpha) -{ - ImU32 alpha8 = IM_F32_TO_INT8_SAT(alpha); - ImGui::RenderArrowPointingAt(draw_list, ImVec2(pos.x + half_sz.x + 1, pos.y), ImVec2(half_sz.x + 2, half_sz.y + 1), ImGuiDir_Right, IM_COL32(0,0,0,alpha8)); - ImGui::RenderArrowPointingAt(draw_list, ImVec2(pos.x + half_sz.x, pos.y), half_sz, ImGuiDir_Right, IM_COL32(255,255,255,alpha8)); - ImGui::RenderArrowPointingAt(draw_list, ImVec2(pos.x + bar_w - half_sz.x - 1, pos.y), ImVec2(half_sz.x + 2, half_sz.y + 1), ImGuiDir_Left, IM_COL32(0,0,0,alpha8)); - ImGui::RenderArrowPointingAt(draw_list, ImVec2(pos.x + bar_w - half_sz.x, pos.y), half_sz, ImGuiDir_Left, IM_COL32(255,255,255,alpha8)); -} - -// Note: ColorPicker4() only accesses 3 floats if ImGuiColorEditFlags_NoAlpha flag is set. -// (In C++ the 'float col[4]' notation for a function argument is equivalent to 'float* col', we only specify a size to facilitate understanding of the code.) -// FIXME: we adjust the big color square height based on item width, which may cause a flickering feedback loop (if automatic height makes a vertical scrollbar appears, affecting automatic width..) -// FIXME: this is trying to be aware of style.Alpha but not fully correct. Also, the color wheel will have overlapping glitches with (style.Alpha < 1.0) -bool ImGui::ColorPicker4(const char* label, float col[4], ImGuiColorEditFlags flags, const float* ref_col) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - - ImDrawList* draw_list = window->DrawList; - ImGuiStyle& style = g.Style; - ImGuiIO& io = g.IO; - - const float width = CalcItemWidth(); - g.NextItemData.ClearFlags(); - - PushID(label); - BeginGroup(); - - if (!(flags & ImGuiColorEditFlags_NoSidePreview)) - flags |= ImGuiColorEditFlags_NoSmallPreview; - - // Context menu: display and store options. - if (!(flags & ImGuiColorEditFlags_NoOptions)) - ColorPickerOptionsPopup(col, flags); - - // Read stored options - if (!(flags & ImGuiColorEditFlags_PickerMask_)) - flags |= ((g.ColorEditOptions & ImGuiColorEditFlags_PickerMask_) ? g.ColorEditOptions : ImGuiColorEditFlags_DefaultOptions_) & ImGuiColorEditFlags_PickerMask_; - if (!(flags & ImGuiColorEditFlags_InputMask_)) - flags |= ((g.ColorEditOptions & ImGuiColorEditFlags_InputMask_) ? g.ColorEditOptions : ImGuiColorEditFlags_DefaultOptions_) & ImGuiColorEditFlags_InputMask_; - IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiColorEditFlags_PickerMask_)); // Check that only 1 is selected - IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiColorEditFlags_InputMask_)); // Check that only 1 is selected - if (!(flags & ImGuiColorEditFlags_NoOptions)) - flags |= (g.ColorEditOptions & ImGuiColorEditFlags_AlphaBar); - - // Setup - int components = (flags & ImGuiColorEditFlags_NoAlpha) ? 3 : 4; - bool alpha_bar = (flags & ImGuiColorEditFlags_AlphaBar) && !(flags & ImGuiColorEditFlags_NoAlpha); - ImVec2 picker_pos = window->DC.CursorPos; - float square_sz = GetFrameHeight(); - float bars_width = square_sz; // Arbitrary smallish width of Hue/Alpha picking bars - float sv_picker_size = ImMax(bars_width * 1, width - (alpha_bar ? 2 : 1) * (bars_width + style.ItemInnerSpacing.x)); // Saturation/Value picking box - float bar0_pos_x = picker_pos.x + sv_picker_size + style.ItemInnerSpacing.x; - float bar1_pos_x = bar0_pos_x + bars_width + style.ItemInnerSpacing.x; - float bars_triangles_half_sz = IM_FLOOR(bars_width * 0.20f); - - float backup_initial_col[4]; - memcpy(backup_initial_col, col, components * sizeof(float)); - - float wheel_thickness = sv_picker_size * 0.08f; - float wheel_r_outer = sv_picker_size * 0.50f; - float wheel_r_inner = wheel_r_outer - wheel_thickness; - ImVec2 wheel_center(picker_pos.x + (sv_picker_size + bars_width)*0.5f, picker_pos.y + sv_picker_size * 0.5f); - - // Note: the triangle is displayed rotated with triangle_pa pointing to Hue, but most coordinates stays unrotated for logic. - float triangle_r = wheel_r_inner - (int)(sv_picker_size * 0.027f); - ImVec2 triangle_pa = ImVec2(triangle_r, 0.0f); // Hue point. - ImVec2 triangle_pb = ImVec2(triangle_r * -0.5f, triangle_r * -0.866025f); // Black point. - ImVec2 triangle_pc = ImVec2(triangle_r * -0.5f, triangle_r * +0.866025f); // White point. - - float H = col[0], S = col[1], V = col[2]; - float R = col[0], G = col[1], B = col[2]; - if (flags & ImGuiColorEditFlags_InputRGB) - { - // Hue is lost when converting from greyscale rgb (saturation=0). Restore it. - ColorConvertRGBtoHSV(R, G, B, H, S, V); - ColorEditRestoreHS(col, &H, &S, &V); - } - else if (flags & ImGuiColorEditFlags_InputHSV) - { - ColorConvertHSVtoRGB(H, S, V, R, G, B); - } - - bool value_changed = false, value_changed_h = false, value_changed_sv = false; - - PushItemFlag(ImGuiItemFlags_NoNav, true); - if (flags & ImGuiColorEditFlags_PickerHueWheel) - { - // Hue wheel + SV triangle logic - InvisibleButton("hsv", ImVec2(sv_picker_size + style.ItemInnerSpacing.x + bars_width, sv_picker_size)); - if (IsItemActive()) - { - ImVec2 initial_off = g.IO.MouseClickedPos[0] - wheel_center; - ImVec2 current_off = g.IO.MousePos - wheel_center; - float initial_dist2 = ImLengthSqr(initial_off); - if (initial_dist2 >= (wheel_r_inner - 1) * (wheel_r_inner - 1) && initial_dist2 <= (wheel_r_outer + 1) * (wheel_r_outer + 1)) - { - // Interactive with Hue wheel - H = ImAtan2(current_off.y, current_off.x) / IM_PI * 0.5f; - if (H < 0.0f) - H += 1.0f; - value_changed = value_changed_h = true; - } - float cos_hue_angle = ImCos(-H * 2.0f * IM_PI); - float sin_hue_angle = ImSin(-H * 2.0f * IM_PI); - if (ImTriangleContainsPoint(triangle_pa, triangle_pb, triangle_pc, ImRotate(initial_off, cos_hue_angle, sin_hue_angle))) - { - // Interacting with SV triangle - ImVec2 current_off_unrotated = ImRotate(current_off, cos_hue_angle, sin_hue_angle); - if (!ImTriangleContainsPoint(triangle_pa, triangle_pb, triangle_pc, current_off_unrotated)) - current_off_unrotated = ImTriangleClosestPoint(triangle_pa, triangle_pb, triangle_pc, current_off_unrotated); - float uu, vv, ww; - ImTriangleBarycentricCoords(triangle_pa, triangle_pb, triangle_pc, current_off_unrotated, uu, vv, ww); - V = ImClamp(1.0f - vv, 0.0001f, 1.0f); - S = ImClamp(uu / V, 0.0001f, 1.0f); - value_changed = value_changed_sv = true; - } - } - if (!(flags & ImGuiColorEditFlags_NoOptions)) - OpenPopupOnItemClick("context"); - } - else if (flags & ImGuiColorEditFlags_PickerHueBar) - { - // SV rectangle logic - InvisibleButton("sv", ImVec2(sv_picker_size, sv_picker_size)); - if (IsItemActive()) - { - S = ImSaturate((io.MousePos.x - picker_pos.x) / (sv_picker_size - 1)); - V = 1.0f - ImSaturate((io.MousePos.y - picker_pos.y) / (sv_picker_size - 1)); - - // Greatly reduces hue jitter and reset to 0 when hue == 255 and color is rapidly modified using SV square. - if (g.ColorEditLastColor == ColorConvertFloat4ToU32(ImVec4(col[0], col[1], col[2], 0))) - H = g.ColorEditLastHue; - value_changed = value_changed_sv = true; - } - if (!(flags & ImGuiColorEditFlags_NoOptions)) - OpenPopupOnItemClick("context"); - - // Hue bar logic - SetCursorScreenPos(ImVec2(bar0_pos_x, picker_pos.y)); - InvisibleButton("hue", ImVec2(bars_width, sv_picker_size)); - if (IsItemActive()) - { - H = ImSaturate((io.MousePos.y - picker_pos.y) / (sv_picker_size - 1)); - value_changed = value_changed_h = true; - } - } - - // Alpha bar logic - if (alpha_bar) - { - SetCursorScreenPos(ImVec2(bar1_pos_x, picker_pos.y)); - InvisibleButton("alpha", ImVec2(bars_width, sv_picker_size)); - if (IsItemActive()) - { - col[3] = 1.0f - ImSaturate((io.MousePos.y - picker_pos.y) / (sv_picker_size - 1)); - value_changed = true; - } - } - PopItemFlag(); // ImGuiItemFlags_NoNav - - if (!(flags & ImGuiColorEditFlags_NoSidePreview)) - { - SameLine(0, style.ItemInnerSpacing.x); - BeginGroup(); - } - - if (!(flags & ImGuiColorEditFlags_NoLabel)) - { - const char* label_display_end = FindRenderedTextEnd(label); - if (label != label_display_end) - { - if ((flags & ImGuiColorEditFlags_NoSidePreview)) - SameLine(0, style.ItemInnerSpacing.x); - TextEx(label, label_display_end); - } - } - - if (!(flags & ImGuiColorEditFlags_NoSidePreview)) - { - PushItemFlag(ImGuiItemFlags_NoNavDefaultFocus, true); - ImVec4 col_v4(col[0], col[1], col[2], (flags & ImGuiColorEditFlags_NoAlpha) ? 1.0f : col[3]); - if ((flags & ImGuiColorEditFlags_NoLabel)) - Text("Current"); - - ImGuiColorEditFlags sub_flags_to_forward = ImGuiColorEditFlags_InputMask_ | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf | ImGuiColorEditFlags_NoTooltip; - ColorButton("##current", col_v4, (flags & sub_flags_to_forward), ImVec2(square_sz * 3, square_sz * 2)); - if (ref_col != NULL) - { - Text("Original"); - ImVec4 ref_col_v4(ref_col[0], ref_col[1], ref_col[2], (flags & ImGuiColorEditFlags_NoAlpha) ? 1.0f : ref_col[3]); - if (ColorButton("##original", ref_col_v4, (flags & sub_flags_to_forward), ImVec2(square_sz * 3, square_sz * 2))) - { - memcpy(col, ref_col, components * sizeof(float)); - value_changed = true; - } - } - PopItemFlag(); - EndGroup(); - } - - // Convert back color to RGB - if (value_changed_h || value_changed_sv) - { - if (flags & ImGuiColorEditFlags_InputRGB) - { - ColorConvertHSVtoRGB(H, S, V, col[0], col[1], col[2]); - g.ColorEditLastHue = H; - g.ColorEditLastSat = S; - g.ColorEditLastColor = ColorConvertFloat4ToU32(ImVec4(col[0], col[1], col[2], 0)); - } - else if (flags & ImGuiColorEditFlags_InputHSV) - { - col[0] = H; - col[1] = S; - col[2] = V; - } - } - - // R,G,B and H,S,V slider color editor - bool value_changed_fix_hue_wrap = false; - if ((flags & ImGuiColorEditFlags_NoInputs) == 0) - { - PushItemWidth((alpha_bar ? bar1_pos_x : bar0_pos_x) + bars_width - picker_pos.x); - ImGuiColorEditFlags sub_flags_to_forward = ImGuiColorEditFlags_DataTypeMask_ | ImGuiColorEditFlags_InputMask_ | ImGuiColorEditFlags_HDR | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_NoOptions | ImGuiColorEditFlags_NoSmallPreview | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf; - ImGuiColorEditFlags sub_flags = (flags & sub_flags_to_forward) | ImGuiColorEditFlags_NoPicker; - if (flags & ImGuiColorEditFlags_DisplayRGB || (flags & ImGuiColorEditFlags_DisplayMask_) == 0) - if (ColorEdit4("##rgb", col, sub_flags | ImGuiColorEditFlags_DisplayRGB)) - { - // FIXME: Hackily differentiating using the DragInt (ActiveId != 0 && !ActiveIdAllowOverlap) vs. using the InputText or DropTarget. - // For the later we don't want to run the hue-wrap canceling code. If you are well versed in HSV picker please provide your input! (See #2050) - value_changed_fix_hue_wrap = (g.ActiveId != 0 && !g.ActiveIdAllowOverlap); - value_changed = true; - } - if (flags & ImGuiColorEditFlags_DisplayHSV || (flags & ImGuiColorEditFlags_DisplayMask_) == 0) - value_changed |= ColorEdit4("##hsv", col, sub_flags | ImGuiColorEditFlags_DisplayHSV); - if (flags & ImGuiColorEditFlags_DisplayHex || (flags & ImGuiColorEditFlags_DisplayMask_) == 0) - value_changed |= ColorEdit4("##hex", col, sub_flags | ImGuiColorEditFlags_DisplayHex); - PopItemWidth(); - } - - // Try to cancel hue wrap (after ColorEdit4 call), if any - if (value_changed_fix_hue_wrap && (flags & ImGuiColorEditFlags_InputRGB)) - { - float new_H, new_S, new_V; - ColorConvertRGBtoHSV(col[0], col[1], col[2], new_H, new_S, new_V); - if (new_H <= 0 && H > 0) - { - if (new_V <= 0 && V != new_V) - ColorConvertHSVtoRGB(H, S, new_V <= 0 ? V * 0.5f : new_V, col[0], col[1], col[2]); - else if (new_S <= 0) - ColorConvertHSVtoRGB(H, new_S <= 0 ? S * 0.5f : new_S, new_V, col[0], col[1], col[2]); - } - } - - if (value_changed) - { - if (flags & ImGuiColorEditFlags_InputRGB) - { - R = col[0]; - G = col[1]; - B = col[2]; - ColorConvertRGBtoHSV(R, G, B, H, S, V); - ColorEditRestoreHS(col, &H, &S, &V); // Fix local Hue as display below will use it immediately. - } - else if (flags & ImGuiColorEditFlags_InputHSV) - { - H = col[0]; - S = col[1]; - V = col[2]; - ColorConvertHSVtoRGB(H, S, V, R, G, B); - } - } - - const int style_alpha8 = IM_F32_TO_INT8_SAT(style.Alpha); - const ImU32 col_black = IM_COL32(0,0,0,style_alpha8); - const ImU32 col_white = IM_COL32(255,255,255,style_alpha8); - const ImU32 col_midgrey = IM_COL32(128,128,128,style_alpha8); - const ImU32 col_hues[6 + 1] = { IM_COL32(255,0,0,style_alpha8), IM_COL32(255,255,0,style_alpha8), IM_COL32(0,255,0,style_alpha8), IM_COL32(0,255,255,style_alpha8), IM_COL32(0,0,255,style_alpha8), IM_COL32(255,0,255,style_alpha8), IM_COL32(255,0,0,style_alpha8) }; - - ImVec4 hue_color_f(1, 1, 1, style.Alpha); ColorConvertHSVtoRGB(H, 1, 1, hue_color_f.x, hue_color_f.y, hue_color_f.z); - ImU32 hue_color32 = ColorConvertFloat4ToU32(hue_color_f); - ImU32 user_col32_striped_of_alpha = ColorConvertFloat4ToU32(ImVec4(R, G, B, style.Alpha)); // Important: this is still including the main rendering/style alpha!! - - ImVec2 sv_cursor_pos; - - if (flags & ImGuiColorEditFlags_PickerHueWheel) - { - // Render Hue Wheel - const float aeps = 0.5f / wheel_r_outer; // Half a pixel arc length in radians (2pi cancels out). - const int segment_per_arc = ImMax(4, (int)wheel_r_outer / 12); - for (int n = 0; n < 6; n++) - { - const float a0 = (n) /6.0f * 2.0f * IM_PI - aeps; - const float a1 = (n+1.0f)/6.0f * 2.0f * IM_PI + aeps; - const int vert_start_idx = draw_list->VtxBuffer.Size; - draw_list->PathArcTo(wheel_center, (wheel_r_inner + wheel_r_outer)*0.5f, a0, a1, segment_per_arc); - draw_list->PathStroke(col_white, 0, wheel_thickness); - const int vert_end_idx = draw_list->VtxBuffer.Size; - - // Paint colors over existing vertices - ImVec2 gradient_p0(wheel_center.x + ImCos(a0) * wheel_r_inner, wheel_center.y + ImSin(a0) * wheel_r_inner); - ImVec2 gradient_p1(wheel_center.x + ImCos(a1) * wheel_r_inner, wheel_center.y + ImSin(a1) * wheel_r_inner); - ShadeVertsLinearColorGradientKeepAlpha(draw_list, vert_start_idx, vert_end_idx, gradient_p0, gradient_p1, col_hues[n], col_hues[n + 1]); - } - - // Render Cursor + preview on Hue Wheel - float cos_hue_angle = ImCos(H * 2.0f * IM_PI); - float sin_hue_angle = ImSin(H * 2.0f * IM_PI); - ImVec2 hue_cursor_pos(wheel_center.x + cos_hue_angle * (wheel_r_inner + wheel_r_outer) * 0.5f, wheel_center.y + sin_hue_angle * (wheel_r_inner + wheel_r_outer) * 0.5f); - float hue_cursor_rad = value_changed_h ? wheel_thickness * 0.65f : wheel_thickness * 0.55f; - int hue_cursor_segments = ImClamp((int)(hue_cursor_rad / 1.4f), 9, 32); - draw_list->AddCircleFilled(hue_cursor_pos, hue_cursor_rad, hue_color32, hue_cursor_segments); - draw_list->AddCircle(hue_cursor_pos, hue_cursor_rad + 1, col_midgrey, hue_cursor_segments); - draw_list->AddCircle(hue_cursor_pos, hue_cursor_rad, col_white, hue_cursor_segments); - - // Render SV triangle (rotated according to hue) - ImVec2 tra = wheel_center + ImRotate(triangle_pa, cos_hue_angle, sin_hue_angle); - ImVec2 trb = wheel_center + ImRotate(triangle_pb, cos_hue_angle, sin_hue_angle); - ImVec2 trc = wheel_center + ImRotate(triangle_pc, cos_hue_angle, sin_hue_angle); - ImVec2 uv_white = GetFontTexUvWhitePixel(); - draw_list->PrimReserve(6, 6); - draw_list->PrimVtx(tra, uv_white, hue_color32); - draw_list->PrimVtx(trb, uv_white, hue_color32); - draw_list->PrimVtx(trc, uv_white, col_white); - draw_list->PrimVtx(tra, uv_white, 0); - draw_list->PrimVtx(trb, uv_white, col_black); - draw_list->PrimVtx(trc, uv_white, 0); - draw_list->AddTriangle(tra, trb, trc, col_midgrey, 1.5f); - sv_cursor_pos = ImLerp(ImLerp(trc, tra, ImSaturate(S)), trb, ImSaturate(1 - V)); - } - else if (flags & ImGuiColorEditFlags_PickerHueBar) - { - // Render SV Square - draw_list->AddRectFilledMultiColor(picker_pos, picker_pos + ImVec2(sv_picker_size, sv_picker_size), col_white, hue_color32, hue_color32, col_white); - draw_list->AddRectFilledMultiColor(picker_pos, picker_pos + ImVec2(sv_picker_size, sv_picker_size), 0, 0, col_black, col_black); - RenderFrameBorder(picker_pos, picker_pos + ImVec2(sv_picker_size, sv_picker_size), 0.0f); - sv_cursor_pos.x = ImClamp(IM_ROUND(picker_pos.x + ImSaturate(S) * sv_picker_size), picker_pos.x + 2, picker_pos.x + sv_picker_size - 2); // Sneakily prevent the circle to stick out too much - sv_cursor_pos.y = ImClamp(IM_ROUND(picker_pos.y + ImSaturate(1 - V) * sv_picker_size), picker_pos.y + 2, picker_pos.y + sv_picker_size - 2); - - // Render Hue Bar - for (int i = 0; i < 6; ++i) - draw_list->AddRectFilledMultiColor(ImVec2(bar0_pos_x, picker_pos.y + i * (sv_picker_size / 6)), ImVec2(bar0_pos_x + bars_width, picker_pos.y + (i + 1) * (sv_picker_size / 6)), col_hues[i], col_hues[i], col_hues[i + 1], col_hues[i + 1]); - float bar0_line_y = IM_ROUND(picker_pos.y + H * sv_picker_size); - RenderFrameBorder(ImVec2(bar0_pos_x, picker_pos.y), ImVec2(bar0_pos_x + bars_width, picker_pos.y + sv_picker_size), 0.0f); - RenderArrowsForVerticalBar(draw_list, ImVec2(bar0_pos_x - 1, bar0_line_y), ImVec2(bars_triangles_half_sz + 1, bars_triangles_half_sz), bars_width + 2.0f, style.Alpha); - } - - // Render cursor/preview circle (clamp S/V within 0..1 range because floating points colors may lead HSV values to be out of range) - float sv_cursor_rad = value_changed_sv ? 10.0f : 6.0f; - draw_list->AddCircleFilled(sv_cursor_pos, sv_cursor_rad, user_col32_striped_of_alpha, 12); - draw_list->AddCircle(sv_cursor_pos, sv_cursor_rad + 1, col_midgrey, 12); - draw_list->AddCircle(sv_cursor_pos, sv_cursor_rad, col_white, 12); - - // Render alpha bar - if (alpha_bar) - { - float alpha = ImSaturate(col[3]); - ImRect bar1_bb(bar1_pos_x, picker_pos.y, bar1_pos_x + bars_width, picker_pos.y + sv_picker_size); - RenderColorRectWithAlphaCheckerboard(draw_list, bar1_bb.Min, bar1_bb.Max, 0, bar1_bb.GetWidth() / 2.0f, ImVec2(0.0f, 0.0f)); - draw_list->AddRectFilledMultiColor(bar1_bb.Min, bar1_bb.Max, user_col32_striped_of_alpha, user_col32_striped_of_alpha, user_col32_striped_of_alpha & ~IM_COL32_A_MASK, user_col32_striped_of_alpha & ~IM_COL32_A_MASK); - float bar1_line_y = IM_ROUND(picker_pos.y + (1.0f - alpha) * sv_picker_size); - RenderFrameBorder(bar1_bb.Min, bar1_bb.Max, 0.0f); - RenderArrowsForVerticalBar(draw_list, ImVec2(bar1_pos_x - 1, bar1_line_y), ImVec2(bars_triangles_half_sz + 1, bars_triangles_half_sz), bars_width + 2.0f, style.Alpha); - } - - EndGroup(); - - if (value_changed && memcmp(backup_initial_col, col, components * sizeof(float)) == 0) - value_changed = false; - if (value_changed) - MarkItemEdited(g.LastItemData.ID); - - PopID(); - - return value_changed; -} - -// A little color square. Return true when clicked. -// FIXME: May want to display/ignore the alpha component in the color display? Yet show it in the tooltip. -// 'desc_id' is not called 'label' because we don't display it next to the button, but only in the tooltip. -// Note that 'col' may be encoded in HSV if ImGuiColorEditFlags_InputHSV is set. -bool ImGui::ColorButton(const char* desc_id, const ImVec4& col, ImGuiColorEditFlags flags, ImVec2 size) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - - ImGuiContext& g = *GImGui; - const ImGuiID id = window->GetID(desc_id); - float default_size = GetFrameHeight(); - if (size.x == 0.0f) - size.x = default_size; - if (size.y == 0.0f) - size.y = default_size; - const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size); - ItemSize(bb, (size.y >= default_size) ? g.Style.FramePadding.y : 0.0f); - if (!ItemAdd(bb, id)) - return false; - - bool hovered, held; - bool pressed = ButtonBehavior(bb, id, &hovered, &held); - - if (flags & ImGuiColorEditFlags_NoAlpha) - flags &= ~(ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf); - - ImVec4 col_rgb = col; - if (flags & ImGuiColorEditFlags_InputHSV) - ColorConvertHSVtoRGB(col_rgb.x, col_rgb.y, col_rgb.z, col_rgb.x, col_rgb.y, col_rgb.z); - - ImVec4 col_rgb_without_alpha(col_rgb.x, col_rgb.y, col_rgb.z, 1.0f); - float grid_step = ImMin(size.x, size.y) / 2.99f; - float rounding = ImMin(g.Style.FrameRounding, grid_step * 0.5f); - ImRect bb_inner = bb; - float off = 0.0f; - if ((flags & ImGuiColorEditFlags_NoBorder) == 0) - { - off = -0.75f; // The border (using Col_FrameBg) tends to look off when color is near-opaque and rounding is enabled. This offset seemed like a good middle ground to reduce those artifacts. - bb_inner.Expand(off); - } - if ((flags & ImGuiColorEditFlags_AlphaPreviewHalf) && col_rgb.w < 1.0f) - { - float mid_x = IM_ROUND((bb_inner.Min.x + bb_inner.Max.x) * 0.5f); - RenderColorRectWithAlphaCheckerboard(window->DrawList, ImVec2(bb_inner.Min.x + grid_step, bb_inner.Min.y), bb_inner.Max, GetColorU32(col_rgb), grid_step, ImVec2(-grid_step + off, off), rounding, ImDrawFlags_RoundCornersRight); - window->DrawList->AddRectFilled(bb_inner.Min, ImVec2(mid_x, bb_inner.Max.y), GetColorU32(col_rgb_without_alpha), rounding, ImDrawFlags_RoundCornersLeft); - } - else - { - // Because GetColorU32() multiplies by the global style Alpha and we don't want to display a checkerboard if the source code had no alpha - ImVec4 col_source = (flags & ImGuiColorEditFlags_AlphaPreview) ? col_rgb : col_rgb_without_alpha; - if (col_source.w < 1.0f) - RenderColorRectWithAlphaCheckerboard(window->DrawList, bb_inner.Min, bb_inner.Max, GetColorU32(col_source), grid_step, ImVec2(off, off), rounding); - else - window->DrawList->AddRectFilled(bb_inner.Min, bb_inner.Max, GetColorU32(col_source), rounding); - } - RenderNavHighlight(bb, id); - if ((flags & ImGuiColorEditFlags_NoBorder) == 0) - { - if (g.Style.FrameBorderSize > 0.0f) - RenderFrameBorder(bb.Min, bb.Max, rounding); - else - window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_FrameBg), rounding); // Color button are often in need of some sort of border - } - - // Drag and Drop Source - // NB: The ActiveId test is merely an optional micro-optimization, BeginDragDropSource() does the same test. - if (g.ActiveId == id && !(flags & ImGuiColorEditFlags_NoDragDrop) && BeginDragDropSource()) - { - if (flags & ImGuiColorEditFlags_NoAlpha) - SetDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_3F, &col_rgb, sizeof(float) * 3, ImGuiCond_Once); - else - SetDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F, &col_rgb, sizeof(float) * 4, ImGuiCond_Once); - ColorButton(desc_id, col, flags); - SameLine(); - TextEx("Color"); - EndDragDropSource(); - } - - // Tooltip - if (!(flags & ImGuiColorEditFlags_NoTooltip) && hovered) - ColorTooltip(desc_id, &col.x, flags & (ImGuiColorEditFlags_InputMask_ | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf)); - - return pressed; -} - -// Initialize/override default color options -void ImGui::SetColorEditOptions(ImGuiColorEditFlags flags) -{ - ImGuiContext& g = *GImGui; - if ((flags & ImGuiColorEditFlags_DisplayMask_) == 0) - flags |= ImGuiColorEditFlags_DefaultOptions_ & ImGuiColorEditFlags_DisplayMask_; - if ((flags & ImGuiColorEditFlags_DataTypeMask_) == 0) - flags |= ImGuiColorEditFlags_DefaultOptions_ & ImGuiColorEditFlags_DataTypeMask_; - if ((flags & ImGuiColorEditFlags_PickerMask_) == 0) - flags |= ImGuiColorEditFlags_DefaultOptions_ & ImGuiColorEditFlags_PickerMask_; - if ((flags & ImGuiColorEditFlags_InputMask_) == 0) - flags |= ImGuiColorEditFlags_DefaultOptions_ & ImGuiColorEditFlags_InputMask_; - IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiColorEditFlags_DisplayMask_)); // Check only 1 option is selected - IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiColorEditFlags_DataTypeMask_)); // Check only 1 option is selected - IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiColorEditFlags_PickerMask_)); // Check only 1 option is selected - IM_ASSERT(ImIsPowerOfTwo(flags & ImGuiColorEditFlags_InputMask_)); // Check only 1 option is selected - g.ColorEditOptions = flags; -} - -// Note: only access 3 floats if ImGuiColorEditFlags_NoAlpha flag is set. -void ImGui::ColorTooltip(const char* text, const float* col, ImGuiColorEditFlags flags) -{ - ImGuiContext& g = *GImGui; - - BeginTooltipEx(0, ImGuiTooltipFlags_OverridePreviousTooltip); - const char* text_end = text ? FindRenderedTextEnd(text, NULL) : text; - if (text_end > text) - { - TextEx(text, text_end); - Separator(); - } - - ImVec2 sz(g.FontSize * 3 + g.Style.FramePadding.y * 2, g.FontSize * 3 + g.Style.FramePadding.y * 2); - ImVec4 cf(col[0], col[1], col[2], (flags & ImGuiColorEditFlags_NoAlpha) ? 1.0f : col[3]); - int cr = IM_F32_TO_INT8_SAT(col[0]), cg = IM_F32_TO_INT8_SAT(col[1]), cb = IM_F32_TO_INT8_SAT(col[2]), ca = (flags & ImGuiColorEditFlags_NoAlpha) ? 255 : IM_F32_TO_INT8_SAT(col[3]); - ColorButton("##preview", cf, (flags & (ImGuiColorEditFlags_InputMask_ | ImGuiColorEditFlags_NoAlpha | ImGuiColorEditFlags_AlphaPreview | ImGuiColorEditFlags_AlphaPreviewHalf)) | ImGuiColorEditFlags_NoTooltip, sz); - SameLine(); - if ((flags & ImGuiColorEditFlags_InputRGB) || !(flags & ImGuiColorEditFlags_InputMask_)) - { - if (flags & ImGuiColorEditFlags_NoAlpha) - Text("#%02X%02X%02X\nR: %d, G: %d, B: %d\n(%.3f, %.3f, %.3f)", cr, cg, cb, cr, cg, cb, col[0], col[1], col[2]); - else - Text("#%02X%02X%02X%02X\nR:%d, G:%d, B:%d, A:%d\n(%.3f, %.3f, %.3f, %.3f)", cr, cg, cb, ca, cr, cg, cb, ca, col[0], col[1], col[2], col[3]); - } - else if (flags & ImGuiColorEditFlags_InputHSV) - { - if (flags & ImGuiColorEditFlags_NoAlpha) - Text("H: %.3f, S: %.3f, V: %.3f", col[0], col[1], col[2]); - else - Text("H: %.3f, S: %.3f, V: %.3f, A: %.3f", col[0], col[1], col[2], col[3]); - } - EndTooltip(); -} - -void ImGui::ColorEditOptionsPopup(const float* col, ImGuiColorEditFlags flags) -{ - bool allow_opt_inputs = !(flags & ImGuiColorEditFlags_DisplayMask_); - bool allow_opt_datatype = !(flags & ImGuiColorEditFlags_DataTypeMask_); - if ((!allow_opt_inputs && !allow_opt_datatype) || !BeginPopup("context")) - return; - ImGuiContext& g = *GImGui; - ImGuiColorEditFlags opts = g.ColorEditOptions; - if (allow_opt_inputs) - { - if (RadioButton("RGB", (opts & ImGuiColorEditFlags_DisplayRGB) != 0)) opts = (opts & ~ImGuiColorEditFlags_DisplayMask_) | ImGuiColorEditFlags_DisplayRGB; - if (RadioButton("HSV", (opts & ImGuiColorEditFlags_DisplayHSV) != 0)) opts = (opts & ~ImGuiColorEditFlags_DisplayMask_) | ImGuiColorEditFlags_DisplayHSV; - if (RadioButton("Hex", (opts & ImGuiColorEditFlags_DisplayHex) != 0)) opts = (opts & ~ImGuiColorEditFlags_DisplayMask_) | ImGuiColorEditFlags_DisplayHex; - } - if (allow_opt_datatype) - { - if (allow_opt_inputs) Separator(); - if (RadioButton("0..255", (opts & ImGuiColorEditFlags_Uint8) != 0)) opts = (opts & ~ImGuiColorEditFlags_DataTypeMask_) | ImGuiColorEditFlags_Uint8; - if (RadioButton("0.00..1.00", (opts & ImGuiColorEditFlags_Float) != 0)) opts = (opts & ~ImGuiColorEditFlags_DataTypeMask_) | ImGuiColorEditFlags_Float; - } - - if (allow_opt_inputs || allow_opt_datatype) - Separator(); - if (Button("Copy as..", ImVec2(-1, 0))) - OpenPopup("Copy"); - if (BeginPopup("Copy")) - { - int cr = IM_F32_TO_INT8_SAT(col[0]), cg = IM_F32_TO_INT8_SAT(col[1]), cb = IM_F32_TO_INT8_SAT(col[2]), ca = (flags & ImGuiColorEditFlags_NoAlpha) ? 255 : IM_F32_TO_INT8_SAT(col[3]); - char buf[64]; - ImFormatString(buf, IM_ARRAYSIZE(buf), "(%.3ff, %.3ff, %.3ff, %.3ff)", col[0], col[1], col[2], (flags & ImGuiColorEditFlags_NoAlpha) ? 1.0f : col[3]); - if (Selectable(buf)) - SetClipboardText(buf); - ImFormatString(buf, IM_ARRAYSIZE(buf), "(%d,%d,%d,%d)", cr, cg, cb, ca); - if (Selectable(buf)) - SetClipboardText(buf); - ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X", cr, cg, cb); - if (Selectable(buf)) - SetClipboardText(buf); - if (!(flags & ImGuiColorEditFlags_NoAlpha)) - { - ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X%02X", cr, cg, cb, ca); - if (Selectable(buf)) - SetClipboardText(buf); - } - EndPopup(); - } - - g.ColorEditOptions = opts; - EndPopup(); -} - -void ImGui::ColorPickerOptionsPopup(const float* ref_col, ImGuiColorEditFlags flags) -{ - bool allow_opt_picker = !(flags & ImGuiColorEditFlags_PickerMask_); - bool allow_opt_alpha_bar = !(flags & ImGuiColorEditFlags_NoAlpha) && !(flags & ImGuiColorEditFlags_AlphaBar); - if ((!allow_opt_picker && !allow_opt_alpha_bar) || !BeginPopup("context")) - return; - ImGuiContext& g = *GImGui; - if (allow_opt_picker) - { - ImVec2 picker_size(g.FontSize * 8, ImMax(g.FontSize * 8 - (GetFrameHeight() + g.Style.ItemInnerSpacing.x), 1.0f)); // FIXME: Picker size copied from main picker function - PushItemWidth(picker_size.x); - for (int picker_type = 0; picker_type < 2; picker_type++) - { - // Draw small/thumbnail version of each picker type (over an invisible button for selection) - if (picker_type > 0) Separator(); - PushID(picker_type); - ImGuiColorEditFlags picker_flags = ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoOptions | ImGuiColorEditFlags_NoLabel | ImGuiColorEditFlags_NoSidePreview | (flags & ImGuiColorEditFlags_NoAlpha); - if (picker_type == 0) picker_flags |= ImGuiColorEditFlags_PickerHueBar; - if (picker_type == 1) picker_flags |= ImGuiColorEditFlags_PickerHueWheel; - ImVec2 backup_pos = GetCursorScreenPos(); - if (Selectable("##selectable", false, 0, picker_size)) // By default, Selectable() is closing popup - g.ColorEditOptions = (g.ColorEditOptions & ~ImGuiColorEditFlags_PickerMask_) | (picker_flags & ImGuiColorEditFlags_PickerMask_); - SetCursorScreenPos(backup_pos); - ImVec4 previewing_ref_col; - memcpy(&previewing_ref_col, ref_col, sizeof(float) * ((picker_flags & ImGuiColorEditFlags_NoAlpha) ? 3 : 4)); - ColorPicker4("##previewing_picker", &previewing_ref_col.x, picker_flags); - PopID(); - } - PopItemWidth(); - } - if (allow_opt_alpha_bar) - { - if (allow_opt_picker) Separator(); - CheckboxFlags("Alpha Bar", &g.ColorEditOptions, ImGuiColorEditFlags_AlphaBar); - } - EndPopup(); -} - -//------------------------------------------------------------------------- -// [SECTION] Widgets: TreeNode, CollapsingHeader, etc. -//------------------------------------------------------------------------- -// - TreeNode() -// - TreeNodeV() -// - TreeNodeEx() -// - TreeNodeExV() -// - TreeNodeBehavior() [Internal] -// - TreePush() -// - TreePop() -// - GetTreeNodeToLabelSpacing() -// - SetNextItemOpen() -// - CollapsingHeader() -//------------------------------------------------------------------------- - -bool ImGui::TreeNode(const char* str_id, const char* fmt, ...) -{ - va_list args; - va_start(args, fmt); - bool is_open = TreeNodeExV(str_id, 0, fmt, args); - va_end(args); - return is_open; -} - -bool ImGui::TreeNode(const void* ptr_id, const char* fmt, ...) -{ - va_list args; - va_start(args, fmt); - bool is_open = TreeNodeExV(ptr_id, 0, fmt, args); - va_end(args); - return is_open; -} - -bool ImGui::TreeNode(const char* label) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - return TreeNodeBehavior(window->GetID(label), 0, label, NULL); -} - -bool ImGui::TreeNodeV(const char* str_id, const char* fmt, va_list args) -{ - return TreeNodeExV(str_id, 0, fmt, args); -} - -bool ImGui::TreeNodeV(const void* ptr_id, const char* fmt, va_list args) -{ - return TreeNodeExV(ptr_id, 0, fmt, args); -} - -bool ImGui::TreeNodeEx(const char* label, ImGuiTreeNodeFlags flags) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - - return TreeNodeBehavior(window->GetID(label), flags, label, NULL); -} - -bool ImGui::TreeNodeEx(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) -{ - va_list args; - va_start(args, fmt); - bool is_open = TreeNodeExV(str_id, flags, fmt, args); - va_end(args); - return is_open; -} - -bool ImGui::TreeNodeEx(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, ...) -{ - va_list args; - va_start(args, fmt); - bool is_open = TreeNodeExV(ptr_id, flags, fmt, args); - va_end(args); - return is_open; -} - -bool ImGui::TreeNodeExV(const char* str_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - - ImGuiContext& g = *GImGui; - const char* label_end = g.TempBuffer + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args); - return TreeNodeBehavior(window->GetID(str_id), flags, g.TempBuffer, label_end); -} - -bool ImGui::TreeNodeExV(const void* ptr_id, ImGuiTreeNodeFlags flags, const char* fmt, va_list args) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - - ImGuiContext& g = *GImGui; - const char* label_end = g.TempBuffer + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args); - return TreeNodeBehavior(window->GetID(ptr_id), flags, g.TempBuffer, label_end); -} - -bool ImGui::TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags) -{ - if (flags & ImGuiTreeNodeFlags_Leaf) - return true; - - // We only write to the tree storage if the user clicks (or explicitly use the SetNextItemOpen function) - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - ImGuiStorage* storage = window->DC.StateStorage; - - bool is_open; - if (g.NextItemData.Flags & ImGuiNextItemDataFlags_HasOpen) - { - if (g.NextItemData.OpenCond & ImGuiCond_Always) - { - is_open = g.NextItemData.OpenVal; - storage->SetInt(id, is_open); - } - else - { - // We treat ImGuiCond_Once and ImGuiCond_FirstUseEver the same because tree node state are not saved persistently. - const int stored_value = storage->GetInt(id, -1); - if (stored_value == -1) - { - is_open = g.NextItemData.OpenVal; - storage->SetInt(id, is_open); - } - else - { - is_open = stored_value != 0; - } - } - } - else - { - is_open = storage->GetInt(id, (flags & ImGuiTreeNodeFlags_DefaultOpen) ? 1 : 0) != 0; - } - - // When logging is enabled, we automatically expand tree nodes (but *NOT* collapsing headers.. seems like sensible behavior). - // NB- If we are above max depth we still allow manually opened nodes to be logged. - if (g.LogEnabled && !(flags & ImGuiTreeNodeFlags_NoAutoOpenOnLog) && (window->DC.TreeDepth - g.LogDepthRef) < g.LogDepthToExpand) - is_open = true; - - return is_open; -} - -bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* label, const char* label_end) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - - ImGuiContext& g = *GImGui; - const ImGuiStyle& style = g.Style; - const bool display_frame = (flags & ImGuiTreeNodeFlags_Framed) != 0; - const ImVec2 padding = (display_frame || (flags & ImGuiTreeNodeFlags_FramePadding)) ? style.FramePadding : ImVec2(style.FramePadding.x, ImMin(window->DC.CurrLineTextBaseOffset, style.FramePadding.y)); - - if (!label_end) - label_end = FindRenderedTextEnd(label); - const ImVec2 label_size = CalcTextSize(label, label_end, false); - - // We vertically grow up to current line height up the typical widget height. - const float frame_height = ImMax(ImMin(window->DC.CurrLineSize.y, g.FontSize + style.FramePadding.y * 2), label_size.y + padding.y * 2); - ImRect frame_bb; - frame_bb.Min.x = (flags & ImGuiTreeNodeFlags_SpanFullWidth) ? window->WorkRect.Min.x : window->DC.CursorPos.x; - frame_bb.Min.y = window->DC.CursorPos.y; - frame_bb.Max.x = window->WorkRect.Max.x; - frame_bb.Max.y = window->DC.CursorPos.y + frame_height; - if (display_frame) - { - // Framed header expand a little outside the default padding, to the edge of InnerClipRect - // (FIXME: May remove this at some point and make InnerClipRect align with WindowPadding.x instead of WindowPadding.x*0.5f) - frame_bb.Min.x -= IM_FLOOR(window->WindowPadding.x * 0.5f - 1.0f); - frame_bb.Max.x += IM_FLOOR(window->WindowPadding.x * 0.5f); - } - - const float text_offset_x = g.FontSize + (display_frame ? padding.x * 3 : padding.x * 2); // Collapser arrow width + Spacing - const float text_offset_y = ImMax(padding.y, window->DC.CurrLineTextBaseOffset); // Latch before ItemSize changes it - const float text_width = g.FontSize + (label_size.x > 0.0f ? label_size.x + padding.x * 2 : 0.0f); // Include collapser - ImVec2 text_pos(window->DC.CursorPos.x + text_offset_x, window->DC.CursorPos.y + text_offset_y); - ItemSize(ImVec2(text_width, frame_height), padding.y); - - // For regular tree nodes, we arbitrary allow to click past 2 worth of ItemSpacing - ImRect interact_bb = frame_bb; - if (!display_frame && (flags & (ImGuiTreeNodeFlags_SpanAvailWidth | ImGuiTreeNodeFlags_SpanFullWidth)) == 0) - interact_bb.Max.x = frame_bb.Min.x + text_width + style.ItemSpacing.x * 2.0f; - - // Store a flag for the current depth to tell if we will allow closing this node when navigating one of its child. - // For this purpose we essentially compare if g.NavIdIsAlive went from 0 to 1 between TreeNode() and TreePop(). - // This is currently only support 32 level deep and we are fine with (1 << Depth) overflowing into a zero. - const bool is_leaf = (flags & ImGuiTreeNodeFlags_Leaf) != 0; - bool is_open = TreeNodeBehaviorIsOpen(id, flags); - if (is_open && !g.NavIdIsAlive && (flags & ImGuiTreeNodeFlags_NavLeftJumpsBackHere) && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen)) - window->DC.TreeJumpToParentOnPopMask |= (1 << window->DC.TreeDepth); - - bool item_add = ItemAdd(interact_bb, id); - g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HasDisplayRect; - g.LastItemData.DisplayRect = frame_bb; - - if (!item_add) - { - if (is_open && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen)) - TreePushOverrideID(id); - IMGUI_TEST_ENGINE_ITEM_INFO(g.LastItemData.ID, label, g.LastItemData.StatusFlags | (is_leaf ? 0 : ImGuiItemStatusFlags_Openable) | (is_open ? ImGuiItemStatusFlags_Opened : 0)); - return is_open; - } - - ImGuiButtonFlags button_flags = ImGuiTreeNodeFlags_None; - if (flags & ImGuiTreeNodeFlags_AllowItemOverlap) - button_flags |= ImGuiButtonFlags_AllowItemOverlap; - if (!is_leaf) - button_flags |= ImGuiButtonFlags_PressedOnDragDropHold; - - // We allow clicking on the arrow section with keyboard modifiers held, in order to easily - // allow browsing a tree while preserving selection with code implementing multi-selection patterns. - // When clicking on the rest of the tree node we always disallow keyboard modifiers. - const float arrow_hit_x1 = (text_pos.x - text_offset_x) - style.TouchExtraPadding.x; - const float arrow_hit_x2 = (text_pos.x - text_offset_x) + (g.FontSize + padding.x * 2.0f) + style.TouchExtraPadding.x; - const bool is_mouse_x_over_arrow = (g.IO.MousePos.x >= arrow_hit_x1 && g.IO.MousePos.x < arrow_hit_x2); - if (window != g.HoveredWindow || !is_mouse_x_over_arrow) - button_flags |= ImGuiButtonFlags_NoKeyModifiers; - - // Open behaviors can be altered with the _OpenOnArrow and _OnOnDoubleClick flags. - // Some alteration have subtle effects (e.g. toggle on MouseUp vs MouseDown events) due to requirements for multi-selection and drag and drop support. - // - Single-click on label = Toggle on MouseUp (default, when _OpenOnArrow=0) - // - Single-click on arrow = Toggle on MouseDown (when _OpenOnArrow=0) - // - Single-click on arrow = Toggle on MouseDown (when _OpenOnArrow=1) - // - Double-click on label = Toggle on MouseDoubleClick (when _OpenOnDoubleClick=1) - // - Double-click on arrow = Toggle on MouseDoubleClick (when _OpenOnDoubleClick=1 and _OpenOnArrow=0) - // It is rather standard that arrow click react on Down rather than Up. - // We set ImGuiButtonFlags_PressedOnClickRelease on OpenOnDoubleClick because we want the item to be active on the initial MouseDown in order for drag and drop to work. - if (is_mouse_x_over_arrow) - button_flags |= ImGuiButtonFlags_PressedOnClick; - else if (flags & ImGuiTreeNodeFlags_OpenOnDoubleClick) - button_flags |= ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnDoubleClick; - else - button_flags |= ImGuiButtonFlags_PressedOnClickRelease; - - bool selected = (flags & ImGuiTreeNodeFlags_Selected) != 0; - const bool was_selected = selected; - - bool hovered, held; - bool pressed = ButtonBehavior(interact_bb, id, &hovered, &held, button_flags); - bool toggled = false; - if (!is_leaf) - { - if (pressed && g.DragDropHoldJustPressedId != id) - { - if ((flags & (ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick)) == 0 || (g.NavActivateId == id)) - toggled = true; - if (flags & ImGuiTreeNodeFlags_OpenOnArrow) - toggled |= is_mouse_x_over_arrow && !g.NavDisableMouseHover; // Lightweight equivalent of IsMouseHoveringRect() since ButtonBehavior() already did the job - if ((flags & ImGuiTreeNodeFlags_OpenOnDoubleClick) && g.IO.MouseDoubleClicked[0]) - toggled = true; - } - else if (pressed && g.DragDropHoldJustPressedId == id) - { - IM_ASSERT(button_flags & ImGuiButtonFlags_PressedOnDragDropHold); - if (!is_open) // When using Drag and Drop "hold to open" we keep the node highlighted after opening, but never close it again. - toggled = true; - } - - if (g.NavId == id && g.NavMoveDir == ImGuiDir_Left && is_open) - { - toggled = true; - NavMoveRequestCancel(); - } - if (g.NavId == id && g.NavMoveDir == ImGuiDir_Right && !is_open) // If there's something upcoming on the line we may want to give it the priority? - { - toggled = true; - NavMoveRequestCancel(); - } - - if (toggled) - { - is_open = !is_open; - window->DC.StateStorage->SetInt(id, is_open); - g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_ToggledOpen; - } - } - if (flags & ImGuiTreeNodeFlags_AllowItemOverlap) - SetItemAllowOverlap(); - - // In this branch, TreeNodeBehavior() cannot toggle the selection so this will never trigger. - if (selected != was_selected) //-V547 - g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_ToggledSelection; - - // Render - const ImU32 text_col = GetColorU32(ImGuiCol_Text); - ImGuiNavHighlightFlags nav_highlight_flags = ImGuiNavHighlightFlags_TypeThin; - if (display_frame) - { - // Framed type - const ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header); - RenderFrame(frame_bb.Min, frame_bb.Max, bg_col, true, style.FrameRounding); - RenderNavHighlight(frame_bb, id, nav_highlight_flags); - if (flags & ImGuiTreeNodeFlags_Bullet) - RenderBullet(window->DrawList, ImVec2(text_pos.x - text_offset_x * 0.60f, text_pos.y + g.FontSize * 0.5f), text_col); - else if (!is_leaf) - RenderArrow(window->DrawList, ImVec2(text_pos.x - text_offset_x + padding.x, text_pos.y), text_col, is_open ? ImGuiDir_Down : ImGuiDir_Right, 1.0f); - else // Leaf without bullet, left-adjusted text - text_pos.x -= text_offset_x; - if (flags & ImGuiTreeNodeFlags_ClipLabelForTrailingButton) - frame_bb.Max.x -= g.FontSize + style.FramePadding.x; - - if (g.LogEnabled) - LogSetNextTextDecoration("###", "###"); - RenderTextClipped(text_pos, frame_bb.Max, label, label_end, &label_size); - } - else - { - // Unframed typed for tree nodes - if (hovered || selected) - { - const ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header); - RenderFrame(frame_bb.Min, frame_bb.Max, bg_col, false); - } - RenderNavHighlight(frame_bb, id, nav_highlight_flags); - if (flags & ImGuiTreeNodeFlags_Bullet) - RenderBullet(window->DrawList, ImVec2(text_pos.x - text_offset_x * 0.5f, text_pos.y + g.FontSize * 0.5f), text_col); - else if (!is_leaf) - RenderArrow(window->DrawList, ImVec2(text_pos.x - text_offset_x + padding.x, text_pos.y + g.FontSize * 0.15f), text_col, is_open ? ImGuiDir_Down : ImGuiDir_Right, 0.70f); - if (g.LogEnabled) - LogSetNextTextDecoration(">", NULL); - RenderText(text_pos, label, label_end, false); - } - - if (is_open && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen)) - TreePushOverrideID(id); - IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | (is_leaf ? 0 : ImGuiItemStatusFlags_Openable) | (is_open ? ImGuiItemStatusFlags_Opened : 0)); - return is_open; -} - -void ImGui::TreePush(const char* str_id) -{ - ImGuiWindow* window = GetCurrentWindow(); - Indent(); - window->DC.TreeDepth++; - PushID(str_id); -} - -void ImGui::TreePush(const void* ptr_id) -{ - ImGuiWindow* window = GetCurrentWindow(); - Indent(); - window->DC.TreeDepth++; - PushID(ptr_id); -} - -void ImGui::TreePushOverrideID(ImGuiID id) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - Indent(); - window->DC.TreeDepth++; - PushOverrideID(id); -} - -void ImGui::TreePop() -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - Unindent(); - - window->DC.TreeDepth--; - ImU32 tree_depth_mask = (1 << window->DC.TreeDepth); - - // Handle Left arrow to move to parent tree node (when ImGuiTreeNodeFlags_NavLeftJumpsBackHere is enabled) - if (g.NavMoveDir == ImGuiDir_Left && g.NavWindow == window && NavMoveRequestButNoResultYet()) - if (g.NavIdIsAlive && (window->DC.TreeJumpToParentOnPopMask & tree_depth_mask)) - { - SetNavID(window->IDStack.back(), g.NavLayer, 0, ImRect()); - NavMoveRequestCancel(); - } - window->DC.TreeJumpToParentOnPopMask &= tree_depth_mask - 1; - - IM_ASSERT(window->IDStack.Size > 1); // There should always be 1 element in the IDStack (pushed during window creation). If this triggers you called TreePop/PopID too much. - PopID(); -} - -// Horizontal distance preceding label when using TreeNode() or Bullet() -float ImGui::GetTreeNodeToLabelSpacing() -{ - ImGuiContext& g = *GImGui; - return g.FontSize + (g.Style.FramePadding.x * 2.0f); -} - -// Set next TreeNode/CollapsingHeader open state. -void ImGui::SetNextItemOpen(bool is_open, ImGuiCond cond) -{ - ImGuiContext& g = *GImGui; - if (g.CurrentWindow->SkipItems) - return; - g.NextItemData.Flags |= ImGuiNextItemDataFlags_HasOpen; - g.NextItemData.OpenVal = is_open; - g.NextItemData.OpenCond = cond ? cond : ImGuiCond_Always; -} - -// CollapsingHeader returns true when opened but do not indent nor push into the ID stack (because of the ImGuiTreeNodeFlags_NoTreePushOnOpen flag). -// This is basically the same as calling TreeNodeEx(label, ImGuiTreeNodeFlags_CollapsingHeader). You can remove the _NoTreePushOnOpen flag if you want behavior closer to normal TreeNode(). -bool ImGui::CollapsingHeader(const char* label, ImGuiTreeNodeFlags flags) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - - return TreeNodeBehavior(window->GetID(label), flags | ImGuiTreeNodeFlags_CollapsingHeader, label); -} - -// p_visible == NULL : regular collapsing header -// p_visible != NULL && *p_visible == true : show a small close button on the corner of the header, clicking the button will set *p_visible = false -// p_visible != NULL && *p_visible == false : do not show the header at all -// Do not mistake this with the Open state of the header itself, which you can adjust with SetNextItemOpen() or ImGuiTreeNodeFlags_DefaultOpen. -bool ImGui::CollapsingHeader(const char* label, bool* p_visible, ImGuiTreeNodeFlags flags) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - - if (p_visible && !*p_visible) - return false; - - ImGuiID id = window->GetID(label); - flags |= ImGuiTreeNodeFlags_CollapsingHeader; - if (p_visible) - flags |= ImGuiTreeNodeFlags_AllowItemOverlap | ImGuiTreeNodeFlags_ClipLabelForTrailingButton; - bool is_open = TreeNodeBehavior(id, flags, label); - if (p_visible != NULL) - { - // Create a small overlapping close button - // FIXME: We can evolve this into user accessible helpers to add extra buttons on title bars, headers, etc. - // FIXME: CloseButton can overlap into text, need find a way to clip the text somehow. - ImGuiContext& g = *GImGui; - ImGuiLastItemData last_item_backup = g.LastItemData; - float button_size = g.FontSize; - float button_x = ImMax(g.LastItemData.Rect.Min.x, g.LastItemData.Rect.Max.x - g.Style.FramePadding.x * 2.0f - button_size); - float button_y = g.LastItemData.Rect.Min.y; - ImGuiID close_button_id = GetIDWithSeed("#CLOSE", NULL, id); - if (CloseButton(close_button_id, ImVec2(button_x, button_y))) - *p_visible = false; - g.LastItemData = last_item_backup; - } - - return is_open; -} - -//------------------------------------------------------------------------- -// [SECTION] Widgets: Selectable -//------------------------------------------------------------------------- -// - Selectable() -//------------------------------------------------------------------------- - -// Tip: pass a non-visible label (e.g. "##hello") then you can use the space to draw other text or image. -// But you need to make sure the ID is unique, e.g. enclose calls in PushID/PopID or use ##unique_id. -// With this scheme, ImGuiSelectableFlags_SpanAllColumns and ImGuiSelectableFlags_AllowItemOverlap are also frequently used flags. -// FIXME: Selectable() with (size.x == 0.0f) and (SelectableTextAlign.x > 0.0f) followed by SameLine() is currently not supported. -bool ImGui::Selectable(const char* label, bool selected, ImGuiSelectableFlags flags, const ImVec2& size_arg) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - - ImGuiContext& g = *GImGui; - const ImGuiStyle& style = g.Style; - - // Submit label or explicit size to ItemSize(), whereas ItemAdd() will submit a larger/spanning rectangle. - ImGuiID id = window->GetID(label); - ImVec2 label_size = CalcTextSize(label, NULL, true); - ImVec2 size(size_arg.x != 0.0f ? size_arg.x : label_size.x, size_arg.y != 0.0f ? size_arg.y : label_size.y); - ImVec2 pos = window->DC.CursorPos; - pos.y += window->DC.CurrLineTextBaseOffset; - ItemSize(size, 0.0f); - - // Fill horizontal space - // We don't support (size < 0.0f) in Selectable() because the ItemSpacing extension would make explicitly right-aligned sizes not visibly match other widgets. - const bool span_all_columns = (flags & ImGuiSelectableFlags_SpanAllColumns) != 0; - const float min_x = span_all_columns ? window->ParentWorkRect.Min.x : pos.x; - const float max_x = span_all_columns ? window->ParentWorkRect.Max.x : window->WorkRect.Max.x; - if (size_arg.x == 0.0f || (flags & ImGuiSelectableFlags_SpanAvailWidth)) - size.x = ImMax(label_size.x, max_x - min_x); - - // Text stays at the submission position, but bounding box may be extended on both sides - const ImVec2 text_min = pos; - const ImVec2 text_max(min_x + size.x, pos.y + size.y); - - // Selectables are meant to be tightly packed together with no click-gap, so we extend their box to cover spacing between selectable. - ImRect bb(min_x, pos.y, text_max.x, text_max.y); - if ((flags & ImGuiSelectableFlags_NoPadWithHalfSpacing) == 0) - { - const float spacing_x = span_all_columns ? 0.0f : style.ItemSpacing.x; - const float spacing_y = style.ItemSpacing.y; - const float spacing_L = IM_FLOOR(spacing_x * 0.50f); - const float spacing_U = IM_FLOOR(spacing_y * 0.50f); - bb.Min.x -= spacing_L; - bb.Min.y -= spacing_U; - bb.Max.x += (spacing_x - spacing_L); - bb.Max.y += (spacing_y - spacing_U); - } - //if (g.IO.KeyCtrl) { GetForegroundDrawList()->AddRect(bb.Min, bb.Max, IM_COL32(0, 255, 0, 255)); } - - // Modify ClipRect for the ItemAdd(), faster than doing a PushColumnsBackground/PushTableBackground for every Selectable.. - const float backup_clip_rect_min_x = window->ClipRect.Min.x; - const float backup_clip_rect_max_x = window->ClipRect.Max.x; - if (span_all_columns) - { - window->ClipRect.Min.x = window->ParentWorkRect.Min.x; - window->ClipRect.Max.x = window->ParentWorkRect.Max.x; - } - - const bool disabled_item = (flags & ImGuiSelectableFlags_Disabled) != 0; - const bool item_add = ItemAdd(bb, id, NULL, disabled_item ? ImGuiItemFlags_Disabled : ImGuiItemFlags_None); - if (span_all_columns) - { - window->ClipRect.Min.x = backup_clip_rect_min_x; - window->ClipRect.Max.x = backup_clip_rect_max_x; - } - - if (!item_add) - return false; - - const bool disabled_global = (g.CurrentItemFlags & ImGuiItemFlags_Disabled) != 0; - if (disabled_item && !disabled_global) // Only testing this as an optimization - BeginDisabled(); - - // FIXME: We can standardize the behavior of those two, we could also keep the fast path of override ClipRect + full push on render only, - // which would be advantageous since most selectable are not selected. - if (span_all_columns && window->DC.CurrentColumns) - PushColumnsBackground(); - else if (span_all_columns && g.CurrentTable) - TablePushBackgroundChannel(); - - // We use NoHoldingActiveID on menus so user can click and _hold_ on a menu then drag to browse child entries - ImGuiButtonFlags button_flags = 0; - if (flags & ImGuiSelectableFlags_NoHoldingActiveID) { button_flags |= ImGuiButtonFlags_NoHoldingActiveId; } - if (flags & ImGuiSelectableFlags_SelectOnClick) { button_flags |= ImGuiButtonFlags_PressedOnClick; } - if (flags & ImGuiSelectableFlags_SelectOnRelease) { button_flags |= ImGuiButtonFlags_PressedOnRelease; } - if (flags & ImGuiSelectableFlags_AllowDoubleClick) { button_flags |= ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnDoubleClick; } - if (flags & ImGuiSelectableFlags_AllowItemOverlap) { button_flags |= ImGuiButtonFlags_AllowItemOverlap; } - - const bool was_selected = selected; - bool hovered, held; - bool pressed = ButtonBehavior(bb, id, &hovered, &held, button_flags); - - // Auto-select when moved into - // - This will be more fully fleshed in the range-select branch - // - This is not exposed as it won't nicely work with some user side handling of shift/control - // - We cannot do 'if (g.NavJustMovedToId != id) { selected = false; pressed = was_selected; }' for two reasons - // - (1) it would require focus scope to be set, need exposing PushFocusScope() or equivalent (e.g. BeginSelection() calling PushFocusScope()) - // - (2) usage will fail with clipped items - // The multi-select API aim to fix those issues, e.g. may be replaced with a BeginSelection() API. - if ((flags & ImGuiSelectableFlags_SelectOnNav) && g.NavJustMovedToId != 0 && g.NavJustMovedToFocusScopeId == window->DC.NavFocusScopeIdCurrent) - if (g.NavJustMovedToId == id) - selected = pressed = true; - - // Update NavId when clicking or when Hovering (this doesn't happen on most widgets), so navigation can be resumed with gamepad/keyboard - if (pressed || (hovered && (flags & ImGuiSelectableFlags_SetNavIdOnHover))) - { - if (!g.NavDisableMouseHover && g.NavWindow == window && g.NavLayer == window->DC.NavLayerCurrent) - { - SetNavID(id, window->DC.NavLayerCurrent, window->DC.NavFocusScopeIdCurrent, ImRect(bb.Min - window->Pos, bb.Max - window->Pos)); // (bb == NavRect) - g.NavDisableHighlight = true; - } - } - if (pressed) - MarkItemEdited(id); - - if (flags & ImGuiSelectableFlags_AllowItemOverlap) - SetItemAllowOverlap(); - - // In this branch, Selectable() cannot toggle the selection so this will never trigger. - if (selected != was_selected) //-V547 - g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_ToggledSelection; - - // Render - if (held && (flags & ImGuiSelectableFlags_DrawHoveredWhenHeld)) - hovered = true; - if (hovered || selected) - { - const ImU32 col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header); - RenderFrame(bb.Min, bb.Max, col, false, 0.0f); - } - RenderNavHighlight(bb, id, ImGuiNavHighlightFlags_TypeThin | ImGuiNavHighlightFlags_NoRounding); - - if (span_all_columns && window->DC.CurrentColumns) - PopColumnsBackground(); - else if (span_all_columns && g.CurrentTable) - TablePopBackgroundChannel(); - - RenderTextClipped(text_min, text_max, label, NULL, &label_size, style.SelectableTextAlign, &bb); - - // Automatically close popups - if (pressed && (window->Flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiSelectableFlags_DontClosePopups) && !(g.LastItemData.InFlags & ImGuiItemFlags_SelectableDontClosePopup)) - CloseCurrentPopup(); - - if (disabled_item && !disabled_global) - EndDisabled(); - - IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags); - return pressed; //-V1020 -} - -bool ImGui::Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags, const ImVec2& size_arg) -{ - if (Selectable(label, *p_selected, flags, size_arg)) - { - *p_selected = !*p_selected; - return true; - } - return false; -} - -//------------------------------------------------------------------------- -// [SECTION] Widgets: ListBox -//------------------------------------------------------------------------- -// - BeginListBox() -// - EndListBox() -// - ListBox() -//------------------------------------------------------------------------- - -// Tip: To have a list filling the entire window width, use size.x = -FLT_MIN and pass an non-visible label e.g. "##empty" -// Tip: If your vertical size is calculated from an item count (e.g. 10 * item_height) consider adding a fractional part to facilitate seeing scrolling boundaries (e.g. 10.25 * item_height). -bool ImGui::BeginListBox(const char* label, const ImVec2& size_arg) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - - const ImGuiStyle& style = g.Style; - const ImGuiID id = GetID(label); - const ImVec2 label_size = CalcTextSize(label, NULL, true); - - // Size default to hold ~7.25 items. - // Fractional number of items helps seeing that we can scroll down/up without looking at scrollbar. - ImVec2 size = ImFloor(CalcItemSize(size_arg, CalcItemWidth(), GetTextLineHeightWithSpacing() * 7.25f + style.FramePadding.y * 2.0f)); - ImVec2 frame_size = ImVec2(size.x, ImMax(size.y, label_size.y)); - ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + frame_size); - ImRect bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f)); - g.NextItemData.ClearFlags(); - - if (!IsRectVisible(bb.Min, bb.Max)) - { - ItemSize(bb.GetSize(), style.FramePadding.y); - ItemAdd(bb, 0, &frame_bb); - return false; - } - - // FIXME-OPT: We could omit the BeginGroup() if label_size.x but would need to omit the EndGroup() as well. - BeginGroup(); - if (label_size.x > 0.0f) - { - ImVec2 label_pos = ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y); - RenderText(label_pos, label); - window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, label_pos + label_size); - } - - BeginChildFrame(id, frame_bb.GetSize()); - return true; -} - -#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS -// OBSOLETED in 1.81 (from February 2021) -bool ImGui::ListBoxHeader(const char* label, int items_count, int height_in_items) -{ - // If height_in_items == -1, default height is maximum 7. - ImGuiContext& g = *GImGui; - float height_in_items_f = (height_in_items < 0 ? ImMin(items_count, 7) : height_in_items) + 0.25f; - ImVec2 size; - size.x = 0.0f; - size.y = GetTextLineHeightWithSpacing() * height_in_items_f + g.Style.FramePadding.y * 2.0f; - return BeginListBox(label, size); -} -#endif - -void ImGui::EndListBox() -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - IM_ASSERT((window->Flags & ImGuiWindowFlags_ChildWindow) && "Mismatched BeginListBox/EndListBox calls. Did you test the return value of BeginListBox?"); - IM_UNUSED(window); - - EndChildFrame(); - EndGroup(); // This is only required to be able to do IsItemXXX query on the whole ListBox including label -} - -bool ImGui::ListBox(const char* label, int* current_item, const char* const items[], int items_count, int height_items) -{ - const bool value_changed = ListBox(label, current_item, Items_ArrayGetter, (void*)items, items_count, height_items); - return value_changed; -} - -// This is merely a helper around BeginListBox(), EndListBox(). -// Considering using those directly to submit custom data or store selection differently. -bool ImGui::ListBox(const char* label, int* current_item, bool (*items_getter)(void*, int, const char**), void* data, int items_count, int height_in_items) -{ - ImGuiContext& g = *GImGui; - - // Calculate size from "height_in_items" - if (height_in_items < 0) - height_in_items = ImMin(items_count, 7); - float height_in_items_f = height_in_items + 0.25f; - ImVec2 size(0.0f, ImFloor(GetTextLineHeightWithSpacing() * height_in_items_f + g.Style.FramePadding.y * 2.0f)); - - if (!BeginListBox(label, size)) - return false; - - // Assume all items have even height (= 1 line of text). If you need items of different height, - // you can create a custom version of ListBox() in your code without using the clipper. - bool value_changed = false; - ImGuiListClipper clipper; - clipper.Begin(items_count, GetTextLineHeightWithSpacing()); // We know exactly our line height here so we pass it as a minor optimization, but generally you don't need to. - while (clipper.Step()) - for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) - { - const char* item_text; - if (!items_getter(data, i, &item_text)) - item_text = "*Unknown item*"; - - PushID(i); - const bool item_selected = (i == *current_item); - if (Selectable(item_text, item_selected)) - { - *current_item = i; - value_changed = true; - } - if (item_selected) - SetItemDefaultFocus(); - PopID(); - } - EndListBox(); - - if (value_changed) - MarkItemEdited(g.LastItemData.ID); - - return value_changed; -} - -//------------------------------------------------------------------------- -// [SECTION] Widgets: PlotLines, PlotHistogram -//------------------------------------------------------------------------- -// - PlotEx() [Internal] -// - PlotLines() -// - PlotHistogram() -//------------------------------------------------------------------------- -// Plot/Graph widgets are not very good. -// Consider writing your own, or using a third-party one, see: -// - ImPlot https://github.com/epezent/implot -// - others https://github.com/ocornut/imgui/wiki/Useful-Extensions -//------------------------------------------------------------------------- - -int ImGui::PlotEx(ImGuiPlotType plot_type, const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 frame_size) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return -1; - - const ImGuiStyle& style = g.Style; - const ImGuiID id = window->GetID(label); - - const ImVec2 label_size = CalcTextSize(label, NULL, true); - if (frame_size.x == 0.0f) - frame_size.x = CalcItemWidth(); - if (frame_size.y == 0.0f) - frame_size.y = label_size.y + (style.FramePadding.y * 2); - - const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + frame_size); - const ImRect inner_bb(frame_bb.Min + style.FramePadding, frame_bb.Max - style.FramePadding); - const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0)); - ItemSize(total_bb, style.FramePadding.y); - if (!ItemAdd(total_bb, 0, &frame_bb)) - return -1; - const bool hovered = ItemHoverable(frame_bb, id); - - // Determine scale from values if not specified - if (scale_min == FLT_MAX || scale_max == FLT_MAX) - { - float v_min = FLT_MAX; - float v_max = -FLT_MAX; - for (int i = 0; i < values_count; i++) - { - const float v = values_getter(data, i); - if (v != v) // Ignore NaN values - continue; - v_min = ImMin(v_min, v); - v_max = ImMax(v_max, v); - } - if (scale_min == FLT_MAX) - scale_min = v_min; - if (scale_max == FLT_MAX) - scale_max = v_max; - } - - RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding); - - const int values_count_min = (plot_type == ImGuiPlotType_Lines) ? 2 : 1; - int idx_hovered = -1; - if (values_count >= values_count_min) - { - int res_w = ImMin((int)frame_size.x, values_count) + ((plot_type == ImGuiPlotType_Lines) ? -1 : 0); - int item_count = values_count + ((plot_type == ImGuiPlotType_Lines) ? -1 : 0); - - // Tooltip on hover - if (hovered && inner_bb.Contains(g.IO.MousePos)) - { - const float t = ImClamp((g.IO.MousePos.x - inner_bb.Min.x) / (inner_bb.Max.x - inner_bb.Min.x), 0.0f, 0.9999f); - const int v_idx = (int)(t * item_count); - IM_ASSERT(v_idx >= 0 && v_idx < values_count); - - const float v0 = values_getter(data, (v_idx + values_offset) % values_count); - const float v1 = values_getter(data, (v_idx + 1 + values_offset) % values_count); - if (plot_type == ImGuiPlotType_Lines) - SetTooltip("%d: %8.4g\n%d: %8.4g", v_idx, v0, v_idx + 1, v1); - else if (plot_type == ImGuiPlotType_Histogram) - SetTooltip("%d: %8.4g", v_idx, v0); - idx_hovered = v_idx; - } - - const float t_step = 1.0f / (float)res_w; - const float inv_scale = (scale_min == scale_max) ? 0.0f : (1.0f / (scale_max - scale_min)); - - float v0 = values_getter(data, (0 + values_offset) % values_count); - float t0 = 0.0f; - ImVec2 tp0 = ImVec2( t0, 1.0f - ImSaturate((v0 - scale_min) * inv_scale) ); // Point in the normalized space of our target rectangle - float histogram_zero_line_t = (scale_min * scale_max < 0.0f) ? (1 + scale_min * inv_scale) : (scale_min < 0.0f ? 0.0f : 1.0f); // Where does the zero line stands - - const ImU32 col_base = GetColorU32((plot_type == ImGuiPlotType_Lines) ? ImGuiCol_PlotLines : ImGuiCol_PlotHistogram); - const ImU32 col_hovered = GetColorU32((plot_type == ImGuiPlotType_Lines) ? ImGuiCol_PlotLinesHovered : ImGuiCol_PlotHistogramHovered); - - for (int n = 0; n < res_w; n++) - { - const float t1 = t0 + t_step; - const int v1_idx = (int)(t0 * item_count + 0.5f); - IM_ASSERT(v1_idx >= 0 && v1_idx < values_count); - const float v1 = values_getter(data, (v1_idx + values_offset + 1) % values_count); - const ImVec2 tp1 = ImVec2( t1, 1.0f - ImSaturate((v1 - scale_min) * inv_scale) ); - - // NB: Draw calls are merged together by the DrawList system. Still, we should render our batch are lower level to save a bit of CPU. - ImVec2 pos0 = ImLerp(inner_bb.Min, inner_bb.Max, tp0); - ImVec2 pos1 = ImLerp(inner_bb.Min, inner_bb.Max, (plot_type == ImGuiPlotType_Lines) ? tp1 : ImVec2(tp1.x, histogram_zero_line_t)); - if (plot_type == ImGuiPlotType_Lines) - { - window->DrawList->AddLine(pos0, pos1, idx_hovered == v1_idx ? col_hovered : col_base); - } - else if (plot_type == ImGuiPlotType_Histogram) - { - if (pos1.x >= pos0.x + 2.0f) - pos1.x -= 1.0f; - window->DrawList->AddRectFilled(pos0, pos1, idx_hovered == v1_idx ? col_hovered : col_base); - } - - t0 = t1; - tp0 = tp1; - } - } - - // Text overlay - if (overlay_text) - RenderTextClipped(ImVec2(frame_bb.Min.x, frame_bb.Min.y + style.FramePadding.y), frame_bb.Max, overlay_text, NULL, NULL, ImVec2(0.5f, 0.0f)); - - if (label_size.x > 0.0f) - RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, inner_bb.Min.y), label); - - // Return hovered index or -1 if none are hovered. - // This is currently not exposed in the public API because we need a larger redesign of the whole thing, but in the short-term we are making it available in PlotEx(). - return idx_hovered; -} - -struct ImGuiPlotArrayGetterData -{ - const float* Values; - int Stride; - - ImGuiPlotArrayGetterData(const float* values, int stride) { Values = values; Stride = stride; } -}; - -static float Plot_ArrayGetter(void* data, int idx) -{ - ImGuiPlotArrayGetterData* plot_data = (ImGuiPlotArrayGetterData*)data; - const float v = *(const float*)(const void*)((const unsigned char*)plot_data->Values + (size_t)idx * plot_data->Stride); - return v; -} - -void ImGui::PlotLines(const char* label, const float* values, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size, int stride) -{ - ImGuiPlotArrayGetterData data(values, stride); - PlotEx(ImGuiPlotType_Lines, label, &Plot_ArrayGetter, (void*)&data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size); -} - -void ImGui::PlotLines(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size) -{ - PlotEx(ImGuiPlotType_Lines, label, values_getter, data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size); -} - -void ImGui::PlotHistogram(const char* label, const float* values, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size, int stride) -{ - ImGuiPlotArrayGetterData data(values, stride); - PlotEx(ImGuiPlotType_Histogram, label, &Plot_ArrayGetter, (void*)&data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size); -} - -void ImGui::PlotHistogram(const char* label, float (*values_getter)(void* data, int idx), void* data, int values_count, int values_offset, const char* overlay_text, float scale_min, float scale_max, ImVec2 graph_size) -{ - PlotEx(ImGuiPlotType_Histogram, label, values_getter, data, values_count, values_offset, overlay_text, scale_min, scale_max, graph_size); -} - -//------------------------------------------------------------------------- -// [SECTION] Widgets: Value helpers -// Those is not very useful, legacy API. -//------------------------------------------------------------------------- -// - Value() -//------------------------------------------------------------------------- - -void ImGui::Value(const char* prefix, bool b) -{ - Text("%s: %s", prefix, (b ? "true" : "false")); -} - -void ImGui::Value(const char* prefix, int v) -{ - Text("%s: %d", prefix, v); -} - -void ImGui::Value(const char* prefix, unsigned int v) -{ - Text("%s: %d", prefix, v); -} - -void ImGui::Value(const char* prefix, float v, const char* float_format) -{ - if (float_format) - { - char fmt[64]; - ImFormatString(fmt, IM_ARRAYSIZE(fmt), "%%s: %s", float_format); - Text(fmt, prefix, v); - } - else - { - Text("%s: %.3f", prefix, v); - } -} - -//------------------------------------------------------------------------- -// [SECTION] MenuItem, BeginMenu, EndMenu, etc. -//------------------------------------------------------------------------- -// - ImGuiMenuColumns [Internal] -// - BeginMenuBar() -// - EndMenuBar() -// - BeginMainMenuBar() -// - EndMainMenuBar() -// - BeginMenu() -// - EndMenu() -// - MenuItemEx() [Internal] -// - MenuItem() -//------------------------------------------------------------------------- - -// Helpers for internal use -void ImGuiMenuColumns::Update(float spacing, bool window_reappearing) -{ - if (window_reappearing) - memset(Widths, 0, sizeof(Widths)); - Spacing = (ImU16)spacing; - CalcNextTotalWidth(true); - memset(Widths, 0, sizeof(Widths)); - TotalWidth = NextTotalWidth; - NextTotalWidth = 0; -} - -void ImGuiMenuColumns::CalcNextTotalWidth(bool update_offsets) -{ - ImU16 offset = 0; - bool want_spacing = false; - for (int i = 0; i < IM_ARRAYSIZE(Widths); i++) - { - ImU16 width = Widths[i]; - if (want_spacing && width > 0) - offset += Spacing; - want_spacing |= (width > 0); - if (update_offsets) - { - if (i == 1) { OffsetLabel = offset; } - if (i == 2) { OffsetShortcut = offset; } - if (i == 3) { OffsetMark = offset; } - } - offset += width; - } - NextTotalWidth = offset; -} - -float ImGuiMenuColumns::DeclColumns(float w_icon, float w_label, float w_shortcut, float w_mark) -{ - Widths[0] = ImMax(Widths[0], (ImU16)w_icon); - Widths[1] = ImMax(Widths[1], (ImU16)w_label); - Widths[2] = ImMax(Widths[2], (ImU16)w_shortcut); - Widths[3] = ImMax(Widths[3], (ImU16)w_mark); - CalcNextTotalWidth(false); - return (float)ImMax(TotalWidth, NextTotalWidth); -} - -// FIXME: Provided a rectangle perhaps e.g. a BeginMenuBarEx() could be used anywhere.. -// Currently the main responsibility of this function being to setup clip-rect + horizontal layout + menu navigation layer. -// Ideally we also want this to be responsible for claiming space out of the main window scrolling rectangle, in which case ImGuiWindowFlags_MenuBar will become unnecessary. -// Then later the same system could be used for multiple menu-bars, scrollbars, side-bars. -bool ImGui::BeginMenuBar() -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - if (!(window->Flags & ImGuiWindowFlags_MenuBar)) - return false; - - IM_ASSERT(!window->DC.MenuBarAppending); - BeginGroup(); // Backup position on layer 0 // FIXME: Misleading to use a group for that backup/restore - PushID("##menubar"); - - // We don't clip with current window clipping rectangle as it is already set to the area below. However we clip with window full rect. - // We remove 1 worth of rounding to Max.x to that text in long menus and small windows don't tend to display over the lower-right rounded area, which looks particularly glitchy. - ImRect bar_rect = window->MenuBarRect(); - ImRect clip_rect(IM_ROUND(bar_rect.Min.x + window->WindowBorderSize), IM_ROUND(bar_rect.Min.y + window->WindowBorderSize), IM_ROUND(ImMax(bar_rect.Min.x, bar_rect.Max.x - ImMax(window->WindowRounding, window->WindowBorderSize))), IM_ROUND(bar_rect.Max.y)); - clip_rect.ClipWith(window->OuterRectClipped); - PushClipRect(clip_rect.Min, clip_rect.Max, false); - - // We overwrite CursorMaxPos because BeginGroup sets it to CursorPos (essentially the .EmitItem hack in EndMenuBar() would need something analogous here, maybe a BeginGroupEx() with flags). - window->DC.CursorPos = window->DC.CursorMaxPos = ImVec2(bar_rect.Min.x + window->DC.MenuBarOffset.x, bar_rect.Min.y + window->DC.MenuBarOffset.y); - window->DC.LayoutType = ImGuiLayoutType_Horizontal; - window->DC.NavLayerCurrent = ImGuiNavLayer_Menu; - window->DC.MenuBarAppending = true; - AlignTextToFramePadding(); - return true; -} - -void ImGui::EndMenuBar() -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return; - ImGuiContext& g = *GImGui; - - // Nav: When a move request within one of our child menu failed, capture the request to navigate among our siblings. - if (NavMoveRequestButNoResultYet() && (g.NavMoveDir == ImGuiDir_Left || g.NavMoveDir == ImGuiDir_Right) && (g.NavWindow->Flags & ImGuiWindowFlags_ChildMenu)) - { - // Try to find out if the request is for one of our child menu - ImGuiWindow* nav_earliest_child = g.NavWindow; - while (nav_earliest_child->ParentWindow && (nav_earliest_child->ParentWindow->Flags & ImGuiWindowFlags_ChildMenu)) - nav_earliest_child = nav_earliest_child->ParentWindow; - if (nav_earliest_child->ParentWindow == window && nav_earliest_child->DC.ParentLayoutType == ImGuiLayoutType_Horizontal && (g.NavMoveFlags & ImGuiNavMoveFlags_Forwarded) == 0) - { - // To do so we claim focus back, restore NavId and then process the movement request for yet another frame. - // This involve a one-frame delay which isn't very problematic in this situation. We could remove it by scoring in advance for multiple window (probably not worth bothering) - const ImGuiNavLayer layer = ImGuiNavLayer_Menu; - IM_ASSERT(window->DC.NavLayersActiveMaskNext & (1 << layer)); // Sanity check - FocusWindow(window); - SetNavID(window->NavLastIds[layer], layer, 0, window->NavRectRel[layer]); - g.NavDisableHighlight = true; // Hide highlight for the current frame so we don't see the intermediary selection. - g.NavDisableMouseHover = g.NavMousePosDirty = true; - NavMoveRequestForward(g.NavMoveDir, g.NavMoveClipDir, g.NavMoveFlags, g.NavMoveScrollFlags); // Repeat - } - } - - IM_MSVC_WARNING_SUPPRESS(6011); // Static Analysis false positive "warning C6011: Dereferencing NULL pointer 'window'" - IM_ASSERT(window->Flags & ImGuiWindowFlags_MenuBar); - IM_ASSERT(window->DC.MenuBarAppending); - PopClipRect(); - PopID(); - window->DC.MenuBarOffset.x = window->DC.CursorPos.x - window->Pos.x; // Save horizontal position so next append can reuse it. This is kinda equivalent to a per-layer CursorPos. - g.GroupStack.back().EmitItem = false; - EndGroup(); // Restore position on layer 0 - window->DC.LayoutType = ImGuiLayoutType_Vertical; - window->DC.NavLayerCurrent = ImGuiNavLayer_Main; - window->DC.MenuBarAppending = false; -} - -// Important: calling order matters! -// FIXME: Somehow overlapping with docking tech. -// FIXME: The "rect-cut" aspect of this could be formalized into a lower-level helper (rect-cut: https://halt.software/dead-simple-layouts) -bool ImGui::BeginViewportSideBar(const char* name, ImGuiViewport* viewport_p, ImGuiDir dir, float axis_size, ImGuiWindowFlags window_flags) -{ - IM_ASSERT(dir != ImGuiDir_None); - - ImGuiWindow* bar_window = FindWindowByName(name); - if (bar_window == NULL || bar_window->BeginCount == 0) - { - // Calculate and set window size/position - ImGuiViewportP* viewport = (ImGuiViewportP*)(void*)(viewport_p ? viewport_p : GetMainViewport()); - ImRect avail_rect = viewport->GetBuildWorkRect(); - ImGuiAxis axis = (dir == ImGuiDir_Up || dir == ImGuiDir_Down) ? ImGuiAxis_Y : ImGuiAxis_X; - ImVec2 pos = avail_rect.Min; - if (dir == ImGuiDir_Right || dir == ImGuiDir_Down) - pos[axis] = avail_rect.Max[axis] - axis_size; - ImVec2 size = avail_rect.GetSize(); - size[axis] = axis_size; - SetNextWindowPos(pos); - SetNextWindowSize(size); - - // Report our size into work area (for next frame) using actual window size - if (dir == ImGuiDir_Up || dir == ImGuiDir_Left) - viewport->BuildWorkOffsetMin[axis] += axis_size; - else if (dir == ImGuiDir_Down || dir == ImGuiDir_Right) - viewport->BuildWorkOffsetMax[axis] -= axis_size; - } - - window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove; - PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f); - PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(0, 0)); // Lift normal size constraint - bool is_open = Begin(name, NULL, window_flags); - PopStyleVar(2); - - return is_open; -} - -bool ImGui::BeginMainMenuBar() -{ - ImGuiContext& g = *GImGui; - ImGuiViewportP* viewport = (ImGuiViewportP*)(void*)GetMainViewport(); - - // For the main menu bar, which cannot be moved, we honor g.Style.DisplaySafeAreaPadding to ensure text can be visible on a TV set. - // FIXME: This could be generalized as an opt-in way to clamp window->DC.CursorStartPos to avoid SafeArea? - // FIXME: Consider removing support for safe area down the line... it's messy. Nowadays consoles have support for TV calibration in OS settings. - g.NextWindowData.MenuBarOffsetMinVal = ImVec2(g.Style.DisplaySafeAreaPadding.x, ImMax(g.Style.DisplaySafeAreaPadding.y - g.Style.FramePadding.y, 0.0f)); - ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_MenuBar; - float height = GetFrameHeight(); - bool is_open = BeginViewportSideBar("##MainMenuBar", viewport, ImGuiDir_Up, height, window_flags); - g.NextWindowData.MenuBarOffsetMinVal = ImVec2(0.0f, 0.0f); - - if (is_open) - BeginMenuBar(); - else - End(); - return is_open; -} - -void ImGui::EndMainMenuBar() -{ - EndMenuBar(); - - // When the user has left the menu layer (typically: closed menus through activation of an item), we restore focus to the previous window - // FIXME: With this strategy we won't be able to restore a NULL focus. - ImGuiContext& g = *GImGui; - if (g.CurrentWindow == g.NavWindow && g.NavLayer == ImGuiNavLayer_Main && !g.NavAnyRequest) - FocusTopMostWindowUnderOne(g.NavWindow, NULL); - - End(); -} - -bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - - ImGuiContext& g = *GImGui; - const ImGuiStyle& style = g.Style; - const ImGuiID id = window->GetID(label); - bool menu_is_open = IsPopupOpen(id, ImGuiPopupFlags_None); - - // Sub-menus are ChildWindow so that mouse can be hovering across them (otherwise top-most popup menu would steal focus and not allow hovering on parent menu) - ImGuiWindowFlags flags = ImGuiWindowFlags_ChildMenu | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoNavFocus; - if (window->Flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_ChildMenu)) - flags |= ImGuiWindowFlags_ChildWindow; - - // If a menu with same the ID was already submitted, we will append to it, matching the behavior of Begin(). - // We are relying on a O(N) search - so O(N log N) over the frame - which seems like the most efficient for the expected small amount of BeginMenu() calls per frame. - // If somehow this is ever becoming a problem we can switch to use e.g. ImGuiStorage mapping key to last frame used. - if (g.MenusIdSubmittedThisFrame.contains(id)) - { - if (menu_is_open) - menu_is_open = BeginPopupEx(id, flags); // menu_is_open can be 'false' when the popup is completely clipped (e.g. zero size display) - else - g.NextWindowData.ClearFlags(); // we behave like Begin() and need to consume those values - return menu_is_open; - } - - // Tag menu as used. Next time BeginMenu() with same ID is called it will append to existing menu - g.MenusIdSubmittedThisFrame.push_back(id); - - ImVec2 label_size = CalcTextSize(label, NULL, true); - bool pressed; - bool menuset_is_open = !(window->Flags & ImGuiWindowFlags_Popup) && (g.OpenPopupStack.Size > g.BeginPopupStack.Size && g.OpenPopupStack[g.BeginPopupStack.Size].OpenParentId == window->IDStack.back()); - ImGuiWindow* backed_nav_window = g.NavWindow; - if (menuset_is_open) - g.NavWindow = window; // Odd hack to allow hovering across menus of a same menu-set (otherwise we wouldn't be able to hover parent) - - // The reference position stored in popup_pos will be used by Begin() to find a suitable position for the child menu, - // However the final position is going to be different! It is chosen by FindBestWindowPosForPopup(). - // e.g. Menus tend to overlap each other horizontally to amplify relative Z-ordering. - ImVec2 popup_pos, pos = window->DC.CursorPos; - PushID(label); - if (!enabled) - BeginDisabled(); - const ImGuiMenuColumns* offsets = &window->DC.MenuColumns; - if (window->DC.LayoutType == ImGuiLayoutType_Horizontal) - { - // Menu inside an horizontal menu bar - // Selectable extend their highlight by half ItemSpacing in each direction. - // For ChildMenu, the popup position will be overwritten by the call to FindBestWindowPosForPopup() in Begin() - popup_pos = ImVec2(pos.x - 1.0f - IM_FLOOR(style.ItemSpacing.x * 0.5f), pos.y - style.FramePadding.y + window->MenuBarHeight()); - window->DC.CursorPos.x += IM_FLOOR(style.ItemSpacing.x * 0.5f); - PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(style.ItemSpacing.x * 2.0f, style.ItemSpacing.y)); - float w = label_size.x; - ImVec2 text_pos(window->DC.CursorPos.x + offsets->OffsetLabel, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset); - pressed = Selectable("", menu_is_open, ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_SelectOnClick | ImGuiSelectableFlags_DontClosePopups, ImVec2(w, 0.0f)); - RenderText(text_pos, label); - PopStyleVar(); - window->DC.CursorPos.x += IM_FLOOR(style.ItemSpacing.x * (-1.0f + 0.5f)); // -1 spacing to compensate the spacing added when Selectable() did a SameLine(). It would also work to call SameLine() ourselves after the PopStyleVar(). - } - else - { - // Menu inside a regular/vertical menu - // (In a typical menu window where all items are BeginMenu() or MenuItem() calls, extra_w will always be 0.0f. - // Only when they are other items sticking out we're going to add spacing, yet only register minimum width into the layout system. - popup_pos = ImVec2(pos.x, pos.y - style.WindowPadding.y); - float icon_w = (icon && icon[0]) ? CalcTextSize(icon, NULL).x : 0.0f; - float checkmark_w = IM_FLOOR(g.FontSize * 1.20f); - float min_w = window->DC.MenuColumns.DeclColumns(icon_w, label_size.x, 0.0f, checkmark_w); // Feedback to next frame - float extra_w = ImMax(0.0f, GetContentRegionAvail().x - min_w); - ImVec2 text_pos(window->DC.CursorPos.x + offsets->OffsetLabel, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset); - pressed = Selectable("", menu_is_open, ImGuiSelectableFlags_NoHoldingActiveID | ImGuiSelectableFlags_SelectOnClick | ImGuiSelectableFlags_DontClosePopups | ImGuiSelectableFlags_SpanAvailWidth, ImVec2(min_w, 0.0f)); - RenderText(text_pos, label); - if (icon_w > 0.0f) - RenderText(pos + ImVec2(offsets->OffsetIcon, 0.0f), icon); - RenderArrow(window->DrawList, pos + ImVec2(offsets->OffsetMark + extra_w + g.FontSize * 0.30f, 0.0f), GetColorU32(ImGuiCol_Text), ImGuiDir_Right); - } - if (!enabled) - EndDisabled(); - - const bool hovered = (g.HoveredId == id) && enabled; - if (menuset_is_open) - g.NavWindow = backed_nav_window; - - bool want_open = false; - bool want_close = false; - if (window->DC.LayoutType == ImGuiLayoutType_Vertical) // (window->Flags & (ImGuiWindowFlags_Popup|ImGuiWindowFlags_ChildMenu)) - { - // Close menu when not hovering it anymore unless we are moving roughly in the direction of the menu - // Implement http://bjk5.com/post/44698559168/breaking-down-amazons-mega-dropdown to avoid using timers, so menus feels more reactive. - bool moving_toward_other_child_menu = false; - ImGuiWindow* child_menu_window = (g.BeginPopupStack.Size < g.OpenPopupStack.Size && g.OpenPopupStack[g.BeginPopupStack.Size].SourceWindow == window) ? g.OpenPopupStack[g.BeginPopupStack.Size].Window : NULL; - if (g.HoveredWindow == window && child_menu_window != NULL && !(window->Flags & ImGuiWindowFlags_MenuBar)) - { - float ref_unit = g.FontSize; // FIXME-DPI - ImRect next_window_rect = child_menu_window->Rect(); - ImVec2 ta = (g.IO.MousePos - g.IO.MouseDelta); - ImVec2 tb = (window->Pos.x < child_menu_window->Pos.x) ? next_window_rect.GetTL() : next_window_rect.GetTR(); - ImVec2 tc = (window->Pos.x < child_menu_window->Pos.x) ? next_window_rect.GetBL() : next_window_rect.GetBR(); - float extra = ImClamp(ImFabs(ta.x - tb.x) * 0.30f, ref_unit * 0.5f, ref_unit * 2.5f); // add a bit of extra slack. - ta.x += (window->Pos.x < child_menu_window->Pos.x) ? -0.5f : +0.5f; // to avoid numerical issues (FIXME: ??) - tb.y = ta.y + ImMax((tb.y - extra) - ta.y, -ref_unit * 8.0f); // triangle is maximum 200 high to limit the slope and the bias toward large sub-menus // FIXME: Multiply by fb_scale? - tc.y = ta.y + ImMin((tc.y + extra) - ta.y, +ref_unit * 8.0f); - moving_toward_other_child_menu = ImTriangleContainsPoint(ta, tb, tc, g.IO.MousePos); - //GetForegroundDrawList()->AddTriangleFilled(ta, tb, tc, moving_toward_other_child_menu ? IM_COL32(0,128,0,128) : IM_COL32(128,0,0,128)); // [DEBUG] - } - if (menu_is_open && !hovered && g.HoveredWindow == window && g.HoveredIdPreviousFrame != 0 && g.HoveredIdPreviousFrame != id && !moving_toward_other_child_menu) - want_close = true; - - // Open - if (!menu_is_open && pressed) // Click/activate to open - want_open = true; - else if (!menu_is_open && hovered && !moving_toward_other_child_menu) // Hover to open - want_open = true; - if (g.NavId == id && g.NavMoveDir == ImGuiDir_Right) // Nav-Right to open - { - want_open = true; - NavMoveRequestCancel(); - } - } - else - { - // Menu bar - if (menu_is_open && pressed && menuset_is_open) // Click an open menu again to close it - { - want_close = true; - want_open = menu_is_open = false; - } - else if (pressed || (hovered && menuset_is_open && !menu_is_open)) // First click to open, then hover to open others - { - want_open = true; - } - else if (g.NavId == id && g.NavMoveDir == ImGuiDir_Down) // Nav-Down to open - { - want_open = true; - NavMoveRequestCancel(); - } - } - - if (!enabled) // explicitly close if an open menu becomes disabled, facilitate users code a lot in pattern such as 'if (BeginMenu("options", has_object)) { ..use object.. }' - want_close = true; - if (want_close && IsPopupOpen(id, ImGuiPopupFlags_None)) - ClosePopupToLevel(g.BeginPopupStack.Size, true); - - IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Openable | (menu_is_open ? ImGuiItemStatusFlags_Opened : 0)); - PopID(); - - if (!menu_is_open && want_open && g.OpenPopupStack.Size > g.BeginPopupStack.Size) - { - // Don't recycle same menu level in the same frame, first close the other menu and yield for a frame. - OpenPopup(label); - return false; - } - - menu_is_open |= want_open; - if (want_open) - OpenPopup(label); - - if (menu_is_open) - { - SetNextWindowPos(popup_pos, ImGuiCond_Always); // Note: this is super misleading! The value will serve as reference for FindBestWindowPosForPopup(), not actual pos. - menu_is_open = BeginPopupEx(id, flags); // menu_is_open can be 'false' when the popup is completely clipped (e.g. zero size display) - } - else - { - g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values - } - - return menu_is_open; -} - -bool ImGui::BeginMenu(const char* label, bool enabled) -{ - return BeginMenuEx(label, NULL, enabled); -} - -void ImGui::EndMenu() -{ - // Nav: When a left move request _within our child menu_ failed, close ourselves (the _parent_ menu). - // A menu doesn't close itself because EndMenuBar() wants the catch the last Left<>Right inputs. - // However, it means that with the current code, a BeginMenu() from outside another menu or a menu-bar won't be closable with the Left direction. - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - if (g.NavMoveDir == ImGuiDir_Left && NavMoveRequestButNoResultYet() && window->DC.LayoutType == ImGuiLayoutType_Vertical) - if (g.NavWindow && (g.NavWindow->RootWindowForNav->Flags & ImGuiWindowFlags_Popup) && g.NavWindow->RootWindowForNav->ParentWindow == window) - { - ClosePopupToLevel(g.BeginPopupStack.Size, true); - NavMoveRequestCancel(); - } - - EndPopup(); -} - -bool ImGui::MenuItemEx(const char* label, const char* icon, const char* shortcut, bool selected, bool enabled) -{ - ImGuiWindow* window = GetCurrentWindow(); - if (window->SkipItems) - return false; - - ImGuiContext& g = *GImGui; - ImGuiStyle& style = g.Style; - ImVec2 pos = window->DC.CursorPos; - ImVec2 label_size = CalcTextSize(label, NULL, true); - - // We've been using the equivalent of ImGuiSelectableFlags_SetNavIdOnHover on all Selectable() since early Nav system days (commit 43ee5d73), - // but I am unsure whether this should be kept at all. For now moved it to be an opt-in feature used by menus only. - bool pressed; - PushID(label); - if (!enabled) - BeginDisabled(); - const ImGuiSelectableFlags flags = ImGuiSelectableFlags_SelectOnRelease | ImGuiSelectableFlags_SetNavIdOnHover; - const ImGuiMenuColumns* offsets = &window->DC.MenuColumns; - if (window->DC.LayoutType == ImGuiLayoutType_Horizontal) - { - // Mimic the exact layout spacing of BeginMenu() to allow MenuItem() inside a menu bar, which is a little misleading but may be useful - // Note that in this situation: we don't render the shortcut, we render a highlight instead of the selected tick mark. - float w = label_size.x; - window->DC.CursorPos.x += IM_FLOOR(style.ItemSpacing.x * 0.5f); - ImVec2 text_pos(window->DC.CursorPos.x + offsets->OffsetLabel, window->DC.CursorPos.y + window->DC.CurrLineTextBaseOffset); - PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(style.ItemSpacing.x * 2.0f, style.ItemSpacing.y)); - pressed = Selectable("", selected, flags, ImVec2(w, 0.0f)); - PopStyleVar(); - RenderText(text_pos, label); - window->DC.CursorPos.x += IM_FLOOR(style.ItemSpacing.x * (-1.0f + 0.5f)); // -1 spacing to compensate the spacing added when Selectable() did a SameLine(). It would also work to call SameLine() ourselves after the PopStyleVar(). - } - else - { - // Menu item inside a vertical menu - // (In a typical menu window where all items are BeginMenu() or MenuItem() calls, extra_w will always be 0.0f. - // Only when they are other items sticking out we're going to add spacing, yet only register minimum width into the layout system. - float icon_w = (icon && icon[0]) ? CalcTextSize(icon, NULL).x : 0.0f; - float shortcut_w = (shortcut && shortcut[0]) ? CalcTextSize(shortcut, NULL).x : 0.0f; - float checkmark_w = IM_FLOOR(g.FontSize * 1.20f); - float min_w = window->DC.MenuColumns.DeclColumns(icon_w, label_size.x, shortcut_w, checkmark_w); // Feedback for next frame - float stretch_w = ImMax(0.0f, GetContentRegionAvail().x - min_w); - pressed = Selectable("", false, flags | ImGuiSelectableFlags_SpanAvailWidth, ImVec2(min_w, 0.0f)); - RenderText(pos + ImVec2(offsets->OffsetLabel, 0.0f), label); - if (icon_w > 0.0f) - RenderText(pos + ImVec2(offsets->OffsetIcon, 0.0f), icon); - if (shortcut_w > 0.0f) - { - PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_TextDisabled]); - RenderText(pos + ImVec2(offsets->OffsetShortcut + stretch_w, 0.0f), shortcut, NULL, false); - PopStyleColor(); - } - if (selected) - RenderCheckMark(window->DrawList, pos + ImVec2(offsets->OffsetMark + stretch_w + g.FontSize * 0.40f, g.FontSize * 0.134f * 0.5f), GetColorU32(ImGuiCol_Text), g.FontSize * 0.866f); - } - IMGUI_TEST_ENGINE_ITEM_INFO(g.LastItemData.ID, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Checkable | (selected ? ImGuiItemStatusFlags_Checked : 0)); - if (!enabled) - EndDisabled(); - PopID(); - - return pressed; -} - -bool ImGui::MenuItem(const char* label, const char* shortcut, bool selected, bool enabled) -{ - return MenuItemEx(label, NULL, shortcut, selected, enabled); -} - -bool ImGui::MenuItem(const char* label, const char* shortcut, bool* p_selected, bool enabled) -{ - if (MenuItemEx(label, NULL, shortcut, p_selected ? *p_selected : false, enabled)) - { - if (p_selected) - *p_selected = !*p_selected; - return true; - } - return false; -} - -//------------------------------------------------------------------------- -// [SECTION] Widgets: BeginTabBar, EndTabBar, etc. -//------------------------------------------------------------------------- -// - BeginTabBar() -// - BeginTabBarEx() [Internal] -// - EndTabBar() -// - TabBarLayout() [Internal] -// - TabBarCalcTabID() [Internal] -// - TabBarCalcMaxTabWidth() [Internal] -// - TabBarFindTabById() [Internal] -// - TabBarRemoveTab() [Internal] -// - TabBarCloseTab() [Internal] -// - TabBarScrollClamp() [Internal] -// - TabBarScrollToTab() [Internal] -// - TabBarQueueChangeTabOrder() [Internal] -// - TabBarScrollingButtons() [Internal] -// - TabBarTabListPopupButton() [Internal] -//------------------------------------------------------------------------- - -struct ImGuiTabBarSection -{ - int TabCount; // Number of tabs in this section. - float Width; // Sum of width of tabs in this section (after shrinking down) - float Spacing; // Horizontal spacing at the end of the section. - - ImGuiTabBarSection() { memset(this, 0, sizeof(*this)); } -}; - -namespace ImGui -{ - static void TabBarLayout(ImGuiTabBar* tab_bar); - static ImU32 TabBarCalcTabID(ImGuiTabBar* tab_bar, const char* label); - static float TabBarCalcMaxTabWidth(); - static float TabBarScrollClamp(ImGuiTabBar* tab_bar, float scrolling); - static void TabBarScrollToTab(ImGuiTabBar* tab_bar, ImGuiID tab_id, ImGuiTabBarSection* sections); - static ImGuiTabItem* TabBarScrollingButtons(ImGuiTabBar* tab_bar); - static ImGuiTabItem* TabBarTabListPopupButton(ImGuiTabBar* tab_bar); -} - -ImGuiTabBar::ImGuiTabBar() -{ - memset(this, 0, sizeof(*this)); - CurrFrameVisible = PrevFrameVisible = -1; - LastTabItemIdx = -1; -} - -static inline int TabItemGetSectionIdx(const ImGuiTabItem* tab) -{ - return (tab->Flags & ImGuiTabItemFlags_Leading) ? 0 : (tab->Flags & ImGuiTabItemFlags_Trailing) ? 2 : 1; -} - -static int IMGUI_CDECL TabItemComparerBySection(const void* lhs, const void* rhs) -{ - const ImGuiTabItem* a = (const ImGuiTabItem*)lhs; - const ImGuiTabItem* b = (const ImGuiTabItem*)rhs; - const int a_section = TabItemGetSectionIdx(a); - const int b_section = TabItemGetSectionIdx(b); - if (a_section != b_section) - return a_section - b_section; - return (int)(a->IndexDuringLayout - b->IndexDuringLayout); -} - -static int IMGUI_CDECL TabItemComparerByBeginOrder(const void* lhs, const void* rhs) -{ - const ImGuiTabItem* a = (const ImGuiTabItem*)lhs; - const ImGuiTabItem* b = (const ImGuiTabItem*)rhs; - return (int)(a->BeginOrder - b->BeginOrder); -} - -static ImGuiTabBar* GetTabBarFromTabBarRef(const ImGuiPtrOrIndex& ref) -{ - ImGuiContext& g = *GImGui; - return ref.Ptr ? (ImGuiTabBar*)ref.Ptr : g.TabBars.GetByIndex(ref.Index); -} - -static ImGuiPtrOrIndex GetTabBarRefFromTabBar(ImGuiTabBar* tab_bar) -{ - ImGuiContext& g = *GImGui; - if (g.TabBars.Contains(tab_bar)) - return ImGuiPtrOrIndex(g.TabBars.GetIndex(tab_bar)); - return ImGuiPtrOrIndex(tab_bar); -} - -bool ImGui::BeginTabBar(const char* str_id, ImGuiTabBarFlags flags) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - if (window->SkipItems) - return false; - - ImGuiID id = window->GetID(str_id); - ImGuiTabBar* tab_bar = g.TabBars.GetOrAddByKey(id); - ImRect tab_bar_bb = ImRect(window->DC.CursorPos.x, window->DC.CursorPos.y, window->WorkRect.Max.x, window->DC.CursorPos.y + g.FontSize + g.Style.FramePadding.y * 2); - tab_bar->ID = id; - return BeginTabBarEx(tab_bar, tab_bar_bb, flags | ImGuiTabBarFlags_IsFocused); -} - -bool ImGui::BeginTabBarEx(ImGuiTabBar* tab_bar, const ImRect& tab_bar_bb, ImGuiTabBarFlags flags) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - if (window->SkipItems) - return false; - - if ((flags & ImGuiTabBarFlags_DockNode) == 0) - PushOverrideID(tab_bar->ID); - - // Add to stack - g.CurrentTabBarStack.push_back(GetTabBarRefFromTabBar(tab_bar)); - g.CurrentTabBar = tab_bar; - - // Append with multiple BeginTabBar()/EndTabBar() pairs. - tab_bar->BackupCursorPos = window->DC.CursorPos; - if (tab_bar->CurrFrameVisible == g.FrameCount) - { - window->DC.CursorPos = ImVec2(tab_bar->BarRect.Min.x, tab_bar->BarRect.Max.y + tab_bar->ItemSpacingY); - tab_bar->BeginCount++; - return true; - } - - // Ensure correct ordering when toggling ImGuiTabBarFlags_Reorderable flag, or when a new tab was added while being not reorderable - if ((flags & ImGuiTabBarFlags_Reorderable) != (tab_bar->Flags & ImGuiTabBarFlags_Reorderable) || (tab_bar->TabsAddedNew && !(flags & ImGuiTabBarFlags_Reorderable))) - if (tab_bar->Tabs.Size > 1) - ImQsort(tab_bar->Tabs.Data, tab_bar->Tabs.Size, sizeof(ImGuiTabItem), TabItemComparerByBeginOrder); - tab_bar->TabsAddedNew = false; - - // Flags - if ((flags & ImGuiTabBarFlags_FittingPolicyMask_) == 0) - flags |= ImGuiTabBarFlags_FittingPolicyDefault_; - - tab_bar->Flags = flags; - tab_bar->BarRect = tab_bar_bb; - tab_bar->WantLayout = true; // Layout will be done on the first call to ItemTab() - tab_bar->PrevFrameVisible = tab_bar->CurrFrameVisible; - tab_bar->CurrFrameVisible = g.FrameCount; - tab_bar->PrevTabsContentsHeight = tab_bar->CurrTabsContentsHeight; - tab_bar->CurrTabsContentsHeight = 0.0f; - tab_bar->ItemSpacingY = g.Style.ItemSpacing.y; - tab_bar->FramePadding = g.Style.FramePadding; - tab_bar->TabsActiveCount = 0; - tab_bar->BeginCount = 1; - - // Set cursor pos in a way which only be used in the off-chance the user erroneously submits item before BeginTabItem(): items will overlap - window->DC.CursorPos = ImVec2(tab_bar->BarRect.Min.x, tab_bar->BarRect.Max.y + tab_bar->ItemSpacingY); - - // Draw separator - const ImU32 col = GetColorU32((flags & ImGuiTabBarFlags_IsFocused) ? ImGuiCol_TabActive : ImGuiCol_TabUnfocusedActive); - const float y = tab_bar->BarRect.Max.y - 1.0f; - { - const float separator_min_x = tab_bar->BarRect.Min.x - IM_FLOOR(window->WindowPadding.x * 0.5f); - const float separator_max_x = tab_bar->BarRect.Max.x + IM_FLOOR(window->WindowPadding.x * 0.5f); - window->DrawList->AddLine(ImVec2(separator_min_x, y), ImVec2(separator_max_x, y), col, 1.0f); - } - return true; -} - -void ImGui::EndTabBar() -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - if (window->SkipItems) - return; - - ImGuiTabBar* tab_bar = g.CurrentTabBar; - if (tab_bar == NULL) - { - IM_ASSERT_USER_ERROR(tab_bar != NULL, "Mismatched BeginTabBar()/EndTabBar()!"); - return; - } - - // Fallback in case no TabItem have been submitted - if (tab_bar->WantLayout) - TabBarLayout(tab_bar); - - // Restore the last visible height if no tab is visible, this reduce vertical flicker/movement when a tabs gets removed without calling SetTabItemClosed(). - const bool tab_bar_appearing = (tab_bar->PrevFrameVisible + 1 < g.FrameCount); - if (tab_bar->VisibleTabWasSubmitted || tab_bar->VisibleTabId == 0 || tab_bar_appearing) - { - tab_bar->CurrTabsContentsHeight = ImMax(window->DC.CursorPos.y - tab_bar->BarRect.Max.y, tab_bar->CurrTabsContentsHeight); - window->DC.CursorPos.y = tab_bar->BarRect.Max.y + tab_bar->CurrTabsContentsHeight; - } - else - { - window->DC.CursorPos.y = tab_bar->BarRect.Max.y + tab_bar->PrevTabsContentsHeight; - } - if (tab_bar->BeginCount > 1) - window->DC.CursorPos = tab_bar->BackupCursorPos; - - if ((tab_bar->Flags & ImGuiTabBarFlags_DockNode) == 0) - PopID(); - - g.CurrentTabBarStack.pop_back(); - g.CurrentTabBar = g.CurrentTabBarStack.empty() ? NULL : GetTabBarFromTabBarRef(g.CurrentTabBarStack.back()); -} - -// This is called only once a frame before by the first call to ItemTab() -// The reason we're not calling it in BeginTabBar() is to leave a chance to the user to call the SetTabItemClosed() functions. -static void ImGui::TabBarLayout(ImGuiTabBar* tab_bar) -{ - ImGuiContext& g = *GImGui; - tab_bar->WantLayout = false; - - // Garbage collect by compacting list - // Detect if we need to sort out tab list (e.g. in rare case where a tab changed section) - int tab_dst_n = 0; - bool need_sort_by_section = false; - ImGuiTabBarSection sections[3]; // Layout sections: Leading, Central, Trailing - for (int tab_src_n = 0; tab_src_n < tab_bar->Tabs.Size; tab_src_n++) - { - ImGuiTabItem* tab = &tab_bar->Tabs[tab_src_n]; - if (tab->LastFrameVisible < tab_bar->PrevFrameVisible || tab->WantClose) - { - // Remove tab - if (tab_bar->VisibleTabId == tab->ID) { tab_bar->VisibleTabId = 0; } - if (tab_bar->SelectedTabId == tab->ID) { tab_bar->SelectedTabId = 0; } - if (tab_bar->NextSelectedTabId == tab->ID) { tab_bar->NextSelectedTabId = 0; } - continue; - } - if (tab_dst_n != tab_src_n) - tab_bar->Tabs[tab_dst_n] = tab_bar->Tabs[tab_src_n]; - - tab = &tab_bar->Tabs[tab_dst_n]; - tab->IndexDuringLayout = (ImS16)tab_dst_n; - - // We will need sorting if tabs have changed section (e.g. moved from one of Leading/Central/Trailing to another) - int curr_tab_section_n = TabItemGetSectionIdx(tab); - if (tab_dst_n > 0) - { - ImGuiTabItem* prev_tab = &tab_bar->Tabs[tab_dst_n - 1]; - int prev_tab_section_n = TabItemGetSectionIdx(prev_tab); - if (curr_tab_section_n == 0 && prev_tab_section_n != 0) - need_sort_by_section = true; - if (prev_tab_section_n == 2 && curr_tab_section_n != 2) - need_sort_by_section = true; - } - - sections[curr_tab_section_n].TabCount++; - tab_dst_n++; - } - if (tab_bar->Tabs.Size != tab_dst_n) - tab_bar->Tabs.resize(tab_dst_n); - - if (need_sort_by_section) - ImQsort(tab_bar->Tabs.Data, tab_bar->Tabs.Size, sizeof(ImGuiTabItem), TabItemComparerBySection); - - // Calculate spacing between sections - sections[0].Spacing = sections[0].TabCount > 0 && (sections[1].TabCount + sections[2].TabCount) > 0 ? g.Style.ItemInnerSpacing.x : 0.0f; - sections[1].Spacing = sections[1].TabCount > 0 && sections[2].TabCount > 0 ? g.Style.ItemInnerSpacing.x : 0.0f; - - // Setup next selected tab - ImGuiID scroll_to_tab_id = 0; - if (tab_bar->NextSelectedTabId) - { - tab_bar->SelectedTabId = tab_bar->NextSelectedTabId; - tab_bar->NextSelectedTabId = 0; - scroll_to_tab_id = tab_bar->SelectedTabId; - } - - // Process order change request (we could probably process it when requested but it's just saner to do it in a single spot). - if (tab_bar->ReorderRequestTabId != 0) - { - if (TabBarProcessReorder(tab_bar)) - if (tab_bar->ReorderRequestTabId == tab_bar->SelectedTabId) - scroll_to_tab_id = tab_bar->ReorderRequestTabId; - tab_bar->ReorderRequestTabId = 0; - } - - // Tab List Popup (will alter tab_bar->BarRect and therefore the available width!) - const bool tab_list_popup_button = (tab_bar->Flags & ImGuiTabBarFlags_TabListPopupButton) != 0; - if (tab_list_popup_button) - if (ImGuiTabItem* tab_to_select = TabBarTabListPopupButton(tab_bar)) // NB: Will alter BarRect.Min.x! - scroll_to_tab_id = tab_bar->SelectedTabId = tab_to_select->ID; - - // Leading/Trailing tabs will be shrink only if central one aren't visible anymore, so layout the shrink data as: leading, trailing, central - // (whereas our tabs are stored as: leading, central, trailing) - int shrink_buffer_indexes[3] = { 0, sections[0].TabCount + sections[2].TabCount, sections[0].TabCount }; - g.ShrinkWidthBuffer.resize(tab_bar->Tabs.Size); - - // Compute ideal tabs widths + store them into shrink buffer - ImGuiTabItem* most_recently_selected_tab = NULL; - int curr_section_n = -1; - bool found_selected_tab_id = false; - for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++) - { - ImGuiTabItem* tab = &tab_bar->Tabs[tab_n]; - IM_ASSERT(tab->LastFrameVisible >= tab_bar->PrevFrameVisible); - - if ((most_recently_selected_tab == NULL || most_recently_selected_tab->LastFrameSelected < tab->LastFrameSelected) && !(tab->Flags & ImGuiTabItemFlags_Button)) - most_recently_selected_tab = tab; - if (tab->ID == tab_bar->SelectedTabId) - found_selected_tab_id = true; - if (scroll_to_tab_id == 0 && g.NavJustMovedToId == tab->ID) - scroll_to_tab_id = tab->ID; - - // Refresh tab width immediately, otherwise changes of style e.g. style.FramePadding.x would noticeably lag in the tab bar. - // Additionally, when using TabBarAddTab() to manipulate tab bar order we occasionally insert new tabs that don't have a width yet, - // and we cannot wait for the next BeginTabItem() call. We cannot compute this width within TabBarAddTab() because font size depends on the active window. - const char* tab_name = tab_bar->GetTabName(tab); - const bool has_close_button = (tab->Flags & ImGuiTabItemFlags_NoCloseButton) ? false : true; - tab->ContentWidth = TabItemCalcSize(tab_name, has_close_button).x; - - int section_n = TabItemGetSectionIdx(tab); - ImGuiTabBarSection* section = §ions[section_n]; - section->Width += tab->ContentWidth + (section_n == curr_section_n ? g.Style.ItemInnerSpacing.x : 0.0f); - curr_section_n = section_n; - - // Store data so we can build an array sorted by width if we need to shrink tabs down - IM_MSVC_WARNING_SUPPRESS(6385); - int shrink_buffer_index = shrink_buffer_indexes[section_n]++; - g.ShrinkWidthBuffer[shrink_buffer_index].Index = tab_n; - g.ShrinkWidthBuffer[shrink_buffer_index].Width = tab->ContentWidth; - - IM_ASSERT(tab->ContentWidth > 0.0f); - tab->Width = tab->ContentWidth; - } - - // Compute total ideal width (used for e.g. auto-resizing a window) - tab_bar->WidthAllTabsIdeal = 0.0f; - for (int section_n = 0; section_n < 3; section_n++) - tab_bar->WidthAllTabsIdeal += sections[section_n].Width + sections[section_n].Spacing; - - // Horizontal scrolling buttons - // (note that TabBarScrollButtons() will alter BarRect.Max.x) - if ((tab_bar->WidthAllTabsIdeal > tab_bar->BarRect.GetWidth() && tab_bar->Tabs.Size > 1) && !(tab_bar->Flags & ImGuiTabBarFlags_NoTabListScrollingButtons) && (tab_bar->Flags & ImGuiTabBarFlags_FittingPolicyScroll)) - if (ImGuiTabItem* scroll_and_select_tab = TabBarScrollingButtons(tab_bar)) - { - scroll_to_tab_id = scroll_and_select_tab->ID; - if ((scroll_and_select_tab->Flags & ImGuiTabItemFlags_Button) == 0) - tab_bar->SelectedTabId = scroll_to_tab_id; - } - - // Shrink widths if full tabs don't fit in their allocated space - float section_0_w = sections[0].Width + sections[0].Spacing; - float section_1_w = sections[1].Width + sections[1].Spacing; - float section_2_w = sections[2].Width + sections[2].Spacing; - bool central_section_is_visible = (section_0_w + section_2_w) < tab_bar->BarRect.GetWidth(); - float width_excess; - if (central_section_is_visible) - width_excess = ImMax(section_1_w - (tab_bar->BarRect.GetWidth() - section_0_w - section_2_w), 0.0f); // Excess used to shrink central section - else - width_excess = (section_0_w + section_2_w) - tab_bar->BarRect.GetWidth(); // Excess used to shrink leading/trailing section - - // With ImGuiTabBarFlags_FittingPolicyScroll policy, we will only shrink leading/trailing if the central section is not visible anymore - if (width_excess > 0.0f && ((tab_bar->Flags & ImGuiTabBarFlags_FittingPolicyResizeDown) || !central_section_is_visible)) - { - int shrink_data_count = (central_section_is_visible ? sections[1].TabCount : sections[0].TabCount + sections[2].TabCount); - int shrink_data_offset = (central_section_is_visible ? sections[0].TabCount + sections[2].TabCount : 0); - ShrinkWidths(g.ShrinkWidthBuffer.Data + shrink_data_offset, shrink_data_count, width_excess); - - // Apply shrunk values into tabs and sections - for (int tab_n = shrink_data_offset; tab_n < shrink_data_offset + shrink_data_count; tab_n++) - { - ImGuiTabItem* tab = &tab_bar->Tabs[g.ShrinkWidthBuffer[tab_n].Index]; - float shrinked_width = IM_FLOOR(g.ShrinkWidthBuffer[tab_n].Width); - if (shrinked_width < 0.0f) - continue; - - int section_n = TabItemGetSectionIdx(tab); - sections[section_n].Width -= (tab->Width - shrinked_width); - tab->Width = shrinked_width; - } - } - - // Layout all active tabs - int section_tab_index = 0; - float tab_offset = 0.0f; - tab_bar->WidthAllTabs = 0.0f; - for (int section_n = 0; section_n < 3; section_n++) - { - ImGuiTabBarSection* section = §ions[section_n]; - if (section_n == 2) - tab_offset = ImMin(ImMax(0.0f, tab_bar->BarRect.GetWidth() - section->Width), tab_offset); - - for (int tab_n = 0; tab_n < section->TabCount; tab_n++) - { - ImGuiTabItem* tab = &tab_bar->Tabs[section_tab_index + tab_n]; - tab->Offset = tab_offset; - tab_offset += tab->Width + (tab_n < section->TabCount - 1 ? g.Style.ItemInnerSpacing.x : 0.0f); - } - tab_bar->WidthAllTabs += ImMax(section->Width + section->Spacing, 0.0f); - tab_offset += section->Spacing; - section_tab_index += section->TabCount; - } - - // If we have lost the selected tab, select the next most recently active one - if (found_selected_tab_id == false) - tab_bar->SelectedTabId = 0; - if (tab_bar->SelectedTabId == 0 && tab_bar->NextSelectedTabId == 0 && most_recently_selected_tab != NULL) - scroll_to_tab_id = tab_bar->SelectedTabId = most_recently_selected_tab->ID; - - // Lock in visible tab - tab_bar->VisibleTabId = tab_bar->SelectedTabId; - tab_bar->VisibleTabWasSubmitted = false; - - // Update scrolling - if (scroll_to_tab_id != 0) - TabBarScrollToTab(tab_bar, scroll_to_tab_id, sections); - tab_bar->ScrollingAnim = TabBarScrollClamp(tab_bar, tab_bar->ScrollingAnim); - tab_bar->ScrollingTarget = TabBarScrollClamp(tab_bar, tab_bar->ScrollingTarget); - if (tab_bar->ScrollingAnim != tab_bar->ScrollingTarget) - { - // Scrolling speed adjust itself so we can always reach our target in 1/3 seconds. - // Teleport if we are aiming far off the visible line - tab_bar->ScrollingSpeed = ImMax(tab_bar->ScrollingSpeed, 70.0f * g.FontSize); - tab_bar->ScrollingSpeed = ImMax(tab_bar->ScrollingSpeed, ImFabs(tab_bar->ScrollingTarget - tab_bar->ScrollingAnim) / 0.3f); - const bool teleport = (tab_bar->PrevFrameVisible + 1 < g.FrameCount) || (tab_bar->ScrollingTargetDistToVisibility > 10.0f * g.FontSize); - tab_bar->ScrollingAnim = teleport ? tab_bar->ScrollingTarget : ImLinearSweep(tab_bar->ScrollingAnim, tab_bar->ScrollingTarget, g.IO.DeltaTime * tab_bar->ScrollingSpeed); - } - else - { - tab_bar->ScrollingSpeed = 0.0f; - } - tab_bar->ScrollingRectMinX = tab_bar->BarRect.Min.x + sections[0].Width + sections[0].Spacing; - tab_bar->ScrollingRectMaxX = tab_bar->BarRect.Max.x - sections[2].Width - sections[1].Spacing; - - // Clear name buffers - if ((tab_bar->Flags & ImGuiTabBarFlags_DockNode) == 0) - tab_bar->TabsNames.Buf.resize(0); - - // Actual layout in host window (we don't do it in BeginTabBar() so as not to waste an extra frame) - ImGuiWindow* window = g.CurrentWindow; - window->DC.CursorPos = tab_bar->BarRect.Min; - ItemSize(ImVec2(tab_bar->WidthAllTabs, tab_bar->BarRect.GetHeight()), tab_bar->FramePadding.y); - window->DC.IdealMaxPos.x = ImMax(window->DC.IdealMaxPos.x, tab_bar->BarRect.Min.x + tab_bar->WidthAllTabsIdeal); -} - -// Dockables uses Name/ID in the global namespace. Non-dockable items use the ID stack. -static ImU32 ImGui::TabBarCalcTabID(ImGuiTabBar* tab_bar, const char* label) -{ - if (tab_bar->Flags & ImGuiTabBarFlags_DockNode) - { - ImGuiID id = ImHashStr(label); - KeepAliveID(id); - return id; - } - else - { - ImGuiWindow* window = GImGui->CurrentWindow; - return window->GetID(label); - } -} - -static float ImGui::TabBarCalcMaxTabWidth() -{ - ImGuiContext& g = *GImGui; - return g.FontSize * 20.0f; -} - -ImGuiTabItem* ImGui::TabBarFindTabByID(ImGuiTabBar* tab_bar, ImGuiID tab_id) -{ - if (tab_id != 0) - for (int n = 0; n < tab_bar->Tabs.Size; n++) - if (tab_bar->Tabs[n].ID == tab_id) - return &tab_bar->Tabs[n]; - return NULL; -} - -// The *TabId fields be already set by the docking system _before_ the actual TabItem was created, so we clear them regardless. -void ImGui::TabBarRemoveTab(ImGuiTabBar* tab_bar, ImGuiID tab_id) -{ - if (ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, tab_id)) - tab_bar->Tabs.erase(tab); - if (tab_bar->VisibleTabId == tab_id) { tab_bar->VisibleTabId = 0; } - if (tab_bar->SelectedTabId == tab_id) { tab_bar->SelectedTabId = 0; } - if (tab_bar->NextSelectedTabId == tab_id) { tab_bar->NextSelectedTabId = 0; } -} - -// Called on manual closure attempt -void ImGui::TabBarCloseTab(ImGuiTabBar* tab_bar, ImGuiTabItem* tab) -{ - IM_ASSERT(!(tab->Flags & ImGuiTabItemFlags_Button)); - if (!(tab->Flags & ImGuiTabItemFlags_UnsavedDocument)) - { - // This will remove a frame of lag for selecting another tab on closure. - // However we don't run it in the case where the 'Unsaved' flag is set, so user gets a chance to fully undo the closure - tab->WantClose = true; - if (tab_bar->VisibleTabId == tab->ID) - { - tab->LastFrameVisible = -1; - tab_bar->SelectedTabId = tab_bar->NextSelectedTabId = 0; - } - } - else - { - // Actually select before expecting closure attempt (on an UnsavedDocument tab user is expect to e.g. show a popup) - if (tab_bar->VisibleTabId != tab->ID) - tab_bar->NextSelectedTabId = tab->ID; - } -} - -static float ImGui::TabBarScrollClamp(ImGuiTabBar* tab_bar, float scrolling) -{ - scrolling = ImMin(scrolling, tab_bar->WidthAllTabs - tab_bar->BarRect.GetWidth()); - return ImMax(scrolling, 0.0f); -} - -// Note: we may scroll to tab that are not selected! e.g. using keyboard arrow keys -static void ImGui::TabBarScrollToTab(ImGuiTabBar* tab_bar, ImGuiID tab_id, ImGuiTabBarSection* sections) -{ - ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, tab_id); - if (tab == NULL) - return; - if (tab->Flags & ImGuiTabItemFlags_SectionMask_) - return; - - ImGuiContext& g = *GImGui; - float margin = g.FontSize * 1.0f; // When to scroll to make Tab N+1 visible always make a bit of N visible to suggest more scrolling area (since we don't have a scrollbar) - int order = tab_bar->GetTabOrder(tab); - - // Scrolling happens only in the central section (leading/trailing sections are not scrolling) - // FIXME: This is all confusing. - float scrollable_width = tab_bar->BarRect.GetWidth() - sections[0].Width - sections[2].Width - sections[1].Spacing; - - // We make all tabs positions all relative Sections[0].Width to make code simpler - float tab_x1 = tab->Offset - sections[0].Width + (order > sections[0].TabCount - 1 ? -margin : 0.0f); - float tab_x2 = tab->Offset - sections[0].Width + tab->Width + (order + 1 < tab_bar->Tabs.Size - sections[2].TabCount ? margin : 1.0f); - tab_bar->ScrollingTargetDistToVisibility = 0.0f; - if (tab_bar->ScrollingTarget > tab_x1 || (tab_x2 - tab_x1 >= scrollable_width)) - { - // Scroll to the left - tab_bar->ScrollingTargetDistToVisibility = ImMax(tab_bar->ScrollingAnim - tab_x2, 0.0f); - tab_bar->ScrollingTarget = tab_x1; - } - else if (tab_bar->ScrollingTarget < tab_x2 - scrollable_width) - { - // Scroll to the right - tab_bar->ScrollingTargetDistToVisibility = ImMax((tab_x1 - scrollable_width) - tab_bar->ScrollingAnim, 0.0f); - tab_bar->ScrollingTarget = tab_x2 - scrollable_width; - } -} - -void ImGui::TabBarQueueReorder(ImGuiTabBar* tab_bar, const ImGuiTabItem* tab, int offset) -{ - IM_ASSERT(offset != 0); - IM_ASSERT(tab_bar->ReorderRequestTabId == 0); - tab_bar->ReorderRequestTabId = tab->ID; - tab_bar->ReorderRequestOffset = (ImS16)offset; -} - -void ImGui::TabBarQueueReorderFromMousePos(ImGuiTabBar* tab_bar, const ImGuiTabItem* src_tab, ImVec2 mouse_pos) -{ - ImGuiContext& g = *GImGui; - IM_ASSERT(tab_bar->ReorderRequestTabId == 0); - if ((tab_bar->Flags & ImGuiTabBarFlags_Reorderable) == 0) - return; - - const bool is_central_section = (src_tab->Flags & ImGuiTabItemFlags_SectionMask_) == 0; - const float bar_offset = tab_bar->BarRect.Min.x - (is_central_section ? tab_bar->ScrollingTarget : 0); - - // Count number of contiguous tabs we are crossing over - const int dir = (bar_offset + src_tab->Offset) > mouse_pos.x ? -1 : +1; - const int src_idx = tab_bar->Tabs.index_from_ptr(src_tab); - int dst_idx = src_idx; - for (int i = src_idx; i >= 0 && i < tab_bar->Tabs.Size; i += dir) - { - // Reordered tabs must share the same section - const ImGuiTabItem* dst_tab = &tab_bar->Tabs[i]; - if (dst_tab->Flags & ImGuiTabItemFlags_NoReorder) - break; - if ((dst_tab->Flags & ImGuiTabItemFlags_SectionMask_) != (src_tab->Flags & ImGuiTabItemFlags_SectionMask_)) - break; - dst_idx = i; - - // Include spacing after tab, so when mouse cursor is between tabs we would not continue checking further tabs that are not hovered. - const float x1 = bar_offset + dst_tab->Offset - g.Style.ItemInnerSpacing.x; - const float x2 = bar_offset + dst_tab->Offset + dst_tab->Width + g.Style.ItemInnerSpacing.x; - //GetForegroundDrawList()->AddRect(ImVec2(x1, tab_bar->BarRect.Min.y), ImVec2(x2, tab_bar->BarRect.Max.y), IM_COL32(255, 0, 0, 255)); - if ((dir < 0 && mouse_pos.x > x1) || (dir > 0 && mouse_pos.x < x2)) - break; - } - - if (dst_idx != src_idx) - TabBarQueueReorder(tab_bar, src_tab, dst_idx - src_idx); -} - -bool ImGui::TabBarProcessReorder(ImGuiTabBar* tab_bar) -{ - ImGuiTabItem* tab1 = TabBarFindTabByID(tab_bar, tab_bar->ReorderRequestTabId); - if (tab1 == NULL || (tab1->Flags & ImGuiTabItemFlags_NoReorder)) - return false; - - //IM_ASSERT(tab_bar->Flags & ImGuiTabBarFlags_Reorderable); // <- this may happen when using debug tools - int tab2_order = tab_bar->GetTabOrder(tab1) + tab_bar->ReorderRequestOffset; - if (tab2_order < 0 || tab2_order >= tab_bar->Tabs.Size) - return false; - - // Reordered tabs must share the same section - // (Note: TabBarQueueReorderFromMousePos() also has a similar test but since we allow direct calls to TabBarQueueReorder() we do it here too) - ImGuiTabItem* tab2 = &tab_bar->Tabs[tab2_order]; - if (tab2->Flags & ImGuiTabItemFlags_NoReorder) - return false; - if ((tab1->Flags & ImGuiTabItemFlags_SectionMask_) != (tab2->Flags & ImGuiTabItemFlags_SectionMask_)) - return false; - - ImGuiTabItem item_tmp = *tab1; - ImGuiTabItem* src_tab = (tab_bar->ReorderRequestOffset > 0) ? tab1 + 1 : tab2; - ImGuiTabItem* dst_tab = (tab_bar->ReorderRequestOffset > 0) ? tab1 : tab2 + 1; - const int move_count = (tab_bar->ReorderRequestOffset > 0) ? tab_bar->ReorderRequestOffset : -tab_bar->ReorderRequestOffset; - memmove(dst_tab, src_tab, move_count * sizeof(ImGuiTabItem)); - *tab2 = item_tmp; - - if (tab_bar->Flags & ImGuiTabBarFlags_SaveSettings) - MarkIniSettingsDirty(); - return true; -} - -static ImGuiTabItem* ImGui::TabBarScrollingButtons(ImGuiTabBar* tab_bar) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - - const ImVec2 arrow_button_size(g.FontSize - 2.0f, g.FontSize + g.Style.FramePadding.y * 2.0f); - const float scrolling_buttons_width = arrow_button_size.x * 2.0f; - - const ImVec2 backup_cursor_pos = window->DC.CursorPos; - //window->DrawList->AddRect(ImVec2(tab_bar->BarRect.Max.x - scrolling_buttons_width, tab_bar->BarRect.Min.y), ImVec2(tab_bar->BarRect.Max.x, tab_bar->BarRect.Max.y), IM_COL32(255,0,0,255)); - - int select_dir = 0; - ImVec4 arrow_col = g.Style.Colors[ImGuiCol_Text]; - arrow_col.w *= 0.5f; - - PushStyleColor(ImGuiCol_Text, arrow_col); - PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); - const float backup_repeat_delay = g.IO.KeyRepeatDelay; - const float backup_repeat_rate = g.IO.KeyRepeatRate; - g.IO.KeyRepeatDelay = 0.250f; - g.IO.KeyRepeatRate = 0.200f; - float x = ImMax(tab_bar->BarRect.Min.x, tab_bar->BarRect.Max.x - scrolling_buttons_width); - window->DC.CursorPos = ImVec2(x, tab_bar->BarRect.Min.y); - if (ArrowButtonEx("##<", ImGuiDir_Left, arrow_button_size, ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_Repeat)) - select_dir = -1; - window->DC.CursorPos = ImVec2(x + arrow_button_size.x, tab_bar->BarRect.Min.y); - if (ArrowButtonEx("##>", ImGuiDir_Right, arrow_button_size, ImGuiButtonFlags_PressedOnClick | ImGuiButtonFlags_Repeat)) - select_dir = +1; - PopStyleColor(2); - g.IO.KeyRepeatRate = backup_repeat_rate; - g.IO.KeyRepeatDelay = backup_repeat_delay; - - ImGuiTabItem* tab_to_scroll_to = NULL; - if (select_dir != 0) - if (ImGuiTabItem* tab_item = TabBarFindTabByID(tab_bar, tab_bar->SelectedTabId)) - { - int selected_order = tab_bar->GetTabOrder(tab_item); - int target_order = selected_order + select_dir; - - // Skip tab item buttons until another tab item is found or end is reached - while (tab_to_scroll_to == NULL) - { - // If we are at the end of the list, still scroll to make our tab visible - tab_to_scroll_to = &tab_bar->Tabs[(target_order >= 0 && target_order < tab_bar->Tabs.Size) ? target_order : selected_order]; - - // Cross through buttons - // (even if first/last item is a button, return it so we can update the scroll) - if (tab_to_scroll_to->Flags & ImGuiTabItemFlags_Button) - { - target_order += select_dir; - selected_order += select_dir; - tab_to_scroll_to = (target_order < 0 || target_order >= tab_bar->Tabs.Size) ? tab_to_scroll_to : NULL; - } - } - } - window->DC.CursorPos = backup_cursor_pos; - tab_bar->BarRect.Max.x -= scrolling_buttons_width + 1.0f; - - return tab_to_scroll_to; -} - -static ImGuiTabItem* ImGui::TabBarTabListPopupButton(ImGuiTabBar* tab_bar) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - - // We use g.Style.FramePadding.y to match the square ArrowButton size - const float tab_list_popup_button_width = g.FontSize + g.Style.FramePadding.y; - const ImVec2 backup_cursor_pos = window->DC.CursorPos; - window->DC.CursorPos = ImVec2(tab_bar->BarRect.Min.x - g.Style.FramePadding.y, tab_bar->BarRect.Min.y); - tab_bar->BarRect.Min.x += tab_list_popup_button_width; - - ImVec4 arrow_col = g.Style.Colors[ImGuiCol_Text]; - arrow_col.w *= 0.5f; - PushStyleColor(ImGuiCol_Text, arrow_col); - PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); - bool open = BeginCombo("##v", NULL, ImGuiComboFlags_NoPreview | ImGuiComboFlags_HeightLargest); - PopStyleColor(2); - - ImGuiTabItem* tab_to_select = NULL; - if (open) - { - for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++) - { - ImGuiTabItem* tab = &tab_bar->Tabs[tab_n]; - if (tab->Flags & ImGuiTabItemFlags_Button) - continue; - - const char* tab_name = tab_bar->GetTabName(tab); - if (Selectable(tab_name, tab_bar->SelectedTabId == tab->ID)) - tab_to_select = tab; - } - EndCombo(); - } - - window->DC.CursorPos = backup_cursor_pos; - return tab_to_select; -} - -//------------------------------------------------------------------------- -// [SECTION] Widgets: BeginTabItem, EndTabItem, etc. -//------------------------------------------------------------------------- -// - BeginTabItem() -// - EndTabItem() -// - TabItemButton() -// - TabItemEx() [Internal] -// - SetTabItemClosed() -// - TabItemCalcSize() [Internal] -// - TabItemBackground() [Internal] -// - TabItemLabelAndCloseButton() [Internal] -//------------------------------------------------------------------------- - -bool ImGui::BeginTabItem(const char* label, bool* p_open, ImGuiTabItemFlags flags) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - if (window->SkipItems) - return false; - - ImGuiTabBar* tab_bar = g.CurrentTabBar; - if (tab_bar == NULL) - { - IM_ASSERT_USER_ERROR(tab_bar, "Needs to be called between BeginTabBar() and EndTabBar()!"); - return false; - } - IM_ASSERT(!(flags & ImGuiTabItemFlags_Button)); // BeginTabItem() Can't be used with button flags, use TabItemButton() instead! - - bool ret = TabItemEx(tab_bar, label, p_open, flags); - if (ret && !(flags & ImGuiTabItemFlags_NoPushId)) - { - ImGuiTabItem* tab = &tab_bar->Tabs[tab_bar->LastTabItemIdx]; - PushOverrideID(tab->ID); // We already hashed 'label' so push into the ID stack directly instead of doing another hash through PushID(label) - } - return ret; -} - -void ImGui::EndTabItem() -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - if (window->SkipItems) - return; - - ImGuiTabBar* tab_bar = g.CurrentTabBar; - if (tab_bar == NULL) - { - IM_ASSERT_USER_ERROR(tab_bar != NULL, "Needs to be called between BeginTabBar() and EndTabBar()!"); - return; - } - IM_ASSERT(tab_bar->LastTabItemIdx >= 0); - ImGuiTabItem* tab = &tab_bar->Tabs[tab_bar->LastTabItemIdx]; - if (!(tab->Flags & ImGuiTabItemFlags_NoPushId)) - PopID(); -} - -bool ImGui::TabItemButton(const char* label, ImGuiTabItemFlags flags) -{ - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - if (window->SkipItems) - return false; - - ImGuiTabBar* tab_bar = g.CurrentTabBar; - if (tab_bar == NULL) - { - IM_ASSERT_USER_ERROR(tab_bar != NULL, "Needs to be called between BeginTabBar() and EndTabBar()!"); - return false; - } - return TabItemEx(tab_bar, label, NULL, flags | ImGuiTabItemFlags_Button | ImGuiTabItemFlags_NoReorder); -} - -bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, ImGuiTabItemFlags flags) -{ - // Layout whole tab bar if not already done - if (tab_bar->WantLayout) - TabBarLayout(tab_bar); - - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - if (window->SkipItems) - return false; - - const ImGuiStyle& style = g.Style; - const ImGuiID id = TabBarCalcTabID(tab_bar, label); - - // If the user called us with *p_open == false, we early out and don't render. - // We make a call to ItemAdd() so that attempts to use a contextual popup menu with an implicit ID won't use an older ID. - IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags); - if (p_open && !*p_open) - { - ItemAdd(ImRect(), id, NULL, ImGuiItemFlags_NoNav | ImGuiItemFlags_NoNavDefaultFocus); - return false; - } - - IM_ASSERT(!p_open || !(flags & ImGuiTabItemFlags_Button)); - IM_ASSERT((flags & (ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_Trailing)) != (ImGuiTabItemFlags_Leading | ImGuiTabItemFlags_Trailing)); // Can't use both Leading and Trailing - - // Store into ImGuiTabItemFlags_NoCloseButton, also honor ImGuiTabItemFlags_NoCloseButton passed by user (although not documented) - if (flags & ImGuiTabItemFlags_NoCloseButton) - p_open = NULL; - else if (p_open == NULL) - flags |= ImGuiTabItemFlags_NoCloseButton; - - // Calculate tab contents size - ImVec2 size = TabItemCalcSize(label, p_open != NULL); - - // Acquire tab data - ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, id); - bool tab_is_new = false; - if (tab == NULL) - { - tab_bar->Tabs.push_back(ImGuiTabItem()); - tab = &tab_bar->Tabs.back(); - tab->ID = id; - tab->Width = size.x; - tab_bar->TabsAddedNew = true; - tab_is_new = true; - } - tab_bar->LastTabItemIdx = (ImS16)tab_bar->Tabs.index_from_ptr(tab); - tab->ContentWidth = size.x; - tab->BeginOrder = tab_bar->TabsActiveCount++; - - const bool tab_bar_appearing = (tab_bar->PrevFrameVisible + 1 < g.FrameCount); - const bool tab_bar_focused = (tab_bar->Flags & ImGuiTabBarFlags_IsFocused) != 0; - const bool tab_appearing = (tab->LastFrameVisible + 1 < g.FrameCount); - const bool is_tab_button = (flags & ImGuiTabItemFlags_Button) != 0; - tab->LastFrameVisible = g.FrameCount; - tab->Flags = flags; - - // Append name with zero-terminator - tab->NameOffset = (ImS32)tab_bar->TabsNames.size(); - tab_bar->TabsNames.append(label, label + strlen(label) + 1); - - // Update selected tab - if (tab_appearing && (tab_bar->Flags & ImGuiTabBarFlags_AutoSelectNewTabs) && tab_bar->NextSelectedTabId == 0) - if (!tab_bar_appearing || tab_bar->SelectedTabId == 0) - if (!is_tab_button) - tab_bar->NextSelectedTabId = id; // New tabs gets activated - if ((flags & ImGuiTabItemFlags_SetSelected) && (tab_bar->SelectedTabId != id)) // SetSelected can only be passed on explicit tab bar - if (!is_tab_button) - tab_bar->NextSelectedTabId = id; - - // Lock visibility - // (Note: tab_contents_visible != tab_selected... because CTRL+TAB operations may preview some tabs without selecting them!) - bool tab_contents_visible = (tab_bar->VisibleTabId == id); - if (tab_contents_visible) - tab_bar->VisibleTabWasSubmitted = true; - - // On the very first frame of a tab bar we let first tab contents be visible to minimize appearing glitches - if (!tab_contents_visible && tab_bar->SelectedTabId == 0 && tab_bar_appearing) - if (tab_bar->Tabs.Size == 1 && !(tab_bar->Flags & ImGuiTabBarFlags_AutoSelectNewTabs)) - tab_contents_visible = true; - - // Note that tab_is_new is not necessarily the same as tab_appearing! When a tab bar stops being submitted - // and then gets submitted again, the tabs will have 'tab_appearing=true' but 'tab_is_new=false'. - if (tab_appearing && (!tab_bar_appearing || tab_is_new)) - { - ItemAdd(ImRect(), id, NULL, ImGuiItemFlags_NoNav | ImGuiItemFlags_NoNavDefaultFocus); - if (is_tab_button) - return false; - return tab_contents_visible; - } - - if (tab_bar->SelectedTabId == id) - tab->LastFrameSelected = g.FrameCount; - - // Backup current layout position - const ImVec2 backup_main_cursor_pos = window->DC.CursorPos; - - // Layout - const bool is_central_section = (tab->Flags & ImGuiTabItemFlags_SectionMask_) == 0; - size.x = tab->Width; - if (is_central_section) - window->DC.CursorPos = tab_bar->BarRect.Min + ImVec2(IM_FLOOR(tab->Offset - tab_bar->ScrollingAnim), 0.0f); - else - window->DC.CursorPos = tab_bar->BarRect.Min + ImVec2(tab->Offset, 0.0f); - ImVec2 pos = window->DC.CursorPos; - ImRect bb(pos, pos + size); - - // We don't have CPU clipping primitives to clip the CloseButton (until it becomes a texture), so need to add an extra draw call (temporary in the case of vertical animation) - const bool want_clip_rect = is_central_section && (bb.Min.x < tab_bar->ScrollingRectMinX || bb.Max.x > tab_bar->ScrollingRectMaxX); - if (want_clip_rect) - PushClipRect(ImVec2(ImMax(bb.Min.x, tab_bar->ScrollingRectMinX), bb.Min.y - 1), ImVec2(tab_bar->ScrollingRectMaxX, bb.Max.y), true); - - ImVec2 backup_cursor_max_pos = window->DC.CursorMaxPos; - ItemSize(bb.GetSize(), style.FramePadding.y); - window->DC.CursorMaxPos = backup_cursor_max_pos; - - if (!ItemAdd(bb, id)) - { - if (want_clip_rect) - PopClipRect(); - window->DC.CursorPos = backup_main_cursor_pos; - return tab_contents_visible; - } - - // Click to Select a tab - ImGuiButtonFlags button_flags = ((is_tab_button ? ImGuiButtonFlags_PressedOnClickRelease : ImGuiButtonFlags_PressedOnClick) | ImGuiButtonFlags_AllowItemOverlap); - if (g.DragDropActive) - button_flags |= ImGuiButtonFlags_PressedOnDragDropHold; - bool hovered, held; - bool pressed = ButtonBehavior(bb, id, &hovered, &held, button_flags); - if (pressed && !is_tab_button) - tab_bar->NextSelectedTabId = id; - - // Allow the close button to overlap unless we are dragging (in which case we don't want any overlapping tabs to be hovered) - if (g.ActiveId != id) - SetItemAllowOverlap(); - - // Drag and drop: re-order tabs - if (held && !tab_appearing && IsMouseDragging(0)) - { - if (!g.DragDropActive && (tab_bar->Flags & ImGuiTabBarFlags_Reorderable)) - { - // While moving a tab it will jump on the other side of the mouse, so we also test for MouseDelta.x - if (g.IO.MouseDelta.x < 0.0f && g.IO.MousePos.x < bb.Min.x) - { - TabBarQueueReorderFromMousePos(tab_bar, tab, g.IO.MousePos); - } - else if (g.IO.MouseDelta.x > 0.0f && g.IO.MousePos.x > bb.Max.x) - { - TabBarQueueReorderFromMousePos(tab_bar, tab, g.IO.MousePos); - } - } - } - -#if 0 - if (hovered && g.HoveredIdNotActiveTimer > TOOLTIP_DELAY && bb.GetWidth() < tab->ContentWidth) - { - // Enlarge tab display when hovering - bb.Max.x = bb.Min.x + IM_FLOOR(ImLerp(bb.GetWidth(), tab->ContentWidth, ImSaturate((g.HoveredIdNotActiveTimer - 0.40f) * 6.0f))); - display_draw_list = GetForegroundDrawList(window); - TabItemBackground(display_draw_list, bb, flags, GetColorU32(ImGuiCol_TitleBgActive)); - } -#endif - - // Render tab shape - ImDrawList* display_draw_list = window->DrawList; - const ImU32 tab_col = GetColorU32((held || hovered) ? ImGuiCol_TabHovered : tab_contents_visible ? (tab_bar_focused ? ImGuiCol_TabActive : ImGuiCol_TabUnfocusedActive) : (tab_bar_focused ? ImGuiCol_Tab : ImGuiCol_TabUnfocused)); - TabItemBackground(display_draw_list, bb, flags, tab_col); - RenderNavHighlight(bb, id); - - // Select with right mouse button. This is so the common idiom for context menu automatically highlight the current widget. - const bool hovered_unblocked = IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup); - if (hovered_unblocked && (IsMouseClicked(1) || IsMouseReleased(1))) - if (!is_tab_button) - tab_bar->NextSelectedTabId = id; - - if (tab_bar->Flags & ImGuiTabBarFlags_NoCloseWithMiddleMouseButton) - flags |= ImGuiTabItemFlags_NoCloseWithMiddleMouseButton; - - // Render tab label, process close button - const ImGuiID close_button_id = p_open ? GetIDWithSeed("#CLOSE", NULL, id) : 0; - bool just_closed; - bool text_clipped; - TabItemLabelAndCloseButton(display_draw_list, bb, flags, tab_bar->FramePadding, label, id, close_button_id, tab_contents_visible, &just_closed, &text_clipped); - if (just_closed && p_open != NULL) - { - *p_open = false; - TabBarCloseTab(tab_bar, tab); - } - - // Restore main window position so user can draw there - if (want_clip_rect) - PopClipRect(); - window->DC.CursorPos = backup_main_cursor_pos; - - // Tooltip - // (Won't work over the close button because ItemOverlap systems messes up with HoveredIdTimer-> seems ok) - // (We test IsItemHovered() to discard e.g. when another item is active or drag and drop over the tab bar, which g.HoveredId ignores) - // FIXME: This is a mess. - // FIXME: We may want disabled tab to still display the tooltip? - if (text_clipped && g.HoveredId == id && !held && g.HoveredIdNotActiveTimer > g.TooltipSlowDelay && IsItemHovered()) - if (!(tab_bar->Flags & ImGuiTabBarFlags_NoTooltip) && !(tab->Flags & ImGuiTabItemFlags_NoTooltip)) - SetTooltip("%.*s", (int)(FindRenderedTextEnd(label) - label), label); - - IM_ASSERT(!is_tab_button || !(tab_bar->SelectedTabId == tab->ID && is_tab_button)); // TabItemButton should not be selected - if (is_tab_button) - return pressed; - return tab_contents_visible; -} - -// [Public] This is call is 100% optional but it allows to remove some one-frame glitches when a tab has been unexpectedly removed. -// To use it to need to call the function SetTabItemClosed() between BeginTabBar() and EndTabBar(). -// Tabs closed by the close button will automatically be flagged to avoid this issue. -void ImGui::SetTabItemClosed(const char* label) -{ - ImGuiContext& g = *GImGui; - bool is_within_manual_tab_bar = g.CurrentTabBar && !(g.CurrentTabBar->Flags & ImGuiTabBarFlags_DockNode); - if (is_within_manual_tab_bar) - { - ImGuiTabBar* tab_bar = g.CurrentTabBar; - ImGuiID tab_id = TabBarCalcTabID(tab_bar, label); - if (ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, tab_id)) - tab->WantClose = true; // Will be processed by next call to TabBarLayout() - } -} - -ImVec2 ImGui::TabItemCalcSize(const char* label, bool has_close_button) -{ - ImGuiContext& g = *GImGui; - ImVec2 label_size = CalcTextSize(label, NULL, true); - ImVec2 size = ImVec2(label_size.x + g.Style.FramePadding.x, label_size.y + g.Style.FramePadding.y * 2.0f); - if (has_close_button) - size.x += g.Style.FramePadding.x + (g.Style.ItemInnerSpacing.x + g.FontSize); // We use Y intentionally to fit the close button circle. - else - size.x += g.Style.FramePadding.x + 1.0f; - return ImVec2(ImMin(size.x, TabBarCalcMaxTabWidth()), size.y); -} - -void ImGui::TabItemBackground(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImU32 col) -{ - // While rendering tabs, we trim 1 pixel off the top of our bounding box so they can fit within a regular frame height while looking "detached" from it. - ImGuiContext& g = *GImGui; - const float width = bb.GetWidth(); - IM_UNUSED(flags); - IM_ASSERT(width > 0.0f); - const float rounding = ImMax(0.0f, ImMin((flags & ImGuiTabItemFlags_Button) ? g.Style.FrameRounding : g.Style.TabRounding, width * 0.5f - 1.0f)); - const float y1 = bb.Min.y + 1.0f; - const float y2 = bb.Max.y - 1.0f; - draw_list->PathLineTo(ImVec2(bb.Min.x, y2)); - draw_list->PathArcToFast(ImVec2(bb.Min.x + rounding, y1 + rounding), rounding, 6, 9); - draw_list->PathArcToFast(ImVec2(bb.Max.x - rounding, y1 + rounding), rounding, 9, 12); - draw_list->PathLineTo(ImVec2(bb.Max.x, y2)); - draw_list->PathFillConvex(col); - if (g.Style.TabBorderSize > 0.0f) - { - draw_list->PathLineTo(ImVec2(bb.Min.x + 0.5f, y2)); - draw_list->PathArcToFast(ImVec2(bb.Min.x + rounding + 0.5f, y1 + rounding + 0.5f), rounding, 6, 9); - draw_list->PathArcToFast(ImVec2(bb.Max.x - rounding - 0.5f, y1 + rounding + 0.5f), rounding, 9, 12); - draw_list->PathLineTo(ImVec2(bb.Max.x - 0.5f, y2)); - draw_list->PathStroke(GetColorU32(ImGuiCol_Border), 0, g.Style.TabBorderSize); - } -} - -// Render text label (with custom clipping) + Unsaved Document marker + Close Button logic -// We tend to lock style.FramePadding for a given tab-bar, hence the 'frame_padding' parameter. -void ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb, ImGuiTabItemFlags flags, ImVec2 frame_padding, const char* label, ImGuiID tab_id, ImGuiID close_button_id, bool is_contents_visible, bool* out_just_closed, bool* out_text_clipped) -{ - ImGuiContext& g = *GImGui; - ImVec2 label_size = CalcTextSize(label, NULL, true); - - if (out_just_closed) - *out_just_closed = false; - if (out_text_clipped) - *out_text_clipped = false; - - if (bb.GetWidth() <= 1.0f) - return; - - // In Style V2 we'll have full override of all colors per state (e.g. focused, selected) - // But right now if you want to alter text color of tabs this is what you need to do. -#if 0 - const float backup_alpha = g.Style.Alpha; - if (!is_contents_visible) - g.Style.Alpha *= 0.7f; -#endif - - // Render text label (with clipping + alpha gradient) + unsaved marker - ImRect text_pixel_clip_bb(bb.Min.x + frame_padding.x, bb.Min.y + frame_padding.y, bb.Max.x - frame_padding.x, bb.Max.y); - ImRect text_ellipsis_clip_bb = text_pixel_clip_bb; - - // Return clipped state ignoring the close button - if (out_text_clipped) - { - *out_text_clipped = (text_ellipsis_clip_bb.Min.x + label_size.x) > text_pixel_clip_bb.Max.x; - //draw_list->AddCircle(text_ellipsis_clip_bb.Min, 3.0f, *out_text_clipped ? IM_COL32(255, 0, 0, 255) : IM_COL32(0, 255, 0, 255)); - } - - const float button_sz = g.FontSize; - const ImVec2 button_pos(ImMax(bb.Min.x, bb.Max.x - frame_padding.x * 2.0f - button_sz), bb.Min.y); - - // Close Button & Unsaved Marker - // We are relying on a subtle and confusing distinction between 'hovered' and 'g.HoveredId' which happens because we are using ImGuiButtonFlags_AllowOverlapMode + SetItemAllowOverlap() - // 'hovered' will be true when hovering the Tab but NOT when hovering the close button - // 'g.HoveredId==id' will be true when hovering the Tab including when hovering the close button - // 'g.ActiveId==close_button_id' will be true when we are holding on the close button, in which case both hovered booleans are false - bool close_button_pressed = false; - bool close_button_visible = false; - if (close_button_id != 0) - if (is_contents_visible || bb.GetWidth() >= ImMax(button_sz, g.Style.TabMinWidthForCloseButton)) - if (g.HoveredId == tab_id || g.HoveredId == close_button_id || g.ActiveId == tab_id || g.ActiveId == close_button_id) - close_button_visible = true; - bool unsaved_marker_visible = (flags & ImGuiTabItemFlags_UnsavedDocument) != 0 && (button_pos.x + button_sz <= bb.Max.x); - - if (close_button_visible) - { - ImGuiLastItemData last_item_backup = g.LastItemData; - PushStyleVar(ImGuiStyleVar_FramePadding, frame_padding); - if (CloseButton(close_button_id, button_pos)) - close_button_pressed = true; - PopStyleVar(); - g.LastItemData = last_item_backup; - - // Close with middle mouse button - if (!(flags & ImGuiTabItemFlags_NoCloseWithMiddleMouseButton) && IsMouseClicked(2)) - close_button_pressed = true; - } - else if (unsaved_marker_visible) - { - const ImRect bullet_bb(button_pos, button_pos + ImVec2(button_sz, button_sz) + g.Style.FramePadding * 2.0f); - RenderBullet(draw_list, bullet_bb.GetCenter(), GetColorU32(ImGuiCol_Text)); - } - - // This is all rather complicated - // (the main idea is that because the close button only appears on hover, we don't want it to alter the ellipsis position) - // FIXME: if FramePadding is noticeably large, ellipsis_max_x will be wrong here (e.g. #3497), maybe for consistency that parameter of RenderTextEllipsis() shouldn't exist.. - float ellipsis_max_x = close_button_visible ? text_pixel_clip_bb.Max.x : bb.Max.x - 1.0f; - if (close_button_visible || unsaved_marker_visible) - { - text_pixel_clip_bb.Max.x -= close_button_visible ? (button_sz) : (button_sz * 0.80f); - text_ellipsis_clip_bb.Max.x -= unsaved_marker_visible ? (button_sz * 0.80f) : 0.0f; - ellipsis_max_x = text_pixel_clip_bb.Max.x; - } - RenderTextEllipsis(draw_list, text_ellipsis_clip_bb.Min, text_ellipsis_clip_bb.Max, text_pixel_clip_bb.Max.x, ellipsis_max_x, label, NULL, &label_size); - -#if 0 - if (!is_contents_visible) - g.Style.Alpha = backup_alpha; -#endif - - if (out_just_closed) - *out_just_closed = close_button_pressed; -} - - -#endif // #ifndef IMGUI_DISABLE diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imstb_rectpack.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imstb_rectpack.h deleted file mode 100644 index 3958952..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imstb_rectpack.h +++ /dev/null @@ -1,639 +0,0 @@ -// [DEAR IMGUI] -// This is a slightly modified version of stb_rect_pack.h 1.00. -// Those changes would need to be pushed into nothings/stb: -// - Added STBRP__CDECL -// Grep for [DEAR IMGUI] to find the changes. - -// stb_rect_pack.h - v1.00 - public domain - rectangle packing -// Sean Barrett 2014 -// -// Useful for e.g. packing rectangular textures into an atlas. -// Does not do rotation. -// -// Not necessarily the awesomest packing method, but better than -// the totally naive one in stb_truetype (which is primarily what -// this is meant to replace). -// -// Has only had a few tests run, may have issues. -// -// More docs to come. -// -// No memory allocations; uses qsort() and assert() from stdlib. -// Can override those by defining STBRP_SORT and STBRP_ASSERT. -// -// This library currently uses the Skyline Bottom-Left algorithm. -// -// Please note: better rectangle packers are welcome! Please -// implement them to the same API, but with a different init -// function. -// -// Credits -// -// Library -// Sean Barrett -// Minor features -// Martins Mozeiko -// github:IntellectualKitty -// -// Bugfixes / warning fixes -// Jeremy Jaussaud -// Fabian Giesen -// -// Version history: -// -// 1.00 (2019-02-25) avoid small space waste; gracefully fail too-wide rectangles -// 0.99 (2019-02-07) warning fixes -// 0.11 (2017-03-03) return packing success/fail result -// 0.10 (2016-10-25) remove cast-away-const to avoid warnings -// 0.09 (2016-08-27) fix compiler warnings -// 0.08 (2015-09-13) really fix bug with empty rects (w=0 or h=0) -// 0.07 (2015-09-13) fix bug with empty rects (w=0 or h=0) -// 0.06 (2015-04-15) added STBRP_SORT to allow replacing qsort -// 0.05: added STBRP_ASSERT to allow replacing assert -// 0.04: fixed minor bug in STBRP_LARGE_RECTS support -// 0.01: initial release -// -// LICENSE -// -// See end of file for license information. - -////////////////////////////////////////////////////////////////////////////// -// -// INCLUDE SECTION -// - -#ifndef STB_INCLUDE_STB_RECT_PACK_H -#define STB_INCLUDE_STB_RECT_PACK_H - -#define STB_RECT_PACK_VERSION 1 - -#ifdef STBRP_STATIC -#define STBRP_DEF static -#else -#define STBRP_DEF extern -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct stbrp_context stbrp_context; -typedef struct stbrp_node stbrp_node; -typedef struct stbrp_rect stbrp_rect; - -#ifdef STBRP_LARGE_RECTS -typedef int stbrp_coord; -#else -typedef unsigned short stbrp_coord; -#endif - -STBRP_DEF int stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects); -// Assign packed locations to rectangles. The rectangles are of type -// 'stbrp_rect' defined below, stored in the array 'rects', and there -// are 'num_rects' many of them. -// -// Rectangles which are successfully packed have the 'was_packed' flag -// set to a non-zero value and 'x' and 'y' store the minimum location -// on each axis (i.e. bottom-left in cartesian coordinates, top-left -// if you imagine y increasing downwards). Rectangles which do not fit -// have the 'was_packed' flag set to 0. -// -// You should not try to access the 'rects' array from another thread -// while this function is running, as the function temporarily reorders -// the array while it executes. -// -// To pack into another rectangle, you need to call stbrp_init_target -// again. To continue packing into the same rectangle, you can call -// this function again. Calling this multiple times with multiple rect -// arrays will probably produce worse packing results than calling it -// a single time with the full rectangle array, but the option is -// available. -// -// The function returns 1 if all of the rectangles were successfully -// packed and 0 otherwise. - -struct stbrp_rect -{ - // reserved for your use: - int id; - - // input: - stbrp_coord w, h; - - // output: - stbrp_coord x, y; - int was_packed; // non-zero if valid packing - -}; // 16 bytes, nominally - - -STBRP_DEF void stbrp_init_target (stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes); -// Initialize a rectangle packer to: -// pack a rectangle that is 'width' by 'height' in dimensions -// using temporary storage provided by the array 'nodes', which is 'num_nodes' long -// -// You must call this function every time you start packing into a new target. -// -// There is no "shutdown" function. The 'nodes' memory must stay valid for -// the following stbrp_pack_rects() call (or calls), but can be freed after -// the call (or calls) finish. -// -// Note: to guarantee best results, either: -// 1. make sure 'num_nodes' >= 'width' -// or 2. call stbrp_allow_out_of_mem() defined below with 'allow_out_of_mem = 1' -// -// If you don't do either of the above things, widths will be quantized to multiples -// of small integers to guarantee the algorithm doesn't run out of temporary storage. -// -// If you do #2, then the non-quantized algorithm will be used, but the algorithm -// may run out of temporary storage and be unable to pack some rectangles. - -STBRP_DEF void stbrp_setup_allow_out_of_mem (stbrp_context *context, int allow_out_of_mem); -// Optionally call this function after init but before doing any packing to -// change the handling of the out-of-temp-memory scenario, described above. -// If you call init again, this will be reset to the default (false). - - -STBRP_DEF void stbrp_setup_heuristic (stbrp_context *context, int heuristic); -// Optionally select which packing heuristic the library should use. Different -// heuristics will produce better/worse results for different data sets. -// If you call init again, this will be reset to the default. - -enum -{ - STBRP_HEURISTIC_Skyline_default=0, - STBRP_HEURISTIC_Skyline_BL_sortHeight = STBRP_HEURISTIC_Skyline_default, - STBRP_HEURISTIC_Skyline_BF_sortHeight -}; - - -////////////////////////////////////////////////////////////////////////////// -// -// the details of the following structures don't matter to you, but they must -// be visible so you can handle the memory allocations for them - -struct stbrp_node -{ - stbrp_coord x,y; - stbrp_node *next; -}; - -struct stbrp_context -{ - int width; - int height; - int align; - int init_mode; - int heuristic; - int num_nodes; - stbrp_node *active_head; - stbrp_node *free_head; - stbrp_node extra[2]; // we allocate two extra nodes so optimal user-node-count is 'width' not 'width+2' -}; - -#ifdef __cplusplus -} -#endif - -#endif - -////////////////////////////////////////////////////////////////////////////// -// -// IMPLEMENTATION SECTION -// - -#ifdef STB_RECT_PACK_IMPLEMENTATION -#ifndef STBRP_SORT -#include -#define STBRP_SORT qsort -#endif - -#ifndef STBRP_ASSERT -#include -#define STBRP_ASSERT assert -#endif - -// [DEAR IMGUI] Added STBRP__CDECL -#ifdef _MSC_VER -#define STBRP__NOTUSED(v) (void)(v) -#define STBRP__CDECL __cdecl -#else -#define STBRP__NOTUSED(v) (void)sizeof(v) -#define STBRP__CDECL -#endif - -enum -{ - STBRP__INIT_skyline = 1 -}; - -STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic) -{ - switch (context->init_mode) { - case STBRP__INIT_skyline: - STBRP_ASSERT(heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight || heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight); - context->heuristic = heuristic; - break; - default: - STBRP_ASSERT(0); - } -} - -STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem) -{ - if (allow_out_of_mem) - // if it's ok to run out of memory, then don't bother aligning them; - // this gives better packing, but may fail due to OOM (even though - // the rectangles easily fit). @TODO a smarter approach would be to only - // quantize once we've hit OOM, then we could get rid of this parameter. - context->align = 1; - else { - // if it's not ok to run out of memory, then quantize the widths - // so that num_nodes is always enough nodes. - // - // I.e. num_nodes * align >= width - // align >= width / num_nodes - // align = ceil(width/num_nodes) - - context->align = (context->width + context->num_nodes-1) / context->num_nodes; - } -} - -STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes) -{ - int i; -#ifndef STBRP_LARGE_RECTS - STBRP_ASSERT(width <= 0xffff && height <= 0xffff); -#endif - - for (i=0; i < num_nodes-1; ++i) - nodes[i].next = &nodes[i+1]; - nodes[i].next = NULL; - context->init_mode = STBRP__INIT_skyline; - context->heuristic = STBRP_HEURISTIC_Skyline_default; - context->free_head = &nodes[0]; - context->active_head = &context->extra[0]; - context->width = width; - context->height = height; - context->num_nodes = num_nodes; - stbrp_setup_allow_out_of_mem(context, 0); - - // node 0 is the full width, node 1 is the sentinel (lets us not store width explicitly) - context->extra[0].x = 0; - context->extra[0].y = 0; - context->extra[0].next = &context->extra[1]; - context->extra[1].x = (stbrp_coord) width; -#ifdef STBRP_LARGE_RECTS - context->extra[1].y = (1<<30); -#else - context->extra[1].y = 65535; -#endif - context->extra[1].next = NULL; -} - -// find minimum y position if it starts at x1 -static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste) -{ - stbrp_node *node = first; - int x1 = x0 + width; - int min_y, visited_width, waste_area; - - STBRP__NOTUSED(c); - - STBRP_ASSERT(first->x <= x0); - - #if 0 - // skip in case we're past the node - while (node->next->x <= x0) - ++node; - #else - STBRP_ASSERT(node->next->x > x0); // we ended up handling this in the caller for efficiency - #endif - - STBRP_ASSERT(node->x <= x0); - - min_y = 0; - waste_area = 0; - visited_width = 0; - while (node->x < x1) { - if (node->y > min_y) { - // raise min_y higher. - // we've accounted for all waste up to min_y, - // but we'll now add more waste for everything we've visted - waste_area += visited_width * (node->y - min_y); - min_y = node->y; - // the first time through, visited_width might be reduced - if (node->x < x0) - visited_width += node->next->x - x0; - else - visited_width += node->next->x - node->x; - } else { - // add waste area - int under_width = node->next->x - node->x; - if (under_width + visited_width > width) - under_width = width - visited_width; - waste_area += under_width * (min_y - node->y); - visited_width += under_width; - } - node = node->next; - } - - *pwaste = waste_area; - return min_y; -} - -typedef struct -{ - int x,y; - stbrp_node **prev_link; -} stbrp__findresult; - -static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, int height) -{ - int best_waste = (1<<30), best_x, best_y = (1 << 30); - stbrp__findresult fr; - stbrp_node **prev, *node, *tail, **best = NULL; - - // align to multiple of c->align - width = (width + c->align - 1); - width -= width % c->align; - STBRP_ASSERT(width % c->align == 0); - - // if it can't possibly fit, bail immediately - if (width > c->width || height > c->height) { - fr.prev_link = NULL; - fr.x = fr.y = 0; - return fr; - } - - node = c->active_head; - prev = &c->active_head; - while (node->x + width <= c->width) { - int y,waste; - y = stbrp__skyline_find_min_y(c, node, node->x, width, &waste); - if (c->heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight) { // actually just want to test BL - // bottom left - if (y < best_y) { - best_y = y; - best = prev; - } - } else { - // best-fit - if (y + height <= c->height) { - // can only use it if it first vertically - if (y < best_y || (y == best_y && waste < best_waste)) { - best_y = y; - best_waste = waste; - best = prev; - } - } - } - prev = &node->next; - node = node->next; - } - - best_x = (best == NULL) ? 0 : (*best)->x; - - // if doing best-fit (BF), we also have to try aligning right edge to each node position - // - // e.g, if fitting - // - // ____________________ - // |____________________| - // - // into - // - // | | - // | ____________| - // |____________| - // - // then right-aligned reduces waste, but bottom-left BL is always chooses left-aligned - // - // This makes BF take about 2x the time - - if (c->heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight) { - tail = c->active_head; - node = c->active_head; - prev = &c->active_head; - // find first node that's admissible - while (tail->x < width) - tail = tail->next; - while (tail) { - int xpos = tail->x - width; - int y,waste; - STBRP_ASSERT(xpos >= 0); - // find the left position that matches this - while (node->next->x <= xpos) { - prev = &node->next; - node = node->next; - } - STBRP_ASSERT(node->next->x > xpos && node->x <= xpos); - y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste); - if (y + height <= c->height) { - if (y <= best_y) { - if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) { - best_x = xpos; - STBRP_ASSERT(y <= best_y); - best_y = y; - best_waste = waste; - best = prev; - } - } - } - tail = tail->next; - } - } - - fr.prev_link = best; - fr.x = best_x; - fr.y = best_y; - return fr; -} - -static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height) -{ - // find best position according to heuristic - stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height); - stbrp_node *node, *cur; - - // bail if: - // 1. it failed - // 2. the best node doesn't fit (we don't always check this) - // 3. we're out of memory - if (res.prev_link == NULL || res.y + height > context->height || context->free_head == NULL) { - res.prev_link = NULL; - return res; - } - - // on success, create new node - node = context->free_head; - node->x = (stbrp_coord) res.x; - node->y = (stbrp_coord) (res.y + height); - - context->free_head = node->next; - - // insert the new node into the right starting point, and - // let 'cur' point to the remaining nodes needing to be - // stiched back in - - cur = *res.prev_link; - if (cur->x < res.x) { - // preserve the existing one, so start testing with the next one - stbrp_node *next = cur->next; - cur->next = node; - cur = next; - } else { - *res.prev_link = node; - } - - // from here, traverse cur and free the nodes, until we get to one - // that shouldn't be freed - while (cur->next && cur->next->x <= res.x + width) { - stbrp_node *next = cur->next; - // move the current node to the free list - cur->next = context->free_head; - context->free_head = cur; - cur = next; - } - - // stitch the list back in - node->next = cur; - - if (cur->x < res.x + width) - cur->x = (stbrp_coord) (res.x + width); - -#ifdef _DEBUG - cur = context->active_head; - while (cur->x < context->width) { - STBRP_ASSERT(cur->x < cur->next->x); - cur = cur->next; - } - STBRP_ASSERT(cur->next == NULL); - - { - int count=0; - cur = context->active_head; - while (cur) { - cur = cur->next; - ++count; - } - cur = context->free_head; - while (cur) { - cur = cur->next; - ++count; - } - STBRP_ASSERT(count == context->num_nodes+2); - } -#endif - - return res; -} - -// [DEAR IMGUI] Added STBRP__CDECL -static int STBRP__CDECL rect_height_compare(const void *a, const void *b) -{ - const stbrp_rect *p = (const stbrp_rect *) a; - const stbrp_rect *q = (const stbrp_rect *) b; - if (p->h > q->h) - return -1; - if (p->h < q->h) - return 1; - return (p->w > q->w) ? -1 : (p->w < q->w); -} - -// [DEAR IMGUI] Added STBRP__CDECL -static int STBRP__CDECL rect_original_order(const void *a, const void *b) -{ - const stbrp_rect *p = (const stbrp_rect *) a; - const stbrp_rect *q = (const stbrp_rect *) b; - return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed); -} - -#ifdef STBRP_LARGE_RECTS -#define STBRP__MAXVAL 0xffffffff -#else -#define STBRP__MAXVAL 0xffff -#endif - -STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects) -{ - int i, all_rects_packed = 1; - - // we use the 'was_packed' field internally to allow sorting/unsorting - for (i=0; i < num_rects; ++i) { - rects[i].was_packed = i; - } - - // sort according to heuristic - STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare); - - for (i=0; i < num_rects; ++i) { - if (rects[i].w == 0 || rects[i].h == 0) { - rects[i].x = rects[i].y = 0; // empty rect needs no space - } else { - stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h); - if (fr.prev_link) { - rects[i].x = (stbrp_coord) fr.x; - rects[i].y = (stbrp_coord) fr.y; - } else { - rects[i].x = rects[i].y = STBRP__MAXVAL; - } - } - } - - // unsort - STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order); - - // set was_packed flags and all_rects_packed status - for (i=0; i < num_rects; ++i) { - rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL); - if (!rects[i].was_packed) - all_rects_packed = 0; - } - - // return the all_rects_packed status - return all_rects_packed; -} -#endif - -/* ------------------------------------------------------------------------------- -This software is available under 2 licenses -- choose whichever you prefer. ------------------------------------------------------------------------------- -ALTERNATIVE A - MIT License -Copyright (c) 2017 Sean Barrett -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. ------------------------------------------------------------------------------- -ALTERNATIVE B - Public Domain (www.unlicense.org) -This is free and unencumbered software released into the public domain. -Anyone is free to copy, modify, publish, use, compile, sell, or distribute this -software, either in source code form or as a compiled binary, for any purpose, -commercial or non-commercial, and by any means. -In jurisdictions that recognize copyright laws, the author or authors of this -software dedicate any and all copyright interest in the software to the public -domain. We make this dedication for the benefit of the public at large and to -the detriment of our heirs and successors. We intend this dedication to be an -overt act of relinquishment in perpetuity of all present and future rights to -this software under copyright law. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------- -*/ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imstb_textedit.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imstb_textedit.h deleted file mode 100644 index 2c635b2..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imstb_textedit.h +++ /dev/null @@ -1,1449 +0,0 @@ -// [DEAR IMGUI] -// This is a slightly modified version of stb_textedit.h 1.13. -// Those changes would need to be pushed into nothings/stb: -// - Fix in stb_textedit_discard_redo (see https://github.com/nothings/stb/issues/321) -// Grep for [DEAR IMGUI] to find the changes. - -// stb_textedit.h - v1.13 - public domain - Sean Barrett -// Development of this library was sponsored by RAD Game Tools -// -// This C header file implements the guts of a multi-line text-editing -// widget; you implement display, word-wrapping, and low-level string -// insertion/deletion, and stb_textedit will map user inputs into -// insertions & deletions, plus updates to the cursor position, -// selection state, and undo state. -// -// It is intended for use in games and other systems that need to build -// their own custom widgets and which do not have heavy text-editing -// requirements (this library is not recommended for use for editing large -// texts, as its performance does not scale and it has limited undo). -// -// Non-trivial behaviors are modelled after Windows text controls. -// -// -// LICENSE -// -// See end of file for license information. -// -// -// DEPENDENCIES -// -// Uses the C runtime function 'memmove', which you can override -// by defining STB_TEXTEDIT_memmove before the implementation. -// Uses no other functions. Performs no runtime allocations. -// -// -// VERSION HISTORY -// -// 1.13 (2019-02-07) fix bug in undo size management -// 1.12 (2018-01-29) user can change STB_TEXTEDIT_KEYTYPE, fix redo to avoid crash -// 1.11 (2017-03-03) fix HOME on last line, dragging off single-line textfield -// 1.10 (2016-10-25) supress warnings about casting away const with -Wcast-qual -// 1.9 (2016-08-27) customizable move-by-word -// 1.8 (2016-04-02) better keyboard handling when mouse button is down -// 1.7 (2015-09-13) change y range handling in case baseline is non-0 -// 1.6 (2015-04-15) allow STB_TEXTEDIT_memmove -// 1.5 (2014-09-10) add support for secondary keys for OS X -// 1.4 (2014-08-17) fix signed/unsigned warnings -// 1.3 (2014-06-19) fix mouse clicking to round to nearest char boundary -// 1.2 (2014-05-27) fix some RAD types that had crept into the new code -// 1.1 (2013-12-15) move-by-word (requires STB_TEXTEDIT_IS_SPACE ) -// 1.0 (2012-07-26) improve documentation, initial public release -// 0.3 (2012-02-24) bugfixes, single-line mode; insert mode -// 0.2 (2011-11-28) fixes to undo/redo -// 0.1 (2010-07-08) initial version -// -// ADDITIONAL CONTRIBUTORS -// -// Ulf Winklemann: move-by-word in 1.1 -// Fabian Giesen: secondary key inputs in 1.5 -// Martins Mozeiko: STB_TEXTEDIT_memmove in 1.6 -// -// Bugfixes: -// Scott Graham -// Daniel Keller -// Omar Cornut -// Dan Thompson -// -// USAGE -// -// This file behaves differently depending on what symbols you define -// before including it. -// -// -// Header-file mode: -// -// If you do not define STB_TEXTEDIT_IMPLEMENTATION before including this, -// it will operate in "header file" mode. In this mode, it declares a -// single public symbol, STB_TexteditState, which encapsulates the current -// state of a text widget (except for the string, which you will store -// separately). -// -// To compile in this mode, you must define STB_TEXTEDIT_CHARTYPE to a -// primitive type that defines a single character (e.g. char, wchar_t, etc). -// -// To save space or increase undo-ability, you can optionally define the -// following things that are used by the undo system: -// -// STB_TEXTEDIT_POSITIONTYPE small int type encoding a valid cursor position -// STB_TEXTEDIT_UNDOSTATECOUNT the number of undo states to allow -// STB_TEXTEDIT_UNDOCHARCOUNT the number of characters to store in the undo buffer -// -// If you don't define these, they are set to permissive types and -// moderate sizes. The undo system does no memory allocations, so -// it grows STB_TexteditState by the worst-case storage which is (in bytes): -// -// [4 + 3 * sizeof(STB_TEXTEDIT_POSITIONTYPE)] * STB_TEXTEDIT_UNDOSTATE_COUNT -// + sizeof(STB_TEXTEDIT_CHARTYPE) * STB_TEXTEDIT_UNDOCHAR_COUNT -// -// -// Implementation mode: -// -// If you define STB_TEXTEDIT_IMPLEMENTATION before including this, it -// will compile the implementation of the text edit widget, depending -// on a large number of symbols which must be defined before the include. -// -// The implementation is defined only as static functions. You will then -// need to provide your own APIs in the same file which will access the -// static functions. -// -// The basic concept is that you provide a "string" object which -// behaves like an array of characters. stb_textedit uses indices to -// refer to positions in the string, implicitly representing positions -// in the displayed textedit. This is true for both plain text and -// rich text; even with rich text stb_truetype interacts with your -// code as if there was an array of all the displayed characters. -// -// Symbols that must be the same in header-file and implementation mode: -// -// STB_TEXTEDIT_CHARTYPE the character type -// STB_TEXTEDIT_POSITIONTYPE small type that is a valid cursor position -// STB_TEXTEDIT_UNDOSTATECOUNT the number of undo states to allow -// STB_TEXTEDIT_UNDOCHARCOUNT the number of characters to store in the undo buffer -// -// Symbols you must define for implementation mode: -// -// STB_TEXTEDIT_STRING the type of object representing a string being edited, -// typically this is a wrapper object with other data you need -// -// STB_TEXTEDIT_STRINGLEN(obj) the length of the string (ideally O(1)) -// STB_TEXTEDIT_LAYOUTROW(&r,obj,n) returns the results of laying out a line of characters -// starting from character #n (see discussion below) -// STB_TEXTEDIT_GETWIDTH(obj,n,i) returns the pixel delta from the xpos of the i'th character -// to the xpos of the i+1'th char for a line of characters -// starting at character #n (i.e. accounts for kerning -// with previous char) -// STB_TEXTEDIT_KEYTOTEXT(k) maps a keyboard input to an insertable character -// (return type is int, -1 means not valid to insert) -// STB_TEXTEDIT_GETCHAR(obj,i) returns the i'th character of obj, 0-based -// STB_TEXTEDIT_NEWLINE the character returned by _GETCHAR() we recognize -// as manually wordwrapping for end-of-line positioning -// -// STB_TEXTEDIT_DELETECHARS(obj,i,n) delete n characters starting at i -// STB_TEXTEDIT_INSERTCHARS(obj,i,c*,n) insert n characters at i (pointed to by STB_TEXTEDIT_CHARTYPE*) -// -// STB_TEXTEDIT_K_SHIFT a power of two that is or'd in to a keyboard input to represent the shift key -// -// STB_TEXTEDIT_K_LEFT keyboard input to move cursor left -// STB_TEXTEDIT_K_RIGHT keyboard input to move cursor right -// STB_TEXTEDIT_K_UP keyboard input to move cursor up -// STB_TEXTEDIT_K_DOWN keyboard input to move cursor down -// STB_TEXTEDIT_K_PGUP keyboard input to move cursor up a page -// STB_TEXTEDIT_K_PGDOWN keyboard input to move cursor down a page -// STB_TEXTEDIT_K_LINESTART keyboard input to move cursor to start of line // e.g. HOME -// STB_TEXTEDIT_K_LINEEND keyboard input to move cursor to end of line // e.g. END -// STB_TEXTEDIT_K_TEXTSTART keyboard input to move cursor to start of text // e.g. ctrl-HOME -// STB_TEXTEDIT_K_TEXTEND keyboard input to move cursor to end of text // e.g. ctrl-END -// STB_TEXTEDIT_K_DELETE keyboard input to delete selection or character under cursor -// STB_TEXTEDIT_K_BACKSPACE keyboard input to delete selection or character left of cursor -// STB_TEXTEDIT_K_UNDO keyboard input to perform undo -// STB_TEXTEDIT_K_REDO keyboard input to perform redo -// -// Optional: -// STB_TEXTEDIT_K_INSERT keyboard input to toggle insert mode -// STB_TEXTEDIT_IS_SPACE(ch) true if character is whitespace (e.g. 'isspace'), -// required for default WORDLEFT/WORDRIGHT handlers -// STB_TEXTEDIT_MOVEWORDLEFT(obj,i) custom handler for WORDLEFT, returns index to move cursor to -// STB_TEXTEDIT_MOVEWORDRIGHT(obj,i) custom handler for WORDRIGHT, returns index to move cursor to -// STB_TEXTEDIT_K_WORDLEFT keyboard input to move cursor left one word // e.g. ctrl-LEFT -// STB_TEXTEDIT_K_WORDRIGHT keyboard input to move cursor right one word // e.g. ctrl-RIGHT -// STB_TEXTEDIT_K_LINESTART2 secondary keyboard input to move cursor to start of line -// STB_TEXTEDIT_K_LINEEND2 secondary keyboard input to move cursor to end of line -// STB_TEXTEDIT_K_TEXTSTART2 secondary keyboard input to move cursor to start of text -// STB_TEXTEDIT_K_TEXTEND2 secondary keyboard input to move cursor to end of text -// -// Keyboard input must be encoded as a single integer value; e.g. a character code -// and some bitflags that represent shift states. to simplify the interface, SHIFT must -// be a bitflag, so we can test the shifted state of cursor movements to allow selection, -// i.e. (STB_TEXTEDIT_K_RIGHT|STB_TEXTEDIT_K_SHIFT) should be shifted right-arrow. -// -// You can encode other things, such as CONTROL or ALT, in additional bits, and -// then test for their presence in e.g. STB_TEXTEDIT_K_WORDLEFT. For example, -// my Windows implementations add an additional CONTROL bit, and an additional KEYDOWN -// bit. Then all of the STB_TEXTEDIT_K_ values bitwise-or in the KEYDOWN bit, -// and I pass both WM_KEYDOWN and WM_CHAR events to the "key" function in the -// API below. The control keys will only match WM_KEYDOWN events because of the -// keydown bit I add, and STB_TEXTEDIT_KEYTOTEXT only tests for the KEYDOWN -// bit so it only decodes WM_CHAR events. -// -// STB_TEXTEDIT_LAYOUTROW returns information about the shape of one displayed -// row of characters assuming they start on the i'th character--the width and -// the height and the number of characters consumed. This allows this library -// to traverse the entire layout incrementally. You need to compute word-wrapping -// here. -// -// Each textfield keeps its own insert mode state, which is not how normal -// applications work. To keep an app-wide insert mode, update/copy the -// "insert_mode" field of STB_TexteditState before/after calling API functions. -// -// API -// -// void stb_textedit_initialize_state(STB_TexteditState *state, int is_single_line) -// -// void stb_textedit_click(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y) -// void stb_textedit_drag(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y) -// int stb_textedit_cut(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) -// int stb_textedit_paste(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_CHARTYPE *text, int len) -// void stb_textedit_key(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXEDIT_KEYTYPE key) -// -// Each of these functions potentially updates the string and updates the -// state. -// -// initialize_state: -// set the textedit state to a known good default state when initially -// constructing the textedit. -// -// click: -// call this with the mouse x,y on a mouse down; it will update the cursor -// and reset the selection start/end to the cursor point. the x,y must -// be relative to the text widget, with (0,0) being the top left. -// -// drag: -// call this with the mouse x,y on a mouse drag/up; it will update the -// cursor and the selection end point -// -// cut: -// call this to delete the current selection; returns true if there was -// one. you should FIRST copy the current selection to the system paste buffer. -// (To copy, just copy the current selection out of the string yourself.) -// -// paste: -// call this to paste text at the current cursor point or over the current -// selection if there is one. -// -// key: -// call this for keyboard inputs sent to the textfield. you can use it -// for "key down" events or for "translated" key events. if you need to -// do both (as in Win32), or distinguish Unicode characters from control -// inputs, set a high bit to distinguish the two; then you can define the -// various definitions like STB_TEXTEDIT_K_LEFT have the is-key-event bit -// set, and make STB_TEXTEDIT_KEYTOCHAR check that the is-key-event bit is -// clear. STB_TEXTEDIT_KEYTYPE defaults to int, but you can #define it to -// anything other type you wante before including. -// -// -// When rendering, you can read the cursor position and selection state from -// the STB_TexteditState. -// -// -// Notes: -// -// This is designed to be usable in IMGUI, so it allows for the possibility of -// running in an IMGUI that has NOT cached the multi-line layout. For this -// reason, it provides an interface that is compatible with computing the -// layout incrementally--we try to make sure we make as few passes through -// as possible. (For example, to locate the mouse pointer in the text, we -// could define functions that return the X and Y positions of characters -// and binary search Y and then X, but if we're doing dynamic layout this -// will run the layout algorithm many times, so instead we manually search -// forward in one pass. Similar logic applies to e.g. up-arrow and -// down-arrow movement.) -// -// If it's run in a widget that *has* cached the layout, then this is less -// efficient, but it's not horrible on modern computers. But you wouldn't -// want to edit million-line files with it. - - -//////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////// -//// -//// Header-file mode -//// -//// - -#ifndef INCLUDE_STB_TEXTEDIT_H -#define INCLUDE_STB_TEXTEDIT_H - -//////////////////////////////////////////////////////////////////////// -// -// STB_TexteditState -// -// Definition of STB_TexteditState which you should store -// per-textfield; it includes cursor position, selection state, -// and undo state. -// - -#ifndef STB_TEXTEDIT_UNDOSTATECOUNT -#define STB_TEXTEDIT_UNDOSTATECOUNT 99 -#endif -#ifndef STB_TEXTEDIT_UNDOCHARCOUNT -#define STB_TEXTEDIT_UNDOCHARCOUNT 999 -#endif -#ifndef STB_TEXTEDIT_CHARTYPE -#define STB_TEXTEDIT_CHARTYPE int -#endif -#ifndef STB_TEXTEDIT_POSITIONTYPE -#define STB_TEXTEDIT_POSITIONTYPE int -#endif - -typedef struct -{ - // private data - STB_TEXTEDIT_POSITIONTYPE where; - STB_TEXTEDIT_POSITIONTYPE insert_length; - STB_TEXTEDIT_POSITIONTYPE delete_length; - int char_storage; -} StbUndoRecord; - -typedef struct -{ - // private data - StbUndoRecord undo_rec [STB_TEXTEDIT_UNDOSTATECOUNT]; - STB_TEXTEDIT_CHARTYPE undo_char[STB_TEXTEDIT_UNDOCHARCOUNT]; - short undo_point, redo_point; - int undo_char_point, redo_char_point; -} StbUndoState; - -typedef struct -{ - ///////////////////// - // - // public data - // - - int cursor; - // position of the text cursor within the string - - int select_start; // selection start point - int select_end; - // selection start and end point in characters; if equal, no selection. - // note that start may be less than or greater than end (e.g. when - // dragging the mouse, start is where the initial click was, and you - // can drag in either direction) - - unsigned char insert_mode; - // each textfield keeps its own insert mode state. to keep an app-wide - // insert mode, copy this value in/out of the app state - - int row_count_per_page; - // page size in number of row. - // this value MUST be set to >0 for pageup or pagedown in multilines documents. - - ///////////////////// - // - // private data - // - unsigned char cursor_at_end_of_line; // not implemented yet - unsigned char initialized; - unsigned char has_preferred_x; - unsigned char single_line; - unsigned char padding1, padding2, padding3; - float preferred_x; // this determines where the cursor up/down tries to seek to along x - StbUndoState undostate; -} STB_TexteditState; - - -//////////////////////////////////////////////////////////////////////// -// -// StbTexteditRow -// -// Result of layout query, used by stb_textedit to determine where -// the text in each row is. - -// result of layout query -typedef struct -{ - float x0,x1; // starting x location, end x location (allows for align=right, etc) - float baseline_y_delta; // position of baseline relative to previous row's baseline - float ymin,ymax; // height of row above and below baseline - int num_chars; -} StbTexteditRow; -#endif //INCLUDE_STB_TEXTEDIT_H - - -//////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////// -//// -//// Implementation mode -//// -//// - - -// implementation isn't include-guarded, since it might have indirectly -// included just the "header" portion -#ifdef STB_TEXTEDIT_IMPLEMENTATION - -#ifndef STB_TEXTEDIT_memmove -#include -#define STB_TEXTEDIT_memmove memmove -#endif - - -///////////////////////////////////////////////////////////////////////////// -// -// Mouse input handling -// - -// traverse the layout to locate the nearest character to a display position -static int stb_text_locate_coord(STB_TEXTEDIT_STRING *str, float x, float y) -{ - StbTexteditRow r; - int n = STB_TEXTEDIT_STRINGLEN(str); - float base_y = 0, prev_x; - int i=0, k; - - r.x0 = r.x1 = 0; - r.ymin = r.ymax = 0; - r.num_chars = 0; - - // search rows to find one that straddles 'y' - while (i < n) { - STB_TEXTEDIT_LAYOUTROW(&r, str, i); - if (r.num_chars <= 0) - return n; - - if (i==0 && y < base_y + r.ymin) - return 0; - - if (y < base_y + r.ymax) - break; - - i += r.num_chars; - base_y += r.baseline_y_delta; - } - - // below all text, return 'after' last character - if (i >= n) - return n; - - // check if it's before the beginning of the line - if (x < r.x0) - return i; - - // check if it's before the end of the line - if (x < r.x1) { - // search characters in row for one that straddles 'x' - prev_x = r.x0; - for (k=0; k < r.num_chars; ++k) { - float w = STB_TEXTEDIT_GETWIDTH(str, i, k); - if (x < prev_x+w) { - if (x < prev_x+w/2) - return k+i; - else - return k+i+1; - } - prev_x += w; - } - // shouldn't happen, but if it does, fall through to end-of-line case - } - - // if the last character is a newline, return that. otherwise return 'after' the last character - if (STB_TEXTEDIT_GETCHAR(str, i+r.num_chars-1) == STB_TEXTEDIT_NEWLINE) - return i+r.num_chars-1; - else - return i+r.num_chars; -} - -// API click: on mouse down, move the cursor to the clicked location, and reset the selection -static void stb_textedit_click(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y) -{ - // In single-line mode, just always make y = 0. This lets the drag keep working if the mouse - // goes off the top or bottom of the text - if( state->single_line ) - { - StbTexteditRow r; - STB_TEXTEDIT_LAYOUTROW(&r, str, 0); - y = r.ymin; - } - - state->cursor = stb_text_locate_coord(str, x, y); - state->select_start = state->cursor; - state->select_end = state->cursor; - state->has_preferred_x = 0; -} - -// API drag: on mouse drag, move the cursor and selection endpoint to the clicked location -static void stb_textedit_drag(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, float x, float y) -{ - int p = 0; - - // In single-line mode, just always make y = 0. This lets the drag keep working if the mouse - // goes off the top or bottom of the text - if( state->single_line ) - { - StbTexteditRow r; - STB_TEXTEDIT_LAYOUTROW(&r, str, 0); - y = r.ymin; - } - - if (state->select_start == state->select_end) - state->select_start = state->cursor; - - p = stb_text_locate_coord(str, x, y); - state->cursor = state->select_end = p; -} - -///////////////////////////////////////////////////////////////////////////// -// -// Keyboard input handling -// - -// forward declarations -static void stb_text_undo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state); -static void stb_text_redo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state); -static void stb_text_makeundo_delete(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int length); -static void stb_text_makeundo_insert(STB_TexteditState *state, int where, int length); -static void stb_text_makeundo_replace(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int old_length, int new_length); - -typedef struct -{ - float x,y; // position of n'th character - float height; // height of line - int first_char, length; // first char of row, and length - int prev_first; // first char of previous row -} StbFindState; - -// find the x/y location of a character, and remember info about the previous row in -// case we get a move-up event (for page up, we'll have to rescan) -static void stb_textedit_find_charpos(StbFindState *find, STB_TEXTEDIT_STRING *str, int n, int single_line) -{ - StbTexteditRow r; - int prev_start = 0; - int z = STB_TEXTEDIT_STRINGLEN(str); - int i=0, first; - - if (n == z) { - // if it's at the end, then find the last line -- simpler than trying to - // explicitly handle this case in the regular code - if (single_line) { - STB_TEXTEDIT_LAYOUTROW(&r, str, 0); - find->y = 0; - find->first_char = 0; - find->length = z; - find->height = r.ymax - r.ymin; - find->x = r.x1; - } else { - find->y = 0; - find->x = 0; - find->height = 1; - while (i < z) { - STB_TEXTEDIT_LAYOUTROW(&r, str, i); - prev_start = i; - i += r.num_chars; - } - find->first_char = i; - find->length = 0; - find->prev_first = prev_start; - } - return; - } - - // search rows to find the one that straddles character n - find->y = 0; - - for(;;) { - STB_TEXTEDIT_LAYOUTROW(&r, str, i); - if (n < i + r.num_chars) - break; - prev_start = i; - i += r.num_chars; - find->y += r.baseline_y_delta; - } - - find->first_char = first = i; - find->length = r.num_chars; - find->height = r.ymax - r.ymin; - find->prev_first = prev_start; - - // now scan to find xpos - find->x = r.x0; - for (i=0; first+i < n; ++i) - find->x += STB_TEXTEDIT_GETWIDTH(str, first, i); -} - -#define STB_TEXT_HAS_SELECTION(s) ((s)->select_start != (s)->select_end) - -// make the selection/cursor state valid if client altered the string -static void stb_textedit_clamp(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) -{ - int n = STB_TEXTEDIT_STRINGLEN(str); - if (STB_TEXT_HAS_SELECTION(state)) { - if (state->select_start > n) state->select_start = n; - if (state->select_end > n) state->select_end = n; - // if clamping forced them to be equal, move the cursor to match - if (state->select_start == state->select_end) - state->cursor = state->select_start; - } - if (state->cursor > n) state->cursor = n; -} - -// delete characters while updating undo -static void stb_textedit_delete(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int len) -{ - stb_text_makeundo_delete(str, state, where, len); - STB_TEXTEDIT_DELETECHARS(str, where, len); - state->has_preferred_x = 0; -} - -// delete the section -static void stb_textedit_delete_selection(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) -{ - stb_textedit_clamp(str, state); - if (STB_TEXT_HAS_SELECTION(state)) { - if (state->select_start < state->select_end) { - stb_textedit_delete(str, state, state->select_start, state->select_end - state->select_start); - state->select_end = state->cursor = state->select_start; - } else { - stb_textedit_delete(str, state, state->select_end, state->select_start - state->select_end); - state->select_start = state->cursor = state->select_end; - } - state->has_preferred_x = 0; - } -} - -// canoncialize the selection so start <= end -static void stb_textedit_sortselection(STB_TexteditState *state) -{ - if (state->select_end < state->select_start) { - int temp = state->select_end; - state->select_end = state->select_start; - state->select_start = temp; - } -} - -// move cursor to first character of selection -static void stb_textedit_move_to_first(STB_TexteditState *state) -{ - if (STB_TEXT_HAS_SELECTION(state)) { - stb_textedit_sortselection(state); - state->cursor = state->select_start; - state->select_end = state->select_start; - state->has_preferred_x = 0; - } -} - -// move cursor to last character of selection -static void stb_textedit_move_to_last(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) -{ - if (STB_TEXT_HAS_SELECTION(state)) { - stb_textedit_sortselection(state); - stb_textedit_clamp(str, state); - state->cursor = state->select_end; - state->select_start = state->select_end; - state->has_preferred_x = 0; - } -} - -#ifdef STB_TEXTEDIT_IS_SPACE -static int is_word_boundary( STB_TEXTEDIT_STRING *str, int idx ) -{ - return idx > 0 ? (STB_TEXTEDIT_IS_SPACE( STB_TEXTEDIT_GETCHAR(str,idx-1) ) && !STB_TEXTEDIT_IS_SPACE( STB_TEXTEDIT_GETCHAR(str, idx) ) ) : 1; -} - -#ifndef STB_TEXTEDIT_MOVEWORDLEFT -static int stb_textedit_move_to_word_previous( STB_TEXTEDIT_STRING *str, int c ) -{ - --c; // always move at least one character - while( c >= 0 && !is_word_boundary( str, c ) ) - --c; - - if( c < 0 ) - c = 0; - - return c; -} -#define STB_TEXTEDIT_MOVEWORDLEFT stb_textedit_move_to_word_previous -#endif - -#ifndef STB_TEXTEDIT_MOVEWORDRIGHT -static int stb_textedit_move_to_word_next( STB_TEXTEDIT_STRING *str, int c ) -{ - const int len = STB_TEXTEDIT_STRINGLEN(str); - ++c; // always move at least one character - while( c < len && !is_word_boundary( str, c ) ) - ++c; - - if( c > len ) - c = len; - - return c; -} -#define STB_TEXTEDIT_MOVEWORDRIGHT stb_textedit_move_to_word_next -#endif - -#endif - -// update selection and cursor to match each other -static void stb_textedit_prep_selection_at_cursor(STB_TexteditState *state) -{ - if (!STB_TEXT_HAS_SELECTION(state)) - state->select_start = state->select_end = state->cursor; - else - state->cursor = state->select_end; -} - -// API cut: delete selection -static int stb_textedit_cut(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) -{ - if (STB_TEXT_HAS_SELECTION(state)) { - stb_textedit_delete_selection(str,state); // implicitly clamps - state->has_preferred_x = 0; - return 1; - } - return 0; -} - -// API paste: replace existing selection with passed-in text -static int stb_textedit_paste_internal(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_CHARTYPE *text, int len) -{ - // if there's a selection, the paste should delete it - stb_textedit_clamp(str, state); - stb_textedit_delete_selection(str,state); - // try to insert the characters - if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, text, len)) { - stb_text_makeundo_insert(state, state->cursor, len); - state->cursor += len; - state->has_preferred_x = 0; - return 1; - } - // [DEAR IMGUI] - //// remove the undo since we didn't actually insert the characters - //if (state->undostate.undo_point) - // --state->undostate.undo_point; - // note: paste failure will leave deleted selection, may be restored with an undo (see https://github.com/nothings/stb/issues/734 for details) - return 0; -} - -#ifndef STB_TEXTEDIT_KEYTYPE -#define STB_TEXTEDIT_KEYTYPE int -#endif - -// API key: process a keyboard input -static void stb_textedit_key(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_KEYTYPE key) -{ -retry: - switch (key) { - default: { - int c = STB_TEXTEDIT_KEYTOTEXT(key); - if (c > 0) { - STB_TEXTEDIT_CHARTYPE ch = (STB_TEXTEDIT_CHARTYPE) c; - - // can't add newline in single-line mode - if (c == '\n' && state->single_line) - break; - - if (state->insert_mode && !STB_TEXT_HAS_SELECTION(state) && state->cursor < STB_TEXTEDIT_STRINGLEN(str)) { - stb_text_makeundo_replace(str, state, state->cursor, 1, 1); - STB_TEXTEDIT_DELETECHARS(str, state->cursor, 1); - if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, &ch, 1)) { - ++state->cursor; - state->has_preferred_x = 0; - } - } else { - stb_textedit_delete_selection(str,state); // implicitly clamps - if (STB_TEXTEDIT_INSERTCHARS(str, state->cursor, &ch, 1)) { - stb_text_makeundo_insert(state, state->cursor, 1); - ++state->cursor; - state->has_preferred_x = 0; - } - } - } - break; - } - -#ifdef STB_TEXTEDIT_K_INSERT - case STB_TEXTEDIT_K_INSERT: - state->insert_mode = !state->insert_mode; - break; -#endif - - case STB_TEXTEDIT_K_UNDO: - stb_text_undo(str, state); - state->has_preferred_x = 0; - break; - - case STB_TEXTEDIT_K_REDO: - stb_text_redo(str, state); - state->has_preferred_x = 0; - break; - - case STB_TEXTEDIT_K_LEFT: - // if currently there's a selection, move cursor to start of selection - if (STB_TEXT_HAS_SELECTION(state)) - stb_textedit_move_to_first(state); - else - if (state->cursor > 0) - --state->cursor; - state->has_preferred_x = 0; - break; - - case STB_TEXTEDIT_K_RIGHT: - // if currently there's a selection, move cursor to end of selection - if (STB_TEXT_HAS_SELECTION(state)) - stb_textedit_move_to_last(str, state); - else - ++state->cursor; - stb_textedit_clamp(str, state); - state->has_preferred_x = 0; - break; - - case STB_TEXTEDIT_K_LEFT | STB_TEXTEDIT_K_SHIFT: - stb_textedit_clamp(str, state); - stb_textedit_prep_selection_at_cursor(state); - // move selection left - if (state->select_end > 0) - --state->select_end; - state->cursor = state->select_end; - state->has_preferred_x = 0; - break; - -#ifdef STB_TEXTEDIT_MOVEWORDLEFT - case STB_TEXTEDIT_K_WORDLEFT: - if (STB_TEXT_HAS_SELECTION(state)) - stb_textedit_move_to_first(state); - else { - state->cursor = STB_TEXTEDIT_MOVEWORDLEFT(str, state->cursor); - stb_textedit_clamp( str, state ); - } - break; - - case STB_TEXTEDIT_K_WORDLEFT | STB_TEXTEDIT_K_SHIFT: - if( !STB_TEXT_HAS_SELECTION( state ) ) - stb_textedit_prep_selection_at_cursor(state); - - state->cursor = STB_TEXTEDIT_MOVEWORDLEFT(str, state->cursor); - state->select_end = state->cursor; - - stb_textedit_clamp( str, state ); - break; -#endif - -#ifdef STB_TEXTEDIT_MOVEWORDRIGHT - case STB_TEXTEDIT_K_WORDRIGHT: - if (STB_TEXT_HAS_SELECTION(state)) - stb_textedit_move_to_last(str, state); - else { - state->cursor = STB_TEXTEDIT_MOVEWORDRIGHT(str, state->cursor); - stb_textedit_clamp( str, state ); - } - break; - - case STB_TEXTEDIT_K_WORDRIGHT | STB_TEXTEDIT_K_SHIFT: - if( !STB_TEXT_HAS_SELECTION( state ) ) - stb_textedit_prep_selection_at_cursor(state); - - state->cursor = STB_TEXTEDIT_MOVEWORDRIGHT(str, state->cursor); - state->select_end = state->cursor; - - stb_textedit_clamp( str, state ); - break; -#endif - - case STB_TEXTEDIT_K_RIGHT | STB_TEXTEDIT_K_SHIFT: - stb_textedit_prep_selection_at_cursor(state); - // move selection right - ++state->select_end; - stb_textedit_clamp(str, state); - state->cursor = state->select_end; - state->has_preferred_x = 0; - break; - - case STB_TEXTEDIT_K_DOWN: - case STB_TEXTEDIT_K_DOWN | STB_TEXTEDIT_K_SHIFT: - case STB_TEXTEDIT_K_PGDOWN: - case STB_TEXTEDIT_K_PGDOWN | STB_TEXTEDIT_K_SHIFT: { - StbFindState find; - StbTexteditRow row; - int i, j, sel = (key & STB_TEXTEDIT_K_SHIFT) != 0; - int is_page = (key & ~STB_TEXTEDIT_K_SHIFT) == STB_TEXTEDIT_K_PGDOWN; - int row_count = is_page ? state->row_count_per_page : 1; - - if (!is_page && state->single_line) { - // on windows, up&down in single-line behave like left&right - key = STB_TEXTEDIT_K_RIGHT | (key & STB_TEXTEDIT_K_SHIFT); - goto retry; - } - - if (sel) - stb_textedit_prep_selection_at_cursor(state); - else if (STB_TEXT_HAS_SELECTION(state)) - stb_textedit_move_to_last(str, state); - - // compute current position of cursor point - stb_textedit_clamp(str, state); - stb_textedit_find_charpos(&find, str, state->cursor, state->single_line); - - for (j = 0; j < row_count; ++j) { - float x, goal_x = state->has_preferred_x ? state->preferred_x : find.x; - int start = find.first_char + find.length; - - if (find.length == 0) - break; - - // [DEAR IMGUI] - // going down while being on the last line shouldn't bring us to that line end - if (STB_TEXTEDIT_GETCHAR(str, find.first_char + find.length - 1) != STB_TEXTEDIT_NEWLINE) - break; - - // now find character position down a row - state->cursor = start; - STB_TEXTEDIT_LAYOUTROW(&row, str, state->cursor); - x = row.x0; - for (i=0; i < row.num_chars; ++i) { - float dx = STB_TEXTEDIT_GETWIDTH(str, start, i); - #ifdef STB_TEXTEDIT_GETWIDTH_NEWLINE - if (dx == STB_TEXTEDIT_GETWIDTH_NEWLINE) - break; - #endif - x += dx; - if (x > goal_x) - break; - ++state->cursor; - } - stb_textedit_clamp(str, state); - - state->has_preferred_x = 1; - state->preferred_x = goal_x; - - if (sel) - state->select_end = state->cursor; - - // go to next line - find.first_char = find.first_char + find.length; - find.length = row.num_chars; - } - break; - } - - case STB_TEXTEDIT_K_UP: - case STB_TEXTEDIT_K_UP | STB_TEXTEDIT_K_SHIFT: - case STB_TEXTEDIT_K_PGUP: - case STB_TEXTEDIT_K_PGUP | STB_TEXTEDIT_K_SHIFT: { - StbFindState find; - StbTexteditRow row; - int i, j, prev_scan, sel = (key & STB_TEXTEDIT_K_SHIFT) != 0; - int is_page = (key & ~STB_TEXTEDIT_K_SHIFT) == STB_TEXTEDIT_K_PGUP; - int row_count = is_page ? state->row_count_per_page : 1; - - if (!is_page && state->single_line) { - // on windows, up&down become left&right - key = STB_TEXTEDIT_K_LEFT | (key & STB_TEXTEDIT_K_SHIFT); - goto retry; - } - - if (sel) - stb_textedit_prep_selection_at_cursor(state); - else if (STB_TEXT_HAS_SELECTION(state)) - stb_textedit_move_to_first(state); - - // compute current position of cursor point - stb_textedit_clamp(str, state); - stb_textedit_find_charpos(&find, str, state->cursor, state->single_line); - - for (j = 0; j < row_count; ++j) { - float x, goal_x = state->has_preferred_x ? state->preferred_x : find.x; - - // can only go up if there's a previous row - if (find.prev_first == find.first_char) - break; - - // now find character position up a row - state->cursor = find.prev_first; - STB_TEXTEDIT_LAYOUTROW(&row, str, state->cursor); - x = row.x0; - for (i=0; i < row.num_chars; ++i) { - float dx = STB_TEXTEDIT_GETWIDTH(str, find.prev_first, i); - #ifdef STB_TEXTEDIT_GETWIDTH_NEWLINE - if (dx == STB_TEXTEDIT_GETWIDTH_NEWLINE) - break; - #endif - x += dx; - if (x > goal_x) - break; - ++state->cursor; - } - stb_textedit_clamp(str, state); - - state->has_preferred_x = 1; - state->preferred_x = goal_x; - - if (sel) - state->select_end = state->cursor; - - // go to previous line - // (we need to scan previous line the hard way. maybe we could expose this as a new API function?) - prev_scan = find.prev_first > 0 ? find.prev_first - 1 : 0; - while (prev_scan > 0 && STB_TEXTEDIT_GETCHAR(str, prev_scan - 1) != STB_TEXTEDIT_NEWLINE) - --prev_scan; - find.first_char = find.prev_first; - find.prev_first = prev_scan; - } - break; - } - - case STB_TEXTEDIT_K_DELETE: - case STB_TEXTEDIT_K_DELETE | STB_TEXTEDIT_K_SHIFT: - if (STB_TEXT_HAS_SELECTION(state)) - stb_textedit_delete_selection(str, state); - else { - int n = STB_TEXTEDIT_STRINGLEN(str); - if (state->cursor < n) - stb_textedit_delete(str, state, state->cursor, 1); - } - state->has_preferred_x = 0; - break; - - case STB_TEXTEDIT_K_BACKSPACE: - case STB_TEXTEDIT_K_BACKSPACE | STB_TEXTEDIT_K_SHIFT: - if (STB_TEXT_HAS_SELECTION(state)) - stb_textedit_delete_selection(str, state); - else { - stb_textedit_clamp(str, state); - if (state->cursor > 0) { - stb_textedit_delete(str, state, state->cursor-1, 1); - --state->cursor; - } - } - state->has_preferred_x = 0; - break; - -#ifdef STB_TEXTEDIT_K_TEXTSTART2 - case STB_TEXTEDIT_K_TEXTSTART2: -#endif - case STB_TEXTEDIT_K_TEXTSTART: - state->cursor = state->select_start = state->select_end = 0; - state->has_preferred_x = 0; - break; - -#ifdef STB_TEXTEDIT_K_TEXTEND2 - case STB_TEXTEDIT_K_TEXTEND2: -#endif - case STB_TEXTEDIT_K_TEXTEND: - state->cursor = STB_TEXTEDIT_STRINGLEN(str); - state->select_start = state->select_end = 0; - state->has_preferred_x = 0; - break; - -#ifdef STB_TEXTEDIT_K_TEXTSTART2 - case STB_TEXTEDIT_K_TEXTSTART2 | STB_TEXTEDIT_K_SHIFT: -#endif - case STB_TEXTEDIT_K_TEXTSTART | STB_TEXTEDIT_K_SHIFT: - stb_textedit_prep_selection_at_cursor(state); - state->cursor = state->select_end = 0; - state->has_preferred_x = 0; - break; - -#ifdef STB_TEXTEDIT_K_TEXTEND2 - case STB_TEXTEDIT_K_TEXTEND2 | STB_TEXTEDIT_K_SHIFT: -#endif - case STB_TEXTEDIT_K_TEXTEND | STB_TEXTEDIT_K_SHIFT: - stb_textedit_prep_selection_at_cursor(state); - state->cursor = state->select_end = STB_TEXTEDIT_STRINGLEN(str); - state->has_preferred_x = 0; - break; - - -#ifdef STB_TEXTEDIT_K_LINESTART2 - case STB_TEXTEDIT_K_LINESTART2: -#endif - case STB_TEXTEDIT_K_LINESTART: - stb_textedit_clamp(str, state); - stb_textedit_move_to_first(state); - if (state->single_line) - state->cursor = 0; - else while (state->cursor > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) != STB_TEXTEDIT_NEWLINE) - --state->cursor; - state->has_preferred_x = 0; - break; - -#ifdef STB_TEXTEDIT_K_LINEEND2 - case STB_TEXTEDIT_K_LINEEND2: -#endif - case STB_TEXTEDIT_K_LINEEND: { - int n = STB_TEXTEDIT_STRINGLEN(str); - stb_textedit_clamp(str, state); - stb_textedit_move_to_first(state); - if (state->single_line) - state->cursor = n; - else while (state->cursor < n && STB_TEXTEDIT_GETCHAR(str, state->cursor) != STB_TEXTEDIT_NEWLINE) - ++state->cursor; - state->has_preferred_x = 0; - break; - } - -#ifdef STB_TEXTEDIT_K_LINESTART2 - case STB_TEXTEDIT_K_LINESTART2 | STB_TEXTEDIT_K_SHIFT: -#endif - case STB_TEXTEDIT_K_LINESTART | STB_TEXTEDIT_K_SHIFT: - stb_textedit_clamp(str, state); - stb_textedit_prep_selection_at_cursor(state); - if (state->single_line) - state->cursor = 0; - else while (state->cursor > 0 && STB_TEXTEDIT_GETCHAR(str, state->cursor-1) != STB_TEXTEDIT_NEWLINE) - --state->cursor; - state->select_end = state->cursor; - state->has_preferred_x = 0; - break; - -#ifdef STB_TEXTEDIT_K_LINEEND2 - case STB_TEXTEDIT_K_LINEEND2 | STB_TEXTEDIT_K_SHIFT: -#endif - case STB_TEXTEDIT_K_LINEEND | STB_TEXTEDIT_K_SHIFT: { - int n = STB_TEXTEDIT_STRINGLEN(str); - stb_textedit_clamp(str, state); - stb_textedit_prep_selection_at_cursor(state); - if (state->single_line) - state->cursor = n; - else while (state->cursor < n && STB_TEXTEDIT_GETCHAR(str, state->cursor) != STB_TEXTEDIT_NEWLINE) - ++state->cursor; - state->select_end = state->cursor; - state->has_preferred_x = 0; - break; - } - } -} - -///////////////////////////////////////////////////////////////////////////// -// -// Undo processing -// -// @OPTIMIZE: the undo/redo buffer should be circular - -static void stb_textedit_flush_redo(StbUndoState *state) -{ - state->redo_point = STB_TEXTEDIT_UNDOSTATECOUNT; - state->redo_char_point = STB_TEXTEDIT_UNDOCHARCOUNT; -} - -// discard the oldest entry in the undo list -static void stb_textedit_discard_undo(StbUndoState *state) -{ - if (state->undo_point > 0) { - // if the 0th undo state has characters, clean those up - if (state->undo_rec[0].char_storage >= 0) { - int n = state->undo_rec[0].insert_length, i; - // delete n characters from all other records - state->undo_char_point -= n; - STB_TEXTEDIT_memmove(state->undo_char, state->undo_char + n, (size_t) (state->undo_char_point*sizeof(STB_TEXTEDIT_CHARTYPE))); - for (i=0; i < state->undo_point; ++i) - if (state->undo_rec[i].char_storage >= 0) - state->undo_rec[i].char_storage -= n; // @OPTIMIZE: get rid of char_storage and infer it - } - --state->undo_point; - STB_TEXTEDIT_memmove(state->undo_rec, state->undo_rec+1, (size_t) (state->undo_point*sizeof(state->undo_rec[0]))); - } -} - -// discard the oldest entry in the redo list--it's bad if this -// ever happens, but because undo & redo have to store the actual -// characters in different cases, the redo character buffer can -// fill up even though the undo buffer didn't -static void stb_textedit_discard_redo(StbUndoState *state) -{ - int k = STB_TEXTEDIT_UNDOSTATECOUNT-1; - - if (state->redo_point <= k) { - // if the k'th undo state has characters, clean those up - if (state->undo_rec[k].char_storage >= 0) { - int n = state->undo_rec[k].insert_length, i; - // move the remaining redo character data to the end of the buffer - state->redo_char_point += n; - STB_TEXTEDIT_memmove(state->undo_char + state->redo_char_point, state->undo_char + state->redo_char_point-n, (size_t) ((STB_TEXTEDIT_UNDOCHARCOUNT - state->redo_char_point)*sizeof(STB_TEXTEDIT_CHARTYPE))); - // adjust the position of all the other records to account for above memmove - for (i=state->redo_point; i < k; ++i) - if (state->undo_rec[i].char_storage >= 0) - state->undo_rec[i].char_storage += n; - } - // now move all the redo records towards the end of the buffer; the first one is at 'redo_point' - // [DEAR IMGUI] - size_t move_size = (size_t)((STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_point - 1) * sizeof(state->undo_rec[0])); - const char* buf_begin = (char*)state->undo_rec; (void)buf_begin; - const char* buf_end = (char*)state->undo_rec + sizeof(state->undo_rec); (void)buf_end; - IM_ASSERT(((char*)(state->undo_rec + state->redo_point)) >= buf_begin); - IM_ASSERT(((char*)(state->undo_rec + state->redo_point + 1) + move_size) <= buf_end); - STB_TEXTEDIT_memmove(state->undo_rec + state->redo_point+1, state->undo_rec + state->redo_point, move_size); - - // now move redo_point to point to the new one - ++state->redo_point; - } -} - -static StbUndoRecord *stb_text_create_undo_record(StbUndoState *state, int numchars) -{ - // any time we create a new undo record, we discard redo - stb_textedit_flush_redo(state); - - // if we have no free records, we have to make room, by sliding the - // existing records down - if (state->undo_point == STB_TEXTEDIT_UNDOSTATECOUNT) - stb_textedit_discard_undo(state); - - // if the characters to store won't possibly fit in the buffer, we can't undo - if (numchars > STB_TEXTEDIT_UNDOCHARCOUNT) { - state->undo_point = 0; - state->undo_char_point = 0; - return NULL; - } - - // if we don't have enough free characters in the buffer, we have to make room - while (state->undo_char_point + numchars > STB_TEXTEDIT_UNDOCHARCOUNT) - stb_textedit_discard_undo(state); - - return &state->undo_rec[state->undo_point++]; -} - -static STB_TEXTEDIT_CHARTYPE *stb_text_createundo(StbUndoState *state, int pos, int insert_len, int delete_len) -{ - StbUndoRecord *r = stb_text_create_undo_record(state, insert_len); - if (r == NULL) - return NULL; - - r->where = pos; - r->insert_length = (STB_TEXTEDIT_POSITIONTYPE) insert_len; - r->delete_length = (STB_TEXTEDIT_POSITIONTYPE) delete_len; - - if (insert_len == 0) { - r->char_storage = -1; - return NULL; - } else { - r->char_storage = state->undo_char_point; - state->undo_char_point += insert_len; - return &state->undo_char[r->char_storage]; - } -} - -static void stb_text_undo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) -{ - StbUndoState *s = &state->undostate; - StbUndoRecord u, *r; - if (s->undo_point == 0) - return; - - // we need to do two things: apply the undo record, and create a redo record - u = s->undo_rec[s->undo_point-1]; - r = &s->undo_rec[s->redo_point-1]; - r->char_storage = -1; - - r->insert_length = u.delete_length; - r->delete_length = u.insert_length; - r->where = u.where; - - if (u.delete_length) { - // if the undo record says to delete characters, then the redo record will - // need to re-insert the characters that get deleted, so we need to store - // them. - - // there are three cases: - // there's enough room to store the characters - // characters stored for *redoing* don't leave room for redo - // characters stored for *undoing* don't leave room for redo - // if the last is true, we have to bail - - if (s->undo_char_point + u.delete_length >= STB_TEXTEDIT_UNDOCHARCOUNT) { - // the undo records take up too much character space; there's no space to store the redo characters - r->insert_length = 0; - } else { - int i; - - // there's definitely room to store the characters eventually - while (s->undo_char_point + u.delete_length > s->redo_char_point) { - // should never happen: - if (s->redo_point == STB_TEXTEDIT_UNDOSTATECOUNT) - return; - // there's currently not enough room, so discard a redo record - stb_textedit_discard_redo(s); - } - r = &s->undo_rec[s->redo_point-1]; - - r->char_storage = s->redo_char_point - u.delete_length; - s->redo_char_point = s->redo_char_point - u.delete_length; - - // now save the characters - for (i=0; i < u.delete_length; ++i) - s->undo_char[r->char_storage + i] = STB_TEXTEDIT_GETCHAR(str, u.where + i); - } - - // now we can carry out the deletion - STB_TEXTEDIT_DELETECHARS(str, u.where, u.delete_length); - } - - // check type of recorded action: - if (u.insert_length) { - // easy case: was a deletion, so we need to insert n characters - STB_TEXTEDIT_INSERTCHARS(str, u.where, &s->undo_char[u.char_storage], u.insert_length); - s->undo_char_point -= u.insert_length; - } - - state->cursor = u.where + u.insert_length; - - s->undo_point--; - s->redo_point--; -} - -static void stb_text_redo(STB_TEXTEDIT_STRING *str, STB_TexteditState *state) -{ - StbUndoState *s = &state->undostate; - StbUndoRecord *u, r; - if (s->redo_point == STB_TEXTEDIT_UNDOSTATECOUNT) - return; - - // we need to do two things: apply the redo record, and create an undo record - u = &s->undo_rec[s->undo_point]; - r = s->undo_rec[s->redo_point]; - - // we KNOW there must be room for the undo record, because the redo record - // was derived from an undo record - - u->delete_length = r.insert_length; - u->insert_length = r.delete_length; - u->where = r.where; - u->char_storage = -1; - - if (r.delete_length) { - // the redo record requires us to delete characters, so the undo record - // needs to store the characters - - if (s->undo_char_point + u->insert_length > s->redo_char_point) { - u->insert_length = 0; - u->delete_length = 0; - } else { - int i; - u->char_storage = s->undo_char_point; - s->undo_char_point = s->undo_char_point + u->insert_length; - - // now save the characters - for (i=0; i < u->insert_length; ++i) - s->undo_char[u->char_storage + i] = STB_TEXTEDIT_GETCHAR(str, u->where + i); - } - - STB_TEXTEDIT_DELETECHARS(str, r.where, r.delete_length); - } - - if (r.insert_length) { - // easy case: need to insert n characters - STB_TEXTEDIT_INSERTCHARS(str, r.where, &s->undo_char[r.char_storage], r.insert_length); - s->redo_char_point += r.insert_length; - } - - state->cursor = r.where + r.insert_length; - - s->undo_point++; - s->redo_point++; -} - -static void stb_text_makeundo_insert(STB_TexteditState *state, int where, int length) -{ - stb_text_createundo(&state->undostate, where, 0, length); -} - -static void stb_text_makeundo_delete(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int length) -{ - int i; - STB_TEXTEDIT_CHARTYPE *p = stb_text_createundo(&state->undostate, where, length, 0); - if (p) { - for (i=0; i < length; ++i) - p[i] = STB_TEXTEDIT_GETCHAR(str, where+i); - } -} - -static void stb_text_makeundo_replace(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, int where, int old_length, int new_length) -{ - int i; - STB_TEXTEDIT_CHARTYPE *p = stb_text_createundo(&state->undostate, where, old_length, new_length); - if (p) { - for (i=0; i < old_length; ++i) - p[i] = STB_TEXTEDIT_GETCHAR(str, where+i); - } -} - -// reset the state to default -static void stb_textedit_clear_state(STB_TexteditState *state, int is_single_line) -{ - state->undostate.undo_point = 0; - state->undostate.undo_char_point = 0; - state->undostate.redo_point = STB_TEXTEDIT_UNDOSTATECOUNT; - state->undostate.redo_char_point = STB_TEXTEDIT_UNDOCHARCOUNT; - state->select_end = state->select_start = 0; - state->cursor = 0; - state->has_preferred_x = 0; - state->preferred_x = 0; - state->cursor_at_end_of_line = 0; - state->initialized = 1; - state->single_line = (unsigned char) is_single_line; - state->insert_mode = 0; - state->row_count_per_page = 0; -} - -// API initialize -static void stb_textedit_initialize_state(STB_TexteditState *state, int is_single_line) -{ - stb_textedit_clear_state(state, is_single_line); -} - -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif - -static int stb_textedit_paste(STB_TEXTEDIT_STRING *str, STB_TexteditState *state, STB_TEXTEDIT_CHARTYPE const *ctext, int len) -{ - return stb_textedit_paste_internal(str, state, (STB_TEXTEDIT_CHARTYPE *) ctext, len); -} - -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - -#endif//STB_TEXTEDIT_IMPLEMENTATION - -/* ------------------------------------------------------------------------------- -This software is available under 2 licenses -- choose whichever you prefer. ------------------------------------------------------------------------------- -ALTERNATIVE A - MIT License -Copyright (c) 2017 Sean Barrett -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. ------------------------------------------------------------------------------- -ALTERNATIVE B - Public Domain (www.unlicense.org) -This is free and unencumbered software released into the public domain. -Anyone is free to copy, modify, publish, use, compile, sell, or distribute this -software, either in source code form or as a compiled binary, for any purpose, -commercial or non-commercial, and by any means. -In jurisdictions that recognize copyright laws, the author or authors of this -software dedicate any and all copyright interest in the software to the public -domain. We make this dedication for the benefit of the public at large and to -the detriment of our heirs and successors. We intend this dedication to be an -overt act of relinquishment in perpetuity of all present and future rights to -this software under copyright law. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------- -*/ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imstb_truetype.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imstb_truetype.h deleted file mode 100644 index 48c2026..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/imstb_truetype.h +++ /dev/null @@ -1,4903 +0,0 @@ -// [DEAR IMGUI] -// This is a slightly modified version of stb_truetype.h 1.20. -// Mostly fixing for compiler and static analyzer warnings. -// Grep for [DEAR IMGUI] to find the changes. - -// stb_truetype.h - v1.20 - public domain -// authored from 2009-2016 by Sean Barrett / RAD Game Tools -// -// This library processes TrueType files: -// parse files -// extract glyph metrics -// extract glyph shapes -// render glyphs to one-channel bitmaps with antialiasing (box filter) -// render glyphs to one-channel SDF bitmaps (signed-distance field/function) -// -// Todo: -// non-MS cmaps -// crashproof on bad data -// hinting? (no longer patented) -// cleartype-style AA? -// optimize: use simple memory allocator for intermediates -// optimize: build edge-list directly from curves -// optimize: rasterize directly from curves? -// -// ADDITIONAL CONTRIBUTORS -// -// Mikko Mononen: compound shape support, more cmap formats -// Tor Andersson: kerning, subpixel rendering -// Dougall Johnson: OpenType / Type 2 font handling -// Daniel Ribeiro Maciel: basic GPOS-based kerning -// -// Misc other: -// Ryan Gordon -// Simon Glass -// github:IntellectualKitty -// Imanol Celaya -// Daniel Ribeiro Maciel -// -// Bug/warning reports/fixes: -// "Zer" on mollyrocket Fabian "ryg" Giesen -// Cass Everitt Martins Mozeiko -// stoiko (Haemimont Games) Cap Petschulat -// Brian Hook Omar Cornut -// Walter van Niftrik github:aloucks -// David Gow Peter LaValle -// David Given Sergey Popov -// Ivan-Assen Ivanov Giumo X. Clanjor -// Anthony Pesch Higor Euripedes -// Johan Duparc Thomas Fields -// Hou Qiming Derek Vinyard -// Rob Loach Cort Stratton -// Kenney Phillis Jr. github:oyvindjam -// Brian Costabile github:vassvik -// -// VERSION HISTORY -// -// 1.20 (2019-02-07) PackFontRange skips missing codepoints; GetScaleFontVMetrics() -// 1.19 (2018-02-11) GPOS kerning, STBTT_fmod -// 1.18 (2018-01-29) add missing function -// 1.17 (2017-07-23) make more arguments const; doc fix -// 1.16 (2017-07-12) SDF support -// 1.15 (2017-03-03) make more arguments const -// 1.14 (2017-01-16) num-fonts-in-TTC function -// 1.13 (2017-01-02) support OpenType fonts, certain Apple fonts -// 1.12 (2016-10-25) suppress warnings about casting away const with -Wcast-qual -// 1.11 (2016-04-02) fix unused-variable warning -// 1.10 (2016-04-02) user-defined fabs(); rare memory leak; remove duplicate typedef -// 1.09 (2016-01-16) warning fix; avoid crash on outofmem; use allocation userdata properly -// 1.08 (2015-09-13) document stbtt_Rasterize(); fixes for vertical & horizontal edges -// 1.07 (2015-08-01) allow PackFontRanges to accept arrays of sparse codepoints; -// variant PackFontRanges to pack and render in separate phases; -// fix stbtt_GetFontOFfsetForIndex (never worked for non-0 input?); -// fixed an assert() bug in the new rasterizer -// replace assert() with STBTT_assert() in new rasterizer -// -// Full history can be found at the end of this file. -// -// LICENSE -// -// See end of file for license information. -// -// USAGE -// -// Include this file in whatever places need to refer to it. In ONE C/C++ -// file, write: -// #define STB_TRUETYPE_IMPLEMENTATION -// before the #include of this file. This expands out the actual -// implementation into that C/C++ file. -// -// To make the implementation private to the file that generates the implementation, -// #define STBTT_STATIC -// -// Simple 3D API (don't ship this, but it's fine for tools and quick start) -// stbtt_BakeFontBitmap() -- bake a font to a bitmap for use as texture -// stbtt_GetBakedQuad() -- compute quad to draw for a given char -// -// Improved 3D API (more shippable): -// #include "stb_rect_pack.h" -- optional, but you really want it -// stbtt_PackBegin() -// stbtt_PackSetOversampling() -- for improved quality on small fonts -// stbtt_PackFontRanges() -- pack and renders -// stbtt_PackEnd() -// stbtt_GetPackedQuad() -// -// "Load" a font file from a memory buffer (you have to keep the buffer loaded) -// stbtt_InitFont() -// stbtt_GetFontOffsetForIndex() -- indexing for TTC font collections -// stbtt_GetNumberOfFonts() -- number of fonts for TTC font collections -// -// Render a unicode codepoint to a bitmap -// stbtt_GetCodepointBitmap() -- allocates and returns a bitmap -// stbtt_MakeCodepointBitmap() -- renders into bitmap you provide -// stbtt_GetCodepointBitmapBox() -- how big the bitmap must be -// -// Character advance/positioning -// stbtt_GetCodepointHMetrics() -// stbtt_GetFontVMetrics() -// stbtt_GetFontVMetricsOS2() -// stbtt_GetCodepointKernAdvance() -// -// Starting with version 1.06, the rasterizer was replaced with a new, -// faster and generally-more-precise rasterizer. The new rasterizer more -// accurately measures pixel coverage for anti-aliasing, except in the case -// where multiple shapes overlap, in which case it overestimates the AA pixel -// coverage. Thus, anti-aliasing of intersecting shapes may look wrong. If -// this turns out to be a problem, you can re-enable the old rasterizer with -// #define STBTT_RASTERIZER_VERSION 1 -// which will incur about a 15% speed hit. -// -// ADDITIONAL DOCUMENTATION -// -// Immediately after this block comment are a series of sample programs. -// -// After the sample programs is the "header file" section. This section -// includes documentation for each API function. -// -// Some important concepts to understand to use this library: -// -// Codepoint -// Characters are defined by unicode codepoints, e.g. 65 is -// uppercase A, 231 is lowercase c with a cedilla, 0x7e30 is -// the hiragana for "ma". -// -// Glyph -// A visual character shape (every codepoint is rendered as -// some glyph) -// -// Glyph index -// A font-specific integer ID representing a glyph -// -// Baseline -// Glyph shapes are defined relative to a baseline, which is the -// bottom of uppercase characters. Characters extend both above -// and below the baseline. -// -// Current Point -// As you draw text to the screen, you keep track of a "current point" -// which is the origin of each character. The current point's vertical -// position is the baseline. Even "baked fonts" use this model. -// -// Vertical Font Metrics -// The vertical qualities of the font, used to vertically position -// and space the characters. See docs for stbtt_GetFontVMetrics. -// -// Font Size in Pixels or Points -// The preferred interface for specifying font sizes in stb_truetype -// is to specify how tall the font's vertical extent should be in pixels. -// If that sounds good enough, skip the next paragraph. -// -// Most font APIs instead use "points", which are a common typographic -// measurement for describing font size, defined as 72 points per inch. -// stb_truetype provides a point API for compatibility. However, true -// "per inch" conventions don't make much sense on computer displays -// since different monitors have different number of pixels per -// inch. For example, Windows traditionally uses a convention that -// there are 96 pixels per inch, thus making 'inch' measurements have -// nothing to do with inches, and thus effectively defining a point to -// be 1.333 pixels. Additionally, the TrueType font data provides -// an explicit scale factor to scale a given font's glyphs to points, -// but the author has observed that this scale factor is often wrong -// for non-commercial fonts, thus making fonts scaled in points -// according to the TrueType spec incoherently sized in practice. -// -// DETAILED USAGE: -// -// Scale: -// Select how high you want the font to be, in points or pixels. -// Call ScaleForPixelHeight or ScaleForMappingEmToPixels to compute -// a scale factor SF that will be used by all other functions. -// -// Baseline: -// You need to select a y-coordinate that is the baseline of where -// your text will appear. Call GetFontBoundingBox to get the baseline-relative -// bounding box for all characters. SF*-y0 will be the distance in pixels -// that the worst-case character could extend above the baseline, so if -// you want the top edge of characters to appear at the top of the -// screen where y=0, then you would set the baseline to SF*-y0. -// -// Current point: -// Set the current point where the first character will appear. The -// first character could extend left of the current point; this is font -// dependent. You can either choose a current point that is the leftmost -// point and hope, or add some padding, or check the bounding box or -// left-side-bearing of the first character to be displayed and set -// the current point based on that. -// -// Displaying a character: -// Compute the bounding box of the character. It will contain signed values -// relative to . I.e. if it returns x0,y0,x1,y1, -// then the character should be displayed in the rectangle from -// to = 32 && *text < 128) { - stbtt_aligned_quad q; - stbtt_GetBakedQuad(cdata, 512,512, *text-32, &x,&y,&q,1);//1=opengl & d3d10+,0=d3d9 - glTexCoord2f(q.s0,q.t1); glVertex2f(q.x0,q.y0); - glTexCoord2f(q.s1,q.t1); glVertex2f(q.x1,q.y0); - glTexCoord2f(q.s1,q.t0); glVertex2f(q.x1,q.y1); - glTexCoord2f(q.s0,q.t0); glVertex2f(q.x0,q.y1); - } - ++text; - } - glEnd(); -} -#endif -// -// -////////////////////////////////////////////////////////////////////////////// -// -// Complete program (this compiles): get a single bitmap, print as ASCII art -// -#if 0 -#include -#define STB_TRUETYPE_IMPLEMENTATION // force following include to generate implementation -#include "stb_truetype.h" - -char ttf_buffer[1<<25]; - -int main(int argc, char **argv) -{ - stbtt_fontinfo font; - unsigned char *bitmap; - int w,h,i,j,c = (argc > 1 ? atoi(argv[1]) : 'a'), s = (argc > 2 ? atoi(argv[2]) : 20); - - fread(ttf_buffer, 1, 1<<25, fopen(argc > 3 ? argv[3] : "c:/windows/fonts/arialbd.ttf", "rb")); - - stbtt_InitFont(&font, ttf_buffer, stbtt_GetFontOffsetForIndex(ttf_buffer,0)); - bitmap = stbtt_GetCodepointBitmap(&font, 0,stbtt_ScaleForPixelHeight(&font, s), c, &w, &h, 0,0); - - for (j=0; j < h; ++j) { - for (i=0; i < w; ++i) - putchar(" .:ioVM@"[bitmap[j*w+i]>>5]); - putchar('\n'); - } - return 0; -} -#endif -// -// Output: -// -// .ii. -// @@@@@@. -// V@Mio@@o -// :i. V@V -// :oM@@M -// :@@@MM@M -// @@o o@M -// :@@. M@M -// @@@o@@@@ -// :M@@V:@@. -// -////////////////////////////////////////////////////////////////////////////// -// -// Complete program: print "Hello World!" banner, with bugs -// -#if 0 -char buffer[24<<20]; -unsigned char screen[20][79]; - -int main(int arg, char **argv) -{ - stbtt_fontinfo font; - int i,j,ascent,baseline,ch=0; - float scale, xpos=2; // leave a little padding in case the character extends left - char *text = "Heljo World!"; // intentionally misspelled to show 'lj' brokenness - - fread(buffer, 1, 1000000, fopen("c:/windows/fonts/arialbd.ttf", "rb")); - stbtt_InitFont(&font, buffer, 0); - - scale = stbtt_ScaleForPixelHeight(&font, 15); - stbtt_GetFontVMetrics(&font, &ascent,0,0); - baseline = (int) (ascent*scale); - - while (text[ch]) { - int advance,lsb,x0,y0,x1,y1; - float x_shift = xpos - (float) floor(xpos); - stbtt_GetCodepointHMetrics(&font, text[ch], &advance, &lsb); - stbtt_GetCodepointBitmapBoxSubpixel(&font, text[ch], scale,scale,x_shift,0, &x0,&y0,&x1,&y1); - stbtt_MakeCodepointBitmapSubpixel(&font, &screen[baseline + y0][(int) xpos + x0], x1-x0,y1-y0, 79, scale,scale,x_shift,0, text[ch]); - // note that this stomps the old data, so where character boxes overlap (e.g. 'lj') it's wrong - // because this API is really for baking character bitmaps into textures. if you want to render - // a sequence of characters, you really need to render each bitmap to a temp buffer, then - // "alpha blend" that into the working buffer - xpos += (advance * scale); - if (text[ch+1]) - xpos += scale*stbtt_GetCodepointKernAdvance(&font, text[ch],text[ch+1]); - ++ch; - } - - for (j=0; j < 20; ++j) { - for (i=0; i < 78; ++i) - putchar(" .:ioVM@"[screen[j][i]>>5]); - putchar('\n'); - } - - return 0; -} -#endif - - -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -//// -//// INTEGRATION WITH YOUR CODEBASE -//// -//// The following sections allow you to supply alternate definitions -//// of C library functions used by stb_truetype, e.g. if you don't -//// link with the C runtime library. - -#ifdef STB_TRUETYPE_IMPLEMENTATION - // #define your own (u)stbtt_int8/16/32 before including to override this - #ifndef stbtt_uint8 - typedef unsigned char stbtt_uint8; - typedef signed char stbtt_int8; - typedef unsigned short stbtt_uint16; - typedef signed short stbtt_int16; - typedef unsigned int stbtt_uint32; - typedef signed int stbtt_int32; - #endif - - typedef char stbtt__check_size32[sizeof(stbtt_int32)==4 ? 1 : -1]; - typedef char stbtt__check_size16[sizeof(stbtt_int16)==2 ? 1 : -1]; - - // e.g. #define your own STBTT_ifloor/STBTT_iceil() to avoid math.h - #ifndef STBTT_ifloor - #include - #define STBTT_ifloor(x) ((int) floor(x)) - #define STBTT_iceil(x) ((int) ceil(x)) - #endif - - #ifndef STBTT_sqrt - #include - #define STBTT_sqrt(x) sqrt(x) - #define STBTT_pow(x,y) pow(x,y) - #endif - - #ifndef STBTT_fmod - #include - #define STBTT_fmod(x,y) fmod(x,y) - #endif - - #ifndef STBTT_cos - #include - #define STBTT_cos(x) cos(x) - #define STBTT_acos(x) acos(x) - #endif - - #ifndef STBTT_fabs - #include - #define STBTT_fabs(x) fabs(x) - #endif - - // #define your own functions "STBTT_malloc" / "STBTT_free" to avoid malloc.h - #ifndef STBTT_malloc - #include - #define STBTT_malloc(x,u) ((void)(u),malloc(x)) - #define STBTT_free(x,u) ((void)(u),free(x)) - #endif - - #ifndef STBTT_assert - #include - #define STBTT_assert(x) assert(x) - #endif - - #ifndef STBTT_strlen - #include - #define STBTT_strlen(x) strlen(x) - #endif - - #ifndef STBTT_memcpy - #include - #define STBTT_memcpy memcpy - #define STBTT_memset memset - #endif -#endif - -/////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// -//// -//// INTERFACE -//// -//// - -#ifndef __STB_INCLUDE_STB_TRUETYPE_H__ -#define __STB_INCLUDE_STB_TRUETYPE_H__ - -#ifdef STBTT_STATIC -#define STBTT_DEF static -#else -#define STBTT_DEF extern -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -// private structure -typedef struct -{ - unsigned char *data; - int cursor; - int size; -} stbtt__buf; - -////////////////////////////////////////////////////////////////////////////// -// -// TEXTURE BAKING API -// -// If you use this API, you only have to call two functions ever. -// - -typedef struct -{ - unsigned short x0,y0,x1,y1; // coordinates of bbox in bitmap - float xoff,yoff,xadvance; -} stbtt_bakedchar; - -STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset, // font location (use offset=0 for plain .ttf) - float pixel_height, // height of font in pixels - unsigned char *pixels, int pw, int ph, // bitmap to be filled in - int first_char, int num_chars, // characters to bake - stbtt_bakedchar *chardata); // you allocate this, it's num_chars long -// if return is positive, the first unused row of the bitmap -// if return is negative, returns the negative of the number of characters that fit -// if return is 0, no characters fit and no rows were used -// This uses a very crappy packing. - -typedef struct -{ - float x0,y0,s0,t0; // top-left - float x1,y1,s1,t1; // bottom-right -} stbtt_aligned_quad; - -STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph, // same data as above - int char_index, // character to display - float *xpos, float *ypos, // pointers to current position in screen pixel space - stbtt_aligned_quad *q, // output: quad to draw - int opengl_fillrule); // true if opengl fill rule; false if DX9 or earlier -// Call GetBakedQuad with char_index = 'character - first_char', and it -// creates the quad you need to draw and advances the current position. -// -// The coordinate system used assumes y increases downwards. -// -// Characters will extend both above and below the current position; -// see discussion of "BASELINE" above. -// -// It's inefficient; you might want to c&p it and optimize it. - -STBTT_DEF void stbtt_GetScaledFontVMetrics(const unsigned char *fontdata, int index, float size, float *ascent, float *descent, float *lineGap); -// Query the font vertical metrics without having to create a font first. - - -////////////////////////////////////////////////////////////////////////////// -// -// NEW TEXTURE BAKING API -// -// This provides options for packing multiple fonts into one atlas, not -// perfectly but better than nothing. - -typedef struct -{ - unsigned short x0,y0,x1,y1; // coordinates of bbox in bitmap - float xoff,yoff,xadvance; - float xoff2,yoff2; -} stbtt_packedchar; - -typedef struct stbtt_pack_context stbtt_pack_context; -typedef struct stbtt_fontinfo stbtt_fontinfo; -#ifndef STB_RECT_PACK_VERSION -typedef struct stbrp_rect stbrp_rect; -#endif - -STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int width, int height, int stride_in_bytes, int padding, void *alloc_context); -// Initializes a packing context stored in the passed-in stbtt_pack_context. -// Future calls using this context will pack characters into the bitmap passed -// in here: a 1-channel bitmap that is width * height. stride_in_bytes is -// the distance from one row to the next (or 0 to mean they are packed tightly -// together). "padding" is the amount of padding to leave between each -// character (normally you want '1' for bitmaps you'll use as textures with -// bilinear filtering). -// -// Returns 0 on failure, 1 on success. - -STBTT_DEF void stbtt_PackEnd (stbtt_pack_context *spc); -// Cleans up the packing context and frees all memory. - -#define STBTT_POINT_SIZE(x) (-(x)) - -STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, float font_size, - int first_unicode_char_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range); -// Creates character bitmaps from the font_index'th font found in fontdata (use -// font_index=0 if you don't know what that is). It creates num_chars_in_range -// bitmaps for characters with unicode values starting at first_unicode_char_in_range -// and increasing. Data for how to render them is stored in chardata_for_range; -// pass these to stbtt_GetPackedQuad to get back renderable quads. -// -// font_size is the full height of the character from ascender to descender, -// as computed by stbtt_ScaleForPixelHeight. To use a point size as computed -// by stbtt_ScaleForMappingEmToPixels, wrap the point size in STBTT_POINT_SIZE() -// and pass that result as 'font_size': -// ..., 20 , ... // font max minus min y is 20 pixels tall -// ..., STBTT_POINT_SIZE(20), ... // 'M' is 20 pixels tall - -typedef struct -{ - float font_size; - int first_unicode_codepoint_in_range; // if non-zero, then the chars are continuous, and this is the first codepoint - int *array_of_unicode_codepoints; // if non-zero, then this is an array of unicode codepoints - int num_chars; - stbtt_packedchar *chardata_for_range; // output - unsigned char h_oversample, v_oversample; // don't set these, they're used internally -} stbtt_pack_range; - -STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges); -// Creates character bitmaps from multiple ranges of characters stored in -// ranges. This will usually create a better-packed bitmap than multiple -// calls to stbtt_PackFontRange. Note that you can call this multiple -// times within a single PackBegin/PackEnd. - -STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample); -// Oversampling a font increases the quality by allowing higher-quality subpixel -// positioning, and is especially valuable at smaller text sizes. -// -// This function sets the amount of oversampling for all following calls to -// stbtt_PackFontRange(s) or stbtt_PackFontRangesGatherRects for a given -// pack context. The default (no oversampling) is achieved by h_oversample=1 -// and v_oversample=1. The total number of pixels required is -// h_oversample*v_oversample larger than the default; for example, 2x2 -// oversampling requires 4x the storage of 1x1. For best results, render -// oversampled textures with bilinear filtering. Look at the readme in -// stb/tests/oversample for information about oversampled fonts -// -// To use with PackFontRangesGather etc., you must set it before calls -// call to PackFontRangesGatherRects. - -STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip); -// If skip != 0, this tells stb_truetype to skip any codepoints for which -// there is no corresponding glyph. If skip=0, which is the default, then -// codepoints without a glyph recived the font's "missing character" glyph, -// typically an empty box by convention. - -STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, // same data as above - int char_index, // character to display - float *xpos, float *ypos, // pointers to current position in screen pixel space - stbtt_aligned_quad *q, // output: quad to draw - int align_to_integer); - -STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects); -STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect *rects, int num_rects); -STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects); -// Calling these functions in sequence is roughly equivalent to calling -// stbtt_PackFontRanges(). If you more control over the packing of multiple -// fonts, or if you want to pack custom data into a font texture, take a look -// at the source to of stbtt_PackFontRanges() and create a custom version -// using these functions, e.g. call GatherRects multiple times, -// building up a single array of rects, then call PackRects once, -// then call RenderIntoRects repeatedly. This may result in a -// better packing than calling PackFontRanges multiple times -// (or it may not). - -// this is an opaque structure that you shouldn't mess with which holds -// all the context needed from PackBegin to PackEnd. -struct stbtt_pack_context { - void *user_allocator_context; - void *pack_info; - int width; - int height; - int stride_in_bytes; - int padding; - int skip_missing; - unsigned int h_oversample, v_oversample; - unsigned char *pixels; - void *nodes; -}; - -////////////////////////////////////////////////////////////////////////////// -// -// FONT LOADING -// -// - -STBTT_DEF int stbtt_GetNumberOfFonts(const unsigned char *data); -// This function will determine the number of fonts in a font file. TrueType -// collection (.ttc) files may contain multiple fonts, while TrueType font -// (.ttf) files only contain one font. The number of fonts can be used for -// indexing with the previous function where the index is between zero and one -// less than the total fonts. If an error occurs, -1 is returned. - -STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index); -// Each .ttf/.ttc file may have more than one font. Each font has a sequential -// index number starting from 0. Call this function to get the font offset for -// a given index; it returns -1 if the index is out of range. A regular .ttf -// file will only define one font and it always be at offset 0, so it will -// return '0' for index 0, and -1 for all other indices. - -// The following structure is defined publicly so you can declare one on -// the stack or as a global or etc, but you should treat it as opaque. -struct stbtt_fontinfo -{ - void * userdata; - unsigned char * data; // pointer to .ttf file - int fontstart; // offset of start of font - - int numGlyphs; // number of glyphs, needed for range checking - - int loca,head,glyf,hhea,hmtx,kern,gpos; // table locations as offset from start of .ttf - int index_map; // a cmap mapping for our chosen character encoding - int indexToLocFormat; // format needed to map from glyph index to glyph - - stbtt__buf cff; // cff font data - stbtt__buf charstrings; // the charstring index - stbtt__buf gsubrs; // global charstring subroutines index - stbtt__buf subrs; // private charstring subroutines index - stbtt__buf fontdicts; // array of font dicts - stbtt__buf fdselect; // map from glyph to fontdict -}; - -STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset); -// Given an offset into the file that defines a font, this function builds -// the necessary cached info for the rest of the system. You must allocate -// the stbtt_fontinfo yourself, and stbtt_InitFont will fill it out. You don't -// need to do anything special to free it, because the contents are pure -// value data with no additional data structures. Returns 0 on failure. - - -////////////////////////////////////////////////////////////////////////////// -// -// CHARACTER TO GLYPH-INDEX CONVERSIOn - -STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint); -// If you're going to perform multiple operations on the same character -// and you want a speed-up, call this function with the character you're -// going to process, then use glyph-based functions instead of the -// codepoint-based functions. -// Returns 0 if the character codepoint is not defined in the font. - - -////////////////////////////////////////////////////////////////////////////// -// -// CHARACTER PROPERTIES -// - -STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float pixels); -// computes a scale factor to produce a font whose "height" is 'pixels' tall. -// Height is measured as the distance from the highest ascender to the lowest -// descender; in other words, it's equivalent to calling stbtt_GetFontVMetrics -// and computing: -// scale = pixels / (ascent - descent) -// so if you prefer to measure height by the ascent only, use a similar calculation. - -STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels); -// computes a scale factor to produce a font whose EM size is mapped to -// 'pixels' tall. This is probably what traditional APIs compute, but -// I'm not positive. - -STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap); -// ascent is the coordinate above the baseline the font extends; descent -// is the coordinate below the baseline the font extends (i.e. it is typically negative) -// lineGap is the spacing between one row's descent and the next row's ascent... -// so you should advance the vertical position by "*ascent - *descent + *lineGap" -// these are expressed in unscaled coordinates, so you must multiply by -// the scale factor for a given size - -STBTT_DEF int stbtt_GetFontVMetricsOS2(const stbtt_fontinfo *info, int *typoAscent, int *typoDescent, int *typoLineGap); -// analogous to GetFontVMetrics, but returns the "typographic" values from the OS/2 -// table (specific to MS/Windows TTF files). -// -// Returns 1 on success (table present), 0 on failure. - -STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1); -// the bounding box around all possible characters - -STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing); -// leftSideBearing is the offset from the current horizontal position to the left edge of the character -// advanceWidth is the offset from the current horizontal position to the next horizontal position -// these are expressed in unscaled coordinates - -STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2); -// an additional amount to add to the 'advance' value between ch1 and ch2 - -STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1); -// Gets the bounding box of the visible part of the glyph, in unscaled coordinates - -STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing); -STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2); -STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1); -// as above, but takes one or more glyph indices for greater efficiency - - -////////////////////////////////////////////////////////////////////////////// -// -// GLYPH SHAPES (you probably don't need these, but they have to go before -// the bitmaps for C declaration-order reasons) -// - -#ifndef STBTT_vmove // you can predefine these to use different values (but why?) - enum { - STBTT_vmove=1, - STBTT_vline, - STBTT_vcurve, - STBTT_vcubic - }; -#endif - -#ifndef stbtt_vertex // you can predefine this to use different values - // (we share this with other code at RAD) - #define stbtt_vertex_type short // can't use stbtt_int16 because that's not visible in the header file - typedef struct - { - stbtt_vertex_type x,y,cx,cy,cx1,cy1; - unsigned char type,padding; - } stbtt_vertex; -#endif - -STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index); -// returns non-zero if nothing is drawn for this glyph - -STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices); -STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **vertices); -// returns # of vertices and fills *vertices with the pointer to them -// these are expressed in "unscaled" coordinates -// -// The shape is a series of contours. Each one starts with -// a STBTT_moveto, then consists of a series of mixed -// STBTT_lineto and STBTT_curveto segments. A lineto -// draws a line from previous endpoint to its x,y; a curveto -// draws a quadratic bezier from previous endpoint to -// its x,y, using cx,cy as the bezier control point. - -STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *vertices); -// frees the data allocated above - -////////////////////////////////////////////////////////////////////////////// -// -// BITMAP RENDERING -// - -STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata); -// frees the bitmap allocated below - -STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff); -// allocates a large-enough single-channel 8bpp bitmap and renders the -// specified character/glyph at the specified scale into it, with -// antialiasing. 0 is no coverage (transparent), 255 is fully covered (opaque). -// *width & *height are filled out with the width & height of the bitmap, -// which is stored left-to-right, top-to-bottom. -// -// xoff/yoff are the offset it pixel space from the glyph origin to the top-left of the bitmap - -STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff); -// the same as stbtt_GetCodepoitnBitmap, but you can specify a subpixel -// shift for the character - -STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint); -// the same as stbtt_GetCodepointBitmap, but you pass in storage for the bitmap -// in the form of 'output', with row spacing of 'out_stride' bytes. the bitmap -// is clipped to out_w/out_h bytes. Call stbtt_GetCodepointBitmapBox to get the -// width and height and positioning info for it first. - -STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint); -// same as stbtt_MakeCodepointBitmap, but you can specify a subpixel -// shift for the character - -STBTT_DEF void stbtt_MakeCodepointBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int codepoint); -// same as stbtt_MakeCodepointBitmapSubpixel, but prefiltering -// is performed (see stbtt_PackSetOversampling) - -STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1); -// get the bbox of the bitmap centered around the glyph origin; so the -// bitmap width is ix1-ix0, height is iy1-iy0, and location to place -// the bitmap top left is (leftSideBearing*scale,iy0). -// (Note that the bitmap uses y-increases-down, but the shape uses -// y-increases-up, so CodepointBitmapBox and CodepointBox are inverted.) - -STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1); -// same as stbtt_GetCodepointBitmapBox, but you can specify a subpixel -// shift for the character - -// the following functions are equivalent to the above functions, but operate -// on glyph indices instead of Unicode codepoints (for efficiency) -STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff); -STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff); -STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph); -STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph); -STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int glyph); -STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1); -STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1); - - -// @TODO: don't expose this structure -typedef struct -{ - int w,h,stride; - unsigned char *pixels; -} stbtt__bitmap; - -// rasterize a shape with quadratic beziers into a bitmap -STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, // 1-channel bitmap to draw into - float flatness_in_pixels, // allowable error of curve in pixels - stbtt_vertex *vertices, // array of vertices defining shape - int num_verts, // number of vertices in above array - float scale_x, float scale_y, // scale applied to input vertices - float shift_x, float shift_y, // translation applied to input vertices - int x_off, int y_off, // another translation applied to input - int invert, // if non-zero, vertically flip shape - void *userdata); // context for to STBTT_MALLOC - -////////////////////////////////////////////////////////////////////////////// -// -// Signed Distance Function (or Field) rendering - -STBTT_DEF void stbtt_FreeSDF(unsigned char *bitmap, void *userdata); -// frees the SDF bitmap allocated below - -STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float scale, int glyph, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff); -STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff); -// These functions compute a discretized SDF field for a single character, suitable for storing -// in a single-channel texture, sampling with bilinear filtering, and testing against -// larger than some threshold to produce scalable fonts. -// info -- the font -// scale -- controls the size of the resulting SDF bitmap, same as it would be creating a regular bitmap -// glyph/codepoint -- the character to generate the SDF for -// padding -- extra "pixels" around the character which are filled with the distance to the character (not 0), -// which allows effects like bit outlines -// onedge_value -- value 0-255 to test the SDF against to reconstruct the character (i.e. the isocontour of the character) -// pixel_dist_scale -- what value the SDF should increase by when moving one SDF "pixel" away from the edge (on the 0..255 scale) -// if positive, > onedge_value is inside; if negative, < onedge_value is inside -// width,height -- output height & width of the SDF bitmap (including padding) -// xoff,yoff -- output origin of the character -// return value -- a 2D array of bytes 0..255, width*height in size -// -// pixel_dist_scale & onedge_value are a scale & bias that allows you to make -// optimal use of the limited 0..255 for your application, trading off precision -// and special effects. SDF values outside the range 0..255 are clamped to 0..255. -// -// Example: -// scale = stbtt_ScaleForPixelHeight(22) -// padding = 5 -// onedge_value = 180 -// pixel_dist_scale = 180/5.0 = 36.0 -// -// This will create an SDF bitmap in which the character is about 22 pixels -// high but the whole bitmap is about 22+5+5=32 pixels high. To produce a filled -// shape, sample the SDF at each pixel and fill the pixel if the SDF value -// is greater than or equal to 180/255. (You'll actually want to antialias, -// which is beyond the scope of this example.) Additionally, you can compute -// offset outlines (e.g. to stroke the character border inside & outside, -// or only outside). For example, to fill outside the character up to 3 SDF -// pixels, you would compare against (180-36.0*3)/255 = 72/255. The above -// choice of variables maps a range from 5 pixels outside the shape to -// 2 pixels inside the shape to 0..255; this is intended primarily for apply -// outside effects only (the interior range is needed to allow proper -// antialiasing of the font at *smaller* sizes) -// -// The function computes the SDF analytically at each SDF pixel, not by e.g. -// building a higher-res bitmap and approximating it. In theory the quality -// should be as high as possible for an SDF of this size & representation, but -// unclear if this is true in practice (perhaps building a higher-res bitmap -// and computing from that can allow drop-out prevention). -// -// The algorithm has not been optimized at all, so expect it to be slow -// if computing lots of characters or very large sizes. - - - -////////////////////////////////////////////////////////////////////////////// -// -// Finding the right font... -// -// You should really just solve this offline, keep your own tables -// of what font is what, and don't try to get it out of the .ttf file. -// That's because getting it out of the .ttf file is really hard, because -// the names in the file can appear in many possible encodings, in many -// possible languages, and e.g. if you need a case-insensitive comparison, -// the details of that depend on the encoding & language in a complex way -// (actually underspecified in truetype, but also gigantic). -// -// But you can use the provided functions in two possible ways: -// stbtt_FindMatchingFont() will use *case-sensitive* comparisons on -// unicode-encoded names to try to find the font you want; -// you can run this before calling stbtt_InitFont() -// -// stbtt_GetFontNameString() lets you get any of the various strings -// from the file yourself and do your own comparisons on them. -// You have to have called stbtt_InitFont() first. - - -STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags); -// returns the offset (not index) of the font that matches, or -1 if none -// if you use STBTT_MACSTYLE_DONTCARE, use a font name like "Arial Bold". -// if you use any other flag, use a font name like "Arial"; this checks -// the 'macStyle' header field; i don't know if fonts set this consistently -#define STBTT_MACSTYLE_DONTCARE 0 -#define STBTT_MACSTYLE_BOLD 1 -#define STBTT_MACSTYLE_ITALIC 2 -#define STBTT_MACSTYLE_UNDERSCORE 4 -#define STBTT_MACSTYLE_NONE 8 // <= not same as 0, this makes us check the bitfield is 0 - -STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2); -// returns 1/0 whether the first string interpreted as utf8 is identical to -// the second string interpreted as big-endian utf16... useful for strings from next func - -STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID); -// returns the string (which may be big-endian double byte, e.g. for unicode) -// and puts the length in bytes in *length. -// -// some of the values for the IDs are below; for more see the truetype spec: -// http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6name.html -// http://www.microsoft.com/typography/otspec/name.htm - -enum { // platformID - STBTT_PLATFORM_ID_UNICODE =0, - STBTT_PLATFORM_ID_MAC =1, - STBTT_PLATFORM_ID_ISO =2, - STBTT_PLATFORM_ID_MICROSOFT =3 -}; - -enum { // encodingID for STBTT_PLATFORM_ID_UNICODE - STBTT_UNICODE_EID_UNICODE_1_0 =0, - STBTT_UNICODE_EID_UNICODE_1_1 =1, - STBTT_UNICODE_EID_ISO_10646 =2, - STBTT_UNICODE_EID_UNICODE_2_0_BMP=3, - STBTT_UNICODE_EID_UNICODE_2_0_FULL=4 -}; - -enum { // encodingID for STBTT_PLATFORM_ID_MICROSOFT - STBTT_MS_EID_SYMBOL =0, - STBTT_MS_EID_UNICODE_BMP =1, - STBTT_MS_EID_SHIFTJIS =2, - STBTT_MS_EID_UNICODE_FULL =10 -}; - -enum { // encodingID for STBTT_PLATFORM_ID_MAC; same as Script Manager codes - STBTT_MAC_EID_ROMAN =0, STBTT_MAC_EID_ARABIC =4, - STBTT_MAC_EID_JAPANESE =1, STBTT_MAC_EID_HEBREW =5, - STBTT_MAC_EID_CHINESE_TRAD =2, STBTT_MAC_EID_GREEK =6, - STBTT_MAC_EID_KOREAN =3, STBTT_MAC_EID_RUSSIAN =7 -}; - -enum { // languageID for STBTT_PLATFORM_ID_MICROSOFT; same as LCID... - // problematic because there are e.g. 16 english LCIDs and 16 arabic LCIDs - STBTT_MS_LANG_ENGLISH =0x0409, STBTT_MS_LANG_ITALIAN =0x0410, - STBTT_MS_LANG_CHINESE =0x0804, STBTT_MS_LANG_JAPANESE =0x0411, - STBTT_MS_LANG_DUTCH =0x0413, STBTT_MS_LANG_KOREAN =0x0412, - STBTT_MS_LANG_FRENCH =0x040c, STBTT_MS_LANG_RUSSIAN =0x0419, - STBTT_MS_LANG_GERMAN =0x0407, STBTT_MS_LANG_SPANISH =0x0409, - STBTT_MS_LANG_HEBREW =0x040d, STBTT_MS_LANG_SWEDISH =0x041D -}; - -enum { // languageID for STBTT_PLATFORM_ID_MAC - STBTT_MAC_LANG_ENGLISH =0 , STBTT_MAC_LANG_JAPANESE =11, - STBTT_MAC_LANG_ARABIC =12, STBTT_MAC_LANG_KOREAN =23, - STBTT_MAC_LANG_DUTCH =4 , STBTT_MAC_LANG_RUSSIAN =32, - STBTT_MAC_LANG_FRENCH =1 , STBTT_MAC_LANG_SPANISH =6 , - STBTT_MAC_LANG_GERMAN =2 , STBTT_MAC_LANG_SWEDISH =5 , - STBTT_MAC_LANG_HEBREW =10, STBTT_MAC_LANG_CHINESE_SIMPLIFIED =33, - STBTT_MAC_LANG_ITALIAN =3 , STBTT_MAC_LANG_CHINESE_TRAD =19 -}; - -#ifdef __cplusplus -} -#endif - -#endif // __STB_INCLUDE_STB_TRUETYPE_H__ - -/////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// -//// -//// IMPLEMENTATION -//// -//// - -#ifdef STB_TRUETYPE_IMPLEMENTATION - -#ifndef STBTT_MAX_OVERSAMPLE -#define STBTT_MAX_OVERSAMPLE 8 -#endif - -#if STBTT_MAX_OVERSAMPLE > 255 -#error "STBTT_MAX_OVERSAMPLE cannot be > 255" -#endif - -typedef int stbtt__test_oversample_pow2[(STBTT_MAX_OVERSAMPLE & (STBTT_MAX_OVERSAMPLE-1)) == 0 ? 1 : -1]; - -#ifndef STBTT_RASTERIZER_VERSION -#define STBTT_RASTERIZER_VERSION 2 -#endif - -#ifdef _MSC_VER -#define STBTT__NOTUSED(v) (void)(v) -#else -#define STBTT__NOTUSED(v) (void)sizeof(v) -#endif - -////////////////////////////////////////////////////////////////////////// -// -// stbtt__buf helpers to parse data from file -// - -static stbtt_uint8 stbtt__buf_get8(stbtt__buf *b) -{ - if (b->cursor >= b->size) - return 0; - return b->data[b->cursor++]; -} - -static stbtt_uint8 stbtt__buf_peek8(stbtt__buf *b) -{ - if (b->cursor >= b->size) - return 0; - return b->data[b->cursor]; -} - -static void stbtt__buf_seek(stbtt__buf *b, int o) -{ - STBTT_assert(!(o > b->size || o < 0)); - b->cursor = (o > b->size || o < 0) ? b->size : o; -} - -static void stbtt__buf_skip(stbtt__buf *b, int o) -{ - stbtt__buf_seek(b, b->cursor + o); -} - -static stbtt_uint32 stbtt__buf_get(stbtt__buf *b, int n) -{ - stbtt_uint32 v = 0; - int i; - STBTT_assert(n >= 1 && n <= 4); - for (i = 0; i < n; i++) - v = (v << 8) | stbtt__buf_get8(b); - return v; -} - -static stbtt__buf stbtt__new_buf(const void *p, size_t size) -{ - stbtt__buf r; - STBTT_assert(size < 0x40000000); - r.data = (stbtt_uint8*) p; - r.size = (int) size; - r.cursor = 0; - return r; -} - -#define stbtt__buf_get16(b) stbtt__buf_get((b), 2) -#define stbtt__buf_get32(b) stbtt__buf_get((b), 4) - -static stbtt__buf stbtt__buf_range(const stbtt__buf *b, int o, int s) -{ - stbtt__buf r = stbtt__new_buf(NULL, 0); - if (o < 0 || s < 0 || o > b->size || s > b->size - o) return r; - r.data = b->data + o; - r.size = s; - return r; -} - -static stbtt__buf stbtt__cff_get_index(stbtt__buf *b) -{ - int count, start, offsize; - start = b->cursor; - count = stbtt__buf_get16(b); - if (count) { - offsize = stbtt__buf_get8(b); - STBTT_assert(offsize >= 1 && offsize <= 4); - stbtt__buf_skip(b, offsize * count); - stbtt__buf_skip(b, stbtt__buf_get(b, offsize) - 1); - } - return stbtt__buf_range(b, start, b->cursor - start); -} - -static stbtt_uint32 stbtt__cff_int(stbtt__buf *b) -{ - int b0 = stbtt__buf_get8(b); - if (b0 >= 32 && b0 <= 246) return b0 - 139; - else if (b0 >= 247 && b0 <= 250) return (b0 - 247)*256 + stbtt__buf_get8(b) + 108; - else if (b0 >= 251 && b0 <= 254) return -(b0 - 251)*256 - stbtt__buf_get8(b) - 108; - else if (b0 == 28) return stbtt__buf_get16(b); - else if (b0 == 29) return stbtt__buf_get32(b); - STBTT_assert(0); - return 0; -} - -static void stbtt__cff_skip_operand(stbtt__buf *b) { - int v, b0 = stbtt__buf_peek8(b); - STBTT_assert(b0 >= 28); - if (b0 == 30) { - stbtt__buf_skip(b, 1); - while (b->cursor < b->size) { - v = stbtt__buf_get8(b); - if ((v & 0xF) == 0xF || (v >> 4) == 0xF) - break; - } - } else { - stbtt__cff_int(b); - } -} - -static stbtt__buf stbtt__dict_get(stbtt__buf *b, int key) -{ - stbtt__buf_seek(b, 0); - while (b->cursor < b->size) { - int start = b->cursor, end, op; - while (stbtt__buf_peek8(b) >= 28) - stbtt__cff_skip_operand(b); - end = b->cursor; - op = stbtt__buf_get8(b); - if (op == 12) op = stbtt__buf_get8(b) | 0x100; - if (op == key) return stbtt__buf_range(b, start, end-start); - } - return stbtt__buf_range(b, 0, 0); -} - -static void stbtt__dict_get_ints(stbtt__buf *b, int key, int outcount, stbtt_uint32 *out) -{ - int i; - stbtt__buf operands = stbtt__dict_get(b, key); - for (i = 0; i < outcount && operands.cursor < operands.size; i++) - out[i] = stbtt__cff_int(&operands); -} - -static int stbtt__cff_index_count(stbtt__buf *b) -{ - stbtt__buf_seek(b, 0); - return stbtt__buf_get16(b); -} - -static stbtt__buf stbtt__cff_index_get(stbtt__buf b, int i) -{ - int count, offsize, start, end; - stbtt__buf_seek(&b, 0); - count = stbtt__buf_get16(&b); - offsize = stbtt__buf_get8(&b); - STBTT_assert(i >= 0 && i < count); - STBTT_assert(offsize >= 1 && offsize <= 4); - stbtt__buf_skip(&b, i*offsize); - start = stbtt__buf_get(&b, offsize); - end = stbtt__buf_get(&b, offsize); - return stbtt__buf_range(&b, 2+(count+1)*offsize+start, end - start); -} - -////////////////////////////////////////////////////////////////////////// -// -// accessors to parse data from file -// - -// on platforms that don't allow misaligned reads, if we want to allow -// truetype fonts that aren't padded to alignment, define ALLOW_UNALIGNED_TRUETYPE - -#define ttBYTE(p) (* (stbtt_uint8 *) (p)) -#define ttCHAR(p) (* (stbtt_int8 *) (p)) -#define ttFixed(p) ttLONG(p) - -static stbtt_uint16 ttUSHORT(stbtt_uint8 *p) { return p[0]*256 + p[1]; } -static stbtt_int16 ttSHORT(stbtt_uint8 *p) { return p[0]*256 + p[1]; } -static stbtt_uint32 ttULONG(stbtt_uint8 *p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; } -static stbtt_int32 ttLONG(stbtt_uint8 *p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; } - -#define stbtt_tag4(p,c0,c1,c2,c3) ((p)[0] == (c0) && (p)[1] == (c1) && (p)[2] == (c2) && (p)[3] == (c3)) -#define stbtt_tag(p,str) stbtt_tag4(p,str[0],str[1],str[2],str[3]) - -static int stbtt__isfont(stbtt_uint8 *font) -{ - // check the version number - if (stbtt_tag4(font, '1',0,0,0)) return 1; // TrueType 1 - if (stbtt_tag(font, "typ1")) return 1; // TrueType with type 1 font -- we don't support this! - if (stbtt_tag(font, "OTTO")) return 1; // OpenType with CFF - if (stbtt_tag4(font, 0,1,0,0)) return 1; // OpenType 1.0 - if (stbtt_tag(font, "true")) return 1; // Apple specification for TrueType fonts - return 0; -} - -// @OPTIMIZE: binary search -static stbtt_uint32 stbtt__find_table(stbtt_uint8 *data, stbtt_uint32 fontstart, const char *tag) -{ - stbtt_int32 num_tables = ttUSHORT(data+fontstart+4); - stbtt_uint32 tabledir = fontstart + 12; - stbtt_int32 i; - for (i=0; i < num_tables; ++i) { - stbtt_uint32 loc = tabledir + 16*i; - if (stbtt_tag(data+loc+0, tag)) - return ttULONG(data+loc+8); - } - return 0; -} - -static int stbtt_GetFontOffsetForIndex_internal(unsigned char *font_collection, int index) -{ - // if it's just a font, there's only one valid index - if (stbtt__isfont(font_collection)) - return index == 0 ? 0 : -1; - - // check if it's a TTC - if (stbtt_tag(font_collection, "ttcf")) { - // version 1? - if (ttULONG(font_collection+4) == 0x00010000 || ttULONG(font_collection+4) == 0x00020000) { - stbtt_int32 n = ttLONG(font_collection+8); - if (index >= n) - return -1; - return ttULONG(font_collection+12+index*4); - } - } - return -1; -} - -static int stbtt_GetNumberOfFonts_internal(unsigned char *font_collection) -{ - // if it's just a font, there's only one valid font - if (stbtt__isfont(font_collection)) - return 1; - - // check if it's a TTC - if (stbtt_tag(font_collection, "ttcf")) { - // version 1? - if (ttULONG(font_collection+4) == 0x00010000 || ttULONG(font_collection+4) == 0x00020000) { - return ttLONG(font_collection+8); - } - } - return 0; -} - -static stbtt__buf stbtt__get_subrs(stbtt__buf cff, stbtt__buf fontdict) -{ - stbtt_uint32 subrsoff = 0, private_loc[2] = { 0, 0 }; - stbtt__buf pdict; - stbtt__dict_get_ints(&fontdict, 18, 2, private_loc); - if (!private_loc[1] || !private_loc[0]) return stbtt__new_buf(NULL, 0); - pdict = stbtt__buf_range(&cff, private_loc[1], private_loc[0]); - stbtt__dict_get_ints(&pdict, 19, 1, &subrsoff); - if (!subrsoff) return stbtt__new_buf(NULL, 0); - stbtt__buf_seek(&cff, private_loc[1]+subrsoff); - return stbtt__cff_get_index(&cff); -} - -static int stbtt_InitFont_internal(stbtt_fontinfo *info, unsigned char *data, int fontstart) -{ - stbtt_uint32 cmap, t; - stbtt_int32 i,numTables; - - info->data = data; - info->fontstart = fontstart; - info->cff = stbtt__new_buf(NULL, 0); - - cmap = stbtt__find_table(data, fontstart, "cmap"); // required - info->loca = stbtt__find_table(data, fontstart, "loca"); // required - info->head = stbtt__find_table(data, fontstart, "head"); // required - info->glyf = stbtt__find_table(data, fontstart, "glyf"); // required - info->hhea = stbtt__find_table(data, fontstart, "hhea"); // required - info->hmtx = stbtt__find_table(data, fontstart, "hmtx"); // required - info->kern = stbtt__find_table(data, fontstart, "kern"); // not required - info->gpos = stbtt__find_table(data, fontstart, "GPOS"); // not required - - if (!cmap || !info->head || !info->hhea || !info->hmtx) - return 0; - if (info->glyf) { - // required for truetype - if (!info->loca) return 0; - } else { - // initialization for CFF / Type2 fonts (OTF) - stbtt__buf b, topdict, topdictidx; - stbtt_uint32 cstype = 2, charstrings = 0, fdarrayoff = 0, fdselectoff = 0; - stbtt_uint32 cff; - - cff = stbtt__find_table(data, fontstart, "CFF "); - if (!cff) return 0; - - info->fontdicts = stbtt__new_buf(NULL, 0); - info->fdselect = stbtt__new_buf(NULL, 0); - - // @TODO this should use size from table (not 512MB) - info->cff = stbtt__new_buf(data+cff, 512*1024*1024); - b = info->cff; - - // read the header - stbtt__buf_skip(&b, 2); - stbtt__buf_seek(&b, stbtt__buf_get8(&b)); // hdrsize - - // @TODO the name INDEX could list multiple fonts, - // but we just use the first one. - stbtt__cff_get_index(&b); // name INDEX - topdictidx = stbtt__cff_get_index(&b); - topdict = stbtt__cff_index_get(topdictidx, 0); - stbtt__cff_get_index(&b); // string INDEX - info->gsubrs = stbtt__cff_get_index(&b); - - stbtt__dict_get_ints(&topdict, 17, 1, &charstrings); - stbtt__dict_get_ints(&topdict, 0x100 | 6, 1, &cstype); - stbtt__dict_get_ints(&topdict, 0x100 | 36, 1, &fdarrayoff); - stbtt__dict_get_ints(&topdict, 0x100 | 37, 1, &fdselectoff); - info->subrs = stbtt__get_subrs(b, topdict); - - // we only support Type 2 charstrings - if (cstype != 2) return 0; - if (charstrings == 0) return 0; - - if (fdarrayoff) { - // looks like a CID font - if (!fdselectoff) return 0; - stbtt__buf_seek(&b, fdarrayoff); - info->fontdicts = stbtt__cff_get_index(&b); - info->fdselect = stbtt__buf_range(&b, fdselectoff, b.size-fdselectoff); - } - - stbtt__buf_seek(&b, charstrings); - info->charstrings = stbtt__cff_get_index(&b); - } - - t = stbtt__find_table(data, fontstart, "maxp"); - if (t) - info->numGlyphs = ttUSHORT(data+t+4); - else - info->numGlyphs = 0xffff; - - // find a cmap encoding table we understand *now* to avoid searching - // later. (todo: could make this installable) - // the same regardless of glyph. - numTables = ttUSHORT(data + cmap + 2); - info->index_map = 0; - for (i=0; i < numTables; ++i) { - stbtt_uint32 encoding_record = cmap + 4 + 8 * i; - // find an encoding we understand: - switch(ttUSHORT(data+encoding_record)) { - case STBTT_PLATFORM_ID_MICROSOFT: - switch (ttUSHORT(data+encoding_record+2)) { - case STBTT_MS_EID_UNICODE_BMP: - case STBTT_MS_EID_UNICODE_FULL: - // MS/Unicode - info->index_map = cmap + ttULONG(data+encoding_record+4); - break; - } - break; - case STBTT_PLATFORM_ID_UNICODE: - // Mac/iOS has these - // all the encodingIDs are unicode, so we don't bother to check it - info->index_map = cmap + ttULONG(data+encoding_record+4); - break; - } - } - if (info->index_map == 0) - return 0; - - info->indexToLocFormat = ttUSHORT(data+info->head + 50); - return 1; -} - -STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint) -{ - stbtt_uint8 *data = info->data; - stbtt_uint32 index_map = info->index_map; - - stbtt_uint16 format = ttUSHORT(data + index_map + 0); - if (format == 0) { // apple byte encoding - stbtt_int32 bytes = ttUSHORT(data + index_map + 2); - if (unicode_codepoint < bytes-6) - return ttBYTE(data + index_map + 6 + unicode_codepoint); - return 0; - } else if (format == 6) { - stbtt_uint32 first = ttUSHORT(data + index_map + 6); - stbtt_uint32 count = ttUSHORT(data + index_map + 8); - if ((stbtt_uint32) unicode_codepoint >= first && (stbtt_uint32) unicode_codepoint < first+count) - return ttUSHORT(data + index_map + 10 + (unicode_codepoint - first)*2); - return 0; - } else if (format == 2) { - STBTT_assert(0); // @TODO: high-byte mapping for japanese/chinese/korean - return 0; - } else if (format == 4) { // standard mapping for windows fonts: binary search collection of ranges - stbtt_uint16 segcount = ttUSHORT(data+index_map+6) >> 1; - stbtt_uint16 searchRange = ttUSHORT(data+index_map+8) >> 1; - stbtt_uint16 entrySelector = ttUSHORT(data+index_map+10); - stbtt_uint16 rangeShift = ttUSHORT(data+index_map+12) >> 1; - - // do a binary search of the segments - stbtt_uint32 endCount = index_map + 14; - stbtt_uint32 search = endCount; - - if (unicode_codepoint > 0xffff) - return 0; - - // they lie from endCount .. endCount + segCount - // but searchRange is the nearest power of two, so... - if (unicode_codepoint >= ttUSHORT(data + search + rangeShift*2)) - search += rangeShift*2; - - // now decrement to bias correctly to find smallest - search -= 2; - while (entrySelector) { - stbtt_uint16 end; - searchRange >>= 1; - end = ttUSHORT(data + search + searchRange*2); - if (unicode_codepoint > end) - search += searchRange*2; - --entrySelector; - } - search += 2; - - { - stbtt_uint16 offset, start; - stbtt_uint16 item = (stbtt_uint16) ((search - endCount) >> 1); - - STBTT_assert(unicode_codepoint <= ttUSHORT(data + endCount + 2*item)); - start = ttUSHORT(data + index_map + 14 + segcount*2 + 2 + 2*item); - if (unicode_codepoint < start) - return 0; - - offset = ttUSHORT(data + index_map + 14 + segcount*6 + 2 + 2*item); - if (offset == 0) - return (stbtt_uint16) (unicode_codepoint + ttSHORT(data + index_map + 14 + segcount*4 + 2 + 2*item)); - - return ttUSHORT(data + offset + (unicode_codepoint-start)*2 + index_map + 14 + segcount*6 + 2 + 2*item); - } - } else if (format == 12 || format == 13) { - stbtt_uint32 ngroups = ttULONG(data+index_map+12); - stbtt_int32 low,high; - low = 0; high = (stbtt_int32)ngroups; - // Binary search the right group. - while (low < high) { - stbtt_int32 mid = low + ((high-low) >> 1); // rounds down, so low <= mid < high - stbtt_uint32 start_char = ttULONG(data+index_map+16+mid*12); - stbtt_uint32 end_char = ttULONG(data+index_map+16+mid*12+4); - if ((stbtt_uint32) unicode_codepoint < start_char) - high = mid; - else if ((stbtt_uint32) unicode_codepoint > end_char) - low = mid+1; - else { - stbtt_uint32 start_glyph = ttULONG(data+index_map+16+mid*12+8); - if (format == 12) - return start_glyph + unicode_codepoint-start_char; - else // format == 13 - return start_glyph; - } - } - return 0; // not found - } - // @TODO - STBTT_assert(0); - return 0; -} - -STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices) -{ - return stbtt_GetGlyphShape(info, stbtt_FindGlyphIndex(info, unicode_codepoint), vertices); -} - -static void stbtt_setvertex(stbtt_vertex *v, stbtt_uint8 type, stbtt_int32 x, stbtt_int32 y, stbtt_int32 cx, stbtt_int32 cy) -{ - v->type = type; - v->x = (stbtt_int16) x; - v->y = (stbtt_int16) y; - v->cx = (stbtt_int16) cx; - v->cy = (stbtt_int16) cy; -} - -static int stbtt__GetGlyfOffset(const stbtt_fontinfo *info, int glyph_index) -{ - int g1,g2; - - STBTT_assert(!info->cff.size); - - if (glyph_index >= info->numGlyphs) return -1; // glyph index out of range - if (info->indexToLocFormat >= 2) return -1; // unknown index->glyph map format - - if (info->indexToLocFormat == 0) { - g1 = info->glyf + ttUSHORT(info->data + info->loca + glyph_index * 2) * 2; - g2 = info->glyf + ttUSHORT(info->data + info->loca + glyph_index * 2 + 2) * 2; - } else { - g1 = info->glyf + ttULONG (info->data + info->loca + glyph_index * 4); - g2 = info->glyf + ttULONG (info->data + info->loca + glyph_index * 4 + 4); - } - - return g1==g2 ? -1 : g1; // if length is 0, return -1 -} - -static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1); - -STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1) -{ - if (info->cff.size) { - stbtt__GetGlyphInfoT2(info, glyph_index, x0, y0, x1, y1); - } else { - int g = stbtt__GetGlyfOffset(info, glyph_index); - if (g < 0) return 0; - - if (x0) *x0 = ttSHORT(info->data + g + 2); - if (y0) *y0 = ttSHORT(info->data + g + 4); - if (x1) *x1 = ttSHORT(info->data + g + 6); - if (y1) *y1 = ttSHORT(info->data + g + 8); - } - return 1; -} - -STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1) -{ - return stbtt_GetGlyphBox(info, stbtt_FindGlyphIndex(info,codepoint), x0,y0,x1,y1); -} - -STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index) -{ - stbtt_int16 numberOfContours; - int g; - if (info->cff.size) - return stbtt__GetGlyphInfoT2(info, glyph_index, NULL, NULL, NULL, NULL) == 0; - g = stbtt__GetGlyfOffset(info, glyph_index); - if (g < 0) return 1; - numberOfContours = ttSHORT(info->data + g); - return numberOfContours == 0; -} - -static int stbtt__close_shape(stbtt_vertex *vertices, int num_vertices, int was_off, int start_off, - stbtt_int32 sx, stbtt_int32 sy, stbtt_int32 scx, stbtt_int32 scy, stbtt_int32 cx, stbtt_int32 cy) -{ - if (start_off) { - if (was_off) - stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, (cx+scx)>>1, (cy+scy)>>1, cx,cy); - stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, sx,sy,scx,scy); - } else { - if (was_off) - stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve,sx,sy,cx,cy); - else - stbtt_setvertex(&vertices[num_vertices++], STBTT_vline,sx,sy,0,0); - } - return num_vertices; -} - -static int stbtt__GetGlyphShapeTT(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) -{ - stbtt_int16 numberOfContours; - stbtt_uint8 *endPtsOfContours; - stbtt_uint8 *data = info->data; - stbtt_vertex *vertices=0; - int num_vertices=0; - int g = stbtt__GetGlyfOffset(info, glyph_index); - - *pvertices = NULL; - - if (g < 0) return 0; - - numberOfContours = ttSHORT(data + g); - - if (numberOfContours > 0) { - stbtt_uint8 flags=0,flagcount; - stbtt_int32 ins, i,j=0,m,n, next_move, was_off=0, off, start_off=0; - stbtt_int32 x,y,cx,cy,sx,sy, scx,scy; - stbtt_uint8 *points; - endPtsOfContours = (data + g + 10); - ins = ttUSHORT(data + g + 10 + numberOfContours * 2); - points = data + g + 10 + numberOfContours * 2 + 2 + ins; - - n = 1+ttUSHORT(endPtsOfContours + numberOfContours*2-2); - - m = n + 2*numberOfContours; // a loose bound on how many vertices we might need - vertices = (stbtt_vertex *) STBTT_malloc(m * sizeof(vertices[0]), info->userdata); - if (vertices == 0) - return 0; - - next_move = 0; - flagcount=0; - - // in first pass, we load uninterpreted data into the allocated array - // above, shifted to the end of the array so we won't overwrite it when - // we create our final data starting from the front - - off = m - n; // starting offset for uninterpreted data, regardless of how m ends up being calculated - - // first load flags - - for (i=0; i < n; ++i) { - if (flagcount == 0) { - flags = *points++; - if (flags & 8) - flagcount = *points++; - } else - --flagcount; - vertices[off+i].type = flags; - } - - // now load x coordinates - x=0; - for (i=0; i < n; ++i) { - flags = vertices[off+i].type; - if (flags & 2) { - stbtt_int16 dx = *points++; - x += (flags & 16) ? dx : -dx; // ??? - } else { - if (!(flags & 16)) { - x = x + (stbtt_int16) (points[0]*256 + points[1]); - points += 2; - } - } - vertices[off+i].x = (stbtt_int16) x; - } - - // now load y coordinates - y=0; - for (i=0; i < n; ++i) { - flags = vertices[off+i].type; - if (flags & 4) { - stbtt_int16 dy = *points++; - y += (flags & 32) ? dy : -dy; // ??? - } else { - if (!(flags & 32)) { - y = y + (stbtt_int16) (points[0]*256 + points[1]); - points += 2; - } - } - vertices[off+i].y = (stbtt_int16) y; - } - - // now convert them to our format - num_vertices=0; - sx = sy = cx = cy = scx = scy = 0; - for (i=0; i < n; ++i) { - flags = vertices[off+i].type; - x = (stbtt_int16) vertices[off+i].x; - y = (stbtt_int16) vertices[off+i].y; - - if (next_move == i) { - if (i != 0) - num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy); - - // now start the new one - start_off = !(flags & 1); - if (start_off) { - // if we start off with an off-curve point, then when we need to find a point on the curve - // where we can start, and we need to save some state for when we wraparound. - scx = x; - scy = y; - if (!(vertices[off+i+1].type & 1)) { - // next point is also a curve point, so interpolate an on-point curve - sx = (x + (stbtt_int32) vertices[off+i+1].x) >> 1; - sy = (y + (stbtt_int32) vertices[off+i+1].y) >> 1; - } else { - // otherwise just use the next point as our start point - sx = (stbtt_int32) vertices[off+i+1].x; - sy = (stbtt_int32) vertices[off+i+1].y; - ++i; // we're using point i+1 as the starting point, so skip it - } - } else { - sx = x; - sy = y; - } - stbtt_setvertex(&vertices[num_vertices++], STBTT_vmove,sx,sy,0,0); - was_off = 0; - next_move = 1 + ttUSHORT(endPtsOfContours+j*2); - ++j; - } else { - if (!(flags & 1)) { // if it's a curve - if (was_off) // two off-curve control points in a row means interpolate an on-curve midpoint - stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, (cx+x)>>1, (cy+y)>>1, cx, cy); - cx = x; - cy = y; - was_off = 1; - } else { - if (was_off) - stbtt_setvertex(&vertices[num_vertices++], STBTT_vcurve, x,y, cx, cy); - else - stbtt_setvertex(&vertices[num_vertices++], STBTT_vline, x,y,0,0); - was_off = 0; - } - } - } - num_vertices = stbtt__close_shape(vertices, num_vertices, was_off, start_off, sx,sy,scx,scy,cx,cy); - } else if (numberOfContours == -1) { - // Compound shapes. - int more = 1; - stbtt_uint8 *comp = data + g + 10; - num_vertices = 0; - vertices = 0; - while (more) { - stbtt_uint16 flags, gidx; - int comp_num_verts = 0, i; - stbtt_vertex *comp_verts = 0, *tmp = 0; - float mtx[6] = {1,0,0,1,0,0}, m, n; - - flags = ttSHORT(comp); comp+=2; - gidx = ttSHORT(comp); comp+=2; - - if (flags & 2) { // XY values - if (flags & 1) { // shorts - mtx[4] = ttSHORT(comp); comp+=2; - mtx[5] = ttSHORT(comp); comp+=2; - } else { - mtx[4] = ttCHAR(comp); comp+=1; - mtx[5] = ttCHAR(comp); comp+=1; - } - } - else { - // @TODO handle matching point - STBTT_assert(0); - } - if (flags & (1<<3)) { // WE_HAVE_A_SCALE - mtx[0] = mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; - mtx[1] = mtx[2] = 0; - } else if (flags & (1<<6)) { // WE_HAVE_AN_X_AND_YSCALE - mtx[0] = ttSHORT(comp)/16384.0f; comp+=2; - mtx[1] = mtx[2] = 0; - mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; - } else if (flags & (1<<7)) { // WE_HAVE_A_TWO_BY_TWO - mtx[0] = ttSHORT(comp)/16384.0f; comp+=2; - mtx[1] = ttSHORT(comp)/16384.0f; comp+=2; - mtx[2] = ttSHORT(comp)/16384.0f; comp+=2; - mtx[3] = ttSHORT(comp)/16384.0f; comp+=2; - } - - // Find transformation scales. - m = (float) STBTT_sqrt(mtx[0]*mtx[0] + mtx[1]*mtx[1]); - n = (float) STBTT_sqrt(mtx[2]*mtx[2] + mtx[3]*mtx[3]); - - // Get indexed glyph. - comp_num_verts = stbtt_GetGlyphShape(info, gidx, &comp_verts); - if (comp_num_verts > 0) { - // Transform vertices. - for (i = 0; i < comp_num_verts; ++i) { - stbtt_vertex* v = &comp_verts[i]; - stbtt_vertex_type x,y; - x=v->x; y=v->y; - v->x = (stbtt_vertex_type)(m * (mtx[0]*x + mtx[2]*y + mtx[4])); - v->y = (stbtt_vertex_type)(n * (mtx[1]*x + mtx[3]*y + mtx[5])); - x=v->cx; y=v->cy; - v->cx = (stbtt_vertex_type)(m * (mtx[0]*x + mtx[2]*y + mtx[4])); - v->cy = (stbtt_vertex_type)(n * (mtx[1]*x + mtx[3]*y + mtx[5])); - } - // Append vertices. - tmp = (stbtt_vertex*)STBTT_malloc((num_vertices+comp_num_verts)*sizeof(stbtt_vertex), info->userdata); - if (!tmp) { - if (vertices) STBTT_free(vertices, info->userdata); - if (comp_verts) STBTT_free(comp_verts, info->userdata); - return 0; - } - if (num_vertices > 0) STBTT_memcpy(tmp, vertices, num_vertices*sizeof(stbtt_vertex)); //-V595 - STBTT_memcpy(tmp+num_vertices, comp_verts, comp_num_verts*sizeof(stbtt_vertex)); - if (vertices) STBTT_free(vertices, info->userdata); - vertices = tmp; - STBTT_free(comp_verts, info->userdata); - num_vertices += comp_num_verts; - } - // More components ? - more = flags & (1<<5); - } - } else if (numberOfContours < 0) { - // @TODO other compound variations? - STBTT_assert(0); - } else { - // numberOfCounters == 0, do nothing - } - - *pvertices = vertices; - return num_vertices; -} - -typedef struct -{ - int bounds; - int started; - float first_x, first_y; - float x, y; - stbtt_int32 min_x, max_x, min_y, max_y; - - stbtt_vertex *pvertices; - int num_vertices; -} stbtt__csctx; - -#define STBTT__CSCTX_INIT(bounds) {bounds,0, 0,0, 0,0, 0,0,0,0, NULL, 0} - -static void stbtt__track_vertex(stbtt__csctx *c, stbtt_int32 x, stbtt_int32 y) -{ - if (x > c->max_x || !c->started) c->max_x = x; - if (y > c->max_y || !c->started) c->max_y = y; - if (x < c->min_x || !c->started) c->min_x = x; - if (y < c->min_y || !c->started) c->min_y = y; - c->started = 1; -} - -static void stbtt__csctx_v(stbtt__csctx *c, stbtt_uint8 type, stbtt_int32 x, stbtt_int32 y, stbtt_int32 cx, stbtt_int32 cy, stbtt_int32 cx1, stbtt_int32 cy1) -{ - if (c->bounds) { - stbtt__track_vertex(c, x, y); - if (type == STBTT_vcubic) { - stbtt__track_vertex(c, cx, cy); - stbtt__track_vertex(c, cx1, cy1); - } - } else { - stbtt_setvertex(&c->pvertices[c->num_vertices], type, x, y, cx, cy); - c->pvertices[c->num_vertices].cx1 = (stbtt_int16) cx1; - c->pvertices[c->num_vertices].cy1 = (stbtt_int16) cy1; - } - c->num_vertices++; -} - -static void stbtt__csctx_close_shape(stbtt__csctx *ctx) -{ - if (ctx->first_x != ctx->x || ctx->first_y != ctx->y) - stbtt__csctx_v(ctx, STBTT_vline, (int)ctx->first_x, (int)ctx->first_y, 0, 0, 0, 0); -} - -static void stbtt__csctx_rmove_to(stbtt__csctx *ctx, float dx, float dy) -{ - stbtt__csctx_close_shape(ctx); - ctx->first_x = ctx->x = ctx->x + dx; - ctx->first_y = ctx->y = ctx->y + dy; - stbtt__csctx_v(ctx, STBTT_vmove, (int)ctx->x, (int)ctx->y, 0, 0, 0, 0); -} - -static void stbtt__csctx_rline_to(stbtt__csctx *ctx, float dx, float dy) -{ - ctx->x += dx; - ctx->y += dy; - stbtt__csctx_v(ctx, STBTT_vline, (int)ctx->x, (int)ctx->y, 0, 0, 0, 0); -} - -static void stbtt__csctx_rccurve_to(stbtt__csctx *ctx, float dx1, float dy1, float dx2, float dy2, float dx3, float dy3) -{ - float cx1 = ctx->x + dx1; - float cy1 = ctx->y + dy1; - float cx2 = cx1 + dx2; - float cy2 = cy1 + dy2; - ctx->x = cx2 + dx3; - ctx->y = cy2 + dy3; - stbtt__csctx_v(ctx, STBTT_vcubic, (int)ctx->x, (int)ctx->y, (int)cx1, (int)cy1, (int)cx2, (int)cy2); -} - -static stbtt__buf stbtt__get_subr(stbtt__buf idx, int n) -{ - int count = stbtt__cff_index_count(&idx); - int bias = 107; - if (count >= 33900) - bias = 32768; - else if (count >= 1240) - bias = 1131; - n += bias; - if (n < 0 || n >= count) - return stbtt__new_buf(NULL, 0); - return stbtt__cff_index_get(idx, n); -} - -static stbtt__buf stbtt__cid_get_glyph_subrs(const stbtt_fontinfo *info, int glyph_index) -{ - stbtt__buf fdselect = info->fdselect; - int nranges, start, end, v, fmt, fdselector = -1, i; - - stbtt__buf_seek(&fdselect, 0); - fmt = stbtt__buf_get8(&fdselect); - if (fmt == 0) { - // untested - stbtt__buf_skip(&fdselect, glyph_index); - fdselector = stbtt__buf_get8(&fdselect); - } else if (fmt == 3) { - nranges = stbtt__buf_get16(&fdselect); - start = stbtt__buf_get16(&fdselect); - for (i = 0; i < nranges; i++) { - v = stbtt__buf_get8(&fdselect); - end = stbtt__buf_get16(&fdselect); - if (glyph_index >= start && glyph_index < end) { - fdselector = v; - break; - } - start = end; - } - } - if (fdselector == -1) stbtt__new_buf(NULL, 0); - return stbtt__get_subrs(info->cff, stbtt__cff_index_get(info->fontdicts, fdselector)); -} - -static int stbtt__run_charstring(const stbtt_fontinfo *info, int glyph_index, stbtt__csctx *c) -{ - int in_header = 1, maskbits = 0, subr_stack_height = 0, sp = 0, v, i, b0; - int has_subrs = 0, clear_stack; - float s[48]; - stbtt__buf subr_stack[10], subrs = info->subrs, b; - float f; - -#define STBTT__CSERR(s) (0) - - // this currently ignores the initial width value, which isn't needed if we have hmtx - b = stbtt__cff_index_get(info->charstrings, glyph_index); - while (b.cursor < b.size) { - i = 0; - clear_stack = 1; - b0 = stbtt__buf_get8(&b); - switch (b0) { - // @TODO implement hinting - case 0x13: // hintmask - case 0x14: // cntrmask - if (in_header) - maskbits += (sp / 2); // implicit "vstem" - in_header = 0; - stbtt__buf_skip(&b, (maskbits + 7) / 8); - break; - - case 0x01: // hstem - case 0x03: // vstem - case 0x12: // hstemhm - case 0x17: // vstemhm - maskbits += (sp / 2); - break; - - case 0x15: // rmoveto - in_header = 0; - if (sp < 2) return STBTT__CSERR("rmoveto stack"); - stbtt__csctx_rmove_to(c, s[sp-2], s[sp-1]); - break; - case 0x04: // vmoveto - in_header = 0; - if (sp < 1) return STBTT__CSERR("vmoveto stack"); - stbtt__csctx_rmove_to(c, 0, s[sp-1]); - break; - case 0x16: // hmoveto - in_header = 0; - if (sp < 1) return STBTT__CSERR("hmoveto stack"); - stbtt__csctx_rmove_to(c, s[sp-1], 0); - break; - - case 0x05: // rlineto - if (sp < 2) return STBTT__CSERR("rlineto stack"); - for (; i + 1 < sp; i += 2) - stbtt__csctx_rline_to(c, s[i], s[i+1]); - break; - - // hlineto/vlineto and vhcurveto/hvcurveto alternate horizontal and vertical - // starting from a different place. - - case 0x07: // vlineto - if (sp < 1) return STBTT__CSERR("vlineto stack"); - goto vlineto; - case 0x06: // hlineto - if (sp < 1) return STBTT__CSERR("hlineto stack"); - for (;;) { - if (i >= sp) break; - stbtt__csctx_rline_to(c, s[i], 0); - i++; - vlineto: - if (i >= sp) break; - stbtt__csctx_rline_to(c, 0, s[i]); - i++; - } - break; - - case 0x1F: // hvcurveto - if (sp < 4) return STBTT__CSERR("hvcurveto stack"); - goto hvcurveto; - case 0x1E: // vhcurveto - if (sp < 4) return STBTT__CSERR("vhcurveto stack"); - for (;;) { - if (i + 3 >= sp) break; - stbtt__csctx_rccurve_to(c, 0, s[i], s[i+1], s[i+2], s[i+3], (sp - i == 5) ? s[i + 4] : 0.0f); - i += 4; - hvcurveto: - if (i + 3 >= sp) break; - stbtt__csctx_rccurve_to(c, s[i], 0, s[i+1], s[i+2], (sp - i == 5) ? s[i+4] : 0.0f, s[i+3]); - i += 4; - } - break; - - case 0x08: // rrcurveto - if (sp < 6) return STBTT__CSERR("rcurveline stack"); - for (; i + 5 < sp; i += 6) - stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); - break; - - case 0x18: // rcurveline - if (sp < 8) return STBTT__CSERR("rcurveline stack"); - for (; i + 5 < sp - 2; i += 6) - stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); - if (i + 1 >= sp) return STBTT__CSERR("rcurveline stack"); - stbtt__csctx_rline_to(c, s[i], s[i+1]); - break; - - case 0x19: // rlinecurve - if (sp < 8) return STBTT__CSERR("rlinecurve stack"); - for (; i + 1 < sp - 6; i += 2) - stbtt__csctx_rline_to(c, s[i], s[i+1]); - if (i + 5 >= sp) return STBTT__CSERR("rlinecurve stack"); - stbtt__csctx_rccurve_to(c, s[i], s[i+1], s[i+2], s[i+3], s[i+4], s[i+5]); - break; - - case 0x1A: // vvcurveto - case 0x1B: // hhcurveto - if (sp < 4) return STBTT__CSERR("(vv|hh)curveto stack"); - f = 0.0; - if (sp & 1) { f = s[i]; i++; } - for (; i + 3 < sp; i += 4) { - if (b0 == 0x1B) - stbtt__csctx_rccurve_to(c, s[i], f, s[i+1], s[i+2], s[i+3], 0.0); - else - stbtt__csctx_rccurve_to(c, f, s[i], s[i+1], s[i+2], 0.0, s[i+3]); - f = 0.0; - } - break; - - case 0x0A: // callsubr - if (!has_subrs) { - if (info->fdselect.size) - subrs = stbtt__cid_get_glyph_subrs(info, glyph_index); - has_subrs = 1; - } - // fallthrough - case 0x1D: // callgsubr - if (sp < 1) return STBTT__CSERR("call(g|)subr stack"); - v = (int) s[--sp]; - if (subr_stack_height >= 10) return STBTT__CSERR("recursion limit"); - subr_stack[subr_stack_height++] = b; - b = stbtt__get_subr(b0 == 0x0A ? subrs : info->gsubrs, v); - if (b.size == 0) return STBTT__CSERR("subr not found"); - b.cursor = 0; - clear_stack = 0; - break; - - case 0x0B: // return - if (subr_stack_height <= 0) return STBTT__CSERR("return outside subr"); - b = subr_stack[--subr_stack_height]; - clear_stack = 0; - break; - - case 0x0E: // endchar - stbtt__csctx_close_shape(c); - return 1; - - case 0x0C: { // two-byte escape - float dx1, dx2, dx3, dx4, dx5, dx6, dy1, dy2, dy3, dy4, dy5, dy6; - float dx, dy; - int b1 = stbtt__buf_get8(&b); - switch (b1) { - // @TODO These "flex" implementations ignore the flex-depth and resolution, - // and always draw beziers. - case 0x22: // hflex - if (sp < 7) return STBTT__CSERR("hflex stack"); - dx1 = s[0]; - dx2 = s[1]; - dy2 = s[2]; - dx3 = s[3]; - dx4 = s[4]; - dx5 = s[5]; - dx6 = s[6]; - stbtt__csctx_rccurve_to(c, dx1, 0, dx2, dy2, dx3, 0); - stbtt__csctx_rccurve_to(c, dx4, 0, dx5, -dy2, dx6, 0); - break; - - case 0x23: // flex - if (sp < 13) return STBTT__CSERR("flex stack"); - dx1 = s[0]; - dy1 = s[1]; - dx2 = s[2]; - dy2 = s[3]; - dx3 = s[4]; - dy3 = s[5]; - dx4 = s[6]; - dy4 = s[7]; - dx5 = s[8]; - dy5 = s[9]; - dx6 = s[10]; - dy6 = s[11]; - //fd is s[12] - stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, dy3); - stbtt__csctx_rccurve_to(c, dx4, dy4, dx5, dy5, dx6, dy6); - break; - - case 0x24: // hflex1 - if (sp < 9) return STBTT__CSERR("hflex1 stack"); - dx1 = s[0]; - dy1 = s[1]; - dx2 = s[2]; - dy2 = s[3]; - dx3 = s[4]; - dx4 = s[5]; - dx5 = s[6]; - dy5 = s[7]; - dx6 = s[8]; - stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, 0); - stbtt__csctx_rccurve_to(c, dx4, 0, dx5, dy5, dx6, -(dy1+dy2+dy5)); - break; - - case 0x25: // flex1 - if (sp < 11) return STBTT__CSERR("flex1 stack"); - dx1 = s[0]; - dy1 = s[1]; - dx2 = s[2]; - dy2 = s[3]; - dx3 = s[4]; - dy3 = s[5]; - dx4 = s[6]; - dy4 = s[7]; - dx5 = s[8]; - dy5 = s[9]; - dx6 = dy6 = s[10]; - dx = dx1+dx2+dx3+dx4+dx5; - dy = dy1+dy2+dy3+dy4+dy5; - if (STBTT_fabs(dx) > STBTT_fabs(dy)) - dy6 = -dy; - else - dx6 = -dx; - stbtt__csctx_rccurve_to(c, dx1, dy1, dx2, dy2, dx3, dy3); - stbtt__csctx_rccurve_to(c, dx4, dy4, dx5, dy5, dx6, dy6); - break; - - default: - return STBTT__CSERR("unimplemented"); - } - } break; - - default: - if (b0 != 255 && b0 != 28 && (b0 < 32 || b0 > 254)) //-V560 - return STBTT__CSERR("reserved operator"); - - // push immediate - if (b0 == 255) { - f = (float)(stbtt_int32)stbtt__buf_get32(&b) / 0x10000; - } else { - stbtt__buf_skip(&b, -1); - f = (float)(stbtt_int16)stbtt__cff_int(&b); - } - if (sp >= 48) return STBTT__CSERR("push stack overflow"); - s[sp++] = f; - clear_stack = 0; - break; - } - if (clear_stack) sp = 0; - } - return STBTT__CSERR("no endchar"); - -#undef STBTT__CSERR -} - -static int stbtt__GetGlyphShapeT2(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) -{ - // runs the charstring twice, once to count and once to output (to avoid realloc) - stbtt__csctx count_ctx = STBTT__CSCTX_INIT(1); - stbtt__csctx output_ctx = STBTT__CSCTX_INIT(0); - if (stbtt__run_charstring(info, glyph_index, &count_ctx)) { - *pvertices = (stbtt_vertex*)STBTT_malloc(count_ctx.num_vertices*sizeof(stbtt_vertex), info->userdata); - output_ctx.pvertices = *pvertices; - if (stbtt__run_charstring(info, glyph_index, &output_ctx)) { - STBTT_assert(output_ctx.num_vertices == count_ctx.num_vertices); - return output_ctx.num_vertices; - } - } - *pvertices = NULL; - return 0; -} - -static int stbtt__GetGlyphInfoT2(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1) -{ - stbtt__csctx c = STBTT__CSCTX_INIT(1); - int r = stbtt__run_charstring(info, glyph_index, &c); - if (x0) *x0 = r ? c.min_x : 0; - if (y0) *y0 = r ? c.min_y : 0; - if (x1) *x1 = r ? c.max_x : 0; - if (y1) *y1 = r ? c.max_y : 0; - return r ? c.num_vertices : 0; -} - -STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices) -{ - if (!info->cff.size) - return stbtt__GetGlyphShapeTT(info, glyph_index, pvertices); - else - return stbtt__GetGlyphShapeT2(info, glyph_index, pvertices); -} - -STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing) -{ - stbtt_uint16 numOfLongHorMetrics = ttUSHORT(info->data+info->hhea + 34); - if (glyph_index < numOfLongHorMetrics) { - if (advanceWidth) *advanceWidth = ttSHORT(info->data + info->hmtx + 4*glyph_index); - if (leftSideBearing) *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*glyph_index + 2); - } else { - if (advanceWidth) *advanceWidth = ttSHORT(info->data + info->hmtx + 4*(numOfLongHorMetrics-1)); - if (leftSideBearing) *leftSideBearing = ttSHORT(info->data + info->hmtx + 4*numOfLongHorMetrics + 2*(glyph_index - numOfLongHorMetrics)); - } -} - -static int stbtt__GetGlyphKernInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2) -{ - stbtt_uint8 *data = info->data + info->kern; - stbtt_uint32 needle, straw; - int l, r, m; - - // we only look at the first table. it must be 'horizontal' and format 0. - if (!info->kern) - return 0; - if (ttUSHORT(data+2) < 1) // number of tables, need at least 1 - return 0; - if (ttUSHORT(data+8) != 1) // horizontal flag must be set in format - return 0; - - l = 0; - r = ttUSHORT(data+10) - 1; - needle = glyph1 << 16 | glyph2; - while (l <= r) { - m = (l + r) >> 1; - straw = ttULONG(data+18+(m*6)); // note: unaligned read - if (needle < straw) - r = m - 1; - else if (needle > straw) - l = m + 1; - else - return ttSHORT(data+22+(m*6)); - } - return 0; -} - -static stbtt_int32 stbtt__GetCoverageIndex(stbtt_uint8 *coverageTable, int glyph) -{ - stbtt_uint16 coverageFormat = ttUSHORT(coverageTable); - switch(coverageFormat) { - case 1: { - stbtt_uint16 glyphCount = ttUSHORT(coverageTable + 2); - - // Binary search. - stbtt_int32 l=0, r=glyphCount-1, m; - int straw, needle=glyph; - while (l <= r) { - stbtt_uint8 *glyphArray = coverageTable + 4; - stbtt_uint16 glyphID; - m = (l + r) >> 1; - glyphID = ttUSHORT(glyphArray + 2 * m); - straw = glyphID; - if (needle < straw) - r = m - 1; - else if (needle > straw) - l = m + 1; - else { - return m; - } - } - } break; - - case 2: { - stbtt_uint16 rangeCount = ttUSHORT(coverageTable + 2); - stbtt_uint8 *rangeArray = coverageTable + 4; - - // Binary search. - stbtt_int32 l=0, r=rangeCount-1, m; - int strawStart, strawEnd, needle=glyph; - while (l <= r) { - stbtt_uint8 *rangeRecord; - m = (l + r) >> 1; - rangeRecord = rangeArray + 6 * m; - strawStart = ttUSHORT(rangeRecord); - strawEnd = ttUSHORT(rangeRecord + 2); - if (needle < strawStart) - r = m - 1; - else if (needle > strawEnd) - l = m + 1; - else { - stbtt_uint16 startCoverageIndex = ttUSHORT(rangeRecord + 4); - return startCoverageIndex + glyph - strawStart; - } - } - } break; - - default: { - // There are no other cases. - STBTT_assert(0); - } break; - } - - return -1; -} - -static stbtt_int32 stbtt__GetGlyphClass(stbtt_uint8 *classDefTable, int glyph) -{ - stbtt_uint16 classDefFormat = ttUSHORT(classDefTable); - switch(classDefFormat) - { - case 1: { - stbtt_uint16 startGlyphID = ttUSHORT(classDefTable + 2); - stbtt_uint16 glyphCount = ttUSHORT(classDefTable + 4); - stbtt_uint8 *classDef1ValueArray = classDefTable + 6; - - if (glyph >= startGlyphID && glyph < startGlyphID + glyphCount) - return (stbtt_int32)ttUSHORT(classDef1ValueArray + 2 * (glyph - startGlyphID)); - - // [DEAR IMGUI] Commented to fix static analyzer warning - //classDefTable = classDef1ValueArray + 2 * glyphCount; - } break; - - case 2: { - stbtt_uint16 classRangeCount = ttUSHORT(classDefTable + 2); - stbtt_uint8 *classRangeRecords = classDefTable + 4; - - // Binary search. - stbtt_int32 l=0, r=classRangeCount-1, m; - int strawStart, strawEnd, needle=glyph; - while (l <= r) { - stbtt_uint8 *classRangeRecord; - m = (l + r) >> 1; - classRangeRecord = classRangeRecords + 6 * m; - strawStart = ttUSHORT(classRangeRecord); - strawEnd = ttUSHORT(classRangeRecord + 2); - if (needle < strawStart) - r = m - 1; - else if (needle > strawEnd) - l = m + 1; - else - return (stbtt_int32)ttUSHORT(classRangeRecord + 4); - } - - // [DEAR IMGUI] Commented to fix static analyzer warning - //classDefTable = classRangeRecords + 6 * classRangeCount; - } break; - - default: { - // There are no other cases. - STBTT_assert(0); - } break; - } - - return -1; -} - -// Define to STBTT_assert(x) if you want to break on unimplemented formats. -#define STBTT_GPOS_TODO_assert(x) - -static stbtt_int32 stbtt__GetGlyphGPOSInfoAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2) -{ - stbtt_uint16 lookupListOffset; - stbtt_uint8 *lookupList; - stbtt_uint16 lookupCount; - stbtt_uint8 *data; - stbtt_int32 i; - - if (!info->gpos) return 0; - - data = info->data + info->gpos; - - if (ttUSHORT(data+0) != 1) return 0; // Major version 1 - if (ttUSHORT(data+2) != 0) return 0; // Minor version 0 - - lookupListOffset = ttUSHORT(data+8); - lookupList = data + lookupListOffset; - lookupCount = ttUSHORT(lookupList); - - for (i=0; i> 1; - pairValue = pairValueArray + (2 + valueRecordPairSizeInBytes) * m; - secondGlyph = ttUSHORT(pairValue); - straw = secondGlyph; - if (needle < straw) - r = m - 1; - else if (needle > straw) - l = m + 1; - else { - stbtt_int16 xAdvance = ttSHORT(pairValue + 2); - return xAdvance; - } - } - } break; - - case 2: { - stbtt_uint16 valueFormat1 = ttUSHORT(table + 4); - stbtt_uint16 valueFormat2 = ttUSHORT(table + 6); - - stbtt_uint16 classDef1Offset = ttUSHORT(table + 8); - stbtt_uint16 classDef2Offset = ttUSHORT(table + 10); - int glyph1class = stbtt__GetGlyphClass(table + classDef1Offset, glyph1); - int glyph2class = stbtt__GetGlyphClass(table + classDef2Offset, glyph2); - - stbtt_uint16 class1Count = ttUSHORT(table + 12); - stbtt_uint16 class2Count = ttUSHORT(table + 14); - STBTT_assert(glyph1class < class1Count); - STBTT_assert(glyph2class < class2Count); - - // TODO: Support more formats. - STBTT_GPOS_TODO_assert(valueFormat1 == 4); - if (valueFormat1 != 4) return 0; - STBTT_GPOS_TODO_assert(valueFormat2 == 0); - if (valueFormat2 != 0) return 0; - - if (glyph1class >= 0 && glyph1class < class1Count && glyph2class >= 0 && glyph2class < class2Count) { - stbtt_uint8 *class1Records = table + 16; - stbtt_uint8 *class2Records = class1Records + 2 * (glyph1class * class2Count); - stbtt_int16 xAdvance = ttSHORT(class2Records + 2 * glyph2class); - return xAdvance; - } - } break; - - default: { - // There are no other cases. - STBTT_assert(0); - break; - } // [DEAR IMGUI] removed ; - } - } - break; - } // [DEAR IMGUI] removed ; - - default: - // TODO: Implement other stuff. - break; - } - } - - return 0; -} - -STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int g1, int g2) -{ - int xAdvance = 0; - - if (info->gpos) - xAdvance += stbtt__GetGlyphGPOSInfoAdvance(info, g1, g2); - - if (info->kern) - xAdvance += stbtt__GetGlyphKernInfoAdvance(info, g1, g2); - - return xAdvance; -} - -STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2) -{ - if (!info->kern && !info->gpos) // if no kerning table, don't waste time looking up both codepoint->glyphs - return 0; - return stbtt_GetGlyphKernAdvance(info, stbtt_FindGlyphIndex(info,ch1), stbtt_FindGlyphIndex(info,ch2)); -} - -STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing) -{ - stbtt_GetGlyphHMetrics(info, stbtt_FindGlyphIndex(info,codepoint), advanceWidth, leftSideBearing); -} - -STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap) -{ - if (ascent ) *ascent = ttSHORT(info->data+info->hhea + 4); - if (descent) *descent = ttSHORT(info->data+info->hhea + 6); - if (lineGap) *lineGap = ttSHORT(info->data+info->hhea + 8); -} - -STBTT_DEF int stbtt_GetFontVMetricsOS2(const stbtt_fontinfo *info, int *typoAscent, int *typoDescent, int *typoLineGap) -{ - int tab = stbtt__find_table(info->data, info->fontstart, "OS/2"); - if (!tab) - return 0; - if (typoAscent ) *typoAscent = ttSHORT(info->data+tab + 68); - if (typoDescent) *typoDescent = ttSHORT(info->data+tab + 70); - if (typoLineGap) *typoLineGap = ttSHORT(info->data+tab + 72); - return 1; -} - -STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1) -{ - *x0 = ttSHORT(info->data + info->head + 36); - *y0 = ttSHORT(info->data + info->head + 38); - *x1 = ttSHORT(info->data + info->head + 40); - *y1 = ttSHORT(info->data + info->head + 42); -} - -STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float height) -{ - int fheight = ttSHORT(info->data + info->hhea + 4) - ttSHORT(info->data + info->hhea + 6); - return (float) height / fheight; -} - -STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels) -{ - int unitsPerEm = ttUSHORT(info->data + info->head + 18); - return pixels / unitsPerEm; -} - -STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *v) -{ - STBTT_free(v, info->userdata); -} - -////////////////////////////////////////////////////////////////////////////// -// -// antialiasing software rasterizer -// - -STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1) -{ - int x0=0,y0=0,x1,y1; // =0 suppresses compiler warning - if (!stbtt_GetGlyphBox(font, glyph, &x0,&y0,&x1,&y1)) { - // e.g. space character - if (ix0) *ix0 = 0; - if (iy0) *iy0 = 0; - if (ix1) *ix1 = 0; - if (iy1) *iy1 = 0; - } else { - // move to integral bboxes (treating pixels as little squares, what pixels get touched)? - if (ix0) *ix0 = STBTT_ifloor( x0 * scale_x + shift_x); - if (iy0) *iy0 = STBTT_ifloor(-y1 * scale_y + shift_y); - if (ix1) *ix1 = STBTT_iceil ( x1 * scale_x + shift_x); - if (iy1) *iy1 = STBTT_iceil (-y0 * scale_y + shift_y); - } -} - -STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1) -{ - stbtt_GetGlyphBitmapBoxSubpixel(font, glyph, scale_x, scale_y,0.0f,0.0f, ix0, iy0, ix1, iy1); -} - -STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1) -{ - stbtt_GetGlyphBitmapBoxSubpixel(font, stbtt_FindGlyphIndex(font,codepoint), scale_x, scale_y,shift_x,shift_y, ix0,iy0,ix1,iy1); -} - -STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1) -{ - stbtt_GetCodepointBitmapBoxSubpixel(font, codepoint, scale_x, scale_y,0.0f,0.0f, ix0,iy0,ix1,iy1); -} - -////////////////////////////////////////////////////////////////////////////// -// -// Rasterizer - -typedef struct stbtt__hheap_chunk -{ - struct stbtt__hheap_chunk *next; -} stbtt__hheap_chunk; - -typedef struct stbtt__hheap -{ - struct stbtt__hheap_chunk *head; - void *first_free; - int num_remaining_in_head_chunk; -} stbtt__hheap; - -static void *stbtt__hheap_alloc(stbtt__hheap *hh, size_t size, void *userdata) -{ - if (hh->first_free) { - void *p = hh->first_free; - hh->first_free = * (void **) p; - return p; - } else { - if (hh->num_remaining_in_head_chunk == 0) { - int count = (size < 32 ? 2000 : size < 128 ? 800 : 100); - stbtt__hheap_chunk *c = (stbtt__hheap_chunk *) STBTT_malloc(sizeof(stbtt__hheap_chunk) + size * count, userdata); - if (c == NULL) - return NULL; - c->next = hh->head; - hh->head = c; - hh->num_remaining_in_head_chunk = count; - } - --hh->num_remaining_in_head_chunk; - return (char *) (hh->head) + sizeof(stbtt__hheap_chunk) + size * hh->num_remaining_in_head_chunk; - } -} - -static void stbtt__hheap_free(stbtt__hheap *hh, void *p) -{ - *(void **) p = hh->first_free; - hh->first_free = p; -} - -static void stbtt__hheap_cleanup(stbtt__hheap *hh, void *userdata) -{ - stbtt__hheap_chunk *c = hh->head; - while (c) { - stbtt__hheap_chunk *n = c->next; - STBTT_free(c, userdata); - c = n; - } -} - -typedef struct stbtt__edge { - float x0,y0, x1,y1; - int invert; -} stbtt__edge; - - -typedef struct stbtt__active_edge -{ - struct stbtt__active_edge *next; - #if STBTT_RASTERIZER_VERSION==1 - int x,dx; - float ey; - int direction; - #elif STBTT_RASTERIZER_VERSION==2 - float fx,fdx,fdy; - float direction; - float sy; - float ey; - #else - #error "Unrecognized value of STBTT_RASTERIZER_VERSION" - #endif -} stbtt__active_edge; - -#if STBTT_RASTERIZER_VERSION == 1 -#define STBTT_FIXSHIFT 10 -#define STBTT_FIX (1 << STBTT_FIXSHIFT) -#define STBTT_FIXMASK (STBTT_FIX-1) - -static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, int off_x, float start_point, void *userdata) -{ - stbtt__active_edge *z = (stbtt__active_edge *) stbtt__hheap_alloc(hh, sizeof(*z), userdata); - float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0); - STBTT_assert(z != NULL); - if (!z) return z; - - // round dx down to avoid overshooting - if (dxdy < 0) - z->dx = -STBTT_ifloor(STBTT_FIX * -dxdy); - else - z->dx = STBTT_ifloor(STBTT_FIX * dxdy); - - z->x = STBTT_ifloor(STBTT_FIX * e->x0 + z->dx * (start_point - e->y0)); // use z->dx so when we offset later it's by the same amount - z->x -= off_x * STBTT_FIX; - - z->ey = e->y1; - z->next = 0; - z->direction = e->invert ? 1 : -1; - return z; -} -#elif STBTT_RASTERIZER_VERSION == 2 -static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, int off_x, float start_point, void *userdata) -{ - stbtt__active_edge *z = (stbtt__active_edge *) stbtt__hheap_alloc(hh, sizeof(*z), userdata); - float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0); - STBTT_assert(z != NULL); - //STBTT_assert(e->y0 <= start_point); - if (!z) return z; - z->fdx = dxdy; - z->fdy = dxdy != 0.0f ? (1.0f/dxdy) : 0.0f; - z->fx = e->x0 + dxdy * (start_point - e->y0); - z->fx -= off_x; - z->direction = e->invert ? 1.0f : -1.0f; - z->sy = e->y0; - z->ey = e->y1; - z->next = 0; - return z; -} -#else -#error "Unrecognized value of STBTT_RASTERIZER_VERSION" -#endif - -#if STBTT_RASTERIZER_VERSION == 1 -// note: this routine clips fills that extend off the edges... ideally this -// wouldn't happen, but it could happen if the truetype glyph bounding boxes -// are wrong, or if the user supplies a too-small bitmap -static void stbtt__fill_active_edges(unsigned char *scanline, int len, stbtt__active_edge *e, int max_weight) -{ - // non-zero winding fill - int x0=0, w=0; - - while (e) { - if (w == 0) { - // if we're currently at zero, we need to record the edge start point - x0 = e->x; w += e->direction; - } else { - int x1 = e->x; w += e->direction; - // if we went to zero, we need to draw - if (w == 0) { - int i = x0 >> STBTT_FIXSHIFT; - int j = x1 >> STBTT_FIXSHIFT; - - if (i < len && j >= 0) { - if (i == j) { - // x0,x1 are the same pixel, so compute combined coverage - scanline[i] = scanline[i] + (stbtt_uint8) ((x1 - x0) * max_weight >> STBTT_FIXSHIFT); - } else { - if (i >= 0) // add antialiasing for x0 - scanline[i] = scanline[i] + (stbtt_uint8) (((STBTT_FIX - (x0 & STBTT_FIXMASK)) * max_weight) >> STBTT_FIXSHIFT); - else - i = -1; // clip - - if (j < len) // add antialiasing for x1 - scanline[j] = scanline[j] + (stbtt_uint8) (((x1 & STBTT_FIXMASK) * max_weight) >> STBTT_FIXSHIFT); - else - j = len; // clip - - for (++i; i < j; ++i) // fill pixels between x0 and x1 - scanline[i] = scanline[i] + (stbtt_uint8) max_weight; - } - } - } - } - - e = e->next; - } -} - -static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, int n, int vsubsample, int off_x, int off_y, void *userdata) -{ - stbtt__hheap hh = { 0, 0, 0 }; - stbtt__active_edge *active = NULL; - int y,j=0; - int max_weight = (255 / vsubsample); // weight per vertical scanline - int s; // vertical subsample index - unsigned char scanline_data[512], *scanline; - - if (result->w > 512) - scanline = (unsigned char *) STBTT_malloc(result->w, userdata); - else - scanline = scanline_data; - - y = off_y * vsubsample; - e[n].y0 = (off_y + result->h) * (float) vsubsample + 1; - - while (j < result->h) { - STBTT_memset(scanline, 0, result->w); - for (s=0; s < vsubsample; ++s) { - // find center of pixel for this scanline - float scan_y = y + 0.5f; - stbtt__active_edge **step = &active; - - // update all active edges; - // remove all active edges that terminate before the center of this scanline - while (*step) { - stbtt__active_edge * z = *step; - if (z->ey <= scan_y) { - *step = z->next; // delete from list - STBTT_assert(z->direction); - z->direction = 0; - stbtt__hheap_free(&hh, z); - } else { - z->x += z->dx; // advance to position for current scanline - step = &((*step)->next); // advance through list - } - } - - // resort the list if needed - for(;;) { - int changed=0; - step = &active; - while (*step && (*step)->next) { - if ((*step)->x > (*step)->next->x) { - stbtt__active_edge *t = *step; - stbtt__active_edge *q = t->next; - - t->next = q->next; - q->next = t; - *step = q; - changed = 1; - } - step = &(*step)->next; - } - if (!changed) break; - } - - // insert all edges that start before the center of this scanline -- omit ones that also end on this scanline - while (e->y0 <= scan_y) { - if (e->y1 > scan_y) { - stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y, userdata); - if (z != NULL) { - // find insertion point - if (active == NULL) - active = z; - else if (z->x < active->x) { - // insert at front - z->next = active; - active = z; - } else { - // find thing to insert AFTER - stbtt__active_edge *p = active; - while (p->next && p->next->x < z->x) - p = p->next; - // at this point, p->next->x is NOT < z->x - z->next = p->next; - p->next = z; - } - } - } - ++e; - } - - // now process all active edges in XOR fashion - if (active) - stbtt__fill_active_edges(scanline, result->w, active, max_weight); - - ++y; - } - STBTT_memcpy(result->pixels + j * result->stride, scanline, result->w); - ++j; - } - - stbtt__hheap_cleanup(&hh, userdata); - - if (scanline != scanline_data) - STBTT_free(scanline, userdata); -} - -#elif STBTT_RASTERIZER_VERSION == 2 - -// the edge passed in here does not cross the vertical line at x or the vertical line at x+1 -// (i.e. it has already been clipped to those) -static void stbtt__handle_clipped_edge(float *scanline, int x, stbtt__active_edge *e, float x0, float y0, float x1, float y1) -{ - if (y0 == y1) return; - STBTT_assert(y0 < y1); - STBTT_assert(e->sy <= e->ey); - if (y0 > e->ey) return; - if (y1 < e->sy) return; - if (y0 < e->sy) { - x0 += (x1-x0) * (e->sy - y0) / (y1-y0); - y0 = e->sy; - } - if (y1 > e->ey) { - x1 += (x1-x0) * (e->ey - y1) / (y1-y0); - y1 = e->ey; - } - - if (x0 == x) - STBTT_assert(x1 <= x+1); - else if (x0 == x+1) - STBTT_assert(x1 >= x); - else if (x0 <= x) - STBTT_assert(x1 <= x); - else if (x0 >= x+1) - STBTT_assert(x1 >= x+1); - else - STBTT_assert(x1 >= x && x1 <= x+1); - - if (x0 <= x && x1 <= x) - scanline[x] += e->direction * (y1-y0); - else if (x0 >= x+1 && x1 >= x+1) - ; - else { - STBTT_assert(x0 >= x && x0 <= x+1 && x1 >= x && x1 <= x+1); - scanline[x] += e->direction * (y1-y0) * (1-((x0-x)+(x1-x))/2); // coverage = 1 - average x position - } -} - -static void stbtt__fill_active_edges_new(float *scanline, float *scanline_fill, int len, stbtt__active_edge *e, float y_top) -{ - float y_bottom = y_top+1; - - while (e) { - // brute force every pixel - - // compute intersection points with top & bottom - STBTT_assert(e->ey >= y_top); - - if (e->fdx == 0) { - float x0 = e->fx; - if (x0 < len) { - if (x0 >= 0) { - stbtt__handle_clipped_edge(scanline,(int) x0,e, x0,y_top, x0,y_bottom); - stbtt__handle_clipped_edge(scanline_fill-1,(int) x0+1,e, x0,y_top, x0,y_bottom); - } else { - stbtt__handle_clipped_edge(scanline_fill-1,0,e, x0,y_top, x0,y_bottom); - } - } - } else { - float x0 = e->fx; - float dx = e->fdx; - float xb = x0 + dx; - float x_top, x_bottom; - float sy0,sy1; - float dy = e->fdy; - STBTT_assert(e->sy <= y_bottom && e->ey >= y_top); - - // compute endpoints of line segment clipped to this scanline (if the - // line segment starts on this scanline. x0 is the intersection of the - // line with y_top, but that may be off the line segment. - if (e->sy > y_top) { - x_top = x0 + dx * (e->sy - y_top); - sy0 = e->sy; - } else { - x_top = x0; - sy0 = y_top; - } - if (e->ey < y_bottom) { - x_bottom = x0 + dx * (e->ey - y_top); - sy1 = e->ey; - } else { - x_bottom = xb; - sy1 = y_bottom; - } - - if (x_top >= 0 && x_bottom >= 0 && x_top < len && x_bottom < len) { - // from here on, we don't have to range check x values - - if ((int) x_top == (int) x_bottom) { - float height; - // simple case, only spans one pixel - int x = (int) x_top; - height = sy1 - sy0; - STBTT_assert(x >= 0 && x < len); - scanline[x] += e->direction * (1-((x_top - x) + (x_bottom-x))/2) * height; - scanline_fill[x] += e->direction * height; // everything right of this pixel is filled - } else { - int x,x1,x2; - float y_crossing, step, sign, area; - // covers 2+ pixels - if (x_top > x_bottom) { - // flip scanline vertically; signed area is the same - float t; - sy0 = y_bottom - (sy0 - y_top); - sy1 = y_bottom - (sy1 - y_top); - t = sy0, sy0 = sy1, sy1 = t; - t = x_bottom, x_bottom = x_top, x_top = t; - dx = -dx; - dy = -dy; - t = x0, x0 = xb, xb = t; - // [DEAR IMGUI] Fix static analyzer warning - (void)dx; // [ImGui: fix static analyzer warning] - } - - x1 = (int) x_top; - x2 = (int) x_bottom; - // compute intersection with y axis at x1+1 - y_crossing = (x1+1 - x0) * dy + y_top; - - sign = e->direction; - // area of the rectangle covered from y0..y_crossing - area = sign * (y_crossing-sy0); - // area of the triangle (x_top,y0), (x+1,y0), (x+1,y_crossing) - scanline[x1] += area * (1-((x_top - x1)+(x1+1-x1))/2); - - step = sign * dy; - for (x = x1+1; x < x2; ++x) { - scanline[x] += area + step/2; - area += step; - } - y_crossing += dy * (x2 - (x1+1)); - - STBTT_assert(STBTT_fabs(area) <= 1.01f); - - scanline[x2] += area + sign * (1-((x2-x2)+(x_bottom-x2))/2) * (sy1-y_crossing); - - scanline_fill[x2] += sign * (sy1-sy0); - } - } else { - // if edge goes outside of box we're drawing, we require - // clipping logic. since this does not match the intended use - // of this library, we use a different, very slow brute - // force implementation - int x; - for (x=0; x < len; ++x) { - // cases: - // - // there can be up to two intersections with the pixel. any intersection - // with left or right edges can be handled by splitting into two (or three) - // regions. intersections with top & bottom do not necessitate case-wise logic. - // - // the old way of doing this found the intersections with the left & right edges, - // then used some simple logic to produce up to three segments in sorted order - // from top-to-bottom. however, this had a problem: if an x edge was epsilon - // across the x border, then the corresponding y position might not be distinct - // from the other y segment, and it might ignored as an empty segment. to avoid - // that, we need to explicitly produce segments based on x positions. - - // rename variables to clearly-defined pairs - float y0 = y_top; - float x1 = (float) (x); - float x2 = (float) (x+1); - float x3 = xb; - float y3 = y_bottom; - - // x = e->x + e->dx * (y-y_top) - // (y-y_top) = (x - e->x) / e->dx - // y = (x - e->x) / e->dx + y_top - float y1 = (x - x0) / dx + y_top; - float y2 = (x+1 - x0) / dx + y_top; - - if (x0 < x1 && x3 > x2) { // three segments descending down-right - stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); - stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x2,y2); - stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3); - } else if (x3 < x1 && x0 > x2) { // three segments descending down-left - stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2); - stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x1,y1); - stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3); - } else if (x0 < x1 && x3 > x1) { // two segments across x, down-right - stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); - stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3); - } else if (x3 < x1 && x0 > x1) { // two segments across x, down-left - stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x1,y1); - stbtt__handle_clipped_edge(scanline,x,e, x1,y1, x3,y3); - } else if (x0 < x2 && x3 > x2) { // two segments across x+1, down-right - stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2); - stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3); - } else if (x3 < x2 && x0 > x2) { // two segments across x+1, down-left - stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x2,y2); - stbtt__handle_clipped_edge(scanline,x,e, x2,y2, x3,y3); - } else { // one segment - stbtt__handle_clipped_edge(scanline,x,e, x0,y0, x3,y3); - } - } - } - } - e = e->next; - } -} - -// directly AA rasterize edges w/o supersampling -static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, int n, int vsubsample, int off_x, int off_y, void *userdata) -{ - stbtt__hheap hh = { 0, 0, 0 }; - stbtt__active_edge *active = NULL; - int y,j=0, i; - float scanline_data[129], *scanline, *scanline2; - - STBTT__NOTUSED(vsubsample); - - if (result->w > 64) - scanline = (float *) STBTT_malloc((result->w*2+1) * sizeof(float), userdata); - else - scanline = scanline_data; - - scanline2 = scanline + result->w; - - y = off_y; - e[n].y0 = (float) (off_y + result->h) + 1; - - while (j < result->h) { - // find center of pixel for this scanline - float scan_y_top = y + 0.0f; - float scan_y_bottom = y + 1.0f; - stbtt__active_edge **step = &active; - - STBTT_memset(scanline , 0, result->w*sizeof(scanline[0])); - STBTT_memset(scanline2, 0, (result->w+1)*sizeof(scanline[0])); - - // update all active edges; - // remove all active edges that terminate before the top of this scanline - while (*step) { - stbtt__active_edge * z = *step; - if (z->ey <= scan_y_top) { - *step = z->next; // delete from list - STBTT_assert(z->direction); - z->direction = 0; - stbtt__hheap_free(&hh, z); - } else { - step = &((*step)->next); // advance through list - } - } - - // insert all edges that start before the bottom of this scanline - while (e->y0 <= scan_y_bottom) { - if (e->y0 != e->y1) { - stbtt__active_edge *z = stbtt__new_active(&hh, e, off_x, scan_y_top, userdata); - if (z != NULL) { - if (j == 0 && off_y != 0) { - if (z->ey < scan_y_top) { - // this can happen due to subpixel positioning and some kind of fp rounding error i think - z->ey = scan_y_top; - } - } - STBTT_assert(z->ey >= scan_y_top); // if we get really unlucky a tiny bit of an edge can be out of bounds - // insert at front - z->next = active; - active = z; - } - } - ++e; - } - - // now process all active edges - if (active) - stbtt__fill_active_edges_new(scanline, scanline2+1, result->w, active, scan_y_top); - - { - float sum = 0; - for (i=0; i < result->w; ++i) { - float k; - int m; - sum += scanline2[i]; - k = scanline[i] + sum; - k = (float) STBTT_fabs(k)*255 + 0.5f; - m = (int) k; - if (m > 255) m = 255; - result->pixels[j*result->stride + i] = (unsigned char) m; - } - } - // advance all the edges - step = &active; - while (*step) { - stbtt__active_edge *z = *step; - z->fx += z->fdx; // advance to position for current scanline - step = &((*step)->next); // advance through list - } - - ++y; - ++j; - } - - stbtt__hheap_cleanup(&hh, userdata); - - if (scanline != scanline_data) - STBTT_free(scanline, userdata); -} -#else -#error "Unrecognized value of STBTT_RASTERIZER_VERSION" -#endif - -#define STBTT__COMPARE(a,b) ((a)->y0 < (b)->y0) - -static void stbtt__sort_edges_ins_sort(stbtt__edge *p, int n) -{ - int i,j; - for (i=1; i < n; ++i) { - stbtt__edge t = p[i], *a = &t; - j = i; - while (j > 0) { - stbtt__edge *b = &p[j-1]; - int c = STBTT__COMPARE(a,b); - if (!c) break; - p[j] = p[j-1]; - --j; - } - if (i != j) - p[j] = t; - } -} - -static void stbtt__sort_edges_quicksort(stbtt__edge *p, int n) -{ - /* threshold for transitioning to insertion sort */ - while (n > 12) { - stbtt__edge t; - int c01,c12,c,m,i,j; - - /* compute median of three */ - m = n >> 1; - c01 = STBTT__COMPARE(&p[0],&p[m]); - c12 = STBTT__COMPARE(&p[m],&p[n-1]); - /* if 0 >= mid >= end, or 0 < mid < end, then use mid */ - if (c01 != c12) { - /* otherwise, we'll need to swap something else to middle */ - int z; - c = STBTT__COMPARE(&p[0],&p[n-1]); - /* 0>mid && midn => n; 0 0 */ - /* 0n: 0>n => 0; 0 n */ - z = (c == c12) ? 0 : n-1; - t = p[z]; - p[z] = p[m]; - p[m] = t; - } - /* now p[m] is the median-of-three */ - /* swap it to the beginning so it won't move around */ - t = p[0]; - p[0] = p[m]; - p[m] = t; - - /* partition loop */ - i=1; - j=n-1; - for(;;) { - /* handling of equality is crucial here */ - /* for sentinels & efficiency with duplicates */ - for (;;++i) { - if (!STBTT__COMPARE(&p[i], &p[0])) break; - } - for (;;--j) { - if (!STBTT__COMPARE(&p[0], &p[j])) break; - } - /* make sure we haven't crossed */ - if (i >= j) break; - t = p[i]; - p[i] = p[j]; - p[j] = t; - - ++i; - --j; - } - /* recurse on smaller side, iterate on larger */ - if (j < (n-i)) { - stbtt__sort_edges_quicksort(p,j); - p = p+i; - n = n-i; - } else { - stbtt__sort_edges_quicksort(p+i, n-i); - n = j; - } - } -} - -static void stbtt__sort_edges(stbtt__edge *p, int n) -{ - stbtt__sort_edges_quicksort(p, n); - stbtt__sort_edges_ins_sort(p, n); -} - -typedef struct -{ - float x,y; -} stbtt__point; - -static void stbtt__rasterize(stbtt__bitmap *result, stbtt__point *pts, int *wcount, int windings, float scale_x, float scale_y, float shift_x, float shift_y, int off_x, int off_y, int invert, void *userdata) -{ - float y_scale_inv = invert ? -scale_y : scale_y; - stbtt__edge *e; - int n,i,j,k,m; -#if STBTT_RASTERIZER_VERSION == 1 - int vsubsample = result->h < 8 ? 15 : 5; -#elif STBTT_RASTERIZER_VERSION == 2 - int vsubsample = 1; -#else - #error "Unrecognized value of STBTT_RASTERIZER_VERSION" -#endif - // vsubsample should divide 255 evenly; otherwise we won't reach full opacity - - // now we have to blow out the windings into explicit edge lists - n = 0; - for (i=0; i < windings; ++i) - n += wcount[i]; - - e = (stbtt__edge *) STBTT_malloc(sizeof(*e) * (n+1), userdata); // add an extra one as a sentinel - if (e == 0) return; - n = 0; - - m=0; - for (i=0; i < windings; ++i) { - stbtt__point *p = pts + m; - m += wcount[i]; - j = wcount[i]-1; - for (k=0; k < wcount[i]; j=k++) { - int a=k,b=j; - // skip the edge if horizontal - if (p[j].y == p[k].y) - continue; - // add edge from j to k to the list - e[n].invert = 0; - if (invert ? p[j].y > p[k].y : p[j].y < p[k].y) { - e[n].invert = 1; - a=j,b=k; - } - e[n].x0 = p[a].x * scale_x + shift_x; - e[n].y0 = (p[a].y * y_scale_inv + shift_y) * vsubsample; - e[n].x1 = p[b].x * scale_x + shift_x; - e[n].y1 = (p[b].y * y_scale_inv + shift_y) * vsubsample; - ++n; - } - } - - // now sort the edges by their highest point (should snap to integer, and then by x) - //STBTT_sort(e, n, sizeof(e[0]), stbtt__edge_compare); - stbtt__sort_edges(e, n); - - // now, traverse the scanlines and find the intersections on each scanline, use xor winding rule - stbtt__rasterize_sorted_edges(result, e, n, vsubsample, off_x, off_y, userdata); - - STBTT_free(e, userdata); -} - -static void stbtt__add_point(stbtt__point *points, int n, float x, float y) -{ - if (!points) return; // during first pass, it's unallocated - points[n].x = x; - points[n].y = y; -} - -// tessellate until threshold p is happy... @TODO warped to compensate for non-linear stretching -static int stbtt__tesselate_curve(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float objspace_flatness_squared, int n) -{ - // midpoint - float mx = (x0 + 2*x1 + x2)/4; - float my = (y0 + 2*y1 + y2)/4; - // versus directly drawn line - float dx = (x0+x2)/2 - mx; - float dy = (y0+y2)/2 - my; - if (n > 16) // 65536 segments on one curve better be enough! - return 1; - if (dx*dx+dy*dy > objspace_flatness_squared) { // half-pixel error allowed... need to be smaller if AA - stbtt__tesselate_curve(points, num_points, x0,y0, (x0+x1)/2.0f,(y0+y1)/2.0f, mx,my, objspace_flatness_squared,n+1); - stbtt__tesselate_curve(points, num_points, mx,my, (x1+x2)/2.0f,(y1+y2)/2.0f, x2,y2, objspace_flatness_squared,n+1); - } else { - stbtt__add_point(points, *num_points,x2,y2); - *num_points = *num_points+1; - } - return 1; -} - -static void stbtt__tesselate_cubic(stbtt__point *points, int *num_points, float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, float objspace_flatness_squared, int n) -{ - // @TODO this "flatness" calculation is just made-up nonsense that seems to work well enough - float dx0 = x1-x0; - float dy0 = y1-y0; - float dx1 = x2-x1; - float dy1 = y2-y1; - float dx2 = x3-x2; - float dy2 = y3-y2; - float dx = x3-x0; - float dy = y3-y0; - float longlen = (float) (STBTT_sqrt(dx0*dx0+dy0*dy0)+STBTT_sqrt(dx1*dx1+dy1*dy1)+STBTT_sqrt(dx2*dx2+dy2*dy2)); - float shortlen = (float) STBTT_sqrt(dx*dx+dy*dy); - float flatness_squared = longlen*longlen-shortlen*shortlen; - - if (n > 16) // 65536 segments on one curve better be enough! - return; - - if (flatness_squared > objspace_flatness_squared) { - float x01 = (x0+x1)/2; - float y01 = (y0+y1)/2; - float x12 = (x1+x2)/2; - float y12 = (y1+y2)/2; - float x23 = (x2+x3)/2; - float y23 = (y2+y3)/2; - - float xa = (x01+x12)/2; - float ya = (y01+y12)/2; - float xb = (x12+x23)/2; - float yb = (y12+y23)/2; - - float mx = (xa+xb)/2; - float my = (ya+yb)/2; - - stbtt__tesselate_cubic(points, num_points, x0,y0, x01,y01, xa,ya, mx,my, objspace_flatness_squared,n+1); - stbtt__tesselate_cubic(points, num_points, mx,my, xb,yb, x23,y23, x3,y3, objspace_flatness_squared,n+1); - } else { - stbtt__add_point(points, *num_points,x3,y3); - *num_points = *num_points+1; - } -} - -// returns number of contours -static stbtt__point *stbtt_FlattenCurves(stbtt_vertex *vertices, int num_verts, float objspace_flatness, int **contour_lengths, int *num_contours, void *userdata) -{ - stbtt__point *points=0; - int num_points=0; - - float objspace_flatness_squared = objspace_flatness * objspace_flatness; - int i,n=0,start=0, pass; - - // count how many "moves" there are to get the contour count - for (i=0; i < num_verts; ++i) - if (vertices[i].type == STBTT_vmove) - ++n; - - *num_contours = n; - if (n == 0) return 0; - - *contour_lengths = (int *) STBTT_malloc(sizeof(**contour_lengths) * n, userdata); - - if (*contour_lengths == 0) { - *num_contours = 0; - return 0; - } - - // make two passes through the points so we don't need to realloc - for (pass=0; pass < 2; ++pass) { - float x=0,y=0; - if (pass == 1) { - points = (stbtt__point *) STBTT_malloc(num_points * sizeof(points[0]), userdata); - if (points == NULL) goto error; - } - num_points = 0; - n= -1; - for (i=0; i < num_verts; ++i) { - switch (vertices[i].type) { - case STBTT_vmove: - // start the next contour - if (n >= 0) - (*contour_lengths)[n] = num_points - start; - ++n; - start = num_points; - - x = vertices[i].x, y = vertices[i].y; - stbtt__add_point(points, num_points++, x,y); - break; - case STBTT_vline: - x = vertices[i].x, y = vertices[i].y; - stbtt__add_point(points, num_points++, x, y); - break; - case STBTT_vcurve: - stbtt__tesselate_curve(points, &num_points, x,y, - vertices[i].cx, vertices[i].cy, - vertices[i].x, vertices[i].y, - objspace_flatness_squared, 0); - x = vertices[i].x, y = vertices[i].y; - break; - case STBTT_vcubic: - stbtt__tesselate_cubic(points, &num_points, x,y, - vertices[i].cx, vertices[i].cy, - vertices[i].cx1, vertices[i].cy1, - vertices[i].x, vertices[i].y, - objspace_flatness_squared, 0); - x = vertices[i].x, y = vertices[i].y; - break; - } - } - (*contour_lengths)[n] = num_points - start; - } - - return points; -error: - STBTT_free(points, userdata); - STBTT_free(*contour_lengths, userdata); - *contour_lengths = 0; - *num_contours = 0; - return NULL; -} - -STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stbtt_vertex *vertices, int num_verts, float scale_x, float scale_y, float shift_x, float shift_y, int x_off, int y_off, int invert, void *userdata) -{ - float scale = scale_x > scale_y ? scale_y : scale_x; - int winding_count = 0; - int *winding_lengths = NULL; - stbtt__point *windings = stbtt_FlattenCurves(vertices, num_verts, flatness_in_pixels / scale, &winding_lengths, &winding_count, userdata); - if (windings) { - stbtt__rasterize(result, windings, winding_lengths, winding_count, scale_x, scale_y, shift_x, shift_y, x_off, y_off, invert, userdata); - STBTT_free(winding_lengths, userdata); - STBTT_free(windings, userdata); - } -} - -STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata) -{ - STBTT_free(bitmap, userdata); -} - -STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff) -{ - int ix0,iy0,ix1,iy1; - stbtt__bitmap gbm; - stbtt_vertex *vertices; - int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices); - - if (scale_x == 0) scale_x = scale_y; - if (scale_y == 0) { - if (scale_x == 0) { - STBTT_free(vertices, info->userdata); - return NULL; - } - scale_y = scale_x; - } - - stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,&ix1,&iy1); - - // now we get the size - gbm.w = (ix1 - ix0); - gbm.h = (iy1 - iy0); - gbm.pixels = NULL; // in case we error - - if (width ) *width = gbm.w; - if (height) *height = gbm.h; - if (xoff ) *xoff = ix0; - if (yoff ) *yoff = iy0; - - if (gbm.w && gbm.h) { - gbm.pixels = (unsigned char *) STBTT_malloc(gbm.w * gbm.h, info->userdata); - if (gbm.pixels) { - gbm.stride = gbm.w; - - stbtt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y, shift_x, shift_y, ix0, iy0, 1, info->userdata); - } - } - STBTT_free(vertices, info->userdata); - return gbm.pixels; -} - -STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff) -{ - return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y, 0.0f, 0.0f, glyph, width, height, xoff, yoff); -} - -STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph) -{ - int ix0,iy0; - stbtt_vertex *vertices; - int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices); - stbtt__bitmap gbm; - - stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,0,0); - gbm.pixels = output; - gbm.w = out_w; - gbm.h = out_h; - gbm.stride = out_stride; - - if (gbm.w && gbm.h) - stbtt_Rasterize(&gbm, 0.35f, vertices, num_verts, scale_x, scale_y, shift_x, shift_y, ix0,iy0, 1, info->userdata); - - STBTT_free(vertices, info->userdata); -} - -STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph) -{ - stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, glyph); -} - -STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff) -{ - return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y,shift_x,shift_y, stbtt_FindGlyphIndex(info,codepoint), width,height,xoff,yoff); -} - -STBTT_DEF void stbtt_MakeCodepointBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float *sub_x, float *sub_y, int codepoint) -{ - stbtt_MakeGlyphBitmapSubpixelPrefilter(info, output, out_w, out_h, out_stride, scale_x, scale_y, shift_x, shift_y, oversample_x, oversample_y, sub_x, sub_y, stbtt_FindGlyphIndex(info,codepoint)); -} - -STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint) -{ - stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, shift_x, shift_y, stbtt_FindGlyphIndex(info,codepoint)); -} - -STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff) -{ - return stbtt_GetCodepointBitmapSubpixel(info, scale_x, scale_y, 0.0f,0.0f, codepoint, width,height,xoff,yoff); -} - -STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint) -{ - stbtt_MakeCodepointBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, codepoint); -} - -////////////////////////////////////////////////////////////////////////////// -// -// bitmap baking -// -// This is SUPER-CRAPPY packing to keep source code small - -static int stbtt_BakeFontBitmap_internal(unsigned char *data, int offset, // font location (use offset=0 for plain .ttf) - float pixel_height, // height of font in pixels - unsigned char *pixels, int pw, int ph, // bitmap to be filled in - int first_char, int num_chars, // characters to bake - stbtt_bakedchar *chardata) -{ - float scale; - int x,y,bottom_y, i; - stbtt_fontinfo f; - f.userdata = NULL; - if (!stbtt_InitFont(&f, data, offset)) - return -1; - STBTT_memset(pixels, 0, pw*ph); // background of 0 around pixels - x=y=1; - bottom_y = 1; - - scale = stbtt_ScaleForPixelHeight(&f, pixel_height); - - for (i=0; i < num_chars; ++i) { - int advance, lsb, x0,y0,x1,y1,gw,gh; - int g = stbtt_FindGlyphIndex(&f, first_char + i); - stbtt_GetGlyphHMetrics(&f, g, &advance, &lsb); - stbtt_GetGlyphBitmapBox(&f, g, scale,scale, &x0,&y0,&x1,&y1); - gw = x1-x0; - gh = y1-y0; - if (x + gw + 1 >= pw) - y = bottom_y, x = 1; // advance to next row - if (y + gh + 1 >= ph) // check if it fits vertically AFTER potentially moving to next row - return -i; - STBTT_assert(x+gw < pw); - STBTT_assert(y+gh < ph); - stbtt_MakeGlyphBitmap(&f, pixels+x+y*pw, gw,gh,pw, scale,scale, g); - chardata[i].x0 = (stbtt_int16) x; - chardata[i].y0 = (stbtt_int16) y; - chardata[i].x1 = (stbtt_int16) (x + gw); - chardata[i].y1 = (stbtt_int16) (y + gh); - chardata[i].xadvance = scale * advance; - chardata[i].xoff = (float) x0; - chardata[i].yoff = (float) y0; - x = x + gw + 1; - if (y+gh+1 > bottom_y) - bottom_y = y+gh+1; - } - return bottom_y; -} - -STBTT_DEF void stbtt_GetBakedQuad(const stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule) -{ - float d3d_bias = opengl_fillrule ? 0 : -0.5f; - float ipw = 1.0f / pw, iph = 1.0f / ph; - const stbtt_bakedchar *b = chardata + char_index; - int round_x = STBTT_ifloor((*xpos + b->xoff) + 0.5f); - int round_y = STBTT_ifloor((*ypos + b->yoff) + 0.5f); - - q->x0 = round_x + d3d_bias; - q->y0 = round_y + d3d_bias; - q->x1 = round_x + b->x1 - b->x0 + d3d_bias; - q->y1 = round_y + b->y1 - b->y0 + d3d_bias; - - q->s0 = b->x0 * ipw; - q->t0 = b->y0 * iph; - q->s1 = b->x1 * ipw; - q->t1 = b->y1 * iph; - - *xpos += b->xadvance; -} - -////////////////////////////////////////////////////////////////////////////// -// -// rectangle packing replacement routines if you don't have stb_rect_pack.h -// - -#ifndef STB_RECT_PACK_VERSION - -typedef int stbrp_coord; - -//////////////////////////////////////////////////////////////////////////////////// -// // -// // -// COMPILER WARNING ?!?!? // -// // -// // -// if you get a compile warning due to these symbols being defined more than // -// once, move #include "stb_rect_pack.h" before #include "stb_truetype.h" // -// // -//////////////////////////////////////////////////////////////////////////////////// - -typedef struct -{ - int width,height; - int x,y,bottom_y; -} stbrp_context; - -typedef struct -{ - unsigned char x; -} stbrp_node; - -struct stbrp_rect -{ - stbrp_coord x,y; - int id,w,h,was_packed; -}; - -static void stbrp_init_target(stbrp_context *con, int pw, int ph, stbrp_node *nodes, int num_nodes) -{ - con->width = pw; - con->height = ph; - con->x = 0; - con->y = 0; - con->bottom_y = 0; - STBTT__NOTUSED(nodes); - STBTT__NOTUSED(num_nodes); -} - -static void stbrp_pack_rects(stbrp_context *con, stbrp_rect *rects, int num_rects) -{ - int i; - for (i=0; i < num_rects; ++i) { - if (con->x + rects[i].w > con->width) { - con->x = 0; - con->y = con->bottom_y; - } - if (con->y + rects[i].h > con->height) - break; - rects[i].x = con->x; - rects[i].y = con->y; - rects[i].was_packed = 1; - con->x += rects[i].w; - if (con->y + rects[i].h > con->bottom_y) - con->bottom_y = con->y + rects[i].h; - } - for ( ; i < num_rects; ++i) - rects[i].was_packed = 0; -} -#endif - -////////////////////////////////////////////////////////////////////////////// -// -// bitmap baking -// -// This is SUPER-AWESOME (tm Ryan Gordon) packing using stb_rect_pack.h. If -// stb_rect_pack.h isn't available, it uses the BakeFontBitmap strategy. - -STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int pw, int ph, int stride_in_bytes, int padding, void *alloc_context) -{ - stbrp_context *context = (stbrp_context *) STBTT_malloc(sizeof(*context) ,alloc_context); - int num_nodes = pw - padding; - stbrp_node *nodes = (stbrp_node *) STBTT_malloc(sizeof(*nodes ) * num_nodes,alloc_context); - - if (context == NULL || nodes == NULL) { - if (context != NULL) STBTT_free(context, alloc_context); - if (nodes != NULL) STBTT_free(nodes , alloc_context); - return 0; - } - - spc->user_allocator_context = alloc_context; - spc->width = pw; - spc->height = ph; - spc->pixels = pixels; - spc->pack_info = context; - spc->nodes = nodes; - spc->padding = padding; - spc->stride_in_bytes = stride_in_bytes != 0 ? stride_in_bytes : pw; - spc->h_oversample = 1; - spc->v_oversample = 1; - spc->skip_missing = 0; - - stbrp_init_target(context, pw-padding, ph-padding, nodes, num_nodes); - - if (pixels) - STBTT_memset(pixels, 0, pw*ph); // background of 0 around pixels - - return 1; -} - -STBTT_DEF void stbtt_PackEnd (stbtt_pack_context *spc) -{ - STBTT_free(spc->nodes , spc->user_allocator_context); - STBTT_free(spc->pack_info, spc->user_allocator_context); -} - -STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample) -{ - STBTT_assert(h_oversample <= STBTT_MAX_OVERSAMPLE); - STBTT_assert(v_oversample <= STBTT_MAX_OVERSAMPLE); - if (h_oversample <= STBTT_MAX_OVERSAMPLE) - spc->h_oversample = h_oversample; - if (v_oversample <= STBTT_MAX_OVERSAMPLE) - spc->v_oversample = v_oversample; -} - -STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip) -{ - spc->skip_missing = skip; -} - -#define STBTT__OVER_MASK (STBTT_MAX_OVERSAMPLE-1) - -static void stbtt__h_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width) -{ - unsigned char buffer[STBTT_MAX_OVERSAMPLE]; - int safe_w = w - kernel_width; - int j; - STBTT_memset(buffer, 0, STBTT_MAX_OVERSAMPLE); // suppress bogus warning from VS2013 -analyze - for (j=0; j < h; ++j) { - int i; - unsigned int total; - STBTT_memset(buffer, 0, kernel_width); - - total = 0; - - // make kernel_width a constant in common cases so compiler can optimize out the divide - switch (kernel_width) { - case 2: - for (i=0; i <= safe_w; ++i) { - total += pixels[i] - buffer[i & STBTT__OVER_MASK]; - buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; - pixels[i] = (unsigned char) (total / 2); - } - break; - case 3: - for (i=0; i <= safe_w; ++i) { - total += pixels[i] - buffer[i & STBTT__OVER_MASK]; - buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; - pixels[i] = (unsigned char) (total / 3); - } - break; - case 4: - for (i=0; i <= safe_w; ++i) { - total += pixels[i] - buffer[i & STBTT__OVER_MASK]; - buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; - pixels[i] = (unsigned char) (total / 4); - } - break; - case 5: - for (i=0; i <= safe_w; ++i) { - total += pixels[i] - buffer[i & STBTT__OVER_MASK]; - buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; - pixels[i] = (unsigned char) (total / 5); - } - break; - default: - for (i=0; i <= safe_w; ++i) { - total += pixels[i] - buffer[i & STBTT__OVER_MASK]; - buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i]; - pixels[i] = (unsigned char) (total / kernel_width); - } - break; - } - - for (; i < w; ++i) { - STBTT_assert(pixels[i] == 0); - total -= buffer[i & STBTT__OVER_MASK]; - pixels[i] = (unsigned char) (total / kernel_width); - } - - pixels += stride_in_bytes; - } -} - -static void stbtt__v_prefilter(unsigned char *pixels, int w, int h, int stride_in_bytes, unsigned int kernel_width) -{ - unsigned char buffer[STBTT_MAX_OVERSAMPLE]; - int safe_h = h - kernel_width; - int j; - STBTT_memset(buffer, 0, STBTT_MAX_OVERSAMPLE); // suppress bogus warning from VS2013 -analyze - for (j=0; j < w; ++j) { - int i; - unsigned int total; - STBTT_memset(buffer, 0, kernel_width); - - total = 0; - - // make kernel_width a constant in common cases so compiler can optimize out the divide - switch (kernel_width) { - case 2: - for (i=0; i <= safe_h; ++i) { - total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; - buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; - pixels[i*stride_in_bytes] = (unsigned char) (total / 2); - } - break; - case 3: - for (i=0; i <= safe_h; ++i) { - total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; - buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; - pixels[i*stride_in_bytes] = (unsigned char) (total / 3); - } - break; - case 4: - for (i=0; i <= safe_h; ++i) { - total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; - buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; - pixels[i*stride_in_bytes] = (unsigned char) (total / 4); - } - break; - case 5: - for (i=0; i <= safe_h; ++i) { - total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; - buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; - pixels[i*stride_in_bytes] = (unsigned char) (total / 5); - } - break; - default: - for (i=0; i <= safe_h; ++i) { - total += pixels[i*stride_in_bytes] - buffer[i & STBTT__OVER_MASK]; - buffer[(i+kernel_width) & STBTT__OVER_MASK] = pixels[i*stride_in_bytes]; - pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width); - } - break; - } - - for (; i < h; ++i) { - STBTT_assert(pixels[i*stride_in_bytes] == 0); - total -= buffer[i & STBTT__OVER_MASK]; - pixels[i*stride_in_bytes] = (unsigned char) (total / kernel_width); - } - - pixels += 1; - } -} - -static float stbtt__oversample_shift(int oversample) -{ - if (!oversample) - return 0.0f; - - // The prefilter is a box filter of width "oversample", - // which shifts phase by (oversample - 1)/2 pixels in - // oversampled space. We want to shift in the opposite - // direction to counter this. - return (float)-(oversample - 1) / (2.0f * (float)oversample); -} - -// rects array must be big enough to accommodate all characters in the given ranges -STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects) -{ - int i,j,k; - - k=0; - for (i=0; i < num_ranges; ++i) { - float fh = ranges[i].font_size; - float scale = fh > 0 ? stbtt_ScaleForPixelHeight(info, fh) : stbtt_ScaleForMappingEmToPixels(info, -fh); - ranges[i].h_oversample = (unsigned char) spc->h_oversample; - ranges[i].v_oversample = (unsigned char) spc->v_oversample; - for (j=0; j < ranges[i].num_chars; ++j) { - int x0,y0,x1,y1; - int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j]; - int glyph = stbtt_FindGlyphIndex(info, codepoint); - if (glyph == 0 && spc->skip_missing) { - rects[k].w = rects[k].h = 0; - } else { - stbtt_GetGlyphBitmapBoxSubpixel(info,glyph, - scale * spc->h_oversample, - scale * spc->v_oversample, - 0,0, - &x0,&y0,&x1,&y1); - rects[k].w = (stbrp_coord) (x1-x0 + spc->padding + spc->h_oversample-1); - rects[k].h = (stbrp_coord) (y1-y0 + spc->padding + spc->v_oversample-1); - } - ++k; - } - } - - return k; -} - -STBTT_DEF void stbtt_MakeGlyphBitmapSubpixelPrefilter(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int prefilter_x, int prefilter_y, float *sub_x, float *sub_y, int glyph) -{ - stbtt_MakeGlyphBitmapSubpixel(info, - output, - out_w - (prefilter_x - 1), - out_h - (prefilter_y - 1), - out_stride, - scale_x, - scale_y, - shift_x, - shift_y, - glyph); - - if (prefilter_x > 1) - stbtt__h_prefilter(output, out_w, out_h, out_stride, prefilter_x); - - if (prefilter_y > 1) - stbtt__v_prefilter(output, out_w, out_h, out_stride, prefilter_y); - - *sub_x = stbtt__oversample_shift(prefilter_x); - *sub_y = stbtt__oversample_shift(prefilter_y); -} - -// rects array must be big enough to accommodate all characters in the given ranges -STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects) -{ - int i,j,k, return_value = 1; - - // save current values - int old_h_over = spc->h_oversample; - int old_v_over = spc->v_oversample; - - k = 0; - for (i=0; i < num_ranges; ++i) { - float fh = ranges[i].font_size; - float scale = fh > 0 ? stbtt_ScaleForPixelHeight(info, fh) : stbtt_ScaleForMappingEmToPixels(info, -fh); - float recip_h,recip_v,sub_x,sub_y; - spc->h_oversample = ranges[i].h_oversample; - spc->v_oversample = ranges[i].v_oversample; - recip_h = 1.0f / spc->h_oversample; - recip_v = 1.0f / spc->v_oversample; - sub_x = stbtt__oversample_shift(spc->h_oversample); - sub_y = stbtt__oversample_shift(spc->v_oversample); - for (j=0; j < ranges[i].num_chars; ++j) { - stbrp_rect *r = &rects[k]; - if (r->was_packed && r->w != 0 && r->h != 0) { - stbtt_packedchar *bc = &ranges[i].chardata_for_range[j]; - int advance, lsb, x0,y0,x1,y1; - int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j]; - int glyph = stbtt_FindGlyphIndex(info, codepoint); - stbrp_coord pad = (stbrp_coord) spc->padding; - - // pad on left and top - r->x += pad; - r->y += pad; - r->w -= pad; - r->h -= pad; - stbtt_GetGlyphHMetrics(info, glyph, &advance, &lsb); - stbtt_GetGlyphBitmapBox(info, glyph, - scale * spc->h_oversample, - scale * spc->v_oversample, - &x0,&y0,&x1,&y1); - stbtt_MakeGlyphBitmapSubpixel(info, - spc->pixels + r->x + r->y*spc->stride_in_bytes, - r->w - spc->h_oversample+1, - r->h - spc->v_oversample+1, - spc->stride_in_bytes, - scale * spc->h_oversample, - scale * spc->v_oversample, - 0,0, - glyph); - - if (spc->h_oversample > 1) - stbtt__h_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes, - r->w, r->h, spc->stride_in_bytes, - spc->h_oversample); - - if (spc->v_oversample > 1) - stbtt__v_prefilter(spc->pixels + r->x + r->y*spc->stride_in_bytes, - r->w, r->h, spc->stride_in_bytes, - spc->v_oversample); - - bc->x0 = (stbtt_int16) r->x; - bc->y0 = (stbtt_int16) r->y; - bc->x1 = (stbtt_int16) (r->x + r->w); - bc->y1 = (stbtt_int16) (r->y + r->h); - bc->xadvance = scale * advance; - bc->xoff = (float) x0 * recip_h + sub_x; - bc->yoff = (float) y0 * recip_v + sub_y; - bc->xoff2 = (x0 + r->w) * recip_h + sub_x; - bc->yoff2 = (y0 + r->h) * recip_v + sub_y; - } else { - return_value = 0; // if any fail, report failure - } - - ++k; - } - } - - // restore original values - spc->h_oversample = old_h_over; - spc->v_oversample = old_v_over; - - return return_value; -} - -STBTT_DEF void stbtt_PackFontRangesPackRects(stbtt_pack_context *spc, stbrp_rect *rects, int num_rects) -{ - stbrp_pack_rects((stbrp_context *) spc->pack_info, rects, num_rects); -} - -STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges) -{ - stbtt_fontinfo info; - int i,j,n, return_value; // [DEAR IMGUI] removed = 1 - //stbrp_context *context = (stbrp_context *) spc->pack_info; - stbrp_rect *rects; - - // flag all characters as NOT packed - for (i=0; i < num_ranges; ++i) - for (j=0; j < ranges[i].num_chars; ++j) - ranges[i].chardata_for_range[j].x0 = - ranges[i].chardata_for_range[j].y0 = - ranges[i].chardata_for_range[j].x1 = - ranges[i].chardata_for_range[j].y1 = 0; - - n = 0; - for (i=0; i < num_ranges; ++i) - n += ranges[i].num_chars; - - rects = (stbrp_rect *) STBTT_malloc(sizeof(*rects) * n, spc->user_allocator_context); - if (rects == NULL) - return 0; - - info.userdata = spc->user_allocator_context; - stbtt_InitFont(&info, fontdata, stbtt_GetFontOffsetForIndex(fontdata,font_index)); - - n = stbtt_PackFontRangesGatherRects(spc, &info, ranges, num_ranges, rects); - - stbtt_PackFontRangesPackRects(spc, rects, n); - - return_value = stbtt_PackFontRangesRenderIntoRects(spc, &info, ranges, num_ranges, rects); - - STBTT_free(rects, spc->user_allocator_context); - return return_value; -} - -STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, const unsigned char *fontdata, int font_index, float font_size, - int first_unicode_codepoint_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range) -{ - stbtt_pack_range range; - range.first_unicode_codepoint_in_range = first_unicode_codepoint_in_range; - range.array_of_unicode_codepoints = NULL; - range.num_chars = num_chars_in_range; - range.chardata_for_range = chardata_for_range; - range.font_size = font_size; - return stbtt_PackFontRanges(spc, fontdata, font_index, &range, 1); -} - -STBTT_DEF void stbtt_GetScaledFontVMetrics(const unsigned char *fontdata, int index, float size, float *ascent, float *descent, float *lineGap) -{ - int i_ascent, i_descent, i_lineGap; - float scale; - stbtt_fontinfo info; - stbtt_InitFont(&info, fontdata, stbtt_GetFontOffsetForIndex(fontdata, index)); - scale = size > 0 ? stbtt_ScaleForPixelHeight(&info, size) : stbtt_ScaleForMappingEmToPixels(&info, -size); - stbtt_GetFontVMetrics(&info, &i_ascent, &i_descent, &i_lineGap); - *ascent = (float) i_ascent * scale; - *descent = (float) i_descent * scale; - *lineGap = (float) i_lineGap * scale; -} - -STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int align_to_integer) -{ - float ipw = 1.0f / pw, iph = 1.0f / ph; - const stbtt_packedchar *b = chardata + char_index; - - if (align_to_integer) { - float x = (float) STBTT_ifloor((*xpos + b->xoff) + 0.5f); - float y = (float) STBTT_ifloor((*ypos + b->yoff) + 0.5f); - q->x0 = x; - q->y0 = y; - q->x1 = x + b->xoff2 - b->xoff; - q->y1 = y + b->yoff2 - b->yoff; - } else { - q->x0 = *xpos + b->xoff; - q->y0 = *ypos + b->yoff; - q->x1 = *xpos + b->xoff2; - q->y1 = *ypos + b->yoff2; - } - - q->s0 = b->x0 * ipw; - q->t0 = b->y0 * iph; - q->s1 = b->x1 * ipw; - q->t1 = b->y1 * iph; - - *xpos += b->xadvance; -} - -////////////////////////////////////////////////////////////////////////////// -// -// sdf computation -// - -#define STBTT_min(a,b) ((a) < (b) ? (a) : (b)) -#define STBTT_max(a,b) ((a) < (b) ? (b) : (a)) - -static int stbtt__ray_intersect_bezier(float orig[2], float ray[2], float q0[2], float q1[2], float q2[2], float hits[2][2]) -{ - float q0perp = q0[1]*ray[0] - q0[0]*ray[1]; - float q1perp = q1[1]*ray[0] - q1[0]*ray[1]; - float q2perp = q2[1]*ray[0] - q2[0]*ray[1]; - float roperp = orig[1]*ray[0] - orig[0]*ray[1]; - - float a = q0perp - 2*q1perp + q2perp; - float b = q1perp - q0perp; - float c = q0perp - roperp; - - float s0 = 0., s1 = 0.; - int num_s = 0; - - if (a != 0.0) { - float discr = b*b - a*c; - if (discr > 0.0) { - float rcpna = -1 / a; - float d = (float) STBTT_sqrt(discr); - s0 = (b+d) * rcpna; - s1 = (b-d) * rcpna; - if (s0 >= 0.0 && s0 <= 1.0) - num_s = 1; - if (d > 0.0 && s1 >= 0.0 && s1 <= 1.0) { - if (num_s == 0) s0 = s1; - ++num_s; - } - } - } else { - // 2*b*s + c = 0 - // s = -c / (2*b) - s0 = c / (-2 * b); - if (s0 >= 0.0 && s0 <= 1.0) - num_s = 1; - } - - if (num_s == 0) - return 0; - else { - float rcp_len2 = 1 / (ray[0]*ray[0] + ray[1]*ray[1]); - float rayn_x = ray[0] * rcp_len2, rayn_y = ray[1] * rcp_len2; - - float q0d = q0[0]*rayn_x + q0[1]*rayn_y; - float q1d = q1[0]*rayn_x + q1[1]*rayn_y; - float q2d = q2[0]*rayn_x + q2[1]*rayn_y; - float rod = orig[0]*rayn_x + orig[1]*rayn_y; - - float q10d = q1d - q0d; - float q20d = q2d - q0d; - float q0rd = q0d - rod; - - hits[0][0] = q0rd + s0*(2.0f - 2.0f*s0)*q10d + s0*s0*q20d; - hits[0][1] = a*s0+b; - - if (num_s > 1) { - hits[1][0] = q0rd + s1*(2.0f - 2.0f*s1)*q10d + s1*s1*q20d; - hits[1][1] = a*s1+b; - return 2; - } else { - return 1; - } - } -} - -static int equal(float *a, float *b) -{ - return (a[0] == b[0] && a[1] == b[1]); -} - -static int stbtt__compute_crossings_x(float x, float y, int nverts, stbtt_vertex *verts) -{ - int i; - float orig[2], ray[2] = { 1, 0 }; - float y_frac; - int winding = 0; - - orig[0] = x; - //orig[1] = y; // [DEAR IMGUI] commented double assignment - - // make sure y never passes through a vertex of the shape - y_frac = (float) STBTT_fmod(y, 1.0f); - if (y_frac < 0.01f) - y += 0.01f; - else if (y_frac > 0.99f) - y -= 0.01f; - orig[1] = y; - - // test a ray from (-infinity,y) to (x,y) - for (i=0; i < nverts; ++i) { - if (verts[i].type == STBTT_vline) { - int x0 = (int) verts[i-1].x, y0 = (int) verts[i-1].y; - int x1 = (int) verts[i ].x, y1 = (int) verts[i ].y; - if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) { - float x_inter = (y - y0) / (y1 - y0) * (x1-x0) + x0; - if (x_inter < x) - winding += (y0 < y1) ? 1 : -1; - } - } - if (verts[i].type == STBTT_vcurve) { - int x0 = (int) verts[i-1].x , y0 = (int) verts[i-1].y ; - int x1 = (int) verts[i ].cx, y1 = (int) verts[i ].cy; - int x2 = (int) verts[i ].x , y2 = (int) verts[i ].y ; - int ax = STBTT_min(x0,STBTT_min(x1,x2)), ay = STBTT_min(y0,STBTT_min(y1,y2)); - int by = STBTT_max(y0,STBTT_max(y1,y2)); - if (y > ay && y < by && x > ax) { - float q0[2],q1[2],q2[2]; - float hits[2][2]; - q0[0] = (float)x0; - q0[1] = (float)y0; - q1[0] = (float)x1; - q1[1] = (float)y1; - q2[0] = (float)x2; - q2[1] = (float)y2; - if (equal(q0,q1) || equal(q1,q2)) { - x0 = (int)verts[i-1].x; - y0 = (int)verts[i-1].y; - x1 = (int)verts[i ].x; - y1 = (int)verts[i ].y; - if (y > STBTT_min(y0,y1) && y < STBTT_max(y0,y1) && x > STBTT_min(x0,x1)) { - float x_inter = (y - y0) / (y1 - y0) * (x1-x0) + x0; - if (x_inter < x) - winding += (y0 < y1) ? 1 : -1; - } - } else { - int num_hits = stbtt__ray_intersect_bezier(orig, ray, q0, q1, q2, hits); - if (num_hits >= 1) - if (hits[0][0] < 0) - winding += (hits[0][1] < 0 ? -1 : 1); - if (num_hits >= 2) - if (hits[1][0] < 0) - winding += (hits[1][1] < 0 ? -1 : 1); - } - } - } - } - return winding; -} - -static float stbtt__cuberoot( float x ) -{ - if (x<0) - return -(float) STBTT_pow(-x,1.0f/3.0f); - else - return (float) STBTT_pow( x,1.0f/3.0f); -} - -// x^3 + c*x^2 + b*x + a = 0 -static int stbtt__solve_cubic(float a, float b, float c, float* r) -{ - float s = -a / 3; - float p = b - a*a / 3; - float q = a * (2*a*a - 9*b) / 27 + c; - float p3 = p*p*p; - float d = q*q + 4*p3 / 27; - if (d >= 0) { - float z = (float) STBTT_sqrt(d); - float u = (-q + z) / 2; - float v = (-q - z) / 2; - u = stbtt__cuberoot(u); - v = stbtt__cuberoot(v); - r[0] = s + u + v; - return 1; - } else { - float u = (float) STBTT_sqrt(-p/3); - float v = (float) STBTT_acos(-STBTT_sqrt(-27/p3) * q / 2) / 3; // p3 must be negative, since d is negative - float m = (float) STBTT_cos(v); - float n = (float) STBTT_cos(v-3.141592/2)*1.732050808f; - r[0] = s + u * 2 * m; - r[1] = s - u * (m + n); - r[2] = s - u * (m - n); - - //STBTT_assert( STBTT_fabs(((r[0]+a)*r[0]+b)*r[0]+c) < 0.05f); // these asserts may not be safe at all scales, though they're in bezier t parameter units so maybe? - //STBTT_assert( STBTT_fabs(((r[1]+a)*r[1]+b)*r[1]+c) < 0.05f); - //STBTT_assert( STBTT_fabs(((r[2]+a)*r[2]+b)*r[2]+c) < 0.05f); - return 3; - } -} - -STBTT_DEF unsigned char * stbtt_GetGlyphSDF(const stbtt_fontinfo *info, float scale, int glyph, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff) -{ - float scale_x = scale, scale_y = scale; - int ix0,iy0,ix1,iy1; - int w,h; - unsigned char *data; - - // if one scale is 0, use same scale for both - if (scale_x == 0) scale_x = scale_y; - if (scale_y == 0) { - if (scale_x == 0) return NULL; // if both scales are 0, return NULL - scale_y = scale_x; - } - - stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale, scale, 0.0f,0.0f, &ix0,&iy0,&ix1,&iy1); - - // if empty, return NULL - if (ix0 == ix1 || iy0 == iy1) - return NULL; - - ix0 -= padding; - iy0 -= padding; - ix1 += padding; - iy1 += padding; - - w = (ix1 - ix0); - h = (iy1 - iy0); - - if (width ) *width = w; - if (height) *height = h; - if (xoff ) *xoff = ix0; - if (yoff ) *yoff = iy0; - - // invert for y-downwards bitmaps - scale_y = -scale_y; - - { - int x,y,i,j; - float *precompute; - stbtt_vertex *verts; - int num_verts = stbtt_GetGlyphShape(info, glyph, &verts); - data = (unsigned char *) STBTT_malloc(w * h, info->userdata); - precompute = (float *) STBTT_malloc(num_verts * sizeof(float), info->userdata); - - for (i=0,j=num_verts-1; i < num_verts; j=i++) { - if (verts[i].type == STBTT_vline) { - float x0 = verts[i].x*scale_x, y0 = verts[i].y*scale_y; - float x1 = verts[j].x*scale_x, y1 = verts[j].y*scale_y; - float dist = (float) STBTT_sqrt((x1-x0)*(x1-x0) + (y1-y0)*(y1-y0)); - precompute[i] = (dist == 0) ? 0.0f : 1.0f / dist; - } else if (verts[i].type == STBTT_vcurve) { - float x2 = verts[j].x *scale_x, y2 = verts[j].y *scale_y; - float x1 = verts[i].cx*scale_x, y1 = verts[i].cy*scale_y; - float x0 = verts[i].x *scale_x, y0 = verts[i].y *scale_y; - float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2; - float len2 = bx*bx + by*by; - if (len2 != 0.0f) - precompute[i] = 1.0f / (bx*bx + by*by); - else - precompute[i] = 0.0f; - } else - precompute[i] = 0.0f; - } - - for (y=iy0; y < iy1; ++y) { - for (x=ix0; x < ix1; ++x) { - float val; - float min_dist = 999999.0f; - float sx = (float) x + 0.5f; - float sy = (float) y + 0.5f; - float x_gspace = (sx / scale_x); - float y_gspace = (sy / scale_y); - - int winding = stbtt__compute_crossings_x(x_gspace, y_gspace, num_verts, verts); // @OPTIMIZE: this could just be a rasterization, but needs to be line vs. non-tesselated curves so a new path - - for (i=0; i < num_verts; ++i) { - float x0 = verts[i].x*scale_x, y0 = verts[i].y*scale_y; - - // check against every point here rather than inside line/curve primitives -- @TODO: wrong if multiple 'moves' in a row produce a garbage point, and given culling, probably more efficient to do within line/curve - float dist2 = (x0-sx)*(x0-sx) + (y0-sy)*(y0-sy); - if (dist2 < min_dist*min_dist) - min_dist = (float) STBTT_sqrt(dist2); - - if (verts[i].type == STBTT_vline) { - float x1 = verts[i-1].x*scale_x, y1 = verts[i-1].y*scale_y; - - // coarse culling against bbox - //if (sx > STBTT_min(x0,x1)-min_dist && sx < STBTT_max(x0,x1)+min_dist && - // sy > STBTT_min(y0,y1)-min_dist && sy < STBTT_max(y0,y1)+min_dist) - float dist = (float) STBTT_fabs((x1-x0)*(y0-sy) - (y1-y0)*(x0-sx)) * precompute[i]; - STBTT_assert(i != 0); - if (dist < min_dist) { - // check position along line - // x' = x0 + t*(x1-x0), y' = y0 + t*(y1-y0) - // minimize (x'-sx)*(x'-sx)+(y'-sy)*(y'-sy) - float dx = x1-x0, dy = y1-y0; - float px = x0-sx, py = y0-sy; - // minimize (px+t*dx)^2 + (py+t*dy)^2 = px*px + 2*px*dx*t + t^2*dx*dx + py*py + 2*py*dy*t + t^2*dy*dy - // derivative: 2*px*dx + 2*py*dy + (2*dx*dx+2*dy*dy)*t, set to 0 and solve - float t = -(px*dx + py*dy) / (dx*dx + dy*dy); - if (t >= 0.0f && t <= 1.0f) - min_dist = dist; - } - } else if (verts[i].type == STBTT_vcurve) { - float x2 = verts[i-1].x *scale_x, y2 = verts[i-1].y *scale_y; - float x1 = verts[i ].cx*scale_x, y1 = verts[i ].cy*scale_y; - float box_x0 = STBTT_min(STBTT_min(x0,x1),x2); - float box_y0 = STBTT_min(STBTT_min(y0,y1),y2); - float box_x1 = STBTT_max(STBTT_max(x0,x1),x2); - float box_y1 = STBTT_max(STBTT_max(y0,y1),y2); - // coarse culling against bbox to avoid computing cubic unnecessarily - if (sx > box_x0-min_dist && sx < box_x1+min_dist && sy > box_y0-min_dist && sy < box_y1+min_dist) { - int num=0; - float ax = x1-x0, ay = y1-y0; - float bx = x0 - 2*x1 + x2, by = y0 - 2*y1 + y2; - float mx = x0 - sx, my = y0 - sy; - float res[3],px,py,t,it; - float a_inv = precompute[i]; - if (a_inv == 0.0) { // if a_inv is 0, it's 2nd degree so use quadratic formula - float a = 3*(ax*bx + ay*by); - float b = 2*(ax*ax + ay*ay) + (mx*bx+my*by); - float c = mx*ax+my*ay; - if (a == 0.0) { // if a is 0, it's linear - if (b != 0.0) { - res[num++] = -c/b; - } - } else { - float discriminant = b*b - 4*a*c; - if (discriminant < 0) - num = 0; - else { - float root = (float) STBTT_sqrt(discriminant); - res[0] = (-b - root)/(2*a); - res[1] = (-b + root)/(2*a); - num = 2; // don't bother distinguishing 1-solution case, as code below will still work - } - } - } else { - float b = 3*(ax*bx + ay*by) * a_inv; // could precompute this as it doesn't depend on sample point - float c = (2*(ax*ax + ay*ay) + (mx*bx+my*by)) * a_inv; - float d = (mx*ax+my*ay) * a_inv; - num = stbtt__solve_cubic(b, c, d, res); - } - if (num >= 1 && res[0] >= 0.0f && res[0] <= 1.0f) { - t = res[0], it = 1.0f - t; - px = it*it*x0 + 2*t*it*x1 + t*t*x2; - py = it*it*y0 + 2*t*it*y1 + t*t*y2; - dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy); - if (dist2 < min_dist * min_dist) - min_dist = (float) STBTT_sqrt(dist2); - } - if (num >= 2 && res[1] >= 0.0f && res[1] <= 1.0f) { - t = res[1], it = 1.0f - t; - px = it*it*x0 + 2*t*it*x1 + t*t*x2; - py = it*it*y0 + 2*t*it*y1 + t*t*y2; - dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy); - if (dist2 < min_dist * min_dist) - min_dist = (float) STBTT_sqrt(dist2); - } - if (num >= 3 && res[2] >= 0.0f && res[2] <= 1.0f) { - t = res[2], it = 1.0f - t; - px = it*it*x0 + 2*t*it*x1 + t*t*x2; - py = it*it*y0 + 2*t*it*y1 + t*t*y2; - dist2 = (px-sx)*(px-sx) + (py-sy)*(py-sy); - if (dist2 < min_dist * min_dist) - min_dist = (float) STBTT_sqrt(dist2); - } - } - } - } - if (winding == 0) - min_dist = -min_dist; // if outside the shape, value is negative - val = onedge_value + pixel_dist_scale * min_dist; - if (val < 0) - val = 0; - else if (val > 255) - val = 255; - data[(y-iy0)*w+(x-ix0)] = (unsigned char) val; - } - } - STBTT_free(precompute, info->userdata); - STBTT_free(verts, info->userdata); - } - return data; -} - -STBTT_DEF unsigned char * stbtt_GetCodepointSDF(const stbtt_fontinfo *info, float scale, int codepoint, int padding, unsigned char onedge_value, float pixel_dist_scale, int *width, int *height, int *xoff, int *yoff) -{ - return stbtt_GetGlyphSDF(info, scale, stbtt_FindGlyphIndex(info, codepoint), padding, onedge_value, pixel_dist_scale, width, height, xoff, yoff); -} - -STBTT_DEF void stbtt_FreeSDF(unsigned char *bitmap, void *userdata) -{ - STBTT_free(bitmap, userdata); -} - -////////////////////////////////////////////////////////////////////////////// -// -// font name matching -- recommended not to use this -// - -// check if a utf8 string contains a prefix which is the utf16 string; if so return length of matching utf8 string -static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(stbtt_uint8 *s1, stbtt_int32 len1, stbtt_uint8 *s2, stbtt_int32 len2) -{ - stbtt_int32 i=0; - - // convert utf16 to utf8 and compare the results while converting - while (len2) { - stbtt_uint16 ch = s2[0]*256 + s2[1]; - if (ch < 0x80) { - if (i >= len1) return -1; - if (s1[i++] != ch) return -1; - } else if (ch < 0x800) { - if (i+1 >= len1) return -1; - if (s1[i++] != 0xc0 + (ch >> 6)) return -1; - if (s1[i++] != 0x80 + (ch & 0x3f)) return -1; - } else if (ch >= 0xd800 && ch < 0xdc00) { - stbtt_uint32 c; - stbtt_uint16 ch2 = s2[2]*256 + s2[3]; - if (i+3 >= len1) return -1; - c = ((ch - 0xd800) << 10) + (ch2 - 0xdc00) + 0x10000; - if (s1[i++] != 0xf0 + (c >> 18)) return -1; - if (s1[i++] != 0x80 + ((c >> 12) & 0x3f)) return -1; - if (s1[i++] != 0x80 + ((c >> 6) & 0x3f)) return -1; - if (s1[i++] != 0x80 + ((c ) & 0x3f)) return -1; - s2 += 2; // plus another 2 below - len2 -= 2; - } else if (ch >= 0xdc00 && ch < 0xe000) { - return -1; - } else { - if (i+2 >= len1) return -1; - if (s1[i++] != 0xe0 + (ch >> 12)) return -1; - if (s1[i++] != 0x80 + ((ch >> 6) & 0x3f)) return -1; - if (s1[i++] != 0x80 + ((ch ) & 0x3f)) return -1; - } - s2 += 2; - len2 -= 2; - } - return i; -} - -static int stbtt_CompareUTF8toUTF16_bigendian_internal(char *s1, int len1, char *s2, int len2) -{ - return len1 == stbtt__CompareUTF8toUTF16_bigendian_prefix((stbtt_uint8*) s1, len1, (stbtt_uint8*) s2, len2); -} - -// returns results in whatever encoding you request... but note that 2-byte encodings -// will be BIG-ENDIAN... use stbtt_CompareUTF8toUTF16_bigendian() to compare -STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID) -{ - stbtt_int32 i,count,stringOffset; - stbtt_uint8 *fc = font->data; - stbtt_uint32 offset = font->fontstart; - stbtt_uint32 nm = stbtt__find_table(fc, offset, "name"); - if (!nm) return NULL; - - count = ttUSHORT(fc+nm+2); - stringOffset = nm + ttUSHORT(fc+nm+4); - for (i=0; i < count; ++i) { - stbtt_uint32 loc = nm + 6 + 12 * i; - if (platformID == ttUSHORT(fc+loc+0) && encodingID == ttUSHORT(fc+loc+2) - && languageID == ttUSHORT(fc+loc+4) && nameID == ttUSHORT(fc+loc+6)) { - *length = ttUSHORT(fc+loc+8); - return (const char *) (fc+stringOffset+ttUSHORT(fc+loc+10)); - } - } - return NULL; -} - -static int stbtt__matchpair(stbtt_uint8 *fc, stbtt_uint32 nm, stbtt_uint8 *name, stbtt_int32 nlen, stbtt_int32 target_id, stbtt_int32 next_id) -{ - stbtt_int32 i; - stbtt_int32 count = ttUSHORT(fc+nm+2); - stbtt_int32 stringOffset = nm + ttUSHORT(fc+nm+4); - - for (i=0; i < count; ++i) { - stbtt_uint32 loc = nm + 6 + 12 * i; - stbtt_int32 id = ttUSHORT(fc+loc+6); - if (id == target_id) { - // find the encoding - stbtt_int32 platform = ttUSHORT(fc+loc+0), encoding = ttUSHORT(fc+loc+2), language = ttUSHORT(fc+loc+4); - - // is this a Unicode encoding? - if (platform == 0 || (platform == 3 && encoding == 1) || (platform == 3 && encoding == 10)) { - stbtt_int32 slen = ttUSHORT(fc+loc+8); - stbtt_int32 off = ttUSHORT(fc+loc+10); - - // check if there's a prefix match - stbtt_int32 matchlen = stbtt__CompareUTF8toUTF16_bigendian_prefix(name, nlen, fc+stringOffset+off,slen); - if (matchlen >= 0) { - // check for target_id+1 immediately following, with same encoding & language - if (i+1 < count && ttUSHORT(fc+loc+12+6) == next_id && ttUSHORT(fc+loc+12) == platform && ttUSHORT(fc+loc+12+2) == encoding && ttUSHORT(fc+loc+12+4) == language) { - slen = ttUSHORT(fc+loc+12+8); - off = ttUSHORT(fc+loc+12+10); - if (slen == 0) { - if (matchlen == nlen) - return 1; - } else if (matchlen < nlen && name[matchlen] == ' ') { - ++matchlen; - if (stbtt_CompareUTF8toUTF16_bigendian_internal((char*) (name+matchlen), nlen-matchlen, (char*)(fc+stringOffset+off),slen)) - return 1; - } - } else { - // if nothing immediately following - if (matchlen == nlen) - return 1; - } - } - } - - // @TODO handle other encodings - } - } - return 0; -} - -static int stbtt__matches(stbtt_uint8 *fc, stbtt_uint32 offset, stbtt_uint8 *name, stbtt_int32 flags) -{ - stbtt_int32 nlen = (stbtt_int32) STBTT_strlen((char *) name); - stbtt_uint32 nm,hd; - if (!stbtt__isfont(fc+offset)) return 0; - - // check italics/bold/underline flags in macStyle... - if (flags) { - hd = stbtt__find_table(fc, offset, "head"); - if ((ttUSHORT(fc+hd+44) & 7) != (flags & 7)) return 0; - } - - nm = stbtt__find_table(fc, offset, "name"); - if (!nm) return 0; - - if (flags) { - // if we checked the macStyle flags, then just check the family and ignore the subfamily - if (stbtt__matchpair(fc, nm, name, nlen, 16, -1)) return 1; - if (stbtt__matchpair(fc, nm, name, nlen, 1, -1)) return 1; - if (stbtt__matchpair(fc, nm, name, nlen, 3, -1)) return 1; - } else { - if (stbtt__matchpair(fc, nm, name, nlen, 16, 17)) return 1; - if (stbtt__matchpair(fc, nm, name, nlen, 1, 2)) return 1; - if (stbtt__matchpair(fc, nm, name, nlen, 3, -1)) return 1; - } - - return 0; -} - -static int stbtt_FindMatchingFont_internal(unsigned char *font_collection, char *name_utf8, stbtt_int32 flags) -{ - stbtt_int32 i; - for (i=0;;++i) { - stbtt_int32 off = stbtt_GetFontOffsetForIndex(font_collection, i); - if (off < 0) return off; - if (stbtt__matches((stbtt_uint8 *) font_collection, off, (stbtt_uint8*) name_utf8, flags)) - return off; - } -} - -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wcast-qual" -#endif - -STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset, - float pixel_height, unsigned char *pixels, int pw, int ph, - int first_char, int num_chars, stbtt_bakedchar *chardata) -{ - return stbtt_BakeFontBitmap_internal((unsigned char *) data, offset, pixel_height, pixels, pw, ph, first_char, num_chars, chardata); -} - -STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index) -{ - return stbtt_GetFontOffsetForIndex_internal((unsigned char *) data, index); -} - -STBTT_DEF int stbtt_GetNumberOfFonts(const unsigned char *data) -{ - return stbtt_GetNumberOfFonts_internal((unsigned char *) data); -} - -STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset) -{ - return stbtt_InitFont_internal(info, (unsigned char *) data, offset); -} - -STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags) -{ - return stbtt_FindMatchingFont_internal((unsigned char *) fontdata, (char *) name, flags); -} - -STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2) -{ - return stbtt_CompareUTF8toUTF16_bigendian_internal((char *) s1, len1, (char *) s2, len2); -} - -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - -#endif // STB_TRUETYPE_IMPLEMENTATION - - -// FULL VERSION HISTORY -// -// 1.19 (2018-02-11) OpenType GPOS kerning (horizontal only), STBTT_fmod -// 1.18 (2018-01-29) add missing function -// 1.17 (2017-07-23) make more arguments const; doc fix -// 1.16 (2017-07-12) SDF support -// 1.15 (2017-03-03) make more arguments const -// 1.14 (2017-01-16) num-fonts-in-TTC function -// 1.13 (2017-01-02) support OpenType fonts, certain Apple fonts -// 1.12 (2016-10-25) suppress warnings about casting away const with -Wcast-qual -// 1.11 (2016-04-02) fix unused-variable warning -// 1.10 (2016-04-02) allow user-defined fabs() replacement -// fix memory leak if fontsize=0.0 -// fix warning from duplicate typedef -// 1.09 (2016-01-16) warning fix; avoid crash on outofmem; use alloc userdata for PackFontRanges -// 1.08 (2015-09-13) document stbtt_Rasterize(); fixes for vertical & horizontal edges -// 1.07 (2015-08-01) allow PackFontRanges to accept arrays of sparse codepoints; -// allow PackFontRanges to pack and render in separate phases; -// fix stbtt_GetFontOFfsetForIndex (never worked for non-0 input?); -// fixed an assert() bug in the new rasterizer -// replace assert() with STBTT_assert() in new rasterizer -// 1.06 (2015-07-14) performance improvements (~35% faster on x86 and x64 on test machine) -// also more precise AA rasterizer, except if shapes overlap -// remove need for STBTT_sort -// 1.05 (2015-04-15) fix misplaced definitions for STBTT_STATIC -// 1.04 (2015-04-15) typo in example -// 1.03 (2015-04-12) STBTT_STATIC, fix memory leak in new packing, various fixes -// 1.02 (2014-12-10) fix various warnings & compile issues w/ stb_rect_pack, C++ -// 1.01 (2014-12-08) fix subpixel position when oversampling to exactly match -// non-oversampled; STBTT_POINT_SIZE for packed case only -// 1.00 (2014-12-06) add new PackBegin etc. API, w/ support for oversampling -// 0.99 (2014-09-18) fix multiple bugs with subpixel rendering (ryg) -// 0.9 (2014-08-07) support certain mac/iOS fonts without an MS platformID -// 0.8b (2014-07-07) fix a warning -// 0.8 (2014-05-25) fix a few more warnings -// 0.7 (2013-09-25) bugfix: subpixel glyph bug fixed in 0.5 had come back -// 0.6c (2012-07-24) improve documentation -// 0.6b (2012-07-20) fix a few more warnings -// 0.6 (2012-07-17) fix warnings; added stbtt_ScaleForMappingEmToPixels, -// stbtt_GetFontBoundingBox, stbtt_IsGlyphEmpty -// 0.5 (2011-12-09) bugfixes: -// subpixel glyph renderer computed wrong bounding box -// first vertex of shape can be off-curve (FreeSans) -// 0.4b (2011-12-03) fixed an error in the font baking example -// 0.4 (2011-12-01) kerning, subpixel rendering (tor) -// bugfixes for: -// codepoint-to-glyph conversion using table fmt=12 -// codepoint-to-glyph conversion using table fmt=4 -// stbtt_GetBakedQuad with non-square texture (Zer) -// updated Hello World! sample to use kerning and subpixel -// fixed some warnings -// 0.3 (2009-06-24) cmap fmt=12, compound shapes (MM) -// userdata, malloc-from-userdata, non-zero fill (stb) -// 0.2 (2009-03-11) Fix unsigned/signed char warnings -// 0.1 (2009-03-09) First public release -// - -/* ------------------------------------------------------------------------------- -This software is available under 2 licenses -- choose whichever you prefer. ------------------------------------------------------------------------------- -ALTERNATIVE A - MIT License -Copyright (c) 2017 Sean Barrett -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. ------------------------------------------------------------------------------- -ALTERNATIVE B - Public Domain (www.unlicense.org) -This is free and unencumbered software released into the public domain. -Anyone is free to copy, modify, publish, use, compile, sell, or distribute this -software, either in source code form or as a compiled binary, for any purpose, -commercial or non-commercial, and by any means. -In jurisdictions that recognize copyright laws, the author or authors of this -software dedicate any and all copyright interest in the software to the public -domain. We make this dedication for the benefit of the public at large and to -the detriment of our heirs and successors. We intend this dedication to be an -overt act of relinquishment in perpetuity of all present and future rights to -this software under copyright law. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------- -*/ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/README.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/README.txt deleted file mode 100644 index b4ce89f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/README.txt +++ /dev/null @@ -1,23 +0,0 @@ - -misc/cpp/ - InputText() wrappers for C++ standard library (STL) type: std::string. - This is also an example of how you may wrap your own similar types. - -misc/debuggers/ - Helper files for popular debuggers. - With the .natvis file, types like ImVector<> will be displayed nicely in Visual Studio debugger. - -misc/fonts/ - Fonts loading/merging instructions (e.g. How to handle glyph ranges, how to merge icons fonts). - Command line tool "binary_to_compressed_c" to create compressed arrays to embed data in source code. - Suggested fonts and links. - -misc/freetype/ - Font atlas builder/rasterizer using FreeType instead of stb_truetype. - Benefit from better FreeType rasterization, in particular for small fonts. - -misc/single_file/ - Single-file header stub. - We use this to validate compiling all *.cpp files in a same compilation unit. - Users of that technique (also called "Unity builds") can generally provide this themselves, - so we don't really recommend you use this in your projects. diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/cpp/README.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/cpp/README.txt deleted file mode 100644 index 4291590..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/cpp/README.txt +++ /dev/null @@ -1,13 +0,0 @@ - -imgui_stdlib.h + imgui_stdlib.cpp - InputText() wrappers for C++ standard library (STL) type: std::string. - This is also an example of how you may wrap your own similar types. - -imgui_scoped.h - [Experimental, not currently in main repository] - Additional header file with some RAII-style wrappers for common Dear ImGui functions. - Try by merging: https://github.com/ocornut/imgui/pull/2197 - Discuss at: https://github.com/ocornut/imgui/issues/2096 - -See more C++ related extension on Wiki - https://github.com/ocornut/imgui/wiki/Useful-Extensions#cness diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/cpp/imgui_stdlib.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/cpp/imgui_stdlib.cpp deleted file mode 100644 index cb1fe17..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/cpp/imgui_stdlib.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// dear imgui: wrappers for C++ standard library (STL) types (std::string, etc.) -// This is also an example of how you may wrap your own similar types. - -// Compatibility: -// - std::string support is only guaranteed to work from C++11. -// If you try to use it pre-C++11, please share your findings (w/ info about compiler/architecture) - -// Changelog: -// - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string - -#include "imgui.h" -#include "imgui_stdlib.h" - -struct InputTextCallback_UserData -{ - std::string* Str; - ImGuiInputTextCallback ChainCallback; - void* ChainCallbackUserData; -}; - -static int InputTextCallback(ImGuiInputTextCallbackData* data) -{ - InputTextCallback_UserData* user_data = (InputTextCallback_UserData*)data->UserData; - if (data->EventFlag == ImGuiInputTextFlags_CallbackResize) - { - // Resize string callback - // If for some reason we refuse the new length (BufTextLen) and/or capacity (BufSize) we need to set them back to what we want. - std::string* str = user_data->Str; - IM_ASSERT(data->Buf == str->c_str()); - str->resize(data->BufTextLen); - data->Buf = (char*)str->c_str(); - } - else if (user_data->ChainCallback) - { - // Forward to user callback, if any - data->UserData = user_data->ChainCallbackUserData; - return user_data->ChainCallback(data); - } - return 0; -} - -bool ImGui::InputText(const char* label, std::string* str, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) -{ - IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0); - flags |= ImGuiInputTextFlags_CallbackResize; - - InputTextCallback_UserData cb_user_data; - cb_user_data.Str = str; - cb_user_data.ChainCallback = callback; - cb_user_data.ChainCallbackUserData = user_data; - return InputText(label, (char*)str->c_str(), str->capacity() + 1, flags, InputTextCallback, &cb_user_data); -} - -bool ImGui::InputTextMultiline(const char* label, std::string* str, const ImVec2& size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) -{ - IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0); - flags |= ImGuiInputTextFlags_CallbackResize; - - InputTextCallback_UserData cb_user_data; - cb_user_data.Str = str; - cb_user_data.ChainCallback = callback; - cb_user_data.ChainCallbackUserData = user_data; - return InputTextMultiline(label, (char*)str->c_str(), str->capacity() + 1, size, flags, InputTextCallback, &cb_user_data); -} - -bool ImGui::InputTextWithHint(const char* label, const char* hint, std::string* str, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) -{ - IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0); - flags |= ImGuiInputTextFlags_CallbackResize; - - InputTextCallback_UserData cb_user_data; - cb_user_data.Str = str; - cb_user_data.ChainCallback = callback; - cb_user_data.ChainCallbackUserData = user_data; - return InputTextWithHint(label, hint, (char*)str->c_str(), str->capacity() + 1, flags, InputTextCallback, &cb_user_data); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/cpp/imgui_stdlib.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/cpp/imgui_stdlib.h deleted file mode 100644 index f860b0c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/cpp/imgui_stdlib.h +++ /dev/null @@ -1,22 +0,0 @@ -// dear imgui: wrappers for C++ standard library (STL) types (std::string, etc.) -// This is also an example of how you may wrap your own similar types. - -// Compatibility: -// - std::string support is only guaranteed to work from C++11. -// If you try to use it pre-C++11, please share your findings (w/ info about compiler/architecture) - -// Changelog: -// - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string - -#pragma once - -#include - -namespace ImGui -{ - // ImGui::InputText() with std::string - // Because text input needs dynamic resizing, we need to setup a callback to grow the capacity - IMGUI_API bool InputText(const char* label, std::string* str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); - IMGUI_API bool InputTextMultiline(const char* label, std::string* str, const ImVec2& size = ImVec2(0, 0), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); - IMGUI_API bool InputTextWithHint(const char* label, const char* hint, std::string* str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/debuggers/README.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/debuggers/README.txt deleted file mode 100644 index 3f4ba83..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/debuggers/README.txt +++ /dev/null @@ -1,16 +0,0 @@ - -HELPER FILES FOR POPULAR DEBUGGERS - -imgui.gdb - GDB: disable stepping into trivial functions. - (read comments inside file for details) - -imgui.natstepfilter - Visual Studio Debugger: disable stepping into trivial functions. - (read comments inside file for details) - -imgui.natvis - Visual Studio Debugger: describe Dear ImGui types for better display. - With this, types like ImVector<> will be displayed nicely in the debugger. - (read comments inside file for details) - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/debuggers/imgui.gdb b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/debuggers/imgui.gdb deleted file mode 100644 index 000ff6e..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/debuggers/imgui.gdb +++ /dev/null @@ -1,12 +0,0 @@ -# GDB configuration to aid debugging experience - -# To enable these customizations edit $HOME/.gdbinit (or ./.gdbinit if local gdbinit is enabled) and add: -# add-auto-load-safe-path /path/to/imgui.gdb -# source /path/to/imgui.gdb -# -# More Information at: -# * https://sourceware.org/gdb/current/onlinedocs/gdb/gdbinit-man.html -# * https://sourceware.org/gdb/current/onlinedocs/gdb/Init-File-in-the-Current-Directory.html#Init-File-in-the-Current-Directory - -# Disable stepping into trivial functions -skip -rfunction Im(Vec2|Vec4|Strv|Vector|Span)::.+ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/debuggers/imgui.natstepfilter b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/debuggers/imgui.natstepfilter deleted file mode 100644 index efd1957..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/debuggers/imgui.natstepfilter +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - (ImVec2|ImVec4|ImStrv)::.+ - NoStepInto - - - (ImVector|ImSpan).*::operator.+ - NoStepInto - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/debuggers/imgui.natvis b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/debuggers/imgui.natvis deleted file mode 100644 index 13b6360..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/debuggers/imgui.natvis +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - {{Size={Size} Capacity={Capacity}}} - - - Size - Data - - - - - - {{Size={DataEnd-Data} }} - - - DataEnd-Data - Data - - - - - - {{x={x,g} y={y,g}}} - - - - {{x={x,g} y={y,g} z={z,g} w={w,g}}} - - - - {{Min=({Min.x,g} {Min.y,g}) Max=({Max.x,g} {Max.y,g}) Size=({Max.x-Min.x,g} {Max.y-Min.y,g})}} - - Min - Max - Max.x - Min.x - Max.y - Min.y - - - - - {{Name {Name,s} Active {(Active||WasActive)?1:0,d} Child {(Flags & 0x01000000)?1:0,d} Popup {(Flags & 0x04000000)?1:0,d} Hidden {(Hidden)?1:0,d}} - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/fonts/Cousine-Regular.ttf b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/fonts/Cousine-Regular.ttf deleted file mode 100644 index 70a0bf9..0000000 Binary files a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/fonts/Cousine-Regular.ttf and /dev/null differ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/fonts/DroidSans.ttf b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/fonts/DroidSans.ttf deleted file mode 100644 index 767c63a..0000000 Binary files a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/fonts/DroidSans.ttf and /dev/null differ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/fonts/Karla-Regular.ttf b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/fonts/Karla-Regular.ttf deleted file mode 100644 index 81b3de6..0000000 Binary files a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/fonts/Karla-Regular.ttf and /dev/null differ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/fonts/ProggyClean.ttf b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/fonts/ProggyClean.ttf deleted file mode 100644 index 0270cdf..0000000 Binary files a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/fonts/ProggyClean.ttf and /dev/null differ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/fonts/ProggyTiny.ttf b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/fonts/ProggyTiny.ttf deleted file mode 100644 index 1c4312c..0000000 Binary files a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/fonts/ProggyTiny.ttf and /dev/null differ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/fonts/Roboto-Medium.ttf b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/fonts/Roboto-Medium.ttf deleted file mode 100644 index 39c63d7..0000000 Binary files a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/fonts/Roboto-Medium.ttf and /dev/null differ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/fonts/binary_to_compressed_c.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/fonts/binary_to_compressed_c.cpp deleted file mode 100644 index 441c8f6..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/fonts/binary_to_compressed_c.cpp +++ /dev/null @@ -1,385 +0,0 @@ -// dear imgui -// (binary_to_compressed_c.cpp) -// Helper tool to turn a file into a C array, if you want to embed font data in your source code. - -// The data is first compressed with stb_compress() to reduce source code size, -// then encoded in Base85 to fit in a string so we can fit roughly 4 bytes of compressed data into 5 bytes of source code (suggested by @mmalex) -// (If we used 32-bit constants it would require take 11 bytes of source code to encode 4 bytes, and be endianness dependent) -// Note that even with compression, the output array is likely to be bigger than the binary file.. -// Load compressed TTF fonts with ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF() - -// Build with, e.g: -// # cl.exe binary_to_compressed_c.cpp -// # g++ binary_to_compressed_c.cpp -// # clang++ binary_to_compressed_c.cpp -// You can also find a precompiled Windows binary in the binary/demo package available from https://github.com/ocornut/imgui - -// Usage: -// binary_to_compressed_c.exe [-base85] [-nocompress] -// Usage example: -// # binary_to_compressed_c.exe myfont.ttf MyFont > myfont.cpp -// # binary_to_compressed_c.exe -base85 myfont.ttf MyFont > myfont.cpp - -#define _CRT_SECURE_NO_WARNINGS -#include -#include -#include -#include - -// stb_compress* from stb.h - declaration -typedef unsigned int stb_uint; -typedef unsigned char stb_uchar; -stb_uint stb_compress(stb_uchar* out, stb_uchar* in, stb_uint len); - -static bool binary_to_compressed_c(const char* filename, const char* symbol, bool use_base85_encoding, bool use_compression); - -int main(int argc, char** argv) -{ - if (argc < 3) - { - printf("Syntax: %s [-base85] [-nocompress] \n", argv[0]); - return 0; - } - - int argn = 1; - bool use_base85_encoding = false; - bool use_compression = true; - if (argv[argn][0] == '-') - { - if (strcmp(argv[argn], "-base85") == 0) { use_base85_encoding = true; argn++; } - else if (strcmp(argv[argn], "-nocompress") == 0) { use_compression = false; argn++; } - else - { - fprintf(stderr, "Unknown argument: '%s'\n", argv[argn]); - return 1; - } - } - - bool ret = binary_to_compressed_c(argv[argn], argv[argn + 1], use_base85_encoding, use_compression); - if (!ret) - fprintf(stderr, "Error opening or reading file: '%s'\n", argv[argn]); - return ret ? 0 : 1; -} - -char Encode85Byte(unsigned int x) -{ - x = (x % 85) + 35; - return (x >= '\\') ? x + 1 : x; -} - -bool binary_to_compressed_c(const char* filename, const char* symbol, bool use_base85_encoding, bool use_compression) -{ - // Read file - FILE* f = fopen(filename, "rb"); - if (!f) return false; - int data_sz; - if (fseek(f, 0, SEEK_END) || (data_sz = (int)ftell(f)) == -1 || fseek(f, 0, SEEK_SET)) { fclose(f); return false; } - char* data = new char[data_sz + 4]; - if (fread(data, 1, data_sz, f) != (size_t)data_sz) { fclose(f); delete[] data; return false; } - memset((void*)(((char*)data) + data_sz), 0, 4); - fclose(f); - - // Compress - int maxlen = data_sz + 512 + (data_sz >> 2) + sizeof(int); // total guess - char* compressed = use_compression ? new char[maxlen] : data; - int compressed_sz = use_compression ? stb_compress((stb_uchar*)compressed, (stb_uchar*)data, data_sz) : data_sz; - if (use_compression) - memset(compressed + compressed_sz, 0, maxlen - compressed_sz); - - // Output as Base85 encoded - FILE* out = stdout; - fprintf(out, "// File: '%s' (%d bytes)\n", filename, (int)data_sz); - fprintf(out, "// Exported using binary_to_compressed_c.cpp\n"); - const char* compressed_str = use_compression ? "compressed_" : ""; - if (use_base85_encoding) - { - fprintf(out, "static const char %s_%sdata_base85[%d+1] =\n \"", symbol, compressed_str, (int)((compressed_sz + 3) / 4)*5); - char prev_c = 0; - for (int src_i = 0; src_i < compressed_sz; src_i += 4) - { - // This is made a little more complicated by the fact that ??X sequences are interpreted as trigraphs by old C/C++ compilers. So we need to escape pairs of ??. - unsigned int d = *(unsigned int*)(compressed + src_i); - for (unsigned int n5 = 0; n5 < 5; n5++, d /= 85) - { - char c = Encode85Byte(d); - fprintf(out, (c == '?' && prev_c == '?') ? "\\%c" : "%c", c); - prev_c = c; - } - if ((src_i % 112) == 112 - 4) - fprintf(out, "\"\n \""); - } - fprintf(out, "\";\n\n"); - } - else - { - fprintf(out, "static const unsigned int %s_%ssize = %d;\n", symbol, compressed_str, (int)compressed_sz); - fprintf(out, "static const unsigned int %s_%sdata[%d/4] =\n{", symbol, compressed_str, (int)((compressed_sz + 3) / 4)*4); - int column = 0; - for (int i = 0; i < compressed_sz; i += 4) - { - unsigned int d = *(unsigned int*)(compressed + i); - if ((column++ % 12) == 0) - fprintf(out, "\n 0x%08x, ", d); - else - fprintf(out, "0x%08x, ", d); - } - fprintf(out, "\n};\n\n"); - } - - // Cleanup - delete[] data; - if (use_compression) - delete[] compressed; - return true; -} - -// stb_compress* from stb.h - definition - -//////////////////// compressor /////////////////////// - -static stb_uint stb_adler32(stb_uint adler32, stb_uchar *buffer, stb_uint buflen) -{ - const unsigned long ADLER_MOD = 65521; - unsigned long s1 = adler32 & 0xffff, s2 = adler32 >> 16; - unsigned long blocklen, i; - - blocklen = buflen % 5552; - while (buflen) { - for (i=0; i + 7 < blocklen; i += 8) { - s1 += buffer[0], s2 += s1; - s1 += buffer[1], s2 += s1; - s1 += buffer[2], s2 += s1; - s1 += buffer[3], s2 += s1; - s1 += buffer[4], s2 += s1; - s1 += buffer[5], s2 += s1; - s1 += buffer[6], s2 += s1; - s1 += buffer[7], s2 += s1; - - buffer += 8; - } - - for (; i < blocklen; ++i) - s1 += *buffer++, s2 += s1; - - s1 %= ADLER_MOD, s2 %= ADLER_MOD; - buflen -= blocklen; - blocklen = 5552; - } - return (s2 << 16) + s1; -} - -static unsigned int stb_matchlen(stb_uchar *m1, stb_uchar *m2, stb_uint maxlen) -{ - stb_uint i; - for (i=0; i < maxlen; ++i) - if (m1[i] != m2[i]) return i; - return i; -} - -// simple implementation that just takes the source data in a big block - -static stb_uchar *stb__out; -static FILE *stb__outfile; -static stb_uint stb__outbytes; - -static void stb__write(unsigned char v) -{ - fputc(v, stb__outfile); - ++stb__outbytes; -} - -//#define stb_out(v) (stb__out ? *stb__out++ = (stb_uchar) (v) : stb__write((stb_uchar) (v))) -#define stb_out(v) do { if (stb__out) *stb__out++ = (stb_uchar) (v); else stb__write((stb_uchar) (v)); } while (0) - -static void stb_out2(stb_uint v) { stb_out(v >> 8); stb_out(v); } -static void stb_out3(stb_uint v) { stb_out(v >> 16); stb_out(v >> 8); stb_out(v); } -static void stb_out4(stb_uint v) { stb_out(v >> 24); stb_out(v >> 16); stb_out(v >> 8 ); stb_out(v); } - -static void outliterals(stb_uchar *in, int numlit) -{ - while (numlit > 65536) { - outliterals(in,65536); - in += 65536; - numlit -= 65536; - } - - if (numlit == 0) ; - else if (numlit <= 32) stb_out (0x000020 + numlit-1); - else if (numlit <= 2048) stb_out2(0x000800 + numlit-1); - else /* numlit <= 65536) */ stb_out3(0x070000 + numlit-1); - - if (stb__out) { - memcpy(stb__out,in,numlit); - stb__out += numlit; - } else - fwrite(in, 1, numlit, stb__outfile); -} - -static int stb__window = 0x40000; // 256K - -static int stb_not_crap(int best, int dist) -{ - return ((best > 2 && dist <= 0x00100) - || (best > 5 && dist <= 0x04000) - || (best > 7 && dist <= 0x80000)); -} - -static stb_uint stb__hashsize = 32768; - -// note that you can play with the hashing functions all you -// want without needing to change the decompressor -#define stb__hc(q,h,c) (((h) << 7) + ((h) >> 25) + q[c]) -#define stb__hc2(q,h,c,d) (((h) << 14) + ((h) >> 18) + (q[c] << 7) + q[d]) -#define stb__hc3(q,c,d,e) ((q[c] << 14) + (q[d] << 7) + q[e]) - -static unsigned int stb__running_adler; - -static int stb_compress_chunk(stb_uchar *history, - stb_uchar *start, - stb_uchar *end, - int length, - int *pending_literals, - stb_uchar **chash, - stb_uint mask) -{ - (void)history; - int window = stb__window; - stb_uint match_max; - stb_uchar *lit_start = start - *pending_literals; - stb_uchar *q = start; - -#define STB__SCRAMBLE(h) (((h) + ((h) >> 16)) & mask) - - // stop short of the end so we don't scan off the end doing - // the hashing; this means we won't compress the last few bytes - // unless they were part of something longer - while (q < start+length && q+12 < end) { - int m; - stb_uint h1,h2,h3,h4, h; - stb_uchar *t; - int best = 2, dist=0; - - if (q+65536 > end) - match_max = end-q; - else - match_max = 65536; - -#define stb__nc(b,d) ((d) <= window && ((b) > 9 || stb_not_crap(b,d))) - -#define STB__TRY(t,p) /* avoid retrying a match we already tried */ \ - if (p ? dist != q-t : 1) \ - if ((m = stb_matchlen(t, q, match_max)) > best) \ - if (stb__nc(m,q-(t))) \ - best = m, dist = q - (t) - - // rather than search for all matches, only try 4 candidate locations, - // chosen based on 4 different hash functions of different lengths. - // this strategy is inspired by LZO; hashing is unrolled here using the - // 'hc' macro - h = stb__hc3(q,0, 1, 2); h1 = STB__SCRAMBLE(h); - t = chash[h1]; if (t) STB__TRY(t,0); - h = stb__hc2(q,h, 3, 4); h2 = STB__SCRAMBLE(h); - h = stb__hc2(q,h, 5, 6); t = chash[h2]; if (t) STB__TRY(t,1); - h = stb__hc2(q,h, 7, 8); h3 = STB__SCRAMBLE(h); - h = stb__hc2(q,h, 9,10); t = chash[h3]; if (t) STB__TRY(t,1); - h = stb__hc2(q,h,11,12); h4 = STB__SCRAMBLE(h); - t = chash[h4]; if (t) STB__TRY(t,1); - - // because we use a shared hash table, can only update it - // _after_ we've probed all of them - chash[h1] = chash[h2] = chash[h3] = chash[h4] = q; - - if (best > 2) - assert(dist > 0); - - // see if our best match qualifies - if (best < 3) { // fast path literals - ++q; - } else if (best > 2 && best <= 0x80 && dist <= 0x100) { - outliterals(lit_start, q-lit_start); lit_start = (q += best); - stb_out(0x80 + best-1); - stb_out(dist-1); - } else if (best > 5 && best <= 0x100 && dist <= 0x4000) { - outliterals(lit_start, q-lit_start); lit_start = (q += best); - stb_out2(0x4000 + dist-1); - stb_out(best-1); - } else if (best > 7 && best <= 0x100 && dist <= 0x80000) { - outliterals(lit_start, q-lit_start); lit_start = (q += best); - stb_out3(0x180000 + dist-1); - stb_out(best-1); - } else if (best > 8 && best <= 0x10000 && dist <= 0x80000) { - outliterals(lit_start, q-lit_start); lit_start = (q += best); - stb_out3(0x100000 + dist-1); - stb_out2(best-1); - } else if (best > 9 && dist <= 0x1000000) { - if (best > 65536) best = 65536; - outliterals(lit_start, q-lit_start); lit_start = (q += best); - if (best <= 0x100) { - stb_out(0x06); - stb_out3(dist-1); - stb_out(best-1); - } else { - stb_out(0x04); - stb_out3(dist-1); - stb_out2(best-1); - } - } else { // fallback literals if no match was a balanced tradeoff - ++q; - } - } - - // if we didn't get all the way, add the rest to literals - if (q-start < length) - q = start+length; - - // the literals are everything from lit_start to q - *pending_literals = (q - lit_start); - - stb__running_adler = stb_adler32(stb__running_adler, start, q - start); - return q - start; -} - -static int stb_compress_inner(stb_uchar *input, stb_uint length) -{ - int literals = 0; - stb_uint len,i; - - stb_uchar **chash; - chash = (stb_uchar**) malloc(stb__hashsize * sizeof(stb_uchar*)); - if (chash == NULL) return 0; // failure - for (i=0; i < stb__hashsize; ++i) - chash[i] = NULL; - - // stream signature - stb_out(0x57); stb_out(0xbc); - stb_out2(0); - - stb_out4(0); // 64-bit length requires 32-bit leading 0 - stb_out4(length); - stb_out4(stb__window); - - stb__running_adler = 1; - - len = stb_compress_chunk(input, input, input+length, length, &literals, chash, stb__hashsize-1); - assert(len == length); - - outliterals(input+length - literals, literals); - - free(chash); - - stb_out2(0x05fa); // end opcode - - stb_out4(stb__running_adler); - - return 1; // success -} - -stb_uint stb_compress(stb_uchar *out, stb_uchar *input, stb_uint length) -{ - stb__out = out; - stb__outfile = NULL; - - stb_compress_inner(input, length); - - return stb__out - out; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/freetype/README.md b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/freetype/README.md deleted file mode 100644 index f7d7bab..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/freetype/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# imgui_freetype - -Build font atlases using FreeType instead of stb_truetype (which is the default font rasterizer). -
    by @vuhdo, @mikesart, @ocornut. - -### Usage - -1. Get latest FreeType binaries or build yourself (under Windows you may use vcpkg with `vcpkg install freetype --triplet=x64-windows`, `vcpkg integrate install`). -2. Add imgui_freetype.h/cpp alongside your project files. -3. Add `#define IMGUI_ENABLE_FREETYPE` in your [imconfig.h](https://github.com/ocornut/imgui/blob/master/imconfig.h) file - -### About Gamma Correct Blending - -FreeType assumes blending in linear space rather than gamma space. -See FreeType note for [FT_Render_Glyph](https://www.freetype.org/freetype2/docs/reference/ft2-base_interface.html#FT_Render_Glyph). -For correct results you need to be using sRGB and convert to linear space in the pixel shader output. -The default Dear ImGui styles will be impacted by this change (alpha values will need tweaking). - -### Testbed for toying with settings (for developers) - -See https://gist.github.com/ocornut/b3a9ecf13502fd818799a452969649ad - -### Known issues - -- Oversampling settins are ignored but also not so much necessary with the higher quality rendering. - -### Comparaison - -Small, thin anti-aliased fonts are typically benefiting a lots from Freetype's hinting: -![comparing_font_rasterizers](https://user-images.githubusercontent.com/8225057/107550178-fef87f00-6bd0-11eb-8d09-e2edb2f0ccfc.gif) - -### Colorful glyphs/emojis - -You can use the `ImGuiFreeTypeBuilderFlags_LoadColor` flag to load certain colorful glyphs. See -["Using Colorful Glyphs/Emojis"](https://github.com/ocornut/imgui/edit/master/docs/FONTS.md#using-colorful-glyphsemojis) section of FONTS.md. - -![colored glyphs](https://user-images.githubusercontent.com/8225057/106171241-9dc4ba80-6191-11eb-8a69-ca1467b206d1.png) diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/freetype/imgui_freetype.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/freetype/imgui_freetype.cpp deleted file mode 100644 index a8ec51b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/freetype/imgui_freetype.cpp +++ /dev/null @@ -1,773 +0,0 @@ -// dear imgui: FreeType font builder (used as a replacement for the stb_truetype builder) -// (code) - -// Get the latest version at https://github.com/ocornut/imgui/tree/master/misc/freetype -// Original code by @vuhdo (Aleksei Skriabin). Improvements by @mikesart. Maintained since 2019 by @ocornut. - -// CHANGELOG -// (minor and older changes stripped away, please see git history for details) -// 2021/08/23: fixed crash when FT_Render_Glyph() fails to render a glyph and returns NULL. -// 2021/03/05: added ImGuiFreeTypeBuilderFlags_Bitmap to load bitmap glyphs. -// 2021/03/02: set 'atlas->TexPixelsUseColors = true' to help some backends with deciding of a prefered texture format. -// 2021/01/28: added support for color-layered glyphs via ImGuiFreeTypeBuilderFlags_LoadColor (require Freetype 2.10+). -// 2021/01/26: simplified integration by using '#define IMGUI_ENABLE_FREETYPE'. -// renamed ImGuiFreeType::XXX flags to ImGuiFreeTypeBuilderFlags_XXX for consistency with other API. removed ImGuiFreeType::BuildFontAtlas(). -// 2020/06/04: fix for rare case where FT_Get_Char_Index() succeed but FT_Load_Glyph() fails. -// 2019/02/09: added RasterizerFlags::Monochrome flag to disable font anti-aliasing (combine with ::MonoHinting for best results!) -// 2019/01/15: added support for imgui allocators + added FreeType only override function SetAllocatorFunctions(). -// 2019/01/10: re-factored to match big update in STB builder. fixed texture height waste. fixed redundant glyphs when merging. support for glyph padding. -// 2018/06/08: added support for ImFontConfig::GlyphMinAdvanceX, GlyphMaxAdvanceX. -// 2018/02/04: moved to main imgui repository (away from http://www.github.com/ocornut/imgui_club) -// 2018/01/22: fix for addition of ImFontAtlas::TexUvscale member. -// 2017/10/22: minor inconsequential change to match change in master (removed an unnecessary statement). -// 2017/09/26: fixes for imgui internal changes. -// 2017/08/26: cleanup, optimizations, support for ImFontConfig::RasterizerFlags, ImFontConfig::RasterizerMultiply. -// 2017/08/16: imported from https://github.com/Vuhdo/imgui_freetype into http://www.github.com/ocornut/imgui_club, updated for latest changes in ImFontAtlas, minor tweaks. - -// About Gamma Correct Blending: -// - FreeType assumes blending in linear space rather than gamma space. -// - See https://www.freetype.org/freetype2/docs/reference/ft2-base_interface.html#FT_Render_Glyph -// - For correct results you need to be using sRGB and convert to linear space in the pixel shader output. -// - The default dear imgui styles will be impacted by this change (alpha values will need tweaking). - -// FIXME: cfg.OversampleH, OversampleV are not supported (but perhaps not so necessary with this rasterizer). - -#include "imgui_freetype.h" -#include "imgui_internal.h" // ImMin,ImMax,ImFontAtlasBuild*, -#include -#include -#include FT_FREETYPE_H // -#include FT_MODULE_H // -#include FT_GLYPH_H // -#include FT_SYNTHESIS_H // - -#ifdef _MSC_VER -#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff) -#pragma warning (disable: 26812) // [Static Analyzer] The enum type 'xxx' is unscoped. Prefer 'enum class' over 'enum' (Enum.3). -#endif - -#if defined(__GNUC__) -#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind -#pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used -#endif - -//------------------------------------------------------------------------- -// Data -//------------------------------------------------------------------------- - -// Default memory allocators -static void* ImGuiFreeTypeDefaultAllocFunc(size_t size, void* user_data) { IM_UNUSED(user_data); return IM_ALLOC(size); } -static void ImGuiFreeTypeDefaultFreeFunc(void* ptr, void* user_data) { IM_UNUSED(user_data); IM_FREE(ptr); } - -// Current memory allocators -static void* (*GImGuiFreeTypeAllocFunc)(size_t size, void* user_data) = ImGuiFreeTypeDefaultAllocFunc; -static void (*GImGuiFreeTypeFreeFunc)(void* ptr, void* user_data) = ImGuiFreeTypeDefaultFreeFunc; -static void* GImGuiFreeTypeAllocatorUserData = NULL; - -//------------------------------------------------------------------------- -// Code -//------------------------------------------------------------------------- - -namespace -{ - // Glyph metrics: - // -------------- - // - // xmin xmax - // | | - // |<-------- width -------->| - // | | - // | +-------------------------+----------------- ymax - // | | ggggggggg ggggg | ^ ^ - // | | g:::::::::ggg::::g | | | - // | | g:::::::::::::::::g | | | - // | | g::::::ggggg::::::gg | | | - // | | g:::::g g:::::g | | | - // offsetX -|-------->| g:::::g g:::::g | offsetY | - // | | g:::::g g:::::g | | | - // | | g::::::g g:::::g | | | - // | | g:::::::ggggg:::::g | | | - // | | g::::::::::::::::g | | height - // | | gg::::::::::::::g | | | - // baseline ---*---------|---- gggggggg::::::g-----*-------- | - // / | | g:::::g | | - // origin | | gggggg g:::::g | | - // | | g:::::gg gg:::::g | | - // | | g::::::ggg:::::::g | | - // | | gg:::::::::::::g | | - // | | ggg::::::ggg | | - // | | gggggg | v - // | +-------------------------+----------------- ymin - // | | - // |------------- advanceX ----------->| - - // A structure that describe a glyph. - struct GlyphInfo - { - int Width; // Glyph's width in pixels. - int Height; // Glyph's height in pixels. - FT_Int OffsetX; // The distance from the origin ("pen position") to the left of the glyph. - FT_Int OffsetY; // The distance from the origin to the top of the glyph. This is usually a value < 0. - float AdvanceX; // The distance from the origin to the origin of the next glyph. This is usually a value > 0. - bool IsColored; // The glyph is colored - }; - - // Font parameters and metrics. - struct FontInfo - { - uint32_t PixelHeight; // Size this font was generated with. - float Ascender; // The pixel extents above the baseline in pixels (typically positive). - float Descender; // The extents below the baseline in pixels (typically negative). - float LineSpacing; // The baseline-to-baseline distance. Note that it usually is larger than the sum of the ascender and descender taken as absolute values. There is also no guarantee that no glyphs extend above or below subsequent baselines when using this distance. Think of it as a value the designer of the font finds appropriate. - float LineGap; // The spacing in pixels between one row's descent and the next row's ascent. - float MaxAdvanceWidth; // This field gives the maximum horizontal cursor advance for all glyphs in the font. - }; - - // FreeType glyph rasterizer. - // NB: No ctor/dtor, explicitly call Init()/Shutdown() - struct FreeTypeFont - { - bool InitFont(FT_Library ft_library, const ImFontConfig& cfg, unsigned int extra_user_flags); // Initialize from an external data buffer. Doesn't copy data, and you must ensure it stays valid up to this object lifetime. - void CloseFont(); - void SetPixelHeight(int pixel_height); // Change font pixel size. All following calls to RasterizeGlyph() will use this size - const FT_Glyph_Metrics* LoadGlyph(uint32_t in_codepoint); - const FT_Bitmap* RenderGlyphAndGetInfo(GlyphInfo* out_glyph_info); - void BlitGlyph(const FT_Bitmap* ft_bitmap, uint32_t* dst, uint32_t dst_pitch, unsigned char* multiply_table = NULL); - ~FreeTypeFont() { CloseFont(); } - - // [Internals] - FontInfo Info; // Font descriptor of the current font. - FT_Face Face; - unsigned int UserFlags; // = ImFontConfig::RasterizerFlags - FT_Int32 LoadFlags; - FT_Render_Mode RenderMode; - }; - - // From SDL_ttf: Handy routines for converting from fixed point - #define FT_CEIL(X) (((X + 63) & -64) / 64) - - bool FreeTypeFont::InitFont(FT_Library ft_library, const ImFontConfig& cfg, unsigned int extra_font_builder_flags) - { - FT_Error error = FT_New_Memory_Face(ft_library, (uint8_t*)cfg.FontData, (uint32_t)cfg.FontDataSize, (uint32_t)cfg.FontNo, &Face); - if (error != 0) - return false; - error = FT_Select_Charmap(Face, FT_ENCODING_UNICODE); - if (error != 0) - return false; - - // Convert to FreeType flags (NB: Bold and Oblique are processed separately) - UserFlags = cfg.FontBuilderFlags | extra_font_builder_flags; - - LoadFlags = 0; - if ((UserFlags & ImGuiFreeTypeBuilderFlags_Bitmap) == 0) - LoadFlags |= FT_LOAD_NO_BITMAP; - - if (UserFlags & ImGuiFreeTypeBuilderFlags_NoHinting) - LoadFlags |= FT_LOAD_NO_HINTING; - if (UserFlags & ImGuiFreeTypeBuilderFlags_NoAutoHint) - LoadFlags |= FT_LOAD_NO_AUTOHINT; - if (UserFlags & ImGuiFreeTypeBuilderFlags_ForceAutoHint) - LoadFlags |= FT_LOAD_FORCE_AUTOHINT; - if (UserFlags & ImGuiFreeTypeBuilderFlags_LightHinting) - LoadFlags |= FT_LOAD_TARGET_LIGHT; - else if (UserFlags & ImGuiFreeTypeBuilderFlags_MonoHinting) - LoadFlags |= FT_LOAD_TARGET_MONO; - else - LoadFlags |= FT_LOAD_TARGET_NORMAL; - - if (UserFlags & ImGuiFreeTypeBuilderFlags_Monochrome) - RenderMode = FT_RENDER_MODE_MONO; - else - RenderMode = FT_RENDER_MODE_NORMAL; - - if (UserFlags & ImGuiFreeTypeBuilderFlags_LoadColor) - LoadFlags |= FT_LOAD_COLOR; - - memset(&Info, 0, sizeof(Info)); - SetPixelHeight((uint32_t)cfg.SizePixels); - - return true; - } - - void FreeTypeFont::CloseFont() - { - if (Face) - { - FT_Done_Face(Face); - Face = NULL; - } - } - - void FreeTypeFont::SetPixelHeight(int pixel_height) - { - // Vuhdo: I'm not sure how to deal with font sizes properly. As far as I understand, currently ImGui assumes that the 'pixel_height' - // is a maximum height of an any given glyph, i.e. it's the sum of font's ascender and descender. Seems strange to me. - // NB: FT_Set_Pixel_Sizes() doesn't seem to get us the same result. - FT_Size_RequestRec req; - req.type = (UserFlags & ImGuiFreeTypeBuilderFlags_Bitmap) ? FT_SIZE_REQUEST_TYPE_NOMINAL : FT_SIZE_REQUEST_TYPE_REAL_DIM; - req.width = 0; - req.height = (uint32_t)pixel_height * 64; - req.horiResolution = 0; - req.vertResolution = 0; - FT_Request_Size(Face, &req); - - // Update font info - FT_Size_Metrics metrics = Face->size->metrics; - Info.PixelHeight = (uint32_t)pixel_height; - Info.Ascender = (float)FT_CEIL(metrics.ascender); - Info.Descender = (float)FT_CEIL(metrics.descender); - Info.LineSpacing = (float)FT_CEIL(metrics.height); - Info.LineGap = (float)FT_CEIL(metrics.height - metrics.ascender + metrics.descender); - Info.MaxAdvanceWidth = (float)FT_CEIL(metrics.max_advance); - } - - const FT_Glyph_Metrics* FreeTypeFont::LoadGlyph(uint32_t codepoint) - { - uint32_t glyph_index = FT_Get_Char_Index(Face, codepoint); - if (glyph_index == 0) - return NULL; - FT_Error error = FT_Load_Glyph(Face, glyph_index, LoadFlags); - if (error) - return NULL; - - // Need an outline for this to work - FT_GlyphSlot slot = Face->glyph; - IM_ASSERT(slot->format == FT_GLYPH_FORMAT_OUTLINE || slot->format == FT_GLYPH_FORMAT_BITMAP); - - // Apply convenience transform (this is not picking from real "Bold"/"Italic" fonts! Merely applying FreeType helper transform. Oblique == Slanting) - if (UserFlags & ImGuiFreeTypeBuilderFlags_Bold) - FT_GlyphSlot_Embolden(slot); - if (UserFlags & ImGuiFreeTypeBuilderFlags_Oblique) - { - FT_GlyphSlot_Oblique(slot); - //FT_BBox bbox; - //FT_Outline_Get_BBox(&slot->outline, &bbox); - //slot->metrics.width = bbox.xMax - bbox.xMin; - //slot->metrics.height = bbox.yMax - bbox.yMin; - } - - return &slot->metrics; - } - - const FT_Bitmap* FreeTypeFont::RenderGlyphAndGetInfo(GlyphInfo* out_glyph_info) - { - FT_GlyphSlot slot = Face->glyph; - FT_Error error = FT_Render_Glyph(slot, RenderMode); - if (error != 0) - return NULL; - - FT_Bitmap* ft_bitmap = &Face->glyph->bitmap; - out_glyph_info->Width = (int)ft_bitmap->width; - out_glyph_info->Height = (int)ft_bitmap->rows; - out_glyph_info->OffsetX = Face->glyph->bitmap_left; - out_glyph_info->OffsetY = -Face->glyph->bitmap_top; - out_glyph_info->AdvanceX = (float)FT_CEIL(slot->advance.x); - out_glyph_info->IsColored = (ft_bitmap->pixel_mode == FT_PIXEL_MODE_BGRA); - - return ft_bitmap; - } - - void FreeTypeFont::BlitGlyph(const FT_Bitmap* ft_bitmap, uint32_t* dst, uint32_t dst_pitch, unsigned char* multiply_table) - { - IM_ASSERT(ft_bitmap != NULL); - const uint32_t w = ft_bitmap->width; - const uint32_t h = ft_bitmap->rows; - const uint8_t* src = ft_bitmap->buffer; - const uint32_t src_pitch = ft_bitmap->pitch; - - switch (ft_bitmap->pixel_mode) - { - case FT_PIXEL_MODE_GRAY: // Grayscale image, 1 byte per pixel. - { - if (multiply_table == NULL) - { - for (uint32_t y = 0; y < h; y++, src += src_pitch, dst += dst_pitch) - for (uint32_t x = 0; x < w; x++) - dst[x] = IM_COL32(255, 255, 255, src[x]); - } - else - { - for (uint32_t y = 0; y < h; y++, src += src_pitch, dst += dst_pitch) - for (uint32_t x = 0; x < w; x++) - dst[x] = IM_COL32(255, 255, 255, multiply_table[src[x]]); - } - break; - } - case FT_PIXEL_MODE_MONO: // Monochrome image, 1 bit per pixel. The bits in each byte are ordered from MSB to LSB. - { - uint8_t color0 = multiply_table ? multiply_table[0] : 0; - uint8_t color1 = multiply_table ? multiply_table[255] : 255; - for (uint32_t y = 0; y < h; y++, src += src_pitch, dst += dst_pitch) - { - uint8_t bits = 0; - const uint8_t* bits_ptr = src; - for (uint32_t x = 0; x < w; x++, bits <<= 1) - { - if ((x & 7) == 0) - bits = *bits_ptr++; - dst[x] = IM_COL32(255, 255, 255, (bits & 0x80) ? color1 : color0); - } - } - break; - } - case FT_PIXEL_MODE_BGRA: - { - // FIXME: Converting pre-multiplied alpha to straight. Doesn't smell good. - #define DE_MULTIPLY(color, alpha) (ImU32)(255.0f * (float)color / (float)alpha + 0.5f) - if (multiply_table == NULL) - { - for (uint32_t y = 0; y < h; y++, src += src_pitch, dst += dst_pitch) - for (uint32_t x = 0; x < w; x++) - { - uint8_t r = src[x * 4 + 2], g = src[x * 4 + 1], b = src[x * 4], a = src[x * 4 + 3]; - dst[x] = IM_COL32(DE_MULTIPLY(r, a), DE_MULTIPLY(g, a), DE_MULTIPLY(b, a), a); - } - } - else - { - for (uint32_t y = 0; y < h; y++, src += src_pitch, dst += dst_pitch) - { - for (uint32_t x = 0; x < w; x++) - { - uint8_t r = src[x * 4 + 2], g = src[x * 4 + 1], b = src[x * 4], a = src[x * 4 + 3]; - dst[x] = IM_COL32(multiply_table[DE_MULTIPLY(r, a)], multiply_table[DE_MULTIPLY(g, a)], multiply_table[DE_MULTIPLY(b, a)], multiply_table[a]); - } - } - } - #undef DE_MULTIPLY - break; - } - default: - IM_ASSERT(0 && "FreeTypeFont::BlitGlyph(): Unknown bitmap pixel mode!"); - } - } -} - -#ifndef STB_RECT_PACK_IMPLEMENTATION // in case the user already have an implementation in the _same_ compilation unit (e.g. unity builds) -#ifndef IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION -#define STBRP_ASSERT(x) do { IM_ASSERT(x); } while (0) -#define STBRP_STATIC -#define STB_RECT_PACK_IMPLEMENTATION -#endif -#ifdef IMGUI_STB_RECT_PACK_FILENAME -#include IMGUI_STB_RECT_PACK_FILENAME -#else -#include "imstb_rectpack.h" -#endif -#endif - -struct ImFontBuildSrcGlyphFT -{ - GlyphInfo Info; - uint32_t Codepoint; - unsigned int* BitmapData; // Point within one of the dst_tmp_bitmap_buffers[] array - - ImFontBuildSrcGlyphFT() { memset(this, 0, sizeof(*this)); } -}; - -struct ImFontBuildSrcDataFT -{ - FreeTypeFont Font; - stbrp_rect* Rects; // Rectangle to pack. We first fill in their size and the packer will give us their position. - const ImWchar* SrcRanges; // Ranges as requested by user (user is allowed to request too much, e.g. 0x0020..0xFFFF) - int DstIndex; // Index into atlas->Fonts[] and dst_tmp_array[] - int GlyphsHighest; // Highest requested codepoint - int GlyphsCount; // Glyph count (excluding missing glyphs and glyphs already set by an earlier source font) - ImBitVector GlyphsSet; // Glyph bit map (random access, 1-bit per codepoint. This will be a maximum of 8KB) - ImVector GlyphsList; -}; - -// Temporary data for one destination ImFont* (multiple source fonts can be merged into one destination ImFont) -struct ImFontBuildDstDataFT -{ - int SrcCount; // Number of source fonts targeting this destination font. - int GlyphsHighest; - int GlyphsCount; - ImBitVector GlyphsSet; // This is used to resolve collision when multiple sources are merged into a same destination font. -}; - -bool ImFontAtlasBuildWithFreeTypeEx(FT_Library ft_library, ImFontAtlas* atlas, unsigned int extra_flags) -{ - IM_ASSERT(atlas->ConfigData.Size > 0); - - ImFontAtlasBuildInit(atlas); - - // Clear atlas - atlas->TexID = (ImTextureID)NULL; - atlas->TexWidth = atlas->TexHeight = 0; - atlas->TexUvScale = ImVec2(0.0f, 0.0f); - atlas->TexUvWhitePixel = ImVec2(0.0f, 0.0f); - atlas->ClearTexData(); - - // Temporary storage for building - bool src_load_color = false; - ImVector src_tmp_array; - ImVector dst_tmp_array; - src_tmp_array.resize(atlas->ConfigData.Size); - dst_tmp_array.resize(atlas->Fonts.Size); - memset((void*)src_tmp_array.Data, 0, (size_t)src_tmp_array.size_in_bytes()); - memset((void*)dst_tmp_array.Data, 0, (size_t)dst_tmp_array.size_in_bytes()); - - // 1. Initialize font loading structure, check font data validity - for (int src_i = 0; src_i < atlas->ConfigData.Size; src_i++) - { - ImFontBuildSrcDataFT& src_tmp = src_tmp_array[src_i]; - ImFontConfig& cfg = atlas->ConfigData[src_i]; - FreeTypeFont& font_face = src_tmp.Font; - IM_ASSERT(cfg.DstFont && (!cfg.DstFont->IsLoaded() || cfg.DstFont->ContainerAtlas == atlas)); - - // Find index from cfg.DstFont (we allow the user to set cfg.DstFont. Also it makes casual debugging nicer than when storing indices) - src_tmp.DstIndex = -1; - for (int output_i = 0; output_i < atlas->Fonts.Size && src_tmp.DstIndex == -1; output_i++) - if (cfg.DstFont == atlas->Fonts[output_i]) - src_tmp.DstIndex = output_i; - IM_ASSERT(src_tmp.DstIndex != -1); // cfg.DstFont not pointing within atlas->Fonts[] array? - if (src_tmp.DstIndex == -1) - return false; - - // Load font - if (!font_face.InitFont(ft_library, cfg, extra_flags)) - return false; - - // Measure highest codepoints - src_load_color |= (cfg.FontBuilderFlags & ImGuiFreeTypeBuilderFlags_LoadColor) != 0; - ImFontBuildDstDataFT& dst_tmp = dst_tmp_array[src_tmp.DstIndex]; - src_tmp.SrcRanges = cfg.GlyphRanges ? cfg.GlyphRanges : atlas->GetGlyphRangesDefault(); - for (const ImWchar* src_range = src_tmp.SrcRanges; src_range[0] && src_range[1]; src_range += 2) - src_tmp.GlyphsHighest = ImMax(src_tmp.GlyphsHighest, (int)src_range[1]); - dst_tmp.SrcCount++; - dst_tmp.GlyphsHighest = ImMax(dst_tmp.GlyphsHighest, src_tmp.GlyphsHighest); - } - - // 2. For every requested codepoint, check for their presence in the font data, and handle redundancy or overlaps between source fonts to avoid unused glyphs. - int total_glyphs_count = 0; - for (int src_i = 0; src_i < src_tmp_array.Size; src_i++) - { - ImFontBuildSrcDataFT& src_tmp = src_tmp_array[src_i]; - ImFontBuildDstDataFT& dst_tmp = dst_tmp_array[src_tmp.DstIndex]; - src_tmp.GlyphsSet.Create(src_tmp.GlyphsHighest + 1); - if (dst_tmp.GlyphsSet.Storage.empty()) - dst_tmp.GlyphsSet.Create(dst_tmp.GlyphsHighest + 1); - - for (const ImWchar* src_range = src_tmp.SrcRanges; src_range[0] && src_range[1]; src_range += 2) - for (int codepoint = src_range[0]; codepoint <= (int)src_range[1]; codepoint++) - { - if (dst_tmp.GlyphsSet.TestBit(codepoint)) // Don't overwrite existing glyphs. We could make this an option (e.g. MergeOverwrite) - continue; - uint32_t glyph_index = FT_Get_Char_Index(src_tmp.Font.Face, codepoint); // It is actually in the font? (FIXME-OPT: We are not storing the glyph_index..) - if (glyph_index == 0) - continue; - - // Add to avail set/counters - src_tmp.GlyphsCount++; - dst_tmp.GlyphsCount++; - src_tmp.GlyphsSet.SetBit(codepoint); - dst_tmp.GlyphsSet.SetBit(codepoint); - total_glyphs_count++; - } - } - - // 3. Unpack our bit map into a flat list (we now have all the Unicode points that we know are requested _and_ available _and_ not overlapping another) - for (int src_i = 0; src_i < src_tmp_array.Size; src_i++) - { - ImFontBuildSrcDataFT& src_tmp = src_tmp_array[src_i]; - src_tmp.GlyphsList.reserve(src_tmp.GlyphsCount); - - IM_ASSERT(sizeof(src_tmp.GlyphsSet.Storage.Data[0]) == sizeof(ImU32)); - const ImU32* it_begin = src_tmp.GlyphsSet.Storage.begin(); - const ImU32* it_end = src_tmp.GlyphsSet.Storage.end(); - for (const ImU32* it = it_begin; it < it_end; it++) - if (ImU32 entries_32 = *it) - for (ImU32 bit_n = 0; bit_n < 32; bit_n++) - if (entries_32 & ((ImU32)1 << bit_n)) - { - ImFontBuildSrcGlyphFT src_glyph; - src_glyph.Codepoint = (ImWchar)(((it - it_begin) << 5) + bit_n); - //src_glyph.GlyphIndex = 0; // FIXME-OPT: We had this info in the previous step and lost it.. - src_tmp.GlyphsList.push_back(src_glyph); - } - src_tmp.GlyphsSet.Clear(); - IM_ASSERT(src_tmp.GlyphsList.Size == src_tmp.GlyphsCount); - } - for (int dst_i = 0; dst_i < dst_tmp_array.Size; dst_i++) - dst_tmp_array[dst_i].GlyphsSet.Clear(); - dst_tmp_array.clear(); - - // Allocate packing character data and flag packed characters buffer as non-packed (x0=y0=x1=y1=0) - // (We technically don't need to zero-clear buf_rects, but let's do it for the sake of sanity) - ImVector buf_rects; - buf_rects.resize(total_glyphs_count); - memset(buf_rects.Data, 0, (size_t)buf_rects.size_in_bytes()); - - // Allocate temporary rasterization data buffers. - // We could not find a way to retrieve accurate glyph size without rendering them. - // (e.g. slot->metrics->width not always matching bitmap->width, especially considering the Oblique transform) - // We allocate in chunks of 256 KB to not waste too much extra memory ahead. Hopefully users of FreeType won't find the temporary allocations. - const int BITMAP_BUFFERS_CHUNK_SIZE = 256 * 1024; - int buf_bitmap_current_used_bytes = 0; - ImVector buf_bitmap_buffers; - buf_bitmap_buffers.push_back((unsigned char*)IM_ALLOC(BITMAP_BUFFERS_CHUNK_SIZE)); - - // 4. Gather glyphs sizes so we can pack them in our virtual canvas. - // 8. Render/rasterize font characters into the texture - int total_surface = 0; - int buf_rects_out_n = 0; - for (int src_i = 0; src_i < src_tmp_array.Size; src_i++) - { - ImFontBuildSrcDataFT& src_tmp = src_tmp_array[src_i]; - ImFontConfig& cfg = atlas->ConfigData[src_i]; - if (src_tmp.GlyphsCount == 0) - continue; - - src_tmp.Rects = &buf_rects[buf_rects_out_n]; - buf_rects_out_n += src_tmp.GlyphsCount; - - // Compute multiply table if requested - const bool multiply_enabled = (cfg.RasterizerMultiply != 1.0f); - unsigned char multiply_table[256]; - if (multiply_enabled) - ImFontAtlasBuildMultiplyCalcLookupTable(multiply_table, cfg.RasterizerMultiply); - - // Gather the sizes of all rectangles we will need to pack - const int padding = atlas->TexGlyphPadding; - for (int glyph_i = 0; glyph_i < src_tmp.GlyphsList.Size; glyph_i++) - { - ImFontBuildSrcGlyphFT& src_glyph = src_tmp.GlyphsList[glyph_i]; - - const FT_Glyph_Metrics* metrics = src_tmp.Font.LoadGlyph(src_glyph.Codepoint); - if (metrics == NULL) - continue; - - // Render glyph into a bitmap (currently held by FreeType) - const FT_Bitmap* ft_bitmap = src_tmp.Font.RenderGlyphAndGetInfo(&src_glyph.Info); - if (ft_bitmap == NULL) - continue; - - // Allocate new temporary chunk if needed - const int bitmap_size_in_bytes = src_glyph.Info.Width * src_glyph.Info.Height * 4; - if (buf_bitmap_current_used_bytes + bitmap_size_in_bytes > BITMAP_BUFFERS_CHUNK_SIZE) - { - buf_bitmap_current_used_bytes = 0; - buf_bitmap_buffers.push_back((unsigned char*)IM_ALLOC(BITMAP_BUFFERS_CHUNK_SIZE)); - } - - // Blit rasterized pixels to our temporary buffer and keep a pointer to it. - src_glyph.BitmapData = (unsigned int*)(buf_bitmap_buffers.back() + buf_bitmap_current_used_bytes); - buf_bitmap_current_used_bytes += bitmap_size_in_bytes; - src_tmp.Font.BlitGlyph(ft_bitmap, src_glyph.BitmapData, src_glyph.Info.Width, multiply_enabled ? multiply_table : NULL); - - src_tmp.Rects[glyph_i].w = (stbrp_coord)(src_glyph.Info.Width + padding); - src_tmp.Rects[glyph_i].h = (stbrp_coord)(src_glyph.Info.Height + padding); - total_surface += src_tmp.Rects[glyph_i].w * src_tmp.Rects[glyph_i].h; - } - } - - // We need a width for the skyline algorithm, any width! - // The exact width doesn't really matter much, but some API/GPU have texture size limitations and increasing width can decrease height. - // User can override TexDesiredWidth and TexGlyphPadding if they wish, otherwise we use a simple heuristic to select the width based on expected surface. - const int surface_sqrt = (int)ImSqrt((float)total_surface) + 1; - atlas->TexHeight = 0; - if (atlas->TexDesiredWidth > 0) - atlas->TexWidth = atlas->TexDesiredWidth; - else - atlas->TexWidth = (surface_sqrt >= 4096 * 0.7f) ? 4096 : (surface_sqrt >= 2048 * 0.7f) ? 2048 : (surface_sqrt >= 1024 * 0.7f) ? 1024 : 512; - - // 5. Start packing - // Pack our extra data rectangles first, so it will be on the upper-left corner of our texture (UV will have small values). - const int TEX_HEIGHT_MAX = 1024 * 32; - const int num_nodes_for_packing_algorithm = atlas->TexWidth - atlas->TexGlyphPadding; - ImVector pack_nodes; - pack_nodes.resize(num_nodes_for_packing_algorithm); - stbrp_context pack_context; - stbrp_init_target(&pack_context, atlas->TexWidth, TEX_HEIGHT_MAX, pack_nodes.Data, pack_nodes.Size); - ImFontAtlasBuildPackCustomRects(atlas, &pack_context); - - // 6. Pack each source font. No rendering yet, we are working with rectangles in an infinitely tall texture at this point. - for (int src_i = 0; src_i < src_tmp_array.Size; src_i++) - { - ImFontBuildSrcDataFT& src_tmp = src_tmp_array[src_i]; - if (src_tmp.GlyphsCount == 0) - continue; - - stbrp_pack_rects(&pack_context, src_tmp.Rects, src_tmp.GlyphsCount); - - // Extend texture height and mark missing glyphs as non-packed so we won't render them. - // FIXME: We are not handling packing failure here (would happen if we got off TEX_HEIGHT_MAX or if a single if larger than TexWidth?) - for (int glyph_i = 0; glyph_i < src_tmp.GlyphsCount; glyph_i++) - if (src_tmp.Rects[glyph_i].was_packed) - atlas->TexHeight = ImMax(atlas->TexHeight, src_tmp.Rects[glyph_i].y + src_tmp.Rects[glyph_i].h); - } - - // 7. Allocate texture - atlas->TexHeight = (atlas->Flags & ImFontAtlasFlags_NoPowerOfTwoHeight) ? (atlas->TexHeight + 1) : ImUpperPowerOfTwo(atlas->TexHeight); - atlas->TexUvScale = ImVec2(1.0f / atlas->TexWidth, 1.0f / atlas->TexHeight); - if (src_load_color) - { - size_t tex_size = (size_t)atlas->TexWidth * atlas->TexHeight * 4; - atlas->TexPixelsRGBA32 = (unsigned int*)IM_ALLOC(tex_size); - memset(atlas->TexPixelsRGBA32, 0, tex_size); - } - else - { - size_t tex_size = (size_t)atlas->TexWidth * atlas->TexHeight * 1; - atlas->TexPixelsAlpha8 = (unsigned char*)IM_ALLOC(tex_size); - memset(atlas->TexPixelsAlpha8, 0, tex_size); - } - - // 8. Copy rasterized font characters back into the main texture - // 9. Setup ImFont and glyphs for runtime - bool tex_use_colors = false; - for (int src_i = 0; src_i < src_tmp_array.Size; src_i++) - { - ImFontBuildSrcDataFT& src_tmp = src_tmp_array[src_i]; - if (src_tmp.GlyphsCount == 0) - continue; - - // When merging fonts with MergeMode=true: - // - We can have multiple input fonts writing into a same destination font. - // - dst_font->ConfigData is != from cfg which is our source configuration. - ImFontConfig& cfg = atlas->ConfigData[src_i]; - ImFont* dst_font = cfg.DstFont; - - const float ascent = src_tmp.Font.Info.Ascender; - const float descent = src_tmp.Font.Info.Descender; - ImFontAtlasBuildSetupFont(atlas, dst_font, &cfg, ascent, descent); - const float font_off_x = cfg.GlyphOffset.x; - const float font_off_y = cfg.GlyphOffset.y + IM_ROUND(dst_font->Ascent); - - const int padding = atlas->TexGlyphPadding; - for (int glyph_i = 0; glyph_i < src_tmp.GlyphsCount; glyph_i++) - { - ImFontBuildSrcGlyphFT& src_glyph = src_tmp.GlyphsList[glyph_i]; - stbrp_rect& pack_rect = src_tmp.Rects[glyph_i]; - IM_ASSERT(pack_rect.was_packed); - if (pack_rect.w == 0 && pack_rect.h == 0) - continue; - - GlyphInfo& info = src_glyph.Info; - IM_ASSERT(info.Width + padding <= pack_rect.w); - IM_ASSERT(info.Height + padding <= pack_rect.h); - const int tx = pack_rect.x + padding; - const int ty = pack_rect.y + padding; - - // Register glyph - float x0 = info.OffsetX + font_off_x; - float y0 = info.OffsetY + font_off_y; - float x1 = x0 + info.Width; - float y1 = y0 + info.Height; - float u0 = (tx) / (float)atlas->TexWidth; - float v0 = (ty) / (float)atlas->TexHeight; - float u1 = (tx + info.Width) / (float)atlas->TexWidth; - float v1 = (ty + info.Height) / (float)atlas->TexHeight; - dst_font->AddGlyph(&cfg, (ImWchar)src_glyph.Codepoint, x0, y0, x1, y1, u0, v0, u1, v1, info.AdvanceX); - - ImFontGlyph* dst_glyph = &dst_font->Glyphs.back(); - IM_ASSERT(dst_glyph->Codepoint == src_glyph.Codepoint); - if (src_glyph.Info.IsColored) - dst_glyph->Colored = tex_use_colors = true; - - // Blit from temporary buffer to final texture - size_t blit_src_stride = (size_t)src_glyph.Info.Width; - size_t blit_dst_stride = (size_t)atlas->TexWidth; - unsigned int* blit_src = src_glyph.BitmapData; - if (atlas->TexPixelsAlpha8 != NULL) - { - unsigned char* blit_dst = atlas->TexPixelsAlpha8 + (ty * blit_dst_stride) + tx; - for (int y = 0; y < info.Height; y++, blit_dst += blit_dst_stride, blit_src += blit_src_stride) - for (int x = 0; x < info.Width; x++) - blit_dst[x] = (unsigned char)((blit_src[x] >> IM_COL32_A_SHIFT) & 0xFF); - } - else - { - unsigned int* blit_dst = atlas->TexPixelsRGBA32 + (ty * blit_dst_stride) + tx; - for (int y = 0; y < info.Height; y++, blit_dst += blit_dst_stride, blit_src += blit_src_stride) - for (int x = 0; x < info.Width; x++) - blit_dst[x] = blit_src[x]; - } - } - - src_tmp.Rects = NULL; - } - atlas->TexPixelsUseColors = tex_use_colors; - - // Cleanup - for (int buf_i = 0; buf_i < buf_bitmap_buffers.Size; buf_i++) - IM_FREE(buf_bitmap_buffers[buf_i]); - src_tmp_array.clear_destruct(); - - ImFontAtlasBuildFinish(atlas); - - return true; -} - -// FreeType memory allocation callbacks -static void* FreeType_Alloc(FT_Memory /*memory*/, long size) -{ - return GImGuiFreeTypeAllocFunc((size_t)size, GImGuiFreeTypeAllocatorUserData); -} - -static void FreeType_Free(FT_Memory /*memory*/, void* block) -{ - GImGuiFreeTypeFreeFunc(block, GImGuiFreeTypeAllocatorUserData); -} - -static void* FreeType_Realloc(FT_Memory /*memory*/, long cur_size, long new_size, void* block) -{ - // Implement realloc() as we don't ask user to provide it. - if (block == NULL) - return GImGuiFreeTypeAllocFunc((size_t)new_size, GImGuiFreeTypeAllocatorUserData); - - if (new_size == 0) - { - GImGuiFreeTypeFreeFunc(block, GImGuiFreeTypeAllocatorUserData); - return NULL; - } - - if (new_size > cur_size) - { - void* new_block = GImGuiFreeTypeAllocFunc((size_t)new_size, GImGuiFreeTypeAllocatorUserData); - memcpy(new_block, block, (size_t)cur_size); - GImGuiFreeTypeFreeFunc(block, GImGuiFreeTypeAllocatorUserData); - return new_block; - } - - return block; -} - -static bool ImFontAtlasBuildWithFreeType(ImFontAtlas* atlas) -{ - // FreeType memory management: https://www.freetype.org/freetype2/docs/design/design-4.html - FT_MemoryRec_ memory_rec = {}; - memory_rec.user = NULL; - memory_rec.alloc = &FreeType_Alloc; - memory_rec.free = &FreeType_Free; - memory_rec.realloc = &FreeType_Realloc; - - // https://www.freetype.org/freetype2/docs/reference/ft2-module_management.html#FT_New_Library - FT_Library ft_library; - FT_Error error = FT_New_Library(&memory_rec, &ft_library); - if (error != 0) - return false; - - // If you don't call FT_Add_Default_Modules() the rest of code may work, but FreeType won't use our custom allocator. - FT_Add_Default_Modules(ft_library); - - bool ret = ImFontAtlasBuildWithFreeTypeEx(ft_library, atlas, atlas->FontBuilderFlags); - FT_Done_Library(ft_library); - - return ret; -} - -const ImFontBuilderIO* ImGuiFreeType::GetBuilderForFreeType() -{ - static ImFontBuilderIO io; - io.FontBuilder_Build = ImFontAtlasBuildWithFreeType; - return &io; -} - -void ImGuiFreeType::SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void (*free_func)(void* ptr, void* user_data), void* user_data) -{ - GImGuiFreeTypeAllocFunc = alloc_func; - GImGuiFreeTypeFreeFunc = free_func; - GImGuiFreeTypeAllocatorUserData = user_data; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/freetype/imgui_freetype.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/freetype/imgui_freetype.h deleted file mode 100644 index 713e463..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/freetype/imgui_freetype.h +++ /dev/null @@ -1,50 +0,0 @@ -// dear imgui: FreeType font builder (used as a replacement for the stb_truetype builder) -// (headers) - -#pragma once - -#include "imgui.h" // IMGUI_API - -// Forward declarations -struct ImFontAtlas; -struct ImFontBuilderIO; - -// Hinting greatly impacts visuals (and glyph sizes). -// - By default, hinting is enabled and the font's native hinter is preferred over the auto-hinter. -// - When disabled, FreeType generates blurrier glyphs, more or less matches the stb_truetype.h -// - The Default hinting mode usually looks good, but may distort glyphs in an unusual way. -// - The Light hinting mode generates fuzzier glyphs but better matches Microsoft's rasterizer. -// You can set those flags globaly in ImFontAtlas::FontBuilderFlags -// You can set those flags on a per font basis in ImFontConfig::FontBuilderFlags -enum ImGuiFreeTypeBuilderFlags -{ - ImGuiFreeTypeBuilderFlags_NoHinting = 1 << 0, // Disable hinting. This generally generates 'blurrier' bitmap glyphs when the glyph are rendered in any of the anti-aliased modes. - ImGuiFreeTypeBuilderFlags_NoAutoHint = 1 << 1, // Disable auto-hinter. - ImGuiFreeTypeBuilderFlags_ForceAutoHint = 1 << 2, // Indicates that the auto-hinter is preferred over the font's native hinter. - ImGuiFreeTypeBuilderFlags_LightHinting = 1 << 3, // A lighter hinting algorithm for gray-level modes. Many generated glyphs are fuzzier but better resemble their original shape. This is achieved by snapping glyphs to the pixel grid only vertically (Y-axis), as is done by Microsoft's ClearType and Adobe's proprietary font renderer. This preserves inter-glyph spacing in horizontal text. - ImGuiFreeTypeBuilderFlags_MonoHinting = 1 << 4, // Strong hinting algorithm that should only be used for monochrome output. - ImGuiFreeTypeBuilderFlags_Bold = 1 << 5, // Styling: Should we artificially embolden the font? - ImGuiFreeTypeBuilderFlags_Oblique = 1 << 6, // Styling: Should we slant the font, emulating italic style? - ImGuiFreeTypeBuilderFlags_Monochrome = 1 << 7, // Disable anti-aliasing. Combine this with MonoHinting for best results! - ImGuiFreeTypeBuilderFlags_LoadColor = 1 << 8, // Enable FreeType color-layered glyphs - ImGuiFreeTypeBuilderFlags_Bitmap = 1 << 9 // Enable FreeType bitmap glyphs -}; - -namespace ImGuiFreeType -{ - // This is automatically assigned when using '#define IMGUI_ENABLE_FREETYPE'. - // If you need to dynamically select between multiple builders: - // - you can manually assign this builder with 'atlas->FontBuilderIO = ImGuiFreeType::GetBuilderForFreeType()' - // - prefer deep-copying this into your own ImFontBuilderIO instance if you use hot-reloading that messes up static data. - IMGUI_API const ImFontBuilderIO* GetBuilderForFreeType(); - - // Override allocators. By default ImGuiFreeType will use IM_ALLOC()/IM_FREE() - // However, as FreeType does lots of allocations we provide a way for the user to redirect it to a separate memory heap if desired. - IMGUI_API void SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void (*free_func)(void* ptr, void* user_data), void* user_data = NULL); - - // Obsolete names (will be removed soon) - // Prefer using '#define IMGUI_ENABLE_FREETYPE' -#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS - static inline bool BuildFontAtlas(ImFontAtlas* atlas, unsigned int flags = 0) { atlas->FontBuilderIO = GetBuilderForFreeType(); atlas->FontBuilderFlags = flags; return atlas->Build(); } -#endif -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/single_file/imgui_single_file.h b/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/single_file/imgui_single_file.h deleted file mode 100644 index 6c1fb36..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/imgui/misc/single_file/imgui_single_file.h +++ /dev/null @@ -1,18 +0,0 @@ -// dear imgui: single-file wrapper include -// We use this to validate compiling all *.cpp files in a same compilation unit. -// Users of that technique (also called "Unity builds") can generally provide this themselves, -// so we don't really recommend you use this in your projects. - -// Do this: -// #define IMGUI_IMPLEMENTATION -// Before you include this file in *one* C++ file to create the implementation. -// Using this in your project will leak the contents of imgui_internal.h and ImVec2 operators in this compilation unit. -#include "../../imgui.h" - -#ifdef IMGUI_IMPLEMENTATION -#include "../../imgui.cpp" -#include "../../imgui_demo.cpp" -#include "../../imgui_draw.cpp" -#include "../../imgui_tables.cpp" -#include "../../imgui_widgets.cpp" -#endif diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/CMakeLists.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/CMakeLists.txt deleted file mode 100644 index ca7b6c1..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/CMakeLists.txt +++ /dev/null @@ -1,234 +0,0 @@ -#cmake_minimum_required(VERSION 2.4.4) -cmake_minimum_required(VERSION 3.12) -set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON) - -project(zlib C) - -set(VERSION "1.2.12") - -option(ASM686 "Enable building i686 assembly implementation") -option(AMD64 "Enable building amd64 assembly implementation") - -set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") -set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") -set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers") -set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages") -set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files") - -include(CheckTypeSize) -include(CheckFunctionExists) -include(CheckIncludeFile) -include(CheckCSourceCompiles) -enable_testing() - -check_include_file(sys/types.h HAVE_SYS_TYPES_H) -check_include_file(stdint.h HAVE_STDINT_H) -check_include_file(stddef.h HAVE_STDDEF_H) - -# -# Check to see if we have large file support -# -set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1) -# We add these other definitions here because CheckTypeSize.cmake -# in CMake 2.4.x does not automatically do so and we want -# compatibility with CMake 2.4.x. -if(HAVE_SYS_TYPES_H) - list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H) -endif() -if(HAVE_STDINT_H) - list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H) -endif() -if(HAVE_STDDEF_H) - list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H) -endif() -check_type_size(off64_t OFF64_T) -if(HAVE_OFF64_T) - add_definitions(-D_LARGEFILE64_SOURCE=1) -endif() -set(CMAKE_REQUIRED_DEFINITIONS) # clear variable - -# -# Check for fseeko -# -check_function_exists(fseeko HAVE_FSEEKO) -if(NOT HAVE_FSEEKO) - add_definitions(-DNO_FSEEKO) -endif() - -# -# Check for unistd.h -# -check_include_file(unistd.h Z_HAVE_UNISTD_H) - -if(MSVC) - set(CMAKE_DEBUG_POSTFIX "d") - add_definitions(-D_CRT_SECURE_NO_DEPRECATE) - add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) - include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -endif() - -if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR) - # If we're doing an out of source build and the user has a zconf.h - # in their source tree... - if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h) - message(STATUS "Renaming") - message(STATUS " ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h") - message(STATUS "to 'zconf.h.included' because this file is included with zlib") - message(STATUS "but CMake generates it automatically in the build directory.") - file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.included) - endif() -endif() - -set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib.pc) -configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein - ${ZLIB_PC} @ONLY) -configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein - ${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY) -include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}) - - -#============================================================================ -# zlib -#============================================================================ - -set(ZLIB_PUBLIC_HDRS - ${CMAKE_CURRENT_BINARY_DIR}/zconf.h - zlib.h -) -set(ZLIB_PRIVATE_HDRS - crc32.h - deflate.h - gzguts.h - inffast.h - inffixed.h - inflate.h - inftrees.h - trees.h - zutil.h -) -set(ZLIB_SRCS - adler32.c - compress.c - crc32.c - deflate.c - gzclose.c - gzlib.c - gzread.c - gzwrite.c - inflate.c - infback.c - inftrees.c - inffast.c - trees.c - uncompr.c - zutil.c -) - -if(NOT MINGW) - set(ZLIB_DLL_SRCS - win32/zlib1.rc # If present will override custom build rule below. - ) -endif() - -if(CMAKE_COMPILER_IS_GNUCC) - if(ASM686) - set(ZLIB_ASMS contrib/asm686/match.S) - elseif (AMD64) - set(ZLIB_ASMS contrib/amd64/amd64-match.S) - endif () - - if(ZLIB_ASMS) - add_definitions(-DASMV) - set_source_files_properties(${ZLIB_ASMS} PROPERTIES LANGUAGE C COMPILE_FLAGS -DNO_UNDERLINE) - endif() -endif() - -if(MSVC) - if(ASM686) - ENABLE_LANGUAGE(ASM_MASM) - set(ZLIB_ASMS - contrib/masmx86/inffas32.asm - contrib/masmx86/match686.asm - ) - elseif (AMD64) - ENABLE_LANGUAGE(ASM_MASM) - set(ZLIB_ASMS - contrib/masmx64/gvmat64.asm - contrib/masmx64/inffasx64.asm - ) - endif() - - if(ZLIB_ASMS) - add_definitions(-DASMV -DASMINF) - endif() -endif() - -# parse the full version number from zlib.h and include in ZLIB_FULL_VERSION -file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents) -string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*" - "\\1" ZLIB_FULL_VERSION ${_zlib_h_contents}) - -if(MINGW) - # This gets us DLL resource information when compiling on MinGW. - if(NOT CMAKE_RC_COMPILER) - set(CMAKE_RC_COMPILER windres.exe) - endif() - - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj - COMMAND ${CMAKE_RC_COMPILER} - -D GCC_WINDRES - -I ${CMAKE_CURRENT_SOURCE_DIR} - -I ${CMAKE_CURRENT_BINARY_DIR} - -o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj - -i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc) - set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) -endif(MINGW) - -#add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) -add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) - - -#set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) -#set_target_properties(zlib PROPERTIES SOVERSION 1) - -if(NOT CYGWIN) - # This property causes shared libraries on Linux to have the full version - # encoded into their final filename. We disable this on Cygwin because - # it causes cygz-${ZLIB_FULL_VERSION}.dll to be created when cygz.dll - # seems to be the default. - # - # This has no effect with MSVC, on that platform the version info for - # the DLL comes from the resource file win32/zlib1.rc - #set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION}) -endif() - -if(UNIX) - # On unix-like platforms the library is almost always called libz - set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z) - if(NOT APPLE) - set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"") - endif() -endif() - - -#============================================================================ -# Example binaries -#============================================================================ - -#add_executable(example test/example.c) -#target_link_libraries(example zlib) -#add_test(example example) - -#add_executable(minigzip test/minigzip.c) -#target_link_libraries(minigzip zlib) - -# if(HAVE_OFF64_T) -# add_executable(example64 test/example.c) -# target_link_libraries(example64 zlib) -# set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") -# add_test(example64 example64) - -# add_executable(minigzip64 test/minigzip.c) -# target_link_libraries(minigzip64 zlib) -# set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") -# endif() diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/ChangeLog b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/ChangeLog deleted file mode 100644 index f0b0e61..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/ChangeLog +++ /dev/null @@ -1,1578 +0,0 @@ - - ChangeLog file for zlib - -Changes in 1.2.12 (27 Mar 2022) -- Cygwin does not have _wopen(), so do not create gzopen_w() there -- Permit a deflateParams() parameter change as soon as possible -- Limit hash table inserts after switch from stored deflate -- Fix bug when window full in deflate_stored() -- Fix CLEAR_HASH macro to be usable as a single statement -- Avoid a conversion error in gzseek when off_t type too small -- Have Makefile return non-zero error code on test failure -- Avoid some conversion warnings in gzread.c and gzwrite.c -- Update use of errno for newer Windows CE versions -- Small speedup to inflate [psumbera] -- Return an error if the gzputs string length can't fit in an int -- Add address checking in clang to -w option of configure -- Don't compute check value for raw inflate if asked to validate -- Handle case where inflateSync used when header never processed -- Avoid the use of ptrdiff_t -- Avoid an undefined behavior of memcpy() in gzappend() -- Avoid undefined behaviors of memcpy() in gz*printf() -- Avoid an undefined behavior of memcpy() in _tr_stored_block() -- Make the names in functions declarations identical to definitions -- Remove old assembler code in which bugs have manifested -- Fix deflateEnd() to not report an error at start of raw deflate -- Add legal disclaimer to README -- Emphasize the need to continue decompressing gzip members -- Correct the initialization requirements for deflateInit2() -- Fix a bug that can crash deflate on some input when using Z_FIXED -- Assure that the number of bits for deflatePrime() is valid -- Use a structure to make globals in enough.c evident -- Use a macro for the printf format of big_t in enough.c -- Clean up code style in enough.c, update version -- Use inline function instead of macro for index in enough.c -- Clarify that prefix codes are counted in enough.c -- Show all the codes for the maximum tables size in enough.c -- Add gznorm.c example, which normalizes gzip files -- Fix the zran.c example to work on a multiple-member gzip file -- Add tables for crc32_combine(), to speed it up by a factor of 200 -- Add crc32_combine_gen() and crc32_combine_op() for fast combines -- Speed up software CRC-32 computation by a factor of 1.5 to 3 -- Use atomic test and set, if available, for dynamic CRC tables -- Don't bother computing check value after successful inflateSync() -- Correct comment in crc32.c -- Add use of the ARMv8 crc32 instructions when requested -- Use ARM crc32 instructions if the ARM architecture has them -- Explicitly note that the 32-bit check values are 32 bits -- Avoid adding empty gzip member after gzflush with Z_FINISH -- Fix memory leak on error in gzlog.c -- Fix error in comment on the polynomial representation of a byte -- Clarify gz* function interfaces, referring to parameter names -- Change macro name in inflate.c to avoid collision in VxWorks -- Correct typo in blast.c -- Improve portability of contrib/minizip -- Fix indentation in minizip's zip.c -- Replace black/white with allow/block. (theresa-m) -- minizip warning fix if MAXU32 already defined. (gvollant) -- Fix unztell64() in minizip to work past 4GB. (Daniël Hörchner) -- Clean up minizip to reduce warnings for testing -- Add fallthrough comments for gcc -- Eliminate use of ULL constants -- Separate out address sanitizing from warnings in configure -- Remove destructive aspects of make distclean -- Check for cc masquerading as gcc or clang in configure -- Fix crc32.c to compile local functions only if used - -Changes in 1.2.11 (15 Jan 2017) -- Fix deflate stored bug when pulling last block from window -- Permit immediate deflateParams changes before any deflate input - -Changes in 1.2.10 (2 Jan 2017) -- Avoid warnings on snprintf() return value -- Fix bug in deflate_stored() for zero-length input -- Fix bug in gzwrite.c that produced corrupt gzip files -- Remove files to be installed before copying them in Makefile.in -- Add warnings when compiling with assembler code - -Changes in 1.2.9 (31 Dec 2016) -- Fix contrib/minizip to permit unzipping with desktop API [Zouzou] -- Improve contrib/blast to return unused bytes -- Assure that gzoffset() is correct when appending -- Improve compress() and uncompress() to support large lengths -- Fix bug in test/example.c where error code not saved -- Remedy Coverity warning [Randers-Pehrson] -- Improve speed of gzprintf() in transparent mode -- Fix inflateInit2() bug when windowBits is 16 or 32 -- Change DEBUG macro to ZLIB_DEBUG -- Avoid uninitialized access by gzclose_w() -- Allow building zlib outside of the source directory -- Fix bug that accepted invalid zlib header when windowBits is zero -- Fix gzseek() problem on MinGW due to buggy _lseeki64 there -- Loop on write() calls in gzwrite.c in case of non-blocking I/O -- Add --warn (-w) option to ./configure for more compiler warnings -- Reject a window size of 256 bytes if not using the zlib wrapper -- Fix bug when level 0 used with Z_HUFFMAN or Z_RLE -- Add --debug (-d) option to ./configure to define ZLIB_DEBUG -- Fix bugs in creating a very large gzip header -- Add uncompress2() function, which returns the input size used -- Assure that deflateParams() will not switch functions mid-block -- Dramatically speed up deflation for level 0 (storing) -- Add gzfread(), duplicating the interface of fread() -- Add gzfwrite(), duplicating the interface of fwrite() -- Add deflateGetDictionary() function -- Use snprintf() for later versions of Microsoft C -- Fix *Init macros to use z_ prefix when requested -- Replace as400 with os400 for OS/400 support [Monnerat] -- Add crc32_z() and adler32_z() functions with size_t lengths -- Update Visual Studio project files [AraHaan] - -Changes in 1.2.8 (28 Apr 2013) -- Update contrib/minizip/iowin32.c for Windows RT [Vollant] -- Do not force Z_CONST for C++ -- Clean up contrib/vstudio [Roß] -- Correct spelling error in zlib.h -- Fix mixed line endings in contrib/vstudio - -Changes in 1.2.7.3 (13 Apr 2013) -- Fix version numbers and DLL names in contrib/vstudio/*/zlib.rc - -Changes in 1.2.7.2 (13 Apr 2013) -- Change check for a four-byte type back to hexadecimal -- Fix typo in win32/Makefile.msc -- Add casts in gzwrite.c for pointer differences - -Changes in 1.2.7.1 (24 Mar 2013) -- Replace use of unsafe string functions with snprintf if available -- Avoid including stddef.h on Windows for Z_SOLO compile [Niessink] -- Fix gzgetc undefine when Z_PREFIX set [Turk] -- Eliminate use of mktemp in Makefile (not always available) -- Fix bug in 'F' mode for gzopen() -- Add inflateGetDictionary() function -- Correct comment in deflate.h -- Use _snprintf for snprintf in Microsoft C -- On Darwin, only use /usr/bin/libtool if libtool is not Apple -- Delete "--version" file if created by "ar --version" [Richard G.] -- Fix configure check for veracity of compiler error return codes -- Fix CMake compilation of static lib for MSVC2010 x64 -- Remove unused variable in infback9.c -- Fix argument checks in gzlog_compress() and gzlog_write() -- Clean up the usage of z_const and respect const usage within zlib -- Clean up examples/gzlog.[ch] comparisons of different types -- Avoid shift equal to bits in type (caused endless loop) -- Fix uninitialized value bug in gzputc() introduced by const patches -- Fix memory allocation error in examples/zran.c [Nor] -- Fix bug where gzopen(), gzclose() would write an empty file -- Fix bug in gzclose() when gzwrite() runs out of memory -- Check for input buffer malloc failure in examples/gzappend.c -- Add note to contrib/blast to use binary mode in stdio -- Fix comparisons of differently signed integers in contrib/blast -- Check for invalid code length codes in contrib/puff -- Fix serious but very rare decompression bug in inftrees.c -- Update inflateBack() comments, since inflate() can be faster -- Use underscored I/O function names for WINAPI_FAMILY -- Add _tr_flush_bits to the external symbols prefixed by --zprefix -- Add contrib/vstudio/vc10 pre-build step for static only -- Quote --version-script argument in CMakeLists.txt -- Don't specify --version-script on Apple platforms in CMakeLists.txt -- Fix casting error in contrib/testzlib/testzlib.c -- Fix types in contrib/minizip to match result of get_crc_table() -- Simplify contrib/vstudio/vc10 with 'd' suffix -- Add TOP support to win32/Makefile.msc -- Suport i686 and amd64 assembler builds in CMakeLists.txt -- Fix typos in the use of _LARGEFILE64_SOURCE in zconf.h -- Add vc11 and vc12 build files to contrib/vstudio -- Add gzvprintf() as an undocumented function in zlib -- Fix configure for Sun shell -- Remove runtime check in configure for four-byte integer type -- Add casts and consts to ease user conversion to C++ -- Add man pages for minizip and miniunzip -- In Makefile uninstall, don't rm if preceding cd fails -- Do not return Z_BUF_ERROR if deflateParam() has nothing to write - -Changes in 1.2.7 (2 May 2012) -- Replace use of memmove() with a simple copy for portability -- Test for existence of strerror -- Restore gzgetc_ for backward compatibility with 1.2.6 -- Fix build with non-GNU make on Solaris -- Require gcc 4.0 or later on Mac OS X to use the hidden attribute -- Include unistd.h for Watcom C -- Use __WATCOMC__ instead of __WATCOM__ -- Do not use the visibility attribute if NO_VIZ defined -- Improve the detection of no hidden visibility attribute -- Avoid using __int64 for gcc or solo compilation -- Cast to char * in gzprintf to avoid warnings [Zinser] -- Fix make_vms.com for VAX [Zinser] -- Don't use library or built-in byte swaps -- Simplify test and use of gcc hidden attribute -- Fix bug in gzclose_w() when gzwrite() fails to allocate memory -- Add "x" (O_EXCL) and "e" (O_CLOEXEC) modes support to gzopen() -- Fix bug in test/minigzip.c for configure --solo -- Fix contrib/vstudio project link errors [Mohanathas] -- Add ability to choose the builder in make_vms.com [Schweda] -- Add DESTDIR support to mingw32 win32/Makefile.gcc -- Fix comments in win32/Makefile.gcc for proper usage -- Allow overriding the default install locations for cmake -- Generate and install the pkg-config file with cmake -- Build both a static and a shared version of zlib with cmake -- Include version symbols for cmake builds -- If using cmake with MSVC, add the source directory to the includes -- Remove unneeded EXTRA_CFLAGS from win32/Makefile.gcc [Truta] -- Move obsolete emx makefile to old [Truta] -- Allow the use of -Wundef when compiling or using zlib -- Avoid the use of the -u option with mktemp -- Improve inflate() documentation on the use of Z_FINISH -- Recognize clang as gcc -- Add gzopen_w() in Windows for wide character path names -- Rename zconf.h in CMakeLists.txt to move it out of the way -- Add source directory in CMakeLists.txt for building examples -- Look in build directory for zlib.pc in CMakeLists.txt -- Remove gzflags from zlibvc.def in vc9 and vc10 -- Fix contrib/minizip compilation in the MinGW environment -- Update ./configure for Solaris, support --64 [Mooney] -- Remove -R. from Solaris shared build (possible security issue) -- Avoid race condition for parallel make (-j) running example -- Fix type mismatch between get_crc_table() and crc_table -- Fix parsing of version with "-" in CMakeLists.txt [Snider, Ziegler] -- Fix the path to zlib.map in CMakeLists.txt -- Force the native libtool in Mac OS X to avoid GNU libtool [Beebe] -- Add instructions to win32/Makefile.gcc for shared install [Torri] - -Changes in 1.2.6.1 (12 Feb 2012) -- Avoid the use of the Objective-C reserved name "id" -- Include io.h in gzguts.h for Microsoft compilers -- Fix problem with ./configure --prefix and gzgetc macro -- Include gz_header definition when compiling zlib solo -- Put gzflags() functionality back in zutil.c -- Avoid library header include in crc32.c for Z_SOLO -- Use name in GCC_CLASSIC as C compiler for coverage testing, if set -- Minor cleanup in contrib/minizip/zip.c [Vollant] -- Update make_vms.com [Zinser] -- Remove unnecessary gzgetc_ function -- Use optimized byte swap operations for Microsoft and GNU [Snyder] -- Fix minor typo in zlib.h comments [Rzesniowiecki] - -Changes in 1.2.6 (29 Jan 2012) -- Update the Pascal interface in contrib/pascal -- Fix function numbers for gzgetc_ in zlibvc.def files -- Fix configure.ac for contrib/minizip [Schiffer] -- Fix large-entry detection in minizip on 64-bit systems [Schiffer] -- Have ./configure use the compiler return code for error indication -- Fix CMakeLists.txt for cross compilation [McClure] -- Fix contrib/minizip/zip.c for 64-bit architectures [Dalsnes] -- Fix compilation of contrib/minizip on FreeBSD [Marquez] -- Correct suggested usages in win32/Makefile.msc [Shachar, Horvath] -- Include io.h for Turbo C / Borland C on all platforms [Truta] -- Make version explicit in contrib/minizip/configure.ac [Bosmans] -- Avoid warning for no encryption in contrib/minizip/zip.c [Vollant] -- Minor cleanup up contrib/minizip/unzip.c [Vollant] -- Fix bug when compiling minizip with C++ [Vollant] -- Protect for long name and extra fields in contrib/minizip [Vollant] -- Avoid some warnings in contrib/minizip [Vollant] -- Add -I../.. -L../.. to CFLAGS for minizip and miniunzip -- Add missing libs to minizip linker command -- Add support for VPATH builds in contrib/minizip -- Add an --enable-demos option to contrib/minizip/configure -- Add the generation of configure.log by ./configure -- Exit when required parameters not provided to win32/Makefile.gcc -- Have gzputc return the character written instead of the argument -- Use the -m option on ldconfig for BSD systems [Tobias] -- Correct in zlib.map when deflateResetKeep was added - -Changes in 1.2.5.3 (15 Jan 2012) -- Restore gzgetc function for binary compatibility -- Do not use _lseeki64 under Borland C++ [Truta] -- Update win32/Makefile.msc to build test/*.c [Truta] -- Remove old/visualc6 given CMakefile and other alternatives -- Update AS400 build files and documentation [Monnerat] -- Update win32/Makefile.gcc to build test/*.c [Truta] -- Permit stronger flushes after Z_BLOCK flushes -- Avoid extraneous empty blocks when doing empty flushes -- Permit Z_NULL arguments to deflatePending -- Allow deflatePrime() to insert bits in the middle of a stream -- Remove second empty static block for Z_PARTIAL_FLUSH -- Write out all of the available bits when using Z_BLOCK -- Insert the first two strings in the hash table after a flush - -Changes in 1.2.5.2 (17 Dec 2011) -- fix ld error: unable to find version dependency 'ZLIB_1.2.5' -- use relative symlinks for shared libs -- Avoid searching past window for Z_RLE strategy -- Assure that high-water mark initialization is always applied in deflate -- Add assertions to fill_window() in deflate.c to match comments -- Update python link in README -- Correct spelling error in gzread.c -- Fix bug in gzgets() for a concatenated empty gzip stream -- Correct error in comment for gz_make() -- Change gzread() and related to ignore junk after gzip streams -- Allow gzread() and related to continue after gzclearerr() -- Allow gzrewind() and gzseek() after a premature end-of-file -- Simplify gzseek() now that raw after gzip is ignored -- Change gzgetc() to a macro for speed (~40% speedup in testing) -- Fix gzclose() to return the actual error last encountered -- Always add large file support for windows -- Include zconf.h for windows large file support -- Include zconf.h.cmakein for windows large file support -- Update zconf.h.cmakein on make distclean -- Merge vestigial vsnprintf determination from zutil.h to gzguts.h -- Clarify how gzopen() appends in zlib.h comments -- Correct documentation of gzdirect() since junk at end now ignored -- Add a transparent write mode to gzopen() when 'T' is in the mode -- Update python link in zlib man page -- Get inffixed.h and MAKEFIXED result to match -- Add a ./config --solo option to make zlib subset with no library use -- Add undocumented inflateResetKeep() function for CAB file decoding -- Add --cover option to ./configure for gcc coverage testing -- Add #define ZLIB_CONST option to use const in the z_stream interface -- Add comment to gzdopen() in zlib.h to use dup() when using fileno() -- Note behavior of uncompress() to provide as much data as it can -- Add files in contrib/minizip to aid in building libminizip -- Split off AR options in Makefile.in and configure -- Change ON macro to Z_ARG to avoid application conflicts -- Facilitate compilation with Borland C++ for pragmas and vsnprintf -- Include io.h for Turbo C / Borland C++ -- Move example.c and minigzip.c to test/ -- Simplify incomplete code table filling in inflate_table() -- Remove code from inflate.c and infback.c that is impossible to execute -- Test the inflate code with full coverage -- Allow deflateSetDictionary, inflateSetDictionary at any time (in raw) -- Add deflateResetKeep and fix inflateResetKeep to retain dictionary -- Fix gzwrite.c to accommodate reduced memory zlib compilation -- Have inflate() with Z_FINISH avoid the allocation of a window -- Do not set strm->adler when doing raw inflate -- Fix gzeof() to behave just like feof() when read is not past end of file -- Fix bug in gzread.c when end-of-file is reached -- Avoid use of Z_BUF_ERROR in gz* functions except for premature EOF -- Document gzread() capability to read concurrently written files -- Remove hard-coding of resource compiler in CMakeLists.txt [Blammo] - -Changes in 1.2.5.1 (10 Sep 2011) -- Update FAQ entry on shared builds (#13) -- Avoid symbolic argument to chmod in Makefile.in -- Fix bug and add consts in contrib/puff [Oberhumer] -- Update contrib/puff/zeros.raw test file to have all block types -- Add full coverage test for puff in contrib/puff/Makefile -- Fix static-only-build install in Makefile.in -- Fix bug in unzGetCurrentFileInfo() in contrib/minizip [Kuno] -- Add libz.a dependency to shared in Makefile.in for parallel builds -- Spell out "number" (instead of "nb") in zlib.h for total_in, total_out -- Replace $(...) with `...` in configure for non-bash sh [Bowler] -- Add darwin* to Darwin* and solaris* to SunOS\ 5* in configure [Groffen] -- Add solaris* to Linux* in configure to allow gcc use [Groffen] -- Add *bsd* to Linux* case in configure [Bar-Lev] -- Add inffast.obj to dependencies in win32/Makefile.msc -- Correct spelling error in deflate.h [Kohler] -- Change libzdll.a again to libz.dll.a (!) in win32/Makefile.gcc -- Add test to configure for GNU C looking for gcc in output of $cc -v -- Add zlib.pc generation to win32/Makefile.gcc [Weigelt] -- Fix bug in zlib.h for _FILE_OFFSET_BITS set and _LARGEFILE64_SOURCE not -- Add comment in zlib.h that adler32_combine with len2 < 0 makes no sense -- Make NO_DIVIDE option in adler32.c much faster (thanks to John Reiser) -- Make stronger test in zconf.h to include unistd.h for LFS -- Apply Darwin patches for 64-bit file offsets to contrib/minizip [Slack] -- Fix zlib.h LFS support when Z_PREFIX used -- Add updated as400 support (removed from old) [Monnerat] -- Avoid deflate sensitivity to volatile input data -- Avoid division in adler32_combine for NO_DIVIDE -- Clarify the use of Z_FINISH with deflateBound() amount of space -- Set binary for output file in puff.c -- Use u4 type for crc_table to avoid conversion warnings -- Apply casts in zlib.h to avoid conversion warnings -- Add OF to prototypes for adler32_combine_ and crc32_combine_ [Miller] -- Improve inflateSync() documentation to note indeterminancy -- Add deflatePending() function to return the amount of pending output -- Correct the spelling of "specification" in FAQ [Randers-Pehrson] -- Add a check in configure for stdarg.h, use for gzprintf() -- Check that pointers fit in ints when gzprint() compiled old style -- Add dummy name before $(SHAREDLIBV) in Makefile [Bar-Lev, Bowler] -- Delete line in configure that adds -L. libz.a to LDFLAGS [Weigelt] -- Add debug records in assmebler code [Londer] -- Update RFC references to use http://tools.ietf.org/html/... [Li] -- Add --archs option, use of libtool to configure for Mac OS X [Borstel] - -Changes in 1.2.5 (19 Apr 2010) -- Disable visibility attribute in win32/Makefile.gcc [Bar-Lev] -- Default to libdir as sharedlibdir in configure [Nieder] -- Update copyright dates on modified source files -- Update trees.c to be able to generate modified trees.h -- Exit configure for MinGW, suggesting win32/Makefile.gcc -- Check for NULL path in gz_open [Homurlu] - -Changes in 1.2.4.5 (18 Apr 2010) -- Set sharedlibdir in configure [Torok] -- Set LDFLAGS in Makefile.in [Bar-Lev] -- Avoid mkdir objs race condition in Makefile.in [Bowler] -- Add ZLIB_INTERNAL in front of internal inter-module functions and arrays -- Define ZLIB_INTERNAL to hide internal functions and arrays for GNU C -- Don't use hidden attribute when it is a warning generator (e.g. Solaris) - -Changes in 1.2.4.4 (18 Apr 2010) -- Fix CROSS_PREFIX executable testing, CHOST extract, mingw* [Torok] -- Undefine _LARGEFILE64_SOURCE in zconf.h if it is zero, but not if empty -- Try to use bash or ksh regardless of functionality of /bin/sh -- Fix configure incompatibility with NetBSD sh -- Remove attempt to run under bash or ksh since have better NetBSD fix -- Fix win32/Makefile.gcc for MinGW [Bar-Lev] -- Add diagnostic messages when using CROSS_PREFIX in configure -- Added --sharedlibdir option to configure [Weigelt] -- Use hidden visibility attribute when available [Frysinger] - -Changes in 1.2.4.3 (10 Apr 2010) -- Only use CROSS_PREFIX in configure for ar and ranlib if they exist -- Use CROSS_PREFIX for nm [Bar-Lev] -- Assume _LARGEFILE64_SOURCE defined is equivalent to true -- Avoid use of undefined symbols in #if with && and || -- Make *64 prototypes in gzguts.h consistent with functions -- Add -shared load option for MinGW in configure [Bowler] -- Move z_off64_t to public interface, use instead of off64_t -- Remove ! from shell test in configure (not portable to Solaris) -- Change +0 macro tests to -0 for possibly increased portability - -Changes in 1.2.4.2 (9 Apr 2010) -- Add consistent carriage returns to readme.txt's in masmx86 and masmx64 -- Really provide prototypes for *64 functions when building without LFS -- Only define unlink() in minigzip.c if unistd.h not included -- Update README to point to contrib/vstudio project files -- Move projects/vc6 to old/ and remove projects/ -- Include stdlib.h in minigzip.c for setmode() definition under WinCE -- Clean up assembler builds in win32/Makefile.msc [Rowe] -- Include sys/types.h for Microsoft for off_t definition -- Fix memory leak on error in gz_open() -- Symbolize nm as $NM in configure [Weigelt] -- Use TEST_LDSHARED instead of LDSHARED to link test programs [Weigelt] -- Add +0 to _FILE_OFFSET_BITS and _LFS64_LARGEFILE in case not defined -- Fix bug in gzeof() to take into account unused input data -- Avoid initialization of structures with variables in puff.c -- Updated win32/README-WIN32.txt [Rowe] - -Changes in 1.2.4.1 (28 Mar 2010) -- Remove the use of [a-z] constructs for sed in configure [gentoo 310225] -- Remove $(SHAREDLIB) from LIBS in Makefile.in [Creech] -- Restore "for debugging" comment on sprintf() in gzlib.c -- Remove fdopen for MVS from gzguts.h -- Put new README-WIN32.txt in win32 [Rowe] -- Add check for shell to configure and invoke another shell if needed -- Fix big fat stinking bug in gzseek() on uncompressed files -- Remove vestigial F_OPEN64 define in zutil.h -- Set and check the value of _LARGEFILE_SOURCE and _LARGEFILE64_SOURCE -- Avoid errors on non-LFS systems when applications define LFS macros -- Set EXE to ".exe" in configure for MINGW [Kahle] -- Match crc32() in crc32.c exactly to the prototype in zlib.h [Sherrill] -- Add prefix for cross-compilation in win32/makefile.gcc [Bar-Lev] -- Add DLL install in win32/makefile.gcc [Bar-Lev] -- Allow Linux* or linux* from uname in configure [Bar-Lev] -- Allow ldconfig to be redefined in configure and Makefile.in [Bar-Lev] -- Add cross-compilation prefixes to configure [Bar-Lev] -- Match type exactly in gz_load() invocation in gzread.c -- Match type exactly of zcalloc() in zutil.c to zlib.h alloc_func -- Provide prototypes for *64 functions when building zlib without LFS -- Don't use -lc when linking shared library on MinGW -- Remove errno.h check in configure and vestigial errno code in zutil.h - -Changes in 1.2.4 (14 Mar 2010) -- Fix VER3 extraction in configure for no fourth subversion -- Update zlib.3, add docs to Makefile.in to make .pdf out of it -- Add zlib.3.pdf to distribution -- Don't set error code in gzerror() if passed pointer is NULL -- Apply destination directory fixes to CMakeLists.txt [Lowman] -- Move #cmakedefine's to a new zconf.in.cmakein -- Restore zconf.h for builds that don't use configure or cmake -- Add distclean to dummy Makefile for convenience -- Update and improve INDEX, README, and FAQ -- Update CMakeLists.txt for the return of zconf.h [Lowman] -- Update contrib/vstudio/vc9 and vc10 [Vollant] -- Change libz.dll.a back to libzdll.a in win32/Makefile.gcc -- Apply license and readme changes to contrib/asm686 [Raiter] -- Check file name lengths and add -c option in minigzip.c [Li] -- Update contrib/amd64 and contrib/masmx86/ [Vollant] -- Avoid use of "eof" parameter in trees.c to not shadow library variable -- Update make_vms.com for removal of zlibdefs.h [Zinser] -- Update assembler code and vstudio projects in contrib [Vollant] -- Remove outdated assembler code contrib/masm686 and contrib/asm586 -- Remove old vc7 and vc8 from contrib/vstudio -- Update win32/Makefile.msc, add ZLIB_VER_SUBREVISION [Rowe] -- Fix memory leaks in gzclose_r() and gzclose_w(), file leak in gz_open() -- Add contrib/gcc_gvmat64 for longest_match and inflate_fast [Vollant] -- Remove *64 functions from win32/zlib.def (they're not 64-bit yet) -- Fix bug in void-returning vsprintf() case in gzwrite.c -- Fix name change from inflate.h in contrib/inflate86/inffas86.c -- Check if temporary file exists before removing in make_vms.com [Zinser] -- Fix make install and uninstall for --static option -- Fix usage of _MSC_VER in gzguts.h and zutil.h [Truta] -- Update readme.txt in contrib/masmx64 and masmx86 to assemble - -Changes in 1.2.3.9 (21 Feb 2010) -- Expunge gzio.c -- Move as400 build information to old -- Fix updates in contrib/minizip and contrib/vstudio -- Add const to vsnprintf test in configure to avoid warnings [Weigelt] -- Delete zconf.h (made by configure) [Weigelt] -- Change zconf.in.h to zconf.h.in per convention [Weigelt] -- Check for NULL buf in gzgets() -- Return empty string for gzgets() with len == 1 (like fgets()) -- Fix description of gzgets() in zlib.h for end-of-file, NULL return -- Update minizip to 1.1 [Vollant] -- Avoid MSVC loss of data warnings in gzread.c, gzwrite.c -- Note in zlib.h that gzerror() should be used to distinguish from EOF -- Remove use of snprintf() from gzlib.c -- Fix bug in gzseek() -- Update contrib/vstudio, adding vc9 and vc10 [Kuno, Vollant] -- Fix zconf.h generation in CMakeLists.txt [Lowman] -- Improve comments in zconf.h where modified by configure - -Changes in 1.2.3.8 (13 Feb 2010) -- Clean up text files (tabs, trailing whitespace, etc.) [Oberhumer] -- Use z_off64_t in gz_zero() and gz_skip() to match state->skip -- Avoid comparison problem when sizeof(int) == sizeof(z_off64_t) -- Revert to Makefile.in from 1.2.3.6 (live with the clutter) -- Fix missing error return in gzflush(), add zlib.h note -- Add *64 functions to zlib.map [Levin] -- Fix signed/unsigned comparison in gz_comp() -- Use SFLAGS when testing shared linking in configure -- Add --64 option to ./configure to use -m64 with gcc -- Fix ./configure --help to correctly name options -- Have make fail if a test fails [Levin] -- Avoid buffer overrun in contrib/masmx64/gvmat64.asm [Simpson] -- Remove assembler object files from contrib - -Changes in 1.2.3.7 (24 Jan 2010) -- Always gzopen() with O_LARGEFILE if available -- Fix gzdirect() to work immediately after gzopen() or gzdopen() -- Make gzdirect() more precise when the state changes while reading -- Improve zlib.h documentation in many places -- Catch memory allocation failure in gz_open() -- Complete close operation if seek forward in gzclose_w() fails -- Return Z_ERRNO from gzclose_r() if close() fails -- Return Z_STREAM_ERROR instead of EOF for gzclose() being passed NULL -- Return zero for gzwrite() errors to match zlib.h description -- Return -1 on gzputs() error to match zlib.h description -- Add zconf.in.h to allow recovery from configure modification [Weigelt] -- Fix static library permissions in Makefile.in [Weigelt] -- Avoid warnings in configure tests that hide functionality [Weigelt] -- Add *BSD and DragonFly to Linux case in configure [gentoo 123571] -- Change libzdll.a to libz.dll.a in win32/Makefile.gcc [gentoo 288212] -- Avoid access of uninitialized data for first inflateReset2 call [Gomes] -- Keep object files in subdirectories to reduce the clutter somewhat -- Remove default Makefile and zlibdefs.h, add dummy Makefile -- Add new external functions to Z_PREFIX, remove duplicates, z_z_ -> z_ -- Remove zlibdefs.h completely -- modify zconf.h instead - -Changes in 1.2.3.6 (17 Jan 2010) -- Avoid void * arithmetic in gzread.c and gzwrite.c -- Make compilers happier with const char * for gz_error message -- Avoid unused parameter warning in inflate.c -- Avoid signed-unsigned comparison warning in inflate.c -- Indent #pragma's for traditional C -- Fix usage of strwinerror() in glib.c, change to gz_strwinerror() -- Correct email address in configure for system options -- Update make_vms.com and add make_vms.com to contrib/minizip [Zinser] -- Update zlib.map [Brown] -- Fix Makefile.in for Solaris 10 make of example64 and minizip64 [Torok] -- Apply various fixes to CMakeLists.txt [Lowman] -- Add checks on len in gzread() and gzwrite() -- Add error message for no more room for gzungetc() -- Remove zlib version check in gzwrite() -- Defer compression of gzprintf() result until need to -- Use snprintf() in gzdopen() if available -- Remove USE_MMAP configuration determination (only used by minigzip) -- Remove examples/pigz.c (available separately) -- Update examples/gun.c to 1.6 - -Changes in 1.2.3.5 (8 Jan 2010) -- Add space after #if in zutil.h for some compilers -- Fix relatively harmless bug in deflate_fast() [Exarevsky] -- Fix same problem in deflate_slow() -- Add $(SHAREDLIBV) to LIBS in Makefile.in [Brown] -- Add deflate_rle() for faster Z_RLE strategy run-length encoding -- Add deflate_huff() for faster Z_HUFFMAN_ONLY encoding -- Change name of "write" variable in inffast.c to avoid library collisions -- Fix premature EOF from gzread() in gzio.c [Brown] -- Use zlib header window size if windowBits is 0 in inflateInit2() -- Remove compressBound() call in deflate.c to avoid linking compress.o -- Replace use of errno in gz* with functions, support WinCE [Alves] -- Provide alternative to perror() in minigzip.c for WinCE [Alves] -- Don't use _vsnprintf on later versions of MSVC [Lowman] -- Add CMake build script and input file [Lowman] -- Update contrib/minizip to 1.1 [Svensson, Vollant] -- Moved nintendods directory from contrib to root -- Replace gzio.c with a new set of routines with the same functionality -- Add gzbuffer(), gzoffset(), gzclose_r(), gzclose_w() as part of above -- Update contrib/minizip to 1.1b -- Change gzeof() to return 0 on error instead of -1 to agree with zlib.h - -Changes in 1.2.3.4 (21 Dec 2009) -- Use old school .SUFFIXES in Makefile.in for FreeBSD compatibility -- Update comments in configure and Makefile.in for default --shared -- Fix test -z's in configure [Marquess] -- Build examplesh and minigzipsh when not testing -- Change NULL's to Z_NULL's in deflate.c and in comments in zlib.h -- Import LDFLAGS from the environment in configure -- Fix configure to populate SFLAGS with discovered CFLAGS options -- Adapt make_vms.com to the new Makefile.in [Zinser] -- Add zlib2ansi script for C++ compilation [Marquess] -- Add _FILE_OFFSET_BITS=64 test to make test (when applicable) -- Add AMD64 assembler code for longest match to contrib [Teterin] -- Include options from $SFLAGS when doing $LDSHARED -- Simplify 64-bit file support by introducing z_off64_t type -- Make shared object files in objs directory to work around old Sun cc -- Use only three-part version number for Darwin shared compiles -- Add rc option to ar in Makefile.in for when ./configure not run -- Add -WI,-rpath,. to LDFLAGS for OSF 1 V4* -- Set LD_LIBRARYN32_PATH for SGI IRIX shared compile -- Protect against _FILE_OFFSET_BITS being defined when compiling zlib -- Rename Makefile.in targets allstatic to static and allshared to shared -- Fix static and shared Makefile.in targets to be independent -- Correct error return bug in gz_open() by setting state [Brown] -- Put spaces before ;;'s in configure for better sh compatibility -- Add pigz.c (parallel implementation of gzip) to examples/ -- Correct constant in crc32.c to UL [Leventhal] -- Reject negative lengths in crc32_combine() -- Add inflateReset2() function to work like inflateEnd()/inflateInit2() -- Include sys/types.h for _LARGEFILE64_SOURCE [Brown] -- Correct typo in doc/algorithm.txt [Janik] -- Fix bug in adler32_combine() [Zhu] -- Catch missing-end-of-block-code error in all inflates and in puff - Assures that random input to inflate eventually results in an error -- Added enough.c (calculation of ENOUGH for inftrees.h) to examples/ -- Update ENOUGH and its usage to reflect discovered bounds -- Fix gzerror() error report on empty input file [Brown] -- Add ush casts in trees.c to avoid pedantic runtime errors -- Fix typo in zlib.h uncompress() description [Reiss] -- Correct inflate() comments with regard to automatic header detection -- Remove deprecation comment on Z_PARTIAL_FLUSH (it stays) -- Put new version of gzlog (2.0) in examples with interruption recovery -- Add puff compile option to permit invalid distance-too-far streams -- Add puff TEST command options, ability to read piped input -- Prototype the *64 functions in zlib.h when _FILE_OFFSET_BITS == 64, but - _LARGEFILE64_SOURCE not defined -- Fix Z_FULL_FLUSH to truly erase the past by resetting s->strstart -- Fix deflateSetDictionary() to use all 32K for output consistency -- Remove extraneous #define MIN_LOOKAHEAD in deflate.c (in deflate.h) -- Clear bytes after deflate lookahead to avoid use of uninitialized data -- Change a limit in inftrees.c to be more transparent to Coverity Prevent -- Update win32/zlib.def with exported symbols from zlib.h -- Correct spelling errors in zlib.h [Willem, Sobrado] -- Allow Z_BLOCK for deflate() to force a new block -- Allow negative bits in inflatePrime() to delete existing bit buffer -- Add Z_TREES flush option to inflate() to return at end of trees -- Add inflateMark() to return current state information for random access -- Add Makefile for NintendoDS to contrib [Costa] -- Add -w in configure compile tests to avoid spurious warnings [Beucler] -- Fix typos in zlib.h comments for deflateSetDictionary() -- Fix EOF detection in transparent gzread() [Maier] - -Changes in 1.2.3.3 (2 October 2006) -- Make --shared the default for configure, add a --static option -- Add compile option to permit invalid distance-too-far streams -- Add inflateUndermine() function which is required to enable above -- Remove use of "this" variable name for C++ compatibility [Marquess] -- Add testing of shared library in make test, if shared library built -- Use ftello() and fseeko() if available instead of ftell() and fseek() -- Provide two versions of all functions that use the z_off_t type for - binary compatibility -- a normal version and a 64-bit offset version, - per the Large File Support Extension when _LARGEFILE64_SOURCE is - defined; use the 64-bit versions by default when _FILE_OFFSET_BITS - is defined to be 64 -- Add a --uname= option to configure to perhaps help with cross-compiling - -Changes in 1.2.3.2 (3 September 2006) -- Turn off silly Borland warnings [Hay] -- Use off64_t and define _LARGEFILE64_SOURCE when present -- Fix missing dependency on inffixed.h in Makefile.in -- Rig configure --shared to build both shared and static [Teredesai, Truta] -- Remove zconf.in.h and instead create a new zlibdefs.h file -- Fix contrib/minizip/unzip.c non-encrypted after encrypted [Vollant] -- Add treebuild.xml (see http://treebuild.metux.de/) [Weigelt] - -Changes in 1.2.3.1 (16 August 2006) -- Add watcom directory with OpenWatcom make files [Daniel] -- Remove #undef of FAR in zconf.in.h for MVS [Fedtke] -- Update make_vms.com [Zinser] -- Use -fPIC for shared build in configure [Teredesai, Nicholson] -- Use only major version number for libz.so on IRIX and OSF1 [Reinholdtsen] -- Use fdopen() (not _fdopen()) for Interix in zutil.h [Bäck] -- Add some FAQ entries about the contrib directory -- Update the MVS question in the FAQ -- Avoid extraneous reads after EOF in gzio.c [Brown] -- Correct spelling of "successfully" in gzio.c [Randers-Pehrson] -- Add comments to zlib.h about gzerror() usage [Brown] -- Set extra flags in gzip header in gzopen() like deflate() does -- Make configure options more compatible with double-dash conventions - [Weigelt] -- Clean up compilation under Solaris SunStudio cc [Rowe, Reinholdtsen] -- Fix uninstall target in Makefile.in [Truta] -- Add pkgconfig support [Weigelt] -- Use $(DESTDIR) macro in Makefile.in [Reinholdtsen, Weigelt] -- Replace set_data_type() with a more accurate detect_data_type() in - trees.c, according to the txtvsbin.txt document [Truta] -- Swap the order of #include and #include "zlib.h" in - gzio.c, example.c and minigzip.c [Truta] -- Shut up annoying VS2005 warnings about standard C deprecation [Rowe, - Truta] (where?) -- Fix target "clean" from win32/Makefile.bor [Truta] -- Create .pdb and .manifest files in win32/makefile.msc [Ziegler, Rowe] -- Update zlib www home address in win32/DLL_FAQ.txt [Truta] -- Update contrib/masmx86/inffas32.asm for VS2005 [Vollant, Van Wassenhove] -- Enable browse info in the "Debug" and "ASM Debug" configurations in - the Visual C++ 6 project, and set (non-ASM) "Debug" as default [Truta] -- Add pkgconfig support [Weigelt] -- Add ZLIB_VER_MAJOR, ZLIB_VER_MINOR and ZLIB_VER_REVISION in zlib.h, - for use in win32/zlib1.rc [Polushin, Rowe, Truta] -- Add a document that explains the new text detection scheme to - doc/txtvsbin.txt [Truta] -- Add rfc1950.txt, rfc1951.txt and rfc1952.txt to doc/ [Truta] -- Move algorithm.txt into doc/ [Truta] -- Synchronize FAQ with website -- Fix compressBound(), was low for some pathological cases [Fearnley] -- Take into account wrapper variations in deflateBound() -- Set examples/zpipe.c input and output to binary mode for Windows -- Update examples/zlib_how.html with new zpipe.c (also web site) -- Fix some warnings in examples/gzlog.c and examples/zran.c (it seems - that gcc became pickier in 4.0) -- Add zlib.map for Linux: "All symbols from zlib-1.1.4 remain - un-versioned, the patch adds versioning only for symbols introduced in - zlib-1.2.0 or later. It also declares as local those symbols which are - not designed to be exported." [Levin] -- Update Z_PREFIX list in zconf.in.h, add --zprefix option to configure -- Do not initialize global static by default in trees.c, add a response - NO_INIT_GLOBAL_POINTERS to initialize them if needed [Marquess] -- Don't use strerror() in gzio.c under WinCE [Yakimov] -- Don't use errno.h in zutil.h under WinCE [Yakimov] -- Move arguments for AR to its usage to allow replacing ar [Marot] -- Add HAVE_VISIBILITY_PRAGMA in zconf.in.h for Mozilla [Randers-Pehrson] -- Improve inflateInit() and inflateInit2() documentation -- Fix structure size comment in inflate.h -- Change configure help option from --h* to --help [Santos] - -Changes in 1.2.3 (18 July 2005) -- Apply security vulnerability fixes to contrib/infback9 as well -- Clean up some text files (carriage returns, trailing space) -- Update testzlib, vstudio, masmx64, and masmx86 in contrib [Vollant] - -Changes in 1.2.2.4 (11 July 2005) -- Add inflatePrime() function for starting inflation at bit boundary -- Avoid some Visual C warnings in deflate.c -- Avoid more silly Visual C warnings in inflate.c and inftrees.c for 64-bit - compile -- Fix some spelling errors in comments [Betts] -- Correct inflateInit2() error return documentation in zlib.h -- Add zran.c example of compressed data random access to examples - directory, shows use of inflatePrime() -- Fix cast for assignments to strm->state in inflate.c and infback.c -- Fix zlibCompileFlags() in zutil.c to use 1L for long shifts [Oberhumer] -- Move declarations of gf2 functions to right place in crc32.c [Oberhumer] -- Add cast in trees.c t avoid a warning [Oberhumer] -- Avoid some warnings in fitblk.c, gun.c, gzjoin.c in examples [Oberhumer] -- Update make_vms.com [Zinser] -- Initialize state->write in inflateReset() since copied in inflate_fast() -- Be more strict on incomplete code sets in inflate_table() and increase - ENOUGH and MAXD -- this repairs a possible security vulnerability for - invalid inflate input. Thanks to Tavis Ormandy and Markus Oberhumer for - discovering the vulnerability and providing test cases -- Add ia64 support to configure for HP-UX [Smith] -- Add error return to gzread() for format or i/o error [Levin] -- Use malloc.h for OS/2 [Necasek] - -Changes in 1.2.2.3 (27 May 2005) -- Replace 1U constants in inflate.c and inftrees.c for 64-bit compile -- Typecast fread() return values in gzio.c [Vollant] -- Remove trailing space in minigzip.c outmode (VC++ can't deal with it) -- Fix crc check bug in gzread() after gzungetc() [Heiner] -- Add the deflateTune() function to adjust internal compression parameters -- Add a fast gzip decompressor, gun.c, to examples (use of inflateBack) -- Remove an incorrect assertion in examples/zpipe.c -- Add C++ wrapper in infback9.h [Donais] -- Fix bug in inflateCopy() when decoding fixed codes -- Note in zlib.h how much deflateSetDictionary() actually uses -- Remove USE_DICT_HEAD in deflate.c (would mess up inflate if used) -- Add _WIN32_WCE to define WIN32 in zconf.in.h [Spencer] -- Don't include stderr.h or errno.h for _WIN32_WCE in zutil.h [Spencer] -- Add gzdirect() function to indicate transparent reads -- Update contrib/minizip [Vollant] -- Fix compilation of deflate.c when both ASMV and FASTEST [Oberhumer] -- Add casts in crc32.c to avoid warnings [Oberhumer] -- Add contrib/masmx64 [Vollant] -- Update contrib/asm586, asm686, masmx86, testzlib, vstudio [Vollant] - -Changes in 1.2.2.2 (30 December 2004) -- Replace structure assignments in deflate.c and inflate.c with zmemcpy to - avoid implicit memcpy calls (portability for no-library compilation) -- Increase sprintf() buffer size in gzdopen() to allow for large numbers -- Add INFLATE_STRICT to check distances against zlib header -- Improve WinCE errno handling and comments [Chang] -- Remove comment about no gzip header processing in FAQ -- Add Z_FIXED strategy option to deflateInit2() to force fixed trees -- Add updated make_vms.com [Coghlan], update README -- Create a new "examples" directory, move gzappend.c there, add zpipe.c, - fitblk.c, gzlog.[ch], gzjoin.c, and zlib_how.html -- Add FAQ entry and comments in deflate.c on uninitialized memory access -- Add Solaris 9 make options in configure [Gilbert] -- Allow strerror() usage in gzio.c for STDC -- Fix DecompressBuf in contrib/delphi/ZLib.pas [ManChesTer] -- Update contrib/masmx86/inffas32.asm and gvmat32.asm [Vollant] -- Use z_off_t for adler32_combine() and crc32_combine() lengths -- Make adler32() much faster for small len -- Use OS_CODE in deflate() default gzip header - -Changes in 1.2.2.1 (31 October 2004) -- Allow inflateSetDictionary() call for raw inflate -- Fix inflate header crc check bug for file names and comments -- Add deflateSetHeader() and gz_header structure for custom gzip headers -- Add inflateGetheader() to retrieve gzip headers -- Add crc32_combine() and adler32_combine() functions -- Add alloc_func, free_func, in_func, out_func to Z_PREFIX list -- Use zstreamp consistently in zlib.h (inflate_back functions) -- Remove GUNZIP condition from definition of inflate_mode in inflate.h - and in contrib/inflate86/inffast.S [Truta, Anderson] -- Add support for AMD64 in contrib/inflate86/inffas86.c [Anderson] -- Update projects/README.projects and projects/visualc6 [Truta] -- Update win32/DLL_FAQ.txt [Truta] -- Avoid warning under NO_GZCOMPRESS in gzio.c; fix typo [Truta] -- Deprecate Z_ASCII; use Z_TEXT instead [Truta] -- Use a new algorithm for setting strm->data_type in trees.c [Truta] -- Do not define an exit() prototype in zutil.c unless DEBUG defined -- Remove prototype of exit() from zutil.c, example.c, minigzip.c [Truta] -- Add comment in zlib.h for Z_NO_FLUSH parameter to deflate() -- Fix Darwin build version identification [Peterson] - -Changes in 1.2.2 (3 October 2004) -- Update zlib.h comments on gzip in-memory processing -- Set adler to 1 in inflateReset() to support Java test suite [Walles] -- Add contrib/dotzlib [Ravn] -- Update win32/DLL_FAQ.txt [Truta] -- Update contrib/minizip [Vollant] -- Move contrib/visual-basic.txt to old/ [Truta] -- Fix assembler builds in projects/visualc6/ [Truta] - -Changes in 1.2.1.2 (9 September 2004) -- Update INDEX file -- Fix trees.c to update strm->data_type (no one ever noticed!) -- Fix bug in error case in inflate.c, infback.c, and infback9.c [Brown] -- Add "volatile" to crc table flag declaration (for DYNAMIC_CRC_TABLE) -- Add limited multitasking protection to DYNAMIC_CRC_TABLE -- Add NO_vsnprintf for VMS in zutil.h [Mozilla] -- Don't declare strerror() under VMS [Mozilla] -- Add comment to DYNAMIC_CRC_TABLE to use get_crc_table() to initialize -- Update contrib/ada [Anisimkov] -- Update contrib/minizip [Vollant] -- Fix configure to not hardcode directories for Darwin [Peterson] -- Fix gzio.c to not return error on empty files [Brown] -- Fix indentation; update version in contrib/delphi/ZLib.pas and - contrib/pascal/zlibpas.pas [Truta] -- Update mkasm.bat in contrib/masmx86 [Truta] -- Update contrib/untgz [Truta] -- Add projects/README.projects [Truta] -- Add project for MS Visual C++ 6.0 in projects/visualc6 [Cadieux, Truta] -- Update win32/DLL_FAQ.txt [Truta] -- Update list of Z_PREFIX symbols in zconf.h [Randers-Pehrson, Truta] -- Remove an unnecessary assignment to curr in inftrees.c [Truta] -- Add OS/2 to exe builds in configure [Poltorak] -- Remove err dummy parameter in zlib.h [Kientzle] - -Changes in 1.2.1.1 (9 January 2004) -- Update email address in README -- Several FAQ updates -- Fix a big fat bug in inftrees.c that prevented decoding valid - dynamic blocks with only literals and no distance codes -- - Thanks to "Hot Emu" for the bug report and sample file -- Add a note to puff.c on no distance codes case - -Changes in 1.2.1 (17 November 2003) -- Remove a tab in contrib/gzappend/gzappend.c -- Update some interfaces in contrib for new zlib functions -- Update zlib version number in some contrib entries -- Add Windows CE definition for ptrdiff_t in zutil.h [Mai, Truta] -- Support shared libraries on Hurd and KFreeBSD [Brown] -- Fix error in NO_DIVIDE option of adler32.c - -Changes in 1.2.0.8 (4 November 2003) -- Update version in contrib/delphi/ZLib.pas and contrib/pascal/zlibpas.pas -- Add experimental NO_DIVIDE #define in adler32.c - - Possibly faster on some processors (let me know if it is) -- Correct Z_BLOCK to not return on first inflate call if no wrap -- Fix strm->data_type on inflate() return to correctly indicate EOB -- Add deflatePrime() function for appending in the middle of a byte -- Add contrib/gzappend for an example of appending to a stream -- Update win32/DLL_FAQ.txt [Truta] -- Delete Turbo C comment in README [Truta] -- Improve some indentation in zconf.h [Truta] -- Fix infinite loop on bad input in configure script [Church] -- Fix gzeof() for concatenated gzip files [Johnson] -- Add example to contrib/visual-basic.txt [Michael B.] -- Add -p to mkdir's in Makefile.in [vda] -- Fix configure to properly detect presence or lack of printf functions -- Add AS400 support [Monnerat] -- Add a little Cygwin support [Wilson] - -Changes in 1.2.0.7 (21 September 2003) -- Correct some debug formats in contrib/infback9 -- Cast a type in a debug statement in trees.c -- Change search and replace delimiter in configure from % to # [Beebe] -- Update contrib/untgz to 0.2 with various fixes [Truta] -- Add build support for Amiga [Nikl] -- Remove some directories in old that have been updated to 1.2 -- Add dylib building for Mac OS X in configure and Makefile.in -- Remove old distribution stuff from Makefile -- Update README to point to DLL_FAQ.txt, and add comment on Mac OS X -- Update links in README - -Changes in 1.2.0.6 (13 September 2003) -- Minor FAQ updates -- Update contrib/minizip to 1.00 [Vollant] -- Remove test of gz functions in example.c when GZ_COMPRESS defined [Truta] -- Update POSTINC comment for 68060 [Nikl] -- Add contrib/infback9 with deflate64 decoding (unsupported) -- For MVS define NO_vsnprintf and undefine FAR [van Burik] -- Add pragma for fdopen on MVS [van Burik] - -Changes in 1.2.0.5 (8 September 2003) -- Add OF to inflateBackEnd() declaration in zlib.h -- Remember start when using gzdopen in the middle of a file -- Use internal off_t counters in gz* functions to properly handle seeks -- Perform more rigorous check for distance-too-far in inffast.c -- Add Z_BLOCK flush option to return from inflate at block boundary -- Set strm->data_type on return from inflate - - Indicate bits unused, if at block boundary, and if in last block -- Replace size_t with ptrdiff_t in crc32.c, and check for correct size -- Add condition so old NO_DEFLATE define still works for compatibility -- FAQ update regarding the Windows DLL [Truta] -- INDEX update: add qnx entry, remove aix entry [Truta] -- Install zlib.3 into mandir [Wilson] -- Move contrib/zlib_dll_FAQ.txt to win32/DLL_FAQ.txt; update [Truta] -- Adapt the zlib interface to the new DLL convention guidelines [Truta] -- Introduce ZLIB_WINAPI macro to allow the export of functions using - the WINAPI calling convention, for Visual Basic [Vollant, Truta] -- Update msdos and win32 scripts and makefiles [Truta] -- Export symbols by name, not by ordinal, in win32/zlib.def [Truta] -- Add contrib/ada [Anisimkov] -- Move asm files from contrib/vstudio/vc70_32 to contrib/asm386 [Truta] -- Rename contrib/asm386 to contrib/masmx86 [Truta, Vollant] -- Add contrib/masm686 [Truta] -- Fix offsets in contrib/inflate86 and contrib/masmx86/inffas32.asm - [Truta, Vollant] -- Update contrib/delphi; rename to contrib/pascal; add example [Truta] -- Remove contrib/delphi2; add a new contrib/delphi [Truta] -- Avoid inclusion of the nonstandard in contrib/iostream, - and fix some method prototypes [Truta] -- Fix the ZCR_SEED2 constant to avoid warnings in contrib/minizip - [Truta] -- Avoid the use of backslash (\) in contrib/minizip [Vollant] -- Fix file time handling in contrib/untgz; update makefiles [Truta] -- Update contrib/vstudio/vc70_32 to comply with the new DLL guidelines - [Vollant] -- Remove contrib/vstudio/vc15_16 [Vollant] -- Rename contrib/vstudio/vc70_32 to contrib/vstudio/vc7 [Truta] -- Update README.contrib [Truta] -- Invert the assignment order of match_head and s->prev[...] in - INSERT_STRING [Truta] -- Compare TOO_FAR with 32767 instead of 32768, to avoid 16-bit warnings - [Truta] -- Compare function pointers with 0, not with NULL or Z_NULL [Truta] -- Fix prototype of syncsearch in inflate.c [Truta] -- Introduce ASMINF macro to be enabled when using an ASM implementation - of inflate_fast [Truta] -- Change NO_DEFLATE to NO_GZCOMPRESS [Truta] -- Modify test_gzio in example.c to take a single file name as a - parameter [Truta] -- Exit the example.c program if gzopen fails [Truta] -- Add type casts around strlen in example.c [Truta] -- Remove casting to sizeof in minigzip.c; give a proper type - to the variable compared with SUFFIX_LEN [Truta] -- Update definitions of STDC and STDC99 in zconf.h [Truta] -- Synchronize zconf.h with the new Windows DLL interface [Truta] -- Use SYS16BIT instead of __32BIT__ to distinguish between - 16- and 32-bit platforms [Truta] -- Use far memory allocators in small 16-bit memory models for - Turbo C [Truta] -- Add info about the use of ASMV, ASMINF and ZLIB_WINAPI in - zlibCompileFlags [Truta] -- Cygwin has vsnprintf [Wilson] -- In Windows16, OS_CODE is 0, as in MSDOS [Truta] -- In Cygwin, OS_CODE is 3 (Unix), not 11 (Windows32) [Wilson] - -Changes in 1.2.0.4 (10 August 2003) -- Minor FAQ updates -- Be more strict when checking inflateInit2's windowBits parameter -- Change NO_GUNZIP compile option to NO_GZIP to cover deflate as well -- Add gzip wrapper option to deflateInit2 using windowBits -- Add updated QNX rule in configure and qnx directory [Bonnefoy] -- Make inflate distance-too-far checks more rigorous -- Clean up FAR usage in inflate -- Add casting to sizeof() in gzio.c and minigzip.c - -Changes in 1.2.0.3 (19 July 2003) -- Fix silly error in gzungetc() implementation [Vollant] -- Update contrib/minizip and contrib/vstudio [Vollant] -- Fix printf format in example.c -- Correct cdecl support in zconf.in.h [Anisimkov] -- Minor FAQ updates - -Changes in 1.2.0.2 (13 July 2003) -- Add ZLIB_VERNUM in zlib.h for numerical preprocessor comparisons -- Attempt to avoid warnings in crc32.c for pointer-int conversion -- Add AIX to configure, remove aix directory [Bakker] -- Add some casts to minigzip.c -- Improve checking after insecure sprintf() or vsprintf() calls -- Remove #elif's from crc32.c -- Change leave label to inf_leave in inflate.c and infback.c to avoid - library conflicts -- Remove inflate gzip decoding by default--only enable gzip decoding by - special request for stricter backward compatibility -- Add zlibCompileFlags() function to return compilation information -- More typecasting in deflate.c to avoid warnings -- Remove leading underscore from _Capital #defines [Truta] -- Fix configure to link shared library when testing -- Add some Windows CE target adjustments [Mai] -- Remove #define ZLIB_DLL in zconf.h [Vollant] -- Add zlib.3 [Rodgers] -- Update RFC URL in deflate.c and algorithm.txt [Mai] -- Add zlib_dll_FAQ.txt to contrib [Truta] -- Add UL to some constants [Truta] -- Update minizip and vstudio [Vollant] -- Remove vestigial NEED_DUMMY_RETURN from zconf.in.h -- Expand use of NO_DUMMY_DECL to avoid all dummy structures -- Added iostream3 to contrib [Schwardt] -- Replace rewind() with fseek() for WinCE [Truta] -- Improve setting of zlib format compression level flags - - Report 0 for huffman and rle strategies and for level == 0 or 1 - - Report 2 only for level == 6 -- Only deal with 64K limit when necessary at compile time [Truta] -- Allow TOO_FAR check to be turned off at compile time [Truta] -- Add gzclearerr() function [Souza] -- Add gzungetc() function - -Changes in 1.2.0.1 (17 March 2003) -- Add Z_RLE strategy for run-length encoding [Truta] - - When Z_RLE requested, restrict matches to distance one - - Update zlib.h, minigzip.c, gzopen(), gzdopen() for Z_RLE -- Correct FASTEST compilation to allow level == 0 -- Clean up what gets compiled for FASTEST -- Incorporate changes to zconf.in.h [Vollant] - - Refine detection of Turbo C need for dummy returns - - Refine ZLIB_DLL compilation - - Include additional header file on VMS for off_t typedef -- Try to use _vsnprintf where it supplants vsprintf [Vollant] -- Add some casts in inffast.c -- Enchance comments in zlib.h on what happens if gzprintf() tries to - write more than 4095 bytes before compression -- Remove unused state from inflateBackEnd() -- Remove exit(0) from minigzip.c, example.c -- Get rid of all those darn tabs -- Add "check" target to Makefile.in that does the same thing as "test" -- Add "mostlyclean" and "maintainer-clean" targets to Makefile.in -- Update contrib/inflate86 [Anderson] -- Update contrib/testzlib, contrib/vstudio, contrib/minizip [Vollant] -- Add msdos and win32 directories with makefiles [Truta] -- More additions and improvements to the FAQ - -Changes in 1.2.0 (9 March 2003) -- New and improved inflate code - - About 20% faster - - Does not allocate 32K window unless and until needed - - Automatically detects and decompresses gzip streams - - Raw inflate no longer needs an extra dummy byte at end - - Added inflateBack functions using a callback interface--even faster - than inflate, useful for file utilities (gzip, zip) - - Added inflateCopy() function to record state for random access on - externally generated deflate streams (e.g. in gzip files) - - More readable code (I hope) -- New and improved crc32() - - About 50% faster, thanks to suggestions from Rodney Brown -- Add deflateBound() and compressBound() functions -- Fix memory leak in deflateInit2() -- Permit setting dictionary for raw deflate (for parallel deflate) -- Fix const declaration for gzwrite() -- Check for some malloc() failures in gzio.c -- Fix bug in gzopen() on single-byte file 0x1f -- Fix bug in gzread() on concatenated file with 0x1f at end of buffer - and next buffer doesn't start with 0x8b -- Fix uncompress() to return Z_DATA_ERROR on truncated input -- Free memory at end of example.c -- Remove MAX #define in trees.c (conflicted with some libraries) -- Fix static const's in deflate.c, gzio.c, and zutil.[ch] -- Declare malloc() and free() in gzio.c if STDC not defined -- Use malloc() instead of calloc() in zutil.c if int big enough -- Define STDC for AIX -- Add aix/ with approach for compiling shared library on AIX -- Add HP-UX support for shared libraries in configure -- Add OpenUNIX support for shared libraries in configure -- Use $cc instead of gcc to build shared library -- Make prefix directory if needed when installing -- Correct Macintosh avoidance of typedef Byte in zconf.h -- Correct Turbo C memory allocation when under Linux -- Use libz.a instead of -lz in Makefile (assure use of compiled library) -- Update configure to check for snprintf or vsnprintf functions and their - return value, warn during make if using an insecure function -- Fix configure problem with compile-time knowledge of HAVE_UNISTD_H that - is lost when library is used--resolution is to build new zconf.h -- Documentation improvements (in zlib.h): - - Document raw deflate and inflate - - Update RFCs URL - - Point out that zlib and gzip formats are different - - Note that Z_BUF_ERROR is not fatal - - Document string limit for gzprintf() and possible buffer overflow - - Note requirement on avail_out when flushing - - Note permitted values of flush parameter of inflate() -- Add some FAQs (and even answers) to the FAQ -- Add contrib/inflate86/ for x86 faster inflate -- Add contrib/blast/ for PKWare Data Compression Library decompression -- Add contrib/puff/ simple inflate for deflate format description - -Changes in 1.1.4 (11 March 2002) -- ZFREE was repeated on same allocation on some error conditions - This creates a security problem described in - http://www.zlib.org/advisory-2002-03-11.txt -- Returned incorrect error (Z_MEM_ERROR) on some invalid data -- Avoid accesses before window for invalid distances with inflate window - less than 32K -- force windowBits > 8 to avoid a bug in the encoder for a window size - of 256 bytes. (A complete fix will be available in 1.1.5) - -Changes in 1.1.3 (9 July 1998) -- fix "an inflate input buffer bug that shows up on rare but persistent - occasions" (Mark) -- fix gzread and gztell for concatenated .gz files (Didier Le Botlan) -- fix gzseek(..., SEEK_SET) in write mode -- fix crc check after a gzeek (Frank Faubert) -- fix miniunzip when the last entry in a zip file is itself a zip file - (J Lillge) -- add contrib/asm586 and contrib/asm686 (Brian Raiter) - See http://www.muppetlabs.com/~breadbox/software/assembly.html -- add support for Delphi 3 in contrib/delphi (Bob Dellaca) -- add support for C++Builder 3 and Delphi 3 in contrib/delphi2 (Davide Moretti) -- do not exit prematurely in untgz if 0 at start of block (Magnus Holmgren) -- use macro EXTERN instead of extern to support DLL for BeOS (Sander Stoks) -- added a FAQ file - -- Support gzdopen on Mac with Metrowerks (Jason Linhart) -- Do not redefine Byte on Mac (Brad Pettit & Jason Linhart) -- define SEEK_END too if SEEK_SET is not defined (Albert Chin-A-Young) -- avoid some warnings with Borland C (Tom Tanner) -- fix a problem in contrib/minizip/zip.c for 16-bit MSDOS (Gilles Vollant) -- emulate utime() for WIN32 in contrib/untgz (Gilles Vollant) -- allow several arguments to configure (Tim Mooney, Frodo Looijaard) -- use libdir and includedir in Makefile.in (Tim Mooney) -- support shared libraries on OSF1 V4 (Tim Mooney) -- remove so_locations in "make clean" (Tim Mooney) -- fix maketree.c compilation error (Glenn, Mark) -- Python interface to zlib now in Python 1.5 (Jeremy Hylton) -- new Makefile.riscos (Rich Walker) -- initialize static descriptors in trees.c for embedded targets (Nick Smith) -- use "foo-gz" in example.c for RISCOS and VMS (Nick Smith) -- add the OS/2 files in Makefile.in too (Andrew Zabolotny) -- fix fdopen and halloc macros for Microsoft C 6.0 (Tom Lane) -- fix maketree.c to allow clean compilation of inffixed.h (Mark) -- fix parameter check in deflateCopy (Gunther Nikl) -- cleanup trees.c, use compressed_len only in debug mode (Christian Spieler) -- Many portability patches by Christian Spieler: - . zutil.c, zutil.h: added "const" for zmem* - . Make_vms.com: fixed some typos - . Make_vms.com: msdos/Makefile.*: removed zutil.h from some dependency lists - . msdos/Makefile.msc: remove "default rtl link library" info from obj files - . msdos/Makefile.*: use model-dependent name for the built zlib library - . msdos/Makefile.emx, nt/Makefile.emx, nt/Makefile.gcc: - new makefiles, for emx (DOS/OS2), emx&rsxnt and mingw32 (Windows 9x / NT) -- use define instead of typedef for Bytef also for MSC small/medium (Tom Lane) -- replace __far with _far for better portability (Christian Spieler, Tom Lane) -- fix test for errno.h in configure (Tim Newsham) - -Changes in 1.1.2 (19 March 98) -- added contrib/minzip, mini zip and unzip based on zlib (Gilles Vollant) - See http://www.winimage.com/zLibDll/unzip.html -- preinitialize the inflate tables for fixed codes, to make the code - completely thread safe (Mark) -- some simplifications and slight speed-up to the inflate code (Mark) -- fix gzeof on non-compressed files (Allan Schrum) -- add -std1 option in configure for OSF1 to fix gzprintf (Martin Mokrejs) -- use default value of 4K for Z_BUFSIZE for 16-bit MSDOS (Tim Wegner + Glenn) -- added os2/Makefile.def and os2/zlib.def (Andrew Zabolotny) -- add shared lib support for UNIX_SV4.2MP (MATSUURA Takanori) -- do not wrap extern "C" around system includes (Tom Lane) -- mention zlib binding for TCL in README (Andreas Kupries) -- added amiga/Makefile.pup for Amiga powerUP SAS/C PPC (Andreas Kleinert) -- allow "make install prefix=..." even after configure (Glenn Randers-Pehrson) -- allow "configure --prefix $HOME" (Tim Mooney) -- remove warnings in example.c and gzio.c (Glenn Randers-Pehrson) -- move Makefile.sas to amiga/Makefile.sas - -Changes in 1.1.1 (27 Feb 98) -- fix macros _tr_tally_* in deflate.h for debug mode (Glenn Randers-Pehrson) -- remove block truncation heuristic which had very marginal effect for zlib - (smaller lit_bufsize than in gzip 1.2.4) and degraded a little the - compression ratio on some files. This also allows inlining _tr_tally for - matches in deflate_slow -- added msdos/Makefile.w32 for WIN32 Microsoft Visual C++ (Bob Frazier) - -Changes in 1.1.0 (24 Feb 98) -- do not return STREAM_END prematurely in inflate (John Bowler) -- revert to the zlib 1.0.8 inflate to avoid the gcc 2.8.0 bug (Jeremy Buhler) -- compile with -DFASTEST to get compression code optimized for speed only -- in minigzip, try mmap'ing the input file first (Miguel Albrecht) -- increase size of I/O buffers in minigzip.c and gzio.c (not a big gain - on Sun but significant on HP) - -- add a pointer to experimental unzip library in README (Gilles Vollant) -- initialize variable gcc in configure (Chris Herborth) - -Changes in 1.0.9 (17 Feb 1998) -- added gzputs and gzgets functions -- do not clear eof flag in gzseek (Mark Diekhans) -- fix gzseek for files in transparent mode (Mark Diekhans) -- do not assume that vsprintf returns the number of bytes written (Jens Krinke) -- replace EXPORT with ZEXPORT to avoid conflict with other programs -- added compress2 in zconf.h, zlib.def, zlib.dnt -- new asm code from Gilles Vollant in contrib/asm386 -- simplify the inflate code (Mark): - . Replace ZALLOC's in huft_build() with single ZALLOC in inflate_blocks_new() - . ZALLOC the length list in inflate_trees_fixed() instead of using stack - . ZALLOC the value area for huft_build() instead of using stack - . Simplify Z_FINISH check in inflate() - -- Avoid gcc 2.8.0 comparison bug a little differently than zlib 1.0.8 -- in inftrees.c, avoid cc -O bug on HP (Farshid Elahi) -- in zconf.h move the ZLIB_DLL stuff earlier to avoid problems with - the declaration of FAR (Gilles VOllant) -- install libz.so* with mode 755 (executable) instead of 644 (Marc Lehmann) -- read_buf buf parameter of type Bytef* instead of charf* -- zmemcpy parameters are of type Bytef*, not charf* (Joseph Strout) -- do not redeclare unlink in minigzip.c for WIN32 (John Bowler) -- fix check for presence of directories in "make install" (Ian Willis) - -Changes in 1.0.8 (27 Jan 1998) -- fixed offsets in contrib/asm386/gvmat32.asm (Gilles Vollant) -- fix gzgetc and gzputc for big endian systems (Markus Oberhumer) -- added compress2() to allow setting the compression level -- include sys/types.h to get off_t on some systems (Marc Lehmann & QingLong) -- use constant arrays for the static trees in trees.c instead of computing - them at run time (thanks to Ken Raeburn for this suggestion). To create - trees.h, compile with GEN_TREES_H and run "make test" -- check return code of example in "make test" and display result -- pass minigzip command line options to file_compress -- simplifying code of inflateSync to avoid gcc 2.8 bug - -- support CC="gcc -Wall" in configure -s (QingLong) -- avoid a flush caused by ftell in gzopen for write mode (Ken Raeburn) -- fix test for shared library support to avoid compiler warnings -- zlib.lib -> zlib.dll in msdos/zlib.rc (Gilles Vollant) -- check for TARGET_OS_MAC in addition to MACOS (Brad Pettit) -- do not use fdopen for Metrowerks on Mac (Brad Pettit)) -- add checks for gzputc and gzputc in example.c -- avoid warnings in gzio.c and deflate.c (Andreas Kleinert) -- use const for the CRC table (Ken Raeburn) -- fixed "make uninstall" for shared libraries -- use Tracev instead of Trace in infblock.c -- in example.c use correct compressed length for test_sync -- suppress +vnocompatwarnings in configure for HPUX (not always supported) - -Changes in 1.0.7 (20 Jan 1998) -- fix gzseek which was broken in write mode -- return error for gzseek to negative absolute position -- fix configure for Linux (Chun-Chung Chen) -- increase stack space for MSC (Tim Wegner) -- get_crc_table and inflateSyncPoint are EXPORTed (Gilles Vollant) -- define EXPORTVA for gzprintf (Gilles Vollant) -- added man page zlib.3 (Rick Rodgers) -- for contrib/untgz, fix makedir() and improve Makefile - -- check gzseek in write mode in example.c -- allocate extra buffer for seeks only if gzseek is actually called -- avoid signed/unsigned comparisons (Tim Wegner, Gilles Vollant) -- add inflateSyncPoint in zconf.h -- fix list of exported functions in nt/zlib.dnt and mdsos/zlib.def - -Changes in 1.0.6 (19 Jan 1998) -- add functions gzprintf, gzputc, gzgetc, gztell, gzeof, gzseek, gzrewind and - gzsetparams (thanks to Roland Giersig and Kevin Ruland for some of this code) -- Fix a deflate bug occurring only with compression level 0 (thanks to - Andy Buckler for finding this one) -- In minigzip, pass transparently also the first byte for .Z files -- return Z_BUF_ERROR instead of Z_OK if output buffer full in uncompress() -- check Z_FINISH in inflate (thanks to Marc Schluper) -- Implement deflateCopy (thanks to Adam Costello) -- make static libraries by default in configure, add --shared option -- move MSDOS or Windows specific files to directory msdos -- suppress the notion of partial flush to simplify the interface - (but the symbol Z_PARTIAL_FLUSH is kept for compatibility with 1.0.4) -- suppress history buffer provided by application to simplify the interface - (this feature was not implemented anyway in 1.0.4) -- next_in and avail_in must be initialized before calling inflateInit or - inflateInit2 -- add EXPORT in all exported functions (for Windows DLL) -- added Makefile.nt (thanks to Stephen Williams) -- added the unsupported "contrib" directory: - contrib/asm386/ by Gilles Vollant - 386 asm code replacing longest_match() - contrib/iostream/ by Kevin Ruland - A C++ I/O streams interface to the zlib gz* functions - contrib/iostream2/ by Tyge Løvset - Another C++ I/O streams interface - contrib/untgz/ by "Pedro A. Aranda Guti\irrez" - A very simple tar.gz file extractor using zlib - contrib/visual-basic.txt by Carlos Rios - How to use compress(), uncompress() and the gz* functions from VB -- pass params -f (filtered data), -h (huffman only), -1 to -9 (compression - level) in minigzip (thanks to Tom Lane) - -- use const for rommable constants in deflate -- added test for gzseek and gztell in example.c -- add undocumented function inflateSyncPoint() (hack for Paul Mackerras) -- add undocumented function zError to convert error code to string - (for Tim Smithers) -- Allow compilation of gzio with -DNO_DEFLATE to avoid the compression code -- Use default memcpy for Symantec MSDOS compiler -- Add EXPORT keyword for check_func (needed for Windows DLL) -- add current directory to LD_LIBRARY_PATH for "make test" -- create also a link for libz.so.1 -- added support for FUJITSU UXP/DS (thanks to Toshiaki Nomura) -- use $(SHAREDLIB) instead of libz.so in Makefile.in (for HPUX) -- added -soname for Linux in configure (Chun-Chung Chen, -- assign numbers to the exported functions in zlib.def (for Windows DLL) -- add advice in zlib.h for best usage of deflateSetDictionary -- work around compiler bug on Atari (cast Z_NULL in call of s->checkfn) -- allow compilation with ANSI keywords only enabled for TurboC in large model -- avoid "versionString"[0] (Borland bug) -- add NEED_DUMMY_RETURN for Borland -- use variable z_verbose for tracing in debug mode (L. Peter Deutsch) -- allow compilation with CC -- defined STDC for OS/2 (David Charlap) -- limit external names to 8 chars for MVS (Thomas Lund) -- in minigzip.c, use static buffers only for 16-bit systems -- fix suffix check for "minigzip -d foo.gz" -- do not return an error for the 2nd of two consecutive gzflush() (Felix Lee) -- use _fdopen instead of fdopen for MSC >= 6.0 (Thomas Fanslau) -- added makelcc.bat for lcc-win32 (Tom St Denis) -- in Makefile.dj2, use copy and del instead of install and rm (Frank Donahoe) -- Avoid expanded $Id$. Use "rcs -kb" or "cvs admin -kb" to avoid Id expansion -- check for unistd.h in configure (for off_t) -- remove useless check parameter in inflate_blocks_free -- avoid useless assignment of s->check to itself in inflate_blocks_new -- do not flush twice in gzclose (thanks to Ken Raeburn) -- rename FOPEN as F_OPEN to avoid clash with /usr/include/sys/file.h -- use NO_ERRNO_H instead of enumeration of operating systems with errno.h -- work around buggy fclose on pipes for HP/UX -- support zlib DLL with BORLAND C++ 5.0 (thanks to Glenn Randers-Pehrson) -- fix configure if CC is already equal to gcc - -Changes in 1.0.5 (3 Jan 98) -- Fix inflate to terminate gracefully when fed corrupted or invalid data -- Use const for rommable constants in inflate -- Eliminate memory leaks on error conditions in inflate -- Removed some vestigial code in inflate -- Update web address in README - -Changes in 1.0.4 (24 Jul 96) -- In very rare conditions, deflate(s, Z_FINISH) could fail to produce an EOF - bit, so the decompressor could decompress all the correct data but went - on to attempt decompressing extra garbage data. This affected minigzip too -- zlibVersion and gzerror return const char* (needed for DLL) -- port to RISCOS (no fdopen, no multiple dots, no unlink, no fileno) -- use z_error only for DEBUG (avoid problem with DLLs) - -Changes in 1.0.3 (2 Jul 96) -- use z_streamp instead of z_stream *, which is now a far pointer in MSDOS - small and medium models; this makes the library incompatible with previous - versions for these models. (No effect in large model or on other systems.) -- return OK instead of BUF_ERROR if previous deflate call returned with - avail_out as zero but there is nothing to do -- added memcmp for non STDC compilers -- define NO_DUMMY_DECL for more Mac compilers (.h files merged incorrectly) -- define __32BIT__ if __386__ or i386 is defined (pb. with Watcom and SCO) -- better check for 16-bit mode MSC (avoids problem with Symantec) - -Changes in 1.0.2 (23 May 96) -- added Windows DLL support -- added a function zlibVersion (for the DLL support) -- fixed declarations using Bytef in infutil.c (pb with MSDOS medium model) -- Bytef is define's instead of typedef'd only for Borland C -- avoid reading uninitialized memory in example.c -- mention in README that the zlib format is now RFC1950 -- updated Makefile.dj2 -- added algorithm.doc - -Changes in 1.0.1 (20 May 96) [1.0 skipped to avoid confusion] -- fix array overlay in deflate.c which sometimes caused bad compressed data -- fix inflate bug with empty stored block -- fix MSDOS medium model which was broken in 0.99 -- fix deflateParams() which could generate bad compressed data -- Bytef is define'd instead of typedef'ed (work around Borland bug) -- added an INDEX file -- new makefiles for DJGPP (Makefile.dj2), 32-bit Borland (Makefile.b32), - Watcom (Makefile.wat), Amiga SAS/C (Makefile.sas) -- speed up adler32 for modern machines without auto-increment -- added -ansi for IRIX in configure -- static_init_done in trees.c is an int -- define unlink as delete for VMS -- fix configure for QNX -- add configure branch for SCO and HPUX -- avoid many warnings (unused variables, dead assignments, etc...) -- no fdopen for BeOS -- fix the Watcom fix for 32 bit mode (define FAR as empty) -- removed redefinition of Byte for MKWERKS -- work around an MWKERKS bug (incorrect merge of all .h files) - -Changes in 0.99 (27 Jan 96) -- allow preset dictionary shared between compressor and decompressor -- allow compression level 0 (no compression) -- add deflateParams in zlib.h: allow dynamic change of compression level - and compression strategy -- test large buffers and deflateParams in example.c -- add optional "configure" to build zlib as a shared library -- suppress Makefile.qnx, use configure instead -- fixed deflate for 64-bit systems (detected on Cray) -- fixed inflate_blocks for 64-bit systems (detected on Alpha) -- declare Z_DEFLATED in zlib.h (possible parameter for deflateInit2) -- always return Z_BUF_ERROR when deflate() has nothing to do -- deflateInit and inflateInit are now macros to allow version checking -- prefix all global functions and types with z_ with -DZ_PREFIX -- make falloc completely reentrant (inftrees.c) -- fixed very unlikely race condition in ct_static_init -- free in reverse order of allocation to help memory manager -- use zlib-1.0/* instead of zlib/* inside the tar.gz -- make zlib warning-free with "gcc -O3 -Wall -Wwrite-strings -Wpointer-arith - -Wconversion -Wstrict-prototypes -Wmissing-prototypes" -- allow gzread on concatenated .gz files -- deflateEnd now returns Z_DATA_ERROR if it was premature -- deflate is finally (?) fully deterministic (no matches beyond end of input) -- Document Z_SYNC_FLUSH -- add uninstall in Makefile -- Check for __cpluplus in zlib.h -- Better test in ct_align for partial flush -- avoid harmless warnings for Borland C++ -- initialize hash_head in deflate.c -- avoid warning on fdopen (gzio.c) for HP cc -Aa -- include stdlib.h for STDC compilers -- include errno.h for Cray -- ignore error if ranlib doesn't exist -- call ranlib twice for NeXTSTEP -- use exec_prefix instead of prefix for libz.a -- renamed ct_* as _tr_* to avoid conflict with applications -- clear z->msg in inflateInit2 before any error return -- initialize opaque in example.c, gzio.c, deflate.c and inflate.c -- fixed typo in zconf.h (_GNUC__ => __GNUC__) -- check for WIN32 in zconf.h and zutil.c (avoid farmalloc in 32-bit mode) -- fix typo in Make_vms.com (f$trnlnm -> f$getsyi) -- in fcalloc, normalize pointer if size > 65520 bytes -- don't use special fcalloc for 32 bit Borland C++ -- use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc... -- use Z_BINARY instead of BINARY -- document that gzclose after gzdopen will close the file -- allow "a" as mode in gzopen -- fix error checking in gzread -- allow skipping .gz extra-field on pipes -- added reference to Perl interface in README -- put the crc table in FAR data (I dislike more and more the medium model :) -- added get_crc_table -- added a dimension to all arrays (Borland C can't count) -- workaround Borland C bug in declaration of inflate_codes_new & inflate_fast -- guard against multiple inclusion of *.h (for precompiled header on Mac) -- Watcom C pretends to be Microsoft C small model even in 32 bit mode -- don't use unsized arrays to avoid silly warnings by Visual C++: - warning C4746: 'inflate_mask' : unsized array treated as '__far' - (what's wrong with far data in far model?) -- define enum out of inflate_blocks_state to allow compilation with C++ - -Changes in 0.95 (16 Aug 95) -- fix MSDOS small and medium model (now easier to adapt to any compiler) -- inlined send_bits -- fix the final (:-) bug for deflate with flush (output was correct but - not completely flushed in rare occasions) -- default window size is same for compression and decompression - (it's now sufficient to set MAX_WBITS in zconf.h) -- voidp -> voidpf and voidnp -> voidp (for consistency with other - typedefs and because voidnp was not near in large model) - -Changes in 0.94 (13 Aug 95) -- support MSDOS medium model -- fix deflate with flush (could sometimes generate bad output) -- fix deflateReset (zlib header was incorrectly suppressed) -- added support for VMS -- allow a compression level in gzopen() -- gzflush now calls fflush -- For deflate with flush, flush even if no more input is provided -- rename libgz.a as libz.a -- avoid complex expression in infcodes.c triggering Turbo C bug -- work around a problem with gcc on Alpha (in INSERT_STRING) -- don't use inline functions (problem with some gcc versions) -- allow renaming of Byte, uInt, etc... with #define -- avoid warning about (unused) pointer before start of array in deflate.c -- avoid various warnings in gzio.c, example.c, infblock.c, adler32.c, zutil.c -- avoid reserved word 'new' in trees.c - -Changes in 0.93 (25 June 95) -- temporarily disable inline functions -- make deflate deterministic -- give enough lookahead for PARTIAL_FLUSH -- Set binary mode for stdin/stdout in minigzip.c for OS/2 -- don't even use signed char in inflate (not portable enough) -- fix inflate memory leak for segmented architectures - -Changes in 0.92 (3 May 95) -- don't assume that char is signed (problem on SGI) -- Clear bit buffer when starting a stored block -- no memcpy on Pyramid -- suppressed inftest.c -- optimized fill_window, put longest_match inline for gcc -- optimized inflate on stored blocks -- untabify all sources to simplify patches - -Changes in 0.91 (2 May 95) -- Default MEM_LEVEL is 8 (not 9 for Unix) as documented in zlib.h -- Document the memory requirements in zconf.h -- added "make install" -- fix sync search logic in inflateSync -- deflate(Z_FULL_FLUSH) now works even if output buffer too short -- after inflateSync, don't scare people with just "lo world" -- added support for DJGPP - -Changes in 0.9 (1 May 95) -- don't assume that zalloc clears the allocated memory (the TurboC bug - was Mark's bug after all :) -- let again gzread copy uncompressed data unchanged (was working in 0.71) -- deflate(Z_FULL_FLUSH), inflateReset and inflateSync are now fully implemented -- added a test of inflateSync in example.c -- moved MAX_WBITS to zconf.h because users might want to change that -- document explicitly that zalloc(64K) on MSDOS must return a normalized - pointer (zero offset) -- added Makefiles for Microsoft C, Turbo C, Borland C++ -- faster crc32() - -Changes in 0.8 (29 April 95) -- added fast inflate (inffast.c) -- deflate(Z_FINISH) now returns Z_STREAM_END when done. Warning: this - is incompatible with previous versions of zlib which returned Z_OK -- work around a TurboC compiler bug (bad code for b << 0, see infutil.h) - (actually that was not a compiler bug, see 0.81 above) -- gzread no longer reads one extra byte in certain cases -- In gzio destroy(), don't reference a freed structure -- avoid many warnings for MSDOS -- avoid the ERROR symbol which is used by MS Windows - -Changes in 0.71 (14 April 95) -- Fixed more MSDOS compilation problems :( There is still a bug with - TurboC large model - -Changes in 0.7 (14 April 95) -- Added full inflate support -- Simplified the crc32() interface. The pre- and post-conditioning - (one's complement) is now done inside crc32(). WARNING: this is - incompatible with previous versions; see zlib.h for the new usage - -Changes in 0.61 (12 April 95) -- workaround for a bug in TurboC. example and minigzip now work on MSDOS - -Changes in 0.6 (11 April 95) -- added minigzip.c -- added gzdopen to reopen a file descriptor as gzFile -- added transparent reading of non-gziped files in gzread -- fixed bug in gzread (don't read crc as data) -- fixed bug in destroy (gzio.c) (don't return Z_STREAM_END for gzclose) -- don't allocate big arrays in the stack (for MSDOS) -- fix some MSDOS compilation problems - -Changes in 0.5: -- do real compression in deflate.c. Z_PARTIAL_FLUSH is supported but - not yet Z_FULL_FLUSH -- support decompression but only in a single step (forced Z_FINISH) -- added opaque object for zalloc and zfree -- added deflateReset and inflateReset -- added a variable zlib_version for consistency checking -- renamed the 'filter' parameter of deflateInit2 as 'strategy' - Added Z_FILTERED and Z_HUFFMAN_ONLY constants - -Changes in 0.4: -- avoid "zip" everywhere, use zlib instead of ziplib -- suppress Z_BLOCK_FLUSH, interpret Z_PARTIAL_FLUSH as block flush - if compression method == 8 -- added adler32 and crc32 -- renamed deflateOptions as deflateInit2, call one or the other but not both -- added the method parameter for deflateInit2 -- added inflateInit2 -- simplied considerably deflateInit and inflateInit by not supporting - user-provided history buffer. This is supported only in deflateInit2 - and inflateInit2 - -Changes in 0.3: -- prefix all macro names with Z_ -- use Z_FINISH instead of deflateEnd to finish compression -- added Z_HUFFMAN_ONLY -- added gzerror() diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/FAQ b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/FAQ deleted file mode 100644 index 99b7cf9..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/FAQ +++ /dev/null @@ -1,368 +0,0 @@ - - Frequently Asked Questions about zlib - - -If your question is not there, please check the zlib home page -http://zlib.net/ which may have more recent information. -The lastest zlib FAQ is at http://zlib.net/zlib_faq.html - - - 1. Is zlib Y2K-compliant? - - Yes. zlib doesn't handle dates. - - 2. Where can I get a Windows DLL version? - - The zlib sources can be compiled without change to produce a DLL. See the - file win32/DLL_FAQ.txt in the zlib distribution. Pointers to the - precompiled DLL are found in the zlib web site at http://zlib.net/ . - - 3. Where can I get a Visual Basic interface to zlib? - - See - * http://marknelson.us/1997/01/01/zlib-engine/ - * win32/DLL_FAQ.txt in the zlib distribution - - 4. compress() returns Z_BUF_ERROR. - - Make sure that before the call of compress(), the length of the compressed - buffer is equal to the available size of the compressed buffer and not - zero. For Visual Basic, check that this parameter is passed by reference - ("as any"), not by value ("as long"). - - 5. deflate() or inflate() returns Z_BUF_ERROR. - - Before making the call, make sure that avail_in and avail_out are not zero. - When setting the parameter flush equal to Z_FINISH, also make sure that - avail_out is big enough to allow processing all pending input. Note that a - Z_BUF_ERROR is not fatal--another call to deflate() or inflate() can be - made with more input or output space. A Z_BUF_ERROR may in fact be - unavoidable depending on how the functions are used, since it is not - possible to tell whether or not there is more output pending when - strm.avail_out returns with zero. See http://zlib.net/zlib_how.html for a - heavily annotated example. - - 6. Where's the zlib documentation (man pages, etc.)? - - It's in zlib.h . Examples of zlib usage are in the files test/example.c - and test/minigzip.c, with more in examples/ . - - 7. Why don't you use GNU autoconf or libtool or ...? - - Because we would like to keep zlib as a very small and simple package. - zlib is rather portable and doesn't need much configuration. - - 8. I found a bug in zlib. - - Most of the time, such problems are due to an incorrect usage of zlib. - Please try to reproduce the problem with a small program and send the - corresponding source to us at zlib@gzip.org . Do not send multi-megabyte - data files without prior agreement. - - 9. Why do I get "undefined reference to gzputc"? - - If "make test" produces something like - - example.o(.text+0x154): undefined reference to `gzputc' - - check that you don't have old files libz.* in /usr/lib, /usr/local/lib or - /usr/X11R6/lib. Remove any old versions, then do "make install". - -10. I need a Delphi interface to zlib. - - See the contrib/delphi directory in the zlib distribution. - -11. Can zlib handle .zip archives? - - Not by itself, no. See the directory contrib/minizip in the zlib - distribution. - -12. Can zlib handle .Z files? - - No, sorry. You have to spawn an uncompress or gunzip subprocess, or adapt - the code of uncompress on your own. - -13. How can I make a Unix shared library? - - By default a shared (and a static) library is built for Unix. So: - - make distclean - ./configure - make - -14. How do I install a shared zlib library on Unix? - - After the above, then: - - make install - - However, many flavors of Unix come with a shared zlib already installed. - Before going to the trouble of compiling a shared version of zlib and - trying to install it, you may want to check if it's already there! If you - can #include , it's there. The -lz option will probably link to - it. You can check the version at the top of zlib.h or with the - ZLIB_VERSION symbol defined in zlib.h . - -15. I have a question about OttoPDF. - - We are not the authors of OttoPDF. The real author is on the OttoPDF web - site: Joel Hainley, jhainley@myndkryme.com. - -16. Can zlib decode Flate data in an Adobe PDF file? - - Yes. See http://www.pdflib.com/ . To modify PDF forms, see - http://sourceforge.net/projects/acroformtool/ . - -17. Why am I getting this "register_frame_info not found" error on Solaris? - - After installing zlib 1.1.4 on Solaris 2.6, running applications using zlib - generates an error such as: - - ld.so.1: rpm: fatal: relocation error: file /usr/local/lib/libz.so: - symbol __register_frame_info: referenced symbol not found - - The symbol __register_frame_info is not part of zlib, it is generated by - the C compiler (cc or gcc). You must recompile applications using zlib - which have this problem. This problem is specific to Solaris. See - http://www.sunfreeware.com for Solaris versions of zlib and applications - using zlib. - -18. Why does gzip give an error on a file I make with compress/deflate? - - The compress and deflate functions produce data in the zlib format, which - is different and incompatible with the gzip format. The gz* functions in - zlib on the other hand use the gzip format. Both the zlib and gzip formats - use the same compressed data format internally, but have different headers - and trailers around the compressed data. - -19. Ok, so why are there two different formats? - - The gzip format was designed to retain the directory information about a - single file, such as the name and last modification date. The zlib format - on the other hand was designed for in-memory and communication channel - applications, and has a much more compact header and trailer and uses a - faster integrity check than gzip. - -20. Well that's nice, but how do I make a gzip file in memory? - - You can request that deflate write the gzip format instead of the zlib - format using deflateInit2(). You can also request that inflate decode the - gzip format using inflateInit2(). Read zlib.h for more details. - -21. Is zlib thread-safe? - - Yes. However any library routines that zlib uses and any application- - provided memory allocation routines must also be thread-safe. zlib's gz* - functions use stdio library routines, and most of zlib's functions use the - library memory allocation routines by default. zlib's *Init* functions - allow for the application to provide custom memory allocation routines. - - Of course, you should only operate on any given zlib or gzip stream from a - single thread at a time. - -22. Can I use zlib in my commercial application? - - Yes. Please read the license in zlib.h. - -23. Is zlib under the GNU license? - - No. Please read the license in zlib.h. - -24. The license says that altered source versions must be "plainly marked". So - what exactly do I need to do to meet that requirement? - - You need to change the ZLIB_VERSION and ZLIB_VERNUM #defines in zlib.h. In - particular, the final version number needs to be changed to "f", and an - identification string should be appended to ZLIB_VERSION. Version numbers - x.x.x.f are reserved for modifications to zlib by others than the zlib - maintainers. For example, if the version of the base zlib you are altering - is "1.2.3.4", then in zlib.h you should change ZLIB_VERNUM to 0x123f, and - ZLIB_VERSION to something like "1.2.3.f-zachary-mods-v3". You can also - update the version strings in deflate.c and inftrees.c. - - For altered source distributions, you should also note the origin and - nature of the changes in zlib.h, as well as in ChangeLog and README, along - with the dates of the alterations. The origin should include at least your - name (or your company's name), and an email address to contact for help or - issues with the library. - - Note that distributing a compiled zlib library along with zlib.h and - zconf.h is also a source distribution, and so you should change - ZLIB_VERSION and ZLIB_VERNUM and note the origin and nature of the changes - in zlib.h as you would for a full source distribution. - -25. Will zlib work on a big-endian or little-endian architecture, and can I - exchange compressed data between them? - - Yes and yes. - -26. Will zlib work on a 64-bit machine? - - Yes. It has been tested on 64-bit machines, and has no dependence on any - data types being limited to 32-bits in length. If you have any - difficulties, please provide a complete problem report to zlib@gzip.org - -27. Will zlib decompress data from the PKWare Data Compression Library? - - No. The PKWare DCL uses a completely different compressed data format than - does PKZIP and zlib. However, you can look in zlib's contrib/blast - directory for a possible solution to your problem. - -28. Can I access data randomly in a compressed stream? - - No, not without some preparation. If when compressing you periodically use - Z_FULL_FLUSH, carefully write all the pending data at those points, and - keep an index of those locations, then you can start decompression at those - points. You have to be careful to not use Z_FULL_FLUSH too often, since it - can significantly degrade compression. Alternatively, you can scan a - deflate stream once to generate an index, and then use that index for - random access. See examples/zran.c . - -29. Does zlib work on MVS, OS/390, CICS, etc.? - - It has in the past, but we have not heard of any recent evidence. There - were working ports of zlib 1.1.4 to MVS, but those links no longer work. - If you know of recent, successful applications of zlib on these operating - systems, please let us know. Thanks. - -30. Is there some simpler, easier to read version of inflate I can look at to - understand the deflate format? - - First off, you should read RFC 1951. Second, yes. Look in zlib's - contrib/puff directory. - -31. Does zlib infringe on any patents? - - As far as we know, no. In fact, that was originally the whole point behind - zlib. Look here for some more information: - - http://www.gzip.org/#faq11 - -32. Can zlib work with greater than 4 GB of data? - - Yes. inflate() and deflate() will process any amount of data correctly. - Each call of inflate() or deflate() is limited to input and output chunks - of the maximum value that can be stored in the compiler's "unsigned int" - type, but there is no limit to the number of chunks. Note however that the - strm.total_in and strm_total_out counters may be limited to 4 GB. These - counters are provided as a convenience and are not used internally by - inflate() or deflate(). The application can easily set up its own counters - updated after each call of inflate() or deflate() to count beyond 4 GB. - compress() and uncompress() may be limited to 4 GB, since they operate in a - single call. gzseek() and gztell() may be limited to 4 GB depending on how - zlib is compiled. See the zlibCompileFlags() function in zlib.h. - - The word "may" appears several times above since there is a 4 GB limit only - if the compiler's "long" type is 32 bits. If the compiler's "long" type is - 64 bits, then the limit is 16 exabytes. - -33. Does zlib have any security vulnerabilities? - - The only one that we are aware of is potentially in gzprintf(). If zlib is - compiled to use sprintf() or vsprintf(), then there is no protection - against a buffer overflow of an 8K string space (or other value as set by - gzbuffer()), other than the caller of gzprintf() assuring that the output - will not exceed 8K. On the other hand, if zlib is compiled to use - snprintf() or vsnprintf(), which should normally be the case, then there is - no vulnerability. The ./configure script will display warnings if an - insecure variation of sprintf() will be used by gzprintf(). Also the - zlibCompileFlags() function will return information on what variant of - sprintf() is used by gzprintf(). - - If you don't have snprintf() or vsnprintf() and would like one, you can - find a portable implementation here: - - http://www.ijs.si/software/snprintf/ - - Note that you should be using the most recent version of zlib. Versions - 1.1.3 and before were subject to a double-free vulnerability, and versions - 1.2.1 and 1.2.2 were subject to an access exception when decompressing - invalid compressed data. - -34. Is there a Java version of zlib? - - Probably what you want is to use zlib in Java. zlib is already included - as part of the Java SDK in the java.util.zip package. If you really want - a version of zlib written in the Java language, look on the zlib home - page for links: http://zlib.net/ . - -35. I get this or that compiler or source-code scanner warning when I crank it - up to maximally-pedantic. Can't you guys write proper code? - - Many years ago, we gave up attempting to avoid warnings on every compiler - in the universe. It just got to be a waste of time, and some compilers - were downright silly as well as contradicted each other. So now, we simply - make sure that the code always works. - -36. Valgrind (or some similar memory access checker) says that deflate is - performing a conditional jump that depends on an uninitialized value. - Isn't that a bug? - - No. That is intentional for performance reasons, and the output of deflate - is not affected. This only started showing up recently since zlib 1.2.x - uses malloc() by default for allocations, whereas earlier versions used - calloc(), which zeros out the allocated memory. Even though the code was - correct, versions 1.2.4 and later was changed to not stimulate these - checkers. - -37. Will zlib read the (insert any ancient or arcane format here) compressed - data format? - - Probably not. Look in the comp.compression FAQ for pointers to various - formats and associated software. - -38. How can I encrypt/decrypt zip files with zlib? - - zlib doesn't support encryption. The original PKZIP encryption is very - weak and can be broken with freely available programs. To get strong - encryption, use GnuPG, http://www.gnupg.org/ , which already includes zlib - compression. For PKZIP compatible "encryption", look at - http://www.info-zip.org/ - -39. What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings? - - "gzip" is the gzip format, and "deflate" is the zlib format. They should - probably have called the second one "zlib" instead to avoid confusion with - the raw deflate compressed data format. While the HTTP 1.1 RFC 2616 - correctly points to the zlib specification in RFC 1950 for the "deflate" - transfer encoding, there have been reports of servers and browsers that - incorrectly produce or expect raw deflate data per the deflate - specification in RFC 1951, most notably Microsoft. So even though the - "deflate" transfer encoding using the zlib format would be the more - efficient approach (and in fact exactly what the zlib format was designed - for), using the "gzip" transfer encoding is probably more reliable due to - an unfortunate choice of name on the part of the HTTP 1.1 authors. - - Bottom line: use the gzip format for HTTP 1.1 encoding. - -40. Does zlib support the new "Deflate64" format introduced by PKWare? - - No. PKWare has apparently decided to keep that format proprietary, since - they have not documented it as they have previous compression formats. In - any case, the compression improvements are so modest compared to other more - modern approaches, that it's not worth the effort to implement. - -41. I'm having a problem with the zip functions in zlib, can you help? - - There are no zip functions in zlib. You are probably using minizip by - Giles Vollant, which is found in the contrib directory of zlib. It is not - part of zlib. In fact none of the stuff in contrib is part of zlib. The - files in there are not supported by the zlib authors. You need to contact - the authors of the respective contribution for help. - -42. The match.asm code in contrib is under the GNU General Public License. - Since it's part of zlib, doesn't that mean that all of zlib falls under the - GNU GPL? - - No. The files in contrib are not part of zlib. They were contributed by - other authors and are provided as a convenience to the user within the zlib - distribution. Each item in contrib has its own license. - -43. Is zlib subject to export controls? What is its ECCN? - - zlib is not subject to export controls, and so is classified as EAR99. - -44. Can you please sign these lengthy legal documents and fax them back to us - so that we can use your software in our product? - - No. Go away. Shoo. diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/INDEX b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/INDEX deleted file mode 100644 index 2ba0641..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/INDEX +++ /dev/null @@ -1,68 +0,0 @@ -CMakeLists.txt cmake build file -ChangeLog history of changes -FAQ Frequently Asked Questions about zlib -INDEX this file -Makefile dummy Makefile that tells you to ./configure -Makefile.in template for Unix Makefile -README guess what -configure configure script for Unix -make_vms.com makefile for VMS -test/example.c zlib usages examples for build testing -test/minigzip.c minimal gzip-like functionality for build testing -test/infcover.c inf*.c code coverage for build coverage testing -treebuild.xml XML description of source file dependencies -zconf.h.cmakein zconf.h template for cmake -zconf.h.in zconf.h template for configure -zlib.3 Man page for zlib -zlib.3.pdf Man page in PDF format -zlib.map Linux symbol information -zlib.pc.in Template for pkg-config descriptor -zlib.pc.cmakein zlib.pc template for cmake -zlib2ansi perl script to convert source files for C++ compilation - -amiga/ makefiles for Amiga SAS C -as400/ makefiles for AS/400 -doc/ documentation for formats and algorithms -msdos/ makefiles for MSDOS -nintendods/ makefile for Nintendo DS -old/ makefiles for various architectures and zlib documentation - files that have not yet been updated for zlib 1.2.x -qnx/ makefiles for QNX -watcom/ makefiles for OpenWatcom -win32/ makefiles for Windows - - zlib public header files (required for library use): -zconf.h -zlib.h - - private source files used to build the zlib library: -adler32.c -compress.c -crc32.c -crc32.h -deflate.c -deflate.h -gzclose.c -gzguts.h -gzlib.c -gzread.c -gzwrite.c -infback.c -inffast.c -inffast.h -inffixed.h -inflate.c -inflate.h -inftrees.c -inftrees.h -trees.c -trees.h -uncompr.c -zutil.c -zutil.h - - source files for sample programs -See examples/README.examples - - unsupported contributions by third parties -See contrib/README.contrib diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/Makefile b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/Makefile deleted file mode 100644 index 6bba86c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -all: - -@echo "Please use ./configure first. Thank you." - -distclean: - make -f Makefile.in distclean diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/Makefile.in b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/Makefile.in deleted file mode 100644 index 3d858aa..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/Makefile.in +++ /dev/null @@ -1,408 +0,0 @@ -# Makefile for zlib -# Copyright (C) 1995-2017 Jean-loup Gailly, Mark Adler -# For conditions of distribution and use, see copyright notice in zlib.h - -# To compile and test, type: -# ./configure; make test -# Normally configure builds both a static and a shared library. -# If you want to build just a static library, use: ./configure --static - -# To use the asm code, type: -# cp contrib/asm?86/match.S ./match.S -# make LOC=-DASMV OBJA=match.o - -# To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type: -# make install -# To install in $HOME instead of /usr/local, use: -# make install prefix=$HOME - -CC=cc - -CFLAGS=-O -#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 -#CFLAGS=-g -DZLIB_DEBUG -#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ -# -Wstrict-prototypes -Wmissing-prototypes - -SFLAGS=-O -LDFLAGS= -TEST_LDFLAGS=-L. libz.a -LDSHARED=$(CC) -CPP=$(CC) -E - -STATICLIB=libz.a -SHAREDLIB=libz.so -SHAREDLIBV=libz.so.1.2.12 -SHAREDLIBM=libz.so.1 -LIBS=$(STATICLIB) $(SHAREDLIBV) - -AR=ar -ARFLAGS=rc -RANLIB=ranlib -LDCONFIG=ldconfig -LDSHAREDLIBC=-lc -TAR=tar -SHELL=/bin/sh -EXE= - -prefix = /usr/local -exec_prefix = ${prefix} -libdir = ${exec_prefix}/lib -sharedlibdir = ${libdir} -includedir = ${prefix}/include -mandir = ${prefix}/share/man -man3dir = ${mandir}/man3 -pkgconfigdir = ${libdir}/pkgconfig -SRCDIR= -ZINC= -ZINCOUT=-I. - -OBJZ = adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o -OBJG = compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o -OBJC = $(OBJZ) $(OBJG) - -PIC_OBJZ = adler32.lo crc32.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo -PIC_OBJG = compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo -PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJG) - -# to use the asm code: make OBJA=match.o, PIC_OBJA=match.lo -OBJA = -PIC_OBJA = - -OBJS = $(OBJC) $(OBJA) - -PIC_OBJS = $(PIC_OBJC) $(PIC_OBJA) - -all: static shared - -static: example$(EXE) minigzip$(EXE) - -shared: examplesh$(EXE) minigzipsh$(EXE) - -all64: example64$(EXE) minigzip64$(EXE) - -check: test - -test: all teststatic testshared - -teststatic: static - @TMPST=tmpst_$$; \ - if echo hello world | ./minigzip | ./minigzip -d && ./example $$TMPST ; then \ - echo ' *** zlib test OK ***'; \ - else \ - echo ' *** zlib test FAILED ***'; false; \ - fi - @rm -f tmpst_$$ - -testshared: shared - @LD_LIBRARY_PATH=`pwd`:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \ - LD_LIBRARYN32_PATH=`pwd`:$(LD_LIBRARYN32_PATH) ; export LD_LIBRARYN32_PATH; \ - DYLD_LIBRARY_PATH=`pwd`:$(DYLD_LIBRARY_PATH) ; export DYLD_LIBRARY_PATH; \ - SHLIB_PATH=`pwd`:$(SHLIB_PATH) ; export SHLIB_PATH; \ - TMPSH=tmpsh_$$; \ - if echo hello world | ./minigzipsh | ./minigzipsh -d && ./examplesh $$TMPSH; then \ - echo ' *** zlib shared test OK ***'; \ - else \ - echo ' *** zlib shared test FAILED ***'; false; \ - fi - @rm -f tmpsh_$$ - -test64: all64 - @TMP64=tmp64_$$; \ - if echo hello world | ./minigzip64 | ./minigzip64 -d && ./example64 $$TMP64; then \ - echo ' *** zlib 64-bit test OK ***'; \ - else \ - echo ' *** zlib 64-bit test FAILED ***'; false; \ - fi - @rm -f tmp64_$$ - -infcover.o: $(SRCDIR)test/infcover.c $(SRCDIR)zlib.h zconf.h - $(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/infcover.c - -infcover: infcover.o libz.a - $(CC) $(CFLAGS) -o $@ infcover.o libz.a - -cover: infcover - rm -f *.gcda - ./infcover - gcov inf*.c - -libz.a: $(OBJS) - $(AR) $(ARFLAGS) $@ $(OBJS) - -@ ($(RANLIB) $@ || true) >/dev/null 2>&1 - -match.o: match.S - $(CPP) match.S > _match.s - $(CC) -c _match.s - mv _match.o match.o - rm -f _match.s - -match.lo: match.S - $(CPP) match.S > _match.s - $(CC) -c -fPIC _match.s - mv _match.o match.lo - rm -f _match.s - -example.o: $(SRCDIR)test/example.c $(SRCDIR)zlib.h zconf.h - $(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/example.c - -minigzip.o: $(SRCDIR)test/minigzip.c $(SRCDIR)zlib.h zconf.h - $(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/minigzip.c - -example64.o: $(SRCDIR)test/example.c $(SRCDIR)zlib.h zconf.h - $(CC) $(CFLAGS) $(ZINCOUT) -D_FILE_OFFSET_BITS=64 -c -o $@ $(SRCDIR)test/example.c - -minigzip64.o: $(SRCDIR)test/minigzip.c $(SRCDIR)zlib.h zconf.h - $(CC) $(CFLAGS) $(ZINCOUT) -D_FILE_OFFSET_BITS=64 -c -o $@ $(SRCDIR)test/minigzip.c - - -adler32.o: $(SRCDIR)adler32.c - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)adler32.c - -crc32.o: $(SRCDIR)crc32.c - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)crc32.c - -deflate.o: $(SRCDIR)deflate.c - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)deflate.c - -infback.o: $(SRCDIR)infback.c - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)infback.c - -inffast.o: $(SRCDIR)inffast.c - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)inffast.c - -inflate.o: $(SRCDIR)inflate.c - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)inflate.c - -inftrees.o: $(SRCDIR)inftrees.c - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)inftrees.c - -trees.o: $(SRCDIR)trees.c - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)trees.c - -zutil.o: $(SRCDIR)zutil.c - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)zutil.c - -compress.o: $(SRCDIR)compress.c - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)compress.c - -uncompr.o: $(SRCDIR)uncompr.c - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)uncompr.c - -gzclose.o: $(SRCDIR)gzclose.c - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzclose.c - -gzlib.o: $(SRCDIR)gzlib.c - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzlib.c - -gzread.o: $(SRCDIR)gzread.c - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzread.c - -gzwrite.o: $(SRCDIR)gzwrite.c - $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzwrite.c - - -adler32.lo: $(SRCDIR)adler32.c - -@mkdir objs 2>/dev/null || test -d objs - $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/adler32.o $(SRCDIR)adler32.c - -@mv objs/adler32.o $@ - -crc32.lo: $(SRCDIR)crc32.c - -@mkdir objs 2>/dev/null || test -d objs - $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/crc32.o $(SRCDIR)crc32.c - -@mv objs/crc32.o $@ - -deflate.lo: $(SRCDIR)deflate.c - -@mkdir objs 2>/dev/null || test -d objs - $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/deflate.o $(SRCDIR)deflate.c - -@mv objs/deflate.o $@ - -infback.lo: $(SRCDIR)infback.c - -@mkdir objs 2>/dev/null || test -d objs - $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/infback.o $(SRCDIR)infback.c - -@mv objs/infback.o $@ - -inffast.lo: $(SRCDIR)inffast.c - -@mkdir objs 2>/dev/null || test -d objs - $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/inffast.o $(SRCDIR)inffast.c - -@mv objs/inffast.o $@ - -inflate.lo: $(SRCDIR)inflate.c - -@mkdir objs 2>/dev/null || test -d objs - $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/inflate.o $(SRCDIR)inflate.c - -@mv objs/inflate.o $@ - -inftrees.lo: $(SRCDIR)inftrees.c - -@mkdir objs 2>/dev/null || test -d objs - $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/inftrees.o $(SRCDIR)inftrees.c - -@mv objs/inftrees.o $@ - -trees.lo: $(SRCDIR)trees.c - -@mkdir objs 2>/dev/null || test -d objs - $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/trees.o $(SRCDIR)trees.c - -@mv objs/trees.o $@ - -zutil.lo: $(SRCDIR)zutil.c - -@mkdir objs 2>/dev/null || test -d objs - $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/zutil.o $(SRCDIR)zutil.c - -@mv objs/zutil.o $@ - -compress.lo: $(SRCDIR)compress.c - -@mkdir objs 2>/dev/null || test -d objs - $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/compress.o $(SRCDIR)compress.c - -@mv objs/compress.o $@ - -uncompr.lo: $(SRCDIR)uncompr.c - -@mkdir objs 2>/dev/null || test -d objs - $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/uncompr.o $(SRCDIR)uncompr.c - -@mv objs/uncompr.o $@ - -gzclose.lo: $(SRCDIR)gzclose.c - -@mkdir objs 2>/dev/null || test -d objs - $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/gzclose.o $(SRCDIR)gzclose.c - -@mv objs/gzclose.o $@ - -gzlib.lo: $(SRCDIR)gzlib.c - -@mkdir objs 2>/dev/null || test -d objs - $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/gzlib.o $(SRCDIR)gzlib.c - -@mv objs/gzlib.o $@ - -gzread.lo: $(SRCDIR)gzread.c - -@mkdir objs 2>/dev/null || test -d objs - $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/gzread.o $(SRCDIR)gzread.c - -@mv objs/gzread.o $@ - -gzwrite.lo: $(SRCDIR)gzwrite.c - -@mkdir objs 2>/dev/null || test -d objs - $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/gzwrite.o $(SRCDIR)gzwrite.c - -@mv objs/gzwrite.o $@ - - -placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a - $(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS) - rm -f $(SHAREDLIB) $(SHAREDLIBM) - ln -s $@ $(SHAREDLIB) - ln -s $@ $(SHAREDLIBM) - -@rmdir objs - -example$(EXE): example.o $(STATICLIB) - $(CC) $(CFLAGS) -o $@ example.o $(TEST_LDFLAGS) - -minigzip$(EXE): minigzip.o $(STATICLIB) - $(CC) $(CFLAGS) -o $@ minigzip.o $(TEST_LDFLAGS) - -examplesh$(EXE): example.o $(SHAREDLIBV) - $(CC) $(CFLAGS) -o $@ example.o -L. $(SHAREDLIBV) - -minigzipsh$(EXE): minigzip.o $(SHAREDLIBV) - $(CC) $(CFLAGS) -o $@ minigzip.o -L. $(SHAREDLIBV) - -example64$(EXE): example64.o $(STATICLIB) - $(CC) $(CFLAGS) -o $@ example64.o $(TEST_LDFLAGS) - -minigzip64$(EXE): minigzip64.o $(STATICLIB) - $(CC) $(CFLAGS) -o $@ minigzip64.o $(TEST_LDFLAGS) - -install-libs: $(LIBS) - -@if [ ! -d $(DESTDIR)$(exec_prefix) ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi - -@if [ ! -d $(DESTDIR)$(libdir) ]; then mkdir -p $(DESTDIR)$(libdir); fi - -@if [ ! -d $(DESTDIR)$(sharedlibdir) ]; then mkdir -p $(DESTDIR)$(sharedlibdir); fi - -@if [ ! -d $(DESTDIR)$(man3dir) ]; then mkdir -p $(DESTDIR)$(man3dir); fi - -@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi - rm -f $(DESTDIR)$(libdir)/$(STATICLIB) - cp $(STATICLIB) $(DESTDIR)$(libdir) - chmod 644 $(DESTDIR)$(libdir)/$(STATICLIB) - -@($(RANLIB) $(DESTDIR)$(libdir)/libz.a || true) >/dev/null 2>&1 - -@if test -n "$(SHAREDLIBV)"; then \ - rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV); \ - cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir); \ - echo "cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)"; \ - chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV); \ - echo "chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV)"; \ - rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \ - ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB); \ - ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \ - ($(LDCONFIG) || true) >/dev/null 2>&1; \ - fi - rm -f $(DESTDIR)$(man3dir)/zlib.3 - cp $(SRCDIR)zlib.3 $(DESTDIR)$(man3dir) - chmod 644 $(DESTDIR)$(man3dir)/zlib.3 - rm -f $(DESTDIR)$(pkgconfigdir)/zlib.pc - cp zlib.pc $(DESTDIR)$(pkgconfigdir) - chmod 644 $(DESTDIR)$(pkgconfigdir)/zlib.pc -# The ranlib in install is needed on NeXTSTEP which checks file times -# ldconfig is for Linux - -install: install-libs - -@if [ ! -d $(DESTDIR)$(includedir) ]; then mkdir -p $(DESTDIR)$(includedir); fi - rm -f $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h - cp $(SRCDIR)zlib.h zconf.h $(DESTDIR)$(includedir) - chmod 644 $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h - -uninstall: - cd $(DESTDIR)$(includedir) && rm -f zlib.h zconf.h - cd $(DESTDIR)$(libdir) && rm -f libz.a; \ - if test -n "$(SHAREDLIBV)" -a -f $(SHAREDLIBV); then \ - rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \ - fi - cd $(DESTDIR)$(man3dir) && rm -f zlib.3 - cd $(DESTDIR)$(pkgconfigdir) && rm -f zlib.pc - -docs: zlib.3.pdf - -zlib.3.pdf: $(SRCDIR)zlib.3 - groff -mandoc -f H -T ps $(SRCDIR)zlib.3 | ps2pdf - $@ - -zconf.h.cmakein: $(SRCDIR)zconf.h.in - -@ TEMPFILE=zconfh_$$; \ - echo "/#define ZCONF_H/ a\\\\\n#cmakedefine Z_PREFIX\\\\\n#cmakedefine Z_HAVE_UNISTD_H\n" >> $$TEMPFILE &&\ - sed -f $$TEMPFILE $(SRCDIR)zconf.h.in > $@ &&\ - touch -r $(SRCDIR)zconf.h.in $@ &&\ - rm $$TEMPFILE - -zconf: $(SRCDIR)zconf.h.in - cp -p $(SRCDIR)zconf.h.in zconf.h - -mostlyclean: clean -clean: - rm -f *.o *.lo *~ \ - example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \ - example64$(EXE) minigzip64$(EXE) \ - infcover \ - libz.* foo.gz so_locations \ - _match.s maketree contrib/infback9/*.o - rm -rf objs - rm -f *.gcda *.gcno *.gcov - rm -f contrib/infback9/*.gcda contrib/infback9/*.gcno contrib/infback9/*.gcov - -maintainer-clean: distclean -distclean: clean zconf zconf.h.cmakein - rm -f Makefile zlib.pc configure.log - -@rm -f .DS_Store - @if [ -f Makefile.in ]; then \ - printf 'all:\n\t-@echo "Please use ./configure first. Thank you."\n' > Makefile ; \ - printf '\ndistclean:\n\tmake -f Makefile.in distclean\n' >> Makefile ; \ - touch -r $(SRCDIR)Makefile.in Makefile ; fi - -tags: - etags $(SRCDIR)*.[ch] - -adler32.o zutil.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h -gzclose.o gzlib.o gzread.o gzwrite.o: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h -compress.o example.o minigzip.o uncompr.o: $(SRCDIR)zlib.h zconf.h -crc32.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)crc32.h -deflate.o: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h -infback.o inflate.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h $(SRCDIR)inffixed.h -inffast.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h -inftrees.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h -trees.o: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h - -adler32.lo zutil.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h -gzclose.lo gzlib.lo gzread.lo gzwrite.lo: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h -compress.lo example.lo minigzip.lo uncompr.lo: $(SRCDIR)zlib.h zconf.h -crc32.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)crc32.h -deflate.lo: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h -infback.lo inflate.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h $(SRCDIR)inffixed.h -inffast.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h -inftrees.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h -trees.lo: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/README b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/README deleted file mode 100644 index 024b79d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/README +++ /dev/null @@ -1,118 +0,0 @@ -ZLIB DATA COMPRESSION LIBRARY - -zlib 1.2.12 is a general purpose data compression library. All the code is -thread safe. The data format used by the zlib library is described by RFCs -(Request for Comments) 1950 to 1952 in the files -http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and -rfc1952 (gzip format). - -All functions of the compression library are documented in the file zlib.h -(volunteer to write man pages welcome, contact zlib@gzip.org). A usage example -of the library is given in the file test/example.c which also tests that -the library is working correctly. Another example is given in the file -test/minigzip.c. The compression library itself is composed of all source -files in the root directory. - -To compile all files and run the test program, follow the instructions given at -the top of Makefile.in. In short "./configure; make test", and if that goes -well, "make install" should work for most flavors of Unix. For Windows, use -one of the special makefiles in win32/ or contrib/vstudio/ . For VMS, use -make_vms.com. - -Questions about zlib should be sent to , or to Gilles Vollant - for the Windows DLL version. The zlib home page is -http://zlib.net/ . Before reporting a problem, please check this site to -verify that you have the latest version of zlib; otherwise get the latest -version and check whether the problem still exists or not. - -PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help. - -Mark Nelson wrote an article about zlib for the Jan. 1997 -issue of Dr. Dobb's Journal; a copy of the article is available at -http://marknelson.us/1997/01/01/zlib-engine/ . - -The changes made in version 1.2.12 are documented in the file ChangeLog. - -Unsupported third party contributions are provided in directory contrib/ . - -zlib is available in Java using the java.util.zip package, documented at -http://java.sun.com/developer/technicalArticles/Programming/compression/ . - -A Perl interface to zlib written by Paul Marquess is available -at CPAN (Comprehensive Perl Archive Network) sites, including -http://search.cpan.org/~pmqs/IO-Compress-Zlib/ . - -A Python interface to zlib written by A.M. Kuchling is -available in Python 1.5 and later versions, see -http://docs.python.org/library/zlib.html . - -zlib is built into tcl: http://wiki.tcl.tk/4610 . - -An experimental package to read and write files in .zip format, written on top -of zlib by Gilles Vollant , is available in the -contrib/minizip directory of zlib. - - -Notes for some targets: - -- For Windows DLL versions, please see win32/DLL_FAQ.txt - -- For 64-bit Irix, deflate.c must be compiled without any optimization. With - -O, one libpng test fails. The test works in 32 bit mode (with the -n32 - compiler flag). The compiler bug has been reported to SGI. - -- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works - when compiled with cc. - -- On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is - necessary to get gzprintf working correctly. This is done by configure. - -- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with - other compilers. Use "make test" to check your compiler. - -- gzdopen is not supported on RISCOS or BEOS. - -- For PalmOs, see http://palmzlib.sourceforge.net/ - - -Acknowledgments: - - The deflate format used by zlib was defined by Phil Katz. The deflate and - zlib specifications were written by L. Peter Deutsch. Thanks to all the - people who reported problems and suggested various improvements in zlib; they - are too numerous to cite here. - -Copyright notice: - - (C) 1995-2022 Jean-loup Gailly and Mark Adler - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jean-loup Gailly Mark Adler - jloup@gzip.org madler@alumni.caltech.edu - -If you use the zlib library in a product, we would appreciate *not* receiving -lengthy legal documents to sign. The sources are provided for free but without -warranty of any kind. The library has been entirely written by Jean-loup -Gailly and Mark Adler; it does not include third-party code. We make all -contributions to and distributions of this project solely in our personal -capacity, and are not conveying any rights to any intellectual property of -any third parties. - -If you redistribute modified sources, we would appreciate that you include in -the file ChangeLog history information documenting your changes. Please read -the FAQ for more information on the distribution of modified source versions. diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/adler32.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/adler32.c deleted file mode 100644 index d0be438..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/adler32.c +++ /dev/null @@ -1,186 +0,0 @@ -/* adler32.c -- compute the Adler-32 checksum of a data stream - * Copyright (C) 1995-2011, 2016 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#include "zutil.h" - -local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); - -#define BASE 65521U /* largest prime smaller than 65536 */ -#define NMAX 5552 -/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ - -#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;} -#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); -#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); -#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); -#define DO16(buf) DO8(buf,0); DO8(buf,8); - -/* use NO_DIVIDE if your processor does not do division in hardware -- - try it both ways to see which is faster */ -#ifdef NO_DIVIDE -/* note that this assumes BASE is 65521, where 65536 % 65521 == 15 - (thank you to John Reiser for pointing this out) */ -# define CHOP(a) \ - do { \ - unsigned long tmp = a >> 16; \ - a &= 0xffffUL; \ - a += (tmp << 4) - tmp; \ - } while (0) -# define MOD28(a) \ - do { \ - CHOP(a); \ - if (a >= BASE) a -= BASE; \ - } while (0) -# define MOD(a) \ - do { \ - CHOP(a); \ - MOD28(a); \ - } while (0) -# define MOD63(a) \ - do { /* this assumes a is not negative */ \ - z_off64_t tmp = a >> 32; \ - a &= 0xffffffffL; \ - a += (tmp << 8) - (tmp << 5) + tmp; \ - tmp = a >> 16; \ - a &= 0xffffL; \ - a += (tmp << 4) - tmp; \ - tmp = a >> 16; \ - a &= 0xffffL; \ - a += (tmp << 4) - tmp; \ - if (a >= BASE) a -= BASE; \ - } while (0) -#else -# define MOD(a) a %= BASE -# define MOD28(a) a %= BASE -# define MOD63(a) a %= BASE -#endif - -/* ========================================================================= */ -uLong ZEXPORT adler32_z(adler, buf, len) - uLong adler; - const Bytef *buf; - z_size_t len; -{ - unsigned long sum2; - unsigned n; - - /* split Adler-32 into component sums */ - sum2 = (adler >> 16) & 0xffff; - adler &= 0xffff; - - /* in case user likes doing a byte at a time, keep it fast */ - if (len == 1) { - adler += buf[0]; - if (adler >= BASE) - adler -= BASE; - sum2 += adler; - if (sum2 >= BASE) - sum2 -= BASE; - return adler | (sum2 << 16); - } - - /* initial Adler-32 value (deferred check for len == 1 speed) */ - if (buf == Z_NULL) - return 1L; - - /* in case short lengths are provided, keep it somewhat fast */ - if (len < 16) { - while (len--) { - adler += *buf++; - sum2 += adler; - } - if (adler >= BASE) - adler -= BASE; - MOD28(sum2); /* only added so many BASE's */ - return adler | (sum2 << 16); - } - - /* do length NMAX blocks -- requires just one modulo operation */ - while (len >= NMAX) { - len -= NMAX; - n = NMAX / 16; /* NMAX is divisible by 16 */ - do { - DO16(buf); /* 16 sums unrolled */ - buf += 16; - } while (--n); - MOD(adler); - MOD(sum2); - } - - /* do remaining bytes (less than NMAX, still just one modulo) */ - if (len) { /* avoid modulos if none remaining */ - while (len >= 16) { - len -= 16; - DO16(buf); - buf += 16; - } - while (len--) { - adler += *buf++; - sum2 += adler; - } - MOD(adler); - MOD(sum2); - } - - /* return recombined sums */ - return adler | (sum2 << 16); -} - -/* ========================================================================= */ -uLong ZEXPORT adler32(adler, buf, len) - uLong adler; - const Bytef *buf; - uInt len; -{ - return adler32_z(adler, buf, len); -} - -/* ========================================================================= */ -local uLong adler32_combine_(adler1, adler2, len2) - uLong adler1; - uLong adler2; - z_off64_t len2; -{ - unsigned long sum1; - unsigned long sum2; - unsigned rem; - - /* for negative len, return invalid adler32 as a clue for debugging */ - if (len2 < 0) - return 0xffffffffUL; - - /* the derivation of this formula is left as an exercise for the reader */ - MOD63(len2); /* assumes len2 >= 0 */ - rem = (unsigned)len2; - sum1 = adler1 & 0xffff; - sum2 = rem * sum1; - MOD(sum2); - sum1 += (adler2 & 0xffff) + BASE - 1; - sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem; - if (sum1 >= BASE) sum1 -= BASE; - if (sum1 >= BASE) sum1 -= BASE; - if (sum2 >= ((unsigned long)BASE << 1)) sum2 -= ((unsigned long)BASE << 1); - if (sum2 >= BASE) sum2 -= BASE; - return sum1 | (sum2 << 16); -} - -/* ========================================================================= */ -uLong ZEXPORT adler32_combine(adler1, adler2, len2) - uLong adler1; - uLong adler2; - z_off_t len2; -{ - return adler32_combine_(adler1, adler2, len2); -} - -uLong ZEXPORT adler32_combine64(adler1, adler2, len2) - uLong adler1; - uLong adler2; - z_off64_t len2; -{ - return adler32_combine_(adler1, adler2, len2); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/amiga/Makefile.pup b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/amiga/Makefile.pup deleted file mode 100644 index 8940c12..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/amiga/Makefile.pup +++ /dev/null @@ -1,69 +0,0 @@ -# Amiga powerUP (TM) Makefile -# makefile for libpng and SAS C V6.58/7.00 PPC compiler -# Copyright (C) 1998 by Andreas R. Kleinert - -LIBNAME = libzip.a - -CC = scppc -CFLAGS = NOSTKCHK NOSINT OPTIMIZE OPTGO OPTPEEP OPTINLOCAL OPTINL \ - OPTLOOP OPTRDEP=8 OPTDEP=8 OPTCOMP=8 NOVER -AR = ppc-amigaos-ar cr -RANLIB = ppc-amigaos-ranlib -LD = ppc-amigaos-ld -r -LDFLAGS = -o -LDLIBS = LIB:scppc.a LIB:end.o -RM = delete quiet - -OBJS = adler32.o compress.o crc32.o gzclose.o gzlib.o gzread.o gzwrite.o \ - uncompr.o deflate.o trees.o zutil.o inflate.o infback.o inftrees.o inffast.o - -TEST_OBJS = example.o minigzip.o - -all: example minigzip - -check: test -test: all - example - echo hello world | minigzip | minigzip -d - -$(LIBNAME): $(OBJS) - $(AR) $@ $(OBJS) - -$(RANLIB) $@ - -example: example.o $(LIBNAME) - $(LD) $(LDFLAGS) $@ LIB:c_ppc.o $@.o $(LIBNAME) $(LDLIBS) - -minigzip: minigzip.o $(LIBNAME) - $(LD) $(LDFLAGS) $@ LIB:c_ppc.o $@.o $(LIBNAME) $(LDLIBS) - -mostlyclean: clean -clean: - $(RM) *.o example minigzip $(LIBNAME) foo.gz - -zip: - zip -ul9 zlib README ChangeLog Makefile Make????.??? Makefile.?? \ - descrip.mms *.[ch] - -tgz: - cd ..; tar cfz zlib/zlib.tgz zlib/README zlib/ChangeLog zlib/Makefile \ - zlib/Make????.??? zlib/Makefile.?? zlib/descrip.mms zlib/*.[ch] - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -adler32.o: zlib.h zconf.h -compress.o: zlib.h zconf.h -crc32.o: crc32.h zlib.h zconf.h -deflate.o: deflate.h zutil.h zlib.h zconf.h -example.o: zlib.h zconf.h -gzclose.o: zlib.h zconf.h gzguts.h -gzlib.o: zlib.h zconf.h gzguts.h -gzread.o: zlib.h zconf.h gzguts.h -gzwrite.o: zlib.h zconf.h gzguts.h -inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h -inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h -infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h -inftrees.o: zutil.h zlib.h zconf.h inftrees.h -minigzip.o: zlib.h zconf.h -trees.o: deflate.h zutil.h zlib.h zconf.h trees.h -uncompr.o: zlib.h zconf.h -zutil.o: zutil.h zlib.h zconf.h diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/amiga/Makefile.sas b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/amiga/Makefile.sas deleted file mode 100644 index 749e291..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/amiga/Makefile.sas +++ /dev/null @@ -1,68 +0,0 @@ -# SMakefile for zlib -# Modified from the standard UNIX Makefile Copyright Jean-loup Gailly -# Osma Ahvenlampi -# Amiga, SAS/C 6.56 & Smake - -CC=sc -CFLAGS=OPT -#CFLAGS=OPT CPU=68030 -#CFLAGS=DEBUG=LINE -LDFLAGS=LIB z.lib - -SCOPTIONS=OPTSCHED OPTINLINE OPTALIAS OPTTIME OPTINLOCAL STRMERGE \ - NOICONS PARMS=BOTH NOSTACKCHECK UTILLIB NOVERSION ERRORREXX \ - DEF=POSTINC - -OBJS = adler32.o compress.o crc32.o gzclose.o gzlib.o gzread.o gzwrite.o \ - uncompr.o deflate.o trees.o zutil.o inflate.o infback.o inftrees.o inffast.o - -TEST_OBJS = example.o minigzip.o - -all: SCOPTIONS example minigzip - -check: test -test: all - example - echo hello world | minigzip | minigzip -d - -install: z.lib - copy clone zlib.h zconf.h INCLUDE: - copy clone z.lib LIB: - -z.lib: $(OBJS) - oml z.lib r $(OBJS) - -example: example.o z.lib - $(CC) $(CFLAGS) LINK TO $@ example.o $(LDFLAGS) - -minigzip: minigzip.o z.lib - $(CC) $(CFLAGS) LINK TO $@ minigzip.o $(LDFLAGS) - -mostlyclean: clean -clean: - -delete force quiet example minigzip *.o z.lib foo.gz *.lnk SCOPTIONS - -SCOPTIONS: Makefile.sas - copy to $@ (uLong)max ? max : (uInt)left; - left -= stream.avail_out; - } - if (stream.avail_in == 0) { - stream.avail_in = sourceLen > (uLong)max ? max : (uInt)sourceLen; - sourceLen -= stream.avail_in; - } - err = deflate(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH); - } while (err == Z_OK); - - *destLen = stream.total_out; - deflateEnd(&stream); - return err == Z_STREAM_END ? Z_OK : err; -} - -/* =========================================================================== - */ -int ZEXPORT compress (dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; -{ - return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); -} - -/* =========================================================================== - If the default memLevel or windowBits for deflateInit() is changed, then - this function needs to be updated. - */ -uLong ZEXPORT compressBound (sourceLen) - uLong sourceLen; -{ - return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + - (sourceLen >> 25) + 13; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/configure b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/configure deleted file mode 100644 index 52ff4a0..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/configure +++ /dev/null @@ -1,927 +0,0 @@ -#!/bin/sh -# configure script for zlib. -# -# Normally configure builds both a static and a shared library. -# If you want to build just a static library, use: ./configure --static -# -# To impose specific compiler or flags or install directory, use for example: -# prefix=$HOME CC=cc CFLAGS="-O4" ./configure -# or for csh/tcsh users: -# (setenv prefix $HOME; setenv CC cc; setenv CFLAGS "-O4"; ./configure) - -# Incorrect settings of CC or CFLAGS may prevent creating a shared library. -# If you have problems, try without defining CC and CFLAGS before reporting -# an error. - -# start off configure.log -echo -------------------- >> configure.log -echo $0 $* >> configure.log -date >> configure.log - -# get source directory -SRCDIR=`dirname $0` -if test $SRCDIR = "."; then - ZINC="" - ZINCOUT="-I." - SRCDIR="" -else - ZINC='-include zconf.h' - ZINCOUT='-I. -I$(SRCDIR)' - SRCDIR="$SRCDIR/" -fi - -# set command prefix for cross-compilation -if [ -n "${CHOST}" ]; then - uname="`echo "${CHOST}" | sed -e 's/^[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)$/\1/' -e 's/^[^-]*-[^-]*-\([^-]*\)-.*$/\1/'`" - CROSS_PREFIX="${CHOST}-" -fi - -# destination name for static library -STATICLIB=libz.a - -# extract zlib version numbers from zlib.h -VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}zlib.h` -VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < ${SRCDIR}zlib.h` -VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h` -VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h` - -# establish commands for library building -if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then - AR=${AR-"${CROSS_PREFIX}ar"} - test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log -else - AR=${AR-"ar"} - test -n "${CROSS_PREFIX}" && echo Using ${AR} | tee -a configure.log -fi -ARFLAGS=${ARFLAGS-"rc"} -if "${CROSS_PREFIX}ranlib" --version >/dev/null 2>/dev/null || test $? -lt 126; then - RANLIB=${RANLIB-"${CROSS_PREFIX}ranlib"} - test -n "${CROSS_PREFIX}" && echo Using ${RANLIB} | tee -a configure.log -else - RANLIB=${RANLIB-"ranlib"} -fi -if "${CROSS_PREFIX}nm" --version >/dev/null 2>/dev/null || test $? -lt 126; then - NM=${NM-"${CROSS_PREFIX}nm"} - test -n "${CROSS_PREFIX}" && echo Using ${NM} | tee -a configure.log -else - NM=${NM-"nm"} -fi - -# set defaults before processing command line options -LDCONFIG=${LDCONFIG-"ldconfig"} -LDSHAREDLIBC="${LDSHAREDLIBC--lc}" -ARCHS= -prefix=${prefix-/usr/local} -exec_prefix=${exec_prefix-'${prefix}'} -libdir=${libdir-'${exec_prefix}/lib'} -sharedlibdir=${sharedlibdir-'${libdir}'} -includedir=${includedir-'${prefix}/include'} -mandir=${mandir-'${prefix}/share/man'} -shared_ext='.so' -shared=1 -solo=0 -cover=0 -zprefix=0 -zconst=0 -build64=0 -gcc=0 -warn=0 -debug=0 -sanitize=0 -old_cc="$CC" -old_cflags="$CFLAGS" -OBJC='$(OBJZ) $(OBJG)' -PIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)' - -# leave this script, optionally in a bad way -leave() -{ - if test "$*" != "0"; then - echo "** $0 aborting." | tee -a configure.log - fi - rm -f $test.[co] $test $test$shared_ext $test.gcno ./--version - echo -------------------- >> configure.log - echo >> configure.log - echo >> configure.log - exit $1 -} - -# process command line options -while test $# -ge 1 -do -case "$1" in - -h* | --help) - echo 'usage:' | tee -a configure.log - echo ' configure [--const] [--zprefix] [--prefix=PREFIX] [--eprefix=EXPREFIX]' | tee -a configure.log - echo ' [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' | tee -a configure.log - echo ' [--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]' | tee -a configure.log - exit 0 ;; - -p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;; - -e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;; - -l*=* | --libdir=*) libdir=`echo $1 | sed 's/.*=//'`; shift ;; - --sharedlibdir=*) sharedlibdir=`echo $1 | sed 's/.*=//'`; shift ;; - -i*=* | --includedir=*) includedir=`echo $1 | sed 's/.*=//'`;shift ;; - -u*=* | --uname=*) uname=`echo $1 | sed 's/.*=//'`;shift ;; - -p* | --prefix) prefix="$2"; shift; shift ;; - -e* | --eprefix) exec_prefix="$2"; shift; shift ;; - -l* | --libdir) libdir="$2"; shift; shift ;; - -i* | --includedir) includedir="$2"; shift; shift ;; - -s* | --shared | --enable-shared) shared=1; shift ;; - -t | --static) shared=0; shift ;; - --solo) solo=1; shift ;; - --cover) cover=1; shift ;; - -z* | --zprefix) zprefix=1; shift ;; - -6* | --64) build64=1; shift ;; - -a*=* | --archs=*) ARCHS=`echo $1 | sed 's/.*=//'`; shift ;; - --sysconfdir=*) echo "ignored option: --sysconfdir" | tee -a configure.log; shift ;; - --localstatedir=*) echo "ignored option: --localstatedir" | tee -a configure.log; shift ;; - -c* | --const) zconst=1; shift ;; - -w* | --warn) warn=1; shift ;; - -d* | --debug) debug=1; shift ;; - --sanitize) sanitize=1; shift ;; - *) - echo "unknown option: $1" | tee -a configure.log - echo "$0 --help for help" | tee -a configure.log - leave 1;; - esac -done - -# temporary file name -test=ztest$$ - -# put arguments in log, also put test file in log if used in arguments -show() -{ - case "$*" in - *$test.c*) - echo === $test.c === >> configure.log - cat $test.c >> configure.log - echo === >> configure.log;; - esac - echo $* >> configure.log -} - -# check for gcc vs. cc and set compile and link flags based on the system identified by uname -cat > $test.c </dev/null 2>&1; then - cc=${CROSS_PREFIX}gcc - else - cc=${CROSS_PREFIX}cc - fi -fi -cflags=${CFLAGS-"-O3"} -# to force the asm version use: CFLAGS="-O3 -DASMV" ./configure -case "$cc" in - *gcc*) gcc=1 ;; - *clang*) gcc=1 ;; -esac -case `$cc -v 2>&1` in - *gcc*) gcc=1 ;; - *clang*) gcc=1 ;; -esac - -show $cc -c $test.c -if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then - echo ... using gcc >> configure.log - CC="$cc" - CFLAGS="${CFLAGS--O3}" - SFLAGS="${CFLAGS--O3} -fPIC" - if test "$ARCHS"; then - CFLAGS="${CFLAGS} ${ARCHS}" - LDFLAGS="${LDFLAGS} ${ARCHS}" - fi - if test $build64 -eq 1; then - CFLAGS="${CFLAGS} -m64" - SFLAGS="${SFLAGS} -m64" - fi - if test "$warn" -eq 1; then - if test "$zconst" -eq 1; then - CFLAGS="${CFLAGS} -Wall -Wextra -Wcast-qual -pedantic -DZLIB_CONST" - else - CFLAGS="${CFLAGS} -Wall -Wextra -pedantic" - fi - fi - if test $sanitize -eq 1; then - CFLAGS="${CFLAGS} -fsanitize=address" - fi - if test $debug -eq 1; then - CFLAGS="${CFLAGS} -DZLIB_DEBUG" - SFLAGS="${SFLAGS} -DZLIB_DEBUG" - fi - if test -z "$uname"; then - uname=`(uname -s || echo unknown) 2>/dev/null` - fi - case "$uname" in - Linux* | linux* | GNU | GNU/* | solaris*) - LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} ;; - *BSD | *bsd* | DragonFly) - LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} - LDCONFIG="ldconfig -m" ;; - CYGWIN* | Cygwin* | cygwin* | OS/2*) - EXE='.exe' ;; - MINGW* | mingw*) -# temporary bypass - rm -f $test.[co] $test $test$shared_ext - echo "Please use win32/Makefile.gcc instead." | tee -a configure.log - leave 1 - LDSHARED=${LDSHARED-"$cc -shared"} - LDSHAREDLIBC="" - EXE='.exe' ;; - QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4 - # (alain.bonnefoy@icbt.com) - LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"} ;; - HP-UX*) - LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"} - case `(uname -m || echo unknown) 2>/dev/null` in - ia64) - shared_ext='.so' - SHAREDLIB='libz.so' ;; - *) - shared_ext='.sl' - SHAREDLIB='libz.sl' ;; - esac ;; - Darwin* | darwin*) - shared_ext='.dylib' - SHAREDLIB=libz$shared_ext - SHAREDLIBV=libz.$VER$shared_ext - SHAREDLIBM=libz.$VER1$shared_ext - LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"} - if libtool -V 2>&1 | grep Apple > /dev/null; then - AR="libtool" - else - AR="/usr/bin/libtool" - fi - ARFLAGS="-o" ;; - *) LDSHARED=${LDSHARED-"$cc -shared"} ;; - esac -else - # find system name and corresponding cc options - CC=${CC-cc} - gcc=0 - echo ... using $CC >> configure.log - if test -z "$uname"; then - uname=`(uname -sr || echo unknown) 2>/dev/null` - fi - case "$uname" in - HP-UX*) SFLAGS=${CFLAGS-"-O +z"} - CFLAGS=${CFLAGS-"-O"} -# LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"} - LDSHARED=${LDSHARED-"ld -b"} - case `(uname -m || echo unknown) 2>/dev/null` in - ia64) - shared_ext='.so' - SHAREDLIB='libz.so' ;; - *) - shared_ext='.sl' - SHAREDLIB='libz.sl' ;; - esac ;; - IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."} - CFLAGS=${CFLAGS-"-ansi -O2"} - LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;; - OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"} - CFLAGS=${CFLAGS-"-O -std1"} - LDFLAGS="${LDFLAGS} -Wl,-rpath,." - LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"} ;; - OSF1*) SFLAGS=${CFLAGS-"-O -std1"} - CFLAGS=${CFLAGS-"-O -std1"} - LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so.1"} ;; - QNX*) SFLAGS=${CFLAGS-"-4 -O"} - CFLAGS=${CFLAGS-"-4 -O"} - LDSHARED=${LDSHARED-"cc"} - RANLIB=${RANLIB-"true"} - AR="cc" - ARFLAGS="-A" ;; - SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "} - CFLAGS=${CFLAGS-"-O3"} - LDSHARED=${LDSHARED-"cc -dy -KPIC -G"} ;; - SunOS\ 5* | solaris*) - LDSHARED=${LDSHARED-"cc -G -h libz$shared_ext.$VER1"} - SFLAGS=${CFLAGS-"-fast -KPIC"} - CFLAGS=${CFLAGS-"-fast"} - if test $build64 -eq 1; then - # old versions of SunPRO/Workshop/Studio don't support -m64, - # but newer ones do. Check for it. - flag64=`$CC -flags | egrep -- '^-m64'` - if test x"$flag64" != x"" ; then - CFLAGS="${CFLAGS} -m64" - SFLAGS="${SFLAGS} -m64" - else - case `(uname -m || echo unknown) 2>/dev/null` in - i86*) - SFLAGS="$SFLAGS -xarch=amd64" - CFLAGS="$CFLAGS -xarch=amd64" ;; - *) - SFLAGS="$SFLAGS -xarch=v9" - CFLAGS="$CFLAGS -xarch=v9" ;; - esac - fi - fi - if test -n "$ZINC"; then - ZINC='-I- -I. -I$(SRCDIR)' - fi - ;; - SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"} - CFLAGS=${CFLAGS-"-O2"} - LDSHARED=${LDSHARED-"ld"} ;; - SunStudio\ 9*) SFLAGS=${CFLAGS-"-fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"} - CFLAGS=${CFLAGS-"-fast -xtarget=ultra3 -xarch=v9b"} - LDSHARED=${LDSHARED-"cc -xarch=v9b"} ;; - UNIX_System_V\ 4.2.0) - SFLAGS=${CFLAGS-"-KPIC -O"} - CFLAGS=${CFLAGS-"-O"} - LDSHARED=${LDSHARED-"cc -G"} ;; - UNIX_SV\ 4.2MP) - SFLAGS=${CFLAGS-"-Kconform_pic -O"} - CFLAGS=${CFLAGS-"-O"} - LDSHARED=${LDSHARED-"cc -G"} ;; - OpenUNIX\ 5) - SFLAGS=${CFLAGS-"-KPIC -O"} - CFLAGS=${CFLAGS-"-O"} - LDSHARED=${LDSHARED-"cc -G"} ;; - AIX*) # Courtesy of dbakker@arrayasolutions.com - SFLAGS=${CFLAGS-"-O -qmaxmem=8192"} - CFLAGS=${CFLAGS-"-O -qmaxmem=8192"} - LDSHARED=${LDSHARED-"xlc -G"} ;; - # send working options for other systems to zlib@gzip.org - *) SFLAGS=${CFLAGS-"-O"} - CFLAGS=${CFLAGS-"-O"} - LDSHARED=${LDSHARED-"cc -shared"} ;; - esac -fi - -# destination names for shared library if not defined above -SHAREDLIB=${SHAREDLIB-"libz$shared_ext"} -SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"} -SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"} - -echo >> configure.log - -# define functions for testing compiler and library characteristics and logging the results - -cat > $test.c </dev/null; then - try() - { - show $* - test "`( $* ) 2>&1 | tee -a configure.log`" = "" - } - echo - using any output from compiler to indicate an error >> configure.log -else - try() - { - show $* - got=`( $* ) 2>&1` - ret=$? - if test "$got" != ""; then - printf "%s\n" "$got" >> configure.log - fi - if test $ret -ne 0; then - echo "(exit code "$ret")" >> configure.log - fi - return $ret - } -fi - -tryboth() -{ - show $* - got=`( $* ) 2>&1` - ret=$? - if test "$got" != ""; then - printf "%s\n" "$got" >> configure.log - fi - if test $ret -ne 0; then - echo "(exit code "$ret")" >> configure.log - return $ret - fi - test "$got" = "" -} - -cat > $test.c << EOF -int foo() { return 0; } -EOF -echo "Checking for obsessive-compulsive compiler options..." >> configure.log -if try $CC -c $CFLAGS $test.c; then - : -else - echo "Compiler error reporting is too harsh for $0 (perhaps remove -Werror)." | tee -a configure.log - leave 1 -fi - -echo >> configure.log - -# see if shared library build supported -cat > $test.c <> configure.log - show "$NM $test.o | grep _hello" - if test "`$NM $test.o | grep _hello | tee -a configure.log`" = ""; then - CPP="$CPP -DNO_UNDERLINE" - echo Checking for underline in external names... No. | tee -a configure.log - else - echo Checking for underline in external names... Yes. | tee -a configure.log - fi ;; -esac - -echo >> configure.log - -# check for size_t -cat > $test.c < -#include -size_t dummy = 0; -EOF -if try $CC -c $CFLAGS $test.c; then - echo "Checking for size_t... Yes." | tee -a configure.log -else - echo "Checking for size_t... No." | tee -a configure.log - # find a size_t integer type - # check for long long - cat > $test.c << EOF -long long dummy = 0; -EOF - if try $CC -c $CFLAGS $test.c; then - echo "Checking for long long... Yes." | tee -a configure.log - cat > $test.c < -int main(void) { - if (sizeof(void *) <= sizeof(int)) puts("int"); - else if (sizeof(void *) <= sizeof(long)) puts("long"); - else puts("z_longlong"); - return 0; -} -EOF - else - echo "Checking for long long... No." | tee -a configure.log - cat > $test.c < -int main(void) { - if (sizeof(void *) <= sizeof(int)) puts("int"); - else puts("long"); - return 0; -} -EOF - fi - if try $CC $CFLAGS -o $test $test.c; then - sizet=`./$test` - echo "Checking for a pointer-size integer type..." $sizet"." | tee -a configure.log - CFLAGS="${CFLAGS} -DNO_SIZE_T=${sizet}" - SFLAGS="${SFLAGS} -DNO_SIZE_T=${sizet}" - else - echo "Checking for a pointer-size integer type... not found." | tee -a configure.log - fi -fi - -echo >> configure.log - -# check for large file support, and if none, check for fseeko() -cat > $test.c < -off64_t dummy = 0; -EOF -if try $CC -c $CFLAGS -D_LARGEFILE64_SOURCE=1 $test.c; then - CFLAGS="${CFLAGS} -D_LARGEFILE64_SOURCE=1" - SFLAGS="${SFLAGS} -D_LARGEFILE64_SOURCE=1" - ALL="${ALL} all64" - TEST="${TEST} test64" - echo "Checking for off64_t... Yes." | tee -a configure.log - echo "Checking for fseeko... Yes." | tee -a configure.log -else - echo "Checking for off64_t... No." | tee -a configure.log - echo >> configure.log - cat > $test.c < -int main(void) { - fseeko(NULL, 0, 0); - return 0; -} -EOF - if try $CC $CFLAGS -o $test $test.c; then - echo "Checking for fseeko... Yes." | tee -a configure.log - else - CFLAGS="${CFLAGS} -DNO_FSEEKO" - SFLAGS="${SFLAGS} -DNO_FSEEKO" - echo "Checking for fseeko... No." | tee -a configure.log - fi -fi - -echo >> configure.log - -# check for strerror() for use by gz* functions -cat > $test.c < -#include -int main() { return strlen(strerror(errno)); } -EOF -if try $CC $CFLAGS -o $test $test.c; then - echo "Checking for strerror... Yes." | tee -a configure.log -else - CFLAGS="${CFLAGS} -DNO_STRERROR" - SFLAGS="${SFLAGS} -DNO_STRERROR" - echo "Checking for strerror... No." | tee -a configure.log -fi - -# copy clean zconf.h for subsequent edits -cp -p ${SRCDIR}zconf.h.in zconf.h - -echo >> configure.log - -# check for unistd.h and save result in zconf.h -cat > $test.c < -int main() { return 0; } -EOF -if try $CC -c $CFLAGS $test.c; then - sed < zconf.h "/^#ifdef HAVE_UNISTD_H.* may be/s/def HAVE_UNISTD_H\(.*\) may be/ 1\1 was/" > zconf.temp.h - mv zconf.temp.h zconf.h - echo "Checking for unistd.h... Yes." | tee -a configure.log -else - echo "Checking for unistd.h... No." | tee -a configure.log -fi - -echo >> configure.log - -# check for stdarg.h and save result in zconf.h -cat > $test.c < -int main() { return 0; } -EOF -if try $CC -c $CFLAGS $test.c; then - sed < zconf.h "/^#ifdef HAVE_STDARG_H.* may be/s/def HAVE_STDARG_H\(.*\) may be/ 1\1 was/" > zconf.temp.h - mv zconf.temp.h zconf.h - echo "Checking for stdarg.h... Yes." | tee -a configure.log -else - echo "Checking for stdarg.h... No." | tee -a configure.log -fi - -# if the z_ prefix was requested, save that in zconf.h -if test $zprefix -eq 1; then - sed < zconf.h "/#ifdef Z_PREFIX.* may be/s/def Z_PREFIX\(.*\) may be/ 1\1 was/" > zconf.temp.h - mv zconf.temp.h zconf.h - echo >> configure.log - echo "Using z_ prefix on all symbols." | tee -a configure.log -fi - -# if --solo compilation was requested, save that in zconf.h and remove gz stuff from object lists -if test $solo -eq 1; then - sed '/#define ZCONF_H/a\ -#define Z_SOLO - -' < zconf.h > zconf.temp.h - mv zconf.temp.h zconf.h -OBJC='$(OBJZ)' -PIC_OBJC='$(PIC_OBJZ)' -fi - -# if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X -if test $cover -eq 1; then - CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage" - if test -n "$GCC_CLASSIC"; then - CC=$GCC_CLASSIC - fi -fi - -echo >> configure.log - -# conduct a series of tests to resolve eight possible cases of using "vs" or "s" printf functions -# (using stdarg or not), with or without "n" (proving size of buffer), and with or without a -# return value. The most secure result is vsnprintf() with a return value. snprintf() with a -# return value is secure as well, but then gzprintf() will be limited to 20 arguments. -cat > $test.c < -#include -#include "zconf.h" -int main() -{ -#ifndef STDC - choke me -#endif - return 0; -} -EOF -if try $CC -c $CFLAGS $test.c; then - echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()." | tee -a configure.log - - echo >> configure.log - cat > $test.c < -#include -int mytest(const char *fmt, ...) -{ - char buf[20]; - va_list ap; - va_start(ap, fmt); - vsnprintf(buf, sizeof(buf), fmt, ap); - va_end(ap); - return 0; -} -int main() -{ - return (mytest("Hello%d\n", 1)); -} -EOF - if try $CC $CFLAGS -o $test $test.c; then - echo "Checking for vsnprintf() in stdio.h... Yes." | tee -a configure.log - - echo >> configure.log - cat >$test.c < -#include -int mytest(const char *fmt, ...) -{ - int n; - char buf[20]; - va_list ap; - va_start(ap, fmt); - n = vsnprintf(buf, sizeof(buf), fmt, ap); - va_end(ap); - return n; -} -int main() -{ - return (mytest("Hello%d\n", 1)); -} -EOF - - if try $CC -c $CFLAGS $test.c; then - echo "Checking for return value of vsnprintf()... Yes." | tee -a configure.log - else - CFLAGS="$CFLAGS -DHAS_vsnprintf_void" - SFLAGS="$SFLAGS -DHAS_vsnprintf_void" - echo "Checking for return value of vsnprintf()... No." | tee -a configure.log - echo " WARNING: apparently vsnprintf() does not return a value. zlib" | tee -a configure.log - echo " can build but will be open to possible string-format security" | tee -a configure.log - echo " vulnerabilities." | tee -a configure.log - fi - else - CFLAGS="$CFLAGS -DNO_vsnprintf" - SFLAGS="$SFLAGS -DNO_vsnprintf" - echo "Checking for vsnprintf() in stdio.h... No." | tee -a configure.log - echo " WARNING: vsnprintf() not found, falling back to vsprintf(). zlib" | tee -a configure.log - echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log - echo " vulnerabilities." | tee -a configure.log - - echo >> configure.log - cat >$test.c < -#include -int mytest(const char *fmt, ...) -{ - int n; - char buf[20]; - va_list ap; - va_start(ap, fmt); - n = vsprintf(buf, fmt, ap); - va_end(ap); - return n; -} -int main() -{ - return (mytest("Hello%d\n", 1)); -} -EOF - - if try $CC -c $CFLAGS $test.c; then - echo "Checking for return value of vsprintf()... Yes." | tee -a configure.log - else - CFLAGS="$CFLAGS -DHAS_vsprintf_void" - SFLAGS="$SFLAGS -DHAS_vsprintf_void" - echo "Checking for return value of vsprintf()... No." | tee -a configure.log - echo " WARNING: apparently vsprintf() does not return a value. zlib" | tee -a configure.log - echo " can build but will be open to possible string-format security" | tee -a configure.log - echo " vulnerabilities." | tee -a configure.log - fi - fi -else - echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()." | tee -a configure.log - - echo >> configure.log - cat >$test.c < -int mytest() -{ - char buf[20]; - snprintf(buf, sizeof(buf), "%s", "foo"); - return 0; -} -int main() -{ - return (mytest()); -} -EOF - - if try $CC $CFLAGS -o $test $test.c; then - echo "Checking for snprintf() in stdio.h... Yes." | tee -a configure.log - - echo >> configure.log - cat >$test.c < -int mytest() -{ - char buf[20]; - return snprintf(buf, sizeof(buf), "%s", "foo"); -} -int main() -{ - return (mytest()); -} -EOF - - if try $CC -c $CFLAGS $test.c; then - echo "Checking for return value of snprintf()... Yes." | tee -a configure.log - else - CFLAGS="$CFLAGS -DHAS_snprintf_void" - SFLAGS="$SFLAGS -DHAS_snprintf_void" - echo "Checking for return value of snprintf()... No." | tee -a configure.log - echo " WARNING: apparently snprintf() does not return a value. zlib" | tee -a configure.log - echo " can build but will be open to possible string-format security" | tee -a configure.log - echo " vulnerabilities." | tee -a configure.log - fi - else - CFLAGS="$CFLAGS -DNO_snprintf" - SFLAGS="$SFLAGS -DNO_snprintf" - echo "Checking for snprintf() in stdio.h... No." | tee -a configure.log - echo " WARNING: snprintf() not found, falling back to sprintf(). zlib" | tee -a configure.log - echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log - echo " vulnerabilities." | tee -a configure.log - - echo >> configure.log - cat >$test.c < -int mytest() -{ - char buf[20]; - return sprintf(buf, "%s", "foo"); -} -int main() -{ - return (mytest()); -} -EOF - - if try $CC -c $CFLAGS $test.c; then - echo "Checking for return value of sprintf()... Yes." | tee -a configure.log - else - CFLAGS="$CFLAGS -DHAS_sprintf_void" - SFLAGS="$SFLAGS -DHAS_sprintf_void" - echo "Checking for return value of sprintf()... No." | tee -a configure.log - echo " WARNING: apparently sprintf() does not return a value. zlib" | tee -a configure.log - echo " can build but will be open to possible string-format security" | tee -a configure.log - echo " vulnerabilities." | tee -a configure.log - fi - fi -fi - -# see if we can hide zlib internal symbols that are linked between separate source files -if test "$gcc" -eq 1; then - echo >> configure.log - cat > $test.c <> configure.log -echo ALL = $ALL >> configure.log -echo AR = $AR >> configure.log -echo ARFLAGS = $ARFLAGS >> configure.log -echo CC = $CC >> configure.log -echo CFLAGS = $CFLAGS >> configure.log -echo CPP = $CPP >> configure.log -echo EXE = $EXE >> configure.log -echo LDCONFIG = $LDCONFIG >> configure.log -echo LDFLAGS = $LDFLAGS >> configure.log -echo LDSHARED = $LDSHARED >> configure.log -echo LDSHAREDLIBC = $LDSHAREDLIBC >> configure.log -echo OBJC = $OBJC >> configure.log -echo PIC_OBJC = $PIC_OBJC >> configure.log -echo RANLIB = $RANLIB >> configure.log -echo SFLAGS = $SFLAGS >> configure.log -echo SHAREDLIB = $SHAREDLIB >> configure.log -echo SHAREDLIBM = $SHAREDLIBM >> configure.log -echo SHAREDLIBV = $SHAREDLIBV >> configure.log -echo STATICLIB = $STATICLIB >> configure.log -echo TEST = $TEST >> configure.log -echo VER = $VER >> configure.log -echo SRCDIR = $SRCDIR >> configure.log -echo exec_prefix = $exec_prefix >> configure.log -echo includedir = $includedir >> configure.log -echo libdir = $libdir >> configure.log -echo mandir = $mandir >> configure.log -echo prefix = $prefix >> configure.log -echo sharedlibdir = $sharedlibdir >> configure.log -echo uname = $uname >> configure.log - -# udpate Makefile with the configure results -sed < ${SRCDIR}Makefile.in " -/^CC *=/s#=.*#=$CC# -/^CFLAGS *=/s#=.*#=$CFLAGS# -/^SFLAGS *=/s#=.*#=$SFLAGS# -/^LDFLAGS *=/s#=.*#=$LDFLAGS# -/^LDSHARED *=/s#=.*#=$LDSHARED# -/^CPP *=/s#=.*#=$CPP# -/^STATICLIB *=/s#=.*#=$STATICLIB# -/^SHAREDLIB *=/s#=.*#=$SHAREDLIB# -/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV# -/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM# -/^AR *=/s#=.*#=$AR# -/^ARFLAGS *=/s#=.*#=$ARFLAGS# -/^RANLIB *=/s#=.*#=$RANLIB# -/^LDCONFIG *=/s#=.*#=$LDCONFIG# -/^LDSHAREDLIBC *=/s#=.*#=$LDSHAREDLIBC# -/^EXE *=/s#=.*#=$EXE# -/^SRCDIR *=/s#=.*#=$SRCDIR# -/^ZINC *=/s#=.*#=$ZINC# -/^ZINCOUT *=/s#=.*#=$ZINCOUT# -/^prefix *=/s#=.*#=$prefix# -/^exec_prefix *=/s#=.*#=$exec_prefix# -/^libdir *=/s#=.*#=$libdir# -/^sharedlibdir *=/s#=.*#=$sharedlibdir# -/^includedir *=/s#=.*#=$includedir# -/^mandir *=/s#=.*#=$mandir# -/^OBJC *=/s#=.*#= $OBJC# -/^PIC_OBJC *=/s#=.*#= $PIC_OBJC# -/^all: */s#:.*#: $ALL# -/^test: */s#:.*#: $TEST# -" > Makefile - -# create zlib.pc with the configure results -sed < ${SRCDIR}zlib.pc.in " -/^CC *=/s#=.*#=$CC# -/^CFLAGS *=/s#=.*#=$CFLAGS# -/^CPP *=/s#=.*#=$CPP# -/^LDSHARED *=/s#=.*#=$LDSHARED# -/^STATICLIB *=/s#=.*#=$STATICLIB# -/^SHAREDLIB *=/s#=.*#=$SHAREDLIB# -/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV# -/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM# -/^AR *=/s#=.*#=$AR# -/^ARFLAGS *=/s#=.*#=$ARFLAGS# -/^RANLIB *=/s#=.*#=$RANLIB# -/^EXE *=/s#=.*#=$EXE# -/^prefix *=/s#=.*#=$prefix# -/^exec_prefix *=/s#=.*#=$exec_prefix# -/^libdir *=/s#=.*#=$libdir# -/^sharedlibdir *=/s#=.*#=$sharedlibdir# -/^includedir *=/s#=.*#=$includedir# -/^mandir *=/s#=.*#=$mandir# -/^LDFLAGS *=/s#=.*#=$LDFLAGS# -" | sed -e " -s/\@VERSION\@/$VER/g; -" > zlib.pc - -# done -leave 0 diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/README.contrib b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/README.contrib deleted file mode 100644 index 335e435..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/README.contrib +++ /dev/null @@ -1,57 +0,0 @@ -All files under this contrib directory are UNSUPPORTED. There were -provided by users of zlib and were not tested by the authors of zlib. -Use at your own risk. Please contact the authors of the contributions -for help about these, not the zlib authors. Thanks. - - -ada/ by Dmitriy Anisimkov - Support for Ada - See http://zlib-ada.sourceforge.net/ - -blast/ by Mark Adler - Decompressor for output of PKWare Data Compression Library (DCL) - -delphi/ by Cosmin Truta - Support for Delphi and C++ Builder - -dotzlib/ by Henrik Ravn - Support for Microsoft .Net and Visual C++ .Net - -gcc_gvmat64/by Gilles Vollant - GCC Version of x86 64-bit (AMD64 and Intel EM64t) code for x64 - assembler to replace longest_match() and inflate_fast() - -infback9/ by Mark Adler - Unsupported diffs to infback to decode the deflate64 format - -iostream/ by Kevin Ruland - A C++ I/O streams interface to the zlib gz* functions - -iostream2/ by Tyge Løvset - Another C++ I/O streams interface - -iostream3/ by Ludwig Schwardt - and Kevin Ruland - Yet another C++ I/O streams interface - -minizip/ by Gilles Vollant - Mini zip and unzip based on zlib - Includes Zip64 support by Mathias Svensson - See http://www.winimage.com/zLibDll/minizip.html - -pascal/ by Bob Dellaca et al. - Support for Pascal - -puff/ by Mark Adler - Small, low memory usage inflate. Also serves to provide an - unambiguous description of the deflate format. - -testzlib/ by Gilles Vollant - Example of the use of zlib - -untgz/ by Pedro A. Aranda Gutierrez - A very simple tar.gz file extractor using zlib - -vstudio/ by Gilles Vollant - Building a minizip-enhanced zlib with Microsoft Visual Studio - Includes vc11 from kreuzerkrieg and vc12 from davispuh diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/buffer_demo.adb b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/buffer_demo.adb deleted file mode 100644 index 46b8638..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/buffer_demo.adb +++ /dev/null @@ -1,106 +0,0 @@ ----------------------------------------------------------------- --- ZLib for Ada thick binding. -- --- -- --- Copyright (C) 2002-2004 Dmitriy Anisimkov -- --- -- --- Open source license information is in the zlib.ads file. -- ----------------------------------------------------------------- --- --- $Id: buffer_demo.adb,v 1.3 2004/09/06 06:55:35 vagul Exp $ - --- This demo program provided by Dr Steve Sangwine --- --- Demonstration of a problem with Zlib-Ada (already fixed) when a buffer --- of exactly the correct size is used for decompressed data, and the last --- few bytes passed in to Zlib are checksum bytes. - --- This program compresses a string of text, and then decompresses the --- compressed text into a buffer of the same size as the original text. - -with Ada.Streams; use Ada.Streams; -with Ada.Text_IO; - -with ZLib; use ZLib; - -procedure Buffer_Demo is - EOL : Character renames ASCII.LF; - Text : constant String - := "Four score and seven years ago our fathers brought forth," & EOL & - "upon this continent, a new nation, conceived in liberty," & EOL & - "and dedicated to the proposition that `all men are created equal'."; - - Source : Stream_Element_Array (1 .. Text'Length); - for Source'Address use Text'Address; - -begin - Ada.Text_IO.Put (Text); - Ada.Text_IO.New_Line; - Ada.Text_IO.Put_Line - ("Uncompressed size : " & Positive'Image (Text'Length) & " bytes"); - - declare - Compressed_Data : Stream_Element_Array (1 .. Text'Length); - L : Stream_Element_Offset; - begin - Compress : declare - Compressor : Filter_Type; - I : Stream_Element_Offset; - begin - Deflate_Init (Compressor); - - -- Compress the whole of T at once. - - Translate (Compressor, Source, I, Compressed_Data, L, Finish); - pragma Assert (I = Source'Last); - - Close (Compressor); - - Ada.Text_IO.Put_Line - ("Compressed size : " - & Stream_Element_Offset'Image (L) & " bytes"); - end Compress; - - -- Now we decompress the data, passing short blocks of data to Zlib - -- (because this demonstrates the problem - the last block passed will - -- contain checksum information and there will be no output, only a - -- check inside Zlib that the checksum is correct). - - Decompress : declare - Decompressor : Filter_Type; - - Uncompressed_Data : Stream_Element_Array (1 .. Text'Length); - - Block_Size : constant := 4; - -- This makes sure that the last block contains - -- only Adler checksum data. - - P : Stream_Element_Offset := Compressed_Data'First - 1; - O : Stream_Element_Offset; - begin - Inflate_Init (Decompressor); - - loop - Translate - (Decompressor, - Compressed_Data - (P + 1 .. Stream_Element_Offset'Min (P + Block_Size, L)), - P, - Uncompressed_Data - (Total_Out (Decompressor) + 1 .. Uncompressed_Data'Last), - O, - No_Flush); - - Ada.Text_IO.Put_Line - ("Total in : " & Count'Image (Total_In (Decompressor)) & - ", out : " & Count'Image (Total_Out (Decompressor))); - - exit when P = L; - end loop; - - Ada.Text_IO.New_Line; - Ada.Text_IO.Put_Line - ("Decompressed text matches original text : " - & Boolean'Image (Uncompressed_Data = Source)); - end Decompress; - end; -end Buffer_Demo; diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/mtest.adb b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/mtest.adb deleted file mode 100644 index c4dfd08..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/mtest.adb +++ /dev/null @@ -1,156 +0,0 @@ ----------------------------------------------------------------- --- ZLib for Ada thick binding. -- --- -- --- Copyright (C) 2002-2003 Dmitriy Anisimkov -- --- -- --- Open source license information is in the zlib.ads file. -- ----------------------------------------------------------------- --- Continuous test for ZLib multithreading. If the test would fail --- we should provide thread safe allocation routines for the Z_Stream. --- --- $Id: mtest.adb,v 1.4 2004/07/23 07:49:54 vagul Exp $ - -with ZLib; -with Ada.Streams; -with Ada.Numerics.Discrete_Random; -with Ada.Text_IO; -with Ada.Exceptions; -with Ada.Task_Identification; - -procedure MTest is - use Ada.Streams; - use ZLib; - - Stop : Boolean := False; - - pragma Atomic (Stop); - - subtype Visible_Symbols is Stream_Element range 16#20# .. 16#7E#; - - package Random_Elements is - new Ada.Numerics.Discrete_Random (Visible_Symbols); - - task type Test_Task; - - task body Test_Task is - Buffer : Stream_Element_Array (1 .. 100_000); - Gen : Random_Elements.Generator; - - Buffer_First : Stream_Element_Offset; - Compare_First : Stream_Element_Offset; - - Deflate : Filter_Type; - Inflate : Filter_Type; - - procedure Further (Item : in Stream_Element_Array); - - procedure Read_Buffer - (Item : out Ada.Streams.Stream_Element_Array; - Last : out Ada.Streams.Stream_Element_Offset); - - ------------- - -- Further -- - ------------- - - procedure Further (Item : in Stream_Element_Array) is - - procedure Compare (Item : in Stream_Element_Array); - - ------------- - -- Compare -- - ------------- - - procedure Compare (Item : in Stream_Element_Array) is - Next_First : Stream_Element_Offset := Compare_First + Item'Length; - begin - if Buffer (Compare_First .. Next_First - 1) /= Item then - raise Program_Error; - end if; - - Compare_First := Next_First; - end Compare; - - procedure Compare_Write is new ZLib.Write (Write => Compare); - begin - Compare_Write (Inflate, Item, No_Flush); - end Further; - - ----------------- - -- Read_Buffer -- - ----------------- - - procedure Read_Buffer - (Item : out Ada.Streams.Stream_Element_Array; - Last : out Ada.Streams.Stream_Element_Offset) - is - Buff_Diff : Stream_Element_Offset := Buffer'Last - Buffer_First; - Next_First : Stream_Element_Offset; - begin - if Item'Length <= Buff_Diff then - Last := Item'Last; - - Next_First := Buffer_First + Item'Length; - - Item := Buffer (Buffer_First .. Next_First - 1); - - Buffer_First := Next_First; - else - Last := Item'First + Buff_Diff; - Item (Item'First .. Last) := Buffer (Buffer_First .. Buffer'Last); - Buffer_First := Buffer'Last + 1; - end if; - end Read_Buffer; - - procedure Translate is new Generic_Translate - (Data_In => Read_Buffer, - Data_Out => Further); - - begin - Random_Elements.Reset (Gen); - - Buffer := (others => 20); - - Main : loop - for J in Buffer'Range loop - Buffer (J) := Random_Elements.Random (Gen); - - Deflate_Init (Deflate); - Inflate_Init (Inflate); - - Buffer_First := Buffer'First; - Compare_First := Buffer'First; - - Translate (Deflate); - - if Compare_First /= Buffer'Last + 1 then - raise Program_Error; - end if; - - Ada.Text_IO.Put_Line - (Ada.Task_Identification.Image - (Ada.Task_Identification.Current_Task) - & Stream_Element_Offset'Image (J) - & ZLib.Count'Image (Total_Out (Deflate))); - - Close (Deflate); - Close (Inflate); - - exit Main when Stop; - end loop; - end loop Main; - exception - when E : others => - Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Information (E)); - Stop := True; - end Test_Task; - - Test : array (1 .. 4) of Test_Task; - - pragma Unreferenced (Test); - - Dummy : Character; - -begin - Ada.Text_IO.Get_Immediate (Dummy); - Stop := True; -end MTest; diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/read.adb b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/read.adb deleted file mode 100644 index 1f2efbf..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/read.adb +++ /dev/null @@ -1,156 +0,0 @@ ----------------------------------------------------------------- --- ZLib for Ada thick binding. -- --- -- --- Copyright (C) 2002-2003 Dmitriy Anisimkov -- --- -- --- Open source license information is in the zlib.ads file. -- ----------------------------------------------------------------- - --- $Id: read.adb,v 1.8 2004/05/31 10:53:40 vagul Exp $ - --- Test/demo program for the generic read interface. - -with Ada.Numerics.Discrete_Random; -with Ada.Streams; -with Ada.Text_IO; - -with ZLib; - -procedure Read is - - use Ada.Streams; - - ------------------------------------ - -- Test configuration parameters -- - ------------------------------------ - - File_Size : Stream_Element_Offset := 100_000; - - Continuous : constant Boolean := False; - -- If this constant is True, the test would be repeated again and again, - -- with increment File_Size for every iteration. - - Header : constant ZLib.Header_Type := ZLib.Default; - -- Do not use Header other than Default in ZLib versions 1.1.4 and older. - - Init_Random : constant := 8; - -- We are using the same random sequence, in case of we catch bug, - -- so we would be able to reproduce it. - - -- End -- - - Pack_Size : Stream_Element_Offset; - Offset : Stream_Element_Offset; - - Filter : ZLib.Filter_Type; - - subtype Visible_Symbols - is Stream_Element range 16#20# .. 16#7E#; - - package Random_Elements is new - Ada.Numerics.Discrete_Random (Visible_Symbols); - - Gen : Random_Elements.Generator; - Period : constant Stream_Element_Offset := 200; - -- Period constant variable for random generator not to be very random. - -- Bigger period, harder random. - - Read_Buffer : Stream_Element_Array (1 .. 2048); - Read_First : Stream_Element_Offset; - Read_Last : Stream_Element_Offset; - - procedure Reset; - - procedure Read - (Item : out Stream_Element_Array; - Last : out Stream_Element_Offset); - -- this procedure is for generic instantiation of - -- ZLib.Read - -- reading data from the File_In. - - procedure Read is new ZLib.Read - (Read, - Read_Buffer, - Rest_First => Read_First, - Rest_Last => Read_Last); - - ---------- - -- Read -- - ---------- - - procedure Read - (Item : out Stream_Element_Array; - Last : out Stream_Element_Offset) is - begin - Last := Stream_Element_Offset'Min - (Item'Last, - Item'First + File_Size - Offset); - - for J in Item'First .. Last loop - if J < Item'First + Period then - Item (J) := Random_Elements.Random (Gen); - else - Item (J) := Item (J - Period); - end if; - - Offset := Offset + 1; - end loop; - end Read; - - ----------- - -- Reset -- - ----------- - - procedure Reset is - begin - Random_Elements.Reset (Gen, Init_Random); - Pack_Size := 0; - Offset := 1; - Read_First := Read_Buffer'Last + 1; - Read_Last := Read_Buffer'Last; - end Reset; - -begin - Ada.Text_IO.Put_Line ("ZLib " & ZLib.Version); - - loop - for Level in ZLib.Compression_Level'Range loop - - Ada.Text_IO.Put ("Level =" - & ZLib.Compression_Level'Image (Level)); - - -- Deflate using generic instantiation. - - ZLib.Deflate_Init - (Filter, - Level, - Header => Header); - - Reset; - - Ada.Text_IO.Put - (Stream_Element_Offset'Image (File_Size) & " ->"); - - loop - declare - Buffer : Stream_Element_Array (1 .. 1024); - Last : Stream_Element_Offset; - begin - Read (Filter, Buffer, Last); - - Pack_Size := Pack_Size + Last - Buffer'First + 1; - - exit when Last < Buffer'Last; - end; - end loop; - - Ada.Text_IO.Put_Line (Stream_Element_Offset'Image (Pack_Size)); - - ZLib.Close (Filter); - end loop; - - exit when not Continuous; - - File_Size := File_Size + 1; - end loop; -end Read; diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/readme.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/readme.txt deleted file mode 100644 index ce4d2ca..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/readme.txt +++ /dev/null @@ -1,65 +0,0 @@ - ZLib for Ada thick binding (ZLib.Ada) - Release 1.3 - -ZLib.Ada is a thick binding interface to the popular ZLib data -compression library, available at http://www.gzip.org/zlib/. -It provides Ada-style access to the ZLib C library. - - - Here are the main changes since ZLib.Ada 1.2: - -- Attension: ZLib.Read generic routine have a initialization requirement - for Read_Last parameter now. It is a bit incompartible with previous version, - but extends functionality, we could use new parameters Allow_Read_Some and - Flush now. - -- Added Is_Open routines to ZLib and ZLib.Streams packages. - -- Add pragma Assert to check Stream_Element is 8 bit. - -- Fix extraction to buffer with exact known decompressed size. Error reported by - Steve Sangwine. - -- Fix definition of ULong (changed to unsigned_long), fix regression on 64 bits - computers. Patch provided by Pascal Obry. - -- Add Status_Error exception definition. - -- Add pragma Assertion that Ada.Streams.Stream_Element size is 8 bit. - - - How to build ZLib.Ada under GNAT - -You should have the ZLib library already build on your computer, before -building ZLib.Ada. Make the directory of ZLib.Ada sources current and -issue the command: - - gnatmake test -largs -L -lz - -Or use the GNAT project file build for GNAT 3.15 or later: - - gnatmake -Pzlib.gpr -L - - - How to build ZLib.Ada under Aonix ObjectAda for Win32 7.2.2 - -1. Make a project with all *.ads and *.adb files from the distribution. -2. Build the libz.a library from the ZLib C sources. -3. Rename libz.a to z.lib. -4. Add the library z.lib to the project. -5. Add the libc.lib library from the ObjectAda distribution to the project. -6. Build the executable using test.adb as a main procedure. - - - How to use ZLib.Ada - -The source files test.adb and read.adb are small demo programs that show -the main functionality of ZLib.Ada. - -The routines from the package specifications are commented. - - -Homepage: http://zlib-ada.sourceforge.net/ -Author: Dmitriy Anisimkov - -Contributors: Pascal Obry , Steve Sangwine diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/test.adb b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/test.adb deleted file mode 100644 index 90773ac..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/test.adb +++ /dev/null @@ -1,463 +0,0 @@ ----------------------------------------------------------------- --- ZLib for Ada thick binding. -- --- -- --- Copyright (C) 2002-2003 Dmitriy Anisimkov -- --- -- --- Open source license information is in the zlib.ads file. -- ----------------------------------------------------------------- - --- $Id: test.adb,v 1.17 2003/08/12 12:13:30 vagul Exp $ - --- The program has a few aims. --- 1. Test ZLib.Ada95 thick binding functionality. --- 2. Show the example of use main functionality of the ZLib.Ada95 binding. --- 3. Build this program automatically compile all ZLib.Ada95 packages under --- GNAT Ada95 compiler. - -with ZLib.Streams; -with Ada.Streams.Stream_IO; -with Ada.Numerics.Discrete_Random; - -with Ada.Text_IO; - -with Ada.Calendar; - -procedure Test is - - use Ada.Streams; - use Stream_IO; - - ------------------------------------ - -- Test configuration parameters -- - ------------------------------------ - - File_Size : Count := 100_000; - Continuous : constant Boolean := False; - - Header : constant ZLib.Header_Type := ZLib.Default; - -- ZLib.None; - -- ZLib.Auto; - -- ZLib.GZip; - -- Do not use Header other then Default in ZLib versions 1.1.4 - -- and older. - - Strategy : constant ZLib.Strategy_Type := ZLib.Default_Strategy; - Init_Random : constant := 10; - - -- End -- - - In_File_Name : constant String := "testzlib.in"; - -- Name of the input file - - Z_File_Name : constant String := "testzlib.zlb"; - -- Name of the compressed file. - - Out_File_Name : constant String := "testzlib.out"; - -- Name of the decompressed file. - - File_In : File_Type; - File_Out : File_Type; - File_Back : File_Type; - File_Z : ZLib.Streams.Stream_Type; - - Filter : ZLib.Filter_Type; - - Time_Stamp : Ada.Calendar.Time; - - procedure Generate_File; - -- Generate file of spetsified size with some random data. - -- The random data is repeatable, for the good compression. - - procedure Compare_Streams - (Left, Right : in out Root_Stream_Type'Class); - -- The procedure compearing data in 2 streams. - -- It is for compare data before and after compression/decompression. - - procedure Compare_Files (Left, Right : String); - -- Compare files. Based on the Compare_Streams. - - procedure Copy_Streams - (Source, Target : in out Root_Stream_Type'Class; - Buffer_Size : in Stream_Element_Offset := 1024); - -- Copying data from one stream to another. It is for test stream - -- interface of the library. - - procedure Data_In - (Item : out Stream_Element_Array; - Last : out Stream_Element_Offset); - -- this procedure is for generic instantiation of - -- ZLib.Generic_Translate. - -- reading data from the File_In. - - procedure Data_Out (Item : in Stream_Element_Array); - -- this procedure is for generic instantiation of - -- ZLib.Generic_Translate. - -- writing data to the File_Out. - - procedure Stamp; - -- Store the timestamp to the local variable. - - procedure Print_Statistic (Msg : String; Data_Size : ZLib.Count); - -- Print the time statistic with the message. - - procedure Translate is new ZLib.Generic_Translate - (Data_In => Data_In, - Data_Out => Data_Out); - -- This procedure is moving data from File_In to File_Out - -- with compression or decompression, depend on initialization of - -- Filter parameter. - - ------------------- - -- Compare_Files -- - ------------------- - - procedure Compare_Files (Left, Right : String) is - Left_File, Right_File : File_Type; - begin - Open (Left_File, In_File, Left); - Open (Right_File, In_File, Right); - Compare_Streams (Stream (Left_File).all, Stream (Right_File).all); - Close (Left_File); - Close (Right_File); - end Compare_Files; - - --------------------- - -- Compare_Streams -- - --------------------- - - procedure Compare_Streams - (Left, Right : in out Ada.Streams.Root_Stream_Type'Class) - is - Left_Buffer, Right_Buffer : Stream_Element_Array (0 .. 16#FFF#); - Left_Last, Right_Last : Stream_Element_Offset; - begin - loop - Read (Left, Left_Buffer, Left_Last); - Read (Right, Right_Buffer, Right_Last); - - if Left_Last /= Right_Last then - Ada.Text_IO.Put_Line ("Compare error :" - & Stream_Element_Offset'Image (Left_Last) - & " /= " - & Stream_Element_Offset'Image (Right_Last)); - - raise Constraint_Error; - - elsif Left_Buffer (0 .. Left_Last) - /= Right_Buffer (0 .. Right_Last) - then - Ada.Text_IO.Put_Line ("ERROR: IN and OUT files is not equal."); - raise Constraint_Error; - - end if; - - exit when Left_Last < Left_Buffer'Last; - end loop; - end Compare_Streams; - - ------------------ - -- Copy_Streams -- - ------------------ - - procedure Copy_Streams - (Source, Target : in out Ada.Streams.Root_Stream_Type'Class; - Buffer_Size : in Stream_Element_Offset := 1024) - is - Buffer : Stream_Element_Array (1 .. Buffer_Size); - Last : Stream_Element_Offset; - begin - loop - Read (Source, Buffer, Last); - Write (Target, Buffer (1 .. Last)); - - exit when Last < Buffer'Last; - end loop; - end Copy_Streams; - - ------------- - -- Data_In -- - ------------- - - procedure Data_In - (Item : out Stream_Element_Array; - Last : out Stream_Element_Offset) is - begin - Read (File_In, Item, Last); - end Data_In; - - -------------- - -- Data_Out -- - -------------- - - procedure Data_Out (Item : in Stream_Element_Array) is - begin - Write (File_Out, Item); - end Data_Out; - - ------------------- - -- Generate_File -- - ------------------- - - procedure Generate_File is - subtype Visible_Symbols is Stream_Element range 16#20# .. 16#7E#; - - package Random_Elements is - new Ada.Numerics.Discrete_Random (Visible_Symbols); - - Gen : Random_Elements.Generator; - Buffer : Stream_Element_Array := (1 .. 77 => 16#20#) & 10; - - Buffer_Count : constant Count := File_Size / Buffer'Length; - -- Number of same buffers in the packet. - - Density : constant Count := 30; -- from 0 to Buffer'Length - 2; - - procedure Fill_Buffer (J, D : in Count); - -- Change the part of the buffer. - - ----------------- - -- Fill_Buffer -- - ----------------- - - procedure Fill_Buffer (J, D : in Count) is - begin - for K in 0 .. D loop - Buffer - (Stream_Element_Offset ((J + K) mod (Buffer'Length - 1) + 1)) - := Random_Elements.Random (Gen); - - end loop; - end Fill_Buffer; - - begin - Random_Elements.Reset (Gen, Init_Random); - - Create (File_In, Out_File, In_File_Name); - - Fill_Buffer (1, Buffer'Length - 2); - - for J in 1 .. Buffer_Count loop - Write (File_In, Buffer); - - Fill_Buffer (J, Density); - end loop; - - -- fill remain size. - - Write - (File_In, - Buffer - (1 .. Stream_Element_Offset - (File_Size - Buffer'Length * Buffer_Count))); - - Flush (File_In); - Close (File_In); - end Generate_File; - - --------------------- - -- Print_Statistic -- - --------------------- - - procedure Print_Statistic (Msg : String; Data_Size : ZLib.Count) is - use Ada.Calendar; - use Ada.Text_IO; - - package Count_IO is new Integer_IO (ZLib.Count); - - Curr_Dur : Duration := Clock - Time_Stamp; - begin - Put (Msg); - - Set_Col (20); - Ada.Text_IO.Put ("size ="); - - Count_IO.Put - (Data_Size, - Width => Stream_IO.Count'Image (File_Size)'Length); - - Put_Line (" duration =" & Duration'Image (Curr_Dur)); - end Print_Statistic; - - ----------- - -- Stamp -- - ----------- - - procedure Stamp is - begin - Time_Stamp := Ada.Calendar.Clock; - end Stamp; - -begin - Ada.Text_IO.Put_Line ("ZLib " & ZLib.Version); - - loop - Generate_File; - - for Level in ZLib.Compression_Level'Range loop - - Ada.Text_IO.Put_Line ("Level =" - & ZLib.Compression_Level'Image (Level)); - - -- Test generic interface. - Open (File_In, In_File, In_File_Name); - Create (File_Out, Out_File, Z_File_Name); - - Stamp; - - -- Deflate using generic instantiation. - - ZLib.Deflate_Init - (Filter => Filter, - Level => Level, - Strategy => Strategy, - Header => Header); - - Translate (Filter); - Print_Statistic ("Generic compress", ZLib.Total_Out (Filter)); - ZLib.Close (Filter); - - Close (File_In); - Close (File_Out); - - Open (File_In, In_File, Z_File_Name); - Create (File_Out, Out_File, Out_File_Name); - - Stamp; - - -- Inflate using generic instantiation. - - ZLib.Inflate_Init (Filter, Header => Header); - - Translate (Filter); - Print_Statistic ("Generic decompress", ZLib.Total_Out (Filter)); - - ZLib.Close (Filter); - - Close (File_In); - Close (File_Out); - - Compare_Files (In_File_Name, Out_File_Name); - - -- Test stream interface. - - -- Compress to the back stream. - - Open (File_In, In_File, In_File_Name); - Create (File_Back, Out_File, Z_File_Name); - - Stamp; - - ZLib.Streams.Create - (Stream => File_Z, - Mode => ZLib.Streams.Out_Stream, - Back => ZLib.Streams.Stream_Access - (Stream (File_Back)), - Back_Compressed => True, - Level => Level, - Strategy => Strategy, - Header => Header); - - Copy_Streams - (Source => Stream (File_In).all, - Target => File_Z); - - -- Flushing internal buffers to the back stream. - - ZLib.Streams.Flush (File_Z, ZLib.Finish); - - Print_Statistic ("Write compress", - ZLib.Streams.Write_Total_Out (File_Z)); - - ZLib.Streams.Close (File_Z); - - Close (File_In); - Close (File_Back); - - -- Compare reading from original file and from - -- decompression stream. - - Open (File_In, In_File, In_File_Name); - Open (File_Back, In_File, Z_File_Name); - - ZLib.Streams.Create - (Stream => File_Z, - Mode => ZLib.Streams.In_Stream, - Back => ZLib.Streams.Stream_Access - (Stream (File_Back)), - Back_Compressed => True, - Header => Header); - - Stamp; - Compare_Streams (Stream (File_In).all, File_Z); - - Print_Statistic ("Read decompress", - ZLib.Streams.Read_Total_Out (File_Z)); - - ZLib.Streams.Close (File_Z); - Close (File_In); - Close (File_Back); - - -- Compress by reading from compression stream. - - Open (File_Back, In_File, In_File_Name); - Create (File_Out, Out_File, Z_File_Name); - - ZLib.Streams.Create - (Stream => File_Z, - Mode => ZLib.Streams.In_Stream, - Back => ZLib.Streams.Stream_Access - (Stream (File_Back)), - Back_Compressed => False, - Level => Level, - Strategy => Strategy, - Header => Header); - - Stamp; - Copy_Streams - (Source => File_Z, - Target => Stream (File_Out).all); - - Print_Statistic ("Read compress", - ZLib.Streams.Read_Total_Out (File_Z)); - - ZLib.Streams.Close (File_Z); - - Close (File_Out); - Close (File_Back); - - -- Decompress to decompression stream. - - Open (File_In, In_File, Z_File_Name); - Create (File_Back, Out_File, Out_File_Name); - - ZLib.Streams.Create - (Stream => File_Z, - Mode => ZLib.Streams.Out_Stream, - Back => ZLib.Streams.Stream_Access - (Stream (File_Back)), - Back_Compressed => False, - Header => Header); - - Stamp; - - Copy_Streams - (Source => Stream (File_In).all, - Target => File_Z); - - Print_Statistic ("Write decompress", - ZLib.Streams.Write_Total_Out (File_Z)); - - ZLib.Streams.Close (File_Z); - Close (File_In); - Close (File_Back); - - Compare_Files (In_File_Name, Out_File_Name); - end loop; - - Ada.Text_IO.Put_Line (Count'Image (File_Size) & " Ok."); - - exit when not Continuous; - - File_Size := File_Size + 1; - end loop; -end Test; diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/zlib-streams.adb b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/zlib-streams.adb deleted file mode 100644 index b6497ba..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/zlib-streams.adb +++ /dev/null @@ -1,225 +0,0 @@ ----------------------------------------------------------------- --- ZLib for Ada thick binding. -- --- -- --- Copyright (C) 2002-2003 Dmitriy Anisimkov -- --- -- --- Open source license information is in the zlib.ads file. -- ----------------------------------------------------------------- - --- $Id: zlib-streams.adb,v 1.10 2004/05/31 10:53:40 vagul Exp $ - -with Ada.Unchecked_Deallocation; - -package body ZLib.Streams is - - ----------- - -- Close -- - ----------- - - procedure Close (Stream : in out Stream_Type) is - procedure Free is new Ada.Unchecked_Deallocation - (Stream_Element_Array, Buffer_Access); - begin - if Stream.Mode = Out_Stream or Stream.Mode = Duplex then - -- We should flush the data written by the writer. - - Flush (Stream, Finish); - - Close (Stream.Writer); - end if; - - if Stream.Mode = In_Stream or Stream.Mode = Duplex then - Close (Stream.Reader); - Free (Stream.Buffer); - end if; - end Close; - - ------------ - -- Create -- - ------------ - - procedure Create - (Stream : out Stream_Type; - Mode : in Stream_Mode; - Back : in Stream_Access; - Back_Compressed : in Boolean; - Level : in Compression_Level := Default_Compression; - Strategy : in Strategy_Type := Default_Strategy; - Header : in Header_Type := Default; - Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset - := Default_Buffer_Size; - Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset - := Default_Buffer_Size) - is - - subtype Buffer_Subtype is Stream_Element_Array (1 .. Read_Buffer_Size); - - procedure Init_Filter - (Filter : in out Filter_Type; - Compress : in Boolean); - - ----------------- - -- Init_Filter -- - ----------------- - - procedure Init_Filter - (Filter : in out Filter_Type; - Compress : in Boolean) is - begin - if Compress then - Deflate_Init - (Filter, Level, Strategy, Header => Header); - else - Inflate_Init (Filter, Header => Header); - end if; - end Init_Filter; - - begin - Stream.Back := Back; - Stream.Mode := Mode; - - if Mode = Out_Stream or Mode = Duplex then - Init_Filter (Stream.Writer, Back_Compressed); - Stream.Buffer_Size := Write_Buffer_Size; - else - Stream.Buffer_Size := 0; - end if; - - if Mode = In_Stream or Mode = Duplex then - Init_Filter (Stream.Reader, not Back_Compressed); - - Stream.Buffer := new Buffer_Subtype; - Stream.Rest_First := Stream.Buffer'Last + 1; - Stream.Rest_Last := Stream.Buffer'Last; - end if; - end Create; - - ----------- - -- Flush -- - ----------- - - procedure Flush - (Stream : in out Stream_Type; - Mode : in Flush_Mode := Sync_Flush) - is - Buffer : Stream_Element_Array (1 .. Stream.Buffer_Size); - Last : Stream_Element_Offset; - begin - loop - Flush (Stream.Writer, Buffer, Last, Mode); - - Ada.Streams.Write (Stream.Back.all, Buffer (1 .. Last)); - - exit when Last < Buffer'Last; - end loop; - end Flush; - - ------------- - -- Is_Open -- - ------------- - - function Is_Open (Stream : Stream_Type) return Boolean is - begin - return Is_Open (Stream.Reader) or else Is_Open (Stream.Writer); - end Is_Open; - - ---------- - -- Read -- - ---------- - - procedure Read - (Stream : in out Stream_Type; - Item : out Stream_Element_Array; - Last : out Stream_Element_Offset) - is - - procedure Read - (Item : out Stream_Element_Array; - Last : out Stream_Element_Offset); - - ---------- - -- Read -- - ---------- - - procedure Read - (Item : out Stream_Element_Array; - Last : out Stream_Element_Offset) is - begin - Ada.Streams.Read (Stream.Back.all, Item, Last); - end Read; - - procedure Read is new ZLib.Read - (Read => Read, - Buffer => Stream.Buffer.all, - Rest_First => Stream.Rest_First, - Rest_Last => Stream.Rest_Last); - - begin - Read (Stream.Reader, Item, Last); - end Read; - - ------------------- - -- Read_Total_In -- - ------------------- - - function Read_Total_In (Stream : in Stream_Type) return Count is - begin - return Total_In (Stream.Reader); - end Read_Total_In; - - -------------------- - -- Read_Total_Out -- - -------------------- - - function Read_Total_Out (Stream : in Stream_Type) return Count is - begin - return Total_Out (Stream.Reader); - end Read_Total_Out; - - ----------- - -- Write -- - ----------- - - procedure Write - (Stream : in out Stream_Type; - Item : in Stream_Element_Array) - is - - procedure Write (Item : in Stream_Element_Array); - - ----------- - -- Write -- - ----------- - - procedure Write (Item : in Stream_Element_Array) is - begin - Ada.Streams.Write (Stream.Back.all, Item); - end Write; - - procedure Write is new ZLib.Write - (Write => Write, - Buffer_Size => Stream.Buffer_Size); - - begin - Write (Stream.Writer, Item, No_Flush); - end Write; - - -------------------- - -- Write_Total_In -- - -------------------- - - function Write_Total_In (Stream : in Stream_Type) return Count is - begin - return Total_In (Stream.Writer); - end Write_Total_In; - - --------------------- - -- Write_Total_Out -- - --------------------- - - function Write_Total_Out (Stream : in Stream_Type) return Count is - begin - return Total_Out (Stream.Writer); - end Write_Total_Out; - -end ZLib.Streams; diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/zlib-streams.ads b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/zlib-streams.ads deleted file mode 100644 index 8e26cd4..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/zlib-streams.ads +++ /dev/null @@ -1,114 +0,0 @@ ----------------------------------------------------------------- --- ZLib for Ada thick binding. -- --- -- --- Copyright (C) 2002-2003 Dmitriy Anisimkov -- --- -- --- Open source license information is in the zlib.ads file. -- ----------------------------------------------------------------- - --- $Id: zlib-streams.ads,v 1.12 2004/05/31 10:53:40 vagul Exp $ - -package ZLib.Streams is - - type Stream_Mode is (In_Stream, Out_Stream, Duplex); - - type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class; - - type Stream_Type is - new Ada.Streams.Root_Stream_Type with private; - - procedure Read - (Stream : in out Stream_Type; - Item : out Ada.Streams.Stream_Element_Array; - Last : out Ada.Streams.Stream_Element_Offset); - - procedure Write - (Stream : in out Stream_Type; - Item : in Ada.Streams.Stream_Element_Array); - - procedure Flush - (Stream : in out Stream_Type; - Mode : in Flush_Mode := Sync_Flush); - -- Flush the written data to the back stream, - -- all data placed to the compressor is flushing to the Back stream. - -- Should not be used until necessary, because it is decreasing - -- compression. - - function Read_Total_In (Stream : in Stream_Type) return Count; - pragma Inline (Read_Total_In); - -- Return total number of bytes read from back stream so far. - - function Read_Total_Out (Stream : in Stream_Type) return Count; - pragma Inline (Read_Total_Out); - -- Return total number of bytes read so far. - - function Write_Total_In (Stream : in Stream_Type) return Count; - pragma Inline (Write_Total_In); - -- Return total number of bytes written so far. - - function Write_Total_Out (Stream : in Stream_Type) return Count; - pragma Inline (Write_Total_Out); - -- Return total number of bytes written to the back stream. - - procedure Create - (Stream : out Stream_Type; - Mode : in Stream_Mode; - Back : in Stream_Access; - Back_Compressed : in Boolean; - Level : in Compression_Level := Default_Compression; - Strategy : in Strategy_Type := Default_Strategy; - Header : in Header_Type := Default; - Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset - := Default_Buffer_Size; - Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset - := Default_Buffer_Size); - -- Create the Comression/Decompression stream. - -- If mode is In_Stream then Write operation is disabled. - -- If mode is Out_Stream then Read operation is disabled. - - -- If Back_Compressed is true then - -- Data written to the Stream is compressing to the Back stream - -- and data read from the Stream is decompressed data from the Back stream. - - -- If Back_Compressed is false then - -- Data written to the Stream is decompressing to the Back stream - -- and data read from the Stream is compressed data from the Back stream. - - -- !!! When the Need_Header is False ZLib-Ada is using undocumented - -- ZLib 1.1.4 functionality to do not create/wait for ZLib headers. - - function Is_Open (Stream : Stream_Type) return Boolean; - - procedure Close (Stream : in out Stream_Type); - -private - - use Ada.Streams; - - type Buffer_Access is access all Stream_Element_Array; - - type Stream_Type - is new Root_Stream_Type with - record - Mode : Stream_Mode; - - Buffer : Buffer_Access; - Rest_First : Stream_Element_Offset; - Rest_Last : Stream_Element_Offset; - -- Buffer for Read operation. - -- We need to have this buffer in the record - -- because not all read data from back stream - -- could be processed during the read operation. - - Buffer_Size : Stream_Element_Offset; - -- Buffer size for write operation. - -- We do not need to have this buffer - -- in the record because all data could be - -- processed in the write operation. - - Back : Stream_Access; - Reader : Filter_Type; - Writer : Filter_Type; - end record; - -end ZLib.Streams; diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/zlib-thin.adb b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/zlib-thin.adb deleted file mode 100644 index 0ca4a71..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/zlib-thin.adb +++ /dev/null @@ -1,141 +0,0 @@ ----------------------------------------------------------------- --- ZLib for Ada thick binding. -- --- -- --- Copyright (C) 2002-2003 Dmitriy Anisimkov -- --- -- --- Open source license information is in the zlib.ads file. -- ----------------------------------------------------------------- - --- $Id: zlib-thin.adb,v 1.8 2003/12/14 18:27:31 vagul Exp $ - -package body ZLib.Thin is - - ZLIB_VERSION : constant Chars_Ptr := zlibVersion; - - Z_Stream_Size : constant Int := Z_Stream'Size / System.Storage_Unit; - - -------------- - -- Avail_In -- - -------------- - - function Avail_In (Strm : in Z_Stream) return UInt is - begin - return Strm.Avail_In; - end Avail_In; - - --------------- - -- Avail_Out -- - --------------- - - function Avail_Out (Strm : in Z_Stream) return UInt is - begin - return Strm.Avail_Out; - end Avail_Out; - - ------------------ - -- Deflate_Init -- - ------------------ - - function Deflate_Init - (strm : Z_Streamp; - level : Int; - method : Int; - windowBits : Int; - memLevel : Int; - strategy : Int) - return Int is - begin - return deflateInit2 - (strm, - level, - method, - windowBits, - memLevel, - strategy, - ZLIB_VERSION, - Z_Stream_Size); - end Deflate_Init; - - ------------------ - -- Inflate_Init -- - ------------------ - - function Inflate_Init (strm : Z_Streamp; windowBits : Int) return Int is - begin - return inflateInit2 (strm, windowBits, ZLIB_VERSION, Z_Stream_Size); - end Inflate_Init; - - ------------------------ - -- Last_Error_Message -- - ------------------------ - - function Last_Error_Message (Strm : in Z_Stream) return String is - use Interfaces.C.Strings; - begin - if Strm.msg = Null_Ptr then - return ""; - else - return Value (Strm.msg); - end if; - end Last_Error_Message; - - ------------ - -- Set_In -- - ------------ - - procedure Set_In - (Strm : in out Z_Stream; - Buffer : in Voidp; - Size : in UInt) is - begin - Strm.Next_In := Buffer; - Strm.Avail_In := Size; - end Set_In; - - ------------------ - -- Set_Mem_Func -- - ------------------ - - procedure Set_Mem_Func - (Strm : in out Z_Stream; - Opaque : in Voidp; - Alloc : in alloc_func; - Free : in free_func) is - begin - Strm.opaque := Opaque; - Strm.zalloc := Alloc; - Strm.zfree := Free; - end Set_Mem_Func; - - ------------- - -- Set_Out -- - ------------- - - procedure Set_Out - (Strm : in out Z_Stream; - Buffer : in Voidp; - Size : in UInt) is - begin - Strm.Next_Out := Buffer; - Strm.Avail_Out := Size; - end Set_Out; - - -------------- - -- Total_In -- - -------------- - - function Total_In (Strm : in Z_Stream) return ULong is - begin - return Strm.Total_In; - end Total_In; - - --------------- - -- Total_Out -- - --------------- - - function Total_Out (Strm : in Z_Stream) return ULong is - begin - return Strm.Total_Out; - end Total_Out; - -end ZLib.Thin; diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/zlib-thin.ads b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/zlib-thin.ads deleted file mode 100644 index 810173c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/zlib-thin.ads +++ /dev/null @@ -1,450 +0,0 @@ ----------------------------------------------------------------- --- ZLib for Ada thick binding. -- --- -- --- Copyright (C) 2002-2003 Dmitriy Anisimkov -- --- -- --- Open source license information is in the zlib.ads file. -- ----------------------------------------------------------------- - --- $Id: zlib-thin.ads,v 1.11 2004/07/23 06:33:11 vagul Exp $ - -with Interfaces.C.Strings; - -with System; - -private package ZLib.Thin is - - -- From zconf.h - - MAX_MEM_LEVEL : constant := 9; -- zconf.h:105 - -- zconf.h:105 - MAX_WBITS : constant := 15; -- zconf.h:115 - -- 32K LZ77 window - -- zconf.h:115 - SEEK_SET : constant := 8#0000#; -- zconf.h:244 - -- Seek from beginning of file. - -- zconf.h:244 - SEEK_CUR : constant := 1; -- zconf.h:245 - -- Seek from current position. - -- zconf.h:245 - SEEK_END : constant := 2; -- zconf.h:246 - -- Set file pointer to EOF plus "offset" - -- zconf.h:246 - - type Byte is new Interfaces.C.unsigned_char; -- 8 bits - -- zconf.h:214 - type UInt is new Interfaces.C.unsigned; -- 16 bits or more - -- zconf.h:216 - type Int is new Interfaces.C.int; - - type ULong is new Interfaces.C.unsigned_long; -- 32 bits or more - -- zconf.h:217 - subtype Chars_Ptr is Interfaces.C.Strings.chars_ptr; - - type ULong_Access is access ULong; - type Int_Access is access Int; - - subtype Voidp is System.Address; -- zconf.h:232 - - subtype Byte_Access is Voidp; - - Nul : constant Voidp := System.Null_Address; - -- end from zconf - - Z_NO_FLUSH : constant := 8#0000#; -- zlib.h:125 - -- zlib.h:125 - Z_PARTIAL_FLUSH : constant := 1; -- zlib.h:126 - -- will be removed, use - -- Z_SYNC_FLUSH instead - -- zlib.h:126 - Z_SYNC_FLUSH : constant := 2; -- zlib.h:127 - -- zlib.h:127 - Z_FULL_FLUSH : constant := 3; -- zlib.h:128 - -- zlib.h:128 - Z_FINISH : constant := 4; -- zlib.h:129 - -- zlib.h:129 - Z_OK : constant := 8#0000#; -- zlib.h:132 - -- zlib.h:132 - Z_STREAM_END : constant := 1; -- zlib.h:133 - -- zlib.h:133 - Z_NEED_DICT : constant := 2; -- zlib.h:134 - -- zlib.h:134 - Z_ERRNO : constant := -1; -- zlib.h:135 - -- zlib.h:135 - Z_STREAM_ERROR : constant := -2; -- zlib.h:136 - -- zlib.h:136 - Z_DATA_ERROR : constant := -3; -- zlib.h:137 - -- zlib.h:137 - Z_MEM_ERROR : constant := -4; -- zlib.h:138 - -- zlib.h:138 - Z_BUF_ERROR : constant := -5; -- zlib.h:139 - -- zlib.h:139 - Z_VERSION_ERROR : constant := -6; -- zlib.h:140 - -- zlib.h:140 - Z_NO_COMPRESSION : constant := 8#0000#; -- zlib.h:145 - -- zlib.h:145 - Z_BEST_SPEED : constant := 1; -- zlib.h:146 - -- zlib.h:146 - Z_BEST_COMPRESSION : constant := 9; -- zlib.h:147 - -- zlib.h:147 - Z_DEFAULT_COMPRESSION : constant := -1; -- zlib.h:148 - -- zlib.h:148 - Z_FILTERED : constant := 1; -- zlib.h:151 - -- zlib.h:151 - Z_HUFFMAN_ONLY : constant := 2; -- zlib.h:152 - -- zlib.h:152 - Z_DEFAULT_STRATEGY : constant := 8#0000#; -- zlib.h:153 - -- zlib.h:153 - Z_BINARY : constant := 8#0000#; -- zlib.h:156 - -- zlib.h:156 - Z_ASCII : constant := 1; -- zlib.h:157 - -- zlib.h:157 - Z_UNKNOWN : constant := 2; -- zlib.h:158 - -- zlib.h:158 - Z_DEFLATED : constant := 8; -- zlib.h:161 - -- zlib.h:161 - Z_NULL : constant := 8#0000#; -- zlib.h:164 - -- for initializing zalloc, zfree, opaque - -- zlib.h:164 - type gzFile is new Voidp; -- zlib.h:646 - - type Z_Stream is private; - - type Z_Streamp is access all Z_Stream; -- zlib.h:89 - - type alloc_func is access function - (Opaque : Voidp; - Items : UInt; - Size : UInt) - return Voidp; -- zlib.h:63 - - type free_func is access procedure (opaque : Voidp; address : Voidp); - - function zlibVersion return Chars_Ptr; - - function Deflate (strm : Z_Streamp; flush : Int) return Int; - - function DeflateEnd (strm : Z_Streamp) return Int; - - function Inflate (strm : Z_Streamp; flush : Int) return Int; - - function InflateEnd (strm : Z_Streamp) return Int; - - function deflateSetDictionary - (strm : Z_Streamp; - dictionary : Byte_Access; - dictLength : UInt) - return Int; - - function deflateCopy (dest : Z_Streamp; source : Z_Streamp) return Int; - -- zlib.h:478 - - function deflateReset (strm : Z_Streamp) return Int; -- zlib.h:495 - - function deflateParams - (strm : Z_Streamp; - level : Int; - strategy : Int) - return Int; -- zlib.h:506 - - function inflateSetDictionary - (strm : Z_Streamp; - dictionary : Byte_Access; - dictLength : UInt) - return Int; -- zlib.h:548 - - function inflateSync (strm : Z_Streamp) return Int; -- zlib.h:565 - - function inflateReset (strm : Z_Streamp) return Int; -- zlib.h:580 - - function compress - (dest : Byte_Access; - destLen : ULong_Access; - source : Byte_Access; - sourceLen : ULong) - return Int; -- zlib.h:601 - - function compress2 - (dest : Byte_Access; - destLen : ULong_Access; - source : Byte_Access; - sourceLen : ULong; - level : Int) - return Int; -- zlib.h:615 - - function uncompress - (dest : Byte_Access; - destLen : ULong_Access; - source : Byte_Access; - sourceLen : ULong) - return Int; - - function gzopen (path : Chars_Ptr; mode : Chars_Ptr) return gzFile; - - function gzdopen (fd : Int; mode : Chars_Ptr) return gzFile; - - function gzsetparams - (file : gzFile; - level : Int; - strategy : Int) - return Int; - - function gzread - (file : gzFile; - buf : Voidp; - len : UInt) - return Int; - - function gzwrite - (file : in gzFile; - buf : in Voidp; - len : in UInt) - return Int; - - function gzprintf (file : in gzFile; format : in Chars_Ptr) return Int; - - function gzputs (file : in gzFile; s : in Chars_Ptr) return Int; - - function gzgets - (file : gzFile; - buf : Chars_Ptr; - len : Int) - return Chars_Ptr; - - function gzputc (file : gzFile; char : Int) return Int; - - function gzgetc (file : gzFile) return Int; - - function gzflush (file : gzFile; flush : Int) return Int; - - function gzseek - (file : gzFile; - offset : Int; - whence : Int) - return Int; - - function gzrewind (file : gzFile) return Int; - - function gztell (file : gzFile) return Int; - - function gzeof (file : gzFile) return Int; - - function gzclose (file : gzFile) return Int; - - function gzerror (file : gzFile; errnum : Int_Access) return Chars_Ptr; - - function adler32 - (adler : ULong; - buf : Byte_Access; - len : UInt) - return ULong; - - function crc32 - (crc : ULong; - buf : Byte_Access; - len : UInt) - return ULong; - - function deflateInit - (strm : Z_Streamp; - level : Int; - version : Chars_Ptr; - stream_size : Int) - return Int; - - function deflateInit2 - (strm : Z_Streamp; - level : Int; - method : Int; - windowBits : Int; - memLevel : Int; - strategy : Int; - version : Chars_Ptr; - stream_size : Int) - return Int; - - function Deflate_Init - (strm : Z_Streamp; - level : Int; - method : Int; - windowBits : Int; - memLevel : Int; - strategy : Int) - return Int; - pragma Inline (Deflate_Init); - - function inflateInit - (strm : Z_Streamp; - version : Chars_Ptr; - stream_size : Int) - return Int; - - function inflateInit2 - (strm : in Z_Streamp; - windowBits : in Int; - version : in Chars_Ptr; - stream_size : in Int) - return Int; - - function inflateBackInit - (strm : in Z_Streamp; - windowBits : in Int; - window : in Byte_Access; - version : in Chars_Ptr; - stream_size : in Int) - return Int; - -- Size of window have to be 2**windowBits. - - function Inflate_Init (strm : Z_Streamp; windowBits : Int) return Int; - pragma Inline (Inflate_Init); - - function zError (err : Int) return Chars_Ptr; - - function inflateSyncPoint (z : Z_Streamp) return Int; - - function get_crc_table return ULong_Access; - - -- Interface to the available fields of the z_stream structure. - -- The application must update next_in and avail_in when avail_in has - -- dropped to zero. It must update next_out and avail_out when avail_out - -- has dropped to zero. The application must initialize zalloc, zfree and - -- opaque before calling the init function. - - procedure Set_In - (Strm : in out Z_Stream; - Buffer : in Voidp; - Size : in UInt); - pragma Inline (Set_In); - - procedure Set_Out - (Strm : in out Z_Stream; - Buffer : in Voidp; - Size : in UInt); - pragma Inline (Set_Out); - - procedure Set_Mem_Func - (Strm : in out Z_Stream; - Opaque : in Voidp; - Alloc : in alloc_func; - Free : in free_func); - pragma Inline (Set_Mem_Func); - - function Last_Error_Message (Strm : in Z_Stream) return String; - pragma Inline (Last_Error_Message); - - function Avail_Out (Strm : in Z_Stream) return UInt; - pragma Inline (Avail_Out); - - function Avail_In (Strm : in Z_Stream) return UInt; - pragma Inline (Avail_In); - - function Total_In (Strm : in Z_Stream) return ULong; - pragma Inline (Total_In); - - function Total_Out (Strm : in Z_Stream) return ULong; - pragma Inline (Total_Out); - - function inflateCopy - (dest : in Z_Streamp; - Source : in Z_Streamp) - return Int; - - function compressBound (Source_Len : in ULong) return ULong; - - function deflateBound - (Strm : in Z_Streamp; - Source_Len : in ULong) - return ULong; - - function gzungetc (C : in Int; File : in gzFile) return Int; - - function zlibCompileFlags return ULong; - -private - - type Z_Stream is record -- zlib.h:68 - Next_In : Voidp := Nul; -- next input byte - Avail_In : UInt := 0; -- number of bytes available at next_in - Total_In : ULong := 0; -- total nb of input bytes read so far - Next_Out : Voidp := Nul; -- next output byte should be put there - Avail_Out : UInt := 0; -- remaining free space at next_out - Total_Out : ULong := 0; -- total nb of bytes output so far - msg : Chars_Ptr; -- last error message, NULL if no error - state : Voidp; -- not visible by applications - zalloc : alloc_func := null; -- used to allocate the internal state - zfree : free_func := null; -- used to free the internal state - opaque : Voidp; -- private data object passed to - -- zalloc and zfree - data_type : Int; -- best guess about the data type: - -- ascii or binary - adler : ULong; -- adler32 value of the uncompressed - -- data - reserved : ULong; -- reserved for future use - end record; - - pragma Convention (C, Z_Stream); - - pragma Import (C, zlibVersion, "zlibVersion"); - pragma Import (C, Deflate, "deflate"); - pragma Import (C, DeflateEnd, "deflateEnd"); - pragma Import (C, Inflate, "inflate"); - pragma Import (C, InflateEnd, "inflateEnd"); - pragma Import (C, deflateSetDictionary, "deflateSetDictionary"); - pragma Import (C, deflateCopy, "deflateCopy"); - pragma Import (C, deflateReset, "deflateReset"); - pragma Import (C, deflateParams, "deflateParams"); - pragma Import (C, inflateSetDictionary, "inflateSetDictionary"); - pragma Import (C, inflateSync, "inflateSync"); - pragma Import (C, inflateReset, "inflateReset"); - pragma Import (C, compress, "compress"); - pragma Import (C, compress2, "compress2"); - pragma Import (C, uncompress, "uncompress"); - pragma Import (C, gzopen, "gzopen"); - pragma Import (C, gzdopen, "gzdopen"); - pragma Import (C, gzsetparams, "gzsetparams"); - pragma Import (C, gzread, "gzread"); - pragma Import (C, gzwrite, "gzwrite"); - pragma Import (C, gzprintf, "gzprintf"); - pragma Import (C, gzputs, "gzputs"); - pragma Import (C, gzgets, "gzgets"); - pragma Import (C, gzputc, "gzputc"); - pragma Import (C, gzgetc, "gzgetc"); - pragma Import (C, gzflush, "gzflush"); - pragma Import (C, gzseek, "gzseek"); - pragma Import (C, gzrewind, "gzrewind"); - pragma Import (C, gztell, "gztell"); - pragma Import (C, gzeof, "gzeof"); - pragma Import (C, gzclose, "gzclose"); - pragma Import (C, gzerror, "gzerror"); - pragma Import (C, adler32, "adler32"); - pragma Import (C, crc32, "crc32"); - pragma Import (C, deflateInit, "deflateInit_"); - pragma Import (C, inflateInit, "inflateInit_"); - pragma Import (C, deflateInit2, "deflateInit2_"); - pragma Import (C, inflateInit2, "inflateInit2_"); - pragma Import (C, zError, "zError"); - pragma Import (C, inflateSyncPoint, "inflateSyncPoint"); - pragma Import (C, get_crc_table, "get_crc_table"); - - -- since zlib 1.2.0: - - pragma Import (C, inflateCopy, "inflateCopy"); - pragma Import (C, compressBound, "compressBound"); - pragma Import (C, deflateBound, "deflateBound"); - pragma Import (C, gzungetc, "gzungetc"); - pragma Import (C, zlibCompileFlags, "zlibCompileFlags"); - - pragma Import (C, inflateBackInit, "inflateBackInit_"); - - -- I stopped binding the inflateBack routines, because realize that - -- it does not support zlib and gzip headers for now, and have no - -- symmetric deflateBack routines. - -- ZLib-Ada is symmetric regarding deflate/inflate data transformation - -- and has a similar generic callback interface for the - -- deflate/inflate transformation based on the regular Deflate/Inflate - -- routines. - - -- pragma Import (C, inflateBack, "inflateBack"); - -- pragma Import (C, inflateBackEnd, "inflateBackEnd"); - -end ZLib.Thin; diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/zlib.adb b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/zlib.adb deleted file mode 100644 index 8b6fd68..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/zlib.adb +++ /dev/null @@ -1,701 +0,0 @@ ----------------------------------------------------------------- --- ZLib for Ada thick binding. -- --- -- --- Copyright (C) 2002-2004 Dmitriy Anisimkov -- --- -- --- Open source license information is in the zlib.ads file. -- ----------------------------------------------------------------- - --- $Id: zlib.adb,v 1.31 2004/09/06 06:53:19 vagul Exp $ - -with Ada.Exceptions; -with Ada.Unchecked_Conversion; -with Ada.Unchecked_Deallocation; - -with Interfaces.C.Strings; - -with ZLib.Thin; - -package body ZLib is - - use type Thin.Int; - - type Z_Stream is new Thin.Z_Stream; - - type Return_Code_Enum is - (OK, - STREAM_END, - NEED_DICT, - ERRNO, - STREAM_ERROR, - DATA_ERROR, - MEM_ERROR, - BUF_ERROR, - VERSION_ERROR); - - type Flate_Step_Function is access - function (Strm : in Thin.Z_Streamp; Flush : in Thin.Int) return Thin.Int; - pragma Convention (C, Flate_Step_Function); - - type Flate_End_Function is access - function (Ctrm : in Thin.Z_Streamp) return Thin.Int; - pragma Convention (C, Flate_End_Function); - - type Flate_Type is record - Step : Flate_Step_Function; - Done : Flate_End_Function; - end record; - - subtype Footer_Array is Stream_Element_Array (1 .. 8); - - Simple_GZip_Header : constant Stream_Element_Array (1 .. 10) - := (16#1f#, 16#8b#, -- Magic header - 16#08#, -- Z_DEFLATED - 16#00#, -- Flags - 16#00#, 16#00#, 16#00#, 16#00#, -- Time - 16#00#, -- XFlags - 16#03# -- OS code - ); - -- The simplest gzip header is not for informational, but just for - -- gzip format compatibility. - -- Note that some code below is using assumption - -- Simple_GZip_Header'Last > Footer_Array'Last, so do not make - -- Simple_GZip_Header'Last <= Footer_Array'Last. - - Return_Code : constant array (Thin.Int range <>) of Return_Code_Enum - := (0 => OK, - 1 => STREAM_END, - 2 => NEED_DICT, - -1 => ERRNO, - -2 => STREAM_ERROR, - -3 => DATA_ERROR, - -4 => MEM_ERROR, - -5 => BUF_ERROR, - -6 => VERSION_ERROR); - - Flate : constant array (Boolean) of Flate_Type - := (True => (Step => Thin.Deflate'Access, - Done => Thin.DeflateEnd'Access), - False => (Step => Thin.Inflate'Access, - Done => Thin.InflateEnd'Access)); - - Flush_Finish : constant array (Boolean) of Flush_Mode - := (True => Finish, False => No_Flush); - - procedure Raise_Error (Stream : in Z_Stream); - pragma Inline (Raise_Error); - - procedure Raise_Error (Message : in String); - pragma Inline (Raise_Error); - - procedure Check_Error (Stream : in Z_Stream; Code : in Thin.Int); - - procedure Free is new Ada.Unchecked_Deallocation - (Z_Stream, Z_Stream_Access); - - function To_Thin_Access is new Ada.Unchecked_Conversion - (Z_Stream_Access, Thin.Z_Streamp); - - procedure Translate_GZip - (Filter : in out Filter_Type; - In_Data : in Ada.Streams.Stream_Element_Array; - In_Last : out Ada.Streams.Stream_Element_Offset; - Out_Data : out Ada.Streams.Stream_Element_Array; - Out_Last : out Ada.Streams.Stream_Element_Offset; - Flush : in Flush_Mode); - -- Separate translate routine for make gzip header. - - procedure Translate_Auto - (Filter : in out Filter_Type; - In_Data : in Ada.Streams.Stream_Element_Array; - In_Last : out Ada.Streams.Stream_Element_Offset; - Out_Data : out Ada.Streams.Stream_Element_Array; - Out_Last : out Ada.Streams.Stream_Element_Offset; - Flush : in Flush_Mode); - -- translate routine without additional headers. - - ----------------- - -- Check_Error -- - ----------------- - - procedure Check_Error (Stream : in Z_Stream; Code : in Thin.Int) is - use type Thin.Int; - begin - if Code /= Thin.Z_OK then - Raise_Error - (Return_Code_Enum'Image (Return_Code (Code)) - & ": " & Last_Error_Message (Stream)); - end if; - end Check_Error; - - ----------- - -- Close -- - ----------- - - procedure Close - (Filter : in out Filter_Type; - Ignore_Error : in Boolean := False) - is - Code : Thin.Int; - begin - if not Ignore_Error and then not Is_Open (Filter) then - raise Status_Error; - end if; - - Code := Flate (Filter.Compression).Done (To_Thin_Access (Filter.Strm)); - - if Ignore_Error or else Code = Thin.Z_OK then - Free (Filter.Strm); - else - declare - Error_Message : constant String - := Last_Error_Message (Filter.Strm.all); - begin - Free (Filter.Strm); - Ada.Exceptions.Raise_Exception - (ZLib_Error'Identity, - Return_Code_Enum'Image (Return_Code (Code)) - & ": " & Error_Message); - end; - end if; - end Close; - - ----------- - -- CRC32 -- - ----------- - - function CRC32 - (CRC : in Unsigned_32; - Data : in Ada.Streams.Stream_Element_Array) - return Unsigned_32 - is - use Thin; - begin - return Unsigned_32 (crc32 (ULong (CRC), - Data'Address, - Data'Length)); - end CRC32; - - procedure CRC32 - (CRC : in out Unsigned_32; - Data : in Ada.Streams.Stream_Element_Array) is - begin - CRC := CRC32 (CRC, Data); - end CRC32; - - ------------------ - -- Deflate_Init -- - ------------------ - - procedure Deflate_Init - (Filter : in out Filter_Type; - Level : in Compression_Level := Default_Compression; - Strategy : in Strategy_Type := Default_Strategy; - Method : in Compression_Method := Deflated; - Window_Bits : in Window_Bits_Type := Default_Window_Bits; - Memory_Level : in Memory_Level_Type := Default_Memory_Level; - Header : in Header_Type := Default) - is - use type Thin.Int; - Win_Bits : Thin.Int := Thin.Int (Window_Bits); - begin - if Is_Open (Filter) then - raise Status_Error; - end if; - - -- We allow ZLib to make header only in case of default header type. - -- Otherwise we would either do header by ourselfs, or do not do - -- header at all. - - if Header = None or else Header = GZip then - Win_Bits := -Win_Bits; - end if; - - -- For the GZip CRC calculation and make headers. - - if Header = GZip then - Filter.CRC := 0; - Filter.Offset := Simple_GZip_Header'First; - else - Filter.Offset := Simple_GZip_Header'Last + 1; - end if; - - Filter.Strm := new Z_Stream; - Filter.Compression := True; - Filter.Stream_End := False; - Filter.Header := Header; - - if Thin.Deflate_Init - (To_Thin_Access (Filter.Strm), - Level => Thin.Int (Level), - method => Thin.Int (Method), - windowBits => Win_Bits, - memLevel => Thin.Int (Memory_Level), - strategy => Thin.Int (Strategy)) /= Thin.Z_OK - then - Raise_Error (Filter.Strm.all); - end if; - end Deflate_Init; - - ----------- - -- Flush -- - ----------- - - procedure Flush - (Filter : in out Filter_Type; - Out_Data : out Ada.Streams.Stream_Element_Array; - Out_Last : out Ada.Streams.Stream_Element_Offset; - Flush : in Flush_Mode) - is - No_Data : Stream_Element_Array := (1 .. 0 => 0); - Last : Stream_Element_Offset; - begin - Translate (Filter, No_Data, Last, Out_Data, Out_Last, Flush); - end Flush; - - ----------------------- - -- Generic_Translate -- - ----------------------- - - procedure Generic_Translate - (Filter : in out ZLib.Filter_Type; - In_Buffer_Size : in Integer := Default_Buffer_Size; - Out_Buffer_Size : in Integer := Default_Buffer_Size) - is - In_Buffer : Stream_Element_Array - (1 .. Stream_Element_Offset (In_Buffer_Size)); - Out_Buffer : Stream_Element_Array - (1 .. Stream_Element_Offset (Out_Buffer_Size)); - Last : Stream_Element_Offset; - In_Last : Stream_Element_Offset; - In_First : Stream_Element_Offset; - Out_Last : Stream_Element_Offset; - begin - Main : loop - Data_In (In_Buffer, Last); - - In_First := In_Buffer'First; - - loop - Translate - (Filter => Filter, - In_Data => In_Buffer (In_First .. Last), - In_Last => In_Last, - Out_Data => Out_Buffer, - Out_Last => Out_Last, - Flush => Flush_Finish (Last < In_Buffer'First)); - - if Out_Buffer'First <= Out_Last then - Data_Out (Out_Buffer (Out_Buffer'First .. Out_Last)); - end if; - - exit Main when Stream_End (Filter); - - -- The end of in buffer. - - exit when In_Last = Last; - - In_First := In_Last + 1; - end loop; - end loop Main; - - end Generic_Translate; - - ------------------ - -- Inflate_Init -- - ------------------ - - procedure Inflate_Init - (Filter : in out Filter_Type; - Window_Bits : in Window_Bits_Type := Default_Window_Bits; - Header : in Header_Type := Default) - is - use type Thin.Int; - Win_Bits : Thin.Int := Thin.Int (Window_Bits); - - procedure Check_Version; - -- Check the latest header types compatibility. - - procedure Check_Version is - begin - if Version <= "1.1.4" then - Raise_Error - ("Inflate header type " & Header_Type'Image (Header) - & " incompatible with ZLib version " & Version); - end if; - end Check_Version; - - begin - if Is_Open (Filter) then - raise Status_Error; - end if; - - case Header is - when None => - Check_Version; - - -- Inflate data without headers determined - -- by negative Win_Bits. - - Win_Bits := -Win_Bits; - when GZip => - Check_Version; - - -- Inflate gzip data defined by flag 16. - - Win_Bits := Win_Bits + 16; - when Auto => - Check_Version; - - -- Inflate with automatic detection - -- of gzip or native header defined by flag 32. - - Win_Bits := Win_Bits + 32; - when Default => null; - end case; - - Filter.Strm := new Z_Stream; - Filter.Compression := False; - Filter.Stream_End := False; - Filter.Header := Header; - - if Thin.Inflate_Init - (To_Thin_Access (Filter.Strm), Win_Bits) /= Thin.Z_OK - then - Raise_Error (Filter.Strm.all); - end if; - end Inflate_Init; - - ------------- - -- Is_Open -- - ------------- - - function Is_Open (Filter : in Filter_Type) return Boolean is - begin - return Filter.Strm /= null; - end Is_Open; - - ----------------- - -- Raise_Error -- - ----------------- - - procedure Raise_Error (Message : in String) is - begin - Ada.Exceptions.Raise_Exception (ZLib_Error'Identity, Message); - end Raise_Error; - - procedure Raise_Error (Stream : in Z_Stream) is - begin - Raise_Error (Last_Error_Message (Stream)); - end Raise_Error; - - ---------- - -- Read -- - ---------- - - procedure Read - (Filter : in out Filter_Type; - Item : out Ada.Streams.Stream_Element_Array; - Last : out Ada.Streams.Stream_Element_Offset; - Flush : in Flush_Mode := No_Flush) - is - In_Last : Stream_Element_Offset; - Item_First : Ada.Streams.Stream_Element_Offset := Item'First; - V_Flush : Flush_Mode := Flush; - - begin - pragma Assert (Rest_First in Buffer'First .. Buffer'Last + 1); - pragma Assert (Rest_Last in Buffer'First - 1 .. Buffer'Last); - - loop - if Rest_Last = Buffer'First - 1 then - V_Flush := Finish; - - elsif Rest_First > Rest_Last then - Read (Buffer, Rest_Last); - Rest_First := Buffer'First; - - if Rest_Last < Buffer'First then - V_Flush := Finish; - end if; - end if; - - Translate - (Filter => Filter, - In_Data => Buffer (Rest_First .. Rest_Last), - In_Last => In_Last, - Out_Data => Item (Item_First .. Item'Last), - Out_Last => Last, - Flush => V_Flush); - - Rest_First := In_Last + 1; - - exit when Stream_End (Filter) - or else Last = Item'Last - or else (Last >= Item'First and then Allow_Read_Some); - - Item_First := Last + 1; - end loop; - end Read; - - ---------------- - -- Stream_End -- - ---------------- - - function Stream_End (Filter : in Filter_Type) return Boolean is - begin - if Filter.Header = GZip and Filter.Compression then - return Filter.Stream_End - and then Filter.Offset = Footer_Array'Last + 1; - else - return Filter.Stream_End; - end if; - end Stream_End; - - -------------- - -- Total_In -- - -------------- - - function Total_In (Filter : in Filter_Type) return Count is - begin - return Count (Thin.Total_In (To_Thin_Access (Filter.Strm).all)); - end Total_In; - - --------------- - -- Total_Out -- - --------------- - - function Total_Out (Filter : in Filter_Type) return Count is - begin - return Count (Thin.Total_Out (To_Thin_Access (Filter.Strm).all)); - end Total_Out; - - --------------- - -- Translate -- - --------------- - - procedure Translate - (Filter : in out Filter_Type; - In_Data : in Ada.Streams.Stream_Element_Array; - In_Last : out Ada.Streams.Stream_Element_Offset; - Out_Data : out Ada.Streams.Stream_Element_Array; - Out_Last : out Ada.Streams.Stream_Element_Offset; - Flush : in Flush_Mode) is - begin - if Filter.Header = GZip and then Filter.Compression then - Translate_GZip - (Filter => Filter, - In_Data => In_Data, - In_Last => In_Last, - Out_Data => Out_Data, - Out_Last => Out_Last, - Flush => Flush); - else - Translate_Auto - (Filter => Filter, - In_Data => In_Data, - In_Last => In_Last, - Out_Data => Out_Data, - Out_Last => Out_Last, - Flush => Flush); - end if; - end Translate; - - -------------------- - -- Translate_Auto -- - -------------------- - - procedure Translate_Auto - (Filter : in out Filter_Type; - In_Data : in Ada.Streams.Stream_Element_Array; - In_Last : out Ada.Streams.Stream_Element_Offset; - Out_Data : out Ada.Streams.Stream_Element_Array; - Out_Last : out Ada.Streams.Stream_Element_Offset; - Flush : in Flush_Mode) - is - use type Thin.Int; - Code : Thin.Int; - - begin - if not Is_Open (Filter) then - raise Status_Error; - end if; - - if Out_Data'Length = 0 and then In_Data'Length = 0 then - raise Constraint_Error; - end if; - - Set_Out (Filter.Strm.all, Out_Data'Address, Out_Data'Length); - Set_In (Filter.Strm.all, In_Data'Address, In_Data'Length); - - Code := Flate (Filter.Compression).Step - (To_Thin_Access (Filter.Strm), - Thin.Int (Flush)); - - if Code = Thin.Z_STREAM_END then - Filter.Stream_End := True; - else - Check_Error (Filter.Strm.all, Code); - end if; - - In_Last := In_Data'Last - - Stream_Element_Offset (Avail_In (Filter.Strm.all)); - Out_Last := Out_Data'Last - - Stream_Element_Offset (Avail_Out (Filter.Strm.all)); - end Translate_Auto; - - -------------------- - -- Translate_GZip -- - -------------------- - - procedure Translate_GZip - (Filter : in out Filter_Type; - In_Data : in Ada.Streams.Stream_Element_Array; - In_Last : out Ada.Streams.Stream_Element_Offset; - Out_Data : out Ada.Streams.Stream_Element_Array; - Out_Last : out Ada.Streams.Stream_Element_Offset; - Flush : in Flush_Mode) - is - Out_First : Stream_Element_Offset; - - procedure Add_Data (Data : in Stream_Element_Array); - -- Add data to stream from the Filter.Offset till necessary, - -- used for add gzip headr/footer. - - procedure Put_32 - (Item : in out Stream_Element_Array; - Data : in Unsigned_32); - pragma Inline (Put_32); - - -------------- - -- Add_Data -- - -------------- - - procedure Add_Data (Data : in Stream_Element_Array) is - Data_First : Stream_Element_Offset renames Filter.Offset; - Data_Last : Stream_Element_Offset; - Data_Len : Stream_Element_Offset; -- -1 - Out_Len : Stream_Element_Offset; -- -1 - begin - Out_First := Out_Last + 1; - - if Data_First > Data'Last then - return; - end if; - - Data_Len := Data'Last - Data_First; - Out_Len := Out_Data'Last - Out_First; - - if Data_Len <= Out_Len then - Out_Last := Out_First + Data_Len; - Data_Last := Data'Last; - else - Out_Last := Out_Data'Last; - Data_Last := Data_First + Out_Len; - end if; - - Out_Data (Out_First .. Out_Last) := Data (Data_First .. Data_Last); - - Data_First := Data_Last + 1; - Out_First := Out_Last + 1; - end Add_Data; - - ------------ - -- Put_32 -- - ------------ - - procedure Put_32 - (Item : in out Stream_Element_Array; - Data : in Unsigned_32) - is - D : Unsigned_32 := Data; - begin - for J in Item'First .. Item'First + 3 loop - Item (J) := Stream_Element (D and 16#FF#); - D := Shift_Right (D, 8); - end loop; - end Put_32; - - begin - Out_Last := Out_Data'First - 1; - - if not Filter.Stream_End then - Add_Data (Simple_GZip_Header); - - Translate_Auto - (Filter => Filter, - In_Data => In_Data, - In_Last => In_Last, - Out_Data => Out_Data (Out_First .. Out_Data'Last), - Out_Last => Out_Last, - Flush => Flush); - - CRC32 (Filter.CRC, In_Data (In_Data'First .. In_Last)); - end if; - - if Filter.Stream_End and then Out_Last <= Out_Data'Last then - -- This detection method would work only when - -- Simple_GZip_Header'Last > Footer_Array'Last - - if Filter.Offset = Simple_GZip_Header'Last + 1 then - Filter.Offset := Footer_Array'First; - end if; - - declare - Footer : Footer_Array; - begin - Put_32 (Footer, Filter.CRC); - Put_32 (Footer (Footer'First + 4 .. Footer'Last), - Unsigned_32 (Total_In (Filter))); - Add_Data (Footer); - end; - end if; - end Translate_GZip; - - ------------- - -- Version -- - ------------- - - function Version return String is - begin - return Interfaces.C.Strings.Value (Thin.zlibVersion); - end Version; - - ----------- - -- Write -- - ----------- - - procedure Write - (Filter : in out Filter_Type; - Item : in Ada.Streams.Stream_Element_Array; - Flush : in Flush_Mode := No_Flush) - is - Buffer : Stream_Element_Array (1 .. Buffer_Size); - In_Last : Stream_Element_Offset; - Out_Last : Stream_Element_Offset; - In_First : Stream_Element_Offset := Item'First; - begin - if Item'Length = 0 and Flush = No_Flush then - return; - end if; - - loop - Translate - (Filter => Filter, - In_Data => Item (In_First .. Item'Last), - In_Last => In_Last, - Out_Data => Buffer, - Out_Last => Out_Last, - Flush => Flush); - - if Out_Last >= Buffer'First then - Write (Buffer (1 .. Out_Last)); - end if; - - exit when In_Last = Item'Last or Stream_End (Filter); - - In_First := In_Last + 1; - end loop; - end Write; - -end ZLib; diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/zlib.ads b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/zlib.ads deleted file mode 100644 index 79ffc40..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/zlib.ads +++ /dev/null @@ -1,328 +0,0 @@ ------------------------------------------------------------------------------- --- ZLib for Ada thick binding. -- --- -- --- Copyright (C) 2002-2004 Dmitriy Anisimkov -- --- -- --- This library is free software; you can redistribute it and/or modify -- --- it under the terms of the GNU General Public License as published by -- --- the Free Software Foundation; either version 2 of the License, or (at -- --- your option) any later version. -- --- -- --- This library is distributed in the hope that it will be useful, but -- --- WITHOUT ANY WARRANTY; without even the implied warranty of -- --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- --- General Public License for more details. -- --- -- --- You should have received a copy of the GNU General Public License -- --- along with this library; if not, write to the Free Software Foundation, -- --- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- --- -- --- As a special exception, if other files instantiate generics from this -- --- unit, or you link this unit with other files to produce an executable, -- --- this unit does not by itself cause the resulting executable to be -- --- covered by the GNU General Public License. This exception does not -- --- however invalidate any other reasons why the executable file might be -- --- covered by the GNU Public License. -- ------------------------------------------------------------------------------- - --- $Id: zlib.ads,v 1.26 2004/09/06 06:53:19 vagul Exp $ - -with Ada.Streams; - -with Interfaces; - -package ZLib is - - ZLib_Error : exception; - Status_Error : exception; - - type Compression_Level is new Integer range -1 .. 9; - - type Flush_Mode is private; - - type Compression_Method is private; - - type Window_Bits_Type is new Integer range 8 .. 15; - - type Memory_Level_Type is new Integer range 1 .. 9; - - type Unsigned_32 is new Interfaces.Unsigned_32; - - type Strategy_Type is private; - - type Header_Type is (None, Auto, Default, GZip); - -- Header type usage have a some limitation for inflate. - -- See comment for Inflate_Init. - - subtype Count is Ada.Streams.Stream_Element_Count; - - Default_Memory_Level : constant Memory_Level_Type := 8; - Default_Window_Bits : constant Window_Bits_Type := 15; - - ---------------------------------- - -- Compression method constants -- - ---------------------------------- - - Deflated : constant Compression_Method; - -- Only one method allowed in this ZLib version - - --------------------------------- - -- Compression level constants -- - --------------------------------- - - No_Compression : constant Compression_Level := 0; - Best_Speed : constant Compression_Level := 1; - Best_Compression : constant Compression_Level := 9; - Default_Compression : constant Compression_Level := -1; - - -------------------------- - -- Flush mode constants -- - -------------------------- - - No_Flush : constant Flush_Mode; - -- Regular way for compression, no flush - - Partial_Flush : constant Flush_Mode; - -- Will be removed, use Z_SYNC_FLUSH instead - - Sync_Flush : constant Flush_Mode; - -- All pending output is flushed to the output buffer and the output - -- is aligned on a byte boundary, so that the decompressor can get all - -- input data available so far. (In particular avail_in is zero after the - -- call if enough output space has been provided before the call.) - -- Flushing may degrade compression for some compression algorithms and so - -- it should be used only when necessary. - - Block_Flush : constant Flush_Mode; - -- Z_BLOCK requests that inflate() stop - -- if and when it get to the next deflate block boundary. When decoding the - -- zlib or gzip format, this will cause inflate() to return immediately - -- after the header and before the first block. When doing a raw inflate, - -- inflate() will go ahead and process the first block, and will return - -- when it gets to the end of that block, or when it runs out of data. - - Full_Flush : constant Flush_Mode; - -- All output is flushed as with SYNC_FLUSH, and the compression state - -- is reset so that decompression can restart from this point if previous - -- compressed data has been damaged or if random access is desired. Using - -- Full_Flush too often can seriously degrade the compression. - - Finish : constant Flush_Mode; - -- Just for tell the compressor that input data is complete. - - ------------------------------------ - -- Compression strategy constants -- - ------------------------------------ - - -- RLE stategy could be used only in version 1.2.0 and later. - - Filtered : constant Strategy_Type; - Huffman_Only : constant Strategy_Type; - RLE : constant Strategy_Type; - Default_Strategy : constant Strategy_Type; - - Default_Buffer_Size : constant := 4096; - - type Filter_Type is tagged limited private; - -- The filter is for compression and for decompression. - -- The usage of the type is depend of its initialization. - - function Version return String; - pragma Inline (Version); - -- Return string representation of the ZLib version. - - procedure Deflate_Init - (Filter : in out Filter_Type; - Level : in Compression_Level := Default_Compression; - Strategy : in Strategy_Type := Default_Strategy; - Method : in Compression_Method := Deflated; - Window_Bits : in Window_Bits_Type := Default_Window_Bits; - Memory_Level : in Memory_Level_Type := Default_Memory_Level; - Header : in Header_Type := Default); - -- Compressor initialization. - -- When Header parameter is Auto or Default, then default zlib header - -- would be provided for compressed data. - -- When Header is GZip, then gzip header would be set instead of - -- default header. - -- When Header is None, no header would be set for compressed data. - - procedure Inflate_Init - (Filter : in out Filter_Type; - Window_Bits : in Window_Bits_Type := Default_Window_Bits; - Header : in Header_Type := Default); - -- Decompressor initialization. - -- Default header type mean that ZLib default header is expecting in the - -- input compressed stream. - -- Header type None mean that no header is expecting in the input stream. - -- GZip header type mean that GZip header is expecting in the - -- input compressed stream. - -- Auto header type mean that header type (GZip or Native) would be - -- detected automatically in the input stream. - -- Note that header types parameter values None, GZip and Auto are - -- supported for inflate routine only in ZLib versions 1.2.0.2 and later. - -- Deflate_Init is supporting all header types. - - function Is_Open (Filter : in Filter_Type) return Boolean; - pragma Inline (Is_Open); - -- Is the filter opened for compression or decompression. - - procedure Close - (Filter : in out Filter_Type; - Ignore_Error : in Boolean := False); - -- Closing the compression or decompressor. - -- If stream is closing before the complete and Ignore_Error is False, - -- The exception would be raised. - - generic - with procedure Data_In - (Item : out Ada.Streams.Stream_Element_Array; - Last : out Ada.Streams.Stream_Element_Offset); - with procedure Data_Out - (Item : in Ada.Streams.Stream_Element_Array); - procedure Generic_Translate - (Filter : in out Filter_Type; - In_Buffer_Size : in Integer := Default_Buffer_Size; - Out_Buffer_Size : in Integer := Default_Buffer_Size); - -- Compress/decompress data fetch from Data_In routine and pass the result - -- to the Data_Out routine. User should provide Data_In and Data_Out - -- for compression/decompression data flow. - -- Compression or decompression depend on Filter initialization. - - function Total_In (Filter : in Filter_Type) return Count; - pragma Inline (Total_In); - -- Returns total number of input bytes read so far - - function Total_Out (Filter : in Filter_Type) return Count; - pragma Inline (Total_Out); - -- Returns total number of bytes output so far - - function CRC32 - (CRC : in Unsigned_32; - Data : in Ada.Streams.Stream_Element_Array) - return Unsigned_32; - pragma Inline (CRC32); - -- Compute CRC32, it could be necessary for make gzip format - - procedure CRC32 - (CRC : in out Unsigned_32; - Data : in Ada.Streams.Stream_Element_Array); - pragma Inline (CRC32); - -- Compute CRC32, it could be necessary for make gzip format - - ------------------------------------------------- - -- Below is more complex low level routines. -- - ------------------------------------------------- - - procedure Translate - (Filter : in out Filter_Type; - In_Data : in Ada.Streams.Stream_Element_Array; - In_Last : out Ada.Streams.Stream_Element_Offset; - Out_Data : out Ada.Streams.Stream_Element_Array; - Out_Last : out Ada.Streams.Stream_Element_Offset; - Flush : in Flush_Mode); - -- Compress/decompress the In_Data buffer and place the result into - -- Out_Data. In_Last is the index of last element from In_Data accepted by - -- the Filter. Out_Last is the last element of the received data from - -- Filter. To tell the filter that incoming data are complete put the - -- Flush parameter to Finish. - - function Stream_End (Filter : in Filter_Type) return Boolean; - pragma Inline (Stream_End); - -- Return the true when the stream is complete. - - procedure Flush - (Filter : in out Filter_Type; - Out_Data : out Ada.Streams.Stream_Element_Array; - Out_Last : out Ada.Streams.Stream_Element_Offset; - Flush : in Flush_Mode); - pragma Inline (Flush); - -- Flushing the data from the compressor. - - generic - with procedure Write - (Item : in Ada.Streams.Stream_Element_Array); - -- User should provide this routine for accept - -- compressed/decompressed data. - - Buffer_Size : in Ada.Streams.Stream_Element_Offset - := Default_Buffer_Size; - -- Buffer size for Write user routine. - - procedure Write - (Filter : in out Filter_Type; - Item : in Ada.Streams.Stream_Element_Array; - Flush : in Flush_Mode := No_Flush); - -- Compress/Decompress data from Item to the generic parameter procedure - -- Write. Output buffer size could be set in Buffer_Size generic parameter. - - generic - with procedure Read - (Item : out Ada.Streams.Stream_Element_Array; - Last : out Ada.Streams.Stream_Element_Offset); - -- User should provide data for compression/decompression - -- thru this routine. - - Buffer : in out Ada.Streams.Stream_Element_Array; - -- Buffer for keep remaining data from the previous - -- back read. - - Rest_First, Rest_Last : in out Ada.Streams.Stream_Element_Offset; - -- Rest_First have to be initialized to Buffer'Last + 1 - -- Rest_Last have to be initialized to Buffer'Last - -- before usage. - - Allow_Read_Some : in Boolean := False; - -- Is it allowed to return Last < Item'Last before end of data. - - procedure Read - (Filter : in out Filter_Type; - Item : out Ada.Streams.Stream_Element_Array; - Last : out Ada.Streams.Stream_Element_Offset; - Flush : in Flush_Mode := No_Flush); - -- Compress/Decompress data from generic parameter procedure Read to the - -- Item. User should provide Buffer and initialized Rest_First, Rest_Last - -- indicators. If Allow_Read_Some is True, Read routines could return - -- Last < Item'Last only at end of stream. - -private - - use Ada.Streams; - - pragma Assert (Ada.Streams.Stream_Element'Size = 8); - pragma Assert (Ada.Streams.Stream_Element'Modulus = 2**8); - - type Flush_Mode is new Integer range 0 .. 5; - - type Compression_Method is new Integer range 8 .. 8; - - type Strategy_Type is new Integer range 0 .. 3; - - No_Flush : constant Flush_Mode := 0; - Partial_Flush : constant Flush_Mode := 1; - Sync_Flush : constant Flush_Mode := 2; - Full_Flush : constant Flush_Mode := 3; - Finish : constant Flush_Mode := 4; - Block_Flush : constant Flush_Mode := 5; - - Filtered : constant Strategy_Type := 1; - Huffman_Only : constant Strategy_Type := 2; - RLE : constant Strategy_Type := 3; - Default_Strategy : constant Strategy_Type := 0; - - Deflated : constant Compression_Method := 8; - - type Z_Stream; - - type Z_Stream_Access is access all Z_Stream; - - type Filter_Type is tagged limited record - Strm : Z_Stream_Access; - Compression : Boolean; - Stream_End : Boolean; - Header : Header_Type; - CRC : Unsigned_32; - Offset : Stream_Element_Offset; - -- Offset for gzip header/footer output. - end record; - -end ZLib; diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/zlib.gpr b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/zlib.gpr deleted file mode 100644 index 296b22a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/ada/zlib.gpr +++ /dev/null @@ -1,20 +0,0 @@ -project Zlib is - - for Languages use ("Ada"); - for Source_Dirs use ("."); - for Object_Dir use "."; - for Main use ("test.adb", "mtest.adb", "read.adb", "buffer_demo"); - - package Compiler is - for Default_Switches ("ada") use ("-gnatwcfilopru", "-gnatVcdfimorst", "-gnatyabcefhiklmnoprst"); - end Compiler; - - package Linker is - for Default_Switches ("ada") use ("-lz"); - end Linker; - - package Builder is - for Default_Switches ("ada") use ("-s", "-gnatQ"); - end Builder; - -end Zlib; diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/blast/Makefile b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/blast/Makefile deleted file mode 100644 index 9be80ba..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/blast/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -blast: blast.c blast.h - cc -DTEST -o blast blast.c - -test: blast - blast < test.pk | cmp - test.txt - -clean: - rm -f blast blast.o diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/blast/README b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/blast/README deleted file mode 100644 index e3a60b3..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/blast/README +++ /dev/null @@ -1,4 +0,0 @@ -Read blast.h for purpose and usage. - -Mark Adler -madler@alumni.caltech.edu diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/blast/blast.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/blast/blast.c deleted file mode 100644 index e6e6590..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/blast/blast.c +++ /dev/null @@ -1,466 +0,0 @@ -/* blast.c - * Copyright (C) 2003, 2012, 2013 Mark Adler - * For conditions of distribution and use, see copyright notice in blast.h - * version 1.3, 24 Aug 2013 - * - * blast.c decompresses data compressed by the PKWare Compression Library. - * This function provides functionality similar to the explode() function of - * the PKWare library, hence the name "blast". - * - * This decompressor is based on the excellent format description provided by - * Ben Rudiak-Gould in comp.compression on August 13, 2001. Interestingly, the - * example Ben provided in the post is incorrect. The distance 110001 should - * instead be 111000. When corrected, the example byte stream becomes: - * - * 00 04 82 24 25 8f 80 7f - * - * which decompresses to "AIAIAIAIAIAIA" (without the quotes). - */ - -/* - * Change history: - * - * 1.0 12 Feb 2003 - First version - * 1.1 16 Feb 2003 - Fixed distance check for > 4 GB uncompressed data - * 1.2 24 Oct 2012 - Add note about using binary mode in stdio - * - Fix comparisons of differently signed integers - * 1.3 24 Aug 2013 - Return unused input from blast() - * - Fix test code to correctly report unused input - * - Enable the provision of initial input to blast() - */ - -#include /* for NULL */ -#include /* for setjmp(), longjmp(), and jmp_buf */ -#include "blast.h" /* prototype for blast() */ - -#define local static /* for local function definitions */ -#define MAXBITS 13 /* maximum code length */ -#define MAXWIN 4096 /* maximum window size */ - -/* input and output state */ -struct state { - /* input state */ - blast_in infun; /* input function provided by user */ - void *inhow; /* opaque information passed to infun() */ - unsigned char *in; /* next input location */ - unsigned left; /* available input at in */ - int bitbuf; /* bit buffer */ - int bitcnt; /* number of bits in bit buffer */ - - /* input limit error return state for bits() and decode() */ - jmp_buf env; - - /* output state */ - blast_out outfun; /* output function provided by user */ - void *outhow; /* opaque information passed to outfun() */ - unsigned next; /* index of next write location in out[] */ - int first; /* true to check distances (for first 4K) */ - unsigned char out[MAXWIN]; /* output buffer and sliding window */ -}; - -/* - * Return need bits from the input stream. This always leaves less than - * eight bits in the buffer. bits() works properly for need == 0. - * - * Format notes: - * - * - Bits are stored in bytes from the least significant bit to the most - * significant bit. Therefore bits are dropped from the bottom of the bit - * buffer, using shift right, and new bytes are appended to the top of the - * bit buffer, using shift left. - */ -local int bits(struct state *s, int need) -{ - int val; /* bit accumulator */ - - /* load at least need bits into val */ - val = s->bitbuf; - while (s->bitcnt < need) { - if (s->left == 0) { - s->left = s->infun(s->inhow, &(s->in)); - if (s->left == 0) longjmp(s->env, 1); /* out of input */ - } - val |= (int)(*(s->in)++) << s->bitcnt; /* load eight bits */ - s->left--; - s->bitcnt += 8; - } - - /* drop need bits and update buffer, always zero to seven bits left */ - s->bitbuf = val >> need; - s->bitcnt -= need; - - /* return need bits, zeroing the bits above that */ - return val & ((1 << need) - 1); -} - -/* - * Huffman code decoding tables. count[1..MAXBITS] is the number of symbols of - * each length, which for a canonical code are stepped through in order. - * symbol[] are the symbol values in canonical order, where the number of - * entries is the sum of the counts in count[]. The decoding process can be - * seen in the function decode() below. - */ -struct huffman { - short *count; /* number of symbols of each length */ - short *symbol; /* canonically ordered symbols */ -}; - -/* - * Decode a code from the stream s using huffman table h. Return the symbol or - * a negative value if there is an error. If all of the lengths are zero, i.e. - * an empty code, or if the code is incomplete and an invalid code is received, - * then -9 is returned after reading MAXBITS bits. - * - * Format notes: - * - * - The codes as stored in the compressed data are bit-reversed relative to - * a simple integer ordering of codes of the same lengths. Hence below the - * bits are pulled from the compressed data one at a time and used to - * build the code value reversed from what is in the stream in order to - * permit simple integer comparisons for decoding. - * - * - The first code for the shortest length is all ones. Subsequent codes of - * the same length are simply integer decrements of the previous code. When - * moving up a length, a one bit is appended to the code. For a complete - * code, the last code of the longest length will be all zeros. To support - * this ordering, the bits pulled during decoding are inverted to apply the - * more "natural" ordering starting with all zeros and incrementing. - */ -local int decode(struct state *s, struct huffman *h) -{ - int len; /* current number of bits in code */ - int code; /* len bits being decoded */ - int first; /* first code of length len */ - int count; /* number of codes of length len */ - int index; /* index of first code of length len in symbol table */ - int bitbuf; /* bits from stream */ - int left; /* bits left in next or left to process */ - short *next; /* next number of codes */ - - bitbuf = s->bitbuf; - left = s->bitcnt; - code = first = index = 0; - len = 1; - next = h->count + 1; - while (1) { - while (left--) { - code |= (bitbuf & 1) ^ 1; /* invert code */ - bitbuf >>= 1; - count = *next++; - if (code < first + count) { /* if length len, return symbol */ - s->bitbuf = bitbuf; - s->bitcnt = (s->bitcnt - len) & 7; - return h->symbol[index + (code - first)]; - } - index += count; /* else update for next length */ - first += count; - first <<= 1; - code <<= 1; - len++; - } - left = (MAXBITS+1) - len; - if (left == 0) break; - if (s->left == 0) { - s->left = s->infun(s->inhow, &(s->in)); - if (s->left == 0) longjmp(s->env, 1); /* out of input */ - } - bitbuf = *(s->in)++; - s->left--; - if (left > 8) left = 8; - } - return -9; /* ran out of codes */ -} - -/* - * Given a list of repeated code lengths rep[0..n-1], where each byte is a - * count (high four bits + 1) and a code length (low four bits), generate the - * list of code lengths. This compaction reduces the size of the object code. - * Then given the list of code lengths length[0..n-1] representing a canonical - * Huffman code for n symbols, construct the tables required to decode those - * codes. Those tables are the number of codes of each length, and the symbols - * sorted by length, retaining their original order within each length. The - * return value is zero for a complete code set, negative for an over- - * subscribed code set, and positive for an incomplete code set. The tables - * can be used if the return value is zero or positive, but they cannot be used - * if the return value is negative. If the return value is zero, it is not - * possible for decode() using that table to return an error--any stream of - * enough bits will resolve to a symbol. If the return value is positive, then - * it is possible for decode() using that table to return an error for received - * codes past the end of the incomplete lengths. - */ -local int construct(struct huffman *h, const unsigned char *rep, int n) -{ - int symbol; /* current symbol when stepping through length[] */ - int len; /* current length when stepping through h->count[] */ - int left; /* number of possible codes left of current length */ - short offs[MAXBITS+1]; /* offsets in symbol table for each length */ - short length[256]; /* code lengths */ - - /* convert compact repeat counts into symbol bit length list */ - symbol = 0; - do { - len = *rep++; - left = (len >> 4) + 1; - len &= 15; - do { - length[symbol++] = len; - } while (--left); - } while (--n); - n = symbol; - - /* count number of codes of each length */ - for (len = 0; len <= MAXBITS; len++) - h->count[len] = 0; - for (symbol = 0; symbol < n; symbol++) - (h->count[length[symbol]])++; /* assumes lengths are within bounds */ - if (h->count[0] == n) /* no codes! */ - return 0; /* complete, but decode() will fail */ - - /* check for an over-subscribed or incomplete set of lengths */ - left = 1; /* one possible code of zero length */ - for (len = 1; len <= MAXBITS; len++) { - left <<= 1; /* one more bit, double codes left */ - left -= h->count[len]; /* deduct count from possible codes */ - if (left < 0) return left; /* over-subscribed--return negative */ - } /* left > 0 means incomplete */ - - /* generate offsets into symbol table for each length for sorting */ - offs[1] = 0; - for (len = 1; len < MAXBITS; len++) - offs[len + 1] = offs[len] + h->count[len]; - - /* - * put symbols in table sorted by length, by symbol order within each - * length - */ - for (symbol = 0; symbol < n; symbol++) - if (length[symbol] != 0) - h->symbol[offs[length[symbol]]++] = symbol; - - /* return zero for complete set, positive for incomplete set */ - return left; -} - -/* - * Decode PKWare Compression Library stream. - * - * Format notes: - * - * - First byte is 0 if literals are uncoded or 1 if they are coded. Second - * byte is 4, 5, or 6 for the number of extra bits in the distance code. - * This is the base-2 logarithm of the dictionary size minus six. - * - * - Compressed data is a combination of literals and length/distance pairs - * terminated by an end code. Literals are either Huffman coded or - * uncoded bytes. A length/distance pair is a coded length followed by a - * coded distance to represent a string that occurs earlier in the - * uncompressed data that occurs again at the current location. - * - * - A bit preceding a literal or length/distance pair indicates which comes - * next, 0 for literals, 1 for length/distance. - * - * - If literals are uncoded, then the next eight bits are the literal, in the - * normal bit order in the stream, i.e. no bit-reversal is needed. Similarly, - * no bit reversal is needed for either the length extra bits or the distance - * extra bits. - * - * - Literal bytes are simply written to the output. A length/distance pair is - * an instruction to copy previously uncompressed bytes to the output. The - * copy is from distance bytes back in the output stream, copying for length - * bytes. - * - * - Distances pointing before the beginning of the output data are not - * permitted. - * - * - Overlapped copies, where the length is greater than the distance, are - * allowed and common. For example, a distance of one and a length of 518 - * simply copies the last byte 518 times. A distance of four and a length of - * twelve copies the last four bytes three times. A simple forward copy - * ignoring whether the length is greater than the distance or not implements - * this correctly. - */ -local int decomp(struct state *s) -{ - int lit; /* true if literals are coded */ - int dict; /* log2(dictionary size) - 6 */ - int symbol; /* decoded symbol, extra bits for distance */ - int len; /* length for copy */ - unsigned dist; /* distance for copy */ - int copy; /* copy counter */ - unsigned char *from, *to; /* copy pointers */ - static int virgin = 1; /* build tables once */ - static short litcnt[MAXBITS+1], litsym[256]; /* litcode memory */ - static short lencnt[MAXBITS+1], lensym[16]; /* lencode memory */ - static short distcnt[MAXBITS+1], distsym[64]; /* distcode memory */ - static struct huffman litcode = {litcnt, litsym}; /* length code */ - static struct huffman lencode = {lencnt, lensym}; /* length code */ - static struct huffman distcode = {distcnt, distsym};/* distance code */ - /* bit lengths of literal codes */ - static const unsigned char litlen[] = { - 11, 124, 8, 7, 28, 7, 188, 13, 76, 4, 10, 8, 12, 10, 12, 10, 8, 23, 8, - 9, 7, 6, 7, 8, 7, 6, 55, 8, 23, 24, 12, 11, 7, 9, 11, 12, 6, 7, 22, 5, - 7, 24, 6, 11, 9, 6, 7, 22, 7, 11, 38, 7, 9, 8, 25, 11, 8, 11, 9, 12, - 8, 12, 5, 38, 5, 38, 5, 11, 7, 5, 6, 21, 6, 10, 53, 8, 7, 24, 10, 27, - 44, 253, 253, 253, 252, 252, 252, 13, 12, 45, 12, 45, 12, 61, 12, 45, - 44, 173}; - /* bit lengths of length codes 0..15 */ - static const unsigned char lenlen[] = {2, 35, 36, 53, 38, 23}; - /* bit lengths of distance codes 0..63 */ - static const unsigned char distlen[] = {2, 20, 53, 230, 247, 151, 248}; - static const short base[16] = { /* base for length codes */ - 3, 2, 4, 5, 6, 7, 8, 9, 10, 12, 16, 24, 40, 72, 136, 264}; - static const char extra[16] = { /* extra bits for length codes */ - 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8}; - - /* set up decoding tables (once--might not be thread-safe) */ - if (virgin) { - construct(&litcode, litlen, sizeof(litlen)); - construct(&lencode, lenlen, sizeof(lenlen)); - construct(&distcode, distlen, sizeof(distlen)); - virgin = 0; - } - - /* read header */ - lit = bits(s, 8); - if (lit > 1) return -1; - dict = bits(s, 8); - if (dict < 4 || dict > 6) return -2; - - /* decode literals and length/distance pairs */ - do { - if (bits(s, 1)) { - /* get length */ - symbol = decode(s, &lencode); - len = base[symbol] + bits(s, extra[symbol]); - if (len == 519) break; /* end code */ - - /* get distance */ - symbol = len == 2 ? 2 : dict; - dist = decode(s, &distcode) << symbol; - dist += bits(s, symbol); - dist++; - if (s->first && dist > s->next) - return -3; /* distance too far back */ - - /* copy length bytes from distance bytes back */ - do { - to = s->out + s->next; - from = to - dist; - copy = MAXWIN; - if (s->next < dist) { - from += copy; - copy = dist; - } - copy -= s->next; - if (copy > len) copy = len; - len -= copy; - s->next += copy; - do { - *to++ = *from++; - } while (--copy); - if (s->next == MAXWIN) { - if (s->outfun(s->outhow, s->out, s->next)) return 1; - s->next = 0; - s->first = 0; - } - } while (len != 0); - } - else { - /* get literal and write it */ - symbol = lit ? decode(s, &litcode) : bits(s, 8); - s->out[s->next++] = symbol; - if (s->next == MAXWIN) { - if (s->outfun(s->outhow, s->out, s->next)) return 1; - s->next = 0; - s->first = 0; - } - } - } while (1); - return 0; -} - -/* See comments in blast.h */ -int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow, - unsigned *left, unsigned char **in) -{ - struct state s; /* input/output state */ - int err; /* return value */ - - /* initialize input state */ - s.infun = infun; - s.inhow = inhow; - if (left != NULL && *left) { - s.left = *left; - s.in = *in; - } - else - s.left = 0; - s.bitbuf = 0; - s.bitcnt = 0; - - /* initialize output state */ - s.outfun = outfun; - s.outhow = outhow; - s.next = 0; - s.first = 1; - - /* return if bits() or decode() tries to read past available input */ - if (setjmp(s.env) != 0) /* if came back here via longjmp(), */ - err = 2; /* then skip decomp(), return error */ - else - err = decomp(&s); /* decompress */ - - /* return unused input */ - if (left != NULL) - *left = s.left; - if (in != NULL) - *in = s.left ? s.in : NULL; - - /* write any leftover output and update the error code if needed */ - if (err != 1 && s.next && s.outfun(s.outhow, s.out, s.next) && err == 0) - err = 1; - return err; -} - -#ifdef TEST -/* Example of how to use blast() */ -#include -#include - -#define CHUNK 16384 - -local unsigned inf(void *how, unsigned char **buf) -{ - static unsigned char hold[CHUNK]; - - *buf = hold; - return fread(hold, 1, CHUNK, (FILE *)how); -} - -local int outf(void *how, unsigned char *buf, unsigned len) -{ - return fwrite(buf, 1, len, (FILE *)how) != len; -} - -/* Decompress a PKWare Compression Library stream from stdin to stdout */ -int main(void) -{ - int ret; - unsigned left; - - /* decompress to stdout */ - left = 0; - ret = blast(inf, stdin, outf, stdout, &left, NULL); - if (ret != 0) - fprintf(stderr, "blast error: %d\n", ret); - - /* count any leftover bytes */ - while (getchar() != EOF) - left++; - if (left) - fprintf(stderr, "blast warning: %u unused bytes of input\n", left); - - /* return blast() error code */ - return ret; -} -#endif diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/blast/blast.h b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/blast/blast.h deleted file mode 100644 index ef8544c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/blast/blast.h +++ /dev/null @@ -1,83 +0,0 @@ -/* blast.h -- interface for blast.c - Copyright (C) 2003, 2012, 2013 Mark Adler - version 1.3, 24 Aug 2013 - - This software is provided 'as-is', without any express or implied - warranty. In no event will the author be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Mark Adler madler@alumni.caltech.edu - */ - - -/* - * blast() decompresses the PKWare Data Compression Library (DCL) compressed - * format. It provides the same functionality as the explode() function in - * that library. (Note: PKWare overused the "implode" verb, and the format - * used by their library implode() function is completely different and - * incompatible with the implode compression method supported by PKZIP.) - * - * The binary mode for stdio functions should be used to assure that the - * compressed data is not corrupted when read or written. For example: - * fopen(..., "rb") and fopen(..., "wb"). - */ - - -typedef unsigned (*blast_in)(void *how, unsigned char **buf); -typedef int (*blast_out)(void *how, unsigned char *buf, unsigned len); -/* Definitions for input/output functions passed to blast(). See below for - * what the provided functions need to do. - */ - - -int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow, - unsigned *left, unsigned char **in); -/* Decompress input to output using the provided infun() and outfun() calls. - * On success, the return value of blast() is zero. If there is an error in - * the source data, i.e. it is not in the proper format, then a negative value - * is returned. If there is not enough input available or there is not enough - * output space, then a positive error is returned. - * - * The input function is invoked: len = infun(how, &buf), where buf is set by - * infun() to point to the input buffer, and infun() returns the number of - * available bytes there. If infun() returns zero, then blast() returns with - * an input error. (blast() only asks for input if it needs it.) inhow is for - * use by the application to pass an input descriptor to infun(), if desired. - * - * If left and in are not NULL and *left is not zero when blast() is called, - * then the *left bytes at *in are consumed for input before infun() is used. - * - * The output function is invoked: err = outfun(how, buf, len), where the bytes - * to be written are buf[0..len-1]. If err is not zero, then blast() returns - * with an output error. outfun() is always called with len <= 4096. outhow - * is for use by the application to pass an output descriptor to outfun(), if - * desired. - * - * If there is any unused input, *left is set to the number of bytes that were - * read and *in points to them. Otherwise *left is set to zero and *in is set - * to NULL. If left or in are NULL, then they are not set. - * - * The return codes are: - * - * 2: ran out of input before completing decompression - * 1: output error before completing decompression - * 0: successful decompression - * -1: literal flag not zero or one - * -2: dictionary size not in 4..6 - * -3: distance is too far back - * - * At the bottom of blast.c is an example program that uses blast() that can be - * compiled to produce a command-line decompression filter by defining TEST. - */ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/blast/test.pk b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/blast/test.pk deleted file mode 100644 index be10b2b..0000000 Binary files a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/blast/test.pk and /dev/null differ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/blast/test.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/blast/test.txt deleted file mode 100644 index bfdf1c5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/blast/test.txt +++ /dev/null @@ -1 +0,0 @@ -AIAIAIAIAIAIA \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/delphi/ZLib.pas b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/delphi/ZLib.pas deleted file mode 100644 index d40dad8..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/delphi/ZLib.pas +++ /dev/null @@ -1,557 +0,0 @@ -{*******************************************************} -{ } -{ Borland Delphi Supplemental Components } -{ ZLIB Data Compression Interface Unit } -{ } -{ Copyright (c) 1997,99 Borland Corporation } -{ } -{*******************************************************} - -{ Updated for zlib 1.2.x by Cosmin Truta } - -unit ZLib; - -interface - -uses SysUtils, Classes; - -type - TAlloc = function (AppData: Pointer; Items, Size: Integer): Pointer; cdecl; - TFree = procedure (AppData, Block: Pointer); cdecl; - - // Internal structure. Ignore. - TZStreamRec = packed record - next_in: PChar; // next input byte - avail_in: Integer; // number of bytes available at next_in - total_in: Longint; // total nb of input bytes read so far - - next_out: PChar; // next output byte should be put here - avail_out: Integer; // remaining free space at next_out - total_out: Longint; // total nb of bytes output so far - - msg: PChar; // last error message, NULL if no error - internal: Pointer; // not visible by applications - - zalloc: TAlloc; // used to allocate the internal state - zfree: TFree; // used to free the internal state - AppData: Pointer; // private data object passed to zalloc and zfree - - data_type: Integer; // best guess about the data type: ascii or binary - adler: Longint; // adler32 value of the uncompressed data - reserved: Longint; // reserved for future use - end; - - // Abstract ancestor class - TCustomZlibStream = class(TStream) - private - FStrm: TStream; - FStrmPos: Integer; - FOnProgress: TNotifyEvent; - FZRec: TZStreamRec; - FBuffer: array [Word] of Char; - protected - procedure Progress(Sender: TObject); dynamic; - property OnProgress: TNotifyEvent read FOnProgress write FOnProgress; - constructor Create(Strm: TStream); - end; - -{ TCompressionStream compresses data on the fly as data is written to it, and - stores the compressed data to another stream. - - TCompressionStream is write-only and strictly sequential. Reading from the - stream will raise an exception. Using Seek to move the stream pointer - will raise an exception. - - Output data is cached internally, written to the output stream only when - the internal output buffer is full. All pending output data is flushed - when the stream is destroyed. - - The Position property returns the number of uncompressed bytes of - data that have been written to the stream so far. - - CompressionRate returns the on-the-fly percentage by which the original - data has been compressed: (1 - (CompressedBytes / UncompressedBytes)) * 100 - If raw data size = 100 and compressed data size = 25, the CompressionRate - is 75% - - The OnProgress event is called each time the output buffer is filled and - written to the output stream. This is useful for updating a progress - indicator when you are writing a large chunk of data to the compression - stream in a single call.} - - - TCompressionLevel = (clNone, clFastest, clDefault, clMax); - - TCompressionStream = class(TCustomZlibStream) - private - function GetCompressionRate: Single; - public - constructor Create(CompressionLevel: TCompressionLevel; Dest: TStream); - destructor Destroy; override; - function Read(var Buffer; Count: Longint): Longint; override; - function Write(const Buffer; Count: Longint): Longint; override; - function Seek(Offset: Longint; Origin: Word): Longint; override; - property CompressionRate: Single read GetCompressionRate; - property OnProgress; - end; - -{ TDecompressionStream decompresses data on the fly as data is read from it. - - Compressed data comes from a separate source stream. TDecompressionStream - is read-only and unidirectional; you can seek forward in the stream, but not - backwards. The special case of setting the stream position to zero is - allowed. Seeking forward decompresses data until the requested position in - the uncompressed data has been reached. Seeking backwards, seeking relative - to the end of the stream, requesting the size of the stream, and writing to - the stream will raise an exception. - - The Position property returns the number of bytes of uncompressed data that - have been read from the stream so far. - - The OnProgress event is called each time the internal input buffer of - compressed data is exhausted and the next block is read from the input stream. - This is useful for updating a progress indicator when you are reading a - large chunk of data from the decompression stream in a single call.} - - TDecompressionStream = class(TCustomZlibStream) - public - constructor Create(Source: TStream); - destructor Destroy; override; - function Read(var Buffer; Count: Longint): Longint; override; - function Write(const Buffer; Count: Longint): Longint; override; - function Seek(Offset: Longint; Origin: Word): Longint; override; - property OnProgress; - end; - - - -{ CompressBuf compresses data, buffer to buffer, in one call. - In: InBuf = ptr to compressed data - InBytes = number of bytes in InBuf - Out: OutBuf = ptr to newly allocated buffer containing decompressed data - OutBytes = number of bytes in OutBuf } -procedure CompressBuf(const InBuf: Pointer; InBytes: Integer; - out OutBuf: Pointer; out OutBytes: Integer); - - -{ DecompressBuf decompresses data, buffer to buffer, in one call. - In: InBuf = ptr to compressed data - InBytes = number of bytes in InBuf - OutEstimate = zero, or est. size of the decompressed data - Out: OutBuf = ptr to newly allocated buffer containing decompressed data - OutBytes = number of bytes in OutBuf } -procedure DecompressBuf(const InBuf: Pointer; InBytes: Integer; - OutEstimate: Integer; out OutBuf: Pointer; out OutBytes: Integer); - -{ DecompressToUserBuf decompresses data, buffer to buffer, in one call. - In: InBuf = ptr to compressed data - InBytes = number of bytes in InBuf - Out: OutBuf = ptr to user-allocated buffer to contain decompressed data - BufSize = number of bytes in OutBuf } -procedure DecompressToUserBuf(const InBuf: Pointer; InBytes: Integer; - const OutBuf: Pointer; BufSize: Integer); - -const - zlib_version = '1.2.12'; - -type - EZlibError = class(Exception); - ECompressionError = class(EZlibError); - EDecompressionError = class(EZlibError); - -implementation - -uses ZLibConst; - -const - Z_NO_FLUSH = 0; - Z_PARTIAL_FLUSH = 1; - Z_SYNC_FLUSH = 2; - Z_FULL_FLUSH = 3; - Z_FINISH = 4; - - Z_OK = 0; - Z_STREAM_END = 1; - Z_NEED_DICT = 2; - Z_ERRNO = (-1); - Z_STREAM_ERROR = (-2); - Z_DATA_ERROR = (-3); - Z_MEM_ERROR = (-4); - Z_BUF_ERROR = (-5); - Z_VERSION_ERROR = (-6); - - Z_NO_COMPRESSION = 0; - Z_BEST_SPEED = 1; - Z_BEST_COMPRESSION = 9; - Z_DEFAULT_COMPRESSION = (-1); - - Z_FILTERED = 1; - Z_HUFFMAN_ONLY = 2; - Z_RLE = 3; - Z_DEFAULT_STRATEGY = 0; - - Z_BINARY = 0; - Z_ASCII = 1; - Z_UNKNOWN = 2; - - Z_DEFLATED = 8; - - -{$L adler32.obj} -{$L compress.obj} -{$L crc32.obj} -{$L deflate.obj} -{$L infback.obj} -{$L inffast.obj} -{$L inflate.obj} -{$L inftrees.obj} -{$L trees.obj} -{$L uncompr.obj} -{$L zutil.obj} - -procedure adler32; external; -procedure compressBound; external; -procedure crc32; external; -procedure deflateInit2_; external; -procedure deflateParams; external; - -function _malloc(Size: Integer): Pointer; cdecl; -begin - Result := AllocMem(Size); -end; - -procedure _free(Block: Pointer); cdecl; -begin - FreeMem(Block); -end; - -procedure _memset(P: Pointer; B: Byte; count: Integer); cdecl; -begin - FillChar(P^, count, B); -end; - -procedure _memcpy(dest, source: Pointer; count: Integer); cdecl; -begin - Move(source^, dest^, count); -end; - - - -// deflate compresses data -function deflateInit_(var strm: TZStreamRec; level: Integer; version: PChar; - recsize: Integer): Integer; external; -function deflate(var strm: TZStreamRec; flush: Integer): Integer; external; -function deflateEnd(var strm: TZStreamRec): Integer; external; - -// inflate decompresses data -function inflateInit_(var strm: TZStreamRec; version: PChar; - recsize: Integer): Integer; external; -function inflate(var strm: TZStreamRec; flush: Integer): Integer; external; -function inflateEnd(var strm: TZStreamRec): Integer; external; -function inflateReset(var strm: TZStreamRec): Integer; external; - - -function zlibAllocMem(AppData: Pointer; Items, Size: Integer): Pointer; cdecl; -begin -// GetMem(Result, Items*Size); - Result := AllocMem(Items * Size); -end; - -procedure zlibFreeMem(AppData, Block: Pointer); cdecl; -begin - FreeMem(Block); -end; - -{function zlibCheck(code: Integer): Integer; -begin - Result := code; - if code < 0 then - raise EZlibError.Create('error'); //!! -end;} - -function CCheck(code: Integer): Integer; -begin - Result := code; - if code < 0 then - raise ECompressionError.Create('error'); //!! -end; - -function DCheck(code: Integer): Integer; -begin - Result := code; - if code < 0 then - raise EDecompressionError.Create('error'); //!! -end; - -procedure CompressBuf(const InBuf: Pointer; InBytes: Integer; - out OutBuf: Pointer; out OutBytes: Integer); -var - strm: TZStreamRec; - P: Pointer; -begin - FillChar(strm, sizeof(strm), 0); - strm.zalloc := zlibAllocMem; - strm.zfree := zlibFreeMem; - OutBytes := ((InBytes + (InBytes div 10) + 12) + 255) and not 255; - GetMem(OutBuf, OutBytes); - try - strm.next_in := InBuf; - strm.avail_in := InBytes; - strm.next_out := OutBuf; - strm.avail_out := OutBytes; - CCheck(deflateInit_(strm, Z_BEST_COMPRESSION, zlib_version, sizeof(strm))); - try - while CCheck(deflate(strm, Z_FINISH)) <> Z_STREAM_END do - begin - P := OutBuf; - Inc(OutBytes, 256); - ReallocMem(OutBuf, OutBytes); - strm.next_out := PChar(Integer(OutBuf) + (Integer(strm.next_out) - Integer(P))); - strm.avail_out := 256; - end; - finally - CCheck(deflateEnd(strm)); - end; - ReallocMem(OutBuf, strm.total_out); - OutBytes := strm.total_out; - except - FreeMem(OutBuf); - raise - end; -end; - - -procedure DecompressBuf(const InBuf: Pointer; InBytes: Integer; - OutEstimate: Integer; out OutBuf: Pointer; out OutBytes: Integer); -var - strm: TZStreamRec; - P: Pointer; - BufInc: Integer; -begin - FillChar(strm, sizeof(strm), 0); - strm.zalloc := zlibAllocMem; - strm.zfree := zlibFreeMem; - BufInc := (InBytes + 255) and not 255; - if OutEstimate = 0 then - OutBytes := BufInc - else - OutBytes := OutEstimate; - GetMem(OutBuf, OutBytes); - try - strm.next_in := InBuf; - strm.avail_in := InBytes; - strm.next_out := OutBuf; - strm.avail_out := OutBytes; - DCheck(inflateInit_(strm, zlib_version, sizeof(strm))); - try - while DCheck(inflate(strm, Z_NO_FLUSH)) <> Z_STREAM_END do - begin - P := OutBuf; - Inc(OutBytes, BufInc); - ReallocMem(OutBuf, OutBytes); - strm.next_out := PChar(Integer(OutBuf) + (Integer(strm.next_out) - Integer(P))); - strm.avail_out := BufInc; - end; - finally - DCheck(inflateEnd(strm)); - end; - ReallocMem(OutBuf, strm.total_out); - OutBytes := strm.total_out; - except - FreeMem(OutBuf); - raise - end; -end; - -procedure DecompressToUserBuf(const InBuf: Pointer; InBytes: Integer; - const OutBuf: Pointer; BufSize: Integer); -var - strm: TZStreamRec; -begin - FillChar(strm, sizeof(strm), 0); - strm.zalloc := zlibAllocMem; - strm.zfree := zlibFreeMem; - strm.next_in := InBuf; - strm.avail_in := InBytes; - strm.next_out := OutBuf; - strm.avail_out := BufSize; - DCheck(inflateInit_(strm, zlib_version, sizeof(strm))); - try - if DCheck(inflate(strm, Z_FINISH)) <> Z_STREAM_END then - raise EZlibError.CreateRes(@sTargetBufferTooSmall); - finally - DCheck(inflateEnd(strm)); - end; -end; - -// TCustomZlibStream - -constructor TCustomZLibStream.Create(Strm: TStream); -begin - inherited Create; - FStrm := Strm; - FStrmPos := Strm.Position; - FZRec.zalloc := zlibAllocMem; - FZRec.zfree := zlibFreeMem; -end; - -procedure TCustomZLibStream.Progress(Sender: TObject); -begin - if Assigned(FOnProgress) then FOnProgress(Sender); -end; - - -// TCompressionStream - -constructor TCompressionStream.Create(CompressionLevel: TCompressionLevel; - Dest: TStream); -const - Levels: array [TCompressionLevel] of ShortInt = - (Z_NO_COMPRESSION, Z_BEST_SPEED, Z_DEFAULT_COMPRESSION, Z_BEST_COMPRESSION); -begin - inherited Create(Dest); - FZRec.next_out := FBuffer; - FZRec.avail_out := sizeof(FBuffer); - CCheck(deflateInit_(FZRec, Levels[CompressionLevel], zlib_version, sizeof(FZRec))); -end; - -destructor TCompressionStream.Destroy; -begin - FZRec.next_in := nil; - FZRec.avail_in := 0; - try - if FStrm.Position <> FStrmPos then FStrm.Position := FStrmPos; - while (CCheck(deflate(FZRec, Z_FINISH)) <> Z_STREAM_END) - and (FZRec.avail_out = 0) do - begin - FStrm.WriteBuffer(FBuffer, sizeof(FBuffer)); - FZRec.next_out := FBuffer; - FZRec.avail_out := sizeof(FBuffer); - end; - if FZRec.avail_out < sizeof(FBuffer) then - FStrm.WriteBuffer(FBuffer, sizeof(FBuffer) - FZRec.avail_out); - finally - deflateEnd(FZRec); - end; - inherited Destroy; -end; - -function TCompressionStream.Read(var Buffer; Count: Longint): Longint; -begin - raise ECompressionError.CreateRes(@sInvalidStreamOp); -end; - -function TCompressionStream.Write(const Buffer; Count: Longint): Longint; -begin - FZRec.next_in := @Buffer; - FZRec.avail_in := Count; - if FStrm.Position <> FStrmPos then FStrm.Position := FStrmPos; - while (FZRec.avail_in > 0) do - begin - CCheck(deflate(FZRec, 0)); - if FZRec.avail_out = 0 then - begin - FStrm.WriteBuffer(FBuffer, sizeof(FBuffer)); - FZRec.next_out := FBuffer; - FZRec.avail_out := sizeof(FBuffer); - FStrmPos := FStrm.Position; - Progress(Self); - end; - end; - Result := Count; -end; - -function TCompressionStream.Seek(Offset: Longint; Origin: Word): Longint; -begin - if (Offset = 0) and (Origin = soFromCurrent) then - Result := FZRec.total_in - else - raise ECompressionError.CreateRes(@sInvalidStreamOp); -end; - -function TCompressionStream.GetCompressionRate: Single; -begin - if FZRec.total_in = 0 then - Result := 0 - else - Result := (1.0 - (FZRec.total_out / FZRec.total_in)) * 100.0; -end; - - -// TDecompressionStream - -constructor TDecompressionStream.Create(Source: TStream); -begin - inherited Create(Source); - FZRec.next_in := FBuffer; - FZRec.avail_in := 0; - DCheck(inflateInit_(FZRec, zlib_version, sizeof(FZRec))); -end; - -destructor TDecompressionStream.Destroy; -begin - FStrm.Seek(-FZRec.avail_in, 1); - inflateEnd(FZRec); - inherited Destroy; -end; - -function TDecompressionStream.Read(var Buffer; Count: Longint): Longint; -begin - FZRec.next_out := @Buffer; - FZRec.avail_out := Count; - if FStrm.Position <> FStrmPos then FStrm.Position := FStrmPos; - while (FZRec.avail_out > 0) do - begin - if FZRec.avail_in = 0 then - begin - FZRec.avail_in := FStrm.Read(FBuffer, sizeof(FBuffer)); - if FZRec.avail_in = 0 then - begin - Result := Count - FZRec.avail_out; - Exit; - end; - FZRec.next_in := FBuffer; - FStrmPos := FStrm.Position; - Progress(Self); - end; - CCheck(inflate(FZRec, 0)); - end; - Result := Count; -end; - -function TDecompressionStream.Write(const Buffer; Count: Longint): Longint; -begin - raise EDecompressionError.CreateRes(@sInvalidStreamOp); -end; - -function TDecompressionStream.Seek(Offset: Longint; Origin: Word): Longint; -var - I: Integer; - Buf: array [0..4095] of Char; -begin - if (Offset = 0) and (Origin = soFromBeginning) then - begin - DCheck(inflateReset(FZRec)); - FZRec.next_in := FBuffer; - FZRec.avail_in := 0; - FStrm.Position := 0; - FStrmPos := 0; - end - else if ( (Offset >= 0) and (Origin = soFromCurrent)) or - ( ((Offset - FZRec.total_out) > 0) and (Origin = soFromBeginning)) then - begin - if Origin = soFromBeginning then Dec(Offset, FZRec.total_out); - if Offset > 0 then - begin - for I := 1 to Offset div sizeof(Buf) do - ReadBuffer(Buf, sizeof(Buf)); - ReadBuffer(Buf, Offset mod sizeof(Buf)); - end; - end - else - raise EDecompressionError.CreateRes(@sInvalidStreamOp); - Result := FZRec.total_out; -end; - - -end. diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/delphi/ZLibConst.pas b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/delphi/ZLibConst.pas deleted file mode 100644 index cdfe136..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/delphi/ZLibConst.pas +++ /dev/null @@ -1,11 +0,0 @@ -unit ZLibConst; - -interface - -resourcestring - sTargetBufferTooSmall = 'ZLib error: target buffer may be too small'; - sInvalidStreamOp = 'Invalid stream operation'; - -implementation - -end. diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/delphi/readme.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/delphi/readme.txt deleted file mode 100644 index 2dc9a8b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/delphi/readme.txt +++ /dev/null @@ -1,76 +0,0 @@ - -Overview -======== - -This directory contains an update to the ZLib interface unit, -distributed by Borland as a Delphi supplemental component. - -The original ZLib unit is Copyright (c) 1997,99 Borland Corp., -and is based on zlib version 1.0.4. There are a series of bugs -and security problems associated with that old zlib version, and -we recommend the users to update their ZLib unit. - - -Summary of modifications -======================== - -- Improved makefile, adapted to zlib version 1.2.1. - -- Some field types from TZStreamRec are changed from Integer to - Longint, for consistency with the zlib.h header, and for 64-bit - readiness. - -- The zlib_version constant is updated. - -- The new Z_RLE strategy has its corresponding symbolic constant. - -- The allocation and deallocation functions and function types - (TAlloc, TFree, zlibAllocMem and zlibFreeMem) are now cdecl, - and _malloc and _free are added as C RTL stubs. As a result, - the original C sources of zlib can be compiled out of the box, - and linked to the ZLib unit. - - -Suggestions for improvements -============================ - -Currently, the ZLib unit provides only a limited wrapper around -the zlib library, and much of the original zlib functionality is -missing. Handling compressed file formats like ZIP/GZIP or PNG -cannot be implemented without having this functionality. -Applications that handle these formats are either using their own, -duplicated code, or not using the ZLib unit at all. - -Here are a few suggestions: - -- Checksum class wrappers around adler32() and crc32(), similar - to the Java classes that implement the java.util.zip.Checksum - interface. - -- The ability to read and write raw deflate streams, without the - zlib stream header and trailer. Raw deflate streams are used - in the ZIP file format. - -- The ability to read and write gzip streams, used in the GZIP - file format, and normally produced by the gzip program. - -- The ability to select a different compression strategy, useful - to PNG and MNG image compression, and to multimedia compression - in general. Besides the compression level - - TCompressionLevel = (clNone, clFastest, clDefault, clMax); - - which, in fact, could have used the 'z' prefix and avoided - TColor-like symbols - - TCompressionLevel = (zcNone, zcFastest, zcDefault, zcMax); - - there could be a compression strategy - - TCompressionStrategy = (zsDefault, zsFiltered, zsHuffmanOnly, zsRle); - -- ZIP and GZIP stream handling via TStreams. - - --- -Cosmin Truta diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/delphi/zlibd32.mak b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/delphi/zlibd32.mak deleted file mode 100644 index 9bb00b7..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/delphi/zlibd32.mak +++ /dev/null @@ -1,99 +0,0 @@ -# Makefile for zlib -# For use with Delphi and C++ Builder under Win32 -# Updated for zlib 1.2.x by Cosmin Truta - -# ------------ Borland C++ ------------ - -# This project uses the Delphi (fastcall/register) calling convention: -LOC = -DZEXPORT=__fastcall -DZEXPORTVA=__cdecl - -CC = bcc32 -LD = bcc32 -AR = tlib -# do not use "-pr" in CFLAGS -CFLAGS = -a -d -k- -O2 $(LOC) -LDFLAGS = - - -# variables -ZLIB_LIB = zlib.lib - -OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj -OBJ2 = gzwrite.obj infback.obj inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj -OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzclose.obj+gzlib.obj+gzread.obj -OBJP2 = +gzwrite.obj+infback.obj+inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj - - -# targets -all: $(ZLIB_LIB) example.exe minigzip.exe - -.c.obj: - $(CC) -c $(CFLAGS) $*.c - -adler32.obj: adler32.c zlib.h zconf.h - -compress.obj: compress.c zlib.h zconf.h - -crc32.obj: crc32.c zlib.h zconf.h crc32.h - -deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h - -gzclose.obj: gzclose.c zlib.h zconf.h gzguts.h - -gzlib.obj: gzlib.c zlib.h zconf.h gzguts.h - -gzread.obj: gzread.c zlib.h zconf.h gzguts.h - -gzwrite.obj: gzwrite.c zlib.h zconf.h gzguts.h - -infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ - inffast.h inffixed.h - -inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ - inffast.h - -inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ - inffast.h inffixed.h - -inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h - -trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h - -uncompr.obj: uncompr.c zlib.h zconf.h - -zutil.obj: zutil.c zutil.h zlib.h zconf.h - -example.obj: test/example.c zlib.h zconf.h - -minigzip.obj: test/minigzip.c zlib.h zconf.h - - -# For the sake of the old Borland make, -# the command line is cut to fit in the MS-DOS 128 byte limit: -$(ZLIB_LIB): $(OBJ1) $(OBJ2) - -del $(ZLIB_LIB) - $(AR) $(ZLIB_LIB) $(OBJP1) - $(AR) $(ZLIB_LIB) $(OBJP2) - - -# testing -test: example.exe minigzip.exe - example - echo hello world | minigzip | minigzip -d - -example.exe: example.obj $(ZLIB_LIB) - $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB) - -minigzip.exe: minigzip.obj $(ZLIB_LIB) - $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB) - - -# cleanup -clean: - -del *.obj - -del *.exe - -del *.lib - -del *.tds - -del zlib.bak - -del foo.gz - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib.build b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib.build deleted file mode 100644 index e69630c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib.build +++ /dev/null @@ -1,33 +0,0 @@ - - - A .Net wrapper library around ZLib1.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib.chm b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib.chm deleted file mode 100644 index f214a44..0000000 Binary files a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib.chm and /dev/null differ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib.sln b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib.sln deleted file mode 100644 index 5d533d6..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib.sln +++ /dev/null @@ -1,21 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotZLib", "DotZLib\DotZLib.csproj", "{BB1EE0B1-1808-46CB-B786-949D91117FC5}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Release = Release - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {BB1EE0B1-1808-46CB-B786-949D91117FC5}.Debug.ActiveCfg = Debug|.NET - {BB1EE0B1-1808-46CB-B786-949D91117FC5}.Debug.Build.0 = Debug|.NET - {BB1EE0B1-1808-46CB-B786-949D91117FC5}.Release.ActiveCfg = Release|.NET - {BB1EE0B1-1808-46CB-B786-949D91117FC5}.Release.Build.0 = Release|.NET - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib/AssemblyInfo.cs b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib/AssemblyInfo.cs deleted file mode 100644 index 724c534..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib/AssemblyInfo.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -// -[assembly: AssemblyTitle("DotZLib")] -[assembly: AssemblyDescription(".Net bindings for ZLib compression dll 1.2.x")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Henrik Ravn")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("(c) 2004 by Henrik Ravn")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: - -[assembly: AssemblyVersion("1.0.*")] - -// -// In order to sign your assembly you must specify a key to use. Refer to the -// Microsoft .NET Framework documentation for more information on assembly signing. -// -// Use the attributes below to control which key is used for signing. -// -// Notes: -// (*) If no key is specified, the assembly is not signed. -// (*) KeyName refers to a key that has been installed in the Crypto Service -// Provider (CSP) on your machine. KeyFile refers to a file which contains -// a key. -// (*) If the KeyFile and the KeyName values are both specified, the -// following processing occurs: -// (1) If the KeyName can be found in the CSP, that key is used. -// (2) If the KeyName does not exist and the KeyFile does exist, the key -// in the KeyFile is installed into the CSP and used. -// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. -// When specifying the KeyFile, the location of the KeyFile should be -// relative to the project output directory which is -// %Project Directory%\obj\. For example, if your KeyFile is -// located in the project directory, you would specify the AssemblyKeyFile -// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] -// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework -// documentation for more information on this. -// -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] -[assembly: AssemblyKeyName("")] diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs deleted file mode 100644 index b110dae..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs +++ /dev/null @@ -1,202 +0,0 @@ -// -// Copyright Henrik Ravn 2004 -// -// Use, modification and distribution are subject to the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -using System; -using System.Runtime.InteropServices; -using System.Text; - - -namespace DotZLib -{ - #region ChecksumGeneratorBase - /// - /// Implements the common functionality needed for all s - /// - /// - public abstract class ChecksumGeneratorBase : ChecksumGenerator - { - /// - /// The value of the current checksum - /// - protected uint _current; - - /// - /// Initializes a new instance of the checksum generator base - the current checksum is - /// set to zero - /// - public ChecksumGeneratorBase() - { - _current = 0; - } - - /// - /// Initializes a new instance of the checksum generator basewith a specified value - /// - /// The value to set the current checksum to - public ChecksumGeneratorBase(uint initialValue) - { - _current = initialValue; - } - - /// - /// Resets the current checksum to zero - /// - public void Reset() { _current = 0; } - - /// - /// Gets the current checksum value - /// - public uint Value { get { return _current; } } - - /// - /// Updates the current checksum with part of an array of bytes - /// - /// The data to update the checksum with - /// Where in data to start updating - /// The number of bytes from data to use - /// The sum of offset and count is larger than the length of data - /// data is a null reference - /// Offset or count is negative. - /// All the other Update methods are implmeneted in terms of this one. - /// This is therefore the only method a derived class has to implement - public abstract void Update(byte[] data, int offset, int count); - - /// - /// Updates the current checksum with an array of bytes. - /// - /// The data to update the checksum with - public void Update(byte[] data) - { - Update(data, 0, data.Length); - } - - /// - /// Updates the current checksum with the data from a string - /// - /// The string to update the checksum with - /// The characters in the string are converted by the UTF-8 encoding - public void Update(string data) - { - Update(Encoding.UTF8.GetBytes(data)); - } - - /// - /// Updates the current checksum with the data from a string, using a specific encoding - /// - /// The string to update the checksum with - /// The encoding to use - public void Update(string data, Encoding encoding) - { - Update(encoding.GetBytes(data)); - } - - } - #endregion - - #region CRC32 - /// - /// Implements a CRC32 checksum generator - /// - public sealed class CRC32Checksum : ChecksumGeneratorBase - { - #region DLL imports - - [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] - private static extern uint crc32(uint crc, int data, uint length); - - #endregion - - /// - /// Initializes a new instance of the CRC32 checksum generator - /// - public CRC32Checksum() : base() {} - - /// - /// Initializes a new instance of the CRC32 checksum generator with a specified value - /// - /// The value to set the current checksum to - public CRC32Checksum(uint initialValue) : base(initialValue) {} - - /// - /// Updates the current checksum with part of an array of bytes - /// - /// The data to update the checksum with - /// Where in data to start updating - /// The number of bytes from data to use - /// The sum of offset and count is larger than the length of data - /// data is a null reference - /// Offset or count is negative. - public override void Update(byte[] data, int offset, int count) - { - if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException(); - if ((offset+count) > data.Length) throw new ArgumentException(); - GCHandle hData = GCHandle.Alloc(data, GCHandleType.Pinned); - try - { - _current = crc32(_current, hData.AddrOfPinnedObject().ToInt32()+offset, (uint)count); - } - finally - { - hData.Free(); - } - } - - } - #endregion - - #region Adler - /// - /// Implements a checksum generator that computes the Adler checksum on data - /// - public sealed class AdlerChecksum : ChecksumGeneratorBase - { - #region DLL imports - - [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] - private static extern uint adler32(uint adler, int data, uint length); - - #endregion - - /// - /// Initializes a new instance of the Adler checksum generator - /// - public AdlerChecksum() : base() {} - - /// - /// Initializes a new instance of the Adler checksum generator with a specified value - /// - /// The value to set the current checksum to - public AdlerChecksum(uint initialValue) : base(initialValue) {} - - /// - /// Updates the current checksum with part of an array of bytes - /// - /// The data to update the checksum with - /// Where in data to start updating - /// The number of bytes from data to use - /// The sum of offset and count is larger than the length of data - /// data is a null reference - /// Offset or count is negative. - public override void Update(byte[] data, int offset, int count) - { - if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException(); - if ((offset+count) > data.Length) throw new ArgumentException(); - GCHandle hData = GCHandle.Alloc(data, GCHandleType.Pinned); - try - { - _current = adler32(_current, hData.AddrOfPinnedObject().ToInt32()+offset, (uint)count); - } - finally - { - hData.Free(); - } - } - - } - #endregion - -} \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib/CircularBuffer.cs b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib/CircularBuffer.cs deleted file mode 100644 index 9c8d601..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib/CircularBuffer.cs +++ /dev/null @@ -1,83 +0,0 @@ -// -// Copyright Henrik Ravn 2004 -// -// Use, modification and distribution are subject to the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -using System; -using System.Diagnostics; - -namespace DotZLib -{ - - /// - /// This class implements a circular buffer - /// - internal class CircularBuffer - { - #region Private data - private int _capacity; - private int _head; - private int _tail; - private int _size; - private byte[] _buffer; - #endregion - - public CircularBuffer(int capacity) - { - Debug.Assert( capacity > 0 ); - _buffer = new byte[capacity]; - _capacity = capacity; - _head = 0; - _tail = 0; - _size = 0; - } - - public int Size { get { return _size; } } - - public int Put(byte[] source, int offset, int count) - { - Debug.Assert( count > 0 ); - int trueCount = Math.Min(count, _capacity - Size); - for (int i = 0; i < trueCount; ++i) - _buffer[(_tail+i) % _capacity] = source[offset+i]; - _tail += trueCount; - _tail %= _capacity; - _size += trueCount; - return trueCount; - } - - public bool Put(byte b) - { - if (Size == _capacity) // no room - return false; - _buffer[_tail++] = b; - _tail %= _capacity; - ++_size; - return true; - } - - public int Get(byte[] destination, int offset, int count) - { - int trueCount = Math.Min(count,Size); - for (int i = 0; i < trueCount; ++i) - destination[offset + i] = _buffer[(_head+i) % _capacity]; - _head += trueCount; - _head %= _capacity; - _size -= trueCount; - return trueCount; - } - - public int Get() - { - if (Size == 0) - return -1; - - int result = (int)_buffer[_head++ % _capacity]; - --_size; - return result; - } - - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib/CodecBase.cs b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib/CodecBase.cs deleted file mode 100644 index b0eb78a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib/CodecBase.cs +++ /dev/null @@ -1,198 +0,0 @@ -// -// Copyright Henrik Ravn 2004 -// -// Use, modification and distribution are subject to the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -using System; -using System.Runtime.InteropServices; - -namespace DotZLib -{ - /// - /// Implements the common functionality needed for all s - /// - public abstract class CodecBase : Codec, IDisposable - { - - #region Data members - - /// - /// Instance of the internal zlib buffer structure that is - /// passed to all functions in the zlib dll - /// - internal ZStream _ztream = new ZStream(); - - /// - /// True if the object instance has been disposed, false otherwise - /// - protected bool _isDisposed = false; - - /// - /// The size of the internal buffers - /// - protected const int kBufferSize = 16384; - - private byte[] _outBuffer = new byte[kBufferSize]; - private byte[] _inBuffer = new byte[kBufferSize]; - - private GCHandle _hInput; - private GCHandle _hOutput; - - private uint _checksum = 0; - - #endregion - - /// - /// Initializes a new instance of the CodeBase class. - /// - public CodecBase() - { - try - { - _hInput = GCHandle.Alloc(_inBuffer, GCHandleType.Pinned); - _hOutput = GCHandle.Alloc(_outBuffer, GCHandleType.Pinned); - } - catch (Exception) - { - CleanUp(false); - throw; - } - } - - - #region Codec Members - - /// - /// Occurs when more processed data are available. - /// - public event DataAvailableHandler DataAvailable; - - /// - /// Fires the event - /// - protected void OnDataAvailable() - { - if (_ztream.total_out > 0) - { - if (DataAvailable != null) - DataAvailable( _outBuffer, 0, (int)_ztream.total_out); - resetOutput(); - } - } - - /// - /// Adds more data to the codec to be processed. - /// - /// Byte array containing the data to be added to the codec - /// Adding data may, or may not, raise the DataAvailable event - public void Add(byte[] data) - { - Add(data,0,data.Length); - } - - /// - /// Adds more data to the codec to be processed. - /// - /// Byte array containing the data to be added to the codec - /// The index of the first byte to add from data - /// The number of bytes to add - /// Adding data may, or may not, raise the DataAvailable event - /// This must be implemented by a derived class - public abstract void Add(byte[] data, int offset, int count); - - /// - /// Finishes up any pending data that needs to be processed and handled. - /// - /// This must be implemented by a derived class - public abstract void Finish(); - - /// - /// Gets the checksum of the data that has been added so far - /// - public uint Checksum { get { return _checksum; } } - - #endregion - - #region Destructor & IDisposable stuff - - /// - /// Destroys this instance - /// - ~CodecBase() - { - CleanUp(false); - } - - /// - /// Releases any unmanaged resources and calls the method of the derived class - /// - public void Dispose() - { - CleanUp(true); - } - - /// - /// Performs any codec specific cleanup - /// - /// This must be implemented by a derived class - protected abstract void CleanUp(); - - // performs the release of the handles and calls the dereived CleanUp() - private void CleanUp(bool isDisposing) - { - if (!_isDisposed) - { - CleanUp(); - if (_hInput.IsAllocated) - _hInput.Free(); - if (_hOutput.IsAllocated) - _hOutput.Free(); - - _isDisposed = true; - } - } - - - #endregion - - #region Helper methods - - /// - /// Copies a number of bytes to the internal codec buffer - ready for proccesing - /// - /// The byte array that contains the data to copy - /// The index of the first byte to copy - /// The number of bytes to copy from data - protected void copyInput(byte[] data, int startIndex, int count) - { - Array.Copy(data, startIndex, _inBuffer,0, count); - _ztream.next_in = _hInput.AddrOfPinnedObject(); - _ztream.total_in = 0; - _ztream.avail_in = (uint)count; - - } - - /// - /// Resets the internal output buffers to a known state - ready for processing - /// - protected void resetOutput() - { - _ztream.total_out = 0; - _ztream.avail_out = kBufferSize; - _ztream.next_out = _hOutput.AddrOfPinnedObject(); - } - - /// - /// Updates the running checksum property - /// - /// The new checksum value - protected void setChecksum(uint newSum) - { - _checksum = newSum; - } - #endregion - - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib/Deflater.cs b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib/Deflater.cs deleted file mode 100644 index 9039f41..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib/Deflater.cs +++ /dev/null @@ -1,106 +0,0 @@ -// -// Copyright Henrik Ravn 2004 -// -// Use, modification and distribution are subject to the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -using System; -using System.Diagnostics; -using System.Runtime.InteropServices; - -namespace DotZLib -{ - - /// - /// Implements a data compressor, using the deflate algorithm in the ZLib dll - /// - public sealed class Deflater : CodecBase - { - #region Dll imports - [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl, CharSet=CharSet.Ansi)] - private static extern int deflateInit_(ref ZStream sz, int level, string vs, int size); - - [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] - private static extern int deflate(ref ZStream sz, int flush); - - [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] - private static extern int deflateReset(ref ZStream sz); - - [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] - private static extern int deflateEnd(ref ZStream sz); - #endregion - - /// - /// Constructs an new instance of the Deflater - /// - /// The compression level to use for this Deflater - public Deflater(CompressLevel level) : base() - { - int retval = deflateInit_(ref _ztream, (int)level, Info.Version, Marshal.SizeOf(_ztream)); - if (retval != 0) - throw new ZLibException(retval, "Could not initialize deflater"); - - resetOutput(); - } - - /// - /// Adds more data to the codec to be processed. - /// - /// Byte array containing the data to be added to the codec - /// The index of the first byte to add from data - /// The number of bytes to add - /// Adding data may, or may not, raise the DataAvailable event - public override void Add(byte[] data, int offset, int count) - { - if (data == null) throw new ArgumentNullException(); - if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException(); - if ((offset+count) > data.Length) throw new ArgumentException(); - - int total = count; - int inputIndex = offset; - int err = 0; - - while (err >= 0 && inputIndex < total) - { - copyInput(data, inputIndex, Math.Min(total - inputIndex, kBufferSize)); - while (err >= 0 && _ztream.avail_in > 0) - { - err = deflate(ref _ztream, (int)FlushTypes.None); - if (err == 0) - while (_ztream.avail_out == 0) - { - OnDataAvailable(); - err = deflate(ref _ztream, (int)FlushTypes.None); - } - inputIndex += (int)_ztream.total_in; - } - } - setChecksum( _ztream.adler ); - } - - - /// - /// Finishes up any pending data that needs to be processed and handled. - /// - public override void Finish() - { - int err; - do - { - err = deflate(ref _ztream, (int)FlushTypes.Finish); - OnDataAvailable(); - } - while (err == 0); - setChecksum( _ztream.adler ); - deflateReset(ref _ztream); - resetOutput(); - } - - /// - /// Closes the internal zlib deflate stream - /// - protected override void CleanUp() { deflateEnd(ref _ztream); } - - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib/DotZLib.cs b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib/DotZLib.cs deleted file mode 100644 index 90c7c3b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib/DotZLib.cs +++ /dev/null @@ -1,288 +0,0 @@ -// -// Copyright Henrik Ravn 2004 -// -// Use, modification and distribution are subject to the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -using System; -using System.IO; -using System.Runtime.InteropServices; -using System.Text; - - -namespace DotZLib -{ - - #region Internal types - - /// - /// Defines constants for the various flush types used with zlib - /// - internal enum FlushTypes - { - None, Partial, Sync, Full, Finish, Block - } - - #region ZStream structure - // internal mapping of the zlib zstream structure for marshalling - [StructLayoutAttribute(LayoutKind.Sequential, Pack=4, Size=0, CharSet=CharSet.Ansi)] - internal struct ZStream - { - public IntPtr next_in; - public uint avail_in; - public uint total_in; - - public IntPtr next_out; - public uint avail_out; - public uint total_out; - - [MarshalAs(UnmanagedType.LPStr)] - string msg; - uint state; - - uint zalloc; - uint zfree; - uint opaque; - - int data_type; - public uint adler; - uint reserved; - } - - #endregion - - #endregion - - #region Public enums - /// - /// Defines constants for the available compression levels in zlib - /// - public enum CompressLevel : int - { - /// - /// The default compression level with a reasonable compromise between compression and speed - /// - Default = -1, - /// - /// No compression at all. The data are passed straight through. - /// - None = 0, - /// - /// The maximum compression rate available. - /// - Best = 9, - /// - /// The fastest available compression level. - /// - Fastest = 1 - } - #endregion - - #region Exception classes - /// - /// The exception that is thrown when an error occurs on the zlib dll - /// - public class ZLibException : ApplicationException - { - /// - /// Initializes a new instance of the class with a specified - /// error message and error code - /// - /// The zlib error code that caused the exception - /// A message that (hopefully) describes the error - public ZLibException(int errorCode, string msg) : base(String.Format("ZLib error {0} {1}", errorCode, msg)) - { - } - - /// - /// Initializes a new instance of the class with a specified - /// error code - /// - /// The zlib error code that caused the exception - public ZLibException(int errorCode) : base(String.Format("ZLib error {0}", errorCode)) - { - } - } - #endregion - - #region Interfaces - - /// - /// Declares methods and properties that enables a running checksum to be calculated - /// - public interface ChecksumGenerator - { - /// - /// Gets the current value of the checksum - /// - uint Value { get; } - - /// - /// Clears the current checksum to 0 - /// - void Reset(); - - /// - /// Updates the current checksum with an array of bytes - /// - /// The data to update the checksum with - void Update(byte[] data); - - /// - /// Updates the current checksum with part of an array of bytes - /// - /// The data to update the checksum with - /// Where in data to start updating - /// The number of bytes from data to use - /// The sum of offset and count is larger than the length of data - /// data is a null reference - /// Offset or count is negative. - void Update(byte[] data, int offset, int count); - - /// - /// Updates the current checksum with the data from a string - /// - /// The string to update the checksum with - /// The characters in the string are converted by the UTF-8 encoding - void Update(string data); - - /// - /// Updates the current checksum with the data from a string, using a specific encoding - /// - /// The string to update the checksum with - /// The encoding to use - void Update(string data, Encoding encoding); - } - - - /// - /// Represents the method that will be called from a codec when new data - /// are available. - /// - /// The byte array containing the processed data - /// The index of the first processed byte in data - /// The number of processed bytes available - /// On return from this method, the data may be overwritten, so grab it while you can. - /// You cannot assume that startIndex will be zero. - /// - public delegate void DataAvailableHandler(byte[] data, int startIndex, int count); - - /// - /// Declares methods and events for implementing compressors/decompressors - /// - public interface Codec - { - /// - /// Occurs when more processed data are available. - /// - event DataAvailableHandler DataAvailable; - - /// - /// Adds more data to the codec to be processed. - /// - /// Byte array containing the data to be added to the codec - /// Adding data may, or may not, raise the DataAvailable event - void Add(byte[] data); - - /// - /// Adds more data to the codec to be processed. - /// - /// Byte array containing the data to be added to the codec - /// The index of the first byte to add from data - /// The number of bytes to add - /// Adding data may, or may not, raise the DataAvailable event - void Add(byte[] data, int offset, int count); - - /// - /// Finishes up any pending data that needs to be processed and handled. - /// - void Finish(); - - /// - /// Gets the checksum of the data that has been added so far - /// - uint Checksum { get; } - - - } - - #endregion - - #region Classes - /// - /// Encapsulates general information about the ZLib library - /// - public class Info - { - #region DLL imports - [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] - private static extern uint zlibCompileFlags(); - - [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] - private static extern string zlibVersion(); - #endregion - - #region Private stuff - private uint _flags; - - // helper function that unpacks a bitsize mask - private static int bitSize(uint bits) - { - switch (bits) - { - case 0: return 16; - case 1: return 32; - case 2: return 64; - } - return -1; - } - #endregion - - /// - /// Constructs an instance of the Info class. - /// - public Info() - { - _flags = zlibCompileFlags(); - } - - /// - /// True if the library is compiled with debug info - /// - public bool HasDebugInfo { get { return 0 != (_flags & 0x100); } } - - /// - /// True if the library is compiled with assembly optimizations - /// - public bool UsesAssemblyCode { get { return 0 != (_flags & 0x200); } } - - /// - /// Gets the size of the unsigned int that was compiled into Zlib - /// - public int SizeOfUInt { get { return bitSize(_flags & 3); } } - - /// - /// Gets the size of the unsigned long that was compiled into Zlib - /// - public int SizeOfULong { get { return bitSize((_flags >> 2) & 3); } } - - /// - /// Gets the size of the pointers that were compiled into Zlib - /// - public int SizeOfPointer { get { return bitSize((_flags >> 4) & 3); } } - - /// - /// Gets the size of the z_off_t type that was compiled into Zlib - /// - public int SizeOfOffset { get { return bitSize((_flags >> 6) & 3); } } - - /// - /// Gets the version of ZLib as a string, e.g. "1.2.1" - /// - public static string Version { get { return zlibVersion(); } } - } - - #endregion - -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib/DotZLib.csproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib/DotZLib.csproj deleted file mode 100644 index dea7fb1..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib/DotZLib.csproj +++ /dev/null @@ -1,141 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib/GZipStream.cs b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib/GZipStream.cs deleted file mode 100644 index f0eada1..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib/GZipStream.cs +++ /dev/null @@ -1,301 +0,0 @@ -// -// Copyright Henrik Ravn 2004 -// -// Use, modification and distribution are subject to the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -using System; -using System.IO; -using System.Runtime.InteropServices; - -namespace DotZLib -{ - /// - /// Implements a compressed , in GZip (.gz) format. - /// - public class GZipStream : Stream, IDisposable - { - #region Dll Imports - [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl, CharSet=CharSet.Ansi)] - private static extern IntPtr gzopen(string name, string mode); - - [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] - private static extern int gzclose(IntPtr gzFile); - - [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] - private static extern int gzwrite(IntPtr gzFile, int data, int length); - - [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] - private static extern int gzread(IntPtr gzFile, int data, int length); - - [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] - private static extern int gzgetc(IntPtr gzFile); - - [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] - private static extern int gzputc(IntPtr gzFile, int c); - - #endregion - - #region Private data - private IntPtr _gzFile; - private bool _isDisposed = false; - private bool _isWriting; - #endregion - - #region Constructors - /// - /// Creates a new file as a writeable GZipStream - /// - /// The name of the compressed file to create - /// The compression level to use when adding data - /// If an error occurred in the internal zlib function - public GZipStream(string fileName, CompressLevel level) - { - _isWriting = true; - _gzFile = gzopen(fileName, String.Format("wb{0}", (int)level)); - if (_gzFile == IntPtr.Zero) - throw new ZLibException(-1, "Could not open " + fileName); - } - - /// - /// Opens an existing file as a readable GZipStream - /// - /// The name of the file to open - /// If an error occurred in the internal zlib function - public GZipStream(string fileName) - { - _isWriting = false; - _gzFile = gzopen(fileName, "rb"); - if (_gzFile == IntPtr.Zero) - throw new ZLibException(-1, "Could not open " + fileName); - - } - #endregion - - #region Access properties - /// - /// Returns true of this stream can be read from, false otherwise - /// - public override bool CanRead - { - get - { - return !_isWriting; - } - } - - - /// - /// Returns false. - /// - public override bool CanSeek - { - get - { - return false; - } - } - - /// - /// Returns true if this tsream is writeable, false otherwise - /// - public override bool CanWrite - { - get - { - return _isWriting; - } - } - #endregion - - #region Destructor & IDispose stuff - - /// - /// Destroys this instance - /// - ~GZipStream() - { - cleanUp(false); - } - - /// - /// Closes the external file handle - /// - public void Dispose() - { - cleanUp(true); - } - - // Does the actual closing of the file handle. - private void cleanUp(bool isDisposing) - { - if (!_isDisposed) - { - gzclose(_gzFile); - _isDisposed = true; - } - } - #endregion - - #region Basic reading and writing - /// - /// Attempts to read a number of bytes from the stream. - /// - /// The destination data buffer - /// The index of the first destination byte in buffer - /// The number of bytes requested - /// The number of bytes read - /// If buffer is null - /// If count or offset are negative - /// If offset + count is > buffer.Length - /// If this stream is not readable. - /// If this stream has been disposed. - public override int Read(byte[] buffer, int offset, int count) - { - if (!CanRead) throw new NotSupportedException(); - if (buffer == null) throw new ArgumentNullException(); - if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException(); - if ((offset+count) > buffer.Length) throw new ArgumentException(); - if (_isDisposed) throw new ObjectDisposedException("GZipStream"); - - GCHandle h = GCHandle.Alloc(buffer, GCHandleType.Pinned); - int result; - try - { - result = gzread(_gzFile, h.AddrOfPinnedObject().ToInt32() + offset, count); - if (result < 0) - throw new IOException(); - } - finally - { - h.Free(); - } - return result; - } - - /// - /// Attempts to read a single byte from the stream. - /// - /// The byte that was read, or -1 in case of error or End-Of-File - public override int ReadByte() - { - if (!CanRead) throw new NotSupportedException(); - if (_isDisposed) throw new ObjectDisposedException("GZipStream"); - return gzgetc(_gzFile); - } - - /// - /// Writes a number of bytes to the stream - /// - /// - /// - /// - /// If buffer is null - /// If count or offset are negative - /// If offset + count is > buffer.Length - /// If this stream is not writeable. - /// If this stream has been disposed. - public override void Write(byte[] buffer, int offset, int count) - { - if (!CanWrite) throw new NotSupportedException(); - if (buffer == null) throw new ArgumentNullException(); - if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException(); - if ((offset+count) > buffer.Length) throw new ArgumentException(); - if (_isDisposed) throw new ObjectDisposedException("GZipStream"); - - GCHandle h = GCHandle.Alloc(buffer, GCHandleType.Pinned); - try - { - int result = gzwrite(_gzFile, h.AddrOfPinnedObject().ToInt32() + offset, count); - if (result < 0) - throw new IOException(); - } - finally - { - h.Free(); - } - } - - /// - /// Writes a single byte to the stream - /// - /// The byte to add to the stream. - /// If this stream is not writeable. - /// If this stream has been disposed. - public override void WriteByte(byte value) - { - if (!CanWrite) throw new NotSupportedException(); - if (_isDisposed) throw new ObjectDisposedException("GZipStream"); - - int result = gzputc(_gzFile, (int)value); - if (result < 0) - throw new IOException(); - } - #endregion - - #region Position & length stuff - /// - /// Not supported. - /// - /// - /// Always thrown - public override void SetLength(long value) - { - throw new NotSupportedException(); - } - - /// - /// Not suppported. - /// - /// - /// - /// - /// Always thrown - public override long Seek(long offset, SeekOrigin origin) - { - throw new NotSupportedException(); - } - - /// - /// Flushes the GZipStream. - /// - /// In this implementation, this method does nothing. This is because excessive - /// flushing may degrade the achievable compression rates. - public override void Flush() - { - // left empty on purpose - } - - /// - /// Gets/sets the current position in the GZipStream. Not suppported. - /// - /// In this implementation this property is not supported - /// Always thrown - public override long Position - { - get - { - throw new NotSupportedException(); - } - set - { - throw new NotSupportedException(); - } - } - - /// - /// Gets the size of the stream. Not suppported. - /// - /// In this implementation this property is not supported - /// Always thrown - public override long Length - { - get - { - throw new NotSupportedException(); - } - } - #endregion - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib/Inflater.cs b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib/Inflater.cs deleted file mode 100644 index d295f26..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib/Inflater.cs +++ /dev/null @@ -1,105 +0,0 @@ -// -// Copyright Henrik Ravn 2004 -// -// Use, modification and distribution are subject to the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -using System; -using System.Diagnostics; -using System.Runtime.InteropServices; - -namespace DotZLib -{ - - /// - /// Implements a data decompressor, using the inflate algorithm in the ZLib dll - /// - public class Inflater : CodecBase - { - #region Dll imports - [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl, CharSet=CharSet.Ansi)] - private static extern int inflateInit_(ref ZStream sz, string vs, int size); - - [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] - private static extern int inflate(ref ZStream sz, int flush); - - [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] - private static extern int inflateReset(ref ZStream sz); - - [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] - private static extern int inflateEnd(ref ZStream sz); - #endregion - - /// - /// Constructs an new instance of the Inflater - /// - public Inflater() : base() - { - int retval = inflateInit_(ref _ztream, Info.Version, Marshal.SizeOf(_ztream)); - if (retval != 0) - throw new ZLibException(retval, "Could not initialize inflater"); - - resetOutput(); - } - - - /// - /// Adds more data to the codec to be processed. - /// - /// Byte array containing the data to be added to the codec - /// The index of the first byte to add from data - /// The number of bytes to add - /// Adding data may, or may not, raise the DataAvailable event - public override void Add(byte[] data, int offset, int count) - { - if (data == null) throw new ArgumentNullException(); - if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException(); - if ((offset+count) > data.Length) throw new ArgumentException(); - - int total = count; - int inputIndex = offset; - int err = 0; - - while (err >= 0 && inputIndex < total) - { - copyInput(data, inputIndex, Math.Min(total - inputIndex, kBufferSize)); - err = inflate(ref _ztream, (int)FlushTypes.None); - if (err == 0) - while (_ztream.avail_out == 0) - { - OnDataAvailable(); - err = inflate(ref _ztream, (int)FlushTypes.None); - } - - inputIndex += (int)_ztream.total_in; - } - setChecksum( _ztream.adler ); - } - - - /// - /// Finishes up any pending data that needs to be processed and handled. - /// - public override void Finish() - { - int err; - do - { - err = inflate(ref _ztream, (int)FlushTypes.Finish); - OnDataAvailable(); - } - while (err == 0); - setChecksum( _ztream.adler ); - inflateReset(ref _ztream); - resetOutput(); - } - - /// - /// Closes the internal zlib inflate stream - /// - protected override void CleanUp() { inflateEnd(ref _ztream); } - - - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib/UnitTests.cs b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib/UnitTests.cs deleted file mode 100644 index 5fd0ae4..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/DotZLib/UnitTests.cs +++ /dev/null @@ -1,274 +0,0 @@ -// -// © Copyright Henrik Ravn 2004 -// -// Use, modification and distribution are subject to the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -using System; -using System.Collections; -using System.IO; - -// uncomment the define below to include unit tests -//#define nunit -#if nunit -using NUnit.Framework; - -// Unit tests for the DotZLib class library -// ---------------------------------------- -// -// Use this with NUnit 2 from http://www.nunit.org -// - -namespace DotZLibTests -{ - using DotZLib; - - // helper methods - internal class Utils - { - public static bool byteArrEqual( byte[] lhs, byte[] rhs ) - { - if (lhs.Length != rhs.Length) - return false; - for (int i = lhs.Length-1; i >= 0; --i) - if (lhs[i] != rhs[i]) - return false; - return true; - } - - } - - - [TestFixture] - public class CircBufferTests - { - #region Circular buffer tests - [Test] - public void SinglePutGet() - { - CircularBuffer buf = new CircularBuffer(10); - Assert.AreEqual( 0, buf.Size ); - Assert.AreEqual( -1, buf.Get() ); - - Assert.IsTrue(buf.Put( 1 )); - Assert.AreEqual( 1, buf.Size ); - Assert.AreEqual( 1, buf.Get() ); - Assert.AreEqual( 0, buf.Size ); - Assert.AreEqual( -1, buf.Get() ); - } - - [Test] - public void BlockPutGet() - { - CircularBuffer buf = new CircularBuffer(10); - byte[] arr = {1,2,3,4,5,6,7,8,9,10}; - Assert.AreEqual( 10, buf.Put(arr,0,10) ); - Assert.AreEqual( 10, buf.Size ); - Assert.IsFalse( buf.Put(11) ); - Assert.AreEqual( 1, buf.Get() ); - Assert.IsTrue( buf.Put(11) ); - - byte[] arr2 = (byte[])arr.Clone(); - Assert.AreEqual( 9, buf.Get(arr2,1,9) ); - Assert.IsTrue( Utils.byteArrEqual(arr,arr2) ); - } - - #endregion - } - - [TestFixture] - public class ChecksumTests - { - #region CRC32 Tests - [Test] - public void CRC32_Null() - { - CRC32Checksum crc32 = new CRC32Checksum(); - Assert.AreEqual( 0, crc32.Value ); - - crc32 = new CRC32Checksum(1); - Assert.AreEqual( 1, crc32.Value ); - - crc32 = new CRC32Checksum(556); - Assert.AreEqual( 556, crc32.Value ); - } - - [Test] - public void CRC32_Data() - { - CRC32Checksum crc32 = new CRC32Checksum(); - byte[] data = { 1,2,3,4,5,6,7 }; - crc32.Update(data); - Assert.AreEqual( 0x70e46888, crc32.Value ); - - crc32 = new CRC32Checksum(); - crc32.Update("penguin"); - Assert.AreEqual( 0x0e5c1a120, crc32.Value ); - - crc32 = new CRC32Checksum(1); - crc32.Update("penguin"); - Assert.AreEqual(0x43b6aa94, crc32.Value); - - } - #endregion - - #region Adler tests - - [Test] - public void Adler_Null() - { - AdlerChecksum adler = new AdlerChecksum(); - Assert.AreEqual(0, adler.Value); - - adler = new AdlerChecksum(1); - Assert.AreEqual( 1, adler.Value ); - - adler = new AdlerChecksum(556); - Assert.AreEqual( 556, adler.Value ); - } - - [Test] - public void Adler_Data() - { - AdlerChecksum adler = new AdlerChecksum(1); - byte[] data = { 1,2,3,4,5,6,7 }; - adler.Update(data); - Assert.AreEqual( 0x5b001d, adler.Value ); - - adler = new AdlerChecksum(); - adler.Update("penguin"); - Assert.AreEqual(0x0bcf02f6, adler.Value ); - - adler = new AdlerChecksum(1); - adler.Update("penguin"); - Assert.AreEqual(0x0bd602f7, adler.Value); - - } - #endregion - } - - [TestFixture] - public class InfoTests - { - #region Info tests - [Test] - public void Info_Version() - { - Info info = new Info(); - Assert.AreEqual("1.2.12", Info.Version); - Assert.AreEqual(32, info.SizeOfUInt); - Assert.AreEqual(32, info.SizeOfULong); - Assert.AreEqual(32, info.SizeOfPointer); - Assert.AreEqual(32, info.SizeOfOffset); - } - #endregion - } - - [TestFixture] - public class DeflateInflateTests - { - #region Deflate tests - [Test] - public void Deflate_Init() - { - using (Deflater def = new Deflater(CompressLevel.Default)) - { - } - } - - private ArrayList compressedData = new ArrayList(); - private uint adler1; - - private ArrayList uncompressedData = new ArrayList(); - private uint adler2; - - public void CDataAvail(byte[] data, int startIndex, int count) - { - for (int i = 0; i < count; ++i) - compressedData.Add(data[i+startIndex]); - } - - [Test] - public void Deflate_Compress() - { - compressedData.Clear(); - - byte[] testData = new byte[35000]; - for (int i = 0; i < testData.Length; ++i) - testData[i] = 5; - - using (Deflater def = new Deflater((CompressLevel)5)) - { - def.DataAvailable += new DataAvailableHandler(CDataAvail); - def.Add(testData); - def.Finish(); - adler1 = def.Checksum; - } - } - #endregion - - #region Inflate tests - [Test] - public void Inflate_Init() - { - using (Inflater inf = new Inflater()) - { - } - } - - private void DDataAvail(byte[] data, int startIndex, int count) - { - for (int i = 0; i < count; ++i) - uncompressedData.Add(data[i+startIndex]); - } - - [Test] - public void Inflate_Expand() - { - uncompressedData.Clear(); - - using (Inflater inf = new Inflater()) - { - inf.DataAvailable += new DataAvailableHandler(DDataAvail); - inf.Add((byte[])compressedData.ToArray(typeof(byte))); - inf.Finish(); - adler2 = inf.Checksum; - } - Assert.AreEqual( adler1, adler2 ); - } - #endregion - } - - [TestFixture] - public class GZipStreamTests - { - #region GZipStream test - [Test] - public void GZipStream_WriteRead() - { - using (GZipStream gzOut = new GZipStream("gzstream.gz", CompressLevel.Best)) - { - BinaryWriter writer = new BinaryWriter(gzOut); - writer.Write("hi there"); - writer.Write(Math.PI); - writer.Write(42); - } - - using (GZipStream gzIn = new GZipStream("gzstream.gz")) - { - BinaryReader reader = new BinaryReader(gzIn); - string s = reader.ReadString(); - Assert.AreEqual("hi there",s); - double d = reader.ReadDouble(); - Assert.AreEqual(Math.PI, d); - int i = reader.ReadInt32(); - Assert.AreEqual(42,i); - } - - } - #endregion - } -} - -#endif diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/LICENSE_1_0.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/LICENSE_1_0.txt deleted file mode 100644 index 127a5bc..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/LICENSE_1_0.txt +++ /dev/null @@ -1,23 +0,0 @@ -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/readme.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/readme.txt deleted file mode 100644 index 4d8c2dd..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/dotzlib/readme.txt +++ /dev/null @@ -1,58 +0,0 @@ -This directory contains a .Net wrapper class library for the ZLib1.dll - -The wrapper includes support for inflating/deflating memory buffers, -.Net streaming wrappers for the gz streams part of zlib, and wrappers -for the checksum parts of zlib. See DotZLib/UnitTests.cs for examples. - -Directory structure: --------------------- - -LICENSE_1_0.txt - License file. -readme.txt - This file. -DotZLib.chm - Class library documentation -DotZLib.build - NAnt build file -DotZLib.sln - Microsoft Visual Studio 2003 solution file - -DotZLib\*.cs - Source files for the class library - -Unit tests: ------------ -The file DotZLib/UnitTests.cs contains unit tests for use with NUnit 2.1 or higher. -To include unit tests in the build, define nunit before building. - - -Build instructions: -------------------- - -1. Using Visual Studio.Net 2003: - Open DotZLib.sln in VS.Net and build from there. Output file (DotZLib.dll) - will be found ./DotZLib/bin/release or ./DotZLib/bin/debug, depending on - you are building the release or debug version of the library. Check - DotZLib/UnitTests.cs for instructions on how to include unit tests in the - build. - -2. Using NAnt: - Open a command prompt with access to the build environment and run nant - in the same directory as the DotZLib.build file. - You can define 2 properties on the nant command-line to control the build: - debug={true|false} to toggle between release/debug builds (default=true). - nunit={true|false} to include or esclude unit tests (default=true). - Also the target clean will remove binaries. - Output file (DotZLib.dll) will be found in either ./DotZLib/bin/release - or ./DotZLib/bin/debug, depending on whether you are building the release - or debug version of the library. - - Examples: - nant -D:debug=false -D:nunit=false - will build a release mode version of the library without unit tests. - nant - will build a debug version of the library with unit tests - nant clean - will remove all previously built files. - - ---------------------------------- -Copyright (c) Henrik Ravn 2004 - -Use, modification and distribution are subject to the Boost Software License, Version 1.0. -(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/gcc_gvmat64/gvmat64.S b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/gcc_gvmat64/gvmat64.S deleted file mode 100644 index 23309fa..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/gcc_gvmat64/gvmat64.S +++ /dev/null @@ -1,574 +0,0 @@ -/* -;uInt longest_match_x64( -; deflate_state *s, -; IPos cur_match); // current match - -; gvmat64.S -- Asm portion of the optimized longest_match for 32 bits x86_64 -; (AMD64 on Athlon 64, Opteron, Phenom -; and Intel EM64T on Pentium 4 with EM64T, Pentium D, Core 2 Duo, Core I5/I7) -; this file is translation from gvmat64.asm to GCC 4.x (for Linux, Mac XCode) -; Copyright (C) 1995-2010 Jean-loup Gailly, Brian Raiter and Gilles Vollant. -; -; File written by Gilles Vollant, by converting to assembly the longest_match -; from Jean-loup Gailly in deflate.c of zLib and infoZip zip. -; and by taking inspiration on asm686 with masm, optimised assembly code -; from Brian Raiter, written 1998 -; -; This software is provided 'as-is', without any express or implied -; warranty. In no event will the authors be held liable for any damages -; arising from the use of this software. -; -; Permission is granted to anyone to use this software for any purpose, -; including commercial applications, and to alter it and redistribute it -; freely, subject to the following restrictions: -; -; 1. The origin of this software must not be misrepresented; you must not -; claim that you wrote the original software. If you use this software -; in a product, an acknowledgment in the product documentation would be -; appreciated but is not required. -; 2. Altered source versions must be plainly marked as such, and must not be -; misrepresented as being the original software -; 3. This notice may not be removed or altered from any source distribution. -; -; http://www.zlib.net -; http://www.winimage.com/zLibDll -; http://www.muppetlabs.com/~breadbox/software/assembly.html -; -; to compile this file for zLib, I use option: -; gcc -c -arch x86_64 gvmat64.S - - -;uInt longest_match(s, cur_match) -; deflate_state *s; -; IPos cur_match; // current match / -; -; with XCode for Mac, I had strange error with some jump on intel syntax -; this is why BEFORE_JMP and AFTER_JMP are used - */ - - -#define BEFORE_JMP .att_syntax -#define AFTER_JMP .intel_syntax noprefix - -#ifndef NO_UNDERLINE -# define match_init _match_init -# define longest_match _longest_match -#endif - -.intel_syntax noprefix - -.globl match_init, longest_match -.text -longest_match: - - - -#define LocalVarsSize 96 -/* -; register used : rax,rbx,rcx,rdx,rsi,rdi,r8,r9,r10,r11,r12 -; free register : r14,r15 -; register can be saved : rsp -*/ - -#define chainlenwmask (rsp + 8 - LocalVarsSize) -#define nicematch (rsp + 16 - LocalVarsSize) - -#define save_rdi (rsp + 24 - LocalVarsSize) -#define save_rsi (rsp + 32 - LocalVarsSize) -#define save_rbx (rsp + 40 - LocalVarsSize) -#define save_rbp (rsp + 48 - LocalVarsSize) -#define save_r12 (rsp + 56 - LocalVarsSize) -#define save_r13 (rsp + 64 - LocalVarsSize) -#define save_r14 (rsp + 72 - LocalVarsSize) -#define save_r15 (rsp + 80 - LocalVarsSize) - - -/* -; all the +4 offsets are due to the addition of pending_buf_size (in zlib -; in the deflate_state structure since the asm code was first written -; (if you compile with zlib 1.0.4 or older, remove the +4). -; Note : these value are good with a 8 bytes boundary pack structure -*/ - -#define MAX_MATCH 258 -#define MIN_MATCH 3 -#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) - -/* -;;; Offsets for fields in the deflate_state structure. These numbers -;;; are calculated from the definition of deflate_state, with the -;;; assumption that the compiler will dword-align the fields. (Thus, -;;; changing the definition of deflate_state could easily cause this -;;; program to crash horribly, without so much as a warning at -;;; compile time. Sigh.) - -; all the +zlib1222add offsets are due to the addition of fields -; in zlib in the deflate_state structure since the asm code was first written -; (if you compile with zlib 1.0.4 or older, use "zlib1222add equ (-4)"). -; (if you compile with zlib between 1.0.5 and 1.2.2.1, use "zlib1222add equ 0"). -; if you compile with zlib 1.2.2.2 or later , use "zlib1222add equ 8"). -*/ - - - -/* you can check the structure offset by running - -#include -#include -#include "deflate.h" - -void print_depl() -{ -deflate_state ds; -deflate_state *s=&ds; -printf("size pointer=%u\n",(int)sizeof(void*)); - -printf("#define dsWSize %u\n",(int)(((char*)&(s->w_size))-((char*)s))); -printf("#define dsWMask %u\n",(int)(((char*)&(s->w_mask))-((char*)s))); -printf("#define dsWindow %u\n",(int)(((char*)&(s->window))-((char*)s))); -printf("#define dsPrev %u\n",(int)(((char*)&(s->prev))-((char*)s))); -printf("#define dsMatchLen %u\n",(int)(((char*)&(s->match_length))-((char*)s))); -printf("#define dsPrevMatch %u\n",(int)(((char*)&(s->prev_match))-((char*)s))); -printf("#define dsStrStart %u\n",(int)(((char*)&(s->strstart))-((char*)s))); -printf("#define dsMatchStart %u\n",(int)(((char*)&(s->match_start))-((char*)s))); -printf("#define dsLookahead %u\n",(int)(((char*)&(s->lookahead))-((char*)s))); -printf("#define dsPrevLen %u\n",(int)(((char*)&(s->prev_length))-((char*)s))); -printf("#define dsMaxChainLen %u\n",(int)(((char*)&(s->max_chain_length))-((char*)s))); -printf("#define dsGoodMatch %u\n",(int)(((char*)&(s->good_match))-((char*)s))); -printf("#define dsNiceMatch %u\n",(int)(((char*)&(s->nice_match))-((char*)s))); -} -*/ - -#define dsWSize 68 -#define dsWMask 76 -#define dsWindow 80 -#define dsPrev 96 -#define dsMatchLen 144 -#define dsPrevMatch 148 -#define dsStrStart 156 -#define dsMatchStart 160 -#define dsLookahead 164 -#define dsPrevLen 168 -#define dsMaxChainLen 172 -#define dsGoodMatch 188 -#define dsNiceMatch 192 - -#define window_size [ rcx + dsWSize] -#define WMask [ rcx + dsWMask] -#define window_ad [ rcx + dsWindow] -#define prev_ad [ rcx + dsPrev] -#define strstart [ rcx + dsStrStart] -#define match_start [ rcx + dsMatchStart] -#define Lookahead [ rcx + dsLookahead] //; 0ffffffffh on infozip -#define prev_length [ rcx + dsPrevLen] -#define max_chain_length [ rcx + dsMaxChainLen] -#define good_match [ rcx + dsGoodMatch] -#define nice_match [ rcx + dsNiceMatch] - -/* -; windows: -; parameter 1 in rcx(deflate state s), param 2 in rdx (cur match) - -; see http://weblogs.asp.net/oldnewthing/archive/2004/01/14/58579.aspx and -; http://msdn.microsoft.com/library/en-us/kmarch/hh/kmarch/64bitAMD_8e951dd2-ee77-4728-8702-55ce4b5dd24a.xml.asp -; -; All registers must be preserved across the call, except for -; rax, rcx, rdx, r8, r9, r10, and r11, which are scratch. - -; -; gcc on macosx-linux: -; see http://www.x86-64.org/documentation/abi-0.99.pdf -; param 1 in rdi, param 2 in rsi -; rbx, rsp, rbp, r12 to r15 must be preserved - -;;; Save registers that the compiler may be using, and adjust esp to -;;; make room for our stack frame. - - -;;; Retrieve the function arguments. r8d will hold cur_match -;;; throughout the entire function. edx will hold the pointer to the -;;; deflate_state structure during the function's setup (before -;;; entering the main loop. - -; ms: parameter 1 in rcx (deflate_state* s), param 2 in edx -> r8 (cur match) -; mac: param 1 in rdi, param 2 rsi -; this clear high 32 bits of r8, which can be garbage in both r8 and rdx -*/ - mov [save_rbx],rbx - mov [save_rbp],rbp - - - mov rcx,rdi - - mov r8d,esi - - - mov [save_r12],r12 - mov [save_r13],r13 - mov [save_r14],r14 - mov [save_r15],r15 - - -//;;; uInt wmask = s->w_mask; -//;;; unsigned chain_length = s->max_chain_length; -//;;; if (s->prev_length >= s->good_match) { -//;;; chain_length >>= 2; -//;;; } - - - mov edi, prev_length - mov esi, good_match - mov eax, WMask - mov ebx, max_chain_length - cmp edi, esi - jl LastMatchGood - shr ebx, 2 -LastMatchGood: - -//;;; chainlen is decremented once beforehand so that the function can -//;;; use the sign flag instead of the zero flag for the exit test. -//;;; It is then shifted into the high word, to make room for the wmask -//;;; value, which it will always accompany. - - dec ebx - shl ebx, 16 - or ebx, eax - -//;;; on zlib only -//;;; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; - - - - mov eax, nice_match - mov [chainlenwmask], ebx - mov r10d, Lookahead - cmp r10d, eax - cmovnl r10d, eax - mov [nicematch],r10d - - - -//;;; register Bytef *scan = s->window + s->strstart; - mov r10, window_ad - mov ebp, strstart - lea r13, [r10 + rbp] - -//;;; Determine how many bytes the scan ptr is off from being -//;;; dword-aligned. - - mov r9,r13 - neg r13 - and r13,3 - -//;;; IPos limit = s->strstart > (IPos)MAX_DIST(s) ? -//;;; s->strstart - (IPos)MAX_DIST(s) : NIL; - - - mov eax, window_size - sub eax, MIN_LOOKAHEAD - - - xor edi,edi - sub ebp, eax - - mov r11d, prev_length - - cmovng ebp,edi - -//;;; int best_len = s->prev_length; - - -//;;; Store the sum of s->window + best_len in esi locally, and in esi. - - lea rsi,[r10+r11] - -//;;; register ush scan_start = *(ushf*)scan; -//;;; register ush scan_end = *(ushf*)(scan+best_len-1); -//;;; Posf *prev = s->prev; - - movzx r12d,word ptr [r9] - movzx ebx, word ptr [r9 + r11 - 1] - - mov rdi, prev_ad - -//;;; Jump into the main loop. - - mov edx, [chainlenwmask] - - cmp bx,word ptr [rsi + r8 - 1] - jz LookupLoopIsZero - - - -LookupLoop1: - and r8d, edx - - movzx r8d, word ptr [rdi + r8*2] - cmp r8d, ebp - jbe LeaveNow - - - - sub edx, 0x00010000 - BEFORE_JMP - js LeaveNow - AFTER_JMP - -LoopEntry1: - cmp bx,word ptr [rsi + r8 - 1] - BEFORE_JMP - jz LookupLoopIsZero - AFTER_JMP - -LookupLoop2: - and r8d, edx - - movzx r8d, word ptr [rdi + r8*2] - cmp r8d, ebp - BEFORE_JMP - jbe LeaveNow - AFTER_JMP - sub edx, 0x00010000 - BEFORE_JMP - js LeaveNow - AFTER_JMP - -LoopEntry2: - cmp bx,word ptr [rsi + r8 - 1] - BEFORE_JMP - jz LookupLoopIsZero - AFTER_JMP - -LookupLoop4: - and r8d, edx - - movzx r8d, word ptr [rdi + r8*2] - cmp r8d, ebp - BEFORE_JMP - jbe LeaveNow - AFTER_JMP - sub edx, 0x00010000 - BEFORE_JMP - js LeaveNow - AFTER_JMP - -LoopEntry4: - - cmp bx,word ptr [rsi + r8 - 1] - BEFORE_JMP - jnz LookupLoop1 - jmp LookupLoopIsZero - AFTER_JMP -/* -;;; do { -;;; match = s->window + cur_match; -;;; if (*(ushf*)(match+best_len-1) != scan_end || -;;; *(ushf*)match != scan_start) continue; -;;; [...] -;;; } while ((cur_match = prev[cur_match & wmask]) > limit -;;; && --chain_length != 0); -;;; -;;; Here is the inner loop of the function. The function will spend the -;;; majority of its time in this loop, and majority of that time will -;;; be spent in the first ten instructions. -;;; -;;; Within this loop: -;;; ebx = scanend -;;; r8d = curmatch -;;; edx = chainlenwmask - i.e., ((chainlen << 16) | wmask) -;;; esi = windowbestlen - i.e., (window + bestlen) -;;; edi = prev -;;; ebp = limit -*/ -.balign 16 -LookupLoop: - and r8d, edx - - movzx r8d, word ptr [rdi + r8*2] - cmp r8d, ebp - BEFORE_JMP - jbe LeaveNow - AFTER_JMP - sub edx, 0x00010000 - BEFORE_JMP - js LeaveNow - AFTER_JMP - -LoopEntry: - - cmp bx,word ptr [rsi + r8 - 1] - BEFORE_JMP - jnz LookupLoop1 - AFTER_JMP -LookupLoopIsZero: - cmp r12w, word ptr [r10 + r8] - BEFORE_JMP - jnz LookupLoop1 - AFTER_JMP - - -//;;; Store the current value of chainlen. - mov [chainlenwmask], edx -/* -;;; Point edi to the string under scrutiny, and esi to the string we -;;; are hoping to match it up with. In actuality, esi and edi are -;;; both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and edx is -;;; initialized to -(MAX_MATCH_8 - scanalign). -*/ - lea rsi,[r8+r10] - mov rdx, 0xfffffffffffffef8 //; -(MAX_MATCH_8) - lea rsi, [rsi + r13 + 0x0108] //;MAX_MATCH_8] - lea rdi, [r9 + r13 + 0x0108] //;MAX_MATCH_8] - - prefetcht1 [rsi+rdx] - prefetcht1 [rdi+rdx] - -/* -;;; Test the strings for equality, 8 bytes at a time. At the end, -;;; adjust rdx so that it is offset to the exact byte that mismatched. -;;; -;;; We already know at this point that the first three bytes of the -;;; strings match each other, and they can be safely passed over before -;;; starting the compare loop. So what this code does is skip over 0-3 -;;; bytes, as much as necessary in order to dword-align the edi -;;; pointer. (rsi will still be misaligned three times out of four.) -;;; -;;; It should be confessed that this loop usually does not represent -;;; much of the total running time. Replacing it with a more -;;; straightforward "rep cmpsb" would not drastically degrade -;;; performance. -*/ - -LoopCmps: - mov rax, [rsi + rdx] - xor rax, [rdi + rdx] - jnz LeaveLoopCmps - - mov rax, [rsi + rdx + 8] - xor rax, [rdi + rdx + 8] - jnz LeaveLoopCmps8 - - - mov rax, [rsi + rdx + 8+8] - xor rax, [rdi + rdx + 8+8] - jnz LeaveLoopCmps16 - - add rdx,8+8+8 - - BEFORE_JMP - jnz LoopCmps - jmp LenMaximum - AFTER_JMP - -LeaveLoopCmps16: add rdx,8 -LeaveLoopCmps8: add rdx,8 -LeaveLoopCmps: - - test eax, 0x0000FFFF - jnz LenLower - - test eax,0xffffffff - - jnz LenLower32 - - add rdx,4 - shr rax,32 - or ax,ax - BEFORE_JMP - jnz LenLower - AFTER_JMP - -LenLower32: - shr eax,16 - add rdx,2 - -LenLower: - sub al, 1 - adc rdx, 0 -//;;; Calculate the length of the match. If it is longer than MAX_MATCH, -//;;; then automatically accept it as the best possible match and leave. - - lea rax, [rdi + rdx] - sub rax, r9 - cmp eax, MAX_MATCH - BEFORE_JMP - jge LenMaximum - AFTER_JMP -/* -;;; If the length of the match is not longer than the best match we -;;; have so far, then forget it and return to the lookup loop. -;/////////////////////////////////// -*/ - cmp eax, r11d - jg LongerMatch - - lea rsi,[r10+r11] - - mov rdi, prev_ad - mov edx, [chainlenwmask] - BEFORE_JMP - jmp LookupLoop - AFTER_JMP -/* -;;; s->match_start = cur_match; -;;; best_len = len; -;;; if (len >= nice_match) break; -;;; scan_end = *(ushf*)(scan+best_len-1); -*/ -LongerMatch: - mov r11d, eax - mov match_start, r8d - cmp eax, [nicematch] - BEFORE_JMP - jge LeaveNow - AFTER_JMP - - lea rsi,[r10+rax] - - movzx ebx, word ptr [r9 + rax - 1] - mov rdi, prev_ad - mov edx, [chainlenwmask] - BEFORE_JMP - jmp LookupLoop - AFTER_JMP - -//;;; Accept the current string, with the maximum possible length. - -LenMaximum: - mov r11d,MAX_MATCH - mov match_start, r8d - -//;;; if ((uInt)best_len <= s->lookahead) return (uInt)best_len; -//;;; return s->lookahead; - -LeaveNow: - mov eax, Lookahead - cmp r11d, eax - cmovng eax, r11d - - - -//;;; Restore the stack and return from whence we came. - - -// mov rsi,[save_rsi] -// mov rdi,[save_rdi] - mov rbx,[save_rbx] - mov rbp,[save_rbp] - mov r12,[save_r12] - mov r13,[save_r13] - mov r14,[save_r14] - mov r15,[save_r15] - - - ret 0 -//; please don't remove this string ! -//; Your can freely use gvmat64 in any free or commercial app -//; but it is far better don't remove the string in the binary! - // db 0dh,0ah,"asm686 with masm, optimised assembly code from Brian Raiter, written 1998, converted to amd 64 by Gilles Vollant 2005",0dh,0ah,0 - - -match_init: - ret 0 - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/infback9/README b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/infback9/README deleted file mode 100644 index e75ed13..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/infback9/README +++ /dev/null @@ -1 +0,0 @@ -See infback9.h for what this is and how to use it. diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/infback9/infback9.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/infback9/infback9.c deleted file mode 100644 index 05fb3e3..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/infback9/infback9.c +++ /dev/null @@ -1,615 +0,0 @@ -/* infback9.c -- inflate deflate64 data using a call-back interface - * Copyright (C) 1995-2008 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "infback9.h" -#include "inftree9.h" -#include "inflate9.h" - -#define WSIZE 65536UL - -/* - strm provides memory allocation functions in zalloc and zfree, or - Z_NULL to use the library memory allocation functions. - - window is a user-supplied window and output buffer that is 64K bytes. - */ -int ZEXPORT inflateBack9Init_(strm, window, version, stream_size) -z_stream FAR *strm; -unsigned char FAR *window; -const char *version; -int stream_size; -{ - struct inflate_state FAR *state; - - if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || - stream_size != (int)(sizeof(z_stream))) - return Z_VERSION_ERROR; - if (strm == Z_NULL || window == Z_NULL) - return Z_STREAM_ERROR; - strm->msg = Z_NULL; /* in case we return an error */ - if (strm->zalloc == (alloc_func)0) { - strm->zalloc = zcalloc; - strm->opaque = (voidpf)0; - } - if (strm->zfree == (free_func)0) strm->zfree = zcfree; - state = (struct inflate_state FAR *)ZALLOC(strm, 1, - sizeof(struct inflate_state)); - if (state == Z_NULL) return Z_MEM_ERROR; - Tracev((stderr, "inflate: allocated\n")); - strm->state = (voidpf)state; - state->window = window; - return Z_OK; -} - -/* - Build and output length and distance decoding tables for fixed code - decoding. - */ -#ifdef MAKEFIXED -#include - -void makefixed9(void) -{ - unsigned sym, bits, low, size; - code *next, *lenfix, *distfix; - struct inflate_state state; - code fixed[544]; - - /* literal/length table */ - sym = 0; - while (sym < 144) state.lens[sym++] = 8; - while (sym < 256) state.lens[sym++] = 9; - while (sym < 280) state.lens[sym++] = 7; - while (sym < 288) state.lens[sym++] = 8; - next = fixed; - lenfix = next; - bits = 9; - inflate_table9(LENS, state.lens, 288, &(next), &(bits), state.work); - - /* distance table */ - sym = 0; - while (sym < 32) state.lens[sym++] = 5; - distfix = next; - bits = 5; - inflate_table9(DISTS, state.lens, 32, &(next), &(bits), state.work); - - /* write tables */ - puts(" /* inffix9.h -- table for decoding deflate64 fixed codes"); - puts(" * Generated automatically by makefixed9()."); - puts(" */"); - puts(""); - puts(" /* WARNING: this file should *not* be used by applications."); - puts(" It is part of the implementation of this library and is"); - puts(" subject to change. Applications should only use zlib.h."); - puts(" */"); - puts(""); - size = 1U << 9; - printf(" static const code lenfix[%u] = {", size); - low = 0; - for (;;) { - if ((low % 6) == 0) printf("\n "); - printf("{%u,%u,%d}", lenfix[low].op, lenfix[low].bits, - lenfix[low].val); - if (++low == size) break; - putchar(','); - } - puts("\n };"); - size = 1U << 5; - printf("\n static const code distfix[%u] = {", size); - low = 0; - for (;;) { - if ((low % 5) == 0) printf("\n "); - printf("{%u,%u,%d}", distfix[low].op, distfix[low].bits, - distfix[low].val); - if (++low == size) break; - putchar(','); - } - puts("\n };"); -} -#endif /* MAKEFIXED */ - -/* Macros for inflateBack(): */ - -/* Clear the input bit accumulator */ -#define INITBITS() \ - do { \ - hold = 0; \ - bits = 0; \ - } while (0) - -/* Assure that some input is available. If input is requested, but denied, - then return a Z_BUF_ERROR from inflateBack(). */ -#define PULL() \ - do { \ - if (have == 0) { \ - have = in(in_desc, &next); \ - if (have == 0) { \ - next = Z_NULL; \ - ret = Z_BUF_ERROR; \ - goto inf_leave; \ - } \ - } \ - } while (0) - -/* Get a byte of input into the bit accumulator, or return from inflateBack() - with an error if there is no input available. */ -#define PULLBYTE() \ - do { \ - PULL(); \ - have--; \ - hold += (unsigned long)(*next++) << bits; \ - bits += 8; \ - } while (0) - -/* Assure that there are at least n bits in the bit accumulator. If there is - not enough available input to do that, then return from inflateBack() with - an error. */ -#define NEEDBITS(n) \ - do { \ - while (bits < (unsigned)(n)) \ - PULLBYTE(); \ - } while (0) - -/* Return the low n bits of the bit accumulator (n <= 16) */ -#define BITS(n) \ - ((unsigned)hold & ((1U << (n)) - 1)) - -/* Remove n bits from the bit accumulator */ -#define DROPBITS(n) \ - do { \ - hold >>= (n); \ - bits -= (unsigned)(n); \ - } while (0) - -/* Remove zero to seven bits as needed to go to a byte boundary */ -#define BYTEBITS() \ - do { \ - hold >>= bits & 7; \ - bits -= bits & 7; \ - } while (0) - -/* Assure that some output space is available, by writing out the window - if it's full. If the write fails, return from inflateBack() with a - Z_BUF_ERROR. */ -#define ROOM() \ - do { \ - if (left == 0) { \ - put = window; \ - left = WSIZE; \ - wrap = 1; \ - if (out(out_desc, put, (unsigned)left)) { \ - ret = Z_BUF_ERROR; \ - goto inf_leave; \ - } \ - } \ - } while (0) - -/* - strm provides the memory allocation functions and window buffer on input, - and provides information on the unused input on return. For Z_DATA_ERROR - returns, strm will also provide an error message. - - in() and out() are the call-back input and output functions. When - inflateBack() needs more input, it calls in(). When inflateBack() has - filled the window with output, or when it completes with data in the - window, it calls out() to write out the data. The application must not - change the provided input until in() is called again or inflateBack() - returns. The application must not change the window/output buffer until - inflateBack() returns. - - in() and out() are called with a descriptor parameter provided in the - inflateBack() call. This parameter can be a structure that provides the - information required to do the read or write, as well as accumulated - information on the input and output such as totals and check values. - - in() should return zero on failure. out() should return non-zero on - failure. If either in() or out() fails, than inflateBack() returns a - Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it - was in() or out() that caused in the error. Otherwise, inflateBack() - returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format - error, or Z_MEM_ERROR if it could not allocate memory for the state. - inflateBack() can also return Z_STREAM_ERROR if the input parameters - are not correct, i.e. strm is Z_NULL or the state was not initialized. - */ -int ZEXPORT inflateBack9(strm, in, in_desc, out, out_desc) -z_stream FAR *strm; -in_func in; -void FAR *in_desc; -out_func out; -void FAR *out_desc; -{ - struct inflate_state FAR *state; - z_const unsigned char FAR *next; /* next input */ - unsigned char FAR *put; /* next output */ - unsigned have; /* available input */ - unsigned long left; /* available output */ - inflate_mode mode; /* current inflate mode */ - int lastblock; /* true if processing last block */ - int wrap; /* true if the window has wrapped */ - unsigned char FAR *window; /* allocated sliding window, if needed */ - unsigned long hold; /* bit buffer */ - unsigned bits; /* bits in bit buffer */ - unsigned extra; /* extra bits needed */ - unsigned long length; /* literal or length of data to copy */ - unsigned long offset; /* distance back to copy string from */ - unsigned long copy; /* number of stored or match bytes to copy */ - unsigned char FAR *from; /* where to copy match bytes from */ - code const FAR *lencode; /* starting table for length/literal codes */ - code const FAR *distcode; /* starting table for distance codes */ - unsigned lenbits; /* index bits for lencode */ - unsigned distbits; /* index bits for distcode */ - code here; /* current decoding table entry */ - code last; /* parent table entry */ - unsigned len; /* length to copy for repeats, bits to drop */ - int ret; /* return code */ - static const unsigned short order[19] = /* permutation of code lengths */ - {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; -#include "inffix9.h" - - /* Check that the strm exists and that the state was initialized */ - if (strm == Z_NULL || strm->state == Z_NULL) - return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - - /* Reset the state */ - strm->msg = Z_NULL; - mode = TYPE; - lastblock = 0; - wrap = 0; - window = state->window; - next = strm->next_in; - have = next != Z_NULL ? strm->avail_in : 0; - hold = 0; - bits = 0; - put = window; - left = WSIZE; - lencode = Z_NULL; - distcode = Z_NULL; - - /* Inflate until end of block marked as last */ - for (;;) - switch (mode) { - case TYPE: - /* determine and dispatch block type */ - if (lastblock) { - BYTEBITS(); - mode = DONE; - break; - } - NEEDBITS(3); - lastblock = BITS(1); - DROPBITS(1); - switch (BITS(2)) { - case 0: /* stored block */ - Tracev((stderr, "inflate: stored block%s\n", - lastblock ? " (last)" : "")); - mode = STORED; - break; - case 1: /* fixed block */ - lencode = lenfix; - lenbits = 9; - distcode = distfix; - distbits = 5; - Tracev((stderr, "inflate: fixed codes block%s\n", - lastblock ? " (last)" : "")); - mode = LEN; /* decode codes */ - break; - case 2: /* dynamic block */ - Tracev((stderr, "inflate: dynamic codes block%s\n", - lastblock ? " (last)" : "")); - mode = TABLE; - break; - case 3: - strm->msg = (char *)"invalid block type"; - mode = BAD; - } - DROPBITS(2); - break; - - case STORED: - /* get and verify stored block length */ - BYTEBITS(); /* go to byte boundary */ - NEEDBITS(32); - if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { - strm->msg = (char *)"invalid stored block lengths"; - mode = BAD; - break; - } - length = (unsigned)hold & 0xffff; - Tracev((stderr, "inflate: stored length %lu\n", - length)); - INITBITS(); - - /* copy stored block from input to output */ - while (length != 0) { - copy = length; - PULL(); - ROOM(); - if (copy > have) copy = have; - if (copy > left) copy = left; - zmemcpy(put, next, copy); - have -= copy; - next += copy; - left -= copy; - put += copy; - length -= copy; - } - Tracev((stderr, "inflate: stored end\n")); - mode = TYPE; - break; - - case TABLE: - /* get dynamic table entries descriptor */ - NEEDBITS(14); - state->nlen = BITS(5) + 257; - DROPBITS(5); - state->ndist = BITS(5) + 1; - DROPBITS(5); - state->ncode = BITS(4) + 4; - DROPBITS(4); - if (state->nlen > 286) { - strm->msg = (char *)"too many length symbols"; - mode = BAD; - break; - } - Tracev((stderr, "inflate: table sizes ok\n")); - - /* get code length code lengths (not a typo) */ - state->have = 0; - while (state->have < state->ncode) { - NEEDBITS(3); - state->lens[order[state->have++]] = (unsigned short)BITS(3); - DROPBITS(3); - } - while (state->have < 19) - state->lens[order[state->have++]] = 0; - state->next = state->codes; - lencode = (code const FAR *)(state->next); - lenbits = 7; - ret = inflate_table9(CODES, state->lens, 19, &(state->next), - &(lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid code lengths set"; - mode = BAD; - break; - } - Tracev((stderr, "inflate: code lengths ok\n")); - - /* get length and distance code code lengths */ - state->have = 0; - while (state->have < state->nlen + state->ndist) { - for (;;) { - here = lencode[BITS(lenbits)]; - if ((unsigned)(here.bits) <= bits) break; - PULLBYTE(); - } - if (here.val < 16) { - NEEDBITS(here.bits); - DROPBITS(here.bits); - state->lens[state->have++] = here.val; - } - else { - if (here.val == 16) { - NEEDBITS(here.bits + 2); - DROPBITS(here.bits); - if (state->have == 0) { - strm->msg = (char *)"invalid bit length repeat"; - mode = BAD; - break; - } - len = (unsigned)(state->lens[state->have - 1]); - copy = 3 + BITS(2); - DROPBITS(2); - } - else if (here.val == 17) { - NEEDBITS(here.bits + 3); - DROPBITS(here.bits); - len = 0; - copy = 3 + BITS(3); - DROPBITS(3); - } - else { - NEEDBITS(here.bits + 7); - DROPBITS(here.bits); - len = 0; - copy = 11 + BITS(7); - DROPBITS(7); - } - if (state->have + copy > state->nlen + state->ndist) { - strm->msg = (char *)"invalid bit length repeat"; - mode = BAD; - break; - } - while (copy--) - state->lens[state->have++] = (unsigned short)len; - } - } - - /* handle error breaks in while */ - if (mode == BAD) break; - - /* check for end-of-block code (better have one) */ - if (state->lens[256] == 0) { - strm->msg = (char *)"invalid code -- missing end-of-block"; - mode = BAD; - break; - } - - /* build code tables -- note: do not change the lenbits or distbits - values here (9 and 6) without reading the comments in inftree9.h - concerning the ENOUGH constants, which depend on those values */ - state->next = state->codes; - lencode = (code const FAR *)(state->next); - lenbits = 9; - ret = inflate_table9(LENS, state->lens, state->nlen, - &(state->next), &(lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid literal/lengths set"; - mode = BAD; - break; - } - distcode = (code const FAR *)(state->next); - distbits = 6; - ret = inflate_table9(DISTS, state->lens + state->nlen, - state->ndist, &(state->next), &(distbits), - state->work); - if (ret) { - strm->msg = (char *)"invalid distances set"; - mode = BAD; - break; - } - Tracev((stderr, "inflate: codes ok\n")); - mode = LEN; - - case LEN: - /* get a literal, length, or end-of-block code */ - for (;;) { - here = lencode[BITS(lenbits)]; - if ((unsigned)(here.bits) <= bits) break; - PULLBYTE(); - } - if (here.op && (here.op & 0xf0) == 0) { - last = here; - for (;;) { - here = lencode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + here.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - } - DROPBITS(here.bits); - length = (unsigned)here.val; - - /* process literal */ - if (here.op == 0) { - Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? - "inflate: literal '%c'\n" : - "inflate: literal 0x%02x\n", here.val)); - ROOM(); - *put++ = (unsigned char)(length); - left--; - mode = LEN; - break; - } - - /* process end of block */ - if (here.op & 32) { - Tracevv((stderr, "inflate: end of block\n")); - mode = TYPE; - break; - } - - /* invalid code */ - if (here.op & 64) { - strm->msg = (char *)"invalid literal/length code"; - mode = BAD; - break; - } - - /* length code -- get extra bits, if any */ - extra = (unsigned)(here.op) & 31; - if (extra != 0) { - NEEDBITS(extra); - length += BITS(extra); - DROPBITS(extra); - } - Tracevv((stderr, "inflate: length %lu\n", length)); - - /* get distance code */ - for (;;) { - here = distcode[BITS(distbits)]; - if ((unsigned)(here.bits) <= bits) break; - PULLBYTE(); - } - if ((here.op & 0xf0) == 0) { - last = here; - for (;;) { - here = distcode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + here.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - } - DROPBITS(here.bits); - if (here.op & 64) { - strm->msg = (char *)"invalid distance code"; - mode = BAD; - break; - } - offset = (unsigned)here.val; - - /* get distance extra bits, if any */ - extra = (unsigned)(here.op) & 15; - if (extra != 0) { - NEEDBITS(extra); - offset += BITS(extra); - DROPBITS(extra); - } - if (offset > WSIZE - (wrap ? 0: left)) { - strm->msg = (char *)"invalid distance too far back"; - mode = BAD; - break; - } - Tracevv((stderr, "inflate: distance %lu\n", offset)); - - /* copy match from window to output */ - do { - ROOM(); - copy = WSIZE - offset; - if (copy < left) { - from = put + copy; - copy = left - copy; - } - else { - from = put - offset; - copy = left; - } - if (copy > length) copy = length; - length -= copy; - left -= copy; - do { - *put++ = *from++; - } while (--copy); - } while (length != 0); - break; - - case DONE: - /* inflate stream terminated properly -- write leftover output */ - ret = Z_STREAM_END; - if (left < WSIZE) { - if (out(out_desc, window, (unsigned)(WSIZE - left))) - ret = Z_BUF_ERROR; - } - goto inf_leave; - - case BAD: - ret = Z_DATA_ERROR; - goto inf_leave; - - default: /* can't happen, but makes compilers happy */ - ret = Z_STREAM_ERROR; - goto inf_leave; - } - - /* Return unused input */ - inf_leave: - strm->next_in = next; - strm->avail_in = have; - return ret; -} - -int ZEXPORT inflateBack9End(strm) -z_stream FAR *strm; -{ - if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) - return Z_STREAM_ERROR; - ZFREE(strm, strm->state); - strm->state = Z_NULL; - Tracev((stderr, "inflate: end\n")); - return Z_OK; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/infback9/infback9.h b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/infback9/infback9.h deleted file mode 100644 index 1073c0a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/infback9/infback9.h +++ /dev/null @@ -1,37 +0,0 @@ -/* infback9.h -- header for using inflateBack9 functions - * Copyright (C) 2003 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - * This header file and associated patches provide a decoder for PKWare's - * undocumented deflate64 compression method (method 9). Use with infback9.c, - * inftree9.h, inftree9.c, and inffix9.h. These patches are not supported. - * This should be compiled with zlib, since it uses zutil.h and zutil.o. - * This code has not yet been tested on 16-bit architectures. See the - * comments in zlib.h for inflateBack() usage. These functions are used - * identically, except that there is no windowBits parameter, and a 64K - * window must be provided. Also if int's are 16 bits, then a zero for - * the third parameter of the "out" function actually means 65536UL. - * zlib.h must be included before this header file. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -ZEXTERN int ZEXPORT inflateBack9 OF((z_stream FAR *strm, - in_func in, void FAR *in_desc, - out_func out, void FAR *out_desc)); -ZEXTERN int ZEXPORT inflateBack9End OF((z_stream FAR *strm)); -ZEXTERN int ZEXPORT inflateBack9Init_ OF((z_stream FAR *strm, - unsigned char FAR *window, - const char *version, - int stream_size)); -#define inflateBack9Init(strm, window) \ - inflateBack9Init_((strm), (window), \ - ZLIB_VERSION, sizeof(z_stream)) - -#ifdef __cplusplus -} -#endif diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/infback9/inffix9.h b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/infback9/inffix9.h deleted file mode 100644 index ee5671d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/infback9/inffix9.h +++ /dev/null @@ -1,107 +0,0 @@ - /* inffix9.h -- table for decoding deflate64 fixed codes - * Generated automatically by makefixed9(). - */ - - /* WARNING: this file should *not* be used by applications. - It is part of the implementation of this library and is - subject to change. Applications should only use zlib.h. - */ - - static const code lenfix[512] = { - {96,7,0},{0,8,80},{0,8,16},{132,8,115},{130,7,31},{0,8,112}, - {0,8,48},{0,9,192},{128,7,10},{0,8,96},{0,8,32},{0,9,160}, - {0,8,0},{0,8,128},{0,8,64},{0,9,224},{128,7,6},{0,8,88}, - {0,8,24},{0,9,144},{131,7,59},{0,8,120},{0,8,56},{0,9,208}, - {129,7,17},{0,8,104},{0,8,40},{0,9,176},{0,8,8},{0,8,136}, - {0,8,72},{0,9,240},{128,7,4},{0,8,84},{0,8,20},{133,8,227}, - {131,7,43},{0,8,116},{0,8,52},{0,9,200},{129,7,13},{0,8,100}, - {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232}, - {128,7,8},{0,8,92},{0,8,28},{0,9,152},{132,7,83},{0,8,124}, - {0,8,60},{0,9,216},{130,7,23},{0,8,108},{0,8,44},{0,9,184}, - {0,8,12},{0,8,140},{0,8,76},{0,9,248},{128,7,3},{0,8,82}, - {0,8,18},{133,8,163},{131,7,35},{0,8,114},{0,8,50},{0,9,196}, - {129,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},{0,8,130}, - {0,8,66},{0,9,228},{128,7,7},{0,8,90},{0,8,26},{0,9,148}, - {132,7,67},{0,8,122},{0,8,58},{0,9,212},{130,7,19},{0,8,106}, - {0,8,42},{0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244}, - {128,7,5},{0,8,86},{0,8,22},{65,8,0},{131,7,51},{0,8,118}, - {0,8,54},{0,9,204},{129,7,15},{0,8,102},{0,8,38},{0,9,172}, - {0,8,6},{0,8,134},{0,8,70},{0,9,236},{128,7,9},{0,8,94}, - {0,8,30},{0,9,156},{132,7,99},{0,8,126},{0,8,62},{0,9,220}, - {130,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, - {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{133,8,131}, - {130,7,31},{0,8,113},{0,8,49},{0,9,194},{128,7,10},{0,8,97}, - {0,8,33},{0,9,162},{0,8,1},{0,8,129},{0,8,65},{0,9,226}, - {128,7,6},{0,8,89},{0,8,25},{0,9,146},{131,7,59},{0,8,121}, - {0,8,57},{0,9,210},{129,7,17},{0,8,105},{0,8,41},{0,9,178}, - {0,8,9},{0,8,137},{0,8,73},{0,9,242},{128,7,4},{0,8,85}, - {0,8,21},{144,8,3},{131,7,43},{0,8,117},{0,8,53},{0,9,202}, - {129,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133}, - {0,8,69},{0,9,234},{128,7,8},{0,8,93},{0,8,29},{0,9,154}, - {132,7,83},{0,8,125},{0,8,61},{0,9,218},{130,7,23},{0,8,109}, - {0,8,45},{0,9,186},{0,8,13},{0,8,141},{0,8,77},{0,9,250}, - {128,7,3},{0,8,83},{0,8,19},{133,8,195},{131,7,35},{0,8,115}, - {0,8,51},{0,9,198},{129,7,11},{0,8,99},{0,8,35},{0,9,166}, - {0,8,3},{0,8,131},{0,8,67},{0,9,230},{128,7,7},{0,8,91}, - {0,8,27},{0,9,150},{132,7,67},{0,8,123},{0,8,59},{0,9,214}, - {130,7,19},{0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139}, - {0,8,75},{0,9,246},{128,7,5},{0,8,87},{0,8,23},{77,8,0}, - {131,7,51},{0,8,119},{0,8,55},{0,9,206},{129,7,15},{0,8,103}, - {0,8,39},{0,9,174},{0,8,7},{0,8,135},{0,8,71},{0,9,238}, - {128,7,9},{0,8,95},{0,8,31},{0,9,158},{132,7,99},{0,8,127}, - {0,8,63},{0,9,222},{130,7,27},{0,8,111},{0,8,47},{0,9,190}, - {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80}, - {0,8,16},{132,8,115},{130,7,31},{0,8,112},{0,8,48},{0,9,193}, - {128,7,10},{0,8,96},{0,8,32},{0,9,161},{0,8,0},{0,8,128}, - {0,8,64},{0,9,225},{128,7,6},{0,8,88},{0,8,24},{0,9,145}, - {131,7,59},{0,8,120},{0,8,56},{0,9,209},{129,7,17},{0,8,104}, - {0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},{0,9,241}, - {128,7,4},{0,8,84},{0,8,20},{133,8,227},{131,7,43},{0,8,116}, - {0,8,52},{0,9,201},{129,7,13},{0,8,100},{0,8,36},{0,9,169}, - {0,8,4},{0,8,132},{0,8,68},{0,9,233},{128,7,8},{0,8,92}, - {0,8,28},{0,9,153},{132,7,83},{0,8,124},{0,8,60},{0,9,217}, - {130,7,23},{0,8,108},{0,8,44},{0,9,185},{0,8,12},{0,8,140}, - {0,8,76},{0,9,249},{128,7,3},{0,8,82},{0,8,18},{133,8,163}, - {131,7,35},{0,8,114},{0,8,50},{0,9,197},{129,7,11},{0,8,98}, - {0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, - {128,7,7},{0,8,90},{0,8,26},{0,9,149},{132,7,67},{0,8,122}, - {0,8,58},{0,9,213},{130,7,19},{0,8,106},{0,8,42},{0,9,181}, - {0,8,10},{0,8,138},{0,8,74},{0,9,245},{128,7,5},{0,8,86}, - {0,8,22},{65,8,0},{131,7,51},{0,8,118},{0,8,54},{0,9,205}, - {129,7,15},{0,8,102},{0,8,38},{0,9,173},{0,8,6},{0,8,134}, - {0,8,70},{0,9,237},{128,7,9},{0,8,94},{0,8,30},{0,9,157}, - {132,7,99},{0,8,126},{0,8,62},{0,9,221},{130,7,27},{0,8,110}, - {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253}, - {96,7,0},{0,8,81},{0,8,17},{133,8,131},{130,7,31},{0,8,113}, - {0,8,49},{0,9,195},{128,7,10},{0,8,97},{0,8,33},{0,9,163}, - {0,8,1},{0,8,129},{0,8,65},{0,9,227},{128,7,6},{0,8,89}, - {0,8,25},{0,9,147},{131,7,59},{0,8,121},{0,8,57},{0,9,211}, - {129,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},{0,8,137}, - {0,8,73},{0,9,243},{128,7,4},{0,8,85},{0,8,21},{144,8,3}, - {131,7,43},{0,8,117},{0,8,53},{0,9,203},{129,7,13},{0,8,101}, - {0,8,37},{0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235}, - {128,7,8},{0,8,93},{0,8,29},{0,9,155},{132,7,83},{0,8,125}, - {0,8,61},{0,9,219},{130,7,23},{0,8,109},{0,8,45},{0,9,187}, - {0,8,13},{0,8,141},{0,8,77},{0,9,251},{128,7,3},{0,8,83}, - {0,8,19},{133,8,195},{131,7,35},{0,8,115},{0,8,51},{0,9,199}, - {129,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, - {0,8,67},{0,9,231},{128,7,7},{0,8,91},{0,8,27},{0,9,151}, - {132,7,67},{0,8,123},{0,8,59},{0,9,215},{130,7,19},{0,8,107}, - {0,8,43},{0,9,183},{0,8,11},{0,8,139},{0,8,75},{0,9,247}, - {128,7,5},{0,8,87},{0,8,23},{77,8,0},{131,7,51},{0,8,119}, - {0,8,55},{0,9,207},{129,7,15},{0,8,103},{0,8,39},{0,9,175}, - {0,8,7},{0,8,135},{0,8,71},{0,9,239},{128,7,9},{0,8,95}, - {0,8,31},{0,9,159},{132,7,99},{0,8,127},{0,8,63},{0,9,223}, - {130,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143}, - {0,8,79},{0,9,255} - }; - - static const code distfix[32] = { - {128,5,1},{135,5,257},{131,5,17},{139,5,4097},{129,5,5}, - {137,5,1025},{133,5,65},{141,5,16385},{128,5,3},{136,5,513}, - {132,5,33},{140,5,8193},{130,5,9},{138,5,2049},{134,5,129}, - {142,5,32769},{128,5,2},{135,5,385},{131,5,25},{139,5,6145}, - {129,5,7},{137,5,1537},{133,5,97},{141,5,24577},{128,5,4}, - {136,5,769},{132,5,49},{140,5,12289},{130,5,13},{138,5,3073}, - {134,5,193},{142,5,49153} - }; diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/infback9/inflate9.h b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/infback9/inflate9.h deleted file mode 100644 index ee9a793..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/infback9/inflate9.h +++ /dev/null @@ -1,47 +0,0 @@ -/* inflate9.h -- internal inflate state definition - * Copyright (C) 1995-2003 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* Possible inflate modes between inflate() calls */ -typedef enum { - TYPE, /* i: waiting for type bits, including last-flag bit */ - STORED, /* i: waiting for stored size (length and complement) */ - TABLE, /* i: waiting for dynamic block table lengths */ - LEN, /* i: waiting for length/lit code */ - DONE, /* finished check, done -- remain here until reset */ - BAD /* got a data error -- remain here until reset */ -} inflate_mode; - -/* - State transitions between above modes - - - (most modes can go to the BAD mode -- not shown for clarity) - - Read deflate blocks: - TYPE -> STORED or TABLE or LEN or DONE - STORED -> TYPE - TABLE -> LENLENS -> CODELENS -> LEN - Read deflate codes: - LEN -> LEN or TYPE - */ - -/* state maintained between inflate() calls. Approximately 7K bytes. */ -struct inflate_state { - /* sliding window */ - unsigned char FAR *window; /* allocated sliding window, if needed */ - /* dynamic table building */ - unsigned ncode; /* number of code length code lengths */ - unsigned nlen; /* number of length code lengths */ - unsigned ndist; /* number of distance code lengths */ - unsigned have; /* number of code lengths in lens[] */ - code FAR *next; /* next available space in codes[] */ - unsigned short lens[320]; /* temporary storage for code lengths */ - unsigned short work[288]; /* work area for code table building */ - code codes[ENOUGH]; /* space for code tables */ -}; diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/infback9/inftree9.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/infback9/inftree9.c deleted file mode 100644 index 0550606..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/infback9/inftree9.c +++ /dev/null @@ -1,324 +0,0 @@ -/* inftree9.c -- generate Huffman trees for efficient decoding - * Copyright (C) 1995-2022 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "inftree9.h" - -#define MAXBITS 15 - -const char inflate9_copyright[] = - " inflate9 1.2.12 Copyright 1995-2022 Mark Adler "; -/* - If you use the zlib library in a product, an acknowledgment is welcome - in the documentation of your product. If for some reason you cannot - include such an acknowledgment, I would appreciate that you keep this - copyright string in the executable of your product. - */ - -/* - Build a set of tables to decode the provided canonical Huffman code. - The code lengths are lens[0..codes-1]. The result starts at *table, - whose indices are 0..2^bits-1. work is a writable array of at least - lens shorts, which is used as a work area. type is the type of code - to be generated, CODES, LENS, or DISTS. On return, zero is success, - -1 is an invalid code, and +1 means that ENOUGH isn't enough. table - on return points to the next available entry's address. bits is the - requested root table index bits, and on return it is the actual root - table index bits. It will differ if the request is greater than the - longest code or if it is less than the shortest code. - */ -int inflate_table9(type, lens, codes, table, bits, work) -codetype type; -unsigned short FAR *lens; -unsigned codes; -code FAR * FAR *table; -unsigned FAR *bits; -unsigned short FAR *work; -{ - unsigned len; /* a code's length in bits */ - unsigned sym; /* index of code symbols */ - unsigned min, max; /* minimum and maximum code lengths */ - unsigned root; /* number of index bits for root table */ - unsigned curr; /* number of index bits for current table */ - unsigned drop; /* code bits to drop for sub-table */ - int left; /* number of prefix codes available */ - unsigned used; /* code entries in table used */ - unsigned huff; /* Huffman code */ - unsigned incr; /* for incrementing code, index */ - unsigned fill; /* index for replicating entries */ - unsigned low; /* low bits for current root entry */ - unsigned mask; /* mask for low root bits */ - code this; /* table entry for duplication */ - code FAR *next; /* next available space in table */ - const unsigned short FAR *base; /* base value table to use */ - const unsigned short FAR *extra; /* extra bits table to use */ - int end; /* use base and extra for symbol > end */ - unsigned short count[MAXBITS+1]; /* number of codes of each length */ - unsigned short offs[MAXBITS+1]; /* offsets in table for each length */ - static const unsigned short lbase[31] = { /* Length codes 257..285 base */ - 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, - 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, - 131, 163, 195, 227, 3, 0, 0}; - static const unsigned short lext[31] = { /* Length codes 257..285 extra */ - 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, - 130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132, - 133, 133, 133, 133, 144, 199, 202}; - static const unsigned short dbase[32] = { /* Distance codes 0..31 base */ - 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, - 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, - 4097, 6145, 8193, 12289, 16385, 24577, 32769, 49153}; - static const unsigned short dext[32] = { /* Distance codes 0..31 extra */ - 128, 128, 128, 128, 129, 129, 130, 130, 131, 131, 132, 132, - 133, 133, 134, 134, 135, 135, 136, 136, 137, 137, 138, 138, - 139, 139, 140, 140, 141, 141, 142, 142}; - - /* - Process a set of code lengths to create a canonical Huffman code. The - code lengths are lens[0..codes-1]. Each length corresponds to the - symbols 0..codes-1. The Huffman code is generated by first sorting the - symbols by length from short to long, and retaining the symbol order - for codes with equal lengths. Then the code starts with all zero bits - for the first code of the shortest length, and the codes are integer - increments for the same length, and zeros are appended as the length - increases. For the deflate format, these bits are stored backwards - from their more natural integer increment ordering, and so when the - decoding tables are built in the large loop below, the integer codes - are incremented backwards. - - This routine assumes, but does not check, that all of the entries in - lens[] are in the range 0..MAXBITS. The caller must assure this. - 1..MAXBITS is interpreted as that code length. zero means that that - symbol does not occur in this code. - - The codes are sorted by computing a count of codes for each length, - creating from that a table of starting indices for each length in the - sorted table, and then entering the symbols in order in the sorted - table. The sorted table is work[], with that space being provided by - the caller. - - The length counts are used for other purposes as well, i.e. finding - the minimum and maximum length codes, determining if there are any - codes at all, checking for a valid set of lengths, and looking ahead - at length counts to determine sub-table sizes when building the - decoding tables. - */ - - /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */ - for (len = 0; len <= MAXBITS; len++) - count[len] = 0; - for (sym = 0; sym < codes; sym++) - count[lens[sym]]++; - - /* bound code lengths, force root to be within code lengths */ - root = *bits; - for (max = MAXBITS; max >= 1; max--) - if (count[max] != 0) break; - if (root > max) root = max; - if (max == 0) return -1; /* no codes! */ - for (min = 1; min <= MAXBITS; min++) - if (count[min] != 0) break; - if (root < min) root = min; - - /* check for an over-subscribed or incomplete set of lengths */ - left = 1; - for (len = 1; len <= MAXBITS; len++) { - left <<= 1; - left -= count[len]; - if (left < 0) return -1; /* over-subscribed */ - } - if (left > 0 && (type == CODES || max != 1)) - return -1; /* incomplete set */ - - /* generate offsets into symbol table for each length for sorting */ - offs[1] = 0; - for (len = 1; len < MAXBITS; len++) - offs[len + 1] = offs[len] + count[len]; - - /* sort symbols by length, by symbol order within each length */ - for (sym = 0; sym < codes; sym++) - if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym; - - /* - Create and fill in decoding tables. In this loop, the table being - filled is at next and has curr index bits. The code being used is huff - with length len. That code is converted to an index by dropping drop - bits off of the bottom. For codes where len is less than drop + curr, - those top drop + curr - len bits are incremented through all values to - fill the table with replicated entries. - - root is the number of index bits for the root table. When len exceeds - root, sub-tables are created pointed to by the root entry with an index - of the low root bits of huff. This is saved in low to check for when a - new sub-table should be started. drop is zero when the root table is - being filled, and drop is root when sub-tables are being filled. - - When a new sub-table is needed, it is necessary to look ahead in the - code lengths to determine what size sub-table is needed. The length - counts are used for this, and so count[] is decremented as codes are - entered in the tables. - - used keeps track of how many table entries have been allocated from the - provided *table space. It is checked for LENS and DIST tables against - the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in - the initial root table size constants. See the comments in inftree9.h - for more information. - - sym increments through all symbols, and the loop terminates when - all codes of length max, i.e. all codes, have been processed. This - routine permits incomplete codes, so another loop after this one fills - in the rest of the decoding tables with invalid code markers. - */ - - /* set up for code type */ - switch (type) { - case CODES: - base = extra = work; /* dummy value--not used */ - end = 19; - break; - case LENS: - base = lbase; - base -= 257; - extra = lext; - extra -= 257; - end = 256; - break; - default: /* DISTS */ - base = dbase; - extra = dext; - end = -1; - } - - /* initialize state for loop */ - huff = 0; /* starting code */ - sym = 0; /* starting code symbol */ - len = min; /* starting code length */ - next = *table; /* current table to fill in */ - curr = root; /* current table index bits */ - drop = 0; /* current bits to drop from code for index */ - low = (unsigned)(-1); /* trigger new sub-table when len > root */ - used = 1U << root; /* use root table entries */ - mask = used - 1; /* mask for comparing low */ - - /* check available table space */ - if ((type == LENS && used >= ENOUGH_LENS) || - (type == DISTS && used >= ENOUGH_DISTS)) - return 1; - - /* process all codes and make table entries */ - for (;;) { - /* create table entry */ - this.bits = (unsigned char)(len - drop); - if ((int)(work[sym]) < end) { - this.op = (unsigned char)0; - this.val = work[sym]; - } - else if ((int)(work[sym]) > end) { - this.op = (unsigned char)(extra[work[sym]]); - this.val = base[work[sym]]; - } - else { - this.op = (unsigned char)(32 + 64); /* end of block */ - this.val = 0; - } - - /* replicate for those indices with low len bits equal to huff */ - incr = 1U << (len - drop); - fill = 1U << curr; - do { - fill -= incr; - next[(huff >> drop) + fill] = this; - } while (fill != 0); - - /* backwards increment the len-bit code huff */ - incr = 1U << (len - 1); - while (huff & incr) - incr >>= 1; - if (incr != 0) { - huff &= incr - 1; - huff += incr; - } - else - huff = 0; - - /* go to next symbol, update count, len */ - sym++; - if (--(count[len]) == 0) { - if (len == max) break; - len = lens[work[sym]]; - } - - /* create new sub-table if needed */ - if (len > root && (huff & mask) != low) { - /* if first time, transition to sub-tables */ - if (drop == 0) - drop = root; - - /* increment past last table */ - next += 1U << curr; - - /* determine length of next table */ - curr = len - drop; - left = (int)(1 << curr); - while (curr + drop < max) { - left -= count[curr + drop]; - if (left <= 0) break; - curr++; - left <<= 1; - } - - /* check for enough space */ - used += 1U << curr; - if ((type == LENS && used >= ENOUGH_LENS) || - (type == DISTS && used >= ENOUGH_DISTS)) - return 1; - - /* point entry in root table to sub-table */ - low = huff & mask; - (*table)[low].op = (unsigned char)curr; - (*table)[low].bits = (unsigned char)root; - (*table)[low].val = (unsigned short)(next - *table); - } - } - - /* - Fill in rest of table for incomplete codes. This loop is similar to the - loop above in incrementing huff for table indices. It is assumed that - len is equal to curr + drop, so there is no loop needed to increment - through high index bits. When the current sub-table is filled, the loop - drops back to the root table to fill in any remaining entries there. - */ - this.op = (unsigned char)64; /* invalid code marker */ - this.bits = (unsigned char)(len - drop); - this.val = (unsigned short)0; - while (huff != 0) { - /* when done with sub-table, drop back to root table */ - if (drop != 0 && (huff & mask) != low) { - drop = 0; - len = root; - next = *table; - curr = root; - this.bits = (unsigned char)len; - } - - /* put invalid code marker in table */ - next[huff >> drop] = this; - - /* backwards increment the len-bit code huff */ - incr = 1U << (len - 1); - while (huff & incr) - incr >>= 1; - if (incr != 0) { - huff &= incr - 1; - huff += incr; - } - else - huff = 0; - } - - /* set return parameters */ - *table += used; - *bits = root; - return 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/infback9/inftree9.h b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/infback9/inftree9.h deleted file mode 100644 index 5ab21f0..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/infback9/inftree9.h +++ /dev/null @@ -1,61 +0,0 @@ -/* inftree9.h -- header to use inftree9.c - * Copyright (C) 1995-2008 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* Structure for decoding tables. Each entry provides either the - information needed to do the operation requested by the code that - indexed that table entry, or it provides a pointer to another - table that indexes more bits of the code. op indicates whether - the entry is a pointer to another table, a literal, a length or - distance, an end-of-block, or an invalid code. For a table - pointer, the low four bits of op is the number of index bits of - that table. For a length or distance, the low four bits of op - is the number of extra bits to get after the code. bits is - the number of bits in this code or part of the code to drop off - of the bit buffer. val is the actual byte to output in the case - of a literal, the base length or distance, or the offset from - the current table to the next table. Each entry is four bytes. */ -typedef struct { - unsigned char op; /* operation, extra bits, table bits */ - unsigned char bits; /* bits in this part of the code */ - unsigned short val; /* offset in table or code value */ -} code; - -/* op values as set by inflate_table(): - 00000000 - literal - 0000tttt - table link, tttt != 0 is the number of table index bits - 100eeeee - length or distance, eeee is the number of extra bits - 01100000 - end of block - 01000000 - invalid code - */ - -/* Maximum size of the dynamic table. The maximum number of code structures is - 1446, which is the sum of 852 for literal/length codes and 594 for distance - codes. These values were found by exhaustive searches using the program - examples/enough.c found in the zlib distribtution. The arguments to that - program are the number of symbols, the initial root table size, and the - maximum bit length of a code. "enough 286 9 15" for literal/length codes - returns returns 852, and "enough 32 6 15" for distance codes returns 594. - The initial root table size (9 or 6) is found in the fifth argument of the - inflate_table() calls in infback9.c. If the root table size is changed, - then these maximum sizes would be need to be recalculated and updated. */ -#define ENOUGH_LENS 852 -#define ENOUGH_DISTS 594 -#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) - -/* Type of code to build for inflate_table9() */ -typedef enum { - CODES, - LENS, - DISTS -} codetype; - -extern int inflate_table9 OF((codetype type, unsigned short FAR *lens, - unsigned codes, code FAR * FAR *table, - unsigned FAR *bits, unsigned short FAR *work)); diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/iostream/test.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/iostream/test.cpp deleted file mode 100644 index 7d265b3..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/iostream/test.cpp +++ /dev/null @@ -1,24 +0,0 @@ - -#include "zfstream.h" - -int main() { - - // Construct a stream object with this filebuffer. Anything sent - // to this stream will go to standard out. - gzofstream os( 1, ios::out ); - - // This text is getting compressed and sent to stdout. - // To prove this, run 'test | zcat'. - os << "Hello, Mommy" << endl; - - os << setcompressionlevel( Z_NO_COMPRESSION ); - os << "hello, hello, hi, ho!" << endl; - - setcompressionlevel( os, Z_DEFAULT_COMPRESSION ) - << "I'm compressing again" << endl; - - os.close(); - - return 0; - -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/iostream/zfstream.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/iostream/zfstream.cpp deleted file mode 100644 index d0cd85f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/iostream/zfstream.cpp +++ /dev/null @@ -1,329 +0,0 @@ - -#include "zfstream.h" - -gzfilebuf::gzfilebuf() : - file(NULL), - mode(0), - own_file_descriptor(0) -{ } - -gzfilebuf::~gzfilebuf() { - - sync(); - if ( own_file_descriptor ) - close(); - -} - -gzfilebuf *gzfilebuf::open( const char *name, - int io_mode ) { - - if ( is_open() ) - return NULL; - - char char_mode[10]; - char *p = char_mode; - - if ( io_mode & ios::in ) { - mode = ios::in; - *p++ = 'r'; - } else if ( io_mode & ios::app ) { - mode = ios::app; - *p++ = 'a'; - } else { - mode = ios::out; - *p++ = 'w'; - } - - if ( io_mode & ios::binary ) { - mode |= ios::binary; - *p++ = 'b'; - } - - // Hard code the compression level - if ( io_mode & (ios::out|ios::app )) { - *p++ = '9'; - } - - // Put the end-of-string indicator - *p = '\0'; - - if ( (file = gzopen(name, char_mode)) == NULL ) - return NULL; - - own_file_descriptor = 1; - - return this; - -} - -gzfilebuf *gzfilebuf::attach( int file_descriptor, - int io_mode ) { - - if ( is_open() ) - return NULL; - - char char_mode[10]; - char *p = char_mode; - - if ( io_mode & ios::in ) { - mode = ios::in; - *p++ = 'r'; - } else if ( io_mode & ios::app ) { - mode = ios::app; - *p++ = 'a'; - } else { - mode = ios::out; - *p++ = 'w'; - } - - if ( io_mode & ios::binary ) { - mode |= ios::binary; - *p++ = 'b'; - } - - // Hard code the compression level - if ( io_mode & (ios::out|ios::app )) { - *p++ = '9'; - } - - // Put the end-of-string indicator - *p = '\0'; - - if ( (file = gzdopen(file_descriptor, char_mode)) == NULL ) - return NULL; - - own_file_descriptor = 0; - - return this; - -} - -gzfilebuf *gzfilebuf::close() { - - if ( is_open() ) { - - sync(); - gzclose( file ); - file = NULL; - - } - - return this; - -} - -int gzfilebuf::setcompressionlevel( int comp_level ) { - - return gzsetparams(file, comp_level, -2); - -} - -int gzfilebuf::setcompressionstrategy( int comp_strategy ) { - - return gzsetparams(file, -2, comp_strategy); - -} - - -streampos gzfilebuf::seekoff( streamoff off, ios::seek_dir dir, int which ) { - - return streampos(EOF); - -} - -int gzfilebuf::underflow() { - - // If the file hasn't been opened for reading, error. - if ( !is_open() || !(mode & ios::in) ) - return EOF; - - // if a buffer doesn't exists, allocate one. - if ( !base() ) { - - if ( (allocate()) == EOF ) - return EOF; - setp(0,0); - - } else { - - if ( in_avail() ) - return (unsigned char) *gptr(); - - if ( out_waiting() ) { - if ( flushbuf() == EOF ) - return EOF; - } - - } - - // Attempt to fill the buffer. - - int result = fillbuf(); - if ( result == EOF ) { - // disable get area - setg(0,0,0); - return EOF; - } - - return (unsigned char) *gptr(); - -} - -int gzfilebuf::overflow( int c ) { - - if ( !is_open() || !(mode & ios::out) ) - return EOF; - - if ( !base() ) { - if ( allocate() == EOF ) - return EOF; - setg(0,0,0); - } else { - if (in_avail()) { - return EOF; - } - if (out_waiting()) { - if (flushbuf() == EOF) - return EOF; - } - } - - int bl = blen(); - setp( base(), base() + bl); - - if ( c != EOF ) { - - *pptr() = c; - pbump(1); - - } - - return 0; - -} - -int gzfilebuf::sync() { - - if ( !is_open() ) - return EOF; - - if ( out_waiting() ) - return flushbuf(); - - return 0; - -} - -int gzfilebuf::flushbuf() { - - int n; - char *q; - - q = pbase(); - n = pptr() - q; - - if ( gzwrite( file, q, n) < n ) - return EOF; - - setp(0,0); - - return 0; - -} - -int gzfilebuf::fillbuf() { - - int required; - char *p; - - p = base(); - - required = blen(); - - int t = gzread( file, p, required ); - - if ( t <= 0) return EOF; - - setg( base(), base(), base()+t); - - return t; - -} - -gzfilestream_common::gzfilestream_common() : - ios( gzfilestream_common::rdbuf() ) -{ } - -gzfilestream_common::~gzfilestream_common() -{ } - -void gzfilestream_common::attach( int fd, int io_mode ) { - - if ( !buffer.attach( fd, io_mode) ) - clear( ios::failbit | ios::badbit ); - else - clear(); - -} - -void gzfilestream_common::open( const char *name, int io_mode ) { - - if ( !buffer.open( name, io_mode ) ) - clear( ios::failbit | ios::badbit ); - else - clear(); - -} - -void gzfilestream_common::close() { - - if ( !buffer.close() ) - clear( ios::failbit | ios::badbit ); - -} - -gzfilebuf *gzfilestream_common::rdbuf() -{ - return &buffer; -} - -gzifstream::gzifstream() : - ios( gzfilestream_common::rdbuf() ) -{ - clear( ios::badbit ); -} - -gzifstream::gzifstream( const char *name, int io_mode ) : - ios( gzfilestream_common::rdbuf() ) -{ - gzfilestream_common::open( name, io_mode ); -} - -gzifstream::gzifstream( int fd, int io_mode ) : - ios( gzfilestream_common::rdbuf() ) -{ - gzfilestream_common::attach( fd, io_mode ); -} - -gzifstream::~gzifstream() { } - -gzofstream::gzofstream() : - ios( gzfilestream_common::rdbuf() ) -{ - clear( ios::badbit ); -} - -gzofstream::gzofstream( const char *name, int io_mode ) : - ios( gzfilestream_common::rdbuf() ) -{ - gzfilestream_common::open( name, io_mode ); -} - -gzofstream::gzofstream( int fd, int io_mode ) : - ios( gzfilestream_common::rdbuf() ) -{ - gzfilestream_common::attach( fd, io_mode ); -} - -gzofstream::~gzofstream() { } diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/iostream/zfstream.h b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/iostream/zfstream.h deleted file mode 100644 index ed79098..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/iostream/zfstream.h +++ /dev/null @@ -1,128 +0,0 @@ - -#ifndef zfstream_h -#define zfstream_h - -#include -#include "zlib.h" - -class gzfilebuf : public streambuf { - -public: - - gzfilebuf( ); - virtual ~gzfilebuf(); - - gzfilebuf *open( const char *name, int io_mode ); - gzfilebuf *attach( int file_descriptor, int io_mode ); - gzfilebuf *close(); - - int setcompressionlevel( int comp_level ); - int setcompressionstrategy( int comp_strategy ); - - inline int is_open() const { return (file !=NULL); } - - virtual streampos seekoff( streamoff, ios::seek_dir, int ); - - virtual int sync(); - -protected: - - virtual int underflow(); - virtual int overflow( int = EOF ); - -private: - - gzFile file; - short mode; - short own_file_descriptor; - - int flushbuf(); - int fillbuf(); - -}; - -class gzfilestream_common : virtual public ios { - - friend class gzifstream; - friend class gzofstream; - friend gzofstream &setcompressionlevel( gzofstream &, int ); - friend gzofstream &setcompressionstrategy( gzofstream &, int ); - -public: - virtual ~gzfilestream_common(); - - void attach( int fd, int io_mode ); - void open( const char *name, int io_mode ); - void close(); - -protected: - gzfilestream_common(); - -private: - gzfilebuf *rdbuf(); - - gzfilebuf buffer; - -}; - -class gzifstream : public gzfilestream_common, public istream { - -public: - - gzifstream(); - gzifstream( const char *name, int io_mode = ios::in ); - gzifstream( int fd, int io_mode = ios::in ); - - virtual ~gzifstream(); - -}; - -class gzofstream : public gzfilestream_common, public ostream { - -public: - - gzofstream(); - gzofstream( const char *name, int io_mode = ios::out ); - gzofstream( int fd, int io_mode = ios::out ); - - virtual ~gzofstream(); - -}; - -template class gzomanip { - friend gzofstream &operator<<(gzofstream &, const gzomanip &); -public: - gzomanip(gzofstream &(*f)(gzofstream &, T), T v) : func(f), val(v) { } -private: - gzofstream &(*func)(gzofstream &, T); - T val; -}; - -template gzofstream &operator<<(gzofstream &s, const gzomanip &m) -{ - return (*m.func)(s, m.val); -} - -inline gzofstream &setcompressionlevel( gzofstream &s, int l ) -{ - (s.rdbuf())->setcompressionlevel(l); - return s; -} - -inline gzofstream &setcompressionstrategy( gzofstream &s, int l ) -{ - (s.rdbuf())->setcompressionstrategy(l); - return s; -} - -inline gzomanip setcompressionlevel(int l) -{ - return gzomanip(&setcompressionlevel,l); -} - -inline gzomanip setcompressionstrategy(int l) -{ - return gzomanip(&setcompressionstrategy,l); -} - -#endif diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/iostream2/zstream.h b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/iostream2/zstream.h deleted file mode 100644 index 43d2332..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/iostream2/zstream.h +++ /dev/null @@ -1,307 +0,0 @@ -/* - * - * Copyright (c) 1997 - * Christian Michelsen Research AS - * Advanced Computing - * Fantoftvegen 38, 5036 BERGEN, Norway - * http://www.cmr.no - * - * Permission to use, copy, modify, distribute and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appear in all copies and - * that both that copyright notice and this permission notice appear - * in supporting documentation. Christian Michelsen Research AS makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - */ - -#ifndef ZSTREAM__H -#define ZSTREAM__H - -/* - * zstream.h - C++ interface to the 'zlib' general purpose compression library - * $Id: zstream.h 1.1 1997-06-25 12:00:56+02 tyge Exp tyge $ - */ - -#include -#include -#include -#include "zlib.h" - -#if defined(_WIN32) -# include -# include -# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY) -#else -# define SET_BINARY_MODE(file) -#endif - -class zstringlen { -public: - zstringlen(class izstream&); - zstringlen(class ozstream&, const char*); - size_t value() const { return val.word; } -private: - struct Val { unsigned char byte; size_t word; } val; -}; - -// ----------------------------- izstream ----------------------------- - -class izstream -{ - public: - izstream() : m_fp(0) {} - izstream(FILE* fp) : m_fp(0) { open(fp); } - izstream(const char* name) : m_fp(0) { open(name); } - ~izstream() { close(); } - - /* Opens a gzip (.gz) file for reading. - * open() can be used to read a file which is not in gzip format; - * in this case read() will directly read from the file without - * decompression. errno can be checked to distinguish two error - * cases (if errno is zero, the zlib error is Z_MEM_ERROR). - */ - void open(const char* name) { - if (m_fp) close(); - m_fp = ::gzopen(name, "rb"); - } - - void open(FILE* fp) { - SET_BINARY_MODE(fp); - if (m_fp) close(); - m_fp = ::gzdopen(fileno(fp), "rb"); - } - - /* Flushes all pending input if necessary, closes the compressed file - * and deallocates all the (de)compression state. The return value is - * the zlib error number (see function error() below). - */ - int close() { - int r = ::gzclose(m_fp); - m_fp = 0; return r; - } - - /* Binary read the given number of bytes from the compressed file. - */ - int read(void* buf, size_t len) { - return ::gzread(m_fp, buf, len); - } - - /* Returns the error message for the last error which occurred on the - * given compressed file. errnum is set to zlib error number. If an - * error occurred in the file system and not in the compression library, - * errnum is set to Z_ERRNO and the application may consult errno - * to get the exact error code. - */ - const char* error(int* errnum) { - return ::gzerror(m_fp, errnum); - } - - gzFile fp() { return m_fp; } - - private: - gzFile m_fp; -}; - -/* - * Binary read the given (array of) object(s) from the compressed file. - * If the input file was not in gzip format, read() copies the objects number - * of bytes into the buffer. - * returns the number of uncompressed bytes actually read - * (0 for end of file, -1 for error). - */ -template -inline int read(izstream& zs, T* x, Items items) { - return ::gzread(zs.fp(), x, items*sizeof(T)); -} - -/* - * Binary input with the '>' operator. - */ -template -inline izstream& operator>(izstream& zs, T& x) { - ::gzread(zs.fp(), &x, sizeof(T)); - return zs; -} - - -inline zstringlen::zstringlen(izstream& zs) { - zs > val.byte; - if (val.byte == 255) zs > val.word; - else val.word = val.byte; -} - -/* - * Read length of string + the string with the '>' operator. - */ -inline izstream& operator>(izstream& zs, char* x) { - zstringlen len(zs); - ::gzread(zs.fp(), x, len.value()); - x[len.value()] = '\0'; - return zs; -} - -inline char* read_string(izstream& zs) { - zstringlen len(zs); - char* x = new char[len.value()+1]; - ::gzread(zs.fp(), x, len.value()); - x[len.value()] = '\0'; - return x; -} - -// ----------------------------- ozstream ----------------------------- - -class ozstream -{ - public: - ozstream() : m_fp(0), m_os(0) { - } - ozstream(FILE* fp, int level = Z_DEFAULT_COMPRESSION) - : m_fp(0), m_os(0) { - open(fp, level); - } - ozstream(const char* name, int level = Z_DEFAULT_COMPRESSION) - : m_fp(0), m_os(0) { - open(name, level); - } - ~ozstream() { - close(); - } - - /* Opens a gzip (.gz) file for writing. - * The compression level parameter should be in 0..9 - * errno can be checked to distinguish two error cases - * (if errno is zero, the zlib error is Z_MEM_ERROR). - */ - void open(const char* name, int level = Z_DEFAULT_COMPRESSION) { - char mode[4] = "wb\0"; - if (level != Z_DEFAULT_COMPRESSION) mode[2] = '0'+level; - if (m_fp) close(); - m_fp = ::gzopen(name, mode); - } - - /* open from a FILE pointer. - */ - void open(FILE* fp, int level = Z_DEFAULT_COMPRESSION) { - SET_BINARY_MODE(fp); - char mode[4] = "wb\0"; - if (level != Z_DEFAULT_COMPRESSION) mode[2] = '0'+level; - if (m_fp) close(); - m_fp = ::gzdopen(fileno(fp), mode); - } - - /* Flushes all pending output if necessary, closes the compressed file - * and deallocates all the (de)compression state. The return value is - * the zlib error number (see function error() below). - */ - int close() { - if (m_os) { - ::gzwrite(m_fp, m_os->str(), m_os->pcount()); - delete[] m_os->str(); delete m_os; m_os = 0; - } - int r = ::gzclose(m_fp); m_fp = 0; return r; - } - - /* Binary write the given number of bytes into the compressed file. - */ - int write(const void* buf, size_t len) { - return ::gzwrite(m_fp, (voidp) buf, len); - } - - /* Flushes all pending output into the compressed file. The parameter - * _flush is as in the deflate() function. The return value is the zlib - * error number (see function gzerror below). flush() returns Z_OK if - * the flush_ parameter is Z_FINISH and all output could be flushed. - * flush() should be called only when strictly necessary because it can - * degrade compression. - */ - int flush(int _flush) { - os_flush(); - return ::gzflush(m_fp, _flush); - } - - /* Returns the error message for the last error which occurred on the - * given compressed file. errnum is set to zlib error number. If an - * error occurred in the file system and not in the compression library, - * errnum is set to Z_ERRNO and the application may consult errno - * to get the exact error code. - */ - const char* error(int* errnum) { - return ::gzerror(m_fp, errnum); - } - - gzFile fp() { return m_fp; } - - ostream& os() { - if (m_os == 0) m_os = new ostrstream; - return *m_os; - } - - void os_flush() { - if (m_os && m_os->pcount()>0) { - ostrstream* oss = new ostrstream; - oss->fill(m_os->fill()); - oss->flags(m_os->flags()); - oss->precision(m_os->precision()); - oss->width(m_os->width()); - ::gzwrite(m_fp, m_os->str(), m_os->pcount()); - delete[] m_os->str(); delete m_os; m_os = oss; - } - } - - private: - gzFile m_fp; - ostrstream* m_os; -}; - -/* - * Binary write the given (array of) object(s) into the compressed file. - * returns the number of uncompressed bytes actually written - * (0 in case of error). - */ -template -inline int write(ozstream& zs, const T* x, Items items) { - return ::gzwrite(zs.fp(), (voidp) x, items*sizeof(T)); -} - -/* - * Binary output with the '<' operator. - */ -template -inline ozstream& operator<(ozstream& zs, const T& x) { - ::gzwrite(zs.fp(), (voidp) &x, sizeof(T)); - return zs; -} - -inline zstringlen::zstringlen(ozstream& zs, const char* x) { - val.byte = 255; val.word = ::strlen(x); - if (val.word < 255) zs < (val.byte = val.word); - else zs < val; -} - -/* - * Write length of string + the string with the '<' operator. - */ -inline ozstream& operator<(ozstream& zs, const char* x) { - zstringlen len(zs, x); - ::gzwrite(zs.fp(), (voidp) x, len.value()); - return zs; -} - -#ifdef _MSC_VER -inline ozstream& operator<(ozstream& zs, char* const& x) { - return zs < (const char*) x; -} -#endif - -/* - * Ascii write with the << operator; - */ -template -inline ostream& operator<<(ozstream& zs, const T& x) { - zs.os_flush(); - return zs.os() << x; -} - -#endif diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/iostream2/zstream_test.cpp b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/iostream2/zstream_test.cpp deleted file mode 100644 index 6273f62..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/iostream2/zstream_test.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "zstream.h" -#include -#include -#include - -void main() { - char h[256] = "Hello"; - char* g = "Goodbye"; - ozstream out("temp.gz"); - out < "This works well" < h < g; - out.close(); - - izstream in("temp.gz"); // read it back - char *x = read_string(in), *y = new char[256], z[256]; - in > y > z; - in.close(); - cout << x << endl << y << endl << z << endl; - - out.open("temp.gz"); // try ascii output; zcat temp.gz to see the results - out << setw(50) << setfill('#') << setprecision(20) << x << endl << y << endl << z << endl; - out << z << endl << y << endl << x << endl; - out << 1.1234567890123456789 << endl; - - delete[] x; delete[] y; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/iostream3/README b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/iostream3/README deleted file mode 100644 index f7b319a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/iostream3/README +++ /dev/null @@ -1,35 +0,0 @@ -These classes provide a C++ stream interface to the zlib library. It allows you -to do things like: - - gzofstream outf("blah.gz"); - outf << "These go into the gzip file " << 123 << endl; - -It does this by deriving a specialized stream buffer for gzipped files, which is -the way Stroustrup would have done it. :-> - -The gzifstream and gzofstream classes were originally written by Kevin Ruland -and made available in the zlib contrib/iostream directory. The older version still -compiles under gcc 2.xx, but not under gcc 3.xx, which sparked the development of -this version. - -The new classes are as standard-compliant as possible, closely following the -approach of the standard library's fstream classes. It compiles under gcc versions -3.2 and 3.3, but not under gcc 2.xx. This is mainly due to changes in the standard -library naming scheme. The new version of gzifstream/gzofstream/gzfilebuf differs -from the previous one in the following respects: -- added showmanyc -- added setbuf, with support for unbuffered output via setbuf(0,0) -- a few bug fixes of stream behavior -- gzipped output file opened with default compression level instead of maximum level -- setcompressionlevel()/strategy() members replaced by single setcompression() - -The code is provided "as is", with the permission to use, copy, modify, distribute -and sell it for any purpose without fee. - -Ludwig Schwardt - - -DSP Lab -Electrical & Electronic Engineering Department -University of Stellenbosch -South Africa diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/iostream3/TODO b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/iostream3/TODO deleted file mode 100644 index 7032f97..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/iostream3/TODO +++ /dev/null @@ -1,17 +0,0 @@ -Possible upgrades to gzfilebuf: - -- The ability to do putback (e.g. putbackfail) - -- The ability to seek (zlib supports this, but could be slow/tricky) - -- Simultaneous read/write access (does it make sense?) - -- Support for ios_base::ate open mode - -- Locale support? - -- Check public interface to see which calls give problems - (due to dependence on library internals) - -- Override operator<<(ostream&, gzfilebuf*) to allow direct copying - of stream buffer to stream ( i.e. os << is.rdbuf(); ) diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/iostream3/test.cc b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/iostream3/test.cc deleted file mode 100644 index 9423533..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/iostream3/test.cc +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Test program for gzifstream and gzofstream - * - * by Ludwig Schwardt - * original version by Kevin Ruland - */ - -#include "zfstream.h" -#include // for cout - -int main() { - - gzofstream outf; - gzifstream inf; - char buf[80]; - - outf.open("test1.txt.gz"); - outf << "The quick brown fox sidestepped the lazy canine\n" - << 1.3 << "\nPlan " << 9 << std::endl; - outf.close(); - std::cout << "Wrote the following message to 'test1.txt.gz' (check with zcat or zless):\n" - << "The quick brown fox sidestepped the lazy canine\n" - << 1.3 << "\nPlan " << 9 << std::endl; - - std::cout << "\nReading 'test1.txt.gz' (buffered) produces:\n"; - inf.open("test1.txt.gz"); - while (inf.getline(buf,80,'\n')) { - std::cout << buf << "\t(" << inf.rdbuf()->in_avail() << " chars left in buffer)\n"; - } - inf.close(); - - outf.rdbuf()->pubsetbuf(0,0); - outf.open("test2.txt.gz"); - outf << setcompression(Z_NO_COMPRESSION) - << "The quick brown fox sidestepped the lazy canine\n" - << 1.3 << "\nPlan " << 9 << std::endl; - outf.close(); - std::cout << "\nWrote the same message to 'test2.txt.gz' in uncompressed form"; - - std::cout << "\nReading 'test2.txt.gz' (unbuffered) produces:\n"; - inf.rdbuf()->pubsetbuf(0,0); - inf.open("test2.txt.gz"); - while (inf.getline(buf,80,'\n')) { - std::cout << buf << "\t(" << inf.rdbuf()->in_avail() << " chars left in buffer)\n"; - } - inf.close(); - - return 0; - -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/iostream3/zfstream.cc b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/iostream3/zfstream.cc deleted file mode 100644 index 94eb933..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/iostream3/zfstream.cc +++ /dev/null @@ -1,479 +0,0 @@ -/* - * A C++ I/O streams interface to the zlib gz* functions - * - * by Ludwig Schwardt - * original version by Kevin Ruland - * - * This version is standard-compliant and compatible with gcc 3.x. - */ - -#include "zfstream.h" -#include // for strcpy, strcat, strlen (mode strings) -#include // for BUFSIZ - -// Internal buffer sizes (default and "unbuffered" versions) -#define BIGBUFSIZE BUFSIZ -#define SMALLBUFSIZE 1 - -/*****************************************************************************/ - -// Default constructor -gzfilebuf::gzfilebuf() -: file(NULL), io_mode(std::ios_base::openmode(0)), own_fd(false), - buffer(NULL), buffer_size(BIGBUFSIZE), own_buffer(true) -{ - // No buffers to start with - this->disable_buffer(); -} - -// Destructor -gzfilebuf::~gzfilebuf() -{ - // Sync output buffer and close only if responsible for file - // (i.e. attached streams should be left open at this stage) - this->sync(); - if (own_fd) - this->close(); - // Make sure internal buffer is deallocated - this->disable_buffer(); -} - -// Set compression level and strategy -int -gzfilebuf::setcompression(int comp_level, - int comp_strategy) -{ - return gzsetparams(file, comp_level, comp_strategy); -} - -// Open gzipped file -gzfilebuf* -gzfilebuf::open(const char *name, - std::ios_base::openmode mode) -{ - // Fail if file already open - if (this->is_open()) - return NULL; - // Don't support simultaneous read/write access (yet) - if ((mode & std::ios_base::in) && (mode & std::ios_base::out)) - return NULL; - - // Build mode string for gzopen and check it [27.8.1.3.2] - char char_mode[6] = "\0\0\0\0\0"; - if (!this->open_mode(mode, char_mode)) - return NULL; - - // Attempt to open file - if ((file = gzopen(name, char_mode)) == NULL) - return NULL; - - // On success, allocate internal buffer and set flags - this->enable_buffer(); - io_mode = mode; - own_fd = true; - return this; -} - -// Attach to gzipped file -gzfilebuf* -gzfilebuf::attach(int fd, - std::ios_base::openmode mode) -{ - // Fail if file already open - if (this->is_open()) - return NULL; - // Don't support simultaneous read/write access (yet) - if ((mode & std::ios_base::in) && (mode & std::ios_base::out)) - return NULL; - - // Build mode string for gzdopen and check it [27.8.1.3.2] - char char_mode[6] = "\0\0\0\0\0"; - if (!this->open_mode(mode, char_mode)) - return NULL; - - // Attempt to attach to file - if ((file = gzdopen(fd, char_mode)) == NULL) - return NULL; - - // On success, allocate internal buffer and set flags - this->enable_buffer(); - io_mode = mode; - own_fd = false; - return this; -} - -// Close gzipped file -gzfilebuf* -gzfilebuf::close() -{ - // Fail immediately if no file is open - if (!this->is_open()) - return NULL; - // Assume success - gzfilebuf* retval = this; - // Attempt to sync and close gzipped file - if (this->sync() == -1) - retval = NULL; - if (gzclose(file) < 0) - retval = NULL; - // File is now gone anyway (postcondition [27.8.1.3.8]) - file = NULL; - own_fd = false; - // Destroy internal buffer if it exists - this->disable_buffer(); - return retval; -} - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -// Convert int open mode to mode string -bool -gzfilebuf::open_mode(std::ios_base::openmode mode, - char* c_mode) const -{ - bool testb = mode & std::ios_base::binary; - bool testi = mode & std::ios_base::in; - bool testo = mode & std::ios_base::out; - bool testt = mode & std::ios_base::trunc; - bool testa = mode & std::ios_base::app; - - // Check for valid flag combinations - see [27.8.1.3.2] (Table 92) - // Original zfstream hardcoded the compression level to maximum here... - // Double the time for less than 1% size improvement seems - // excessive though - keeping it at the default level - // To change back, just append "9" to the next three mode strings - if (!testi && testo && !testt && !testa) - strcpy(c_mode, "w"); - if (!testi && testo && !testt && testa) - strcpy(c_mode, "a"); - if (!testi && testo && testt && !testa) - strcpy(c_mode, "w"); - if (testi && !testo && !testt && !testa) - strcpy(c_mode, "r"); - // No read/write mode yet -// if (testi && testo && !testt && !testa) -// strcpy(c_mode, "r+"); -// if (testi && testo && testt && !testa) -// strcpy(c_mode, "w+"); - - // Mode string should be empty for invalid combination of flags - if (strlen(c_mode) == 0) - return false; - if (testb) - strcat(c_mode, "b"); - return true; -} - -// Determine number of characters in internal get buffer -std::streamsize -gzfilebuf::showmanyc() -{ - // Calls to underflow will fail if file not opened for reading - if (!this->is_open() || !(io_mode & std::ios_base::in)) - return -1; - // Make sure get area is in use - if (this->gptr() && (this->gptr() < this->egptr())) - return std::streamsize(this->egptr() - this->gptr()); - else - return 0; -} - -// Fill get area from gzipped file -gzfilebuf::int_type -gzfilebuf::underflow() -{ - // If something is left in the get area by chance, return it - // (this shouldn't normally happen, as underflow is only supposed - // to be called when gptr >= egptr, but it serves as error check) - if (this->gptr() && (this->gptr() < this->egptr())) - return traits_type::to_int_type(*(this->gptr())); - - // If the file hasn't been opened for reading, produce error - if (!this->is_open() || !(io_mode & std::ios_base::in)) - return traits_type::eof(); - - // Attempt to fill internal buffer from gzipped file - // (buffer must be guaranteed to exist...) - int bytes_read = gzread(file, buffer, buffer_size); - // Indicates error or EOF - if (bytes_read <= 0) - { - // Reset get area - this->setg(buffer, buffer, buffer); - return traits_type::eof(); - } - // Make all bytes read from file available as get area - this->setg(buffer, buffer, buffer + bytes_read); - - // Return next character in get area - return traits_type::to_int_type(*(this->gptr())); -} - -// Write put area to gzipped file -gzfilebuf::int_type -gzfilebuf::overflow(int_type c) -{ - // Determine whether put area is in use - if (this->pbase()) - { - // Double-check pointer range - if (this->pptr() > this->epptr() || this->pptr() < this->pbase()) - return traits_type::eof(); - // Add extra character to buffer if not EOF - if (!traits_type::eq_int_type(c, traits_type::eof())) - { - *(this->pptr()) = traits_type::to_char_type(c); - this->pbump(1); - } - // Number of characters to write to file - int bytes_to_write = this->pptr() - this->pbase(); - // Overflow doesn't fail if nothing is to be written - if (bytes_to_write > 0) - { - // If the file hasn't been opened for writing, produce error - if (!this->is_open() || !(io_mode & std::ios_base::out)) - return traits_type::eof(); - // If gzipped file won't accept all bytes written to it, fail - if (gzwrite(file, this->pbase(), bytes_to_write) != bytes_to_write) - return traits_type::eof(); - // Reset next pointer to point to pbase on success - this->pbump(-bytes_to_write); - } - } - // Write extra character to file if not EOF - else if (!traits_type::eq_int_type(c, traits_type::eof())) - { - // If the file hasn't been opened for writing, produce error - if (!this->is_open() || !(io_mode & std::ios_base::out)) - return traits_type::eof(); - // Impromptu char buffer (allows "unbuffered" output) - char_type last_char = traits_type::to_char_type(c); - // If gzipped file won't accept this character, fail - if (gzwrite(file, &last_char, 1) != 1) - return traits_type::eof(); - } - - // If you got here, you have succeeded (even if c was EOF) - // The return value should therefore be non-EOF - if (traits_type::eq_int_type(c, traits_type::eof())) - return traits_type::not_eof(c); - else - return c; -} - -// Assign new buffer -std::streambuf* -gzfilebuf::setbuf(char_type* p, - std::streamsize n) -{ - // First make sure stuff is sync'ed, for safety - if (this->sync() == -1) - return NULL; - // If buffering is turned off on purpose via setbuf(0,0), still allocate one... - // "Unbuffered" only really refers to put [27.8.1.4.10], while get needs at - // least a buffer of size 1 (very inefficient though, therefore make it bigger?) - // This follows from [27.5.2.4.3]/12 (gptr needs to point at something, it seems) - if (!p || !n) - { - // Replace existing buffer (if any) with small internal buffer - this->disable_buffer(); - buffer = NULL; - buffer_size = 0; - own_buffer = true; - this->enable_buffer(); - } - else - { - // Replace existing buffer (if any) with external buffer - this->disable_buffer(); - buffer = p; - buffer_size = n; - own_buffer = false; - this->enable_buffer(); - } - return this; -} - -// Write put area to gzipped file (i.e. ensures that put area is empty) -int -gzfilebuf::sync() -{ - return traits_type::eq_int_type(this->overflow(), traits_type::eof()) ? -1 : 0; -} - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -// Allocate internal buffer -void -gzfilebuf::enable_buffer() -{ - // If internal buffer required, allocate one - if (own_buffer && !buffer) - { - // Check for buffered vs. "unbuffered" - if (buffer_size > 0) - { - // Allocate internal buffer - buffer = new char_type[buffer_size]; - // Get area starts empty and will be expanded by underflow as need arises - this->setg(buffer, buffer, buffer); - // Setup entire internal buffer as put area. - // The one-past-end pointer actually points to the last element of the buffer, - // so that overflow(c) can safely add the extra character c to the sequence. - // These pointers remain in place for the duration of the buffer - this->setp(buffer, buffer + buffer_size - 1); - } - else - { - // Even in "unbuffered" case, (small?) get buffer is still required - buffer_size = SMALLBUFSIZE; - buffer = new char_type[buffer_size]; - this->setg(buffer, buffer, buffer); - // "Unbuffered" means no put buffer - this->setp(0, 0); - } - } - else - { - // If buffer already allocated, reset buffer pointers just to make sure no - // stale chars are lying around - this->setg(buffer, buffer, buffer); - this->setp(buffer, buffer + buffer_size - 1); - } -} - -// Destroy internal buffer -void -gzfilebuf::disable_buffer() -{ - // If internal buffer exists, deallocate it - if (own_buffer && buffer) - { - // Preserve unbuffered status by zeroing size - if (!this->pbase()) - buffer_size = 0; - delete[] buffer; - buffer = NULL; - this->setg(0, 0, 0); - this->setp(0, 0); - } - else - { - // Reset buffer pointers to initial state if external buffer exists - this->setg(buffer, buffer, buffer); - if (buffer) - this->setp(buffer, buffer + buffer_size - 1); - else - this->setp(0, 0); - } -} - -/*****************************************************************************/ - -// Default constructor initializes stream buffer -gzifstream::gzifstream() -: std::istream(NULL), sb() -{ this->init(&sb); } - -// Initialize stream buffer and open file -gzifstream::gzifstream(const char* name, - std::ios_base::openmode mode) -: std::istream(NULL), sb() -{ - this->init(&sb); - this->open(name, mode); -} - -// Initialize stream buffer and attach to file -gzifstream::gzifstream(int fd, - std::ios_base::openmode mode) -: std::istream(NULL), sb() -{ - this->init(&sb); - this->attach(fd, mode); -} - -// Open file and go into fail() state if unsuccessful -void -gzifstream::open(const char* name, - std::ios_base::openmode mode) -{ - if (!sb.open(name, mode | std::ios_base::in)) - this->setstate(std::ios_base::failbit); - else - this->clear(); -} - -// Attach to file and go into fail() state if unsuccessful -void -gzifstream::attach(int fd, - std::ios_base::openmode mode) -{ - if (!sb.attach(fd, mode | std::ios_base::in)) - this->setstate(std::ios_base::failbit); - else - this->clear(); -} - -// Close file -void -gzifstream::close() -{ - if (!sb.close()) - this->setstate(std::ios_base::failbit); -} - -/*****************************************************************************/ - -// Default constructor initializes stream buffer -gzofstream::gzofstream() -: std::ostream(NULL), sb() -{ this->init(&sb); } - -// Initialize stream buffer and open file -gzofstream::gzofstream(const char* name, - std::ios_base::openmode mode) -: std::ostream(NULL), sb() -{ - this->init(&sb); - this->open(name, mode); -} - -// Initialize stream buffer and attach to file -gzofstream::gzofstream(int fd, - std::ios_base::openmode mode) -: std::ostream(NULL), sb() -{ - this->init(&sb); - this->attach(fd, mode); -} - -// Open file and go into fail() state if unsuccessful -void -gzofstream::open(const char* name, - std::ios_base::openmode mode) -{ - if (!sb.open(name, mode | std::ios_base::out)) - this->setstate(std::ios_base::failbit); - else - this->clear(); -} - -// Attach to file and go into fail() state if unsuccessful -void -gzofstream::attach(int fd, - std::ios_base::openmode mode) -{ - if (!sb.attach(fd, mode | std::ios_base::out)) - this->setstate(std::ios_base::failbit); - else - this->clear(); -} - -// Close file -void -gzofstream::close() -{ - if (!sb.close()) - this->setstate(std::ios_base::failbit); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/iostream3/zfstream.h b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/iostream3/zfstream.h deleted file mode 100644 index 8574479..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/iostream3/zfstream.h +++ /dev/null @@ -1,466 +0,0 @@ -/* - * A C++ I/O streams interface to the zlib gz* functions - * - * by Ludwig Schwardt - * original version by Kevin Ruland - * - * This version is standard-compliant and compatible with gcc 3.x. - */ - -#ifndef ZFSTREAM_H -#define ZFSTREAM_H - -#include // not iostream, since we don't need cin/cout -#include -#include "zlib.h" - -/*****************************************************************************/ - -/** - * @brief Gzipped file stream buffer class. - * - * This class implements basic_filebuf for gzipped files. It doesn't yet support - * seeking (allowed by zlib but slow/limited), putback and read/write access - * (tricky). Otherwise, it attempts to be a drop-in replacement for the standard - * file streambuf. -*/ -class gzfilebuf : public std::streambuf -{ -public: - // Default constructor. - gzfilebuf(); - - // Destructor. - virtual - ~gzfilebuf(); - - /** - * @brief Set compression level and strategy on the fly. - * @param comp_level Compression level (see zlib.h for allowed values) - * @param comp_strategy Compression strategy (see zlib.h for allowed values) - * @return Z_OK on success, Z_STREAM_ERROR otherwise. - * - * Unfortunately, these parameters cannot be modified separately, as the - * previous zfstream version assumed. Since the strategy is seldom changed, - * it can default and setcompression(level) then becomes like the old - * setcompressionlevel(level). - */ - int - setcompression(int comp_level, - int comp_strategy = Z_DEFAULT_STRATEGY); - - /** - * @brief Check if file is open. - * @return True if file is open. - */ - bool - is_open() const { return (file != NULL); } - - /** - * @brief Open gzipped file. - * @param name File name. - * @param mode Open mode flags. - * @return @c this on success, NULL on failure. - */ - gzfilebuf* - open(const char* name, - std::ios_base::openmode mode); - - /** - * @brief Attach to already open gzipped file. - * @param fd File descriptor. - * @param mode Open mode flags. - * @return @c this on success, NULL on failure. - */ - gzfilebuf* - attach(int fd, - std::ios_base::openmode mode); - - /** - * @brief Close gzipped file. - * @return @c this on success, NULL on failure. - */ - gzfilebuf* - close(); - -protected: - /** - * @brief Convert ios open mode int to mode string used by zlib. - * @return True if valid mode flag combination. - */ - bool - open_mode(std::ios_base::openmode mode, - char* c_mode) const; - - /** - * @brief Number of characters available in stream buffer. - * @return Number of characters. - * - * This indicates number of characters in get area of stream buffer. - * These characters can be read without accessing the gzipped file. - */ - virtual std::streamsize - showmanyc(); - - /** - * @brief Fill get area from gzipped file. - * @return First character in get area on success, EOF on error. - * - * This actually reads characters from gzipped file to stream - * buffer. Always buffered. - */ - virtual int_type - underflow(); - - /** - * @brief Write put area to gzipped file. - * @param c Extra character to add to buffer contents. - * @return Non-EOF on success, EOF on error. - * - * This actually writes characters in stream buffer to - * gzipped file. With unbuffered output this is done one - * character at a time. - */ - virtual int_type - overflow(int_type c = traits_type::eof()); - - /** - * @brief Installs external stream buffer. - * @param p Pointer to char buffer. - * @param n Size of external buffer. - * @return @c this on success, NULL on failure. - * - * Call setbuf(0,0) to enable unbuffered output. - */ - virtual std::streambuf* - setbuf(char_type* p, - std::streamsize n); - - /** - * @brief Flush stream buffer to file. - * @return 0 on success, -1 on error. - * - * This calls underflow(EOF) to do the job. - */ - virtual int - sync(); - -// -// Some future enhancements -// -// virtual int_type uflow(); -// virtual int_type pbackfail(int_type c = traits_type::eof()); -// virtual pos_type -// seekoff(off_type off, -// std::ios_base::seekdir way, -// std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out); -// virtual pos_type -// seekpos(pos_type sp, -// std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out); - -private: - /** - * @brief Allocate internal buffer. - * - * This function is safe to call multiple times. It will ensure - * that a proper internal buffer exists if it is required. If the - * buffer already exists or is external, the buffer pointers will be - * reset to their original state. - */ - void - enable_buffer(); - - /** - * @brief Destroy internal buffer. - * - * This function is safe to call multiple times. It will ensure - * that the internal buffer is deallocated if it exists. In any - * case, it will also reset the buffer pointers. - */ - void - disable_buffer(); - - /** - * Underlying file pointer. - */ - gzFile file; - - /** - * Mode in which file was opened. - */ - std::ios_base::openmode io_mode; - - /** - * @brief True if this object owns file descriptor. - * - * This makes the class responsible for closing the file - * upon destruction. - */ - bool own_fd; - - /** - * @brief Stream buffer. - * - * For simplicity this remains allocated on the free store for the - * entire life span of the gzfilebuf object, unless replaced by setbuf. - */ - char_type* buffer; - - /** - * @brief Stream buffer size. - * - * Defaults to system default buffer size (typically 8192 bytes). - * Modified by setbuf. - */ - std::streamsize buffer_size; - - /** - * @brief True if this object owns stream buffer. - * - * This makes the class responsible for deleting the buffer - * upon destruction. - */ - bool own_buffer; -}; - -/*****************************************************************************/ - -/** - * @brief Gzipped file input stream class. - * - * This class implements ifstream for gzipped files. Seeking and putback - * is not supported yet. -*/ -class gzifstream : public std::istream -{ -public: - // Default constructor - gzifstream(); - - /** - * @brief Construct stream on gzipped file to be opened. - * @param name File name. - * @param mode Open mode flags (forced to contain ios::in). - */ - explicit - gzifstream(const char* name, - std::ios_base::openmode mode = std::ios_base::in); - - /** - * @brief Construct stream on already open gzipped file. - * @param fd File descriptor. - * @param mode Open mode flags (forced to contain ios::in). - */ - explicit - gzifstream(int fd, - std::ios_base::openmode mode = std::ios_base::in); - - /** - * Obtain underlying stream buffer. - */ - gzfilebuf* - rdbuf() const - { return const_cast(&sb); } - - /** - * @brief Check if file is open. - * @return True if file is open. - */ - bool - is_open() { return sb.is_open(); } - - /** - * @brief Open gzipped file. - * @param name File name. - * @param mode Open mode flags (forced to contain ios::in). - * - * Stream will be in state good() if file opens successfully; - * otherwise in state fail(). This differs from the behavior of - * ifstream, which never sets the state to good() and therefore - * won't allow you to reuse the stream for a second file unless - * you manually clear() the state. The choice is a matter of - * convenience. - */ - void - open(const char* name, - std::ios_base::openmode mode = std::ios_base::in); - - /** - * @brief Attach to already open gzipped file. - * @param fd File descriptor. - * @param mode Open mode flags (forced to contain ios::in). - * - * Stream will be in state good() if attach succeeded; otherwise - * in state fail(). - */ - void - attach(int fd, - std::ios_base::openmode mode = std::ios_base::in); - - /** - * @brief Close gzipped file. - * - * Stream will be in state fail() if close failed. - */ - void - close(); - -private: - /** - * Underlying stream buffer. - */ - gzfilebuf sb; -}; - -/*****************************************************************************/ - -/** - * @brief Gzipped file output stream class. - * - * This class implements ofstream for gzipped files. Seeking and putback - * is not supported yet. -*/ -class gzofstream : public std::ostream -{ -public: - // Default constructor - gzofstream(); - - /** - * @brief Construct stream on gzipped file to be opened. - * @param name File name. - * @param mode Open mode flags (forced to contain ios::out). - */ - explicit - gzofstream(const char* name, - std::ios_base::openmode mode = std::ios_base::out); - - /** - * @brief Construct stream on already open gzipped file. - * @param fd File descriptor. - * @param mode Open mode flags (forced to contain ios::out). - */ - explicit - gzofstream(int fd, - std::ios_base::openmode mode = std::ios_base::out); - - /** - * Obtain underlying stream buffer. - */ - gzfilebuf* - rdbuf() const - { return const_cast(&sb); } - - /** - * @brief Check if file is open. - * @return True if file is open. - */ - bool - is_open() { return sb.is_open(); } - - /** - * @brief Open gzipped file. - * @param name File name. - * @param mode Open mode flags (forced to contain ios::out). - * - * Stream will be in state good() if file opens successfully; - * otherwise in state fail(). This differs from the behavior of - * ofstream, which never sets the state to good() and therefore - * won't allow you to reuse the stream for a second file unless - * you manually clear() the state. The choice is a matter of - * convenience. - */ - void - open(const char* name, - std::ios_base::openmode mode = std::ios_base::out); - - /** - * @brief Attach to already open gzipped file. - * @param fd File descriptor. - * @param mode Open mode flags (forced to contain ios::out). - * - * Stream will be in state good() if attach succeeded; otherwise - * in state fail(). - */ - void - attach(int fd, - std::ios_base::openmode mode = std::ios_base::out); - - /** - * @brief Close gzipped file. - * - * Stream will be in state fail() if close failed. - */ - void - close(); - -private: - /** - * Underlying stream buffer. - */ - gzfilebuf sb; -}; - -/*****************************************************************************/ - -/** - * @brief Gzipped file output stream manipulator class. - * - * This class defines a two-argument manipulator for gzofstream. It is used - * as base for the setcompression(int,int) manipulator. -*/ -template - class gzomanip2 - { - public: - // Allows insertor to peek at internals - template - friend gzofstream& - operator<<(gzofstream&, - const gzomanip2&); - - // Constructor - gzomanip2(gzofstream& (*f)(gzofstream&, T1, T2), - T1 v1, - T2 v2); - private: - // Underlying manipulator function - gzofstream& - (*func)(gzofstream&, T1, T2); - - // Arguments for manipulator function - T1 val1; - T2 val2; - }; - -/*****************************************************************************/ - -// Manipulator function thunks through to stream buffer -inline gzofstream& -setcompression(gzofstream &gzs, int l, int s = Z_DEFAULT_STRATEGY) -{ - (gzs.rdbuf())->setcompression(l, s); - return gzs; -} - -// Manipulator constructor stores arguments -template - inline - gzomanip2::gzomanip2(gzofstream &(*f)(gzofstream &, T1, T2), - T1 v1, - T2 v2) - : func(f), val1(v1), val2(v2) - { } - -// Insertor applies underlying manipulator function to stream -template - inline gzofstream& - operator<<(gzofstream& s, const gzomanip2& m) - { return (*m.func)(s, m.val1, m.val2); } - -// Insert this onto stream to simplify setting of compression level -inline gzomanip2 -setcompression(int l, int s = Z_DEFAULT_STRATEGY) -{ return gzomanip2(&setcompression, l, s); } - -#endif // ZFSTREAM_H diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/Makefile b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/Makefile deleted file mode 100644 index aac76e0..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -CC=cc -CFLAGS := $(CFLAGS) -O -I../.. - -UNZ_OBJS = miniunz.o unzip.o ioapi.o ../../libz.a -ZIP_OBJS = minizip.o zip.o ioapi.o ../../libz.a - -.c.o: - $(CC) -c $(CFLAGS) $*.c - -all: miniunz minizip - -miniunz: $(UNZ_OBJS) - $(CC) $(CFLAGS) -o $@ $(UNZ_OBJS) - -minizip: $(ZIP_OBJS) - $(CC) $(CFLAGS) -o $@ $(ZIP_OBJS) - -test: miniunz minizip - @rm -f test.* - @echo hello hello hello > test.txt - ./minizip test test.txt - ./miniunz -l test.zip - @mv test.txt test.old - ./miniunz test.zip - @cmp test.txt test.old - @rm -f test.* - -clean: - /bin/rm -f *.o *~ minizip miniunz test.* diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/Makefile.am b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/Makefile.am deleted file mode 100644 index d343011..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/Makefile.am +++ /dev/null @@ -1,45 +0,0 @@ -lib_LTLIBRARIES = libminizip.la - -if COND_DEMOS -bin_PROGRAMS = miniunzip minizip -endif - -zlib_top_srcdir = $(top_srcdir)/../.. -zlib_top_builddir = $(top_builddir)/../.. - -AM_CPPFLAGS = -I$(zlib_top_srcdir) -AM_LDFLAGS = -L$(zlib_top_builddir) - -if WIN32 -iowin32_src = iowin32.c -iowin32_h = iowin32.h -endif - -libminizip_la_SOURCES = \ - ioapi.c \ - mztools.c \ - unzip.c \ - zip.c \ - ${iowin32_src} - -libminizip_la_LDFLAGS = $(AM_LDFLAGS) -version-info 1:0:0 -lz - -minizip_includedir = $(includedir)/minizip -minizip_include_HEADERS = \ - crypt.h \ - ioapi.h \ - mztools.h \ - unzip.h \ - zip.h \ - ${iowin32_h} - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = minizip.pc - -EXTRA_PROGRAMS = miniunzip minizip - -miniunzip_SOURCES = miniunz.c -miniunzip_LDADD = libminizip.la - -minizip_SOURCES = minizip.c -minizip_LDADD = libminizip.la -lz diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/MiniZip64_Changes.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/MiniZip64_Changes.txt deleted file mode 100644 index 13a1bd9..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/MiniZip64_Changes.txt +++ /dev/null @@ -1,6 +0,0 @@ - -MiniZip 1.1 was derrived from MiniZip at version 1.01f - -Change in 1.0 (Okt 2009) - - **TODO - Add history** - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/MiniZip64_info.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/MiniZip64_info.txt deleted file mode 100644 index 57d7152..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/MiniZip64_info.txt +++ /dev/null @@ -1,74 +0,0 @@ -MiniZip - Copyright (c) 1998-2010 - by Gilles Vollant - version 1.1 64 bits from Mathias Svensson - -Introduction ---------------------- -MiniZip 1.1 is built from MiniZip 1.0 by Gilles Vollant ( http://www.winimage.com/zLibDll/minizip.html ) - -When adding ZIP64 support into minizip it would result into risk of breaking compatibility with minizip 1.0. -All possible work was done for compatibility. - - -Background ---------------------- -When adding ZIP64 support Mathias Svensson found that Even Rouault have added ZIP64 -support for unzip.c into minizip for a open source project called gdal ( http://www.gdal.org/ ) - -That was used as a starting point. And after that ZIP64 support was added to zip.c -some refactoring and code cleanup was also done. - - -Changed from MiniZip 1.0 to MiniZip 1.1 ---------------------------------------- -* Added ZIP64 support for unzip ( by Even Rouault ) -* Added ZIP64 support for zip ( by Mathias Svensson ) -* Reverted some changed that Even Rouault did. -* Bunch of patches received from Gulles Vollant that he received for MiniZip from various users. -* Added unzip patch for BZIP Compression method (patch create by Daniel Borca) -* Added BZIP Compress method for zip -* Did some refactoring and code cleanup - - -Credits - - Gilles Vollant - Original MiniZip author - Even Rouault - ZIP64 unzip Support - Daniel Borca - BZip Compression method support in unzip - Mathias Svensson - ZIP64 zip support - Mathias Svensson - BZip Compression method support in zip - - Resources - - ZipLayout http://result42.com/projects/ZipFileLayout - Command line tool for Windows that shows the layout and information of the headers in a zip archive. - Used when debugging and validating the creation of zip files using MiniZip64 - - - ZIP App Note http://www.pkware.com/documents/casestudies/APPNOTE.TXT - Zip File specification - - -Notes. - * To be able to use BZip compression method in zip64.c or unzip64.c the BZIP2 lib is needed and HAVE_BZIP2 need to be defined. - -License ----------------------------------------------------------- - Condition of use and distribution are the same than zlib : - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - ----------------------------------------------------------- - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/configure.ac b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/configure.ac deleted file mode 100644 index 6409abc..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/configure.ac +++ /dev/null @@ -1,32 +0,0 @@ -# -*- Autoconf -*- -# Process this file with autoconf to produce a configure script. - -AC_INIT([minizip], [1.2.12], [bugzilla.redhat.com]) -AC_CONFIG_SRCDIR([minizip.c]) -AM_INIT_AUTOMAKE([foreign]) -LT_INIT - -AC_MSG_CHECKING([whether to build example programs]) -AC_ARG_ENABLE([demos], AC_HELP_STRING([--enable-demos], [build example programs])) -AM_CONDITIONAL([COND_DEMOS], [test "$enable_demos" = yes]) -if test "$enable_demos" = yes -then - AC_MSG_RESULT([yes]) -else - AC_MSG_RESULT([no]) -fi - -case "${host}" in - *-mingw* | mingw*) - WIN32="yes" - ;; - *) - ;; -esac -AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"]) - - -AC_SUBST([HAVE_UNISTD_H], [0]) -AC_CHECK_HEADER([unistd.h], [HAVE_UNISTD_H=1], []) -AC_CONFIG_FILES([Makefile minizip.pc]) -AC_OUTPUT diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/crypt.h b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/crypt.h deleted file mode 100644 index 9da1537..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/crypt.h +++ /dev/null @@ -1,132 +0,0 @@ -/* crypt.h -- base code for crypt/uncrypt ZIPfile - - - Version 1.01e, February 12th, 2005 - - Copyright (C) 1998-2005 Gilles Vollant - - This code is a modified version of crypting code in Infozip distribution - - The encryption/decryption parts of this source code (as opposed to the - non-echoing password parts) were originally written in Europe. The - whole source package can be freely distributed, including from the USA. - (Prior to January 2000, re-export from the US was a violation of US law.) - - This encryption code is a direct transcription of the algorithm from - Roger Schlafly, described by Phil Katz in the file appnote.txt. This - file (appnote.txt) is distributed with the PKZIP program (even in the - version without encryption capabilities). - - If you don't need crypting in your application, just define symbols - NOCRYPT and NOUNCRYPT. - - This code support the "Traditional PKWARE Encryption". - - The new AES encryption added on Zip format by Winzip (see the page - http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong - Encryption is not supported. -*/ - -#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8)) - -/*********************************************************************** - * Return the next byte in the pseudo-random sequence - */ -static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab) -{ - unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an - * unpredictable manner on 16-bit systems; not a problem - * with any known compiler so far, though */ - - (void)pcrc_32_tab; - temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2; - return (int)(((temp * (temp ^ 1)) >> 8) & 0xff); -} - -/*********************************************************************** - * Update the encryption keys with the next byte of plain text - */ -static int update_keys(unsigned long* pkeys,const z_crc_t* pcrc_32_tab,int c) -{ - (*(pkeys+0)) = CRC32((*(pkeys+0)), c); - (*(pkeys+1)) += (*(pkeys+0)) & 0xff; - (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1; - { - register int keyshift = (int)((*(pkeys+1)) >> 24); - (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift); - } - return c; -} - - -/*********************************************************************** - * Initialize the encryption keys and the random header according to - * the given password. - */ -static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t* pcrc_32_tab) -{ - *(pkeys+0) = 305419896L; - *(pkeys+1) = 591751049L; - *(pkeys+2) = 878082192L; - while (*passwd != '\0') { - update_keys(pkeys,pcrc_32_tab,(int)*passwd); - passwd++; - } -} - -#define zdecode(pkeys,pcrc_32_tab,c) \ - (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab))) - -#define zencode(pkeys,pcrc_32_tab,c,t) \ - (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), (Byte)t^(c)) - -#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED - -#define RAND_HEAD_LEN 12 - /* "last resort" source for second part of crypt seed pattern */ -# ifndef ZCR_SEED2 -# define ZCR_SEED2 3141592654L /* use PI as default pattern */ -# endif - -static unsigned crypthead(const char* passwd, /* password string */ - unsigned char* buf, /* where to write header */ - int bufSize, - unsigned long* pkeys, - const z_crc_t* pcrc_32_tab, - unsigned long crcForCrypting) -{ - unsigned n; /* index in random header */ - int t; /* temporary */ - int c; /* random byte */ - unsigned char header[RAND_HEAD_LEN-2]; /* random header */ - static unsigned calls = 0; /* ensure different random header each time */ - - if (bufSize> 7) & 0xff; - header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t); - } - /* Encrypt random header (last two bytes is high word of crc) */ - init_keys(passwd, pkeys, pcrc_32_tab); - for (n = 0; n < RAND_HEAD_LEN-2; n++) - { - buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t); - } - buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t); - buf[n++] = (unsigned char)zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t); - return n; -} - -#endif diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/ioapi.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/ioapi.c deleted file mode 100644 index d666e5a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/ioapi.c +++ /dev/null @@ -1,257 +0,0 @@ -/* ioapi.h -- IO base function header for compress/uncompress .zip - part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) - - Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) - - Modifications for Zip64 support - Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) - - For more info read MiniZip_info.txt - -*/ - -#if defined(_WIN32) && (!(defined(_CRT_SECURE_NO_WARNINGS))) - #define _CRT_SECURE_NO_WARNINGS -#endif - -#if defined(__APPLE__) || defined(IOAPI_NO_64) -// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions -#define FOPEN_FUNC(filename, mode) fopen(filename, mode) -#define FTELLO_FUNC(stream) ftello(stream) -#define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin) -#else -#define FOPEN_FUNC(filename, mode) fopen64(filename, mode) -#define FTELLO_FUNC(stream) ftello64(stream) -#define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin) -#endif - - -#include "ioapi.h" - -voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode) -{ - if (pfilefunc->zfile_func64.zopen64_file != NULL) - return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode); - else - { - return (*(pfilefunc->zopen32_file))(pfilefunc->zfile_func64.opaque,(const char*)filename,mode); - } -} - -long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin) -{ - if (pfilefunc->zfile_func64.zseek64_file != NULL) - return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin); - else - { - uLong offsetTruncated = (uLong)offset; - if (offsetTruncated != offset) - return -1; - else - return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin); - } -} - -ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream) -{ - if (pfilefunc->zfile_func64.zseek64_file != NULL) - return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream); - else - { - uLong tell_uLong = (uLong)(*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream); - if ((tell_uLong) == MAXU32) - return (ZPOS64_T)-1; - else - return tell_uLong; - } -} - -void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32) -{ - p_filefunc64_32->zfile_func64.zopen64_file = NULL; - p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file; - p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file; - p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file; - p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file; - p_filefunc64_32->zfile_func64.ztell64_file = NULL; - p_filefunc64_32->zfile_func64.zseek64_file = NULL; - p_filefunc64_32->zfile_func64.zclose_file = p_filefunc32->zclose_file; - p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file; - p_filefunc64_32->zfile_func64.opaque = p_filefunc32->opaque; - p_filefunc64_32->zseek32_file = p_filefunc32->zseek_file; - p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file; -} - - - -static voidpf ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode)); -static uLong ZCALLBACK fread_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size)); -static uLong ZCALLBACK fwrite_file_func OF((voidpf opaque, voidpf stream, const void* buf,uLong size)); -static ZPOS64_T ZCALLBACK ftell64_file_func OF((voidpf opaque, voidpf stream)); -static long ZCALLBACK fseek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); -static int ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream)); -static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream)); - -static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode) -{ - (void)opaque; - FILE* file = NULL; - const char* mode_fopen = NULL; - if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) - mode_fopen = "rb"; - else - if (mode & ZLIB_FILEFUNC_MODE_EXISTING) - mode_fopen = "r+b"; - else - if (mode & ZLIB_FILEFUNC_MODE_CREATE) - mode_fopen = "wb"; - - if ((filename!=NULL) && (mode_fopen != NULL)) - file = fopen(filename, mode_fopen); - return file; -} - -static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode) -{ - (void)opaque; - FILE* file = NULL; - const char* mode_fopen = NULL; - if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) - mode_fopen = "rb"; - else - if (mode & ZLIB_FILEFUNC_MODE_EXISTING) - mode_fopen = "r+b"; - else - if (mode & ZLIB_FILEFUNC_MODE_CREATE) - mode_fopen = "wb"; - - if ((filename!=NULL) && (mode_fopen != NULL)) - file = FOPEN_FUNC((const char*)filename, mode_fopen); - return file; -} - - -static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size) -{ - (void)opaque; - uLong ret; - ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream); - return ret; -} - -static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size) -{ - (void)opaque; - uLong ret; - ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream); - return ret; -} - -static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream) -{ - (void)opaque; - long ret; - ret = ftell((FILE *)stream); - return ret; -} - - -static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream) -{ - (void)opaque; - ZPOS64_T ret; - ret = (ZPOS64_T)FTELLO_FUNC((FILE *)stream); - return ret; -} - -static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin) -{ - (void)opaque; - int fseek_origin=0; - long ret; - switch (origin) - { - case ZLIB_FILEFUNC_SEEK_CUR : - fseek_origin = SEEK_CUR; - break; - case ZLIB_FILEFUNC_SEEK_END : - fseek_origin = SEEK_END; - break; - case ZLIB_FILEFUNC_SEEK_SET : - fseek_origin = SEEK_SET; - break; - default: return -1; - } - ret = 0; - if (fseek((FILE *)stream, (long)offset, fseek_origin) != 0) - ret = -1; - return ret; -} - -static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) -{ - (void)opaque; - int fseek_origin=0; - long ret; - switch (origin) - { - case ZLIB_FILEFUNC_SEEK_CUR : - fseek_origin = SEEK_CUR; - break; - case ZLIB_FILEFUNC_SEEK_END : - fseek_origin = SEEK_END; - break; - case ZLIB_FILEFUNC_SEEK_SET : - fseek_origin = SEEK_SET; - break; - default: return -1; - } - ret = 0; - - if(FSEEKO_FUNC((FILE *)stream, (long)offset, fseek_origin) != 0) - ret = -1; - - return ret; -} - - -static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream) -{ - (void)opaque; - int ret; - ret = fclose((FILE *)stream); - return ret; -} - -static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream) -{ - (void)opaque; - int ret; - ret = ferror((FILE *)stream); - return ret; -} - -void fill_fopen_filefunc (pzlib_filefunc_def) - zlib_filefunc_def* pzlib_filefunc_def; -{ - pzlib_filefunc_def->zopen_file = fopen_file_func; - pzlib_filefunc_def->zread_file = fread_file_func; - pzlib_filefunc_def->zwrite_file = fwrite_file_func; - pzlib_filefunc_def->ztell_file = ftell_file_func; - pzlib_filefunc_def->zseek_file = fseek_file_func; - pzlib_filefunc_def->zclose_file = fclose_file_func; - pzlib_filefunc_def->zerror_file = ferror_file_func; - pzlib_filefunc_def->opaque = NULL; -} - -void fill_fopen64_filefunc (zlib_filefunc64_def* pzlib_filefunc_def) -{ - pzlib_filefunc_def->zopen64_file = fopen64_file_func; - pzlib_filefunc_def->zread_file = fread_file_func; - pzlib_filefunc_def->zwrite_file = fwrite_file_func; - pzlib_filefunc_def->ztell64_file = ftell64_file_func; - pzlib_filefunc_def->zseek64_file = fseek64_file_func; - pzlib_filefunc_def->zclose_file = fclose_file_func; - pzlib_filefunc_def->zerror_file = ferror_file_func; - pzlib_filefunc_def->opaque = NULL; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/ioapi.h b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/ioapi.h deleted file mode 100644 index 114bfab..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/ioapi.h +++ /dev/null @@ -1,210 +0,0 @@ -/* ioapi.h -- IO base function header for compress/uncompress .zip - part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) - - Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) - - Modifications for Zip64 support - Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) - - For more info read MiniZip_info.txt - - Changes - - Oct-2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux. (might need to find a better why for this) - Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux. - More if/def section may be needed to support other platforms - Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows. - (but you should use iowin32.c for windows instead) - -*/ - -#ifndef _ZLIBIOAPI64_H -#define _ZLIBIOAPI64_H - -#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) - - // Linux needs this to support file operation on files larger then 4+GB - // But might need better if/def to select just the platforms that needs them. - - #ifndef __USE_FILE_OFFSET64 - #define __USE_FILE_OFFSET64 - #endif - #ifndef __USE_LARGEFILE64 - #define __USE_LARGEFILE64 - #endif - #ifndef _LARGEFILE64_SOURCE - #define _LARGEFILE64_SOURCE - #endif - #ifndef _FILE_OFFSET_BIT - #define _FILE_OFFSET_BIT 64 - #endif - -#endif - -#include -#include -#include "zlib.h" - -#if defined(USE_FILE32API) -#define fopen64 fopen -#define ftello64 ftell -#define fseeko64 fseek -#else -#ifdef __FreeBSD__ -#define fopen64 fopen -#define ftello64 ftello -#define fseeko64 fseeko -#endif -#ifdef _MSC_VER - #define fopen64 fopen - #if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC))) - #define ftello64 _ftelli64 - #define fseeko64 _fseeki64 - #else // old MSC - #define ftello64 ftell - #define fseeko64 fseek - #endif -#endif -#endif - -/* -#ifndef ZPOS64_T - #ifdef _WIN32 - #define ZPOS64_T fpos_t - #else - #include - #define ZPOS64_T uint64_t - #endif -#endif -*/ - -#ifdef HAVE_MINIZIP64_CONF_H -#include "mz64conf.h" -#endif - -/* a type choosen by DEFINE */ -#ifdef HAVE_64BIT_INT_CUSTOM -typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T; -#else -#ifdef HAS_STDINT_H -#include "stdint.h" -typedef uint64_t ZPOS64_T; -#else - - - -#if defined(_MSC_VER) || defined(__BORLANDC__) -typedef unsigned __int64 ZPOS64_T; -#else -typedef unsigned long long int ZPOS64_T; -#endif -#endif -#endif - -/* Maximum unsigned 32-bit value used as placeholder for zip64 */ -#ifndef MAXU32 -#define MAXU32 (0xffffffff) -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -#define ZLIB_FILEFUNC_SEEK_CUR (1) -#define ZLIB_FILEFUNC_SEEK_END (2) -#define ZLIB_FILEFUNC_SEEK_SET (0) - -#define ZLIB_FILEFUNC_MODE_READ (1) -#define ZLIB_FILEFUNC_MODE_WRITE (2) -#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) - -#define ZLIB_FILEFUNC_MODE_EXISTING (4) -#define ZLIB_FILEFUNC_MODE_CREATE (8) - - -#ifndef ZCALLBACK - #if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) - #define ZCALLBACK CALLBACK - #else - #define ZCALLBACK - #endif -#endif - - - - -typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); -typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); -typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); -typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); -typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); - -typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); -typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); - - -/* here is the "old" 32 bits structure structure */ -typedef struct zlib_filefunc_def_s -{ - open_file_func zopen_file; - read_file_func zread_file; - write_file_func zwrite_file; - tell_file_func ztell_file; - seek_file_func zseek_file; - close_file_func zclose_file; - testerror_file_func zerror_file; - voidpf opaque; -} zlib_filefunc_def; - -typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream)); -typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); -typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void* filename, int mode)); - -typedef struct zlib_filefunc64_def_s -{ - open64_file_func zopen64_file; - read_file_func zread_file; - write_file_func zwrite_file; - tell64_file_func ztell64_file; - seek64_file_func zseek64_file; - close_file_func zclose_file; - testerror_file_func zerror_file; - voidpf opaque; -} zlib_filefunc64_def; - -void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def)); -void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); - -/* now internal definition, only for zip.c and unzip.h */ -typedef struct zlib_filefunc64_32_def_s -{ - zlib_filefunc64_def zfile_func64; - open_file_func zopen32_file; - tell_file_func ztell32_file; - seek_file_func zseek32_file; -} zlib_filefunc64_32_def; - - -#define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) -#define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) -//#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream)) -//#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode)) -#define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream)) -#define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream)) - -voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)); -long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)); -ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)); - -void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32); - -#define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode))) -#define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream))) -#define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(filestream),(pos),(mode))) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/iowin32.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/iowin32.c deleted file mode 100644 index 274f39e..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/iowin32.c +++ /dev/null @@ -1,462 +0,0 @@ -/* iowin32.c -- IO base function header for compress/uncompress .zip - Version 1.1, February 14h, 2010 - part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) - - Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) - - Modifications for Zip64 support - Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) - - For more info read MiniZip_info.txt - -*/ - -#include - -#include "zlib.h" -#include "ioapi.h" -#include "iowin32.h" - -#ifndef INVALID_HANDLE_VALUE -#define INVALID_HANDLE_VALUE (0xFFFFFFFF) -#endif - -#ifndef INVALID_SET_FILE_POINTER -#define INVALID_SET_FILE_POINTER ((DWORD)-1) -#endif - - -// see Include/shared/winapifamily.h in the Windows Kit -#if defined(WINAPI_FAMILY_PARTITION) && (!(defined(IOWIN32_USING_WINRT_API))) -#if WINAPI_FAMILY_ONE_PARTITION(WINAPI_FAMILY, WINAPI_PARTITION_APP) -#define IOWIN32_USING_WINRT_API 1 -#endif -#endif - -voidpf ZCALLBACK win32_open_file_func OF((voidpf opaque, const char* filename, int mode)); -uLong ZCALLBACK win32_read_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size)); -uLong ZCALLBACK win32_write_file_func OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); -ZPOS64_T ZCALLBACK win32_tell64_file_func OF((voidpf opaque, voidpf stream)); -long ZCALLBACK win32_seek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); -int ZCALLBACK win32_close_file_func OF((voidpf opaque, voidpf stream)); -int ZCALLBACK win32_error_file_func OF((voidpf opaque, voidpf stream)); - -typedef struct -{ - HANDLE hf; - int error; -} WIN32FILE_IOWIN; - - -static void win32_translate_open_mode(int mode, - DWORD* lpdwDesiredAccess, - DWORD* lpdwCreationDisposition, - DWORD* lpdwShareMode, - DWORD* lpdwFlagsAndAttributes) -{ - *lpdwDesiredAccess = *lpdwShareMode = *lpdwFlagsAndAttributes = *lpdwCreationDisposition = 0; - - if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) - { - *lpdwDesiredAccess = GENERIC_READ; - *lpdwCreationDisposition = OPEN_EXISTING; - *lpdwShareMode = FILE_SHARE_READ; - } - else if (mode & ZLIB_FILEFUNC_MODE_EXISTING) - { - *lpdwDesiredAccess = GENERIC_WRITE | GENERIC_READ; - *lpdwCreationDisposition = OPEN_EXISTING; - } - else if (mode & ZLIB_FILEFUNC_MODE_CREATE) - { - *lpdwDesiredAccess = GENERIC_WRITE | GENERIC_READ; - *lpdwCreationDisposition = CREATE_ALWAYS; - } -} - -static voidpf win32_build_iowin(HANDLE hFile) -{ - voidpf ret=NULL; - - if ((hFile != NULL) && (hFile != INVALID_HANDLE_VALUE)) - { - WIN32FILE_IOWIN w32fiow; - w32fiow.hf = hFile; - w32fiow.error = 0; - ret = malloc(sizeof(WIN32FILE_IOWIN)); - - if (ret==NULL) - CloseHandle(hFile); - else - *((WIN32FILE_IOWIN*)ret) = w32fiow; - } - return ret; -} - -voidpf ZCALLBACK win32_open64_file_func (voidpf opaque,const void* filename,int mode) -{ - const char* mode_fopen = NULL; - DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; - HANDLE hFile = NULL; - - win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); - -#ifdef IOWIN32_USING_WINRT_API -#ifdef UNICODE - if ((filename!=NULL) && (dwDesiredAccess != 0)) - hFile = CreateFile2((LPCTSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL); -#else - if ((filename!=NULL) && (dwDesiredAccess != 0)) - { - WCHAR filenameW[FILENAME_MAX + 0x200 + 1]; - MultiByteToWideChar(CP_ACP,0,(const char*)filename,-1,filenameW,FILENAME_MAX + 0x200); - hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL); - } -#endif -#else - if ((filename!=NULL) && (dwDesiredAccess != 0)) - hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL); -#endif - - return win32_build_iowin(hFile); -} - - -voidpf ZCALLBACK win32_open64_file_funcA (voidpf opaque,const void* filename,int mode) -{ - const char* mode_fopen = NULL; - DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; - HANDLE hFile = NULL; - - win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); - -#ifdef IOWIN32_USING_WINRT_API - if ((filename!=NULL) && (dwDesiredAccess != 0)) - { - WCHAR filenameW[FILENAME_MAX + 0x200 + 1]; - MultiByteToWideChar(CP_ACP,0,(const char*)filename,-1,filenameW,FILENAME_MAX + 0x200); - hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL); - } -#else - if ((filename!=NULL) && (dwDesiredAccess != 0)) - hFile = CreateFileA((LPCSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL); -#endif - - return win32_build_iowin(hFile); -} - - -voidpf ZCALLBACK win32_open64_file_funcW (voidpf opaque,const void* filename,int mode) -{ - const char* mode_fopen = NULL; - DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; - HANDLE hFile = NULL; - - win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); - -#ifdef IOWIN32_USING_WINRT_API - if ((filename!=NULL) && (dwDesiredAccess != 0)) - hFile = CreateFile2((LPCWSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition,NULL); -#else - if ((filename!=NULL) && (dwDesiredAccess != 0)) - hFile = CreateFileW((LPCWSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL); -#endif - - return win32_build_iowin(hFile); -} - - -voidpf ZCALLBACK win32_open_file_func (voidpf opaque,const char* filename,int mode) -{ - const char* mode_fopen = NULL; - DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; - HANDLE hFile = NULL; - - win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); - -#ifdef IOWIN32_USING_WINRT_API -#ifdef UNICODE - if ((filename!=NULL) && (dwDesiredAccess != 0)) - hFile = CreateFile2((LPCTSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL); -#else - if ((filename!=NULL) && (dwDesiredAccess != 0)) - { - WCHAR filenameW[FILENAME_MAX + 0x200 + 1]; - MultiByteToWideChar(CP_ACP,0,(const char*)filename,-1,filenameW,FILENAME_MAX + 0x200); - hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL); - } -#endif -#else - if ((filename!=NULL) && (dwDesiredAccess != 0)) - hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL); -#endif - - return win32_build_iowin(hFile); -} - - -uLong ZCALLBACK win32_read_file_func (voidpf opaque, voidpf stream, void* buf,uLong size) -{ - uLong ret=0; - HANDLE hFile = NULL; - if (stream!=NULL) - hFile = ((WIN32FILE_IOWIN*)stream) -> hf; - - if (hFile != NULL) - { - if (!ReadFile(hFile, buf, size, &ret, NULL)) - { - DWORD dwErr = GetLastError(); - if (dwErr == ERROR_HANDLE_EOF) - dwErr = 0; - ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; - } - } - - return ret; -} - - -uLong ZCALLBACK win32_write_file_func (voidpf opaque,voidpf stream,const void* buf,uLong size) -{ - uLong ret=0; - HANDLE hFile = NULL; - if (stream!=NULL) - hFile = ((WIN32FILE_IOWIN*)stream) -> hf; - - if (hFile != NULL) - { - if (!WriteFile(hFile, buf, size, &ret, NULL)) - { - DWORD dwErr = GetLastError(); - if (dwErr == ERROR_HANDLE_EOF) - dwErr = 0; - ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; - } - } - - return ret; -} - -static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos, DWORD dwMoveMethod) -{ -#ifdef IOWIN32_USING_WINRT_API - return SetFilePointerEx(hFile, pos, newPos, dwMoveMethod); -#else - LONG lHigh = pos.HighPart; - DWORD dwNewPos = SetFilePointer(hFile, pos.LowPart, &lHigh, dwMoveMethod); - BOOL fOk = TRUE; - if (dwNewPos == 0xFFFFFFFF) - if (GetLastError() != NO_ERROR) - fOk = FALSE; - if ((newPos != NULL) && (fOk)) - { - newPos->LowPart = dwNewPos; - newPos->HighPart = lHigh; - } - return fOk; -#endif -} - -long ZCALLBACK win32_tell_file_func (voidpf opaque,voidpf stream) -{ - long ret=-1; - HANDLE hFile = NULL; - if (stream!=NULL) - hFile = ((WIN32FILE_IOWIN*)stream) -> hf; - if (hFile != NULL) - { - LARGE_INTEGER pos; - pos.QuadPart = 0; - - if (!MySetFilePointerEx(hFile, pos, &pos, FILE_CURRENT)) - { - DWORD dwErr = GetLastError(); - ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; - ret = -1; - } - else - ret=(long)pos.LowPart; - } - return ret; -} - -ZPOS64_T ZCALLBACK win32_tell64_file_func (voidpf opaque, voidpf stream) -{ - ZPOS64_T ret= (ZPOS64_T)-1; - HANDLE hFile = NULL; - if (stream!=NULL) - hFile = ((WIN32FILE_IOWIN*)stream)->hf; - - if (hFile) - { - LARGE_INTEGER pos; - pos.QuadPart = 0; - - if (!MySetFilePointerEx(hFile, pos, &pos, FILE_CURRENT)) - { - DWORD dwErr = GetLastError(); - ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; - ret = (ZPOS64_T)-1; - } - else - ret=pos.QuadPart; - } - return ret; -} - - -long ZCALLBACK win32_seek_file_func (voidpf opaque,voidpf stream,uLong offset,int origin) -{ - DWORD dwMoveMethod=0xFFFFFFFF; - HANDLE hFile = NULL; - - long ret=-1; - if (stream!=NULL) - hFile = ((WIN32FILE_IOWIN*)stream) -> hf; - switch (origin) - { - case ZLIB_FILEFUNC_SEEK_CUR : - dwMoveMethod = FILE_CURRENT; - break; - case ZLIB_FILEFUNC_SEEK_END : - dwMoveMethod = FILE_END; - break; - case ZLIB_FILEFUNC_SEEK_SET : - dwMoveMethod = FILE_BEGIN; - break; - default: return -1; - } - - if (hFile != NULL) - { - LARGE_INTEGER pos; - pos.QuadPart = offset; - if (!MySetFilePointerEx(hFile, pos, NULL, dwMoveMethod)) - { - DWORD dwErr = GetLastError(); - ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; - ret = -1; - } - else - ret=0; - } - return ret; -} - -long ZCALLBACK win32_seek64_file_func (voidpf opaque, voidpf stream,ZPOS64_T offset,int origin) -{ - DWORD dwMoveMethod=0xFFFFFFFF; - HANDLE hFile = NULL; - long ret=-1; - - if (stream!=NULL) - hFile = ((WIN32FILE_IOWIN*)stream)->hf; - - switch (origin) - { - case ZLIB_FILEFUNC_SEEK_CUR : - dwMoveMethod = FILE_CURRENT; - break; - case ZLIB_FILEFUNC_SEEK_END : - dwMoveMethod = FILE_END; - break; - case ZLIB_FILEFUNC_SEEK_SET : - dwMoveMethod = FILE_BEGIN; - break; - default: return -1; - } - - if (hFile) - { - LARGE_INTEGER pos; - pos.QuadPart = offset; - if (!MySetFilePointerEx(hFile, pos, NULL, dwMoveMethod)) - { - DWORD dwErr = GetLastError(); - ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; - ret = -1; - } - else - ret=0; - } - return ret; -} - -int ZCALLBACK win32_close_file_func (voidpf opaque, voidpf stream) -{ - int ret=-1; - - if (stream!=NULL) - { - HANDLE hFile; - hFile = ((WIN32FILE_IOWIN*)stream) -> hf; - if (hFile != NULL) - { - CloseHandle(hFile); - ret=0; - } - free(stream); - } - return ret; -} - -int ZCALLBACK win32_error_file_func (voidpf opaque,voidpf stream) -{ - int ret=-1; - if (stream!=NULL) - { - ret = ((WIN32FILE_IOWIN*)stream) -> error; - } - return ret; -} - -void fill_win32_filefunc (zlib_filefunc_def* pzlib_filefunc_def) -{ - pzlib_filefunc_def->zopen_file = win32_open_file_func; - pzlib_filefunc_def->zread_file = win32_read_file_func; - pzlib_filefunc_def->zwrite_file = win32_write_file_func; - pzlib_filefunc_def->ztell_file = win32_tell_file_func; - pzlib_filefunc_def->zseek_file = win32_seek_file_func; - pzlib_filefunc_def->zclose_file = win32_close_file_func; - pzlib_filefunc_def->zerror_file = win32_error_file_func; - pzlib_filefunc_def->opaque = NULL; -} - -void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def) -{ - pzlib_filefunc_def->zopen64_file = win32_open64_file_func; - pzlib_filefunc_def->zread_file = win32_read_file_func; - pzlib_filefunc_def->zwrite_file = win32_write_file_func; - pzlib_filefunc_def->ztell64_file = win32_tell64_file_func; - pzlib_filefunc_def->zseek64_file = win32_seek64_file_func; - pzlib_filefunc_def->zclose_file = win32_close_file_func; - pzlib_filefunc_def->zerror_file = win32_error_file_func; - pzlib_filefunc_def->opaque = NULL; -} - - -void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def) -{ - pzlib_filefunc_def->zopen64_file = win32_open64_file_funcA; - pzlib_filefunc_def->zread_file = win32_read_file_func; - pzlib_filefunc_def->zwrite_file = win32_write_file_func; - pzlib_filefunc_def->ztell64_file = win32_tell64_file_func; - pzlib_filefunc_def->zseek64_file = win32_seek64_file_func; - pzlib_filefunc_def->zclose_file = win32_close_file_func; - pzlib_filefunc_def->zerror_file = win32_error_file_func; - pzlib_filefunc_def->opaque = NULL; -} - - -void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def) -{ - pzlib_filefunc_def->zopen64_file = win32_open64_file_funcW; - pzlib_filefunc_def->zread_file = win32_read_file_func; - pzlib_filefunc_def->zwrite_file = win32_write_file_func; - pzlib_filefunc_def->ztell64_file = win32_tell64_file_func; - pzlib_filefunc_def->zseek64_file = win32_seek64_file_func; - pzlib_filefunc_def->zclose_file = win32_close_file_func; - pzlib_filefunc_def->zerror_file = win32_error_file_func; - pzlib_filefunc_def->opaque = NULL; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/iowin32.h b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/iowin32.h deleted file mode 100644 index 0ca0969..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/iowin32.h +++ /dev/null @@ -1,28 +0,0 @@ -/* iowin32.h -- IO base function header for compress/uncompress .zip - Version 1.1, February 14h, 2010 - part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) - - Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) - - Modifications for Zip64 support - Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) - - For more info read MiniZip_info.txt - -*/ - -#include - - -#ifdef __cplusplus -extern "C" { -#endif - -void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); -void fill_win32_filefunc64 OF((zlib_filefunc64_def* pzlib_filefunc_def)); -void fill_win32_filefunc64A OF((zlib_filefunc64_def* pzlib_filefunc_def)); -void fill_win32_filefunc64W OF((zlib_filefunc64_def* pzlib_filefunc_def)); - -#ifdef __cplusplus -} -#endif diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/make_vms.com b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/make_vms.com deleted file mode 100644 index 9ac13a9..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/make_vms.com +++ /dev/null @@ -1,25 +0,0 @@ -$ if f$search("ioapi.h_orig") .eqs. "" then copy ioapi.h ioapi.h_orig -$ open/write zdef vmsdefs.h -$ copy sys$input: zdef -$ deck -#define unix -#define fill_zlib_filefunc64_32_def_from_filefunc32 fillzffunc64from -#define Write_Zip64EndOfCentralDirectoryLocator Write_Zip64EoDLocator -#define Write_Zip64EndOfCentralDirectoryRecord Write_Zip64EoDRecord -#define Write_EndOfCentralDirectoryRecord Write_EoDRecord -$ eod -$ close zdef -$ copy vmsdefs.h,ioapi.h_orig ioapi.h -$ cc/include=[--]/prefix=all ioapi.c -$ cc/include=[--]/prefix=all miniunz.c -$ cc/include=[--]/prefix=all unzip.c -$ cc/include=[--]/prefix=all minizip.c -$ cc/include=[--]/prefix=all zip.c -$ link miniunz,unzip,ioapi,[--]libz.olb/lib -$ link minizip,zip,ioapi,[--]libz.olb/lib -$ mcr []minizip test minizip_info.txt -$ mcr []miniunz -l test.zip -$ rename minizip_info.txt; minizip_info.txt_old -$ mcr []miniunz test.zip -$ delete test.zip;* -$exit diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/miniunz.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/miniunz.c deleted file mode 100644 index f103815..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/miniunz.c +++ /dev/null @@ -1,659 +0,0 @@ -/* - miniunz.c - Version 1.1, February 14h, 2010 - sample part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) - - Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) - - Modifications of Unzip for Zip64 - Copyright (C) 2007-2008 Even Rouault - - Modifications for Zip64 support on both zip and unzip - Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) -*/ - -#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) - #ifndef __USE_FILE_OFFSET64 - #define __USE_FILE_OFFSET64 - #endif - #ifndef __USE_LARGEFILE64 - #define __USE_LARGEFILE64 - #endif - #ifndef _LARGEFILE64_SOURCE - #define _LARGEFILE64_SOURCE - #endif - #ifndef _FILE_OFFSET_BIT - #define _FILE_OFFSET_BIT 64 - #endif -#endif - -#ifdef __APPLE__ -// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions -#define FOPEN_FUNC(filename, mode) fopen(filename, mode) -#define FTELLO_FUNC(stream) ftello(stream) -#define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin) -#else -#define FOPEN_FUNC(filename, mode) fopen64(filename, mode) -#define FTELLO_FUNC(stream) ftello64(stream) -#define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin) -#endif - - -#include -#include -#include -#include -#include -#include -#include - -#ifdef _WIN32 -# include -# include -#else -# include -# include -#endif - - -#include "unzip.h" - -#define CASESENSITIVITY (0) -#define WRITEBUFFERSIZE (8192) -#define MAXFILENAME (256) - -#ifdef _WIN32 -#define USEWIN32IOAPI -#include "iowin32.h" -#endif -/* - mini unzip, demo of unzip package - - usage : - Usage : miniunz [-exvlo] file.zip [file_to_extract] [-d extractdir] - - list the file in the zipfile, and print the content of FILE_ID.ZIP or README.TXT - if it exists -*/ - - -/* change_file_date : change the date/time of a file - filename : the filename of the file where date/time must be modified - dosdate : the new date at the MSDos format (4 bytes) - tmu_date : the SAME new date at the tm_unz format */ -static void change_file_date(filename,dosdate,tmu_date) - const char *filename; - uLong dosdate; - tm_unz tmu_date; -{ -#ifdef _WIN32 - HANDLE hFile; - FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite; - - hFile = CreateFileA(filename,GENERIC_READ | GENERIC_WRITE, - 0,NULL,OPEN_EXISTING,0,NULL); - GetFileTime(hFile,&ftCreate,&ftLastAcc,&ftLastWrite); - DosDateTimeToFileTime((WORD)(dosdate>>16),(WORD)dosdate,&ftLocal); - LocalFileTimeToFileTime(&ftLocal,&ftm); - SetFileTime(hFile,&ftm,&ftLastAcc,&ftm); - CloseHandle(hFile); -#else -#if defined(unix) || defined(__APPLE__) - (void)dosdate; - struct utimbuf ut; - struct tm newdate; - newdate.tm_sec = tmu_date.tm_sec; - newdate.tm_min=tmu_date.tm_min; - newdate.tm_hour=tmu_date.tm_hour; - newdate.tm_mday=tmu_date.tm_mday; - newdate.tm_mon=tmu_date.tm_mon; - if (tmu_date.tm_year > 1900) - newdate.tm_year=tmu_date.tm_year - 1900; - else - newdate.tm_year=tmu_date.tm_year ; - newdate.tm_isdst=-1; - - ut.actime=ut.modtime=mktime(&newdate); - utime(filename,&ut); -#endif -#endif -} - - -/* mymkdir and change_file_date are not 100 % portable - As I don't know well Unix, I wait feedback for the unix portion */ - -static int mymkdir(dirname) - const char* dirname; -{ - int ret=0; -#ifdef _WIN32 - ret = _mkdir(dirname); -#elif unix - ret = mkdir (dirname,0775); -#elif __APPLE__ - ret = mkdir (dirname,0775); -#endif - return ret; -} - -static int makedir (newdir) - const char *newdir; -{ - char *buffer ; - char *p; - size_t len = strlen(newdir); - - if (len == 0) - return 0; - - buffer = (char*)malloc(len+1); - if (buffer==NULL) - { - printf("Error allocating memory\n"); - return UNZ_INTERNALERROR; - } - strcpy(buffer,newdir); - - if (buffer[len-1] == '/') { - buffer[len-1] = '\0'; - } - if (mymkdir(buffer) == 0) - { - free(buffer); - return 1; - } - - p = buffer+1; - while (1) - { - char hold; - - while(*p && *p != '\\' && *p != '/') - p++; - hold = *p; - *p = 0; - if ((mymkdir(buffer) == -1) && (errno == ENOENT)) - { - printf("couldn't create directory %s\n",buffer); - free(buffer); - return 0; - } - if (hold == 0) - break; - *p++ = hold; - } - free(buffer); - return 1; -} - -static void do_banner() -{ - printf("MiniUnz 1.01b, demo of zLib + Unz package written by Gilles Vollant\n"); - printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n"); -} - -static void do_help() -{ - printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.] [-d extractdir]\n\n" \ - " -e Extract without pathname (junk paths)\n" \ - " -x Extract with pathname\n" \ - " -v list files\n" \ - " -l list files\n" \ - " -d directory to extract into\n" \ - " -o overwrite files without prompting\n" \ - " -p extract crypted file using password\n\n"); -} - -static void Display64BitsSize(ZPOS64_T n, int size_char) -{ - /* to avoid compatibility problem , we do here the conversion */ - char number[21]; - int offset=19; - int pos_string = 19; - number[20]=0; - for (;;) { - number[offset]=(char)((n%10)+'0'); - if (number[offset] != '0') - pos_string=offset; - n/=10; - if (offset==0) - break; - offset--; - } - { - int size_display_string = 19-pos_string; - while (size_char > size_display_string) - { - size_char--; - printf(" "); - } - } - - printf("%s",&number[pos_string]); -} - -static int do_list(uf) - unzFile uf; -{ - uLong i; - unz_global_info64 gi; - int err; - - err = unzGetGlobalInfo64(uf,&gi); - if (err!=UNZ_OK) - printf("error %d with zipfile in unzGetGlobalInfo \n",err); - printf(" Length Method Size Ratio Date Time CRC-32 Name\n"); - printf(" ------ ------ ---- ----- ---- ---- ------ ----\n"); - for (i=0;i0) - ratio = (uLong)((file_info.compressed_size*100)/file_info.uncompressed_size); - - /* display a '*' if the file is crypted */ - if ((file_info.flag & 1) != 0) - charCrypt='*'; - - if (file_info.compression_method==0) - string_method="Stored"; - else - if (file_info.compression_method==Z_DEFLATED) - { - uInt iLevel=(uInt)((file_info.flag & 0x6)/2); - if (iLevel==0) - string_method="Defl:N"; - else if (iLevel==1) - string_method="Defl:X"; - else if ((iLevel==2) || (iLevel==3)) - string_method="Defl:F"; /* 2:fast , 3 : extra fast*/ - } - else - if (file_info.compression_method==Z_BZIP2ED) - { - string_method="BZip2 "; - } - else - string_method="Unkn. "; - - Display64BitsSize(file_info.uncompressed_size,7); - printf(" %6s%c",string_method,charCrypt); - Display64BitsSize(file_info.compressed_size,7); - printf(" %3lu%% %2.2lu-%2.2lu-%2.2lu %2.2lu:%2.2lu %8.8lx %s\n", - ratio, - (uLong)file_info.tmu_date.tm_mon + 1, - (uLong)file_info.tmu_date.tm_mday, - (uLong)file_info.tmu_date.tm_year % 100, - (uLong)file_info.tmu_date.tm_hour,(uLong)file_info.tmu_date.tm_min, - (uLong)file_info.crc,filename_inzip); - if ((i+1)='a') && (rep<='z')) - rep -= 0x20; - } - while ((rep!='Y') && (rep!='N') && (rep!='A')); - } - - if (rep == 'N') - skip = 1; - - if (rep == 'A') - *popt_overwrite=1; - } - - if ((skip==0) && (err==UNZ_OK)) - { - fout=FOPEN_FUNC(write_filename,"wb"); - /* some zipfile don't contain directory alone before file */ - if ((fout==NULL) && ((*popt_extract_without_path)==0) && - (filename_withoutpath!=(char*)filename_inzip)) - { - char c=*(filename_withoutpath-1); - *(filename_withoutpath-1)='\0'; - makedir(write_filename); - *(filename_withoutpath-1)=c; - fout=FOPEN_FUNC(write_filename,"wb"); - } - - if (fout==NULL) - { - printf("error opening %s\n",write_filename); - } - } - - if (fout!=NULL) - { - printf(" extracting: %s\n",write_filename); - - do - { - err = unzReadCurrentFile(uf,buf,size_buf); - if (err<0) - { - printf("error %d with zipfile in unzReadCurrentFile\n",err); - break; - } - if (err>0) - if (fwrite(buf,(unsigned)err,1,fout)!=1) - { - printf("error in writing extracted file\n"); - err=UNZ_ERRNO; - break; - } - } - while (err>0); - if (fout) - fclose(fout); - - if (err==0) - change_file_date(write_filename,file_info.dosDate, - file_info.tmu_date); - } - - if (err==UNZ_OK) - { - err = unzCloseCurrentFile (uf); - if (err!=UNZ_OK) - { - printf("error %d with zipfile in unzCloseCurrentFile\n",err); - } - } - else - unzCloseCurrentFile(uf); /* don't lose the error */ - } - - free(buf); - return err; -} - - -static int do_extract(uf,opt_extract_without_path,opt_overwrite,password) - unzFile uf; - int opt_extract_without_path; - int opt_overwrite; - const char* password; -{ - uLong i; - unz_global_info64 gi; - int err; - - err = unzGetGlobalInfo64(uf,&gi); - if (err!=UNZ_OK) - printf("error %d with zipfile in unzGetGlobalInfo \n",err); - - for (i=0;i insert n+1 empty lines -.\" for manpage-specific macros, see man(7) -.SH NAME -miniunzip - uncompress and examine ZIP archives -.SH SYNOPSIS -.B miniunzip -.RI [ -exvlo ] -zipfile [ files_to_extract ] [-d tempdir] -.SH DESCRIPTION -.B minizip -is a simple tool which allows the extraction of compressed file -archives in the ZIP format used by the MS-DOS utility PKZIP. It was -written as a demonstration of the -.IR zlib (3) -library and therefore lack many of the features of the -.IR unzip (1) -program. -.SH OPTIONS -A number of options are supported. With the exception of -.BI \-d\ tempdir -these must be supplied before any -other arguments and are: -.TP -.BI \-l\ ,\ \-\-v -List the files in the archive without extracting them. -.TP -.B \-o -Overwrite files without prompting for confirmation. -.TP -.B \-x -Extract files (default). -.PP -The -.I zipfile -argument is the name of the archive to process. The next argument can be used -to specify a single file to extract from the archive. - -Lastly, the following option can be specified at the end of the command-line: -.TP -.BI \-d\ tempdir -Extract the archive in the directory -.I tempdir -rather than the current directory. -.SH SEE ALSO -.BR minizip (1), -.BR zlib (3), -.BR unzip (1). -.SH AUTHOR -This program was written by Gilles Vollant. This manual page was -written by Mark Brown . The -d tempdir option -was added by Dirk Eddelbuettel . diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/minizip.1 b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/minizip.1 deleted file mode 100644 index 1154484..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/minizip.1 +++ /dev/null @@ -1,46 +0,0 @@ -.\" Hey, EMACS: -*- nroff -*- -.TH minizip 1 "May 2, 2001" -.\" Please adjust this date whenever revising the manpage. -.\" -.\" Some roff macros, for reference: -.\" .nh disable hyphenation -.\" .hy enable hyphenation -.\" .ad l left justify -.\" .ad b justify to both left and right margins -.\" .nf disable filling -.\" .fi enable filling -.\" .br insert line break -.\" .sp insert n+1 empty lines -.\" for manpage-specific macros, see man(7) -.SH NAME -minizip - create ZIP archives -.SH SYNOPSIS -.B minizip -.RI [ -o ] -zipfile [ " files" ... ] -.SH DESCRIPTION -.B minizip -is a simple tool which allows the creation of compressed file archives -in the ZIP format used by the MS-DOS utility PKZIP. It was written as -a demonstration of the -.IR zlib (3) -library and therefore lack many of the features of the -.IR zip (1) -program. -.SH OPTIONS -The first argument supplied is the name of the ZIP archive to create or -.RI -o -in which case it is ignored and the second argument treated as the -name of the ZIP file. If the ZIP file already exists it will be -overwritten. -.PP -Subsequent arguments specify a list of files to place in the ZIP -archive. If none are specified then an empty archive will be created. -.SH SEE ALSO -.BR miniunzip (1), -.BR zlib (3), -.BR zip (1). -.SH AUTHOR -This program was written by Gilles Vollant. This manual page was -written by Mark Brown . - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/minizip.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/minizip.c deleted file mode 100644 index 7f937aa..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/minizip.c +++ /dev/null @@ -1,521 +0,0 @@ -/* - minizip.c - Version 1.1, February 14h, 2010 - sample part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) - - Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) - - Modifications of Unzip for Zip64 - Copyright (C) 2007-2008 Even Rouault - - Modifications for Zip64 support on both zip and unzip - Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) -*/ - - -#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__)) - #ifndef __USE_FILE_OFFSET64 - #define __USE_FILE_OFFSET64 - #endif - #ifndef __USE_LARGEFILE64 - #define __USE_LARGEFILE64 - #endif - #ifndef _LARGEFILE64_SOURCE - #define _LARGEFILE64_SOURCE - #endif - #ifndef _FILE_OFFSET_BIT - #define _FILE_OFFSET_BIT 64 - #endif -#endif - -#ifdef __APPLE__ -// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions -#define FOPEN_FUNC(filename, mode) fopen(filename, mode) -#define FTELLO_FUNC(stream) ftello(stream) -#define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin) -#else -#define FOPEN_FUNC(filename, mode) fopen64(filename, mode) -#define FTELLO_FUNC(stream) ftello64(stream) -#define FSEEKO_FUNC(stream, offset, origin) fseeko64(stream, offset, origin) -#endif - - - -#include -#include -#include -#include -#include -#include - -#ifdef _WIN32 -# include -# include -#else -# include -# include -# include -# include -#endif - -#include "zip.h" - -#ifdef _WIN32 - #define USEWIN32IOAPI - #include "iowin32.h" -#endif - - - -#define WRITEBUFFERSIZE (16384) -#define MAXFILENAME (256) - -#ifdef _WIN32 -static int filetime(f, tmzip, dt) - const char *f; /* name of file to get info on */ - tm_zip *tmzip; /* return value: access, modific. and creation times */ - uLong *dt; /* dostime */ -{ - int ret = 0; - { - FILETIME ftLocal; - HANDLE hFind; - WIN32_FIND_DATAA ff32; - - hFind = FindFirstFileA(f,&ff32); - if (hFind != INVALID_HANDLE_VALUE) - { - FileTimeToLocalFileTime(&(ff32.ftLastWriteTime),&ftLocal); - FileTimeToDosDateTime(&ftLocal,((LPWORD)dt)+1,((LPWORD)dt)+0); - FindClose(hFind); - ret = 1; - } - } - return ret; -} -#else -#if defined(unix) || defined(__APPLE__) -static int filetime(f, tmzip, dt) - const char *f; /* name of file to get info on */ - tm_zip *tmzip; /* return value: access, modific. and creation times */ - uLong *dt; /* dostime */ -{ - (void)dt; - int ret=0; - struct stat s; /* results of stat() */ - struct tm* filedate; - time_t tm_t=0; - - if (strcmp(f,"-")!=0) - { - char name[MAXFILENAME+1]; - size_t len = strlen(f); - if (len > MAXFILENAME) - len = MAXFILENAME; - - strncpy(name, f,MAXFILENAME-1); - /* strncpy doesnt append the trailing NULL, of the string is too long. */ - name[ MAXFILENAME ] = '\0'; - - if (name[len - 1] == '/') - name[len - 1] = '\0'; - /* not all systems allow stat'ing a file with / appended */ - if (stat(name,&s)==0) - { - tm_t = s.st_mtime; - ret = 1; - } - } - filedate = localtime(&tm_t); - - tmzip->tm_sec = filedate->tm_sec; - tmzip->tm_min = filedate->tm_min; - tmzip->tm_hour = filedate->tm_hour; - tmzip->tm_mday = filedate->tm_mday; - tmzip->tm_mon = filedate->tm_mon ; - tmzip->tm_year = filedate->tm_year; - - return ret; -} -#else -uLong filetime(f, tmzip, dt) - const char *f; /* name of file to get info on */ - tm_zip *tmzip; /* return value: access, modific. and creation times */ - uLong *dt; /* dostime */ -{ - return 0; -} -#endif -#endif - - - - -static int check_exist_file(filename) - const char* filename; -{ - FILE* ftestexist; - int ret = 1; - ftestexist = FOPEN_FUNC(filename,"rb"); - if (ftestexist==NULL) - ret = 0; - else - fclose(ftestexist); - return ret; -} - -static void do_banner() -{ - printf("MiniZip 1.1, demo of zLib + MiniZip64 package, written by Gilles Vollant\n"); - printf("more info on MiniZip at http://www.winimage.com/zLibDll/minizip.html\n\n"); -} - -static void do_help() -{ - printf("Usage : minizip [-o] [-a] [-0 to -9] [-p password] [-j] file.zip [files_to_add]\n\n" \ - " -o Overwrite existing file.zip\n" \ - " -a Append to existing file.zip\n" \ - " -0 Store only\n" \ - " -1 Compress faster\n" \ - " -9 Compress better\n\n" \ - " -j exclude path. store only the file name.\n\n"); -} - -/* calculate the CRC32 of a file, - because to encrypt a file, we need known the CRC32 of the file before */ -static int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigned long* result_crc) -{ - unsigned long calculate_crc=0; - int err=ZIP_OK; - FILE * fin = FOPEN_FUNC(filenameinzip,"rb"); - - unsigned long size_read = 0; - unsigned long total_read = 0; - if (fin==NULL) - { - err = ZIP_ERRNO; - } - - if (err == ZIP_OK) - do - { - err = ZIP_OK; - size_read = fread(buf,1,size_buf,fin); - if (size_read < size_buf) - if (feof(fin)==0) - { - printf("error in reading %s\n",filenameinzip); - err = ZIP_ERRNO; - } - - if (size_read>0) - calculate_crc = crc32_z(calculate_crc,buf,size_read); - total_read += size_read; - - } while ((err == ZIP_OK) && (size_read>0)); - - if (fin) - fclose(fin); - - *result_crc=calculate_crc; - printf("file %s crc %lx\n", filenameinzip, calculate_crc); - return err; -} - -static int isLargeFile(const char* filename) -{ - int largeFile = 0; - ZPOS64_T pos = 0; - FILE* pFile = FOPEN_FUNC(filename, "rb"); - - if(pFile != NULL) - { - FSEEKO_FUNC(pFile, 0, SEEK_END); - pos = (ZPOS64_T)FTELLO_FUNC(pFile); - - printf("File : %s is %lld bytes\n", filename, pos); - - if(pos >= 0xffffffff) - largeFile = 1; - - fclose(pFile); - } - - return largeFile; -} - -int main(argc,argv) - int argc; - char *argv[]; -{ - int i; - int opt_overwrite=0; - int opt_compress_level=Z_DEFAULT_COMPRESSION; - int opt_exclude_path=0; - int zipfilenamearg = 0; - char filename_try[MAXFILENAME+16]; - int zipok; - int err=0; - size_t size_buf=0; - void* buf=NULL; - const char* password=NULL; - - - do_banner(); - if (argc==1) - { - do_help(); - return 0; - } - else - { - for (i=1;i='0') && (c<='9')) - opt_compress_level = c-'0'; - if ((c=='j') || (c=='J')) - opt_exclude_path = 1; - - if (((c=='p') || (c=='P')) && (i+1='a') && (rep<='z')) - rep -= 0x20; - } - while ((rep!='Y') && (rep!='N') && (rep!='A')); - if (rep=='N') - zipok = 0; - if (rep=='A') - opt_overwrite = 2; - } - } - - if (zipok==1) - { - zipFile zf; - int errclose; -# ifdef USEWIN32IOAPI - zlib_filefunc64_def ffunc; - fill_win32_filefunc64A(&ffunc); - zf = zipOpen2_64(filename_try,(opt_overwrite==2) ? 2 : 0,NULL,&ffunc); -# else - zf = zipOpen64(filename_try,(opt_overwrite==2) ? 2 : 0); -# endif - - if (zf == NULL) - { - printf("error opening %s\n",filename_try); - err= ZIP_ERRNO; - } - else - printf("creating %s\n",filename_try); - - for (i=zipfilenamearg+1;(i='0') || (argv[i][1]<='9'))) && - (strlen(argv[i]) == 2))) - { - FILE * fin; - size_t size_read; - const char* filenameinzip = argv[i]; - const char *savefilenameinzip; - zip_fileinfo zi; - unsigned long crcFile=0; - int zip64 = 0; - - zi.tmz_date.tm_sec = zi.tmz_date.tm_min = zi.tmz_date.tm_hour = - zi.tmz_date.tm_mday = zi.tmz_date.tm_mon = zi.tmz_date.tm_year = 0; - zi.dosDate = 0; - zi.internal_fa = 0; - zi.external_fa = 0; - filetime(filenameinzip,&zi.tmz_date,&zi.dosDate); - -/* - err = zipOpenNewFileInZip(zf,filenameinzip,&zi, - NULL,0,NULL,0,NULL / * comment * /, - (opt_compress_level != 0) ? Z_DEFLATED : 0, - opt_compress_level); -*/ - if ((password != NULL) && (err==ZIP_OK)) - err = getFileCrc(filenameinzip,buf,size_buf,&crcFile); - - zip64 = isLargeFile(filenameinzip); - - /* The path name saved, should not include a leading slash. */ - /*if it did, windows/xp and dynazip couldn't read the zip file. */ - savefilenameinzip = filenameinzip; - while( savefilenameinzip[0] == '\\' || savefilenameinzip[0] == '/' ) - { - savefilenameinzip++; - } - - /*should the zip file contain any path at all?*/ - if( opt_exclude_path ) - { - const char *tmpptr; - const char *lastslash = 0; - for( tmpptr = savefilenameinzip; *tmpptr; tmpptr++) - { - if( *tmpptr == '\\' || *tmpptr == '/') - { - lastslash = tmpptr; - } - } - if( lastslash != NULL ) - { - savefilenameinzip = lastslash+1; // base filename follows last slash. - } - } - - /**/ - err = zipOpenNewFileInZip3_64(zf,savefilenameinzip,&zi, - NULL,0,NULL,0,NULL /* comment*/, - (opt_compress_level != 0) ? Z_DEFLATED : 0, - opt_compress_level,0, - /* -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, */ - -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, - password,crcFile, zip64); - - if (err != ZIP_OK) - printf("error in opening %s in zipfile\n",filenameinzip); - else - { - fin = FOPEN_FUNC(filenameinzip,"rb"); - if (fin==NULL) - { - err=ZIP_ERRNO; - printf("error in opening %s for reading\n",filenameinzip); - } - } - - if (err == ZIP_OK) - do - { - err = ZIP_OK; - size_read = fread(buf,1,size_buf,fin); - if (size_read < size_buf) - if (feof(fin)==0) - { - printf("error in reading %s\n",filenameinzip); - err = ZIP_ERRNO; - } - - if (size_read>0) - { - err = zipWriteInFileInZip (zf,buf,(unsigned)size_read); - if (err<0) - { - printf("error in writing %s in the zipfile\n", - filenameinzip); - } - - } - } while ((err == ZIP_OK) && (size_read>0)); - - if (fin) - fclose(fin); - - if (err<0) - err=ZIP_ERRNO; - else - { - err = zipCloseFileInZip(zf); - if (err!=ZIP_OK) - printf("error in closing %s in the zipfile\n", - filenameinzip); - } - } - } - errclose = zipClose(zf,NULL); - if (errclose != ZIP_OK) - printf("error in closing %s\n",filename_try); - } - else - { - do_help(); - } - - free(buf); - return 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/minizip.pc.in b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/minizip.pc.in deleted file mode 100644 index 69b5b7f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/minizip.pc.in +++ /dev/null @@ -1,12 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@/minizip - -Name: minizip -Description: Minizip zip file manipulation library -Requires: -Version: @PACKAGE_VERSION@ -Libs: -L${libdir} -lminizip -Libs.private: -lz -Cflags: -I${includedir} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/mztools.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/mztools.c deleted file mode 100644 index 96891c2..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/mztools.c +++ /dev/null @@ -1,291 +0,0 @@ -/* - Additional tools for Minizip - Code: Xavier Roche '2004 - License: Same as ZLIB (www.gzip.org) -*/ - -/* Code */ -#include -#include -#include -#include "zlib.h" -#include "unzip.h" - -#define READ_8(adr) ((unsigned char)*(adr)) -#define READ_16(adr) ( READ_8(adr) | (READ_8(adr+1) << 8) ) -#define READ_32(adr) ( READ_16(adr) | (READ_16((adr)+2) << 16) ) - -#define WRITE_8(buff, n) do { \ - *((unsigned char*)(buff)) = (unsigned char) ((n) & 0xff); \ -} while(0) -#define WRITE_16(buff, n) do { \ - WRITE_8((unsigned char*)(buff), n); \ - WRITE_8(((unsigned char*)(buff)) + 1, (n) >> 8); \ -} while(0) -#define WRITE_32(buff, n) do { \ - WRITE_16((unsigned char*)(buff), (n) & 0xffff); \ - WRITE_16((unsigned char*)(buff) + 2, (n) >> 16); \ -} while(0) - -extern int ZEXPORT unzRepair(file, fileOut, fileOutTmp, nRecovered, bytesRecovered) -const char* file; -const char* fileOut; -const char* fileOutTmp; -uLong* nRecovered; -uLong* bytesRecovered; -{ - int err = Z_OK; - FILE* fpZip = fopen(file, "rb"); - FILE* fpOut = fopen(fileOut, "wb"); - FILE* fpOutCD = fopen(fileOutTmp, "wb"); - if (fpZip != NULL && fpOut != NULL) { - int entries = 0; - uLong totalBytes = 0; - char header[30]; - char filename[1024]; - char extra[1024]; - int offset = 0; - int offsetCD = 0; - while ( fread(header, 1, 30, fpZip) == 30 ) { - int currentOffset = offset; - - /* File entry */ - if (READ_32(header) == 0x04034b50) { - unsigned int version = READ_16(header + 4); - unsigned int gpflag = READ_16(header + 6); - unsigned int method = READ_16(header + 8); - unsigned int filetime = READ_16(header + 10); - unsigned int filedate = READ_16(header + 12); - unsigned int crc = READ_32(header + 14); /* crc */ - unsigned int cpsize = READ_32(header + 18); /* compressed size */ - unsigned int uncpsize = READ_32(header + 22); /* uncompressed sz */ - unsigned int fnsize = READ_16(header + 26); /* file name length */ - unsigned int extsize = READ_16(header + 28); /* extra field length */ - filename[0] = extra[0] = '\0'; - - /* Header */ - if (fwrite(header, 1, 30, fpOut) == 30) { - offset += 30; - } else { - err = Z_ERRNO; - break; - } - - /* Filename */ - if (fnsize > 0) { - if (fnsize < sizeof(filename)) { - if (fread(filename, 1, fnsize, fpZip) == fnsize) { - if (fwrite(filename, 1, fnsize, fpOut) == fnsize) { - offset += fnsize; - } else { - err = Z_ERRNO; - break; - } - } else { - err = Z_ERRNO; - break; - } - } else { - err = Z_ERRNO; - break; - } - } else { - err = Z_STREAM_ERROR; - break; - } - - /* Extra field */ - if (extsize > 0) { - if (extsize < sizeof(extra)) { - if (fread(extra, 1, extsize, fpZip) == extsize) { - if (fwrite(extra, 1, extsize, fpOut) == extsize) { - offset += extsize; - } else { - err = Z_ERRNO; - break; - } - } else { - err = Z_ERRNO; - break; - } - } else { - err = Z_ERRNO; - break; - } - } - - /* Data */ - { - int dataSize = cpsize; - if (dataSize == 0) { - dataSize = uncpsize; - } - if (dataSize > 0) { - char* data = malloc(dataSize); - if (data != NULL) { - if ((int)fread(data, 1, dataSize, fpZip) == dataSize) { - if ((int)fwrite(data, 1, dataSize, fpOut) == dataSize) { - offset += dataSize; - totalBytes += dataSize; - } else { - err = Z_ERRNO; - } - } else { - err = Z_ERRNO; - } - free(data); - if (err != Z_OK) { - break; - } - } else { - err = Z_MEM_ERROR; - break; - } - } - } - - /* Central directory entry */ - { - char header[46]; - char* comment = ""; - int comsize = (int) strlen(comment); - WRITE_32(header, 0x02014b50); - WRITE_16(header + 4, version); - WRITE_16(header + 6, version); - WRITE_16(header + 8, gpflag); - WRITE_16(header + 10, method); - WRITE_16(header + 12, filetime); - WRITE_16(header + 14, filedate); - WRITE_32(header + 16, crc); - WRITE_32(header + 20, cpsize); - WRITE_32(header + 24, uncpsize); - WRITE_16(header + 28, fnsize); - WRITE_16(header + 30, extsize); - WRITE_16(header + 32, comsize); - WRITE_16(header + 34, 0); /* disk # */ - WRITE_16(header + 36, 0); /* int attrb */ - WRITE_32(header + 38, 0); /* ext attrb */ - WRITE_32(header + 42, currentOffset); - /* Header */ - if (fwrite(header, 1, 46, fpOutCD) == 46) { - offsetCD += 46; - - /* Filename */ - if (fnsize > 0) { - if (fwrite(filename, 1, fnsize, fpOutCD) == fnsize) { - offsetCD += fnsize; - } else { - err = Z_ERRNO; - break; - } - } else { - err = Z_STREAM_ERROR; - break; - } - - /* Extra field */ - if (extsize > 0) { - if (fwrite(extra, 1, extsize, fpOutCD) == extsize) { - offsetCD += extsize; - } else { - err = Z_ERRNO; - break; - } - } - - /* Comment field */ - if (comsize > 0) { - if ((int)fwrite(comment, 1, comsize, fpOutCD) == comsize) { - offsetCD += comsize; - } else { - err = Z_ERRNO; - break; - } - } - - - } else { - err = Z_ERRNO; - break; - } - } - - /* Success */ - entries++; - - } else { - break; - } - } - - /* Final central directory */ - { - int entriesZip = entries; - char header[22]; - char* comment = ""; // "ZIP File recovered by zlib/minizip/mztools"; - int comsize = (int) strlen(comment); - if (entriesZip > 0xffff) { - entriesZip = 0xffff; - } - WRITE_32(header, 0x06054b50); - WRITE_16(header + 4, 0); /* disk # */ - WRITE_16(header + 6, 0); /* disk # */ - WRITE_16(header + 8, entriesZip); /* hack */ - WRITE_16(header + 10, entriesZip); /* hack */ - WRITE_32(header + 12, offsetCD); /* size of CD */ - WRITE_32(header + 16, offset); /* offset to CD */ - WRITE_16(header + 20, comsize); /* comment */ - - /* Header */ - if (fwrite(header, 1, 22, fpOutCD) == 22) { - - /* Comment field */ - if (comsize > 0) { - if ((int)fwrite(comment, 1, comsize, fpOutCD) != comsize) { - err = Z_ERRNO; - } - } - - } else { - err = Z_ERRNO; - } - } - - /* Final merge (file + central directory) */ - fclose(fpOutCD); - if (err == Z_OK) { - fpOutCD = fopen(fileOutTmp, "rb"); - if (fpOutCD != NULL) { - int nRead; - char buffer[8192]; - while ( (nRead = (int)fread(buffer, 1, sizeof(buffer), fpOutCD)) > 0) { - if ((int)fwrite(buffer, 1, nRead, fpOut) != nRead) { - err = Z_ERRNO; - break; - } - } - fclose(fpOutCD); - } - } - - /* Close */ - fclose(fpZip); - fclose(fpOut); - - /* Wipe temporary file */ - (void)remove(fileOutTmp); - - /* Number of recovered entries */ - if (err == Z_OK) { - if (nRecovered != NULL) { - *nRecovered = entries; - } - if (bytesRecovered != NULL) { - *bytesRecovered = totalBytes; - } - } - } else { - err = Z_STREAM_ERROR; - } - return err; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/mztools.h b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/mztools.h deleted file mode 100644 index a49a426..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/mztools.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - Additional tools for Minizip - Code: Xavier Roche '2004 - License: Same as ZLIB (www.gzip.org) -*/ - -#ifndef _zip_tools_H -#define _zip_tools_H - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _ZLIB_H -#include "zlib.h" -#endif - -#include "unzip.h" - -/* Repair a ZIP file (missing central directory) - file: file to recover - fileOut: output file after recovery - fileOutTmp: temporary file name used for recovery -*/ -extern int ZEXPORT unzRepair(const char* file, - const char* fileOut, - const char* fileOutTmp, - uLong* nRecovered, - uLong* bytesRecovered); - - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/unzip.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/unzip.c deleted file mode 100644 index 5e12e47..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/unzip.c +++ /dev/null @@ -1,2128 +0,0 @@ -/* unzip.c -- IO for uncompress .zip files using zlib - Version 1.1, February 14h, 2010 - part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) - - Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) - - Modifications of Unzip for Zip64 - Copyright (C) 2007-2008 Even Rouault - - Modifications for Zip64 support on both zip and unzip - Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) - - For more info read MiniZip_info.txt - - - ------------------------------------------------------------------------------------ - Decryption code comes from crypt.c by Info-ZIP but has been greatly reduced in terms of - compatibility with older software. The following is from the original crypt.c. - Code woven in by Terry Thorsen 1/2003. - - Copyright (c) 1990-2000 Info-ZIP. All rights reserved. - - See the accompanying file LICENSE, version 2000-Apr-09 or later - (the contents of which are also included in zip.h) for terms of use. - If, for some reason, all these files are missing, the Info-ZIP license - also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html - - crypt.c (full version) by Info-ZIP. Last revised: [see crypt.h] - - The encryption/decryption parts of this source code (as opposed to the - non-echoing password parts) were originally written in Europe. The - whole source package can be freely distributed, including from the USA. - (Prior to January 2000, re-export from the US was a violation of US law.) - - This encryption code is a direct transcription of the algorithm from - Roger Schlafly, described by Phil Katz in the file appnote.txt. This - file (appnote.txt) is distributed with the PKZIP program (even in the - version without encryption capabilities). - - ------------------------------------------------------------------------------------ - - Changes in unzip.c - - 2007-2008 - Even Rouault - Addition of cpl_unzGetCurrentFileZStreamPos - 2007-2008 - Even Rouault - Decoration of symbol names unz* -> cpl_unz* - 2007-2008 - Even Rouault - Remove old C style function prototypes - 2007-2008 - Even Rouault - Add unzip support for ZIP64 - - Copyright (C) 2007-2008 Even Rouault - - - Oct-2009 - Mathias Svensson - Removed cpl_* from symbol names (Even Rouault added them but since this is now moved to a new project (minizip64) I renamed them again). - Oct-2009 - Mathias Svensson - Fixed problem if uncompressed size was > 4G and compressed size was <4G - should only read the compressed/uncompressed size from the Zip64 format if - the size from normal header was 0xFFFFFFFF - Oct-2009 - Mathias Svensson - Applied some bug fixes from paches recived from Gilles Vollant - Oct-2009 - Mathias Svensson - Applied support to unzip files with compression mathod BZIP2 (bzip2 lib is required) - Patch created by Daniel Borca - - Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer - - Copyright (C) 1998 - 2010 Gilles Vollant, Even Rouault, Mathias Svensson - -*/ - - -#include -#include -#include - -#ifndef NOUNCRYPT - #define NOUNCRYPT -#endif - -#include "zlib.h" -#include "unzip.h" - -#ifdef STDC -# include -# include -# include -#endif -#ifdef NO_ERRNO_H - extern int errno; -#else -# include -#endif - - -#ifndef local -# define local static -#endif -/* compile with -Dlocal if your debugger can't find static symbols */ - - -#ifndef CASESENSITIVITYDEFAULT_NO -# if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) -# define CASESENSITIVITYDEFAULT_NO -# endif -#endif - - -#ifndef UNZ_BUFSIZE -#define UNZ_BUFSIZE (16384) -#endif - -#ifndef UNZ_MAXFILENAMEINZIP -#define UNZ_MAXFILENAMEINZIP (256) -#endif - -#ifndef ALLOC -# define ALLOC(size) (malloc(size)) -#endif -#ifndef TRYFREE -# define TRYFREE(p) {if (p) free(p);} -#endif - -#define SIZECENTRALDIRITEM (0x2e) -#define SIZEZIPLOCALHEADER (0x1e) - - -const char unz_copyright[] = - " unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll"; - -/* unz_file_info_interntal contain internal info about a file in zipfile*/ -typedef struct unz_file_info64_internal_s -{ - ZPOS64_T offset_curfile;/* relative offset of local header 8 bytes */ -} unz_file_info64_internal; - - -/* file_in_zip_read_info_s contain internal information about a file in zipfile, - when reading and decompress it */ -typedef struct -{ - char *read_buffer; /* internal buffer for compressed data */ - z_stream stream; /* zLib stream structure for inflate */ - -#ifdef HAVE_BZIP2 - bz_stream bstream; /* bzLib stream structure for bziped */ -#endif - - ZPOS64_T pos_in_zipfile; /* position in byte on the zipfile, for fseek*/ - uLong stream_initialised; /* flag set if stream structure is initialised*/ - - ZPOS64_T offset_local_extrafield;/* offset of the local extra field */ - uInt size_local_extrafield;/* size of the local extra field */ - ZPOS64_T pos_local_extrafield; /* position in the local extra field in read*/ - ZPOS64_T total_out_64; - - uLong crc32; /* crc32 of all data uncompressed */ - uLong crc32_wait; /* crc32 we must obtain after decompress all */ - ZPOS64_T rest_read_compressed; /* number of byte to be decompressed */ - ZPOS64_T rest_read_uncompressed;/*number of byte to be obtained after decomp*/ - zlib_filefunc64_32_def z_filefunc; - voidpf filestream; /* io structore of the zipfile */ - uLong compression_method; /* compression method (0==store) */ - ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ - int raw; -} file_in_zip64_read_info_s; - - -/* unz64_s contain internal information about the zipfile -*/ -typedef struct -{ - zlib_filefunc64_32_def z_filefunc; - int is64bitOpenFunction; - voidpf filestream; /* io structore of the zipfile */ - unz_global_info64 gi; /* public global information */ - ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ - ZPOS64_T num_file; /* number of the current file in the zipfile*/ - ZPOS64_T pos_in_central_dir; /* pos of the current file in the central dir*/ - ZPOS64_T current_file_ok; /* flag about the usability of the current file*/ - ZPOS64_T central_pos; /* position of the beginning of the central dir*/ - - ZPOS64_T size_central_dir; /* size of the central directory */ - ZPOS64_T offset_central_dir; /* offset of start of central directory with - respect to the starting disk number */ - - unz_file_info64 cur_file_info; /* public info about the current file in zip*/ - unz_file_info64_internal cur_file_info_internal; /* private info about it*/ - file_in_zip64_read_info_s* pfile_in_zip_read; /* structure about the current - file if we are decompressing it */ - int encrypted; - - int isZip64; - -# ifndef NOUNCRYPT - unsigned long keys[3]; /* keys defining the pseudo-random sequence */ - const z_crc_t* pcrc_32_tab; -# endif -} unz64_s; - - -#ifndef NOUNCRYPT -#include "crypt.h" -#endif - -/* =========================================================================== - Read a byte from a gz_stream; update next_in and avail_in. Return EOF - for end of file. - IN assertion: the stream s has been successfully opened for reading. -*/ - - -local int unz64local_getByte OF(( - const zlib_filefunc64_32_def* pzlib_filefunc_def, - voidpf filestream, - int *pi)); - -local int unz64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi) -{ - unsigned char c; - int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1); - if (err==1) - { - *pi = (int)c; - return UNZ_OK; - } - else - { - if (ZERROR64(*pzlib_filefunc_def,filestream)) - return UNZ_ERRNO; - else - return UNZ_EOF; - } -} - - -/* =========================================================================== - Reads a long in LSB order from the given gz_stream. Sets -*/ -local int unz64local_getShort OF(( - const zlib_filefunc64_32_def* pzlib_filefunc_def, - voidpf filestream, - uLong *pX)); - -local int unz64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def, - voidpf filestream, - uLong *pX) -{ - uLong x ; - int i = 0; - int err; - - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); - x = (uLong)i; - - if (err==UNZ_OK) - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); - x |= ((uLong)i)<<8; - - if (err==UNZ_OK) - *pX = x; - else - *pX = 0; - return err; -} - -local int unz64local_getLong OF(( - const zlib_filefunc64_32_def* pzlib_filefunc_def, - voidpf filestream, - uLong *pX)); - -local int unz64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def, - voidpf filestream, - uLong *pX) -{ - uLong x ; - int i = 0; - int err; - - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); - x = (uLong)i; - - if (err==UNZ_OK) - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); - x |= ((uLong)i)<<8; - - if (err==UNZ_OK) - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); - x |= ((uLong)i)<<16; - - if (err==UNZ_OK) - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); - x += ((uLong)i)<<24; - - if (err==UNZ_OK) - *pX = x; - else - *pX = 0; - return err; -} - -local int unz64local_getLong64 OF(( - const zlib_filefunc64_32_def* pzlib_filefunc_def, - voidpf filestream, - ZPOS64_T *pX)); - - -local int unz64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def, - voidpf filestream, - ZPOS64_T *pX) -{ - ZPOS64_T x ; - int i = 0; - int err; - - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); - x = (ZPOS64_T)i; - - if (err==UNZ_OK) - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); - x |= ((ZPOS64_T)i)<<8; - - if (err==UNZ_OK) - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); - x |= ((ZPOS64_T)i)<<16; - - if (err==UNZ_OK) - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); - x |= ((ZPOS64_T)i)<<24; - - if (err==UNZ_OK) - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); - x |= ((ZPOS64_T)i)<<32; - - if (err==UNZ_OK) - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); - x |= ((ZPOS64_T)i)<<40; - - if (err==UNZ_OK) - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); - x |= ((ZPOS64_T)i)<<48; - - if (err==UNZ_OK) - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); - x |= ((ZPOS64_T)i)<<56; - - if (err==UNZ_OK) - *pX = x; - else - *pX = 0; - return err; -} - -/* My own strcmpi / strcasecmp */ -local int strcmpcasenosensitive_internal (const char* fileName1, const char* fileName2) -{ - for (;;) - { - char c1=*(fileName1++); - char c2=*(fileName2++); - if ((c1>='a') && (c1<='z')) - c1 -= 0x20; - if ((c2>='a') && (c2<='z')) - c2 -= 0x20; - if (c1=='\0') - return ((c2=='\0') ? 0 : -1); - if (c2=='\0') - return 1; - if (c1c2) - return 1; - } -} - - -#ifdef CASESENSITIVITYDEFAULT_NO -#define CASESENSITIVITYDEFAULTVALUE 2 -#else -#define CASESENSITIVITYDEFAULTVALUE 1 -#endif - -#ifndef STRCMPCASENOSENTIVEFUNCTION -#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal -#endif - -/* - Compare two filename (fileName1,fileName2). - If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) - If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi - or strcasecmp) - If iCaseSenisivity = 0, case sensitivity is defaut of your operating system - (like 1 on Unix, 2 on Windows) - -*/ -extern int ZEXPORT unzStringFileNameCompare (const char* fileName1, - const char* fileName2, - int iCaseSensitivity) - -{ - if (iCaseSensitivity==0) - iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; - - if (iCaseSensitivity==1) - return strcmp(fileName1,fileName2); - - return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2); -} - -#ifndef BUFREADCOMMENT -#define BUFREADCOMMENT (0x400) -#endif - -/* - Locate the Central directory of a zipfile (at the end, just before - the global comment) -*/ -local ZPOS64_T unz64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)); -local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) -{ - unsigned char* buf; - ZPOS64_T uSizeFile; - ZPOS64_T uBackRead; - ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ - ZPOS64_T uPosFound=0; - - if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) - return 0; - - - uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream); - - if (uMaxBack>uSizeFile) - uMaxBack = uSizeFile; - - buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); - if (buf==NULL) - return 0; - - uBackRead = 4; - while (uBackReaduMaxBack) - uBackRead = uMaxBack; - else - uBackRead+=BUFREADCOMMENT; - uReadPos = uSizeFile-uBackRead ; - - uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? - (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos); - if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) - break; - - if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) - break; - - for (i=(int)uReadSize-3; (i--)>0;) - if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && - ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) - { - uPosFound = uReadPos+(unsigned)i; - break; - } - - if (uPosFound!=0) - break; - } - TRYFREE(buf); - return uPosFound; -} - - -/* - Locate the Central directory 64 of a zipfile (at the end, just before - the global comment) -*/ -local ZPOS64_T unz64local_SearchCentralDir64 OF(( - const zlib_filefunc64_32_def* pzlib_filefunc_def, - voidpf filestream)); - -local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def, - voidpf filestream) -{ - unsigned char* buf; - ZPOS64_T uSizeFile; - ZPOS64_T uBackRead; - ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ - ZPOS64_T uPosFound=0; - uLong uL; - ZPOS64_T relativeOffset; - - if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) - return 0; - - - uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream); - - if (uMaxBack>uSizeFile) - uMaxBack = uSizeFile; - - buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); - if (buf==NULL) - return 0; - - uBackRead = 4; - while (uBackReaduMaxBack) - uBackRead = uMaxBack; - else - uBackRead+=BUFREADCOMMENT; - uReadPos = uSizeFile-uBackRead ; - - uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? - (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos); - if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) - break; - - if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) - break; - - for (i=(int)uReadSize-3; (i--)>0;) - if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && - ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07)) - { - uPosFound = uReadPos+(unsigned)i; - break; - } - - if (uPosFound!=0) - break; - } - TRYFREE(buf); - if (uPosFound == 0) - return 0; - - /* Zip64 end of central directory locator */ - if (ZSEEK64(*pzlib_filefunc_def,filestream, uPosFound,ZLIB_FILEFUNC_SEEK_SET)!=0) - return 0; - - /* the signature, already checked */ - if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) - return 0; - - /* number of the disk with the start of the zip64 end of central directory */ - if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) - return 0; - if (uL != 0) - return 0; - - /* relative offset of the zip64 end of central directory record */ - if (unz64local_getLong64(pzlib_filefunc_def,filestream,&relativeOffset)!=UNZ_OK) - return 0; - - /* total number of disks */ - if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) - return 0; - if (uL != 1) - return 0; - - /* Goto end of central directory record */ - if (ZSEEK64(*pzlib_filefunc_def,filestream, relativeOffset,ZLIB_FILEFUNC_SEEK_SET)!=0) - return 0; - - /* the signature */ - if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) - return 0; - - if (uL != 0x06064b50) - return 0; - - return relativeOffset; -} - -/* - Open a Zip file. path contain the full pathname (by example, - on a Windows NT computer "c:\\test\\zlib114.zip" or on an Unix computer - "zlib/zlib114.zip". - If the zipfile cannot be opened (file doesn't exist or in not valid), the - return value is NULL. - Else, the return value is a unzFile Handle, usable with other function - of this unzip package. -*/ -local unzFile unzOpenInternal (const void *path, - zlib_filefunc64_32_def* pzlib_filefunc64_32_def, - int is64bitOpenFunction) -{ - unz64_s us; - unz64_s *s; - ZPOS64_T central_pos; - uLong uL; - - uLong number_disk; /* number of the current dist, used for - spaning ZIP, unsupported, always 0*/ - uLong number_disk_with_CD; /* number the the disk with central dir, used - for spaning ZIP, unsupported, always 0*/ - ZPOS64_T number_entry_CD; /* total number of entries in - the central dir - (same than number_entry on nospan) */ - - int err=UNZ_OK; - - if (unz_copyright[0]!=' ') - return NULL; - - us.z_filefunc.zseek32_file = NULL; - us.z_filefunc.ztell32_file = NULL; - if (pzlib_filefunc64_32_def==NULL) - fill_fopen64_filefunc(&us.z_filefunc.zfile_func64); - else - us.z_filefunc = *pzlib_filefunc64_32_def; - us.is64bitOpenFunction = is64bitOpenFunction; - - - - us.filestream = ZOPEN64(us.z_filefunc, - path, - ZLIB_FILEFUNC_MODE_READ | - ZLIB_FILEFUNC_MODE_EXISTING); - if (us.filestream==NULL) - return NULL; - - central_pos = unz64local_SearchCentralDir64(&us.z_filefunc,us.filestream); - if (central_pos) - { - uLong uS; - ZPOS64_T uL64; - - us.isZip64 = 1; - - if (ZSEEK64(us.z_filefunc, us.filestream, - central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) - err=UNZ_ERRNO; - - /* the signature, already checked */ - if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) - err=UNZ_ERRNO; - - /* size of zip64 end of central directory record */ - if (unz64local_getLong64(&us.z_filefunc, us.filestream,&uL64)!=UNZ_OK) - err=UNZ_ERRNO; - - /* version made by */ - if (unz64local_getShort(&us.z_filefunc, us.filestream,&uS)!=UNZ_OK) - err=UNZ_ERRNO; - - /* version needed to extract */ - if (unz64local_getShort(&us.z_filefunc, us.filestream,&uS)!=UNZ_OK) - err=UNZ_ERRNO; - - /* number of this disk */ - if (unz64local_getLong(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK) - err=UNZ_ERRNO; - - /* number of the disk with the start of the central directory */ - if (unz64local_getLong(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK) - err=UNZ_ERRNO; - - /* total number of entries in the central directory on this disk */ - if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.gi.number_entry)!=UNZ_OK) - err=UNZ_ERRNO; - - /* total number of entries in the central directory */ - if (unz64local_getLong64(&us.z_filefunc, us.filestream,&number_entry_CD)!=UNZ_OK) - err=UNZ_ERRNO; - - if ((number_entry_CD!=us.gi.number_entry) || - (number_disk_with_CD!=0) || - (number_disk!=0)) - err=UNZ_BADZIPFILE; - - /* size of the central directory */ - if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.size_central_dir)!=UNZ_OK) - err=UNZ_ERRNO; - - /* offset of start of central directory with respect to the - starting disk number */ - if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.offset_central_dir)!=UNZ_OK) - err=UNZ_ERRNO; - - us.gi.size_comment = 0; - } - else - { - central_pos = unz64local_SearchCentralDir(&us.z_filefunc,us.filestream); - if (central_pos==0) - err=UNZ_ERRNO; - - us.isZip64 = 0; - - if (ZSEEK64(us.z_filefunc, us.filestream, - central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) - err=UNZ_ERRNO; - - /* the signature, already checked */ - if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) - err=UNZ_ERRNO; - - /* number of this disk */ - if (unz64local_getShort(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK) - err=UNZ_ERRNO; - - /* number of the disk with the start of the central directory */ - if (unz64local_getShort(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK) - err=UNZ_ERRNO; - - /* total number of entries in the central dir on this disk */ - if (unz64local_getShort(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) - err=UNZ_ERRNO; - us.gi.number_entry = uL; - - /* total number of entries in the central dir */ - if (unz64local_getShort(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) - err=UNZ_ERRNO; - number_entry_CD = uL; - - if ((number_entry_CD!=us.gi.number_entry) || - (number_disk_with_CD!=0) || - (number_disk!=0)) - err=UNZ_BADZIPFILE; - - /* size of the central directory */ - if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) - err=UNZ_ERRNO; - us.size_central_dir = uL; - - /* offset of start of central directory with respect to the - starting disk number */ - if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) - err=UNZ_ERRNO; - us.offset_central_dir = uL; - - /* zipfile comment length */ - if (unz64local_getShort(&us.z_filefunc, us.filestream,&us.gi.size_comment)!=UNZ_OK) - err=UNZ_ERRNO; - } - - if ((central_pospfile_in_zip_read!=NULL) - unzCloseCurrentFile(file); - - ZCLOSE64(s->z_filefunc, s->filestream); - TRYFREE(s); - return UNZ_OK; -} - - -/* - Write info about the ZipFile in the *pglobal_info structure. - No preparation of the structure is needed - return UNZ_OK if there is no problem. */ -extern int ZEXPORT unzGetGlobalInfo64 (unzFile file, unz_global_info64* pglobal_info) -{ - unz64_s* s; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz64_s*)file; - *pglobal_info=s->gi; - return UNZ_OK; -} - -extern int ZEXPORT unzGetGlobalInfo (unzFile file, unz_global_info* pglobal_info32) -{ - unz64_s* s; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz64_s*)file; - /* to do : check if number_entry is not truncated */ - pglobal_info32->number_entry = (uLong)s->gi.number_entry; - pglobal_info32->size_comment = s->gi.size_comment; - return UNZ_OK; -} -/* - Translate date/time from Dos format to tm_unz (readable more easilty) -*/ -local void unz64local_DosDateToTmuDate (ZPOS64_T ulDosDate, tm_unz* ptm) -{ - ZPOS64_T uDate; - uDate = (ZPOS64_T)(ulDosDate>>16); - ptm->tm_mday = (int)(uDate&0x1f) ; - ptm->tm_mon = (int)((((uDate)&0x1E0)/0x20)-1) ; - ptm->tm_year = (int)(((uDate&0x0FE00)/0x0200)+1980) ; - - ptm->tm_hour = (int) ((ulDosDate &0xF800)/0x800); - ptm->tm_min = (int) ((ulDosDate&0x7E0)/0x20) ; - ptm->tm_sec = (int) (2*(ulDosDate&0x1f)) ; -} - -/* - Get Info about the current file in the zipfile, with internal only info -*/ -local int unz64local_GetCurrentFileInfoInternal OF((unzFile file, - unz_file_info64 *pfile_info, - unz_file_info64_internal - *pfile_info_internal, - char *szFileName, - uLong fileNameBufferSize, - void *extraField, - uLong extraFieldBufferSize, - char *szComment, - uLong commentBufferSize)); - -local int unz64local_GetCurrentFileInfoInternal (unzFile file, - unz_file_info64 *pfile_info, - unz_file_info64_internal - *pfile_info_internal, - char *szFileName, - uLong fileNameBufferSize, - void *extraField, - uLong extraFieldBufferSize, - char *szComment, - uLong commentBufferSize) -{ - unz64_s* s; - unz_file_info64 file_info; - unz_file_info64_internal file_info_internal; - int err=UNZ_OK; - uLong uMagic; - long lSeek=0; - uLong uL; - - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz64_s*)file; - if (ZSEEK64(s->z_filefunc, s->filestream, - s->pos_in_central_dir+s->byte_before_the_zipfile, - ZLIB_FILEFUNC_SEEK_SET)!=0) - err=UNZ_ERRNO; - - - /* we check the magic */ - if (err==UNZ_OK) - { - if (unz64local_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) - err=UNZ_ERRNO; - else if (uMagic!=0x02014b50) - err=UNZ_BADZIPFILE; - } - - if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK) - err=UNZ_ERRNO; - - if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.version_needed) != UNZ_OK) - err=UNZ_ERRNO; - - if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.flag) != UNZ_OK) - err=UNZ_ERRNO; - - if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.compression_method) != UNZ_OK) - err=UNZ_ERRNO; - - if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.dosDate) != UNZ_OK) - err=UNZ_ERRNO; - - unz64local_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date); - - if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.crc) != UNZ_OK) - err=UNZ_ERRNO; - - if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK) - err=UNZ_ERRNO; - file_info.compressed_size = uL; - - if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK) - err=UNZ_ERRNO; - file_info.uncompressed_size = uL; - - if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_filename) != UNZ_OK) - err=UNZ_ERRNO; - - if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_extra) != UNZ_OK) - err=UNZ_ERRNO; - - if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_comment) != UNZ_OK) - err=UNZ_ERRNO; - - if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK) - err=UNZ_ERRNO; - - if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.internal_fa) != UNZ_OK) - err=UNZ_ERRNO; - - if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK) - err=UNZ_ERRNO; - - // relative offset of local header - if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK) - err=UNZ_ERRNO; - file_info_internal.offset_curfile = uL; - - lSeek+=file_info.size_filename; - if ((err==UNZ_OK) && (szFileName!=NULL)) - { - uLong uSizeRead ; - if (file_info.size_filename0) && (fileNameBufferSize>0)) - if (ZREAD64(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead) - err=UNZ_ERRNO; - lSeek -= uSizeRead; - } - - // Read extrafield - if ((err==UNZ_OK) && (extraField!=NULL)) - { - ZPOS64_T uSizeRead ; - if (file_info.size_file_extraz_filefunc, s->filestream,(ZPOS64_T)lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) - lSeek=0; - else - err=UNZ_ERRNO; - } - - if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) - if (ZREAD64(s->z_filefunc, s->filestream,extraField,(uLong)uSizeRead)!=uSizeRead) - err=UNZ_ERRNO; - - lSeek += file_info.size_file_extra - (uLong)uSizeRead; - } - else - lSeek += file_info.size_file_extra; - - - if ((err==UNZ_OK) && (file_info.size_file_extra != 0)) - { - uLong acc = 0; - - // since lSeek now points to after the extra field we need to move back - lSeek -= file_info.size_file_extra; - - if (lSeek!=0) - { - if (ZSEEK64(s->z_filefunc, s->filestream,(ZPOS64_T)lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) - lSeek=0; - else - err=UNZ_ERRNO; - } - - while(acc < file_info.size_file_extra) - { - uLong headerId; - uLong dataSize; - - if (unz64local_getShort(&s->z_filefunc, s->filestream,&headerId) != UNZ_OK) - err=UNZ_ERRNO; - - if (unz64local_getShort(&s->z_filefunc, s->filestream,&dataSize) != UNZ_OK) - err=UNZ_ERRNO; - - /* ZIP64 extra fields */ - if (headerId == 0x0001) - { - uLong uL; - - if(file_info.uncompressed_size == MAXU32) - { - if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK) - err=UNZ_ERRNO; - } - - if(file_info.compressed_size == MAXU32) - { - if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK) - err=UNZ_ERRNO; - } - - if(file_info_internal.offset_curfile == MAXU32) - { - /* Relative Header offset */ - if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK) - err=UNZ_ERRNO; - } - - if(file_info.disk_num_start == MAXU32) - { - /* Disk Start Number */ - if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK) - err=UNZ_ERRNO; - } - - } - else - { - if (ZSEEK64(s->z_filefunc, s->filestream,dataSize,ZLIB_FILEFUNC_SEEK_CUR)!=0) - err=UNZ_ERRNO; - } - - acc += 2 + 2 + dataSize; - } - } - - if ((err==UNZ_OK) && (szComment!=NULL)) - { - uLong uSizeRead ; - if (file_info.size_file_commentz_filefunc, s->filestream,(ZPOS64_T)lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) - lSeek=0; - else - err=UNZ_ERRNO; - } - - if ((file_info.size_file_comment>0) && (commentBufferSize>0)) - if (ZREAD64(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead) - err=UNZ_ERRNO; - lSeek+=file_info.size_file_comment - uSizeRead; - } - else - lSeek+=file_info.size_file_comment; - - - if ((err==UNZ_OK) && (pfile_info!=NULL)) - *pfile_info=file_info; - - if ((err==UNZ_OK) && (pfile_info_internal!=NULL)) - *pfile_info_internal=file_info_internal; - - return err; -} - - - -/* - Write info about the ZipFile in the *pglobal_info structure. - No preparation of the structure is needed - return UNZ_OK if there is no problem. -*/ -extern int ZEXPORT unzGetCurrentFileInfo64 (unzFile file, - unz_file_info64 * pfile_info, - char * szFileName, uLong fileNameBufferSize, - void *extraField, uLong extraFieldBufferSize, - char* szComment, uLong commentBufferSize) -{ - return unz64local_GetCurrentFileInfoInternal(file,pfile_info,NULL, - szFileName,fileNameBufferSize, - extraField,extraFieldBufferSize, - szComment,commentBufferSize); -} - -extern int ZEXPORT unzGetCurrentFileInfo (unzFile file, - unz_file_info * pfile_info, - char * szFileName, uLong fileNameBufferSize, - void *extraField, uLong extraFieldBufferSize, - char* szComment, uLong commentBufferSize) -{ - int err; - unz_file_info64 file_info64; - err = unz64local_GetCurrentFileInfoInternal(file,&file_info64,NULL, - szFileName,fileNameBufferSize, - extraField,extraFieldBufferSize, - szComment,commentBufferSize); - if ((err==UNZ_OK) && (pfile_info != NULL)) - { - pfile_info->version = file_info64.version; - pfile_info->version_needed = file_info64.version_needed; - pfile_info->flag = file_info64.flag; - pfile_info->compression_method = file_info64.compression_method; - pfile_info->dosDate = file_info64.dosDate; - pfile_info->crc = file_info64.crc; - - pfile_info->size_filename = file_info64.size_filename; - pfile_info->size_file_extra = file_info64.size_file_extra; - pfile_info->size_file_comment = file_info64.size_file_comment; - - pfile_info->disk_num_start = file_info64.disk_num_start; - pfile_info->internal_fa = file_info64.internal_fa; - pfile_info->external_fa = file_info64.external_fa; - - pfile_info->tmu_date = file_info64.tmu_date, - - - pfile_info->compressed_size = (uLong)file_info64.compressed_size; - pfile_info->uncompressed_size = (uLong)file_info64.uncompressed_size; - - } - return err; -} -/* - Set the current file of the zipfile to the first file. - return UNZ_OK if there is no problem -*/ -extern int ZEXPORT unzGoToFirstFile (unzFile file) -{ - int err=UNZ_OK; - unz64_s* s; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz64_s*)file; - s->pos_in_central_dir=s->offset_central_dir; - s->num_file=0; - err=unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info, - &s->cur_file_info_internal, - NULL,0,NULL,0,NULL,0); - s->current_file_ok = (err == UNZ_OK); - return err; -} - -/* - Set the current file of the zipfile to the next file. - return UNZ_OK if there is no problem - return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. -*/ -extern int ZEXPORT unzGoToNextFile (unzFile file) -{ - unz64_s* s; - int err; - - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz64_s*)file; - if (!s->current_file_ok) - return UNZ_END_OF_LIST_OF_FILE; - if (s->gi.number_entry != 0xffff) /* 2^16 files overflow hack */ - if (s->num_file+1==s->gi.number_entry) - return UNZ_END_OF_LIST_OF_FILE; - - s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + - s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ; - s->num_file++; - err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info, - &s->cur_file_info_internal, - NULL,0,NULL,0,NULL,0); - s->current_file_ok = (err == UNZ_OK); - return err; -} - - -/* - Try locate the file szFileName in the zipfile. - For the iCaseSensitivity signification, see unzStringFileNameCompare - - return value : - UNZ_OK if the file is found. It becomes the current file. - UNZ_END_OF_LIST_OF_FILE if the file is not found -*/ -extern int ZEXPORT unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity) -{ - unz64_s* s; - int err; - - /* We remember the 'current' position in the file so that we can jump - * back there if we fail. - */ - unz_file_info64 cur_file_infoSaved; - unz_file_info64_internal cur_file_info_internalSaved; - ZPOS64_T num_fileSaved; - ZPOS64_T pos_in_central_dirSaved; - - - if (file==NULL) - return UNZ_PARAMERROR; - - if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP) - return UNZ_PARAMERROR; - - s=(unz64_s*)file; - if (!s->current_file_ok) - return UNZ_END_OF_LIST_OF_FILE; - - /* Save the current state */ - num_fileSaved = s->num_file; - pos_in_central_dirSaved = s->pos_in_central_dir; - cur_file_infoSaved = s->cur_file_info; - cur_file_info_internalSaved = s->cur_file_info_internal; - - err = unzGoToFirstFile(file); - - while (err == UNZ_OK) - { - char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; - err = unzGetCurrentFileInfo64(file,NULL, - szCurrentFileName,sizeof(szCurrentFileName)-1, - NULL,0,NULL,0); - if (err == UNZ_OK) - { - if (unzStringFileNameCompare(szCurrentFileName, - szFileName,iCaseSensitivity)==0) - return UNZ_OK; - err = unzGoToNextFile(file); - } - } - - /* We failed, so restore the state of the 'current file' to where we - * were. - */ - s->num_file = num_fileSaved ; - s->pos_in_central_dir = pos_in_central_dirSaved ; - s->cur_file_info = cur_file_infoSaved; - s->cur_file_info_internal = cur_file_info_internalSaved; - return err; -} - - -/* -/////////////////////////////////////////// -// Contributed by Ryan Haksi (mailto://cryogen@infoserve.net) -// I need random access -// -// Further optimization could be realized by adding an ability -// to cache the directory in memory. The goal being a single -// comprehensive file read to put the file I need in a memory. -*/ - -/* -typedef struct unz_file_pos_s -{ - ZPOS64_T pos_in_zip_directory; // offset in file - ZPOS64_T num_of_file; // # of file -} unz_file_pos; -*/ - -extern int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos* file_pos) -{ - unz64_s* s; - - if (file==NULL || file_pos==NULL) - return UNZ_PARAMERROR; - s=(unz64_s*)file; - if (!s->current_file_ok) - return UNZ_END_OF_LIST_OF_FILE; - - file_pos->pos_in_zip_directory = s->pos_in_central_dir; - file_pos->num_of_file = s->num_file; - - return UNZ_OK; -} - -extern int ZEXPORT unzGetFilePos( - unzFile file, - unz_file_pos* file_pos) -{ - unz64_file_pos file_pos64; - int err = unzGetFilePos64(file,&file_pos64); - if (err==UNZ_OK) - { - file_pos->pos_in_zip_directory = (uLong)file_pos64.pos_in_zip_directory; - file_pos->num_of_file = (uLong)file_pos64.num_of_file; - } - return err; -} - -extern int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos* file_pos) -{ - unz64_s* s; - int err; - - if (file==NULL || file_pos==NULL) - return UNZ_PARAMERROR; - s=(unz64_s*)file; - - /* jump to the right spot */ - s->pos_in_central_dir = file_pos->pos_in_zip_directory; - s->num_file = file_pos->num_of_file; - - /* set the current file */ - err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info, - &s->cur_file_info_internal, - NULL,0,NULL,0,NULL,0); - /* return results */ - s->current_file_ok = (err == UNZ_OK); - return err; -} - -extern int ZEXPORT unzGoToFilePos( - unzFile file, - unz_file_pos* file_pos) -{ - unz64_file_pos file_pos64; - if (file_pos == NULL) - return UNZ_PARAMERROR; - - file_pos64.pos_in_zip_directory = file_pos->pos_in_zip_directory; - file_pos64.num_of_file = file_pos->num_of_file; - return unzGoToFilePos64(file,&file_pos64); -} - -/* -// Unzip Helper Functions - should be here? -/////////////////////////////////////////// -*/ - -/* - Read the local header of the current zipfile - Check the coherency of the local header and info in the end of central - directory about this file - store in *piSizeVar the size of extra info in local header - (filename and size of extra field data) -*/ -local int unz64local_CheckCurrentFileCoherencyHeader (unz64_s* s, uInt* piSizeVar, - ZPOS64_T * poffset_local_extrafield, - uInt * psize_local_extrafield) -{ - uLong uMagic,uData,uFlags; - uLong size_filename; - uLong size_extra_field; - int err=UNZ_OK; - - *piSizeVar = 0; - *poffset_local_extrafield = 0; - *psize_local_extrafield = 0; - - if (ZSEEK64(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile + - s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0) - return UNZ_ERRNO; - - - if (err==UNZ_OK) - { - if (unz64local_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) - err=UNZ_ERRNO; - else if (uMagic!=0x04034b50) - err=UNZ_BADZIPFILE; - } - - if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) - err=UNZ_ERRNO; -/* - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) - err=UNZ_BADZIPFILE; -*/ - if (unz64local_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK) - err=UNZ_ERRNO; - - if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method)) - err=UNZ_BADZIPFILE; - - if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) && -/* #ifdef HAVE_BZIP2 */ - (s->cur_file_info.compression_method!=Z_BZIP2ED) && -/* #endif */ - (s->cur_file_info.compression_method!=Z_DEFLATED)) - err=UNZ_BADZIPFILE; - - if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* date/time */ - err=UNZ_ERRNO; - - if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* crc */ - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && ((uFlags & 8)==0)) - err=UNZ_BADZIPFILE; - - if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size compr */ - err=UNZ_ERRNO; - else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && ((uFlags & 8)==0)) - err=UNZ_BADZIPFILE; - - if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size uncompr */ - err=UNZ_ERRNO; - else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && ((uFlags & 8)==0)) - err=UNZ_BADZIPFILE; - - if (unz64local_getShort(&s->z_filefunc, s->filestream,&size_filename) != UNZ_OK) - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename)) - err=UNZ_BADZIPFILE; - - *piSizeVar += (uInt)size_filename; - - if (unz64local_getShort(&s->z_filefunc, s->filestream,&size_extra_field) != UNZ_OK) - err=UNZ_ERRNO; - *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile + - SIZEZIPLOCALHEADER + size_filename; - *psize_local_extrafield = (uInt)size_extra_field; - - *piSizeVar += (uInt)size_extra_field; - - return err; -} - -/* - Open for reading data the current file in the zipfile. - If there is no error and the file is opened, the return value is UNZ_OK. -*/ -extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method, - int* level, int raw, const char* password) -{ - int err=UNZ_OK; - uInt iSizeVar; - unz64_s* s; - file_in_zip64_read_info_s* pfile_in_zip_read_info; - ZPOS64_T offset_local_extrafield; /* offset of the local extra field */ - uInt size_local_extrafield; /* size of the local extra field */ -# ifndef NOUNCRYPT - char source[12]; -# else - if (password != NULL) - return UNZ_PARAMERROR; -# endif - - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz64_s*)file; - if (!s->current_file_ok) - return UNZ_PARAMERROR; - - if (s->pfile_in_zip_read != NULL) - unzCloseCurrentFile(file); - - if (unz64local_CheckCurrentFileCoherencyHeader(s,&iSizeVar, &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) - return UNZ_BADZIPFILE; - - pfile_in_zip_read_info = (file_in_zip64_read_info_s*)ALLOC(sizeof(file_in_zip64_read_info_s)); - if (pfile_in_zip_read_info==NULL) - return UNZ_INTERNALERROR; - - pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE); - pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield; - pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield; - pfile_in_zip_read_info->pos_local_extrafield=0; - pfile_in_zip_read_info->raw=raw; - - if (pfile_in_zip_read_info->read_buffer==NULL) - { - TRYFREE(pfile_in_zip_read_info); - return UNZ_INTERNALERROR; - } - - pfile_in_zip_read_info->stream_initialised=0; - - if (method!=NULL) - *method = (int)s->cur_file_info.compression_method; - - if (level!=NULL) - { - *level = 6; - switch (s->cur_file_info.flag & 0x06) - { - case 6 : *level = 1; break; - case 4 : *level = 2; break; - case 2 : *level = 9; break; - } - } - - if ((s->cur_file_info.compression_method!=0) && -/* #ifdef HAVE_BZIP2 */ - (s->cur_file_info.compression_method!=Z_BZIP2ED) && -/* #endif */ - (s->cur_file_info.compression_method!=Z_DEFLATED)) - - err=UNZ_BADZIPFILE; - - pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc; - pfile_in_zip_read_info->crc32=0; - pfile_in_zip_read_info->total_out_64=0; - pfile_in_zip_read_info->compression_method = s->cur_file_info.compression_method; - pfile_in_zip_read_info->filestream=s->filestream; - pfile_in_zip_read_info->z_filefunc=s->z_filefunc; - pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile; - - pfile_in_zip_read_info->stream.total_out = 0; - - if ((s->cur_file_info.compression_method==Z_BZIP2ED) && (!raw)) - { -#ifdef HAVE_BZIP2 - pfile_in_zip_read_info->bstream.bzalloc = (void *(*) (void *, int, int))0; - pfile_in_zip_read_info->bstream.bzfree = (free_func)0; - pfile_in_zip_read_info->bstream.opaque = (voidpf)0; - pfile_in_zip_read_info->bstream.state = (voidpf)0; - - pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; - pfile_in_zip_read_info->stream.zfree = (free_func)0; - pfile_in_zip_read_info->stream.opaque = (voidpf)0; - pfile_in_zip_read_info->stream.next_in = (voidpf)0; - pfile_in_zip_read_info->stream.avail_in = 0; - - err=BZ2_bzDecompressInit(&pfile_in_zip_read_info->bstream, 0, 0); - if (err == Z_OK) - pfile_in_zip_read_info->stream_initialised=Z_BZIP2ED; - else - { - TRYFREE(pfile_in_zip_read_info); - return err; - } -#else - pfile_in_zip_read_info->raw=1; -#endif - } - else if ((s->cur_file_info.compression_method==Z_DEFLATED) && (!raw)) - { - pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; - pfile_in_zip_read_info->stream.zfree = (free_func)0; - pfile_in_zip_read_info->stream.opaque = (voidpf)0; - pfile_in_zip_read_info->stream.next_in = 0; - pfile_in_zip_read_info->stream.avail_in = 0; - - err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); - if (err == Z_OK) - pfile_in_zip_read_info->stream_initialised=Z_DEFLATED; - else - { - TRYFREE(pfile_in_zip_read_info); - return err; - } - /* windowBits is passed < 0 to tell that there is no zlib header. - * Note that in this case inflate *requires* an extra "dummy" byte - * after the compressed stream in order to complete decompression and - * return Z_STREAM_END. - * In unzip, i don't wait absolutely Z_STREAM_END because I known the - * size of both compressed and uncompressed data - */ - } - pfile_in_zip_read_info->rest_read_compressed = - s->cur_file_info.compressed_size ; - pfile_in_zip_read_info->rest_read_uncompressed = - s->cur_file_info.uncompressed_size ; - - - pfile_in_zip_read_info->pos_in_zipfile = - s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + - iSizeVar; - - pfile_in_zip_read_info->stream.avail_in = (uInt)0; - - s->pfile_in_zip_read = pfile_in_zip_read_info; - s->encrypted = 0; - -# ifndef NOUNCRYPT - if (password != NULL) - { - int i; - s->pcrc_32_tab = get_crc_table(); - init_keys(password,s->keys,s->pcrc_32_tab); - if (ZSEEK64(s->z_filefunc, s->filestream, - s->pfile_in_zip_read->pos_in_zipfile + - s->pfile_in_zip_read->byte_before_the_zipfile, - SEEK_SET)!=0) - return UNZ_INTERNALERROR; - if(ZREAD64(s->z_filefunc, s->filestream,source, 12)<12) - return UNZ_INTERNALERROR; - - for (i = 0; i<12; i++) - zdecode(s->keys,s->pcrc_32_tab,source[i]); - - s->pfile_in_zip_read->pos_in_zipfile+=12; - s->encrypted=1; - } -# endif - - - return UNZ_OK; -} - -extern int ZEXPORT unzOpenCurrentFile (unzFile file) -{ - return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL); -} - -extern int ZEXPORT unzOpenCurrentFilePassword (unzFile file, const char* password) -{ - return unzOpenCurrentFile3(file, NULL, NULL, 0, password); -} - -extern int ZEXPORT unzOpenCurrentFile2 (unzFile file, int* method, int* level, int raw) -{ - return unzOpenCurrentFile3(file, method, level, raw, NULL); -} - -/** Addition for GDAL : START */ - -extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64( unzFile file) -{ - unz64_s* s; - file_in_zip64_read_info_s* pfile_in_zip_read_info; - s=(unz64_s*)file; - if (file==NULL) - return 0; //UNZ_PARAMERROR; - pfile_in_zip_read_info=s->pfile_in_zip_read; - if (pfile_in_zip_read_info==NULL) - return 0; //UNZ_PARAMERROR; - return pfile_in_zip_read_info->pos_in_zipfile + - pfile_in_zip_read_info->byte_before_the_zipfile; -} - -/** Addition for GDAL : END */ - -/* - Read bytes from the current file. - buf contain buffer where data must be copied - len the size of buf. - - return the number of byte copied if somes bytes are copied - return 0 if the end of file was reached - return <0 with error code if there is an error - (UNZ_ERRNO for IO error, or zLib error for uncompress error) -*/ -extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len) -{ - int err=UNZ_OK; - uInt iRead = 0; - unz64_s* s; - file_in_zip64_read_info_s* pfile_in_zip_read_info; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz64_s*)file; - pfile_in_zip_read_info=s->pfile_in_zip_read; - - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; - - - if (pfile_in_zip_read_info->read_buffer == NULL) - return UNZ_END_OF_LIST_OF_FILE; - if (len==0) - return 0; - - pfile_in_zip_read_info->stream.next_out = (Bytef*)buf; - - pfile_in_zip_read_info->stream.avail_out = (uInt)len; - - if ((len>pfile_in_zip_read_info->rest_read_uncompressed) && - (!(pfile_in_zip_read_info->raw))) - pfile_in_zip_read_info->stream.avail_out = - (uInt)pfile_in_zip_read_info->rest_read_uncompressed; - - if ((len>pfile_in_zip_read_info->rest_read_compressed+ - pfile_in_zip_read_info->stream.avail_in) && - (pfile_in_zip_read_info->raw)) - pfile_in_zip_read_info->stream.avail_out = - (uInt)pfile_in_zip_read_info->rest_read_compressed+ - pfile_in_zip_read_info->stream.avail_in; - - while (pfile_in_zip_read_info->stream.avail_out>0) - { - if ((pfile_in_zip_read_info->stream.avail_in==0) && - (pfile_in_zip_read_info->rest_read_compressed>0)) - { - uInt uReadThis = UNZ_BUFSIZE; - if (pfile_in_zip_read_info->rest_read_compressedrest_read_compressed; - if (uReadThis == 0) - return UNZ_EOF; - if (ZSEEK64(pfile_in_zip_read_info->z_filefunc, - pfile_in_zip_read_info->filestream, - pfile_in_zip_read_info->pos_in_zipfile + - pfile_in_zip_read_info->byte_before_the_zipfile, - ZLIB_FILEFUNC_SEEK_SET)!=0) - return UNZ_ERRNO; - if (ZREAD64(pfile_in_zip_read_info->z_filefunc, - pfile_in_zip_read_info->filestream, - pfile_in_zip_read_info->read_buffer, - uReadThis)!=uReadThis) - return UNZ_ERRNO; - - -# ifndef NOUNCRYPT - if(s->encrypted) - { - uInt i; - for(i=0;iread_buffer[i] = - zdecode(s->keys,s->pcrc_32_tab, - pfile_in_zip_read_info->read_buffer[i]); - } -# endif - - - pfile_in_zip_read_info->pos_in_zipfile += uReadThis; - - pfile_in_zip_read_info->rest_read_compressed-=uReadThis; - - pfile_in_zip_read_info->stream.next_in = - (Bytef*)pfile_in_zip_read_info->read_buffer; - pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis; - } - - if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw)) - { - uInt uDoCopy,i ; - - if ((pfile_in_zip_read_info->stream.avail_in == 0) && - (pfile_in_zip_read_info->rest_read_compressed == 0)) - return (iRead==0) ? UNZ_EOF : (int)iRead; - - if (pfile_in_zip_read_info->stream.avail_out < - pfile_in_zip_read_info->stream.avail_in) - uDoCopy = pfile_in_zip_read_info->stream.avail_out ; - else - uDoCopy = pfile_in_zip_read_info->stream.avail_in ; - - for (i=0;istream.next_out+i) = - *(pfile_in_zip_read_info->stream.next_in+i); - - pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uDoCopy; - - pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32, - pfile_in_zip_read_info->stream.next_out, - uDoCopy); - pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy; - pfile_in_zip_read_info->stream.avail_in -= uDoCopy; - pfile_in_zip_read_info->stream.avail_out -= uDoCopy; - pfile_in_zip_read_info->stream.next_out += uDoCopy; - pfile_in_zip_read_info->stream.next_in += uDoCopy; - pfile_in_zip_read_info->stream.total_out += uDoCopy; - iRead += uDoCopy; - } - else if (pfile_in_zip_read_info->compression_method==Z_BZIP2ED) - { -#ifdef HAVE_BZIP2 - uLong uTotalOutBefore,uTotalOutAfter; - const Bytef *bufBefore; - uLong uOutThis; - - pfile_in_zip_read_info->bstream.next_in = (char*)pfile_in_zip_read_info->stream.next_in; - pfile_in_zip_read_info->bstream.avail_in = pfile_in_zip_read_info->stream.avail_in; - pfile_in_zip_read_info->bstream.total_in_lo32 = pfile_in_zip_read_info->stream.total_in; - pfile_in_zip_read_info->bstream.total_in_hi32 = 0; - pfile_in_zip_read_info->bstream.next_out = (char*)pfile_in_zip_read_info->stream.next_out; - pfile_in_zip_read_info->bstream.avail_out = pfile_in_zip_read_info->stream.avail_out; - pfile_in_zip_read_info->bstream.total_out_lo32 = pfile_in_zip_read_info->stream.total_out; - pfile_in_zip_read_info->bstream.total_out_hi32 = 0; - - uTotalOutBefore = pfile_in_zip_read_info->bstream.total_out_lo32; - bufBefore = (const Bytef *)pfile_in_zip_read_info->bstream.next_out; - - err=BZ2_bzDecompress(&pfile_in_zip_read_info->bstream); - - uTotalOutAfter = pfile_in_zip_read_info->bstream.total_out_lo32; - uOutThis = uTotalOutAfter-uTotalOutBefore; - - pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis; - - pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,bufBefore, (uInt)(uOutThis)); - pfile_in_zip_read_info->rest_read_uncompressed -= uOutThis; - iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); - - pfile_in_zip_read_info->stream.next_in = (Bytef*)pfile_in_zip_read_info->bstream.next_in; - pfile_in_zip_read_info->stream.avail_in = pfile_in_zip_read_info->bstream.avail_in; - pfile_in_zip_read_info->stream.total_in = pfile_in_zip_read_info->bstream.total_in_lo32; - pfile_in_zip_read_info->stream.next_out = (Bytef*)pfile_in_zip_read_info->bstream.next_out; - pfile_in_zip_read_info->stream.avail_out = pfile_in_zip_read_info->bstream.avail_out; - pfile_in_zip_read_info->stream.total_out = pfile_in_zip_read_info->bstream.total_out_lo32; - - if (err==BZ_STREAM_END) - return (iRead==0) ? UNZ_EOF : iRead; - if (err!=BZ_OK) - break; -#endif - } // end Z_BZIP2ED - else - { - ZPOS64_T uTotalOutBefore,uTotalOutAfter; - const Bytef *bufBefore; - ZPOS64_T uOutThis; - int flush=Z_SYNC_FLUSH; - - uTotalOutBefore = pfile_in_zip_read_info->stream.total_out; - bufBefore = pfile_in_zip_read_info->stream.next_out; - - /* - if ((pfile_in_zip_read_info->rest_read_uncompressed == - pfile_in_zip_read_info->stream.avail_out) && - (pfile_in_zip_read_info->rest_read_compressed == 0)) - flush = Z_FINISH; - */ - err=inflate(&pfile_in_zip_read_info->stream,flush); - - if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL)) - err = Z_DATA_ERROR; - - uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; - /* Detect overflow, because z_stream.total_out is uLong (32 bits) */ - if (uTotalOutAftertotal_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis; - - pfile_in_zip_read_info->crc32 = - crc32(pfile_in_zip_read_info->crc32,bufBefore, - (uInt)(uOutThis)); - - pfile_in_zip_read_info->rest_read_uncompressed -= - uOutThis; - - iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); - - if (err==Z_STREAM_END) - return (iRead==0) ? UNZ_EOF : (int)iRead; - if (err!=Z_OK) - break; - } - } - - if (err==Z_OK) - return (int)iRead; - return err; -} - - -/* - Give the current position in uncompressed data -*/ -extern z_off_t ZEXPORT unztell (unzFile file) -{ - unz64_s* s; - file_in_zip64_read_info_s* pfile_in_zip_read_info; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz64_s*)file; - pfile_in_zip_read_info=s->pfile_in_zip_read; - - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; - - return (z_off_t)pfile_in_zip_read_info->stream.total_out; -} - -extern ZPOS64_T ZEXPORT unztell64 (unzFile file) -{ - - unz64_s* s; - file_in_zip64_read_info_s* pfile_in_zip_read_info; - if (file==NULL) - return (ZPOS64_T)-1; - s=(unz64_s*)file; - pfile_in_zip_read_info=s->pfile_in_zip_read; - - if (pfile_in_zip_read_info==NULL) - return (ZPOS64_T)-1; - - return pfile_in_zip_read_info->total_out_64; -} - - -/* - return 1 if the end of file was reached, 0 elsewhere -*/ -extern int ZEXPORT unzeof (unzFile file) -{ - unz64_s* s; - file_in_zip64_read_info_s* pfile_in_zip_read_info; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz64_s*)file; - pfile_in_zip_read_info=s->pfile_in_zip_read; - - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; - - if (pfile_in_zip_read_info->rest_read_uncompressed == 0) - return 1; - else - return 0; -} - - - -/* -Read extra field from the current file (opened by unzOpenCurrentFile) -This is the local-header version of the extra field (sometimes, there is -more info in the local-header version than in the central-header) - - if buf==NULL, it return the size of the local extra field that can be read - - if buf!=NULL, len is the size of the buffer, the extra header is copied in - buf. - the return value is the number of bytes copied in buf, or (if <0) - the error code -*/ -extern int ZEXPORT unzGetLocalExtrafield (unzFile file, voidp buf, unsigned len) -{ - unz64_s* s; - file_in_zip64_read_info_s* pfile_in_zip_read_info; - uInt read_now; - ZPOS64_T size_to_read; - - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz64_s*)file; - pfile_in_zip_read_info=s->pfile_in_zip_read; - - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; - - size_to_read = (pfile_in_zip_read_info->size_local_extrafield - - pfile_in_zip_read_info->pos_local_extrafield); - - if (buf==NULL) - return (int)size_to_read; - - if (len>size_to_read) - read_now = (uInt)size_to_read; - else - read_now = (uInt)len ; - - if (read_now==0) - return 0; - - if (ZSEEK64(pfile_in_zip_read_info->z_filefunc, - pfile_in_zip_read_info->filestream, - pfile_in_zip_read_info->offset_local_extrafield + - pfile_in_zip_read_info->pos_local_extrafield, - ZLIB_FILEFUNC_SEEK_SET)!=0) - return UNZ_ERRNO; - - if (ZREAD64(pfile_in_zip_read_info->z_filefunc, - pfile_in_zip_read_info->filestream, - buf,read_now)!=read_now) - return UNZ_ERRNO; - - return (int)read_now; -} - -/* - Close the file in zip opened with unzOpenCurrentFile - Return UNZ_CRCERROR if all the file was read but the CRC is not good -*/ -extern int ZEXPORT unzCloseCurrentFile (unzFile file) -{ - int err=UNZ_OK; - - unz64_s* s; - file_in_zip64_read_info_s* pfile_in_zip_read_info; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz64_s*)file; - pfile_in_zip_read_info=s->pfile_in_zip_read; - - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; - - - if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) && - (!pfile_in_zip_read_info->raw)) - { - if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) - err=UNZ_CRCERROR; - } - - - TRYFREE(pfile_in_zip_read_info->read_buffer); - pfile_in_zip_read_info->read_buffer = NULL; - if (pfile_in_zip_read_info->stream_initialised == Z_DEFLATED) - inflateEnd(&pfile_in_zip_read_info->stream); -#ifdef HAVE_BZIP2 - else if (pfile_in_zip_read_info->stream_initialised == Z_BZIP2ED) - BZ2_bzDecompressEnd(&pfile_in_zip_read_info->bstream); -#endif - - - pfile_in_zip_read_info->stream_initialised = 0; - TRYFREE(pfile_in_zip_read_info); - - s->pfile_in_zip_read=NULL; - - return err; -} - - -/* - Get the global comment string of the ZipFile, in the szComment buffer. - uSizeBuf is the size of the szComment buffer. - return the number of byte copied or an error code <0 -*/ -extern int ZEXPORT unzGetGlobalComment (unzFile file, char * szComment, uLong uSizeBuf) -{ - unz64_s* s; - uLong uReadThis ; - if (file==NULL) - return (int)UNZ_PARAMERROR; - s=(unz64_s*)file; - - uReadThis = uSizeBuf; - if (uReadThis>s->gi.size_comment) - uReadThis = s->gi.size_comment; - - if (ZSEEK64(s->z_filefunc,s->filestream,s->central_pos+22,ZLIB_FILEFUNC_SEEK_SET)!=0) - return UNZ_ERRNO; - - if (uReadThis>0) - { - *szComment='\0'; - if (ZREAD64(s->z_filefunc,s->filestream,szComment,uReadThis)!=uReadThis) - return UNZ_ERRNO; - } - - if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment)) - *(szComment+s->gi.size_comment)='\0'; - return (int)uReadThis; -} - -/* Additions by RX '2004 */ -extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file) -{ - unz64_s* s; - - if (file==NULL) - return 0; //UNZ_PARAMERROR; - s=(unz64_s*)file; - if (!s->current_file_ok) - return 0; - if (s->gi.number_entry != 0 && s->gi.number_entry != 0xffff) - if (s->num_file==s->gi.number_entry) - return 0; - return s->pos_in_central_dir; -} - -extern uLong ZEXPORT unzGetOffset (unzFile file) -{ - ZPOS64_T offset64; - - if (file==NULL) - return 0; //UNZ_PARAMERROR; - offset64 = unzGetOffset64(file); - return (uLong)offset64; -} - -extern int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos) -{ - unz64_s* s; - int err; - - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz64_s*)file; - - s->pos_in_central_dir = pos; - s->num_file = s->gi.number_entry; /* hack */ - err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info, - &s->cur_file_info_internal, - NULL,0,NULL,0,NULL,0); - s->current_file_ok = (err == UNZ_OK); - return err; -} - -extern int ZEXPORT unzSetOffset (unzFile file, uLong pos) -{ - return unzSetOffset64(file,pos); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/unzip.h b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/unzip.h deleted file mode 100644 index 6f95e94..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/unzip.h +++ /dev/null @@ -1,437 +0,0 @@ -/* unzip.h -- IO for uncompress .zip files using zlib - Version 1.1, February 14h, 2010 - part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) - - Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) - - Modifications of Unzip for Zip64 - Copyright (C) 2007-2008 Even Rouault - - Modifications for Zip64 support on both zip and unzip - Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) - - For more info read MiniZip_info.txt - - --------------------------------------------------------------------------------- - - Condition of use and distribution are the same than zlib : - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - --------------------------------------------------------------------------------- - - Changes - - See header of unzip64.c - -*/ - -#ifndef _unz64_H -#define _unz64_H - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _ZLIB_H -#include "zlib.h" -#endif - -#ifndef _ZLIBIOAPI_H -#include "ioapi.h" -#endif - -#ifdef HAVE_BZIP2 -#include "bzlib.h" -#endif - -#define Z_BZIP2ED 12 - -#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) -/* like the STRICT of WIN32, we define a pointer that cannot be converted - from (void*) without cast */ -typedef struct TagunzFile__ { int unused; } unzFile__; -typedef unzFile__ *unzFile; -#else -typedef voidp unzFile; -#endif - - -#define UNZ_OK (0) -#define UNZ_END_OF_LIST_OF_FILE (-100) -#define UNZ_ERRNO (Z_ERRNO) -#define UNZ_EOF (0) -#define UNZ_PARAMERROR (-102) -#define UNZ_BADZIPFILE (-103) -#define UNZ_INTERNALERROR (-104) -#define UNZ_CRCERROR (-105) - -/* tm_unz contain date/time info */ -typedef struct tm_unz_s -{ - int tm_sec; /* seconds after the minute - [0,59] */ - int tm_min; /* minutes after the hour - [0,59] */ - int tm_hour; /* hours since midnight - [0,23] */ - int tm_mday; /* day of the month - [1,31] */ - int tm_mon; /* months since January - [0,11] */ - int tm_year; /* years - [1980..2044] */ -} tm_unz; - -/* unz_global_info structure contain global data about the ZIPfile - These data comes from the end of central dir */ -typedef struct unz_global_info64_s -{ - ZPOS64_T number_entry; /* total number of entries in - the central dir on this disk */ - uLong size_comment; /* size of the global comment of the zipfile */ -} unz_global_info64; - -typedef struct unz_global_info_s -{ - uLong number_entry; /* total number of entries in - the central dir on this disk */ - uLong size_comment; /* size of the global comment of the zipfile */ -} unz_global_info; - -/* unz_file_info contain information about a file in the zipfile */ -typedef struct unz_file_info64_s -{ - uLong version; /* version made by 2 bytes */ - uLong version_needed; /* version needed to extract 2 bytes */ - uLong flag; /* general purpose bit flag 2 bytes */ - uLong compression_method; /* compression method 2 bytes */ - uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ - uLong crc; /* crc-32 4 bytes */ - ZPOS64_T compressed_size; /* compressed size 8 bytes */ - ZPOS64_T uncompressed_size; /* uncompressed size 8 bytes */ - uLong size_filename; /* filename length 2 bytes */ - uLong size_file_extra; /* extra field length 2 bytes */ - uLong size_file_comment; /* file comment length 2 bytes */ - - uLong disk_num_start; /* disk number start 2 bytes */ - uLong internal_fa; /* internal file attributes 2 bytes */ - uLong external_fa; /* external file attributes 4 bytes */ - - tm_unz tmu_date; -} unz_file_info64; - -typedef struct unz_file_info_s -{ - uLong version; /* version made by 2 bytes */ - uLong version_needed; /* version needed to extract 2 bytes */ - uLong flag; /* general purpose bit flag 2 bytes */ - uLong compression_method; /* compression method 2 bytes */ - uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ - uLong crc; /* crc-32 4 bytes */ - uLong compressed_size; /* compressed size 4 bytes */ - uLong uncompressed_size; /* uncompressed size 4 bytes */ - uLong size_filename; /* filename length 2 bytes */ - uLong size_file_extra; /* extra field length 2 bytes */ - uLong size_file_comment; /* file comment length 2 bytes */ - - uLong disk_num_start; /* disk number start 2 bytes */ - uLong internal_fa; /* internal file attributes 2 bytes */ - uLong external_fa; /* external file attributes 4 bytes */ - - tm_unz tmu_date; -} unz_file_info; - -extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, - const char* fileName2, - int iCaseSensitivity)); -/* - Compare two filename (fileName1,fileName2). - If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) - If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi - or strcasecmp) - If iCaseSenisivity = 0, case sensitivity is defaut of your operating system - (like 1 on Unix, 2 on Windows) -*/ - - -extern unzFile ZEXPORT unzOpen OF((const char *path)); -extern unzFile ZEXPORT unzOpen64 OF((const void *path)); -/* - Open a Zip file. path contain the full pathname (by example, - on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer - "zlib/zlib113.zip". - If the zipfile cannot be opened (file don't exist or in not valid), the - return value is NULL. - Else, the return value is a unzFile Handle, usable with other function - of this unzip package. - the "64" function take a const void* pointer, because the path is just the - value passed to the open64_file_func callback. - Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path - is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char* - does not describe the reality -*/ - - -extern unzFile ZEXPORT unzOpen2 OF((const char *path, - zlib_filefunc_def* pzlib_filefunc_def)); -/* - Open a Zip file, like unzOpen, but provide a set of file low level API - for read/write the zip file (see ioapi.h) -*/ - -extern unzFile ZEXPORT unzOpen2_64 OF((const void *path, - zlib_filefunc64_def* pzlib_filefunc_def)); -/* - Open a Zip file, like unz64Open, but provide a set of file low level API - for read/write the zip file (see ioapi.h) -*/ - -extern int ZEXPORT unzClose OF((unzFile file)); -/* - Close a ZipFile opened with unzOpen. - If there is files inside the .Zip opened with unzOpenCurrentFile (see later), - these files MUST be closed with unzCloseCurrentFile before call unzClose. - return UNZ_OK if there is no problem. */ - -extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, - unz_global_info *pglobal_info)); - -extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file, - unz_global_info64 *pglobal_info)); -/* - Write info about the ZipFile in the *pglobal_info structure. - No preparation of the structure is needed - return UNZ_OK if there is no problem. */ - - -extern int ZEXPORT unzGetGlobalComment OF((unzFile file, - char *szComment, - uLong uSizeBuf)); -/* - Get the global comment string of the ZipFile, in the szComment buffer. - uSizeBuf is the size of the szComment buffer. - return the number of byte copied or an error code <0 -*/ - - -/***************************************************************************/ -/* Unzip package allow you browse the directory of the zipfile */ - -extern int ZEXPORT unzGoToFirstFile OF((unzFile file)); -/* - Set the current file of the zipfile to the first file. - return UNZ_OK if there is no problem -*/ - -extern int ZEXPORT unzGoToNextFile OF((unzFile file)); -/* - Set the current file of the zipfile to the next file. - return UNZ_OK if there is no problem - return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. -*/ - -extern int ZEXPORT unzLocateFile OF((unzFile file, - const char *szFileName, - int iCaseSensitivity)); -/* - Try locate the file szFileName in the zipfile. - For the iCaseSensitivity signification, see unzStringFileNameCompare - - return value : - UNZ_OK if the file is found. It becomes the current file. - UNZ_END_OF_LIST_OF_FILE if the file is not found -*/ - - -/* ****************************************** */ -/* Ryan supplied functions */ -/* unz_file_info contain information about a file in the zipfile */ -typedef struct unz_file_pos_s -{ - uLong pos_in_zip_directory; /* offset in zip file directory */ - uLong num_of_file; /* # of file */ -} unz_file_pos; - -extern int ZEXPORT unzGetFilePos( - unzFile file, - unz_file_pos* file_pos); - -extern int ZEXPORT unzGoToFilePos( - unzFile file, - unz_file_pos* file_pos); - -typedef struct unz64_file_pos_s -{ - ZPOS64_T pos_in_zip_directory; /* offset in zip file directory */ - ZPOS64_T num_of_file; /* # of file */ -} unz64_file_pos; - -extern int ZEXPORT unzGetFilePos64( - unzFile file, - unz64_file_pos* file_pos); - -extern int ZEXPORT unzGoToFilePos64( - unzFile file, - const unz64_file_pos* file_pos); - -/* ****************************************** */ - -extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file, - unz_file_info64 *pfile_info, - char *szFileName, - uLong fileNameBufferSize, - void *extraField, - uLong extraFieldBufferSize, - char *szComment, - uLong commentBufferSize)); - -extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, - unz_file_info *pfile_info, - char *szFileName, - uLong fileNameBufferSize, - void *extraField, - uLong extraFieldBufferSize, - char *szComment, - uLong commentBufferSize)); -/* - Get Info about the current file - if pfile_info!=NULL, the *pfile_info structure will contain somes info about - the current file - if szFileName!=NULL, the filemane string will be copied in szFileName - (fileNameBufferSize is the size of the buffer) - if extraField!=NULL, the extra field information will be copied in extraField - (extraFieldBufferSize is the size of the buffer). - This is the Central-header version of the extra field - if szComment!=NULL, the comment string of the file will be copied in szComment - (commentBufferSize is the size of the buffer) -*/ - - -/** Addition for GDAL : START */ - -extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file)); - -/** Addition for GDAL : END */ - - -/***************************************************************************/ -/* for reading the content of the current zipfile, you can open it, read data - from it, and close it (you can close it before reading all the file) - */ - -extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); -/* - Open for reading data the current file in the zipfile. - If there is no error, the return value is UNZ_OK. -*/ - -extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file, - const char* password)); -/* - Open for reading data the current file in the zipfile. - password is a crypting password - If there is no error, the return value is UNZ_OK. -*/ - -extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file, - int* method, - int* level, - int raw)); -/* - Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) - if raw==1 - *method will receive method of compression, *level will receive level of - compression - note : you can set level parameter as NULL (if you did not want known level, - but you CANNOT set method parameter as NULL -*/ - -extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file, - int* method, - int* level, - int raw, - const char* password)); -/* - Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) - if raw==1 - *method will receive method of compression, *level will receive level of - compression - note : you can set level parameter as NULL (if you did not want known level, - but you CANNOT set method parameter as NULL -*/ - - -extern int ZEXPORT unzCloseCurrentFile OF((unzFile file)); -/* - Close the file in zip opened with unzOpenCurrentFile - Return UNZ_CRCERROR if all the file was read but the CRC is not good -*/ - -extern int ZEXPORT unzReadCurrentFile OF((unzFile file, - voidp buf, - unsigned len)); -/* - Read bytes from the current file (opened by unzOpenCurrentFile) - buf contain buffer where data must be copied - len the size of buf. - - return the number of byte copied if somes bytes are copied - return 0 if the end of file was reached - return <0 with error code if there is an error - (UNZ_ERRNO for IO error, or zLib error for uncompress error) -*/ - -extern z_off_t ZEXPORT unztell OF((unzFile file)); - -extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file)); -/* - Give the current position in uncompressed data -*/ - -extern int ZEXPORT unzeof OF((unzFile file)); -/* - return 1 if the end of file was reached, 0 elsewhere -*/ - -extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, - voidp buf, - unsigned len)); -/* - Read extra field from the current file (opened by unzOpenCurrentFile) - This is the local-header version of the extra field (sometimes, there is - more info in the local-header version than in the central-header) - - if buf==NULL, it return the size of the local extra field - - if buf!=NULL, len is the size of the buffer, the extra header is copied in - buf. - the return value is the number of bytes copied in buf, or (if <0) - the error code -*/ - -/***************************************************************************/ - -/* Get the current file offset */ -extern ZPOS64_T ZEXPORT unzGetOffset64 (unzFile file); -extern uLong ZEXPORT unzGetOffset (unzFile file); - -/* Set the current file offset */ -extern int ZEXPORT unzSetOffset64 (unzFile file, ZPOS64_T pos); -extern int ZEXPORT unzSetOffset (unzFile file, uLong pos); - - - -#ifdef __cplusplus -} -#endif - -#endif /* _unz64_H */ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/zip.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/zip.c deleted file mode 100644 index 4e611e1..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/zip.c +++ /dev/null @@ -1,2007 +0,0 @@ -/* zip.c -- IO on .zip files using zlib - Version 1.1, February 14h, 2010 - part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) - - Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) - - Modifications for Zip64 support - Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) - - For more info read MiniZip_info.txt - - Changes - Oct-2009 - Mathias Svensson - Remove old C style function prototypes - Oct-2009 - Mathias Svensson - Added Zip64 Support when creating new file archives - Oct-2009 - Mathias Svensson - Did some code cleanup and refactoring to get better overview of some functions. - Oct-2009 - Mathias Svensson - Added zipRemoveExtraInfoBlock to strip extra field data from its ZIP64 data - It is used when recreting zip archive with RAW when deleting items from a zip. - ZIP64 data is automatically added to items that needs it, and existing ZIP64 data need to be removed. - Oct-2009 - Mathias Svensson - Added support for BZIP2 as compression mode (bzip2 lib is required) - Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer - -*/ - - -#include -#include -#include -#include -#include "zlib.h" -#include "zip.h" - -#ifdef STDC -# include -# include -# include -#endif -#ifdef NO_ERRNO_H - extern int errno; -#else -# include -#endif - - -#ifndef local -# define local static -#endif -/* compile with -Dlocal if your debugger can't find static symbols */ - -#ifndef VERSIONMADEBY -# define VERSIONMADEBY (0x0) /* platform depedent */ -#endif - -#ifndef Z_BUFSIZE -#define Z_BUFSIZE (64*1024) //(16384) -#endif - -#ifndef Z_MAXFILENAMEINZIP -#define Z_MAXFILENAMEINZIP (256) -#endif - -#ifndef ALLOC -# define ALLOC(size) (malloc(size)) -#endif -#ifndef TRYFREE -# define TRYFREE(p) {if (p) free(p);} -#endif - -/* -#define SIZECENTRALDIRITEM (0x2e) -#define SIZEZIPLOCALHEADER (0x1e) -*/ - -/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ - - -// NOT sure that this work on ALL platform -#define MAKEULONG64(a, b) ((ZPOS64_T)(((unsigned long)(a)) | ((ZPOS64_T)((unsigned long)(b))) << 32)) - -#ifndef SEEK_CUR -#define SEEK_CUR 1 -#endif - -#ifndef SEEK_END -#define SEEK_END 2 -#endif - -#ifndef SEEK_SET -#define SEEK_SET 0 -#endif - -#ifndef DEF_MEM_LEVEL -#if MAX_MEM_LEVEL >= 8 -# define DEF_MEM_LEVEL 8 -#else -# define DEF_MEM_LEVEL MAX_MEM_LEVEL -#endif -#endif -const char zip_copyright[] =" zip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll"; - - -#define SIZEDATA_INDATABLOCK (4096-(4*4)) - -#define LOCALHEADERMAGIC (0x04034b50) -#define CENTRALHEADERMAGIC (0x02014b50) -#define ENDHEADERMAGIC (0x06054b50) -#define ZIP64ENDHEADERMAGIC (0x6064b50) -#define ZIP64ENDLOCHEADERMAGIC (0x7064b50) - -#define FLAG_LOCALHEADER_OFFSET (0x06) -#define CRC_LOCALHEADER_OFFSET (0x0e) - -#define SIZECENTRALHEADER (0x2e) /* 46 */ - -typedef struct linkedlist_datablock_internal_s -{ - struct linkedlist_datablock_internal_s* next_datablock; - uLong avail_in_this_block; - uLong filled_in_this_block; - uLong unused; /* for future use and alignment */ - unsigned char data[SIZEDATA_INDATABLOCK]; -} linkedlist_datablock_internal; - -typedef struct linkedlist_data_s -{ - linkedlist_datablock_internal* first_block; - linkedlist_datablock_internal* last_block; -} linkedlist_data; - - -typedef struct -{ - z_stream stream; /* zLib stream structure for inflate */ -#ifdef HAVE_BZIP2 - bz_stream bstream; /* bzLib stream structure for bziped */ -#endif - - int stream_initialised; /* 1 is stream is initialised */ - uInt pos_in_buffered_data; /* last written byte in buffered_data */ - - ZPOS64_T pos_local_header; /* offset of the local header of the file - currenty writing */ - char* central_header; /* central header data for the current file */ - uLong size_centralExtra; - uLong size_centralheader; /* size of the central header for cur file */ - uLong size_centralExtraFree; /* Extra bytes allocated to the centralheader but that are not used */ - uLong flag; /* flag of the file currently writing */ - - int method; /* compression method of file currenty wr.*/ - int raw; /* 1 for directly writing raw data */ - Byte buffered_data[Z_BUFSIZE];/* buffer contain compressed data to be writ*/ - uLong dosDate; - uLong crc32; - int encrypt; - int zip64; /* Add ZIP64 extened information in the extra field */ - ZPOS64_T pos_zip64extrainfo; - ZPOS64_T totalCompressedData; - ZPOS64_T totalUncompressedData; -#ifndef NOCRYPT - unsigned long keys[3]; /* keys defining the pseudo-random sequence */ - const z_crc_t* pcrc_32_tab; - unsigned crypt_header_size; -#endif -} curfile64_info; - -typedef struct -{ - zlib_filefunc64_32_def z_filefunc; - voidpf filestream; /* io structore of the zipfile */ - linkedlist_data central_dir;/* datablock with central dir in construction*/ - int in_opened_file_inzip; /* 1 if a file in the zip is currently writ.*/ - curfile64_info ci; /* info on the file curretly writing */ - - ZPOS64_T begin_pos; /* position of the beginning of the zipfile */ - ZPOS64_T add_position_when_writing_offset; - ZPOS64_T number_entry; - -#ifndef NO_ADDFILEINEXISTINGZIP - char *globalcomment; -#endif - -} zip64_internal; - - -#ifndef NOCRYPT -#define INCLUDECRYPTINGCODE_IFCRYPTALLOWED -#include "crypt.h" -#endif - -local linkedlist_datablock_internal* allocate_new_datablock() -{ - linkedlist_datablock_internal* ldi; - ldi = (linkedlist_datablock_internal*) - ALLOC(sizeof(linkedlist_datablock_internal)); - if (ldi!=NULL) - { - ldi->next_datablock = NULL ; - ldi->filled_in_this_block = 0 ; - ldi->avail_in_this_block = SIZEDATA_INDATABLOCK ; - } - return ldi; -} - -local void free_datablock(linkedlist_datablock_internal* ldi) -{ - while (ldi!=NULL) - { - linkedlist_datablock_internal* ldinext = ldi->next_datablock; - TRYFREE(ldi); - ldi = ldinext; - } -} - -local void init_linkedlist(linkedlist_data* ll) -{ - ll->first_block = ll->last_block = NULL; -} - -local void free_linkedlist(linkedlist_data* ll) -{ - free_datablock(ll->first_block); - ll->first_block = ll->last_block = NULL; -} - - -local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len) -{ - linkedlist_datablock_internal* ldi; - const unsigned char* from_copy; - - if (ll==NULL) - return ZIP_INTERNALERROR; - - if (ll->last_block == NULL) - { - ll->first_block = ll->last_block = allocate_new_datablock(); - if (ll->first_block == NULL) - return ZIP_INTERNALERROR; - } - - ldi = ll->last_block; - from_copy = (unsigned char*)buf; - - while (len>0) - { - uInt copy_this; - uInt i; - unsigned char* to_copy; - - if (ldi->avail_in_this_block==0) - { - ldi->next_datablock = allocate_new_datablock(); - if (ldi->next_datablock == NULL) - return ZIP_INTERNALERROR; - ldi = ldi->next_datablock ; - ll->last_block = ldi; - } - - if (ldi->avail_in_this_block < len) - copy_this = (uInt)ldi->avail_in_this_block; - else - copy_this = (uInt)len; - - to_copy = &(ldi->data[ldi->filled_in_this_block]); - - for (i=0;ifilled_in_this_block += copy_this; - ldi->avail_in_this_block -= copy_this; - from_copy += copy_this ; - len -= copy_this; - } - return ZIP_OK; -} - - - -/****************************************************************************/ - -#ifndef NO_ADDFILEINEXISTINGZIP -/* =========================================================================== - Inputs a long in LSB order to the given file - nbByte == 1, 2 ,4 or 8 (byte, short or long, ZPOS64_T) -*/ - -local int zip64local_putValue OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte)); -local int zip64local_putValue (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte) -{ - unsigned char buf[8]; - int n; - for (n = 0; n < nbByte; n++) - { - buf[n] = (unsigned char)(x & 0xff); - x >>= 8; - } - if (x != 0) - { /* data overflow - hack for ZIP64 (X Roche) */ - for (n = 0; n < nbByte; n++) - { - buf[n] = 0xff; - } - } - - if (ZWRITE64(*pzlib_filefunc_def,filestream,buf,(uLong)nbByte)!=(uLong)nbByte) - return ZIP_ERRNO; - else - return ZIP_OK; -} - -local void zip64local_putValue_inmemory OF((void* dest, ZPOS64_T x, int nbByte)); -local void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbByte) -{ - unsigned char* buf=(unsigned char*)dest; - int n; - for (n = 0; n < nbByte; n++) { - buf[n] = (unsigned char)(x & 0xff); - x >>= 8; - } - - if (x != 0) - { /* data overflow - hack for ZIP64 */ - for (n = 0; n < nbByte; n++) - { - buf[n] = 0xff; - } - } -} - -/****************************************************************************/ - - -local uLong zip64local_TmzDateToDosDate(const tm_zip* ptm) -{ - uLong year = (uLong)ptm->tm_year; - if (year>=1980) - year-=1980; - else if (year>=80) - year-=80; - return - (uLong) (((uLong)(ptm->tm_mday) + (32 * (uLong)(ptm->tm_mon+1)) + (512 * year)) << 16) | - (((uLong)ptm->tm_sec/2) + (32 * (uLong)ptm->tm_min) + (2048 * (uLong)ptm->tm_hour)); -} - - -/****************************************************************************/ - -local int zip64local_getByte OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi)); - -local int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def,voidpf filestream,int* pi) -{ - unsigned char c; - int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1); - if (err==1) - { - *pi = (int)c; - return ZIP_OK; - } - else - { - if (ZERROR64(*pzlib_filefunc_def,filestream)) - return ZIP_ERRNO; - else - return ZIP_EOF; - } -} - - -/* =========================================================================== - Reads a long in LSB order from the given gz_stream. Sets -*/ -local int zip64local_getShort OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX)); - -local int zip64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX) -{ - uLong x ; - int i = 0; - int err; - - err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); - x = (uLong)i; - - if (err==ZIP_OK) - err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); - x += ((uLong)i)<<8; - - if (err==ZIP_OK) - *pX = x; - else - *pX = 0; - return err; -} - -local int zip64local_getLong OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX)); - -local int zip64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX) -{ - uLong x ; - int i = 0; - int err; - - err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); - x = (uLong)i; - - if (err==ZIP_OK) - err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); - x += ((uLong)i)<<8; - - if (err==ZIP_OK) - err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); - x += ((uLong)i)<<16; - - if (err==ZIP_OK) - err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); - x += ((uLong)i)<<24; - - if (err==ZIP_OK) - *pX = x; - else - *pX = 0; - return err; -} - -local int zip64local_getLong64 OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX)); - - -local int zip64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX) -{ - ZPOS64_T x; - int i = 0; - int err; - - err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); - x = (ZPOS64_T)i; - - if (err==ZIP_OK) - err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); - x += ((ZPOS64_T)i)<<8; - - if (err==ZIP_OK) - err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); - x += ((ZPOS64_T)i)<<16; - - if (err==ZIP_OK) - err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); - x += ((ZPOS64_T)i)<<24; - - if (err==ZIP_OK) - err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); - x += ((ZPOS64_T)i)<<32; - - if (err==ZIP_OK) - err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); - x += ((ZPOS64_T)i)<<40; - - if (err==ZIP_OK) - err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); - x += ((ZPOS64_T)i)<<48; - - if (err==ZIP_OK) - err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); - x += ((ZPOS64_T)i)<<56; - - if (err==ZIP_OK) - *pX = x; - else - *pX = 0; - - return err; -} - -#ifndef BUFREADCOMMENT -#define BUFREADCOMMENT (0x400) -#endif -/* - Locate the Central directory of a zipfile (at the end, just before - the global comment) -*/ -local ZPOS64_T zip64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)); - -local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) -{ - unsigned char* buf; - ZPOS64_T uSizeFile; - ZPOS64_T uBackRead; - ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ - ZPOS64_T uPosFound=0; - - if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) - return 0; - - - uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream); - - if (uMaxBack>uSizeFile) - uMaxBack = uSizeFile; - - buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); - if (buf==NULL) - return 0; - - uBackRead = 4; - while (uBackReaduMaxBack) - uBackRead = uMaxBack; - else - uBackRead+=BUFREADCOMMENT; - uReadPos = uSizeFile-uBackRead ; - - uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? - (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos); - if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) - break; - - if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) - break; - - for (i=(int)uReadSize-3; (i--)>0;) - if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && - ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) - { - uPosFound = uReadPos+(unsigned)i; - break; - } - - if (uPosFound!=0) - break; - } - TRYFREE(buf); - return uPosFound; -} - -/* -Locate the End of Zip64 Central directory locator and from there find the CD of a zipfile (at the end, just before -the global comment) -*/ -local ZPOS64_T zip64local_SearchCentralDir64 OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)); - -local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) -{ - unsigned char* buf; - ZPOS64_T uSizeFile; - ZPOS64_T uBackRead; - ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ - ZPOS64_T uPosFound=0; - uLong uL; - ZPOS64_T relativeOffset; - - if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) - return 0; - - uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream); - - if (uMaxBack>uSizeFile) - uMaxBack = uSizeFile; - - buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); - if (buf==NULL) - return 0; - - uBackRead = 4; - while (uBackReaduMaxBack) - uBackRead = uMaxBack; - else - uBackRead+=BUFREADCOMMENT; - uReadPos = uSizeFile-uBackRead ; - - uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? - (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos); - if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) - break; - - if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) - break; - - for (i=(int)uReadSize-3; (i--)>0;) - { - // Signature "0x07064b50" Zip64 end of central directory locater - if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07)) - { - uPosFound = uReadPos+(unsigned)i; - break; - } - } - - if (uPosFound!=0) - break; - } - - TRYFREE(buf); - if (uPosFound == 0) - return 0; - - /* Zip64 end of central directory locator */ - if (ZSEEK64(*pzlib_filefunc_def,filestream, uPosFound,ZLIB_FILEFUNC_SEEK_SET)!=0) - return 0; - - /* the signature, already checked */ - if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK) - return 0; - - /* number of the disk with the start of the zip64 end of central directory */ - if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK) - return 0; - if (uL != 0) - return 0; - - /* relative offset of the zip64 end of central directory record */ - if (zip64local_getLong64(pzlib_filefunc_def,filestream,&relativeOffset)!=ZIP_OK) - return 0; - - /* total number of disks */ - if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK) - return 0; - if (uL != 1) - return 0; - - /* Goto Zip64 end of central directory record */ - if (ZSEEK64(*pzlib_filefunc_def,filestream, relativeOffset,ZLIB_FILEFUNC_SEEK_SET)!=0) - return 0; - - /* the signature */ - if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK) - return 0; - - if (uL != 0x06064b50) // signature of 'Zip64 end of central directory' - return 0; - - return relativeOffset; -} - -local int LoadCentralDirectoryRecord(zip64_internal* pziinit) -{ - int err=ZIP_OK; - ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ - - ZPOS64_T size_central_dir; /* size of the central directory */ - ZPOS64_T offset_central_dir; /* offset of start of central directory */ - ZPOS64_T central_pos; - uLong uL; - - uLong number_disk; /* number of the current dist, used for - spaning ZIP, unsupported, always 0*/ - uLong number_disk_with_CD; /* number the the disk with central dir, used - for spaning ZIP, unsupported, always 0*/ - ZPOS64_T number_entry; - ZPOS64_T number_entry_CD; /* total number of entries in - the central dir - (same than number_entry on nospan) */ - uLong VersionMadeBy; - uLong VersionNeeded; - uLong size_comment; - - int hasZIP64Record = 0; - - // check first if we find a ZIP64 record - central_pos = zip64local_SearchCentralDir64(&pziinit->z_filefunc,pziinit->filestream); - if(central_pos > 0) - { - hasZIP64Record = 1; - } - else if(central_pos == 0) - { - central_pos = zip64local_SearchCentralDir(&pziinit->z_filefunc,pziinit->filestream); - } - -/* disable to allow appending to empty ZIP archive - if (central_pos==0) - err=ZIP_ERRNO; -*/ - - if(hasZIP64Record) - { - ZPOS64_T sizeEndOfCentralDirectory; - if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, central_pos, ZLIB_FILEFUNC_SEEK_SET) != 0) - err=ZIP_ERRNO; - - /* the signature, already checked */ - if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream,&uL)!=ZIP_OK) - err=ZIP_ERRNO; - - /* size of zip64 end of central directory record */ - if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream, &sizeEndOfCentralDirectory)!=ZIP_OK) - err=ZIP_ERRNO; - - /* version made by */ - if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream, &VersionMadeBy)!=ZIP_OK) - err=ZIP_ERRNO; - - /* version needed to extract */ - if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream, &VersionNeeded)!=ZIP_OK) - err=ZIP_ERRNO; - - /* number of this disk */ - if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream,&number_disk)!=ZIP_OK) - err=ZIP_ERRNO; - - /* number of the disk with the start of the central directory */ - if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream,&number_disk_with_CD)!=ZIP_OK) - err=ZIP_ERRNO; - - /* total number of entries in the central directory on this disk */ - if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream, &number_entry)!=ZIP_OK) - err=ZIP_ERRNO; - - /* total number of entries in the central directory */ - if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream,&number_entry_CD)!=ZIP_OK) - err=ZIP_ERRNO; - - if ((number_entry_CD!=number_entry) || (number_disk_with_CD!=0) || (number_disk!=0)) - err=ZIP_BADZIPFILE; - - /* size of the central directory */ - if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream,&size_central_dir)!=ZIP_OK) - err=ZIP_ERRNO; - - /* offset of start of central directory with respect to the - starting disk number */ - if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream,&offset_central_dir)!=ZIP_OK) - err=ZIP_ERRNO; - - // TODO.. - // read the comment from the standard central header. - size_comment = 0; - } - else - { - // Read End of central Directory info - if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) - err=ZIP_ERRNO; - - /* the signature, already checked */ - if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream,&uL)!=ZIP_OK) - err=ZIP_ERRNO; - - /* number of this disk */ - if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream,&number_disk)!=ZIP_OK) - err=ZIP_ERRNO; - - /* number of the disk with the start of the central directory */ - if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream,&number_disk_with_CD)!=ZIP_OK) - err=ZIP_ERRNO; - - /* total number of entries in the central dir on this disk */ - number_entry = 0; - if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream, &uL)!=ZIP_OK) - err=ZIP_ERRNO; - else - number_entry = uL; - - /* total number of entries in the central dir */ - number_entry_CD = 0; - if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream, &uL)!=ZIP_OK) - err=ZIP_ERRNO; - else - number_entry_CD = uL; - - if ((number_entry_CD!=number_entry) || (number_disk_with_CD!=0) || (number_disk!=0)) - err=ZIP_BADZIPFILE; - - /* size of the central directory */ - size_central_dir = 0; - if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream, &uL)!=ZIP_OK) - err=ZIP_ERRNO; - else - size_central_dir = uL; - - /* offset of start of central directory with respect to the starting disk number */ - offset_central_dir = 0; - if (zip64local_getLong(&pziinit->z_filefunc, pziinit->filestream, &uL)!=ZIP_OK) - err=ZIP_ERRNO; - else - offset_central_dir = uL; - - - /* zipfile global comment length */ - if (zip64local_getShort(&pziinit->z_filefunc, pziinit->filestream, &size_comment)!=ZIP_OK) - err=ZIP_ERRNO; - } - - if ((central_posz_filefunc, pziinit->filestream); - return ZIP_ERRNO; - } - - if (size_comment>0) - { - pziinit->globalcomment = (char*)ALLOC(size_comment+1); - if (pziinit->globalcomment) - { - size_comment = ZREAD64(pziinit->z_filefunc, pziinit->filestream, pziinit->globalcomment,size_comment); - pziinit->globalcomment[size_comment]=0; - } - } - - byte_before_the_zipfile = central_pos - (offset_central_dir+size_central_dir); - pziinit->add_position_when_writing_offset = byte_before_the_zipfile; - - { - ZPOS64_T size_central_dir_to_read = size_central_dir; - size_t buf_size = SIZEDATA_INDATABLOCK; - void* buf_read = (void*)ALLOC(buf_size); - if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, offset_central_dir + byte_before_the_zipfile, ZLIB_FILEFUNC_SEEK_SET) != 0) - err=ZIP_ERRNO; - - while ((size_central_dir_to_read>0) && (err==ZIP_OK)) - { - ZPOS64_T read_this = SIZEDATA_INDATABLOCK; - if (read_this > size_central_dir_to_read) - read_this = size_central_dir_to_read; - - if (ZREAD64(pziinit->z_filefunc, pziinit->filestream,buf_read,(uLong)read_this) != read_this) - err=ZIP_ERRNO; - - if (err==ZIP_OK) - err = add_data_in_datablock(&pziinit->central_dir,buf_read, (uLong)read_this); - - size_central_dir_to_read-=read_this; - } - TRYFREE(buf_read); - } - pziinit->begin_pos = byte_before_the_zipfile; - pziinit->number_entry = number_entry_CD; - - if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, offset_central_dir+byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET) != 0) - err=ZIP_ERRNO; - - return err; -} - - -#endif /* !NO_ADDFILEINEXISTINGZIP*/ - - -/************************************************************/ -extern zipFile ZEXPORT zipOpen3 (const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_32_def* pzlib_filefunc64_32_def) -{ - zip64_internal ziinit; - zip64_internal* zi; - int err=ZIP_OK; - - ziinit.z_filefunc.zseek32_file = NULL; - ziinit.z_filefunc.ztell32_file = NULL; - if (pzlib_filefunc64_32_def==NULL) - fill_fopen64_filefunc(&ziinit.z_filefunc.zfile_func64); - else - ziinit.z_filefunc = *pzlib_filefunc64_32_def; - - ziinit.filestream = ZOPEN64(ziinit.z_filefunc, - pathname, - (append == APPEND_STATUS_CREATE) ? - (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_CREATE) : - (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_EXISTING)); - - if (ziinit.filestream == NULL) - return NULL; - - if (append == APPEND_STATUS_CREATEAFTER) - ZSEEK64(ziinit.z_filefunc,ziinit.filestream,0,SEEK_END); - - ziinit.begin_pos = ZTELL64(ziinit.z_filefunc,ziinit.filestream); - ziinit.in_opened_file_inzip = 0; - ziinit.ci.stream_initialised = 0; - ziinit.number_entry = 0; - ziinit.add_position_when_writing_offset = 0; - init_linkedlist(&(ziinit.central_dir)); - - - - zi = (zip64_internal*)ALLOC(sizeof(zip64_internal)); - if (zi==NULL) - { - ZCLOSE64(ziinit.z_filefunc,ziinit.filestream); - return NULL; - } - - /* now we add file in a zipfile */ -# ifndef NO_ADDFILEINEXISTINGZIP - ziinit.globalcomment = NULL; - if (append == APPEND_STATUS_ADDINZIP) - { - // Read and Cache Central Directory Records - err = LoadCentralDirectoryRecord(&ziinit); - } - - if (globalcomment) - { - *globalcomment = ziinit.globalcomment; - } -# endif /* !NO_ADDFILEINEXISTINGZIP*/ - - if (err != ZIP_OK) - { -# ifndef NO_ADDFILEINEXISTINGZIP - TRYFREE(ziinit.globalcomment); -# endif /* !NO_ADDFILEINEXISTINGZIP*/ - TRYFREE(zi); - return NULL; - } - else - { - *zi = ziinit; - return (zipFile)zi; - } -} - -extern zipFile ZEXPORT zipOpen2 (const char *pathname, int append, zipcharpc* globalcomment, zlib_filefunc_def* pzlib_filefunc32_def) -{ - if (pzlib_filefunc32_def != NULL) - { - zlib_filefunc64_32_def zlib_filefunc64_32_def_fill; - fill_zlib_filefunc64_32_def_from_filefunc32(&zlib_filefunc64_32_def_fill,pzlib_filefunc32_def); - return zipOpen3(pathname, append, globalcomment, &zlib_filefunc64_32_def_fill); - } - else - return zipOpen3(pathname, append, globalcomment, NULL); -} - -extern zipFile ZEXPORT zipOpen2_64 (const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_def* pzlib_filefunc_def) -{ - if (pzlib_filefunc_def != NULL) - { - zlib_filefunc64_32_def zlib_filefunc64_32_def_fill; - zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def; - zlib_filefunc64_32_def_fill.ztell32_file = NULL; - zlib_filefunc64_32_def_fill.zseek32_file = NULL; - return zipOpen3(pathname, append, globalcomment, &zlib_filefunc64_32_def_fill); - } - else - return zipOpen3(pathname, append, globalcomment, NULL); -} - - - -extern zipFile ZEXPORT zipOpen (const char* pathname, int append) -{ - return zipOpen3((const void*)pathname,append,NULL,NULL); -} - -extern zipFile ZEXPORT zipOpen64 (const void* pathname, int append) -{ - return zipOpen3(pathname,append,NULL,NULL); -} - -local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local) -{ - /* write the local header */ - int err; - uInt size_filename = (uInt)strlen(filename); - uInt size_extrafield = size_extrafield_local; - - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)LOCALHEADERMAGIC, 4); - - if (err==ZIP_OK) - { - if(zi->ci.zip64) - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2);/* version needed to extract */ - else - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)20,2);/* version needed to extract */ - } - - if (err==ZIP_OK) - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.flag,2); - - if (err==ZIP_OK) - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.method,2); - - if (err==ZIP_OK) - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.dosDate,4); - - // CRC / Compressed size / Uncompressed size will be filled in later and rewritten later - if (err==ZIP_OK) - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* crc 32, unknown */ - if (err==ZIP_OK) - { - if(zi->ci.zip64) - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xFFFFFFFF,4); /* compressed size, unknown */ - else - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* compressed size, unknown */ - } - if (err==ZIP_OK) - { - if(zi->ci.zip64) - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xFFFFFFFF,4); /* uncompressed size, unknown */ - else - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* uncompressed size, unknown */ - } - - if (err==ZIP_OK) - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_filename,2); - - if(zi->ci.zip64) - { - size_extrafield += 20; - } - - if (err==ZIP_OK) - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_extrafield,2); - - if ((err==ZIP_OK) && (size_filename > 0)) - { - if (ZWRITE64(zi->z_filefunc,zi->filestream,filename,size_filename)!=size_filename) - err = ZIP_ERRNO; - } - - if ((err==ZIP_OK) && (size_extrafield_local > 0)) - { - if (ZWRITE64(zi->z_filefunc, zi->filestream, extrafield_local, size_extrafield_local) != size_extrafield_local) - err = ZIP_ERRNO; - } - - - if ((err==ZIP_OK) && (zi->ci.zip64)) - { - // write the Zip64 extended info - short HeaderID = 1; - short DataSize = 16; - ZPOS64_T CompressedSize = 0; - ZPOS64_T UncompressedSize = 0; - - // Remember position of Zip64 extended info for the local file header. (needed when we update size after done with file) - zi->ci.pos_zip64extrainfo = ZTELL64(zi->z_filefunc,zi->filestream); - - err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)HeaderID,2); - err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)DataSize,2); - - err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)UncompressedSize,8); - err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)CompressedSize,8); - } - - return err; -} - -/* - NOTE. - When writing RAW the ZIP64 extended information in extrafield_local and extrafield_global needs to be stripped - before calling this function it can be done with zipRemoveExtraInfoBlock - - It is not done here because then we need to realloc a new buffer since parameters are 'const' and I want to minimize - unnecessary allocations. - */ -extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename, const zip_fileinfo* zipfi, - const void* extrafield_local, uInt size_extrafield_local, - const void* extrafield_global, uInt size_extrafield_global, - const char* comment, int method, int level, int raw, - int windowBits,int memLevel, int strategy, - const char* password, uLong crcForCrypting, - uLong versionMadeBy, uLong flagBase, int zip64) -{ - zip64_internal* zi; - uInt size_filename; - uInt size_comment; - uInt i; - int err = ZIP_OK; - -# ifdef NOCRYPT - (crcForCrypting); - if (password != NULL) - return ZIP_PARAMERROR; -# endif - - if (file == NULL) - return ZIP_PARAMERROR; - -#ifdef HAVE_BZIP2 - if ((method!=0) && (method!=Z_DEFLATED) && (method!=Z_BZIP2ED)) - return ZIP_PARAMERROR; -#else - if ((method!=0) && (method!=Z_DEFLATED)) - return ZIP_PARAMERROR; -#endif - - zi = (zip64_internal*)file; - - if (zi->in_opened_file_inzip == 1) - { - err = zipCloseFileInZip (file); - if (err != ZIP_OK) - return err; - } - - if (filename==NULL) - filename="-"; - - if (comment==NULL) - size_comment = 0; - else - size_comment = (uInt)strlen(comment); - - size_filename = (uInt)strlen(filename); - - if (zipfi == NULL) - zi->ci.dosDate = 0; - else - { - if (zipfi->dosDate != 0) - zi->ci.dosDate = zipfi->dosDate; - else - zi->ci.dosDate = zip64local_TmzDateToDosDate(&zipfi->tmz_date); - } - - zi->ci.flag = flagBase; - if ((level==8) || (level==9)) - zi->ci.flag |= 2; - if (level==2) - zi->ci.flag |= 4; - if (level==1) - zi->ci.flag |= 6; - if (password != NULL) - zi->ci.flag |= 1; - - zi->ci.crc32 = 0; - zi->ci.method = method; - zi->ci.encrypt = 0; - zi->ci.stream_initialised = 0; - zi->ci.pos_in_buffered_data = 0; - zi->ci.raw = raw; - zi->ci.pos_local_header = ZTELL64(zi->z_filefunc,zi->filestream); - - zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename + size_extrafield_global + size_comment; - zi->ci.size_centralExtraFree = 32; // Extra space we have reserved in case we need to add ZIP64 extra info data - - zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader + zi->ci.size_centralExtraFree); - - zi->ci.size_centralExtra = size_extrafield_global; - zip64local_putValue_inmemory(zi->ci.central_header,(uLong)CENTRALHEADERMAGIC,4); - /* version info */ - zip64local_putValue_inmemory(zi->ci.central_header+4,(uLong)versionMadeBy,2); - zip64local_putValue_inmemory(zi->ci.central_header+6,(uLong)20,2); - zip64local_putValue_inmemory(zi->ci.central_header+8,(uLong)zi->ci.flag,2); - zip64local_putValue_inmemory(zi->ci.central_header+10,(uLong)zi->ci.method,2); - zip64local_putValue_inmemory(zi->ci.central_header+12,(uLong)zi->ci.dosDate,4); - zip64local_putValue_inmemory(zi->ci.central_header+16,(uLong)0,4); /*crc*/ - zip64local_putValue_inmemory(zi->ci.central_header+20,(uLong)0,4); /*compr size*/ - zip64local_putValue_inmemory(zi->ci.central_header+24,(uLong)0,4); /*uncompr size*/ - zip64local_putValue_inmemory(zi->ci.central_header+28,(uLong)size_filename,2); - zip64local_putValue_inmemory(zi->ci.central_header+30,(uLong)size_extrafield_global,2); - zip64local_putValue_inmemory(zi->ci.central_header+32,(uLong)size_comment,2); - zip64local_putValue_inmemory(zi->ci.central_header+34,(uLong)0,2); /*disk nm start*/ - - if (zipfi==NULL) - zip64local_putValue_inmemory(zi->ci.central_header+36,(uLong)0,2); - else - zip64local_putValue_inmemory(zi->ci.central_header+36,(uLong)zipfi->internal_fa,2); - - if (zipfi==NULL) - zip64local_putValue_inmemory(zi->ci.central_header+38,(uLong)0,4); - else - zip64local_putValue_inmemory(zi->ci.central_header+38,(uLong)zipfi->external_fa,4); - - if(zi->ci.pos_local_header >= 0xffffffff) - zip64local_putValue_inmemory(zi->ci.central_header+42,(uLong)0xffffffff,4); - else - zip64local_putValue_inmemory(zi->ci.central_header+42,(uLong)zi->ci.pos_local_header - zi->add_position_when_writing_offset,4); - - for (i=0;ici.central_header+SIZECENTRALHEADER+i) = *(filename+i); - - for (i=0;ici.central_header+SIZECENTRALHEADER+size_filename+i) = - *(((const char*)extrafield_global)+i); - - for (i=0;ici.central_header+SIZECENTRALHEADER+size_filename+ - size_extrafield_global+i) = *(comment+i); - if (zi->ci.central_header == NULL) - return ZIP_INTERNALERROR; - - zi->ci.zip64 = zip64; - zi->ci.totalCompressedData = 0; - zi->ci.totalUncompressedData = 0; - zi->ci.pos_zip64extrainfo = 0; - - err = Write_LocalFileHeader(zi, filename, size_extrafield_local, extrafield_local); - -#ifdef HAVE_BZIP2 - zi->ci.bstream.avail_in = (uInt)0; - zi->ci.bstream.avail_out = (uInt)Z_BUFSIZE; - zi->ci.bstream.next_out = (char*)zi->ci.buffered_data; - zi->ci.bstream.total_in_hi32 = 0; - zi->ci.bstream.total_in_lo32 = 0; - zi->ci.bstream.total_out_hi32 = 0; - zi->ci.bstream.total_out_lo32 = 0; -#endif - - zi->ci.stream.avail_in = (uInt)0; - zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; - zi->ci.stream.next_out = zi->ci.buffered_data; - zi->ci.stream.total_in = 0; - zi->ci.stream.total_out = 0; - zi->ci.stream.data_type = Z_BINARY; - -#ifdef HAVE_BZIP2 - if ((err==ZIP_OK) && (zi->ci.method == Z_DEFLATED || zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw)) -#else - if ((err==ZIP_OK) && (zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) -#endif - { - if(zi->ci.method == Z_DEFLATED) - { - zi->ci.stream.zalloc = (alloc_func)0; - zi->ci.stream.zfree = (free_func)0; - zi->ci.stream.opaque = (voidpf)0; - - if (windowBits>0) - windowBits = -windowBits; - - err = deflateInit2(&zi->ci.stream, level, Z_DEFLATED, windowBits, memLevel, strategy); - - if (err==Z_OK) - zi->ci.stream_initialised = Z_DEFLATED; - } - else if(zi->ci.method == Z_BZIP2ED) - { -#ifdef HAVE_BZIP2 - // Init BZip stuff here - zi->ci.bstream.bzalloc = 0; - zi->ci.bstream.bzfree = 0; - zi->ci.bstream.opaque = (voidpf)0; - - err = BZ2_bzCompressInit(&zi->ci.bstream, level, 0,35); - if(err == BZ_OK) - zi->ci.stream_initialised = Z_BZIP2ED; -#endif - } - - } - -# ifndef NOCRYPT - zi->ci.crypt_header_size = 0; - if ((err==Z_OK) && (password != NULL)) - { - unsigned char bufHead[RAND_HEAD_LEN]; - unsigned int sizeHead; - zi->ci.encrypt = 1; - zi->ci.pcrc_32_tab = get_crc_table(); - /*init_keys(password,zi->ci.keys,zi->ci.pcrc_32_tab);*/ - - sizeHead=crypthead(password,bufHead,RAND_HEAD_LEN,zi->ci.keys,zi->ci.pcrc_32_tab,crcForCrypting); - zi->ci.crypt_header_size = sizeHead; - - if (ZWRITE64(zi->z_filefunc,zi->filestream,bufHead,sizeHead) != sizeHead) - err = ZIP_ERRNO; - } -# endif - - if (err==Z_OK) - zi->in_opened_file_inzip = 1; - return err; -} - -extern int ZEXPORT zipOpenNewFileInZip4 (zipFile file, const char* filename, const zip_fileinfo* zipfi, - const void* extrafield_local, uInt size_extrafield_local, - const void* extrafield_global, uInt size_extrafield_global, - const char* comment, int method, int level, int raw, - int windowBits,int memLevel, int strategy, - const char* password, uLong crcForCrypting, - uLong versionMadeBy, uLong flagBase) -{ - return zipOpenNewFileInZip4_64 (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, raw, - windowBits, memLevel, strategy, - password, crcForCrypting, versionMadeBy, flagBase, 0); -} - -extern int ZEXPORT zipOpenNewFileInZip3 (zipFile file, const char* filename, const zip_fileinfo* zipfi, - const void* extrafield_local, uInt size_extrafield_local, - const void* extrafield_global, uInt size_extrafield_global, - const char* comment, int method, int level, int raw, - int windowBits,int memLevel, int strategy, - const char* password, uLong crcForCrypting) -{ - return zipOpenNewFileInZip4_64 (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, raw, - windowBits, memLevel, strategy, - password, crcForCrypting, VERSIONMADEBY, 0, 0); -} - -extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char* filename, const zip_fileinfo* zipfi, - const void* extrafield_local, uInt size_extrafield_local, - const void* extrafield_global, uInt size_extrafield_global, - const char* comment, int method, int level, int raw, - int windowBits,int memLevel, int strategy, - const char* password, uLong crcForCrypting, int zip64) -{ - return zipOpenNewFileInZip4_64 (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, raw, - windowBits, memLevel, strategy, - password, crcForCrypting, VERSIONMADEBY, 0, zip64); -} - -extern int ZEXPORT zipOpenNewFileInZip2(zipFile file, const char* filename, const zip_fileinfo* zipfi, - const void* extrafield_local, uInt size_extrafield_local, - const void* extrafield_global, uInt size_extrafield_global, - const char* comment, int method, int level, int raw) -{ - return zipOpenNewFileInZip4_64 (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, raw, - -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, - NULL, 0, VERSIONMADEBY, 0, 0); -} - -extern int ZEXPORT zipOpenNewFileInZip2_64(zipFile file, const char* filename, const zip_fileinfo* zipfi, - const void* extrafield_local, uInt size_extrafield_local, - const void* extrafield_global, uInt size_extrafield_global, - const char* comment, int method, int level, int raw, int zip64) -{ - return zipOpenNewFileInZip4_64 (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, raw, - -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, - NULL, 0, VERSIONMADEBY, 0, zip64); -} - -extern int ZEXPORT zipOpenNewFileInZip64 (zipFile file, const char* filename, const zip_fileinfo* zipfi, - const void* extrafield_local, uInt size_extrafield_local, - const void*extrafield_global, uInt size_extrafield_global, - const char* comment, int method, int level, int zip64) -{ - return zipOpenNewFileInZip4_64 (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, 0, - -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, - NULL, 0, VERSIONMADEBY, 0, zip64); -} - -extern int ZEXPORT zipOpenNewFileInZip (zipFile file, const char* filename, const zip_fileinfo* zipfi, - const void* extrafield_local, uInt size_extrafield_local, - const void*extrafield_global, uInt size_extrafield_global, - const char* comment, int method, int level) -{ - return zipOpenNewFileInZip4_64 (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level, 0, - -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, - NULL, 0, VERSIONMADEBY, 0, 0); -} - -local int zip64FlushWriteBuffer(zip64_internal* zi) -{ - int err=ZIP_OK; - - if (zi->ci.encrypt != 0) - { -#ifndef NOCRYPT - uInt i; - int t; - for (i=0;ici.pos_in_buffered_data;i++) - zi->ci.buffered_data[i] = zencode(zi->ci.keys, zi->ci.pcrc_32_tab, zi->ci.buffered_data[i],t); -#endif - } - - if (ZWRITE64(zi->z_filefunc,zi->filestream,zi->ci.buffered_data,zi->ci.pos_in_buffered_data) != zi->ci.pos_in_buffered_data) - err = ZIP_ERRNO; - - zi->ci.totalCompressedData += zi->ci.pos_in_buffered_data; - -#ifdef HAVE_BZIP2 - if(zi->ci.method == Z_BZIP2ED) - { - zi->ci.totalUncompressedData += zi->ci.bstream.total_in_lo32; - zi->ci.bstream.total_in_lo32 = 0; - zi->ci.bstream.total_in_hi32 = 0; - } - else -#endif - { - zi->ci.totalUncompressedData += zi->ci.stream.total_in; - zi->ci.stream.total_in = 0; - } - - - zi->ci.pos_in_buffered_data = 0; - - return err; -} - -extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned int len) -{ - zip64_internal* zi; - int err=ZIP_OK; - - if (file == NULL) - return ZIP_PARAMERROR; - zi = (zip64_internal*)file; - - if (zi->in_opened_file_inzip == 0) - return ZIP_PARAMERROR; - - zi->ci.crc32 = crc32(zi->ci.crc32,buf,(uInt)len); - -#ifdef HAVE_BZIP2 - if(zi->ci.method == Z_BZIP2ED && (!zi->ci.raw)) - { - zi->ci.bstream.next_in = (void*)buf; - zi->ci.bstream.avail_in = len; - err = BZ_RUN_OK; - - while ((err==BZ_RUN_OK) && (zi->ci.bstream.avail_in>0)) - { - if (zi->ci.bstream.avail_out == 0) - { - if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO) - err = ZIP_ERRNO; - zi->ci.bstream.avail_out = (uInt)Z_BUFSIZE; - zi->ci.bstream.next_out = (char*)zi->ci.buffered_data; - } - - - if(err != BZ_RUN_OK) - break; - - if ((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw)) - { - uLong uTotalOutBefore_lo = zi->ci.bstream.total_out_lo32; -// uLong uTotalOutBefore_hi = zi->ci.bstream.total_out_hi32; - err=BZ2_bzCompress(&zi->ci.bstream, BZ_RUN); - - zi->ci.pos_in_buffered_data += (uInt)(zi->ci.bstream.total_out_lo32 - uTotalOutBefore_lo) ; - } - } - - if(err == BZ_RUN_OK) - err = ZIP_OK; - } - else -#endif - { - zi->ci.stream.next_in = (Bytef*)buf; - zi->ci.stream.avail_in = len; - - while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0)) - { - if (zi->ci.stream.avail_out == 0) - { - if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO) - err = ZIP_ERRNO; - zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; - zi->ci.stream.next_out = zi->ci.buffered_data; - } - - - if(err != ZIP_OK) - break; - - if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) - { - uLong uTotalOutBefore = zi->ci.stream.total_out; - err=deflate(&zi->ci.stream, Z_NO_FLUSH); - if(uTotalOutBefore > zi->ci.stream.total_out) - { - int bBreak = 0; - bBreak++; - } - - zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; - } - else - { - uInt copy_this,i; - if (zi->ci.stream.avail_in < zi->ci.stream.avail_out) - copy_this = zi->ci.stream.avail_in; - else - copy_this = zi->ci.stream.avail_out; - - for (i = 0; i < copy_this; i++) - *(((char*)zi->ci.stream.next_out)+i) = - *(((const char*)zi->ci.stream.next_in)+i); - { - zi->ci.stream.avail_in -= copy_this; - zi->ci.stream.avail_out-= copy_this; - zi->ci.stream.next_in+= copy_this; - zi->ci.stream.next_out+= copy_this; - zi->ci.stream.total_in+= copy_this; - zi->ci.stream.total_out+= copy_this; - zi->ci.pos_in_buffered_data += copy_this; - } - } - }// while(...) - } - - return err; -} - -extern int ZEXPORT zipCloseFileInZipRaw (zipFile file, uLong uncompressed_size, uLong crc32) -{ - return zipCloseFileInZipRaw64 (file, uncompressed_size, crc32); -} - -extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_size, uLong crc32) -{ - zip64_internal* zi; - ZPOS64_T compressed_size; - uLong invalidValue = 0xffffffff; - unsigned datasize = 0; - int err=ZIP_OK; - - if (file == NULL) - return ZIP_PARAMERROR; - zi = (zip64_internal*)file; - - if (zi->in_opened_file_inzip == 0) - return ZIP_PARAMERROR; - zi->ci.stream.avail_in = 0; - - if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) - { - while (err==ZIP_OK) - { - uLong uTotalOutBefore; - if (zi->ci.stream.avail_out == 0) - { - if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO) - err = ZIP_ERRNO; - zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; - zi->ci.stream.next_out = zi->ci.buffered_data; - } - uTotalOutBefore = zi->ci.stream.total_out; - err=deflate(&zi->ci.stream, Z_FINISH); - zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; - } - } - else if ((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw)) - { -#ifdef HAVE_BZIP2 - err = BZ_FINISH_OK; - while (err==BZ_FINISH_OK) - { - uLong uTotalOutBefore; - if (zi->ci.bstream.avail_out == 0) - { - if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO) - err = ZIP_ERRNO; - zi->ci.bstream.avail_out = (uInt)Z_BUFSIZE; - zi->ci.bstream.next_out = (char*)zi->ci.buffered_data; - } - uTotalOutBefore = zi->ci.bstream.total_out_lo32; - err=BZ2_bzCompress(&zi->ci.bstream, BZ_FINISH); - if(err == BZ_STREAM_END) - err = Z_STREAM_END; - - zi->ci.pos_in_buffered_data += (uInt)(zi->ci.bstream.total_out_lo32 - uTotalOutBefore); - } - - if(err == BZ_FINISH_OK) - err = ZIP_OK; -#endif - } - - if (err==Z_STREAM_END) - err=ZIP_OK; /* this is normal */ - - if ((zi->ci.pos_in_buffered_data>0) && (err==ZIP_OK)) - { - if (zip64FlushWriteBuffer(zi)==ZIP_ERRNO) - err = ZIP_ERRNO; - } - - if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) - { - int tmp_err = deflateEnd(&zi->ci.stream); - if (err == ZIP_OK) - err = tmp_err; - zi->ci.stream_initialised = 0; - } -#ifdef HAVE_BZIP2 - else if((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw)) - { - int tmperr = BZ2_bzCompressEnd(&zi->ci.bstream); - if (err==ZIP_OK) - err = tmperr; - zi->ci.stream_initialised = 0; - } -#endif - - if (!zi->ci.raw) - { - crc32 = (uLong)zi->ci.crc32; - uncompressed_size = zi->ci.totalUncompressedData; - } - compressed_size = zi->ci.totalCompressedData; - -# ifndef NOCRYPT - compressed_size += zi->ci.crypt_header_size; -# endif - - // update Current Item crc and sizes, - if(compressed_size >= 0xffffffff || uncompressed_size >= 0xffffffff || zi->ci.pos_local_header >= 0xffffffff) - { - /*version Made by*/ - zip64local_putValue_inmemory(zi->ci.central_header+4,(uLong)45,2); - /*version needed*/ - zip64local_putValue_inmemory(zi->ci.central_header+6,(uLong)45,2); - - } - - zip64local_putValue_inmemory(zi->ci.central_header+16,crc32,4); /*crc*/ - - - if(compressed_size >= 0xffffffff) - zip64local_putValue_inmemory(zi->ci.central_header+20, invalidValue,4); /*compr size*/ - else - zip64local_putValue_inmemory(zi->ci.central_header+20, compressed_size,4); /*compr size*/ - - /// set internal file attributes field - if (zi->ci.stream.data_type == Z_ASCII) - zip64local_putValue_inmemory(zi->ci.central_header+36,(uLong)Z_ASCII,2); - - if(uncompressed_size >= 0xffffffff) - zip64local_putValue_inmemory(zi->ci.central_header+24, invalidValue,4); /*uncompr size*/ - else - zip64local_putValue_inmemory(zi->ci.central_header+24, uncompressed_size,4); /*uncompr size*/ - - // Add ZIP64 extra info field for uncompressed size - if(uncompressed_size >= 0xffffffff) - datasize += 8; - - // Add ZIP64 extra info field for compressed size - if(compressed_size >= 0xffffffff) - datasize += 8; - - // Add ZIP64 extra info field for relative offset to local file header of current file - if(zi->ci.pos_local_header >= 0xffffffff) - datasize += 8; - - if(datasize > 0) - { - char* p = NULL; - - if((uLong)(datasize + 4) > zi->ci.size_centralExtraFree) - { - // we can not write more data to the buffer that we have room for. - return ZIP_BADZIPFILE; - } - - p = zi->ci.central_header + zi->ci.size_centralheader; - - // Add Extra Information Header for 'ZIP64 information' - zip64local_putValue_inmemory(p, 0x0001, 2); // HeaderID - p += 2; - zip64local_putValue_inmemory(p, datasize, 2); // DataSize - p += 2; - - if(uncompressed_size >= 0xffffffff) - { - zip64local_putValue_inmemory(p, uncompressed_size, 8); - p += 8; - } - - if(compressed_size >= 0xffffffff) - { - zip64local_putValue_inmemory(p, compressed_size, 8); - p += 8; - } - - if(zi->ci.pos_local_header >= 0xffffffff) - { - zip64local_putValue_inmemory(p, zi->ci.pos_local_header, 8); - p += 8; - } - - // Update how much extra free space we got in the memory buffer - // and increase the centralheader size so the new ZIP64 fields are included - // ( 4 below is the size of HeaderID and DataSize field ) - zi->ci.size_centralExtraFree -= datasize + 4; - zi->ci.size_centralheader += datasize + 4; - - // Update the extra info size field - zi->ci.size_centralExtra += datasize + 4; - zip64local_putValue_inmemory(zi->ci.central_header+30,(uLong)zi->ci.size_centralExtra,2); - } - - if (err==ZIP_OK) - err = add_data_in_datablock(&zi->central_dir, zi->ci.central_header, (uLong)zi->ci.size_centralheader); - - free(zi->ci.central_header); - - if (err==ZIP_OK) - { - // Update the LocalFileHeader with the new values. - - ZPOS64_T cur_pos_inzip = ZTELL64(zi->z_filefunc,zi->filestream); - - if (ZSEEK64(zi->z_filefunc,zi->filestream, zi->ci.pos_local_header + 14,ZLIB_FILEFUNC_SEEK_SET)!=0) - err = ZIP_ERRNO; - - if (err==ZIP_OK) - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,crc32,4); /* crc 32, unknown */ - - if(uncompressed_size >= 0xffffffff || compressed_size >= 0xffffffff ) - { - if(zi->ci.pos_zip64extrainfo > 0) - { - // Update the size in the ZIP64 extended field. - if (ZSEEK64(zi->z_filefunc,zi->filestream, zi->ci.pos_zip64extrainfo + 4,ZLIB_FILEFUNC_SEEK_SET)!=0) - err = ZIP_ERRNO; - - if (err==ZIP_OK) /* compressed size, unknown */ - err = zip64local_putValue(&zi->z_filefunc, zi->filestream, uncompressed_size, 8); - - if (err==ZIP_OK) /* uncompressed size, unknown */ - err = zip64local_putValue(&zi->z_filefunc, zi->filestream, compressed_size, 8); - } - else - err = ZIP_BADZIPFILE; // Caller passed zip64 = 0, so no room for zip64 info -> fatal - } - else - { - if (err==ZIP_OK) /* compressed size, unknown */ - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,compressed_size,4); - - if (err==ZIP_OK) /* uncompressed size, unknown */ - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,uncompressed_size,4); - } - - if (ZSEEK64(zi->z_filefunc,zi->filestream, cur_pos_inzip,ZLIB_FILEFUNC_SEEK_SET)!=0) - err = ZIP_ERRNO; - } - - zi->number_entry ++; - zi->in_opened_file_inzip = 0; - - return err; -} - -extern int ZEXPORT zipCloseFileInZip (zipFile file) -{ - return zipCloseFileInZipRaw (file,0,0); -} - -local int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip) -{ - int err = ZIP_OK; - ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writing_offset; - - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ZIP64ENDLOCHEADERMAGIC,4); - - /*num disks*/ - if (err==ZIP_OK) /* number of the disk with the start of the central directory */ - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); - - /*relative offset*/ - if (err==ZIP_OK) /* Relative offset to the Zip64EndOfCentralDirectory */ - err = zip64local_putValue(&zi->z_filefunc,zi->filestream, pos,8); - - /*total disks*/ /* Do not support spawning of disk so always say 1 here*/ - if (err==ZIP_OK) /* number of the disk with the start of the central directory */ - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)1,4); - - return err; -} - -local int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) -{ - int err = ZIP_OK; - - uLong Zip64DataSize = 44; - - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ZIP64ENDHEADERMAGIC,4); - - if (err==ZIP_OK) /* size of this 'zip64 end of central directory' */ - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(ZPOS64_T)Zip64DataSize,8); // why ZPOS64_T of this ? - - if (err==ZIP_OK) /* version made by */ - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2); - - if (err==ZIP_OK) /* version needed */ - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2); - - if (err==ZIP_OK) /* number of this disk */ - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); - - if (err==ZIP_OK) /* number of the disk with the start of the central directory */ - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); - - if (err==ZIP_OK) /* total number of entries in the central dir on this disk */ - err = zip64local_putValue(&zi->z_filefunc, zi->filestream, zi->number_entry, 8); - - if (err==ZIP_OK) /* total number of entries in the central dir */ - err = zip64local_putValue(&zi->z_filefunc, zi->filestream, zi->number_entry, 8); - - if (err==ZIP_OK) /* size of the central directory */ - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(ZPOS64_T)size_centraldir,8); - - if (err==ZIP_OK) /* offset of start of central directory with respect to the starting disk number */ - { - ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writing_offset; - err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (ZPOS64_T)pos,8); - } - return err; -} -local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) -{ - int err = ZIP_OK; - - /*signature*/ - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ENDHEADERMAGIC,4); - - if (err==ZIP_OK) /* number of this disk */ - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2); - - if (err==ZIP_OK) /* number of the disk with the start of the central directory */ - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2); - - if (err==ZIP_OK) /* total number of entries in the central dir on this disk */ - { - { - if(zi->number_entry >= 0xFFFF) - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xffff,2); // use value in ZIP64 record - else - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2); - } - } - - if (err==ZIP_OK) /* total number of entries in the central dir */ - { - if(zi->number_entry >= 0xFFFF) - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xffff,2); // use value in ZIP64 record - else - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2); - } - - if (err==ZIP_OK) /* size of the central directory */ - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_centraldir,4); - - if (err==ZIP_OK) /* offset of start of central directory with respect to the starting disk number */ - { - ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writing_offset; - if(pos >= 0xffffffff) - { - err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)0xffffffff,4); - } - else - err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (uLong)(centraldir_pos_inzip - zi->add_position_when_writing_offset),4); - } - - return err; -} - -local int Write_GlobalComment(zip64_internal* zi, const char* global_comment) -{ - int err = ZIP_OK; - uInt size_global_comment = 0; - - if(global_comment != NULL) - size_global_comment = (uInt)strlen(global_comment); - - err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_global_comment,2); - - if (err == ZIP_OK && size_global_comment > 0) - { - if (ZWRITE64(zi->z_filefunc,zi->filestream, global_comment, size_global_comment) != size_global_comment) - err = ZIP_ERRNO; - } - return err; -} - -extern int ZEXPORT zipClose (zipFile file, const char* global_comment) -{ - zip64_internal* zi; - int err = 0; - uLong size_centraldir = 0; - ZPOS64_T centraldir_pos_inzip; - ZPOS64_T pos; - - if (file == NULL) - return ZIP_PARAMERROR; - - zi = (zip64_internal*)file; - - if (zi->in_opened_file_inzip == 1) - { - err = zipCloseFileInZip (file); - } - -#ifndef NO_ADDFILEINEXISTINGZIP - if (global_comment==NULL) - global_comment = zi->globalcomment; -#endif - - centraldir_pos_inzip = ZTELL64(zi->z_filefunc,zi->filestream); - - if (err==ZIP_OK) - { - linkedlist_datablock_internal* ldi = zi->central_dir.first_block; - while (ldi!=NULL) - { - if ((err==ZIP_OK) && (ldi->filled_in_this_block>0)) - { - if (ZWRITE64(zi->z_filefunc,zi->filestream, ldi->data, ldi->filled_in_this_block) != ldi->filled_in_this_block) - err = ZIP_ERRNO; - } - - size_centraldir += ldi->filled_in_this_block; - ldi = ldi->next_datablock; - } - } - free_linkedlist(&(zi->central_dir)); - - pos = centraldir_pos_inzip - zi->add_position_when_writing_offset; - if(pos >= 0xffffffff || zi->number_entry > 0xFFFF) - { - ZPOS64_T Zip64EOCDpos = ZTELL64(zi->z_filefunc,zi->filestream); - Write_Zip64EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos_inzip); - - Write_Zip64EndOfCentralDirectoryLocator(zi, Zip64EOCDpos); - } - - if (err==ZIP_OK) - err = Write_EndOfCentralDirectoryRecord(zi, size_centraldir, centraldir_pos_inzip); - - if(err == ZIP_OK) - err = Write_GlobalComment(zi, global_comment); - - if (ZCLOSE64(zi->z_filefunc,zi->filestream) != 0) - if (err == ZIP_OK) - err = ZIP_ERRNO; - -#ifndef NO_ADDFILEINEXISTINGZIP - TRYFREE(zi->globalcomment); -#endif - TRYFREE(zi); - - return err; -} - -extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHeader) -{ - char* p = pData; - int size = 0; - char* pNewHeader; - char* pTmp; - short header; - short dataSize; - - int retVal = ZIP_OK; - - if(pData == NULL || *dataLen < 4) - return ZIP_PARAMERROR; - - pNewHeader = (char*)ALLOC((unsigned)*dataLen); - pTmp = pNewHeader; - - while(p < (pData + *dataLen)) - { - header = *(short*)p; - dataSize = *(((short*)p)+1); - - if( header == sHeader ) // Header found. - { - p += dataSize + 4; // skip it. do not copy to temp buffer - } - else - { - // Extra Info block should not be removed, So copy it to the temp buffer. - memcpy(pTmp, p, dataSize + 4); - p += dataSize + 4; - size += dataSize + 4; - } - - } - - if(size < *dataLen) - { - // clean old extra info block. - memset(pData,0, *dataLen); - - // copy the new extra info block over the old - if(size > 0) - memcpy(pData, pNewHeader, size); - - // set the new extra info size - *dataLen = size; - - retVal = ZIP_OK; - } - else - retVal = ZIP_ERRNO; - - TRYFREE(pNewHeader); - - return retVal; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/zip.h b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/zip.h deleted file mode 100644 index 7e4509d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/minizip/zip.h +++ /dev/null @@ -1,367 +0,0 @@ -/* zip.h -- IO on .zip files using zlib - Version 1.1, February 14h, 2010 - part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) - - Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) - - Modifications for Zip64 support - Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) - - For more info read MiniZip_info.txt - - --------------------------------------------------------------------------- - - Condition of use and distribution are the same than zlib : - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - --------------------------------------------------------------------------- - - Changes - - See header of zip.h - -*/ - -#ifndef _zip12_H -#define _zip12_H - -#ifdef __cplusplus -extern "C" { -#endif - -//#define HAVE_BZIP2 - -#ifndef _ZLIB_H -#include "zlib.h" -#endif - -#ifndef _ZLIBIOAPI_H -#include "ioapi.h" -#endif - -#ifdef HAVE_BZIP2 -#include "bzlib.h" -#endif - -#define Z_BZIP2ED 12 - -#if defined(STRICTZIP) || defined(STRICTZIPUNZIP) -/* like the STRICT of WIN32, we define a pointer that cannot be converted - from (void*) without cast */ -typedef struct TagzipFile__ { int unused; } zipFile__; -typedef zipFile__ *zipFile; -#else -typedef voidp zipFile; -#endif - -#define ZIP_OK (0) -#define ZIP_EOF (0) -#define ZIP_ERRNO (Z_ERRNO) -#define ZIP_PARAMERROR (-102) -#define ZIP_BADZIPFILE (-103) -#define ZIP_INTERNALERROR (-104) - -#ifndef DEF_MEM_LEVEL -# if MAX_MEM_LEVEL >= 8 -# define DEF_MEM_LEVEL 8 -# else -# define DEF_MEM_LEVEL MAX_MEM_LEVEL -# endif -#endif -/* default memLevel */ - -/* tm_zip contain date/time info */ -typedef struct tm_zip_s -{ - int tm_sec; /* seconds after the minute - [0,59] */ - int tm_min; /* minutes after the hour - [0,59] */ - int tm_hour; /* hours since midnight - [0,23] */ - int tm_mday; /* day of the month - [1,31] */ - int tm_mon; /* months since January - [0,11] */ - int tm_year; /* years - [1980..2044] */ -} tm_zip; - -typedef struct -{ - tm_zip tmz_date; /* date in understandable format */ - uLong dosDate; /* if dos_date == 0, tmu_date is used */ -/* uLong flag; */ /* general purpose bit flag 2 bytes */ - - uLong internal_fa; /* internal file attributes 2 bytes */ - uLong external_fa; /* external file attributes 4 bytes */ -} zip_fileinfo; - -typedef const char* zipcharpc; - - -#define APPEND_STATUS_CREATE (0) -#define APPEND_STATUS_CREATEAFTER (1) -#define APPEND_STATUS_ADDINZIP (2) - -extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append)); -extern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append)); -/* - Create a zipfile. - pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on - an Unix computer "zlib/zlib113.zip". - if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip - will be created at the end of the file. - (useful if the file contain a self extractor code) - if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will - add files in existing zip (be sure you don't add file that doesn't exist) - If the zipfile cannot be opened, the return value is NULL. - Else, the return value is a zipFile Handle, usable with other function - of this zip package. -*/ - -/* Note : there is no delete function into a zipfile. - If you want delete file into a zipfile, you must open a zipfile, and create another - Of couse, you can use RAW reading and writing to copy the file you did not want delte -*/ - -extern zipFile ZEXPORT zipOpen2 OF((const char *pathname, - int append, - zipcharpc* globalcomment, - zlib_filefunc_def* pzlib_filefunc_def)); - -extern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname, - int append, - zipcharpc* globalcomment, - zlib_filefunc64_def* pzlib_filefunc_def)); - -extern zipFile ZEXPORT zipOpen3 OF((const void *pathname, - int append, - zipcharpc* globalcomment, - zlib_filefunc64_32_def* pzlib_filefunc64_32_def)); - -extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level)); - -extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level, - int zip64)); - -/* - Open a file in the ZIP for writing. - filename : the filename in zip (if NULL, '-' without quote will be used - *zipfi contain supplemental information - if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local - contains the extrafield data the the local header - if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global - contains the extrafield data the the local header - if comment != NULL, comment contain the comment string - method contain the compression method (0 for store, Z_DEFLATED for deflate) - level contain the level of compression (can be Z_DEFAULT_COMPRESSION) - zip64 is set to 1 if a zip64 extended information block should be added to the local file header. - this MUST be '1' if the uncompressed size is >= 0xffffffff. - -*/ - - -extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level, - int raw)); - - -extern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level, - int raw, - int zip64)); -/* - Same than zipOpenNewFileInZip, except if raw=1, we write raw file - */ - -extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level, - int raw, - int windowBits, - int memLevel, - int strategy, - const char* password, - uLong crcForCrypting)); - -extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level, - int raw, - int windowBits, - int memLevel, - int strategy, - const char* password, - uLong crcForCrypting, - int zip64 - )); - -/* - Same than zipOpenNewFileInZip2, except - windowBits,memLevel,,strategy : see parameter strategy in deflateInit2 - password : crypting password (NULL for no crypting) - crcForCrypting : crc of file to compress (needed for crypting) - */ - -extern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level, - int raw, - int windowBits, - int memLevel, - int strategy, - const char* password, - uLong crcForCrypting, - uLong versionMadeBy, - uLong flagBase - )); - - -extern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level, - int raw, - int windowBits, - int memLevel, - int strategy, - const char* password, - uLong crcForCrypting, - uLong versionMadeBy, - uLong flagBase, - int zip64 - )); -/* - Same than zipOpenNewFileInZip4, except - versionMadeBy : value for Version made by field - flag : value for flag field (compression level info will be added) - */ - - -extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, - const void* buf, - unsigned len)); -/* - Write data in the zipfile -*/ - -extern int ZEXPORT zipCloseFileInZip OF((zipFile file)); -/* - Close the current file in the zipfile -*/ - -extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file, - uLong uncompressed_size, - uLong crc32)); - -extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file, - ZPOS64_T uncompressed_size, - uLong crc32)); - -/* - Close the current file in the zipfile, for file opened with - parameter raw=1 in zipOpenNewFileInZip2 - uncompressed_size and crc32 are value for the uncompressed size -*/ - -extern int ZEXPORT zipClose OF((zipFile file, - const char* global_comment)); -/* - Close the zipfile -*/ - - -extern int ZEXPORT zipRemoveExtraInfoBlock OF((char* pData, int* dataLen, short sHeader)); -/* - zipRemoveExtraInfoBlock - Added by Mathias Svensson - - Remove extra information block from a extra information data for the local file header or central directory header - - It is needed to remove ZIP64 extra information blocks when before data is written if using RAW mode. - - 0x0001 is the signature header for the ZIP64 extra information blocks - - usage. - Remove ZIP64 Extra information from a central director extra field data - zipRemoveExtraInfoBlock(pCenDirExtraFieldData, &nCenDirExtraFieldDataLen, 0x0001); - - Remove ZIP64 Extra information from a Local File Header extra field data - zipRemoveExtraInfoBlock(pLocalHeaderExtraFieldData, &nLocalHeaderExtraFieldDataLen, 0x0001); -*/ - -#ifdef __cplusplus -} -#endif - -#endif /* _zip64_H */ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/pascal/example.pas b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/pascal/example.pas deleted file mode 100644 index 5518b36..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/pascal/example.pas +++ /dev/null @@ -1,599 +0,0 @@ -(* example.c -- usage example of the zlib compression library - * Copyright (C) 1995-2003 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - * - * Pascal translation - * Copyright (C) 1998 by Jacques Nomssi Nzali. - * For conditions of distribution and use, see copyright notice in readme.txt - * - * Adaptation to the zlibpas interface - * Copyright (C) 2003 by Cosmin Truta. - * For conditions of distribution and use, see copyright notice in readme.txt - *) - -program example; - -{$DEFINE TEST_COMPRESS} -{DO NOT $DEFINE TEST_GZIO} -{$DEFINE TEST_DEFLATE} -{$DEFINE TEST_INFLATE} -{$DEFINE TEST_FLUSH} -{$DEFINE TEST_SYNC} -{$DEFINE TEST_DICT} - -uses SysUtils, zlibpas; - -const TESTFILE = 'foo.gz'; - -(* "hello world" would be more standard, but the repeated "hello" - * stresses the compression code better, sorry... - *) -const hello: PChar = 'hello, hello!'; - -const dictionary: PChar = 'hello'; - -var dictId: LongInt; (* Adler32 value of the dictionary *) - -procedure CHECK_ERR(err: Integer; msg: String); -begin - if err <> Z_OK then - begin - WriteLn(msg, ' error: ', err); - Halt(1); - end; -end; - -procedure EXIT_ERR(const msg: String); -begin - WriteLn('Error: ', msg); - Halt(1); -end; - -(* =========================================================================== - * Test compress and uncompress - *) -{$IFDEF TEST_COMPRESS} -procedure test_compress(compr: Pointer; comprLen: LongInt; - uncompr: Pointer; uncomprLen: LongInt); -var err: Integer; - len: LongInt; -begin - len := StrLen(hello)+1; - - err := compress(compr, comprLen, hello, len); - CHECK_ERR(err, 'compress'); - - StrCopy(PChar(uncompr), 'garbage'); - - err := uncompress(uncompr, uncomprLen, compr, comprLen); - CHECK_ERR(err, 'uncompress'); - - if StrComp(PChar(uncompr), hello) <> 0 then - EXIT_ERR('bad uncompress') - else - WriteLn('uncompress(): ', PChar(uncompr)); -end; -{$ENDIF} - -(* =========================================================================== - * Test read/write of .gz files - *) -{$IFDEF TEST_GZIO} -procedure test_gzio(const fname: PChar; (* compressed file name *) - uncompr: Pointer; - uncomprLen: LongInt); -var err: Integer; - len: Integer; - zfile: gzFile; - pos: LongInt; -begin - len := StrLen(hello)+1; - - zfile := gzopen(fname, 'wb'); - if zfile = NIL then - begin - WriteLn('gzopen error'); - Halt(1); - end; - gzputc(zfile, 'h'); - if gzputs(zfile, 'ello') <> 4 then - begin - WriteLn('gzputs err: ', gzerror(zfile, err)); - Halt(1); - end; - {$IFDEF GZ_FORMAT_STRING} - if gzprintf(zfile, ', %s!', 'hello') <> 8 then - begin - WriteLn('gzprintf err: ', gzerror(zfile, err)); - Halt(1); - end; - {$ELSE} - if gzputs(zfile, ', hello!') <> 8 then - begin - WriteLn('gzputs err: ', gzerror(zfile, err)); - Halt(1); - end; - {$ENDIF} - gzseek(zfile, 1, SEEK_CUR); (* add one zero byte *) - gzclose(zfile); - - zfile := gzopen(fname, 'rb'); - if zfile = NIL then - begin - WriteLn('gzopen error'); - Halt(1); - end; - - StrCopy(PChar(uncompr), 'garbage'); - - if gzread(zfile, uncompr, uncomprLen) <> len then - begin - WriteLn('gzread err: ', gzerror(zfile, err)); - Halt(1); - end; - if StrComp(PChar(uncompr), hello) <> 0 then - begin - WriteLn('bad gzread: ', PChar(uncompr)); - Halt(1); - end - else - WriteLn('gzread(): ', PChar(uncompr)); - - pos := gzseek(zfile, -8, SEEK_CUR); - if (pos <> 6) or (gztell(zfile) <> pos) then - begin - WriteLn('gzseek error, pos=', pos, ', gztell=', gztell(zfile)); - Halt(1); - end; - - if gzgetc(zfile) <> ' ' then - begin - WriteLn('gzgetc error'); - Halt(1); - end; - - if gzungetc(' ', zfile) <> ' ' then - begin - WriteLn('gzungetc error'); - Halt(1); - end; - - gzgets(zfile, PChar(uncompr), uncomprLen); - uncomprLen := StrLen(PChar(uncompr)); - if uncomprLen <> 7 then (* " hello!" *) - begin - WriteLn('gzgets err after gzseek: ', gzerror(zfile, err)); - Halt(1); - end; - if StrComp(PChar(uncompr), hello + 6) <> 0 then - begin - WriteLn('bad gzgets after gzseek'); - Halt(1); - end - else - WriteLn('gzgets() after gzseek: ', PChar(uncompr)); - - gzclose(zfile); -end; -{$ENDIF} - -(* =========================================================================== - * Test deflate with small buffers - *) -{$IFDEF TEST_DEFLATE} -procedure test_deflate(compr: Pointer; comprLen: LongInt); -var c_stream: z_stream; (* compression stream *) - err: Integer; - len: LongInt; -begin - len := StrLen(hello)+1; - - c_stream.zalloc := NIL; - c_stream.zfree := NIL; - c_stream.opaque := NIL; - - err := deflateInit(c_stream, Z_DEFAULT_COMPRESSION); - CHECK_ERR(err, 'deflateInit'); - - c_stream.next_in := hello; - c_stream.next_out := compr; - - while (c_stream.total_in <> len) and - (c_stream.total_out < comprLen) do - begin - c_stream.avail_out := 1; { force small buffers } - c_stream.avail_in := 1; - err := deflate(c_stream, Z_NO_FLUSH); - CHECK_ERR(err, 'deflate'); - end; - - (* Finish the stream, still forcing small buffers: *) - while TRUE do - begin - c_stream.avail_out := 1; - err := deflate(c_stream, Z_FINISH); - if err = Z_STREAM_END then - break; - CHECK_ERR(err, 'deflate'); - end; - - err := deflateEnd(c_stream); - CHECK_ERR(err, 'deflateEnd'); -end; -{$ENDIF} - -(* =========================================================================== - * Test inflate with small buffers - *) -{$IFDEF TEST_INFLATE} -procedure test_inflate(compr: Pointer; comprLen : LongInt; - uncompr: Pointer; uncomprLen : LongInt); -var err: Integer; - d_stream: z_stream; (* decompression stream *) -begin - StrCopy(PChar(uncompr), 'garbage'); - - d_stream.zalloc := NIL; - d_stream.zfree := NIL; - d_stream.opaque := NIL; - - d_stream.next_in := compr; - d_stream.avail_in := 0; - d_stream.next_out := uncompr; - - err := inflateInit(d_stream); - CHECK_ERR(err, 'inflateInit'); - - while (d_stream.total_out < uncomprLen) and - (d_stream.total_in < comprLen) do - begin - d_stream.avail_out := 1; (* force small buffers *) - d_stream.avail_in := 1; - err := inflate(d_stream, Z_NO_FLUSH); - if err = Z_STREAM_END then - break; - CHECK_ERR(err, 'inflate'); - end; - - err := inflateEnd(d_stream); - CHECK_ERR(err, 'inflateEnd'); - - if StrComp(PChar(uncompr), hello) <> 0 then - EXIT_ERR('bad inflate') - else - WriteLn('inflate(): ', PChar(uncompr)); -end; -{$ENDIF} - -(* =========================================================================== - * Test deflate with large buffers and dynamic change of compression level - *) -{$IFDEF TEST_DEFLATE} -procedure test_large_deflate(compr: Pointer; comprLen: LongInt; - uncompr: Pointer; uncomprLen: LongInt); -var c_stream: z_stream; (* compression stream *) - err: Integer; -begin - c_stream.zalloc := NIL; - c_stream.zfree := NIL; - c_stream.opaque := NIL; - - err := deflateInit(c_stream, Z_BEST_SPEED); - CHECK_ERR(err, 'deflateInit'); - - c_stream.next_out := compr; - c_stream.avail_out := Integer(comprLen); - - (* At this point, uncompr is still mostly zeroes, so it should compress - * very well: - *) - c_stream.next_in := uncompr; - c_stream.avail_in := Integer(uncomprLen); - err := deflate(c_stream, Z_NO_FLUSH); - CHECK_ERR(err, 'deflate'); - if c_stream.avail_in <> 0 then - EXIT_ERR('deflate not greedy'); - - (* Feed in already compressed data and switch to no compression: *) - deflateParams(c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY); - c_stream.next_in := compr; - c_stream.avail_in := Integer(comprLen div 2); - err := deflate(c_stream, Z_NO_FLUSH); - CHECK_ERR(err, 'deflate'); - - (* Switch back to compressing mode: *) - deflateParams(c_stream, Z_BEST_COMPRESSION, Z_FILTERED); - c_stream.next_in := uncompr; - c_stream.avail_in := Integer(uncomprLen); - err := deflate(c_stream, Z_NO_FLUSH); - CHECK_ERR(err, 'deflate'); - - err := deflate(c_stream, Z_FINISH); - if err <> Z_STREAM_END then - EXIT_ERR('deflate should report Z_STREAM_END'); - - err := deflateEnd(c_stream); - CHECK_ERR(err, 'deflateEnd'); -end; -{$ENDIF} - -(* =========================================================================== - * Test inflate with large buffers - *) -{$IFDEF TEST_INFLATE} -procedure test_large_inflate(compr: Pointer; comprLen: LongInt; - uncompr: Pointer; uncomprLen: LongInt); -var err: Integer; - d_stream: z_stream; (* decompression stream *) -begin - StrCopy(PChar(uncompr), 'garbage'); - - d_stream.zalloc := NIL; - d_stream.zfree := NIL; - d_stream.opaque := NIL; - - d_stream.next_in := compr; - d_stream.avail_in := Integer(comprLen); - - err := inflateInit(d_stream); - CHECK_ERR(err, 'inflateInit'); - - while TRUE do - begin - d_stream.next_out := uncompr; (* discard the output *) - d_stream.avail_out := Integer(uncomprLen); - err := inflate(d_stream, Z_NO_FLUSH); - if err = Z_STREAM_END then - break; - CHECK_ERR(err, 'large inflate'); - end; - - err := inflateEnd(d_stream); - CHECK_ERR(err, 'inflateEnd'); - - if d_stream.total_out <> 2 * uncomprLen + comprLen div 2 then - begin - WriteLn('bad large inflate: ', d_stream.total_out); - Halt(1); - end - else - WriteLn('large_inflate(): OK'); -end; -{$ENDIF} - -(* =========================================================================== - * Test deflate with full flush - *) -{$IFDEF TEST_FLUSH} -procedure test_flush(compr: Pointer; var comprLen : LongInt); -var c_stream: z_stream; (* compression stream *) - err: Integer; - len: Integer; -begin - len := StrLen(hello)+1; - - c_stream.zalloc := NIL; - c_stream.zfree := NIL; - c_stream.opaque := NIL; - - err := deflateInit(c_stream, Z_DEFAULT_COMPRESSION); - CHECK_ERR(err, 'deflateInit'); - - c_stream.next_in := hello; - c_stream.next_out := compr; - c_stream.avail_in := 3; - c_stream.avail_out := Integer(comprLen); - err := deflate(c_stream, Z_FULL_FLUSH); - CHECK_ERR(err, 'deflate'); - - Inc(PByteArray(compr)^[3]); (* force an error in first compressed block *) - c_stream.avail_in := len - 3; - - err := deflate(c_stream, Z_FINISH); - if err <> Z_STREAM_END then - CHECK_ERR(err, 'deflate'); - - err := deflateEnd(c_stream); - CHECK_ERR(err, 'deflateEnd'); - - comprLen := c_stream.total_out; -end; -{$ENDIF} - -(* =========================================================================== - * Test inflateSync() - *) -{$IFDEF TEST_SYNC} -procedure test_sync(compr: Pointer; comprLen: LongInt; - uncompr: Pointer; uncomprLen : LongInt); -var err: Integer; - d_stream: z_stream; (* decompression stream *) -begin - StrCopy(PChar(uncompr), 'garbage'); - - d_stream.zalloc := NIL; - d_stream.zfree := NIL; - d_stream.opaque := NIL; - - d_stream.next_in := compr; - d_stream.avail_in := 2; (* just read the zlib header *) - - err := inflateInit(d_stream); - CHECK_ERR(err, 'inflateInit'); - - d_stream.next_out := uncompr; - d_stream.avail_out := Integer(uncomprLen); - - inflate(d_stream, Z_NO_FLUSH); - CHECK_ERR(err, 'inflate'); - - d_stream.avail_in := Integer(comprLen-2); (* read all compressed data *) - err := inflateSync(d_stream); (* but skip the damaged part *) - CHECK_ERR(err, 'inflateSync'); - - err := inflate(d_stream, Z_FINISH); - if err <> Z_DATA_ERROR then - EXIT_ERR('inflate should report DATA_ERROR'); - (* Because of incorrect adler32 *) - - err := inflateEnd(d_stream); - CHECK_ERR(err, 'inflateEnd'); - - WriteLn('after inflateSync(): hel', PChar(uncompr)); -end; -{$ENDIF} - -(* =========================================================================== - * Test deflate with preset dictionary - *) -{$IFDEF TEST_DICT} -procedure test_dict_deflate(compr: Pointer; comprLen: LongInt); -var c_stream: z_stream; (* compression stream *) - err: Integer; -begin - c_stream.zalloc := NIL; - c_stream.zfree := NIL; - c_stream.opaque := NIL; - - err := deflateInit(c_stream, Z_BEST_COMPRESSION); - CHECK_ERR(err, 'deflateInit'); - - err := deflateSetDictionary(c_stream, dictionary, StrLen(dictionary)); - CHECK_ERR(err, 'deflateSetDictionary'); - - dictId := c_stream.adler; - c_stream.next_out := compr; - c_stream.avail_out := Integer(comprLen); - - c_stream.next_in := hello; - c_stream.avail_in := StrLen(hello)+1; - - err := deflate(c_stream, Z_FINISH); - if err <> Z_STREAM_END then - EXIT_ERR('deflate should report Z_STREAM_END'); - - err := deflateEnd(c_stream); - CHECK_ERR(err, 'deflateEnd'); -end; -{$ENDIF} - -(* =========================================================================== - * Test inflate with a preset dictionary - *) -{$IFDEF TEST_DICT} -procedure test_dict_inflate(compr: Pointer; comprLen: LongInt; - uncompr: Pointer; uncomprLen: LongInt); -var err: Integer; - d_stream: z_stream; (* decompression stream *) -begin - StrCopy(PChar(uncompr), 'garbage'); - - d_stream.zalloc := NIL; - d_stream.zfree := NIL; - d_stream.opaque := NIL; - - d_stream.next_in := compr; - d_stream.avail_in := Integer(comprLen); - - err := inflateInit(d_stream); - CHECK_ERR(err, 'inflateInit'); - - d_stream.next_out := uncompr; - d_stream.avail_out := Integer(uncomprLen); - - while TRUE do - begin - err := inflate(d_stream, Z_NO_FLUSH); - if err = Z_STREAM_END then - break; - if err = Z_NEED_DICT then - begin - if d_stream.adler <> dictId then - EXIT_ERR('unexpected dictionary'); - err := inflateSetDictionary(d_stream, dictionary, StrLen(dictionary)); - end; - CHECK_ERR(err, 'inflate with dict'); - end; - - err := inflateEnd(d_stream); - CHECK_ERR(err, 'inflateEnd'); - - if StrComp(PChar(uncompr), hello) <> 0 then - EXIT_ERR('bad inflate with dict') - else - WriteLn('inflate with dictionary: ', PChar(uncompr)); -end; -{$ENDIF} - -var compr, uncompr: Pointer; - comprLen, uncomprLen: LongInt; - -begin - if zlibVersion^ <> ZLIB_VERSION[1] then - EXIT_ERR('Incompatible zlib version'); - - WriteLn('zlib version: ', zlibVersion); - WriteLn('zlib compile flags: ', Format('0x%x', [zlibCompileFlags])); - - comprLen := 10000 * SizeOf(Integer); (* don't overflow on MSDOS *) - uncomprLen := comprLen; - GetMem(compr, comprLen); - GetMem(uncompr, uncomprLen); - if (compr = NIL) or (uncompr = NIL) then - EXIT_ERR('Out of memory'); - (* compr and uncompr are cleared to avoid reading uninitialized - * data and to ensure that uncompr compresses well. - *) - FillChar(compr^, comprLen, 0); - FillChar(uncompr^, uncomprLen, 0); - - {$IFDEF TEST_COMPRESS} - WriteLn('** Testing compress'); - test_compress(compr, comprLen, uncompr, uncomprLen); - {$ENDIF} - - {$IFDEF TEST_GZIO} - WriteLn('** Testing gzio'); - if ParamCount >= 1 then - test_gzio(ParamStr(1), uncompr, uncomprLen) - else - test_gzio(TESTFILE, uncompr, uncomprLen); - {$ENDIF} - - {$IFDEF TEST_DEFLATE} - WriteLn('** Testing deflate with small buffers'); - test_deflate(compr, comprLen); - {$ENDIF} - {$IFDEF TEST_INFLATE} - WriteLn('** Testing inflate with small buffers'); - test_inflate(compr, comprLen, uncompr, uncomprLen); - {$ENDIF} - - {$IFDEF TEST_DEFLATE} - WriteLn('** Testing deflate with large buffers'); - test_large_deflate(compr, comprLen, uncompr, uncomprLen); - {$ENDIF} - {$IFDEF TEST_INFLATE} - WriteLn('** Testing inflate with large buffers'); - test_large_inflate(compr, comprLen, uncompr, uncomprLen); - {$ENDIF} - - {$IFDEF TEST_FLUSH} - WriteLn('** Testing deflate with full flush'); - test_flush(compr, comprLen); - {$ENDIF} - {$IFDEF TEST_SYNC} - WriteLn('** Testing inflateSync'); - test_sync(compr, comprLen, uncompr, uncomprLen); - {$ENDIF} - comprLen := uncomprLen; - - {$IFDEF TEST_DICT} - WriteLn('** Testing deflate and inflate with preset dictionary'); - test_dict_deflate(compr, comprLen); - test_dict_inflate(compr, comprLen, uncompr, uncomprLen); - {$ENDIF} - - FreeMem(compr, comprLen); - FreeMem(uncompr, uncomprLen); -end. diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/pascal/readme.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/pascal/readme.txt deleted file mode 100644 index 60e87c8..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/pascal/readme.txt +++ /dev/null @@ -1,76 +0,0 @@ - -This directory contains a Pascal (Delphi, Kylix) interface to the -zlib data compression library. - - -Directory listing -================= - -zlibd32.mak makefile for Borland C++ -example.pas usage example of zlib -zlibpas.pas the Pascal interface to zlib -readme.txt this file - - -Compatibility notes -=================== - -- Although the name "zlib" would have been more normal for the - zlibpas unit, this name is already taken by Borland's ZLib unit. - This is somehow unfortunate, because that unit is not a genuine - interface to the full-fledged zlib functionality, but a suite of - class wrappers around zlib streams. Other essential features, - such as checksums, are missing. - It would have been more appropriate for that unit to have a name - like "ZStreams", or something similar. - -- The C and zlib-supplied types int, uInt, long, uLong, etc. are - translated directly into Pascal types of similar sizes (Integer, - LongInt, etc.), to avoid namespace pollution. In particular, - there is no conversion of unsigned int into a Pascal unsigned - integer. The Word type is non-portable and has the same size - (16 bits) both in a 16-bit and in a 32-bit environment, unlike - Integer. Even if there is a 32-bit Cardinal type, there is no - real need for unsigned int in zlib under a 32-bit environment. - -- Except for the callbacks, the zlib function interfaces are - assuming the calling convention normally used in Pascal - (__pascal for DOS and Windows16, __fastcall for Windows32). - Since the cdecl keyword is used, the old Turbo Pascal does - not work with this interface. - -- The gz* function interfaces are not translated, to avoid - interfacing problems with the C runtime library. Besides, - gzprintf(gzFile file, const char *format, ...) - cannot be translated into Pascal. - - -Legal issues -============ - -The zlibpas interface is: - Copyright (C) 1995-2003 Jean-loup Gailly and Mark Adler. - Copyright (C) 1998 by Bob Dellaca. - Copyright (C) 2003 by Cosmin Truta. - -The example program is: - Copyright (C) 1995-2003 by Jean-loup Gailly. - Copyright (C) 1998,1999,2000 by Jacques Nomssi Nzali. - Copyright (C) 2003 by Cosmin Truta. - - This software is provided 'as-is', without any express or implied - warranty. In no event will the author be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/pascal/zlibd32.mak b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/pascal/zlibd32.mak deleted file mode 100644 index 9bb00b7..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/pascal/zlibd32.mak +++ /dev/null @@ -1,99 +0,0 @@ -# Makefile for zlib -# For use with Delphi and C++ Builder under Win32 -# Updated for zlib 1.2.x by Cosmin Truta - -# ------------ Borland C++ ------------ - -# This project uses the Delphi (fastcall/register) calling convention: -LOC = -DZEXPORT=__fastcall -DZEXPORTVA=__cdecl - -CC = bcc32 -LD = bcc32 -AR = tlib -# do not use "-pr" in CFLAGS -CFLAGS = -a -d -k- -O2 $(LOC) -LDFLAGS = - - -# variables -ZLIB_LIB = zlib.lib - -OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj -OBJ2 = gzwrite.obj infback.obj inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj -OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzclose.obj+gzlib.obj+gzread.obj -OBJP2 = +gzwrite.obj+infback.obj+inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj - - -# targets -all: $(ZLIB_LIB) example.exe minigzip.exe - -.c.obj: - $(CC) -c $(CFLAGS) $*.c - -adler32.obj: adler32.c zlib.h zconf.h - -compress.obj: compress.c zlib.h zconf.h - -crc32.obj: crc32.c zlib.h zconf.h crc32.h - -deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h - -gzclose.obj: gzclose.c zlib.h zconf.h gzguts.h - -gzlib.obj: gzlib.c zlib.h zconf.h gzguts.h - -gzread.obj: gzread.c zlib.h zconf.h gzguts.h - -gzwrite.obj: gzwrite.c zlib.h zconf.h gzguts.h - -infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ - inffast.h inffixed.h - -inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ - inffast.h - -inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ - inffast.h inffixed.h - -inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h - -trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h - -uncompr.obj: uncompr.c zlib.h zconf.h - -zutil.obj: zutil.c zutil.h zlib.h zconf.h - -example.obj: test/example.c zlib.h zconf.h - -minigzip.obj: test/minigzip.c zlib.h zconf.h - - -# For the sake of the old Borland make, -# the command line is cut to fit in the MS-DOS 128 byte limit: -$(ZLIB_LIB): $(OBJ1) $(OBJ2) - -del $(ZLIB_LIB) - $(AR) $(ZLIB_LIB) $(OBJP1) - $(AR) $(ZLIB_LIB) $(OBJP2) - - -# testing -test: example.exe minigzip.exe - example - echo hello world | minigzip | minigzip -d - -example.exe: example.obj $(ZLIB_LIB) - $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB) - -minigzip.exe: minigzip.obj $(ZLIB_LIB) - $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB) - - -# cleanup -clean: - -del *.obj - -del *.exe - -del *.lib - -del *.tds - -del zlib.bak - -del foo.gz - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/pascal/zlibpas.pas b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/pascal/zlibpas.pas deleted file mode 100644 index adb5cd6..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/pascal/zlibpas.pas +++ /dev/null @@ -1,276 +0,0 @@ -(* zlibpas -- Pascal interface to the zlib data compression library - * - * Copyright (C) 2003 Cosmin Truta. - * Derived from original sources by Bob Dellaca. - * For conditions of distribution and use, see copyright notice in readme.txt - *) - -unit zlibpas; - -interface - -const - ZLIB_VERSION = '1.2.12'; - ZLIB_VERNUM = $12a0; - -type - alloc_func = function(opaque: Pointer; items, size: Integer): Pointer; - cdecl; - free_func = procedure(opaque, address: Pointer); - cdecl; - - in_func = function(opaque: Pointer; var buf: PByte): Integer; - cdecl; - out_func = function(opaque: Pointer; buf: PByte; size: Integer): Integer; - cdecl; - - z_streamp = ^z_stream; - z_stream = packed record - next_in: PChar; (* next input byte *) - avail_in: Integer; (* number of bytes available at next_in *) - total_in: LongInt; (* total nb of input bytes read so far *) - - next_out: PChar; (* next output byte should be put there *) - avail_out: Integer; (* remaining free space at next_out *) - total_out: LongInt; (* total nb of bytes output so far *) - - msg: PChar; (* last error message, NULL if no error *) - state: Pointer; (* not visible by applications *) - - zalloc: alloc_func; (* used to allocate the internal state *) - zfree: free_func; (* used to free the internal state *) - opaque: Pointer; (* private data object passed to zalloc and zfree *) - - data_type: Integer; (* best guess about the data type: ascii or binary *) - adler: LongInt; (* adler32 value of the uncompressed data *) - reserved: LongInt; (* reserved for future use *) - end; - - gz_headerp = ^gz_header; - gz_header = packed record - text: Integer; (* true if compressed data believed to be text *) - time: LongInt; (* modification time *) - xflags: Integer; (* extra flags (not used when writing a gzip file) *) - os: Integer; (* operating system *) - extra: PChar; (* pointer to extra field or Z_NULL if none *) - extra_len: Integer; (* extra field length (valid if extra != Z_NULL) *) - extra_max: Integer; (* space at extra (only when reading header) *) - name: PChar; (* pointer to zero-terminated file name or Z_NULL *) - name_max: Integer; (* space at name (only when reading header) *) - comment: PChar; (* pointer to zero-terminated comment or Z_NULL *) - comm_max: Integer; (* space at comment (only when reading header) *) - hcrc: Integer; (* true if there was or will be a header crc *) - done: Integer; (* true when done reading gzip header *) - end; - -(* constants *) -const - Z_NO_FLUSH = 0; - Z_PARTIAL_FLUSH = 1; - Z_SYNC_FLUSH = 2; - Z_FULL_FLUSH = 3; - Z_FINISH = 4; - Z_BLOCK = 5; - Z_TREES = 6; - - Z_OK = 0; - Z_STREAM_END = 1; - Z_NEED_DICT = 2; - Z_ERRNO = -1; - Z_STREAM_ERROR = -2; - Z_DATA_ERROR = -3; - Z_MEM_ERROR = -4; - Z_BUF_ERROR = -5; - Z_VERSION_ERROR = -6; - - Z_NO_COMPRESSION = 0; - Z_BEST_SPEED = 1; - Z_BEST_COMPRESSION = 9; - Z_DEFAULT_COMPRESSION = -1; - - Z_FILTERED = 1; - Z_HUFFMAN_ONLY = 2; - Z_RLE = 3; - Z_FIXED = 4; - Z_DEFAULT_STRATEGY = 0; - - Z_BINARY = 0; - Z_TEXT = 1; - Z_ASCII = 1; - Z_UNKNOWN = 2; - - Z_DEFLATED = 8; - -(* basic functions *) -function zlibVersion: PChar; -function deflateInit(var strm: z_stream; level: Integer): Integer; -function deflate(var strm: z_stream; flush: Integer): Integer; -function deflateEnd(var strm: z_stream): Integer; -function inflateInit(var strm: z_stream): Integer; -function inflate(var strm: z_stream; flush: Integer): Integer; -function inflateEnd(var strm: z_stream): Integer; - -(* advanced functions *) -function deflateInit2(var strm: z_stream; level, method, windowBits, - memLevel, strategy: Integer): Integer; -function deflateSetDictionary(var strm: z_stream; const dictionary: PChar; - dictLength: Integer): Integer; -function deflateCopy(var dest, source: z_stream): Integer; -function deflateReset(var strm: z_stream): Integer; -function deflateParams(var strm: z_stream; level, strategy: Integer): Integer; -function deflateTune(var strm: z_stream; good_length, max_lazy, nice_length, max_chain: Integer): Integer; -function deflateBound(var strm: z_stream; sourceLen: LongInt): LongInt; -function deflatePending(var strm: z_stream; var pending: Integer; var bits: Integer): Integer; -function deflatePrime(var strm: z_stream; bits, value: Integer): Integer; -function deflateSetHeader(var strm: z_stream; head: gz_header): Integer; -function inflateInit2(var strm: z_stream; windowBits: Integer): Integer; -function inflateSetDictionary(var strm: z_stream; const dictionary: PChar; - dictLength: Integer): Integer; -function inflateSync(var strm: z_stream): Integer; -function inflateCopy(var dest, source: z_stream): Integer; -function inflateReset(var strm: z_stream): Integer; -function inflateReset2(var strm: z_stream; windowBits: Integer): Integer; -function inflatePrime(var strm: z_stream; bits, value: Integer): Integer; -function inflateMark(var strm: z_stream): LongInt; -function inflateGetHeader(var strm: z_stream; var head: gz_header): Integer; -function inflateBackInit(var strm: z_stream; - windowBits: Integer; window: PChar): Integer; -function inflateBack(var strm: z_stream; in_fn: in_func; in_desc: Pointer; - out_fn: out_func; out_desc: Pointer): Integer; -function inflateBackEnd(var strm: z_stream): Integer; -function zlibCompileFlags: LongInt; - -(* utility functions *) -function compress(dest: PChar; var destLen: LongInt; - const source: PChar; sourceLen: LongInt): Integer; -function compress2(dest: PChar; var destLen: LongInt; - const source: PChar; sourceLen: LongInt; - level: Integer): Integer; -function compressBound(sourceLen: LongInt): LongInt; -function uncompress(dest: PChar; var destLen: LongInt; - const source: PChar; sourceLen: LongInt): Integer; - -(* checksum functions *) -function adler32(adler: LongInt; const buf: PChar; len: Integer): LongInt; -function adler32_combine(adler1, adler2, len2: LongInt): LongInt; -function crc32(crc: LongInt; const buf: PChar; len: Integer): LongInt; -function crc32_combine(crc1, crc2, len2: LongInt): LongInt; - -(* various hacks, don't look :) *) -function deflateInit_(var strm: z_stream; level: Integer; - const version: PChar; stream_size: Integer): Integer; -function inflateInit_(var strm: z_stream; const version: PChar; - stream_size: Integer): Integer; -function deflateInit2_(var strm: z_stream; - level, method, windowBits, memLevel, strategy: Integer; - const version: PChar; stream_size: Integer): Integer; -function inflateInit2_(var strm: z_stream; windowBits: Integer; - const version: PChar; stream_size: Integer): Integer; -function inflateBackInit_(var strm: z_stream; - windowBits: Integer; window: PChar; - const version: PChar; stream_size: Integer): Integer; - - -implementation - -{$L adler32.obj} -{$L compress.obj} -{$L crc32.obj} -{$L deflate.obj} -{$L infback.obj} -{$L inffast.obj} -{$L inflate.obj} -{$L inftrees.obj} -{$L trees.obj} -{$L uncompr.obj} -{$L zutil.obj} - -function adler32; external; -function adler32_combine; external; -function compress; external; -function compress2; external; -function compressBound; external; -function crc32; external; -function crc32_combine; external; -function deflate; external; -function deflateBound; external; -function deflateCopy; external; -function deflateEnd; external; -function deflateInit_; external; -function deflateInit2_; external; -function deflateParams; external; -function deflatePending; external; -function deflatePrime; external; -function deflateReset; external; -function deflateSetDictionary; external; -function deflateSetHeader; external; -function deflateTune; external; -function inflate; external; -function inflateBack; external; -function inflateBackEnd; external; -function inflateBackInit_; external; -function inflateCopy; external; -function inflateEnd; external; -function inflateGetHeader; external; -function inflateInit_; external; -function inflateInit2_; external; -function inflateMark; external; -function inflatePrime; external; -function inflateReset; external; -function inflateReset2; external; -function inflateSetDictionary; external; -function inflateSync; external; -function uncompress; external; -function zlibCompileFlags; external; -function zlibVersion; external; - -function deflateInit(var strm: z_stream; level: Integer): Integer; -begin - Result := deflateInit_(strm, level, ZLIB_VERSION, sizeof(z_stream)); -end; - -function deflateInit2(var strm: z_stream; level, method, windowBits, memLevel, - strategy: Integer): Integer; -begin - Result := deflateInit2_(strm, level, method, windowBits, memLevel, strategy, - ZLIB_VERSION, sizeof(z_stream)); -end; - -function inflateInit(var strm: z_stream): Integer; -begin - Result := inflateInit_(strm, ZLIB_VERSION, sizeof(z_stream)); -end; - -function inflateInit2(var strm: z_stream; windowBits: Integer): Integer; -begin - Result := inflateInit2_(strm, windowBits, ZLIB_VERSION, sizeof(z_stream)); -end; - -function inflateBackInit(var strm: z_stream; - windowBits: Integer; window: PChar): Integer; -begin - Result := inflateBackInit_(strm, windowBits, window, - ZLIB_VERSION, sizeof(z_stream)); -end; - -function _malloc(Size: Integer): Pointer; cdecl; -begin - GetMem(Result, Size); -end; - -procedure _free(Block: Pointer); cdecl; -begin - FreeMem(Block); -end; - -procedure _memset(P: Pointer; B: Byte; count: Integer); cdecl; -begin - FillChar(P^, count, B); -end; - -procedure _memcpy(dest, source: Pointer; count: Integer); cdecl; -begin - Move(source^, dest^, count); -end; - -end. diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/puff/Makefile b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/puff/Makefile deleted file mode 100644 index 0e2594c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/puff/Makefile +++ /dev/null @@ -1,42 +0,0 @@ -CFLAGS=-O - -puff: puff.o pufftest.o - -puff.o: puff.h - -pufftest.o: puff.h - -test: puff - puff zeros.raw - -puft: puff.c puff.h pufftest.o - cc -fprofile-arcs -ftest-coverage -o puft puff.c pufftest.o - -# puff full coverage test (should say 100%) -cov: puft - @rm -f *.gcov *.gcda - @puft -w zeros.raw 2>&1 | cat > /dev/null - @echo '04' | xxd -r -p | puft 2> /dev/null || test $$? -eq 2 - @echo '00' | xxd -r -p | puft 2> /dev/null || test $$? -eq 2 - @echo '00 00 00 00 00' | xxd -r -p | puft 2> /dev/null || test $$? -eq 254 - @echo '00 01 00 fe ff' | xxd -r -p | puft 2> /dev/null || test $$? -eq 2 - @echo '01 01 00 fe ff 0a' | xxd -r -p | puft -f 2>&1 | cat > /dev/null - @echo '02 7e ff ff' | xxd -r -p | puft 2> /dev/null || test $$? -eq 246 - @echo '02' | xxd -r -p | puft 2> /dev/null || test $$? -eq 2 - @echo '04 80 49 92 24 49 92 24 0f b4 ff ff c3 04' | xxd -r -p | puft 2> /dev/null || test $$? -eq 2 - @echo '04 80 49 92 24 49 92 24 71 ff ff 93 11 00' | xxd -r -p | puft 2> /dev/null || test $$? -eq 249 - @echo '04 c0 81 08 00 00 00 00 20 7f eb 0b 00 00' | xxd -r -p | puft 2> /dev/null || test $$? -eq 246 - @echo '0b 00 00' | xxd -r -p | puft -f 2>&1 | cat > /dev/null - @echo '1a 07' | xxd -r -p | puft 2> /dev/null || test $$? -eq 246 - @echo '0c c0 81 00 00 00 00 00 90 ff 6b 04' | xxd -r -p | puft 2> /dev/null || test $$? -eq 245 - @puft -f zeros.raw 2>&1 | cat > /dev/null - @echo 'fc 00 00' | xxd -r -p | puft 2> /dev/null || test $$? -eq 253 - @echo '04 00 fe ff' | xxd -r -p | puft 2> /dev/null || test $$? -eq 252 - @echo '04 00 24 49' | xxd -r -p | puft 2> /dev/null || test $$? -eq 251 - @echo '04 80 49 92 24 49 92 24 0f b4 ff ff c3 84' | xxd -r -p | puft 2> /dev/null || test $$? -eq 248 - @echo '04 00 24 e9 ff ff' | xxd -r -p | puft 2> /dev/null || test $$? -eq 250 - @echo '04 00 24 e9 ff 6d' | xxd -r -p | puft 2> /dev/null || test $$? -eq 247 - @gcov -n puff.c - -clean: - rm -f puff puft *.o *.gc* diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/puff/README b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/puff/README deleted file mode 100644 index bbc4cb5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/puff/README +++ /dev/null @@ -1,63 +0,0 @@ -Puff -- A Simple Inflate -3 Mar 2003 -Mark Adler -madler@alumni.caltech.edu - -What this is -- - -puff.c provides the routine puff() to decompress the deflate data format. It -does so more slowly than zlib, but the code is about one-fifth the size of the -inflate code in zlib, and written to be very easy to read. - -Why I wrote this -- - -puff.c was written to document the deflate format unambiguously, by virtue of -being working C code. It is meant to supplement RFC 1951, which formally -describes the deflate format. I have received many questions on details of the -deflate format, and I hope that reading this code will answer those questions. -puff.c is heavily commented with details of the deflate format, especially -those little nooks and cranies of the format that might not be obvious from a -specification. - -puff.c may also be useful in applications where code size or memory usage is a -very limited resource, and speed is not as important. - -How to use it -- - -Well, most likely you should just be reading puff.c and using zlib for actual -applications, but if you must ... - -Include puff.h in your code, which provides this prototype: - -int puff(unsigned char *dest, /* pointer to destination pointer */ - unsigned long *destlen, /* amount of output space */ - unsigned char *source, /* pointer to source data pointer */ - unsigned long *sourcelen); /* amount of input available */ - -Then you can call puff() to decompress a deflate stream that is in memory in -its entirety at source, to a sufficiently sized block of memory for the -decompressed data at dest. puff() is the only external symbol in puff.c The -only C library functions that puff.c needs are setjmp() and longjmp(), which -are used to simplify error checking in the code to improve readabilty. puff.c -does no memory allocation, and uses less than 2K bytes off of the stack. - -If destlen is not enough space for the uncompressed data, then inflate will -return an error without writing more than destlen bytes. Note that this means -that in order to decompress the deflate data successfully, you need to know -the size of the uncompressed data ahead of time. - -If needed, puff() can determine the size of the uncompressed data with no -output space. This is done by passing dest equal to (unsigned char *)0. Then -the initial value of *destlen is ignored and *destlen is set to the length of -the uncompressed data. So if the size of the uncompressed data is not known, -then two passes of puff() can be used--first to determine the size, and second -to do the actual inflation after allocating the appropriate memory. Not -pretty, but it works. (This is one of the reasons you should be using zlib.) - -The deflate format is self-terminating. If the deflate stream does not end -in *sourcelen bytes, puff() will return an error without reading at or past -endsource. - -On return, *sourcelen is updated to the amount of input data consumed, and -*destlen is updated to the size of the uncompressed data. See the comments -in puff.c for the possible return codes for puff(). diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/puff/puff.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/puff/puff.c deleted file mode 100644 index c6c90d7..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/puff/puff.c +++ /dev/null @@ -1,840 +0,0 @@ -/* - * puff.c - * Copyright (C) 2002-2013 Mark Adler - * For conditions of distribution and use, see copyright notice in puff.h - * version 2.3, 21 Jan 2013 - * - * puff.c is a simple inflate written to be an unambiguous way to specify the - * deflate format. It is not written for speed but rather simplicity. As a - * side benefit, this code might actually be useful when small code is more - * important than speed, such as bootstrap applications. For typical deflate - * data, zlib's inflate() is about four times as fast as puff(). zlib's - * inflate compiles to around 20K on my machine, whereas puff.c compiles to - * around 4K on my machine (a PowerPC using GNU cc). If the faster decode() - * function here is used, then puff() is only twice as slow as zlib's - * inflate(). - * - * All dynamically allocated memory comes from the stack. The stack required - * is less than 2K bytes. This code is compatible with 16-bit int's and - * assumes that long's are at least 32 bits. puff.c uses the short data type, - * assumed to be 16 bits, for arrays in order to conserve memory. The code - * works whether integers are stored big endian or little endian. - * - * In the comments below are "Format notes" that describe the inflate process - * and document some of the less obvious aspects of the format. This source - * code is meant to supplement RFC 1951, which formally describes the deflate - * format: - * - * http://www.zlib.org/rfc-deflate.html - */ - -/* - * Change history: - * - * 1.0 10 Feb 2002 - First version - * 1.1 17 Feb 2002 - Clarifications of some comments and notes - * - Update puff() dest and source pointers on negative - * errors to facilitate debugging deflators - * - Remove longest from struct huffman -- not needed - * - Simplify offs[] index in construct() - * - Add input size and checking, using longjmp() to - * maintain easy readability - * - Use short data type for large arrays - * - Use pointers instead of long to specify source and - * destination sizes to avoid arbitrary 4 GB limits - * 1.2 17 Mar 2002 - Add faster version of decode(), doubles speed (!), - * but leave simple version for readabilty - * - Make sure invalid distances detected if pointers - * are 16 bits - * - Fix fixed codes table error - * - Provide a scanning mode for determining size of - * uncompressed data - * 1.3 20 Mar 2002 - Go back to lengths for puff() parameters [Gailly] - * - Add a puff.h file for the interface - * - Add braces in puff() for else do [Gailly] - * - Use indexes instead of pointers for readability - * 1.4 31 Mar 2002 - Simplify construct() code set check - * - Fix some comments - * - Add FIXLCODES #define - * 1.5 6 Apr 2002 - Minor comment fixes - * 1.6 7 Aug 2002 - Minor format changes - * 1.7 3 Mar 2003 - Added test code for distribution - * - Added zlib-like license - * 1.8 9 Jan 2004 - Added some comments on no distance codes case - * 1.9 21 Feb 2008 - Fix bug on 16-bit integer architectures [Pohland] - * - Catch missing end-of-block symbol error - * 2.0 25 Jul 2008 - Add #define to permit distance too far back - * - Add option in TEST code for puff to write the data - * - Add option in TEST code to skip input bytes - * - Allow TEST code to read from piped stdin - * 2.1 4 Apr 2010 - Avoid variable initialization for happier compilers - * - Avoid unsigned comparisons for even happier compilers - * 2.2 25 Apr 2010 - Fix bug in variable initializations [Oberhumer] - * - Add const where appropriate [Oberhumer] - * - Split if's and ?'s for coverage testing - * - Break out test code to separate file - * - Move NIL to puff.h - * - Allow incomplete code only if single code length is 1 - * - Add full code coverage test to Makefile - * 2.3 21 Jan 2013 - Check for invalid code length codes in dynamic blocks - */ - -#include /* for setjmp(), longjmp(), and jmp_buf */ -#include "puff.h" /* prototype for puff() */ - -#define local static /* for local function definitions */ - -/* - * Maximums for allocations and loops. It is not useful to change these -- - * they are fixed by the deflate format. - */ -#define MAXBITS 15 /* maximum bits in a code */ -#define MAXLCODES 286 /* maximum number of literal/length codes */ -#define MAXDCODES 30 /* maximum number of distance codes */ -#define MAXCODES (MAXLCODES+MAXDCODES) /* maximum codes lengths to read */ -#define FIXLCODES 288 /* number of fixed literal/length codes */ - -/* input and output state */ -struct state { - /* output state */ - unsigned char *out; /* output buffer */ - unsigned long outlen; /* available space at out */ - unsigned long outcnt; /* bytes written to out so far */ - - /* input state */ - const unsigned char *in; /* input buffer */ - unsigned long inlen; /* available input at in */ - unsigned long incnt; /* bytes read so far */ - int bitbuf; /* bit buffer */ - int bitcnt; /* number of bits in bit buffer */ - - /* input limit error return state for bits() and decode() */ - jmp_buf env; -}; - -/* - * Return need bits from the input stream. This always leaves less than - * eight bits in the buffer. bits() works properly for need == 0. - * - * Format notes: - * - * - Bits are stored in bytes from the least significant bit to the most - * significant bit. Therefore bits are dropped from the bottom of the bit - * buffer, using shift right, and new bytes are appended to the top of the - * bit buffer, using shift left. - */ -local int bits(struct state *s, int need) -{ - long val; /* bit accumulator (can use up to 20 bits) */ - - /* load at least need bits into val */ - val = s->bitbuf; - while (s->bitcnt < need) { - if (s->incnt == s->inlen) - longjmp(s->env, 1); /* out of input */ - val |= (long)(s->in[s->incnt++]) << s->bitcnt; /* load eight bits */ - s->bitcnt += 8; - } - - /* drop need bits and update buffer, always zero to seven bits left */ - s->bitbuf = (int)(val >> need); - s->bitcnt -= need; - - /* return need bits, zeroing the bits above that */ - return (int)(val & ((1L << need) - 1)); -} - -/* - * Process a stored block. - * - * Format notes: - * - * - After the two-bit stored block type (00), the stored block length and - * stored bytes are byte-aligned for fast copying. Therefore any leftover - * bits in the byte that has the last bit of the type, as many as seven, are - * discarded. The value of the discarded bits are not defined and should not - * be checked against any expectation. - * - * - The second inverted copy of the stored block length does not have to be - * checked, but it's probably a good idea to do so anyway. - * - * - A stored block can have zero length. This is sometimes used to byte-align - * subsets of the compressed data for random access or partial recovery. - */ -local int stored(struct state *s) -{ - unsigned len; /* length of stored block */ - - /* discard leftover bits from current byte (assumes s->bitcnt < 8) */ - s->bitbuf = 0; - s->bitcnt = 0; - - /* get length and check against its one's complement */ - if (s->incnt + 4 > s->inlen) - return 2; /* not enough input */ - len = s->in[s->incnt++]; - len |= s->in[s->incnt++] << 8; - if (s->in[s->incnt++] != (~len & 0xff) || - s->in[s->incnt++] != ((~len >> 8) & 0xff)) - return -2; /* didn't match complement! */ - - /* copy len bytes from in to out */ - if (s->incnt + len > s->inlen) - return 2; /* not enough input */ - if (s->out != NIL) { - if (s->outcnt + len > s->outlen) - return 1; /* not enough output space */ - while (len--) - s->out[s->outcnt++] = s->in[s->incnt++]; - } - else { /* just scanning */ - s->outcnt += len; - s->incnt += len; - } - - /* done with a valid stored block */ - return 0; -} - -/* - * Huffman code decoding tables. count[1..MAXBITS] is the number of symbols of - * each length, which for a canonical code are stepped through in order. - * symbol[] are the symbol values in canonical order, where the number of - * entries is the sum of the counts in count[]. The decoding process can be - * seen in the function decode() below. - */ -struct huffman { - short *count; /* number of symbols of each length */ - short *symbol; /* canonically ordered symbols */ -}; - -/* - * Decode a code from the stream s using huffman table h. Return the symbol or - * a negative value if there is an error. If all of the lengths are zero, i.e. - * an empty code, or if the code is incomplete and an invalid code is received, - * then -10 is returned after reading MAXBITS bits. - * - * Format notes: - * - * - The codes as stored in the compressed data are bit-reversed relative to - * a simple integer ordering of codes of the same lengths. Hence below the - * bits are pulled from the compressed data one at a time and used to - * build the code value reversed from what is in the stream in order to - * permit simple integer comparisons for decoding. A table-based decoding - * scheme (as used in zlib) does not need to do this reversal. - * - * - The first code for the shortest length is all zeros. Subsequent codes of - * the same length are simply integer increments of the previous code. When - * moving up a length, a zero bit is appended to the code. For a complete - * code, the last code of the longest length will be all ones. - * - * - Incomplete codes are handled by this decoder, since they are permitted - * in the deflate format. See the format notes for fixed() and dynamic(). - */ -#ifdef SLOW -local int decode(struct state *s, const struct huffman *h) -{ - int len; /* current number of bits in code */ - int code; /* len bits being decoded */ - int first; /* first code of length len */ - int count; /* number of codes of length len */ - int index; /* index of first code of length len in symbol table */ - - code = first = index = 0; - for (len = 1; len <= MAXBITS; len++) { - code |= bits(s, 1); /* get next bit */ - count = h->count[len]; - if (code - count < first) /* if length len, return symbol */ - return h->symbol[index + (code - first)]; - index += count; /* else update for next length */ - first += count; - first <<= 1; - code <<= 1; - } - return -10; /* ran out of codes */ -} - -/* - * A faster version of decode() for real applications of this code. It's not - * as readable, but it makes puff() twice as fast. And it only makes the code - * a few percent larger. - */ -#else /* !SLOW */ -local int decode(struct state *s, const struct huffman *h) -{ - int len; /* current number of bits in code */ - int code; /* len bits being decoded */ - int first; /* first code of length len */ - int count; /* number of codes of length len */ - int index; /* index of first code of length len in symbol table */ - int bitbuf; /* bits from stream */ - int left; /* bits left in next or left to process */ - short *next; /* next number of codes */ - - bitbuf = s->bitbuf; - left = s->bitcnt; - code = first = index = 0; - len = 1; - next = h->count + 1; - while (1) { - while (left--) { - code |= bitbuf & 1; - bitbuf >>= 1; - count = *next++; - if (code - count < first) { /* if length len, return symbol */ - s->bitbuf = bitbuf; - s->bitcnt = (s->bitcnt - len) & 7; - return h->symbol[index + (code - first)]; - } - index += count; /* else update for next length */ - first += count; - first <<= 1; - code <<= 1; - len++; - } - left = (MAXBITS+1) - len; - if (left == 0) - break; - if (s->incnt == s->inlen) - longjmp(s->env, 1); /* out of input */ - bitbuf = s->in[s->incnt++]; - if (left > 8) - left = 8; - } - return -10; /* ran out of codes */ -} -#endif /* SLOW */ - -/* - * Given the list of code lengths length[0..n-1] representing a canonical - * Huffman code for n symbols, construct the tables required to decode those - * codes. Those tables are the number of codes of each length, and the symbols - * sorted by length, retaining their original order within each length. The - * return value is zero for a complete code set, negative for an over- - * subscribed code set, and positive for an incomplete code set. The tables - * can be used if the return value is zero or positive, but they cannot be used - * if the return value is negative. If the return value is zero, it is not - * possible for decode() using that table to return an error--any stream of - * enough bits will resolve to a symbol. If the return value is positive, then - * it is possible for decode() using that table to return an error for received - * codes past the end of the incomplete lengths. - * - * Not used by decode(), but used for error checking, h->count[0] is the number - * of the n symbols not in the code. So n - h->count[0] is the number of - * codes. This is useful for checking for incomplete codes that have more than - * one symbol, which is an error in a dynamic block. - * - * Assumption: for all i in 0..n-1, 0 <= length[i] <= MAXBITS - * This is assured by the construction of the length arrays in dynamic() and - * fixed() and is not verified by construct(). - * - * Format notes: - * - * - Permitted and expected examples of incomplete codes are one of the fixed - * codes and any code with a single symbol which in deflate is coded as one - * bit instead of zero bits. See the format notes for fixed() and dynamic(). - * - * - Within a given code length, the symbols are kept in ascending order for - * the code bits definition. - */ -local int construct(struct huffman *h, const short *length, int n) -{ - int symbol; /* current symbol when stepping through length[] */ - int len; /* current length when stepping through h->count[] */ - int left; /* number of possible codes left of current length */ - short offs[MAXBITS+1]; /* offsets in symbol table for each length */ - - /* count number of codes of each length */ - for (len = 0; len <= MAXBITS; len++) - h->count[len] = 0; - for (symbol = 0; symbol < n; symbol++) - (h->count[length[symbol]])++; /* assumes lengths are within bounds */ - if (h->count[0] == n) /* no codes! */ - return 0; /* complete, but decode() will fail */ - - /* check for an over-subscribed or incomplete set of lengths */ - left = 1; /* one possible code of zero length */ - for (len = 1; len <= MAXBITS; len++) { - left <<= 1; /* one more bit, double codes left */ - left -= h->count[len]; /* deduct count from possible codes */ - if (left < 0) - return left; /* over-subscribed--return negative */ - } /* left > 0 means incomplete */ - - /* generate offsets into symbol table for each length for sorting */ - offs[1] = 0; - for (len = 1; len < MAXBITS; len++) - offs[len + 1] = offs[len] + h->count[len]; - - /* - * put symbols in table sorted by length, by symbol order within each - * length - */ - for (symbol = 0; symbol < n; symbol++) - if (length[symbol] != 0) - h->symbol[offs[length[symbol]]++] = symbol; - - /* return zero for complete set, positive for incomplete set */ - return left; -} - -/* - * Decode literal/length and distance codes until an end-of-block code. - * - * Format notes: - * - * - Compressed data that is after the block type if fixed or after the code - * description if dynamic is a combination of literals and length/distance - * pairs terminated by and end-of-block code. Literals are simply Huffman - * coded bytes. A length/distance pair is a coded length followed by a - * coded distance to represent a string that occurs earlier in the - * uncompressed data that occurs again at the current location. - * - * - Literals, lengths, and the end-of-block code are combined into a single - * code of up to 286 symbols. They are 256 literals (0..255), 29 length - * symbols (257..285), and the end-of-block symbol (256). - * - * - There are 256 possible lengths (3..258), and so 29 symbols are not enough - * to represent all of those. Lengths 3..10 and 258 are in fact represented - * by just a length symbol. Lengths 11..257 are represented as a symbol and - * some number of extra bits that are added as an integer to the base length - * of the length symbol. The number of extra bits is determined by the base - * length symbol. These are in the static arrays below, lens[] for the base - * lengths and lext[] for the corresponding number of extra bits. - * - * - The reason that 258 gets its own symbol is that the longest length is used - * often in highly redundant files. Note that 258 can also be coded as the - * base value 227 plus the maximum extra value of 31. While a good deflate - * should never do this, it is not an error, and should be decoded properly. - * - * - If a length is decoded, including its extra bits if any, then it is - * followed a distance code. There are up to 30 distance symbols. Again - * there are many more possible distances (1..32768), so extra bits are added - * to a base value represented by the symbol. The distances 1..4 get their - * own symbol, but the rest require extra bits. The base distances and - * corresponding number of extra bits are below in the static arrays dist[] - * and dext[]. - * - * - Literal bytes are simply written to the output. A length/distance pair is - * an instruction to copy previously uncompressed bytes to the output. The - * copy is from distance bytes back in the output stream, copying for length - * bytes. - * - * - Distances pointing before the beginning of the output data are not - * permitted. - * - * - Overlapped copies, where the length is greater than the distance, are - * allowed and common. For example, a distance of one and a length of 258 - * simply copies the last byte 258 times. A distance of four and a length of - * twelve copies the last four bytes three times. A simple forward copy - * ignoring whether the length is greater than the distance or not implements - * this correctly. You should not use memcpy() since its behavior is not - * defined for overlapped arrays. You should not use memmove() or bcopy() - * since though their behavior -is- defined for overlapping arrays, it is - * defined to do the wrong thing in this case. - */ -local int codes(struct state *s, - const struct huffman *lencode, - const struct huffman *distcode) -{ - int symbol; /* decoded symbol */ - int len; /* length for copy */ - unsigned dist; /* distance for copy */ - static const short lens[29] = { /* Size base for length codes 257..285 */ - 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, - 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258}; - static const short lext[29] = { /* Extra bits for length codes 257..285 */ - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, - 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0}; - static const short dists[30] = { /* Offset base for distance codes 0..29 */ - 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, - 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, - 8193, 12289, 16385, 24577}; - static const short dext[30] = { /* Extra bits for distance codes 0..29 */ - 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, - 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, - 12, 12, 13, 13}; - - /* decode literals and length/distance pairs */ - do { - symbol = decode(s, lencode); - if (symbol < 0) - return symbol; /* invalid symbol */ - if (symbol < 256) { /* literal: symbol is the byte */ - /* write out the literal */ - if (s->out != NIL) { - if (s->outcnt == s->outlen) - return 1; - s->out[s->outcnt] = symbol; - } - s->outcnt++; - } - else if (symbol > 256) { /* length */ - /* get and compute length */ - symbol -= 257; - if (symbol >= 29) - return -10; /* invalid fixed code */ - len = lens[symbol] + bits(s, lext[symbol]); - - /* get and check distance */ - symbol = decode(s, distcode); - if (symbol < 0) - return symbol; /* invalid symbol */ - dist = dists[symbol] + bits(s, dext[symbol]); -#ifndef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR - if (dist > s->outcnt) - return -11; /* distance too far back */ -#endif - - /* copy length bytes from distance bytes back */ - if (s->out != NIL) { - if (s->outcnt + len > s->outlen) - return 1; - while (len--) { - s->out[s->outcnt] = -#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR - dist > s->outcnt ? - 0 : -#endif - s->out[s->outcnt - dist]; - s->outcnt++; - } - } - else - s->outcnt += len; - } - } while (symbol != 256); /* end of block symbol */ - - /* done with a valid fixed or dynamic block */ - return 0; -} - -/* - * Process a fixed codes block. - * - * Format notes: - * - * - This block type can be useful for compressing small amounts of data for - * which the size of the code descriptions in a dynamic block exceeds the - * benefit of custom codes for that block. For fixed codes, no bits are - * spent on code descriptions. Instead the code lengths for literal/length - * codes and distance codes are fixed. The specific lengths for each symbol - * can be seen in the "for" loops below. - * - * - The literal/length code is complete, but has two symbols that are invalid - * and should result in an error if received. This cannot be implemented - * simply as an incomplete code since those two symbols are in the "middle" - * of the code. They are eight bits long and the longest literal/length\ - * code is nine bits. Therefore the code must be constructed with those - * symbols, and the invalid symbols must be detected after decoding. - * - * - The fixed distance codes also have two invalid symbols that should result - * in an error if received. Since all of the distance codes are the same - * length, this can be implemented as an incomplete code. Then the invalid - * codes are detected while decoding. - */ -local int fixed(struct state *s) -{ - static int virgin = 1; - static short lencnt[MAXBITS+1], lensym[FIXLCODES]; - static short distcnt[MAXBITS+1], distsym[MAXDCODES]; - static struct huffman lencode, distcode; - - /* build fixed huffman tables if first call (may not be thread safe) */ - if (virgin) { - int symbol; - short lengths[FIXLCODES]; - - /* construct lencode and distcode */ - lencode.count = lencnt; - lencode.symbol = lensym; - distcode.count = distcnt; - distcode.symbol = distsym; - - /* literal/length table */ - for (symbol = 0; symbol < 144; symbol++) - lengths[symbol] = 8; - for (; symbol < 256; symbol++) - lengths[symbol] = 9; - for (; symbol < 280; symbol++) - lengths[symbol] = 7; - for (; symbol < FIXLCODES; symbol++) - lengths[symbol] = 8; - construct(&lencode, lengths, FIXLCODES); - - /* distance table */ - for (symbol = 0; symbol < MAXDCODES; symbol++) - lengths[symbol] = 5; - construct(&distcode, lengths, MAXDCODES); - - /* do this just once */ - virgin = 0; - } - - /* decode data until end-of-block code */ - return codes(s, &lencode, &distcode); -} - -/* - * Process a dynamic codes block. - * - * Format notes: - * - * - A dynamic block starts with a description of the literal/length and - * distance codes for that block. New dynamic blocks allow the compressor to - * rapidly adapt to changing data with new codes optimized for that data. - * - * - The codes used by the deflate format are "canonical", which means that - * the actual bits of the codes are generated in an unambiguous way simply - * from the number of bits in each code. Therefore the code descriptions - * are simply a list of code lengths for each symbol. - * - * - The code lengths are stored in order for the symbols, so lengths are - * provided for each of the literal/length symbols, and for each of the - * distance symbols. - * - * - If a symbol is not used in the block, this is represented by a zero as - * as the code length. This does not mean a zero-length code, but rather - * that no code should be created for this symbol. There is no way in the - * deflate format to represent a zero-length code. - * - * - The maximum number of bits in a code is 15, so the possible lengths for - * any code are 1..15. - * - * - The fact that a length of zero is not permitted for a code has an - * interesting consequence. Normally if only one symbol is used for a given - * code, then in fact that code could be represented with zero bits. However - * in deflate, that code has to be at least one bit. So for example, if - * only a single distance base symbol appears in a block, then it will be - * represented by a single code of length one, in particular one 0 bit. This - * is an incomplete code, since if a 1 bit is received, it has no meaning, - * and should result in an error. So incomplete distance codes of one symbol - * should be permitted, and the receipt of invalid codes should be handled. - * - * - It is also possible to have a single literal/length code, but that code - * must be the end-of-block code, since every dynamic block has one. This - * is not the most efficient way to create an empty block (an empty fixed - * block is fewer bits), but it is allowed by the format. So incomplete - * literal/length codes of one symbol should also be permitted. - * - * - If there are only literal codes and no lengths, then there are no distance - * codes. This is represented by one distance code with zero bits. - * - * - The list of up to 286 length/literal lengths and up to 30 distance lengths - * are themselves compressed using Huffman codes and run-length encoding. In - * the list of code lengths, a 0 symbol means no code, a 1..15 symbol means - * that length, and the symbols 16, 17, and 18 are run-length instructions. - * Each of 16, 17, and 18 are follwed by extra bits to define the length of - * the run. 16 copies the last length 3 to 6 times. 17 represents 3 to 10 - * zero lengths, and 18 represents 11 to 138 zero lengths. Unused symbols - * are common, hence the special coding for zero lengths. - * - * - The symbols for 0..18 are Huffman coded, and so that code must be - * described first. This is simply a sequence of up to 19 three-bit values - * representing no code (0) or the code length for that symbol (1..7). - * - * - A dynamic block starts with three fixed-size counts from which is computed - * the number of literal/length code lengths, the number of distance code - * lengths, and the number of code length code lengths (ok, you come up with - * a better name!) in the code descriptions. For the literal/length and - * distance codes, lengths after those provided are considered zero, i.e. no - * code. The code length code lengths are received in a permuted order (see - * the order[] array below) to make a short code length code length list more - * likely. As it turns out, very short and very long codes are less likely - * to be seen in a dynamic code description, hence what may appear initially - * to be a peculiar ordering. - * - * - Given the number of literal/length code lengths (nlen) and distance code - * lengths (ndist), then they are treated as one long list of nlen + ndist - * code lengths. Therefore run-length coding can and often does cross the - * boundary between the two sets of lengths. - * - * - So to summarize, the code description at the start of a dynamic block is - * three counts for the number of code lengths for the literal/length codes, - * the distance codes, and the code length codes. This is followed by the - * code length code lengths, three bits each. This is used to construct the - * code length code which is used to read the remainder of the lengths. Then - * the literal/length code lengths and distance lengths are read as a single - * set of lengths using the code length codes. Codes are constructed from - * the resulting two sets of lengths, and then finally you can start - * decoding actual compressed data in the block. - * - * - For reference, a "typical" size for the code description in a dynamic - * block is around 80 bytes. - */ -local int dynamic(struct state *s) -{ - int nlen, ndist, ncode; /* number of lengths in descriptor */ - int index; /* index of lengths[] */ - int err; /* construct() return value */ - short lengths[MAXCODES]; /* descriptor code lengths */ - short lencnt[MAXBITS+1], lensym[MAXLCODES]; /* lencode memory */ - short distcnt[MAXBITS+1], distsym[MAXDCODES]; /* distcode memory */ - struct huffman lencode, distcode; /* length and distance codes */ - static const short order[19] = /* permutation of code length codes */ - {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - - /* construct lencode and distcode */ - lencode.count = lencnt; - lencode.symbol = lensym; - distcode.count = distcnt; - distcode.symbol = distsym; - - /* get number of lengths in each table, check lengths */ - nlen = bits(s, 5) + 257; - ndist = bits(s, 5) + 1; - ncode = bits(s, 4) + 4; - if (nlen > MAXLCODES || ndist > MAXDCODES) - return -3; /* bad counts */ - - /* read code length code lengths (really), missing lengths are zero */ - for (index = 0; index < ncode; index++) - lengths[order[index]] = bits(s, 3); - for (; index < 19; index++) - lengths[order[index]] = 0; - - /* build huffman table for code lengths codes (use lencode temporarily) */ - err = construct(&lencode, lengths, 19); - if (err != 0) /* require complete code set here */ - return -4; - - /* read length/literal and distance code length tables */ - index = 0; - while (index < nlen + ndist) { - int symbol; /* decoded value */ - int len; /* last length to repeat */ - - symbol = decode(s, &lencode); - if (symbol < 0) - return symbol; /* invalid symbol */ - if (symbol < 16) /* length in 0..15 */ - lengths[index++] = symbol; - else { /* repeat instruction */ - len = 0; /* assume repeating zeros */ - if (symbol == 16) { /* repeat last length 3..6 times */ - if (index == 0) - return -5; /* no last length! */ - len = lengths[index - 1]; /* last length */ - symbol = 3 + bits(s, 2); - } - else if (symbol == 17) /* repeat zero 3..10 times */ - symbol = 3 + bits(s, 3); - else /* == 18, repeat zero 11..138 times */ - symbol = 11 + bits(s, 7); - if (index + symbol > nlen + ndist) - return -6; /* too many lengths! */ - while (symbol--) /* repeat last or zero symbol times */ - lengths[index++] = len; - } - } - - /* check for end-of-block code -- there better be one! */ - if (lengths[256] == 0) - return -9; - - /* build huffman table for literal/length codes */ - err = construct(&lencode, lengths, nlen); - if (err && (err < 0 || nlen != lencode.count[0] + lencode.count[1])) - return -7; /* incomplete code ok only for single length 1 code */ - - /* build huffman table for distance codes */ - err = construct(&distcode, lengths + nlen, ndist); - if (err && (err < 0 || ndist != distcode.count[0] + distcode.count[1])) - return -8; /* incomplete code ok only for single length 1 code */ - - /* decode data until end-of-block code */ - return codes(s, &lencode, &distcode); -} - -/* - * Inflate source to dest. On return, destlen and sourcelen are updated to the - * size of the uncompressed data and the size of the deflate data respectively. - * On success, the return value of puff() is zero. If there is an error in the - * source data, i.e. it is not in the deflate format, then a negative value is - * returned. If there is not enough input available or there is not enough - * output space, then a positive error is returned. In that case, destlen and - * sourcelen are not updated to facilitate retrying from the beginning with the - * provision of more input data or more output space. In the case of invalid - * inflate data (a negative error), the dest and source pointers are updated to - * facilitate the debugging of deflators. - * - * puff() also has a mode to determine the size of the uncompressed output with - * no output written. For this dest must be (unsigned char *)0. In this case, - * the input value of *destlen is ignored, and on return *destlen is set to the - * size of the uncompressed output. - * - * The return codes are: - * - * 2: available inflate data did not terminate - * 1: output space exhausted before completing inflate - * 0: successful inflate - * -1: invalid block type (type == 3) - * -2: stored block length did not match one's complement - * -3: dynamic block code description: too many length or distance codes - * -4: dynamic block code description: code lengths codes incomplete - * -5: dynamic block code description: repeat lengths with no first length - * -6: dynamic block code description: repeat more than specified lengths - * -7: dynamic block code description: invalid literal/length code lengths - * -8: dynamic block code description: invalid distance code lengths - * -9: dynamic block code description: missing end-of-block code - * -10: invalid literal/length or distance code in fixed or dynamic block - * -11: distance is too far back in fixed or dynamic block - * - * Format notes: - * - * - Three bits are read for each block to determine the kind of block and - * whether or not it is the last block. Then the block is decoded and the - * process repeated if it was not the last block. - * - * - The leftover bits in the last byte of the deflate data after the last - * block (if it was a fixed or dynamic block) are undefined and have no - * expected values to check. - */ -int puff(unsigned char *dest, /* pointer to destination pointer */ - unsigned long *destlen, /* amount of output space */ - const unsigned char *source, /* pointer to source data pointer */ - unsigned long *sourcelen) /* amount of input available */ -{ - struct state s; /* input/output state */ - int last, type; /* block information */ - int err; /* return value */ - - /* initialize output state */ - s.out = dest; - s.outlen = *destlen; /* ignored if dest is NIL */ - s.outcnt = 0; - - /* initialize input state */ - s.in = source; - s.inlen = *sourcelen; - s.incnt = 0; - s.bitbuf = 0; - s.bitcnt = 0; - - /* return if bits() or decode() tries to read past available input */ - if (setjmp(s.env) != 0) /* if came back here via longjmp() */ - err = 2; /* then skip do-loop, return error */ - else { - /* process blocks until last block or error */ - do { - last = bits(&s, 1); /* one if last block */ - type = bits(&s, 2); /* block type 0..3 */ - err = type == 0 ? - stored(&s) : - (type == 1 ? - fixed(&s) : - (type == 2 ? - dynamic(&s) : - -1)); /* type == 3, invalid */ - if (err != 0) - break; /* return with error */ - } while (!last); - } - - /* update the lengths and return */ - if (err <= 0) { - *destlen = s.outcnt; - *sourcelen = s.incnt; - } - return err; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/puff/puff.h b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/puff/puff.h deleted file mode 100644 index e23a245..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/puff/puff.h +++ /dev/null @@ -1,35 +0,0 @@ -/* puff.h - Copyright (C) 2002-2013 Mark Adler, all rights reserved - version 2.3, 21 Jan 2013 - - This software is provided 'as-is', without any express or implied - warranty. In no event will the author be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Mark Adler madler@alumni.caltech.edu - */ - - -/* - * See puff.c for purpose and usage. - */ -#ifndef NIL -# define NIL ((unsigned char *)0) /* for no output option */ -#endif - -int puff(unsigned char *dest, /* pointer to destination pointer */ - unsigned long *destlen, /* amount of output space */ - const unsigned char *source, /* pointer to source data pointer */ - unsigned long *sourcelen); /* amount of input available */ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/puff/pufftest.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/puff/pufftest.c deleted file mode 100644 index 7764814..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/puff/pufftest.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - * pufftest.c - * Copyright (C) 2002-2013 Mark Adler - * For conditions of distribution and use, see copyright notice in puff.h - * version 2.3, 21 Jan 2013 - */ - -/* Example of how to use puff(). - - Usage: puff [-w] [-f] [-nnn] file - ... | puff [-w] [-f] [-nnn] - - where file is the input file with deflate data, nnn is the number of bytes - of input to skip before inflating (e.g. to skip a zlib or gzip header), and - -w is used to write the decompressed data to stdout. -f is for coverage - testing, and causes pufftest to fail with not enough output space (-f does - a write like -w, so -w is not required). */ - -#include -#include -#include "puff.h" - -#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__) -# include -# include -# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY) -#else -# define SET_BINARY_MODE(file) -#endif - -#define local static - -/* Return size times approximately the cube root of 2, keeping the result as 1, - 3, or 5 times a power of 2 -- the result is always > size, until the result - is the maximum value of an unsigned long, where it remains. This is useful - to keep reallocations less than ~33% over the actual data. */ -local size_t bythirds(size_t size) -{ - int n; - size_t m; - - m = size; - for (n = 0; m; n++) - m >>= 1; - if (n < 3) - return size + 1; - n -= 3; - m = size >> n; - m += m == 6 ? 2 : 1; - m <<= n; - return m > size ? m : (size_t)(-1); -} - -/* Read the input file *name, or stdin if name is NULL, into allocated memory. - Reallocate to larger buffers until the entire file is read in. Return a - pointer to the allocated data, or NULL if there was a memory allocation - failure. *len is the number of bytes of data read from the input file (even - if load() returns NULL). If the input file was empty or could not be opened - or read, *len is zero. */ -local void *load(const char *name, size_t *len) -{ - size_t size; - void *buf, *swap; - FILE *in; - - *len = 0; - buf = malloc(size = 4096); - if (buf == NULL) - return NULL; - in = name == NULL ? stdin : fopen(name, "rb"); - if (in != NULL) { - for (;;) { - *len += fread((char *)buf + *len, 1, size - *len, in); - if (*len < size) break; - size = bythirds(size); - if (size == *len || (swap = realloc(buf, size)) == NULL) { - free(buf); - buf = NULL; - break; - } - buf = swap; - } - fclose(in); - } - return buf; -} - -int main(int argc, char **argv) -{ - int ret, put = 0, fail = 0; - unsigned skip = 0; - char *arg, *name = NULL; - unsigned char *source = NULL, *dest; - size_t len = 0; - unsigned long sourcelen, destlen; - - /* process arguments */ - while (arg = *++argv, --argc) - if (arg[0] == '-') { - if (arg[1] == 'w' && arg[2] == 0) - put = 1; - else if (arg[1] == 'f' && arg[2] == 0) - fail = 1, put = 1; - else if (arg[1] >= '0' && arg[1] <= '9') - skip = (unsigned)atoi(arg + 1); - else { - fprintf(stderr, "invalid option %s\n", arg); - return 3; - } - } - else if (name != NULL) { - fprintf(stderr, "only one file name allowed\n"); - return 3; - } - else - name = arg; - source = load(name, &len); - if (source == NULL) { - fprintf(stderr, "memory allocation failure\n"); - return 4; - } - if (len == 0) { - fprintf(stderr, "could not read %s, or it was empty\n", - name == NULL ? "" : name); - free(source); - return 3; - } - if (skip >= len) { - fprintf(stderr, "skip request of %d leaves no input\n", skip); - free(source); - return 3; - } - - /* test inflate data with offset skip */ - len -= skip; - sourcelen = (unsigned long)len; - ret = puff(NIL, &destlen, source + skip, &sourcelen); - if (ret) - fprintf(stderr, "puff() failed with return code %d\n", ret); - else { - fprintf(stderr, "puff() succeeded uncompressing %lu bytes\n", destlen); - if (sourcelen < len) fprintf(stderr, "%lu compressed bytes unused\n", - len - sourcelen); - } - - /* if requested, inflate again and write decompressd data to stdout */ - if (put && ret == 0) { - if (fail) - destlen >>= 1; - dest = malloc(destlen); - if (dest == NULL) { - fprintf(stderr, "memory allocation failure\n"); - free(source); - return 4; - } - puff(dest, &destlen, source + skip, &sourcelen); - SET_BINARY_MODE(stdout); - fwrite(dest, 1, destlen, stdout); - free(dest); - } - - /* clean up */ - free(source); - return ret; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/puff/zeros.raw b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/puff/zeros.raw deleted file mode 100644 index 0a90e76..0000000 Binary files a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/puff/zeros.raw and /dev/null differ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/testzlib/testzlib.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/testzlib/testzlib.c deleted file mode 100644 index 8626c92..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/testzlib/testzlib.c +++ /dev/null @@ -1,275 +0,0 @@ -#include -#include -#include - -#include "zlib.h" - - -void MyDoMinus64(LARGE_INTEGER *R,LARGE_INTEGER A,LARGE_INTEGER B) -{ - R->HighPart = A.HighPart - B.HighPart; - if (A.LowPart >= B.LowPart) - R->LowPart = A.LowPart - B.LowPart; - else - { - R->LowPart = A.LowPart - B.LowPart; - R->HighPart --; - } -} - -#ifdef _M_X64 -// see http://msdn2.microsoft.com/library/twchhe95(en-us,vs.80).aspx for __rdtsc -unsigned __int64 __rdtsc(void); -void BeginCountRdtsc(LARGE_INTEGER * pbeginTime64) -{ - // printf("rdtsc = %I64x\n",__rdtsc()); - pbeginTime64->QuadPart=__rdtsc(); -} - -LARGE_INTEGER GetResRdtsc(LARGE_INTEGER beginTime64,BOOL fComputeTimeQueryPerf) -{ - LARGE_INTEGER LIres; - unsigned _int64 res=__rdtsc()-((unsigned _int64)(beginTime64.QuadPart)); - LIres.QuadPart=res; - // printf("rdtsc = %I64x\n",__rdtsc()); - return LIres; -} -#else -#ifdef _M_IX86 -void myGetRDTSC32(LARGE_INTEGER * pbeginTime64) -{ - DWORD dwEdx,dwEax; - _asm - { - rdtsc - mov dwEax,eax - mov dwEdx,edx - } - pbeginTime64->LowPart=dwEax; - pbeginTime64->HighPart=dwEdx; -} - -void BeginCountRdtsc(LARGE_INTEGER * pbeginTime64) -{ - myGetRDTSC32(pbeginTime64); -} - -LARGE_INTEGER GetResRdtsc(LARGE_INTEGER beginTime64,BOOL fComputeTimeQueryPerf) -{ - LARGE_INTEGER LIres,endTime64; - myGetRDTSC32(&endTime64); - - LIres.LowPart=LIres.HighPart=0; - MyDoMinus64(&LIres,endTime64,beginTime64); - return LIres; -} -#else -void myGetRDTSC32(LARGE_INTEGER * pbeginTime64) -{ -} - -void BeginCountRdtsc(LARGE_INTEGER * pbeginTime64) -{ -} - -LARGE_INTEGER GetResRdtsc(LARGE_INTEGER beginTime64,BOOL fComputeTimeQueryPerf) -{ - LARGE_INTEGER lr; - lr.QuadPart=0; - return lr; -} -#endif -#endif - -void BeginCountPerfCounter(LARGE_INTEGER * pbeginTime64,BOOL fComputeTimeQueryPerf) -{ - if ((!fComputeTimeQueryPerf) || (!QueryPerformanceCounter(pbeginTime64))) - { - pbeginTime64->LowPart = GetTickCount(); - pbeginTime64->HighPart = 0; - } -} - -DWORD GetMsecSincePerfCounter(LARGE_INTEGER beginTime64,BOOL fComputeTimeQueryPerf) -{ - LARGE_INTEGER endTime64,ticksPerSecond,ticks; - DWORDLONG ticksShifted,tickSecShifted; - DWORD dwLog=16+0; - DWORD dwRet; - if ((!fComputeTimeQueryPerf) || (!QueryPerformanceCounter(&endTime64))) - dwRet = (GetTickCount() - beginTime64.LowPart)*1; - else - { - MyDoMinus64(&ticks,endTime64,beginTime64); - QueryPerformanceFrequency(&ticksPerSecond); - - - { - ticksShifted = Int64ShrlMod32(*(DWORDLONG*)&ticks,dwLog); - tickSecShifted = Int64ShrlMod32(*(DWORDLONG*)&ticksPerSecond,dwLog); - - } - - dwRet = (DWORD)((((DWORD)ticksShifted)*1000)/(DWORD)(tickSecShifted)); - dwRet *=1; - } - return dwRet; -} - -int ReadFileMemory(const char* filename,long* plFileSize,unsigned char** pFilePtr) -{ - FILE* stream; - unsigned char* ptr; - int retVal=1; - stream=fopen(filename, "rb"); - if (stream==NULL) - return 0; - - fseek(stream,0,SEEK_END); - - *plFileSize=ftell(stream); - fseek(stream,0,SEEK_SET); - ptr=malloc((*plFileSize)+1); - if (ptr==NULL) - retVal=0; - else - { - if (fread(ptr, 1, *plFileSize,stream) != (*plFileSize)) - retVal=0; - } - fclose(stream); - *pFilePtr=ptr; - return retVal; -} - -int main(int argc, char *argv[]) -{ - int BlockSizeCompress=0x8000; - int BlockSizeUncompress=0x8000; - int cprLevel=Z_DEFAULT_COMPRESSION ; - long lFileSize; - unsigned char* FilePtr; - long lBufferSizeCpr; - long lBufferSizeUncpr; - long lCompressedSize=0; - unsigned char* CprPtr; - unsigned char* UncprPtr; - long lSizeCpr,lSizeUncpr; - DWORD dwGetTick,dwMsecQP; - LARGE_INTEGER li_qp,li_rdtsc,dwResRdtsc; - - if (argc<=1) - { - printf("run TestZlib [BlockSizeCompress] [BlockSizeUncompress] [compres. level]\n"); - return 0; - } - - if (ReadFileMemory(argv[1],&lFileSize,&FilePtr)==0) - { - printf("error reading %s\n",argv[1]); - return 1; - } - else printf("file %s read, %u bytes\n",argv[1],lFileSize); - - if (argc>=3) - BlockSizeCompress=atol(argv[2]); - - if (argc>=4) - BlockSizeUncompress=atol(argv[3]); - - if (argc>=5) - cprLevel=(int)atol(argv[4]); - - lBufferSizeCpr = lFileSize + (lFileSize/0x10) + 0x200; - lBufferSizeUncpr = lBufferSizeCpr; - - CprPtr=(unsigned char*)malloc(lBufferSizeCpr + BlockSizeCompress); - - BeginCountPerfCounter(&li_qp,TRUE); - dwGetTick=GetTickCount(); - BeginCountRdtsc(&li_rdtsc); - { - z_stream zcpr; - int ret=Z_OK; - long lOrigToDo = lFileSize; - long lOrigDone = 0; - int step=0; - memset(&zcpr,0,sizeof(z_stream)); - deflateInit(&zcpr,cprLevel); - - zcpr.next_in = FilePtr; - zcpr.next_out = CprPtr; - - - do - { - long all_read_before = zcpr.total_in; - zcpr.avail_in = min(lOrigToDo,BlockSizeCompress); - zcpr.avail_out = BlockSizeCompress; - ret=deflate(&zcpr,(zcpr.avail_in==lOrigToDo) ? Z_FINISH : Z_SYNC_FLUSH); - lOrigDone += (zcpr.total_in-all_read_before); - lOrigToDo -= (zcpr.total_in-all_read_before); - step++; - } while (ret==Z_OK); - - lSizeCpr=zcpr.total_out; - deflateEnd(&zcpr); - dwGetTick=GetTickCount()-dwGetTick; - dwMsecQP=GetMsecSincePerfCounter(li_qp,TRUE); - dwResRdtsc=GetResRdtsc(li_rdtsc,TRUE); - printf("total compress size = %u, in %u step\n",lSizeCpr,step); - printf("time = %u msec = %f sec\n",dwGetTick,dwGetTick/(double)1000.); - printf("defcpr time QP = %u msec = %f sec\n",dwMsecQP,dwMsecQP/(double)1000.); - printf("defcpr result rdtsc = %I64x\n\n",dwResRdtsc.QuadPart); - } - - CprPtr=(unsigned char*)realloc(CprPtr,lSizeCpr); - UncprPtr=(unsigned char*)malloc(lBufferSizeUncpr + BlockSizeUncompress); - - BeginCountPerfCounter(&li_qp,TRUE); - dwGetTick=GetTickCount(); - BeginCountRdtsc(&li_rdtsc); - { - z_stream zcpr; - int ret=Z_OK; - long lOrigToDo = lSizeCpr; - long lOrigDone = 0; - int step=0; - memset(&zcpr,0,sizeof(z_stream)); - inflateInit(&zcpr); - - zcpr.next_in = CprPtr; - zcpr.next_out = UncprPtr; - - - do - { - long all_read_before = zcpr.total_in; - zcpr.avail_in = min(lOrigToDo,BlockSizeUncompress); - zcpr.avail_out = BlockSizeUncompress; - ret=inflate(&zcpr,Z_SYNC_FLUSH); - lOrigDone += (zcpr.total_in-all_read_before); - lOrigToDo -= (zcpr.total_in-all_read_before); - step++; - } while (ret==Z_OK); - - lSizeUncpr=zcpr.total_out; - inflateEnd(&zcpr); - dwGetTick=GetTickCount()-dwGetTick; - dwMsecQP=GetMsecSincePerfCounter(li_qp,TRUE); - dwResRdtsc=GetResRdtsc(li_rdtsc,TRUE); - printf("total uncompress size = %u, in %u step\n",lSizeUncpr,step); - printf("time = %u msec = %f sec\n",dwGetTick,dwGetTick/(double)1000.); - printf("uncpr time QP = %u msec = %f sec\n",dwMsecQP,dwMsecQP/(double)1000.); - printf("uncpr result rdtsc = %I64x\n\n",dwResRdtsc.QuadPart); - } - - if (lSizeUncpr==lFileSize) - { - if (memcmp(FilePtr,UncprPtr,lFileSize)==0) - printf("compare ok\n"); - - } - - return 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/testzlib/testzlib.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/testzlib/testzlib.txt deleted file mode 100644 index e508bb2..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/testzlib/testzlib.txt +++ /dev/null @@ -1,10 +0,0 @@ -To build testzLib with Visual Studio 2005: - -copy to a directory file from : -- root of zLib tree -- contrib/testzlib -- contrib/masmx86 -- contrib/masmx64 -- contrib/vstudio/vc7 - -and open testzlib8.sln \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/untgz/Makefile b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/untgz/Makefile deleted file mode 100644 index b54266f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/untgz/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -CC=cc -CFLAGS=-g - -untgz: untgz.o ../../libz.a - $(CC) $(CFLAGS) -o untgz untgz.o -L../.. -lz - -untgz.o: untgz.c ../../zlib.h - $(CC) $(CFLAGS) -c -I../.. untgz.c - -../../libz.a: - cd ../..; ./configure; make - -clean: - rm -f untgz untgz.o *~ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/untgz/Makefile.msc b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/untgz/Makefile.msc deleted file mode 100644 index 77b8602..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/untgz/Makefile.msc +++ /dev/null @@ -1,17 +0,0 @@ -CC=cl -CFLAGS=-MD - -untgz.exe: untgz.obj ..\..\zlib.lib - $(CC) $(CFLAGS) untgz.obj ..\..\zlib.lib - -untgz.obj: untgz.c ..\..\zlib.h - $(CC) $(CFLAGS) -c -I..\.. untgz.c - -..\..\zlib.lib: - cd ..\.. - $(MAKE) -f win32\makefile.msc - cd contrib\untgz - -clean: - -del untgz.obj - -del untgz.exe diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/untgz/untgz.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/untgz/untgz.c deleted file mode 100644 index 2c391e5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/untgz/untgz.c +++ /dev/null @@ -1,674 +0,0 @@ -/* - * untgz.c -- Display contents and extract files from a gzip'd TAR file - * - * written by Pedro A. Aranda Gutierrez - * adaptation to Unix by Jean-loup Gailly - * various fixes by Cosmin Truta - */ - -#include -#include -#include -#include -#include - -#include "zlib.h" - -#ifdef unix -# include -#else -# include -# include -#endif - -#ifdef WIN32 -#include -# ifndef F_OK -# define F_OK 0 -# endif -# define mkdir(dirname,mode) _mkdir(dirname) -# ifdef _MSC_VER -# define access(path,mode) _access(path,mode) -# define chmod(path,mode) _chmod(path,mode) -# define strdup(str) _strdup(str) -# endif -#else -# include -#endif - - -/* values used in typeflag field */ - -#define REGTYPE '0' /* regular file */ -#define AREGTYPE '\0' /* regular file */ -#define LNKTYPE '1' /* link */ -#define SYMTYPE '2' /* reserved */ -#define CHRTYPE '3' /* character special */ -#define BLKTYPE '4' /* block special */ -#define DIRTYPE '5' /* directory */ -#define FIFOTYPE '6' /* FIFO special */ -#define CONTTYPE '7' /* reserved */ - -/* GNU tar extensions */ - -#define GNUTYPE_DUMPDIR 'D' /* file names from dumped directory */ -#define GNUTYPE_LONGLINK 'K' /* long link name */ -#define GNUTYPE_LONGNAME 'L' /* long file name */ -#define GNUTYPE_MULTIVOL 'M' /* continuation of file from another volume */ -#define GNUTYPE_NAMES 'N' /* file name that does not fit into main hdr */ -#define GNUTYPE_SPARSE 'S' /* sparse file */ -#define GNUTYPE_VOLHDR 'V' /* tape/volume header */ - - -/* tar header */ - -#define BLOCKSIZE 512 -#define SHORTNAMESIZE 100 - -struct tar_header -{ /* byte offset */ - char name[100]; /* 0 */ - char mode[8]; /* 100 */ - char uid[8]; /* 108 */ - char gid[8]; /* 116 */ - char size[12]; /* 124 */ - char mtime[12]; /* 136 */ - char chksum[8]; /* 148 */ - char typeflag; /* 156 */ - char linkname[100]; /* 157 */ - char magic[6]; /* 257 */ - char version[2]; /* 263 */ - char uname[32]; /* 265 */ - char gname[32]; /* 297 */ - char devmajor[8]; /* 329 */ - char devminor[8]; /* 337 */ - char prefix[155]; /* 345 */ - /* 500 */ -}; - -union tar_buffer -{ - char buffer[BLOCKSIZE]; - struct tar_header header; -}; - -struct attr_item -{ - struct attr_item *next; - char *fname; - int mode; - time_t time; -}; - -enum { TGZ_EXTRACT, TGZ_LIST, TGZ_INVALID }; - -char *TGZfname OF((const char *)); -void TGZnotfound OF((const char *)); - -int getoct OF((char *, int)); -char *strtime OF((time_t *)); -int setfiletime OF((char *, time_t)); -void push_attr OF((struct attr_item **, char *, int, time_t)); -void restore_attr OF((struct attr_item **)); - -int ExprMatch OF((char *, char *)); - -int makedir OF((char *)); -int matchname OF((int, int, char **, char *)); - -void error OF((const char *)); -int tar OF((gzFile, int, int, int, char **)); - -void help OF((int)); -int main OF((int, char **)); - -char *prog; - -const char *TGZsuffix[] = { "\0", ".tar", ".tar.gz", ".taz", ".tgz", NULL }; - -/* return the file name of the TGZ archive */ -/* or NULL if it does not exist */ - -char *TGZfname (const char *arcname) -{ - static char buffer[1024]; - int origlen,i; - - strcpy(buffer,arcname); - origlen = strlen(buffer); - - for (i=0; TGZsuffix[i]; i++) - { - strcpy(buffer+origlen,TGZsuffix[i]); - if (access(buffer,F_OK) == 0) - return buffer; - } - return NULL; -} - - -/* error message for the filename */ - -void TGZnotfound (const char *arcname) -{ - int i; - - fprintf(stderr,"%s: Couldn't find ",prog); - for (i=0;TGZsuffix[i];i++) - fprintf(stderr,(TGZsuffix[i+1]) ? "%s%s, " : "or %s%s\n", - arcname, - TGZsuffix[i]); - exit(1); -} - - -/* convert octal digits to int */ -/* on error return -1 */ - -int getoct (char *p,int width) -{ - int result = 0; - char c; - - while (width--) - { - c = *p++; - if (c == 0) - break; - if (c == ' ') - continue; - if (c < '0' || c > '7') - return -1; - result = result * 8 + (c - '0'); - } - return result; -} - - -/* convert time_t to string */ -/* use the "YYYY/MM/DD hh:mm:ss" format */ - -char *strtime (time_t *t) -{ - struct tm *local; - static char result[32]; - - local = localtime(t); - sprintf(result,"%4d/%02d/%02d %02d:%02d:%02d", - local->tm_year+1900, local->tm_mon+1, local->tm_mday, - local->tm_hour, local->tm_min, local->tm_sec); - return result; -} - - -/* set file time */ - -int setfiletime (char *fname,time_t ftime) -{ -#ifdef WIN32 - static int isWinNT = -1; - SYSTEMTIME st; - FILETIME locft, modft; - struct tm *loctm; - HANDLE hFile; - int result; - - loctm = localtime(&ftime); - if (loctm == NULL) - return -1; - - st.wYear = (WORD)loctm->tm_year + 1900; - st.wMonth = (WORD)loctm->tm_mon + 1; - st.wDayOfWeek = (WORD)loctm->tm_wday; - st.wDay = (WORD)loctm->tm_mday; - st.wHour = (WORD)loctm->tm_hour; - st.wMinute = (WORD)loctm->tm_min; - st.wSecond = (WORD)loctm->tm_sec; - st.wMilliseconds = 0; - if (!SystemTimeToFileTime(&st, &locft) || - !LocalFileTimeToFileTime(&locft, &modft)) - return -1; - - if (isWinNT < 0) - isWinNT = (GetVersion() < 0x80000000) ? 1 : 0; - hFile = CreateFile(fname, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, - (isWinNT ? FILE_FLAG_BACKUP_SEMANTICS : 0), - NULL); - if (hFile == INVALID_HANDLE_VALUE) - return -1; - result = SetFileTime(hFile, NULL, NULL, &modft) ? 0 : -1; - CloseHandle(hFile); - return result; -#else - struct utimbuf settime; - - settime.actime = settime.modtime = ftime; - return utime(fname,&settime); -#endif -} - - -/* push file attributes */ - -void push_attr(struct attr_item **list,char *fname,int mode,time_t time) -{ - struct attr_item *item; - - item = (struct attr_item *)malloc(sizeof(struct attr_item)); - if (item == NULL) - error("Out of memory"); - item->fname = strdup(fname); - item->mode = mode; - item->time = time; - item->next = *list; - *list = item; -} - - -/* restore file attributes */ - -void restore_attr(struct attr_item **list) -{ - struct attr_item *item, *prev; - - for (item = *list; item != NULL; ) - { - setfiletime(item->fname,item->time); - chmod(item->fname,item->mode); - prev = item; - item = item->next; - free(prev); - } - *list = NULL; -} - - -/* match regular expression */ - -#define ISSPECIAL(c) (((c) == '*') || ((c) == '/')) - -int ExprMatch (char *string,char *expr) -{ - while (1) - { - if (ISSPECIAL(*expr)) - { - if (*expr == '/') - { - if (*string != '\\' && *string != '/') - return 0; - string ++; expr++; - } - else if (*expr == '*') - { - if (*expr ++ == 0) - return 1; - while (*++string != *expr) - if (*string == 0) - return 0; - } - } - else - { - if (*string != *expr) - return 0; - if (*expr++ == 0) - return 1; - string++; - } - } -} - - -/* recursive mkdir */ -/* abort on ENOENT; ignore other errors like "directory already exists" */ -/* return 1 if OK */ -/* 0 on error */ - -int makedir (char *newdir) -{ - char *buffer = strdup(newdir); - char *p; - int len = strlen(buffer); - - if (len <= 0) { - free(buffer); - return 0; - } - if (buffer[len-1] == '/') { - buffer[len-1] = '\0'; - } - if (mkdir(buffer, 0755) == 0) - { - free(buffer); - return 1; - } - - p = buffer+1; - while (1) - { - char hold; - - while(*p && *p != '\\' && *p != '/') - p++; - hold = *p; - *p = 0; - if ((mkdir(buffer, 0755) == -1) && (errno == ENOENT)) - { - fprintf(stderr,"%s: Couldn't create directory %s\n",prog,buffer); - free(buffer); - return 0; - } - if (hold == 0) - break; - *p++ = hold; - } - free(buffer); - return 1; -} - - -int matchname (int arg,int argc,char **argv,char *fname) -{ - if (arg == argc) /* no arguments given (untgz tgzarchive) */ - return 1; - - while (arg < argc) - if (ExprMatch(fname,argv[arg++])) - return 1; - - return 0; /* ignore this for the moment being */ -} - - -/* tar file list or extract */ - -int tar (gzFile in,int action,int arg,int argc,char **argv) -{ - union tar_buffer buffer; - int len; - int err; - int getheader = 1; - int remaining = 0; - FILE *outfile = NULL; - char fname[BLOCKSIZE]; - int tarmode; - time_t tartime; - struct attr_item *attributes = NULL; - - if (action == TGZ_LIST) - printf(" date time size file\n" - " ---------- -------- --------- -------------------------------------\n"); - while (1) - { - len = gzread(in, &buffer, BLOCKSIZE); - if (len < 0) - error(gzerror(in, &err)); - /* - * Always expect complete blocks to process - * the tar information. - */ - if (len != BLOCKSIZE) - { - action = TGZ_INVALID; /* force error exit */ - remaining = 0; /* force I/O cleanup */ - } - - /* - * If we have to get a tar header - */ - if (getheader >= 1) - { - /* - * if we met the end of the tar - * or the end-of-tar block, - * we are done - */ - if (len == 0 || buffer.header.name[0] == 0) - break; - - tarmode = getoct(buffer.header.mode,8); - tartime = (time_t)getoct(buffer.header.mtime,12); - if (tarmode == -1 || tartime == (time_t)-1) - { - buffer.header.name[0] = 0; - action = TGZ_INVALID; - } - - if (getheader == 1) - { - strncpy(fname,buffer.header.name,SHORTNAMESIZE); - if (fname[SHORTNAMESIZE-1] != 0) - fname[SHORTNAMESIZE] = 0; - } - else - { - /* - * The file name is longer than SHORTNAMESIZE - */ - if (strncmp(fname,buffer.header.name,SHORTNAMESIZE-1) != 0) - error("bad long name"); - getheader = 1; - } - - /* - * Act according to the type flag - */ - switch (buffer.header.typeflag) - { - case DIRTYPE: - if (action == TGZ_LIST) - printf(" %s
    %s\n",strtime(&tartime),fname); - if (action == TGZ_EXTRACT) - { - makedir(fname); - push_attr(&attributes,fname,tarmode,tartime); - } - break; - case REGTYPE: - case AREGTYPE: - remaining = getoct(buffer.header.size,12); - if (remaining == -1) - { - action = TGZ_INVALID; - break; - } - if (action == TGZ_LIST) - printf(" %s %9d %s\n",strtime(&tartime),remaining,fname); - else if (action == TGZ_EXTRACT) - { - if (matchname(arg,argc,argv,fname)) - { - outfile = fopen(fname,"wb"); - if (outfile == NULL) { - /* try creating directory */ - char *p = strrchr(fname, '/'); - if (p != NULL) { - *p = '\0'; - makedir(fname); - *p = '/'; - outfile = fopen(fname,"wb"); - } - } - if (outfile != NULL) - printf("Extracting %s\n",fname); - else - fprintf(stderr, "%s: Couldn't create %s",prog,fname); - } - else - outfile = NULL; - } - getheader = 0; - break; - case GNUTYPE_LONGLINK: - case GNUTYPE_LONGNAME: - remaining = getoct(buffer.header.size,12); - if (remaining < 0 || remaining >= BLOCKSIZE) - { - action = TGZ_INVALID; - break; - } - len = gzread(in, fname, BLOCKSIZE); - if (len < 0) - error(gzerror(in, &err)); - if (fname[BLOCKSIZE-1] != 0 || (int)strlen(fname) > remaining) - { - action = TGZ_INVALID; - break; - } - getheader = 2; - break; - default: - if (action == TGZ_LIST) - printf(" %s <---> %s\n",strtime(&tartime),fname); - break; - } - } - else - { - unsigned int bytes = (remaining > BLOCKSIZE) ? BLOCKSIZE : remaining; - - if (outfile != NULL) - { - if (fwrite(&buffer,sizeof(char),bytes,outfile) != bytes) - { - fprintf(stderr, - "%s: Error writing %s -- skipping\n",prog,fname); - fclose(outfile); - outfile = NULL; - remove(fname); - } - } - remaining -= bytes; - } - - if (remaining == 0) - { - getheader = 1; - if (outfile != NULL) - { - fclose(outfile); - outfile = NULL; - if (action != TGZ_INVALID) - push_attr(&attributes,fname,tarmode,tartime); - } - } - - /* - * Abandon if errors are found - */ - if (action == TGZ_INVALID) - { - error("broken archive"); - break; - } - } - - /* - * Restore file modes and time stamps - */ - restore_attr(&attributes); - - if (gzclose(in) != Z_OK) - error("failed gzclose"); - - return 0; -} - - -/* ============================================================ */ - -void help(int exitval) -{ - printf("untgz version 0.2.1\n" - " using zlib version %s\n\n", - zlibVersion()); - printf("Usage: untgz file.tgz extract all files\n" - " untgz file.tgz fname ... extract selected files\n" - " untgz -l file.tgz list archive contents\n" - " untgz -h display this help\n"); - exit(exitval); -} - -void error(const char *msg) -{ - fprintf(stderr, "%s: %s\n", prog, msg); - exit(1); -} - - -/* ============================================================ */ - -#if defined(WIN32) && defined(__GNUC__) -int _CRT_glob = 0; /* disable argument globbing in MinGW */ -#endif - -int main(int argc,char **argv) -{ - int action = TGZ_EXTRACT; - int arg = 1; - char *TGZfile; - gzFile *f; - - prog = strrchr(argv[0],'\\'); - if (prog == NULL) - { - prog = strrchr(argv[0],'/'); - if (prog == NULL) - { - prog = strrchr(argv[0],':'); - if (prog == NULL) - prog = argv[0]; - else - prog++; - } - else - prog++; - } - else - prog++; - - if (argc == 1) - help(0); - - if (strcmp(argv[arg],"-l") == 0) - { - action = TGZ_LIST; - if (argc == ++arg) - help(0); - } - else if (strcmp(argv[arg],"-h") == 0) - { - help(0); - } - - if ((TGZfile = TGZfname(argv[arg])) == NULL) - TGZnotfound(argv[arg]); - - ++arg; - if ((action == TGZ_LIST) && (arg != argc)) - help(1); - -/* - * Process the TGZ file - */ - switch(action) - { - case TGZ_LIST: - case TGZ_EXTRACT: - f = gzopen(TGZfile,"rb"); - if (f == NULL) - { - fprintf(stderr,"%s: Couldn't gzopen %s\n",prog,TGZfile); - return 1; - } - exit(tar(f, action, arg, argc, argv)); - break; - - default: - error("Unknown option"); - exit(1); - } - - return 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/readme.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/readme.txt deleted file mode 100644 index 48047d9..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/readme.txt +++ /dev/null @@ -1,78 +0,0 @@ -Building instructions for the DLL versions of Zlib 1.2.12 -======================================================== - -This directory contains projects that build zlib and minizip using -Microsoft Visual C++ 9.0/10.0. - -You don't need to build these projects yourself. You can download the -binaries from: - http://www.winimage.com/zLibDll - -More information can be found at this site. - - - - - -Build instructions for Visual Studio 2008 (32 bits or 64 bits) --------------------------------------------------------------- -- Decompress current zlib, including all contrib/* files -- Compile assembly code (with Visual Studio Command Prompt) by running: - bld_ml64.bat (in contrib\masmx64) - bld_ml32.bat (in contrib\masmx86) -- Open contrib\vstudio\vc9\zlibvc.sln with Microsoft Visual C++ 2008 -- Or run: vcbuild /rebuild contrib\vstudio\vc9\zlibvc.sln "Release|Win32" - -Build instructions for Visual Studio 2010 (32 bits or 64 bits) --------------------------------------------------------------- -- Decompress current zlib, including all contrib/* files -- Open contrib\vstudio\vc10\zlibvc.sln with Microsoft Visual C++ 2010 - -Build instructions for Visual Studio 2012 (32 bits or 64 bits) --------------------------------------------------------------- -- Decompress current zlib, including all contrib/* files -- Open contrib\vstudio\vc11\zlibvc.sln with Microsoft Visual C++ 2012 - -Build instructions for Visual Studio 2013 (32 bits or 64 bits) --------------------------------------------------------------- -- Decompress current zlib, including all contrib/* files -- Open contrib\vstudio\vc12\zlibvc.sln with Microsoft Visual C++ 2013 - -Build instructions for Visual Studio 2015 (32 bits or 64 bits) --------------------------------------------------------------- -- Decompress current zlib, including all contrib/* files -- Open contrib\vstudio\vc14\zlibvc.sln with Microsoft Visual C++ 2015 - - -Important ---------- -- To use zlibwapi.dll in your application, you must define the - macro ZLIB_WINAPI when compiling your application's source files. - - -Additional notes ----------------- -- This DLL, named zlibwapi.dll, is compatible to the old zlib.dll built - by Gilles Vollant from the zlib 1.1.x sources, and distributed at - http://www.winimage.com/zLibDll - It uses the WINAPI calling convention for the exported functions, and - includes the minizip functionality. If your application needs that - particular build of zlib.dll, you can rename zlibwapi.dll to zlib.dll. - -- The new DLL was renamed because there exist several incompatible - versions of zlib.dll on the Internet. - -- There is also an official DLL build of zlib, named zlib1.dll. This one - is exporting the functions using the CDECL convention. See the file - win32\DLL_FAQ.txt found in this zlib distribution. - -- There used to be a ZLIB_DLL macro in zlib 1.1.x, but now this symbol - has a slightly different effect. To avoid compatibility problems, do - not define it here. - - -Gilles Vollant -info@winimage.com - -Visual Studio 2013 and 2015 Projects from Sean Hunt -seandhunt_7@yahoo.com diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/miniunz.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/miniunz.vcxproj deleted file mode 100644 index 1b36242..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/miniunz.vcxproj +++ /dev/null @@ -1,310 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Win32 - - - Debug - x64 - - - Release - Itanium - - - Release - Win32 - - - Release - x64 - - - - {C52F9E7B-498A-42BE-8DB4-85A15694382A} - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30128.1 - x86\MiniUnzip$(Configuration)\ - x86\MiniUnzip$(Configuration)\Tmp\ - true - false - x86\MiniUnzip$(Configuration)\ - x86\MiniUnzip$(Configuration)\Tmp\ - false - false - x64\MiniUnzip$(Configuration)\ - x64\MiniUnzip$(Configuration)\Tmp\ - true - false - ia64\MiniUnzip$(Configuration)\ - ia64\MiniUnzip$(Configuration)\Tmp\ - true - false - x64\MiniUnzip$(Configuration)\ - x64\MiniUnzip$(Configuration)\Tmp\ - false - false - ia64\MiniUnzip$(Configuration)\ - ia64\MiniUnzip$(Configuration)\Tmp\ - false - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebug - false - - - $(IntDir) - Level3 - EditAndContinue - - - x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)miniunz.exe - true - $(OutDir)miniunz.pdb - Console - false - - - MachineX86 - - - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - Default - MultiThreaded - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)miniunz.exe - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)miniunz.exe - true - $(OutDir)miniunz.pdb - Console - MachineX64 - - - - - Itanium - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)miniunz.exe - true - $(OutDir)miniunz.pdb - Console - MachineIA64 - - - - - X64 - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)miniunz.exe - true - Console - true - true - MachineX64 - - - - - Itanium - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)miniunz.exe - true - Console - true - true - MachineIA64 - - - - - - - - {8fd826f8-3739-44e6-8cc8-997122e53b8d} - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/miniunz.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/miniunz.vcxproj.filters deleted file mode 100644 index 0bd1221..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/miniunz.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {048af943-022b-4db6-beeb-a54c34774ee2} - cpp;c;cxx;def;odl;idl;hpj;bat;asm - - - {c1d600d2-888f-4aea-b73e-8b0dd9befa0c} - h;hpp;hxx;hm;inl;inc - - - {0844199a-966b-4f19-81db-1e0125e141b9} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - - - Source Files - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/minizip.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/minizip.vcxproj deleted file mode 100644 index ccd3651..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/minizip.vcxproj +++ /dev/null @@ -1,307 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Win32 - - - Debug - x64 - - - Release - Itanium - - - Release - Win32 - - - Release - x64 - - - - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B} - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30128.1 - x86\MiniZip$(Configuration)\ - x86\MiniZip$(Configuration)\Tmp\ - true - false - x86\MiniZip$(Configuration)\ - x86\MiniZip$(Configuration)\Tmp\ - false - x64\$(Configuration)\ - x64\$(Configuration)\ - true - false - ia64\$(Configuration)\ - ia64\$(Configuration)\ - true - false - x64\$(Configuration)\ - x64\$(Configuration)\ - false - ia64\$(Configuration)\ - ia64\$(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebug - false - - - $(IntDir) - Level3 - EditAndContinue - - - x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)minizip.exe - true - $(OutDir)minizip.pdb - Console - false - - - MachineX86 - - - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - Default - MultiThreaded - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)minizip.exe - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)minizip.exe - true - $(OutDir)minizip.pdb - Console - MachineX64 - - - - - Itanium - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)minizip.exe - true - $(OutDir)minizip.pdb - Console - MachineIA64 - - - - - X64 - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)minizip.exe - true - Console - true - true - MachineX64 - - - - - Itanium - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)minizip.exe - true - Console - true - true - MachineIA64 - - - - - - - - {8fd826f8-3739-44e6-8cc8-997122e53b8d} - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/minizip.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/minizip.vcxproj.filters deleted file mode 100644 index 7076d76..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/minizip.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {c0419b40-bf50-40da-b153-ff74215b79de} - cpp;c;cxx;def;odl;idl;hpj;bat;asm - - - {bb87b070-735b-478e-92ce-7383abb2f36c} - h;hpp;hxx;hm;inl;inc - - - {f46ab6a6-548f-43cb-ae96-681abb5bd5db} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - - - Source Files - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/testzlib.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/testzlib.vcxproj deleted file mode 100644 index 476b8ea..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/testzlib.vcxproj +++ /dev/null @@ -1,420 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Win32 - - - Debug - x64 - - - ReleaseWithoutAsm - Itanium - - - ReleaseWithoutAsm - Win32 - - - ReleaseWithoutAsm - x64 - - - Release - Itanium - - - Release - Win32 - - - Release - x64 - - - - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B} - testzlib - Win32Proj - - - - Application - MultiByte - true - - - Application - MultiByte - true - - - Application - MultiByte - - - Application - MultiByte - true - - - Application - MultiByte - true - - - Application - MultiByte - - - Application - true - - - Application - true - - - Application - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30128.1 - x86\TestZlib$(Configuration)\ - x86\TestZlib$(Configuration)\Tmp\ - true - false - x86\TestZlib$(Configuration)\ - x86\TestZlib$(Configuration)\Tmp\ - false - false - x86\TestZlib$(Configuration)\ - x86\TestZlib$(Configuration)\Tmp\ - false - false - x64\TestZlib$(Configuration)\ - x64\TestZlib$(Configuration)\Tmp\ - false - ia64\TestZlib$(Configuration)\ - ia64\TestZlib$(Configuration)\Tmp\ - true - false - x64\TestZlib$(Configuration)\ - x64\TestZlib$(Configuration)\Tmp\ - false - ia64\TestZlib$(Configuration)\ - ia64\TestZlib$(Configuration)\Tmp\ - false - false - x64\TestZlib$(Configuration)\ - x64\TestZlib$(Configuration)\Tmp\ - false - ia64\TestZlib$(Configuration)\ - ia64\TestZlib$(Configuration)\Tmp\ - false - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - ..\..\..;%(AdditionalIncludeDirectories) - ASMV;ASMINF;WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebug - false - - - AssemblyAndSourceCode - $(IntDir) - Level3 - EditAndContinue - - - ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) - $(OutDir)testzlib.exe - true - $(OutDir)testzlib.pdb - Console - false - - - MachineX86 - - - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;%(AdditionalIncludeDirectories) - WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - true - Default - MultiThreaded - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - $(OutDir)testzlib.exe - true - Console - true - true - false - - - MachineX86 - - - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;%(AdditionalIncludeDirectories) - ASMV;ASMINF;WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - true - Default - MultiThreaded - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) - $(OutDir)testzlib.exe - true - Console - true - true - false - - - MachineX86 - - - - - ..\..\..;%(AdditionalIncludeDirectories) - ASMV;ASMINF;WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - Default - MultiThreadedDebugDLL - false - $(IntDir) - - - ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) - - - - - Itanium - - - Disabled - ..\..\..;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - AssemblyAndSourceCode - $(IntDir) - Level3 - ProgramDatabase - - - $(OutDir)testzlib.exe - true - $(OutDir)testzlib.pdb - Console - MachineIA64 - - - - - ..\..\..;%(AdditionalIncludeDirectories) - WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - Default - MultiThreadedDLL - false - $(IntDir) - - - %(AdditionalDependencies) - - - - - Itanium - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - $(OutDir)testzlib.exe - true - Console - true - true - MachineIA64 - - - - - ..\..\..;%(AdditionalIncludeDirectories) - ASMV;ASMINF;WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - Default - MultiThreadedDLL - false - $(IntDir) - - - ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) - - - - - Itanium - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - $(OutDir)testzlib.exe - true - Console - true - true - MachineIA64 - - - - - - - - - - true - true - true - true - true - true - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/testzlib.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/testzlib.vcxproj.filters deleted file mode 100644 index 3276491..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/testzlib.vcxproj.filters +++ /dev/null @@ -1,58 +0,0 @@ - - - - - {c1f6a2e3-5da5-4955-8653-310d3efe05a9} - cpp;c;cxx;def;odl;idl;hpj;bat;asm - - - {c2aaffdc-2c95-4d6f-8466-4bec5890af2c} - h;hpp;hxx;hm;inl;inc - - - {c274fe07-05f2-461c-964b-f6341e4e7eb5} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/testzlibdll.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/testzlibdll.vcxproj deleted file mode 100644 index 8e38876..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/testzlibdll.vcxproj +++ /dev/null @@ -1,310 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Win32 - - - Debug - x64 - - - Release - Itanium - - - Release - Win32 - - - Release - x64 - - - - {C52F9E7B-498A-42BE-8DB4-85A15694366A} - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30128.1 - x86\TestZlibDll$(Configuration)\ - x86\TestZlibDll$(Configuration)\Tmp\ - true - false - x86\TestZlibDll$(Configuration)\ - x86\TestZlibDll$(Configuration)\Tmp\ - false - false - x64\TestZlibDll$(Configuration)\ - x64\TestZlibDll$(Configuration)\Tmp\ - true - false - ia64\TestZlibDll$(Configuration)\ - ia64\TestZlibDll$(Configuration)\Tmp\ - true - false - x64\TestZlibDll$(Configuration)\ - x64\TestZlibDll$(Configuration)\Tmp\ - false - false - ia64\TestZlibDll$(Configuration)\ - ia64\TestZlibDll$(Configuration)\Tmp\ - false - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebug - false - - - $(IntDir) - Level3 - EditAndContinue - - - x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)testzlibdll.exe - true - $(OutDir)testzlib.pdb - Console - false - - - MachineX86 - - - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - Default - MultiThreaded - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)testzlibdll.exe - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)testzlibdll.exe - true - $(OutDir)testzlib.pdb - Console - MachineX64 - - - - - Itanium - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)testzlibdll.exe - true - $(OutDir)testzlib.pdb - Console - MachineIA64 - - - - - X64 - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)testzlibdll.exe - true - Console - true - true - MachineX64 - - - - - Itanium - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)testzlibdll.exe - true - Console - true - true - MachineIA64 - - - - - - - - {8fd826f8-3739-44e6-8cc8-997122e53b8d} - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/testzlibdll.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/testzlibdll.vcxproj.filters deleted file mode 100644 index ab87f09..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/testzlibdll.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {fa61a89f-93fc-4c89-b29e-36224b7592f4} - cpp;c;cxx;def;odl;idl;hpj;bat;asm - - - {d4b85da0-2ba2-4934-b57f-e2584e3848ee} - h;hpp;hxx;hm;inl;inc - - - {e573e075-00bd-4a7d-bd67-a8cc9bfc5aca} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - - - Source Files - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/zlib.rc b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/zlib.rc deleted file mode 100644 index 9475873..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/zlib.rc +++ /dev/null @@ -1,32 +0,0 @@ -#include - -#define IDR_VERSION1 1 -IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE - FILEVERSION 1, 2, 12, 0 - PRODUCTVERSION 1, 2, 12, 0 - FILEFLAGSMASK VS_FFI_FILEFLAGSMASK - FILEFLAGS 0 - FILEOS VOS_DOS_WINDOWS32 - FILETYPE VFT_DLL - FILESUBTYPE 0 // not used -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904E4" - //language ID = U.S. English, char set = Windows, Multilingual - - BEGIN - VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" - VALUE "FileVersion", "1.2.12\0" - VALUE "InternalName", "zlib\0" - VALUE "OriginalFilename", "zlibwapi.dll\0" - VALUE "ProductName", "ZLib.DLL\0" - VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" - VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0409, 1252 - END -END diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/zlibstat.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/zlibstat.vcxproj deleted file mode 100644 index 45389a3..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/zlibstat.vcxproj +++ /dev/null @@ -1,473 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Win32 - - - Debug - x64 - - - ReleaseWithoutAsm - Itanium - - - ReleaseWithoutAsm - Win32 - - - ReleaseWithoutAsm - x64 - - - Release - Itanium - - - Release - Win32 - - - Release - x64 - - - - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8} - - - - StaticLibrary - false - - - StaticLibrary - false - - - StaticLibrary - false - - - StaticLibrary - false - - - StaticLibrary - false - - - StaticLibrary - false - - - StaticLibrary - false - - - StaticLibrary - false - - - StaticLibrary - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30128.1 - x86\ZlibStat$(Configuration)\ - x86\ZlibStat$(Configuration)\Tmp\ - x86\ZlibStat$(Configuration)\ - x86\ZlibStat$(Configuration)\Tmp\ - x86\ZlibStat$(Configuration)\ - x86\ZlibStat$(Configuration)\Tmp\ - x64\ZlibStat$(Configuration)\ - x64\ZlibStat$(Configuration)\Tmp\ - ia64\ZlibStat$(Configuration)\ - ia64\ZlibStat$(Configuration)\Tmp\ - x64\ZlibStat$(Configuration)\ - x64\ZlibStat$(Configuration)\Tmp\ - ia64\ZlibStat$(Configuration)\ - ia64\ZlibStat$(Configuration)\Tmp\ - x64\ZlibStat$(Configuration)\ - x64\ZlibStat$(Configuration)\Tmp\ - ia64\ZlibStat$(Configuration)\ - ia64\ZlibStat$(Configuration)\Tmp\ - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - - - MultiThreadedDebug - false - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - OldStyle - - - 0x040c - - - /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) - $(OutDir)zlibstat.lib - true - - - cd ..\..\masmx86 -bld_ml32.bat - - - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ASMV;ASMINF;%(PreprocessorDefinitions) - true - - - MultiThreaded - false - true - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - - - 0x040c - - - /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) - ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) - $(OutDir)zlibstat.lib - true - - - cd ..\..\masmx86 -bld_ml32.bat - - - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - true - - - MultiThreaded - false - true - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - - - 0x040c - - - /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) - $(OutDir)zlibstat.lib - true - - - - - X64 - - - Disabled - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - - - MultiThreadedDebugDLL - false - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - OldStyle - - - 0x040c - - - /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) - $(OutDir)zlibstat.lib - true - - - cd ..\..\masmx64 -bld_ml64.bat - - - - - Itanium - - - Disabled - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - - - MultiThreadedDebugDLL - false - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - OldStyle - - - 0x040c - - - /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) - $(OutDir)zlibstat.lib - true - - - - - X64 - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - - - 0x040c - - - /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) - ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) - $(OutDir)zlibstat.lib - true - - - cd ..\..\masmx64 -bld_ml64.bat - - - - - Itanium - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - - - 0x040c - - - /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) - $(OutDir)zlibstat.lib - true - - - - - X64 - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - - - 0x040c - - - /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) - $(OutDir)zlibstat.lib - true - - - - - Itanium - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - - - 0x040c - - - /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) - $(OutDir)zlibstat.lib - true - - - - - - - - - - - - - - true - true - true - true - true - true - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/zlibstat.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/zlibstat.vcxproj.filters deleted file mode 100644 index 0c8b250..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/zlibstat.vcxproj.filters +++ /dev/null @@ -1,77 +0,0 @@ - - - - - {174213f6-7f66-4ae8-a3a8-a1e0a1e6ffdd} - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files - - - - - Source Files - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/zlibvc.def b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/zlibvc.def deleted file mode 100644 index 99c71e3..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/zlibvc.def +++ /dev/null @@ -1,158 +0,0 @@ -LIBRARY -; zlib data compression and ZIP file I/O library - -VERSION 1.2 - -EXPORTS - adler32 @1 - compress @2 - crc32 @3 - deflate @4 - deflateCopy @5 - deflateEnd @6 - deflateInit2_ @7 - deflateInit_ @8 - deflateParams @9 - deflateReset @10 - deflateSetDictionary @11 - gzclose @12 - gzdopen @13 - gzerror @14 - gzflush @15 - gzopen @16 - gzread @17 - gzwrite @18 - inflate @19 - inflateEnd @20 - inflateInit2_ @21 - inflateInit_ @22 - inflateReset @23 - inflateSetDictionary @24 - inflateSync @25 - uncompress @26 - zlibVersion @27 - gzprintf @28 - gzputc @29 - gzgetc @30 - gzseek @31 - gzrewind @32 - gztell @33 - gzeof @34 - gzsetparams @35 - zError @36 - inflateSyncPoint @37 - get_crc_table @38 - compress2 @39 - gzputs @40 - gzgets @41 - inflateCopy @42 - inflateBackInit_ @43 - inflateBack @44 - inflateBackEnd @45 - compressBound @46 - deflateBound @47 - gzclearerr @48 - gzungetc @49 - zlibCompileFlags @50 - deflatePrime @51 - deflatePending @52 - - unzOpen @61 - unzClose @62 - unzGetGlobalInfo @63 - unzGetCurrentFileInfo @64 - unzGoToFirstFile @65 - unzGoToNextFile @66 - unzOpenCurrentFile @67 - unzReadCurrentFile @68 - unzOpenCurrentFile3 @69 - unztell @70 - unzeof @71 - unzCloseCurrentFile @72 - unzGetGlobalComment @73 - unzStringFileNameCompare @74 - unzLocateFile @75 - unzGetLocalExtrafield @76 - unzOpen2 @77 - unzOpenCurrentFile2 @78 - unzOpenCurrentFilePassword @79 - - zipOpen @80 - zipOpenNewFileInZip @81 - zipWriteInFileInZip @82 - zipCloseFileInZip @83 - zipClose @84 - zipOpenNewFileInZip2 @86 - zipCloseFileInZipRaw @87 - zipOpen2 @88 - zipOpenNewFileInZip3 @89 - - unzGetFilePos @100 - unzGoToFilePos @101 - - fill_win32_filefunc @110 - -; zlibwapi v1.2.4 added: - fill_win32_filefunc64 @111 - fill_win32_filefunc64A @112 - fill_win32_filefunc64W @113 - - unzOpen64 @120 - unzOpen2_64 @121 - unzGetGlobalInfo64 @122 - unzGetCurrentFileInfo64 @124 - unzGetCurrentFileZStreamPos64 @125 - unztell64 @126 - unzGetFilePos64 @127 - unzGoToFilePos64 @128 - - zipOpen64 @130 - zipOpen2_64 @131 - zipOpenNewFileInZip64 @132 - zipOpenNewFileInZip2_64 @133 - zipOpenNewFileInZip3_64 @134 - zipOpenNewFileInZip4_64 @135 - zipCloseFileInZipRaw64 @136 - -; zlib1 v1.2.4 added: - adler32_combine @140 - crc32_combine @142 - deflateSetHeader @144 - deflateTune @145 - gzbuffer @146 - gzclose_r @147 - gzclose_w @148 - gzdirect @149 - gzoffset @150 - inflateGetHeader @156 - inflateMark @157 - inflatePrime @158 - inflateReset2 @159 - inflateUndermine @160 - -; zlib1 v1.2.6 added: - gzgetc_ @161 - inflateResetKeep @163 - deflateResetKeep @164 - -; zlib1 v1.2.7 added: - gzopen_w @165 - -; zlib1 v1.2.8 added: - inflateGetDictionary @166 - gzvprintf @167 - -; zlib1 v1.2.9 added: - inflateCodesUsed @168 - inflateValidate @169 - uncompress2 @170 - gzfread @171 - gzfwrite @172 - deflateGetDictionary @173 - adler32_z @174 - crc32_z @175 - -; zlib1 v1.2.12 added: - crc32_combine_gen @176 - crc32_combine_gen64 @177 - crc32_combine_op @178 diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/zlibvc.sln b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/zlibvc.sln deleted file mode 100644 index 649f40c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/zlibvc.sln +++ /dev/null @@ -1,135 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibvc", "zlibvc.vcxproj", "{8FD826F8-3739-44E6-8CC8-997122E53B8D}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibstat", "zlibstat.vcxproj", "{745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlib", "testzlib.vcxproj", "{AA6666AA-E09F-4135-9C0C-4FE50C3C654B}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlibdll", "testzlibdll.vcxproj", "{C52F9E7B-498A-42BE-8DB4-85A15694366A}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minizip", "minizip.vcxproj", "{48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniunz", "miniunz.vcxproj", "{C52F9E7B-498A-42BE-8DB4-85A15694382A}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Itanium = Debug|Itanium - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Itanium = Release|Itanium - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - ReleaseWithoutAsm|Itanium = ReleaseWithoutAsm|Itanium - ReleaseWithoutAsm|Win32 = ReleaseWithoutAsm|Win32 - ReleaseWithoutAsm|x64 = ReleaseWithoutAsm|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Itanium.ActiveCfg = Debug|Itanium - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Itanium.Build.0 = Debug|Itanium - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.ActiveCfg = Debug|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.Build.0 = Debug|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.ActiveCfg = Debug|x64 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.Build.0 = Debug|x64 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Itanium.ActiveCfg = Release|Itanium - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Itanium.Build.0 = Release|Itanium - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.ActiveCfg = Release|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.Build.0 = Release|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.ActiveCfg = Release|x64 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.Build.0 = Release|x64 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Itanium - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Itanium.Build.0 = ReleaseWithoutAsm|Itanium - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Itanium.ActiveCfg = Debug|Itanium - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Itanium.Build.0 = Debug|Itanium - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.ActiveCfg = Debug|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.Build.0 = Debug|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.ActiveCfg = Debug|x64 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.Build.0 = Debug|x64 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Itanium.ActiveCfg = Release|Itanium - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Itanium.Build.0 = Release|Itanium - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.ActiveCfg = Release|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.Build.0 = Release|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.ActiveCfg = Release|x64 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.Build.0 = Release|x64 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Itanium - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Itanium.Build.0 = ReleaseWithoutAsm|Itanium - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Itanium - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.Build.0 = Debug|Itanium - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Itanium - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.Build.0 = Release|Itanium - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Itanium - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.Build.0 = ReleaseWithoutAsm|Itanium - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Itanium.ActiveCfg = Debug|Itanium - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Itanium.Build.0 = Debug|Itanium - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.ActiveCfg = Debug|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.Build.0 = Debug|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.ActiveCfg = Debug|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.Build.0 = Debug|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Itanium.ActiveCfg = Release|Itanium - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Itanium.Build.0 = Release|Itanium - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.Build.0 = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.ActiveCfg = Release|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.Build.0 = Release|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Itanium - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Itanium.Build.0 = Release|Itanium - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Itanium - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.Build.0 = Debug|Itanium - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Itanium - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.Build.0 = Release|Itanium - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Itanium - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.Build.0 = Release|Itanium - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Itanium.ActiveCfg = Debug|Itanium - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Itanium.Build.0 = Debug|Itanium - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.ActiveCfg = Debug|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.Build.0 = Debug|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.ActiveCfg = Debug|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.Build.0 = Debug|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Itanium.ActiveCfg = Release|Itanium - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Itanium.Build.0 = Release|Itanium - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.Build.0 = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.ActiveCfg = Release|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.Build.0 = Release|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Itanium - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Itanium.Build.0 = Release|Itanium - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/zlibvc.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/zlibvc.vcxproj deleted file mode 100644 index 7d7c49a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/zlibvc.vcxproj +++ /dev/null @@ -1,657 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Win32 - - - Debug - x64 - - - ReleaseWithoutAsm - Itanium - - - ReleaseWithoutAsm - Win32 - - - ReleaseWithoutAsm - x64 - - - Release - Itanium - - - Release - Win32 - - - Release - x64 - - - - {8FD826F8-3739-44E6-8CC8-997122E53B8D} - - - - DynamicLibrary - false - true - - - DynamicLibrary - false - true - - - DynamicLibrary - false - - - DynamicLibrary - false - true - - - DynamicLibrary - false - true - - - DynamicLibrary - false - - - DynamicLibrary - false - true - - - DynamicLibrary - false - true - - - DynamicLibrary - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30128.1 - x86\ZlibDll$(Configuration)\ - x86\ZlibDll$(Configuration)\Tmp\ - true - false - x86\ZlibDll$(Configuration)\ - x86\ZlibDll$(Configuration)\Tmp\ - false - false - x86\ZlibDll$(Configuration)\ - x86\ZlibDll$(Configuration)\Tmp\ - false - false - x64\ZlibDll$(Configuration)\ - x64\ZlibDll$(Configuration)\Tmp\ - true - false - ia64\ZlibDll$(Configuration)\ - ia64\ZlibDll$(Configuration)\Tmp\ - true - false - x64\ZlibDll$(Configuration)\ - x64\ZlibDll$(Configuration)\Tmp\ - false - false - ia64\ZlibDll$(Configuration)\ - ia64\ZlibDll$(Configuration)\Tmp\ - false - false - x64\ZlibDll$(Configuration)\ - x64\ZlibDll$(Configuration)\Tmp\ - false - false - ia64\ZlibDll$(Configuration)\ - ia64\ZlibDll$(Configuration)\Tmp\ - false - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - zlibwapid - zlibwapi - zlibwapi - zlibwapid - zlibwapi - zlibwapi - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - Win32 - $(OutDir)zlibvc.tlb - - - Disabled - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;%(PreprocessorDefinitions) - - - MultiThreadedDebug - false - $(IntDir)zlibvc.pch - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - EditAndContinue - - - _DEBUG;%(PreprocessorDefinitions) - 0x040c - - - /MACHINE:I386 %(AdditionalOptions) - ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) - true - .\zlibvc.def - true - true - Windows - false - - - - - cd ..\..\masmx86 -bld_ml32.bat - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - Win32 - $(OutDir)zlibvc.tlb - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibvc.pch - All - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x040c - - - /MACHINE:I386 %(AdditionalOptions) - true - false - .\zlibvc.def - true - Windows - false - - - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - Win32 - $(OutDir)zlibvc.tlb - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;%(PreprocessorDefinitions) - true - - - MultiThreaded - false - true - $(IntDir)zlibvc.pch - All - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x040c - - - /MACHINE:I386 %(AdditionalOptions) - ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) - true - false - .\zlibvc.def - true - Windows - false - - - - - cd ..\..\masmx86 -bld_ml32.bat - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - X64 - $(OutDir)zlibvc.tlb - - - Disabled - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) - - - MultiThreadedDebugDLL - false - $(IntDir)zlibvc.pch - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x040c - - - ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) - true - .\zlibvc.def - true - true - Windows - MachineX64 - - - cd ..\..\masmx64 -bld_ml64.bat - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - Itanium - $(OutDir)zlibvc.tlb - - - Disabled - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) - - - MultiThreadedDebugDLL - false - $(IntDir)zlibvc.pch - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x040c - - - $(OutDir)zlibwapi.dll - true - .\zlibvc.def - true - $(OutDir)zlibwapi.pdb - true - $(OutDir)zlibwapi.map - Windows - $(OutDir)zlibwapi.lib - MachineIA64 - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - X64 - $(OutDir)zlibvc.tlb - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibvc.pch - All - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x040c - - - true - false - .\zlibvc.def - true - Windows - MachineX64 - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - Itanium - $(OutDir)zlibvc.tlb - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibvc.pch - All - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x040c - - - $(OutDir)zlibwapi.dll - true - false - .\zlibvc.def - $(OutDir)zlibwapi.pdb - true - $(OutDir)zlibwapi.map - Windows - $(OutDir)zlibwapi.lib - MachineIA64 - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - X64 - $(OutDir)zlibvc.tlb - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibvc.pch - All - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x040c - - - ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) - true - false - .\zlibvc.def - true - Windows - MachineX64 - - - cd ..\..\masmx64 -bld_ml64.bat - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - Itanium - $(OutDir)zlibvc.tlb - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibvc.pch - All - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x040c - - - $(OutDir)zlibwapi.dll - true - false - .\zlibvc.def - $(OutDir)zlibwapi.pdb - true - $(OutDir)zlibwapi.map - Windows - $(OutDir)zlibwapi.lib - MachineIA64 - - - - - - - - - - - - - - true - true - true - true - true - true - - - - - - - - - - %(AdditionalIncludeDirectories) - ZLIB_INTERNAL;%(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - ZLIB_INTERNAL;%(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - ZLIB_INTERNAL;%(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - ZLIB_INTERNAL;%(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - ZLIB_INTERNAL;%(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - ZLIB_INTERNAL;%(PreprocessorDefinitions) - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/zlibvc.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/zlibvc.vcxproj.filters deleted file mode 100644 index 2278682..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc10/zlibvc.vcxproj.filters +++ /dev/null @@ -1,118 +0,0 @@ - - - - - {07934a85-8b61-443d-a0ee-b2eedb74f3cd} - cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90 - - - {1d99675b-433d-4a21-9e50-ed4ab8b19762} - h;hpp;hxx;hm;inl;fi;fd - - - {431c0958-fa71-44d0-9084-2d19d100c0cc} - ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files - - - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc11/miniunz.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc11/miniunz.vcxproj deleted file mode 100644 index 99be63d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc11/miniunz.vcxproj +++ /dev/null @@ -1,314 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Win32 - - - Debug - x64 - - - Release - Itanium - - - Release - Win32 - - - Release - x64 - - - - {C52F9E7B-498A-42BE-8DB4-85A15694382A} - Win32Proj - - - - Application - MultiByte - v110 - - - Application - Unicode - v110 - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - v110 - - - Application - MultiByte - v110 - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30128.1 - x86\MiniUnzip$(Configuration)\ - x86\MiniUnzip$(Configuration)\Tmp\ - true - false - x86\MiniUnzip$(Configuration)\ - x86\MiniUnzip$(Configuration)\Tmp\ - false - false - x64\MiniUnzip$(Configuration)\ - x64\MiniUnzip$(Configuration)\Tmp\ - true - false - ia64\MiniUnzip$(Configuration)\ - ia64\MiniUnzip$(Configuration)\Tmp\ - true - false - x64\MiniUnzip$(Configuration)\ - x64\MiniUnzip$(Configuration)\Tmp\ - false - false - ia64\MiniUnzip$(Configuration)\ - ia64\MiniUnzip$(Configuration)\Tmp\ - false - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)miniunz.exe - true - $(OutDir)miniunz.pdb - Console - false - - - MachineX86 - - - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - Default - MultiThreaded - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)miniunz.exe - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)miniunz.exe - true - $(OutDir)miniunz.pdb - Console - MachineX64 - - - - - Itanium - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)miniunz.exe - true - $(OutDir)miniunz.pdb - Console - MachineIA64 - - - - - X64 - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)miniunz.exe - true - Console - true - true - MachineX64 - - - - - Itanium - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)miniunz.exe - true - Console - true - true - MachineIA64 - - - - - - - - {8fd826f8-3739-44e6-8cc8-997122e53b8d} - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc11/minizip.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc11/minizip.vcxproj deleted file mode 100644 index d6e98f4..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc11/minizip.vcxproj +++ /dev/null @@ -1,311 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Win32 - - - Debug - x64 - - - Release - Itanium - - - Release - Win32 - - - Release - x64 - - - - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B} - Win32Proj - - - - Application - MultiByte - v110 - - - Application - Unicode - v110 - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - v110 - - - Application - MultiByte - v110 - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30128.1 - x86\MiniZip$(Configuration)\ - x86\MiniZip$(Configuration)\Tmp\ - true - false - x86\MiniZip$(Configuration)\ - x86\MiniZip$(Configuration)\Tmp\ - false - x64\$(Configuration)\ - x64\$(Configuration)\ - true - false - ia64\$(Configuration)\ - ia64\$(Configuration)\ - true - false - x64\$(Configuration)\ - x64\$(Configuration)\ - false - ia64\$(Configuration)\ - ia64\$(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)minizip.exe - true - $(OutDir)minizip.pdb - Console - false - - - MachineX86 - - - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - Default - MultiThreaded - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)minizip.exe - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)minizip.exe - true - $(OutDir)minizip.pdb - Console - MachineX64 - - - - - Itanium - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)minizip.exe - true - $(OutDir)minizip.pdb - Console - MachineIA64 - - - - - X64 - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)minizip.exe - true - Console - true - true - MachineX64 - - - - - Itanium - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)minizip.exe - true - Console - true - true - MachineIA64 - - - - - - - - {8fd826f8-3739-44e6-8cc8-997122e53b8d} - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc11/testzlib.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc11/testzlib.vcxproj deleted file mode 100644 index 0115dd1..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc11/testzlib.vcxproj +++ /dev/null @@ -1,426 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Win32 - - - Debug - x64 - - - ReleaseWithoutAsm - Itanium - - - ReleaseWithoutAsm - Win32 - - - ReleaseWithoutAsm - x64 - - - Release - Itanium - - - Release - Win32 - - - Release - x64 - - - - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B} - testzlib - Win32Proj - - - - Application - MultiByte - true - v110 - - - Application - MultiByte - true - v110 - - - Application - Unicode - v110 - - - Application - MultiByte - true - - - Application - MultiByte - true - - - Application - MultiByte - - - Application - true - v110 - - - Application - true - v110 - - - Application - v110 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30128.1 - x86\TestZlib$(Configuration)\ - x86\TestZlib$(Configuration)\Tmp\ - true - false - x86\TestZlib$(Configuration)\ - x86\TestZlib$(Configuration)\Tmp\ - false - false - x86\TestZlib$(Configuration)\ - x86\TestZlib$(Configuration)\Tmp\ - false - false - x64\TestZlib$(Configuration)\ - x64\TestZlib$(Configuration)\Tmp\ - false - ia64\TestZlib$(Configuration)\ - ia64\TestZlib$(Configuration)\Tmp\ - true - false - x64\TestZlib$(Configuration)\ - x64\TestZlib$(Configuration)\Tmp\ - false - ia64\TestZlib$(Configuration)\ - ia64\TestZlib$(Configuration)\Tmp\ - false - false - x64\TestZlib$(Configuration)\ - x64\TestZlib$(Configuration)\Tmp\ - false - ia64\TestZlib$(Configuration)\ - ia64\TestZlib$(Configuration)\Tmp\ - false - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - ..\..\..;%(AdditionalIncludeDirectories) - ASMV;ASMINF;WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - AssemblyAndSourceCode - $(IntDir) - Level3 - ProgramDatabase - - - ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) - $(OutDir)testzlib.exe - true - $(OutDir)testzlib.pdb - Console - false - - - MachineX86 - - - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;%(AdditionalIncludeDirectories) - WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - true - Default - MultiThreaded - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - $(OutDir)testzlib.exe - true - Console - true - true - false - - - MachineX86 - - - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;%(AdditionalIncludeDirectories) - ASMV;ASMINF;WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - true - Default - MultiThreaded - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) - $(OutDir)testzlib.exe - true - Console - true - true - false - - - MachineX86 - - - - - ..\..\..;%(AdditionalIncludeDirectories) - ASMV;ASMINF;WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - Default - MultiThreadedDebugDLL - false - $(IntDir) - - - ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) - - - - - Itanium - - - Disabled - ..\..\..;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - AssemblyAndSourceCode - $(IntDir) - Level3 - ProgramDatabase - - - $(OutDir)testzlib.exe - true - $(OutDir)testzlib.pdb - Console - MachineIA64 - - - - - ..\..\..;%(AdditionalIncludeDirectories) - WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - Default - MultiThreadedDLL - false - $(IntDir) - - - %(AdditionalDependencies) - - - - - Itanium - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - $(OutDir)testzlib.exe - true - Console - true - true - MachineIA64 - - - - - ..\..\..;%(AdditionalIncludeDirectories) - ASMV;ASMINF;WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - Default - MultiThreadedDLL - false - $(IntDir) - - - ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) - - - - - Itanium - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - $(OutDir)testzlib.exe - true - Console - true - true - MachineIA64 - - - - - - - - - - true - true - true - true - true - true - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc11/testzlibdll.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc11/testzlibdll.vcxproj deleted file mode 100644 index 9d36336..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc11/testzlibdll.vcxproj +++ /dev/null @@ -1,314 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Win32 - - - Debug - x64 - - - Release - Itanium - - - Release - Win32 - - - Release - x64 - - - - {C52F9E7B-498A-42BE-8DB4-85A15694366A} - Win32Proj - - - - Application - MultiByte - v110 - - - Application - Unicode - v110 - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - v110 - - - Application - MultiByte - v110 - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30128.1 - x86\TestZlibDll$(Configuration)\ - x86\TestZlibDll$(Configuration)\Tmp\ - true - false - x86\TestZlibDll$(Configuration)\ - x86\TestZlibDll$(Configuration)\Tmp\ - false - false - x64\TestZlibDll$(Configuration)\ - x64\TestZlibDll$(Configuration)\Tmp\ - true - false - ia64\TestZlibDll$(Configuration)\ - ia64\TestZlibDll$(Configuration)\Tmp\ - true - false - x64\TestZlibDll$(Configuration)\ - x64\TestZlibDll$(Configuration)\Tmp\ - false - false - ia64\TestZlibDll$(Configuration)\ - ia64\TestZlibDll$(Configuration)\Tmp\ - false - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)testzlibdll.exe - true - $(OutDir)testzlib.pdb - Console - false - - - MachineX86 - - - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - Default - MultiThreaded - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)testzlibdll.exe - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)testzlibdll.exe - true - $(OutDir)testzlib.pdb - Console - MachineX64 - - - - - Itanium - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)testzlibdll.exe - true - $(OutDir)testzlib.pdb - Console - MachineIA64 - - - - - X64 - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)testzlibdll.exe - true - Console - true - true - MachineX64 - - - - - Itanium - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)testzlibdll.exe - true - Console - true - true - MachineIA64 - - - - - - - - {8fd826f8-3739-44e6-8cc8-997122e53b8d} - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc11/zlib.rc b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc11/zlib.rc deleted file mode 100644 index 9475873..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc11/zlib.rc +++ /dev/null @@ -1,32 +0,0 @@ -#include - -#define IDR_VERSION1 1 -IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE - FILEVERSION 1, 2, 12, 0 - PRODUCTVERSION 1, 2, 12, 0 - FILEFLAGSMASK VS_FFI_FILEFLAGSMASK - FILEFLAGS 0 - FILEOS VOS_DOS_WINDOWS32 - FILETYPE VFT_DLL - FILESUBTYPE 0 // not used -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904E4" - //language ID = U.S. English, char set = Windows, Multilingual - - BEGIN - VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" - VALUE "FileVersion", "1.2.12\0" - VALUE "InternalName", "zlib\0" - VALUE "OriginalFilename", "zlibwapi.dll\0" - VALUE "ProductName", "ZLib.DLL\0" - VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" - VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0409, 1252 - END -END diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc11/zlibstat.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc11/zlibstat.vcxproj deleted file mode 100644 index 64b4d86..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc11/zlibstat.vcxproj +++ /dev/null @@ -1,464 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Win32 - - - Debug - x64 - - - ReleaseWithoutAsm - Itanium - - - ReleaseWithoutAsm - Win32 - - - ReleaseWithoutAsm - x64 - - - Release - Itanium - - - Release - Win32 - - - Release - x64 - - - - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8} - - - - StaticLibrary - false - v110 - - - StaticLibrary - false - v110 - - - StaticLibrary - false - v110 - Unicode - - - StaticLibrary - false - - - StaticLibrary - false - - - StaticLibrary - false - - - StaticLibrary - false - v110 - - - StaticLibrary - false - v110 - - - StaticLibrary - false - v110 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30128.1 - x86\ZlibStat$(Configuration)\ - x86\ZlibStat$(Configuration)\Tmp\ - x86\ZlibStat$(Configuration)\ - x86\ZlibStat$(Configuration)\Tmp\ - x86\ZlibStat$(Configuration)\ - x86\ZlibStat$(Configuration)\Tmp\ - x64\ZlibStat$(Configuration)\ - x64\ZlibStat$(Configuration)\Tmp\ - ia64\ZlibStat$(Configuration)\ - ia64\ZlibStat$(Configuration)\Tmp\ - x64\ZlibStat$(Configuration)\ - x64\ZlibStat$(Configuration)\Tmp\ - ia64\ZlibStat$(Configuration)\ - ia64\ZlibStat$(Configuration)\Tmp\ - x64\ZlibStat$(Configuration)\ - x64\ZlibStat$(Configuration)\Tmp\ - ia64\ZlibStat$(Configuration)\ - ia64\ZlibStat$(Configuration)\Tmp\ - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - - - MultiThreadedDebugDLL - false - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - OldStyle - - - 0x040c - - - /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) - $(OutDir)zlibstat.lib - true - - - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ASMV;ASMINF;%(PreprocessorDefinitions) - true - - - MultiThreaded - false - true - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - - - 0x040c - - - /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) - ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) - $(OutDir)zlibstat.lib - true - - - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - true - - - MultiThreaded - false - true - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - - - 0x040c - - - /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) - $(OutDir)zlibstat.lib - true - - - - - X64 - - - Disabled - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - - - MultiThreadedDebugDLL - false - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - OldStyle - - - 0x040c - - - /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) - $(OutDir)zlibstat.lib - true - - - - - Itanium - - - Disabled - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - - - MultiThreadedDebugDLL - false - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - OldStyle - - - 0x040c - - - /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) - $(OutDir)zlibstat.lib - true - - - - - X64 - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - - - 0x040c - - - /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) - ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) - $(OutDir)zlibstat.lib - true - - - - - Itanium - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - - - 0x040c - - - /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) - $(OutDir)zlibstat.lib - true - - - - - X64 - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - - - 0x040c - - - /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) - $(OutDir)zlibstat.lib - true - - - - - Itanium - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - - - 0x040c - - - /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) - $(OutDir)zlibstat.lib - true - - - - - - - - - - - - - - true - true - true - true - true - true - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc11/zlibvc.def b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc11/zlibvc.def deleted file mode 100644 index 99c71e3..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc11/zlibvc.def +++ /dev/null @@ -1,158 +0,0 @@ -LIBRARY -; zlib data compression and ZIP file I/O library - -VERSION 1.2 - -EXPORTS - adler32 @1 - compress @2 - crc32 @3 - deflate @4 - deflateCopy @5 - deflateEnd @6 - deflateInit2_ @7 - deflateInit_ @8 - deflateParams @9 - deflateReset @10 - deflateSetDictionary @11 - gzclose @12 - gzdopen @13 - gzerror @14 - gzflush @15 - gzopen @16 - gzread @17 - gzwrite @18 - inflate @19 - inflateEnd @20 - inflateInit2_ @21 - inflateInit_ @22 - inflateReset @23 - inflateSetDictionary @24 - inflateSync @25 - uncompress @26 - zlibVersion @27 - gzprintf @28 - gzputc @29 - gzgetc @30 - gzseek @31 - gzrewind @32 - gztell @33 - gzeof @34 - gzsetparams @35 - zError @36 - inflateSyncPoint @37 - get_crc_table @38 - compress2 @39 - gzputs @40 - gzgets @41 - inflateCopy @42 - inflateBackInit_ @43 - inflateBack @44 - inflateBackEnd @45 - compressBound @46 - deflateBound @47 - gzclearerr @48 - gzungetc @49 - zlibCompileFlags @50 - deflatePrime @51 - deflatePending @52 - - unzOpen @61 - unzClose @62 - unzGetGlobalInfo @63 - unzGetCurrentFileInfo @64 - unzGoToFirstFile @65 - unzGoToNextFile @66 - unzOpenCurrentFile @67 - unzReadCurrentFile @68 - unzOpenCurrentFile3 @69 - unztell @70 - unzeof @71 - unzCloseCurrentFile @72 - unzGetGlobalComment @73 - unzStringFileNameCompare @74 - unzLocateFile @75 - unzGetLocalExtrafield @76 - unzOpen2 @77 - unzOpenCurrentFile2 @78 - unzOpenCurrentFilePassword @79 - - zipOpen @80 - zipOpenNewFileInZip @81 - zipWriteInFileInZip @82 - zipCloseFileInZip @83 - zipClose @84 - zipOpenNewFileInZip2 @86 - zipCloseFileInZipRaw @87 - zipOpen2 @88 - zipOpenNewFileInZip3 @89 - - unzGetFilePos @100 - unzGoToFilePos @101 - - fill_win32_filefunc @110 - -; zlibwapi v1.2.4 added: - fill_win32_filefunc64 @111 - fill_win32_filefunc64A @112 - fill_win32_filefunc64W @113 - - unzOpen64 @120 - unzOpen2_64 @121 - unzGetGlobalInfo64 @122 - unzGetCurrentFileInfo64 @124 - unzGetCurrentFileZStreamPos64 @125 - unztell64 @126 - unzGetFilePos64 @127 - unzGoToFilePos64 @128 - - zipOpen64 @130 - zipOpen2_64 @131 - zipOpenNewFileInZip64 @132 - zipOpenNewFileInZip2_64 @133 - zipOpenNewFileInZip3_64 @134 - zipOpenNewFileInZip4_64 @135 - zipCloseFileInZipRaw64 @136 - -; zlib1 v1.2.4 added: - adler32_combine @140 - crc32_combine @142 - deflateSetHeader @144 - deflateTune @145 - gzbuffer @146 - gzclose_r @147 - gzclose_w @148 - gzdirect @149 - gzoffset @150 - inflateGetHeader @156 - inflateMark @157 - inflatePrime @158 - inflateReset2 @159 - inflateUndermine @160 - -; zlib1 v1.2.6 added: - gzgetc_ @161 - inflateResetKeep @163 - deflateResetKeep @164 - -; zlib1 v1.2.7 added: - gzopen_w @165 - -; zlib1 v1.2.8 added: - inflateGetDictionary @166 - gzvprintf @167 - -; zlib1 v1.2.9 added: - inflateCodesUsed @168 - inflateValidate @169 - uncompress2 @170 - gzfread @171 - gzfwrite @172 - deflateGetDictionary @173 - adler32_z @174 - crc32_z @175 - -; zlib1 v1.2.12 added: - crc32_combine_gen @176 - crc32_combine_gen64 @177 - crc32_combine_op @178 diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc11/zlibvc.sln b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc11/zlibvc.sln deleted file mode 100644 index b7e3812..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc11/zlibvc.sln +++ /dev/null @@ -1,117 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibvc", "zlibvc.vcxproj", "{8FD826F8-3739-44E6-8CC8-997122E53B8D}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibstat", "zlibstat.vcxproj", "{745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlib", "testzlib.vcxproj", "{AA6666AA-E09F-4135-9C0C-4FE50C3C654B}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlibdll", "testzlibdll.vcxproj", "{C52F9E7B-498A-42BE-8DB4-85A15694366A}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minizip", "minizip.vcxproj", "{48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniunz", "miniunz.vcxproj", "{C52F9E7B-498A-42BE-8DB4-85A15694382A}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Itanium = Debug|Itanium - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Itanium = Release|Itanium - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - ReleaseWithoutAsm|Itanium = ReleaseWithoutAsm|Itanium - ReleaseWithoutAsm|Win32 = ReleaseWithoutAsm|Win32 - ReleaseWithoutAsm|x64 = ReleaseWithoutAsm|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Itanium.ActiveCfg = Debug|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.ActiveCfg = Debug|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.Build.0 = Debug|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.ActiveCfg = Debug|x64 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.Build.0 = Debug|x64 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Itanium.ActiveCfg = Release|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.ActiveCfg = Release|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.Build.0 = Release|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.ActiveCfg = Release|x64 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.Build.0 = Release|x64 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Itanium.ActiveCfg = Debug|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.ActiveCfg = Debug|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.Build.0 = Debug|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.ActiveCfg = Debug|x64 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.Build.0 = Debug|x64 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Itanium.ActiveCfg = Release|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.ActiveCfg = Release|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.Build.0 = Release|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.ActiveCfg = Release|x64 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.Build.0 = Release|x64 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Itanium.ActiveCfg = Debug|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.ActiveCfg = Debug|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.Build.0 = Debug|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.ActiveCfg = Debug|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.Build.0 = Debug|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Itanium.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.Build.0 = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.ActiveCfg = Release|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.Build.0 = Release|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Itanium.ActiveCfg = Debug|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.ActiveCfg = Debug|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.Build.0 = Debug|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.ActiveCfg = Debug|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.Build.0 = Debug|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Itanium.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.Build.0 = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.ActiveCfg = Release|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.Build.0 = Release|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc11/zlibvc.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc11/zlibvc.vcxproj deleted file mode 100644 index c4cffcc..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc11/zlibvc.vcxproj +++ /dev/null @@ -1,688 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Win32 - - - Debug - x64 - - - ReleaseWithoutAsm - Itanium - - - ReleaseWithoutAsm - Win32 - - - ReleaseWithoutAsm - x64 - - - Release - Itanium - - - Release - Win32 - - - Release - x64 - - - - {8FD826F8-3739-44E6-8CC8-997122E53B8D} - - - - DynamicLibrary - false - true - v110 - - - DynamicLibrary - false - true - v110 - - - DynamicLibrary - false - v110 - Unicode - - - DynamicLibrary - false - true - - - DynamicLibrary - false - true - - - DynamicLibrary - false - - - DynamicLibrary - false - true - v110 - - - DynamicLibrary - false - true - v110 - - - DynamicLibrary - false - v110 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30128.1 - x86\ZlibDll$(Configuration)\ - x86\ZlibDll$(Configuration)\Tmp\ - true - false - x86\ZlibDll$(Configuration)\ - x86\ZlibDll$(Configuration)\Tmp\ - false - false - x86\ZlibDll$(Configuration)\ - x86\ZlibDll$(Configuration)\Tmp\ - false - false - x64\ZlibDll$(Configuration)\ - x64\ZlibDll$(Configuration)\Tmp\ - true - false - ia64\ZlibDll$(Configuration)\ - ia64\ZlibDll$(Configuration)\Tmp\ - true - false - x64\ZlibDll$(Configuration)\ - x64\ZlibDll$(Configuration)\Tmp\ - false - false - ia64\ZlibDll$(Configuration)\ - ia64\ZlibDll$(Configuration)\Tmp\ - false - false - x64\ZlibDll$(Configuration)\ - x64\ZlibDll$(Configuration)\Tmp\ - false - false - ia64\ZlibDll$(Configuration)\ - ia64\ZlibDll$(Configuration)\Tmp\ - false - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - zlibwapi - zlibwapi - zlibwapi - zlibwapi - zlibwapi - zlibwapi - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - Win32 - $(OutDir)zlibvc.tlb - - - Disabled - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;%(PreprocessorDefinitions) - - - MultiThreadedDebugDLL - false - $(IntDir)zlibvc.pch - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x040c - - - /MACHINE:I386 %(AdditionalOptions) - ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) - $(OutDir)zlibwapi.dll - true - .\zlibvc.def - true - $(OutDir)zlibwapi.pdb - true - $(OutDir)zlibwapi.map - Windows - false - - - $(OutDir)zlibwapi.lib - - - cd ..\..\masmx86 -bld_ml32.bat - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - Win32 - $(OutDir)zlibvc.tlb - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibvc.pch - All - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x040c - - - /MACHINE:I386 %(AdditionalOptions) - $(OutDir)zlibwapi.dll - true - false - .\zlibvc.def - $(OutDir)zlibwapi.pdb - true - $(OutDir)zlibwapi.map - Windows - false - - - $(OutDir)zlibwapi.lib - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - Win32 - $(OutDir)zlibvc.tlb - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;%(PreprocessorDefinitions) - true - - - MultiThreaded - false - true - $(IntDir)zlibvc.pch - All - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x040c - - - /MACHINE:I386 %(AdditionalOptions) - ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) - $(OutDir)zlibwapi.dll - true - false - .\zlibvc.def - $(OutDir)zlibwapi.pdb - true - $(OutDir)zlibwapi.map - Windows - false - - - $(OutDir)zlibwapi.lib - - - cd ..\..\masmx86 -bld_ml32.bat - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - X64 - $(OutDir)zlibvc.tlb - - - Disabled - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) - - - MultiThreadedDebugDLL - false - $(IntDir)zlibvc.pch - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x040c - - - ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) - $(OutDir)zlibwapi.dll - true - .\zlibvc.def - true - $(OutDir)zlibwapi.pdb - true - $(OutDir)zlibwapi.map - Windows - $(OutDir)zlibwapi.lib - MachineX64 - - - cd ..\..\contrib\masmx64 -bld_ml64.bat - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - Itanium - $(OutDir)zlibvc.tlb - - - Disabled - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) - - - MultiThreadedDebugDLL - false - $(IntDir)zlibvc.pch - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x040c - - - $(OutDir)zlibwapi.dll - true - .\zlibvc.def - true - $(OutDir)zlibwapi.pdb - true - $(OutDir)zlibwapi.map - Windows - $(OutDir)zlibwapi.lib - MachineIA64 - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - X64 - $(OutDir)zlibvc.tlb - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibvc.pch - All - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x040c - - - $(OutDir)zlibwapi.dll - true - false - .\zlibvc.def - $(OutDir)zlibwapi.pdb - true - $(OutDir)zlibwapi.map - Windows - $(OutDir)zlibwapi.lib - MachineX64 - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - Itanium - $(OutDir)zlibvc.tlb - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibvc.pch - All - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x040c - - - $(OutDir)zlibwapi.dll - true - false - .\zlibvc.def - $(OutDir)zlibwapi.pdb - true - $(OutDir)zlibwapi.map - Windows - $(OutDir)zlibwapi.lib - MachineIA64 - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - X64 - $(OutDir)zlibvc.tlb - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibvc.pch - All - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x040c - - - ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) - $(OutDir)zlibwapi.dll - true - false - .\zlibvc.def - $(OutDir)zlibwapi.pdb - true - $(OutDir)zlibwapi.map - Windows - $(OutDir)zlibwapi.lib - MachineX64 - - - cd ..\..\masmx64 -bld_ml64.bat - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - Itanium - $(OutDir)zlibvc.tlb - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibvc.pch - All - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x040c - - - $(OutDir)zlibwapi.dll - true - false - .\zlibvc.def - $(OutDir)zlibwapi.pdb - true - $(OutDir)zlibwapi.map - Windows - $(OutDir)zlibwapi.lib - MachineIA64 - - - - - - - - - - - - - - true - true - true - true - true - true - - - - - - - - - - %(AdditionalIncludeDirectories) - ZLIB_INTERNAL;%(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - ZLIB_INTERNAL;%(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - ZLIB_INTERNAL;%(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - ZLIB_INTERNAL;%(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - ZLIB_INTERNAL;%(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - ZLIB_INTERNAL;%(PreprocessorDefinitions) - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc12/miniunz.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc12/miniunz.vcxproj deleted file mode 100644 index d88ac7f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc12/miniunz.vcxproj +++ /dev/null @@ -1,316 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Win32 - - - Debug - x64 - - - Release - Itanium - - - Release - Win32 - - - Release - x64 - - - - {C52F9E7B-498A-42BE-8DB4-85A15694382A} - Win32Proj - - - - Application - MultiByte - v120 - - - Application - Unicode - v120 - - - Application - MultiByte - v120 - - - Application - MultiByte - v120 - - - Application - MultiByte - v120 - - - Application - MultiByte - v120 - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30128.1 - x86\MiniUnzip$(Configuration)\ - x86\MiniUnzip$(Configuration)\Tmp\ - true - false - x86\MiniUnzip$(Configuration)\ - x86\MiniUnzip$(Configuration)\Tmp\ - false - false - x64\MiniUnzip$(Configuration)\ - x64\MiniUnzip$(Configuration)\Tmp\ - true - false - ia64\MiniUnzip$(Configuration)\ - ia64\MiniUnzip$(Configuration)\Tmp\ - true - false - x64\MiniUnzip$(Configuration)\ - x64\MiniUnzip$(Configuration)\Tmp\ - false - false - ia64\MiniUnzip$(Configuration)\ - ia64\MiniUnzip$(Configuration)\Tmp\ - false - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)miniunz.exe - true - $(OutDir)miniunz.pdb - Console - false - - - MachineX86 - - - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - Default - MultiThreaded - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)miniunz.exe - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)miniunz.exe - true - $(OutDir)miniunz.pdb - Console - MachineX64 - - - - - Itanium - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)miniunz.exe - true - $(OutDir)miniunz.pdb - Console - MachineIA64 - - - - - X64 - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)miniunz.exe - true - Console - true - true - MachineX64 - - - - - Itanium - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)miniunz.exe - true - Console - true - true - MachineIA64 - - - - - - - - {8fd826f8-3739-44e6-8cc8-997122e53b8d} - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc12/minizip.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc12/minizip.vcxproj deleted file mode 100644 index f1f239c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc12/minizip.vcxproj +++ /dev/null @@ -1,313 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Win32 - - - Debug - x64 - - - Release - Itanium - - - Release - Win32 - - - Release - x64 - - - - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B} - Win32Proj - - - - Application - MultiByte - v120 - - - Application - Unicode - v120 - - - Application - MultiByte - v120 - - - Application - MultiByte - v120 - - - Application - MultiByte - v120 - - - Application - MultiByte - v120 - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30128.1 - x86\MiniZip$(Configuration)\ - x86\MiniZip$(Configuration)\Tmp\ - true - false - x86\MiniZip$(Configuration)\ - x86\MiniZip$(Configuration)\Tmp\ - false - x64\$(Configuration)\ - x64\$(Configuration)\ - true - false - ia64\$(Configuration)\ - ia64\$(Configuration)\ - true - false - x64\$(Configuration)\ - x64\$(Configuration)\ - false - ia64\$(Configuration)\ - ia64\$(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)minizip.exe - true - $(OutDir)minizip.pdb - Console - false - - - MachineX86 - - - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - Default - MultiThreaded - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)minizip.exe - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)minizip.exe - true - $(OutDir)minizip.pdb - Console - MachineX64 - - - - - Itanium - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)minizip.exe - true - $(OutDir)minizip.pdb - Console - MachineIA64 - - - - - X64 - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)minizip.exe - true - Console - true - true - MachineX64 - - - - - Itanium - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)minizip.exe - true - Console - true - true - MachineIA64 - - - - - - - - {8fd826f8-3739-44e6-8cc8-997122e53b8d} - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc12/testzlib.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc12/testzlib.vcxproj deleted file mode 100644 index 64b2cbe..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc12/testzlib.vcxproj +++ /dev/null @@ -1,430 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Win32 - - - Debug - x64 - - - ReleaseWithoutAsm - Itanium - - - ReleaseWithoutAsm - Win32 - - - ReleaseWithoutAsm - x64 - - - Release - Itanium - - - Release - Win32 - - - Release - x64 - - - - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B} - testzlib - Win32Proj - - - - Application - MultiByte - true - v120 - - - Application - MultiByte - true - v120 - - - Application - Unicode - v120 - - - Application - MultiByte - true - v120 - - - Application - MultiByte - true - v120 - - - Application - MultiByte - v120 - - - Application - true - v120 - - - Application - true - v120 - - - Application - v120 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30128.1 - x86\TestZlib$(Configuration)\ - x86\TestZlib$(Configuration)\Tmp\ - true - false - x86\TestZlib$(Configuration)\ - x86\TestZlib$(Configuration)\Tmp\ - false - false - x86\TestZlib$(Configuration)\ - x86\TestZlib$(Configuration)\Tmp\ - false - false - x64\TestZlib$(Configuration)\ - x64\TestZlib$(Configuration)\Tmp\ - false - ia64\TestZlib$(Configuration)\ - ia64\TestZlib$(Configuration)\Tmp\ - true - false - x64\TestZlib$(Configuration)\ - x64\TestZlib$(Configuration)\Tmp\ - false - ia64\TestZlib$(Configuration)\ - ia64\TestZlib$(Configuration)\Tmp\ - false - false - x64\TestZlib$(Configuration)\ - x64\TestZlib$(Configuration)\Tmp\ - false - ia64\TestZlib$(Configuration)\ - ia64\TestZlib$(Configuration)\Tmp\ - false - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - ..\..\..;%(AdditionalIncludeDirectories) - ASMV;ASMINF;WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - AssemblyAndSourceCode - $(IntDir) - Level3 - ProgramDatabase - - - ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) - $(OutDir)testzlib.exe - true - $(OutDir)testzlib.pdb - Console - false - - - MachineX86 - - - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;%(AdditionalIncludeDirectories) - WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - true - Default - MultiThreaded - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - $(OutDir)testzlib.exe - true - Console - true - true - false - - - MachineX86 - - - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;%(AdditionalIncludeDirectories) - ASMV;ASMINF;WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - true - Default - MultiThreaded - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) - $(OutDir)testzlib.exe - true - Console - true - true - false - - - MachineX86 - false - - - - - ..\..\..;%(AdditionalIncludeDirectories) - ASMV;ASMINF;WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - Default - MultiThreadedDebugDLL - false - $(IntDir) - - - ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) - - - - - Itanium - - - Disabled - ..\..\..;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - AssemblyAndSourceCode - $(IntDir) - Level3 - ProgramDatabase - - - $(OutDir)testzlib.exe - true - $(OutDir)testzlib.pdb - Console - MachineIA64 - - - - - ..\..\..;%(AdditionalIncludeDirectories) - WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - Default - MultiThreadedDLL - false - $(IntDir) - - - %(AdditionalDependencies) - - - - - Itanium - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - $(OutDir)testzlib.exe - true - Console - true - true - MachineIA64 - - - - - ..\..\..;%(AdditionalIncludeDirectories) - ASMV;ASMINF;WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - Default - MultiThreadedDLL - false - $(IntDir) - - - ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) - - - - - Itanium - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - $(OutDir)testzlib.exe - true - Console - true - true - MachineIA64 - - - - - - - - - - true - true - true - true - true - true - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc12/testzlibdll.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc12/testzlibdll.vcxproj deleted file mode 100644 index c66573a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc12/testzlibdll.vcxproj +++ /dev/null @@ -1,316 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Win32 - - - Debug - x64 - - - Release - Itanium - - - Release - Win32 - - - Release - x64 - - - - {C52F9E7B-498A-42BE-8DB4-85A15694366A} - Win32Proj - - - - Application - MultiByte - v120 - - - Application - Unicode - v120 - - - Application - MultiByte - v120 - - - Application - MultiByte - v120 - - - Application - MultiByte - v120 - - - Application - MultiByte - v120 - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30128.1 - x86\TestZlibDll$(Configuration)\ - x86\TestZlibDll$(Configuration)\Tmp\ - true - false - x86\TestZlibDll$(Configuration)\ - x86\TestZlibDll$(Configuration)\Tmp\ - false - false - x64\TestZlibDll$(Configuration)\ - x64\TestZlibDll$(Configuration)\Tmp\ - true - false - ia64\TestZlibDll$(Configuration)\ - ia64\TestZlibDll$(Configuration)\Tmp\ - true - false - x64\TestZlibDll$(Configuration)\ - x64\TestZlibDll$(Configuration)\Tmp\ - false - false - ia64\TestZlibDll$(Configuration)\ - ia64\TestZlibDll$(Configuration)\Tmp\ - false - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)testzlibdll.exe - true - $(OutDir)testzlib.pdb - Console - false - - - MachineX86 - - - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - Default - MultiThreaded - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)testzlibdll.exe - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)testzlibdll.exe - true - $(OutDir)testzlib.pdb - Console - MachineX64 - - - - - Itanium - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)testzlibdll.exe - true - $(OutDir)testzlib.pdb - Console - MachineIA64 - - - - - X64 - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)testzlibdll.exe - true - Console - true - true - MachineX64 - - - - - Itanium - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)testzlibdll.exe - true - Console - true - true - MachineIA64 - - - - - - - - {8fd826f8-3739-44e6-8cc8-997122e53b8d} - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc12/zlib.rc b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc12/zlib.rc deleted file mode 100644 index 9475873..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc12/zlib.rc +++ /dev/null @@ -1,32 +0,0 @@ -#include - -#define IDR_VERSION1 1 -IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE - FILEVERSION 1, 2, 12, 0 - PRODUCTVERSION 1, 2, 12, 0 - FILEFLAGSMASK VS_FFI_FILEFLAGSMASK - FILEFLAGS 0 - FILEOS VOS_DOS_WINDOWS32 - FILETYPE VFT_DLL - FILESUBTYPE 0 // not used -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904E4" - //language ID = U.S. English, char set = Windows, Multilingual - - BEGIN - VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" - VALUE "FileVersion", "1.2.12\0" - VALUE "InternalName", "zlib\0" - VALUE "OriginalFilename", "zlibwapi.dll\0" - VALUE "ProductName", "ZLib.DLL\0" - VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" - VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0409, 1252 - END -END diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc12/zlibstat.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc12/zlibstat.vcxproj deleted file mode 100644 index 3fdee7c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc12/zlibstat.vcxproj +++ /dev/null @@ -1,467 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Win32 - - - Debug - x64 - - - ReleaseWithoutAsm - Itanium - - - ReleaseWithoutAsm - Win32 - - - ReleaseWithoutAsm - x64 - - - Release - Itanium - - - Release - Win32 - - - Release - x64 - - - - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8} - - - - StaticLibrary - false - v120 - - - StaticLibrary - false - v120 - - - StaticLibrary - false - v120 - Unicode - - - StaticLibrary - false - v120 - - - StaticLibrary - false - v120 - - - StaticLibrary - false - v120 - - - StaticLibrary - false - v120 - - - StaticLibrary - false - v120 - - - StaticLibrary - false - v120 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30128.1 - x86\ZlibStat$(Configuration)\ - x86\ZlibStat$(Configuration)\Tmp\ - x86\ZlibStat$(Configuration)\ - x86\ZlibStat$(Configuration)\Tmp\ - x86\ZlibStat$(Configuration)\ - x86\ZlibStat$(Configuration)\Tmp\ - x64\ZlibStat$(Configuration)\ - x64\ZlibStat$(Configuration)\Tmp\ - ia64\ZlibStat$(Configuration)\ - ia64\ZlibStat$(Configuration)\Tmp\ - x64\ZlibStat$(Configuration)\ - x64\ZlibStat$(Configuration)\Tmp\ - ia64\ZlibStat$(Configuration)\ - ia64\ZlibStat$(Configuration)\Tmp\ - x64\ZlibStat$(Configuration)\ - x64\ZlibStat$(Configuration)\Tmp\ - ia64\ZlibStat$(Configuration)\ - ia64\ZlibStat$(Configuration)\Tmp\ - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - - - MultiThreadedDebugDLL - false - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - OldStyle - - - 0x040c - - - /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) - $(OutDir)zlibstat.lib - true - - - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ASMV;ASMINF;%(PreprocessorDefinitions) - true - - - MultiThreaded - false - true - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - - - 0x040c - - - /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) - ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) - $(OutDir)zlibstat.lib - true - - - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - true - - - MultiThreaded - false - true - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - - - 0x040c - - - /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) - $(OutDir)zlibstat.lib - true - - - - - X64 - - - Disabled - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - - - MultiThreadedDebugDLL - false - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - OldStyle - - - 0x040c - - - /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) - $(OutDir)zlibstat.lib - true - - - - - Itanium - - - Disabled - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - - - MultiThreadedDebugDLL - false - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - OldStyle - - - 0x040c - - - /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) - $(OutDir)zlibstat.lib - true - - - - - X64 - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - - - 0x040c - - - /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) - ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) - $(OutDir)zlibstat.lib - true - - - - - Itanium - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - - - 0x040c - - - /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) - $(OutDir)zlibstat.lib - true - - - - - X64 - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - - - 0x040c - - - /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) - $(OutDir)zlibstat.lib - true - - - - - Itanium - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - - - 0x040c - - - /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) - $(OutDir)zlibstat.lib - true - - - - - - - - - - - - - - true - true - true - true - true - true - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc12/zlibvc.def b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc12/zlibvc.def deleted file mode 100644 index 99c71e3..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc12/zlibvc.def +++ /dev/null @@ -1,158 +0,0 @@ -LIBRARY -; zlib data compression and ZIP file I/O library - -VERSION 1.2 - -EXPORTS - adler32 @1 - compress @2 - crc32 @3 - deflate @4 - deflateCopy @5 - deflateEnd @6 - deflateInit2_ @7 - deflateInit_ @8 - deflateParams @9 - deflateReset @10 - deflateSetDictionary @11 - gzclose @12 - gzdopen @13 - gzerror @14 - gzflush @15 - gzopen @16 - gzread @17 - gzwrite @18 - inflate @19 - inflateEnd @20 - inflateInit2_ @21 - inflateInit_ @22 - inflateReset @23 - inflateSetDictionary @24 - inflateSync @25 - uncompress @26 - zlibVersion @27 - gzprintf @28 - gzputc @29 - gzgetc @30 - gzseek @31 - gzrewind @32 - gztell @33 - gzeof @34 - gzsetparams @35 - zError @36 - inflateSyncPoint @37 - get_crc_table @38 - compress2 @39 - gzputs @40 - gzgets @41 - inflateCopy @42 - inflateBackInit_ @43 - inflateBack @44 - inflateBackEnd @45 - compressBound @46 - deflateBound @47 - gzclearerr @48 - gzungetc @49 - zlibCompileFlags @50 - deflatePrime @51 - deflatePending @52 - - unzOpen @61 - unzClose @62 - unzGetGlobalInfo @63 - unzGetCurrentFileInfo @64 - unzGoToFirstFile @65 - unzGoToNextFile @66 - unzOpenCurrentFile @67 - unzReadCurrentFile @68 - unzOpenCurrentFile3 @69 - unztell @70 - unzeof @71 - unzCloseCurrentFile @72 - unzGetGlobalComment @73 - unzStringFileNameCompare @74 - unzLocateFile @75 - unzGetLocalExtrafield @76 - unzOpen2 @77 - unzOpenCurrentFile2 @78 - unzOpenCurrentFilePassword @79 - - zipOpen @80 - zipOpenNewFileInZip @81 - zipWriteInFileInZip @82 - zipCloseFileInZip @83 - zipClose @84 - zipOpenNewFileInZip2 @86 - zipCloseFileInZipRaw @87 - zipOpen2 @88 - zipOpenNewFileInZip3 @89 - - unzGetFilePos @100 - unzGoToFilePos @101 - - fill_win32_filefunc @110 - -; zlibwapi v1.2.4 added: - fill_win32_filefunc64 @111 - fill_win32_filefunc64A @112 - fill_win32_filefunc64W @113 - - unzOpen64 @120 - unzOpen2_64 @121 - unzGetGlobalInfo64 @122 - unzGetCurrentFileInfo64 @124 - unzGetCurrentFileZStreamPos64 @125 - unztell64 @126 - unzGetFilePos64 @127 - unzGoToFilePos64 @128 - - zipOpen64 @130 - zipOpen2_64 @131 - zipOpenNewFileInZip64 @132 - zipOpenNewFileInZip2_64 @133 - zipOpenNewFileInZip3_64 @134 - zipOpenNewFileInZip4_64 @135 - zipCloseFileInZipRaw64 @136 - -; zlib1 v1.2.4 added: - adler32_combine @140 - crc32_combine @142 - deflateSetHeader @144 - deflateTune @145 - gzbuffer @146 - gzclose_r @147 - gzclose_w @148 - gzdirect @149 - gzoffset @150 - inflateGetHeader @156 - inflateMark @157 - inflatePrime @158 - inflateReset2 @159 - inflateUndermine @160 - -; zlib1 v1.2.6 added: - gzgetc_ @161 - inflateResetKeep @163 - deflateResetKeep @164 - -; zlib1 v1.2.7 added: - gzopen_w @165 - -; zlib1 v1.2.8 added: - inflateGetDictionary @166 - gzvprintf @167 - -; zlib1 v1.2.9 added: - inflateCodesUsed @168 - inflateValidate @169 - uncompress2 @170 - gzfread @171 - gzfwrite @172 - deflateGetDictionary @173 - adler32_z @174 - crc32_z @175 - -; zlib1 v1.2.12 added: - crc32_combine_gen @176 - crc32_combine_gen64 @177 - crc32_combine_op @178 diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc12/zlibvc.sln b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc12/zlibvc.sln deleted file mode 100644 index dcda229..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc12/zlibvc.sln +++ /dev/null @@ -1,119 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.40629.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibvc", "zlibvc.vcxproj", "{8FD826F8-3739-44E6-8CC8-997122E53B8D}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibstat", "zlibstat.vcxproj", "{745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlib", "testzlib.vcxproj", "{AA6666AA-E09F-4135-9C0C-4FE50C3C654B}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlibdll", "testzlibdll.vcxproj", "{C52F9E7B-498A-42BE-8DB4-85A15694366A}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minizip", "minizip.vcxproj", "{48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniunz", "miniunz.vcxproj", "{C52F9E7B-498A-42BE-8DB4-85A15694382A}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Itanium = Debug|Itanium - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Itanium = Release|Itanium - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - ReleaseWithoutAsm|Itanium = ReleaseWithoutAsm|Itanium - ReleaseWithoutAsm|Win32 = ReleaseWithoutAsm|Win32 - ReleaseWithoutAsm|x64 = ReleaseWithoutAsm|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Itanium.ActiveCfg = Debug|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.ActiveCfg = Debug|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.Build.0 = Debug|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.ActiveCfg = Debug|x64 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.Build.0 = Debug|x64 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Itanium.ActiveCfg = Release|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.ActiveCfg = Release|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.Build.0 = Release|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.ActiveCfg = Release|x64 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.Build.0 = Release|x64 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Itanium.ActiveCfg = Debug|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.ActiveCfg = Debug|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.Build.0 = Debug|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.ActiveCfg = Debug|x64 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.Build.0 = Debug|x64 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Itanium.ActiveCfg = Release|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.ActiveCfg = Release|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.Build.0 = Release|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.ActiveCfg = Release|x64 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.Build.0 = Release|x64 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Itanium.ActiveCfg = Debug|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.ActiveCfg = Debug|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.Build.0 = Debug|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.ActiveCfg = Debug|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.Build.0 = Debug|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Itanium.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.Build.0 = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.ActiveCfg = Release|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.Build.0 = Release|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Itanium.ActiveCfg = Debug|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.ActiveCfg = Debug|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.Build.0 = Debug|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.ActiveCfg = Debug|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.Build.0 = Debug|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Itanium.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.Build.0 = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.ActiveCfg = Release|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.Build.0 = Release|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc12/zlibvc.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc12/zlibvc.vcxproj deleted file mode 100644 index ab2b6c3..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc12/zlibvc.vcxproj +++ /dev/null @@ -1,692 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Win32 - - - Debug - x64 - - - ReleaseWithoutAsm - Itanium - - - ReleaseWithoutAsm - Win32 - - - ReleaseWithoutAsm - x64 - - - Release - Itanium - - - Release - Win32 - - - Release - x64 - - - - {8FD826F8-3739-44E6-8CC8-997122E53B8D} - - - - DynamicLibrary - false - true - v120 - - - DynamicLibrary - false - true - v120 - - - DynamicLibrary - false - v120 - Unicode - - - DynamicLibrary - false - true - v120 - - - DynamicLibrary - false - true - v120 - - - DynamicLibrary - false - v120 - - - DynamicLibrary - false - true - v120 - - - DynamicLibrary - false - true - v120 - - - DynamicLibrary - false - v120 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30128.1 - x86\ZlibDll$(Configuration)\ - x86\ZlibDll$(Configuration)\Tmp\ - true - false - x86\ZlibDll$(Configuration)\ - x86\ZlibDll$(Configuration)\Tmp\ - false - false - x86\ZlibDll$(Configuration)\ - x86\ZlibDll$(Configuration)\Tmp\ - false - false - x64\ZlibDll$(Configuration)\ - x64\ZlibDll$(Configuration)\Tmp\ - true - false - ia64\ZlibDll$(Configuration)\ - ia64\ZlibDll$(Configuration)\Tmp\ - true - false - x64\ZlibDll$(Configuration)\ - x64\ZlibDll$(Configuration)\Tmp\ - false - false - ia64\ZlibDll$(Configuration)\ - ia64\ZlibDll$(Configuration)\Tmp\ - false - false - x64\ZlibDll$(Configuration)\ - x64\ZlibDll$(Configuration)\Tmp\ - false - false - ia64\ZlibDll$(Configuration)\ - ia64\ZlibDll$(Configuration)\Tmp\ - false - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - zlibwapi - zlibwapi - zlibwapi - zlibwapi - zlibwapi - zlibwapi - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - Win32 - $(OutDir)zlibvc.tlb - - - Disabled - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;%(PreprocessorDefinitions) - - - MultiThreadedDebugDLL - false - $(IntDir)zlibvc.pch - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x040c - - - /MACHINE:I386 %(AdditionalOptions) - ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) - $(OutDir)zlibwapi.dll - true - .\zlibvc.def - true - $(OutDir)zlibwapi.pdb - true - $(OutDir)zlibwapi.map - Windows - false - - - $(OutDir)zlibwapi.lib - - - cd ..\..\masmx86 -bld_ml32.bat - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - Win32 - $(OutDir)zlibvc.tlb - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibvc.pch - All - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x040c - - - /MACHINE:I386 %(AdditionalOptions) - $(OutDir)zlibwapi.dll - true - false - .\zlibvc.def - $(OutDir)zlibwapi.pdb - true - $(OutDir)zlibwapi.map - Windows - false - - - $(OutDir)zlibwapi.lib - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - Win32 - $(OutDir)zlibvc.tlb - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;%(PreprocessorDefinitions) - true - - - MultiThreaded - false - true - $(IntDir)zlibvc.pch - All - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x040c - - - /MACHINE:I386 %(AdditionalOptions) - ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) - $(OutDir)zlibwapi.dll - true - false - .\zlibvc.def - $(OutDir)zlibwapi.pdb - true - $(OutDir)zlibwapi.map - Windows - false - - - $(OutDir)zlibwapi.lib - false - - - cd ..\..\masmx86 -bld_ml32.bat - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - X64 - $(OutDir)zlibvc.tlb - - - Disabled - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) - - - MultiThreadedDebugDLL - false - $(IntDir)zlibvc.pch - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x040c - - - ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) - $(OutDir)zlibwapi.dll - true - .\zlibvc.def - true - $(OutDir)zlibwapi.pdb - true - $(OutDir)zlibwapi.map - Windows - $(OutDir)zlibwapi.lib - MachineX64 - - - cd ..\..\contrib\masmx64 -bld_ml64.bat - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - Itanium - $(OutDir)zlibvc.tlb - - - Disabled - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) - - - MultiThreadedDebugDLL - false - $(IntDir)zlibvc.pch - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x040c - - - $(OutDir)zlibwapi.dll - true - .\zlibvc.def - true - $(OutDir)zlibwapi.pdb - true - $(OutDir)zlibwapi.map - Windows - $(OutDir)zlibwapi.lib - MachineIA64 - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - X64 - $(OutDir)zlibvc.tlb - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibvc.pch - All - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x040c - - - $(OutDir)zlibwapi.dll - true - false - .\zlibvc.def - $(OutDir)zlibwapi.pdb - true - $(OutDir)zlibwapi.map - Windows - $(OutDir)zlibwapi.lib - MachineX64 - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - Itanium - $(OutDir)zlibvc.tlb - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibvc.pch - All - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x040c - - - $(OutDir)zlibwapi.dll - true - false - .\zlibvc.def - $(OutDir)zlibwapi.pdb - true - $(OutDir)zlibwapi.map - Windows - $(OutDir)zlibwapi.lib - MachineIA64 - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - X64 - $(OutDir)zlibvc.tlb - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibvc.pch - All - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x040c - - - ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) - $(OutDir)zlibwapi.dll - true - false - .\zlibvc.def - $(OutDir)zlibwapi.pdb - true - $(OutDir)zlibwapi.map - Windows - $(OutDir)zlibwapi.lib - MachineX64 - - - cd ..\..\masmx64 -bld_ml64.bat - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - Itanium - $(OutDir)zlibvc.tlb - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibvc.pch - All - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x040c - - - $(OutDir)zlibwapi.dll - true - false - .\zlibvc.def - $(OutDir)zlibwapi.pdb - true - $(OutDir)zlibwapi.map - Windows - $(OutDir)zlibwapi.lib - MachineIA64 - - - - - - - - - - - - - - true - true - true - true - true - true - - - - - - - - - - %(AdditionalIncludeDirectories) - ZLIB_INTERNAL;%(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - ZLIB_INTERNAL;%(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - ZLIB_INTERNAL;%(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - ZLIB_INTERNAL;%(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - ZLIB_INTERNAL;%(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - ZLIB_INTERNAL;%(PreprocessorDefinitions) - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc14/miniunz.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc14/miniunz.vcxproj deleted file mode 100644 index 9b5c075..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc14/miniunz.vcxproj +++ /dev/null @@ -1,316 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Win32 - - - Debug - x64 - - - Release - Itanium - - - Release - Win32 - - - Release - x64 - - - - {C52F9E7B-498A-42BE-8DB4-85A15694382A} - Win32Proj - - - - Application - MultiByte - v140 - - - Application - Unicode - v140 - - - Application - MultiByte - v140 - - - Application - MultiByte - v140 - - - Application - MultiByte - v140 - - - Application - MultiByte - v140 - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30128.1 - x86\MiniUnzip$(Configuration)\ - x86\MiniUnzip$(Configuration)\Tmp\ - true - false - x86\MiniUnzip$(Configuration)\ - x86\MiniUnzip$(Configuration)\Tmp\ - false - false - x64\MiniUnzip$(Configuration)\ - x64\MiniUnzip$(Configuration)\Tmp\ - true - false - ia64\MiniUnzip$(Configuration)\ - ia64\MiniUnzip$(Configuration)\Tmp\ - true - false - x64\MiniUnzip$(Configuration)\ - x64\MiniUnzip$(Configuration)\Tmp\ - false - false - ia64\MiniUnzip$(Configuration)\ - ia64\MiniUnzip$(Configuration)\Tmp\ - false - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)miniunz.exe - true - $(OutDir)miniunz.pdb - Console - false - - - MachineX86 - - - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - Default - MultiThreaded - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)miniunz.exe - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)miniunz.exe - true - $(OutDir)miniunz.pdb - Console - MachineX64 - - - - - Itanium - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)miniunz.exe - true - $(OutDir)miniunz.pdb - Console - MachineIA64 - - - - - X64 - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)miniunz.exe - true - Console - true - true - MachineX64 - - - - - Itanium - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)miniunz.exe - true - Console - true - true - MachineIA64 - - - - - - - - {8fd826f8-3739-44e6-8cc8-997122e53b8d} - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc14/minizip.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc14/minizip.vcxproj deleted file mode 100644 index 968a410..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc14/minizip.vcxproj +++ /dev/null @@ -1,313 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Win32 - - - Debug - x64 - - - Release - Itanium - - - Release - Win32 - - - Release - x64 - - - - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B} - Win32Proj - - - - Application - MultiByte - v140 - - - Application - Unicode - v140 - - - Application - MultiByte - v140 - - - Application - MultiByte - v140 - - - Application - MultiByte - v140 - - - Application - MultiByte - v140 - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30128.1 - x86\MiniZip$(Configuration)\ - x86\MiniZip$(Configuration)\Tmp\ - true - false - x86\MiniZip$(Configuration)\ - x86\MiniZip$(Configuration)\Tmp\ - false - x64\$(Configuration)\ - x64\$(Configuration)\ - true - false - ia64\$(Configuration)\ - ia64\$(Configuration)\ - true - false - x64\$(Configuration)\ - x64\$(Configuration)\ - false - ia64\$(Configuration)\ - ia64\$(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)minizip.exe - true - $(OutDir)minizip.pdb - Console - false - - - MachineX86 - - - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - Default - MultiThreaded - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)minizip.exe - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)minizip.exe - true - $(OutDir)minizip.pdb - Console - MachineX64 - - - - - Itanium - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)minizip.exe - true - $(OutDir)minizip.pdb - Console - MachineIA64 - - - - - X64 - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)minizip.exe - true - Console - true - true - MachineX64 - - - - - Itanium - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)minizip.exe - true - Console - true - true - MachineIA64 - - - - - - - - {8fd826f8-3739-44e6-8cc8-997122e53b8d} - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc14/testzlib.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc14/testzlib.vcxproj deleted file mode 100644 index 2c37125..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc14/testzlib.vcxproj +++ /dev/null @@ -1,430 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Win32 - - - Debug - x64 - - - ReleaseWithoutAsm - Itanium - - - ReleaseWithoutAsm - Win32 - - - ReleaseWithoutAsm - x64 - - - Release - Itanium - - - Release - Win32 - - - Release - x64 - - - - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B} - testzlib - Win32Proj - - - - Application - MultiByte - true - v140 - - - Application - MultiByte - true - v140 - - - Application - Unicode - v140 - - - Application - MultiByte - true - v140 - - - Application - MultiByte - true - v140 - - - Application - MultiByte - v140 - - - Application - true - v140 - - - Application - true - v140 - - - Application - v140 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30128.1 - x86\TestZlib$(Configuration)\ - x86\TestZlib$(Configuration)\Tmp\ - true - false - x86\TestZlib$(Configuration)\ - x86\TestZlib$(Configuration)\Tmp\ - false - false - x86\TestZlib$(Configuration)\ - x86\TestZlib$(Configuration)\Tmp\ - false - false - x64\TestZlib$(Configuration)\ - x64\TestZlib$(Configuration)\Tmp\ - false - ia64\TestZlib$(Configuration)\ - ia64\TestZlib$(Configuration)\Tmp\ - true - false - x64\TestZlib$(Configuration)\ - x64\TestZlib$(Configuration)\Tmp\ - false - ia64\TestZlib$(Configuration)\ - ia64\TestZlib$(Configuration)\Tmp\ - false - false - x64\TestZlib$(Configuration)\ - x64\TestZlib$(Configuration)\Tmp\ - false - ia64\TestZlib$(Configuration)\ - ia64\TestZlib$(Configuration)\Tmp\ - false - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - ..\..\..;%(AdditionalIncludeDirectories) - ASMV;ASMINF;WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - AssemblyAndSourceCode - $(IntDir) - Level3 - ProgramDatabase - - - ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) - $(OutDir)testzlib.exe - true - $(OutDir)testzlib.pdb - Console - false - - - MachineX86 - - - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;%(AdditionalIncludeDirectories) - WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - true - Default - MultiThreaded - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - $(OutDir)testzlib.exe - true - Console - true - true - false - - - MachineX86 - - - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;%(AdditionalIncludeDirectories) - ASMV;ASMINF;WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - true - Default - MultiThreaded - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) - $(OutDir)testzlib.exe - true - Console - true - true - false - - - MachineX86 - false - - - - - ..\..\..;%(AdditionalIncludeDirectories) - ASMV;ASMINF;WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - Default - MultiThreadedDebugDLL - false - $(IntDir) - - - ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) - - - - - Itanium - - - Disabled - ..\..\..;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - AssemblyAndSourceCode - $(IntDir) - Level3 - ProgramDatabase - - - $(OutDir)testzlib.exe - true - $(OutDir)testzlib.pdb - Console - MachineIA64 - - - - - ..\..\..;%(AdditionalIncludeDirectories) - WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - Default - MultiThreadedDLL - false - $(IntDir) - - - %(AdditionalDependencies) - - - - - Itanium - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - $(OutDir)testzlib.exe - true - Console - true - true - MachineIA64 - - - - - ..\..\..;%(AdditionalIncludeDirectories) - ASMV;ASMINF;WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - Default - MultiThreadedDLL - false - $(IntDir) - - - ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) - - - - - Itanium - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - $(OutDir)testzlib.exe - true - Console - true - true - MachineIA64 - - - - - - - - - - true - true - true - true - true - true - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc14/testzlibdll.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc14/testzlibdll.vcxproj deleted file mode 100644 index d87474d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc14/testzlibdll.vcxproj +++ /dev/null @@ -1,316 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Win32 - - - Debug - x64 - - - Release - Itanium - - - Release - Win32 - - - Release - x64 - - - - {C52F9E7B-498A-42BE-8DB4-85A15694366A} - Win32Proj - - - - Application - MultiByte - v140 - - - Application - Unicode - v140 - - - Application - MultiByte - v140 - - - Application - MultiByte - v140 - - - Application - MultiByte - v140 - - - Application - MultiByte - v140 - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30128.1 - x86\TestZlibDll$(Configuration)\ - x86\TestZlibDll$(Configuration)\Tmp\ - true - false - x86\TestZlibDll$(Configuration)\ - x86\TestZlibDll$(Configuration)\Tmp\ - false - false - x64\TestZlibDll$(Configuration)\ - x64\TestZlibDll$(Configuration)\Tmp\ - true - false - ia64\TestZlibDll$(Configuration)\ - ia64\TestZlibDll$(Configuration)\Tmp\ - true - false - x64\TestZlibDll$(Configuration)\ - x64\TestZlibDll$(Configuration)\Tmp\ - false - false - ia64\TestZlibDll$(Configuration)\ - ia64\TestZlibDll$(Configuration)\Tmp\ - false - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)testzlibdll.exe - true - $(OutDir)testzlib.pdb - Console - false - - - MachineX86 - - - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - Default - MultiThreaded - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)testzlibdll.exe - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)testzlibdll.exe - true - $(OutDir)testzlib.pdb - Console - MachineX64 - - - - - Itanium - - - Disabled - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDebugDLL - false - - - $(IntDir) - Level3 - ProgramDatabase - - - ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)testzlibdll.exe - true - $(OutDir)testzlib.pdb - Console - MachineIA64 - - - - - X64 - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)testzlibdll.exe - true - Console - true - true - MachineX64 - - - - - Itanium - - - MaxSpeed - OnlyExplicitInline - true - ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) - true - Default - MultiThreadedDLL - false - true - - - $(IntDir) - Level3 - ProgramDatabase - - - ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) - $(OutDir)testzlibdll.exe - true - Console - true - true - MachineIA64 - - - - - - - - {8fd826f8-3739-44e6-8cc8-997122e53b8d} - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc14/zlib.rc b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc14/zlib.rc deleted file mode 100644 index 9475873..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc14/zlib.rc +++ /dev/null @@ -1,32 +0,0 @@ -#include - -#define IDR_VERSION1 1 -IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE - FILEVERSION 1, 2, 12, 0 - PRODUCTVERSION 1, 2, 12, 0 - FILEFLAGSMASK VS_FFI_FILEFLAGSMASK - FILEFLAGS 0 - FILEOS VOS_DOS_WINDOWS32 - FILETYPE VFT_DLL - FILESUBTYPE 0 // not used -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904E4" - //language ID = U.S. English, char set = Windows, Multilingual - - BEGIN - VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" - VALUE "FileVersion", "1.2.12\0" - VALUE "InternalName", "zlib\0" - VALUE "OriginalFilename", "zlibwapi.dll\0" - VALUE "ProductName", "ZLib.DLL\0" - VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" - VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0409, 1252 - END -END diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc14/zlibstat.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc14/zlibstat.vcxproj deleted file mode 100644 index 3e4b986..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc14/zlibstat.vcxproj +++ /dev/null @@ -1,467 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Win32 - - - Debug - x64 - - - ReleaseWithoutAsm - Itanium - - - ReleaseWithoutAsm - Win32 - - - ReleaseWithoutAsm - x64 - - - Release - Itanium - - - Release - Win32 - - - Release - x64 - - - - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8} - - - - StaticLibrary - false - v140 - - - StaticLibrary - false - v140 - - - StaticLibrary - false - v140 - Unicode - - - StaticLibrary - false - v140 - - - StaticLibrary - false - v140 - - - StaticLibrary - false - v140 - - - StaticLibrary - false - v140 - - - StaticLibrary - false - v140 - - - StaticLibrary - false - v140 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30128.1 - x86\ZlibStat$(Configuration)\ - x86\ZlibStat$(Configuration)\Tmp\ - x86\ZlibStat$(Configuration)\ - x86\ZlibStat$(Configuration)\Tmp\ - x86\ZlibStat$(Configuration)\ - x86\ZlibStat$(Configuration)\Tmp\ - x64\ZlibStat$(Configuration)\ - x64\ZlibStat$(Configuration)\Tmp\ - ia64\ZlibStat$(Configuration)\ - ia64\ZlibStat$(Configuration)\Tmp\ - x64\ZlibStat$(Configuration)\ - x64\ZlibStat$(Configuration)\Tmp\ - ia64\ZlibStat$(Configuration)\ - ia64\ZlibStat$(Configuration)\Tmp\ - x64\ZlibStat$(Configuration)\ - x64\ZlibStat$(Configuration)\Tmp\ - ia64\ZlibStat$(Configuration)\ - ia64\ZlibStat$(Configuration)\Tmp\ - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - - - MultiThreadedDebugDLL - false - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - OldStyle - - - 0x040c - - - /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) - $(OutDir)zlibstat.lib - true - - - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ASMV;ASMINF;%(PreprocessorDefinitions) - true - - - MultiThreaded - false - true - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - - - 0x040c - - - /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) - ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) - $(OutDir)zlibstat.lib - true - - - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) - true - - - MultiThreaded - false - true - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - - - 0x040c - - - /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) - $(OutDir)zlibstat.lib - true - - - - - X64 - - - Disabled - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - - - MultiThreadedDebugDLL - false - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - OldStyle - - - 0x040c - - - /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) - $(OutDir)zlibstat.lib - true - - - - - Itanium - - - Disabled - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - - - MultiThreadedDebugDLL - false - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - OldStyle - - - 0x040c - - - /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) - $(OutDir)zlibstat.lib - true - - - - - X64 - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - - - 0x040c - - - /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) - ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) - $(OutDir)zlibstat.lib - true - - - - - Itanium - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - - - 0x040c - - - /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) - $(OutDir)zlibstat.lib - true - - - - - X64 - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - - - 0x040c - - - /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) - $(OutDir)zlibstat.lib - true - - - - - Itanium - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibstat.pch - $(IntDir) - $(IntDir) - $(OutDir) - Level3 - true - - - 0x040c - - - /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) - $(OutDir)zlibstat.lib - true - - - - - - - - - - - - - - true - true - true - true - true - true - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc14/zlibvc.def b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc14/zlibvc.def deleted file mode 100644 index 99c71e3..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc14/zlibvc.def +++ /dev/null @@ -1,158 +0,0 @@ -LIBRARY -; zlib data compression and ZIP file I/O library - -VERSION 1.2 - -EXPORTS - adler32 @1 - compress @2 - crc32 @3 - deflate @4 - deflateCopy @5 - deflateEnd @6 - deflateInit2_ @7 - deflateInit_ @8 - deflateParams @9 - deflateReset @10 - deflateSetDictionary @11 - gzclose @12 - gzdopen @13 - gzerror @14 - gzflush @15 - gzopen @16 - gzread @17 - gzwrite @18 - inflate @19 - inflateEnd @20 - inflateInit2_ @21 - inflateInit_ @22 - inflateReset @23 - inflateSetDictionary @24 - inflateSync @25 - uncompress @26 - zlibVersion @27 - gzprintf @28 - gzputc @29 - gzgetc @30 - gzseek @31 - gzrewind @32 - gztell @33 - gzeof @34 - gzsetparams @35 - zError @36 - inflateSyncPoint @37 - get_crc_table @38 - compress2 @39 - gzputs @40 - gzgets @41 - inflateCopy @42 - inflateBackInit_ @43 - inflateBack @44 - inflateBackEnd @45 - compressBound @46 - deflateBound @47 - gzclearerr @48 - gzungetc @49 - zlibCompileFlags @50 - deflatePrime @51 - deflatePending @52 - - unzOpen @61 - unzClose @62 - unzGetGlobalInfo @63 - unzGetCurrentFileInfo @64 - unzGoToFirstFile @65 - unzGoToNextFile @66 - unzOpenCurrentFile @67 - unzReadCurrentFile @68 - unzOpenCurrentFile3 @69 - unztell @70 - unzeof @71 - unzCloseCurrentFile @72 - unzGetGlobalComment @73 - unzStringFileNameCompare @74 - unzLocateFile @75 - unzGetLocalExtrafield @76 - unzOpen2 @77 - unzOpenCurrentFile2 @78 - unzOpenCurrentFilePassword @79 - - zipOpen @80 - zipOpenNewFileInZip @81 - zipWriteInFileInZip @82 - zipCloseFileInZip @83 - zipClose @84 - zipOpenNewFileInZip2 @86 - zipCloseFileInZipRaw @87 - zipOpen2 @88 - zipOpenNewFileInZip3 @89 - - unzGetFilePos @100 - unzGoToFilePos @101 - - fill_win32_filefunc @110 - -; zlibwapi v1.2.4 added: - fill_win32_filefunc64 @111 - fill_win32_filefunc64A @112 - fill_win32_filefunc64W @113 - - unzOpen64 @120 - unzOpen2_64 @121 - unzGetGlobalInfo64 @122 - unzGetCurrentFileInfo64 @124 - unzGetCurrentFileZStreamPos64 @125 - unztell64 @126 - unzGetFilePos64 @127 - unzGoToFilePos64 @128 - - zipOpen64 @130 - zipOpen2_64 @131 - zipOpenNewFileInZip64 @132 - zipOpenNewFileInZip2_64 @133 - zipOpenNewFileInZip3_64 @134 - zipOpenNewFileInZip4_64 @135 - zipCloseFileInZipRaw64 @136 - -; zlib1 v1.2.4 added: - adler32_combine @140 - crc32_combine @142 - deflateSetHeader @144 - deflateTune @145 - gzbuffer @146 - gzclose_r @147 - gzclose_w @148 - gzdirect @149 - gzoffset @150 - inflateGetHeader @156 - inflateMark @157 - inflatePrime @158 - inflateReset2 @159 - inflateUndermine @160 - -; zlib1 v1.2.6 added: - gzgetc_ @161 - inflateResetKeep @163 - deflateResetKeep @164 - -; zlib1 v1.2.7 added: - gzopen_w @165 - -; zlib1 v1.2.8 added: - inflateGetDictionary @166 - gzvprintf @167 - -; zlib1 v1.2.9 added: - inflateCodesUsed @168 - inflateValidate @169 - uncompress2 @170 - gzfread @171 - gzfwrite @172 - deflateGetDictionary @173 - adler32_z @174 - crc32_z @175 - -; zlib1 v1.2.12 added: - crc32_combine_gen @176 - crc32_combine_gen64 @177 - crc32_combine_op @178 diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc14/zlibvc.sln b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc14/zlibvc.sln deleted file mode 100644 index 6f4a107..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc14/zlibvc.sln +++ /dev/null @@ -1,119 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibvc", "zlibvc.vcxproj", "{8FD826F8-3739-44E6-8CC8-997122E53B8D}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibstat", "zlibstat.vcxproj", "{745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlib", "testzlib.vcxproj", "{AA6666AA-E09F-4135-9C0C-4FE50C3C654B}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlibdll", "testzlibdll.vcxproj", "{C52F9E7B-498A-42BE-8DB4-85A15694366A}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minizip", "minizip.vcxproj", "{48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniunz", "miniunz.vcxproj", "{C52F9E7B-498A-42BE-8DB4-85A15694382A}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Itanium = Debug|Itanium - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Itanium = Release|Itanium - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - ReleaseWithoutAsm|Itanium = ReleaseWithoutAsm|Itanium - ReleaseWithoutAsm|Win32 = ReleaseWithoutAsm|Win32 - ReleaseWithoutAsm|x64 = ReleaseWithoutAsm|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Itanium.ActiveCfg = Debug|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.ActiveCfg = Debug|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.Build.0 = Debug|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.ActiveCfg = Debug|x64 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.Build.0 = Debug|x64 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Itanium.ActiveCfg = Release|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.ActiveCfg = Release|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.Build.0 = Release|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.ActiveCfg = Release|x64 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.Build.0 = Release|x64 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Itanium.ActiveCfg = Debug|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.ActiveCfg = Debug|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.Build.0 = Debug|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.ActiveCfg = Debug|x64 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.Build.0 = Debug|x64 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Itanium.ActiveCfg = Release|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.ActiveCfg = Release|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.Build.0 = Release|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.ActiveCfg = Release|x64 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.Build.0 = Release|x64 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Itanium.ActiveCfg = Debug|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.ActiveCfg = Debug|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.Build.0 = Debug|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.ActiveCfg = Debug|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.Build.0 = Debug|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Itanium.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.Build.0 = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.ActiveCfg = Release|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.Build.0 = Release|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Itanium.ActiveCfg = Debug|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.ActiveCfg = Debug|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.Build.0 = Debug|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.ActiveCfg = Debug|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.Build.0 = Debug|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Itanium.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.Build.0 = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.ActiveCfg = Release|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.Build.0 = Release|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc14/zlibvc.vcxproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc14/zlibvc.vcxproj deleted file mode 100644 index f8f673c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc14/zlibvc.vcxproj +++ /dev/null @@ -1,692 +0,0 @@ - - - - - Debug - Itanium - - - Debug - Win32 - - - Debug - x64 - - - ReleaseWithoutAsm - Itanium - - - ReleaseWithoutAsm - Win32 - - - ReleaseWithoutAsm - x64 - - - Release - Itanium - - - Release - Win32 - - - Release - x64 - - - - {8FD826F8-3739-44E6-8CC8-997122E53B8D} - - - - DynamicLibrary - false - true - v140 - - - DynamicLibrary - false - true - v140 - - - DynamicLibrary - false - v140 - Unicode - - - DynamicLibrary - false - true - v140 - - - DynamicLibrary - false - true - v140 - - - DynamicLibrary - false - v140 - - - DynamicLibrary - false - true - v140 - - - DynamicLibrary - false - true - v140 - - - DynamicLibrary - false - v140 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30128.1 - x86\ZlibDll$(Configuration)\ - x86\ZlibDll$(Configuration)\Tmp\ - true - false - x86\ZlibDll$(Configuration)\ - x86\ZlibDll$(Configuration)\Tmp\ - false - false - x86\ZlibDll$(Configuration)\ - x86\ZlibDll$(Configuration)\Tmp\ - false - false - x64\ZlibDll$(Configuration)\ - x64\ZlibDll$(Configuration)\Tmp\ - true - false - ia64\ZlibDll$(Configuration)\ - ia64\ZlibDll$(Configuration)\Tmp\ - true - false - x64\ZlibDll$(Configuration)\ - x64\ZlibDll$(Configuration)\Tmp\ - false - false - ia64\ZlibDll$(Configuration)\ - ia64\ZlibDll$(Configuration)\Tmp\ - false - false - x64\ZlibDll$(Configuration)\ - x64\ZlibDll$(Configuration)\Tmp\ - false - false - ia64\ZlibDll$(Configuration)\ - ia64\ZlibDll$(Configuration)\Tmp\ - false - false - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - zlibwapi - zlibwapi - zlibwapi - zlibwapi - zlibwapi - zlibwapi - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - Win32 - $(OutDir)zlibvc.tlb - - - Disabled - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;%(PreprocessorDefinitions) - - - MultiThreadedDebugDLL - false - $(IntDir)zlibvc.pch - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x040c - - - /MACHINE:I386 %(AdditionalOptions) - ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) - $(OutDir)zlibwapi.dll - true - .\zlibvc.def - true - $(OutDir)zlibwapi.pdb - true - $(OutDir)zlibwapi.map - Windows - false - - - $(OutDir)zlibwapi.lib - - - cd ..\..\masmx86 -bld_ml32.bat - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - Win32 - $(OutDir)zlibvc.tlb - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibvc.pch - All - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x040c - - - /MACHINE:I386 %(AdditionalOptions) - $(OutDir)zlibwapi.dll - true - false - .\zlibvc.def - $(OutDir)zlibwapi.pdb - true - $(OutDir)zlibwapi.map - Windows - false - - - $(OutDir)zlibwapi.lib - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - Win32 - $(OutDir)zlibvc.tlb - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;%(PreprocessorDefinitions) - true - - - MultiThreaded - false - true - $(IntDir)zlibvc.pch - All - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x040c - - - /MACHINE:I386 %(AdditionalOptions) - ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) - $(OutDir)zlibwapi.dll - true - false - .\zlibvc.def - $(OutDir)zlibwapi.pdb - true - $(OutDir)zlibwapi.map - Windows - false - - - $(OutDir)zlibwapi.lib - false - - - cd ..\..\masmx86 -bld_ml32.bat - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - X64 - $(OutDir)zlibvc.tlb - - - Disabled - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) - - - MultiThreadedDebugDLL - false - $(IntDir)zlibvc.pch - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x040c - - - ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) - $(OutDir)zlibwapi.dll - true - .\zlibvc.def - true - $(OutDir)zlibwapi.pdb - true - $(OutDir)zlibwapi.map - Windows - $(OutDir)zlibwapi.lib - MachineX64 - - - cd ..\..\contrib\masmx64 -bld_ml64.bat - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - Itanium - $(OutDir)zlibvc.tlb - - - Disabled - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) - - - MultiThreadedDebugDLL - false - $(IntDir)zlibvc.pch - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - ProgramDatabase - - - _DEBUG;%(PreprocessorDefinitions) - 0x040c - - - $(OutDir)zlibwapi.dll - true - .\zlibvc.def - true - $(OutDir)zlibwapi.pdb - true - $(OutDir)zlibwapi.map - Windows - $(OutDir)zlibwapi.lib - MachineIA64 - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - X64 - $(OutDir)zlibvc.tlb - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibvc.pch - All - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x040c - - - $(OutDir)zlibwapi.dll - true - false - .\zlibvc.def - $(OutDir)zlibwapi.pdb - true - $(OutDir)zlibwapi.map - Windows - $(OutDir)zlibwapi.lib - MachineX64 - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - Itanium - $(OutDir)zlibvc.tlb - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibvc.pch - All - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x040c - - - $(OutDir)zlibwapi.dll - true - false - .\zlibvc.def - $(OutDir)zlibwapi.pdb - true - $(OutDir)zlibwapi.map - Windows - $(OutDir)zlibwapi.lib - MachineIA64 - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - X64 - $(OutDir)zlibvc.tlb - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibvc.pch - All - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x040c - - - ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) - $(OutDir)zlibwapi.dll - true - false - .\zlibvc.def - $(OutDir)zlibwapi.pdb - true - $(OutDir)zlibwapi.map - Windows - $(OutDir)zlibwapi.lib - MachineX64 - - - cd ..\..\masmx64 -bld_ml64.bat - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - Itanium - $(OutDir)zlibvc.tlb - - - OnlyExplicitInline - ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) - _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) - true - - - MultiThreadedDLL - false - true - $(IntDir)zlibvc.pch - All - $(IntDir) - $(IntDir) - $(OutDir) - - - Level3 - true - - - NDEBUG;%(PreprocessorDefinitions) - 0x040c - - - $(OutDir)zlibwapi.dll - true - false - .\zlibvc.def - $(OutDir)zlibwapi.pdb - true - $(OutDir)zlibwapi.map - Windows - $(OutDir)zlibwapi.lib - MachineIA64 - - - - - - - - - - - - - - true - true - true - true - true - true - - - - - - - - - - %(AdditionalIncludeDirectories) - ZLIB_INTERNAL;%(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - ZLIB_INTERNAL;%(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - ZLIB_INTERNAL;%(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - ZLIB_INTERNAL;%(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - ZLIB_INTERNAL;%(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - ZLIB_INTERNAL;%(PreprocessorDefinitions) - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc9/miniunz.vcproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc9/miniunz.vcproj deleted file mode 100644 index 038a9e5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc9/miniunz.vcproj +++ /dev/null @@ -1,565 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc9/minizip.vcproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc9/minizip.vcproj deleted file mode 100644 index ad40239..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc9/minizip.vcproj +++ /dev/null @@ -1,562 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc9/testzlib.vcproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc9/testzlib.vcproj deleted file mode 100644 index c9f19d2..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc9/testzlib.vcproj +++ /dev/null @@ -1,852 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc9/testzlibdll.vcproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc9/testzlibdll.vcproj deleted file mode 100644 index d7530fd..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc9/testzlibdll.vcproj +++ /dev/null @@ -1,565 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc9/zlib.rc b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc9/zlib.rc deleted file mode 100644 index 9475873..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc9/zlib.rc +++ /dev/null @@ -1,32 +0,0 @@ -#include - -#define IDR_VERSION1 1 -IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE - FILEVERSION 1, 2, 12, 0 - PRODUCTVERSION 1, 2, 12, 0 - FILEFLAGSMASK VS_FFI_FILEFLAGSMASK - FILEFLAGS 0 - FILEOS VOS_DOS_WINDOWS32 - FILETYPE VFT_DLL - FILESUBTYPE 0 // not used -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904E4" - //language ID = U.S. English, char set = Windows, Multilingual - - BEGIN - VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" - VALUE "FileVersion", "1.2.12\0" - VALUE "InternalName", "zlib\0" - VALUE "OriginalFilename", "zlibwapi.dll\0" - VALUE "ProductName", "ZLib.DLL\0" - VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" - VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0409, 1252 - END -END diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc9/zlibstat.vcproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc9/zlibstat.vcproj deleted file mode 100644 index d4ffb46..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc9/zlibstat.vcproj +++ /dev/null @@ -1,835 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc9/zlibvc.def b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc9/zlibvc.def deleted file mode 100644 index 99c71e3..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc9/zlibvc.def +++ /dev/null @@ -1,158 +0,0 @@ -LIBRARY -; zlib data compression and ZIP file I/O library - -VERSION 1.2 - -EXPORTS - adler32 @1 - compress @2 - crc32 @3 - deflate @4 - deflateCopy @5 - deflateEnd @6 - deflateInit2_ @7 - deflateInit_ @8 - deflateParams @9 - deflateReset @10 - deflateSetDictionary @11 - gzclose @12 - gzdopen @13 - gzerror @14 - gzflush @15 - gzopen @16 - gzread @17 - gzwrite @18 - inflate @19 - inflateEnd @20 - inflateInit2_ @21 - inflateInit_ @22 - inflateReset @23 - inflateSetDictionary @24 - inflateSync @25 - uncompress @26 - zlibVersion @27 - gzprintf @28 - gzputc @29 - gzgetc @30 - gzseek @31 - gzrewind @32 - gztell @33 - gzeof @34 - gzsetparams @35 - zError @36 - inflateSyncPoint @37 - get_crc_table @38 - compress2 @39 - gzputs @40 - gzgets @41 - inflateCopy @42 - inflateBackInit_ @43 - inflateBack @44 - inflateBackEnd @45 - compressBound @46 - deflateBound @47 - gzclearerr @48 - gzungetc @49 - zlibCompileFlags @50 - deflatePrime @51 - deflatePending @52 - - unzOpen @61 - unzClose @62 - unzGetGlobalInfo @63 - unzGetCurrentFileInfo @64 - unzGoToFirstFile @65 - unzGoToNextFile @66 - unzOpenCurrentFile @67 - unzReadCurrentFile @68 - unzOpenCurrentFile3 @69 - unztell @70 - unzeof @71 - unzCloseCurrentFile @72 - unzGetGlobalComment @73 - unzStringFileNameCompare @74 - unzLocateFile @75 - unzGetLocalExtrafield @76 - unzOpen2 @77 - unzOpenCurrentFile2 @78 - unzOpenCurrentFilePassword @79 - - zipOpen @80 - zipOpenNewFileInZip @81 - zipWriteInFileInZip @82 - zipCloseFileInZip @83 - zipClose @84 - zipOpenNewFileInZip2 @86 - zipCloseFileInZipRaw @87 - zipOpen2 @88 - zipOpenNewFileInZip3 @89 - - unzGetFilePos @100 - unzGoToFilePos @101 - - fill_win32_filefunc @110 - -; zlibwapi v1.2.4 added: - fill_win32_filefunc64 @111 - fill_win32_filefunc64A @112 - fill_win32_filefunc64W @113 - - unzOpen64 @120 - unzOpen2_64 @121 - unzGetGlobalInfo64 @122 - unzGetCurrentFileInfo64 @124 - unzGetCurrentFileZStreamPos64 @125 - unztell64 @126 - unzGetFilePos64 @127 - unzGoToFilePos64 @128 - - zipOpen64 @130 - zipOpen2_64 @131 - zipOpenNewFileInZip64 @132 - zipOpenNewFileInZip2_64 @133 - zipOpenNewFileInZip3_64 @134 - zipOpenNewFileInZip4_64 @135 - zipCloseFileInZipRaw64 @136 - -; zlib1 v1.2.4 added: - adler32_combine @140 - crc32_combine @142 - deflateSetHeader @144 - deflateTune @145 - gzbuffer @146 - gzclose_r @147 - gzclose_w @148 - gzdirect @149 - gzoffset @150 - inflateGetHeader @156 - inflateMark @157 - inflatePrime @158 - inflateReset2 @159 - inflateUndermine @160 - -; zlib1 v1.2.6 added: - gzgetc_ @161 - inflateResetKeep @163 - deflateResetKeep @164 - -; zlib1 v1.2.7 added: - gzopen_w @165 - -; zlib1 v1.2.8 added: - inflateGetDictionary @166 - gzvprintf @167 - -; zlib1 v1.2.9 added: - inflateCodesUsed @168 - inflateValidate @169 - uncompress2 @170 - gzfread @171 - gzfwrite @172 - deflateGetDictionary @173 - adler32_z @174 - crc32_z @175 - -; zlib1 v1.2.12 added: - crc32_combine_gen @176 - crc32_combine_gen64 @177 - crc32_combine_op @178 diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc9/zlibvc.sln b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc9/zlibvc.sln deleted file mode 100644 index 75c64c3..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc9/zlibvc.sln +++ /dev/null @@ -1,144 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibvc", "zlibvc.vcproj", "{8FD826F8-3739-44E6-8CC8-997122E53B8D}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibstat", "zlibstat.vcproj", "{745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlib", "testzlib.vcproj", "{AA6666AA-E09F-4135-9C0C-4FE50C3C654B}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestZlibDll", "testzlibdll.vcproj", "{C52F9E7B-498A-42BE-8DB4-85A15694366A}" - ProjectSection(ProjectDependencies) = postProject - {8FD826F8-3739-44E6-8CC8-997122E53B8D} = {8FD826F8-3739-44E6-8CC8-997122E53B8D} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minizip", "minizip.vcproj", "{48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}" - ProjectSection(ProjectDependencies) = postProject - {8FD826F8-3739-44E6-8CC8-997122E53B8D} = {8FD826F8-3739-44E6-8CC8-997122E53B8D} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniunz", "miniunz.vcproj", "{C52F9E7B-498A-42BE-8DB4-85A15694382A}" - ProjectSection(ProjectDependencies) = postProject - {8FD826F8-3739-44E6-8CC8-997122E53B8D} = {8FD826F8-3739-44E6-8CC8-997122E53B8D} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Itanium = Debug|Itanium - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Itanium = Release|Itanium - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - ReleaseWithoutAsm|Itanium = ReleaseWithoutAsm|Itanium - ReleaseWithoutAsm|Win32 = ReleaseWithoutAsm|Win32 - ReleaseWithoutAsm|x64 = ReleaseWithoutAsm|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Itanium.ActiveCfg = Debug|Itanium - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Itanium.Build.0 = Debug|Itanium - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.ActiveCfg = Debug|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.Build.0 = Debug|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.ActiveCfg = Debug|x64 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.Build.0 = Debug|x64 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Itanium.ActiveCfg = Release|Itanium - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Itanium.Build.0 = Release|Itanium - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.ActiveCfg = Release|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.Build.0 = Release|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.ActiveCfg = Release|x64 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.Build.0 = Release|x64 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Itanium - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Itanium.Build.0 = ReleaseWithoutAsm|Itanium - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 - {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Itanium.ActiveCfg = Debug|Itanium - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Itanium.Build.0 = Debug|Itanium - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.ActiveCfg = Debug|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.Build.0 = Debug|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.ActiveCfg = Debug|x64 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.Build.0 = Debug|x64 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Itanium.ActiveCfg = Release|Itanium - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Itanium.Build.0 = Release|Itanium - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.ActiveCfg = Release|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.Build.0 = Release|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.ActiveCfg = Release|x64 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.Build.0 = Release|x64 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Itanium - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Itanium.Build.0 = ReleaseWithoutAsm|Itanium - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 - {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Itanium - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.Build.0 = Debug|Itanium - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Itanium - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.Build.0 = Release|Itanium - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Itanium - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.Build.0 = ReleaseWithoutAsm|Itanium - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 - {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Itanium.ActiveCfg = Debug|Itanium - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Itanium.Build.0 = Debug|Itanium - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.ActiveCfg = Debug|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.Build.0 = Debug|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.ActiveCfg = Debug|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.Build.0 = Debug|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Itanium.ActiveCfg = Release|Itanium - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Itanium.Build.0 = Release|Itanium - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.Build.0 = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.ActiveCfg = Release|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.Build.0 = Release|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Itanium - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Itanium.Build.0 = Release|Itanium - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Itanium - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.Build.0 = Debug|Itanium - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Itanium - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.Build.0 = Release|Itanium - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Itanium - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.Build.0 = Release|Itanium - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 - {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Itanium.ActiveCfg = Debug|Itanium - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Itanium.Build.0 = Debug|Itanium - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.ActiveCfg = Debug|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.Build.0 = Debug|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.ActiveCfg = Debug|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.Build.0 = Debug|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Itanium.ActiveCfg = Release|Itanium - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Itanium.Build.0 = Release|Itanium - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.Build.0 = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.ActiveCfg = Release|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.Build.0 = Release|x64 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Itanium - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Itanium.Build.0 = Release|Itanium - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 - {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc9/zlibvc.vcproj b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc9/zlibvc.vcproj deleted file mode 100644 index 95bb241..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/contrib/vstudio/vc9/zlibvc.vcproj +++ /dev/null @@ -1,1156 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/crc32.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/crc32.c deleted file mode 100644 index a1bdce5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/crc32.c +++ /dev/null @@ -1,1116 +0,0 @@ -/* crc32.c -- compute the CRC-32 of a data stream - * Copyright (C) 1995-2022 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - * - * This interleaved implementation of a CRC makes use of pipelined multiple - * arithmetic-logic units, commonly found in modern CPU cores. It is due to - * Kadatch and Jenkins (2010). See doc/crc-doc.1.0.pdf in this distribution. - */ - -/* @(#) $Id$ */ - -/* - Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore - protection on the static variables used to control the first-use generation - of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should - first call get_crc_table() to initialize the tables before allowing more than - one thread to use crc32(). - - MAKECRCH can be #defined to write out crc32.h. A main() routine is also - produced, so that this one source file can be compiled to an executable. - */ - -#ifdef MAKECRCH -# include -# ifndef DYNAMIC_CRC_TABLE -# define DYNAMIC_CRC_TABLE -# endif /* !DYNAMIC_CRC_TABLE */ -#endif /* MAKECRCH */ - -#include "zutil.h" /* for Z_U4, Z_U8, z_crc_t, and FAR definitions */ - - /* - A CRC of a message is computed on N braids of words in the message, where - each word consists of W bytes (4 or 8). If N is 3, for example, then three - running sparse CRCs are calculated respectively on each braid, at these - indices in the array of words: 0, 3, 6, ..., 1, 4, 7, ..., and 2, 5, 8, ... - This is done starting at a word boundary, and continues until as many blocks - of N * W bytes as are available have been processed. The results are combined - into a single CRC at the end. For this code, N must be in the range 1..6 and - W must be 4 or 8. The upper limit on N can be increased if desired by adding - more #if blocks, extending the patterns apparent in the code. In addition, - crc32.h would need to be regenerated, if the maximum N value is increased. - - N and W are chosen empirically by benchmarking the execution time on a given - processor. The choices for N and W below were based on testing on Intel Kaby - Lake i7, AMD Ryzen 7, ARM Cortex-A57, Sparc64-VII, PowerPC POWER9, and MIPS64 - Octeon II processors. The Intel, AMD, and ARM processors were all fastest - with N=5, W=8. The Sparc, PowerPC, and MIPS64 were all fastest at N=5, W=4. - They were all tested with either gcc or clang, all using the -O3 optimization - level. Your mileage may vary. - */ - -/* Define N */ -#ifdef Z_TESTN -# define N Z_TESTN -#else -# define N 5 -#endif -#if N < 1 || N > 6 -# error N must be in 1..6 -#endif - -/* - z_crc_t must be at least 32 bits. z_word_t must be at least as long as - z_crc_t. It is assumed here that z_word_t is either 32 bits or 64 bits, and - that bytes are eight bits. - */ - -/* - Define W and the associated z_word_t type. If W is not defined, then a - braided calculation is not used, and the associated tables and code are not - compiled. - */ -#ifdef Z_TESTW -# if Z_TESTW-1 != -1 -# define W Z_TESTW -# endif -#else -# ifdef MAKECRCH -# define W 8 /* required for MAKECRCH */ -# else -# if defined(__x86_64__) || defined(__aarch64__) -# define W 8 -# else -# define W 4 -# endif -# endif -#endif -#ifdef W -# if W == 8 && defined(Z_U8) - typedef Z_U8 z_word_t; -# elif defined(Z_U4) -# undef W -# define W 4 - typedef Z_U4 z_word_t; -# else -# undef W -# endif -#endif - -/* Local functions. */ -local z_crc_t multmodp OF((z_crc_t a, z_crc_t b)); -local z_crc_t x2nmodp OF((z_off64_t n, unsigned k)); - -/* If available, use the ARM processor CRC32 instruction. */ -#if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32) && W == 8 -# define ARMCRC32 -#endif - -#if defined(W) && (!defined(ARMCRC32) || defined(DYNAMIC_CRC_TABLE)) -/* - Swap the bytes in a z_word_t to convert between little and big endian. Any - self-respecting compiler will optimize this to a single machine byte-swap - instruction, if one is available. This assumes that word_t is either 32 bits - or 64 bits. - */ -local z_word_t byte_swap(word) - z_word_t word; -{ -# if W == 8 - return - (word & 0xff00000000000000) >> 56 | - (word & 0xff000000000000) >> 40 | - (word & 0xff0000000000) >> 24 | - (word & 0xff00000000) >> 8 | - (word & 0xff000000) << 8 | - (word & 0xff0000) << 24 | - (word & 0xff00) << 40 | - (word & 0xff) << 56; -# else /* W == 4 */ - return - (word & 0xff000000) >> 24 | - (word & 0xff0000) >> 8 | - (word & 0xff00) << 8 | - (word & 0xff) << 24; -# endif -} -#endif - -/* CRC polynomial. */ -#define POLY 0xedb88320 /* p(x) reflected, with x^32 implied */ - -#ifdef DYNAMIC_CRC_TABLE - -local z_crc_t FAR crc_table[256]; -local z_crc_t FAR x2n_table[32]; -local void make_crc_table OF((void)); -#ifdef W - local z_word_t FAR crc_big_table[256]; - local z_crc_t FAR crc_braid_table[W][256]; - local z_word_t FAR crc_braid_big_table[W][256]; - local void braid OF((z_crc_t [][256], z_word_t [][256], int, int)); -#endif -#ifdef MAKECRCH - local void write_table OF((FILE *, const z_crc_t FAR *, int)); - local void write_table32hi OF((FILE *, const z_word_t FAR *, int)); - local void write_table64 OF((FILE *, const z_word_t FAR *, int)); -#endif /* MAKECRCH */ - -/* - Define a once() function depending on the availability of atomics. If this is - compiled with DYNAMIC_CRC_TABLE defined, and if CRCs will be computed in - multiple threads, and if atomics are not available, then get_crc_table() must - be called to initialize the tables and must return before any threads are - allowed to compute or combine CRCs. - */ - -/* Definition of once functionality. */ -typedef struct once_s once_t; -local void once OF((once_t *, void (*)(void))); - -/* Check for the availability of atomics. */ -#if defined(__STDC__) && __STDC_VERSION__ >= 201112L && \ - !defined(__STDC_NO_ATOMICS__) - -#include - -/* Structure for once(), which must be initialized with ONCE_INIT. */ -struct once_s { - atomic_flag begun; - atomic_int done; -}; -#define ONCE_INIT {ATOMIC_FLAG_INIT, 0} - -/* - Run the provided init() function exactly once, even if multiple threads - invoke once() at the same time. The state must be a once_t initialized with - ONCE_INIT. - */ -local void once(state, init) - once_t *state; - void (*init)(void); -{ - if (!atomic_load(&state->done)) { - if (atomic_flag_test_and_set(&state->begun)) - while (!atomic_load(&state->done)) - ; - else { - init(); - atomic_store(&state->done, 1); - } - } -} - -#else /* no atomics */ - -/* Structure for once(), which must be initialized with ONCE_INIT. */ -struct once_s { - volatile int begun; - volatile int done; -}; -#define ONCE_INIT {0, 0} - -/* Test and set. Alas, not atomic, but tries to minimize the period of - vulnerability. */ -local int test_and_set OF((int volatile *)); -local int test_and_set(flag) - int volatile *flag; -{ - int was; - - was = *flag; - *flag = 1; - return was; -} - -/* Run the provided init() function once. This is not thread-safe. */ -local void once(state, init) - once_t *state; - void (*init)(void); -{ - if (!state->done) { - if (test_and_set(&state->begun)) - while (!state->done) - ; - else { - init(); - state->done = 1; - } - } -} - -#endif - -/* State for once(). */ -local once_t made = ONCE_INIT; - -/* - Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: - x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. - - Polynomials over GF(2) are represented in binary, one bit per coefficient, - with the lowest powers in the most significant bit. Then adding polynomials - is just exclusive-or, and multiplying a polynomial by x is a right shift by - one. If we call the above polynomial p, and represent a byte as the - polynomial q, also with the lowest power in the most significant bit (so the - byte 0xb1 is the polynomial x^7+x^3+x^2+1), then the CRC is (q*x^32) mod p, - where a mod b means the remainder after dividing a by b. - - This calculation is done using the shift-register method of multiplying and - taking the remainder. The register is initialized to zero, and for each - incoming bit, x^32 is added mod p to the register if the bit is a one (where - x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by x - (which is shifting right by one and adding x^32 mod p if the bit shifted out - is a one). We start with the highest power (least significant bit) of q and - repeat for all eight bits of q. - - The table is simply the CRC of all possible eight bit values. This is all the - information needed to generate CRCs on data a byte at a time for all - combinations of CRC register values and incoming bytes. - */ - -local void make_crc_table() -{ - unsigned i, j, n; - z_crc_t p; - - /* initialize the CRC of bytes tables */ - for (i = 0; i < 256; i++) { - p = i; - for (j = 0; j < 8; j++) - p = p & 1 ? (p >> 1) ^ POLY : p >> 1; - crc_table[i] = p; -#ifdef W - crc_big_table[i] = byte_swap(p); -#endif - } - - /* initialize the x^2^n mod p(x) table */ - p = (z_crc_t)1 << 30; /* x^1 */ - x2n_table[0] = p; - for (n = 1; n < 32; n++) - x2n_table[n] = p = multmodp(p, p); - -#ifdef W - /* initialize the braiding tables -- needs x2n_table[] */ - braid(crc_braid_table, crc_braid_big_table, N, W); -#endif - -#ifdef MAKECRCH - { - /* - The crc32.h header file contains tables for both 32-bit and 64-bit - z_word_t's, and so requires a 64-bit type be available. In that case, - z_word_t must be defined to be 64-bits. This code then also generates - and writes out the tables for the case that z_word_t is 32 bits. - */ -#if !defined(W) || W != 8 -# error Need a 64-bit integer type in order to generate crc32.h. -#endif - FILE *out; - int k, n; - z_crc_t ltl[8][256]; - z_word_t big[8][256]; - - out = fopen("crc32.h", "w"); - if (out == NULL) return; - - /* write out little-endian CRC table to crc32.h */ - fprintf(out, - "/* crc32.h -- tables for rapid CRC calculation\n" - " * Generated automatically by crc32.c\n */\n" - "\n" - "local const z_crc_t FAR crc_table[] = {\n" - " "); - write_table(out, crc_table, 256); - fprintf(out, - "};\n"); - - /* write out big-endian CRC table for 64-bit z_word_t to crc32.h */ - fprintf(out, - "\n" - "#ifdef W\n" - "\n" - "#if W == 8\n" - "\n" - "local const z_word_t FAR crc_big_table[] = {\n" - " "); - write_table64(out, crc_big_table, 256); - fprintf(out, - "};\n"); - - /* write out big-endian CRC table for 32-bit z_word_t to crc32.h */ - fprintf(out, - "\n" - "#else /* W == 4 */\n" - "\n" - "local const z_word_t FAR crc_big_table[] = {\n" - " "); - write_table32hi(out, crc_big_table, 256); - fprintf(out, - "};\n" - "\n" - "#endif\n"); - - /* write out braid tables for each value of N */ - for (n = 1; n <= 6; n++) { - fprintf(out, - "\n" - "#if N == %d\n", n); - - /* compute braid tables for this N and 64-bit word_t */ - braid(ltl, big, n, 8); - - /* write out braid tables for 64-bit z_word_t to crc32.h */ - fprintf(out, - "\n" - "#if W == 8\n" - "\n" - "local const z_crc_t FAR crc_braid_table[][256] = {\n"); - for (k = 0; k < 8; k++) { - fprintf(out, " {"); - write_table(out, ltl[k], 256); - fprintf(out, "}%s", k < 7 ? ",\n" : ""); - } - fprintf(out, - "};\n" - "\n" - "local const z_word_t FAR crc_braid_big_table[][256] = {\n"); - for (k = 0; k < 8; k++) { - fprintf(out, " {"); - write_table64(out, big[k], 256); - fprintf(out, "}%s", k < 7 ? ",\n" : ""); - } - fprintf(out, - "};\n"); - - /* compute braid tables for this N and 32-bit word_t */ - braid(ltl, big, n, 4); - - /* write out braid tables for 32-bit z_word_t to crc32.h */ - fprintf(out, - "\n" - "#else /* W == 4 */\n" - "\n" - "local const z_crc_t FAR crc_braid_table[][256] = {\n"); - for (k = 0; k < 4; k++) { - fprintf(out, " {"); - write_table(out, ltl[k], 256); - fprintf(out, "}%s", k < 3 ? ",\n" : ""); - } - fprintf(out, - "};\n" - "\n" - "local const z_word_t FAR crc_braid_big_table[][256] = {\n"); - for (k = 0; k < 4; k++) { - fprintf(out, " {"); - write_table32hi(out, big[k], 256); - fprintf(out, "}%s", k < 3 ? ",\n" : ""); - } - fprintf(out, - "};\n" - "\n" - "#endif\n" - "\n" - "#endif\n"); - } - fprintf(out, - "\n" - "#endif\n"); - - /* write out zeros operator table to crc32.h */ - fprintf(out, - "\n" - "local const z_crc_t FAR x2n_table[] = {\n" - " "); - write_table(out, x2n_table, 32); - fprintf(out, - "};\n"); - fclose(out); - } -#endif /* MAKECRCH */ -} - -#ifdef MAKECRCH - -/* - Write the 32-bit values in table[0..k-1] to out, five per line in - hexadecimal separated by commas. - */ -local void write_table(out, table, k) - FILE *out; - const z_crc_t FAR *table; - int k; -{ - int n; - - for (n = 0; n < k; n++) - fprintf(out, "%s0x%08lx%s", n == 0 || n % 5 ? "" : " ", - (unsigned long)(table[n]), - n == k - 1 ? "" : (n % 5 == 4 ? ",\n" : ", ")); -} - -/* - Write the high 32-bits of each value in table[0..k-1] to out, five per line - in hexadecimal separated by commas. - */ -local void write_table32hi(out, table, k) -FILE *out; -const z_word_t FAR *table; -int k; -{ - int n; - - for (n = 0; n < k; n++) - fprintf(out, "%s0x%08lx%s", n == 0 || n % 5 ? "" : " ", - (unsigned long)(table[n] >> 32), - n == k - 1 ? "" : (n % 5 == 4 ? ",\n" : ", ")); -} - -/* - Write the 64-bit values in table[0..k-1] to out, three per line in - hexadecimal separated by commas. This assumes that if there is a 64-bit - type, then there is also a long long integer type, and it is at least 64 - bits. If not, then the type cast and format string can be adjusted - accordingly. - */ -local void write_table64(out, table, k) - FILE *out; - const z_word_t FAR *table; - int k; -{ - int n; - - for (n = 0; n < k; n++) - fprintf(out, "%s0x%016llx%s", n == 0 || n % 3 ? "" : " ", - (unsigned long long)(table[n]), - n == k - 1 ? "" : (n % 3 == 2 ? ",\n" : ", ")); -} - -/* Actually do the deed. */ -int main() -{ - make_crc_table(); - return 0; -} - -#endif /* MAKECRCH */ - -#ifdef W -/* - Generate the little and big-endian braid tables for the given n and z_word_t - size w. Each array must have room for w blocks of 256 elements. - */ -local void braid(ltl, big, n, w) - z_crc_t ltl[][256]; - z_word_t big[][256]; - int n; - int w; -{ - int k; - z_crc_t i, p, q; - for (k = 0; k < w; k++) { - p = x2nmodp((n * w + 3 - k) << 3, 0); - ltl[k][0] = 0; - big[w - 1 - k][0] = 0; - for (i = 1; i < 256; i++) { - ltl[k][i] = q = multmodp(i << 24, p); - big[w - 1 - k][i] = byte_swap(q); - } - } -} -#endif - -#else /* !DYNAMIC_CRC_TABLE */ -/* ======================================================================== - * Tables for byte-wise and braided CRC-32 calculations, and a table of powers - * of x for combining CRC-32s, all made by make_crc_table(). - */ -#include "crc32.h" -#endif /* DYNAMIC_CRC_TABLE */ - -/* ======================================================================== - * Routines used for CRC calculation. Some are also required for the table - * generation above. - */ - -/* - Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial, - reflected. For speed, this requires that a not be zero. - */ -local z_crc_t multmodp(a, b) - z_crc_t a; - z_crc_t b; -{ - z_crc_t m, p; - - m = (z_crc_t)1 << 31; - p = 0; - for (;;) { - if (a & m) { - p ^= b; - if ((a & (m - 1)) == 0) - break; - } - m >>= 1; - b = b & 1 ? (b >> 1) ^ POLY : b >> 1; - } - return p; -} - -/* - Return x^(n * 2^k) modulo p(x). Requires that x2n_table[] has been - initialized. - */ -local z_crc_t x2nmodp(n, k) - z_off64_t n; - unsigned k; -{ - z_crc_t p; - - p = (z_crc_t)1 << 31; /* x^0 == 1 */ - while (n) { - if (n & 1) - p = multmodp(x2n_table[k & 31], p); - n >>= 1; - k++; - } - return p; -} - -/* ========================================================================= - * This function can be used by asm versions of crc32(), and to force the - * generation of the CRC tables in a threaded application. - */ -const z_crc_t FAR * ZEXPORT get_crc_table() -{ -#ifdef DYNAMIC_CRC_TABLE - once(&made, make_crc_table); -#endif /* DYNAMIC_CRC_TABLE */ - return (const z_crc_t FAR *)crc_table; -} - -/* ========================================================================= - * Use ARM machine instructions if available. This will compute the CRC about - * ten times faster than the braided calculation. This code does not check for - * the presence of the CRC instruction at run time. __ARM_FEATURE_CRC32 will - * only be defined if the compilation specifies an ARM processor architecture - * that has the instructions. For example, compiling with -march=armv8.1-a or - * -march=armv8-a+crc, or -march=native if the compile machine has the crc32 - * instructions. - */ -#ifdef ARMCRC32 - -/* - Constants empirically determined to maximize speed. These values are from - measurements on a Cortex-A57. Your mileage may vary. - */ -#define Z_BATCH 3990 /* number of words in a batch */ -#define Z_BATCH_ZEROS 0xa10d3d0c /* computed from Z_BATCH = 3990 */ -#define Z_BATCH_MIN 800 /* fewest words in a final batch */ - -unsigned long ZEXPORT crc32_z(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - z_size_t len; -{ - z_crc_t val; - z_word_t crc1, crc2; - const z_word_t *word; - z_word_t val0, val1, val2; - z_size_t last, last2, i; - z_size_t num; - - /* Return initial CRC, if requested. */ - if (buf == Z_NULL) return 0; - -#ifdef DYNAMIC_CRC_TABLE - once(&made, make_crc_table); -#endif /* DYNAMIC_CRC_TABLE */ - - /* Pre-condition the CRC */ - crc ^= 0xffffffff; - - /* Compute the CRC up to a word boundary. */ - while (len && ((z_size_t)buf & 7) != 0) { - len--; - val = *buf++; - __asm__ volatile("crc32b %w0, %w0, %w1" : "+r"(crc) : "r"(val)); - } - - /* Prepare to compute the CRC on full 64-bit words word[0..num-1]. */ - word = (z_word_t const *)buf; - num = len >> 3; - len &= 7; - - /* Do three interleaved CRCs to realize the throughput of one crc32x - instruction per cycle. Each CRC is calcuated on Z_BATCH words. The three - CRCs are combined into a single CRC after each set of batches. */ - while (num >= 3 * Z_BATCH) { - crc1 = 0; - crc2 = 0; - for (i = 0; i < Z_BATCH; i++) { - val0 = word[i]; - val1 = word[i + Z_BATCH]; - val2 = word[i + 2 * Z_BATCH]; - __asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc) : "r"(val0)); - __asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc1) : "r"(val1)); - __asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc2) : "r"(val2)); - } - word += 3 * Z_BATCH; - num -= 3 * Z_BATCH; - crc = multmodp(Z_BATCH_ZEROS, crc) ^ crc1; - crc = multmodp(Z_BATCH_ZEROS, crc) ^ crc2; - } - - /* Do one last smaller batch with the remaining words, if there are enough - to pay for the combination of CRCs. */ - last = num / 3; - if (last >= Z_BATCH_MIN) { - last2 = last << 1; - crc1 = 0; - crc2 = 0; - for (i = 0; i < last; i++) { - val0 = word[i]; - val1 = word[i + last]; - val2 = word[i + last2]; - __asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc) : "r"(val0)); - __asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc1) : "r"(val1)); - __asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc2) : "r"(val2)); - } - word += 3 * last; - num -= 3 * last; - val = x2nmodp(last, 6); - crc = multmodp(val, crc) ^ crc1; - crc = multmodp(val, crc) ^ crc2; - } - - /* Compute the CRC on any remaining words. */ - for (i = 0; i < num; i++) { - val0 = word[i]; - __asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc) : "r"(val0)); - } - word += num; - - /* Complete the CRC on any remaining bytes. */ - buf = (const unsigned char FAR *)word; - while (len) { - len--; - val = *buf++; - __asm__ volatile("crc32b %w0, %w0, %w1" : "+r"(crc) : "r"(val)); - } - - /* Return the CRC, post-conditioned. */ - return crc ^ 0xffffffff; -} - -#else - -#ifdef W - -/* - Return the CRC of the W bytes in the word_t data, taking the - least-significant byte of the word as the first byte of data, without any pre - or post conditioning. This is used to combine the CRCs of each braid. - */ -local z_crc_t crc_word(data) - z_word_t data; -{ - int k; - for (k = 0; k < W; k++) - data = (data >> 8) ^ crc_table[data & 0xff]; - return (z_crc_t)data; -} - -local z_word_t crc_word_big(data) - z_word_t data; -{ - int k; - for (k = 0; k < W; k++) - data = (data << 8) ^ - crc_big_table[(data >> ((W - 1) << 3)) & 0xff]; - return data; -} - -#endif - -/* ========================================================================= */ -unsigned long ZEXPORT crc32_z(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - z_size_t len; -{ - /* Return initial CRC, if requested. */ - if (buf == Z_NULL) return 0; - -#ifdef DYNAMIC_CRC_TABLE - once(&made, make_crc_table); -#endif /* DYNAMIC_CRC_TABLE */ - - /* Pre-condition the CRC */ - crc ^= 0xffffffff; - -#ifdef W - - /* If provided enough bytes, do a braided CRC calculation. */ - if (len >= N * W + W - 1) { - z_size_t blks; - z_word_t const *words; - unsigned endian; - int k; - - /* Compute the CRC up to a z_word_t boundary. */ - while (len && ((z_size_t)buf & (W - 1)) != 0) { - len--; - crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; - } - - /* Compute the CRC on as many N z_word_t blocks as are available. */ - blks = len / (N * W); - len -= blks * N * W; - words = (z_word_t const *)buf; - - /* Do endian check at execution time instead of compile time, since ARM - processors can change the endianess at execution time. If the - compiler knows what the endianess will be, it can optimize out the - check and the unused branch. */ - endian = 1; - if (*(unsigned char *)&endian) { - /* Little endian. */ - - z_crc_t crc0; - z_word_t word0; -#if N > 1 - z_crc_t crc1; - z_word_t word1; -#if N > 2 - z_crc_t crc2; - z_word_t word2; -#if N > 3 - z_crc_t crc3; - z_word_t word3; -#if N > 4 - z_crc_t crc4; - z_word_t word4; -#if N > 5 - z_crc_t crc5; - z_word_t word5; -#endif -#endif -#endif -#endif -#endif - - /* Initialize the CRC for each braid. */ - crc0 = crc; -#if N > 1 - crc1 = 0; -#if N > 2 - crc2 = 0; -#if N > 3 - crc3 = 0; -#if N > 4 - crc4 = 0; -#if N > 5 - crc5 = 0; -#endif -#endif -#endif -#endif -#endif - - /* - Process the first blks-1 blocks, computing the CRCs on each braid - independently. - */ - while (--blks) { - /* Load the word for each braid into registers. */ - word0 = crc0 ^ words[0]; -#if N > 1 - word1 = crc1 ^ words[1]; -#if N > 2 - word2 = crc2 ^ words[2]; -#if N > 3 - word3 = crc3 ^ words[3]; -#if N > 4 - word4 = crc4 ^ words[4]; -#if N > 5 - word5 = crc5 ^ words[5]; -#endif -#endif -#endif -#endif -#endif - words += N; - - /* Compute and update the CRC for each word. The loop should - get unrolled. */ - crc0 = crc_braid_table[0][word0 & 0xff]; -#if N > 1 - crc1 = crc_braid_table[0][word1 & 0xff]; -#if N > 2 - crc2 = crc_braid_table[0][word2 & 0xff]; -#if N > 3 - crc3 = crc_braid_table[0][word3 & 0xff]; -#if N > 4 - crc4 = crc_braid_table[0][word4 & 0xff]; -#if N > 5 - crc5 = crc_braid_table[0][word5 & 0xff]; -#endif -#endif -#endif -#endif -#endif - for (k = 1; k < W; k++) { - crc0 ^= crc_braid_table[k][(word0 >> (k << 3)) & 0xff]; -#if N > 1 - crc1 ^= crc_braid_table[k][(word1 >> (k << 3)) & 0xff]; -#if N > 2 - crc2 ^= crc_braid_table[k][(word2 >> (k << 3)) & 0xff]; -#if N > 3 - crc3 ^= crc_braid_table[k][(word3 >> (k << 3)) & 0xff]; -#if N > 4 - crc4 ^= crc_braid_table[k][(word4 >> (k << 3)) & 0xff]; -#if N > 5 - crc5 ^= crc_braid_table[k][(word5 >> (k << 3)) & 0xff]; -#endif -#endif -#endif -#endif -#endif - } - } - - /* - Process the last block, combining the CRCs of the N braids at the - same time. - */ - crc = crc_word(crc0 ^ words[0]); -#if N > 1 - crc = crc_word(crc1 ^ words[1] ^ crc); -#if N > 2 - crc = crc_word(crc2 ^ words[2] ^ crc); -#if N > 3 - crc = crc_word(crc3 ^ words[3] ^ crc); -#if N > 4 - crc = crc_word(crc4 ^ words[4] ^ crc); -#if N > 5 - crc = crc_word(crc5 ^ words[5] ^ crc); -#endif -#endif -#endif -#endif -#endif - words += N; - } - else { - /* Big endian. */ - - z_word_t crc0, word0, comb; -#if N > 1 - z_word_t crc1, word1; -#if N > 2 - z_word_t crc2, word2; -#if N > 3 - z_word_t crc3, word3; -#if N > 4 - z_word_t crc4, word4; -#if N > 5 - z_word_t crc5, word5; -#endif -#endif -#endif -#endif -#endif - - /* Initialize the CRC for each braid. */ - crc0 = byte_swap(crc); -#if N > 1 - crc1 = 0; -#if N > 2 - crc2 = 0; -#if N > 3 - crc3 = 0; -#if N > 4 - crc4 = 0; -#if N > 5 - crc5 = 0; -#endif -#endif -#endif -#endif -#endif - - /* - Process the first blks-1 blocks, computing the CRCs on each braid - independently. - */ - while (--blks) { - /* Load the word for each braid into registers. */ - word0 = crc0 ^ words[0]; -#if N > 1 - word1 = crc1 ^ words[1]; -#if N > 2 - word2 = crc2 ^ words[2]; -#if N > 3 - word3 = crc3 ^ words[3]; -#if N > 4 - word4 = crc4 ^ words[4]; -#if N > 5 - word5 = crc5 ^ words[5]; -#endif -#endif -#endif -#endif -#endif - words += N; - - /* Compute and update the CRC for each word. The loop should - get unrolled. */ - crc0 = crc_braid_big_table[0][word0 & 0xff]; -#if N > 1 - crc1 = crc_braid_big_table[0][word1 & 0xff]; -#if N > 2 - crc2 = crc_braid_big_table[0][word2 & 0xff]; -#if N > 3 - crc3 = crc_braid_big_table[0][word3 & 0xff]; -#if N > 4 - crc4 = crc_braid_big_table[0][word4 & 0xff]; -#if N > 5 - crc5 = crc_braid_big_table[0][word5 & 0xff]; -#endif -#endif -#endif -#endif -#endif - for (k = 1; k < W; k++) { - crc0 ^= crc_braid_big_table[k][(word0 >> (k << 3)) & 0xff]; -#if N > 1 - crc1 ^= crc_braid_big_table[k][(word1 >> (k << 3)) & 0xff]; -#if N > 2 - crc2 ^= crc_braid_big_table[k][(word2 >> (k << 3)) & 0xff]; -#if N > 3 - crc3 ^= crc_braid_big_table[k][(word3 >> (k << 3)) & 0xff]; -#if N > 4 - crc4 ^= crc_braid_big_table[k][(word4 >> (k << 3)) & 0xff]; -#if N > 5 - crc5 ^= crc_braid_big_table[k][(word5 >> (k << 3)) & 0xff]; -#endif -#endif -#endif -#endif -#endif - } - } - - /* - Process the last block, combining the CRCs of the N braids at the - same time. - */ - comb = crc_word_big(crc0 ^ words[0]); -#if N > 1 - comb = crc_word_big(crc1 ^ words[1] ^ comb); -#if N > 2 - comb = crc_word_big(crc2 ^ words[2] ^ comb); -#if N > 3 - comb = crc_word_big(crc3 ^ words[3] ^ comb); -#if N > 4 - comb = crc_word_big(crc4 ^ words[4] ^ comb); -#if N > 5 - comb = crc_word_big(crc5 ^ words[5] ^ comb); -#endif -#endif -#endif -#endif -#endif - words += N; - crc = byte_swap(comb); - } - - /* - Update the pointer to the remaining bytes to process. - */ - buf = (unsigned char const *)words; - } - -#endif /* W */ - - /* Complete the computation of the CRC on any remaining bytes. */ - while (len >= 8) { - len -= 8; - crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; - crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; - crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; - crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; - crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; - crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; - crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; - crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; - } - while (len) { - len--; - crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; - } - - /* Return the CRC, post-conditioned. */ - return crc ^ 0xffffffff; -} - -#endif - -/* ========================================================================= */ -unsigned long ZEXPORT crc32(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - uInt len; -{ - return crc32_z(crc, buf, len); -} - -/* ========================================================================= */ -uLong ZEXPORT crc32_combine64(crc1, crc2, len2) - uLong crc1; - uLong crc2; - z_off64_t len2; -{ -#ifdef DYNAMIC_CRC_TABLE - once(&made, make_crc_table); -#endif /* DYNAMIC_CRC_TABLE */ - return multmodp(x2nmodp(len2, 3), crc1) ^ crc2; -} - -/* ========================================================================= */ -uLong ZEXPORT crc32_combine(crc1, crc2, len2) - uLong crc1; - uLong crc2; - z_off_t len2; -{ - return crc32_combine64(crc1, crc2, len2); -} - -/* ========================================================================= */ -uLong ZEXPORT crc32_combine_gen64(len2) - z_off64_t len2; -{ -#ifdef DYNAMIC_CRC_TABLE - once(&made, make_crc_table); -#endif /* DYNAMIC_CRC_TABLE */ - return x2nmodp(len2, 3); -} - -/* ========================================================================= */ -uLong ZEXPORT crc32_combine_gen(len2) - z_off_t len2; -{ - return crc32_combine_gen64(len2); -} - -/* ========================================================================= */ -uLong crc32_combine_op(crc1, crc2, op) - uLong crc1; - uLong crc2; - uLong op; -{ - return multmodp(op, crc1) ^ crc2; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/crc32.h b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/crc32.h deleted file mode 100644 index 137df68..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/crc32.h +++ /dev/null @@ -1,9446 +0,0 @@ -/* crc32.h -- tables for rapid CRC calculation - * Generated automatically by crc32.c - */ - -local const z_crc_t FAR crc_table[] = { - 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, - 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, - 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, - 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, - 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, - 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, - 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, - 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, - 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, - 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, - 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, - 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, - 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, - 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, - 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, - 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, - 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, - 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, - 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, - 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, - 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, - 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, - 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, - 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, - 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, - 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, - 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, - 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, - 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, - 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, - 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, - 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, - 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, - 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, - 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, - 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, - 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, - 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, - 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, - 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, - 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, - 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, - 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, - 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, - 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, - 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, - 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, - 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, - 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, - 0x2d02ef8d}; - -#ifdef W - -#if W == 8 - -local const z_word_t FAR crc_big_table[] = { - 0x0000000000000000, 0x9630077700000000, 0x2c610eee00000000, - 0xba51099900000000, 0x19c46d0700000000, 0x8ff46a7000000000, - 0x35a563e900000000, 0xa395649e00000000, 0x3288db0e00000000, - 0xa4b8dc7900000000, 0x1ee9d5e000000000, 0x88d9d29700000000, - 0x2b4cb60900000000, 0xbd7cb17e00000000, 0x072db8e700000000, - 0x911dbf9000000000, 0x6410b71d00000000, 0xf220b06a00000000, - 0x4871b9f300000000, 0xde41be8400000000, 0x7dd4da1a00000000, - 0xebe4dd6d00000000, 0x51b5d4f400000000, 0xc785d38300000000, - 0x56986c1300000000, 0xc0a86b6400000000, 0x7af962fd00000000, - 0xecc9658a00000000, 0x4f5c011400000000, 0xd96c066300000000, - 0x633d0ffa00000000, 0xf50d088d00000000, 0xc8206e3b00000000, - 0x5e10694c00000000, 0xe44160d500000000, 0x727167a200000000, - 0xd1e4033c00000000, 0x47d4044b00000000, 0xfd850dd200000000, - 0x6bb50aa500000000, 0xfaa8b53500000000, 0x6c98b24200000000, - 0xd6c9bbdb00000000, 0x40f9bcac00000000, 0xe36cd83200000000, - 0x755cdf4500000000, 0xcf0dd6dc00000000, 0x593dd1ab00000000, - 0xac30d92600000000, 0x3a00de5100000000, 0x8051d7c800000000, - 0x1661d0bf00000000, 0xb5f4b42100000000, 0x23c4b35600000000, - 0x9995bacf00000000, 0x0fa5bdb800000000, 0x9eb8022800000000, - 0x0888055f00000000, 0xb2d90cc600000000, 0x24e90bb100000000, - 0x877c6f2f00000000, 0x114c685800000000, 0xab1d61c100000000, - 0x3d2d66b600000000, 0x9041dc7600000000, 0x0671db0100000000, - 0xbc20d29800000000, 0x2a10d5ef00000000, 0x8985b17100000000, - 0x1fb5b60600000000, 0xa5e4bf9f00000000, 0x33d4b8e800000000, - 0xa2c9077800000000, 0x34f9000f00000000, 0x8ea8099600000000, - 0x18980ee100000000, 0xbb0d6a7f00000000, 0x2d3d6d0800000000, - 0x976c649100000000, 0x015c63e600000000, 0xf4516b6b00000000, - 0x62616c1c00000000, 0xd830658500000000, 0x4e0062f200000000, - 0xed95066c00000000, 0x7ba5011b00000000, 0xc1f4088200000000, - 0x57c40ff500000000, 0xc6d9b06500000000, 0x50e9b71200000000, - 0xeab8be8b00000000, 0x7c88b9fc00000000, 0xdf1ddd6200000000, - 0x492dda1500000000, 0xf37cd38c00000000, 0x654cd4fb00000000, - 0x5861b24d00000000, 0xce51b53a00000000, 0x7400bca300000000, - 0xe230bbd400000000, 0x41a5df4a00000000, 0xd795d83d00000000, - 0x6dc4d1a400000000, 0xfbf4d6d300000000, 0x6ae9694300000000, - 0xfcd96e3400000000, 0x468867ad00000000, 0xd0b860da00000000, - 0x732d044400000000, 0xe51d033300000000, 0x5f4c0aaa00000000, - 0xc97c0ddd00000000, 0x3c71055000000000, 0xaa41022700000000, - 0x10100bbe00000000, 0x86200cc900000000, 0x25b5685700000000, - 0xb3856f2000000000, 0x09d466b900000000, 0x9fe461ce00000000, - 0x0ef9de5e00000000, 0x98c9d92900000000, 0x2298d0b000000000, - 0xb4a8d7c700000000, 0x173db35900000000, 0x810db42e00000000, - 0x3b5cbdb700000000, 0xad6cbac000000000, 0x2083b8ed00000000, - 0xb6b3bf9a00000000, 0x0ce2b60300000000, 0x9ad2b17400000000, - 0x3947d5ea00000000, 0xaf77d29d00000000, 0x1526db0400000000, - 0x8316dc7300000000, 0x120b63e300000000, 0x843b649400000000, - 0x3e6a6d0d00000000, 0xa85a6a7a00000000, 0x0bcf0ee400000000, - 0x9dff099300000000, 0x27ae000a00000000, 0xb19e077d00000000, - 0x44930ff000000000, 0xd2a3088700000000, 0x68f2011e00000000, - 0xfec2066900000000, 0x5d5762f700000000, 0xcb67658000000000, - 0x71366c1900000000, 0xe7066b6e00000000, 0x761bd4fe00000000, - 0xe02bd38900000000, 0x5a7ada1000000000, 0xcc4add6700000000, - 0x6fdfb9f900000000, 0xf9efbe8e00000000, 0x43beb71700000000, - 0xd58eb06000000000, 0xe8a3d6d600000000, 0x7e93d1a100000000, - 0xc4c2d83800000000, 0x52f2df4f00000000, 0xf167bbd100000000, - 0x6757bca600000000, 0xdd06b53f00000000, 0x4b36b24800000000, - 0xda2b0dd800000000, 0x4c1b0aaf00000000, 0xf64a033600000000, - 0x607a044100000000, 0xc3ef60df00000000, 0x55df67a800000000, - 0xef8e6e3100000000, 0x79be694600000000, 0x8cb361cb00000000, - 0x1a8366bc00000000, 0xa0d26f2500000000, 0x36e2685200000000, - 0x95770ccc00000000, 0x03470bbb00000000, 0xb916022200000000, - 0x2f26055500000000, 0xbe3bbac500000000, 0x280bbdb200000000, - 0x925ab42b00000000, 0x046ab35c00000000, 0xa7ffd7c200000000, - 0x31cfd0b500000000, 0x8b9ed92c00000000, 0x1daede5b00000000, - 0xb0c2649b00000000, 0x26f263ec00000000, 0x9ca36a7500000000, - 0x0a936d0200000000, 0xa906099c00000000, 0x3f360eeb00000000, - 0x8567077200000000, 0x1357000500000000, 0x824abf9500000000, - 0x147ab8e200000000, 0xae2bb17b00000000, 0x381bb60c00000000, - 0x9b8ed29200000000, 0x0dbed5e500000000, 0xb7efdc7c00000000, - 0x21dfdb0b00000000, 0xd4d2d38600000000, 0x42e2d4f100000000, - 0xf8b3dd6800000000, 0x6e83da1f00000000, 0xcd16be8100000000, - 0x5b26b9f600000000, 0xe177b06f00000000, 0x7747b71800000000, - 0xe65a088800000000, 0x706a0fff00000000, 0xca3b066600000000, - 0x5c0b011100000000, 0xff9e658f00000000, 0x69ae62f800000000, - 0xd3ff6b6100000000, 0x45cf6c1600000000, 0x78e20aa000000000, - 0xeed20dd700000000, 0x5483044e00000000, 0xc2b3033900000000, - 0x612667a700000000, 0xf71660d000000000, 0x4d47694900000000, - 0xdb776e3e00000000, 0x4a6ad1ae00000000, 0xdc5ad6d900000000, - 0x660bdf4000000000, 0xf03bd83700000000, 0x53aebca900000000, - 0xc59ebbde00000000, 0x7fcfb24700000000, 0xe9ffb53000000000, - 0x1cf2bdbd00000000, 0x8ac2baca00000000, 0x3093b35300000000, - 0xa6a3b42400000000, 0x0536d0ba00000000, 0x9306d7cd00000000, - 0x2957de5400000000, 0xbf67d92300000000, 0x2e7a66b300000000, - 0xb84a61c400000000, 0x021b685d00000000, 0x942b6f2a00000000, - 0x37be0bb400000000, 0xa18e0cc300000000, 0x1bdf055a00000000, - 0x8def022d00000000}; - -#else /* W == 4 */ - -local const z_word_t FAR crc_big_table[] = { - 0x00000000, 0x96300777, 0x2c610eee, 0xba510999, 0x19c46d07, - 0x8ff46a70, 0x35a563e9, 0xa395649e, 0x3288db0e, 0xa4b8dc79, - 0x1ee9d5e0, 0x88d9d297, 0x2b4cb609, 0xbd7cb17e, 0x072db8e7, - 0x911dbf90, 0x6410b71d, 0xf220b06a, 0x4871b9f3, 0xde41be84, - 0x7dd4da1a, 0xebe4dd6d, 0x51b5d4f4, 0xc785d383, 0x56986c13, - 0xc0a86b64, 0x7af962fd, 0xecc9658a, 0x4f5c0114, 0xd96c0663, - 0x633d0ffa, 0xf50d088d, 0xc8206e3b, 0x5e10694c, 0xe44160d5, - 0x727167a2, 0xd1e4033c, 0x47d4044b, 0xfd850dd2, 0x6bb50aa5, - 0xfaa8b535, 0x6c98b242, 0xd6c9bbdb, 0x40f9bcac, 0xe36cd832, - 0x755cdf45, 0xcf0dd6dc, 0x593dd1ab, 0xac30d926, 0x3a00de51, - 0x8051d7c8, 0x1661d0bf, 0xb5f4b421, 0x23c4b356, 0x9995bacf, - 0x0fa5bdb8, 0x9eb80228, 0x0888055f, 0xb2d90cc6, 0x24e90bb1, - 0x877c6f2f, 0x114c6858, 0xab1d61c1, 0x3d2d66b6, 0x9041dc76, - 0x0671db01, 0xbc20d298, 0x2a10d5ef, 0x8985b171, 0x1fb5b606, - 0xa5e4bf9f, 0x33d4b8e8, 0xa2c90778, 0x34f9000f, 0x8ea80996, - 0x18980ee1, 0xbb0d6a7f, 0x2d3d6d08, 0x976c6491, 0x015c63e6, - 0xf4516b6b, 0x62616c1c, 0xd8306585, 0x4e0062f2, 0xed95066c, - 0x7ba5011b, 0xc1f40882, 0x57c40ff5, 0xc6d9b065, 0x50e9b712, - 0xeab8be8b, 0x7c88b9fc, 0xdf1ddd62, 0x492dda15, 0xf37cd38c, - 0x654cd4fb, 0x5861b24d, 0xce51b53a, 0x7400bca3, 0xe230bbd4, - 0x41a5df4a, 0xd795d83d, 0x6dc4d1a4, 0xfbf4d6d3, 0x6ae96943, - 0xfcd96e34, 0x468867ad, 0xd0b860da, 0x732d0444, 0xe51d0333, - 0x5f4c0aaa, 0xc97c0ddd, 0x3c710550, 0xaa410227, 0x10100bbe, - 0x86200cc9, 0x25b56857, 0xb3856f20, 0x09d466b9, 0x9fe461ce, - 0x0ef9de5e, 0x98c9d929, 0x2298d0b0, 0xb4a8d7c7, 0x173db359, - 0x810db42e, 0x3b5cbdb7, 0xad6cbac0, 0x2083b8ed, 0xb6b3bf9a, - 0x0ce2b603, 0x9ad2b174, 0x3947d5ea, 0xaf77d29d, 0x1526db04, - 0x8316dc73, 0x120b63e3, 0x843b6494, 0x3e6a6d0d, 0xa85a6a7a, - 0x0bcf0ee4, 0x9dff0993, 0x27ae000a, 0xb19e077d, 0x44930ff0, - 0xd2a30887, 0x68f2011e, 0xfec20669, 0x5d5762f7, 0xcb676580, - 0x71366c19, 0xe7066b6e, 0x761bd4fe, 0xe02bd389, 0x5a7ada10, - 0xcc4add67, 0x6fdfb9f9, 0xf9efbe8e, 0x43beb717, 0xd58eb060, - 0xe8a3d6d6, 0x7e93d1a1, 0xc4c2d838, 0x52f2df4f, 0xf167bbd1, - 0x6757bca6, 0xdd06b53f, 0x4b36b248, 0xda2b0dd8, 0x4c1b0aaf, - 0xf64a0336, 0x607a0441, 0xc3ef60df, 0x55df67a8, 0xef8e6e31, - 0x79be6946, 0x8cb361cb, 0x1a8366bc, 0xa0d26f25, 0x36e26852, - 0x95770ccc, 0x03470bbb, 0xb9160222, 0x2f260555, 0xbe3bbac5, - 0x280bbdb2, 0x925ab42b, 0x046ab35c, 0xa7ffd7c2, 0x31cfd0b5, - 0x8b9ed92c, 0x1daede5b, 0xb0c2649b, 0x26f263ec, 0x9ca36a75, - 0x0a936d02, 0xa906099c, 0x3f360eeb, 0x85670772, 0x13570005, - 0x824abf95, 0x147ab8e2, 0xae2bb17b, 0x381bb60c, 0x9b8ed292, - 0x0dbed5e5, 0xb7efdc7c, 0x21dfdb0b, 0xd4d2d386, 0x42e2d4f1, - 0xf8b3dd68, 0x6e83da1f, 0xcd16be81, 0x5b26b9f6, 0xe177b06f, - 0x7747b718, 0xe65a0888, 0x706a0fff, 0xca3b0666, 0x5c0b0111, - 0xff9e658f, 0x69ae62f8, 0xd3ff6b61, 0x45cf6c16, 0x78e20aa0, - 0xeed20dd7, 0x5483044e, 0xc2b30339, 0x612667a7, 0xf71660d0, - 0x4d476949, 0xdb776e3e, 0x4a6ad1ae, 0xdc5ad6d9, 0x660bdf40, - 0xf03bd837, 0x53aebca9, 0xc59ebbde, 0x7fcfb247, 0xe9ffb530, - 0x1cf2bdbd, 0x8ac2baca, 0x3093b353, 0xa6a3b424, 0x0536d0ba, - 0x9306d7cd, 0x2957de54, 0xbf67d923, 0x2e7a66b3, 0xb84a61c4, - 0x021b685d, 0x942b6f2a, 0x37be0bb4, 0xa18e0cc3, 0x1bdf055a, - 0x8def022d}; - -#endif - -#if N == 1 - -#if W == 8 - -local const z_crc_t FAR crc_braid_table[][256] = { - {0x00000000, 0xccaa009e, 0x4225077d, 0x8e8f07e3, 0x844a0efa, - 0x48e00e64, 0xc66f0987, 0x0ac50919, 0xd3e51bb5, 0x1f4f1b2b, - 0x91c01cc8, 0x5d6a1c56, 0x57af154f, 0x9b0515d1, 0x158a1232, - 0xd92012ac, 0x7cbb312b, 0xb01131b5, 0x3e9e3656, 0xf23436c8, - 0xf8f13fd1, 0x345b3f4f, 0xbad438ac, 0x767e3832, 0xaf5e2a9e, - 0x63f42a00, 0xed7b2de3, 0x21d12d7d, 0x2b142464, 0xe7be24fa, - 0x69312319, 0xa59b2387, 0xf9766256, 0x35dc62c8, 0xbb53652b, - 0x77f965b5, 0x7d3c6cac, 0xb1966c32, 0x3f196bd1, 0xf3b36b4f, - 0x2a9379e3, 0xe639797d, 0x68b67e9e, 0xa41c7e00, 0xaed97719, - 0x62737787, 0xecfc7064, 0x205670fa, 0x85cd537d, 0x496753e3, - 0xc7e85400, 0x0b42549e, 0x01875d87, 0xcd2d5d19, 0x43a25afa, - 0x8f085a64, 0x562848c8, 0x9a824856, 0x140d4fb5, 0xd8a74f2b, - 0xd2624632, 0x1ec846ac, 0x9047414f, 0x5ced41d1, 0x299dc2ed, - 0xe537c273, 0x6bb8c590, 0xa712c50e, 0xadd7cc17, 0x617dcc89, - 0xeff2cb6a, 0x2358cbf4, 0xfa78d958, 0x36d2d9c6, 0xb85dde25, - 0x74f7debb, 0x7e32d7a2, 0xb298d73c, 0x3c17d0df, 0xf0bdd041, - 0x5526f3c6, 0x998cf358, 0x1703f4bb, 0xdba9f425, 0xd16cfd3c, - 0x1dc6fda2, 0x9349fa41, 0x5fe3fadf, 0x86c3e873, 0x4a69e8ed, - 0xc4e6ef0e, 0x084cef90, 0x0289e689, 0xce23e617, 0x40ace1f4, - 0x8c06e16a, 0xd0eba0bb, 0x1c41a025, 0x92cea7c6, 0x5e64a758, - 0x54a1ae41, 0x980baedf, 0x1684a93c, 0xda2ea9a2, 0x030ebb0e, - 0xcfa4bb90, 0x412bbc73, 0x8d81bced, 0x8744b5f4, 0x4beeb56a, - 0xc561b289, 0x09cbb217, 0xac509190, 0x60fa910e, 0xee7596ed, - 0x22df9673, 0x281a9f6a, 0xe4b09ff4, 0x6a3f9817, 0xa6959889, - 0x7fb58a25, 0xb31f8abb, 0x3d908d58, 0xf13a8dc6, 0xfbff84df, - 0x37558441, 0xb9da83a2, 0x7570833c, 0x533b85da, 0x9f918544, - 0x111e82a7, 0xddb48239, 0xd7718b20, 0x1bdb8bbe, 0x95548c5d, - 0x59fe8cc3, 0x80de9e6f, 0x4c749ef1, 0xc2fb9912, 0x0e51998c, - 0x04949095, 0xc83e900b, 0x46b197e8, 0x8a1b9776, 0x2f80b4f1, - 0xe32ab46f, 0x6da5b38c, 0xa10fb312, 0xabcaba0b, 0x6760ba95, - 0xe9efbd76, 0x2545bde8, 0xfc65af44, 0x30cfafda, 0xbe40a839, - 0x72eaa8a7, 0x782fa1be, 0xb485a120, 0x3a0aa6c3, 0xf6a0a65d, - 0xaa4de78c, 0x66e7e712, 0xe868e0f1, 0x24c2e06f, 0x2e07e976, - 0xe2ade9e8, 0x6c22ee0b, 0xa088ee95, 0x79a8fc39, 0xb502fca7, - 0x3b8dfb44, 0xf727fbda, 0xfde2f2c3, 0x3148f25d, 0xbfc7f5be, - 0x736df520, 0xd6f6d6a7, 0x1a5cd639, 0x94d3d1da, 0x5879d144, - 0x52bcd85d, 0x9e16d8c3, 0x1099df20, 0xdc33dfbe, 0x0513cd12, - 0xc9b9cd8c, 0x4736ca6f, 0x8b9ccaf1, 0x8159c3e8, 0x4df3c376, - 0xc37cc495, 0x0fd6c40b, 0x7aa64737, 0xb60c47a9, 0x3883404a, - 0xf42940d4, 0xfeec49cd, 0x32464953, 0xbcc94eb0, 0x70634e2e, - 0xa9435c82, 0x65e95c1c, 0xeb665bff, 0x27cc5b61, 0x2d095278, - 0xe1a352e6, 0x6f2c5505, 0xa386559b, 0x061d761c, 0xcab77682, - 0x44387161, 0x889271ff, 0x825778e6, 0x4efd7878, 0xc0727f9b, - 0x0cd87f05, 0xd5f86da9, 0x19526d37, 0x97dd6ad4, 0x5b776a4a, - 0x51b26353, 0x9d1863cd, 0x1397642e, 0xdf3d64b0, 0x83d02561, - 0x4f7a25ff, 0xc1f5221c, 0x0d5f2282, 0x079a2b9b, 0xcb302b05, - 0x45bf2ce6, 0x89152c78, 0x50353ed4, 0x9c9f3e4a, 0x121039a9, - 0xdeba3937, 0xd47f302e, 0x18d530b0, 0x965a3753, 0x5af037cd, - 0xff6b144a, 0x33c114d4, 0xbd4e1337, 0x71e413a9, 0x7b211ab0, - 0xb78b1a2e, 0x39041dcd, 0xf5ae1d53, 0x2c8e0fff, 0xe0240f61, - 0x6eab0882, 0xa201081c, 0xa8c40105, 0x646e019b, 0xeae10678, - 0x264b06e6}, - {0x00000000, 0xa6770bb4, 0x979f1129, 0x31e81a9d, 0xf44f2413, - 0x52382fa7, 0x63d0353a, 0xc5a73e8e, 0x33ef4e67, 0x959845d3, - 0xa4705f4e, 0x020754fa, 0xc7a06a74, 0x61d761c0, 0x503f7b5d, - 0xf64870e9, 0x67de9cce, 0xc1a9977a, 0xf0418de7, 0x56368653, - 0x9391b8dd, 0x35e6b369, 0x040ea9f4, 0xa279a240, 0x5431d2a9, - 0xf246d91d, 0xc3aec380, 0x65d9c834, 0xa07ef6ba, 0x0609fd0e, - 0x37e1e793, 0x9196ec27, 0xcfbd399c, 0x69ca3228, 0x582228b5, - 0xfe552301, 0x3bf21d8f, 0x9d85163b, 0xac6d0ca6, 0x0a1a0712, - 0xfc5277fb, 0x5a257c4f, 0x6bcd66d2, 0xcdba6d66, 0x081d53e8, - 0xae6a585c, 0x9f8242c1, 0x39f54975, 0xa863a552, 0x0e14aee6, - 0x3ffcb47b, 0x998bbfcf, 0x5c2c8141, 0xfa5b8af5, 0xcbb39068, - 0x6dc49bdc, 0x9b8ceb35, 0x3dfbe081, 0x0c13fa1c, 0xaa64f1a8, - 0x6fc3cf26, 0xc9b4c492, 0xf85cde0f, 0x5e2bd5bb, 0x440b7579, - 0xe27c7ecd, 0xd3946450, 0x75e36fe4, 0xb044516a, 0x16335ade, - 0x27db4043, 0x81ac4bf7, 0x77e43b1e, 0xd19330aa, 0xe07b2a37, - 0x460c2183, 0x83ab1f0d, 0x25dc14b9, 0x14340e24, 0xb2430590, - 0x23d5e9b7, 0x85a2e203, 0xb44af89e, 0x123df32a, 0xd79acda4, - 0x71edc610, 0x4005dc8d, 0xe672d739, 0x103aa7d0, 0xb64dac64, - 0x87a5b6f9, 0x21d2bd4d, 0xe47583c3, 0x42028877, 0x73ea92ea, - 0xd59d995e, 0x8bb64ce5, 0x2dc14751, 0x1c295dcc, 0xba5e5678, - 0x7ff968f6, 0xd98e6342, 0xe86679df, 0x4e11726b, 0xb8590282, - 0x1e2e0936, 0x2fc613ab, 0x89b1181f, 0x4c162691, 0xea612d25, - 0xdb8937b8, 0x7dfe3c0c, 0xec68d02b, 0x4a1fdb9f, 0x7bf7c102, - 0xdd80cab6, 0x1827f438, 0xbe50ff8c, 0x8fb8e511, 0x29cfeea5, - 0xdf879e4c, 0x79f095f8, 0x48188f65, 0xee6f84d1, 0x2bc8ba5f, - 0x8dbfb1eb, 0xbc57ab76, 0x1a20a0c2, 0x8816eaf2, 0x2e61e146, - 0x1f89fbdb, 0xb9fef06f, 0x7c59cee1, 0xda2ec555, 0xebc6dfc8, - 0x4db1d47c, 0xbbf9a495, 0x1d8eaf21, 0x2c66b5bc, 0x8a11be08, - 0x4fb68086, 0xe9c18b32, 0xd82991af, 0x7e5e9a1b, 0xefc8763c, - 0x49bf7d88, 0x78576715, 0xde206ca1, 0x1b87522f, 0xbdf0599b, - 0x8c184306, 0x2a6f48b2, 0xdc27385b, 0x7a5033ef, 0x4bb82972, - 0xedcf22c6, 0x28681c48, 0x8e1f17fc, 0xbff70d61, 0x198006d5, - 0x47abd36e, 0xe1dcd8da, 0xd034c247, 0x7643c9f3, 0xb3e4f77d, - 0x1593fcc9, 0x247be654, 0x820cede0, 0x74449d09, 0xd23396bd, - 0xe3db8c20, 0x45ac8794, 0x800bb91a, 0x267cb2ae, 0x1794a833, - 0xb1e3a387, 0x20754fa0, 0x86024414, 0xb7ea5e89, 0x119d553d, - 0xd43a6bb3, 0x724d6007, 0x43a57a9a, 0xe5d2712e, 0x139a01c7, - 0xb5ed0a73, 0x840510ee, 0x22721b5a, 0xe7d525d4, 0x41a22e60, - 0x704a34fd, 0xd63d3f49, 0xcc1d9f8b, 0x6a6a943f, 0x5b828ea2, - 0xfdf58516, 0x3852bb98, 0x9e25b02c, 0xafcdaab1, 0x09baa105, - 0xfff2d1ec, 0x5985da58, 0x686dc0c5, 0xce1acb71, 0x0bbdf5ff, - 0xadcafe4b, 0x9c22e4d6, 0x3a55ef62, 0xabc30345, 0x0db408f1, - 0x3c5c126c, 0x9a2b19d8, 0x5f8c2756, 0xf9fb2ce2, 0xc813367f, - 0x6e643dcb, 0x982c4d22, 0x3e5b4696, 0x0fb35c0b, 0xa9c457bf, - 0x6c636931, 0xca146285, 0xfbfc7818, 0x5d8b73ac, 0x03a0a617, - 0xa5d7ada3, 0x943fb73e, 0x3248bc8a, 0xf7ef8204, 0x519889b0, - 0x6070932d, 0xc6079899, 0x304fe870, 0x9638e3c4, 0xa7d0f959, - 0x01a7f2ed, 0xc400cc63, 0x6277c7d7, 0x539fdd4a, 0xf5e8d6fe, - 0x647e3ad9, 0xc209316d, 0xf3e12bf0, 0x55962044, 0x90311eca, - 0x3646157e, 0x07ae0fe3, 0xa1d90457, 0x579174be, 0xf1e67f0a, - 0xc00e6597, 0x66796e23, 0xa3de50ad, 0x05a95b19, 0x34414184, - 0x92364a30}, - {0x00000000, 0xcb5cd3a5, 0x4dc8a10b, 0x869472ae, 0x9b914216, - 0x50cd91b3, 0xd659e31d, 0x1d0530b8, 0xec53826d, 0x270f51c8, - 0xa19b2366, 0x6ac7f0c3, 0x77c2c07b, 0xbc9e13de, 0x3a0a6170, - 0xf156b2d5, 0x03d6029b, 0xc88ad13e, 0x4e1ea390, 0x85427035, - 0x9847408d, 0x531b9328, 0xd58fe186, 0x1ed33223, 0xef8580f6, - 0x24d95353, 0xa24d21fd, 0x6911f258, 0x7414c2e0, 0xbf481145, - 0x39dc63eb, 0xf280b04e, 0x07ac0536, 0xccf0d693, 0x4a64a43d, - 0x81387798, 0x9c3d4720, 0x57619485, 0xd1f5e62b, 0x1aa9358e, - 0xebff875b, 0x20a354fe, 0xa6372650, 0x6d6bf5f5, 0x706ec54d, - 0xbb3216e8, 0x3da66446, 0xf6fab7e3, 0x047a07ad, 0xcf26d408, - 0x49b2a6a6, 0x82ee7503, 0x9feb45bb, 0x54b7961e, 0xd223e4b0, - 0x197f3715, 0xe82985c0, 0x23755665, 0xa5e124cb, 0x6ebdf76e, - 0x73b8c7d6, 0xb8e41473, 0x3e7066dd, 0xf52cb578, 0x0f580a6c, - 0xc404d9c9, 0x4290ab67, 0x89cc78c2, 0x94c9487a, 0x5f959bdf, - 0xd901e971, 0x125d3ad4, 0xe30b8801, 0x28575ba4, 0xaec3290a, - 0x659ffaaf, 0x789aca17, 0xb3c619b2, 0x35526b1c, 0xfe0eb8b9, - 0x0c8e08f7, 0xc7d2db52, 0x4146a9fc, 0x8a1a7a59, 0x971f4ae1, - 0x5c439944, 0xdad7ebea, 0x118b384f, 0xe0dd8a9a, 0x2b81593f, - 0xad152b91, 0x6649f834, 0x7b4cc88c, 0xb0101b29, 0x36846987, - 0xfdd8ba22, 0x08f40f5a, 0xc3a8dcff, 0x453cae51, 0x8e607df4, - 0x93654d4c, 0x58399ee9, 0xdeadec47, 0x15f13fe2, 0xe4a78d37, - 0x2ffb5e92, 0xa96f2c3c, 0x6233ff99, 0x7f36cf21, 0xb46a1c84, - 0x32fe6e2a, 0xf9a2bd8f, 0x0b220dc1, 0xc07ede64, 0x46eaacca, - 0x8db67f6f, 0x90b34fd7, 0x5bef9c72, 0xdd7beedc, 0x16273d79, - 0xe7718fac, 0x2c2d5c09, 0xaab92ea7, 0x61e5fd02, 0x7ce0cdba, - 0xb7bc1e1f, 0x31286cb1, 0xfa74bf14, 0x1eb014d8, 0xd5ecc77d, - 0x5378b5d3, 0x98246676, 0x852156ce, 0x4e7d856b, 0xc8e9f7c5, - 0x03b52460, 0xf2e396b5, 0x39bf4510, 0xbf2b37be, 0x7477e41b, - 0x6972d4a3, 0xa22e0706, 0x24ba75a8, 0xefe6a60d, 0x1d661643, - 0xd63ac5e6, 0x50aeb748, 0x9bf264ed, 0x86f75455, 0x4dab87f0, - 0xcb3ff55e, 0x006326fb, 0xf135942e, 0x3a69478b, 0xbcfd3525, - 0x77a1e680, 0x6aa4d638, 0xa1f8059d, 0x276c7733, 0xec30a496, - 0x191c11ee, 0xd240c24b, 0x54d4b0e5, 0x9f886340, 0x828d53f8, - 0x49d1805d, 0xcf45f2f3, 0x04192156, 0xf54f9383, 0x3e134026, - 0xb8873288, 0x73dbe12d, 0x6eded195, 0xa5820230, 0x2316709e, - 0xe84aa33b, 0x1aca1375, 0xd196c0d0, 0x5702b27e, 0x9c5e61db, - 0x815b5163, 0x4a0782c6, 0xcc93f068, 0x07cf23cd, 0xf6999118, - 0x3dc542bd, 0xbb513013, 0x700de3b6, 0x6d08d30e, 0xa65400ab, - 0x20c07205, 0xeb9ca1a0, 0x11e81eb4, 0xdab4cd11, 0x5c20bfbf, - 0x977c6c1a, 0x8a795ca2, 0x41258f07, 0xc7b1fda9, 0x0ced2e0c, - 0xfdbb9cd9, 0x36e74f7c, 0xb0733dd2, 0x7b2fee77, 0x662adecf, - 0xad760d6a, 0x2be27fc4, 0xe0beac61, 0x123e1c2f, 0xd962cf8a, - 0x5ff6bd24, 0x94aa6e81, 0x89af5e39, 0x42f38d9c, 0xc467ff32, - 0x0f3b2c97, 0xfe6d9e42, 0x35314de7, 0xb3a53f49, 0x78f9ecec, - 0x65fcdc54, 0xaea00ff1, 0x28347d5f, 0xe368aefa, 0x16441b82, - 0xdd18c827, 0x5b8cba89, 0x90d0692c, 0x8dd55994, 0x46898a31, - 0xc01df89f, 0x0b412b3a, 0xfa1799ef, 0x314b4a4a, 0xb7df38e4, - 0x7c83eb41, 0x6186dbf9, 0xaada085c, 0x2c4e7af2, 0xe712a957, - 0x15921919, 0xdececabc, 0x585ab812, 0x93066bb7, 0x8e035b0f, - 0x455f88aa, 0xc3cbfa04, 0x089729a1, 0xf9c19b74, 0x329d48d1, - 0xb4093a7f, 0x7f55e9da, 0x6250d962, 0xa90c0ac7, 0x2f987869, - 0xe4c4abcc}, - {0x00000000, 0x3d6029b0, 0x7ac05360, 0x47a07ad0, 0xf580a6c0, - 0xc8e08f70, 0x8f40f5a0, 0xb220dc10, 0x30704bc1, 0x0d106271, - 0x4ab018a1, 0x77d03111, 0xc5f0ed01, 0xf890c4b1, 0xbf30be61, - 0x825097d1, 0x60e09782, 0x5d80be32, 0x1a20c4e2, 0x2740ed52, - 0x95603142, 0xa80018f2, 0xefa06222, 0xd2c04b92, 0x5090dc43, - 0x6df0f5f3, 0x2a508f23, 0x1730a693, 0xa5107a83, 0x98705333, - 0xdfd029e3, 0xe2b00053, 0xc1c12f04, 0xfca106b4, 0xbb017c64, - 0x866155d4, 0x344189c4, 0x0921a074, 0x4e81daa4, 0x73e1f314, - 0xf1b164c5, 0xccd14d75, 0x8b7137a5, 0xb6111e15, 0x0431c205, - 0x3951ebb5, 0x7ef19165, 0x4391b8d5, 0xa121b886, 0x9c419136, - 0xdbe1ebe6, 0xe681c256, 0x54a11e46, 0x69c137f6, 0x2e614d26, - 0x13016496, 0x9151f347, 0xac31daf7, 0xeb91a027, 0xd6f18997, - 0x64d15587, 0x59b17c37, 0x1e1106e7, 0x23712f57, 0x58f35849, - 0x659371f9, 0x22330b29, 0x1f532299, 0xad73fe89, 0x9013d739, - 0xd7b3ade9, 0xead38459, 0x68831388, 0x55e33a38, 0x124340e8, - 0x2f236958, 0x9d03b548, 0xa0639cf8, 0xe7c3e628, 0xdaa3cf98, - 0x3813cfcb, 0x0573e67b, 0x42d39cab, 0x7fb3b51b, 0xcd93690b, - 0xf0f340bb, 0xb7533a6b, 0x8a3313db, 0x0863840a, 0x3503adba, - 0x72a3d76a, 0x4fc3feda, 0xfde322ca, 0xc0830b7a, 0x872371aa, - 0xba43581a, 0x9932774d, 0xa4525efd, 0xe3f2242d, 0xde920d9d, - 0x6cb2d18d, 0x51d2f83d, 0x167282ed, 0x2b12ab5d, 0xa9423c8c, - 0x9422153c, 0xd3826fec, 0xeee2465c, 0x5cc29a4c, 0x61a2b3fc, - 0x2602c92c, 0x1b62e09c, 0xf9d2e0cf, 0xc4b2c97f, 0x8312b3af, - 0xbe729a1f, 0x0c52460f, 0x31326fbf, 0x7692156f, 0x4bf23cdf, - 0xc9a2ab0e, 0xf4c282be, 0xb362f86e, 0x8e02d1de, 0x3c220dce, - 0x0142247e, 0x46e25eae, 0x7b82771e, 0xb1e6b092, 0x8c869922, - 0xcb26e3f2, 0xf646ca42, 0x44661652, 0x79063fe2, 0x3ea64532, - 0x03c66c82, 0x8196fb53, 0xbcf6d2e3, 0xfb56a833, 0xc6368183, - 0x74165d93, 0x49767423, 0x0ed60ef3, 0x33b62743, 0xd1062710, - 0xec660ea0, 0xabc67470, 0x96a65dc0, 0x248681d0, 0x19e6a860, - 0x5e46d2b0, 0x6326fb00, 0xe1766cd1, 0xdc164561, 0x9bb63fb1, - 0xa6d61601, 0x14f6ca11, 0x2996e3a1, 0x6e369971, 0x5356b0c1, - 0x70279f96, 0x4d47b626, 0x0ae7ccf6, 0x3787e546, 0x85a73956, - 0xb8c710e6, 0xff676a36, 0xc2074386, 0x4057d457, 0x7d37fde7, - 0x3a978737, 0x07f7ae87, 0xb5d77297, 0x88b75b27, 0xcf1721f7, - 0xf2770847, 0x10c70814, 0x2da721a4, 0x6a075b74, 0x576772c4, - 0xe547aed4, 0xd8278764, 0x9f87fdb4, 0xa2e7d404, 0x20b743d5, - 0x1dd76a65, 0x5a7710b5, 0x67173905, 0xd537e515, 0xe857cca5, - 0xaff7b675, 0x92979fc5, 0xe915e8db, 0xd475c16b, 0x93d5bbbb, - 0xaeb5920b, 0x1c954e1b, 0x21f567ab, 0x66551d7b, 0x5b3534cb, - 0xd965a31a, 0xe4058aaa, 0xa3a5f07a, 0x9ec5d9ca, 0x2ce505da, - 0x11852c6a, 0x562556ba, 0x6b457f0a, 0x89f57f59, 0xb49556e9, - 0xf3352c39, 0xce550589, 0x7c75d999, 0x4115f029, 0x06b58af9, - 0x3bd5a349, 0xb9853498, 0x84e51d28, 0xc34567f8, 0xfe254e48, - 0x4c059258, 0x7165bbe8, 0x36c5c138, 0x0ba5e888, 0x28d4c7df, - 0x15b4ee6f, 0x521494bf, 0x6f74bd0f, 0xdd54611f, 0xe03448af, - 0xa794327f, 0x9af41bcf, 0x18a48c1e, 0x25c4a5ae, 0x6264df7e, - 0x5f04f6ce, 0xed242ade, 0xd044036e, 0x97e479be, 0xaa84500e, - 0x4834505d, 0x755479ed, 0x32f4033d, 0x0f942a8d, 0xbdb4f69d, - 0x80d4df2d, 0xc774a5fd, 0xfa148c4d, 0x78441b9c, 0x4524322c, - 0x028448fc, 0x3fe4614c, 0x8dc4bd5c, 0xb0a494ec, 0xf704ee3c, - 0xca64c78c}, - {0x00000000, 0xb8bc6765, 0xaa09c88b, 0x12b5afee, 0x8f629757, - 0x37def032, 0x256b5fdc, 0x9dd738b9, 0xc5b428ef, 0x7d084f8a, - 0x6fbde064, 0xd7018701, 0x4ad6bfb8, 0xf26ad8dd, 0xe0df7733, - 0x58631056, 0x5019579f, 0xe8a530fa, 0xfa109f14, 0x42acf871, - 0xdf7bc0c8, 0x67c7a7ad, 0x75720843, 0xcdce6f26, 0x95ad7f70, - 0x2d111815, 0x3fa4b7fb, 0x8718d09e, 0x1acfe827, 0xa2738f42, - 0xb0c620ac, 0x087a47c9, 0xa032af3e, 0x188ec85b, 0x0a3b67b5, - 0xb28700d0, 0x2f503869, 0x97ec5f0c, 0x8559f0e2, 0x3de59787, - 0x658687d1, 0xdd3ae0b4, 0xcf8f4f5a, 0x7733283f, 0xeae41086, - 0x525877e3, 0x40edd80d, 0xf851bf68, 0xf02bf8a1, 0x48979fc4, - 0x5a22302a, 0xe29e574f, 0x7f496ff6, 0xc7f50893, 0xd540a77d, - 0x6dfcc018, 0x359fd04e, 0x8d23b72b, 0x9f9618c5, 0x272a7fa0, - 0xbafd4719, 0x0241207c, 0x10f48f92, 0xa848e8f7, 0x9b14583d, - 0x23a83f58, 0x311d90b6, 0x89a1f7d3, 0x1476cf6a, 0xaccaa80f, - 0xbe7f07e1, 0x06c36084, 0x5ea070d2, 0xe61c17b7, 0xf4a9b859, - 0x4c15df3c, 0xd1c2e785, 0x697e80e0, 0x7bcb2f0e, 0xc377486b, - 0xcb0d0fa2, 0x73b168c7, 0x6104c729, 0xd9b8a04c, 0x446f98f5, - 0xfcd3ff90, 0xee66507e, 0x56da371b, 0x0eb9274d, 0xb6054028, - 0xa4b0efc6, 0x1c0c88a3, 0x81dbb01a, 0x3967d77f, 0x2bd27891, - 0x936e1ff4, 0x3b26f703, 0x839a9066, 0x912f3f88, 0x299358ed, - 0xb4446054, 0x0cf80731, 0x1e4da8df, 0xa6f1cfba, 0xfe92dfec, - 0x462eb889, 0x549b1767, 0xec277002, 0x71f048bb, 0xc94c2fde, - 0xdbf98030, 0x6345e755, 0x6b3fa09c, 0xd383c7f9, 0xc1366817, - 0x798a0f72, 0xe45d37cb, 0x5ce150ae, 0x4e54ff40, 0xf6e89825, - 0xae8b8873, 0x1637ef16, 0x048240f8, 0xbc3e279d, 0x21e91f24, - 0x99557841, 0x8be0d7af, 0x335cb0ca, 0xed59b63b, 0x55e5d15e, - 0x47507eb0, 0xffec19d5, 0x623b216c, 0xda874609, 0xc832e9e7, - 0x708e8e82, 0x28ed9ed4, 0x9051f9b1, 0x82e4565f, 0x3a58313a, - 0xa78f0983, 0x1f336ee6, 0x0d86c108, 0xb53aa66d, 0xbd40e1a4, - 0x05fc86c1, 0x1749292f, 0xaff54e4a, 0x322276f3, 0x8a9e1196, - 0x982bbe78, 0x2097d91d, 0x78f4c94b, 0xc048ae2e, 0xd2fd01c0, - 0x6a4166a5, 0xf7965e1c, 0x4f2a3979, 0x5d9f9697, 0xe523f1f2, - 0x4d6b1905, 0xf5d77e60, 0xe762d18e, 0x5fdeb6eb, 0xc2098e52, - 0x7ab5e937, 0x680046d9, 0xd0bc21bc, 0x88df31ea, 0x3063568f, - 0x22d6f961, 0x9a6a9e04, 0x07bda6bd, 0xbf01c1d8, 0xadb46e36, - 0x15080953, 0x1d724e9a, 0xa5ce29ff, 0xb77b8611, 0x0fc7e174, - 0x9210d9cd, 0x2aacbea8, 0x38191146, 0x80a57623, 0xd8c66675, - 0x607a0110, 0x72cfaefe, 0xca73c99b, 0x57a4f122, 0xef189647, - 0xfdad39a9, 0x45115ecc, 0x764dee06, 0xcef18963, 0xdc44268d, - 0x64f841e8, 0xf92f7951, 0x41931e34, 0x5326b1da, 0xeb9ad6bf, - 0xb3f9c6e9, 0x0b45a18c, 0x19f00e62, 0xa14c6907, 0x3c9b51be, - 0x842736db, 0x96929935, 0x2e2efe50, 0x2654b999, 0x9ee8defc, - 0x8c5d7112, 0x34e11677, 0xa9362ece, 0x118a49ab, 0x033fe645, - 0xbb838120, 0xe3e09176, 0x5b5cf613, 0x49e959fd, 0xf1553e98, - 0x6c820621, 0xd43e6144, 0xc68bceaa, 0x7e37a9cf, 0xd67f4138, - 0x6ec3265d, 0x7c7689b3, 0xc4caeed6, 0x591dd66f, 0xe1a1b10a, - 0xf3141ee4, 0x4ba87981, 0x13cb69d7, 0xab770eb2, 0xb9c2a15c, - 0x017ec639, 0x9ca9fe80, 0x241599e5, 0x36a0360b, 0x8e1c516e, - 0x866616a7, 0x3eda71c2, 0x2c6fde2c, 0x94d3b949, 0x090481f0, - 0xb1b8e695, 0xa30d497b, 0x1bb12e1e, 0x43d23e48, 0xfb6e592d, - 0xe9dbf6c3, 0x516791a6, 0xccb0a91f, 0x740cce7a, 0x66b96194, - 0xde0506f1}, - {0x00000000, 0x01c26a37, 0x0384d46e, 0x0246be59, 0x0709a8dc, - 0x06cbc2eb, 0x048d7cb2, 0x054f1685, 0x0e1351b8, 0x0fd13b8f, - 0x0d9785d6, 0x0c55efe1, 0x091af964, 0x08d89353, 0x0a9e2d0a, - 0x0b5c473d, 0x1c26a370, 0x1de4c947, 0x1fa2771e, 0x1e601d29, - 0x1b2f0bac, 0x1aed619b, 0x18abdfc2, 0x1969b5f5, 0x1235f2c8, - 0x13f798ff, 0x11b126a6, 0x10734c91, 0x153c5a14, 0x14fe3023, - 0x16b88e7a, 0x177ae44d, 0x384d46e0, 0x398f2cd7, 0x3bc9928e, - 0x3a0bf8b9, 0x3f44ee3c, 0x3e86840b, 0x3cc03a52, 0x3d025065, - 0x365e1758, 0x379c7d6f, 0x35dac336, 0x3418a901, 0x3157bf84, - 0x3095d5b3, 0x32d36bea, 0x331101dd, 0x246be590, 0x25a98fa7, - 0x27ef31fe, 0x262d5bc9, 0x23624d4c, 0x22a0277b, 0x20e69922, - 0x2124f315, 0x2a78b428, 0x2bbade1f, 0x29fc6046, 0x283e0a71, - 0x2d711cf4, 0x2cb376c3, 0x2ef5c89a, 0x2f37a2ad, 0x709a8dc0, - 0x7158e7f7, 0x731e59ae, 0x72dc3399, 0x7793251c, 0x76514f2b, - 0x7417f172, 0x75d59b45, 0x7e89dc78, 0x7f4bb64f, 0x7d0d0816, - 0x7ccf6221, 0x798074a4, 0x78421e93, 0x7a04a0ca, 0x7bc6cafd, - 0x6cbc2eb0, 0x6d7e4487, 0x6f38fade, 0x6efa90e9, 0x6bb5866c, - 0x6a77ec5b, 0x68315202, 0x69f33835, 0x62af7f08, 0x636d153f, - 0x612bab66, 0x60e9c151, 0x65a6d7d4, 0x6464bde3, 0x662203ba, - 0x67e0698d, 0x48d7cb20, 0x4915a117, 0x4b531f4e, 0x4a917579, - 0x4fde63fc, 0x4e1c09cb, 0x4c5ab792, 0x4d98dda5, 0x46c49a98, - 0x4706f0af, 0x45404ef6, 0x448224c1, 0x41cd3244, 0x400f5873, - 0x4249e62a, 0x438b8c1d, 0x54f16850, 0x55330267, 0x5775bc3e, - 0x56b7d609, 0x53f8c08c, 0x523aaabb, 0x507c14e2, 0x51be7ed5, - 0x5ae239e8, 0x5b2053df, 0x5966ed86, 0x58a487b1, 0x5deb9134, - 0x5c29fb03, 0x5e6f455a, 0x5fad2f6d, 0xe1351b80, 0xe0f771b7, - 0xe2b1cfee, 0xe373a5d9, 0xe63cb35c, 0xe7fed96b, 0xe5b86732, - 0xe47a0d05, 0xef264a38, 0xeee4200f, 0xeca29e56, 0xed60f461, - 0xe82fe2e4, 0xe9ed88d3, 0xebab368a, 0xea695cbd, 0xfd13b8f0, - 0xfcd1d2c7, 0xfe976c9e, 0xff5506a9, 0xfa1a102c, 0xfbd87a1b, - 0xf99ec442, 0xf85cae75, 0xf300e948, 0xf2c2837f, 0xf0843d26, - 0xf1465711, 0xf4094194, 0xf5cb2ba3, 0xf78d95fa, 0xf64fffcd, - 0xd9785d60, 0xd8ba3757, 0xdafc890e, 0xdb3ee339, 0xde71f5bc, - 0xdfb39f8b, 0xddf521d2, 0xdc374be5, 0xd76b0cd8, 0xd6a966ef, - 0xd4efd8b6, 0xd52db281, 0xd062a404, 0xd1a0ce33, 0xd3e6706a, - 0xd2241a5d, 0xc55efe10, 0xc49c9427, 0xc6da2a7e, 0xc7184049, - 0xc25756cc, 0xc3953cfb, 0xc1d382a2, 0xc011e895, 0xcb4dafa8, - 0xca8fc59f, 0xc8c97bc6, 0xc90b11f1, 0xcc440774, 0xcd866d43, - 0xcfc0d31a, 0xce02b92d, 0x91af9640, 0x906dfc77, 0x922b422e, - 0x93e92819, 0x96a63e9c, 0x976454ab, 0x9522eaf2, 0x94e080c5, - 0x9fbcc7f8, 0x9e7eadcf, 0x9c381396, 0x9dfa79a1, 0x98b56f24, - 0x99770513, 0x9b31bb4a, 0x9af3d17d, 0x8d893530, 0x8c4b5f07, - 0x8e0de15e, 0x8fcf8b69, 0x8a809dec, 0x8b42f7db, 0x89044982, - 0x88c623b5, 0x839a6488, 0x82580ebf, 0x801eb0e6, 0x81dcdad1, - 0x8493cc54, 0x8551a663, 0x8717183a, 0x86d5720d, 0xa9e2d0a0, - 0xa820ba97, 0xaa6604ce, 0xaba46ef9, 0xaeeb787c, 0xaf29124b, - 0xad6fac12, 0xacadc625, 0xa7f18118, 0xa633eb2f, 0xa4755576, - 0xa5b73f41, 0xa0f829c4, 0xa13a43f3, 0xa37cfdaa, 0xa2be979d, - 0xb5c473d0, 0xb40619e7, 0xb640a7be, 0xb782cd89, 0xb2cddb0c, - 0xb30fb13b, 0xb1490f62, 0xb08b6555, 0xbbd72268, 0xba15485f, - 0xb853f606, 0xb9919c31, 0xbcde8ab4, 0xbd1ce083, 0xbf5a5eda, - 0xbe9834ed}, - {0x00000000, 0x191b3141, 0x32366282, 0x2b2d53c3, 0x646cc504, - 0x7d77f445, 0x565aa786, 0x4f4196c7, 0xc8d98a08, 0xd1c2bb49, - 0xfaefe88a, 0xe3f4d9cb, 0xacb54f0c, 0xb5ae7e4d, 0x9e832d8e, - 0x87981ccf, 0x4ac21251, 0x53d92310, 0x78f470d3, 0x61ef4192, - 0x2eaed755, 0x37b5e614, 0x1c98b5d7, 0x05838496, 0x821b9859, - 0x9b00a918, 0xb02dfadb, 0xa936cb9a, 0xe6775d5d, 0xff6c6c1c, - 0xd4413fdf, 0xcd5a0e9e, 0x958424a2, 0x8c9f15e3, 0xa7b24620, - 0xbea97761, 0xf1e8e1a6, 0xe8f3d0e7, 0xc3de8324, 0xdac5b265, - 0x5d5daeaa, 0x44469feb, 0x6f6bcc28, 0x7670fd69, 0x39316bae, - 0x202a5aef, 0x0b07092c, 0x121c386d, 0xdf4636f3, 0xc65d07b2, - 0xed705471, 0xf46b6530, 0xbb2af3f7, 0xa231c2b6, 0x891c9175, - 0x9007a034, 0x179fbcfb, 0x0e848dba, 0x25a9de79, 0x3cb2ef38, - 0x73f379ff, 0x6ae848be, 0x41c51b7d, 0x58de2a3c, 0xf0794f05, - 0xe9627e44, 0xc24f2d87, 0xdb541cc6, 0x94158a01, 0x8d0ebb40, - 0xa623e883, 0xbf38d9c2, 0x38a0c50d, 0x21bbf44c, 0x0a96a78f, - 0x138d96ce, 0x5ccc0009, 0x45d73148, 0x6efa628b, 0x77e153ca, - 0xbabb5d54, 0xa3a06c15, 0x888d3fd6, 0x91960e97, 0xded79850, - 0xc7cca911, 0xece1fad2, 0xf5facb93, 0x7262d75c, 0x6b79e61d, - 0x4054b5de, 0x594f849f, 0x160e1258, 0x0f152319, 0x243870da, - 0x3d23419b, 0x65fd6ba7, 0x7ce65ae6, 0x57cb0925, 0x4ed03864, - 0x0191aea3, 0x188a9fe2, 0x33a7cc21, 0x2abcfd60, 0xad24e1af, - 0xb43fd0ee, 0x9f12832d, 0x8609b26c, 0xc94824ab, 0xd05315ea, - 0xfb7e4629, 0xe2657768, 0x2f3f79f6, 0x362448b7, 0x1d091b74, - 0x04122a35, 0x4b53bcf2, 0x52488db3, 0x7965de70, 0x607eef31, - 0xe7e6f3fe, 0xfefdc2bf, 0xd5d0917c, 0xcccba03d, 0x838a36fa, - 0x9a9107bb, 0xb1bc5478, 0xa8a76539, 0x3b83984b, 0x2298a90a, - 0x09b5fac9, 0x10aecb88, 0x5fef5d4f, 0x46f46c0e, 0x6dd93fcd, - 0x74c20e8c, 0xf35a1243, 0xea412302, 0xc16c70c1, 0xd8774180, - 0x9736d747, 0x8e2de606, 0xa500b5c5, 0xbc1b8484, 0x71418a1a, - 0x685abb5b, 0x4377e898, 0x5a6cd9d9, 0x152d4f1e, 0x0c367e5f, - 0x271b2d9c, 0x3e001cdd, 0xb9980012, 0xa0833153, 0x8bae6290, - 0x92b553d1, 0xddf4c516, 0xc4eff457, 0xefc2a794, 0xf6d996d5, - 0xae07bce9, 0xb71c8da8, 0x9c31de6b, 0x852aef2a, 0xca6b79ed, - 0xd37048ac, 0xf85d1b6f, 0xe1462a2e, 0x66de36e1, 0x7fc507a0, - 0x54e85463, 0x4df36522, 0x02b2f3e5, 0x1ba9c2a4, 0x30849167, - 0x299fa026, 0xe4c5aeb8, 0xfdde9ff9, 0xd6f3cc3a, 0xcfe8fd7b, - 0x80a96bbc, 0x99b25afd, 0xb29f093e, 0xab84387f, 0x2c1c24b0, - 0x350715f1, 0x1e2a4632, 0x07317773, 0x4870e1b4, 0x516bd0f5, - 0x7a468336, 0x635db277, 0xcbfad74e, 0xd2e1e60f, 0xf9ccb5cc, - 0xe0d7848d, 0xaf96124a, 0xb68d230b, 0x9da070c8, 0x84bb4189, - 0x03235d46, 0x1a386c07, 0x31153fc4, 0x280e0e85, 0x674f9842, - 0x7e54a903, 0x5579fac0, 0x4c62cb81, 0x8138c51f, 0x9823f45e, - 0xb30ea79d, 0xaa1596dc, 0xe554001b, 0xfc4f315a, 0xd7626299, - 0xce7953d8, 0x49e14f17, 0x50fa7e56, 0x7bd72d95, 0x62cc1cd4, - 0x2d8d8a13, 0x3496bb52, 0x1fbbe891, 0x06a0d9d0, 0x5e7ef3ec, - 0x4765c2ad, 0x6c48916e, 0x7553a02f, 0x3a1236e8, 0x230907a9, - 0x0824546a, 0x113f652b, 0x96a779e4, 0x8fbc48a5, 0xa4911b66, - 0xbd8a2a27, 0xf2cbbce0, 0xebd08da1, 0xc0fdde62, 0xd9e6ef23, - 0x14bce1bd, 0x0da7d0fc, 0x268a833f, 0x3f91b27e, 0x70d024b9, - 0x69cb15f8, 0x42e6463b, 0x5bfd777a, 0xdc656bb5, 0xc57e5af4, - 0xee530937, 0xf7483876, 0xb809aeb1, 0xa1129ff0, 0x8a3fcc33, - 0x9324fd72}, - {0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, - 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, - 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, - 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, - 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, - 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, - 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, - 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, - 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, - 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, - 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, - 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, - 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, - 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, - 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, - 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, - 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, - 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, - 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, - 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, - 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, - 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, - 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, - 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, - 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, - 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, - 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, - 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, - 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, - 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, - 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, - 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, - 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, - 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, - 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, - 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, - 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, - 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, - 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, - 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, - 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, - 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, - 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, - 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, - 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, - 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, - 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, - 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, - 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, - 0x2d02ef8d}}; - -local const z_word_t FAR crc_braid_big_table[][256] = { - {0x0000000000000000, 0x9630077700000000, 0x2c610eee00000000, - 0xba51099900000000, 0x19c46d0700000000, 0x8ff46a7000000000, - 0x35a563e900000000, 0xa395649e00000000, 0x3288db0e00000000, - 0xa4b8dc7900000000, 0x1ee9d5e000000000, 0x88d9d29700000000, - 0x2b4cb60900000000, 0xbd7cb17e00000000, 0x072db8e700000000, - 0x911dbf9000000000, 0x6410b71d00000000, 0xf220b06a00000000, - 0x4871b9f300000000, 0xde41be8400000000, 0x7dd4da1a00000000, - 0xebe4dd6d00000000, 0x51b5d4f400000000, 0xc785d38300000000, - 0x56986c1300000000, 0xc0a86b6400000000, 0x7af962fd00000000, - 0xecc9658a00000000, 0x4f5c011400000000, 0xd96c066300000000, - 0x633d0ffa00000000, 0xf50d088d00000000, 0xc8206e3b00000000, - 0x5e10694c00000000, 0xe44160d500000000, 0x727167a200000000, - 0xd1e4033c00000000, 0x47d4044b00000000, 0xfd850dd200000000, - 0x6bb50aa500000000, 0xfaa8b53500000000, 0x6c98b24200000000, - 0xd6c9bbdb00000000, 0x40f9bcac00000000, 0xe36cd83200000000, - 0x755cdf4500000000, 0xcf0dd6dc00000000, 0x593dd1ab00000000, - 0xac30d92600000000, 0x3a00de5100000000, 0x8051d7c800000000, - 0x1661d0bf00000000, 0xb5f4b42100000000, 0x23c4b35600000000, - 0x9995bacf00000000, 0x0fa5bdb800000000, 0x9eb8022800000000, - 0x0888055f00000000, 0xb2d90cc600000000, 0x24e90bb100000000, - 0x877c6f2f00000000, 0x114c685800000000, 0xab1d61c100000000, - 0x3d2d66b600000000, 0x9041dc7600000000, 0x0671db0100000000, - 0xbc20d29800000000, 0x2a10d5ef00000000, 0x8985b17100000000, - 0x1fb5b60600000000, 0xa5e4bf9f00000000, 0x33d4b8e800000000, - 0xa2c9077800000000, 0x34f9000f00000000, 0x8ea8099600000000, - 0x18980ee100000000, 0xbb0d6a7f00000000, 0x2d3d6d0800000000, - 0x976c649100000000, 0x015c63e600000000, 0xf4516b6b00000000, - 0x62616c1c00000000, 0xd830658500000000, 0x4e0062f200000000, - 0xed95066c00000000, 0x7ba5011b00000000, 0xc1f4088200000000, - 0x57c40ff500000000, 0xc6d9b06500000000, 0x50e9b71200000000, - 0xeab8be8b00000000, 0x7c88b9fc00000000, 0xdf1ddd6200000000, - 0x492dda1500000000, 0xf37cd38c00000000, 0x654cd4fb00000000, - 0x5861b24d00000000, 0xce51b53a00000000, 0x7400bca300000000, - 0xe230bbd400000000, 0x41a5df4a00000000, 0xd795d83d00000000, - 0x6dc4d1a400000000, 0xfbf4d6d300000000, 0x6ae9694300000000, - 0xfcd96e3400000000, 0x468867ad00000000, 0xd0b860da00000000, - 0x732d044400000000, 0xe51d033300000000, 0x5f4c0aaa00000000, - 0xc97c0ddd00000000, 0x3c71055000000000, 0xaa41022700000000, - 0x10100bbe00000000, 0x86200cc900000000, 0x25b5685700000000, - 0xb3856f2000000000, 0x09d466b900000000, 0x9fe461ce00000000, - 0x0ef9de5e00000000, 0x98c9d92900000000, 0x2298d0b000000000, - 0xb4a8d7c700000000, 0x173db35900000000, 0x810db42e00000000, - 0x3b5cbdb700000000, 0xad6cbac000000000, 0x2083b8ed00000000, - 0xb6b3bf9a00000000, 0x0ce2b60300000000, 0x9ad2b17400000000, - 0x3947d5ea00000000, 0xaf77d29d00000000, 0x1526db0400000000, - 0x8316dc7300000000, 0x120b63e300000000, 0x843b649400000000, - 0x3e6a6d0d00000000, 0xa85a6a7a00000000, 0x0bcf0ee400000000, - 0x9dff099300000000, 0x27ae000a00000000, 0xb19e077d00000000, - 0x44930ff000000000, 0xd2a3088700000000, 0x68f2011e00000000, - 0xfec2066900000000, 0x5d5762f700000000, 0xcb67658000000000, - 0x71366c1900000000, 0xe7066b6e00000000, 0x761bd4fe00000000, - 0xe02bd38900000000, 0x5a7ada1000000000, 0xcc4add6700000000, - 0x6fdfb9f900000000, 0xf9efbe8e00000000, 0x43beb71700000000, - 0xd58eb06000000000, 0xe8a3d6d600000000, 0x7e93d1a100000000, - 0xc4c2d83800000000, 0x52f2df4f00000000, 0xf167bbd100000000, - 0x6757bca600000000, 0xdd06b53f00000000, 0x4b36b24800000000, - 0xda2b0dd800000000, 0x4c1b0aaf00000000, 0xf64a033600000000, - 0x607a044100000000, 0xc3ef60df00000000, 0x55df67a800000000, - 0xef8e6e3100000000, 0x79be694600000000, 0x8cb361cb00000000, - 0x1a8366bc00000000, 0xa0d26f2500000000, 0x36e2685200000000, - 0x95770ccc00000000, 0x03470bbb00000000, 0xb916022200000000, - 0x2f26055500000000, 0xbe3bbac500000000, 0x280bbdb200000000, - 0x925ab42b00000000, 0x046ab35c00000000, 0xa7ffd7c200000000, - 0x31cfd0b500000000, 0x8b9ed92c00000000, 0x1daede5b00000000, - 0xb0c2649b00000000, 0x26f263ec00000000, 0x9ca36a7500000000, - 0x0a936d0200000000, 0xa906099c00000000, 0x3f360eeb00000000, - 0x8567077200000000, 0x1357000500000000, 0x824abf9500000000, - 0x147ab8e200000000, 0xae2bb17b00000000, 0x381bb60c00000000, - 0x9b8ed29200000000, 0x0dbed5e500000000, 0xb7efdc7c00000000, - 0x21dfdb0b00000000, 0xd4d2d38600000000, 0x42e2d4f100000000, - 0xf8b3dd6800000000, 0x6e83da1f00000000, 0xcd16be8100000000, - 0x5b26b9f600000000, 0xe177b06f00000000, 0x7747b71800000000, - 0xe65a088800000000, 0x706a0fff00000000, 0xca3b066600000000, - 0x5c0b011100000000, 0xff9e658f00000000, 0x69ae62f800000000, - 0xd3ff6b6100000000, 0x45cf6c1600000000, 0x78e20aa000000000, - 0xeed20dd700000000, 0x5483044e00000000, 0xc2b3033900000000, - 0x612667a700000000, 0xf71660d000000000, 0x4d47694900000000, - 0xdb776e3e00000000, 0x4a6ad1ae00000000, 0xdc5ad6d900000000, - 0x660bdf4000000000, 0xf03bd83700000000, 0x53aebca900000000, - 0xc59ebbde00000000, 0x7fcfb24700000000, 0xe9ffb53000000000, - 0x1cf2bdbd00000000, 0x8ac2baca00000000, 0x3093b35300000000, - 0xa6a3b42400000000, 0x0536d0ba00000000, 0x9306d7cd00000000, - 0x2957de5400000000, 0xbf67d92300000000, 0x2e7a66b300000000, - 0xb84a61c400000000, 0x021b685d00000000, 0x942b6f2a00000000, - 0x37be0bb400000000, 0xa18e0cc300000000, 0x1bdf055a00000000, - 0x8def022d00000000}, - {0x0000000000000000, 0x41311b1900000000, 0x8262363200000000, - 0xc3532d2b00000000, 0x04c56c6400000000, 0x45f4777d00000000, - 0x86a75a5600000000, 0xc796414f00000000, 0x088ad9c800000000, - 0x49bbc2d100000000, 0x8ae8effa00000000, 0xcbd9f4e300000000, - 0x0c4fb5ac00000000, 0x4d7eaeb500000000, 0x8e2d839e00000000, - 0xcf1c988700000000, 0x5112c24a00000000, 0x1023d95300000000, - 0xd370f47800000000, 0x9241ef6100000000, 0x55d7ae2e00000000, - 0x14e6b53700000000, 0xd7b5981c00000000, 0x9684830500000000, - 0x59981b8200000000, 0x18a9009b00000000, 0xdbfa2db000000000, - 0x9acb36a900000000, 0x5d5d77e600000000, 0x1c6c6cff00000000, - 0xdf3f41d400000000, 0x9e0e5acd00000000, 0xa224849500000000, - 0xe3159f8c00000000, 0x2046b2a700000000, 0x6177a9be00000000, - 0xa6e1e8f100000000, 0xe7d0f3e800000000, 0x2483dec300000000, - 0x65b2c5da00000000, 0xaaae5d5d00000000, 0xeb9f464400000000, - 0x28cc6b6f00000000, 0x69fd707600000000, 0xae6b313900000000, - 0xef5a2a2000000000, 0x2c09070b00000000, 0x6d381c1200000000, - 0xf33646df00000000, 0xb2075dc600000000, 0x715470ed00000000, - 0x30656bf400000000, 0xf7f32abb00000000, 0xb6c231a200000000, - 0x75911c8900000000, 0x34a0079000000000, 0xfbbc9f1700000000, - 0xba8d840e00000000, 0x79dea92500000000, 0x38efb23c00000000, - 0xff79f37300000000, 0xbe48e86a00000000, 0x7d1bc54100000000, - 0x3c2ade5800000000, 0x054f79f000000000, 0x447e62e900000000, - 0x872d4fc200000000, 0xc61c54db00000000, 0x018a159400000000, - 0x40bb0e8d00000000, 0x83e823a600000000, 0xc2d938bf00000000, - 0x0dc5a03800000000, 0x4cf4bb2100000000, 0x8fa7960a00000000, - 0xce968d1300000000, 0x0900cc5c00000000, 0x4831d74500000000, - 0x8b62fa6e00000000, 0xca53e17700000000, 0x545dbbba00000000, - 0x156ca0a300000000, 0xd63f8d8800000000, 0x970e969100000000, - 0x5098d7de00000000, 0x11a9ccc700000000, 0xd2fae1ec00000000, - 0x93cbfaf500000000, 0x5cd7627200000000, 0x1de6796b00000000, - 0xdeb5544000000000, 0x9f844f5900000000, 0x58120e1600000000, - 0x1923150f00000000, 0xda70382400000000, 0x9b41233d00000000, - 0xa76bfd6500000000, 0xe65ae67c00000000, 0x2509cb5700000000, - 0x6438d04e00000000, 0xa3ae910100000000, 0xe29f8a1800000000, - 0x21cca73300000000, 0x60fdbc2a00000000, 0xafe124ad00000000, - 0xeed03fb400000000, 0x2d83129f00000000, 0x6cb2098600000000, - 0xab2448c900000000, 0xea1553d000000000, 0x29467efb00000000, - 0x687765e200000000, 0xf6793f2f00000000, 0xb748243600000000, - 0x741b091d00000000, 0x352a120400000000, 0xf2bc534b00000000, - 0xb38d485200000000, 0x70de657900000000, 0x31ef7e6000000000, - 0xfef3e6e700000000, 0xbfc2fdfe00000000, 0x7c91d0d500000000, - 0x3da0cbcc00000000, 0xfa368a8300000000, 0xbb07919a00000000, - 0x7854bcb100000000, 0x3965a7a800000000, 0x4b98833b00000000, - 0x0aa9982200000000, 0xc9fab50900000000, 0x88cbae1000000000, - 0x4f5def5f00000000, 0x0e6cf44600000000, 0xcd3fd96d00000000, - 0x8c0ec27400000000, 0x43125af300000000, 0x022341ea00000000, - 0xc1706cc100000000, 0x804177d800000000, 0x47d7369700000000, - 0x06e62d8e00000000, 0xc5b500a500000000, 0x84841bbc00000000, - 0x1a8a417100000000, 0x5bbb5a6800000000, 0x98e8774300000000, - 0xd9d96c5a00000000, 0x1e4f2d1500000000, 0x5f7e360c00000000, - 0x9c2d1b2700000000, 0xdd1c003e00000000, 0x120098b900000000, - 0x533183a000000000, 0x9062ae8b00000000, 0xd153b59200000000, - 0x16c5f4dd00000000, 0x57f4efc400000000, 0x94a7c2ef00000000, - 0xd596d9f600000000, 0xe9bc07ae00000000, 0xa88d1cb700000000, - 0x6bde319c00000000, 0x2aef2a8500000000, 0xed796bca00000000, - 0xac4870d300000000, 0x6f1b5df800000000, 0x2e2a46e100000000, - 0xe136de6600000000, 0xa007c57f00000000, 0x6354e85400000000, - 0x2265f34d00000000, 0xe5f3b20200000000, 0xa4c2a91b00000000, - 0x6791843000000000, 0x26a09f2900000000, 0xb8aec5e400000000, - 0xf99fdefd00000000, 0x3accf3d600000000, 0x7bfde8cf00000000, - 0xbc6ba98000000000, 0xfd5ab29900000000, 0x3e099fb200000000, - 0x7f3884ab00000000, 0xb0241c2c00000000, 0xf115073500000000, - 0x32462a1e00000000, 0x7377310700000000, 0xb4e1704800000000, - 0xf5d06b5100000000, 0x3683467a00000000, 0x77b25d6300000000, - 0x4ed7facb00000000, 0x0fe6e1d200000000, 0xccb5ccf900000000, - 0x8d84d7e000000000, 0x4a1296af00000000, 0x0b238db600000000, - 0xc870a09d00000000, 0x8941bb8400000000, 0x465d230300000000, - 0x076c381a00000000, 0xc43f153100000000, 0x850e0e2800000000, - 0x42984f6700000000, 0x03a9547e00000000, 0xc0fa795500000000, - 0x81cb624c00000000, 0x1fc5388100000000, 0x5ef4239800000000, - 0x9da70eb300000000, 0xdc9615aa00000000, 0x1b0054e500000000, - 0x5a314ffc00000000, 0x996262d700000000, 0xd85379ce00000000, - 0x174fe14900000000, 0x567efa5000000000, 0x952dd77b00000000, - 0xd41ccc6200000000, 0x138a8d2d00000000, 0x52bb963400000000, - 0x91e8bb1f00000000, 0xd0d9a00600000000, 0xecf37e5e00000000, - 0xadc2654700000000, 0x6e91486c00000000, 0x2fa0537500000000, - 0xe836123a00000000, 0xa907092300000000, 0x6a54240800000000, - 0x2b653f1100000000, 0xe479a79600000000, 0xa548bc8f00000000, - 0x661b91a400000000, 0x272a8abd00000000, 0xe0bccbf200000000, - 0xa18dd0eb00000000, 0x62defdc000000000, 0x23efe6d900000000, - 0xbde1bc1400000000, 0xfcd0a70d00000000, 0x3f838a2600000000, - 0x7eb2913f00000000, 0xb924d07000000000, 0xf815cb6900000000, - 0x3b46e64200000000, 0x7a77fd5b00000000, 0xb56b65dc00000000, - 0xf45a7ec500000000, 0x370953ee00000000, 0x763848f700000000, - 0xb1ae09b800000000, 0xf09f12a100000000, 0x33cc3f8a00000000, - 0x72fd249300000000}, - {0x0000000000000000, 0x376ac20100000000, 0x6ed4840300000000, - 0x59be460200000000, 0xdca8090700000000, 0xebc2cb0600000000, - 0xb27c8d0400000000, 0x85164f0500000000, 0xb851130e00000000, - 0x8f3bd10f00000000, 0xd685970d00000000, 0xe1ef550c00000000, - 0x64f91a0900000000, 0x5393d80800000000, 0x0a2d9e0a00000000, - 0x3d475c0b00000000, 0x70a3261c00000000, 0x47c9e41d00000000, - 0x1e77a21f00000000, 0x291d601e00000000, 0xac0b2f1b00000000, - 0x9b61ed1a00000000, 0xc2dfab1800000000, 0xf5b5691900000000, - 0xc8f2351200000000, 0xff98f71300000000, 0xa626b11100000000, - 0x914c731000000000, 0x145a3c1500000000, 0x2330fe1400000000, - 0x7a8eb81600000000, 0x4de47a1700000000, 0xe0464d3800000000, - 0xd72c8f3900000000, 0x8e92c93b00000000, 0xb9f80b3a00000000, - 0x3cee443f00000000, 0x0b84863e00000000, 0x523ac03c00000000, - 0x6550023d00000000, 0x58175e3600000000, 0x6f7d9c3700000000, - 0x36c3da3500000000, 0x01a9183400000000, 0x84bf573100000000, - 0xb3d5953000000000, 0xea6bd33200000000, 0xdd01113300000000, - 0x90e56b2400000000, 0xa78fa92500000000, 0xfe31ef2700000000, - 0xc95b2d2600000000, 0x4c4d622300000000, 0x7b27a02200000000, - 0x2299e62000000000, 0x15f3242100000000, 0x28b4782a00000000, - 0x1fdeba2b00000000, 0x4660fc2900000000, 0x710a3e2800000000, - 0xf41c712d00000000, 0xc376b32c00000000, 0x9ac8f52e00000000, - 0xada2372f00000000, 0xc08d9a7000000000, 0xf7e7587100000000, - 0xae591e7300000000, 0x9933dc7200000000, 0x1c25937700000000, - 0x2b4f517600000000, 0x72f1177400000000, 0x459bd57500000000, - 0x78dc897e00000000, 0x4fb64b7f00000000, 0x16080d7d00000000, - 0x2162cf7c00000000, 0xa474807900000000, 0x931e427800000000, - 0xcaa0047a00000000, 0xfdcac67b00000000, 0xb02ebc6c00000000, - 0x87447e6d00000000, 0xdefa386f00000000, 0xe990fa6e00000000, - 0x6c86b56b00000000, 0x5bec776a00000000, 0x0252316800000000, - 0x3538f36900000000, 0x087faf6200000000, 0x3f156d6300000000, - 0x66ab2b6100000000, 0x51c1e96000000000, 0xd4d7a66500000000, - 0xe3bd646400000000, 0xba03226600000000, 0x8d69e06700000000, - 0x20cbd74800000000, 0x17a1154900000000, 0x4e1f534b00000000, - 0x7975914a00000000, 0xfc63de4f00000000, 0xcb091c4e00000000, - 0x92b75a4c00000000, 0xa5dd984d00000000, 0x989ac44600000000, - 0xaff0064700000000, 0xf64e404500000000, 0xc124824400000000, - 0x4432cd4100000000, 0x73580f4000000000, 0x2ae6494200000000, - 0x1d8c8b4300000000, 0x5068f15400000000, 0x6702335500000000, - 0x3ebc755700000000, 0x09d6b75600000000, 0x8cc0f85300000000, - 0xbbaa3a5200000000, 0xe2147c5000000000, 0xd57ebe5100000000, - 0xe839e25a00000000, 0xdf53205b00000000, 0x86ed665900000000, - 0xb187a45800000000, 0x3491eb5d00000000, 0x03fb295c00000000, - 0x5a456f5e00000000, 0x6d2fad5f00000000, 0x801b35e100000000, - 0xb771f7e000000000, 0xeecfb1e200000000, 0xd9a573e300000000, - 0x5cb33ce600000000, 0x6bd9fee700000000, 0x3267b8e500000000, - 0x050d7ae400000000, 0x384a26ef00000000, 0x0f20e4ee00000000, - 0x569ea2ec00000000, 0x61f460ed00000000, 0xe4e22fe800000000, - 0xd388ede900000000, 0x8a36abeb00000000, 0xbd5c69ea00000000, - 0xf0b813fd00000000, 0xc7d2d1fc00000000, 0x9e6c97fe00000000, - 0xa90655ff00000000, 0x2c101afa00000000, 0x1b7ad8fb00000000, - 0x42c49ef900000000, 0x75ae5cf800000000, 0x48e900f300000000, - 0x7f83c2f200000000, 0x263d84f000000000, 0x115746f100000000, - 0x944109f400000000, 0xa32bcbf500000000, 0xfa958df700000000, - 0xcdff4ff600000000, 0x605d78d900000000, 0x5737bad800000000, - 0x0e89fcda00000000, 0x39e33edb00000000, 0xbcf571de00000000, - 0x8b9fb3df00000000, 0xd221f5dd00000000, 0xe54b37dc00000000, - 0xd80c6bd700000000, 0xef66a9d600000000, 0xb6d8efd400000000, - 0x81b22dd500000000, 0x04a462d000000000, 0x33cea0d100000000, - 0x6a70e6d300000000, 0x5d1a24d200000000, 0x10fe5ec500000000, - 0x27949cc400000000, 0x7e2adac600000000, 0x494018c700000000, - 0xcc5657c200000000, 0xfb3c95c300000000, 0xa282d3c100000000, - 0x95e811c000000000, 0xa8af4dcb00000000, 0x9fc58fca00000000, - 0xc67bc9c800000000, 0xf1110bc900000000, 0x740744cc00000000, - 0x436d86cd00000000, 0x1ad3c0cf00000000, 0x2db902ce00000000, - 0x4096af9100000000, 0x77fc6d9000000000, 0x2e422b9200000000, - 0x1928e99300000000, 0x9c3ea69600000000, 0xab54649700000000, - 0xf2ea229500000000, 0xc580e09400000000, 0xf8c7bc9f00000000, - 0xcfad7e9e00000000, 0x9613389c00000000, 0xa179fa9d00000000, - 0x246fb59800000000, 0x1305779900000000, 0x4abb319b00000000, - 0x7dd1f39a00000000, 0x3035898d00000000, 0x075f4b8c00000000, - 0x5ee10d8e00000000, 0x698bcf8f00000000, 0xec9d808a00000000, - 0xdbf7428b00000000, 0x8249048900000000, 0xb523c68800000000, - 0x88649a8300000000, 0xbf0e588200000000, 0xe6b01e8000000000, - 0xd1dadc8100000000, 0x54cc938400000000, 0x63a6518500000000, - 0x3a18178700000000, 0x0d72d58600000000, 0xa0d0e2a900000000, - 0x97ba20a800000000, 0xce0466aa00000000, 0xf96ea4ab00000000, - 0x7c78ebae00000000, 0x4b1229af00000000, 0x12ac6fad00000000, - 0x25c6adac00000000, 0x1881f1a700000000, 0x2feb33a600000000, - 0x765575a400000000, 0x413fb7a500000000, 0xc429f8a000000000, - 0xf3433aa100000000, 0xaafd7ca300000000, 0x9d97bea200000000, - 0xd073c4b500000000, 0xe71906b400000000, 0xbea740b600000000, - 0x89cd82b700000000, 0x0cdbcdb200000000, 0x3bb10fb300000000, - 0x620f49b100000000, 0x55658bb000000000, 0x6822d7bb00000000, - 0x5f4815ba00000000, 0x06f653b800000000, 0x319c91b900000000, - 0xb48adebc00000000, 0x83e01cbd00000000, 0xda5e5abf00000000, - 0xed3498be00000000}, - {0x0000000000000000, 0x6567bcb800000000, 0x8bc809aa00000000, - 0xeeafb51200000000, 0x5797628f00000000, 0x32f0de3700000000, - 0xdc5f6b2500000000, 0xb938d79d00000000, 0xef28b4c500000000, - 0x8a4f087d00000000, 0x64e0bd6f00000000, 0x018701d700000000, - 0xb8bfd64a00000000, 0xddd86af200000000, 0x3377dfe000000000, - 0x5610635800000000, 0x9f57195000000000, 0xfa30a5e800000000, - 0x149f10fa00000000, 0x71f8ac4200000000, 0xc8c07bdf00000000, - 0xada7c76700000000, 0x4308727500000000, 0x266fcecd00000000, - 0x707fad9500000000, 0x1518112d00000000, 0xfbb7a43f00000000, - 0x9ed0188700000000, 0x27e8cf1a00000000, 0x428f73a200000000, - 0xac20c6b000000000, 0xc9477a0800000000, 0x3eaf32a000000000, - 0x5bc88e1800000000, 0xb5673b0a00000000, 0xd00087b200000000, - 0x6938502f00000000, 0x0c5fec9700000000, 0xe2f0598500000000, - 0x8797e53d00000000, 0xd187866500000000, 0xb4e03add00000000, - 0x5a4f8fcf00000000, 0x3f28337700000000, 0x8610e4ea00000000, - 0xe377585200000000, 0x0dd8ed4000000000, 0x68bf51f800000000, - 0xa1f82bf000000000, 0xc49f974800000000, 0x2a30225a00000000, - 0x4f579ee200000000, 0xf66f497f00000000, 0x9308f5c700000000, - 0x7da740d500000000, 0x18c0fc6d00000000, 0x4ed09f3500000000, - 0x2bb7238d00000000, 0xc518969f00000000, 0xa07f2a2700000000, - 0x1947fdba00000000, 0x7c20410200000000, 0x928ff41000000000, - 0xf7e848a800000000, 0x3d58149b00000000, 0x583fa82300000000, - 0xb6901d3100000000, 0xd3f7a18900000000, 0x6acf761400000000, - 0x0fa8caac00000000, 0xe1077fbe00000000, 0x8460c30600000000, - 0xd270a05e00000000, 0xb7171ce600000000, 0x59b8a9f400000000, - 0x3cdf154c00000000, 0x85e7c2d100000000, 0xe0807e6900000000, - 0x0e2fcb7b00000000, 0x6b4877c300000000, 0xa20f0dcb00000000, - 0xc768b17300000000, 0x29c7046100000000, 0x4ca0b8d900000000, - 0xf5986f4400000000, 0x90ffd3fc00000000, 0x7e5066ee00000000, - 0x1b37da5600000000, 0x4d27b90e00000000, 0x284005b600000000, - 0xc6efb0a400000000, 0xa3880c1c00000000, 0x1ab0db8100000000, - 0x7fd7673900000000, 0x9178d22b00000000, 0xf41f6e9300000000, - 0x03f7263b00000000, 0x66909a8300000000, 0x883f2f9100000000, - 0xed58932900000000, 0x546044b400000000, 0x3107f80c00000000, - 0xdfa84d1e00000000, 0xbacff1a600000000, 0xecdf92fe00000000, - 0x89b82e4600000000, 0x67179b5400000000, 0x027027ec00000000, - 0xbb48f07100000000, 0xde2f4cc900000000, 0x3080f9db00000000, - 0x55e7456300000000, 0x9ca03f6b00000000, 0xf9c783d300000000, - 0x176836c100000000, 0x720f8a7900000000, 0xcb375de400000000, - 0xae50e15c00000000, 0x40ff544e00000000, 0x2598e8f600000000, - 0x73888bae00000000, 0x16ef371600000000, 0xf840820400000000, - 0x9d273ebc00000000, 0x241fe92100000000, 0x4178559900000000, - 0xafd7e08b00000000, 0xcab05c3300000000, 0x3bb659ed00000000, - 0x5ed1e55500000000, 0xb07e504700000000, 0xd519ecff00000000, - 0x6c213b6200000000, 0x094687da00000000, 0xe7e932c800000000, - 0x828e8e7000000000, 0xd49eed2800000000, 0xb1f9519000000000, - 0x5f56e48200000000, 0x3a31583a00000000, 0x83098fa700000000, - 0xe66e331f00000000, 0x08c1860d00000000, 0x6da63ab500000000, - 0xa4e140bd00000000, 0xc186fc0500000000, 0x2f29491700000000, - 0x4a4ef5af00000000, 0xf376223200000000, 0x96119e8a00000000, - 0x78be2b9800000000, 0x1dd9972000000000, 0x4bc9f47800000000, - 0x2eae48c000000000, 0xc001fdd200000000, 0xa566416a00000000, - 0x1c5e96f700000000, 0x79392a4f00000000, 0x97969f5d00000000, - 0xf2f123e500000000, 0x05196b4d00000000, 0x607ed7f500000000, - 0x8ed162e700000000, 0xebb6de5f00000000, 0x528e09c200000000, - 0x37e9b57a00000000, 0xd946006800000000, 0xbc21bcd000000000, - 0xea31df8800000000, 0x8f56633000000000, 0x61f9d62200000000, - 0x049e6a9a00000000, 0xbda6bd0700000000, 0xd8c101bf00000000, - 0x366eb4ad00000000, 0x5309081500000000, 0x9a4e721d00000000, - 0xff29cea500000000, 0x11867bb700000000, 0x74e1c70f00000000, - 0xcdd9109200000000, 0xa8beac2a00000000, 0x4611193800000000, - 0x2376a58000000000, 0x7566c6d800000000, 0x10017a6000000000, - 0xfeaecf7200000000, 0x9bc973ca00000000, 0x22f1a45700000000, - 0x479618ef00000000, 0xa939adfd00000000, 0xcc5e114500000000, - 0x06ee4d7600000000, 0x6389f1ce00000000, 0x8d2644dc00000000, - 0xe841f86400000000, 0x51792ff900000000, 0x341e934100000000, - 0xdab1265300000000, 0xbfd69aeb00000000, 0xe9c6f9b300000000, - 0x8ca1450b00000000, 0x620ef01900000000, 0x07694ca100000000, - 0xbe519b3c00000000, 0xdb36278400000000, 0x3599929600000000, - 0x50fe2e2e00000000, 0x99b9542600000000, 0xfcdee89e00000000, - 0x12715d8c00000000, 0x7716e13400000000, 0xce2e36a900000000, - 0xab498a1100000000, 0x45e63f0300000000, 0x208183bb00000000, - 0x7691e0e300000000, 0x13f65c5b00000000, 0xfd59e94900000000, - 0x983e55f100000000, 0x2106826c00000000, 0x44613ed400000000, - 0xaace8bc600000000, 0xcfa9377e00000000, 0x38417fd600000000, - 0x5d26c36e00000000, 0xb389767c00000000, 0xd6eecac400000000, - 0x6fd61d5900000000, 0x0ab1a1e100000000, 0xe41e14f300000000, - 0x8179a84b00000000, 0xd769cb1300000000, 0xb20e77ab00000000, - 0x5ca1c2b900000000, 0x39c67e0100000000, 0x80fea99c00000000, - 0xe599152400000000, 0x0b36a03600000000, 0x6e511c8e00000000, - 0xa716668600000000, 0xc271da3e00000000, 0x2cde6f2c00000000, - 0x49b9d39400000000, 0xf081040900000000, 0x95e6b8b100000000, - 0x7b490da300000000, 0x1e2eb11b00000000, 0x483ed24300000000, - 0x2d596efb00000000, 0xc3f6dbe900000000, 0xa691675100000000, - 0x1fa9b0cc00000000, 0x7ace0c7400000000, 0x9461b96600000000, - 0xf10605de00000000}, - {0x0000000000000000, 0xb029603d00000000, 0x6053c07a00000000, - 0xd07aa04700000000, 0xc0a680f500000000, 0x708fe0c800000000, - 0xa0f5408f00000000, 0x10dc20b200000000, 0xc14b703000000000, - 0x7162100d00000000, 0xa118b04a00000000, 0x1131d07700000000, - 0x01edf0c500000000, 0xb1c490f800000000, 0x61be30bf00000000, - 0xd197508200000000, 0x8297e06000000000, 0x32be805d00000000, - 0xe2c4201a00000000, 0x52ed402700000000, 0x4231609500000000, - 0xf21800a800000000, 0x2262a0ef00000000, 0x924bc0d200000000, - 0x43dc905000000000, 0xf3f5f06d00000000, 0x238f502a00000000, - 0x93a6301700000000, 0x837a10a500000000, 0x3353709800000000, - 0xe329d0df00000000, 0x5300b0e200000000, 0x042fc1c100000000, - 0xb406a1fc00000000, 0x647c01bb00000000, 0xd455618600000000, - 0xc489413400000000, 0x74a0210900000000, 0xa4da814e00000000, - 0x14f3e17300000000, 0xc564b1f100000000, 0x754dd1cc00000000, - 0xa537718b00000000, 0x151e11b600000000, 0x05c2310400000000, - 0xb5eb513900000000, 0x6591f17e00000000, 0xd5b8914300000000, - 0x86b821a100000000, 0x3691419c00000000, 0xe6ebe1db00000000, - 0x56c281e600000000, 0x461ea15400000000, 0xf637c16900000000, - 0x264d612e00000000, 0x9664011300000000, 0x47f3519100000000, - 0xf7da31ac00000000, 0x27a091eb00000000, 0x9789f1d600000000, - 0x8755d16400000000, 0x377cb15900000000, 0xe706111e00000000, - 0x572f712300000000, 0x4958f35800000000, 0xf971936500000000, - 0x290b332200000000, 0x9922531f00000000, 0x89fe73ad00000000, - 0x39d7139000000000, 0xe9adb3d700000000, 0x5984d3ea00000000, - 0x8813836800000000, 0x383ae35500000000, 0xe840431200000000, - 0x5869232f00000000, 0x48b5039d00000000, 0xf89c63a000000000, - 0x28e6c3e700000000, 0x98cfa3da00000000, 0xcbcf133800000000, - 0x7be6730500000000, 0xab9cd34200000000, 0x1bb5b37f00000000, - 0x0b6993cd00000000, 0xbb40f3f000000000, 0x6b3a53b700000000, - 0xdb13338a00000000, 0x0a84630800000000, 0xbaad033500000000, - 0x6ad7a37200000000, 0xdafec34f00000000, 0xca22e3fd00000000, - 0x7a0b83c000000000, 0xaa71238700000000, 0x1a5843ba00000000, - 0x4d77329900000000, 0xfd5e52a400000000, 0x2d24f2e300000000, - 0x9d0d92de00000000, 0x8dd1b26c00000000, 0x3df8d25100000000, - 0xed82721600000000, 0x5dab122b00000000, 0x8c3c42a900000000, - 0x3c15229400000000, 0xec6f82d300000000, 0x5c46e2ee00000000, - 0x4c9ac25c00000000, 0xfcb3a26100000000, 0x2cc9022600000000, - 0x9ce0621b00000000, 0xcfe0d2f900000000, 0x7fc9b2c400000000, - 0xafb3128300000000, 0x1f9a72be00000000, 0x0f46520c00000000, - 0xbf6f323100000000, 0x6f15927600000000, 0xdf3cf24b00000000, - 0x0eaba2c900000000, 0xbe82c2f400000000, 0x6ef862b300000000, - 0xded1028e00000000, 0xce0d223c00000000, 0x7e24420100000000, - 0xae5ee24600000000, 0x1e77827b00000000, 0x92b0e6b100000000, - 0x2299868c00000000, 0xf2e326cb00000000, 0x42ca46f600000000, - 0x5216664400000000, 0xe23f067900000000, 0x3245a63e00000000, - 0x826cc60300000000, 0x53fb968100000000, 0xe3d2f6bc00000000, - 0x33a856fb00000000, 0x838136c600000000, 0x935d167400000000, - 0x2374764900000000, 0xf30ed60e00000000, 0x4327b63300000000, - 0x102706d100000000, 0xa00e66ec00000000, 0x7074c6ab00000000, - 0xc05da69600000000, 0xd081862400000000, 0x60a8e61900000000, - 0xb0d2465e00000000, 0x00fb266300000000, 0xd16c76e100000000, - 0x614516dc00000000, 0xb13fb69b00000000, 0x0116d6a600000000, - 0x11caf61400000000, 0xa1e3962900000000, 0x7199366e00000000, - 0xc1b0565300000000, 0x969f277000000000, 0x26b6474d00000000, - 0xf6cce70a00000000, 0x46e5873700000000, 0x5639a78500000000, - 0xe610c7b800000000, 0x366a67ff00000000, 0x864307c200000000, - 0x57d4574000000000, 0xe7fd377d00000000, 0x3787973a00000000, - 0x87aef70700000000, 0x9772d7b500000000, 0x275bb78800000000, - 0xf72117cf00000000, 0x470877f200000000, 0x1408c71000000000, - 0xa421a72d00000000, 0x745b076a00000000, 0xc472675700000000, - 0xd4ae47e500000000, 0x648727d800000000, 0xb4fd879f00000000, - 0x04d4e7a200000000, 0xd543b72000000000, 0x656ad71d00000000, - 0xb510775a00000000, 0x0539176700000000, 0x15e537d500000000, - 0xa5cc57e800000000, 0x75b6f7af00000000, 0xc59f979200000000, - 0xdbe815e900000000, 0x6bc175d400000000, 0xbbbbd59300000000, - 0x0b92b5ae00000000, 0x1b4e951c00000000, 0xab67f52100000000, - 0x7b1d556600000000, 0xcb34355b00000000, 0x1aa365d900000000, - 0xaa8a05e400000000, 0x7af0a5a300000000, 0xcad9c59e00000000, - 0xda05e52c00000000, 0x6a2c851100000000, 0xba56255600000000, - 0x0a7f456b00000000, 0x597ff58900000000, 0xe95695b400000000, - 0x392c35f300000000, 0x890555ce00000000, 0x99d9757c00000000, - 0x29f0154100000000, 0xf98ab50600000000, 0x49a3d53b00000000, - 0x983485b900000000, 0x281de58400000000, 0xf86745c300000000, - 0x484e25fe00000000, 0x5892054c00000000, 0xe8bb657100000000, - 0x38c1c53600000000, 0x88e8a50b00000000, 0xdfc7d42800000000, - 0x6feeb41500000000, 0xbf94145200000000, 0x0fbd746f00000000, - 0x1f6154dd00000000, 0xaf4834e000000000, 0x7f3294a700000000, - 0xcf1bf49a00000000, 0x1e8ca41800000000, 0xaea5c42500000000, - 0x7edf646200000000, 0xcef6045f00000000, 0xde2a24ed00000000, - 0x6e0344d000000000, 0xbe79e49700000000, 0x0e5084aa00000000, - 0x5d50344800000000, 0xed79547500000000, 0x3d03f43200000000, - 0x8d2a940f00000000, 0x9df6b4bd00000000, 0x2ddfd48000000000, - 0xfda574c700000000, 0x4d8c14fa00000000, 0x9c1b447800000000, - 0x2c32244500000000, 0xfc48840200000000, 0x4c61e43f00000000, - 0x5cbdc48d00000000, 0xec94a4b000000000, 0x3cee04f700000000, - 0x8cc764ca00000000}, - {0x0000000000000000, 0xa5d35ccb00000000, 0x0ba1c84d00000000, - 0xae72948600000000, 0x1642919b00000000, 0xb391cd5000000000, - 0x1de359d600000000, 0xb830051d00000000, 0x6d8253ec00000000, - 0xc8510f2700000000, 0x66239ba100000000, 0xc3f0c76a00000000, - 0x7bc0c27700000000, 0xde139ebc00000000, 0x70610a3a00000000, - 0xd5b256f100000000, 0x9b02d60300000000, 0x3ed18ac800000000, - 0x90a31e4e00000000, 0x3570428500000000, 0x8d40479800000000, - 0x28931b5300000000, 0x86e18fd500000000, 0x2332d31e00000000, - 0xf68085ef00000000, 0x5353d92400000000, 0xfd214da200000000, - 0x58f2116900000000, 0xe0c2147400000000, 0x451148bf00000000, - 0xeb63dc3900000000, 0x4eb080f200000000, 0x3605ac0700000000, - 0x93d6f0cc00000000, 0x3da4644a00000000, 0x9877388100000000, - 0x20473d9c00000000, 0x8594615700000000, 0x2be6f5d100000000, - 0x8e35a91a00000000, 0x5b87ffeb00000000, 0xfe54a32000000000, - 0x502637a600000000, 0xf5f56b6d00000000, 0x4dc56e7000000000, - 0xe81632bb00000000, 0x4664a63d00000000, 0xe3b7faf600000000, - 0xad077a0400000000, 0x08d426cf00000000, 0xa6a6b24900000000, - 0x0375ee8200000000, 0xbb45eb9f00000000, 0x1e96b75400000000, - 0xb0e423d200000000, 0x15377f1900000000, 0xc08529e800000000, - 0x6556752300000000, 0xcb24e1a500000000, 0x6ef7bd6e00000000, - 0xd6c7b87300000000, 0x7314e4b800000000, 0xdd66703e00000000, - 0x78b52cf500000000, 0x6c0a580f00000000, 0xc9d904c400000000, - 0x67ab904200000000, 0xc278cc8900000000, 0x7a48c99400000000, - 0xdf9b955f00000000, 0x71e901d900000000, 0xd43a5d1200000000, - 0x01880be300000000, 0xa45b572800000000, 0x0a29c3ae00000000, - 0xaffa9f6500000000, 0x17ca9a7800000000, 0xb219c6b300000000, - 0x1c6b523500000000, 0xb9b80efe00000000, 0xf7088e0c00000000, - 0x52dbd2c700000000, 0xfca9464100000000, 0x597a1a8a00000000, - 0xe14a1f9700000000, 0x4499435c00000000, 0xeaebd7da00000000, - 0x4f388b1100000000, 0x9a8adde000000000, 0x3f59812b00000000, - 0x912b15ad00000000, 0x34f8496600000000, 0x8cc84c7b00000000, - 0x291b10b000000000, 0x8769843600000000, 0x22bad8fd00000000, - 0x5a0ff40800000000, 0xffdca8c300000000, 0x51ae3c4500000000, - 0xf47d608e00000000, 0x4c4d659300000000, 0xe99e395800000000, - 0x47ecadde00000000, 0xe23ff11500000000, 0x378da7e400000000, - 0x925efb2f00000000, 0x3c2c6fa900000000, 0x99ff336200000000, - 0x21cf367f00000000, 0x841c6ab400000000, 0x2a6efe3200000000, - 0x8fbda2f900000000, 0xc10d220b00000000, 0x64de7ec000000000, - 0xcaacea4600000000, 0x6f7fb68d00000000, 0xd74fb39000000000, - 0x729cef5b00000000, 0xdcee7bdd00000000, 0x793d271600000000, - 0xac8f71e700000000, 0x095c2d2c00000000, 0xa72eb9aa00000000, - 0x02fde56100000000, 0xbacde07c00000000, 0x1f1ebcb700000000, - 0xb16c283100000000, 0x14bf74fa00000000, 0xd814b01e00000000, - 0x7dc7ecd500000000, 0xd3b5785300000000, 0x7666249800000000, - 0xce56218500000000, 0x6b857d4e00000000, 0xc5f7e9c800000000, - 0x6024b50300000000, 0xb596e3f200000000, 0x1045bf3900000000, - 0xbe372bbf00000000, 0x1be4777400000000, 0xa3d4726900000000, - 0x06072ea200000000, 0xa875ba2400000000, 0x0da6e6ef00000000, - 0x4316661d00000000, 0xe6c53ad600000000, 0x48b7ae5000000000, - 0xed64f29b00000000, 0x5554f78600000000, 0xf087ab4d00000000, - 0x5ef53fcb00000000, 0xfb26630000000000, 0x2e9435f100000000, - 0x8b47693a00000000, 0x2535fdbc00000000, 0x80e6a17700000000, - 0x38d6a46a00000000, 0x9d05f8a100000000, 0x33776c2700000000, - 0x96a430ec00000000, 0xee111c1900000000, 0x4bc240d200000000, - 0xe5b0d45400000000, 0x4063889f00000000, 0xf8538d8200000000, - 0x5d80d14900000000, 0xf3f245cf00000000, 0x5621190400000000, - 0x83934ff500000000, 0x2640133e00000000, 0x883287b800000000, - 0x2de1db7300000000, 0x95d1de6e00000000, 0x300282a500000000, - 0x9e70162300000000, 0x3ba34ae800000000, 0x7513ca1a00000000, - 0xd0c096d100000000, 0x7eb2025700000000, 0xdb615e9c00000000, - 0x63515b8100000000, 0xc682074a00000000, 0x68f093cc00000000, - 0xcd23cf0700000000, 0x189199f600000000, 0xbd42c53d00000000, - 0x133051bb00000000, 0xb6e30d7000000000, 0x0ed3086d00000000, - 0xab0054a600000000, 0x0572c02000000000, 0xa0a19ceb00000000, - 0xb41ee81100000000, 0x11cdb4da00000000, 0xbfbf205c00000000, - 0x1a6c7c9700000000, 0xa25c798a00000000, 0x078f254100000000, - 0xa9fdb1c700000000, 0x0c2eed0c00000000, 0xd99cbbfd00000000, - 0x7c4fe73600000000, 0xd23d73b000000000, 0x77ee2f7b00000000, - 0xcfde2a6600000000, 0x6a0d76ad00000000, 0xc47fe22b00000000, - 0x61acbee000000000, 0x2f1c3e1200000000, 0x8acf62d900000000, - 0x24bdf65f00000000, 0x816eaa9400000000, 0x395eaf8900000000, - 0x9c8df34200000000, 0x32ff67c400000000, 0x972c3b0f00000000, - 0x429e6dfe00000000, 0xe74d313500000000, 0x493fa5b300000000, - 0xececf97800000000, 0x54dcfc6500000000, 0xf10fa0ae00000000, - 0x5f7d342800000000, 0xfaae68e300000000, 0x821b441600000000, - 0x27c818dd00000000, 0x89ba8c5b00000000, 0x2c69d09000000000, - 0x9459d58d00000000, 0x318a894600000000, 0x9ff81dc000000000, - 0x3a2b410b00000000, 0xef9917fa00000000, 0x4a4a4b3100000000, - 0xe438dfb700000000, 0x41eb837c00000000, 0xf9db866100000000, - 0x5c08daaa00000000, 0xf27a4e2c00000000, 0x57a912e700000000, - 0x1919921500000000, 0xbccacede00000000, 0x12b85a5800000000, - 0xb76b069300000000, 0x0f5b038e00000000, 0xaa885f4500000000, - 0x04facbc300000000, 0xa129970800000000, 0x749bc1f900000000, - 0xd1489d3200000000, 0x7f3a09b400000000, 0xdae9557f00000000, - 0x62d9506200000000, 0xc70a0ca900000000, 0x6978982f00000000, - 0xccabc4e400000000}, - {0x0000000000000000, 0xb40b77a600000000, 0x29119f9700000000, - 0x9d1ae83100000000, 0x13244ff400000000, 0xa72f385200000000, - 0x3a35d06300000000, 0x8e3ea7c500000000, 0x674eef3300000000, - 0xd345989500000000, 0x4e5f70a400000000, 0xfa54070200000000, - 0x746aa0c700000000, 0xc061d76100000000, 0x5d7b3f5000000000, - 0xe97048f600000000, 0xce9cde6700000000, 0x7a97a9c100000000, - 0xe78d41f000000000, 0x5386365600000000, 0xddb8919300000000, - 0x69b3e63500000000, 0xf4a90e0400000000, 0x40a279a200000000, - 0xa9d2315400000000, 0x1dd946f200000000, 0x80c3aec300000000, - 0x34c8d96500000000, 0xbaf67ea000000000, 0x0efd090600000000, - 0x93e7e13700000000, 0x27ec969100000000, 0x9c39bdcf00000000, - 0x2832ca6900000000, 0xb528225800000000, 0x012355fe00000000, - 0x8f1df23b00000000, 0x3b16859d00000000, 0xa60c6dac00000000, - 0x12071a0a00000000, 0xfb7752fc00000000, 0x4f7c255a00000000, - 0xd266cd6b00000000, 0x666dbacd00000000, 0xe8531d0800000000, - 0x5c586aae00000000, 0xc142829f00000000, 0x7549f53900000000, - 0x52a563a800000000, 0xe6ae140e00000000, 0x7bb4fc3f00000000, - 0xcfbf8b9900000000, 0x41812c5c00000000, 0xf58a5bfa00000000, - 0x6890b3cb00000000, 0xdc9bc46d00000000, 0x35eb8c9b00000000, - 0x81e0fb3d00000000, 0x1cfa130c00000000, 0xa8f164aa00000000, - 0x26cfc36f00000000, 0x92c4b4c900000000, 0x0fde5cf800000000, - 0xbbd52b5e00000000, 0x79750b4400000000, 0xcd7e7ce200000000, - 0x506494d300000000, 0xe46fe37500000000, 0x6a5144b000000000, - 0xde5a331600000000, 0x4340db2700000000, 0xf74bac8100000000, - 0x1e3be47700000000, 0xaa3093d100000000, 0x372a7be000000000, - 0x83210c4600000000, 0x0d1fab8300000000, 0xb914dc2500000000, - 0x240e341400000000, 0x900543b200000000, 0xb7e9d52300000000, - 0x03e2a28500000000, 0x9ef84ab400000000, 0x2af33d1200000000, - 0xa4cd9ad700000000, 0x10c6ed7100000000, 0x8ddc054000000000, - 0x39d772e600000000, 0xd0a73a1000000000, 0x64ac4db600000000, - 0xf9b6a58700000000, 0x4dbdd22100000000, 0xc38375e400000000, - 0x7788024200000000, 0xea92ea7300000000, 0x5e999dd500000000, - 0xe54cb68b00000000, 0x5147c12d00000000, 0xcc5d291c00000000, - 0x78565eba00000000, 0xf668f97f00000000, 0x42638ed900000000, - 0xdf7966e800000000, 0x6b72114e00000000, 0x820259b800000000, - 0x36092e1e00000000, 0xab13c62f00000000, 0x1f18b18900000000, - 0x9126164c00000000, 0x252d61ea00000000, 0xb83789db00000000, - 0x0c3cfe7d00000000, 0x2bd068ec00000000, 0x9fdb1f4a00000000, - 0x02c1f77b00000000, 0xb6ca80dd00000000, 0x38f4271800000000, - 0x8cff50be00000000, 0x11e5b88f00000000, 0xa5eecf2900000000, - 0x4c9e87df00000000, 0xf895f07900000000, 0x658f184800000000, - 0xd1846fee00000000, 0x5fbac82b00000000, 0xebb1bf8d00000000, - 0x76ab57bc00000000, 0xc2a0201a00000000, 0xf2ea168800000000, - 0x46e1612e00000000, 0xdbfb891f00000000, 0x6ff0feb900000000, - 0xe1ce597c00000000, 0x55c52eda00000000, 0xc8dfc6eb00000000, - 0x7cd4b14d00000000, 0x95a4f9bb00000000, 0x21af8e1d00000000, - 0xbcb5662c00000000, 0x08be118a00000000, 0x8680b64f00000000, - 0x328bc1e900000000, 0xaf9129d800000000, 0x1b9a5e7e00000000, - 0x3c76c8ef00000000, 0x887dbf4900000000, 0x1567577800000000, - 0xa16c20de00000000, 0x2f52871b00000000, 0x9b59f0bd00000000, - 0x0643188c00000000, 0xb2486f2a00000000, 0x5b3827dc00000000, - 0xef33507a00000000, 0x7229b84b00000000, 0xc622cfed00000000, - 0x481c682800000000, 0xfc171f8e00000000, 0x610df7bf00000000, - 0xd506801900000000, 0x6ed3ab4700000000, 0xdad8dce100000000, - 0x47c234d000000000, 0xf3c9437600000000, 0x7df7e4b300000000, - 0xc9fc931500000000, 0x54e67b2400000000, 0xe0ed0c8200000000, - 0x099d447400000000, 0xbd9633d200000000, 0x208cdbe300000000, - 0x9487ac4500000000, 0x1ab90b8000000000, 0xaeb27c2600000000, - 0x33a8941700000000, 0x87a3e3b100000000, 0xa04f752000000000, - 0x1444028600000000, 0x895eeab700000000, 0x3d559d1100000000, - 0xb36b3ad400000000, 0x07604d7200000000, 0x9a7aa54300000000, - 0x2e71d2e500000000, 0xc7019a1300000000, 0x730aedb500000000, - 0xee10058400000000, 0x5a1b722200000000, 0xd425d5e700000000, - 0x602ea24100000000, 0xfd344a7000000000, 0x493f3dd600000000, - 0x8b9f1dcc00000000, 0x3f946a6a00000000, 0xa28e825b00000000, - 0x1685f5fd00000000, 0x98bb523800000000, 0x2cb0259e00000000, - 0xb1aacdaf00000000, 0x05a1ba0900000000, 0xecd1f2ff00000000, - 0x58da855900000000, 0xc5c06d6800000000, 0x71cb1ace00000000, - 0xfff5bd0b00000000, 0x4bfecaad00000000, 0xd6e4229c00000000, - 0x62ef553a00000000, 0x4503c3ab00000000, 0xf108b40d00000000, - 0x6c125c3c00000000, 0xd8192b9a00000000, 0x56278c5f00000000, - 0xe22cfbf900000000, 0x7f3613c800000000, 0xcb3d646e00000000, - 0x224d2c9800000000, 0x96465b3e00000000, 0x0b5cb30f00000000, - 0xbf57c4a900000000, 0x3169636c00000000, 0x856214ca00000000, - 0x1878fcfb00000000, 0xac738b5d00000000, 0x17a6a00300000000, - 0xa3add7a500000000, 0x3eb73f9400000000, 0x8abc483200000000, - 0x0482eff700000000, 0xb089985100000000, 0x2d93706000000000, - 0x999807c600000000, 0x70e84f3000000000, 0xc4e3389600000000, - 0x59f9d0a700000000, 0xedf2a70100000000, 0x63cc00c400000000, - 0xd7c7776200000000, 0x4add9f5300000000, 0xfed6e8f500000000, - 0xd93a7e6400000000, 0x6d3109c200000000, 0xf02be1f300000000, - 0x4420965500000000, 0xca1e319000000000, 0x7e15463600000000, - 0xe30fae0700000000, 0x5704d9a100000000, 0xbe74915700000000, - 0x0a7fe6f100000000, 0x97650ec000000000, 0x236e796600000000, - 0xad50dea300000000, 0x195ba90500000000, 0x8441413400000000, - 0x304a369200000000}, - {0x0000000000000000, 0x9e00aacc00000000, 0x7d07254200000000, - 0xe3078f8e00000000, 0xfa0e4a8400000000, 0x640ee04800000000, - 0x87096fc600000000, 0x1909c50a00000000, 0xb51be5d300000000, - 0x2b1b4f1f00000000, 0xc81cc09100000000, 0x561c6a5d00000000, - 0x4f15af5700000000, 0xd115059b00000000, 0x32128a1500000000, - 0xac1220d900000000, 0x2b31bb7c00000000, 0xb53111b000000000, - 0x56369e3e00000000, 0xc83634f200000000, 0xd13ff1f800000000, - 0x4f3f5b3400000000, 0xac38d4ba00000000, 0x32387e7600000000, - 0x9e2a5eaf00000000, 0x002af46300000000, 0xe32d7bed00000000, - 0x7d2dd12100000000, 0x6424142b00000000, 0xfa24bee700000000, - 0x1923316900000000, 0x87239ba500000000, 0x566276f900000000, - 0xc862dc3500000000, 0x2b6553bb00000000, 0xb565f97700000000, - 0xac6c3c7d00000000, 0x326c96b100000000, 0xd16b193f00000000, - 0x4f6bb3f300000000, 0xe379932a00000000, 0x7d7939e600000000, - 0x9e7eb66800000000, 0x007e1ca400000000, 0x1977d9ae00000000, - 0x8777736200000000, 0x6470fcec00000000, 0xfa70562000000000, - 0x7d53cd8500000000, 0xe353674900000000, 0x0054e8c700000000, - 0x9e54420b00000000, 0x875d870100000000, 0x195d2dcd00000000, - 0xfa5aa24300000000, 0x645a088f00000000, 0xc848285600000000, - 0x5648829a00000000, 0xb54f0d1400000000, 0x2b4fa7d800000000, - 0x324662d200000000, 0xac46c81e00000000, 0x4f41479000000000, - 0xd141ed5c00000000, 0xedc29d2900000000, 0x73c237e500000000, - 0x90c5b86b00000000, 0x0ec512a700000000, 0x17ccd7ad00000000, - 0x89cc7d6100000000, 0x6acbf2ef00000000, 0xf4cb582300000000, - 0x58d978fa00000000, 0xc6d9d23600000000, 0x25de5db800000000, - 0xbbdef77400000000, 0xa2d7327e00000000, 0x3cd798b200000000, - 0xdfd0173c00000000, 0x41d0bdf000000000, 0xc6f3265500000000, - 0x58f38c9900000000, 0xbbf4031700000000, 0x25f4a9db00000000, - 0x3cfd6cd100000000, 0xa2fdc61d00000000, 0x41fa499300000000, - 0xdffae35f00000000, 0x73e8c38600000000, 0xede8694a00000000, - 0x0eefe6c400000000, 0x90ef4c0800000000, 0x89e6890200000000, - 0x17e623ce00000000, 0xf4e1ac4000000000, 0x6ae1068c00000000, - 0xbba0ebd000000000, 0x25a0411c00000000, 0xc6a7ce9200000000, - 0x58a7645e00000000, 0x41aea15400000000, 0xdfae0b9800000000, - 0x3ca9841600000000, 0xa2a92eda00000000, 0x0ebb0e0300000000, - 0x90bba4cf00000000, 0x73bc2b4100000000, 0xedbc818d00000000, - 0xf4b5448700000000, 0x6ab5ee4b00000000, 0x89b261c500000000, - 0x17b2cb0900000000, 0x909150ac00000000, 0x0e91fa6000000000, - 0xed9675ee00000000, 0x7396df2200000000, 0x6a9f1a2800000000, - 0xf49fb0e400000000, 0x17983f6a00000000, 0x899895a600000000, - 0x258ab57f00000000, 0xbb8a1fb300000000, 0x588d903d00000000, - 0xc68d3af100000000, 0xdf84fffb00000000, 0x4184553700000000, - 0xa283dab900000000, 0x3c83707500000000, 0xda853b5300000000, - 0x4485919f00000000, 0xa7821e1100000000, 0x3982b4dd00000000, - 0x208b71d700000000, 0xbe8bdb1b00000000, 0x5d8c549500000000, - 0xc38cfe5900000000, 0x6f9ede8000000000, 0xf19e744c00000000, - 0x1299fbc200000000, 0x8c99510e00000000, 0x9590940400000000, - 0x0b903ec800000000, 0xe897b14600000000, 0x76971b8a00000000, - 0xf1b4802f00000000, 0x6fb42ae300000000, 0x8cb3a56d00000000, - 0x12b30fa100000000, 0x0bbacaab00000000, 0x95ba606700000000, - 0x76bdefe900000000, 0xe8bd452500000000, 0x44af65fc00000000, - 0xdaafcf3000000000, 0x39a840be00000000, 0xa7a8ea7200000000, - 0xbea12f7800000000, 0x20a185b400000000, 0xc3a60a3a00000000, - 0x5da6a0f600000000, 0x8ce74daa00000000, 0x12e7e76600000000, - 0xf1e068e800000000, 0x6fe0c22400000000, 0x76e9072e00000000, - 0xe8e9ade200000000, 0x0bee226c00000000, 0x95ee88a000000000, - 0x39fca87900000000, 0xa7fc02b500000000, 0x44fb8d3b00000000, - 0xdafb27f700000000, 0xc3f2e2fd00000000, 0x5df2483100000000, - 0xbef5c7bf00000000, 0x20f56d7300000000, 0xa7d6f6d600000000, - 0x39d65c1a00000000, 0xdad1d39400000000, 0x44d1795800000000, - 0x5dd8bc5200000000, 0xc3d8169e00000000, 0x20df991000000000, - 0xbedf33dc00000000, 0x12cd130500000000, 0x8ccdb9c900000000, - 0x6fca364700000000, 0xf1ca9c8b00000000, 0xe8c3598100000000, - 0x76c3f34d00000000, 0x95c47cc300000000, 0x0bc4d60f00000000, - 0x3747a67a00000000, 0xa9470cb600000000, 0x4a40833800000000, - 0xd44029f400000000, 0xcd49ecfe00000000, 0x5349463200000000, - 0xb04ec9bc00000000, 0x2e4e637000000000, 0x825c43a900000000, - 0x1c5ce96500000000, 0xff5b66eb00000000, 0x615bcc2700000000, - 0x7852092d00000000, 0xe652a3e100000000, 0x05552c6f00000000, - 0x9b5586a300000000, 0x1c761d0600000000, 0x8276b7ca00000000, - 0x6171384400000000, 0xff71928800000000, 0xe678578200000000, - 0x7878fd4e00000000, 0x9b7f72c000000000, 0x057fd80c00000000, - 0xa96df8d500000000, 0x376d521900000000, 0xd46add9700000000, - 0x4a6a775b00000000, 0x5363b25100000000, 0xcd63189d00000000, - 0x2e64971300000000, 0xb0643ddf00000000, 0x6125d08300000000, - 0xff257a4f00000000, 0x1c22f5c100000000, 0x82225f0d00000000, - 0x9b2b9a0700000000, 0x052b30cb00000000, 0xe62cbf4500000000, - 0x782c158900000000, 0xd43e355000000000, 0x4a3e9f9c00000000, - 0xa939101200000000, 0x3739bade00000000, 0x2e307fd400000000, - 0xb030d51800000000, 0x53375a9600000000, 0xcd37f05a00000000, - 0x4a146bff00000000, 0xd414c13300000000, 0x37134ebd00000000, - 0xa913e47100000000, 0xb01a217b00000000, 0x2e1a8bb700000000, - 0xcd1d043900000000, 0x531daef500000000, 0xff0f8e2c00000000, - 0x610f24e000000000, 0x8208ab6e00000000, 0x1c0801a200000000, - 0x0501c4a800000000, 0x9b016e6400000000, 0x7806e1ea00000000, - 0xe6064b2600000000}}; - -#else /* W == 4 */ - -local const z_crc_t FAR crc_braid_table[][256] = { - {0x00000000, 0xb8bc6765, 0xaa09c88b, 0x12b5afee, 0x8f629757, - 0x37def032, 0x256b5fdc, 0x9dd738b9, 0xc5b428ef, 0x7d084f8a, - 0x6fbde064, 0xd7018701, 0x4ad6bfb8, 0xf26ad8dd, 0xe0df7733, - 0x58631056, 0x5019579f, 0xe8a530fa, 0xfa109f14, 0x42acf871, - 0xdf7bc0c8, 0x67c7a7ad, 0x75720843, 0xcdce6f26, 0x95ad7f70, - 0x2d111815, 0x3fa4b7fb, 0x8718d09e, 0x1acfe827, 0xa2738f42, - 0xb0c620ac, 0x087a47c9, 0xa032af3e, 0x188ec85b, 0x0a3b67b5, - 0xb28700d0, 0x2f503869, 0x97ec5f0c, 0x8559f0e2, 0x3de59787, - 0x658687d1, 0xdd3ae0b4, 0xcf8f4f5a, 0x7733283f, 0xeae41086, - 0x525877e3, 0x40edd80d, 0xf851bf68, 0xf02bf8a1, 0x48979fc4, - 0x5a22302a, 0xe29e574f, 0x7f496ff6, 0xc7f50893, 0xd540a77d, - 0x6dfcc018, 0x359fd04e, 0x8d23b72b, 0x9f9618c5, 0x272a7fa0, - 0xbafd4719, 0x0241207c, 0x10f48f92, 0xa848e8f7, 0x9b14583d, - 0x23a83f58, 0x311d90b6, 0x89a1f7d3, 0x1476cf6a, 0xaccaa80f, - 0xbe7f07e1, 0x06c36084, 0x5ea070d2, 0xe61c17b7, 0xf4a9b859, - 0x4c15df3c, 0xd1c2e785, 0x697e80e0, 0x7bcb2f0e, 0xc377486b, - 0xcb0d0fa2, 0x73b168c7, 0x6104c729, 0xd9b8a04c, 0x446f98f5, - 0xfcd3ff90, 0xee66507e, 0x56da371b, 0x0eb9274d, 0xb6054028, - 0xa4b0efc6, 0x1c0c88a3, 0x81dbb01a, 0x3967d77f, 0x2bd27891, - 0x936e1ff4, 0x3b26f703, 0x839a9066, 0x912f3f88, 0x299358ed, - 0xb4446054, 0x0cf80731, 0x1e4da8df, 0xa6f1cfba, 0xfe92dfec, - 0x462eb889, 0x549b1767, 0xec277002, 0x71f048bb, 0xc94c2fde, - 0xdbf98030, 0x6345e755, 0x6b3fa09c, 0xd383c7f9, 0xc1366817, - 0x798a0f72, 0xe45d37cb, 0x5ce150ae, 0x4e54ff40, 0xf6e89825, - 0xae8b8873, 0x1637ef16, 0x048240f8, 0xbc3e279d, 0x21e91f24, - 0x99557841, 0x8be0d7af, 0x335cb0ca, 0xed59b63b, 0x55e5d15e, - 0x47507eb0, 0xffec19d5, 0x623b216c, 0xda874609, 0xc832e9e7, - 0x708e8e82, 0x28ed9ed4, 0x9051f9b1, 0x82e4565f, 0x3a58313a, - 0xa78f0983, 0x1f336ee6, 0x0d86c108, 0xb53aa66d, 0xbd40e1a4, - 0x05fc86c1, 0x1749292f, 0xaff54e4a, 0x322276f3, 0x8a9e1196, - 0x982bbe78, 0x2097d91d, 0x78f4c94b, 0xc048ae2e, 0xd2fd01c0, - 0x6a4166a5, 0xf7965e1c, 0x4f2a3979, 0x5d9f9697, 0xe523f1f2, - 0x4d6b1905, 0xf5d77e60, 0xe762d18e, 0x5fdeb6eb, 0xc2098e52, - 0x7ab5e937, 0x680046d9, 0xd0bc21bc, 0x88df31ea, 0x3063568f, - 0x22d6f961, 0x9a6a9e04, 0x07bda6bd, 0xbf01c1d8, 0xadb46e36, - 0x15080953, 0x1d724e9a, 0xa5ce29ff, 0xb77b8611, 0x0fc7e174, - 0x9210d9cd, 0x2aacbea8, 0x38191146, 0x80a57623, 0xd8c66675, - 0x607a0110, 0x72cfaefe, 0xca73c99b, 0x57a4f122, 0xef189647, - 0xfdad39a9, 0x45115ecc, 0x764dee06, 0xcef18963, 0xdc44268d, - 0x64f841e8, 0xf92f7951, 0x41931e34, 0x5326b1da, 0xeb9ad6bf, - 0xb3f9c6e9, 0x0b45a18c, 0x19f00e62, 0xa14c6907, 0x3c9b51be, - 0x842736db, 0x96929935, 0x2e2efe50, 0x2654b999, 0x9ee8defc, - 0x8c5d7112, 0x34e11677, 0xa9362ece, 0x118a49ab, 0x033fe645, - 0xbb838120, 0xe3e09176, 0x5b5cf613, 0x49e959fd, 0xf1553e98, - 0x6c820621, 0xd43e6144, 0xc68bceaa, 0x7e37a9cf, 0xd67f4138, - 0x6ec3265d, 0x7c7689b3, 0xc4caeed6, 0x591dd66f, 0xe1a1b10a, - 0xf3141ee4, 0x4ba87981, 0x13cb69d7, 0xab770eb2, 0xb9c2a15c, - 0x017ec639, 0x9ca9fe80, 0x241599e5, 0x36a0360b, 0x8e1c516e, - 0x866616a7, 0x3eda71c2, 0x2c6fde2c, 0x94d3b949, 0x090481f0, - 0xb1b8e695, 0xa30d497b, 0x1bb12e1e, 0x43d23e48, 0xfb6e592d, - 0xe9dbf6c3, 0x516791a6, 0xccb0a91f, 0x740cce7a, 0x66b96194, - 0xde0506f1}, - {0x00000000, 0x01c26a37, 0x0384d46e, 0x0246be59, 0x0709a8dc, - 0x06cbc2eb, 0x048d7cb2, 0x054f1685, 0x0e1351b8, 0x0fd13b8f, - 0x0d9785d6, 0x0c55efe1, 0x091af964, 0x08d89353, 0x0a9e2d0a, - 0x0b5c473d, 0x1c26a370, 0x1de4c947, 0x1fa2771e, 0x1e601d29, - 0x1b2f0bac, 0x1aed619b, 0x18abdfc2, 0x1969b5f5, 0x1235f2c8, - 0x13f798ff, 0x11b126a6, 0x10734c91, 0x153c5a14, 0x14fe3023, - 0x16b88e7a, 0x177ae44d, 0x384d46e0, 0x398f2cd7, 0x3bc9928e, - 0x3a0bf8b9, 0x3f44ee3c, 0x3e86840b, 0x3cc03a52, 0x3d025065, - 0x365e1758, 0x379c7d6f, 0x35dac336, 0x3418a901, 0x3157bf84, - 0x3095d5b3, 0x32d36bea, 0x331101dd, 0x246be590, 0x25a98fa7, - 0x27ef31fe, 0x262d5bc9, 0x23624d4c, 0x22a0277b, 0x20e69922, - 0x2124f315, 0x2a78b428, 0x2bbade1f, 0x29fc6046, 0x283e0a71, - 0x2d711cf4, 0x2cb376c3, 0x2ef5c89a, 0x2f37a2ad, 0x709a8dc0, - 0x7158e7f7, 0x731e59ae, 0x72dc3399, 0x7793251c, 0x76514f2b, - 0x7417f172, 0x75d59b45, 0x7e89dc78, 0x7f4bb64f, 0x7d0d0816, - 0x7ccf6221, 0x798074a4, 0x78421e93, 0x7a04a0ca, 0x7bc6cafd, - 0x6cbc2eb0, 0x6d7e4487, 0x6f38fade, 0x6efa90e9, 0x6bb5866c, - 0x6a77ec5b, 0x68315202, 0x69f33835, 0x62af7f08, 0x636d153f, - 0x612bab66, 0x60e9c151, 0x65a6d7d4, 0x6464bde3, 0x662203ba, - 0x67e0698d, 0x48d7cb20, 0x4915a117, 0x4b531f4e, 0x4a917579, - 0x4fde63fc, 0x4e1c09cb, 0x4c5ab792, 0x4d98dda5, 0x46c49a98, - 0x4706f0af, 0x45404ef6, 0x448224c1, 0x41cd3244, 0x400f5873, - 0x4249e62a, 0x438b8c1d, 0x54f16850, 0x55330267, 0x5775bc3e, - 0x56b7d609, 0x53f8c08c, 0x523aaabb, 0x507c14e2, 0x51be7ed5, - 0x5ae239e8, 0x5b2053df, 0x5966ed86, 0x58a487b1, 0x5deb9134, - 0x5c29fb03, 0x5e6f455a, 0x5fad2f6d, 0xe1351b80, 0xe0f771b7, - 0xe2b1cfee, 0xe373a5d9, 0xe63cb35c, 0xe7fed96b, 0xe5b86732, - 0xe47a0d05, 0xef264a38, 0xeee4200f, 0xeca29e56, 0xed60f461, - 0xe82fe2e4, 0xe9ed88d3, 0xebab368a, 0xea695cbd, 0xfd13b8f0, - 0xfcd1d2c7, 0xfe976c9e, 0xff5506a9, 0xfa1a102c, 0xfbd87a1b, - 0xf99ec442, 0xf85cae75, 0xf300e948, 0xf2c2837f, 0xf0843d26, - 0xf1465711, 0xf4094194, 0xf5cb2ba3, 0xf78d95fa, 0xf64fffcd, - 0xd9785d60, 0xd8ba3757, 0xdafc890e, 0xdb3ee339, 0xde71f5bc, - 0xdfb39f8b, 0xddf521d2, 0xdc374be5, 0xd76b0cd8, 0xd6a966ef, - 0xd4efd8b6, 0xd52db281, 0xd062a404, 0xd1a0ce33, 0xd3e6706a, - 0xd2241a5d, 0xc55efe10, 0xc49c9427, 0xc6da2a7e, 0xc7184049, - 0xc25756cc, 0xc3953cfb, 0xc1d382a2, 0xc011e895, 0xcb4dafa8, - 0xca8fc59f, 0xc8c97bc6, 0xc90b11f1, 0xcc440774, 0xcd866d43, - 0xcfc0d31a, 0xce02b92d, 0x91af9640, 0x906dfc77, 0x922b422e, - 0x93e92819, 0x96a63e9c, 0x976454ab, 0x9522eaf2, 0x94e080c5, - 0x9fbcc7f8, 0x9e7eadcf, 0x9c381396, 0x9dfa79a1, 0x98b56f24, - 0x99770513, 0x9b31bb4a, 0x9af3d17d, 0x8d893530, 0x8c4b5f07, - 0x8e0de15e, 0x8fcf8b69, 0x8a809dec, 0x8b42f7db, 0x89044982, - 0x88c623b5, 0x839a6488, 0x82580ebf, 0x801eb0e6, 0x81dcdad1, - 0x8493cc54, 0x8551a663, 0x8717183a, 0x86d5720d, 0xa9e2d0a0, - 0xa820ba97, 0xaa6604ce, 0xaba46ef9, 0xaeeb787c, 0xaf29124b, - 0xad6fac12, 0xacadc625, 0xa7f18118, 0xa633eb2f, 0xa4755576, - 0xa5b73f41, 0xa0f829c4, 0xa13a43f3, 0xa37cfdaa, 0xa2be979d, - 0xb5c473d0, 0xb40619e7, 0xb640a7be, 0xb782cd89, 0xb2cddb0c, - 0xb30fb13b, 0xb1490f62, 0xb08b6555, 0xbbd72268, 0xba15485f, - 0xb853f606, 0xb9919c31, 0xbcde8ab4, 0xbd1ce083, 0xbf5a5eda, - 0xbe9834ed}, - {0x00000000, 0x191b3141, 0x32366282, 0x2b2d53c3, 0x646cc504, - 0x7d77f445, 0x565aa786, 0x4f4196c7, 0xc8d98a08, 0xd1c2bb49, - 0xfaefe88a, 0xe3f4d9cb, 0xacb54f0c, 0xb5ae7e4d, 0x9e832d8e, - 0x87981ccf, 0x4ac21251, 0x53d92310, 0x78f470d3, 0x61ef4192, - 0x2eaed755, 0x37b5e614, 0x1c98b5d7, 0x05838496, 0x821b9859, - 0x9b00a918, 0xb02dfadb, 0xa936cb9a, 0xe6775d5d, 0xff6c6c1c, - 0xd4413fdf, 0xcd5a0e9e, 0x958424a2, 0x8c9f15e3, 0xa7b24620, - 0xbea97761, 0xf1e8e1a6, 0xe8f3d0e7, 0xc3de8324, 0xdac5b265, - 0x5d5daeaa, 0x44469feb, 0x6f6bcc28, 0x7670fd69, 0x39316bae, - 0x202a5aef, 0x0b07092c, 0x121c386d, 0xdf4636f3, 0xc65d07b2, - 0xed705471, 0xf46b6530, 0xbb2af3f7, 0xa231c2b6, 0x891c9175, - 0x9007a034, 0x179fbcfb, 0x0e848dba, 0x25a9de79, 0x3cb2ef38, - 0x73f379ff, 0x6ae848be, 0x41c51b7d, 0x58de2a3c, 0xf0794f05, - 0xe9627e44, 0xc24f2d87, 0xdb541cc6, 0x94158a01, 0x8d0ebb40, - 0xa623e883, 0xbf38d9c2, 0x38a0c50d, 0x21bbf44c, 0x0a96a78f, - 0x138d96ce, 0x5ccc0009, 0x45d73148, 0x6efa628b, 0x77e153ca, - 0xbabb5d54, 0xa3a06c15, 0x888d3fd6, 0x91960e97, 0xded79850, - 0xc7cca911, 0xece1fad2, 0xf5facb93, 0x7262d75c, 0x6b79e61d, - 0x4054b5de, 0x594f849f, 0x160e1258, 0x0f152319, 0x243870da, - 0x3d23419b, 0x65fd6ba7, 0x7ce65ae6, 0x57cb0925, 0x4ed03864, - 0x0191aea3, 0x188a9fe2, 0x33a7cc21, 0x2abcfd60, 0xad24e1af, - 0xb43fd0ee, 0x9f12832d, 0x8609b26c, 0xc94824ab, 0xd05315ea, - 0xfb7e4629, 0xe2657768, 0x2f3f79f6, 0x362448b7, 0x1d091b74, - 0x04122a35, 0x4b53bcf2, 0x52488db3, 0x7965de70, 0x607eef31, - 0xe7e6f3fe, 0xfefdc2bf, 0xd5d0917c, 0xcccba03d, 0x838a36fa, - 0x9a9107bb, 0xb1bc5478, 0xa8a76539, 0x3b83984b, 0x2298a90a, - 0x09b5fac9, 0x10aecb88, 0x5fef5d4f, 0x46f46c0e, 0x6dd93fcd, - 0x74c20e8c, 0xf35a1243, 0xea412302, 0xc16c70c1, 0xd8774180, - 0x9736d747, 0x8e2de606, 0xa500b5c5, 0xbc1b8484, 0x71418a1a, - 0x685abb5b, 0x4377e898, 0x5a6cd9d9, 0x152d4f1e, 0x0c367e5f, - 0x271b2d9c, 0x3e001cdd, 0xb9980012, 0xa0833153, 0x8bae6290, - 0x92b553d1, 0xddf4c516, 0xc4eff457, 0xefc2a794, 0xf6d996d5, - 0xae07bce9, 0xb71c8da8, 0x9c31de6b, 0x852aef2a, 0xca6b79ed, - 0xd37048ac, 0xf85d1b6f, 0xe1462a2e, 0x66de36e1, 0x7fc507a0, - 0x54e85463, 0x4df36522, 0x02b2f3e5, 0x1ba9c2a4, 0x30849167, - 0x299fa026, 0xe4c5aeb8, 0xfdde9ff9, 0xd6f3cc3a, 0xcfe8fd7b, - 0x80a96bbc, 0x99b25afd, 0xb29f093e, 0xab84387f, 0x2c1c24b0, - 0x350715f1, 0x1e2a4632, 0x07317773, 0x4870e1b4, 0x516bd0f5, - 0x7a468336, 0x635db277, 0xcbfad74e, 0xd2e1e60f, 0xf9ccb5cc, - 0xe0d7848d, 0xaf96124a, 0xb68d230b, 0x9da070c8, 0x84bb4189, - 0x03235d46, 0x1a386c07, 0x31153fc4, 0x280e0e85, 0x674f9842, - 0x7e54a903, 0x5579fac0, 0x4c62cb81, 0x8138c51f, 0x9823f45e, - 0xb30ea79d, 0xaa1596dc, 0xe554001b, 0xfc4f315a, 0xd7626299, - 0xce7953d8, 0x49e14f17, 0x50fa7e56, 0x7bd72d95, 0x62cc1cd4, - 0x2d8d8a13, 0x3496bb52, 0x1fbbe891, 0x06a0d9d0, 0x5e7ef3ec, - 0x4765c2ad, 0x6c48916e, 0x7553a02f, 0x3a1236e8, 0x230907a9, - 0x0824546a, 0x113f652b, 0x96a779e4, 0x8fbc48a5, 0xa4911b66, - 0xbd8a2a27, 0xf2cbbce0, 0xebd08da1, 0xc0fdde62, 0xd9e6ef23, - 0x14bce1bd, 0x0da7d0fc, 0x268a833f, 0x3f91b27e, 0x70d024b9, - 0x69cb15f8, 0x42e6463b, 0x5bfd777a, 0xdc656bb5, 0xc57e5af4, - 0xee530937, 0xf7483876, 0xb809aeb1, 0xa1129ff0, 0x8a3fcc33, - 0x9324fd72}, - {0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, - 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, - 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, - 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, - 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, - 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, - 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, - 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, - 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, - 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, - 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, - 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, - 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, - 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, - 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, - 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, - 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, - 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, - 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, - 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, - 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, - 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, - 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, - 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, - 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, - 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, - 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, - 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, - 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, - 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, - 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, - 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, - 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, - 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, - 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, - 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, - 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, - 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, - 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, - 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, - 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, - 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, - 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, - 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, - 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, - 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, - 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, - 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, - 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, - 0x2d02ef8d}}; - -local const z_word_t FAR crc_braid_big_table[][256] = { - {0x00000000, 0x96300777, 0x2c610eee, 0xba510999, 0x19c46d07, - 0x8ff46a70, 0x35a563e9, 0xa395649e, 0x3288db0e, 0xa4b8dc79, - 0x1ee9d5e0, 0x88d9d297, 0x2b4cb609, 0xbd7cb17e, 0x072db8e7, - 0x911dbf90, 0x6410b71d, 0xf220b06a, 0x4871b9f3, 0xde41be84, - 0x7dd4da1a, 0xebe4dd6d, 0x51b5d4f4, 0xc785d383, 0x56986c13, - 0xc0a86b64, 0x7af962fd, 0xecc9658a, 0x4f5c0114, 0xd96c0663, - 0x633d0ffa, 0xf50d088d, 0xc8206e3b, 0x5e10694c, 0xe44160d5, - 0x727167a2, 0xd1e4033c, 0x47d4044b, 0xfd850dd2, 0x6bb50aa5, - 0xfaa8b535, 0x6c98b242, 0xd6c9bbdb, 0x40f9bcac, 0xe36cd832, - 0x755cdf45, 0xcf0dd6dc, 0x593dd1ab, 0xac30d926, 0x3a00de51, - 0x8051d7c8, 0x1661d0bf, 0xb5f4b421, 0x23c4b356, 0x9995bacf, - 0x0fa5bdb8, 0x9eb80228, 0x0888055f, 0xb2d90cc6, 0x24e90bb1, - 0x877c6f2f, 0x114c6858, 0xab1d61c1, 0x3d2d66b6, 0x9041dc76, - 0x0671db01, 0xbc20d298, 0x2a10d5ef, 0x8985b171, 0x1fb5b606, - 0xa5e4bf9f, 0x33d4b8e8, 0xa2c90778, 0x34f9000f, 0x8ea80996, - 0x18980ee1, 0xbb0d6a7f, 0x2d3d6d08, 0x976c6491, 0x015c63e6, - 0xf4516b6b, 0x62616c1c, 0xd8306585, 0x4e0062f2, 0xed95066c, - 0x7ba5011b, 0xc1f40882, 0x57c40ff5, 0xc6d9b065, 0x50e9b712, - 0xeab8be8b, 0x7c88b9fc, 0xdf1ddd62, 0x492dda15, 0xf37cd38c, - 0x654cd4fb, 0x5861b24d, 0xce51b53a, 0x7400bca3, 0xe230bbd4, - 0x41a5df4a, 0xd795d83d, 0x6dc4d1a4, 0xfbf4d6d3, 0x6ae96943, - 0xfcd96e34, 0x468867ad, 0xd0b860da, 0x732d0444, 0xe51d0333, - 0x5f4c0aaa, 0xc97c0ddd, 0x3c710550, 0xaa410227, 0x10100bbe, - 0x86200cc9, 0x25b56857, 0xb3856f20, 0x09d466b9, 0x9fe461ce, - 0x0ef9de5e, 0x98c9d929, 0x2298d0b0, 0xb4a8d7c7, 0x173db359, - 0x810db42e, 0x3b5cbdb7, 0xad6cbac0, 0x2083b8ed, 0xb6b3bf9a, - 0x0ce2b603, 0x9ad2b174, 0x3947d5ea, 0xaf77d29d, 0x1526db04, - 0x8316dc73, 0x120b63e3, 0x843b6494, 0x3e6a6d0d, 0xa85a6a7a, - 0x0bcf0ee4, 0x9dff0993, 0x27ae000a, 0xb19e077d, 0x44930ff0, - 0xd2a30887, 0x68f2011e, 0xfec20669, 0x5d5762f7, 0xcb676580, - 0x71366c19, 0xe7066b6e, 0x761bd4fe, 0xe02bd389, 0x5a7ada10, - 0xcc4add67, 0x6fdfb9f9, 0xf9efbe8e, 0x43beb717, 0xd58eb060, - 0xe8a3d6d6, 0x7e93d1a1, 0xc4c2d838, 0x52f2df4f, 0xf167bbd1, - 0x6757bca6, 0xdd06b53f, 0x4b36b248, 0xda2b0dd8, 0x4c1b0aaf, - 0xf64a0336, 0x607a0441, 0xc3ef60df, 0x55df67a8, 0xef8e6e31, - 0x79be6946, 0x8cb361cb, 0x1a8366bc, 0xa0d26f25, 0x36e26852, - 0x95770ccc, 0x03470bbb, 0xb9160222, 0x2f260555, 0xbe3bbac5, - 0x280bbdb2, 0x925ab42b, 0x046ab35c, 0xa7ffd7c2, 0x31cfd0b5, - 0x8b9ed92c, 0x1daede5b, 0xb0c2649b, 0x26f263ec, 0x9ca36a75, - 0x0a936d02, 0xa906099c, 0x3f360eeb, 0x85670772, 0x13570005, - 0x824abf95, 0x147ab8e2, 0xae2bb17b, 0x381bb60c, 0x9b8ed292, - 0x0dbed5e5, 0xb7efdc7c, 0x21dfdb0b, 0xd4d2d386, 0x42e2d4f1, - 0xf8b3dd68, 0x6e83da1f, 0xcd16be81, 0x5b26b9f6, 0xe177b06f, - 0x7747b718, 0xe65a0888, 0x706a0fff, 0xca3b0666, 0x5c0b0111, - 0xff9e658f, 0x69ae62f8, 0xd3ff6b61, 0x45cf6c16, 0x78e20aa0, - 0xeed20dd7, 0x5483044e, 0xc2b30339, 0x612667a7, 0xf71660d0, - 0x4d476949, 0xdb776e3e, 0x4a6ad1ae, 0xdc5ad6d9, 0x660bdf40, - 0xf03bd837, 0x53aebca9, 0xc59ebbde, 0x7fcfb247, 0xe9ffb530, - 0x1cf2bdbd, 0x8ac2baca, 0x3093b353, 0xa6a3b424, 0x0536d0ba, - 0x9306d7cd, 0x2957de54, 0xbf67d923, 0x2e7a66b3, 0xb84a61c4, - 0x021b685d, 0x942b6f2a, 0x37be0bb4, 0xa18e0cc3, 0x1bdf055a, - 0x8def022d}, - {0x00000000, 0x41311b19, 0x82623632, 0xc3532d2b, 0x04c56c64, - 0x45f4777d, 0x86a75a56, 0xc796414f, 0x088ad9c8, 0x49bbc2d1, - 0x8ae8effa, 0xcbd9f4e3, 0x0c4fb5ac, 0x4d7eaeb5, 0x8e2d839e, - 0xcf1c9887, 0x5112c24a, 0x1023d953, 0xd370f478, 0x9241ef61, - 0x55d7ae2e, 0x14e6b537, 0xd7b5981c, 0x96848305, 0x59981b82, - 0x18a9009b, 0xdbfa2db0, 0x9acb36a9, 0x5d5d77e6, 0x1c6c6cff, - 0xdf3f41d4, 0x9e0e5acd, 0xa2248495, 0xe3159f8c, 0x2046b2a7, - 0x6177a9be, 0xa6e1e8f1, 0xe7d0f3e8, 0x2483dec3, 0x65b2c5da, - 0xaaae5d5d, 0xeb9f4644, 0x28cc6b6f, 0x69fd7076, 0xae6b3139, - 0xef5a2a20, 0x2c09070b, 0x6d381c12, 0xf33646df, 0xb2075dc6, - 0x715470ed, 0x30656bf4, 0xf7f32abb, 0xb6c231a2, 0x75911c89, - 0x34a00790, 0xfbbc9f17, 0xba8d840e, 0x79dea925, 0x38efb23c, - 0xff79f373, 0xbe48e86a, 0x7d1bc541, 0x3c2ade58, 0x054f79f0, - 0x447e62e9, 0x872d4fc2, 0xc61c54db, 0x018a1594, 0x40bb0e8d, - 0x83e823a6, 0xc2d938bf, 0x0dc5a038, 0x4cf4bb21, 0x8fa7960a, - 0xce968d13, 0x0900cc5c, 0x4831d745, 0x8b62fa6e, 0xca53e177, - 0x545dbbba, 0x156ca0a3, 0xd63f8d88, 0x970e9691, 0x5098d7de, - 0x11a9ccc7, 0xd2fae1ec, 0x93cbfaf5, 0x5cd76272, 0x1de6796b, - 0xdeb55440, 0x9f844f59, 0x58120e16, 0x1923150f, 0xda703824, - 0x9b41233d, 0xa76bfd65, 0xe65ae67c, 0x2509cb57, 0x6438d04e, - 0xa3ae9101, 0xe29f8a18, 0x21cca733, 0x60fdbc2a, 0xafe124ad, - 0xeed03fb4, 0x2d83129f, 0x6cb20986, 0xab2448c9, 0xea1553d0, - 0x29467efb, 0x687765e2, 0xf6793f2f, 0xb7482436, 0x741b091d, - 0x352a1204, 0xf2bc534b, 0xb38d4852, 0x70de6579, 0x31ef7e60, - 0xfef3e6e7, 0xbfc2fdfe, 0x7c91d0d5, 0x3da0cbcc, 0xfa368a83, - 0xbb07919a, 0x7854bcb1, 0x3965a7a8, 0x4b98833b, 0x0aa99822, - 0xc9fab509, 0x88cbae10, 0x4f5def5f, 0x0e6cf446, 0xcd3fd96d, - 0x8c0ec274, 0x43125af3, 0x022341ea, 0xc1706cc1, 0x804177d8, - 0x47d73697, 0x06e62d8e, 0xc5b500a5, 0x84841bbc, 0x1a8a4171, - 0x5bbb5a68, 0x98e87743, 0xd9d96c5a, 0x1e4f2d15, 0x5f7e360c, - 0x9c2d1b27, 0xdd1c003e, 0x120098b9, 0x533183a0, 0x9062ae8b, - 0xd153b592, 0x16c5f4dd, 0x57f4efc4, 0x94a7c2ef, 0xd596d9f6, - 0xe9bc07ae, 0xa88d1cb7, 0x6bde319c, 0x2aef2a85, 0xed796bca, - 0xac4870d3, 0x6f1b5df8, 0x2e2a46e1, 0xe136de66, 0xa007c57f, - 0x6354e854, 0x2265f34d, 0xe5f3b202, 0xa4c2a91b, 0x67918430, - 0x26a09f29, 0xb8aec5e4, 0xf99fdefd, 0x3accf3d6, 0x7bfde8cf, - 0xbc6ba980, 0xfd5ab299, 0x3e099fb2, 0x7f3884ab, 0xb0241c2c, - 0xf1150735, 0x32462a1e, 0x73773107, 0xb4e17048, 0xf5d06b51, - 0x3683467a, 0x77b25d63, 0x4ed7facb, 0x0fe6e1d2, 0xccb5ccf9, - 0x8d84d7e0, 0x4a1296af, 0x0b238db6, 0xc870a09d, 0x8941bb84, - 0x465d2303, 0x076c381a, 0xc43f1531, 0x850e0e28, 0x42984f67, - 0x03a9547e, 0xc0fa7955, 0x81cb624c, 0x1fc53881, 0x5ef42398, - 0x9da70eb3, 0xdc9615aa, 0x1b0054e5, 0x5a314ffc, 0x996262d7, - 0xd85379ce, 0x174fe149, 0x567efa50, 0x952dd77b, 0xd41ccc62, - 0x138a8d2d, 0x52bb9634, 0x91e8bb1f, 0xd0d9a006, 0xecf37e5e, - 0xadc26547, 0x6e91486c, 0x2fa05375, 0xe836123a, 0xa9070923, - 0x6a542408, 0x2b653f11, 0xe479a796, 0xa548bc8f, 0x661b91a4, - 0x272a8abd, 0xe0bccbf2, 0xa18dd0eb, 0x62defdc0, 0x23efe6d9, - 0xbde1bc14, 0xfcd0a70d, 0x3f838a26, 0x7eb2913f, 0xb924d070, - 0xf815cb69, 0x3b46e642, 0x7a77fd5b, 0xb56b65dc, 0xf45a7ec5, - 0x370953ee, 0x763848f7, 0xb1ae09b8, 0xf09f12a1, 0x33cc3f8a, - 0x72fd2493}, - {0x00000000, 0x376ac201, 0x6ed48403, 0x59be4602, 0xdca80907, - 0xebc2cb06, 0xb27c8d04, 0x85164f05, 0xb851130e, 0x8f3bd10f, - 0xd685970d, 0xe1ef550c, 0x64f91a09, 0x5393d808, 0x0a2d9e0a, - 0x3d475c0b, 0x70a3261c, 0x47c9e41d, 0x1e77a21f, 0x291d601e, - 0xac0b2f1b, 0x9b61ed1a, 0xc2dfab18, 0xf5b56919, 0xc8f23512, - 0xff98f713, 0xa626b111, 0x914c7310, 0x145a3c15, 0x2330fe14, - 0x7a8eb816, 0x4de47a17, 0xe0464d38, 0xd72c8f39, 0x8e92c93b, - 0xb9f80b3a, 0x3cee443f, 0x0b84863e, 0x523ac03c, 0x6550023d, - 0x58175e36, 0x6f7d9c37, 0x36c3da35, 0x01a91834, 0x84bf5731, - 0xb3d59530, 0xea6bd332, 0xdd011133, 0x90e56b24, 0xa78fa925, - 0xfe31ef27, 0xc95b2d26, 0x4c4d6223, 0x7b27a022, 0x2299e620, - 0x15f32421, 0x28b4782a, 0x1fdeba2b, 0x4660fc29, 0x710a3e28, - 0xf41c712d, 0xc376b32c, 0x9ac8f52e, 0xada2372f, 0xc08d9a70, - 0xf7e75871, 0xae591e73, 0x9933dc72, 0x1c259377, 0x2b4f5176, - 0x72f11774, 0x459bd575, 0x78dc897e, 0x4fb64b7f, 0x16080d7d, - 0x2162cf7c, 0xa4748079, 0x931e4278, 0xcaa0047a, 0xfdcac67b, - 0xb02ebc6c, 0x87447e6d, 0xdefa386f, 0xe990fa6e, 0x6c86b56b, - 0x5bec776a, 0x02523168, 0x3538f369, 0x087faf62, 0x3f156d63, - 0x66ab2b61, 0x51c1e960, 0xd4d7a665, 0xe3bd6464, 0xba032266, - 0x8d69e067, 0x20cbd748, 0x17a11549, 0x4e1f534b, 0x7975914a, - 0xfc63de4f, 0xcb091c4e, 0x92b75a4c, 0xa5dd984d, 0x989ac446, - 0xaff00647, 0xf64e4045, 0xc1248244, 0x4432cd41, 0x73580f40, - 0x2ae64942, 0x1d8c8b43, 0x5068f154, 0x67023355, 0x3ebc7557, - 0x09d6b756, 0x8cc0f853, 0xbbaa3a52, 0xe2147c50, 0xd57ebe51, - 0xe839e25a, 0xdf53205b, 0x86ed6659, 0xb187a458, 0x3491eb5d, - 0x03fb295c, 0x5a456f5e, 0x6d2fad5f, 0x801b35e1, 0xb771f7e0, - 0xeecfb1e2, 0xd9a573e3, 0x5cb33ce6, 0x6bd9fee7, 0x3267b8e5, - 0x050d7ae4, 0x384a26ef, 0x0f20e4ee, 0x569ea2ec, 0x61f460ed, - 0xe4e22fe8, 0xd388ede9, 0x8a36abeb, 0xbd5c69ea, 0xf0b813fd, - 0xc7d2d1fc, 0x9e6c97fe, 0xa90655ff, 0x2c101afa, 0x1b7ad8fb, - 0x42c49ef9, 0x75ae5cf8, 0x48e900f3, 0x7f83c2f2, 0x263d84f0, - 0x115746f1, 0x944109f4, 0xa32bcbf5, 0xfa958df7, 0xcdff4ff6, - 0x605d78d9, 0x5737bad8, 0x0e89fcda, 0x39e33edb, 0xbcf571de, - 0x8b9fb3df, 0xd221f5dd, 0xe54b37dc, 0xd80c6bd7, 0xef66a9d6, - 0xb6d8efd4, 0x81b22dd5, 0x04a462d0, 0x33cea0d1, 0x6a70e6d3, - 0x5d1a24d2, 0x10fe5ec5, 0x27949cc4, 0x7e2adac6, 0x494018c7, - 0xcc5657c2, 0xfb3c95c3, 0xa282d3c1, 0x95e811c0, 0xa8af4dcb, - 0x9fc58fca, 0xc67bc9c8, 0xf1110bc9, 0x740744cc, 0x436d86cd, - 0x1ad3c0cf, 0x2db902ce, 0x4096af91, 0x77fc6d90, 0x2e422b92, - 0x1928e993, 0x9c3ea696, 0xab546497, 0xf2ea2295, 0xc580e094, - 0xf8c7bc9f, 0xcfad7e9e, 0x9613389c, 0xa179fa9d, 0x246fb598, - 0x13057799, 0x4abb319b, 0x7dd1f39a, 0x3035898d, 0x075f4b8c, - 0x5ee10d8e, 0x698bcf8f, 0xec9d808a, 0xdbf7428b, 0x82490489, - 0xb523c688, 0x88649a83, 0xbf0e5882, 0xe6b01e80, 0xd1dadc81, - 0x54cc9384, 0x63a65185, 0x3a181787, 0x0d72d586, 0xa0d0e2a9, - 0x97ba20a8, 0xce0466aa, 0xf96ea4ab, 0x7c78ebae, 0x4b1229af, - 0x12ac6fad, 0x25c6adac, 0x1881f1a7, 0x2feb33a6, 0x765575a4, - 0x413fb7a5, 0xc429f8a0, 0xf3433aa1, 0xaafd7ca3, 0x9d97bea2, - 0xd073c4b5, 0xe71906b4, 0xbea740b6, 0x89cd82b7, 0x0cdbcdb2, - 0x3bb10fb3, 0x620f49b1, 0x55658bb0, 0x6822d7bb, 0x5f4815ba, - 0x06f653b8, 0x319c91b9, 0xb48adebc, 0x83e01cbd, 0xda5e5abf, - 0xed3498be}, - {0x00000000, 0x6567bcb8, 0x8bc809aa, 0xeeafb512, 0x5797628f, - 0x32f0de37, 0xdc5f6b25, 0xb938d79d, 0xef28b4c5, 0x8a4f087d, - 0x64e0bd6f, 0x018701d7, 0xb8bfd64a, 0xddd86af2, 0x3377dfe0, - 0x56106358, 0x9f571950, 0xfa30a5e8, 0x149f10fa, 0x71f8ac42, - 0xc8c07bdf, 0xada7c767, 0x43087275, 0x266fcecd, 0x707fad95, - 0x1518112d, 0xfbb7a43f, 0x9ed01887, 0x27e8cf1a, 0x428f73a2, - 0xac20c6b0, 0xc9477a08, 0x3eaf32a0, 0x5bc88e18, 0xb5673b0a, - 0xd00087b2, 0x6938502f, 0x0c5fec97, 0xe2f05985, 0x8797e53d, - 0xd1878665, 0xb4e03add, 0x5a4f8fcf, 0x3f283377, 0x8610e4ea, - 0xe3775852, 0x0dd8ed40, 0x68bf51f8, 0xa1f82bf0, 0xc49f9748, - 0x2a30225a, 0x4f579ee2, 0xf66f497f, 0x9308f5c7, 0x7da740d5, - 0x18c0fc6d, 0x4ed09f35, 0x2bb7238d, 0xc518969f, 0xa07f2a27, - 0x1947fdba, 0x7c204102, 0x928ff410, 0xf7e848a8, 0x3d58149b, - 0x583fa823, 0xb6901d31, 0xd3f7a189, 0x6acf7614, 0x0fa8caac, - 0xe1077fbe, 0x8460c306, 0xd270a05e, 0xb7171ce6, 0x59b8a9f4, - 0x3cdf154c, 0x85e7c2d1, 0xe0807e69, 0x0e2fcb7b, 0x6b4877c3, - 0xa20f0dcb, 0xc768b173, 0x29c70461, 0x4ca0b8d9, 0xf5986f44, - 0x90ffd3fc, 0x7e5066ee, 0x1b37da56, 0x4d27b90e, 0x284005b6, - 0xc6efb0a4, 0xa3880c1c, 0x1ab0db81, 0x7fd76739, 0x9178d22b, - 0xf41f6e93, 0x03f7263b, 0x66909a83, 0x883f2f91, 0xed589329, - 0x546044b4, 0x3107f80c, 0xdfa84d1e, 0xbacff1a6, 0xecdf92fe, - 0x89b82e46, 0x67179b54, 0x027027ec, 0xbb48f071, 0xde2f4cc9, - 0x3080f9db, 0x55e74563, 0x9ca03f6b, 0xf9c783d3, 0x176836c1, - 0x720f8a79, 0xcb375de4, 0xae50e15c, 0x40ff544e, 0x2598e8f6, - 0x73888bae, 0x16ef3716, 0xf8408204, 0x9d273ebc, 0x241fe921, - 0x41785599, 0xafd7e08b, 0xcab05c33, 0x3bb659ed, 0x5ed1e555, - 0xb07e5047, 0xd519ecff, 0x6c213b62, 0x094687da, 0xe7e932c8, - 0x828e8e70, 0xd49eed28, 0xb1f95190, 0x5f56e482, 0x3a31583a, - 0x83098fa7, 0xe66e331f, 0x08c1860d, 0x6da63ab5, 0xa4e140bd, - 0xc186fc05, 0x2f294917, 0x4a4ef5af, 0xf3762232, 0x96119e8a, - 0x78be2b98, 0x1dd99720, 0x4bc9f478, 0x2eae48c0, 0xc001fdd2, - 0xa566416a, 0x1c5e96f7, 0x79392a4f, 0x97969f5d, 0xf2f123e5, - 0x05196b4d, 0x607ed7f5, 0x8ed162e7, 0xebb6de5f, 0x528e09c2, - 0x37e9b57a, 0xd9460068, 0xbc21bcd0, 0xea31df88, 0x8f566330, - 0x61f9d622, 0x049e6a9a, 0xbda6bd07, 0xd8c101bf, 0x366eb4ad, - 0x53090815, 0x9a4e721d, 0xff29cea5, 0x11867bb7, 0x74e1c70f, - 0xcdd91092, 0xa8beac2a, 0x46111938, 0x2376a580, 0x7566c6d8, - 0x10017a60, 0xfeaecf72, 0x9bc973ca, 0x22f1a457, 0x479618ef, - 0xa939adfd, 0xcc5e1145, 0x06ee4d76, 0x6389f1ce, 0x8d2644dc, - 0xe841f864, 0x51792ff9, 0x341e9341, 0xdab12653, 0xbfd69aeb, - 0xe9c6f9b3, 0x8ca1450b, 0x620ef019, 0x07694ca1, 0xbe519b3c, - 0xdb362784, 0x35999296, 0x50fe2e2e, 0x99b95426, 0xfcdee89e, - 0x12715d8c, 0x7716e134, 0xce2e36a9, 0xab498a11, 0x45e63f03, - 0x208183bb, 0x7691e0e3, 0x13f65c5b, 0xfd59e949, 0x983e55f1, - 0x2106826c, 0x44613ed4, 0xaace8bc6, 0xcfa9377e, 0x38417fd6, - 0x5d26c36e, 0xb389767c, 0xd6eecac4, 0x6fd61d59, 0x0ab1a1e1, - 0xe41e14f3, 0x8179a84b, 0xd769cb13, 0xb20e77ab, 0x5ca1c2b9, - 0x39c67e01, 0x80fea99c, 0xe5991524, 0x0b36a036, 0x6e511c8e, - 0xa7166686, 0xc271da3e, 0x2cde6f2c, 0x49b9d394, 0xf0810409, - 0x95e6b8b1, 0x7b490da3, 0x1e2eb11b, 0x483ed243, 0x2d596efb, - 0xc3f6dbe9, 0xa6916751, 0x1fa9b0cc, 0x7ace0c74, 0x9461b966, - 0xf10605de}}; - -#endif - -#endif - -#if N == 2 - -#if W == 8 - -local const z_crc_t FAR crc_braid_table[][256] = { - {0x00000000, 0xae689191, 0x87a02563, 0x29c8b4f2, 0xd4314c87, - 0x7a59dd16, 0x539169e4, 0xfdf9f875, 0x73139f4f, 0xdd7b0ede, - 0xf4b3ba2c, 0x5adb2bbd, 0xa722d3c8, 0x094a4259, 0x2082f6ab, - 0x8eea673a, 0xe6273e9e, 0x484faf0f, 0x61871bfd, 0xcfef8a6c, - 0x32167219, 0x9c7ee388, 0xb5b6577a, 0x1bdec6eb, 0x9534a1d1, - 0x3b5c3040, 0x129484b2, 0xbcfc1523, 0x4105ed56, 0xef6d7cc7, - 0xc6a5c835, 0x68cd59a4, 0x173f7b7d, 0xb957eaec, 0x909f5e1e, - 0x3ef7cf8f, 0xc30e37fa, 0x6d66a66b, 0x44ae1299, 0xeac68308, - 0x642ce432, 0xca4475a3, 0xe38cc151, 0x4de450c0, 0xb01da8b5, - 0x1e753924, 0x37bd8dd6, 0x99d51c47, 0xf11845e3, 0x5f70d472, - 0x76b86080, 0xd8d0f111, 0x25290964, 0x8b4198f5, 0xa2892c07, - 0x0ce1bd96, 0x820bdaac, 0x2c634b3d, 0x05abffcf, 0xabc36e5e, - 0x563a962b, 0xf85207ba, 0xd19ab348, 0x7ff222d9, 0x2e7ef6fa, - 0x8016676b, 0xa9ded399, 0x07b64208, 0xfa4fba7d, 0x54272bec, - 0x7def9f1e, 0xd3870e8f, 0x5d6d69b5, 0xf305f824, 0xdacd4cd6, - 0x74a5dd47, 0x895c2532, 0x2734b4a3, 0x0efc0051, 0xa09491c0, - 0xc859c864, 0x663159f5, 0x4ff9ed07, 0xe1917c96, 0x1c6884e3, - 0xb2001572, 0x9bc8a180, 0x35a03011, 0xbb4a572b, 0x1522c6ba, - 0x3cea7248, 0x9282e3d9, 0x6f7b1bac, 0xc1138a3d, 0xe8db3ecf, - 0x46b3af5e, 0x39418d87, 0x97291c16, 0xbee1a8e4, 0x10893975, - 0xed70c100, 0x43185091, 0x6ad0e463, 0xc4b875f2, 0x4a5212c8, - 0xe43a8359, 0xcdf237ab, 0x639aa63a, 0x9e635e4f, 0x300bcfde, - 0x19c37b2c, 0xb7abeabd, 0xdf66b319, 0x710e2288, 0x58c6967a, - 0xf6ae07eb, 0x0b57ff9e, 0xa53f6e0f, 0x8cf7dafd, 0x229f4b6c, - 0xac752c56, 0x021dbdc7, 0x2bd50935, 0x85bd98a4, 0x784460d1, - 0xd62cf140, 0xffe445b2, 0x518cd423, 0x5cfdedf4, 0xf2957c65, - 0xdb5dc897, 0x75355906, 0x88cca173, 0x26a430e2, 0x0f6c8410, - 0xa1041581, 0x2fee72bb, 0x8186e32a, 0xa84e57d8, 0x0626c649, - 0xfbdf3e3c, 0x55b7afad, 0x7c7f1b5f, 0xd2178ace, 0xbadad36a, - 0x14b242fb, 0x3d7af609, 0x93126798, 0x6eeb9fed, 0xc0830e7c, - 0xe94bba8e, 0x47232b1f, 0xc9c94c25, 0x67a1ddb4, 0x4e696946, - 0xe001f8d7, 0x1df800a2, 0xb3909133, 0x9a5825c1, 0x3430b450, - 0x4bc29689, 0xe5aa0718, 0xcc62b3ea, 0x620a227b, 0x9ff3da0e, - 0x319b4b9f, 0x1853ff6d, 0xb63b6efc, 0x38d109c6, 0x96b99857, - 0xbf712ca5, 0x1119bd34, 0xece04541, 0x4288d4d0, 0x6b406022, - 0xc528f1b3, 0xade5a817, 0x038d3986, 0x2a458d74, 0x842d1ce5, - 0x79d4e490, 0xd7bc7501, 0xfe74c1f3, 0x501c5062, 0xdef63758, - 0x709ea6c9, 0x5956123b, 0xf73e83aa, 0x0ac77bdf, 0xa4afea4e, - 0x8d675ebc, 0x230fcf2d, 0x72831b0e, 0xdceb8a9f, 0xf5233e6d, - 0x5b4baffc, 0xa6b25789, 0x08dac618, 0x211272ea, 0x8f7ae37b, - 0x01908441, 0xaff815d0, 0x8630a122, 0x285830b3, 0xd5a1c8c6, - 0x7bc95957, 0x5201eda5, 0xfc697c34, 0x94a42590, 0x3accb401, - 0x130400f3, 0xbd6c9162, 0x40956917, 0xeefdf886, 0xc7354c74, - 0x695ddde5, 0xe7b7badf, 0x49df2b4e, 0x60179fbc, 0xce7f0e2d, - 0x3386f658, 0x9dee67c9, 0xb426d33b, 0x1a4e42aa, 0x65bc6073, - 0xcbd4f1e2, 0xe21c4510, 0x4c74d481, 0xb18d2cf4, 0x1fe5bd65, - 0x362d0997, 0x98459806, 0x16afff3c, 0xb8c76ead, 0x910fda5f, - 0x3f674bce, 0xc29eb3bb, 0x6cf6222a, 0x453e96d8, 0xeb560749, - 0x839b5eed, 0x2df3cf7c, 0x043b7b8e, 0xaa53ea1f, 0x57aa126a, - 0xf9c283fb, 0xd00a3709, 0x7e62a698, 0xf088c1a2, 0x5ee05033, - 0x7728e4c1, 0xd9407550, 0x24b98d25, 0x8ad11cb4, 0xa319a846, - 0x0d7139d7}, - {0x00000000, 0xb9fbdbe8, 0xa886b191, 0x117d6a79, 0x8a7c6563, - 0x3387be8b, 0x22fad4f2, 0x9b010f1a, 0xcf89cc87, 0x7672176f, - 0x670f7d16, 0xdef4a6fe, 0x45f5a9e4, 0xfc0e720c, 0xed731875, - 0x5488c39d, 0x44629f4f, 0xfd9944a7, 0xece42ede, 0x551ff536, - 0xce1efa2c, 0x77e521c4, 0x66984bbd, 0xdf639055, 0x8beb53c8, - 0x32108820, 0x236de259, 0x9a9639b1, 0x019736ab, 0xb86ced43, - 0xa911873a, 0x10ea5cd2, 0x88c53e9e, 0x313ee576, 0x20438f0f, - 0x99b854e7, 0x02b95bfd, 0xbb428015, 0xaa3fea6c, 0x13c43184, - 0x474cf219, 0xfeb729f1, 0xefca4388, 0x56319860, 0xcd30977a, - 0x74cb4c92, 0x65b626eb, 0xdc4dfd03, 0xcca7a1d1, 0x755c7a39, - 0x64211040, 0xdddacba8, 0x46dbc4b2, 0xff201f5a, 0xee5d7523, - 0x57a6aecb, 0x032e6d56, 0xbad5b6be, 0xaba8dcc7, 0x1253072f, - 0x89520835, 0x30a9d3dd, 0x21d4b9a4, 0x982f624c, 0xcafb7b7d, - 0x7300a095, 0x627dcaec, 0xdb861104, 0x40871e1e, 0xf97cc5f6, - 0xe801af8f, 0x51fa7467, 0x0572b7fa, 0xbc896c12, 0xadf4066b, - 0x140fdd83, 0x8f0ed299, 0x36f50971, 0x27886308, 0x9e73b8e0, - 0x8e99e432, 0x37623fda, 0x261f55a3, 0x9fe48e4b, 0x04e58151, - 0xbd1e5ab9, 0xac6330c0, 0x1598eb28, 0x411028b5, 0xf8ebf35d, - 0xe9969924, 0x506d42cc, 0xcb6c4dd6, 0x7297963e, 0x63eafc47, - 0xda1127af, 0x423e45e3, 0xfbc59e0b, 0xeab8f472, 0x53432f9a, - 0xc8422080, 0x71b9fb68, 0x60c49111, 0xd93f4af9, 0x8db78964, - 0x344c528c, 0x253138f5, 0x9ccae31d, 0x07cbec07, 0xbe3037ef, - 0xaf4d5d96, 0x16b6867e, 0x065cdaac, 0xbfa70144, 0xaeda6b3d, - 0x1721b0d5, 0x8c20bfcf, 0x35db6427, 0x24a60e5e, 0x9d5dd5b6, - 0xc9d5162b, 0x702ecdc3, 0x6153a7ba, 0xd8a87c52, 0x43a97348, - 0xfa52a8a0, 0xeb2fc2d9, 0x52d41931, 0x4e87f0bb, 0xf77c2b53, - 0xe601412a, 0x5ffa9ac2, 0xc4fb95d8, 0x7d004e30, 0x6c7d2449, - 0xd586ffa1, 0x810e3c3c, 0x38f5e7d4, 0x29888dad, 0x90735645, - 0x0b72595f, 0xb28982b7, 0xa3f4e8ce, 0x1a0f3326, 0x0ae56ff4, - 0xb31eb41c, 0xa263de65, 0x1b98058d, 0x80990a97, 0x3962d17f, - 0x281fbb06, 0x91e460ee, 0xc56ca373, 0x7c97789b, 0x6dea12e2, - 0xd411c90a, 0x4f10c610, 0xf6eb1df8, 0xe7967781, 0x5e6dac69, - 0xc642ce25, 0x7fb915cd, 0x6ec47fb4, 0xd73fa45c, 0x4c3eab46, - 0xf5c570ae, 0xe4b81ad7, 0x5d43c13f, 0x09cb02a2, 0xb030d94a, - 0xa14db333, 0x18b668db, 0x83b767c1, 0x3a4cbc29, 0x2b31d650, - 0x92ca0db8, 0x8220516a, 0x3bdb8a82, 0x2aa6e0fb, 0x935d3b13, - 0x085c3409, 0xb1a7efe1, 0xa0da8598, 0x19215e70, 0x4da99ded, - 0xf4524605, 0xe52f2c7c, 0x5cd4f794, 0xc7d5f88e, 0x7e2e2366, - 0x6f53491f, 0xd6a892f7, 0x847c8bc6, 0x3d87502e, 0x2cfa3a57, - 0x9501e1bf, 0x0e00eea5, 0xb7fb354d, 0xa6865f34, 0x1f7d84dc, - 0x4bf54741, 0xf20e9ca9, 0xe373f6d0, 0x5a882d38, 0xc1892222, - 0x7872f9ca, 0x690f93b3, 0xd0f4485b, 0xc01e1489, 0x79e5cf61, - 0x6898a518, 0xd1637ef0, 0x4a6271ea, 0xf399aa02, 0xe2e4c07b, - 0x5b1f1b93, 0x0f97d80e, 0xb66c03e6, 0xa711699f, 0x1eeab277, - 0x85ebbd6d, 0x3c106685, 0x2d6d0cfc, 0x9496d714, 0x0cb9b558, - 0xb5426eb0, 0xa43f04c9, 0x1dc4df21, 0x86c5d03b, 0x3f3e0bd3, - 0x2e4361aa, 0x97b8ba42, 0xc33079df, 0x7acba237, 0x6bb6c84e, - 0xd24d13a6, 0x494c1cbc, 0xf0b7c754, 0xe1caad2d, 0x583176c5, - 0x48db2a17, 0xf120f1ff, 0xe05d9b86, 0x59a6406e, 0xc2a74f74, - 0x7b5c949c, 0x6a21fee5, 0xd3da250d, 0x8752e690, 0x3ea93d78, - 0x2fd45701, 0x962f8ce9, 0x0d2e83f3, 0xb4d5581b, 0xa5a83262, - 0x1c53e98a}, - {0x00000000, 0x9d0fe176, 0xe16ec4ad, 0x7c6125db, 0x19ac8f1b, - 0x84a36e6d, 0xf8c24bb6, 0x65cdaac0, 0x33591e36, 0xae56ff40, - 0xd237da9b, 0x4f383bed, 0x2af5912d, 0xb7fa705b, 0xcb9b5580, - 0x5694b4f6, 0x66b23c6c, 0xfbbddd1a, 0x87dcf8c1, 0x1ad319b7, - 0x7f1eb377, 0xe2115201, 0x9e7077da, 0x037f96ac, 0x55eb225a, - 0xc8e4c32c, 0xb485e6f7, 0x298a0781, 0x4c47ad41, 0xd1484c37, - 0xad2969ec, 0x3026889a, 0xcd6478d8, 0x506b99ae, 0x2c0abc75, - 0xb1055d03, 0xd4c8f7c3, 0x49c716b5, 0x35a6336e, 0xa8a9d218, - 0xfe3d66ee, 0x63328798, 0x1f53a243, 0x825c4335, 0xe791e9f5, - 0x7a9e0883, 0x06ff2d58, 0x9bf0cc2e, 0xabd644b4, 0x36d9a5c2, - 0x4ab88019, 0xd7b7616f, 0xb27acbaf, 0x2f752ad9, 0x53140f02, - 0xce1bee74, 0x988f5a82, 0x0580bbf4, 0x79e19e2f, 0xe4ee7f59, - 0x8123d599, 0x1c2c34ef, 0x604d1134, 0xfd42f042, 0x41b9f7f1, - 0xdcb61687, 0xa0d7335c, 0x3dd8d22a, 0x581578ea, 0xc51a999c, - 0xb97bbc47, 0x24745d31, 0x72e0e9c7, 0xefef08b1, 0x938e2d6a, - 0x0e81cc1c, 0x6b4c66dc, 0xf64387aa, 0x8a22a271, 0x172d4307, - 0x270bcb9d, 0xba042aeb, 0xc6650f30, 0x5b6aee46, 0x3ea74486, - 0xa3a8a5f0, 0xdfc9802b, 0x42c6615d, 0x1452d5ab, 0x895d34dd, - 0xf53c1106, 0x6833f070, 0x0dfe5ab0, 0x90f1bbc6, 0xec909e1d, - 0x719f7f6b, 0x8cdd8f29, 0x11d26e5f, 0x6db34b84, 0xf0bcaaf2, - 0x95710032, 0x087ee144, 0x741fc49f, 0xe91025e9, 0xbf84911f, - 0x228b7069, 0x5eea55b2, 0xc3e5b4c4, 0xa6281e04, 0x3b27ff72, - 0x4746daa9, 0xda493bdf, 0xea6fb345, 0x77605233, 0x0b0177e8, - 0x960e969e, 0xf3c33c5e, 0x6eccdd28, 0x12adf8f3, 0x8fa21985, - 0xd936ad73, 0x44394c05, 0x385869de, 0xa55788a8, 0xc09a2268, - 0x5d95c31e, 0x21f4e6c5, 0xbcfb07b3, 0x8373efe2, 0x1e7c0e94, - 0x621d2b4f, 0xff12ca39, 0x9adf60f9, 0x07d0818f, 0x7bb1a454, - 0xe6be4522, 0xb02af1d4, 0x2d2510a2, 0x51443579, 0xcc4bd40f, - 0xa9867ecf, 0x34899fb9, 0x48e8ba62, 0xd5e75b14, 0xe5c1d38e, - 0x78ce32f8, 0x04af1723, 0x99a0f655, 0xfc6d5c95, 0x6162bde3, - 0x1d039838, 0x800c794e, 0xd698cdb8, 0x4b972cce, 0x37f60915, - 0xaaf9e863, 0xcf3442a3, 0x523ba3d5, 0x2e5a860e, 0xb3556778, - 0x4e17973a, 0xd318764c, 0xaf795397, 0x3276b2e1, 0x57bb1821, - 0xcab4f957, 0xb6d5dc8c, 0x2bda3dfa, 0x7d4e890c, 0xe041687a, - 0x9c204da1, 0x012facd7, 0x64e20617, 0xf9ede761, 0x858cc2ba, - 0x188323cc, 0x28a5ab56, 0xb5aa4a20, 0xc9cb6ffb, 0x54c48e8d, - 0x3109244d, 0xac06c53b, 0xd067e0e0, 0x4d680196, 0x1bfcb560, - 0x86f35416, 0xfa9271cd, 0x679d90bb, 0x02503a7b, 0x9f5fdb0d, - 0xe33efed6, 0x7e311fa0, 0xc2ca1813, 0x5fc5f965, 0x23a4dcbe, - 0xbeab3dc8, 0xdb669708, 0x4669767e, 0x3a0853a5, 0xa707b2d3, - 0xf1930625, 0x6c9ce753, 0x10fdc288, 0x8df223fe, 0xe83f893e, - 0x75306848, 0x09514d93, 0x945eace5, 0xa478247f, 0x3977c509, - 0x4516e0d2, 0xd81901a4, 0xbdd4ab64, 0x20db4a12, 0x5cba6fc9, - 0xc1b58ebf, 0x97213a49, 0x0a2edb3f, 0x764ffee4, 0xeb401f92, - 0x8e8db552, 0x13825424, 0x6fe371ff, 0xf2ec9089, 0x0fae60cb, - 0x92a181bd, 0xeec0a466, 0x73cf4510, 0x1602efd0, 0x8b0d0ea6, - 0xf76c2b7d, 0x6a63ca0b, 0x3cf77efd, 0xa1f89f8b, 0xdd99ba50, - 0x40965b26, 0x255bf1e6, 0xb8541090, 0xc435354b, 0x593ad43d, - 0x691c5ca7, 0xf413bdd1, 0x8872980a, 0x157d797c, 0x70b0d3bc, - 0xedbf32ca, 0x91de1711, 0x0cd1f667, 0x5a454291, 0xc74aa3e7, - 0xbb2b863c, 0x2624674a, 0x43e9cd8a, 0xdee62cfc, 0xa2870927, - 0x3f88e851}, - {0x00000000, 0xdd96d985, 0x605cb54b, 0xbdca6cce, 0xc0b96a96, - 0x1d2fb313, 0xa0e5dfdd, 0x7d730658, 0x5a03d36d, 0x87950ae8, - 0x3a5f6626, 0xe7c9bfa3, 0x9abab9fb, 0x472c607e, 0xfae60cb0, - 0x2770d535, 0xb407a6da, 0x69917f5f, 0xd45b1391, 0x09cdca14, - 0x74becc4c, 0xa92815c9, 0x14e27907, 0xc974a082, 0xee0475b7, - 0x3392ac32, 0x8e58c0fc, 0x53ce1979, 0x2ebd1f21, 0xf32bc6a4, - 0x4ee1aa6a, 0x937773ef, 0xb37e4bf5, 0x6ee89270, 0xd322febe, - 0x0eb4273b, 0x73c72163, 0xae51f8e6, 0x139b9428, 0xce0d4dad, - 0xe97d9898, 0x34eb411d, 0x89212dd3, 0x54b7f456, 0x29c4f20e, - 0xf4522b8b, 0x49984745, 0x940e9ec0, 0x0779ed2f, 0xdaef34aa, - 0x67255864, 0xbab381e1, 0xc7c087b9, 0x1a565e3c, 0xa79c32f2, - 0x7a0aeb77, 0x5d7a3e42, 0x80ece7c7, 0x3d268b09, 0xe0b0528c, - 0x9dc354d4, 0x40558d51, 0xfd9fe19f, 0x2009381a, 0xbd8d91ab, - 0x601b482e, 0xddd124e0, 0x0047fd65, 0x7d34fb3d, 0xa0a222b8, - 0x1d684e76, 0xc0fe97f3, 0xe78e42c6, 0x3a189b43, 0x87d2f78d, - 0x5a442e08, 0x27372850, 0xfaa1f1d5, 0x476b9d1b, 0x9afd449e, - 0x098a3771, 0xd41ceef4, 0x69d6823a, 0xb4405bbf, 0xc9335de7, - 0x14a58462, 0xa96fe8ac, 0x74f93129, 0x5389e41c, 0x8e1f3d99, - 0x33d55157, 0xee4388d2, 0x93308e8a, 0x4ea6570f, 0xf36c3bc1, - 0x2efae244, 0x0ef3da5e, 0xd36503db, 0x6eaf6f15, 0xb339b690, - 0xce4ab0c8, 0x13dc694d, 0xae160583, 0x7380dc06, 0x54f00933, - 0x8966d0b6, 0x34acbc78, 0xe93a65fd, 0x944963a5, 0x49dfba20, - 0xf415d6ee, 0x29830f6b, 0xbaf47c84, 0x6762a501, 0xdaa8c9cf, - 0x073e104a, 0x7a4d1612, 0xa7dbcf97, 0x1a11a359, 0xc7877adc, - 0xe0f7afe9, 0x3d61766c, 0x80ab1aa2, 0x5d3dc327, 0x204ec57f, - 0xfdd81cfa, 0x40127034, 0x9d84a9b1, 0xa06a2517, 0x7dfcfc92, - 0xc036905c, 0x1da049d9, 0x60d34f81, 0xbd459604, 0x008ffaca, - 0xdd19234f, 0xfa69f67a, 0x27ff2fff, 0x9a354331, 0x47a39ab4, - 0x3ad09cec, 0xe7464569, 0x5a8c29a7, 0x871af022, 0x146d83cd, - 0xc9fb5a48, 0x74313686, 0xa9a7ef03, 0xd4d4e95b, 0x094230de, - 0xb4885c10, 0x691e8595, 0x4e6e50a0, 0x93f88925, 0x2e32e5eb, - 0xf3a43c6e, 0x8ed73a36, 0x5341e3b3, 0xee8b8f7d, 0x331d56f8, - 0x13146ee2, 0xce82b767, 0x7348dba9, 0xaede022c, 0xd3ad0474, - 0x0e3bddf1, 0xb3f1b13f, 0x6e6768ba, 0x4917bd8f, 0x9481640a, - 0x294b08c4, 0xf4ddd141, 0x89aed719, 0x54380e9c, 0xe9f26252, - 0x3464bbd7, 0xa713c838, 0x7a8511bd, 0xc74f7d73, 0x1ad9a4f6, - 0x67aaa2ae, 0xba3c7b2b, 0x07f617e5, 0xda60ce60, 0xfd101b55, - 0x2086c2d0, 0x9d4cae1e, 0x40da779b, 0x3da971c3, 0xe03fa846, - 0x5df5c488, 0x80631d0d, 0x1de7b4bc, 0xc0716d39, 0x7dbb01f7, - 0xa02dd872, 0xdd5ede2a, 0x00c807af, 0xbd026b61, 0x6094b2e4, - 0x47e467d1, 0x9a72be54, 0x27b8d29a, 0xfa2e0b1f, 0x875d0d47, - 0x5acbd4c2, 0xe701b80c, 0x3a976189, 0xa9e01266, 0x7476cbe3, - 0xc9bca72d, 0x142a7ea8, 0x695978f0, 0xb4cfa175, 0x0905cdbb, - 0xd493143e, 0xf3e3c10b, 0x2e75188e, 0x93bf7440, 0x4e29adc5, - 0x335aab9d, 0xeecc7218, 0x53061ed6, 0x8e90c753, 0xae99ff49, - 0x730f26cc, 0xcec54a02, 0x13539387, 0x6e2095df, 0xb3b64c5a, - 0x0e7c2094, 0xd3eaf911, 0xf49a2c24, 0x290cf5a1, 0x94c6996f, - 0x495040ea, 0x342346b2, 0xe9b59f37, 0x547ff3f9, 0x89e92a7c, - 0x1a9e5993, 0xc7088016, 0x7ac2ecd8, 0xa754355d, 0xda273305, - 0x07b1ea80, 0xba7b864e, 0x67ed5fcb, 0x409d8afe, 0x9d0b537b, - 0x20c13fb5, 0xfd57e630, 0x8024e068, 0x5db239ed, 0xe0785523, - 0x3dee8ca6}, - {0x00000000, 0x9ba54c6f, 0xec3b9e9f, 0x779ed2f0, 0x03063b7f, - 0x98a37710, 0xef3da5e0, 0x7498e98f, 0x060c76fe, 0x9da93a91, - 0xea37e861, 0x7192a40e, 0x050a4d81, 0x9eaf01ee, 0xe931d31e, - 0x72949f71, 0x0c18edfc, 0x97bda193, 0xe0237363, 0x7b863f0c, - 0x0f1ed683, 0x94bb9aec, 0xe325481c, 0x78800473, 0x0a149b02, - 0x91b1d76d, 0xe62f059d, 0x7d8a49f2, 0x0912a07d, 0x92b7ec12, - 0xe5293ee2, 0x7e8c728d, 0x1831dbf8, 0x83949797, 0xf40a4567, - 0x6faf0908, 0x1b37e087, 0x8092ace8, 0xf70c7e18, 0x6ca93277, - 0x1e3dad06, 0x8598e169, 0xf2063399, 0x69a37ff6, 0x1d3b9679, - 0x869eda16, 0xf10008e6, 0x6aa54489, 0x14293604, 0x8f8c7a6b, - 0xf812a89b, 0x63b7e4f4, 0x172f0d7b, 0x8c8a4114, 0xfb1493e4, - 0x60b1df8b, 0x122540fa, 0x89800c95, 0xfe1ede65, 0x65bb920a, - 0x11237b85, 0x8a8637ea, 0xfd18e51a, 0x66bda975, 0x3063b7f0, - 0xabc6fb9f, 0xdc58296f, 0x47fd6500, 0x33658c8f, 0xa8c0c0e0, - 0xdf5e1210, 0x44fb5e7f, 0x366fc10e, 0xadca8d61, 0xda545f91, - 0x41f113fe, 0x3569fa71, 0xaeccb61e, 0xd95264ee, 0x42f72881, - 0x3c7b5a0c, 0xa7de1663, 0xd040c493, 0x4be588fc, 0x3f7d6173, - 0xa4d82d1c, 0xd346ffec, 0x48e3b383, 0x3a772cf2, 0xa1d2609d, - 0xd64cb26d, 0x4de9fe02, 0x3971178d, 0xa2d45be2, 0xd54a8912, - 0x4eefc57d, 0x28526c08, 0xb3f72067, 0xc469f297, 0x5fccbef8, - 0x2b545777, 0xb0f11b18, 0xc76fc9e8, 0x5cca8587, 0x2e5e1af6, - 0xb5fb5699, 0xc2658469, 0x59c0c806, 0x2d582189, 0xb6fd6de6, - 0xc163bf16, 0x5ac6f379, 0x244a81f4, 0xbfefcd9b, 0xc8711f6b, - 0x53d45304, 0x274cba8b, 0xbce9f6e4, 0xcb772414, 0x50d2687b, - 0x2246f70a, 0xb9e3bb65, 0xce7d6995, 0x55d825fa, 0x2140cc75, - 0xbae5801a, 0xcd7b52ea, 0x56de1e85, 0x60c76fe0, 0xfb62238f, - 0x8cfcf17f, 0x1759bd10, 0x63c1549f, 0xf86418f0, 0x8ffaca00, - 0x145f866f, 0x66cb191e, 0xfd6e5571, 0x8af08781, 0x1155cbee, - 0x65cd2261, 0xfe686e0e, 0x89f6bcfe, 0x1253f091, 0x6cdf821c, - 0xf77ace73, 0x80e41c83, 0x1b4150ec, 0x6fd9b963, 0xf47cf50c, - 0x83e227fc, 0x18476b93, 0x6ad3f4e2, 0xf176b88d, 0x86e86a7d, - 0x1d4d2612, 0x69d5cf9d, 0xf27083f2, 0x85ee5102, 0x1e4b1d6d, - 0x78f6b418, 0xe353f877, 0x94cd2a87, 0x0f6866e8, 0x7bf08f67, - 0xe055c308, 0x97cb11f8, 0x0c6e5d97, 0x7efac2e6, 0xe55f8e89, - 0x92c15c79, 0x09641016, 0x7dfcf999, 0xe659b5f6, 0x91c76706, - 0x0a622b69, 0x74ee59e4, 0xef4b158b, 0x98d5c77b, 0x03708b14, - 0x77e8629b, 0xec4d2ef4, 0x9bd3fc04, 0x0076b06b, 0x72e22f1a, - 0xe9476375, 0x9ed9b185, 0x057cfdea, 0x71e41465, 0xea41580a, - 0x9ddf8afa, 0x067ac695, 0x50a4d810, 0xcb01947f, 0xbc9f468f, - 0x273a0ae0, 0x53a2e36f, 0xc807af00, 0xbf997df0, 0x243c319f, - 0x56a8aeee, 0xcd0de281, 0xba933071, 0x21367c1e, 0x55ae9591, - 0xce0bd9fe, 0xb9950b0e, 0x22304761, 0x5cbc35ec, 0xc7197983, - 0xb087ab73, 0x2b22e71c, 0x5fba0e93, 0xc41f42fc, 0xb381900c, - 0x2824dc63, 0x5ab04312, 0xc1150f7d, 0xb68bdd8d, 0x2d2e91e2, - 0x59b6786d, 0xc2133402, 0xb58de6f2, 0x2e28aa9d, 0x489503e8, - 0xd3304f87, 0xa4ae9d77, 0x3f0bd118, 0x4b933897, 0xd03674f8, - 0xa7a8a608, 0x3c0dea67, 0x4e997516, 0xd53c3979, 0xa2a2eb89, - 0x3907a7e6, 0x4d9f4e69, 0xd63a0206, 0xa1a4d0f6, 0x3a019c99, - 0x448dee14, 0xdf28a27b, 0xa8b6708b, 0x33133ce4, 0x478bd56b, - 0xdc2e9904, 0xabb04bf4, 0x3015079b, 0x428198ea, 0xd924d485, - 0xaeba0675, 0x351f4a1a, 0x4187a395, 0xda22effa, 0xadbc3d0a, - 0x36197165}, - {0x00000000, 0xc18edfc0, 0x586cb9c1, 0x99e26601, 0xb0d97382, - 0x7157ac42, 0xe8b5ca43, 0x293b1583, 0xbac3e145, 0x7b4d3e85, - 0xe2af5884, 0x23218744, 0x0a1a92c7, 0xcb944d07, 0x52762b06, - 0x93f8f4c6, 0xaef6c4cb, 0x6f781b0b, 0xf69a7d0a, 0x3714a2ca, - 0x1e2fb749, 0xdfa16889, 0x46430e88, 0x87cdd148, 0x1435258e, - 0xd5bbfa4e, 0x4c599c4f, 0x8dd7438f, 0xa4ec560c, 0x656289cc, - 0xfc80efcd, 0x3d0e300d, 0x869c8fd7, 0x47125017, 0xdef03616, - 0x1f7ee9d6, 0x3645fc55, 0xf7cb2395, 0x6e294594, 0xafa79a54, - 0x3c5f6e92, 0xfdd1b152, 0x6433d753, 0xa5bd0893, 0x8c861d10, - 0x4d08c2d0, 0xd4eaa4d1, 0x15647b11, 0x286a4b1c, 0xe9e494dc, - 0x7006f2dd, 0xb1882d1d, 0x98b3389e, 0x593de75e, 0xc0df815f, - 0x01515e9f, 0x92a9aa59, 0x53277599, 0xcac51398, 0x0b4bcc58, - 0x2270d9db, 0xe3fe061b, 0x7a1c601a, 0xbb92bfda, 0xd64819ef, - 0x17c6c62f, 0x8e24a02e, 0x4faa7fee, 0x66916a6d, 0xa71fb5ad, - 0x3efdd3ac, 0xff730c6c, 0x6c8bf8aa, 0xad05276a, 0x34e7416b, - 0xf5699eab, 0xdc528b28, 0x1ddc54e8, 0x843e32e9, 0x45b0ed29, - 0x78bedd24, 0xb93002e4, 0x20d264e5, 0xe15cbb25, 0xc867aea6, - 0x09e97166, 0x900b1767, 0x5185c8a7, 0xc27d3c61, 0x03f3e3a1, - 0x9a1185a0, 0x5b9f5a60, 0x72a44fe3, 0xb32a9023, 0x2ac8f622, - 0xeb4629e2, 0x50d49638, 0x915a49f8, 0x08b82ff9, 0xc936f039, - 0xe00de5ba, 0x21833a7a, 0xb8615c7b, 0x79ef83bb, 0xea17777d, - 0x2b99a8bd, 0xb27bcebc, 0x73f5117c, 0x5ace04ff, 0x9b40db3f, - 0x02a2bd3e, 0xc32c62fe, 0xfe2252f3, 0x3fac8d33, 0xa64eeb32, - 0x67c034f2, 0x4efb2171, 0x8f75feb1, 0x169798b0, 0xd7194770, - 0x44e1b3b6, 0x856f6c76, 0x1c8d0a77, 0xdd03d5b7, 0xf438c034, - 0x35b61ff4, 0xac5479f5, 0x6ddaa635, 0x77e1359f, 0xb66fea5f, - 0x2f8d8c5e, 0xee03539e, 0xc738461d, 0x06b699dd, 0x9f54ffdc, - 0x5eda201c, 0xcd22d4da, 0x0cac0b1a, 0x954e6d1b, 0x54c0b2db, - 0x7dfba758, 0xbc757898, 0x25971e99, 0xe419c159, 0xd917f154, - 0x18992e94, 0x817b4895, 0x40f59755, 0x69ce82d6, 0xa8405d16, - 0x31a23b17, 0xf02ce4d7, 0x63d41011, 0xa25acfd1, 0x3bb8a9d0, - 0xfa367610, 0xd30d6393, 0x1283bc53, 0x8b61da52, 0x4aef0592, - 0xf17dba48, 0x30f36588, 0xa9110389, 0x689fdc49, 0x41a4c9ca, - 0x802a160a, 0x19c8700b, 0xd846afcb, 0x4bbe5b0d, 0x8a3084cd, - 0x13d2e2cc, 0xd25c3d0c, 0xfb67288f, 0x3ae9f74f, 0xa30b914e, - 0x62854e8e, 0x5f8b7e83, 0x9e05a143, 0x07e7c742, 0xc6691882, - 0xef520d01, 0x2edcd2c1, 0xb73eb4c0, 0x76b06b00, 0xe5489fc6, - 0x24c64006, 0xbd242607, 0x7caaf9c7, 0x5591ec44, 0x941f3384, - 0x0dfd5585, 0xcc738a45, 0xa1a92c70, 0x6027f3b0, 0xf9c595b1, - 0x384b4a71, 0x11705ff2, 0xd0fe8032, 0x491ce633, 0x889239f3, - 0x1b6acd35, 0xdae412f5, 0x430674f4, 0x8288ab34, 0xabb3beb7, - 0x6a3d6177, 0xf3df0776, 0x3251d8b6, 0x0f5fe8bb, 0xced1377b, - 0x5733517a, 0x96bd8eba, 0xbf869b39, 0x7e0844f9, 0xe7ea22f8, - 0x2664fd38, 0xb59c09fe, 0x7412d63e, 0xedf0b03f, 0x2c7e6fff, - 0x05457a7c, 0xc4cba5bc, 0x5d29c3bd, 0x9ca71c7d, 0x2735a3a7, - 0xe6bb7c67, 0x7f591a66, 0xbed7c5a6, 0x97ecd025, 0x56620fe5, - 0xcf8069e4, 0x0e0eb624, 0x9df642e2, 0x5c789d22, 0xc59afb23, - 0x041424e3, 0x2d2f3160, 0xeca1eea0, 0x754388a1, 0xb4cd5761, - 0x89c3676c, 0x484db8ac, 0xd1afdead, 0x1021016d, 0x391a14ee, - 0xf894cb2e, 0x6176ad2f, 0xa0f872ef, 0x33008629, 0xf28e59e9, - 0x6b6c3fe8, 0xaae2e028, 0x83d9f5ab, 0x42572a6b, 0xdbb54c6a, - 0x1a3b93aa}, - {0x00000000, 0xefc26b3e, 0x04f5d03d, 0xeb37bb03, 0x09eba07a, - 0xe629cb44, 0x0d1e7047, 0xe2dc1b79, 0x13d740f4, 0xfc152bca, - 0x172290c9, 0xf8e0fbf7, 0x1a3ce08e, 0xf5fe8bb0, 0x1ec930b3, - 0xf10b5b8d, 0x27ae81e8, 0xc86cead6, 0x235b51d5, 0xcc993aeb, - 0x2e452192, 0xc1874aac, 0x2ab0f1af, 0xc5729a91, 0x3479c11c, - 0xdbbbaa22, 0x308c1121, 0xdf4e7a1f, 0x3d926166, 0xd2500a58, - 0x3967b15b, 0xd6a5da65, 0x4f5d03d0, 0xa09f68ee, 0x4ba8d3ed, - 0xa46ab8d3, 0x46b6a3aa, 0xa974c894, 0x42437397, 0xad8118a9, - 0x5c8a4324, 0xb348281a, 0x587f9319, 0xb7bdf827, 0x5561e35e, - 0xbaa38860, 0x51943363, 0xbe56585d, 0x68f38238, 0x8731e906, - 0x6c065205, 0x83c4393b, 0x61182242, 0x8eda497c, 0x65edf27f, - 0x8a2f9941, 0x7b24c2cc, 0x94e6a9f2, 0x7fd112f1, 0x901379cf, - 0x72cf62b6, 0x9d0d0988, 0x763ab28b, 0x99f8d9b5, 0x9eba07a0, - 0x71786c9e, 0x9a4fd79d, 0x758dbca3, 0x9751a7da, 0x7893cce4, - 0x93a477e7, 0x7c661cd9, 0x8d6d4754, 0x62af2c6a, 0x89989769, - 0x665afc57, 0x8486e72e, 0x6b448c10, 0x80733713, 0x6fb15c2d, - 0xb9148648, 0x56d6ed76, 0xbde15675, 0x52233d4b, 0xb0ff2632, - 0x5f3d4d0c, 0xb40af60f, 0x5bc89d31, 0xaac3c6bc, 0x4501ad82, - 0xae361681, 0x41f47dbf, 0xa32866c6, 0x4cea0df8, 0xa7ddb6fb, - 0x481fddc5, 0xd1e70470, 0x3e256f4e, 0xd512d44d, 0x3ad0bf73, - 0xd80ca40a, 0x37cecf34, 0xdcf97437, 0x333b1f09, 0xc2304484, - 0x2df22fba, 0xc6c594b9, 0x2907ff87, 0xcbdbe4fe, 0x24198fc0, - 0xcf2e34c3, 0x20ec5ffd, 0xf6498598, 0x198beea6, 0xf2bc55a5, - 0x1d7e3e9b, 0xffa225e2, 0x10604edc, 0xfb57f5df, 0x14959ee1, - 0xe59ec56c, 0x0a5cae52, 0xe16b1551, 0x0ea97e6f, 0xec756516, - 0x03b70e28, 0xe880b52b, 0x0742de15, 0xe6050901, 0x09c7623f, - 0xe2f0d93c, 0x0d32b202, 0xefeea97b, 0x002cc245, 0xeb1b7946, - 0x04d91278, 0xf5d249f5, 0x1a1022cb, 0xf12799c8, 0x1ee5f2f6, - 0xfc39e98f, 0x13fb82b1, 0xf8cc39b2, 0x170e528c, 0xc1ab88e9, - 0x2e69e3d7, 0xc55e58d4, 0x2a9c33ea, 0xc8402893, 0x278243ad, - 0xccb5f8ae, 0x23779390, 0xd27cc81d, 0x3dbea323, 0xd6891820, - 0x394b731e, 0xdb976867, 0x34550359, 0xdf62b85a, 0x30a0d364, - 0xa9580ad1, 0x469a61ef, 0xadaddaec, 0x426fb1d2, 0xa0b3aaab, - 0x4f71c195, 0xa4467a96, 0x4b8411a8, 0xba8f4a25, 0x554d211b, - 0xbe7a9a18, 0x51b8f126, 0xb364ea5f, 0x5ca68161, 0xb7913a62, - 0x5853515c, 0x8ef68b39, 0x6134e007, 0x8a035b04, 0x65c1303a, - 0x871d2b43, 0x68df407d, 0x83e8fb7e, 0x6c2a9040, 0x9d21cbcd, - 0x72e3a0f3, 0x99d41bf0, 0x761670ce, 0x94ca6bb7, 0x7b080089, - 0x903fbb8a, 0x7ffdd0b4, 0x78bf0ea1, 0x977d659f, 0x7c4ade9c, - 0x9388b5a2, 0x7154aedb, 0x9e96c5e5, 0x75a17ee6, 0x9a6315d8, - 0x6b684e55, 0x84aa256b, 0x6f9d9e68, 0x805ff556, 0x6283ee2f, - 0x8d418511, 0x66763e12, 0x89b4552c, 0x5f118f49, 0xb0d3e477, - 0x5be45f74, 0xb426344a, 0x56fa2f33, 0xb938440d, 0x520fff0e, - 0xbdcd9430, 0x4cc6cfbd, 0xa304a483, 0x48331f80, 0xa7f174be, - 0x452d6fc7, 0xaaef04f9, 0x41d8bffa, 0xae1ad4c4, 0x37e20d71, - 0xd820664f, 0x3317dd4c, 0xdcd5b672, 0x3e09ad0b, 0xd1cbc635, - 0x3afc7d36, 0xd53e1608, 0x24354d85, 0xcbf726bb, 0x20c09db8, - 0xcf02f686, 0x2ddeedff, 0xc21c86c1, 0x292b3dc2, 0xc6e956fc, - 0x104c8c99, 0xff8ee7a7, 0x14b95ca4, 0xfb7b379a, 0x19a72ce3, - 0xf66547dd, 0x1d52fcde, 0xf29097e0, 0x039bcc6d, 0xec59a753, - 0x076e1c50, 0xe8ac776e, 0x0a706c17, 0xe5b20729, 0x0e85bc2a, - 0xe147d714}, - {0x00000000, 0x177b1443, 0x2ef62886, 0x398d3cc5, 0x5dec510c, - 0x4a97454f, 0x731a798a, 0x64616dc9, 0xbbd8a218, 0xaca3b65b, - 0x952e8a9e, 0x82559edd, 0xe634f314, 0xf14fe757, 0xc8c2db92, - 0xdfb9cfd1, 0xacc04271, 0xbbbb5632, 0x82366af7, 0x954d7eb4, - 0xf12c137d, 0xe657073e, 0xdfda3bfb, 0xc8a12fb8, 0x1718e069, - 0x0063f42a, 0x39eec8ef, 0x2e95dcac, 0x4af4b165, 0x5d8fa526, - 0x640299e3, 0x73798da0, 0x82f182a3, 0x958a96e0, 0xac07aa25, - 0xbb7cbe66, 0xdf1dd3af, 0xc866c7ec, 0xf1ebfb29, 0xe690ef6a, - 0x392920bb, 0x2e5234f8, 0x17df083d, 0x00a41c7e, 0x64c571b7, - 0x73be65f4, 0x4a335931, 0x5d484d72, 0x2e31c0d2, 0x394ad491, - 0x00c7e854, 0x17bcfc17, 0x73dd91de, 0x64a6859d, 0x5d2bb958, - 0x4a50ad1b, 0x95e962ca, 0x82927689, 0xbb1f4a4c, 0xac645e0f, - 0xc80533c6, 0xdf7e2785, 0xe6f31b40, 0xf1880f03, 0xde920307, - 0xc9e91744, 0xf0642b81, 0xe71f3fc2, 0x837e520b, 0x94054648, - 0xad887a8d, 0xbaf36ece, 0x654aa11f, 0x7231b55c, 0x4bbc8999, - 0x5cc79dda, 0x38a6f013, 0x2fdde450, 0x1650d895, 0x012bccd6, - 0x72524176, 0x65295535, 0x5ca469f0, 0x4bdf7db3, 0x2fbe107a, - 0x38c50439, 0x014838fc, 0x16332cbf, 0xc98ae36e, 0xdef1f72d, - 0xe77ccbe8, 0xf007dfab, 0x9466b262, 0x831da621, 0xba909ae4, - 0xadeb8ea7, 0x5c6381a4, 0x4b1895e7, 0x7295a922, 0x65eebd61, - 0x018fd0a8, 0x16f4c4eb, 0x2f79f82e, 0x3802ec6d, 0xe7bb23bc, - 0xf0c037ff, 0xc94d0b3a, 0xde361f79, 0xba5772b0, 0xad2c66f3, - 0x94a15a36, 0x83da4e75, 0xf0a3c3d5, 0xe7d8d796, 0xde55eb53, - 0xc92eff10, 0xad4f92d9, 0xba34869a, 0x83b9ba5f, 0x94c2ae1c, - 0x4b7b61cd, 0x5c00758e, 0x658d494b, 0x72f65d08, 0x169730c1, - 0x01ec2482, 0x38611847, 0x2f1a0c04, 0x6655004f, 0x712e140c, - 0x48a328c9, 0x5fd83c8a, 0x3bb95143, 0x2cc24500, 0x154f79c5, - 0x02346d86, 0xdd8da257, 0xcaf6b614, 0xf37b8ad1, 0xe4009e92, - 0x8061f35b, 0x971ae718, 0xae97dbdd, 0xb9eccf9e, 0xca95423e, - 0xddee567d, 0xe4636ab8, 0xf3187efb, 0x97791332, 0x80020771, - 0xb98f3bb4, 0xaef42ff7, 0x714de026, 0x6636f465, 0x5fbbc8a0, - 0x48c0dce3, 0x2ca1b12a, 0x3bdaa569, 0x025799ac, 0x152c8def, - 0xe4a482ec, 0xf3df96af, 0xca52aa6a, 0xdd29be29, 0xb948d3e0, - 0xae33c7a3, 0x97befb66, 0x80c5ef25, 0x5f7c20f4, 0x480734b7, - 0x718a0872, 0x66f11c31, 0x029071f8, 0x15eb65bb, 0x2c66597e, - 0x3b1d4d3d, 0x4864c09d, 0x5f1fd4de, 0x6692e81b, 0x71e9fc58, - 0x15889191, 0x02f385d2, 0x3b7eb917, 0x2c05ad54, 0xf3bc6285, - 0xe4c776c6, 0xdd4a4a03, 0xca315e40, 0xae503389, 0xb92b27ca, - 0x80a61b0f, 0x97dd0f4c, 0xb8c70348, 0xafbc170b, 0x96312bce, - 0x814a3f8d, 0xe52b5244, 0xf2504607, 0xcbdd7ac2, 0xdca66e81, - 0x031fa150, 0x1464b513, 0x2de989d6, 0x3a929d95, 0x5ef3f05c, - 0x4988e41f, 0x7005d8da, 0x677ecc99, 0x14074139, 0x037c557a, - 0x3af169bf, 0x2d8a7dfc, 0x49eb1035, 0x5e900476, 0x671d38b3, - 0x70662cf0, 0xafdfe321, 0xb8a4f762, 0x8129cba7, 0x9652dfe4, - 0xf233b22d, 0xe548a66e, 0xdcc59aab, 0xcbbe8ee8, 0x3a3681eb, - 0x2d4d95a8, 0x14c0a96d, 0x03bbbd2e, 0x67dad0e7, 0x70a1c4a4, - 0x492cf861, 0x5e57ec22, 0x81ee23f3, 0x969537b0, 0xaf180b75, - 0xb8631f36, 0xdc0272ff, 0xcb7966bc, 0xf2f45a79, 0xe58f4e3a, - 0x96f6c39a, 0x818dd7d9, 0xb800eb1c, 0xaf7bff5f, 0xcb1a9296, - 0xdc6186d5, 0xe5ecba10, 0xf297ae53, 0x2d2e6182, 0x3a5575c1, - 0x03d84904, 0x14a35d47, 0x70c2308e, 0x67b924cd, 0x5e341808, - 0x494f0c4b}}; - -local const z_word_t FAR crc_braid_big_table[][256] = { - {0x0000000000000000, 0x43147b1700000000, 0x8628f62e00000000, - 0xc53c8d3900000000, 0x0c51ec5d00000000, 0x4f45974a00000000, - 0x8a791a7300000000, 0xc96d616400000000, 0x18a2d8bb00000000, - 0x5bb6a3ac00000000, 0x9e8a2e9500000000, 0xdd9e558200000000, - 0x14f334e600000000, 0x57e74ff100000000, 0x92dbc2c800000000, - 0xd1cfb9df00000000, 0x7142c0ac00000000, 0x3256bbbb00000000, - 0xf76a368200000000, 0xb47e4d9500000000, 0x7d132cf100000000, - 0x3e0757e600000000, 0xfb3bdadf00000000, 0xb82fa1c800000000, - 0x69e0181700000000, 0x2af4630000000000, 0xefc8ee3900000000, - 0xacdc952e00000000, 0x65b1f44a00000000, 0x26a58f5d00000000, - 0xe399026400000000, 0xa08d797300000000, 0xa382f18200000000, - 0xe0968a9500000000, 0x25aa07ac00000000, 0x66be7cbb00000000, - 0xafd31ddf00000000, 0xecc766c800000000, 0x29fbebf100000000, - 0x6aef90e600000000, 0xbb20293900000000, 0xf834522e00000000, - 0x3d08df1700000000, 0x7e1ca40000000000, 0xb771c56400000000, - 0xf465be7300000000, 0x3159334a00000000, 0x724d485d00000000, - 0xd2c0312e00000000, 0x91d44a3900000000, 0x54e8c70000000000, - 0x17fcbc1700000000, 0xde91dd7300000000, 0x9d85a66400000000, - 0x58b92b5d00000000, 0x1bad504a00000000, 0xca62e99500000000, - 0x8976928200000000, 0x4c4a1fbb00000000, 0x0f5e64ac00000000, - 0xc63305c800000000, 0x85277edf00000000, 0x401bf3e600000000, - 0x030f88f100000000, 0x070392de00000000, 0x4417e9c900000000, - 0x812b64f000000000, 0xc23f1fe700000000, 0x0b527e8300000000, - 0x4846059400000000, 0x8d7a88ad00000000, 0xce6ef3ba00000000, - 0x1fa14a6500000000, 0x5cb5317200000000, 0x9989bc4b00000000, - 0xda9dc75c00000000, 0x13f0a63800000000, 0x50e4dd2f00000000, - 0x95d8501600000000, 0xd6cc2b0100000000, 0x7641527200000000, - 0x3555296500000000, 0xf069a45c00000000, 0xb37ddf4b00000000, - 0x7a10be2f00000000, 0x3904c53800000000, 0xfc38480100000000, - 0xbf2c331600000000, 0x6ee38ac900000000, 0x2df7f1de00000000, - 0xe8cb7ce700000000, 0xabdf07f000000000, 0x62b2669400000000, - 0x21a61d8300000000, 0xe49a90ba00000000, 0xa78eebad00000000, - 0xa481635c00000000, 0xe795184b00000000, 0x22a9957200000000, - 0x61bdee6500000000, 0xa8d08f0100000000, 0xebc4f41600000000, - 0x2ef8792f00000000, 0x6dec023800000000, 0xbc23bbe700000000, - 0xff37c0f000000000, 0x3a0b4dc900000000, 0x791f36de00000000, - 0xb07257ba00000000, 0xf3662cad00000000, 0x365aa19400000000, - 0x754eda8300000000, 0xd5c3a3f000000000, 0x96d7d8e700000000, - 0x53eb55de00000000, 0x10ff2ec900000000, 0xd9924fad00000000, - 0x9a8634ba00000000, 0x5fbab98300000000, 0x1caec29400000000, - 0xcd617b4b00000000, 0x8e75005c00000000, 0x4b498d6500000000, - 0x085df67200000000, 0xc130971600000000, 0x8224ec0100000000, - 0x4718613800000000, 0x040c1a2f00000000, 0x4f00556600000000, - 0x0c142e7100000000, 0xc928a34800000000, 0x8a3cd85f00000000, - 0x4351b93b00000000, 0x0045c22c00000000, 0xc5794f1500000000, - 0x866d340200000000, 0x57a28ddd00000000, 0x14b6f6ca00000000, - 0xd18a7bf300000000, 0x929e00e400000000, 0x5bf3618000000000, - 0x18e71a9700000000, 0xdddb97ae00000000, 0x9ecfecb900000000, - 0x3e4295ca00000000, 0x7d56eedd00000000, 0xb86a63e400000000, - 0xfb7e18f300000000, 0x3213799700000000, 0x7107028000000000, - 0xb43b8fb900000000, 0xf72ff4ae00000000, 0x26e04d7100000000, - 0x65f4366600000000, 0xa0c8bb5f00000000, 0xe3dcc04800000000, - 0x2ab1a12c00000000, 0x69a5da3b00000000, 0xac99570200000000, - 0xef8d2c1500000000, 0xec82a4e400000000, 0xaf96dff300000000, - 0x6aaa52ca00000000, 0x29be29dd00000000, 0xe0d348b900000000, - 0xa3c733ae00000000, 0x66fbbe9700000000, 0x25efc58000000000, - 0xf4207c5f00000000, 0xb734074800000000, 0x72088a7100000000, - 0x311cf16600000000, 0xf871900200000000, 0xbb65eb1500000000, - 0x7e59662c00000000, 0x3d4d1d3b00000000, 0x9dc0644800000000, - 0xded41f5f00000000, 0x1be8926600000000, 0x58fce97100000000, - 0x9191881500000000, 0xd285f30200000000, 0x17b97e3b00000000, - 0x54ad052c00000000, 0x8562bcf300000000, 0xc676c7e400000000, - 0x034a4add00000000, 0x405e31ca00000000, 0x893350ae00000000, - 0xca272bb900000000, 0x0f1ba68000000000, 0x4c0fdd9700000000, - 0x4803c7b800000000, 0x0b17bcaf00000000, 0xce2b319600000000, - 0x8d3f4a8100000000, 0x44522be500000000, 0x074650f200000000, - 0xc27addcb00000000, 0x816ea6dc00000000, 0x50a11f0300000000, - 0x13b5641400000000, 0xd689e92d00000000, 0x959d923a00000000, - 0x5cf0f35e00000000, 0x1fe4884900000000, 0xdad8057000000000, - 0x99cc7e6700000000, 0x3941071400000000, 0x7a557c0300000000, - 0xbf69f13a00000000, 0xfc7d8a2d00000000, 0x3510eb4900000000, - 0x7604905e00000000, 0xb3381d6700000000, 0xf02c667000000000, - 0x21e3dfaf00000000, 0x62f7a4b800000000, 0xa7cb298100000000, - 0xe4df529600000000, 0x2db233f200000000, 0x6ea648e500000000, - 0xab9ac5dc00000000, 0xe88ebecb00000000, 0xeb81363a00000000, - 0xa8954d2d00000000, 0x6da9c01400000000, 0x2ebdbb0300000000, - 0xe7d0da6700000000, 0xa4c4a17000000000, 0x61f82c4900000000, - 0x22ec575e00000000, 0xf323ee8100000000, 0xb037959600000000, - 0x750b18af00000000, 0x361f63b800000000, 0xff7202dc00000000, - 0xbc6679cb00000000, 0x795af4f200000000, 0x3a4e8fe500000000, - 0x9ac3f69600000000, 0xd9d78d8100000000, 0x1ceb00b800000000, - 0x5fff7baf00000000, 0x96921acb00000000, 0xd58661dc00000000, - 0x10baece500000000, 0x53ae97f200000000, 0x82612e2d00000000, - 0xc175553a00000000, 0x0449d80300000000, 0x475da31400000000, - 0x8e30c27000000000, 0xcd24b96700000000, 0x0818345e00000000, - 0x4b0c4f4900000000}, - {0x0000000000000000, 0x3e6bc2ef00000000, 0x3dd0f50400000000, - 0x03bb37eb00000000, 0x7aa0eb0900000000, 0x44cb29e600000000, - 0x47701e0d00000000, 0x791bdce200000000, 0xf440d71300000000, - 0xca2b15fc00000000, 0xc990221700000000, 0xf7fbe0f800000000, - 0x8ee03c1a00000000, 0xb08bfef500000000, 0xb330c91e00000000, - 0x8d5b0bf100000000, 0xe881ae2700000000, 0xd6ea6cc800000000, - 0xd5515b2300000000, 0xeb3a99cc00000000, 0x9221452e00000000, - 0xac4a87c100000000, 0xaff1b02a00000000, 0x919a72c500000000, - 0x1cc1793400000000, 0x22aabbdb00000000, 0x21118c3000000000, - 0x1f7a4edf00000000, 0x6661923d00000000, 0x580a50d200000000, - 0x5bb1673900000000, 0x65daa5d600000000, 0xd0035d4f00000000, - 0xee689fa000000000, 0xedd3a84b00000000, 0xd3b86aa400000000, - 0xaaa3b64600000000, 0x94c874a900000000, 0x9773434200000000, - 0xa91881ad00000000, 0x24438a5c00000000, 0x1a2848b300000000, - 0x19937f5800000000, 0x27f8bdb700000000, 0x5ee3615500000000, - 0x6088a3ba00000000, 0x6333945100000000, 0x5d5856be00000000, - 0x3882f36800000000, 0x06e9318700000000, 0x0552066c00000000, - 0x3b39c48300000000, 0x4222186100000000, 0x7c49da8e00000000, - 0x7ff2ed6500000000, 0x41992f8a00000000, 0xccc2247b00000000, - 0xf2a9e69400000000, 0xf112d17f00000000, 0xcf79139000000000, - 0xb662cf7200000000, 0x88090d9d00000000, 0x8bb23a7600000000, - 0xb5d9f89900000000, 0xa007ba9e00000000, 0x9e6c787100000000, - 0x9dd74f9a00000000, 0xa3bc8d7500000000, 0xdaa7519700000000, - 0xe4cc937800000000, 0xe777a49300000000, 0xd91c667c00000000, - 0x54476d8d00000000, 0x6a2caf6200000000, 0x6997988900000000, - 0x57fc5a6600000000, 0x2ee7868400000000, 0x108c446b00000000, - 0x1337738000000000, 0x2d5cb16f00000000, 0x488614b900000000, - 0x76edd65600000000, 0x7556e1bd00000000, 0x4b3d235200000000, - 0x3226ffb000000000, 0x0c4d3d5f00000000, 0x0ff60ab400000000, - 0x319dc85b00000000, 0xbcc6c3aa00000000, 0x82ad014500000000, - 0x811636ae00000000, 0xbf7df44100000000, 0xc66628a300000000, - 0xf80dea4c00000000, 0xfbb6dda700000000, 0xc5dd1f4800000000, - 0x7004e7d100000000, 0x4e6f253e00000000, 0x4dd412d500000000, - 0x73bfd03a00000000, 0x0aa40cd800000000, 0x34cfce3700000000, - 0x3774f9dc00000000, 0x091f3b3300000000, 0x844430c200000000, - 0xba2ff22d00000000, 0xb994c5c600000000, 0x87ff072900000000, - 0xfee4dbcb00000000, 0xc08f192400000000, 0xc3342ecf00000000, - 0xfd5fec2000000000, 0x988549f600000000, 0xa6ee8b1900000000, - 0xa555bcf200000000, 0x9b3e7e1d00000000, 0xe225a2ff00000000, - 0xdc4e601000000000, 0xdff557fb00000000, 0xe19e951400000000, - 0x6cc59ee500000000, 0x52ae5c0a00000000, 0x51156be100000000, - 0x6f7ea90e00000000, 0x166575ec00000000, 0x280eb70300000000, - 0x2bb580e800000000, 0x15de420700000000, 0x010905e600000000, - 0x3f62c70900000000, 0x3cd9f0e200000000, 0x02b2320d00000000, - 0x7ba9eeef00000000, 0x45c22c0000000000, 0x46791beb00000000, - 0x7812d90400000000, 0xf549d2f500000000, 0xcb22101a00000000, - 0xc89927f100000000, 0xf6f2e51e00000000, 0x8fe939fc00000000, - 0xb182fb1300000000, 0xb239ccf800000000, 0x8c520e1700000000, - 0xe988abc100000000, 0xd7e3692e00000000, 0xd4585ec500000000, - 0xea339c2a00000000, 0x932840c800000000, 0xad43822700000000, - 0xaef8b5cc00000000, 0x9093772300000000, 0x1dc87cd200000000, - 0x23a3be3d00000000, 0x201889d600000000, 0x1e734b3900000000, - 0x676897db00000000, 0x5903553400000000, 0x5ab862df00000000, - 0x64d3a03000000000, 0xd10a58a900000000, 0xef619a4600000000, - 0xecdaadad00000000, 0xd2b16f4200000000, 0xabaab3a000000000, - 0x95c1714f00000000, 0x967a46a400000000, 0xa811844b00000000, - 0x254a8fba00000000, 0x1b214d5500000000, 0x189a7abe00000000, - 0x26f1b85100000000, 0x5fea64b300000000, 0x6181a65c00000000, - 0x623a91b700000000, 0x5c51535800000000, 0x398bf68e00000000, - 0x07e0346100000000, 0x045b038a00000000, 0x3a30c16500000000, - 0x432b1d8700000000, 0x7d40df6800000000, 0x7efbe88300000000, - 0x40902a6c00000000, 0xcdcb219d00000000, 0xf3a0e37200000000, - 0xf01bd49900000000, 0xce70167600000000, 0xb76bca9400000000, - 0x8900087b00000000, 0x8abb3f9000000000, 0xb4d0fd7f00000000, - 0xa10ebf7800000000, 0x9f657d9700000000, 0x9cde4a7c00000000, - 0xa2b5889300000000, 0xdbae547100000000, 0xe5c5969e00000000, - 0xe67ea17500000000, 0xd815639a00000000, 0x554e686b00000000, - 0x6b25aa8400000000, 0x689e9d6f00000000, 0x56f55f8000000000, - 0x2fee836200000000, 0x1185418d00000000, 0x123e766600000000, - 0x2c55b48900000000, 0x498f115f00000000, 0x77e4d3b000000000, - 0x745fe45b00000000, 0x4a3426b400000000, 0x332ffa5600000000, - 0x0d4438b900000000, 0x0eff0f5200000000, 0x3094cdbd00000000, - 0xbdcfc64c00000000, 0x83a404a300000000, 0x801f334800000000, - 0xbe74f1a700000000, 0xc76f2d4500000000, 0xf904efaa00000000, - 0xfabfd84100000000, 0xc4d41aae00000000, 0x710de23700000000, - 0x4f6620d800000000, 0x4cdd173300000000, 0x72b6d5dc00000000, - 0x0bad093e00000000, 0x35c6cbd100000000, 0x367dfc3a00000000, - 0x08163ed500000000, 0x854d352400000000, 0xbb26f7cb00000000, - 0xb89dc02000000000, 0x86f602cf00000000, 0xffedde2d00000000, - 0xc1861cc200000000, 0xc23d2b2900000000, 0xfc56e9c600000000, - 0x998c4c1000000000, 0xa7e78eff00000000, 0xa45cb91400000000, - 0x9a377bfb00000000, 0xe32ca71900000000, 0xdd4765f600000000, - 0xdefc521d00000000, 0xe09790f200000000, 0x6dcc9b0300000000, - 0x53a759ec00000000, 0x501c6e0700000000, 0x6e77ace800000000, - 0x176c700a00000000, 0x2907b2e500000000, 0x2abc850e00000000, - 0x14d747e100000000}, - {0x0000000000000000, 0xc0df8ec100000000, 0xc1b96c5800000000, - 0x0166e29900000000, 0x8273d9b000000000, 0x42ac577100000000, - 0x43cab5e800000000, 0x83153b2900000000, 0x45e1c3ba00000000, - 0x853e4d7b00000000, 0x8458afe200000000, 0x4487212300000000, - 0xc7921a0a00000000, 0x074d94cb00000000, 0x062b765200000000, - 0xc6f4f89300000000, 0xcbc4f6ae00000000, 0x0b1b786f00000000, - 0x0a7d9af600000000, 0xcaa2143700000000, 0x49b72f1e00000000, - 0x8968a1df00000000, 0x880e434600000000, 0x48d1cd8700000000, - 0x8e25351400000000, 0x4efabbd500000000, 0x4f9c594c00000000, - 0x8f43d78d00000000, 0x0c56eca400000000, 0xcc89626500000000, - 0xcdef80fc00000000, 0x0d300e3d00000000, 0xd78f9c8600000000, - 0x1750124700000000, 0x1636f0de00000000, 0xd6e97e1f00000000, - 0x55fc453600000000, 0x9523cbf700000000, 0x9445296e00000000, - 0x549aa7af00000000, 0x926e5f3c00000000, 0x52b1d1fd00000000, - 0x53d7336400000000, 0x9308bda500000000, 0x101d868c00000000, - 0xd0c2084d00000000, 0xd1a4ead400000000, 0x117b641500000000, - 0x1c4b6a2800000000, 0xdc94e4e900000000, 0xddf2067000000000, - 0x1d2d88b100000000, 0x9e38b39800000000, 0x5ee73d5900000000, - 0x5f81dfc000000000, 0x9f5e510100000000, 0x59aaa99200000000, - 0x9975275300000000, 0x9813c5ca00000000, 0x58cc4b0b00000000, - 0xdbd9702200000000, 0x1b06fee300000000, 0x1a601c7a00000000, - 0xdabf92bb00000000, 0xef1948d600000000, 0x2fc6c61700000000, - 0x2ea0248e00000000, 0xee7faa4f00000000, 0x6d6a916600000000, - 0xadb51fa700000000, 0xacd3fd3e00000000, 0x6c0c73ff00000000, - 0xaaf88b6c00000000, 0x6a2705ad00000000, 0x6b41e73400000000, - 0xab9e69f500000000, 0x288b52dc00000000, 0xe854dc1d00000000, - 0xe9323e8400000000, 0x29edb04500000000, 0x24ddbe7800000000, - 0xe40230b900000000, 0xe564d22000000000, 0x25bb5ce100000000, - 0xa6ae67c800000000, 0x6671e90900000000, 0x67170b9000000000, - 0xa7c8855100000000, 0x613c7dc200000000, 0xa1e3f30300000000, - 0xa085119a00000000, 0x605a9f5b00000000, 0xe34fa47200000000, - 0x23902ab300000000, 0x22f6c82a00000000, 0xe22946eb00000000, - 0x3896d45000000000, 0xf8495a9100000000, 0xf92fb80800000000, - 0x39f036c900000000, 0xbae50de000000000, 0x7a3a832100000000, - 0x7b5c61b800000000, 0xbb83ef7900000000, 0x7d7717ea00000000, - 0xbda8992b00000000, 0xbcce7bb200000000, 0x7c11f57300000000, - 0xff04ce5a00000000, 0x3fdb409b00000000, 0x3ebda20200000000, - 0xfe622cc300000000, 0xf35222fe00000000, 0x338dac3f00000000, - 0x32eb4ea600000000, 0xf234c06700000000, 0x7121fb4e00000000, - 0xb1fe758f00000000, 0xb098971600000000, 0x704719d700000000, - 0xb6b3e14400000000, 0x766c6f8500000000, 0x770a8d1c00000000, - 0xb7d503dd00000000, 0x34c038f400000000, 0xf41fb63500000000, - 0xf57954ac00000000, 0x35a6da6d00000000, 0x9f35e17700000000, - 0x5fea6fb600000000, 0x5e8c8d2f00000000, 0x9e5303ee00000000, - 0x1d4638c700000000, 0xdd99b60600000000, 0xdcff549f00000000, - 0x1c20da5e00000000, 0xdad422cd00000000, 0x1a0bac0c00000000, - 0x1b6d4e9500000000, 0xdbb2c05400000000, 0x58a7fb7d00000000, - 0x987875bc00000000, 0x991e972500000000, 0x59c119e400000000, - 0x54f117d900000000, 0x942e991800000000, 0x95487b8100000000, - 0x5597f54000000000, 0xd682ce6900000000, 0x165d40a800000000, - 0x173ba23100000000, 0xd7e42cf000000000, 0x1110d46300000000, - 0xd1cf5aa200000000, 0xd0a9b83b00000000, 0x107636fa00000000, - 0x93630dd300000000, 0x53bc831200000000, 0x52da618b00000000, - 0x9205ef4a00000000, 0x48ba7df100000000, 0x8865f33000000000, - 0x890311a900000000, 0x49dc9f6800000000, 0xcac9a44100000000, - 0x0a162a8000000000, 0x0b70c81900000000, 0xcbaf46d800000000, - 0x0d5bbe4b00000000, 0xcd84308a00000000, 0xcce2d21300000000, - 0x0c3d5cd200000000, 0x8f2867fb00000000, 0x4ff7e93a00000000, - 0x4e910ba300000000, 0x8e4e856200000000, 0x837e8b5f00000000, - 0x43a1059e00000000, 0x42c7e70700000000, 0x821869c600000000, - 0x010d52ef00000000, 0xc1d2dc2e00000000, 0xc0b43eb700000000, - 0x006bb07600000000, 0xc69f48e500000000, 0x0640c62400000000, - 0x072624bd00000000, 0xc7f9aa7c00000000, 0x44ec915500000000, - 0x84331f9400000000, 0x8555fd0d00000000, 0x458a73cc00000000, - 0x702ca9a100000000, 0xb0f3276000000000, 0xb195c5f900000000, - 0x714a4b3800000000, 0xf25f701100000000, 0x3280fed000000000, - 0x33e61c4900000000, 0xf339928800000000, 0x35cd6a1b00000000, - 0xf512e4da00000000, 0xf474064300000000, 0x34ab888200000000, - 0xb7beb3ab00000000, 0x77613d6a00000000, 0x7607dff300000000, - 0xb6d8513200000000, 0xbbe85f0f00000000, 0x7b37d1ce00000000, - 0x7a51335700000000, 0xba8ebd9600000000, 0x399b86bf00000000, - 0xf944087e00000000, 0xf822eae700000000, 0x38fd642600000000, - 0xfe099cb500000000, 0x3ed6127400000000, 0x3fb0f0ed00000000, - 0xff6f7e2c00000000, 0x7c7a450500000000, 0xbca5cbc400000000, - 0xbdc3295d00000000, 0x7d1ca79c00000000, 0xa7a3352700000000, - 0x677cbbe600000000, 0x661a597f00000000, 0xa6c5d7be00000000, - 0x25d0ec9700000000, 0xe50f625600000000, 0xe46980cf00000000, - 0x24b60e0e00000000, 0xe242f69d00000000, 0x229d785c00000000, - 0x23fb9ac500000000, 0xe324140400000000, 0x60312f2d00000000, - 0xa0eea1ec00000000, 0xa188437500000000, 0x6157cdb400000000, - 0x6c67c38900000000, 0xacb84d4800000000, 0xaddeafd100000000, - 0x6d01211000000000, 0xee141a3900000000, 0x2ecb94f800000000, - 0x2fad766100000000, 0xef72f8a000000000, 0x2986003300000000, - 0xe9598ef200000000, 0xe83f6c6b00000000, 0x28e0e2aa00000000, - 0xabf5d98300000000, 0x6b2a574200000000, 0x6a4cb5db00000000, - 0xaa933b1a00000000}, - {0x0000000000000000, 0x6f4ca59b00000000, 0x9f9e3bec00000000, - 0xf0d29e7700000000, 0x7f3b060300000000, 0x1077a39800000000, - 0xe0a53def00000000, 0x8fe9987400000000, 0xfe760c0600000000, - 0x913aa99d00000000, 0x61e837ea00000000, 0x0ea4927100000000, - 0x814d0a0500000000, 0xee01af9e00000000, 0x1ed331e900000000, - 0x719f947200000000, 0xfced180c00000000, 0x93a1bd9700000000, - 0x637323e000000000, 0x0c3f867b00000000, 0x83d61e0f00000000, - 0xec9abb9400000000, 0x1c4825e300000000, 0x7304807800000000, - 0x029b140a00000000, 0x6dd7b19100000000, 0x9d052fe600000000, - 0xf2498a7d00000000, 0x7da0120900000000, 0x12ecb79200000000, - 0xe23e29e500000000, 0x8d728c7e00000000, 0xf8db311800000000, - 0x9797948300000000, 0x67450af400000000, 0x0809af6f00000000, - 0x87e0371b00000000, 0xe8ac928000000000, 0x187e0cf700000000, - 0x7732a96c00000000, 0x06ad3d1e00000000, 0x69e1988500000000, - 0x993306f200000000, 0xf67fa36900000000, 0x79963b1d00000000, - 0x16da9e8600000000, 0xe60800f100000000, 0x8944a56a00000000, - 0x0436291400000000, 0x6b7a8c8f00000000, 0x9ba812f800000000, - 0xf4e4b76300000000, 0x7b0d2f1700000000, 0x14418a8c00000000, - 0xe49314fb00000000, 0x8bdfb16000000000, 0xfa40251200000000, - 0x950c808900000000, 0x65de1efe00000000, 0x0a92bb6500000000, - 0x857b231100000000, 0xea37868a00000000, 0x1ae518fd00000000, - 0x75a9bd6600000000, 0xf0b7633000000000, 0x9ffbc6ab00000000, - 0x6f2958dc00000000, 0x0065fd4700000000, 0x8f8c653300000000, - 0xe0c0c0a800000000, 0x10125edf00000000, 0x7f5efb4400000000, - 0x0ec16f3600000000, 0x618dcaad00000000, 0x915f54da00000000, - 0xfe13f14100000000, 0x71fa693500000000, 0x1eb6ccae00000000, - 0xee6452d900000000, 0x8128f74200000000, 0x0c5a7b3c00000000, - 0x6316dea700000000, 0x93c440d000000000, 0xfc88e54b00000000, - 0x73617d3f00000000, 0x1c2dd8a400000000, 0xecff46d300000000, - 0x83b3e34800000000, 0xf22c773a00000000, 0x9d60d2a100000000, - 0x6db24cd600000000, 0x02fee94d00000000, 0x8d17713900000000, - 0xe25bd4a200000000, 0x12894ad500000000, 0x7dc5ef4e00000000, - 0x086c522800000000, 0x6720f7b300000000, 0x97f269c400000000, - 0xf8becc5f00000000, 0x7757542b00000000, 0x181bf1b000000000, - 0xe8c96fc700000000, 0x8785ca5c00000000, 0xf61a5e2e00000000, - 0x9956fbb500000000, 0x698465c200000000, 0x06c8c05900000000, - 0x8921582d00000000, 0xe66dfdb600000000, 0x16bf63c100000000, - 0x79f3c65a00000000, 0xf4814a2400000000, 0x9bcdefbf00000000, - 0x6b1f71c800000000, 0x0453d45300000000, 0x8bba4c2700000000, - 0xe4f6e9bc00000000, 0x142477cb00000000, 0x7b68d25000000000, - 0x0af7462200000000, 0x65bbe3b900000000, 0x95697dce00000000, - 0xfa25d85500000000, 0x75cc402100000000, 0x1a80e5ba00000000, - 0xea527bcd00000000, 0x851ede5600000000, 0xe06fc76000000000, - 0x8f2362fb00000000, 0x7ff1fc8c00000000, 0x10bd591700000000, - 0x9f54c16300000000, 0xf01864f800000000, 0x00cafa8f00000000, - 0x6f865f1400000000, 0x1e19cb6600000000, 0x71556efd00000000, - 0x8187f08a00000000, 0xeecb551100000000, 0x6122cd6500000000, - 0x0e6e68fe00000000, 0xfebcf68900000000, 0x91f0531200000000, - 0x1c82df6c00000000, 0x73ce7af700000000, 0x831ce48000000000, - 0xec50411b00000000, 0x63b9d96f00000000, 0x0cf57cf400000000, - 0xfc27e28300000000, 0x936b471800000000, 0xe2f4d36a00000000, - 0x8db876f100000000, 0x7d6ae88600000000, 0x12264d1d00000000, - 0x9dcfd56900000000, 0xf28370f200000000, 0x0251ee8500000000, - 0x6d1d4b1e00000000, 0x18b4f67800000000, 0x77f853e300000000, - 0x872acd9400000000, 0xe866680f00000000, 0x678ff07b00000000, - 0x08c355e000000000, 0xf811cb9700000000, 0x975d6e0c00000000, - 0xe6c2fa7e00000000, 0x898e5fe500000000, 0x795cc19200000000, - 0x1610640900000000, 0x99f9fc7d00000000, 0xf6b559e600000000, - 0x0667c79100000000, 0x692b620a00000000, 0xe459ee7400000000, - 0x8b154bef00000000, 0x7bc7d59800000000, 0x148b700300000000, - 0x9b62e87700000000, 0xf42e4dec00000000, 0x04fcd39b00000000, - 0x6bb0760000000000, 0x1a2fe27200000000, 0x756347e900000000, - 0x85b1d99e00000000, 0xeafd7c0500000000, 0x6514e47100000000, - 0x0a5841ea00000000, 0xfa8adf9d00000000, 0x95c67a0600000000, - 0x10d8a45000000000, 0x7f9401cb00000000, 0x8f469fbc00000000, - 0xe00a3a2700000000, 0x6fe3a25300000000, 0x00af07c800000000, - 0xf07d99bf00000000, 0x9f313c2400000000, 0xeeaea85600000000, - 0x81e20dcd00000000, 0x713093ba00000000, 0x1e7c362100000000, - 0x9195ae5500000000, 0xfed90bce00000000, 0x0e0b95b900000000, - 0x6147302200000000, 0xec35bc5c00000000, 0x837919c700000000, - 0x73ab87b000000000, 0x1ce7222b00000000, 0x930eba5f00000000, - 0xfc421fc400000000, 0x0c9081b300000000, 0x63dc242800000000, - 0x1243b05a00000000, 0x7d0f15c100000000, 0x8ddd8bb600000000, - 0xe2912e2d00000000, 0x6d78b65900000000, 0x023413c200000000, - 0xf2e68db500000000, 0x9daa282e00000000, 0xe803954800000000, - 0x874f30d300000000, 0x779daea400000000, 0x18d10b3f00000000, - 0x9738934b00000000, 0xf87436d000000000, 0x08a6a8a700000000, - 0x67ea0d3c00000000, 0x1675994e00000000, 0x79393cd500000000, - 0x89eba2a200000000, 0xe6a7073900000000, 0x694e9f4d00000000, - 0x06023ad600000000, 0xf6d0a4a100000000, 0x999c013a00000000, - 0x14ee8d4400000000, 0x7ba228df00000000, 0x8b70b6a800000000, - 0xe43c133300000000, 0x6bd58b4700000000, 0x04992edc00000000, - 0xf44bb0ab00000000, 0x9b07153000000000, 0xea98814200000000, - 0x85d424d900000000, 0x7506baae00000000, 0x1a4a1f3500000000, - 0x95a3874100000000, 0xfaef22da00000000, 0x0a3dbcad00000000, - 0x6571193600000000}, - {0x0000000000000000, 0x85d996dd00000000, 0x4bb55c6000000000, - 0xce6ccabd00000000, 0x966ab9c000000000, 0x13b32f1d00000000, - 0xdddfe5a000000000, 0x5806737d00000000, 0x6dd3035a00000000, - 0xe80a958700000000, 0x26665f3a00000000, 0xa3bfc9e700000000, - 0xfbb9ba9a00000000, 0x7e602c4700000000, 0xb00ce6fa00000000, - 0x35d5702700000000, 0xdaa607b400000000, 0x5f7f916900000000, - 0x91135bd400000000, 0x14cacd0900000000, 0x4cccbe7400000000, - 0xc91528a900000000, 0x0779e21400000000, 0x82a074c900000000, - 0xb77504ee00000000, 0x32ac923300000000, 0xfcc0588e00000000, - 0x7919ce5300000000, 0x211fbd2e00000000, 0xa4c62bf300000000, - 0x6aaae14e00000000, 0xef73779300000000, 0xf54b7eb300000000, - 0x7092e86e00000000, 0xbefe22d300000000, 0x3b27b40e00000000, - 0x6321c77300000000, 0xe6f851ae00000000, 0x28949b1300000000, - 0xad4d0dce00000000, 0x98987de900000000, 0x1d41eb3400000000, - 0xd32d218900000000, 0x56f4b75400000000, 0x0ef2c42900000000, - 0x8b2b52f400000000, 0x4547984900000000, 0xc09e0e9400000000, - 0x2fed790700000000, 0xaa34efda00000000, 0x6458256700000000, - 0xe181b3ba00000000, 0xb987c0c700000000, 0x3c5e561a00000000, - 0xf2329ca700000000, 0x77eb0a7a00000000, 0x423e7a5d00000000, - 0xc7e7ec8000000000, 0x098b263d00000000, 0x8c52b0e000000000, - 0xd454c39d00000000, 0x518d554000000000, 0x9fe19ffd00000000, - 0x1a38092000000000, 0xab918dbd00000000, 0x2e481b6000000000, - 0xe024d1dd00000000, 0x65fd470000000000, 0x3dfb347d00000000, - 0xb822a2a000000000, 0x764e681d00000000, 0xf397fec000000000, - 0xc6428ee700000000, 0x439b183a00000000, 0x8df7d28700000000, - 0x082e445a00000000, 0x5028372700000000, 0xd5f1a1fa00000000, - 0x1b9d6b4700000000, 0x9e44fd9a00000000, 0x71378a0900000000, - 0xf4ee1cd400000000, 0x3a82d66900000000, 0xbf5b40b400000000, - 0xe75d33c900000000, 0x6284a51400000000, 0xace86fa900000000, - 0x2931f97400000000, 0x1ce4895300000000, 0x993d1f8e00000000, - 0x5751d53300000000, 0xd28843ee00000000, 0x8a8e309300000000, - 0x0f57a64e00000000, 0xc13b6cf300000000, 0x44e2fa2e00000000, - 0x5edaf30e00000000, 0xdb0365d300000000, 0x156faf6e00000000, - 0x90b639b300000000, 0xc8b04ace00000000, 0x4d69dc1300000000, - 0x830516ae00000000, 0x06dc807300000000, 0x3309f05400000000, - 0xb6d0668900000000, 0x78bcac3400000000, 0xfd653ae900000000, - 0xa563499400000000, 0x20badf4900000000, 0xeed615f400000000, - 0x6b0f832900000000, 0x847cf4ba00000000, 0x01a5626700000000, - 0xcfc9a8da00000000, 0x4a103e0700000000, 0x12164d7a00000000, - 0x97cfdba700000000, 0x59a3111a00000000, 0xdc7a87c700000000, - 0xe9aff7e000000000, 0x6c76613d00000000, 0xa21aab8000000000, - 0x27c33d5d00000000, 0x7fc54e2000000000, 0xfa1cd8fd00000000, - 0x3470124000000000, 0xb1a9849d00000000, 0x17256aa000000000, - 0x92fcfc7d00000000, 0x5c9036c000000000, 0xd949a01d00000000, - 0x814fd36000000000, 0x049645bd00000000, 0xcafa8f0000000000, - 0x4f2319dd00000000, 0x7af669fa00000000, 0xff2fff2700000000, - 0x3143359a00000000, 0xb49aa34700000000, 0xec9cd03a00000000, - 0x694546e700000000, 0xa7298c5a00000000, 0x22f01a8700000000, - 0xcd836d1400000000, 0x485afbc900000000, 0x8636317400000000, - 0x03efa7a900000000, 0x5be9d4d400000000, 0xde30420900000000, - 0x105c88b400000000, 0x95851e6900000000, 0xa0506e4e00000000, - 0x2589f89300000000, 0xebe5322e00000000, 0x6e3ca4f300000000, - 0x363ad78e00000000, 0xb3e3415300000000, 0x7d8f8bee00000000, - 0xf8561d3300000000, 0xe26e141300000000, 0x67b782ce00000000, - 0xa9db487300000000, 0x2c02deae00000000, 0x7404add300000000, - 0xf1dd3b0e00000000, 0x3fb1f1b300000000, 0xba68676e00000000, - 0x8fbd174900000000, 0x0a64819400000000, 0xc4084b2900000000, - 0x41d1ddf400000000, 0x19d7ae8900000000, 0x9c0e385400000000, - 0x5262f2e900000000, 0xd7bb643400000000, 0x38c813a700000000, - 0xbd11857a00000000, 0x737d4fc700000000, 0xf6a4d91a00000000, - 0xaea2aa6700000000, 0x2b7b3cba00000000, 0xe517f60700000000, - 0x60ce60da00000000, 0x551b10fd00000000, 0xd0c2862000000000, - 0x1eae4c9d00000000, 0x9b77da4000000000, 0xc371a93d00000000, - 0x46a83fe000000000, 0x88c4f55d00000000, 0x0d1d638000000000, - 0xbcb4e71d00000000, 0x396d71c000000000, 0xf701bb7d00000000, - 0x72d82da000000000, 0x2ade5edd00000000, 0xaf07c80000000000, - 0x616b02bd00000000, 0xe4b2946000000000, 0xd167e44700000000, - 0x54be729a00000000, 0x9ad2b82700000000, 0x1f0b2efa00000000, - 0x470d5d8700000000, 0xc2d4cb5a00000000, 0x0cb801e700000000, - 0x8961973a00000000, 0x6612e0a900000000, 0xe3cb767400000000, - 0x2da7bcc900000000, 0xa87e2a1400000000, 0xf078596900000000, - 0x75a1cfb400000000, 0xbbcd050900000000, 0x3e1493d400000000, - 0x0bc1e3f300000000, 0x8e18752e00000000, 0x4074bf9300000000, - 0xc5ad294e00000000, 0x9dab5a3300000000, 0x1872ccee00000000, - 0xd61e065300000000, 0x53c7908e00000000, 0x49ff99ae00000000, - 0xcc260f7300000000, 0x024ac5ce00000000, 0x8793531300000000, - 0xdf95206e00000000, 0x5a4cb6b300000000, 0x94207c0e00000000, - 0x11f9ead300000000, 0x242c9af400000000, 0xa1f50c2900000000, - 0x6f99c69400000000, 0xea40504900000000, 0xb246233400000000, - 0x379fb5e900000000, 0xf9f37f5400000000, 0x7c2ae98900000000, - 0x93599e1a00000000, 0x168008c700000000, 0xd8ecc27a00000000, - 0x5d3554a700000000, 0x053327da00000000, 0x80eab10700000000, - 0x4e867bba00000000, 0xcb5fed6700000000, 0xfe8a9d4000000000, - 0x7b530b9d00000000, 0xb53fc12000000000, 0x30e657fd00000000, - 0x68e0248000000000, 0xed39b25d00000000, 0x235578e000000000, - 0xa68cee3d00000000}, - {0x0000000000000000, 0x76e10f9d00000000, 0xadc46ee100000000, - 0xdb25617c00000000, 0x1b8fac1900000000, 0x6d6ea38400000000, - 0xb64bc2f800000000, 0xc0aacd6500000000, 0x361e593300000000, - 0x40ff56ae00000000, 0x9bda37d200000000, 0xed3b384f00000000, - 0x2d91f52a00000000, 0x5b70fab700000000, 0x80559bcb00000000, - 0xf6b4945600000000, 0x6c3cb26600000000, 0x1addbdfb00000000, - 0xc1f8dc8700000000, 0xb719d31a00000000, 0x77b31e7f00000000, - 0x015211e200000000, 0xda77709e00000000, 0xac967f0300000000, - 0x5a22eb5500000000, 0x2cc3e4c800000000, 0xf7e685b400000000, - 0x81078a2900000000, 0x41ad474c00000000, 0x374c48d100000000, - 0xec6929ad00000000, 0x9a88263000000000, 0xd87864cd00000000, - 0xae996b5000000000, 0x75bc0a2c00000000, 0x035d05b100000000, - 0xc3f7c8d400000000, 0xb516c74900000000, 0x6e33a63500000000, - 0x18d2a9a800000000, 0xee663dfe00000000, 0x9887326300000000, - 0x43a2531f00000000, 0x35435c8200000000, 0xf5e991e700000000, - 0x83089e7a00000000, 0x582dff0600000000, 0x2eccf09b00000000, - 0xb444d6ab00000000, 0xc2a5d93600000000, 0x1980b84a00000000, - 0x6f61b7d700000000, 0xafcb7ab200000000, 0xd92a752f00000000, - 0x020f145300000000, 0x74ee1bce00000000, 0x825a8f9800000000, - 0xf4bb800500000000, 0x2f9ee17900000000, 0x597feee400000000, - 0x99d5238100000000, 0xef342c1c00000000, 0x34114d6000000000, - 0x42f042fd00000000, 0xf1f7b94100000000, 0x8716b6dc00000000, - 0x5c33d7a000000000, 0x2ad2d83d00000000, 0xea78155800000000, - 0x9c991ac500000000, 0x47bc7bb900000000, 0x315d742400000000, - 0xc7e9e07200000000, 0xb108efef00000000, 0x6a2d8e9300000000, - 0x1ccc810e00000000, 0xdc664c6b00000000, 0xaa8743f600000000, - 0x71a2228a00000000, 0x07432d1700000000, 0x9dcb0b2700000000, - 0xeb2a04ba00000000, 0x300f65c600000000, 0x46ee6a5b00000000, - 0x8644a73e00000000, 0xf0a5a8a300000000, 0x2b80c9df00000000, - 0x5d61c64200000000, 0xabd5521400000000, 0xdd345d8900000000, - 0x06113cf500000000, 0x70f0336800000000, 0xb05afe0d00000000, - 0xc6bbf19000000000, 0x1d9e90ec00000000, 0x6b7f9f7100000000, - 0x298fdd8c00000000, 0x5f6ed21100000000, 0x844bb36d00000000, - 0xf2aabcf000000000, 0x3200719500000000, 0x44e17e0800000000, - 0x9fc41f7400000000, 0xe92510e900000000, 0x1f9184bf00000000, - 0x69708b2200000000, 0xb255ea5e00000000, 0xc4b4e5c300000000, - 0x041e28a600000000, 0x72ff273b00000000, 0xa9da464700000000, - 0xdf3b49da00000000, 0x45b36fea00000000, 0x3352607700000000, - 0xe877010b00000000, 0x9e960e9600000000, 0x5e3cc3f300000000, - 0x28ddcc6e00000000, 0xf3f8ad1200000000, 0x8519a28f00000000, - 0x73ad36d900000000, 0x054c394400000000, 0xde69583800000000, - 0xa88857a500000000, 0x68229ac000000000, 0x1ec3955d00000000, - 0xc5e6f42100000000, 0xb307fbbc00000000, 0xe2ef738300000000, - 0x940e7c1e00000000, 0x4f2b1d6200000000, 0x39ca12ff00000000, - 0xf960df9a00000000, 0x8f81d00700000000, 0x54a4b17b00000000, - 0x2245bee600000000, 0xd4f12ab000000000, 0xa210252d00000000, - 0x7935445100000000, 0x0fd44bcc00000000, 0xcf7e86a900000000, - 0xb99f893400000000, 0x62bae84800000000, 0x145be7d500000000, - 0x8ed3c1e500000000, 0xf832ce7800000000, 0x2317af0400000000, - 0x55f6a09900000000, 0x955c6dfc00000000, 0xe3bd626100000000, - 0x3898031d00000000, 0x4e790c8000000000, 0xb8cd98d600000000, - 0xce2c974b00000000, 0x1509f63700000000, 0x63e8f9aa00000000, - 0xa34234cf00000000, 0xd5a33b5200000000, 0x0e865a2e00000000, - 0x786755b300000000, 0x3a97174e00000000, 0x4c7618d300000000, - 0x975379af00000000, 0xe1b2763200000000, 0x2118bb5700000000, - 0x57f9b4ca00000000, 0x8cdcd5b600000000, 0xfa3dda2b00000000, - 0x0c894e7d00000000, 0x7a6841e000000000, 0xa14d209c00000000, - 0xd7ac2f0100000000, 0x1706e26400000000, 0x61e7edf900000000, - 0xbac28c8500000000, 0xcc23831800000000, 0x56aba52800000000, - 0x204aaab500000000, 0xfb6fcbc900000000, 0x8d8ec45400000000, - 0x4d24093100000000, 0x3bc506ac00000000, 0xe0e067d000000000, - 0x9601684d00000000, 0x60b5fc1b00000000, 0x1654f38600000000, - 0xcd7192fa00000000, 0xbb909d6700000000, 0x7b3a500200000000, - 0x0ddb5f9f00000000, 0xd6fe3ee300000000, 0xa01f317e00000000, - 0x1318cac200000000, 0x65f9c55f00000000, 0xbedca42300000000, - 0xc83dabbe00000000, 0x089766db00000000, 0x7e76694600000000, - 0xa553083a00000000, 0xd3b207a700000000, 0x250693f100000000, - 0x53e79c6c00000000, 0x88c2fd1000000000, 0xfe23f28d00000000, - 0x3e893fe800000000, 0x4868307500000000, 0x934d510900000000, - 0xe5ac5e9400000000, 0x7f2478a400000000, 0x09c5773900000000, - 0xd2e0164500000000, 0xa40119d800000000, 0x64abd4bd00000000, - 0x124adb2000000000, 0xc96fba5c00000000, 0xbf8eb5c100000000, - 0x493a219700000000, 0x3fdb2e0a00000000, 0xe4fe4f7600000000, - 0x921f40eb00000000, 0x52b58d8e00000000, 0x2454821300000000, - 0xff71e36f00000000, 0x8990ecf200000000, 0xcb60ae0f00000000, - 0xbd81a19200000000, 0x66a4c0ee00000000, 0x1045cf7300000000, - 0xd0ef021600000000, 0xa60e0d8b00000000, 0x7d2b6cf700000000, - 0x0bca636a00000000, 0xfd7ef73c00000000, 0x8b9ff8a100000000, - 0x50ba99dd00000000, 0x265b964000000000, 0xe6f15b2500000000, - 0x901054b800000000, 0x4b3535c400000000, 0x3dd43a5900000000, - 0xa75c1c6900000000, 0xd1bd13f400000000, 0x0a98728800000000, - 0x7c797d1500000000, 0xbcd3b07000000000, 0xca32bfed00000000, - 0x1117de9100000000, 0x67f6d10c00000000, 0x9142455a00000000, - 0xe7a34ac700000000, 0x3c862bbb00000000, 0x4a67242600000000, - 0x8acde94300000000, 0xfc2ce6de00000000, 0x270987a200000000, - 0x51e8883f00000000}, - {0x0000000000000000, 0xe8dbfbb900000000, 0x91b186a800000000, - 0x796a7d1100000000, 0x63657c8a00000000, 0x8bbe873300000000, - 0xf2d4fa2200000000, 0x1a0f019b00000000, 0x87cc89cf00000000, - 0x6f17727600000000, 0x167d0f6700000000, 0xfea6f4de00000000, - 0xe4a9f54500000000, 0x0c720efc00000000, 0x751873ed00000000, - 0x9dc3885400000000, 0x4f9f624400000000, 0xa74499fd00000000, - 0xde2ee4ec00000000, 0x36f51f5500000000, 0x2cfa1ece00000000, - 0xc421e57700000000, 0xbd4b986600000000, 0x559063df00000000, - 0xc853eb8b00000000, 0x2088103200000000, 0x59e26d2300000000, - 0xb139969a00000000, 0xab36970100000000, 0x43ed6cb800000000, - 0x3a8711a900000000, 0xd25cea1000000000, 0x9e3ec58800000000, - 0x76e53e3100000000, 0x0f8f432000000000, 0xe754b89900000000, - 0xfd5bb90200000000, 0x158042bb00000000, 0x6cea3faa00000000, - 0x8431c41300000000, 0x19f24c4700000000, 0xf129b7fe00000000, - 0x8843caef00000000, 0x6098315600000000, 0x7a9730cd00000000, - 0x924ccb7400000000, 0xeb26b66500000000, 0x03fd4ddc00000000, - 0xd1a1a7cc00000000, 0x397a5c7500000000, 0x4010216400000000, - 0xa8cbdadd00000000, 0xb2c4db4600000000, 0x5a1f20ff00000000, - 0x23755dee00000000, 0xcbaea65700000000, 0x566d2e0300000000, - 0xbeb6d5ba00000000, 0xc7dca8ab00000000, 0x2f07531200000000, - 0x3508528900000000, 0xddd3a93000000000, 0xa4b9d42100000000, - 0x4c622f9800000000, 0x7d7bfbca00000000, 0x95a0007300000000, - 0xecca7d6200000000, 0x041186db00000000, 0x1e1e874000000000, - 0xf6c57cf900000000, 0x8faf01e800000000, 0x6774fa5100000000, - 0xfab7720500000000, 0x126c89bc00000000, 0x6b06f4ad00000000, - 0x83dd0f1400000000, 0x99d20e8f00000000, 0x7109f53600000000, - 0x0863882700000000, 0xe0b8739e00000000, 0x32e4998e00000000, - 0xda3f623700000000, 0xa3551f2600000000, 0x4b8ee49f00000000, - 0x5181e50400000000, 0xb95a1ebd00000000, 0xc03063ac00000000, - 0x28eb981500000000, 0xb528104100000000, 0x5df3ebf800000000, - 0x249996e900000000, 0xcc426d5000000000, 0xd64d6ccb00000000, - 0x3e96977200000000, 0x47fcea6300000000, 0xaf2711da00000000, - 0xe3453e4200000000, 0x0b9ec5fb00000000, 0x72f4b8ea00000000, - 0x9a2f435300000000, 0x802042c800000000, 0x68fbb97100000000, - 0x1191c46000000000, 0xf94a3fd900000000, 0x6489b78d00000000, - 0x8c524c3400000000, 0xf538312500000000, 0x1de3ca9c00000000, - 0x07eccb0700000000, 0xef3730be00000000, 0x965d4daf00000000, - 0x7e86b61600000000, 0xacda5c0600000000, 0x4401a7bf00000000, - 0x3d6bdaae00000000, 0xd5b0211700000000, 0xcfbf208c00000000, - 0x2764db3500000000, 0x5e0ea62400000000, 0xb6d55d9d00000000, - 0x2b16d5c900000000, 0xc3cd2e7000000000, 0xbaa7536100000000, - 0x527ca8d800000000, 0x4873a94300000000, 0xa0a852fa00000000, - 0xd9c22feb00000000, 0x3119d45200000000, 0xbbf0874e00000000, - 0x532b7cf700000000, 0x2a4101e600000000, 0xc29afa5f00000000, - 0xd895fbc400000000, 0x304e007d00000000, 0x49247d6c00000000, - 0xa1ff86d500000000, 0x3c3c0e8100000000, 0xd4e7f53800000000, - 0xad8d882900000000, 0x4556739000000000, 0x5f59720b00000000, - 0xb78289b200000000, 0xcee8f4a300000000, 0x26330f1a00000000, - 0xf46fe50a00000000, 0x1cb41eb300000000, 0x65de63a200000000, - 0x8d05981b00000000, 0x970a998000000000, 0x7fd1623900000000, - 0x06bb1f2800000000, 0xee60e49100000000, 0x73a36cc500000000, - 0x9b78977c00000000, 0xe212ea6d00000000, 0x0ac911d400000000, - 0x10c6104f00000000, 0xf81debf600000000, 0x817796e700000000, - 0x69ac6d5e00000000, 0x25ce42c600000000, 0xcd15b97f00000000, - 0xb47fc46e00000000, 0x5ca43fd700000000, 0x46ab3e4c00000000, - 0xae70c5f500000000, 0xd71ab8e400000000, 0x3fc1435d00000000, - 0xa202cb0900000000, 0x4ad930b000000000, 0x33b34da100000000, - 0xdb68b61800000000, 0xc167b78300000000, 0x29bc4c3a00000000, - 0x50d6312b00000000, 0xb80dca9200000000, 0x6a51208200000000, - 0x828adb3b00000000, 0xfbe0a62a00000000, 0x133b5d9300000000, - 0x09345c0800000000, 0xe1efa7b100000000, 0x9885daa000000000, - 0x705e211900000000, 0xed9da94d00000000, 0x054652f400000000, - 0x7c2c2fe500000000, 0x94f7d45c00000000, 0x8ef8d5c700000000, - 0x66232e7e00000000, 0x1f49536f00000000, 0xf792a8d600000000, - 0xc68b7c8400000000, 0x2e50873d00000000, 0x573afa2c00000000, - 0xbfe1019500000000, 0xa5ee000e00000000, 0x4d35fbb700000000, - 0x345f86a600000000, 0xdc847d1f00000000, 0x4147f54b00000000, - 0xa99c0ef200000000, 0xd0f673e300000000, 0x382d885a00000000, - 0x222289c100000000, 0xcaf9727800000000, 0xb3930f6900000000, - 0x5b48f4d000000000, 0x89141ec000000000, 0x61cfe57900000000, - 0x18a5986800000000, 0xf07e63d100000000, 0xea71624a00000000, - 0x02aa99f300000000, 0x7bc0e4e200000000, 0x931b1f5b00000000, - 0x0ed8970f00000000, 0xe6036cb600000000, 0x9f6911a700000000, - 0x77b2ea1e00000000, 0x6dbdeb8500000000, 0x8566103c00000000, - 0xfc0c6d2d00000000, 0x14d7969400000000, 0x58b5b90c00000000, - 0xb06e42b500000000, 0xc9043fa400000000, 0x21dfc41d00000000, - 0x3bd0c58600000000, 0xd30b3e3f00000000, 0xaa61432e00000000, - 0x42bab89700000000, 0xdf7930c300000000, 0x37a2cb7a00000000, - 0x4ec8b66b00000000, 0xa6134dd200000000, 0xbc1c4c4900000000, - 0x54c7b7f000000000, 0x2dadcae100000000, 0xc576315800000000, - 0x172adb4800000000, 0xfff120f100000000, 0x869b5de000000000, - 0x6e40a65900000000, 0x744fa7c200000000, 0x9c945c7b00000000, - 0xe5fe216a00000000, 0x0d25dad300000000, 0x90e6528700000000, - 0x783da93e00000000, 0x0157d42f00000000, 0xe98c2f9600000000, - 0xf3832e0d00000000, 0x1b58d5b400000000, 0x6232a8a500000000, - 0x8ae9531c00000000}, - {0x0000000000000000, 0x919168ae00000000, 0x6325a08700000000, - 0xf2b4c82900000000, 0x874c31d400000000, 0x16dd597a00000000, - 0xe469915300000000, 0x75f8f9fd00000000, 0x4f9f137300000000, - 0xde0e7bdd00000000, 0x2cbab3f400000000, 0xbd2bdb5a00000000, - 0xc8d322a700000000, 0x59424a0900000000, 0xabf6822000000000, - 0x3a67ea8e00000000, 0x9e3e27e600000000, 0x0faf4f4800000000, - 0xfd1b876100000000, 0x6c8aefcf00000000, 0x1972163200000000, - 0x88e37e9c00000000, 0x7a57b6b500000000, 0xebc6de1b00000000, - 0xd1a1349500000000, 0x40305c3b00000000, 0xb284941200000000, - 0x2315fcbc00000000, 0x56ed054100000000, 0xc77c6def00000000, - 0x35c8a5c600000000, 0xa459cd6800000000, 0x7d7b3f1700000000, - 0xecea57b900000000, 0x1e5e9f9000000000, 0x8fcff73e00000000, - 0xfa370ec300000000, 0x6ba6666d00000000, 0x9912ae4400000000, - 0x0883c6ea00000000, 0x32e42c6400000000, 0xa37544ca00000000, - 0x51c18ce300000000, 0xc050e44d00000000, 0xb5a81db000000000, - 0x2439751e00000000, 0xd68dbd3700000000, 0x471cd59900000000, - 0xe34518f100000000, 0x72d4705f00000000, 0x8060b87600000000, - 0x11f1d0d800000000, 0x6409292500000000, 0xf598418b00000000, - 0x072c89a200000000, 0x96bde10c00000000, 0xacda0b8200000000, - 0x3d4b632c00000000, 0xcfffab0500000000, 0x5e6ec3ab00000000, - 0x2b963a5600000000, 0xba0752f800000000, 0x48b39ad100000000, - 0xd922f27f00000000, 0xfaf67e2e00000000, 0x6b67168000000000, - 0x99d3dea900000000, 0x0842b60700000000, 0x7dba4ffa00000000, - 0xec2b275400000000, 0x1e9fef7d00000000, 0x8f0e87d300000000, - 0xb5696d5d00000000, 0x24f805f300000000, 0xd64ccdda00000000, - 0x47dda57400000000, 0x32255c8900000000, 0xa3b4342700000000, - 0x5100fc0e00000000, 0xc09194a000000000, 0x64c859c800000000, - 0xf559316600000000, 0x07edf94f00000000, 0x967c91e100000000, - 0xe384681c00000000, 0x721500b200000000, 0x80a1c89b00000000, - 0x1130a03500000000, 0x2b574abb00000000, 0xbac6221500000000, - 0x4872ea3c00000000, 0xd9e3829200000000, 0xac1b7b6f00000000, - 0x3d8a13c100000000, 0xcf3edbe800000000, 0x5eafb34600000000, - 0x878d413900000000, 0x161c299700000000, 0xe4a8e1be00000000, - 0x7539891000000000, 0x00c170ed00000000, 0x9150184300000000, - 0x63e4d06a00000000, 0xf275b8c400000000, 0xc812524a00000000, - 0x59833ae400000000, 0xab37f2cd00000000, 0x3aa69a6300000000, - 0x4f5e639e00000000, 0xdecf0b3000000000, 0x2c7bc31900000000, - 0xbdeaabb700000000, 0x19b366df00000000, 0x88220e7100000000, - 0x7a96c65800000000, 0xeb07aef600000000, 0x9eff570b00000000, - 0x0f6e3fa500000000, 0xfddaf78c00000000, 0x6c4b9f2200000000, - 0x562c75ac00000000, 0xc7bd1d0200000000, 0x3509d52b00000000, - 0xa498bd8500000000, 0xd160447800000000, 0x40f12cd600000000, - 0xb245e4ff00000000, 0x23d48c5100000000, 0xf4edfd5c00000000, - 0x657c95f200000000, 0x97c85ddb00000000, 0x0659357500000000, - 0x73a1cc8800000000, 0xe230a42600000000, 0x10846c0f00000000, - 0x811504a100000000, 0xbb72ee2f00000000, 0x2ae3868100000000, - 0xd8574ea800000000, 0x49c6260600000000, 0x3c3edffb00000000, - 0xadafb75500000000, 0x5f1b7f7c00000000, 0xce8a17d200000000, - 0x6ad3daba00000000, 0xfb42b21400000000, 0x09f67a3d00000000, - 0x9867129300000000, 0xed9feb6e00000000, 0x7c0e83c000000000, - 0x8eba4be900000000, 0x1f2b234700000000, 0x254cc9c900000000, - 0xb4dda16700000000, 0x4669694e00000000, 0xd7f801e000000000, - 0xa200f81d00000000, 0x339190b300000000, 0xc125589a00000000, - 0x50b4303400000000, 0x8996c24b00000000, 0x1807aae500000000, - 0xeab362cc00000000, 0x7b220a6200000000, 0x0edaf39f00000000, - 0x9f4b9b3100000000, 0x6dff531800000000, 0xfc6e3bb600000000, - 0xc609d13800000000, 0x5798b99600000000, 0xa52c71bf00000000, - 0x34bd191100000000, 0x4145e0ec00000000, 0xd0d4884200000000, - 0x2260406b00000000, 0xb3f128c500000000, 0x17a8e5ad00000000, - 0x86398d0300000000, 0x748d452a00000000, 0xe51c2d8400000000, - 0x90e4d47900000000, 0x0175bcd700000000, 0xf3c174fe00000000, - 0x62501c5000000000, 0x5837f6de00000000, 0xc9a69e7000000000, - 0x3b12565900000000, 0xaa833ef700000000, 0xdf7bc70a00000000, - 0x4eeaafa400000000, 0xbc5e678d00000000, 0x2dcf0f2300000000, - 0x0e1b837200000000, 0x9f8aebdc00000000, 0x6d3e23f500000000, - 0xfcaf4b5b00000000, 0x8957b2a600000000, 0x18c6da0800000000, - 0xea72122100000000, 0x7be37a8f00000000, 0x4184900100000000, - 0xd015f8af00000000, 0x22a1308600000000, 0xb330582800000000, - 0xc6c8a1d500000000, 0x5759c97b00000000, 0xa5ed015200000000, - 0x347c69fc00000000, 0x9025a49400000000, 0x01b4cc3a00000000, - 0xf300041300000000, 0x62916cbd00000000, 0x1769954000000000, - 0x86f8fdee00000000, 0x744c35c700000000, 0xe5dd5d6900000000, - 0xdfbab7e700000000, 0x4e2bdf4900000000, 0xbc9f176000000000, - 0x2d0e7fce00000000, 0x58f6863300000000, 0xc967ee9d00000000, - 0x3bd326b400000000, 0xaa424e1a00000000, 0x7360bc6500000000, - 0xe2f1d4cb00000000, 0x10451ce200000000, 0x81d4744c00000000, - 0xf42c8db100000000, 0x65bde51f00000000, 0x97092d3600000000, - 0x0698459800000000, 0x3cffaf1600000000, 0xad6ec7b800000000, - 0x5fda0f9100000000, 0xce4b673f00000000, 0xbbb39ec200000000, - 0x2a22f66c00000000, 0xd8963e4500000000, 0x490756eb00000000, - 0xed5e9b8300000000, 0x7ccff32d00000000, 0x8e7b3b0400000000, - 0x1fea53aa00000000, 0x6a12aa5700000000, 0xfb83c2f900000000, - 0x09370ad000000000, 0x98a6627e00000000, 0xa2c188f000000000, - 0x3350e05e00000000, 0xc1e4287700000000, 0x507540d900000000, - 0x258db92400000000, 0xb41cd18a00000000, 0x46a819a300000000, - 0xd739710d00000000}}; - -#else /* W == 4 */ - -local const z_crc_t FAR crc_braid_table[][256] = { - {0x00000000, 0xccaa009e, 0x4225077d, 0x8e8f07e3, 0x844a0efa, - 0x48e00e64, 0xc66f0987, 0x0ac50919, 0xd3e51bb5, 0x1f4f1b2b, - 0x91c01cc8, 0x5d6a1c56, 0x57af154f, 0x9b0515d1, 0x158a1232, - 0xd92012ac, 0x7cbb312b, 0xb01131b5, 0x3e9e3656, 0xf23436c8, - 0xf8f13fd1, 0x345b3f4f, 0xbad438ac, 0x767e3832, 0xaf5e2a9e, - 0x63f42a00, 0xed7b2de3, 0x21d12d7d, 0x2b142464, 0xe7be24fa, - 0x69312319, 0xa59b2387, 0xf9766256, 0x35dc62c8, 0xbb53652b, - 0x77f965b5, 0x7d3c6cac, 0xb1966c32, 0x3f196bd1, 0xf3b36b4f, - 0x2a9379e3, 0xe639797d, 0x68b67e9e, 0xa41c7e00, 0xaed97719, - 0x62737787, 0xecfc7064, 0x205670fa, 0x85cd537d, 0x496753e3, - 0xc7e85400, 0x0b42549e, 0x01875d87, 0xcd2d5d19, 0x43a25afa, - 0x8f085a64, 0x562848c8, 0x9a824856, 0x140d4fb5, 0xd8a74f2b, - 0xd2624632, 0x1ec846ac, 0x9047414f, 0x5ced41d1, 0x299dc2ed, - 0xe537c273, 0x6bb8c590, 0xa712c50e, 0xadd7cc17, 0x617dcc89, - 0xeff2cb6a, 0x2358cbf4, 0xfa78d958, 0x36d2d9c6, 0xb85dde25, - 0x74f7debb, 0x7e32d7a2, 0xb298d73c, 0x3c17d0df, 0xf0bdd041, - 0x5526f3c6, 0x998cf358, 0x1703f4bb, 0xdba9f425, 0xd16cfd3c, - 0x1dc6fda2, 0x9349fa41, 0x5fe3fadf, 0x86c3e873, 0x4a69e8ed, - 0xc4e6ef0e, 0x084cef90, 0x0289e689, 0xce23e617, 0x40ace1f4, - 0x8c06e16a, 0xd0eba0bb, 0x1c41a025, 0x92cea7c6, 0x5e64a758, - 0x54a1ae41, 0x980baedf, 0x1684a93c, 0xda2ea9a2, 0x030ebb0e, - 0xcfa4bb90, 0x412bbc73, 0x8d81bced, 0x8744b5f4, 0x4beeb56a, - 0xc561b289, 0x09cbb217, 0xac509190, 0x60fa910e, 0xee7596ed, - 0x22df9673, 0x281a9f6a, 0xe4b09ff4, 0x6a3f9817, 0xa6959889, - 0x7fb58a25, 0xb31f8abb, 0x3d908d58, 0xf13a8dc6, 0xfbff84df, - 0x37558441, 0xb9da83a2, 0x7570833c, 0x533b85da, 0x9f918544, - 0x111e82a7, 0xddb48239, 0xd7718b20, 0x1bdb8bbe, 0x95548c5d, - 0x59fe8cc3, 0x80de9e6f, 0x4c749ef1, 0xc2fb9912, 0x0e51998c, - 0x04949095, 0xc83e900b, 0x46b197e8, 0x8a1b9776, 0x2f80b4f1, - 0xe32ab46f, 0x6da5b38c, 0xa10fb312, 0xabcaba0b, 0x6760ba95, - 0xe9efbd76, 0x2545bde8, 0xfc65af44, 0x30cfafda, 0xbe40a839, - 0x72eaa8a7, 0x782fa1be, 0xb485a120, 0x3a0aa6c3, 0xf6a0a65d, - 0xaa4de78c, 0x66e7e712, 0xe868e0f1, 0x24c2e06f, 0x2e07e976, - 0xe2ade9e8, 0x6c22ee0b, 0xa088ee95, 0x79a8fc39, 0xb502fca7, - 0x3b8dfb44, 0xf727fbda, 0xfde2f2c3, 0x3148f25d, 0xbfc7f5be, - 0x736df520, 0xd6f6d6a7, 0x1a5cd639, 0x94d3d1da, 0x5879d144, - 0x52bcd85d, 0x9e16d8c3, 0x1099df20, 0xdc33dfbe, 0x0513cd12, - 0xc9b9cd8c, 0x4736ca6f, 0x8b9ccaf1, 0x8159c3e8, 0x4df3c376, - 0xc37cc495, 0x0fd6c40b, 0x7aa64737, 0xb60c47a9, 0x3883404a, - 0xf42940d4, 0xfeec49cd, 0x32464953, 0xbcc94eb0, 0x70634e2e, - 0xa9435c82, 0x65e95c1c, 0xeb665bff, 0x27cc5b61, 0x2d095278, - 0xe1a352e6, 0x6f2c5505, 0xa386559b, 0x061d761c, 0xcab77682, - 0x44387161, 0x889271ff, 0x825778e6, 0x4efd7878, 0xc0727f9b, - 0x0cd87f05, 0xd5f86da9, 0x19526d37, 0x97dd6ad4, 0x5b776a4a, - 0x51b26353, 0x9d1863cd, 0x1397642e, 0xdf3d64b0, 0x83d02561, - 0x4f7a25ff, 0xc1f5221c, 0x0d5f2282, 0x079a2b9b, 0xcb302b05, - 0x45bf2ce6, 0x89152c78, 0x50353ed4, 0x9c9f3e4a, 0x121039a9, - 0xdeba3937, 0xd47f302e, 0x18d530b0, 0x965a3753, 0x5af037cd, - 0xff6b144a, 0x33c114d4, 0xbd4e1337, 0x71e413a9, 0x7b211ab0, - 0xb78b1a2e, 0x39041dcd, 0xf5ae1d53, 0x2c8e0fff, 0xe0240f61, - 0x6eab0882, 0xa201081c, 0xa8c40105, 0x646e019b, 0xeae10678, - 0x264b06e6}, - {0x00000000, 0xa6770bb4, 0x979f1129, 0x31e81a9d, 0xf44f2413, - 0x52382fa7, 0x63d0353a, 0xc5a73e8e, 0x33ef4e67, 0x959845d3, - 0xa4705f4e, 0x020754fa, 0xc7a06a74, 0x61d761c0, 0x503f7b5d, - 0xf64870e9, 0x67de9cce, 0xc1a9977a, 0xf0418de7, 0x56368653, - 0x9391b8dd, 0x35e6b369, 0x040ea9f4, 0xa279a240, 0x5431d2a9, - 0xf246d91d, 0xc3aec380, 0x65d9c834, 0xa07ef6ba, 0x0609fd0e, - 0x37e1e793, 0x9196ec27, 0xcfbd399c, 0x69ca3228, 0x582228b5, - 0xfe552301, 0x3bf21d8f, 0x9d85163b, 0xac6d0ca6, 0x0a1a0712, - 0xfc5277fb, 0x5a257c4f, 0x6bcd66d2, 0xcdba6d66, 0x081d53e8, - 0xae6a585c, 0x9f8242c1, 0x39f54975, 0xa863a552, 0x0e14aee6, - 0x3ffcb47b, 0x998bbfcf, 0x5c2c8141, 0xfa5b8af5, 0xcbb39068, - 0x6dc49bdc, 0x9b8ceb35, 0x3dfbe081, 0x0c13fa1c, 0xaa64f1a8, - 0x6fc3cf26, 0xc9b4c492, 0xf85cde0f, 0x5e2bd5bb, 0x440b7579, - 0xe27c7ecd, 0xd3946450, 0x75e36fe4, 0xb044516a, 0x16335ade, - 0x27db4043, 0x81ac4bf7, 0x77e43b1e, 0xd19330aa, 0xe07b2a37, - 0x460c2183, 0x83ab1f0d, 0x25dc14b9, 0x14340e24, 0xb2430590, - 0x23d5e9b7, 0x85a2e203, 0xb44af89e, 0x123df32a, 0xd79acda4, - 0x71edc610, 0x4005dc8d, 0xe672d739, 0x103aa7d0, 0xb64dac64, - 0x87a5b6f9, 0x21d2bd4d, 0xe47583c3, 0x42028877, 0x73ea92ea, - 0xd59d995e, 0x8bb64ce5, 0x2dc14751, 0x1c295dcc, 0xba5e5678, - 0x7ff968f6, 0xd98e6342, 0xe86679df, 0x4e11726b, 0xb8590282, - 0x1e2e0936, 0x2fc613ab, 0x89b1181f, 0x4c162691, 0xea612d25, - 0xdb8937b8, 0x7dfe3c0c, 0xec68d02b, 0x4a1fdb9f, 0x7bf7c102, - 0xdd80cab6, 0x1827f438, 0xbe50ff8c, 0x8fb8e511, 0x29cfeea5, - 0xdf879e4c, 0x79f095f8, 0x48188f65, 0xee6f84d1, 0x2bc8ba5f, - 0x8dbfb1eb, 0xbc57ab76, 0x1a20a0c2, 0x8816eaf2, 0x2e61e146, - 0x1f89fbdb, 0xb9fef06f, 0x7c59cee1, 0xda2ec555, 0xebc6dfc8, - 0x4db1d47c, 0xbbf9a495, 0x1d8eaf21, 0x2c66b5bc, 0x8a11be08, - 0x4fb68086, 0xe9c18b32, 0xd82991af, 0x7e5e9a1b, 0xefc8763c, - 0x49bf7d88, 0x78576715, 0xde206ca1, 0x1b87522f, 0xbdf0599b, - 0x8c184306, 0x2a6f48b2, 0xdc27385b, 0x7a5033ef, 0x4bb82972, - 0xedcf22c6, 0x28681c48, 0x8e1f17fc, 0xbff70d61, 0x198006d5, - 0x47abd36e, 0xe1dcd8da, 0xd034c247, 0x7643c9f3, 0xb3e4f77d, - 0x1593fcc9, 0x247be654, 0x820cede0, 0x74449d09, 0xd23396bd, - 0xe3db8c20, 0x45ac8794, 0x800bb91a, 0x267cb2ae, 0x1794a833, - 0xb1e3a387, 0x20754fa0, 0x86024414, 0xb7ea5e89, 0x119d553d, - 0xd43a6bb3, 0x724d6007, 0x43a57a9a, 0xe5d2712e, 0x139a01c7, - 0xb5ed0a73, 0x840510ee, 0x22721b5a, 0xe7d525d4, 0x41a22e60, - 0x704a34fd, 0xd63d3f49, 0xcc1d9f8b, 0x6a6a943f, 0x5b828ea2, - 0xfdf58516, 0x3852bb98, 0x9e25b02c, 0xafcdaab1, 0x09baa105, - 0xfff2d1ec, 0x5985da58, 0x686dc0c5, 0xce1acb71, 0x0bbdf5ff, - 0xadcafe4b, 0x9c22e4d6, 0x3a55ef62, 0xabc30345, 0x0db408f1, - 0x3c5c126c, 0x9a2b19d8, 0x5f8c2756, 0xf9fb2ce2, 0xc813367f, - 0x6e643dcb, 0x982c4d22, 0x3e5b4696, 0x0fb35c0b, 0xa9c457bf, - 0x6c636931, 0xca146285, 0xfbfc7818, 0x5d8b73ac, 0x03a0a617, - 0xa5d7ada3, 0x943fb73e, 0x3248bc8a, 0xf7ef8204, 0x519889b0, - 0x6070932d, 0xc6079899, 0x304fe870, 0x9638e3c4, 0xa7d0f959, - 0x01a7f2ed, 0xc400cc63, 0x6277c7d7, 0x539fdd4a, 0xf5e8d6fe, - 0x647e3ad9, 0xc209316d, 0xf3e12bf0, 0x55962044, 0x90311eca, - 0x3646157e, 0x07ae0fe3, 0xa1d90457, 0x579174be, 0xf1e67f0a, - 0xc00e6597, 0x66796e23, 0xa3de50ad, 0x05a95b19, 0x34414184, - 0x92364a30}, - {0x00000000, 0xcb5cd3a5, 0x4dc8a10b, 0x869472ae, 0x9b914216, - 0x50cd91b3, 0xd659e31d, 0x1d0530b8, 0xec53826d, 0x270f51c8, - 0xa19b2366, 0x6ac7f0c3, 0x77c2c07b, 0xbc9e13de, 0x3a0a6170, - 0xf156b2d5, 0x03d6029b, 0xc88ad13e, 0x4e1ea390, 0x85427035, - 0x9847408d, 0x531b9328, 0xd58fe186, 0x1ed33223, 0xef8580f6, - 0x24d95353, 0xa24d21fd, 0x6911f258, 0x7414c2e0, 0xbf481145, - 0x39dc63eb, 0xf280b04e, 0x07ac0536, 0xccf0d693, 0x4a64a43d, - 0x81387798, 0x9c3d4720, 0x57619485, 0xd1f5e62b, 0x1aa9358e, - 0xebff875b, 0x20a354fe, 0xa6372650, 0x6d6bf5f5, 0x706ec54d, - 0xbb3216e8, 0x3da66446, 0xf6fab7e3, 0x047a07ad, 0xcf26d408, - 0x49b2a6a6, 0x82ee7503, 0x9feb45bb, 0x54b7961e, 0xd223e4b0, - 0x197f3715, 0xe82985c0, 0x23755665, 0xa5e124cb, 0x6ebdf76e, - 0x73b8c7d6, 0xb8e41473, 0x3e7066dd, 0xf52cb578, 0x0f580a6c, - 0xc404d9c9, 0x4290ab67, 0x89cc78c2, 0x94c9487a, 0x5f959bdf, - 0xd901e971, 0x125d3ad4, 0xe30b8801, 0x28575ba4, 0xaec3290a, - 0x659ffaaf, 0x789aca17, 0xb3c619b2, 0x35526b1c, 0xfe0eb8b9, - 0x0c8e08f7, 0xc7d2db52, 0x4146a9fc, 0x8a1a7a59, 0x971f4ae1, - 0x5c439944, 0xdad7ebea, 0x118b384f, 0xe0dd8a9a, 0x2b81593f, - 0xad152b91, 0x6649f834, 0x7b4cc88c, 0xb0101b29, 0x36846987, - 0xfdd8ba22, 0x08f40f5a, 0xc3a8dcff, 0x453cae51, 0x8e607df4, - 0x93654d4c, 0x58399ee9, 0xdeadec47, 0x15f13fe2, 0xe4a78d37, - 0x2ffb5e92, 0xa96f2c3c, 0x6233ff99, 0x7f36cf21, 0xb46a1c84, - 0x32fe6e2a, 0xf9a2bd8f, 0x0b220dc1, 0xc07ede64, 0x46eaacca, - 0x8db67f6f, 0x90b34fd7, 0x5bef9c72, 0xdd7beedc, 0x16273d79, - 0xe7718fac, 0x2c2d5c09, 0xaab92ea7, 0x61e5fd02, 0x7ce0cdba, - 0xb7bc1e1f, 0x31286cb1, 0xfa74bf14, 0x1eb014d8, 0xd5ecc77d, - 0x5378b5d3, 0x98246676, 0x852156ce, 0x4e7d856b, 0xc8e9f7c5, - 0x03b52460, 0xf2e396b5, 0x39bf4510, 0xbf2b37be, 0x7477e41b, - 0x6972d4a3, 0xa22e0706, 0x24ba75a8, 0xefe6a60d, 0x1d661643, - 0xd63ac5e6, 0x50aeb748, 0x9bf264ed, 0x86f75455, 0x4dab87f0, - 0xcb3ff55e, 0x006326fb, 0xf135942e, 0x3a69478b, 0xbcfd3525, - 0x77a1e680, 0x6aa4d638, 0xa1f8059d, 0x276c7733, 0xec30a496, - 0x191c11ee, 0xd240c24b, 0x54d4b0e5, 0x9f886340, 0x828d53f8, - 0x49d1805d, 0xcf45f2f3, 0x04192156, 0xf54f9383, 0x3e134026, - 0xb8873288, 0x73dbe12d, 0x6eded195, 0xa5820230, 0x2316709e, - 0xe84aa33b, 0x1aca1375, 0xd196c0d0, 0x5702b27e, 0x9c5e61db, - 0x815b5163, 0x4a0782c6, 0xcc93f068, 0x07cf23cd, 0xf6999118, - 0x3dc542bd, 0xbb513013, 0x700de3b6, 0x6d08d30e, 0xa65400ab, - 0x20c07205, 0xeb9ca1a0, 0x11e81eb4, 0xdab4cd11, 0x5c20bfbf, - 0x977c6c1a, 0x8a795ca2, 0x41258f07, 0xc7b1fda9, 0x0ced2e0c, - 0xfdbb9cd9, 0x36e74f7c, 0xb0733dd2, 0x7b2fee77, 0x662adecf, - 0xad760d6a, 0x2be27fc4, 0xe0beac61, 0x123e1c2f, 0xd962cf8a, - 0x5ff6bd24, 0x94aa6e81, 0x89af5e39, 0x42f38d9c, 0xc467ff32, - 0x0f3b2c97, 0xfe6d9e42, 0x35314de7, 0xb3a53f49, 0x78f9ecec, - 0x65fcdc54, 0xaea00ff1, 0x28347d5f, 0xe368aefa, 0x16441b82, - 0xdd18c827, 0x5b8cba89, 0x90d0692c, 0x8dd55994, 0x46898a31, - 0xc01df89f, 0x0b412b3a, 0xfa1799ef, 0x314b4a4a, 0xb7df38e4, - 0x7c83eb41, 0x6186dbf9, 0xaada085c, 0x2c4e7af2, 0xe712a957, - 0x15921919, 0xdececabc, 0x585ab812, 0x93066bb7, 0x8e035b0f, - 0x455f88aa, 0xc3cbfa04, 0x089729a1, 0xf9c19b74, 0x329d48d1, - 0xb4093a7f, 0x7f55e9da, 0x6250d962, 0xa90c0ac7, 0x2f987869, - 0xe4c4abcc}, - {0x00000000, 0x3d6029b0, 0x7ac05360, 0x47a07ad0, 0xf580a6c0, - 0xc8e08f70, 0x8f40f5a0, 0xb220dc10, 0x30704bc1, 0x0d106271, - 0x4ab018a1, 0x77d03111, 0xc5f0ed01, 0xf890c4b1, 0xbf30be61, - 0x825097d1, 0x60e09782, 0x5d80be32, 0x1a20c4e2, 0x2740ed52, - 0x95603142, 0xa80018f2, 0xefa06222, 0xd2c04b92, 0x5090dc43, - 0x6df0f5f3, 0x2a508f23, 0x1730a693, 0xa5107a83, 0x98705333, - 0xdfd029e3, 0xe2b00053, 0xc1c12f04, 0xfca106b4, 0xbb017c64, - 0x866155d4, 0x344189c4, 0x0921a074, 0x4e81daa4, 0x73e1f314, - 0xf1b164c5, 0xccd14d75, 0x8b7137a5, 0xb6111e15, 0x0431c205, - 0x3951ebb5, 0x7ef19165, 0x4391b8d5, 0xa121b886, 0x9c419136, - 0xdbe1ebe6, 0xe681c256, 0x54a11e46, 0x69c137f6, 0x2e614d26, - 0x13016496, 0x9151f347, 0xac31daf7, 0xeb91a027, 0xd6f18997, - 0x64d15587, 0x59b17c37, 0x1e1106e7, 0x23712f57, 0x58f35849, - 0x659371f9, 0x22330b29, 0x1f532299, 0xad73fe89, 0x9013d739, - 0xd7b3ade9, 0xead38459, 0x68831388, 0x55e33a38, 0x124340e8, - 0x2f236958, 0x9d03b548, 0xa0639cf8, 0xe7c3e628, 0xdaa3cf98, - 0x3813cfcb, 0x0573e67b, 0x42d39cab, 0x7fb3b51b, 0xcd93690b, - 0xf0f340bb, 0xb7533a6b, 0x8a3313db, 0x0863840a, 0x3503adba, - 0x72a3d76a, 0x4fc3feda, 0xfde322ca, 0xc0830b7a, 0x872371aa, - 0xba43581a, 0x9932774d, 0xa4525efd, 0xe3f2242d, 0xde920d9d, - 0x6cb2d18d, 0x51d2f83d, 0x167282ed, 0x2b12ab5d, 0xa9423c8c, - 0x9422153c, 0xd3826fec, 0xeee2465c, 0x5cc29a4c, 0x61a2b3fc, - 0x2602c92c, 0x1b62e09c, 0xf9d2e0cf, 0xc4b2c97f, 0x8312b3af, - 0xbe729a1f, 0x0c52460f, 0x31326fbf, 0x7692156f, 0x4bf23cdf, - 0xc9a2ab0e, 0xf4c282be, 0xb362f86e, 0x8e02d1de, 0x3c220dce, - 0x0142247e, 0x46e25eae, 0x7b82771e, 0xb1e6b092, 0x8c869922, - 0xcb26e3f2, 0xf646ca42, 0x44661652, 0x79063fe2, 0x3ea64532, - 0x03c66c82, 0x8196fb53, 0xbcf6d2e3, 0xfb56a833, 0xc6368183, - 0x74165d93, 0x49767423, 0x0ed60ef3, 0x33b62743, 0xd1062710, - 0xec660ea0, 0xabc67470, 0x96a65dc0, 0x248681d0, 0x19e6a860, - 0x5e46d2b0, 0x6326fb00, 0xe1766cd1, 0xdc164561, 0x9bb63fb1, - 0xa6d61601, 0x14f6ca11, 0x2996e3a1, 0x6e369971, 0x5356b0c1, - 0x70279f96, 0x4d47b626, 0x0ae7ccf6, 0x3787e546, 0x85a73956, - 0xb8c710e6, 0xff676a36, 0xc2074386, 0x4057d457, 0x7d37fde7, - 0x3a978737, 0x07f7ae87, 0xb5d77297, 0x88b75b27, 0xcf1721f7, - 0xf2770847, 0x10c70814, 0x2da721a4, 0x6a075b74, 0x576772c4, - 0xe547aed4, 0xd8278764, 0x9f87fdb4, 0xa2e7d404, 0x20b743d5, - 0x1dd76a65, 0x5a7710b5, 0x67173905, 0xd537e515, 0xe857cca5, - 0xaff7b675, 0x92979fc5, 0xe915e8db, 0xd475c16b, 0x93d5bbbb, - 0xaeb5920b, 0x1c954e1b, 0x21f567ab, 0x66551d7b, 0x5b3534cb, - 0xd965a31a, 0xe4058aaa, 0xa3a5f07a, 0x9ec5d9ca, 0x2ce505da, - 0x11852c6a, 0x562556ba, 0x6b457f0a, 0x89f57f59, 0xb49556e9, - 0xf3352c39, 0xce550589, 0x7c75d999, 0x4115f029, 0x06b58af9, - 0x3bd5a349, 0xb9853498, 0x84e51d28, 0xc34567f8, 0xfe254e48, - 0x4c059258, 0x7165bbe8, 0x36c5c138, 0x0ba5e888, 0x28d4c7df, - 0x15b4ee6f, 0x521494bf, 0x6f74bd0f, 0xdd54611f, 0xe03448af, - 0xa794327f, 0x9af41bcf, 0x18a48c1e, 0x25c4a5ae, 0x6264df7e, - 0x5f04f6ce, 0xed242ade, 0xd044036e, 0x97e479be, 0xaa84500e, - 0x4834505d, 0x755479ed, 0x32f4033d, 0x0f942a8d, 0xbdb4f69d, - 0x80d4df2d, 0xc774a5fd, 0xfa148c4d, 0x78441b9c, 0x4524322c, - 0x028448fc, 0x3fe4614c, 0x8dc4bd5c, 0xb0a494ec, 0xf704ee3c, - 0xca64c78c}}; - -local const z_word_t FAR crc_braid_big_table[][256] = { - {0x00000000, 0xb029603d, 0x6053c07a, 0xd07aa047, 0xc0a680f5, - 0x708fe0c8, 0xa0f5408f, 0x10dc20b2, 0xc14b7030, 0x7162100d, - 0xa118b04a, 0x1131d077, 0x01edf0c5, 0xb1c490f8, 0x61be30bf, - 0xd1975082, 0x8297e060, 0x32be805d, 0xe2c4201a, 0x52ed4027, - 0x42316095, 0xf21800a8, 0x2262a0ef, 0x924bc0d2, 0x43dc9050, - 0xf3f5f06d, 0x238f502a, 0x93a63017, 0x837a10a5, 0x33537098, - 0xe329d0df, 0x5300b0e2, 0x042fc1c1, 0xb406a1fc, 0x647c01bb, - 0xd4556186, 0xc4894134, 0x74a02109, 0xa4da814e, 0x14f3e173, - 0xc564b1f1, 0x754dd1cc, 0xa537718b, 0x151e11b6, 0x05c23104, - 0xb5eb5139, 0x6591f17e, 0xd5b89143, 0x86b821a1, 0x3691419c, - 0xe6ebe1db, 0x56c281e6, 0x461ea154, 0xf637c169, 0x264d612e, - 0x96640113, 0x47f35191, 0xf7da31ac, 0x27a091eb, 0x9789f1d6, - 0x8755d164, 0x377cb159, 0xe706111e, 0x572f7123, 0x4958f358, - 0xf9719365, 0x290b3322, 0x9922531f, 0x89fe73ad, 0x39d71390, - 0xe9adb3d7, 0x5984d3ea, 0x88138368, 0x383ae355, 0xe8404312, - 0x5869232f, 0x48b5039d, 0xf89c63a0, 0x28e6c3e7, 0x98cfa3da, - 0xcbcf1338, 0x7be67305, 0xab9cd342, 0x1bb5b37f, 0x0b6993cd, - 0xbb40f3f0, 0x6b3a53b7, 0xdb13338a, 0x0a846308, 0xbaad0335, - 0x6ad7a372, 0xdafec34f, 0xca22e3fd, 0x7a0b83c0, 0xaa712387, - 0x1a5843ba, 0x4d773299, 0xfd5e52a4, 0x2d24f2e3, 0x9d0d92de, - 0x8dd1b26c, 0x3df8d251, 0xed827216, 0x5dab122b, 0x8c3c42a9, - 0x3c152294, 0xec6f82d3, 0x5c46e2ee, 0x4c9ac25c, 0xfcb3a261, - 0x2cc90226, 0x9ce0621b, 0xcfe0d2f9, 0x7fc9b2c4, 0xafb31283, - 0x1f9a72be, 0x0f46520c, 0xbf6f3231, 0x6f159276, 0xdf3cf24b, - 0x0eaba2c9, 0xbe82c2f4, 0x6ef862b3, 0xded1028e, 0xce0d223c, - 0x7e244201, 0xae5ee246, 0x1e77827b, 0x92b0e6b1, 0x2299868c, - 0xf2e326cb, 0x42ca46f6, 0x52166644, 0xe23f0679, 0x3245a63e, - 0x826cc603, 0x53fb9681, 0xe3d2f6bc, 0x33a856fb, 0x838136c6, - 0x935d1674, 0x23747649, 0xf30ed60e, 0x4327b633, 0x102706d1, - 0xa00e66ec, 0x7074c6ab, 0xc05da696, 0xd0818624, 0x60a8e619, - 0xb0d2465e, 0x00fb2663, 0xd16c76e1, 0x614516dc, 0xb13fb69b, - 0x0116d6a6, 0x11caf614, 0xa1e39629, 0x7199366e, 0xc1b05653, - 0x969f2770, 0x26b6474d, 0xf6cce70a, 0x46e58737, 0x5639a785, - 0xe610c7b8, 0x366a67ff, 0x864307c2, 0x57d45740, 0xe7fd377d, - 0x3787973a, 0x87aef707, 0x9772d7b5, 0x275bb788, 0xf72117cf, - 0x470877f2, 0x1408c710, 0xa421a72d, 0x745b076a, 0xc4726757, - 0xd4ae47e5, 0x648727d8, 0xb4fd879f, 0x04d4e7a2, 0xd543b720, - 0x656ad71d, 0xb510775a, 0x05391767, 0x15e537d5, 0xa5cc57e8, - 0x75b6f7af, 0xc59f9792, 0xdbe815e9, 0x6bc175d4, 0xbbbbd593, - 0x0b92b5ae, 0x1b4e951c, 0xab67f521, 0x7b1d5566, 0xcb34355b, - 0x1aa365d9, 0xaa8a05e4, 0x7af0a5a3, 0xcad9c59e, 0xda05e52c, - 0x6a2c8511, 0xba562556, 0x0a7f456b, 0x597ff589, 0xe95695b4, - 0x392c35f3, 0x890555ce, 0x99d9757c, 0x29f01541, 0xf98ab506, - 0x49a3d53b, 0x983485b9, 0x281de584, 0xf86745c3, 0x484e25fe, - 0x5892054c, 0xe8bb6571, 0x38c1c536, 0x88e8a50b, 0xdfc7d428, - 0x6feeb415, 0xbf941452, 0x0fbd746f, 0x1f6154dd, 0xaf4834e0, - 0x7f3294a7, 0xcf1bf49a, 0x1e8ca418, 0xaea5c425, 0x7edf6462, - 0xcef6045f, 0xde2a24ed, 0x6e0344d0, 0xbe79e497, 0x0e5084aa, - 0x5d503448, 0xed795475, 0x3d03f432, 0x8d2a940f, 0x9df6b4bd, - 0x2ddfd480, 0xfda574c7, 0x4d8c14fa, 0x9c1b4478, 0x2c322445, - 0xfc488402, 0x4c61e43f, 0x5cbdc48d, 0xec94a4b0, 0x3cee04f7, - 0x8cc764ca}, - {0x00000000, 0xa5d35ccb, 0x0ba1c84d, 0xae729486, 0x1642919b, - 0xb391cd50, 0x1de359d6, 0xb830051d, 0x6d8253ec, 0xc8510f27, - 0x66239ba1, 0xc3f0c76a, 0x7bc0c277, 0xde139ebc, 0x70610a3a, - 0xd5b256f1, 0x9b02d603, 0x3ed18ac8, 0x90a31e4e, 0x35704285, - 0x8d404798, 0x28931b53, 0x86e18fd5, 0x2332d31e, 0xf68085ef, - 0x5353d924, 0xfd214da2, 0x58f21169, 0xe0c21474, 0x451148bf, - 0xeb63dc39, 0x4eb080f2, 0x3605ac07, 0x93d6f0cc, 0x3da4644a, - 0x98773881, 0x20473d9c, 0x85946157, 0x2be6f5d1, 0x8e35a91a, - 0x5b87ffeb, 0xfe54a320, 0x502637a6, 0xf5f56b6d, 0x4dc56e70, - 0xe81632bb, 0x4664a63d, 0xe3b7faf6, 0xad077a04, 0x08d426cf, - 0xa6a6b249, 0x0375ee82, 0xbb45eb9f, 0x1e96b754, 0xb0e423d2, - 0x15377f19, 0xc08529e8, 0x65567523, 0xcb24e1a5, 0x6ef7bd6e, - 0xd6c7b873, 0x7314e4b8, 0xdd66703e, 0x78b52cf5, 0x6c0a580f, - 0xc9d904c4, 0x67ab9042, 0xc278cc89, 0x7a48c994, 0xdf9b955f, - 0x71e901d9, 0xd43a5d12, 0x01880be3, 0xa45b5728, 0x0a29c3ae, - 0xaffa9f65, 0x17ca9a78, 0xb219c6b3, 0x1c6b5235, 0xb9b80efe, - 0xf7088e0c, 0x52dbd2c7, 0xfca94641, 0x597a1a8a, 0xe14a1f97, - 0x4499435c, 0xeaebd7da, 0x4f388b11, 0x9a8adde0, 0x3f59812b, - 0x912b15ad, 0x34f84966, 0x8cc84c7b, 0x291b10b0, 0x87698436, - 0x22bad8fd, 0x5a0ff408, 0xffdca8c3, 0x51ae3c45, 0xf47d608e, - 0x4c4d6593, 0xe99e3958, 0x47ecadde, 0xe23ff115, 0x378da7e4, - 0x925efb2f, 0x3c2c6fa9, 0x99ff3362, 0x21cf367f, 0x841c6ab4, - 0x2a6efe32, 0x8fbda2f9, 0xc10d220b, 0x64de7ec0, 0xcaacea46, - 0x6f7fb68d, 0xd74fb390, 0x729cef5b, 0xdcee7bdd, 0x793d2716, - 0xac8f71e7, 0x095c2d2c, 0xa72eb9aa, 0x02fde561, 0xbacde07c, - 0x1f1ebcb7, 0xb16c2831, 0x14bf74fa, 0xd814b01e, 0x7dc7ecd5, - 0xd3b57853, 0x76662498, 0xce562185, 0x6b857d4e, 0xc5f7e9c8, - 0x6024b503, 0xb596e3f2, 0x1045bf39, 0xbe372bbf, 0x1be47774, - 0xa3d47269, 0x06072ea2, 0xa875ba24, 0x0da6e6ef, 0x4316661d, - 0xe6c53ad6, 0x48b7ae50, 0xed64f29b, 0x5554f786, 0xf087ab4d, - 0x5ef53fcb, 0xfb266300, 0x2e9435f1, 0x8b47693a, 0x2535fdbc, - 0x80e6a177, 0x38d6a46a, 0x9d05f8a1, 0x33776c27, 0x96a430ec, - 0xee111c19, 0x4bc240d2, 0xe5b0d454, 0x4063889f, 0xf8538d82, - 0x5d80d149, 0xf3f245cf, 0x56211904, 0x83934ff5, 0x2640133e, - 0x883287b8, 0x2de1db73, 0x95d1de6e, 0x300282a5, 0x9e701623, - 0x3ba34ae8, 0x7513ca1a, 0xd0c096d1, 0x7eb20257, 0xdb615e9c, - 0x63515b81, 0xc682074a, 0x68f093cc, 0xcd23cf07, 0x189199f6, - 0xbd42c53d, 0x133051bb, 0xb6e30d70, 0x0ed3086d, 0xab0054a6, - 0x0572c020, 0xa0a19ceb, 0xb41ee811, 0x11cdb4da, 0xbfbf205c, - 0x1a6c7c97, 0xa25c798a, 0x078f2541, 0xa9fdb1c7, 0x0c2eed0c, - 0xd99cbbfd, 0x7c4fe736, 0xd23d73b0, 0x77ee2f7b, 0xcfde2a66, - 0x6a0d76ad, 0xc47fe22b, 0x61acbee0, 0x2f1c3e12, 0x8acf62d9, - 0x24bdf65f, 0x816eaa94, 0x395eaf89, 0x9c8df342, 0x32ff67c4, - 0x972c3b0f, 0x429e6dfe, 0xe74d3135, 0x493fa5b3, 0xececf978, - 0x54dcfc65, 0xf10fa0ae, 0x5f7d3428, 0xfaae68e3, 0x821b4416, - 0x27c818dd, 0x89ba8c5b, 0x2c69d090, 0x9459d58d, 0x318a8946, - 0x9ff81dc0, 0x3a2b410b, 0xef9917fa, 0x4a4a4b31, 0xe438dfb7, - 0x41eb837c, 0xf9db8661, 0x5c08daaa, 0xf27a4e2c, 0x57a912e7, - 0x19199215, 0xbccacede, 0x12b85a58, 0xb76b0693, 0x0f5b038e, - 0xaa885f45, 0x04facbc3, 0xa1299708, 0x749bc1f9, 0xd1489d32, - 0x7f3a09b4, 0xdae9557f, 0x62d95062, 0xc70a0ca9, 0x6978982f, - 0xccabc4e4}, - {0x00000000, 0xb40b77a6, 0x29119f97, 0x9d1ae831, 0x13244ff4, - 0xa72f3852, 0x3a35d063, 0x8e3ea7c5, 0x674eef33, 0xd3459895, - 0x4e5f70a4, 0xfa540702, 0x746aa0c7, 0xc061d761, 0x5d7b3f50, - 0xe97048f6, 0xce9cde67, 0x7a97a9c1, 0xe78d41f0, 0x53863656, - 0xddb89193, 0x69b3e635, 0xf4a90e04, 0x40a279a2, 0xa9d23154, - 0x1dd946f2, 0x80c3aec3, 0x34c8d965, 0xbaf67ea0, 0x0efd0906, - 0x93e7e137, 0x27ec9691, 0x9c39bdcf, 0x2832ca69, 0xb5282258, - 0x012355fe, 0x8f1df23b, 0x3b16859d, 0xa60c6dac, 0x12071a0a, - 0xfb7752fc, 0x4f7c255a, 0xd266cd6b, 0x666dbacd, 0xe8531d08, - 0x5c586aae, 0xc142829f, 0x7549f539, 0x52a563a8, 0xe6ae140e, - 0x7bb4fc3f, 0xcfbf8b99, 0x41812c5c, 0xf58a5bfa, 0x6890b3cb, - 0xdc9bc46d, 0x35eb8c9b, 0x81e0fb3d, 0x1cfa130c, 0xa8f164aa, - 0x26cfc36f, 0x92c4b4c9, 0x0fde5cf8, 0xbbd52b5e, 0x79750b44, - 0xcd7e7ce2, 0x506494d3, 0xe46fe375, 0x6a5144b0, 0xde5a3316, - 0x4340db27, 0xf74bac81, 0x1e3be477, 0xaa3093d1, 0x372a7be0, - 0x83210c46, 0x0d1fab83, 0xb914dc25, 0x240e3414, 0x900543b2, - 0xb7e9d523, 0x03e2a285, 0x9ef84ab4, 0x2af33d12, 0xa4cd9ad7, - 0x10c6ed71, 0x8ddc0540, 0x39d772e6, 0xd0a73a10, 0x64ac4db6, - 0xf9b6a587, 0x4dbdd221, 0xc38375e4, 0x77880242, 0xea92ea73, - 0x5e999dd5, 0xe54cb68b, 0x5147c12d, 0xcc5d291c, 0x78565eba, - 0xf668f97f, 0x42638ed9, 0xdf7966e8, 0x6b72114e, 0x820259b8, - 0x36092e1e, 0xab13c62f, 0x1f18b189, 0x9126164c, 0x252d61ea, - 0xb83789db, 0x0c3cfe7d, 0x2bd068ec, 0x9fdb1f4a, 0x02c1f77b, - 0xb6ca80dd, 0x38f42718, 0x8cff50be, 0x11e5b88f, 0xa5eecf29, - 0x4c9e87df, 0xf895f079, 0x658f1848, 0xd1846fee, 0x5fbac82b, - 0xebb1bf8d, 0x76ab57bc, 0xc2a0201a, 0xf2ea1688, 0x46e1612e, - 0xdbfb891f, 0x6ff0feb9, 0xe1ce597c, 0x55c52eda, 0xc8dfc6eb, - 0x7cd4b14d, 0x95a4f9bb, 0x21af8e1d, 0xbcb5662c, 0x08be118a, - 0x8680b64f, 0x328bc1e9, 0xaf9129d8, 0x1b9a5e7e, 0x3c76c8ef, - 0x887dbf49, 0x15675778, 0xa16c20de, 0x2f52871b, 0x9b59f0bd, - 0x0643188c, 0xb2486f2a, 0x5b3827dc, 0xef33507a, 0x7229b84b, - 0xc622cfed, 0x481c6828, 0xfc171f8e, 0x610df7bf, 0xd5068019, - 0x6ed3ab47, 0xdad8dce1, 0x47c234d0, 0xf3c94376, 0x7df7e4b3, - 0xc9fc9315, 0x54e67b24, 0xe0ed0c82, 0x099d4474, 0xbd9633d2, - 0x208cdbe3, 0x9487ac45, 0x1ab90b80, 0xaeb27c26, 0x33a89417, - 0x87a3e3b1, 0xa04f7520, 0x14440286, 0x895eeab7, 0x3d559d11, - 0xb36b3ad4, 0x07604d72, 0x9a7aa543, 0x2e71d2e5, 0xc7019a13, - 0x730aedb5, 0xee100584, 0x5a1b7222, 0xd425d5e7, 0x602ea241, - 0xfd344a70, 0x493f3dd6, 0x8b9f1dcc, 0x3f946a6a, 0xa28e825b, - 0x1685f5fd, 0x98bb5238, 0x2cb0259e, 0xb1aacdaf, 0x05a1ba09, - 0xecd1f2ff, 0x58da8559, 0xc5c06d68, 0x71cb1ace, 0xfff5bd0b, - 0x4bfecaad, 0xd6e4229c, 0x62ef553a, 0x4503c3ab, 0xf108b40d, - 0x6c125c3c, 0xd8192b9a, 0x56278c5f, 0xe22cfbf9, 0x7f3613c8, - 0xcb3d646e, 0x224d2c98, 0x96465b3e, 0x0b5cb30f, 0xbf57c4a9, - 0x3169636c, 0x856214ca, 0x1878fcfb, 0xac738b5d, 0x17a6a003, - 0xa3add7a5, 0x3eb73f94, 0x8abc4832, 0x0482eff7, 0xb0899851, - 0x2d937060, 0x999807c6, 0x70e84f30, 0xc4e33896, 0x59f9d0a7, - 0xedf2a701, 0x63cc00c4, 0xd7c77762, 0x4add9f53, 0xfed6e8f5, - 0xd93a7e64, 0x6d3109c2, 0xf02be1f3, 0x44209655, 0xca1e3190, - 0x7e154636, 0xe30fae07, 0x5704d9a1, 0xbe749157, 0x0a7fe6f1, - 0x97650ec0, 0x236e7966, 0xad50dea3, 0x195ba905, 0x84414134, - 0x304a3692}, - {0x00000000, 0x9e00aacc, 0x7d072542, 0xe3078f8e, 0xfa0e4a84, - 0x640ee048, 0x87096fc6, 0x1909c50a, 0xb51be5d3, 0x2b1b4f1f, - 0xc81cc091, 0x561c6a5d, 0x4f15af57, 0xd115059b, 0x32128a15, - 0xac1220d9, 0x2b31bb7c, 0xb53111b0, 0x56369e3e, 0xc83634f2, - 0xd13ff1f8, 0x4f3f5b34, 0xac38d4ba, 0x32387e76, 0x9e2a5eaf, - 0x002af463, 0xe32d7bed, 0x7d2dd121, 0x6424142b, 0xfa24bee7, - 0x19233169, 0x87239ba5, 0x566276f9, 0xc862dc35, 0x2b6553bb, - 0xb565f977, 0xac6c3c7d, 0x326c96b1, 0xd16b193f, 0x4f6bb3f3, - 0xe379932a, 0x7d7939e6, 0x9e7eb668, 0x007e1ca4, 0x1977d9ae, - 0x87777362, 0x6470fcec, 0xfa705620, 0x7d53cd85, 0xe3536749, - 0x0054e8c7, 0x9e54420b, 0x875d8701, 0x195d2dcd, 0xfa5aa243, - 0x645a088f, 0xc8482856, 0x5648829a, 0xb54f0d14, 0x2b4fa7d8, - 0x324662d2, 0xac46c81e, 0x4f414790, 0xd141ed5c, 0xedc29d29, - 0x73c237e5, 0x90c5b86b, 0x0ec512a7, 0x17ccd7ad, 0x89cc7d61, - 0x6acbf2ef, 0xf4cb5823, 0x58d978fa, 0xc6d9d236, 0x25de5db8, - 0xbbdef774, 0xa2d7327e, 0x3cd798b2, 0xdfd0173c, 0x41d0bdf0, - 0xc6f32655, 0x58f38c99, 0xbbf40317, 0x25f4a9db, 0x3cfd6cd1, - 0xa2fdc61d, 0x41fa4993, 0xdffae35f, 0x73e8c386, 0xede8694a, - 0x0eefe6c4, 0x90ef4c08, 0x89e68902, 0x17e623ce, 0xf4e1ac40, - 0x6ae1068c, 0xbba0ebd0, 0x25a0411c, 0xc6a7ce92, 0x58a7645e, - 0x41aea154, 0xdfae0b98, 0x3ca98416, 0xa2a92eda, 0x0ebb0e03, - 0x90bba4cf, 0x73bc2b41, 0xedbc818d, 0xf4b54487, 0x6ab5ee4b, - 0x89b261c5, 0x17b2cb09, 0x909150ac, 0x0e91fa60, 0xed9675ee, - 0x7396df22, 0x6a9f1a28, 0xf49fb0e4, 0x17983f6a, 0x899895a6, - 0x258ab57f, 0xbb8a1fb3, 0x588d903d, 0xc68d3af1, 0xdf84fffb, - 0x41845537, 0xa283dab9, 0x3c837075, 0xda853b53, 0x4485919f, - 0xa7821e11, 0x3982b4dd, 0x208b71d7, 0xbe8bdb1b, 0x5d8c5495, - 0xc38cfe59, 0x6f9ede80, 0xf19e744c, 0x1299fbc2, 0x8c99510e, - 0x95909404, 0x0b903ec8, 0xe897b146, 0x76971b8a, 0xf1b4802f, - 0x6fb42ae3, 0x8cb3a56d, 0x12b30fa1, 0x0bbacaab, 0x95ba6067, - 0x76bdefe9, 0xe8bd4525, 0x44af65fc, 0xdaafcf30, 0x39a840be, - 0xa7a8ea72, 0xbea12f78, 0x20a185b4, 0xc3a60a3a, 0x5da6a0f6, - 0x8ce74daa, 0x12e7e766, 0xf1e068e8, 0x6fe0c224, 0x76e9072e, - 0xe8e9ade2, 0x0bee226c, 0x95ee88a0, 0x39fca879, 0xa7fc02b5, - 0x44fb8d3b, 0xdafb27f7, 0xc3f2e2fd, 0x5df24831, 0xbef5c7bf, - 0x20f56d73, 0xa7d6f6d6, 0x39d65c1a, 0xdad1d394, 0x44d17958, - 0x5dd8bc52, 0xc3d8169e, 0x20df9910, 0xbedf33dc, 0x12cd1305, - 0x8ccdb9c9, 0x6fca3647, 0xf1ca9c8b, 0xe8c35981, 0x76c3f34d, - 0x95c47cc3, 0x0bc4d60f, 0x3747a67a, 0xa9470cb6, 0x4a408338, - 0xd44029f4, 0xcd49ecfe, 0x53494632, 0xb04ec9bc, 0x2e4e6370, - 0x825c43a9, 0x1c5ce965, 0xff5b66eb, 0x615bcc27, 0x7852092d, - 0xe652a3e1, 0x05552c6f, 0x9b5586a3, 0x1c761d06, 0x8276b7ca, - 0x61713844, 0xff719288, 0xe6785782, 0x7878fd4e, 0x9b7f72c0, - 0x057fd80c, 0xa96df8d5, 0x376d5219, 0xd46add97, 0x4a6a775b, - 0x5363b251, 0xcd63189d, 0x2e649713, 0xb0643ddf, 0x6125d083, - 0xff257a4f, 0x1c22f5c1, 0x82225f0d, 0x9b2b9a07, 0x052b30cb, - 0xe62cbf45, 0x782c1589, 0xd43e3550, 0x4a3e9f9c, 0xa9391012, - 0x3739bade, 0x2e307fd4, 0xb030d518, 0x53375a96, 0xcd37f05a, - 0x4a146bff, 0xd414c133, 0x37134ebd, 0xa913e471, 0xb01a217b, - 0x2e1a8bb7, 0xcd1d0439, 0x531daef5, 0xff0f8e2c, 0x610f24e0, - 0x8208ab6e, 0x1c0801a2, 0x0501c4a8, 0x9b016e64, 0x7806e1ea, - 0xe6064b26}}; - -#endif - -#endif - -#if N == 3 - -#if W == 8 - -local const z_crc_t FAR crc_braid_table[][256] = { - {0x00000000, 0x81256527, 0xd93bcc0f, 0x581ea928, 0x69069e5f, - 0xe823fb78, 0xb03d5250, 0x31183777, 0xd20d3cbe, 0x53285999, - 0x0b36f0b1, 0x8a139596, 0xbb0ba2e1, 0x3a2ec7c6, 0x62306eee, - 0xe3150bc9, 0x7f6b7f3d, 0xfe4e1a1a, 0xa650b332, 0x2775d615, - 0x166de162, 0x97488445, 0xcf562d6d, 0x4e73484a, 0xad664383, - 0x2c4326a4, 0x745d8f8c, 0xf578eaab, 0xc460dddc, 0x4545b8fb, - 0x1d5b11d3, 0x9c7e74f4, 0xfed6fe7a, 0x7ff39b5d, 0x27ed3275, - 0xa6c85752, 0x97d06025, 0x16f50502, 0x4eebac2a, 0xcfcec90d, - 0x2cdbc2c4, 0xadfea7e3, 0xf5e00ecb, 0x74c56bec, 0x45dd5c9b, - 0xc4f839bc, 0x9ce69094, 0x1dc3f5b3, 0x81bd8147, 0x0098e460, - 0x58864d48, 0xd9a3286f, 0xe8bb1f18, 0x699e7a3f, 0x3180d317, - 0xb0a5b630, 0x53b0bdf9, 0xd295d8de, 0x8a8b71f6, 0x0bae14d1, - 0x3ab623a6, 0xbb934681, 0xe38defa9, 0x62a88a8e, 0x26dcfab5, - 0xa7f99f92, 0xffe736ba, 0x7ec2539d, 0x4fda64ea, 0xceff01cd, - 0x96e1a8e5, 0x17c4cdc2, 0xf4d1c60b, 0x75f4a32c, 0x2dea0a04, - 0xaccf6f23, 0x9dd75854, 0x1cf23d73, 0x44ec945b, 0xc5c9f17c, - 0x59b78588, 0xd892e0af, 0x808c4987, 0x01a92ca0, 0x30b11bd7, - 0xb1947ef0, 0xe98ad7d8, 0x68afb2ff, 0x8bbab936, 0x0a9fdc11, - 0x52817539, 0xd3a4101e, 0xe2bc2769, 0x6399424e, 0x3b87eb66, - 0xbaa28e41, 0xd80a04cf, 0x592f61e8, 0x0131c8c0, 0x8014ade7, - 0xb10c9a90, 0x3029ffb7, 0x6837569f, 0xe91233b8, 0x0a073871, - 0x8b225d56, 0xd33cf47e, 0x52199159, 0x6301a62e, 0xe224c309, - 0xba3a6a21, 0x3b1f0f06, 0xa7617bf2, 0x26441ed5, 0x7e5ab7fd, - 0xff7fd2da, 0xce67e5ad, 0x4f42808a, 0x175c29a2, 0x96794c85, - 0x756c474c, 0xf449226b, 0xac578b43, 0x2d72ee64, 0x1c6ad913, - 0x9d4fbc34, 0xc551151c, 0x4474703b, 0x4db9f56a, 0xcc9c904d, - 0x94823965, 0x15a75c42, 0x24bf6b35, 0xa59a0e12, 0xfd84a73a, - 0x7ca1c21d, 0x9fb4c9d4, 0x1e91acf3, 0x468f05db, 0xc7aa60fc, - 0xf6b2578b, 0x779732ac, 0x2f899b84, 0xaeacfea3, 0x32d28a57, - 0xb3f7ef70, 0xebe94658, 0x6acc237f, 0x5bd41408, 0xdaf1712f, - 0x82efd807, 0x03cabd20, 0xe0dfb6e9, 0x61fad3ce, 0x39e47ae6, - 0xb8c11fc1, 0x89d928b6, 0x08fc4d91, 0x50e2e4b9, 0xd1c7819e, - 0xb36f0b10, 0x324a6e37, 0x6a54c71f, 0xeb71a238, 0xda69954f, - 0x5b4cf068, 0x03525940, 0x82773c67, 0x616237ae, 0xe0475289, - 0xb859fba1, 0x397c9e86, 0x0864a9f1, 0x8941ccd6, 0xd15f65fe, - 0x507a00d9, 0xcc04742d, 0x4d21110a, 0x153fb822, 0x941add05, - 0xa502ea72, 0x24278f55, 0x7c39267d, 0xfd1c435a, 0x1e094893, - 0x9f2c2db4, 0xc732849c, 0x4617e1bb, 0x770fd6cc, 0xf62ab3eb, - 0xae341ac3, 0x2f117fe4, 0x6b650fdf, 0xea406af8, 0xb25ec3d0, - 0x337ba6f7, 0x02639180, 0x8346f4a7, 0xdb585d8f, 0x5a7d38a8, - 0xb9683361, 0x384d5646, 0x6053ff6e, 0xe1769a49, 0xd06ead3e, - 0x514bc819, 0x09556131, 0x88700416, 0x140e70e2, 0x952b15c5, - 0xcd35bced, 0x4c10d9ca, 0x7d08eebd, 0xfc2d8b9a, 0xa43322b2, - 0x25164795, 0xc6034c5c, 0x4726297b, 0x1f388053, 0x9e1de574, - 0xaf05d203, 0x2e20b724, 0x763e1e0c, 0xf71b7b2b, 0x95b3f1a5, - 0x14969482, 0x4c883daa, 0xcdad588d, 0xfcb56ffa, 0x7d900add, - 0x258ea3f5, 0xa4abc6d2, 0x47becd1b, 0xc69ba83c, 0x9e850114, - 0x1fa06433, 0x2eb85344, 0xaf9d3663, 0xf7839f4b, 0x76a6fa6c, - 0xead88e98, 0x6bfdebbf, 0x33e34297, 0xb2c627b0, 0x83de10c7, - 0x02fb75e0, 0x5ae5dcc8, 0xdbc0b9ef, 0x38d5b226, 0xb9f0d701, - 0xe1ee7e29, 0x60cb1b0e, 0x51d32c79, 0xd0f6495e, 0x88e8e076, - 0x09cd8551}, - {0x00000000, 0x9b73ead4, 0xed96d3e9, 0x76e5393d, 0x005ca193, - 0x9b2f4b47, 0xedca727a, 0x76b998ae, 0x00b94326, 0x9bcaa9f2, - 0xed2f90cf, 0x765c7a1b, 0x00e5e2b5, 0x9b960861, 0xed73315c, - 0x7600db88, 0x0172864c, 0x9a016c98, 0xece455a5, 0x7797bf71, - 0x012e27df, 0x9a5dcd0b, 0xecb8f436, 0x77cb1ee2, 0x01cbc56a, - 0x9ab82fbe, 0xec5d1683, 0x772efc57, 0x019764f9, 0x9ae48e2d, - 0xec01b710, 0x77725dc4, 0x02e50c98, 0x9996e64c, 0xef73df71, - 0x740035a5, 0x02b9ad0b, 0x99ca47df, 0xef2f7ee2, 0x745c9436, - 0x025c4fbe, 0x992fa56a, 0xefca9c57, 0x74b97683, 0x0200ee2d, - 0x997304f9, 0xef963dc4, 0x74e5d710, 0x03978ad4, 0x98e46000, - 0xee01593d, 0x7572b3e9, 0x03cb2b47, 0x98b8c193, 0xee5df8ae, - 0x752e127a, 0x032ec9f2, 0x985d2326, 0xeeb81a1b, 0x75cbf0cf, - 0x03726861, 0x980182b5, 0xeee4bb88, 0x7597515c, 0x05ca1930, - 0x9eb9f3e4, 0xe85ccad9, 0x732f200d, 0x0596b8a3, 0x9ee55277, - 0xe8006b4a, 0x7373819e, 0x05735a16, 0x9e00b0c2, 0xe8e589ff, - 0x7396632b, 0x052ffb85, 0x9e5c1151, 0xe8b9286c, 0x73cac2b8, - 0x04b89f7c, 0x9fcb75a8, 0xe92e4c95, 0x725da641, 0x04e43eef, - 0x9f97d43b, 0xe972ed06, 0x720107d2, 0x0401dc5a, 0x9f72368e, - 0xe9970fb3, 0x72e4e567, 0x045d7dc9, 0x9f2e971d, 0xe9cbae20, - 0x72b844f4, 0x072f15a8, 0x9c5cff7c, 0xeab9c641, 0x71ca2c95, - 0x0773b43b, 0x9c005eef, 0xeae567d2, 0x71968d06, 0x0796568e, - 0x9ce5bc5a, 0xea008567, 0x71736fb3, 0x07caf71d, 0x9cb91dc9, - 0xea5c24f4, 0x712fce20, 0x065d93e4, 0x9d2e7930, 0xebcb400d, - 0x70b8aad9, 0x06013277, 0x9d72d8a3, 0xeb97e19e, 0x70e40b4a, - 0x06e4d0c2, 0x9d973a16, 0xeb72032b, 0x7001e9ff, 0x06b87151, - 0x9dcb9b85, 0xeb2ea2b8, 0x705d486c, 0x0b943260, 0x90e7d8b4, - 0xe602e189, 0x7d710b5d, 0x0bc893f3, 0x90bb7927, 0xe65e401a, - 0x7d2daace, 0x0b2d7146, 0x905e9b92, 0xe6bba2af, 0x7dc8487b, - 0x0b71d0d5, 0x90023a01, 0xe6e7033c, 0x7d94e9e8, 0x0ae6b42c, - 0x91955ef8, 0xe77067c5, 0x7c038d11, 0x0aba15bf, 0x91c9ff6b, - 0xe72cc656, 0x7c5f2c82, 0x0a5ff70a, 0x912c1dde, 0xe7c924e3, - 0x7cbace37, 0x0a035699, 0x9170bc4d, 0xe7958570, 0x7ce66fa4, - 0x09713ef8, 0x9202d42c, 0xe4e7ed11, 0x7f9407c5, 0x092d9f6b, - 0x925e75bf, 0xe4bb4c82, 0x7fc8a656, 0x09c87dde, 0x92bb970a, - 0xe45eae37, 0x7f2d44e3, 0x0994dc4d, 0x92e73699, 0xe4020fa4, - 0x7f71e570, 0x0803b8b4, 0x93705260, 0xe5956b5d, 0x7ee68189, - 0x085f1927, 0x932cf3f3, 0xe5c9cace, 0x7eba201a, 0x08bafb92, - 0x93c91146, 0xe52c287b, 0x7e5fc2af, 0x08e65a01, 0x9395b0d5, - 0xe57089e8, 0x7e03633c, 0x0e5e2b50, 0x952dc184, 0xe3c8f8b9, - 0x78bb126d, 0x0e028ac3, 0x95716017, 0xe394592a, 0x78e7b3fe, - 0x0ee76876, 0x959482a2, 0xe371bb9f, 0x7802514b, 0x0ebbc9e5, - 0x95c82331, 0xe32d1a0c, 0x785ef0d8, 0x0f2cad1c, 0x945f47c8, - 0xe2ba7ef5, 0x79c99421, 0x0f700c8f, 0x9403e65b, 0xe2e6df66, - 0x799535b2, 0x0f95ee3a, 0x94e604ee, 0xe2033dd3, 0x7970d707, - 0x0fc94fa9, 0x94baa57d, 0xe25f9c40, 0x792c7694, 0x0cbb27c8, - 0x97c8cd1c, 0xe12df421, 0x7a5e1ef5, 0x0ce7865b, 0x97946c8f, - 0xe17155b2, 0x7a02bf66, 0x0c0264ee, 0x97718e3a, 0xe194b707, - 0x7ae75dd3, 0x0c5ec57d, 0x972d2fa9, 0xe1c81694, 0x7abbfc40, - 0x0dc9a184, 0x96ba4b50, 0xe05f726d, 0x7b2c98b9, 0x0d950017, - 0x96e6eac3, 0xe003d3fe, 0x7b70392a, 0x0d70e2a2, 0x96030876, - 0xe0e6314b, 0x7b95db9f, 0x0d2c4331, 0x965fa9e5, 0xe0ba90d8, - 0x7bc97a0c}, - {0x00000000, 0x172864c0, 0x2e50c980, 0x3978ad40, 0x5ca19300, - 0x4b89f7c0, 0x72f15a80, 0x65d93e40, 0xb9432600, 0xae6b42c0, - 0x9713ef80, 0x803b8b40, 0xe5e2b500, 0xf2cad1c0, 0xcbb27c80, - 0xdc9a1840, 0xa9f74a41, 0xbedf2e81, 0x87a783c1, 0x908fe701, - 0xf556d941, 0xe27ebd81, 0xdb0610c1, 0xcc2e7401, 0x10b46c41, - 0x079c0881, 0x3ee4a5c1, 0x29ccc101, 0x4c15ff41, 0x5b3d9b81, - 0x624536c1, 0x756d5201, 0x889f92c3, 0x9fb7f603, 0xa6cf5b43, - 0xb1e73f83, 0xd43e01c3, 0xc3166503, 0xfa6ec843, 0xed46ac83, - 0x31dcb4c3, 0x26f4d003, 0x1f8c7d43, 0x08a41983, 0x6d7d27c3, - 0x7a554303, 0x432dee43, 0x54058a83, 0x2168d882, 0x3640bc42, - 0x0f381102, 0x181075c2, 0x7dc94b82, 0x6ae12f42, 0x53998202, - 0x44b1e6c2, 0x982bfe82, 0x8f039a42, 0xb67b3702, 0xa15353c2, - 0xc48a6d82, 0xd3a20942, 0xeadaa402, 0xfdf2c0c2, 0xca4e23c7, - 0xdd664707, 0xe41eea47, 0xf3368e87, 0x96efb0c7, 0x81c7d407, - 0xb8bf7947, 0xaf971d87, 0x730d05c7, 0x64256107, 0x5d5dcc47, - 0x4a75a887, 0x2fac96c7, 0x3884f207, 0x01fc5f47, 0x16d43b87, - 0x63b96986, 0x74910d46, 0x4de9a006, 0x5ac1c4c6, 0x3f18fa86, - 0x28309e46, 0x11483306, 0x066057c6, 0xdafa4f86, 0xcdd22b46, - 0xf4aa8606, 0xe382e2c6, 0x865bdc86, 0x9173b846, 0xa80b1506, - 0xbf2371c6, 0x42d1b104, 0x55f9d5c4, 0x6c817884, 0x7ba91c44, - 0x1e702204, 0x095846c4, 0x3020eb84, 0x27088f44, 0xfb929704, - 0xecbaf3c4, 0xd5c25e84, 0xc2ea3a44, 0xa7330404, 0xb01b60c4, - 0x8963cd84, 0x9e4ba944, 0xeb26fb45, 0xfc0e9f85, 0xc57632c5, - 0xd25e5605, 0xb7876845, 0xa0af0c85, 0x99d7a1c5, 0x8effc505, - 0x5265dd45, 0x454db985, 0x7c3514c5, 0x6b1d7005, 0x0ec44e45, - 0x19ec2a85, 0x209487c5, 0x37bce305, 0x4fed41cf, 0x58c5250f, - 0x61bd884f, 0x7695ec8f, 0x134cd2cf, 0x0464b60f, 0x3d1c1b4f, - 0x2a347f8f, 0xf6ae67cf, 0xe186030f, 0xd8feae4f, 0xcfd6ca8f, - 0xaa0ff4cf, 0xbd27900f, 0x845f3d4f, 0x9377598f, 0xe61a0b8e, - 0xf1326f4e, 0xc84ac20e, 0xdf62a6ce, 0xbabb988e, 0xad93fc4e, - 0x94eb510e, 0x83c335ce, 0x5f592d8e, 0x4871494e, 0x7109e40e, - 0x662180ce, 0x03f8be8e, 0x14d0da4e, 0x2da8770e, 0x3a8013ce, - 0xc772d30c, 0xd05ab7cc, 0xe9221a8c, 0xfe0a7e4c, 0x9bd3400c, - 0x8cfb24cc, 0xb583898c, 0xa2abed4c, 0x7e31f50c, 0x691991cc, - 0x50613c8c, 0x4749584c, 0x2290660c, 0x35b802cc, 0x0cc0af8c, - 0x1be8cb4c, 0x6e85994d, 0x79adfd8d, 0x40d550cd, 0x57fd340d, - 0x32240a4d, 0x250c6e8d, 0x1c74c3cd, 0x0b5ca70d, 0xd7c6bf4d, - 0xc0eedb8d, 0xf99676cd, 0xeebe120d, 0x8b672c4d, 0x9c4f488d, - 0xa537e5cd, 0xb21f810d, 0x85a36208, 0x928b06c8, 0xabf3ab88, - 0xbcdbcf48, 0xd902f108, 0xce2a95c8, 0xf7523888, 0xe07a5c48, - 0x3ce04408, 0x2bc820c8, 0x12b08d88, 0x0598e948, 0x6041d708, - 0x7769b3c8, 0x4e111e88, 0x59397a48, 0x2c542849, 0x3b7c4c89, - 0x0204e1c9, 0x152c8509, 0x70f5bb49, 0x67dddf89, 0x5ea572c9, - 0x498d1609, 0x95170e49, 0x823f6a89, 0xbb47c7c9, 0xac6fa309, - 0xc9b69d49, 0xde9ef989, 0xe7e654c9, 0xf0ce3009, 0x0d3cf0cb, - 0x1a14940b, 0x236c394b, 0x34445d8b, 0x519d63cb, 0x46b5070b, - 0x7fcdaa4b, 0x68e5ce8b, 0xb47fd6cb, 0xa357b20b, 0x9a2f1f4b, - 0x8d077b8b, 0xe8de45cb, 0xfff6210b, 0xc68e8c4b, 0xd1a6e88b, - 0xa4cbba8a, 0xb3e3de4a, 0x8a9b730a, 0x9db317ca, 0xf86a298a, - 0xef424d4a, 0xd63ae00a, 0xc11284ca, 0x1d889c8a, 0x0aa0f84a, - 0x33d8550a, 0x24f031ca, 0x41290f8a, 0x56016b4a, 0x6f79c60a, - 0x7851a2ca}, - {0x00000000, 0x9fda839e, 0xe4c4017d, 0x7b1e82e3, 0x12f904bb, - 0x8d238725, 0xf63d05c6, 0x69e78658, 0x25f20976, 0xba288ae8, - 0xc136080b, 0x5eec8b95, 0x370b0dcd, 0xa8d18e53, 0xd3cf0cb0, - 0x4c158f2e, 0x4be412ec, 0xd43e9172, 0xaf201391, 0x30fa900f, - 0x591d1657, 0xc6c795c9, 0xbdd9172a, 0x220394b4, 0x6e161b9a, - 0xf1cc9804, 0x8ad21ae7, 0x15089979, 0x7cef1f21, 0xe3359cbf, - 0x982b1e5c, 0x07f19dc2, 0x97c825d8, 0x0812a646, 0x730c24a5, - 0xecd6a73b, 0x85312163, 0x1aeba2fd, 0x61f5201e, 0xfe2fa380, - 0xb23a2cae, 0x2de0af30, 0x56fe2dd3, 0xc924ae4d, 0xa0c32815, - 0x3f19ab8b, 0x44072968, 0xdbddaaf6, 0xdc2c3734, 0x43f6b4aa, - 0x38e83649, 0xa732b5d7, 0xced5338f, 0x510fb011, 0x2a1132f2, - 0xb5cbb16c, 0xf9de3e42, 0x6604bddc, 0x1d1a3f3f, 0x82c0bca1, - 0xeb273af9, 0x74fdb967, 0x0fe33b84, 0x9039b81a, 0xf4e14df1, - 0x6b3bce6f, 0x10254c8c, 0x8fffcf12, 0xe618494a, 0x79c2cad4, - 0x02dc4837, 0x9d06cba9, 0xd1134487, 0x4ec9c719, 0x35d745fa, - 0xaa0dc664, 0xc3ea403c, 0x5c30c3a2, 0x272e4141, 0xb8f4c2df, - 0xbf055f1d, 0x20dfdc83, 0x5bc15e60, 0xc41bddfe, 0xadfc5ba6, - 0x3226d838, 0x49385adb, 0xd6e2d945, 0x9af7566b, 0x052dd5f5, - 0x7e335716, 0xe1e9d488, 0x880e52d0, 0x17d4d14e, 0x6cca53ad, - 0xf310d033, 0x63296829, 0xfcf3ebb7, 0x87ed6954, 0x1837eaca, - 0x71d06c92, 0xee0aef0c, 0x95146def, 0x0aceee71, 0x46db615f, - 0xd901e2c1, 0xa21f6022, 0x3dc5e3bc, 0x542265e4, 0xcbf8e67a, - 0xb0e66499, 0x2f3ce707, 0x28cd7ac5, 0xb717f95b, 0xcc097bb8, - 0x53d3f826, 0x3a347e7e, 0xa5eefde0, 0xdef07f03, 0x412afc9d, - 0x0d3f73b3, 0x92e5f02d, 0xe9fb72ce, 0x7621f150, 0x1fc67708, - 0x801cf496, 0xfb027675, 0x64d8f5eb, 0x32b39da3, 0xad691e3d, - 0xd6779cde, 0x49ad1f40, 0x204a9918, 0xbf901a86, 0xc48e9865, - 0x5b541bfb, 0x174194d5, 0x889b174b, 0xf38595a8, 0x6c5f1636, - 0x05b8906e, 0x9a6213f0, 0xe17c9113, 0x7ea6128d, 0x79578f4f, - 0xe68d0cd1, 0x9d938e32, 0x02490dac, 0x6bae8bf4, 0xf474086a, - 0x8f6a8a89, 0x10b00917, 0x5ca58639, 0xc37f05a7, 0xb8618744, - 0x27bb04da, 0x4e5c8282, 0xd186011c, 0xaa9883ff, 0x35420061, - 0xa57bb87b, 0x3aa13be5, 0x41bfb906, 0xde653a98, 0xb782bcc0, - 0x28583f5e, 0x5346bdbd, 0xcc9c3e23, 0x8089b10d, 0x1f533293, - 0x644db070, 0xfb9733ee, 0x9270b5b6, 0x0daa3628, 0x76b4b4cb, - 0xe96e3755, 0xee9faa97, 0x71452909, 0x0a5babea, 0x95812874, - 0xfc66ae2c, 0x63bc2db2, 0x18a2af51, 0x87782ccf, 0xcb6da3e1, - 0x54b7207f, 0x2fa9a29c, 0xb0732102, 0xd994a75a, 0x464e24c4, - 0x3d50a627, 0xa28a25b9, 0xc652d052, 0x598853cc, 0x2296d12f, - 0xbd4c52b1, 0xd4abd4e9, 0x4b715777, 0x306fd594, 0xafb5560a, - 0xe3a0d924, 0x7c7a5aba, 0x0764d859, 0x98be5bc7, 0xf159dd9f, - 0x6e835e01, 0x159ddce2, 0x8a475f7c, 0x8db6c2be, 0x126c4120, - 0x6972c3c3, 0xf6a8405d, 0x9f4fc605, 0x0095459b, 0x7b8bc778, - 0xe45144e6, 0xa844cbc8, 0x379e4856, 0x4c80cab5, 0xd35a492b, - 0xbabdcf73, 0x25674ced, 0x5e79ce0e, 0xc1a34d90, 0x519af58a, - 0xce407614, 0xb55ef4f7, 0x2a847769, 0x4363f131, 0xdcb972af, - 0xa7a7f04c, 0x387d73d2, 0x7468fcfc, 0xebb27f62, 0x90acfd81, - 0x0f767e1f, 0x6691f847, 0xf94b7bd9, 0x8255f93a, 0x1d8f7aa4, - 0x1a7ee766, 0x85a464f8, 0xfebae61b, 0x61606585, 0x0887e3dd, - 0x975d6043, 0xec43e2a0, 0x7399613e, 0x3f8cee10, 0xa0566d8e, - 0xdb48ef6d, 0x44926cf3, 0x2d75eaab, 0xb2af6935, 0xc9b1ebd6, - 0x566b6848}, - {0x00000000, 0x65673b46, 0xcace768c, 0xafa94dca, 0x4eedeb59, - 0x2b8ad01f, 0x84239dd5, 0xe144a693, 0x9ddbd6b2, 0xf8bcedf4, - 0x5715a03e, 0x32729b78, 0xd3363deb, 0xb65106ad, 0x19f84b67, - 0x7c9f7021, 0xe0c6ab25, 0x85a19063, 0x2a08dda9, 0x4f6fe6ef, - 0xae2b407c, 0xcb4c7b3a, 0x64e536f0, 0x01820db6, 0x7d1d7d97, - 0x187a46d1, 0xb7d30b1b, 0xd2b4305d, 0x33f096ce, 0x5697ad88, - 0xf93ee042, 0x9c59db04, 0x1afc500b, 0x7f9b6b4d, 0xd0322687, - 0xb5551dc1, 0x5411bb52, 0x31768014, 0x9edfcdde, 0xfbb8f698, - 0x872786b9, 0xe240bdff, 0x4de9f035, 0x288ecb73, 0xc9ca6de0, - 0xacad56a6, 0x03041b6c, 0x6663202a, 0xfa3afb2e, 0x9f5dc068, - 0x30f48da2, 0x5593b6e4, 0xb4d71077, 0xd1b02b31, 0x7e1966fb, - 0x1b7e5dbd, 0x67e12d9c, 0x028616da, 0xad2f5b10, 0xc8486056, - 0x290cc6c5, 0x4c6bfd83, 0xe3c2b049, 0x86a58b0f, 0x35f8a016, - 0x509f9b50, 0xff36d69a, 0x9a51eddc, 0x7b154b4f, 0x1e727009, - 0xb1db3dc3, 0xd4bc0685, 0xa82376a4, 0xcd444de2, 0x62ed0028, - 0x078a3b6e, 0xe6ce9dfd, 0x83a9a6bb, 0x2c00eb71, 0x4967d037, - 0xd53e0b33, 0xb0593075, 0x1ff07dbf, 0x7a9746f9, 0x9bd3e06a, - 0xfeb4db2c, 0x511d96e6, 0x347aada0, 0x48e5dd81, 0x2d82e6c7, - 0x822bab0d, 0xe74c904b, 0x060836d8, 0x636f0d9e, 0xccc64054, - 0xa9a17b12, 0x2f04f01d, 0x4a63cb5b, 0xe5ca8691, 0x80adbdd7, - 0x61e91b44, 0x048e2002, 0xab276dc8, 0xce40568e, 0xb2df26af, - 0xd7b81de9, 0x78115023, 0x1d766b65, 0xfc32cdf6, 0x9955f6b0, - 0x36fcbb7a, 0x539b803c, 0xcfc25b38, 0xaaa5607e, 0x050c2db4, - 0x606b16f2, 0x812fb061, 0xe4488b27, 0x4be1c6ed, 0x2e86fdab, - 0x52198d8a, 0x377eb6cc, 0x98d7fb06, 0xfdb0c040, 0x1cf466d3, - 0x79935d95, 0xd63a105f, 0xb35d2b19, 0x6bf1402c, 0x0e967b6a, - 0xa13f36a0, 0xc4580de6, 0x251cab75, 0x407b9033, 0xefd2ddf9, - 0x8ab5e6bf, 0xf62a969e, 0x934dadd8, 0x3ce4e012, 0x5983db54, - 0xb8c77dc7, 0xdda04681, 0x72090b4b, 0x176e300d, 0x8b37eb09, - 0xee50d04f, 0x41f99d85, 0x249ea6c3, 0xc5da0050, 0xa0bd3b16, - 0x0f1476dc, 0x6a734d9a, 0x16ec3dbb, 0x738b06fd, 0xdc224b37, - 0xb9457071, 0x5801d6e2, 0x3d66eda4, 0x92cfa06e, 0xf7a89b28, - 0x710d1027, 0x146a2b61, 0xbbc366ab, 0xdea45ded, 0x3fe0fb7e, - 0x5a87c038, 0xf52e8df2, 0x9049b6b4, 0xecd6c695, 0x89b1fdd3, - 0x2618b019, 0x437f8b5f, 0xa23b2dcc, 0xc75c168a, 0x68f55b40, - 0x0d926006, 0x91cbbb02, 0xf4ac8044, 0x5b05cd8e, 0x3e62f6c8, - 0xdf26505b, 0xba416b1d, 0x15e826d7, 0x708f1d91, 0x0c106db0, - 0x697756f6, 0xc6de1b3c, 0xa3b9207a, 0x42fd86e9, 0x279abdaf, - 0x8833f065, 0xed54cb23, 0x5e09e03a, 0x3b6edb7c, 0x94c796b6, - 0xf1a0adf0, 0x10e40b63, 0x75833025, 0xda2a7def, 0xbf4d46a9, - 0xc3d23688, 0xa6b50dce, 0x091c4004, 0x6c7b7b42, 0x8d3fddd1, - 0xe858e697, 0x47f1ab5d, 0x2296901b, 0xbecf4b1f, 0xdba87059, - 0x74013d93, 0x116606d5, 0xf022a046, 0x95459b00, 0x3aecd6ca, - 0x5f8bed8c, 0x23149dad, 0x4673a6eb, 0xe9daeb21, 0x8cbdd067, - 0x6df976f4, 0x089e4db2, 0xa7370078, 0xc2503b3e, 0x44f5b031, - 0x21928b77, 0x8e3bc6bd, 0xeb5cfdfb, 0x0a185b68, 0x6f7f602e, - 0xc0d62de4, 0xa5b116a2, 0xd92e6683, 0xbc495dc5, 0x13e0100f, - 0x76872b49, 0x97c38dda, 0xf2a4b69c, 0x5d0dfb56, 0x386ac010, - 0xa4331b14, 0xc1542052, 0x6efd6d98, 0x0b9a56de, 0xeadef04d, - 0x8fb9cb0b, 0x201086c1, 0x4577bd87, 0x39e8cda6, 0x5c8ff6e0, - 0xf326bb2a, 0x9641806c, 0x770526ff, 0x12621db9, 0xbdcb5073, - 0xd8ac6b35}, - {0x00000000, 0xd7e28058, 0x74b406f1, 0xa35686a9, 0xe9680de2, - 0x3e8a8dba, 0x9ddc0b13, 0x4a3e8b4b, 0x09a11d85, 0xde439ddd, - 0x7d151b74, 0xaaf79b2c, 0xe0c91067, 0x372b903f, 0x947d1696, - 0x439f96ce, 0x13423b0a, 0xc4a0bb52, 0x67f63dfb, 0xb014bda3, - 0xfa2a36e8, 0x2dc8b6b0, 0x8e9e3019, 0x597cb041, 0x1ae3268f, - 0xcd01a6d7, 0x6e57207e, 0xb9b5a026, 0xf38b2b6d, 0x2469ab35, - 0x873f2d9c, 0x50ddadc4, 0x26847614, 0xf166f64c, 0x523070e5, - 0x85d2f0bd, 0xcfec7bf6, 0x180efbae, 0xbb587d07, 0x6cbafd5f, - 0x2f256b91, 0xf8c7ebc9, 0x5b916d60, 0x8c73ed38, 0xc64d6673, - 0x11afe62b, 0xb2f96082, 0x651be0da, 0x35c64d1e, 0xe224cd46, - 0x41724bef, 0x9690cbb7, 0xdcae40fc, 0x0b4cc0a4, 0xa81a460d, - 0x7ff8c655, 0x3c67509b, 0xeb85d0c3, 0x48d3566a, 0x9f31d632, - 0xd50f5d79, 0x02eddd21, 0xa1bb5b88, 0x7659dbd0, 0x4d08ec28, - 0x9aea6c70, 0x39bcead9, 0xee5e6a81, 0xa460e1ca, 0x73826192, - 0xd0d4e73b, 0x07366763, 0x44a9f1ad, 0x934b71f5, 0x301df75c, - 0xe7ff7704, 0xadc1fc4f, 0x7a237c17, 0xd975fabe, 0x0e977ae6, - 0x5e4ad722, 0x89a8577a, 0x2afed1d3, 0xfd1c518b, 0xb722dac0, - 0x60c05a98, 0xc396dc31, 0x14745c69, 0x57ebcaa7, 0x80094aff, - 0x235fcc56, 0xf4bd4c0e, 0xbe83c745, 0x6961471d, 0xca37c1b4, - 0x1dd541ec, 0x6b8c9a3c, 0xbc6e1a64, 0x1f389ccd, 0xc8da1c95, - 0x82e497de, 0x55061786, 0xf650912f, 0x21b21177, 0x622d87b9, - 0xb5cf07e1, 0x16998148, 0xc17b0110, 0x8b458a5b, 0x5ca70a03, - 0xfff18caa, 0x28130cf2, 0x78cea136, 0xaf2c216e, 0x0c7aa7c7, - 0xdb98279f, 0x91a6acd4, 0x46442c8c, 0xe512aa25, 0x32f02a7d, - 0x716fbcb3, 0xa68d3ceb, 0x05dbba42, 0xd2393a1a, 0x9807b151, - 0x4fe53109, 0xecb3b7a0, 0x3b5137f8, 0x9a11d850, 0x4df35808, - 0xeea5dea1, 0x39475ef9, 0x7379d5b2, 0xa49b55ea, 0x07cdd343, - 0xd02f531b, 0x93b0c5d5, 0x4452458d, 0xe704c324, 0x30e6437c, - 0x7ad8c837, 0xad3a486f, 0x0e6ccec6, 0xd98e4e9e, 0x8953e35a, - 0x5eb16302, 0xfde7e5ab, 0x2a0565f3, 0x603beeb8, 0xb7d96ee0, - 0x148fe849, 0xc36d6811, 0x80f2fedf, 0x57107e87, 0xf446f82e, - 0x23a47876, 0x699af33d, 0xbe787365, 0x1d2ef5cc, 0xcacc7594, - 0xbc95ae44, 0x6b772e1c, 0xc821a8b5, 0x1fc328ed, 0x55fda3a6, - 0x821f23fe, 0x2149a557, 0xf6ab250f, 0xb534b3c1, 0x62d63399, - 0xc180b530, 0x16623568, 0x5c5cbe23, 0x8bbe3e7b, 0x28e8b8d2, - 0xff0a388a, 0xafd7954e, 0x78351516, 0xdb6393bf, 0x0c8113e7, - 0x46bf98ac, 0x915d18f4, 0x320b9e5d, 0xe5e91e05, 0xa67688cb, - 0x71940893, 0xd2c28e3a, 0x05200e62, 0x4f1e8529, 0x98fc0571, - 0x3baa83d8, 0xec480380, 0xd7193478, 0x00fbb420, 0xa3ad3289, - 0x744fb2d1, 0x3e71399a, 0xe993b9c2, 0x4ac53f6b, 0x9d27bf33, - 0xdeb829fd, 0x095aa9a5, 0xaa0c2f0c, 0x7deeaf54, 0x37d0241f, - 0xe032a447, 0x436422ee, 0x9486a2b6, 0xc45b0f72, 0x13b98f2a, - 0xb0ef0983, 0x670d89db, 0x2d330290, 0xfad182c8, 0x59870461, - 0x8e658439, 0xcdfa12f7, 0x1a1892af, 0xb94e1406, 0x6eac945e, - 0x24921f15, 0xf3709f4d, 0x502619e4, 0x87c499bc, 0xf19d426c, - 0x267fc234, 0x8529449d, 0x52cbc4c5, 0x18f54f8e, 0xcf17cfd6, - 0x6c41497f, 0xbba3c927, 0xf83c5fe9, 0x2fdedfb1, 0x8c885918, - 0x5b6ad940, 0x1154520b, 0xc6b6d253, 0x65e054fa, 0xb202d4a2, - 0xe2df7966, 0x353df93e, 0x966b7f97, 0x4189ffcf, 0x0bb77484, - 0xdc55f4dc, 0x7f037275, 0xa8e1f22d, 0xeb7e64e3, 0x3c9ce4bb, - 0x9fca6212, 0x4828e24a, 0x02166901, 0xd5f4e959, 0x76a26ff0, - 0xa140efa8}, - {0x00000000, 0xef52b6e1, 0x05d46b83, 0xea86dd62, 0x0ba8d706, - 0xe4fa61e7, 0x0e7cbc85, 0xe12e0a64, 0x1751ae0c, 0xf80318ed, - 0x1285c58f, 0xfdd7736e, 0x1cf9790a, 0xf3abcfeb, 0x192d1289, - 0xf67fa468, 0x2ea35c18, 0xc1f1eaf9, 0x2b77379b, 0xc425817a, - 0x250b8b1e, 0xca593dff, 0x20dfe09d, 0xcf8d567c, 0x39f2f214, - 0xd6a044f5, 0x3c269997, 0xd3742f76, 0x325a2512, 0xdd0893f3, - 0x378e4e91, 0xd8dcf870, 0x5d46b830, 0xb2140ed1, 0x5892d3b3, - 0xb7c06552, 0x56ee6f36, 0xb9bcd9d7, 0x533a04b5, 0xbc68b254, - 0x4a17163c, 0xa545a0dd, 0x4fc37dbf, 0xa091cb5e, 0x41bfc13a, - 0xaeed77db, 0x446baab9, 0xab391c58, 0x73e5e428, 0x9cb752c9, - 0x76318fab, 0x9963394a, 0x784d332e, 0x971f85cf, 0x7d9958ad, - 0x92cbee4c, 0x64b44a24, 0x8be6fcc5, 0x616021a7, 0x8e329746, - 0x6f1c9d22, 0x804e2bc3, 0x6ac8f6a1, 0x859a4040, 0xba8d7060, - 0x55dfc681, 0xbf591be3, 0x500bad02, 0xb125a766, 0x5e771187, - 0xb4f1cce5, 0x5ba37a04, 0xaddcde6c, 0x428e688d, 0xa808b5ef, - 0x475a030e, 0xa674096a, 0x4926bf8b, 0xa3a062e9, 0x4cf2d408, - 0x942e2c78, 0x7b7c9a99, 0x91fa47fb, 0x7ea8f11a, 0x9f86fb7e, - 0x70d44d9f, 0x9a5290fd, 0x7500261c, 0x837f8274, 0x6c2d3495, - 0x86abe9f7, 0x69f95f16, 0x88d75572, 0x6785e393, 0x8d033ef1, - 0x62518810, 0xe7cbc850, 0x08997eb1, 0xe21fa3d3, 0x0d4d1532, - 0xec631f56, 0x0331a9b7, 0xe9b774d5, 0x06e5c234, 0xf09a665c, - 0x1fc8d0bd, 0xf54e0ddf, 0x1a1cbb3e, 0xfb32b15a, 0x146007bb, - 0xfee6dad9, 0x11b46c38, 0xc9689448, 0x263a22a9, 0xccbcffcb, - 0x23ee492a, 0xc2c0434e, 0x2d92f5af, 0xc71428cd, 0x28469e2c, - 0xde393a44, 0x316b8ca5, 0xdbed51c7, 0x34bfe726, 0xd591ed42, - 0x3ac35ba3, 0xd04586c1, 0x3f173020, 0xae6be681, 0x41395060, - 0xabbf8d02, 0x44ed3be3, 0xa5c33187, 0x4a918766, 0xa0175a04, - 0x4f45ece5, 0xb93a488d, 0x5668fe6c, 0xbcee230e, 0x53bc95ef, - 0xb2929f8b, 0x5dc0296a, 0xb746f408, 0x581442e9, 0x80c8ba99, - 0x6f9a0c78, 0x851cd11a, 0x6a4e67fb, 0x8b606d9f, 0x6432db7e, - 0x8eb4061c, 0x61e6b0fd, 0x97991495, 0x78cba274, 0x924d7f16, - 0x7d1fc9f7, 0x9c31c393, 0x73637572, 0x99e5a810, 0x76b71ef1, - 0xf32d5eb1, 0x1c7fe850, 0xf6f93532, 0x19ab83d3, 0xf88589b7, - 0x17d73f56, 0xfd51e234, 0x120354d5, 0xe47cf0bd, 0x0b2e465c, - 0xe1a89b3e, 0x0efa2ddf, 0xefd427bb, 0x0086915a, 0xea004c38, - 0x0552fad9, 0xdd8e02a9, 0x32dcb448, 0xd85a692a, 0x3708dfcb, - 0xd626d5af, 0x3974634e, 0xd3f2be2c, 0x3ca008cd, 0xcadfaca5, - 0x258d1a44, 0xcf0bc726, 0x205971c7, 0xc1777ba3, 0x2e25cd42, - 0xc4a31020, 0x2bf1a6c1, 0x14e696e1, 0xfbb42000, 0x1132fd62, - 0xfe604b83, 0x1f4e41e7, 0xf01cf706, 0x1a9a2a64, 0xf5c89c85, - 0x03b738ed, 0xece58e0c, 0x0663536e, 0xe931e58f, 0x081fefeb, - 0xe74d590a, 0x0dcb8468, 0xe2993289, 0x3a45caf9, 0xd5177c18, - 0x3f91a17a, 0xd0c3179b, 0x31ed1dff, 0xdebfab1e, 0x3439767c, - 0xdb6bc09d, 0x2d1464f5, 0xc246d214, 0x28c00f76, 0xc792b997, - 0x26bcb3f3, 0xc9ee0512, 0x2368d870, 0xcc3a6e91, 0x49a02ed1, - 0xa6f29830, 0x4c744552, 0xa326f3b3, 0x4208f9d7, 0xad5a4f36, - 0x47dc9254, 0xa88e24b5, 0x5ef180dd, 0xb1a3363c, 0x5b25eb5e, - 0xb4775dbf, 0x555957db, 0xba0be13a, 0x508d3c58, 0xbfdf8ab9, - 0x670372c9, 0x8851c428, 0x62d7194a, 0x8d85afab, 0x6caba5cf, - 0x83f9132e, 0x697fce4c, 0x862d78ad, 0x7052dcc5, 0x9f006a24, - 0x7586b746, 0x9ad401a7, 0x7bfa0bc3, 0x94a8bd22, 0x7e2e6040, - 0x917cd6a1}, - {0x00000000, 0x87a6cb43, 0xd43c90c7, 0x539a5b84, 0x730827cf, - 0xf4aeec8c, 0xa734b708, 0x20927c4b, 0xe6104f9e, 0x61b684dd, - 0x322cdf59, 0xb58a141a, 0x95186851, 0x12bea312, 0x4124f896, - 0xc68233d5, 0x1751997d, 0x90f7523e, 0xc36d09ba, 0x44cbc2f9, - 0x6459beb2, 0xe3ff75f1, 0xb0652e75, 0x37c3e536, 0xf141d6e3, - 0x76e71da0, 0x257d4624, 0xa2db8d67, 0x8249f12c, 0x05ef3a6f, - 0x567561eb, 0xd1d3aaa8, 0x2ea332fa, 0xa905f9b9, 0xfa9fa23d, - 0x7d39697e, 0x5dab1535, 0xda0dde76, 0x899785f2, 0x0e314eb1, - 0xc8b37d64, 0x4f15b627, 0x1c8feda3, 0x9b2926e0, 0xbbbb5aab, - 0x3c1d91e8, 0x6f87ca6c, 0xe821012f, 0x39f2ab87, 0xbe5460c4, - 0xedce3b40, 0x6a68f003, 0x4afa8c48, 0xcd5c470b, 0x9ec61c8f, - 0x1960d7cc, 0xdfe2e419, 0x58442f5a, 0x0bde74de, 0x8c78bf9d, - 0xaceac3d6, 0x2b4c0895, 0x78d65311, 0xff709852, 0x5d4665f4, - 0xdae0aeb7, 0x897af533, 0x0edc3e70, 0x2e4e423b, 0xa9e88978, - 0xfa72d2fc, 0x7dd419bf, 0xbb562a6a, 0x3cf0e129, 0x6f6abaad, - 0xe8cc71ee, 0xc85e0da5, 0x4ff8c6e6, 0x1c629d62, 0x9bc45621, - 0x4a17fc89, 0xcdb137ca, 0x9e2b6c4e, 0x198da70d, 0x391fdb46, - 0xbeb91005, 0xed234b81, 0x6a8580c2, 0xac07b317, 0x2ba17854, - 0x783b23d0, 0xff9de893, 0xdf0f94d8, 0x58a95f9b, 0x0b33041f, - 0x8c95cf5c, 0x73e5570e, 0xf4439c4d, 0xa7d9c7c9, 0x207f0c8a, - 0x00ed70c1, 0x874bbb82, 0xd4d1e006, 0x53772b45, 0x95f51890, - 0x1253d3d3, 0x41c98857, 0xc66f4314, 0xe6fd3f5f, 0x615bf41c, - 0x32c1af98, 0xb56764db, 0x64b4ce73, 0xe3120530, 0xb0885eb4, - 0x372e95f7, 0x17bce9bc, 0x901a22ff, 0xc380797b, 0x4426b238, - 0x82a481ed, 0x05024aae, 0x5698112a, 0xd13eda69, 0xf1aca622, - 0x760a6d61, 0x259036e5, 0xa236fda6, 0xba8ccbe8, 0x3d2a00ab, - 0x6eb05b2f, 0xe916906c, 0xc984ec27, 0x4e222764, 0x1db87ce0, - 0x9a1eb7a3, 0x5c9c8476, 0xdb3a4f35, 0x88a014b1, 0x0f06dff2, - 0x2f94a3b9, 0xa83268fa, 0xfba8337e, 0x7c0ef83d, 0xaddd5295, - 0x2a7b99d6, 0x79e1c252, 0xfe470911, 0xded5755a, 0x5973be19, - 0x0ae9e59d, 0x8d4f2ede, 0x4bcd1d0b, 0xcc6bd648, 0x9ff18dcc, - 0x1857468f, 0x38c53ac4, 0xbf63f187, 0xecf9aa03, 0x6b5f6140, - 0x942ff912, 0x13893251, 0x401369d5, 0xc7b5a296, 0xe727dedd, - 0x6081159e, 0x331b4e1a, 0xb4bd8559, 0x723fb68c, 0xf5997dcf, - 0xa603264b, 0x21a5ed08, 0x01379143, 0x86915a00, 0xd50b0184, - 0x52adcac7, 0x837e606f, 0x04d8ab2c, 0x5742f0a8, 0xd0e43beb, - 0xf07647a0, 0x77d08ce3, 0x244ad767, 0xa3ec1c24, 0x656e2ff1, - 0xe2c8e4b2, 0xb152bf36, 0x36f47475, 0x1666083e, 0x91c0c37d, - 0xc25a98f9, 0x45fc53ba, 0xe7caae1c, 0x606c655f, 0x33f63edb, - 0xb450f598, 0x94c289d3, 0x13644290, 0x40fe1914, 0xc758d257, - 0x01dae182, 0x867c2ac1, 0xd5e67145, 0x5240ba06, 0x72d2c64d, - 0xf5740d0e, 0xa6ee568a, 0x21489dc9, 0xf09b3761, 0x773dfc22, - 0x24a7a7a6, 0xa3016ce5, 0x839310ae, 0x0435dbed, 0x57af8069, - 0xd0094b2a, 0x168b78ff, 0x912db3bc, 0xc2b7e838, 0x4511237b, - 0x65835f30, 0xe2259473, 0xb1bfcff7, 0x361904b4, 0xc9699ce6, - 0x4ecf57a5, 0x1d550c21, 0x9af3c762, 0xba61bb29, 0x3dc7706a, - 0x6e5d2bee, 0xe9fbe0ad, 0x2f79d378, 0xa8df183b, 0xfb4543bf, - 0x7ce388fc, 0x5c71f4b7, 0xdbd73ff4, 0x884d6470, 0x0febaf33, - 0xde38059b, 0x599eced8, 0x0a04955c, 0x8da25e1f, 0xad302254, - 0x2a96e917, 0x790cb293, 0xfeaa79d0, 0x38284a05, 0xbf8e8146, - 0xec14dac2, 0x6bb21181, 0x4b206dca, 0xcc86a689, 0x9f1cfd0d, - 0x18ba364e}}; - -local const z_word_t FAR crc_braid_big_table[][256] = { - {0x0000000000000000, 0x43cba68700000000, 0xc7903cd400000000, - 0x845b9a5300000000, 0xcf27087300000000, 0x8cecaef400000000, - 0x08b734a700000000, 0x4b7c922000000000, 0x9e4f10e600000000, - 0xdd84b66100000000, 0x59df2c3200000000, 0x1a148ab500000000, - 0x5168189500000000, 0x12a3be1200000000, 0x96f8244100000000, - 0xd53382c600000000, 0x7d99511700000000, 0x3e52f79000000000, - 0xba096dc300000000, 0xf9c2cb4400000000, 0xb2be596400000000, - 0xf175ffe300000000, 0x752e65b000000000, 0x36e5c33700000000, - 0xe3d641f100000000, 0xa01de77600000000, 0x24467d2500000000, - 0x678ddba200000000, 0x2cf1498200000000, 0x6f3aef0500000000, - 0xeb61755600000000, 0xa8aad3d100000000, 0xfa32a32e00000000, - 0xb9f905a900000000, 0x3da29ffa00000000, 0x7e69397d00000000, - 0x3515ab5d00000000, 0x76de0dda00000000, 0xf285978900000000, - 0xb14e310e00000000, 0x647db3c800000000, 0x27b6154f00000000, - 0xa3ed8f1c00000000, 0xe026299b00000000, 0xab5abbbb00000000, - 0xe8911d3c00000000, 0x6cca876f00000000, 0x2f0121e800000000, - 0x87abf23900000000, 0xc46054be00000000, 0x403bceed00000000, - 0x03f0686a00000000, 0x488cfa4a00000000, 0x0b475ccd00000000, - 0x8f1cc69e00000000, 0xccd7601900000000, 0x19e4e2df00000000, - 0x5a2f445800000000, 0xde74de0b00000000, 0x9dbf788c00000000, - 0xd6c3eaac00000000, 0x95084c2b00000000, 0x1153d67800000000, - 0x529870ff00000000, 0xf465465d00000000, 0xb7aee0da00000000, - 0x33f57a8900000000, 0x703edc0e00000000, 0x3b424e2e00000000, - 0x7889e8a900000000, 0xfcd272fa00000000, 0xbf19d47d00000000, - 0x6a2a56bb00000000, 0x29e1f03c00000000, 0xadba6a6f00000000, - 0xee71cce800000000, 0xa50d5ec800000000, 0xe6c6f84f00000000, - 0x629d621c00000000, 0x2156c49b00000000, 0x89fc174a00000000, - 0xca37b1cd00000000, 0x4e6c2b9e00000000, 0x0da78d1900000000, - 0x46db1f3900000000, 0x0510b9be00000000, 0x814b23ed00000000, - 0xc280856a00000000, 0x17b307ac00000000, 0x5478a12b00000000, - 0xd0233b7800000000, 0x93e89dff00000000, 0xd8940fdf00000000, - 0x9b5fa95800000000, 0x1f04330b00000000, 0x5ccf958c00000000, - 0x0e57e57300000000, 0x4d9c43f400000000, 0xc9c7d9a700000000, - 0x8a0c7f2000000000, 0xc170ed0000000000, 0x82bb4b8700000000, - 0x06e0d1d400000000, 0x452b775300000000, 0x9018f59500000000, - 0xd3d3531200000000, 0x5788c94100000000, 0x14436fc600000000, - 0x5f3ffde600000000, 0x1cf45b6100000000, 0x98afc13200000000, - 0xdb6467b500000000, 0x73ceb46400000000, 0x300512e300000000, - 0xb45e88b000000000, 0xf7952e3700000000, 0xbce9bc1700000000, - 0xff221a9000000000, 0x7b7980c300000000, 0x38b2264400000000, - 0xed81a48200000000, 0xae4a020500000000, 0x2a11985600000000, - 0x69da3ed100000000, 0x22a6acf100000000, 0x616d0a7600000000, - 0xe536902500000000, 0xa6fd36a200000000, 0xe8cb8cba00000000, - 0xab002a3d00000000, 0x2f5bb06e00000000, 0x6c9016e900000000, - 0x27ec84c900000000, 0x6427224e00000000, 0xe07cb81d00000000, - 0xa3b71e9a00000000, 0x76849c5c00000000, 0x354f3adb00000000, - 0xb114a08800000000, 0xf2df060f00000000, 0xb9a3942f00000000, - 0xfa6832a800000000, 0x7e33a8fb00000000, 0x3df80e7c00000000, - 0x9552ddad00000000, 0xd6997b2a00000000, 0x52c2e17900000000, - 0x110947fe00000000, 0x5a75d5de00000000, 0x19be735900000000, - 0x9de5e90a00000000, 0xde2e4f8d00000000, 0x0b1dcd4b00000000, - 0x48d66bcc00000000, 0xcc8df19f00000000, 0x8f46571800000000, - 0xc43ac53800000000, 0x87f163bf00000000, 0x03aaf9ec00000000, - 0x40615f6b00000000, 0x12f92f9400000000, 0x5132891300000000, - 0xd569134000000000, 0x96a2b5c700000000, 0xddde27e700000000, - 0x9e15816000000000, 0x1a4e1b3300000000, 0x5985bdb400000000, - 0x8cb63f7200000000, 0xcf7d99f500000000, 0x4b2603a600000000, - 0x08eda52100000000, 0x4391370100000000, 0x005a918600000000, - 0x84010bd500000000, 0xc7caad5200000000, 0x6f607e8300000000, - 0x2cabd80400000000, 0xa8f0425700000000, 0xeb3be4d000000000, - 0xa04776f000000000, 0xe38cd07700000000, 0x67d74a2400000000, - 0x241ceca300000000, 0xf12f6e6500000000, 0xb2e4c8e200000000, - 0x36bf52b100000000, 0x7574f43600000000, 0x3e08661600000000, - 0x7dc3c09100000000, 0xf9985ac200000000, 0xba53fc4500000000, - 0x1caecae700000000, 0x5f656c6000000000, 0xdb3ef63300000000, - 0x98f550b400000000, 0xd389c29400000000, 0x9042641300000000, - 0x1419fe4000000000, 0x57d258c700000000, 0x82e1da0100000000, - 0xc12a7c8600000000, 0x4571e6d500000000, 0x06ba405200000000, - 0x4dc6d27200000000, 0x0e0d74f500000000, 0x8a56eea600000000, - 0xc99d482100000000, 0x61379bf000000000, 0x22fc3d7700000000, - 0xa6a7a72400000000, 0xe56c01a300000000, 0xae10938300000000, - 0xeddb350400000000, 0x6980af5700000000, 0x2a4b09d000000000, - 0xff788b1600000000, 0xbcb32d9100000000, 0x38e8b7c200000000, - 0x7b23114500000000, 0x305f836500000000, 0x739425e200000000, - 0xf7cfbfb100000000, 0xb404193600000000, 0xe69c69c900000000, - 0xa557cf4e00000000, 0x210c551d00000000, 0x62c7f39a00000000, - 0x29bb61ba00000000, 0x6a70c73d00000000, 0xee2b5d6e00000000, - 0xade0fbe900000000, 0x78d3792f00000000, 0x3b18dfa800000000, - 0xbf4345fb00000000, 0xfc88e37c00000000, 0xb7f4715c00000000, - 0xf43fd7db00000000, 0x70644d8800000000, 0x33afeb0f00000000, - 0x9b0538de00000000, 0xd8ce9e5900000000, 0x5c95040a00000000, - 0x1f5ea28d00000000, 0x542230ad00000000, 0x17e9962a00000000, - 0x93b20c7900000000, 0xd079aafe00000000, 0x054a283800000000, - 0x46818ebf00000000, 0xc2da14ec00000000, 0x8111b26b00000000, - 0xca6d204b00000000, 0x89a686cc00000000, 0x0dfd1c9f00000000, - 0x4e36ba1800000000}, - {0x0000000000000000, 0xe1b652ef00000000, 0x836bd40500000000, - 0x62dd86ea00000000, 0x06d7a80b00000000, 0xe761fae400000000, - 0x85bc7c0e00000000, 0x640a2ee100000000, 0x0cae511700000000, - 0xed1803f800000000, 0x8fc5851200000000, 0x6e73d7fd00000000, - 0x0a79f91c00000000, 0xebcfabf300000000, 0x89122d1900000000, - 0x68a47ff600000000, 0x185ca32e00000000, 0xf9eaf1c100000000, - 0x9b37772b00000000, 0x7a8125c400000000, 0x1e8b0b2500000000, - 0xff3d59ca00000000, 0x9de0df2000000000, 0x7c568dcf00000000, - 0x14f2f23900000000, 0xf544a0d600000000, 0x9799263c00000000, - 0x762f74d300000000, 0x12255a3200000000, 0xf39308dd00000000, - 0x914e8e3700000000, 0x70f8dcd800000000, 0x30b8465d00000000, - 0xd10e14b200000000, 0xb3d3925800000000, 0x5265c0b700000000, - 0x366fee5600000000, 0xd7d9bcb900000000, 0xb5043a5300000000, - 0x54b268bc00000000, 0x3c16174a00000000, 0xdda045a500000000, - 0xbf7dc34f00000000, 0x5ecb91a000000000, 0x3ac1bf4100000000, - 0xdb77edae00000000, 0xb9aa6b4400000000, 0x581c39ab00000000, - 0x28e4e57300000000, 0xc952b79c00000000, 0xab8f317600000000, - 0x4a39639900000000, 0x2e334d7800000000, 0xcf851f9700000000, - 0xad58997d00000000, 0x4ceecb9200000000, 0x244ab46400000000, - 0xc5fce68b00000000, 0xa721606100000000, 0x4697328e00000000, - 0x229d1c6f00000000, 0xc32b4e8000000000, 0xa1f6c86a00000000, - 0x40409a8500000000, 0x60708dba00000000, 0x81c6df5500000000, - 0xe31b59bf00000000, 0x02ad0b5000000000, 0x66a725b100000000, - 0x8711775e00000000, 0xe5ccf1b400000000, 0x047aa35b00000000, - 0x6cdedcad00000000, 0x8d688e4200000000, 0xefb508a800000000, - 0x0e035a4700000000, 0x6a0974a600000000, 0x8bbf264900000000, - 0xe962a0a300000000, 0x08d4f24c00000000, 0x782c2e9400000000, - 0x999a7c7b00000000, 0xfb47fa9100000000, 0x1af1a87e00000000, - 0x7efb869f00000000, 0x9f4dd47000000000, 0xfd90529a00000000, - 0x1c26007500000000, 0x74827f8300000000, 0x95342d6c00000000, - 0xf7e9ab8600000000, 0x165ff96900000000, 0x7255d78800000000, - 0x93e3856700000000, 0xf13e038d00000000, 0x1088516200000000, - 0x50c8cbe700000000, 0xb17e990800000000, 0xd3a31fe200000000, - 0x32154d0d00000000, 0x561f63ec00000000, 0xb7a9310300000000, - 0xd574b7e900000000, 0x34c2e50600000000, 0x5c669af000000000, - 0xbdd0c81f00000000, 0xdf0d4ef500000000, 0x3ebb1c1a00000000, - 0x5ab132fb00000000, 0xbb07601400000000, 0xd9dae6fe00000000, - 0x386cb41100000000, 0x489468c900000000, 0xa9223a2600000000, - 0xcbffbccc00000000, 0x2a49ee2300000000, 0x4e43c0c200000000, - 0xaff5922d00000000, 0xcd2814c700000000, 0x2c9e462800000000, - 0x443a39de00000000, 0xa58c6b3100000000, 0xc751eddb00000000, - 0x26e7bf3400000000, 0x42ed91d500000000, 0xa35bc33a00000000, - 0xc18645d000000000, 0x2030173f00000000, 0x81e66bae00000000, - 0x6050394100000000, 0x028dbfab00000000, 0xe33bed4400000000, - 0x8731c3a500000000, 0x6687914a00000000, 0x045a17a000000000, - 0xe5ec454f00000000, 0x8d483ab900000000, 0x6cfe685600000000, - 0x0e23eebc00000000, 0xef95bc5300000000, 0x8b9f92b200000000, - 0x6a29c05d00000000, 0x08f446b700000000, 0xe942145800000000, - 0x99bac88000000000, 0x780c9a6f00000000, 0x1ad11c8500000000, - 0xfb674e6a00000000, 0x9f6d608b00000000, 0x7edb326400000000, - 0x1c06b48e00000000, 0xfdb0e66100000000, 0x9514999700000000, - 0x74a2cb7800000000, 0x167f4d9200000000, 0xf7c91f7d00000000, - 0x93c3319c00000000, 0x7275637300000000, 0x10a8e59900000000, - 0xf11eb77600000000, 0xb15e2df300000000, 0x50e87f1c00000000, - 0x3235f9f600000000, 0xd383ab1900000000, 0xb78985f800000000, - 0x563fd71700000000, 0x34e251fd00000000, 0xd554031200000000, - 0xbdf07ce400000000, 0x5c462e0b00000000, 0x3e9ba8e100000000, - 0xdf2dfa0e00000000, 0xbb27d4ef00000000, 0x5a91860000000000, - 0x384c00ea00000000, 0xd9fa520500000000, 0xa9028edd00000000, - 0x48b4dc3200000000, 0x2a695ad800000000, 0xcbdf083700000000, - 0xafd526d600000000, 0x4e63743900000000, 0x2cbef2d300000000, - 0xcd08a03c00000000, 0xa5acdfca00000000, 0x441a8d2500000000, - 0x26c70bcf00000000, 0xc771592000000000, 0xa37b77c100000000, - 0x42cd252e00000000, 0x2010a3c400000000, 0xc1a6f12b00000000, - 0xe196e61400000000, 0x0020b4fb00000000, 0x62fd321100000000, - 0x834b60fe00000000, 0xe7414e1f00000000, 0x06f71cf000000000, - 0x642a9a1a00000000, 0x859cc8f500000000, 0xed38b70300000000, - 0x0c8ee5ec00000000, 0x6e53630600000000, 0x8fe531e900000000, - 0xebef1f0800000000, 0x0a594de700000000, 0x6884cb0d00000000, - 0x893299e200000000, 0xf9ca453a00000000, 0x187c17d500000000, - 0x7aa1913f00000000, 0x9b17c3d000000000, 0xff1ded3100000000, - 0x1eabbfde00000000, 0x7c76393400000000, 0x9dc06bdb00000000, - 0xf564142d00000000, 0x14d246c200000000, 0x760fc02800000000, - 0x97b992c700000000, 0xf3b3bc2600000000, 0x1205eec900000000, - 0x70d8682300000000, 0x916e3acc00000000, 0xd12ea04900000000, - 0x3098f2a600000000, 0x5245744c00000000, 0xb3f326a300000000, - 0xd7f9084200000000, 0x364f5aad00000000, 0x5492dc4700000000, - 0xb5248ea800000000, 0xdd80f15e00000000, 0x3c36a3b100000000, - 0x5eeb255b00000000, 0xbf5d77b400000000, 0xdb57595500000000, - 0x3ae10bba00000000, 0x583c8d5000000000, 0xb98adfbf00000000, - 0xc972036700000000, 0x28c4518800000000, 0x4a19d76200000000, - 0xabaf858d00000000, 0xcfa5ab6c00000000, 0x2e13f98300000000, - 0x4cce7f6900000000, 0xad782d8600000000, 0xc5dc527000000000, - 0x246a009f00000000, 0x46b7867500000000, 0xa701d49a00000000, - 0xc30bfa7b00000000, 0x22bda89400000000, 0x40602e7e00000000, - 0xa1d67c9100000000}, - {0x0000000000000000, 0x5880e2d700000000, 0xf106b47400000000, - 0xa98656a300000000, 0xe20d68e900000000, 0xba8d8a3e00000000, - 0x130bdc9d00000000, 0x4b8b3e4a00000000, 0x851da10900000000, - 0xdd9d43de00000000, 0x741b157d00000000, 0x2c9bf7aa00000000, - 0x6710c9e000000000, 0x3f902b3700000000, 0x96167d9400000000, - 0xce969f4300000000, 0x0a3b421300000000, 0x52bba0c400000000, - 0xfb3df66700000000, 0xa3bd14b000000000, 0xe8362afa00000000, - 0xb0b6c82d00000000, 0x19309e8e00000000, 0x41b07c5900000000, - 0x8f26e31a00000000, 0xd7a601cd00000000, 0x7e20576e00000000, - 0x26a0b5b900000000, 0x6d2b8bf300000000, 0x35ab692400000000, - 0x9c2d3f8700000000, 0xc4addd5000000000, 0x1476842600000000, - 0x4cf666f100000000, 0xe570305200000000, 0xbdf0d28500000000, - 0xf67beccf00000000, 0xaefb0e1800000000, 0x077d58bb00000000, - 0x5ffdba6c00000000, 0x916b252f00000000, 0xc9ebc7f800000000, - 0x606d915b00000000, 0x38ed738c00000000, 0x73664dc600000000, - 0x2be6af1100000000, 0x8260f9b200000000, 0xdae01b6500000000, - 0x1e4dc63500000000, 0x46cd24e200000000, 0xef4b724100000000, - 0xb7cb909600000000, 0xfc40aedc00000000, 0xa4c04c0b00000000, - 0x0d461aa800000000, 0x55c6f87f00000000, 0x9b50673c00000000, - 0xc3d085eb00000000, 0x6a56d34800000000, 0x32d6319f00000000, - 0x795d0fd500000000, 0x21dded0200000000, 0x885bbba100000000, - 0xd0db597600000000, 0x28ec084d00000000, 0x706cea9a00000000, - 0xd9eabc3900000000, 0x816a5eee00000000, 0xcae160a400000000, - 0x9261827300000000, 0x3be7d4d000000000, 0x6367360700000000, - 0xadf1a94400000000, 0xf5714b9300000000, 0x5cf71d3000000000, - 0x0477ffe700000000, 0x4ffcc1ad00000000, 0x177c237a00000000, - 0xbefa75d900000000, 0xe67a970e00000000, 0x22d74a5e00000000, - 0x7a57a88900000000, 0xd3d1fe2a00000000, 0x8b511cfd00000000, - 0xc0da22b700000000, 0x985ac06000000000, 0x31dc96c300000000, - 0x695c741400000000, 0xa7caeb5700000000, 0xff4a098000000000, - 0x56cc5f2300000000, 0x0e4cbdf400000000, 0x45c783be00000000, - 0x1d47616900000000, 0xb4c137ca00000000, 0xec41d51d00000000, - 0x3c9a8c6b00000000, 0x641a6ebc00000000, 0xcd9c381f00000000, - 0x951cdac800000000, 0xde97e48200000000, 0x8617065500000000, - 0x2f9150f600000000, 0x7711b22100000000, 0xb9872d6200000000, - 0xe107cfb500000000, 0x4881991600000000, 0x10017bc100000000, - 0x5b8a458b00000000, 0x030aa75c00000000, 0xaa8cf1ff00000000, - 0xf20c132800000000, 0x36a1ce7800000000, 0x6e212caf00000000, - 0xc7a77a0c00000000, 0x9f2798db00000000, 0xd4aca69100000000, - 0x8c2c444600000000, 0x25aa12e500000000, 0x7d2af03200000000, - 0xb3bc6f7100000000, 0xeb3c8da600000000, 0x42badb0500000000, - 0x1a3a39d200000000, 0x51b1079800000000, 0x0931e54f00000000, - 0xa0b7b3ec00000000, 0xf837513b00000000, 0x50d8119a00000000, - 0x0858f34d00000000, 0xa1dea5ee00000000, 0xf95e473900000000, - 0xb2d5797300000000, 0xea559ba400000000, 0x43d3cd0700000000, - 0x1b532fd000000000, 0xd5c5b09300000000, 0x8d45524400000000, - 0x24c304e700000000, 0x7c43e63000000000, 0x37c8d87a00000000, - 0x6f483aad00000000, 0xc6ce6c0e00000000, 0x9e4e8ed900000000, - 0x5ae3538900000000, 0x0263b15e00000000, 0xabe5e7fd00000000, - 0xf365052a00000000, 0xb8ee3b6000000000, 0xe06ed9b700000000, - 0x49e88f1400000000, 0x11686dc300000000, 0xdffef28000000000, - 0x877e105700000000, 0x2ef846f400000000, 0x7678a42300000000, - 0x3df39a6900000000, 0x657378be00000000, 0xccf52e1d00000000, - 0x9475ccca00000000, 0x44ae95bc00000000, 0x1c2e776b00000000, - 0xb5a821c800000000, 0xed28c31f00000000, 0xa6a3fd5500000000, - 0xfe231f8200000000, 0x57a5492100000000, 0x0f25abf600000000, - 0xc1b334b500000000, 0x9933d66200000000, 0x30b580c100000000, - 0x6835621600000000, 0x23be5c5c00000000, 0x7b3ebe8b00000000, - 0xd2b8e82800000000, 0x8a380aff00000000, 0x4e95d7af00000000, - 0x1615357800000000, 0xbf9363db00000000, 0xe713810c00000000, - 0xac98bf4600000000, 0xf4185d9100000000, 0x5d9e0b3200000000, - 0x051ee9e500000000, 0xcb8876a600000000, 0x9308947100000000, - 0x3a8ec2d200000000, 0x620e200500000000, 0x29851e4f00000000, - 0x7105fc9800000000, 0xd883aa3b00000000, 0x800348ec00000000, - 0x783419d700000000, 0x20b4fb0000000000, 0x8932ada300000000, - 0xd1b24f7400000000, 0x9a39713e00000000, 0xc2b993e900000000, - 0x6b3fc54a00000000, 0x33bf279d00000000, 0xfd29b8de00000000, - 0xa5a95a0900000000, 0x0c2f0caa00000000, 0x54afee7d00000000, - 0x1f24d03700000000, 0x47a432e000000000, 0xee22644300000000, - 0xb6a2869400000000, 0x720f5bc400000000, 0x2a8fb91300000000, - 0x8309efb000000000, 0xdb890d6700000000, 0x9002332d00000000, - 0xc882d1fa00000000, 0x6104875900000000, 0x3984658e00000000, - 0xf712facd00000000, 0xaf92181a00000000, 0x06144eb900000000, - 0x5e94ac6e00000000, 0x151f922400000000, 0x4d9f70f300000000, - 0xe419265000000000, 0xbc99c48700000000, 0x6c429df100000000, - 0x34c27f2600000000, 0x9d44298500000000, 0xc5c4cb5200000000, - 0x8e4ff51800000000, 0xd6cf17cf00000000, 0x7f49416c00000000, - 0x27c9a3bb00000000, 0xe95f3cf800000000, 0xb1dfde2f00000000, - 0x1859888c00000000, 0x40d96a5b00000000, 0x0b52541100000000, - 0x53d2b6c600000000, 0xfa54e06500000000, 0xa2d402b200000000, - 0x6679dfe200000000, 0x3ef93d3500000000, 0x977f6b9600000000, - 0xcfff894100000000, 0x8474b70b00000000, 0xdcf455dc00000000, - 0x7572037f00000000, 0x2df2e1a800000000, 0xe3647eeb00000000, - 0xbbe49c3c00000000, 0x1262ca9f00000000, 0x4ae2284800000000, - 0x0169160200000000, 0x59e9f4d500000000, 0xf06fa27600000000, - 0xa8ef40a100000000}, - {0x0000000000000000, 0x463b676500000000, 0x8c76ceca00000000, - 0xca4da9af00000000, 0x59ebed4e00000000, 0x1fd08a2b00000000, - 0xd59d238400000000, 0x93a644e100000000, 0xb2d6db9d00000000, - 0xf4edbcf800000000, 0x3ea0155700000000, 0x789b723200000000, - 0xeb3d36d300000000, 0xad0651b600000000, 0x674bf81900000000, - 0x21709f7c00000000, 0x25abc6e000000000, 0x6390a18500000000, - 0xa9dd082a00000000, 0xefe66f4f00000000, 0x7c402bae00000000, - 0x3a7b4ccb00000000, 0xf036e56400000000, 0xb60d820100000000, - 0x977d1d7d00000000, 0xd1467a1800000000, 0x1b0bd3b700000000, - 0x5d30b4d200000000, 0xce96f03300000000, 0x88ad975600000000, - 0x42e03ef900000000, 0x04db599c00000000, 0x0b50fc1a00000000, - 0x4d6b9b7f00000000, 0x872632d000000000, 0xc11d55b500000000, - 0x52bb115400000000, 0x1480763100000000, 0xdecddf9e00000000, - 0x98f6b8fb00000000, 0xb986278700000000, 0xffbd40e200000000, - 0x35f0e94d00000000, 0x73cb8e2800000000, 0xe06dcac900000000, - 0xa656adac00000000, 0x6c1b040300000000, 0x2a20636600000000, - 0x2efb3afa00000000, 0x68c05d9f00000000, 0xa28df43000000000, - 0xe4b6935500000000, 0x7710d7b400000000, 0x312bb0d100000000, - 0xfb66197e00000000, 0xbd5d7e1b00000000, 0x9c2de16700000000, - 0xda16860200000000, 0x105b2fad00000000, 0x566048c800000000, - 0xc5c60c2900000000, 0x83fd6b4c00000000, 0x49b0c2e300000000, - 0x0f8ba58600000000, 0x16a0f83500000000, 0x509b9f5000000000, - 0x9ad636ff00000000, 0xdced519a00000000, 0x4f4b157b00000000, - 0x0970721e00000000, 0xc33ddbb100000000, 0x8506bcd400000000, - 0xa47623a800000000, 0xe24d44cd00000000, 0x2800ed6200000000, - 0x6e3b8a0700000000, 0xfd9dcee600000000, 0xbba6a98300000000, - 0x71eb002c00000000, 0x37d0674900000000, 0x330b3ed500000000, - 0x753059b000000000, 0xbf7df01f00000000, 0xf946977a00000000, - 0x6ae0d39b00000000, 0x2cdbb4fe00000000, 0xe6961d5100000000, - 0xa0ad7a3400000000, 0x81dde54800000000, 0xc7e6822d00000000, - 0x0dab2b8200000000, 0x4b904ce700000000, 0xd836080600000000, - 0x9e0d6f6300000000, 0x5440c6cc00000000, 0x127ba1a900000000, - 0x1df0042f00000000, 0x5bcb634a00000000, 0x9186cae500000000, - 0xd7bdad8000000000, 0x441be96100000000, 0x02208e0400000000, - 0xc86d27ab00000000, 0x8e5640ce00000000, 0xaf26dfb200000000, - 0xe91db8d700000000, 0x2350117800000000, 0x656b761d00000000, - 0xf6cd32fc00000000, 0xb0f6559900000000, 0x7abbfc3600000000, - 0x3c809b5300000000, 0x385bc2cf00000000, 0x7e60a5aa00000000, - 0xb42d0c0500000000, 0xf2166b6000000000, 0x61b02f8100000000, - 0x278b48e400000000, 0xedc6e14b00000000, 0xabfd862e00000000, - 0x8a8d195200000000, 0xccb67e3700000000, 0x06fbd79800000000, - 0x40c0b0fd00000000, 0xd366f41c00000000, 0x955d937900000000, - 0x5f103ad600000000, 0x192b5db300000000, 0x2c40f16b00000000, - 0x6a7b960e00000000, 0xa0363fa100000000, 0xe60d58c400000000, - 0x75ab1c2500000000, 0x33907b4000000000, 0xf9ddd2ef00000000, - 0xbfe6b58a00000000, 0x9e962af600000000, 0xd8ad4d9300000000, - 0x12e0e43c00000000, 0x54db835900000000, 0xc77dc7b800000000, - 0x8146a0dd00000000, 0x4b0b097200000000, 0x0d306e1700000000, - 0x09eb378b00000000, 0x4fd050ee00000000, 0x859df94100000000, - 0xc3a69e2400000000, 0x5000dac500000000, 0x163bbda000000000, - 0xdc76140f00000000, 0x9a4d736a00000000, 0xbb3dec1600000000, - 0xfd068b7300000000, 0x374b22dc00000000, 0x717045b900000000, - 0xe2d6015800000000, 0xa4ed663d00000000, 0x6ea0cf9200000000, - 0x289ba8f700000000, 0x27100d7100000000, 0x612b6a1400000000, - 0xab66c3bb00000000, 0xed5da4de00000000, 0x7efbe03f00000000, - 0x38c0875a00000000, 0xf28d2ef500000000, 0xb4b6499000000000, - 0x95c6d6ec00000000, 0xd3fdb18900000000, 0x19b0182600000000, - 0x5f8b7f4300000000, 0xcc2d3ba200000000, 0x8a165cc700000000, - 0x405bf56800000000, 0x0660920d00000000, 0x02bbcb9100000000, - 0x4480acf400000000, 0x8ecd055b00000000, 0xc8f6623e00000000, - 0x5b5026df00000000, 0x1d6b41ba00000000, 0xd726e81500000000, - 0x911d8f7000000000, 0xb06d100c00000000, 0xf656776900000000, - 0x3c1bdec600000000, 0x7a20b9a300000000, 0xe986fd4200000000, - 0xafbd9a2700000000, 0x65f0338800000000, 0x23cb54ed00000000, - 0x3ae0095e00000000, 0x7cdb6e3b00000000, 0xb696c79400000000, - 0xf0ada0f100000000, 0x630be41000000000, 0x2530837500000000, - 0xef7d2ada00000000, 0xa9464dbf00000000, 0x8836d2c300000000, - 0xce0db5a600000000, 0x04401c0900000000, 0x427b7b6c00000000, - 0xd1dd3f8d00000000, 0x97e658e800000000, 0x5dabf14700000000, - 0x1b90962200000000, 0x1f4bcfbe00000000, 0x5970a8db00000000, - 0x933d017400000000, 0xd506661100000000, 0x46a022f000000000, - 0x009b459500000000, 0xcad6ec3a00000000, 0x8ced8b5f00000000, - 0xad9d142300000000, 0xeba6734600000000, 0x21ebdae900000000, - 0x67d0bd8c00000000, 0xf476f96d00000000, 0xb24d9e0800000000, - 0x780037a700000000, 0x3e3b50c200000000, 0x31b0f54400000000, - 0x778b922100000000, 0xbdc63b8e00000000, 0xfbfd5ceb00000000, - 0x685b180a00000000, 0x2e607f6f00000000, 0xe42dd6c000000000, - 0xa216b1a500000000, 0x83662ed900000000, 0xc55d49bc00000000, - 0x0f10e01300000000, 0x492b877600000000, 0xda8dc39700000000, - 0x9cb6a4f200000000, 0x56fb0d5d00000000, 0x10c06a3800000000, - 0x141b33a400000000, 0x522054c100000000, 0x986dfd6e00000000, - 0xde569a0b00000000, 0x4df0deea00000000, 0x0bcbb98f00000000, - 0xc186102000000000, 0x87bd774500000000, 0xa6cde83900000000, - 0xe0f68f5c00000000, 0x2abb26f300000000, 0x6c80419600000000, - 0xff26057700000000, 0xb91d621200000000, 0x7350cbbd00000000, - 0x356bacd800000000}, - {0x0000000000000000, 0x9e83da9f00000000, 0x7d01c4e400000000, - 0xe3821e7b00000000, 0xbb04f91200000000, 0x2587238d00000000, - 0xc6053df600000000, 0x5886e76900000000, 0x7609f22500000000, - 0xe88a28ba00000000, 0x0b0836c100000000, 0x958bec5e00000000, - 0xcd0d0b3700000000, 0x538ed1a800000000, 0xb00ccfd300000000, - 0x2e8f154c00000000, 0xec12e44b00000000, 0x72913ed400000000, - 0x911320af00000000, 0x0f90fa3000000000, 0x57161d5900000000, - 0xc995c7c600000000, 0x2a17d9bd00000000, 0xb494032200000000, - 0x9a1b166e00000000, 0x0498ccf100000000, 0xe71ad28a00000000, - 0x7999081500000000, 0x211fef7c00000000, 0xbf9c35e300000000, - 0x5c1e2b9800000000, 0xc29df10700000000, 0xd825c89700000000, - 0x46a6120800000000, 0xa5240c7300000000, 0x3ba7d6ec00000000, - 0x6321318500000000, 0xfda2eb1a00000000, 0x1e20f56100000000, - 0x80a32ffe00000000, 0xae2c3ab200000000, 0x30afe02d00000000, - 0xd32dfe5600000000, 0x4dae24c900000000, 0x1528c3a000000000, - 0x8bab193f00000000, 0x6829074400000000, 0xf6aadddb00000000, - 0x34372cdc00000000, 0xaab4f64300000000, 0x4936e83800000000, - 0xd7b532a700000000, 0x8f33d5ce00000000, 0x11b00f5100000000, - 0xf232112a00000000, 0x6cb1cbb500000000, 0x423edef900000000, - 0xdcbd046600000000, 0x3f3f1a1d00000000, 0xa1bcc08200000000, - 0xf93a27eb00000000, 0x67b9fd7400000000, 0x843be30f00000000, - 0x1ab8399000000000, 0xf14de1f400000000, 0x6fce3b6b00000000, - 0x8c4c251000000000, 0x12cfff8f00000000, 0x4a4918e600000000, - 0xd4cac27900000000, 0x3748dc0200000000, 0xa9cb069d00000000, - 0x874413d100000000, 0x19c7c94e00000000, 0xfa45d73500000000, - 0x64c60daa00000000, 0x3c40eac300000000, 0xa2c3305c00000000, - 0x41412e2700000000, 0xdfc2f4b800000000, 0x1d5f05bf00000000, - 0x83dcdf2000000000, 0x605ec15b00000000, 0xfedd1bc400000000, - 0xa65bfcad00000000, 0x38d8263200000000, 0xdb5a384900000000, - 0x45d9e2d600000000, 0x6b56f79a00000000, 0xf5d52d0500000000, - 0x1657337e00000000, 0x88d4e9e100000000, 0xd0520e8800000000, - 0x4ed1d41700000000, 0xad53ca6c00000000, 0x33d010f300000000, - 0x2968296300000000, 0xb7ebf3fc00000000, 0x5469ed8700000000, - 0xcaea371800000000, 0x926cd07100000000, 0x0cef0aee00000000, - 0xef6d149500000000, 0x71eece0a00000000, 0x5f61db4600000000, - 0xc1e201d900000000, 0x22601fa200000000, 0xbce3c53d00000000, - 0xe465225400000000, 0x7ae6f8cb00000000, 0x9964e6b000000000, - 0x07e73c2f00000000, 0xc57acd2800000000, 0x5bf917b700000000, - 0xb87b09cc00000000, 0x26f8d35300000000, 0x7e7e343a00000000, - 0xe0fdeea500000000, 0x037ff0de00000000, 0x9dfc2a4100000000, - 0xb3733f0d00000000, 0x2df0e59200000000, 0xce72fbe900000000, - 0x50f1217600000000, 0x0877c61f00000000, 0x96f41c8000000000, - 0x757602fb00000000, 0xebf5d86400000000, 0xa39db33200000000, - 0x3d1e69ad00000000, 0xde9c77d600000000, 0x401fad4900000000, - 0x18994a2000000000, 0x861a90bf00000000, 0x65988ec400000000, - 0xfb1b545b00000000, 0xd594411700000000, 0x4b179b8800000000, - 0xa89585f300000000, 0x36165f6c00000000, 0x6e90b80500000000, - 0xf013629a00000000, 0x13917ce100000000, 0x8d12a67e00000000, - 0x4f8f577900000000, 0xd10c8de600000000, 0x328e939d00000000, - 0xac0d490200000000, 0xf48bae6b00000000, 0x6a0874f400000000, - 0x898a6a8f00000000, 0x1709b01000000000, 0x3986a55c00000000, - 0xa7057fc300000000, 0x448761b800000000, 0xda04bb2700000000, - 0x82825c4e00000000, 0x1c0186d100000000, 0xff8398aa00000000, - 0x6100423500000000, 0x7bb87ba500000000, 0xe53ba13a00000000, - 0x06b9bf4100000000, 0x983a65de00000000, 0xc0bc82b700000000, - 0x5e3f582800000000, 0xbdbd465300000000, 0x233e9ccc00000000, - 0x0db1898000000000, 0x9332531f00000000, 0x70b04d6400000000, - 0xee3397fb00000000, 0xb6b5709200000000, 0x2836aa0d00000000, - 0xcbb4b47600000000, 0x55376ee900000000, 0x97aa9fee00000000, - 0x0929457100000000, 0xeaab5b0a00000000, 0x7428819500000000, - 0x2cae66fc00000000, 0xb22dbc6300000000, 0x51afa21800000000, - 0xcf2c788700000000, 0xe1a36dcb00000000, 0x7f20b75400000000, - 0x9ca2a92f00000000, 0x022173b000000000, 0x5aa794d900000000, - 0xc4244e4600000000, 0x27a6503d00000000, 0xb9258aa200000000, - 0x52d052c600000000, 0xcc53885900000000, 0x2fd1962200000000, - 0xb1524cbd00000000, 0xe9d4abd400000000, 0x7757714b00000000, - 0x94d56f3000000000, 0x0a56b5af00000000, 0x24d9a0e300000000, - 0xba5a7a7c00000000, 0x59d8640700000000, 0xc75bbe9800000000, - 0x9fdd59f100000000, 0x015e836e00000000, 0xe2dc9d1500000000, - 0x7c5f478a00000000, 0xbec2b68d00000000, 0x20416c1200000000, - 0xc3c3726900000000, 0x5d40a8f600000000, 0x05c64f9f00000000, - 0x9b45950000000000, 0x78c78b7b00000000, 0xe64451e400000000, - 0xc8cb44a800000000, 0x56489e3700000000, 0xb5ca804c00000000, - 0x2b495ad300000000, 0x73cfbdba00000000, 0xed4c672500000000, - 0x0ece795e00000000, 0x904da3c100000000, 0x8af59a5100000000, - 0x147640ce00000000, 0xf7f45eb500000000, 0x6977842a00000000, - 0x31f1634300000000, 0xaf72b9dc00000000, 0x4cf0a7a700000000, - 0xd2737d3800000000, 0xfcfc687400000000, 0x627fb2eb00000000, - 0x81fdac9000000000, 0x1f7e760f00000000, 0x47f8916600000000, - 0xd97b4bf900000000, 0x3af9558200000000, 0xa47a8f1d00000000, - 0x66e77e1a00000000, 0xf864a48500000000, 0x1be6bafe00000000, - 0x8565606100000000, 0xdde3870800000000, 0x43605d9700000000, - 0xa0e243ec00000000, 0x3e61997300000000, 0x10ee8c3f00000000, - 0x8e6d56a000000000, 0x6def48db00000000, 0xf36c924400000000, - 0xabea752d00000000, 0x3569afb200000000, 0xd6ebb1c900000000, - 0x48686b5600000000}, - {0x0000000000000000, 0xc064281700000000, 0x80c9502e00000000, - 0x40ad783900000000, 0x0093a15c00000000, 0xc0f7894b00000000, - 0x805af17200000000, 0x403ed96500000000, 0x002643b900000000, - 0xc0426bae00000000, 0x80ef139700000000, 0x408b3b8000000000, - 0x00b5e2e500000000, 0xc0d1caf200000000, 0x807cb2cb00000000, - 0x40189adc00000000, 0x414af7a900000000, 0x812edfbe00000000, - 0xc183a78700000000, 0x01e78f9000000000, 0x41d956f500000000, - 0x81bd7ee200000000, 0xc11006db00000000, 0x01742ecc00000000, - 0x416cb41000000000, 0x81089c0700000000, 0xc1a5e43e00000000, - 0x01c1cc2900000000, 0x41ff154c00000000, 0x819b3d5b00000000, - 0xc136456200000000, 0x01526d7500000000, 0xc3929f8800000000, - 0x03f6b79f00000000, 0x435bcfa600000000, 0x833fe7b100000000, - 0xc3013ed400000000, 0x036516c300000000, 0x43c86efa00000000, - 0x83ac46ed00000000, 0xc3b4dc3100000000, 0x03d0f42600000000, - 0x437d8c1f00000000, 0x8319a40800000000, 0xc3277d6d00000000, - 0x0343557a00000000, 0x43ee2d4300000000, 0x838a055400000000, - 0x82d8682100000000, 0x42bc403600000000, 0x0211380f00000000, - 0xc275101800000000, 0x824bc97d00000000, 0x422fe16a00000000, - 0x0282995300000000, 0xc2e6b14400000000, 0x82fe2b9800000000, - 0x429a038f00000000, 0x02377bb600000000, 0xc25353a100000000, - 0x826d8ac400000000, 0x4209a2d300000000, 0x02a4daea00000000, - 0xc2c0f2fd00000000, 0xc7234eca00000000, 0x074766dd00000000, - 0x47ea1ee400000000, 0x878e36f300000000, 0xc7b0ef9600000000, - 0x07d4c78100000000, 0x4779bfb800000000, 0x871d97af00000000, - 0xc7050d7300000000, 0x0761256400000000, 0x47cc5d5d00000000, - 0x87a8754a00000000, 0xc796ac2f00000000, 0x07f2843800000000, - 0x475ffc0100000000, 0x873bd41600000000, 0x8669b96300000000, - 0x460d917400000000, 0x06a0e94d00000000, 0xc6c4c15a00000000, - 0x86fa183f00000000, 0x469e302800000000, 0x0633481100000000, - 0xc657600600000000, 0x864ffada00000000, 0x462bd2cd00000000, - 0x0686aaf400000000, 0xc6e282e300000000, 0x86dc5b8600000000, - 0x46b8739100000000, 0x06150ba800000000, 0xc67123bf00000000, - 0x04b1d14200000000, 0xc4d5f95500000000, 0x8478816c00000000, - 0x441ca97b00000000, 0x0422701e00000000, 0xc446580900000000, - 0x84eb203000000000, 0x448f082700000000, 0x049792fb00000000, - 0xc4f3baec00000000, 0x845ec2d500000000, 0x443aeac200000000, - 0x040433a700000000, 0xc4601bb000000000, 0x84cd638900000000, - 0x44a94b9e00000000, 0x45fb26eb00000000, 0x859f0efc00000000, - 0xc53276c500000000, 0x05565ed200000000, 0x456887b700000000, - 0x850cafa000000000, 0xc5a1d79900000000, 0x05c5ff8e00000000, - 0x45dd655200000000, 0x85b94d4500000000, 0xc514357c00000000, - 0x05701d6b00000000, 0x454ec40e00000000, 0x852aec1900000000, - 0xc587942000000000, 0x05e3bc3700000000, 0xcf41ed4f00000000, - 0x0f25c55800000000, 0x4f88bd6100000000, 0x8fec957600000000, - 0xcfd24c1300000000, 0x0fb6640400000000, 0x4f1b1c3d00000000, - 0x8f7f342a00000000, 0xcf67aef600000000, 0x0f0386e100000000, - 0x4faefed800000000, 0x8fcad6cf00000000, 0xcff40faa00000000, - 0x0f9027bd00000000, 0x4f3d5f8400000000, 0x8f59779300000000, - 0x8e0b1ae600000000, 0x4e6f32f100000000, 0x0ec24ac800000000, - 0xcea662df00000000, 0x8e98bbba00000000, 0x4efc93ad00000000, - 0x0e51eb9400000000, 0xce35c38300000000, 0x8e2d595f00000000, - 0x4e49714800000000, 0x0ee4097100000000, 0xce80216600000000, - 0x8ebef80300000000, 0x4edad01400000000, 0x0e77a82d00000000, - 0xce13803a00000000, 0x0cd372c700000000, 0xccb75ad000000000, - 0x8c1a22e900000000, 0x4c7e0afe00000000, 0x0c40d39b00000000, - 0xcc24fb8c00000000, 0x8c8983b500000000, 0x4cedaba200000000, - 0x0cf5317e00000000, 0xcc91196900000000, 0x8c3c615000000000, - 0x4c58494700000000, 0x0c66902200000000, 0xcc02b83500000000, - 0x8cafc00c00000000, 0x4ccbe81b00000000, 0x4d99856e00000000, - 0x8dfdad7900000000, 0xcd50d54000000000, 0x0d34fd5700000000, - 0x4d0a243200000000, 0x8d6e0c2500000000, 0xcdc3741c00000000, - 0x0da75c0b00000000, 0x4dbfc6d700000000, 0x8ddbeec000000000, - 0xcd7696f900000000, 0x0d12beee00000000, 0x4d2c678b00000000, - 0x8d484f9c00000000, 0xcde537a500000000, 0x0d811fb200000000, - 0x0862a38500000000, 0xc8068b9200000000, 0x88abf3ab00000000, - 0x48cfdbbc00000000, 0x08f102d900000000, 0xc8952ace00000000, - 0x883852f700000000, 0x485c7ae000000000, 0x0844e03c00000000, - 0xc820c82b00000000, 0x888db01200000000, 0x48e9980500000000, - 0x08d7416000000000, 0xc8b3697700000000, 0x881e114e00000000, - 0x487a395900000000, 0x4928542c00000000, 0x894c7c3b00000000, - 0xc9e1040200000000, 0x09852c1500000000, 0x49bbf57000000000, - 0x89dfdd6700000000, 0xc972a55e00000000, 0x09168d4900000000, - 0x490e179500000000, 0x896a3f8200000000, 0xc9c747bb00000000, - 0x09a36fac00000000, 0x499db6c900000000, 0x89f99ede00000000, - 0xc954e6e700000000, 0x0930cef000000000, 0xcbf03c0d00000000, - 0x0b94141a00000000, 0x4b396c2300000000, 0x8b5d443400000000, - 0xcb639d5100000000, 0x0b07b54600000000, 0x4baacd7f00000000, - 0x8bcee56800000000, 0xcbd67fb400000000, 0x0bb257a300000000, - 0x4b1f2f9a00000000, 0x8b7b078d00000000, 0xcb45dee800000000, - 0x0b21f6ff00000000, 0x4b8c8ec600000000, 0x8be8a6d100000000, - 0x8abacba400000000, 0x4adee3b300000000, 0x0a739b8a00000000, - 0xca17b39d00000000, 0x8a296af800000000, 0x4a4d42ef00000000, - 0x0ae03ad600000000, 0xca8412c100000000, 0x8a9c881d00000000, - 0x4af8a00a00000000, 0x0a55d83300000000, 0xca31f02400000000, - 0x8a0f294100000000, 0x4a6b015600000000, 0x0ac6796f00000000, - 0xcaa2517800000000}, - {0x0000000000000000, 0xd4ea739b00000000, 0xe9d396ed00000000, - 0x3d39e57600000000, 0x93a15c0000000000, 0x474b2f9b00000000, - 0x7a72caed00000000, 0xae98b97600000000, 0x2643b90000000000, - 0xf2a9ca9b00000000, 0xcf902fed00000000, 0x1b7a5c7600000000, - 0xb5e2e50000000000, 0x6108969b00000000, 0x5c3173ed00000000, - 0x88db007600000000, 0x4c86720100000000, 0x986c019a00000000, - 0xa555e4ec00000000, 0x71bf977700000000, 0xdf272e0100000000, - 0x0bcd5d9a00000000, 0x36f4b8ec00000000, 0xe21ecb7700000000, - 0x6ac5cb0100000000, 0xbe2fb89a00000000, 0x83165dec00000000, - 0x57fc2e7700000000, 0xf964970100000000, 0x2d8ee49a00000000, - 0x10b701ec00000000, 0xc45d727700000000, 0x980ce50200000000, - 0x4ce6969900000000, 0x71df73ef00000000, 0xa535007400000000, - 0x0badb90200000000, 0xdf47ca9900000000, 0xe27e2fef00000000, - 0x36945c7400000000, 0xbe4f5c0200000000, 0x6aa52f9900000000, - 0x579ccaef00000000, 0x8376b97400000000, 0x2dee000200000000, - 0xf904739900000000, 0xc43d96ef00000000, 0x10d7e57400000000, - 0xd48a970300000000, 0x0060e49800000000, 0x3d5901ee00000000, - 0xe9b3727500000000, 0x472bcb0300000000, 0x93c1b89800000000, - 0xaef85dee00000000, 0x7a122e7500000000, 0xf2c92e0300000000, - 0x26235d9800000000, 0x1b1ab8ee00000000, 0xcff0cb7500000000, - 0x6168720300000000, 0xb582019800000000, 0x88bbe4ee00000000, - 0x5c51977500000000, 0x3019ca0500000000, 0xe4f3b99e00000000, - 0xd9ca5ce800000000, 0x0d202f7300000000, 0xa3b8960500000000, - 0x7752e59e00000000, 0x4a6b00e800000000, 0x9e81737300000000, - 0x165a730500000000, 0xc2b0009e00000000, 0xff89e5e800000000, - 0x2b63967300000000, 0x85fb2f0500000000, 0x51115c9e00000000, - 0x6c28b9e800000000, 0xb8c2ca7300000000, 0x7c9fb80400000000, - 0xa875cb9f00000000, 0x954c2ee900000000, 0x41a65d7200000000, - 0xef3ee40400000000, 0x3bd4979f00000000, 0x06ed72e900000000, - 0xd207017200000000, 0x5adc010400000000, 0x8e36729f00000000, - 0xb30f97e900000000, 0x67e5e47200000000, 0xc97d5d0400000000, - 0x1d972e9f00000000, 0x20aecbe900000000, 0xf444b87200000000, - 0xa8152f0700000000, 0x7cff5c9c00000000, 0x41c6b9ea00000000, - 0x952cca7100000000, 0x3bb4730700000000, 0xef5e009c00000000, - 0xd267e5ea00000000, 0x068d967100000000, 0x8e56960700000000, - 0x5abce59c00000000, 0x678500ea00000000, 0xb36f737100000000, - 0x1df7ca0700000000, 0xc91db99c00000000, 0xf4245cea00000000, - 0x20ce2f7100000000, 0xe4935d0600000000, 0x30792e9d00000000, - 0x0d40cbeb00000000, 0xd9aab87000000000, 0x7732010600000000, - 0xa3d8729d00000000, 0x9ee197eb00000000, 0x4a0be47000000000, - 0xc2d0e40600000000, 0x163a979d00000000, 0x2b0372eb00000000, - 0xffe9017000000000, 0x5171b80600000000, 0x859bcb9d00000000, - 0xb8a22eeb00000000, 0x6c485d7000000000, 0x6032940b00000000, - 0xb4d8e79000000000, 0x89e102e600000000, 0x5d0b717d00000000, - 0xf393c80b00000000, 0x2779bb9000000000, 0x1a405ee600000000, - 0xceaa2d7d00000000, 0x46712d0b00000000, 0x929b5e9000000000, - 0xafa2bbe600000000, 0x7b48c87d00000000, 0xd5d0710b00000000, - 0x013a029000000000, 0x3c03e7e600000000, 0xe8e9947d00000000, - 0x2cb4e60a00000000, 0xf85e959100000000, 0xc56770e700000000, - 0x118d037c00000000, 0xbf15ba0a00000000, 0x6bffc99100000000, - 0x56c62ce700000000, 0x822c5f7c00000000, 0x0af75f0a00000000, - 0xde1d2c9100000000, 0xe324c9e700000000, 0x37ceba7c00000000, - 0x9956030a00000000, 0x4dbc709100000000, 0x708595e700000000, - 0xa46fe67c00000000, 0xf83e710900000000, 0x2cd4029200000000, - 0x11ede7e400000000, 0xc507947f00000000, 0x6b9f2d0900000000, - 0xbf755e9200000000, 0x824cbbe400000000, 0x56a6c87f00000000, - 0xde7dc80900000000, 0x0a97bb9200000000, 0x37ae5ee400000000, - 0xe3442d7f00000000, 0x4ddc940900000000, 0x9936e79200000000, - 0xa40f02e400000000, 0x70e5717f00000000, 0xb4b8030800000000, - 0x6052709300000000, 0x5d6b95e500000000, 0x8981e67e00000000, - 0x27195f0800000000, 0xf3f32c9300000000, 0xcecac9e500000000, - 0x1a20ba7e00000000, 0x92fbba0800000000, 0x4611c99300000000, - 0x7b282ce500000000, 0xafc25f7e00000000, 0x015ae60800000000, - 0xd5b0959300000000, 0xe88970e500000000, 0x3c63037e00000000, - 0x502b5e0e00000000, 0x84c12d9500000000, 0xb9f8c8e300000000, - 0x6d12bb7800000000, 0xc38a020e00000000, 0x1760719500000000, - 0x2a5994e300000000, 0xfeb3e77800000000, 0x7668e70e00000000, - 0xa282949500000000, 0x9fbb71e300000000, 0x4b51027800000000, - 0xe5c9bb0e00000000, 0x3123c89500000000, 0x0c1a2de300000000, - 0xd8f05e7800000000, 0x1cad2c0f00000000, 0xc8475f9400000000, - 0xf57ebae200000000, 0x2194c97900000000, 0x8f0c700f00000000, - 0x5be6039400000000, 0x66dfe6e200000000, 0xb235957900000000, - 0x3aee950f00000000, 0xee04e69400000000, 0xd33d03e200000000, - 0x07d7707900000000, 0xa94fc90f00000000, 0x7da5ba9400000000, - 0x409c5fe200000000, 0x94762c7900000000, 0xc827bb0c00000000, - 0x1ccdc89700000000, 0x21f42de100000000, 0xf51e5e7a00000000, - 0x5b86e70c00000000, 0x8f6c949700000000, 0xb25571e100000000, - 0x66bf027a00000000, 0xee64020c00000000, 0x3a8e719700000000, - 0x07b794e100000000, 0xd35de77a00000000, 0x7dc55e0c00000000, - 0xa92f2d9700000000, 0x9416c8e100000000, 0x40fcbb7a00000000, - 0x84a1c90d00000000, 0x504bba9600000000, 0x6d725fe000000000, - 0xb9982c7b00000000, 0x1700950d00000000, 0xc3eae69600000000, - 0xfed303e000000000, 0x2a39707b00000000, 0xa2e2700d00000000, - 0x7608039600000000, 0x4b31e6e000000000, 0x9fdb957b00000000, - 0x31432c0d00000000, 0xe5a95f9600000000, 0xd890bae000000000, - 0x0c7ac97b00000000}, - {0x0000000000000000, 0x2765258100000000, 0x0fcc3bd900000000, - 0x28a91e5800000000, 0x5f9e066900000000, 0x78fb23e800000000, - 0x50523db000000000, 0x7737183100000000, 0xbe3c0dd200000000, - 0x9959285300000000, 0xb1f0360b00000000, 0x9695138a00000000, - 0xe1a20bbb00000000, 0xc6c72e3a00000000, 0xee6e306200000000, - 0xc90b15e300000000, 0x3d7f6b7f00000000, 0x1a1a4efe00000000, - 0x32b350a600000000, 0x15d6752700000000, 0x62e16d1600000000, - 0x4584489700000000, 0x6d2d56cf00000000, 0x4a48734e00000000, - 0x834366ad00000000, 0xa426432c00000000, 0x8c8f5d7400000000, - 0xabea78f500000000, 0xdcdd60c400000000, 0xfbb8454500000000, - 0xd3115b1d00000000, 0xf4747e9c00000000, 0x7afed6fe00000000, - 0x5d9bf37f00000000, 0x7532ed2700000000, 0x5257c8a600000000, - 0x2560d09700000000, 0x0205f51600000000, 0x2aaceb4e00000000, - 0x0dc9cecf00000000, 0xc4c2db2c00000000, 0xe3a7fead00000000, - 0xcb0ee0f500000000, 0xec6bc57400000000, 0x9b5cdd4500000000, - 0xbc39f8c400000000, 0x9490e69c00000000, 0xb3f5c31d00000000, - 0x4781bd8100000000, 0x60e4980000000000, 0x484d865800000000, - 0x6f28a3d900000000, 0x181fbbe800000000, 0x3f7a9e6900000000, - 0x17d3803100000000, 0x30b6a5b000000000, 0xf9bdb05300000000, - 0xded895d200000000, 0xf6718b8a00000000, 0xd114ae0b00000000, - 0xa623b63a00000000, 0x814693bb00000000, 0xa9ef8de300000000, - 0x8e8aa86200000000, 0xb5fadc2600000000, 0x929ff9a700000000, - 0xba36e7ff00000000, 0x9d53c27e00000000, 0xea64da4f00000000, - 0xcd01ffce00000000, 0xe5a8e19600000000, 0xc2cdc41700000000, - 0x0bc6d1f400000000, 0x2ca3f47500000000, 0x040aea2d00000000, - 0x236fcfac00000000, 0x5458d79d00000000, 0x733df21c00000000, - 0x5b94ec4400000000, 0x7cf1c9c500000000, 0x8885b75900000000, - 0xafe092d800000000, 0x87498c8000000000, 0xa02ca90100000000, - 0xd71bb13000000000, 0xf07e94b100000000, 0xd8d78ae900000000, - 0xffb2af6800000000, 0x36b9ba8b00000000, 0x11dc9f0a00000000, - 0x3975815200000000, 0x1e10a4d300000000, 0x6927bce200000000, - 0x4e42996300000000, 0x66eb873b00000000, 0x418ea2ba00000000, - 0xcf040ad800000000, 0xe8612f5900000000, 0xc0c8310100000000, - 0xe7ad148000000000, 0x909a0cb100000000, 0xb7ff293000000000, - 0x9f56376800000000, 0xb83312e900000000, 0x7138070a00000000, - 0x565d228b00000000, 0x7ef43cd300000000, 0x5991195200000000, - 0x2ea6016300000000, 0x09c324e200000000, 0x216a3aba00000000, - 0x060f1f3b00000000, 0xf27b61a700000000, 0xd51e442600000000, - 0xfdb75a7e00000000, 0xdad27fff00000000, 0xade567ce00000000, - 0x8a80424f00000000, 0xa2295c1700000000, 0x854c799600000000, - 0x4c476c7500000000, 0x6b2249f400000000, 0x438b57ac00000000, - 0x64ee722d00000000, 0x13d96a1c00000000, 0x34bc4f9d00000000, - 0x1c1551c500000000, 0x3b70744400000000, 0x6af5b94d00000000, - 0x4d909ccc00000000, 0x6539829400000000, 0x425ca71500000000, - 0x356bbf2400000000, 0x120e9aa500000000, 0x3aa784fd00000000, - 0x1dc2a17c00000000, 0xd4c9b49f00000000, 0xf3ac911e00000000, - 0xdb058f4600000000, 0xfc60aac700000000, 0x8b57b2f600000000, - 0xac32977700000000, 0x849b892f00000000, 0xa3feacae00000000, - 0x578ad23200000000, 0x70eff7b300000000, 0x5846e9eb00000000, - 0x7f23cc6a00000000, 0x0814d45b00000000, 0x2f71f1da00000000, - 0x07d8ef8200000000, 0x20bdca0300000000, 0xe9b6dfe000000000, - 0xced3fa6100000000, 0xe67ae43900000000, 0xc11fc1b800000000, - 0xb628d98900000000, 0x914dfc0800000000, 0xb9e4e25000000000, - 0x9e81c7d100000000, 0x100b6fb300000000, 0x376e4a3200000000, - 0x1fc7546a00000000, 0x38a271eb00000000, 0x4f9569da00000000, - 0x68f04c5b00000000, 0x4059520300000000, 0x673c778200000000, - 0xae37626100000000, 0x895247e000000000, 0xa1fb59b800000000, - 0x869e7c3900000000, 0xf1a9640800000000, 0xd6cc418900000000, - 0xfe655fd100000000, 0xd9007a5000000000, 0x2d7404cc00000000, - 0x0a11214d00000000, 0x22b83f1500000000, 0x05dd1a9400000000, - 0x72ea02a500000000, 0x558f272400000000, 0x7d26397c00000000, - 0x5a431cfd00000000, 0x9348091e00000000, 0xb42d2c9f00000000, - 0x9c8432c700000000, 0xbbe1174600000000, 0xccd60f7700000000, - 0xebb32af600000000, 0xc31a34ae00000000, 0xe47f112f00000000, - 0xdf0f656b00000000, 0xf86a40ea00000000, 0xd0c35eb200000000, - 0xf7a67b3300000000, 0x8091630200000000, 0xa7f4468300000000, - 0x8f5d58db00000000, 0xa8387d5a00000000, 0x613368b900000000, - 0x46564d3800000000, 0x6eff536000000000, 0x499a76e100000000, - 0x3ead6ed000000000, 0x19c84b5100000000, 0x3161550900000000, - 0x1604708800000000, 0xe2700e1400000000, 0xc5152b9500000000, - 0xedbc35cd00000000, 0xcad9104c00000000, 0xbdee087d00000000, - 0x9a8b2dfc00000000, 0xb22233a400000000, 0x9547162500000000, - 0x5c4c03c600000000, 0x7b29264700000000, 0x5380381f00000000, - 0x74e51d9e00000000, 0x03d205af00000000, 0x24b7202e00000000, - 0x0c1e3e7600000000, 0x2b7b1bf700000000, 0xa5f1b39500000000, - 0x8294961400000000, 0xaa3d884c00000000, 0x8d58adcd00000000, - 0xfa6fb5fc00000000, 0xdd0a907d00000000, 0xf5a38e2500000000, - 0xd2c6aba400000000, 0x1bcdbe4700000000, 0x3ca89bc600000000, - 0x1401859e00000000, 0x3364a01f00000000, 0x4453b82e00000000, - 0x63369daf00000000, 0x4b9f83f700000000, 0x6cfaa67600000000, - 0x988ed8ea00000000, 0xbfebfd6b00000000, 0x9742e33300000000, - 0xb027c6b200000000, 0xc710de8300000000, 0xe075fb0200000000, - 0xc8dce55a00000000, 0xefb9c0db00000000, 0x26b2d53800000000, - 0x01d7f0b900000000, 0x297eeee100000000, 0x0e1bcb6000000000, - 0x792cd35100000000, 0x5e49f6d000000000, 0x76e0e88800000000, - 0x5185cd0900000000}}; - -#else /* W == 4 */ - -local const z_crc_t FAR crc_braid_table[][256] = { - {0x00000000, 0x9ba54c6f, 0xec3b9e9f, 0x779ed2f0, 0x03063b7f, - 0x98a37710, 0xef3da5e0, 0x7498e98f, 0x060c76fe, 0x9da93a91, - 0xea37e861, 0x7192a40e, 0x050a4d81, 0x9eaf01ee, 0xe931d31e, - 0x72949f71, 0x0c18edfc, 0x97bda193, 0xe0237363, 0x7b863f0c, - 0x0f1ed683, 0x94bb9aec, 0xe325481c, 0x78800473, 0x0a149b02, - 0x91b1d76d, 0xe62f059d, 0x7d8a49f2, 0x0912a07d, 0x92b7ec12, - 0xe5293ee2, 0x7e8c728d, 0x1831dbf8, 0x83949797, 0xf40a4567, - 0x6faf0908, 0x1b37e087, 0x8092ace8, 0xf70c7e18, 0x6ca93277, - 0x1e3dad06, 0x8598e169, 0xf2063399, 0x69a37ff6, 0x1d3b9679, - 0x869eda16, 0xf10008e6, 0x6aa54489, 0x14293604, 0x8f8c7a6b, - 0xf812a89b, 0x63b7e4f4, 0x172f0d7b, 0x8c8a4114, 0xfb1493e4, - 0x60b1df8b, 0x122540fa, 0x89800c95, 0xfe1ede65, 0x65bb920a, - 0x11237b85, 0x8a8637ea, 0xfd18e51a, 0x66bda975, 0x3063b7f0, - 0xabc6fb9f, 0xdc58296f, 0x47fd6500, 0x33658c8f, 0xa8c0c0e0, - 0xdf5e1210, 0x44fb5e7f, 0x366fc10e, 0xadca8d61, 0xda545f91, - 0x41f113fe, 0x3569fa71, 0xaeccb61e, 0xd95264ee, 0x42f72881, - 0x3c7b5a0c, 0xa7de1663, 0xd040c493, 0x4be588fc, 0x3f7d6173, - 0xa4d82d1c, 0xd346ffec, 0x48e3b383, 0x3a772cf2, 0xa1d2609d, - 0xd64cb26d, 0x4de9fe02, 0x3971178d, 0xa2d45be2, 0xd54a8912, - 0x4eefc57d, 0x28526c08, 0xb3f72067, 0xc469f297, 0x5fccbef8, - 0x2b545777, 0xb0f11b18, 0xc76fc9e8, 0x5cca8587, 0x2e5e1af6, - 0xb5fb5699, 0xc2658469, 0x59c0c806, 0x2d582189, 0xb6fd6de6, - 0xc163bf16, 0x5ac6f379, 0x244a81f4, 0xbfefcd9b, 0xc8711f6b, - 0x53d45304, 0x274cba8b, 0xbce9f6e4, 0xcb772414, 0x50d2687b, - 0x2246f70a, 0xb9e3bb65, 0xce7d6995, 0x55d825fa, 0x2140cc75, - 0xbae5801a, 0xcd7b52ea, 0x56de1e85, 0x60c76fe0, 0xfb62238f, - 0x8cfcf17f, 0x1759bd10, 0x63c1549f, 0xf86418f0, 0x8ffaca00, - 0x145f866f, 0x66cb191e, 0xfd6e5571, 0x8af08781, 0x1155cbee, - 0x65cd2261, 0xfe686e0e, 0x89f6bcfe, 0x1253f091, 0x6cdf821c, - 0xf77ace73, 0x80e41c83, 0x1b4150ec, 0x6fd9b963, 0xf47cf50c, - 0x83e227fc, 0x18476b93, 0x6ad3f4e2, 0xf176b88d, 0x86e86a7d, - 0x1d4d2612, 0x69d5cf9d, 0xf27083f2, 0x85ee5102, 0x1e4b1d6d, - 0x78f6b418, 0xe353f877, 0x94cd2a87, 0x0f6866e8, 0x7bf08f67, - 0xe055c308, 0x97cb11f8, 0x0c6e5d97, 0x7efac2e6, 0xe55f8e89, - 0x92c15c79, 0x09641016, 0x7dfcf999, 0xe659b5f6, 0x91c76706, - 0x0a622b69, 0x74ee59e4, 0xef4b158b, 0x98d5c77b, 0x03708b14, - 0x77e8629b, 0xec4d2ef4, 0x9bd3fc04, 0x0076b06b, 0x72e22f1a, - 0xe9476375, 0x9ed9b185, 0x057cfdea, 0x71e41465, 0xea41580a, - 0x9ddf8afa, 0x067ac695, 0x50a4d810, 0xcb01947f, 0xbc9f468f, - 0x273a0ae0, 0x53a2e36f, 0xc807af00, 0xbf997df0, 0x243c319f, - 0x56a8aeee, 0xcd0de281, 0xba933071, 0x21367c1e, 0x55ae9591, - 0xce0bd9fe, 0xb9950b0e, 0x22304761, 0x5cbc35ec, 0xc7197983, - 0xb087ab73, 0x2b22e71c, 0x5fba0e93, 0xc41f42fc, 0xb381900c, - 0x2824dc63, 0x5ab04312, 0xc1150f7d, 0xb68bdd8d, 0x2d2e91e2, - 0x59b6786d, 0xc2133402, 0xb58de6f2, 0x2e28aa9d, 0x489503e8, - 0xd3304f87, 0xa4ae9d77, 0x3f0bd118, 0x4b933897, 0xd03674f8, - 0xa7a8a608, 0x3c0dea67, 0x4e997516, 0xd53c3979, 0xa2a2eb89, - 0x3907a7e6, 0x4d9f4e69, 0xd63a0206, 0xa1a4d0f6, 0x3a019c99, - 0x448dee14, 0xdf28a27b, 0xa8b6708b, 0x33133ce4, 0x478bd56b, - 0xdc2e9904, 0xabb04bf4, 0x3015079b, 0x428198ea, 0xd924d485, - 0xaeba0675, 0x351f4a1a, 0x4187a395, 0xda22effa, 0xadbc3d0a, - 0x36197165}, - {0x00000000, 0xc18edfc0, 0x586cb9c1, 0x99e26601, 0xb0d97382, - 0x7157ac42, 0xe8b5ca43, 0x293b1583, 0xbac3e145, 0x7b4d3e85, - 0xe2af5884, 0x23218744, 0x0a1a92c7, 0xcb944d07, 0x52762b06, - 0x93f8f4c6, 0xaef6c4cb, 0x6f781b0b, 0xf69a7d0a, 0x3714a2ca, - 0x1e2fb749, 0xdfa16889, 0x46430e88, 0x87cdd148, 0x1435258e, - 0xd5bbfa4e, 0x4c599c4f, 0x8dd7438f, 0xa4ec560c, 0x656289cc, - 0xfc80efcd, 0x3d0e300d, 0x869c8fd7, 0x47125017, 0xdef03616, - 0x1f7ee9d6, 0x3645fc55, 0xf7cb2395, 0x6e294594, 0xafa79a54, - 0x3c5f6e92, 0xfdd1b152, 0x6433d753, 0xa5bd0893, 0x8c861d10, - 0x4d08c2d0, 0xd4eaa4d1, 0x15647b11, 0x286a4b1c, 0xe9e494dc, - 0x7006f2dd, 0xb1882d1d, 0x98b3389e, 0x593de75e, 0xc0df815f, - 0x01515e9f, 0x92a9aa59, 0x53277599, 0xcac51398, 0x0b4bcc58, - 0x2270d9db, 0xe3fe061b, 0x7a1c601a, 0xbb92bfda, 0xd64819ef, - 0x17c6c62f, 0x8e24a02e, 0x4faa7fee, 0x66916a6d, 0xa71fb5ad, - 0x3efdd3ac, 0xff730c6c, 0x6c8bf8aa, 0xad05276a, 0x34e7416b, - 0xf5699eab, 0xdc528b28, 0x1ddc54e8, 0x843e32e9, 0x45b0ed29, - 0x78bedd24, 0xb93002e4, 0x20d264e5, 0xe15cbb25, 0xc867aea6, - 0x09e97166, 0x900b1767, 0x5185c8a7, 0xc27d3c61, 0x03f3e3a1, - 0x9a1185a0, 0x5b9f5a60, 0x72a44fe3, 0xb32a9023, 0x2ac8f622, - 0xeb4629e2, 0x50d49638, 0x915a49f8, 0x08b82ff9, 0xc936f039, - 0xe00de5ba, 0x21833a7a, 0xb8615c7b, 0x79ef83bb, 0xea17777d, - 0x2b99a8bd, 0xb27bcebc, 0x73f5117c, 0x5ace04ff, 0x9b40db3f, - 0x02a2bd3e, 0xc32c62fe, 0xfe2252f3, 0x3fac8d33, 0xa64eeb32, - 0x67c034f2, 0x4efb2171, 0x8f75feb1, 0x169798b0, 0xd7194770, - 0x44e1b3b6, 0x856f6c76, 0x1c8d0a77, 0xdd03d5b7, 0xf438c034, - 0x35b61ff4, 0xac5479f5, 0x6ddaa635, 0x77e1359f, 0xb66fea5f, - 0x2f8d8c5e, 0xee03539e, 0xc738461d, 0x06b699dd, 0x9f54ffdc, - 0x5eda201c, 0xcd22d4da, 0x0cac0b1a, 0x954e6d1b, 0x54c0b2db, - 0x7dfba758, 0xbc757898, 0x25971e99, 0xe419c159, 0xd917f154, - 0x18992e94, 0x817b4895, 0x40f59755, 0x69ce82d6, 0xa8405d16, - 0x31a23b17, 0xf02ce4d7, 0x63d41011, 0xa25acfd1, 0x3bb8a9d0, - 0xfa367610, 0xd30d6393, 0x1283bc53, 0x8b61da52, 0x4aef0592, - 0xf17dba48, 0x30f36588, 0xa9110389, 0x689fdc49, 0x41a4c9ca, - 0x802a160a, 0x19c8700b, 0xd846afcb, 0x4bbe5b0d, 0x8a3084cd, - 0x13d2e2cc, 0xd25c3d0c, 0xfb67288f, 0x3ae9f74f, 0xa30b914e, - 0x62854e8e, 0x5f8b7e83, 0x9e05a143, 0x07e7c742, 0xc6691882, - 0xef520d01, 0x2edcd2c1, 0xb73eb4c0, 0x76b06b00, 0xe5489fc6, - 0x24c64006, 0xbd242607, 0x7caaf9c7, 0x5591ec44, 0x941f3384, - 0x0dfd5585, 0xcc738a45, 0xa1a92c70, 0x6027f3b0, 0xf9c595b1, - 0x384b4a71, 0x11705ff2, 0xd0fe8032, 0x491ce633, 0x889239f3, - 0x1b6acd35, 0xdae412f5, 0x430674f4, 0x8288ab34, 0xabb3beb7, - 0x6a3d6177, 0xf3df0776, 0x3251d8b6, 0x0f5fe8bb, 0xced1377b, - 0x5733517a, 0x96bd8eba, 0xbf869b39, 0x7e0844f9, 0xe7ea22f8, - 0x2664fd38, 0xb59c09fe, 0x7412d63e, 0xedf0b03f, 0x2c7e6fff, - 0x05457a7c, 0xc4cba5bc, 0x5d29c3bd, 0x9ca71c7d, 0x2735a3a7, - 0xe6bb7c67, 0x7f591a66, 0xbed7c5a6, 0x97ecd025, 0x56620fe5, - 0xcf8069e4, 0x0e0eb624, 0x9df642e2, 0x5c789d22, 0xc59afb23, - 0x041424e3, 0x2d2f3160, 0xeca1eea0, 0x754388a1, 0xb4cd5761, - 0x89c3676c, 0x484db8ac, 0xd1afdead, 0x1021016d, 0x391a14ee, - 0xf894cb2e, 0x6176ad2f, 0xa0f872ef, 0x33008629, 0xf28e59e9, - 0x6b6c3fe8, 0xaae2e028, 0x83d9f5ab, 0x42572a6b, 0xdbb54c6a, - 0x1a3b93aa}, - {0x00000000, 0xefc26b3e, 0x04f5d03d, 0xeb37bb03, 0x09eba07a, - 0xe629cb44, 0x0d1e7047, 0xe2dc1b79, 0x13d740f4, 0xfc152bca, - 0x172290c9, 0xf8e0fbf7, 0x1a3ce08e, 0xf5fe8bb0, 0x1ec930b3, - 0xf10b5b8d, 0x27ae81e8, 0xc86cead6, 0x235b51d5, 0xcc993aeb, - 0x2e452192, 0xc1874aac, 0x2ab0f1af, 0xc5729a91, 0x3479c11c, - 0xdbbbaa22, 0x308c1121, 0xdf4e7a1f, 0x3d926166, 0xd2500a58, - 0x3967b15b, 0xd6a5da65, 0x4f5d03d0, 0xa09f68ee, 0x4ba8d3ed, - 0xa46ab8d3, 0x46b6a3aa, 0xa974c894, 0x42437397, 0xad8118a9, - 0x5c8a4324, 0xb348281a, 0x587f9319, 0xb7bdf827, 0x5561e35e, - 0xbaa38860, 0x51943363, 0xbe56585d, 0x68f38238, 0x8731e906, - 0x6c065205, 0x83c4393b, 0x61182242, 0x8eda497c, 0x65edf27f, - 0x8a2f9941, 0x7b24c2cc, 0x94e6a9f2, 0x7fd112f1, 0x901379cf, - 0x72cf62b6, 0x9d0d0988, 0x763ab28b, 0x99f8d9b5, 0x9eba07a0, - 0x71786c9e, 0x9a4fd79d, 0x758dbca3, 0x9751a7da, 0x7893cce4, - 0x93a477e7, 0x7c661cd9, 0x8d6d4754, 0x62af2c6a, 0x89989769, - 0x665afc57, 0x8486e72e, 0x6b448c10, 0x80733713, 0x6fb15c2d, - 0xb9148648, 0x56d6ed76, 0xbde15675, 0x52233d4b, 0xb0ff2632, - 0x5f3d4d0c, 0xb40af60f, 0x5bc89d31, 0xaac3c6bc, 0x4501ad82, - 0xae361681, 0x41f47dbf, 0xa32866c6, 0x4cea0df8, 0xa7ddb6fb, - 0x481fddc5, 0xd1e70470, 0x3e256f4e, 0xd512d44d, 0x3ad0bf73, - 0xd80ca40a, 0x37cecf34, 0xdcf97437, 0x333b1f09, 0xc2304484, - 0x2df22fba, 0xc6c594b9, 0x2907ff87, 0xcbdbe4fe, 0x24198fc0, - 0xcf2e34c3, 0x20ec5ffd, 0xf6498598, 0x198beea6, 0xf2bc55a5, - 0x1d7e3e9b, 0xffa225e2, 0x10604edc, 0xfb57f5df, 0x14959ee1, - 0xe59ec56c, 0x0a5cae52, 0xe16b1551, 0x0ea97e6f, 0xec756516, - 0x03b70e28, 0xe880b52b, 0x0742de15, 0xe6050901, 0x09c7623f, - 0xe2f0d93c, 0x0d32b202, 0xefeea97b, 0x002cc245, 0xeb1b7946, - 0x04d91278, 0xf5d249f5, 0x1a1022cb, 0xf12799c8, 0x1ee5f2f6, - 0xfc39e98f, 0x13fb82b1, 0xf8cc39b2, 0x170e528c, 0xc1ab88e9, - 0x2e69e3d7, 0xc55e58d4, 0x2a9c33ea, 0xc8402893, 0x278243ad, - 0xccb5f8ae, 0x23779390, 0xd27cc81d, 0x3dbea323, 0xd6891820, - 0x394b731e, 0xdb976867, 0x34550359, 0xdf62b85a, 0x30a0d364, - 0xa9580ad1, 0x469a61ef, 0xadaddaec, 0x426fb1d2, 0xa0b3aaab, - 0x4f71c195, 0xa4467a96, 0x4b8411a8, 0xba8f4a25, 0x554d211b, - 0xbe7a9a18, 0x51b8f126, 0xb364ea5f, 0x5ca68161, 0xb7913a62, - 0x5853515c, 0x8ef68b39, 0x6134e007, 0x8a035b04, 0x65c1303a, - 0x871d2b43, 0x68df407d, 0x83e8fb7e, 0x6c2a9040, 0x9d21cbcd, - 0x72e3a0f3, 0x99d41bf0, 0x761670ce, 0x94ca6bb7, 0x7b080089, - 0x903fbb8a, 0x7ffdd0b4, 0x78bf0ea1, 0x977d659f, 0x7c4ade9c, - 0x9388b5a2, 0x7154aedb, 0x9e96c5e5, 0x75a17ee6, 0x9a6315d8, - 0x6b684e55, 0x84aa256b, 0x6f9d9e68, 0x805ff556, 0x6283ee2f, - 0x8d418511, 0x66763e12, 0x89b4552c, 0x5f118f49, 0xb0d3e477, - 0x5be45f74, 0xb426344a, 0x56fa2f33, 0xb938440d, 0x520fff0e, - 0xbdcd9430, 0x4cc6cfbd, 0xa304a483, 0x48331f80, 0xa7f174be, - 0x452d6fc7, 0xaaef04f9, 0x41d8bffa, 0xae1ad4c4, 0x37e20d71, - 0xd820664f, 0x3317dd4c, 0xdcd5b672, 0x3e09ad0b, 0xd1cbc635, - 0x3afc7d36, 0xd53e1608, 0x24354d85, 0xcbf726bb, 0x20c09db8, - 0xcf02f686, 0x2ddeedff, 0xc21c86c1, 0x292b3dc2, 0xc6e956fc, - 0x104c8c99, 0xff8ee7a7, 0x14b95ca4, 0xfb7b379a, 0x19a72ce3, - 0xf66547dd, 0x1d52fcde, 0xf29097e0, 0x039bcc6d, 0xec59a753, - 0x076e1c50, 0xe8ac776e, 0x0a706c17, 0xe5b20729, 0x0e85bc2a, - 0xe147d714}, - {0x00000000, 0x177b1443, 0x2ef62886, 0x398d3cc5, 0x5dec510c, - 0x4a97454f, 0x731a798a, 0x64616dc9, 0xbbd8a218, 0xaca3b65b, - 0x952e8a9e, 0x82559edd, 0xe634f314, 0xf14fe757, 0xc8c2db92, - 0xdfb9cfd1, 0xacc04271, 0xbbbb5632, 0x82366af7, 0x954d7eb4, - 0xf12c137d, 0xe657073e, 0xdfda3bfb, 0xc8a12fb8, 0x1718e069, - 0x0063f42a, 0x39eec8ef, 0x2e95dcac, 0x4af4b165, 0x5d8fa526, - 0x640299e3, 0x73798da0, 0x82f182a3, 0x958a96e0, 0xac07aa25, - 0xbb7cbe66, 0xdf1dd3af, 0xc866c7ec, 0xf1ebfb29, 0xe690ef6a, - 0x392920bb, 0x2e5234f8, 0x17df083d, 0x00a41c7e, 0x64c571b7, - 0x73be65f4, 0x4a335931, 0x5d484d72, 0x2e31c0d2, 0x394ad491, - 0x00c7e854, 0x17bcfc17, 0x73dd91de, 0x64a6859d, 0x5d2bb958, - 0x4a50ad1b, 0x95e962ca, 0x82927689, 0xbb1f4a4c, 0xac645e0f, - 0xc80533c6, 0xdf7e2785, 0xe6f31b40, 0xf1880f03, 0xde920307, - 0xc9e91744, 0xf0642b81, 0xe71f3fc2, 0x837e520b, 0x94054648, - 0xad887a8d, 0xbaf36ece, 0x654aa11f, 0x7231b55c, 0x4bbc8999, - 0x5cc79dda, 0x38a6f013, 0x2fdde450, 0x1650d895, 0x012bccd6, - 0x72524176, 0x65295535, 0x5ca469f0, 0x4bdf7db3, 0x2fbe107a, - 0x38c50439, 0x014838fc, 0x16332cbf, 0xc98ae36e, 0xdef1f72d, - 0xe77ccbe8, 0xf007dfab, 0x9466b262, 0x831da621, 0xba909ae4, - 0xadeb8ea7, 0x5c6381a4, 0x4b1895e7, 0x7295a922, 0x65eebd61, - 0x018fd0a8, 0x16f4c4eb, 0x2f79f82e, 0x3802ec6d, 0xe7bb23bc, - 0xf0c037ff, 0xc94d0b3a, 0xde361f79, 0xba5772b0, 0xad2c66f3, - 0x94a15a36, 0x83da4e75, 0xf0a3c3d5, 0xe7d8d796, 0xde55eb53, - 0xc92eff10, 0xad4f92d9, 0xba34869a, 0x83b9ba5f, 0x94c2ae1c, - 0x4b7b61cd, 0x5c00758e, 0x658d494b, 0x72f65d08, 0x169730c1, - 0x01ec2482, 0x38611847, 0x2f1a0c04, 0x6655004f, 0x712e140c, - 0x48a328c9, 0x5fd83c8a, 0x3bb95143, 0x2cc24500, 0x154f79c5, - 0x02346d86, 0xdd8da257, 0xcaf6b614, 0xf37b8ad1, 0xe4009e92, - 0x8061f35b, 0x971ae718, 0xae97dbdd, 0xb9eccf9e, 0xca95423e, - 0xddee567d, 0xe4636ab8, 0xf3187efb, 0x97791332, 0x80020771, - 0xb98f3bb4, 0xaef42ff7, 0x714de026, 0x6636f465, 0x5fbbc8a0, - 0x48c0dce3, 0x2ca1b12a, 0x3bdaa569, 0x025799ac, 0x152c8def, - 0xe4a482ec, 0xf3df96af, 0xca52aa6a, 0xdd29be29, 0xb948d3e0, - 0xae33c7a3, 0x97befb66, 0x80c5ef25, 0x5f7c20f4, 0x480734b7, - 0x718a0872, 0x66f11c31, 0x029071f8, 0x15eb65bb, 0x2c66597e, - 0x3b1d4d3d, 0x4864c09d, 0x5f1fd4de, 0x6692e81b, 0x71e9fc58, - 0x15889191, 0x02f385d2, 0x3b7eb917, 0x2c05ad54, 0xf3bc6285, - 0xe4c776c6, 0xdd4a4a03, 0xca315e40, 0xae503389, 0xb92b27ca, - 0x80a61b0f, 0x97dd0f4c, 0xb8c70348, 0xafbc170b, 0x96312bce, - 0x814a3f8d, 0xe52b5244, 0xf2504607, 0xcbdd7ac2, 0xdca66e81, - 0x031fa150, 0x1464b513, 0x2de989d6, 0x3a929d95, 0x5ef3f05c, - 0x4988e41f, 0x7005d8da, 0x677ecc99, 0x14074139, 0x037c557a, - 0x3af169bf, 0x2d8a7dfc, 0x49eb1035, 0x5e900476, 0x671d38b3, - 0x70662cf0, 0xafdfe321, 0xb8a4f762, 0x8129cba7, 0x9652dfe4, - 0xf233b22d, 0xe548a66e, 0xdcc59aab, 0xcbbe8ee8, 0x3a3681eb, - 0x2d4d95a8, 0x14c0a96d, 0x03bbbd2e, 0x67dad0e7, 0x70a1c4a4, - 0x492cf861, 0x5e57ec22, 0x81ee23f3, 0x969537b0, 0xaf180b75, - 0xb8631f36, 0xdc0272ff, 0xcb7966bc, 0xf2f45a79, 0xe58f4e3a, - 0x96f6c39a, 0x818dd7d9, 0xb800eb1c, 0xaf7bff5f, 0xcb1a9296, - 0xdc6186d5, 0xe5ecba10, 0xf297ae53, 0x2d2e6182, 0x3a5575c1, - 0x03d84904, 0x14a35d47, 0x70c2308e, 0x67b924cd, 0x5e341808, - 0x494f0c4b}}; - -local const z_word_t FAR crc_braid_big_table[][256] = { - {0x00000000, 0x43147b17, 0x8628f62e, 0xc53c8d39, 0x0c51ec5d, - 0x4f45974a, 0x8a791a73, 0xc96d6164, 0x18a2d8bb, 0x5bb6a3ac, - 0x9e8a2e95, 0xdd9e5582, 0x14f334e6, 0x57e74ff1, 0x92dbc2c8, - 0xd1cfb9df, 0x7142c0ac, 0x3256bbbb, 0xf76a3682, 0xb47e4d95, - 0x7d132cf1, 0x3e0757e6, 0xfb3bdadf, 0xb82fa1c8, 0x69e01817, - 0x2af46300, 0xefc8ee39, 0xacdc952e, 0x65b1f44a, 0x26a58f5d, - 0xe3990264, 0xa08d7973, 0xa382f182, 0xe0968a95, 0x25aa07ac, - 0x66be7cbb, 0xafd31ddf, 0xecc766c8, 0x29fbebf1, 0x6aef90e6, - 0xbb202939, 0xf834522e, 0x3d08df17, 0x7e1ca400, 0xb771c564, - 0xf465be73, 0x3159334a, 0x724d485d, 0xd2c0312e, 0x91d44a39, - 0x54e8c700, 0x17fcbc17, 0xde91dd73, 0x9d85a664, 0x58b92b5d, - 0x1bad504a, 0xca62e995, 0x89769282, 0x4c4a1fbb, 0x0f5e64ac, - 0xc63305c8, 0x85277edf, 0x401bf3e6, 0x030f88f1, 0x070392de, - 0x4417e9c9, 0x812b64f0, 0xc23f1fe7, 0x0b527e83, 0x48460594, - 0x8d7a88ad, 0xce6ef3ba, 0x1fa14a65, 0x5cb53172, 0x9989bc4b, - 0xda9dc75c, 0x13f0a638, 0x50e4dd2f, 0x95d85016, 0xd6cc2b01, - 0x76415272, 0x35552965, 0xf069a45c, 0xb37ddf4b, 0x7a10be2f, - 0x3904c538, 0xfc384801, 0xbf2c3316, 0x6ee38ac9, 0x2df7f1de, - 0xe8cb7ce7, 0xabdf07f0, 0x62b26694, 0x21a61d83, 0xe49a90ba, - 0xa78eebad, 0xa481635c, 0xe795184b, 0x22a99572, 0x61bdee65, - 0xa8d08f01, 0xebc4f416, 0x2ef8792f, 0x6dec0238, 0xbc23bbe7, - 0xff37c0f0, 0x3a0b4dc9, 0x791f36de, 0xb07257ba, 0xf3662cad, - 0x365aa194, 0x754eda83, 0xd5c3a3f0, 0x96d7d8e7, 0x53eb55de, - 0x10ff2ec9, 0xd9924fad, 0x9a8634ba, 0x5fbab983, 0x1caec294, - 0xcd617b4b, 0x8e75005c, 0x4b498d65, 0x085df672, 0xc1309716, - 0x8224ec01, 0x47186138, 0x040c1a2f, 0x4f005566, 0x0c142e71, - 0xc928a348, 0x8a3cd85f, 0x4351b93b, 0x0045c22c, 0xc5794f15, - 0x866d3402, 0x57a28ddd, 0x14b6f6ca, 0xd18a7bf3, 0x929e00e4, - 0x5bf36180, 0x18e71a97, 0xdddb97ae, 0x9ecfecb9, 0x3e4295ca, - 0x7d56eedd, 0xb86a63e4, 0xfb7e18f3, 0x32137997, 0x71070280, - 0xb43b8fb9, 0xf72ff4ae, 0x26e04d71, 0x65f43666, 0xa0c8bb5f, - 0xe3dcc048, 0x2ab1a12c, 0x69a5da3b, 0xac995702, 0xef8d2c15, - 0xec82a4e4, 0xaf96dff3, 0x6aaa52ca, 0x29be29dd, 0xe0d348b9, - 0xa3c733ae, 0x66fbbe97, 0x25efc580, 0xf4207c5f, 0xb7340748, - 0x72088a71, 0x311cf166, 0xf8719002, 0xbb65eb15, 0x7e59662c, - 0x3d4d1d3b, 0x9dc06448, 0xded41f5f, 0x1be89266, 0x58fce971, - 0x91918815, 0xd285f302, 0x17b97e3b, 0x54ad052c, 0x8562bcf3, - 0xc676c7e4, 0x034a4add, 0x405e31ca, 0x893350ae, 0xca272bb9, - 0x0f1ba680, 0x4c0fdd97, 0x4803c7b8, 0x0b17bcaf, 0xce2b3196, - 0x8d3f4a81, 0x44522be5, 0x074650f2, 0xc27addcb, 0x816ea6dc, - 0x50a11f03, 0x13b56414, 0xd689e92d, 0x959d923a, 0x5cf0f35e, - 0x1fe48849, 0xdad80570, 0x99cc7e67, 0x39410714, 0x7a557c03, - 0xbf69f13a, 0xfc7d8a2d, 0x3510eb49, 0x7604905e, 0xb3381d67, - 0xf02c6670, 0x21e3dfaf, 0x62f7a4b8, 0xa7cb2981, 0xe4df5296, - 0x2db233f2, 0x6ea648e5, 0xab9ac5dc, 0xe88ebecb, 0xeb81363a, - 0xa8954d2d, 0x6da9c014, 0x2ebdbb03, 0xe7d0da67, 0xa4c4a170, - 0x61f82c49, 0x22ec575e, 0xf323ee81, 0xb0379596, 0x750b18af, - 0x361f63b8, 0xff7202dc, 0xbc6679cb, 0x795af4f2, 0x3a4e8fe5, - 0x9ac3f696, 0xd9d78d81, 0x1ceb00b8, 0x5fff7baf, 0x96921acb, - 0xd58661dc, 0x10baece5, 0x53ae97f2, 0x82612e2d, 0xc175553a, - 0x0449d803, 0x475da314, 0x8e30c270, 0xcd24b967, 0x0818345e, - 0x4b0c4f49}, - {0x00000000, 0x3e6bc2ef, 0x3dd0f504, 0x03bb37eb, 0x7aa0eb09, - 0x44cb29e6, 0x47701e0d, 0x791bdce2, 0xf440d713, 0xca2b15fc, - 0xc9902217, 0xf7fbe0f8, 0x8ee03c1a, 0xb08bfef5, 0xb330c91e, - 0x8d5b0bf1, 0xe881ae27, 0xd6ea6cc8, 0xd5515b23, 0xeb3a99cc, - 0x9221452e, 0xac4a87c1, 0xaff1b02a, 0x919a72c5, 0x1cc17934, - 0x22aabbdb, 0x21118c30, 0x1f7a4edf, 0x6661923d, 0x580a50d2, - 0x5bb16739, 0x65daa5d6, 0xd0035d4f, 0xee689fa0, 0xedd3a84b, - 0xd3b86aa4, 0xaaa3b646, 0x94c874a9, 0x97734342, 0xa91881ad, - 0x24438a5c, 0x1a2848b3, 0x19937f58, 0x27f8bdb7, 0x5ee36155, - 0x6088a3ba, 0x63339451, 0x5d5856be, 0x3882f368, 0x06e93187, - 0x0552066c, 0x3b39c483, 0x42221861, 0x7c49da8e, 0x7ff2ed65, - 0x41992f8a, 0xccc2247b, 0xf2a9e694, 0xf112d17f, 0xcf791390, - 0xb662cf72, 0x88090d9d, 0x8bb23a76, 0xb5d9f899, 0xa007ba9e, - 0x9e6c7871, 0x9dd74f9a, 0xa3bc8d75, 0xdaa75197, 0xe4cc9378, - 0xe777a493, 0xd91c667c, 0x54476d8d, 0x6a2caf62, 0x69979889, - 0x57fc5a66, 0x2ee78684, 0x108c446b, 0x13377380, 0x2d5cb16f, - 0x488614b9, 0x76edd656, 0x7556e1bd, 0x4b3d2352, 0x3226ffb0, - 0x0c4d3d5f, 0x0ff60ab4, 0x319dc85b, 0xbcc6c3aa, 0x82ad0145, - 0x811636ae, 0xbf7df441, 0xc66628a3, 0xf80dea4c, 0xfbb6dda7, - 0xc5dd1f48, 0x7004e7d1, 0x4e6f253e, 0x4dd412d5, 0x73bfd03a, - 0x0aa40cd8, 0x34cfce37, 0x3774f9dc, 0x091f3b33, 0x844430c2, - 0xba2ff22d, 0xb994c5c6, 0x87ff0729, 0xfee4dbcb, 0xc08f1924, - 0xc3342ecf, 0xfd5fec20, 0x988549f6, 0xa6ee8b19, 0xa555bcf2, - 0x9b3e7e1d, 0xe225a2ff, 0xdc4e6010, 0xdff557fb, 0xe19e9514, - 0x6cc59ee5, 0x52ae5c0a, 0x51156be1, 0x6f7ea90e, 0x166575ec, - 0x280eb703, 0x2bb580e8, 0x15de4207, 0x010905e6, 0x3f62c709, - 0x3cd9f0e2, 0x02b2320d, 0x7ba9eeef, 0x45c22c00, 0x46791beb, - 0x7812d904, 0xf549d2f5, 0xcb22101a, 0xc89927f1, 0xf6f2e51e, - 0x8fe939fc, 0xb182fb13, 0xb239ccf8, 0x8c520e17, 0xe988abc1, - 0xd7e3692e, 0xd4585ec5, 0xea339c2a, 0x932840c8, 0xad438227, - 0xaef8b5cc, 0x90937723, 0x1dc87cd2, 0x23a3be3d, 0x201889d6, - 0x1e734b39, 0x676897db, 0x59035534, 0x5ab862df, 0x64d3a030, - 0xd10a58a9, 0xef619a46, 0xecdaadad, 0xd2b16f42, 0xabaab3a0, - 0x95c1714f, 0x967a46a4, 0xa811844b, 0x254a8fba, 0x1b214d55, - 0x189a7abe, 0x26f1b851, 0x5fea64b3, 0x6181a65c, 0x623a91b7, - 0x5c515358, 0x398bf68e, 0x07e03461, 0x045b038a, 0x3a30c165, - 0x432b1d87, 0x7d40df68, 0x7efbe883, 0x40902a6c, 0xcdcb219d, - 0xf3a0e372, 0xf01bd499, 0xce701676, 0xb76bca94, 0x8900087b, - 0x8abb3f90, 0xb4d0fd7f, 0xa10ebf78, 0x9f657d97, 0x9cde4a7c, - 0xa2b58893, 0xdbae5471, 0xe5c5969e, 0xe67ea175, 0xd815639a, - 0x554e686b, 0x6b25aa84, 0x689e9d6f, 0x56f55f80, 0x2fee8362, - 0x1185418d, 0x123e7666, 0x2c55b489, 0x498f115f, 0x77e4d3b0, - 0x745fe45b, 0x4a3426b4, 0x332ffa56, 0x0d4438b9, 0x0eff0f52, - 0x3094cdbd, 0xbdcfc64c, 0x83a404a3, 0x801f3348, 0xbe74f1a7, - 0xc76f2d45, 0xf904efaa, 0xfabfd841, 0xc4d41aae, 0x710de237, - 0x4f6620d8, 0x4cdd1733, 0x72b6d5dc, 0x0bad093e, 0x35c6cbd1, - 0x367dfc3a, 0x08163ed5, 0x854d3524, 0xbb26f7cb, 0xb89dc020, - 0x86f602cf, 0xffedde2d, 0xc1861cc2, 0xc23d2b29, 0xfc56e9c6, - 0x998c4c10, 0xa7e78eff, 0xa45cb914, 0x9a377bfb, 0xe32ca719, - 0xdd4765f6, 0xdefc521d, 0xe09790f2, 0x6dcc9b03, 0x53a759ec, - 0x501c6e07, 0x6e77ace8, 0x176c700a, 0x2907b2e5, 0x2abc850e, - 0x14d747e1}, - {0x00000000, 0xc0df8ec1, 0xc1b96c58, 0x0166e299, 0x8273d9b0, - 0x42ac5771, 0x43cab5e8, 0x83153b29, 0x45e1c3ba, 0x853e4d7b, - 0x8458afe2, 0x44872123, 0xc7921a0a, 0x074d94cb, 0x062b7652, - 0xc6f4f893, 0xcbc4f6ae, 0x0b1b786f, 0x0a7d9af6, 0xcaa21437, - 0x49b72f1e, 0x8968a1df, 0x880e4346, 0x48d1cd87, 0x8e253514, - 0x4efabbd5, 0x4f9c594c, 0x8f43d78d, 0x0c56eca4, 0xcc896265, - 0xcdef80fc, 0x0d300e3d, 0xd78f9c86, 0x17501247, 0x1636f0de, - 0xd6e97e1f, 0x55fc4536, 0x9523cbf7, 0x9445296e, 0x549aa7af, - 0x926e5f3c, 0x52b1d1fd, 0x53d73364, 0x9308bda5, 0x101d868c, - 0xd0c2084d, 0xd1a4ead4, 0x117b6415, 0x1c4b6a28, 0xdc94e4e9, - 0xddf20670, 0x1d2d88b1, 0x9e38b398, 0x5ee73d59, 0x5f81dfc0, - 0x9f5e5101, 0x59aaa992, 0x99752753, 0x9813c5ca, 0x58cc4b0b, - 0xdbd97022, 0x1b06fee3, 0x1a601c7a, 0xdabf92bb, 0xef1948d6, - 0x2fc6c617, 0x2ea0248e, 0xee7faa4f, 0x6d6a9166, 0xadb51fa7, - 0xacd3fd3e, 0x6c0c73ff, 0xaaf88b6c, 0x6a2705ad, 0x6b41e734, - 0xab9e69f5, 0x288b52dc, 0xe854dc1d, 0xe9323e84, 0x29edb045, - 0x24ddbe78, 0xe40230b9, 0xe564d220, 0x25bb5ce1, 0xa6ae67c8, - 0x6671e909, 0x67170b90, 0xa7c88551, 0x613c7dc2, 0xa1e3f303, - 0xa085119a, 0x605a9f5b, 0xe34fa472, 0x23902ab3, 0x22f6c82a, - 0xe22946eb, 0x3896d450, 0xf8495a91, 0xf92fb808, 0x39f036c9, - 0xbae50de0, 0x7a3a8321, 0x7b5c61b8, 0xbb83ef79, 0x7d7717ea, - 0xbda8992b, 0xbcce7bb2, 0x7c11f573, 0xff04ce5a, 0x3fdb409b, - 0x3ebda202, 0xfe622cc3, 0xf35222fe, 0x338dac3f, 0x32eb4ea6, - 0xf234c067, 0x7121fb4e, 0xb1fe758f, 0xb0989716, 0x704719d7, - 0xb6b3e144, 0x766c6f85, 0x770a8d1c, 0xb7d503dd, 0x34c038f4, - 0xf41fb635, 0xf57954ac, 0x35a6da6d, 0x9f35e177, 0x5fea6fb6, - 0x5e8c8d2f, 0x9e5303ee, 0x1d4638c7, 0xdd99b606, 0xdcff549f, - 0x1c20da5e, 0xdad422cd, 0x1a0bac0c, 0x1b6d4e95, 0xdbb2c054, - 0x58a7fb7d, 0x987875bc, 0x991e9725, 0x59c119e4, 0x54f117d9, - 0x942e9918, 0x95487b81, 0x5597f540, 0xd682ce69, 0x165d40a8, - 0x173ba231, 0xd7e42cf0, 0x1110d463, 0xd1cf5aa2, 0xd0a9b83b, - 0x107636fa, 0x93630dd3, 0x53bc8312, 0x52da618b, 0x9205ef4a, - 0x48ba7df1, 0x8865f330, 0x890311a9, 0x49dc9f68, 0xcac9a441, - 0x0a162a80, 0x0b70c819, 0xcbaf46d8, 0x0d5bbe4b, 0xcd84308a, - 0xcce2d213, 0x0c3d5cd2, 0x8f2867fb, 0x4ff7e93a, 0x4e910ba3, - 0x8e4e8562, 0x837e8b5f, 0x43a1059e, 0x42c7e707, 0x821869c6, - 0x010d52ef, 0xc1d2dc2e, 0xc0b43eb7, 0x006bb076, 0xc69f48e5, - 0x0640c624, 0x072624bd, 0xc7f9aa7c, 0x44ec9155, 0x84331f94, - 0x8555fd0d, 0x458a73cc, 0x702ca9a1, 0xb0f32760, 0xb195c5f9, - 0x714a4b38, 0xf25f7011, 0x3280fed0, 0x33e61c49, 0xf3399288, - 0x35cd6a1b, 0xf512e4da, 0xf4740643, 0x34ab8882, 0xb7beb3ab, - 0x77613d6a, 0x7607dff3, 0xb6d85132, 0xbbe85f0f, 0x7b37d1ce, - 0x7a513357, 0xba8ebd96, 0x399b86bf, 0xf944087e, 0xf822eae7, - 0x38fd6426, 0xfe099cb5, 0x3ed61274, 0x3fb0f0ed, 0xff6f7e2c, - 0x7c7a4505, 0xbca5cbc4, 0xbdc3295d, 0x7d1ca79c, 0xa7a33527, - 0x677cbbe6, 0x661a597f, 0xa6c5d7be, 0x25d0ec97, 0xe50f6256, - 0xe46980cf, 0x24b60e0e, 0xe242f69d, 0x229d785c, 0x23fb9ac5, - 0xe3241404, 0x60312f2d, 0xa0eea1ec, 0xa1884375, 0x6157cdb4, - 0x6c67c389, 0xacb84d48, 0xaddeafd1, 0x6d012110, 0xee141a39, - 0x2ecb94f8, 0x2fad7661, 0xef72f8a0, 0x29860033, 0xe9598ef2, - 0xe83f6c6b, 0x28e0e2aa, 0xabf5d983, 0x6b2a5742, 0x6a4cb5db, - 0xaa933b1a}, - {0x00000000, 0x6f4ca59b, 0x9f9e3bec, 0xf0d29e77, 0x7f3b0603, - 0x1077a398, 0xe0a53def, 0x8fe99874, 0xfe760c06, 0x913aa99d, - 0x61e837ea, 0x0ea49271, 0x814d0a05, 0xee01af9e, 0x1ed331e9, - 0x719f9472, 0xfced180c, 0x93a1bd97, 0x637323e0, 0x0c3f867b, - 0x83d61e0f, 0xec9abb94, 0x1c4825e3, 0x73048078, 0x029b140a, - 0x6dd7b191, 0x9d052fe6, 0xf2498a7d, 0x7da01209, 0x12ecb792, - 0xe23e29e5, 0x8d728c7e, 0xf8db3118, 0x97979483, 0x67450af4, - 0x0809af6f, 0x87e0371b, 0xe8ac9280, 0x187e0cf7, 0x7732a96c, - 0x06ad3d1e, 0x69e19885, 0x993306f2, 0xf67fa369, 0x79963b1d, - 0x16da9e86, 0xe60800f1, 0x8944a56a, 0x04362914, 0x6b7a8c8f, - 0x9ba812f8, 0xf4e4b763, 0x7b0d2f17, 0x14418a8c, 0xe49314fb, - 0x8bdfb160, 0xfa402512, 0x950c8089, 0x65de1efe, 0x0a92bb65, - 0x857b2311, 0xea37868a, 0x1ae518fd, 0x75a9bd66, 0xf0b76330, - 0x9ffbc6ab, 0x6f2958dc, 0x0065fd47, 0x8f8c6533, 0xe0c0c0a8, - 0x10125edf, 0x7f5efb44, 0x0ec16f36, 0x618dcaad, 0x915f54da, - 0xfe13f141, 0x71fa6935, 0x1eb6ccae, 0xee6452d9, 0x8128f742, - 0x0c5a7b3c, 0x6316dea7, 0x93c440d0, 0xfc88e54b, 0x73617d3f, - 0x1c2dd8a4, 0xecff46d3, 0x83b3e348, 0xf22c773a, 0x9d60d2a1, - 0x6db24cd6, 0x02fee94d, 0x8d177139, 0xe25bd4a2, 0x12894ad5, - 0x7dc5ef4e, 0x086c5228, 0x6720f7b3, 0x97f269c4, 0xf8becc5f, - 0x7757542b, 0x181bf1b0, 0xe8c96fc7, 0x8785ca5c, 0xf61a5e2e, - 0x9956fbb5, 0x698465c2, 0x06c8c059, 0x8921582d, 0xe66dfdb6, - 0x16bf63c1, 0x79f3c65a, 0xf4814a24, 0x9bcdefbf, 0x6b1f71c8, - 0x0453d453, 0x8bba4c27, 0xe4f6e9bc, 0x142477cb, 0x7b68d250, - 0x0af74622, 0x65bbe3b9, 0x95697dce, 0xfa25d855, 0x75cc4021, - 0x1a80e5ba, 0xea527bcd, 0x851ede56, 0xe06fc760, 0x8f2362fb, - 0x7ff1fc8c, 0x10bd5917, 0x9f54c163, 0xf01864f8, 0x00cafa8f, - 0x6f865f14, 0x1e19cb66, 0x71556efd, 0x8187f08a, 0xeecb5511, - 0x6122cd65, 0x0e6e68fe, 0xfebcf689, 0x91f05312, 0x1c82df6c, - 0x73ce7af7, 0x831ce480, 0xec50411b, 0x63b9d96f, 0x0cf57cf4, - 0xfc27e283, 0x936b4718, 0xe2f4d36a, 0x8db876f1, 0x7d6ae886, - 0x12264d1d, 0x9dcfd569, 0xf28370f2, 0x0251ee85, 0x6d1d4b1e, - 0x18b4f678, 0x77f853e3, 0x872acd94, 0xe866680f, 0x678ff07b, - 0x08c355e0, 0xf811cb97, 0x975d6e0c, 0xe6c2fa7e, 0x898e5fe5, - 0x795cc192, 0x16106409, 0x99f9fc7d, 0xf6b559e6, 0x0667c791, - 0x692b620a, 0xe459ee74, 0x8b154bef, 0x7bc7d598, 0x148b7003, - 0x9b62e877, 0xf42e4dec, 0x04fcd39b, 0x6bb07600, 0x1a2fe272, - 0x756347e9, 0x85b1d99e, 0xeafd7c05, 0x6514e471, 0x0a5841ea, - 0xfa8adf9d, 0x95c67a06, 0x10d8a450, 0x7f9401cb, 0x8f469fbc, - 0xe00a3a27, 0x6fe3a253, 0x00af07c8, 0xf07d99bf, 0x9f313c24, - 0xeeaea856, 0x81e20dcd, 0x713093ba, 0x1e7c3621, 0x9195ae55, - 0xfed90bce, 0x0e0b95b9, 0x61473022, 0xec35bc5c, 0x837919c7, - 0x73ab87b0, 0x1ce7222b, 0x930eba5f, 0xfc421fc4, 0x0c9081b3, - 0x63dc2428, 0x1243b05a, 0x7d0f15c1, 0x8ddd8bb6, 0xe2912e2d, - 0x6d78b659, 0x023413c2, 0xf2e68db5, 0x9daa282e, 0xe8039548, - 0x874f30d3, 0x779daea4, 0x18d10b3f, 0x9738934b, 0xf87436d0, - 0x08a6a8a7, 0x67ea0d3c, 0x1675994e, 0x79393cd5, 0x89eba2a2, - 0xe6a70739, 0x694e9f4d, 0x06023ad6, 0xf6d0a4a1, 0x999c013a, - 0x14ee8d44, 0x7ba228df, 0x8b70b6a8, 0xe43c1333, 0x6bd58b47, - 0x04992edc, 0xf44bb0ab, 0x9b071530, 0xea988142, 0x85d424d9, - 0x7506baae, 0x1a4a1f35, 0x95a38741, 0xfaef22da, 0x0a3dbcad, - 0x65711936}}; - -#endif - -#endif - -#if N == 4 - -#if W == 8 - -local const z_crc_t FAR crc_braid_table[][256] = { - {0x00000000, 0xf1da05aa, 0x38c50d15, 0xc91f08bf, 0x718a1a2a, - 0x80501f80, 0x494f173f, 0xb8951295, 0xe3143454, 0x12ce31fe, - 0xdbd13941, 0x2a0b3ceb, 0x929e2e7e, 0x63442bd4, 0xaa5b236b, - 0x5b8126c1, 0x1d596ee9, 0xec836b43, 0x259c63fc, 0xd4466656, - 0x6cd374c3, 0x9d097169, 0x541679d6, 0xa5cc7c7c, 0xfe4d5abd, - 0x0f975f17, 0xc68857a8, 0x37525202, 0x8fc74097, 0x7e1d453d, - 0xb7024d82, 0x46d84828, 0x3ab2ddd2, 0xcb68d878, 0x0277d0c7, - 0xf3add56d, 0x4b38c7f8, 0xbae2c252, 0x73fdcaed, 0x8227cf47, - 0xd9a6e986, 0x287cec2c, 0xe163e493, 0x10b9e139, 0xa82cf3ac, - 0x59f6f606, 0x90e9feb9, 0x6133fb13, 0x27ebb33b, 0xd631b691, - 0x1f2ebe2e, 0xeef4bb84, 0x5661a911, 0xa7bbacbb, 0x6ea4a404, - 0x9f7ea1ae, 0xc4ff876f, 0x352582c5, 0xfc3a8a7a, 0x0de08fd0, - 0xb5759d45, 0x44af98ef, 0x8db09050, 0x7c6a95fa, 0x7565bba4, - 0x84bfbe0e, 0x4da0b6b1, 0xbc7ab31b, 0x04efa18e, 0xf535a424, - 0x3c2aac9b, 0xcdf0a931, 0x96718ff0, 0x67ab8a5a, 0xaeb482e5, - 0x5f6e874f, 0xe7fb95da, 0x16219070, 0xdf3e98cf, 0x2ee49d65, - 0x683cd54d, 0x99e6d0e7, 0x50f9d858, 0xa123ddf2, 0x19b6cf67, - 0xe86ccacd, 0x2173c272, 0xd0a9c7d8, 0x8b28e119, 0x7af2e4b3, - 0xb3edec0c, 0x4237e9a6, 0xfaa2fb33, 0x0b78fe99, 0xc267f626, - 0x33bdf38c, 0x4fd76676, 0xbe0d63dc, 0x77126b63, 0x86c86ec9, - 0x3e5d7c5c, 0xcf8779f6, 0x06987149, 0xf74274e3, 0xacc35222, - 0x5d195788, 0x94065f37, 0x65dc5a9d, 0xdd494808, 0x2c934da2, - 0xe58c451d, 0x145640b7, 0x528e089f, 0xa3540d35, 0x6a4b058a, - 0x9b910020, 0x230412b5, 0xd2de171f, 0x1bc11fa0, 0xea1b1a0a, - 0xb19a3ccb, 0x40403961, 0x895f31de, 0x78853474, 0xc01026e1, - 0x31ca234b, 0xf8d52bf4, 0x090f2e5e, 0xeacb7748, 0x1b1172e2, - 0xd20e7a5d, 0x23d47ff7, 0x9b416d62, 0x6a9b68c8, 0xa3846077, - 0x525e65dd, 0x09df431c, 0xf80546b6, 0x311a4e09, 0xc0c04ba3, - 0x78555936, 0x898f5c9c, 0x40905423, 0xb14a5189, 0xf79219a1, - 0x06481c0b, 0xcf5714b4, 0x3e8d111e, 0x8618038b, 0x77c20621, - 0xbedd0e9e, 0x4f070b34, 0x14862df5, 0xe55c285f, 0x2c4320e0, - 0xdd99254a, 0x650c37df, 0x94d63275, 0x5dc93aca, 0xac133f60, - 0xd079aa9a, 0x21a3af30, 0xe8bca78f, 0x1966a225, 0xa1f3b0b0, - 0x5029b51a, 0x9936bda5, 0x68ecb80f, 0x336d9ece, 0xc2b79b64, - 0x0ba893db, 0xfa729671, 0x42e784e4, 0xb33d814e, 0x7a2289f1, - 0x8bf88c5b, 0xcd20c473, 0x3cfac1d9, 0xf5e5c966, 0x043fcccc, - 0xbcaade59, 0x4d70dbf3, 0x846fd34c, 0x75b5d6e6, 0x2e34f027, - 0xdfeef58d, 0x16f1fd32, 0xe72bf898, 0x5fbeea0d, 0xae64efa7, - 0x677be718, 0x96a1e2b2, 0x9faeccec, 0x6e74c946, 0xa76bc1f9, - 0x56b1c453, 0xee24d6c6, 0x1ffed36c, 0xd6e1dbd3, 0x273bde79, - 0x7cbaf8b8, 0x8d60fd12, 0x447ff5ad, 0xb5a5f007, 0x0d30e292, - 0xfceae738, 0x35f5ef87, 0xc42fea2d, 0x82f7a205, 0x732da7af, - 0xba32af10, 0x4be8aaba, 0xf37db82f, 0x02a7bd85, 0xcbb8b53a, - 0x3a62b090, 0x61e39651, 0x903993fb, 0x59269b44, 0xa8fc9eee, - 0x10698c7b, 0xe1b389d1, 0x28ac816e, 0xd97684c4, 0xa51c113e, - 0x54c61494, 0x9dd91c2b, 0x6c031981, 0xd4960b14, 0x254c0ebe, - 0xec530601, 0x1d8903ab, 0x4608256a, 0xb7d220c0, 0x7ecd287f, - 0x8f172dd5, 0x37823f40, 0xc6583aea, 0x0f473255, 0xfe9d37ff, - 0xb8457fd7, 0x499f7a7d, 0x808072c2, 0x715a7768, 0xc9cf65fd, - 0x38156057, 0xf10a68e8, 0x00d06d42, 0x5b514b83, 0xaa8b4e29, - 0x63944696, 0x924e433c, 0x2adb51a9, 0xdb015403, 0x121e5cbc, - 0xe3c45916}, - {0x00000000, 0x0ee7e8d1, 0x1dcfd1a2, 0x13283973, 0x3b9fa344, - 0x35784b95, 0x265072e6, 0x28b79a37, 0x773f4688, 0x79d8ae59, - 0x6af0972a, 0x64177ffb, 0x4ca0e5cc, 0x42470d1d, 0x516f346e, - 0x5f88dcbf, 0xee7e8d10, 0xe09965c1, 0xf3b15cb2, 0xfd56b463, - 0xd5e12e54, 0xdb06c685, 0xc82efff6, 0xc6c91727, 0x9941cb98, - 0x97a62349, 0x848e1a3a, 0x8a69f2eb, 0xa2de68dc, 0xac39800d, - 0xbf11b97e, 0xb1f651af, 0x078c1c61, 0x096bf4b0, 0x1a43cdc3, - 0x14a42512, 0x3c13bf25, 0x32f457f4, 0x21dc6e87, 0x2f3b8656, - 0x70b35ae9, 0x7e54b238, 0x6d7c8b4b, 0x639b639a, 0x4b2cf9ad, - 0x45cb117c, 0x56e3280f, 0x5804c0de, 0xe9f29171, 0xe71579a0, - 0xf43d40d3, 0xfadaa802, 0xd26d3235, 0xdc8adae4, 0xcfa2e397, - 0xc1450b46, 0x9ecdd7f9, 0x902a3f28, 0x8302065b, 0x8de5ee8a, - 0xa55274bd, 0xabb59c6c, 0xb89da51f, 0xb67a4dce, 0x0f1838c2, - 0x01ffd013, 0x12d7e960, 0x1c3001b1, 0x34879b86, 0x3a607357, - 0x29484a24, 0x27afa2f5, 0x78277e4a, 0x76c0969b, 0x65e8afe8, - 0x6b0f4739, 0x43b8dd0e, 0x4d5f35df, 0x5e770cac, 0x5090e47d, - 0xe166b5d2, 0xef815d03, 0xfca96470, 0xf24e8ca1, 0xdaf91696, - 0xd41efe47, 0xc736c734, 0xc9d12fe5, 0x9659f35a, 0x98be1b8b, - 0x8b9622f8, 0x8571ca29, 0xadc6501e, 0xa321b8cf, 0xb00981bc, - 0xbeee696d, 0x089424a3, 0x0673cc72, 0x155bf501, 0x1bbc1dd0, - 0x330b87e7, 0x3dec6f36, 0x2ec45645, 0x2023be94, 0x7fab622b, - 0x714c8afa, 0x6264b389, 0x6c835b58, 0x4434c16f, 0x4ad329be, - 0x59fb10cd, 0x571cf81c, 0xe6eaa9b3, 0xe80d4162, 0xfb257811, - 0xf5c290c0, 0xdd750af7, 0xd392e226, 0xc0badb55, 0xce5d3384, - 0x91d5ef3b, 0x9f3207ea, 0x8c1a3e99, 0x82fdd648, 0xaa4a4c7f, - 0xa4ada4ae, 0xb7859ddd, 0xb962750c, 0x1e307184, 0x10d79955, - 0x03ffa026, 0x0d1848f7, 0x25afd2c0, 0x2b483a11, 0x38600362, - 0x3687ebb3, 0x690f370c, 0x67e8dfdd, 0x74c0e6ae, 0x7a270e7f, - 0x52909448, 0x5c777c99, 0x4f5f45ea, 0x41b8ad3b, 0xf04efc94, - 0xfea91445, 0xed812d36, 0xe366c5e7, 0xcbd15fd0, 0xc536b701, - 0xd61e8e72, 0xd8f966a3, 0x8771ba1c, 0x899652cd, 0x9abe6bbe, - 0x9459836f, 0xbcee1958, 0xb209f189, 0xa121c8fa, 0xafc6202b, - 0x19bc6de5, 0x175b8534, 0x0473bc47, 0x0a945496, 0x2223cea1, - 0x2cc42670, 0x3fec1f03, 0x310bf7d2, 0x6e832b6d, 0x6064c3bc, - 0x734cfacf, 0x7dab121e, 0x551c8829, 0x5bfb60f8, 0x48d3598b, - 0x4634b15a, 0xf7c2e0f5, 0xf9250824, 0xea0d3157, 0xe4ead986, - 0xcc5d43b1, 0xc2baab60, 0xd1929213, 0xdf757ac2, 0x80fda67d, - 0x8e1a4eac, 0x9d3277df, 0x93d59f0e, 0xbb620539, 0xb585ede8, - 0xa6add49b, 0xa84a3c4a, 0x11284946, 0x1fcfa197, 0x0ce798e4, - 0x02007035, 0x2ab7ea02, 0x245002d3, 0x37783ba0, 0x399fd371, - 0x66170fce, 0x68f0e71f, 0x7bd8de6c, 0x753f36bd, 0x5d88ac8a, - 0x536f445b, 0x40477d28, 0x4ea095f9, 0xff56c456, 0xf1b12c87, - 0xe29915f4, 0xec7efd25, 0xc4c96712, 0xca2e8fc3, 0xd906b6b0, - 0xd7e15e61, 0x886982de, 0x868e6a0f, 0x95a6537c, 0x9b41bbad, - 0xb3f6219a, 0xbd11c94b, 0xae39f038, 0xa0de18e9, 0x16a45527, - 0x1843bdf6, 0x0b6b8485, 0x058c6c54, 0x2d3bf663, 0x23dc1eb2, - 0x30f427c1, 0x3e13cf10, 0x619b13af, 0x6f7cfb7e, 0x7c54c20d, - 0x72b32adc, 0x5a04b0eb, 0x54e3583a, 0x47cb6149, 0x492c8998, - 0xf8dad837, 0xf63d30e6, 0xe5150995, 0xebf2e144, 0xc3457b73, - 0xcda293a2, 0xde8aaad1, 0xd06d4200, 0x8fe59ebf, 0x8102766e, - 0x922a4f1d, 0x9ccda7cc, 0xb47a3dfb, 0xba9dd52a, 0xa9b5ec59, - 0xa7520488}, - {0x00000000, 0x3c60e308, 0x78c1c610, 0x44a12518, 0xf1838c20, - 0xcde36f28, 0x89424a30, 0xb522a938, 0x38761e01, 0x0416fd09, - 0x40b7d811, 0x7cd73b19, 0xc9f59221, 0xf5957129, 0xb1345431, - 0x8d54b739, 0x70ec3c02, 0x4c8cdf0a, 0x082dfa12, 0x344d191a, - 0x816fb022, 0xbd0f532a, 0xf9ae7632, 0xc5ce953a, 0x489a2203, - 0x74fac10b, 0x305be413, 0x0c3b071b, 0xb919ae23, 0x85794d2b, - 0xc1d86833, 0xfdb88b3b, 0xe1d87804, 0xddb89b0c, 0x9919be14, - 0xa5795d1c, 0x105bf424, 0x2c3b172c, 0x689a3234, 0x54fad13c, - 0xd9ae6605, 0xe5ce850d, 0xa16fa015, 0x9d0f431d, 0x282dea25, - 0x144d092d, 0x50ec2c35, 0x6c8ccf3d, 0x91344406, 0xad54a70e, - 0xe9f58216, 0xd595611e, 0x60b7c826, 0x5cd72b2e, 0x18760e36, - 0x2416ed3e, 0xa9425a07, 0x9522b90f, 0xd1839c17, 0xede37f1f, - 0x58c1d627, 0x64a1352f, 0x20001037, 0x1c60f33f, 0x18c1f649, - 0x24a11541, 0x60003059, 0x5c60d351, 0xe9427a69, 0xd5229961, - 0x9183bc79, 0xade35f71, 0x20b7e848, 0x1cd70b40, 0x58762e58, - 0x6416cd50, 0xd1346468, 0xed548760, 0xa9f5a278, 0x95954170, - 0x682dca4b, 0x544d2943, 0x10ec0c5b, 0x2c8cef53, 0x99ae466b, - 0xa5cea563, 0xe16f807b, 0xdd0f6373, 0x505bd44a, 0x6c3b3742, - 0x289a125a, 0x14faf152, 0xa1d8586a, 0x9db8bb62, 0xd9199e7a, - 0xe5797d72, 0xf9198e4d, 0xc5796d45, 0x81d8485d, 0xbdb8ab55, - 0x089a026d, 0x34fae165, 0x705bc47d, 0x4c3b2775, 0xc16f904c, - 0xfd0f7344, 0xb9ae565c, 0x85ceb554, 0x30ec1c6c, 0x0c8cff64, - 0x482dda7c, 0x744d3974, 0x89f5b24f, 0xb5955147, 0xf134745f, - 0xcd549757, 0x78763e6f, 0x4416dd67, 0x00b7f87f, 0x3cd71b77, - 0xb183ac4e, 0x8de34f46, 0xc9426a5e, 0xf5228956, 0x4000206e, - 0x7c60c366, 0x38c1e67e, 0x04a10576, 0x3183ec92, 0x0de30f9a, - 0x49422a82, 0x7522c98a, 0xc00060b2, 0xfc6083ba, 0xb8c1a6a2, - 0x84a145aa, 0x09f5f293, 0x3595119b, 0x71343483, 0x4d54d78b, - 0xf8767eb3, 0xc4169dbb, 0x80b7b8a3, 0xbcd75bab, 0x416fd090, - 0x7d0f3398, 0x39ae1680, 0x05cef588, 0xb0ec5cb0, 0x8c8cbfb8, - 0xc82d9aa0, 0xf44d79a8, 0x7919ce91, 0x45792d99, 0x01d80881, - 0x3db8eb89, 0x889a42b1, 0xb4faa1b9, 0xf05b84a1, 0xcc3b67a9, - 0xd05b9496, 0xec3b779e, 0xa89a5286, 0x94fab18e, 0x21d818b6, - 0x1db8fbbe, 0x5919dea6, 0x65793dae, 0xe82d8a97, 0xd44d699f, - 0x90ec4c87, 0xac8caf8f, 0x19ae06b7, 0x25cee5bf, 0x616fc0a7, - 0x5d0f23af, 0xa0b7a894, 0x9cd74b9c, 0xd8766e84, 0xe4168d8c, - 0x513424b4, 0x6d54c7bc, 0x29f5e2a4, 0x159501ac, 0x98c1b695, - 0xa4a1559d, 0xe0007085, 0xdc60938d, 0x69423ab5, 0x5522d9bd, - 0x1183fca5, 0x2de31fad, 0x29421adb, 0x1522f9d3, 0x5183dccb, - 0x6de33fc3, 0xd8c196fb, 0xe4a175f3, 0xa00050eb, 0x9c60b3e3, - 0x113404da, 0x2d54e7d2, 0x69f5c2ca, 0x559521c2, 0xe0b788fa, - 0xdcd76bf2, 0x98764eea, 0xa416ade2, 0x59ae26d9, 0x65cec5d1, - 0x216fe0c9, 0x1d0f03c1, 0xa82daaf9, 0x944d49f1, 0xd0ec6ce9, - 0xec8c8fe1, 0x61d838d8, 0x5db8dbd0, 0x1919fec8, 0x25791dc0, - 0x905bb4f8, 0xac3b57f0, 0xe89a72e8, 0xd4fa91e0, 0xc89a62df, - 0xf4fa81d7, 0xb05ba4cf, 0x8c3b47c7, 0x3919eeff, 0x05790df7, - 0x41d828ef, 0x7db8cbe7, 0xf0ec7cde, 0xcc8c9fd6, 0x882dbace, - 0xb44d59c6, 0x016ff0fe, 0x3d0f13f6, 0x79ae36ee, 0x45ced5e6, - 0xb8765edd, 0x8416bdd5, 0xc0b798cd, 0xfcd77bc5, 0x49f5d2fd, - 0x759531f5, 0x313414ed, 0x0d54f7e5, 0x800040dc, 0xbc60a3d4, - 0xf8c186cc, 0xc4a165c4, 0x7183ccfc, 0x4de32ff4, 0x09420aec, - 0x3522e9e4}, - {0x00000000, 0x6307d924, 0xc60fb248, 0xa5086b6c, 0x576e62d1, - 0x3469bbf5, 0x9161d099, 0xf26609bd, 0xaedcc5a2, 0xcddb1c86, - 0x68d377ea, 0x0bd4aece, 0xf9b2a773, 0x9ab57e57, 0x3fbd153b, - 0x5cbacc1f, 0x86c88d05, 0xe5cf5421, 0x40c73f4d, 0x23c0e669, - 0xd1a6efd4, 0xb2a136f0, 0x17a95d9c, 0x74ae84b8, 0x281448a7, - 0x4b139183, 0xee1bfaef, 0x8d1c23cb, 0x7f7a2a76, 0x1c7df352, - 0xb975983e, 0xda72411a, 0xd6e01c4b, 0xb5e7c56f, 0x10efae03, - 0x73e87727, 0x818e7e9a, 0xe289a7be, 0x4781ccd2, 0x248615f6, - 0x783cd9e9, 0x1b3b00cd, 0xbe336ba1, 0xdd34b285, 0x2f52bb38, - 0x4c55621c, 0xe95d0970, 0x8a5ad054, 0x5028914e, 0x332f486a, - 0x96272306, 0xf520fa22, 0x0746f39f, 0x64412abb, 0xc14941d7, - 0xa24e98f3, 0xfef454ec, 0x9df38dc8, 0x38fbe6a4, 0x5bfc3f80, - 0xa99a363d, 0xca9def19, 0x6f958475, 0x0c925d51, 0x76b13ed7, - 0x15b6e7f3, 0xb0be8c9f, 0xd3b955bb, 0x21df5c06, 0x42d88522, - 0xe7d0ee4e, 0x84d7376a, 0xd86dfb75, 0xbb6a2251, 0x1e62493d, - 0x7d659019, 0x8f0399a4, 0xec044080, 0x490c2bec, 0x2a0bf2c8, - 0xf079b3d2, 0x937e6af6, 0x3676019a, 0x5571d8be, 0xa717d103, - 0xc4100827, 0x6118634b, 0x021fba6f, 0x5ea57670, 0x3da2af54, - 0x98aac438, 0xfbad1d1c, 0x09cb14a1, 0x6acccd85, 0xcfc4a6e9, - 0xacc37fcd, 0xa051229c, 0xc356fbb8, 0x665e90d4, 0x055949f0, - 0xf73f404d, 0x94389969, 0x3130f205, 0x52372b21, 0x0e8de73e, - 0x6d8a3e1a, 0xc8825576, 0xab858c52, 0x59e385ef, 0x3ae45ccb, - 0x9fec37a7, 0xfcebee83, 0x2699af99, 0x459e76bd, 0xe0961dd1, - 0x8391c4f5, 0x71f7cd48, 0x12f0146c, 0xb7f87f00, 0xd4ffa624, - 0x88456a3b, 0xeb42b31f, 0x4e4ad873, 0x2d4d0157, 0xdf2b08ea, - 0xbc2cd1ce, 0x1924baa2, 0x7a236386, 0xed627dae, 0x8e65a48a, - 0x2b6dcfe6, 0x486a16c2, 0xba0c1f7f, 0xd90bc65b, 0x7c03ad37, - 0x1f047413, 0x43beb80c, 0x20b96128, 0x85b10a44, 0xe6b6d360, - 0x14d0dadd, 0x77d703f9, 0xd2df6895, 0xb1d8b1b1, 0x6baaf0ab, - 0x08ad298f, 0xada542e3, 0xcea29bc7, 0x3cc4927a, 0x5fc34b5e, - 0xfacb2032, 0x99ccf916, 0xc5763509, 0xa671ec2d, 0x03798741, - 0x607e5e65, 0x921857d8, 0xf11f8efc, 0x5417e590, 0x37103cb4, - 0x3b8261e5, 0x5885b8c1, 0xfd8dd3ad, 0x9e8a0a89, 0x6cec0334, - 0x0febda10, 0xaae3b17c, 0xc9e46858, 0x955ea447, 0xf6597d63, - 0x5351160f, 0x3056cf2b, 0xc230c696, 0xa1371fb2, 0x043f74de, - 0x6738adfa, 0xbd4aece0, 0xde4d35c4, 0x7b455ea8, 0x1842878c, - 0xea248e31, 0x89235715, 0x2c2b3c79, 0x4f2ce55d, 0x13962942, - 0x7091f066, 0xd5999b0a, 0xb69e422e, 0x44f84b93, 0x27ff92b7, - 0x82f7f9db, 0xe1f020ff, 0x9bd34379, 0xf8d49a5d, 0x5ddcf131, - 0x3edb2815, 0xccbd21a8, 0xafbaf88c, 0x0ab293e0, 0x69b54ac4, - 0x350f86db, 0x56085fff, 0xf3003493, 0x9007edb7, 0x6261e40a, - 0x01663d2e, 0xa46e5642, 0xc7698f66, 0x1d1bce7c, 0x7e1c1758, - 0xdb147c34, 0xb813a510, 0x4a75acad, 0x29727589, 0x8c7a1ee5, - 0xef7dc7c1, 0xb3c70bde, 0xd0c0d2fa, 0x75c8b996, 0x16cf60b2, - 0xe4a9690f, 0x87aeb02b, 0x22a6db47, 0x41a10263, 0x4d335f32, - 0x2e348616, 0x8b3ced7a, 0xe83b345e, 0x1a5d3de3, 0x795ae4c7, - 0xdc528fab, 0xbf55568f, 0xe3ef9a90, 0x80e843b4, 0x25e028d8, - 0x46e7f1fc, 0xb481f841, 0xd7862165, 0x728e4a09, 0x1189932d, - 0xcbfbd237, 0xa8fc0b13, 0x0df4607f, 0x6ef3b95b, 0x9c95b0e6, - 0xff9269c2, 0x5a9a02ae, 0x399ddb8a, 0x65271795, 0x0620ceb1, - 0xa328a5dd, 0xc02f7cf9, 0x32497544, 0x514eac60, 0xf446c70c, - 0x97411e28}, - {0x00000000, 0x01b5fd1d, 0x036bfa3a, 0x02de0727, 0x06d7f474, - 0x07620969, 0x05bc0e4e, 0x0409f353, 0x0dafe8e8, 0x0c1a15f5, - 0x0ec412d2, 0x0f71efcf, 0x0b781c9c, 0x0acde181, 0x0813e6a6, - 0x09a61bbb, 0x1b5fd1d0, 0x1aea2ccd, 0x18342bea, 0x1981d6f7, - 0x1d8825a4, 0x1c3dd8b9, 0x1ee3df9e, 0x1f562283, 0x16f03938, - 0x1745c425, 0x159bc302, 0x142e3e1f, 0x1027cd4c, 0x11923051, - 0x134c3776, 0x12f9ca6b, 0x36bfa3a0, 0x370a5ebd, 0x35d4599a, - 0x3461a487, 0x306857d4, 0x31ddaac9, 0x3303adee, 0x32b650f3, - 0x3b104b48, 0x3aa5b655, 0x387bb172, 0x39ce4c6f, 0x3dc7bf3c, - 0x3c724221, 0x3eac4506, 0x3f19b81b, 0x2de07270, 0x2c558f6d, - 0x2e8b884a, 0x2f3e7557, 0x2b378604, 0x2a827b19, 0x285c7c3e, - 0x29e98123, 0x204f9a98, 0x21fa6785, 0x232460a2, 0x22919dbf, - 0x26986eec, 0x272d93f1, 0x25f394d6, 0x244669cb, 0x6d7f4740, - 0x6ccaba5d, 0x6e14bd7a, 0x6fa14067, 0x6ba8b334, 0x6a1d4e29, - 0x68c3490e, 0x6976b413, 0x60d0afa8, 0x616552b5, 0x63bb5592, - 0x620ea88f, 0x66075bdc, 0x67b2a6c1, 0x656ca1e6, 0x64d95cfb, - 0x76209690, 0x77956b8d, 0x754b6caa, 0x74fe91b7, 0x70f762e4, - 0x71429ff9, 0x739c98de, 0x722965c3, 0x7b8f7e78, 0x7a3a8365, - 0x78e48442, 0x7951795f, 0x7d588a0c, 0x7ced7711, 0x7e337036, - 0x7f868d2b, 0x5bc0e4e0, 0x5a7519fd, 0x58ab1eda, 0x591ee3c7, - 0x5d171094, 0x5ca2ed89, 0x5e7ceaae, 0x5fc917b3, 0x566f0c08, - 0x57daf115, 0x5504f632, 0x54b10b2f, 0x50b8f87c, 0x510d0561, - 0x53d30246, 0x5266ff5b, 0x409f3530, 0x412ac82d, 0x43f4cf0a, - 0x42413217, 0x4648c144, 0x47fd3c59, 0x45233b7e, 0x4496c663, - 0x4d30ddd8, 0x4c8520c5, 0x4e5b27e2, 0x4feedaff, 0x4be729ac, - 0x4a52d4b1, 0x488cd396, 0x49392e8b, 0xdafe8e80, 0xdb4b739d, - 0xd99574ba, 0xd82089a7, 0xdc297af4, 0xdd9c87e9, 0xdf4280ce, - 0xdef77dd3, 0xd7516668, 0xd6e49b75, 0xd43a9c52, 0xd58f614f, - 0xd186921c, 0xd0336f01, 0xd2ed6826, 0xd358953b, 0xc1a15f50, - 0xc014a24d, 0xc2caa56a, 0xc37f5877, 0xc776ab24, 0xc6c35639, - 0xc41d511e, 0xc5a8ac03, 0xcc0eb7b8, 0xcdbb4aa5, 0xcf654d82, - 0xced0b09f, 0xcad943cc, 0xcb6cbed1, 0xc9b2b9f6, 0xc80744eb, - 0xec412d20, 0xedf4d03d, 0xef2ad71a, 0xee9f2a07, 0xea96d954, - 0xeb232449, 0xe9fd236e, 0xe848de73, 0xe1eec5c8, 0xe05b38d5, - 0xe2853ff2, 0xe330c2ef, 0xe73931bc, 0xe68ccca1, 0xe452cb86, - 0xe5e7369b, 0xf71efcf0, 0xf6ab01ed, 0xf47506ca, 0xf5c0fbd7, - 0xf1c90884, 0xf07cf599, 0xf2a2f2be, 0xf3170fa3, 0xfab11418, - 0xfb04e905, 0xf9daee22, 0xf86f133f, 0xfc66e06c, 0xfdd31d71, - 0xff0d1a56, 0xfeb8e74b, 0xb781c9c0, 0xb63434dd, 0xb4ea33fa, - 0xb55fcee7, 0xb1563db4, 0xb0e3c0a9, 0xb23dc78e, 0xb3883a93, - 0xba2e2128, 0xbb9bdc35, 0xb945db12, 0xb8f0260f, 0xbcf9d55c, - 0xbd4c2841, 0xbf922f66, 0xbe27d27b, 0xacde1810, 0xad6be50d, - 0xafb5e22a, 0xae001f37, 0xaa09ec64, 0xabbc1179, 0xa962165e, - 0xa8d7eb43, 0xa171f0f8, 0xa0c40de5, 0xa21a0ac2, 0xa3aff7df, - 0xa7a6048c, 0xa613f991, 0xa4cdfeb6, 0xa57803ab, 0x813e6a60, - 0x808b977d, 0x8255905a, 0x83e06d47, 0x87e99e14, 0x865c6309, - 0x8482642e, 0x85379933, 0x8c918288, 0x8d247f95, 0x8ffa78b2, - 0x8e4f85af, 0x8a4676fc, 0x8bf38be1, 0x892d8cc6, 0x889871db, - 0x9a61bbb0, 0x9bd446ad, 0x990a418a, 0x98bfbc97, 0x9cb64fc4, - 0x9d03b2d9, 0x9fddb5fe, 0x9e6848e3, 0x97ce5358, 0x967bae45, - 0x94a5a962, 0x9510547f, 0x9119a72c, 0x90ac5a31, 0x92725d16, - 0x93c7a00b}, - {0x00000000, 0x6e8c1b41, 0xdd183682, 0xb3942dc3, 0x61416b45, - 0x0fcd7004, 0xbc595dc7, 0xd2d54686, 0xc282d68a, 0xac0ecdcb, - 0x1f9ae008, 0x7116fb49, 0xa3c3bdcf, 0xcd4fa68e, 0x7edb8b4d, - 0x1057900c, 0x5e74ab55, 0x30f8b014, 0x836c9dd7, 0xede08696, - 0x3f35c010, 0x51b9db51, 0xe22df692, 0x8ca1edd3, 0x9cf67ddf, - 0xf27a669e, 0x41ee4b5d, 0x2f62501c, 0xfdb7169a, 0x933b0ddb, - 0x20af2018, 0x4e233b59, 0xbce956aa, 0xd2654deb, 0x61f16028, - 0x0f7d7b69, 0xdda83def, 0xb32426ae, 0x00b00b6d, 0x6e3c102c, - 0x7e6b8020, 0x10e79b61, 0xa373b6a2, 0xcdffade3, 0x1f2aeb65, - 0x71a6f024, 0xc232dde7, 0xacbec6a6, 0xe29dfdff, 0x8c11e6be, - 0x3f85cb7d, 0x5109d03c, 0x83dc96ba, 0xed508dfb, 0x5ec4a038, - 0x3048bb79, 0x201f2b75, 0x4e933034, 0xfd071df7, 0x938b06b6, - 0x415e4030, 0x2fd25b71, 0x9c4676b2, 0xf2ca6df3, 0xa2a3ab15, - 0xcc2fb054, 0x7fbb9d97, 0x113786d6, 0xc3e2c050, 0xad6edb11, - 0x1efaf6d2, 0x7076ed93, 0x60217d9f, 0x0ead66de, 0xbd394b1d, - 0xd3b5505c, 0x016016da, 0x6fec0d9b, 0xdc782058, 0xb2f43b19, - 0xfcd70040, 0x925b1b01, 0x21cf36c2, 0x4f432d83, 0x9d966b05, - 0xf31a7044, 0x408e5d87, 0x2e0246c6, 0x3e55d6ca, 0x50d9cd8b, - 0xe34de048, 0x8dc1fb09, 0x5f14bd8f, 0x3198a6ce, 0x820c8b0d, - 0xec80904c, 0x1e4afdbf, 0x70c6e6fe, 0xc352cb3d, 0xadded07c, - 0x7f0b96fa, 0x11878dbb, 0xa213a078, 0xcc9fbb39, 0xdcc82b35, - 0xb2443074, 0x01d01db7, 0x6f5c06f6, 0xbd894070, 0xd3055b31, - 0x609176f2, 0x0e1d6db3, 0x403e56ea, 0x2eb24dab, 0x9d266068, - 0xf3aa7b29, 0x217f3daf, 0x4ff326ee, 0xfc670b2d, 0x92eb106c, - 0x82bc8060, 0xec309b21, 0x5fa4b6e2, 0x3128ada3, 0xe3fdeb25, - 0x8d71f064, 0x3ee5dda7, 0x5069c6e6, 0x9e36506b, 0xf0ba4b2a, - 0x432e66e9, 0x2da27da8, 0xff773b2e, 0x91fb206f, 0x226f0dac, - 0x4ce316ed, 0x5cb486e1, 0x32389da0, 0x81acb063, 0xef20ab22, - 0x3df5eda4, 0x5379f6e5, 0xe0eddb26, 0x8e61c067, 0xc042fb3e, - 0xaecee07f, 0x1d5acdbc, 0x73d6d6fd, 0xa103907b, 0xcf8f8b3a, - 0x7c1ba6f9, 0x1297bdb8, 0x02c02db4, 0x6c4c36f5, 0xdfd81b36, - 0xb1540077, 0x638146f1, 0x0d0d5db0, 0xbe997073, 0xd0156b32, - 0x22df06c1, 0x4c531d80, 0xffc73043, 0x914b2b02, 0x439e6d84, - 0x2d1276c5, 0x9e865b06, 0xf00a4047, 0xe05dd04b, 0x8ed1cb0a, - 0x3d45e6c9, 0x53c9fd88, 0x811cbb0e, 0xef90a04f, 0x5c048d8c, - 0x328896cd, 0x7cabad94, 0x1227b6d5, 0xa1b39b16, 0xcf3f8057, - 0x1deac6d1, 0x7366dd90, 0xc0f2f053, 0xae7eeb12, 0xbe297b1e, - 0xd0a5605f, 0x63314d9c, 0x0dbd56dd, 0xdf68105b, 0xb1e40b1a, - 0x027026d9, 0x6cfc3d98, 0x3c95fb7e, 0x5219e03f, 0xe18dcdfc, - 0x8f01d6bd, 0x5dd4903b, 0x33588b7a, 0x80cca6b9, 0xee40bdf8, - 0xfe172df4, 0x909b36b5, 0x230f1b76, 0x4d830037, 0x9f5646b1, - 0xf1da5df0, 0x424e7033, 0x2cc26b72, 0x62e1502b, 0x0c6d4b6a, - 0xbff966a9, 0xd1757de8, 0x03a03b6e, 0x6d2c202f, 0xdeb80dec, - 0xb03416ad, 0xa06386a1, 0xceef9de0, 0x7d7bb023, 0x13f7ab62, - 0xc122ede4, 0xafaef6a5, 0x1c3adb66, 0x72b6c027, 0x807cadd4, - 0xeef0b695, 0x5d649b56, 0x33e88017, 0xe13dc691, 0x8fb1ddd0, - 0x3c25f013, 0x52a9eb52, 0x42fe7b5e, 0x2c72601f, 0x9fe64ddc, - 0xf16a569d, 0x23bf101b, 0x4d330b5a, 0xfea72699, 0x902b3dd8, - 0xde080681, 0xb0841dc0, 0x03103003, 0x6d9c2b42, 0xbf496dc4, - 0xd1c57685, 0x62515b46, 0x0cdd4007, 0x1c8ad00b, 0x7206cb4a, - 0xc192e689, 0xaf1efdc8, 0x7dcbbb4e, 0x1347a00f, 0xa0d38dcc, - 0xce5f968d}, - {0x00000000, 0xe71da697, 0x154a4b6f, 0xf257edf8, 0x2a9496de, - 0xcd893049, 0x3fdeddb1, 0xd8c37b26, 0x55292dbc, 0xb2348b2b, - 0x406366d3, 0xa77ec044, 0x7fbdbb62, 0x98a01df5, 0x6af7f00d, - 0x8dea569a, 0xaa525b78, 0x4d4ffdef, 0xbf181017, 0x5805b680, - 0x80c6cda6, 0x67db6b31, 0x958c86c9, 0x7291205e, 0xff7b76c4, - 0x1866d053, 0xea313dab, 0x0d2c9b3c, 0xd5efe01a, 0x32f2468d, - 0xc0a5ab75, 0x27b80de2, 0x8fd5b0b1, 0x68c81626, 0x9a9ffbde, - 0x7d825d49, 0xa541266f, 0x425c80f8, 0xb00b6d00, 0x5716cb97, - 0xdafc9d0d, 0x3de13b9a, 0xcfb6d662, 0x28ab70f5, 0xf0680bd3, - 0x1775ad44, 0xe52240bc, 0x023fe62b, 0x2587ebc9, 0xc29a4d5e, - 0x30cda0a6, 0xd7d00631, 0x0f137d17, 0xe80edb80, 0x1a593678, - 0xfd4490ef, 0x70aec675, 0x97b360e2, 0x65e48d1a, 0x82f92b8d, - 0x5a3a50ab, 0xbd27f63c, 0x4f701bc4, 0xa86dbd53, 0xc4da6723, - 0x23c7c1b4, 0xd1902c4c, 0x368d8adb, 0xee4ef1fd, 0x0953576a, - 0xfb04ba92, 0x1c191c05, 0x91f34a9f, 0x76eeec08, 0x84b901f0, - 0x63a4a767, 0xbb67dc41, 0x5c7a7ad6, 0xae2d972e, 0x493031b9, - 0x6e883c5b, 0x89959acc, 0x7bc27734, 0x9cdfd1a3, 0x441caa85, - 0xa3010c12, 0x5156e1ea, 0xb64b477d, 0x3ba111e7, 0xdcbcb770, - 0x2eeb5a88, 0xc9f6fc1f, 0x11358739, 0xf62821ae, 0x047fcc56, - 0xe3626ac1, 0x4b0fd792, 0xac127105, 0x5e459cfd, 0xb9583a6a, - 0x619b414c, 0x8686e7db, 0x74d10a23, 0x93ccacb4, 0x1e26fa2e, - 0xf93b5cb9, 0x0b6cb141, 0xec7117d6, 0x34b26cf0, 0xd3afca67, - 0x21f8279f, 0xc6e58108, 0xe15d8cea, 0x06402a7d, 0xf417c785, - 0x130a6112, 0xcbc91a34, 0x2cd4bca3, 0xde83515b, 0x399ef7cc, - 0xb474a156, 0x536907c1, 0xa13eea39, 0x46234cae, 0x9ee03788, - 0x79fd911f, 0x8baa7ce7, 0x6cb7da70, 0x52c5c807, 0xb5d86e90, - 0x478f8368, 0xa09225ff, 0x78515ed9, 0x9f4cf84e, 0x6d1b15b6, - 0x8a06b321, 0x07ece5bb, 0xe0f1432c, 0x12a6aed4, 0xf5bb0843, - 0x2d787365, 0xca65d5f2, 0x3832380a, 0xdf2f9e9d, 0xf897937f, - 0x1f8a35e8, 0xedddd810, 0x0ac07e87, 0xd20305a1, 0x351ea336, - 0xc7494ece, 0x2054e859, 0xadbebec3, 0x4aa31854, 0xb8f4f5ac, - 0x5fe9533b, 0x872a281d, 0x60378e8a, 0x92606372, 0x757dc5e5, - 0xdd1078b6, 0x3a0dde21, 0xc85a33d9, 0x2f47954e, 0xf784ee68, - 0x109948ff, 0xe2cea507, 0x05d30390, 0x8839550a, 0x6f24f39d, - 0x9d731e65, 0x7a6eb8f2, 0xa2adc3d4, 0x45b06543, 0xb7e788bb, - 0x50fa2e2c, 0x774223ce, 0x905f8559, 0x620868a1, 0x8515ce36, - 0x5dd6b510, 0xbacb1387, 0x489cfe7f, 0xaf8158e8, 0x226b0e72, - 0xc576a8e5, 0x3721451d, 0xd03ce38a, 0x08ff98ac, 0xefe23e3b, - 0x1db5d3c3, 0xfaa87554, 0x961faf24, 0x710209b3, 0x8355e44b, - 0x644842dc, 0xbc8b39fa, 0x5b969f6d, 0xa9c17295, 0x4edcd402, - 0xc3368298, 0x242b240f, 0xd67cc9f7, 0x31616f60, 0xe9a21446, - 0x0ebfb2d1, 0xfce85f29, 0x1bf5f9be, 0x3c4df45c, 0xdb5052cb, - 0x2907bf33, 0xce1a19a4, 0x16d96282, 0xf1c4c415, 0x039329ed, - 0xe48e8f7a, 0x6964d9e0, 0x8e797f77, 0x7c2e928f, 0x9b333418, - 0x43f04f3e, 0xa4ede9a9, 0x56ba0451, 0xb1a7a2c6, 0x19ca1f95, - 0xfed7b902, 0x0c8054fa, 0xeb9df26d, 0x335e894b, 0xd4432fdc, - 0x2614c224, 0xc10964b3, 0x4ce33229, 0xabfe94be, 0x59a97946, - 0xbeb4dfd1, 0x6677a4f7, 0x816a0260, 0x733def98, 0x9420490f, - 0xb39844ed, 0x5485e27a, 0xa6d20f82, 0x41cfa915, 0x990cd233, - 0x7e1174a4, 0x8c46995c, 0x6b5b3fcb, 0xe6b16951, 0x01accfc6, - 0xf3fb223e, 0x14e684a9, 0xcc25ff8f, 0x2b385918, 0xd96fb4e0, - 0x3e721277}, - {0x00000000, 0xa58b900e, 0x9066265d, 0x35edb653, 0xfbbd4afb, - 0x5e36daf5, 0x6bdb6ca6, 0xce50fca8, 0x2c0b93b7, 0x898003b9, - 0xbc6db5ea, 0x19e625e4, 0xd7b6d94c, 0x723d4942, 0x47d0ff11, - 0xe25b6f1f, 0x5817276e, 0xfd9cb760, 0xc8710133, 0x6dfa913d, - 0xa3aa6d95, 0x0621fd9b, 0x33cc4bc8, 0x9647dbc6, 0x741cb4d9, - 0xd19724d7, 0xe47a9284, 0x41f1028a, 0x8fa1fe22, 0x2a2a6e2c, - 0x1fc7d87f, 0xba4c4871, 0xb02e4edc, 0x15a5ded2, 0x20486881, - 0x85c3f88f, 0x4b930427, 0xee189429, 0xdbf5227a, 0x7e7eb274, - 0x9c25dd6b, 0x39ae4d65, 0x0c43fb36, 0xa9c86b38, 0x67989790, - 0xc213079e, 0xf7feb1cd, 0x527521c3, 0xe83969b2, 0x4db2f9bc, - 0x785f4fef, 0xddd4dfe1, 0x13842349, 0xb60fb347, 0x83e20514, - 0x2669951a, 0xc432fa05, 0x61b96a0b, 0x5454dc58, 0xf1df4c56, - 0x3f8fb0fe, 0x9a0420f0, 0xafe996a3, 0x0a6206ad, 0xbb2d9bf9, - 0x1ea60bf7, 0x2b4bbda4, 0x8ec02daa, 0x4090d102, 0xe51b410c, - 0xd0f6f75f, 0x757d6751, 0x9726084e, 0x32ad9840, 0x07402e13, - 0xa2cbbe1d, 0x6c9b42b5, 0xc910d2bb, 0xfcfd64e8, 0x5976f4e6, - 0xe33abc97, 0x46b12c99, 0x735c9aca, 0xd6d70ac4, 0x1887f66c, - 0xbd0c6662, 0x88e1d031, 0x2d6a403f, 0xcf312f20, 0x6ababf2e, - 0x5f57097d, 0xfadc9973, 0x348c65db, 0x9107f5d5, 0xa4ea4386, - 0x0161d388, 0x0b03d525, 0xae88452b, 0x9b65f378, 0x3eee6376, - 0xf0be9fde, 0x55350fd0, 0x60d8b983, 0xc553298d, 0x27084692, - 0x8283d69c, 0xb76e60cf, 0x12e5f0c1, 0xdcb50c69, 0x793e9c67, - 0x4cd32a34, 0xe958ba3a, 0x5314f24b, 0xf69f6245, 0xc372d416, - 0x66f94418, 0xa8a9b8b0, 0x0d2228be, 0x38cf9eed, 0x9d440ee3, - 0x7f1f61fc, 0xda94f1f2, 0xef7947a1, 0x4af2d7af, 0x84a22b07, - 0x2129bb09, 0x14c40d5a, 0xb14f9d54, 0xad2a31b3, 0x08a1a1bd, - 0x3d4c17ee, 0x98c787e0, 0x56977b48, 0xf31ceb46, 0xc6f15d15, - 0x637acd1b, 0x8121a204, 0x24aa320a, 0x11478459, 0xb4cc1457, - 0x7a9ce8ff, 0xdf1778f1, 0xeafacea2, 0x4f715eac, 0xf53d16dd, - 0x50b686d3, 0x655b3080, 0xc0d0a08e, 0x0e805c26, 0xab0bcc28, - 0x9ee67a7b, 0x3b6dea75, 0xd936856a, 0x7cbd1564, 0x4950a337, - 0xecdb3339, 0x228bcf91, 0x87005f9f, 0xb2ede9cc, 0x176679c2, - 0x1d047f6f, 0xb88fef61, 0x8d625932, 0x28e9c93c, 0xe6b93594, - 0x4332a59a, 0x76df13c9, 0xd35483c7, 0x310fecd8, 0x94847cd6, - 0xa169ca85, 0x04e25a8b, 0xcab2a623, 0x6f39362d, 0x5ad4807e, - 0xff5f1070, 0x45135801, 0xe098c80f, 0xd5757e5c, 0x70feee52, - 0xbeae12fa, 0x1b2582f4, 0x2ec834a7, 0x8b43a4a9, 0x6918cbb6, - 0xcc935bb8, 0xf97eedeb, 0x5cf57de5, 0x92a5814d, 0x372e1143, - 0x02c3a710, 0xa748371e, 0x1607aa4a, 0xb38c3a44, 0x86618c17, - 0x23ea1c19, 0xedbae0b1, 0x483170bf, 0x7ddcc6ec, 0xd85756e2, - 0x3a0c39fd, 0x9f87a9f3, 0xaa6a1fa0, 0x0fe18fae, 0xc1b17306, - 0x643ae308, 0x51d7555b, 0xf45cc555, 0x4e108d24, 0xeb9b1d2a, - 0xde76ab79, 0x7bfd3b77, 0xb5adc7df, 0x102657d1, 0x25cbe182, - 0x8040718c, 0x621b1e93, 0xc7908e9d, 0xf27d38ce, 0x57f6a8c0, - 0x99a65468, 0x3c2dc466, 0x09c07235, 0xac4be23b, 0xa629e496, - 0x03a27498, 0x364fc2cb, 0x93c452c5, 0x5d94ae6d, 0xf81f3e63, - 0xcdf28830, 0x6879183e, 0x8a227721, 0x2fa9e72f, 0x1a44517c, - 0xbfcfc172, 0x719f3dda, 0xd414add4, 0xe1f91b87, 0x44728b89, - 0xfe3ec3f8, 0x5bb553f6, 0x6e58e5a5, 0xcbd375ab, 0x05838903, - 0xa008190d, 0x95e5af5e, 0x306e3f50, 0xd235504f, 0x77bec041, - 0x42537612, 0xe7d8e61c, 0x29881ab4, 0x8c038aba, 0xb9ee3ce9, - 0x1c65ace7}}; - -local const z_word_t FAR crc_braid_big_table[][256] = { - {0x0000000000000000, 0x0e908ba500000000, 0x5d26669000000000, - 0x53b6ed3500000000, 0xfb4abdfb00000000, 0xf5da365e00000000, - 0xa66cdb6b00000000, 0xa8fc50ce00000000, 0xb7930b2c00000000, - 0xb903808900000000, 0xeab56dbc00000000, 0xe425e61900000000, - 0x4cd9b6d700000000, 0x42493d7200000000, 0x11ffd04700000000, - 0x1f6f5be200000000, 0x6e27175800000000, 0x60b79cfd00000000, - 0x330171c800000000, 0x3d91fa6d00000000, 0x956daaa300000000, - 0x9bfd210600000000, 0xc84bcc3300000000, 0xc6db479600000000, - 0xd9b41c7400000000, 0xd72497d100000000, 0x84927ae400000000, - 0x8a02f14100000000, 0x22fea18f00000000, 0x2c6e2a2a00000000, - 0x7fd8c71f00000000, 0x71484cba00000000, 0xdc4e2eb000000000, - 0xd2dea51500000000, 0x8168482000000000, 0x8ff8c38500000000, - 0x2704934b00000000, 0x299418ee00000000, 0x7a22f5db00000000, - 0x74b27e7e00000000, 0x6bdd259c00000000, 0x654dae3900000000, - 0x36fb430c00000000, 0x386bc8a900000000, 0x9097986700000000, - 0x9e0713c200000000, 0xcdb1fef700000000, 0xc321755200000000, - 0xb26939e800000000, 0xbcf9b24d00000000, 0xef4f5f7800000000, - 0xe1dfd4dd00000000, 0x4923841300000000, 0x47b30fb600000000, - 0x1405e28300000000, 0x1a95692600000000, 0x05fa32c400000000, - 0x0b6ab96100000000, 0x58dc545400000000, 0x564cdff100000000, - 0xfeb08f3f00000000, 0xf020049a00000000, 0xa396e9af00000000, - 0xad06620a00000000, 0xf99b2dbb00000000, 0xf70ba61e00000000, - 0xa4bd4b2b00000000, 0xaa2dc08e00000000, 0x02d1904000000000, - 0x0c411be500000000, 0x5ff7f6d000000000, 0x51677d7500000000, - 0x4e08269700000000, 0x4098ad3200000000, 0x132e400700000000, - 0x1dbecba200000000, 0xb5429b6c00000000, 0xbbd210c900000000, - 0xe864fdfc00000000, 0xe6f4765900000000, 0x97bc3ae300000000, - 0x992cb14600000000, 0xca9a5c7300000000, 0xc40ad7d600000000, - 0x6cf6871800000000, 0x62660cbd00000000, 0x31d0e18800000000, - 0x3f406a2d00000000, 0x202f31cf00000000, 0x2ebfba6a00000000, - 0x7d09575f00000000, 0x7399dcfa00000000, 0xdb658c3400000000, - 0xd5f5079100000000, 0x8643eaa400000000, 0x88d3610100000000, - 0x25d5030b00000000, 0x2b4588ae00000000, 0x78f3659b00000000, - 0x7663ee3e00000000, 0xde9fbef000000000, 0xd00f355500000000, - 0x83b9d86000000000, 0x8d2953c500000000, 0x9246082700000000, - 0x9cd6838200000000, 0xcf606eb700000000, 0xc1f0e51200000000, - 0x690cb5dc00000000, 0x679c3e7900000000, 0x342ad34c00000000, - 0x3aba58e900000000, 0x4bf2145300000000, 0x45629ff600000000, - 0x16d472c300000000, 0x1844f96600000000, 0xb0b8a9a800000000, - 0xbe28220d00000000, 0xed9ecf3800000000, 0xe30e449d00000000, - 0xfc611f7f00000000, 0xf2f194da00000000, 0xa14779ef00000000, - 0xafd7f24a00000000, 0x072ba28400000000, 0x09bb292100000000, - 0x5a0dc41400000000, 0x549d4fb100000000, 0xb3312aad00000000, - 0xbda1a10800000000, 0xee174c3d00000000, 0xe087c79800000000, - 0x487b975600000000, 0x46eb1cf300000000, 0x155df1c600000000, - 0x1bcd7a6300000000, 0x04a2218100000000, 0x0a32aa2400000000, - 0x5984471100000000, 0x5714ccb400000000, 0xffe89c7a00000000, - 0xf17817df00000000, 0xa2cefaea00000000, 0xac5e714f00000000, - 0xdd163df500000000, 0xd386b65000000000, 0x80305b6500000000, - 0x8ea0d0c000000000, 0x265c800e00000000, 0x28cc0bab00000000, - 0x7b7ae69e00000000, 0x75ea6d3b00000000, 0x6a8536d900000000, - 0x6415bd7c00000000, 0x37a3504900000000, 0x3933dbec00000000, - 0x91cf8b2200000000, 0x9f5f008700000000, 0xcce9edb200000000, - 0xc279661700000000, 0x6f7f041d00000000, 0x61ef8fb800000000, - 0x3259628d00000000, 0x3cc9e92800000000, 0x9435b9e600000000, - 0x9aa5324300000000, 0xc913df7600000000, 0xc78354d300000000, - 0xd8ec0f3100000000, 0xd67c849400000000, 0x85ca69a100000000, - 0x8b5ae20400000000, 0x23a6b2ca00000000, 0x2d36396f00000000, - 0x7e80d45a00000000, 0x70105fff00000000, 0x0158134500000000, - 0x0fc898e000000000, 0x5c7e75d500000000, 0x52eefe7000000000, - 0xfa12aebe00000000, 0xf482251b00000000, 0xa734c82e00000000, - 0xa9a4438b00000000, 0xb6cb186900000000, 0xb85b93cc00000000, - 0xebed7ef900000000, 0xe57df55c00000000, 0x4d81a59200000000, - 0x43112e3700000000, 0x10a7c30200000000, 0x1e3748a700000000, - 0x4aaa071600000000, 0x443a8cb300000000, 0x178c618600000000, - 0x191cea2300000000, 0xb1e0baed00000000, 0xbf70314800000000, - 0xecc6dc7d00000000, 0xe25657d800000000, 0xfd390c3a00000000, - 0xf3a9879f00000000, 0xa01f6aaa00000000, 0xae8fe10f00000000, - 0x0673b1c100000000, 0x08e33a6400000000, 0x5b55d75100000000, - 0x55c55cf400000000, 0x248d104e00000000, 0x2a1d9beb00000000, - 0x79ab76de00000000, 0x773bfd7b00000000, 0xdfc7adb500000000, - 0xd157261000000000, 0x82e1cb2500000000, 0x8c71408000000000, - 0x931e1b6200000000, 0x9d8e90c700000000, 0xce387df200000000, - 0xc0a8f65700000000, 0x6854a69900000000, 0x66c42d3c00000000, - 0x3572c00900000000, 0x3be24bac00000000, 0x96e429a600000000, - 0x9874a20300000000, 0xcbc24f3600000000, 0xc552c49300000000, - 0x6dae945d00000000, 0x633e1ff800000000, 0x3088f2cd00000000, - 0x3e18796800000000, 0x2177228a00000000, 0x2fe7a92f00000000, - 0x7c51441a00000000, 0x72c1cfbf00000000, 0xda3d9f7100000000, - 0xd4ad14d400000000, 0x871bf9e100000000, 0x898b724400000000, - 0xf8c33efe00000000, 0xf653b55b00000000, 0xa5e5586e00000000, - 0xab75d3cb00000000, 0x0389830500000000, 0x0d1908a000000000, - 0x5eafe59500000000, 0x503f6e3000000000, 0x4f5035d200000000, - 0x41c0be7700000000, 0x1276534200000000, 0x1ce6d8e700000000, - 0xb41a882900000000, 0xba8a038c00000000, 0xe93ceeb900000000, - 0xe7ac651c00000000}, - {0x0000000000000000, 0x97a61de700000000, 0x6f4b4a1500000000, - 0xf8ed57f200000000, 0xde96942a00000000, 0x493089cd00000000, - 0xb1ddde3f00000000, 0x267bc3d800000000, 0xbc2d295500000000, - 0x2b8b34b200000000, 0xd366634000000000, 0x44c07ea700000000, - 0x62bbbd7f00000000, 0xf51da09800000000, 0x0df0f76a00000000, - 0x9a56ea8d00000000, 0x785b52aa00000000, 0xeffd4f4d00000000, - 0x171018bf00000000, 0x80b6055800000000, 0xa6cdc68000000000, - 0x316bdb6700000000, 0xc9868c9500000000, 0x5e20917200000000, - 0xc4767bff00000000, 0x53d0661800000000, 0xab3d31ea00000000, - 0x3c9b2c0d00000000, 0x1ae0efd500000000, 0x8d46f23200000000, - 0x75aba5c000000000, 0xe20db82700000000, 0xb1b0d58f00000000, - 0x2616c86800000000, 0xdefb9f9a00000000, 0x495d827d00000000, - 0x6f2641a500000000, 0xf8805c4200000000, 0x006d0bb000000000, - 0x97cb165700000000, 0x0d9dfcda00000000, 0x9a3be13d00000000, - 0x62d6b6cf00000000, 0xf570ab2800000000, 0xd30b68f000000000, - 0x44ad751700000000, 0xbc4022e500000000, 0x2be63f0200000000, - 0xc9eb872500000000, 0x5e4d9ac200000000, 0xa6a0cd3000000000, - 0x3106d0d700000000, 0x177d130f00000000, 0x80db0ee800000000, - 0x7836591a00000000, 0xef9044fd00000000, 0x75c6ae7000000000, - 0xe260b39700000000, 0x1a8de46500000000, 0x8d2bf98200000000, - 0xab503a5a00000000, 0x3cf627bd00000000, 0xc41b704f00000000, - 0x53bd6da800000000, 0x2367dac400000000, 0xb4c1c72300000000, - 0x4c2c90d100000000, 0xdb8a8d3600000000, 0xfdf14eee00000000, - 0x6a57530900000000, 0x92ba04fb00000000, 0x051c191c00000000, - 0x9f4af39100000000, 0x08ecee7600000000, 0xf001b98400000000, - 0x67a7a46300000000, 0x41dc67bb00000000, 0xd67a7a5c00000000, - 0x2e972dae00000000, 0xb931304900000000, 0x5b3c886e00000000, - 0xcc9a958900000000, 0x3477c27b00000000, 0xa3d1df9c00000000, - 0x85aa1c4400000000, 0x120c01a300000000, 0xeae1565100000000, - 0x7d474bb600000000, 0xe711a13b00000000, 0x70b7bcdc00000000, - 0x885aeb2e00000000, 0x1ffcf6c900000000, 0x3987351100000000, - 0xae2128f600000000, 0x56cc7f0400000000, 0xc16a62e300000000, - 0x92d70f4b00000000, 0x057112ac00000000, 0xfd9c455e00000000, - 0x6a3a58b900000000, 0x4c419b6100000000, 0xdbe7868600000000, - 0x230ad17400000000, 0xb4accc9300000000, 0x2efa261e00000000, - 0xb95c3bf900000000, 0x41b16c0b00000000, 0xd61771ec00000000, - 0xf06cb23400000000, 0x67caafd300000000, 0x9f27f82100000000, - 0x0881e5c600000000, 0xea8c5de100000000, 0x7d2a400600000000, - 0x85c717f400000000, 0x12610a1300000000, 0x341ac9cb00000000, - 0xa3bcd42c00000000, 0x5b5183de00000000, 0xccf79e3900000000, - 0x56a174b400000000, 0xc107695300000000, 0x39ea3ea100000000, - 0xae4c234600000000, 0x8837e09e00000000, 0x1f91fd7900000000, - 0xe77caa8b00000000, 0x70dab76c00000000, 0x07c8c55200000000, - 0x906ed8b500000000, 0x68838f4700000000, 0xff2592a000000000, - 0xd95e517800000000, 0x4ef84c9f00000000, 0xb6151b6d00000000, - 0x21b3068a00000000, 0xbbe5ec0700000000, 0x2c43f1e000000000, - 0xd4aea61200000000, 0x4308bbf500000000, 0x6573782d00000000, - 0xf2d565ca00000000, 0x0a38323800000000, 0x9d9e2fdf00000000, - 0x7f9397f800000000, 0xe8358a1f00000000, 0x10d8dded00000000, - 0x877ec00a00000000, 0xa10503d200000000, 0x36a31e3500000000, - 0xce4e49c700000000, 0x59e8542000000000, 0xc3bebead00000000, - 0x5418a34a00000000, 0xacf5f4b800000000, 0x3b53e95f00000000, - 0x1d282a8700000000, 0x8a8e376000000000, 0x7263609200000000, - 0xe5c57d7500000000, 0xb67810dd00000000, 0x21de0d3a00000000, - 0xd9335ac800000000, 0x4e95472f00000000, 0x68ee84f700000000, - 0xff48991000000000, 0x07a5cee200000000, 0x9003d30500000000, - 0x0a55398800000000, 0x9df3246f00000000, 0x651e739d00000000, - 0xf2b86e7a00000000, 0xd4c3ada200000000, 0x4365b04500000000, - 0xbb88e7b700000000, 0x2c2efa5000000000, 0xce23427700000000, - 0x59855f9000000000, 0xa168086200000000, 0x36ce158500000000, - 0x10b5d65d00000000, 0x8713cbba00000000, 0x7ffe9c4800000000, - 0xe85881af00000000, 0x720e6b2200000000, 0xe5a876c500000000, - 0x1d45213700000000, 0x8ae33cd000000000, 0xac98ff0800000000, - 0x3b3ee2ef00000000, 0xc3d3b51d00000000, 0x5475a8fa00000000, - 0x24af1f9600000000, 0xb309027100000000, 0x4be4558300000000, - 0xdc42486400000000, 0xfa398bbc00000000, 0x6d9f965b00000000, - 0x9572c1a900000000, 0x02d4dc4e00000000, 0x988236c300000000, - 0x0f242b2400000000, 0xf7c97cd600000000, 0x606f613100000000, - 0x4614a2e900000000, 0xd1b2bf0e00000000, 0x295fe8fc00000000, - 0xbef9f51b00000000, 0x5cf44d3c00000000, 0xcb5250db00000000, - 0x33bf072900000000, 0xa4191ace00000000, 0x8262d91600000000, - 0x15c4c4f100000000, 0xed29930300000000, 0x7a8f8ee400000000, - 0xe0d9646900000000, 0x777f798e00000000, 0x8f922e7c00000000, - 0x1834339b00000000, 0x3e4ff04300000000, 0xa9e9eda400000000, - 0x5104ba5600000000, 0xc6a2a7b100000000, 0x951fca1900000000, - 0x02b9d7fe00000000, 0xfa54800c00000000, 0x6df29deb00000000, - 0x4b895e3300000000, 0xdc2f43d400000000, 0x24c2142600000000, - 0xb36409c100000000, 0x2932e34c00000000, 0xbe94feab00000000, - 0x4679a95900000000, 0xd1dfb4be00000000, 0xf7a4776600000000, - 0x60026a8100000000, 0x98ef3d7300000000, 0x0f49209400000000, - 0xed4498b300000000, 0x7ae2855400000000, 0x820fd2a600000000, - 0x15a9cf4100000000, 0x33d20c9900000000, 0xa474117e00000000, - 0x5c99468c00000000, 0xcb3f5b6b00000000, 0x5169b1e600000000, - 0xc6cfac0100000000, 0x3e22fbf300000000, 0xa984e61400000000, - 0x8fff25cc00000000, 0x1859382b00000000, 0xe0b46fd900000000, - 0x7712723e00000000}, - {0x0000000000000000, 0x411b8c6e00000000, 0x823618dd00000000, - 0xc32d94b300000000, 0x456b416100000000, 0x0470cd0f00000000, - 0xc75d59bc00000000, 0x8646d5d200000000, 0x8ad682c200000000, - 0xcbcd0eac00000000, 0x08e09a1f00000000, 0x49fb167100000000, - 0xcfbdc3a300000000, 0x8ea64fcd00000000, 0x4d8bdb7e00000000, - 0x0c90571000000000, 0x55ab745e00000000, 0x14b0f83000000000, - 0xd79d6c8300000000, 0x9686e0ed00000000, 0x10c0353f00000000, - 0x51dbb95100000000, 0x92f62de200000000, 0xd3eda18c00000000, - 0xdf7df69c00000000, 0x9e667af200000000, 0x5d4bee4100000000, - 0x1c50622f00000000, 0x9a16b7fd00000000, 0xdb0d3b9300000000, - 0x1820af2000000000, 0x593b234e00000000, 0xaa56e9bc00000000, - 0xeb4d65d200000000, 0x2860f16100000000, 0x697b7d0f00000000, - 0xef3da8dd00000000, 0xae2624b300000000, 0x6d0bb00000000000, - 0x2c103c6e00000000, 0x20806b7e00000000, 0x619be71000000000, - 0xa2b673a300000000, 0xe3adffcd00000000, 0x65eb2a1f00000000, - 0x24f0a67100000000, 0xe7dd32c200000000, 0xa6c6beac00000000, - 0xfffd9de200000000, 0xbee6118c00000000, 0x7dcb853f00000000, - 0x3cd0095100000000, 0xba96dc8300000000, 0xfb8d50ed00000000, - 0x38a0c45e00000000, 0x79bb483000000000, 0x752b1f2000000000, - 0x3430934e00000000, 0xf71d07fd00000000, 0xb6068b9300000000, - 0x30405e4100000000, 0x715bd22f00000000, 0xb276469c00000000, - 0xf36dcaf200000000, 0x15aba3a200000000, 0x54b02fcc00000000, - 0x979dbb7f00000000, 0xd686371100000000, 0x50c0e2c300000000, - 0x11db6ead00000000, 0xd2f6fa1e00000000, 0x93ed767000000000, - 0x9f7d216000000000, 0xde66ad0e00000000, 0x1d4b39bd00000000, - 0x5c50b5d300000000, 0xda16600100000000, 0x9b0dec6f00000000, - 0x582078dc00000000, 0x193bf4b200000000, 0x4000d7fc00000000, - 0x011b5b9200000000, 0xc236cf2100000000, 0x832d434f00000000, - 0x056b969d00000000, 0x44701af300000000, 0x875d8e4000000000, - 0xc646022e00000000, 0xcad6553e00000000, 0x8bcdd95000000000, - 0x48e04de300000000, 0x09fbc18d00000000, 0x8fbd145f00000000, - 0xcea6983100000000, 0x0d8b0c8200000000, 0x4c9080ec00000000, - 0xbffd4a1e00000000, 0xfee6c67000000000, 0x3dcb52c300000000, - 0x7cd0dead00000000, 0xfa960b7f00000000, 0xbb8d871100000000, - 0x78a013a200000000, 0x39bb9fcc00000000, 0x352bc8dc00000000, - 0x743044b200000000, 0xb71dd00100000000, 0xf6065c6f00000000, - 0x704089bd00000000, 0x315b05d300000000, 0xf276916000000000, - 0xb36d1d0e00000000, 0xea563e4000000000, 0xab4db22e00000000, - 0x6860269d00000000, 0x297baaf300000000, 0xaf3d7f2100000000, - 0xee26f34f00000000, 0x2d0b67fc00000000, 0x6c10eb9200000000, - 0x6080bc8200000000, 0x219b30ec00000000, 0xe2b6a45f00000000, - 0xa3ad283100000000, 0x25ebfde300000000, 0x64f0718d00000000, - 0xa7dde53e00000000, 0xe6c6695000000000, 0x6b50369e00000000, - 0x2a4bbaf000000000, 0xe9662e4300000000, 0xa87da22d00000000, - 0x2e3b77ff00000000, 0x6f20fb9100000000, 0xac0d6f2200000000, - 0xed16e34c00000000, 0xe186b45c00000000, 0xa09d383200000000, - 0x63b0ac8100000000, 0x22ab20ef00000000, 0xa4edf53d00000000, - 0xe5f6795300000000, 0x26dbede000000000, 0x67c0618e00000000, - 0x3efb42c000000000, 0x7fe0ceae00000000, 0xbccd5a1d00000000, - 0xfdd6d67300000000, 0x7b9003a100000000, 0x3a8b8fcf00000000, - 0xf9a61b7c00000000, 0xb8bd971200000000, 0xb42dc00200000000, - 0xf5364c6c00000000, 0x361bd8df00000000, 0x770054b100000000, - 0xf146816300000000, 0xb05d0d0d00000000, 0x737099be00000000, - 0x326b15d000000000, 0xc106df2200000000, 0x801d534c00000000, - 0x4330c7ff00000000, 0x022b4b9100000000, 0x846d9e4300000000, - 0xc576122d00000000, 0x065b869e00000000, 0x47400af000000000, - 0x4bd05de000000000, 0x0acbd18e00000000, 0xc9e6453d00000000, - 0x88fdc95300000000, 0x0ebb1c8100000000, 0x4fa090ef00000000, - 0x8c8d045c00000000, 0xcd96883200000000, 0x94adab7c00000000, - 0xd5b6271200000000, 0x169bb3a100000000, 0x57803fcf00000000, - 0xd1c6ea1d00000000, 0x90dd667300000000, 0x53f0f2c000000000, - 0x12eb7eae00000000, 0x1e7b29be00000000, 0x5f60a5d000000000, - 0x9c4d316300000000, 0xdd56bd0d00000000, 0x5b1068df00000000, - 0x1a0be4b100000000, 0xd926700200000000, 0x983dfc6c00000000, - 0x7efb953c00000000, 0x3fe0195200000000, 0xfccd8de100000000, - 0xbdd6018f00000000, 0x3b90d45d00000000, 0x7a8b583300000000, - 0xb9a6cc8000000000, 0xf8bd40ee00000000, 0xf42d17fe00000000, - 0xb5369b9000000000, 0x761b0f2300000000, 0x3700834d00000000, - 0xb146569f00000000, 0xf05ddaf100000000, 0x33704e4200000000, - 0x726bc22c00000000, 0x2b50e16200000000, 0x6a4b6d0c00000000, - 0xa966f9bf00000000, 0xe87d75d100000000, 0x6e3ba00300000000, - 0x2f202c6d00000000, 0xec0db8de00000000, 0xad1634b000000000, - 0xa18663a000000000, 0xe09defce00000000, 0x23b07b7d00000000, - 0x62abf71300000000, 0xe4ed22c100000000, 0xa5f6aeaf00000000, - 0x66db3a1c00000000, 0x27c0b67200000000, 0xd4ad7c8000000000, - 0x95b6f0ee00000000, 0x569b645d00000000, 0x1780e83300000000, - 0x91c63de100000000, 0xd0ddb18f00000000, 0x13f0253c00000000, - 0x52eba95200000000, 0x5e7bfe4200000000, 0x1f60722c00000000, - 0xdc4de69f00000000, 0x9d566af100000000, 0x1b10bf2300000000, - 0x5a0b334d00000000, 0x9926a7fe00000000, 0xd83d2b9000000000, - 0x810608de00000000, 0xc01d84b000000000, 0x0330100300000000, - 0x422b9c6d00000000, 0xc46d49bf00000000, 0x8576c5d100000000, - 0x465b516200000000, 0x0740dd0c00000000, 0x0bd08a1c00000000, - 0x4acb067200000000, 0x89e692c100000000, 0xc8fd1eaf00000000, - 0x4ebbcb7d00000000, 0x0fa0471300000000, 0xcc8dd3a000000000, - 0x8d965fce00000000}, - {0x0000000000000000, 0x1dfdb50100000000, 0x3afa6b0300000000, - 0x2707de0200000000, 0x74f4d70600000000, 0x6909620700000000, - 0x4e0ebc0500000000, 0x53f3090400000000, 0xe8e8af0d00000000, - 0xf5151a0c00000000, 0xd212c40e00000000, 0xcfef710f00000000, - 0x9c1c780b00000000, 0x81e1cd0a00000000, 0xa6e6130800000000, - 0xbb1ba60900000000, 0xd0d15f1b00000000, 0xcd2cea1a00000000, - 0xea2b341800000000, 0xf7d6811900000000, 0xa425881d00000000, - 0xb9d83d1c00000000, 0x9edfe31e00000000, 0x8322561f00000000, - 0x3839f01600000000, 0x25c4451700000000, 0x02c39b1500000000, - 0x1f3e2e1400000000, 0x4ccd271000000000, 0x5130921100000000, - 0x76374c1300000000, 0x6bcaf91200000000, 0xa0a3bf3600000000, - 0xbd5e0a3700000000, 0x9a59d43500000000, 0x87a4613400000000, - 0xd457683000000000, 0xc9aadd3100000000, 0xeead033300000000, - 0xf350b63200000000, 0x484b103b00000000, 0x55b6a53a00000000, - 0x72b17b3800000000, 0x6f4cce3900000000, 0x3cbfc73d00000000, - 0x2142723c00000000, 0x0645ac3e00000000, 0x1bb8193f00000000, - 0x7072e02d00000000, 0x6d8f552c00000000, 0x4a888b2e00000000, - 0x57753e2f00000000, 0x0486372b00000000, 0x197b822a00000000, - 0x3e7c5c2800000000, 0x2381e92900000000, 0x989a4f2000000000, - 0x8567fa2100000000, 0xa260242300000000, 0xbf9d912200000000, - 0xec6e982600000000, 0xf1932d2700000000, 0xd694f32500000000, - 0xcb69462400000000, 0x40477f6d00000000, 0x5dbaca6c00000000, - 0x7abd146e00000000, 0x6740a16f00000000, 0x34b3a86b00000000, - 0x294e1d6a00000000, 0x0e49c36800000000, 0x13b4766900000000, - 0xa8afd06000000000, 0xb552656100000000, 0x9255bb6300000000, - 0x8fa80e6200000000, 0xdc5b076600000000, 0xc1a6b26700000000, - 0xe6a16c6500000000, 0xfb5cd96400000000, 0x9096207600000000, - 0x8d6b957700000000, 0xaa6c4b7500000000, 0xb791fe7400000000, - 0xe462f77000000000, 0xf99f427100000000, 0xde989c7300000000, - 0xc365297200000000, 0x787e8f7b00000000, 0x65833a7a00000000, - 0x4284e47800000000, 0x5f79517900000000, 0x0c8a587d00000000, - 0x1177ed7c00000000, 0x3670337e00000000, 0x2b8d867f00000000, - 0xe0e4c05b00000000, 0xfd19755a00000000, 0xda1eab5800000000, - 0xc7e31e5900000000, 0x9410175d00000000, 0x89eda25c00000000, - 0xaeea7c5e00000000, 0xb317c95f00000000, 0x080c6f5600000000, - 0x15f1da5700000000, 0x32f6045500000000, 0x2f0bb15400000000, - 0x7cf8b85000000000, 0x61050d5100000000, 0x4602d35300000000, - 0x5bff665200000000, 0x30359f4000000000, 0x2dc82a4100000000, - 0x0acff44300000000, 0x1732414200000000, 0x44c1484600000000, - 0x593cfd4700000000, 0x7e3b234500000000, 0x63c6964400000000, - 0xd8dd304d00000000, 0xc520854c00000000, 0xe2275b4e00000000, - 0xffdaee4f00000000, 0xac29e74b00000000, 0xb1d4524a00000000, - 0x96d38c4800000000, 0x8b2e394900000000, 0x808efeda00000000, - 0x9d734bdb00000000, 0xba7495d900000000, 0xa78920d800000000, - 0xf47a29dc00000000, 0xe9879cdd00000000, 0xce8042df00000000, - 0xd37df7de00000000, 0x686651d700000000, 0x759be4d600000000, - 0x529c3ad400000000, 0x4f618fd500000000, 0x1c9286d100000000, - 0x016f33d000000000, 0x2668edd200000000, 0x3b9558d300000000, - 0x505fa1c100000000, 0x4da214c000000000, 0x6aa5cac200000000, - 0x77587fc300000000, 0x24ab76c700000000, 0x3956c3c600000000, - 0x1e511dc400000000, 0x03aca8c500000000, 0xb8b70ecc00000000, - 0xa54abbcd00000000, 0x824d65cf00000000, 0x9fb0d0ce00000000, - 0xcc43d9ca00000000, 0xd1be6ccb00000000, 0xf6b9b2c900000000, - 0xeb4407c800000000, 0x202d41ec00000000, 0x3dd0f4ed00000000, - 0x1ad72aef00000000, 0x072a9fee00000000, 0x54d996ea00000000, - 0x492423eb00000000, 0x6e23fde900000000, 0x73de48e800000000, - 0xc8c5eee100000000, 0xd5385be000000000, 0xf23f85e200000000, - 0xefc230e300000000, 0xbc3139e700000000, 0xa1cc8ce600000000, - 0x86cb52e400000000, 0x9b36e7e500000000, 0xf0fc1ef700000000, - 0xed01abf600000000, 0xca0675f400000000, 0xd7fbc0f500000000, - 0x8408c9f100000000, 0x99f57cf000000000, 0xbef2a2f200000000, - 0xa30f17f300000000, 0x1814b1fa00000000, 0x05e904fb00000000, - 0x22eedaf900000000, 0x3f136ff800000000, 0x6ce066fc00000000, - 0x711dd3fd00000000, 0x561a0dff00000000, 0x4be7b8fe00000000, - 0xc0c981b700000000, 0xdd3434b600000000, 0xfa33eab400000000, - 0xe7ce5fb500000000, 0xb43d56b100000000, 0xa9c0e3b000000000, - 0x8ec73db200000000, 0x933a88b300000000, 0x28212eba00000000, - 0x35dc9bbb00000000, 0x12db45b900000000, 0x0f26f0b800000000, - 0x5cd5f9bc00000000, 0x41284cbd00000000, 0x662f92bf00000000, - 0x7bd227be00000000, 0x1018deac00000000, 0x0de56bad00000000, - 0x2ae2b5af00000000, 0x371f00ae00000000, 0x64ec09aa00000000, - 0x7911bcab00000000, 0x5e1662a900000000, 0x43ebd7a800000000, - 0xf8f071a100000000, 0xe50dc4a000000000, 0xc20a1aa200000000, - 0xdff7afa300000000, 0x8c04a6a700000000, 0x91f913a600000000, - 0xb6fecda400000000, 0xab0378a500000000, 0x606a3e8100000000, - 0x7d978b8000000000, 0x5a90558200000000, 0x476de08300000000, - 0x149ee98700000000, 0x09635c8600000000, 0x2e64828400000000, - 0x3399378500000000, 0x8882918c00000000, 0x957f248d00000000, - 0xb278fa8f00000000, 0xaf854f8e00000000, 0xfc76468a00000000, - 0xe18bf38b00000000, 0xc68c2d8900000000, 0xdb71988800000000, - 0xb0bb619a00000000, 0xad46d49b00000000, 0x8a410a9900000000, - 0x97bcbf9800000000, 0xc44fb69c00000000, 0xd9b2039d00000000, - 0xfeb5dd9f00000000, 0xe348689e00000000, 0x5853ce9700000000, - 0x45ae7b9600000000, 0x62a9a59400000000, 0x7f54109500000000, - 0x2ca7199100000000, 0x315aac9000000000, 0x165d729200000000, - 0x0ba0c79300000000}, - {0x0000000000000000, 0x24d9076300000000, 0x48b20fc600000000, - 0x6c6b08a500000000, 0xd1626e5700000000, 0xf5bb693400000000, - 0x99d0619100000000, 0xbd0966f200000000, 0xa2c5dcae00000000, - 0x861cdbcd00000000, 0xea77d36800000000, 0xceaed40b00000000, - 0x73a7b2f900000000, 0x577eb59a00000000, 0x3b15bd3f00000000, - 0x1fccba5c00000000, 0x058dc88600000000, 0x2154cfe500000000, - 0x4d3fc74000000000, 0x69e6c02300000000, 0xd4efa6d100000000, - 0xf036a1b200000000, 0x9c5da91700000000, 0xb884ae7400000000, - 0xa748142800000000, 0x8391134b00000000, 0xeffa1bee00000000, - 0xcb231c8d00000000, 0x762a7a7f00000000, 0x52f37d1c00000000, - 0x3e9875b900000000, 0x1a4172da00000000, 0x4b1ce0d600000000, - 0x6fc5e7b500000000, 0x03aeef1000000000, 0x2777e87300000000, - 0x9a7e8e8100000000, 0xbea789e200000000, 0xd2cc814700000000, - 0xf615862400000000, 0xe9d93c7800000000, 0xcd003b1b00000000, - 0xa16b33be00000000, 0x85b234dd00000000, 0x38bb522f00000000, - 0x1c62554c00000000, 0x70095de900000000, 0x54d05a8a00000000, - 0x4e91285000000000, 0x6a482f3300000000, 0x0623279600000000, - 0x22fa20f500000000, 0x9ff3460700000000, 0xbb2a416400000000, - 0xd74149c100000000, 0xf3984ea200000000, 0xec54f4fe00000000, - 0xc88df39d00000000, 0xa4e6fb3800000000, 0x803ffc5b00000000, - 0x3d369aa900000000, 0x19ef9dca00000000, 0x7584956f00000000, - 0x515d920c00000000, 0xd73eb17600000000, 0xf3e7b61500000000, - 0x9f8cbeb000000000, 0xbb55b9d300000000, 0x065cdf2100000000, - 0x2285d84200000000, 0x4eeed0e700000000, 0x6a37d78400000000, - 0x75fb6dd800000000, 0x51226abb00000000, 0x3d49621e00000000, - 0x1990657d00000000, 0xa499038f00000000, 0x804004ec00000000, - 0xec2b0c4900000000, 0xc8f20b2a00000000, 0xd2b379f000000000, - 0xf66a7e9300000000, 0x9a01763600000000, 0xbed8715500000000, - 0x03d117a700000000, 0x270810c400000000, 0x4b63186100000000, - 0x6fba1f0200000000, 0x7076a55e00000000, 0x54afa23d00000000, - 0x38c4aa9800000000, 0x1c1dadfb00000000, 0xa114cb0900000000, - 0x85cdcc6a00000000, 0xe9a6c4cf00000000, 0xcd7fc3ac00000000, - 0x9c2251a000000000, 0xb8fb56c300000000, 0xd4905e6600000000, - 0xf049590500000000, 0x4d403ff700000000, 0x6999389400000000, - 0x05f2303100000000, 0x212b375200000000, 0x3ee78d0e00000000, - 0x1a3e8a6d00000000, 0x765582c800000000, 0x528c85ab00000000, - 0xef85e35900000000, 0xcb5ce43a00000000, 0xa737ec9f00000000, - 0x83eeebfc00000000, 0x99af992600000000, 0xbd769e4500000000, - 0xd11d96e000000000, 0xf5c4918300000000, 0x48cdf77100000000, - 0x6c14f01200000000, 0x007ff8b700000000, 0x24a6ffd400000000, - 0x3b6a458800000000, 0x1fb342eb00000000, 0x73d84a4e00000000, - 0x57014d2d00000000, 0xea082bdf00000000, 0xced12cbc00000000, - 0xa2ba241900000000, 0x8663237a00000000, 0xae7d62ed00000000, - 0x8aa4658e00000000, 0xe6cf6d2b00000000, 0xc2166a4800000000, - 0x7f1f0cba00000000, 0x5bc60bd900000000, 0x37ad037c00000000, - 0x1374041f00000000, 0x0cb8be4300000000, 0x2861b92000000000, - 0x440ab18500000000, 0x60d3b6e600000000, 0xdddad01400000000, - 0xf903d77700000000, 0x9568dfd200000000, 0xb1b1d8b100000000, - 0xabf0aa6b00000000, 0x8f29ad0800000000, 0xe342a5ad00000000, - 0xc79ba2ce00000000, 0x7a92c43c00000000, 0x5e4bc35f00000000, - 0x3220cbfa00000000, 0x16f9cc9900000000, 0x093576c500000000, - 0x2dec71a600000000, 0x4187790300000000, 0x655e7e6000000000, - 0xd857189200000000, 0xfc8e1ff100000000, 0x90e5175400000000, - 0xb43c103700000000, 0xe561823b00000000, 0xc1b8855800000000, - 0xadd38dfd00000000, 0x890a8a9e00000000, 0x3403ec6c00000000, - 0x10daeb0f00000000, 0x7cb1e3aa00000000, 0x5868e4c900000000, - 0x47a45e9500000000, 0x637d59f600000000, 0x0f16515300000000, - 0x2bcf563000000000, 0x96c630c200000000, 0xb21f37a100000000, - 0xde743f0400000000, 0xfaad386700000000, 0xe0ec4abd00000000, - 0xc4354dde00000000, 0xa85e457b00000000, 0x8c87421800000000, - 0x318e24ea00000000, 0x1557238900000000, 0x793c2b2c00000000, - 0x5de52c4f00000000, 0x4229961300000000, 0x66f0917000000000, - 0x0a9b99d500000000, 0x2e429eb600000000, 0x934bf84400000000, - 0xb792ff2700000000, 0xdbf9f78200000000, 0xff20f0e100000000, - 0x7943d39b00000000, 0x5d9ad4f800000000, 0x31f1dc5d00000000, - 0x1528db3e00000000, 0xa821bdcc00000000, 0x8cf8baaf00000000, - 0xe093b20a00000000, 0xc44ab56900000000, 0xdb860f3500000000, - 0xff5f085600000000, 0x933400f300000000, 0xb7ed079000000000, - 0x0ae4616200000000, 0x2e3d660100000000, 0x42566ea400000000, - 0x668f69c700000000, 0x7cce1b1d00000000, 0x58171c7e00000000, - 0x347c14db00000000, 0x10a513b800000000, 0xadac754a00000000, - 0x8975722900000000, 0xe51e7a8c00000000, 0xc1c77def00000000, - 0xde0bc7b300000000, 0xfad2c0d000000000, 0x96b9c87500000000, - 0xb260cf1600000000, 0x0f69a9e400000000, 0x2bb0ae8700000000, - 0x47dba62200000000, 0x6302a14100000000, 0x325f334d00000000, - 0x1686342e00000000, 0x7aed3c8b00000000, 0x5e343be800000000, - 0xe33d5d1a00000000, 0xc7e45a7900000000, 0xab8f52dc00000000, - 0x8f5655bf00000000, 0x909aefe300000000, 0xb443e88000000000, - 0xd828e02500000000, 0xfcf1e74600000000, 0x41f881b400000000, - 0x652186d700000000, 0x094a8e7200000000, 0x2d93891100000000, - 0x37d2fbcb00000000, 0x130bfca800000000, 0x7f60f40d00000000, - 0x5bb9f36e00000000, 0xe6b0959c00000000, 0xc26992ff00000000, - 0xae029a5a00000000, 0x8adb9d3900000000, 0x9517276500000000, - 0xb1ce200600000000, 0xdda528a300000000, 0xf97c2fc000000000, - 0x4475493200000000, 0x60ac4e5100000000, 0x0cc746f400000000, - 0x281e419700000000}, - {0x0000000000000000, 0x08e3603c00000000, 0x10c6c17800000000, - 0x1825a14400000000, 0x208c83f100000000, 0x286fe3cd00000000, - 0x304a428900000000, 0x38a922b500000000, 0x011e763800000000, - 0x09fd160400000000, 0x11d8b74000000000, 0x193bd77c00000000, - 0x2192f5c900000000, 0x297195f500000000, 0x315434b100000000, - 0x39b7548d00000000, 0x023cec7000000000, 0x0adf8c4c00000000, - 0x12fa2d0800000000, 0x1a194d3400000000, 0x22b06f8100000000, - 0x2a530fbd00000000, 0x3276aef900000000, 0x3a95cec500000000, - 0x03229a4800000000, 0x0bc1fa7400000000, 0x13e45b3000000000, - 0x1b073b0c00000000, 0x23ae19b900000000, 0x2b4d798500000000, - 0x3368d8c100000000, 0x3b8bb8fd00000000, 0x0478d8e100000000, - 0x0c9bb8dd00000000, 0x14be199900000000, 0x1c5d79a500000000, - 0x24f45b1000000000, 0x2c173b2c00000000, 0x34329a6800000000, - 0x3cd1fa5400000000, 0x0566aed900000000, 0x0d85cee500000000, - 0x15a06fa100000000, 0x1d430f9d00000000, 0x25ea2d2800000000, - 0x2d094d1400000000, 0x352cec5000000000, 0x3dcf8c6c00000000, - 0x0644349100000000, 0x0ea754ad00000000, 0x1682f5e900000000, - 0x1e6195d500000000, 0x26c8b76000000000, 0x2e2bd75c00000000, - 0x360e761800000000, 0x3eed162400000000, 0x075a42a900000000, - 0x0fb9229500000000, 0x179c83d100000000, 0x1f7fe3ed00000000, - 0x27d6c15800000000, 0x2f35a16400000000, 0x3710002000000000, - 0x3ff3601c00000000, 0x49f6c11800000000, 0x4115a12400000000, - 0x5930006000000000, 0x51d3605c00000000, 0x697a42e900000000, - 0x619922d500000000, 0x79bc839100000000, 0x715fe3ad00000000, - 0x48e8b72000000000, 0x400bd71c00000000, 0x582e765800000000, - 0x50cd166400000000, 0x686434d100000000, 0x608754ed00000000, - 0x78a2f5a900000000, 0x7041959500000000, 0x4bca2d6800000000, - 0x43294d5400000000, 0x5b0cec1000000000, 0x53ef8c2c00000000, - 0x6b46ae9900000000, 0x63a5cea500000000, 0x7b806fe100000000, - 0x73630fdd00000000, 0x4ad45b5000000000, 0x42373b6c00000000, - 0x5a129a2800000000, 0x52f1fa1400000000, 0x6a58d8a100000000, - 0x62bbb89d00000000, 0x7a9e19d900000000, 0x727d79e500000000, - 0x4d8e19f900000000, 0x456d79c500000000, 0x5d48d88100000000, - 0x55abb8bd00000000, 0x6d029a0800000000, 0x65e1fa3400000000, - 0x7dc45b7000000000, 0x75273b4c00000000, 0x4c906fc100000000, - 0x44730ffd00000000, 0x5c56aeb900000000, 0x54b5ce8500000000, - 0x6c1cec3000000000, 0x64ff8c0c00000000, 0x7cda2d4800000000, - 0x74394d7400000000, 0x4fb2f58900000000, 0x475195b500000000, - 0x5f7434f100000000, 0x579754cd00000000, 0x6f3e767800000000, - 0x67dd164400000000, 0x7ff8b70000000000, 0x771bd73c00000000, - 0x4eac83b100000000, 0x464fe38d00000000, 0x5e6a42c900000000, - 0x568922f500000000, 0x6e20004000000000, 0x66c3607c00000000, - 0x7ee6c13800000000, 0x7605a10400000000, 0x92ec833100000000, - 0x9a0fe30d00000000, 0x822a424900000000, 0x8ac9227500000000, - 0xb26000c000000000, 0xba8360fc00000000, 0xa2a6c1b800000000, - 0xaa45a18400000000, 0x93f2f50900000000, 0x9b11953500000000, - 0x8334347100000000, 0x8bd7544d00000000, 0xb37e76f800000000, - 0xbb9d16c400000000, 0xa3b8b78000000000, 0xab5bd7bc00000000, - 0x90d06f4100000000, 0x98330f7d00000000, 0x8016ae3900000000, - 0x88f5ce0500000000, 0xb05cecb000000000, 0xb8bf8c8c00000000, - 0xa09a2dc800000000, 0xa8794df400000000, 0x91ce197900000000, - 0x992d794500000000, 0x8108d80100000000, 0x89ebb83d00000000, - 0xb1429a8800000000, 0xb9a1fab400000000, 0xa1845bf000000000, - 0xa9673bcc00000000, 0x96945bd000000000, 0x9e773bec00000000, - 0x86529aa800000000, 0x8eb1fa9400000000, 0xb618d82100000000, - 0xbefbb81d00000000, 0xa6de195900000000, 0xae3d796500000000, - 0x978a2de800000000, 0x9f694dd400000000, 0x874cec9000000000, - 0x8faf8cac00000000, 0xb706ae1900000000, 0xbfe5ce2500000000, - 0xa7c06f6100000000, 0xaf230f5d00000000, 0x94a8b7a000000000, - 0x9c4bd79c00000000, 0x846e76d800000000, 0x8c8d16e400000000, - 0xb424345100000000, 0xbcc7546d00000000, 0xa4e2f52900000000, - 0xac01951500000000, 0x95b6c19800000000, 0x9d55a1a400000000, - 0x857000e000000000, 0x8d9360dc00000000, 0xb53a426900000000, - 0xbdd9225500000000, 0xa5fc831100000000, 0xad1fe32d00000000, - 0xdb1a422900000000, 0xd3f9221500000000, 0xcbdc835100000000, - 0xc33fe36d00000000, 0xfb96c1d800000000, 0xf375a1e400000000, - 0xeb5000a000000000, 0xe3b3609c00000000, 0xda04341100000000, - 0xd2e7542d00000000, 0xcac2f56900000000, 0xc221955500000000, - 0xfa88b7e000000000, 0xf26bd7dc00000000, 0xea4e769800000000, - 0xe2ad16a400000000, 0xd926ae5900000000, 0xd1c5ce6500000000, - 0xc9e06f2100000000, 0xc1030f1d00000000, 0xf9aa2da800000000, - 0xf1494d9400000000, 0xe96cecd000000000, 0xe18f8cec00000000, - 0xd838d86100000000, 0xd0dbb85d00000000, 0xc8fe191900000000, - 0xc01d792500000000, 0xf8b45b9000000000, 0xf0573bac00000000, - 0xe8729ae800000000, 0xe091fad400000000, 0xdf629ac800000000, - 0xd781faf400000000, 0xcfa45bb000000000, 0xc7473b8c00000000, - 0xffee193900000000, 0xf70d790500000000, 0xef28d84100000000, - 0xe7cbb87d00000000, 0xde7cecf000000000, 0xd69f8ccc00000000, - 0xceba2d8800000000, 0xc6594db400000000, 0xfef06f0100000000, - 0xf6130f3d00000000, 0xee36ae7900000000, 0xe6d5ce4500000000, - 0xdd5e76b800000000, 0xd5bd168400000000, 0xcd98b7c000000000, - 0xc57bd7fc00000000, 0xfdd2f54900000000, 0xf531957500000000, - 0xed14343100000000, 0xe5f7540d00000000, 0xdc40008000000000, - 0xd4a360bc00000000, 0xcc86c1f800000000, 0xc465a1c400000000, - 0xfccc837100000000, 0xf42fe34d00000000, 0xec0a420900000000, - 0xe4e9223500000000}, - {0x0000000000000000, 0xd1e8e70e00000000, 0xa2d1cf1d00000000, - 0x7339281300000000, 0x44a39f3b00000000, 0x954b783500000000, - 0xe672502600000000, 0x379ab72800000000, 0x88463f7700000000, - 0x59aed87900000000, 0x2a97f06a00000000, 0xfb7f176400000000, - 0xcce5a04c00000000, 0x1d0d474200000000, 0x6e346f5100000000, - 0xbfdc885f00000000, 0x108d7eee00000000, 0xc16599e000000000, - 0xb25cb1f300000000, 0x63b456fd00000000, 0x542ee1d500000000, - 0x85c606db00000000, 0xf6ff2ec800000000, 0x2717c9c600000000, - 0x98cb419900000000, 0x4923a69700000000, 0x3a1a8e8400000000, - 0xebf2698a00000000, 0xdc68dea200000000, 0x0d8039ac00000000, - 0x7eb911bf00000000, 0xaf51f6b100000000, 0x611c8c0700000000, - 0xb0f46b0900000000, 0xc3cd431a00000000, 0x1225a41400000000, - 0x25bf133c00000000, 0xf457f43200000000, 0x876edc2100000000, - 0x56863b2f00000000, 0xe95ab37000000000, 0x38b2547e00000000, - 0x4b8b7c6d00000000, 0x9a639b6300000000, 0xadf92c4b00000000, - 0x7c11cb4500000000, 0x0f28e35600000000, 0xdec0045800000000, - 0x7191f2e900000000, 0xa07915e700000000, 0xd3403df400000000, - 0x02a8dafa00000000, 0x35326dd200000000, 0xe4da8adc00000000, - 0x97e3a2cf00000000, 0x460b45c100000000, 0xf9d7cd9e00000000, - 0x283f2a9000000000, 0x5b06028300000000, 0x8aeee58d00000000, - 0xbd7452a500000000, 0x6c9cb5ab00000000, 0x1fa59db800000000, - 0xce4d7ab600000000, 0xc238180f00000000, 0x13d0ff0100000000, - 0x60e9d71200000000, 0xb101301c00000000, 0x869b873400000000, - 0x5773603a00000000, 0x244a482900000000, 0xf5a2af2700000000, - 0x4a7e277800000000, 0x9b96c07600000000, 0xe8afe86500000000, - 0x39470f6b00000000, 0x0eddb84300000000, 0xdf355f4d00000000, - 0xac0c775e00000000, 0x7de4905000000000, 0xd2b566e100000000, - 0x035d81ef00000000, 0x7064a9fc00000000, 0xa18c4ef200000000, - 0x9616f9da00000000, 0x47fe1ed400000000, 0x34c736c700000000, - 0xe52fd1c900000000, 0x5af3599600000000, 0x8b1bbe9800000000, - 0xf822968b00000000, 0x29ca718500000000, 0x1e50c6ad00000000, - 0xcfb821a300000000, 0xbc8109b000000000, 0x6d69eebe00000000, - 0xa324940800000000, 0x72cc730600000000, 0x01f55b1500000000, - 0xd01dbc1b00000000, 0xe7870b3300000000, 0x366fec3d00000000, - 0x4556c42e00000000, 0x94be232000000000, 0x2b62ab7f00000000, - 0xfa8a4c7100000000, 0x89b3646200000000, 0x585b836c00000000, - 0x6fc1344400000000, 0xbe29d34a00000000, 0xcd10fb5900000000, - 0x1cf81c5700000000, 0xb3a9eae600000000, 0x62410de800000000, - 0x117825fb00000000, 0xc090c2f500000000, 0xf70a75dd00000000, - 0x26e292d300000000, 0x55dbbac000000000, 0x84335dce00000000, - 0x3befd59100000000, 0xea07329f00000000, 0x993e1a8c00000000, - 0x48d6fd8200000000, 0x7f4c4aaa00000000, 0xaea4ada400000000, - 0xdd9d85b700000000, 0x0c7562b900000000, 0x8471301e00000000, - 0x5599d71000000000, 0x26a0ff0300000000, 0xf748180d00000000, - 0xc0d2af2500000000, 0x113a482b00000000, 0x6203603800000000, - 0xb3eb873600000000, 0x0c370f6900000000, 0xdddfe86700000000, - 0xaee6c07400000000, 0x7f0e277a00000000, 0x4894905200000000, - 0x997c775c00000000, 0xea455f4f00000000, 0x3badb84100000000, - 0x94fc4ef000000000, 0x4514a9fe00000000, 0x362d81ed00000000, - 0xe7c566e300000000, 0xd05fd1cb00000000, 0x01b736c500000000, - 0x728e1ed600000000, 0xa366f9d800000000, 0x1cba718700000000, - 0xcd52968900000000, 0xbe6bbe9a00000000, 0x6f83599400000000, - 0x5819eebc00000000, 0x89f109b200000000, 0xfac821a100000000, - 0x2b20c6af00000000, 0xe56dbc1900000000, 0x34855b1700000000, - 0x47bc730400000000, 0x9654940a00000000, 0xa1ce232200000000, - 0x7026c42c00000000, 0x031fec3f00000000, 0xd2f70b3100000000, - 0x6d2b836e00000000, 0xbcc3646000000000, 0xcffa4c7300000000, - 0x1e12ab7d00000000, 0x29881c5500000000, 0xf860fb5b00000000, - 0x8b59d34800000000, 0x5ab1344600000000, 0xf5e0c2f700000000, - 0x240825f900000000, 0x57310dea00000000, 0x86d9eae400000000, - 0xb1435dcc00000000, 0x60abbac200000000, 0x139292d100000000, - 0xc27a75df00000000, 0x7da6fd8000000000, 0xac4e1a8e00000000, - 0xdf77329d00000000, 0x0e9fd59300000000, 0x390562bb00000000, - 0xe8ed85b500000000, 0x9bd4ada600000000, 0x4a3c4aa800000000, - 0x4649281100000000, 0x97a1cf1f00000000, 0xe498e70c00000000, - 0x3570000200000000, 0x02eab72a00000000, 0xd302502400000000, - 0xa03b783700000000, 0x71d39f3900000000, 0xce0f176600000000, - 0x1fe7f06800000000, 0x6cded87b00000000, 0xbd363f7500000000, - 0x8aac885d00000000, 0x5b446f5300000000, 0x287d474000000000, - 0xf995a04e00000000, 0x56c456ff00000000, 0x872cb1f100000000, - 0xf41599e200000000, 0x25fd7eec00000000, 0x1267c9c400000000, - 0xc38f2eca00000000, 0xb0b606d900000000, 0x615ee1d700000000, - 0xde82698800000000, 0x0f6a8e8600000000, 0x7c53a69500000000, - 0xadbb419b00000000, 0x9a21f6b300000000, 0x4bc911bd00000000, - 0x38f039ae00000000, 0xe918dea000000000, 0x2755a41600000000, - 0xf6bd431800000000, 0x85846b0b00000000, 0x546c8c0500000000, - 0x63f63b2d00000000, 0xb21edc2300000000, 0xc127f43000000000, - 0x10cf133e00000000, 0xaf139b6100000000, 0x7efb7c6f00000000, - 0x0dc2547c00000000, 0xdc2ab37200000000, 0xebb0045a00000000, - 0x3a58e35400000000, 0x4961cb4700000000, 0x98892c4900000000, - 0x37d8daf800000000, 0xe6303df600000000, 0x950915e500000000, - 0x44e1f2eb00000000, 0x737b45c300000000, 0xa293a2cd00000000, - 0xd1aa8ade00000000, 0x00426dd000000000, 0xbf9ee58f00000000, - 0x6e76028100000000, 0x1d4f2a9200000000, 0xcca7cd9c00000000, - 0xfb3d7ab400000000, 0x2ad59dba00000000, 0x59ecb5a900000000, - 0x880452a700000000}, - {0x0000000000000000, 0xaa05daf100000000, 0x150dc53800000000, - 0xbf081fc900000000, 0x2a1a8a7100000000, 0x801f508000000000, - 0x3f174f4900000000, 0x951295b800000000, 0x543414e300000000, - 0xfe31ce1200000000, 0x4139d1db00000000, 0xeb3c0b2a00000000, - 0x7e2e9e9200000000, 0xd42b446300000000, 0x6b235baa00000000, - 0xc126815b00000000, 0xe96e591d00000000, 0x436b83ec00000000, - 0xfc639c2500000000, 0x566646d400000000, 0xc374d36c00000000, - 0x6971099d00000000, 0xd679165400000000, 0x7c7ccca500000000, - 0xbd5a4dfe00000000, 0x175f970f00000000, 0xa85788c600000000, - 0x0252523700000000, 0x9740c78f00000000, 0x3d451d7e00000000, - 0x824d02b700000000, 0x2848d84600000000, 0xd2ddb23a00000000, - 0x78d868cb00000000, 0xc7d0770200000000, 0x6dd5adf300000000, - 0xf8c7384b00000000, 0x52c2e2ba00000000, 0xedcafd7300000000, - 0x47cf278200000000, 0x86e9a6d900000000, 0x2cec7c2800000000, - 0x93e463e100000000, 0x39e1b91000000000, 0xacf32ca800000000, - 0x06f6f65900000000, 0xb9fee99000000000, 0x13fb336100000000, - 0x3bb3eb2700000000, 0x91b631d600000000, 0x2ebe2e1f00000000, - 0x84bbf4ee00000000, 0x11a9615600000000, 0xbbacbba700000000, - 0x04a4a46e00000000, 0xaea17e9f00000000, 0x6f87ffc400000000, - 0xc582253500000000, 0x7a8a3afc00000000, 0xd08fe00d00000000, - 0x459d75b500000000, 0xef98af4400000000, 0x5090b08d00000000, - 0xfa956a7c00000000, 0xa4bb657500000000, 0x0ebebf8400000000, - 0xb1b6a04d00000000, 0x1bb37abc00000000, 0x8ea1ef0400000000, - 0x24a435f500000000, 0x9bac2a3c00000000, 0x31a9f0cd00000000, - 0xf08f719600000000, 0x5a8aab6700000000, 0xe582b4ae00000000, - 0x4f876e5f00000000, 0xda95fbe700000000, 0x7090211600000000, - 0xcf983edf00000000, 0x659de42e00000000, 0x4dd53c6800000000, - 0xe7d0e69900000000, 0x58d8f95000000000, 0xf2dd23a100000000, - 0x67cfb61900000000, 0xcdca6ce800000000, 0x72c2732100000000, - 0xd8c7a9d000000000, 0x19e1288b00000000, 0xb3e4f27a00000000, - 0x0cecedb300000000, 0xa6e9374200000000, 0x33fba2fa00000000, - 0x99fe780b00000000, 0x26f667c200000000, 0x8cf3bd3300000000, - 0x7666d74f00000000, 0xdc630dbe00000000, 0x636b127700000000, - 0xc96ec88600000000, 0x5c7c5d3e00000000, 0xf67987cf00000000, - 0x4971980600000000, 0xe37442f700000000, 0x2252c3ac00000000, - 0x8857195d00000000, 0x375f069400000000, 0x9d5adc6500000000, - 0x084849dd00000000, 0xa24d932c00000000, 0x1d458ce500000000, - 0xb740561400000000, 0x9f088e5200000000, 0x350d54a300000000, - 0x8a054b6a00000000, 0x2000919b00000000, 0xb512042300000000, - 0x1f17ded200000000, 0xa01fc11b00000000, 0x0a1a1bea00000000, - 0xcb3c9ab100000000, 0x6139404000000000, 0xde315f8900000000, - 0x7434857800000000, 0xe12610c000000000, 0x4b23ca3100000000, - 0xf42bd5f800000000, 0x5e2e0f0900000000, 0x4877cbea00000000, - 0xe272111b00000000, 0x5d7a0ed200000000, 0xf77fd42300000000, - 0x626d419b00000000, 0xc8689b6a00000000, 0x776084a300000000, - 0xdd655e5200000000, 0x1c43df0900000000, 0xb64605f800000000, - 0x094e1a3100000000, 0xa34bc0c000000000, 0x3659557800000000, - 0x9c5c8f8900000000, 0x2354904000000000, 0x89514ab100000000, - 0xa11992f700000000, 0x0b1c480600000000, 0xb41457cf00000000, - 0x1e118d3e00000000, 0x8b03188600000000, 0x2106c27700000000, - 0x9e0eddbe00000000, 0x340b074f00000000, 0xf52d861400000000, - 0x5f285ce500000000, 0xe020432c00000000, 0x4a2599dd00000000, - 0xdf370c6500000000, 0x7532d69400000000, 0xca3ac95d00000000, - 0x603f13ac00000000, 0x9aaa79d000000000, 0x30afa32100000000, - 0x8fa7bce800000000, 0x25a2661900000000, 0xb0b0f3a100000000, - 0x1ab5295000000000, 0xa5bd369900000000, 0x0fb8ec6800000000, - 0xce9e6d3300000000, 0x649bb7c200000000, 0xdb93a80b00000000, - 0x719672fa00000000, 0xe484e74200000000, 0x4e813db300000000, - 0xf189227a00000000, 0x5b8cf88b00000000, 0x73c420cd00000000, - 0xd9c1fa3c00000000, 0x66c9e5f500000000, 0xcccc3f0400000000, - 0x59deaabc00000000, 0xf3db704d00000000, 0x4cd36f8400000000, - 0xe6d6b57500000000, 0x27f0342e00000000, 0x8df5eedf00000000, - 0x32fdf11600000000, 0x98f82be700000000, 0x0deabe5f00000000, - 0xa7ef64ae00000000, 0x18e77b6700000000, 0xb2e2a19600000000, - 0xecccae9f00000000, 0x46c9746e00000000, 0xf9c16ba700000000, - 0x53c4b15600000000, 0xc6d624ee00000000, 0x6cd3fe1f00000000, - 0xd3dbe1d600000000, 0x79de3b2700000000, 0xb8f8ba7c00000000, - 0x12fd608d00000000, 0xadf57f4400000000, 0x07f0a5b500000000, - 0x92e2300d00000000, 0x38e7eafc00000000, 0x87eff53500000000, - 0x2dea2fc400000000, 0x05a2f78200000000, 0xafa72d7300000000, - 0x10af32ba00000000, 0xbaaae84b00000000, 0x2fb87df300000000, - 0x85bda70200000000, 0x3ab5b8cb00000000, 0x90b0623a00000000, - 0x5196e36100000000, 0xfb93399000000000, 0x449b265900000000, - 0xee9efca800000000, 0x7b8c691000000000, 0xd189b3e100000000, - 0x6e81ac2800000000, 0xc48476d900000000, 0x3e111ca500000000, - 0x9414c65400000000, 0x2b1cd99d00000000, 0x8119036c00000000, - 0x140b96d400000000, 0xbe0e4c2500000000, 0x010653ec00000000, - 0xab03891d00000000, 0x6a25084600000000, 0xc020d2b700000000, - 0x7f28cd7e00000000, 0xd52d178f00000000, 0x403f823700000000, - 0xea3a58c600000000, 0x5532470f00000000, 0xff379dfe00000000, - 0xd77f45b800000000, 0x7d7a9f4900000000, 0xc272808000000000, - 0x68775a7100000000, 0xfd65cfc900000000, 0x5760153800000000, - 0xe8680af100000000, 0x426dd00000000000, 0x834b515b00000000, - 0x294e8baa00000000, 0x9646946300000000, 0x3c434e9200000000, - 0xa951db2a00000000, 0x035401db00000000, 0xbc5c1e1200000000, - 0x1659c4e300000000}}; - -#else /* W == 4 */ - -local const z_crc_t FAR crc_braid_table[][256] = { - {0x00000000, 0xae689191, 0x87a02563, 0x29c8b4f2, 0xd4314c87, - 0x7a59dd16, 0x539169e4, 0xfdf9f875, 0x73139f4f, 0xdd7b0ede, - 0xf4b3ba2c, 0x5adb2bbd, 0xa722d3c8, 0x094a4259, 0x2082f6ab, - 0x8eea673a, 0xe6273e9e, 0x484faf0f, 0x61871bfd, 0xcfef8a6c, - 0x32167219, 0x9c7ee388, 0xb5b6577a, 0x1bdec6eb, 0x9534a1d1, - 0x3b5c3040, 0x129484b2, 0xbcfc1523, 0x4105ed56, 0xef6d7cc7, - 0xc6a5c835, 0x68cd59a4, 0x173f7b7d, 0xb957eaec, 0x909f5e1e, - 0x3ef7cf8f, 0xc30e37fa, 0x6d66a66b, 0x44ae1299, 0xeac68308, - 0x642ce432, 0xca4475a3, 0xe38cc151, 0x4de450c0, 0xb01da8b5, - 0x1e753924, 0x37bd8dd6, 0x99d51c47, 0xf11845e3, 0x5f70d472, - 0x76b86080, 0xd8d0f111, 0x25290964, 0x8b4198f5, 0xa2892c07, - 0x0ce1bd96, 0x820bdaac, 0x2c634b3d, 0x05abffcf, 0xabc36e5e, - 0x563a962b, 0xf85207ba, 0xd19ab348, 0x7ff222d9, 0x2e7ef6fa, - 0x8016676b, 0xa9ded399, 0x07b64208, 0xfa4fba7d, 0x54272bec, - 0x7def9f1e, 0xd3870e8f, 0x5d6d69b5, 0xf305f824, 0xdacd4cd6, - 0x74a5dd47, 0x895c2532, 0x2734b4a3, 0x0efc0051, 0xa09491c0, - 0xc859c864, 0x663159f5, 0x4ff9ed07, 0xe1917c96, 0x1c6884e3, - 0xb2001572, 0x9bc8a180, 0x35a03011, 0xbb4a572b, 0x1522c6ba, - 0x3cea7248, 0x9282e3d9, 0x6f7b1bac, 0xc1138a3d, 0xe8db3ecf, - 0x46b3af5e, 0x39418d87, 0x97291c16, 0xbee1a8e4, 0x10893975, - 0xed70c100, 0x43185091, 0x6ad0e463, 0xc4b875f2, 0x4a5212c8, - 0xe43a8359, 0xcdf237ab, 0x639aa63a, 0x9e635e4f, 0x300bcfde, - 0x19c37b2c, 0xb7abeabd, 0xdf66b319, 0x710e2288, 0x58c6967a, - 0xf6ae07eb, 0x0b57ff9e, 0xa53f6e0f, 0x8cf7dafd, 0x229f4b6c, - 0xac752c56, 0x021dbdc7, 0x2bd50935, 0x85bd98a4, 0x784460d1, - 0xd62cf140, 0xffe445b2, 0x518cd423, 0x5cfdedf4, 0xf2957c65, - 0xdb5dc897, 0x75355906, 0x88cca173, 0x26a430e2, 0x0f6c8410, - 0xa1041581, 0x2fee72bb, 0x8186e32a, 0xa84e57d8, 0x0626c649, - 0xfbdf3e3c, 0x55b7afad, 0x7c7f1b5f, 0xd2178ace, 0xbadad36a, - 0x14b242fb, 0x3d7af609, 0x93126798, 0x6eeb9fed, 0xc0830e7c, - 0xe94bba8e, 0x47232b1f, 0xc9c94c25, 0x67a1ddb4, 0x4e696946, - 0xe001f8d7, 0x1df800a2, 0xb3909133, 0x9a5825c1, 0x3430b450, - 0x4bc29689, 0xe5aa0718, 0xcc62b3ea, 0x620a227b, 0x9ff3da0e, - 0x319b4b9f, 0x1853ff6d, 0xb63b6efc, 0x38d109c6, 0x96b99857, - 0xbf712ca5, 0x1119bd34, 0xece04541, 0x4288d4d0, 0x6b406022, - 0xc528f1b3, 0xade5a817, 0x038d3986, 0x2a458d74, 0x842d1ce5, - 0x79d4e490, 0xd7bc7501, 0xfe74c1f3, 0x501c5062, 0xdef63758, - 0x709ea6c9, 0x5956123b, 0xf73e83aa, 0x0ac77bdf, 0xa4afea4e, - 0x8d675ebc, 0x230fcf2d, 0x72831b0e, 0xdceb8a9f, 0xf5233e6d, - 0x5b4baffc, 0xa6b25789, 0x08dac618, 0x211272ea, 0x8f7ae37b, - 0x01908441, 0xaff815d0, 0x8630a122, 0x285830b3, 0xd5a1c8c6, - 0x7bc95957, 0x5201eda5, 0xfc697c34, 0x94a42590, 0x3accb401, - 0x130400f3, 0xbd6c9162, 0x40956917, 0xeefdf886, 0xc7354c74, - 0x695ddde5, 0xe7b7badf, 0x49df2b4e, 0x60179fbc, 0xce7f0e2d, - 0x3386f658, 0x9dee67c9, 0xb426d33b, 0x1a4e42aa, 0x65bc6073, - 0xcbd4f1e2, 0xe21c4510, 0x4c74d481, 0xb18d2cf4, 0x1fe5bd65, - 0x362d0997, 0x98459806, 0x16afff3c, 0xb8c76ead, 0x910fda5f, - 0x3f674bce, 0xc29eb3bb, 0x6cf6222a, 0x453e96d8, 0xeb560749, - 0x839b5eed, 0x2df3cf7c, 0x043b7b8e, 0xaa53ea1f, 0x57aa126a, - 0xf9c283fb, 0xd00a3709, 0x7e62a698, 0xf088c1a2, 0x5ee05033, - 0x7728e4c1, 0xd9407550, 0x24b98d25, 0x8ad11cb4, 0xa319a846, - 0x0d7139d7}, - {0x00000000, 0xb9fbdbe8, 0xa886b191, 0x117d6a79, 0x8a7c6563, - 0x3387be8b, 0x22fad4f2, 0x9b010f1a, 0xcf89cc87, 0x7672176f, - 0x670f7d16, 0xdef4a6fe, 0x45f5a9e4, 0xfc0e720c, 0xed731875, - 0x5488c39d, 0x44629f4f, 0xfd9944a7, 0xece42ede, 0x551ff536, - 0xce1efa2c, 0x77e521c4, 0x66984bbd, 0xdf639055, 0x8beb53c8, - 0x32108820, 0x236de259, 0x9a9639b1, 0x019736ab, 0xb86ced43, - 0xa911873a, 0x10ea5cd2, 0x88c53e9e, 0x313ee576, 0x20438f0f, - 0x99b854e7, 0x02b95bfd, 0xbb428015, 0xaa3fea6c, 0x13c43184, - 0x474cf219, 0xfeb729f1, 0xefca4388, 0x56319860, 0xcd30977a, - 0x74cb4c92, 0x65b626eb, 0xdc4dfd03, 0xcca7a1d1, 0x755c7a39, - 0x64211040, 0xdddacba8, 0x46dbc4b2, 0xff201f5a, 0xee5d7523, - 0x57a6aecb, 0x032e6d56, 0xbad5b6be, 0xaba8dcc7, 0x1253072f, - 0x89520835, 0x30a9d3dd, 0x21d4b9a4, 0x982f624c, 0xcafb7b7d, - 0x7300a095, 0x627dcaec, 0xdb861104, 0x40871e1e, 0xf97cc5f6, - 0xe801af8f, 0x51fa7467, 0x0572b7fa, 0xbc896c12, 0xadf4066b, - 0x140fdd83, 0x8f0ed299, 0x36f50971, 0x27886308, 0x9e73b8e0, - 0x8e99e432, 0x37623fda, 0x261f55a3, 0x9fe48e4b, 0x04e58151, - 0xbd1e5ab9, 0xac6330c0, 0x1598eb28, 0x411028b5, 0xf8ebf35d, - 0xe9969924, 0x506d42cc, 0xcb6c4dd6, 0x7297963e, 0x63eafc47, - 0xda1127af, 0x423e45e3, 0xfbc59e0b, 0xeab8f472, 0x53432f9a, - 0xc8422080, 0x71b9fb68, 0x60c49111, 0xd93f4af9, 0x8db78964, - 0x344c528c, 0x253138f5, 0x9ccae31d, 0x07cbec07, 0xbe3037ef, - 0xaf4d5d96, 0x16b6867e, 0x065cdaac, 0xbfa70144, 0xaeda6b3d, - 0x1721b0d5, 0x8c20bfcf, 0x35db6427, 0x24a60e5e, 0x9d5dd5b6, - 0xc9d5162b, 0x702ecdc3, 0x6153a7ba, 0xd8a87c52, 0x43a97348, - 0xfa52a8a0, 0xeb2fc2d9, 0x52d41931, 0x4e87f0bb, 0xf77c2b53, - 0xe601412a, 0x5ffa9ac2, 0xc4fb95d8, 0x7d004e30, 0x6c7d2449, - 0xd586ffa1, 0x810e3c3c, 0x38f5e7d4, 0x29888dad, 0x90735645, - 0x0b72595f, 0xb28982b7, 0xa3f4e8ce, 0x1a0f3326, 0x0ae56ff4, - 0xb31eb41c, 0xa263de65, 0x1b98058d, 0x80990a97, 0x3962d17f, - 0x281fbb06, 0x91e460ee, 0xc56ca373, 0x7c97789b, 0x6dea12e2, - 0xd411c90a, 0x4f10c610, 0xf6eb1df8, 0xe7967781, 0x5e6dac69, - 0xc642ce25, 0x7fb915cd, 0x6ec47fb4, 0xd73fa45c, 0x4c3eab46, - 0xf5c570ae, 0xe4b81ad7, 0x5d43c13f, 0x09cb02a2, 0xb030d94a, - 0xa14db333, 0x18b668db, 0x83b767c1, 0x3a4cbc29, 0x2b31d650, - 0x92ca0db8, 0x8220516a, 0x3bdb8a82, 0x2aa6e0fb, 0x935d3b13, - 0x085c3409, 0xb1a7efe1, 0xa0da8598, 0x19215e70, 0x4da99ded, - 0xf4524605, 0xe52f2c7c, 0x5cd4f794, 0xc7d5f88e, 0x7e2e2366, - 0x6f53491f, 0xd6a892f7, 0x847c8bc6, 0x3d87502e, 0x2cfa3a57, - 0x9501e1bf, 0x0e00eea5, 0xb7fb354d, 0xa6865f34, 0x1f7d84dc, - 0x4bf54741, 0xf20e9ca9, 0xe373f6d0, 0x5a882d38, 0xc1892222, - 0x7872f9ca, 0x690f93b3, 0xd0f4485b, 0xc01e1489, 0x79e5cf61, - 0x6898a518, 0xd1637ef0, 0x4a6271ea, 0xf399aa02, 0xe2e4c07b, - 0x5b1f1b93, 0x0f97d80e, 0xb66c03e6, 0xa711699f, 0x1eeab277, - 0x85ebbd6d, 0x3c106685, 0x2d6d0cfc, 0x9496d714, 0x0cb9b558, - 0xb5426eb0, 0xa43f04c9, 0x1dc4df21, 0x86c5d03b, 0x3f3e0bd3, - 0x2e4361aa, 0x97b8ba42, 0xc33079df, 0x7acba237, 0x6bb6c84e, - 0xd24d13a6, 0x494c1cbc, 0xf0b7c754, 0xe1caad2d, 0x583176c5, - 0x48db2a17, 0xf120f1ff, 0xe05d9b86, 0x59a6406e, 0xc2a74f74, - 0x7b5c949c, 0x6a21fee5, 0xd3da250d, 0x8752e690, 0x3ea93d78, - 0x2fd45701, 0x962f8ce9, 0x0d2e83f3, 0xb4d5581b, 0xa5a83262, - 0x1c53e98a}, - {0x00000000, 0x9d0fe176, 0xe16ec4ad, 0x7c6125db, 0x19ac8f1b, - 0x84a36e6d, 0xf8c24bb6, 0x65cdaac0, 0x33591e36, 0xae56ff40, - 0xd237da9b, 0x4f383bed, 0x2af5912d, 0xb7fa705b, 0xcb9b5580, - 0x5694b4f6, 0x66b23c6c, 0xfbbddd1a, 0x87dcf8c1, 0x1ad319b7, - 0x7f1eb377, 0xe2115201, 0x9e7077da, 0x037f96ac, 0x55eb225a, - 0xc8e4c32c, 0xb485e6f7, 0x298a0781, 0x4c47ad41, 0xd1484c37, - 0xad2969ec, 0x3026889a, 0xcd6478d8, 0x506b99ae, 0x2c0abc75, - 0xb1055d03, 0xd4c8f7c3, 0x49c716b5, 0x35a6336e, 0xa8a9d218, - 0xfe3d66ee, 0x63328798, 0x1f53a243, 0x825c4335, 0xe791e9f5, - 0x7a9e0883, 0x06ff2d58, 0x9bf0cc2e, 0xabd644b4, 0x36d9a5c2, - 0x4ab88019, 0xd7b7616f, 0xb27acbaf, 0x2f752ad9, 0x53140f02, - 0xce1bee74, 0x988f5a82, 0x0580bbf4, 0x79e19e2f, 0xe4ee7f59, - 0x8123d599, 0x1c2c34ef, 0x604d1134, 0xfd42f042, 0x41b9f7f1, - 0xdcb61687, 0xa0d7335c, 0x3dd8d22a, 0x581578ea, 0xc51a999c, - 0xb97bbc47, 0x24745d31, 0x72e0e9c7, 0xefef08b1, 0x938e2d6a, - 0x0e81cc1c, 0x6b4c66dc, 0xf64387aa, 0x8a22a271, 0x172d4307, - 0x270bcb9d, 0xba042aeb, 0xc6650f30, 0x5b6aee46, 0x3ea74486, - 0xa3a8a5f0, 0xdfc9802b, 0x42c6615d, 0x1452d5ab, 0x895d34dd, - 0xf53c1106, 0x6833f070, 0x0dfe5ab0, 0x90f1bbc6, 0xec909e1d, - 0x719f7f6b, 0x8cdd8f29, 0x11d26e5f, 0x6db34b84, 0xf0bcaaf2, - 0x95710032, 0x087ee144, 0x741fc49f, 0xe91025e9, 0xbf84911f, - 0x228b7069, 0x5eea55b2, 0xc3e5b4c4, 0xa6281e04, 0x3b27ff72, - 0x4746daa9, 0xda493bdf, 0xea6fb345, 0x77605233, 0x0b0177e8, - 0x960e969e, 0xf3c33c5e, 0x6eccdd28, 0x12adf8f3, 0x8fa21985, - 0xd936ad73, 0x44394c05, 0x385869de, 0xa55788a8, 0xc09a2268, - 0x5d95c31e, 0x21f4e6c5, 0xbcfb07b3, 0x8373efe2, 0x1e7c0e94, - 0x621d2b4f, 0xff12ca39, 0x9adf60f9, 0x07d0818f, 0x7bb1a454, - 0xe6be4522, 0xb02af1d4, 0x2d2510a2, 0x51443579, 0xcc4bd40f, - 0xa9867ecf, 0x34899fb9, 0x48e8ba62, 0xd5e75b14, 0xe5c1d38e, - 0x78ce32f8, 0x04af1723, 0x99a0f655, 0xfc6d5c95, 0x6162bde3, - 0x1d039838, 0x800c794e, 0xd698cdb8, 0x4b972cce, 0x37f60915, - 0xaaf9e863, 0xcf3442a3, 0x523ba3d5, 0x2e5a860e, 0xb3556778, - 0x4e17973a, 0xd318764c, 0xaf795397, 0x3276b2e1, 0x57bb1821, - 0xcab4f957, 0xb6d5dc8c, 0x2bda3dfa, 0x7d4e890c, 0xe041687a, - 0x9c204da1, 0x012facd7, 0x64e20617, 0xf9ede761, 0x858cc2ba, - 0x188323cc, 0x28a5ab56, 0xb5aa4a20, 0xc9cb6ffb, 0x54c48e8d, - 0x3109244d, 0xac06c53b, 0xd067e0e0, 0x4d680196, 0x1bfcb560, - 0x86f35416, 0xfa9271cd, 0x679d90bb, 0x02503a7b, 0x9f5fdb0d, - 0xe33efed6, 0x7e311fa0, 0xc2ca1813, 0x5fc5f965, 0x23a4dcbe, - 0xbeab3dc8, 0xdb669708, 0x4669767e, 0x3a0853a5, 0xa707b2d3, - 0xf1930625, 0x6c9ce753, 0x10fdc288, 0x8df223fe, 0xe83f893e, - 0x75306848, 0x09514d93, 0x945eace5, 0xa478247f, 0x3977c509, - 0x4516e0d2, 0xd81901a4, 0xbdd4ab64, 0x20db4a12, 0x5cba6fc9, - 0xc1b58ebf, 0x97213a49, 0x0a2edb3f, 0x764ffee4, 0xeb401f92, - 0x8e8db552, 0x13825424, 0x6fe371ff, 0xf2ec9089, 0x0fae60cb, - 0x92a181bd, 0xeec0a466, 0x73cf4510, 0x1602efd0, 0x8b0d0ea6, - 0xf76c2b7d, 0x6a63ca0b, 0x3cf77efd, 0xa1f89f8b, 0xdd99ba50, - 0x40965b26, 0x255bf1e6, 0xb8541090, 0xc435354b, 0x593ad43d, - 0x691c5ca7, 0xf413bdd1, 0x8872980a, 0x157d797c, 0x70b0d3bc, - 0xedbf32ca, 0x91de1711, 0x0cd1f667, 0x5a454291, 0xc74aa3e7, - 0xbb2b863c, 0x2624674a, 0x43e9cd8a, 0xdee62cfc, 0xa2870927, - 0x3f88e851}, - {0x00000000, 0xdd96d985, 0x605cb54b, 0xbdca6cce, 0xc0b96a96, - 0x1d2fb313, 0xa0e5dfdd, 0x7d730658, 0x5a03d36d, 0x87950ae8, - 0x3a5f6626, 0xe7c9bfa3, 0x9abab9fb, 0x472c607e, 0xfae60cb0, - 0x2770d535, 0xb407a6da, 0x69917f5f, 0xd45b1391, 0x09cdca14, - 0x74becc4c, 0xa92815c9, 0x14e27907, 0xc974a082, 0xee0475b7, - 0x3392ac32, 0x8e58c0fc, 0x53ce1979, 0x2ebd1f21, 0xf32bc6a4, - 0x4ee1aa6a, 0x937773ef, 0xb37e4bf5, 0x6ee89270, 0xd322febe, - 0x0eb4273b, 0x73c72163, 0xae51f8e6, 0x139b9428, 0xce0d4dad, - 0xe97d9898, 0x34eb411d, 0x89212dd3, 0x54b7f456, 0x29c4f20e, - 0xf4522b8b, 0x49984745, 0x940e9ec0, 0x0779ed2f, 0xdaef34aa, - 0x67255864, 0xbab381e1, 0xc7c087b9, 0x1a565e3c, 0xa79c32f2, - 0x7a0aeb77, 0x5d7a3e42, 0x80ece7c7, 0x3d268b09, 0xe0b0528c, - 0x9dc354d4, 0x40558d51, 0xfd9fe19f, 0x2009381a, 0xbd8d91ab, - 0x601b482e, 0xddd124e0, 0x0047fd65, 0x7d34fb3d, 0xa0a222b8, - 0x1d684e76, 0xc0fe97f3, 0xe78e42c6, 0x3a189b43, 0x87d2f78d, - 0x5a442e08, 0x27372850, 0xfaa1f1d5, 0x476b9d1b, 0x9afd449e, - 0x098a3771, 0xd41ceef4, 0x69d6823a, 0xb4405bbf, 0xc9335de7, - 0x14a58462, 0xa96fe8ac, 0x74f93129, 0x5389e41c, 0x8e1f3d99, - 0x33d55157, 0xee4388d2, 0x93308e8a, 0x4ea6570f, 0xf36c3bc1, - 0x2efae244, 0x0ef3da5e, 0xd36503db, 0x6eaf6f15, 0xb339b690, - 0xce4ab0c8, 0x13dc694d, 0xae160583, 0x7380dc06, 0x54f00933, - 0x8966d0b6, 0x34acbc78, 0xe93a65fd, 0x944963a5, 0x49dfba20, - 0xf415d6ee, 0x29830f6b, 0xbaf47c84, 0x6762a501, 0xdaa8c9cf, - 0x073e104a, 0x7a4d1612, 0xa7dbcf97, 0x1a11a359, 0xc7877adc, - 0xe0f7afe9, 0x3d61766c, 0x80ab1aa2, 0x5d3dc327, 0x204ec57f, - 0xfdd81cfa, 0x40127034, 0x9d84a9b1, 0xa06a2517, 0x7dfcfc92, - 0xc036905c, 0x1da049d9, 0x60d34f81, 0xbd459604, 0x008ffaca, - 0xdd19234f, 0xfa69f67a, 0x27ff2fff, 0x9a354331, 0x47a39ab4, - 0x3ad09cec, 0xe7464569, 0x5a8c29a7, 0x871af022, 0x146d83cd, - 0xc9fb5a48, 0x74313686, 0xa9a7ef03, 0xd4d4e95b, 0x094230de, - 0xb4885c10, 0x691e8595, 0x4e6e50a0, 0x93f88925, 0x2e32e5eb, - 0xf3a43c6e, 0x8ed73a36, 0x5341e3b3, 0xee8b8f7d, 0x331d56f8, - 0x13146ee2, 0xce82b767, 0x7348dba9, 0xaede022c, 0xd3ad0474, - 0x0e3bddf1, 0xb3f1b13f, 0x6e6768ba, 0x4917bd8f, 0x9481640a, - 0x294b08c4, 0xf4ddd141, 0x89aed719, 0x54380e9c, 0xe9f26252, - 0x3464bbd7, 0xa713c838, 0x7a8511bd, 0xc74f7d73, 0x1ad9a4f6, - 0x67aaa2ae, 0xba3c7b2b, 0x07f617e5, 0xda60ce60, 0xfd101b55, - 0x2086c2d0, 0x9d4cae1e, 0x40da779b, 0x3da971c3, 0xe03fa846, - 0x5df5c488, 0x80631d0d, 0x1de7b4bc, 0xc0716d39, 0x7dbb01f7, - 0xa02dd872, 0xdd5ede2a, 0x00c807af, 0xbd026b61, 0x6094b2e4, - 0x47e467d1, 0x9a72be54, 0x27b8d29a, 0xfa2e0b1f, 0x875d0d47, - 0x5acbd4c2, 0xe701b80c, 0x3a976189, 0xa9e01266, 0x7476cbe3, - 0xc9bca72d, 0x142a7ea8, 0x695978f0, 0xb4cfa175, 0x0905cdbb, - 0xd493143e, 0xf3e3c10b, 0x2e75188e, 0x93bf7440, 0x4e29adc5, - 0x335aab9d, 0xeecc7218, 0x53061ed6, 0x8e90c753, 0xae99ff49, - 0x730f26cc, 0xcec54a02, 0x13539387, 0x6e2095df, 0xb3b64c5a, - 0x0e7c2094, 0xd3eaf911, 0xf49a2c24, 0x290cf5a1, 0x94c6996f, - 0x495040ea, 0x342346b2, 0xe9b59f37, 0x547ff3f9, 0x89e92a7c, - 0x1a9e5993, 0xc7088016, 0x7ac2ecd8, 0xa754355d, 0xda273305, - 0x07b1ea80, 0xba7b864e, 0x67ed5fcb, 0x409d8afe, 0x9d0b537b, - 0x20c13fb5, 0xfd57e630, 0x8024e068, 0x5db239ed, 0xe0785523, - 0x3dee8ca6}}; - -local const z_word_t FAR crc_braid_big_table[][256] = { - {0x00000000, 0x85d996dd, 0x4bb55c60, 0xce6ccabd, 0x966ab9c0, - 0x13b32f1d, 0xdddfe5a0, 0x5806737d, 0x6dd3035a, 0xe80a9587, - 0x26665f3a, 0xa3bfc9e7, 0xfbb9ba9a, 0x7e602c47, 0xb00ce6fa, - 0x35d57027, 0xdaa607b4, 0x5f7f9169, 0x91135bd4, 0x14cacd09, - 0x4cccbe74, 0xc91528a9, 0x0779e214, 0x82a074c9, 0xb77504ee, - 0x32ac9233, 0xfcc0588e, 0x7919ce53, 0x211fbd2e, 0xa4c62bf3, - 0x6aaae14e, 0xef737793, 0xf54b7eb3, 0x7092e86e, 0xbefe22d3, - 0x3b27b40e, 0x6321c773, 0xe6f851ae, 0x28949b13, 0xad4d0dce, - 0x98987de9, 0x1d41eb34, 0xd32d2189, 0x56f4b754, 0x0ef2c429, - 0x8b2b52f4, 0x45479849, 0xc09e0e94, 0x2fed7907, 0xaa34efda, - 0x64582567, 0xe181b3ba, 0xb987c0c7, 0x3c5e561a, 0xf2329ca7, - 0x77eb0a7a, 0x423e7a5d, 0xc7e7ec80, 0x098b263d, 0x8c52b0e0, - 0xd454c39d, 0x518d5540, 0x9fe19ffd, 0x1a380920, 0xab918dbd, - 0x2e481b60, 0xe024d1dd, 0x65fd4700, 0x3dfb347d, 0xb822a2a0, - 0x764e681d, 0xf397fec0, 0xc6428ee7, 0x439b183a, 0x8df7d287, - 0x082e445a, 0x50283727, 0xd5f1a1fa, 0x1b9d6b47, 0x9e44fd9a, - 0x71378a09, 0xf4ee1cd4, 0x3a82d669, 0xbf5b40b4, 0xe75d33c9, - 0x6284a514, 0xace86fa9, 0x2931f974, 0x1ce48953, 0x993d1f8e, - 0x5751d533, 0xd28843ee, 0x8a8e3093, 0x0f57a64e, 0xc13b6cf3, - 0x44e2fa2e, 0x5edaf30e, 0xdb0365d3, 0x156faf6e, 0x90b639b3, - 0xc8b04ace, 0x4d69dc13, 0x830516ae, 0x06dc8073, 0x3309f054, - 0xb6d06689, 0x78bcac34, 0xfd653ae9, 0xa5634994, 0x20badf49, - 0xeed615f4, 0x6b0f8329, 0x847cf4ba, 0x01a56267, 0xcfc9a8da, - 0x4a103e07, 0x12164d7a, 0x97cfdba7, 0x59a3111a, 0xdc7a87c7, - 0xe9aff7e0, 0x6c76613d, 0xa21aab80, 0x27c33d5d, 0x7fc54e20, - 0xfa1cd8fd, 0x34701240, 0xb1a9849d, 0x17256aa0, 0x92fcfc7d, - 0x5c9036c0, 0xd949a01d, 0x814fd360, 0x049645bd, 0xcafa8f00, - 0x4f2319dd, 0x7af669fa, 0xff2fff27, 0x3143359a, 0xb49aa347, - 0xec9cd03a, 0x694546e7, 0xa7298c5a, 0x22f01a87, 0xcd836d14, - 0x485afbc9, 0x86363174, 0x03efa7a9, 0x5be9d4d4, 0xde304209, - 0x105c88b4, 0x95851e69, 0xa0506e4e, 0x2589f893, 0xebe5322e, - 0x6e3ca4f3, 0x363ad78e, 0xb3e34153, 0x7d8f8bee, 0xf8561d33, - 0xe26e1413, 0x67b782ce, 0xa9db4873, 0x2c02deae, 0x7404add3, - 0xf1dd3b0e, 0x3fb1f1b3, 0xba68676e, 0x8fbd1749, 0x0a648194, - 0xc4084b29, 0x41d1ddf4, 0x19d7ae89, 0x9c0e3854, 0x5262f2e9, - 0xd7bb6434, 0x38c813a7, 0xbd11857a, 0x737d4fc7, 0xf6a4d91a, - 0xaea2aa67, 0x2b7b3cba, 0xe517f607, 0x60ce60da, 0x551b10fd, - 0xd0c28620, 0x1eae4c9d, 0x9b77da40, 0xc371a93d, 0x46a83fe0, - 0x88c4f55d, 0x0d1d6380, 0xbcb4e71d, 0x396d71c0, 0xf701bb7d, - 0x72d82da0, 0x2ade5edd, 0xaf07c800, 0x616b02bd, 0xe4b29460, - 0xd167e447, 0x54be729a, 0x9ad2b827, 0x1f0b2efa, 0x470d5d87, - 0xc2d4cb5a, 0x0cb801e7, 0x8961973a, 0x6612e0a9, 0xe3cb7674, - 0x2da7bcc9, 0xa87e2a14, 0xf0785969, 0x75a1cfb4, 0xbbcd0509, - 0x3e1493d4, 0x0bc1e3f3, 0x8e18752e, 0x4074bf93, 0xc5ad294e, - 0x9dab5a33, 0x1872ccee, 0xd61e0653, 0x53c7908e, 0x49ff99ae, - 0xcc260f73, 0x024ac5ce, 0x87935313, 0xdf95206e, 0x5a4cb6b3, - 0x94207c0e, 0x11f9ead3, 0x242c9af4, 0xa1f50c29, 0x6f99c694, - 0xea405049, 0xb2462334, 0x379fb5e9, 0xf9f37f54, 0x7c2ae989, - 0x93599e1a, 0x168008c7, 0xd8ecc27a, 0x5d3554a7, 0x053327da, - 0x80eab107, 0x4e867bba, 0xcb5fed67, 0xfe8a9d40, 0x7b530b9d, - 0xb53fc120, 0x30e657fd, 0x68e02480, 0xed39b25d, 0x235578e0, - 0xa68cee3d}, - {0x00000000, 0x76e10f9d, 0xadc46ee1, 0xdb25617c, 0x1b8fac19, - 0x6d6ea384, 0xb64bc2f8, 0xc0aacd65, 0x361e5933, 0x40ff56ae, - 0x9bda37d2, 0xed3b384f, 0x2d91f52a, 0x5b70fab7, 0x80559bcb, - 0xf6b49456, 0x6c3cb266, 0x1addbdfb, 0xc1f8dc87, 0xb719d31a, - 0x77b31e7f, 0x015211e2, 0xda77709e, 0xac967f03, 0x5a22eb55, - 0x2cc3e4c8, 0xf7e685b4, 0x81078a29, 0x41ad474c, 0x374c48d1, - 0xec6929ad, 0x9a882630, 0xd87864cd, 0xae996b50, 0x75bc0a2c, - 0x035d05b1, 0xc3f7c8d4, 0xb516c749, 0x6e33a635, 0x18d2a9a8, - 0xee663dfe, 0x98873263, 0x43a2531f, 0x35435c82, 0xf5e991e7, - 0x83089e7a, 0x582dff06, 0x2eccf09b, 0xb444d6ab, 0xc2a5d936, - 0x1980b84a, 0x6f61b7d7, 0xafcb7ab2, 0xd92a752f, 0x020f1453, - 0x74ee1bce, 0x825a8f98, 0xf4bb8005, 0x2f9ee179, 0x597feee4, - 0x99d52381, 0xef342c1c, 0x34114d60, 0x42f042fd, 0xf1f7b941, - 0x8716b6dc, 0x5c33d7a0, 0x2ad2d83d, 0xea781558, 0x9c991ac5, - 0x47bc7bb9, 0x315d7424, 0xc7e9e072, 0xb108efef, 0x6a2d8e93, - 0x1ccc810e, 0xdc664c6b, 0xaa8743f6, 0x71a2228a, 0x07432d17, - 0x9dcb0b27, 0xeb2a04ba, 0x300f65c6, 0x46ee6a5b, 0x8644a73e, - 0xf0a5a8a3, 0x2b80c9df, 0x5d61c642, 0xabd55214, 0xdd345d89, - 0x06113cf5, 0x70f03368, 0xb05afe0d, 0xc6bbf190, 0x1d9e90ec, - 0x6b7f9f71, 0x298fdd8c, 0x5f6ed211, 0x844bb36d, 0xf2aabcf0, - 0x32007195, 0x44e17e08, 0x9fc41f74, 0xe92510e9, 0x1f9184bf, - 0x69708b22, 0xb255ea5e, 0xc4b4e5c3, 0x041e28a6, 0x72ff273b, - 0xa9da4647, 0xdf3b49da, 0x45b36fea, 0x33526077, 0xe877010b, - 0x9e960e96, 0x5e3cc3f3, 0x28ddcc6e, 0xf3f8ad12, 0x8519a28f, - 0x73ad36d9, 0x054c3944, 0xde695838, 0xa88857a5, 0x68229ac0, - 0x1ec3955d, 0xc5e6f421, 0xb307fbbc, 0xe2ef7383, 0x940e7c1e, - 0x4f2b1d62, 0x39ca12ff, 0xf960df9a, 0x8f81d007, 0x54a4b17b, - 0x2245bee6, 0xd4f12ab0, 0xa210252d, 0x79354451, 0x0fd44bcc, - 0xcf7e86a9, 0xb99f8934, 0x62bae848, 0x145be7d5, 0x8ed3c1e5, - 0xf832ce78, 0x2317af04, 0x55f6a099, 0x955c6dfc, 0xe3bd6261, - 0x3898031d, 0x4e790c80, 0xb8cd98d6, 0xce2c974b, 0x1509f637, - 0x63e8f9aa, 0xa34234cf, 0xd5a33b52, 0x0e865a2e, 0x786755b3, - 0x3a97174e, 0x4c7618d3, 0x975379af, 0xe1b27632, 0x2118bb57, - 0x57f9b4ca, 0x8cdcd5b6, 0xfa3dda2b, 0x0c894e7d, 0x7a6841e0, - 0xa14d209c, 0xd7ac2f01, 0x1706e264, 0x61e7edf9, 0xbac28c85, - 0xcc238318, 0x56aba528, 0x204aaab5, 0xfb6fcbc9, 0x8d8ec454, - 0x4d240931, 0x3bc506ac, 0xe0e067d0, 0x9601684d, 0x60b5fc1b, - 0x1654f386, 0xcd7192fa, 0xbb909d67, 0x7b3a5002, 0x0ddb5f9f, - 0xd6fe3ee3, 0xa01f317e, 0x1318cac2, 0x65f9c55f, 0xbedca423, - 0xc83dabbe, 0x089766db, 0x7e766946, 0xa553083a, 0xd3b207a7, - 0x250693f1, 0x53e79c6c, 0x88c2fd10, 0xfe23f28d, 0x3e893fe8, - 0x48683075, 0x934d5109, 0xe5ac5e94, 0x7f2478a4, 0x09c57739, - 0xd2e01645, 0xa40119d8, 0x64abd4bd, 0x124adb20, 0xc96fba5c, - 0xbf8eb5c1, 0x493a2197, 0x3fdb2e0a, 0xe4fe4f76, 0x921f40eb, - 0x52b58d8e, 0x24548213, 0xff71e36f, 0x8990ecf2, 0xcb60ae0f, - 0xbd81a192, 0x66a4c0ee, 0x1045cf73, 0xd0ef0216, 0xa60e0d8b, - 0x7d2b6cf7, 0x0bca636a, 0xfd7ef73c, 0x8b9ff8a1, 0x50ba99dd, - 0x265b9640, 0xe6f15b25, 0x901054b8, 0x4b3535c4, 0x3dd43a59, - 0xa75c1c69, 0xd1bd13f4, 0x0a987288, 0x7c797d15, 0xbcd3b070, - 0xca32bfed, 0x1117de91, 0x67f6d10c, 0x9142455a, 0xe7a34ac7, - 0x3c862bbb, 0x4a672426, 0x8acde943, 0xfc2ce6de, 0x270987a2, - 0x51e8883f}, - {0x00000000, 0xe8dbfbb9, 0x91b186a8, 0x796a7d11, 0x63657c8a, - 0x8bbe8733, 0xf2d4fa22, 0x1a0f019b, 0x87cc89cf, 0x6f177276, - 0x167d0f67, 0xfea6f4de, 0xe4a9f545, 0x0c720efc, 0x751873ed, - 0x9dc38854, 0x4f9f6244, 0xa74499fd, 0xde2ee4ec, 0x36f51f55, - 0x2cfa1ece, 0xc421e577, 0xbd4b9866, 0x559063df, 0xc853eb8b, - 0x20881032, 0x59e26d23, 0xb139969a, 0xab369701, 0x43ed6cb8, - 0x3a8711a9, 0xd25cea10, 0x9e3ec588, 0x76e53e31, 0x0f8f4320, - 0xe754b899, 0xfd5bb902, 0x158042bb, 0x6cea3faa, 0x8431c413, - 0x19f24c47, 0xf129b7fe, 0x8843caef, 0x60983156, 0x7a9730cd, - 0x924ccb74, 0xeb26b665, 0x03fd4ddc, 0xd1a1a7cc, 0x397a5c75, - 0x40102164, 0xa8cbdadd, 0xb2c4db46, 0x5a1f20ff, 0x23755dee, - 0xcbaea657, 0x566d2e03, 0xbeb6d5ba, 0xc7dca8ab, 0x2f075312, - 0x35085289, 0xddd3a930, 0xa4b9d421, 0x4c622f98, 0x7d7bfbca, - 0x95a00073, 0xecca7d62, 0x041186db, 0x1e1e8740, 0xf6c57cf9, - 0x8faf01e8, 0x6774fa51, 0xfab77205, 0x126c89bc, 0x6b06f4ad, - 0x83dd0f14, 0x99d20e8f, 0x7109f536, 0x08638827, 0xe0b8739e, - 0x32e4998e, 0xda3f6237, 0xa3551f26, 0x4b8ee49f, 0x5181e504, - 0xb95a1ebd, 0xc03063ac, 0x28eb9815, 0xb5281041, 0x5df3ebf8, - 0x249996e9, 0xcc426d50, 0xd64d6ccb, 0x3e969772, 0x47fcea63, - 0xaf2711da, 0xe3453e42, 0x0b9ec5fb, 0x72f4b8ea, 0x9a2f4353, - 0x802042c8, 0x68fbb971, 0x1191c460, 0xf94a3fd9, 0x6489b78d, - 0x8c524c34, 0xf5383125, 0x1de3ca9c, 0x07eccb07, 0xef3730be, - 0x965d4daf, 0x7e86b616, 0xacda5c06, 0x4401a7bf, 0x3d6bdaae, - 0xd5b02117, 0xcfbf208c, 0x2764db35, 0x5e0ea624, 0xb6d55d9d, - 0x2b16d5c9, 0xc3cd2e70, 0xbaa75361, 0x527ca8d8, 0x4873a943, - 0xa0a852fa, 0xd9c22feb, 0x3119d452, 0xbbf0874e, 0x532b7cf7, - 0x2a4101e6, 0xc29afa5f, 0xd895fbc4, 0x304e007d, 0x49247d6c, - 0xa1ff86d5, 0x3c3c0e81, 0xd4e7f538, 0xad8d8829, 0x45567390, - 0x5f59720b, 0xb78289b2, 0xcee8f4a3, 0x26330f1a, 0xf46fe50a, - 0x1cb41eb3, 0x65de63a2, 0x8d05981b, 0x970a9980, 0x7fd16239, - 0x06bb1f28, 0xee60e491, 0x73a36cc5, 0x9b78977c, 0xe212ea6d, - 0x0ac911d4, 0x10c6104f, 0xf81debf6, 0x817796e7, 0x69ac6d5e, - 0x25ce42c6, 0xcd15b97f, 0xb47fc46e, 0x5ca43fd7, 0x46ab3e4c, - 0xae70c5f5, 0xd71ab8e4, 0x3fc1435d, 0xa202cb09, 0x4ad930b0, - 0x33b34da1, 0xdb68b618, 0xc167b783, 0x29bc4c3a, 0x50d6312b, - 0xb80dca92, 0x6a512082, 0x828adb3b, 0xfbe0a62a, 0x133b5d93, - 0x09345c08, 0xe1efa7b1, 0x9885daa0, 0x705e2119, 0xed9da94d, - 0x054652f4, 0x7c2c2fe5, 0x94f7d45c, 0x8ef8d5c7, 0x66232e7e, - 0x1f49536f, 0xf792a8d6, 0xc68b7c84, 0x2e50873d, 0x573afa2c, - 0xbfe10195, 0xa5ee000e, 0x4d35fbb7, 0x345f86a6, 0xdc847d1f, - 0x4147f54b, 0xa99c0ef2, 0xd0f673e3, 0x382d885a, 0x222289c1, - 0xcaf97278, 0xb3930f69, 0x5b48f4d0, 0x89141ec0, 0x61cfe579, - 0x18a59868, 0xf07e63d1, 0xea71624a, 0x02aa99f3, 0x7bc0e4e2, - 0x931b1f5b, 0x0ed8970f, 0xe6036cb6, 0x9f6911a7, 0x77b2ea1e, - 0x6dbdeb85, 0x8566103c, 0xfc0c6d2d, 0x14d79694, 0x58b5b90c, - 0xb06e42b5, 0xc9043fa4, 0x21dfc41d, 0x3bd0c586, 0xd30b3e3f, - 0xaa61432e, 0x42bab897, 0xdf7930c3, 0x37a2cb7a, 0x4ec8b66b, - 0xa6134dd2, 0xbc1c4c49, 0x54c7b7f0, 0x2dadcae1, 0xc5763158, - 0x172adb48, 0xfff120f1, 0x869b5de0, 0x6e40a659, 0x744fa7c2, - 0x9c945c7b, 0xe5fe216a, 0x0d25dad3, 0x90e65287, 0x783da93e, - 0x0157d42f, 0xe98c2f96, 0xf3832e0d, 0x1b58d5b4, 0x6232a8a5, - 0x8ae9531c}, - {0x00000000, 0x919168ae, 0x6325a087, 0xf2b4c829, 0x874c31d4, - 0x16dd597a, 0xe4699153, 0x75f8f9fd, 0x4f9f1373, 0xde0e7bdd, - 0x2cbab3f4, 0xbd2bdb5a, 0xc8d322a7, 0x59424a09, 0xabf68220, - 0x3a67ea8e, 0x9e3e27e6, 0x0faf4f48, 0xfd1b8761, 0x6c8aefcf, - 0x19721632, 0x88e37e9c, 0x7a57b6b5, 0xebc6de1b, 0xd1a13495, - 0x40305c3b, 0xb2849412, 0x2315fcbc, 0x56ed0541, 0xc77c6def, - 0x35c8a5c6, 0xa459cd68, 0x7d7b3f17, 0xecea57b9, 0x1e5e9f90, - 0x8fcff73e, 0xfa370ec3, 0x6ba6666d, 0x9912ae44, 0x0883c6ea, - 0x32e42c64, 0xa37544ca, 0x51c18ce3, 0xc050e44d, 0xb5a81db0, - 0x2439751e, 0xd68dbd37, 0x471cd599, 0xe34518f1, 0x72d4705f, - 0x8060b876, 0x11f1d0d8, 0x64092925, 0xf598418b, 0x072c89a2, - 0x96bde10c, 0xacda0b82, 0x3d4b632c, 0xcfffab05, 0x5e6ec3ab, - 0x2b963a56, 0xba0752f8, 0x48b39ad1, 0xd922f27f, 0xfaf67e2e, - 0x6b671680, 0x99d3dea9, 0x0842b607, 0x7dba4ffa, 0xec2b2754, - 0x1e9fef7d, 0x8f0e87d3, 0xb5696d5d, 0x24f805f3, 0xd64ccdda, - 0x47dda574, 0x32255c89, 0xa3b43427, 0x5100fc0e, 0xc09194a0, - 0x64c859c8, 0xf5593166, 0x07edf94f, 0x967c91e1, 0xe384681c, - 0x721500b2, 0x80a1c89b, 0x1130a035, 0x2b574abb, 0xbac62215, - 0x4872ea3c, 0xd9e38292, 0xac1b7b6f, 0x3d8a13c1, 0xcf3edbe8, - 0x5eafb346, 0x878d4139, 0x161c2997, 0xe4a8e1be, 0x75398910, - 0x00c170ed, 0x91501843, 0x63e4d06a, 0xf275b8c4, 0xc812524a, - 0x59833ae4, 0xab37f2cd, 0x3aa69a63, 0x4f5e639e, 0xdecf0b30, - 0x2c7bc319, 0xbdeaabb7, 0x19b366df, 0x88220e71, 0x7a96c658, - 0xeb07aef6, 0x9eff570b, 0x0f6e3fa5, 0xfddaf78c, 0x6c4b9f22, - 0x562c75ac, 0xc7bd1d02, 0x3509d52b, 0xa498bd85, 0xd1604478, - 0x40f12cd6, 0xb245e4ff, 0x23d48c51, 0xf4edfd5c, 0x657c95f2, - 0x97c85ddb, 0x06593575, 0x73a1cc88, 0xe230a426, 0x10846c0f, - 0x811504a1, 0xbb72ee2f, 0x2ae38681, 0xd8574ea8, 0x49c62606, - 0x3c3edffb, 0xadafb755, 0x5f1b7f7c, 0xce8a17d2, 0x6ad3daba, - 0xfb42b214, 0x09f67a3d, 0x98671293, 0xed9feb6e, 0x7c0e83c0, - 0x8eba4be9, 0x1f2b2347, 0x254cc9c9, 0xb4dda167, 0x4669694e, - 0xd7f801e0, 0xa200f81d, 0x339190b3, 0xc125589a, 0x50b43034, - 0x8996c24b, 0x1807aae5, 0xeab362cc, 0x7b220a62, 0x0edaf39f, - 0x9f4b9b31, 0x6dff5318, 0xfc6e3bb6, 0xc609d138, 0x5798b996, - 0xa52c71bf, 0x34bd1911, 0x4145e0ec, 0xd0d48842, 0x2260406b, - 0xb3f128c5, 0x17a8e5ad, 0x86398d03, 0x748d452a, 0xe51c2d84, - 0x90e4d479, 0x0175bcd7, 0xf3c174fe, 0x62501c50, 0x5837f6de, - 0xc9a69e70, 0x3b125659, 0xaa833ef7, 0xdf7bc70a, 0x4eeaafa4, - 0xbc5e678d, 0x2dcf0f23, 0x0e1b8372, 0x9f8aebdc, 0x6d3e23f5, - 0xfcaf4b5b, 0x8957b2a6, 0x18c6da08, 0xea721221, 0x7be37a8f, - 0x41849001, 0xd015f8af, 0x22a13086, 0xb3305828, 0xc6c8a1d5, - 0x5759c97b, 0xa5ed0152, 0x347c69fc, 0x9025a494, 0x01b4cc3a, - 0xf3000413, 0x62916cbd, 0x17699540, 0x86f8fdee, 0x744c35c7, - 0xe5dd5d69, 0xdfbab7e7, 0x4e2bdf49, 0xbc9f1760, 0x2d0e7fce, - 0x58f68633, 0xc967ee9d, 0x3bd326b4, 0xaa424e1a, 0x7360bc65, - 0xe2f1d4cb, 0x10451ce2, 0x81d4744c, 0xf42c8db1, 0x65bde51f, - 0x97092d36, 0x06984598, 0x3cffaf16, 0xad6ec7b8, 0x5fda0f91, - 0xce4b673f, 0xbbb39ec2, 0x2a22f66c, 0xd8963e45, 0x490756eb, - 0xed5e9b83, 0x7ccff32d, 0x8e7b3b04, 0x1fea53aa, 0x6a12aa57, - 0xfb83c2f9, 0x09370ad0, 0x98a6627e, 0xa2c188f0, 0x3350e05e, - 0xc1e42877, 0x507540d9, 0x258db924, 0xb41cd18a, 0x46a819a3, - 0xd739710d}}; - -#endif - -#endif - -#if N == 5 - -#if W == 8 - -local const z_crc_t FAR crc_braid_table[][256] = { - {0x00000000, 0xaf449247, 0x85f822cf, 0x2abcb088, 0xd08143df, - 0x7fc5d198, 0x55796110, 0xfa3df357, 0x7a7381ff, 0xd53713b8, - 0xff8ba330, 0x50cf3177, 0xaaf2c220, 0x05b65067, 0x2f0ae0ef, - 0x804e72a8, 0xf4e703fe, 0x5ba391b9, 0x711f2131, 0xde5bb376, - 0x24664021, 0x8b22d266, 0xa19e62ee, 0x0edaf0a9, 0x8e948201, - 0x21d01046, 0x0b6ca0ce, 0xa4283289, 0x5e15c1de, 0xf1515399, - 0xdbede311, 0x74a97156, 0x32bf01bd, 0x9dfb93fa, 0xb7472372, - 0x1803b135, 0xe23e4262, 0x4d7ad025, 0x67c660ad, 0xc882f2ea, - 0x48cc8042, 0xe7881205, 0xcd34a28d, 0x627030ca, 0x984dc39d, - 0x370951da, 0x1db5e152, 0xb2f17315, 0xc6580243, 0x691c9004, - 0x43a0208c, 0xece4b2cb, 0x16d9419c, 0xb99dd3db, 0x93216353, - 0x3c65f114, 0xbc2b83bc, 0x136f11fb, 0x39d3a173, 0x96973334, - 0x6caac063, 0xc3ee5224, 0xe952e2ac, 0x461670eb, 0x657e037a, - 0xca3a913d, 0xe08621b5, 0x4fc2b3f2, 0xb5ff40a5, 0x1abbd2e2, - 0x3007626a, 0x9f43f02d, 0x1f0d8285, 0xb04910c2, 0x9af5a04a, - 0x35b1320d, 0xcf8cc15a, 0x60c8531d, 0x4a74e395, 0xe53071d2, - 0x91990084, 0x3edd92c3, 0x1461224b, 0xbb25b00c, 0x4118435b, - 0xee5cd11c, 0xc4e06194, 0x6ba4f3d3, 0xebea817b, 0x44ae133c, - 0x6e12a3b4, 0xc15631f3, 0x3b6bc2a4, 0x942f50e3, 0xbe93e06b, - 0x11d7722c, 0x57c102c7, 0xf8859080, 0xd2392008, 0x7d7db24f, - 0x87404118, 0x2804d35f, 0x02b863d7, 0xadfcf190, 0x2db28338, - 0x82f6117f, 0xa84aa1f7, 0x070e33b0, 0xfd33c0e7, 0x527752a0, - 0x78cbe228, 0xd78f706f, 0xa3260139, 0x0c62937e, 0x26de23f6, - 0x899ab1b1, 0x73a742e6, 0xdce3d0a1, 0xf65f6029, 0x591bf26e, - 0xd95580c6, 0x76111281, 0x5cada209, 0xf3e9304e, 0x09d4c319, - 0xa690515e, 0x8c2ce1d6, 0x23687391, 0xcafc06f4, 0x65b894b3, - 0x4f04243b, 0xe040b67c, 0x1a7d452b, 0xb539d76c, 0x9f8567e4, - 0x30c1f5a3, 0xb08f870b, 0x1fcb154c, 0x3577a5c4, 0x9a333783, - 0x600ec4d4, 0xcf4a5693, 0xe5f6e61b, 0x4ab2745c, 0x3e1b050a, - 0x915f974d, 0xbbe327c5, 0x14a7b582, 0xee9a46d5, 0x41ded492, - 0x6b62641a, 0xc426f65d, 0x446884f5, 0xeb2c16b2, 0xc190a63a, - 0x6ed4347d, 0x94e9c72a, 0x3bad556d, 0x1111e5e5, 0xbe5577a2, - 0xf8430749, 0x5707950e, 0x7dbb2586, 0xd2ffb7c1, 0x28c24496, - 0x8786d6d1, 0xad3a6659, 0x027ef41e, 0x823086b6, 0x2d7414f1, - 0x07c8a479, 0xa88c363e, 0x52b1c569, 0xfdf5572e, 0xd749e7a6, - 0x780d75e1, 0x0ca404b7, 0xa3e096f0, 0x895c2678, 0x2618b43f, - 0xdc254768, 0x7361d52f, 0x59dd65a7, 0xf699f7e0, 0x76d78548, - 0xd993170f, 0xf32fa787, 0x5c6b35c0, 0xa656c697, 0x091254d0, - 0x23aee458, 0x8cea761f, 0xaf82058e, 0x00c697c9, 0x2a7a2741, - 0x853eb506, 0x7f034651, 0xd047d416, 0xfafb649e, 0x55bff6d9, - 0xd5f18471, 0x7ab51636, 0x5009a6be, 0xff4d34f9, 0x0570c7ae, - 0xaa3455e9, 0x8088e561, 0x2fcc7726, 0x5b650670, 0xf4219437, - 0xde9d24bf, 0x71d9b6f8, 0x8be445af, 0x24a0d7e8, 0x0e1c6760, - 0xa158f527, 0x2116878f, 0x8e5215c8, 0xa4eea540, 0x0baa3707, - 0xf197c450, 0x5ed35617, 0x746fe69f, 0xdb2b74d8, 0x9d3d0433, - 0x32799674, 0x18c526fc, 0xb781b4bb, 0x4dbc47ec, 0xe2f8d5ab, - 0xc8446523, 0x6700f764, 0xe74e85cc, 0x480a178b, 0x62b6a703, - 0xcdf23544, 0x37cfc613, 0x988b5454, 0xb237e4dc, 0x1d73769b, - 0x69da07cd, 0xc69e958a, 0xec222502, 0x4366b745, 0xb95b4412, - 0x161fd655, 0x3ca366dd, 0x93e7f49a, 0x13a98632, 0xbced1475, - 0x9651a4fd, 0x391536ba, 0xc328c5ed, 0x6c6c57aa, 0x46d0e722, - 0xe9947565}, - {0x00000000, 0x4e890ba9, 0x9d121752, 0xd39b1cfb, 0xe15528e5, - 0xafdc234c, 0x7c473fb7, 0x32ce341e, 0x19db578b, 0x57525c22, - 0x84c940d9, 0xca404b70, 0xf88e7f6e, 0xb60774c7, 0x659c683c, - 0x2b156395, 0x33b6af16, 0x7d3fa4bf, 0xaea4b844, 0xe02db3ed, - 0xd2e387f3, 0x9c6a8c5a, 0x4ff190a1, 0x01789b08, 0x2a6df89d, - 0x64e4f334, 0xb77fefcf, 0xf9f6e466, 0xcb38d078, 0x85b1dbd1, - 0x562ac72a, 0x18a3cc83, 0x676d5e2c, 0x29e45585, 0xfa7f497e, - 0xb4f642d7, 0x863876c9, 0xc8b17d60, 0x1b2a619b, 0x55a36a32, - 0x7eb609a7, 0x303f020e, 0xe3a41ef5, 0xad2d155c, 0x9fe32142, - 0xd16a2aeb, 0x02f13610, 0x4c783db9, 0x54dbf13a, 0x1a52fa93, - 0xc9c9e668, 0x8740edc1, 0xb58ed9df, 0xfb07d276, 0x289cce8d, - 0x6615c524, 0x4d00a6b1, 0x0389ad18, 0xd012b1e3, 0x9e9bba4a, - 0xac558e54, 0xe2dc85fd, 0x31479906, 0x7fce92af, 0xcedabc58, - 0x8053b7f1, 0x53c8ab0a, 0x1d41a0a3, 0x2f8f94bd, 0x61069f14, - 0xb29d83ef, 0xfc148846, 0xd701ebd3, 0x9988e07a, 0x4a13fc81, - 0x049af728, 0x3654c336, 0x78ddc89f, 0xab46d464, 0xe5cfdfcd, - 0xfd6c134e, 0xb3e518e7, 0x607e041c, 0x2ef70fb5, 0x1c393bab, - 0x52b03002, 0x812b2cf9, 0xcfa22750, 0xe4b744c5, 0xaa3e4f6c, - 0x79a55397, 0x372c583e, 0x05e26c20, 0x4b6b6789, 0x98f07b72, - 0xd67970db, 0xa9b7e274, 0xe73ee9dd, 0x34a5f526, 0x7a2cfe8f, - 0x48e2ca91, 0x066bc138, 0xd5f0ddc3, 0x9b79d66a, 0xb06cb5ff, - 0xfee5be56, 0x2d7ea2ad, 0x63f7a904, 0x51399d1a, 0x1fb096b3, - 0xcc2b8a48, 0x82a281e1, 0x9a014d62, 0xd48846cb, 0x07135a30, - 0x499a5199, 0x7b546587, 0x35dd6e2e, 0xe64672d5, 0xa8cf797c, - 0x83da1ae9, 0xcd531140, 0x1ec80dbb, 0x50410612, 0x628f320c, - 0x2c0639a5, 0xff9d255e, 0xb1142ef7, 0x46c47ef1, 0x084d7558, - 0xdbd669a3, 0x955f620a, 0xa7915614, 0xe9185dbd, 0x3a834146, - 0x740a4aef, 0x5f1f297a, 0x119622d3, 0xc20d3e28, 0x8c843581, - 0xbe4a019f, 0xf0c30a36, 0x235816cd, 0x6dd11d64, 0x7572d1e7, - 0x3bfbda4e, 0xe860c6b5, 0xa6e9cd1c, 0x9427f902, 0xdaaef2ab, - 0x0935ee50, 0x47bce5f9, 0x6ca9866c, 0x22208dc5, 0xf1bb913e, - 0xbf329a97, 0x8dfcae89, 0xc375a520, 0x10eeb9db, 0x5e67b272, - 0x21a920dd, 0x6f202b74, 0xbcbb378f, 0xf2323c26, 0xc0fc0838, - 0x8e750391, 0x5dee1f6a, 0x136714c3, 0x38727756, 0x76fb7cff, - 0xa5606004, 0xebe96bad, 0xd9275fb3, 0x97ae541a, 0x443548e1, - 0x0abc4348, 0x121f8fcb, 0x5c968462, 0x8f0d9899, 0xc1849330, - 0xf34aa72e, 0xbdc3ac87, 0x6e58b07c, 0x20d1bbd5, 0x0bc4d840, - 0x454dd3e9, 0x96d6cf12, 0xd85fc4bb, 0xea91f0a5, 0xa418fb0c, - 0x7783e7f7, 0x390aec5e, 0x881ec2a9, 0xc697c900, 0x150cd5fb, - 0x5b85de52, 0x694bea4c, 0x27c2e1e5, 0xf459fd1e, 0xbad0f6b7, - 0x91c59522, 0xdf4c9e8b, 0x0cd78270, 0x425e89d9, 0x7090bdc7, - 0x3e19b66e, 0xed82aa95, 0xa30ba13c, 0xbba86dbf, 0xf5216616, - 0x26ba7aed, 0x68337144, 0x5afd455a, 0x14744ef3, 0xc7ef5208, - 0x896659a1, 0xa2733a34, 0xecfa319d, 0x3f612d66, 0x71e826cf, - 0x432612d1, 0x0daf1978, 0xde340583, 0x90bd0e2a, 0xef739c85, - 0xa1fa972c, 0x72618bd7, 0x3ce8807e, 0x0e26b460, 0x40afbfc9, - 0x9334a332, 0xddbda89b, 0xf6a8cb0e, 0xb821c0a7, 0x6bbadc5c, - 0x2533d7f5, 0x17fde3eb, 0x5974e842, 0x8aeff4b9, 0xc466ff10, - 0xdcc53393, 0x924c383a, 0x41d724c1, 0x0f5e2f68, 0x3d901b76, - 0x731910df, 0xa0820c24, 0xee0b078d, 0xc51e6418, 0x8b976fb1, - 0x580c734a, 0x168578e3, 0x244b4cfd, 0x6ac24754, 0xb9595baf, - 0xf7d05006}, - {0x00000000, 0x8d88fde2, 0xc060fd85, 0x4de80067, 0x5bb0fd4b, - 0xd63800a9, 0x9bd000ce, 0x1658fd2c, 0xb761fa96, 0x3ae90774, - 0x77010713, 0xfa89faf1, 0xecd107dd, 0x6159fa3f, 0x2cb1fa58, - 0xa13907ba, 0xb5b2f36d, 0x383a0e8f, 0x75d20ee8, 0xf85af30a, - 0xee020e26, 0x638af3c4, 0x2e62f3a3, 0xa3ea0e41, 0x02d309fb, - 0x8f5bf419, 0xc2b3f47e, 0x4f3b099c, 0x5963f4b0, 0xd4eb0952, - 0x99030935, 0x148bf4d7, 0xb014e09b, 0x3d9c1d79, 0x70741d1e, - 0xfdfce0fc, 0xeba41dd0, 0x662ce032, 0x2bc4e055, 0xa64c1db7, - 0x07751a0d, 0x8afde7ef, 0xc715e788, 0x4a9d1a6a, 0x5cc5e746, - 0xd14d1aa4, 0x9ca51ac3, 0x112de721, 0x05a613f6, 0x882eee14, - 0xc5c6ee73, 0x484e1391, 0x5e16eebd, 0xd39e135f, 0x9e761338, - 0x13feeeda, 0xb2c7e960, 0x3f4f1482, 0x72a714e5, 0xff2fe907, - 0xe977142b, 0x64ffe9c9, 0x2917e9ae, 0xa49f144c, 0xbb58c777, - 0x36d03a95, 0x7b383af2, 0xf6b0c710, 0xe0e83a3c, 0x6d60c7de, - 0x2088c7b9, 0xad003a5b, 0x0c393de1, 0x81b1c003, 0xcc59c064, - 0x41d13d86, 0x5789c0aa, 0xda013d48, 0x97e93d2f, 0x1a61c0cd, - 0x0eea341a, 0x8362c9f8, 0xce8ac99f, 0x4302347d, 0x555ac951, - 0xd8d234b3, 0x953a34d4, 0x18b2c936, 0xb98bce8c, 0x3403336e, - 0x79eb3309, 0xf463ceeb, 0xe23b33c7, 0x6fb3ce25, 0x225bce42, - 0xafd333a0, 0x0b4c27ec, 0x86c4da0e, 0xcb2cda69, 0x46a4278b, - 0x50fcdaa7, 0xdd742745, 0x909c2722, 0x1d14dac0, 0xbc2ddd7a, - 0x31a52098, 0x7c4d20ff, 0xf1c5dd1d, 0xe79d2031, 0x6a15ddd3, - 0x27fdddb4, 0xaa752056, 0xbefed481, 0x33762963, 0x7e9e2904, - 0xf316d4e6, 0xe54e29ca, 0x68c6d428, 0x252ed44f, 0xa8a629ad, - 0x099f2e17, 0x8417d3f5, 0xc9ffd392, 0x44772e70, 0x522fd35c, - 0xdfa72ebe, 0x924f2ed9, 0x1fc7d33b, 0xadc088af, 0x2048754d, - 0x6da0752a, 0xe02888c8, 0xf67075e4, 0x7bf88806, 0x36108861, - 0xbb987583, 0x1aa17239, 0x97298fdb, 0xdac18fbc, 0x5749725e, - 0x41118f72, 0xcc997290, 0x817172f7, 0x0cf98f15, 0x18727bc2, - 0x95fa8620, 0xd8128647, 0x559a7ba5, 0x43c28689, 0xce4a7b6b, - 0x83a27b0c, 0x0e2a86ee, 0xaf138154, 0x229b7cb6, 0x6f737cd1, - 0xe2fb8133, 0xf4a37c1f, 0x792b81fd, 0x34c3819a, 0xb94b7c78, - 0x1dd46834, 0x905c95d6, 0xddb495b1, 0x503c6853, 0x4664957f, - 0xcbec689d, 0x860468fa, 0x0b8c9518, 0xaab592a2, 0x273d6f40, - 0x6ad56f27, 0xe75d92c5, 0xf1056fe9, 0x7c8d920b, 0x3165926c, - 0xbced6f8e, 0xa8669b59, 0x25ee66bb, 0x680666dc, 0xe58e9b3e, - 0xf3d66612, 0x7e5e9bf0, 0x33b69b97, 0xbe3e6675, 0x1f0761cf, - 0x928f9c2d, 0xdf679c4a, 0x52ef61a8, 0x44b79c84, 0xc93f6166, - 0x84d76101, 0x095f9ce3, 0x16984fd8, 0x9b10b23a, 0xd6f8b25d, - 0x5b704fbf, 0x4d28b293, 0xc0a04f71, 0x8d484f16, 0x00c0b2f4, - 0xa1f9b54e, 0x2c7148ac, 0x619948cb, 0xec11b529, 0xfa494805, - 0x77c1b5e7, 0x3a29b580, 0xb7a14862, 0xa32abcb5, 0x2ea24157, - 0x634a4130, 0xeec2bcd2, 0xf89a41fe, 0x7512bc1c, 0x38fabc7b, - 0xb5724199, 0x144b4623, 0x99c3bbc1, 0xd42bbba6, 0x59a34644, - 0x4ffbbb68, 0xc273468a, 0x8f9b46ed, 0x0213bb0f, 0xa68caf43, - 0x2b0452a1, 0x66ec52c6, 0xeb64af24, 0xfd3c5208, 0x70b4afea, - 0x3d5caf8d, 0xb0d4526f, 0x11ed55d5, 0x9c65a837, 0xd18da850, - 0x5c0555b2, 0x4a5da89e, 0xc7d5557c, 0x8a3d551b, 0x07b5a8f9, - 0x133e5c2e, 0x9eb6a1cc, 0xd35ea1ab, 0x5ed65c49, 0x488ea165, - 0xc5065c87, 0x88ee5ce0, 0x0566a102, 0xa45fa6b8, 0x29d75b5a, - 0x643f5b3d, 0xe9b7a6df, 0xffef5bf3, 0x7267a611, 0x3f8fa676, - 0xb2075b94}, - {0x00000000, 0x80f0171f, 0xda91287f, 0x5a613f60, 0x6e5356bf, - 0xeea341a0, 0xb4c27ec0, 0x343269df, 0xdca6ad7e, 0x5c56ba61, - 0x06378501, 0x86c7921e, 0xb2f5fbc1, 0x3205ecde, 0x6864d3be, - 0xe894c4a1, 0x623c5cbd, 0xe2cc4ba2, 0xb8ad74c2, 0x385d63dd, - 0x0c6f0a02, 0x8c9f1d1d, 0xd6fe227d, 0x560e3562, 0xbe9af1c3, - 0x3e6ae6dc, 0x640bd9bc, 0xe4fbcea3, 0xd0c9a77c, 0x5039b063, - 0x0a588f03, 0x8aa8981c, 0xc478b97a, 0x4488ae65, 0x1ee99105, - 0x9e19861a, 0xaa2befc5, 0x2adbf8da, 0x70bac7ba, 0xf04ad0a5, - 0x18de1404, 0x982e031b, 0xc24f3c7b, 0x42bf2b64, 0x768d42bb, - 0xf67d55a4, 0xac1c6ac4, 0x2cec7ddb, 0xa644e5c7, 0x26b4f2d8, - 0x7cd5cdb8, 0xfc25daa7, 0xc817b378, 0x48e7a467, 0x12869b07, - 0x92768c18, 0x7ae248b9, 0xfa125fa6, 0xa07360c6, 0x208377d9, - 0x14b11e06, 0x94410919, 0xce203679, 0x4ed02166, 0x538074b5, - 0xd37063aa, 0x89115cca, 0x09e14bd5, 0x3dd3220a, 0xbd233515, - 0xe7420a75, 0x67b21d6a, 0x8f26d9cb, 0x0fd6ced4, 0x55b7f1b4, - 0xd547e6ab, 0xe1758f74, 0x6185986b, 0x3be4a70b, 0xbb14b014, - 0x31bc2808, 0xb14c3f17, 0xeb2d0077, 0x6bdd1768, 0x5fef7eb7, - 0xdf1f69a8, 0x857e56c8, 0x058e41d7, 0xed1a8576, 0x6dea9269, - 0x378bad09, 0xb77bba16, 0x8349d3c9, 0x03b9c4d6, 0x59d8fbb6, - 0xd928eca9, 0x97f8cdcf, 0x1708dad0, 0x4d69e5b0, 0xcd99f2af, - 0xf9ab9b70, 0x795b8c6f, 0x233ab30f, 0xa3caa410, 0x4b5e60b1, - 0xcbae77ae, 0x91cf48ce, 0x113f5fd1, 0x250d360e, 0xa5fd2111, - 0xff9c1e71, 0x7f6c096e, 0xf5c49172, 0x7534866d, 0x2f55b90d, - 0xafa5ae12, 0x9b97c7cd, 0x1b67d0d2, 0x4106efb2, 0xc1f6f8ad, - 0x29623c0c, 0xa9922b13, 0xf3f31473, 0x7303036c, 0x47316ab3, - 0xc7c17dac, 0x9da042cc, 0x1d5055d3, 0xa700e96a, 0x27f0fe75, - 0x7d91c115, 0xfd61d60a, 0xc953bfd5, 0x49a3a8ca, 0x13c297aa, - 0x933280b5, 0x7ba64414, 0xfb56530b, 0xa1376c6b, 0x21c77b74, - 0x15f512ab, 0x950505b4, 0xcf643ad4, 0x4f942dcb, 0xc53cb5d7, - 0x45cca2c8, 0x1fad9da8, 0x9f5d8ab7, 0xab6fe368, 0x2b9ff477, - 0x71fecb17, 0xf10edc08, 0x199a18a9, 0x996a0fb6, 0xc30b30d6, - 0x43fb27c9, 0x77c94e16, 0xf7395909, 0xad586669, 0x2da87176, - 0x63785010, 0xe388470f, 0xb9e9786f, 0x39196f70, 0x0d2b06af, - 0x8ddb11b0, 0xd7ba2ed0, 0x574a39cf, 0xbfdefd6e, 0x3f2eea71, - 0x654fd511, 0xe5bfc20e, 0xd18dabd1, 0x517dbcce, 0x0b1c83ae, - 0x8bec94b1, 0x01440cad, 0x81b41bb2, 0xdbd524d2, 0x5b2533cd, - 0x6f175a12, 0xefe74d0d, 0xb586726d, 0x35766572, 0xdde2a1d3, - 0x5d12b6cc, 0x077389ac, 0x87839eb3, 0xb3b1f76c, 0x3341e073, - 0x6920df13, 0xe9d0c80c, 0xf4809ddf, 0x74708ac0, 0x2e11b5a0, - 0xaee1a2bf, 0x9ad3cb60, 0x1a23dc7f, 0x4042e31f, 0xc0b2f400, - 0x282630a1, 0xa8d627be, 0xf2b718de, 0x72470fc1, 0x4675661e, - 0xc6857101, 0x9ce44e61, 0x1c14597e, 0x96bcc162, 0x164cd67d, - 0x4c2de91d, 0xccddfe02, 0xf8ef97dd, 0x781f80c2, 0x227ebfa2, - 0xa28ea8bd, 0x4a1a6c1c, 0xcaea7b03, 0x908b4463, 0x107b537c, - 0x24493aa3, 0xa4b92dbc, 0xfed812dc, 0x7e2805c3, 0x30f824a5, - 0xb00833ba, 0xea690cda, 0x6a991bc5, 0x5eab721a, 0xde5b6505, - 0x843a5a65, 0x04ca4d7a, 0xec5e89db, 0x6cae9ec4, 0x36cfa1a4, - 0xb63fb6bb, 0x820ddf64, 0x02fdc87b, 0x589cf71b, 0xd86ce004, - 0x52c47818, 0xd2346f07, 0x88555067, 0x08a54778, 0x3c972ea7, - 0xbc6739b8, 0xe60606d8, 0x66f611c7, 0x8e62d566, 0x0e92c279, - 0x54f3fd19, 0xd403ea06, 0xe03183d9, 0x60c194c6, 0x3aa0aba6, - 0xba50bcb9}, - {0x00000000, 0x9570d495, 0xf190af6b, 0x64e07bfe, 0x38505897, - 0xad208c02, 0xc9c0f7fc, 0x5cb02369, 0x70a0b12e, 0xe5d065bb, - 0x81301e45, 0x1440cad0, 0x48f0e9b9, 0xdd803d2c, 0xb96046d2, - 0x2c109247, 0xe141625c, 0x7431b6c9, 0x10d1cd37, 0x85a119a2, - 0xd9113acb, 0x4c61ee5e, 0x288195a0, 0xbdf14135, 0x91e1d372, - 0x049107e7, 0x60717c19, 0xf501a88c, 0xa9b18be5, 0x3cc15f70, - 0x5821248e, 0xcd51f01b, 0x19f3c2f9, 0x8c83166c, 0xe8636d92, - 0x7d13b907, 0x21a39a6e, 0xb4d34efb, 0xd0333505, 0x4543e190, - 0x695373d7, 0xfc23a742, 0x98c3dcbc, 0x0db30829, 0x51032b40, - 0xc473ffd5, 0xa093842b, 0x35e350be, 0xf8b2a0a5, 0x6dc27430, - 0x09220fce, 0x9c52db5b, 0xc0e2f832, 0x55922ca7, 0x31725759, - 0xa40283cc, 0x8812118b, 0x1d62c51e, 0x7982bee0, 0xecf26a75, - 0xb042491c, 0x25329d89, 0x41d2e677, 0xd4a232e2, 0x33e785f2, - 0xa6975167, 0xc2772a99, 0x5707fe0c, 0x0bb7dd65, 0x9ec709f0, - 0xfa27720e, 0x6f57a69b, 0x434734dc, 0xd637e049, 0xb2d79bb7, - 0x27a74f22, 0x7b176c4b, 0xee67b8de, 0x8a87c320, 0x1ff717b5, - 0xd2a6e7ae, 0x47d6333b, 0x233648c5, 0xb6469c50, 0xeaf6bf39, - 0x7f866bac, 0x1b661052, 0x8e16c4c7, 0xa2065680, 0x37768215, - 0x5396f9eb, 0xc6e62d7e, 0x9a560e17, 0x0f26da82, 0x6bc6a17c, - 0xfeb675e9, 0x2a14470b, 0xbf64939e, 0xdb84e860, 0x4ef43cf5, - 0x12441f9c, 0x8734cb09, 0xe3d4b0f7, 0x76a46462, 0x5ab4f625, - 0xcfc422b0, 0xab24594e, 0x3e548ddb, 0x62e4aeb2, 0xf7947a27, - 0x937401d9, 0x0604d54c, 0xcb552557, 0x5e25f1c2, 0x3ac58a3c, - 0xafb55ea9, 0xf3057dc0, 0x6675a955, 0x0295d2ab, 0x97e5063e, - 0xbbf59479, 0x2e8540ec, 0x4a653b12, 0xdf15ef87, 0x83a5ccee, - 0x16d5187b, 0x72356385, 0xe745b710, 0x67cf0be4, 0xf2bfdf71, - 0x965fa48f, 0x032f701a, 0x5f9f5373, 0xcaef87e6, 0xae0ffc18, - 0x3b7f288d, 0x176fbaca, 0x821f6e5f, 0xe6ff15a1, 0x738fc134, - 0x2f3fe25d, 0xba4f36c8, 0xdeaf4d36, 0x4bdf99a3, 0x868e69b8, - 0x13febd2d, 0x771ec6d3, 0xe26e1246, 0xbede312f, 0x2baee5ba, - 0x4f4e9e44, 0xda3e4ad1, 0xf62ed896, 0x635e0c03, 0x07be77fd, - 0x92cea368, 0xce7e8001, 0x5b0e5494, 0x3fee2f6a, 0xaa9efbff, - 0x7e3cc91d, 0xeb4c1d88, 0x8fac6676, 0x1adcb2e3, 0x466c918a, - 0xd31c451f, 0xb7fc3ee1, 0x228cea74, 0x0e9c7833, 0x9becaca6, - 0xff0cd758, 0x6a7c03cd, 0x36cc20a4, 0xa3bcf431, 0xc75c8fcf, - 0x522c5b5a, 0x9f7dab41, 0x0a0d7fd4, 0x6eed042a, 0xfb9dd0bf, - 0xa72df3d6, 0x325d2743, 0x56bd5cbd, 0xc3cd8828, 0xefdd1a6f, - 0x7aadcefa, 0x1e4db504, 0x8b3d6191, 0xd78d42f8, 0x42fd966d, - 0x261ded93, 0xb36d3906, 0x54288e16, 0xc1585a83, 0xa5b8217d, - 0x30c8f5e8, 0x6c78d681, 0xf9080214, 0x9de879ea, 0x0898ad7f, - 0x24883f38, 0xb1f8ebad, 0xd5189053, 0x406844c6, 0x1cd867af, - 0x89a8b33a, 0xed48c8c4, 0x78381c51, 0xb569ec4a, 0x201938df, - 0x44f94321, 0xd18997b4, 0x8d39b4dd, 0x18496048, 0x7ca91bb6, - 0xe9d9cf23, 0xc5c95d64, 0x50b989f1, 0x3459f20f, 0xa129269a, - 0xfd9905f3, 0x68e9d166, 0x0c09aa98, 0x99797e0d, 0x4ddb4cef, - 0xd8ab987a, 0xbc4be384, 0x293b3711, 0x758b1478, 0xe0fbc0ed, - 0x841bbb13, 0x116b6f86, 0x3d7bfdc1, 0xa80b2954, 0xcceb52aa, - 0x599b863f, 0x052ba556, 0x905b71c3, 0xf4bb0a3d, 0x61cbdea8, - 0xac9a2eb3, 0x39eafa26, 0x5d0a81d8, 0xc87a554d, 0x94ca7624, - 0x01baa2b1, 0x655ad94f, 0xf02a0dda, 0xdc3a9f9d, 0x494a4b08, - 0x2daa30f6, 0xb8dae463, 0xe46ac70a, 0x711a139f, 0x15fa6861, - 0x808abcf4}, - {0x00000000, 0xcf9e17c8, 0x444d29d1, 0x8bd33e19, 0x889a53a2, - 0x4704446a, 0xccd77a73, 0x03496dbb, 0xca45a105, 0x05dbb6cd, - 0x8e0888d4, 0x41969f1c, 0x42dff2a7, 0x8d41e56f, 0x0692db76, - 0xc90cccbe, 0x4ffa444b, 0x80645383, 0x0bb76d9a, 0xc4297a52, - 0xc76017e9, 0x08fe0021, 0x832d3e38, 0x4cb329f0, 0x85bfe54e, - 0x4a21f286, 0xc1f2cc9f, 0x0e6cdb57, 0x0d25b6ec, 0xc2bba124, - 0x49689f3d, 0x86f688f5, 0x9ff48896, 0x506a9f5e, 0xdbb9a147, - 0x1427b68f, 0x176edb34, 0xd8f0ccfc, 0x5323f2e5, 0x9cbde52d, - 0x55b12993, 0x9a2f3e5b, 0x11fc0042, 0xde62178a, 0xdd2b7a31, - 0x12b56df9, 0x996653e0, 0x56f84428, 0xd00eccdd, 0x1f90db15, - 0x9443e50c, 0x5bddf2c4, 0x58949f7f, 0x970a88b7, 0x1cd9b6ae, - 0xd347a166, 0x1a4b6dd8, 0xd5d57a10, 0x5e064409, 0x919853c1, - 0x92d13e7a, 0x5d4f29b2, 0xd69c17ab, 0x19020063, 0xe498176d, - 0x2b0600a5, 0xa0d53ebc, 0x6f4b2974, 0x6c0244cf, 0xa39c5307, - 0x284f6d1e, 0xe7d17ad6, 0x2eddb668, 0xe143a1a0, 0x6a909fb9, - 0xa50e8871, 0xa647e5ca, 0x69d9f202, 0xe20acc1b, 0x2d94dbd3, - 0xab625326, 0x64fc44ee, 0xef2f7af7, 0x20b16d3f, 0x23f80084, - 0xec66174c, 0x67b52955, 0xa82b3e9d, 0x6127f223, 0xaeb9e5eb, - 0x256adbf2, 0xeaf4cc3a, 0xe9bda181, 0x2623b649, 0xadf08850, - 0x626e9f98, 0x7b6c9ffb, 0xb4f28833, 0x3f21b62a, 0xf0bfa1e2, - 0xf3f6cc59, 0x3c68db91, 0xb7bbe588, 0x7825f240, 0xb1293efe, - 0x7eb72936, 0xf564172f, 0x3afa00e7, 0x39b36d5c, 0xf62d7a94, - 0x7dfe448d, 0xb2605345, 0x3496dbb0, 0xfb08cc78, 0x70dbf261, - 0xbf45e5a9, 0xbc0c8812, 0x73929fda, 0xf841a1c3, 0x37dfb60b, - 0xfed37ab5, 0x314d6d7d, 0xba9e5364, 0x750044ac, 0x76492917, - 0xb9d73edf, 0x320400c6, 0xfd9a170e, 0x1241289b, 0xdddf3f53, - 0x560c014a, 0x99921682, 0x9adb7b39, 0x55456cf1, 0xde9652e8, - 0x11084520, 0xd804899e, 0x179a9e56, 0x9c49a04f, 0x53d7b787, - 0x509eda3c, 0x9f00cdf4, 0x14d3f3ed, 0xdb4de425, 0x5dbb6cd0, - 0x92257b18, 0x19f64501, 0xd66852c9, 0xd5213f72, 0x1abf28ba, - 0x916c16a3, 0x5ef2016b, 0x97fecdd5, 0x5860da1d, 0xd3b3e404, - 0x1c2df3cc, 0x1f649e77, 0xd0fa89bf, 0x5b29b7a6, 0x94b7a06e, - 0x8db5a00d, 0x422bb7c5, 0xc9f889dc, 0x06669e14, 0x052ff3af, - 0xcab1e467, 0x4162da7e, 0x8efccdb6, 0x47f00108, 0x886e16c0, - 0x03bd28d9, 0xcc233f11, 0xcf6a52aa, 0x00f44562, 0x8b277b7b, - 0x44b96cb3, 0xc24fe446, 0x0dd1f38e, 0x8602cd97, 0x499cda5f, - 0x4ad5b7e4, 0x854ba02c, 0x0e989e35, 0xc10689fd, 0x080a4543, - 0xc794528b, 0x4c476c92, 0x83d97b5a, 0x809016e1, 0x4f0e0129, - 0xc4dd3f30, 0x0b4328f8, 0xf6d93ff6, 0x3947283e, 0xb2941627, - 0x7d0a01ef, 0x7e436c54, 0xb1dd7b9c, 0x3a0e4585, 0xf590524d, - 0x3c9c9ef3, 0xf302893b, 0x78d1b722, 0xb74fa0ea, 0xb406cd51, - 0x7b98da99, 0xf04be480, 0x3fd5f348, 0xb9237bbd, 0x76bd6c75, - 0xfd6e526c, 0x32f045a4, 0x31b9281f, 0xfe273fd7, 0x75f401ce, - 0xba6a1606, 0x7366dab8, 0xbcf8cd70, 0x372bf369, 0xf8b5e4a1, - 0xfbfc891a, 0x34629ed2, 0xbfb1a0cb, 0x702fb703, 0x692db760, - 0xa6b3a0a8, 0x2d609eb1, 0xe2fe8979, 0xe1b7e4c2, 0x2e29f30a, - 0xa5facd13, 0x6a64dadb, 0xa3681665, 0x6cf601ad, 0xe7253fb4, - 0x28bb287c, 0x2bf245c7, 0xe46c520f, 0x6fbf6c16, 0xa0217bde, - 0x26d7f32b, 0xe949e4e3, 0x629adafa, 0xad04cd32, 0xae4da089, - 0x61d3b741, 0xea008958, 0x259e9e90, 0xec92522e, 0x230c45e6, - 0xa8df7bff, 0x67416c37, 0x6408018c, 0xab961644, 0x2045285d, - 0xefdb3f95}, - {0x00000000, 0x24825136, 0x4904a26c, 0x6d86f35a, 0x920944d8, - 0xb68b15ee, 0xdb0de6b4, 0xff8fb782, 0xff638ff1, 0xdbe1dec7, - 0xb6672d9d, 0x92e57cab, 0x6d6acb29, 0x49e89a1f, 0x246e6945, - 0x00ec3873, 0x25b619a3, 0x01344895, 0x6cb2bbcf, 0x4830eaf9, - 0xb7bf5d7b, 0x933d0c4d, 0xfebbff17, 0xda39ae21, 0xdad59652, - 0xfe57c764, 0x93d1343e, 0xb7536508, 0x48dcd28a, 0x6c5e83bc, - 0x01d870e6, 0x255a21d0, 0x4b6c3346, 0x6fee6270, 0x0268912a, - 0x26eac01c, 0xd965779e, 0xfde726a8, 0x9061d5f2, 0xb4e384c4, - 0xb40fbcb7, 0x908ded81, 0xfd0b1edb, 0xd9894fed, 0x2606f86f, - 0x0284a959, 0x6f025a03, 0x4b800b35, 0x6eda2ae5, 0x4a587bd3, - 0x27de8889, 0x035cd9bf, 0xfcd36e3d, 0xd8513f0b, 0xb5d7cc51, - 0x91559d67, 0x91b9a514, 0xb53bf422, 0xd8bd0778, 0xfc3f564e, - 0x03b0e1cc, 0x2732b0fa, 0x4ab443a0, 0x6e361296, 0x96d8668c, - 0xb25a37ba, 0xdfdcc4e0, 0xfb5e95d6, 0x04d12254, 0x20537362, - 0x4dd58038, 0x6957d10e, 0x69bbe97d, 0x4d39b84b, 0x20bf4b11, - 0x043d1a27, 0xfbb2ada5, 0xdf30fc93, 0xb2b60fc9, 0x96345eff, - 0xb36e7f2f, 0x97ec2e19, 0xfa6add43, 0xdee88c75, 0x21673bf7, - 0x05e56ac1, 0x6863999b, 0x4ce1c8ad, 0x4c0df0de, 0x688fa1e8, - 0x050952b2, 0x218b0384, 0xde04b406, 0xfa86e530, 0x9700166a, - 0xb382475c, 0xddb455ca, 0xf93604fc, 0x94b0f7a6, 0xb032a690, - 0x4fbd1112, 0x6b3f4024, 0x06b9b37e, 0x223be248, 0x22d7da3b, - 0x06558b0d, 0x6bd37857, 0x4f512961, 0xb0de9ee3, 0x945ccfd5, - 0xf9da3c8f, 0xdd586db9, 0xf8024c69, 0xdc801d5f, 0xb106ee05, - 0x9584bf33, 0x6a0b08b1, 0x4e895987, 0x230faadd, 0x078dfbeb, - 0x0761c398, 0x23e392ae, 0x4e6561f4, 0x6ae730c2, 0x95688740, - 0xb1ead676, 0xdc6c252c, 0xf8ee741a, 0xf6c1cb59, 0xd2439a6f, - 0xbfc56935, 0x9b473803, 0x64c88f81, 0x404adeb7, 0x2dcc2ded, - 0x094e7cdb, 0x09a244a8, 0x2d20159e, 0x40a6e6c4, 0x6424b7f2, - 0x9bab0070, 0xbf295146, 0xd2afa21c, 0xf62df32a, 0xd377d2fa, - 0xf7f583cc, 0x9a737096, 0xbef121a0, 0x417e9622, 0x65fcc714, - 0x087a344e, 0x2cf86578, 0x2c145d0b, 0x08960c3d, 0x6510ff67, - 0x4192ae51, 0xbe1d19d3, 0x9a9f48e5, 0xf719bbbf, 0xd39bea89, - 0xbdadf81f, 0x992fa929, 0xf4a95a73, 0xd02b0b45, 0x2fa4bcc7, - 0x0b26edf1, 0x66a01eab, 0x42224f9d, 0x42ce77ee, 0x664c26d8, - 0x0bcad582, 0x2f4884b4, 0xd0c73336, 0xf4456200, 0x99c3915a, - 0xbd41c06c, 0x981be1bc, 0xbc99b08a, 0xd11f43d0, 0xf59d12e6, - 0x0a12a564, 0x2e90f452, 0x43160708, 0x6794563e, 0x67786e4d, - 0x43fa3f7b, 0x2e7ccc21, 0x0afe9d17, 0xf5712a95, 0xd1f37ba3, - 0xbc7588f9, 0x98f7d9cf, 0x6019add5, 0x449bfce3, 0x291d0fb9, - 0x0d9f5e8f, 0xf210e90d, 0xd692b83b, 0xbb144b61, 0x9f961a57, - 0x9f7a2224, 0xbbf87312, 0xd67e8048, 0xf2fcd17e, 0x0d7366fc, - 0x29f137ca, 0x4477c490, 0x60f595a6, 0x45afb476, 0x612de540, - 0x0cab161a, 0x2829472c, 0xd7a6f0ae, 0xf324a198, 0x9ea252c2, - 0xba2003f4, 0xbacc3b87, 0x9e4e6ab1, 0xf3c899eb, 0xd74ac8dd, - 0x28c57f5f, 0x0c472e69, 0x61c1dd33, 0x45438c05, 0x2b759e93, - 0x0ff7cfa5, 0x62713cff, 0x46f36dc9, 0xb97cda4b, 0x9dfe8b7d, - 0xf0787827, 0xd4fa2911, 0xd4161162, 0xf0944054, 0x9d12b30e, - 0xb990e238, 0x461f55ba, 0x629d048c, 0x0f1bf7d6, 0x2b99a6e0, - 0x0ec38730, 0x2a41d606, 0x47c7255c, 0x6345746a, 0x9ccac3e8, - 0xb84892de, 0xd5ce6184, 0xf14c30b2, 0xf1a008c1, 0xd52259f7, - 0xb8a4aaad, 0x9c26fb9b, 0x63a94c19, 0x472b1d2f, 0x2aadee75, - 0x0e2fbf43}, - {0x00000000, 0x36f290f3, 0x6de521e6, 0x5b17b115, 0xdbca43cc, - 0xed38d33f, 0xb62f622a, 0x80ddf2d9, 0x6ce581d9, 0x5a17112a, - 0x0100a03f, 0x37f230cc, 0xb72fc215, 0x81dd52e6, 0xdacae3f3, - 0xec387300, 0xd9cb03b2, 0xef399341, 0xb42e2254, 0x82dcb2a7, - 0x0201407e, 0x34f3d08d, 0x6fe46198, 0x5916f16b, 0xb52e826b, - 0x83dc1298, 0xd8cba38d, 0xee39337e, 0x6ee4c1a7, 0x58165154, - 0x0301e041, 0x35f370b2, 0x68e70125, 0x5e1591d6, 0x050220c3, - 0x33f0b030, 0xb32d42e9, 0x85dfd21a, 0xdec8630f, 0xe83af3fc, - 0x040280fc, 0x32f0100f, 0x69e7a11a, 0x5f1531e9, 0xdfc8c330, - 0xe93a53c3, 0xb22de2d6, 0x84df7225, 0xb12c0297, 0x87de9264, - 0xdcc92371, 0xea3bb382, 0x6ae6415b, 0x5c14d1a8, 0x070360bd, - 0x31f1f04e, 0xddc9834e, 0xeb3b13bd, 0xb02ca2a8, 0x86de325b, - 0x0603c082, 0x30f15071, 0x6be6e164, 0x5d147197, 0xd1ce024a, - 0xe73c92b9, 0xbc2b23ac, 0x8ad9b35f, 0x0a044186, 0x3cf6d175, - 0x67e16060, 0x5113f093, 0xbd2b8393, 0x8bd91360, 0xd0cea275, - 0xe63c3286, 0x66e1c05f, 0x501350ac, 0x0b04e1b9, 0x3df6714a, - 0x080501f8, 0x3ef7910b, 0x65e0201e, 0x5312b0ed, 0xd3cf4234, - 0xe53dd2c7, 0xbe2a63d2, 0x88d8f321, 0x64e08021, 0x521210d2, - 0x0905a1c7, 0x3ff73134, 0xbf2ac3ed, 0x89d8531e, 0xd2cfe20b, - 0xe43d72f8, 0xb929036f, 0x8fdb939c, 0xd4cc2289, 0xe23eb27a, - 0x62e340a3, 0x5411d050, 0x0f066145, 0x39f4f1b6, 0xd5cc82b6, - 0xe33e1245, 0xb829a350, 0x8edb33a3, 0x0e06c17a, 0x38f45189, - 0x63e3e09c, 0x5511706f, 0x60e200dd, 0x5610902e, 0x0d07213b, - 0x3bf5b1c8, 0xbb284311, 0x8ddad3e2, 0xd6cd62f7, 0xe03ff204, - 0x0c078104, 0x3af511f7, 0x61e2a0e2, 0x57103011, 0xd7cdc2c8, - 0xe13f523b, 0xba28e32e, 0x8cda73dd, 0x78ed02d5, 0x4e1f9226, - 0x15082333, 0x23fab3c0, 0xa3274119, 0x95d5d1ea, 0xcec260ff, - 0xf830f00c, 0x1408830c, 0x22fa13ff, 0x79eda2ea, 0x4f1f3219, - 0xcfc2c0c0, 0xf9305033, 0xa227e126, 0x94d571d5, 0xa1260167, - 0x97d49194, 0xccc32081, 0xfa31b072, 0x7aec42ab, 0x4c1ed258, - 0x1709634d, 0x21fbf3be, 0xcdc380be, 0xfb31104d, 0xa026a158, - 0x96d431ab, 0x1609c372, 0x20fb5381, 0x7bece294, 0x4d1e7267, - 0x100a03f0, 0x26f89303, 0x7def2216, 0x4b1db2e5, 0xcbc0403c, - 0xfd32d0cf, 0xa62561da, 0x90d7f129, 0x7cef8229, 0x4a1d12da, - 0x110aa3cf, 0x27f8333c, 0xa725c1e5, 0x91d75116, 0xcac0e003, - 0xfc3270f0, 0xc9c10042, 0xff3390b1, 0xa42421a4, 0x92d6b157, - 0x120b438e, 0x24f9d37d, 0x7fee6268, 0x491cf29b, 0xa524819b, - 0x93d61168, 0xc8c1a07d, 0xfe33308e, 0x7eeec257, 0x481c52a4, - 0x130be3b1, 0x25f97342, 0xa923009f, 0x9fd1906c, 0xc4c62179, - 0xf234b18a, 0x72e94353, 0x441bd3a0, 0x1f0c62b5, 0x29fef246, - 0xc5c68146, 0xf33411b5, 0xa823a0a0, 0x9ed13053, 0x1e0cc28a, - 0x28fe5279, 0x73e9e36c, 0x451b739f, 0x70e8032d, 0x461a93de, - 0x1d0d22cb, 0x2bffb238, 0xab2240e1, 0x9dd0d012, 0xc6c76107, - 0xf035f1f4, 0x1c0d82f4, 0x2aff1207, 0x71e8a312, 0x471a33e1, - 0xc7c7c138, 0xf13551cb, 0xaa22e0de, 0x9cd0702d, 0xc1c401ba, - 0xf7369149, 0xac21205c, 0x9ad3b0af, 0x1a0e4276, 0x2cfcd285, - 0x77eb6390, 0x4119f363, 0xad218063, 0x9bd31090, 0xc0c4a185, - 0xf6363176, 0x76ebc3af, 0x4019535c, 0x1b0ee249, 0x2dfc72ba, - 0x180f0208, 0x2efd92fb, 0x75ea23ee, 0x4318b31d, 0xc3c541c4, - 0xf537d137, 0xae206022, 0x98d2f0d1, 0x74ea83d1, 0x42181322, - 0x190fa237, 0x2ffd32c4, 0xaf20c01d, 0x99d250ee, 0xc2c5e1fb, - 0xf4377108}}; - -local const z_word_t FAR crc_braid_big_table[][256] = { - {0x0000000000000000, 0xf390f23600000000, 0xe621e56d00000000, - 0x15b1175b00000000, 0xcc43cadb00000000, 0x3fd338ed00000000, - 0x2a622fb600000000, 0xd9f2dd8000000000, 0xd981e56c00000000, - 0x2a11175a00000000, 0x3fa0000100000000, 0xcc30f23700000000, - 0x15c22fb700000000, 0xe652dd8100000000, 0xf3e3cada00000000, - 0x007338ec00000000, 0xb203cbd900000000, 0x419339ef00000000, - 0x54222eb400000000, 0xa7b2dc8200000000, 0x7e40010200000000, - 0x8dd0f33400000000, 0x9861e46f00000000, 0x6bf1165900000000, - 0x6b822eb500000000, 0x9812dc8300000000, 0x8da3cbd800000000, - 0x7e3339ee00000000, 0xa7c1e46e00000000, 0x5451165800000000, - 0x41e0010300000000, 0xb270f33500000000, 0x2501e76800000000, - 0xd691155e00000000, 0xc320020500000000, 0x30b0f03300000000, - 0xe9422db300000000, 0x1ad2df8500000000, 0x0f63c8de00000000, - 0xfcf33ae800000000, 0xfc80020400000000, 0x0f10f03200000000, - 0x1aa1e76900000000, 0xe931155f00000000, 0x30c3c8df00000000, - 0xc3533ae900000000, 0xd6e22db200000000, 0x2572df8400000000, - 0x97022cb100000000, 0x6492de8700000000, 0x7123c9dc00000000, - 0x82b33bea00000000, 0x5b41e66a00000000, 0xa8d1145c00000000, - 0xbd60030700000000, 0x4ef0f13100000000, 0x4e83c9dd00000000, - 0xbd133beb00000000, 0xa8a22cb000000000, 0x5b32de8600000000, - 0x82c0030600000000, 0x7150f13000000000, 0x64e1e66b00000000, - 0x9771145d00000000, 0x4a02ced100000000, 0xb9923ce700000000, - 0xac232bbc00000000, 0x5fb3d98a00000000, 0x8641040a00000000, - 0x75d1f63c00000000, 0x6060e16700000000, 0x93f0135100000000, - 0x93832bbd00000000, 0x6013d98b00000000, 0x75a2ced000000000, - 0x86323ce600000000, 0x5fc0e16600000000, 0xac50135000000000, - 0xb9e1040b00000000, 0x4a71f63d00000000, 0xf801050800000000, - 0x0b91f73e00000000, 0x1e20e06500000000, 0xedb0125300000000, - 0x3442cfd300000000, 0xc7d23de500000000, 0xd2632abe00000000, - 0x21f3d88800000000, 0x2180e06400000000, 0xd210125200000000, - 0xc7a1050900000000, 0x3431f73f00000000, 0xedc32abf00000000, - 0x1e53d88900000000, 0x0be2cfd200000000, 0xf8723de400000000, - 0x6f0329b900000000, 0x9c93db8f00000000, 0x8922ccd400000000, - 0x7ab23ee200000000, 0xa340e36200000000, 0x50d0115400000000, - 0x4561060f00000000, 0xb6f1f43900000000, 0xb682ccd500000000, - 0x45123ee300000000, 0x50a329b800000000, 0xa333db8e00000000, - 0x7ac1060e00000000, 0x8951f43800000000, 0x9ce0e36300000000, - 0x6f70115500000000, 0xdd00e26000000000, 0x2e90105600000000, - 0x3b21070d00000000, 0xc8b1f53b00000000, 0x114328bb00000000, - 0xe2d3da8d00000000, 0xf762cdd600000000, 0x04f23fe000000000, - 0x0481070c00000000, 0xf711f53a00000000, 0xe2a0e26100000000, - 0x1130105700000000, 0xc8c2cdd700000000, 0x3b523fe100000000, - 0x2ee328ba00000000, 0xdd73da8c00000000, 0xd502ed7800000000, - 0x26921f4e00000000, 0x3323081500000000, 0xc0b3fa2300000000, - 0x194127a300000000, 0xead1d59500000000, 0xff60c2ce00000000, - 0x0cf030f800000000, 0x0c83081400000000, 0xff13fa2200000000, - 0xeaa2ed7900000000, 0x19321f4f00000000, 0xc0c0c2cf00000000, - 0x335030f900000000, 0x26e127a200000000, 0xd571d59400000000, - 0x670126a100000000, 0x9491d49700000000, 0x8120c3cc00000000, - 0x72b031fa00000000, 0xab42ec7a00000000, 0x58d21e4c00000000, - 0x4d63091700000000, 0xbef3fb2100000000, 0xbe80c3cd00000000, - 0x4d1031fb00000000, 0x58a126a000000000, 0xab31d49600000000, - 0x72c3091600000000, 0x8153fb2000000000, 0x94e2ec7b00000000, - 0x67721e4d00000000, 0xf0030a1000000000, 0x0393f82600000000, - 0x1622ef7d00000000, 0xe5b21d4b00000000, 0x3c40c0cb00000000, - 0xcfd032fd00000000, 0xda6125a600000000, 0x29f1d79000000000, - 0x2982ef7c00000000, 0xda121d4a00000000, 0xcfa30a1100000000, - 0x3c33f82700000000, 0xe5c125a700000000, 0x1651d79100000000, - 0x03e0c0ca00000000, 0xf07032fc00000000, 0x4200c1c900000000, - 0xb19033ff00000000, 0xa42124a400000000, 0x57b1d69200000000, - 0x8e430b1200000000, 0x7dd3f92400000000, 0x6862ee7f00000000, - 0x9bf21c4900000000, 0x9b8124a500000000, 0x6811d69300000000, - 0x7da0c1c800000000, 0x8e3033fe00000000, 0x57c2ee7e00000000, - 0xa4521c4800000000, 0xb1e30b1300000000, 0x4273f92500000000, - 0x9f0023a900000000, 0x6c90d19f00000000, 0x7921c6c400000000, - 0x8ab134f200000000, 0x5343e97200000000, 0xa0d31b4400000000, - 0xb5620c1f00000000, 0x46f2fe2900000000, 0x4681c6c500000000, - 0xb51134f300000000, 0xa0a023a800000000, 0x5330d19e00000000, - 0x8ac20c1e00000000, 0x7952fe2800000000, 0x6ce3e97300000000, - 0x9f731b4500000000, 0x2d03e87000000000, 0xde931a4600000000, - 0xcb220d1d00000000, 0x38b2ff2b00000000, 0xe14022ab00000000, - 0x12d0d09d00000000, 0x0761c7c600000000, 0xf4f135f000000000, - 0xf4820d1c00000000, 0x0712ff2a00000000, 0x12a3e87100000000, - 0xe1331a4700000000, 0x38c1c7c700000000, 0xcb5135f100000000, - 0xdee022aa00000000, 0x2d70d09c00000000, 0xba01c4c100000000, - 0x499136f700000000, 0x5c2021ac00000000, 0xafb0d39a00000000, - 0x76420e1a00000000, 0x85d2fc2c00000000, 0x9063eb7700000000, - 0x63f3194100000000, 0x638021ad00000000, 0x9010d39b00000000, - 0x85a1c4c000000000, 0x763136f600000000, 0xafc3eb7600000000, - 0x5c53194000000000, 0x49e20e1b00000000, 0xba72fc2d00000000, - 0x08020f1800000000, 0xfb92fd2e00000000, 0xee23ea7500000000, - 0x1db3184300000000, 0xc441c5c300000000, 0x37d137f500000000, - 0x226020ae00000000, 0xd1f0d29800000000, 0xd183ea7400000000, - 0x2213184200000000, 0x37a20f1900000000, 0xc432fd2f00000000, - 0x1dc020af00000000, 0xee50d29900000000, 0xfbe1c5c200000000, - 0x087137f400000000}, - {0x0000000000000000, 0x3651822400000000, 0x6ca2044900000000, - 0x5af3866d00000000, 0xd844099200000000, 0xee158bb600000000, - 0xb4e60ddb00000000, 0x82b78fff00000000, 0xf18f63ff00000000, - 0xc7dee1db00000000, 0x9d2d67b600000000, 0xab7ce59200000000, - 0x29cb6a6d00000000, 0x1f9ae84900000000, 0x45696e2400000000, - 0x7338ec0000000000, 0xa319b62500000000, 0x9548340100000000, - 0xcfbbb26c00000000, 0xf9ea304800000000, 0x7b5dbfb700000000, - 0x4d0c3d9300000000, 0x17ffbbfe00000000, 0x21ae39da00000000, - 0x5296d5da00000000, 0x64c757fe00000000, 0x3e34d19300000000, - 0x086553b700000000, 0x8ad2dc4800000000, 0xbc835e6c00000000, - 0xe670d80100000000, 0xd0215a2500000000, 0x46336c4b00000000, - 0x7062ee6f00000000, 0x2a91680200000000, 0x1cc0ea2600000000, - 0x9e7765d900000000, 0xa826e7fd00000000, 0xf2d5619000000000, - 0xc484e3b400000000, 0xb7bc0fb400000000, 0x81ed8d9000000000, - 0xdb1e0bfd00000000, 0xed4f89d900000000, 0x6ff8062600000000, - 0x59a9840200000000, 0x035a026f00000000, 0x350b804b00000000, - 0xe52ada6e00000000, 0xd37b584a00000000, 0x8988de2700000000, - 0xbfd95c0300000000, 0x3d6ed3fc00000000, 0x0b3f51d800000000, - 0x51ccd7b500000000, 0x679d559100000000, 0x14a5b99100000000, - 0x22f43bb500000000, 0x7807bdd800000000, 0x4e563ffc00000000, - 0xcce1b00300000000, 0xfab0322700000000, 0xa043b44a00000000, - 0x9612366e00000000, 0x8c66d89600000000, 0xba375ab200000000, - 0xe0c4dcdf00000000, 0xd6955efb00000000, 0x5422d10400000000, - 0x6273532000000000, 0x3880d54d00000000, 0x0ed1576900000000, - 0x7de9bb6900000000, 0x4bb8394d00000000, 0x114bbf2000000000, - 0x271a3d0400000000, 0xa5adb2fb00000000, 0x93fc30df00000000, - 0xc90fb6b200000000, 0xff5e349600000000, 0x2f7f6eb300000000, - 0x192eec9700000000, 0x43dd6afa00000000, 0x758ce8de00000000, - 0xf73b672100000000, 0xc16ae50500000000, 0x9b99636800000000, - 0xadc8e14c00000000, 0xdef00d4c00000000, 0xe8a18f6800000000, - 0xb252090500000000, 0x84038b2100000000, 0x06b404de00000000, - 0x30e586fa00000000, 0x6a16009700000000, 0x5c4782b300000000, - 0xca55b4dd00000000, 0xfc0436f900000000, 0xa6f7b09400000000, - 0x90a632b000000000, 0x1211bd4f00000000, 0x24403f6b00000000, - 0x7eb3b90600000000, 0x48e23b2200000000, 0x3bdad72200000000, - 0x0d8b550600000000, 0x5778d36b00000000, 0x6129514f00000000, - 0xe39edeb000000000, 0xd5cf5c9400000000, 0x8f3cdaf900000000, - 0xb96d58dd00000000, 0x694c02f800000000, 0x5f1d80dc00000000, - 0x05ee06b100000000, 0x33bf849500000000, 0xb1080b6a00000000, - 0x8759894e00000000, 0xddaa0f2300000000, 0xebfb8d0700000000, - 0x98c3610700000000, 0xae92e32300000000, 0xf461654e00000000, - 0xc230e76a00000000, 0x4087689500000000, 0x76d6eab100000000, - 0x2c256cdc00000000, 0x1a74eef800000000, 0x59cbc1f600000000, - 0x6f9a43d200000000, 0x3569c5bf00000000, 0x0338479b00000000, - 0x818fc86400000000, 0xb7de4a4000000000, 0xed2dcc2d00000000, - 0xdb7c4e0900000000, 0xa844a20900000000, 0x9e15202d00000000, - 0xc4e6a64000000000, 0xf2b7246400000000, 0x7000ab9b00000000, - 0x465129bf00000000, 0x1ca2afd200000000, 0x2af32df600000000, - 0xfad277d300000000, 0xcc83f5f700000000, 0x9670739a00000000, - 0xa021f1be00000000, 0x22967e4100000000, 0x14c7fc6500000000, - 0x4e347a0800000000, 0x7865f82c00000000, 0x0b5d142c00000000, - 0x3d0c960800000000, 0x67ff106500000000, 0x51ae924100000000, - 0xd3191dbe00000000, 0xe5489f9a00000000, 0xbfbb19f700000000, - 0x89ea9bd300000000, 0x1ff8adbd00000000, 0x29a92f9900000000, - 0x735aa9f400000000, 0x450b2bd000000000, 0xc7bca42f00000000, - 0xf1ed260b00000000, 0xab1ea06600000000, 0x9d4f224200000000, - 0xee77ce4200000000, 0xd8264c6600000000, 0x82d5ca0b00000000, - 0xb484482f00000000, 0x3633c7d000000000, 0x006245f400000000, - 0x5a91c39900000000, 0x6cc041bd00000000, 0xbce11b9800000000, - 0x8ab099bc00000000, 0xd0431fd100000000, 0xe6129df500000000, - 0x64a5120a00000000, 0x52f4902e00000000, 0x0807164300000000, - 0x3e56946700000000, 0x4d6e786700000000, 0x7b3ffa4300000000, - 0x21cc7c2e00000000, 0x179dfe0a00000000, 0x952a71f500000000, - 0xa37bf3d100000000, 0xf98875bc00000000, 0xcfd9f79800000000, - 0xd5ad196000000000, 0xe3fc9b4400000000, 0xb90f1d2900000000, - 0x8f5e9f0d00000000, 0x0de910f200000000, 0x3bb892d600000000, - 0x614b14bb00000000, 0x571a969f00000000, 0x24227a9f00000000, - 0x1273f8bb00000000, 0x48807ed600000000, 0x7ed1fcf200000000, - 0xfc66730d00000000, 0xca37f12900000000, 0x90c4774400000000, - 0xa695f56000000000, 0x76b4af4500000000, 0x40e52d6100000000, - 0x1a16ab0c00000000, 0x2c47292800000000, 0xaef0a6d700000000, - 0x98a124f300000000, 0xc252a29e00000000, 0xf40320ba00000000, - 0x873bccba00000000, 0xb16a4e9e00000000, 0xeb99c8f300000000, - 0xddc84ad700000000, 0x5f7fc52800000000, 0x692e470c00000000, - 0x33ddc16100000000, 0x058c434500000000, 0x939e752b00000000, - 0xa5cff70f00000000, 0xff3c716200000000, 0xc96df34600000000, - 0x4bda7cb900000000, 0x7d8bfe9d00000000, 0x277878f000000000, - 0x1129fad400000000, 0x621116d400000000, 0x544094f000000000, - 0x0eb3129d00000000, 0x38e290b900000000, 0xba551f4600000000, - 0x8c049d6200000000, 0xd6f71b0f00000000, 0xe0a6992b00000000, - 0x3087c30e00000000, 0x06d6412a00000000, 0x5c25c74700000000, - 0x6a74456300000000, 0xe8c3ca9c00000000, 0xde9248b800000000, - 0x8461ced500000000, 0xb2304cf100000000, 0xc108a0f100000000, - 0xf75922d500000000, 0xadaaa4b800000000, 0x9bfb269c00000000, - 0x194ca96300000000, 0x2f1d2b4700000000, 0x75eead2a00000000, - 0x43bf2f0e00000000}, - {0x0000000000000000, 0xc8179ecf00000000, 0xd1294d4400000000, - 0x193ed38b00000000, 0xa2539a8800000000, 0x6a44044700000000, - 0x737ad7cc00000000, 0xbb6d490300000000, 0x05a145ca00000000, - 0xcdb6db0500000000, 0xd488088e00000000, 0x1c9f964100000000, - 0xa7f2df4200000000, 0x6fe5418d00000000, 0x76db920600000000, - 0xbecc0cc900000000, 0x4b44fa4f00000000, 0x8353648000000000, - 0x9a6db70b00000000, 0x527a29c400000000, 0xe91760c700000000, - 0x2100fe0800000000, 0x383e2d8300000000, 0xf029b34c00000000, - 0x4ee5bf8500000000, 0x86f2214a00000000, 0x9fccf2c100000000, - 0x57db6c0e00000000, 0xecb6250d00000000, 0x24a1bbc200000000, - 0x3d9f684900000000, 0xf588f68600000000, 0x9688f49f00000000, - 0x5e9f6a5000000000, 0x47a1b9db00000000, 0x8fb6271400000000, - 0x34db6e1700000000, 0xfcccf0d800000000, 0xe5f2235300000000, - 0x2de5bd9c00000000, 0x9329b15500000000, 0x5b3e2f9a00000000, - 0x4200fc1100000000, 0x8a1762de00000000, 0x317a2bdd00000000, - 0xf96db51200000000, 0xe053669900000000, 0x2844f85600000000, - 0xddcc0ed000000000, 0x15db901f00000000, 0x0ce5439400000000, - 0xc4f2dd5b00000000, 0x7f9f945800000000, 0xb7880a9700000000, - 0xaeb6d91c00000000, 0x66a147d300000000, 0xd86d4b1a00000000, - 0x107ad5d500000000, 0x0944065e00000000, 0xc153989100000000, - 0x7a3ed19200000000, 0xb2294f5d00000000, 0xab179cd600000000, - 0x6300021900000000, 0x6d1798e400000000, 0xa500062b00000000, - 0xbc3ed5a000000000, 0x74294b6f00000000, 0xcf44026c00000000, - 0x07539ca300000000, 0x1e6d4f2800000000, 0xd67ad1e700000000, - 0x68b6dd2e00000000, 0xa0a143e100000000, 0xb99f906a00000000, - 0x71880ea500000000, 0xcae547a600000000, 0x02f2d96900000000, - 0x1bcc0ae200000000, 0xd3db942d00000000, 0x265362ab00000000, - 0xee44fc6400000000, 0xf77a2fef00000000, 0x3f6db12000000000, - 0x8400f82300000000, 0x4c1766ec00000000, 0x5529b56700000000, - 0x9d3e2ba800000000, 0x23f2276100000000, 0xebe5b9ae00000000, - 0xf2db6a2500000000, 0x3accf4ea00000000, 0x81a1bde900000000, - 0x49b6232600000000, 0x5088f0ad00000000, 0x989f6e6200000000, - 0xfb9f6c7b00000000, 0x3388f2b400000000, 0x2ab6213f00000000, - 0xe2a1bff000000000, 0x59ccf6f300000000, 0x91db683c00000000, - 0x88e5bbb700000000, 0x40f2257800000000, 0xfe3e29b100000000, - 0x3629b77e00000000, 0x2f1764f500000000, 0xe700fa3a00000000, - 0x5c6db33900000000, 0x947a2df600000000, 0x8d44fe7d00000000, - 0x455360b200000000, 0xb0db963400000000, 0x78cc08fb00000000, - 0x61f2db7000000000, 0xa9e545bf00000000, 0x12880cbc00000000, - 0xda9f927300000000, 0xc3a141f800000000, 0x0bb6df3700000000, - 0xb57ad3fe00000000, 0x7d6d4d3100000000, 0x64539eba00000000, - 0xac44007500000000, 0x1729497600000000, 0xdf3ed7b900000000, - 0xc600043200000000, 0x0e179afd00000000, 0x9b28411200000000, - 0x533fdfdd00000000, 0x4a010c5600000000, 0x8216929900000000, - 0x397bdb9a00000000, 0xf16c455500000000, 0xe85296de00000000, - 0x2045081100000000, 0x9e8904d800000000, 0x569e9a1700000000, - 0x4fa0499c00000000, 0x87b7d75300000000, 0x3cda9e5000000000, - 0xf4cd009f00000000, 0xedf3d31400000000, 0x25e44ddb00000000, - 0xd06cbb5d00000000, 0x187b259200000000, 0x0145f61900000000, - 0xc95268d600000000, 0x723f21d500000000, 0xba28bf1a00000000, - 0xa3166c9100000000, 0x6b01f25e00000000, 0xd5cdfe9700000000, - 0x1dda605800000000, 0x04e4b3d300000000, 0xccf32d1c00000000, - 0x779e641f00000000, 0xbf89fad000000000, 0xa6b7295b00000000, - 0x6ea0b79400000000, 0x0da0b58d00000000, 0xc5b72b4200000000, - 0xdc89f8c900000000, 0x149e660600000000, 0xaff32f0500000000, - 0x67e4b1ca00000000, 0x7eda624100000000, 0xb6cdfc8e00000000, - 0x0801f04700000000, 0xc0166e8800000000, 0xd928bd0300000000, - 0x113f23cc00000000, 0xaa526acf00000000, 0x6245f40000000000, - 0x7b7b278b00000000, 0xb36cb94400000000, 0x46e44fc200000000, - 0x8ef3d10d00000000, 0x97cd028600000000, 0x5fda9c4900000000, - 0xe4b7d54a00000000, 0x2ca04b8500000000, 0x359e980e00000000, - 0xfd8906c100000000, 0x43450a0800000000, 0x8b5294c700000000, - 0x926c474c00000000, 0x5a7bd98300000000, 0xe116908000000000, - 0x29010e4f00000000, 0x303fddc400000000, 0xf828430b00000000, - 0xf63fd9f600000000, 0x3e28473900000000, 0x271694b200000000, - 0xef010a7d00000000, 0x546c437e00000000, 0x9c7bddb100000000, - 0x85450e3a00000000, 0x4d5290f500000000, 0xf39e9c3c00000000, - 0x3b8902f300000000, 0x22b7d17800000000, 0xeaa04fb700000000, - 0x51cd06b400000000, 0x99da987b00000000, 0x80e44bf000000000, - 0x48f3d53f00000000, 0xbd7b23b900000000, 0x756cbd7600000000, - 0x6c526efd00000000, 0xa445f03200000000, 0x1f28b93100000000, - 0xd73f27fe00000000, 0xce01f47500000000, 0x06166aba00000000, - 0xb8da667300000000, 0x70cdf8bc00000000, 0x69f32b3700000000, - 0xa1e4b5f800000000, 0x1a89fcfb00000000, 0xd29e623400000000, - 0xcba0b1bf00000000, 0x03b72f7000000000, 0x60b72d6900000000, - 0xa8a0b3a600000000, 0xb19e602d00000000, 0x7989fee200000000, - 0xc2e4b7e100000000, 0x0af3292e00000000, 0x13cdfaa500000000, - 0xdbda646a00000000, 0x651668a300000000, 0xad01f66c00000000, - 0xb43f25e700000000, 0x7c28bb2800000000, 0xc745f22b00000000, - 0x0f526ce400000000, 0x166cbf6f00000000, 0xde7b21a000000000, - 0x2bf3d72600000000, 0xe3e449e900000000, 0xfada9a6200000000, - 0x32cd04ad00000000, 0x89a04dae00000000, 0x41b7d36100000000, - 0x588900ea00000000, 0x909e9e2500000000, 0x2e5292ec00000000, - 0xe6450c2300000000, 0xff7bdfa800000000, 0x376c416700000000, - 0x8c01086400000000, 0x441696ab00000000, 0x5d28452000000000, - 0x953fdbef00000000}, - {0x0000000000000000, 0x95d4709500000000, 0x6baf90f100000000, - 0xfe7be06400000000, 0x9758503800000000, 0x028c20ad00000000, - 0xfcf7c0c900000000, 0x6923b05c00000000, 0x2eb1a07000000000, - 0xbb65d0e500000000, 0x451e308100000000, 0xd0ca401400000000, - 0xb9e9f04800000000, 0x2c3d80dd00000000, 0xd24660b900000000, - 0x4792102c00000000, 0x5c6241e100000000, 0xc9b6317400000000, - 0x37cdd11000000000, 0xa219a18500000000, 0xcb3a11d900000000, - 0x5eee614c00000000, 0xa095812800000000, 0x3541f1bd00000000, - 0x72d3e19100000000, 0xe707910400000000, 0x197c716000000000, - 0x8ca801f500000000, 0xe58bb1a900000000, 0x705fc13c00000000, - 0x8e24215800000000, 0x1bf051cd00000000, 0xf9c2f31900000000, - 0x6c16838c00000000, 0x926d63e800000000, 0x07b9137d00000000, - 0x6e9aa32100000000, 0xfb4ed3b400000000, 0x053533d000000000, - 0x90e1434500000000, 0xd773536900000000, 0x42a723fc00000000, - 0xbcdcc39800000000, 0x2908b30d00000000, 0x402b035100000000, - 0xd5ff73c400000000, 0x2b8493a000000000, 0xbe50e33500000000, - 0xa5a0b2f800000000, 0x3074c26d00000000, 0xce0f220900000000, - 0x5bdb529c00000000, 0x32f8e2c000000000, 0xa72c925500000000, - 0x5957723100000000, 0xcc8302a400000000, 0x8b11128800000000, - 0x1ec5621d00000000, 0xe0be827900000000, 0x756af2ec00000000, - 0x1c4942b000000000, 0x899d322500000000, 0x77e6d24100000000, - 0xe232a2d400000000, 0xf285e73300000000, 0x675197a600000000, - 0x992a77c200000000, 0x0cfe075700000000, 0x65ddb70b00000000, - 0xf009c79e00000000, 0x0e7227fa00000000, 0x9ba6576f00000000, - 0xdc34474300000000, 0x49e037d600000000, 0xb79bd7b200000000, - 0x224fa72700000000, 0x4b6c177b00000000, 0xdeb867ee00000000, - 0x20c3878a00000000, 0xb517f71f00000000, 0xaee7a6d200000000, - 0x3b33d64700000000, 0xc548362300000000, 0x509c46b600000000, - 0x39bff6ea00000000, 0xac6b867f00000000, 0x5210661b00000000, - 0xc7c4168e00000000, 0x805606a200000000, 0x1582763700000000, - 0xebf9965300000000, 0x7e2de6c600000000, 0x170e569a00000000, - 0x82da260f00000000, 0x7ca1c66b00000000, 0xe975b6fe00000000, - 0x0b47142a00000000, 0x9e9364bf00000000, 0x60e884db00000000, - 0xf53cf44e00000000, 0x9c1f441200000000, 0x09cb348700000000, - 0xf7b0d4e300000000, 0x6264a47600000000, 0x25f6b45a00000000, - 0xb022c4cf00000000, 0x4e5924ab00000000, 0xdb8d543e00000000, - 0xb2aee46200000000, 0x277a94f700000000, 0xd901749300000000, - 0x4cd5040600000000, 0x572555cb00000000, 0xc2f1255e00000000, - 0x3c8ac53a00000000, 0xa95eb5af00000000, 0xc07d05f300000000, - 0x55a9756600000000, 0xabd2950200000000, 0x3e06e59700000000, - 0x7994f5bb00000000, 0xec40852e00000000, 0x123b654a00000000, - 0x87ef15df00000000, 0xeecca58300000000, 0x7b18d51600000000, - 0x8563357200000000, 0x10b745e700000000, 0xe40bcf6700000000, - 0x71dfbff200000000, 0x8fa45f9600000000, 0x1a702f0300000000, - 0x73539f5f00000000, 0xe687efca00000000, 0x18fc0fae00000000, - 0x8d287f3b00000000, 0xcaba6f1700000000, 0x5f6e1f8200000000, - 0xa115ffe600000000, 0x34c18f7300000000, 0x5de23f2f00000000, - 0xc8364fba00000000, 0x364dafde00000000, 0xa399df4b00000000, - 0xb8698e8600000000, 0x2dbdfe1300000000, 0xd3c61e7700000000, - 0x46126ee200000000, 0x2f31debe00000000, 0xbae5ae2b00000000, - 0x449e4e4f00000000, 0xd14a3eda00000000, 0x96d82ef600000000, - 0x030c5e6300000000, 0xfd77be0700000000, 0x68a3ce9200000000, - 0x01807ece00000000, 0x94540e5b00000000, 0x6a2fee3f00000000, - 0xfffb9eaa00000000, 0x1dc93c7e00000000, 0x881d4ceb00000000, - 0x7666ac8f00000000, 0xe3b2dc1a00000000, 0x8a916c4600000000, - 0x1f451cd300000000, 0xe13efcb700000000, 0x74ea8c2200000000, - 0x33789c0e00000000, 0xa6acec9b00000000, 0x58d70cff00000000, - 0xcd037c6a00000000, 0xa420cc3600000000, 0x31f4bca300000000, - 0xcf8f5cc700000000, 0x5a5b2c5200000000, 0x41ab7d9f00000000, - 0xd47f0d0a00000000, 0x2a04ed6e00000000, 0xbfd09dfb00000000, - 0xd6f32da700000000, 0x43275d3200000000, 0xbd5cbd5600000000, - 0x2888cdc300000000, 0x6f1addef00000000, 0xfacead7a00000000, - 0x04b54d1e00000000, 0x91613d8b00000000, 0xf8428dd700000000, - 0x6d96fd4200000000, 0x93ed1d2600000000, 0x06396db300000000, - 0x168e285400000000, 0x835a58c100000000, 0x7d21b8a500000000, - 0xe8f5c83000000000, 0x81d6786c00000000, 0x140208f900000000, - 0xea79e89d00000000, 0x7fad980800000000, 0x383f882400000000, - 0xadebf8b100000000, 0x539018d500000000, 0xc644684000000000, - 0xaf67d81c00000000, 0x3ab3a88900000000, 0xc4c848ed00000000, - 0x511c387800000000, 0x4aec69b500000000, 0xdf38192000000000, - 0x2143f94400000000, 0xb49789d100000000, 0xddb4398d00000000, - 0x4860491800000000, 0xb61ba97c00000000, 0x23cfd9e900000000, - 0x645dc9c500000000, 0xf189b95000000000, 0x0ff2593400000000, - 0x9a2629a100000000, 0xf30599fd00000000, 0x66d1e96800000000, - 0x98aa090c00000000, 0x0d7e799900000000, 0xef4cdb4d00000000, - 0x7a98abd800000000, 0x84e34bbc00000000, 0x11373b2900000000, - 0x78148b7500000000, 0xedc0fbe000000000, 0x13bb1b8400000000, - 0x866f6b1100000000, 0xc1fd7b3d00000000, 0x54290ba800000000, - 0xaa52ebcc00000000, 0x3f869b5900000000, 0x56a52b0500000000, - 0xc3715b9000000000, 0x3d0abbf400000000, 0xa8decb6100000000, - 0xb32e9aac00000000, 0x26faea3900000000, 0xd8810a5d00000000, - 0x4d557ac800000000, 0x2476ca9400000000, 0xb1a2ba0100000000, - 0x4fd95a6500000000, 0xda0d2af000000000, 0x9d9f3adc00000000, - 0x084b4a4900000000, 0xf630aa2d00000000, 0x63e4dab800000000, - 0x0ac76ae400000000, 0x9f131a7100000000, 0x6168fa1500000000, - 0xf4bc8a8000000000}, - {0x0000000000000000, 0x1f17f08000000000, 0x7f2891da00000000, - 0x603f615a00000000, 0xbf56536e00000000, 0xa041a3ee00000000, - 0xc07ec2b400000000, 0xdf69323400000000, 0x7eada6dc00000000, - 0x61ba565c00000000, 0x0185370600000000, 0x1e92c78600000000, - 0xc1fbf5b200000000, 0xdeec053200000000, 0xbed3646800000000, - 0xa1c494e800000000, 0xbd5c3c6200000000, 0xa24bcce200000000, - 0xc274adb800000000, 0xdd635d3800000000, 0x020a6f0c00000000, - 0x1d1d9f8c00000000, 0x7d22fed600000000, 0x62350e5600000000, - 0xc3f19abe00000000, 0xdce66a3e00000000, 0xbcd90b6400000000, - 0xa3cefbe400000000, 0x7ca7c9d000000000, 0x63b0395000000000, - 0x038f580a00000000, 0x1c98a88a00000000, 0x7ab978c400000000, - 0x65ae884400000000, 0x0591e91e00000000, 0x1a86199e00000000, - 0xc5ef2baa00000000, 0xdaf8db2a00000000, 0xbac7ba7000000000, - 0xa5d04af000000000, 0x0414de1800000000, 0x1b032e9800000000, - 0x7b3c4fc200000000, 0x642bbf4200000000, 0xbb428d7600000000, - 0xa4557df600000000, 0xc46a1cac00000000, 0xdb7dec2c00000000, - 0xc7e544a600000000, 0xd8f2b42600000000, 0xb8cdd57c00000000, - 0xa7da25fc00000000, 0x78b317c800000000, 0x67a4e74800000000, - 0x079b861200000000, 0x188c769200000000, 0xb948e27a00000000, - 0xa65f12fa00000000, 0xc66073a000000000, 0xd977832000000000, - 0x061eb11400000000, 0x1909419400000000, 0x793620ce00000000, - 0x6621d04e00000000, 0xb574805300000000, 0xaa6370d300000000, - 0xca5c118900000000, 0xd54be10900000000, 0x0a22d33d00000000, - 0x153523bd00000000, 0x750a42e700000000, 0x6a1db26700000000, - 0xcbd9268f00000000, 0xd4ced60f00000000, 0xb4f1b75500000000, - 0xabe647d500000000, 0x748f75e100000000, 0x6b98856100000000, - 0x0ba7e43b00000000, 0x14b014bb00000000, 0x0828bc3100000000, - 0x173f4cb100000000, 0x77002deb00000000, 0x6817dd6b00000000, - 0xb77eef5f00000000, 0xa8691fdf00000000, 0xc8567e8500000000, - 0xd7418e0500000000, 0x76851aed00000000, 0x6992ea6d00000000, - 0x09ad8b3700000000, 0x16ba7bb700000000, 0xc9d3498300000000, - 0xd6c4b90300000000, 0xb6fbd85900000000, 0xa9ec28d900000000, - 0xcfcdf89700000000, 0xd0da081700000000, 0xb0e5694d00000000, - 0xaff299cd00000000, 0x709babf900000000, 0x6f8c5b7900000000, - 0x0fb33a2300000000, 0x10a4caa300000000, 0xb1605e4b00000000, - 0xae77aecb00000000, 0xce48cf9100000000, 0xd15f3f1100000000, - 0x0e360d2500000000, 0x1121fda500000000, 0x711e9cff00000000, - 0x6e096c7f00000000, 0x7291c4f500000000, 0x6d86347500000000, - 0x0db9552f00000000, 0x12aea5af00000000, 0xcdc7979b00000000, - 0xd2d0671b00000000, 0xb2ef064100000000, 0xadf8f6c100000000, - 0x0c3c622900000000, 0x132b92a900000000, 0x7314f3f300000000, - 0x6c03037300000000, 0xb36a314700000000, 0xac7dc1c700000000, - 0xcc42a09d00000000, 0xd355501d00000000, 0x6ae900a700000000, - 0x75fef02700000000, 0x15c1917d00000000, 0x0ad661fd00000000, - 0xd5bf53c900000000, 0xcaa8a34900000000, 0xaa97c21300000000, - 0xb580329300000000, 0x1444a67b00000000, 0x0b5356fb00000000, - 0x6b6c37a100000000, 0x747bc72100000000, 0xab12f51500000000, - 0xb405059500000000, 0xd43a64cf00000000, 0xcb2d944f00000000, - 0xd7b53cc500000000, 0xc8a2cc4500000000, 0xa89dad1f00000000, - 0xb78a5d9f00000000, 0x68e36fab00000000, 0x77f49f2b00000000, - 0x17cbfe7100000000, 0x08dc0ef100000000, 0xa9189a1900000000, - 0xb60f6a9900000000, 0xd6300bc300000000, 0xc927fb4300000000, - 0x164ec97700000000, 0x095939f700000000, 0x696658ad00000000, - 0x7671a82d00000000, 0x1050786300000000, 0x0f4788e300000000, - 0x6f78e9b900000000, 0x706f193900000000, 0xaf062b0d00000000, - 0xb011db8d00000000, 0xd02ebad700000000, 0xcf394a5700000000, - 0x6efddebf00000000, 0x71ea2e3f00000000, 0x11d54f6500000000, - 0x0ec2bfe500000000, 0xd1ab8dd100000000, 0xcebc7d5100000000, - 0xae831c0b00000000, 0xb194ec8b00000000, 0xad0c440100000000, - 0xb21bb48100000000, 0xd224d5db00000000, 0xcd33255b00000000, - 0x125a176f00000000, 0x0d4de7ef00000000, 0x6d7286b500000000, - 0x7265763500000000, 0xd3a1e2dd00000000, 0xccb6125d00000000, - 0xac89730700000000, 0xb39e838700000000, 0x6cf7b1b300000000, - 0x73e0413300000000, 0x13df206900000000, 0x0cc8d0e900000000, - 0xdf9d80f400000000, 0xc08a707400000000, 0xa0b5112e00000000, - 0xbfa2e1ae00000000, 0x60cbd39a00000000, 0x7fdc231a00000000, - 0x1fe3424000000000, 0x00f4b2c000000000, 0xa130262800000000, - 0xbe27d6a800000000, 0xde18b7f200000000, 0xc10f477200000000, - 0x1e66754600000000, 0x017185c600000000, 0x614ee49c00000000, - 0x7e59141c00000000, 0x62c1bc9600000000, 0x7dd64c1600000000, - 0x1de92d4c00000000, 0x02feddcc00000000, 0xdd97eff800000000, - 0xc2801f7800000000, 0xa2bf7e2200000000, 0xbda88ea200000000, - 0x1c6c1a4a00000000, 0x037beaca00000000, 0x63448b9000000000, - 0x7c537b1000000000, 0xa33a492400000000, 0xbc2db9a400000000, - 0xdc12d8fe00000000, 0xc305287e00000000, 0xa524f83000000000, - 0xba3308b000000000, 0xda0c69ea00000000, 0xc51b996a00000000, - 0x1a72ab5e00000000, 0x05655bde00000000, 0x655a3a8400000000, - 0x7a4dca0400000000, 0xdb895eec00000000, 0xc49eae6c00000000, - 0xa4a1cf3600000000, 0xbbb63fb600000000, 0x64df0d8200000000, - 0x7bc8fd0200000000, 0x1bf79c5800000000, 0x04e06cd800000000, - 0x1878c45200000000, 0x076f34d200000000, 0x6750558800000000, - 0x7847a50800000000, 0xa72e973c00000000, 0xb83967bc00000000, - 0xd80606e600000000, 0xc711f66600000000, 0x66d5628e00000000, - 0x79c2920e00000000, 0x19fdf35400000000, 0x06ea03d400000000, - 0xd98331e000000000, 0xc694c16000000000, 0xa6aba03a00000000, - 0xb9bc50ba00000000}, - {0x0000000000000000, 0xe2fd888d00000000, 0x85fd60c000000000, - 0x6700e84d00000000, 0x4bfdb05b00000000, 0xa90038d600000000, - 0xce00d09b00000000, 0x2cfd581600000000, 0x96fa61b700000000, - 0x7407e93a00000000, 0x1307017700000000, 0xf1fa89fa00000000, - 0xdd07d1ec00000000, 0x3ffa596100000000, 0x58fab12c00000000, - 0xba0739a100000000, 0x6df3b2b500000000, 0x8f0e3a3800000000, - 0xe80ed27500000000, 0x0af35af800000000, 0x260e02ee00000000, - 0xc4f38a6300000000, 0xa3f3622e00000000, 0x410eeaa300000000, - 0xfb09d30200000000, 0x19f45b8f00000000, 0x7ef4b3c200000000, - 0x9c093b4f00000000, 0xb0f4635900000000, 0x5209ebd400000000, - 0x3509039900000000, 0xd7f48b1400000000, 0x9be014b000000000, - 0x791d9c3d00000000, 0x1e1d747000000000, 0xfce0fcfd00000000, - 0xd01da4eb00000000, 0x32e02c6600000000, 0x55e0c42b00000000, - 0xb71d4ca600000000, 0x0d1a750700000000, 0xefe7fd8a00000000, - 0x88e715c700000000, 0x6a1a9d4a00000000, 0x46e7c55c00000000, - 0xa41a4dd100000000, 0xc31aa59c00000000, 0x21e72d1100000000, - 0xf613a60500000000, 0x14ee2e8800000000, 0x73eec6c500000000, - 0x91134e4800000000, 0xbdee165e00000000, 0x5f139ed300000000, - 0x3813769e00000000, 0xdaeefe1300000000, 0x60e9c7b200000000, - 0x82144f3f00000000, 0xe514a77200000000, 0x07e92fff00000000, - 0x2b1477e900000000, 0xc9e9ff6400000000, 0xaee9172900000000, - 0x4c149fa400000000, 0x77c758bb00000000, 0x953ad03600000000, - 0xf23a387b00000000, 0x10c7b0f600000000, 0x3c3ae8e000000000, - 0xdec7606d00000000, 0xb9c7882000000000, 0x5b3a00ad00000000, - 0xe13d390c00000000, 0x03c0b18100000000, 0x64c059cc00000000, - 0x863dd14100000000, 0xaac0895700000000, 0x483d01da00000000, - 0x2f3de99700000000, 0xcdc0611a00000000, 0x1a34ea0e00000000, - 0xf8c9628300000000, 0x9fc98ace00000000, 0x7d34024300000000, - 0x51c95a5500000000, 0xb334d2d800000000, 0xd4343a9500000000, - 0x36c9b21800000000, 0x8cce8bb900000000, 0x6e33033400000000, - 0x0933eb7900000000, 0xebce63f400000000, 0xc7333be200000000, - 0x25ceb36f00000000, 0x42ce5b2200000000, 0xa033d3af00000000, - 0xec274c0b00000000, 0x0edac48600000000, 0x69da2ccb00000000, - 0x8b27a44600000000, 0xa7dafc5000000000, 0x452774dd00000000, - 0x22279c9000000000, 0xc0da141d00000000, 0x7add2dbc00000000, - 0x9820a53100000000, 0xff204d7c00000000, 0x1dddc5f100000000, - 0x31209de700000000, 0xd3dd156a00000000, 0xb4ddfd2700000000, - 0x562075aa00000000, 0x81d4febe00000000, 0x6329763300000000, - 0x04299e7e00000000, 0xe6d416f300000000, 0xca294ee500000000, - 0x28d4c66800000000, 0x4fd42e2500000000, 0xad29a6a800000000, - 0x172e9f0900000000, 0xf5d3178400000000, 0x92d3ffc900000000, - 0x702e774400000000, 0x5cd32f5200000000, 0xbe2ea7df00000000, - 0xd92e4f9200000000, 0x3bd3c71f00000000, 0xaf88c0ad00000000, - 0x4d75482000000000, 0x2a75a06d00000000, 0xc88828e000000000, - 0xe47570f600000000, 0x0688f87b00000000, 0x6188103600000000, - 0x837598bb00000000, 0x3972a11a00000000, 0xdb8f299700000000, - 0xbc8fc1da00000000, 0x5e72495700000000, 0x728f114100000000, - 0x907299cc00000000, 0xf772718100000000, 0x158ff90c00000000, - 0xc27b721800000000, 0x2086fa9500000000, 0x478612d800000000, - 0xa57b9a5500000000, 0x8986c24300000000, 0x6b7b4ace00000000, - 0x0c7ba28300000000, 0xee862a0e00000000, 0x548113af00000000, - 0xb67c9b2200000000, 0xd17c736f00000000, 0x3381fbe200000000, - 0x1f7ca3f400000000, 0xfd812b7900000000, 0x9a81c33400000000, - 0x787c4bb900000000, 0x3468d41d00000000, 0xd6955c9000000000, - 0xb195b4dd00000000, 0x53683c5000000000, 0x7f95644600000000, - 0x9d68eccb00000000, 0xfa68048600000000, 0x18958c0b00000000, - 0xa292b5aa00000000, 0x406f3d2700000000, 0x276fd56a00000000, - 0xc5925de700000000, 0xe96f05f100000000, 0x0b928d7c00000000, - 0x6c92653100000000, 0x8e6fedbc00000000, 0x599b66a800000000, - 0xbb66ee2500000000, 0xdc66066800000000, 0x3e9b8ee500000000, - 0x1266d6f300000000, 0xf09b5e7e00000000, 0x979bb63300000000, - 0x75663ebe00000000, 0xcf61071f00000000, 0x2d9c8f9200000000, - 0x4a9c67df00000000, 0xa861ef5200000000, 0x849cb74400000000, - 0x66613fc900000000, 0x0161d78400000000, 0xe39c5f0900000000, - 0xd84f981600000000, 0x3ab2109b00000000, 0x5db2f8d600000000, - 0xbf4f705b00000000, 0x93b2284d00000000, 0x714fa0c000000000, - 0x164f488d00000000, 0xf4b2c00000000000, 0x4eb5f9a100000000, - 0xac48712c00000000, 0xcb48996100000000, 0x29b511ec00000000, - 0x054849fa00000000, 0xe7b5c17700000000, 0x80b5293a00000000, - 0x6248a1b700000000, 0xb5bc2aa300000000, 0x5741a22e00000000, - 0x30414a6300000000, 0xd2bcc2ee00000000, 0xfe419af800000000, - 0x1cbc127500000000, 0x7bbcfa3800000000, 0x994172b500000000, - 0x23464b1400000000, 0xc1bbc39900000000, 0xa6bb2bd400000000, - 0x4446a35900000000, 0x68bbfb4f00000000, 0x8a4673c200000000, - 0xed469b8f00000000, 0x0fbb130200000000, 0x43af8ca600000000, - 0xa152042b00000000, 0xc652ec6600000000, 0x24af64eb00000000, - 0x08523cfd00000000, 0xeaafb47000000000, 0x8daf5c3d00000000, - 0x6f52d4b000000000, 0xd555ed1100000000, 0x37a8659c00000000, - 0x50a88dd100000000, 0xb255055c00000000, 0x9ea85d4a00000000, - 0x7c55d5c700000000, 0x1b553d8a00000000, 0xf9a8b50700000000, - 0x2e5c3e1300000000, 0xcca1b69e00000000, 0xaba15ed300000000, - 0x495cd65e00000000, 0x65a18e4800000000, 0x875c06c500000000, - 0xe05cee8800000000, 0x02a1660500000000, 0xb8a65fa400000000, - 0x5a5bd72900000000, 0x3d5b3f6400000000, 0xdfa6b7e900000000, - 0xf35befff00000000, 0x11a6677200000000, 0x76a68f3f00000000, - 0x945b07b200000000}, - {0x0000000000000000, 0xa90b894e00000000, 0x5217129d00000000, - 0xfb1c9bd300000000, 0xe52855e100000000, 0x4c23dcaf00000000, - 0xb73f477c00000000, 0x1e34ce3200000000, 0x8b57db1900000000, - 0x225c525700000000, 0xd940c98400000000, 0x704b40ca00000000, - 0x6e7f8ef800000000, 0xc77407b600000000, 0x3c689c6500000000, - 0x9563152b00000000, 0x16afb63300000000, 0xbfa43f7d00000000, - 0x44b8a4ae00000000, 0xedb32de000000000, 0xf387e3d200000000, - 0x5a8c6a9c00000000, 0xa190f14f00000000, 0x089b780100000000, - 0x9df86d2a00000000, 0x34f3e46400000000, 0xcfef7fb700000000, - 0x66e4f6f900000000, 0x78d038cb00000000, 0xd1dbb18500000000, - 0x2ac72a5600000000, 0x83cca31800000000, 0x2c5e6d6700000000, - 0x8555e42900000000, 0x7e497ffa00000000, 0xd742f6b400000000, - 0xc976388600000000, 0x607db1c800000000, 0x9b612a1b00000000, - 0x326aa35500000000, 0xa709b67e00000000, 0x0e023f3000000000, - 0xf51ea4e300000000, 0x5c152dad00000000, 0x4221e39f00000000, - 0xeb2a6ad100000000, 0x1036f10200000000, 0xb93d784c00000000, - 0x3af1db5400000000, 0x93fa521a00000000, 0x68e6c9c900000000, - 0xc1ed408700000000, 0xdfd98eb500000000, 0x76d207fb00000000, - 0x8dce9c2800000000, 0x24c5156600000000, 0xb1a6004d00000000, - 0x18ad890300000000, 0xe3b112d000000000, 0x4aba9b9e00000000, - 0x548e55ac00000000, 0xfd85dce200000000, 0x0699473100000000, - 0xaf92ce7f00000000, 0x58bcdace00000000, 0xf1b7538000000000, - 0x0aabc85300000000, 0xa3a0411d00000000, 0xbd948f2f00000000, - 0x149f066100000000, 0xef839db200000000, 0x468814fc00000000, - 0xd3eb01d700000000, 0x7ae0889900000000, 0x81fc134a00000000, - 0x28f79a0400000000, 0x36c3543600000000, 0x9fc8dd7800000000, - 0x64d446ab00000000, 0xcddfcfe500000000, 0x4e136cfd00000000, - 0xe718e5b300000000, 0x1c047e6000000000, 0xb50ff72e00000000, - 0xab3b391c00000000, 0x0230b05200000000, 0xf92c2b8100000000, - 0x5027a2cf00000000, 0xc544b7e400000000, 0x6c4f3eaa00000000, - 0x9753a57900000000, 0x3e582c3700000000, 0x206ce20500000000, - 0x89676b4b00000000, 0x727bf09800000000, 0xdb7079d600000000, - 0x74e2b7a900000000, 0xdde93ee700000000, 0x26f5a53400000000, - 0x8ffe2c7a00000000, 0x91cae24800000000, 0x38c16b0600000000, - 0xc3ddf0d500000000, 0x6ad6799b00000000, 0xffb56cb000000000, - 0x56bee5fe00000000, 0xada27e2d00000000, 0x04a9f76300000000, - 0x1a9d395100000000, 0xb396b01f00000000, 0x488a2bcc00000000, - 0xe181a28200000000, 0x624d019a00000000, 0xcb4688d400000000, - 0x305a130700000000, 0x99519a4900000000, 0x8765547b00000000, - 0x2e6edd3500000000, 0xd57246e600000000, 0x7c79cfa800000000, - 0xe91ada8300000000, 0x401153cd00000000, 0xbb0dc81e00000000, - 0x1206415000000000, 0x0c328f6200000000, 0xa539062c00000000, - 0x5e259dff00000000, 0xf72e14b100000000, 0xf17ec44600000000, - 0x58754d0800000000, 0xa369d6db00000000, 0x0a625f9500000000, - 0x145691a700000000, 0xbd5d18e900000000, 0x4641833a00000000, - 0xef4a0a7400000000, 0x7a291f5f00000000, 0xd322961100000000, - 0x283e0dc200000000, 0x8135848c00000000, 0x9f014abe00000000, - 0x360ac3f000000000, 0xcd16582300000000, 0x641dd16d00000000, - 0xe7d1727500000000, 0x4edafb3b00000000, 0xb5c660e800000000, - 0x1ccde9a600000000, 0x02f9279400000000, 0xabf2aeda00000000, - 0x50ee350900000000, 0xf9e5bc4700000000, 0x6c86a96c00000000, - 0xc58d202200000000, 0x3e91bbf100000000, 0x979a32bf00000000, - 0x89aefc8d00000000, 0x20a575c300000000, 0xdbb9ee1000000000, - 0x72b2675e00000000, 0xdd20a92100000000, 0x742b206f00000000, - 0x8f37bbbc00000000, 0x263c32f200000000, 0x3808fcc000000000, - 0x9103758e00000000, 0x6a1fee5d00000000, 0xc314671300000000, - 0x5677723800000000, 0xff7cfb7600000000, 0x046060a500000000, - 0xad6be9eb00000000, 0xb35f27d900000000, 0x1a54ae9700000000, - 0xe148354400000000, 0x4843bc0a00000000, 0xcb8f1f1200000000, - 0x6284965c00000000, 0x99980d8f00000000, 0x309384c100000000, - 0x2ea74af300000000, 0x87acc3bd00000000, 0x7cb0586e00000000, - 0xd5bbd12000000000, 0x40d8c40b00000000, 0xe9d34d4500000000, - 0x12cfd69600000000, 0xbbc45fd800000000, 0xa5f091ea00000000, - 0x0cfb18a400000000, 0xf7e7837700000000, 0x5eec0a3900000000, - 0xa9c21e8800000000, 0x00c997c600000000, 0xfbd50c1500000000, - 0x52de855b00000000, 0x4cea4b6900000000, 0xe5e1c22700000000, - 0x1efd59f400000000, 0xb7f6d0ba00000000, 0x2295c59100000000, - 0x8b9e4cdf00000000, 0x7082d70c00000000, 0xd9895e4200000000, - 0xc7bd907000000000, 0x6eb6193e00000000, 0x95aa82ed00000000, - 0x3ca10ba300000000, 0xbf6da8bb00000000, 0x166621f500000000, - 0xed7aba2600000000, 0x4471336800000000, 0x5a45fd5a00000000, - 0xf34e741400000000, 0x0852efc700000000, 0xa159668900000000, - 0x343a73a200000000, 0x9d31faec00000000, 0x662d613f00000000, - 0xcf26e87100000000, 0xd112264300000000, 0x7819af0d00000000, - 0x830534de00000000, 0x2a0ebd9000000000, 0x859c73ef00000000, - 0x2c97faa100000000, 0xd78b617200000000, 0x7e80e83c00000000, - 0x60b4260e00000000, 0xc9bfaf4000000000, 0x32a3349300000000, - 0x9ba8bddd00000000, 0x0ecba8f600000000, 0xa7c021b800000000, - 0x5cdcba6b00000000, 0xf5d7332500000000, 0xebe3fd1700000000, - 0x42e8745900000000, 0xb9f4ef8a00000000, 0x10ff66c400000000, - 0x9333c5dc00000000, 0x3a384c9200000000, 0xc124d74100000000, - 0x682f5e0f00000000, 0x761b903d00000000, 0xdf10197300000000, - 0x240c82a000000000, 0x8d070bee00000000, 0x18641ec500000000, - 0xb16f978b00000000, 0x4a730c5800000000, 0xe378851600000000, - 0xfd4c4b2400000000, 0x5447c26a00000000, 0xaf5b59b900000000, - 0x0650d0f700000000}, - {0x0000000000000000, 0x479244af00000000, 0xcf22f88500000000, - 0x88b0bc2a00000000, 0xdf4381d000000000, 0x98d1c57f00000000, - 0x1061795500000000, 0x57f33dfa00000000, 0xff81737a00000000, - 0xb81337d500000000, 0x30a38bff00000000, 0x7731cf5000000000, - 0x20c2f2aa00000000, 0x6750b60500000000, 0xefe00a2f00000000, - 0xa8724e8000000000, 0xfe03e7f400000000, 0xb991a35b00000000, - 0x31211f7100000000, 0x76b35bde00000000, 0x2140662400000000, - 0x66d2228b00000000, 0xee629ea100000000, 0xa9f0da0e00000000, - 0x0182948e00000000, 0x4610d02100000000, 0xcea06c0b00000000, - 0x893228a400000000, 0xdec1155e00000000, 0x995351f100000000, - 0x11e3eddb00000000, 0x5671a97400000000, 0xbd01bf3200000000, - 0xfa93fb9d00000000, 0x722347b700000000, 0x35b1031800000000, - 0x62423ee200000000, 0x25d07a4d00000000, 0xad60c66700000000, - 0xeaf282c800000000, 0x4280cc4800000000, 0x051288e700000000, - 0x8da234cd00000000, 0xca30706200000000, 0x9dc34d9800000000, - 0xda51093700000000, 0x52e1b51d00000000, 0x1573f1b200000000, - 0x430258c600000000, 0x04901c6900000000, 0x8c20a04300000000, - 0xcbb2e4ec00000000, 0x9c41d91600000000, 0xdbd39db900000000, - 0x5363219300000000, 0x14f1653c00000000, 0xbc832bbc00000000, - 0xfb116f1300000000, 0x73a1d33900000000, 0x3433979600000000, - 0x63c0aa6c00000000, 0x2452eec300000000, 0xace252e900000000, - 0xeb70164600000000, 0x7a037e6500000000, 0x3d913aca00000000, - 0xb52186e000000000, 0xf2b3c24f00000000, 0xa540ffb500000000, - 0xe2d2bb1a00000000, 0x6a62073000000000, 0x2df0439f00000000, - 0x85820d1f00000000, 0xc21049b000000000, 0x4aa0f59a00000000, - 0x0d32b13500000000, 0x5ac18ccf00000000, 0x1d53c86000000000, - 0x95e3744a00000000, 0xd27130e500000000, 0x8400999100000000, - 0xc392dd3e00000000, 0x4b22611400000000, 0x0cb025bb00000000, - 0x5b43184100000000, 0x1cd15cee00000000, 0x9461e0c400000000, - 0xd3f3a46b00000000, 0x7b81eaeb00000000, 0x3c13ae4400000000, - 0xb4a3126e00000000, 0xf33156c100000000, 0xa4c26b3b00000000, - 0xe3502f9400000000, 0x6be093be00000000, 0x2c72d71100000000, - 0xc702c15700000000, 0x809085f800000000, 0x082039d200000000, - 0x4fb27d7d00000000, 0x1841408700000000, 0x5fd3042800000000, - 0xd763b80200000000, 0x90f1fcad00000000, 0x3883b22d00000000, - 0x7f11f68200000000, 0xf7a14aa800000000, 0xb0330e0700000000, - 0xe7c033fd00000000, 0xa052775200000000, 0x28e2cb7800000000, - 0x6f708fd700000000, 0x390126a300000000, 0x7e93620c00000000, - 0xf623de2600000000, 0xb1b19a8900000000, 0xe642a77300000000, - 0xa1d0e3dc00000000, 0x29605ff600000000, 0x6ef21b5900000000, - 0xc68055d900000000, 0x8112117600000000, 0x09a2ad5c00000000, - 0x4e30e9f300000000, 0x19c3d40900000000, 0x5e5190a600000000, - 0xd6e12c8c00000000, 0x9173682300000000, 0xf406fcca00000000, - 0xb394b86500000000, 0x3b24044f00000000, 0x7cb640e000000000, - 0x2b457d1a00000000, 0x6cd739b500000000, 0xe467859f00000000, - 0xa3f5c13000000000, 0x0b878fb000000000, 0x4c15cb1f00000000, - 0xc4a5773500000000, 0x8337339a00000000, 0xd4c40e6000000000, - 0x93564acf00000000, 0x1be6f6e500000000, 0x5c74b24a00000000, - 0x0a051b3e00000000, 0x4d975f9100000000, 0xc527e3bb00000000, - 0x82b5a71400000000, 0xd5469aee00000000, 0x92d4de4100000000, - 0x1a64626b00000000, 0x5df626c400000000, 0xf584684400000000, - 0xb2162ceb00000000, 0x3aa690c100000000, 0x7d34d46e00000000, - 0x2ac7e99400000000, 0x6d55ad3b00000000, 0xe5e5111100000000, - 0xa27755be00000000, 0x490743f800000000, 0x0e95075700000000, - 0x8625bb7d00000000, 0xc1b7ffd200000000, 0x9644c22800000000, - 0xd1d6868700000000, 0x59663aad00000000, 0x1ef47e0200000000, - 0xb686308200000000, 0xf114742d00000000, 0x79a4c80700000000, - 0x3e368ca800000000, 0x69c5b15200000000, 0x2e57f5fd00000000, - 0xa6e749d700000000, 0xe1750d7800000000, 0xb704a40c00000000, - 0xf096e0a300000000, 0x78265c8900000000, 0x3fb4182600000000, - 0x684725dc00000000, 0x2fd5617300000000, 0xa765dd5900000000, - 0xe0f799f600000000, 0x4885d77600000000, 0x0f1793d900000000, - 0x87a72ff300000000, 0xc0356b5c00000000, 0x97c656a600000000, - 0xd054120900000000, 0x58e4ae2300000000, 0x1f76ea8c00000000, - 0x8e0582af00000000, 0xc997c60000000000, 0x41277a2a00000000, - 0x06b53e8500000000, 0x5146037f00000000, 0x16d447d000000000, - 0x9e64fbfa00000000, 0xd9f6bf5500000000, 0x7184f1d500000000, - 0x3616b57a00000000, 0xbea6095000000000, 0xf9344dff00000000, - 0xaec7700500000000, 0xe95534aa00000000, 0x61e5888000000000, - 0x2677cc2f00000000, 0x7006655b00000000, 0x379421f400000000, - 0xbf249dde00000000, 0xf8b6d97100000000, 0xaf45e48b00000000, - 0xe8d7a02400000000, 0x60671c0e00000000, 0x27f558a100000000, - 0x8f87162100000000, 0xc815528e00000000, 0x40a5eea400000000, - 0x0737aa0b00000000, 0x50c497f100000000, 0x1756d35e00000000, - 0x9fe66f7400000000, 0xd8742bdb00000000, 0x33043d9d00000000, - 0x7496793200000000, 0xfc26c51800000000, 0xbbb481b700000000, - 0xec47bc4d00000000, 0xabd5f8e200000000, 0x236544c800000000, - 0x64f7006700000000, 0xcc854ee700000000, 0x8b170a4800000000, - 0x03a7b66200000000, 0x4435f2cd00000000, 0x13c6cf3700000000, - 0x54548b9800000000, 0xdce437b200000000, 0x9b76731d00000000, - 0xcd07da6900000000, 0x8a959ec600000000, 0x022522ec00000000, - 0x45b7664300000000, 0x12445bb900000000, 0x55d61f1600000000, - 0xdd66a33c00000000, 0x9af4e79300000000, 0x3286a91300000000, - 0x7514edbc00000000, 0xfda4519600000000, 0xba36153900000000, - 0xedc528c300000000, 0xaa576c6c00000000, 0x22e7d04600000000, - 0x657594e900000000}}; - -#else /* W == 4 */ - -local const z_crc_t FAR crc_braid_table[][256] = { - {0x00000000, 0x65673b46, 0xcace768c, 0xafa94dca, 0x4eedeb59, - 0x2b8ad01f, 0x84239dd5, 0xe144a693, 0x9ddbd6b2, 0xf8bcedf4, - 0x5715a03e, 0x32729b78, 0xd3363deb, 0xb65106ad, 0x19f84b67, - 0x7c9f7021, 0xe0c6ab25, 0x85a19063, 0x2a08dda9, 0x4f6fe6ef, - 0xae2b407c, 0xcb4c7b3a, 0x64e536f0, 0x01820db6, 0x7d1d7d97, - 0x187a46d1, 0xb7d30b1b, 0xd2b4305d, 0x33f096ce, 0x5697ad88, - 0xf93ee042, 0x9c59db04, 0x1afc500b, 0x7f9b6b4d, 0xd0322687, - 0xb5551dc1, 0x5411bb52, 0x31768014, 0x9edfcdde, 0xfbb8f698, - 0x872786b9, 0xe240bdff, 0x4de9f035, 0x288ecb73, 0xc9ca6de0, - 0xacad56a6, 0x03041b6c, 0x6663202a, 0xfa3afb2e, 0x9f5dc068, - 0x30f48da2, 0x5593b6e4, 0xb4d71077, 0xd1b02b31, 0x7e1966fb, - 0x1b7e5dbd, 0x67e12d9c, 0x028616da, 0xad2f5b10, 0xc8486056, - 0x290cc6c5, 0x4c6bfd83, 0xe3c2b049, 0x86a58b0f, 0x35f8a016, - 0x509f9b50, 0xff36d69a, 0x9a51eddc, 0x7b154b4f, 0x1e727009, - 0xb1db3dc3, 0xd4bc0685, 0xa82376a4, 0xcd444de2, 0x62ed0028, - 0x078a3b6e, 0xe6ce9dfd, 0x83a9a6bb, 0x2c00eb71, 0x4967d037, - 0xd53e0b33, 0xb0593075, 0x1ff07dbf, 0x7a9746f9, 0x9bd3e06a, - 0xfeb4db2c, 0x511d96e6, 0x347aada0, 0x48e5dd81, 0x2d82e6c7, - 0x822bab0d, 0xe74c904b, 0x060836d8, 0x636f0d9e, 0xccc64054, - 0xa9a17b12, 0x2f04f01d, 0x4a63cb5b, 0xe5ca8691, 0x80adbdd7, - 0x61e91b44, 0x048e2002, 0xab276dc8, 0xce40568e, 0xb2df26af, - 0xd7b81de9, 0x78115023, 0x1d766b65, 0xfc32cdf6, 0x9955f6b0, - 0x36fcbb7a, 0x539b803c, 0xcfc25b38, 0xaaa5607e, 0x050c2db4, - 0x606b16f2, 0x812fb061, 0xe4488b27, 0x4be1c6ed, 0x2e86fdab, - 0x52198d8a, 0x377eb6cc, 0x98d7fb06, 0xfdb0c040, 0x1cf466d3, - 0x79935d95, 0xd63a105f, 0xb35d2b19, 0x6bf1402c, 0x0e967b6a, - 0xa13f36a0, 0xc4580de6, 0x251cab75, 0x407b9033, 0xefd2ddf9, - 0x8ab5e6bf, 0xf62a969e, 0x934dadd8, 0x3ce4e012, 0x5983db54, - 0xb8c77dc7, 0xdda04681, 0x72090b4b, 0x176e300d, 0x8b37eb09, - 0xee50d04f, 0x41f99d85, 0x249ea6c3, 0xc5da0050, 0xa0bd3b16, - 0x0f1476dc, 0x6a734d9a, 0x16ec3dbb, 0x738b06fd, 0xdc224b37, - 0xb9457071, 0x5801d6e2, 0x3d66eda4, 0x92cfa06e, 0xf7a89b28, - 0x710d1027, 0x146a2b61, 0xbbc366ab, 0xdea45ded, 0x3fe0fb7e, - 0x5a87c038, 0xf52e8df2, 0x9049b6b4, 0xecd6c695, 0x89b1fdd3, - 0x2618b019, 0x437f8b5f, 0xa23b2dcc, 0xc75c168a, 0x68f55b40, - 0x0d926006, 0x91cbbb02, 0xf4ac8044, 0x5b05cd8e, 0x3e62f6c8, - 0xdf26505b, 0xba416b1d, 0x15e826d7, 0x708f1d91, 0x0c106db0, - 0x697756f6, 0xc6de1b3c, 0xa3b9207a, 0x42fd86e9, 0x279abdaf, - 0x8833f065, 0xed54cb23, 0x5e09e03a, 0x3b6edb7c, 0x94c796b6, - 0xf1a0adf0, 0x10e40b63, 0x75833025, 0xda2a7def, 0xbf4d46a9, - 0xc3d23688, 0xa6b50dce, 0x091c4004, 0x6c7b7b42, 0x8d3fddd1, - 0xe858e697, 0x47f1ab5d, 0x2296901b, 0xbecf4b1f, 0xdba87059, - 0x74013d93, 0x116606d5, 0xf022a046, 0x95459b00, 0x3aecd6ca, - 0x5f8bed8c, 0x23149dad, 0x4673a6eb, 0xe9daeb21, 0x8cbdd067, - 0x6df976f4, 0x089e4db2, 0xa7370078, 0xc2503b3e, 0x44f5b031, - 0x21928b77, 0x8e3bc6bd, 0xeb5cfdfb, 0x0a185b68, 0x6f7f602e, - 0xc0d62de4, 0xa5b116a2, 0xd92e6683, 0xbc495dc5, 0x13e0100f, - 0x76872b49, 0x97c38dda, 0xf2a4b69c, 0x5d0dfb56, 0x386ac010, - 0xa4331b14, 0xc1542052, 0x6efd6d98, 0x0b9a56de, 0xeadef04d, - 0x8fb9cb0b, 0x201086c1, 0x4577bd87, 0x39e8cda6, 0x5c8ff6e0, - 0xf326bb2a, 0x9641806c, 0x770526ff, 0x12621db9, 0xbdcb5073, - 0xd8ac6b35}, - {0x00000000, 0xd7e28058, 0x74b406f1, 0xa35686a9, 0xe9680de2, - 0x3e8a8dba, 0x9ddc0b13, 0x4a3e8b4b, 0x09a11d85, 0xde439ddd, - 0x7d151b74, 0xaaf79b2c, 0xe0c91067, 0x372b903f, 0x947d1696, - 0x439f96ce, 0x13423b0a, 0xc4a0bb52, 0x67f63dfb, 0xb014bda3, - 0xfa2a36e8, 0x2dc8b6b0, 0x8e9e3019, 0x597cb041, 0x1ae3268f, - 0xcd01a6d7, 0x6e57207e, 0xb9b5a026, 0xf38b2b6d, 0x2469ab35, - 0x873f2d9c, 0x50ddadc4, 0x26847614, 0xf166f64c, 0x523070e5, - 0x85d2f0bd, 0xcfec7bf6, 0x180efbae, 0xbb587d07, 0x6cbafd5f, - 0x2f256b91, 0xf8c7ebc9, 0x5b916d60, 0x8c73ed38, 0xc64d6673, - 0x11afe62b, 0xb2f96082, 0x651be0da, 0x35c64d1e, 0xe224cd46, - 0x41724bef, 0x9690cbb7, 0xdcae40fc, 0x0b4cc0a4, 0xa81a460d, - 0x7ff8c655, 0x3c67509b, 0xeb85d0c3, 0x48d3566a, 0x9f31d632, - 0xd50f5d79, 0x02eddd21, 0xa1bb5b88, 0x7659dbd0, 0x4d08ec28, - 0x9aea6c70, 0x39bcead9, 0xee5e6a81, 0xa460e1ca, 0x73826192, - 0xd0d4e73b, 0x07366763, 0x44a9f1ad, 0x934b71f5, 0x301df75c, - 0xe7ff7704, 0xadc1fc4f, 0x7a237c17, 0xd975fabe, 0x0e977ae6, - 0x5e4ad722, 0x89a8577a, 0x2afed1d3, 0xfd1c518b, 0xb722dac0, - 0x60c05a98, 0xc396dc31, 0x14745c69, 0x57ebcaa7, 0x80094aff, - 0x235fcc56, 0xf4bd4c0e, 0xbe83c745, 0x6961471d, 0xca37c1b4, - 0x1dd541ec, 0x6b8c9a3c, 0xbc6e1a64, 0x1f389ccd, 0xc8da1c95, - 0x82e497de, 0x55061786, 0xf650912f, 0x21b21177, 0x622d87b9, - 0xb5cf07e1, 0x16998148, 0xc17b0110, 0x8b458a5b, 0x5ca70a03, - 0xfff18caa, 0x28130cf2, 0x78cea136, 0xaf2c216e, 0x0c7aa7c7, - 0xdb98279f, 0x91a6acd4, 0x46442c8c, 0xe512aa25, 0x32f02a7d, - 0x716fbcb3, 0xa68d3ceb, 0x05dbba42, 0xd2393a1a, 0x9807b151, - 0x4fe53109, 0xecb3b7a0, 0x3b5137f8, 0x9a11d850, 0x4df35808, - 0xeea5dea1, 0x39475ef9, 0x7379d5b2, 0xa49b55ea, 0x07cdd343, - 0xd02f531b, 0x93b0c5d5, 0x4452458d, 0xe704c324, 0x30e6437c, - 0x7ad8c837, 0xad3a486f, 0x0e6ccec6, 0xd98e4e9e, 0x8953e35a, - 0x5eb16302, 0xfde7e5ab, 0x2a0565f3, 0x603beeb8, 0xb7d96ee0, - 0x148fe849, 0xc36d6811, 0x80f2fedf, 0x57107e87, 0xf446f82e, - 0x23a47876, 0x699af33d, 0xbe787365, 0x1d2ef5cc, 0xcacc7594, - 0xbc95ae44, 0x6b772e1c, 0xc821a8b5, 0x1fc328ed, 0x55fda3a6, - 0x821f23fe, 0x2149a557, 0xf6ab250f, 0xb534b3c1, 0x62d63399, - 0xc180b530, 0x16623568, 0x5c5cbe23, 0x8bbe3e7b, 0x28e8b8d2, - 0xff0a388a, 0xafd7954e, 0x78351516, 0xdb6393bf, 0x0c8113e7, - 0x46bf98ac, 0x915d18f4, 0x320b9e5d, 0xe5e91e05, 0xa67688cb, - 0x71940893, 0xd2c28e3a, 0x05200e62, 0x4f1e8529, 0x98fc0571, - 0x3baa83d8, 0xec480380, 0xd7193478, 0x00fbb420, 0xa3ad3289, - 0x744fb2d1, 0x3e71399a, 0xe993b9c2, 0x4ac53f6b, 0x9d27bf33, - 0xdeb829fd, 0x095aa9a5, 0xaa0c2f0c, 0x7deeaf54, 0x37d0241f, - 0xe032a447, 0x436422ee, 0x9486a2b6, 0xc45b0f72, 0x13b98f2a, - 0xb0ef0983, 0x670d89db, 0x2d330290, 0xfad182c8, 0x59870461, - 0x8e658439, 0xcdfa12f7, 0x1a1892af, 0xb94e1406, 0x6eac945e, - 0x24921f15, 0xf3709f4d, 0x502619e4, 0x87c499bc, 0xf19d426c, - 0x267fc234, 0x8529449d, 0x52cbc4c5, 0x18f54f8e, 0xcf17cfd6, - 0x6c41497f, 0xbba3c927, 0xf83c5fe9, 0x2fdedfb1, 0x8c885918, - 0x5b6ad940, 0x1154520b, 0xc6b6d253, 0x65e054fa, 0xb202d4a2, - 0xe2df7966, 0x353df93e, 0x966b7f97, 0x4189ffcf, 0x0bb77484, - 0xdc55f4dc, 0x7f037275, 0xa8e1f22d, 0xeb7e64e3, 0x3c9ce4bb, - 0x9fca6212, 0x4828e24a, 0x02166901, 0xd5f4e959, 0x76a26ff0, - 0xa140efa8}, - {0x00000000, 0xef52b6e1, 0x05d46b83, 0xea86dd62, 0x0ba8d706, - 0xe4fa61e7, 0x0e7cbc85, 0xe12e0a64, 0x1751ae0c, 0xf80318ed, - 0x1285c58f, 0xfdd7736e, 0x1cf9790a, 0xf3abcfeb, 0x192d1289, - 0xf67fa468, 0x2ea35c18, 0xc1f1eaf9, 0x2b77379b, 0xc425817a, - 0x250b8b1e, 0xca593dff, 0x20dfe09d, 0xcf8d567c, 0x39f2f214, - 0xd6a044f5, 0x3c269997, 0xd3742f76, 0x325a2512, 0xdd0893f3, - 0x378e4e91, 0xd8dcf870, 0x5d46b830, 0xb2140ed1, 0x5892d3b3, - 0xb7c06552, 0x56ee6f36, 0xb9bcd9d7, 0x533a04b5, 0xbc68b254, - 0x4a17163c, 0xa545a0dd, 0x4fc37dbf, 0xa091cb5e, 0x41bfc13a, - 0xaeed77db, 0x446baab9, 0xab391c58, 0x73e5e428, 0x9cb752c9, - 0x76318fab, 0x9963394a, 0x784d332e, 0x971f85cf, 0x7d9958ad, - 0x92cbee4c, 0x64b44a24, 0x8be6fcc5, 0x616021a7, 0x8e329746, - 0x6f1c9d22, 0x804e2bc3, 0x6ac8f6a1, 0x859a4040, 0xba8d7060, - 0x55dfc681, 0xbf591be3, 0x500bad02, 0xb125a766, 0x5e771187, - 0xb4f1cce5, 0x5ba37a04, 0xaddcde6c, 0x428e688d, 0xa808b5ef, - 0x475a030e, 0xa674096a, 0x4926bf8b, 0xa3a062e9, 0x4cf2d408, - 0x942e2c78, 0x7b7c9a99, 0x91fa47fb, 0x7ea8f11a, 0x9f86fb7e, - 0x70d44d9f, 0x9a5290fd, 0x7500261c, 0x837f8274, 0x6c2d3495, - 0x86abe9f7, 0x69f95f16, 0x88d75572, 0x6785e393, 0x8d033ef1, - 0x62518810, 0xe7cbc850, 0x08997eb1, 0xe21fa3d3, 0x0d4d1532, - 0xec631f56, 0x0331a9b7, 0xe9b774d5, 0x06e5c234, 0xf09a665c, - 0x1fc8d0bd, 0xf54e0ddf, 0x1a1cbb3e, 0xfb32b15a, 0x146007bb, - 0xfee6dad9, 0x11b46c38, 0xc9689448, 0x263a22a9, 0xccbcffcb, - 0x23ee492a, 0xc2c0434e, 0x2d92f5af, 0xc71428cd, 0x28469e2c, - 0xde393a44, 0x316b8ca5, 0xdbed51c7, 0x34bfe726, 0xd591ed42, - 0x3ac35ba3, 0xd04586c1, 0x3f173020, 0xae6be681, 0x41395060, - 0xabbf8d02, 0x44ed3be3, 0xa5c33187, 0x4a918766, 0xa0175a04, - 0x4f45ece5, 0xb93a488d, 0x5668fe6c, 0xbcee230e, 0x53bc95ef, - 0xb2929f8b, 0x5dc0296a, 0xb746f408, 0x581442e9, 0x80c8ba99, - 0x6f9a0c78, 0x851cd11a, 0x6a4e67fb, 0x8b606d9f, 0x6432db7e, - 0x8eb4061c, 0x61e6b0fd, 0x97991495, 0x78cba274, 0x924d7f16, - 0x7d1fc9f7, 0x9c31c393, 0x73637572, 0x99e5a810, 0x76b71ef1, - 0xf32d5eb1, 0x1c7fe850, 0xf6f93532, 0x19ab83d3, 0xf88589b7, - 0x17d73f56, 0xfd51e234, 0x120354d5, 0xe47cf0bd, 0x0b2e465c, - 0xe1a89b3e, 0x0efa2ddf, 0xefd427bb, 0x0086915a, 0xea004c38, - 0x0552fad9, 0xdd8e02a9, 0x32dcb448, 0xd85a692a, 0x3708dfcb, - 0xd626d5af, 0x3974634e, 0xd3f2be2c, 0x3ca008cd, 0xcadfaca5, - 0x258d1a44, 0xcf0bc726, 0x205971c7, 0xc1777ba3, 0x2e25cd42, - 0xc4a31020, 0x2bf1a6c1, 0x14e696e1, 0xfbb42000, 0x1132fd62, - 0xfe604b83, 0x1f4e41e7, 0xf01cf706, 0x1a9a2a64, 0xf5c89c85, - 0x03b738ed, 0xece58e0c, 0x0663536e, 0xe931e58f, 0x081fefeb, - 0xe74d590a, 0x0dcb8468, 0xe2993289, 0x3a45caf9, 0xd5177c18, - 0x3f91a17a, 0xd0c3179b, 0x31ed1dff, 0xdebfab1e, 0x3439767c, - 0xdb6bc09d, 0x2d1464f5, 0xc246d214, 0x28c00f76, 0xc792b997, - 0x26bcb3f3, 0xc9ee0512, 0x2368d870, 0xcc3a6e91, 0x49a02ed1, - 0xa6f29830, 0x4c744552, 0xa326f3b3, 0x4208f9d7, 0xad5a4f36, - 0x47dc9254, 0xa88e24b5, 0x5ef180dd, 0xb1a3363c, 0x5b25eb5e, - 0xb4775dbf, 0x555957db, 0xba0be13a, 0x508d3c58, 0xbfdf8ab9, - 0x670372c9, 0x8851c428, 0x62d7194a, 0x8d85afab, 0x6caba5cf, - 0x83f9132e, 0x697fce4c, 0x862d78ad, 0x7052dcc5, 0x9f006a24, - 0x7586b746, 0x9ad401a7, 0x7bfa0bc3, 0x94a8bd22, 0x7e2e6040, - 0x917cd6a1}, - {0x00000000, 0x87a6cb43, 0xd43c90c7, 0x539a5b84, 0x730827cf, - 0xf4aeec8c, 0xa734b708, 0x20927c4b, 0xe6104f9e, 0x61b684dd, - 0x322cdf59, 0xb58a141a, 0x95186851, 0x12bea312, 0x4124f896, - 0xc68233d5, 0x1751997d, 0x90f7523e, 0xc36d09ba, 0x44cbc2f9, - 0x6459beb2, 0xe3ff75f1, 0xb0652e75, 0x37c3e536, 0xf141d6e3, - 0x76e71da0, 0x257d4624, 0xa2db8d67, 0x8249f12c, 0x05ef3a6f, - 0x567561eb, 0xd1d3aaa8, 0x2ea332fa, 0xa905f9b9, 0xfa9fa23d, - 0x7d39697e, 0x5dab1535, 0xda0dde76, 0x899785f2, 0x0e314eb1, - 0xc8b37d64, 0x4f15b627, 0x1c8feda3, 0x9b2926e0, 0xbbbb5aab, - 0x3c1d91e8, 0x6f87ca6c, 0xe821012f, 0x39f2ab87, 0xbe5460c4, - 0xedce3b40, 0x6a68f003, 0x4afa8c48, 0xcd5c470b, 0x9ec61c8f, - 0x1960d7cc, 0xdfe2e419, 0x58442f5a, 0x0bde74de, 0x8c78bf9d, - 0xaceac3d6, 0x2b4c0895, 0x78d65311, 0xff709852, 0x5d4665f4, - 0xdae0aeb7, 0x897af533, 0x0edc3e70, 0x2e4e423b, 0xa9e88978, - 0xfa72d2fc, 0x7dd419bf, 0xbb562a6a, 0x3cf0e129, 0x6f6abaad, - 0xe8cc71ee, 0xc85e0da5, 0x4ff8c6e6, 0x1c629d62, 0x9bc45621, - 0x4a17fc89, 0xcdb137ca, 0x9e2b6c4e, 0x198da70d, 0x391fdb46, - 0xbeb91005, 0xed234b81, 0x6a8580c2, 0xac07b317, 0x2ba17854, - 0x783b23d0, 0xff9de893, 0xdf0f94d8, 0x58a95f9b, 0x0b33041f, - 0x8c95cf5c, 0x73e5570e, 0xf4439c4d, 0xa7d9c7c9, 0x207f0c8a, - 0x00ed70c1, 0x874bbb82, 0xd4d1e006, 0x53772b45, 0x95f51890, - 0x1253d3d3, 0x41c98857, 0xc66f4314, 0xe6fd3f5f, 0x615bf41c, - 0x32c1af98, 0xb56764db, 0x64b4ce73, 0xe3120530, 0xb0885eb4, - 0x372e95f7, 0x17bce9bc, 0x901a22ff, 0xc380797b, 0x4426b238, - 0x82a481ed, 0x05024aae, 0x5698112a, 0xd13eda69, 0xf1aca622, - 0x760a6d61, 0x259036e5, 0xa236fda6, 0xba8ccbe8, 0x3d2a00ab, - 0x6eb05b2f, 0xe916906c, 0xc984ec27, 0x4e222764, 0x1db87ce0, - 0x9a1eb7a3, 0x5c9c8476, 0xdb3a4f35, 0x88a014b1, 0x0f06dff2, - 0x2f94a3b9, 0xa83268fa, 0xfba8337e, 0x7c0ef83d, 0xaddd5295, - 0x2a7b99d6, 0x79e1c252, 0xfe470911, 0xded5755a, 0x5973be19, - 0x0ae9e59d, 0x8d4f2ede, 0x4bcd1d0b, 0xcc6bd648, 0x9ff18dcc, - 0x1857468f, 0x38c53ac4, 0xbf63f187, 0xecf9aa03, 0x6b5f6140, - 0x942ff912, 0x13893251, 0x401369d5, 0xc7b5a296, 0xe727dedd, - 0x6081159e, 0x331b4e1a, 0xb4bd8559, 0x723fb68c, 0xf5997dcf, - 0xa603264b, 0x21a5ed08, 0x01379143, 0x86915a00, 0xd50b0184, - 0x52adcac7, 0x837e606f, 0x04d8ab2c, 0x5742f0a8, 0xd0e43beb, - 0xf07647a0, 0x77d08ce3, 0x244ad767, 0xa3ec1c24, 0x656e2ff1, - 0xe2c8e4b2, 0xb152bf36, 0x36f47475, 0x1666083e, 0x91c0c37d, - 0xc25a98f9, 0x45fc53ba, 0xe7caae1c, 0x606c655f, 0x33f63edb, - 0xb450f598, 0x94c289d3, 0x13644290, 0x40fe1914, 0xc758d257, - 0x01dae182, 0x867c2ac1, 0xd5e67145, 0x5240ba06, 0x72d2c64d, - 0xf5740d0e, 0xa6ee568a, 0x21489dc9, 0xf09b3761, 0x773dfc22, - 0x24a7a7a6, 0xa3016ce5, 0x839310ae, 0x0435dbed, 0x57af8069, - 0xd0094b2a, 0x168b78ff, 0x912db3bc, 0xc2b7e838, 0x4511237b, - 0x65835f30, 0xe2259473, 0xb1bfcff7, 0x361904b4, 0xc9699ce6, - 0x4ecf57a5, 0x1d550c21, 0x9af3c762, 0xba61bb29, 0x3dc7706a, - 0x6e5d2bee, 0xe9fbe0ad, 0x2f79d378, 0xa8df183b, 0xfb4543bf, - 0x7ce388fc, 0x5c71f4b7, 0xdbd73ff4, 0x884d6470, 0x0febaf33, - 0xde38059b, 0x599eced8, 0x0a04955c, 0x8da25e1f, 0xad302254, - 0x2a96e917, 0x790cb293, 0xfeaa79d0, 0x38284a05, 0xbf8e8146, - 0xec14dac2, 0x6bb21181, 0x4b206dca, 0xcc86a689, 0x9f1cfd0d, - 0x18ba364e}}; - -local const z_word_t FAR crc_braid_big_table[][256] = { - {0x00000000, 0x43cba687, 0xc7903cd4, 0x845b9a53, 0xcf270873, - 0x8cecaef4, 0x08b734a7, 0x4b7c9220, 0x9e4f10e6, 0xdd84b661, - 0x59df2c32, 0x1a148ab5, 0x51681895, 0x12a3be12, 0x96f82441, - 0xd53382c6, 0x7d995117, 0x3e52f790, 0xba096dc3, 0xf9c2cb44, - 0xb2be5964, 0xf175ffe3, 0x752e65b0, 0x36e5c337, 0xe3d641f1, - 0xa01de776, 0x24467d25, 0x678ddba2, 0x2cf14982, 0x6f3aef05, - 0xeb617556, 0xa8aad3d1, 0xfa32a32e, 0xb9f905a9, 0x3da29ffa, - 0x7e69397d, 0x3515ab5d, 0x76de0dda, 0xf2859789, 0xb14e310e, - 0x647db3c8, 0x27b6154f, 0xa3ed8f1c, 0xe026299b, 0xab5abbbb, - 0xe8911d3c, 0x6cca876f, 0x2f0121e8, 0x87abf239, 0xc46054be, - 0x403bceed, 0x03f0686a, 0x488cfa4a, 0x0b475ccd, 0x8f1cc69e, - 0xccd76019, 0x19e4e2df, 0x5a2f4458, 0xde74de0b, 0x9dbf788c, - 0xd6c3eaac, 0x95084c2b, 0x1153d678, 0x529870ff, 0xf465465d, - 0xb7aee0da, 0x33f57a89, 0x703edc0e, 0x3b424e2e, 0x7889e8a9, - 0xfcd272fa, 0xbf19d47d, 0x6a2a56bb, 0x29e1f03c, 0xadba6a6f, - 0xee71cce8, 0xa50d5ec8, 0xe6c6f84f, 0x629d621c, 0x2156c49b, - 0x89fc174a, 0xca37b1cd, 0x4e6c2b9e, 0x0da78d19, 0x46db1f39, - 0x0510b9be, 0x814b23ed, 0xc280856a, 0x17b307ac, 0x5478a12b, - 0xd0233b78, 0x93e89dff, 0xd8940fdf, 0x9b5fa958, 0x1f04330b, - 0x5ccf958c, 0x0e57e573, 0x4d9c43f4, 0xc9c7d9a7, 0x8a0c7f20, - 0xc170ed00, 0x82bb4b87, 0x06e0d1d4, 0x452b7753, 0x9018f595, - 0xd3d35312, 0x5788c941, 0x14436fc6, 0x5f3ffde6, 0x1cf45b61, - 0x98afc132, 0xdb6467b5, 0x73ceb464, 0x300512e3, 0xb45e88b0, - 0xf7952e37, 0xbce9bc17, 0xff221a90, 0x7b7980c3, 0x38b22644, - 0xed81a482, 0xae4a0205, 0x2a119856, 0x69da3ed1, 0x22a6acf1, - 0x616d0a76, 0xe5369025, 0xa6fd36a2, 0xe8cb8cba, 0xab002a3d, - 0x2f5bb06e, 0x6c9016e9, 0x27ec84c9, 0x6427224e, 0xe07cb81d, - 0xa3b71e9a, 0x76849c5c, 0x354f3adb, 0xb114a088, 0xf2df060f, - 0xb9a3942f, 0xfa6832a8, 0x7e33a8fb, 0x3df80e7c, 0x9552ddad, - 0xd6997b2a, 0x52c2e179, 0x110947fe, 0x5a75d5de, 0x19be7359, - 0x9de5e90a, 0xde2e4f8d, 0x0b1dcd4b, 0x48d66bcc, 0xcc8df19f, - 0x8f465718, 0xc43ac538, 0x87f163bf, 0x03aaf9ec, 0x40615f6b, - 0x12f92f94, 0x51328913, 0xd5691340, 0x96a2b5c7, 0xddde27e7, - 0x9e158160, 0x1a4e1b33, 0x5985bdb4, 0x8cb63f72, 0xcf7d99f5, - 0x4b2603a6, 0x08eda521, 0x43913701, 0x005a9186, 0x84010bd5, - 0xc7caad52, 0x6f607e83, 0x2cabd804, 0xa8f04257, 0xeb3be4d0, - 0xa04776f0, 0xe38cd077, 0x67d74a24, 0x241ceca3, 0xf12f6e65, - 0xb2e4c8e2, 0x36bf52b1, 0x7574f436, 0x3e086616, 0x7dc3c091, - 0xf9985ac2, 0xba53fc45, 0x1caecae7, 0x5f656c60, 0xdb3ef633, - 0x98f550b4, 0xd389c294, 0x90426413, 0x1419fe40, 0x57d258c7, - 0x82e1da01, 0xc12a7c86, 0x4571e6d5, 0x06ba4052, 0x4dc6d272, - 0x0e0d74f5, 0x8a56eea6, 0xc99d4821, 0x61379bf0, 0x22fc3d77, - 0xa6a7a724, 0xe56c01a3, 0xae109383, 0xeddb3504, 0x6980af57, - 0x2a4b09d0, 0xff788b16, 0xbcb32d91, 0x38e8b7c2, 0x7b231145, - 0x305f8365, 0x739425e2, 0xf7cfbfb1, 0xb4041936, 0xe69c69c9, - 0xa557cf4e, 0x210c551d, 0x62c7f39a, 0x29bb61ba, 0x6a70c73d, - 0xee2b5d6e, 0xade0fbe9, 0x78d3792f, 0x3b18dfa8, 0xbf4345fb, - 0xfc88e37c, 0xb7f4715c, 0xf43fd7db, 0x70644d88, 0x33afeb0f, - 0x9b0538de, 0xd8ce9e59, 0x5c95040a, 0x1f5ea28d, 0x542230ad, - 0x17e9962a, 0x93b20c79, 0xd079aafe, 0x054a2838, 0x46818ebf, - 0xc2da14ec, 0x8111b26b, 0xca6d204b, 0x89a686cc, 0x0dfd1c9f, - 0x4e36ba18}, - {0x00000000, 0xe1b652ef, 0x836bd405, 0x62dd86ea, 0x06d7a80b, - 0xe761fae4, 0x85bc7c0e, 0x640a2ee1, 0x0cae5117, 0xed1803f8, - 0x8fc58512, 0x6e73d7fd, 0x0a79f91c, 0xebcfabf3, 0x89122d19, - 0x68a47ff6, 0x185ca32e, 0xf9eaf1c1, 0x9b37772b, 0x7a8125c4, - 0x1e8b0b25, 0xff3d59ca, 0x9de0df20, 0x7c568dcf, 0x14f2f239, - 0xf544a0d6, 0x9799263c, 0x762f74d3, 0x12255a32, 0xf39308dd, - 0x914e8e37, 0x70f8dcd8, 0x30b8465d, 0xd10e14b2, 0xb3d39258, - 0x5265c0b7, 0x366fee56, 0xd7d9bcb9, 0xb5043a53, 0x54b268bc, - 0x3c16174a, 0xdda045a5, 0xbf7dc34f, 0x5ecb91a0, 0x3ac1bf41, - 0xdb77edae, 0xb9aa6b44, 0x581c39ab, 0x28e4e573, 0xc952b79c, - 0xab8f3176, 0x4a396399, 0x2e334d78, 0xcf851f97, 0xad58997d, - 0x4ceecb92, 0x244ab464, 0xc5fce68b, 0xa7216061, 0x4697328e, - 0x229d1c6f, 0xc32b4e80, 0xa1f6c86a, 0x40409a85, 0x60708dba, - 0x81c6df55, 0xe31b59bf, 0x02ad0b50, 0x66a725b1, 0x8711775e, - 0xe5ccf1b4, 0x047aa35b, 0x6cdedcad, 0x8d688e42, 0xefb508a8, - 0x0e035a47, 0x6a0974a6, 0x8bbf2649, 0xe962a0a3, 0x08d4f24c, - 0x782c2e94, 0x999a7c7b, 0xfb47fa91, 0x1af1a87e, 0x7efb869f, - 0x9f4dd470, 0xfd90529a, 0x1c260075, 0x74827f83, 0x95342d6c, - 0xf7e9ab86, 0x165ff969, 0x7255d788, 0x93e38567, 0xf13e038d, - 0x10885162, 0x50c8cbe7, 0xb17e9908, 0xd3a31fe2, 0x32154d0d, - 0x561f63ec, 0xb7a93103, 0xd574b7e9, 0x34c2e506, 0x5c669af0, - 0xbdd0c81f, 0xdf0d4ef5, 0x3ebb1c1a, 0x5ab132fb, 0xbb076014, - 0xd9dae6fe, 0x386cb411, 0x489468c9, 0xa9223a26, 0xcbffbccc, - 0x2a49ee23, 0x4e43c0c2, 0xaff5922d, 0xcd2814c7, 0x2c9e4628, - 0x443a39de, 0xa58c6b31, 0xc751eddb, 0x26e7bf34, 0x42ed91d5, - 0xa35bc33a, 0xc18645d0, 0x2030173f, 0x81e66bae, 0x60503941, - 0x028dbfab, 0xe33bed44, 0x8731c3a5, 0x6687914a, 0x045a17a0, - 0xe5ec454f, 0x8d483ab9, 0x6cfe6856, 0x0e23eebc, 0xef95bc53, - 0x8b9f92b2, 0x6a29c05d, 0x08f446b7, 0xe9421458, 0x99bac880, - 0x780c9a6f, 0x1ad11c85, 0xfb674e6a, 0x9f6d608b, 0x7edb3264, - 0x1c06b48e, 0xfdb0e661, 0x95149997, 0x74a2cb78, 0x167f4d92, - 0xf7c91f7d, 0x93c3319c, 0x72756373, 0x10a8e599, 0xf11eb776, - 0xb15e2df3, 0x50e87f1c, 0x3235f9f6, 0xd383ab19, 0xb78985f8, - 0x563fd717, 0x34e251fd, 0xd5540312, 0xbdf07ce4, 0x5c462e0b, - 0x3e9ba8e1, 0xdf2dfa0e, 0xbb27d4ef, 0x5a918600, 0x384c00ea, - 0xd9fa5205, 0xa9028edd, 0x48b4dc32, 0x2a695ad8, 0xcbdf0837, - 0xafd526d6, 0x4e637439, 0x2cbef2d3, 0xcd08a03c, 0xa5acdfca, - 0x441a8d25, 0x26c70bcf, 0xc7715920, 0xa37b77c1, 0x42cd252e, - 0x2010a3c4, 0xc1a6f12b, 0xe196e614, 0x0020b4fb, 0x62fd3211, - 0x834b60fe, 0xe7414e1f, 0x06f71cf0, 0x642a9a1a, 0x859cc8f5, - 0xed38b703, 0x0c8ee5ec, 0x6e536306, 0x8fe531e9, 0xebef1f08, - 0x0a594de7, 0x6884cb0d, 0x893299e2, 0xf9ca453a, 0x187c17d5, - 0x7aa1913f, 0x9b17c3d0, 0xff1ded31, 0x1eabbfde, 0x7c763934, - 0x9dc06bdb, 0xf564142d, 0x14d246c2, 0x760fc028, 0x97b992c7, - 0xf3b3bc26, 0x1205eec9, 0x70d86823, 0x916e3acc, 0xd12ea049, - 0x3098f2a6, 0x5245744c, 0xb3f326a3, 0xd7f90842, 0x364f5aad, - 0x5492dc47, 0xb5248ea8, 0xdd80f15e, 0x3c36a3b1, 0x5eeb255b, - 0xbf5d77b4, 0xdb575955, 0x3ae10bba, 0x583c8d50, 0xb98adfbf, - 0xc9720367, 0x28c45188, 0x4a19d762, 0xabaf858d, 0xcfa5ab6c, - 0x2e13f983, 0x4cce7f69, 0xad782d86, 0xc5dc5270, 0x246a009f, - 0x46b78675, 0xa701d49a, 0xc30bfa7b, 0x22bda894, 0x40602e7e, - 0xa1d67c91}, - {0x00000000, 0x5880e2d7, 0xf106b474, 0xa98656a3, 0xe20d68e9, - 0xba8d8a3e, 0x130bdc9d, 0x4b8b3e4a, 0x851da109, 0xdd9d43de, - 0x741b157d, 0x2c9bf7aa, 0x6710c9e0, 0x3f902b37, 0x96167d94, - 0xce969f43, 0x0a3b4213, 0x52bba0c4, 0xfb3df667, 0xa3bd14b0, - 0xe8362afa, 0xb0b6c82d, 0x19309e8e, 0x41b07c59, 0x8f26e31a, - 0xd7a601cd, 0x7e20576e, 0x26a0b5b9, 0x6d2b8bf3, 0x35ab6924, - 0x9c2d3f87, 0xc4addd50, 0x14768426, 0x4cf666f1, 0xe5703052, - 0xbdf0d285, 0xf67beccf, 0xaefb0e18, 0x077d58bb, 0x5ffdba6c, - 0x916b252f, 0xc9ebc7f8, 0x606d915b, 0x38ed738c, 0x73664dc6, - 0x2be6af11, 0x8260f9b2, 0xdae01b65, 0x1e4dc635, 0x46cd24e2, - 0xef4b7241, 0xb7cb9096, 0xfc40aedc, 0xa4c04c0b, 0x0d461aa8, - 0x55c6f87f, 0x9b50673c, 0xc3d085eb, 0x6a56d348, 0x32d6319f, - 0x795d0fd5, 0x21dded02, 0x885bbba1, 0xd0db5976, 0x28ec084d, - 0x706cea9a, 0xd9eabc39, 0x816a5eee, 0xcae160a4, 0x92618273, - 0x3be7d4d0, 0x63673607, 0xadf1a944, 0xf5714b93, 0x5cf71d30, - 0x0477ffe7, 0x4ffcc1ad, 0x177c237a, 0xbefa75d9, 0xe67a970e, - 0x22d74a5e, 0x7a57a889, 0xd3d1fe2a, 0x8b511cfd, 0xc0da22b7, - 0x985ac060, 0x31dc96c3, 0x695c7414, 0xa7caeb57, 0xff4a0980, - 0x56cc5f23, 0x0e4cbdf4, 0x45c783be, 0x1d476169, 0xb4c137ca, - 0xec41d51d, 0x3c9a8c6b, 0x641a6ebc, 0xcd9c381f, 0x951cdac8, - 0xde97e482, 0x86170655, 0x2f9150f6, 0x7711b221, 0xb9872d62, - 0xe107cfb5, 0x48819916, 0x10017bc1, 0x5b8a458b, 0x030aa75c, - 0xaa8cf1ff, 0xf20c1328, 0x36a1ce78, 0x6e212caf, 0xc7a77a0c, - 0x9f2798db, 0xd4aca691, 0x8c2c4446, 0x25aa12e5, 0x7d2af032, - 0xb3bc6f71, 0xeb3c8da6, 0x42badb05, 0x1a3a39d2, 0x51b10798, - 0x0931e54f, 0xa0b7b3ec, 0xf837513b, 0x50d8119a, 0x0858f34d, - 0xa1dea5ee, 0xf95e4739, 0xb2d57973, 0xea559ba4, 0x43d3cd07, - 0x1b532fd0, 0xd5c5b093, 0x8d455244, 0x24c304e7, 0x7c43e630, - 0x37c8d87a, 0x6f483aad, 0xc6ce6c0e, 0x9e4e8ed9, 0x5ae35389, - 0x0263b15e, 0xabe5e7fd, 0xf365052a, 0xb8ee3b60, 0xe06ed9b7, - 0x49e88f14, 0x11686dc3, 0xdffef280, 0x877e1057, 0x2ef846f4, - 0x7678a423, 0x3df39a69, 0x657378be, 0xccf52e1d, 0x9475ccca, - 0x44ae95bc, 0x1c2e776b, 0xb5a821c8, 0xed28c31f, 0xa6a3fd55, - 0xfe231f82, 0x57a54921, 0x0f25abf6, 0xc1b334b5, 0x9933d662, - 0x30b580c1, 0x68356216, 0x23be5c5c, 0x7b3ebe8b, 0xd2b8e828, - 0x8a380aff, 0x4e95d7af, 0x16153578, 0xbf9363db, 0xe713810c, - 0xac98bf46, 0xf4185d91, 0x5d9e0b32, 0x051ee9e5, 0xcb8876a6, - 0x93089471, 0x3a8ec2d2, 0x620e2005, 0x29851e4f, 0x7105fc98, - 0xd883aa3b, 0x800348ec, 0x783419d7, 0x20b4fb00, 0x8932ada3, - 0xd1b24f74, 0x9a39713e, 0xc2b993e9, 0x6b3fc54a, 0x33bf279d, - 0xfd29b8de, 0xa5a95a09, 0x0c2f0caa, 0x54afee7d, 0x1f24d037, - 0x47a432e0, 0xee226443, 0xb6a28694, 0x720f5bc4, 0x2a8fb913, - 0x8309efb0, 0xdb890d67, 0x9002332d, 0xc882d1fa, 0x61048759, - 0x3984658e, 0xf712facd, 0xaf92181a, 0x06144eb9, 0x5e94ac6e, - 0x151f9224, 0x4d9f70f3, 0xe4192650, 0xbc99c487, 0x6c429df1, - 0x34c27f26, 0x9d442985, 0xc5c4cb52, 0x8e4ff518, 0xd6cf17cf, - 0x7f49416c, 0x27c9a3bb, 0xe95f3cf8, 0xb1dfde2f, 0x1859888c, - 0x40d96a5b, 0x0b525411, 0x53d2b6c6, 0xfa54e065, 0xa2d402b2, - 0x6679dfe2, 0x3ef93d35, 0x977f6b96, 0xcfff8941, 0x8474b70b, - 0xdcf455dc, 0x7572037f, 0x2df2e1a8, 0xe3647eeb, 0xbbe49c3c, - 0x1262ca9f, 0x4ae22848, 0x01691602, 0x59e9f4d5, 0xf06fa276, - 0xa8ef40a1}, - {0x00000000, 0x463b6765, 0x8c76ceca, 0xca4da9af, 0x59ebed4e, - 0x1fd08a2b, 0xd59d2384, 0x93a644e1, 0xb2d6db9d, 0xf4edbcf8, - 0x3ea01557, 0x789b7232, 0xeb3d36d3, 0xad0651b6, 0x674bf819, - 0x21709f7c, 0x25abc6e0, 0x6390a185, 0xa9dd082a, 0xefe66f4f, - 0x7c402bae, 0x3a7b4ccb, 0xf036e564, 0xb60d8201, 0x977d1d7d, - 0xd1467a18, 0x1b0bd3b7, 0x5d30b4d2, 0xce96f033, 0x88ad9756, - 0x42e03ef9, 0x04db599c, 0x0b50fc1a, 0x4d6b9b7f, 0x872632d0, - 0xc11d55b5, 0x52bb1154, 0x14807631, 0xdecddf9e, 0x98f6b8fb, - 0xb9862787, 0xffbd40e2, 0x35f0e94d, 0x73cb8e28, 0xe06dcac9, - 0xa656adac, 0x6c1b0403, 0x2a206366, 0x2efb3afa, 0x68c05d9f, - 0xa28df430, 0xe4b69355, 0x7710d7b4, 0x312bb0d1, 0xfb66197e, - 0xbd5d7e1b, 0x9c2de167, 0xda168602, 0x105b2fad, 0x566048c8, - 0xc5c60c29, 0x83fd6b4c, 0x49b0c2e3, 0x0f8ba586, 0x16a0f835, - 0x509b9f50, 0x9ad636ff, 0xdced519a, 0x4f4b157b, 0x0970721e, - 0xc33ddbb1, 0x8506bcd4, 0xa47623a8, 0xe24d44cd, 0x2800ed62, - 0x6e3b8a07, 0xfd9dcee6, 0xbba6a983, 0x71eb002c, 0x37d06749, - 0x330b3ed5, 0x753059b0, 0xbf7df01f, 0xf946977a, 0x6ae0d39b, - 0x2cdbb4fe, 0xe6961d51, 0xa0ad7a34, 0x81dde548, 0xc7e6822d, - 0x0dab2b82, 0x4b904ce7, 0xd8360806, 0x9e0d6f63, 0x5440c6cc, - 0x127ba1a9, 0x1df0042f, 0x5bcb634a, 0x9186cae5, 0xd7bdad80, - 0x441be961, 0x02208e04, 0xc86d27ab, 0x8e5640ce, 0xaf26dfb2, - 0xe91db8d7, 0x23501178, 0x656b761d, 0xf6cd32fc, 0xb0f65599, - 0x7abbfc36, 0x3c809b53, 0x385bc2cf, 0x7e60a5aa, 0xb42d0c05, - 0xf2166b60, 0x61b02f81, 0x278b48e4, 0xedc6e14b, 0xabfd862e, - 0x8a8d1952, 0xccb67e37, 0x06fbd798, 0x40c0b0fd, 0xd366f41c, - 0x955d9379, 0x5f103ad6, 0x192b5db3, 0x2c40f16b, 0x6a7b960e, - 0xa0363fa1, 0xe60d58c4, 0x75ab1c25, 0x33907b40, 0xf9ddd2ef, - 0xbfe6b58a, 0x9e962af6, 0xd8ad4d93, 0x12e0e43c, 0x54db8359, - 0xc77dc7b8, 0x8146a0dd, 0x4b0b0972, 0x0d306e17, 0x09eb378b, - 0x4fd050ee, 0x859df941, 0xc3a69e24, 0x5000dac5, 0x163bbda0, - 0xdc76140f, 0x9a4d736a, 0xbb3dec16, 0xfd068b73, 0x374b22dc, - 0x717045b9, 0xe2d60158, 0xa4ed663d, 0x6ea0cf92, 0x289ba8f7, - 0x27100d71, 0x612b6a14, 0xab66c3bb, 0xed5da4de, 0x7efbe03f, - 0x38c0875a, 0xf28d2ef5, 0xb4b64990, 0x95c6d6ec, 0xd3fdb189, - 0x19b01826, 0x5f8b7f43, 0xcc2d3ba2, 0x8a165cc7, 0x405bf568, - 0x0660920d, 0x02bbcb91, 0x4480acf4, 0x8ecd055b, 0xc8f6623e, - 0x5b5026df, 0x1d6b41ba, 0xd726e815, 0x911d8f70, 0xb06d100c, - 0xf6567769, 0x3c1bdec6, 0x7a20b9a3, 0xe986fd42, 0xafbd9a27, - 0x65f03388, 0x23cb54ed, 0x3ae0095e, 0x7cdb6e3b, 0xb696c794, - 0xf0ada0f1, 0x630be410, 0x25308375, 0xef7d2ada, 0xa9464dbf, - 0x8836d2c3, 0xce0db5a6, 0x04401c09, 0x427b7b6c, 0xd1dd3f8d, - 0x97e658e8, 0x5dabf147, 0x1b909622, 0x1f4bcfbe, 0x5970a8db, - 0x933d0174, 0xd5066611, 0x46a022f0, 0x009b4595, 0xcad6ec3a, - 0x8ced8b5f, 0xad9d1423, 0xeba67346, 0x21ebdae9, 0x67d0bd8c, - 0xf476f96d, 0xb24d9e08, 0x780037a7, 0x3e3b50c2, 0x31b0f544, - 0x778b9221, 0xbdc63b8e, 0xfbfd5ceb, 0x685b180a, 0x2e607f6f, - 0xe42dd6c0, 0xa216b1a5, 0x83662ed9, 0xc55d49bc, 0x0f10e013, - 0x492b8776, 0xda8dc397, 0x9cb6a4f2, 0x56fb0d5d, 0x10c06a38, - 0x141b33a4, 0x522054c1, 0x986dfd6e, 0xde569a0b, 0x4df0deea, - 0x0bcbb98f, 0xc1861020, 0x87bd7745, 0xa6cde839, 0xe0f68f5c, - 0x2abb26f3, 0x6c804196, 0xff260577, 0xb91d6212, 0x7350cbbd, - 0x356bacd8}}; - -#endif - -#endif - -#if N == 6 - -#if W == 8 - -local const z_crc_t FAR crc_braid_table[][256] = { - {0x00000000, 0x3db1ecdc, 0x7b63d9b8, 0x46d23564, 0xf6c7b370, - 0xcb765fac, 0x8da46ac8, 0xb0158614, 0x36fe60a1, 0x0b4f8c7d, - 0x4d9db919, 0x702c55c5, 0xc039d3d1, 0xfd883f0d, 0xbb5a0a69, - 0x86ebe6b5, 0x6dfcc142, 0x504d2d9e, 0x169f18fa, 0x2b2ef426, - 0x9b3b7232, 0xa68a9eee, 0xe058ab8a, 0xdde94756, 0x5b02a1e3, - 0x66b34d3f, 0x2061785b, 0x1dd09487, 0xadc51293, 0x9074fe4f, - 0xd6a6cb2b, 0xeb1727f7, 0xdbf98284, 0xe6486e58, 0xa09a5b3c, - 0x9d2bb7e0, 0x2d3e31f4, 0x108fdd28, 0x565de84c, 0x6bec0490, - 0xed07e225, 0xd0b60ef9, 0x96643b9d, 0xabd5d741, 0x1bc05155, - 0x2671bd89, 0x60a388ed, 0x5d126431, 0xb60543c6, 0x8bb4af1a, - 0xcd669a7e, 0xf0d776a2, 0x40c2f0b6, 0x7d731c6a, 0x3ba1290e, - 0x0610c5d2, 0x80fb2367, 0xbd4acfbb, 0xfb98fadf, 0xc6291603, - 0x763c9017, 0x4b8d7ccb, 0x0d5f49af, 0x30eea573, 0x6c820349, - 0x5133ef95, 0x17e1daf1, 0x2a50362d, 0x9a45b039, 0xa7f45ce5, - 0xe1266981, 0xdc97855d, 0x5a7c63e8, 0x67cd8f34, 0x211fba50, - 0x1cae568c, 0xacbbd098, 0x910a3c44, 0xd7d80920, 0xea69e5fc, - 0x017ec20b, 0x3ccf2ed7, 0x7a1d1bb3, 0x47acf76f, 0xf7b9717b, - 0xca089da7, 0x8cdaa8c3, 0xb16b441f, 0x3780a2aa, 0x0a314e76, - 0x4ce37b12, 0x715297ce, 0xc14711da, 0xfcf6fd06, 0xba24c862, - 0x879524be, 0xb77b81cd, 0x8aca6d11, 0xcc185875, 0xf1a9b4a9, - 0x41bc32bd, 0x7c0dde61, 0x3adfeb05, 0x076e07d9, 0x8185e16c, - 0xbc340db0, 0xfae638d4, 0xc757d408, 0x7742521c, 0x4af3bec0, - 0x0c218ba4, 0x31906778, 0xda87408f, 0xe736ac53, 0xa1e49937, - 0x9c5575eb, 0x2c40f3ff, 0x11f11f23, 0x57232a47, 0x6a92c69b, - 0xec79202e, 0xd1c8ccf2, 0x971af996, 0xaaab154a, 0x1abe935e, - 0x270f7f82, 0x61dd4ae6, 0x5c6ca63a, 0xd9040692, 0xe4b5ea4e, - 0xa267df2a, 0x9fd633f6, 0x2fc3b5e2, 0x1272593e, 0x54a06c5a, - 0x69118086, 0xeffa6633, 0xd24b8aef, 0x9499bf8b, 0xa9285357, - 0x193dd543, 0x248c399f, 0x625e0cfb, 0x5fefe027, 0xb4f8c7d0, - 0x89492b0c, 0xcf9b1e68, 0xf22af2b4, 0x423f74a0, 0x7f8e987c, - 0x395cad18, 0x04ed41c4, 0x8206a771, 0xbfb74bad, 0xf9657ec9, - 0xc4d49215, 0x74c11401, 0x4970f8dd, 0x0fa2cdb9, 0x32132165, - 0x02fd8416, 0x3f4c68ca, 0x799e5dae, 0x442fb172, 0xf43a3766, - 0xc98bdbba, 0x8f59eede, 0xb2e80202, 0x3403e4b7, 0x09b2086b, - 0x4f603d0f, 0x72d1d1d3, 0xc2c457c7, 0xff75bb1b, 0xb9a78e7f, - 0x841662a3, 0x6f014554, 0x52b0a988, 0x14629cec, 0x29d37030, - 0x99c6f624, 0xa4771af8, 0xe2a52f9c, 0xdf14c340, 0x59ff25f5, - 0x644ec929, 0x229cfc4d, 0x1f2d1091, 0xaf389685, 0x92897a59, - 0xd45b4f3d, 0xe9eaa3e1, 0xb58605db, 0x8837e907, 0xcee5dc63, - 0xf35430bf, 0x4341b6ab, 0x7ef05a77, 0x38226f13, 0x059383cf, - 0x8378657a, 0xbec989a6, 0xf81bbcc2, 0xc5aa501e, 0x75bfd60a, - 0x480e3ad6, 0x0edc0fb2, 0x336de36e, 0xd87ac499, 0xe5cb2845, - 0xa3191d21, 0x9ea8f1fd, 0x2ebd77e9, 0x130c9b35, 0x55deae51, - 0x686f428d, 0xee84a438, 0xd33548e4, 0x95e77d80, 0xa856915c, - 0x18431748, 0x25f2fb94, 0x6320cef0, 0x5e91222c, 0x6e7f875f, - 0x53ce6b83, 0x151c5ee7, 0x28adb23b, 0x98b8342f, 0xa509d8f3, - 0xe3dbed97, 0xde6a014b, 0x5881e7fe, 0x65300b22, 0x23e23e46, - 0x1e53d29a, 0xae46548e, 0x93f7b852, 0xd5258d36, 0xe89461ea, - 0x0383461d, 0x3e32aac1, 0x78e09fa5, 0x45517379, 0xf544f56d, - 0xc8f519b1, 0x8e272cd5, 0xb396c009, 0x357d26bc, 0x08ccca60, - 0x4e1eff04, 0x73af13d8, 0xc3ba95cc, 0xfe0b7910, 0xb8d94c74, - 0x8568a0a8}, - {0x00000000, 0x69790b65, 0xd2f216ca, 0xbb8b1daf, 0x7e952bd5, - 0x17ec20b0, 0xac673d1f, 0xc51e367a, 0xfd2a57aa, 0x94535ccf, - 0x2fd84160, 0x46a14a05, 0x83bf7c7f, 0xeac6771a, 0x514d6ab5, - 0x383461d0, 0x2125a915, 0x485ca270, 0xf3d7bfdf, 0x9aaeb4ba, - 0x5fb082c0, 0x36c989a5, 0x8d42940a, 0xe43b9f6f, 0xdc0ffebf, - 0xb576f5da, 0x0efde875, 0x6784e310, 0xa29ad56a, 0xcbe3de0f, - 0x7068c3a0, 0x1911c8c5, 0x424b522a, 0x2b32594f, 0x90b944e0, - 0xf9c04f85, 0x3cde79ff, 0x55a7729a, 0xee2c6f35, 0x87556450, - 0xbf610580, 0xd6180ee5, 0x6d93134a, 0x04ea182f, 0xc1f42e55, - 0xa88d2530, 0x1306389f, 0x7a7f33fa, 0x636efb3f, 0x0a17f05a, - 0xb19cedf5, 0xd8e5e690, 0x1dfbd0ea, 0x7482db8f, 0xcf09c620, - 0xa670cd45, 0x9e44ac95, 0xf73da7f0, 0x4cb6ba5f, 0x25cfb13a, - 0xe0d18740, 0x89a88c25, 0x3223918a, 0x5b5a9aef, 0x8496a454, - 0xedefaf31, 0x5664b29e, 0x3f1db9fb, 0xfa038f81, 0x937a84e4, - 0x28f1994b, 0x4188922e, 0x79bcf3fe, 0x10c5f89b, 0xab4ee534, - 0xc237ee51, 0x0729d82b, 0x6e50d34e, 0xd5dbcee1, 0xbca2c584, - 0xa5b30d41, 0xccca0624, 0x77411b8b, 0x1e3810ee, 0xdb262694, - 0xb25f2df1, 0x09d4305e, 0x60ad3b3b, 0x58995aeb, 0x31e0518e, - 0x8a6b4c21, 0xe3124744, 0x260c713e, 0x4f757a5b, 0xf4fe67f4, - 0x9d876c91, 0xc6ddf67e, 0xafa4fd1b, 0x142fe0b4, 0x7d56ebd1, - 0xb848ddab, 0xd131d6ce, 0x6abacb61, 0x03c3c004, 0x3bf7a1d4, - 0x528eaab1, 0xe905b71e, 0x807cbc7b, 0x45628a01, 0x2c1b8164, - 0x97909ccb, 0xfee997ae, 0xe7f85f6b, 0x8e81540e, 0x350a49a1, - 0x5c7342c4, 0x996d74be, 0xf0147fdb, 0x4b9f6274, 0x22e66911, - 0x1ad208c1, 0x73ab03a4, 0xc8201e0b, 0xa159156e, 0x64472314, - 0x0d3e2871, 0xb6b535de, 0xdfcc3ebb, 0xd25c4ee9, 0xbb25458c, - 0x00ae5823, 0x69d75346, 0xacc9653c, 0xc5b06e59, 0x7e3b73f6, - 0x17427893, 0x2f761943, 0x460f1226, 0xfd840f89, 0x94fd04ec, - 0x51e33296, 0x389a39f3, 0x8311245c, 0xea682f39, 0xf379e7fc, - 0x9a00ec99, 0x218bf136, 0x48f2fa53, 0x8deccc29, 0xe495c74c, - 0x5f1edae3, 0x3667d186, 0x0e53b056, 0x672abb33, 0xdca1a69c, - 0xb5d8adf9, 0x70c69b83, 0x19bf90e6, 0xa2348d49, 0xcb4d862c, - 0x90171cc3, 0xf96e17a6, 0x42e50a09, 0x2b9c016c, 0xee823716, - 0x87fb3c73, 0x3c7021dc, 0x55092ab9, 0x6d3d4b69, 0x0444400c, - 0xbfcf5da3, 0xd6b656c6, 0x13a860bc, 0x7ad16bd9, 0xc15a7676, - 0xa8237d13, 0xb132b5d6, 0xd84bbeb3, 0x63c0a31c, 0x0ab9a879, - 0xcfa79e03, 0xa6de9566, 0x1d5588c9, 0x742c83ac, 0x4c18e27c, - 0x2561e919, 0x9eeaf4b6, 0xf793ffd3, 0x328dc9a9, 0x5bf4c2cc, - 0xe07fdf63, 0x8906d406, 0x56caeabd, 0x3fb3e1d8, 0x8438fc77, - 0xed41f712, 0x285fc168, 0x4126ca0d, 0xfaadd7a2, 0x93d4dcc7, - 0xabe0bd17, 0xc299b672, 0x7912abdd, 0x106ba0b8, 0xd57596c2, - 0xbc0c9da7, 0x07878008, 0x6efe8b6d, 0x77ef43a8, 0x1e9648cd, - 0xa51d5562, 0xcc645e07, 0x097a687d, 0x60036318, 0xdb887eb7, - 0xb2f175d2, 0x8ac51402, 0xe3bc1f67, 0x583702c8, 0x314e09ad, - 0xf4503fd7, 0x9d2934b2, 0x26a2291d, 0x4fdb2278, 0x1481b897, - 0x7df8b3f2, 0xc673ae5d, 0xaf0aa538, 0x6a149342, 0x036d9827, - 0xb8e68588, 0xd19f8eed, 0xe9abef3d, 0x80d2e458, 0x3b59f9f7, - 0x5220f292, 0x973ec4e8, 0xfe47cf8d, 0x45ccd222, 0x2cb5d947, - 0x35a41182, 0x5cdd1ae7, 0xe7560748, 0x8e2f0c2d, 0x4b313a57, - 0x22483132, 0x99c32c9d, 0xf0ba27f8, 0xc88e4628, 0xa1f74d4d, - 0x1a7c50e2, 0x73055b87, 0xb61b6dfd, 0xdf626698, 0x64e97b37, - 0x0d907052}, - {0x00000000, 0x7fc99b93, 0xff933726, 0x805aacb5, 0x2457680d, - 0x5b9ef39e, 0xdbc45f2b, 0xa40dc4b8, 0x48aed01a, 0x37674b89, - 0xb73de73c, 0xc8f47caf, 0x6cf9b817, 0x13302384, 0x936a8f31, - 0xeca314a2, 0x915da034, 0xee943ba7, 0x6ece9712, 0x11070c81, - 0xb50ac839, 0xcac353aa, 0x4a99ff1f, 0x3550648c, 0xd9f3702e, - 0xa63aebbd, 0x26604708, 0x59a9dc9b, 0xfda41823, 0x826d83b0, - 0x02372f05, 0x7dfeb496, 0xf9ca4629, 0x8603ddba, 0x0659710f, - 0x7990ea9c, 0xdd9d2e24, 0xa254b5b7, 0x220e1902, 0x5dc78291, - 0xb1649633, 0xcead0da0, 0x4ef7a115, 0x313e3a86, 0x9533fe3e, - 0xeafa65ad, 0x6aa0c918, 0x1569528b, 0x6897e61d, 0x175e7d8e, - 0x9704d13b, 0xe8cd4aa8, 0x4cc08e10, 0x33091583, 0xb353b936, - 0xcc9a22a5, 0x20393607, 0x5ff0ad94, 0xdfaa0121, 0xa0639ab2, - 0x046e5e0a, 0x7ba7c599, 0xfbfd692c, 0x8434f2bf, 0x28e58a13, - 0x572c1180, 0xd776bd35, 0xa8bf26a6, 0x0cb2e21e, 0x737b798d, - 0xf321d538, 0x8ce84eab, 0x604b5a09, 0x1f82c19a, 0x9fd86d2f, - 0xe011f6bc, 0x441c3204, 0x3bd5a997, 0xbb8f0522, 0xc4469eb1, - 0xb9b82a27, 0xc671b1b4, 0x462b1d01, 0x39e28692, 0x9def422a, - 0xe226d9b9, 0x627c750c, 0x1db5ee9f, 0xf116fa3d, 0x8edf61ae, - 0x0e85cd1b, 0x714c5688, 0xd5419230, 0xaa8809a3, 0x2ad2a516, - 0x551b3e85, 0xd12fcc3a, 0xaee657a9, 0x2ebcfb1c, 0x5175608f, - 0xf578a437, 0x8ab13fa4, 0x0aeb9311, 0x75220882, 0x99811c20, - 0xe64887b3, 0x66122b06, 0x19dbb095, 0xbdd6742d, 0xc21fefbe, - 0x4245430b, 0x3d8cd898, 0x40726c0e, 0x3fbbf79d, 0xbfe15b28, - 0xc028c0bb, 0x64250403, 0x1bec9f90, 0x9bb63325, 0xe47fa8b6, - 0x08dcbc14, 0x77152787, 0xf74f8b32, 0x888610a1, 0x2c8bd419, - 0x53424f8a, 0xd318e33f, 0xacd178ac, 0x51cb1426, 0x2e028fb5, - 0xae582300, 0xd191b893, 0x759c7c2b, 0x0a55e7b8, 0x8a0f4b0d, - 0xf5c6d09e, 0x1965c43c, 0x66ac5faf, 0xe6f6f31a, 0x993f6889, - 0x3d32ac31, 0x42fb37a2, 0xc2a19b17, 0xbd680084, 0xc096b412, - 0xbf5f2f81, 0x3f058334, 0x40cc18a7, 0xe4c1dc1f, 0x9b08478c, - 0x1b52eb39, 0x649b70aa, 0x88386408, 0xf7f1ff9b, 0x77ab532e, - 0x0862c8bd, 0xac6f0c05, 0xd3a69796, 0x53fc3b23, 0x2c35a0b0, - 0xa801520f, 0xd7c8c99c, 0x57926529, 0x285bfeba, 0x8c563a02, - 0xf39fa191, 0x73c50d24, 0x0c0c96b7, 0xe0af8215, 0x9f661986, - 0x1f3cb533, 0x60f52ea0, 0xc4f8ea18, 0xbb31718b, 0x3b6bdd3e, - 0x44a246ad, 0x395cf23b, 0x469569a8, 0xc6cfc51d, 0xb9065e8e, - 0x1d0b9a36, 0x62c201a5, 0xe298ad10, 0x9d513683, 0x71f22221, - 0x0e3bb9b2, 0x8e611507, 0xf1a88e94, 0x55a54a2c, 0x2a6cd1bf, - 0xaa367d0a, 0xd5ffe699, 0x792e9e35, 0x06e705a6, 0x86bda913, - 0xf9743280, 0x5d79f638, 0x22b06dab, 0xa2eac11e, 0xdd235a8d, - 0x31804e2f, 0x4e49d5bc, 0xce137909, 0xb1dae29a, 0x15d72622, - 0x6a1ebdb1, 0xea441104, 0x958d8a97, 0xe8733e01, 0x97baa592, - 0x17e00927, 0x682992b4, 0xcc24560c, 0xb3edcd9f, 0x33b7612a, - 0x4c7efab9, 0xa0ddee1b, 0xdf147588, 0x5f4ed93d, 0x208742ae, - 0x848a8616, 0xfb431d85, 0x7b19b130, 0x04d02aa3, 0x80e4d81c, - 0xff2d438f, 0x7f77ef3a, 0x00be74a9, 0xa4b3b011, 0xdb7a2b82, - 0x5b208737, 0x24e91ca4, 0xc84a0806, 0xb7839395, 0x37d93f20, - 0x4810a4b3, 0xec1d600b, 0x93d4fb98, 0x138e572d, 0x6c47ccbe, - 0x11b97828, 0x6e70e3bb, 0xee2a4f0e, 0x91e3d49d, 0x35ee1025, - 0x4a278bb6, 0xca7d2703, 0xb5b4bc90, 0x5917a832, 0x26de33a1, - 0xa6849f14, 0xd94d0487, 0x7d40c03f, 0x02895bac, 0x82d3f719, - 0xfd1a6c8a}, - {0x00000000, 0xa396284c, 0x9c5d56d9, 0x3fcb7e95, 0xe3cbabf3, - 0x405d83bf, 0x7f96fd2a, 0xdc00d566, 0x1ce651a7, 0xbf7079eb, - 0x80bb077e, 0x232d2f32, 0xff2dfa54, 0x5cbbd218, 0x6370ac8d, - 0xc0e684c1, 0x39cca34e, 0x9a5a8b02, 0xa591f597, 0x0607dddb, - 0xda0708bd, 0x799120f1, 0x465a5e64, 0xe5cc7628, 0x252af2e9, - 0x86bcdaa5, 0xb977a430, 0x1ae18c7c, 0xc6e1591a, 0x65777156, - 0x5abc0fc3, 0xf92a278f, 0x7399469c, 0xd00f6ed0, 0xefc41045, - 0x4c523809, 0x9052ed6f, 0x33c4c523, 0x0c0fbbb6, 0xaf9993fa, - 0x6f7f173b, 0xcce93f77, 0xf32241e2, 0x50b469ae, 0x8cb4bcc8, - 0x2f229484, 0x10e9ea11, 0xb37fc25d, 0x4a55e5d2, 0xe9c3cd9e, - 0xd608b30b, 0x759e9b47, 0xa99e4e21, 0x0a08666d, 0x35c318f8, - 0x965530b4, 0x56b3b475, 0xf5259c39, 0xcaeee2ac, 0x6978cae0, - 0xb5781f86, 0x16ee37ca, 0x2925495f, 0x8ab36113, 0xe7328d38, - 0x44a4a574, 0x7b6fdbe1, 0xd8f9f3ad, 0x04f926cb, 0xa76f0e87, - 0x98a47012, 0x3b32585e, 0xfbd4dc9f, 0x5842f4d3, 0x67898a46, - 0xc41fa20a, 0x181f776c, 0xbb895f20, 0x844221b5, 0x27d409f9, - 0xdefe2e76, 0x7d68063a, 0x42a378af, 0xe13550e3, 0x3d358585, - 0x9ea3adc9, 0xa168d35c, 0x02fefb10, 0xc2187fd1, 0x618e579d, - 0x5e452908, 0xfdd30144, 0x21d3d422, 0x8245fc6e, 0xbd8e82fb, - 0x1e18aab7, 0x94abcba4, 0x373de3e8, 0x08f69d7d, 0xab60b531, - 0x77606057, 0xd4f6481b, 0xeb3d368e, 0x48ab1ec2, 0x884d9a03, - 0x2bdbb24f, 0x1410ccda, 0xb786e496, 0x6b8631f0, 0xc81019bc, - 0xf7db6729, 0x544d4f65, 0xad6768ea, 0x0ef140a6, 0x313a3e33, - 0x92ac167f, 0x4eacc319, 0xed3aeb55, 0xd2f195c0, 0x7167bd8c, - 0xb181394d, 0x12171101, 0x2ddc6f94, 0x8e4a47d8, 0x524a92be, - 0xf1dcbaf2, 0xce17c467, 0x6d81ec2b, 0x15141c31, 0xb682347d, - 0x89494ae8, 0x2adf62a4, 0xf6dfb7c2, 0x55499f8e, 0x6a82e11b, - 0xc914c957, 0x09f24d96, 0xaa6465da, 0x95af1b4f, 0x36393303, - 0xea39e665, 0x49afce29, 0x7664b0bc, 0xd5f298f0, 0x2cd8bf7f, - 0x8f4e9733, 0xb085e9a6, 0x1313c1ea, 0xcf13148c, 0x6c853cc0, - 0x534e4255, 0xf0d86a19, 0x303eeed8, 0x93a8c694, 0xac63b801, - 0x0ff5904d, 0xd3f5452b, 0x70636d67, 0x4fa813f2, 0xec3e3bbe, - 0x668d5aad, 0xc51b72e1, 0xfad00c74, 0x59462438, 0x8546f15e, - 0x26d0d912, 0x191ba787, 0xba8d8fcb, 0x7a6b0b0a, 0xd9fd2346, - 0xe6365dd3, 0x45a0759f, 0x99a0a0f9, 0x3a3688b5, 0x05fdf620, - 0xa66bde6c, 0x5f41f9e3, 0xfcd7d1af, 0xc31caf3a, 0x608a8776, - 0xbc8a5210, 0x1f1c7a5c, 0x20d704c9, 0x83412c85, 0x43a7a844, - 0xe0318008, 0xdffafe9d, 0x7c6cd6d1, 0xa06c03b7, 0x03fa2bfb, - 0x3c31556e, 0x9fa77d22, 0xf2269109, 0x51b0b945, 0x6e7bc7d0, - 0xcdedef9c, 0x11ed3afa, 0xb27b12b6, 0x8db06c23, 0x2e26446f, - 0xeec0c0ae, 0x4d56e8e2, 0x729d9677, 0xd10bbe3b, 0x0d0b6b5d, - 0xae9d4311, 0x91563d84, 0x32c015c8, 0xcbea3247, 0x687c1a0b, - 0x57b7649e, 0xf4214cd2, 0x282199b4, 0x8bb7b1f8, 0xb47ccf6d, - 0x17eae721, 0xd70c63e0, 0x749a4bac, 0x4b513539, 0xe8c71d75, - 0x34c7c813, 0x9751e05f, 0xa89a9eca, 0x0b0cb686, 0x81bfd795, - 0x2229ffd9, 0x1de2814c, 0xbe74a900, 0x62747c66, 0xc1e2542a, - 0xfe292abf, 0x5dbf02f3, 0x9d598632, 0x3ecfae7e, 0x0104d0eb, - 0xa292f8a7, 0x7e922dc1, 0xdd04058d, 0xe2cf7b18, 0x41595354, - 0xb87374db, 0x1be55c97, 0x242e2202, 0x87b80a4e, 0x5bb8df28, - 0xf82ef764, 0xc7e589f1, 0x6473a1bd, 0xa495257c, 0x07030d30, - 0x38c873a5, 0x9b5e5be9, 0x475e8e8f, 0xe4c8a6c3, 0xdb03d856, - 0x7895f01a}, - {0x00000000, 0x2a283862, 0x545070c4, 0x7e7848a6, 0xa8a0e188, - 0x8288d9ea, 0xfcf0914c, 0xd6d8a92e, 0x8a30c551, 0xa018fd33, - 0xde60b595, 0xf4488df7, 0x229024d9, 0x08b81cbb, 0x76c0541d, - 0x5ce86c7f, 0xcf108ce3, 0xe538b481, 0x9b40fc27, 0xb168c445, - 0x67b06d6b, 0x4d985509, 0x33e01daf, 0x19c825cd, 0x452049b2, - 0x6f0871d0, 0x11703976, 0x3b580114, 0xed80a83a, 0xc7a89058, - 0xb9d0d8fe, 0x93f8e09c, 0x45501f87, 0x6f7827e5, 0x11006f43, - 0x3b285721, 0xedf0fe0f, 0xc7d8c66d, 0xb9a08ecb, 0x9388b6a9, - 0xcf60dad6, 0xe548e2b4, 0x9b30aa12, 0xb1189270, 0x67c03b5e, - 0x4de8033c, 0x33904b9a, 0x19b873f8, 0x8a409364, 0xa068ab06, - 0xde10e3a0, 0xf438dbc2, 0x22e072ec, 0x08c84a8e, 0x76b00228, - 0x5c983a4a, 0x00705635, 0x2a586e57, 0x542026f1, 0x7e081e93, - 0xa8d0b7bd, 0x82f88fdf, 0xfc80c779, 0xd6a8ff1b, 0x8aa03f0e, - 0xa088076c, 0xdef04fca, 0xf4d877a8, 0x2200de86, 0x0828e6e4, - 0x7650ae42, 0x5c789620, 0x0090fa5f, 0x2ab8c23d, 0x54c08a9b, - 0x7ee8b2f9, 0xa8301bd7, 0x821823b5, 0xfc606b13, 0xd6485371, - 0x45b0b3ed, 0x6f988b8f, 0x11e0c329, 0x3bc8fb4b, 0xed105265, - 0xc7386a07, 0xb94022a1, 0x93681ac3, 0xcf8076bc, 0xe5a84ede, - 0x9bd00678, 0xb1f83e1a, 0x67209734, 0x4d08af56, 0x3370e7f0, - 0x1958df92, 0xcff02089, 0xe5d818eb, 0x9ba0504d, 0xb188682f, - 0x6750c101, 0x4d78f963, 0x3300b1c5, 0x192889a7, 0x45c0e5d8, - 0x6fe8ddba, 0x1190951c, 0x3bb8ad7e, 0xed600450, 0xc7483c32, - 0xb9307494, 0x93184cf6, 0x00e0ac6a, 0x2ac89408, 0x54b0dcae, - 0x7e98e4cc, 0xa8404de2, 0x82687580, 0xfc103d26, 0xd6380544, - 0x8ad0693b, 0xa0f85159, 0xde8019ff, 0xf4a8219d, 0x227088b3, - 0x0858b0d1, 0x7620f877, 0x5c08c015, 0xce31785d, 0xe419403f, - 0x9a610899, 0xb04930fb, 0x669199d5, 0x4cb9a1b7, 0x32c1e911, - 0x18e9d173, 0x4401bd0c, 0x6e29856e, 0x1051cdc8, 0x3a79f5aa, - 0xeca15c84, 0xc68964e6, 0xb8f12c40, 0x92d91422, 0x0121f4be, - 0x2b09ccdc, 0x5571847a, 0x7f59bc18, 0xa9811536, 0x83a92d54, - 0xfdd165f2, 0xd7f95d90, 0x8b1131ef, 0xa139098d, 0xdf41412b, - 0xf5697949, 0x23b1d067, 0x0999e805, 0x77e1a0a3, 0x5dc998c1, - 0x8b6167da, 0xa1495fb8, 0xdf31171e, 0xf5192f7c, 0x23c18652, - 0x09e9be30, 0x7791f696, 0x5db9cef4, 0x0151a28b, 0x2b799ae9, - 0x5501d24f, 0x7f29ea2d, 0xa9f14303, 0x83d97b61, 0xfda133c7, - 0xd7890ba5, 0x4471eb39, 0x6e59d35b, 0x10219bfd, 0x3a09a39f, - 0xecd10ab1, 0xc6f932d3, 0xb8817a75, 0x92a94217, 0xce412e68, - 0xe469160a, 0x9a115eac, 0xb03966ce, 0x66e1cfe0, 0x4cc9f782, - 0x32b1bf24, 0x18998746, 0x44914753, 0x6eb97f31, 0x10c13797, - 0x3ae90ff5, 0xec31a6db, 0xc6199eb9, 0xb861d61f, 0x9249ee7d, - 0xcea18202, 0xe489ba60, 0x9af1f2c6, 0xb0d9caa4, 0x6601638a, - 0x4c295be8, 0x3251134e, 0x18792b2c, 0x8b81cbb0, 0xa1a9f3d2, - 0xdfd1bb74, 0xf5f98316, 0x23212a38, 0x0909125a, 0x77715afc, - 0x5d59629e, 0x01b10ee1, 0x2b993683, 0x55e17e25, 0x7fc94647, - 0xa911ef69, 0x8339d70b, 0xfd419fad, 0xd769a7cf, 0x01c158d4, - 0x2be960b6, 0x55912810, 0x7fb91072, 0xa961b95c, 0x8349813e, - 0xfd31c998, 0xd719f1fa, 0x8bf19d85, 0xa1d9a5e7, 0xdfa1ed41, - 0xf589d523, 0x23517c0d, 0x0979446f, 0x77010cc9, 0x5d2934ab, - 0xced1d437, 0xe4f9ec55, 0x9a81a4f3, 0xb0a99c91, 0x667135bf, - 0x4c590ddd, 0x3221457b, 0x18097d19, 0x44e11166, 0x6ec92904, - 0x10b161a2, 0x3a9959c0, 0xec41f0ee, 0xc669c88c, 0xb811802a, - 0x9239b848}, - {0x00000000, 0x4713f6fb, 0x8e27edf6, 0xc9341b0d, 0xc73eddad, - 0x802d2b56, 0x4919305b, 0x0e0ac6a0, 0x550cbd1b, 0x121f4be0, - 0xdb2b50ed, 0x9c38a616, 0x923260b6, 0xd521964d, 0x1c158d40, - 0x5b067bbb, 0xaa197a36, 0xed0a8ccd, 0x243e97c0, 0x632d613b, - 0x6d27a79b, 0x2a345160, 0xe3004a6d, 0xa413bc96, 0xff15c72d, - 0xb80631d6, 0x71322adb, 0x3621dc20, 0x382b1a80, 0x7f38ec7b, - 0xb60cf776, 0xf11f018d, 0x8f43f22d, 0xc85004d6, 0x01641fdb, - 0x4677e920, 0x487d2f80, 0x0f6ed97b, 0xc65ac276, 0x8149348d, - 0xda4f4f36, 0x9d5cb9cd, 0x5468a2c0, 0x137b543b, 0x1d71929b, - 0x5a626460, 0x93567f6d, 0xd4458996, 0x255a881b, 0x62497ee0, - 0xab7d65ed, 0xec6e9316, 0xe26455b6, 0xa577a34d, 0x6c43b840, - 0x2b504ebb, 0x70563500, 0x3745c3fb, 0xfe71d8f6, 0xb9622e0d, - 0xb768e8ad, 0xf07b1e56, 0x394f055b, 0x7e5cf3a0, 0xc5f6e21b, - 0x82e514e0, 0x4bd10fed, 0x0cc2f916, 0x02c83fb6, 0x45dbc94d, - 0x8cefd240, 0xcbfc24bb, 0x90fa5f00, 0xd7e9a9fb, 0x1eddb2f6, - 0x59ce440d, 0x57c482ad, 0x10d77456, 0xd9e36f5b, 0x9ef099a0, - 0x6fef982d, 0x28fc6ed6, 0xe1c875db, 0xa6db8320, 0xa8d14580, - 0xefc2b37b, 0x26f6a876, 0x61e55e8d, 0x3ae32536, 0x7df0d3cd, - 0xb4c4c8c0, 0xf3d73e3b, 0xfdddf89b, 0xbace0e60, 0x73fa156d, - 0x34e9e396, 0x4ab51036, 0x0da6e6cd, 0xc492fdc0, 0x83810b3b, - 0x8d8bcd9b, 0xca983b60, 0x03ac206d, 0x44bfd696, 0x1fb9ad2d, - 0x58aa5bd6, 0x919e40db, 0xd68db620, 0xd8877080, 0x9f94867b, - 0x56a09d76, 0x11b36b8d, 0xe0ac6a00, 0xa7bf9cfb, 0x6e8b87f6, - 0x2998710d, 0x2792b7ad, 0x60814156, 0xa9b55a5b, 0xeea6aca0, - 0xb5a0d71b, 0xf2b321e0, 0x3b873aed, 0x7c94cc16, 0x729e0ab6, - 0x358dfc4d, 0xfcb9e740, 0xbbaa11bb, 0x509cc277, 0x178f348c, - 0xdebb2f81, 0x99a8d97a, 0x97a21fda, 0xd0b1e921, 0x1985f22c, - 0x5e9604d7, 0x05907f6c, 0x42838997, 0x8bb7929a, 0xcca46461, - 0xc2aea2c1, 0x85bd543a, 0x4c894f37, 0x0b9ab9cc, 0xfa85b841, - 0xbd964eba, 0x74a255b7, 0x33b1a34c, 0x3dbb65ec, 0x7aa89317, - 0xb39c881a, 0xf48f7ee1, 0xaf89055a, 0xe89af3a1, 0x21aee8ac, - 0x66bd1e57, 0x68b7d8f7, 0x2fa42e0c, 0xe6903501, 0xa183c3fa, - 0xdfdf305a, 0x98ccc6a1, 0x51f8ddac, 0x16eb2b57, 0x18e1edf7, - 0x5ff21b0c, 0x96c60001, 0xd1d5f6fa, 0x8ad38d41, 0xcdc07bba, - 0x04f460b7, 0x43e7964c, 0x4ded50ec, 0x0afea617, 0xc3cabd1a, - 0x84d94be1, 0x75c64a6c, 0x32d5bc97, 0xfbe1a79a, 0xbcf25161, - 0xb2f897c1, 0xf5eb613a, 0x3cdf7a37, 0x7bcc8ccc, 0x20caf777, - 0x67d9018c, 0xaeed1a81, 0xe9feec7a, 0xe7f42ada, 0xa0e7dc21, - 0x69d3c72c, 0x2ec031d7, 0x956a206c, 0xd279d697, 0x1b4dcd9a, - 0x5c5e3b61, 0x5254fdc1, 0x15470b3a, 0xdc731037, 0x9b60e6cc, - 0xc0669d77, 0x87756b8c, 0x4e417081, 0x0952867a, 0x075840da, - 0x404bb621, 0x897fad2c, 0xce6c5bd7, 0x3f735a5a, 0x7860aca1, - 0xb154b7ac, 0xf6474157, 0xf84d87f7, 0xbf5e710c, 0x766a6a01, - 0x31799cfa, 0x6a7fe741, 0x2d6c11ba, 0xe4580ab7, 0xa34bfc4c, - 0xad413aec, 0xea52cc17, 0x2366d71a, 0x647521e1, 0x1a29d241, - 0x5d3a24ba, 0x940e3fb7, 0xd31dc94c, 0xdd170fec, 0x9a04f917, - 0x5330e21a, 0x142314e1, 0x4f256f5a, 0x083699a1, 0xc10282ac, - 0x86117457, 0x881bb2f7, 0xcf08440c, 0x063c5f01, 0x412fa9fa, - 0xb030a877, 0xf7235e8c, 0x3e174581, 0x7904b37a, 0x770e75da, - 0x301d8321, 0xf929982c, 0xbe3a6ed7, 0xe53c156c, 0xa22fe397, - 0x6b1bf89a, 0x2c080e61, 0x2202c8c1, 0x65113e3a, 0xac252537, - 0xeb36d3cc}, - {0x00000000, 0xa13984ee, 0x99020f9d, 0x383b8b73, 0xe975197b, - 0x484c9d95, 0x707716e6, 0xd14e9208, 0x099b34b7, 0xa8a2b059, - 0x90993b2a, 0x31a0bfc4, 0xe0ee2dcc, 0x41d7a922, 0x79ec2251, - 0xd8d5a6bf, 0x1336696e, 0xb20fed80, 0x8a3466f3, 0x2b0de21d, - 0xfa437015, 0x5b7af4fb, 0x63417f88, 0xc278fb66, 0x1aad5dd9, - 0xbb94d937, 0x83af5244, 0x2296d6aa, 0xf3d844a2, 0x52e1c04c, - 0x6ada4b3f, 0xcbe3cfd1, 0x266cd2dc, 0x87555632, 0xbf6edd41, - 0x1e5759af, 0xcf19cba7, 0x6e204f49, 0x561bc43a, 0xf72240d4, - 0x2ff7e66b, 0x8ece6285, 0xb6f5e9f6, 0x17cc6d18, 0xc682ff10, - 0x67bb7bfe, 0x5f80f08d, 0xfeb97463, 0x355abbb2, 0x94633f5c, - 0xac58b42f, 0x0d6130c1, 0xdc2fa2c9, 0x7d162627, 0x452dad54, - 0xe41429ba, 0x3cc18f05, 0x9df80beb, 0xa5c38098, 0x04fa0476, - 0xd5b4967e, 0x748d1290, 0x4cb699e3, 0xed8f1d0d, 0x4cd9a5b8, - 0xede02156, 0xd5dbaa25, 0x74e22ecb, 0xa5acbcc3, 0x0495382d, - 0x3caeb35e, 0x9d9737b0, 0x4542910f, 0xe47b15e1, 0xdc409e92, - 0x7d791a7c, 0xac378874, 0x0d0e0c9a, 0x353587e9, 0x940c0307, - 0x5fefccd6, 0xfed64838, 0xc6edc34b, 0x67d447a5, 0xb69ad5ad, - 0x17a35143, 0x2f98da30, 0x8ea15ede, 0x5674f861, 0xf74d7c8f, - 0xcf76f7fc, 0x6e4f7312, 0xbf01e11a, 0x1e3865f4, 0x2603ee87, - 0x873a6a69, 0x6ab57764, 0xcb8cf38a, 0xf3b778f9, 0x528efc17, - 0x83c06e1f, 0x22f9eaf1, 0x1ac26182, 0xbbfbe56c, 0x632e43d3, - 0xc217c73d, 0xfa2c4c4e, 0x5b15c8a0, 0x8a5b5aa8, 0x2b62de46, - 0x13595535, 0xb260d1db, 0x79831e0a, 0xd8ba9ae4, 0xe0811197, - 0x41b89579, 0x90f60771, 0x31cf839f, 0x09f408ec, 0xa8cd8c02, - 0x70182abd, 0xd121ae53, 0xe91a2520, 0x4823a1ce, 0x996d33c6, - 0x3854b728, 0x006f3c5b, 0xa156b8b5, 0x99b34b70, 0x388acf9e, - 0x00b144ed, 0xa188c003, 0x70c6520b, 0xd1ffd6e5, 0xe9c45d96, - 0x48fdd978, 0x90287fc7, 0x3111fb29, 0x092a705a, 0xa813f4b4, - 0x795d66bc, 0xd864e252, 0xe05f6921, 0x4166edcf, 0x8a85221e, - 0x2bbca6f0, 0x13872d83, 0xb2bea96d, 0x63f03b65, 0xc2c9bf8b, - 0xfaf234f8, 0x5bcbb016, 0x831e16a9, 0x22279247, 0x1a1c1934, - 0xbb259dda, 0x6a6b0fd2, 0xcb528b3c, 0xf369004f, 0x525084a1, - 0xbfdf99ac, 0x1ee61d42, 0x26dd9631, 0x87e412df, 0x56aa80d7, - 0xf7930439, 0xcfa88f4a, 0x6e910ba4, 0xb644ad1b, 0x177d29f5, - 0x2f46a286, 0x8e7f2668, 0x5f31b460, 0xfe08308e, 0xc633bbfd, - 0x670a3f13, 0xace9f0c2, 0x0dd0742c, 0x35ebff5f, 0x94d27bb1, - 0x459ce9b9, 0xe4a56d57, 0xdc9ee624, 0x7da762ca, 0xa572c475, - 0x044b409b, 0x3c70cbe8, 0x9d494f06, 0x4c07dd0e, 0xed3e59e0, - 0xd505d293, 0x743c567d, 0xd56aeec8, 0x74536a26, 0x4c68e155, - 0xed5165bb, 0x3c1ff7b3, 0x9d26735d, 0xa51df82e, 0x04247cc0, - 0xdcf1da7f, 0x7dc85e91, 0x45f3d5e2, 0xe4ca510c, 0x3584c304, - 0x94bd47ea, 0xac86cc99, 0x0dbf4877, 0xc65c87a6, 0x67650348, - 0x5f5e883b, 0xfe670cd5, 0x2f299edd, 0x8e101a33, 0xb62b9140, - 0x171215ae, 0xcfc7b311, 0x6efe37ff, 0x56c5bc8c, 0xf7fc3862, - 0x26b2aa6a, 0x878b2e84, 0xbfb0a5f7, 0x1e892119, 0xf3063c14, - 0x523fb8fa, 0x6a043389, 0xcb3db767, 0x1a73256f, 0xbb4aa181, - 0x83712af2, 0x2248ae1c, 0xfa9d08a3, 0x5ba48c4d, 0x639f073e, - 0xc2a683d0, 0x13e811d8, 0xb2d19536, 0x8aea1e45, 0x2bd39aab, - 0xe030557a, 0x4109d194, 0x79325ae7, 0xd80bde09, 0x09454c01, - 0xa87cc8ef, 0x9047439c, 0x317ec772, 0xe9ab61cd, 0x4892e523, - 0x70a96e50, 0xd190eabe, 0x00de78b6, 0xa1e7fc58, 0x99dc772b, - 0x38e5f3c5}, - {0x00000000, 0xe81790a1, 0x0b5e2703, 0xe349b7a2, 0x16bc4e06, - 0xfeabdea7, 0x1de26905, 0xf5f5f9a4, 0x2d789c0c, 0xc56f0cad, - 0x2626bb0f, 0xce312bae, 0x3bc4d20a, 0xd3d342ab, 0x309af509, - 0xd88d65a8, 0x5af13818, 0xb2e6a8b9, 0x51af1f1b, 0xb9b88fba, - 0x4c4d761e, 0xa45ae6bf, 0x4713511d, 0xaf04c1bc, 0x7789a414, - 0x9f9e34b5, 0x7cd78317, 0x94c013b6, 0x6135ea12, 0x89227ab3, - 0x6a6bcd11, 0x827c5db0, 0xb5e27030, 0x5df5e091, 0xbebc5733, - 0x56abc792, 0xa35e3e36, 0x4b49ae97, 0xa8001935, 0x40178994, - 0x989aec3c, 0x708d7c9d, 0x93c4cb3f, 0x7bd35b9e, 0x8e26a23a, - 0x6631329b, 0x85788539, 0x6d6f1598, 0xef134828, 0x0704d889, - 0xe44d6f2b, 0x0c5aff8a, 0xf9af062e, 0x11b8968f, 0xf2f1212d, - 0x1ae6b18c, 0xc26bd424, 0x2a7c4485, 0xc935f327, 0x21226386, - 0xd4d79a22, 0x3cc00a83, 0xdf89bd21, 0x379e2d80, 0xb0b5e621, - 0x58a27680, 0xbbebc122, 0x53fc5183, 0xa609a827, 0x4e1e3886, - 0xad578f24, 0x45401f85, 0x9dcd7a2d, 0x75daea8c, 0x96935d2e, - 0x7e84cd8f, 0x8b71342b, 0x6366a48a, 0x802f1328, 0x68388389, - 0xea44de39, 0x02534e98, 0xe11af93a, 0x090d699b, 0xfcf8903f, - 0x14ef009e, 0xf7a6b73c, 0x1fb1279d, 0xc73c4235, 0x2f2bd294, - 0xcc626536, 0x2475f597, 0xd1800c33, 0x39979c92, 0xdade2b30, - 0x32c9bb91, 0x05579611, 0xed4006b0, 0x0e09b112, 0xe61e21b3, - 0x13ebd817, 0xfbfc48b6, 0x18b5ff14, 0xf0a26fb5, 0x282f0a1d, - 0xc0389abc, 0x23712d1e, 0xcb66bdbf, 0x3e93441b, 0xd684d4ba, - 0x35cd6318, 0xdddaf3b9, 0x5fa6ae09, 0xb7b13ea8, 0x54f8890a, - 0xbcef19ab, 0x491ae00f, 0xa10d70ae, 0x4244c70c, 0xaa5357ad, - 0x72de3205, 0x9ac9a2a4, 0x79801506, 0x919785a7, 0x64627c03, - 0x8c75eca2, 0x6f3c5b00, 0x872bcba1, 0xba1aca03, 0x520d5aa2, - 0xb144ed00, 0x59537da1, 0xaca68405, 0x44b114a4, 0xa7f8a306, - 0x4fef33a7, 0x9762560f, 0x7f75c6ae, 0x9c3c710c, 0x742be1ad, - 0x81de1809, 0x69c988a8, 0x8a803f0a, 0x6297afab, 0xe0ebf21b, - 0x08fc62ba, 0xebb5d518, 0x03a245b9, 0xf657bc1d, 0x1e402cbc, - 0xfd099b1e, 0x151e0bbf, 0xcd936e17, 0x2584feb6, 0xc6cd4914, - 0x2edad9b5, 0xdb2f2011, 0x3338b0b0, 0xd0710712, 0x386697b3, - 0x0ff8ba33, 0xe7ef2a92, 0x04a69d30, 0xecb10d91, 0x1944f435, - 0xf1536494, 0x121ad336, 0xfa0d4397, 0x2280263f, 0xca97b69e, - 0x29de013c, 0xc1c9919d, 0x343c6839, 0xdc2bf898, 0x3f624f3a, - 0xd775df9b, 0x5509822b, 0xbd1e128a, 0x5e57a528, 0xb6403589, - 0x43b5cc2d, 0xaba25c8c, 0x48ebeb2e, 0xa0fc7b8f, 0x78711e27, - 0x90668e86, 0x732f3924, 0x9b38a985, 0x6ecd5021, 0x86dac080, - 0x65937722, 0x8d84e783, 0x0aaf2c22, 0xe2b8bc83, 0x01f10b21, - 0xe9e69b80, 0x1c136224, 0xf404f285, 0x174d4527, 0xff5ad586, - 0x27d7b02e, 0xcfc0208f, 0x2c89972d, 0xc49e078c, 0x316bfe28, - 0xd97c6e89, 0x3a35d92b, 0xd222498a, 0x505e143a, 0xb849849b, - 0x5b003339, 0xb317a398, 0x46e25a3c, 0xaef5ca9d, 0x4dbc7d3f, - 0xa5abed9e, 0x7d268836, 0x95311897, 0x7678af35, 0x9e6f3f94, - 0x6b9ac630, 0x838d5691, 0x60c4e133, 0x88d37192, 0xbf4d5c12, - 0x575accb3, 0xb4137b11, 0x5c04ebb0, 0xa9f11214, 0x41e682b5, - 0xa2af3517, 0x4ab8a5b6, 0x9235c01e, 0x7a2250bf, 0x996be71d, - 0x717c77bc, 0x84898e18, 0x6c9e1eb9, 0x8fd7a91b, 0x67c039ba, - 0xe5bc640a, 0x0dabf4ab, 0xeee24309, 0x06f5d3a8, 0xf3002a0c, - 0x1b17baad, 0xf85e0d0f, 0x10499dae, 0xc8c4f806, 0x20d368a7, - 0xc39adf05, 0x2b8d4fa4, 0xde78b600, 0x366f26a1, 0xd5269103, - 0x3d3101a2}}; - -local const z_word_t FAR crc_braid_big_table[][256] = { - {0x0000000000000000, 0xa19017e800000000, 0x03275e0b00000000, - 0xa2b749e300000000, 0x064ebc1600000000, 0xa7deabfe00000000, - 0x0569e21d00000000, 0xa4f9f5f500000000, 0x0c9c782d00000000, - 0xad0c6fc500000000, 0x0fbb262600000000, 0xae2b31ce00000000, - 0x0ad2c43b00000000, 0xab42d3d300000000, 0x09f59a3000000000, - 0xa8658dd800000000, 0x1838f15a00000000, 0xb9a8e6b200000000, - 0x1b1faf5100000000, 0xba8fb8b900000000, 0x1e764d4c00000000, - 0xbfe65aa400000000, 0x1d51134700000000, 0xbcc104af00000000, - 0x14a4897700000000, 0xb5349e9f00000000, 0x1783d77c00000000, - 0xb613c09400000000, 0x12ea356100000000, 0xb37a228900000000, - 0x11cd6b6a00000000, 0xb05d7c8200000000, 0x3070e2b500000000, - 0x91e0f55d00000000, 0x3357bcbe00000000, 0x92c7ab5600000000, - 0x363e5ea300000000, 0x97ae494b00000000, 0x351900a800000000, - 0x9489174000000000, 0x3cec9a9800000000, 0x9d7c8d7000000000, - 0x3fcbc49300000000, 0x9e5bd37b00000000, 0x3aa2268e00000000, - 0x9b32316600000000, 0x3985788500000000, 0x98156f6d00000000, - 0x284813ef00000000, 0x89d8040700000000, 0x2b6f4de400000000, - 0x8aff5a0c00000000, 0x2e06aff900000000, 0x8f96b81100000000, - 0x2d21f1f200000000, 0x8cb1e61a00000000, 0x24d46bc200000000, - 0x85447c2a00000000, 0x27f335c900000000, 0x8663222100000000, - 0x229ad7d400000000, 0x830ac03c00000000, 0x21bd89df00000000, - 0x802d9e3700000000, 0x21e6b5b000000000, 0x8076a25800000000, - 0x22c1ebbb00000000, 0x8351fc5300000000, 0x27a809a600000000, - 0x86381e4e00000000, 0x248f57ad00000000, 0x851f404500000000, - 0x2d7acd9d00000000, 0x8ceada7500000000, 0x2e5d939600000000, - 0x8fcd847e00000000, 0x2b34718b00000000, 0x8aa4666300000000, - 0x28132f8000000000, 0x8983386800000000, 0x39de44ea00000000, - 0x984e530200000000, 0x3af91ae100000000, 0x9b690d0900000000, - 0x3f90f8fc00000000, 0x9e00ef1400000000, 0x3cb7a6f700000000, - 0x9d27b11f00000000, 0x35423cc700000000, 0x94d22b2f00000000, - 0x366562cc00000000, 0x97f5752400000000, 0x330c80d100000000, - 0x929c973900000000, 0x302bdeda00000000, 0x91bbc93200000000, - 0x1196570500000000, 0xb00640ed00000000, 0x12b1090e00000000, - 0xb3211ee600000000, 0x17d8eb1300000000, 0xb648fcfb00000000, - 0x14ffb51800000000, 0xb56fa2f000000000, 0x1d0a2f2800000000, - 0xbc9a38c000000000, 0x1e2d712300000000, 0xbfbd66cb00000000, - 0x1b44933e00000000, 0xbad484d600000000, 0x1863cd3500000000, - 0xb9f3dadd00000000, 0x09aea65f00000000, 0xa83eb1b700000000, - 0x0a89f85400000000, 0xab19efbc00000000, 0x0fe01a4900000000, - 0xae700da100000000, 0x0cc7444200000000, 0xad5753aa00000000, - 0x0532de7200000000, 0xa4a2c99a00000000, 0x0615807900000000, - 0xa785979100000000, 0x037c626400000000, 0xa2ec758c00000000, - 0x005b3c6f00000000, 0xa1cb2b8700000000, 0x03ca1aba00000000, - 0xa25a0d5200000000, 0x00ed44b100000000, 0xa17d535900000000, - 0x0584a6ac00000000, 0xa414b14400000000, 0x06a3f8a700000000, - 0xa733ef4f00000000, 0x0f56629700000000, 0xaec6757f00000000, - 0x0c713c9c00000000, 0xade12b7400000000, 0x0918de8100000000, - 0xa888c96900000000, 0x0a3f808a00000000, 0xabaf976200000000, - 0x1bf2ebe000000000, 0xba62fc0800000000, 0x18d5b5eb00000000, - 0xb945a20300000000, 0x1dbc57f600000000, 0xbc2c401e00000000, - 0x1e9b09fd00000000, 0xbf0b1e1500000000, 0x176e93cd00000000, - 0xb6fe842500000000, 0x1449cdc600000000, 0xb5d9da2e00000000, - 0x11202fdb00000000, 0xb0b0383300000000, 0x120771d000000000, - 0xb397663800000000, 0x33baf80f00000000, 0x922aefe700000000, - 0x309da60400000000, 0x910db1ec00000000, 0x35f4441900000000, - 0x946453f100000000, 0x36d31a1200000000, 0x97430dfa00000000, - 0x3f26802200000000, 0x9eb697ca00000000, 0x3c01de2900000000, - 0x9d91c9c100000000, 0x39683c3400000000, 0x98f82bdc00000000, - 0x3a4f623f00000000, 0x9bdf75d700000000, 0x2b82095500000000, - 0x8a121ebd00000000, 0x28a5575e00000000, 0x893540b600000000, - 0x2dccb54300000000, 0x8c5ca2ab00000000, 0x2eebeb4800000000, - 0x8f7bfca000000000, 0x271e717800000000, 0x868e669000000000, - 0x24392f7300000000, 0x85a9389b00000000, 0x2150cd6e00000000, - 0x80c0da8600000000, 0x2277936500000000, 0x83e7848d00000000, - 0x222caf0a00000000, 0x83bcb8e200000000, 0x210bf10100000000, - 0x809be6e900000000, 0x2462131c00000000, 0x85f204f400000000, - 0x27454d1700000000, 0x86d55aff00000000, 0x2eb0d72700000000, - 0x8f20c0cf00000000, 0x2d97892c00000000, 0x8c079ec400000000, - 0x28fe6b3100000000, 0x896e7cd900000000, 0x2bd9353a00000000, - 0x8a4922d200000000, 0x3a145e5000000000, 0x9b8449b800000000, - 0x3933005b00000000, 0x98a317b300000000, 0x3c5ae24600000000, - 0x9dcaf5ae00000000, 0x3f7dbc4d00000000, 0x9eedaba500000000, - 0x3688267d00000000, 0x9718319500000000, 0x35af787600000000, - 0x943f6f9e00000000, 0x30c69a6b00000000, 0x91568d8300000000, - 0x33e1c46000000000, 0x9271d38800000000, 0x125c4dbf00000000, - 0xb3cc5a5700000000, 0x117b13b400000000, 0xb0eb045c00000000, - 0x1412f1a900000000, 0xb582e64100000000, 0x1735afa200000000, - 0xb6a5b84a00000000, 0x1ec0359200000000, 0xbf50227a00000000, - 0x1de76b9900000000, 0xbc777c7100000000, 0x188e898400000000, - 0xb91e9e6c00000000, 0x1ba9d78f00000000, 0xba39c06700000000, - 0x0a64bce500000000, 0xabf4ab0d00000000, 0x0943e2ee00000000, - 0xa8d3f50600000000, 0x0c2a00f300000000, 0xadba171b00000000, - 0x0f0d5ef800000000, 0xae9d491000000000, 0x06f8c4c800000000, - 0xa768d32000000000, 0x05df9ac300000000, 0xa44f8d2b00000000, - 0x00b678de00000000, 0xa1266f3600000000, 0x039126d500000000, - 0xa201313d00000000}, - {0x0000000000000000, 0xee8439a100000000, 0x9d0f029900000000, - 0x738b3b3800000000, 0x7b1975e900000000, 0x959d4c4800000000, - 0xe616777000000000, 0x08924ed100000000, 0xb7349b0900000000, - 0x59b0a2a800000000, 0x2a3b999000000000, 0xc4bfa03100000000, - 0xcc2deee000000000, 0x22a9d74100000000, 0x5122ec7900000000, - 0xbfa6d5d800000000, 0x6e69361300000000, 0x80ed0fb200000000, - 0xf366348a00000000, 0x1de20d2b00000000, 0x157043fa00000000, - 0xfbf47a5b00000000, 0x887f416300000000, 0x66fb78c200000000, - 0xd95dad1a00000000, 0x37d994bb00000000, 0x4452af8300000000, - 0xaad6962200000000, 0xa244d8f300000000, 0x4cc0e15200000000, - 0x3f4bda6a00000000, 0xd1cfe3cb00000000, 0xdcd26c2600000000, - 0x3256558700000000, 0x41dd6ebf00000000, 0xaf59571e00000000, - 0xa7cb19cf00000000, 0x494f206e00000000, 0x3ac41b5600000000, - 0xd44022f700000000, 0x6be6f72f00000000, 0x8562ce8e00000000, - 0xf6e9f5b600000000, 0x186dcc1700000000, 0x10ff82c600000000, - 0xfe7bbb6700000000, 0x8df0805f00000000, 0x6374b9fe00000000, - 0xb2bb5a3500000000, 0x5c3f639400000000, 0x2fb458ac00000000, - 0xc130610d00000000, 0xc9a22fdc00000000, 0x2726167d00000000, - 0x54ad2d4500000000, 0xba2914e400000000, 0x058fc13c00000000, - 0xeb0bf89d00000000, 0x9880c3a500000000, 0x7604fa0400000000, - 0x7e96b4d500000000, 0x90128d7400000000, 0xe399b64c00000000, - 0x0d1d8fed00000000, 0xb8a5d94c00000000, 0x5621e0ed00000000, - 0x25aadbd500000000, 0xcb2ee27400000000, 0xc3bcaca500000000, - 0x2d38950400000000, 0x5eb3ae3c00000000, 0xb037979d00000000, - 0x0f91424500000000, 0xe1157be400000000, 0x929e40dc00000000, - 0x7c1a797d00000000, 0x748837ac00000000, 0x9a0c0e0d00000000, - 0xe987353500000000, 0x07030c9400000000, 0xd6ccef5f00000000, - 0x3848d6fe00000000, 0x4bc3edc600000000, 0xa547d46700000000, - 0xadd59ab600000000, 0x4351a31700000000, 0x30da982f00000000, - 0xde5ea18e00000000, 0x61f8745600000000, 0x8f7c4df700000000, - 0xfcf776cf00000000, 0x12734f6e00000000, 0x1ae101bf00000000, - 0xf465381e00000000, 0x87ee032600000000, 0x696a3a8700000000, - 0x6477b56a00000000, 0x8af38ccb00000000, 0xf978b7f300000000, - 0x17fc8e5200000000, 0x1f6ec08300000000, 0xf1eaf92200000000, - 0x8261c21a00000000, 0x6ce5fbbb00000000, 0xd3432e6300000000, - 0x3dc717c200000000, 0x4e4c2cfa00000000, 0xa0c8155b00000000, - 0xa85a5b8a00000000, 0x46de622b00000000, 0x3555591300000000, - 0xdbd160b200000000, 0x0a1e837900000000, 0xe49abad800000000, - 0x971181e000000000, 0x7995b84100000000, 0x7107f69000000000, - 0x9f83cf3100000000, 0xec08f40900000000, 0x028ccda800000000, - 0xbd2a187000000000, 0x53ae21d100000000, 0x20251ae900000000, - 0xcea1234800000000, 0xc6336d9900000000, 0x28b7543800000000, - 0x5b3c6f0000000000, 0xb5b856a100000000, 0x704bb39900000000, - 0x9ecf8a3800000000, 0xed44b10000000000, 0x03c088a100000000, - 0x0b52c67000000000, 0xe5d6ffd100000000, 0x965dc4e900000000, - 0x78d9fd4800000000, 0xc77f289000000000, 0x29fb113100000000, - 0x5a702a0900000000, 0xb4f413a800000000, 0xbc665d7900000000, - 0x52e264d800000000, 0x21695fe000000000, 0xcfed664100000000, - 0x1e22858a00000000, 0xf0a6bc2b00000000, 0x832d871300000000, - 0x6da9beb200000000, 0x653bf06300000000, 0x8bbfc9c200000000, - 0xf834f2fa00000000, 0x16b0cb5b00000000, 0xa9161e8300000000, - 0x4792272200000000, 0x34191c1a00000000, 0xda9d25bb00000000, - 0xd20f6b6a00000000, 0x3c8b52cb00000000, 0x4f0069f300000000, - 0xa184505200000000, 0xac99dfbf00000000, 0x421de61e00000000, - 0x3196dd2600000000, 0xdf12e48700000000, 0xd780aa5600000000, - 0x390493f700000000, 0x4a8fa8cf00000000, 0xa40b916e00000000, - 0x1bad44b600000000, 0xf5297d1700000000, 0x86a2462f00000000, - 0x68267f8e00000000, 0x60b4315f00000000, 0x8e3008fe00000000, - 0xfdbb33c600000000, 0x133f0a6700000000, 0xc2f0e9ac00000000, - 0x2c74d00d00000000, 0x5fffeb3500000000, 0xb17bd29400000000, - 0xb9e99c4500000000, 0x576da5e400000000, 0x24e69edc00000000, - 0xca62a77d00000000, 0x75c472a500000000, 0x9b404b0400000000, - 0xe8cb703c00000000, 0x064f499d00000000, 0x0edd074c00000000, - 0xe0593eed00000000, 0x93d205d500000000, 0x7d563c7400000000, - 0xc8ee6ad500000000, 0x266a537400000000, 0x55e1684c00000000, - 0xbb6551ed00000000, 0xb3f71f3c00000000, 0x5d73269d00000000, - 0x2ef81da500000000, 0xc07c240400000000, 0x7fdaf1dc00000000, - 0x915ec87d00000000, 0xe2d5f34500000000, 0x0c51cae400000000, - 0x04c3843500000000, 0xea47bd9400000000, 0x99cc86ac00000000, - 0x7748bf0d00000000, 0xa6875cc600000000, 0x4803656700000000, - 0x3b885e5f00000000, 0xd50c67fe00000000, 0xdd9e292f00000000, - 0x331a108e00000000, 0x40912bb600000000, 0xae15121700000000, - 0x11b3c7cf00000000, 0xff37fe6e00000000, 0x8cbcc55600000000, - 0x6238fcf700000000, 0x6aaab22600000000, 0x842e8b8700000000, - 0xf7a5b0bf00000000, 0x1921891e00000000, 0x143c06f300000000, - 0xfab83f5200000000, 0x8933046a00000000, 0x67b73dcb00000000, - 0x6f25731a00000000, 0x81a14abb00000000, 0xf22a718300000000, - 0x1cae482200000000, 0xa3089dfa00000000, 0x4d8ca45b00000000, - 0x3e079f6300000000, 0xd083a6c200000000, 0xd811e81300000000, - 0x3695d1b200000000, 0x451eea8a00000000, 0xab9ad32b00000000, - 0x7a5530e000000000, 0x94d1094100000000, 0xe75a327900000000, - 0x09de0bd800000000, 0x014c450900000000, 0xefc87ca800000000, - 0x9c43479000000000, 0x72c77e3100000000, 0xcd61abe900000000, - 0x23e5924800000000, 0x506ea97000000000, 0xbeea90d100000000, - 0xb678de0000000000, 0x58fce7a100000000, 0x2b77dc9900000000, - 0xc5f3e53800000000}, - {0x0000000000000000, 0xfbf6134700000000, 0xf6ed278e00000000, - 0x0d1b34c900000000, 0xaddd3ec700000000, 0x562b2d8000000000, - 0x5b30194900000000, 0xa0c60a0e00000000, 0x1bbd0c5500000000, - 0xe04b1f1200000000, 0xed502bdb00000000, 0x16a6389c00000000, - 0xb660329200000000, 0x4d9621d500000000, 0x408d151c00000000, - 0xbb7b065b00000000, 0x367a19aa00000000, 0xcd8c0aed00000000, - 0xc0973e2400000000, 0x3b612d6300000000, 0x9ba7276d00000000, - 0x6051342a00000000, 0x6d4a00e300000000, 0x96bc13a400000000, - 0x2dc715ff00000000, 0xd63106b800000000, 0xdb2a327100000000, - 0x20dc213600000000, 0x801a2b3800000000, 0x7bec387f00000000, - 0x76f70cb600000000, 0x8d011ff100000000, 0x2df2438f00000000, - 0xd60450c800000000, 0xdb1f640100000000, 0x20e9774600000000, - 0x802f7d4800000000, 0x7bd96e0f00000000, 0x76c25ac600000000, - 0x8d34498100000000, 0x364f4fda00000000, 0xcdb95c9d00000000, - 0xc0a2685400000000, 0x3b547b1300000000, 0x9b92711d00000000, - 0x6064625a00000000, 0x6d7f569300000000, 0x968945d400000000, - 0x1b885a2500000000, 0xe07e496200000000, 0xed657dab00000000, - 0x16936eec00000000, 0xb65564e200000000, 0x4da377a500000000, - 0x40b8436c00000000, 0xbb4e502b00000000, 0x0035567000000000, - 0xfbc3453700000000, 0xf6d871fe00000000, 0x0d2e62b900000000, - 0xade868b700000000, 0x561e7bf000000000, 0x5b054f3900000000, - 0xa0f35c7e00000000, 0x1be2f6c500000000, 0xe014e58200000000, - 0xed0fd14b00000000, 0x16f9c20c00000000, 0xb63fc80200000000, - 0x4dc9db4500000000, 0x40d2ef8c00000000, 0xbb24fccb00000000, - 0x005ffa9000000000, 0xfba9e9d700000000, 0xf6b2dd1e00000000, - 0x0d44ce5900000000, 0xad82c45700000000, 0x5674d71000000000, - 0x5b6fe3d900000000, 0xa099f09e00000000, 0x2d98ef6f00000000, - 0xd66efc2800000000, 0xdb75c8e100000000, 0x2083dba600000000, - 0x8045d1a800000000, 0x7bb3c2ef00000000, 0x76a8f62600000000, - 0x8d5ee56100000000, 0x3625e33a00000000, 0xcdd3f07d00000000, - 0xc0c8c4b400000000, 0x3b3ed7f300000000, 0x9bf8ddfd00000000, - 0x600eceba00000000, 0x6d15fa7300000000, 0x96e3e93400000000, - 0x3610b54a00000000, 0xcde6a60d00000000, 0xc0fd92c400000000, - 0x3b0b818300000000, 0x9bcd8b8d00000000, 0x603b98ca00000000, - 0x6d20ac0300000000, 0x96d6bf4400000000, 0x2dadb91f00000000, - 0xd65baa5800000000, 0xdb409e9100000000, 0x20b68dd600000000, - 0x807087d800000000, 0x7b86949f00000000, 0x769da05600000000, - 0x8d6bb31100000000, 0x006aace000000000, 0xfb9cbfa700000000, - 0xf6878b6e00000000, 0x0d71982900000000, 0xadb7922700000000, - 0x5641816000000000, 0x5b5ab5a900000000, 0xa0aca6ee00000000, - 0x1bd7a0b500000000, 0xe021b3f200000000, 0xed3a873b00000000, - 0x16cc947c00000000, 0xb60a9e7200000000, 0x4dfc8d3500000000, - 0x40e7b9fc00000000, 0xbb11aabb00000000, 0x77c29c5000000000, - 0x8c348f1700000000, 0x812fbbde00000000, 0x7ad9a89900000000, - 0xda1fa29700000000, 0x21e9b1d000000000, 0x2cf2851900000000, - 0xd704965e00000000, 0x6c7f900500000000, 0x9789834200000000, - 0x9a92b78b00000000, 0x6164a4cc00000000, 0xc1a2aec200000000, - 0x3a54bd8500000000, 0x374f894c00000000, 0xccb99a0b00000000, - 0x41b885fa00000000, 0xba4e96bd00000000, 0xb755a27400000000, - 0x4ca3b13300000000, 0xec65bb3d00000000, 0x1793a87a00000000, - 0x1a889cb300000000, 0xe17e8ff400000000, 0x5a0589af00000000, - 0xa1f39ae800000000, 0xace8ae2100000000, 0x571ebd6600000000, - 0xf7d8b76800000000, 0x0c2ea42f00000000, 0x013590e600000000, - 0xfac383a100000000, 0x5a30dfdf00000000, 0xa1c6cc9800000000, - 0xacddf85100000000, 0x572beb1600000000, 0xf7ede11800000000, - 0x0c1bf25f00000000, 0x0100c69600000000, 0xfaf6d5d100000000, - 0x418dd38a00000000, 0xba7bc0cd00000000, 0xb760f40400000000, - 0x4c96e74300000000, 0xec50ed4d00000000, 0x17a6fe0a00000000, - 0x1abdcac300000000, 0xe14bd98400000000, 0x6c4ac67500000000, - 0x97bcd53200000000, 0x9aa7e1fb00000000, 0x6151f2bc00000000, - 0xc197f8b200000000, 0x3a61ebf500000000, 0x377adf3c00000000, - 0xcc8ccc7b00000000, 0x77f7ca2000000000, 0x8c01d96700000000, - 0x811aedae00000000, 0x7aecfee900000000, 0xda2af4e700000000, - 0x21dce7a000000000, 0x2cc7d36900000000, 0xd731c02e00000000, - 0x6c206a9500000000, 0x97d679d200000000, 0x9acd4d1b00000000, - 0x613b5e5c00000000, 0xc1fd545200000000, 0x3a0b471500000000, - 0x371073dc00000000, 0xcce6609b00000000, 0x779d66c000000000, - 0x8c6b758700000000, 0x8170414e00000000, 0x7a86520900000000, - 0xda40580700000000, 0x21b64b4000000000, 0x2cad7f8900000000, - 0xd75b6cce00000000, 0x5a5a733f00000000, 0xa1ac607800000000, - 0xacb754b100000000, 0x574147f600000000, 0xf7874df800000000, - 0x0c715ebf00000000, 0x016a6a7600000000, 0xfa9c793100000000, - 0x41e77f6a00000000, 0xba116c2d00000000, 0xb70a58e400000000, - 0x4cfc4ba300000000, 0xec3a41ad00000000, 0x17cc52ea00000000, - 0x1ad7662300000000, 0xe121756400000000, 0x41d2291a00000000, - 0xba243a5d00000000, 0xb73f0e9400000000, 0x4cc91dd300000000, - 0xec0f17dd00000000, 0x17f9049a00000000, 0x1ae2305300000000, - 0xe114231400000000, 0x5a6f254f00000000, 0xa199360800000000, - 0xac8202c100000000, 0x5774118600000000, 0xf7b21b8800000000, - 0x0c4408cf00000000, 0x015f3c0600000000, 0xfaa92f4100000000, - 0x77a830b000000000, 0x8c5e23f700000000, 0x8145173e00000000, - 0x7ab3047900000000, 0xda750e7700000000, 0x21831d3000000000, - 0x2c9829f900000000, 0xd76e3abe00000000, 0x6c153ce500000000, - 0x97e32fa200000000, 0x9af81b6b00000000, 0x610e082c00000000, - 0xc1c8022200000000, 0x3a3e116500000000, 0x372525ac00000000, - 0xccd336eb00000000}, - {0x0000000000000000, 0x6238282a00000000, 0xc470505400000000, - 0xa648787e00000000, 0x88e1a0a800000000, 0xead9888200000000, - 0x4c91f0fc00000000, 0x2ea9d8d600000000, 0x51c5308a00000000, - 0x33fd18a000000000, 0x95b560de00000000, 0xf78d48f400000000, - 0xd924902200000000, 0xbb1cb80800000000, 0x1d54c07600000000, - 0x7f6ce85c00000000, 0xe38c10cf00000000, 0x81b438e500000000, - 0x27fc409b00000000, 0x45c468b100000000, 0x6b6db06700000000, - 0x0955984d00000000, 0xaf1de03300000000, 0xcd25c81900000000, - 0xb249204500000000, 0xd071086f00000000, 0x7639701100000000, - 0x1401583b00000000, 0x3aa880ed00000000, 0x5890a8c700000000, - 0xfed8d0b900000000, 0x9ce0f89300000000, 0x871f504500000000, - 0xe527786f00000000, 0x436f001100000000, 0x2157283b00000000, - 0x0ffef0ed00000000, 0x6dc6d8c700000000, 0xcb8ea0b900000000, - 0xa9b6889300000000, 0xd6da60cf00000000, 0xb4e248e500000000, - 0x12aa309b00000000, 0x709218b100000000, 0x5e3bc06700000000, - 0x3c03e84d00000000, 0x9a4b903300000000, 0xf873b81900000000, - 0x6493408a00000000, 0x06ab68a000000000, 0xa0e310de00000000, - 0xc2db38f400000000, 0xec72e02200000000, 0x8e4ac80800000000, - 0x2802b07600000000, 0x4a3a985c00000000, 0x3556700000000000, - 0x576e582a00000000, 0xf126205400000000, 0x931e087e00000000, - 0xbdb7d0a800000000, 0xdf8ff88200000000, 0x79c780fc00000000, - 0x1bffa8d600000000, 0x0e3fa08a00000000, 0x6c0788a000000000, - 0xca4ff0de00000000, 0xa877d8f400000000, 0x86de002200000000, - 0xe4e6280800000000, 0x42ae507600000000, 0x2096785c00000000, - 0x5ffa900000000000, 0x3dc2b82a00000000, 0x9b8ac05400000000, - 0xf9b2e87e00000000, 0xd71b30a800000000, 0xb523188200000000, - 0x136b60fc00000000, 0x715348d600000000, 0xedb3b04500000000, - 0x8f8b986f00000000, 0x29c3e01100000000, 0x4bfbc83b00000000, - 0x655210ed00000000, 0x076a38c700000000, 0xa12240b900000000, - 0xc31a689300000000, 0xbc7680cf00000000, 0xde4ea8e500000000, - 0x7806d09b00000000, 0x1a3ef8b100000000, 0x3497206700000000, - 0x56af084d00000000, 0xf0e7703300000000, 0x92df581900000000, - 0x8920f0cf00000000, 0xeb18d8e500000000, 0x4d50a09b00000000, - 0x2f6888b100000000, 0x01c1506700000000, 0x63f9784d00000000, - 0xc5b1003300000000, 0xa789281900000000, 0xd8e5c04500000000, - 0xbadde86f00000000, 0x1c95901100000000, 0x7eadb83b00000000, - 0x500460ed00000000, 0x323c48c700000000, 0x947430b900000000, - 0xf64c189300000000, 0x6aace00000000000, 0x0894c82a00000000, - 0xaedcb05400000000, 0xcce4987e00000000, 0xe24d40a800000000, - 0x8075688200000000, 0x263d10fc00000000, 0x440538d600000000, - 0x3b69d08a00000000, 0x5951f8a000000000, 0xff1980de00000000, - 0x9d21a8f400000000, 0xb388702200000000, 0xd1b0580800000000, - 0x77f8207600000000, 0x15c0085c00000000, 0x5d7831ce00000000, - 0x3f4019e400000000, 0x9908619a00000000, 0xfb3049b000000000, - 0xd599916600000000, 0xb7a1b94c00000000, 0x11e9c13200000000, - 0x73d1e91800000000, 0x0cbd014400000000, 0x6e85296e00000000, - 0xc8cd511000000000, 0xaaf5793a00000000, 0x845ca1ec00000000, - 0xe66489c600000000, 0x402cf1b800000000, 0x2214d99200000000, - 0xbef4210100000000, 0xdccc092b00000000, 0x7a84715500000000, - 0x18bc597f00000000, 0x361581a900000000, 0x542da98300000000, - 0xf265d1fd00000000, 0x905df9d700000000, 0xef31118b00000000, - 0x8d0939a100000000, 0x2b4141df00000000, 0x497969f500000000, - 0x67d0b12300000000, 0x05e8990900000000, 0xa3a0e17700000000, - 0xc198c95d00000000, 0xda67618b00000000, 0xb85f49a100000000, - 0x1e1731df00000000, 0x7c2f19f500000000, 0x5286c12300000000, - 0x30bee90900000000, 0x96f6917700000000, 0xf4ceb95d00000000, - 0x8ba2510100000000, 0xe99a792b00000000, 0x4fd2015500000000, - 0x2dea297f00000000, 0x0343f1a900000000, 0x617bd98300000000, - 0xc733a1fd00000000, 0xa50b89d700000000, 0x39eb714400000000, - 0x5bd3596e00000000, 0xfd9b211000000000, 0x9fa3093a00000000, - 0xb10ad1ec00000000, 0xd332f9c600000000, 0x757a81b800000000, - 0x1742a99200000000, 0x682e41ce00000000, 0x0a1669e400000000, - 0xac5e119a00000000, 0xce6639b000000000, 0xe0cfe16600000000, - 0x82f7c94c00000000, 0x24bfb13200000000, 0x4687991800000000, - 0x5347914400000000, 0x317fb96e00000000, 0x9737c11000000000, - 0xf50fe93a00000000, 0xdba631ec00000000, 0xb99e19c600000000, - 0x1fd661b800000000, 0x7dee499200000000, 0x0282a1ce00000000, - 0x60ba89e400000000, 0xc6f2f19a00000000, 0xa4cad9b000000000, - 0x8a63016600000000, 0xe85b294c00000000, 0x4e13513200000000, - 0x2c2b791800000000, 0xb0cb818b00000000, 0xd2f3a9a100000000, - 0x74bbd1df00000000, 0x1683f9f500000000, 0x382a212300000000, - 0x5a12090900000000, 0xfc5a717700000000, 0x9e62595d00000000, - 0xe10eb10100000000, 0x8336992b00000000, 0x257ee15500000000, - 0x4746c97f00000000, 0x69ef11a900000000, 0x0bd7398300000000, - 0xad9f41fd00000000, 0xcfa769d700000000, 0xd458c10100000000, - 0xb660e92b00000000, 0x1028915500000000, 0x7210b97f00000000, - 0x5cb961a900000000, 0x3e81498300000000, 0x98c931fd00000000, - 0xfaf119d700000000, 0x859df18b00000000, 0xe7a5d9a100000000, - 0x41eda1df00000000, 0x23d589f500000000, 0x0d7c512300000000, - 0x6f44790900000000, 0xc90c017700000000, 0xab34295d00000000, - 0x37d4d1ce00000000, 0x55ecf9e400000000, 0xf3a4819a00000000, - 0x919ca9b000000000, 0xbf35716600000000, 0xdd0d594c00000000, - 0x7b45213200000000, 0x197d091800000000, 0x6611e14400000000, - 0x0429c96e00000000, 0xa261b11000000000, 0xc059993a00000000, - 0xeef041ec00000000, 0x8cc869c600000000, 0x2a8011b800000000, - 0x48b8399200000000}, - {0x0000000000000000, 0x4c2896a300000000, 0xd9565d9c00000000, - 0x957ecb3f00000000, 0xf3abcbe300000000, 0xbf835d4000000000, - 0x2afd967f00000000, 0x66d500dc00000000, 0xa751e61c00000000, - 0xeb7970bf00000000, 0x7e07bb8000000000, 0x322f2d2300000000, - 0x54fa2dff00000000, 0x18d2bb5c00000000, 0x8dac706300000000, - 0xc184e6c000000000, 0x4ea3cc3900000000, 0x028b5a9a00000000, - 0x97f591a500000000, 0xdbdd070600000000, 0xbd0807da00000000, - 0xf120917900000000, 0x645e5a4600000000, 0x2876cce500000000, - 0xe9f22a2500000000, 0xa5dabc8600000000, 0x30a477b900000000, - 0x7c8ce11a00000000, 0x1a59e1c600000000, 0x5671776500000000, - 0xc30fbc5a00000000, 0x8f272af900000000, 0x9c46997300000000, - 0xd06e0fd000000000, 0x4510c4ef00000000, 0x0938524c00000000, - 0x6fed529000000000, 0x23c5c43300000000, 0xb6bb0f0c00000000, - 0xfa9399af00000000, 0x3b177f6f00000000, 0x773fe9cc00000000, - 0xe24122f300000000, 0xae69b45000000000, 0xc8bcb48c00000000, - 0x8494222f00000000, 0x11eae91000000000, 0x5dc27fb300000000, - 0xd2e5554a00000000, 0x9ecdc3e900000000, 0x0bb308d600000000, - 0x479b9e7500000000, 0x214e9ea900000000, 0x6d66080a00000000, - 0xf818c33500000000, 0xb430559600000000, 0x75b4b35600000000, - 0x399c25f500000000, 0xace2eeca00000000, 0xe0ca786900000000, - 0x861f78b500000000, 0xca37ee1600000000, 0x5f49252900000000, - 0x1361b38a00000000, 0x388d32e700000000, 0x74a5a44400000000, - 0xe1db6f7b00000000, 0xadf3f9d800000000, 0xcb26f90400000000, - 0x870e6fa700000000, 0x1270a49800000000, 0x5e58323b00000000, - 0x9fdcd4fb00000000, 0xd3f4425800000000, 0x468a896700000000, - 0x0aa21fc400000000, 0x6c771f1800000000, 0x205f89bb00000000, - 0xb521428400000000, 0xf909d42700000000, 0x762efede00000000, - 0x3a06687d00000000, 0xaf78a34200000000, 0xe35035e100000000, - 0x8585353d00000000, 0xc9ada39e00000000, 0x5cd368a100000000, - 0x10fbfe0200000000, 0xd17f18c200000000, 0x9d578e6100000000, - 0x0829455e00000000, 0x4401d3fd00000000, 0x22d4d32100000000, - 0x6efc458200000000, 0xfb828ebd00000000, 0xb7aa181e00000000, - 0xa4cbab9400000000, 0xe8e33d3700000000, 0x7d9df60800000000, - 0x31b560ab00000000, 0x5760607700000000, 0x1b48f6d400000000, - 0x8e363deb00000000, 0xc21eab4800000000, 0x039a4d8800000000, - 0x4fb2db2b00000000, 0xdacc101400000000, 0x96e486b700000000, - 0xf031866b00000000, 0xbc1910c800000000, 0x2967dbf700000000, - 0x654f4d5400000000, 0xea6867ad00000000, 0xa640f10e00000000, - 0x333e3a3100000000, 0x7f16ac9200000000, 0x19c3ac4e00000000, - 0x55eb3aed00000000, 0xc095f1d200000000, 0x8cbd677100000000, - 0x4d3981b100000000, 0x0111171200000000, 0x946fdc2d00000000, - 0xd8474a8e00000000, 0xbe924a5200000000, 0xf2badcf100000000, - 0x67c417ce00000000, 0x2bec816d00000000, 0x311c141500000000, - 0x7d3482b600000000, 0xe84a498900000000, 0xa462df2a00000000, - 0xc2b7dff600000000, 0x8e9f495500000000, 0x1be1826a00000000, - 0x57c914c900000000, 0x964df20900000000, 0xda6564aa00000000, - 0x4f1baf9500000000, 0x0333393600000000, 0x65e639ea00000000, - 0x29ceaf4900000000, 0xbcb0647600000000, 0xf098f2d500000000, - 0x7fbfd82c00000000, 0x33974e8f00000000, 0xa6e985b000000000, - 0xeac1131300000000, 0x8c1413cf00000000, 0xc03c856c00000000, - 0x55424e5300000000, 0x196ad8f000000000, 0xd8ee3e3000000000, - 0x94c6a89300000000, 0x01b863ac00000000, 0x4d90f50f00000000, - 0x2b45f5d300000000, 0x676d637000000000, 0xf213a84f00000000, - 0xbe3b3eec00000000, 0xad5a8d6600000000, 0xe1721bc500000000, - 0x740cd0fa00000000, 0x3824465900000000, 0x5ef1468500000000, - 0x12d9d02600000000, 0x87a71b1900000000, 0xcb8f8dba00000000, - 0x0a0b6b7a00000000, 0x4623fdd900000000, 0xd35d36e600000000, - 0x9f75a04500000000, 0xf9a0a09900000000, 0xb588363a00000000, - 0x20f6fd0500000000, 0x6cde6ba600000000, 0xe3f9415f00000000, - 0xafd1d7fc00000000, 0x3aaf1cc300000000, 0x76878a6000000000, - 0x10528abc00000000, 0x5c7a1c1f00000000, 0xc904d72000000000, - 0x852c418300000000, 0x44a8a74300000000, 0x088031e000000000, - 0x9dfefadf00000000, 0xd1d66c7c00000000, 0xb7036ca000000000, - 0xfb2bfa0300000000, 0x6e55313c00000000, 0x227da79f00000000, - 0x099126f200000000, 0x45b9b05100000000, 0xd0c77b6e00000000, - 0x9cefedcd00000000, 0xfa3aed1100000000, 0xb6127bb200000000, - 0x236cb08d00000000, 0x6f44262e00000000, 0xaec0c0ee00000000, - 0xe2e8564d00000000, 0x77969d7200000000, 0x3bbe0bd100000000, - 0x5d6b0b0d00000000, 0x11439dae00000000, 0x843d569100000000, - 0xc815c03200000000, 0x4732eacb00000000, 0x0b1a7c6800000000, - 0x9e64b75700000000, 0xd24c21f400000000, 0xb499212800000000, - 0xf8b1b78b00000000, 0x6dcf7cb400000000, 0x21e7ea1700000000, - 0xe0630cd700000000, 0xac4b9a7400000000, 0x3935514b00000000, - 0x751dc7e800000000, 0x13c8c73400000000, 0x5fe0519700000000, - 0xca9e9aa800000000, 0x86b60c0b00000000, 0x95d7bf8100000000, - 0xd9ff292200000000, 0x4c81e21d00000000, 0x00a974be00000000, - 0x667c746200000000, 0x2a54e2c100000000, 0xbf2a29fe00000000, - 0xf302bf5d00000000, 0x3286599d00000000, 0x7eaecf3e00000000, - 0xebd0040100000000, 0xa7f892a200000000, 0xc12d927e00000000, - 0x8d0504dd00000000, 0x187bcfe200000000, 0x5453594100000000, - 0xdb7473b800000000, 0x975ce51b00000000, 0x02222e2400000000, - 0x4e0ab88700000000, 0x28dfb85b00000000, 0x64f72ef800000000, - 0xf189e5c700000000, 0xbda1736400000000, 0x7c2595a400000000, - 0x300d030700000000, 0xa573c83800000000, 0xe95b5e9b00000000, - 0x8f8e5e4700000000, 0xc3a6c8e400000000, 0x56d803db00000000, - 0x1af0957800000000}, - {0x0000000000000000, 0x939bc97f00000000, 0x263793ff00000000, - 0xb5ac5a8000000000, 0x0d68572400000000, 0x9ef39e5b00000000, - 0x2b5fc4db00000000, 0xb8c40da400000000, 0x1ad0ae4800000000, - 0x894b673700000000, 0x3ce73db700000000, 0xaf7cf4c800000000, - 0x17b8f96c00000000, 0x8423301300000000, 0x318f6a9300000000, - 0xa214a3ec00000000, 0x34a05d9100000000, 0xa73b94ee00000000, - 0x1297ce6e00000000, 0x810c071100000000, 0x39c80ab500000000, - 0xaa53c3ca00000000, 0x1fff994a00000000, 0x8c64503500000000, - 0x2e70f3d900000000, 0xbdeb3aa600000000, 0x0847602600000000, - 0x9bdca95900000000, 0x2318a4fd00000000, 0xb0836d8200000000, - 0x052f370200000000, 0x96b4fe7d00000000, 0x2946caf900000000, - 0xbadd038600000000, 0x0f71590600000000, 0x9cea907900000000, - 0x242e9ddd00000000, 0xb7b554a200000000, 0x02190e2200000000, - 0x9182c75d00000000, 0x339664b100000000, 0xa00dadce00000000, - 0x15a1f74e00000000, 0x863a3e3100000000, 0x3efe339500000000, - 0xad65faea00000000, 0x18c9a06a00000000, 0x8b52691500000000, - 0x1de6976800000000, 0x8e7d5e1700000000, 0x3bd1049700000000, - 0xa84acde800000000, 0x108ec04c00000000, 0x8315093300000000, - 0x36b953b300000000, 0xa5229acc00000000, 0x0736392000000000, - 0x94adf05f00000000, 0x2101aadf00000000, 0xb29a63a000000000, - 0x0a5e6e0400000000, 0x99c5a77b00000000, 0x2c69fdfb00000000, - 0xbff2348400000000, 0x138ae52800000000, 0x80112c5700000000, - 0x35bd76d700000000, 0xa626bfa800000000, 0x1ee2b20c00000000, - 0x8d797b7300000000, 0x38d521f300000000, 0xab4ee88c00000000, - 0x095a4b6000000000, 0x9ac1821f00000000, 0x2f6dd89f00000000, - 0xbcf611e000000000, 0x04321c4400000000, 0x97a9d53b00000000, - 0x22058fbb00000000, 0xb19e46c400000000, 0x272ab8b900000000, - 0xb4b171c600000000, 0x011d2b4600000000, 0x9286e23900000000, - 0x2a42ef9d00000000, 0xb9d926e200000000, 0x0c757c6200000000, - 0x9feeb51d00000000, 0x3dfa16f100000000, 0xae61df8e00000000, - 0x1bcd850e00000000, 0x88564c7100000000, 0x309241d500000000, - 0xa30988aa00000000, 0x16a5d22a00000000, 0x853e1b5500000000, - 0x3acc2fd100000000, 0xa957e6ae00000000, 0x1cfbbc2e00000000, - 0x8f60755100000000, 0x37a478f500000000, 0xa43fb18a00000000, - 0x1193eb0a00000000, 0x8208227500000000, 0x201c819900000000, - 0xb38748e600000000, 0x062b126600000000, 0x95b0db1900000000, - 0x2d74d6bd00000000, 0xbeef1fc200000000, 0x0b43454200000000, - 0x98d88c3d00000000, 0x0e6c724000000000, 0x9df7bb3f00000000, - 0x285be1bf00000000, 0xbbc028c000000000, 0x0304256400000000, - 0x909fec1b00000000, 0x2533b69b00000000, 0xb6a87fe400000000, - 0x14bcdc0800000000, 0x8727157700000000, 0x328b4ff700000000, - 0xa110868800000000, 0x19d48b2c00000000, 0x8a4f425300000000, - 0x3fe318d300000000, 0xac78d1ac00000000, 0x2614cb5100000000, - 0xb58f022e00000000, 0x002358ae00000000, 0x93b891d100000000, - 0x2b7c9c7500000000, 0xb8e7550a00000000, 0x0d4b0f8a00000000, - 0x9ed0c6f500000000, 0x3cc4651900000000, 0xaf5fac6600000000, - 0x1af3f6e600000000, 0x89683f9900000000, 0x31ac323d00000000, - 0xa237fb4200000000, 0x179ba1c200000000, 0x840068bd00000000, - 0x12b496c000000000, 0x812f5fbf00000000, 0x3483053f00000000, - 0xa718cc4000000000, 0x1fdcc1e400000000, 0x8c47089b00000000, - 0x39eb521b00000000, 0xaa709b6400000000, 0x0864388800000000, - 0x9bfff1f700000000, 0x2e53ab7700000000, 0xbdc8620800000000, - 0x050c6fac00000000, 0x9697a6d300000000, 0x233bfc5300000000, - 0xb0a0352c00000000, 0x0f5201a800000000, 0x9cc9c8d700000000, - 0x2965925700000000, 0xbafe5b2800000000, 0x023a568c00000000, - 0x91a19ff300000000, 0x240dc57300000000, 0xb7960c0c00000000, - 0x1582afe000000000, 0x8619669f00000000, 0x33b53c1f00000000, - 0xa02ef56000000000, 0x18eaf8c400000000, 0x8b7131bb00000000, - 0x3edd6b3b00000000, 0xad46a24400000000, 0x3bf25c3900000000, - 0xa869954600000000, 0x1dc5cfc600000000, 0x8e5e06b900000000, - 0x369a0b1d00000000, 0xa501c26200000000, 0x10ad98e200000000, - 0x8336519d00000000, 0x2122f27100000000, 0xb2b93b0e00000000, - 0x0715618e00000000, 0x948ea8f100000000, 0x2c4aa55500000000, - 0xbfd16c2a00000000, 0x0a7d36aa00000000, 0x99e6ffd500000000, - 0x359e2e7900000000, 0xa605e70600000000, 0x13a9bd8600000000, - 0x803274f900000000, 0x38f6795d00000000, 0xab6db02200000000, - 0x1ec1eaa200000000, 0x8d5a23dd00000000, 0x2f4e803100000000, - 0xbcd5494e00000000, 0x097913ce00000000, 0x9ae2dab100000000, - 0x2226d71500000000, 0xb1bd1e6a00000000, 0x041144ea00000000, - 0x978a8d9500000000, 0x013e73e800000000, 0x92a5ba9700000000, - 0x2709e01700000000, 0xb492296800000000, 0x0c5624cc00000000, - 0x9fcdedb300000000, 0x2a61b73300000000, 0xb9fa7e4c00000000, - 0x1beedda000000000, 0x887514df00000000, 0x3dd94e5f00000000, - 0xae42872000000000, 0x16868a8400000000, 0x851d43fb00000000, - 0x30b1197b00000000, 0xa32ad00400000000, 0x1cd8e48000000000, - 0x8f432dff00000000, 0x3aef777f00000000, 0xa974be0000000000, - 0x11b0b3a400000000, 0x822b7adb00000000, 0x3787205b00000000, - 0xa41ce92400000000, 0x06084ac800000000, 0x959383b700000000, - 0x203fd93700000000, 0xb3a4104800000000, 0x0b601dec00000000, - 0x98fbd49300000000, 0x2d578e1300000000, 0xbecc476c00000000, - 0x2878b91100000000, 0xbbe3706e00000000, 0x0e4f2aee00000000, - 0x9dd4e39100000000, 0x2510ee3500000000, 0xb68b274a00000000, - 0x03277dca00000000, 0x90bcb4b500000000, 0x32a8175900000000, - 0xa133de2600000000, 0x149f84a600000000, 0x87044dd900000000, - 0x3fc0407d00000000, 0xac5b890200000000, 0x19f7d38200000000, - 0x8a6c1afd00000000}, - {0x0000000000000000, 0x650b796900000000, 0xca16f2d200000000, - 0xaf1d8bbb00000000, 0xd52b957e00000000, 0xb020ec1700000000, - 0x1f3d67ac00000000, 0x7a361ec500000000, 0xaa572afd00000000, - 0xcf5c539400000000, 0x6041d82f00000000, 0x054aa14600000000, - 0x7f7cbf8300000000, 0x1a77c6ea00000000, 0xb56a4d5100000000, - 0xd061343800000000, 0x15a9252100000000, 0x70a25c4800000000, - 0xdfbfd7f300000000, 0xbab4ae9a00000000, 0xc082b05f00000000, - 0xa589c93600000000, 0x0a94428d00000000, 0x6f9f3be400000000, - 0xbffe0fdc00000000, 0xdaf576b500000000, 0x75e8fd0e00000000, - 0x10e3846700000000, 0x6ad59aa200000000, 0x0fdee3cb00000000, - 0xa0c3687000000000, 0xc5c8111900000000, 0x2a524b4200000000, - 0x4f59322b00000000, 0xe044b99000000000, 0x854fc0f900000000, - 0xff79de3c00000000, 0x9a72a75500000000, 0x356f2cee00000000, - 0x5064558700000000, 0x800561bf00000000, 0xe50e18d600000000, - 0x4a13936d00000000, 0x2f18ea0400000000, 0x552ef4c100000000, - 0x30258da800000000, 0x9f38061300000000, 0xfa337f7a00000000, - 0x3ffb6e6300000000, 0x5af0170a00000000, 0xf5ed9cb100000000, - 0x90e6e5d800000000, 0xead0fb1d00000000, 0x8fdb827400000000, - 0x20c609cf00000000, 0x45cd70a600000000, 0x95ac449e00000000, - 0xf0a73df700000000, 0x5fbab64c00000000, 0x3ab1cf2500000000, - 0x4087d1e000000000, 0x258ca88900000000, 0x8a91233200000000, - 0xef9a5a5b00000000, 0x54a4968400000000, 0x31afefed00000000, - 0x9eb2645600000000, 0xfbb91d3f00000000, 0x818f03fa00000000, - 0xe4847a9300000000, 0x4b99f12800000000, 0x2e92884100000000, - 0xfef3bc7900000000, 0x9bf8c51000000000, 0x34e54eab00000000, - 0x51ee37c200000000, 0x2bd8290700000000, 0x4ed3506e00000000, - 0xe1cedbd500000000, 0x84c5a2bc00000000, 0x410db3a500000000, - 0x2406cacc00000000, 0x8b1b417700000000, 0xee10381e00000000, - 0x942626db00000000, 0xf12d5fb200000000, 0x5e30d40900000000, - 0x3b3bad6000000000, 0xeb5a995800000000, 0x8e51e03100000000, - 0x214c6b8a00000000, 0x444712e300000000, 0x3e710c2600000000, - 0x5b7a754f00000000, 0xf467fef400000000, 0x916c879d00000000, - 0x7ef6ddc600000000, 0x1bfda4af00000000, 0xb4e02f1400000000, - 0xd1eb567d00000000, 0xabdd48b800000000, 0xced631d100000000, - 0x61cbba6a00000000, 0x04c0c30300000000, 0xd4a1f73b00000000, - 0xb1aa8e5200000000, 0x1eb705e900000000, 0x7bbc7c8000000000, - 0x018a624500000000, 0x64811b2c00000000, 0xcb9c909700000000, - 0xae97e9fe00000000, 0x6b5ff8e700000000, 0x0e54818e00000000, - 0xa1490a3500000000, 0xc442735c00000000, 0xbe746d9900000000, - 0xdb7f14f000000000, 0x74629f4b00000000, 0x1169e62200000000, - 0xc108d21a00000000, 0xa403ab7300000000, 0x0b1e20c800000000, - 0x6e1559a100000000, 0x1423476400000000, 0x71283e0d00000000, - 0xde35b5b600000000, 0xbb3eccdf00000000, 0xe94e5cd200000000, - 0x8c4525bb00000000, 0x2358ae0000000000, 0x4653d76900000000, - 0x3c65c9ac00000000, 0x596eb0c500000000, 0xf6733b7e00000000, - 0x9378421700000000, 0x4319762f00000000, 0x26120f4600000000, - 0x890f84fd00000000, 0xec04fd9400000000, 0x9632e35100000000, - 0xf3399a3800000000, 0x5c24118300000000, 0x392f68ea00000000, - 0xfce779f300000000, 0x99ec009a00000000, 0x36f18b2100000000, - 0x53faf24800000000, 0x29ccec8d00000000, 0x4cc795e400000000, - 0xe3da1e5f00000000, 0x86d1673600000000, 0x56b0530e00000000, - 0x33bb2a6700000000, 0x9ca6a1dc00000000, 0xf9add8b500000000, - 0x839bc67000000000, 0xe690bf1900000000, 0x498d34a200000000, - 0x2c864dcb00000000, 0xc31c179000000000, 0xa6176ef900000000, - 0x090ae54200000000, 0x6c019c2b00000000, 0x163782ee00000000, - 0x733cfb8700000000, 0xdc21703c00000000, 0xb92a095500000000, - 0x694b3d6d00000000, 0x0c40440400000000, 0xa35dcfbf00000000, - 0xc656b6d600000000, 0xbc60a81300000000, 0xd96bd17a00000000, - 0x76765ac100000000, 0x137d23a800000000, 0xd6b532b100000000, - 0xb3be4bd800000000, 0x1ca3c06300000000, 0x79a8b90a00000000, - 0x039ea7cf00000000, 0x6695dea600000000, 0xc988551d00000000, - 0xac832c7400000000, 0x7ce2184c00000000, 0x19e9612500000000, - 0xb6f4ea9e00000000, 0xd3ff93f700000000, 0xa9c98d3200000000, - 0xccc2f45b00000000, 0x63df7fe000000000, 0x06d4068900000000, - 0xbdeaca5600000000, 0xd8e1b33f00000000, 0x77fc388400000000, - 0x12f741ed00000000, 0x68c15f2800000000, 0x0dca264100000000, - 0xa2d7adfa00000000, 0xc7dcd49300000000, 0x17bde0ab00000000, - 0x72b699c200000000, 0xddab127900000000, 0xb8a06b1000000000, - 0xc29675d500000000, 0xa79d0cbc00000000, 0x0880870700000000, - 0x6d8bfe6e00000000, 0xa843ef7700000000, 0xcd48961e00000000, - 0x62551da500000000, 0x075e64cc00000000, 0x7d687a0900000000, - 0x1863036000000000, 0xb77e88db00000000, 0xd275f1b200000000, - 0x0214c58a00000000, 0x671fbce300000000, 0xc802375800000000, - 0xad094e3100000000, 0xd73f50f400000000, 0xb234299d00000000, - 0x1d29a22600000000, 0x7822db4f00000000, 0x97b8811400000000, - 0xf2b3f87d00000000, 0x5dae73c600000000, 0x38a50aaf00000000, - 0x4293146a00000000, 0x27986d0300000000, 0x8885e6b800000000, - 0xed8e9fd100000000, 0x3defabe900000000, 0x58e4d28000000000, - 0xf7f9593b00000000, 0x92f2205200000000, 0xe8c43e9700000000, - 0x8dcf47fe00000000, 0x22d2cc4500000000, 0x47d9b52c00000000, - 0x8211a43500000000, 0xe71add5c00000000, 0x480756e700000000, - 0x2d0c2f8e00000000, 0x573a314b00000000, 0x3231482200000000, - 0x9d2cc39900000000, 0xf827baf000000000, 0x28468ec800000000, - 0x4d4df7a100000000, 0xe2507c1a00000000, 0x875b057300000000, - 0xfd6d1bb600000000, 0x986662df00000000, 0x377be96400000000, - 0x5270900d00000000}, - {0x0000000000000000, 0xdcecb13d00000000, 0xb8d9637b00000000, - 0x6435d24600000000, 0x70b3c7f600000000, 0xac5f76cb00000000, - 0xc86aa48d00000000, 0x148615b000000000, 0xa160fe3600000000, - 0x7d8c4f0b00000000, 0x19b99d4d00000000, 0xc5552c7000000000, - 0xd1d339c000000000, 0x0d3f88fd00000000, 0x690a5abb00000000, - 0xb5e6eb8600000000, 0x42c1fc6d00000000, 0x9e2d4d5000000000, - 0xfa189f1600000000, 0x26f42e2b00000000, 0x32723b9b00000000, - 0xee9e8aa600000000, 0x8aab58e000000000, 0x5647e9dd00000000, - 0xe3a1025b00000000, 0x3f4db36600000000, 0x5b78612000000000, - 0x8794d01d00000000, 0x9312c5ad00000000, 0x4ffe749000000000, - 0x2bcba6d600000000, 0xf72717eb00000000, 0x8482f9db00000000, - 0x586e48e600000000, 0x3c5b9aa000000000, 0xe0b72b9d00000000, - 0xf4313e2d00000000, 0x28dd8f1000000000, 0x4ce85d5600000000, - 0x9004ec6b00000000, 0x25e207ed00000000, 0xf90eb6d000000000, - 0x9d3b649600000000, 0x41d7d5ab00000000, 0x5551c01b00000000, - 0x89bd712600000000, 0xed88a36000000000, 0x3164125d00000000, - 0xc64305b600000000, 0x1aafb48b00000000, 0x7e9a66cd00000000, - 0xa276d7f000000000, 0xb6f0c24000000000, 0x6a1c737d00000000, - 0x0e29a13b00000000, 0xd2c5100600000000, 0x6723fb8000000000, - 0xbbcf4abd00000000, 0xdffa98fb00000000, 0x031629c600000000, - 0x17903c7600000000, 0xcb7c8d4b00000000, 0xaf495f0d00000000, - 0x73a5ee3000000000, 0x4903826c00000000, 0x95ef335100000000, - 0xf1dae11700000000, 0x2d36502a00000000, 0x39b0459a00000000, - 0xe55cf4a700000000, 0x816926e100000000, 0x5d8597dc00000000, - 0xe8637c5a00000000, 0x348fcd6700000000, 0x50ba1f2100000000, - 0x8c56ae1c00000000, 0x98d0bbac00000000, 0x443c0a9100000000, - 0x2009d8d700000000, 0xfce569ea00000000, 0x0bc27e0100000000, - 0xd72ecf3c00000000, 0xb31b1d7a00000000, 0x6ff7ac4700000000, - 0x7b71b9f700000000, 0xa79d08ca00000000, 0xc3a8da8c00000000, - 0x1f446bb100000000, 0xaaa2803700000000, 0x764e310a00000000, - 0x127be34c00000000, 0xce97527100000000, 0xda1147c100000000, - 0x06fdf6fc00000000, 0x62c824ba00000000, 0xbe24958700000000, - 0xcd817bb700000000, 0x116dca8a00000000, 0x755818cc00000000, - 0xa9b4a9f100000000, 0xbd32bc4100000000, 0x61de0d7c00000000, - 0x05ebdf3a00000000, 0xd9076e0700000000, 0x6ce1858100000000, - 0xb00d34bc00000000, 0xd438e6fa00000000, 0x08d457c700000000, - 0x1c52427700000000, 0xc0bef34a00000000, 0xa48b210c00000000, - 0x7867903100000000, 0x8f4087da00000000, 0x53ac36e700000000, - 0x3799e4a100000000, 0xeb75559c00000000, 0xfff3402c00000000, - 0x231ff11100000000, 0x472a235700000000, 0x9bc6926a00000000, - 0x2e2079ec00000000, 0xf2ccc8d100000000, 0x96f91a9700000000, - 0x4a15abaa00000000, 0x5e93be1a00000000, 0x827f0f2700000000, - 0xe64add6100000000, 0x3aa66c5c00000000, 0x920604d900000000, - 0x4eeab5e400000000, 0x2adf67a200000000, 0xf633d69f00000000, - 0xe2b5c32f00000000, 0x3e59721200000000, 0x5a6ca05400000000, - 0x8680116900000000, 0x3366faef00000000, 0xef8a4bd200000000, - 0x8bbf999400000000, 0x575328a900000000, 0x43d53d1900000000, - 0x9f398c2400000000, 0xfb0c5e6200000000, 0x27e0ef5f00000000, - 0xd0c7f8b400000000, 0x0c2b498900000000, 0x681e9bcf00000000, - 0xb4f22af200000000, 0xa0743f4200000000, 0x7c988e7f00000000, - 0x18ad5c3900000000, 0xc441ed0400000000, 0x71a7068200000000, - 0xad4bb7bf00000000, 0xc97e65f900000000, 0x1592d4c400000000, - 0x0114c17400000000, 0xddf8704900000000, 0xb9cda20f00000000, - 0x6521133200000000, 0x1684fd0200000000, 0xca684c3f00000000, - 0xae5d9e7900000000, 0x72b12f4400000000, 0x66373af400000000, - 0xbadb8bc900000000, 0xdeee598f00000000, 0x0202e8b200000000, - 0xb7e4033400000000, 0x6b08b20900000000, 0x0f3d604f00000000, - 0xd3d1d17200000000, 0xc757c4c200000000, 0x1bbb75ff00000000, - 0x7f8ea7b900000000, 0xa362168400000000, 0x5445016f00000000, - 0x88a9b05200000000, 0xec9c621400000000, 0x3070d32900000000, - 0x24f6c69900000000, 0xf81a77a400000000, 0x9c2fa5e200000000, - 0x40c314df00000000, 0xf525ff5900000000, 0x29c94e6400000000, - 0x4dfc9c2200000000, 0x91102d1f00000000, 0x859638af00000000, - 0x597a899200000000, 0x3d4f5bd400000000, 0xe1a3eae900000000, - 0xdb0586b500000000, 0x07e9378800000000, 0x63dce5ce00000000, - 0xbf3054f300000000, 0xabb6414300000000, 0x775af07e00000000, - 0x136f223800000000, 0xcf83930500000000, 0x7a65788300000000, - 0xa689c9be00000000, 0xc2bc1bf800000000, 0x1e50aac500000000, - 0x0ad6bf7500000000, 0xd63a0e4800000000, 0xb20fdc0e00000000, - 0x6ee36d3300000000, 0x99c47ad800000000, 0x4528cbe500000000, - 0x211d19a300000000, 0xfdf1a89e00000000, 0xe977bd2e00000000, - 0x359b0c1300000000, 0x51aede5500000000, 0x8d426f6800000000, - 0x38a484ee00000000, 0xe44835d300000000, 0x807de79500000000, - 0x5c9156a800000000, 0x4817431800000000, 0x94fbf22500000000, - 0xf0ce206300000000, 0x2c22915e00000000, 0x5f877f6e00000000, - 0x836bce5300000000, 0xe75e1c1500000000, 0x3bb2ad2800000000, - 0x2f34b89800000000, 0xf3d809a500000000, 0x97eddbe300000000, - 0x4b016ade00000000, 0xfee7815800000000, 0x220b306500000000, - 0x463ee22300000000, 0x9ad2531e00000000, 0x8e5446ae00000000, - 0x52b8f79300000000, 0x368d25d500000000, 0xea6194e800000000, - 0x1d46830300000000, 0xc1aa323e00000000, 0xa59fe07800000000, - 0x7973514500000000, 0x6df544f500000000, 0xb119f5c800000000, - 0xd52c278e00000000, 0x09c096b300000000, 0xbc267d3500000000, - 0x60cacc0800000000, 0x04ff1e4e00000000, 0xd813af7300000000, - 0xcc95bac300000000, 0x10790bfe00000000, 0x744cd9b800000000, - 0xa8a0688500000000}}; - -#else /* W == 4 */ - -local const z_crc_t FAR crc_braid_table[][256] = { - {0x00000000, 0x81256527, 0xd93bcc0f, 0x581ea928, 0x69069e5f, - 0xe823fb78, 0xb03d5250, 0x31183777, 0xd20d3cbe, 0x53285999, - 0x0b36f0b1, 0x8a139596, 0xbb0ba2e1, 0x3a2ec7c6, 0x62306eee, - 0xe3150bc9, 0x7f6b7f3d, 0xfe4e1a1a, 0xa650b332, 0x2775d615, - 0x166de162, 0x97488445, 0xcf562d6d, 0x4e73484a, 0xad664383, - 0x2c4326a4, 0x745d8f8c, 0xf578eaab, 0xc460dddc, 0x4545b8fb, - 0x1d5b11d3, 0x9c7e74f4, 0xfed6fe7a, 0x7ff39b5d, 0x27ed3275, - 0xa6c85752, 0x97d06025, 0x16f50502, 0x4eebac2a, 0xcfcec90d, - 0x2cdbc2c4, 0xadfea7e3, 0xf5e00ecb, 0x74c56bec, 0x45dd5c9b, - 0xc4f839bc, 0x9ce69094, 0x1dc3f5b3, 0x81bd8147, 0x0098e460, - 0x58864d48, 0xd9a3286f, 0xe8bb1f18, 0x699e7a3f, 0x3180d317, - 0xb0a5b630, 0x53b0bdf9, 0xd295d8de, 0x8a8b71f6, 0x0bae14d1, - 0x3ab623a6, 0xbb934681, 0xe38defa9, 0x62a88a8e, 0x26dcfab5, - 0xa7f99f92, 0xffe736ba, 0x7ec2539d, 0x4fda64ea, 0xceff01cd, - 0x96e1a8e5, 0x17c4cdc2, 0xf4d1c60b, 0x75f4a32c, 0x2dea0a04, - 0xaccf6f23, 0x9dd75854, 0x1cf23d73, 0x44ec945b, 0xc5c9f17c, - 0x59b78588, 0xd892e0af, 0x808c4987, 0x01a92ca0, 0x30b11bd7, - 0xb1947ef0, 0xe98ad7d8, 0x68afb2ff, 0x8bbab936, 0x0a9fdc11, - 0x52817539, 0xd3a4101e, 0xe2bc2769, 0x6399424e, 0x3b87eb66, - 0xbaa28e41, 0xd80a04cf, 0x592f61e8, 0x0131c8c0, 0x8014ade7, - 0xb10c9a90, 0x3029ffb7, 0x6837569f, 0xe91233b8, 0x0a073871, - 0x8b225d56, 0xd33cf47e, 0x52199159, 0x6301a62e, 0xe224c309, - 0xba3a6a21, 0x3b1f0f06, 0xa7617bf2, 0x26441ed5, 0x7e5ab7fd, - 0xff7fd2da, 0xce67e5ad, 0x4f42808a, 0x175c29a2, 0x96794c85, - 0x756c474c, 0xf449226b, 0xac578b43, 0x2d72ee64, 0x1c6ad913, - 0x9d4fbc34, 0xc551151c, 0x4474703b, 0x4db9f56a, 0xcc9c904d, - 0x94823965, 0x15a75c42, 0x24bf6b35, 0xa59a0e12, 0xfd84a73a, - 0x7ca1c21d, 0x9fb4c9d4, 0x1e91acf3, 0x468f05db, 0xc7aa60fc, - 0xf6b2578b, 0x779732ac, 0x2f899b84, 0xaeacfea3, 0x32d28a57, - 0xb3f7ef70, 0xebe94658, 0x6acc237f, 0x5bd41408, 0xdaf1712f, - 0x82efd807, 0x03cabd20, 0xe0dfb6e9, 0x61fad3ce, 0x39e47ae6, - 0xb8c11fc1, 0x89d928b6, 0x08fc4d91, 0x50e2e4b9, 0xd1c7819e, - 0xb36f0b10, 0x324a6e37, 0x6a54c71f, 0xeb71a238, 0xda69954f, - 0x5b4cf068, 0x03525940, 0x82773c67, 0x616237ae, 0xe0475289, - 0xb859fba1, 0x397c9e86, 0x0864a9f1, 0x8941ccd6, 0xd15f65fe, - 0x507a00d9, 0xcc04742d, 0x4d21110a, 0x153fb822, 0x941add05, - 0xa502ea72, 0x24278f55, 0x7c39267d, 0xfd1c435a, 0x1e094893, - 0x9f2c2db4, 0xc732849c, 0x4617e1bb, 0x770fd6cc, 0xf62ab3eb, - 0xae341ac3, 0x2f117fe4, 0x6b650fdf, 0xea406af8, 0xb25ec3d0, - 0x337ba6f7, 0x02639180, 0x8346f4a7, 0xdb585d8f, 0x5a7d38a8, - 0xb9683361, 0x384d5646, 0x6053ff6e, 0xe1769a49, 0xd06ead3e, - 0x514bc819, 0x09556131, 0x88700416, 0x140e70e2, 0x952b15c5, - 0xcd35bced, 0x4c10d9ca, 0x7d08eebd, 0xfc2d8b9a, 0xa43322b2, - 0x25164795, 0xc6034c5c, 0x4726297b, 0x1f388053, 0x9e1de574, - 0xaf05d203, 0x2e20b724, 0x763e1e0c, 0xf71b7b2b, 0x95b3f1a5, - 0x14969482, 0x4c883daa, 0xcdad588d, 0xfcb56ffa, 0x7d900add, - 0x258ea3f5, 0xa4abc6d2, 0x47becd1b, 0xc69ba83c, 0x9e850114, - 0x1fa06433, 0x2eb85344, 0xaf9d3663, 0xf7839f4b, 0x76a6fa6c, - 0xead88e98, 0x6bfdebbf, 0x33e34297, 0xb2c627b0, 0x83de10c7, - 0x02fb75e0, 0x5ae5dcc8, 0xdbc0b9ef, 0x38d5b226, 0xb9f0d701, - 0xe1ee7e29, 0x60cb1b0e, 0x51d32c79, 0xd0f6495e, 0x88e8e076, - 0x09cd8551}, - {0x00000000, 0x9b73ead4, 0xed96d3e9, 0x76e5393d, 0x005ca193, - 0x9b2f4b47, 0xedca727a, 0x76b998ae, 0x00b94326, 0x9bcaa9f2, - 0xed2f90cf, 0x765c7a1b, 0x00e5e2b5, 0x9b960861, 0xed73315c, - 0x7600db88, 0x0172864c, 0x9a016c98, 0xece455a5, 0x7797bf71, - 0x012e27df, 0x9a5dcd0b, 0xecb8f436, 0x77cb1ee2, 0x01cbc56a, - 0x9ab82fbe, 0xec5d1683, 0x772efc57, 0x019764f9, 0x9ae48e2d, - 0xec01b710, 0x77725dc4, 0x02e50c98, 0x9996e64c, 0xef73df71, - 0x740035a5, 0x02b9ad0b, 0x99ca47df, 0xef2f7ee2, 0x745c9436, - 0x025c4fbe, 0x992fa56a, 0xefca9c57, 0x74b97683, 0x0200ee2d, - 0x997304f9, 0xef963dc4, 0x74e5d710, 0x03978ad4, 0x98e46000, - 0xee01593d, 0x7572b3e9, 0x03cb2b47, 0x98b8c193, 0xee5df8ae, - 0x752e127a, 0x032ec9f2, 0x985d2326, 0xeeb81a1b, 0x75cbf0cf, - 0x03726861, 0x980182b5, 0xeee4bb88, 0x7597515c, 0x05ca1930, - 0x9eb9f3e4, 0xe85ccad9, 0x732f200d, 0x0596b8a3, 0x9ee55277, - 0xe8006b4a, 0x7373819e, 0x05735a16, 0x9e00b0c2, 0xe8e589ff, - 0x7396632b, 0x052ffb85, 0x9e5c1151, 0xe8b9286c, 0x73cac2b8, - 0x04b89f7c, 0x9fcb75a8, 0xe92e4c95, 0x725da641, 0x04e43eef, - 0x9f97d43b, 0xe972ed06, 0x720107d2, 0x0401dc5a, 0x9f72368e, - 0xe9970fb3, 0x72e4e567, 0x045d7dc9, 0x9f2e971d, 0xe9cbae20, - 0x72b844f4, 0x072f15a8, 0x9c5cff7c, 0xeab9c641, 0x71ca2c95, - 0x0773b43b, 0x9c005eef, 0xeae567d2, 0x71968d06, 0x0796568e, - 0x9ce5bc5a, 0xea008567, 0x71736fb3, 0x07caf71d, 0x9cb91dc9, - 0xea5c24f4, 0x712fce20, 0x065d93e4, 0x9d2e7930, 0xebcb400d, - 0x70b8aad9, 0x06013277, 0x9d72d8a3, 0xeb97e19e, 0x70e40b4a, - 0x06e4d0c2, 0x9d973a16, 0xeb72032b, 0x7001e9ff, 0x06b87151, - 0x9dcb9b85, 0xeb2ea2b8, 0x705d486c, 0x0b943260, 0x90e7d8b4, - 0xe602e189, 0x7d710b5d, 0x0bc893f3, 0x90bb7927, 0xe65e401a, - 0x7d2daace, 0x0b2d7146, 0x905e9b92, 0xe6bba2af, 0x7dc8487b, - 0x0b71d0d5, 0x90023a01, 0xe6e7033c, 0x7d94e9e8, 0x0ae6b42c, - 0x91955ef8, 0xe77067c5, 0x7c038d11, 0x0aba15bf, 0x91c9ff6b, - 0xe72cc656, 0x7c5f2c82, 0x0a5ff70a, 0x912c1dde, 0xe7c924e3, - 0x7cbace37, 0x0a035699, 0x9170bc4d, 0xe7958570, 0x7ce66fa4, - 0x09713ef8, 0x9202d42c, 0xe4e7ed11, 0x7f9407c5, 0x092d9f6b, - 0x925e75bf, 0xe4bb4c82, 0x7fc8a656, 0x09c87dde, 0x92bb970a, - 0xe45eae37, 0x7f2d44e3, 0x0994dc4d, 0x92e73699, 0xe4020fa4, - 0x7f71e570, 0x0803b8b4, 0x93705260, 0xe5956b5d, 0x7ee68189, - 0x085f1927, 0x932cf3f3, 0xe5c9cace, 0x7eba201a, 0x08bafb92, - 0x93c91146, 0xe52c287b, 0x7e5fc2af, 0x08e65a01, 0x9395b0d5, - 0xe57089e8, 0x7e03633c, 0x0e5e2b50, 0x952dc184, 0xe3c8f8b9, - 0x78bb126d, 0x0e028ac3, 0x95716017, 0xe394592a, 0x78e7b3fe, - 0x0ee76876, 0x959482a2, 0xe371bb9f, 0x7802514b, 0x0ebbc9e5, - 0x95c82331, 0xe32d1a0c, 0x785ef0d8, 0x0f2cad1c, 0x945f47c8, - 0xe2ba7ef5, 0x79c99421, 0x0f700c8f, 0x9403e65b, 0xe2e6df66, - 0x799535b2, 0x0f95ee3a, 0x94e604ee, 0xe2033dd3, 0x7970d707, - 0x0fc94fa9, 0x94baa57d, 0xe25f9c40, 0x792c7694, 0x0cbb27c8, - 0x97c8cd1c, 0xe12df421, 0x7a5e1ef5, 0x0ce7865b, 0x97946c8f, - 0xe17155b2, 0x7a02bf66, 0x0c0264ee, 0x97718e3a, 0xe194b707, - 0x7ae75dd3, 0x0c5ec57d, 0x972d2fa9, 0xe1c81694, 0x7abbfc40, - 0x0dc9a184, 0x96ba4b50, 0xe05f726d, 0x7b2c98b9, 0x0d950017, - 0x96e6eac3, 0xe003d3fe, 0x7b70392a, 0x0d70e2a2, 0x96030876, - 0xe0e6314b, 0x7b95db9f, 0x0d2c4331, 0x965fa9e5, 0xe0ba90d8, - 0x7bc97a0c}, - {0x00000000, 0x172864c0, 0x2e50c980, 0x3978ad40, 0x5ca19300, - 0x4b89f7c0, 0x72f15a80, 0x65d93e40, 0xb9432600, 0xae6b42c0, - 0x9713ef80, 0x803b8b40, 0xe5e2b500, 0xf2cad1c0, 0xcbb27c80, - 0xdc9a1840, 0xa9f74a41, 0xbedf2e81, 0x87a783c1, 0x908fe701, - 0xf556d941, 0xe27ebd81, 0xdb0610c1, 0xcc2e7401, 0x10b46c41, - 0x079c0881, 0x3ee4a5c1, 0x29ccc101, 0x4c15ff41, 0x5b3d9b81, - 0x624536c1, 0x756d5201, 0x889f92c3, 0x9fb7f603, 0xa6cf5b43, - 0xb1e73f83, 0xd43e01c3, 0xc3166503, 0xfa6ec843, 0xed46ac83, - 0x31dcb4c3, 0x26f4d003, 0x1f8c7d43, 0x08a41983, 0x6d7d27c3, - 0x7a554303, 0x432dee43, 0x54058a83, 0x2168d882, 0x3640bc42, - 0x0f381102, 0x181075c2, 0x7dc94b82, 0x6ae12f42, 0x53998202, - 0x44b1e6c2, 0x982bfe82, 0x8f039a42, 0xb67b3702, 0xa15353c2, - 0xc48a6d82, 0xd3a20942, 0xeadaa402, 0xfdf2c0c2, 0xca4e23c7, - 0xdd664707, 0xe41eea47, 0xf3368e87, 0x96efb0c7, 0x81c7d407, - 0xb8bf7947, 0xaf971d87, 0x730d05c7, 0x64256107, 0x5d5dcc47, - 0x4a75a887, 0x2fac96c7, 0x3884f207, 0x01fc5f47, 0x16d43b87, - 0x63b96986, 0x74910d46, 0x4de9a006, 0x5ac1c4c6, 0x3f18fa86, - 0x28309e46, 0x11483306, 0x066057c6, 0xdafa4f86, 0xcdd22b46, - 0xf4aa8606, 0xe382e2c6, 0x865bdc86, 0x9173b846, 0xa80b1506, - 0xbf2371c6, 0x42d1b104, 0x55f9d5c4, 0x6c817884, 0x7ba91c44, - 0x1e702204, 0x095846c4, 0x3020eb84, 0x27088f44, 0xfb929704, - 0xecbaf3c4, 0xd5c25e84, 0xc2ea3a44, 0xa7330404, 0xb01b60c4, - 0x8963cd84, 0x9e4ba944, 0xeb26fb45, 0xfc0e9f85, 0xc57632c5, - 0xd25e5605, 0xb7876845, 0xa0af0c85, 0x99d7a1c5, 0x8effc505, - 0x5265dd45, 0x454db985, 0x7c3514c5, 0x6b1d7005, 0x0ec44e45, - 0x19ec2a85, 0x209487c5, 0x37bce305, 0x4fed41cf, 0x58c5250f, - 0x61bd884f, 0x7695ec8f, 0x134cd2cf, 0x0464b60f, 0x3d1c1b4f, - 0x2a347f8f, 0xf6ae67cf, 0xe186030f, 0xd8feae4f, 0xcfd6ca8f, - 0xaa0ff4cf, 0xbd27900f, 0x845f3d4f, 0x9377598f, 0xe61a0b8e, - 0xf1326f4e, 0xc84ac20e, 0xdf62a6ce, 0xbabb988e, 0xad93fc4e, - 0x94eb510e, 0x83c335ce, 0x5f592d8e, 0x4871494e, 0x7109e40e, - 0x662180ce, 0x03f8be8e, 0x14d0da4e, 0x2da8770e, 0x3a8013ce, - 0xc772d30c, 0xd05ab7cc, 0xe9221a8c, 0xfe0a7e4c, 0x9bd3400c, - 0x8cfb24cc, 0xb583898c, 0xa2abed4c, 0x7e31f50c, 0x691991cc, - 0x50613c8c, 0x4749584c, 0x2290660c, 0x35b802cc, 0x0cc0af8c, - 0x1be8cb4c, 0x6e85994d, 0x79adfd8d, 0x40d550cd, 0x57fd340d, - 0x32240a4d, 0x250c6e8d, 0x1c74c3cd, 0x0b5ca70d, 0xd7c6bf4d, - 0xc0eedb8d, 0xf99676cd, 0xeebe120d, 0x8b672c4d, 0x9c4f488d, - 0xa537e5cd, 0xb21f810d, 0x85a36208, 0x928b06c8, 0xabf3ab88, - 0xbcdbcf48, 0xd902f108, 0xce2a95c8, 0xf7523888, 0xe07a5c48, - 0x3ce04408, 0x2bc820c8, 0x12b08d88, 0x0598e948, 0x6041d708, - 0x7769b3c8, 0x4e111e88, 0x59397a48, 0x2c542849, 0x3b7c4c89, - 0x0204e1c9, 0x152c8509, 0x70f5bb49, 0x67dddf89, 0x5ea572c9, - 0x498d1609, 0x95170e49, 0x823f6a89, 0xbb47c7c9, 0xac6fa309, - 0xc9b69d49, 0xde9ef989, 0xe7e654c9, 0xf0ce3009, 0x0d3cf0cb, - 0x1a14940b, 0x236c394b, 0x34445d8b, 0x519d63cb, 0x46b5070b, - 0x7fcdaa4b, 0x68e5ce8b, 0xb47fd6cb, 0xa357b20b, 0x9a2f1f4b, - 0x8d077b8b, 0xe8de45cb, 0xfff6210b, 0xc68e8c4b, 0xd1a6e88b, - 0xa4cbba8a, 0xb3e3de4a, 0x8a9b730a, 0x9db317ca, 0xf86a298a, - 0xef424d4a, 0xd63ae00a, 0xc11284ca, 0x1d889c8a, 0x0aa0f84a, - 0x33d8550a, 0x24f031ca, 0x41290f8a, 0x56016b4a, 0x6f79c60a, - 0x7851a2ca}, - {0x00000000, 0x9fda839e, 0xe4c4017d, 0x7b1e82e3, 0x12f904bb, - 0x8d238725, 0xf63d05c6, 0x69e78658, 0x25f20976, 0xba288ae8, - 0xc136080b, 0x5eec8b95, 0x370b0dcd, 0xa8d18e53, 0xd3cf0cb0, - 0x4c158f2e, 0x4be412ec, 0xd43e9172, 0xaf201391, 0x30fa900f, - 0x591d1657, 0xc6c795c9, 0xbdd9172a, 0x220394b4, 0x6e161b9a, - 0xf1cc9804, 0x8ad21ae7, 0x15089979, 0x7cef1f21, 0xe3359cbf, - 0x982b1e5c, 0x07f19dc2, 0x97c825d8, 0x0812a646, 0x730c24a5, - 0xecd6a73b, 0x85312163, 0x1aeba2fd, 0x61f5201e, 0xfe2fa380, - 0xb23a2cae, 0x2de0af30, 0x56fe2dd3, 0xc924ae4d, 0xa0c32815, - 0x3f19ab8b, 0x44072968, 0xdbddaaf6, 0xdc2c3734, 0x43f6b4aa, - 0x38e83649, 0xa732b5d7, 0xced5338f, 0x510fb011, 0x2a1132f2, - 0xb5cbb16c, 0xf9de3e42, 0x6604bddc, 0x1d1a3f3f, 0x82c0bca1, - 0xeb273af9, 0x74fdb967, 0x0fe33b84, 0x9039b81a, 0xf4e14df1, - 0x6b3bce6f, 0x10254c8c, 0x8fffcf12, 0xe618494a, 0x79c2cad4, - 0x02dc4837, 0x9d06cba9, 0xd1134487, 0x4ec9c719, 0x35d745fa, - 0xaa0dc664, 0xc3ea403c, 0x5c30c3a2, 0x272e4141, 0xb8f4c2df, - 0xbf055f1d, 0x20dfdc83, 0x5bc15e60, 0xc41bddfe, 0xadfc5ba6, - 0x3226d838, 0x49385adb, 0xd6e2d945, 0x9af7566b, 0x052dd5f5, - 0x7e335716, 0xe1e9d488, 0x880e52d0, 0x17d4d14e, 0x6cca53ad, - 0xf310d033, 0x63296829, 0xfcf3ebb7, 0x87ed6954, 0x1837eaca, - 0x71d06c92, 0xee0aef0c, 0x95146def, 0x0aceee71, 0x46db615f, - 0xd901e2c1, 0xa21f6022, 0x3dc5e3bc, 0x542265e4, 0xcbf8e67a, - 0xb0e66499, 0x2f3ce707, 0x28cd7ac5, 0xb717f95b, 0xcc097bb8, - 0x53d3f826, 0x3a347e7e, 0xa5eefde0, 0xdef07f03, 0x412afc9d, - 0x0d3f73b3, 0x92e5f02d, 0xe9fb72ce, 0x7621f150, 0x1fc67708, - 0x801cf496, 0xfb027675, 0x64d8f5eb, 0x32b39da3, 0xad691e3d, - 0xd6779cde, 0x49ad1f40, 0x204a9918, 0xbf901a86, 0xc48e9865, - 0x5b541bfb, 0x174194d5, 0x889b174b, 0xf38595a8, 0x6c5f1636, - 0x05b8906e, 0x9a6213f0, 0xe17c9113, 0x7ea6128d, 0x79578f4f, - 0xe68d0cd1, 0x9d938e32, 0x02490dac, 0x6bae8bf4, 0xf474086a, - 0x8f6a8a89, 0x10b00917, 0x5ca58639, 0xc37f05a7, 0xb8618744, - 0x27bb04da, 0x4e5c8282, 0xd186011c, 0xaa9883ff, 0x35420061, - 0xa57bb87b, 0x3aa13be5, 0x41bfb906, 0xde653a98, 0xb782bcc0, - 0x28583f5e, 0x5346bdbd, 0xcc9c3e23, 0x8089b10d, 0x1f533293, - 0x644db070, 0xfb9733ee, 0x9270b5b6, 0x0daa3628, 0x76b4b4cb, - 0xe96e3755, 0xee9faa97, 0x71452909, 0x0a5babea, 0x95812874, - 0xfc66ae2c, 0x63bc2db2, 0x18a2af51, 0x87782ccf, 0xcb6da3e1, - 0x54b7207f, 0x2fa9a29c, 0xb0732102, 0xd994a75a, 0x464e24c4, - 0x3d50a627, 0xa28a25b9, 0xc652d052, 0x598853cc, 0x2296d12f, - 0xbd4c52b1, 0xd4abd4e9, 0x4b715777, 0x306fd594, 0xafb5560a, - 0xe3a0d924, 0x7c7a5aba, 0x0764d859, 0x98be5bc7, 0xf159dd9f, - 0x6e835e01, 0x159ddce2, 0x8a475f7c, 0x8db6c2be, 0x126c4120, - 0x6972c3c3, 0xf6a8405d, 0x9f4fc605, 0x0095459b, 0x7b8bc778, - 0xe45144e6, 0xa844cbc8, 0x379e4856, 0x4c80cab5, 0xd35a492b, - 0xbabdcf73, 0x25674ced, 0x5e79ce0e, 0xc1a34d90, 0x519af58a, - 0xce407614, 0xb55ef4f7, 0x2a847769, 0x4363f131, 0xdcb972af, - 0xa7a7f04c, 0x387d73d2, 0x7468fcfc, 0xebb27f62, 0x90acfd81, - 0x0f767e1f, 0x6691f847, 0xf94b7bd9, 0x8255f93a, 0x1d8f7aa4, - 0x1a7ee766, 0x85a464f8, 0xfebae61b, 0x61606585, 0x0887e3dd, - 0x975d6043, 0xec43e2a0, 0x7399613e, 0x3f8cee10, 0xa0566d8e, - 0xdb48ef6d, 0x44926cf3, 0x2d75eaab, 0xb2af6935, 0xc9b1ebd6, - 0x566b6848}}; - -local const z_word_t FAR crc_braid_big_table[][256] = { - {0x00000000, 0x9e83da9f, 0x7d01c4e4, 0xe3821e7b, 0xbb04f912, - 0x2587238d, 0xc6053df6, 0x5886e769, 0x7609f225, 0xe88a28ba, - 0x0b0836c1, 0x958bec5e, 0xcd0d0b37, 0x538ed1a8, 0xb00ccfd3, - 0x2e8f154c, 0xec12e44b, 0x72913ed4, 0x911320af, 0x0f90fa30, - 0x57161d59, 0xc995c7c6, 0x2a17d9bd, 0xb4940322, 0x9a1b166e, - 0x0498ccf1, 0xe71ad28a, 0x79990815, 0x211fef7c, 0xbf9c35e3, - 0x5c1e2b98, 0xc29df107, 0xd825c897, 0x46a61208, 0xa5240c73, - 0x3ba7d6ec, 0x63213185, 0xfda2eb1a, 0x1e20f561, 0x80a32ffe, - 0xae2c3ab2, 0x30afe02d, 0xd32dfe56, 0x4dae24c9, 0x1528c3a0, - 0x8bab193f, 0x68290744, 0xf6aadddb, 0x34372cdc, 0xaab4f643, - 0x4936e838, 0xd7b532a7, 0x8f33d5ce, 0x11b00f51, 0xf232112a, - 0x6cb1cbb5, 0x423edef9, 0xdcbd0466, 0x3f3f1a1d, 0xa1bcc082, - 0xf93a27eb, 0x67b9fd74, 0x843be30f, 0x1ab83990, 0xf14de1f4, - 0x6fce3b6b, 0x8c4c2510, 0x12cfff8f, 0x4a4918e6, 0xd4cac279, - 0x3748dc02, 0xa9cb069d, 0x874413d1, 0x19c7c94e, 0xfa45d735, - 0x64c60daa, 0x3c40eac3, 0xa2c3305c, 0x41412e27, 0xdfc2f4b8, - 0x1d5f05bf, 0x83dcdf20, 0x605ec15b, 0xfedd1bc4, 0xa65bfcad, - 0x38d82632, 0xdb5a3849, 0x45d9e2d6, 0x6b56f79a, 0xf5d52d05, - 0x1657337e, 0x88d4e9e1, 0xd0520e88, 0x4ed1d417, 0xad53ca6c, - 0x33d010f3, 0x29682963, 0xb7ebf3fc, 0x5469ed87, 0xcaea3718, - 0x926cd071, 0x0cef0aee, 0xef6d1495, 0x71eece0a, 0x5f61db46, - 0xc1e201d9, 0x22601fa2, 0xbce3c53d, 0xe4652254, 0x7ae6f8cb, - 0x9964e6b0, 0x07e73c2f, 0xc57acd28, 0x5bf917b7, 0xb87b09cc, - 0x26f8d353, 0x7e7e343a, 0xe0fdeea5, 0x037ff0de, 0x9dfc2a41, - 0xb3733f0d, 0x2df0e592, 0xce72fbe9, 0x50f12176, 0x0877c61f, - 0x96f41c80, 0x757602fb, 0xebf5d864, 0xa39db332, 0x3d1e69ad, - 0xde9c77d6, 0x401fad49, 0x18994a20, 0x861a90bf, 0x65988ec4, - 0xfb1b545b, 0xd5944117, 0x4b179b88, 0xa89585f3, 0x36165f6c, - 0x6e90b805, 0xf013629a, 0x13917ce1, 0x8d12a67e, 0x4f8f5779, - 0xd10c8de6, 0x328e939d, 0xac0d4902, 0xf48bae6b, 0x6a0874f4, - 0x898a6a8f, 0x1709b010, 0x3986a55c, 0xa7057fc3, 0x448761b8, - 0xda04bb27, 0x82825c4e, 0x1c0186d1, 0xff8398aa, 0x61004235, - 0x7bb87ba5, 0xe53ba13a, 0x06b9bf41, 0x983a65de, 0xc0bc82b7, - 0x5e3f5828, 0xbdbd4653, 0x233e9ccc, 0x0db18980, 0x9332531f, - 0x70b04d64, 0xee3397fb, 0xb6b57092, 0x2836aa0d, 0xcbb4b476, - 0x55376ee9, 0x97aa9fee, 0x09294571, 0xeaab5b0a, 0x74288195, - 0x2cae66fc, 0xb22dbc63, 0x51afa218, 0xcf2c7887, 0xe1a36dcb, - 0x7f20b754, 0x9ca2a92f, 0x022173b0, 0x5aa794d9, 0xc4244e46, - 0x27a6503d, 0xb9258aa2, 0x52d052c6, 0xcc538859, 0x2fd19622, - 0xb1524cbd, 0xe9d4abd4, 0x7757714b, 0x94d56f30, 0x0a56b5af, - 0x24d9a0e3, 0xba5a7a7c, 0x59d86407, 0xc75bbe98, 0x9fdd59f1, - 0x015e836e, 0xe2dc9d15, 0x7c5f478a, 0xbec2b68d, 0x20416c12, - 0xc3c37269, 0x5d40a8f6, 0x05c64f9f, 0x9b459500, 0x78c78b7b, - 0xe64451e4, 0xc8cb44a8, 0x56489e37, 0xb5ca804c, 0x2b495ad3, - 0x73cfbdba, 0xed4c6725, 0x0ece795e, 0x904da3c1, 0x8af59a51, - 0x147640ce, 0xf7f45eb5, 0x6977842a, 0x31f16343, 0xaf72b9dc, - 0x4cf0a7a7, 0xd2737d38, 0xfcfc6874, 0x627fb2eb, 0x81fdac90, - 0x1f7e760f, 0x47f89166, 0xd97b4bf9, 0x3af95582, 0xa47a8f1d, - 0x66e77e1a, 0xf864a485, 0x1be6bafe, 0x85656061, 0xdde38708, - 0x43605d97, 0xa0e243ec, 0x3e619973, 0x10ee8c3f, 0x8e6d56a0, - 0x6def48db, 0xf36c9244, 0xabea752d, 0x3569afb2, 0xd6ebb1c9, - 0x48686b56}, - {0x00000000, 0xc0642817, 0x80c9502e, 0x40ad7839, 0x0093a15c, - 0xc0f7894b, 0x805af172, 0x403ed965, 0x002643b9, 0xc0426bae, - 0x80ef1397, 0x408b3b80, 0x00b5e2e5, 0xc0d1caf2, 0x807cb2cb, - 0x40189adc, 0x414af7a9, 0x812edfbe, 0xc183a787, 0x01e78f90, - 0x41d956f5, 0x81bd7ee2, 0xc11006db, 0x01742ecc, 0x416cb410, - 0x81089c07, 0xc1a5e43e, 0x01c1cc29, 0x41ff154c, 0x819b3d5b, - 0xc1364562, 0x01526d75, 0xc3929f88, 0x03f6b79f, 0x435bcfa6, - 0x833fe7b1, 0xc3013ed4, 0x036516c3, 0x43c86efa, 0x83ac46ed, - 0xc3b4dc31, 0x03d0f426, 0x437d8c1f, 0x8319a408, 0xc3277d6d, - 0x0343557a, 0x43ee2d43, 0x838a0554, 0x82d86821, 0x42bc4036, - 0x0211380f, 0xc2751018, 0x824bc97d, 0x422fe16a, 0x02829953, - 0xc2e6b144, 0x82fe2b98, 0x429a038f, 0x02377bb6, 0xc25353a1, - 0x826d8ac4, 0x4209a2d3, 0x02a4daea, 0xc2c0f2fd, 0xc7234eca, - 0x074766dd, 0x47ea1ee4, 0x878e36f3, 0xc7b0ef96, 0x07d4c781, - 0x4779bfb8, 0x871d97af, 0xc7050d73, 0x07612564, 0x47cc5d5d, - 0x87a8754a, 0xc796ac2f, 0x07f28438, 0x475ffc01, 0x873bd416, - 0x8669b963, 0x460d9174, 0x06a0e94d, 0xc6c4c15a, 0x86fa183f, - 0x469e3028, 0x06334811, 0xc6576006, 0x864ffada, 0x462bd2cd, - 0x0686aaf4, 0xc6e282e3, 0x86dc5b86, 0x46b87391, 0x06150ba8, - 0xc67123bf, 0x04b1d142, 0xc4d5f955, 0x8478816c, 0x441ca97b, - 0x0422701e, 0xc4465809, 0x84eb2030, 0x448f0827, 0x049792fb, - 0xc4f3baec, 0x845ec2d5, 0x443aeac2, 0x040433a7, 0xc4601bb0, - 0x84cd6389, 0x44a94b9e, 0x45fb26eb, 0x859f0efc, 0xc53276c5, - 0x05565ed2, 0x456887b7, 0x850cafa0, 0xc5a1d799, 0x05c5ff8e, - 0x45dd6552, 0x85b94d45, 0xc514357c, 0x05701d6b, 0x454ec40e, - 0x852aec19, 0xc5879420, 0x05e3bc37, 0xcf41ed4f, 0x0f25c558, - 0x4f88bd61, 0x8fec9576, 0xcfd24c13, 0x0fb66404, 0x4f1b1c3d, - 0x8f7f342a, 0xcf67aef6, 0x0f0386e1, 0x4faefed8, 0x8fcad6cf, - 0xcff40faa, 0x0f9027bd, 0x4f3d5f84, 0x8f597793, 0x8e0b1ae6, - 0x4e6f32f1, 0x0ec24ac8, 0xcea662df, 0x8e98bbba, 0x4efc93ad, - 0x0e51eb94, 0xce35c383, 0x8e2d595f, 0x4e497148, 0x0ee40971, - 0xce802166, 0x8ebef803, 0x4edad014, 0x0e77a82d, 0xce13803a, - 0x0cd372c7, 0xccb75ad0, 0x8c1a22e9, 0x4c7e0afe, 0x0c40d39b, - 0xcc24fb8c, 0x8c8983b5, 0x4cedaba2, 0x0cf5317e, 0xcc911969, - 0x8c3c6150, 0x4c584947, 0x0c669022, 0xcc02b835, 0x8cafc00c, - 0x4ccbe81b, 0x4d99856e, 0x8dfdad79, 0xcd50d540, 0x0d34fd57, - 0x4d0a2432, 0x8d6e0c25, 0xcdc3741c, 0x0da75c0b, 0x4dbfc6d7, - 0x8ddbeec0, 0xcd7696f9, 0x0d12beee, 0x4d2c678b, 0x8d484f9c, - 0xcde537a5, 0x0d811fb2, 0x0862a385, 0xc8068b92, 0x88abf3ab, - 0x48cfdbbc, 0x08f102d9, 0xc8952ace, 0x883852f7, 0x485c7ae0, - 0x0844e03c, 0xc820c82b, 0x888db012, 0x48e99805, 0x08d74160, - 0xc8b36977, 0x881e114e, 0x487a3959, 0x4928542c, 0x894c7c3b, - 0xc9e10402, 0x09852c15, 0x49bbf570, 0x89dfdd67, 0xc972a55e, - 0x09168d49, 0x490e1795, 0x896a3f82, 0xc9c747bb, 0x09a36fac, - 0x499db6c9, 0x89f99ede, 0xc954e6e7, 0x0930cef0, 0xcbf03c0d, - 0x0b94141a, 0x4b396c23, 0x8b5d4434, 0xcb639d51, 0x0b07b546, - 0x4baacd7f, 0x8bcee568, 0xcbd67fb4, 0x0bb257a3, 0x4b1f2f9a, - 0x8b7b078d, 0xcb45dee8, 0x0b21f6ff, 0x4b8c8ec6, 0x8be8a6d1, - 0x8abacba4, 0x4adee3b3, 0x0a739b8a, 0xca17b39d, 0x8a296af8, - 0x4a4d42ef, 0x0ae03ad6, 0xca8412c1, 0x8a9c881d, 0x4af8a00a, - 0x0a55d833, 0xca31f024, 0x8a0f2941, 0x4a6b0156, 0x0ac6796f, - 0xcaa25178}, - {0x00000000, 0xd4ea739b, 0xe9d396ed, 0x3d39e576, 0x93a15c00, - 0x474b2f9b, 0x7a72caed, 0xae98b976, 0x2643b900, 0xf2a9ca9b, - 0xcf902fed, 0x1b7a5c76, 0xb5e2e500, 0x6108969b, 0x5c3173ed, - 0x88db0076, 0x4c867201, 0x986c019a, 0xa555e4ec, 0x71bf9777, - 0xdf272e01, 0x0bcd5d9a, 0x36f4b8ec, 0xe21ecb77, 0x6ac5cb01, - 0xbe2fb89a, 0x83165dec, 0x57fc2e77, 0xf9649701, 0x2d8ee49a, - 0x10b701ec, 0xc45d7277, 0x980ce502, 0x4ce69699, 0x71df73ef, - 0xa5350074, 0x0badb902, 0xdf47ca99, 0xe27e2fef, 0x36945c74, - 0xbe4f5c02, 0x6aa52f99, 0x579ccaef, 0x8376b974, 0x2dee0002, - 0xf9047399, 0xc43d96ef, 0x10d7e574, 0xd48a9703, 0x0060e498, - 0x3d5901ee, 0xe9b37275, 0x472bcb03, 0x93c1b898, 0xaef85dee, - 0x7a122e75, 0xf2c92e03, 0x26235d98, 0x1b1ab8ee, 0xcff0cb75, - 0x61687203, 0xb5820198, 0x88bbe4ee, 0x5c519775, 0x3019ca05, - 0xe4f3b99e, 0xd9ca5ce8, 0x0d202f73, 0xa3b89605, 0x7752e59e, - 0x4a6b00e8, 0x9e817373, 0x165a7305, 0xc2b0009e, 0xff89e5e8, - 0x2b639673, 0x85fb2f05, 0x51115c9e, 0x6c28b9e8, 0xb8c2ca73, - 0x7c9fb804, 0xa875cb9f, 0x954c2ee9, 0x41a65d72, 0xef3ee404, - 0x3bd4979f, 0x06ed72e9, 0xd2070172, 0x5adc0104, 0x8e36729f, - 0xb30f97e9, 0x67e5e472, 0xc97d5d04, 0x1d972e9f, 0x20aecbe9, - 0xf444b872, 0xa8152f07, 0x7cff5c9c, 0x41c6b9ea, 0x952cca71, - 0x3bb47307, 0xef5e009c, 0xd267e5ea, 0x068d9671, 0x8e569607, - 0x5abce59c, 0x678500ea, 0xb36f7371, 0x1df7ca07, 0xc91db99c, - 0xf4245cea, 0x20ce2f71, 0xe4935d06, 0x30792e9d, 0x0d40cbeb, - 0xd9aab870, 0x77320106, 0xa3d8729d, 0x9ee197eb, 0x4a0be470, - 0xc2d0e406, 0x163a979d, 0x2b0372eb, 0xffe90170, 0x5171b806, - 0x859bcb9d, 0xb8a22eeb, 0x6c485d70, 0x6032940b, 0xb4d8e790, - 0x89e102e6, 0x5d0b717d, 0xf393c80b, 0x2779bb90, 0x1a405ee6, - 0xceaa2d7d, 0x46712d0b, 0x929b5e90, 0xafa2bbe6, 0x7b48c87d, - 0xd5d0710b, 0x013a0290, 0x3c03e7e6, 0xe8e9947d, 0x2cb4e60a, - 0xf85e9591, 0xc56770e7, 0x118d037c, 0xbf15ba0a, 0x6bffc991, - 0x56c62ce7, 0x822c5f7c, 0x0af75f0a, 0xde1d2c91, 0xe324c9e7, - 0x37ceba7c, 0x9956030a, 0x4dbc7091, 0x708595e7, 0xa46fe67c, - 0xf83e7109, 0x2cd40292, 0x11ede7e4, 0xc507947f, 0x6b9f2d09, - 0xbf755e92, 0x824cbbe4, 0x56a6c87f, 0xde7dc809, 0x0a97bb92, - 0x37ae5ee4, 0xe3442d7f, 0x4ddc9409, 0x9936e792, 0xa40f02e4, - 0x70e5717f, 0xb4b80308, 0x60527093, 0x5d6b95e5, 0x8981e67e, - 0x27195f08, 0xf3f32c93, 0xcecac9e5, 0x1a20ba7e, 0x92fbba08, - 0x4611c993, 0x7b282ce5, 0xafc25f7e, 0x015ae608, 0xd5b09593, - 0xe88970e5, 0x3c63037e, 0x502b5e0e, 0x84c12d95, 0xb9f8c8e3, - 0x6d12bb78, 0xc38a020e, 0x17607195, 0x2a5994e3, 0xfeb3e778, - 0x7668e70e, 0xa2829495, 0x9fbb71e3, 0x4b510278, 0xe5c9bb0e, - 0x3123c895, 0x0c1a2de3, 0xd8f05e78, 0x1cad2c0f, 0xc8475f94, - 0xf57ebae2, 0x2194c979, 0x8f0c700f, 0x5be60394, 0x66dfe6e2, - 0xb2359579, 0x3aee950f, 0xee04e694, 0xd33d03e2, 0x07d77079, - 0xa94fc90f, 0x7da5ba94, 0x409c5fe2, 0x94762c79, 0xc827bb0c, - 0x1ccdc897, 0x21f42de1, 0xf51e5e7a, 0x5b86e70c, 0x8f6c9497, - 0xb25571e1, 0x66bf027a, 0xee64020c, 0x3a8e7197, 0x07b794e1, - 0xd35de77a, 0x7dc55e0c, 0xa92f2d97, 0x9416c8e1, 0x40fcbb7a, - 0x84a1c90d, 0x504bba96, 0x6d725fe0, 0xb9982c7b, 0x1700950d, - 0xc3eae696, 0xfed303e0, 0x2a39707b, 0xa2e2700d, 0x76080396, - 0x4b31e6e0, 0x9fdb957b, 0x31432c0d, 0xe5a95f96, 0xd890bae0, - 0x0c7ac97b}, - {0x00000000, 0x27652581, 0x0fcc3bd9, 0x28a91e58, 0x5f9e0669, - 0x78fb23e8, 0x50523db0, 0x77371831, 0xbe3c0dd2, 0x99592853, - 0xb1f0360b, 0x9695138a, 0xe1a20bbb, 0xc6c72e3a, 0xee6e3062, - 0xc90b15e3, 0x3d7f6b7f, 0x1a1a4efe, 0x32b350a6, 0x15d67527, - 0x62e16d16, 0x45844897, 0x6d2d56cf, 0x4a48734e, 0x834366ad, - 0xa426432c, 0x8c8f5d74, 0xabea78f5, 0xdcdd60c4, 0xfbb84545, - 0xd3115b1d, 0xf4747e9c, 0x7afed6fe, 0x5d9bf37f, 0x7532ed27, - 0x5257c8a6, 0x2560d097, 0x0205f516, 0x2aaceb4e, 0x0dc9cecf, - 0xc4c2db2c, 0xe3a7fead, 0xcb0ee0f5, 0xec6bc574, 0x9b5cdd45, - 0xbc39f8c4, 0x9490e69c, 0xb3f5c31d, 0x4781bd81, 0x60e49800, - 0x484d8658, 0x6f28a3d9, 0x181fbbe8, 0x3f7a9e69, 0x17d38031, - 0x30b6a5b0, 0xf9bdb053, 0xded895d2, 0xf6718b8a, 0xd114ae0b, - 0xa623b63a, 0x814693bb, 0xa9ef8de3, 0x8e8aa862, 0xb5fadc26, - 0x929ff9a7, 0xba36e7ff, 0x9d53c27e, 0xea64da4f, 0xcd01ffce, - 0xe5a8e196, 0xc2cdc417, 0x0bc6d1f4, 0x2ca3f475, 0x040aea2d, - 0x236fcfac, 0x5458d79d, 0x733df21c, 0x5b94ec44, 0x7cf1c9c5, - 0x8885b759, 0xafe092d8, 0x87498c80, 0xa02ca901, 0xd71bb130, - 0xf07e94b1, 0xd8d78ae9, 0xffb2af68, 0x36b9ba8b, 0x11dc9f0a, - 0x39758152, 0x1e10a4d3, 0x6927bce2, 0x4e429963, 0x66eb873b, - 0x418ea2ba, 0xcf040ad8, 0xe8612f59, 0xc0c83101, 0xe7ad1480, - 0x909a0cb1, 0xb7ff2930, 0x9f563768, 0xb83312e9, 0x7138070a, - 0x565d228b, 0x7ef43cd3, 0x59911952, 0x2ea60163, 0x09c324e2, - 0x216a3aba, 0x060f1f3b, 0xf27b61a7, 0xd51e4426, 0xfdb75a7e, - 0xdad27fff, 0xade567ce, 0x8a80424f, 0xa2295c17, 0x854c7996, - 0x4c476c75, 0x6b2249f4, 0x438b57ac, 0x64ee722d, 0x13d96a1c, - 0x34bc4f9d, 0x1c1551c5, 0x3b707444, 0x6af5b94d, 0x4d909ccc, - 0x65398294, 0x425ca715, 0x356bbf24, 0x120e9aa5, 0x3aa784fd, - 0x1dc2a17c, 0xd4c9b49f, 0xf3ac911e, 0xdb058f46, 0xfc60aac7, - 0x8b57b2f6, 0xac329777, 0x849b892f, 0xa3feacae, 0x578ad232, - 0x70eff7b3, 0x5846e9eb, 0x7f23cc6a, 0x0814d45b, 0x2f71f1da, - 0x07d8ef82, 0x20bdca03, 0xe9b6dfe0, 0xced3fa61, 0xe67ae439, - 0xc11fc1b8, 0xb628d989, 0x914dfc08, 0xb9e4e250, 0x9e81c7d1, - 0x100b6fb3, 0x376e4a32, 0x1fc7546a, 0x38a271eb, 0x4f9569da, - 0x68f04c5b, 0x40595203, 0x673c7782, 0xae376261, 0x895247e0, - 0xa1fb59b8, 0x869e7c39, 0xf1a96408, 0xd6cc4189, 0xfe655fd1, - 0xd9007a50, 0x2d7404cc, 0x0a11214d, 0x22b83f15, 0x05dd1a94, - 0x72ea02a5, 0x558f2724, 0x7d26397c, 0x5a431cfd, 0x9348091e, - 0xb42d2c9f, 0x9c8432c7, 0xbbe11746, 0xccd60f77, 0xebb32af6, - 0xc31a34ae, 0xe47f112f, 0xdf0f656b, 0xf86a40ea, 0xd0c35eb2, - 0xf7a67b33, 0x80916302, 0xa7f44683, 0x8f5d58db, 0xa8387d5a, - 0x613368b9, 0x46564d38, 0x6eff5360, 0x499a76e1, 0x3ead6ed0, - 0x19c84b51, 0x31615509, 0x16047088, 0xe2700e14, 0xc5152b95, - 0xedbc35cd, 0xcad9104c, 0xbdee087d, 0x9a8b2dfc, 0xb22233a4, - 0x95471625, 0x5c4c03c6, 0x7b292647, 0x5380381f, 0x74e51d9e, - 0x03d205af, 0x24b7202e, 0x0c1e3e76, 0x2b7b1bf7, 0xa5f1b395, - 0x82949614, 0xaa3d884c, 0x8d58adcd, 0xfa6fb5fc, 0xdd0a907d, - 0xf5a38e25, 0xd2c6aba4, 0x1bcdbe47, 0x3ca89bc6, 0x1401859e, - 0x3364a01f, 0x4453b82e, 0x63369daf, 0x4b9f83f7, 0x6cfaa676, - 0x988ed8ea, 0xbfebfd6b, 0x9742e333, 0xb027c6b2, 0xc710de83, - 0xe075fb02, 0xc8dce55a, 0xefb9c0db, 0x26b2d538, 0x01d7f0b9, - 0x297eeee1, 0x0e1bcb60, 0x792cd351, 0x5e49f6d0, 0x76e0e888, - 0x5185cd09}}; - -#endif - -#endif - -#endif - -local const z_crc_t FAR x2n_table[] = { - 0x40000000, 0x20000000, 0x08000000, 0x00800000, 0x00008000, - 0xedb88320, 0xb1e6b092, 0xa06a2517, 0xed627dae, 0x88d14467, - 0xd7bbfe6a, 0xec447f11, 0x8e7ea170, 0x6427800e, 0x4d47bae0, - 0x09fe548f, 0x83852d0f, 0x30362f1a, 0x7b5a9cc3, 0x31fec169, - 0x9fec022a, 0x6c8dedc4, 0x15d6874d, 0x5fde7a4e, 0xbad90e37, - 0x2e4e5eef, 0x4eaba214, 0xa8a472c0, 0x429a969e, 0x148d302a, - 0xc40ba6d0, 0xc4e22c3c}; diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/deflate.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/deflate.c deleted file mode 100644 index 799fb93..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/deflate.c +++ /dev/null @@ -1,2211 +0,0 @@ -/* deflate.c -- compress data using the deflation algorithm - * Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - * ALGORITHM - * - * The "deflation" process depends on being able to identify portions - * of the input text which are identical to earlier input (within a - * sliding window trailing behind the input currently being processed). - * - * The most straightforward technique turns out to be the fastest for - * most input files: try all possible matches and select the longest. - * The key feature of this algorithm is that insertions into the string - * dictionary are very simple and thus fast, and deletions are avoided - * completely. Insertions are performed at each input character, whereas - * string matches are performed only when the previous match ends. So it - * is preferable to spend more time in matches to allow very fast string - * insertions and avoid deletions. The matching algorithm for small - * strings is inspired from that of Rabin & Karp. A brute force approach - * is used to find longer strings when a small match has been found. - * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze - * (by Leonid Broukhis). - * A previous version of this file used a more sophisticated algorithm - * (by Fiala and Greene) which is guaranteed to run in linear amortized - * time, but has a larger average cost, uses more memory and is patented. - * However the F&G algorithm may be faster for some highly redundant - * files if the parameter max_chain_length (described below) is too large. - * - * ACKNOWLEDGEMENTS - * - * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and - * I found it in 'freeze' written by Leonid Broukhis. - * Thanks to many people for bug reports and testing. - * - * REFERENCES - * - * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification". - * Available in http://tools.ietf.org/html/rfc1951 - * - * A description of the Rabin and Karp algorithm is given in the book - * "Algorithms" by R. Sedgewick, Addison-Wesley, p252. - * - * Fiala,E.R., and Greene,D.H. - * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595 - * - */ - -/* @(#) $Id$ */ - -#include "deflate.h" - -const char deflate_copyright[] = - " deflate 1.2.12 Copyright 1995-2022 Jean-loup Gailly and Mark Adler "; -/* - If you use the zlib library in a product, an acknowledgment is welcome - in the documentation of your product. If for some reason you cannot - include such an acknowledgment, I would appreciate that you keep this - copyright string in the executable of your product. - */ - -/* =========================================================================== - * Function prototypes. - */ -typedef enum { - need_more, /* block not completed, need more input or more output */ - block_done, /* block flush performed */ - finish_started, /* finish started, need only more output at next deflate */ - finish_done /* finish done, accept no more input or output */ -} block_state; - -typedef block_state (*compress_func) OF((deflate_state *s, int flush)); -/* Compression function. Returns the block state after the call. */ - -local int deflateStateCheck OF((z_streamp strm)); -local void slide_hash OF((deflate_state *s)); -local void fill_window OF((deflate_state *s)); -local block_state deflate_stored OF((deflate_state *s, int flush)); -local block_state deflate_fast OF((deflate_state *s, int flush)); -#ifndef FASTEST -local block_state deflate_slow OF((deflate_state *s, int flush)); -#endif -local block_state deflate_rle OF((deflate_state *s, int flush)); -local block_state deflate_huff OF((deflate_state *s, int flush)); -local void lm_init OF((deflate_state *s)); -local void putShortMSB OF((deflate_state *s, uInt b)); -local void flush_pending OF((z_streamp strm)); -local unsigned read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); -#ifdef ASMV -# pragma message("Assembler code may have bugs -- use at your own risk") - void match_init OF((void)); /* asm code initialization */ - uInt longest_match OF((deflate_state *s, IPos cur_match)); -#else -local uInt longest_match OF((deflate_state *s, IPos cur_match)); -#endif - -#ifdef ZLIB_DEBUG -local void check_match OF((deflate_state *s, IPos start, IPos match, - int length)); -#endif - -/* =========================================================================== - * Local data - */ - -#define NIL 0 -/* Tail of hash chains */ - -#ifndef TOO_FAR -# define TOO_FAR 4096 -#endif -/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */ - -/* Values for max_lazy_match, good_match and max_chain_length, depending on - * the desired pack level (0..9). The values given below have been tuned to - * exclude worst case performance for pathological files. Better values may be - * found for specific files. - */ -typedef struct config_s { - ush good_length; /* reduce lazy search above this match length */ - ush max_lazy; /* do not perform lazy search above this match length */ - ush nice_length; /* quit search above this match length */ - ush max_chain; - compress_func func; -} config; - -#ifdef FASTEST -local const config configuration_table[2] = { -/* good lazy nice chain */ -/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ -/* 1 */ {4, 4, 8, 4, deflate_fast}}; /* max speed, no lazy matches */ -#else -local const config configuration_table[10] = { -/* good lazy nice chain */ -/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ -/* 1 */ {4, 4, 8, 4, deflate_fast}, /* max speed, no lazy matches */ -/* 2 */ {4, 5, 16, 8, deflate_fast}, -/* 3 */ {4, 6, 32, 32, deflate_fast}, - -/* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */ -/* 5 */ {8, 16, 32, 32, deflate_slow}, -/* 6 */ {8, 16, 128, 128, deflate_slow}, -/* 7 */ {8, 32, 128, 256, deflate_slow}, -/* 8 */ {32, 128, 258, 1024, deflate_slow}, -/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */ -#endif - -/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4 - * For deflate_fast() (levels <= 3) good is ignored and lazy has a different - * meaning. - */ - -/* rank Z_BLOCK between Z_NO_FLUSH and Z_PARTIAL_FLUSH */ -#define RANK(f) (((f) * 2) - ((f) > 4 ? 9 : 0)) - -/* =========================================================================== - * Update a hash value with the given input byte - * IN assertion: all calls to UPDATE_HASH are made with consecutive input - * characters, so that a running hash key can be computed from the previous - * key instead of complete recalculation each time. - */ -#define UPDATE_HASH(s,h,c) (h = (((h)<hash_shift) ^ (c)) & s->hash_mask) - - -/* =========================================================================== - * Insert string str in the dictionary and set match_head to the previous head - * of the hash chain (the most recent string with same hash key). Return - * the previous length of the hash chain. - * If this file is compiled with -DFASTEST, the compression level is forced - * to 1, and no hash chains are maintained. - * IN assertion: all calls to INSERT_STRING are made with consecutive input - * characters and the first MIN_MATCH bytes of str are valid (except for - * the last MIN_MATCH-1 bytes of the input file). - */ -#ifdef FASTEST -#define INSERT_STRING(s, str, match_head) \ - (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ - match_head = s->head[s->ins_h], \ - s->head[s->ins_h] = (Pos)(str)) -#else -#define INSERT_STRING(s, str, match_head) \ - (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ - match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \ - s->head[s->ins_h] = (Pos)(str)) -#endif - -/* =========================================================================== - * Initialize the hash table (avoiding 64K overflow for 16 bit systems). - * prev[] will be initialized on the fly. - */ -#define CLEAR_HASH(s) \ - do { \ - s->head[s->hash_size-1] = NIL; \ - zmemzero((Bytef *)s->head, \ - (unsigned)(s->hash_size-1)*sizeof(*s->head)); \ - } while (0) - -/* =========================================================================== - * Slide the hash table when sliding the window down (could be avoided with 32 - * bit values at the expense of memory usage). We slide even when level == 0 to - * keep the hash table consistent if we switch back to level > 0 later. - */ -local void slide_hash(s) - deflate_state *s; -{ - unsigned n, m; - Posf *p; - uInt wsize = s->w_size; - - n = s->hash_size; - p = &s->head[n]; - do { - m = *--p; - *p = (Pos)(m >= wsize ? m - wsize : NIL); - } while (--n); - n = wsize; -#ifndef FASTEST - p = &s->prev[n]; - do { - m = *--p; - *p = (Pos)(m >= wsize ? m - wsize : NIL); - /* If n is not on any hash chain, prev[n] is garbage but - * its value will never be used. - */ - } while (--n); -#endif -} - -/* ========================================================================= */ -int ZEXPORT deflateInit_(strm, level, version, stream_size) - z_streamp strm; - int level; - const char *version; - int stream_size; -{ - return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, - Z_DEFAULT_STRATEGY, version, stream_size); - /* To do: ignore strm->next_in if we use it as window */ -} - -/* ========================================================================= */ -int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, - version, stream_size) - z_streamp strm; - int level; - int method; - int windowBits; - int memLevel; - int strategy; - const char *version; - int stream_size; -{ - deflate_state *s; - int wrap = 1; - static const char my_version[] = ZLIB_VERSION; - - if (version == Z_NULL || version[0] != my_version[0] || - stream_size != sizeof(z_stream)) { - return Z_VERSION_ERROR; - } - if (strm == Z_NULL) return Z_STREAM_ERROR; - - strm->msg = Z_NULL; - if (strm->zalloc == (alloc_func)0) { -#ifdef Z_SOLO - return Z_STREAM_ERROR; -#else - strm->zalloc = zcalloc; - strm->opaque = (voidpf)0; -#endif - } - if (strm->zfree == (free_func)0) -#ifdef Z_SOLO - return Z_STREAM_ERROR; -#else - strm->zfree = zcfree; -#endif - -#ifdef FASTEST - if (level != 0) level = 1; -#else - if (level == Z_DEFAULT_COMPRESSION) level = 6; -#endif - - if (windowBits < 0) { /* suppress zlib wrapper */ - wrap = 0; - windowBits = -windowBits; - } -#ifdef GZIP - else if (windowBits > 15) { - wrap = 2; /* write gzip wrapper instead */ - windowBits -= 16; - } -#endif - if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || - windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || - strategy < 0 || strategy > Z_FIXED || (windowBits == 8 && wrap != 1)) { - return Z_STREAM_ERROR; - } - if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */ - s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state)); - if (s == Z_NULL) return Z_MEM_ERROR; - strm->state = (struct internal_state FAR *)s; - s->strm = strm; - s->status = INIT_STATE; /* to pass state test in deflateReset() */ - - s->wrap = wrap; - s->gzhead = Z_NULL; - s->w_bits = (uInt)windowBits; - s->w_size = 1 << s->w_bits; - s->w_mask = s->w_size - 1; - - s->hash_bits = (uInt)memLevel + 7; - s->hash_size = 1 << s->hash_bits; - s->hash_mask = s->hash_size - 1; - s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH); - - s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte)); - s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos)); - s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos)); - - s->high_water = 0; /* nothing written to s->window yet */ - - s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */ - - /* We overlay pending_buf and sym_buf. This works since the average size - * for length/distance pairs over any compressed block is assured to be 31 - * bits or less. - * - * Analysis: The longest fixed codes are a length code of 8 bits plus 5 - * extra bits, for lengths 131 to 257. The longest fixed distance codes are - * 5 bits plus 13 extra bits, for distances 16385 to 32768. The longest - * possible fixed-codes length/distance pair is then 31 bits total. - * - * sym_buf starts one-fourth of the way into pending_buf. So there are - * three bytes in sym_buf for every four bytes in pending_buf. Each symbol - * in sym_buf is three bytes -- two for the distance and one for the - * literal/length. As each symbol is consumed, the pointer to the next - * sym_buf value to read moves forward three bytes. From that symbol, up to - * 31 bits are written to pending_buf. The closest the written pending_buf - * bits gets to the next sym_buf symbol to read is just before the last - * code is written. At that time, 31*(n-2) bits have been written, just - * after 24*(n-2) bits have been consumed from sym_buf. sym_buf starts at - * 8*n bits into pending_buf. (Note that the symbol buffer fills when n-1 - * symbols are written.) The closest the writing gets to what is unread is - * then n+14 bits. Here n is lit_bufsize, which is 16384 by default, and - * can range from 128 to 32768. - * - * Therefore, at a minimum, there are 142 bits of space between what is - * written and what is read in the overlain buffers, so the symbols cannot - * be overwritten by the compressed data. That space is actually 139 bits, - * due to the three-bit fixed-code block header. - * - * That covers the case where either Z_FIXED is specified, forcing fixed - * codes, or when the use of fixed codes is chosen, because that choice - * results in a smaller compressed block than dynamic codes. That latter - * condition then assures that the above analysis also covers all dynamic - * blocks. A dynamic-code block will only be chosen to be emitted if it has - * fewer bits than a fixed-code block would for the same set of symbols. - * Therefore its average symbol length is assured to be less than 31. So - * the compressed data for a dynamic block also cannot overwrite the - * symbols from which it is being constructed. - */ - - s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, 4); - s->pending_buf_size = (ulg)s->lit_bufsize * 4; - - if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || - s->pending_buf == Z_NULL) { - s->status = FINISH_STATE; - strm->msg = ERR_MSG(Z_MEM_ERROR); - deflateEnd (strm); - return Z_MEM_ERROR; - } - s->sym_buf = s->pending_buf + s->lit_bufsize; - s->sym_end = (s->lit_bufsize - 1) * 3; - /* We avoid equality with lit_bufsize*3 because of wraparound at 64K - * on 16 bit machines and because stored blocks are restricted to - * 64K-1 bytes. - */ - - s->level = level; - s->strategy = strategy; - s->method = (Byte)method; - - return deflateReset(strm); -} - -/* ========================================================================= - * Check for a valid deflate stream state. Return 0 if ok, 1 if not. - */ -local int deflateStateCheck (strm) - z_streamp strm; -{ - deflate_state *s; - if (strm == Z_NULL || - strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) - return 1; - s = strm->state; - if (s == Z_NULL || s->strm != strm || (s->status != INIT_STATE && -#ifdef GZIP - s->status != GZIP_STATE && -#endif - s->status != EXTRA_STATE && - s->status != NAME_STATE && - s->status != COMMENT_STATE && - s->status != HCRC_STATE && - s->status != BUSY_STATE && - s->status != FINISH_STATE)) - return 1; - return 0; -} - -/* ========================================================================= */ -int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) - z_streamp strm; - const Bytef *dictionary; - uInt dictLength; -{ - deflate_state *s; - uInt str, n; - int wrap; - unsigned avail; - z_const unsigned char *next; - - if (deflateStateCheck(strm) || dictionary == Z_NULL) - return Z_STREAM_ERROR; - s = strm->state; - wrap = s->wrap; - if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead) - return Z_STREAM_ERROR; - - /* when using zlib wrappers, compute Adler-32 for provided dictionary */ - if (wrap == 1) - strm->adler = adler32(strm->adler, dictionary, dictLength); - s->wrap = 0; /* avoid computing Adler-32 in read_buf */ - - /* if dictionary would fill window, just replace the history */ - if (dictLength >= s->w_size) { - if (wrap == 0) { /* already empty otherwise */ - CLEAR_HASH(s); - s->strstart = 0; - s->block_start = 0L; - s->insert = 0; - } - dictionary += dictLength - s->w_size; /* use the tail */ - dictLength = s->w_size; - } - - /* insert dictionary into window and hash */ - avail = strm->avail_in; - next = strm->next_in; - strm->avail_in = dictLength; - strm->next_in = (z_const Bytef *)dictionary; - fill_window(s); - while (s->lookahead >= MIN_MATCH) { - str = s->strstart; - n = s->lookahead - (MIN_MATCH-1); - do { - UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); -#ifndef FASTEST - s->prev[str & s->w_mask] = s->head[s->ins_h]; -#endif - s->head[s->ins_h] = (Pos)str; - str++; - } while (--n); - s->strstart = str; - s->lookahead = MIN_MATCH-1; - fill_window(s); - } - s->strstart += s->lookahead; - s->block_start = (long)s->strstart; - s->insert = s->lookahead; - s->lookahead = 0; - s->match_length = s->prev_length = MIN_MATCH-1; - s->match_available = 0; - strm->next_in = next; - strm->avail_in = avail; - s->wrap = wrap; - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflateGetDictionary (strm, dictionary, dictLength) - z_streamp strm; - Bytef *dictionary; - uInt *dictLength; -{ - deflate_state *s; - uInt len; - - if (deflateStateCheck(strm)) - return Z_STREAM_ERROR; - s = strm->state; - len = s->strstart + s->lookahead; - if (len > s->w_size) - len = s->w_size; - if (dictionary != Z_NULL && len) - zmemcpy(dictionary, s->window + s->strstart + s->lookahead - len, len); - if (dictLength != Z_NULL) - *dictLength = len; - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflateResetKeep (strm) - z_streamp strm; -{ - deflate_state *s; - - if (deflateStateCheck(strm)) { - return Z_STREAM_ERROR; - } - - strm->total_in = strm->total_out = 0; - strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */ - strm->data_type = Z_UNKNOWN; - - s = (deflate_state *)strm->state; - s->pending = 0; - s->pending_out = s->pending_buf; - - if (s->wrap < 0) { - s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */ - } - s->status = -#ifdef GZIP - s->wrap == 2 ? GZIP_STATE : -#endif - INIT_STATE; - strm->adler = -#ifdef GZIP - s->wrap == 2 ? crc32(0L, Z_NULL, 0) : -#endif - adler32(0L, Z_NULL, 0); - s->last_flush = -2; - - _tr_init(s); - - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflateReset (strm) - z_streamp strm; -{ - int ret; - - ret = deflateResetKeep(strm); - if (ret == Z_OK) - lm_init(strm->state); - return ret; -} - -/* ========================================================================= */ -int ZEXPORT deflateSetHeader (strm, head) - z_streamp strm; - gz_headerp head; -{ - if (deflateStateCheck(strm) || strm->state->wrap != 2) - return Z_STREAM_ERROR; - strm->state->gzhead = head; - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflatePending (strm, pending, bits) - unsigned *pending; - int *bits; - z_streamp strm; -{ - if (deflateStateCheck(strm)) return Z_STREAM_ERROR; - if (pending != Z_NULL) - *pending = strm->state->pending; - if (bits != Z_NULL) - *bits = strm->state->bi_valid; - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflatePrime (strm, bits, value) - z_streamp strm; - int bits; - int value; -{ - deflate_state *s; - int put; - - if (deflateStateCheck(strm)) return Z_STREAM_ERROR; - s = strm->state; - if (bits < 0 || bits > 16 || - s->sym_buf < s->pending_out + ((Buf_size + 7) >> 3)) - return Z_BUF_ERROR; - do { - put = Buf_size - s->bi_valid; - if (put > bits) - put = bits; - s->bi_buf |= (ush)((value & ((1 << put) - 1)) << s->bi_valid); - s->bi_valid += put; - _tr_flush_bits(s); - value >>= put; - bits -= put; - } while (bits); - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflateParams(strm, level, strategy) - z_streamp strm; - int level; - int strategy; -{ - deflate_state *s; - compress_func func; - - if (deflateStateCheck(strm)) return Z_STREAM_ERROR; - s = strm->state; - -#ifdef FASTEST - if (level != 0) level = 1; -#else - if (level == Z_DEFAULT_COMPRESSION) level = 6; -#endif - if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) { - return Z_STREAM_ERROR; - } - func = configuration_table[s->level].func; - - if ((strategy != s->strategy || func != configuration_table[level].func) && - s->last_flush != -2) { - /* Flush the last buffer: */ - int err = deflate(strm, Z_BLOCK); - if (err == Z_STREAM_ERROR) - return err; - if (strm->avail_in || (s->strstart - s->block_start) + s->lookahead) - return Z_BUF_ERROR; - } - if (s->level != level) { - if (s->level == 0 && s->matches != 0) { - if (s->matches == 1) - slide_hash(s); - else - CLEAR_HASH(s); - s->matches = 0; - } - s->level = level; - s->max_lazy_match = configuration_table[level].max_lazy; - s->good_match = configuration_table[level].good_length; - s->nice_match = configuration_table[level].nice_length; - s->max_chain_length = configuration_table[level].max_chain; - } - s->strategy = strategy; - return Z_OK; -} - -/* ========================================================================= */ -int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain) - z_streamp strm; - int good_length; - int max_lazy; - int nice_length; - int max_chain; -{ - deflate_state *s; - - if (deflateStateCheck(strm)) return Z_STREAM_ERROR; - s = strm->state; - s->good_match = (uInt)good_length; - s->max_lazy_match = (uInt)max_lazy; - s->nice_match = nice_length; - s->max_chain_length = (uInt)max_chain; - return Z_OK; -} - -/* ========================================================================= - * For the default windowBits of 15 and memLevel of 8, this function returns - * a close to exact, as well as small, upper bound on the compressed size. - * They are coded as constants here for a reason--if the #define's are - * changed, then this function needs to be changed as well. The return - * value for 15 and 8 only works for those exact settings. - * - * For any setting other than those defaults for windowBits and memLevel, - * the value returned is a conservative worst case for the maximum expansion - * resulting from using fixed blocks instead of stored blocks, which deflate - * can emit on compressed data for some combinations of the parameters. - * - * This function could be more sophisticated to provide closer upper bounds for - * every combination of windowBits and memLevel. But even the conservative - * upper bound of about 14% expansion does not seem onerous for output buffer - * allocation. - */ -uLong ZEXPORT deflateBound(strm, sourceLen) - z_streamp strm; - uLong sourceLen; -{ - deflate_state *s; - uLong complen, wraplen; - - /* conservative upper bound for compressed data */ - complen = sourceLen + - ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5; - - /* if can't get parameters, return conservative bound plus zlib wrapper */ - if (deflateStateCheck(strm)) - return complen + 6; - - /* compute wrapper length */ - s = strm->state; - switch (s->wrap) { - case 0: /* raw deflate */ - wraplen = 0; - break; - case 1: /* zlib wrapper */ - wraplen = 6 + (s->strstart ? 4 : 0); - break; -#ifdef GZIP - case 2: /* gzip wrapper */ - wraplen = 18; - if (s->gzhead != Z_NULL) { /* user-supplied gzip header */ - Bytef *str; - if (s->gzhead->extra != Z_NULL) - wraplen += 2 + s->gzhead->extra_len; - str = s->gzhead->name; - if (str != Z_NULL) - do { - wraplen++; - } while (*str++); - str = s->gzhead->comment; - if (str != Z_NULL) - do { - wraplen++; - } while (*str++); - if (s->gzhead->hcrc) - wraplen += 2; - } - break; -#endif - default: /* for compiler happiness */ - wraplen = 6; - } - - /* if not default parameters, return conservative bound */ - if (s->w_bits != 15 || s->hash_bits != 8 + 7) - return complen + wraplen; - - /* default settings: return tight bound for that case */ - return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + - (sourceLen >> 25) + 13 - 6 + wraplen; -} - -/* ========================================================================= - * Put a short in the pending buffer. The 16-bit value is put in MSB order. - * IN assertion: the stream state is correct and there is enough room in - * pending_buf. - */ -local void putShortMSB (s, b) - deflate_state *s; - uInt b; -{ - put_byte(s, (Byte)(b >> 8)); - put_byte(s, (Byte)(b & 0xff)); -} - -/* ========================================================================= - * Flush as much pending output as possible. All deflate() output, except for - * some deflate_stored() output, goes through this function so some - * applications may wish to modify it to avoid allocating a large - * strm->next_out buffer and copying into it. (See also read_buf()). - */ -local void flush_pending(strm) - z_streamp strm; -{ - unsigned len; - deflate_state *s = strm->state; - - _tr_flush_bits(s); - len = s->pending; - if (len > strm->avail_out) len = strm->avail_out; - if (len == 0) return; - - zmemcpy(strm->next_out, s->pending_out, len); - strm->next_out += len; - s->pending_out += len; - strm->total_out += len; - strm->avail_out -= len; - s->pending -= len; - if (s->pending == 0) { - s->pending_out = s->pending_buf; - } -} - -/* =========================================================================== - * Update the header CRC with the bytes s->pending_buf[beg..s->pending - 1]. - */ -#define HCRC_UPDATE(beg) \ - do { \ - if (s->gzhead->hcrc && s->pending > (beg)) \ - strm->adler = crc32(strm->adler, s->pending_buf + (beg), \ - s->pending - (beg)); \ - } while (0) - -/* ========================================================================= */ -int ZEXPORT deflate (strm, flush) - z_streamp strm; - int flush; -{ - int old_flush; /* value of flush param for previous deflate call */ - deflate_state *s; - - if (deflateStateCheck(strm) || flush > Z_BLOCK || flush < 0) { - return Z_STREAM_ERROR; - } - s = strm->state; - - if (strm->next_out == Z_NULL || - (strm->avail_in != 0 && strm->next_in == Z_NULL) || - (s->status == FINISH_STATE && flush != Z_FINISH)) { - ERR_RETURN(strm, Z_STREAM_ERROR); - } - if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR); - - old_flush = s->last_flush; - s->last_flush = flush; - - /* Flush as much pending output as possible */ - if (s->pending != 0) { - flush_pending(strm); - if (strm->avail_out == 0) { - /* Since avail_out is 0, deflate will be called again with - * more output space, but possibly with both pending and - * avail_in equal to zero. There won't be anything to do, - * but this is not an error situation so make sure we - * return OK instead of BUF_ERROR at next call of deflate: - */ - s->last_flush = -1; - return Z_OK; - } - - /* Make sure there is something to do and avoid duplicate consecutive - * flushes. For repeated and useless calls with Z_FINISH, we keep - * returning Z_STREAM_END instead of Z_BUF_ERROR. - */ - } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) && - flush != Z_FINISH) { - ERR_RETURN(strm, Z_BUF_ERROR); - } - - /* User must not provide more input after the first FINISH: */ - if (s->status == FINISH_STATE && strm->avail_in != 0) { - ERR_RETURN(strm, Z_BUF_ERROR); - } - - /* Write the header */ - if (s->status == INIT_STATE && s->wrap == 0) - s->status = BUSY_STATE; - if (s->status == INIT_STATE) { - /* zlib header */ - uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; - uInt level_flags; - - if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2) - level_flags = 0; - else if (s->level < 6) - level_flags = 1; - else if (s->level == 6) - level_flags = 2; - else - level_flags = 3; - header |= (level_flags << 6); - if (s->strstart != 0) header |= PRESET_DICT; - header += 31 - (header % 31); - - putShortMSB(s, header); - - /* Save the adler32 of the preset dictionary: */ - if (s->strstart != 0) { - putShortMSB(s, (uInt)(strm->adler >> 16)); - putShortMSB(s, (uInt)(strm->adler & 0xffff)); - } - strm->adler = adler32(0L, Z_NULL, 0); - s->status = BUSY_STATE; - - /* Compression must start with an empty pending buffer */ - flush_pending(strm); - if (s->pending != 0) { - s->last_flush = -1; - return Z_OK; - } - } -#ifdef GZIP - if (s->status == GZIP_STATE) { - /* gzip header */ - strm->adler = crc32(0L, Z_NULL, 0); - put_byte(s, 31); - put_byte(s, 139); - put_byte(s, 8); - if (s->gzhead == Z_NULL) { - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, s->level == 9 ? 2 : - (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? - 4 : 0)); - put_byte(s, OS_CODE); - s->status = BUSY_STATE; - - /* Compression must start with an empty pending buffer */ - flush_pending(strm); - if (s->pending != 0) { - s->last_flush = -1; - return Z_OK; - } - } - else { - put_byte(s, (s->gzhead->text ? 1 : 0) + - (s->gzhead->hcrc ? 2 : 0) + - (s->gzhead->extra == Z_NULL ? 0 : 4) + - (s->gzhead->name == Z_NULL ? 0 : 8) + - (s->gzhead->comment == Z_NULL ? 0 : 16) - ); - put_byte(s, (Byte)(s->gzhead->time & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff)); - put_byte(s, s->level == 9 ? 2 : - (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? - 4 : 0)); - put_byte(s, s->gzhead->os & 0xff); - if (s->gzhead->extra != Z_NULL) { - put_byte(s, s->gzhead->extra_len & 0xff); - put_byte(s, (s->gzhead->extra_len >> 8) & 0xff); - } - if (s->gzhead->hcrc) - strm->adler = crc32(strm->adler, s->pending_buf, - s->pending); - s->gzindex = 0; - s->status = EXTRA_STATE; - } - } - if (s->status == EXTRA_STATE) { - if (s->gzhead->extra != Z_NULL) { - ulg beg = s->pending; /* start of bytes to update crc */ - uInt left = (s->gzhead->extra_len & 0xffff) - s->gzindex; - while (s->pending + left > s->pending_buf_size) { - uInt copy = s->pending_buf_size - s->pending; - zmemcpy(s->pending_buf + s->pending, - s->gzhead->extra + s->gzindex, copy); - s->pending = s->pending_buf_size; - HCRC_UPDATE(beg); - s->gzindex += copy; - flush_pending(strm); - if (s->pending != 0) { - s->last_flush = -1; - return Z_OK; - } - beg = 0; - left -= copy; - } - zmemcpy(s->pending_buf + s->pending, - s->gzhead->extra + s->gzindex, left); - s->pending += left; - HCRC_UPDATE(beg); - s->gzindex = 0; - } - s->status = NAME_STATE; - } - if (s->status == NAME_STATE) { - if (s->gzhead->name != Z_NULL) { - ulg beg = s->pending; /* start of bytes to update crc */ - int val; - do { - if (s->pending == s->pending_buf_size) { - HCRC_UPDATE(beg); - flush_pending(strm); - if (s->pending != 0) { - s->last_flush = -1; - return Z_OK; - } - beg = 0; - } - val = s->gzhead->name[s->gzindex++]; - put_byte(s, val); - } while (val != 0); - HCRC_UPDATE(beg); - s->gzindex = 0; - } - s->status = COMMENT_STATE; - } - if (s->status == COMMENT_STATE) { - if (s->gzhead->comment != Z_NULL) { - ulg beg = s->pending; /* start of bytes to update crc */ - int val; - do { - if (s->pending == s->pending_buf_size) { - HCRC_UPDATE(beg); - flush_pending(strm); - if (s->pending != 0) { - s->last_flush = -1; - return Z_OK; - } - beg = 0; - } - val = s->gzhead->comment[s->gzindex++]; - put_byte(s, val); - } while (val != 0); - HCRC_UPDATE(beg); - } - s->status = HCRC_STATE; - } - if (s->status == HCRC_STATE) { - if (s->gzhead->hcrc) { - if (s->pending + 2 > s->pending_buf_size) { - flush_pending(strm); - if (s->pending != 0) { - s->last_flush = -1; - return Z_OK; - } - } - put_byte(s, (Byte)(strm->adler & 0xff)); - put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); - strm->adler = crc32(0L, Z_NULL, 0); - } - s->status = BUSY_STATE; - - /* Compression must start with an empty pending buffer */ - flush_pending(strm); - if (s->pending != 0) { - s->last_flush = -1; - return Z_OK; - } - } -#endif - - /* Start a new block or continue the current one. - */ - if (strm->avail_in != 0 || s->lookahead != 0 || - (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) { - block_state bstate; - - bstate = s->level == 0 ? deflate_stored(s, flush) : - s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : - s->strategy == Z_RLE ? deflate_rle(s, flush) : - (*(configuration_table[s->level].func))(s, flush); - - if (bstate == finish_started || bstate == finish_done) { - s->status = FINISH_STATE; - } - if (bstate == need_more || bstate == finish_started) { - if (strm->avail_out == 0) { - s->last_flush = -1; /* avoid BUF_ERROR next call, see above */ - } - return Z_OK; - /* If flush != Z_NO_FLUSH && avail_out == 0, the next call - * of deflate should use the same flush parameter to make sure - * that the flush is complete. So we don't have to output an - * empty block here, this will be done at next call. This also - * ensures that for a very small output buffer, we emit at most - * one empty block. - */ - } - if (bstate == block_done) { - if (flush == Z_PARTIAL_FLUSH) { - _tr_align(s); - } else if (flush != Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */ - _tr_stored_block(s, (char*)0, 0L, 0); - /* For a full flush, this empty block will be recognized - * as a special marker by inflate_sync(). - */ - if (flush == Z_FULL_FLUSH) { - CLEAR_HASH(s); /* forget history */ - if (s->lookahead == 0) { - s->strstart = 0; - s->block_start = 0L; - s->insert = 0; - } - } - } - flush_pending(strm); - if (strm->avail_out == 0) { - s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */ - return Z_OK; - } - } - } - - if (flush != Z_FINISH) return Z_OK; - if (s->wrap <= 0) return Z_STREAM_END; - - /* Write the trailer */ -#ifdef GZIP - if (s->wrap == 2) { - put_byte(s, (Byte)(strm->adler & 0xff)); - put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); - put_byte(s, (Byte)((strm->adler >> 16) & 0xff)); - put_byte(s, (Byte)((strm->adler >> 24) & 0xff)); - put_byte(s, (Byte)(strm->total_in & 0xff)); - put_byte(s, (Byte)((strm->total_in >> 8) & 0xff)); - put_byte(s, (Byte)((strm->total_in >> 16) & 0xff)); - put_byte(s, (Byte)((strm->total_in >> 24) & 0xff)); - } - else -#endif - { - putShortMSB(s, (uInt)(strm->adler >> 16)); - putShortMSB(s, (uInt)(strm->adler & 0xffff)); - } - flush_pending(strm); - /* If avail_out is zero, the application will call deflate again - * to flush the rest. - */ - if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */ - return s->pending != 0 ? Z_OK : Z_STREAM_END; -} - -/* ========================================================================= */ -int ZEXPORT deflateEnd (strm) - z_streamp strm; -{ - int status; - - if (deflateStateCheck(strm)) return Z_STREAM_ERROR; - - status = strm->state->status; - - /* Deallocate in reverse order of allocations: */ - TRY_FREE(strm, strm->state->pending_buf); - TRY_FREE(strm, strm->state->head); - TRY_FREE(strm, strm->state->prev); - TRY_FREE(strm, strm->state->window); - - ZFREE(strm, strm->state); - strm->state = Z_NULL; - - return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK; -} - -/* ========================================================================= - * Copy the source state to the destination state. - * To simplify the source, this is not supported for 16-bit MSDOS (which - * doesn't have enough memory anyway to duplicate compression states). - */ -int ZEXPORT deflateCopy (dest, source) - z_streamp dest; - z_streamp source; -{ -#ifdef MAXSEG_64K - return Z_STREAM_ERROR; -#else - deflate_state *ds; - deflate_state *ss; - - - if (deflateStateCheck(source) || dest == Z_NULL) { - return Z_STREAM_ERROR; - } - - ss = source->state; - - zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream)); - - ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); - if (ds == Z_NULL) return Z_MEM_ERROR; - dest->state = (struct internal_state FAR *) ds; - zmemcpy((voidpf)ds, (voidpf)ss, sizeof(deflate_state)); - ds->strm = dest; - - ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); - ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos)); - ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); - ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, 4); - - if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL || - ds->pending_buf == Z_NULL) { - deflateEnd (dest); - return Z_MEM_ERROR; - } - /* following zmemcpy do not work for 16-bit MSDOS */ - zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); - zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos)); - zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos)); - zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); - - ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); - ds->sym_buf = ds->pending_buf + ds->lit_bufsize; - - ds->l_desc.dyn_tree = ds->dyn_ltree; - ds->d_desc.dyn_tree = ds->dyn_dtree; - ds->bl_desc.dyn_tree = ds->bl_tree; - - return Z_OK; -#endif /* MAXSEG_64K */ -} - -/* =========================================================================== - * Read a new buffer from the current input stream, update the adler32 - * and total number of bytes read. All deflate() input goes through - * this function so some applications may wish to modify it to avoid - * allocating a large strm->next_in buffer and copying from it. - * (See also flush_pending()). - */ -local unsigned read_buf(strm, buf, size) - z_streamp strm; - Bytef *buf; - unsigned size; -{ - unsigned len = strm->avail_in; - - if (len > size) len = size; - if (len == 0) return 0; - - strm->avail_in -= len; - - zmemcpy(buf, strm->next_in, len); - if (strm->state->wrap == 1) { - strm->adler = adler32(strm->adler, buf, len); - } -#ifdef GZIP - else if (strm->state->wrap == 2) { - strm->adler = crc32(strm->adler, buf, len); - } -#endif - strm->next_in += len; - strm->total_in += len; - - return len; -} - -/* =========================================================================== - * Initialize the "longest match" routines for a new zlib stream - */ -local void lm_init (s) - deflate_state *s; -{ - s->window_size = (ulg)2L*s->w_size; - - CLEAR_HASH(s); - - /* Set the default configuration parameters: - */ - s->max_lazy_match = configuration_table[s->level].max_lazy; - s->good_match = configuration_table[s->level].good_length; - s->nice_match = configuration_table[s->level].nice_length; - s->max_chain_length = configuration_table[s->level].max_chain; - - s->strstart = 0; - s->block_start = 0L; - s->lookahead = 0; - s->insert = 0; - s->match_length = s->prev_length = MIN_MATCH-1; - s->match_available = 0; - s->ins_h = 0; -#ifndef FASTEST -#ifdef ASMV - match_init(); /* initialize the asm code */ -#endif -#endif -} - -#ifndef FASTEST -/* =========================================================================== - * Set match_start to the longest match starting at the given string and - * return its length. Matches shorter or equal to prev_length are discarded, - * in which case the result is equal to prev_length and match_start is - * garbage. - * IN assertions: cur_match is the head of the hash chain for the current - * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 - * OUT assertion: the match length is not greater than s->lookahead. - */ -#ifndef ASMV -/* For 80x86 and 680x0, an optimized version will be provided in match.asm or - * match.S. The code will be functionally equivalent. - */ -local uInt longest_match(s, cur_match) - deflate_state *s; - IPos cur_match; /* current match */ -{ - unsigned chain_length = s->max_chain_length;/* max hash chain length */ - register Bytef *scan = s->window + s->strstart; /* current string */ - register Bytef *match; /* matched string */ - register int len; /* length of current match */ - int best_len = (int)s->prev_length; /* best match length so far */ - int nice_match = s->nice_match; /* stop if match long enough */ - IPos limit = s->strstart > (IPos)MAX_DIST(s) ? - s->strstart - (IPos)MAX_DIST(s) : NIL; - /* Stop when cur_match becomes <= limit. To simplify the code, - * we prevent matches with the string of window index 0. - */ - Posf *prev = s->prev; - uInt wmask = s->w_mask; - -#ifdef UNALIGNED_OK - /* Compare two bytes at a time. Note: this is not always beneficial. - * Try with and without -DUNALIGNED_OK to check. - */ - register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1; - register ush scan_start = *(ushf*)scan; - register ush scan_end = *(ushf*)(scan+best_len-1); -#else - register Bytef *strend = s->window + s->strstart + MAX_MATCH; - register Byte scan_end1 = scan[best_len-1]; - register Byte scan_end = scan[best_len]; -#endif - - /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. - * It is easy to get rid of this optimization if necessary. - */ - Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); - - /* Do not waste too much time if we already have a good match: */ - if (s->prev_length >= s->good_match) { - chain_length >>= 2; - } - /* Do not look for matches beyond the end of the input. This is necessary - * to make deflate deterministic. - */ - if ((uInt)nice_match > s->lookahead) nice_match = (int)s->lookahead; - - Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); - - do { - Assert(cur_match < s->strstart, "no future"); - match = s->window + cur_match; - - /* Skip to next match if the match length cannot increase - * or if the match length is less than 2. Note that the checks below - * for insufficient lookahead only occur occasionally for performance - * reasons. Therefore uninitialized memory will be accessed, and - * conditional jumps will be made that depend on those values. - * However the length of the match is limited to the lookahead, so - * the output of deflate is not affected by the uninitialized values. - */ -#if (defined(UNALIGNED_OK) && MAX_MATCH == 258) - /* This code assumes sizeof(unsigned short) == 2. Do not use - * UNALIGNED_OK if your compiler uses a different size. - */ - if (*(ushf*)(match+best_len-1) != scan_end || - *(ushf*)match != scan_start) continue; - - /* It is not necessary to compare scan[2] and match[2] since they are - * always equal when the other bytes match, given that the hash keys - * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at - * strstart+3, +5, ... up to strstart+257. We check for insufficient - * lookahead only every 4th comparison; the 128th check will be made - * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is - * necessary to put more guard bytes at the end of the window, or - * to check more often for insufficient lookahead. - */ - Assert(scan[2] == match[2], "scan[2]?"); - scan++, match++; - do { - } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) && - *(ushf*)(scan+=2) == *(ushf*)(match+=2) && - *(ushf*)(scan+=2) == *(ushf*)(match+=2) && - *(ushf*)(scan+=2) == *(ushf*)(match+=2) && - scan < strend); - /* The funny "do {}" generates better code on most compilers */ - - /* Here, scan <= window+strstart+257 */ - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); - if (*scan == *match) scan++; - - len = (MAX_MATCH - 1) - (int)(strend-scan); - scan = strend - (MAX_MATCH-1); - -#else /* UNALIGNED_OK */ - - if (match[best_len] != scan_end || - match[best_len-1] != scan_end1 || - *match != *scan || - *++match != scan[1]) continue; - - /* The check at best_len-1 can be removed because it will be made - * again later. (This heuristic is not always a win.) - * It is not necessary to compare scan[2] and match[2] since they - * are always equal when the other bytes match, given that - * the hash keys are equal and that HASH_BITS >= 8. - */ - scan += 2, match++; - Assert(*scan == *match, "match[2]?"); - - /* We check for insufficient lookahead only every 8th comparison; - * the 256th check will be made at strstart+258. - */ - do { - } while (*++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - scan < strend); - - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); - - len = MAX_MATCH - (int)(strend - scan); - scan = strend - MAX_MATCH; - -#endif /* UNALIGNED_OK */ - - if (len > best_len) { - s->match_start = cur_match; - best_len = len; - if (len >= nice_match) break; -#ifdef UNALIGNED_OK - scan_end = *(ushf*)(scan+best_len-1); -#else - scan_end1 = scan[best_len-1]; - scan_end = scan[best_len]; -#endif - } - } while ((cur_match = prev[cur_match & wmask]) > limit - && --chain_length != 0); - - if ((uInt)best_len <= s->lookahead) return (uInt)best_len; - return s->lookahead; -} -#endif /* ASMV */ - -#else /* FASTEST */ - -/* --------------------------------------------------------------------------- - * Optimized version for FASTEST only - */ -local uInt longest_match(s, cur_match) - deflate_state *s; - IPos cur_match; /* current match */ -{ - register Bytef *scan = s->window + s->strstart; /* current string */ - register Bytef *match; /* matched string */ - register int len; /* length of current match */ - register Bytef *strend = s->window + s->strstart + MAX_MATCH; - - /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. - * It is easy to get rid of this optimization if necessary. - */ - Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); - - Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); - - Assert(cur_match < s->strstart, "no future"); - - match = s->window + cur_match; - - /* Return failure if the match length is less than 2: - */ - if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1; - - /* The check at best_len-1 can be removed because it will be made - * again later. (This heuristic is not always a win.) - * It is not necessary to compare scan[2] and match[2] since they - * are always equal when the other bytes match, given that - * the hash keys are equal and that HASH_BITS >= 8. - */ - scan += 2, match += 2; - Assert(*scan == *match, "match[2]?"); - - /* We check for insufficient lookahead only every 8th comparison; - * the 256th check will be made at strstart+258. - */ - do { - } while (*++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - *++scan == *++match && *++scan == *++match && - scan < strend); - - Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); - - len = MAX_MATCH - (int)(strend - scan); - - if (len < MIN_MATCH) return MIN_MATCH - 1; - - s->match_start = cur_match; - return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead; -} - -#endif /* FASTEST */ - -#ifdef ZLIB_DEBUG - -#define EQUAL 0 -/* result of memcmp for equal strings */ - -/* =========================================================================== - * Check that the match at match_start is indeed a match. - */ -local void check_match(s, start, match, length) - deflate_state *s; - IPos start, match; - int length; -{ - /* check that the match is indeed a match */ - if (zmemcmp(s->window + match, - s->window + start, length) != EQUAL) { - fprintf(stderr, " start %u, match %u, length %d\n", - start, match, length); - do { - fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); - } while (--length != 0); - z_error("invalid match"); - } - if (z_verbose > 1) { - fprintf(stderr,"\\[%d,%d]", start-match, length); - do { putc(s->window[start++], stderr); } while (--length != 0); - } -} -#else -# define check_match(s, start, match, length) -#endif /* ZLIB_DEBUG */ - -/* =========================================================================== - * Fill the window when the lookahead becomes insufficient. - * Updates strstart and lookahead. - * - * IN assertion: lookahead < MIN_LOOKAHEAD - * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD - * At least one byte has been read, or avail_in == 0; reads are - * performed for at least two bytes (required for the zip translate_eol - * option -- not supported here). - */ -local void fill_window(s) - deflate_state *s; -{ - unsigned n; - unsigned more; /* Amount of free space at the end of the window. */ - uInt wsize = s->w_size; - - Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead"); - - do { - more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); - - /* Deal with !@#$% 64K limit: */ - if (sizeof(int) <= 2) { - if (more == 0 && s->strstart == 0 && s->lookahead == 0) { - more = wsize; - - } else if (more == (unsigned)(-1)) { - /* Very unlikely, but possible on 16 bit machine if - * strstart == 0 && lookahead == 1 (input done a byte at time) - */ - more--; - } - } - - /* If the window is almost full and there is insufficient lookahead, - * move the upper half to the lower one to make room in the upper half. - */ - if (s->strstart >= wsize+MAX_DIST(s)) { - - zmemcpy(s->window, s->window+wsize, (unsigned)wsize - more); - s->match_start -= wsize; - s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ - s->block_start -= (long) wsize; - if (s->insert > s->strstart) - s->insert = s->strstart; - slide_hash(s); - more += wsize; - } - if (s->strm->avail_in == 0) break; - - /* If there was no sliding: - * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && - * more == window_size - lookahead - strstart - * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) - * => more >= window_size - 2*WSIZE + 2 - * In the BIG_MEM or MMAP case (not yet supported), - * window_size == input_size + MIN_LOOKAHEAD && - * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. - * Otherwise, window_size == 2*WSIZE so more >= 2. - * If there was sliding, more >= WSIZE. So in all cases, more >= 2. - */ - Assert(more >= 2, "more < 2"); - - n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); - s->lookahead += n; - - /* Initialize the hash value now that we have some input: */ - if (s->lookahead + s->insert >= MIN_MATCH) { - uInt str = s->strstart - s->insert; - s->ins_h = s->window[str]; - UPDATE_HASH(s, s->ins_h, s->window[str + 1]); -#if MIN_MATCH != 3 - Call UPDATE_HASH() MIN_MATCH-3 more times -#endif - while (s->insert) { - UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); -#ifndef FASTEST - s->prev[str & s->w_mask] = s->head[s->ins_h]; -#endif - s->head[s->ins_h] = (Pos)str; - str++; - s->insert--; - if (s->lookahead + s->insert < MIN_MATCH) - break; - } - } - /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, - * but this is not important since only literal bytes will be emitted. - */ - - } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); - - /* If the WIN_INIT bytes after the end of the current data have never been - * written, then zero those bytes in order to avoid memory check reports of - * the use of uninitialized (or uninitialised as Julian writes) bytes by - * the longest match routines. Update the high water mark for the next - * time through here. WIN_INIT is set to MAX_MATCH since the longest match - * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead. - */ - if (s->high_water < s->window_size) { - ulg curr = s->strstart + (ulg)(s->lookahead); - ulg init; - - if (s->high_water < curr) { - /* Previous high water mark below current data -- zero WIN_INIT - * bytes or up to end of window, whichever is less. - */ - init = s->window_size - curr; - if (init > WIN_INIT) - init = WIN_INIT; - zmemzero(s->window + curr, (unsigned)init); - s->high_water = curr + init; - } - else if (s->high_water < (ulg)curr + WIN_INIT) { - /* High water mark at or above current data, but below current data - * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up - * to end of window, whichever is less. - */ - init = (ulg)curr + WIN_INIT - s->high_water; - if (init > s->window_size - s->high_water) - init = s->window_size - s->high_water; - zmemzero(s->window + s->high_water, (unsigned)init); - s->high_water += init; - } - } - - Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, - "not enough room for search"); -} - -/* =========================================================================== - * Flush the current block, with given end-of-file flag. - * IN assertion: strstart is set to the end of the current match. - */ -#define FLUSH_BLOCK_ONLY(s, last) { \ - _tr_flush_block(s, (s->block_start >= 0L ? \ - (charf *)&s->window[(unsigned)s->block_start] : \ - (charf *)Z_NULL), \ - (ulg)((long)s->strstart - s->block_start), \ - (last)); \ - s->block_start = s->strstart; \ - flush_pending(s->strm); \ - Tracev((stderr,"[FLUSH]")); \ -} - -/* Same but force premature exit if necessary. */ -#define FLUSH_BLOCK(s, last) { \ - FLUSH_BLOCK_ONLY(s, last); \ - if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \ -} - -/* Maximum stored block length in deflate format (not including header). */ -#define MAX_STORED 65535 - -/* Minimum of a and b. */ -#define MIN(a, b) ((a) > (b) ? (b) : (a)) - -/* =========================================================================== - * Copy without compression as much as possible from the input stream, return - * the current block state. - * - * In case deflateParams() is used to later switch to a non-zero compression - * level, s->matches (otherwise unused when storing) keeps track of the number - * of hash table slides to perform. If s->matches is 1, then one hash table - * slide will be done when switching. If s->matches is 2, the maximum value - * allowed here, then the hash table will be cleared, since two or more slides - * is the same as a clear. - * - * deflate_stored() is written to minimize the number of times an input byte is - * copied. It is most efficient with large input and output buffers, which - * maximizes the opportunites to have a single copy from next_in to next_out. - */ -local block_state deflate_stored(s, flush) - deflate_state *s; - int flush; -{ - /* Smallest worthy block size when not flushing or finishing. By default - * this is 32K. This can be as small as 507 bytes for memLevel == 1. For - * large input and output buffers, the stored block size will be larger. - */ - unsigned min_block = MIN(s->pending_buf_size - 5, s->w_size); - - /* Copy as many min_block or larger stored blocks directly to next_out as - * possible. If flushing, copy the remaining available input to next_out as - * stored blocks, if there is enough space. - */ - unsigned len, left, have, last = 0; - unsigned used = s->strm->avail_in; - do { - /* Set len to the maximum size block that we can copy directly with the - * available input data and output space. Set left to how much of that - * would be copied from what's left in the window. - */ - len = MAX_STORED; /* maximum deflate stored block length */ - have = (s->bi_valid + 42) >> 3; /* number of header bytes */ - if (s->strm->avail_out < have) /* need room for header */ - break; - /* maximum stored block length that will fit in avail_out: */ - have = s->strm->avail_out - have; - left = s->strstart - s->block_start; /* bytes left in window */ - if (len > (ulg)left + s->strm->avail_in) - len = left + s->strm->avail_in; /* limit len to the input */ - if (len > have) - len = have; /* limit len to the output */ - - /* If the stored block would be less than min_block in length, or if - * unable to copy all of the available input when flushing, then try - * copying to the window and the pending buffer instead. Also don't - * write an empty block when flushing -- deflate() does that. - */ - if (len < min_block && ((len == 0 && flush != Z_FINISH) || - flush == Z_NO_FLUSH || - len != left + s->strm->avail_in)) - break; - - /* Make a dummy stored block in pending to get the header bytes, - * including any pending bits. This also updates the debugging counts. - */ - last = flush == Z_FINISH && len == left + s->strm->avail_in ? 1 : 0; - _tr_stored_block(s, (char *)0, 0L, last); - - /* Replace the lengths in the dummy stored block with len. */ - s->pending_buf[s->pending - 4] = len; - s->pending_buf[s->pending - 3] = len >> 8; - s->pending_buf[s->pending - 2] = ~len; - s->pending_buf[s->pending - 1] = ~len >> 8; - - /* Write the stored block header bytes. */ - flush_pending(s->strm); - -#ifdef ZLIB_DEBUG - /* Update debugging counts for the data about to be copied. */ - s->compressed_len += len << 3; - s->bits_sent += len << 3; -#endif - - /* Copy uncompressed bytes from the window to next_out. */ - if (left) { - if (left > len) - left = len; - zmemcpy(s->strm->next_out, s->window + s->block_start, left); - s->strm->next_out += left; - s->strm->avail_out -= left; - s->strm->total_out += left; - s->block_start += left; - len -= left; - } - - /* Copy uncompressed bytes directly from next_in to next_out, updating - * the check value. - */ - if (len) { - read_buf(s->strm, s->strm->next_out, len); - s->strm->next_out += len; - s->strm->avail_out -= len; - s->strm->total_out += len; - } - } while (last == 0); - - /* Update the sliding window with the last s->w_size bytes of the copied - * data, or append all of the copied data to the existing window if less - * than s->w_size bytes were copied. Also update the number of bytes to - * insert in the hash tables, in the event that deflateParams() switches to - * a non-zero compression level. - */ - used -= s->strm->avail_in; /* number of input bytes directly copied */ - if (used) { - /* If any input was used, then no unused input remains in the window, - * therefore s->block_start == s->strstart. - */ - if (used >= s->w_size) { /* supplant the previous history */ - s->matches = 2; /* clear hash */ - zmemcpy(s->window, s->strm->next_in - s->w_size, s->w_size); - s->strstart = s->w_size; - s->insert = s->strstart; - } - else { - if (s->window_size - s->strstart <= used) { - /* Slide the window down. */ - s->strstart -= s->w_size; - zmemcpy(s->window, s->window + s->w_size, s->strstart); - if (s->matches < 2) - s->matches++; /* add a pending slide_hash() */ - if (s->insert > s->strstart) - s->insert = s->strstart; - } - zmemcpy(s->window + s->strstart, s->strm->next_in - used, used); - s->strstart += used; - s->insert += MIN(used, s->w_size - s->insert); - } - s->block_start = s->strstart; - } - if (s->high_water < s->strstart) - s->high_water = s->strstart; - - /* If the last block was written to next_out, then done. */ - if (last) - return finish_done; - - /* If flushing and all input has been consumed, then done. */ - if (flush != Z_NO_FLUSH && flush != Z_FINISH && - s->strm->avail_in == 0 && (long)s->strstart == s->block_start) - return block_done; - - /* Fill the window with any remaining input. */ - have = s->window_size - s->strstart; - if (s->strm->avail_in > have && s->block_start >= (long)s->w_size) { - /* Slide the window down. */ - s->block_start -= s->w_size; - s->strstart -= s->w_size; - zmemcpy(s->window, s->window + s->w_size, s->strstart); - if (s->matches < 2) - s->matches++; /* add a pending slide_hash() */ - have += s->w_size; /* more space now */ - if (s->insert > s->strstart) - s->insert = s->strstart; - } - if (have > s->strm->avail_in) - have = s->strm->avail_in; - if (have) { - read_buf(s->strm, s->window + s->strstart, have); - s->strstart += have; - s->insert += MIN(have, s->w_size - s->insert); - } - if (s->high_water < s->strstart) - s->high_water = s->strstart; - - /* There was not enough avail_out to write a complete worthy or flushed - * stored block to next_out. Write a stored block to pending instead, if we - * have enough input for a worthy block, or if flushing and there is enough - * room for the remaining input as a stored block in the pending buffer. - */ - have = (s->bi_valid + 42) >> 3; /* number of header bytes */ - /* maximum stored block length that will fit in pending: */ - have = MIN(s->pending_buf_size - have, MAX_STORED); - min_block = MIN(have, s->w_size); - left = s->strstart - s->block_start; - if (left >= min_block || - ((left || flush == Z_FINISH) && flush != Z_NO_FLUSH && - s->strm->avail_in == 0 && left <= have)) { - len = MIN(left, have); - last = flush == Z_FINISH && s->strm->avail_in == 0 && - len == left ? 1 : 0; - _tr_stored_block(s, (charf *)s->window + s->block_start, len, last); - s->block_start += len; - flush_pending(s->strm); - } - - /* We've done all we can with the available input and output. */ - return last ? finish_started : need_more; -} - -/* =========================================================================== - * Compress as much as possible from the input stream, return the current - * block state. - * This function does not perform lazy evaluation of matches and inserts - * new strings in the dictionary only for unmatched strings or for short - * matches. It is used only for the fast compression options. - */ -local block_state deflate_fast(s, flush) - deflate_state *s; - int flush; -{ - IPos hash_head; /* head of the hash chain */ - int bflush; /* set if current block must be flushed */ - - for (;;) { - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the next match, plus MIN_MATCH bytes to insert the - * string following the next match. - */ - if (s->lookahead < MIN_LOOKAHEAD) { - fill_window(s); - if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { - return need_more; - } - if (s->lookahead == 0) break; /* flush the current block */ - } - - /* Insert the string window[strstart .. strstart+2] in the - * dictionary, and set hash_head to the head of the hash chain: - */ - hash_head = NIL; - if (s->lookahead >= MIN_MATCH) { - INSERT_STRING(s, s->strstart, hash_head); - } - - /* Find the longest match, discarding those <= prev_length. - * At this point we have always match_length < MIN_MATCH - */ - if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) { - /* To simplify the code, we prevent matches with the string - * of window index 0 (in particular we have to avoid a match - * of the string with itself at the start of the input file). - */ - s->match_length = longest_match (s, hash_head); - /* longest_match() sets match_start */ - } - if (s->match_length >= MIN_MATCH) { - check_match(s, s->strstart, s->match_start, s->match_length); - - _tr_tally_dist(s, s->strstart - s->match_start, - s->match_length - MIN_MATCH, bflush); - - s->lookahead -= s->match_length; - - /* Insert new strings in the hash table only if the match length - * is not too large. This saves time but degrades compression. - */ -#ifndef FASTEST - if (s->match_length <= s->max_insert_length && - s->lookahead >= MIN_MATCH) { - s->match_length--; /* string at strstart already in table */ - do { - s->strstart++; - INSERT_STRING(s, s->strstart, hash_head); - /* strstart never exceeds WSIZE-MAX_MATCH, so there are - * always MIN_MATCH bytes ahead. - */ - } while (--s->match_length != 0); - s->strstart++; - } else -#endif - { - s->strstart += s->match_length; - s->match_length = 0; - s->ins_h = s->window[s->strstart]; - UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]); -#if MIN_MATCH != 3 - Call UPDATE_HASH() MIN_MATCH-3 more times -#endif - /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not - * matter since it will be recomputed at next deflate call. - */ - } - } else { - /* No match, output a literal byte */ - Tracevv((stderr,"%c", s->window[s->strstart])); - _tr_tally_lit (s, s->window[s->strstart], bflush); - s->lookahead--; - s->strstart++; - } - if (bflush) FLUSH_BLOCK(s, 0); - } - s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1; - if (flush == Z_FINISH) { - FLUSH_BLOCK(s, 1); - return finish_done; - } - if (s->sym_next) - FLUSH_BLOCK(s, 0); - return block_done; -} - -#ifndef FASTEST -/* =========================================================================== - * Same as above, but achieves better compression. We use a lazy - * evaluation for matches: a match is finally adopted only if there is - * no better match at the next window position. - */ -local block_state deflate_slow(s, flush) - deflate_state *s; - int flush; -{ - IPos hash_head; /* head of hash chain */ - int bflush; /* set if current block must be flushed */ - - /* Process the input block. */ - for (;;) { - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the next match, plus MIN_MATCH bytes to insert the - * string following the next match. - */ - if (s->lookahead < MIN_LOOKAHEAD) { - fill_window(s); - if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { - return need_more; - } - if (s->lookahead == 0) break; /* flush the current block */ - } - - /* Insert the string window[strstart .. strstart+2] in the - * dictionary, and set hash_head to the head of the hash chain: - */ - hash_head = NIL; - if (s->lookahead >= MIN_MATCH) { - INSERT_STRING(s, s->strstart, hash_head); - } - - /* Find the longest match, discarding those <= prev_length. - */ - s->prev_length = s->match_length, s->prev_match = s->match_start; - s->match_length = MIN_MATCH-1; - - if (hash_head != NIL && s->prev_length < s->max_lazy_match && - s->strstart - hash_head <= MAX_DIST(s)) { - /* To simplify the code, we prevent matches with the string - * of window index 0 (in particular we have to avoid a match - * of the string with itself at the start of the input file). - */ - s->match_length = longest_match (s, hash_head); - /* longest_match() sets match_start */ - - if (s->match_length <= 5 && (s->strategy == Z_FILTERED -#if TOO_FAR <= 32767 - || (s->match_length == MIN_MATCH && - s->strstart - s->match_start > TOO_FAR) -#endif - )) { - - /* If prev_match is also MIN_MATCH, match_start is garbage - * but we will ignore the current match anyway. - */ - s->match_length = MIN_MATCH-1; - } - } - /* If there was a match at the previous step and the current - * match is not better, output the previous match: - */ - if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) { - uInt max_insert = s->strstart + s->lookahead - MIN_MATCH; - /* Do not insert strings in hash table beyond this. */ - - check_match(s, s->strstart-1, s->prev_match, s->prev_length); - - _tr_tally_dist(s, s->strstart -1 - s->prev_match, - s->prev_length - MIN_MATCH, bflush); - - /* Insert in hash table all strings up to the end of the match. - * strstart-1 and strstart are already inserted. If there is not - * enough lookahead, the last two strings are not inserted in - * the hash table. - */ - s->lookahead -= s->prev_length-1; - s->prev_length -= 2; - do { - if (++s->strstart <= max_insert) { - INSERT_STRING(s, s->strstart, hash_head); - } - } while (--s->prev_length != 0); - s->match_available = 0; - s->match_length = MIN_MATCH-1; - s->strstart++; - - if (bflush) FLUSH_BLOCK(s, 0); - - } else if (s->match_available) { - /* If there was no match at the previous position, output a - * single literal. If there was a match but the current match - * is longer, truncate the previous match to a single literal. - */ - Tracevv((stderr,"%c", s->window[s->strstart-1])); - _tr_tally_lit(s, s->window[s->strstart-1], bflush); - if (bflush) { - FLUSH_BLOCK_ONLY(s, 0); - } - s->strstart++; - s->lookahead--; - if (s->strm->avail_out == 0) return need_more; - } else { - /* There is no previous match to compare with, wait for - * the next step to decide. - */ - s->match_available = 1; - s->strstart++; - s->lookahead--; - } - } - Assert (flush != Z_NO_FLUSH, "no flush?"); - if (s->match_available) { - Tracevv((stderr,"%c", s->window[s->strstart-1])); - _tr_tally_lit(s, s->window[s->strstart-1], bflush); - s->match_available = 0; - } - s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1; - if (flush == Z_FINISH) { - FLUSH_BLOCK(s, 1); - return finish_done; - } - if (s->sym_next) - FLUSH_BLOCK(s, 0); - return block_done; -} -#endif /* FASTEST */ - -/* =========================================================================== - * For Z_RLE, simply look for runs of bytes, generate matches only of distance - * one. Do not maintain a hash table. (It will be regenerated if this run of - * deflate switches away from Z_RLE.) - */ -local block_state deflate_rle(s, flush) - deflate_state *s; - int flush; -{ - int bflush; /* set if current block must be flushed */ - uInt prev; /* byte at distance one to match */ - Bytef *scan, *strend; /* scan goes up to strend for length of run */ - - for (;;) { - /* Make sure that we always have enough lookahead, except - * at the end of the input file. We need MAX_MATCH bytes - * for the longest run, plus one for the unrolled loop. - */ - if (s->lookahead <= MAX_MATCH) { - fill_window(s); - if (s->lookahead <= MAX_MATCH && flush == Z_NO_FLUSH) { - return need_more; - } - if (s->lookahead == 0) break; /* flush the current block */ - } - - /* See how many times the previous byte repeats */ - s->match_length = 0; - if (s->lookahead >= MIN_MATCH && s->strstart > 0) { - scan = s->window + s->strstart - 1; - prev = *scan; - if (prev == *++scan && prev == *++scan && prev == *++scan) { - strend = s->window + s->strstart + MAX_MATCH; - do { - } while (prev == *++scan && prev == *++scan && - prev == *++scan && prev == *++scan && - prev == *++scan && prev == *++scan && - prev == *++scan && prev == *++scan && - scan < strend); - s->match_length = MAX_MATCH - (uInt)(strend - scan); - if (s->match_length > s->lookahead) - s->match_length = s->lookahead; - } - Assert(scan <= s->window+(uInt)(s->window_size-1), "wild scan"); - } - - /* Emit match if have run of MIN_MATCH or longer, else emit literal */ - if (s->match_length >= MIN_MATCH) { - check_match(s, s->strstart, s->strstart - 1, s->match_length); - - _tr_tally_dist(s, 1, s->match_length - MIN_MATCH, bflush); - - s->lookahead -= s->match_length; - s->strstart += s->match_length; - s->match_length = 0; - } else { - /* No match, output a literal byte */ - Tracevv((stderr,"%c", s->window[s->strstart])); - _tr_tally_lit (s, s->window[s->strstart], bflush); - s->lookahead--; - s->strstart++; - } - if (bflush) FLUSH_BLOCK(s, 0); - } - s->insert = 0; - if (flush == Z_FINISH) { - FLUSH_BLOCK(s, 1); - return finish_done; - } - if (s->sym_next) - FLUSH_BLOCK(s, 0); - return block_done; -} - -/* =========================================================================== - * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table. - * (It will be regenerated if this run of deflate switches away from Huffman.) - */ -local block_state deflate_huff(s, flush) - deflate_state *s; - int flush; -{ - int bflush; /* set if current block must be flushed */ - - for (;;) { - /* Make sure that we have a literal to write. */ - if (s->lookahead == 0) { - fill_window(s); - if (s->lookahead == 0) { - if (flush == Z_NO_FLUSH) - return need_more; - break; /* flush the current block */ - } - } - - /* Output a literal byte */ - s->match_length = 0; - Tracevv((stderr,"%c", s->window[s->strstart])); - _tr_tally_lit (s, s->window[s->strstart], bflush); - s->lookahead--; - s->strstart++; - if (bflush) FLUSH_BLOCK(s, 0); - } - s->insert = 0; - if (flush == Z_FINISH) { - FLUSH_BLOCK(s, 1); - return finish_done; - } - if (s->sym_next) - FLUSH_BLOCK(s, 0); - return block_done; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/deflate.h b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/deflate.h deleted file mode 100644 index 17c2261..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/deflate.h +++ /dev/null @@ -1,346 +0,0 @@ -/* deflate.h -- internal compression state - * Copyright (C) 1995-2018 Jean-loup Gailly - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* @(#) $Id$ */ - -#ifndef DEFLATE_H -#define DEFLATE_H - -#include "zutil.h" - -/* define NO_GZIP when compiling if you want to disable gzip header and - trailer creation by deflate(). NO_GZIP would be used to avoid linking in - the crc code when it is not needed. For shared libraries, gzip encoding - should be left enabled. */ -#ifndef NO_GZIP -# define GZIP -#endif - -/* =========================================================================== - * Internal compression state. - */ - -#define LENGTH_CODES 29 -/* number of length codes, not counting the special END_BLOCK code */ - -#define LITERALS 256 -/* number of literal bytes 0..255 */ - -#define L_CODES (LITERALS+1+LENGTH_CODES) -/* number of Literal or Length codes, including the END_BLOCK code */ - -#define D_CODES 30 -/* number of distance codes */ - -#define BL_CODES 19 -/* number of codes used to transfer the bit lengths */ - -#define HEAP_SIZE (2*L_CODES+1) -/* maximum heap size */ - -#define MAX_BITS 15 -/* All codes must not exceed MAX_BITS bits */ - -#define Buf_size 16 -/* size of bit buffer in bi_buf */ - -#define INIT_STATE 42 /* zlib header -> BUSY_STATE */ -#ifdef GZIP -# define GZIP_STATE 57 /* gzip header -> BUSY_STATE | EXTRA_STATE */ -#endif -#define EXTRA_STATE 69 /* gzip extra block -> NAME_STATE */ -#define NAME_STATE 73 /* gzip file name -> COMMENT_STATE */ -#define COMMENT_STATE 91 /* gzip comment -> HCRC_STATE */ -#define HCRC_STATE 103 /* gzip header CRC -> BUSY_STATE */ -#define BUSY_STATE 113 /* deflate -> FINISH_STATE */ -#define FINISH_STATE 666 /* stream complete */ -/* Stream status */ - - -/* Data structure describing a single value and its code string. */ -typedef struct ct_data_s { - union { - ush freq; /* frequency count */ - ush code; /* bit string */ - } fc; - union { - ush dad; /* father node in Huffman tree */ - ush len; /* length of bit string */ - } dl; -} FAR ct_data; - -#define Freq fc.freq -#define Code fc.code -#define Dad dl.dad -#define Len dl.len - -typedef struct static_tree_desc_s static_tree_desc; - -typedef struct tree_desc_s { - ct_data *dyn_tree; /* the dynamic tree */ - int max_code; /* largest code with non zero frequency */ - const static_tree_desc *stat_desc; /* the corresponding static tree */ -} FAR tree_desc; - -typedef ush Pos; -typedef Pos FAR Posf; -typedef unsigned IPos; - -/* A Pos is an index in the character window. We use short instead of int to - * save space in the various tables. IPos is used only for parameter passing. - */ - -typedef struct internal_state { - z_streamp strm; /* pointer back to this zlib stream */ - int status; /* as the name implies */ - Bytef *pending_buf; /* output still pending */ - ulg pending_buf_size; /* size of pending_buf */ - Bytef *pending_out; /* next pending byte to output to the stream */ - ulg pending; /* nb of bytes in the pending buffer */ - int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ - gz_headerp gzhead; /* gzip header information to write */ - ulg gzindex; /* where in extra, name, or comment */ - Byte method; /* can only be DEFLATED */ - int last_flush; /* value of flush param for previous deflate call */ - - /* used by deflate.c: */ - - uInt w_size; /* LZ77 window size (32K by default) */ - uInt w_bits; /* log2(w_size) (8..16) */ - uInt w_mask; /* w_size - 1 */ - - Bytef *window; - /* Sliding window. Input bytes are read into the second half of the window, - * and move to the first half later to keep a dictionary of at least wSize - * bytes. With this organization, matches are limited to a distance of - * wSize-MAX_MATCH bytes, but this ensures that IO is always - * performed with a length multiple of the block size. Also, it limits - * the window size to 64K, which is quite useful on MSDOS. - * To do: use the user input buffer as sliding window. - */ - - ulg window_size; - /* Actual size of window: 2*wSize, except when the user input buffer - * is directly used as sliding window. - */ - - Posf *prev; - /* Link to older string with same hash index. To limit the size of this - * array to 64K, this link is maintained only for the last 32K strings. - * An index in this array is thus a window index modulo 32K. - */ - - Posf *head; /* Heads of the hash chains or NIL. */ - - uInt ins_h; /* hash index of string to be inserted */ - uInt hash_size; /* number of elements in hash table */ - uInt hash_bits; /* log2(hash_size) */ - uInt hash_mask; /* hash_size-1 */ - - uInt hash_shift; - /* Number of bits by which ins_h must be shifted at each input - * step. It must be such that after MIN_MATCH steps, the oldest - * byte no longer takes part in the hash key, that is: - * hash_shift * MIN_MATCH >= hash_bits - */ - - long block_start; - /* Window position at the beginning of the current output block. Gets - * negative when the window is moved backwards. - */ - - uInt match_length; /* length of best match */ - IPos prev_match; /* previous match */ - int match_available; /* set if previous match exists */ - uInt strstart; /* start of string to insert */ - uInt match_start; /* start of matching string */ - uInt lookahead; /* number of valid bytes ahead in window */ - - uInt prev_length; - /* Length of the best match at previous step. Matches not greater than this - * are discarded. This is used in the lazy match evaluation. - */ - - uInt max_chain_length; - /* To speed up deflation, hash chains are never searched beyond this - * length. A higher limit improves compression ratio but degrades the - * speed. - */ - - uInt max_lazy_match; - /* Attempt to find a better match only when the current match is strictly - * smaller than this value. This mechanism is used only for compression - * levels >= 4. - */ -# define max_insert_length max_lazy_match - /* Insert new strings in the hash table only if the match length is not - * greater than this length. This saves time but degrades compression. - * max_insert_length is used only for compression levels <= 3. - */ - - int level; /* compression level (1..9) */ - int strategy; /* favor or force Huffman coding*/ - - uInt good_match; - /* Use a faster search when the previous match is longer than this */ - - int nice_match; /* Stop searching when current match exceeds this */ - - /* used by trees.c: */ - /* Didn't use ct_data typedef below to suppress compiler warning */ - struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ - struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ - struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ - - struct tree_desc_s l_desc; /* desc. for literal tree */ - struct tree_desc_s d_desc; /* desc. for distance tree */ - struct tree_desc_s bl_desc; /* desc. for bit length tree */ - - ush bl_count[MAX_BITS+1]; - /* number of codes at each bit length for an optimal tree */ - - int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ - int heap_len; /* number of elements in the heap */ - int heap_max; /* element of largest frequency */ - /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. - * The same heap array is used to build all trees. - */ - - uch depth[2*L_CODES+1]; - /* Depth of each subtree used as tie breaker for trees of equal frequency - */ - - uchf *sym_buf; /* buffer for distances and literals/lengths */ - - uInt lit_bufsize; - /* Size of match buffer for literals/lengths. There are 4 reasons for - * limiting lit_bufsize to 64K: - * - frequencies can be kept in 16 bit counters - * - if compression is not successful for the first block, all input - * data is still in the window so we can still emit a stored block even - * when input comes from standard input. (This can also be done for - * all blocks if lit_bufsize is not greater than 32K.) - * - if compression is not successful for a file smaller than 64K, we can - * even emit a stored file instead of a stored block (saving 5 bytes). - * This is applicable only for zip (not gzip or zlib). - * - creating new Huffman trees less frequently may not provide fast - * adaptation to changes in the input data statistics. (Take for - * example a binary file with poorly compressible code followed by - * a highly compressible string table.) Smaller buffer sizes give - * fast adaptation but have of course the overhead of transmitting - * trees more frequently. - * - I can't count above 4 - */ - - uInt sym_next; /* running index in sym_buf */ - uInt sym_end; /* symbol table full when sym_next reaches this */ - - ulg opt_len; /* bit length of current block with optimal trees */ - ulg static_len; /* bit length of current block with static trees */ - uInt matches; /* number of string matches in current block */ - uInt insert; /* bytes at end of window left to insert */ - -#ifdef ZLIB_DEBUG - ulg compressed_len; /* total bit length of compressed file mod 2^32 */ - ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ -#endif - - ush bi_buf; - /* Output buffer. bits are inserted starting at the bottom (least - * significant bits). - */ - int bi_valid; - /* Number of valid bits in bi_buf. All bits above the last valid bit - * are always zero. - */ - - ulg high_water; - /* High water mark offset in window for initialized bytes -- bytes above - * this are set to zero in order to avoid memory check warnings when - * longest match routines access bytes past the input. This is then - * updated to the new high water mark. - */ - -} FAR deflate_state; - -/* Output a byte on the stream. - * IN assertion: there is enough room in pending_buf. - */ -#define put_byte(s, c) {s->pending_buf[s->pending++] = (Bytef)(c);} - - -#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) -/* Minimum amount of lookahead, except at the end of the input file. - * See deflate.c for comments about the MIN_MATCH+1. - */ - -#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD) -/* In order to simplify the code, particularly on 16 bit machines, match - * distances are limited to MAX_DIST instead of WSIZE. - */ - -#define WIN_INIT MAX_MATCH -/* Number of bytes after end of data in window to initialize in order to avoid - memory checker errors from longest match routines */ - - /* in trees.c */ -void ZLIB_INTERNAL _tr_init OF((deflate_state *s)); -int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); -void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf, - ulg stored_len, int last)); -void ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s)); -void ZLIB_INTERNAL _tr_align OF((deflate_state *s)); -void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, - ulg stored_len, int last)); - -#define d_code(dist) \ - ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) -/* Mapping from a distance to a distance code. dist is the distance - 1 and - * must not have side effects. _dist_code[256] and _dist_code[257] are never - * used. - */ - -#ifndef ZLIB_DEBUG -/* Inline versions of _tr_tally for speed: */ - -#if defined(GEN_TREES_H) || !defined(STDC) - extern uch ZLIB_INTERNAL _length_code[]; - extern uch ZLIB_INTERNAL _dist_code[]; -#else - extern const uch ZLIB_INTERNAL _length_code[]; - extern const uch ZLIB_INTERNAL _dist_code[]; -#endif - -# define _tr_tally_lit(s, c, flush) \ - { uch cc = (c); \ - s->sym_buf[s->sym_next++] = 0; \ - s->sym_buf[s->sym_next++] = 0; \ - s->sym_buf[s->sym_next++] = cc; \ - s->dyn_ltree[cc].Freq++; \ - flush = (s->sym_next == s->sym_end); \ - } -# define _tr_tally_dist(s, distance, length, flush) \ - { uch len = (uch)(length); \ - ush dist = (ush)(distance); \ - s->sym_buf[s->sym_next++] = dist; \ - s->sym_buf[s->sym_next++] = dist >> 8; \ - s->sym_buf[s->sym_next++] = len; \ - dist--; \ - s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ - s->dyn_dtree[d_code(dist)].Freq++; \ - flush = (s->sym_next == s->sym_end); \ - } -#else -# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) -# define _tr_tally_dist(s, distance, length, flush) \ - flush = _tr_tally(s, distance, length) -#endif - -#endif /* DEFLATE_H */ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/doc/algorithm.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/doc/algorithm.txt deleted file mode 100644 index c97f495..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/doc/algorithm.txt +++ /dev/null @@ -1,209 +0,0 @@ -1. Compression algorithm (deflate) - -The deflation algorithm used by gzip (also zip and zlib) is a variation of -LZ77 (Lempel-Ziv 1977, see reference below). It finds duplicated strings in -the input data. The second occurrence of a string is replaced by a -pointer to the previous string, in the form of a pair (distance, -length). Distances are limited to 32K bytes, and lengths are limited -to 258 bytes. When a string does not occur anywhere in the previous -32K bytes, it is emitted as a sequence of literal bytes. (In this -description, `string' must be taken as an arbitrary sequence of bytes, -and is not restricted to printable characters.) - -Literals or match lengths are compressed with one Huffman tree, and -match distances are compressed with another tree. The trees are stored -in a compact form at the start of each block. The blocks can have any -size (except that the compressed data for one block must fit in -available memory). A block is terminated when deflate() determines that -it would be useful to start another block with fresh trees. (This is -somewhat similar to the behavior of LZW-based _compress_.) - -Duplicated strings are found using a hash table. All input strings of -length 3 are inserted in the hash table. A hash index is computed for -the next 3 bytes. If the hash chain for this index is not empty, all -strings in the chain are compared with the current input string, and -the longest match is selected. - -The hash chains are searched starting with the most recent strings, to -favor small distances and thus take advantage of the Huffman encoding. -The hash chains are singly linked. There are no deletions from the -hash chains, the algorithm simply discards matches that are too old. - -To avoid a worst-case situation, very long hash chains are arbitrarily -truncated at a certain length, determined by a runtime option (level -parameter of deflateInit). So deflate() does not always find the longest -possible match but generally finds a match which is long enough. - -deflate() also defers the selection of matches with a lazy evaluation -mechanism. After a match of length N has been found, deflate() searches for -a longer match at the next input byte. If a longer match is found, the -previous match is truncated to a length of one (thus producing a single -literal byte) and the process of lazy evaluation begins again. Otherwise, -the original match is kept, and the next match search is attempted only N -steps later. - -The lazy match evaluation is also subject to a runtime parameter. If -the current match is long enough, deflate() reduces the search for a longer -match, thus speeding up the whole process. If compression ratio is more -important than speed, deflate() attempts a complete second search even if -the first match is already long enough. - -The lazy match evaluation is not performed for the fastest compression -modes (level parameter 1 to 3). For these fast modes, new strings -are inserted in the hash table only when no match was found, or -when the match is not too long. This degrades the compression ratio -but saves time since there are both fewer insertions and fewer searches. - - -2. Decompression algorithm (inflate) - -2.1 Introduction - -The key question is how to represent a Huffman code (or any prefix code) so -that you can decode fast. The most important characteristic is that shorter -codes are much more common than longer codes, so pay attention to decoding the -short codes fast, and let the long codes take longer to decode. - -inflate() sets up a first level table that covers some number of bits of -input less than the length of longest code. It gets that many bits from the -stream, and looks it up in the table. The table will tell if the next -code is that many bits or less and how many, and if it is, it will tell -the value, else it will point to the next level table for which inflate() -grabs more bits and tries to decode a longer code. - -How many bits to make the first lookup is a tradeoff between the time it -takes to decode and the time it takes to build the table. If building the -table took no time (and if you had infinite memory), then there would only -be a first level table to cover all the way to the longest code. However, -building the table ends up taking a lot longer for more bits since short -codes are replicated many times in such a table. What inflate() does is -simply to make the number of bits in the first table a variable, and then -to set that variable for the maximum speed. - -For inflate, which has 286 possible codes for the literal/length tree, the size -of the first table is nine bits. Also the distance trees have 30 possible -values, and the size of the first table is six bits. Note that for each of -those cases, the table ended up one bit longer than the ``average'' code -length, i.e. the code length of an approximately flat code which would be a -little more than eight bits for 286 symbols and a little less than five bits -for 30 symbols. - - -2.2 More details on the inflate table lookup - -Ok, you want to know what this cleverly obfuscated inflate tree actually -looks like. You are correct that it's not a Huffman tree. It is simply a -lookup table for the first, let's say, nine bits of a Huffman symbol. The -symbol could be as short as one bit or as long as 15 bits. If a particular -symbol is shorter than nine bits, then that symbol's translation is duplicated -in all those entries that start with that symbol's bits. For example, if the -symbol is four bits, then it's duplicated 32 times in a nine-bit table. If a -symbol is nine bits long, it appears in the table once. - -If the symbol is longer than nine bits, then that entry in the table points -to another similar table for the remaining bits. Again, there are duplicated -entries as needed. The idea is that most of the time the symbol will be short -and there will only be one table look up. (That's whole idea behind data -compression in the first place.) For the less frequent long symbols, there -will be two lookups. If you had a compression method with really long -symbols, you could have as many levels of lookups as is efficient. For -inflate, two is enough. - -So a table entry either points to another table (in which case nine bits in -the above example are gobbled), or it contains the translation for the symbol -and the number of bits to gobble. Then you start again with the next -ungobbled bit. - -You may wonder: why not just have one lookup table for how ever many bits the -longest symbol is? The reason is that if you do that, you end up spending -more time filling in duplicate symbol entries than you do actually decoding. -At least for deflate's output that generates new trees every several 10's of -kbytes. You can imagine that filling in a 2^15 entry table for a 15-bit code -would take too long if you're only decoding several thousand symbols. At the -other extreme, you could make a new table for every bit in the code. In fact, -that's essentially a Huffman tree. But then you spend too much time -traversing the tree while decoding, even for short symbols. - -So the number of bits for the first lookup table is a trade of the time to -fill out the table vs. the time spent looking at the second level and above of -the table. - -Here is an example, scaled down: - -The code being decoded, with 10 symbols, from 1 to 6 bits long: - -A: 0 -B: 10 -C: 1100 -D: 11010 -E: 11011 -F: 11100 -G: 11101 -H: 11110 -I: 111110 -J: 111111 - -Let's make the first table three bits long (eight entries): - -000: A,1 -001: A,1 -010: A,1 -011: A,1 -100: B,2 -101: B,2 -110: -> table X (gobble 3 bits) -111: -> table Y (gobble 3 bits) - -Each entry is what the bits decode as and how many bits that is, i.e. how -many bits to gobble. Or the entry points to another table, with the number of -bits to gobble implicit in the size of the table. - -Table X is two bits long since the longest code starting with 110 is five bits -long: - -00: C,1 -01: C,1 -10: D,2 -11: E,2 - -Table Y is three bits long since the longest code starting with 111 is six -bits long: - -000: F,2 -001: F,2 -010: G,2 -011: G,2 -100: H,2 -101: H,2 -110: I,3 -111: J,3 - -So what we have here are three tables with a total of 20 entries that had to -be constructed. That's compared to 64 entries for a single table. Or -compared to 16 entries for a Huffman tree (six two entry tables and one four -entry table). Assuming that the code ideally represents the probability of -the symbols, it takes on the average 1.25 lookups per symbol. That's compared -to one lookup for the single table, or 1.66 lookups per symbol for the -Huffman tree. - -There, I think that gives you a picture of what's going on. For inflate, the -meaning of a particular symbol is often more than just a letter. It can be a -byte (a "literal"), or it can be either a length or a distance which -indicates a base value and a number of bits to fetch after the code that is -added to the base value. Or it might be the special end-of-block code. The -data structures created in inftrees.c try to encode all that information -compactly in the tables. - - -Jean-loup Gailly Mark Adler -jloup@gzip.org madler@alumni.caltech.edu - - -References: - -[LZ77] Ziv J., Lempel A., ``A Universal Algorithm for Sequential Data -Compression,'' IEEE Transactions on Information Theory, Vol. 23, No. 3, -pp. 337-343. - -``DEFLATE Compressed Data Format Specification'' available in -http://tools.ietf.org/html/rfc1951 diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/doc/crc-doc.1.0.pdf b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/doc/crc-doc.1.0.pdf deleted file mode 100644 index d6942ec..0000000 Binary files a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/doc/crc-doc.1.0.pdf and /dev/null differ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/doc/rfc1950.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/doc/rfc1950.txt deleted file mode 100644 index ce6428a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/doc/rfc1950.txt +++ /dev/null @@ -1,619 +0,0 @@ - - - - - - -Network Working Group P. Deutsch -Request for Comments: 1950 Aladdin Enterprises -Category: Informational J-L. Gailly - Info-ZIP - May 1996 - - - ZLIB Compressed Data Format Specification version 3.3 - -Status of This Memo - - This memo provides information for the Internet community. This memo - does not specify an Internet standard of any kind. Distribution of - this memo is unlimited. - -IESG Note: - - The IESG takes no position on the validity of any Intellectual - Property Rights statements contained in this document. - -Notices - - Copyright (c) 1996 L. Peter Deutsch and Jean-Loup Gailly - - Permission is granted to copy and distribute this document for any - purpose and without charge, including translations into other - languages and incorporation into compilations, provided that the - copyright notice and this notice are preserved, and that any - substantive changes or deletions from the original are clearly - marked. - - A pointer to the latest version of this and related documentation in - HTML format can be found at the URL - . - -Abstract - - This specification defines a lossless compressed data format. The - data can be produced or consumed, even for an arbitrarily long - sequentially presented input data stream, using only an a priori - bounded amount of intermediate storage. The format presently uses - the DEFLATE compression method but can be easily extended to use - other compression methods. It can be implemented readily in a manner - not covered by patents. This specification also defines the ADLER-32 - checksum (an extension and improvement of the Fletcher checksum), - used for detection of data corruption, and provides an algorithm for - computing it. - - - - -Deutsch & Gailly Informational [Page 1] - -RFC 1950 ZLIB Compressed Data Format Specification May 1996 - - -Table of Contents - - 1. Introduction ................................................... 2 - 1.1. Purpose ................................................... 2 - 1.2. Intended audience ......................................... 3 - 1.3. Scope ..................................................... 3 - 1.4. Compliance ................................................ 3 - 1.5. Definitions of terms and conventions used ................ 3 - 1.6. Changes from previous versions ............................ 3 - 2. Detailed specification ......................................... 3 - 2.1. Overall conventions ....................................... 3 - 2.2. Data format ............................................... 4 - 2.3. Compliance ................................................ 7 - 3. References ..................................................... 7 - 4. Source code .................................................... 8 - 5. Security Considerations ........................................ 8 - 6. Acknowledgements ............................................... 8 - 7. Authors' Addresses ............................................. 8 - 8. Appendix: Rationale ............................................ 9 - 9. Appendix: Sample code ..........................................10 - -1. Introduction - - 1.1. Purpose - - The purpose of this specification is to define a lossless - compressed data format that: - - * Is independent of CPU type, operating system, file system, - and character set, and hence can be used for interchange; - - * Can be produced or consumed, even for an arbitrarily long - sequentially presented input data stream, using only an a - priori bounded amount of intermediate storage, and hence can - be used in data communications or similar structures such as - Unix filters; - - * Can use a number of different compression methods; - - * Can be implemented readily in a manner not covered by - patents, and hence can be practiced freely. - - The data format defined by this specification does not attempt to - allow random access to compressed data. - - - - - - - -Deutsch & Gailly Informational [Page 2] - -RFC 1950 ZLIB Compressed Data Format Specification May 1996 - - - 1.2. Intended audience - - This specification is intended for use by implementors of software - to compress data into zlib format and/or decompress data from zlib - format. - - The text of the specification assumes a basic background in - programming at the level of bits and other primitive data - representations. - - 1.3. Scope - - The specification specifies a compressed data format that can be - used for in-memory compression of a sequence of arbitrary bytes. - - 1.4. Compliance - - Unless otherwise indicated below, a compliant decompressor must be - able to accept and decompress any data set that conforms to all - the specifications presented here; a compliant compressor must - produce data sets that conform to all the specifications presented - here. - - 1.5. Definitions of terms and conventions used - - byte: 8 bits stored or transmitted as a unit (same as an octet). - (For this specification, a byte is exactly 8 bits, even on - machines which store a character on a number of bits different - from 8.) See below, for the numbering of bits within a byte. - - 1.6. Changes from previous versions - - Version 3.1 was the first public release of this specification. - In version 3.2, some terminology was changed and the Adler-32 - sample code was rewritten for clarity. In version 3.3, the - support for a preset dictionary was introduced, and the - specification was converted to RFC style. - -2. Detailed specification - - 2.1. Overall conventions - - In the diagrams below, a box like this: - - +---+ - | | <-- the vertical bars might be missing - +---+ - - - - -Deutsch & Gailly Informational [Page 3] - -RFC 1950 ZLIB Compressed Data Format Specification May 1996 - - - represents one byte; a box like this: - - +==============+ - | | - +==============+ - - represents a variable number of bytes. - - Bytes stored within a computer do not have a "bit order", since - they are always treated as a unit. However, a byte considered as - an integer between 0 and 255 does have a most- and least- - significant bit, and since we write numbers with the most- - significant digit on the left, we also write bytes with the most- - significant bit on the left. In the diagrams below, we number the - bits of a byte so that bit 0 is the least-significant bit, i.e., - the bits are numbered: - - +--------+ - |76543210| - +--------+ - - Within a computer, a number may occupy multiple bytes. All - multi-byte numbers in the format described here are stored with - the MOST-significant byte first (at the lower memory address). - For example, the decimal number 520 is stored as: - - 0 1 - +--------+--------+ - |00000010|00001000| - +--------+--------+ - ^ ^ - | | - | + less significant byte = 8 - + more significant byte = 2 x 256 - - 2.2. Data format - - A zlib stream has the following structure: - - 0 1 - +---+---+ - |CMF|FLG| (more-->) - +---+---+ - - - - - - - - -Deutsch & Gailly Informational [Page 4] - -RFC 1950 ZLIB Compressed Data Format Specification May 1996 - - - (if FLG.FDICT set) - - 0 1 2 3 - +---+---+---+---+ - | DICTID | (more-->) - +---+---+---+---+ - - +=====================+---+---+---+---+ - |...compressed data...| ADLER32 | - +=====================+---+---+---+---+ - - Any data which may appear after ADLER32 are not part of the zlib - stream. - - CMF (Compression Method and flags) - This byte is divided into a 4-bit compression method and a 4- - bit information field depending on the compression method. - - bits 0 to 3 CM Compression method - bits 4 to 7 CINFO Compression info - - CM (Compression method) - This identifies the compression method used in the file. CM = 8 - denotes the "deflate" compression method with a window size up - to 32K. This is the method used by gzip and PNG (see - references [1] and [2] in Chapter 3, below, for the reference - documents). CM = 15 is reserved. It might be used in a future - version of this specification to indicate the presence of an - extra field before the compressed data. - - CINFO (Compression info) - For CM = 8, CINFO is the base-2 logarithm of the LZ77 window - size, minus eight (CINFO=7 indicates a 32K window size). Values - of CINFO above 7 are not allowed in this version of the - specification. CINFO is not defined in this specification for - CM not equal to 8. - - FLG (FLaGs) - This flag byte is divided as follows: - - bits 0 to 4 FCHECK (check bits for CMF and FLG) - bit 5 FDICT (preset dictionary) - bits 6 to 7 FLEVEL (compression level) - - The FCHECK value must be such that CMF and FLG, when viewed as - a 16-bit unsigned integer stored in MSB order (CMF*256 + FLG), - is a multiple of 31. - - - - -Deutsch & Gailly Informational [Page 5] - -RFC 1950 ZLIB Compressed Data Format Specification May 1996 - - - FDICT (Preset dictionary) - If FDICT is set, a DICT dictionary identifier is present - immediately after the FLG byte. The dictionary is a sequence of - bytes which are initially fed to the compressor without - producing any compressed output. DICT is the Adler-32 checksum - of this sequence of bytes (see the definition of ADLER32 - below). The decompressor can use this identifier to determine - which dictionary has been used by the compressor. - - FLEVEL (Compression level) - These flags are available for use by specific compression - methods. The "deflate" method (CM = 8) sets these flags as - follows: - - 0 - compressor used fastest algorithm - 1 - compressor used fast algorithm - 2 - compressor used default algorithm - 3 - compressor used maximum compression, slowest algorithm - - The information in FLEVEL is not needed for decompression; it - is there to indicate if recompression might be worthwhile. - - compressed data - For compression method 8, the compressed data is stored in the - deflate compressed data format as described in the document - "DEFLATE Compressed Data Format Specification" by L. Peter - Deutsch. (See reference [3] in Chapter 3, below) - - Other compressed data formats are not specified in this version - of the zlib specification. - - ADLER32 (Adler-32 checksum) - This contains a checksum value of the uncompressed data - (excluding any dictionary data) computed according to Adler-32 - algorithm. This algorithm is a 32-bit extension and improvement - of the Fletcher algorithm, used in the ITU-T X.224 / ISO 8073 - standard. See references [4] and [5] in Chapter 3, below) - - Adler-32 is composed of two sums accumulated per byte: s1 is - the sum of all bytes, s2 is the sum of all s1 values. Both sums - are done modulo 65521. s1 is initialized to 1, s2 to zero. The - Adler-32 checksum is stored as s2*65536 + s1 in most- - significant-byte first (network) order. - - - - - - - - -Deutsch & Gailly Informational [Page 6] - -RFC 1950 ZLIB Compressed Data Format Specification May 1996 - - - 2.3. Compliance - - A compliant compressor must produce streams with correct CMF, FLG - and ADLER32, but need not support preset dictionaries. When the - zlib data format is used as part of another standard data format, - the compressor may use only preset dictionaries that are specified - by this other data format. If this other format does not use the - preset dictionary feature, the compressor must not set the FDICT - flag. - - A compliant decompressor must check CMF, FLG, and ADLER32, and - provide an error indication if any of these have incorrect values. - A compliant decompressor must give an error indication if CM is - not one of the values defined in this specification (only the - value 8 is permitted in this version), since another value could - indicate the presence of new features that would cause subsequent - data to be interpreted incorrectly. A compliant decompressor must - give an error indication if FDICT is set and DICTID is not the - identifier of a known preset dictionary. A decompressor may - ignore FLEVEL and still be compliant. When the zlib data format - is being used as a part of another standard format, a compliant - decompressor must support all the preset dictionaries specified by - the other format. When the other format does not use the preset - dictionary feature, a compliant decompressor must reject any - stream in which the FDICT flag is set. - -3. References - - [1] Deutsch, L.P.,"GZIP Compressed Data Format Specification", - available in ftp://ftp.uu.net/pub/archiving/zip/doc/ - - [2] Thomas Boutell, "PNG (Portable Network Graphics) specification", - available in ftp://ftp.uu.net/graphics/png/documents/ - - [3] Deutsch, L.P.,"DEFLATE Compressed Data Format Specification", - available in ftp://ftp.uu.net/pub/archiving/zip/doc/ - - [4] Fletcher, J. G., "An Arithmetic Checksum for Serial - Transmissions," IEEE Transactions on Communications, Vol. COM-30, - No. 1, January 1982, pp. 247-252. - - [5] ITU-T Recommendation X.224, Annex D, "Checksum Algorithms," - November, 1993, pp. 144, 145. (Available from - gopher://info.itu.ch). ITU-T X.244 is also the same as ISO 8073. - - - - - - - -Deutsch & Gailly Informational [Page 7] - -RFC 1950 ZLIB Compressed Data Format Specification May 1996 - - -4. Source code - - Source code for a C language implementation of a "zlib" compliant - library is available at ftp://ftp.uu.net/pub/archiving/zip/zlib/. - -5. Security Considerations - - A decoder that fails to check the ADLER32 checksum value may be - subject to undetected data corruption. - -6. Acknowledgements - - Trademarks cited in this document are the property of their - respective owners. - - Jean-Loup Gailly and Mark Adler designed the zlib format and wrote - the related software described in this specification. Glenn - Randers-Pehrson converted this document to RFC and HTML format. - -7. Authors' Addresses - - L. Peter Deutsch - Aladdin Enterprises - 203 Santa Margarita Ave. - Menlo Park, CA 94025 - - Phone: (415) 322-0103 (AM only) - FAX: (415) 322-1734 - EMail: - - - Jean-Loup Gailly - - EMail: - - Questions about the technical content of this specification can be - sent by email to - - Jean-Loup Gailly and - Mark Adler - - Editorial comments on this specification can be sent by email to - - L. Peter Deutsch and - Glenn Randers-Pehrson - - - - - - -Deutsch & Gailly Informational [Page 8] - -RFC 1950 ZLIB Compressed Data Format Specification May 1996 - - -8. Appendix: Rationale - - 8.1. Preset dictionaries - - A preset dictionary is specially useful to compress short input - sequences. The compressor can take advantage of the dictionary - context to encode the input in a more compact manner. The - decompressor can be initialized with the appropriate context by - virtually decompressing a compressed version of the dictionary - without producing any output. However for certain compression - algorithms such as the deflate algorithm this operation can be - achieved without actually performing any decompression. - - The compressor and the decompressor must use exactly the same - dictionary. The dictionary may be fixed or may be chosen among a - certain number of predefined dictionaries, according to the kind - of input data. The decompressor can determine which dictionary has - been chosen by the compressor by checking the dictionary - identifier. This document does not specify the contents of - predefined dictionaries, since the optimal dictionaries are - application specific. Standard data formats using this feature of - the zlib specification must precisely define the allowed - dictionaries. - - 8.2. The Adler-32 algorithm - - The Adler-32 algorithm is much faster than the CRC32 algorithm yet - still provides an extremely low probability of undetected errors. - - The modulo on unsigned long accumulators can be delayed for 5552 - bytes, so the modulo operation time is negligible. If the bytes - are a, b, c, the second sum is 3a + 2b + c + 3, and so is position - and order sensitive, unlike the first sum, which is just a - checksum. That 65521 is prime is important to avoid a possible - large class of two-byte errors that leave the check unchanged. - (The Fletcher checksum uses 255, which is not prime and which also - makes the Fletcher check insensitive to single byte changes 0 <-> - 255.) - - The sum s1 is initialized to 1 instead of zero to make the length - of the sequence part of s2, so that the length does not have to be - checked separately. (Any sequence of zeroes has a Fletcher - checksum of zero.) - - - - - - - - -Deutsch & Gailly Informational [Page 9] - -RFC 1950 ZLIB Compressed Data Format Specification May 1996 - - -9. Appendix: Sample code - - The following C code computes the Adler-32 checksum of a data buffer. - It is written for clarity, not for speed. The sample code is in the - ANSI C programming language. Non C users may find it easier to read - with these hints: - - & Bitwise AND operator. - >> Bitwise right shift operator. When applied to an - unsigned quantity, as here, right shift inserts zero bit(s) - at the left. - << Bitwise left shift operator. Left shift inserts zero - bit(s) at the right. - ++ "n++" increments the variable n. - % modulo operator: a % b is the remainder of a divided by b. - - #define BASE 65521 /* largest prime smaller than 65536 */ - - /* - Update a running Adler-32 checksum with the bytes buf[0..len-1] - and return the updated checksum. The Adler-32 checksum should be - initialized to 1. - - Usage example: - - unsigned long adler = 1L; - - while (read_buffer(buffer, length) != EOF) { - adler = update_adler32(adler, buffer, length); - } - if (adler != original_adler) error(); - */ - unsigned long update_adler32(unsigned long adler, - unsigned char *buf, int len) - { - unsigned long s1 = adler & 0xffff; - unsigned long s2 = (adler >> 16) & 0xffff; - int n; - - for (n = 0; n < len; n++) { - s1 = (s1 + buf[n]) % BASE; - s2 = (s2 + s1) % BASE; - } - return (s2 << 16) + s1; - } - - /* Return the adler32 of the bytes buf[0..len-1] */ - - - - -Deutsch & Gailly Informational [Page 10] - -RFC 1950 ZLIB Compressed Data Format Specification May 1996 - - - unsigned long adler32(unsigned char *buf, int len) - { - return update_adler32(1L, buf, len); - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Deutsch & Gailly Informational [Page 11] - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/doc/rfc1951.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/doc/rfc1951.txt deleted file mode 100644 index 403c8c7..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/doc/rfc1951.txt +++ /dev/null @@ -1,955 +0,0 @@ - - - - - - -Network Working Group P. Deutsch -Request for Comments: 1951 Aladdin Enterprises -Category: Informational May 1996 - - - DEFLATE Compressed Data Format Specification version 1.3 - -Status of This Memo - - This memo provides information for the Internet community. This memo - does not specify an Internet standard of any kind. Distribution of - this memo is unlimited. - -IESG Note: - - The IESG takes no position on the validity of any Intellectual - Property Rights statements contained in this document. - -Notices - - Copyright (c) 1996 L. Peter Deutsch - - Permission is granted to copy and distribute this document for any - purpose and without charge, including translations into other - languages and incorporation into compilations, provided that the - copyright notice and this notice are preserved, and that any - substantive changes or deletions from the original are clearly - marked. - - A pointer to the latest version of this and related documentation in - HTML format can be found at the URL - . - -Abstract - - This specification defines a lossless compressed data format that - compresses data using a combination of the LZ77 algorithm and Huffman - coding, with efficiency comparable to the best currently available - general-purpose compression methods. The data can be produced or - consumed, even for an arbitrarily long sequentially presented input - data stream, using only an a priori bounded amount of intermediate - storage. The format can be implemented readily in a manner not - covered by patents. - - - - - - - - -Deutsch Informational [Page 1] - -RFC 1951 DEFLATE Compressed Data Format Specification May 1996 - - -Table of Contents - - 1. Introduction ................................................... 2 - 1.1. Purpose ................................................... 2 - 1.2. Intended audience ......................................... 3 - 1.3. Scope ..................................................... 3 - 1.4. Compliance ................................................ 3 - 1.5. Definitions of terms and conventions used ................ 3 - 1.6. Changes from previous versions ............................ 4 - 2. Compressed representation overview ............................. 4 - 3. Detailed specification ......................................... 5 - 3.1. Overall conventions ....................................... 5 - 3.1.1. Packing into bytes .................................. 5 - 3.2. Compressed block format ................................... 6 - 3.2.1. Synopsis of prefix and Huffman coding ............... 6 - 3.2.2. Use of Huffman coding in the "deflate" format ....... 7 - 3.2.3. Details of block format ............................. 9 - 3.2.4. Non-compressed blocks (BTYPE=00) ................... 11 - 3.2.5. Compressed blocks (length and distance codes) ...... 11 - 3.2.6. Compression with fixed Huffman codes (BTYPE=01) .... 12 - 3.2.7. Compression with dynamic Huffman codes (BTYPE=10) .. 13 - 3.3. Compliance ............................................... 14 - 4. Compression algorithm details ................................. 14 - 5. References .................................................... 16 - 6. Security Considerations ....................................... 16 - 7. Source code ................................................... 16 - 8. Acknowledgements .............................................. 16 - 9. Author's Address .............................................. 17 - -1. Introduction - - 1.1. Purpose - - The purpose of this specification is to define a lossless - compressed data format that: - * Is independent of CPU type, operating system, file system, - and character set, and hence can be used for interchange; - * Can be produced or consumed, even for an arbitrarily long - sequentially presented input data stream, using only an a - priori bounded amount of intermediate storage, and hence - can be used in data communications or similar structures - such as Unix filters; - * Compresses data with efficiency comparable to the best - currently available general-purpose compression methods, - and in particular considerably better than the "compress" - program; - * Can be implemented readily in a manner not covered by - patents, and hence can be practiced freely; - - - -Deutsch Informational [Page 2] - -RFC 1951 DEFLATE Compressed Data Format Specification May 1996 - - - * Is compatible with the file format produced by the current - widely used gzip utility, in that conforming decompressors - will be able to read data produced by the existing gzip - compressor. - - The data format defined by this specification does not attempt to: - - * Allow random access to compressed data; - * Compress specialized data (e.g., raster graphics) as well - as the best currently available specialized algorithms. - - A simple counting argument shows that no lossless compression - algorithm can compress every possible input data set. For the - format defined here, the worst case expansion is 5 bytes per 32K- - byte block, i.e., a size increase of 0.015% for large data sets. - English text usually compresses by a factor of 2.5 to 3; - executable files usually compress somewhat less; graphical data - such as raster images may compress much more. - - 1.2. Intended audience - - This specification is intended for use by implementors of software - to compress data into "deflate" format and/or decompress data from - "deflate" format. - - The text of the specification assumes a basic background in - programming at the level of bits and other primitive data - representations. Familiarity with the technique of Huffman coding - is helpful but not required. - - 1.3. Scope - - The specification specifies a method for representing a sequence - of bytes as a (usually shorter) sequence of bits, and a method for - packing the latter bit sequence into bytes. - - 1.4. Compliance - - Unless otherwise indicated below, a compliant decompressor must be - able to accept and decompress any data set that conforms to all - the specifications presented here; a compliant compressor must - produce data sets that conform to all the specifications presented - here. - - 1.5. Definitions of terms and conventions used - - Byte: 8 bits stored or transmitted as a unit (same as an octet). - For this specification, a byte is exactly 8 bits, even on machines - - - -Deutsch Informational [Page 3] - -RFC 1951 DEFLATE Compressed Data Format Specification May 1996 - - - which store a character on a number of bits different from eight. - See below, for the numbering of bits within a byte. - - String: a sequence of arbitrary bytes. - - 1.6. Changes from previous versions - - There have been no technical changes to the deflate format since - version 1.1 of this specification. In version 1.2, some - terminology was changed. Version 1.3 is a conversion of the - specification to RFC style. - -2. Compressed representation overview - - A compressed data set consists of a series of blocks, corresponding - to successive blocks of input data. The block sizes are arbitrary, - except that non-compressible blocks are limited to 65,535 bytes. - - Each block is compressed using a combination of the LZ77 algorithm - and Huffman coding. The Huffman trees for each block are independent - of those for previous or subsequent blocks; the LZ77 algorithm may - use a reference to a duplicated string occurring in a previous block, - up to 32K input bytes before. - - Each block consists of two parts: a pair of Huffman code trees that - describe the representation of the compressed data part, and a - compressed data part. (The Huffman trees themselves are compressed - using Huffman encoding.) The compressed data consists of a series of - elements of two types: literal bytes (of strings that have not been - detected as duplicated within the previous 32K input bytes), and - pointers to duplicated strings, where a pointer is represented as a - pair . The representation used in the - "deflate" format limits distances to 32K bytes and lengths to 258 - bytes, but does not limit the size of a block, except for - uncompressible blocks, which are limited as noted above. - - Each type of value (literals, distances, and lengths) in the - compressed data is represented using a Huffman code, using one code - tree for literals and lengths and a separate code tree for distances. - The code trees for each block appear in a compact form just before - the compressed data for that block. - - - - - - - - - - -Deutsch Informational [Page 4] - -RFC 1951 DEFLATE Compressed Data Format Specification May 1996 - - -3. Detailed specification - - 3.1. Overall conventions In the diagrams below, a box like this: - - +---+ - | | <-- the vertical bars might be missing - +---+ - - represents one byte; a box like this: - - +==============+ - | | - +==============+ - - represents a variable number of bytes. - - Bytes stored within a computer do not have a "bit order", since - they are always treated as a unit. However, a byte considered as - an integer between 0 and 255 does have a most- and least- - significant bit, and since we write numbers with the most- - significant digit on the left, we also write bytes with the most- - significant bit on the left. In the diagrams below, we number the - bits of a byte so that bit 0 is the least-significant bit, i.e., - the bits are numbered: - - +--------+ - |76543210| - +--------+ - - Within a computer, a number may occupy multiple bytes. All - multi-byte numbers in the format described here are stored with - the least-significant byte first (at the lower memory address). - For example, the decimal number 520 is stored as: - - 0 1 - +--------+--------+ - |00001000|00000010| - +--------+--------+ - ^ ^ - | | - | + more significant byte = 2 x 256 - + less significant byte = 8 - - 3.1.1. Packing into bytes - - This document does not address the issue of the order in which - bits of a byte are transmitted on a bit-sequential medium, - since the final data format described here is byte- rather than - - - -Deutsch Informational [Page 5] - -RFC 1951 DEFLATE Compressed Data Format Specification May 1996 - - - bit-oriented. However, we describe the compressed block format - in below, as a sequence of data elements of various bit - lengths, not a sequence of bytes. We must therefore specify - how to pack these data elements into bytes to form the final - compressed byte sequence: - - * Data elements are packed into bytes in order of - increasing bit number within the byte, i.e., starting - with the least-significant bit of the byte. - * Data elements other than Huffman codes are packed - starting with the least-significant bit of the data - element. - * Huffman codes are packed starting with the most- - significant bit of the code. - - In other words, if one were to print out the compressed data as - a sequence of bytes, starting with the first byte at the - *right* margin and proceeding to the *left*, with the most- - significant bit of each byte on the left as usual, one would be - able to parse the result from right to left, with fixed-width - elements in the correct MSB-to-LSB order and Huffman codes in - bit-reversed order (i.e., with the first bit of the code in the - relative LSB position). - - 3.2. Compressed block format - - 3.2.1. Synopsis of prefix and Huffman coding - - Prefix coding represents symbols from an a priori known - alphabet by bit sequences (codes), one code for each symbol, in - a manner such that different symbols may be represented by bit - sequences of different lengths, but a parser can always parse - an encoded string unambiguously symbol-by-symbol. - - We define a prefix code in terms of a binary tree in which the - two edges descending from each non-leaf node are labeled 0 and - 1 and in which the leaf nodes correspond one-for-one with (are - labeled with) the symbols of the alphabet; then the code for a - symbol is the sequence of 0's and 1's on the edges leading from - the root to the leaf labeled with that symbol. For example: - - - - - - - - - - - -Deutsch Informational [Page 6] - -RFC 1951 DEFLATE Compressed Data Format Specification May 1996 - - - /\ Symbol Code - 0 1 ------ ---- - / \ A 00 - /\ B B 1 - 0 1 C 011 - / \ D 010 - A /\ - 0 1 - / \ - D C - - A parser can decode the next symbol from an encoded input - stream by walking down the tree from the root, at each step - choosing the edge corresponding to the next input bit. - - Given an alphabet with known symbol frequencies, the Huffman - algorithm allows the construction of an optimal prefix code - (one which represents strings with those symbol frequencies - using the fewest bits of any possible prefix codes for that - alphabet). Such a code is called a Huffman code. (See - reference [1] in Chapter 5, references for additional - information on Huffman codes.) - - Note that in the "deflate" format, the Huffman codes for the - various alphabets must not exceed certain maximum code lengths. - This constraint complicates the algorithm for computing code - lengths from symbol frequencies. Again, see Chapter 5, - references for details. - - 3.2.2. Use of Huffman coding in the "deflate" format - - The Huffman codes used for each alphabet in the "deflate" - format have two additional rules: - - * All codes of a given bit length have lexicographically - consecutive values, in the same order as the symbols - they represent; - - * Shorter codes lexicographically precede longer codes. - - - - - - - - - - - - -Deutsch Informational [Page 7] - -RFC 1951 DEFLATE Compressed Data Format Specification May 1996 - - - We could recode the example above to follow this rule as - follows, assuming that the order of the alphabet is ABCD: - - Symbol Code - ------ ---- - A 10 - B 0 - C 110 - D 111 - - I.e., 0 precedes 10 which precedes 11x, and 110 and 111 are - lexicographically consecutive. - - Given this rule, we can define the Huffman code for an alphabet - just by giving the bit lengths of the codes for each symbol of - the alphabet in order; this is sufficient to determine the - actual codes. In our example, the code is completely defined - by the sequence of bit lengths (2, 1, 3, 3). The following - algorithm generates the codes as integers, intended to be read - from most- to least-significant bit. The code lengths are - initially in tree[I].Len; the codes are produced in - tree[I].Code. - - 1) Count the number of codes for each code length. Let - bl_count[N] be the number of codes of length N, N >= 1. - - 2) Find the numerical value of the smallest code for each - code length: - - code = 0; - bl_count[0] = 0; - for (bits = 1; bits <= MAX_BITS; bits++) { - code = (code + bl_count[bits-1]) << 1; - next_code[bits] = code; - } - - 3) Assign numerical values to all codes, using consecutive - values for all codes of the same length with the base - values determined at step 2. Codes that are never used - (which have a bit length of zero) must not be assigned a - value. - - for (n = 0; n <= max_code; n++) { - len = tree[n].Len; - if (len != 0) { - tree[n].Code = next_code[len]; - next_code[len]++; - } - - - -Deutsch Informational [Page 8] - -RFC 1951 DEFLATE Compressed Data Format Specification May 1996 - - - } - - Example: - - Consider the alphabet ABCDEFGH, with bit lengths (3, 3, 3, 3, - 3, 2, 4, 4). After step 1, we have: - - N bl_count[N] - - ----------- - 2 1 - 3 5 - 4 2 - - Step 2 computes the following next_code values: - - N next_code[N] - - ------------ - 1 0 - 2 0 - 3 2 - 4 14 - - Step 3 produces the following code values: - - Symbol Length Code - ------ ------ ---- - A 3 010 - B 3 011 - C 3 100 - D 3 101 - E 3 110 - F 2 00 - G 4 1110 - H 4 1111 - - 3.2.3. Details of block format - - Each block of compressed data begins with 3 header bits - containing the following data: - - first bit BFINAL - next 2 bits BTYPE - - Note that the header bits do not necessarily begin on a byte - boundary, since a block does not necessarily occupy an integral - number of bytes. - - - - - -Deutsch Informational [Page 9] - -RFC 1951 DEFLATE Compressed Data Format Specification May 1996 - - - BFINAL is set if and only if this is the last block of the data - set. - - BTYPE specifies how the data are compressed, as follows: - - 00 - no compression - 01 - compressed with fixed Huffman codes - 10 - compressed with dynamic Huffman codes - 11 - reserved (error) - - The only difference between the two compressed cases is how the - Huffman codes for the literal/length and distance alphabets are - defined. - - In all cases, the decoding algorithm for the actual data is as - follows: - - do - read block header from input stream. - if stored with no compression - skip any remaining bits in current partially - processed byte - read LEN and NLEN (see next section) - copy LEN bytes of data to output - otherwise - if compressed with dynamic Huffman codes - read representation of code trees (see - subsection below) - loop (until end of block code recognized) - decode literal/length value from input stream - if value < 256 - copy value (literal byte) to output stream - otherwise - if value = end of block (256) - break from loop - otherwise (value = 257..285) - decode distance from input stream - - move backwards distance bytes in the output - stream, and copy length bytes from this - position to the output stream. - end loop - while not last block - - Note that a duplicated string reference may refer to a string - in a previous block; i.e., the backward distance may cross one - or more block boundaries. However a distance cannot refer past - the beginning of the output stream. (An application using a - - - -Deutsch Informational [Page 10] - -RFC 1951 DEFLATE Compressed Data Format Specification May 1996 - - - preset dictionary might discard part of the output stream; a - distance can refer to that part of the output stream anyway) - Note also that the referenced string may overlap the current - position; for example, if the last 2 bytes decoded have values - X and Y, a string reference with - adds X,Y,X,Y,X to the output stream. - - We now specify each compression method in turn. - - 3.2.4. Non-compressed blocks (BTYPE=00) - - Any bits of input up to the next byte boundary are ignored. - The rest of the block consists of the following information: - - 0 1 2 3 4... - +---+---+---+---+================================+ - | LEN | NLEN |... LEN bytes of literal data...| - +---+---+---+---+================================+ - - LEN is the number of data bytes in the block. NLEN is the - one's complement of LEN. - - 3.2.5. Compressed blocks (length and distance codes) - - As noted above, encoded data blocks in the "deflate" format - consist of sequences of symbols drawn from three conceptually - distinct alphabets: either literal bytes, from the alphabet of - byte values (0..255), or pairs, - where the length is drawn from (3..258) and the distance is - drawn from (1..32,768). In fact, the literal and length - alphabets are merged into a single alphabet (0..285), where - values 0..255 represent literal bytes, the value 256 indicates - end-of-block, and values 257..285 represent length codes - (possibly in conjunction with extra bits following the symbol - code) as follows: - - - - - - - - - - - - - - - - -Deutsch Informational [Page 11] - -RFC 1951 DEFLATE Compressed Data Format Specification May 1996 - - - Extra Extra Extra - Code Bits Length(s) Code Bits Lengths Code Bits Length(s) - ---- ---- ------ ---- ---- ------- ---- ---- ------- - 257 0 3 267 1 15,16 277 4 67-82 - 258 0 4 268 1 17,18 278 4 83-98 - 259 0 5 269 2 19-22 279 4 99-114 - 260 0 6 270 2 23-26 280 4 115-130 - 261 0 7 271 2 27-30 281 5 131-162 - 262 0 8 272 2 31-34 282 5 163-194 - 263 0 9 273 3 35-42 283 5 195-226 - 264 0 10 274 3 43-50 284 5 227-257 - 265 1 11,12 275 3 51-58 285 0 258 - 266 1 13,14 276 3 59-66 - - The extra bits should be interpreted as a machine integer - stored with the most-significant bit first, e.g., bits 1110 - represent the value 14. - - Extra Extra Extra - Code Bits Dist Code Bits Dist Code Bits Distance - ---- ---- ---- ---- ---- ------ ---- ---- -------- - 0 0 1 10 4 33-48 20 9 1025-1536 - 1 0 2 11 4 49-64 21 9 1537-2048 - 2 0 3 12 5 65-96 22 10 2049-3072 - 3 0 4 13 5 97-128 23 10 3073-4096 - 4 1 5,6 14 6 129-192 24 11 4097-6144 - 5 1 7,8 15 6 193-256 25 11 6145-8192 - 6 2 9-12 16 7 257-384 26 12 8193-12288 - 7 2 13-16 17 7 385-512 27 12 12289-16384 - 8 3 17-24 18 8 513-768 28 13 16385-24576 - 9 3 25-32 19 8 769-1024 29 13 24577-32768 - - 3.2.6. Compression with fixed Huffman codes (BTYPE=01) - - The Huffman codes for the two alphabets are fixed, and are not - represented explicitly in the data. The Huffman code lengths - for the literal/length alphabet are: - - Lit Value Bits Codes - --------- ---- ----- - 0 - 143 8 00110000 through - 10111111 - 144 - 255 9 110010000 through - 111111111 - 256 - 279 7 0000000 through - 0010111 - 280 - 287 8 11000000 through - 11000111 - - - -Deutsch Informational [Page 12] - -RFC 1951 DEFLATE Compressed Data Format Specification May 1996 - - - The code lengths are sufficient to generate the actual codes, - as described above; we show the codes in the table for added - clarity. Literal/length values 286-287 will never actually - occur in the compressed data, but participate in the code - construction. - - Distance codes 0-31 are represented by (fixed-length) 5-bit - codes, with possible additional bits as shown in the table - shown in Paragraph 3.2.5, above. Note that distance codes 30- - 31 will never actually occur in the compressed data. - - 3.2.7. Compression with dynamic Huffman codes (BTYPE=10) - - The Huffman codes for the two alphabets appear in the block - immediately after the header bits and before the actual - compressed data, first the literal/length code and then the - distance code. Each code is defined by a sequence of code - lengths, as discussed in Paragraph 3.2.2, above. For even - greater compactness, the code length sequences themselves are - compressed using a Huffman code. The alphabet for code lengths - is as follows: - - 0 - 15: Represent code lengths of 0 - 15 - 16: Copy the previous code length 3 - 6 times. - The next 2 bits indicate repeat length - (0 = 3, ... , 3 = 6) - Example: Codes 8, 16 (+2 bits 11), - 16 (+2 bits 10) will expand to - 12 code lengths of 8 (1 + 6 + 5) - 17: Repeat a code length of 0 for 3 - 10 times. - (3 bits of length) - 18: Repeat a code length of 0 for 11 - 138 times - (7 bits of length) - - A code length of 0 indicates that the corresponding symbol in - the literal/length or distance alphabet will not occur in the - block, and should not participate in the Huffman code - construction algorithm given earlier. If only one distance - code is used, it is encoded using one bit, not zero bits; in - this case there is a single code length of one, with one unused - code. One distance code of zero bits means that there are no - distance codes used at all (the data is all literals). - - We can now define the format of the block: - - 5 Bits: HLIT, # of Literal/Length codes - 257 (257 - 286) - 5 Bits: HDIST, # of Distance codes - 1 (1 - 32) - 4 Bits: HCLEN, # of Code Length codes - 4 (4 - 19) - - - -Deutsch Informational [Page 13] - -RFC 1951 DEFLATE Compressed Data Format Specification May 1996 - - - (HCLEN + 4) x 3 bits: code lengths for the code length - alphabet given just above, in the order: 16, 17, 18, - 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 - - These code lengths are interpreted as 3-bit integers - (0-7); as above, a code length of 0 means the - corresponding symbol (literal/length or distance code - length) is not used. - - HLIT + 257 code lengths for the literal/length alphabet, - encoded using the code length Huffman code - - HDIST + 1 code lengths for the distance alphabet, - encoded using the code length Huffman code - - The actual compressed data of the block, - encoded using the literal/length and distance Huffman - codes - - The literal/length symbol 256 (end of data), - encoded using the literal/length Huffman code - - The code length repeat codes can cross from HLIT + 257 to the - HDIST + 1 code lengths. In other words, all code lengths form - a single sequence of HLIT + HDIST + 258 values. - - 3.3. Compliance - - A compressor may limit further the ranges of values specified in - the previous section and still be compliant; for example, it may - limit the range of backward pointers to some value smaller than - 32K. Similarly, a compressor may limit the size of blocks so that - a compressible block fits in memory. - - A compliant decompressor must accept the full range of possible - values defined in the previous section, and must accept blocks of - arbitrary size. - -4. Compression algorithm details - - While it is the intent of this document to define the "deflate" - compressed data format without reference to any particular - compression algorithm, the format is related to the compressed - formats produced by LZ77 (Lempel-Ziv 1977, see reference [2] below); - since many variations of LZ77 are patented, it is strongly - recommended that the implementor of a compressor follow the general - algorithm presented here, which is known not to be patented per se. - The material in this section is not part of the definition of the - - - -Deutsch Informational [Page 14] - -RFC 1951 DEFLATE Compressed Data Format Specification May 1996 - - - specification per se, and a compressor need not follow it in order to - be compliant. - - The compressor terminates a block when it determines that starting a - new block with fresh trees would be useful, or when the block size - fills up the compressor's block buffer. - - The compressor uses a chained hash table to find duplicated strings, - using a hash function that operates on 3-byte sequences. At any - given point during compression, let XYZ be the next 3 input bytes to - be examined (not necessarily all different, of course). First, the - compressor examines the hash chain for XYZ. If the chain is empty, - the compressor simply writes out X as a literal byte and advances one - byte in the input. If the hash chain is not empty, indicating that - the sequence XYZ (or, if we are unlucky, some other 3 bytes with the - same hash function value) has occurred recently, the compressor - compares all strings on the XYZ hash chain with the actual input data - sequence starting at the current point, and selects the longest - match. - - The compressor searches the hash chains starting with the most recent - strings, to favor small distances and thus take advantage of the - Huffman encoding. The hash chains are singly linked. There are no - deletions from the hash chains; the algorithm simply discards matches - that are too old. To avoid a worst-case situation, very long hash - chains are arbitrarily truncated at a certain length, determined by a - run-time parameter. - - To improve overall compression, the compressor optionally defers the - selection of matches ("lazy matching"): after a match of length N has - been found, the compressor searches for a longer match starting at - the next input byte. If it finds a longer match, it truncates the - previous match to a length of one (thus producing a single literal - byte) and then emits the longer match. Otherwise, it emits the - original match, and, as described above, advances N bytes before - continuing. - - Run-time parameters also control this "lazy match" procedure. If - compression ratio is most important, the compressor attempts a - complete second search regardless of the length of the first match. - In the normal case, if the current match is "long enough", the - compressor reduces the search for a longer match, thus speeding up - the process. If speed is most important, the compressor inserts new - strings in the hash table only when no match was found, or when the - match is not "too long". This degrades the compression ratio but - saves time since there are both fewer insertions and fewer searches. - - - - - -Deutsch Informational [Page 15] - -RFC 1951 DEFLATE Compressed Data Format Specification May 1996 - - -5. References - - [1] Huffman, D. A., "A Method for the Construction of Minimum - Redundancy Codes", Proceedings of the Institute of Radio - Engineers, September 1952, Volume 40, Number 9, pp. 1098-1101. - - [2] Ziv J., Lempel A., "A Universal Algorithm for Sequential Data - Compression", IEEE Transactions on Information Theory, Vol. 23, - No. 3, pp. 337-343. - - [3] Gailly, J.-L., and Adler, M., ZLIB documentation and sources, - available in ftp://ftp.uu.net/pub/archiving/zip/doc/ - - [4] Gailly, J.-L., and Adler, M., GZIP documentation and sources, - available as gzip-*.tar in ftp://prep.ai.mit.edu/pub/gnu/ - - [5] Schwartz, E. S., and Kallick, B. "Generating a canonical prefix - encoding." Comm. ACM, 7,3 (Mar. 1964), pp. 166-169. - - [6] Hirschberg and Lelewer, "Efficient decoding of prefix codes," - Comm. ACM, 33,4, April 1990, pp. 449-459. - -6. Security Considerations - - Any data compression method involves the reduction of redundancy in - the data. Consequently, any corruption of the data is likely to have - severe effects and be difficult to correct. Uncompressed text, on - the other hand, will probably still be readable despite the presence - of some corrupted bytes. - - It is recommended that systems using this data format provide some - means of validating the integrity of the compressed data. See - reference [3], for example. - -7. Source code - - Source code for a C language implementation of a "deflate" compliant - compressor and decompressor is available within the zlib package at - ftp://ftp.uu.net/pub/archiving/zip/zlib/. - -8. Acknowledgements - - Trademarks cited in this document are the property of their - respective owners. - - Phil Katz designed the deflate format. Jean-Loup Gailly and Mark - Adler wrote the related software described in this specification. - Glenn Randers-Pehrson converted this document to RFC and HTML format. - - - -Deutsch Informational [Page 16] - -RFC 1951 DEFLATE Compressed Data Format Specification May 1996 - - -9. Author's Address - - L. Peter Deutsch - Aladdin Enterprises - 203 Santa Margarita Ave. - Menlo Park, CA 94025 - - Phone: (415) 322-0103 (AM only) - FAX: (415) 322-1734 - EMail: - - Questions about the technical content of this specification can be - sent by email to: - - Jean-Loup Gailly and - Mark Adler - - Editorial comments on this specification can be sent by email to: - - L. Peter Deutsch and - Glenn Randers-Pehrson - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Deutsch Informational [Page 17] - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/doc/rfc1952.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/doc/rfc1952.txt deleted file mode 100644 index a8e51b4..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/doc/rfc1952.txt +++ /dev/null @@ -1,675 +0,0 @@ - - - - - - -Network Working Group P. Deutsch -Request for Comments: 1952 Aladdin Enterprises -Category: Informational May 1996 - - - GZIP file format specification version 4.3 - -Status of This Memo - - This memo provides information for the Internet community. This memo - does not specify an Internet standard of any kind. Distribution of - this memo is unlimited. - -IESG Note: - - The IESG takes no position on the validity of any Intellectual - Property Rights statements contained in this document. - -Notices - - Copyright (c) 1996 L. Peter Deutsch - - Permission is granted to copy and distribute this document for any - purpose and without charge, including translations into other - languages and incorporation into compilations, provided that the - copyright notice and this notice are preserved, and that any - substantive changes or deletions from the original are clearly - marked. - - A pointer to the latest version of this and related documentation in - HTML format can be found at the URL - . - -Abstract - - This specification defines a lossless compressed data format that is - compatible with the widely used GZIP utility. The format includes a - cyclic redundancy check value for detecting data corruption. The - format presently uses the DEFLATE method of compression but can be - easily extended to use other compression methods. The format can be - implemented readily in a manner not covered by patents. - - - - - - - - - - -Deutsch Informational [Page 1] - -RFC 1952 GZIP File Format Specification May 1996 - - -Table of Contents - - 1. Introduction ................................................... 2 - 1.1. Purpose ................................................... 2 - 1.2. Intended audience ......................................... 3 - 1.3. Scope ..................................................... 3 - 1.4. Compliance ................................................ 3 - 1.5. Definitions of terms and conventions used ................. 3 - 1.6. Changes from previous versions ............................ 3 - 2. Detailed specification ......................................... 4 - 2.1. Overall conventions ....................................... 4 - 2.2. File format ............................................... 5 - 2.3. Member format ............................................. 5 - 2.3.1. Member header and trailer ........................... 6 - 2.3.1.1. Extra field ................................... 8 - 2.3.1.2. Compliance .................................... 9 - 3. References .................................................. 9 - 4. Security Considerations .................................... 10 - 5. Acknowledgements ........................................... 10 - 6. Author's Address ........................................... 10 - 7. Appendix: Jean-Loup Gailly's gzip utility .................. 11 - 8. Appendix: Sample CRC Code .................................. 11 - -1. Introduction - - 1.1. Purpose - - The purpose of this specification is to define a lossless - compressed data format that: - - * Is independent of CPU type, operating system, file system, - and character set, and hence can be used for interchange; - * Can compress or decompress a data stream (as opposed to a - randomly accessible file) to produce another data stream, - using only an a priori bounded amount of intermediate - storage, and hence can be used in data communications or - similar structures such as Unix filters; - * Compresses data with efficiency comparable to the best - currently available general-purpose compression methods, - and in particular considerably better than the "compress" - program; - * Can be implemented readily in a manner not covered by - patents, and hence can be practiced freely; - * Is compatible with the file format produced by the current - widely used gzip utility, in that conforming decompressors - will be able to read data produced by the existing gzip - compressor. - - - - -Deutsch Informational [Page 2] - -RFC 1952 GZIP File Format Specification May 1996 - - - The data format defined by this specification does not attempt to: - - * Provide random access to compressed data; - * Compress specialized data (e.g., raster graphics) as well as - the best currently available specialized algorithms. - - 1.2. Intended audience - - This specification is intended for use by implementors of software - to compress data into gzip format and/or decompress data from gzip - format. - - The text of the specification assumes a basic background in - programming at the level of bits and other primitive data - representations. - - 1.3. Scope - - The specification specifies a compression method and a file format - (the latter assuming only that a file can store a sequence of - arbitrary bytes). It does not specify any particular interface to - a file system or anything about character sets or encodings - (except for file names and comments, which are optional). - - 1.4. Compliance - - Unless otherwise indicated below, a compliant decompressor must be - able to accept and decompress any file that conforms to all the - specifications presented here; a compliant compressor must produce - files that conform to all the specifications presented here. The - material in the appendices is not part of the specification per se - and is not relevant to compliance. - - 1.5. Definitions of terms and conventions used - - byte: 8 bits stored or transmitted as a unit (same as an octet). - (For this specification, a byte is exactly 8 bits, even on - machines which store a character on a number of bits different - from 8.) See below for the numbering of bits within a byte. - - 1.6. Changes from previous versions - - There have been no technical changes to the gzip format since - version 4.1 of this specification. In version 4.2, some - terminology was changed, and the sample CRC code was rewritten for - clarity and to eliminate the requirement for the caller to do pre- - and post-conditioning. Version 4.3 is a conversion of the - specification to RFC style. - - - -Deutsch Informational [Page 3] - -RFC 1952 GZIP File Format Specification May 1996 - - -2. Detailed specification - - 2.1. Overall conventions - - In the diagrams below, a box like this: - - +---+ - | | <-- the vertical bars might be missing - +---+ - - represents one byte; a box like this: - - +==============+ - | | - +==============+ - - represents a variable number of bytes. - - Bytes stored within a computer do not have a "bit order", since - they are always treated as a unit. However, a byte considered as - an integer between 0 and 255 does have a most- and least- - significant bit, and since we write numbers with the most- - significant digit on the left, we also write bytes with the most- - significant bit on the left. In the diagrams below, we number the - bits of a byte so that bit 0 is the least-significant bit, i.e., - the bits are numbered: - - +--------+ - |76543210| - +--------+ - - This document does not address the issue of the order in which - bits of a byte are transmitted on a bit-sequential medium, since - the data format described here is byte- rather than bit-oriented. - - Within a computer, a number may occupy multiple bytes. All - multi-byte numbers in the format described here are stored with - the least-significant byte first (at the lower memory address). - For example, the decimal number 520 is stored as: - - 0 1 - +--------+--------+ - |00001000|00000010| - +--------+--------+ - ^ ^ - | | - | + more significant byte = 2 x 256 - + less significant byte = 8 - - - -Deutsch Informational [Page 4] - -RFC 1952 GZIP File Format Specification May 1996 - - - 2.2. File format - - A gzip file consists of a series of "members" (compressed data - sets). The format of each member is specified in the following - section. The members simply appear one after another in the file, - with no additional information before, between, or after them. - - 2.3. Member format - - Each member has the following structure: - - +---+---+---+---+---+---+---+---+---+---+ - |ID1|ID2|CM |FLG| MTIME |XFL|OS | (more-->) - +---+---+---+---+---+---+---+---+---+---+ - - (if FLG.FEXTRA set) - - +---+---+=================================+ - | XLEN |...XLEN bytes of "extra field"...| (more-->) - +---+---+=================================+ - - (if FLG.FNAME set) - - +=========================================+ - |...original file name, zero-terminated...| (more-->) - +=========================================+ - - (if FLG.FCOMMENT set) - - +===================================+ - |...file comment, zero-terminated...| (more-->) - +===================================+ - - (if FLG.FHCRC set) - - +---+---+ - | CRC16 | - +---+---+ - - +=======================+ - |...compressed blocks...| (more-->) - +=======================+ - - 0 1 2 3 4 5 6 7 - +---+---+---+---+---+---+---+---+ - | CRC32 | ISIZE | - +---+---+---+---+---+---+---+---+ - - - - -Deutsch Informational [Page 5] - -RFC 1952 GZIP File Format Specification May 1996 - - - 2.3.1. Member header and trailer - - ID1 (IDentification 1) - ID2 (IDentification 2) - These have the fixed values ID1 = 31 (0x1f, \037), ID2 = 139 - (0x8b, \213), to identify the file as being in gzip format. - - CM (Compression Method) - This identifies the compression method used in the file. CM - = 0-7 are reserved. CM = 8 denotes the "deflate" - compression method, which is the one customarily used by - gzip and which is documented elsewhere. - - FLG (FLaGs) - This flag byte is divided into individual bits as follows: - - bit 0 FTEXT - bit 1 FHCRC - bit 2 FEXTRA - bit 3 FNAME - bit 4 FCOMMENT - bit 5 reserved - bit 6 reserved - bit 7 reserved - - If FTEXT is set, the file is probably ASCII text. This is - an optional indication, which the compressor may set by - checking a small amount of the input data to see whether any - non-ASCII characters are present. In case of doubt, FTEXT - is cleared, indicating binary data. For systems which have - different file formats for ascii text and binary data, the - decompressor can use FTEXT to choose the appropriate format. - We deliberately do not specify the algorithm used to set - this bit, since a compressor always has the option of - leaving it cleared and a decompressor always has the option - of ignoring it and letting some other program handle issues - of data conversion. - - If FHCRC is set, a CRC16 for the gzip header is present, - immediately before the compressed data. The CRC16 consists - of the two least significant bytes of the CRC32 for all - bytes of the gzip header up to and not including the CRC16. - [The FHCRC bit was never set by versions of gzip up to - 1.2.4, even though it was documented with a different - meaning in gzip 1.2.4.] - - If FEXTRA is set, optional extra fields are present, as - described in a following section. - - - -Deutsch Informational [Page 6] - -RFC 1952 GZIP File Format Specification May 1996 - - - If FNAME is set, an original file name is present, - terminated by a zero byte. The name must consist of ISO - 8859-1 (LATIN-1) characters; on operating systems using - EBCDIC or any other character set for file names, the name - must be translated to the ISO LATIN-1 character set. This - is the original name of the file being compressed, with any - directory components removed, and, if the file being - compressed is on a file system with case insensitive names, - forced to lower case. There is no original file name if the - data was compressed from a source other than a named file; - for example, if the source was stdin on a Unix system, there - is no file name. - - If FCOMMENT is set, a zero-terminated file comment is - present. This comment is not interpreted; it is only - intended for human consumption. The comment must consist of - ISO 8859-1 (LATIN-1) characters. Line breaks should be - denoted by a single line feed character (10 decimal). - - Reserved FLG bits must be zero. - - MTIME (Modification TIME) - This gives the most recent modification time of the original - file being compressed. The time is in Unix format, i.e., - seconds since 00:00:00 GMT, Jan. 1, 1970. (Note that this - may cause problems for MS-DOS and other systems that use - local rather than Universal time.) If the compressed data - did not come from a file, MTIME is set to the time at which - compression started. MTIME = 0 means no time stamp is - available. - - XFL (eXtra FLags) - These flags are available for use by specific compression - methods. The "deflate" method (CM = 8) sets these flags as - follows: - - XFL = 2 - compressor used maximum compression, - slowest algorithm - XFL = 4 - compressor used fastest algorithm - - OS (Operating System) - This identifies the type of file system on which compression - took place. This may be useful in determining end-of-line - convention for text files. The currently defined values are - as follows: - - - - - - -Deutsch Informational [Page 7] - -RFC 1952 GZIP File Format Specification May 1996 - - - 0 - FAT filesystem (MS-DOS, OS/2, NT/Win32) - 1 - Amiga - 2 - VMS (or OpenVMS) - 3 - Unix - 4 - VM/CMS - 5 - Atari TOS - 6 - HPFS filesystem (OS/2, NT) - 7 - Macintosh - 8 - Z-System - 9 - CP/M - 10 - TOPS-20 - 11 - NTFS filesystem (NT) - 12 - QDOS - 13 - Acorn RISCOS - 255 - unknown - - XLEN (eXtra LENgth) - If FLG.FEXTRA is set, this gives the length of the optional - extra field. See below for details. - - CRC32 (CRC-32) - This contains a Cyclic Redundancy Check value of the - uncompressed data computed according to CRC-32 algorithm - used in the ISO 3309 standard and in section 8.1.1.6.2 of - ITU-T recommendation V.42. (See http://www.iso.ch for - ordering ISO documents. See gopher://info.itu.ch for an - online version of ITU-T V.42.) - - ISIZE (Input SIZE) - This contains the size of the original (uncompressed) input - data modulo 2^32. - - 2.3.1.1. Extra field - - If the FLG.FEXTRA bit is set, an "extra field" is present in - the header, with total length XLEN bytes. It consists of a - series of subfields, each of the form: - - +---+---+---+---+==================================+ - |SI1|SI2| LEN |... LEN bytes of subfield data ...| - +---+---+---+---+==================================+ - - SI1 and SI2 provide a subfield ID, typically two ASCII letters - with some mnemonic value. Jean-Loup Gailly - is maintaining a registry of subfield - IDs; please send him any subfield ID you wish to use. Subfield - IDs with SI2 = 0 are reserved for future use. The following - IDs are currently defined: - - - -Deutsch Informational [Page 8] - -RFC 1952 GZIP File Format Specification May 1996 - - - SI1 SI2 Data - ---------- ---------- ---- - 0x41 ('A') 0x70 ('P') Apollo file type information - - LEN gives the length of the subfield data, excluding the 4 - initial bytes. - - 2.3.1.2. Compliance - - A compliant compressor must produce files with correct ID1, - ID2, CM, CRC32, and ISIZE, but may set all the other fields in - the fixed-length part of the header to default values (255 for - OS, 0 for all others). The compressor must set all reserved - bits to zero. - - A compliant decompressor must check ID1, ID2, and CM, and - provide an error indication if any of these have incorrect - values. It must examine FEXTRA/XLEN, FNAME, FCOMMENT and FHCRC - at least so it can skip over the optional fields if they are - present. It need not examine any other part of the header or - trailer; in particular, a decompressor may ignore FTEXT and OS - and always produce binary output, and still be compliant. A - compliant decompressor must give an error indication if any - reserved bit is non-zero, since such a bit could indicate the - presence of a new field that would cause subsequent data to be - interpreted incorrectly. - -3. References - - [1] "Information Processing - 8-bit single-byte coded graphic - character sets - Part 1: Latin alphabet No.1" (ISO 8859-1:1987). - The ISO 8859-1 (Latin-1) character set is a superset of 7-bit - ASCII. Files defining this character set are available as - iso_8859-1.* in ftp://ftp.uu.net/graphics/png/documents/ - - [2] ISO 3309 - - [3] ITU-T recommendation V.42 - - [4] Deutsch, L.P.,"DEFLATE Compressed Data Format Specification", - available in ftp://ftp.uu.net/pub/archiving/zip/doc/ - - [5] Gailly, J.-L., GZIP documentation, available as gzip-*.tar in - ftp://prep.ai.mit.edu/pub/gnu/ - - [6] Sarwate, D.V., "Computation of Cyclic Redundancy Checks via Table - Look-Up", Communications of the ACM, 31(8), pp.1008-1013. - - - - -Deutsch Informational [Page 9] - -RFC 1952 GZIP File Format Specification May 1996 - - - [7] Schwaderer, W.D., "CRC Calculation", April 85 PC Tech Journal, - pp.118-133. - - [8] ftp://ftp.adelaide.edu.au/pub/rocksoft/papers/crc_v3.txt, - describing the CRC concept. - -4. Security Considerations - - Any data compression method involves the reduction of redundancy in - the data. Consequently, any corruption of the data is likely to have - severe effects and be difficult to correct. Uncompressed text, on - the other hand, will probably still be readable despite the presence - of some corrupted bytes. - - It is recommended that systems using this data format provide some - means of validating the integrity of the compressed data, such as by - setting and checking the CRC-32 check value. - -5. Acknowledgements - - Trademarks cited in this document are the property of their - respective owners. - - Jean-Loup Gailly designed the gzip format and wrote, with Mark Adler, - the related software described in this specification. Glenn - Randers-Pehrson converted this document to RFC and HTML format. - -6. Author's Address - - L. Peter Deutsch - Aladdin Enterprises - 203 Santa Margarita Ave. - Menlo Park, CA 94025 - - Phone: (415) 322-0103 (AM only) - FAX: (415) 322-1734 - EMail: - - Questions about the technical content of this specification can be - sent by email to: - - Jean-Loup Gailly and - Mark Adler - - Editorial comments on this specification can be sent by email to: - - L. Peter Deutsch and - Glenn Randers-Pehrson - - - -Deutsch Informational [Page 10] - -RFC 1952 GZIP File Format Specification May 1996 - - -7. Appendix: Jean-Loup Gailly's gzip utility - - The most widely used implementation of gzip compression, and the - original documentation on which this specification is based, were - created by Jean-Loup Gailly . Since this - implementation is a de facto standard, we mention some more of its - features here. Again, the material in this section is not part of - the specification per se, and implementations need not follow it to - be compliant. - - When compressing or decompressing a file, gzip preserves the - protection, ownership, and modification time attributes on the local - file system, since there is no provision for representing protection - attributes in the gzip file format itself. Since the file format - includes a modification time, the gzip decompressor provides a - command line switch that assigns the modification time from the file, - rather than the local modification time of the compressed input, to - the decompressed output. - -8. Appendix: Sample CRC Code - - The following sample code represents a practical implementation of - the CRC (Cyclic Redundancy Check). (See also ISO 3309 and ITU-T V.42 - for a formal specification.) - - The sample code is in the ANSI C programming language. Non C users - may find it easier to read with these hints: - - & Bitwise AND operator. - ^ Bitwise exclusive-OR operator. - >> Bitwise right shift operator. When applied to an - unsigned quantity, as here, right shift inserts zero - bit(s) at the left. - ! Logical NOT operator. - ++ "n++" increments the variable n. - 0xNNN 0x introduces a hexadecimal (base 16) constant. - Suffix L indicates a long value (at least 32 bits). - - /* Table of CRCs of all 8-bit messages. */ - unsigned long crc_table[256]; - - /* Flag: has the table been computed? Initially false. */ - int crc_table_computed = 0; - - /* Make the table for a fast CRC. */ - void make_crc_table(void) - { - unsigned long c; - - - -Deutsch Informational [Page 11] - -RFC 1952 GZIP File Format Specification May 1996 - - - int n, k; - for (n = 0; n < 256; n++) { - c = (unsigned long) n; - for (k = 0; k < 8; k++) { - if (c & 1) { - c = 0xedb88320L ^ (c >> 1); - } else { - c = c >> 1; - } - } - crc_table[n] = c; - } - crc_table_computed = 1; - } - - /* - Update a running crc with the bytes buf[0..len-1] and return - the updated crc. The crc should be initialized to zero. Pre- and - post-conditioning (one's complement) is performed within this - function so it shouldn't be done by the caller. Usage example: - - unsigned long crc = 0L; - - while (read_buffer(buffer, length) != EOF) { - crc = update_crc(crc, buffer, length); - } - if (crc != original_crc) error(); - */ - unsigned long update_crc(unsigned long crc, - unsigned char *buf, int len) - { - unsigned long c = crc ^ 0xffffffffL; - int n; - - if (!crc_table_computed) - make_crc_table(); - for (n = 0; n < len; n++) { - c = crc_table[(c ^ buf[n]) & 0xff] ^ (c >> 8); - } - return c ^ 0xffffffffL; - } - - /* Return the CRC of the bytes buf[0..len-1]. */ - unsigned long crc(unsigned char *buf, int len) - { - return update_crc(0L, buf, len); - } - - - - -Deutsch Informational [Page 12] - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/doc/txtvsbin.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/doc/txtvsbin.txt deleted file mode 100644 index 2a901ea..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/doc/txtvsbin.txt +++ /dev/null @@ -1,107 +0,0 @@ -A Fast Method for Identifying Plain Text Files -============================================== - - -Introduction ------------- - -Given a file coming from an unknown source, it is sometimes desirable -to find out whether the format of that file is plain text. Although -this may appear like a simple task, a fully accurate detection of the -file type requires heavy-duty semantic analysis on the file contents. -It is, however, possible to obtain satisfactory results by employing -various heuristics. - -Previous versions of PKZip and other zip-compatible compression tools -were using a crude detection scheme: if more than 80% (4/5) of the bytes -found in a certain buffer are within the range [7..127], the file is -labeled as plain text, otherwise it is labeled as binary. A prominent -limitation of this scheme is the restriction to Latin-based alphabets. -Other alphabets, like Greek, Cyrillic or Asian, make extensive use of -the bytes within the range [128..255], and texts using these alphabets -are most often misidentified by this scheme; in other words, the rate -of false negatives is sometimes too high, which means that the recall -is low. Another weakness of this scheme is a reduced precision, due to -the false positives that may occur when binary files containing large -amounts of textual characters are misidentified as plain text. - -In this article we propose a new, simple detection scheme that features -a much increased precision and a near-100% recall. This scheme is -designed to work on ASCII, Unicode and other ASCII-derived alphabets, -and it handles single-byte encodings (ISO-8859, MacRoman, KOI8, etc.) -and variable-sized encodings (ISO-2022, UTF-8, etc.). Wider encodings -(UCS-2/UTF-16 and UCS-4/UTF-32) are not handled, however. - - -The Algorithm -------------- - -The algorithm works by dividing the set of bytecodes [0..255] into three -categories: -- The allow list of textual bytecodes: - 9 (TAB), 10 (LF), 13 (CR), 32 (SPACE) to 255. -- The gray list of tolerated bytecodes: - 7 (BEL), 8 (BS), 11 (VT), 12 (FF), 26 (SUB), 27 (ESC). -- The block list of undesired, non-textual bytecodes: - 0 (NUL) to 6, 14 to 31. - -If a file contains at least one byte that belongs to the allow list and -no byte that belongs to the block list, then the file is categorized as -plain text; otherwise, it is categorized as binary. (The boundary case, -when the file is empty, automatically falls into the latter category.) - - -Rationale ---------- - -The idea behind this algorithm relies on two observations. - -The first observation is that, although the full range of 7-bit codes -[0..127] is properly specified by the ASCII standard, most control -characters in the range [0..31] are not used in practice. The only -widely-used, almost universally-portable control codes are 9 (TAB), -10 (LF) and 13 (CR). There are a few more control codes that are -recognized on a reduced range of platforms and text viewers/editors: -7 (BEL), 8 (BS), 11 (VT), 12 (FF), 26 (SUB) and 27 (ESC); but these -codes are rarely (if ever) used alone, without being accompanied by -some printable text. Even the newer, portable text formats such as -XML avoid using control characters outside the list mentioned here. - -The second observation is that most of the binary files tend to contain -control characters, especially 0 (NUL). Even though the older text -detection schemes observe the presence of non-ASCII codes from the range -[128..255], the precision rarely has to suffer if this upper range is -labeled as textual, because the files that are genuinely binary tend to -contain both control characters and codes from the upper range. On the -other hand, the upper range needs to be labeled as textual, because it -is used by virtually all ASCII extensions. In particular, this range is -used for encoding non-Latin scripts. - -Since there is no counting involved, other than simply observing the -presence or the absence of some byte values, the algorithm produces -consistent results, regardless what alphabet encoding is being used. -(If counting were involved, it could be possible to obtain different -results on a text encoded, say, using ISO-8859-16 versus UTF-8.) - -There is an extra category of plain text files that are "polluted" with -one or more block-listed codes, either by mistake or by peculiar design -considerations. In such cases, a scheme that tolerates a small fraction -of block-listed codes would provide an increased recall (i.e. more true -positives). This, however, incurs a reduced precision overall, since -false positives are more likely to appear in binary files that contain -large chunks of textual data. Furthermore, "polluted" plain text should -be regarded as binary by general-purpose text detection schemes, because -general-purpose text processing algorithms might not be applicable. -Under this premise, it is safe to say that our detection method provides -a near-100% recall. - -Experiments have been run on many files coming from various platforms -and applications. We tried plain text files, system logs, source code, -formatted office documents, compiled object code, etc. The results -confirm the optimistic assumptions about the capabilities of this -algorithm. - - --- -Cosmin Truta -Last updated: 2006-May-28 diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/README.examples b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/README.examples deleted file mode 100644 index e3a4b88..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/README.examples +++ /dev/null @@ -1,54 +0,0 @@ -This directory contains examples of the use of zlib and other relevant -programs and documentation. - -enough.c - calculation and justification of ENOUGH parameter in inftrees.h - - calculates the maximum table space used in inflate tree - construction over all possible Huffman codes - -fitblk.c - compress just enough input to nearly fill a requested output size - - zlib isn't designed to do this, but fitblk does it anyway - -gun.c - uncompress a gzip file - - illustrates the use of inflateBack() for high speed file-to-file - decompression using call-back functions - - is approximately twice as fast as gzip -d - - also provides Unix uncompress functionality, again twice as fast - -gzappend.c - append to a gzip file - - illustrates the use of the Z_BLOCK flush parameter for inflate() - - illustrates the use of deflatePrime() to start at any bit - -gzjoin.c - join gzip files without recalculating the crc or recompressing - - illustrates the use of the Z_BLOCK flush parameter for inflate() - - illustrates the use of crc32_combine() - -gzlog.c -gzlog.h - efficiently and robustly maintain a message log file in gzip format - - illustrates use of raw deflate, Z_PARTIAL_FLUSH, deflatePrime(), - and deflateSetDictionary() - - illustrates use of a gzip header extra field - -gznorm.c - normalize a gzip file by combining members into a single member - - demonstrates how to concatenate deflate streams using Z_BLOCK - -zlib_how.html - painfully comprehensive description of zpipe.c (see below) - - describes in excruciating detail the use of deflate() and inflate() - -zpipe.c - reads and writes zlib streams from stdin to stdout - - illustrates the proper use of deflate() and inflate() - - deeply commented in zlib_how.html (see above) - -zran.c -zran.h - index a zlib or gzip stream and randomly access it - - illustrates the use of Z_BLOCK, inflatePrime(), and - inflateSetDictionary() to provide random access diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/enough.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/enough.c deleted file mode 100644 index 19cf08c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/enough.c +++ /dev/null @@ -1,597 +0,0 @@ -/* enough.c -- determine the maximum size of inflate's Huffman code tables over - * all possible valid and complete prefix codes, subject to a length limit. - * Copyright (C) 2007, 2008, 2012, 2018 Mark Adler - * Version 1.5 5 August 2018 Mark Adler - */ - -/* Version history: - 1.0 3 Jan 2007 First version (derived from codecount.c version 1.4) - 1.1 4 Jan 2007 Use faster incremental table usage computation - Prune examine() search on previously visited states - 1.2 5 Jan 2007 Comments clean up - As inflate does, decrease root for short codes - Refuse cases where inflate would increase root - 1.3 17 Feb 2008 Add argument for initial root table size - Fix bug for initial root table size == max - 1 - Use a macro to compute the history index - 1.4 18 Aug 2012 Avoid shifts more than bits in type (caused endless loop!) - Clean up comparisons of different types - Clean up code indentation - 1.5 5 Aug 2018 Clean up code style, formatting, and comments - Show all the codes for the maximum, and only the maximum - */ - -/* - Examine all possible prefix codes for a given number of symbols and a - maximum code length in bits to determine the maximum table size for zlib's - inflate. Only complete prefix codes are counted. - - Two codes are considered distinct if the vectors of the number of codes per - length are not identical. So permutations of the symbol assignments result - in the same code for the counting, as do permutations of the assignments of - the bit values to the codes (i.e. only canonical codes are counted). - - We build a code from shorter to longer lengths, determining how many symbols - are coded at each length. At each step, we have how many symbols remain to - be coded, what the last code length used was, and how many bit patterns of - that length remain unused. Then we add one to the code length and double the - number of unused patterns to graduate to the next code length. We then - assign all portions of the remaining symbols to that code length that - preserve the properties of a correct and eventually complete code. Those - properties are: we cannot use more bit patterns than are available; and when - all the symbols are used, there are exactly zero possible bit patterns left - unused. - - The inflate Huffman decoding algorithm uses two-level lookup tables for - speed. There is a single first-level table to decode codes up to root bits - in length (root == 9 for literal/length codes and root == 6 for distance - codes, in the current inflate implementation). The base table has 1 << root - entries and is indexed by the next root bits of input. Codes shorter than - root bits have replicated table entries, so that the correct entry is - pointed to regardless of the bits that follow the short code. If the code is - longer than root bits, then the table entry points to a second-level table. - The size of that table is determined by the longest code with that root-bit - prefix. If that longest code has length len, then the table has size 1 << - (len - root), to index the remaining bits in that set of codes. Each - subsequent root-bit prefix then has its own sub-table. The total number of - table entries required by the code is calculated incrementally as the number - of codes at each bit length is populated. When all of the codes are shorter - than root bits, then root is reduced to the longest code length, resulting - in a single, smaller, one-level table. - - The inflate algorithm also provides for small values of root (relative to - the log2 of the number of symbols), where the shortest code has more bits - than root. In that case, root is increased to the length of the shortest - code. This program, by design, does not handle that case, so it is verified - that the number of symbols is less than 1 << (root + 1). - - In order to speed up the examination (by about ten orders of magnitude for - the default arguments), the intermediate states in the build-up of a code - are remembered and previously visited branches are pruned. The memory - required for this will increase rapidly with the total number of symbols and - the maximum code length in bits. However this is a very small price to pay - for the vast speedup. - - First, all of the possible prefix codes are counted, and reachable - intermediate states are noted by a non-zero count in a saved-results array. - Second, the intermediate states that lead to (root + 1) bit or longer codes - are used to look at all sub-codes from those junctures for their inflate - memory usage. (The amount of memory used is not affected by the number of - codes of root bits or less in length.) Third, the visited states in the - construction of those sub-codes and the associated calculation of the table - size is recalled in order to avoid recalculating from the same juncture. - Beginning the code examination at (root + 1) bit codes, which is enabled by - identifying the reachable nodes, accounts for about six of the orders of - magnitude of improvement for the default arguments. About another four - orders of magnitude come from not revisiting previous states. Out of - approximately 2x10^16 possible prefix codes, only about 2x10^6 sub-codes - need to be examined to cover all of the possible table memory usage cases - for the default arguments of 286 symbols limited to 15-bit codes. - - Note that the uintmax_t type is used for counting. It is quite easy to - exceed the capacity of an eight-byte integer with a large number of symbols - and a large maximum code length, so multiple-precision arithmetic would need - to replace the integer arithmetic in that case. This program will abort if - an overflow occurs. The big_t type identifies where the counting takes - place. - - The uintmax_t type is also used for calculating the number of possible codes - remaining at the maximum length. This limits the maximum code length to the - number of bits in a long long minus the number of bits needed to represent - the symbols in a flat code. The code_t type identifies where the bit-pattern - counting takes place. - */ - -#include -#include -#include -#include -#include -#include - -#define local static - -// Special data types. -typedef uintmax_t big_t; // type for code counting -#define PRIbig "ju" // printf format for big_t -typedef uintmax_t code_t; // type for bit pattern counting -struct tab { // type for been-here check - size_t len; // allocated length of bit vector in octets - char *vec; // allocated bit vector -}; - -/* The array for saving results, num[], is indexed with this triplet: - - syms: number of symbols remaining to code - left: number of available bit patterns at length len - len: number of bits in the codes currently being assigned - - Those indices are constrained thusly when saving results: - - syms: 3..totsym (totsym == total symbols to code) - left: 2..syms - 1, but only the evens (so syms == 8 -> 2, 4, 6) - len: 1..max - 1 (max == maximum code length in bits) - - syms == 2 is not saved since that immediately leads to a single code. left - must be even, since it represents the number of available bit patterns at - the current length, which is double the number at the previous length. left - ends at syms-1 since left == syms immediately results in a single code. - (left > sym is not allowed since that would result in an incomplete code.) - len is less than max, since the code completes immediately when len == max. - - The offset into the array is calculated for the three indices with the first - one (syms) being outermost, and the last one (len) being innermost. We build - the array with length max-1 lists for the len index, with syms-3 of those - for each symbol. There are totsym-2 of those, with each one varying in - length as a function of sym. See the calculation of index in map() for the - index, and the calculation of size in main() for the size of the array. - - For the deflate example of 286 symbols limited to 15-bit codes, the array - has 284,284 entries, taking up 2.17 MB for an 8-byte big_t. More than half - of the space allocated for saved results is actually used -- not all - possible triplets are reached in the generation of valid prefix codes. - */ - -/* The array for tracking visited states, done[], is itself indexed identically - to the num[] array as described above for the (syms, left, len) triplet. - Each element in the array is further indexed by the (mem, rem) doublet, - where mem is the amount of inflate table space used so far, and rem is the - remaining unused entries in the current inflate sub-table. Each indexed - element is simply one bit indicating whether the state has been visited or - not. Since the ranges for mem and rem are not known a priori, each bit - vector is of a variable size, and grows as needed to accommodate the visited - states. mem and rem are used to calculate a single index in a triangular - array. Since the range of mem is expected in the default case to be about - ten times larger than the range of rem, the array is skewed to reduce the - memory usage, with eight times the range for mem than for rem. See the - calculations for offset and bit in been_here() for the details. - - For the deflate example of 286 symbols limited to 15-bit codes, the bit - vectors grow to total 5.5 MB, in addition to the 4.3 MB done array itself. - */ - -// Type for a variable-length, allocated string. -typedef struct { - char *str; // pointer to allocated string - size_t size; // size of allocation - size_t len; // length of string, not including terminating zero -} string_t; - -// Clear a string_t. -local void string_clear(string_t *s) { - s->str[0] = 0; - s->len = 0; -} - -// Initialize a string_t. -local void string_init(string_t *s) { - s->size = 16; - s->str = malloc(s->size); - assert(s->str != NULL && "out of memory"); - string_clear(s); -} - -// Release the allocation of a string_t. -local void string_free(string_t *s) { - free(s->str); - s->str = NULL; - s->size = 0; - s->len = 0; -} - -// Save the results of printf with fmt and the subsequent argument list to s. -// Each call appends to s. The allocated space for s is increased as needed. -local void string_printf(string_t *s, char *fmt, ...) { - va_list ap; - va_start(ap, fmt); - size_t len = s->len; - int ret = vsnprintf(s->str + len, s->size - len, fmt, ap); - assert(ret >= 0 && "out of memory"); - s->len += ret; - if (s->size < s->len + 1) { - do { - s->size <<= 1; - assert(s->size != 0 && "overflow"); - } while (s->size < s->len + 1); - s->str = realloc(s->str, s->size); - assert(s->str != NULL && "out of memory"); - vsnprintf(s->str + len, s->size - len, fmt, ap); - } - va_end(ap); -} - -// Globals to avoid propagating constants or constant pointers recursively. -struct { - int max; // maximum allowed bit length for the codes - int root; // size of base code table in bits - int large; // largest code table so far - size_t size; // number of elements in num and done - big_t tot; // total number of codes with maximum tables size - string_t out; // display of subcodes for maximum tables size - int *code; // number of symbols assigned to each bit length - big_t *num; // saved results array for code counting - struct tab *done; // states already evaluated array -} g; - -// Index function for num[] and done[]. -local inline size_t map(int syms, int left, int len) { - return ((size_t)((syms - 1) >> 1) * ((syms - 2) >> 1) + - (left >> 1) - 1) * (g.max - 1) + - len - 1; -} - -// Free allocated space in globals. -local void cleanup(void) { - if (g.done != NULL) { - for (size_t n = 0; n < g.size; n++) - if (g.done[n].len) - free(g.done[n].vec); - g.size = 0; - free(g.done); g.done = NULL; - } - free(g.num); g.num = NULL; - free(g.code); g.code = NULL; - string_free(&g.out); -} - -// Return the number of possible prefix codes using bit patterns of lengths len -// through max inclusive, coding syms symbols, with left bit patterns of length -// len unused -- return -1 if there is an overflow in the counting. Keep a -// record of previous results in num to prevent repeating the same calculation. -local big_t count(int syms, int left, int len) { - // see if only one possible code - if (syms == left) - return 1; - - // note and verify the expected state - assert(syms > left && left > 0 && len < g.max); - - // see if we've done this one already - size_t index = map(syms, left, len); - big_t got = g.num[index]; - if (got) - return got; // we have -- return the saved result - - // we need to use at least this many bit patterns so that the code won't be - // incomplete at the next length (more bit patterns than symbols) - int least = (left << 1) - syms; - if (least < 0) - least = 0; - - // we can use at most this many bit patterns, lest there not be enough - // available for the remaining symbols at the maximum length (if there were - // no limit to the code length, this would become: most = left - 1) - int most = (((code_t)left << (g.max - len)) - syms) / - (((code_t)1 << (g.max - len)) - 1); - - // count all possible codes from this juncture and add them up - big_t sum = 0; - for (int use = least; use <= most; use++) { - got = count(syms - use, (left - use) << 1, len + 1); - sum += got; - if (got == (big_t)-1 || sum < got) // overflow - return (big_t)-1; - } - - // verify that all recursive calls are productive - assert(sum != 0); - - // save the result and return it - g.num[index] = sum; - return sum; -} - -// Return true if we've been here before, set to true if not. Set a bit in a -// bit vector to indicate visiting this state. Each (syms,len,left) state has a -// variable size bit vector indexed by (mem,rem). The bit vector is lengthened -// as needed to allow setting the (mem,rem) bit. -local int been_here(int syms, int left, int len, int mem, int rem) { - // point to vector for (syms,left,len), bit in vector for (mem,rem) - size_t index = map(syms, left, len); - mem -= 1 << g.root; // mem always includes the root table - mem >>= 1; // mem and rem are always even - rem >>= 1; - size_t offset = (mem >> 3) + rem; - offset = ((offset * (offset + 1)) >> 1) + rem; - int bit = 1 << (mem & 7); - - // see if we've been here - size_t length = g.done[index].len; - if (offset < length && (g.done[index].vec[offset] & bit) != 0) - return 1; // done this! - - // we haven't been here before -- set the bit to show we have now - - // see if we need to lengthen the vector in order to set the bit - if (length <= offset) { - // if we have one already, enlarge it, zero out the appended space - char *vector; - if (length) { - do { - length <<= 1; - } while (length <= offset); - vector = realloc(g.done[index].vec, length); - assert(vector != NULL && "out of memory"); - memset(vector + g.done[index].len, 0, length - g.done[index].len); - } - - // otherwise we need to make a new vector and zero it out - else { - length = 16; - while (length <= offset) - length <<= 1; - vector = calloc(length, 1); - assert(vector != NULL && "out of memory"); - } - - // install the new vector - g.done[index].len = length; - g.done[index].vec = vector; - } - - // set the bit - g.done[index].vec[offset] |= bit; - return 0; -} - -// Examine all possible codes from the given node (syms, len, left). Compute -// the amount of memory required to build inflate's decoding tables, where the -// number of code structures used so far is mem, and the number remaining in -// the current sub-table is rem. -local void examine(int syms, int left, int len, int mem, int rem) { - // see if we have a complete code - if (syms == left) { - // set the last code entry - g.code[len] = left; - - // complete computation of memory used by this code - while (rem < left) { - left -= rem; - rem = 1 << (len - g.root); - mem += rem; - } - assert(rem == left); - - // if this is at the maximum, show the sub-code - if (mem >= g.large) { - // if this is a new maximum, update the maximum and clear out the - // printed sub-codes from the previous maximum - if (mem > g.large) { - g.large = mem; - string_clear(&g.out); - } - - // compute the starting state for this sub-code - syms = 0; - left = 1 << g.max; - for (int bits = g.max; bits > g.root; bits--) { - syms += g.code[bits]; - left -= g.code[bits]; - assert((left & 1) == 0); - left >>= 1; - } - - // print the starting state and the resulting sub-code to g.out - string_printf(&g.out, "<%u, %u, %u>:", - syms, g.root + 1, ((1 << g.root) - left) << 1); - for (int bits = g.root + 1; bits <= g.max; bits++) - if (g.code[bits]) - string_printf(&g.out, " %d[%d]", g.code[bits], bits); - string_printf(&g.out, "\n"); - } - - // remove entries as we drop back down in the recursion - g.code[len] = 0; - return; - } - - // prune the tree if we can - if (been_here(syms, left, len, mem, rem)) - return; - - // we need to use at least this many bit patterns so that the code won't be - // incomplete at the next length (more bit patterns than symbols) - int least = (left << 1) - syms; - if (least < 0) - least = 0; - - // we can use at most this many bit patterns, lest there not be enough - // available for the remaining symbols at the maximum length (if there were - // no limit to the code length, this would become: most = left - 1) - int most = (((code_t)left << (g.max - len)) - syms) / - (((code_t)1 << (g.max - len)) - 1); - - // occupy least table spaces, creating new sub-tables as needed - int use = least; - while (rem < use) { - use -= rem; - rem = 1 << (len - g.root); - mem += rem; - } - rem -= use; - - // examine codes from here, updating table space as we go - for (use = least; use <= most; use++) { - g.code[len] = use; - examine(syms - use, (left - use) << 1, len + 1, - mem + (rem ? 1 << (len - g.root) : 0), rem << 1); - if (rem == 0) { - rem = 1 << (len - g.root); - mem += rem; - } - rem--; - } - - // remove entries as we drop back down in the recursion - g.code[len] = 0; -} - -// Look at all sub-codes starting with root + 1 bits. Look at only the valid -// intermediate code states (syms, left, len). For each completed code, -// calculate the amount of memory required by inflate to build the decoding -// tables. Find the maximum amount of memory required and show the codes that -// require that maximum. -local void enough(int syms) { - // clear code - for (int n = 0; n <= g.max; n++) - g.code[n] = 0; - - // look at all (root + 1) bit and longer codes - string_clear(&g.out); // empty saved results - g.large = 1 << g.root; // base table - if (g.root < g.max) // otherwise, there's only a base table - for (int n = 3; n <= syms; n++) - for (int left = 2; left < n; left += 2) { - // look at all reachable (root + 1) bit nodes, and the - // resulting codes (complete at root + 2 or more) - size_t index = map(n, left, g.root + 1); - if (g.root + 1 < g.max && g.num[index]) // reachable node - examine(n, left, g.root + 1, 1 << g.root, 0); - - // also look at root bit codes with completions at root + 1 - // bits (not saved in num, since complete), just in case - if (g.num[index - 1] && n <= left << 1) - examine((n - left) << 1, (n - left) << 1, g.root + 1, - 1 << g.root, 0); - } - - // done - printf("maximum of %d table entries for root = %d\n", g.large, g.root); - fputs(g.out.str, stdout); -} - -// Examine and show the total number of possible prefix codes for a given -// maximum number of symbols, initial root table size, and maximum code length -// in bits -- those are the command arguments in that order. The default values -// are 286, 9, and 15 respectively, for the deflate literal/length code. The -// possible codes are counted for each number of coded symbols from two to the -// maximum. The counts for each of those and the total number of codes are -// shown. The maximum number of inflate table entires is then calculated across -// all possible codes. Each new maximum number of table entries and the -// associated sub-code (starting at root + 1 == 10 bits) is shown. -// -// To count and examine prefix codes that are not length-limited, provide a -// maximum length equal to the number of symbols minus one. -// -// For the deflate literal/length code, use "enough". For the deflate distance -// code, use "enough 30 6". -int main(int argc, char **argv) { - // set up globals for cleanup() - g.code = NULL; - g.num = NULL; - g.done = NULL; - string_init(&g.out); - - // get arguments -- default to the deflate literal/length code - int syms = 286; - g.root = 9; - g.max = 15; - if (argc > 1) { - syms = atoi(argv[1]); - if (argc > 2) { - g.root = atoi(argv[2]); - if (argc > 3) - g.max = atoi(argv[3]); - } - } - if (argc > 4 || syms < 2 || g.root < 1 || g.max < 1) { - fputs("invalid arguments, need: [sym >= 2 [root >= 1 [max >= 1]]]\n", - stderr); - return 1; - } - - // if not restricting the code length, the longest is syms - 1 - if (g.max > syms - 1) - g.max = syms - 1; - - // determine the number of bits in a code_t - int bits = 0; - for (code_t word = 1; word; word <<= 1) - bits++; - - // make sure that the calculation of most will not overflow - if (g.max > bits || (code_t)(syms - 2) >= ((code_t)-1 >> (g.max - 1))) { - fputs("abort: code length too long for internal types\n", stderr); - return 1; - } - - // reject impossible code requests - if ((code_t)(syms - 1) > ((code_t)1 << g.max) - 1) { - fprintf(stderr, "%d symbols cannot be coded in %d bits\n", - syms, g.max); - return 1; - } - - // allocate code vector - g.code = calloc(g.max + 1, sizeof(int)); - assert(g.code != NULL && "out of memory"); - - // determine size of saved results array, checking for overflows, - // allocate and clear the array (set all to zero with calloc()) - if (syms == 2) // iff max == 1 - g.num = NULL; // won't be saving any results - else { - g.size = syms >> 1; - int n = (syms - 1) >> 1; - assert(g.size <= (size_t)-1 / n && "overflow"); - g.size *= n; - n = g.max - 1; - assert(g.size <= (size_t)-1 / n && "overflow"); - g.size *= n; - g.num = calloc(g.size, sizeof(big_t)); - assert(g.num != NULL && "out of memory"); - } - - // count possible codes for all numbers of symbols, add up counts - big_t sum = 0; - for (int n = 2; n <= syms; n++) { - big_t got = count(n, 2, 1); - sum += got; - assert(got != (big_t)-1 && sum >= got && "overflow"); - } - printf("%"PRIbig" total codes for 2 to %d symbols", sum, syms); - if (g.max < syms - 1) - printf(" (%d-bit length limit)\n", g.max); - else - puts(" (no length limit)"); - - // allocate and clear done array for been_here() - if (syms == 2) - g.done = NULL; - else { - g.done = calloc(g.size, sizeof(struct tab)); - assert(g.done != NULL && "out of memory"); - } - - // find and show maximum inflate table usage - if (g.root > g.max) // reduce root to max length - g.root = g.max; - if ((code_t)syms < ((code_t)1 << (g.root + 1))) - enough(syms); - else - fputs("cannot handle minimum code lengths > root", stderr); - - // done - cleanup(); - return 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/fitblk.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/fitblk.c deleted file mode 100644 index c61de5c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/fitblk.c +++ /dev/null @@ -1,233 +0,0 @@ -/* fitblk.c: example of fitting compressed output to a specified size - Not copyrighted -- provided to the public domain - Version 1.1 25 November 2004 Mark Adler */ - -/* Version history: - 1.0 24 Nov 2004 First version - 1.1 25 Nov 2004 Change deflateInit2() to deflateInit() - Use fixed-size, stack-allocated raw buffers - Simplify code moving compression to subroutines - Use assert() for internal errors - Add detailed description of approach - */ - -/* Approach to just fitting a requested compressed size: - - fitblk performs three compression passes on a portion of the input - data in order to determine how much of that input will compress to - nearly the requested output block size. The first pass generates - enough deflate blocks to produce output to fill the requested - output size plus a specfied excess amount (see the EXCESS define - below). The last deflate block may go quite a bit past that, but - is discarded. The second pass decompresses and recompresses just - the compressed data that fit in the requested plus excess sized - buffer. The deflate process is terminated after that amount of - input, which is less than the amount consumed on the first pass. - The last deflate block of the result will be of a comparable size - to the final product, so that the header for that deflate block and - the compression ratio for that block will be about the same as in - the final product. The third compression pass decompresses the - result of the second step, but only the compressed data up to the - requested size minus an amount to allow the compressed stream to - complete (see the MARGIN define below). That will result in a - final compressed stream whose length is less than or equal to the - requested size. Assuming sufficient input and a requested size - greater than a few hundred bytes, the shortfall will typically be - less than ten bytes. - - If the input is short enough that the first compression completes - before filling the requested output size, then that compressed - stream is return with no recompression. - - EXCESS is chosen to be just greater than the shortfall seen in a - two pass approach similar to the above. That shortfall is due to - the last deflate block compressing more efficiently with a smaller - header on the second pass. EXCESS is set to be large enough so - that there is enough uncompressed data for the second pass to fill - out the requested size, and small enough so that the final deflate - block of the second pass will be close in size to the final deflate - block of the third and final pass. MARGIN is chosen to be just - large enough to assure that the final compression has enough room - to complete in all cases. - */ - -#include -#include -#include -#include "zlib.h" - -#define local static - -/* print nastygram and leave */ -local void quit(char *why) -{ - fprintf(stderr, "fitblk abort: %s\n", why); - exit(1); -} - -#define RAWLEN 4096 /* intermediate uncompressed buffer size */ - -/* compress from file to def until provided buffer is full or end of - input reached; return last deflate() return value, or Z_ERRNO if - there was read error on the file */ -local int partcompress(FILE *in, z_streamp def) -{ - int ret, flush; - unsigned char raw[RAWLEN]; - - flush = Z_NO_FLUSH; - do { - def->avail_in = fread(raw, 1, RAWLEN, in); - if (ferror(in)) - return Z_ERRNO; - def->next_in = raw; - if (feof(in)) - flush = Z_FINISH; - ret = deflate(def, flush); - assert(ret != Z_STREAM_ERROR); - } while (def->avail_out != 0 && flush == Z_NO_FLUSH); - return ret; -} - -/* recompress from inf's input to def's output; the input for inf and - the output for def are set in those structures before calling; - return last deflate() return value, or Z_MEM_ERROR if inflate() - was not able to allocate enough memory when it needed to */ -local int recompress(z_streamp inf, z_streamp def) -{ - int ret, flush; - unsigned char raw[RAWLEN]; - - flush = Z_NO_FLUSH; - do { - /* decompress */ - inf->avail_out = RAWLEN; - inf->next_out = raw; - ret = inflate(inf, Z_NO_FLUSH); - assert(ret != Z_STREAM_ERROR && ret != Z_DATA_ERROR && - ret != Z_NEED_DICT); - if (ret == Z_MEM_ERROR) - return ret; - - /* compress what was decompresed until done or no room */ - def->avail_in = RAWLEN - inf->avail_out; - def->next_in = raw; - if (inf->avail_out != 0) - flush = Z_FINISH; - ret = deflate(def, flush); - assert(ret != Z_STREAM_ERROR); - } while (ret != Z_STREAM_END && def->avail_out != 0); - return ret; -} - -#define EXCESS 256 /* empirically determined stream overage */ -#define MARGIN 8 /* amount to back off for completion */ - -/* compress from stdin to fixed-size block on stdout */ -int main(int argc, char **argv) -{ - int ret; /* return code */ - unsigned size; /* requested fixed output block size */ - unsigned have; /* bytes written by deflate() call */ - unsigned char *blk; /* intermediate and final stream */ - unsigned char *tmp; /* close to desired size stream */ - z_stream def, inf; /* zlib deflate and inflate states */ - - /* get requested output size */ - if (argc != 2) - quit("need one argument: size of output block"); - ret = strtol(argv[1], argv + 1, 10); - if (argv[1][0] != 0) - quit("argument must be a number"); - if (ret < 8) /* 8 is minimum zlib stream size */ - quit("need positive size of 8 or greater"); - size = (unsigned)ret; - - /* allocate memory for buffers and compression engine */ - blk = malloc(size + EXCESS); - def.zalloc = Z_NULL; - def.zfree = Z_NULL; - def.opaque = Z_NULL; - ret = deflateInit(&def, Z_DEFAULT_COMPRESSION); - if (ret != Z_OK || blk == NULL) - quit("out of memory"); - - /* compress from stdin until output full, or no more input */ - def.avail_out = size + EXCESS; - def.next_out = blk; - ret = partcompress(stdin, &def); - if (ret == Z_ERRNO) - quit("error reading input"); - - /* if it all fit, then size was undersubscribed -- done! */ - if (ret == Z_STREAM_END && def.avail_out >= EXCESS) { - /* write block to stdout */ - have = size + EXCESS - def.avail_out; - if (fwrite(blk, 1, have, stdout) != have || ferror(stdout)) - quit("error writing output"); - - /* clean up and print results to stderr */ - ret = deflateEnd(&def); - assert(ret != Z_STREAM_ERROR); - free(blk); - fprintf(stderr, - "%u bytes unused out of %u requested (all input)\n", - size - have, size); - return 0; - } - - /* it didn't all fit -- set up for recompression */ - inf.zalloc = Z_NULL; - inf.zfree = Z_NULL; - inf.opaque = Z_NULL; - inf.avail_in = 0; - inf.next_in = Z_NULL; - ret = inflateInit(&inf); - tmp = malloc(size + EXCESS); - if (ret != Z_OK || tmp == NULL) - quit("out of memory"); - ret = deflateReset(&def); - assert(ret != Z_STREAM_ERROR); - - /* do first recompression close to the right amount */ - inf.avail_in = size + EXCESS; - inf.next_in = blk; - def.avail_out = size + EXCESS; - def.next_out = tmp; - ret = recompress(&inf, &def); - if (ret == Z_MEM_ERROR) - quit("out of memory"); - - /* set up for next reocmpression */ - ret = inflateReset(&inf); - assert(ret != Z_STREAM_ERROR); - ret = deflateReset(&def); - assert(ret != Z_STREAM_ERROR); - - /* do second and final recompression (third compression) */ - inf.avail_in = size - MARGIN; /* assure stream will complete */ - inf.next_in = tmp; - def.avail_out = size; - def.next_out = blk; - ret = recompress(&inf, &def); - if (ret == Z_MEM_ERROR) - quit("out of memory"); - assert(ret == Z_STREAM_END); /* otherwise MARGIN too small */ - - /* done -- write block to stdout */ - have = size - def.avail_out; - if (fwrite(blk, 1, have, stdout) != have || ferror(stdout)) - quit("error writing output"); - - /* clean up and print results to stderr */ - free(tmp); - ret = inflateEnd(&inf); - assert(ret != Z_STREAM_ERROR); - ret = deflateEnd(&def); - assert(ret != Z_STREAM_ERROR); - free(blk); - fprintf(stderr, - "%u bytes unused out of %u requested (%lu input)\n", - size - have, size, def.total_in); - return 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/gun.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/gun.c deleted file mode 100644 index be44fa5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/gun.c +++ /dev/null @@ -1,702 +0,0 @@ -/* gun.c -- simple gunzip to give an example of the use of inflateBack() - * Copyright (C) 2003, 2005, 2008, 2010, 2012 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - Version 1.7 12 August 2012 Mark Adler */ - -/* Version history: - 1.0 16 Feb 2003 First version for testing of inflateBack() - 1.1 21 Feb 2005 Decompress concatenated gzip streams - Remove use of "this" variable (C++ keyword) - Fix return value for in() - Improve allocation failure checking - Add typecasting for void * structures - Add -h option for command version and usage - Add a bunch of comments - 1.2 20 Mar 2005 Add Unix compress (LZW) decompression - Copy file attributes from input file to output file - 1.3 12 Jun 2005 Add casts for error messages [Oberhumer] - 1.4 8 Dec 2006 LZW decompression speed improvements - 1.5 9 Feb 2008 Avoid warning in latest version of gcc - 1.6 17 Jan 2010 Avoid signed/unsigned comparison warnings - 1.7 12 Aug 2012 Update for z_const usage in zlib 1.2.8 - */ - -/* - gun [ -t ] [ name ... ] - - decompresses the data in the named gzip files. If no arguments are given, - gun will decompress from stdin to stdout. The names must end in .gz, -gz, - .z, -z, _z, or .Z. The uncompressed data will be written to a file name - with the suffix stripped. On success, the original file is deleted. On - failure, the output file is deleted. For most failures, the command will - continue to process the remaining names on the command line. A memory - allocation failure will abort the command. If -t is specified, then the - listed files or stdin will be tested as gzip files for integrity (without - checking for a proper suffix), no output will be written, and no files - will be deleted. - - Like gzip, gun allows concatenated gzip streams and will decompress them, - writing all of the uncompressed data to the output. Unlike gzip, gun allows - an empty file on input, and will produce no error writing an empty output - file. - - gun will also decompress files made by Unix compress, which uses LZW - compression. These files are automatically detected by virtue of their - magic header bytes. Since the end of Unix compress stream is marked by the - end-of-file, they cannot be concantenated. If a Unix compress stream is - encountered in an input file, it is the last stream in that file. - - Like gunzip and uncompress, the file attributes of the original compressed - file are maintained in the final uncompressed file, to the extent that the - user permissions allow it. - - On my Mac OS X PowerPC G4, gun is almost twice as fast as gunzip (version - 1.2.4) is on the same file, when gun is linked with zlib 1.2.2. Also the - LZW decompression provided by gun is about twice as fast as the standard - Unix uncompress command. - */ - -/* external functions and related types and constants */ -#include /* fprintf() */ -#include /* malloc(), free() */ -#include /* strerror(), strcmp(), strlen(), memcpy() */ -#include /* errno */ -#include /* open() */ -#include /* read(), write(), close(), chown(), unlink() */ -#include -#include /* stat(), chmod() */ -#include /* utime() */ -#include "zlib.h" /* inflateBackInit(), inflateBack(), */ - /* inflateBackEnd(), crc32() */ - -/* function declaration */ -#define local static - -/* buffer constants */ -#define SIZE 32768U /* input and output buffer sizes */ -#define PIECE 16384 /* limits i/o chunks for 16-bit int case */ - -/* structure for infback() to pass to input function in() -- it maintains the - input file and a buffer of size SIZE */ -struct ind { - int infile; - unsigned char *inbuf; -}; - -/* Load input buffer, assumed to be empty, and return bytes loaded and a - pointer to them. read() is called until the buffer is full, or until it - returns end-of-file or error. Return 0 on error. */ -local unsigned in(void *in_desc, z_const unsigned char **buf) -{ - int ret; - unsigned len; - unsigned char *next; - struct ind *me = (struct ind *)in_desc; - - next = me->inbuf; - *buf = next; - len = 0; - do { - ret = PIECE; - if ((unsigned)ret > SIZE - len) - ret = (int)(SIZE - len); - ret = (int)read(me->infile, next, ret); - if (ret == -1) { - len = 0; - break; - } - next += ret; - len += ret; - } while (ret != 0 && len < SIZE); - return len; -} - -/* structure for infback() to pass to output function out() -- it maintains the - output file, a running CRC-32 check on the output and the total number of - bytes output, both for checking against the gzip trailer. (The length in - the gzip trailer is stored modulo 2^32, so it's ok if a long is 32 bits and - the output is greater than 4 GB.) */ -struct outd { - int outfile; - int check; /* true if checking crc and total */ - unsigned long crc; - unsigned long total; -}; - -/* Write output buffer and update the CRC-32 and total bytes written. write() - is called until all of the output is written or an error is encountered. - On success out() returns 0. For a write failure, out() returns 1. If the - output file descriptor is -1, then nothing is written. - */ -local int out(void *out_desc, unsigned char *buf, unsigned len) -{ - int ret; - struct outd *me = (struct outd *)out_desc; - - if (me->check) { - me->crc = crc32(me->crc, buf, len); - me->total += len; - } - if (me->outfile != -1) - do { - ret = PIECE; - if ((unsigned)ret > len) - ret = (int)len; - ret = (int)write(me->outfile, buf, ret); - if (ret == -1) - return 1; - buf += ret; - len -= ret; - } while (len != 0); - return 0; -} - -/* next input byte macro for use inside lunpipe() and gunpipe() */ -#define NEXT() (have ? 0 : (have = in(indp, &next)), \ - last = have ? (have--, (int)(*next++)) : -1) - -/* memory for gunpipe() and lunpipe() -- - the first 256 entries of prefix[] and suffix[] are never used, could - have offset the index, but it's faster to waste the memory */ -unsigned char inbuf[SIZE]; /* input buffer */ -unsigned char outbuf[SIZE]; /* output buffer */ -unsigned short prefix[65536]; /* index to LZW prefix string */ -unsigned char suffix[65536]; /* one-character LZW suffix */ -unsigned char match[65280 + 2]; /* buffer for reversed match or gzip - 32K sliding window */ - -/* throw out what's left in the current bits byte buffer (this is a vestigial - aspect of the compressed data format derived from an implementation that - made use of a special VAX machine instruction!) */ -#define FLUSHCODE() \ - do { \ - left = 0; \ - rem = 0; \ - if (chunk > have) { \ - chunk -= have; \ - have = 0; \ - if (NEXT() == -1) \ - break; \ - chunk--; \ - if (chunk > have) { \ - chunk = have = 0; \ - break; \ - } \ - } \ - have -= chunk; \ - next += chunk; \ - chunk = 0; \ - } while (0) - -/* Decompress a compress (LZW) file from indp to outfile. The compress magic - header (two bytes) has already been read and verified. There are have bytes - of buffered input at next. strm is used for passing error information back - to gunpipe(). - - lunpipe() will return Z_OK on success, Z_BUF_ERROR for an unexpected end of - file, read error, or write error (a write error indicated by strm->next_in - not equal to Z_NULL), or Z_DATA_ERROR for invalid input. - */ -local int lunpipe(unsigned have, z_const unsigned char *next, struct ind *indp, - int outfile, z_stream *strm) -{ - int last; /* last byte read by NEXT(), or -1 if EOF */ - unsigned chunk; /* bytes left in current chunk */ - int left; /* bits left in rem */ - unsigned rem; /* unused bits from input */ - int bits; /* current bits per code */ - unsigned code; /* code, table traversal index */ - unsigned mask; /* mask for current bits codes */ - int max; /* maximum bits per code for this stream */ - unsigned flags; /* compress flags, then block compress flag */ - unsigned end; /* last valid entry in prefix/suffix tables */ - unsigned temp; /* current code */ - unsigned prev; /* previous code */ - unsigned final; /* last character written for previous code */ - unsigned stack; /* next position for reversed string */ - unsigned outcnt; /* bytes in output buffer */ - struct outd outd; /* output structure */ - unsigned char *p; - - /* set up output */ - outd.outfile = outfile; - outd.check = 0; - - /* process remainder of compress header -- a flags byte */ - flags = NEXT(); - if (last == -1) - return Z_BUF_ERROR; - if (flags & 0x60) { - strm->msg = (char *)"unknown lzw flags set"; - return Z_DATA_ERROR; - } - max = flags & 0x1f; - if (max < 9 || max > 16) { - strm->msg = (char *)"lzw bits out of range"; - return Z_DATA_ERROR; - } - if (max == 9) /* 9 doesn't really mean 9 */ - max = 10; - flags &= 0x80; /* true if block compress */ - - /* clear table */ - bits = 9; - mask = 0x1ff; - end = flags ? 256 : 255; - - /* set up: get first 9-bit code, which is the first decompressed byte, but - don't create a table entry until the next code */ - if (NEXT() == -1) /* no compressed data is ok */ - return Z_OK; - final = prev = (unsigned)last; /* low 8 bits of code */ - if (NEXT() == -1) /* missing a bit */ - return Z_BUF_ERROR; - if (last & 1) { /* code must be < 256 */ - strm->msg = (char *)"invalid lzw code"; - return Z_DATA_ERROR; - } - rem = (unsigned)last >> 1; /* remaining 7 bits */ - left = 7; - chunk = bits - 2; /* 7 bytes left in this chunk */ - outbuf[0] = (unsigned char)final; /* write first decompressed byte */ - outcnt = 1; - - /* decode codes */ - stack = 0; - for (;;) { - /* if the table will be full after this, increment the code size */ - if (end >= mask && bits < max) { - FLUSHCODE(); - bits++; - mask <<= 1; - mask++; - } - - /* get a code of length bits */ - if (chunk == 0) /* decrement chunk modulo bits */ - chunk = bits; - code = rem; /* low bits of code */ - if (NEXT() == -1) { /* EOF is end of compressed data */ - /* write remaining buffered output */ - if (outcnt && out(&outd, outbuf, outcnt)) { - strm->next_in = outbuf; /* signal write error */ - return Z_BUF_ERROR; - } - return Z_OK; - } - code += (unsigned)last << left; /* middle (or high) bits of code */ - left += 8; - chunk--; - if (bits > left) { /* need more bits */ - if (NEXT() == -1) /* can't end in middle of code */ - return Z_BUF_ERROR; - code += (unsigned)last << left; /* high bits of code */ - left += 8; - chunk--; - } - code &= mask; /* mask to current code length */ - left -= bits; /* number of unused bits */ - rem = (unsigned)last >> (8 - left); /* unused bits from last byte */ - - /* process clear code (256) */ - if (code == 256 && flags) { - FLUSHCODE(); - bits = 9; /* initialize bits and mask */ - mask = 0x1ff; - end = 255; /* empty table */ - continue; /* get next code */ - } - - /* special code to reuse last match */ - temp = code; /* save the current code */ - if (code > end) { - /* Be picky on the allowed code here, and make sure that the code - we drop through (prev) will be a valid index so that random - input does not cause an exception. The code != end + 1 check is - empirically derived, and not checked in the original uncompress - code. If this ever causes a problem, that check could be safely - removed. Leaving this check in greatly improves gun's ability - to detect random or corrupted input after a compress header. - In any case, the prev > end check must be retained. */ - if (code != end + 1 || prev > end) { - strm->msg = (char *)"invalid lzw code"; - return Z_DATA_ERROR; - } - match[stack++] = (unsigned char)final; - code = prev; - } - - /* walk through linked list to generate output in reverse order */ - p = match + stack; - while (code >= 256) { - *p++ = suffix[code]; - code = prefix[code]; - } - stack = p - match; - match[stack++] = (unsigned char)code; - final = code; - - /* link new table entry */ - if (end < mask) { - end++; - prefix[end] = (unsigned short)prev; - suffix[end] = (unsigned char)final; - } - - /* set previous code for next iteration */ - prev = temp; - - /* write output in forward order */ - while (stack > SIZE - outcnt) { - while (outcnt < SIZE) - outbuf[outcnt++] = match[--stack]; - if (out(&outd, outbuf, outcnt)) { - strm->next_in = outbuf; /* signal write error */ - return Z_BUF_ERROR; - } - outcnt = 0; - } - p = match + stack; - do { - outbuf[outcnt++] = *--p; - } while (p > match); - stack = 0; - - /* loop for next code with final and prev as the last match, rem and - left provide the first 0..7 bits of the next code, end is the last - valid table entry */ - } -} - -/* Decompress a gzip file from infile to outfile. strm is assumed to have been - successfully initialized with inflateBackInit(). The input file may consist - of a series of gzip streams, in which case all of them will be decompressed - to the output file. If outfile is -1, then the gzip stream(s) integrity is - checked and nothing is written. - - The return value is a zlib error code: Z_MEM_ERROR if out of memory, - Z_DATA_ERROR if the header or the compressed data is invalid, or if the - trailer CRC-32 check or length doesn't match, Z_BUF_ERROR if the input ends - prematurely or a write error occurs, or Z_ERRNO if junk (not a another gzip - stream) follows a valid gzip stream. - */ -local int gunpipe(z_stream *strm, int infile, int outfile) -{ - int ret, first, last; - unsigned have, flags, len; - z_const unsigned char *next = NULL; - struct ind ind, *indp; - struct outd outd; - - /* setup input buffer */ - ind.infile = infile; - ind.inbuf = inbuf; - indp = &ind; - - /* decompress concatenated gzip streams */ - have = 0; /* no input data read in yet */ - first = 1; /* looking for first gzip header */ - strm->next_in = Z_NULL; /* so Z_BUF_ERROR means EOF */ - for (;;) { - /* look for the two magic header bytes for a gzip stream */ - if (NEXT() == -1) { - ret = Z_OK; - break; /* empty gzip stream is ok */ - } - if (last != 31 || (NEXT() != 139 && last != 157)) { - strm->msg = (char *)"incorrect header check"; - ret = first ? Z_DATA_ERROR : Z_ERRNO; - break; /* not a gzip or compress header */ - } - first = 0; /* next non-header is junk */ - - /* process a compress (LZW) file -- can't be concatenated after this */ - if (last == 157) { - ret = lunpipe(have, next, indp, outfile, strm); - break; - } - - /* process remainder of gzip header */ - ret = Z_BUF_ERROR; - if (NEXT() != 8) { /* only deflate method allowed */ - if (last == -1) break; - strm->msg = (char *)"unknown compression method"; - ret = Z_DATA_ERROR; - break; - } - flags = NEXT(); /* header flags */ - NEXT(); /* discard mod time, xflgs, os */ - NEXT(); - NEXT(); - NEXT(); - NEXT(); - NEXT(); - if (last == -1) break; - if (flags & 0xe0) { - strm->msg = (char *)"unknown header flags set"; - ret = Z_DATA_ERROR; - break; - } - if (flags & 4) { /* extra field */ - len = NEXT(); - len += (unsigned)(NEXT()) << 8; - if (last == -1) break; - while (len > have) { - len -= have; - have = 0; - if (NEXT() == -1) break; - len--; - } - if (last == -1) break; - have -= len; - next += len; - } - if (flags & 8) /* file name */ - while (NEXT() != 0 && last != -1) - ; - if (flags & 16) /* comment */ - while (NEXT() != 0 && last != -1) - ; - if (flags & 2) { /* header crc */ - NEXT(); - NEXT(); - } - if (last == -1) break; - - /* set up output */ - outd.outfile = outfile; - outd.check = 1; - outd.crc = crc32(0L, Z_NULL, 0); - outd.total = 0; - - /* decompress data to output */ - strm->next_in = next; - strm->avail_in = have; - ret = inflateBack(strm, in, indp, out, &outd); - if (ret != Z_STREAM_END) break; - next = strm->next_in; - have = strm->avail_in; - strm->next_in = Z_NULL; /* so Z_BUF_ERROR means EOF */ - - /* check trailer */ - ret = Z_BUF_ERROR; - if (NEXT() != (int)(outd.crc & 0xff) || - NEXT() != (int)((outd.crc >> 8) & 0xff) || - NEXT() != (int)((outd.crc >> 16) & 0xff) || - NEXT() != (int)((outd.crc >> 24) & 0xff)) { - /* crc error */ - if (last != -1) { - strm->msg = (char *)"incorrect data check"; - ret = Z_DATA_ERROR; - } - break; - } - if (NEXT() != (int)(outd.total & 0xff) || - NEXT() != (int)((outd.total >> 8) & 0xff) || - NEXT() != (int)((outd.total >> 16) & 0xff) || - NEXT() != (int)((outd.total >> 24) & 0xff)) { - /* length error */ - if (last != -1) { - strm->msg = (char *)"incorrect length check"; - ret = Z_DATA_ERROR; - } - break; - } - - /* go back and look for another gzip stream */ - } - - /* clean up and return */ - return ret; -} - -/* Copy file attributes, from -> to, as best we can. This is best effort, so - no errors are reported. The mode bits, including suid, sgid, and the sticky - bit are copied (if allowed), the owner's user id and group id are copied - (again if allowed), and the access and modify times are copied. */ -local void copymeta(char *from, char *to) -{ - struct stat was; - struct utimbuf when; - - /* get all of from's Unix meta data, return if not a regular file */ - if (stat(from, &was) != 0 || (was.st_mode & S_IFMT) != S_IFREG) - return; - - /* set to's mode bits, ignore errors */ - (void)chmod(to, was.st_mode & 07777); - - /* copy owner's user and group, ignore errors */ - (void)chown(to, was.st_uid, was.st_gid); - - /* copy access and modify times, ignore errors */ - when.actime = was.st_atime; - when.modtime = was.st_mtime; - (void)utime(to, &when); -} - -/* Decompress the file inname to the file outnname, of if test is true, just - decompress without writing and check the gzip trailer for integrity. If - inname is NULL or an empty string, read from stdin. If outname is NULL or - an empty string, write to stdout. strm is a pre-initialized inflateBack - structure. When appropriate, copy the file attributes from inname to - outname. - - gunzip() returns 1 if there is an out-of-memory error or an unexpected - return code from gunpipe(). Otherwise it returns 0. - */ -local int gunzip(z_stream *strm, char *inname, char *outname, int test) -{ - int ret; - int infile, outfile; - - /* open files */ - if (inname == NULL || *inname == 0) { - inname = "-"; - infile = 0; /* stdin */ - } - else { - infile = open(inname, O_RDONLY, 0); - if (infile == -1) { - fprintf(stderr, "gun cannot open %s\n", inname); - return 0; - } - } - if (test) - outfile = -1; - else if (outname == NULL || *outname == 0) { - outname = "-"; - outfile = 1; /* stdout */ - } - else { - outfile = open(outname, O_CREAT | O_TRUNC | O_WRONLY, 0666); - if (outfile == -1) { - close(infile); - fprintf(stderr, "gun cannot create %s\n", outname); - return 0; - } - } - errno = 0; - - /* decompress */ - ret = gunpipe(strm, infile, outfile); - if (outfile > 2) close(outfile); - if (infile > 2) close(infile); - - /* interpret result */ - switch (ret) { - case Z_OK: - case Z_ERRNO: - if (infile > 2 && outfile > 2) { - copymeta(inname, outname); /* copy attributes */ - unlink(inname); - } - if (ret == Z_ERRNO) - fprintf(stderr, "gun warning: trailing garbage ignored in %s\n", - inname); - break; - case Z_DATA_ERROR: - if (outfile > 2) unlink(outname); - fprintf(stderr, "gun data error on %s: %s\n", inname, strm->msg); - break; - case Z_MEM_ERROR: - if (outfile > 2) unlink(outname); - fprintf(stderr, "gun out of memory error--aborting\n"); - return 1; - case Z_BUF_ERROR: - if (outfile > 2) unlink(outname); - if (strm->next_in != Z_NULL) { - fprintf(stderr, "gun write error on %s: %s\n", - outname, strerror(errno)); - } - else if (errno) { - fprintf(stderr, "gun read error on %s: %s\n", - inname, strerror(errno)); - } - else { - fprintf(stderr, "gun unexpected end of file on %s\n", - inname); - } - break; - default: - if (outfile > 2) unlink(outname); - fprintf(stderr, "gun internal error--aborting\n"); - return 1; - } - return 0; -} - -/* Process the gun command line arguments. See the command syntax near the - beginning of this source file. */ -int main(int argc, char **argv) -{ - int ret, len, test; - char *outname; - unsigned char *window; - z_stream strm; - - /* initialize inflateBack state for repeated use */ - window = match; /* reuse LZW match buffer */ - strm.zalloc = Z_NULL; - strm.zfree = Z_NULL; - strm.opaque = Z_NULL; - ret = inflateBackInit(&strm, 15, window); - if (ret != Z_OK) { - fprintf(stderr, "gun out of memory error--aborting\n"); - return 1; - } - - /* decompress each file to the same name with the suffix removed */ - argc--; - argv++; - test = 0; - if (argc && strcmp(*argv, "-h") == 0) { - fprintf(stderr, "gun 1.6 (17 Jan 2010)\n"); - fprintf(stderr, "Copyright (C) 2003-2010 Mark Adler\n"); - fprintf(stderr, "usage: gun [-t] [file1.gz [file2.Z ...]]\n"); - return 0; - } - if (argc && strcmp(*argv, "-t") == 0) { - test = 1; - argc--; - argv++; - } - if (argc) - do { - if (test) - outname = NULL; - else { - len = (int)strlen(*argv); - if (strcmp(*argv + len - 3, ".gz") == 0 || - strcmp(*argv + len - 3, "-gz") == 0) - len -= 3; - else if (strcmp(*argv + len - 2, ".z") == 0 || - strcmp(*argv + len - 2, "-z") == 0 || - strcmp(*argv + len - 2, "_z") == 0 || - strcmp(*argv + len - 2, ".Z") == 0) - len -= 2; - else { - fprintf(stderr, "gun error: no gz type on %s--skipping\n", - *argv); - continue; - } - outname = malloc(len + 1); - if (outname == NULL) { - fprintf(stderr, "gun out of memory error--aborting\n"); - ret = 1; - break; - } - memcpy(outname, *argv, len); - outname[len] = 0; - } - ret = gunzip(&strm, *argv, outname, test); - if (outname != NULL) free(outname); - if (ret) break; - } while (argv++, --argc); - else - ret = gunzip(&strm, NULL, NULL, test); - - /* clean up */ - inflateBackEnd(&strm); - return ret; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/gzappend.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/gzappend.c deleted file mode 100644 index d7eea3e..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/gzappend.c +++ /dev/null @@ -1,504 +0,0 @@ -/* gzappend -- command to append to a gzip file - - Copyright (C) 2003, 2012 Mark Adler, all rights reserved - version 1.2, 11 Oct 2012 - - This software is provided 'as-is', without any express or implied - warranty. In no event will the author be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Mark Adler madler@alumni.caltech.edu - */ - -/* - * Change history: - * - * 1.0 19 Oct 2003 - First version - * 1.1 4 Nov 2003 - Expand and clarify some comments and notes - * - Add version and copyright to help - * - Send help to stdout instead of stderr - * - Add some preemptive typecasts - * - Add L to constants in lseek() calls - * - Remove some debugging information in error messages - * - Use new data_type definition for zlib 1.2.1 - * - Simplfy and unify file operations - * - Finish off gzip file in gztack() - * - Use deflatePrime() instead of adding empty blocks - * - Keep gzip file clean on appended file read errors - * - Use in-place rotate instead of auxiliary buffer - * (Why you ask? Because it was fun to write!) - * 1.2 11 Oct 2012 - Fix for proper z_const usage - * - Check for input buffer malloc failure - */ - -/* - gzappend takes a gzip file and appends to it, compressing files from the - command line or data from stdin. The gzip file is written to directly, to - avoid copying that file, in case it's large. Note that this results in the - unfriendly behavior that if gzappend fails, the gzip file is corrupted. - - This program was written to illustrate the use of the new Z_BLOCK option of - zlib 1.2.x's inflate() function. This option returns from inflate() at each - block boundary to facilitate locating and modifying the last block bit at - the start of the final deflate block. Also whether using Z_BLOCK or not, - another required feature of zlib 1.2.x is that inflate() now provides the - number of unusued bits in the last input byte used. gzappend will not work - with versions of zlib earlier than 1.2.1. - - gzappend first decompresses the gzip file internally, discarding all but - the last 32K of uncompressed data, and noting the location of the last block - bit and the number of unused bits in the last byte of the compressed data. - The gzip trailer containing the CRC-32 and length of the uncompressed data - is verified. This trailer will be later overwritten. - - Then the last block bit is cleared by seeking back in the file and rewriting - the byte that contains it. Seeking forward, the last byte of the compressed - data is saved along with the number of unused bits to initialize deflate. - - A deflate process is initialized, using the last 32K of the uncompressed - data from the gzip file to initialize the dictionary. If the total - uncompressed data was less than 32K, then all of it is used to initialize - the dictionary. The deflate output bit buffer is also initialized with the - last bits from the original deflate stream. From here on, the data to - append is simply compressed using deflate, and written to the gzip file. - When that is complete, the new CRC-32 and uncompressed length are written - as the trailer of the gzip file. - */ - -#include -#include -#include -#include -#include -#include "zlib.h" - -#define local static -#define LGCHUNK 14 -#define CHUNK (1U << LGCHUNK) -#define DSIZE 32768U - -/* print an error message and terminate with extreme prejudice */ -local void bye(char *msg1, char *msg2) -{ - fprintf(stderr, "gzappend error: %s%s\n", msg1, msg2); - exit(1); -} - -/* return the greatest common divisor of a and b using Euclid's algorithm, - modified to be fast when one argument much greater than the other, and - coded to avoid unnecessary swapping */ -local unsigned gcd(unsigned a, unsigned b) -{ - unsigned c; - - while (a && b) - if (a > b) { - c = b; - while (a - c >= c) - c <<= 1; - a -= c; - } - else { - c = a; - while (b - c >= c) - c <<= 1; - b -= c; - } - return a + b; -} - -/* rotate list[0..len-1] left by rot positions, in place */ -local void rotate(unsigned char *list, unsigned len, unsigned rot) -{ - unsigned char tmp; - unsigned cycles; - unsigned char *start, *last, *to, *from; - - /* normalize rot and handle degenerate cases */ - if (len < 2) return; - if (rot >= len) rot %= len; - if (rot == 0) return; - - /* pointer to last entry in list */ - last = list + (len - 1); - - /* do simple left shift by one */ - if (rot == 1) { - tmp = *list; - memmove(list, list + 1, len - 1); - *last = tmp; - return; - } - - /* do simple right shift by one */ - if (rot == len - 1) { - tmp = *last; - memmove(list + 1, list, len - 1); - *list = tmp; - return; - } - - /* otherwise do rotate as a set of cycles in place */ - cycles = gcd(len, rot); /* number of cycles */ - do { - start = from = list + cycles; /* start index is arbitrary */ - tmp = *from; /* save entry to be overwritten */ - for (;;) { - to = from; /* next step in cycle */ - from += rot; /* go right rot positions */ - if (from > last) from -= len; /* (pointer better not wrap) */ - if (from == start) break; /* all but one shifted */ - *to = *from; /* shift left */ - } - *to = tmp; /* complete the circle */ - } while (--cycles); -} - -/* structure for gzip file read operations */ -typedef struct { - int fd; /* file descriptor */ - int size; /* 1 << size is bytes in buf */ - unsigned left; /* bytes available at next */ - unsigned char *buf; /* buffer */ - z_const unsigned char *next; /* next byte in buffer */ - char *name; /* file name for error messages */ -} file; - -/* reload buffer */ -local int readin(file *in) -{ - int len; - - len = read(in->fd, in->buf, 1 << in->size); - if (len == -1) bye("error reading ", in->name); - in->left = (unsigned)len; - in->next = in->buf; - return len; -} - -/* read from file in, exit if end-of-file */ -local int readmore(file *in) -{ - if (readin(in) == 0) bye("unexpected end of ", in->name); - return 0; -} - -#define read1(in) (in->left == 0 ? readmore(in) : 0, \ - in->left--, *(in->next)++) - -/* skip over n bytes of in */ -local void skip(file *in, unsigned n) -{ - unsigned bypass; - - if (n > in->left) { - n -= in->left; - bypass = n & ~((1U << in->size) - 1); - if (bypass) { - if (lseek(in->fd, (off_t)bypass, SEEK_CUR) == -1) - bye("seeking ", in->name); - n -= bypass; - } - readmore(in); - if (n > in->left) - bye("unexpected end of ", in->name); - } - in->left -= n; - in->next += n; -} - -/* read a four-byte unsigned integer, little-endian, from in */ -unsigned long read4(file *in) -{ - unsigned long val; - - val = read1(in); - val += (unsigned)read1(in) << 8; - val += (unsigned long)read1(in) << 16; - val += (unsigned long)read1(in) << 24; - return val; -} - -/* skip over gzip header */ -local void gzheader(file *in) -{ - int flags; - unsigned n; - - if (read1(in) != 31 || read1(in) != 139) bye(in->name, " not a gzip file"); - if (read1(in) != 8) bye("unknown compression method in", in->name); - flags = read1(in); - if (flags & 0xe0) bye("unknown header flags set in", in->name); - skip(in, 6); - if (flags & 4) { - n = read1(in); - n += (unsigned)(read1(in)) << 8; - skip(in, n); - } - if (flags & 8) while (read1(in) != 0) ; - if (flags & 16) while (read1(in) != 0) ; - if (flags & 2) skip(in, 2); -} - -/* decompress gzip file "name", return strm with a deflate stream ready to - continue compression of the data in the gzip file, and return a file - descriptor pointing to where to write the compressed data -- the deflate - stream is initialized to compress using level "level" */ -local int gzscan(char *name, z_stream *strm, int level) -{ - int ret, lastbit, left, full; - unsigned have; - unsigned long crc, tot; - unsigned char *window; - off_t lastoff, end; - file gz; - - /* open gzip file */ - gz.name = name; - gz.fd = open(name, O_RDWR, 0); - if (gz.fd == -1) bye("cannot open ", name); - gz.buf = malloc(CHUNK); - if (gz.buf == NULL) bye("out of memory", ""); - gz.size = LGCHUNK; - gz.left = 0; - - /* skip gzip header */ - gzheader(&gz); - - /* prepare to decompress */ - window = malloc(DSIZE); - if (window == NULL) bye("out of memory", ""); - strm->zalloc = Z_NULL; - strm->zfree = Z_NULL; - strm->opaque = Z_NULL; - ret = inflateInit2(strm, -15); - if (ret != Z_OK) bye("out of memory", " or library mismatch"); - - /* decompress the deflate stream, saving append information */ - lastbit = 0; - lastoff = lseek(gz.fd, 0L, SEEK_CUR) - gz.left; - left = 0; - strm->avail_in = gz.left; - strm->next_in = gz.next; - crc = crc32(0L, Z_NULL, 0); - have = full = 0; - do { - /* if needed, get more input */ - if (strm->avail_in == 0) { - readmore(&gz); - strm->avail_in = gz.left; - strm->next_in = gz.next; - } - - /* set up output to next available section of sliding window */ - strm->avail_out = DSIZE - have; - strm->next_out = window + have; - - /* inflate and check for errors */ - ret = inflate(strm, Z_BLOCK); - if (ret == Z_STREAM_ERROR) bye("internal stream error!", ""); - if (ret == Z_MEM_ERROR) bye("out of memory", ""); - if (ret == Z_DATA_ERROR) - bye("invalid compressed data--format violated in", name); - - /* update crc and sliding window pointer */ - crc = crc32(crc, window + have, DSIZE - have - strm->avail_out); - if (strm->avail_out) - have = DSIZE - strm->avail_out; - else { - have = 0; - full = 1; - } - - /* process end of block */ - if (strm->data_type & 128) { - if (strm->data_type & 64) - left = strm->data_type & 0x1f; - else { - lastbit = strm->data_type & 0x1f; - lastoff = lseek(gz.fd, 0L, SEEK_CUR) - strm->avail_in; - } - } - } while (ret != Z_STREAM_END); - inflateEnd(strm); - gz.left = strm->avail_in; - gz.next = strm->next_in; - - /* save the location of the end of the compressed data */ - end = lseek(gz.fd, 0L, SEEK_CUR) - gz.left; - - /* check gzip trailer and save total for deflate */ - if (crc != read4(&gz)) - bye("invalid compressed data--crc mismatch in ", name); - tot = strm->total_out; - if ((tot & 0xffffffffUL) != read4(&gz)) - bye("invalid compressed data--length mismatch in", name); - - /* if not at end of file, warn */ - if (gz.left || readin(&gz)) - fprintf(stderr, - "gzappend warning: junk at end of gzip file overwritten\n"); - - /* clear last block bit */ - lseek(gz.fd, lastoff - (lastbit != 0), SEEK_SET); - if (read(gz.fd, gz.buf, 1) != 1) bye("reading after seek on ", name); - *gz.buf = (unsigned char)(*gz.buf ^ (1 << ((8 - lastbit) & 7))); - lseek(gz.fd, -1L, SEEK_CUR); - if (write(gz.fd, gz.buf, 1) != 1) bye("writing after seek to ", name); - - /* if window wrapped, build dictionary from window by rotating */ - if (full) { - rotate(window, DSIZE, have); - have = DSIZE; - } - - /* set up deflate stream with window, crc, total_in, and leftover bits */ - ret = deflateInit2(strm, level, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY); - if (ret != Z_OK) bye("out of memory", ""); - deflateSetDictionary(strm, window, have); - strm->adler = crc; - strm->total_in = tot; - if (left) { - lseek(gz.fd, --end, SEEK_SET); - if (read(gz.fd, gz.buf, 1) != 1) bye("reading after seek on ", name); - deflatePrime(strm, 8 - left, *gz.buf); - } - lseek(gz.fd, end, SEEK_SET); - - /* clean up and return */ - free(window); - free(gz.buf); - return gz.fd; -} - -/* append file "name" to gzip file gd using deflate stream strm -- if last - is true, then finish off the deflate stream at the end */ -local void gztack(char *name, int gd, z_stream *strm, int last) -{ - int fd, len, ret; - unsigned left; - unsigned char *in, *out; - - /* open file to compress and append */ - fd = 0; - if (name != NULL) { - fd = open(name, O_RDONLY, 0); - if (fd == -1) - fprintf(stderr, "gzappend warning: %s not found, skipping ...\n", - name); - } - - /* allocate buffers */ - in = malloc(CHUNK); - out = malloc(CHUNK); - if (in == NULL || out == NULL) bye("out of memory", ""); - - /* compress input file and append to gzip file */ - do { - /* get more input */ - len = read(fd, in, CHUNK); - if (len == -1) { - fprintf(stderr, - "gzappend warning: error reading %s, skipping rest ...\n", - name); - len = 0; - } - strm->avail_in = (unsigned)len; - strm->next_in = in; - if (len) strm->adler = crc32(strm->adler, in, (unsigned)len); - - /* compress and write all available output */ - do { - strm->avail_out = CHUNK; - strm->next_out = out; - ret = deflate(strm, last && len == 0 ? Z_FINISH : Z_NO_FLUSH); - left = CHUNK - strm->avail_out; - while (left) { - len = write(gd, out + CHUNK - strm->avail_out - left, left); - if (len == -1) bye("writing gzip file", ""); - left -= (unsigned)len; - } - } while (strm->avail_out == 0 && ret != Z_STREAM_END); - } while (len != 0); - - /* write trailer after last entry */ - if (last) { - deflateEnd(strm); - out[0] = (unsigned char)(strm->adler); - out[1] = (unsigned char)(strm->adler >> 8); - out[2] = (unsigned char)(strm->adler >> 16); - out[3] = (unsigned char)(strm->adler >> 24); - out[4] = (unsigned char)(strm->total_in); - out[5] = (unsigned char)(strm->total_in >> 8); - out[6] = (unsigned char)(strm->total_in >> 16); - out[7] = (unsigned char)(strm->total_in >> 24); - len = 8; - do { - ret = write(gd, out + 8 - len, len); - if (ret == -1) bye("writing gzip file", ""); - len -= ret; - } while (len); - close(gd); - } - - /* clean up and return */ - free(out); - free(in); - if (fd > 0) close(fd); -} - -/* process the compression level option if present, scan the gzip file, and - append the specified files, or append the data from stdin if no other file - names are provided on the command line -- the gzip file must be writable - and seekable */ -int main(int argc, char **argv) -{ - int gd, level; - z_stream strm; - - /* ignore command name */ - argc--; argv++; - - /* provide usage if no arguments */ - if (*argv == NULL) { - printf( - "gzappend 1.2 (11 Oct 2012) Copyright (C) 2003, 2012 Mark Adler\n" - ); - printf( - "usage: gzappend [-level] file.gz [ addthis [ andthis ... ]]\n"); - return 0; - } - - /* set compression level */ - level = Z_DEFAULT_COMPRESSION; - if (argv[0][0] == '-') { - if (argv[0][1] < '0' || argv[0][1] > '9' || argv[0][2] != 0) - bye("invalid compression level", ""); - level = argv[0][1] - '0'; - if (*++argv == NULL) bye("no gzip file name after options", ""); - } - - /* prepare to append to gzip file */ - gd = gzscan(*argv++, &strm, level); - - /* append files on command line, or from stdin if none */ - if (*argv == NULL) - gztack(NULL, gd, &strm, 1); - else - do { - gztack(*argv, gd, &strm, argv[1] == NULL); - } while (*++argv != NULL); - return 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/gzjoin.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/gzjoin.c deleted file mode 100644 index 89e8098..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/gzjoin.c +++ /dev/null @@ -1,449 +0,0 @@ -/* gzjoin -- command to join gzip files into one gzip file - - Copyright (C) 2004, 2005, 2012 Mark Adler, all rights reserved - version 1.2, 14 Aug 2012 - - This software is provided 'as-is', without any express or implied - warranty. In no event will the author be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Mark Adler madler@alumni.caltech.edu - */ - -/* - * Change history: - * - * 1.0 11 Dec 2004 - First version - * 1.1 12 Jun 2005 - Changed ssize_t to long for portability - * 1.2 14 Aug 2012 - Clean up for z_const usage - */ - -/* - gzjoin takes one or more gzip files on the command line and writes out a - single gzip file that will uncompress to the concatenation of the - uncompressed data from the individual gzip files. gzjoin does this without - having to recompress any of the data and without having to calculate a new - crc32 for the concatenated uncompressed data. gzjoin does however have to - decompress all of the input data in order to find the bits in the compressed - data that need to be modified to concatenate the streams. - - gzjoin does not do an integrity check on the input gzip files other than - checking the gzip header and decompressing the compressed data. They are - otherwise assumed to be complete and correct. - - Each joint between gzip files removes at least 18 bytes of previous trailer - and subsequent header, and inserts an average of about three bytes to the - compressed data in order to connect the streams. The output gzip file - has a minimal ten-byte gzip header with no file name or modification time. - - This program was written to illustrate the use of the Z_BLOCK option of - inflate() and the crc32_combine() function. gzjoin will not compile with - versions of zlib earlier than 1.2.3. - */ - -#include /* fputs(), fprintf(), fwrite(), putc() */ -#include /* exit(), malloc(), free() */ -#include /* open() */ -#include /* close(), read(), lseek() */ -#include "zlib.h" - /* crc32(), crc32_combine(), inflateInit2(), inflate(), inflateEnd() */ - -#define local static - -/* exit with an error (return a value to allow use in an expression) */ -local int bail(char *why1, char *why2) -{ - fprintf(stderr, "gzjoin error: %s%s, output incomplete\n", why1, why2); - exit(1); - return 0; -} - -/* -- simple buffered file input with access to the buffer -- */ - -#define CHUNK 32768 /* must be a power of two and fit in unsigned */ - -/* bin buffered input file type */ -typedef struct { - char *name; /* name of file for error messages */ - int fd; /* file descriptor */ - unsigned left; /* bytes remaining at next */ - unsigned char *next; /* next byte to read */ - unsigned char *buf; /* allocated buffer of length CHUNK */ -} bin; - -/* close a buffered file and free allocated memory */ -local void bclose(bin *in) -{ - if (in != NULL) { - if (in->fd != -1) - close(in->fd); - if (in->buf != NULL) - free(in->buf); - free(in); - } -} - -/* open a buffered file for input, return a pointer to type bin, or NULL on - failure */ -local bin *bopen(char *name) -{ - bin *in; - - in = malloc(sizeof(bin)); - if (in == NULL) - return NULL; - in->buf = malloc(CHUNK); - in->fd = open(name, O_RDONLY, 0); - if (in->buf == NULL || in->fd == -1) { - bclose(in); - return NULL; - } - in->left = 0; - in->next = in->buf; - in->name = name; - return in; -} - -/* load buffer from file, return -1 on read error, 0 or 1 on success, with - 1 indicating that end-of-file was reached */ -local int bload(bin *in) -{ - long len; - - if (in == NULL) - return -1; - if (in->left != 0) - return 0; - in->next = in->buf; - do { - len = (long)read(in->fd, in->buf + in->left, CHUNK - in->left); - if (len < 0) - return -1; - in->left += (unsigned)len; - } while (len != 0 && in->left < CHUNK); - return len == 0 ? 1 : 0; -} - -/* get a byte from the file, bail if end of file */ -#define bget(in) (in->left ? 0 : bload(in), \ - in->left ? (in->left--, *(in->next)++) : \ - bail("unexpected end of file on ", in->name)) - -/* get a four-byte little-endian unsigned integer from file */ -local unsigned long bget4(bin *in) -{ - unsigned long val; - - val = bget(in); - val += (unsigned long)(bget(in)) << 8; - val += (unsigned long)(bget(in)) << 16; - val += (unsigned long)(bget(in)) << 24; - return val; -} - -/* skip bytes in file */ -local void bskip(bin *in, unsigned skip) -{ - /* check pointer */ - if (in == NULL) - return; - - /* easy case -- skip bytes in buffer */ - if (skip <= in->left) { - in->left -= skip; - in->next += skip; - return; - } - - /* skip what's in buffer, discard buffer contents */ - skip -= in->left; - in->left = 0; - - /* seek past multiples of CHUNK bytes */ - if (skip > CHUNK) { - unsigned left; - - left = skip & (CHUNK - 1); - if (left == 0) { - /* exact number of chunks: seek all the way minus one byte to check - for end-of-file with a read */ - lseek(in->fd, skip - 1, SEEK_CUR); - if (read(in->fd, in->buf, 1) != 1) - bail("unexpected end of file on ", in->name); - return; - } - - /* skip the integral chunks, update skip with remainder */ - lseek(in->fd, skip - left, SEEK_CUR); - skip = left; - } - - /* read more input and skip remainder */ - bload(in); - if (skip > in->left) - bail("unexpected end of file on ", in->name); - in->left -= skip; - in->next += skip; -} - -/* -- end of buffered input functions -- */ - -/* skip the gzip header from file in */ -local void gzhead(bin *in) -{ - int flags; - - /* verify gzip magic header and compression method */ - if (bget(in) != 0x1f || bget(in) != 0x8b || bget(in) != 8) - bail(in->name, " is not a valid gzip file"); - - /* get and verify flags */ - flags = bget(in); - if ((flags & 0xe0) != 0) - bail("unknown reserved bits set in ", in->name); - - /* skip modification time, extra flags, and os */ - bskip(in, 6); - - /* skip extra field if present */ - if (flags & 4) { - unsigned len; - - len = bget(in); - len += (unsigned)(bget(in)) << 8; - bskip(in, len); - } - - /* skip file name if present */ - if (flags & 8) - while (bget(in) != 0) - ; - - /* skip comment if present */ - if (flags & 16) - while (bget(in) != 0) - ; - - /* skip header crc if present */ - if (flags & 2) - bskip(in, 2); -} - -/* write a four-byte little-endian unsigned integer to out */ -local void put4(unsigned long val, FILE *out) -{ - putc(val & 0xff, out); - putc((val >> 8) & 0xff, out); - putc((val >> 16) & 0xff, out); - putc((val >> 24) & 0xff, out); -} - -/* Load up zlib stream from buffered input, bail if end of file */ -local void zpull(z_streamp strm, bin *in) -{ - if (in->left == 0) - bload(in); - if (in->left == 0) - bail("unexpected end of file on ", in->name); - strm->avail_in = in->left; - strm->next_in = in->next; -} - -/* Write header for gzip file to out and initialize trailer. */ -local void gzinit(unsigned long *crc, unsigned long *tot, FILE *out) -{ - fwrite("\x1f\x8b\x08\0\0\0\0\0\0\xff", 1, 10, out); - *crc = crc32(0L, Z_NULL, 0); - *tot = 0; -} - -/* Copy the compressed data from name, zeroing the last block bit of the last - block if clr is true, and adding empty blocks as needed to get to a byte - boundary. If clr is false, then the last block becomes the last block of - the output, and the gzip trailer is written. crc and tot maintains the - crc and length (modulo 2^32) of the output for the trailer. The resulting - gzip file is written to out. gzinit() must be called before the first call - of gzcopy() to write the gzip header and to initialize crc and tot. */ -local void gzcopy(char *name, int clr, unsigned long *crc, unsigned long *tot, - FILE *out) -{ - int ret; /* return value from zlib functions */ - int pos; /* where the "last block" bit is in byte */ - int last; /* true if processing the last block */ - bin *in; /* buffered input file */ - unsigned char *start; /* start of compressed data in buffer */ - unsigned char *junk; /* buffer for uncompressed data -- discarded */ - z_off_t len; /* length of uncompressed data (support > 4 GB) */ - z_stream strm; /* zlib inflate stream */ - - /* open gzip file and skip header */ - in = bopen(name); - if (in == NULL) - bail("could not open ", name); - gzhead(in); - - /* allocate buffer for uncompressed data and initialize raw inflate - stream */ - junk = malloc(CHUNK); - strm.zalloc = Z_NULL; - strm.zfree = Z_NULL; - strm.opaque = Z_NULL; - strm.avail_in = 0; - strm.next_in = Z_NULL; - ret = inflateInit2(&strm, -15); - if (junk == NULL || ret != Z_OK) - bail("out of memory", ""); - - /* inflate and copy compressed data, clear last-block bit if requested */ - len = 0; - zpull(&strm, in); - start = in->next; - last = start[0] & 1; - if (last && clr) - start[0] &= ~1; - strm.avail_out = 0; - for (;;) { - /* if input used and output done, write used input and get more */ - if (strm.avail_in == 0 && strm.avail_out != 0) { - fwrite(start, 1, strm.next_in - start, out); - start = in->buf; - in->left = 0; - zpull(&strm, in); - } - - /* decompress -- return early when end-of-block reached */ - strm.avail_out = CHUNK; - strm.next_out = junk; - ret = inflate(&strm, Z_BLOCK); - switch (ret) { - case Z_MEM_ERROR: - bail("out of memory", ""); - case Z_DATA_ERROR: - bail("invalid compressed data in ", in->name); - } - - /* update length of uncompressed data */ - len += CHUNK - strm.avail_out; - - /* check for block boundary (only get this when block copied out) */ - if (strm.data_type & 128) { - /* if that was the last block, then done */ - if (last) - break; - - /* number of unused bits in last byte */ - pos = strm.data_type & 7; - - /* find the next last-block bit */ - if (pos != 0) { - /* next last-block bit is in last used byte */ - pos = 0x100 >> pos; - last = strm.next_in[-1] & pos; - if (last && clr) - in->buf[strm.next_in - in->buf - 1] &= ~pos; - } - else { - /* next last-block bit is in next unused byte */ - if (strm.avail_in == 0) { - /* don't have that byte yet -- get it */ - fwrite(start, 1, strm.next_in - start, out); - start = in->buf; - in->left = 0; - zpull(&strm, in); - } - last = strm.next_in[0] & 1; - if (last && clr) - in->buf[strm.next_in - in->buf] &= ~1; - } - } - } - - /* update buffer with unused input */ - in->left = strm.avail_in; - in->next = in->buf + (strm.next_in - in->buf); - - /* copy used input, write empty blocks to get to byte boundary */ - pos = strm.data_type & 7; - fwrite(start, 1, in->next - start - 1, out); - last = in->next[-1]; - if (pos == 0 || !clr) - /* already at byte boundary, or last file: write last byte */ - putc(last, out); - else { - /* append empty blocks to last byte */ - last &= ((0x100 >> pos) - 1); /* assure unused bits are zero */ - if (pos & 1) { - /* odd -- append an empty stored block */ - putc(last, out); - if (pos == 1) - putc(0, out); /* two more bits in block header */ - fwrite("\0\0\xff\xff", 1, 4, out); - } - else { - /* even -- append 1, 2, or 3 empty fixed blocks */ - switch (pos) { - case 6: - putc(last | 8, out); - last = 0; - case 4: - putc(last | 0x20, out); - last = 0; - case 2: - putc(last | 0x80, out); - putc(0, out); - } - } - } - - /* update crc and tot */ - *crc = crc32_combine(*crc, bget4(in), len); - *tot += (unsigned long)len; - - /* clean up */ - inflateEnd(&strm); - free(junk); - bclose(in); - - /* write trailer if this is the last gzip file */ - if (!clr) { - put4(*crc, out); - put4(*tot, out); - } -} - -/* join the gzip files on the command line, write result to stdout */ -int main(int argc, char **argv) -{ - unsigned long crc, tot; /* running crc and total uncompressed length */ - - /* skip command name */ - argc--; - argv++; - - /* show usage if no arguments */ - if (argc == 0) { - fputs("gzjoin usage: gzjoin f1.gz [f2.gz [f3.gz ...]] > fjoin.gz\n", - stderr); - return 0; - } - - /* join gzip files on command line and write to stdout */ - gzinit(&crc, &tot, stdout); - while (argc--) - gzcopy(*argv++, argc, &crc, &tot, stdout); - - /* done */ - return 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/gzlog.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/gzlog.c deleted file mode 100644 index b977802..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/gzlog.c +++ /dev/null @@ -1,1061 +0,0 @@ -/* - * gzlog.c - * Copyright (C) 2004, 2008, 2012, 2016, 2019 Mark Adler, all rights reserved - * For conditions of distribution and use, see copyright notice in gzlog.h - * version 2.3, 25 May 2019 - */ - -/* - gzlog provides a mechanism for frequently appending short strings to a gzip - file that is efficient both in execution time and compression ratio. The - strategy is to write the short strings in an uncompressed form to the end of - the gzip file, only compressing when the amount of uncompressed data has - reached a given threshold. - - gzlog also provides protection against interruptions in the process due to - system crashes. The status of the operation is recorded in an extra field - in the gzip file, and is only updated once the gzip file is brought to a - valid state. The last data to be appended or compressed is saved in an - auxiliary file, so that if the operation is interrupted, it can be completed - the next time an append operation is attempted. - - gzlog maintains another auxiliary file with the last 32K of data from the - compressed portion, which is preloaded for the compression of the subsequent - data. This minimizes the impact to the compression ratio of appending. - */ - -/* - Operations Concept: - - Files (log name "foo"): - foo.gz -- gzip file with the complete log - foo.add -- last message to append or last data to compress - foo.dict -- dictionary of the last 32K of data for next compression - foo.temp -- temporary dictionary file for compression after this one - foo.lock -- lock file for reading and writing the other files - foo.repairs -- log file for log file recovery operations (not compressed) - - gzip file structure: - - fixed-length (no file name) header with extra field (see below) - - compressed data ending initially with empty stored block - - uncompressed data filling out originally empty stored block and - subsequent stored blocks as needed (16K max each) - - gzip trailer - - no junk at end (no other gzip streams) - - When appending data, the information in the first three items above plus the - foo.add file are sufficient to recover an interrupted append operation. The - extra field has the necessary information to restore the start of the last - stored block and determine where to append the data in the foo.add file, as - well as the crc and length of the gzip data before the append operation. - - The foo.add file is created before the gzip file is marked for append, and - deleted after the gzip file is marked as complete. So if the append - operation is interrupted, the data to add will still be there. If due to - some external force, the foo.add file gets deleted between when the append - operation was interrupted and when recovery is attempted, the gzip file will - still be restored, but without the appended data. - - When compressing data, the information in the first two items above plus the - foo.add file are sufficient to recover an interrupted compress operation. - The extra field has the necessary information to find the end of the - compressed data, and contains both the crc and length of just the compressed - data and of the complete set of data including the contents of the foo.add - file. - - Again, the foo.add file is maintained during the compress operation in case - of an interruption. If in the unlikely event the foo.add file with the data - to be compressed is missing due to some external force, a gzip file with - just the previous compressed data will be reconstructed. In this case, all - of the data that was to be compressed is lost (approximately one megabyte). - This will not occur if all that happened was an interruption of the compress - operation. - - The third state that is marked is the replacement of the old dictionary with - the new dictionary after a compress operation. Once compression is - complete, the gzip file is marked as being in the replace state. This - completes the gzip file, so an interrupt after being so marked does not - result in recompression. Then the dictionary file is replaced, and the gzip - file is marked as completed. This state prevents the possibility of - restarting compression with the wrong dictionary file. - - All three operations are wrapped by a lock/unlock procedure. In order to - gain exclusive access to the log files, first a foo.lock file must be - exclusively created. When all operations are complete, the lock is - released by deleting the foo.lock file. If when attempting to create the - lock file, it already exists and the modify time of the lock file is more - than five minutes old (set by the PATIENCE define below), then the old - lock file is considered stale and deleted, and the exclusive creation of - the lock file is retried. To assure that there are no false assessments - of the staleness of the lock file, the operations periodically touch the - lock file to update the modified date. - - Following is the definition of the extra field with all of the information - required to enable the above append and compress operations and their - recovery if interrupted. Multi-byte values are stored little endian - (consistent with the gzip format). File pointers are eight bytes long. - The crc's and lengths for the gzip trailer are four bytes long. (Note that - the length at the end of a gzip file is used for error checking only, and - for large files is actually the length modulo 2^32.) The stored block - length is two bytes long. The gzip extra field two-byte identification is - "ap" for append. It is assumed that writing the extra field to the file is - an "atomic" operation. That is, either all of the extra field is written - to the file, or none of it is, if the operation is interrupted right at the - point of updating the extra field. This is a reasonable assumption, since - the extra field is within the first 52 bytes of the file, which is smaller - than any expected block size for a mass storage device (usually 512 bytes or - larger). - - Extra field (35 bytes): - - Pointer to first stored block length -- this points to the two-byte length - of the first stored block, which is followed by the two-byte, one's - complement of that length. The stored block length is preceded by the - three-bit header of the stored block, which is the actual start of the - stored block in the deflate format. See the bit offset field below. - - Pointer to the last stored block length. This is the same as above, but - for the last stored block of the uncompressed data in the gzip file. - Initially this is the same as the first stored block length pointer. - When the stored block gets to 16K (see the MAX_STORE define), then a new - stored block as added, at which point the last stored block length pointer - is different from the first stored block length pointer. When they are - different, the first bit of the last stored block header is eight bits, or - one byte back from the block length. - - Compressed data crc and length. This is the crc and length of the data - that is in the compressed portion of the deflate stream. These are used - only in the event that the foo.add file containing the data to compress is - lost after a compress operation is interrupted. - - Total data crc and length. This is the crc and length of all of the data - stored in the gzip file, compressed and uncompressed. It is used to - reconstruct the gzip trailer when compressing, as well as when recovering - interrupted operations. - - Final stored block length. This is used to quickly find where to append, - and allows the restoration of the original final stored block state when - an append operation is interrupted. - - First stored block start as the number of bits back from the final stored - block first length byte. This value is in the range of 3..10, and is - stored as the low three bits of the final byte of the extra field after - subtracting three (0..7). This allows the last-block bit of the stored - block header to be updated when a new stored block is added, for the case - when the first stored block and the last stored block are the same. (When - they are different, the numbers of bits back is known to be eight.) This - also allows for new compressed data to be appended to the old compressed - data in the compress operation, overwriting the previous first stored - block, or for the compressed data to be terminated and a valid gzip file - reconstructed on the off chance that a compression operation was - interrupted and the data to compress in the foo.add file was deleted. - - The operation in process. This is the next two bits in the last byte (the - bits under the mask 0x18). The are interpreted as 0: nothing in process, - 1: append in process, 2: compress in process, 3: replace in process. - - The top three bits of the last byte in the extra field are reserved and - are currently set to zero. - - Main procedure: - - Exclusively create the foo.lock file using the O_CREAT and O_EXCL modes of - the system open() call. If the modify time of an existing lock file is - more than PATIENCE seconds old, then the lock file is deleted and the - exclusive create is retried. - - Load the extra field from the foo.gz file, and see if an operation was in - progress but not completed. If so, apply the recovery procedure below. - - Perform the append procedure with the provided data. - - If the uncompressed data in the foo.gz file is 1MB or more, apply the - compress procedure. - - Delete the foo.lock file. - - Append procedure: - - Put what to append in the foo.add file so that the operation can be - restarted if this procedure is interrupted. - - Mark the foo.gz extra field with the append operation in progress. - + Restore the original last-block bit and stored block length of the last - stored block from the information in the extra field, in case a previous - append operation was interrupted. - - Append the provided data to the last stored block, creating new stored - blocks as needed and updating the stored blocks last-block bits and - lengths. - - Update the crc and length with the new data, and write the gzip trailer. - - Write over the extra field (with a single write operation) with the new - pointers, lengths, and crc's, and mark the gzip file as not in process. - Though there is still a foo.add file, it will be ignored since nothing - is in process. If a foo.add file is leftover from a previously - completed operation, it is truncated when writing new data to it. - - Delete the foo.add file. - - Compress and replace procedures: - - Read all of the uncompressed data in the stored blocks in foo.gz and write - it to foo.add. Also write foo.temp with the last 32K of that data to - provide a dictionary for the next invocation of this procedure. - - Rewrite the extra field marking foo.gz with a compression in process. - * If there is no data provided to compress (due to a missing foo.add file - when recovering), reconstruct and truncate the foo.gz file to contain - only the previous compressed data and proceed to the step after the next - one. Otherwise ... - - Compress the data with the dictionary in foo.dict, and write to the - foo.gz file starting at the bit immediately following the last previously - compressed block. If there is no foo.dict, proceed anyway with the - compression at slightly reduced efficiency. (For the foo.dict file to be - missing requires some external failure beyond simply the interruption of - a compress operation.) During this process, the foo.lock file is - periodically touched to assure that that file is not considered stale by - another process before we're done. The deflation is terminated with a - non-last empty static block (10 bits long), that is then located and - written over by a last-bit-set empty stored block. - - Append the crc and length of the data in the gzip file (previously - calculated during the append operations). - - Write over the extra field with the updated stored block offsets, bits - back, crc's, and lengths, and mark foo.gz as in process for a replacement - of the dictionary. - @ Delete the foo.add file. - - Replace foo.dict with foo.temp. - - Write over the extra field, marking foo.gz as complete. - - Recovery procedure: - - If not a replace recovery, read in the foo.add file, and provide that data - to the appropriate recovery below. If there is no foo.add file, provide - a zero data length to the recovery. In that case, the append recovery - restores the foo.gz to the previous compressed + uncompressed data state. - For the the compress recovery, a missing foo.add file results in foo.gz - being restored to the previous compressed-only data state. - - Append recovery: - - Pick up append at + step above - - Compress recovery: - - Pick up compress at * step above - - Replace recovery: - - Pick up compress at @ step above - - Log the repair with a date stamp in foo.repairs - */ - -#include -#include /* rename, fopen, fprintf, fclose */ -#include /* malloc, free */ -#include /* strlen, strrchr, strcpy, strncpy, strcmp */ -#include /* open */ -#include /* lseek, read, write, close, unlink, sleep, */ - /* ftruncate, fsync */ -#include /* errno */ -#include /* time, ctime */ -#include /* stat */ -#include /* utimes */ -#include "zlib.h" /* crc32 */ - -#include "gzlog.h" /* header for external access */ - -#define local static -typedef unsigned int uint; -typedef unsigned long ulong; - -/* Macro for debugging to deterministically force recovery operations */ -#ifdef GZLOG_DEBUG - #include /* longjmp */ - jmp_buf gzlog_jump; /* where to go back to */ - int gzlog_bail = 0; /* which point to bail at (1..8) */ - int gzlog_count = -1; /* number of times through to wait */ -# define BAIL(n) do { if (n == gzlog_bail && gzlog_count-- == 0) \ - longjmp(gzlog_jump, gzlog_bail); } while (0) -#else -# define BAIL(n) -#endif - -/* how old the lock file can be in seconds before considering it stale */ -#define PATIENCE 300 - -/* maximum stored block size in Kbytes -- must be in 1..63 */ -#define MAX_STORE 16 - -/* number of stored Kbytes to trigger compression (must be >= 32 to allow - dictionary construction, and <= 204 * MAX_STORE, in order for >> 10 to - discard the stored block headers contribution of five bytes each) */ -#define TRIGGER 1024 - -/* size of a deflate dictionary (this cannot be changed) */ -#define DICT 32768U - -/* values for the operation (2 bits) */ -#define NO_OP 0 -#define APPEND_OP 1 -#define COMPRESS_OP 2 -#define REPLACE_OP 3 - -/* macros to extract little-endian integers from an unsigned byte buffer */ -#define PULL2(p) ((p)[0]+((uint)((p)[1])<<8)) -#define PULL4(p) (PULL2(p)+((ulong)PULL2(p+2)<<16)) -#define PULL8(p) (PULL4(p)+((off_t)PULL4(p+4)<<32)) - -/* macros to store integers into a byte buffer in little-endian order */ -#define PUT2(p,a) do {(p)[0]=a;(p)[1]=(a)>>8;} while(0) -#define PUT4(p,a) do {PUT2(p,a);PUT2(p+2,a>>16);} while(0) -#define PUT8(p,a) do {PUT4(p,a);PUT4(p+4,a>>32);} while(0) - -/* internal structure for log information */ -#define LOGID "\106\035\172" /* should be three non-zero characters */ -struct log { - char id[4]; /* contains LOGID to detect inadvertent overwrites */ - int fd; /* file descriptor for .gz file, opened read/write */ - char *path; /* allocated path, e.g. "/var/log/foo" or "foo" */ - char *end; /* end of path, for appending suffices such as ".gz" */ - off_t first; /* offset of first stored block first length byte */ - int back; /* location of first block id in bits back from first */ - uint stored; /* bytes currently in last stored block */ - off_t last; /* offset of last stored block first length byte */ - ulong ccrc; /* crc of compressed data */ - ulong clen; /* length (modulo 2^32) of compressed data */ - ulong tcrc; /* crc of total data */ - ulong tlen; /* length (modulo 2^32) of total data */ - time_t lock; /* last modify time of our lock file */ -}; - -/* gzip header for gzlog */ -local unsigned char log_gzhead[] = { - 0x1f, 0x8b, /* magic gzip id */ - 8, /* compression method is deflate */ - 4, /* there is an extra field (no file name) */ - 0, 0, 0, 0, /* no modification time provided */ - 0, 0xff, /* no extra flags, no OS specified */ - 39, 0, 'a', 'p', 35, 0 /* extra field with "ap" subfield */ - /* 35 is EXTRA, 39 is EXTRA + 4 */ -}; - -#define HEAD sizeof(log_gzhead) /* should be 16 */ - -/* initial gzip extra field content (52 == HEAD + EXTRA + 1) */ -local unsigned char log_gzext[] = { - 52, 0, 0, 0, 0, 0, 0, 0, /* offset of first stored block length */ - 52, 0, 0, 0, 0, 0, 0, 0, /* offset of last stored block length */ - 0, 0, 0, 0, 0, 0, 0, 0, /* compressed data crc and length */ - 0, 0, 0, 0, 0, 0, 0, 0, /* total data crc and length */ - 0, 0, /* final stored block data length */ - 5 /* op is NO_OP, last bit 8 bits back */ -}; - -#define EXTRA sizeof(log_gzext) /* should be 35 */ - -/* initial gzip data and trailer */ -local unsigned char log_gzbody[] = { - 1, 0, 0, 0xff, 0xff, /* empty stored block (last) */ - 0, 0, 0, 0, /* crc */ - 0, 0, 0, 0 /* uncompressed length */ -}; - -#define BODY sizeof(log_gzbody) - -/* Exclusively create foo.lock in order to negotiate exclusive access to the - foo.* files. If the modify time of an existing lock file is greater than - PATIENCE seconds in the past, then consider the lock file to have been - abandoned, delete it, and try the exclusive create again. Save the lock - file modify time for verification of ownership. Return 0 on success, or -1 - on failure, usually due to an access restriction or invalid path. Note that - if stat() or unlink() fails, it may be due to another process noticing the - abandoned lock file a smidge sooner and deleting it, so those are not - flagged as an error. */ -local int log_lock(struct log *log) -{ - int fd; - struct stat st; - - strcpy(log->end, ".lock"); - while ((fd = open(log->path, O_CREAT | O_EXCL, 0644)) < 0) { - if (errno != EEXIST) - return -1; - if (stat(log->path, &st) == 0 && time(NULL) - st.st_mtime > PATIENCE) { - unlink(log->path); - continue; - } - sleep(2); /* relinquish the CPU for two seconds while waiting */ - } - close(fd); - if (stat(log->path, &st) == 0) - log->lock = st.st_mtime; - return 0; -} - -/* Update the modify time of the lock file to now, in order to prevent another - task from thinking that the lock is stale. Save the lock file modify time - for verification of ownership. */ -local void log_touch(struct log *log) -{ - struct stat st; - - strcpy(log->end, ".lock"); - utimes(log->path, NULL); - if (stat(log->path, &st) == 0) - log->lock = st.st_mtime; -} - -/* Check the log file modify time against what is expected. Return true if - this is not our lock. If it is our lock, touch it to keep it. */ -local int log_check(struct log *log) -{ - struct stat st; - - strcpy(log->end, ".lock"); - if (stat(log->path, &st) || st.st_mtime != log->lock) - return 1; - log_touch(log); - return 0; -} - -/* Unlock a previously acquired lock, but only if it's ours. */ -local void log_unlock(struct log *log) -{ - if (log_check(log)) - return; - strcpy(log->end, ".lock"); - unlink(log->path); - log->lock = 0; -} - -/* Check the gzip header and read in the extra field, filling in the values in - the log structure. Return op on success or -1 if the gzip header was not as - expected. op is the current operation in progress last written to the extra - field. This assumes that the gzip file has already been opened, with the - file descriptor log->fd. */ -local int log_head(struct log *log) -{ - int op; - unsigned char buf[HEAD + EXTRA]; - - if (lseek(log->fd, 0, SEEK_SET) < 0 || - read(log->fd, buf, HEAD + EXTRA) != HEAD + EXTRA || - memcmp(buf, log_gzhead, HEAD)) { - return -1; - } - log->first = PULL8(buf + HEAD); - log->last = PULL8(buf + HEAD + 8); - log->ccrc = PULL4(buf + HEAD + 16); - log->clen = PULL4(buf + HEAD + 20); - log->tcrc = PULL4(buf + HEAD + 24); - log->tlen = PULL4(buf + HEAD + 28); - log->stored = PULL2(buf + HEAD + 32); - log->back = 3 + (buf[HEAD + 34] & 7); - op = (buf[HEAD + 34] >> 3) & 3; - return op; -} - -/* Write over the extra field contents, marking the operation as op. Use fsync - to assure that the device is written to, and in the requested order. This - operation, and only this operation, is assumed to be atomic in order to - assure that the log is recoverable in the event of an interruption at any - point in the process. Return -1 if the write to foo.gz failed. */ -local int log_mark(struct log *log, int op) -{ - int ret; - unsigned char ext[EXTRA]; - - PUT8(ext, log->first); - PUT8(ext + 8, log->last); - PUT4(ext + 16, log->ccrc); - PUT4(ext + 20, log->clen); - PUT4(ext + 24, log->tcrc); - PUT4(ext + 28, log->tlen); - PUT2(ext + 32, log->stored); - ext[34] = log->back - 3 + (op << 3); - fsync(log->fd); - ret = lseek(log->fd, HEAD, SEEK_SET) < 0 || - write(log->fd, ext, EXTRA) != EXTRA ? -1 : 0; - fsync(log->fd); - return ret; -} - -/* Rewrite the last block header bits and subsequent zero bits to get to a byte - boundary, setting the last block bit if last is true, and then write the - remainder of the stored block header (length and one's complement). Leave - the file pointer after the end of the last stored block data. Return -1 if - there is a read or write failure on the foo.gz file */ -local int log_last(struct log *log, int last) -{ - int back, len, mask; - unsigned char buf[6]; - - /* determine the locations of the bytes and bits to modify */ - back = log->last == log->first ? log->back : 8; - len = back > 8 ? 2 : 1; /* bytes back from log->last */ - mask = 0x80 >> ((back - 1) & 7); /* mask for block last-bit */ - - /* get the byte to modify (one or two back) into buf[0] -- don't need to - read the byte if the last-bit is eight bits back, since in that case - the entire byte will be modified */ - buf[0] = 0; - if (back != 8 && (lseek(log->fd, log->last - len, SEEK_SET) < 0 || - read(log->fd, buf, 1) != 1)) - return -1; - - /* change the last-bit of the last stored block as requested -- note - that all bits above the last-bit are set to zero, per the type bits - of a stored block being 00 and per the convention that the bits to - bring the stream to a byte boundary are also zeros */ - buf[1] = 0; - buf[2 - len] = (*buf & (mask - 1)) + (last ? mask : 0); - - /* write the modified stored block header and lengths, move the file - pointer to after the last stored block data */ - PUT2(buf + 2, log->stored); - PUT2(buf + 4, log->stored ^ 0xffff); - return lseek(log->fd, log->last - len, SEEK_SET) < 0 || - write(log->fd, buf + 2 - len, len + 4) != len + 4 || - lseek(log->fd, log->stored, SEEK_CUR) < 0 ? -1 : 0; -} - -/* Append len bytes from data to the locked and open log file. len may be zero - if recovering and no .add file was found. In that case, the previous state - of the foo.gz file is restored. The data is appended uncompressed in - deflate stored blocks. Return -1 if there was an error reading or writing - the foo.gz file. */ -local int log_append(struct log *log, unsigned char *data, size_t len) -{ - uint put; - off_t end; - unsigned char buf[8]; - - /* set the last block last-bit and length, in case recovering an - interrupted append, then position the file pointer to append to the - block */ - if (log_last(log, 1)) - return -1; - - /* append, adding stored blocks and updating the offset of the last stored - block as needed, and update the total crc and length */ - while (len) { - /* append as much as we can to the last block */ - put = (MAX_STORE << 10) - log->stored; - if (put > len) - put = (uint)len; - if (put) { - if (write(log->fd, data, put) != put) - return -1; - BAIL(1); - log->tcrc = crc32(log->tcrc, data, put); - log->tlen += put; - log->stored += put; - data += put; - len -= put; - } - - /* if we need to, add a new empty stored block */ - if (len) { - /* mark current block as not last */ - if (log_last(log, 0)) - return -1; - - /* point to new, empty stored block */ - log->last += 4 + log->stored + 1; - log->stored = 0; - } - - /* mark last block as last, update its length */ - if (log_last(log, 1)) - return -1; - BAIL(2); - } - - /* write the new crc and length trailer, and truncate just in case (could - be recovering from partial append with a missing foo.add file) */ - PUT4(buf, log->tcrc); - PUT4(buf + 4, log->tlen); - if (write(log->fd, buf, 8) != 8 || - (end = lseek(log->fd, 0, SEEK_CUR)) < 0 || ftruncate(log->fd, end)) - return -1; - - /* write the extra field, marking the log file as done, delete .add file */ - if (log_mark(log, NO_OP)) - return -1; - strcpy(log->end, ".add"); - unlink(log->path); /* ignore error, since may not exist */ - return 0; -} - -/* Replace the foo.dict file with the foo.temp file. Also delete the foo.add - file, since the compress operation may have been interrupted before that was - done. Returns 1 if memory could not be allocated, or -1 if reading or - writing foo.gz fails, or if the rename fails for some reason other than - foo.temp not existing. foo.temp not existing is a permitted error, since - the replace operation may have been interrupted after the rename is done, - but before foo.gz is marked as complete. */ -local int log_replace(struct log *log) -{ - int ret; - char *dest; - - /* delete foo.add file */ - strcpy(log->end, ".add"); - unlink(log->path); /* ignore error, since may not exist */ - BAIL(3); - - /* rename foo.name to foo.dict, replacing foo.dict if it exists */ - strcpy(log->end, ".dict"); - dest = malloc(strlen(log->path) + 1); - if (dest == NULL) - return -2; - strcpy(dest, log->path); - strcpy(log->end, ".temp"); - ret = rename(log->path, dest); - free(dest); - if (ret && errno != ENOENT) - return -1; - BAIL(4); - - /* mark the foo.gz file as done */ - return log_mark(log, NO_OP); -} - -/* Compress the len bytes at data and append the compressed data to the - foo.gz deflate data immediately after the previous compressed data. This - overwrites the previous uncompressed data, which was stored in foo.add - and is the data provided in data[0..len-1]. If this operation is - interrupted, it picks up at the start of this routine, with the foo.add - file read in again. If there is no data to compress (len == 0), then we - simply terminate the foo.gz file after the previously compressed data, - appending a final empty stored block and the gzip trailer. Return -1 if - reading or writing the log.gz file failed, or -2 if there was a memory - allocation failure. */ -local int log_compress(struct log *log, unsigned char *data, size_t len) -{ - int fd; - uint got, max; - ssize_t dict; - off_t end; - z_stream strm; - unsigned char buf[DICT]; - - /* compress and append compressed data */ - if (len) { - /* set up for deflate, allocating memory */ - strm.zalloc = Z_NULL; - strm.zfree = Z_NULL; - strm.opaque = Z_NULL; - if (deflateInit2(&strm, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -15, 8, - Z_DEFAULT_STRATEGY) != Z_OK) - return -2; - - /* read in dictionary (last 32K of data that was compressed) */ - strcpy(log->end, ".dict"); - fd = open(log->path, O_RDONLY, 0); - if (fd >= 0) { - dict = read(fd, buf, DICT); - close(fd); - if (dict < 0) { - deflateEnd(&strm); - return -1; - } - if (dict) - deflateSetDictionary(&strm, buf, (uint)dict); - } - log_touch(log); - - /* prime deflate with last bits of previous block, position write - pointer to write those bits and overwrite what follows */ - if (lseek(log->fd, log->first - (log->back > 8 ? 2 : 1), - SEEK_SET) < 0 || - read(log->fd, buf, 1) != 1 || lseek(log->fd, -1, SEEK_CUR) < 0) { - deflateEnd(&strm); - return -1; - } - deflatePrime(&strm, (8 - log->back) & 7, *buf); - - /* compress, finishing with a partial non-last empty static block */ - strm.next_in = data; - max = (((uint)0 - 1) >> 1) + 1; /* in case int smaller than size_t */ - do { - strm.avail_in = len > max ? max : (uint)len; - len -= strm.avail_in; - do { - strm.avail_out = DICT; - strm.next_out = buf; - deflate(&strm, len ? Z_NO_FLUSH : Z_PARTIAL_FLUSH); - got = DICT - strm.avail_out; - if (got && write(log->fd, buf, got) != got) { - deflateEnd(&strm); - return -1; - } - log_touch(log); - } while (strm.avail_out == 0); - } while (len); - deflateEnd(&strm); - BAIL(5); - - /* find start of empty static block -- scanning backwards the first one - bit is the second bit of the block, if the last byte is zero, then - we know the byte before that has a one in the top bit, since an - empty static block is ten bits long */ - if ((log->first = lseek(log->fd, -1, SEEK_CUR)) < 0 || - read(log->fd, buf, 1) != 1) - return -1; - log->first++; - if (*buf) { - log->back = 1; - while ((*buf & ((uint)1 << (8 - log->back++))) == 0) - ; /* guaranteed to terminate, since *buf != 0 */ - } - else - log->back = 10; - - /* update compressed crc and length */ - log->ccrc = log->tcrc; - log->clen = log->tlen; - } - else { - /* no data to compress -- fix up existing gzip stream */ - log->tcrc = log->ccrc; - log->tlen = log->clen; - } - - /* complete and truncate gzip stream */ - log->last = log->first; - log->stored = 0; - PUT4(buf, log->tcrc); - PUT4(buf + 4, log->tlen); - if (log_last(log, 1) || write(log->fd, buf, 8) != 8 || - (end = lseek(log->fd, 0, SEEK_CUR)) < 0 || ftruncate(log->fd, end)) - return -1; - BAIL(6); - - /* mark as being in the replace operation */ - if (log_mark(log, REPLACE_OP)) - return -1; - - /* execute the replace operation and mark the file as done */ - return log_replace(log); -} - -/* log a repair record to the .repairs file */ -local void log_log(struct log *log, int op, char *record) -{ - time_t now; - FILE *rec; - - now = time(NULL); - strcpy(log->end, ".repairs"); - rec = fopen(log->path, "a"); - if (rec == NULL) - return; - fprintf(rec, "%.24s %s recovery: %s\n", ctime(&now), op == APPEND_OP ? - "append" : (op == COMPRESS_OP ? "compress" : "replace"), record); - fclose(rec); - return; -} - -/* Recover the interrupted operation op. First read foo.add for recovering an - append or compress operation. Return -1 if there was an error reading or - writing foo.gz or reading an existing foo.add, or -2 if there was a memory - allocation failure. */ -local int log_recover(struct log *log, int op) -{ - int fd, ret = 0; - unsigned char *data = NULL; - size_t len = 0; - struct stat st; - - /* log recovery */ - log_log(log, op, "start"); - - /* load foo.add file if expected and present */ - if (op == APPEND_OP || op == COMPRESS_OP) { - strcpy(log->end, ".add"); - if (stat(log->path, &st) == 0 && st.st_size) { - len = (size_t)(st.st_size); - if ((off_t)len != st.st_size || - (data = malloc(st.st_size)) == NULL) { - log_log(log, op, "allocation failure"); - return -2; - } - if ((fd = open(log->path, O_RDONLY, 0)) < 0) { - free(data); - log_log(log, op, ".add file read failure"); - return -1; - } - ret = (size_t)read(fd, data, len) != len; - close(fd); - if (ret) { - free(data); - log_log(log, op, ".add file read failure"); - return -1; - } - log_log(log, op, "loaded .add file"); - } - else - log_log(log, op, "missing .add file!"); - } - - /* recover the interrupted operation */ - switch (op) { - case APPEND_OP: - ret = log_append(log, data, len); - break; - case COMPRESS_OP: - ret = log_compress(log, data, len); - break; - case REPLACE_OP: - ret = log_replace(log); - } - - /* log status */ - log_log(log, op, ret ? "failure" : "complete"); - - /* clean up */ - if (data != NULL) - free(data); - return ret; -} - -/* Close the foo.gz file (if open) and release the lock. */ -local void log_close(struct log *log) -{ - if (log->fd >= 0) - close(log->fd); - log->fd = -1; - log_unlock(log); -} - -/* Open foo.gz, verify the header, and load the extra field contents, after - first creating the foo.lock file to gain exclusive access to the foo.* - files. If foo.gz does not exist or is empty, then write the initial header, - extra, and body content of an empty foo.gz log file. If there is an error - creating the lock file due to access restrictions, or an error reading or - writing the foo.gz file, or if the foo.gz file is not a proper log file for - this object (e.g. not a gzip file or does not contain the expected extra - field), then return true. If there is an error, the lock is released. - Otherwise, the lock is left in place. */ -local int log_open(struct log *log) -{ - int op; - - /* release open file resource if left over -- can occur if lock lost - between gzlog_open() and gzlog_write() */ - if (log->fd >= 0) - close(log->fd); - log->fd = -1; - - /* negotiate exclusive access */ - if (log_lock(log) < 0) - return -1; - - /* open the log file, foo.gz */ - strcpy(log->end, ".gz"); - log->fd = open(log->path, O_RDWR | O_CREAT, 0644); - if (log->fd < 0) { - log_close(log); - return -1; - } - - /* if new, initialize foo.gz with an empty log, delete old dictionary */ - if (lseek(log->fd, 0, SEEK_END) == 0) { - if (write(log->fd, log_gzhead, HEAD) != HEAD || - write(log->fd, log_gzext, EXTRA) != EXTRA || - write(log->fd, log_gzbody, BODY) != BODY) { - log_close(log); - return -1; - } - strcpy(log->end, ".dict"); - unlink(log->path); - } - - /* verify log file and load extra field information */ - if ((op = log_head(log)) < 0) { - log_close(log); - return -1; - } - - /* check for interrupted process and if so, recover */ - if (op != NO_OP && log_recover(log, op)) { - log_close(log); - return -1; - } - - /* touch the lock file to prevent another process from grabbing it */ - log_touch(log); - return 0; -} - -/* See gzlog.h for the description of the external methods below */ -gzlog *gzlog_open(char *path) -{ - size_t n; - struct log *log; - - /* check arguments */ - if (path == NULL || *path == 0) - return NULL; - - /* allocate and initialize log structure */ - log = malloc(sizeof(struct log)); - if (log == NULL) - return NULL; - strcpy(log->id, LOGID); - log->fd = -1; - - /* save path and end of path for name construction */ - n = strlen(path); - log->path = malloc(n + 9); /* allow for ".repairs" */ - if (log->path == NULL) { - free(log); - return NULL; - } - strcpy(log->path, path); - log->end = log->path + n; - - /* gain exclusive access and verify log file -- may perform a - recovery operation if needed */ - if (log_open(log)) { - free(log->path); - free(log); - return NULL; - } - - /* return pointer to log structure */ - return log; -} - -/* gzlog_compress() return values: - 0: all good - -1: file i/o error (usually access issue) - -2: memory allocation failure - -3: invalid log pointer argument */ -int gzlog_compress(gzlog *logd) -{ - int fd, ret; - uint block; - size_t len, next; - unsigned char *data, buf[5]; - struct log *log = logd; - - /* check arguments */ - if (log == NULL || strcmp(log->id, LOGID)) - return -3; - - /* see if we lost the lock -- if so get it again and reload the extra - field information (it probably changed), recover last operation if - necessary */ - if (log_check(log) && log_open(log)) - return -1; - - /* create space for uncompressed data */ - len = ((size_t)(log->last - log->first) & ~(((size_t)1 << 10) - 1)) + - log->stored; - if ((data = malloc(len)) == NULL) - return -2; - - /* do statement here is just a cheap trick for error handling */ - do { - /* read in the uncompressed data */ - if (lseek(log->fd, log->first - 1, SEEK_SET) < 0) - break; - next = 0; - while (next < len) { - if (read(log->fd, buf, 5) != 5) - break; - block = PULL2(buf + 1); - if (next + block > len || - read(log->fd, (char *)data + next, block) != block) - break; - next += block; - } - if (lseek(log->fd, 0, SEEK_CUR) != log->last + 4 + log->stored) - break; - log_touch(log); - - /* write the uncompressed data to the .add file */ - strcpy(log->end, ".add"); - fd = open(log->path, O_WRONLY | O_CREAT | O_TRUNC, 0644); - if (fd < 0) - break; - ret = (size_t)write(fd, data, len) != len; - if (ret | close(fd)) - break; - log_touch(log); - - /* write the dictionary for the next compress to the .temp file */ - strcpy(log->end, ".temp"); - fd = open(log->path, O_WRONLY | O_CREAT | O_TRUNC, 0644); - if (fd < 0) - break; - next = DICT > len ? len : DICT; - ret = (size_t)write(fd, (char *)data + len - next, next) != next; - if (ret | close(fd)) - break; - log_touch(log); - - /* roll back to compressed data, mark the compress in progress */ - log->last = log->first; - log->stored = 0; - if (log_mark(log, COMPRESS_OP)) - break; - BAIL(7); - - /* compress and append the data (clears mark) */ - ret = log_compress(log, data, len); - free(data); - return ret; - } while (0); - - /* broke out of do above on i/o error */ - free(data); - return -1; -} - -/* gzlog_write() return values: - 0: all good - -1: file i/o error (usually access issue) - -2: memory allocation failure - -3: invalid log pointer argument */ -int gzlog_write(gzlog *logd, void *data, size_t len) -{ - int fd, ret; - struct log *log = logd; - - /* check arguments */ - if (log == NULL || strcmp(log->id, LOGID)) - return -3; - if (data == NULL || len <= 0) - return 0; - - /* see if we lost the lock -- if so get it again and reload the extra - field information (it probably changed), recover last operation if - necessary */ - if (log_check(log) && log_open(log)) - return -1; - - /* create and write .add file */ - strcpy(log->end, ".add"); - fd = open(log->path, O_WRONLY | O_CREAT | O_TRUNC, 0644); - if (fd < 0) - return -1; - ret = (size_t)write(fd, data, len) != len; - if (ret | close(fd)) - return -1; - log_touch(log); - - /* mark log file with append in progress */ - if (log_mark(log, APPEND_OP)) - return -1; - BAIL(8); - - /* append data (clears mark) */ - if (log_append(log, data, len)) - return -1; - - /* check to see if it's time to compress -- if not, then done */ - if (((log->last - log->first) >> 10) + (log->stored >> 10) < TRIGGER) - return 0; - - /* time to compress */ - return gzlog_compress(log); -} - -/* gzlog_close() return values: - 0: ok - -3: invalid log pointer argument */ -int gzlog_close(gzlog *logd) -{ - struct log *log = logd; - - /* check arguments */ - if (log == NULL || strcmp(log->id, LOGID)) - return -3; - - /* close the log file and release the lock */ - log_close(log); - - /* free structure and return */ - if (log->path != NULL) - free(log->path); - strcpy(log->id, "bad"); - free(log); - return 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/gzlog.h b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/gzlog.h deleted file mode 100644 index 86f0cec..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/gzlog.h +++ /dev/null @@ -1,91 +0,0 @@ -/* gzlog.h - Copyright (C) 2004, 2008, 2012 Mark Adler, all rights reserved - version 2.2, 14 Aug 2012 - - This software is provided 'as-is', without any express or implied - warranty. In no event will the author be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Mark Adler madler@alumni.caltech.edu - */ - -/* Version History: - 1.0 26 Nov 2004 First version - 2.0 25 Apr 2008 Complete redesign for recovery of interrupted operations - Interface changed slightly in that now path is a prefix - Compression now occurs as needed during gzlog_write() - gzlog_write() now always leaves the log file as valid gzip - 2.1 8 Jul 2012 Fix argument checks in gzlog_compress() and gzlog_write() - 2.2 14 Aug 2012 Clean up signed comparisons - */ - -/* - The gzlog object allows writing short messages to a gzipped log file, - opening the log file locked for small bursts, and then closing it. The log - object works by appending stored (uncompressed) data to the gzip file until - 1 MB has been accumulated. At that time, the stored data is compressed, and - replaces the uncompressed data in the file. The log file is truncated to - its new size at that time. After each write operation, the log file is a - valid gzip file that can decompressed to recover what was written. - - The gzlog operations can be interupted at any point due to an application or - system crash, and the log file will be recovered the next time the log is - opened with gzlog_open(). - */ - -#ifndef GZLOG_H -#define GZLOG_H - -/* gzlog object type */ -typedef void gzlog; - -/* Open a gzlog object, creating the log file if it does not exist. Return - NULL on error. Note that gzlog_open() could take a while to complete if it - has to wait to verify that a lock is stale (possibly for five minutes), or - if there is significant contention with other instantiations of this object - when locking the resource. path is the prefix of the file names created by - this object. If path is "foo", then the log file will be "foo.gz", and - other auxiliary files will be created and destroyed during the process: - "foo.dict" for a compression dictionary, "foo.temp" for a temporary (next) - dictionary, "foo.add" for data being added or compressed, "foo.lock" for the - lock file, and "foo.repairs" to log recovery operations performed due to - interrupted gzlog operations. A gzlog_open() followed by a gzlog_close() - will recover a previously interrupted operation, if any. */ -gzlog *gzlog_open(char *path); - -/* Write to a gzlog object. Return zero on success, -1 if there is a file i/o - error on any of the gzlog files (this should not happen if gzlog_open() - succeeded, unless the device has run out of space or leftover auxiliary - files have permissions or ownership that prevent their use), -2 if there is - a memory allocation failure, or -3 if the log argument is invalid (e.g. if - it was not created by gzlog_open()). This function will write data to the - file uncompressed, until 1 MB has been accumulated, at which time that data - will be compressed. The log file will be a valid gzip file upon successful - return. */ -int gzlog_write(gzlog *log, void *data, size_t len); - -/* Force compression of any uncompressed data in the log. This should be used - sparingly, if at all. The main application would be when a log file will - not be appended to again. If this is used to compress frequently while - appending, it will both significantly increase the execution time and - reduce the compression ratio. The return codes are the same as for - gzlog_write(). */ -int gzlog_compress(gzlog *log); - -/* Close a gzlog object. Return zero on success, -3 if the log argument is - invalid. The log object is freed, and so cannot be referenced again. */ -int gzlog_close(gzlog *log); - -#endif diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/gznorm.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/gznorm.c deleted file mode 100644 index 68e0a0f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/gznorm.c +++ /dev/null @@ -1,470 +0,0 @@ -/* gznorm.c -- normalize a gzip stream - * Copyright (C) 2018 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - * Version 1.0 7 Oct 2018 Mark Adler */ - -// gznorm takes a gzip stream, potentially containing multiple members, and -// converts it to a gzip stream with a single member. In addition the gzip -// header is normalized, removing the file name and time stamp, and setting the -// other header contents (XFL, OS) to fixed values. gznorm does not recompress -// the data, so it is fast, but no advantage is gained from the history that -// could be available across member boundaries. - -#include // fread, fwrite, putc, fflush, ferror, fprintf, - // vsnprintf, stdout, stderr, NULL, FILE -#include // malloc, free -#include // strerror -#include // errno -#include // va_list, va_start, va_end -#include "zlib.h" // inflateInit2, inflate, inflateReset, inflateEnd, - // z_stream, z_off_t, crc32_combine, Z_NULL, Z_BLOCK, - // Z_OK, Z_STREAM_END, Z_BUF_ERROR, Z_DATA_ERROR, - // Z_MEM_ERROR - -#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__) -# include -# include -# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY) -#else -# define SET_BINARY_MODE(file) -#endif - -#define local static - -// printf to an allocated string. Return the string, or NULL if the printf or -// allocation fails. -local char *aprintf(char *fmt, ...) { - // Get the length of the result of the printf. - va_list args; - va_start(args, fmt); - int len = vsnprintf(NULL, 0, fmt, args); - va_end(args); - if (len < 0) - return NULL; - - // Allocate the required space and printf to it. - char *str = malloc(len + 1); - if (str == NULL) - return NULL; - va_start(args, fmt); - vsnprintf(str, len + 1, fmt, args); - va_end(args); - return str; -} - -// Return with an error, putting an allocated error message in *err. Doing an -// inflateEnd() on an already ended state, or one with state set to Z_NULL, is -// permitted. -#define BYE(...) \ - do { \ - inflateEnd(&strm); \ - *err = aprintf(__VA_ARGS__); \ - return 1; \ - } while (0) - -// Chunk size for buffered reads and for decompression. Twice this many bytes -// will be allocated on the stack by gzip_normalize(). Must fit in an unsigned. -#define CHUNK 16384 - -// Read a gzip stream from in and write an equivalent normalized gzip stream to -// out. If given no input, an empty gzip stream will be written. If successful, -// 0 is returned, and *err is set to NULL. On error, 1 is returned, where the -// details of the error are returned in *err, a pointer to an allocated string. -// -// The input may be a stream with multiple gzip members, which is converted to -// a single gzip member on the output. Each gzip member is decompressed at the -// level of deflate blocks. This enables clearing the last-block bit, shifting -// the compressed data to concatenate to the previous member's compressed data, -// which can end at an arbitrary bit boundary, and identifying stored blocks in -// order to resynchronize those to byte boundaries. The deflate compressed data -// is terminated with a 10-bit empty fixed block. If any members on the input -// end with a 10-bit empty fixed block, then that block is excised from the -// stream. This avoids appending empty fixed blocks for every normalization, -// and assures that gzip_normalize applied a second time will not change the -// input. The pad bits after stored block headers and after the final deflate -// block are all forced to zeros. -local int gzip_normalize(FILE *in, FILE *out, char **err) { - // initialize the inflate engine to process a gzip member - z_stream strm; - strm.zalloc = Z_NULL; - strm.zfree = Z_NULL; - strm.opaque = Z_NULL; - strm.avail_in = 0; - strm.next_in = Z_NULL; - if (inflateInit2(&strm, 15 + 16) != Z_OK) - BYE("out of memory"); - - // State while processing the input gzip stream. - enum { // BETWEEN -> HEAD -> BLOCK -> TAIL -> BETWEEN -> ... - BETWEEN, // between gzip members (must end in this state) - HEAD, // reading a gzip header - BLOCK, // reading deflate blocks - TAIL // reading a gzip trailer - } state = BETWEEN; // current component being processed - unsigned long crc = 0; // accumulated CRC of uncompressed data - unsigned long len = 0; // accumulated length of uncompressed data - unsigned long buf = 0; // deflate stream bit buffer of num bits - int num = 0; // number of bits in buf (at bottom) - - // Write a canonical gzip header (no mod time, file name, comment, extra - // block, or extra flags, and OS is marked as unknown). - fwrite("\x1f\x8b\x08\0\0\0\0\0\0\xff", 1, 10, out); - - // Process the gzip stream from in until reaching the end of the input, - // encountering invalid input, or experiencing an i/o error. - int more; // true if not at the end of the input - do { - // State inside this loop. - unsigned char *put; // next input buffer location to process - int prev; // number of bits from previous block in - // the bit buffer, or -1 if not at the - // start of a block - unsigned long long memb; // uncompressed length of member - size_t tail; // number of trailer bytes read (0..8) - unsigned long part; // accumulated trailer component - - // Get the next chunk of input from in. - unsigned char dat[CHUNK]; - strm.avail_in = fread(dat, 1, CHUNK, in); - if (strm.avail_in == 0) - break; - more = strm.avail_in == CHUNK; - strm.next_in = put = dat; - - // Run that chunk of input through the inflate engine to exhaustion. - do { - // At this point it is assured that strm.avail_in > 0. - - // Inflate until the end of a gzip component (header, deflate - // block, trailer) is reached, or until all of the chunk is - // consumed. The resulting decompressed data is discarded, though - // the total size of the decompressed data in each member is - // tracked, for the calculation of the total CRC. - do { - // inflate and handle any errors - unsigned char scrap[CHUNK]; - strm.avail_out = CHUNK; - strm.next_out = scrap; - int ret = inflate(&strm, Z_BLOCK); - if (ret == Z_MEM_ERROR) - BYE("out of memory"); - if (ret == Z_DATA_ERROR) - BYE("input invalid: %s", strm.msg); - if (ret != Z_OK && ret != Z_BUF_ERROR && ret != Z_STREAM_END) - BYE("internal error"); - - // Update the number of uncompressed bytes generated in this - // member. The actual count (not modulo 2^32) is required to - // correctly compute the total CRC. - unsigned got = CHUNK - strm.avail_out; - memb += got; - if (memb < got) - BYE("overflow error"); - - // Continue to process this chunk until it is consumed, or - // until the end of a component (header, deflate block, or - // trailer) is reached. - } while (strm.avail_out == 0 && (strm.data_type & 0x80) == 0); - - // Since strm.avail_in was > 0 for the inflate call, some input was - // just consumed. It is therefore assured that put < strm.next_in. - - // Disposition the consumed component or part of a component. - switch (state) { - case BETWEEN: - state = HEAD; - // Fall through to HEAD when some or all of the header is - // processed. - - case HEAD: - // Discard the header. - if (strm.data_type & 0x80) { - // End of header reached -- deflate blocks follow. - put = strm.next_in; - prev = num; - memb = 0; - state = BLOCK; - } - break; - - case BLOCK: - // Copy the deflate stream to the output, but with the - // last-block-bit cleared. Re-synchronize stored block - // headers to the output byte boundaries. The bytes at - // put..strm.next_in-1 is the compressed data that has been - // processed and is ready to be copied to the output. - - // At this point, it is assured that new compressed data is - // available, i.e., put < strm.next_in. If prev is -1, then - // that compressed data starts in the middle of a deflate - // block. If prev is not -1, then the bits in the bit - // buffer, possibly combined with the bits in *put, contain - // the three-bit header of the new deflate block. In that - // case, prev is the number of bits from the previous block - // that remain in the bit buffer. Since num is the number - // of bits in the bit buffer, we have that num - prev is - // the number of bits from the new block currently in the - // bit buffer. - - // If strm.data_type & 0xc0 is 0x80, then the last byte of - // the available compressed data includes the last bits of - // the end of a deflate block. In that case, that last byte - // also has strm.data_type & 0x1f bits of the next deflate - // block, in the range 0..7. If strm.data_type & 0xc0 is - // 0xc0, then the last byte of the compressed data is the - // end of the deflate stream, followed by strm.data_type & - // 0x1f pad bits, also in the range 0..7. - - // Set bits to the number of bits not yet consumed from the - // last byte. If we are at the end of the block, bits is - // either the number of bits in the last byte belonging to - // the next block, or the number of pad bits after the - // final block. In either of those cases, bits is in the - // range 0..7. - ; // (required due to C syntax oddity) - int bits = strm.data_type & 0x1f; - - if (prev != -1) { - // We are at the start of a new block. Clear the last - // block bit, and check for special cases. If it is a - // stored block, then emit the header and pad to the - // next byte boundary. If it is a final, empty fixed - // block, then excise it. - - // Some or all of the three header bits for this block - // may already be in the bit buffer. Load any remaining - // header bits into the bit buffer. - if (num - prev < 3) { - buf += (unsigned long)*put++ << num; - num += 8; - } - - // Set last to have a 1 in the position of the last - // block bit in the bit buffer. - unsigned long last = (unsigned long)1 << prev; - - if (((buf >> prev) & 7) == 3) { - // This is a final fixed block. Load at least ten - // bits from this block, including the header, into - // the bit buffer. We already have at least three, - // so at most one more byte needs to be loaded. - if (num - prev < 10) { - if (put == strm.next_in) - // Need to go get and process more input. - // We'll end up back here to finish this. - break; - buf += (unsigned long)*put++ << num; - num += 8; - } - if (((buf >> prev) & 0x3ff) == 3) { - // That final fixed block is empty. Delete it - // to avoid adding an empty block every time a - // gzip stream is normalized. - num = prev; - buf &= last - 1; // zero the pad bits - } - } - else if (((buf >> prev) & 6) == 0) { - // This is a stored block. Flush to the next - // byte boundary after the three-bit header. - num = (prev + 10) & ~7; - buf &= last - 1; // zero the pad bits - } - - // Clear the last block bit. - buf &= ~last; - - // Write out complete bytes in the bit buffer. - while (num >= 8) { - putc(buf, out); - buf >>= 8; - num -= 8; - } - - // If no more bytes left to process, then we have - // consumed the byte that had bits from the next block. - if (put == strm.next_in) - bits = 0; - } - - // We are done handling the deflate block header. Now copy - // all or almost all of the remaining compressed data that - // has been processed so far. Don't copy one byte at the - // end if it contains bits from the next deflate block or - // pad bits at the end of a deflate block. - - // mix is 1 if we are at the end of a deflate block, and if - // some of the bits in the last byte follow this block. mix - // is 0 if we are in the middle of a deflate block, if the - // deflate block ended on a byte boundary, or if all of the - // compressed data processed so far has been consumed. - int mix = (strm.data_type & 0x80) && bits; - - // Copy all of the processed compressed data to the output, - // except for the last byte if it contains bits from the - // next deflate block or pad bits at the end of the deflate - // stream. Copy the data after shifting in num bits from - // buf in front of it, leaving num bits from the end of the - // compressed data in buf when done. - unsigned char *end = strm.next_in - mix; - if (put < end) { - if (num) - // Insert num bits from buf before the data being - // copied. - do { - buf += (unsigned)(*put++) << num; - putc(buf, out); - buf >>= 8; - } while (put < end); - else { - // No shifting needed -- write directly. - fwrite(put, 1, end - put, out); - put = end; - } - } - - // Process the last processed byte if it wasn't written. - if (mix) { - // Load the last byte into the bit buffer. - buf += (unsigned)(*put++) << num; - num += 8; - - if (strm.data_type & 0x40) { - // We are at the end of the deflate stream and - // there are bits pad bits. Discard the pad bits - // and write a byte to the output, if available. - // Leave the num bits left over in buf to prepend - // to the next deflate stream. - num -= bits; - if (num >= 8) { - putc(buf, out); - num -= 8; - buf >>= 8; - } - - // Force the pad bits in the bit buffer to zeros. - buf &= ((unsigned long)1 << num) - 1; - - // Don't need to set prev here since going to TAIL. - } - else - // At the end of an internal deflate block. Leave - // the last byte in the bit buffer to examine on - // the next entry to BLOCK, when more bits from the - // next block will be available. - prev = num - bits; // number of bits in buffer - // from current block - } - - // Don't have a byte left over, so we are in the middle of - // a deflate block, or the deflate block ended on a byte - // boundary. Set prev appropriately for the next entry into - // BLOCK. - else if (strm.data_type & 0x80) - // The block ended on a byte boundary, so no header - // bits are in the bit buffer. - prev = num; - else - // In the middle of a deflate block, so no header here. - prev = -1; - - // Check for the end of the deflate stream. - if ((strm.data_type & 0xc0) == 0xc0) { - // That ends the deflate stream on the input side, the - // pad bits were discarded, and any remaining bits from - // the last block in the stream are saved in the bit - // buffer to prepend to the next stream. Process the - // gzip trailer next. - tail = 0; - part = 0; - state = TAIL; - } - break; - - case TAIL: - // Accumulate available trailer bytes to update the total - // CRC and the total uncompressed length. - do { - part = (part >> 8) + ((unsigned long)(*put++) << 24); - tail++; - if (tail == 4) { - // Update the total CRC. - z_off_t len2 = memb; - if (len2 < 0 || (unsigned long long)len2 != memb) - BYE("overflow error"); - crc = crc ? crc32_combine(crc, part, len2) : part; - part = 0; - } - else if (tail == 8) { - // Update the total uncompressed length. (It's ok - // if this sum is done modulo 2^32.) - len += part; - - // At the end of a member. Set up to inflate an - // immediately following gzip member. (If we made - // it this far, then the trailer was valid.) - if (inflateReset(&strm) != Z_OK) - BYE("internal error"); - state = BETWEEN; - break; - } - } while (put < strm.next_in); - break; - } - - // Process the input buffer until completely consumed. - } while (strm.avail_in > 0); - - // Process input until end of file, invalid input, or i/o error. - } while (more); - - // Done with the inflate engine. - inflateEnd(&strm); - - // Verify the validity of the input. - if (state != BETWEEN) - BYE("input invalid: incomplete gzip stream"); - - // Write the remaining deflate stream bits, followed by a terminating - // deflate fixed block. - buf += (unsigned long)3 << num; - putc(buf, out); - putc(buf >> 8, out); - if (num > 6) - putc(0, out); - - // Write the gzip trailer, which is the CRC and the uncompressed length - // modulo 2^32, both in little-endian order. - putc(crc, out); - putc(crc >> 8, out); - putc(crc >> 16, out); - putc(crc >> 24, out); - putc(len, out); - putc(len >> 8, out); - putc(len >> 16, out); - putc(len >> 24, out); - fflush(out); - - // Check for any i/o errors. - if (ferror(in) || ferror(out)) - BYE("i/o error: %s", strerror(errno)); - - // All good! - *err = NULL; - return 0; -} - -// Normalize the gzip stream on stdin, writing the result to stdout. -int main(void) { - // Avoid end-of-line conversions on evil operating systems. - SET_BINARY_MODE(stdin); - SET_BINARY_MODE(stdout); - - // Normalize from stdin to stdout, returning 1 on error, 0 if ok. - char *err; - int ret = gzip_normalize(stdin, stdout, &err); - if (ret) - fprintf(stderr, "gznorm error: %s\n", err); - free(err); - return ret; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/zlib_how.html b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/zlib_how.html deleted file mode 100644 index 444ff1c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/zlib_how.html +++ /dev/null @@ -1,545 +0,0 @@ - - - - -zlib Usage Example - - - -

    zlib Usage Example

    -We often get questions about how the deflate() and inflate() functions should be used. -Users wonder when they should provide more input, when they should use more output, -what to do with a Z_BUF_ERROR, how to make sure the process terminates properly, and -so on. So for those who have read zlib.h (a few times), and -would like further edification, below is an annotated example in C of simple routines to compress and decompress -from an input file to an output file using deflate() and inflate() respectively. The -annotations are interspersed between lines of the code. So please read between the lines. -We hope this helps explain some of the intricacies of zlib. -

    -Without further adieu, here is the program zpipe.c: -

    
    -/* zpipe.c: example of proper use of zlib's inflate() and deflate()
    -   Not copyrighted -- provided to the public domain
    -   Version 1.4  11 December 2005  Mark Adler */
    -
    -/* Version history:
    -   1.0  30 Oct 2004  First version
    -   1.1   8 Nov 2004  Add void casting for unused return values
    -                     Use switch statement for inflate() return values
    -   1.2   9 Nov 2004  Add assertions to document zlib guarantees
    -   1.3   6 Apr 2005  Remove incorrect assertion in inf()
    -   1.4  11 Dec 2005  Add hack to avoid MSDOS end-of-line conversions
    -                     Avoid some compiler warnings for input and output buffers
    - */
    -
    -We now include the header files for the required definitions. From -stdio.h we use fopen(), fread(), fwrite(), -feof(), ferror(), and fclose() for file i/o, and -fputs() for error messages. From string.h we use -strcmp() for command line argument processing. -From assert.h we use the assert() macro. -From zlib.h -we use the basic compression functions deflateInit(), -deflate(), and deflateEnd(), and the basic decompression -functions inflateInit(), inflate(), and -inflateEnd(). -
    
    -#include <stdio.h>
    -#include <string.h>
    -#include <assert.h>
    -#include "zlib.h"
    -
    -This is an ugly hack required to avoid corruption of the input and output data on -Windows/MS-DOS systems. Without this, those systems would assume that the input and output -files are text, and try to convert the end-of-line characters from one standard to -another. That would corrupt binary data, and in particular would render the compressed data unusable. -This sets the input and output to binary which suppresses the end-of-line conversions. -SET_BINARY_MODE() will be used later on stdin and stdout, at the beginning of main(). -
    
    -#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
    -#  include <fcntl.h>
    -#  include <io.h>
    -#  define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
    -#else
    -#  define SET_BINARY_MODE(file)
    -#endif
    -
    -CHUNK is simply the buffer size for feeding data to and pulling data -from the zlib routines. Larger buffer sizes would be more efficient, -especially for inflate(). If the memory is available, buffers sizes -on the order of 128K or 256K bytes should be used. -
    
    -#define CHUNK 16384
    -
    -The def() routine compresses data from an input file to an output file. The output data -will be in the zlib format, which is different from the gzip or zip -formats. The zlib format has a very small header of only two bytes to identify it as -a zlib stream and to provide decoding information, and a four-byte trailer with a fast -check value to verify the integrity of the uncompressed data after decoding. -
    
    -/* Compress from file source to file dest until EOF on source.
    -   def() returns Z_OK on success, Z_MEM_ERROR if memory could not be
    -   allocated for processing, Z_STREAM_ERROR if an invalid compression
    -   level is supplied, Z_VERSION_ERROR if the version of zlib.h and the
    -   version of the library linked do not match, or Z_ERRNO if there is
    -   an error reading or writing the files. */
    -int def(FILE *source, FILE *dest, int level)
    -{
    -
    -Here are the local variables for def(). ret will be used for zlib -return codes. flush will keep track of the current flushing state for deflate(), -which is either no flushing, or flush to completion after the end of the input file is reached. -have is the amount of data returned from deflate(). The strm structure -is used to pass information to and from the zlib routines, and to maintain the -deflate() state. in and out are the input and output buffers for -deflate(). -
    
    -    int ret, flush;
    -    unsigned have;
    -    z_stream strm;
    -    unsigned char in[CHUNK];
    -    unsigned char out[CHUNK];
    -
    -The first thing we do is to initialize the zlib state for compression using -deflateInit(). This must be done before the first use of deflate(). -The zalloc, zfree, and opaque fields in the strm -structure must be initialized before calling deflateInit(). Here they are -set to the zlib constant Z_NULL to request that zlib use -the default memory allocation routines. An application may also choose to provide -custom memory allocation routines here. deflateInit() will allocate on the -order of 256K bytes for the internal state. -(See zlib Technical Details.) -

    -deflateInit() is called with a pointer to the structure to be initialized and -the compression level, which is an integer in the range of -1 to 9. Lower compression -levels result in faster execution, but less compression. Higher levels result in -greater compression, but slower execution. The zlib constant Z_DEFAULT_COMPRESSION, -equal to -1, -provides a good compromise between compression and speed and is equivalent to level 6. -Level 0 actually does no compression at all, and in fact expands the data slightly to produce -the zlib format (it is not a byte-for-byte copy of the input). -More advanced applications of zlib -may use deflateInit2() here instead. Such an application may want to reduce how -much memory will be used, at some price in compression. Or it may need to request a -gzip header and trailer instead of a zlib header and trailer, or raw -encoding with no header or trailer at all. -

    -We must check the return value of deflateInit() against the zlib constant -Z_OK to make sure that it was able to -allocate memory for the internal state, and that the provided arguments were valid. -deflateInit() will also check that the version of zlib that the zlib.h -file came from matches the version of zlib actually linked with the program. This -is especially important for environments in which zlib is a shared library. -

    -Note that an application can initialize multiple, independent zlib streams, which can -operate in parallel. The state information maintained in the structure allows the zlib -routines to be reentrant. -

    
    -    /* allocate deflate state */
    -    strm.zalloc = Z_NULL;
    -    strm.zfree = Z_NULL;
    -    strm.opaque = Z_NULL;
    -    ret = deflateInit(&strm, level);
    -    if (ret != Z_OK)
    -        return ret;
    -
    -With the pleasantries out of the way, now we can get down to business. The outer do-loop -reads all of the input file and exits at the bottom of the loop once end-of-file is reached. -This loop contains the only call of deflate(). So we must make sure that all of the -input data has been processed and that all of the output data has been generated and consumed -before we fall out of the loop at the bottom. -
    
    -    /* compress until end of file */
    -    do {
    -
    -We start off by reading data from the input file. The number of bytes read is put directly -into avail_in, and a pointer to those bytes is put into next_in. We also -check to see if end-of-file on the input has been reached. If we are at the end of file, then flush is set to the -zlib constant Z_FINISH, which is later passed to deflate() to -indicate that this is the last chunk of input data to compress. We need to use feof() -to check for end-of-file as opposed to seeing if fewer than CHUNK bytes have been read. The -reason is that if the input file length is an exact multiple of CHUNK, we will miss -the fact that we got to the end-of-file, and not know to tell deflate() to finish -up the compressed stream. If we are not yet at the end of the input, then the zlib -constant Z_NO_FLUSH will be passed to deflate to indicate that we are still -in the middle of the uncompressed data. -

    -If there is an error in reading from the input file, the process is aborted with -deflateEnd() being called to free the allocated zlib state before returning -the error. We wouldn't want a memory leak, now would we? deflateEnd() can be called -at any time after the state has been initialized. Once that's done, deflateInit() (or -deflateInit2()) would have to be called to start a new compression process. There is -no point here in checking the deflateEnd() return code. The deallocation can't fail. -

    
    -        strm.avail_in = fread(in, 1, CHUNK, source);
    -        if (ferror(source)) {
    -            (void)deflateEnd(&strm);
    -            return Z_ERRNO;
    -        }
    -        flush = feof(source) ? Z_FINISH : Z_NO_FLUSH;
    -        strm.next_in = in;
    -
    -The inner do-loop passes our chunk of input data to deflate(), and then -keeps calling deflate() until it is done producing output. Once there is no more -new output, deflate() is guaranteed to have consumed all of the input, i.e., -avail_in will be zero. -
    
    -        /* run deflate() on input until output buffer not full, finish
    -           compression if all of source has been read in */
    -        do {
    -
    -Output space is provided to deflate() by setting avail_out to the number -of available output bytes and next_out to a pointer to that space. -
    
    -            strm.avail_out = CHUNK;
    -            strm.next_out = out;
    -
    -Now we call the compression engine itself, deflate(). It takes as many of the -avail_in bytes at next_in as it can process, and writes as many as -avail_out bytes to next_out. Those counters and pointers are then -updated past the input data consumed and the output data written. It is the amount of -output space available that may limit how much input is consumed. -Hence the inner loop to make sure that -all of the input is consumed by providing more output space each time. Since avail_in -and next_in are updated by deflate(), we don't have to mess with those -between deflate() calls until it's all used up. -

    -The parameters to deflate() are a pointer to the strm structure containing -the input and output information and the internal compression engine state, and a parameter -indicating whether and how to flush data to the output. Normally deflate will consume -several K bytes of input data before producing any output (except for the header), in order -to accumulate statistics on the data for optimum compression. It will then put out a burst of -compressed data, and proceed to consume more input before the next burst. Eventually, -deflate() -must be told to terminate the stream, complete the compression with provided input data, and -write out the trailer check value. deflate() will continue to compress normally as long -as the flush parameter is Z_NO_FLUSH. Once the Z_FINISH parameter is provided, -deflate() will begin to complete the compressed output stream. However depending on how -much output space is provided, deflate() may have to be called several times until it -has provided the complete compressed stream, even after it has consumed all of the input. The flush -parameter must continue to be Z_FINISH for those subsequent calls. -

    -There are other values of the flush parameter that are used in more advanced applications. You can -force deflate() to produce a burst of output that encodes all of the input data provided -so far, even if it wouldn't have otherwise, for example to control data latency on a link with -compressed data. You can also ask that deflate() do that as well as erase any history up to -that point so that what follows can be decompressed independently, for example for random access -applications. Both requests will degrade compression by an amount depending on how often such -requests are made. -

    -deflate() has a return value that can indicate errors, yet we do not check it here. Why -not? Well, it turns out that deflate() can do no wrong here. Let's go through -deflate()'s return values and dispense with them one by one. The possible values are -Z_OK, Z_STREAM_END, Z_STREAM_ERROR, or Z_BUF_ERROR. Z_OK -is, well, ok. Z_STREAM_END is also ok and will be returned for the last call of -deflate(). This is already guaranteed by calling deflate() with Z_FINISH -until it has no more output. Z_STREAM_ERROR is only possible if the stream is not -initialized properly, but we did initialize it properly. There is no harm in checking for -Z_STREAM_ERROR here, for example to check for the possibility that some -other part of the application inadvertently clobbered the memory containing the zlib state. -Z_BUF_ERROR will be explained further below, but -suffice it to say that this is simply an indication that deflate() could not consume -more input or produce more output. deflate() can be called again with more output space -or more available input, which it will be in this code. -

    
    -            ret = deflate(&strm, flush);    /* no bad return value */
    -            assert(ret != Z_STREAM_ERROR);  /* state not clobbered */
    -
    -Now we compute how much output deflate() provided on the last call, which is the -difference between how much space was provided before the call, and how much output space -is still available after the call. Then that data, if any, is written to the output file. -We can then reuse the output buffer for the next call of deflate(). Again if there -is a file i/o error, we call deflateEnd() before returning to avoid a memory leak. -
    
    -            have = CHUNK - strm.avail_out;
    -            if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
    -                (void)deflateEnd(&strm);
    -                return Z_ERRNO;
    -            }
    -
    -The inner do-loop is repeated until the last deflate() call fails to fill the -provided output buffer. Then we know that deflate() has done as much as it can with -the provided input, and that all of that input has been consumed. We can then fall out of this -loop and reuse the input buffer. -

    -The way we tell that deflate() has no more output is by seeing that it did not fill -the output buffer, leaving avail_out greater than zero. However suppose that -deflate() has no more output, but just so happened to exactly fill the output buffer! -avail_out is zero, and we can't tell that deflate() has done all it can. -As far as we know, deflate() -has more output for us. So we call it again. But now deflate() produces no output -at all, and avail_out remains unchanged as CHUNK. That deflate() call -wasn't able to do anything, either consume input or produce output, and so it returns -Z_BUF_ERROR. (See, I told you I'd cover this later.) However this is not a problem at -all. Now we finally have the desired indication that deflate() is really done, -and so we drop out of the inner loop to provide more input to deflate(). -

    -With flush set to Z_FINISH, this final set of deflate() calls will -complete the output stream. Once that is done, subsequent calls of deflate() would return -Z_STREAM_ERROR if the flush parameter is not Z_FINISH, and do no more processing -until the state is reinitialized. -

    -Some applications of zlib have two loops that call deflate() -instead of the single inner loop we have here. The first loop would call -without flushing and feed all of the data to deflate(). The second loop would call -deflate() with no more -data and the Z_FINISH parameter to complete the process. As you can see from this -example, that can be avoided by simply keeping track of the current flush state. -

    
    -        } while (strm.avail_out == 0);
    -        assert(strm.avail_in == 0);     /* all input will be used */
    -
    -Now we check to see if we have already processed all of the input file. That information was -saved in the flush variable, so we see if that was set to Z_FINISH. If so, -then we're done and we fall out of the outer loop. We're guaranteed to get Z_STREAM_END -from the last deflate() call, since we ran it until the last chunk of input was -consumed and all of the output was generated. -
    
    -        /* done when last data in file processed */
    -    } while (flush != Z_FINISH);
    -    assert(ret == Z_STREAM_END);        /* stream will be complete */
    -
    -The process is complete, but we still need to deallocate the state to avoid a memory leak -(or rather more like a memory hemorrhage if you didn't do this). Then -finally we can return with a happy return value. -
    
    -    /* clean up and return */
    -    (void)deflateEnd(&strm);
    -    return Z_OK;
    -}
    -
    -Now we do the same thing for decompression in the inf() routine. inf() -decompresses what is hopefully a valid zlib stream from the input file and writes the -uncompressed data to the output file. Much of the discussion above for def() -applies to inf() as well, so the discussion here will focus on the differences between -the two. -
    
    -/* Decompress from file source to file dest until stream ends or EOF.
    -   inf() returns Z_OK on success, Z_MEM_ERROR if memory could not be
    -   allocated for processing, Z_DATA_ERROR if the deflate data is
    -   invalid or incomplete, Z_VERSION_ERROR if the version of zlib.h and
    -   the version of the library linked do not match, or Z_ERRNO if there
    -   is an error reading or writing the files. */
    -int inf(FILE *source, FILE *dest)
    -{
    -
    -The local variables have the same functionality as they do for def(). The -only difference is that there is no flush variable, since inflate() -can tell from the zlib stream itself when the stream is complete. -
    
    -    int ret;
    -    unsigned have;
    -    z_stream strm;
    -    unsigned char in[CHUNK];
    -    unsigned char out[CHUNK];
    -
    -The initialization of the state is the same, except that there is no compression level, -of course, and two more elements of the structure are initialized. avail_in -and next_in must be initialized before calling inflateInit(). This -is because the application has the option to provide the start of the zlib stream in -order for inflateInit() to have access to information about the compression -method to aid in memory allocation. In the current implementation of zlib -(up through versions 1.2.x), the method-dependent memory allocations are deferred to the first call of -inflate() anyway. However those fields must be initialized since later versions -of zlib that provide more compression methods may take advantage of this interface. -In any case, no decompression is performed by inflateInit(), so the -avail_out and next_out fields do not need to be initialized before calling. -

    -Here avail_in is set to zero and next_in is set to Z_NULL to -indicate that no input data is being provided. -

    
    -    /* allocate inflate state */
    -    strm.zalloc = Z_NULL;
    -    strm.zfree = Z_NULL;
    -    strm.opaque = Z_NULL;
    -    strm.avail_in = 0;
    -    strm.next_in = Z_NULL;
    -    ret = inflateInit(&strm);
    -    if (ret != Z_OK)
    -        return ret;
    -
    -The outer do-loop decompresses input until inflate() indicates -that it has reached the end of the compressed data and has produced all of the uncompressed -output. This is in contrast to def() which processes all of the input file. -If end-of-file is reached before the compressed data self-terminates, then the compressed -data is incomplete and an error is returned. -
    
    -    /* decompress until deflate stream ends or end of file */
    -    do {
    -
    -We read input data and set the strm structure accordingly. If we've reached the -end of the input file, then we leave the outer loop and report an error, since the -compressed data is incomplete. Note that we may read more data than is eventually consumed -by inflate(), if the input file continues past the zlib stream. -For applications where zlib streams are embedded in other data, this routine would -need to be modified to return the unused data, or at least indicate how much of the input -data was not used, so the application would know where to pick up after the zlib stream. -
    
    -        strm.avail_in = fread(in, 1, CHUNK, source);
    -        if (ferror(source)) {
    -            (void)inflateEnd(&strm);
    -            return Z_ERRNO;
    -        }
    -        if (strm.avail_in == 0)
    -            break;
    -        strm.next_in = in;
    -
    -The inner do-loop has the same function it did in def(), which is to -keep calling inflate() until has generated all of the output it can with the -provided input. -
    
    -        /* run inflate() on input until output buffer not full */
    -        do {
    -
    -Just like in def(), the same output space is provided for each call of inflate(). -
    
    -            strm.avail_out = CHUNK;
    -            strm.next_out = out;
    -
    -Now we run the decompression engine itself. There is no need to adjust the flush parameter, since -the zlib format is self-terminating. The main difference here is that there are -return values that we need to pay attention to. Z_DATA_ERROR -indicates that inflate() detected an error in the zlib compressed data format, -which means that either the data is not a zlib stream to begin with, or that the data was -corrupted somewhere along the way since it was compressed. The other error to be processed is -Z_MEM_ERROR, which can occur since memory allocation is deferred until inflate() -needs it, unlike deflate(), whose memory is allocated at the start by deflateInit(). -

    -Advanced applications may use -deflateSetDictionary() to prime deflate() with a set of likely data to improve the -first 32K or so of compression. This is noted in the zlib header, so inflate() -requests that that dictionary be provided before it can start to decompress. Without the dictionary, -correct decompression is not possible. For this routine, we have no idea what the dictionary is, -so the Z_NEED_DICT indication is converted to a Z_DATA_ERROR. -

    -inflate() can also return Z_STREAM_ERROR, which should not be possible here, -but could be checked for as noted above for def(). Z_BUF_ERROR does not need to be -checked for here, for the same reasons noted for def(). Z_STREAM_END will be -checked for later. -

    
    -            ret = inflate(&strm, Z_NO_FLUSH);
    -            assert(ret != Z_STREAM_ERROR);  /* state not clobbered */
    -            switch (ret) {
    -            case Z_NEED_DICT:
    -                ret = Z_DATA_ERROR;     /* and fall through */
    -            case Z_DATA_ERROR:
    -            case Z_MEM_ERROR:
    -                (void)inflateEnd(&strm);
    -                return ret;
    -            }
    -
    -The output of inflate() is handled identically to that of deflate(). -
    
    -            have = CHUNK - strm.avail_out;
    -            if (fwrite(out, 1, have, dest) != have || ferror(dest)) {
    -                (void)inflateEnd(&strm);
    -                return Z_ERRNO;
    -            }
    -
    -The inner do-loop ends when inflate() has no more output as indicated -by not filling the output buffer, just as for deflate(). In this case, we cannot -assert that strm.avail_in will be zero, since the deflate stream may end before the file -does. -
    
    -        } while (strm.avail_out == 0);
    -
    -The outer do-loop ends when inflate() reports that it has reached the -end of the input zlib stream, has completed the decompression and integrity -check, and has provided all of the output. This is indicated by the inflate() -return value Z_STREAM_END. The inner loop is guaranteed to leave ret -equal to Z_STREAM_END if the last chunk of the input file read contained the end -of the zlib stream. So if the return value is not Z_STREAM_END, the -loop continues to read more input. -
    
    -        /* done when inflate() says it's done */
    -    } while (ret != Z_STREAM_END);
    -
    -At this point, decompression successfully completed, or we broke out of the loop due to no -more data being available from the input file. If the last inflate() return value -is not Z_STREAM_END, then the zlib stream was incomplete and a data error -is returned. Otherwise, we return with a happy return value. Of course, inflateEnd() -is called first to avoid a memory leak. -
    
    -    /* clean up and return */
    -    (void)inflateEnd(&strm);
    -    return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR;
    -}
    -
    -That ends the routines that directly use zlib. The following routines make this -a command-line program by running data through the above routines from stdin to -stdout, and handling any errors reported by def() or inf(). -

    -zerr() is used to interpret the possible error codes from def() -and inf(), as detailed in their comments above, and print out an error message. -Note that these are only a subset of the possible return values from deflate() -and inflate(). -

    
    -/* report a zlib or i/o error */
    -void zerr(int ret)
    -{
    -    fputs("zpipe: ", stderr);
    -    switch (ret) {
    -    case Z_ERRNO:
    -        if (ferror(stdin))
    -            fputs("error reading stdin\n", stderr);
    -        if (ferror(stdout))
    -            fputs("error writing stdout\n", stderr);
    -        break;
    -    case Z_STREAM_ERROR:
    -        fputs("invalid compression level\n", stderr);
    -        break;
    -    case Z_DATA_ERROR:
    -        fputs("invalid or incomplete deflate data\n", stderr);
    -        break;
    -    case Z_MEM_ERROR:
    -        fputs("out of memory\n", stderr);
    -        break;
    -    case Z_VERSION_ERROR:
    -        fputs("zlib version mismatch!\n", stderr);
    -    }
    -}
    -
    -Here is the main() routine used to test def() and inf(). The -zpipe command is simply a compression pipe from stdin to stdout, if -no arguments are given, or it is a decompression pipe if zpipe -d is used. If any other -arguments are provided, no compression or decompression is performed. Instead a usage -message is displayed. Examples are zpipe < foo.txt > foo.txt.z to compress, and -zpipe -d < foo.txt.z > foo.txt to decompress. -
    
    -/* compress or decompress from stdin to stdout */
    -int main(int argc, char **argv)
    -{
    -    int ret;
    -
    -    /* avoid end-of-line conversions */
    -    SET_BINARY_MODE(stdin);
    -    SET_BINARY_MODE(stdout);
    -
    -    /* do compression if no arguments */
    -    if (argc == 1) {
    -        ret = def(stdin, stdout, Z_DEFAULT_COMPRESSION);
    -        if (ret != Z_OK)
    -            zerr(ret);
    -        return ret;
    -    }
    -
    -    /* do decompression if -d specified */
    -    else if (argc == 2 && strcmp(argv[1], "-d") == 0) {
    -        ret = inf(stdin, stdout);
    -        if (ret != Z_OK)
    -            zerr(ret);
    -        return ret;
    -    }
    -
    -    /* otherwise, report usage */
    -    else {
    -        fputs("zpipe usage: zpipe [-d] < source > dest\n", stderr);
    -        return 1;
    -    }
    -}
    -
    -
    -Copyright (c) 2004, 2005 by Mark Adler
    Last modified 11 December 2005
    - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/zpipe.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/zpipe.c deleted file mode 100644 index 83535d1..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/zpipe.c +++ /dev/null @@ -1,205 +0,0 @@ -/* zpipe.c: example of proper use of zlib's inflate() and deflate() - Not copyrighted -- provided to the public domain - Version 1.4 11 December 2005 Mark Adler */ - -/* Version history: - 1.0 30 Oct 2004 First version - 1.1 8 Nov 2004 Add void casting for unused return values - Use switch statement for inflate() return values - 1.2 9 Nov 2004 Add assertions to document zlib guarantees - 1.3 6 Apr 2005 Remove incorrect assertion in inf() - 1.4 11 Dec 2005 Add hack to avoid MSDOS end-of-line conversions - Avoid some compiler warnings for input and output buffers - */ - -#include -#include -#include -#include "zlib.h" - -#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__) -# include -# include -# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY) -#else -# define SET_BINARY_MODE(file) -#endif - -#define CHUNK 16384 - -/* Compress from file source to file dest until EOF on source. - def() returns Z_OK on success, Z_MEM_ERROR if memory could not be - allocated for processing, Z_STREAM_ERROR if an invalid compression - level is supplied, Z_VERSION_ERROR if the version of zlib.h and the - version of the library linked do not match, or Z_ERRNO if there is - an error reading or writing the files. */ -int def(FILE *source, FILE *dest, int level) -{ - int ret, flush; - unsigned have; - z_stream strm; - unsigned char in[CHUNK]; - unsigned char out[CHUNK]; - - /* allocate deflate state */ - strm.zalloc = Z_NULL; - strm.zfree = Z_NULL; - strm.opaque = Z_NULL; - ret = deflateInit(&strm, level); - if (ret != Z_OK) - return ret; - - /* compress until end of file */ - do { - strm.avail_in = fread(in, 1, CHUNK, source); - if (ferror(source)) { - (void)deflateEnd(&strm); - return Z_ERRNO; - } - flush = feof(source) ? Z_FINISH : Z_NO_FLUSH; - strm.next_in = in; - - /* run deflate() on input until output buffer not full, finish - compression if all of source has been read in */ - do { - strm.avail_out = CHUNK; - strm.next_out = out; - ret = deflate(&strm, flush); /* no bad return value */ - assert(ret != Z_STREAM_ERROR); /* state not clobbered */ - have = CHUNK - strm.avail_out; - if (fwrite(out, 1, have, dest) != have || ferror(dest)) { - (void)deflateEnd(&strm); - return Z_ERRNO; - } - } while (strm.avail_out == 0); - assert(strm.avail_in == 0); /* all input will be used */ - - /* done when last data in file processed */ - } while (flush != Z_FINISH); - assert(ret == Z_STREAM_END); /* stream will be complete */ - - /* clean up and return */ - (void)deflateEnd(&strm); - return Z_OK; -} - -/* Decompress from file source to file dest until stream ends or EOF. - inf() returns Z_OK on success, Z_MEM_ERROR if memory could not be - allocated for processing, Z_DATA_ERROR if the deflate data is - invalid or incomplete, Z_VERSION_ERROR if the version of zlib.h and - the version of the library linked do not match, or Z_ERRNO if there - is an error reading or writing the files. */ -int inf(FILE *source, FILE *dest) -{ - int ret; - unsigned have; - z_stream strm; - unsigned char in[CHUNK]; - unsigned char out[CHUNK]; - - /* allocate inflate state */ - strm.zalloc = Z_NULL; - strm.zfree = Z_NULL; - strm.opaque = Z_NULL; - strm.avail_in = 0; - strm.next_in = Z_NULL; - ret = inflateInit(&strm); - if (ret != Z_OK) - return ret; - - /* decompress until deflate stream ends or end of file */ - do { - strm.avail_in = fread(in, 1, CHUNK, source); - if (ferror(source)) { - (void)inflateEnd(&strm); - return Z_ERRNO; - } - if (strm.avail_in == 0) - break; - strm.next_in = in; - - /* run inflate() on input until output buffer not full */ - do { - strm.avail_out = CHUNK; - strm.next_out = out; - ret = inflate(&strm, Z_NO_FLUSH); - assert(ret != Z_STREAM_ERROR); /* state not clobbered */ - switch (ret) { - case Z_NEED_DICT: - ret = Z_DATA_ERROR; /* and fall through */ - case Z_DATA_ERROR: - case Z_MEM_ERROR: - (void)inflateEnd(&strm); - return ret; - } - have = CHUNK - strm.avail_out; - if (fwrite(out, 1, have, dest) != have || ferror(dest)) { - (void)inflateEnd(&strm); - return Z_ERRNO; - } - } while (strm.avail_out == 0); - - /* done when inflate() says it's done */ - } while (ret != Z_STREAM_END); - - /* clean up and return */ - (void)inflateEnd(&strm); - return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR; -} - -/* report a zlib or i/o error */ -void zerr(int ret) -{ - fputs("zpipe: ", stderr); - switch (ret) { - case Z_ERRNO: - if (ferror(stdin)) - fputs("error reading stdin\n", stderr); - if (ferror(stdout)) - fputs("error writing stdout\n", stderr); - break; - case Z_STREAM_ERROR: - fputs("invalid compression level\n", stderr); - break; - case Z_DATA_ERROR: - fputs("invalid or incomplete deflate data\n", stderr); - break; - case Z_MEM_ERROR: - fputs("out of memory\n", stderr); - break; - case Z_VERSION_ERROR: - fputs("zlib version mismatch!\n", stderr); - } -} - -/* compress or decompress from stdin to stdout */ -int main(int argc, char **argv) -{ - int ret; - - /* avoid end-of-line conversions */ - SET_BINARY_MODE(stdin); - SET_BINARY_MODE(stdout); - - /* do compression if no arguments */ - if (argc == 1) { - ret = def(stdin, stdout, Z_DEFAULT_COMPRESSION); - if (ret != Z_OK) - zerr(ret); - return ret; - } - - /* do decompression if -d specified */ - else if (argc == 2 && strcmp(argv[1], "-d") == 0) { - ret = inf(stdin, stdout); - if (ret != Z_OK) - zerr(ret); - return ret; - } - - /* otherwise, report usage */ - else { - fputs("zpipe usage: zpipe [-d] < source > dest\n", stderr); - return 1; - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/zran.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/zran.c deleted file mode 100644 index f279db7..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/zran.c +++ /dev/null @@ -1,479 +0,0 @@ -/* zran.c -- example of zlib/gzip stream indexing and random access - * Copyright (C) 2005, 2012, 2018 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - * Version 1.2 14 Oct 2018 Mark Adler */ - -/* Version History: - 1.0 29 May 2005 First version - 1.1 29 Sep 2012 Fix memory reallocation error - 1.2 14 Oct 2018 Handle gzip streams with multiple members - Add a header file to facilitate usage in applications - */ - -/* Illustrate the use of Z_BLOCK, inflatePrime(), and inflateSetDictionary() - for random access of a compressed file. A file containing a zlib or gzip - stream is provided on the command line. The compressed stream is decoded in - its entirety, and an index built with access points about every SPAN bytes - in the uncompressed output. The compressed file is left open, and can then - be read randomly, having to decompress on the average SPAN/2 uncompressed - bytes before getting to the desired block of data. - - An access point can be created at the start of any deflate block, by saving - the starting file offset and bit of that block, and the 32K bytes of - uncompressed data that precede that block. Also the uncompressed offset of - that block is saved to provide a referece for locating a desired starting - point in the uncompressed stream. deflate_index_build() works by - decompressing the input zlib or gzip stream a block at a time, and at the - end of each block deciding if enough uncompressed data has gone by to - justify the creation of a new access point. If so, that point is saved in a - data structure that grows as needed to accommodate the points. - - To use the index, an offset in the uncompressed data is provided, for which - the latest access point at or preceding that offset is located in the index. - The input file is positioned to the specified location in the index, and if - necessary the first few bits of the compressed data is read from the file. - inflate is initialized with those bits and the 32K of uncompressed data, and - the decompression then proceeds until the desired offset in the file is - reached. Then the decompression continues to read the desired uncompressed - data from the file. - - Another approach would be to generate the index on demand. In that case, - requests for random access reads from the compressed data would try to use - the index, but if a read far enough past the end of the index is required, - then further index entries would be generated and added. - - There is some fair bit of overhead to starting inflation for the random - access, mainly copying the 32K byte dictionary. So if small pieces of the - file are being accessed, it would make sense to implement a cache to hold - some lookahead and avoid many calls to deflate_index_extract() for small - lengths. - - Another way to build an index would be to use inflateCopy(). That would - not be constrained to have access points at block boundaries, but requires - more memory per access point, and also cannot be saved to file due to the - use of pointers in the state. The approach here allows for storage of the - index in a file. - */ - -#include -#include -#include -#include "zlib.h" -#include "zran.h" - -#define WINSIZE 32768U /* sliding window size */ -#define CHUNK 16384 /* file input buffer size */ - -/* Access point entry. */ -struct point { - off_t out; /* corresponding offset in uncompressed data */ - off_t in; /* offset in input file of first full byte */ - int bits; /* number of bits (1-7) from byte at in-1, or 0 */ - unsigned char window[WINSIZE]; /* preceding 32K of uncompressed data */ -}; - -/* See comments in zran.h. */ -void deflate_index_free(struct deflate_index *index) -{ - if (index != NULL) { - free(index->list); - free(index); - } -} - -/* Add an entry to the access point list. If out of memory, deallocate the - existing list and return NULL. index->gzip is the allocated size of the - index in point entries, until it is time for deflate_index_build() to - return, at which point gzip is set to indicate a gzip file or not. - */ -static struct deflate_index *addpoint(struct deflate_index *index, int bits, - off_t in, off_t out, unsigned left, - unsigned char *window) -{ - struct point *next; - - /* if list is empty, create it (start with eight points) */ - if (index == NULL) { - index = malloc(sizeof(struct deflate_index)); - if (index == NULL) return NULL; - index->list = malloc(sizeof(struct point) << 3); - if (index->list == NULL) { - free(index); - return NULL; - } - index->gzip = 8; - index->have = 0; - } - - /* if list is full, make it bigger */ - else if (index->have == index->gzip) { - index->gzip <<= 1; - next = realloc(index->list, sizeof(struct point) * index->gzip); - if (next == NULL) { - deflate_index_free(index); - return NULL; - } - index->list = next; - } - - /* fill in entry and increment how many we have */ - next = (struct point *)(index->list) + index->have; - next->bits = bits; - next->in = in; - next->out = out; - if (left) - memcpy(next->window, window + WINSIZE - left, left); - if (left < WINSIZE) - memcpy(next->window + left, window, WINSIZE - left); - index->have++; - - /* return list, possibly reallocated */ - return index; -} - -/* See comments in zran.h. */ -int deflate_index_build(FILE *in, off_t span, struct deflate_index **built) -{ - int ret; - int gzip = 0; /* true if reading a gzip file */ - off_t totin, totout; /* our own total counters to avoid 4GB limit */ - off_t last; /* totout value of last access point */ - struct deflate_index *index; /* access points being generated */ - z_stream strm; - unsigned char input[CHUNK]; - unsigned char window[WINSIZE]; - - /* initialize inflate */ - strm.zalloc = Z_NULL; - strm.zfree = Z_NULL; - strm.opaque = Z_NULL; - strm.avail_in = 0; - strm.next_in = Z_NULL; - ret = inflateInit2(&strm, 47); /* automatic zlib or gzip decoding */ - if (ret != Z_OK) - return ret; - - /* inflate the input, maintain a sliding window, and build an index -- this - also validates the integrity of the compressed data using the check - information in the gzip or zlib stream */ - totin = totout = last = 0; - index = NULL; /* will be allocated by first addpoint() */ - strm.avail_out = 0; - do { - /* get some compressed data from input file */ - strm.avail_in = fread(input, 1, CHUNK, in); - if (ferror(in)) { - ret = Z_ERRNO; - goto deflate_index_build_error; - } - if (strm.avail_in == 0) { - ret = Z_DATA_ERROR; - goto deflate_index_build_error; - } - strm.next_in = input; - - /* check for a gzip stream */ - if (totin == 0 && strm.avail_in >= 3 && - input[0] == 31 && input[1] == 139 && input[2] == 8) - gzip = 1; - - /* process all of that, or until end of stream */ - do { - /* reset sliding window if necessary */ - if (strm.avail_out == 0) { - strm.avail_out = WINSIZE; - strm.next_out = window; - } - - /* inflate until out of input, output, or at end of block -- - update the total input and output counters */ - totin += strm.avail_in; - totout += strm.avail_out; - ret = inflate(&strm, Z_BLOCK); /* return at end of block */ - totin -= strm.avail_in; - totout -= strm.avail_out; - if (ret == Z_NEED_DICT) - ret = Z_DATA_ERROR; - if (ret == Z_MEM_ERROR || ret == Z_DATA_ERROR) - goto deflate_index_build_error; - if (ret == Z_STREAM_END) { - if (gzip && - (strm.avail_in || ungetc(getc(in), in) != EOF)) { - ret = inflateReset(&strm); - if (ret != Z_OK) - goto deflate_index_build_error; - continue; - } - break; - } - - /* if at end of block, consider adding an index entry (note that if - data_type indicates an end-of-block, then all of the - uncompressed data from that block has been delivered, and none - of the compressed data after that block has been consumed, - except for up to seven bits) -- the totout == 0 provides an - entry point after the zlib or gzip header, and assures that the - index always has at least one access point; we avoid creating an - access point after the last block by checking bit 6 of data_type - */ - if ((strm.data_type & 128) && !(strm.data_type & 64) && - (totout == 0 || totout - last > span)) { - index = addpoint(index, strm.data_type & 7, totin, - totout, strm.avail_out, window); - if (index == NULL) { - ret = Z_MEM_ERROR; - goto deflate_index_build_error; - } - last = totout; - } - } while (strm.avail_in != 0); - } while (ret != Z_STREAM_END); - - /* clean up and return index (release unused entries in list) */ - (void)inflateEnd(&strm); - index->list = realloc(index->list, sizeof(struct point) * index->have); - index->gzip = gzip; - index->length = totout; - *built = index; - return index->have; - - /* return error */ - deflate_index_build_error: - (void)inflateEnd(&strm); - deflate_index_free(index); - return ret; -} - -/* See comments in zran.h. */ -int deflate_index_extract(FILE *in, struct deflate_index *index, off_t offset, - unsigned char *buf, int len) -{ - int ret, skip; - z_stream strm; - struct point *here; - unsigned char input[CHUNK]; - unsigned char discard[WINSIZE]; - - /* proceed only if something reasonable to do */ - if (len < 0) - return 0; - - /* find where in stream to start */ - here = index->list; - ret = index->have; - while (--ret && here[1].out <= offset) - here++; - - /* initialize file and inflate state to start there */ - strm.zalloc = Z_NULL; - strm.zfree = Z_NULL; - strm.opaque = Z_NULL; - strm.avail_in = 0; - strm.next_in = Z_NULL; - ret = inflateInit2(&strm, -15); /* raw inflate */ - if (ret != Z_OK) - return ret; - ret = fseeko(in, here->in - (here->bits ? 1 : 0), SEEK_SET); - if (ret == -1) - goto deflate_index_extract_ret; - if (here->bits) { - ret = getc(in); - if (ret == -1) { - ret = ferror(in) ? Z_ERRNO : Z_DATA_ERROR; - goto deflate_index_extract_ret; - } - (void)inflatePrime(&strm, here->bits, ret >> (8 - here->bits)); - } - (void)inflateSetDictionary(&strm, here->window, WINSIZE); - - /* skip uncompressed bytes until offset reached, then satisfy request */ - offset -= here->out; - strm.avail_in = 0; - skip = 1; /* while skipping to offset */ - do { - /* define where to put uncompressed data, and how much */ - if (offset > WINSIZE) { /* skip WINSIZE bytes */ - strm.avail_out = WINSIZE; - strm.next_out = discard; - offset -= WINSIZE; - } - else if (offset > 0) { /* last skip */ - strm.avail_out = (unsigned)offset; - strm.next_out = discard; - offset = 0; - } - else if (skip) { /* at offset now */ - strm.avail_out = len; - strm.next_out = buf; - skip = 0; /* only do this once */ - } - - /* uncompress until avail_out filled, or end of stream */ - do { - if (strm.avail_in == 0) { - strm.avail_in = fread(input, 1, CHUNK, in); - if (ferror(in)) { - ret = Z_ERRNO; - goto deflate_index_extract_ret; - } - if (strm.avail_in == 0) { - ret = Z_DATA_ERROR; - goto deflate_index_extract_ret; - } - strm.next_in = input; - } - ret = inflate(&strm, Z_NO_FLUSH); /* normal inflate */ - if (ret == Z_NEED_DICT) - ret = Z_DATA_ERROR; - if (ret == Z_MEM_ERROR || ret == Z_DATA_ERROR) - goto deflate_index_extract_ret; - if (ret == Z_STREAM_END) { - /* the raw deflate stream has ended */ - if (index->gzip == 0) - /* this is a zlib stream that has ended -- done */ - break; - - /* near the end of a gzip member, which might be followed by - another gzip member -- skip the gzip trailer and see if - there is more input after it */ - if (strm.avail_in < 8) { - fseeko(in, 8 - strm.avail_in, SEEK_CUR); - strm.avail_in = 0; - } - else { - strm.avail_in -= 8; - strm.next_in += 8; - } - if (strm.avail_in == 0 && ungetc(getc(in), in) == EOF) - /* the input ended after the gzip trailer -- done */ - break; - - /* there is more input, so another gzip member should follow -- - validate and skip the gzip header */ - ret = inflateReset2(&strm, 31); - if (ret != Z_OK) - goto deflate_index_extract_ret; - do { - if (strm.avail_in == 0) { - strm.avail_in = fread(input, 1, CHUNK, in); - if (ferror(in)) { - ret = Z_ERRNO; - goto deflate_index_extract_ret; - } - if (strm.avail_in == 0) { - ret = Z_DATA_ERROR; - goto deflate_index_extract_ret; - } - strm.next_in = input; - } - ret = inflate(&strm, Z_BLOCK); - if (ret == Z_MEM_ERROR || ret == Z_DATA_ERROR) - goto deflate_index_extract_ret; - } while ((strm.data_type & 128) == 0); - - /* set up to continue decompression of the raw deflate stream - that follows the gzip header */ - ret = inflateReset2(&strm, -15); - if (ret != Z_OK) - goto deflate_index_extract_ret; - } - - /* continue to process the available input before reading more */ - } while (strm.avail_out != 0); - - if (ret == Z_STREAM_END) - /* reached the end of the compressed data -- return the data that - was available, possibly less than requested */ - break; - - /* do until offset reached and requested data read */ - } while (skip); - - /* compute the number of uncompressed bytes read after the offset */ - ret = skip ? 0 : len - strm.avail_out; - - /* clean up and return the bytes read, or the negative error */ - deflate_index_extract_ret: - (void)inflateEnd(&strm); - return ret; -} - -#ifdef TEST - -#define SPAN 1048576L /* desired distance between access points */ -#define LEN 16384 /* number of bytes to extract */ - -/* Demonstrate the use of deflate_index_build() and deflate_index_extract() by - processing the file provided on the command line, and extracting LEN bytes - from 2/3rds of the way through the uncompressed output, writing that to - stdout. An offset can be provided as the second argument, in which case the - data is extracted from there instead. */ -int main(int argc, char **argv) -{ - int len; - off_t offset = -1; - FILE *in; - struct deflate_index *index = NULL; - unsigned char buf[LEN]; - - /* open input file */ - if (argc < 2 || argc > 3) { - fprintf(stderr, "usage: zran file.gz [offset]\n"); - return 1; - } - in = fopen(argv[1], "rb"); - if (in == NULL) { - fprintf(stderr, "zran: could not open %s for reading\n", argv[1]); - return 1; - } - - /* get optional offset */ - if (argc == 3) { - char *end; - offset = strtoll(argv[2], &end, 10); - if (*end || offset < 0) { - fprintf(stderr, "zran: %s is not a valid offset\n", argv[2]); - return 1; - } - } - - /* build index */ - len = deflate_index_build(in, SPAN, &index); - if (len < 0) { - fclose(in); - switch (len) { - case Z_MEM_ERROR: - fprintf(stderr, "zran: out of memory\n"); - break; - case Z_DATA_ERROR: - fprintf(stderr, "zran: compressed data error in %s\n", argv[1]); - break; - case Z_ERRNO: - fprintf(stderr, "zran: read error on %s\n", argv[1]); - break; - default: - fprintf(stderr, "zran: error %d while building index\n", len); - } - return 1; - } - fprintf(stderr, "zran: built index with %d access points\n", len); - - /* use index by reading some bytes from an arbitrary offset */ - if (offset == -1) - offset = (index->length << 1) / 3; - len = deflate_index_extract(in, index, offset, buf, LEN); - if (len < 0) - fprintf(stderr, "zran: extraction failed: %s error\n", - len == Z_MEM_ERROR ? "out of memory" : "input corrupted"); - else { - fwrite(buf, 1, len, stdout); - fprintf(stderr, "zran: extracted %d bytes at %llu\n", len, offset); - } - - /* clean up and exit */ - deflate_index_free(index); - fclose(in); - return 0; -} - -#endif diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/zran.h b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/zran.h deleted file mode 100644 index 2314125..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/examples/zran.h +++ /dev/null @@ -1,40 +0,0 @@ -/* zran.h -- example of zlib/gzip stream indexing and random access - * Copyright (C) 2005, 2012, 2018 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - * Version 1.2 14 Oct 2018 Mark Adler */ - -#include -#include "zlib.h" - -/* Access point list. */ -struct deflate_index { - int have; /* number of list entries */ - int gzip; /* 1 if the index is of a gzip file, 0 if it is of a - zlib stream */ - off_t length; /* total length of uncompressed data */ - void *list; /* allocated list of entries */ -}; - -/* Make one entire pass through a zlib or gzip compressed stream and build an - index, with access points about every span bytes of uncompressed output. - gzip files with multiple members are indexed in their entirety. span should - be chosen to balance the speed of random access against the memory - requirements of the list, about 32K bytes per access point. The return value - is the number of access points on success (>= 1), Z_MEM_ERROR for out of - memory, Z_DATA_ERROR for an error in the input file, or Z_ERRNO for a file - read error. On success, *built points to the resulting index. */ -int deflate_index_build(FILE *in, off_t span, struct deflate_index **built); - -/* Deallocate an index built by deflate_index_build() */ -void deflate_index_free(struct deflate_index *index); - -/* Use the index to read len bytes from offset into buf. Return bytes read or - negative for error (Z_DATA_ERROR or Z_MEM_ERROR). If data is requested past - the end of the uncompressed data, then deflate_index_extract() will return a - value less than len, indicating how much was actually read into buf. This - function should not return a data error unless the file was modified since - the index was generated, since deflate_index_build() validated all of the - input. deflate_index_extract() will return Z_ERRNO if there is an error on - reading or seeking the input file. */ -int deflate_index_extract(FILE *in, struct deflate_index *index, off_t offset, - unsigned char *buf, int len); diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/gzclose.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/gzclose.c deleted file mode 100644 index caeb99a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/gzclose.c +++ /dev/null @@ -1,25 +0,0 @@ -/* gzclose.c -- zlib gzclose() function - * Copyright (C) 2004, 2010 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "gzguts.h" - -/* gzclose() is in a separate file so that it is linked in only if it is used. - That way the other gzclose functions can be used instead to avoid linking in - unneeded compression or decompression routines. */ -int ZEXPORT gzclose(file) - gzFile file; -{ -#ifndef NO_GZCOMPRESS - gz_statep state; - - if (file == NULL) - return Z_STREAM_ERROR; - state = (gz_statep)file; - - return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file); -#else - return gzclose_r(file); -#endif -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/gzguts.h b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/gzguts.h deleted file mode 100644 index 57faf37..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/gzguts.h +++ /dev/null @@ -1,219 +0,0 @@ -/* gzguts.h -- zlib internal header definitions for gz* operations - * Copyright (C) 2004-2019 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#ifdef _LARGEFILE64_SOURCE -# ifndef _LARGEFILE_SOURCE -# define _LARGEFILE_SOURCE 1 -# endif -# ifdef _FILE_OFFSET_BITS -# undef _FILE_OFFSET_BITS -# endif -#endif - -#ifdef HAVE_HIDDEN -# define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) -#else -# define ZLIB_INTERNAL -#endif - -#include -#include "zlib.h" -#ifdef STDC -# include -# include -# include -#endif - -#ifndef _POSIX_SOURCE -# define _POSIX_SOURCE -#endif -#include - -#ifdef _WIN32 -# include -#endif - -#if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32) -# include -#endif - -#if defined(_WIN32) -# define WIDECHAR -#endif - -#ifdef WINAPI_FAMILY -# define open _open -# define read _read -# define write _write -# define close _close -#endif - -#ifdef NO_DEFLATE /* for compatibility with old definition */ -# define NO_GZCOMPRESS -#endif - -#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) -# ifndef HAVE_VSNPRINTF -# define HAVE_VSNPRINTF -# endif -#endif - -#if defined(__CYGWIN__) -# ifndef HAVE_VSNPRINTF -# define HAVE_VSNPRINTF -# endif -#endif - -#if defined(MSDOS) && defined(__BORLANDC__) && (BORLANDC > 0x410) -# ifndef HAVE_VSNPRINTF -# define HAVE_VSNPRINTF -# endif -#endif - -#ifndef HAVE_VSNPRINTF -# ifdef MSDOS -/* vsnprintf may exist on some MS-DOS compilers (DJGPP?), - but for now we just assume it doesn't. */ -# define NO_vsnprintf -# endif -# ifdef __TURBOC__ -# define NO_vsnprintf -# endif -# ifdef WIN32 -/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ -# if !defined(vsnprintf) && !defined(NO_vsnprintf) -# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 ) -# define vsnprintf _vsnprintf -# endif -# endif -# endif -# ifdef __SASC -# define NO_vsnprintf -# endif -# ifdef VMS -# define NO_vsnprintf -# endif -# ifdef __OS400__ -# define NO_vsnprintf -# endif -# ifdef __MVS__ -# define NO_vsnprintf -# endif -#endif - -/* unlike snprintf (which is required in C99), _snprintf does not guarantee - null termination of the result -- however this is only used in gzlib.c where - the result is assured to fit in the space provided */ -#if defined(_MSC_VER) && _MSC_VER < 1900 -# define snprintf _snprintf -#endif - -#ifndef local -# define local static -#endif -/* since "static" is used to mean two completely different things in C, we - define "local" for the non-static meaning of "static", for readability - (compile with -Dlocal if your debugger can't find static symbols) */ - -/* gz* functions always use library allocation functions */ -#ifndef STDC - extern voidp malloc OF((uInt size)); - extern void free OF((voidpf ptr)); -#endif - -/* get errno and strerror definition */ -#if defined UNDER_CE -# include -# define zstrerror() gz_strwinerror((DWORD)GetLastError()) -#else -# ifndef NO_STRERROR -# include -# define zstrerror() strerror(errno) -# else -# define zstrerror() "stdio error (consult errno)" -# endif -#endif - -/* provide prototypes for these when building zlib without LFS */ -#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); - ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); -#endif - -/* default memLevel */ -#if MAX_MEM_LEVEL >= 8 -# define DEF_MEM_LEVEL 8 -#else -# define DEF_MEM_LEVEL MAX_MEM_LEVEL -#endif - -/* default i/o buffer size -- double this for output when reading (this and - twice this must be able to fit in an unsigned type) */ -#define GZBUFSIZE 8192 - -/* gzip modes, also provide a little integrity check on the passed structure */ -#define GZ_NONE 0 -#define GZ_READ 7247 -#define GZ_WRITE 31153 -#define GZ_APPEND 1 /* mode set to GZ_WRITE after the file is opened */ - -/* values for gz_state how */ -#define LOOK 0 /* look for a gzip header */ -#define COPY 1 /* copy input directly */ -#define GZIP 2 /* decompress a gzip stream */ - -/* internal gzip file state data structure */ -typedef struct { - /* exposed contents for gzgetc() macro */ - struct gzFile_s x; /* "x" for exposed */ - /* x.have: number of bytes available at x.next */ - /* x.next: next output data to deliver or write */ - /* x.pos: current position in uncompressed data */ - /* used for both reading and writing */ - int mode; /* see gzip modes above */ - int fd; /* file descriptor */ - char *path; /* path or fd for error messages */ - unsigned size; /* buffer size, zero if not allocated yet */ - unsigned want; /* requested buffer size, default is GZBUFSIZE */ - unsigned char *in; /* input buffer (double-sized when writing) */ - unsigned char *out; /* output buffer (double-sized when reading) */ - int direct; /* 0 if processing gzip, 1 if transparent */ - /* just for reading */ - int how; /* 0: get header, 1: copy, 2: decompress */ - z_off64_t start; /* where the gzip data started, for rewinding */ - int eof; /* true if end of input file reached */ - int past; /* true if read requested past end */ - /* just for writing */ - int level; /* compression level */ - int strategy; /* compression strategy */ - int reset; /* true if a reset is pending after a Z_FINISH */ - /* seek request */ - z_off64_t skip; /* amount to skip (already rewound if backwards) */ - int seek; /* true if seek request pending */ - /* error information */ - int err; /* error code */ - char *msg; /* error message */ - /* zlib inflate or deflate stream */ - z_stream strm; /* stream structure in-place (not a pointer) */ -} gz_state; -typedef gz_state FAR *gz_statep; - -/* shared functions */ -void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *)); -#if defined UNDER_CE -char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error)); -#endif - -/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t - value -- needed when comparing unsigned to z_off64_t, which is signed - (possible z_off64_t types off_t, off64_t, and long are all signed) */ -#ifdef INT_MAX -# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX) -#else -unsigned ZLIB_INTERNAL gz_intmax OF((void)); -# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) -#endif diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/gzlib.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/gzlib.c deleted file mode 100644 index dddaf26..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/gzlib.c +++ /dev/null @@ -1,639 +0,0 @@ -/* gzlib.c -- zlib functions common to reading and writing gzip files - * Copyright (C) 2004-2019 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "gzguts.h" - -#if defined(_WIN32) && !defined(__BORLANDC__) -# define LSEEK _lseeki64 -#else -#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 -# define LSEEK lseek64 -#else -# define LSEEK lseek -#endif -#endif - -/* Local functions */ -local void gz_reset OF((gz_statep)); -local gzFile gz_open OF((const void *, int, const char *)); - -#if defined UNDER_CE - -/* Map the Windows error number in ERROR to a locale-dependent error message - string and return a pointer to it. Typically, the values for ERROR come - from GetLastError. - - The string pointed to shall not be modified by the application, but may be - overwritten by a subsequent call to gz_strwinerror - - The gz_strwinerror function does not change the current setting of - GetLastError. */ -char ZLIB_INTERNAL *gz_strwinerror (error) - DWORD error; -{ - static char buf[1024]; - - wchar_t *msgbuf; - DWORD lasterr = GetLastError(); - DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM - | FORMAT_MESSAGE_ALLOCATE_BUFFER, - NULL, - error, - 0, /* Default language */ - (LPVOID)&msgbuf, - 0, - NULL); - if (chars != 0) { - /* If there is an \r\n appended, zap it. */ - if (chars >= 2 - && msgbuf[chars - 2] == '\r' && msgbuf[chars - 1] == '\n') { - chars -= 2; - msgbuf[chars] = 0; - } - - if (chars > sizeof (buf) - 1) { - chars = sizeof (buf) - 1; - msgbuf[chars] = 0; - } - - wcstombs(buf, msgbuf, chars + 1); - LocalFree(msgbuf); - } - else { - sprintf(buf, "unknown win32 error (%ld)", error); - } - - SetLastError(lasterr); - return buf; -} - -#endif /* UNDER_CE */ - -/* Reset gzip file state */ -local void gz_reset(state) - gz_statep state; -{ - state->x.have = 0; /* no output data available */ - if (state->mode == GZ_READ) { /* for reading ... */ - state->eof = 0; /* not at end of file */ - state->past = 0; /* have not read past end yet */ - state->how = LOOK; /* look for gzip header */ - } - else /* for writing ... */ - state->reset = 0; /* no deflateReset pending */ - state->seek = 0; /* no seek request pending */ - gz_error(state, Z_OK, NULL); /* clear error */ - state->x.pos = 0; /* no uncompressed data yet */ - state->strm.avail_in = 0; /* no input data yet */ -} - -/* Open a gzip file either by name or file descriptor. */ -local gzFile gz_open(path, fd, mode) - const void *path; - int fd; - const char *mode; -{ - gz_statep state; - z_size_t len; - int oflag; -#ifdef O_CLOEXEC - int cloexec = 0; -#endif -#ifdef O_EXCL - int exclusive = 0; -#endif - - /* check input */ - if (path == NULL) - return NULL; - - /* allocate gzFile structure to return */ - state = (gz_statep)malloc(sizeof(gz_state)); - if (state == NULL) - return NULL; - state->size = 0; /* no buffers allocated yet */ - state->want = GZBUFSIZE; /* requested buffer size */ - state->msg = NULL; /* no error message yet */ - - /* interpret mode */ - state->mode = GZ_NONE; - state->level = Z_DEFAULT_COMPRESSION; - state->strategy = Z_DEFAULT_STRATEGY; - state->direct = 0; - while (*mode) { - if (*mode >= '0' && *mode <= '9') - state->level = *mode - '0'; - else - switch (*mode) { - case 'r': - state->mode = GZ_READ; - break; -#ifndef NO_GZCOMPRESS - case 'w': - state->mode = GZ_WRITE; - break; - case 'a': - state->mode = GZ_APPEND; - break; -#endif - case '+': /* can't read and write at the same time */ - free(state); - return NULL; - case 'b': /* ignore -- will request binary anyway */ - break; -#ifdef O_CLOEXEC - case 'e': - cloexec = 1; - break; -#endif -#ifdef O_EXCL - case 'x': - exclusive = 1; - break; -#endif - case 'f': - state->strategy = Z_FILTERED; - break; - case 'h': - state->strategy = Z_HUFFMAN_ONLY; - break; - case 'R': - state->strategy = Z_RLE; - break; - case 'F': - state->strategy = Z_FIXED; - break; - case 'T': - state->direct = 1; - break; - default: /* could consider as an error, but just ignore */ - ; - } - mode++; - } - - /* must provide an "r", "w", or "a" */ - if (state->mode == GZ_NONE) { - free(state); - return NULL; - } - - /* can't force transparent read */ - if (state->mode == GZ_READ) { - if (state->direct) { - free(state); - return NULL; - } - state->direct = 1; /* for empty file */ - } - - /* save the path name for error messages */ -#ifdef WIDECHAR - if (fd == -2) { - len = wcstombs(NULL, path, 0); - if (len == (z_size_t)-1) - len = 0; - } - else -#endif - len = strlen((const char *)path); - state->path = (char *)malloc(len + 1); - if (state->path == NULL) { - free(state); - return NULL; - } -#ifdef WIDECHAR - if (fd == -2) - if (len) - wcstombs(state->path, path, len + 1); - else - *(state->path) = 0; - else -#endif -#if !defined(NO_snprintf) && !defined(NO_vsnprintf) - (void)snprintf(state->path, len + 1, "%s", (const char *)path); -#else - strcpy(state->path, path); -#endif - - /* compute the flags for open() */ - oflag = -#ifdef O_LARGEFILE - O_LARGEFILE | -#endif -#ifdef O_BINARY - O_BINARY | -#endif -#ifdef O_CLOEXEC - (cloexec ? O_CLOEXEC : 0) | -#endif - (state->mode == GZ_READ ? - O_RDONLY : - (O_WRONLY | O_CREAT | -#ifdef O_EXCL - (exclusive ? O_EXCL : 0) | -#endif - (state->mode == GZ_WRITE ? - O_TRUNC : - O_APPEND))); - - /* open the file with the appropriate flags (or just use fd) */ - state->fd = fd > -1 ? fd : ( -#ifdef WIDECHAR - fd == -2 ? _wopen(path, oflag, 0666) : -#endif - open((const char *)path, oflag, 0666)); - if (state->fd == -1) { - free(state->path); - free(state); - return NULL; - } - if (state->mode == GZ_APPEND) { - LSEEK(state->fd, 0, SEEK_END); /* so gzoffset() is correct */ - state->mode = GZ_WRITE; /* simplify later checks */ - } - - /* save the current position for rewinding (only if reading) */ - if (state->mode == GZ_READ) { - state->start = LSEEK(state->fd, 0, SEEK_CUR); - if (state->start == -1) state->start = 0; - } - - /* initialize stream */ - gz_reset(state); - - /* return stream */ - return (gzFile)state; -} - -/* -- see zlib.h -- */ -gzFile ZEXPORT gzopen(path, mode) - const char *path; - const char *mode; -{ - return gz_open(path, -1, mode); -} - -/* -- see zlib.h -- */ -gzFile ZEXPORT gzopen64(path, mode) - const char *path; - const char *mode; -{ - return gz_open(path, -1, mode); -} - -/* -- see zlib.h -- */ -gzFile ZEXPORT gzdopen(fd, mode) - int fd; - const char *mode; -{ - char *path; /* identifier for error messages */ - gzFile gz; - - if (fd == -1 || (path = (char *)malloc(7 + 3 * sizeof(int))) == NULL) - return NULL; -#if !defined(NO_snprintf) && !defined(NO_vsnprintf) - (void)snprintf(path, 7 + 3 * sizeof(int), "", fd); -#else - sprintf(path, "", fd); /* for debugging */ -#endif - gz = gz_open(path, fd, mode); - free(path); - return gz; -} - -/* -- see zlib.h -- */ -#ifdef WIDECHAR -gzFile ZEXPORT gzopen_w(path, mode) - const wchar_t *path; - const char *mode; -{ - return gz_open(path, -2, mode); -} -#endif - -/* -- see zlib.h -- */ -int ZEXPORT gzbuffer(file, size) - gzFile file; - unsigned size; -{ - gz_statep state; - - /* get internal structure and check integrity */ - if (file == NULL) - return -1; - state = (gz_statep)file; - if (state->mode != GZ_READ && state->mode != GZ_WRITE) - return -1; - - /* make sure we haven't already allocated memory */ - if (state->size != 0) - return -1; - - /* check and set requested size */ - if ((size << 1) < size) - return -1; /* need to be able to double it */ - if (size < 2) - size = 2; /* need two bytes to check magic header */ - state->want = size; - return 0; -} - -/* -- see zlib.h -- */ -int ZEXPORT gzrewind(file) - gzFile file; -{ - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return -1; - state = (gz_statep)file; - - /* check that we're reading and that there's no error */ - if (state->mode != GZ_READ || - (state->err != Z_OK && state->err != Z_BUF_ERROR)) - return -1; - - /* back up and start over */ - if (LSEEK(state->fd, state->start, SEEK_SET) == -1) - return -1; - gz_reset(state); - return 0; -} - -/* -- see zlib.h -- */ -z_off64_t ZEXPORT gzseek64(file, offset, whence) - gzFile file; - z_off64_t offset; - int whence; -{ - unsigned n; - z_off64_t ret; - gz_statep state; - - /* get internal structure and check integrity */ - if (file == NULL) - return -1; - state = (gz_statep)file; - if (state->mode != GZ_READ && state->mode != GZ_WRITE) - return -1; - - /* check that there's no error */ - if (state->err != Z_OK && state->err != Z_BUF_ERROR) - return -1; - - /* can only seek from start or relative to current position */ - if (whence != SEEK_SET && whence != SEEK_CUR) - return -1; - - /* normalize offset to a SEEK_CUR specification */ - if (whence == SEEK_SET) - offset -= state->x.pos; - else if (state->seek) - offset += state->skip; - state->seek = 0; - - /* if within raw area while reading, just go there */ - if (state->mode == GZ_READ && state->how == COPY && - state->x.pos + offset >= 0) { - ret = LSEEK(state->fd, offset - (z_off64_t)state->x.have, SEEK_CUR); - if (ret == -1) - return -1; - state->x.have = 0; - state->eof = 0; - state->past = 0; - state->seek = 0; - gz_error(state, Z_OK, NULL); - state->strm.avail_in = 0; - state->x.pos += offset; - return state->x.pos; - } - - /* calculate skip amount, rewinding if needed for back seek when reading */ - if (offset < 0) { - if (state->mode != GZ_READ) /* writing -- can't go backwards */ - return -1; - offset += state->x.pos; - if (offset < 0) /* before start of file! */ - return -1; - if (gzrewind(file) == -1) /* rewind, then skip to offset */ - return -1; - } - - /* if reading, skip what's in output buffer (one less gzgetc() check) */ - if (state->mode == GZ_READ) { - n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > offset ? - (unsigned)offset : state->x.have; - state->x.have -= n; - state->x.next += n; - state->x.pos += n; - offset -= n; - } - - /* request skip (if not zero) */ - if (offset) { - state->seek = 1; - state->skip = offset; - } - return state->x.pos + offset; -} - -/* -- see zlib.h -- */ -z_off_t ZEXPORT gzseek(file, offset, whence) - gzFile file; - z_off_t offset; - int whence; -{ - z_off64_t ret; - - ret = gzseek64(file, (z_off64_t)offset, whence); - return ret == (z_off_t)ret ? (z_off_t)ret : -1; -} - -/* -- see zlib.h -- */ -z_off64_t ZEXPORT gztell64(file) - gzFile file; -{ - gz_statep state; - - /* get internal structure and check integrity */ - if (file == NULL) - return -1; - state = (gz_statep)file; - if (state->mode != GZ_READ && state->mode != GZ_WRITE) - return -1; - - /* return position */ - return state->x.pos + (state->seek ? state->skip : 0); -} - -/* -- see zlib.h -- */ -z_off_t ZEXPORT gztell(file) - gzFile file; -{ - z_off64_t ret; - - ret = gztell64(file); - return ret == (z_off_t)ret ? (z_off_t)ret : -1; -} - -/* -- see zlib.h -- */ -z_off64_t ZEXPORT gzoffset64(file) - gzFile file; -{ - z_off64_t offset; - gz_statep state; - - /* get internal structure and check integrity */ - if (file == NULL) - return -1; - state = (gz_statep)file; - if (state->mode != GZ_READ && state->mode != GZ_WRITE) - return -1; - - /* compute and return effective offset in file */ - offset = LSEEK(state->fd, 0, SEEK_CUR); - if (offset == -1) - return -1; - if (state->mode == GZ_READ) /* reading */ - offset -= state->strm.avail_in; /* don't count buffered input */ - return offset; -} - -/* -- see zlib.h -- */ -z_off_t ZEXPORT gzoffset(file) - gzFile file; -{ - z_off64_t ret; - - ret = gzoffset64(file); - return ret == (z_off_t)ret ? (z_off_t)ret : -1; -} - -/* -- see zlib.h -- */ -int ZEXPORT gzeof(file) - gzFile file; -{ - gz_statep state; - - /* get internal structure and check integrity */ - if (file == NULL) - return 0; - state = (gz_statep)file; - if (state->mode != GZ_READ && state->mode != GZ_WRITE) - return 0; - - /* return end-of-file state */ - return state->mode == GZ_READ ? state->past : 0; -} - -/* -- see zlib.h -- */ -const char * ZEXPORT gzerror(file, errnum) - gzFile file; - int *errnum; -{ - gz_statep state; - - /* get internal structure and check integrity */ - if (file == NULL) - return NULL; - state = (gz_statep)file; - if (state->mode != GZ_READ && state->mode != GZ_WRITE) - return NULL; - - /* return error information */ - if (errnum != NULL) - *errnum = state->err; - return state->err == Z_MEM_ERROR ? "out of memory" : - (state->msg == NULL ? "" : state->msg); -} - -/* -- see zlib.h -- */ -void ZEXPORT gzclearerr(file) - gzFile file; -{ - gz_statep state; - - /* get internal structure and check integrity */ - if (file == NULL) - return; - state = (gz_statep)file; - if (state->mode != GZ_READ && state->mode != GZ_WRITE) - return; - - /* clear error and end-of-file */ - if (state->mode == GZ_READ) { - state->eof = 0; - state->past = 0; - } - gz_error(state, Z_OK, NULL); -} - -/* Create an error message in allocated memory and set state->err and - state->msg accordingly. Free any previous error message already there. Do - not try to free or allocate space if the error is Z_MEM_ERROR (out of - memory). Simply save the error message as a static string. If there is an - allocation failure constructing the error message, then convert the error to - out of memory. */ -void ZLIB_INTERNAL gz_error(state, err, msg) - gz_statep state; - int err; - const char *msg; -{ - /* free previously allocated message and clear */ - if (state->msg != NULL) { - if (state->err != Z_MEM_ERROR) - free(state->msg); - state->msg = NULL; - } - - /* if fatal, set state->x.have to 0 so that the gzgetc() macro fails */ - if (err != Z_OK && err != Z_BUF_ERROR) - state->x.have = 0; - - /* set error code, and if no message, then done */ - state->err = err; - if (msg == NULL) - return; - - /* for an out of memory error, return literal string when requested */ - if (err == Z_MEM_ERROR) - return; - - /* construct error message with path */ - if ((state->msg = (char *)malloc(strlen(state->path) + strlen(msg) + 3)) == - NULL) { - state->err = Z_MEM_ERROR; - return; - } -#if !defined(NO_snprintf) && !defined(NO_vsnprintf) - (void)snprintf(state->msg, strlen(state->path) + strlen(msg) + 3, - "%s%s%s", state->path, ": ", msg); -#else - strcpy(state->msg, state->path); - strcat(state->msg, ": "); - strcat(state->msg, msg); -#endif -} - -#ifndef INT_MAX -/* portably return maximum value for an int (when limits.h presumed not - available) -- we need to do this to cover cases where 2's complement not - used, since C standard permits 1's complement and sign-bit representations, - otherwise we could just use ((unsigned)-1) >> 1 */ -unsigned ZLIB_INTERNAL gz_intmax() -{ - unsigned p, q; - - p = 1; - do { - q = p; - p <<= 1; - p++; - } while (p > q); - return q >> 1; -} -#endif diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/gzread.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/gzread.c deleted file mode 100644 index 884c9bf..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/gzread.c +++ /dev/null @@ -1,652 +0,0 @@ -/* gzread.c -- zlib functions for reading gzip files - * Copyright (C) 2004-2017 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "gzguts.h" - -/* Local functions */ -local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *)); -local int gz_avail OF((gz_statep)); -local int gz_look OF((gz_statep)); -local int gz_decomp OF((gz_statep)); -local int gz_fetch OF((gz_statep)); -local int gz_skip OF((gz_statep, z_off64_t)); -local z_size_t gz_read OF((gz_statep, voidp, z_size_t)); - -/* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from - state->fd, and update state->eof, state->err, and state->msg as appropriate. - This function needs to loop on read(), since read() is not guaranteed to - read the number of bytes requested, depending on the type of descriptor. */ -local int gz_load(state, buf, len, have) - gz_statep state; - unsigned char *buf; - unsigned len; - unsigned *have; -{ - int ret; - unsigned get, max = ((unsigned)-1 >> 2) + 1; - - *have = 0; - do { - get = len - *have; - if (get > max) - get = max; - ret = read(state->fd, buf + *have, get); - if (ret <= 0) - break; - *have += (unsigned)ret; - } while (*have < len); - if (ret < 0) { - gz_error(state, Z_ERRNO, zstrerror()); - return -1; - } - if (ret == 0) - state->eof = 1; - return 0; -} - -/* Load up input buffer and set eof flag if last data loaded -- return -1 on - error, 0 otherwise. Note that the eof flag is set when the end of the input - file is reached, even though there may be unused data in the buffer. Once - that data has been used, no more attempts will be made to read the file. - If strm->avail_in != 0, then the current data is moved to the beginning of - the input buffer, and then the remainder of the buffer is loaded with the - available data from the input file. */ -local int gz_avail(state) - gz_statep state; -{ - unsigned got; - z_streamp strm = &(state->strm); - - if (state->err != Z_OK && state->err != Z_BUF_ERROR) - return -1; - if (state->eof == 0) { - if (strm->avail_in) { /* copy what's there to the start */ - unsigned char *p = state->in; - unsigned const char *q = strm->next_in; - unsigned n = strm->avail_in; - do { - *p++ = *q++; - } while (--n); - } - if (gz_load(state, state->in + strm->avail_in, - state->size - strm->avail_in, &got) == -1) - return -1; - strm->avail_in += got; - strm->next_in = state->in; - } - return 0; -} - -/* Look for gzip header, set up for inflate or copy. state->x.have must be 0. - If this is the first time in, allocate required memory. state->how will be - left unchanged if there is no more input data available, will be set to COPY - if there is no gzip header and direct copying will be performed, or it will - be set to GZIP for decompression. If direct copying, then leftover input - data from the input buffer will be copied to the output buffer. In that - case, all further file reads will be directly to either the output buffer or - a user buffer. If decompressing, the inflate state will be initialized. - gz_look() will return 0 on success or -1 on failure. */ -local int gz_look(state) - gz_statep state; -{ - z_streamp strm = &(state->strm); - - /* allocate read buffers and inflate memory */ - if (state->size == 0) { - /* allocate buffers */ - state->in = (unsigned char *)malloc(state->want); - state->out = (unsigned char *)malloc(state->want << 1); - if (state->in == NULL || state->out == NULL) { - free(state->out); - free(state->in); - gz_error(state, Z_MEM_ERROR, "out of memory"); - return -1; - } - state->size = state->want; - - /* allocate inflate memory */ - state->strm.zalloc = Z_NULL; - state->strm.zfree = Z_NULL; - state->strm.opaque = Z_NULL; - state->strm.avail_in = 0; - state->strm.next_in = Z_NULL; - if (inflateInit2(&(state->strm), 15 + 16) != Z_OK) { /* gunzip */ - free(state->out); - free(state->in); - state->size = 0; - gz_error(state, Z_MEM_ERROR, "out of memory"); - return -1; - } - } - - /* get at least the magic bytes in the input buffer */ - if (strm->avail_in < 2) { - if (gz_avail(state) == -1) - return -1; - if (strm->avail_in == 0) - return 0; - } - - /* look for gzip magic bytes -- if there, do gzip decoding (note: there is - a logical dilemma here when considering the case of a partially written - gzip file, to wit, if a single 31 byte is written, then we cannot tell - whether this is a single-byte file, or just a partially written gzip - file -- for here we assume that if a gzip file is being written, then - the header will be written in a single operation, so that reading a - single byte is sufficient indication that it is not a gzip file) */ - if (strm->avail_in > 1 && - strm->next_in[0] == 31 && strm->next_in[1] == 139) { - inflateReset(strm); - state->how = GZIP; - state->direct = 0; - return 0; - } - - /* no gzip header -- if we were decoding gzip before, then this is trailing - garbage. Ignore the trailing garbage and finish. */ - if (state->direct == 0) { - strm->avail_in = 0; - state->eof = 1; - state->x.have = 0; - return 0; - } - - /* doing raw i/o, copy any leftover input to output -- this assumes that - the output buffer is larger than the input buffer, which also assures - space for gzungetc() */ - state->x.next = state->out; - if (strm->avail_in) { - memcpy(state->x.next, strm->next_in, strm->avail_in); - state->x.have = strm->avail_in; - strm->avail_in = 0; - } - state->how = COPY; - state->direct = 1; - return 0; -} - -/* Decompress from input to the provided next_out and avail_out in the state. - On return, state->x.have and state->x.next point to the just decompressed - data. If the gzip stream completes, state->how is reset to LOOK to look for - the next gzip stream or raw data, once state->x.have is depleted. Returns 0 - on success, -1 on failure. */ -local int gz_decomp(state) - gz_statep state; -{ - int ret = Z_OK; - unsigned had; - z_streamp strm = &(state->strm); - - /* fill output buffer up to end of deflate stream */ - had = strm->avail_out; - do { - /* get more input for inflate() */ - if (strm->avail_in == 0 && gz_avail(state) == -1) - return -1; - if (strm->avail_in == 0) { - gz_error(state, Z_BUF_ERROR, "unexpected end of file"); - break; - } - - /* decompress and handle errors */ - ret = inflate(strm, Z_NO_FLUSH); - if (ret == Z_STREAM_ERROR || ret == Z_NEED_DICT) { - gz_error(state, Z_STREAM_ERROR, - "internal error: inflate stream corrupt"); - return -1; - } - if (ret == Z_MEM_ERROR) { - gz_error(state, Z_MEM_ERROR, "out of memory"); - return -1; - } - if (ret == Z_DATA_ERROR) { /* deflate stream invalid */ - gz_error(state, Z_DATA_ERROR, - strm->msg == NULL ? "compressed data error" : strm->msg); - return -1; - } - } while (strm->avail_out && ret != Z_STREAM_END); - - /* update available output */ - state->x.have = had - strm->avail_out; - state->x.next = strm->next_out - state->x.have; - - /* if the gzip stream completed successfully, look for another */ - if (ret == Z_STREAM_END) - state->how = LOOK; - - /* good decompression */ - return 0; -} - -/* Fetch data and put it in the output buffer. Assumes state->x.have is 0. - Data is either copied from the input file or decompressed from the input - file depending on state->how. If state->how is LOOK, then a gzip header is - looked for to determine whether to copy or decompress. Returns -1 on error, - otherwise 0. gz_fetch() will leave state->how as COPY or GZIP unless the - end of the input file has been reached and all data has been processed. */ -local int gz_fetch(state) - gz_statep state; -{ - z_streamp strm = &(state->strm); - - do { - switch(state->how) { - case LOOK: /* -> LOOK, COPY (only if never GZIP), or GZIP */ - if (gz_look(state) == -1) - return -1; - if (state->how == LOOK) - return 0; - break; - case COPY: /* -> COPY */ - if (gz_load(state, state->out, state->size << 1, &(state->x.have)) - == -1) - return -1; - state->x.next = state->out; - return 0; - case GZIP: /* -> GZIP or LOOK (if end of gzip stream) */ - strm->avail_out = state->size << 1; - strm->next_out = state->out; - if (gz_decomp(state) == -1) - return -1; - } - } while (state->x.have == 0 && (!state->eof || strm->avail_in)); - return 0; -} - -/* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */ -local int gz_skip(state, len) - gz_statep state; - z_off64_t len; -{ - unsigned n; - - /* skip over len bytes or reach end-of-file, whichever comes first */ - while (len) - /* skip over whatever is in output buffer */ - if (state->x.have) { - n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > len ? - (unsigned)len : state->x.have; - state->x.have -= n; - state->x.next += n; - state->x.pos += n; - len -= n; - } - - /* output buffer empty -- return if we're at the end of the input */ - else if (state->eof && state->strm.avail_in == 0) - break; - - /* need more data to skip -- load up output buffer */ - else { - /* get more output, looking for header if required */ - if (gz_fetch(state) == -1) - return -1; - } - return 0; -} - -/* Read len bytes into buf from file, or less than len up to the end of the - input. Return the number of bytes read. If zero is returned, either the - end of file was reached, or there was an error. state->err must be - consulted in that case to determine which. */ -local z_size_t gz_read(state, buf, len) - gz_statep state; - voidp buf; - z_size_t len; -{ - z_size_t got; - unsigned n; - - /* if len is zero, avoid unnecessary operations */ - if (len == 0) - return 0; - - /* process a skip request */ - if (state->seek) { - state->seek = 0; - if (gz_skip(state, state->skip) == -1) - return 0; - } - - /* get len bytes to buf, or less than len if at the end */ - got = 0; - do { - /* set n to the maximum amount of len that fits in an unsigned int */ - n = (unsigned)-1; - if (n > len) - n = (unsigned)len; - - /* first just try copying data from the output buffer */ - if (state->x.have) { - if (state->x.have < n) - n = state->x.have; - memcpy(buf, state->x.next, n); - state->x.next += n; - state->x.have -= n; - } - - /* output buffer empty -- return if we're at the end of the input */ - else if (state->eof && state->strm.avail_in == 0) { - state->past = 1; /* tried to read past end */ - break; - } - - /* need output data -- for small len or new stream load up our output - buffer */ - else if (state->how == LOOK || n < (state->size << 1)) { - /* get more output, looking for header if required */ - if (gz_fetch(state) == -1) - return 0; - continue; /* no progress yet -- go back to copy above */ - /* the copy above assures that we will leave with space in the - output buffer, allowing at least one gzungetc() to succeed */ - } - - /* large len -- read directly into user buffer */ - else if (state->how == COPY) { /* read directly */ - if (gz_load(state, (unsigned char *)buf, n, &n) == -1) - return 0; - } - - /* large len -- decompress directly into user buffer */ - else { /* state->how == GZIP */ - state->strm.avail_out = n; - state->strm.next_out = (unsigned char *)buf; - if (gz_decomp(state) == -1) - return 0; - n = state->x.have; - state->x.have = 0; - } - - /* update progress */ - len -= n; - buf = (char *)buf + n; - got += n; - state->x.pos += n; - } while (len); - - /* return number of bytes read into user buffer */ - return got; -} - -/* -- see zlib.h -- */ -int ZEXPORT gzread(file, buf, len) - gzFile file; - voidp buf; - unsigned len; -{ - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return -1; - state = (gz_statep)file; - - /* check that we're reading and that there's no (serious) error */ - if (state->mode != GZ_READ || - (state->err != Z_OK && state->err != Z_BUF_ERROR)) - return -1; - - /* since an int is returned, make sure len fits in one, otherwise return - with an error (this avoids a flaw in the interface) */ - if ((int)len < 0) { - gz_error(state, Z_STREAM_ERROR, "request does not fit in an int"); - return -1; - } - - /* read len or fewer bytes to buf */ - len = (unsigned)gz_read(state, buf, len); - - /* check for an error */ - if (len == 0 && state->err != Z_OK && state->err != Z_BUF_ERROR) - return -1; - - /* return the number of bytes read (this is assured to fit in an int) */ - return (int)len; -} - -/* -- see zlib.h -- */ -z_size_t ZEXPORT gzfread(buf, size, nitems, file) - voidp buf; - z_size_t size; - z_size_t nitems; - gzFile file; -{ - z_size_t len; - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return 0; - state = (gz_statep)file; - - /* check that we're reading and that there's no (serious) error */ - if (state->mode != GZ_READ || - (state->err != Z_OK && state->err != Z_BUF_ERROR)) - return 0; - - /* compute bytes to read -- error on overflow */ - len = nitems * size; - if (size && len / size != nitems) { - gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t"); - return 0; - } - - /* read len or fewer bytes to buf, return the number of full items read */ - return len ? gz_read(state, buf, len) / size : 0; -} - -/* -- see zlib.h -- */ -#ifdef Z_PREFIX_SET -# undef z_gzgetc -#else -# undef gzgetc -#endif -int ZEXPORT gzgetc(file) - gzFile file; -{ - unsigned char buf[1]; - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return -1; - state = (gz_statep)file; - - /* check that we're reading and that there's no (serious) error */ - if (state->mode != GZ_READ || - (state->err != Z_OK && state->err != Z_BUF_ERROR)) - return -1; - - /* try output buffer (no need to check for skip request) */ - if (state->x.have) { - state->x.have--; - state->x.pos++; - return *(state->x.next)++; - } - - /* nothing there -- try gz_read() */ - return gz_read(state, buf, 1) < 1 ? -1 : buf[0]; -} - -int ZEXPORT gzgetc_(file) -gzFile file; -{ - return gzgetc(file); -} - -/* -- see zlib.h -- */ -int ZEXPORT gzungetc(c, file) - int c; - gzFile file; -{ - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return -1; - state = (gz_statep)file; - - /* check that we're reading and that there's no (serious) error */ - if (state->mode != GZ_READ || - (state->err != Z_OK && state->err != Z_BUF_ERROR)) - return -1; - - /* process a skip request */ - if (state->seek) { - state->seek = 0; - if (gz_skip(state, state->skip) == -1) - return -1; - } - - /* can't push EOF */ - if (c < 0) - return -1; - - /* if output buffer empty, put byte at end (allows more pushing) */ - if (state->x.have == 0) { - state->x.have = 1; - state->x.next = state->out + (state->size << 1) - 1; - state->x.next[0] = (unsigned char)c; - state->x.pos--; - state->past = 0; - return c; - } - - /* if no room, give up (must have already done a gzungetc()) */ - if (state->x.have == (state->size << 1)) { - gz_error(state, Z_DATA_ERROR, "out of room to push characters"); - return -1; - } - - /* slide output data if needed and insert byte before existing data */ - if (state->x.next == state->out) { - unsigned char *src = state->out + state->x.have; - unsigned char *dest = state->out + (state->size << 1); - while (src > state->out) - *--dest = *--src; - state->x.next = dest; - } - state->x.have++; - state->x.next--; - state->x.next[0] = (unsigned char)c; - state->x.pos--; - state->past = 0; - return c; -} - -/* -- see zlib.h -- */ -char * ZEXPORT gzgets(file, buf, len) - gzFile file; - char *buf; - int len; -{ - unsigned left, n; - char *str; - unsigned char *eol; - gz_statep state; - - /* check parameters and get internal structure */ - if (file == NULL || buf == NULL || len < 1) - return NULL; - state = (gz_statep)file; - - /* check that we're reading and that there's no (serious) error */ - if (state->mode != GZ_READ || - (state->err != Z_OK && state->err != Z_BUF_ERROR)) - return NULL; - - /* process a skip request */ - if (state->seek) { - state->seek = 0; - if (gz_skip(state, state->skip) == -1) - return NULL; - } - - /* copy output bytes up to new line or len - 1, whichever comes first -- - append a terminating zero to the string (we don't check for a zero in - the contents, let the user worry about that) */ - str = buf; - left = (unsigned)len - 1; - if (left) do { - /* assure that something is in the output buffer */ - if (state->x.have == 0 && gz_fetch(state) == -1) - return NULL; /* error */ - if (state->x.have == 0) { /* end of file */ - state->past = 1; /* read past end */ - break; /* return what we have */ - } - - /* look for end-of-line in current output buffer */ - n = state->x.have > left ? left : state->x.have; - eol = (unsigned char *)memchr(state->x.next, '\n', n); - if (eol != NULL) - n = (unsigned)(eol - state->x.next) + 1; - - /* copy through end-of-line, or remainder if not found */ - memcpy(buf, state->x.next, n); - state->x.have -= n; - state->x.next += n; - state->x.pos += n; - left -= n; - buf += n; - } while (left && eol == NULL); - - /* return terminated string, or if nothing, end of file */ - if (buf == str) - return NULL; - buf[0] = 0; - return str; -} - -/* -- see zlib.h -- */ -int ZEXPORT gzdirect(file) - gzFile file; -{ - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return 0; - state = (gz_statep)file; - - /* if the state is not known, but we can find out, then do so (this is - mainly for right after a gzopen() or gzdopen()) */ - if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0) - (void)gz_look(state); - - /* return 1 if transparent, 0 if processing a gzip stream */ - return state->direct; -} - -/* -- see zlib.h -- */ -int ZEXPORT gzclose_r(file) - gzFile file; -{ - int ret, err; - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return Z_STREAM_ERROR; - state = (gz_statep)file; - - /* check that we're reading */ - if (state->mode != GZ_READ) - return Z_STREAM_ERROR; - - /* free memory and close file */ - if (state->size) { - inflateEnd(&(state->strm)); - free(state->out); - free(state->in); - } - err = state->err == Z_BUF_ERROR ? Z_BUF_ERROR : Z_OK; - gz_error(state, Z_OK, NULL); - free(state->path); - ret = close(state->fd); - free(state); - return ret ? Z_ERRNO : err; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/gzwrite.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/gzwrite.c deleted file mode 100644 index a8ffc8f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/gzwrite.c +++ /dev/null @@ -1,677 +0,0 @@ -/* gzwrite.c -- zlib functions for writing gzip files - * Copyright (C) 2004-2019 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "gzguts.h" - -/* Local functions */ -local int gz_init OF((gz_statep)); -local int gz_comp OF((gz_statep, int)); -local int gz_zero OF((gz_statep, z_off64_t)); -local z_size_t gz_write OF((gz_statep, voidpc, z_size_t)); - -/* Initialize state for writing a gzip file. Mark initialization by setting - state->size to non-zero. Return -1 on a memory allocation failure, or 0 on - success. */ -local int gz_init(state) - gz_statep state; -{ - int ret; - z_streamp strm = &(state->strm); - - /* allocate input buffer (double size for gzprintf) */ - state->in = (unsigned char *)malloc(state->want << 1); - if (state->in == NULL) { - gz_error(state, Z_MEM_ERROR, "out of memory"); - return -1; - } - - /* only need output buffer and deflate state if compressing */ - if (!state->direct) { - /* allocate output buffer */ - state->out = (unsigned char *)malloc(state->want); - if (state->out == NULL) { - free(state->in); - gz_error(state, Z_MEM_ERROR, "out of memory"); - return -1; - } - - /* allocate deflate memory, set up for gzip compression */ - strm->zalloc = Z_NULL; - strm->zfree = Z_NULL; - strm->opaque = Z_NULL; - ret = deflateInit2(strm, state->level, Z_DEFLATED, - MAX_WBITS + 16, DEF_MEM_LEVEL, state->strategy); - if (ret != Z_OK) { - free(state->out); - free(state->in); - gz_error(state, Z_MEM_ERROR, "out of memory"); - return -1; - } - strm->next_in = NULL; - } - - /* mark state as initialized */ - state->size = state->want; - - /* initialize write buffer if compressing */ - if (!state->direct) { - strm->avail_out = state->size; - strm->next_out = state->out; - state->x.next = strm->next_out; - } - return 0; -} - -/* Compress whatever is at avail_in and next_in and write to the output file. - Return -1 if there is an error writing to the output file or if gz_init() - fails to allocate memory, otherwise 0. flush is assumed to be a valid - deflate() flush value. If flush is Z_FINISH, then the deflate() state is - reset to start a new gzip stream. If gz->direct is true, then simply write - to the output file without compressing, and ignore flush. */ -local int gz_comp(state, flush) - gz_statep state; - int flush; -{ - int ret, writ; - unsigned have, put, max = ((unsigned)-1 >> 2) + 1; - z_streamp strm = &(state->strm); - - /* allocate memory if this is the first time through */ - if (state->size == 0 && gz_init(state) == -1) - return -1; - - /* write directly if requested */ - if (state->direct) { - while (strm->avail_in) { - put = strm->avail_in > max ? max : strm->avail_in; - writ = write(state->fd, strm->next_in, put); - if (writ < 0) { - gz_error(state, Z_ERRNO, zstrerror()); - return -1; - } - strm->avail_in -= (unsigned)writ; - strm->next_in += writ; - } - return 0; - } - - /* check for a pending reset */ - if (state->reset) { - /* don't start a new gzip member unless there is data to write */ - if (strm->avail_in == 0) - return 0; - deflateReset(strm); - state->reset = 0; - } - - /* run deflate() on provided input until it produces no more output */ - ret = Z_OK; - do { - /* write out current buffer contents if full, or if flushing, but if - doing Z_FINISH then don't write until we get to Z_STREAM_END */ - if (strm->avail_out == 0 || (flush != Z_NO_FLUSH && - (flush != Z_FINISH || ret == Z_STREAM_END))) { - while (strm->next_out > state->x.next) { - put = strm->next_out - state->x.next > (int)max ? max : - (unsigned)(strm->next_out - state->x.next); - writ = write(state->fd, state->x.next, put); - if (writ < 0) { - gz_error(state, Z_ERRNO, zstrerror()); - return -1; - } - state->x.next += writ; - } - if (strm->avail_out == 0) { - strm->avail_out = state->size; - strm->next_out = state->out; - state->x.next = state->out; - } - } - - /* compress */ - have = strm->avail_out; - ret = deflate(strm, flush); - if (ret == Z_STREAM_ERROR) { - gz_error(state, Z_STREAM_ERROR, - "internal error: deflate stream corrupt"); - return -1; - } - have -= strm->avail_out; - } while (have); - - /* if that completed a deflate stream, allow another to start */ - if (flush == Z_FINISH) - state->reset = 1; - - /* all done, no errors */ - return 0; -} - -/* Compress len zeros to output. Return -1 on a write error or memory - allocation failure by gz_comp(), or 0 on success. */ -local int gz_zero(state, len) - gz_statep state; - z_off64_t len; -{ - int first; - unsigned n; - z_streamp strm = &(state->strm); - - /* consume whatever's left in the input buffer */ - if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1) - return -1; - - /* compress len zeros (len guaranteed > 0) */ - first = 1; - while (len) { - n = GT_OFF(state->size) || (z_off64_t)state->size > len ? - (unsigned)len : state->size; - if (first) { - memset(state->in, 0, n); - first = 0; - } - strm->avail_in = n; - strm->next_in = state->in; - state->x.pos += n; - if (gz_comp(state, Z_NO_FLUSH) == -1) - return -1; - len -= n; - } - return 0; -} - -/* Write len bytes from buf to file. Return the number of bytes written. If - the returned value is less than len, then there was an error. */ -local z_size_t gz_write(state, buf, len) - gz_statep state; - voidpc buf; - z_size_t len; -{ - z_size_t put = len; - - /* if len is zero, avoid unnecessary operations */ - if (len == 0) - return 0; - - /* allocate memory if this is the first time through */ - if (state->size == 0 && gz_init(state) == -1) - return 0; - - /* check for seek request */ - if (state->seek) { - state->seek = 0; - if (gz_zero(state, state->skip) == -1) - return 0; - } - - /* for small len, copy to input buffer, otherwise compress directly */ - if (len < state->size) { - /* copy to input buffer, compress when full */ - do { - unsigned have, copy; - - if (state->strm.avail_in == 0) - state->strm.next_in = state->in; - have = (unsigned)((state->strm.next_in + state->strm.avail_in) - - state->in); - copy = state->size - have; - if (copy > len) - copy = (unsigned)len; - memcpy(state->in + have, buf, copy); - state->strm.avail_in += copy; - state->x.pos += copy; - buf = (const char *)buf + copy; - len -= copy; - if (len && gz_comp(state, Z_NO_FLUSH) == -1) - return 0; - } while (len); - } - else { - /* consume whatever's left in the input buffer */ - if (state->strm.avail_in && gz_comp(state, Z_NO_FLUSH) == -1) - return 0; - - /* directly compress user buffer to file */ - state->strm.next_in = (z_const Bytef *)buf; - do { - unsigned n = (unsigned)-1; - if (n > len) - n = (unsigned)len; - state->strm.avail_in = n; - state->x.pos += n; - if (gz_comp(state, Z_NO_FLUSH) == -1) - return 0; - len -= n; - } while (len); - } - - /* input was all buffered or compressed */ - return put; -} - -/* -- see zlib.h -- */ -int ZEXPORT gzwrite(file, buf, len) - gzFile file; - voidpc buf; - unsigned len; -{ - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return 0; - state = (gz_statep)file; - - /* check that we're writing and that there's no error */ - if (state->mode != GZ_WRITE || state->err != Z_OK) - return 0; - - /* since an int is returned, make sure len fits in one, otherwise return - with an error (this avoids a flaw in the interface) */ - if ((int)len < 0) { - gz_error(state, Z_DATA_ERROR, "requested length does not fit in int"); - return 0; - } - - /* write len bytes from buf (the return value will fit in an int) */ - return (int)gz_write(state, buf, len); -} - -/* -- see zlib.h -- */ -z_size_t ZEXPORT gzfwrite(buf, size, nitems, file) - voidpc buf; - z_size_t size; - z_size_t nitems; - gzFile file; -{ - z_size_t len; - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return 0; - state = (gz_statep)file; - - /* check that we're writing and that there's no error */ - if (state->mode != GZ_WRITE || state->err != Z_OK) - return 0; - - /* compute bytes to read -- error on overflow */ - len = nitems * size; - if (size && len / size != nitems) { - gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t"); - return 0; - } - - /* write len bytes to buf, return the number of full items written */ - return len ? gz_write(state, buf, len) / size : 0; -} - -/* -- see zlib.h -- */ -int ZEXPORT gzputc(file, c) - gzFile file; - int c; -{ - unsigned have; - unsigned char buf[1]; - gz_statep state; - z_streamp strm; - - /* get internal structure */ - if (file == NULL) - return -1; - state = (gz_statep)file; - strm = &(state->strm); - - /* check that we're writing and that there's no error */ - if (state->mode != GZ_WRITE || state->err != Z_OK) - return -1; - - /* check for seek request */ - if (state->seek) { - state->seek = 0; - if (gz_zero(state, state->skip) == -1) - return -1; - } - - /* try writing to input buffer for speed (state->size == 0 if buffer not - initialized) */ - if (state->size) { - if (strm->avail_in == 0) - strm->next_in = state->in; - have = (unsigned)((strm->next_in + strm->avail_in) - state->in); - if (have < state->size) { - state->in[have] = (unsigned char)c; - strm->avail_in++; - state->x.pos++; - return c & 0xff; - } - } - - /* no room in buffer or not initialized, use gz_write() */ - buf[0] = (unsigned char)c; - if (gz_write(state, buf, 1) != 1) - return -1; - return c & 0xff; -} - -/* -- see zlib.h -- */ -int ZEXPORT gzputs(file, s) - gzFile file; - const char *s; -{ - z_size_t len, put; - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return -1; - state = (gz_statep)file; - - /* check that we're writing and that there's no error */ - if (state->mode != GZ_WRITE || state->err != Z_OK) - return -1; - - /* write string */ - len = strlen(s); - if ((int)len < 0 || (unsigned)len != len) { - gz_error(state, Z_STREAM_ERROR, "string length does not fit in int"); - return -1; - } - put = gz_write(state, s, len); - return put < len ? -1 : (int)len; -} - -#if defined(STDC) || defined(Z_HAVE_STDARG_H) -#include - -/* -- see zlib.h -- */ -int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) -{ - int len; - unsigned left; - char *next; - gz_statep state; - z_streamp strm; - - /* get internal structure */ - if (file == NULL) - return Z_STREAM_ERROR; - state = (gz_statep)file; - strm = &(state->strm); - - /* check that we're writing and that there's no error */ - if (state->mode != GZ_WRITE || state->err != Z_OK) - return Z_STREAM_ERROR; - - /* make sure we have some buffer space */ - if (state->size == 0 && gz_init(state) == -1) - return state->err; - - /* check for seek request */ - if (state->seek) { - state->seek = 0; - if (gz_zero(state, state->skip) == -1) - return state->err; - } - - /* do the printf() into the input buffer, put length in len -- the input - buffer is double-sized just for this function, so there is guaranteed to - be state->size bytes available after the current contents */ - if (strm->avail_in == 0) - strm->next_in = state->in; - next = (char *)(state->in + (strm->next_in - state->in) + strm->avail_in); - next[state->size - 1] = 0; -#ifdef NO_vsnprintf -# ifdef HAS_vsprintf_void - (void)vsprintf(next, format, va); - for (len = 0; len < state->size; len++) - if (next[len] == 0) break; -# else - len = vsprintf(next, format, va); -# endif -#else -# ifdef HAS_vsnprintf_void - (void)vsnprintf(next, state->size, format, va); - len = strlen(next); -# else - len = vsnprintf(next, state->size, format, va); -# endif -#endif - - /* check that printf() results fit in buffer */ - if (len == 0 || (unsigned)len >= state->size || next[state->size - 1] != 0) - return 0; - - /* update buffer and position, compress first half if past that */ - strm->avail_in += (unsigned)len; - state->x.pos += len; - if (strm->avail_in >= state->size) { - left = strm->avail_in - state->size; - strm->avail_in = state->size; - if (gz_comp(state, Z_NO_FLUSH) == -1) - return state->err; - memmove(state->in, state->in + state->size, left); - strm->next_in = state->in; - strm->avail_in = left; - } - return len; -} - -int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) -{ - va_list va; - int ret; - - va_start(va, format); - ret = gzvprintf(file, format, va); - va_end(va); - return ret; -} - -#else /* !STDC && !Z_HAVE_STDARG_H */ - -/* -- see zlib.h -- */ -int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) - gzFile file; - const char *format; - int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20; -{ - unsigned len, left; - char *next; - gz_statep state; - z_streamp strm; - - /* get internal structure */ - if (file == NULL) - return Z_STREAM_ERROR; - state = (gz_statep)file; - strm = &(state->strm); - - /* check that can really pass pointer in ints */ - if (sizeof(int) != sizeof(void *)) - return Z_STREAM_ERROR; - - /* check that we're writing and that there's no error */ - if (state->mode != GZ_WRITE || state->err != Z_OK) - return Z_STREAM_ERROR; - - /* make sure we have some buffer space */ - if (state->size == 0 && gz_init(state) == -1) - return state->error; - - /* check for seek request */ - if (state->seek) { - state->seek = 0; - if (gz_zero(state, state->skip) == -1) - return state->error; - } - - /* do the printf() into the input buffer, put length in len -- the input - buffer is double-sized just for this function, so there is guaranteed to - be state->size bytes available after the current contents */ - if (strm->avail_in == 0) - strm->next_in = state->in; - next = (char *)(strm->next_in + strm->avail_in); - next[state->size - 1] = 0; -#ifdef NO_snprintf -# ifdef HAS_sprintf_void - sprintf(next, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, - a13, a14, a15, a16, a17, a18, a19, a20); - for (len = 0; len < size; len++) - if (next[len] == 0) - break; -# else - len = sprintf(next, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, - a12, a13, a14, a15, a16, a17, a18, a19, a20); -# endif -#else -# ifdef HAS_snprintf_void - snprintf(next, state->size, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, - a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); - len = strlen(next); -# else - len = snprintf(next, state->size, format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); -# endif -#endif - - /* check that printf() results fit in buffer */ - if (len == 0 || len >= state->size || next[state->size - 1] != 0) - return 0; - - /* update buffer and position, compress first half if past that */ - strm->avail_in += len; - state->x.pos += len; - if (strm->avail_in >= state->size) { - left = strm->avail_in - state->size; - strm->avail_in = state->size; - if (gz_comp(state, Z_NO_FLUSH) == -1) - return state->err; - memmove(state->in, state->in + state->size, left); - strm->next_in = state->in; - strm->avail_in = left; - } - return (int)len; -} - -#endif - -/* -- see zlib.h -- */ -int ZEXPORT gzflush(file, flush) - gzFile file; - int flush; -{ - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return Z_STREAM_ERROR; - state = (gz_statep)file; - - /* check that we're writing and that there's no error */ - if (state->mode != GZ_WRITE || state->err != Z_OK) - return Z_STREAM_ERROR; - - /* check flush parameter */ - if (flush < 0 || flush > Z_FINISH) - return Z_STREAM_ERROR; - - /* check for seek request */ - if (state->seek) { - state->seek = 0; - if (gz_zero(state, state->skip) == -1) - return state->err; - } - - /* compress remaining data with requested flush */ - (void)gz_comp(state, flush); - return state->err; -} - -/* -- see zlib.h -- */ -int ZEXPORT gzsetparams(file, level, strategy) - gzFile file; - int level; - int strategy; -{ - gz_statep state; - z_streamp strm; - - /* get internal structure */ - if (file == NULL) - return Z_STREAM_ERROR; - state = (gz_statep)file; - strm = &(state->strm); - - /* check that we're writing and that there's no error */ - if (state->mode != GZ_WRITE || state->err != Z_OK) - return Z_STREAM_ERROR; - - /* if no change is requested, then do nothing */ - if (level == state->level && strategy == state->strategy) - return Z_OK; - - /* check for seek request */ - if (state->seek) { - state->seek = 0; - if (gz_zero(state, state->skip) == -1) - return state->err; - } - - /* change compression parameters for subsequent input */ - if (state->size) { - /* flush previous input with previous parameters before changing */ - if (strm->avail_in && gz_comp(state, Z_BLOCK) == -1) - return state->err; - deflateParams(strm, level, strategy); - } - state->level = level; - state->strategy = strategy; - return Z_OK; -} - -/* -- see zlib.h -- */ -int ZEXPORT gzclose_w(file) - gzFile file; -{ - int ret = Z_OK; - gz_statep state; - - /* get internal structure */ - if (file == NULL) - return Z_STREAM_ERROR; - state = (gz_statep)file; - - /* check that we're writing */ - if (state->mode != GZ_WRITE) - return Z_STREAM_ERROR; - - /* check for seek request */ - if (state->seek) { - state->seek = 0; - if (gz_zero(state, state->skip) == -1) - ret = state->err; - } - - /* flush, free memory, and close file */ - if (gz_comp(state, Z_FINISH) == -1) - ret = state->err; - if (state->size) { - if (!state->direct) { - (void)deflateEnd(&(state->strm)); - free(state->out); - } - free(state->in); - } - gz_error(state, Z_OK, NULL); - free(state->path); - if (close(state->fd) == -1) - ret = Z_ERRNO; - free(state); - return ret; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/infback.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/infback.c deleted file mode 100644 index a390c58..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/infback.c +++ /dev/null @@ -1,641 +0,0 @@ -/* infback.c -- inflate using a call-back interface - * Copyright (C) 1995-2022 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - This code is largely copied from inflate.c. Normally either infback.o or - inflate.o would be linked into an application--not both. The interface - with inffast.c is retained so that optimized assembler-coded versions of - inflate_fast() can be used with either inflate.c or infback.c. - */ - -#include "zutil.h" -#include "inftrees.h" -#include "inflate.h" -#include "inffast.h" - -/* function prototypes */ -local void fixedtables OF((struct inflate_state FAR *state)); - -/* - strm provides memory allocation functions in zalloc and zfree, or - Z_NULL to use the library memory allocation functions. - - windowBits is in the range 8..15, and window is a user-supplied - window and output buffer that is 2**windowBits bytes. - */ -int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size) -z_streamp strm; -int windowBits; -unsigned char FAR *window; -const char *version; -int stream_size; -{ - struct inflate_state FAR *state; - - if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || - stream_size != (int)(sizeof(z_stream))) - return Z_VERSION_ERROR; - if (strm == Z_NULL || window == Z_NULL || - windowBits < 8 || windowBits > 15) - return Z_STREAM_ERROR; - strm->msg = Z_NULL; /* in case we return an error */ - if (strm->zalloc == (alloc_func)0) { -#ifdef Z_SOLO - return Z_STREAM_ERROR; -#else - strm->zalloc = zcalloc; - strm->opaque = (voidpf)0; -#endif - } - if (strm->zfree == (free_func)0) -#ifdef Z_SOLO - return Z_STREAM_ERROR; -#else - strm->zfree = zcfree; -#endif - state = (struct inflate_state FAR *)ZALLOC(strm, 1, - sizeof(struct inflate_state)); - if (state == Z_NULL) return Z_MEM_ERROR; - Tracev((stderr, "inflate: allocated\n")); - strm->state = (struct internal_state FAR *)state; - state->dmax = 32768U; - state->wbits = (uInt)windowBits; - state->wsize = 1U << windowBits; - state->window = window; - state->wnext = 0; - state->whave = 0; - return Z_OK; -} - -/* - Return state with length and distance decoding tables and index sizes set to - fixed code decoding. Normally this returns fixed tables from inffixed.h. - If BUILDFIXED is defined, then instead this routine builds the tables the - first time it's called, and returns those tables the first time and - thereafter. This reduces the size of the code by about 2K bytes, in - exchange for a little execution time. However, BUILDFIXED should not be - used for threaded applications, since the rewriting of the tables and virgin - may not be thread-safe. - */ -local void fixedtables(state) -struct inflate_state FAR *state; -{ -#ifdef BUILDFIXED - static int virgin = 1; - static code *lenfix, *distfix; - static code fixed[544]; - - /* build fixed huffman tables if first call (may not be thread safe) */ - if (virgin) { - unsigned sym, bits; - static code *next; - - /* literal/length table */ - sym = 0; - while (sym < 144) state->lens[sym++] = 8; - while (sym < 256) state->lens[sym++] = 9; - while (sym < 280) state->lens[sym++] = 7; - while (sym < 288) state->lens[sym++] = 8; - next = fixed; - lenfix = next; - bits = 9; - inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); - - /* distance table */ - sym = 0; - while (sym < 32) state->lens[sym++] = 5; - distfix = next; - bits = 5; - inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); - - /* do this just once */ - virgin = 0; - } -#else /* !BUILDFIXED */ -# include "inffixed.h" -#endif /* BUILDFIXED */ - state->lencode = lenfix; - state->lenbits = 9; - state->distcode = distfix; - state->distbits = 5; -} - -/* Macros for inflateBack(): */ - -/* Load returned state from inflate_fast() */ -#define LOAD() \ - do { \ - put = strm->next_out; \ - left = strm->avail_out; \ - next = strm->next_in; \ - have = strm->avail_in; \ - hold = state->hold; \ - bits = state->bits; \ - } while (0) - -/* Set state from registers for inflate_fast() */ -#define RESTORE() \ - do { \ - strm->next_out = put; \ - strm->avail_out = left; \ - strm->next_in = next; \ - strm->avail_in = have; \ - state->hold = hold; \ - state->bits = bits; \ - } while (0) - -/* Clear the input bit accumulator */ -#define INITBITS() \ - do { \ - hold = 0; \ - bits = 0; \ - } while (0) - -/* Assure that some input is available. If input is requested, but denied, - then return a Z_BUF_ERROR from inflateBack(). */ -#define PULL() \ - do { \ - if (have == 0) { \ - have = in(in_desc, &next); \ - if (have == 0) { \ - next = Z_NULL; \ - ret = Z_BUF_ERROR; \ - goto inf_leave; \ - } \ - } \ - } while (0) - -/* Get a byte of input into the bit accumulator, or return from inflateBack() - with an error if there is no input available. */ -#define PULLBYTE() \ - do { \ - PULL(); \ - have--; \ - hold += (unsigned long)(*next++) << bits; \ - bits += 8; \ - } while (0) - -/* Assure that there are at least n bits in the bit accumulator. If there is - not enough available input to do that, then return from inflateBack() with - an error. */ -#define NEEDBITS(n) \ - do { \ - while (bits < (unsigned)(n)) \ - PULLBYTE(); \ - } while (0) - -/* Return the low n bits of the bit accumulator (n < 16) */ -#define BITS(n) \ - ((unsigned)hold & ((1U << (n)) - 1)) - -/* Remove n bits from the bit accumulator */ -#define DROPBITS(n) \ - do { \ - hold >>= (n); \ - bits -= (unsigned)(n); \ - } while (0) - -/* Remove zero to seven bits as needed to go to a byte boundary */ -#define BYTEBITS() \ - do { \ - hold >>= bits & 7; \ - bits -= bits & 7; \ - } while (0) - -/* Assure that some output space is available, by writing out the window - if it's full. If the write fails, return from inflateBack() with a - Z_BUF_ERROR. */ -#define ROOM() \ - do { \ - if (left == 0) { \ - put = state->window; \ - left = state->wsize; \ - state->whave = left; \ - if (out(out_desc, put, left)) { \ - ret = Z_BUF_ERROR; \ - goto inf_leave; \ - } \ - } \ - } while (0) - -/* - strm provides the memory allocation functions and window buffer on input, - and provides information on the unused input on return. For Z_DATA_ERROR - returns, strm will also provide an error message. - - in() and out() are the call-back input and output functions. When - inflateBack() needs more input, it calls in(). When inflateBack() has - filled the window with output, or when it completes with data in the - window, it calls out() to write out the data. The application must not - change the provided input until in() is called again or inflateBack() - returns. The application must not change the window/output buffer until - inflateBack() returns. - - in() and out() are called with a descriptor parameter provided in the - inflateBack() call. This parameter can be a structure that provides the - information required to do the read or write, as well as accumulated - information on the input and output such as totals and check values. - - in() should return zero on failure. out() should return non-zero on - failure. If either in() or out() fails, than inflateBack() returns a - Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it - was in() or out() that caused in the error. Otherwise, inflateBack() - returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format - error, or Z_MEM_ERROR if it could not allocate memory for the state. - inflateBack() can also return Z_STREAM_ERROR if the input parameters - are not correct, i.e. strm is Z_NULL or the state was not initialized. - */ -int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc) -z_streamp strm; -in_func in; -void FAR *in_desc; -out_func out; -void FAR *out_desc; -{ - struct inflate_state FAR *state; - z_const unsigned char FAR *next; /* next input */ - unsigned char FAR *put; /* next output */ - unsigned have, left; /* available input and output */ - unsigned long hold; /* bit buffer */ - unsigned bits; /* bits in bit buffer */ - unsigned copy; /* number of stored or match bytes to copy */ - unsigned char FAR *from; /* where to copy match bytes from */ - code here; /* current decoding table entry */ - code last; /* parent table entry */ - unsigned len; /* length to copy for repeats, bits to drop */ - int ret; /* return code */ - static const unsigned short order[19] = /* permutation of code lengths */ - {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - - /* Check that the strm exists and that the state was initialized */ - if (strm == Z_NULL || strm->state == Z_NULL) - return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - - /* Reset the state */ - strm->msg = Z_NULL; - state->mode = TYPE; - state->last = 0; - state->whave = 0; - next = strm->next_in; - have = next != Z_NULL ? strm->avail_in : 0; - hold = 0; - bits = 0; - put = state->window; - left = state->wsize; - - /* Inflate until end of block marked as last */ - for (;;) - switch (state->mode) { - case TYPE: - /* determine and dispatch block type */ - if (state->last) { - BYTEBITS(); - state->mode = DONE; - break; - } - NEEDBITS(3); - state->last = BITS(1); - DROPBITS(1); - switch (BITS(2)) { - case 0: /* stored block */ - Tracev((stderr, "inflate: stored block%s\n", - state->last ? " (last)" : "")); - state->mode = STORED; - break; - case 1: /* fixed block */ - fixedtables(state); - Tracev((stderr, "inflate: fixed codes block%s\n", - state->last ? " (last)" : "")); - state->mode = LEN; /* decode codes */ - break; - case 2: /* dynamic block */ - Tracev((stderr, "inflate: dynamic codes block%s\n", - state->last ? " (last)" : "")); - state->mode = TABLE; - break; - case 3: - strm->msg = (char *)"invalid block type"; - state->mode = BAD; - } - DROPBITS(2); - break; - - case STORED: - /* get and verify stored block length */ - BYTEBITS(); /* go to byte boundary */ - NEEDBITS(32); - if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { - strm->msg = (char *)"invalid stored block lengths"; - state->mode = BAD; - break; - } - state->length = (unsigned)hold & 0xffff; - Tracev((stderr, "inflate: stored length %u\n", - state->length)); - INITBITS(); - - /* copy stored block from input to output */ - while (state->length != 0) { - copy = state->length; - PULL(); - ROOM(); - if (copy > have) copy = have; - if (copy > left) copy = left; - zmemcpy(put, next, copy); - have -= copy; - next += copy; - left -= copy; - put += copy; - state->length -= copy; - } - Tracev((stderr, "inflate: stored end\n")); - state->mode = TYPE; - break; - - case TABLE: - /* get dynamic table entries descriptor */ - NEEDBITS(14); - state->nlen = BITS(5) + 257; - DROPBITS(5); - state->ndist = BITS(5) + 1; - DROPBITS(5); - state->ncode = BITS(4) + 4; - DROPBITS(4); -#ifndef PKZIP_BUG_WORKAROUND - if (state->nlen > 286 || state->ndist > 30) { - strm->msg = (char *)"too many length or distance symbols"; - state->mode = BAD; - break; - } -#endif - Tracev((stderr, "inflate: table sizes ok\n")); - - /* get code length code lengths (not a typo) */ - state->have = 0; - while (state->have < state->ncode) { - NEEDBITS(3); - state->lens[order[state->have++]] = (unsigned short)BITS(3); - DROPBITS(3); - } - while (state->have < 19) - state->lens[order[state->have++]] = 0; - state->next = state->codes; - state->lencode = (code const FAR *)(state->next); - state->lenbits = 7; - ret = inflate_table(CODES, state->lens, 19, &(state->next), - &(state->lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid code lengths set"; - state->mode = BAD; - break; - } - Tracev((stderr, "inflate: code lengths ok\n")); - - /* get length and distance code code lengths */ - state->have = 0; - while (state->have < state->nlen + state->ndist) { - for (;;) { - here = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(here.bits) <= bits) break; - PULLBYTE(); - } - if (here.val < 16) { - DROPBITS(here.bits); - state->lens[state->have++] = here.val; - } - else { - if (here.val == 16) { - NEEDBITS(here.bits + 2); - DROPBITS(here.bits); - if (state->have == 0) { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - len = (unsigned)(state->lens[state->have - 1]); - copy = 3 + BITS(2); - DROPBITS(2); - } - else if (here.val == 17) { - NEEDBITS(here.bits + 3); - DROPBITS(here.bits); - len = 0; - copy = 3 + BITS(3); - DROPBITS(3); - } - else { - NEEDBITS(here.bits + 7); - DROPBITS(here.bits); - len = 0; - copy = 11 + BITS(7); - DROPBITS(7); - } - if (state->have + copy > state->nlen + state->ndist) { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - while (copy--) - state->lens[state->have++] = (unsigned short)len; - } - } - - /* handle error breaks in while */ - if (state->mode == BAD) break; - - /* check for end-of-block code (better have one) */ - if (state->lens[256] == 0) { - strm->msg = (char *)"invalid code -- missing end-of-block"; - state->mode = BAD; - break; - } - - /* build code tables -- note: do not change the lenbits or distbits - values here (9 and 6) without reading the comments in inftrees.h - concerning the ENOUGH constants, which depend on those values */ - state->next = state->codes; - state->lencode = (code const FAR *)(state->next); - state->lenbits = 9; - ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), - &(state->lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid literal/lengths set"; - state->mode = BAD; - break; - } - state->distcode = (code const FAR *)(state->next); - state->distbits = 6; - ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, - &(state->next), &(state->distbits), state->work); - if (ret) { - strm->msg = (char *)"invalid distances set"; - state->mode = BAD; - break; - } - Tracev((stderr, "inflate: codes ok\n")); - state->mode = LEN; - /* fallthrough */ - - case LEN: - /* use inflate_fast() if we have enough input and output */ - if (have >= 6 && left >= 258) { - RESTORE(); - if (state->whave < state->wsize) - state->whave = state->wsize - left; - inflate_fast(strm, state->wsize); - LOAD(); - break; - } - - /* get a literal, length, or end-of-block code */ - for (;;) { - here = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(here.bits) <= bits) break; - PULLBYTE(); - } - if (here.op && (here.op & 0xf0) == 0) { - last = here; - for (;;) { - here = state->lencode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + here.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - } - DROPBITS(here.bits); - state->length = (unsigned)here.val; - - /* process literal */ - if (here.op == 0) { - Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? - "inflate: literal '%c'\n" : - "inflate: literal 0x%02x\n", here.val)); - ROOM(); - *put++ = (unsigned char)(state->length); - left--; - state->mode = LEN; - break; - } - - /* process end of block */ - if (here.op & 32) { - Tracevv((stderr, "inflate: end of block\n")); - state->mode = TYPE; - break; - } - - /* invalid code */ - if (here.op & 64) { - strm->msg = (char *)"invalid literal/length code"; - state->mode = BAD; - break; - } - - /* length code -- get extra bits, if any */ - state->extra = (unsigned)(here.op) & 15; - if (state->extra != 0) { - NEEDBITS(state->extra); - state->length += BITS(state->extra); - DROPBITS(state->extra); - } - Tracevv((stderr, "inflate: length %u\n", state->length)); - - /* get distance code */ - for (;;) { - here = state->distcode[BITS(state->distbits)]; - if ((unsigned)(here.bits) <= bits) break; - PULLBYTE(); - } - if ((here.op & 0xf0) == 0) { - last = here; - for (;;) { - here = state->distcode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + here.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - } - DROPBITS(here.bits); - if (here.op & 64) { - strm->msg = (char *)"invalid distance code"; - state->mode = BAD; - break; - } - state->offset = (unsigned)here.val; - - /* get distance extra bits, if any */ - state->extra = (unsigned)(here.op) & 15; - if (state->extra != 0) { - NEEDBITS(state->extra); - state->offset += BITS(state->extra); - DROPBITS(state->extra); - } - if (state->offset > state->wsize - (state->whave < state->wsize ? - left : 0)) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } - Tracevv((stderr, "inflate: distance %u\n", state->offset)); - - /* copy match from window to output */ - do { - ROOM(); - copy = state->wsize - state->offset; - if (copy < left) { - from = put + copy; - copy = left - copy; - } - else { - from = put - state->offset; - copy = left; - } - if (copy > state->length) copy = state->length; - state->length -= copy; - left -= copy; - do { - *put++ = *from++; - } while (--copy); - } while (state->length != 0); - break; - - case DONE: - /* inflate stream terminated properly -- write leftover output */ - ret = Z_STREAM_END; - if (left < state->wsize) { - if (out(out_desc, state->window, state->wsize - left)) - ret = Z_BUF_ERROR; - } - goto inf_leave; - - case BAD: - ret = Z_DATA_ERROR; - goto inf_leave; - - default: /* can't happen, but makes compilers happy */ - ret = Z_STREAM_ERROR; - goto inf_leave; - } - - /* Return unused input */ - inf_leave: - strm->next_in = next; - strm->avail_in = have; - return ret; -} - -int ZEXPORT inflateBackEnd(strm) -z_streamp strm; -{ - if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) - return Z_STREAM_ERROR; - ZFREE(strm, strm->state); - strm->state = Z_NULL; - Tracev((stderr, "inflate: end\n")); - return Z_OK; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/inffast.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/inffast.c deleted file mode 100644 index 1fec7f3..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/inffast.c +++ /dev/null @@ -1,323 +0,0 @@ -/* inffast.c -- fast decoding - * Copyright (C) 1995-2017 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "inftrees.h" -#include "inflate.h" -#include "inffast.h" - -#ifdef ASMINF -# pragma message("Assembler code may have bugs -- use at your own risk") -#else - -/* - Decode literal, length, and distance codes and write out the resulting - literal and match bytes until either not enough input or output is - available, an end-of-block is encountered, or a data error is encountered. - When large enough input and output buffers are supplied to inflate(), for - example, a 16K input buffer and a 64K output buffer, more than 95% of the - inflate execution time is spent in this routine. - - Entry assumptions: - - state->mode == LEN - strm->avail_in >= 6 - strm->avail_out >= 258 - start >= strm->avail_out - state->bits < 8 - - On return, state->mode is one of: - - LEN -- ran out of enough output space or enough available input - TYPE -- reached end of block code, inflate() to interpret next block - BAD -- error in block data - - Notes: - - - The maximum input bits used by a length/distance pair is 15 bits for the - length code, 5 bits for the length extra, 15 bits for the distance code, - and 13 bits for the distance extra. This totals 48 bits, or six bytes. - Therefore if strm->avail_in >= 6, then there is enough input to avoid - checking for available input while decoding. - - - The maximum bytes that a single length/distance pair can output is 258 - bytes, which is the maximum length that can be coded. inflate_fast() - requires strm->avail_out >= 258 for each loop to avoid checking for - output space. - */ -void ZLIB_INTERNAL inflate_fast(strm, start) -z_streamp strm; -unsigned start; /* inflate()'s starting value for strm->avail_out */ -{ - struct inflate_state FAR *state; - z_const unsigned char FAR *in; /* local strm->next_in */ - z_const unsigned char FAR *last; /* have enough input while in < last */ - unsigned char FAR *out; /* local strm->next_out */ - unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ - unsigned char FAR *end; /* while out < end, enough space available */ -#ifdef INFLATE_STRICT - unsigned dmax; /* maximum distance from zlib header */ -#endif - unsigned wsize; /* window size or zero if not using window */ - unsigned whave; /* valid bytes in the window */ - unsigned wnext; /* window write index */ - unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */ - unsigned long hold; /* local strm->hold */ - unsigned bits; /* local strm->bits */ - code const FAR *lcode; /* local strm->lencode */ - code const FAR *dcode; /* local strm->distcode */ - unsigned lmask; /* mask for first level of length codes */ - unsigned dmask; /* mask for first level of distance codes */ - code const *here; /* retrieved table entry */ - unsigned op; /* code bits, operation, extra bits, or */ - /* window position, window bytes to copy */ - unsigned len; /* match length, unused bytes */ - unsigned dist; /* match distance */ - unsigned char FAR *from; /* where to copy match from */ - - /* copy state to local variables */ - state = (struct inflate_state FAR *)strm->state; - in = strm->next_in; - last = in + (strm->avail_in - 5); - out = strm->next_out; - beg = out - (start - strm->avail_out); - end = out + (strm->avail_out - 257); -#ifdef INFLATE_STRICT - dmax = state->dmax; -#endif - wsize = state->wsize; - whave = state->whave; - wnext = state->wnext; - window = state->window; - hold = state->hold; - bits = state->bits; - lcode = state->lencode; - dcode = state->distcode; - lmask = (1U << state->lenbits) - 1; - dmask = (1U << state->distbits) - 1; - - /* decode literals and length/distances until end-of-block or not enough - input data or output space */ - do { - if (bits < 15) { - hold += (unsigned long)(*in++) << bits; - bits += 8; - hold += (unsigned long)(*in++) << bits; - bits += 8; - } - here = lcode + (hold & lmask); - dolen: - op = (unsigned)(here->bits); - hold >>= op; - bits -= op; - op = (unsigned)(here->op); - if (op == 0) { /* literal */ - Tracevv((stderr, here->val >= 0x20 && here->val < 0x7f ? - "inflate: literal '%c'\n" : - "inflate: literal 0x%02x\n", here->val)); - *out++ = (unsigned char)(here->val); - } - else if (op & 16) { /* length base */ - len = (unsigned)(here->val); - op &= 15; /* number of extra bits */ - if (op) { - if (bits < op) { - hold += (unsigned long)(*in++) << bits; - bits += 8; - } - len += (unsigned)hold & ((1U << op) - 1); - hold >>= op; - bits -= op; - } - Tracevv((stderr, "inflate: length %u\n", len)); - if (bits < 15) { - hold += (unsigned long)(*in++) << bits; - bits += 8; - hold += (unsigned long)(*in++) << bits; - bits += 8; - } - here = dcode + (hold & dmask); - dodist: - op = (unsigned)(here->bits); - hold >>= op; - bits -= op; - op = (unsigned)(here->op); - if (op & 16) { /* distance base */ - dist = (unsigned)(here->val); - op &= 15; /* number of extra bits */ - if (bits < op) { - hold += (unsigned long)(*in++) << bits; - bits += 8; - if (bits < op) { - hold += (unsigned long)(*in++) << bits; - bits += 8; - } - } - dist += (unsigned)hold & ((1U << op) - 1); -#ifdef INFLATE_STRICT - if (dist > dmax) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } -#endif - hold >>= op; - bits -= op; - Tracevv((stderr, "inflate: distance %u\n", dist)); - op = (unsigned)(out - beg); /* max distance in output */ - if (dist > op) { /* see if copy from window */ - op = dist - op; /* distance back in window */ - if (op > whave) { - if (state->sane) { - strm->msg = - (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } -#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR - if (len <= op - whave) { - do { - *out++ = 0; - } while (--len); - continue; - } - len -= op - whave; - do { - *out++ = 0; - } while (--op > whave); - if (op == 0) { - from = out - dist; - do { - *out++ = *from++; - } while (--len); - continue; - } -#endif - } - from = window; - if (wnext == 0) { /* very common case */ - from += wsize - op; - if (op < len) { /* some from window */ - len -= op; - do { - *out++ = *from++; - } while (--op); - from = out - dist; /* rest from output */ - } - } - else if (wnext < op) { /* wrap around window */ - from += wsize + wnext - op; - op -= wnext; - if (op < len) { /* some from end of window */ - len -= op; - do { - *out++ = *from++; - } while (--op); - from = window; - if (wnext < len) { /* some from start of window */ - op = wnext; - len -= op; - do { - *out++ = *from++; - } while (--op); - from = out - dist; /* rest from output */ - } - } - } - else { /* contiguous in window */ - from += wnext - op; - if (op < len) { /* some from window */ - len -= op; - do { - *out++ = *from++; - } while (--op); - from = out - dist; /* rest from output */ - } - } - while (len > 2) { - *out++ = *from++; - *out++ = *from++; - *out++ = *from++; - len -= 3; - } - if (len) { - *out++ = *from++; - if (len > 1) - *out++ = *from++; - } - } - else { - from = out - dist; /* copy direct from output */ - do { /* minimum length is three */ - *out++ = *from++; - *out++ = *from++; - *out++ = *from++; - len -= 3; - } while (len > 2); - if (len) { - *out++ = *from++; - if (len > 1) - *out++ = *from++; - } - } - } - else if ((op & 64) == 0) { /* 2nd level distance code */ - here = dcode + here->val + (hold & ((1U << op) - 1)); - goto dodist; - } - else { - strm->msg = (char *)"invalid distance code"; - state->mode = BAD; - break; - } - } - else if ((op & 64) == 0) { /* 2nd level length code */ - here = lcode + here->val + (hold & ((1U << op) - 1)); - goto dolen; - } - else if (op & 32) { /* end-of-block */ - Tracevv((stderr, "inflate: end of block\n")); - state->mode = TYPE; - break; - } - else { - strm->msg = (char *)"invalid literal/length code"; - state->mode = BAD; - break; - } - } while (in < last && out < end); - - /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ - len = bits >> 3; - in -= len; - bits -= len << 3; - hold &= (1U << bits) - 1; - - /* update state and return */ - strm->next_in = in; - strm->next_out = out; - strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last)); - strm->avail_out = (unsigned)(out < end ? - 257 + (end - out) : 257 - (out - end)); - state->hold = hold; - state->bits = bits; - return; -} - -/* - inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe): - - Using bit fields for code structure - - Different op definition to avoid & for extra bits (do & for table bits) - - Three separate decoding do-loops for direct, window, and wnext == 0 - - Special case for distance > 1 copies to do overlapped load and store copy - - Explicit branch predictions (based on measured branch probabilities) - - Deferring match copy and interspersed it with decoding subsequent codes - - Swapping literal/length else - - Swapping window/direct else - - Larger unrolled copy loops (three is about right) - - Moving len -= 3 statement into middle of loop - */ - -#endif /* !ASMINF */ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/inffast.h b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/inffast.h deleted file mode 100644 index e5c1aa4..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/inffast.h +++ /dev/null @@ -1,11 +0,0 @@ -/* inffast.h -- header to use inffast.c - * Copyright (C) 1995-2003, 2010 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/inffixed.h b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/inffixed.h deleted file mode 100644 index d628327..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/inffixed.h +++ /dev/null @@ -1,94 +0,0 @@ - /* inffixed.h -- table for decoding fixed codes - * Generated automatically by makefixed(). - */ - - /* WARNING: this file should *not* be used by applications. - It is part of the implementation of this library and is - subject to change. Applications should only use zlib.h. - */ - - static const code lenfix[512] = { - {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, - {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, - {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, - {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, - {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, - {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, - {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, - {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, - {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, - {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, - {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, - {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, - {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, - {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, - {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, - {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, - {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, - {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, - {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, - {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, - {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, - {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, - {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, - {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, - {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, - {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, - {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, - {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, - {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, - {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, - {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, - {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, - {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55}, - {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, - {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, - {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, - {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, - {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, - {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, - {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, - {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, - {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, - {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, - {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, - {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, - {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, - {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, - {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, - {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, - {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, - {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51}, - {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, - {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, - {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, - {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, - {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, - {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, - {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, - {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, - {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258}, - {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, - {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, - {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, - {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, - {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, - {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, - {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, - {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, - {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, - {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, - {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, - {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, - {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, - {0,9,255} - }; - - static const code distfix[32] = { - {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, - {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, - {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385}, - {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, - {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, - {22,5,193},{64,5,0} - }; diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/inflate.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/inflate.c deleted file mode 100644 index 7be8c63..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/inflate.c +++ /dev/null @@ -1,1592 +0,0 @@ -/* inflate.c -- zlib decompression - * Copyright (C) 1995-2022 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - * Change history: - * - * 1.2.beta0 24 Nov 2002 - * - First version -- complete rewrite of inflate to simplify code, avoid - * creation of window when not needed, minimize use of window when it is - * needed, make inffast.c even faster, implement gzip decoding, and to - * improve code readability and style over the previous zlib inflate code - * - * 1.2.beta1 25 Nov 2002 - * - Use pointers for available input and output checking in inffast.c - * - Remove input and output counters in inffast.c - * - Change inffast.c entry and loop from avail_in >= 7 to >= 6 - * - Remove unnecessary second byte pull from length extra in inffast.c - * - Unroll direct copy to three copies per loop in inffast.c - * - * 1.2.beta2 4 Dec 2002 - * - Change external routine names to reduce potential conflicts - * - Correct filename to inffixed.h for fixed tables in inflate.c - * - Make hbuf[] unsigned char to match parameter type in inflate.c - * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset) - * to avoid negation problem on Alphas (64 bit) in inflate.c - * - * 1.2.beta3 22 Dec 2002 - * - Add comments on state->bits assertion in inffast.c - * - Add comments on op field in inftrees.h - * - Fix bug in reuse of allocated window after inflateReset() - * - Remove bit fields--back to byte structure for speed - * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths - * - Change post-increments to pre-increments in inflate_fast(), PPC biased? - * - Add compile time option, POSTINC, to use post-increments instead (Intel?) - * - Make MATCH copy in inflate() much faster for when inflate_fast() not used - * - Use local copies of stream next and avail values, as well as local bit - * buffer and bit count in inflate()--for speed when inflate_fast() not used - * - * 1.2.beta4 1 Jan 2003 - * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings - * - Move a comment on output buffer sizes from inffast.c to inflate.c - * - Add comments in inffast.c to introduce the inflate_fast() routine - * - Rearrange window copies in inflate_fast() for speed and simplification - * - Unroll last copy for window match in inflate_fast() - * - Use local copies of window variables in inflate_fast() for speed - * - Pull out common wnext == 0 case for speed in inflate_fast() - * - Make op and len in inflate_fast() unsigned for consistency - * - Add FAR to lcode and dcode declarations in inflate_fast() - * - Simplified bad distance check in inflate_fast() - * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new - * source file infback.c to provide a call-back interface to inflate for - * programs like gzip and unzip -- uses window as output buffer to avoid - * window copying - * - * 1.2.beta5 1 Jan 2003 - * - Improved inflateBack() interface to allow the caller to provide initial - * input in strm. - * - Fixed stored blocks bug in inflateBack() - * - * 1.2.beta6 4 Jan 2003 - * - Added comments in inffast.c on effectiveness of POSTINC - * - Typecasting all around to reduce compiler warnings - * - Changed loops from while (1) or do {} while (1) to for (;;), again to - * make compilers happy - * - Changed type of window in inflateBackInit() to unsigned char * - * - * 1.2.beta7 27 Jan 2003 - * - Changed many types to unsigned or unsigned short to avoid warnings - * - Added inflateCopy() function - * - * 1.2.0 9 Mar 2003 - * - Changed inflateBack() interface to provide separate opaque descriptors - * for the in() and out() functions - * - Changed inflateBack() argument and in_func typedef to swap the length - * and buffer address return values for the input function - * - Check next_in and next_out for Z_NULL on entry to inflate() - * - * The history for versions after 1.2.0 are in ChangeLog in zlib distribution. - */ - -#include "zutil.h" -#include "inftrees.h" -#include "inflate.h" -#include "inffast.h" - -#ifdef MAKEFIXED -# ifndef BUILDFIXED -# define BUILDFIXED -# endif -#endif - -/* function prototypes */ -local int inflateStateCheck OF((z_streamp strm)); -local void fixedtables OF((struct inflate_state FAR *state)); -local int updatewindow OF((z_streamp strm, const unsigned char FAR *end, - unsigned copy)); -#ifdef BUILDFIXED - void makefixed OF((void)); -#endif -local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf, - unsigned len)); - -local int inflateStateCheck(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - if (strm == Z_NULL || - strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) - return 1; - state = (struct inflate_state FAR *)strm->state; - if (state == Z_NULL || state->strm != strm || - state->mode < HEAD || state->mode > SYNC) - return 1; - return 0; -} - -int ZEXPORT inflateResetKeep(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - - if (inflateStateCheck(strm)) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - strm->total_in = strm->total_out = state->total = 0; - strm->msg = Z_NULL; - if (state->wrap) /* to support ill-conceived Java test suite */ - strm->adler = state->wrap & 1; - state->mode = HEAD; - state->last = 0; - state->havedict = 0; - state->flags = -1; - state->dmax = 32768U; - state->head = Z_NULL; - state->hold = 0; - state->bits = 0; - state->lencode = state->distcode = state->next = state->codes; - state->sane = 1; - state->back = -1; - Tracev((stderr, "inflate: reset\n")); - return Z_OK; -} - -int ZEXPORT inflateReset(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - - if (inflateStateCheck(strm)) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - state->wsize = 0; - state->whave = 0; - state->wnext = 0; - return inflateResetKeep(strm); -} - -int ZEXPORT inflateReset2(strm, windowBits) -z_streamp strm; -int windowBits; -{ - int wrap; - struct inflate_state FAR *state; - - /* get the state */ - if (inflateStateCheck(strm)) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - - /* extract wrap request from windowBits parameter */ - if (windowBits < 0) { - wrap = 0; - windowBits = -windowBits; - } - else { - wrap = (windowBits >> 4) + 5; -#ifdef GUNZIP - if (windowBits < 48) - windowBits &= 15; -#endif - } - - /* set number of window bits, free window if different */ - if (windowBits && (windowBits < 8 || windowBits > 15)) - return Z_STREAM_ERROR; - if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) { - ZFREE(strm, state->window); - state->window = Z_NULL; - } - - /* update state and reset the rest of it */ - state->wrap = wrap; - state->wbits = (unsigned)windowBits; - return inflateReset(strm); -} - -int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size) -z_streamp strm; -int windowBits; -const char *version; -int stream_size; -{ - int ret; - struct inflate_state FAR *state; - - if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || - stream_size != (int)(sizeof(z_stream))) - return Z_VERSION_ERROR; - if (strm == Z_NULL) return Z_STREAM_ERROR; - strm->msg = Z_NULL; /* in case we return an error */ - if (strm->zalloc == (alloc_func)0) { -#ifdef Z_SOLO - return Z_STREAM_ERROR; -#else - strm->zalloc = zcalloc; - strm->opaque = (voidpf)0; -#endif - } - if (strm->zfree == (free_func)0) -#ifdef Z_SOLO - return Z_STREAM_ERROR; -#else - strm->zfree = zcfree; -#endif - state = (struct inflate_state FAR *) - ZALLOC(strm, 1, sizeof(struct inflate_state)); - if (state == Z_NULL) return Z_MEM_ERROR; - Tracev((stderr, "inflate: allocated\n")); - strm->state = (struct internal_state FAR *)state; - state->strm = strm; - state->window = Z_NULL; - state->mode = HEAD; /* to pass state test in inflateReset2() */ - ret = inflateReset2(strm, windowBits); - if (ret != Z_OK) { - ZFREE(strm, state); - strm->state = Z_NULL; - } - return ret; -} - -int ZEXPORT inflateInit_(strm, version, stream_size) -z_streamp strm; -const char *version; -int stream_size; -{ - return inflateInit2_(strm, DEF_WBITS, version, stream_size); -} - -int ZEXPORT inflatePrime(strm, bits, value) -z_streamp strm; -int bits; -int value; -{ - struct inflate_state FAR *state; - - if (inflateStateCheck(strm)) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (bits < 0) { - state->hold = 0; - state->bits = 0; - return Z_OK; - } - if (bits > 16 || state->bits + (uInt)bits > 32) return Z_STREAM_ERROR; - value &= (1L << bits) - 1; - state->hold += (unsigned)value << state->bits; - state->bits += (uInt)bits; - return Z_OK; -} - -/* - Return state with length and distance decoding tables and index sizes set to - fixed code decoding. Normally this returns fixed tables from inffixed.h. - If BUILDFIXED is defined, then instead this routine builds the tables the - first time it's called, and returns those tables the first time and - thereafter. This reduces the size of the code by about 2K bytes, in - exchange for a little execution time. However, BUILDFIXED should not be - used for threaded applications, since the rewriting of the tables and virgin - may not be thread-safe. - */ -local void fixedtables(state) -struct inflate_state FAR *state; -{ -#ifdef BUILDFIXED - static int virgin = 1; - static code *lenfix, *distfix; - static code fixed[544]; - - /* build fixed huffman tables if first call (may not be thread safe) */ - if (virgin) { - unsigned sym, bits; - static code *next; - - /* literal/length table */ - sym = 0; - while (sym < 144) state->lens[sym++] = 8; - while (sym < 256) state->lens[sym++] = 9; - while (sym < 280) state->lens[sym++] = 7; - while (sym < 288) state->lens[sym++] = 8; - next = fixed; - lenfix = next; - bits = 9; - inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); - - /* distance table */ - sym = 0; - while (sym < 32) state->lens[sym++] = 5; - distfix = next; - bits = 5; - inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); - - /* do this just once */ - virgin = 0; - } -#else /* !BUILDFIXED */ -# include "inffixed.h" -#endif /* BUILDFIXED */ - state->lencode = lenfix; - state->lenbits = 9; - state->distcode = distfix; - state->distbits = 5; -} - -#ifdef MAKEFIXED -#include - -/* - Write out the inffixed.h that is #include'd above. Defining MAKEFIXED also - defines BUILDFIXED, so the tables are built on the fly. makefixed() writes - those tables to stdout, which would be piped to inffixed.h. A small program - can simply call makefixed to do this: - - void makefixed(void); - - int main(void) - { - makefixed(); - return 0; - } - - Then that can be linked with zlib built with MAKEFIXED defined and run: - - a.out > inffixed.h - */ -void makefixed() -{ - unsigned low, size; - struct inflate_state state; - - fixedtables(&state); - puts(" /* inffixed.h -- table for decoding fixed codes"); - puts(" * Generated automatically by makefixed()."); - puts(" */"); - puts(""); - puts(" /* WARNING: this file should *not* be used by applications."); - puts(" It is part of the implementation of this library and is"); - puts(" subject to change. Applications should only use zlib.h."); - puts(" */"); - puts(""); - size = 1U << 9; - printf(" static const code lenfix[%u] = {", size); - low = 0; - for (;;) { - if ((low % 7) == 0) printf("\n "); - printf("{%u,%u,%d}", (low & 127) == 99 ? 64 : state.lencode[low].op, - state.lencode[low].bits, state.lencode[low].val); - if (++low == size) break; - putchar(','); - } - puts("\n };"); - size = 1U << 5; - printf("\n static const code distfix[%u] = {", size); - low = 0; - for (;;) { - if ((low % 6) == 0) printf("\n "); - printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits, - state.distcode[low].val); - if (++low == size) break; - putchar(','); - } - puts("\n };"); -} -#endif /* MAKEFIXED */ - -/* - Update the window with the last wsize (normally 32K) bytes written before - returning. If window does not exist yet, create it. This is only called - when a window is already in use, or when output has been written during this - inflate call, but the end of the deflate stream has not been reached yet. - It is also called to create a window for dictionary data when a dictionary - is loaded. - - Providing output buffers larger than 32K to inflate() should provide a speed - advantage, since only the last 32K of output is copied to the sliding window - upon return from inflate(), and since all distances after the first 32K of - output will fall in the output data, making match copies simpler and faster. - The advantage may be dependent on the size of the processor's data caches. - */ -local int updatewindow(strm, end, copy) -z_streamp strm; -const Bytef *end; -unsigned copy; -{ - struct inflate_state FAR *state; - unsigned dist; - - state = (struct inflate_state FAR *)strm->state; - - /* if it hasn't been done already, allocate space for the window */ - if (state->window == Z_NULL) { - state->window = (unsigned char FAR *) - ZALLOC(strm, 1U << state->wbits, - sizeof(unsigned char)); - if (state->window == Z_NULL) return 1; - } - - /* if window not in use yet, initialize */ - if (state->wsize == 0) { - state->wsize = 1U << state->wbits; - state->wnext = 0; - state->whave = 0; - } - - /* copy state->wsize or less output bytes into the circular window */ - if (copy >= state->wsize) { - zmemcpy(state->window, end - state->wsize, state->wsize); - state->wnext = 0; - state->whave = state->wsize; - } - else { - dist = state->wsize - state->wnext; - if (dist > copy) dist = copy; - zmemcpy(state->window + state->wnext, end - copy, dist); - copy -= dist; - if (copy) { - zmemcpy(state->window, end - copy, copy); - state->wnext = copy; - state->whave = state->wsize; - } - else { - state->wnext += dist; - if (state->wnext == state->wsize) state->wnext = 0; - if (state->whave < state->wsize) state->whave += dist; - } - } - return 0; -} - -/* Macros for inflate(): */ - -/* check function to use adler32() for zlib or crc32() for gzip */ -#ifdef GUNZIP -# define UPDATE_CHECK(check, buf, len) \ - (state->flags ? crc32(check, buf, len) : adler32(check, buf, len)) -#else -# define UPDATE_CHECK(check, buf, len) adler32(check, buf, len) -#endif - -/* check macros for header crc */ -#ifdef GUNZIP -# define CRC2(check, word) \ - do { \ - hbuf[0] = (unsigned char)(word); \ - hbuf[1] = (unsigned char)((word) >> 8); \ - check = crc32(check, hbuf, 2); \ - } while (0) - -# define CRC4(check, word) \ - do { \ - hbuf[0] = (unsigned char)(word); \ - hbuf[1] = (unsigned char)((word) >> 8); \ - hbuf[2] = (unsigned char)((word) >> 16); \ - hbuf[3] = (unsigned char)((word) >> 24); \ - check = crc32(check, hbuf, 4); \ - } while (0) -#endif - -/* Load registers with state in inflate() for speed */ -#define LOAD() \ - do { \ - put = strm->next_out; \ - left = strm->avail_out; \ - next = strm->next_in; \ - have = strm->avail_in; \ - hold = state->hold; \ - bits = state->bits; \ - } while (0) - -/* Restore state from registers in inflate() */ -#define RESTORE() \ - do { \ - strm->next_out = put; \ - strm->avail_out = left; \ - strm->next_in = next; \ - strm->avail_in = have; \ - state->hold = hold; \ - state->bits = bits; \ - } while (0) - -/* Clear the input bit accumulator */ -#define INITBITS() \ - do { \ - hold = 0; \ - bits = 0; \ - } while (0) - -/* Get a byte of input into the bit accumulator, or return from inflate() - if there is no input available. */ -#define PULLBYTE() \ - do { \ - if (have == 0) goto inf_leave; \ - have--; \ - hold += (unsigned long)(*next++) << bits; \ - bits += 8; \ - } while (0) - -/* Assure that there are at least n bits in the bit accumulator. If there is - not enough available input to do that, then return from inflate(). */ -#define NEEDBITS(n) \ - do { \ - while (bits < (unsigned)(n)) \ - PULLBYTE(); \ - } while (0) - -/* Return the low n bits of the bit accumulator (n < 16) */ -#define BITS(n) \ - ((unsigned)hold & ((1U << (n)) - 1)) - -/* Remove n bits from the bit accumulator */ -#define DROPBITS(n) \ - do { \ - hold >>= (n); \ - bits -= (unsigned)(n); \ - } while (0) - -/* Remove zero to seven bits as needed to go to a byte boundary */ -#define BYTEBITS() \ - do { \ - hold >>= bits & 7; \ - bits -= bits & 7; \ - } while (0) - -/* - inflate() uses a state machine to process as much input data and generate as - much output data as possible before returning. The state machine is - structured roughly as follows: - - for (;;) switch (state) { - ... - case STATEn: - if (not enough input data or output space to make progress) - return; - ... make progress ... - state = STATEm; - break; - ... - } - - so when inflate() is called again, the same case is attempted again, and - if the appropriate resources are provided, the machine proceeds to the - next state. The NEEDBITS() macro is usually the way the state evaluates - whether it can proceed or should return. NEEDBITS() does the return if - the requested bits are not available. The typical use of the BITS macros - is: - - NEEDBITS(n); - ... do something with BITS(n) ... - DROPBITS(n); - - where NEEDBITS(n) either returns from inflate() if there isn't enough - input left to load n bits into the accumulator, or it continues. BITS(n) - gives the low n bits in the accumulator. When done, DROPBITS(n) drops - the low n bits off the accumulator. INITBITS() clears the accumulator - and sets the number of available bits to zero. BYTEBITS() discards just - enough bits to put the accumulator on a byte boundary. After BYTEBITS() - and a NEEDBITS(8), then BITS(8) would return the next byte in the stream. - - NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return - if there is no input available. The decoding of variable length codes uses - PULLBYTE() directly in order to pull just enough bytes to decode the next - code, and no more. - - Some states loop until they get enough input, making sure that enough - state information is maintained to continue the loop where it left off - if NEEDBITS() returns in the loop. For example, want, need, and keep - would all have to actually be part of the saved state in case NEEDBITS() - returns: - - case STATEw: - while (want < need) { - NEEDBITS(n); - keep[want++] = BITS(n); - DROPBITS(n); - } - state = STATEx; - case STATEx: - - As shown above, if the next state is also the next case, then the break - is omitted. - - A state may also return if there is not enough output space available to - complete that state. Those states are copying stored data, writing a - literal byte, and copying a matching string. - - When returning, a "goto inf_leave" is used to update the total counters, - update the check value, and determine whether any progress has been made - during that inflate() call in order to return the proper return code. - Progress is defined as a change in either strm->avail_in or strm->avail_out. - When there is a window, goto inf_leave will update the window with the last - output written. If a goto inf_leave occurs in the middle of decompression - and there is no window currently, goto inf_leave will create one and copy - output to the window for the next call of inflate(). - - In this implementation, the flush parameter of inflate() only affects the - return code (per zlib.h). inflate() always writes as much as possible to - strm->next_out, given the space available and the provided input--the effect - documented in zlib.h of Z_SYNC_FLUSH. Furthermore, inflate() always defers - the allocation of and copying into a sliding window until necessary, which - provides the effect documented in zlib.h for Z_FINISH when the entire input - stream available. So the only thing the flush parameter actually does is: - when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it - will return Z_BUF_ERROR if it has not reached the end of the stream. - */ - -int ZEXPORT inflate(strm, flush) -z_streamp strm; -int flush; -{ - struct inflate_state FAR *state; - z_const unsigned char FAR *next; /* next input */ - unsigned char FAR *put; /* next output */ - unsigned have, left; /* available input and output */ - unsigned long hold; /* bit buffer */ - unsigned bits; /* bits in bit buffer */ - unsigned in, out; /* save starting available input and output */ - unsigned copy; /* number of stored or match bytes to copy */ - unsigned char FAR *from; /* where to copy match bytes from */ - code here; /* current decoding table entry */ - code last; /* parent table entry */ - unsigned len; /* length to copy for repeats, bits to drop */ - int ret; /* return code */ -#ifdef GUNZIP - unsigned char hbuf[4]; /* buffer for gzip header crc calculation */ -#endif - static const unsigned short order[19] = /* permutation of code lengths */ - {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - - if (inflateStateCheck(strm) || strm->next_out == Z_NULL || - (strm->next_in == Z_NULL && strm->avail_in != 0)) - return Z_STREAM_ERROR; - - state = (struct inflate_state FAR *)strm->state; - if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */ - LOAD(); - in = have; - out = left; - ret = Z_OK; - for (;;) - switch (state->mode) { - case HEAD: - if (state->wrap == 0) { - state->mode = TYPEDO; - break; - } - NEEDBITS(16); -#ifdef GUNZIP - if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */ - if (state->wbits == 0) - state->wbits = 15; - state->check = crc32(0L, Z_NULL, 0); - CRC2(state->check, hold); - INITBITS(); - state->mode = FLAGS; - break; - } - if (state->head != Z_NULL) - state->head->done = -1; - if (!(state->wrap & 1) || /* check if zlib header allowed */ -#else - if ( -#endif - ((BITS(8) << 8) + (hold >> 8)) % 31) { - strm->msg = (char *)"incorrect header check"; - state->mode = BAD; - break; - } - if (BITS(4) != Z_DEFLATED) { - strm->msg = (char *)"unknown compression method"; - state->mode = BAD; - break; - } - DROPBITS(4); - len = BITS(4) + 8; - if (state->wbits == 0) - state->wbits = len; - if (len > 15 || len > state->wbits) { - strm->msg = (char *)"invalid window size"; - state->mode = BAD; - break; - } - state->dmax = 1U << len; - state->flags = 0; /* indicate zlib header */ - Tracev((stderr, "inflate: zlib header ok\n")); - strm->adler = state->check = adler32(0L, Z_NULL, 0); - state->mode = hold & 0x200 ? DICTID : TYPE; - INITBITS(); - break; -#ifdef GUNZIP - case FLAGS: - NEEDBITS(16); - state->flags = (int)(hold); - if ((state->flags & 0xff) != Z_DEFLATED) { - strm->msg = (char *)"unknown compression method"; - state->mode = BAD; - break; - } - if (state->flags & 0xe000) { - strm->msg = (char *)"unknown header flags set"; - state->mode = BAD; - break; - } - if (state->head != Z_NULL) - state->head->text = (int)((hold >> 8) & 1); - if ((state->flags & 0x0200) && (state->wrap & 4)) - CRC2(state->check, hold); - INITBITS(); - state->mode = TIME; - /* fallthrough */ - case TIME: - NEEDBITS(32); - if (state->head != Z_NULL) - state->head->time = hold; - if ((state->flags & 0x0200) && (state->wrap & 4)) - CRC4(state->check, hold); - INITBITS(); - state->mode = OS; - /* fallthrough */ - case OS: - NEEDBITS(16); - if (state->head != Z_NULL) { - state->head->xflags = (int)(hold & 0xff); - state->head->os = (int)(hold >> 8); - } - if ((state->flags & 0x0200) && (state->wrap & 4)) - CRC2(state->check, hold); - INITBITS(); - state->mode = EXLEN; - /* fallthrough */ - case EXLEN: - if (state->flags & 0x0400) { - NEEDBITS(16); - state->length = (unsigned)(hold); - if (state->head != Z_NULL) - state->head->extra_len = (unsigned)hold; - if ((state->flags & 0x0200) && (state->wrap & 4)) - CRC2(state->check, hold); - INITBITS(); - } - else if (state->head != Z_NULL) - state->head->extra = Z_NULL; - state->mode = EXTRA; - /* fallthrough */ - case EXTRA: - if (state->flags & 0x0400) { - copy = state->length; - if (copy > have) copy = have; - if (copy) { - if (state->head != Z_NULL && - state->head->extra != Z_NULL) { - len = state->head->extra_len - state->length; - zmemcpy(state->head->extra + len, next, - len + copy > state->head->extra_max ? - state->head->extra_max - len : copy); - } - if ((state->flags & 0x0200) && (state->wrap & 4)) - state->check = crc32(state->check, next, copy); - have -= copy; - next += copy; - state->length -= copy; - } - if (state->length) goto inf_leave; - } - state->length = 0; - state->mode = NAME; - /* fallthrough */ - case NAME: - if (state->flags & 0x0800) { - if (have == 0) goto inf_leave; - copy = 0; - do { - len = (unsigned)(next[copy++]); - if (state->head != Z_NULL && - state->head->name != Z_NULL && - state->length < state->head->name_max) - state->head->name[state->length++] = (Bytef)len; - } while (len && copy < have); - if ((state->flags & 0x0200) && (state->wrap & 4)) - state->check = crc32(state->check, next, copy); - have -= copy; - next += copy; - if (len) goto inf_leave; - } - else if (state->head != Z_NULL) - state->head->name = Z_NULL; - state->length = 0; - state->mode = COMMENT; - /* fallthrough */ - case COMMENT: - if (state->flags & 0x1000) { - if (have == 0) goto inf_leave; - copy = 0; - do { - len = (unsigned)(next[copy++]); - if (state->head != Z_NULL && - state->head->comment != Z_NULL && - state->length < state->head->comm_max) - state->head->comment[state->length++] = (Bytef)len; - } while (len && copy < have); - if ((state->flags & 0x0200) && (state->wrap & 4)) - state->check = crc32(state->check, next, copy); - have -= copy; - next += copy; - if (len) goto inf_leave; - } - else if (state->head != Z_NULL) - state->head->comment = Z_NULL; - state->mode = HCRC; - /* fallthrough */ - case HCRC: - if (state->flags & 0x0200) { - NEEDBITS(16); - if ((state->wrap & 4) && hold != (state->check & 0xffff)) { - strm->msg = (char *)"header crc mismatch"; - state->mode = BAD; - break; - } - INITBITS(); - } - if (state->head != Z_NULL) { - state->head->hcrc = (int)((state->flags >> 9) & 1); - state->head->done = 1; - } - strm->adler = state->check = crc32(0L, Z_NULL, 0); - state->mode = TYPE; - break; -#endif - case DICTID: - NEEDBITS(32); - strm->adler = state->check = ZSWAP32(hold); - INITBITS(); - state->mode = DICT; - /* fallthrough */ - case DICT: - if (state->havedict == 0) { - RESTORE(); - return Z_NEED_DICT; - } - strm->adler = state->check = adler32(0L, Z_NULL, 0); - state->mode = TYPE; - /* fallthrough */ - case TYPE: - if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave; - /* fallthrough */ - case TYPEDO: - if (state->last) { - BYTEBITS(); - state->mode = CHECK; - break; - } - NEEDBITS(3); - state->last = BITS(1); - DROPBITS(1); - switch (BITS(2)) { - case 0: /* stored block */ - Tracev((stderr, "inflate: stored block%s\n", - state->last ? " (last)" : "")); - state->mode = STORED; - break; - case 1: /* fixed block */ - fixedtables(state); - Tracev((stderr, "inflate: fixed codes block%s\n", - state->last ? " (last)" : "")); - state->mode = LEN_; /* decode codes */ - if (flush == Z_TREES) { - DROPBITS(2); - goto inf_leave; - } - break; - case 2: /* dynamic block */ - Tracev((stderr, "inflate: dynamic codes block%s\n", - state->last ? " (last)" : "")); - state->mode = TABLE; - break; - case 3: - strm->msg = (char *)"invalid block type"; - state->mode = BAD; - } - DROPBITS(2); - break; - case STORED: - BYTEBITS(); /* go to byte boundary */ - NEEDBITS(32); - if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { - strm->msg = (char *)"invalid stored block lengths"; - state->mode = BAD; - break; - } - state->length = (unsigned)hold & 0xffff; - Tracev((stderr, "inflate: stored length %u\n", - state->length)); - INITBITS(); - state->mode = COPY_; - if (flush == Z_TREES) goto inf_leave; - /* fallthrough */ - case COPY_: - state->mode = COPY; - /* fallthrough */ - case COPY: - copy = state->length; - if (copy) { - if (copy > have) copy = have; - if (copy > left) copy = left; - if (copy == 0) goto inf_leave; - zmemcpy(put, next, copy); - have -= copy; - next += copy; - left -= copy; - put += copy; - state->length -= copy; - break; - } - Tracev((stderr, "inflate: stored end\n")); - state->mode = TYPE; - break; - case TABLE: - NEEDBITS(14); - state->nlen = BITS(5) + 257; - DROPBITS(5); - state->ndist = BITS(5) + 1; - DROPBITS(5); - state->ncode = BITS(4) + 4; - DROPBITS(4); -#ifndef PKZIP_BUG_WORKAROUND - if (state->nlen > 286 || state->ndist > 30) { - strm->msg = (char *)"too many length or distance symbols"; - state->mode = BAD; - break; - } -#endif - Tracev((stderr, "inflate: table sizes ok\n")); - state->have = 0; - state->mode = LENLENS; - /* fallthrough */ - case LENLENS: - while (state->have < state->ncode) { - NEEDBITS(3); - state->lens[order[state->have++]] = (unsigned short)BITS(3); - DROPBITS(3); - } - while (state->have < 19) - state->lens[order[state->have++]] = 0; - state->next = state->codes; - state->lencode = (const code FAR *)(state->next); - state->lenbits = 7; - ret = inflate_table(CODES, state->lens, 19, &(state->next), - &(state->lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid code lengths set"; - state->mode = BAD; - break; - } - Tracev((stderr, "inflate: code lengths ok\n")); - state->have = 0; - state->mode = CODELENS; - /* fallthrough */ - case CODELENS: - while (state->have < state->nlen + state->ndist) { - for (;;) { - here = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(here.bits) <= bits) break; - PULLBYTE(); - } - if (here.val < 16) { - DROPBITS(here.bits); - state->lens[state->have++] = here.val; - } - else { - if (here.val == 16) { - NEEDBITS(here.bits + 2); - DROPBITS(here.bits); - if (state->have == 0) { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - len = state->lens[state->have - 1]; - copy = 3 + BITS(2); - DROPBITS(2); - } - else if (here.val == 17) { - NEEDBITS(here.bits + 3); - DROPBITS(here.bits); - len = 0; - copy = 3 + BITS(3); - DROPBITS(3); - } - else { - NEEDBITS(here.bits + 7); - DROPBITS(here.bits); - len = 0; - copy = 11 + BITS(7); - DROPBITS(7); - } - if (state->have + copy > state->nlen + state->ndist) { - strm->msg = (char *)"invalid bit length repeat"; - state->mode = BAD; - break; - } - while (copy--) - state->lens[state->have++] = (unsigned short)len; - } - } - - /* handle error breaks in while */ - if (state->mode == BAD) break; - - /* check for end-of-block code (better have one) */ - if (state->lens[256] == 0) { - strm->msg = (char *)"invalid code -- missing end-of-block"; - state->mode = BAD; - break; - } - - /* build code tables -- note: do not change the lenbits or distbits - values here (9 and 6) without reading the comments in inftrees.h - concerning the ENOUGH constants, which depend on those values */ - state->next = state->codes; - state->lencode = (const code FAR *)(state->next); - state->lenbits = 9; - ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), - &(state->lenbits), state->work); - if (ret) { - strm->msg = (char *)"invalid literal/lengths set"; - state->mode = BAD; - break; - } - state->distcode = (const code FAR *)(state->next); - state->distbits = 6; - ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, - &(state->next), &(state->distbits), state->work); - if (ret) { - strm->msg = (char *)"invalid distances set"; - state->mode = BAD; - break; - } - Tracev((stderr, "inflate: codes ok\n")); - state->mode = LEN_; - if (flush == Z_TREES) goto inf_leave; - /* fallthrough */ - case LEN_: - state->mode = LEN; - /* fallthrough */ - case LEN: - if (have >= 6 && left >= 258) { - RESTORE(); - inflate_fast(strm, out); - LOAD(); - if (state->mode == TYPE) - state->back = -1; - break; - } - state->back = 0; - for (;;) { - here = state->lencode[BITS(state->lenbits)]; - if ((unsigned)(here.bits) <= bits) break; - PULLBYTE(); - } - if (here.op && (here.op & 0xf0) == 0) { - last = here; - for (;;) { - here = state->lencode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + here.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - state->back += last.bits; - } - DROPBITS(here.bits); - state->back += here.bits; - state->length = (unsigned)here.val; - if ((int)(here.op) == 0) { - Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? - "inflate: literal '%c'\n" : - "inflate: literal 0x%02x\n", here.val)); - state->mode = LIT; - break; - } - if (here.op & 32) { - Tracevv((stderr, "inflate: end of block\n")); - state->back = -1; - state->mode = TYPE; - break; - } - if (here.op & 64) { - strm->msg = (char *)"invalid literal/length code"; - state->mode = BAD; - break; - } - state->extra = (unsigned)(here.op) & 15; - state->mode = LENEXT; - /* fallthrough */ - case LENEXT: - if (state->extra) { - NEEDBITS(state->extra); - state->length += BITS(state->extra); - DROPBITS(state->extra); - state->back += state->extra; - } - Tracevv((stderr, "inflate: length %u\n", state->length)); - state->was = state->length; - state->mode = DIST; - /* fallthrough */ - case DIST: - for (;;) { - here = state->distcode[BITS(state->distbits)]; - if ((unsigned)(here.bits) <= bits) break; - PULLBYTE(); - } - if ((here.op & 0xf0) == 0) { - last = here; - for (;;) { - here = state->distcode[last.val + - (BITS(last.bits + last.op) >> last.bits)]; - if ((unsigned)(last.bits + here.bits) <= bits) break; - PULLBYTE(); - } - DROPBITS(last.bits); - state->back += last.bits; - } - DROPBITS(here.bits); - state->back += here.bits; - if (here.op & 64) { - strm->msg = (char *)"invalid distance code"; - state->mode = BAD; - break; - } - state->offset = (unsigned)here.val; - state->extra = (unsigned)(here.op) & 15; - state->mode = DISTEXT; - /* fallthrough */ - case DISTEXT: - if (state->extra) { - NEEDBITS(state->extra); - state->offset += BITS(state->extra); - DROPBITS(state->extra); - state->back += state->extra; - } -#ifdef INFLATE_STRICT - if (state->offset > state->dmax) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } -#endif - Tracevv((stderr, "inflate: distance %u\n", state->offset)); - state->mode = MATCH; - /* fallthrough */ - case MATCH: - if (left == 0) goto inf_leave; - copy = out - left; - if (state->offset > copy) { /* copy from window */ - copy = state->offset - copy; - if (copy > state->whave) { - if (state->sane) { - strm->msg = (char *)"invalid distance too far back"; - state->mode = BAD; - break; - } -#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR - Trace((stderr, "inflate.c too far\n")); - copy -= state->whave; - if (copy > state->length) copy = state->length; - if (copy > left) copy = left; - left -= copy; - state->length -= copy; - do { - *put++ = 0; - } while (--copy); - if (state->length == 0) state->mode = LEN; - break; -#endif - } - if (copy > state->wnext) { - copy -= state->wnext; - from = state->window + (state->wsize - copy); - } - else - from = state->window + (state->wnext - copy); - if (copy > state->length) copy = state->length; - } - else { /* copy from output */ - from = put - state->offset; - copy = state->length; - } - if (copy > left) copy = left; - left -= copy; - state->length -= copy; - do { - *put++ = *from++; - } while (--copy); - if (state->length == 0) state->mode = LEN; - break; - case LIT: - if (left == 0) goto inf_leave; - *put++ = (unsigned char)(state->length); - left--; - state->mode = LEN; - break; - case CHECK: - if (state->wrap) { - NEEDBITS(32); - out -= left; - strm->total_out += out; - state->total += out; - if ((state->wrap & 4) && out) - strm->adler = state->check = - UPDATE_CHECK(state->check, put - out, out); - out = left; - if ((state->wrap & 4) && ( -#ifdef GUNZIP - state->flags ? hold : -#endif - ZSWAP32(hold)) != state->check) { - strm->msg = (char *)"incorrect data check"; - state->mode = BAD; - break; - } - INITBITS(); - Tracev((stderr, "inflate: check matches trailer\n")); - } -#ifdef GUNZIP - state->mode = LENGTH; - /* fallthrough */ - case LENGTH: - if (state->wrap && state->flags) { - NEEDBITS(32); - if ((state->wrap & 4) && hold != (state->total & 0xffffffff)) { - strm->msg = (char *)"incorrect length check"; - state->mode = BAD; - break; - } - INITBITS(); - Tracev((stderr, "inflate: length matches trailer\n")); - } -#endif - state->mode = DONE; - /* fallthrough */ - case DONE: - ret = Z_STREAM_END; - goto inf_leave; - case BAD: - ret = Z_DATA_ERROR; - goto inf_leave; - case MEM: - return Z_MEM_ERROR; - case SYNC: - /* fallthrough */ - default: - return Z_STREAM_ERROR; - } - - /* - Return from inflate(), updating the total counts and the check value. - If there was no progress during the inflate() call, return a buffer - error. Call updatewindow() to create and/or update the window state. - Note: a memory error from inflate() is non-recoverable. - */ - inf_leave: - RESTORE(); - if (state->wsize || (out != strm->avail_out && state->mode < BAD && - (state->mode < CHECK || flush != Z_FINISH))) - if (updatewindow(strm, strm->next_out, out - strm->avail_out)) { - state->mode = MEM; - return Z_MEM_ERROR; - } - in -= strm->avail_in; - out -= strm->avail_out; - strm->total_in += in; - strm->total_out += out; - state->total += out; - if ((state->wrap & 4) && out) - strm->adler = state->check = - UPDATE_CHECK(state->check, strm->next_out - out, out); - strm->data_type = (int)state->bits + (state->last ? 64 : 0) + - (state->mode == TYPE ? 128 : 0) + - (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0); - if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) - ret = Z_BUF_ERROR; - return ret; -} - -int ZEXPORT inflateEnd(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - if (inflateStateCheck(strm)) - return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (state->window != Z_NULL) ZFREE(strm, state->window); - ZFREE(strm, strm->state); - strm->state = Z_NULL; - Tracev((stderr, "inflate: end\n")); - return Z_OK; -} - -int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength) -z_streamp strm; -Bytef *dictionary; -uInt *dictLength; -{ - struct inflate_state FAR *state; - - /* check state */ - if (inflateStateCheck(strm)) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - - /* copy dictionary */ - if (state->whave && dictionary != Z_NULL) { - zmemcpy(dictionary, state->window + state->wnext, - state->whave - state->wnext); - zmemcpy(dictionary + state->whave - state->wnext, - state->window, state->wnext); - } - if (dictLength != Z_NULL) - *dictLength = state->whave; - return Z_OK; -} - -int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength) -z_streamp strm; -const Bytef *dictionary; -uInt dictLength; -{ - struct inflate_state FAR *state; - unsigned long dictid; - int ret; - - /* check state */ - if (inflateStateCheck(strm)) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (state->wrap != 0 && state->mode != DICT) - return Z_STREAM_ERROR; - - /* check for correct dictionary identifier */ - if (state->mode == DICT) { - dictid = adler32(0L, Z_NULL, 0); - dictid = adler32(dictid, dictionary, dictLength); - if (dictid != state->check) - return Z_DATA_ERROR; - } - - /* copy dictionary to window using updatewindow(), which will amend the - existing dictionary if appropriate */ - ret = updatewindow(strm, dictionary + dictLength, dictLength); - if (ret) { - state->mode = MEM; - return Z_MEM_ERROR; - } - state->havedict = 1; - Tracev((stderr, "inflate: dictionary set\n")); - return Z_OK; -} - -int ZEXPORT inflateGetHeader(strm, head) -z_streamp strm; -gz_headerp head; -{ - struct inflate_state FAR *state; - - /* check state */ - if (inflateStateCheck(strm)) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if ((state->wrap & 2) == 0) return Z_STREAM_ERROR; - - /* save header structure */ - state->head = head; - head->done = 0; - return Z_OK; -} - -/* - Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found - or when out of input. When called, *have is the number of pattern bytes - found in order so far, in 0..3. On return *have is updated to the new - state. If on return *have equals four, then the pattern was found and the - return value is how many bytes were read including the last byte of the - pattern. If *have is less than four, then the pattern has not been found - yet and the return value is len. In the latter case, syncsearch() can be - called again with more data and the *have state. *have is initialized to - zero for the first call. - */ -local unsigned syncsearch(have, buf, len) -unsigned FAR *have; -const unsigned char FAR *buf; -unsigned len; -{ - unsigned got; - unsigned next; - - got = *have; - next = 0; - while (next < len && got < 4) { - if ((int)(buf[next]) == (got < 2 ? 0 : 0xff)) - got++; - else if (buf[next]) - got = 0; - else - got = 4 - got; - next++; - } - *have = got; - return next; -} - -int ZEXPORT inflateSync(strm) -z_streamp strm; -{ - unsigned len; /* number of bytes to look at or looked at */ - int flags; /* temporary to save header status */ - unsigned long in, out; /* temporary to save total_in and total_out */ - unsigned char buf[4]; /* to restore bit buffer to byte string */ - struct inflate_state FAR *state; - - /* check parameters */ - if (inflateStateCheck(strm)) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR; - - /* if first time, start search in bit buffer */ - if (state->mode != SYNC) { - state->mode = SYNC; - state->hold <<= state->bits & 7; - state->bits -= state->bits & 7; - len = 0; - while (state->bits >= 8) { - buf[len++] = (unsigned char)(state->hold); - state->hold >>= 8; - state->bits -= 8; - } - state->have = 0; - syncsearch(&(state->have), buf, len); - } - - /* search available input */ - len = syncsearch(&(state->have), strm->next_in, strm->avail_in); - strm->avail_in -= len; - strm->next_in += len; - strm->total_in += len; - - /* return no joy or set up to restart inflate() on a new block */ - if (state->have != 4) return Z_DATA_ERROR; - if (state->flags == -1) - state->wrap = 0; /* if no header yet, treat as raw */ - else - state->wrap &= ~4; /* no point in computing a check value now */ - flags = state->flags; - in = strm->total_in; out = strm->total_out; - inflateReset(strm); - strm->total_in = in; strm->total_out = out; - state->flags = flags; - state->mode = TYPE; - return Z_OK; -} - -/* - Returns true if inflate is currently at the end of a block generated by - Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP - implementation to provide an additional safety check. PPP uses - Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored - block. When decompressing, PPP checks that at the end of input packet, - inflate is waiting for these length bytes. - */ -int ZEXPORT inflateSyncPoint(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - - if (inflateStateCheck(strm)) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - return state->mode == STORED && state->bits == 0; -} - -int ZEXPORT inflateCopy(dest, source) -z_streamp dest; -z_streamp source; -{ - struct inflate_state FAR *state; - struct inflate_state FAR *copy; - unsigned char FAR *window; - unsigned wsize; - - /* check input */ - if (inflateStateCheck(source) || dest == Z_NULL) - return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)source->state; - - /* allocate space */ - copy = (struct inflate_state FAR *) - ZALLOC(source, 1, sizeof(struct inflate_state)); - if (copy == Z_NULL) return Z_MEM_ERROR; - window = Z_NULL; - if (state->window != Z_NULL) { - window = (unsigned char FAR *) - ZALLOC(source, 1U << state->wbits, sizeof(unsigned char)); - if (window == Z_NULL) { - ZFREE(source, copy); - return Z_MEM_ERROR; - } - } - - /* copy state */ - zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream)); - zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state)); - copy->strm = dest; - if (state->lencode >= state->codes && - state->lencode <= state->codes + ENOUGH - 1) { - copy->lencode = copy->codes + (state->lencode - state->codes); - copy->distcode = copy->codes + (state->distcode - state->codes); - } - copy->next = copy->codes + (state->next - state->codes); - if (window != Z_NULL) { - wsize = 1U << state->wbits; - zmemcpy(window, state->window, wsize); - } - copy->window = window; - dest->state = (struct internal_state FAR *)copy; - return Z_OK; -} - -int ZEXPORT inflateUndermine(strm, subvert) -z_streamp strm; -int subvert; -{ - struct inflate_state FAR *state; - - if (inflateStateCheck(strm)) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; -#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR - state->sane = !subvert; - return Z_OK; -#else - (void)subvert; - state->sane = 1; - return Z_DATA_ERROR; -#endif -} - -int ZEXPORT inflateValidate(strm, check) -z_streamp strm; -int check; -{ - struct inflate_state FAR *state; - - if (inflateStateCheck(strm)) return Z_STREAM_ERROR; - state = (struct inflate_state FAR *)strm->state; - if (check && state->wrap) - state->wrap |= 4; - else - state->wrap &= ~4; - return Z_OK; -} - -long ZEXPORT inflateMark(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - - if (inflateStateCheck(strm)) - return -(1L << 16); - state = (struct inflate_state FAR *)strm->state; - return (long)(((unsigned long)((long)state->back)) << 16) + - (state->mode == COPY ? state->length : - (state->mode == MATCH ? state->was - state->length : 0)); -} - -unsigned long ZEXPORT inflateCodesUsed(strm) -z_streamp strm; -{ - struct inflate_state FAR *state; - if (inflateStateCheck(strm)) return (unsigned long)-1; - state = (struct inflate_state FAR *)strm->state; - return (unsigned long)(state->next - state->codes); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/inflate.h b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/inflate.h deleted file mode 100644 index f127b6b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/inflate.h +++ /dev/null @@ -1,126 +0,0 @@ -/* inflate.h -- internal inflate state definition - * Copyright (C) 1995-2019 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* define NO_GZIP when compiling if you want to disable gzip header and - trailer decoding by inflate(). NO_GZIP would be used to avoid linking in - the crc code when it is not needed. For shared libraries, gzip decoding - should be left enabled. */ -#ifndef NO_GZIP -# define GUNZIP -#endif - -/* Possible inflate modes between inflate() calls */ -typedef enum { - HEAD = 16180, /* i: waiting for magic header */ - FLAGS, /* i: waiting for method and flags (gzip) */ - TIME, /* i: waiting for modification time (gzip) */ - OS, /* i: waiting for extra flags and operating system (gzip) */ - EXLEN, /* i: waiting for extra length (gzip) */ - EXTRA, /* i: waiting for extra bytes (gzip) */ - NAME, /* i: waiting for end of file name (gzip) */ - COMMENT, /* i: waiting for end of comment (gzip) */ - HCRC, /* i: waiting for header crc (gzip) */ - DICTID, /* i: waiting for dictionary check value */ - DICT, /* waiting for inflateSetDictionary() call */ - TYPE, /* i: waiting for type bits, including last-flag bit */ - TYPEDO, /* i: same, but skip check to exit inflate on new block */ - STORED, /* i: waiting for stored size (length and complement) */ - COPY_, /* i/o: same as COPY below, but only first time in */ - COPY, /* i/o: waiting for input or output to copy stored block */ - TABLE, /* i: waiting for dynamic block table lengths */ - LENLENS, /* i: waiting for code length code lengths */ - CODELENS, /* i: waiting for length/lit and distance code lengths */ - LEN_, /* i: same as LEN below, but only first time in */ - LEN, /* i: waiting for length/lit/eob code */ - LENEXT, /* i: waiting for length extra bits */ - DIST, /* i: waiting for distance code */ - DISTEXT, /* i: waiting for distance extra bits */ - MATCH, /* o: waiting for output space to copy string */ - LIT, /* o: waiting for output space to write literal */ - CHECK, /* i: waiting for 32-bit check value */ - LENGTH, /* i: waiting for 32-bit length (gzip) */ - DONE, /* finished check, done -- remain here until reset */ - BAD, /* got a data error -- remain here until reset */ - MEM, /* got an inflate() memory error -- remain here until reset */ - SYNC /* looking for synchronization bytes to restart inflate() */ -} inflate_mode; - -/* - State transitions between above modes - - - (most modes can go to BAD or MEM on error -- not shown for clarity) - - Process header: - HEAD -> (gzip) or (zlib) or (raw) - (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT -> - HCRC -> TYPE - (zlib) -> DICTID or TYPE - DICTID -> DICT -> TYPE - (raw) -> TYPEDO - Read deflate blocks: - TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK - STORED -> COPY_ -> COPY -> TYPE - TABLE -> LENLENS -> CODELENS -> LEN_ - LEN_ -> LEN - Read deflate codes in fixed or dynamic block: - LEN -> LENEXT or LIT or TYPE - LENEXT -> DIST -> DISTEXT -> MATCH -> LEN - LIT -> LEN - Process trailer: - CHECK -> LENGTH -> DONE - */ - -/* State maintained between inflate() calls -- approximately 7K bytes, not - including the allocated sliding window, which is up to 32K bytes. */ -struct inflate_state { - z_streamp strm; /* pointer back to this zlib stream */ - inflate_mode mode; /* current inflate mode */ - int last; /* true if processing last block */ - int wrap; /* bit 0 true for zlib, bit 1 true for gzip, - bit 2 true to validate check value */ - int havedict; /* true if dictionary provided */ - int flags; /* gzip header method and flags, 0 if zlib, or - -1 if raw or no header yet */ - unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ - unsigned long check; /* protected copy of check value */ - unsigned long total; /* protected copy of output count */ - gz_headerp head; /* where to save gzip header information */ - /* sliding window */ - unsigned wbits; /* log base 2 of requested window size */ - unsigned wsize; /* window size or zero if not using window */ - unsigned whave; /* valid bytes in the window */ - unsigned wnext; /* window write index */ - unsigned char FAR *window; /* allocated sliding window, if needed */ - /* bit accumulator */ - unsigned long hold; /* input bit accumulator */ - unsigned bits; /* number of bits in "in" */ - /* for string and stored block copying */ - unsigned length; /* literal or length of data to copy */ - unsigned offset; /* distance back to copy string from */ - /* for table and code decoding */ - unsigned extra; /* extra bits needed */ - /* fixed and dynamic code tables */ - code const FAR *lencode; /* starting table for length/literal codes */ - code const FAR *distcode; /* starting table for distance codes */ - unsigned lenbits; /* index bits for lencode */ - unsigned distbits; /* index bits for distcode */ - /* dynamic table building */ - unsigned ncode; /* number of code length code lengths */ - unsigned nlen; /* number of length code lengths */ - unsigned ndist; /* number of distance code lengths */ - unsigned have; /* number of code lengths in lens[] */ - code FAR *next; /* next available space in codes[] */ - unsigned short lens[320]; /* temporary storage for code lengths */ - unsigned short work[288]; /* work area for code table building */ - code codes[ENOUGH]; /* space for code tables */ - int sane; /* if false, allow invalid distance too far */ - int back; /* bits back of last unprocessed length/lit */ - unsigned was; /* initial length of match */ -}; diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/inftrees.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/inftrees.c deleted file mode 100644 index 09462a7..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/inftrees.c +++ /dev/null @@ -1,304 +0,0 @@ -/* inftrees.c -- generate Huffman trees for efficient decoding - * Copyright (C) 1995-2022 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "inftrees.h" - -#define MAXBITS 15 - -const char inflate_copyright[] = - " inflate 1.2.12 Copyright 1995-2022 Mark Adler "; -/* - If you use the zlib library in a product, an acknowledgment is welcome - in the documentation of your product. If for some reason you cannot - include such an acknowledgment, I would appreciate that you keep this - copyright string in the executable of your product. - */ - -/* - Build a set of tables to decode the provided canonical Huffman code. - The code lengths are lens[0..codes-1]. The result starts at *table, - whose indices are 0..2^bits-1. work is a writable array of at least - lens shorts, which is used as a work area. type is the type of code - to be generated, CODES, LENS, or DISTS. On return, zero is success, - -1 is an invalid code, and +1 means that ENOUGH isn't enough. table - on return points to the next available entry's address. bits is the - requested root table index bits, and on return it is the actual root - table index bits. It will differ if the request is greater than the - longest code or if it is less than the shortest code. - */ -int ZLIB_INTERNAL inflate_table(type, lens, codes, table, bits, work) -codetype type; -unsigned short FAR *lens; -unsigned codes; -code FAR * FAR *table; -unsigned FAR *bits; -unsigned short FAR *work; -{ - unsigned len; /* a code's length in bits */ - unsigned sym; /* index of code symbols */ - unsigned min, max; /* minimum and maximum code lengths */ - unsigned root; /* number of index bits for root table */ - unsigned curr; /* number of index bits for current table */ - unsigned drop; /* code bits to drop for sub-table */ - int left; /* number of prefix codes available */ - unsigned used; /* code entries in table used */ - unsigned huff; /* Huffman code */ - unsigned incr; /* for incrementing code, index */ - unsigned fill; /* index for replicating entries */ - unsigned low; /* low bits for current root entry */ - unsigned mask; /* mask for low root bits */ - code here; /* table entry for duplication */ - code FAR *next; /* next available space in table */ - const unsigned short FAR *base; /* base value table to use */ - const unsigned short FAR *extra; /* extra bits table to use */ - unsigned match; /* use base and extra for symbol >= match */ - unsigned short count[MAXBITS+1]; /* number of codes of each length */ - unsigned short offs[MAXBITS+1]; /* offsets in table for each length */ - static const unsigned short lbase[31] = { /* Length codes 257..285 base */ - 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, - 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; - static const unsigned short lext[31] = { /* Length codes 257..285 extra */ - 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, - 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 199, 202}; - static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ - 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, - 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, - 8193, 12289, 16385, 24577, 0, 0}; - static const unsigned short dext[32] = { /* Distance codes 0..29 extra */ - 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, - 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, - 28, 28, 29, 29, 64, 64}; - - /* - Process a set of code lengths to create a canonical Huffman code. The - code lengths are lens[0..codes-1]. Each length corresponds to the - symbols 0..codes-1. The Huffman code is generated by first sorting the - symbols by length from short to long, and retaining the symbol order - for codes with equal lengths. Then the code starts with all zero bits - for the first code of the shortest length, and the codes are integer - increments for the same length, and zeros are appended as the length - increases. For the deflate format, these bits are stored backwards - from their more natural integer increment ordering, and so when the - decoding tables are built in the large loop below, the integer codes - are incremented backwards. - - This routine assumes, but does not check, that all of the entries in - lens[] are in the range 0..MAXBITS. The caller must assure this. - 1..MAXBITS is interpreted as that code length. zero means that that - symbol does not occur in this code. - - The codes are sorted by computing a count of codes for each length, - creating from that a table of starting indices for each length in the - sorted table, and then entering the symbols in order in the sorted - table. The sorted table is work[], with that space being provided by - the caller. - - The length counts are used for other purposes as well, i.e. finding - the minimum and maximum length codes, determining if there are any - codes at all, checking for a valid set of lengths, and looking ahead - at length counts to determine sub-table sizes when building the - decoding tables. - */ - - /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */ - for (len = 0; len <= MAXBITS; len++) - count[len] = 0; - for (sym = 0; sym < codes; sym++) - count[lens[sym]]++; - - /* bound code lengths, force root to be within code lengths */ - root = *bits; - for (max = MAXBITS; max >= 1; max--) - if (count[max] != 0) break; - if (root > max) root = max; - if (max == 0) { /* no symbols to code at all */ - here.op = (unsigned char)64; /* invalid code marker */ - here.bits = (unsigned char)1; - here.val = (unsigned short)0; - *(*table)++ = here; /* make a table to force an error */ - *(*table)++ = here; - *bits = 1; - return 0; /* no symbols, but wait for decoding to report error */ - } - for (min = 1; min < max; min++) - if (count[min] != 0) break; - if (root < min) root = min; - - /* check for an over-subscribed or incomplete set of lengths */ - left = 1; - for (len = 1; len <= MAXBITS; len++) { - left <<= 1; - left -= count[len]; - if (left < 0) return -1; /* over-subscribed */ - } - if (left > 0 && (type == CODES || max != 1)) - return -1; /* incomplete set */ - - /* generate offsets into symbol table for each length for sorting */ - offs[1] = 0; - for (len = 1; len < MAXBITS; len++) - offs[len + 1] = offs[len] + count[len]; - - /* sort symbols by length, by symbol order within each length */ - for (sym = 0; sym < codes; sym++) - if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym; - - /* - Create and fill in decoding tables. In this loop, the table being - filled is at next and has curr index bits. The code being used is huff - with length len. That code is converted to an index by dropping drop - bits off of the bottom. For codes where len is less than drop + curr, - those top drop + curr - len bits are incremented through all values to - fill the table with replicated entries. - - root is the number of index bits for the root table. When len exceeds - root, sub-tables are created pointed to by the root entry with an index - of the low root bits of huff. This is saved in low to check for when a - new sub-table should be started. drop is zero when the root table is - being filled, and drop is root when sub-tables are being filled. - - When a new sub-table is needed, it is necessary to look ahead in the - code lengths to determine what size sub-table is needed. The length - counts are used for this, and so count[] is decremented as codes are - entered in the tables. - - used keeps track of how many table entries have been allocated from the - provided *table space. It is checked for LENS and DIST tables against - the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in - the initial root table size constants. See the comments in inftrees.h - for more information. - - sym increments through all symbols, and the loop terminates when - all codes of length max, i.e. all codes, have been processed. This - routine permits incomplete codes, so another loop after this one fills - in the rest of the decoding tables with invalid code markers. - */ - - /* set up for code type */ - switch (type) { - case CODES: - base = extra = work; /* dummy value--not used */ - match = 20; - break; - case LENS: - base = lbase; - extra = lext; - match = 257; - break; - default: /* DISTS */ - base = dbase; - extra = dext; - match = 0; - } - - /* initialize state for loop */ - huff = 0; /* starting code */ - sym = 0; /* starting code symbol */ - len = min; /* starting code length */ - next = *table; /* current table to fill in */ - curr = root; /* current table index bits */ - drop = 0; /* current bits to drop from code for index */ - low = (unsigned)(-1); /* trigger new sub-table when len > root */ - used = 1U << root; /* use root table entries */ - mask = used - 1; /* mask for comparing low */ - - /* check available table space */ - if ((type == LENS && used > ENOUGH_LENS) || - (type == DISTS && used > ENOUGH_DISTS)) - return 1; - - /* process all codes and make table entries */ - for (;;) { - /* create table entry */ - here.bits = (unsigned char)(len - drop); - if (work[sym] + 1U < match) { - here.op = (unsigned char)0; - here.val = work[sym]; - } - else if (work[sym] >= match) { - here.op = (unsigned char)(extra[work[sym] - match]); - here.val = base[work[sym] - match]; - } - else { - here.op = (unsigned char)(32 + 64); /* end of block */ - here.val = 0; - } - - /* replicate for those indices with low len bits equal to huff */ - incr = 1U << (len - drop); - fill = 1U << curr; - min = fill; /* save offset to next table */ - do { - fill -= incr; - next[(huff >> drop) + fill] = here; - } while (fill != 0); - - /* backwards increment the len-bit code huff */ - incr = 1U << (len - 1); - while (huff & incr) - incr >>= 1; - if (incr != 0) { - huff &= incr - 1; - huff += incr; - } - else - huff = 0; - - /* go to next symbol, update count, len */ - sym++; - if (--(count[len]) == 0) { - if (len == max) break; - len = lens[work[sym]]; - } - - /* create new sub-table if needed */ - if (len > root && (huff & mask) != low) { - /* if first time, transition to sub-tables */ - if (drop == 0) - drop = root; - - /* increment past last table */ - next += min; /* here min is 1 << curr */ - - /* determine length of next table */ - curr = len - drop; - left = (int)(1 << curr); - while (curr + drop < max) { - left -= count[curr + drop]; - if (left <= 0) break; - curr++; - left <<= 1; - } - - /* check for enough space */ - used += 1U << curr; - if ((type == LENS && used > ENOUGH_LENS) || - (type == DISTS && used > ENOUGH_DISTS)) - return 1; - - /* point entry in root table to sub-table */ - low = huff & mask; - (*table)[low].op = (unsigned char)curr; - (*table)[low].bits = (unsigned char)root; - (*table)[low].val = (unsigned short)(next - *table); - } - } - - /* fill in remaining table entry if code is incomplete (guaranteed to have - at most one remaining entry, since if the code is incomplete, the - maximum code length that was allowed to get this far is one bit) */ - if (huff != 0) { - here.op = (unsigned char)64; /* invalid code marker */ - here.bits = (unsigned char)(len - drop); - here.val = (unsigned short)0; - next[huff] = here; - } - - /* set return parameters */ - *table += used; - *bits = root; - return 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/inftrees.h b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/inftrees.h deleted file mode 100644 index baa53a0..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/inftrees.h +++ /dev/null @@ -1,62 +0,0 @@ -/* inftrees.h -- header to use inftrees.c - * Copyright (C) 1995-2005, 2010 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* Structure for decoding tables. Each entry provides either the - information needed to do the operation requested by the code that - indexed that table entry, or it provides a pointer to another - table that indexes more bits of the code. op indicates whether - the entry is a pointer to another table, a literal, a length or - distance, an end-of-block, or an invalid code. For a table - pointer, the low four bits of op is the number of index bits of - that table. For a length or distance, the low four bits of op - is the number of extra bits to get after the code. bits is - the number of bits in this code or part of the code to drop off - of the bit buffer. val is the actual byte to output in the case - of a literal, the base length or distance, or the offset from - the current table to the next table. Each entry is four bytes. */ -typedef struct { - unsigned char op; /* operation, extra bits, table bits */ - unsigned char bits; /* bits in this part of the code */ - unsigned short val; /* offset in table or code value */ -} code; - -/* op values as set by inflate_table(): - 00000000 - literal - 0000tttt - table link, tttt != 0 is the number of table index bits - 0001eeee - length or distance, eeee is the number of extra bits - 01100000 - end of block - 01000000 - invalid code - */ - -/* Maximum size of the dynamic table. The maximum number of code structures is - 1444, which is the sum of 852 for literal/length codes and 592 for distance - codes. These values were found by exhaustive searches using the program - examples/enough.c found in the zlib distribtution. The arguments to that - program are the number of symbols, the initial root table size, and the - maximum bit length of a code. "enough 286 9 15" for literal/length codes - returns returns 852, and "enough 30 6 15" for distance codes returns 592. - The initial root table size (9 or 6) is found in the fifth argument of the - inflate_table() calls in inflate.c and infback.c. If the root table size is - changed, then these maximum sizes would be need to be recalculated and - updated. */ -#define ENOUGH_LENS 852 -#define ENOUGH_DISTS 592 -#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) - -/* Type of code to build for inflate_table() */ -typedef enum { - CODES, - LENS, - DISTS -} codetype; - -int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, - unsigned codes, code FAR * FAR *table, - unsigned FAR *bits, unsigned short FAR *work)); diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/make_vms.com b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/make_vms.com deleted file mode 100644 index 65e9d0c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/make_vms.com +++ /dev/null @@ -1,867 +0,0 @@ -$! make libz under VMS written by -$! Martin P.J. Zinser -$! -$! In case of problems with the install you might contact me at -$! zinser@zinser.no-ip.info(preferred) or -$! martin.zinser@eurexchange.com (work) -$! -$! Make procedure history for Zlib -$! -$!------------------------------------------------------------------------------ -$! Version history -$! 0.01 20060120 First version to receive a number -$! 0.02 20061008 Adapt to new Makefile.in -$! 0.03 20091224 Add support for large file check -$! 0.04 20100110 Add new gzclose, gzlib, gzread, gzwrite -$! 0.05 20100221 Exchange zlibdefs.h by zconf.h.in -$! 0.06 20120111 Fix missing amiss_err, update zconf_h.in, fix new exmples -$! subdir path, update module search in makefile.in -$! 0.07 20120115 Triggered by work done by Alexey Chupahin completly redesigned -$! shared image creation -$! 0.08 20120219 Make it work on VAX again, pre-load missing symbols to shared -$! image -$! 0.09 20120305 SMS. P1 sets builder ("MMK", "MMS", " " (built-in)). -$! "" -> automatic, preference: MMK, MMS, built-in. -$! -$ on error then goto err_exit -$! -$ true = 1 -$ false = 0 -$ tmpnam = "temp_" + f$getjpi("","pid") -$ tt = tmpnam + ".txt" -$ tc = tmpnam + ".c" -$ th = tmpnam + ".h" -$ define/nolog tconfig 'th' -$ its_decc = false -$ its_vaxc = false -$ its_gnuc = false -$ s_case = False -$! -$! Setup variables holding "config" information -$! -$ Make = "''p1'" -$ name = "Zlib" -$ version = "?.?.?" -$ v_string = "ZLIB_VERSION" -$ v_file = "zlib.h" -$ ccopt = "/include = []" -$ lopts = "" -$ dnsrl = "" -$ aconf_in_file = "zconf.h.in#zconf.h_in#zconf_h.in" -$ conf_check_string = "" -$ linkonly = false -$ optfile = name + ".opt" -$ mapfile = name + ".map" -$ libdefs = "" -$ vax = f$getsyi("HW_MODEL").lt.1024 -$ axp = f$getsyi("HW_MODEL").ge.1024 .and. f$getsyi("HW_MODEL").lt.4096 -$ ia64 = f$getsyi("HW_MODEL").ge.4096 -$! -$! 2012-03-05 SMS. -$! Why is this needed? And if it is needed, why not simply ".not. vax"? -$! -$!!! if axp .or. ia64 then set proc/parse=extended -$! -$ whoami = f$parse(f$environment("Procedure"),,,,"NO_CONCEAL") -$ mydef = F$parse(whoami,,,"DEVICE") -$ mydir = f$parse(whoami,,,"DIRECTORY") - "][" -$ myproc = f$parse(whoami,,,"Name") + f$parse(whoami,,,"type") -$! -$! Check for MMK/MMS -$! -$ if (Make .eqs. "") -$ then -$ If F$Search ("Sys$System:MMS.EXE") .nes. "" Then Make = "MMS" -$ If F$Type (MMK) .eqs. "STRING" Then Make = "MMK" -$ else -$ Make = f$edit( Make, "trim") -$ endif -$! -$ gosub find_version -$! -$ open/write topt tmp.opt -$ open/write optf 'optfile' -$! -$ gosub check_opts -$! -$! Look for the compiler used -$! -$ gosub check_compiler -$ close topt -$ close optf -$! -$ if its_decc -$ then -$ ccopt = "/prefix=all" + ccopt -$ if f$trnlnm("SYS") .eqs. "" -$ then -$ if axp -$ then -$ define sys sys$library: -$ else -$ ccopt = "/decc" + ccopt -$ define sys decc$library_include: -$ endif -$ endif -$! -$! 2012-03-05 SMS. -$! Why /NAMES = AS_IS? Why not simply ".not. vax"? And why not on VAX? -$! -$ if axp .or. ia64 -$ then -$ ccopt = ccopt + "/name=as_is/opt=(inline=speed)" -$ s_case = true -$ endif -$ endif -$ if its_vaxc .or. its_gnuc -$ then -$ if f$trnlnm("SYS").eqs."" then define sys sys$library: -$ endif -$! -$! Build a fake configure input header -$! -$ open/write conf_hin config.hin -$ write conf_hin "#undef _LARGEFILE64_SOURCE" -$ close conf_hin -$! -$! -$ i = 0 -$FIND_ACONF: -$ fname = f$element(i,"#",aconf_in_file) -$ if fname .eqs. "#" then goto AMISS_ERR -$ if f$search(fname) .eqs. "" -$ then -$ i = i + 1 -$ goto find_aconf -$ endif -$ open/read/err=aconf_err aconf_in 'fname' -$ open/write aconf zconf.h -$ACONF_LOOP: -$ read/end_of_file=aconf_exit aconf_in line -$ work = f$edit(line, "compress,trim") -$ if f$extract(0,6,work) .nes. "#undef" -$ then -$ if f$extract(0,12,work) .nes. "#cmakedefine" -$ then -$ write aconf line -$ endif -$ else -$ cdef = f$element(1," ",work) -$ gosub check_config -$ endif -$ goto aconf_loop -$ACONF_EXIT: -$ write aconf "" -$ write aconf "/* VMS specifics added by make_vms.com: */" -$ write aconf "#define VMS 1" -$ write aconf "#include " -$ write aconf "#include " -$ write aconf "#ifdef _LARGEFILE" -$ write aconf "# define off64_t __off64_t" -$ write aconf "# define fopen64 fopen" -$ write aconf "# define fseeko64 fseeko" -$ write aconf "# define lseek64 lseek" -$ write aconf "# define ftello64 ftell" -$ write aconf "#endif" -$ write aconf "#if !defined( __VAX) && (__CRTL_VER >= 70312000)" -$ write aconf "# define HAVE_VSNPRINTF" -$ write aconf "#endif" -$ close aconf_in -$ close aconf -$ if f$search("''th'") .nes. "" then delete 'th';* -$! Build the thing plain or with mms -$! -$ write sys$output "Compiling Zlib sources ..." -$ if make.eqs."" -$ then -$ if (f$search( "example.obj;*") .nes. "") then delete example.obj;* -$ if (f$search( "minigzip.obj;*") .nes. "") then delete minigzip.obj;* -$ CALL MAKE adler32.OBJ "CC ''CCOPT' adler32" - - adler32.c zlib.h zconf.h -$ CALL MAKE compress.OBJ "CC ''CCOPT' compress" - - compress.c zlib.h zconf.h -$ CALL MAKE crc32.OBJ "CC ''CCOPT' crc32" - - crc32.c zlib.h zconf.h -$ CALL MAKE deflate.OBJ "CC ''CCOPT' deflate" - - deflate.c deflate.h zutil.h zlib.h zconf.h -$ CALL MAKE gzclose.OBJ "CC ''CCOPT' gzclose" - - gzclose.c zutil.h zlib.h zconf.h -$ CALL MAKE gzlib.OBJ "CC ''CCOPT' gzlib" - - gzlib.c zutil.h zlib.h zconf.h -$ CALL MAKE gzread.OBJ "CC ''CCOPT' gzread" - - gzread.c zutil.h zlib.h zconf.h -$ CALL MAKE gzwrite.OBJ "CC ''CCOPT' gzwrite" - - gzwrite.c zutil.h zlib.h zconf.h -$ CALL MAKE infback.OBJ "CC ''CCOPT' infback" - - infback.c zutil.h inftrees.h inflate.h inffast.h inffixed.h -$ CALL MAKE inffast.OBJ "CC ''CCOPT' inffast" - - inffast.c zutil.h zlib.h zconf.h inffast.h -$ CALL MAKE inflate.OBJ "CC ''CCOPT' inflate" - - inflate.c zutil.h zlib.h zconf.h infblock.h -$ CALL MAKE inftrees.OBJ "CC ''CCOPT' inftrees" - - inftrees.c zutil.h zlib.h zconf.h inftrees.h -$ CALL MAKE trees.OBJ "CC ''CCOPT' trees" - - trees.c deflate.h zutil.h zlib.h zconf.h -$ CALL MAKE uncompr.OBJ "CC ''CCOPT' uncompr" - - uncompr.c zlib.h zconf.h -$ CALL MAKE zutil.OBJ "CC ''CCOPT' zutil" - - zutil.c zutil.h zlib.h zconf.h -$ write sys$output "Building Zlib ..." -$ CALL MAKE libz.OLB "lib/crea libz.olb *.obj" *.OBJ -$ write sys$output "Building example..." -$ CALL MAKE example.OBJ "CC ''CCOPT' [.test]example" - - [.test]example.c zlib.h zconf.h -$ call make example.exe "LINK example,libz.olb/lib" example.obj libz.olb -$ write sys$output "Building minigzip..." -$ CALL MAKE minigzip.OBJ "CC ''CCOPT' [.test]minigzip" - - [.test]minigzip.c zlib.h zconf.h -$ call make minigzip.exe - - "LINK minigzip,libz.olb/lib" - - minigzip.obj libz.olb -$ else -$ gosub crea_mms -$ write sys$output "Make ''name' ''version' with ''Make' " -$ 'make' -$ endif -$! -$! Create shareable image -$! -$ gosub crea_olist -$ write sys$output "Creating libzshr.exe" -$ call map_2_shopt 'mapfile' 'optfile' -$ LINK_'lopts'/SHARE=libzshr.exe modules.opt/opt,'optfile'/opt -$ write sys$output "Zlib build completed" -$ delete/nolog tmp.opt;* -$ exit -$AMISS_ERR: -$ write sys$output "No source for config.hin found." -$ write sys$output "Tried any of ''aconf_in_file'" -$ goto err_exit -$CC_ERR: -$ write sys$output "C compiler required to build ''name'" -$ goto err_exit -$ERR_EXIT: -$ set message/facil/ident/sever/text -$ close/nolog optf -$ close/nolog topt -$ close/nolog aconf_in -$ close/nolog aconf -$ close/nolog out -$ close/nolog min -$ close/nolog mod -$ close/nolog h_in -$ write sys$output "Exiting..." -$ exit 2 -$! -$! -$MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES -$ V = 'F$Verify(0) -$! P1 = What we are trying to make -$! P2 = Command to make it -$! P3 - P8 What it depends on -$ -$ If F$Search(P1) .Eqs. "" Then Goto Makeit -$ Time = F$CvTime(F$File(P1,"RDT")) -$arg=3 -$Loop: -$ Argument = P'arg -$ If Argument .Eqs. "" Then Goto Exit -$ El=0 -$Loop2: -$ File = F$Element(El," ",Argument) -$ If File .Eqs. " " Then Goto Endl -$ AFile = "" -$Loop3: -$ OFile = AFile -$ AFile = F$Search(File) -$ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl -$ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit -$ Goto Loop3 -$NextEL: -$ El = El + 1 -$ Goto Loop2 -$EndL: -$ arg=arg+1 -$ If arg .Le. 8 Then Goto Loop -$ Goto Exit -$ -$Makeit: -$ VV=F$VERIFY(0) -$ write sys$output P2 -$ 'P2 -$ VV='F$Verify(VV) -$Exit: -$ If V Then Set Verify -$ENDSUBROUTINE -$!------------------------------------------------------------------------------ -$! -$! Check command line options and set symbols accordingly -$! -$!------------------------------------------------------------------------------ -$! Version history -$! 0.01 20041206 First version to receive a number -$! 0.02 20060126 Add new "HELP" target -$ CHECK_OPTS: -$ i = 1 -$ OPT_LOOP: -$ if i .lt. 9 -$ then -$ cparm = f$edit(p'i',"upcase") -$! -$! Check if parameter actually contains something -$! -$ if f$edit(cparm,"trim") .nes. "" -$ then -$ if cparm .eqs. "DEBUG" -$ then -$ ccopt = ccopt + "/noopt/deb" -$ lopts = lopts + "/deb" -$ endif -$ if f$locate("CCOPT=",cparm) .lt. f$length(cparm) -$ then -$ start = f$locate("=",cparm) + 1 -$ len = f$length(cparm) - start -$ ccopt = ccopt + f$extract(start,len,cparm) -$ if f$locate("AS_IS",f$edit(ccopt,"UPCASE")) .lt. f$length(ccopt) - - then s_case = true -$ endif -$ if cparm .eqs. "LINK" then linkonly = true -$ if f$locate("LOPTS=",cparm) .lt. f$length(cparm) -$ then -$ start = f$locate("=",cparm) + 1 -$ len = f$length(cparm) - start -$ lopts = lopts + f$extract(start,len,cparm) -$ endif -$ if f$locate("CC=",cparm) .lt. f$length(cparm) -$ then -$ start = f$locate("=",cparm) + 1 -$ len = f$length(cparm) - start -$ cc_com = f$extract(start,len,cparm) - if (cc_com .nes. "DECC") .and. - - (cc_com .nes. "VAXC") .and. - - (cc_com .nes. "GNUC") -$ then -$ write sys$output "Unsupported compiler choice ''cc_com' ignored" -$ write sys$output "Use DECC, VAXC, or GNUC instead" -$ else -$ if cc_com .eqs. "DECC" then its_decc = true -$ if cc_com .eqs. "VAXC" then its_vaxc = true -$ if cc_com .eqs. "GNUC" then its_gnuc = true -$ endif -$ endif -$ if f$locate("MAKE=",cparm) .lt. f$length(cparm) -$ then -$ start = f$locate("=",cparm) + 1 -$ len = f$length(cparm) - start -$ mmks = f$extract(start,len,cparm) -$ if (mmks .eqs. "MMK") .or. (mmks .eqs. "MMS") -$ then -$ make = mmks -$ else -$ write sys$output "Unsupported make choice ''mmks' ignored" -$ write sys$output "Use MMK or MMS instead" -$ endif -$ endif -$ if cparm .eqs. "HELP" then gosub bhelp -$ endif -$ i = i + 1 -$ goto opt_loop -$ endif -$ return -$!------------------------------------------------------------------------------ -$! -$! Look for the compiler used -$! -$! Version history -$! 0.01 20040223 First version to receive a number -$! 0.02 20040229 Save/set value of decc$no_rooted_search_lists -$! 0.03 20060202 Extend handling of GNU C -$! 0.04 20090402 Compaq -> hp -$CHECK_COMPILER: -$ if (.not. (its_decc .or. its_vaxc .or. its_gnuc)) -$ then -$ its_decc = (f$search("SYS$SYSTEM:DECC$COMPILER.EXE") .nes. "") -$ its_vaxc = .not. its_decc .and. (F$Search("SYS$System:VAXC.Exe") .nes. "") -$ its_gnuc = .not. (its_decc .or. its_vaxc) .and. (f$trnlnm("gnu_cc") .nes. "") -$ endif -$! -$! Exit if no compiler available -$! -$ if (.not. (its_decc .or. its_vaxc .or. its_gnuc)) -$ then goto CC_ERR -$ else -$ if its_decc -$ then -$ write sys$output "CC compiler check ... hp C" -$ if f$trnlnm("decc$no_rooted_search_lists") .nes. "" -$ then -$ dnrsl = f$trnlnm("decc$no_rooted_search_lists") -$ endif -$ define/nolog decc$no_rooted_search_lists 1 -$ else -$ if its_vaxc then write sys$output "CC compiler check ... VAX C" -$ if its_gnuc -$ then -$ write sys$output "CC compiler check ... GNU C" -$ if f$trnlnm(topt) then write topt "gnu_cc:[000000]gcclib.olb/lib" -$ if f$trnlnm(optf) then write optf "gnu_cc:[000000]gcclib.olb/lib" -$ cc = "gcc" -$ endif -$ if f$trnlnm(topt) then write topt "sys$share:vaxcrtl.exe/share" -$ if f$trnlnm(optf) then write optf "sys$share:vaxcrtl.exe/share" -$ endif -$ endif -$ return -$!------------------------------------------------------------------------------ -$! -$! If MMS/MMK are available dump out the descrip.mms if required -$! -$CREA_MMS: -$ write sys$output "Creating descrip.mms..." -$ create descrip.mms -$ open/append out descrip.mms -$ copy sys$input: out -$ deck -# descrip.mms: MMS description file for building zlib on VMS -# written by Martin P.J. Zinser -# - -OBJS = adler32.obj, compress.obj, crc32.obj, gzclose.obj, gzlib.obj\ - gzread.obj, gzwrite.obj, uncompr.obj, infback.obj\ - deflate.obj, trees.obj, zutil.obj, inflate.obj, \ - inftrees.obj, inffast.obj - -$ eod -$ write out "CFLAGS=", ccopt -$ write out "LOPTS=", lopts -$ write out "all : example.exe minigzip.exe libz.olb" -$ copy sys$input: out -$ deck - @ write sys$output " Example applications available" - -libz.olb : libz.olb($(OBJS)) - @ write sys$output " libz available" - -example.exe : example.obj libz.olb - link $(LOPTS) example,libz.olb/lib - -minigzip.exe : minigzip.obj libz.olb - link $(LOPTS) minigzip,libz.olb/lib - -clean : - delete *.obj;*,libz.olb;*,*.opt;*,*.exe;* - - -# Other dependencies. -adler32.obj : adler32.c zutil.h zlib.h zconf.h -compress.obj : compress.c zlib.h zconf.h -crc32.obj : crc32.c zutil.h zlib.h zconf.h -deflate.obj : deflate.c deflate.h zutil.h zlib.h zconf.h -example.obj : [.test]example.c zlib.h zconf.h -gzclose.obj : gzclose.c zutil.h zlib.h zconf.h -gzlib.obj : gzlib.c zutil.h zlib.h zconf.h -gzread.obj : gzread.c zutil.h zlib.h zconf.h -gzwrite.obj : gzwrite.c zutil.h zlib.h zconf.h -inffast.obj : inffast.c zutil.h zlib.h zconf.h inftrees.h inffast.h -inflate.obj : inflate.c zutil.h zlib.h zconf.h -inftrees.obj : inftrees.c zutil.h zlib.h zconf.h inftrees.h -minigzip.obj : [.test]minigzip.c zlib.h zconf.h -trees.obj : trees.c deflate.h zutil.h zlib.h zconf.h -uncompr.obj : uncompr.c zlib.h zconf.h -zutil.obj : zutil.c zutil.h zlib.h zconf.h -infback.obj : infback.c zutil.h inftrees.h inflate.h inffast.h inffixed.h -$ eod -$ close out -$ return -$!------------------------------------------------------------------------------ -$! -$! Read list of core library sources from makefile.in and create options -$! needed to build shareable image -$! -$CREA_OLIST: -$ open/read min makefile.in -$ open/write mod modules.opt -$ src_check_list = "OBJZ =#OBJG =" -$MRLOOP: -$ read/end=mrdone min rec -$ i = 0 -$SRC_CHECK_LOOP: -$ src_check = f$element(i, "#", src_check_list) -$ i = i+1 -$ if src_check .eqs. "#" then goto mrloop -$ if (f$extract(0,6,rec) .nes. src_check) then goto src_check_loop -$ rec = rec - src_check -$ gosub extra_filnam -$ if (f$element(1,"\",rec) .eqs. "\") then goto mrloop -$MRSLOOP: -$ read/end=mrdone min rec -$ gosub extra_filnam -$ if (f$element(1,"\",rec) .nes. "\") then goto mrsloop -$MRDONE: -$ close min -$ close mod -$ return -$!------------------------------------------------------------------------------ -$! -$! Take record extracted in crea_olist and split it into single filenames -$! -$EXTRA_FILNAM: -$ myrec = f$edit(rec - "\", "trim,compress") -$ i = 0 -$FELOOP: -$ srcfil = f$element(i," ", myrec) -$ if (srcfil .nes. " ") -$ then -$ write mod f$parse(srcfil,,,"NAME"), ".obj" -$ i = i + 1 -$ goto feloop -$ endif -$ return -$!------------------------------------------------------------------------------ -$! -$! Find current Zlib version number -$! -$FIND_VERSION: -$ open/read h_in 'v_file' -$hloop: -$ read/end=hdone h_in rec -$ rec = f$edit(rec,"TRIM") -$ if (f$extract(0,1,rec) .nes. "#") then goto hloop -$ rec = f$edit(rec - "#", "TRIM") -$ if f$element(0," ",rec) .nes. "define" then goto hloop -$ if f$element(1," ",rec) .eqs. v_string -$ then -$ version = 'f$element(2," ",rec)' -$ goto hdone -$ endif -$ goto hloop -$hdone: -$ close h_in -$ return -$!------------------------------------------------------------------------------ -$! -$CHECK_CONFIG: -$! -$ in_ldef = f$locate(cdef,libdefs) -$ if (in_ldef .lt. f$length(libdefs)) -$ then -$ write aconf "#define ''cdef' 1" -$ libdefs = f$extract(0,in_ldef,libdefs) + - - f$extract(in_ldef + f$length(cdef) + 1, - - f$length(libdefs) - in_ldef - f$length(cdef) - 1, - - libdefs) -$ else -$ if (f$type('cdef') .eqs. "INTEGER") -$ then -$ write aconf "#define ''cdef' ", 'cdef' -$ else -$ if (f$type('cdef') .eqs. "STRING") -$ then -$ write aconf "#define ''cdef' ", """", '''cdef'', """" -$ else -$ gosub check_cc_def -$ endif -$ endif -$ endif -$ return -$!------------------------------------------------------------------------------ -$! -$! Check if this is a define relating to the properties of the C/C++ -$! compiler -$! -$ CHECK_CC_DEF: -$ if (cdef .eqs. "_LARGEFILE64_SOURCE") -$ then -$ copy sys$input: 'tc' -$ deck -#include "tconfig" -#define _LARGEFILE -#include - -int main(){ -FILE *fp; - fp = fopen("temp.txt","r"); - fseeko(fp,1,SEEK_SET); - fclose(fp); -} - -$ eod -$ test_inv = false -$ comm_h = false -$ gosub cc_prop_check -$ return -$ endif -$ write aconf "/* ", line, " */" -$ return -$!------------------------------------------------------------------------------ -$! -$! Check for properties of C/C++ compiler -$! -$! Version history -$! 0.01 20031020 First version to receive a number -$! 0.02 20031022 Added logic for defines with value -$! 0.03 20040309 Make sure local config file gets not deleted -$! 0.04 20041230 Also write include for configure run -$! 0.05 20050103 Add processing of "comment defines" -$CC_PROP_CHECK: -$ cc_prop = true -$ is_need = false -$ is_need = (f$extract(0,4,cdef) .eqs. "NEED") .or. (test_inv .eq. true) -$ if f$search(th) .eqs. "" then create 'th' -$ set message/nofac/noident/nosever/notext -$ on error then continue -$ cc 'tmpnam' -$ if .not. ($status) then cc_prop = false -$ on error then continue -$! The headers might lie about the capabilities of the RTL -$ link 'tmpnam',tmp.opt/opt -$ if .not. ($status) then cc_prop = false -$ set message/fac/ident/sever/text -$ on error then goto err_exit -$ delete/nolog 'tmpnam'.*;*/exclude='th' -$ if (cc_prop .and. .not. is_need) .or. - - (.not. cc_prop .and. is_need) -$ then -$ write sys$output "Checking for ''cdef'... yes" -$ if f$type('cdef_val'_yes) .nes. "" -$ then -$ if f$type('cdef_val'_yes) .eqs. "INTEGER" - - then call write_config f$fao("#define !AS !UL",cdef,'cdef_val'_yes) -$ if f$type('cdef_val'_yes) .eqs. "STRING" - - then call write_config f$fao("#define !AS !AS",cdef,'cdef_val'_yes) -$ else -$ call write_config f$fao("#define !AS 1",cdef) -$ endif -$ if (cdef .eqs. "HAVE_FSEEKO") .or. (cdef .eqs. "_LARGE_FILES") .or. - - (cdef .eqs. "_LARGEFILE64_SOURCE") then - - call write_config f$string("#define _LARGEFILE 1") -$ else -$ write sys$output "Checking for ''cdef'... no" -$ if (comm_h) -$ then - call write_config f$fao("/* !AS */",line) -$ else -$ if f$type('cdef_val'_no) .nes. "" -$ then -$ if f$type('cdef_val'_no) .eqs. "INTEGER" - - then call write_config f$fao("#define !AS !UL",cdef,'cdef_val'_no) -$ if f$type('cdef_val'_no) .eqs. "STRING" - - then call write_config f$fao("#define !AS !AS",cdef,'cdef_val'_no) -$ else -$ call write_config f$fao("#undef !AS",cdef) -$ endif -$ endif -$ endif -$ return -$!------------------------------------------------------------------------------ -$! -$! Check for properties of C/C++ compiler with multiple result values -$! -$! Version history -$! 0.01 20040127 First version -$! 0.02 20050103 Reconcile changes from cc_prop up to version 0.05 -$CC_MPROP_CHECK: -$ cc_prop = true -$ i = 1 -$ idel = 1 -$ MT_LOOP: -$ if f$type(result_'i') .eqs. "STRING" -$ then -$ set message/nofac/noident/nosever/notext -$ on error then continue -$ cc 'tmpnam'_'i' -$ if .not. ($status) then cc_prop = false -$ on error then continue -$! The headers might lie about the capabilities of the RTL -$ link 'tmpnam'_'i',tmp.opt/opt -$ if .not. ($status) then cc_prop = false -$ set message/fac/ident/sever/text -$ on error then goto err_exit -$ delete/nolog 'tmpnam'_'i'.*;* -$ if (cc_prop) -$ then -$ write sys$output "Checking for ''cdef'... ", mdef_'i' -$ if f$type(mdef_'i') .eqs. "INTEGER" - - then call write_config f$fao("#define !AS !UL",cdef,mdef_'i') -$ if f$type('cdef_val'_yes) .eqs. "STRING" - - then call write_config f$fao("#define !AS !AS",cdef,mdef_'i') -$ goto msym_clean -$ else -$ i = i + 1 -$ goto mt_loop -$ endif -$ endif -$ write sys$output "Checking for ''cdef'... no" -$ call write_config f$fao("#undef !AS",cdef) -$ MSYM_CLEAN: -$ if (idel .le. msym_max) -$ then -$ delete/sym mdef_'idel' -$ idel = idel + 1 -$ goto msym_clean -$ endif -$ return -$!------------------------------------------------------------------------------ -$! -$! Write configuration to both permanent and temporary config file -$! -$! Version history -$! 0.01 20031029 First version to receive a number -$! -$WRITE_CONFIG: SUBROUTINE -$ write aconf 'p1' -$ open/append confh 'th' -$ write confh 'p1' -$ close confh -$ENDSUBROUTINE -$!------------------------------------------------------------------------------ -$! -$! Analyze the project map file and create the symbol vector for a shareable -$! image from it -$! -$! Version history -$! 0.01 20120128 First version -$! 0.02 20120226 Add pre-load logic -$! -$ MAP_2_SHOPT: Subroutine -$! -$ SAY := "WRITE_ SYS$OUTPUT" -$! -$ IF F$SEARCH("''P1'") .EQS. "" -$ THEN -$ SAY "MAP_2_SHOPT-E-NOSUCHFILE: Error, inputfile ''p1' not available" -$ goto exit_m2s -$ ENDIF -$ IF "''P2'" .EQS. "" -$ THEN -$ SAY "MAP_2_SHOPT: Error, no output file provided" -$ goto exit_m2s -$ ENDIF -$! -$ module1 = "deflate#deflateEnd#deflateInit_#deflateParams#deflateSetDictionary" -$ module2 = "gzclose#gzerror#gzgetc#gzgets#gzopen#gzprintf#gzputc#gzputs#gzread" -$ module3 = "gzseek#gztell#inflate#inflateEnd#inflateInit_#inflateSetDictionary" -$ module4 = "inflateSync#uncompress#zlibVersion#compress" -$ open/read map 'p1 -$ if axp .or. ia64 -$ then -$ open/write aopt a.opt -$ open/write bopt b.opt -$ write aopt " CASE_SENSITIVE=YES" -$ write bopt "SYMBOL_VECTOR= (-" -$ mod_sym_num = 1 -$ MOD_SYM_LOOP: -$ if f$type(module'mod_sym_num') .nes. "" -$ then -$ mod_in = 0 -$ MOD_SYM_IN: -$ shared_proc = f$element(mod_in, "#", module'mod_sym_num') -$ if shared_proc .nes. "#" -$ then -$ write aopt f$fao(" symbol_vector=(!AS/!AS=PROCEDURE)",- - f$edit(shared_proc,"upcase"),shared_proc) -$ write bopt f$fao("!AS=PROCEDURE,-",shared_proc) -$ mod_in = mod_in + 1 -$ goto mod_sym_in -$ endif -$ mod_sym_num = mod_sym_num + 1 -$ goto mod_sym_loop -$ endif -$MAP_LOOP: -$ read/end=map_end map line -$ if (f$locate("{",line).lt. f$length(line)) .or. - - (f$locate("global:", line) .lt. f$length(line)) -$ then -$ proc = true -$ goto map_loop -$ endif -$ if f$locate("}",line).lt. f$length(line) then proc = false -$ if f$locate("local:", line) .lt. f$length(line) then proc = false -$ if proc -$ then -$ shared_proc = f$edit(line,"collapse") -$ chop_semi = f$locate(";", shared_proc) -$ if chop_semi .lt. f$length(shared_proc) then - - shared_proc = f$extract(0, chop_semi, shared_proc) -$ write aopt f$fao(" symbol_vector=(!AS/!AS=PROCEDURE)",- - f$edit(shared_proc,"upcase"),shared_proc) -$ write bopt f$fao("!AS=PROCEDURE,-",shared_proc) -$ endif -$ goto map_loop -$MAP_END: -$ close/nolog aopt -$ close/nolog bopt -$ open/append libopt 'p2' -$ open/read aopt a.opt -$ open/read bopt b.opt -$ALOOP: -$ read/end=aloop_end aopt line -$ write libopt line -$ goto aloop -$ALOOP_END: -$ close/nolog aopt -$ sv = "" -$BLOOP: -$ read/end=bloop_end bopt svn -$ if (svn.nes."") -$ then -$ if (sv.nes."") then write libopt sv -$ sv = svn -$ endif -$ goto bloop -$BLOOP_END: -$ write libopt f$extract(0,f$length(sv)-2,sv), "-" -$ write libopt ")" -$ close/nolog bopt -$ delete/nolog/noconf a.opt;*,b.opt;* -$ else -$ if vax -$ then -$ open/append libopt 'p2' -$ mod_sym_num = 1 -$ VMOD_SYM_LOOP: -$ if f$type(module'mod_sym_num') .nes. "" -$ then -$ mod_in = 0 -$ VMOD_SYM_IN: -$ shared_proc = f$element(mod_in, "#", module'mod_sym_num') -$ if shared_proc .nes. "#" -$ then -$ write libopt f$fao("UNIVERSAL=!AS",- - f$edit(shared_proc,"upcase")) -$ mod_in = mod_in + 1 -$ goto vmod_sym_in -$ endif -$ mod_sym_num = mod_sym_num + 1 -$ goto vmod_sym_loop -$ endif -$VMAP_LOOP: -$ read/end=vmap_end map line -$ if (f$locate("{",line).lt. f$length(line)) .or. - - (f$locate("global:", line) .lt. f$length(line)) -$ then -$ proc = true -$ goto vmap_loop -$ endif -$ if f$locate("}",line).lt. f$length(line) then proc = false -$ if f$locate("local:", line) .lt. f$length(line) then proc = false -$ if proc -$ then -$ shared_proc = f$edit(line,"collapse") -$ chop_semi = f$locate(";", shared_proc) -$ if chop_semi .lt. f$length(shared_proc) then - - shared_proc = f$extract(0, chop_semi, shared_proc) -$ write libopt f$fao("UNIVERSAL=!AS",- - f$edit(shared_proc,"upcase")) -$ endif -$ goto vmap_loop -$VMAP_END: -$ else -$ write sys$output "Unknown Architecture (Not VAX, AXP, or IA64)" -$ write sys$output "No options file created" -$ endif -$ endif -$ EXIT_M2S: -$ close/nolog map -$ close/nolog libopt -$ endsubroutine diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/msdos/Makefile.bor b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/msdos/Makefile.bor deleted file mode 100644 index 3d12a2c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/msdos/Makefile.bor +++ /dev/null @@ -1,115 +0,0 @@ -# Makefile for zlib -# Borland C++ -# Last updated: 15-Mar-2003 - -# To use, do "make -fmakefile.bor" -# To compile in small model, set below: MODEL=s - -# WARNING: the small model is supported but only for small values of -# MAX_WBITS and MAX_MEM_LEVEL. For example: -# -DMAX_WBITS=11 -DDEF_WBITS=11 -DMAX_MEM_LEVEL=3 -# If you wish to reduce the memory requirements (default 256K for big -# objects plus a few K), you can add to the LOC macro below: -# -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14 -# See zconf.h for details about the memory requirements. - -# ------------ Turbo C++, Borland C++ ------------ - -# Optional nonstandard preprocessor flags (e.g. -DMAX_MEM_LEVEL=7) -# should be added to the environment via "set LOCAL_ZLIB=-DFOO" or added -# to the declaration of LOC here: -LOC = $(LOCAL_ZLIB) - -# type for CPU required: 0: 8086, 1: 80186, 2: 80286, 3: 80386, etc. -CPU_TYP = 0 - -# memory model: one of s, m, c, l (small, medium, compact, large) -MODEL=l - -# replace bcc with tcc for Turbo C++ 1.0, with bcc32 for the 32 bit version -CC=bcc -LD=bcc -AR=tlib - -# compiler flags -# replace "-O2" by "-O -G -a -d" for Turbo C++ 1.0 -CFLAGS=-O2 -Z -m$(MODEL) $(LOC) - -LDFLAGS=-m$(MODEL) -f- - - -# variables -ZLIB_LIB = zlib_$(MODEL).lib - -OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj -OBJ2 = gzwrite.obj infback.obj inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj -OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzclose.obj+gzlib.obj+gzread.obj -OBJP2 = +gzwrite.obj+infback.obj+inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj - - -# targets -all: $(ZLIB_LIB) example.exe minigzip.exe - -.c.obj: - $(CC) -c $(CFLAGS) $*.c - -adler32.obj: adler32.c zlib.h zconf.h - -compress.obj: compress.c zlib.h zconf.h - -crc32.obj: crc32.c zlib.h zconf.h crc32.h - -deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h - -gzclose.obj: gzclose.c zlib.h zconf.h gzguts.h - -gzlib.obj: gzlib.c zlib.h zconf.h gzguts.h - -gzread.obj: gzread.c zlib.h zconf.h gzguts.h - -gzwrite.obj: gzwrite.c zlib.h zconf.h gzguts.h - -infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ - inffast.h inffixed.h - -inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ - inffast.h - -inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ - inffast.h inffixed.h - -inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h - -trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h - -uncompr.obj: uncompr.c zlib.h zconf.h - -zutil.obj: zutil.c zutil.h zlib.h zconf.h - -example.obj: test/example.c zlib.h zconf.h - -minigzip.obj: test/minigzip.c zlib.h zconf.h - - -# the command line is cut to fit in the MS-DOS 128 byte limit: -$(ZLIB_LIB): $(OBJ1) $(OBJ2) - -del $(ZLIB_LIB) - $(AR) $(ZLIB_LIB) $(OBJP1) - $(AR) $(ZLIB_LIB) $(OBJP2) - -example.exe: example.obj $(ZLIB_LIB) - $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB) - -minigzip.exe: minigzip.obj $(ZLIB_LIB) - $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB) - -test: example.exe minigzip.exe - example - echo hello world | minigzip | minigzip -d - -clean: - -del *.obj - -del *.lib - -del *.exe - -del zlib_*.bak - -del foo.gz diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/msdos/Makefile.dj2 b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/msdos/Makefile.dj2 deleted file mode 100644 index 59d2037..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/msdos/Makefile.dj2 +++ /dev/null @@ -1,104 +0,0 @@ -# Makefile for zlib. Modified for djgpp v2.0 by F. J. Donahoe, 3/15/96. -# Copyright (C) 1995-1998 Jean-loup Gailly. -# For conditions of distribution and use, see copyright notice in zlib.h - -# To compile, or to compile and test, type: -# -# make -fmakefile.dj2; make test -fmakefile.dj2 -# -# To install libz.a, zconf.h and zlib.h in the djgpp directories, type: -# -# make install -fmakefile.dj2 -# -# after first defining LIBRARY_PATH and INCLUDE_PATH in djgpp.env as -# in the sample below if the pattern of the DJGPP distribution is to -# be followed. Remember that, while 'es around <=> are ignored in -# makefiles, they are *not* in batch files or in djgpp.env. -# - - - - - -# [make] -# INCLUDE_PATH=%\>;INCLUDE_PATH%%\DJDIR%\include -# LIBRARY_PATH=%\>;LIBRARY_PATH%%\DJDIR%\lib -# BUTT=-m486 -# - - - - - -# Alternately, these variables may be defined below, overriding the values -# in djgpp.env, as -# INCLUDE_PATH=c:\usr\include -# LIBRARY_PATH=c:\usr\lib - -CC=gcc - -#CFLAGS=-MMD -O -#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 -#CFLAGS=-MMD -g -DZLIB_DEBUG -CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ - -Wstrict-prototypes -Wmissing-prototypes - -# If cp.exe is available, replace "copy /Y" with "cp -fp" . -CP=copy /Y -# If gnu install.exe is available, replace $(CP) with ginstall. -INSTALL=$(CP) -# The default value of RM is "rm -f." If "rm.exe" is found, comment out: -RM=del -LDLIBS=-L. -lz -LD=$(CC) -s -o -LDSHARED=$(CC) - -INCL=zlib.h zconf.h -LIBS=libz.a - -AR=ar rcs - -prefix=/usr/local -exec_prefix = $(prefix) - -OBJS = adler32.o compress.o crc32.o gzclose.o gzlib.o gzread.o gzwrite.o \ - uncompr.o deflate.o trees.o zutil.o inflate.o infback.o inftrees.o inffast.o - -OBJA = -# to use the asm code: make OBJA=match.o - -TEST_OBJS = example.o minigzip.o - -all: example.exe minigzip.exe - -check: test -test: all - ./example - echo hello world | .\minigzip | .\minigzip -d - -%.o : %.c - $(CC) $(CFLAGS) -c $< -o $@ - -libz.a: $(OBJS) $(OBJA) - $(AR) $@ $(OBJS) $(OBJA) - -%.exe : %.o $(LIBS) - $(LD) $@ $< $(LDLIBS) - -# INCLUDE_PATH and LIBRARY_PATH were set for [make] in djgpp.env . - -.PHONY : uninstall clean - -install: $(INCL) $(LIBS) - -@if not exist $(INCLUDE_PATH)\nul mkdir $(INCLUDE_PATH) - -@if not exist $(LIBRARY_PATH)\nul mkdir $(LIBRARY_PATH) - $(INSTALL) zlib.h $(INCLUDE_PATH) - $(INSTALL) zconf.h $(INCLUDE_PATH) - $(INSTALL) libz.a $(LIBRARY_PATH) - -uninstall: - $(RM) $(INCLUDE_PATH)\zlib.h - $(RM) $(INCLUDE_PATH)\zconf.h - $(RM) $(LIBRARY_PATH)\libz.a - -clean: - $(RM) *.d - $(RM) *.o - $(RM) *.exe - $(RM) libz.a - $(RM) foo.gz - -DEPS := $(wildcard *.d) -ifneq ($(DEPS),) -include $(DEPS) -endif diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/msdos/Makefile.emx b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/msdos/Makefile.emx deleted file mode 100644 index e30f67b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/msdos/Makefile.emx +++ /dev/null @@ -1,69 +0,0 @@ -# Makefile for zlib. Modified for emx 0.9c by Chr. Spieler, 6/17/98. -# Copyright (C) 1995-1998 Jean-loup Gailly. -# For conditions of distribution and use, see copyright notice in zlib.h - -# To compile, or to compile and test, type: -# -# make -fmakefile.emx; make test -fmakefile.emx -# - -CC=gcc - -#CFLAGS=-MMD -O -#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 -#CFLAGS=-MMD -g -DZLIB_DEBUG -CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ - -Wstrict-prototypes -Wmissing-prototypes - -# If cp.exe is available, replace "copy /Y" with "cp -fp" . -CP=copy /Y -# If gnu install.exe is available, replace $(CP) with ginstall. -INSTALL=$(CP) -# The default value of RM is "rm -f." If "rm.exe" is found, comment out: -RM=del -LDLIBS=-L. -lzlib -LD=$(CC) -s -o -LDSHARED=$(CC) - -INCL=zlib.h zconf.h -LIBS=zlib.a - -AR=ar rcs - -prefix=/usr/local -exec_prefix = $(prefix) - -OBJS = adler32.o compress.o crc32.o gzclose.o gzlib.o gzread.o gzwrite.o \ - uncompr.o deflate.o trees.o zutil.o inflate.o infback.o inftrees.o inffast.o - -TEST_OBJS = example.o minigzip.o - -all: example.exe minigzip.exe - -test: all - ./example - echo hello world | .\minigzip | .\minigzip -d - -%.o : %.c - $(CC) $(CFLAGS) -c $< -o $@ - -zlib.a: $(OBJS) - $(AR) $@ $(OBJS) - -%.exe : %.o $(LIBS) - $(LD) $@ $< $(LDLIBS) - - -.PHONY : clean - -clean: - $(RM) *.d - $(RM) *.o - $(RM) *.exe - $(RM) zlib.a - $(RM) foo.gz - -DEPS := $(wildcard *.d) -ifneq ($(DEPS),) -include $(DEPS) -endif diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/msdos/Makefile.msc b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/msdos/Makefile.msc deleted file mode 100644 index ae83786..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/msdos/Makefile.msc +++ /dev/null @@ -1,112 +0,0 @@ -# Makefile for zlib -# Microsoft C 5.1 or later -# Last updated: 19-Mar-2003 - -# To use, do "make makefile.msc" -# To compile in small model, set below: MODEL=S - -# If you wish to reduce the memory requirements (default 256K for big -# objects plus a few K), you can add to the LOC macro below: -# -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14 -# See zconf.h for details about the memory requirements. - -# ------------- Microsoft C 5.1 and later ------------- - -# Optional nonstandard preprocessor flags (e.g. -DMAX_MEM_LEVEL=7) -# should be added to the environment via "set LOCAL_ZLIB=-DFOO" or added -# to the declaration of LOC here: -LOC = $(LOCAL_ZLIB) - -# Type for CPU required: 0: 8086, 1: 80186, 2: 80286, 3: 80386, etc. -CPU_TYP = 0 - -# Memory model: one of S, M, C, L (small, medium, compact, large) -MODEL=L - -CC=cl -CFLAGS=-nologo -A$(MODEL) -G$(CPU_TYP) -W3 -Oait -Gs $(LOC) -#-Ox generates bad code with MSC 5.1 -LIB_CFLAGS=-Zl $(CFLAGS) - -LD=link -LDFLAGS=/noi/e/st:0x1500/noe/farcall/packcode -# "/farcall/packcode" are only useful for `large code' memory models -# but should be a "no-op" for small code models. - - -# variables -ZLIB_LIB = zlib_$(MODEL).lib - -OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj -OBJ2 = gzwrite.obj infback.obj inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj - - -# targets -all: $(ZLIB_LIB) example.exe minigzip.exe - -.c.obj: - $(CC) -c $(LIB_CFLAGS) $*.c - -adler32.obj: adler32.c zlib.h zconf.h - -compress.obj: compress.c zlib.h zconf.h - -crc32.obj: crc32.c zlib.h zconf.h crc32.h - -deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h - -gzclose.obj: gzclose.c zlib.h zconf.h gzguts.h - -gzlib.obj: gzlib.c zlib.h zconf.h gzguts.h - -gzread.obj: gzread.c zlib.h zconf.h gzguts.h - -gzwrite.obj: gzwrite.c zlib.h zconf.h gzguts.h - -infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ - inffast.h inffixed.h - -inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ - inffast.h - -inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ - inffast.h inffixed.h - -inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h - -trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h - -uncompr.obj: uncompr.c zlib.h zconf.h - -zutil.obj: zutil.c zutil.h zlib.h zconf.h - -example.obj: test/example.c zlib.h zconf.h - $(CC) -c $(CFLAGS) $*.c - -minigzip.obj: test/minigzip.c zlib.h zconf.h - $(CC) -c $(CFLAGS) $*.c - - -# the command line is cut to fit in the MS-DOS 128 byte limit: -$(ZLIB_LIB): $(OBJ1) $(OBJ2) - if exist $(ZLIB_LIB) del $(ZLIB_LIB) - lib $(ZLIB_LIB) $(OBJ1); - lib $(ZLIB_LIB) $(OBJ2); - -example.exe: example.obj $(ZLIB_LIB) - $(LD) $(LDFLAGS) example.obj,,,$(ZLIB_LIB); - -minigzip.exe: minigzip.obj $(ZLIB_LIB) - $(LD) $(LDFLAGS) minigzip.obj,,,$(ZLIB_LIB); - -test: example.exe minigzip.exe - example - echo hello world | minigzip | minigzip -d - -clean: - -del *.obj - -del *.lib - -del *.exe - -del *.map - -del zlib_*.bak - -del foo.gz diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/msdos/Makefile.tc b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/msdos/Makefile.tc deleted file mode 100644 index 5aec82a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/msdos/Makefile.tc +++ /dev/null @@ -1,100 +0,0 @@ -# Makefile for zlib -# Turbo C 2.01, Turbo C++ 1.01 -# Last updated: 15-Mar-2003 - -# To use, do "make -fmakefile.tc" -# To compile in small model, set below: MODEL=s - -# WARNING: the small model is supported but only for small values of -# MAX_WBITS and MAX_MEM_LEVEL. For example: -# -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3 -# If you wish to reduce the memory requirements (default 256K for big -# objects plus a few K), you can add to CFLAGS below: -# -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14 -# See zconf.h for details about the memory requirements. - -# ------------ Turbo C 2.01, Turbo C++ 1.01 ------------ -MODEL=l -CC=tcc -LD=tcc -AR=tlib -# CFLAGS=-O2 -G -Z -m$(MODEL) -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3 -CFLAGS=-O2 -G -Z -m$(MODEL) -LDFLAGS=-m$(MODEL) -f- - - -# variables -ZLIB_LIB = zlib_$(MODEL).lib - -OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj -OBJ2 = gzwrite.obj infback.obj inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj -OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzclose.obj+gzlib.obj+gzread.obj -OBJP2 = +gzwrite.obj+infback.obj+inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj - - -# targets -all: $(ZLIB_LIB) example.exe minigzip.exe - -.c.obj: - $(CC) -c $(CFLAGS) $*.c - -adler32.obj: adler32.c zlib.h zconf.h - -compress.obj: compress.c zlib.h zconf.h - -crc32.obj: crc32.c zlib.h zconf.h crc32.h - -deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h - -gzclose.obj: gzclose.c zlib.h zconf.h gzguts.h - -gzlib.obj: gzlib.c zlib.h zconf.h gzguts.h - -gzread.obj: gzread.c zlib.h zconf.h gzguts.h - -gzwrite.obj: gzwrite.c zlib.h zconf.h gzguts.h - -infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ - inffast.h inffixed.h - -inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ - inffast.h - -inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ - inffast.h inffixed.h - -inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h - -trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h - -uncompr.obj: uncompr.c zlib.h zconf.h - -zutil.obj: zutil.c zutil.h zlib.h zconf.h - -example.obj: test/example.c zlib.h zconf.h - -minigzip.obj: test/minigzip.c zlib.h zconf.h - - -# the command line is cut to fit in the MS-DOS 128 byte limit: -$(ZLIB_LIB): $(OBJ1) $(OBJ2) - -del $(ZLIB_LIB) - $(AR) $(ZLIB_LIB) $(OBJP1) - $(AR) $(ZLIB_LIB) $(OBJP2) - -example.exe: example.obj $(ZLIB_LIB) - $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB) - -minigzip.exe: minigzip.obj $(ZLIB_LIB) - $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB) - -test: example.exe minigzip.exe - example - echo hello world | minigzip | minigzip -d - -clean: - -del *.obj - -del *.lib - -del *.exe - -del zlib_*.bak - -del foo.gz diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/nintendods/Makefile b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/nintendods/Makefile deleted file mode 100644 index 21337d0..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/nintendods/Makefile +++ /dev/null @@ -1,126 +0,0 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- - -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif - -include $(DEVKITARM)/ds_rules - -#--------------------------------------------------------------------------------- -# TARGET is the name of the output -# BUILD is the directory where object files & intermediate files will be placed -# SOURCES is a list of directories containing source code -# DATA is a list of directories containing data files -# INCLUDES is a list of directories containing header files -#--------------------------------------------------------------------------------- -TARGET := $(shell basename $(CURDIR)) -BUILD := build -SOURCES := ../../ -DATA := data -INCLUDES := include - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -mthumb -mthumb-interwork - -CFLAGS := -Wall -O2\ - -march=armv5te -mtune=arm946e-s \ - -fomit-frame-pointer -ffast-math \ - $(ARCH) - -CFLAGS += $(INCLUDE) -DARM9 -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions - -ASFLAGS := $(ARCH) -march=armv5te -mtune=arm946e-s -LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -#--------------------------------------------------------------------------------- -# list of directories containing libraries, this must be the top level containing -# include and lib -#--------------------------------------------------------------------------------- -LIBDIRS := $(LIBNDS) - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export OUTPUT := $(CURDIR)/lib/libz.a - -export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ - $(foreach dir,$(DATA),$(CURDIR)/$(dir)) - -export DEPSDIR := $(CURDIR)/$(BUILD) - -CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) -CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) -SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) -BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) - -#--------------------------------------------------------------------------------- -# use CXX for linking C++ projects, CC for standard C -#--------------------------------------------------------------------------------- -ifeq ($(strip $(CPPFILES)),) -#--------------------------------------------------------------------------------- - export LD := $(CC) -#--------------------------------------------------------------------------------- -else -#--------------------------------------------------------------------------------- - export LD := $(CXX) -#--------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------- - -export OFILES := $(addsuffix .o,$(BINFILES)) \ - $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) - -export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ - $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ - -I$(CURDIR)/$(BUILD) - -.PHONY: $(BUILD) clean all - -#--------------------------------------------------------------------------------- -all: $(BUILD) - @[ -d $@ ] || mkdir -p include - @cp ../../*.h include - -lib: - @[ -d $@ ] || mkdir -p $@ - -$(BUILD): lib - @[ -d $@ ] || mkdir -p $@ - @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr $(BUILD) lib - -#--------------------------------------------------------------------------------- -else - -DEPENDS := $(OFILES:.o=.d) - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT) : $(OFILES) - -#--------------------------------------------------------------------------------- -%.bin.o : %.bin -#--------------------------------------------------------------------------------- - @echo $(notdir $<) - @$(bin2o) - - --include $(DEPENDS) - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/nintendods/README b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/nintendods/README deleted file mode 100644 index ba7a37d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/nintendods/README +++ /dev/null @@ -1,5 +0,0 @@ -This Makefile requires devkitARM (http://www.devkitpro.org/category/devkitarm/) and works inside "contrib/nds". It is based on a devkitARM template. - -Eduardo Costa -January 3, 2009 - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/old/Makefile.emx b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/old/Makefile.emx deleted file mode 100644 index 612b037..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/old/Makefile.emx +++ /dev/null @@ -1,69 +0,0 @@ -# Makefile for zlib. Modified for emx/rsxnt by Chr. Spieler, 6/16/98. -# Copyright (C) 1995-1998 Jean-loup Gailly. -# For conditions of distribution and use, see copyright notice in zlib.h - -# To compile, or to compile and test, type: -# -# make -fmakefile.emx; make test -fmakefile.emx -# - -CC=gcc -Zwin32 - -#CFLAGS=-MMD -O -#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 -#CFLAGS=-MMD -g -DZLIB_DEBUG -CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ - -Wstrict-prototypes -Wmissing-prototypes - -# If cp.exe is available, replace "copy /Y" with "cp -fp" . -CP=copy /Y -# If gnu install.exe is available, replace $(CP) with ginstall. -INSTALL=$(CP) -# The default value of RM is "rm -f." If "rm.exe" is found, comment out: -RM=del -LDLIBS=-L. -lzlib -LD=$(CC) -s -o -LDSHARED=$(CC) - -INCL=zlib.h zconf.h -LIBS=zlib.a - -AR=ar rcs - -prefix=/usr/local -exec_prefix = $(prefix) - -OBJS = adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o \ - gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o - -TEST_OBJS = example.o minigzip.o - -all: example.exe minigzip.exe - -test: all - ./example - echo hello world | .\minigzip | .\minigzip -d - -%.o : %.c - $(CC) $(CFLAGS) -c $< -o $@ - -zlib.a: $(OBJS) - $(AR) $@ $(OBJS) - -%.exe : %.o $(LIBS) - $(LD) $@ $< $(LDLIBS) - - -.PHONY : clean - -clean: - $(RM) *.d - $(RM) *.o - $(RM) *.exe - $(RM) zlib.a - $(RM) foo.gz - -DEPS := $(wildcard *.d) -ifneq ($(DEPS),) -include $(DEPS) -endif diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/old/Makefile.riscos b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/old/Makefile.riscos deleted file mode 100644 index 57e29d3..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/old/Makefile.riscos +++ /dev/null @@ -1,151 +0,0 @@ -# Project: zlib_1_03 -# Patched for zlib 1.1.2 rw@shadow.org.uk 19980430 -# test works out-of-the-box, installs `somewhere' on demand - -# Toolflags: -CCflags = -c -depend !Depend -IC: -g -throwback -DRISCOS -fah -C++flags = -c -depend !Depend -IC: -throwback -Linkflags = -aif -c++ -o $@ -ObjAsmflags = -throwback -NoCache -depend !Depend -CMHGflags = -LibFileflags = -c -l -o $@ -Squeezeflags = -o $@ - -# change the line below to where _you_ want the library installed. -libdest = lib:zlib - -# Final targets: -@.lib: @.o.adler32 @.o.compress @.o.crc32 @.o.deflate @.o.gzio \ - @.o.infblock @.o.infcodes @.o.inffast @.o.inflate @.o.inftrees @.o.infutil @.o.trees \ - @.o.uncompr @.o.zutil - LibFile $(LibFileflags) @.o.adler32 @.o.compress @.o.crc32 @.o.deflate \ - @.o.gzio @.o.infblock @.o.infcodes @.o.inffast @.o.inflate @.o.inftrees @.o.infutil \ - @.o.trees @.o.uncompr @.o.zutil -test: @.minigzip @.example @.lib - @copy @.lib @.libc A~C~DF~L~N~P~Q~RS~TV - @echo running tests: hang on. - @/@.minigzip -f -9 libc - @/@.minigzip -d libc-gz - @/@.minigzip -f -1 libc - @/@.minigzip -d libc-gz - @/@.minigzip -h -9 libc - @/@.minigzip -d libc-gz - @/@.minigzip -h -1 libc - @/@.minigzip -d libc-gz - @/@.minigzip -9 libc - @/@.minigzip -d libc-gz - @/@.minigzip -1 libc - @/@.minigzip -d libc-gz - @diff @.lib @.libc - @echo that should have reported '@.lib and @.libc identical' if you have diff. - @/@.example @.fred @.fred - @echo that will have given lots of hello!'s. - -@.minigzip: @.o.minigzip @.lib C:o.Stubs - Link $(Linkflags) @.o.minigzip @.lib C:o.Stubs -@.example: @.o.example @.lib C:o.Stubs - Link $(Linkflags) @.o.example @.lib C:o.Stubs - -install: @.lib - cdir $(libdest) - cdir $(libdest).h - @copy @.h.zlib $(libdest).h.zlib A~C~DF~L~N~P~Q~RS~TV - @copy @.h.zconf $(libdest).h.zconf A~C~DF~L~N~P~Q~RS~TV - @copy @.lib $(libdest).lib A~C~DF~L~N~P~Q~RS~TV - @echo okay, installed zlib in $(libdest) - -clean:; remove @.minigzip - remove @.example - remove @.libc - -wipe @.o.* F~r~cV - remove @.fred - -# User-editable dependencies: -.c.o: - cc $(ccflags) -o $@ $< - -# Static dependencies: - -# Dynamic dependencies: -o.example: c.example -o.example: h.zlib -o.example: h.zconf -o.minigzip: c.minigzip -o.minigzip: h.zlib -o.minigzip: h.zconf -o.adler32: c.adler32 -o.adler32: h.zlib -o.adler32: h.zconf -o.compress: c.compress -o.compress: h.zlib -o.compress: h.zconf -o.crc32: c.crc32 -o.crc32: h.zlib -o.crc32: h.zconf -o.deflate: c.deflate -o.deflate: h.deflate -o.deflate: h.zutil -o.deflate: h.zlib -o.deflate: h.zconf -o.gzio: c.gzio -o.gzio: h.zutil -o.gzio: h.zlib -o.gzio: h.zconf -o.infblock: c.infblock -o.infblock: h.zutil -o.infblock: h.zlib -o.infblock: h.zconf -o.infblock: h.infblock -o.infblock: h.inftrees -o.infblock: h.infcodes -o.infblock: h.infutil -o.infcodes: c.infcodes -o.infcodes: h.zutil -o.infcodes: h.zlib -o.infcodes: h.zconf -o.infcodes: h.inftrees -o.infcodes: h.infblock -o.infcodes: h.infcodes -o.infcodes: h.infutil -o.infcodes: h.inffast -o.inffast: c.inffast -o.inffast: h.zutil -o.inffast: h.zlib -o.inffast: h.zconf -o.inffast: h.inftrees -o.inffast: h.infblock -o.inffast: h.infcodes -o.inffast: h.infutil -o.inffast: h.inffast -o.inflate: c.inflate -o.inflate: h.zutil -o.inflate: h.zlib -o.inflate: h.zconf -o.inflate: h.infblock -o.inftrees: c.inftrees -o.inftrees: h.zutil -o.inftrees: h.zlib -o.inftrees: h.zconf -o.inftrees: h.inftrees -o.inftrees: h.inffixed -o.infutil: c.infutil -o.infutil: h.zutil -o.infutil: h.zlib -o.infutil: h.zconf -o.infutil: h.infblock -o.infutil: h.inftrees -o.infutil: h.infcodes -o.infutil: h.infutil -o.trees: c.trees -o.trees: h.deflate -o.trees: h.zutil -o.trees: h.zlib -o.trees: h.zconf -o.trees: h.trees -o.uncompr: c.uncompr -o.uncompr: h.zlib -o.uncompr: h.zconf -o.zutil: c.zutil -o.zutil: h.zutil -o.zutil: h.zlib -o.zutil: h.zconf diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/old/README b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/old/README deleted file mode 100644 index 800bf07..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/old/README +++ /dev/null @@ -1,3 +0,0 @@ -This directory contains files that have not been updated for zlib 1.2.x - -(Volunteers are encouraged to help clean this up. Thanks.) diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/old/descrip.mms b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/old/descrip.mms deleted file mode 100644 index 7066da5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/old/descrip.mms +++ /dev/null @@ -1,48 +0,0 @@ -# descrip.mms: MMS description file for building zlib on VMS -# written by Martin P.J. Zinser - -cc_defs = -c_deb = - -.ifdef __DECC__ -pref = /prefix=all -.endif - -OBJS = adler32.obj, compress.obj, crc32.obj, gzio.obj, uncompr.obj,\ - deflate.obj, trees.obj, zutil.obj, inflate.obj, infblock.obj,\ - inftrees.obj, infcodes.obj, infutil.obj, inffast.obj - -CFLAGS= $(C_DEB) $(CC_DEFS) $(PREF) - -all : example.exe minigzip.exe - @ write sys$output " Example applications available" -libz.olb : libz.olb($(OBJS)) - @ write sys$output " libz available" - -example.exe : example.obj libz.olb - link example,libz.olb/lib - -minigzip.exe : minigzip.obj libz.olb - link minigzip,libz.olb/lib,x11vms:xvmsutils.olb/lib - -clean : - delete *.obj;*,libz.olb;* - - -# Other dependencies. -adler32.obj : zutil.h zlib.h zconf.h -compress.obj : zlib.h zconf.h -crc32.obj : zutil.h zlib.h zconf.h -deflate.obj : deflate.h zutil.h zlib.h zconf.h -example.obj : zlib.h zconf.h -gzio.obj : zutil.h zlib.h zconf.h -infblock.obj : zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h -infcodes.obj : zutil.h zlib.h zconf.h inftrees.h infutil.h infcodes.h inffast.h -inffast.obj : zutil.h zlib.h zconf.h inftrees.h infutil.h inffast.h -inflate.obj : zutil.h zlib.h zconf.h infblock.h -inftrees.obj : zutil.h zlib.h zconf.h inftrees.h -infutil.obj : zutil.h zlib.h zconf.h inftrees.h infutil.h -minigzip.obj : zlib.h zconf.h -trees.obj : deflate.h zutil.h zlib.h zconf.h -uncompr.obj : zlib.h zconf.h -zutil.obj : zutil.h zlib.h zconf.h diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/old/os2/Makefile.os2 b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/old/os2/Makefile.os2 deleted file mode 100644 index bb426c0..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/old/os2/Makefile.os2 +++ /dev/null @@ -1,136 +0,0 @@ -# Makefile for zlib under OS/2 using GCC (PGCC) -# For conditions of distribution and use, see copyright notice in zlib.h - -# To compile and test, type: -# cp Makefile.os2 .. -# cd .. -# make -f Makefile.os2 test - -# This makefile will build a static library z.lib, a shared library -# z.dll and a import library zdll.lib. You can use either z.lib or -# zdll.lib by specifying either -lz or -lzdll on gcc's command line - -CC=gcc -Zomf -s - -CFLAGS=-O6 -Wall -#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 -#CFLAGS=-g -DZLIB_DEBUG -#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ -# -Wstrict-prototypes -Wmissing-prototypes - -#################### BUG WARNING: ##################### -## infcodes.c hits a bug in pgcc-1.0, so you have to use either -## -O# where # <= 4 or one of (-fno-ommit-frame-pointer or -fno-force-mem) -## This bug is reportedly fixed in pgcc >1.0, but this was not tested -CFLAGS+=-fno-force-mem - -LDFLAGS=-s -L. -lzdll -Zcrtdll -LDSHARED=$(CC) -s -Zomf -Zdll -Zcrtdll - -VER=1.1.0 -ZLIB=z.lib -SHAREDLIB=z.dll -SHAREDLIBIMP=zdll.lib -LIBS=$(ZLIB) $(SHAREDLIB) $(SHAREDLIBIMP) - -AR=emxomfar cr -IMPLIB=emximp -RANLIB=echo -TAR=tar -SHELL=bash - -prefix=/usr/local -exec_prefix = $(prefix) - -OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ - zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o - -TEST_OBJS = example.o minigzip.o - -DISTFILES = README INDEX ChangeLog configure Make*[a-z0-9] *.[ch] descrip.mms \ - algorithm.txt zlib.3 msdos/Make*[a-z0-9] msdos/zlib.def msdos/zlib.rc \ - nt/Makefile.nt nt/zlib.dnt contrib/README.contrib contrib/*.txt \ - contrib/asm386/*.asm contrib/asm386/*.c \ - contrib/asm386/*.bat contrib/asm386/zlibvc.d?? contrib/iostream/*.cpp \ - contrib/iostream/*.h contrib/iostream2/*.h contrib/iostream2/*.cpp \ - contrib/untgz/Makefile contrib/untgz/*.c contrib/untgz/*.w32 - -all: example.exe minigzip.exe - -test: all - @LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \ - echo hello world | ./minigzip | ./minigzip -d || \ - echo ' *** minigzip test FAILED ***' ; \ - if ./example; then \ - echo ' *** zlib test OK ***'; \ - else \ - echo ' *** zlib test FAILED ***'; \ - fi - -$(ZLIB): $(OBJS) - $(AR) $@ $(OBJS) - -@ ($(RANLIB) $@ || true) >/dev/null 2>&1 - -$(SHAREDLIB): $(OBJS) os2/z.def - $(LDSHARED) -o $@ $^ - -$(SHAREDLIBIMP): os2/z.def - $(IMPLIB) -o $@ $^ - -example.exe: example.o $(LIBS) - $(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS) - -minigzip.exe: minigzip.o $(LIBS) - $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS) - -clean: - rm -f *.o *~ example minigzip libz.a libz.so* foo.gz - -distclean: clean - -zip: - mv Makefile Makefile~; cp -p Makefile.in Makefile - rm -f test.c ztest*.c - v=`sed -n -e 's/\.//g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ - zip -ul9 zlib$$v $(DISTFILES) - mv Makefile~ Makefile - -dist: - mv Makefile Makefile~; cp -p Makefile.in Makefile - rm -f test.c ztest*.c - d=zlib-`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ - rm -f $$d.tar.gz; \ - if test ! -d ../$$d; then rm -f ../$$d; ln -s `pwd` ../$$d; fi; \ - files=""; \ - for f in $(DISTFILES); do files="$$files $$d/$$f"; done; \ - cd ..; \ - GZIP=-9 $(TAR) chofz $$d/$$d.tar.gz $$files; \ - if test ! -d $$d; then rm -f $$d; fi - mv Makefile~ Makefile - -tags: - etags *.[ch] - -depend: - makedepend -- $(CFLAGS) -- *.[ch] - -# DO NOT DELETE THIS LINE -- make depend depends on it. - -adler32.o: zlib.h zconf.h -compress.o: zlib.h zconf.h -crc32.o: zlib.h zconf.h -deflate.o: deflate.h zutil.h zlib.h zconf.h -example.o: zlib.h zconf.h -gzio.o: zutil.h zlib.h zconf.h -infblock.o: infblock.h inftrees.h infcodes.h infutil.h zutil.h zlib.h zconf.h -infcodes.o: zutil.h zlib.h zconf.h -infcodes.o: inftrees.h infblock.h infcodes.h infutil.h inffast.h -inffast.o: zutil.h zlib.h zconf.h inftrees.h -inffast.o: infblock.h infcodes.h infutil.h inffast.h -inflate.o: zutil.h zlib.h zconf.h infblock.h -inftrees.o: zutil.h zlib.h zconf.h inftrees.h -infutil.o: zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h -minigzip.o: zlib.h zconf.h -trees.o: deflate.h zutil.h zlib.h zconf.h trees.h -uncompr.o: zlib.h zconf.h -zutil.o: zutil.h zlib.h zconf.h diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/old/os2/zlib.def b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/old/os2/zlib.def deleted file mode 100644 index 4c753f1..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/old/os2/zlib.def +++ /dev/null @@ -1,51 +0,0 @@ -; -; Slightly modified version of ../nt/zlib.dnt :-) -; - -LIBRARY Z -DESCRIPTION "Zlib compression library for OS/2" -CODE PRELOAD MOVEABLE DISCARDABLE -DATA PRELOAD MOVEABLE MULTIPLE - -EXPORTS - adler32 - compress - crc32 - deflate - deflateCopy - deflateEnd - deflateInit2_ - deflateInit_ - deflateParams - deflateReset - deflateSetDictionary - gzclose - gzdopen - gzerror - gzflush - gzopen - gzread - gzwrite - inflate - inflateEnd - inflateInit2_ - inflateInit_ - inflateReset - inflateSetDictionary - inflateSync - uncompress - zlibVersion - gzprintf - gzputc - gzgetc - gzseek - gzrewind - gztell - gzeof - gzsetparams - zError - inflateSyncPoint - get_crc_table - compress2 - gzputs - gzgets diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/old/visual-basic.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/old/visual-basic.txt deleted file mode 100644 index 57efe58..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/old/visual-basic.txt +++ /dev/null @@ -1,160 +0,0 @@ -See below some functions declarations for Visual Basic. - -Frequently Asked Question: - -Q: Each time I use the compress function I get the -5 error (not enough - room in the output buffer). - -A: Make sure that the length of the compressed buffer is passed by - reference ("as any"), not by value ("as long"). Also check that - before the call of compress this length is equal to the total size of - the compressed buffer and not zero. - - -From: "Jon Caruana" -Subject: Re: How to port zlib declares to vb? -Date: Mon, 28 Oct 1996 18:33:03 -0600 - -Got the answer! (I haven't had time to check this but it's what I got, and -looks correct): - -He has the following routines working: - compress - uncompress - gzopen - gzwrite - gzread - gzclose - -Declares follow: (Quoted from Carlos Rios , in Vb4 form) - -#If Win16 Then 'Use Win16 calls. -Declare Function compress Lib "ZLIB.DLL" (ByVal compr As - String, comprLen As Any, ByVal buf As String, ByVal buflen - As Long) As Integer -Declare Function uncompress Lib "ZLIB.DLL" (ByVal uncompr - As String, uncomprLen As Any, ByVal compr As String, ByVal - lcompr As Long) As Integer -Declare Function gzopen Lib "ZLIB.DLL" (ByVal filePath As - String, ByVal mode As String) As Long -Declare Function gzread Lib "ZLIB.DLL" (ByVal file As - Long, ByVal uncompr As String, ByVal uncomprLen As Integer) - As Integer -Declare Function gzwrite Lib "ZLIB.DLL" (ByVal file As - Long, ByVal uncompr As String, ByVal uncomprLen As Integer) - As Integer -Declare Function gzclose Lib "ZLIB.DLL" (ByVal file As - Long) As Integer -#Else -Declare Function compress Lib "ZLIB32.DLL" - (ByVal compr As String, comprLen As Any, ByVal buf As - String, ByVal buflen As Long) As Integer -Declare Function uncompress Lib "ZLIB32.DLL" - (ByVal uncompr As String, uncomprLen As Any, ByVal compr As - String, ByVal lcompr As Long) As Long -Declare Function gzopen Lib "ZLIB32.DLL" - (ByVal file As String, ByVal mode As String) As Long -Declare Function gzread Lib "ZLIB32.DLL" - (ByVal file As Long, ByVal uncompr As String, ByVal - uncomprLen As Long) As Long -Declare Function gzwrite Lib "ZLIB32.DLL" - (ByVal file As Long, ByVal uncompr As String, ByVal - uncomprLen As Long) As Long -Declare Function gzclose Lib "ZLIB32.DLL" - (ByVal file As Long) As Long -#End If - --Jon Caruana -jon-net@usa.net -Microsoft Sitebuilder Network Level 1 Member - HTML Writer's Guild Member - - -Here is another example from Michael that he -says conforms to the VB guidelines, and that solves the problem of not -knowing the uncompressed size by storing it at the end of the file: - -'Calling the functions: -'bracket meaning: [optional] {Range of possible values} -'Call subCompressFile( [, , [level of compression {1..9}]]) -'Call subUncompressFile() - -Option Explicit -Private lngpvtPcnSml As Long 'Stores value for 'lngPercentSmaller' -Private Const SUCCESS As Long = 0 -Private Const strFilExt As String = ".cpr" -Private Declare Function lngfncCpr Lib "zlib.dll" Alias "compress2" (ByRef -dest As Any, ByRef destLen As Any, ByRef src As Any, ByVal srcLen As Long, -ByVal level As Integer) As Long -Private Declare Function lngfncUcp Lib "zlib.dll" Alias "uncompress" (ByRef -dest As Any, ByRef destLen As Any, ByRef src As Any, ByVal srcLen As Long) -As Long - -Public Sub subCompressFile(ByVal strargOriFilPth As String, Optional ByVal -strargCprFilPth As String, Optional ByVal intLvl As Integer = 9) - Dim strCprPth As String - Dim lngOriSiz As Long - Dim lngCprSiz As Long - Dim bytaryOri() As Byte - Dim bytaryCpr() As Byte - lngOriSiz = FileLen(strargOriFilPth) - ReDim bytaryOri(lngOriSiz - 1) - Open strargOriFilPth For Binary Access Read As #1 - Get #1, , bytaryOri() - Close #1 - strCprPth = IIf(strargCprFilPth = "", strargOriFilPth, strargCprFilPth) -'Select file path and name - strCprPth = strCprPth & IIf(Right(strCprPth, Len(strFilExt)) = -strFilExt, "", strFilExt) 'Add file extension if not exists - lngCprSiz = (lngOriSiz * 1.01) + 12 'Compression needs temporary a bit -more space then original file size - ReDim bytaryCpr(lngCprSiz - 1) - If lngfncCpr(bytaryCpr(0), lngCprSiz, bytaryOri(0), lngOriSiz, intLvl) = -SUCCESS Then - lngpvtPcnSml = (1# - (lngCprSiz / lngOriSiz)) * 100 - ReDim Preserve bytaryCpr(lngCprSiz - 1) - Open strCprPth For Binary Access Write As #1 - Put #1, , bytaryCpr() - Put #1, , lngOriSiz 'Add the the original size value to the end -(last 4 bytes) - Close #1 - Else - MsgBox "Compression error" - End If - Erase bytaryCpr - Erase bytaryOri -End Sub - -Public Sub subUncompressFile(ByVal strargFilPth As String) - Dim bytaryCpr() As Byte - Dim bytaryOri() As Byte - Dim lngOriSiz As Long - Dim lngCprSiz As Long - Dim strOriPth As String - lngCprSiz = FileLen(strargFilPth) - ReDim bytaryCpr(lngCprSiz - 1) - Open strargFilPth For Binary Access Read As #1 - Get #1, , bytaryCpr() - Close #1 - 'Read the original file size value: - lngOriSiz = bytaryCpr(lngCprSiz - 1) * (2 ^ 24) _ - + bytaryCpr(lngCprSiz - 2) * (2 ^ 16) _ - + bytaryCpr(lngCprSiz - 3) * (2 ^ 8) _ - + bytaryCpr(lngCprSiz - 4) - ReDim Preserve bytaryCpr(lngCprSiz - 5) 'Cut of the original size value - ReDim bytaryOri(lngOriSiz - 1) - If lngfncUcp(bytaryOri(0), lngOriSiz, bytaryCpr(0), lngCprSiz) = SUCCESS -Then - strOriPth = Left(strargFilPth, Len(strargFilPth) - Len(strFilExt)) - Open strOriPth For Binary Access Write As #1 - Put #1, , bytaryOri() - Close #1 - Else - MsgBox "Uncompression error" - End If - Erase bytaryCpr - Erase bytaryOri -End Sub -Public Property Get lngPercentSmaller() As Long - lngPercentSmaller = lngpvtPcnSml -End Property diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/os400/README400 b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/os400/README400 deleted file mode 100644 index 10f6c9d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/os400/README400 +++ /dev/null @@ -1,48 +0,0 @@ - ZLIB version 1.2.12 for OS/400 installation instructions - -1) Download and unpack the zlib tarball to some IFS directory. - (i.e.: /path/to/the/zlib/ifs/source/directory) - - If the installed IFS command suppors gzip format, this is straightforward, -else you have to unpack first to some directory on a system supporting it, -then move the whole directory to the IFS via the network (via SMB or FTP). - -2) Edit the configuration parameters in the compilation script. - - EDTF STMF('/path/to/the/zlib/ifs/source/directory/os400/make.sh') - -Tune the parameters according to your needs if not matching the defaults. -Save the file and exit after edition. - -3) Enter qshell, then work in the zlib OS/400 specific directory. - - QSH - cd /path/to/the/zlib/ifs/source/directory/os400 - -4) Compile and install - - sh make.sh - -The script will: -- create the libraries, objects and IFS directories for the zlib environment, -- compile all modules, -- create a service program, -- create a static and a dynamic binding directory, -- install header files for C/C++ and for ILE/RPG, both for compilation in - DB2 and IFS environments. - -That's all. - - -Notes: For OS/400 ILE RPG programmers, a /copy member defining the ZLIB - API prototypes for ILE RPG can be found in ZLIB/H(ZLIB.INC). - In the ILE environment, the same definitions are available from - file zlib.inc located in the same IFS include directory as the - C/C++ header files. - Please read comments in this member for more information. - - Remember that most foreign textual data are ASCII coded: this - implementation does not handle conversion from/to ASCII, so - text data code conversions must be done explicitely. - - Mainly for the reason above, always open zipped files in binary mode. diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/os400/bndsrc b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/os400/bndsrc deleted file mode 100644 index 5e6e0a2..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/os400/bndsrc +++ /dev/null @@ -1,119 +0,0 @@ -STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('ZLIB') - -/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ -/* Version 1.1.3 entry points. */ -/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ - - EXPORT SYMBOL("adler32") - EXPORT SYMBOL("compress") - EXPORT SYMBOL("compress2") - EXPORT SYMBOL("crc32") - EXPORT SYMBOL("get_crc_table") - EXPORT SYMBOL("deflate") - EXPORT SYMBOL("deflateEnd") - EXPORT SYMBOL("deflateSetDictionary") - EXPORT SYMBOL("deflateCopy") - EXPORT SYMBOL("deflateReset") - EXPORT SYMBOL("deflateParams") - EXPORT SYMBOL("deflatePrime") - EXPORT SYMBOL("deflateInit_") - EXPORT SYMBOL("deflateInit2_") - EXPORT SYMBOL("gzopen") - EXPORT SYMBOL("gzdopen") - EXPORT SYMBOL("gzsetparams") - EXPORT SYMBOL("gzread") - EXPORT SYMBOL("gzwrite") - EXPORT SYMBOL("gzprintf") - EXPORT SYMBOL("gzputs") - EXPORT SYMBOL("gzgets") - EXPORT SYMBOL("gzputc") - EXPORT SYMBOL("gzgetc") - EXPORT SYMBOL("gzflush") - EXPORT SYMBOL("gzseek") - EXPORT SYMBOL("gzrewind") - EXPORT SYMBOL("gztell") - EXPORT SYMBOL("gzeof") - EXPORT SYMBOL("gzclose") - EXPORT SYMBOL("gzerror") - EXPORT SYMBOL("inflate") - EXPORT SYMBOL("inflateEnd") - EXPORT SYMBOL("inflateSetDictionary") - EXPORT SYMBOL("inflateSync") - EXPORT SYMBOL("inflateReset") - EXPORT SYMBOL("inflateInit_") - EXPORT SYMBOL("inflateInit2_") - EXPORT SYMBOL("inflateSyncPoint") - EXPORT SYMBOL("uncompress") - EXPORT SYMBOL("zlibVersion") - EXPORT SYMBOL("zError") - EXPORT SYMBOL("z_errmsg") - -/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ -/* Version 1.2.1 additional entry points. */ -/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ - - EXPORT SYMBOL("compressBound") - EXPORT SYMBOL("deflateBound") - EXPORT SYMBOL("deflatePending") - EXPORT SYMBOL("gzungetc") - EXPORT SYMBOL("gzclearerr") - EXPORT SYMBOL("inflateBack") - EXPORT SYMBOL("inflateBackEnd") - EXPORT SYMBOL("inflateBackInit_") - EXPORT SYMBOL("inflateCopy") - EXPORT SYMBOL("zlibCompileFlags") - -/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ -/* Version 1.2.4 additional entry points. */ -/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ - - EXPORT SYMBOL("adler32_combine") - EXPORT SYMBOL("adler32_combine64") - EXPORT SYMBOL("crc32_combine") - EXPORT SYMBOL("crc32_combine64") - EXPORT SYMBOL("deflateSetHeader") - EXPORT SYMBOL("deflateTune") - EXPORT SYMBOL("gzbuffer") - EXPORT SYMBOL("gzclose_r") - EXPORT SYMBOL("gzclose_w") - EXPORT SYMBOL("gzdirect") - EXPORT SYMBOL("gzoffset") - EXPORT SYMBOL("gzoffset64") - EXPORT SYMBOL("gzopen64") - EXPORT SYMBOL("gzseek64") - EXPORT SYMBOL("gztell64") - EXPORT SYMBOL("inflateGetHeader") - EXPORT SYMBOL("inflateMark") - EXPORT SYMBOL("inflatePrime") - EXPORT SYMBOL("inflateReset2") - EXPORT SYMBOL("inflateUndermine") - -/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ -/* Version 1.2.6 additional entry points. */ -/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ - - EXPORT SYMBOL("deflateResetKeep") - EXPORT SYMBOL("gzgetc_") - EXPORT SYMBOL("inflateResetKeep") - -/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ -/* Version 1.2.8 additional entry points. */ -/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ - - EXPORT SYMBOL("gzvprintf") - EXPORT SYMBOL("inflateGetDictionary") - -/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ -/* Version 1.2.9 additional entry points. */ -/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ - - EXPORT SYMBOL("adler32_z") - EXPORT SYMBOL("crc32_z") - EXPORT SYMBOL("deflateGetDictionary") - EXPORT SYMBOL("gzfread") - EXPORT SYMBOL("gzfwrite") - EXPORT SYMBOL("inflateCodesUsed") - EXPORT SYMBOL("inflateValidate") - EXPORT SYMBOL("uncompress2") - -ENDPGMEXP diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/os400/make.sh b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/os400/make.sh deleted file mode 100644 index 19eec11..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/os400/make.sh +++ /dev/null @@ -1,366 +0,0 @@ -#!/bin/sh -# -# ZLIB compilation script for the OS/400. -# -# -# This is a shell script since make is not a standard component of OS/400. - - -################################################################################ -# -# Tunable configuration parameters. -# -################################################################################ - -TARGETLIB='ZLIB' # Target OS/400 program library -STATBNDDIR='ZLIB_A' # Static binding directory. -DYNBNDDIR='ZLIB' # Dynamic binding directory. -SRVPGM="ZLIB" # Service program. -IFSDIR='/zlib' # IFS support base directory. -TGTCCSID='500' # Target CCSID of objects -DEBUG='*NONE' # Debug level -OPTIMIZE='40' # Optimisation level -OUTPUT='*NONE' # Compilation output option. -TGTRLS='V6R1M0' # Target OS release - -export TARGETLIB STATBNDDIR DYNBNDDIR SRVPGM IFSDIR -export TGTCCSID DEBUG OPTIMIZE OUTPUT TGTRLS - - -################################################################################ -# -# OS/400 specific definitions. -# -################################################################################ - -LIBIFSNAME="/QSYS.LIB/${TARGETLIB}.LIB" - - -################################################################################ -# -# Procedures. -# -################################################################################ - -# action_needed dest [src] -# -# dest is an object to build -# if specified, src is an object on which dest depends. -# -# exit 0 (succeeds) if some action has to be taken, else 1. - -action_needed() - -{ - [ ! -e "${1}" ] && return 0 - [ "${2}" ] || return 1 - [ "${1}" -ot "${2}" ] && return 0 - return 1 -} - - -# make_module module_name source_name [additional_definitions] -# -# Compile source name into module if needed. -# As side effect, append the module name to variable MODULES. -# Set LINK to "YES" if the module has been compiled. - -make_module() - -{ - MODULES="${MODULES} ${1}" - MODIFSNAME="${LIBIFSNAME}/${1}.MODULE" - CSRC="`basename \"${2}\"`" - - if action_needed "${MODIFSNAME}" "${2}" - then : - elif [ ! "`sed -e \"//,/<\\\\/source>/!d\" \ - -e '/ tmphdrfile - - # Need to translate to target CCSID. - - CMD="CPY OBJ('`pwd`/tmphdrfile') TOOBJ('${DEST}')" - CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)" - system "${CMD}" - # touch -r "${HFILE}" "${DEST}" - rm -f tmphdrfile - fi - - IFSFILE="${IFSDIR}/include/`basename \"${HFILE}\"`" - - if action_needed "${IFSFILE}" "${DEST}" - then rm -f "${IFSFILE}" - ln -s "${DEST}" "${IFSFILE}" - fi -done - - -# Install the ILE/RPG header file. - - -HFILE="${SCRIPTDIR}/zlib.inc" -DEST="${SRCPF}/ZLIB.INC.MBR" - -if action_needed "${DEST}" "${HFILE}" -then CMD="CPY OBJ('${HFILE}') TOOBJ('${DEST}')" - CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)" - system "${CMD}" - # touch -r "${HFILE}" "${DEST}" -fi - -IFSFILE="${IFSDIR}/include/`basename \"${HFILE}\"`" - -if action_needed "${IFSFILE}" "${DEST}" -then rm -f "${IFSFILE}" - ln -s "${DEST}" "${IFSFILE}" -fi - - -# Create and compile the identification source file. - -echo '#pragma comment(user, "ZLIB version '"${VERSION}"'")' > os400.c -echo '#pragma comment(user, __DATE__)' >> os400.c -echo '#pragma comment(user, __TIME__)' >> os400.c -echo '#pragma comment(copyright, "Copyright (C) 1995-2017 Jean-Loup Gailly, Mark Adler. OS/400 version by P. Monnerat.")' >> os400.c -make_module OS400 os400.c -LINK= # No need to rebuild service program yet. -MODULES= - - -# Get source list. - -CSOURCES=`sed -e '/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Library - - Medium - - 2.0 - - - - zlib - zlib - alain.bonnefoy@icbt.com - Public - public - www.gzip.org/zlib - - - Jean-Loup Gailly,Mark Adler - www.gzip.org/zlib - - zlib@gzip.org - - - A massively spiffy yet delicately unobtrusive compression library. - zlib is designed to be a free, general-purpose, legally unencumbered, lossless data compression library for use on virtually any computer hardware and operating system. - http://www.gzip.org/zlib - - - - - 1.2.12 - Medium - Stable - - - - - - - No License - - - - Software Development/Libraries and Extensions/C Libraries - zlib,compression - qnx6 - qnx6 - None - Developer - - - - - - - - - - - - - - Install - Post - No - Ignore - - No - Optional - - - - - - - - - - - - - InstallOver - zlib - - - - - - - - - - - - - InstallOver - zlib-dev - - - - - - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/test/example.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/test/example.c deleted file mode 100644 index 949f4f6..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/test/example.c +++ /dev/null @@ -1,601 +0,0 @@ -/* example.c -- usage example of the zlib compression library - * Copyright (C) 1995-2006, 2011, 2016 Jean-loup Gailly - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#include "zlib.h" -#include - -#ifdef STDC -# include -# include -#endif - -#if defined(VMS) || defined(RISCOS) -# define TESTFILE "foo-gz" -#else -# define TESTFILE "foo.gz" -#endif - -#define CHECK_ERR(err, msg) { \ - if (err != Z_OK) { \ - fprintf(stderr, "%s error: %d\n", msg, err); \ - exit(1); \ - } \ -} - -static z_const char hello[] = "hello, hello!"; -/* "hello world" would be more standard, but the repeated "hello" - * stresses the compression code better, sorry... - */ - -static const char dictionary[] = "hello"; -static uLong dictId; /* Adler32 value of the dictionary */ - -void test_deflate OF((Byte *compr, uLong comprLen)); -void test_inflate OF((Byte *compr, uLong comprLen, - Byte *uncompr, uLong uncomprLen)); -void test_large_deflate OF((Byte *compr, uLong comprLen, - Byte *uncompr, uLong uncomprLen)); -void test_large_inflate OF((Byte *compr, uLong comprLen, - Byte *uncompr, uLong uncomprLen)); -void test_flush OF((Byte *compr, uLong *comprLen)); -void test_sync OF((Byte *compr, uLong comprLen, - Byte *uncompr, uLong uncomprLen)); -void test_dict_deflate OF((Byte *compr, uLong comprLen)); -void test_dict_inflate OF((Byte *compr, uLong comprLen, - Byte *uncompr, uLong uncomprLen)); -int main OF((int argc, char *argv[])); - - -#ifdef Z_SOLO - -void *myalloc OF((void *, unsigned, unsigned)); -void myfree OF((void *, void *)); - -void *myalloc(q, n, m) - void *q; - unsigned n, m; -{ - (void)q; - return calloc(n, m); -} - -void myfree(void *q, void *p) -{ - (void)q; - free(p); -} - -static alloc_func zalloc = myalloc; -static free_func zfree = myfree; - -#else /* !Z_SOLO */ - -static alloc_func zalloc = (alloc_func)0; -static free_func zfree = (free_func)0; - -void test_compress OF((Byte *compr, uLong comprLen, - Byte *uncompr, uLong uncomprLen)); -void test_gzio OF((const char *fname, - Byte *uncompr, uLong uncomprLen)); - -/* =========================================================================== - * Test compress() and uncompress() - */ -void test_compress(compr, comprLen, uncompr, uncomprLen) - Byte *compr, *uncompr; - uLong comprLen, uncomprLen; -{ - int err; - uLong len = (uLong)strlen(hello)+1; - - err = compress(compr, &comprLen, (const Bytef*)hello, len); - CHECK_ERR(err, "compress"); - - strcpy((char*)uncompr, "garbage"); - - err = uncompress(uncompr, &uncomprLen, compr, comprLen); - CHECK_ERR(err, "uncompress"); - - if (strcmp((char*)uncompr, hello)) { - fprintf(stderr, "bad uncompress\n"); - exit(1); - } else { - printf("uncompress(): %s\n", (char *)uncompr); - } -} - -/* =========================================================================== - * Test read/write of .gz files - */ -void test_gzio(fname, uncompr, uncomprLen) - const char *fname; /* compressed file name */ - Byte *uncompr; - uLong uncomprLen; -{ -#ifdef NO_GZCOMPRESS - fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n"); -#else - int err; - int len = (int)strlen(hello)+1; - gzFile file; - z_off_t pos; - - file = gzopen(fname, "wb"); - if (file == NULL) { - fprintf(stderr, "gzopen error\n"); - exit(1); - } - gzputc(file, 'h'); - if (gzputs(file, "ello") != 4) { - fprintf(stderr, "gzputs err: %s\n", gzerror(file, &err)); - exit(1); - } - if (gzprintf(file, ", %s!", "hello") != 8) { - fprintf(stderr, "gzprintf err: %s\n", gzerror(file, &err)); - exit(1); - } - gzseek(file, 1L, SEEK_CUR); /* add one zero byte */ - gzclose(file); - - file = gzopen(fname, "rb"); - if (file == NULL) { - fprintf(stderr, "gzopen error\n"); - exit(1); - } - strcpy((char*)uncompr, "garbage"); - - if (gzread(file, uncompr, (unsigned)uncomprLen) != len) { - fprintf(stderr, "gzread err: %s\n", gzerror(file, &err)); - exit(1); - } - if (strcmp((char*)uncompr, hello)) { - fprintf(stderr, "bad gzread: %s\n", (char*)uncompr); - exit(1); - } else { - printf("gzread(): %s\n", (char*)uncompr); - } - - pos = gzseek(file, -8L, SEEK_CUR); - if (pos != 6 || gztell(file) != pos) { - fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n", - (long)pos, (long)gztell(file)); - exit(1); - } - - if (gzgetc(file) != ' ') { - fprintf(stderr, "gzgetc error\n"); - exit(1); - } - - if (gzungetc(' ', file) != ' ') { - fprintf(stderr, "gzungetc error\n"); - exit(1); - } - - gzgets(file, (char*)uncompr, (int)uncomprLen); - if (strlen((char*)uncompr) != 7) { /* " hello!" */ - fprintf(stderr, "gzgets err after gzseek: %s\n", gzerror(file, &err)); - exit(1); - } - if (strcmp((char*)uncompr, hello + 6)) { - fprintf(stderr, "bad gzgets after gzseek\n"); - exit(1); - } else { - printf("gzgets() after gzseek: %s\n", (char*)uncompr); - } - - gzclose(file); -#endif -} - -#endif /* Z_SOLO */ - -/* =========================================================================== - * Test deflate() with small buffers - */ -void test_deflate(compr, comprLen) - Byte *compr; - uLong comprLen; -{ - z_stream c_stream; /* compression stream */ - int err; - uLong len = (uLong)strlen(hello)+1; - - c_stream.zalloc = zalloc; - c_stream.zfree = zfree; - c_stream.opaque = (voidpf)0; - - err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION); - CHECK_ERR(err, "deflateInit"); - - c_stream.next_in = (z_const unsigned char *)hello; - c_stream.next_out = compr; - - while (c_stream.total_in != len && c_stream.total_out < comprLen) { - c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */ - err = deflate(&c_stream, Z_NO_FLUSH); - CHECK_ERR(err, "deflate"); - } - /* Finish the stream, still forcing small buffers: */ - for (;;) { - c_stream.avail_out = 1; - err = deflate(&c_stream, Z_FINISH); - if (err == Z_STREAM_END) break; - CHECK_ERR(err, "deflate"); - } - - err = deflateEnd(&c_stream); - CHECK_ERR(err, "deflateEnd"); -} - -/* =========================================================================== - * Test inflate() with small buffers - */ -void test_inflate(compr, comprLen, uncompr, uncomprLen) - Byte *compr, *uncompr; - uLong comprLen, uncomprLen; -{ - int err; - z_stream d_stream; /* decompression stream */ - - strcpy((char*)uncompr, "garbage"); - - d_stream.zalloc = zalloc; - d_stream.zfree = zfree; - d_stream.opaque = (voidpf)0; - - d_stream.next_in = compr; - d_stream.avail_in = 0; - d_stream.next_out = uncompr; - - err = inflateInit(&d_stream); - CHECK_ERR(err, "inflateInit"); - - while (d_stream.total_out < uncomprLen && d_stream.total_in < comprLen) { - d_stream.avail_in = d_stream.avail_out = 1; /* force small buffers */ - err = inflate(&d_stream, Z_NO_FLUSH); - if (err == Z_STREAM_END) break; - CHECK_ERR(err, "inflate"); - } - - err = inflateEnd(&d_stream); - CHECK_ERR(err, "inflateEnd"); - - if (strcmp((char*)uncompr, hello)) { - fprintf(stderr, "bad inflate\n"); - exit(1); - } else { - printf("inflate(): %s\n", (char *)uncompr); - } -} - -/* =========================================================================== - * Test deflate() with large buffers and dynamic change of compression level - */ -void test_large_deflate(compr, comprLen, uncompr, uncomprLen) - Byte *compr, *uncompr; - uLong comprLen, uncomprLen; -{ - z_stream c_stream; /* compression stream */ - int err; - - c_stream.zalloc = zalloc; - c_stream.zfree = zfree; - c_stream.opaque = (voidpf)0; - - err = deflateInit(&c_stream, Z_BEST_SPEED); - CHECK_ERR(err, "deflateInit"); - - c_stream.next_out = compr; - c_stream.avail_out = (uInt)comprLen; - - /* At this point, uncompr is still mostly zeroes, so it should compress - * very well: - */ - c_stream.next_in = uncompr; - c_stream.avail_in = (uInt)uncomprLen; - err = deflate(&c_stream, Z_NO_FLUSH); - CHECK_ERR(err, "deflate"); - if (c_stream.avail_in != 0) { - fprintf(stderr, "deflate not greedy\n"); - exit(1); - } - - /* Feed in already compressed data and switch to no compression: */ - deflateParams(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY); - c_stream.next_in = compr; - c_stream.avail_in = (uInt)comprLen/2; - err = deflate(&c_stream, Z_NO_FLUSH); - CHECK_ERR(err, "deflate"); - - /* Switch back to compressing mode: */ - deflateParams(&c_stream, Z_BEST_COMPRESSION, Z_FILTERED); - c_stream.next_in = uncompr; - c_stream.avail_in = (uInt)uncomprLen; - err = deflate(&c_stream, Z_NO_FLUSH); - CHECK_ERR(err, "deflate"); - - err = deflate(&c_stream, Z_FINISH); - if (err != Z_STREAM_END) { - fprintf(stderr, "deflate should report Z_STREAM_END\n"); - exit(1); - } - err = deflateEnd(&c_stream); - CHECK_ERR(err, "deflateEnd"); -} - -/* =========================================================================== - * Test inflate() with large buffers - */ -void test_large_inflate(compr, comprLen, uncompr, uncomprLen) - Byte *compr, *uncompr; - uLong comprLen, uncomprLen; -{ - int err; - z_stream d_stream; /* decompression stream */ - - strcpy((char*)uncompr, "garbage"); - - d_stream.zalloc = zalloc; - d_stream.zfree = zfree; - d_stream.opaque = (voidpf)0; - - d_stream.next_in = compr; - d_stream.avail_in = (uInt)comprLen; - - err = inflateInit(&d_stream); - CHECK_ERR(err, "inflateInit"); - - for (;;) { - d_stream.next_out = uncompr; /* discard the output */ - d_stream.avail_out = (uInt)uncomprLen; - err = inflate(&d_stream, Z_NO_FLUSH); - if (err == Z_STREAM_END) break; - CHECK_ERR(err, "large inflate"); - } - - err = inflateEnd(&d_stream); - CHECK_ERR(err, "inflateEnd"); - - if (d_stream.total_out != 2*uncomprLen + comprLen/2) { - fprintf(stderr, "bad large inflate: %ld\n", d_stream.total_out); - exit(1); - } else { - printf("large_inflate(): OK\n"); - } -} - -/* =========================================================================== - * Test deflate() with full flush - */ -void test_flush(compr, comprLen) - Byte *compr; - uLong *comprLen; -{ - z_stream c_stream; /* compression stream */ - int err; - uInt len = (uInt)strlen(hello)+1; - - c_stream.zalloc = zalloc; - c_stream.zfree = zfree; - c_stream.opaque = (voidpf)0; - - err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION); - CHECK_ERR(err, "deflateInit"); - - c_stream.next_in = (z_const unsigned char *)hello; - c_stream.next_out = compr; - c_stream.avail_in = 3; - c_stream.avail_out = (uInt)*comprLen; - err = deflate(&c_stream, Z_FULL_FLUSH); - CHECK_ERR(err, "deflate"); - - compr[3]++; /* force an error in first compressed block */ - c_stream.avail_in = len - 3; - - err = deflate(&c_stream, Z_FINISH); - if (err != Z_STREAM_END) { - CHECK_ERR(err, "deflate"); - } - err = deflateEnd(&c_stream); - CHECK_ERR(err, "deflateEnd"); - - *comprLen = c_stream.total_out; -} - -/* =========================================================================== - * Test inflateSync() - */ -void test_sync(compr, comprLen, uncompr, uncomprLen) - Byte *compr, *uncompr; - uLong comprLen, uncomprLen; -{ - int err; - z_stream d_stream; /* decompression stream */ - - strcpy((char*)uncompr, "garbage"); - - d_stream.zalloc = zalloc; - d_stream.zfree = zfree; - d_stream.opaque = (voidpf)0; - - d_stream.next_in = compr; - d_stream.avail_in = 2; /* just read the zlib header */ - - err = inflateInit(&d_stream); - CHECK_ERR(err, "inflateInit"); - - d_stream.next_out = uncompr; - d_stream.avail_out = (uInt)uncomprLen; - - err = inflate(&d_stream, Z_NO_FLUSH); - CHECK_ERR(err, "inflate"); - - d_stream.avail_in = (uInt)comprLen-2; /* read all compressed data */ - err = inflateSync(&d_stream); /* but skip the damaged part */ - CHECK_ERR(err, "inflateSync"); - - err = inflate(&d_stream, Z_FINISH); - if (err != Z_STREAM_END) { - fprintf(stderr, "inflate should report Z_STREAM_END\n"); - exit(1); - } - err = inflateEnd(&d_stream); - CHECK_ERR(err, "inflateEnd"); - - printf("after inflateSync(): hel%s\n", (char *)uncompr); -} - -/* =========================================================================== - * Test deflate() with preset dictionary - */ -void test_dict_deflate(compr, comprLen) - Byte *compr; - uLong comprLen; -{ - z_stream c_stream; /* compression stream */ - int err; - - c_stream.zalloc = zalloc; - c_stream.zfree = zfree; - c_stream.opaque = (voidpf)0; - - err = deflateInit(&c_stream, Z_BEST_COMPRESSION); - CHECK_ERR(err, "deflateInit"); - - err = deflateSetDictionary(&c_stream, - (const Bytef*)dictionary, (int)sizeof(dictionary)); - CHECK_ERR(err, "deflateSetDictionary"); - - dictId = c_stream.adler; - c_stream.next_out = compr; - c_stream.avail_out = (uInt)comprLen; - - c_stream.next_in = (z_const unsigned char *)hello; - c_stream.avail_in = (uInt)strlen(hello)+1; - - err = deflate(&c_stream, Z_FINISH); - if (err != Z_STREAM_END) { - fprintf(stderr, "deflate should report Z_STREAM_END\n"); - exit(1); - } - err = deflateEnd(&c_stream); - CHECK_ERR(err, "deflateEnd"); -} - -/* =========================================================================== - * Test inflate() with a preset dictionary - */ -void test_dict_inflate(compr, comprLen, uncompr, uncomprLen) - Byte *compr, *uncompr; - uLong comprLen, uncomprLen; -{ - int err; - z_stream d_stream; /* decompression stream */ - - strcpy((char*)uncompr, "garbage"); - - d_stream.zalloc = zalloc; - d_stream.zfree = zfree; - d_stream.opaque = (voidpf)0; - - d_stream.next_in = compr; - d_stream.avail_in = (uInt)comprLen; - - err = inflateInit(&d_stream); - CHECK_ERR(err, "inflateInit"); - - d_stream.next_out = uncompr; - d_stream.avail_out = (uInt)uncomprLen; - - for (;;) { - err = inflate(&d_stream, Z_NO_FLUSH); - if (err == Z_STREAM_END) break; - if (err == Z_NEED_DICT) { - if (d_stream.adler != dictId) { - fprintf(stderr, "unexpected dictionary"); - exit(1); - } - err = inflateSetDictionary(&d_stream, (const Bytef*)dictionary, - (int)sizeof(dictionary)); - } - CHECK_ERR(err, "inflate with dict"); - } - - err = inflateEnd(&d_stream); - CHECK_ERR(err, "inflateEnd"); - - if (strcmp((char*)uncompr, hello)) { - fprintf(stderr, "bad inflate with dict\n"); - exit(1); - } else { - printf("inflate with dictionary: %s\n", (char *)uncompr); - } -} - -/* =========================================================================== - * Usage: example [output.gz [input.gz]] - */ - -int main(argc, argv) - int argc; - char *argv[]; -{ - Byte *compr, *uncompr; - uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */ - uLong uncomprLen = comprLen; - static const char* myVersion = ZLIB_VERSION; - - if (zlibVersion()[0] != myVersion[0]) { - fprintf(stderr, "incompatible zlib version\n"); - exit(1); - - } else if (strcmp(zlibVersion(), ZLIB_VERSION) != 0) { - fprintf(stderr, "warning: different zlib version\n"); - } - - printf("zlib version %s = 0x%04x, compile flags = 0x%lx\n", - ZLIB_VERSION, ZLIB_VERNUM, zlibCompileFlags()); - - compr = (Byte*)calloc((uInt)comprLen, 1); - uncompr = (Byte*)calloc((uInt)uncomprLen, 1); - /* compr and uncompr are cleared to avoid reading uninitialized - * data and to ensure that uncompr compresses well. - */ - if (compr == Z_NULL || uncompr == Z_NULL) { - printf("out of memory\n"); - exit(1); - } - -#ifdef Z_SOLO - (void)argc; - (void)argv; -#else - test_compress(compr, comprLen, uncompr, uncomprLen); - - test_gzio((argc > 1 ? argv[1] : TESTFILE), - uncompr, uncomprLen); -#endif - - test_deflate(compr, comprLen); - test_inflate(compr, comprLen, uncompr, uncomprLen); - - test_large_deflate(compr, comprLen, uncompr, uncomprLen); - test_large_inflate(compr, comprLen, uncompr, uncomprLen); - - test_flush(compr, &comprLen); - test_sync(compr, comprLen, uncompr, uncomprLen); - comprLen = uncomprLen; - - test_dict_deflate(compr, comprLen); - test_dict_inflate(compr, comprLen, uncompr, uncomprLen); - - free(compr); - free(uncompr); - - return 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/test/infcover.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/test/infcover.c deleted file mode 100644 index 2be0164..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/test/infcover.c +++ /dev/null @@ -1,671 +0,0 @@ -/* infcover.c -- test zlib's inflate routines with full code coverage - * Copyright (C) 2011, 2016 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* to use, do: ./configure --cover && make cover */ - -#include -#include -#include -#include -#include "zlib.h" - -/* get definition of internal structure so we can mess with it (see pull()), - and so we can call inflate_trees() (see cover5()) */ -#define ZLIB_INTERNAL -#include "inftrees.h" -#include "inflate.h" - -#define local static - -/* -- memory tracking routines -- */ - -/* - These memory tracking routines are provided to zlib and track all of zlib's - allocations and deallocations, check for LIFO operations, keep a current - and high water mark of total bytes requested, optionally set a limit on the - total memory that can be allocated, and when done check for memory leaks. - - They are used as follows: - - z_stream strm; - mem_setup(&strm) initializes the memory tracking and sets the - zalloc, zfree, and opaque members of strm to use - memory tracking for all zlib operations on strm - mem_limit(&strm, limit) sets a limit on the total bytes requested -- a - request that exceeds this limit will result in an - allocation failure (returns NULL) -- setting the - limit to zero means no limit, which is the default - after mem_setup() - mem_used(&strm, "msg") prints to stderr "msg" and the total bytes used - mem_high(&strm, "msg") prints to stderr "msg" and the high water mark - mem_done(&strm, "msg") ends memory tracking, releases all allocations - for the tracking as well as leaked zlib blocks, if - any. If there was anything unusual, such as leaked - blocks, non-FIFO frees, or frees of addresses not - allocated, then "msg" and information about the - problem is printed to stderr. If everything is - normal, nothing is printed. mem_done resets the - strm members to Z_NULL to use the default memory - allocation routines on the next zlib initialization - using strm. - */ - -/* these items are strung together in a linked list, one for each allocation */ -struct mem_item { - void *ptr; /* pointer to allocated memory */ - size_t size; /* requested size of allocation */ - struct mem_item *next; /* pointer to next item in list, or NULL */ -}; - -/* this structure is at the root of the linked list, and tracks statistics */ -struct mem_zone { - struct mem_item *first; /* pointer to first item in list, or NULL */ - size_t total, highwater; /* total allocations, and largest total */ - size_t limit; /* memory allocation limit, or 0 if no limit */ - int notlifo, rogue; /* counts of non-LIFO frees and rogue frees */ -}; - -/* memory allocation routine to pass to zlib */ -local void *mem_alloc(void *mem, unsigned count, unsigned size) -{ - void *ptr; - struct mem_item *item; - struct mem_zone *zone = mem; - size_t len = count * (size_t)size; - - /* induced allocation failure */ - if (zone == NULL || (zone->limit && zone->total + len > zone->limit)) - return NULL; - - /* perform allocation using the standard library, fill memory with a - non-zero value to make sure that the code isn't depending on zeros */ - ptr = malloc(len); - if (ptr == NULL) - return NULL; - memset(ptr, 0xa5, len); - - /* create a new item for the list */ - item = malloc(sizeof(struct mem_item)); - if (item == NULL) { - free(ptr); - return NULL; - } - item->ptr = ptr; - item->size = len; - - /* insert item at the beginning of the list */ - item->next = zone->first; - zone->first = item; - - /* update the statistics */ - zone->total += item->size; - if (zone->total > zone->highwater) - zone->highwater = zone->total; - - /* return the allocated memory */ - return ptr; -} - -/* memory free routine to pass to zlib */ -local void mem_free(void *mem, void *ptr) -{ - struct mem_item *item, *next; - struct mem_zone *zone = mem; - - /* if no zone, just do a free */ - if (zone == NULL) { - free(ptr); - return; - } - - /* point next to the item that matches ptr, or NULL if not found -- remove - the item from the linked list if found */ - next = zone->first; - if (next) { - if (next->ptr == ptr) - zone->first = next->next; /* first one is it, remove from list */ - else { - do { /* search the linked list */ - item = next; - next = item->next; - } while (next != NULL && next->ptr != ptr); - if (next) { /* if found, remove from linked list */ - item->next = next->next; - zone->notlifo++; /* not a LIFO free */ - } - - } - } - - /* if found, update the statistics and free the item */ - if (next) { - zone->total -= next->size; - free(next); - } - - /* if not found, update the rogue count */ - else - zone->rogue++; - - /* in any case, do the requested free with the standard library function */ - free(ptr); -} - -/* set up a controlled memory allocation space for monitoring, set the stream - parameters to the controlled routines, with opaque pointing to the space */ -local void mem_setup(z_stream *strm) -{ - struct mem_zone *zone; - - zone = malloc(sizeof(struct mem_zone)); - assert(zone != NULL); - zone->first = NULL; - zone->total = 0; - zone->highwater = 0; - zone->limit = 0; - zone->notlifo = 0; - zone->rogue = 0; - strm->opaque = zone; - strm->zalloc = mem_alloc; - strm->zfree = mem_free; -} - -/* set a limit on the total memory allocation, or 0 to remove the limit */ -local void mem_limit(z_stream *strm, size_t limit) -{ - struct mem_zone *zone = strm->opaque; - - zone->limit = limit; -} - -/* show the current total requested allocations in bytes */ -local void mem_used(z_stream *strm, char *prefix) -{ - struct mem_zone *zone = strm->opaque; - - fprintf(stderr, "%s: %lu allocated\n", prefix, zone->total); -} - -/* show the high water allocation in bytes */ -local void mem_high(z_stream *strm, char *prefix) -{ - struct mem_zone *zone = strm->opaque; - - fprintf(stderr, "%s: %lu high water mark\n", prefix, zone->highwater); -} - -/* release the memory allocation zone -- if there are any surprises, notify */ -local void mem_done(z_stream *strm, char *prefix) -{ - int count = 0; - struct mem_item *item, *next; - struct mem_zone *zone = strm->opaque; - - /* show high water mark */ - mem_high(strm, prefix); - - /* free leftover allocations and item structures, if any */ - item = zone->first; - while (item != NULL) { - free(item->ptr); - next = item->next; - free(item); - item = next; - count++; - } - - /* issue alerts about anything unexpected */ - if (count || zone->total) - fprintf(stderr, "** %s: %lu bytes in %d blocks not freed\n", - prefix, zone->total, count); - if (zone->notlifo) - fprintf(stderr, "** %s: %d frees not LIFO\n", prefix, zone->notlifo); - if (zone->rogue) - fprintf(stderr, "** %s: %d frees not recognized\n", - prefix, zone->rogue); - - /* free the zone and delete from the stream */ - free(zone); - strm->opaque = Z_NULL; - strm->zalloc = Z_NULL; - strm->zfree = Z_NULL; -} - -/* -- inflate test routines -- */ - -/* Decode a hexadecimal string, set *len to length, in[] to the bytes. This - decodes liberally, in that hex digits can be adjacent, in which case two in - a row writes a byte. Or they can be delimited by any non-hex character, - where the delimiters are ignored except when a single hex digit is followed - by a delimiter, where that single digit writes a byte. The returned data is - allocated and must eventually be freed. NULL is returned if out of memory. - If the length is not needed, then len can be NULL. */ -local unsigned char *h2b(const char *hex, unsigned *len) -{ - unsigned char *in, *re; - unsigned next, val; - - in = malloc((strlen(hex) + 1) >> 1); - if (in == NULL) - return NULL; - next = 0; - val = 1; - do { - if (*hex >= '0' && *hex <= '9') - val = (val << 4) + *hex - '0'; - else if (*hex >= 'A' && *hex <= 'F') - val = (val << 4) + *hex - 'A' + 10; - else if (*hex >= 'a' && *hex <= 'f') - val = (val << 4) + *hex - 'a' + 10; - else if (val != 1 && val < 32) /* one digit followed by delimiter */ - val += 240; /* make it look like two digits */ - if (val > 255) { /* have two digits */ - in[next++] = val & 0xff; /* save the decoded byte */ - val = 1; /* start over */ - } - } while (*hex++); /* go through the loop with the terminating null */ - if (len != NULL) - *len = next; - re = realloc(in, next); - return re == NULL ? in : re; -} - -/* generic inflate() run, where hex is the hexadecimal input data, what is the - text to include in an error message, step is how much input data to feed - inflate() on each call, or zero to feed it all, win is the window bits - parameter to inflateInit2(), len is the size of the output buffer, and err - is the error code expected from the first inflate() call (the second - inflate() call is expected to return Z_STREAM_END). If win is 47, then - header information is collected with inflateGetHeader(). If a zlib stream - is looking for a dictionary, then an empty dictionary is provided. - inflate() is run until all of the input data is consumed. */ -local void inf(char *hex, char *what, unsigned step, int win, unsigned len, - int err) -{ - int ret; - unsigned have; - unsigned char *in, *out; - z_stream strm, copy; - gz_header head; - - mem_setup(&strm); - strm.avail_in = 0; - strm.next_in = Z_NULL; - ret = inflateInit2(&strm, win); - if (ret != Z_OK) { - mem_done(&strm, what); - return; - } - out = malloc(len); assert(out != NULL); - if (win == 47) { - head.extra = out; - head.extra_max = len; - head.name = out; - head.name_max = len; - head.comment = out; - head.comm_max = len; - ret = inflateGetHeader(&strm, &head); assert(ret == Z_OK); - } - in = h2b(hex, &have); assert(in != NULL); - if (step == 0 || step > have) - step = have; - strm.avail_in = step; - have -= step; - strm.next_in = in; - do { - strm.avail_out = len; - strm.next_out = out; - ret = inflate(&strm, Z_NO_FLUSH); assert(err == 9 || ret == err); - if (ret != Z_OK && ret != Z_BUF_ERROR && ret != Z_NEED_DICT) - break; - if (ret == Z_NEED_DICT) { - ret = inflateSetDictionary(&strm, in, 1); - assert(ret == Z_DATA_ERROR); - mem_limit(&strm, 1); - ret = inflateSetDictionary(&strm, out, 0); - assert(ret == Z_MEM_ERROR); - mem_limit(&strm, 0); - ((struct inflate_state *)strm.state)->mode = DICT; - ret = inflateSetDictionary(&strm, out, 0); - assert(ret == Z_OK); - ret = inflate(&strm, Z_NO_FLUSH); assert(ret == Z_BUF_ERROR); - } - ret = inflateCopy(©, &strm); assert(ret == Z_OK); - ret = inflateEnd(©); assert(ret == Z_OK); - err = 9; /* don't care next time around */ - have += strm.avail_in; - strm.avail_in = step > have ? have : step; - have -= strm.avail_in; - } while (strm.avail_in); - free(in); - free(out); - ret = inflateReset2(&strm, -8); assert(ret == Z_OK); - ret = inflateEnd(&strm); assert(ret == Z_OK); - mem_done(&strm, what); -} - -/* cover all of the lines in inflate.c up to inflate() */ -local void cover_support(void) -{ - int ret; - z_stream strm; - - mem_setup(&strm); - strm.avail_in = 0; - strm.next_in = Z_NULL; - ret = inflateInit(&strm); assert(ret == Z_OK); - mem_used(&strm, "inflate init"); - ret = inflatePrime(&strm, 5, 31); assert(ret == Z_OK); - ret = inflatePrime(&strm, -1, 0); assert(ret == Z_OK); - ret = inflateSetDictionary(&strm, Z_NULL, 0); - assert(ret == Z_STREAM_ERROR); - ret = inflateEnd(&strm); assert(ret == Z_OK); - mem_done(&strm, "prime"); - - inf("63 0", "force window allocation", 0, -15, 1, Z_OK); - inf("63 18 5", "force window replacement", 0, -8, 259, Z_OK); - inf("63 18 68 30 d0 0 0", "force split window update", 4, -8, 259, Z_OK); - inf("3 0", "use fixed blocks", 0, -15, 1, Z_STREAM_END); - inf("", "bad window size", 0, 1, 0, Z_STREAM_ERROR); - - mem_setup(&strm); - strm.avail_in = 0; - strm.next_in = Z_NULL; - ret = inflateInit_(&strm, ZLIB_VERSION - 1, (int)sizeof(z_stream)); - assert(ret == Z_VERSION_ERROR); - mem_done(&strm, "wrong version"); - - strm.avail_in = 0; - strm.next_in = Z_NULL; - ret = inflateInit(&strm); assert(ret == Z_OK); - ret = inflateEnd(&strm); assert(ret == Z_OK); - fputs("inflate built-in memory routines\n", stderr); -} - -/* cover all inflate() header and trailer cases and code after inflate() */ -local void cover_wrap(void) -{ - int ret; - z_stream strm, copy; - unsigned char dict[257]; - - ret = inflate(Z_NULL, 0); assert(ret == Z_STREAM_ERROR); - ret = inflateEnd(Z_NULL); assert(ret == Z_STREAM_ERROR); - ret = inflateCopy(Z_NULL, Z_NULL); assert(ret == Z_STREAM_ERROR); - fputs("inflate bad parameters\n", stderr); - - inf("1f 8b 0 0", "bad gzip method", 0, 31, 0, Z_DATA_ERROR); - inf("1f 8b 8 80", "bad gzip flags", 0, 31, 0, Z_DATA_ERROR); - inf("77 85", "bad zlib method", 0, 15, 0, Z_DATA_ERROR); - inf("8 99", "set window size from header", 0, 0, 0, Z_OK); - inf("78 9c", "bad zlib window size", 0, 8, 0, Z_DATA_ERROR); - inf("78 9c 63 0 0 0 1 0 1", "check adler32", 0, 15, 1, Z_STREAM_END); - inf("1f 8b 8 1e 0 0 0 0 0 0 1 0 0 0 0 0 0", "bad header crc", 0, 47, 1, - Z_DATA_ERROR); - inf("1f 8b 8 2 0 0 0 0 0 0 1d 26 3 0 0 0 0 0 0 0 0 0", "check gzip length", - 0, 47, 0, Z_STREAM_END); - inf("78 90", "bad zlib header check", 0, 47, 0, Z_DATA_ERROR); - inf("8 b8 0 0 0 1", "need dictionary", 0, 8, 0, Z_NEED_DICT); - inf("78 9c 63 0", "compute adler32", 0, 15, 1, Z_OK); - - mem_setup(&strm); - strm.avail_in = 0; - strm.next_in = Z_NULL; - ret = inflateInit2(&strm, -8); - strm.avail_in = 2; - strm.next_in = (void *)"\x63"; - strm.avail_out = 1; - strm.next_out = (void *)&ret; - mem_limit(&strm, 1); - ret = inflate(&strm, Z_NO_FLUSH); assert(ret == Z_MEM_ERROR); - ret = inflate(&strm, Z_NO_FLUSH); assert(ret == Z_MEM_ERROR); - mem_limit(&strm, 0); - memset(dict, 0, 257); - ret = inflateSetDictionary(&strm, dict, 257); - assert(ret == Z_OK); - mem_limit(&strm, (sizeof(struct inflate_state) << 1) + 256); - ret = inflatePrime(&strm, 16, 0); assert(ret == Z_OK); - strm.avail_in = 2; - strm.next_in = (void *)"\x80"; - ret = inflateSync(&strm); assert(ret == Z_DATA_ERROR); - ret = inflate(&strm, Z_NO_FLUSH); assert(ret == Z_STREAM_ERROR); - strm.avail_in = 4; - strm.next_in = (void *)"\0\0\xff\xff"; - ret = inflateSync(&strm); assert(ret == Z_OK); - (void)inflateSyncPoint(&strm); - ret = inflateCopy(©, &strm); assert(ret == Z_MEM_ERROR); - mem_limit(&strm, 0); - ret = inflateUndermine(&strm, 1); assert(ret == Z_DATA_ERROR); - (void)inflateMark(&strm); - ret = inflateEnd(&strm); assert(ret == Z_OK); - mem_done(&strm, "miscellaneous, force memory errors"); -} - -/* input and output functions for inflateBack() */ -local unsigned pull(void *desc, unsigned char **buf) -{ - static unsigned int next = 0; - static unsigned char dat[] = {0x63, 0, 2, 0}; - struct inflate_state *state; - - if (desc == Z_NULL) { - next = 0; - return 0; /* no input (already provided at next_in) */ - } - state = (void *)((z_stream *)desc)->state; - if (state != Z_NULL) - state->mode = SYNC; /* force an otherwise impossible situation */ - return next < sizeof(dat) ? (*buf = dat + next++, 1) : 0; -} - -local int push(void *desc, unsigned char *buf, unsigned len) -{ - buf += len; - return desc != Z_NULL; /* force error if desc not null */ -} - -/* cover inflateBack() up to common deflate data cases and after those */ -local void cover_back(void) -{ - int ret; - z_stream strm; - unsigned char win[32768]; - - ret = inflateBackInit_(Z_NULL, 0, win, 0, 0); - assert(ret == Z_VERSION_ERROR); - ret = inflateBackInit(Z_NULL, 0, win); assert(ret == Z_STREAM_ERROR); - ret = inflateBack(Z_NULL, Z_NULL, Z_NULL, Z_NULL, Z_NULL); - assert(ret == Z_STREAM_ERROR); - ret = inflateBackEnd(Z_NULL); assert(ret == Z_STREAM_ERROR); - fputs("inflateBack bad parameters\n", stderr); - - mem_setup(&strm); - ret = inflateBackInit(&strm, 15, win); assert(ret == Z_OK); - strm.avail_in = 2; - strm.next_in = (void *)"\x03"; - ret = inflateBack(&strm, pull, Z_NULL, push, Z_NULL); - assert(ret == Z_STREAM_END); - /* force output error */ - strm.avail_in = 3; - strm.next_in = (void *)"\x63\x00"; - ret = inflateBack(&strm, pull, Z_NULL, push, &strm); - assert(ret == Z_BUF_ERROR); - /* force mode error by mucking with state */ - ret = inflateBack(&strm, pull, &strm, push, Z_NULL); - assert(ret == Z_STREAM_ERROR); - ret = inflateBackEnd(&strm); assert(ret == Z_OK); - mem_done(&strm, "inflateBack bad state"); - - ret = inflateBackInit(&strm, 15, win); assert(ret == Z_OK); - ret = inflateBackEnd(&strm); assert(ret == Z_OK); - fputs("inflateBack built-in memory routines\n", stderr); -} - -/* do a raw inflate of data in hexadecimal with both inflate and inflateBack */ -local int try(char *hex, char *id, int err) -{ - int ret; - unsigned len, size; - unsigned char *in, *out, *win; - char *prefix; - z_stream strm; - - /* convert to hex */ - in = h2b(hex, &len); - assert(in != NULL); - - /* allocate work areas */ - size = len << 3; - out = malloc(size); - assert(out != NULL); - win = malloc(32768); - assert(win != NULL); - prefix = malloc(strlen(id) + 6); - assert(prefix != NULL); - - /* first with inflate */ - strcpy(prefix, id); - strcat(prefix, "-late"); - mem_setup(&strm); - strm.avail_in = 0; - strm.next_in = Z_NULL; - ret = inflateInit2(&strm, err < 0 ? 47 : -15); - assert(ret == Z_OK); - strm.avail_in = len; - strm.next_in = in; - do { - strm.avail_out = size; - strm.next_out = out; - ret = inflate(&strm, Z_TREES); - assert(ret != Z_STREAM_ERROR && ret != Z_MEM_ERROR); - if (ret == Z_DATA_ERROR || ret == Z_NEED_DICT) - break; - } while (strm.avail_in || strm.avail_out == 0); - if (err) { - assert(ret == Z_DATA_ERROR); - assert(strcmp(id, strm.msg) == 0); - } - inflateEnd(&strm); - mem_done(&strm, prefix); - - /* then with inflateBack */ - if (err >= 0) { - strcpy(prefix, id); - strcat(prefix, "-back"); - mem_setup(&strm); - ret = inflateBackInit(&strm, 15, win); - assert(ret == Z_OK); - strm.avail_in = len; - strm.next_in = in; - ret = inflateBack(&strm, pull, Z_NULL, push, Z_NULL); - assert(ret != Z_STREAM_ERROR); - if (err) { - assert(ret == Z_DATA_ERROR); - assert(strcmp(id, strm.msg) == 0); - } - inflateBackEnd(&strm); - mem_done(&strm, prefix); - } - - /* clean up */ - free(prefix); - free(win); - free(out); - free(in); - return ret; -} - -/* cover deflate data cases in both inflate() and inflateBack() */ -local void cover_inflate(void) -{ - try("0 0 0 0 0", "invalid stored block lengths", 1); - try("3 0", "fixed", 0); - try("6", "invalid block type", 1); - try("1 1 0 fe ff 0", "stored", 0); - try("fc 0 0", "too many length or distance symbols", 1); - try("4 0 fe ff", "invalid code lengths set", 1); - try("4 0 24 49 0", "invalid bit length repeat", 1); - try("4 0 24 e9 ff ff", "invalid bit length repeat", 1); - try("4 0 24 e9 ff 6d", "invalid code -- missing end-of-block", 1); - try("4 80 49 92 24 49 92 24 71 ff ff 93 11 0", - "invalid literal/lengths set", 1); - try("4 80 49 92 24 49 92 24 f b4 ff ff c3 84", "invalid distances set", 1); - try("4 c0 81 8 0 0 0 0 20 7f eb b 0 0", "invalid literal/length code", 1); - try("2 7e ff ff", "invalid distance code", 1); - try("c c0 81 0 0 0 0 0 90 ff 6b 4 0", "invalid distance too far back", 1); - - /* also trailer mismatch just in inflate() */ - try("1f 8b 8 0 0 0 0 0 0 0 3 0 0 0 0 1", "incorrect data check", -1); - try("1f 8b 8 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 1", - "incorrect length check", -1); - try("5 c0 21 d 0 0 0 80 b0 fe 6d 2f 91 6c", "pull 17", 0); - try("5 e0 81 91 24 cb b2 2c 49 e2 f 2e 8b 9a 47 56 9f fb fe ec d2 ff 1f", - "long code", 0); - try("ed c0 1 1 0 0 0 40 20 ff 57 1b 42 2c 4f", "length extra", 0); - try("ed cf c1 b1 2c 47 10 c4 30 fa 6f 35 1d 1 82 59 3d fb be 2e 2a fc f c", - "long distance and extra", 0); - try("ed c0 81 0 0 0 0 80 a0 fd a9 17 a9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 " - "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6", "window end", 0); - inf("2 8 20 80 0 3 0", "inflate_fast TYPE return", 0, -15, 258, - Z_STREAM_END); - inf("63 18 5 40 c 0", "window wrap", 3, -8, 300, Z_OK); -} - -/* cover remaining lines in inftrees.c */ -local void cover_trees(void) -{ - int ret; - unsigned bits; - unsigned short lens[16], work[16]; - code *next, table[ENOUGH_DISTS]; - - /* we need to call inflate_table() directly in order to manifest not- - enough errors, since zlib insures that enough is always enough */ - for (bits = 0; bits < 15; bits++) - lens[bits] = (unsigned short)(bits + 1); - lens[15] = 15; - next = table; - bits = 15; - ret = inflate_table(DISTS, lens, 16, &next, &bits, work); - assert(ret == 1); - next = table; - bits = 1; - ret = inflate_table(DISTS, lens, 16, &next, &bits, work); - assert(ret == 1); - fputs("inflate_table not enough errors\n", stderr); -} - -/* cover remaining inffast.c decoding and window copying */ -local void cover_fast(void) -{ - inf("e5 e0 81 ad 6d cb b2 2c c9 01 1e 59 63 ae 7d ee fb 4d fd b5 35 41 68" - " ff 7f 0f 0 0 0", "fast length extra bits", 0, -8, 258, Z_DATA_ERROR); - inf("25 fd 81 b5 6d 59 b6 6a 49 ea af 35 6 34 eb 8c b9 f6 b9 1e ef 67 49" - " 50 fe ff ff 3f 0 0", "fast distance extra bits", 0, -8, 258, - Z_DATA_ERROR); - inf("3 7e 0 0 0 0 0", "fast invalid distance code", 0, -8, 258, - Z_DATA_ERROR); - inf("1b 7 0 0 0 0 0", "fast invalid literal/length code", 0, -8, 258, - Z_DATA_ERROR); - inf("d c7 1 ae eb 38 c 4 41 a0 87 72 de df fb 1f b8 36 b1 38 5d ff ff 0", - "fast 2nd level codes and too far back", 0, -8, 258, Z_DATA_ERROR); - inf("63 18 5 8c 10 8 0 0 0 0", "very common case", 0, -8, 259, Z_OK); - inf("63 60 60 18 c9 0 8 18 18 18 26 c0 28 0 29 0 0 0", - "contiguous and wrap around window", 6, -8, 259, Z_OK); - inf("63 0 3 0 0 0 0 0", "copy direct from output", 0, -8, 259, - Z_STREAM_END); -} - -int main(void) -{ - fprintf(stderr, "%s\n", zlibVersion()); - cover_support(); - cover_wrap(); - cover_back(); - cover_inflate(); - cover_trees(); - cover_fast(); - return 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/test/minigzip.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/test/minigzip.c deleted file mode 100644 index e22fb08..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/test/minigzip.c +++ /dev/null @@ -1,651 +0,0 @@ -/* minigzip.c -- simulate gzip using the zlib compression library - * Copyright (C) 1995-2006, 2010, 2011, 2016 Jean-loup Gailly - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - * minigzip is a minimal implementation of the gzip utility. This is - * only an example of using zlib and isn't meant to replace the - * full-featured gzip. No attempt is made to deal with file systems - * limiting names to 14 or 8+3 characters, etc... Error checking is - * very limited. So use minigzip only for testing; use gzip for the - * real thing. On MSDOS, use only on file names without extension - * or in pipe mode. - */ - -/* @(#) $Id$ */ - -#include "zlib.h" -#include - -#ifdef STDC -# include -# include -#endif - -#ifdef USE_MMAP -# include -# include -# include -#endif - -#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__) -# include -# include -# ifdef UNDER_CE -# include -# endif -# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY) -#else -# define SET_BINARY_MODE(file) -#endif - -#if defined(_MSC_VER) && _MSC_VER < 1900 -# define snprintf _snprintf -#endif - -#ifdef VMS -# define unlink delete -# define GZ_SUFFIX "-gz" -#endif -#ifdef RISCOS -# define unlink remove -# define GZ_SUFFIX "-gz" -# define fileno(file) file->__file -#endif -#if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os -# include /* for fileno */ -#endif - -#if !defined(Z_HAVE_UNISTD_H) && !defined(_LARGEFILE64_SOURCE) -#ifndef WIN32 /* unlink already in stdio.h for WIN32 */ - extern int unlink OF((const char *)); -#endif -#endif - -#if defined(UNDER_CE) -# include -# define perror(s) pwinerror(s) - -/* Map the Windows error number in ERROR to a locale-dependent error - message string and return a pointer to it. Typically, the values - for ERROR come from GetLastError. - - The string pointed to shall not be modified by the application, - but may be overwritten by a subsequent call to strwinerror - - The strwinerror function does not change the current setting - of GetLastError. */ - -static char *strwinerror (error) - DWORD error; -{ - static char buf[1024]; - - wchar_t *msgbuf; - DWORD lasterr = GetLastError(); - DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM - | FORMAT_MESSAGE_ALLOCATE_BUFFER, - NULL, - error, - 0, /* Default language */ - (LPVOID)&msgbuf, - 0, - NULL); - if (chars != 0) { - /* If there is an \r\n appended, zap it. */ - if (chars >= 2 - && msgbuf[chars - 2] == '\r' && msgbuf[chars - 1] == '\n') { - chars -= 2; - msgbuf[chars] = 0; - } - - if (chars > sizeof (buf) - 1) { - chars = sizeof (buf) - 1; - msgbuf[chars] = 0; - } - - wcstombs(buf, msgbuf, chars + 1); - LocalFree(msgbuf); - } - else { - sprintf(buf, "unknown win32 error (%ld)", error); - } - - SetLastError(lasterr); - return buf; -} - -static void pwinerror (s) - const char *s; -{ - if (s && *s) - fprintf(stderr, "%s: %s\n", s, strwinerror(GetLastError ())); - else - fprintf(stderr, "%s\n", strwinerror(GetLastError ())); -} - -#endif /* UNDER_CE */ - -#ifndef GZ_SUFFIX -# define GZ_SUFFIX ".gz" -#endif -#define SUFFIX_LEN (sizeof(GZ_SUFFIX)-1) - -#define BUFLEN 16384 -#define MAX_NAME_LEN 1024 - -#ifdef MAXSEG_64K -# define local static - /* Needed for systems with limitation on stack size. */ -#else -# define local -#endif - -#ifdef Z_SOLO -/* for Z_SOLO, create simplified gz* functions using deflate and inflate */ - -#if defined(Z_HAVE_UNISTD_H) || defined(Z_LARGE) -# include /* for unlink() */ -#endif - -void *myalloc OF((void *, unsigned, unsigned)); -void myfree OF((void *, void *)); - -void *myalloc(q, n, m) - void *q; - unsigned n, m; -{ - (void)q; - return calloc(n, m); -} - -void myfree(q, p) - void *q, *p; -{ - (void)q; - free(p); -} - -typedef struct gzFile_s { - FILE *file; - int write; - int err; - char *msg; - z_stream strm; -} *gzFile; - -gzFile gzopen OF((const char *, const char *)); -gzFile gzdopen OF((int, const char *)); -gzFile gz_open OF((const char *, int, const char *)); - -gzFile gzopen(path, mode) -const char *path; -const char *mode; -{ - return gz_open(path, -1, mode); -} - -gzFile gzdopen(fd, mode) -int fd; -const char *mode; -{ - return gz_open(NULL, fd, mode); -} - -gzFile gz_open(path, fd, mode) - const char *path; - int fd; - const char *mode; -{ - gzFile gz; - int ret; - - gz = malloc(sizeof(struct gzFile_s)); - if (gz == NULL) - return NULL; - gz->write = strchr(mode, 'w') != NULL; - gz->strm.zalloc = myalloc; - gz->strm.zfree = myfree; - gz->strm.opaque = Z_NULL; - if (gz->write) - ret = deflateInit2(&(gz->strm), -1, 8, 15 + 16, 8, 0); - else { - gz->strm.next_in = 0; - gz->strm.avail_in = Z_NULL; - ret = inflateInit2(&(gz->strm), 15 + 16); - } - if (ret != Z_OK) { - free(gz); - return NULL; - } - gz->file = path == NULL ? fdopen(fd, gz->write ? "wb" : "rb") : - fopen(path, gz->write ? "wb" : "rb"); - if (gz->file == NULL) { - gz->write ? deflateEnd(&(gz->strm)) : inflateEnd(&(gz->strm)); - free(gz); - return NULL; - } - gz->err = 0; - gz->msg = ""; - return gz; -} - -int gzwrite OF((gzFile, const void *, unsigned)); - -int gzwrite(gz, buf, len) - gzFile gz; - const void *buf; - unsigned len; -{ - z_stream *strm; - unsigned char out[BUFLEN]; - - if (gz == NULL || !gz->write) - return 0; - strm = &(gz->strm); - strm->next_in = (void *)buf; - strm->avail_in = len; - do { - strm->next_out = out; - strm->avail_out = BUFLEN; - (void)deflate(strm, Z_NO_FLUSH); - fwrite(out, 1, BUFLEN - strm->avail_out, gz->file); - } while (strm->avail_out == 0); - return len; -} - -int gzread OF((gzFile, void *, unsigned)); - -int gzread(gz, buf, len) - gzFile gz; - void *buf; - unsigned len; -{ - int ret; - unsigned got; - unsigned char in[1]; - z_stream *strm; - - if (gz == NULL || gz->write) - return 0; - if (gz->err) - return 0; - strm = &(gz->strm); - strm->next_out = (void *)buf; - strm->avail_out = len; - do { - got = fread(in, 1, 1, gz->file); - if (got == 0) - break; - strm->next_in = in; - strm->avail_in = 1; - ret = inflate(strm, Z_NO_FLUSH); - if (ret == Z_DATA_ERROR) { - gz->err = Z_DATA_ERROR; - gz->msg = strm->msg; - return 0; - } - if (ret == Z_STREAM_END) - inflateReset(strm); - } while (strm->avail_out); - return len - strm->avail_out; -} - -int gzclose OF((gzFile)); - -int gzclose(gz) - gzFile gz; -{ - z_stream *strm; - unsigned char out[BUFLEN]; - - if (gz == NULL) - return Z_STREAM_ERROR; - strm = &(gz->strm); - if (gz->write) { - strm->next_in = Z_NULL; - strm->avail_in = 0; - do { - strm->next_out = out; - strm->avail_out = BUFLEN; - (void)deflate(strm, Z_FINISH); - fwrite(out, 1, BUFLEN - strm->avail_out, gz->file); - } while (strm->avail_out == 0); - deflateEnd(strm); - } - else - inflateEnd(strm); - fclose(gz->file); - free(gz); - return Z_OK; -} - -const char *gzerror OF((gzFile, int *)); - -const char *gzerror(gz, err) - gzFile gz; - int *err; -{ - *err = gz->err; - return gz->msg; -} - -#endif - -static char *prog; - -void error OF((const char *msg)); -void gz_compress OF((FILE *in, gzFile out)); -#ifdef USE_MMAP -int gz_compress_mmap OF((FILE *in, gzFile out)); -#endif -void gz_uncompress OF((gzFile in, FILE *out)); -void file_compress OF((char *file, char *mode)); -void file_uncompress OF((char *file)); -int main OF((int argc, char *argv[])); - -/* =========================================================================== - * Display error message and exit - */ -void error(msg) - const char *msg; -{ - fprintf(stderr, "%s: %s\n", prog, msg); - exit(1); -} - -/* =========================================================================== - * Compress input to output then close both files. - */ - -void gz_compress(in, out) - FILE *in; - gzFile out; -{ - local char buf[BUFLEN]; - int len; - int err; - -#ifdef USE_MMAP - /* Try first compressing with mmap. If mmap fails (minigzip used in a - * pipe), use the normal fread loop. - */ - if (gz_compress_mmap(in, out) == Z_OK) return; -#endif - for (;;) { - len = (int)fread(buf, 1, sizeof(buf), in); - if (ferror(in)) { - perror("fread"); - exit(1); - } - if (len == 0) break; - - if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err)); - } - fclose(in); - if (gzclose(out) != Z_OK) error("failed gzclose"); -} - -#ifdef USE_MMAP /* MMAP version, Miguel Albrecht */ - -/* Try compressing the input file at once using mmap. Return Z_OK if - * if success, Z_ERRNO otherwise. - */ -int gz_compress_mmap(in, out) - FILE *in; - gzFile out; -{ - int len; - int err; - int ifd = fileno(in); - caddr_t buf; /* mmap'ed buffer for the entire input file */ - off_t buf_len; /* length of the input file */ - struct stat sb; - - /* Determine the size of the file, needed for mmap: */ - if (fstat(ifd, &sb) < 0) return Z_ERRNO; - buf_len = sb.st_size; - if (buf_len <= 0) return Z_ERRNO; - - /* Now do the actual mmap: */ - buf = mmap((caddr_t) 0, buf_len, PROT_READ, MAP_SHARED, ifd, (off_t)0); - if (buf == (caddr_t)(-1)) return Z_ERRNO; - - /* Compress the whole file at once: */ - len = gzwrite(out, (char *)buf, (unsigned)buf_len); - - if (len != (int)buf_len) error(gzerror(out, &err)); - - munmap(buf, buf_len); - fclose(in); - if (gzclose(out) != Z_OK) error("failed gzclose"); - return Z_OK; -} -#endif /* USE_MMAP */ - -/* =========================================================================== - * Uncompress input to output then close both files. - */ -void gz_uncompress(in, out) - gzFile in; - FILE *out; -{ - local char buf[BUFLEN]; - int len; - int err; - - for (;;) { - len = gzread(in, buf, sizeof(buf)); - if (len < 0) error (gzerror(in, &err)); - if (len == 0) break; - - if ((int)fwrite(buf, 1, (unsigned)len, out) != len) { - error("failed fwrite"); - } - } - if (fclose(out)) error("failed fclose"); - - if (gzclose(in) != Z_OK) error("failed gzclose"); -} - - -/* =========================================================================== - * Compress the given file: create a corresponding .gz file and remove the - * original. - */ -void file_compress(file, mode) - char *file; - char *mode; -{ - local char outfile[MAX_NAME_LEN]; - FILE *in; - gzFile out; - - if (strlen(file) + strlen(GZ_SUFFIX) >= sizeof(outfile)) { - fprintf(stderr, "%s: filename too long\n", prog); - exit(1); - } - -#if !defined(NO_snprintf) && !defined(NO_vsnprintf) - snprintf(outfile, sizeof(outfile), "%s%s", file, GZ_SUFFIX); -#else - strcpy(outfile, file); - strcat(outfile, GZ_SUFFIX); -#endif - - in = fopen(file, "rb"); - if (in == NULL) { - perror(file); - exit(1); - } - out = gzopen(outfile, mode); - if (out == NULL) { - fprintf(stderr, "%s: can't gzopen %s\n", prog, outfile); - exit(1); - } - gz_compress(in, out); - - unlink(file); -} - - -/* =========================================================================== - * Uncompress the given file and remove the original. - */ -void file_uncompress(file) - char *file; -{ - local char buf[MAX_NAME_LEN]; - char *infile, *outfile; - FILE *out; - gzFile in; - unsigned len = strlen(file); - - if (len + strlen(GZ_SUFFIX) >= sizeof(buf)) { - fprintf(stderr, "%s: filename too long\n", prog); - exit(1); - } - -#if !defined(NO_snprintf) && !defined(NO_vsnprintf) - snprintf(buf, sizeof(buf), "%s", file); -#else - strcpy(buf, file); -#endif - - if (len > SUFFIX_LEN && strcmp(file+len-SUFFIX_LEN, GZ_SUFFIX) == 0) { - infile = file; - outfile = buf; - outfile[len-3] = '\0'; - } else { - outfile = file; - infile = buf; -#if !defined(NO_snprintf) && !defined(NO_vsnprintf) - snprintf(buf + len, sizeof(buf) - len, "%s", GZ_SUFFIX); -#else - strcat(infile, GZ_SUFFIX); -#endif - } - in = gzopen(infile, "rb"); - if (in == NULL) { - fprintf(stderr, "%s: can't gzopen %s\n", prog, infile); - exit(1); - } - out = fopen(outfile, "wb"); - if (out == NULL) { - perror(file); - exit(1); - } - - gz_uncompress(in, out); - - unlink(infile); -} - - -/* =========================================================================== - * Usage: minigzip [-c] [-d] [-f] [-h] [-r] [-1 to -9] [files...] - * -c : write to standard output - * -d : decompress - * -f : compress with Z_FILTERED - * -h : compress with Z_HUFFMAN_ONLY - * -r : compress with Z_RLE - * -1 to -9 : compression level - */ - -int main(argc, argv) - int argc; - char *argv[]; -{ - int copyout = 0; - int uncompr = 0; - gzFile file; - char *bname, outmode[20]; - -#if !defined(NO_snprintf) && !defined(NO_vsnprintf) - snprintf(outmode, sizeof(outmode), "%s", "wb6 "); -#else - strcpy(outmode, "wb6 "); -#endif - - prog = argv[0]; - bname = strrchr(argv[0], '/'); - if (bname) - bname++; - else - bname = argv[0]; - argc--, argv++; - - if (!strcmp(bname, "gunzip")) - uncompr = 1; - else if (!strcmp(bname, "zcat")) - copyout = uncompr = 1; - - while (argc > 0) { - if (strcmp(*argv, "-c") == 0) - copyout = 1; - else if (strcmp(*argv, "-d") == 0) - uncompr = 1; - else if (strcmp(*argv, "-f") == 0) - outmode[3] = 'f'; - else if (strcmp(*argv, "-h") == 0) - outmode[3] = 'h'; - else if (strcmp(*argv, "-r") == 0) - outmode[3] = 'R'; - else if ((*argv)[0] == '-' && (*argv)[1] >= '1' && (*argv)[1] <= '9' && - (*argv)[2] == 0) - outmode[2] = (*argv)[1]; - else - break; - argc--, argv++; - } - if (outmode[3] == ' ') - outmode[3] = 0; - if (argc == 0) { - SET_BINARY_MODE(stdin); - SET_BINARY_MODE(stdout); - if (uncompr) { - file = gzdopen(fileno(stdin), "rb"); - if (file == NULL) error("can't gzdopen stdin"); - gz_uncompress(file, stdout); - } else { - file = gzdopen(fileno(stdout), outmode); - if (file == NULL) error("can't gzdopen stdout"); - gz_compress(stdin, file); - } - } else { - if (copyout) { - SET_BINARY_MODE(stdout); - } - do { - if (uncompr) { - if (copyout) { - file = gzopen(*argv, "rb"); - if (file == NULL) - fprintf(stderr, "%s: can't gzopen %s\n", prog, *argv); - else - gz_uncompress(file, stdout); - } else { - file_uncompress(*argv); - } - } else { - if (copyout) { - FILE * in = fopen(*argv, "rb"); - - if (in == NULL) { - perror(*argv); - } else { - file = gzdopen(fileno(stdout), outmode); - if (file == NULL) error("can't gzdopen stdout"); - - gz_compress(in, file); - } - - } else { - file_compress(*argv, outmode); - } - } - } while (argv++, --argc); - } - return 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/treebuild.xml b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/treebuild.xml deleted file mode 100644 index 781b4c9..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/treebuild.xml +++ /dev/null @@ -1,116 +0,0 @@ - - - - zip compression library - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/trees.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/trees.c deleted file mode 100644 index f73fd99..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/trees.c +++ /dev/null @@ -1,1182 +0,0 @@ -/* trees.c -- output deflated data using Huffman coding - * Copyright (C) 1995-2021 Jean-loup Gailly - * detect_data_type() function provided freely by Cosmin Truta, 2006 - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* - * ALGORITHM - * - * The "deflation" process uses several Huffman trees. The more - * common source values are represented by shorter bit sequences. - * - * Each code tree is stored in a compressed form which is itself - * a Huffman encoding of the lengths of all the code strings (in - * ascending order by source values). The actual code strings are - * reconstructed from the lengths in the inflate process, as described - * in the deflate specification. - * - * REFERENCES - * - * Deutsch, L.P.,"'Deflate' Compressed Data Format Specification". - * Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc - * - * Storer, James A. - * Data Compression: Methods and Theory, pp. 49-50. - * Computer Science Press, 1988. ISBN 0-7167-8156-5. - * - * Sedgewick, R. - * Algorithms, p290. - * Addison-Wesley, 1983. ISBN 0-201-06672-6. - */ - -/* @(#) $Id$ */ - -/* #define GEN_TREES_H */ - -#include "deflate.h" - -#ifdef ZLIB_DEBUG -# include -#endif - -/* =========================================================================== - * Constants - */ - -#define MAX_BL_BITS 7 -/* Bit length codes must not exceed MAX_BL_BITS bits */ - -#define END_BLOCK 256 -/* end of block literal code */ - -#define REP_3_6 16 -/* repeat previous bit length 3-6 times (2 bits of repeat count) */ - -#define REPZ_3_10 17 -/* repeat a zero length 3-10 times (3 bits of repeat count) */ - -#define REPZ_11_138 18 -/* repeat a zero length 11-138 times (7 bits of repeat count) */ - -local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */ - = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0}; - -local const int extra_dbits[D_CODES] /* extra bits for each distance code */ - = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; - -local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */ - = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7}; - -local const uch bl_order[BL_CODES] - = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; -/* The lengths of the bit length codes are sent in order of decreasing - * probability, to avoid transmitting the lengths for unused bit length codes. - */ - -/* =========================================================================== - * Local data. These are initialized only once. - */ - -#define DIST_CODE_LEN 512 /* see definition of array dist_code below */ - -#if defined(GEN_TREES_H) || !defined(STDC) -/* non ANSI compilers may not accept trees.h */ - -local ct_data static_ltree[L_CODES+2]; -/* The static literal tree. Since the bit lengths are imposed, there is no - * need for the L_CODES extra codes used during heap construction. However - * The codes 286 and 287 are needed to build a canonical tree (see _tr_init - * below). - */ - -local ct_data static_dtree[D_CODES]; -/* The static distance tree. (Actually a trivial tree since all codes use - * 5 bits.) - */ - -uch _dist_code[DIST_CODE_LEN]; -/* Distance codes. The first 256 values correspond to the distances - * 3 .. 258, the last 256 values correspond to the top 8 bits of - * the 15 bit distances. - */ - -uch _length_code[MAX_MATCH-MIN_MATCH+1]; -/* length code for each normalized match length (0 == MIN_MATCH) */ - -local int base_length[LENGTH_CODES]; -/* First normalized length for each code (0 = MIN_MATCH) */ - -local int base_dist[D_CODES]; -/* First normalized distance for each code (0 = distance of 1) */ - -#else -# include "trees.h" -#endif /* GEN_TREES_H */ - -struct static_tree_desc_s { - const ct_data *static_tree; /* static tree or NULL */ - const intf *extra_bits; /* extra bits for each code or NULL */ - int extra_base; /* base index for extra_bits */ - int elems; /* max number of elements in the tree */ - int max_length; /* max bit length for the codes */ -}; - -local const static_tree_desc static_l_desc = -{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS}; - -local const static_tree_desc static_d_desc = -{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; - -local const static_tree_desc static_bl_desc = -{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; - -/* =========================================================================== - * Local (static) routines in this file. - */ - -local void tr_static_init OF((void)); -local void init_block OF((deflate_state *s)); -local void pqdownheap OF((deflate_state *s, ct_data *tree, int k)); -local void gen_bitlen OF((deflate_state *s, tree_desc *desc)); -local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count)); -local void build_tree OF((deflate_state *s, tree_desc *desc)); -local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code)); -local void send_tree OF((deflate_state *s, ct_data *tree, int max_code)); -local int build_bl_tree OF((deflate_state *s)); -local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes, - int blcodes)); -local void compress_block OF((deflate_state *s, const ct_data *ltree, - const ct_data *dtree)); -local int detect_data_type OF((deflate_state *s)); -local unsigned bi_reverse OF((unsigned code, int len)); -local void bi_windup OF((deflate_state *s)); -local void bi_flush OF((deflate_state *s)); - -#ifdef GEN_TREES_H -local void gen_trees_header OF((void)); -#endif - -#ifndef ZLIB_DEBUG -# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len) - /* Send a code of the given tree. c and tree must not have side effects */ - -#else /* !ZLIB_DEBUG */ -# define send_code(s, c, tree) \ - { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \ - send_bits(s, tree[c].Code, tree[c].Len); } -#endif - -/* =========================================================================== - * Output a short LSB first on the stream. - * IN assertion: there is enough room in pendingBuf. - */ -#define put_short(s, w) { \ - put_byte(s, (uch)((w) & 0xff)); \ - put_byte(s, (uch)((ush)(w) >> 8)); \ -} - -/* =========================================================================== - * Send a value on a given number of bits. - * IN assertion: length <= 16 and value fits in length bits. - */ -#ifdef ZLIB_DEBUG -local void send_bits OF((deflate_state *s, int value, int length)); - -local void send_bits(s, value, length) - deflate_state *s; - int value; /* value to send */ - int length; /* number of bits */ -{ - Tracevv((stderr," l %2d v %4x ", length, value)); - Assert(length > 0 && length <= 15, "invalid length"); - s->bits_sent += (ulg)length; - - /* If not enough room in bi_buf, use (valid) bits from bi_buf and - * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid)) - * unused bits in value. - */ - if (s->bi_valid > (int)Buf_size - length) { - s->bi_buf |= (ush)value << s->bi_valid; - put_short(s, s->bi_buf); - s->bi_buf = (ush)value >> (Buf_size - s->bi_valid); - s->bi_valid += length - Buf_size; - } else { - s->bi_buf |= (ush)value << s->bi_valid; - s->bi_valid += length; - } -} -#else /* !ZLIB_DEBUG */ - -#define send_bits(s, value, length) \ -{ int len = length;\ - if (s->bi_valid > (int)Buf_size - len) {\ - int val = (int)value;\ - s->bi_buf |= (ush)val << s->bi_valid;\ - put_short(s, s->bi_buf);\ - s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\ - s->bi_valid += len - Buf_size;\ - } else {\ - s->bi_buf |= (ush)(value) << s->bi_valid;\ - s->bi_valid += len;\ - }\ -} -#endif /* ZLIB_DEBUG */ - - -/* the arguments must not have side effects */ - -/* =========================================================================== - * Initialize the various 'constant' tables. - */ -local void tr_static_init() -{ -#if defined(GEN_TREES_H) || !defined(STDC) - static int static_init_done = 0; - int n; /* iterates over tree elements */ - int bits; /* bit counter */ - int length; /* length value */ - int code; /* code value */ - int dist; /* distance index */ - ush bl_count[MAX_BITS+1]; - /* number of codes at each bit length for an optimal tree */ - - if (static_init_done) return; - - /* For some embedded targets, global variables are not initialized: */ -#ifdef NO_INIT_GLOBAL_POINTERS - static_l_desc.static_tree = static_ltree; - static_l_desc.extra_bits = extra_lbits; - static_d_desc.static_tree = static_dtree; - static_d_desc.extra_bits = extra_dbits; - static_bl_desc.extra_bits = extra_blbits; -#endif - - /* Initialize the mapping length (0..255) -> length code (0..28) */ - length = 0; - for (code = 0; code < LENGTH_CODES-1; code++) { - base_length[code] = length; - for (n = 0; n < (1< dist code (0..29) */ - dist = 0; - for (code = 0 ; code < 16; code++) { - base_dist[code] = dist; - for (n = 0; n < (1<>= 7; /* from now on, all distances are divided by 128 */ - for ( ; code < D_CODES; code++) { - base_dist[code] = dist << 7; - for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) { - _dist_code[256 + dist++] = (uch)code; - } - } - Assert (dist == 256, "tr_static_init: 256+dist != 512"); - - /* Construct the codes of the static literal tree */ - for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0; - n = 0; - while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++; - while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++; - while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++; - while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++; - /* Codes 286 and 287 do not exist, but we must include them in the - * tree construction to get a canonical Huffman tree (longest code - * all ones) - */ - gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count); - - /* The static distance tree is trivial: */ - for (n = 0; n < D_CODES; n++) { - static_dtree[n].Len = 5; - static_dtree[n].Code = bi_reverse((unsigned)n, 5); - } - static_init_done = 1; - -# ifdef GEN_TREES_H - gen_trees_header(); -# endif -#endif /* defined(GEN_TREES_H) || !defined(STDC) */ -} - -/* =========================================================================== - * Genererate the file trees.h describing the static trees. - */ -#ifdef GEN_TREES_H -# ifndef ZLIB_DEBUG -# include -# endif - -# define SEPARATOR(i, last, width) \ - ((i) == (last)? "\n};\n\n" : \ - ((i) % (width) == (width)-1 ? ",\n" : ", ")) - -void gen_trees_header() -{ - FILE *header = fopen("trees.h", "w"); - int i; - - Assert (header != NULL, "Can't open trees.h"); - fprintf(header, - "/* header created automatically with -DGEN_TREES_H */\n\n"); - - fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n"); - for (i = 0; i < L_CODES+2; i++) { - fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code, - static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5)); - } - - fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n"); - for (i = 0; i < D_CODES; i++) { - fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code, - static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5)); - } - - fprintf(header, "const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = {\n"); - for (i = 0; i < DIST_CODE_LEN; i++) { - fprintf(header, "%2u%s", _dist_code[i], - SEPARATOR(i, DIST_CODE_LEN-1, 20)); - } - - fprintf(header, - "const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= {\n"); - for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) { - fprintf(header, "%2u%s", _length_code[i], - SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20)); - } - - fprintf(header, "local const int base_length[LENGTH_CODES] = {\n"); - for (i = 0; i < LENGTH_CODES; i++) { - fprintf(header, "%1u%s", base_length[i], - SEPARATOR(i, LENGTH_CODES-1, 20)); - } - - fprintf(header, "local const int base_dist[D_CODES] = {\n"); - for (i = 0; i < D_CODES; i++) { - fprintf(header, "%5u%s", base_dist[i], - SEPARATOR(i, D_CODES-1, 10)); - } - - fclose(header); -} -#endif /* GEN_TREES_H */ - -/* =========================================================================== - * Initialize the tree data structures for a new zlib stream. - */ -void ZLIB_INTERNAL _tr_init(s) - deflate_state *s; -{ - tr_static_init(); - - s->l_desc.dyn_tree = s->dyn_ltree; - s->l_desc.stat_desc = &static_l_desc; - - s->d_desc.dyn_tree = s->dyn_dtree; - s->d_desc.stat_desc = &static_d_desc; - - s->bl_desc.dyn_tree = s->bl_tree; - s->bl_desc.stat_desc = &static_bl_desc; - - s->bi_buf = 0; - s->bi_valid = 0; -#ifdef ZLIB_DEBUG - s->compressed_len = 0L; - s->bits_sent = 0L; -#endif - - /* Initialize the first block of the first file: */ - init_block(s); -} - -/* =========================================================================== - * Initialize a new block. - */ -local void init_block(s) - deflate_state *s; -{ - int n; /* iterates over tree elements */ - - /* Initialize the trees. */ - for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; - for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; - for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; - - s->dyn_ltree[END_BLOCK].Freq = 1; - s->opt_len = s->static_len = 0L; - s->sym_next = s->matches = 0; -} - -#define SMALLEST 1 -/* Index within the heap array of least frequent node in the Huffman tree */ - - -/* =========================================================================== - * Remove the smallest element from the heap and recreate the heap with - * one less element. Updates heap and heap_len. - */ -#define pqremove(s, tree, top) \ -{\ - top = s->heap[SMALLEST]; \ - s->heap[SMALLEST] = s->heap[s->heap_len--]; \ - pqdownheap(s, tree, SMALLEST); \ -} - -/* =========================================================================== - * Compares to subtrees, using the tree depth as tie breaker when - * the subtrees have equal frequency. This minimizes the worst case length. - */ -#define smaller(tree, n, m, depth) \ - (tree[n].Freq < tree[m].Freq || \ - (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m])) - -/* =========================================================================== - * Restore the heap property by moving down the tree starting at node k, - * exchanging a node with the smallest of its two sons if necessary, stopping - * when the heap property is re-established (each father smaller than its - * two sons). - */ -local void pqdownheap(s, tree, k) - deflate_state *s; - ct_data *tree; /* the tree to restore */ - int k; /* node to move down */ -{ - int v = s->heap[k]; - int j = k << 1; /* left son of k */ - while (j <= s->heap_len) { - /* Set j to the smallest of the two sons: */ - if (j < s->heap_len && - smaller(tree, s->heap[j+1], s->heap[j], s->depth)) { - j++; - } - /* Exit if v is smaller than both sons */ - if (smaller(tree, v, s->heap[j], s->depth)) break; - - /* Exchange v with the smallest son */ - s->heap[k] = s->heap[j]; k = j; - - /* And continue down the tree, setting j to the left son of k */ - j <<= 1; - } - s->heap[k] = v; -} - -/* =========================================================================== - * Compute the optimal bit lengths for a tree and update the total bit length - * for the current block. - * IN assertion: the fields freq and dad are set, heap[heap_max] and - * above are the tree nodes sorted by increasing frequency. - * OUT assertions: the field len is set to the optimal bit length, the - * array bl_count contains the frequencies for each bit length. - * The length opt_len is updated; static_len is also updated if stree is - * not null. - */ -local void gen_bitlen(s, desc) - deflate_state *s; - tree_desc *desc; /* the tree descriptor */ -{ - ct_data *tree = desc->dyn_tree; - int max_code = desc->max_code; - const ct_data *stree = desc->stat_desc->static_tree; - const intf *extra = desc->stat_desc->extra_bits; - int base = desc->stat_desc->extra_base; - int max_length = desc->stat_desc->max_length; - int h; /* heap index */ - int n, m; /* iterate over the tree elements */ - int bits; /* bit length */ - int xbits; /* extra bits */ - ush f; /* frequency */ - int overflow = 0; /* number of elements with bit length too large */ - - for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0; - - /* In a first pass, compute the optimal bit lengths (which may - * overflow in the case of the bit length tree). - */ - tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */ - - for (h = s->heap_max+1; h < HEAP_SIZE; h++) { - n = s->heap[h]; - bits = tree[tree[n].Dad].Len + 1; - if (bits > max_length) bits = max_length, overflow++; - tree[n].Len = (ush)bits; - /* We overwrite tree[n].Dad which is no longer needed */ - - if (n > max_code) continue; /* not a leaf node */ - - s->bl_count[bits]++; - xbits = 0; - if (n >= base) xbits = extra[n-base]; - f = tree[n].Freq; - s->opt_len += (ulg)f * (unsigned)(bits + xbits); - if (stree) s->static_len += (ulg)f * (unsigned)(stree[n].Len + xbits); - } - if (overflow == 0) return; - - Tracev((stderr,"\nbit length overflow\n")); - /* This happens for example on obj2 and pic of the Calgary corpus */ - - /* Find the first bit length which could increase: */ - do { - bits = max_length-1; - while (s->bl_count[bits] == 0) bits--; - s->bl_count[bits]--; /* move one leaf down the tree */ - s->bl_count[bits+1] += 2; /* move one overflow item as its brother */ - s->bl_count[max_length]--; - /* The brother of the overflow item also moves one step up, - * but this does not affect bl_count[max_length] - */ - overflow -= 2; - } while (overflow > 0); - - /* Now recompute all bit lengths, scanning in increasing frequency. - * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all - * lengths instead of fixing only the wrong ones. This idea is taken - * from 'ar' written by Haruhiko Okumura.) - */ - for (bits = max_length; bits != 0; bits--) { - n = s->bl_count[bits]; - while (n != 0) { - m = s->heap[--h]; - if (m > max_code) continue; - if ((unsigned) tree[m].Len != (unsigned) bits) { - Tracev((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); - s->opt_len += ((ulg)bits - tree[m].Len) * tree[m].Freq; - tree[m].Len = (ush)bits; - } - n--; - } - } -} - -/* =========================================================================== - * Generate the codes for a given tree and bit counts (which need not be - * optimal). - * IN assertion: the array bl_count contains the bit length statistics for - * the given tree and the field len is set for all tree elements. - * OUT assertion: the field code is set for all tree elements of non - * zero code length. - */ -local void gen_codes (tree, max_code, bl_count) - ct_data *tree; /* the tree to decorate */ - int max_code; /* largest code with non zero frequency */ - ushf *bl_count; /* number of codes at each bit length */ -{ - ush next_code[MAX_BITS+1]; /* next code value for each bit length */ - unsigned code = 0; /* running code value */ - int bits; /* bit index */ - int n; /* code index */ - - /* The distribution counts are first used to generate the code values - * without bit reversal. - */ - for (bits = 1; bits <= MAX_BITS; bits++) { - code = (code + bl_count[bits-1]) << 1; - next_code[bits] = (ush)code; - } - /* Check that the bit counts in bl_count are consistent. The last code - * must be all ones. - */ - Assert (code + bl_count[MAX_BITS]-1 == (1<dyn_tree; - const ct_data *stree = desc->stat_desc->static_tree; - int elems = desc->stat_desc->elems; - int n, m; /* iterate over heap elements */ - int max_code = -1; /* largest code with non zero frequency */ - int node; /* new node being created */ - - /* Construct the initial heap, with least frequent element in - * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. - * heap[0] is not used. - */ - s->heap_len = 0, s->heap_max = HEAP_SIZE; - - for (n = 0; n < elems; n++) { - if (tree[n].Freq != 0) { - s->heap[++(s->heap_len)] = max_code = n; - s->depth[n] = 0; - } else { - tree[n].Len = 0; - } - } - - /* The pkzip format requires that at least one distance code exists, - * and that at least one bit should be sent even if there is only one - * possible code. So to avoid special checks later on we force at least - * two codes of non zero frequency. - */ - while (s->heap_len < 2) { - node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0); - tree[node].Freq = 1; - s->depth[node] = 0; - s->opt_len--; if (stree) s->static_len -= stree[node].Len; - /* node is 0 or 1 so it does not have extra bits */ - } - desc->max_code = max_code; - - /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree, - * establish sub-heaps of increasing lengths: - */ - for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n); - - /* Construct the Huffman tree by repeatedly combining the least two - * frequent nodes. - */ - node = elems; /* next internal node of the tree */ - do { - pqremove(s, tree, n); /* n = node of least frequency */ - m = s->heap[SMALLEST]; /* m = node of next least frequency */ - - s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */ - s->heap[--(s->heap_max)] = m; - - /* Create a new node father of n and m */ - tree[node].Freq = tree[n].Freq + tree[m].Freq; - s->depth[node] = (uch)((s->depth[n] >= s->depth[m] ? - s->depth[n] : s->depth[m]) + 1); - tree[n].Dad = tree[m].Dad = (ush)node; -#ifdef DUMP_BL_TREE - if (tree == s->bl_tree) { - fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)", - node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq); - } -#endif - /* and insert the new node in the heap */ - s->heap[SMALLEST] = node++; - pqdownheap(s, tree, SMALLEST); - - } while (s->heap_len >= 2); - - s->heap[--(s->heap_max)] = s->heap[SMALLEST]; - - /* At this point, the fields freq and dad are set. We can now - * generate the bit lengths. - */ - gen_bitlen(s, (tree_desc *)desc); - - /* The field len is now set, we can generate the bit codes */ - gen_codes ((ct_data *)tree, max_code, s->bl_count); -} - -/* =========================================================================== - * Scan a literal or distance tree to determine the frequencies of the codes - * in the bit length tree. - */ -local void scan_tree (s, tree, max_code) - deflate_state *s; - ct_data *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ - int n; /* iterates over all tree elements */ - int prevlen = -1; /* last emitted length */ - int curlen; /* length of current code */ - int nextlen = tree[0].Len; /* length of next code */ - int count = 0; /* repeat count of the current code */ - int max_count = 7; /* max repeat count */ - int min_count = 4; /* min repeat count */ - - if (nextlen == 0) max_count = 138, min_count = 3; - tree[max_code+1].Len = (ush)0xffff; /* guard */ - - for (n = 0; n <= max_code; n++) { - curlen = nextlen; nextlen = tree[n+1].Len; - if (++count < max_count && curlen == nextlen) { - continue; - } else if (count < min_count) { - s->bl_tree[curlen].Freq += count; - } else if (curlen != 0) { - if (curlen != prevlen) s->bl_tree[curlen].Freq++; - s->bl_tree[REP_3_6].Freq++; - } else if (count <= 10) { - s->bl_tree[REPZ_3_10].Freq++; - } else { - s->bl_tree[REPZ_11_138].Freq++; - } - count = 0; prevlen = curlen; - if (nextlen == 0) { - max_count = 138, min_count = 3; - } else if (curlen == nextlen) { - max_count = 6, min_count = 3; - } else { - max_count = 7, min_count = 4; - } - } -} - -/* =========================================================================== - * Send a literal or distance tree in compressed form, using the codes in - * bl_tree. - */ -local void send_tree (s, tree, max_code) - deflate_state *s; - ct_data *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ - int n; /* iterates over all tree elements */ - int prevlen = -1; /* last emitted length */ - int curlen; /* length of current code */ - int nextlen = tree[0].Len; /* length of next code */ - int count = 0; /* repeat count of the current code */ - int max_count = 7; /* max repeat count */ - int min_count = 4; /* min repeat count */ - - /* tree[max_code+1].Len = -1; */ /* guard already set */ - if (nextlen == 0) max_count = 138, min_count = 3; - - for (n = 0; n <= max_code; n++) { - curlen = nextlen; nextlen = tree[n+1].Len; - if (++count < max_count && curlen == nextlen) { - continue; - } else if (count < min_count) { - do { send_code(s, curlen, s->bl_tree); } while (--count != 0); - - } else if (curlen != 0) { - if (curlen != prevlen) { - send_code(s, curlen, s->bl_tree); count--; - } - Assert(count >= 3 && count <= 6, " 3_6?"); - send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2); - - } else if (count <= 10) { - send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3); - - } else { - send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7); - } - count = 0; prevlen = curlen; - if (nextlen == 0) { - max_count = 138, min_count = 3; - } else if (curlen == nextlen) { - max_count = 6, min_count = 3; - } else { - max_count = 7, min_count = 4; - } - } -} - -/* =========================================================================== - * Construct the Huffman tree for the bit lengths and return the index in - * bl_order of the last bit length code to send. - */ -local int build_bl_tree(s) - deflate_state *s; -{ - int max_blindex; /* index of last bit length code of non zero freq */ - - /* Determine the bit length frequencies for literal and distance trees */ - scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code); - scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code); - - /* Build the bit length tree: */ - build_tree(s, (tree_desc *)(&(s->bl_desc))); - /* opt_len now includes the length of the tree representations, except - * the lengths of the bit lengths codes and the 5+5+4 bits for the counts. - */ - - /* Determine the number of bit length codes to send. The pkzip format - * requires that at least 4 bit length codes be sent. (appnote.txt says - * 3 but the actual value used is 4.) - */ - for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) { - if (s->bl_tree[bl_order[max_blindex]].Len != 0) break; - } - /* Update opt_len to include the bit length tree and counts */ - s->opt_len += 3*((ulg)max_blindex+1) + 5+5+4; - Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", - s->opt_len, s->static_len)); - - return max_blindex; -} - -/* =========================================================================== - * Send the header for a block using dynamic Huffman trees: the counts, the - * lengths of the bit length codes, the literal tree and the distance tree. - * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. - */ -local void send_all_trees(s, lcodes, dcodes, blcodes) - deflate_state *s; - int lcodes, dcodes, blcodes; /* number of codes for each tree */ -{ - int rank; /* index in bl_order */ - - Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); - Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, - "too many codes"); - Tracev((stderr, "\nbl counts: ")); - send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */ - send_bits(s, dcodes-1, 5); - send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */ - for (rank = 0; rank < blcodes; rank++) { - Tracev((stderr, "\nbl code %2d ", bl_order[rank])); - send_bits(s, s->bl_tree[bl_order[rank]].Len, 3); - } - Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent)); - - send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */ - Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent)); - - send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */ - Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent)); -} - -/* =========================================================================== - * Send a stored block - */ -void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last) - deflate_state *s; - charf *buf; /* input block */ - ulg stored_len; /* length of input block */ - int last; /* one if this is the last block for a file */ -{ - send_bits(s, (STORED_BLOCK<<1)+last, 3); /* send block type */ - bi_windup(s); /* align on byte boundary */ - put_short(s, (ush)stored_len); - put_short(s, (ush)~stored_len); - if (stored_len) - zmemcpy(s->pending_buf + s->pending, (Bytef *)buf, stored_len); - s->pending += stored_len; -#ifdef ZLIB_DEBUG - s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; - s->compressed_len += (stored_len + 4) << 3; - s->bits_sent += 2*16; - s->bits_sent += stored_len<<3; -#endif -} - -/* =========================================================================== - * Flush the bits in the bit buffer to pending output (leaves at most 7 bits) - */ -void ZLIB_INTERNAL _tr_flush_bits(s) - deflate_state *s; -{ - bi_flush(s); -} - -/* =========================================================================== - * Send one empty static block to give enough lookahead for inflate. - * This takes 10 bits, of which 7 may remain in the bit buffer. - */ -void ZLIB_INTERNAL _tr_align(s) - deflate_state *s; -{ - send_bits(s, STATIC_TREES<<1, 3); - send_code(s, END_BLOCK, static_ltree); -#ifdef ZLIB_DEBUG - s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ -#endif - bi_flush(s); -} - -/* =========================================================================== - * Determine the best encoding for the current block: dynamic trees, static - * trees or store, and write out the encoded block. - */ -void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) - deflate_state *s; - charf *buf; /* input block, or NULL if too old */ - ulg stored_len; /* length of input block */ - int last; /* one if this is the last block for a file */ -{ - ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ - int max_blindex = 0; /* index of last bit length code of non zero freq */ - - /* Build the Huffman trees unless a stored block is forced */ - if (s->level > 0) { - - /* Check if the file is binary or text */ - if (s->strm->data_type == Z_UNKNOWN) - s->strm->data_type = detect_data_type(s); - - /* Construct the literal and distance trees */ - build_tree(s, (tree_desc *)(&(s->l_desc))); - Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len, - s->static_len)); - - build_tree(s, (tree_desc *)(&(s->d_desc))); - Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len, - s->static_len)); - /* At this point, opt_len and static_len are the total bit lengths of - * the compressed block data, excluding the tree representations. - */ - - /* Build the bit length tree for the above two trees, and get the index - * in bl_order of the last bit length code to send. - */ - max_blindex = build_bl_tree(s); - - /* Determine the best encoding. Compute the block lengths in bytes. */ - opt_lenb = (s->opt_len+3+7)>>3; - static_lenb = (s->static_len+3+7)>>3; - - Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ", - opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, - s->sym_next / 3)); - - if (static_lenb <= opt_lenb) opt_lenb = static_lenb; - - } else { - Assert(buf != (char*)0, "lost buf"); - opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ - } - -#ifdef FORCE_STORED - if (buf != (char*)0) { /* force stored block */ -#else - if (stored_len+4 <= opt_lenb && buf != (char*)0) { - /* 4: two words for the lengths */ -#endif - /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. - * Otherwise we can't have processed more than WSIZE input bytes since - * the last block flush, because compression would have been - * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to - * transform a block into a stored block. - */ - _tr_stored_block(s, buf, stored_len, last); - -#ifdef FORCE_STATIC - } else if (static_lenb >= 0) { /* force static trees */ -#else - } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) { -#endif - send_bits(s, (STATIC_TREES<<1)+last, 3); - compress_block(s, (const ct_data *)static_ltree, - (const ct_data *)static_dtree); -#ifdef ZLIB_DEBUG - s->compressed_len += 3 + s->static_len; -#endif - } else { - send_bits(s, (DYN_TREES<<1)+last, 3); - send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, - max_blindex+1); - compress_block(s, (const ct_data *)s->dyn_ltree, - (const ct_data *)s->dyn_dtree); -#ifdef ZLIB_DEBUG - s->compressed_len += 3 + s->opt_len; -#endif - } - Assert (s->compressed_len == s->bits_sent, "bad compressed size"); - /* The above check is made mod 2^32, for files larger than 512 MB - * and uLong implemented on 32 bits. - */ - init_block(s); - - if (last) { - bi_windup(s); -#ifdef ZLIB_DEBUG - s->compressed_len += 7; /* align on byte boundary */ -#endif - } - Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3, - s->compressed_len-7*last)); -} - -/* =========================================================================== - * Save the match info and tally the frequency counts. Return true if - * the current block must be flushed. - */ -int ZLIB_INTERNAL _tr_tally (s, dist, lc) - deflate_state *s; - unsigned dist; /* distance of matched string */ - unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */ -{ - s->sym_buf[s->sym_next++] = dist; - s->sym_buf[s->sym_next++] = dist >> 8; - s->sym_buf[s->sym_next++] = lc; - if (dist == 0) { - /* lc is the unmatched char */ - s->dyn_ltree[lc].Freq++; - } else { - s->matches++; - /* Here, lc is the match length - MIN_MATCH */ - dist--; /* dist = match distance - 1 */ - Assert((ush)dist < (ush)MAX_DIST(s) && - (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && - (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match"); - - s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++; - s->dyn_dtree[d_code(dist)].Freq++; - } - return (s->sym_next == s->sym_end); -} - -/* =========================================================================== - * Send the block data compressed using the given Huffman trees - */ -local void compress_block(s, ltree, dtree) - deflate_state *s; - const ct_data *ltree; /* literal tree */ - const ct_data *dtree; /* distance tree */ -{ - unsigned dist; /* distance of matched string */ - int lc; /* match length or unmatched char (if dist == 0) */ - unsigned sx = 0; /* running index in sym_buf */ - unsigned code; /* the code to send */ - int extra; /* number of extra bits to send */ - - if (s->sym_next != 0) do { - dist = s->sym_buf[sx++] & 0xff; - dist += (unsigned)(s->sym_buf[sx++] & 0xff) << 8; - lc = s->sym_buf[sx++]; - if (dist == 0) { - send_code(s, lc, ltree); /* send a literal byte */ - Tracecv(isgraph(lc), (stderr," '%c' ", lc)); - } else { - /* Here, lc is the match length - MIN_MATCH */ - code = _length_code[lc]; - send_code(s, code+LITERALS+1, ltree); /* send the length code */ - extra = extra_lbits[code]; - if (extra != 0) { - lc -= base_length[code]; - send_bits(s, lc, extra); /* send the extra length bits */ - } - dist--; /* dist is now the match distance - 1 */ - code = d_code(dist); - Assert (code < D_CODES, "bad d_code"); - - send_code(s, code, dtree); /* send the distance code */ - extra = extra_dbits[code]; - if (extra != 0) { - dist -= (unsigned)base_dist[code]; - send_bits(s, dist, extra); /* send the extra distance bits */ - } - } /* literal or match pair ? */ - - /* Check that the overlay between pending_buf and sym_buf is ok: */ - Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow"); - - } while (sx < s->sym_next); - - send_code(s, END_BLOCK, ltree); -} - -/* =========================================================================== - * Check if the data type is TEXT or BINARY, using the following algorithm: - * - TEXT if the two conditions below are satisfied: - * a) There are no non-portable control characters belonging to the - * "block list" (0..6, 14..25, 28..31). - * b) There is at least one printable character belonging to the - * "allow list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255). - * - BINARY otherwise. - * - The following partially-portable control characters form a - * "gray list" that is ignored in this detection algorithm: - * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}). - * IN assertion: the fields Freq of dyn_ltree are set. - */ -local int detect_data_type(s) - deflate_state *s; -{ - /* block_mask is the bit mask of block-listed bytes - * set bits 0..6, 14..25, and 28..31 - * 0xf3ffc07f = binary 11110011111111111100000001111111 - */ - unsigned long block_mask = 0xf3ffc07fUL; - int n; - - /* Check for non-textual ("block-listed") bytes. */ - for (n = 0; n <= 31; n++, block_mask >>= 1) - if ((block_mask & 1) && (s->dyn_ltree[n].Freq != 0)) - return Z_BINARY; - - /* Check for textual ("allow-listed") bytes. */ - if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0 - || s->dyn_ltree[13].Freq != 0) - return Z_TEXT; - for (n = 32; n < LITERALS; n++) - if (s->dyn_ltree[n].Freq != 0) - return Z_TEXT; - - /* There are no "block-listed" or "allow-listed" bytes: - * this stream either is empty or has tolerated ("gray-listed") bytes only. - */ - return Z_BINARY; -} - -/* =========================================================================== - * Reverse the first len bits of a code, using straightforward code (a faster - * method would use a table) - * IN assertion: 1 <= len <= 15 - */ -local unsigned bi_reverse(code, len) - unsigned code; /* the value to invert */ - int len; /* its bit length */ -{ - register unsigned res = 0; - do { - res |= code & 1; - code >>= 1, res <<= 1; - } while (--len > 0); - return res >> 1; -} - -/* =========================================================================== - * Flush the bit buffer, keeping at most 7 bits in it. - */ -local void bi_flush(s) - deflate_state *s; -{ - if (s->bi_valid == 16) { - put_short(s, s->bi_buf); - s->bi_buf = 0; - s->bi_valid = 0; - } else if (s->bi_valid >= 8) { - put_byte(s, (Byte)s->bi_buf); - s->bi_buf >>= 8; - s->bi_valid -= 8; - } -} - -/* =========================================================================== - * Flush the bit buffer and align the output on a byte boundary - */ -local void bi_windup(s) - deflate_state *s; -{ - if (s->bi_valid > 8) { - put_short(s, s->bi_buf); - } else if (s->bi_valid > 0) { - put_byte(s, (Byte)s->bi_buf); - } - s->bi_buf = 0; - s->bi_valid = 0; -#ifdef ZLIB_DEBUG - s->bits_sent = (s->bits_sent+7) & ~7; -#endif -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/trees.h b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/trees.h deleted file mode 100644 index d35639d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/trees.h +++ /dev/null @@ -1,128 +0,0 @@ -/* header created automatically with -DGEN_TREES_H */ - -local const ct_data static_ltree[L_CODES+2] = { -{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}}, -{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}}, -{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}}, -{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}}, -{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}}, -{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}}, -{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}}, -{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}}, -{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}}, -{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}}, -{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}}, -{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}}, -{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}}, -{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}}, -{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}}, -{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}}, -{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}}, -{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}}, -{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}}, -{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}}, -{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}}, -{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}}, -{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}}, -{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}}, -{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}}, -{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}}, -{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}}, -{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}}, -{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}}, -{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}}, -{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}}, -{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}}, -{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}}, -{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}}, -{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}}, -{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}}, -{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}}, -{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}}, -{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}}, -{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}}, -{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}}, -{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}}, -{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}}, -{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}}, -{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}}, -{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}}, -{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}}, -{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}}, -{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}}, -{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}}, -{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}}, -{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}}, -{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}}, -{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}}, -{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}}, -{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}}, -{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}}, -{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}} -}; - -local const ct_data static_dtree[D_CODES] = { -{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, -{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, -{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, -{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, -{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, -{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} -}; - -const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = { - 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, - 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, -10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, -11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, -12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, -13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, -13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, -18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, -23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 -}; - -const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, -13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, -17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, -19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, -21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, -22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, -23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, -25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 -}; - -local const int base_length[LENGTH_CODES] = { -0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, -64, 80, 96, 112, 128, 160, 192, 224, 0 -}; - -local const int base_dist[D_CODES] = { - 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, - 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, - 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 -}; - diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/uncompr.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/uncompr.c deleted file mode 100644 index f03a1a8..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/uncompr.c +++ /dev/null @@ -1,93 +0,0 @@ -/* uncompr.c -- decompress a memory buffer - * Copyright (C) 1995-2003, 2010, 2014, 2016 Jean-loup Gailly, Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#define ZLIB_INTERNAL -#include "zlib.h" - -/* =========================================================================== - Decompresses the source buffer into the destination buffer. *sourceLen is - the byte length of the source buffer. Upon entry, *destLen is the total size - of the destination buffer, which must be large enough to hold the entire - uncompressed data. (The size of the uncompressed data must have been saved - previously by the compressor and transmitted to the decompressor by some - mechanism outside the scope of this compression library.) Upon exit, - *destLen is the size of the decompressed data and *sourceLen is the number - of source bytes consumed. Upon return, source + *sourceLen points to the - first unused input byte. - - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_BUF_ERROR if there was not enough room in the output buffer, or - Z_DATA_ERROR if the input data was corrupted, including if the input data is - an incomplete zlib stream. -*/ -int ZEXPORT uncompress2 (dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong *sourceLen; -{ - z_stream stream; - int err; - const uInt max = (uInt)-1; - uLong len, left; - Byte buf[1]; /* for detection of incomplete stream when *destLen == 0 */ - - len = *sourceLen; - if (*destLen) { - left = *destLen; - *destLen = 0; - } - else { - left = 1; - dest = buf; - } - - stream.next_in = (z_const Bytef *)source; - stream.avail_in = 0; - stream.zalloc = (alloc_func)0; - stream.zfree = (free_func)0; - stream.opaque = (voidpf)0; - - err = inflateInit(&stream); - if (err != Z_OK) return err; - - stream.next_out = dest; - stream.avail_out = 0; - - do { - if (stream.avail_out == 0) { - stream.avail_out = left > (uLong)max ? max : (uInt)left; - left -= stream.avail_out; - } - if (stream.avail_in == 0) { - stream.avail_in = len > (uLong)max ? max : (uInt)len; - len -= stream.avail_in; - } - err = inflate(&stream, Z_NO_FLUSH); - } while (err == Z_OK); - - *sourceLen -= len + stream.avail_in; - if (dest != buf) - *destLen = stream.total_out; - else if (stream.total_out && err == Z_BUF_ERROR) - left = 1; - - inflateEnd(&stream); - return err == Z_STREAM_END ? Z_OK : - err == Z_NEED_DICT ? Z_DATA_ERROR : - err == Z_BUF_ERROR && left + stream.avail_out ? Z_DATA_ERROR : - err; -} - -int ZEXPORT uncompress (dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; -{ - return uncompress2(dest, destLen, source, &sourceLen); -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/watcom/watcom_f.mak b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/watcom/watcom_f.mak deleted file mode 100644 index 37f4d74..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/watcom/watcom_f.mak +++ /dev/null @@ -1,43 +0,0 @@ -# Makefile for zlib -# OpenWatcom flat model -# Last updated: 28-Dec-2005 - -# To use, do "wmake -f watcom_f.mak" - -C_SOURCE = adler32.c compress.c crc32.c deflate.c & - gzclose.c gzlib.c gzread.c gzwrite.c & - infback.c inffast.c inflate.c inftrees.c & - trees.c uncompr.c zutil.c - -OBJS = adler32.obj compress.obj crc32.obj deflate.obj & - gzclose.obj gzlib.obj gzread.obj gzwrite.obj & - infback.obj inffast.obj inflate.obj inftrees.obj & - trees.obj uncompr.obj zutil.obj - -CC = wcc386 -LINKER = wcl386 -CFLAGS = -zq -mf -3r -fp3 -s -bt=dos -oilrtfm -fr=nul -wx -ZLIB_LIB = zlib_f.lib - -.C.OBJ: - $(CC) $(CFLAGS) $[@ - -all: $(ZLIB_LIB) example.exe minigzip.exe - -$(ZLIB_LIB): $(OBJS) - wlib -b -c $(ZLIB_LIB) -+adler32.obj -+compress.obj -+crc32.obj - wlib -b -c $(ZLIB_LIB) -+gzclose.obj -+gzlib.obj -+gzread.obj -+gzwrite.obj - wlib -b -c $(ZLIB_LIB) -+deflate.obj -+infback.obj - wlib -b -c $(ZLIB_LIB) -+inffast.obj -+inflate.obj -+inftrees.obj - wlib -b -c $(ZLIB_LIB) -+trees.obj -+uncompr.obj -+zutil.obj - -example.exe: $(ZLIB_LIB) example.obj - $(LINKER) -ldos32a -fe=example.exe example.obj $(ZLIB_LIB) - -minigzip.exe: $(ZLIB_LIB) minigzip.obj - $(LINKER) -ldos32a -fe=minigzip.exe minigzip.obj $(ZLIB_LIB) - -clean: .SYMBOLIC - del *.obj - del $(ZLIB_LIB) - @echo Cleaning done diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/watcom/watcom_l.mak b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/watcom/watcom_l.mak deleted file mode 100644 index 193eed7..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/watcom/watcom_l.mak +++ /dev/null @@ -1,43 +0,0 @@ -# Makefile for zlib -# OpenWatcom large model -# Last updated: 28-Dec-2005 - -# To use, do "wmake -f watcom_l.mak" - -C_SOURCE = adler32.c compress.c crc32.c deflate.c & - gzclose.c gzlib.c gzread.c gzwrite.c & - infback.c inffast.c inflate.c inftrees.c & - trees.c uncompr.c zutil.c - -OBJS = adler32.obj compress.obj crc32.obj deflate.obj & - gzclose.obj gzlib.obj gzread.obj gzwrite.obj & - infback.obj inffast.obj inflate.obj inftrees.obj & - trees.obj uncompr.obj zutil.obj - -CC = wcc -LINKER = wcl -CFLAGS = -zq -ml -s -bt=dos -oilrtfm -fr=nul -wx -ZLIB_LIB = zlib_l.lib - -.C.OBJ: - $(CC) $(CFLAGS) $[@ - -all: $(ZLIB_LIB) example.exe minigzip.exe - -$(ZLIB_LIB): $(OBJS) - wlib -b -c $(ZLIB_LIB) -+adler32.obj -+compress.obj -+crc32.obj - wlib -b -c $(ZLIB_LIB) -+gzclose.obj -+gzlib.obj -+gzread.obj -+gzwrite.obj - wlib -b -c $(ZLIB_LIB) -+deflate.obj -+infback.obj - wlib -b -c $(ZLIB_LIB) -+inffast.obj -+inflate.obj -+inftrees.obj - wlib -b -c $(ZLIB_LIB) -+trees.obj -+uncompr.obj -+zutil.obj - -example.exe: $(ZLIB_LIB) example.obj - $(LINKER) -fe=example.exe example.obj $(ZLIB_LIB) - -minigzip.exe: $(ZLIB_LIB) minigzip.obj - $(LINKER) -fe=minigzip.exe minigzip.obj $(ZLIB_LIB) - -clean: .SYMBOLIC - del *.obj - del $(ZLIB_LIB) - @echo Cleaning done diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/win32/DLL_FAQ.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/win32/DLL_FAQ.txt deleted file mode 100644 index 12c0090..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/win32/DLL_FAQ.txt +++ /dev/null @@ -1,397 +0,0 @@ - - Frequently Asked Questions about ZLIB1.DLL - - -This document describes the design, the rationale, and the usage -of the official DLL build of zlib, named ZLIB1.DLL. If you have -general questions about zlib, you should see the file "FAQ" found -in the zlib distribution, or at the following location: - http://www.gzip.org/zlib/zlib_faq.html - - - 1. What is ZLIB1.DLL, and how can I get it? - - - ZLIB1.DLL is the official build of zlib as a DLL. - (Please remark the character '1' in the name.) - - Pointers to a precompiled ZLIB1.DLL can be found in the zlib - web site at: - http://www.zlib.net/ - - Applications that link to ZLIB1.DLL can rely on the following - specification: - - * The exported symbols are exclusively defined in the source - files "zlib.h" and "zlib.def", found in an official zlib - source distribution. - * The symbols are exported by name, not by ordinal. - * The exported names are undecorated. - * The calling convention of functions is "C" (CDECL). - * The ZLIB1.DLL binary is linked to MSVCRT.DLL. - - The archive in which ZLIB1.DLL is bundled contains compiled - test programs that must run with a valid build of ZLIB1.DLL. - It is recommended to download the prebuilt DLL from the zlib - web site, instead of building it yourself, to avoid potential - incompatibilities that could be introduced by your compiler - and build settings. If you do build the DLL yourself, please - make sure that it complies with all the above requirements, - and it runs with the precompiled test programs, bundled with - the original ZLIB1.DLL distribution. - - If, for any reason, you need to build an incompatible DLL, - please use a different file name. - - - 2. Why did you change the name of the DLL to ZLIB1.DLL? - What happened to the old ZLIB.DLL? - - - The old ZLIB.DLL, built from zlib-1.1.4 or earlier, required - compilation settings that were incompatible to those used by - a static build. The DLL settings were supposed to be enabled - by defining the macro ZLIB_DLL, before including "zlib.h". - Incorrect handling of this macro was silently accepted at - build time, resulting in two major problems: - - * ZLIB_DLL was missing from the old makefile. When building - the DLL, not all people added it to the build options. In - consequence, incompatible incarnations of ZLIB.DLL started - to circulate around the net. - - * When switching from using the static library to using the - DLL, applications had to define the ZLIB_DLL macro and - to recompile all the sources that contained calls to zlib - functions. Failure to do so resulted in creating binaries - that were unable to run with the official ZLIB.DLL build. - - The only possible solution that we could foresee was to make - a binary-incompatible change in the DLL interface, in order to - remove the dependency on the ZLIB_DLL macro, and to release - the new DLL under a different name. - - We chose the name ZLIB1.DLL, where '1' indicates the major - zlib version number. We hope that we will not have to break - the binary compatibility again, at least not as long as the - zlib-1.x series will last. - - There is still a ZLIB_DLL macro, that can trigger a more - efficient build and use of the DLL, but compatibility no - longer dependents on it. - - - 3. Can I build ZLIB.DLL from the new zlib sources, and replace - an old ZLIB.DLL, that was built from zlib-1.1.4 or earlier? - - - In principle, you can do it by assigning calling convention - keywords to the macros ZEXPORT and ZEXPORTVA. In practice, - it depends on what you mean by "an old ZLIB.DLL", because the - old DLL exists in several mutually-incompatible versions. - You have to find out first what kind of calling convention is - being used in your particular ZLIB.DLL build, and to use the - same one in the new build. If you don't know what this is all - about, you might be better off if you would just leave the old - DLL intact. - - - 4. Can I compile my application using the new zlib interface, and - link it to an old ZLIB.DLL, that was built from zlib-1.1.4 or - earlier? - - - The official answer is "no"; the real answer depends again on - what kind of ZLIB.DLL you have. Even if you are lucky, this - course of action is unreliable. - - If you rebuild your application and you intend to use a newer - version of zlib (post- 1.1.4), it is strongly recommended to - link it to the new ZLIB1.DLL. - - - 5. Why are the zlib symbols exported by name, and not by ordinal? - - - Although exporting symbols by ordinal is a little faster, it - is risky. Any single glitch in the maintenance or use of the - DEF file that contains the ordinals can result in incompatible - builds and frustrating crashes. Simply put, the benefits of - exporting symbols by ordinal do not justify the risks. - - Technically, it should be possible to maintain ordinals in - the DEF file, and still export the symbols by name. Ordinals - exist in every DLL, and even if the dynamic linking performed - at the DLL startup is searching for names, ordinals serve as - hints, for a faster name lookup. However, if the DEF file - contains ordinals, the Microsoft linker automatically builds - an implib that will cause the executables linked to it to use - those ordinals, and not the names. It is interesting to - notice that the GNU linker for Win32 does not suffer from this - problem. - - It is possible to avoid the DEF file if the exported symbols - are accompanied by a "__declspec(dllexport)" attribute in the - source files. You can do this in zlib by predefining the - ZLIB_DLL macro. - - - 6. I see that the ZLIB1.DLL functions use the "C" (CDECL) calling - convention. Why not use the STDCALL convention? - STDCALL is the standard convention in Win32, and I need it in - my Visual Basic project! - - (For readability, we use CDECL to refer to the convention - triggered by the "__cdecl" keyword, STDCALL to refer to - the convention triggered by "__stdcall", and FASTCALL to - refer to the convention triggered by "__fastcall".) - - - Most of the native Windows API functions (without varargs) use - indeed the WINAPI convention (which translates to STDCALL in - Win32), but the standard C functions use CDECL. If a user - application is intrinsically tied to the Windows API (e.g. - it calls native Windows API functions such as CreateFile()), - sometimes it makes sense to decorate its own functions with - WINAPI. But if ANSI C or POSIX portability is a goal (e.g. - it calls standard C functions such as fopen()), it is not a - sound decision to request the inclusion of , or to - use non-ANSI constructs, for the sole purpose to make the user - functions STDCALL-able. - - The functionality offered by zlib is not in the category of - "Windows functionality", but is more like "C functionality". - - Technically, STDCALL is not bad; in fact, it is slightly - faster than CDECL, and it works with variable-argument - functions, just like CDECL. It is unfortunate that, in spite - of using STDCALL in the Windows API, it is not the default - convention used by the C compilers that run under Windows. - The roots of the problem reside deep inside the unsafety of - the K&R-style function prototypes, where the argument types - are not specified; but that is another story for another day. - - The remaining fact is that CDECL is the default convention. - Even if an explicit convention is hard-coded into the function - prototypes inside C headers, problems may appear. The - necessity to expose the convention in users' callbacks is one - of these problems. - - The calling convention issues are also important when using - zlib in other programming languages. Some of them, like Ada - (GNAT) and Fortran (GNU G77), have C bindings implemented - initially on Unix, and relying on the C calling convention. - On the other hand, the pre- .NET versions of Microsoft Visual - Basic require STDCALL, while Borland Delphi prefers, although - it does not require, FASTCALL. - - In fairness to all possible uses of zlib outside the C - programming language, we choose the default "C" convention. - Anyone interested in different bindings or conventions is - encouraged to maintain specialized projects. The "contrib/" - directory from the zlib distribution already holds a couple - of foreign bindings, such as Ada, C++, and Delphi. - - - 7. I need a DLL for my Visual Basic project. What can I do? - - - Define the ZLIB_WINAPI macro before including "zlib.h", when - building both the DLL and the user application (except that - you don't need to define anything when using the DLL in Visual - Basic). The ZLIB_WINAPI macro will switch on the WINAPI - (STDCALL) convention. The name of this DLL must be different - than the official ZLIB1.DLL. - - Gilles Vollant has contributed a build named ZLIBWAPI.DLL, - with the ZLIB_WINAPI macro turned on, and with the minizip - functionality built in. For more information, please read - the notes inside "contrib/vstudio/readme.txt", found in the - zlib distribution. - - - 8. I need to use zlib in my Microsoft .NET project. What can I - do? - - - Henrik Ravn has contributed a .NET wrapper around zlib. Look - into contrib/dotzlib/, inside the zlib distribution. - - - 9. If my application uses ZLIB1.DLL, should I link it to - MSVCRT.DLL? Why? - - - It is not required, but it is recommended to link your - application to MSVCRT.DLL, if it uses ZLIB1.DLL. - - The executables (.EXE, .DLL, etc.) that are involved in the - same process and are using the C run-time library (i.e. they - are calling standard C functions), must link to the same - library. There are several libraries in the Win32 system: - CRTDLL.DLL, MSVCRT.DLL, the static C libraries, etc. - Since ZLIB1.DLL is linked to MSVCRT.DLL, the executables that - depend on it should also be linked to MSVCRT.DLL. - - -10. Why are you saying that ZLIB1.DLL and my application should - be linked to the same C run-time (CRT) library? I linked my - application and my DLLs to different C libraries (e.g. my - application to a static library, and my DLLs to MSVCRT.DLL), - and everything works fine. - - - If a user library invokes only pure Win32 API (accessible via - and the related headers), its DLL build will work - in any context. But if this library invokes standard C API, - things get more complicated. - - There is a single Win32 library in a Win32 system. Every - function in this library resides in a single DLL module, that - is safe to call from anywhere. On the other hand, there are - multiple versions of the C library, and each of them has its - own separate internal state. Standalone executables and user - DLLs that call standard C functions must link to a C run-time - (CRT) library, be it static or shared (DLL). Intermixing - occurs when an executable (not necessarily standalone) and a - DLL are linked to different CRTs, and both are running in the - same process. - - Intermixing multiple CRTs is possible, as long as their - internal states are kept intact. The Microsoft Knowledge Base - articles KB94248 "HOWTO: Use the C Run-Time" and KB140584 - "HOWTO: Link with the Correct C Run-Time (CRT) Library" - mention the potential problems raised by intermixing. - - If intermixing works for you, it's because your application - and DLLs are avoiding the corruption of each of the CRTs' - internal states, maybe by careful design, or maybe by fortune. - - Also note that linking ZLIB1.DLL to non-Microsoft CRTs, such - as those provided by Borland, raises similar problems. - - -11. Why are you linking ZLIB1.DLL to MSVCRT.DLL? - - - MSVCRT.DLL exists on every Windows 95 with a new service pack - installed, or with Microsoft Internet Explorer 4 or later, and - on all other Windows 4.x or later (Windows 98, Windows NT 4, - or later). It is freely distributable; if not present in the - system, it can be downloaded from Microsoft or from other - software provider for free. - - The fact that MSVCRT.DLL does not exist on a virgin Windows 95 - is not so problematic. Windows 95 is scarcely found nowadays, - Microsoft ended its support a long time ago, and many recent - applications from various vendors, including Microsoft, do not - even run on it. Furthermore, no serious user should run - Windows 95 without a proper update installed. - - -12. Why are you not linking ZLIB1.DLL to - <> ? - - - We considered and abandoned the following alternatives: - - * Linking ZLIB1.DLL to a static C library (LIBC.LIB, or - LIBCMT.LIB) is not a good option. People are using the DLL - mainly to save disk space. If you are linking your program - to a static C library, you may as well consider linking zlib - in statically, too. - - * Linking ZLIB1.DLL to CRTDLL.DLL looks appealing, because - CRTDLL.DLL is present on every Win32 installation. - Unfortunately, it has a series of problems: it does not - work properly with Microsoft's C++ libraries, it does not - provide support for 64-bit file offsets, (and so on...), - and Microsoft discontinued its support a long time ago. - - * Linking ZLIB1.DLL to MSVCR70.DLL or MSVCR71.DLL, supplied - with the Microsoft .NET platform, and Visual C++ 7.0/7.1, - raises problems related to the status of ZLIB1.DLL as a - system component. According to the Microsoft Knowledge Base - article KB326922 "INFO: Redistribution of the Shared C - Runtime Component in Visual C++ .NET", MSVCR70.DLL and - MSVCR71.DLL are not supposed to function as system DLLs, - because they may clash with MSVCRT.DLL. Instead, the - application's installer is supposed to put these DLLs - (if needed) in the application's private directory. - If ZLIB1.DLL depends on a non-system runtime, it cannot - function as a redistributable system component. - - * Linking ZLIB1.DLL to non-Microsoft runtimes, such as - Borland's, or Cygwin's, raises problems related to the - reliable presence of these runtimes on Win32 systems. - It's easier to let the DLL build of zlib up to the people - who distribute these runtimes, and who may proceed as - explained in the answer to Question 14. - - -13. If ZLIB1.DLL cannot be linked to MSVCR70.DLL or MSVCR71.DLL, - how can I build/use ZLIB1.DLL in Microsoft Visual C++ 7.0 - (Visual Studio .NET) or newer? - - - Due to the problems explained in the Microsoft Knowledge Base - article KB326922 (see the previous answer), the C runtime that - comes with the VC7 environment is no longer considered a - system component. That is, it should not be assumed that this - runtime exists, or may be installed in a system directory. - Since ZLIB1.DLL is supposed to be a system component, it may - not depend on a non-system component. - - In order to link ZLIB1.DLL and your application to MSVCRT.DLL - in VC7, you need the library of Visual C++ 6.0 or older. If - you don't have this library at hand, it's probably best not to - use ZLIB1.DLL. - - We are hoping that, in the future, Microsoft will provide a - way to build applications linked to a proper system runtime, - from the Visual C++ environment. Until then, you have a - couple of alternatives, such as linking zlib in statically. - If your application requires dynamic linking, you may proceed - as explained in the answer to Question 14. - - -14. I need to link my own DLL build to a CRT different than - MSVCRT.DLL. What can I do? - - - Feel free to rebuild the DLL from the zlib sources, and link - it the way you want. You should, however, clearly state that - your build is unofficial. You should give it a different file - name, and/or install it in a private directory that can be - accessed by your application only, and is not visible to the - others (i.e. it's neither in the PATH, nor in the SYSTEM or - SYSTEM32 directories). Otherwise, your build may clash with - applications that link to the official build. - - For example, in Cygwin, zlib is linked to the Cygwin runtime - CYGWIN1.DLL, and it is distributed under the name CYGZ.DLL. - - -15. May I include additional pieces of code that I find useful, - link them in ZLIB1.DLL, and export them? - - - No. A legitimate build of ZLIB1.DLL must not include code - that does not originate from the official zlib source code. - But you can make your own private DLL build, under a different - file name, as suggested in the previous answer. - - For example, zlib is a part of the VCL library, distributed - with Borland Delphi and C++ Builder. The DLL build of VCL - is a redistributable file, named VCLxx.DLL. - - -16. May I remove some functionality out of ZLIB1.DLL, by enabling - macros like NO_GZCOMPRESS or NO_GZIP at compile time? - - - No. A legitimate build of ZLIB1.DLL must provide the complete - zlib functionality, as implemented in the official zlib source - code. But you can make your own private DLL build, under a - different file name, as suggested in the previous answer. - - -17. I made my own ZLIB1.DLL build. Can I test it for compliance? - - - We prefer that you download the official DLL from the zlib - web site. If you need something peculiar from this DLL, you - can send your suggestion to the zlib mailing list. - - However, in case you do rebuild the DLL yourself, you can run - it with the test programs found in the DLL distribution. - Running these test programs is not a guarantee of compliance, - but a failure can imply a detected problem. - -** - -This document is written and maintained by -Cosmin Truta diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/win32/Makefile.bor b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/win32/Makefile.bor deleted file mode 100644 index 4495353..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/win32/Makefile.bor +++ /dev/null @@ -1,109 +0,0 @@ -# Makefile for zlib -# Borland C++ for Win32 -# -# Usage: -# make -f win32/Makefile.bor - -# ------------ Borland C++ ------------ - -# Optional nonstandard preprocessor flags (e.g. -DMAX_MEM_LEVEL=7) -# should be added to the environment via "set LOCAL_ZLIB=-DFOO" or -# added to the declaration of LOC here: -LOC = $(LOCAL_ZLIB) - -CC = bcc32 -AS = bcc32 -LD = bcc32 -AR = tlib -CFLAGS = -a -d -k- -O2 $(LOC) -ASFLAGS = $(LOC) -LDFLAGS = $(LOC) - - -# variables -ZLIB_LIB = zlib.lib - -OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj -OBJ2 = gzwrite.obj infback.obj inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj -#OBJA = -OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzclose.obj+gzlib.obj+gzread.obj -OBJP2 = +gzwrite.obj+infback.obj+inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj -#OBJPA= - - -# targets -all: $(ZLIB_LIB) example.exe minigzip.exe - -.c.obj: - $(CC) -c $(CFLAGS) $< - -.asm.obj: - $(AS) -c $(ASFLAGS) $< - -adler32.obj: adler32.c zlib.h zconf.h - -compress.obj: compress.c zlib.h zconf.h - -crc32.obj: crc32.c zlib.h zconf.h crc32.h - -deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h - -gzclose.obj: gzclose.c zlib.h zconf.h gzguts.h - -gzlib.obj: gzlib.c zlib.h zconf.h gzguts.h - -gzread.obj: gzread.c zlib.h zconf.h gzguts.h - -gzwrite.obj: gzwrite.c zlib.h zconf.h gzguts.h - -infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ - inffast.h inffixed.h - -inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ - inffast.h - -inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ - inffast.h inffixed.h - -inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h - -trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h - -uncompr.obj: uncompr.c zlib.h zconf.h - -zutil.obj: zutil.c zutil.h zlib.h zconf.h - -example.obj: test/example.c zlib.h zconf.h - -minigzip.obj: test/minigzip.c zlib.h zconf.h - - -# For the sake of the old Borland make, -# the command line is cut to fit in the MS-DOS 128 byte limit: -$(ZLIB_LIB): $(OBJ1) $(OBJ2) $(OBJA) - -del $(ZLIB_LIB) - $(AR) $(ZLIB_LIB) $(OBJP1) - $(AR) $(ZLIB_LIB) $(OBJP2) - $(AR) $(ZLIB_LIB) $(OBJPA) - - -# testing -test: example.exe minigzip.exe - example - echo hello world | minigzip | minigzip -d - -example.exe: example.obj $(ZLIB_LIB) - $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB) - -minigzip.exe: minigzip.obj $(ZLIB_LIB) - $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB) - - -# cleanup -clean: - -del $(ZLIB_LIB) - -del *.obj - -del *.exe - -del *.tds - -del zlib.bak - -del foo.gz diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/win32/Makefile.gcc b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/win32/Makefile.gcc deleted file mode 100644 index 081e391..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/win32/Makefile.gcc +++ /dev/null @@ -1,177 +0,0 @@ -# Makefile for zlib, derived from Makefile.dj2. -# Modified for mingw32 by C. Spieler, 6/16/98. -# Updated for zlib 1.2.x by Christian Spieler and Cosmin Truta, Mar-2003. -# Last updated: Mar 2012. -# Tested under Cygwin and MinGW. - -# Copyright (C) 1995-2003 Jean-loup Gailly. -# For conditions of distribution and use, see copyright notice in zlib.h - -# To compile, or to compile and test, type from the top level zlib directory: -# -# make -fwin32/Makefile.gcc; make test testdll -fwin32/Makefile.gcc -# -# To install libz.a, zconf.h and zlib.h in the system directories, type: -# -# make install -fwin32/Makefile.gcc -# -# BINARY_PATH, INCLUDE_PATH and LIBRARY_PATH must be set. -# -# To install the shared lib, append SHARED_MODE=1 to the make command : -# -# make install -fwin32/Makefile.gcc SHARED_MODE=1 - -# Note: -# If the platform is *not* MinGW (e.g. it is Cygwin or UWIN), -# the DLL name should be changed from "zlib1.dll". - -STATICLIB = libz.a -SHAREDLIB = zlib1.dll -IMPLIB = libz.dll.a - -# -# Set to 1 if shared object needs to be installed -# -SHARED_MODE=0 - -#LOC = -DZLIB_DEBUG -g - -PREFIX = -CC = $(PREFIX)gcc -CFLAGS = $(LOC) -O3 -Wall - -AS = $(CC) -ASFLAGS = $(LOC) -Wall - -LD = $(CC) -LDFLAGS = $(LOC) - -AR = $(PREFIX)ar -ARFLAGS = rcs - -RC = $(PREFIX)windres -RCFLAGS = --define GCC_WINDRES - -STRIP = $(PREFIX)strip - -CP = cp -fp -# If GNU install is available, replace $(CP) with install. -INSTALL = $(CP) -RM = rm -f - -prefix ?= /usr/local -exec_prefix = $(prefix) - -OBJS = adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o \ - gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o -OBJA = - -all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) example.exe minigzip.exe example_d.exe minigzip_d.exe - -test: example.exe minigzip.exe - ./example - echo hello world | ./minigzip | ./minigzip -d - -testdll: example_d.exe minigzip_d.exe - ./example_d - echo hello world | ./minigzip_d | ./minigzip_d -d - -.c.o: - $(CC) $(CFLAGS) -c -o $@ $< - -.S.o: - $(AS) $(ASFLAGS) -c -o $@ $< - -$(STATICLIB): $(OBJS) $(OBJA) - $(AR) $(ARFLAGS) $@ $(OBJS) $(OBJA) - -$(IMPLIB): $(SHAREDLIB) - -$(SHAREDLIB): win32/zlib.def $(OBJS) $(OBJA) zlibrc.o - $(CC) -shared -Wl,--out-implib,$(IMPLIB) $(LDFLAGS) \ - -o $@ win32/zlib.def $(OBJS) $(OBJA) zlibrc.o - $(STRIP) $@ - -example.exe: example.o $(STATICLIB) - $(LD) $(LDFLAGS) -o $@ example.o $(STATICLIB) - $(STRIP) $@ - -minigzip.exe: minigzip.o $(STATICLIB) - $(LD) $(LDFLAGS) -o $@ minigzip.o $(STATICLIB) - $(STRIP) $@ - -example_d.exe: example.o $(IMPLIB) - $(LD) $(LDFLAGS) -o $@ example.o $(IMPLIB) - $(STRIP) $@ - -minigzip_d.exe: minigzip.o $(IMPLIB) - $(LD) $(LDFLAGS) -o $@ minigzip.o $(IMPLIB) - $(STRIP) $@ - -example.o: test/example.c zlib.h zconf.h - $(CC) $(CFLAGS) -I. -c -o $@ test/example.c - -minigzip.o: test/minigzip.c zlib.h zconf.h - $(CC) $(CFLAGS) -I. -c -o $@ test/minigzip.c - -zlibrc.o: win32/zlib1.rc - $(RC) $(RCFLAGS) -o $@ win32/zlib1.rc - -.PHONY: install uninstall clean - -install: zlib.h zconf.h $(STATICLIB) $(IMPLIB) - @if test -z "$(DESTDIR)$(INCLUDE_PATH)" -o -z "$(DESTDIR)$(LIBRARY_PATH)" -o -z "$(DESTDIR)$(BINARY_PATH)"; then \ - echo INCLUDE_PATH, LIBRARY_PATH, and BINARY_PATH must be specified; \ - exit 1; \ - fi - -@mkdir -p '$(DESTDIR)$(INCLUDE_PATH)' - -@mkdir -p '$(DESTDIR)$(LIBRARY_PATH)' '$(DESTDIR)$(LIBRARY_PATH)'/pkgconfig - -if [ "$(SHARED_MODE)" = "1" ]; then \ - mkdir -p '$(DESTDIR)$(BINARY_PATH)'; \ - $(INSTALL) $(SHAREDLIB) '$(DESTDIR)$(BINARY_PATH)'; \ - $(INSTALL) $(IMPLIB) '$(DESTDIR)$(LIBRARY_PATH)'; \ - fi - -$(INSTALL) zlib.h '$(DESTDIR)$(INCLUDE_PATH)' - -$(INSTALL) zconf.h '$(DESTDIR)$(INCLUDE_PATH)' - -$(INSTALL) $(STATICLIB) '$(DESTDIR)$(LIBRARY_PATH)' - sed \ - -e 's|@prefix@|${prefix}|g' \ - -e 's|@exec_prefix@|${exec_prefix}|g' \ - -e 's|@libdir@|$(LIBRARY_PATH)|g' \ - -e 's|@sharedlibdir@|$(LIBRARY_PATH)|g' \ - -e 's|@includedir@|$(INCLUDE_PATH)|g' \ - -e 's|@VERSION@|'`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' zlib.h`'|g' \ - zlib.pc.in > '$(DESTDIR)$(LIBRARY_PATH)'/pkgconfig/zlib.pc - -uninstall: - -if [ "$(SHARED_MODE)" = "1" ]; then \ - $(RM) '$(DESTDIR)$(BINARY_PATH)'/$(SHAREDLIB); \ - $(RM) '$(DESTDIR)$(LIBRARY_PATH)'/$(IMPLIB); \ - fi - -$(RM) '$(DESTDIR)$(INCLUDE_PATH)'/zlib.h - -$(RM) '$(DESTDIR)$(INCLUDE_PATH)'/zconf.h - -$(RM) '$(DESTDIR)$(LIBRARY_PATH)'/$(STATICLIB) - -clean: - -$(RM) $(STATICLIB) - -$(RM) $(SHAREDLIB) - -$(RM) $(IMPLIB) - -$(RM) *.o - -$(RM) *.exe - -$(RM) foo.gz - -adler32.o: zlib.h zconf.h -compress.o: zlib.h zconf.h -crc32.o: crc32.h zlib.h zconf.h -deflate.o: deflate.h zutil.h zlib.h zconf.h -gzclose.o: zlib.h zconf.h gzguts.h -gzlib.o: zlib.h zconf.h gzguts.h -gzread.o: zlib.h zconf.h gzguts.h -gzwrite.o: zlib.h zconf.h gzguts.h -inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h -inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h -infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h -inftrees.o: zutil.h zlib.h zconf.h inftrees.h -trees.o: deflate.h zutil.h zlib.h zconf.h trees.h -uncompr.o: zlib.h zconf.h -zutil.o: zutil.h zlib.h zconf.h diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/win32/Makefile.msc b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/win32/Makefile.msc deleted file mode 100644 index 9c65153..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/win32/Makefile.msc +++ /dev/null @@ -1,159 +0,0 @@ -# Makefile for zlib using Microsoft (Visual) C -# zlib is copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler -# -# Usage: -# nmake -f win32/Makefile.msc (standard build) -# nmake -f win32/Makefile.msc LOC=-DFOO (nonstandard build) - -# The toplevel directory of the source tree. -# -TOP = . - -# optional build flags -LOC = - -# variables -STATICLIB = zlib.lib -SHAREDLIB = zlib1.dll -IMPLIB = zdll.lib - -CC = cl -AS = ml -LD = link -AR = lib -RC = rc -CFLAGS = -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" $(LOC) -WFLAGS = -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -ASFLAGS = -coff -Zi $(LOC) -LDFLAGS = -nologo -debug -incremental:no -opt:ref -ARFLAGS = -nologo -RCFLAGS = /dWIN32 /r - -OBJS = adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj \ - gzwrite.obj infback.obj inflate.obj inftrees.obj inffast.obj trees.obj uncompr.obj zutil.obj -OBJA = - - -# targets -all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) \ - example.exe minigzip.exe example_d.exe minigzip_d.exe - -$(STATICLIB): $(OBJS) $(OBJA) - $(AR) $(ARFLAGS) -out:$@ $(OBJS) $(OBJA) - -$(IMPLIB): $(SHAREDLIB) - -$(SHAREDLIB): $(TOP)/win32/zlib.def $(OBJS) $(OBJA) zlib1.res - $(LD) $(LDFLAGS) -def:$(TOP)/win32/zlib.def -dll -implib:$(IMPLIB) \ - -out:$@ -base:0x5A4C0000 $(OBJS) $(OBJA) zlib1.res - if exist $@.manifest \ - mt -nologo -manifest $@.manifest -outputresource:$@;2 - -example.exe: example.obj $(STATICLIB) - $(LD) $(LDFLAGS) example.obj $(STATICLIB) - if exist $@.manifest \ - mt -nologo -manifest $@.manifest -outputresource:$@;1 - -minigzip.exe: minigzip.obj $(STATICLIB) - $(LD) $(LDFLAGS) minigzip.obj $(STATICLIB) - if exist $@.manifest \ - mt -nologo -manifest $@.manifest -outputresource:$@;1 - -example_d.exe: example.obj $(IMPLIB) - $(LD) $(LDFLAGS) -out:$@ example.obj $(IMPLIB) - if exist $@.manifest \ - mt -nologo -manifest $@.manifest -outputresource:$@;1 - -minigzip_d.exe: minigzip.obj $(IMPLIB) - $(LD) $(LDFLAGS) -out:$@ minigzip.obj $(IMPLIB) - if exist $@.manifest \ - mt -nologo -manifest $@.manifest -outputresource:$@;1 - -{$(TOP)}.c.obj: - $(CC) -c $(WFLAGS) $(CFLAGS) $< - -{$(TOP)/test}.c.obj: - $(CC) -c -I$(TOP) $(WFLAGS) $(CFLAGS) $< - -{$(TOP)/contrib/masmx64}.c.obj: - $(CC) -c $(WFLAGS) $(CFLAGS) $< - -{$(TOP)/contrib/masmx64}.asm.obj: - $(AS) -c $(ASFLAGS) $< - -{$(TOP)/contrib/masmx86}.asm.obj: - $(AS) -c $(ASFLAGS) $< - -adler32.obj: $(TOP)/adler32.c $(TOP)/zlib.h $(TOP)/zconf.h - -compress.obj: $(TOP)/compress.c $(TOP)/zlib.h $(TOP)/zconf.h - -crc32.obj: $(TOP)/crc32.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/crc32.h - -deflate.obj: $(TOP)/deflate.c $(TOP)/deflate.h $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h - -gzclose.obj: $(TOP)/gzclose.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h - -gzlib.obj: $(TOP)/gzlib.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h - -gzread.obj: $(TOP)/gzread.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h - -gzwrite.obj: $(TOP)/gzwrite.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h - -infback.obj: $(TOP)/infback.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h $(TOP)/inflate.h \ - $(TOP)/inffast.h $(TOP)/inffixed.h - -inffast.obj: $(TOP)/inffast.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h $(TOP)/inflate.h \ - $(TOP)/inffast.h - -inflate.obj: $(TOP)/inflate.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h $(TOP)/inflate.h \ - $(TOP)/inffast.h $(TOP)/inffixed.h - -inftrees.obj: $(TOP)/inftrees.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h - -trees.obj: $(TOP)/trees.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/deflate.h $(TOP)/trees.h - -uncompr.obj: $(TOP)/uncompr.c $(TOP)/zlib.h $(TOP)/zconf.h - -zutil.obj: $(TOP)/zutil.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h - -gvmat64.obj: $(TOP)/contrib\masmx64\gvmat64.asm - -inffasx64.obj: $(TOP)/contrib\masmx64\inffasx64.asm - -inffas8664.obj: $(TOP)/contrib\masmx64\inffas8664.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h \ - $(TOP)/inftrees.h $(TOP)/inflate.h $(TOP)/inffast.h - -inffas32.obj: $(TOP)/contrib\masmx86\inffas32.asm - -match686.obj: $(TOP)/contrib\masmx86\match686.asm - -example.obj: $(TOP)/test/example.c $(TOP)/zlib.h $(TOP)/zconf.h - -minigzip.obj: $(TOP)/test/minigzip.c $(TOP)/zlib.h $(TOP)/zconf.h - -zlib1.res: $(TOP)/win32/zlib1.rc - $(RC) $(RCFLAGS) /fo$@ $(TOP)/win32/zlib1.rc - -# testing -test: example.exe minigzip.exe - example - echo hello world | minigzip | minigzip -d - -testdll: example_d.exe minigzip_d.exe - example_d - echo hello world | minigzip_d | minigzip_d -d - - -# cleanup -clean: - -del $(STATICLIB) - -del $(SHAREDLIB) - -del $(IMPLIB) - -del *.obj - -del *.res - -del *.exp - -del *.exe - -del *.pdb - -del *.manifest - -del foo.gz diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/win32/README-WIN32.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/win32/README-WIN32.txt deleted file mode 100644 index 536cfec..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/win32/README-WIN32.txt +++ /dev/null @@ -1,103 +0,0 @@ -ZLIB DATA COMPRESSION LIBRARY - -zlib 1.2.12 is a general purpose data compression library. All the code is -thread safe. The data format used by the zlib library is described by RFCs -(Request for Comments) 1950 to 1952 in the files -http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) -and rfc1952.txt (gzip format). - -All functions of the compression library are documented in the file zlib.h -(volunteer to write man pages welcome, contact zlib@gzip.org). Two compiled -examples are distributed in this package, example and minigzip. The example_d -and minigzip_d flavors validate that the zlib1.dll file is working correctly. - -Questions about zlib should be sent to . The zlib home page -is http://zlib.net/ . Before reporting a problem, please check this site to -verify that you have the latest version of zlib; otherwise get the latest -version and check whether the problem still exists or not. - -PLEASE read DLL_FAQ.txt, and the the zlib FAQ http://zlib.net/zlib_faq.html -before asking for help. - - -Manifest: - -The package zlib-1.2.12-win32-x86.zip will contain the following files: - - README-WIN32.txt This document - ChangeLog Changes since previous zlib packages - DLL_FAQ.txt Frequently asked questions about zlib1.dll - zlib.3.pdf Documentation of this library in Adobe Acrobat format - - example.exe A statically-bound example (using zlib.lib, not the dll) - example.pdb Symbolic information for debugging example.exe - - example_d.exe A zlib1.dll bound example (using zdll.lib) - example_d.pdb Symbolic information for debugging example_d.exe - - minigzip.exe A statically-bound test program (using zlib.lib, not the dll) - minigzip.pdb Symbolic information for debugging minigzip.exe - - minigzip_d.exe A zlib1.dll bound test program (using zdll.lib) - minigzip_d.pdb Symbolic information for debugging minigzip_d.exe - - zlib.h Install these files into the compilers' INCLUDE path to - zconf.h compile programs which use zlib.lib or zdll.lib - - zdll.lib Install these files into the compilers' LIB path if linking - zdll.exp a compiled program to the zlib1.dll binary - - zlib.lib Install these files into the compilers' LIB path to link zlib - zlib.pdb into compiled programs, without zlib1.dll runtime dependency - (zlib.pdb provides debugging info to the compile time linker) - - zlib1.dll Install this binary shared library into the system PATH, or - the program's runtime directory (where the .exe resides) - zlib1.pdb Install in the same directory as zlib1.dll, in order to debug - an application crash using WinDbg or similar tools. - -All .pdb files above are entirely optional, but are very useful to a developer -attempting to diagnose program misbehavior or a crash. Many additional -important files for developers can be found in the zlib127.zip source package -available from http://zlib.net/ - review that package's README file for details. - - -Acknowledgments: - -The deflate format used by zlib was defined by Phil Katz. The deflate and -zlib specifications were written by L. Peter Deutsch. Thanks to all the -people who reported problems and suggested various improvements in zlib; they -are too numerous to cite here. - - -Copyright notice: - - (C) 1995-2017 Jean-loup Gailly and Mark Adler - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jean-loup Gailly Mark Adler - jloup@gzip.org madler@alumni.caltech.edu - -If you use the zlib library in a product, we would appreciate *not* receiving -lengthy legal documents to sign. The sources are provided for free but without -warranty of any kind. The library has been entirely written by Jean-loup -Gailly and Mark Adler; it does not include third-party code. - -If you redistribute modified sources, we would appreciate that you include in -the file ChangeLog history information documenting your changes. Please read -the FAQ for more information on the distribution of modified source versions. diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/win32/VisualC.txt b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/win32/VisualC.txt deleted file mode 100644 index 1005b21..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/win32/VisualC.txt +++ /dev/null @@ -1,3 +0,0 @@ - -To build zlib using the Microsoft Visual C++ environment, -use the appropriate project from the contrib/vstudio/ directory. diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/win32/zlib.def b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/win32/zlib.def deleted file mode 100644 index 666bc6f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/win32/zlib.def +++ /dev/null @@ -1,97 +0,0 @@ -; zlib data compression library -EXPORTS -; basic functions - zlibVersion - deflate - deflateEnd - inflate - inflateEnd -; advanced functions - deflateSetDictionary - deflateGetDictionary - deflateCopy - deflateReset - deflateParams - deflateTune - deflateBound - deflatePending - deflatePrime - deflateSetHeader - inflateSetDictionary - inflateGetDictionary - inflateSync - inflateCopy - inflateReset - inflateReset2 - inflatePrime - inflateMark - inflateGetHeader - inflateBack - inflateBackEnd - zlibCompileFlags -; utility functions - compress - compress2 - compressBound - uncompress - uncompress2 - gzopen - gzdopen - gzbuffer - gzsetparams - gzread - gzfread - gzwrite - gzfwrite - gzprintf - gzvprintf - gzputs - gzgets - gzputc - gzgetc - gzungetc - gzflush - gzseek - gzrewind - gztell - gzoffset - gzeof - gzdirect - gzclose - gzclose_r - gzclose_w - gzerror - gzclearerr -; large file functions - gzopen64 - gzseek64 - gztell64 - gzoffset64 - adler32_combine64 - crc32_combine64 - crc32_combine_gen64 -; checksum functions - adler32 - adler32_z - crc32 - crc32_z - adler32_combine - crc32_combine - crc32_combine_gen - crc32_combine_op -; various hacks, don't look :) - deflateInit_ - deflateInit2_ - inflateInit_ - inflateInit2_ - inflateBackInit_ - gzgetc_ - zError - inflateSyncPoint - get_crc_table - inflateUndermine - inflateValidate - inflateCodesUsed - inflateResetKeep - deflateResetKeep - gzopen_w diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/win32/zlib1.rc b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/win32/zlib1.rc deleted file mode 100644 index 234e641..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/win32/zlib1.rc +++ /dev/null @@ -1,40 +0,0 @@ -#include -#include "../zlib.h" - -#ifdef GCC_WINDRES -VS_VERSION_INFO VERSIONINFO -#else -VS_VERSION_INFO VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE -#endif - FILEVERSION ZLIB_VER_MAJOR,ZLIB_VER_MINOR,ZLIB_VER_REVISION,0 - PRODUCTVERSION ZLIB_VER_MAJOR,ZLIB_VER_MINOR,ZLIB_VER_REVISION,0 - FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -#ifdef _DEBUG - FILEFLAGS 1 -#else - FILEFLAGS 0 -#endif - FILEOS VOS__WINDOWS32 - FILETYPE VFT_DLL - FILESUBTYPE 0 // not used -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904E4" - //language ID = U.S. English, char set = Windows, Multilingual - BEGIN - VALUE "FileDescription", "zlib data compression library\0" - VALUE "FileVersion", ZLIB_VERSION "\0" - VALUE "InternalName", "zlib1.dll\0" - VALUE "LegalCopyright", "(C) 1995-2017 Jean-loup Gailly & Mark Adler\0" - VALUE "OriginalFilename", "zlib1.dll\0" - VALUE "ProductName", "zlib\0" - VALUE "ProductVersion", ZLIB_VERSION "\0" - VALUE "Comments", "For more information visit http://www.zlib.net/\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0409, 1252 - END -END diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zconf.h.cmakein b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zconf.h.cmakein deleted file mode 100644 index a7f24cc..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zconf.h.cmakein +++ /dev/null @@ -1,536 +0,0 @@ -/* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#ifndef ZCONF_H -#define ZCONF_H -#cmakedefine Z_PREFIX -#cmakedefine Z_HAVE_UNISTD_H - -/* - * If you *really* need a unique prefix for all types and library functions, - * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. - * Even better than compiling with -DZ_PREFIX would be to use configure to set - * this permanently in zconf.h using "./configure --zprefix". - */ -#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ -# define Z_PREFIX_SET - -/* all linked symbols and init macros */ -# define _dist_code z__dist_code -# define _length_code z__length_code -# define _tr_align z__tr_align -# define _tr_flush_bits z__tr_flush_bits -# define _tr_flush_block z__tr_flush_block -# define _tr_init z__tr_init -# define _tr_stored_block z__tr_stored_block -# define _tr_tally z__tr_tally -# define adler32 z_adler32 -# define adler32_combine z_adler32_combine -# define adler32_combine64 z_adler32_combine64 -# define adler32_z z_adler32_z -# ifndef Z_SOLO -# define compress z_compress -# define compress2 z_compress2 -# define compressBound z_compressBound -# endif -# define crc32 z_crc32 -# define crc32_combine z_crc32_combine -# define crc32_combine64 z_crc32_combine64 -# define crc32_z z_crc32_z -# define deflate z_deflate -# define deflateBound z_deflateBound -# define deflateCopy z_deflateCopy -# define deflateEnd z_deflateEnd -# define deflateGetDictionary z_deflateGetDictionary -# define deflateInit z_deflateInit -# define deflateInit2 z_deflateInit2 -# define deflateInit2_ z_deflateInit2_ -# define deflateInit_ z_deflateInit_ -# define deflateParams z_deflateParams -# define deflatePending z_deflatePending -# define deflatePrime z_deflatePrime -# define deflateReset z_deflateReset -# define deflateResetKeep z_deflateResetKeep -# define deflateSetDictionary z_deflateSetDictionary -# define deflateSetHeader z_deflateSetHeader -# define deflateTune z_deflateTune -# define deflate_copyright z_deflate_copyright -# define get_crc_table z_get_crc_table -# ifndef Z_SOLO -# define gz_error z_gz_error -# define gz_intmax z_gz_intmax -# define gz_strwinerror z_gz_strwinerror -# define gzbuffer z_gzbuffer -# define gzclearerr z_gzclearerr -# define gzclose z_gzclose -# define gzclose_r z_gzclose_r -# define gzclose_w z_gzclose_w -# define gzdirect z_gzdirect -# define gzdopen z_gzdopen -# define gzeof z_gzeof -# define gzerror z_gzerror -# define gzflush z_gzflush -# define gzfread z_gzfread -# define gzfwrite z_gzfwrite -# define gzgetc z_gzgetc -# define gzgetc_ z_gzgetc_ -# define gzgets z_gzgets -# define gzoffset z_gzoffset -# define gzoffset64 z_gzoffset64 -# define gzopen z_gzopen -# define gzopen64 z_gzopen64 -# ifdef _WIN32 -# define gzopen_w z_gzopen_w -# endif -# define gzprintf z_gzprintf -# define gzputc z_gzputc -# define gzputs z_gzputs -# define gzread z_gzread -# define gzrewind z_gzrewind -# define gzseek z_gzseek -# define gzseek64 z_gzseek64 -# define gzsetparams z_gzsetparams -# define gztell z_gztell -# define gztell64 z_gztell64 -# define gzungetc z_gzungetc -# define gzvprintf z_gzvprintf -# define gzwrite z_gzwrite -# endif -# define inflate z_inflate -# define inflateBack z_inflateBack -# define inflateBackEnd z_inflateBackEnd -# define inflateBackInit z_inflateBackInit -# define inflateBackInit_ z_inflateBackInit_ -# define inflateCodesUsed z_inflateCodesUsed -# define inflateCopy z_inflateCopy -# define inflateEnd z_inflateEnd -# define inflateGetDictionary z_inflateGetDictionary -# define inflateGetHeader z_inflateGetHeader -# define inflateInit z_inflateInit -# define inflateInit2 z_inflateInit2 -# define inflateInit2_ z_inflateInit2_ -# define inflateInit_ z_inflateInit_ -# define inflateMark z_inflateMark -# define inflatePrime z_inflatePrime -# define inflateReset z_inflateReset -# define inflateReset2 z_inflateReset2 -# define inflateResetKeep z_inflateResetKeep -# define inflateSetDictionary z_inflateSetDictionary -# define inflateSync z_inflateSync -# define inflateSyncPoint z_inflateSyncPoint -# define inflateUndermine z_inflateUndermine -# define inflateValidate z_inflateValidate -# define inflate_copyright z_inflate_copyright -# define inflate_fast z_inflate_fast -# define inflate_table z_inflate_table -# ifndef Z_SOLO -# define uncompress z_uncompress -# define uncompress2 z_uncompress2 -# endif -# define zError z_zError -# ifndef Z_SOLO -# define zcalloc z_zcalloc -# define zcfree z_zcfree -# endif -# define zlibCompileFlags z_zlibCompileFlags -# define zlibVersion z_zlibVersion - -/* all zlib typedefs in zlib.h and zconf.h */ -# define Byte z_Byte -# define Bytef z_Bytef -# define alloc_func z_alloc_func -# define charf z_charf -# define free_func z_free_func -# ifndef Z_SOLO -# define gzFile z_gzFile -# endif -# define gz_header z_gz_header -# define gz_headerp z_gz_headerp -# define in_func z_in_func -# define intf z_intf -# define out_func z_out_func -# define uInt z_uInt -# define uIntf z_uIntf -# define uLong z_uLong -# define uLongf z_uLongf -# define voidp z_voidp -# define voidpc z_voidpc -# define voidpf z_voidpf - -/* all zlib structs in zlib.h and zconf.h */ -# define gz_header_s z_gz_header_s -# define internal_state z_internal_state - -#endif - -#if defined(__MSDOS__) && !defined(MSDOS) -# define MSDOS -#endif -#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) -# define OS2 -#endif -#if defined(_WINDOWS) && !defined(WINDOWS) -# define WINDOWS -#endif -#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) -# ifndef WIN32 -# define WIN32 -# endif -#endif -#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) -# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) -# ifndef SYS16BIT -# define SYS16BIT -# endif -# endif -#endif - -/* - * Compile with -DMAXSEG_64K if the alloc function cannot allocate more - * than 64k bytes at a time (needed on systems with 16-bit int). - */ -#ifdef SYS16BIT -# define MAXSEG_64K -#endif -#ifdef MSDOS -# define UNALIGNED_OK -#endif - -#ifdef __STDC_VERSION__ -# ifndef STDC -# define STDC -# endif -# if __STDC_VERSION__ >= 199901L -# ifndef STDC99 -# define STDC99 -# endif -# endif -#endif -#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) -# define STDC -#endif -#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) -# define STDC -#endif -#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) -# define STDC -#endif -#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) -# define STDC -#endif - -#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ -# define STDC -#endif - -#ifndef STDC -# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ -# define const /* note: need a more gentle solution here */ -# endif -#endif - -#if defined(ZLIB_CONST) && !defined(z_const) -# define z_const const -#else -# define z_const -#endif - -#ifdef Z_SOLO - typedef unsigned long z_size_t; -#else -# define z_longlong long long -# if defined(NO_SIZE_T) - typedef unsigned NO_SIZE_T z_size_t; -# elif defined(STDC) -# include - typedef size_t z_size_t; -# else - typedef unsigned long z_size_t; -# endif -# undef z_longlong -#endif - -/* Maximum value for memLevel in deflateInit2 */ -#ifndef MAX_MEM_LEVEL -# ifdef MAXSEG_64K -# define MAX_MEM_LEVEL 8 -# else -# define MAX_MEM_LEVEL 9 -# endif -#endif - -/* Maximum value for windowBits in deflateInit2 and inflateInit2. - * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files - * created by gzip. (Files created by minigzip can still be extracted by - * gzip.) - */ -#ifndef MAX_WBITS -# define MAX_WBITS 15 /* 32K LZ77 window */ -#endif - -/* The memory requirements for deflate are (in bytes): - (1 << (windowBits+2)) + (1 << (memLevel+9)) - that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) - plus a few kilobytes for small objects. For example, if you want to reduce - the default memory requirements from 256K to 128K, compile with - make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" - Of course this will generally degrade compression (there's no free lunch). - - The memory requirements for inflate are (in bytes) 1 << windowBits - that is, 32K for windowBits=15 (default value) plus about 7 kilobytes - for small objects. -*/ - - /* Type declarations */ - -#ifndef OF /* function prototypes */ -# ifdef STDC -# define OF(args) args -# else -# define OF(args) () -# endif -#endif - -#ifndef Z_ARG /* function prototypes for stdarg */ -# if defined(STDC) || defined(Z_HAVE_STDARG_H) -# define Z_ARG(args) args -# else -# define Z_ARG(args) () -# endif -#endif - -/* The following definitions for FAR are needed only for MSDOS mixed - * model programming (small or medium model with some far allocations). - * This was tested only with MSC; for other MSDOS compilers you may have - * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, - * just define FAR to be empty. - */ -#ifdef SYS16BIT -# if defined(M_I86SM) || defined(M_I86MM) - /* MSC small or medium model */ -# define SMALL_MEDIUM -# ifdef _MSC_VER -# define FAR _far -# else -# define FAR far -# endif -# endif -# if (defined(__SMALL__) || defined(__MEDIUM__)) - /* Turbo C small or medium model */ -# define SMALL_MEDIUM -# ifdef __BORLANDC__ -# define FAR _far -# else -# define FAR far -# endif -# endif -#endif - -#if defined(WINDOWS) || defined(WIN32) - /* If building or using zlib as a DLL, define ZLIB_DLL. - * This is not mandatory, but it offers a little performance increase. - */ -# ifdef ZLIB_DLL -# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) -# ifdef ZLIB_INTERNAL -# define ZEXTERN extern __declspec(dllexport) -# else -# define ZEXTERN extern __declspec(dllimport) -# endif -# endif -# endif /* ZLIB_DLL */ - /* If building or using zlib with the WINAPI/WINAPIV calling convention, - * define ZLIB_WINAPI. - * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. - */ -# ifdef ZLIB_WINAPI -# ifdef FAR -# undef FAR -# endif -# include - /* No need for _export, use ZLIB.DEF instead. */ - /* For complete Windows compatibility, use WINAPI, not __stdcall. */ -# define ZEXPORT WINAPI -# ifdef WIN32 -# define ZEXPORTVA WINAPIV -# else -# define ZEXPORTVA FAR CDECL -# endif -# endif -#endif - -#if defined (__BEOS__) -# ifdef ZLIB_DLL -# ifdef ZLIB_INTERNAL -# define ZEXPORT __declspec(dllexport) -# define ZEXPORTVA __declspec(dllexport) -# else -# define ZEXPORT __declspec(dllimport) -# define ZEXPORTVA __declspec(dllimport) -# endif -# endif -#endif - -#ifndef ZEXTERN -# define ZEXTERN extern -#endif -#ifndef ZEXPORT -# define ZEXPORT -#endif -#ifndef ZEXPORTVA -# define ZEXPORTVA -#endif - -#ifndef FAR -# define FAR -#endif - -#if !defined(__MACTYPES__) -typedef unsigned char Byte; /* 8 bits */ -#endif -typedef unsigned int uInt; /* 16 bits or more */ -typedef unsigned long uLong; /* 32 bits or more */ - -#ifdef SMALL_MEDIUM - /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ -# define Bytef Byte FAR -#else - typedef Byte FAR Bytef; -#endif -typedef char FAR charf; -typedef int FAR intf; -typedef uInt FAR uIntf; -typedef uLong FAR uLongf; - -#ifdef STDC - typedef void const *voidpc; - typedef void FAR *voidpf; - typedef void *voidp; -#else - typedef Byte const *voidpc; - typedef Byte FAR *voidpf; - typedef Byte *voidp; -#endif - -#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC) -# include -# if (UINT_MAX == 0xffffffffUL) -# define Z_U4 unsigned -# elif (ULONG_MAX == 0xffffffffUL) -# define Z_U4 unsigned long -# elif (USHRT_MAX == 0xffffffffUL) -# define Z_U4 unsigned short -# endif -#endif - -#ifdef Z_U4 - typedef Z_U4 z_crc_t; -#else - typedef unsigned long z_crc_t; -#endif - -#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ -# define Z_HAVE_UNISTD_H -#endif - -#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */ -# define Z_HAVE_STDARG_H -#endif - -#ifdef STDC -# ifndef Z_SOLO -# include /* for off_t */ -# endif -#endif - -#if defined(STDC) || defined(Z_HAVE_STDARG_H) -# ifndef Z_SOLO -# include /* for va_list */ -# endif -#endif - -#ifdef _WIN32 -# ifndef Z_SOLO -# include /* for wchar_t */ -# endif -#endif - -/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and - * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even - * though the former does not conform to the LFS document), but considering - * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as - * equivalently requesting no 64-bit operations - */ -#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 -# undef _LARGEFILE64_SOURCE -#endif - -#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H) -# define Z_HAVE_UNISTD_H -#endif -#ifndef Z_SOLO -# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) -# include /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ -# ifdef VMS -# include /* for off_t */ -# endif -# ifndef z_off_t -# define z_off_t off_t -# endif -# endif -#endif - -#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 -# define Z_LFS64 -#endif - -#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) -# define Z_LARGE64 -#endif - -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) -# define Z_WANT64 -#endif - -#if !defined(SEEK_SET) && !defined(Z_SOLO) -# define SEEK_SET 0 /* Seek from beginning of file. */ -# define SEEK_CUR 1 /* Seek from current position. */ -# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ -#endif - -#ifndef z_off_t -# define z_off_t long -#endif - -#if !defined(_WIN32) && defined(Z_LARGE64) -# define z_off64_t off64_t -#else -# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) -# define z_off64_t __int64 -# else -# define z_off64_t z_off_t -# endif -#endif - -/* MVS linker does not support external names larger than 8 bytes */ -#if defined(__MVS__) - #pragma map(deflateInit_,"DEIN") - #pragma map(deflateInit2_,"DEIN2") - #pragma map(deflateEnd,"DEEND") - #pragma map(deflateBound,"DEBND") - #pragma map(inflateInit_,"ININ") - #pragma map(inflateInit2_,"ININ2") - #pragma map(inflateEnd,"INEND") - #pragma map(inflateSync,"INSY") - #pragma map(inflateSetDictionary,"INSEDI") - #pragma map(compressBound,"CMBND") - #pragma map(inflate_table,"INTABL") - #pragma map(inflate_fast,"INFA") - #pragma map(inflate_copyright,"INCOPY") -#endif - -#endif /* ZCONF_H */ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zconf.h.in b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zconf.h.in deleted file mode 100644 index 5e1d68a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zconf.h.in +++ /dev/null @@ -1,534 +0,0 @@ -/* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#ifndef ZCONF_H -#define ZCONF_H - -/* - * If you *really* need a unique prefix for all types and library functions, - * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. - * Even better than compiling with -DZ_PREFIX would be to use configure to set - * this permanently in zconf.h using "./configure --zprefix". - */ -#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ -# define Z_PREFIX_SET - -/* all linked symbols and init macros */ -# define _dist_code z__dist_code -# define _length_code z__length_code -# define _tr_align z__tr_align -# define _tr_flush_bits z__tr_flush_bits -# define _tr_flush_block z__tr_flush_block -# define _tr_init z__tr_init -# define _tr_stored_block z__tr_stored_block -# define _tr_tally z__tr_tally -# define adler32 z_adler32 -# define adler32_combine z_adler32_combine -# define adler32_combine64 z_adler32_combine64 -# define adler32_z z_adler32_z -# ifndef Z_SOLO -# define compress z_compress -# define compress2 z_compress2 -# define compressBound z_compressBound -# endif -# define crc32 z_crc32 -# define crc32_combine z_crc32_combine -# define crc32_combine64 z_crc32_combine64 -# define crc32_z z_crc32_z -# define deflate z_deflate -# define deflateBound z_deflateBound -# define deflateCopy z_deflateCopy -# define deflateEnd z_deflateEnd -# define deflateGetDictionary z_deflateGetDictionary -# define deflateInit z_deflateInit -# define deflateInit2 z_deflateInit2 -# define deflateInit2_ z_deflateInit2_ -# define deflateInit_ z_deflateInit_ -# define deflateParams z_deflateParams -# define deflatePending z_deflatePending -# define deflatePrime z_deflatePrime -# define deflateReset z_deflateReset -# define deflateResetKeep z_deflateResetKeep -# define deflateSetDictionary z_deflateSetDictionary -# define deflateSetHeader z_deflateSetHeader -# define deflateTune z_deflateTune -# define deflate_copyright z_deflate_copyright -# define get_crc_table z_get_crc_table -# ifndef Z_SOLO -# define gz_error z_gz_error -# define gz_intmax z_gz_intmax -# define gz_strwinerror z_gz_strwinerror -# define gzbuffer z_gzbuffer -# define gzclearerr z_gzclearerr -# define gzclose z_gzclose -# define gzclose_r z_gzclose_r -# define gzclose_w z_gzclose_w -# define gzdirect z_gzdirect -# define gzdopen z_gzdopen -# define gzeof z_gzeof -# define gzerror z_gzerror -# define gzflush z_gzflush -# define gzfread z_gzfread -# define gzfwrite z_gzfwrite -# define gzgetc z_gzgetc -# define gzgetc_ z_gzgetc_ -# define gzgets z_gzgets -# define gzoffset z_gzoffset -# define gzoffset64 z_gzoffset64 -# define gzopen z_gzopen -# define gzopen64 z_gzopen64 -# ifdef _WIN32 -# define gzopen_w z_gzopen_w -# endif -# define gzprintf z_gzprintf -# define gzputc z_gzputc -# define gzputs z_gzputs -# define gzread z_gzread -# define gzrewind z_gzrewind -# define gzseek z_gzseek -# define gzseek64 z_gzseek64 -# define gzsetparams z_gzsetparams -# define gztell z_gztell -# define gztell64 z_gztell64 -# define gzungetc z_gzungetc -# define gzvprintf z_gzvprintf -# define gzwrite z_gzwrite -# endif -# define inflate z_inflate -# define inflateBack z_inflateBack -# define inflateBackEnd z_inflateBackEnd -# define inflateBackInit z_inflateBackInit -# define inflateBackInit_ z_inflateBackInit_ -# define inflateCodesUsed z_inflateCodesUsed -# define inflateCopy z_inflateCopy -# define inflateEnd z_inflateEnd -# define inflateGetDictionary z_inflateGetDictionary -# define inflateGetHeader z_inflateGetHeader -# define inflateInit z_inflateInit -# define inflateInit2 z_inflateInit2 -# define inflateInit2_ z_inflateInit2_ -# define inflateInit_ z_inflateInit_ -# define inflateMark z_inflateMark -# define inflatePrime z_inflatePrime -# define inflateReset z_inflateReset -# define inflateReset2 z_inflateReset2 -# define inflateResetKeep z_inflateResetKeep -# define inflateSetDictionary z_inflateSetDictionary -# define inflateSync z_inflateSync -# define inflateSyncPoint z_inflateSyncPoint -# define inflateUndermine z_inflateUndermine -# define inflateValidate z_inflateValidate -# define inflate_copyright z_inflate_copyright -# define inflate_fast z_inflate_fast -# define inflate_table z_inflate_table -# ifndef Z_SOLO -# define uncompress z_uncompress -# define uncompress2 z_uncompress2 -# endif -# define zError z_zError -# ifndef Z_SOLO -# define zcalloc z_zcalloc -# define zcfree z_zcfree -# endif -# define zlibCompileFlags z_zlibCompileFlags -# define zlibVersion z_zlibVersion - -/* all zlib typedefs in zlib.h and zconf.h */ -# define Byte z_Byte -# define Bytef z_Bytef -# define alloc_func z_alloc_func -# define charf z_charf -# define free_func z_free_func -# ifndef Z_SOLO -# define gzFile z_gzFile -# endif -# define gz_header z_gz_header -# define gz_headerp z_gz_headerp -# define in_func z_in_func -# define intf z_intf -# define out_func z_out_func -# define uInt z_uInt -# define uIntf z_uIntf -# define uLong z_uLong -# define uLongf z_uLongf -# define voidp z_voidp -# define voidpc z_voidpc -# define voidpf z_voidpf - -/* all zlib structs in zlib.h and zconf.h */ -# define gz_header_s z_gz_header_s -# define internal_state z_internal_state - -#endif - -#if defined(__MSDOS__) && !defined(MSDOS) -# define MSDOS -#endif -#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) -# define OS2 -#endif -#if defined(_WINDOWS) && !defined(WINDOWS) -# define WINDOWS -#endif -#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) -# ifndef WIN32 -# define WIN32 -# endif -#endif -#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) -# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) -# ifndef SYS16BIT -# define SYS16BIT -# endif -# endif -#endif - -/* - * Compile with -DMAXSEG_64K if the alloc function cannot allocate more - * than 64k bytes at a time (needed on systems with 16-bit int). - */ -#ifdef SYS16BIT -# define MAXSEG_64K -#endif -#ifdef MSDOS -# define UNALIGNED_OK -#endif - -#ifdef __STDC_VERSION__ -# ifndef STDC -# define STDC -# endif -# if __STDC_VERSION__ >= 199901L -# ifndef STDC99 -# define STDC99 -# endif -# endif -#endif -#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) -# define STDC -#endif -#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) -# define STDC -#endif -#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) -# define STDC -#endif -#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) -# define STDC -#endif - -#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ -# define STDC -#endif - -#ifndef STDC -# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ -# define const /* note: need a more gentle solution here */ -# endif -#endif - -#if defined(ZLIB_CONST) && !defined(z_const) -# define z_const const -#else -# define z_const -#endif - -#ifdef Z_SOLO - typedef unsigned long z_size_t; -#else -# define z_longlong long long -# if defined(NO_SIZE_T) - typedef unsigned NO_SIZE_T z_size_t; -# elif defined(STDC) -# include - typedef size_t z_size_t; -# else - typedef unsigned long z_size_t; -# endif -# undef z_longlong -#endif - -/* Maximum value for memLevel in deflateInit2 */ -#ifndef MAX_MEM_LEVEL -# ifdef MAXSEG_64K -# define MAX_MEM_LEVEL 8 -# else -# define MAX_MEM_LEVEL 9 -# endif -#endif - -/* Maximum value for windowBits in deflateInit2 and inflateInit2. - * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files - * created by gzip. (Files created by minigzip can still be extracted by - * gzip.) - */ -#ifndef MAX_WBITS -# define MAX_WBITS 15 /* 32K LZ77 window */ -#endif - -/* The memory requirements for deflate are (in bytes): - (1 << (windowBits+2)) + (1 << (memLevel+9)) - that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) - plus a few kilobytes for small objects. For example, if you want to reduce - the default memory requirements from 256K to 128K, compile with - make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" - Of course this will generally degrade compression (there's no free lunch). - - The memory requirements for inflate are (in bytes) 1 << windowBits - that is, 32K for windowBits=15 (default value) plus about 7 kilobytes - for small objects. -*/ - - /* Type declarations */ - -#ifndef OF /* function prototypes */ -# ifdef STDC -# define OF(args) args -# else -# define OF(args) () -# endif -#endif - -#ifndef Z_ARG /* function prototypes for stdarg */ -# if defined(STDC) || defined(Z_HAVE_STDARG_H) -# define Z_ARG(args) args -# else -# define Z_ARG(args) () -# endif -#endif - -/* The following definitions for FAR are needed only for MSDOS mixed - * model programming (small or medium model with some far allocations). - * This was tested only with MSC; for other MSDOS compilers you may have - * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, - * just define FAR to be empty. - */ -#ifdef SYS16BIT -# if defined(M_I86SM) || defined(M_I86MM) - /* MSC small or medium model */ -# define SMALL_MEDIUM -# ifdef _MSC_VER -# define FAR _far -# else -# define FAR far -# endif -# endif -# if (defined(__SMALL__) || defined(__MEDIUM__)) - /* Turbo C small or medium model */ -# define SMALL_MEDIUM -# ifdef __BORLANDC__ -# define FAR _far -# else -# define FAR far -# endif -# endif -#endif - -#if defined(WINDOWS) || defined(WIN32) - /* If building or using zlib as a DLL, define ZLIB_DLL. - * This is not mandatory, but it offers a little performance increase. - */ -# ifdef ZLIB_DLL -# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) -# ifdef ZLIB_INTERNAL -# define ZEXTERN extern __declspec(dllexport) -# else -# define ZEXTERN extern __declspec(dllimport) -# endif -# endif -# endif /* ZLIB_DLL */ - /* If building or using zlib with the WINAPI/WINAPIV calling convention, - * define ZLIB_WINAPI. - * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. - */ -# ifdef ZLIB_WINAPI -# ifdef FAR -# undef FAR -# endif -# include - /* No need for _export, use ZLIB.DEF instead. */ - /* For complete Windows compatibility, use WINAPI, not __stdcall. */ -# define ZEXPORT WINAPI -# ifdef WIN32 -# define ZEXPORTVA WINAPIV -# else -# define ZEXPORTVA FAR CDECL -# endif -# endif -#endif - -#if defined (__BEOS__) -# ifdef ZLIB_DLL -# ifdef ZLIB_INTERNAL -# define ZEXPORT __declspec(dllexport) -# define ZEXPORTVA __declspec(dllexport) -# else -# define ZEXPORT __declspec(dllimport) -# define ZEXPORTVA __declspec(dllimport) -# endif -# endif -#endif - -#ifndef ZEXTERN -# define ZEXTERN extern -#endif -#ifndef ZEXPORT -# define ZEXPORT -#endif -#ifndef ZEXPORTVA -# define ZEXPORTVA -#endif - -#ifndef FAR -# define FAR -#endif - -#if !defined(__MACTYPES__) -typedef unsigned char Byte; /* 8 bits */ -#endif -typedef unsigned int uInt; /* 16 bits or more */ -typedef unsigned long uLong; /* 32 bits or more */ - -#ifdef SMALL_MEDIUM - /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ -# define Bytef Byte FAR -#else - typedef Byte FAR Bytef; -#endif -typedef char FAR charf; -typedef int FAR intf; -typedef uInt FAR uIntf; -typedef uLong FAR uLongf; - -#ifdef STDC - typedef void const *voidpc; - typedef void FAR *voidpf; - typedef void *voidp; -#else - typedef Byte const *voidpc; - typedef Byte FAR *voidpf; - typedef Byte *voidp; -#endif - -#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC) -# include -# if (UINT_MAX == 0xffffffffUL) -# define Z_U4 unsigned -# elif (ULONG_MAX == 0xffffffffUL) -# define Z_U4 unsigned long -# elif (USHRT_MAX == 0xffffffffUL) -# define Z_U4 unsigned short -# endif -#endif - -#ifdef Z_U4 - typedef Z_U4 z_crc_t; -#else - typedef unsigned long z_crc_t; -#endif - -#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ -# define Z_HAVE_UNISTD_H -#endif - -#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */ -# define Z_HAVE_STDARG_H -#endif - -#ifdef STDC -# ifndef Z_SOLO -# include /* for off_t */ -# endif -#endif - -#if defined(STDC) || defined(Z_HAVE_STDARG_H) -# ifndef Z_SOLO -# include /* for va_list */ -# endif -#endif - -#ifdef _WIN32 -# ifndef Z_SOLO -# include /* for wchar_t */ -# endif -#endif - -/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and - * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even - * though the former does not conform to the LFS document), but considering - * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as - * equivalently requesting no 64-bit operations - */ -#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 -# undef _LARGEFILE64_SOURCE -#endif - -#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H) -# define Z_HAVE_UNISTD_H -#endif -#ifndef Z_SOLO -# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) -# include /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ -# ifdef VMS -# include /* for off_t */ -# endif -# ifndef z_off_t -# define z_off_t off_t -# endif -# endif -#endif - -#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 -# define Z_LFS64 -#endif - -#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) -# define Z_LARGE64 -#endif - -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) -# define Z_WANT64 -#endif - -#if !defined(SEEK_SET) && !defined(Z_SOLO) -# define SEEK_SET 0 /* Seek from beginning of file. */ -# define SEEK_CUR 1 /* Seek from current position. */ -# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ -#endif - -#ifndef z_off_t -# define z_off_t long -#endif - -#if !defined(_WIN32) && defined(Z_LARGE64) -# define z_off64_t off64_t -#else -# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) -# define z_off64_t __int64 -# else -# define z_off64_t z_off_t -# endif -#endif - -/* MVS linker does not support external names larger than 8 bytes */ -#if defined(__MVS__) - #pragma map(deflateInit_,"DEIN") - #pragma map(deflateInit2_,"DEIN2") - #pragma map(deflateEnd,"DEEND") - #pragma map(deflateBound,"DEBND") - #pragma map(inflateInit_,"ININ") - #pragma map(inflateInit2_,"ININ2") - #pragma map(inflateEnd,"INEND") - #pragma map(inflateSync,"INSY") - #pragma map(inflateSetDictionary,"INSEDI") - #pragma map(compressBound,"CMBND") - #pragma map(inflate_table,"INTABL") - #pragma map(inflate_fast,"INFA") - #pragma map(inflate_copyright,"INCOPY") -#endif - -#endif /* ZCONF_H */ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zconf.h.included b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zconf.h.included deleted file mode 100644 index 5e1d68a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zconf.h.included +++ /dev/null @@ -1,534 +0,0 @@ -/* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#ifndef ZCONF_H -#define ZCONF_H - -/* - * If you *really* need a unique prefix for all types and library functions, - * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. - * Even better than compiling with -DZ_PREFIX would be to use configure to set - * this permanently in zconf.h using "./configure --zprefix". - */ -#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ -# define Z_PREFIX_SET - -/* all linked symbols and init macros */ -# define _dist_code z__dist_code -# define _length_code z__length_code -# define _tr_align z__tr_align -# define _tr_flush_bits z__tr_flush_bits -# define _tr_flush_block z__tr_flush_block -# define _tr_init z__tr_init -# define _tr_stored_block z__tr_stored_block -# define _tr_tally z__tr_tally -# define adler32 z_adler32 -# define adler32_combine z_adler32_combine -# define adler32_combine64 z_adler32_combine64 -# define adler32_z z_adler32_z -# ifndef Z_SOLO -# define compress z_compress -# define compress2 z_compress2 -# define compressBound z_compressBound -# endif -# define crc32 z_crc32 -# define crc32_combine z_crc32_combine -# define crc32_combine64 z_crc32_combine64 -# define crc32_z z_crc32_z -# define deflate z_deflate -# define deflateBound z_deflateBound -# define deflateCopy z_deflateCopy -# define deflateEnd z_deflateEnd -# define deflateGetDictionary z_deflateGetDictionary -# define deflateInit z_deflateInit -# define deflateInit2 z_deflateInit2 -# define deflateInit2_ z_deflateInit2_ -# define deflateInit_ z_deflateInit_ -# define deflateParams z_deflateParams -# define deflatePending z_deflatePending -# define deflatePrime z_deflatePrime -# define deflateReset z_deflateReset -# define deflateResetKeep z_deflateResetKeep -# define deflateSetDictionary z_deflateSetDictionary -# define deflateSetHeader z_deflateSetHeader -# define deflateTune z_deflateTune -# define deflate_copyright z_deflate_copyright -# define get_crc_table z_get_crc_table -# ifndef Z_SOLO -# define gz_error z_gz_error -# define gz_intmax z_gz_intmax -# define gz_strwinerror z_gz_strwinerror -# define gzbuffer z_gzbuffer -# define gzclearerr z_gzclearerr -# define gzclose z_gzclose -# define gzclose_r z_gzclose_r -# define gzclose_w z_gzclose_w -# define gzdirect z_gzdirect -# define gzdopen z_gzdopen -# define gzeof z_gzeof -# define gzerror z_gzerror -# define gzflush z_gzflush -# define gzfread z_gzfread -# define gzfwrite z_gzfwrite -# define gzgetc z_gzgetc -# define gzgetc_ z_gzgetc_ -# define gzgets z_gzgets -# define gzoffset z_gzoffset -# define gzoffset64 z_gzoffset64 -# define gzopen z_gzopen -# define gzopen64 z_gzopen64 -# ifdef _WIN32 -# define gzopen_w z_gzopen_w -# endif -# define gzprintf z_gzprintf -# define gzputc z_gzputc -# define gzputs z_gzputs -# define gzread z_gzread -# define gzrewind z_gzrewind -# define gzseek z_gzseek -# define gzseek64 z_gzseek64 -# define gzsetparams z_gzsetparams -# define gztell z_gztell -# define gztell64 z_gztell64 -# define gzungetc z_gzungetc -# define gzvprintf z_gzvprintf -# define gzwrite z_gzwrite -# endif -# define inflate z_inflate -# define inflateBack z_inflateBack -# define inflateBackEnd z_inflateBackEnd -# define inflateBackInit z_inflateBackInit -# define inflateBackInit_ z_inflateBackInit_ -# define inflateCodesUsed z_inflateCodesUsed -# define inflateCopy z_inflateCopy -# define inflateEnd z_inflateEnd -# define inflateGetDictionary z_inflateGetDictionary -# define inflateGetHeader z_inflateGetHeader -# define inflateInit z_inflateInit -# define inflateInit2 z_inflateInit2 -# define inflateInit2_ z_inflateInit2_ -# define inflateInit_ z_inflateInit_ -# define inflateMark z_inflateMark -# define inflatePrime z_inflatePrime -# define inflateReset z_inflateReset -# define inflateReset2 z_inflateReset2 -# define inflateResetKeep z_inflateResetKeep -# define inflateSetDictionary z_inflateSetDictionary -# define inflateSync z_inflateSync -# define inflateSyncPoint z_inflateSyncPoint -# define inflateUndermine z_inflateUndermine -# define inflateValidate z_inflateValidate -# define inflate_copyright z_inflate_copyright -# define inflate_fast z_inflate_fast -# define inflate_table z_inflate_table -# ifndef Z_SOLO -# define uncompress z_uncompress -# define uncompress2 z_uncompress2 -# endif -# define zError z_zError -# ifndef Z_SOLO -# define zcalloc z_zcalloc -# define zcfree z_zcfree -# endif -# define zlibCompileFlags z_zlibCompileFlags -# define zlibVersion z_zlibVersion - -/* all zlib typedefs in zlib.h and zconf.h */ -# define Byte z_Byte -# define Bytef z_Bytef -# define alloc_func z_alloc_func -# define charf z_charf -# define free_func z_free_func -# ifndef Z_SOLO -# define gzFile z_gzFile -# endif -# define gz_header z_gz_header -# define gz_headerp z_gz_headerp -# define in_func z_in_func -# define intf z_intf -# define out_func z_out_func -# define uInt z_uInt -# define uIntf z_uIntf -# define uLong z_uLong -# define uLongf z_uLongf -# define voidp z_voidp -# define voidpc z_voidpc -# define voidpf z_voidpf - -/* all zlib structs in zlib.h and zconf.h */ -# define gz_header_s z_gz_header_s -# define internal_state z_internal_state - -#endif - -#if defined(__MSDOS__) && !defined(MSDOS) -# define MSDOS -#endif -#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) -# define OS2 -#endif -#if defined(_WINDOWS) && !defined(WINDOWS) -# define WINDOWS -#endif -#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) -# ifndef WIN32 -# define WIN32 -# endif -#endif -#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) -# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) -# ifndef SYS16BIT -# define SYS16BIT -# endif -# endif -#endif - -/* - * Compile with -DMAXSEG_64K if the alloc function cannot allocate more - * than 64k bytes at a time (needed on systems with 16-bit int). - */ -#ifdef SYS16BIT -# define MAXSEG_64K -#endif -#ifdef MSDOS -# define UNALIGNED_OK -#endif - -#ifdef __STDC_VERSION__ -# ifndef STDC -# define STDC -# endif -# if __STDC_VERSION__ >= 199901L -# ifndef STDC99 -# define STDC99 -# endif -# endif -#endif -#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) -# define STDC -#endif -#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) -# define STDC -#endif -#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) -# define STDC -#endif -#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) -# define STDC -#endif - -#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ -# define STDC -#endif - -#ifndef STDC -# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ -# define const /* note: need a more gentle solution here */ -# endif -#endif - -#if defined(ZLIB_CONST) && !defined(z_const) -# define z_const const -#else -# define z_const -#endif - -#ifdef Z_SOLO - typedef unsigned long z_size_t; -#else -# define z_longlong long long -# if defined(NO_SIZE_T) - typedef unsigned NO_SIZE_T z_size_t; -# elif defined(STDC) -# include - typedef size_t z_size_t; -# else - typedef unsigned long z_size_t; -# endif -# undef z_longlong -#endif - -/* Maximum value for memLevel in deflateInit2 */ -#ifndef MAX_MEM_LEVEL -# ifdef MAXSEG_64K -# define MAX_MEM_LEVEL 8 -# else -# define MAX_MEM_LEVEL 9 -# endif -#endif - -/* Maximum value for windowBits in deflateInit2 and inflateInit2. - * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files - * created by gzip. (Files created by minigzip can still be extracted by - * gzip.) - */ -#ifndef MAX_WBITS -# define MAX_WBITS 15 /* 32K LZ77 window */ -#endif - -/* The memory requirements for deflate are (in bytes): - (1 << (windowBits+2)) + (1 << (memLevel+9)) - that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) - plus a few kilobytes for small objects. For example, if you want to reduce - the default memory requirements from 256K to 128K, compile with - make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" - Of course this will generally degrade compression (there's no free lunch). - - The memory requirements for inflate are (in bytes) 1 << windowBits - that is, 32K for windowBits=15 (default value) plus about 7 kilobytes - for small objects. -*/ - - /* Type declarations */ - -#ifndef OF /* function prototypes */ -# ifdef STDC -# define OF(args) args -# else -# define OF(args) () -# endif -#endif - -#ifndef Z_ARG /* function prototypes for stdarg */ -# if defined(STDC) || defined(Z_HAVE_STDARG_H) -# define Z_ARG(args) args -# else -# define Z_ARG(args) () -# endif -#endif - -/* The following definitions for FAR are needed only for MSDOS mixed - * model programming (small or medium model with some far allocations). - * This was tested only with MSC; for other MSDOS compilers you may have - * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, - * just define FAR to be empty. - */ -#ifdef SYS16BIT -# if defined(M_I86SM) || defined(M_I86MM) - /* MSC small or medium model */ -# define SMALL_MEDIUM -# ifdef _MSC_VER -# define FAR _far -# else -# define FAR far -# endif -# endif -# if (defined(__SMALL__) || defined(__MEDIUM__)) - /* Turbo C small or medium model */ -# define SMALL_MEDIUM -# ifdef __BORLANDC__ -# define FAR _far -# else -# define FAR far -# endif -# endif -#endif - -#if defined(WINDOWS) || defined(WIN32) - /* If building or using zlib as a DLL, define ZLIB_DLL. - * This is not mandatory, but it offers a little performance increase. - */ -# ifdef ZLIB_DLL -# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) -# ifdef ZLIB_INTERNAL -# define ZEXTERN extern __declspec(dllexport) -# else -# define ZEXTERN extern __declspec(dllimport) -# endif -# endif -# endif /* ZLIB_DLL */ - /* If building or using zlib with the WINAPI/WINAPIV calling convention, - * define ZLIB_WINAPI. - * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. - */ -# ifdef ZLIB_WINAPI -# ifdef FAR -# undef FAR -# endif -# include - /* No need for _export, use ZLIB.DEF instead. */ - /* For complete Windows compatibility, use WINAPI, not __stdcall. */ -# define ZEXPORT WINAPI -# ifdef WIN32 -# define ZEXPORTVA WINAPIV -# else -# define ZEXPORTVA FAR CDECL -# endif -# endif -#endif - -#if defined (__BEOS__) -# ifdef ZLIB_DLL -# ifdef ZLIB_INTERNAL -# define ZEXPORT __declspec(dllexport) -# define ZEXPORTVA __declspec(dllexport) -# else -# define ZEXPORT __declspec(dllimport) -# define ZEXPORTVA __declspec(dllimport) -# endif -# endif -#endif - -#ifndef ZEXTERN -# define ZEXTERN extern -#endif -#ifndef ZEXPORT -# define ZEXPORT -#endif -#ifndef ZEXPORTVA -# define ZEXPORTVA -#endif - -#ifndef FAR -# define FAR -#endif - -#if !defined(__MACTYPES__) -typedef unsigned char Byte; /* 8 bits */ -#endif -typedef unsigned int uInt; /* 16 bits or more */ -typedef unsigned long uLong; /* 32 bits or more */ - -#ifdef SMALL_MEDIUM - /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ -# define Bytef Byte FAR -#else - typedef Byte FAR Bytef; -#endif -typedef char FAR charf; -typedef int FAR intf; -typedef uInt FAR uIntf; -typedef uLong FAR uLongf; - -#ifdef STDC - typedef void const *voidpc; - typedef void FAR *voidpf; - typedef void *voidp; -#else - typedef Byte const *voidpc; - typedef Byte FAR *voidpf; - typedef Byte *voidp; -#endif - -#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC) -# include -# if (UINT_MAX == 0xffffffffUL) -# define Z_U4 unsigned -# elif (ULONG_MAX == 0xffffffffUL) -# define Z_U4 unsigned long -# elif (USHRT_MAX == 0xffffffffUL) -# define Z_U4 unsigned short -# endif -#endif - -#ifdef Z_U4 - typedef Z_U4 z_crc_t; -#else - typedef unsigned long z_crc_t; -#endif - -#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ -# define Z_HAVE_UNISTD_H -#endif - -#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */ -# define Z_HAVE_STDARG_H -#endif - -#ifdef STDC -# ifndef Z_SOLO -# include /* for off_t */ -# endif -#endif - -#if defined(STDC) || defined(Z_HAVE_STDARG_H) -# ifndef Z_SOLO -# include /* for va_list */ -# endif -#endif - -#ifdef _WIN32 -# ifndef Z_SOLO -# include /* for wchar_t */ -# endif -#endif - -/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and - * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even - * though the former does not conform to the LFS document), but considering - * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as - * equivalently requesting no 64-bit operations - */ -#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 -# undef _LARGEFILE64_SOURCE -#endif - -#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H) -# define Z_HAVE_UNISTD_H -#endif -#ifndef Z_SOLO -# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) -# include /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ -# ifdef VMS -# include /* for off_t */ -# endif -# ifndef z_off_t -# define z_off_t off_t -# endif -# endif -#endif - -#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 -# define Z_LFS64 -#endif - -#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) -# define Z_LARGE64 -#endif - -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) -# define Z_WANT64 -#endif - -#if !defined(SEEK_SET) && !defined(Z_SOLO) -# define SEEK_SET 0 /* Seek from beginning of file. */ -# define SEEK_CUR 1 /* Seek from current position. */ -# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ -#endif - -#ifndef z_off_t -# define z_off_t long -#endif - -#if !defined(_WIN32) && defined(Z_LARGE64) -# define z_off64_t off64_t -#else -# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) -# define z_off64_t __int64 -# else -# define z_off64_t z_off_t -# endif -#endif - -/* MVS linker does not support external names larger than 8 bytes */ -#if defined(__MVS__) - #pragma map(deflateInit_,"DEIN") - #pragma map(deflateInit2_,"DEIN2") - #pragma map(deflateEnd,"DEEND") - #pragma map(deflateBound,"DEBND") - #pragma map(inflateInit_,"ININ") - #pragma map(inflateInit2_,"ININ2") - #pragma map(inflateEnd,"INEND") - #pragma map(inflateSync,"INSY") - #pragma map(inflateSetDictionary,"INSEDI") - #pragma map(compressBound,"CMBND") - #pragma map(inflate_table,"INTABL") - #pragma map(inflate_fast,"INFA") - #pragma map(inflate_copyright,"INCOPY") -#endif - -#endif /* ZCONF_H */ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zlib.3 b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zlib.3 deleted file mode 100644 index bcaebd9..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zlib.3 +++ /dev/null @@ -1,149 +0,0 @@ -.TH ZLIB 3 "27 Mar 2022" -.SH NAME -zlib \- compression/decompression library -.SH SYNOPSIS -[see -.I zlib.h -for full description] -.SH DESCRIPTION -The -.I zlib -library is a general purpose data compression library. -The code is thread safe, assuming that the standard library functions -used are thread safe, such as memory allocation routines. -It provides in-memory compression and decompression functions, -including integrity checks of the uncompressed data. -This version of the library supports only one compression method (deflation) -but other algorithms may be added later -with the same stream interface. -.LP -Compression can be done in a single step if the buffers are large enough -or can be done by repeated calls of the compression function. -In the latter case, -the application must provide more input and/or consume the output -(providing more output space) before each call. -.LP -The library also supports reading and writing files in -.IR gzip (1) -(.gz) format -with an interface similar to that of stdio. -.LP -The library does not install any signal handler. -The decoder checks the consistency of the compressed data, -so the library should never crash even in the case of corrupted input. -.LP -All functions of the compression library are documented in the file -.IR zlib.h . -The distribution source includes examples of use of the library -in the files -.I test/example.c -and -.IR test/minigzip.c, -as well as other examples in the -.IR examples/ -directory. -.LP -Changes to this version are documented in the file -.I ChangeLog -that accompanies the source. -.LP -.I zlib -is built in to many languages and operating systems, including but not limited to -Java, Python, .NET, PHP, Perl, Ruby, Swift, and Go. -.LP -An experimental package to read and write files in the .zip format, -written on top of -.I zlib -by Gilles Vollant (info@winimage.com), -is available at: -.IP -http://www.winimage.com/zLibDll/minizip.html -and also in the -.I contrib/minizip -directory of the main -.I zlib -source distribution. -.SH "SEE ALSO" -The -.I zlib -web site can be found at: -.IP -http://zlib.net/ -.LP -The data format used by the -.I zlib -library is described by RFC -(Request for Comments) 1950 to 1952 in the files: -.IP -http://tools.ietf.org/html/rfc1950 (for the zlib header and trailer format) -.br -http://tools.ietf.org/html/rfc1951 (for the deflate compressed data format) -.br -http://tools.ietf.org/html/rfc1952 (for the gzip header and trailer format) -.LP -Mark Nelson wrote an article about -.I zlib -for the Jan. 1997 issue of Dr. Dobb's Journal; -a copy of the article is available at: -.IP -http://marknelson.us/1997/01/01/zlib-engine/ -.SH "REPORTING PROBLEMS" -Before reporting a problem, -please check the -.I zlib -web site to verify that you have the latest version of -.IR zlib ; -otherwise, -obtain the latest version and see if the problem still exists. -Please read the -.I zlib -FAQ at: -.IP -http://zlib.net/zlib_faq.html -.LP -before asking for help. -Send questions and/or comments to zlib@gzip.org, -or (for the Windows DLL version) to Gilles Vollant (info@winimage.com). -.SH AUTHORS AND LICENSE -Version 1.2.12 -.LP -Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler -.LP -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any damages -arising from the use of this software. -.LP -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it -freely, subject to the following restrictions: -.LP -.nr step 1 1 -.IP \n[step]. 3 -The origin of this software must not be misrepresented; you must not -claim that you wrote the original software. If you use this software -in a product, an acknowledgment in the product documentation would be -appreciated but is not required. -.IP \n+[step]. -Altered source versions must be plainly marked as such, and must not be -misrepresented as being the original software. -.IP \n+[step]. -This notice may not be removed or altered from any source distribution. -.LP -Jean-loup Gailly Mark Adler -.br -jloup@gzip.org madler@alumni.caltech.edu -.LP -The deflate format used by -.I zlib -was defined by Phil Katz. -The deflate and -.I zlib -specifications were written by L. Peter Deutsch. -Thanks to all the people who reported problems and suggested various -improvements in -.IR zlib ; -who are too numerous to cite here. -.LP -UNIX manual page by R. P. C. Rodgers, -U.S. National Library of Medicine (rodgers@nlm.nih.gov). -.\" end of man page diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zlib.3.pdf b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zlib.3.pdf deleted file mode 100644 index 54d677a..0000000 Binary files a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zlib.3.pdf and /dev/null differ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zlib.h b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zlib.h deleted file mode 100644 index 4a98e38..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zlib.h +++ /dev/null @@ -1,1935 +0,0 @@ -/* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.2.12, March 11th, 2022 - - Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jean-loup Gailly Mark Adler - jloup@gzip.org madler@alumni.caltech.edu - - - The data format used by the zlib library is described by RFCs (Request for - Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 - (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format). -*/ - -#ifndef ZLIB_H -#define ZLIB_H - -#include "zconf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define ZLIB_VERSION "1.2.12" -#define ZLIB_VERNUM 0x12c0 -#define ZLIB_VER_MAJOR 1 -#define ZLIB_VER_MINOR 2 -#define ZLIB_VER_REVISION 12 -#define ZLIB_VER_SUBREVISION 0 - -/* - The 'zlib' compression library provides in-memory compression and - decompression functions, including integrity checks of the uncompressed data. - This version of the library supports only one compression method (deflation) - but other algorithms will be added later and will have the same stream - interface. - - Compression can be done in a single step if the buffers are large enough, - or can be done by repeated calls of the compression function. In the latter - case, the application must provide more input and/or consume the output - (providing more output space) before each call. - - The compressed data format used by default by the in-memory functions is - the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped - around a deflate stream, which is itself documented in RFC 1951. - - The library also supports reading and writing files in gzip (.gz) format - with an interface similar to that of stdio using the functions that start - with "gz". The gzip format is different from the zlib format. gzip is a - gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. - - This library can optionally read and write gzip and raw deflate streams in - memory as well. - - The zlib format was designed to be compact and fast for use in memory - and on communications channels. The gzip format was designed for single- - file compression on file systems, has a larger header than zlib to maintain - directory information, and uses a different, slower check method than zlib. - - The library does not install any signal handler. The decoder checks - the consistency of the compressed data, so the library should never crash - even in the case of corrupted input. -*/ - -typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); -typedef void (*free_func) OF((voidpf opaque, voidpf address)); - -struct internal_state; - -typedef struct z_stream_s { - z_const Bytef *next_in; /* next input byte */ - uInt avail_in; /* number of bytes available at next_in */ - uLong total_in; /* total number of input bytes read so far */ - - Bytef *next_out; /* next output byte will go here */ - uInt avail_out; /* remaining free space at next_out */ - uLong total_out; /* total number of bytes output so far */ - - z_const char *msg; /* last error message, NULL if no error */ - struct internal_state FAR *state; /* not visible by applications */ - - alloc_func zalloc; /* used to allocate the internal state */ - free_func zfree; /* used to free the internal state */ - voidpf opaque; /* private data object passed to zalloc and zfree */ - - int data_type; /* best guess about the data type: binary or text - for deflate, or the decoding state for inflate */ - uLong adler; /* Adler-32 or CRC-32 value of the uncompressed data */ - uLong reserved; /* reserved for future use */ -} z_stream; - -typedef z_stream FAR *z_streamp; - -/* - gzip header information passed to and from zlib routines. See RFC 1952 - for more details on the meanings of these fields. -*/ -typedef struct gz_header_s { - int text; /* true if compressed data believed to be text */ - uLong time; /* modification time */ - int xflags; /* extra flags (not used when writing a gzip file) */ - int os; /* operating system */ - Bytef *extra; /* pointer to extra field or Z_NULL if none */ - uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ - uInt extra_max; /* space at extra (only when reading header) */ - Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ - uInt name_max; /* space at name (only when reading header) */ - Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ - uInt comm_max; /* space at comment (only when reading header) */ - int hcrc; /* true if there was or will be a header crc */ - int done; /* true when done reading gzip header (not used - when writing a gzip file) */ -} gz_header; - -typedef gz_header FAR *gz_headerp; - -/* - The application must update next_in and avail_in when avail_in has dropped - to zero. It must update next_out and avail_out when avail_out has dropped - to zero. The application must initialize zalloc, zfree and opaque before - calling the init function. All other fields are set by the compression - library and must not be updated by the application. - - The opaque value provided by the application will be passed as the first - parameter for calls of zalloc and zfree. This can be useful for custom - memory management. The compression library attaches no meaning to the - opaque value. - - zalloc must return Z_NULL if there is not enough memory for the object. - If zlib is used in a multi-threaded application, zalloc and zfree must be - thread safe. In that case, zlib is thread-safe. When zalloc and zfree are - Z_NULL on entry to the initialization function, they are set to internal - routines that use the standard library functions malloc() and free(). - - On 16-bit systems, the functions zalloc and zfree must be able to allocate - exactly 65536 bytes, but will not be required to allocate more than this if - the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers - returned by zalloc for objects of exactly 65536 bytes *must* have their - offset normalized to zero. The default allocation function provided by this - library ensures this (see zutil.c). To reduce memory requirements and avoid - any allocation of 64K objects, at the expense of compression ratio, compile - the library with -DMAX_WBITS=14 (see zconf.h). - - The fields total_in and total_out can be used for statistics or progress - reports. After compression, total_in holds the total size of the - uncompressed data and may be saved for use by the decompressor (particularly - if the decompressor wants to decompress everything in a single step). -*/ - - /* constants */ - -#define Z_NO_FLUSH 0 -#define Z_PARTIAL_FLUSH 1 -#define Z_SYNC_FLUSH 2 -#define Z_FULL_FLUSH 3 -#define Z_FINISH 4 -#define Z_BLOCK 5 -#define Z_TREES 6 -/* Allowed flush values; see deflate() and inflate() below for details */ - -#define Z_OK 0 -#define Z_STREAM_END 1 -#define Z_NEED_DICT 2 -#define Z_ERRNO (-1) -#define Z_STREAM_ERROR (-2) -#define Z_DATA_ERROR (-3) -#define Z_MEM_ERROR (-4) -#define Z_BUF_ERROR (-5) -#define Z_VERSION_ERROR (-6) -/* Return codes for the compression/decompression functions. Negative values - * are errors, positive values are used for special but normal events. - */ - -#define Z_NO_COMPRESSION 0 -#define Z_BEST_SPEED 1 -#define Z_BEST_COMPRESSION 9 -#define Z_DEFAULT_COMPRESSION (-1) -/* compression levels */ - -#define Z_FILTERED 1 -#define Z_HUFFMAN_ONLY 2 -#define Z_RLE 3 -#define Z_FIXED 4 -#define Z_DEFAULT_STRATEGY 0 -/* compression strategy; see deflateInit2() below for details */ - -#define Z_BINARY 0 -#define Z_TEXT 1 -#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ -#define Z_UNKNOWN 2 -/* Possible values of the data_type field for deflate() */ - -#define Z_DEFLATED 8 -/* The deflate compression method (the only one supported in this version) */ - -#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ - -#define zlib_version zlibVersion() -/* for compatibility with versions < 1.0.2 */ - - - /* basic functions */ - -ZEXTERN const char * ZEXPORT zlibVersion OF((void)); -/* The application can compare zlibVersion and ZLIB_VERSION for consistency. - If the first character differs, the library code actually used is not - compatible with the zlib.h header file used by the application. This check - is automatically made by deflateInit and inflateInit. - */ - -/* -ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); - - Initializes the internal stream state for compression. The fields - zalloc, zfree and opaque must be initialized before by the caller. If - zalloc and zfree are set to Z_NULL, deflateInit updates them to use default - allocation functions. - - The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: - 1 gives best speed, 9 gives best compression, 0 gives no compression at all - (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION - requests a default compromise between speed and compression (currently - equivalent to level 6). - - deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if level is not a valid compression level, or - Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible - with the version assumed by the caller (ZLIB_VERSION). msg is set to null - if there is no error message. deflateInit does not perform any compression: - this will be done by deflate(). -*/ - - -ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); -/* - deflate compresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce - some output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. deflate performs one or both of the - following actions: - - - Compress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in and avail_in are updated and - processing will resume at this point for the next call of deflate(). - - - Generate more output starting at next_out and update next_out and avail_out - accordingly. This action is forced if the parameter flush is non zero. - Forcing flush frequently degrades the compression ratio, so this parameter - should be set only when necessary. Some output may be provided even if - flush is zero. - - Before the call of deflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming more - output, and updating avail_in or avail_out accordingly; avail_out should - never be zero before the call. The application can consume the compressed - output when it wants, for example when the output buffer is full (avail_out - == 0), or after each call of deflate(). If deflate returns Z_OK and with - zero avail_out, it must be called again after making room in the output - buffer because there might be more output pending. See deflatePending(), - which can be used if desired to determine whether or not there is more ouput - in that case. - - Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to - decide how much data to accumulate before producing output, in order to - maximize compression. - - If the parameter flush is set to Z_SYNC_FLUSH, all pending output is - flushed to the output buffer and the output is aligned on a byte boundary, so - that the decompressor can get all input data available so far. (In - particular avail_in is zero after the call if enough output space has been - provided before the call.) Flushing may degrade compression for some - compression algorithms and so it should be used only when necessary. This - completes the current deflate block and follows it with an empty stored block - that is three bits plus filler bits to the next byte, followed by four bytes - (00 00 ff ff). - - If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the - output buffer, but the output is not aligned to a byte boundary. All of the - input data so far will be available to the decompressor, as for Z_SYNC_FLUSH. - This completes the current deflate block and follows it with an empty fixed - codes block that is 10 bits long. This assures that enough bytes are output - in order for the decompressor to finish the block before the empty fixed - codes block. - - If flush is set to Z_BLOCK, a deflate block is completed and emitted, as - for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to - seven bits of the current block are held to be written as the next byte after - the next deflate block is completed. In this case, the decompressor may not - be provided enough bits at this point in order to complete decompression of - the data provided so far to the compressor. It may need to wait for the next - block to be emitted. This is for advanced applications that need to control - the emission of deflate blocks. - - If flush is set to Z_FULL_FLUSH, all output is flushed as with - Z_SYNC_FLUSH, and the compression state is reset so that decompression can - restart from this point if previous compressed data has been damaged or if - random access is desired. Using Z_FULL_FLUSH too often can seriously degrade - compression. - - If deflate returns with avail_out == 0, this function must be called again - with the same value of the flush parameter and more output space (updated - avail_out), until the flush is complete (deflate returns with non-zero - avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that - avail_out is greater than six to avoid repeated flush markers due to - avail_out == 0 on return. - - If the parameter flush is set to Z_FINISH, pending input is processed, - pending output is flushed and deflate returns with Z_STREAM_END if there was - enough output space. If deflate returns with Z_OK or Z_BUF_ERROR, this - function must be called again with Z_FINISH and more output space (updated - avail_out) but no more input data, until it returns with Z_STREAM_END or an - error. After deflate has returned Z_STREAM_END, the only possible operations - on the stream are deflateReset or deflateEnd. - - Z_FINISH can be used in the first deflate call after deflateInit if all the - compression is to be done in a single step. In order to complete in one - call, avail_out must be at least the value returned by deflateBound (see - below). Then deflate is guaranteed to return Z_STREAM_END. If not enough - output space is provided, deflate will not return Z_STREAM_END, and it must - be called again as described above. - - deflate() sets strm->adler to the Adler-32 checksum of all input read - so far (that is, total_in bytes). If a gzip stream is being generated, then - strm->adler will be the CRC-32 checksum of the input read so far. (See - deflateInit2 below.) - - deflate() may update strm->data_type if it can make a good guess about - the input data type (Z_BINARY or Z_TEXT). If in doubt, the data is - considered binary. This field is only for information purposes and does not - affect the compression algorithm in any manner. - - deflate() returns Z_OK if some progress has been made (more input - processed or more output produced), Z_STREAM_END if all input has been - consumed and all output has been produced (only when flush is set to - Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example - if next_in or next_out was Z_NULL or the state was inadvertently written over - by the application), or Z_BUF_ERROR if no progress is possible (for example - avail_in or avail_out was zero). Note that Z_BUF_ERROR is not fatal, and - deflate() can be called again with more input and more output space to - continue compressing. -*/ - - -ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any pending - output. - - deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the - stream state was inconsistent, Z_DATA_ERROR if the stream was freed - prematurely (some input or output was discarded). In the error case, msg - may be set but then points to a static string (which must not be - deallocated). -*/ - - -/* -ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); - - Initializes the internal stream state for decompression. The fields - next_in, avail_in, zalloc, zfree and opaque must be initialized before by - the caller. In the current version of inflate, the provided input is not - read or consumed. The allocation of a sliding window will be deferred to - the first call of inflate (if the decompression does not complete on the - first call). If zalloc and zfree are set to Z_NULL, inflateInit updates - them to use default allocation functions. - - inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the - version assumed by the caller, or Z_STREAM_ERROR if the parameters are - invalid, such as a null pointer to the structure. msg is set to null if - there is no error message. inflateInit does not perform any decompression. - Actual decompression will be done by inflate(). So next_in, and avail_in, - next_out, and avail_out are unused and unchanged. The current - implementation of inflateInit() does not process any header information -- - that is deferred until inflate() is called. -*/ - - -ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); -/* - inflate decompresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce - some output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. inflate performs one or both of the - following actions: - - - Decompress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), then next_in and avail_in are updated - accordingly, and processing will resume at this point for the next call of - inflate(). - - - Generate more output starting at next_out and update next_out and avail_out - accordingly. inflate() provides as much output as possible, until there is - no more input data or no more space in the output buffer (see below about - the flush parameter). - - Before the call of inflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming more - output, and updating the next_* and avail_* values accordingly. If the - caller of inflate() does not provide both available input and available - output space, it is possible that there will be no progress made. The - application can consume the uncompressed output when it wants, for example - when the output buffer is full (avail_out == 0), or after each call of - inflate(). If inflate returns Z_OK and with zero avail_out, it must be - called again after making room in the output buffer because there might be - more output pending. - - The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH, - Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much - output as possible to the output buffer. Z_BLOCK requests that inflate() - stop if and when it gets to the next deflate block boundary. When decoding - the zlib or gzip format, this will cause inflate() to return immediately - after the header and before the first block. When doing a raw inflate, - inflate() will go ahead and process the first block, and will return when it - gets to the end of that block, or when it runs out of data. - - The Z_BLOCK option assists in appending to or combining deflate streams. - To assist in this, on return inflate() always sets strm->data_type to the - number of unused bits in the last byte taken from strm->next_in, plus 64 if - inflate() is currently decoding the last block in the deflate stream, plus - 128 if inflate() returned immediately after decoding an end-of-block code or - decoding the complete header up to just before the first byte of the deflate - stream. The end-of-block will not be indicated until all of the uncompressed - data from that block has been written to strm->next_out. The number of - unused bits may in general be greater than seven, except when bit 7 of - data_type is set, in which case the number of unused bits will be less than - eight. data_type is set as noted here every time inflate() returns for all - flush options, and so can be used to determine the amount of currently - consumed input in bits. - - The Z_TREES option behaves as Z_BLOCK does, but it also returns when the - end of each deflate block header is reached, before any actual data in that - block is decoded. This allows the caller to determine the length of the - deflate block header for later use in random access within a deflate block. - 256 is added to the value of strm->data_type when inflate() returns - immediately after reaching the end of the deflate block header. - - inflate() should normally be called until it returns Z_STREAM_END or an - error. However if all decompression is to be performed in a single step (a - single call of inflate), the parameter flush should be set to Z_FINISH. In - this case all pending input is processed and all pending output is flushed; - avail_out must be large enough to hold all of the uncompressed data for the - operation to complete. (The size of the uncompressed data may have been - saved by the compressor for this purpose.) The use of Z_FINISH is not - required to perform an inflation in one step. However it may be used to - inform inflate that a faster approach can be used for the single inflate() - call. Z_FINISH also informs inflate to not maintain a sliding window if the - stream completes, which reduces inflate's memory footprint. If the stream - does not complete, either because not all of the stream is provided or not - enough output space is provided, then a sliding window will be allocated and - inflate() can be called again to continue the operation as if Z_NO_FLUSH had - been used. - - In this implementation, inflate() always flushes as much output as - possible to the output buffer, and always uses the faster approach on the - first call. So the effects of the flush parameter in this implementation are - on the return value of inflate() as noted below, when inflate() returns early - when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of - memory for a sliding window when Z_FINISH is used. - - If a preset dictionary is needed after this call (see inflateSetDictionary - below), inflate sets strm->adler to the Adler-32 checksum of the dictionary - chosen by the compressor and returns Z_NEED_DICT; otherwise it sets - strm->adler to the Adler-32 checksum of all output produced so far (that is, - total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described - below. At the end of the stream, inflate() checks that its computed Adler-32 - checksum is equal to that saved by the compressor and returns Z_STREAM_END - only if the checksum is correct. - - inflate() can decompress and check either zlib-wrapped or gzip-wrapped - deflate data. The header type is detected automatically, if requested when - initializing with inflateInit2(). Any information contained in the gzip - header is not retained unless inflateGetHeader() is used. When processing - gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output - produced so far. The CRC-32 is checked against the gzip trailer, as is the - uncompressed length, modulo 2^32. - - inflate() returns Z_OK if some progress has been made (more input processed - or more output produced), Z_STREAM_END if the end of the compressed data has - been reached and all uncompressed output has been produced, Z_NEED_DICT if a - preset dictionary is needed at this point, Z_DATA_ERROR if the input data was - corrupted (input stream not conforming to the zlib format or incorrect check - value, in which case strm->msg points to a string with a more specific - error), Z_STREAM_ERROR if the stream structure was inconsistent (for example - next_in or next_out was Z_NULL, or the state was inadvertently written over - by the application), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR - if no progress was possible or if there was not enough room in the output - buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and - inflate() can be called again with more input and more output space to - continue decompressing. If Z_DATA_ERROR is returned, the application may - then call inflateSync() to look for a good compression block if a partial - recovery of the data is to be attempted. -*/ - - -ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any pending - output. - - inflateEnd returns Z_OK if success, or Z_STREAM_ERROR if the stream state - was inconsistent. -*/ - - - /* Advanced functions */ - -/* - The following functions are needed only in some special applications. -*/ - -/* -ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, - int level, - int method, - int windowBits, - int memLevel, - int strategy)); - - This is another version of deflateInit with more compression options. The - fields zalloc, zfree and opaque must be initialized before by the caller. - - The method parameter is the compression method. It must be Z_DEFLATED in - this version of the library. - - The windowBits parameter is the base two logarithm of the window size - (the size of the history buffer). It should be in the range 8..15 for this - version of the library. Larger values of this parameter result in better - compression at the expense of memory usage. The default value is 15 if - deflateInit is used instead. - - For the current implementation of deflate(), a windowBits value of 8 (a - window size of 256 bytes) is not supported. As a result, a request for 8 - will result in 9 (a 512-byte window). In that case, providing 8 to - inflateInit2() will result in an error when the zlib header with 9 is - checked against the initialization of inflate(). The remedy is to not use 8 - with deflateInit2() with this initialization, or at least in that case use 9 - with inflateInit2(). - - windowBits can also be -8..-15 for raw deflate. In this case, -windowBits - determines the window size. deflate() will then generate raw deflate data - with no zlib header or trailer, and will not compute a check value. - - windowBits can also be greater than 15 for optional gzip encoding. Add - 16 to windowBits to write a simple gzip header and trailer around the - compressed data instead of a zlib wrapper. The gzip header will have no - file name, no extra data, no comment, no modification time (set to zero), no - header crc, and the operating system will be set to the appropriate value, - if the operating system was determined at compile time. If a gzip stream is - being written, strm->adler is a CRC-32 instead of an Adler-32. - - For raw deflate or gzip encoding, a request for a 256-byte window is - rejected as invalid, since only the zlib header provides a means of - transmitting the window size to the decompressor. - - The memLevel parameter specifies how much memory should be allocated - for the internal compression state. memLevel=1 uses minimum memory but is - slow and reduces compression ratio; memLevel=9 uses maximum memory for - optimal speed. The default value is 8. See zconf.h for total memory usage - as a function of windowBits and memLevel. - - The strategy parameter is used to tune the compression algorithm. Use the - value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a - filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no - string match), or Z_RLE to limit match distances to one (run-length - encoding). Filtered data consists mostly of small values with a somewhat - random distribution. In this case, the compression algorithm is tuned to - compress them better. The effect of Z_FILTERED is to force more Huffman - coding and less string matching; it is somewhat intermediate between - Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as - fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The - strategy parameter only affects the compression ratio but not the - correctness of the compressed output even if it is not set appropriately. - Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler - decoder for special applications. - - deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid - method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is - incompatible with the version assumed by the caller (ZLIB_VERSION). msg is - set to null if there is no error message. deflateInit2 does not perform any - compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the compression dictionary from the given byte sequence - without producing any compressed output. When using the zlib format, this - function must be called immediately after deflateInit, deflateInit2 or - deflateReset, and before any call of deflate. When doing raw deflate, this - function must be called either before any call of deflate, or immediately - after the completion of a deflate block, i.e. after all input has been - consumed and all output has been delivered when using any of the flush - options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH. The - compressor and decompressor must use exactly the same dictionary (see - inflateSetDictionary). - - The dictionary should consist of strings (byte sequences) that are likely - to be encountered later in the data to be compressed, with the most commonly - used strings preferably put towards the end of the dictionary. Using a - dictionary is most useful when the data to be compressed is short and can be - predicted with good accuracy; the data can then be compressed better than - with the default empty dictionary. - - Depending on the size of the compression data structures selected by - deflateInit or deflateInit2, a part of the dictionary may in effect be - discarded, for example if the dictionary is larger than the window size - provided in deflateInit or deflateInit2. Thus the strings most likely to be - useful should be put at the end of the dictionary, not at the front. In - addition, the current implementation of deflate will use at most the window - size minus 262 bytes of the provided dictionary. - - Upon return of this function, strm->adler is set to the Adler-32 value - of the dictionary; the decompressor may later use this value to determine - which dictionary has been used by the compressor. (The Adler-32 value - applies to the whole dictionary even if only a subset of the dictionary is - actually used by the compressor.) If a raw deflate was requested, then the - Adler-32 value is not computed and strm->adler is not set. - - deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a - parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is - inconsistent (for example if deflate has already been called for this stream - or if not at a block boundary for raw deflate). deflateSetDictionary does - not perform any compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm, - Bytef *dictionary, - uInt *dictLength)); -/* - Returns the sliding dictionary being maintained by deflate. dictLength is - set to the number of bytes in the dictionary, and that many bytes are copied - to dictionary. dictionary must have enough space, where 32768 bytes is - always enough. If deflateGetDictionary() is called with dictionary equal to - Z_NULL, then only the dictionary length is returned, and nothing is copied. - Similary, if dictLength is Z_NULL, then it is not set. - - deflateGetDictionary() may return a length less than the window size, even - when more than the window size in input has been provided. It may return up - to 258 bytes less in that case, due to how zlib's implementation of deflate - manages the sliding window and lookahead for matches, where matches can be - up to 258 bytes long. If the application needs the last window-size bytes of - input, then that would need to be saved by the application outside of zlib. - - deflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the - stream state is inconsistent. -*/ - -ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when several compression strategies will be - tried, for example when there are several ways of pre-processing the input - data with a filter. The streams that will be discarded should then be freed - by calling deflateEnd. Note that deflateCopy duplicates the internal - compression state which can be quite large, so this strategy is slow and can - consume lots of memory. - - deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being Z_NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); -/* - This function is equivalent to deflateEnd followed by deflateInit, but - does not free and reallocate the internal compression state. The stream - will leave the compression level and any other attributes that may have been - set unchanged. - - deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being Z_NULL). -*/ - -ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, - int level, - int strategy)); -/* - Dynamically update the compression level and compression strategy. The - interpretation of level and strategy is as in deflateInit2(). This can be - used to switch between compression and straight copy of the input data, or - to switch to a different kind of input data requiring a different strategy. - If the compression approach (which is a function of the level) or the - strategy is changed, and if there have been any deflate() calls since the - state was initialized or reset, then the input available so far is - compressed with the old level and strategy using deflate(strm, Z_BLOCK). - There are three approaches for the compression levels 0, 1..3, and 4..9 - respectively. The new level and strategy will take effect at the next call - of deflate(). - - If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does - not have enough output space to complete, then the parameter change will not - take effect. In this case, deflateParams() can be called again with the - same parameters and more output space to try again. - - In order to assure a change in the parameters on the first try, the - deflate stream should be flushed using deflate() with Z_BLOCK or other flush - request until strm.avail_out is not zero, before calling deflateParams(). - Then no more input data should be provided before the deflateParams() call. - If this is done, the old level and strategy will be applied to the data - compressed before deflateParams(), and the new level and strategy will be - applied to the the data compressed after deflateParams(). - - deflateParams returns Z_OK on success, Z_STREAM_ERROR if the source stream - state was inconsistent or if a parameter was invalid, or Z_BUF_ERROR if - there was not enough output space to complete the compression of the - available input data before a change in the strategy or approach. Note that - in the case of a Z_BUF_ERROR, the parameters are not changed. A return - value of Z_BUF_ERROR is not fatal, in which case deflateParams() can be - retried with more output space. -*/ - -ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, - int good_length, - int max_lazy, - int nice_length, - int max_chain)); -/* - Fine tune deflate's internal compression parameters. This should only be - used by someone who understands the algorithm used by zlib's deflate for - searching for the best matching string, and even then only by the most - fanatic optimizer trying to squeeze out the last compressed bit for their - specific input data. Read the deflate.c source code for the meaning of the - max_lazy, good_length, nice_length, and max_chain parameters. - - deflateTune() can be called after deflateInit() or deflateInit2(), and - returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. - */ - -ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, - uLong sourceLen)); -/* - deflateBound() returns an upper bound on the compressed size after - deflation of sourceLen bytes. It must be called after deflateInit() or - deflateInit2(), and after deflateSetHeader(), if used. This would be used - to allocate an output buffer for deflation in a single pass, and so would be - called before deflate(). If that first deflate() call is provided the - sourceLen input bytes, an output buffer allocated to the size returned by - deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed - to return Z_STREAM_END. Note that it is possible for the compressed size to - be larger than the value returned by deflateBound() if flush options other - than Z_FINISH or Z_NO_FLUSH are used. -*/ - -ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm, - unsigned *pending, - int *bits)); -/* - deflatePending() returns the number of bytes and bits of output that have - been generated, but not yet provided in the available output. The bytes not - provided would be due to the available output space having being consumed. - The number of bits of output not provided are between 0 and 7, where they - await more bits to join them in order to fill out a full byte. If pending - or bits are Z_NULL, then those values are not set. - - deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. - */ - -ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - deflatePrime() inserts bits in the deflate output stream. The intent - is that this function is used to start off the deflate output with the bits - leftover from a previous deflate stream when appending to it. As such, this - function can only be used for raw deflate, and must be used before the first - deflate() call after a deflateInit2() or deflateReset(). bits must be less - than or equal to 16, and that many of the least significant bits of value - will be inserted in the output. - - deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough - room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the - source stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, - gz_headerp head)); -/* - deflateSetHeader() provides gzip header information for when a gzip - stream is requested by deflateInit2(). deflateSetHeader() may be called - after deflateInit2() or deflateReset() and before the first call of - deflate(). The text, time, os, extra field, name, and comment information - in the provided gz_header structure are written to the gzip header (xflag is - ignored -- the extra flags are set according to the compression level). The - caller must assure that, if not Z_NULL, name and comment are terminated with - a zero byte, and that if extra is not Z_NULL, that extra_len bytes are - available there. If hcrc is true, a gzip header crc is included. Note that - the current versions of the command-line version of gzip (up through version - 1.3.x) do not support header crc's, and will report that it is a "multi-part - gzip file" and give up. - - If deflateSetHeader is not used, the default gzip header has text false, - the time set to zero, and os set to 255, with no extra, name, or comment - fields. The gzip header is returned to the default state by deflateReset(). - - deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, - int windowBits)); - - This is another version of inflateInit with an extra parameter. The - fields next_in, avail_in, zalloc, zfree and opaque must be initialized - before by the caller. - - The windowBits parameter is the base two logarithm of the maximum window - size (the size of the history buffer). It should be in the range 8..15 for - this version of the library. The default value is 15 if inflateInit is used - instead. windowBits must be greater than or equal to the windowBits value - provided to deflateInit2() while compressing, or it must be equal to 15 if - deflateInit2() was not used. If a compressed stream with a larger window - size is given as input, inflate() will return with the error code - Z_DATA_ERROR instead of trying to allocate a larger window. - - windowBits can also be zero to request that inflate use the window size in - the zlib header of the compressed stream. - - windowBits can also be -8..-15 for raw inflate. In this case, -windowBits - determines the window size. inflate() will then process raw deflate data, - not looking for a zlib or gzip header, not generating a check value, and not - looking for any check values for comparison at the end of the stream. This - is for use with other formats that use the deflate compressed data format - such as zip. Those formats provide their own check values. If a custom - format is developed using the raw deflate format for compressed data, it is - recommended that a check value such as an Adler-32 or a CRC-32 be applied to - the uncompressed data as is done in the zlib, gzip, and zip formats. For - most applications, the zlib format should be used as is. Note that comments - above on the use in deflateInit2() applies to the magnitude of windowBits. - - windowBits can also be greater than 15 for optional gzip decoding. Add - 32 to windowBits to enable zlib and gzip decoding with automatic header - detection, or add 16 to decode only the gzip format (the zlib format will - return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a - CRC-32 instead of an Adler-32. Unlike the gunzip utility and gzread() (see - below), inflate() will *not* automatically decode concatenated gzip members. - inflate() will return Z_STREAM_END at the end of the gzip member. The state - would need to be reset to continue decoding a subsequent gzip member. This - *must* be done if there is more data after a gzip member, in order for the - decompression to be compliant with the gzip standard (RFC 1952). - - inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the - version assumed by the caller, or Z_STREAM_ERROR if the parameters are - invalid, such as a null pointer to the structure. msg is set to null if - there is no error message. inflateInit2 does not perform any decompression - apart from possibly reading the zlib header if present: actual decompression - will be done by inflate(). (So next_in and avail_in may be modified, but - next_out and avail_out are unused and unchanged.) The current implementation - of inflateInit2() does not process any header information -- that is - deferred until inflate() is called. -*/ - -ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the decompression dictionary from the given uncompressed byte - sequence. This function must be called immediately after a call of inflate, - if that call returned Z_NEED_DICT. The dictionary chosen by the compressor - can be determined from the Adler-32 value returned by that call of inflate. - The compressor and decompressor must use exactly the same dictionary (see - deflateSetDictionary). For raw inflate, this function can be called at any - time to set the dictionary. If the provided dictionary is smaller than the - window and there is already data in the window, then the provided dictionary - will amend what's there. The application must insure that the dictionary - that was used for compression is provided. - - inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a - parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is - inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the - expected one (incorrect Adler-32 value). inflateSetDictionary does not - perform any decompression: this will be done by subsequent calls of - inflate(). -*/ - -ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm, - Bytef *dictionary, - uInt *dictLength)); -/* - Returns the sliding dictionary being maintained by inflate. dictLength is - set to the number of bytes in the dictionary, and that many bytes are copied - to dictionary. dictionary must have enough space, where 32768 bytes is - always enough. If inflateGetDictionary() is called with dictionary equal to - Z_NULL, then only the dictionary length is returned, and nothing is copied. - Similary, if dictLength is Z_NULL, then it is not set. - - inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the - stream state is inconsistent. -*/ - -ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); -/* - Skips invalid compressed data until a possible full flush point (see above - for the description of deflate with Z_FULL_FLUSH) can be found, or until all - available input is skipped. No output is provided. - - inflateSync searches for a 00 00 FF FF pattern in the compressed data. - All full flush points have this pattern, but not all occurrences of this - pattern are full flush points. - - inflateSync returns Z_OK if a possible full flush point has been found, - Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point - has been found, or Z_STREAM_ERROR if the stream structure was inconsistent. - In the success case, the application may save the current current value of - total_in which indicates where valid compressed data was found. In the - error case, the application may repeatedly call inflateSync, providing more - input each time, until success or end of the input data. -*/ - -ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when randomly accessing a large stream. The - first pass through the stream can periodically record the inflate state, - allowing restarting inflate at those points when randomly accessing the - stream. - - inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being Z_NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); -/* - This function is equivalent to inflateEnd followed by inflateInit, - but does not free and reallocate the internal decompression state. The - stream will keep attributes that may have been set by inflateInit2. - - inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being Z_NULL). -*/ - -ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, - int windowBits)); -/* - This function is the same as inflateReset, but it also permits changing - the wrap and window size requests. The windowBits parameter is interpreted - the same as it is for inflateInit2. If the window size is changed, then the - memory allocated for the window is freed, and the window will be reallocated - by inflate() if needed. - - inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being Z_NULL), or if - the windowBits parameter is invalid. -*/ - -ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - This function inserts bits in the inflate input stream. The intent is - that this function is used to start inflating at a bit position in the - middle of a byte. The provided bits will be used before any bytes are used - from next_in. This function should only be used with raw inflate, and - should be used before the first inflate() call after inflateInit2() or - inflateReset(). bits must be less than or equal to 16, and that many of the - least significant bits of value will be inserted in the input. - - If bits is negative, then the input stream bit buffer is emptied. Then - inflatePrime() can be called again to put bits in the buffer. This is used - to clear out bits leftover after feeding inflate a block description prior - to feeding inflate codes. - - inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); -/* - This function returns two values, one in the lower 16 bits of the return - value, and the other in the remaining upper bits, obtained by shifting the - return value down 16 bits. If the upper value is -1 and the lower value is - zero, then inflate() is currently decoding information outside of a block. - If the upper value is -1 and the lower value is non-zero, then inflate is in - the middle of a stored block, with the lower value equaling the number of - bytes from the input remaining to copy. If the upper value is not -1, then - it is the number of bits back from the current bit position in the input of - the code (literal or length/distance pair) currently being processed. In - that case the lower value is the number of bytes already emitted for that - code. - - A code is being processed if inflate is waiting for more input to complete - decoding of the code, or if it has completed decoding but is waiting for - more output space to write the literal or match data. - - inflateMark() is used to mark locations in the input data for random - access, which may be at bit positions, and to note those cases where the - output of a code may span boundaries of random access blocks. The current - location in the input stream can be determined from avail_in and data_type - as noted in the description for the Z_BLOCK flush parameter for inflate. - - inflateMark returns the value noted above, or -65536 if the provided - source stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, - gz_headerp head)); -/* - inflateGetHeader() requests that gzip header information be stored in the - provided gz_header structure. inflateGetHeader() may be called after - inflateInit2() or inflateReset(), and before the first call of inflate(). - As inflate() processes the gzip stream, head->done is zero until the header - is completed, at which time head->done is set to one. If a zlib stream is - being decoded, then head->done is set to -1 to indicate that there will be - no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be - used to force inflate() to return immediately after header processing is - complete and before any actual data is decompressed. - - The text, time, xflags, and os fields are filled in with the gzip header - contents. hcrc is set to true if there is a header CRC. (The header CRC - was valid if done is set to one.) If extra is not Z_NULL, then extra_max - contains the maximum number of bytes to write to extra. Once done is true, - extra_len contains the actual extra field length, and extra contains the - extra field, or that field truncated if extra_max is less than extra_len. - If name is not Z_NULL, then up to name_max characters are written there, - terminated with a zero unless the length is greater than name_max. If - comment is not Z_NULL, then up to comm_max characters are written there, - terminated with a zero unless the length is greater than comm_max. When any - of extra, name, or comment are not Z_NULL and the respective field is not - present in the header, then that field is set to Z_NULL to signal its - absence. This allows the use of deflateSetHeader() with the returned - structure to duplicate the header. However if those fields are set to - allocated memory, then the application will need to save those pointers - elsewhere so that they can be eventually freed. - - If inflateGetHeader is not used, then the header information is simply - discarded. The header is always checked for validity, including the header - CRC if present. inflateReset() will reset the process to discard the header - information. The application would need to call inflateGetHeader() again to - retrieve the header from the next gzip stream. - - inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, - unsigned char FAR *window)); - - Initialize the internal stream state for decompression using inflateBack() - calls. The fields zalloc, zfree and opaque in strm must be initialized - before the call. If zalloc and zfree are Z_NULL, then the default library- - derived memory allocation routines are used. windowBits is the base two - logarithm of the window size, in the range 8..15. window is a caller - supplied buffer of that size. Except for special applications where it is - assured that deflate was used with small window sizes, windowBits must be 15 - and a 32K byte window must be supplied to be able to decompress general - deflate streams. - - See inflateBack() for the usage of these routines. - - inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of - the parameters are invalid, Z_MEM_ERROR if the internal state could not be - allocated, or Z_VERSION_ERROR if the version of the library does not match - the version of the header file. -*/ - -typedef unsigned (*in_func) OF((void FAR *, - z_const unsigned char FAR * FAR *)); -typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); - -ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, - in_func in, void FAR *in_desc, - out_func out, void FAR *out_desc)); -/* - inflateBack() does a raw inflate with a single call using a call-back - interface for input and output. This is potentially more efficient than - inflate() for file i/o applications, in that it avoids copying between the - output and the sliding window by simply making the window itself the output - buffer. inflate() can be faster on modern CPUs when used with large - buffers. inflateBack() trusts the application to not change the output - buffer passed by the output function, at least until inflateBack() returns. - - inflateBackInit() must be called first to allocate the internal state - and to initialize the state with the user-provided window buffer. - inflateBack() may then be used multiple times to inflate a complete, raw - deflate stream with each call. inflateBackEnd() is then called to free the - allocated state. - - A raw deflate stream is one with no zlib or gzip header or trailer. - This routine would normally be used in a utility that reads zip or gzip - files and writes out uncompressed files. The utility would decode the - header and process the trailer on its own, hence this routine expects only - the raw deflate stream to decompress. This is different from the default - behavior of inflate(), which expects a zlib header and trailer around the - deflate stream. - - inflateBack() uses two subroutines supplied by the caller that are then - called by inflateBack() for input and output. inflateBack() calls those - routines until it reads a complete deflate stream and writes out all of the - uncompressed data, or until it encounters an error. The function's - parameters and return types are defined above in the in_func and out_func - typedefs. inflateBack() will call in(in_desc, &buf) which should return the - number of bytes of provided input, and a pointer to that input in buf. If - there is no input available, in() must return zero -- buf is ignored in that - case -- and inflateBack() will return a buffer error. inflateBack() will - call out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. - out() should return zero on success, or non-zero on failure. If out() - returns non-zero, inflateBack() will return with an error. Neither in() nor - out() are permitted to change the contents of the window provided to - inflateBackInit(), which is also the buffer that out() uses to write from. - The length written by out() will be at most the window size. Any non-zero - amount of input may be provided by in(). - - For convenience, inflateBack() can be provided input on the first call by - setting strm->next_in and strm->avail_in. If that input is exhausted, then - in() will be called. Therefore strm->next_in must be initialized before - calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called - immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in - must also be initialized, and then if strm->avail_in is not zero, input will - initially be taken from strm->next_in[0 .. strm->avail_in - 1]. - - The in_desc and out_desc parameters of inflateBack() is passed as the - first parameter of in() and out() respectively when they are called. These - descriptors can be optionally used to pass any information that the caller- - supplied in() and out() functions need to do their job. - - On return, inflateBack() will set strm->next_in and strm->avail_in to - pass back any unused input that was provided by the last in() call. The - return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR - if in() or out() returned an error, Z_DATA_ERROR if there was a format error - in the deflate stream (in which case strm->msg is set to indicate the nature - of the error), or Z_STREAM_ERROR if the stream was not properly initialized. - In the case of Z_BUF_ERROR, an input or output error can be distinguished - using strm->next_in which will be Z_NULL only if in() returned an error. If - strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning - non-zero. (in() will always be called before out(), so strm->next_in is - assured to be defined if out() returns non-zero.) Note that inflateBack() - cannot return Z_OK. -*/ - -ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); -/* - All memory allocated by inflateBackInit() is freed. - - inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream - state was inconsistent. -*/ - -ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); -/* Return flags indicating compile-time options. - - Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: - 1.0: size of uInt - 3.2: size of uLong - 5.4: size of voidpf (pointer) - 7.6: size of z_off_t - - Compiler, assembler, and debug options: - 8: ZLIB_DEBUG - 9: ASMV or ASMINF -- use ASM code - 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention - 11: 0 (reserved) - - One-time table building (smaller code, but not thread-safe if true): - 12: BUILDFIXED -- build static block decoding tables when needed - 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed - 14,15: 0 (reserved) - - Library content (indicates missing functionality): - 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking - deflate code when not needed) - 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect - and decode gzip streams (to avoid linking crc code) - 18-19: 0 (reserved) - - Operation variations (changes in library functionality): - 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate - 21: FASTEST -- deflate algorithm with only one, lowest compression level - 22,23: 0 (reserved) - - The sprintf variant used by gzprintf (zero is best): - 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format - 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! - 26: 0 = returns value, 1 = void -- 1 means inferred string length returned - - Remainder: - 27-31: 0 (reserved) - */ - -#ifndef Z_SOLO - - /* utility functions */ - -/* - The following utility functions are implemented on top of the basic - stream-oriented functions. To simplify the interface, some default options - are assumed (compression level and memory usage, standard memory allocation - functions). The source code of these utility functions can be modified if - you need special options. -*/ - -ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Compresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total size - of the destination buffer, which must be at least the value returned by - compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed data. compress() is equivalent to compress2() with a level - parameter of Z_DEFAULT_COMPRESSION. - - compress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer. -*/ - -ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen, - int level)); -/* - Compresses the source buffer into the destination buffer. The level - parameter has the same meaning as in deflateInit. sourceLen is the byte - length of the source buffer. Upon entry, destLen is the total size of the - destination buffer, which must be at least the value returned by - compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed data. - - compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_BUF_ERROR if there was not enough room in the output buffer, - Z_STREAM_ERROR if the level parameter is invalid. -*/ - -ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); -/* - compressBound() returns an upper bound on the compressed size after - compress() or compress2() on sourceLen bytes. It would be used before a - compress() or compress2() call to allocate the destination buffer. -*/ - -ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Decompresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total size - of the destination buffer, which must be large enough to hold the entire - uncompressed data. (The size of the uncompressed data must have been saved - previously by the compressor and transmitted to the decompressor by some - mechanism outside the scope of this compression library.) Upon exit, destLen - is the actual size of the uncompressed data. - - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In - the case where there is not enough room, uncompress() will fill the output - buffer with the uncompressed data up to that point. -*/ - -ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong *sourceLen)); -/* - Same as uncompress, except that sourceLen is a pointer, where the - length of the source is *sourceLen. On return, *sourceLen is the number of - source bytes consumed. -*/ - - /* gzip file access functions */ - -/* - This library supports reading and writing files in gzip (.gz) format with - an interface similar to that of stdio, using the functions that start with - "gz". The gzip format is different from the zlib format. gzip is a gzip - wrapper, documented in RFC 1952, wrapped around a deflate stream. -*/ - -typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ - -/* -ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); - - Open the gzip (.gz) file at path for reading and decompressing, or - compressing and writing. The mode parameter is as in fopen ("rb" or "wb") - but can also include a compression level ("wb9") or a strategy: 'f' for - filtered data as in "wb6f", 'h' for Huffman-only compression as in "wb1h", - 'R' for run-length encoding as in "wb1R", or 'F' for fixed code compression - as in "wb9F". (See the description of deflateInit2 for more information - about the strategy parameter.) 'T' will request transparent writing or - appending with no compression and not using the gzip format. - - "a" can be used instead of "w" to request that the gzip stream that will - be written be appended to the file. "+" will result in an error, since - reading and writing to the same gzip file is not supported. The addition of - "x" when writing will create the file exclusively, which fails if the file - already exists. On systems that support it, the addition of "e" when - reading or writing will set the flag to close the file on an execve() call. - - These functions, as well as gzip, will read and decode a sequence of gzip - streams in a file. The append function of gzopen() can be used to create - such a file. (Also see gzflush() for another way to do this.) When - appending, gzopen does not test whether the file begins with a gzip stream, - nor does it look for the end of the gzip streams to begin appending. gzopen - will simply append a gzip stream to the existing file. - - gzopen can be used to read a file which is not in gzip format; in this - case gzread will directly read from the file without decompression. When - reading, this will be detected automatically by looking for the magic two- - byte gzip header. - - gzopen returns NULL if the file could not be opened, if there was - insufficient memory to allocate the gzFile state, or if an invalid mode was - specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). - errno can be checked to determine if the reason gzopen failed was that the - file could not be opened. -*/ - -ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); -/* - Associate a gzFile with the file descriptor fd. File descriptors are - obtained from calls like open, dup, creat, pipe or fileno (if the file has - been previously opened with fopen). The mode parameter is as in gzopen. - - The next call of gzclose on the returned gzFile will also close the file - descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor - fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd, - mode);. The duplicated descriptor should be saved to avoid a leak, since - gzdopen does not close fd if it fails. If you are using fileno() to get the - file descriptor from a FILE *, then you will have to use dup() to avoid - double-close()ing the file descriptor. Both gzclose() and fclose() will - close the associated file descriptor, so they need to have different file - descriptors. - - gzdopen returns NULL if there was insufficient memory to allocate the - gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not - provided, or '+' was provided), or if fd is -1. The file descriptor is not - used until the next gz* read, write, seek, or close operation, so gzdopen - will not detect if fd is invalid (unless fd is -1). -*/ - -ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); -/* - Set the internal buffer size used by this library's functions for file to - size. The default buffer size is 8192 bytes. This function must be called - after gzopen() or gzdopen(), and before any other calls that read or write - the file. The buffer memory allocation is always deferred to the first read - or write. Three times that size in buffer space is allocated. A larger - buffer size of, for example, 64K or 128K bytes will noticeably increase the - speed of decompression (reading). - - The new buffer size also affects the maximum length for gzprintf(). - - gzbuffer() returns 0 on success, or -1 on failure, such as being called - too late. -*/ - -ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); -/* - Dynamically update the compression level and strategy for file. See the - description of deflateInit2 for the meaning of these parameters. Previously - provided data is flushed before applying the parameter changes. - - gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not - opened for writing, Z_ERRNO if there is an error writing the flushed data, - or Z_MEM_ERROR if there is a memory allocation error. -*/ - -ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); -/* - Read and decompress up to len uncompressed bytes from file into buf. If - the input file is not in gzip format, gzread copies the given number of - bytes into the buffer directly from the file. - - After reaching the end of a gzip stream in the input, gzread will continue - to read, looking for another gzip stream. Any number of gzip streams may be - concatenated in the input file, and will all be decompressed by gzread(). - If something other than a gzip stream is encountered after a gzip stream, - that remaining trailing garbage is ignored (and no error is returned). - - gzread can be used to read a gzip file that is being concurrently written. - Upon reaching the end of the input, gzread will return with the available - data. If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then - gzclearerr can be used to clear the end of file indicator in order to permit - gzread to be tried again. Z_OK indicates that a gzip stream was completed - on the last gzread. Z_BUF_ERROR indicates that the input file ended in the - middle of a gzip stream. Note that gzread does not return -1 in the event - of an incomplete gzip stream. This error is deferred until gzclose(), which - will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip - stream. Alternatively, gzerror can be used before gzclose to detect this - case. - - gzread returns the number of uncompressed bytes actually read, less than - len for end of file, or -1 for error. If len is too large to fit in an int, - then nothing is read, -1 is returned, and the error state is set to - Z_STREAM_ERROR. -*/ - -ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems, - gzFile file)); -/* - Read and decompress up to nitems items of size size from file into buf, - otherwise operating as gzread() does. This duplicates the interface of - stdio's fread(), with size_t request and return types. If the library - defines size_t, then z_size_t is identical to size_t. If not, then z_size_t - is an unsigned integer type that can contain a pointer. - - gzfread() returns the number of full items read of size size, or zero if - the end of the file was reached and a full item could not be read, or if - there was an error. gzerror() must be consulted if zero is returned in - order to determine if there was an error. If the multiplication of size and - nitems overflows, i.e. the product does not fit in a z_size_t, then nothing - is read, zero is returned, and the error state is set to Z_STREAM_ERROR. - - In the event that the end of file is reached and only a partial item is - available at the end, i.e. the remaining uncompressed data length is not a - multiple of size, then the final partial item is nevetheless read into buf - and the end-of-file flag is set. The length of the partial item read is not - provided, but could be inferred from the result of gztell(). This behavior - is the same as the behavior of fread() implementations in common libraries, - but it prevents the direct use of gzfread() to read a concurrently written - file, reseting and retrying on end-of-file, when size is not 1. -*/ - -ZEXTERN int ZEXPORT gzwrite OF((gzFile file, voidpc buf, unsigned len)); -/* - Compress and write the len uncompressed bytes at buf to file. gzwrite - returns the number of uncompressed bytes written or 0 in case of error. -*/ - -ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size, - z_size_t nitems, gzFile file)); -/* - Compress and write nitems items of size size from buf to file, duplicating - the interface of stdio's fwrite(), with size_t request and return types. If - the library defines size_t, then z_size_t is identical to size_t. If not, - then z_size_t is an unsigned integer type that can contain a pointer. - - gzfwrite() returns the number of full items written of size size, or zero - if there was an error. If the multiplication of size and nitems overflows, - i.e. the product does not fit in a z_size_t, then nothing is written, zero - is returned, and the error state is set to Z_STREAM_ERROR. -*/ - -ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...)); -/* - Convert, format, compress, and write the arguments (...) to file under - control of the string format, as in fprintf. gzprintf returns the number of - uncompressed bytes actually written, or a negative zlib error code in case - of error. The number of uncompressed bytes written is limited to 8191, or - one less than the buffer size given to gzbuffer(). The caller should assure - that this limit is not exceeded. If it is exceeded, then gzprintf() will - return an error (0) with nothing written. In this case, there may also be a - buffer overflow with unpredictable consequences, which is possible only if - zlib was compiled with the insecure functions sprintf() or vsprintf(), - because the secure snprintf() or vsnprintf() functions were not available. - This can be determined using zlibCompileFlags(). -*/ - -ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); -/* - Compress and write the given null-terminated string s to file, excluding - the terminating null character. - - gzputs returns the number of characters written, or -1 in case of error. -*/ - -ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); -/* - Read and decompress bytes from file into buf, until len-1 characters are - read, or until a newline character is read and transferred to buf, or an - end-of-file condition is encountered. If any characters are read or if len - is one, the string is terminated with a null character. If no characters - are read due to an end-of-file or len is less than one, then the buffer is - left untouched. - - gzgets returns buf which is a null-terminated string, or it returns NULL - for end-of-file or in case of error. If there was an error, the contents at - buf are indeterminate. -*/ - -ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); -/* - Compress and write c, converted to an unsigned char, into file. gzputc - returns the value that was written, or -1 in case of error. -*/ - -ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); -/* - Read and decompress one byte from file. gzgetc returns this byte or -1 - in case of end of file or error. This is implemented as a macro for speed. - As such, it does not do all of the checking the other functions do. I.e. - it does not check to see if file is NULL, nor whether the structure file - points to has been clobbered or not. -*/ - -ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); -/* - Push c back onto the stream for file to be read as the first character on - the next read. At least one character of push-back is always allowed. - gzungetc() returns the character pushed, or -1 on failure. gzungetc() will - fail if c is -1, and may fail if a character has been pushed but not read - yet. If gzungetc is used immediately after gzopen or gzdopen, at least the - output buffer size of pushed characters is allowed. (See gzbuffer above.) - The pushed character will be discarded if the stream is repositioned with - gzseek() or gzrewind(). -*/ - -ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); -/* - Flush all pending output to file. The parameter flush is as in the - deflate() function. The return value is the zlib error number (see function - gzerror below). gzflush is only permitted when writing. - - If the flush parameter is Z_FINISH, the remaining data is written and the - gzip stream is completed in the output. If gzwrite() is called again, a new - gzip stream will be started in the output. gzread() is able to read such - concatenated gzip streams. - - gzflush should be called only when strictly necessary because it will - degrade compression if called too often. -*/ - -/* -ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, - z_off_t offset, int whence)); - - Set the starting position to offset relative to whence for the next gzread - or gzwrite on file. The offset represents a number of bytes in the - uncompressed data stream. The whence parameter is defined as in lseek(2); - the value SEEK_END is not supported. - - If the file is opened for reading, this function is emulated but can be - extremely slow. If the file is opened for writing, only forward seeks are - supported; gzseek then compresses a sequence of zeroes up to the new - starting position. - - gzseek returns the resulting offset location as measured in bytes from - the beginning of the uncompressed stream, or -1 in case of error, in - particular if the file is opened for writing and the new starting position - would be before the current position. -*/ - -ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); -/* - Rewind file. This function is supported only for reading. - - gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET). -*/ - -/* -ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); - - Return the starting position for the next gzread or gzwrite on file. - This position represents a number of bytes in the uncompressed data stream, - and is zero when starting, even if appending or reading a gzip stream from - the middle of a file using gzdopen(). - - gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) -*/ - -/* -ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); - - Return the current compressed (actual) read or write offset of file. This - offset includes the count of bytes that precede the gzip stream, for example - when appending or when using gzdopen() for reading. When reading, the - offset does not include as yet unused buffered input. This information can - be used for a progress indicator. On error, gzoffset() returns -1. -*/ - -ZEXTERN int ZEXPORT gzeof OF((gzFile file)); -/* - Return true (1) if the end-of-file indicator for file has been set while - reading, false (0) otherwise. Note that the end-of-file indicator is set - only if the read tried to go past the end of the input, but came up short. - Therefore, just like feof(), gzeof() may return false even if there is no - more data to read, in the event that the last read request was for the exact - number of bytes remaining in the input file. This will happen if the input - file size is an exact multiple of the buffer size. - - If gzeof() returns true, then the read functions will return no more data, - unless the end-of-file indicator is reset by gzclearerr() and the input file - has grown since the previous end of file was detected. -*/ - -ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); -/* - Return true (1) if file is being copied directly while reading, or false - (0) if file is a gzip stream being decompressed. - - If the input file is empty, gzdirect() will return true, since the input - does not contain a gzip stream. - - If gzdirect() is used immediately after gzopen() or gzdopen() it will - cause buffers to be allocated to allow reading the file to determine if it - is a gzip file. Therefore if gzbuffer() is used, it should be called before - gzdirect(). - - When writing, gzdirect() returns true (1) if transparent writing was - requested ("wT" for the gzopen() mode), or false (0) otherwise. (Note: - gzdirect() is not needed when writing. Transparent writing must be - explicitly requested, so the application already knows the answer. When - linking statically, using gzdirect() will include all of the zlib code for - gzip file reading and decompression, which may not be desired.) -*/ - -ZEXTERN int ZEXPORT gzclose OF((gzFile file)); -/* - Flush all pending output for file, if necessary, close file and - deallocate the (de)compression state. Note that once file is closed, you - cannot call gzerror with file, since its structures have been deallocated. - gzclose must not be called more than once on the same file, just as free - must not be called more than once on the same allocation. - - gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a - file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the - last read ended in the middle of a gzip stream, or Z_OK on success. -*/ - -ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); -ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); -/* - Same as gzclose(), but gzclose_r() is only for use when reading, and - gzclose_w() is only for use when writing or appending. The advantage to - using these instead of gzclose() is that they avoid linking in zlib - compression or decompression code that is not used when only reading or only - writing respectively. If gzclose() is used, then both compression and - decompression code will be included the application when linking to a static - zlib library. -*/ - -ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); -/* - Return the error message for the last error which occurred on file. - errnum is set to zlib error number. If an error occurred in the file system - and not in the compression library, errnum is set to Z_ERRNO and the - application may consult errno to get the exact error code. - - The application must not modify the returned string. Future calls to - this function may invalidate the previously returned string. If file is - closed, then the string previously returned by gzerror will no longer be - available. - - gzerror() should be used to distinguish errors from end-of-file for those - functions above that do not distinguish those cases in their return values. -*/ - -ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); -/* - Clear the error and end-of-file flags for file. This is analogous to the - clearerr() function in stdio. This is useful for continuing to read a gzip - file that is being written concurrently. -*/ - -#endif /* !Z_SOLO */ - - /* checksum functions */ - -/* - These functions are not related to compression but are exported - anyway because they might be useful in applications using the compression - library. -*/ - -ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); -/* - Update a running Adler-32 checksum with the bytes buf[0..len-1] and - return the updated checksum. An Adler-32 value is in the range of a 32-bit - unsigned integer. If buf is Z_NULL, this function returns the required - initial value for the checksum. - - An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed - much faster. - - Usage example: - - uLong adler = adler32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - adler = adler32(adler, buffer, length); - } - if (adler != original_adler) error(); -*/ - -ZEXTERN uLong ZEXPORT adler32_z OF((uLong adler, const Bytef *buf, - z_size_t len)); -/* - Same as adler32(), but with a size_t length. -*/ - -/* -ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, - z_off_t len2)); - - Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 - and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for - each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of - seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note - that the z_off_t type (like off_t) is a signed integer. If len2 is - negative, the result has no meaning or utility. -*/ - -ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); -/* - Update a running CRC-32 with the bytes buf[0..len-1] and return the - updated CRC-32. A CRC-32 value is in the range of a 32-bit unsigned integer. - If buf is Z_NULL, this function returns the required initial value for the - crc. Pre- and post-conditioning (one's complement) is performed within this - function so it shouldn't be done by the application. - - Usage example: - - uLong crc = crc32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - crc = crc32(crc, buffer, length); - } - if (crc != original_crc) error(); -*/ - -ZEXTERN uLong ZEXPORT crc32_z OF((uLong crc, const Bytef *buf, - z_size_t len)); -/* - Same as crc32(), but with a size_t length. -*/ - -/* -ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); - - Combine two CRC-32 check values into one. For two sequences of bytes, - seq1 and seq2 with lengths len1 and len2, CRC-32 check values were - calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 - check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and - len2. -*/ - -/* -ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t len2)); - - Return the operator corresponding to length len2, to be used with - crc32_combine_op(). -*/ - -ZEXTERN uLong ZEXPORT crc32_combine_op OF((uLong crc1, uLong crc2, uLong op)); -/* - Give the same result as crc32_combine(), using op in place of len2. op is - is generated from len2 by crc32_combine_gen(). This will be faster than - crc32_combine() if the generated op is used more than once. -*/ - - - /* various hacks, don't look :) */ - -/* deflateInit and inflateInit are macros to allow checking the zlib version - * and the compiler's view of z_stream: - */ -ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, - int windowBits, int memLevel, - int strategy, const char *version, - int stream_size)); -ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, - unsigned char FAR *window, - const char *version, - int stream_size)); -#ifdef Z_PREFIX_SET -# define z_deflateInit(strm, level) \ - deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) -# define z_inflateInit(strm) \ - inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) -# define z_deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ - deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ - (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) -# define z_inflateInit2(strm, windowBits) \ - inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ - (int)sizeof(z_stream)) -# define z_inflateBackInit(strm, windowBits, window) \ - inflateBackInit_((strm), (windowBits), (window), \ - ZLIB_VERSION, (int)sizeof(z_stream)) -#else -# define deflateInit(strm, level) \ - deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) -# define inflateInit(strm) \ - inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) -# define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ - deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ - (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) -# define inflateInit2(strm, windowBits) \ - inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ - (int)sizeof(z_stream)) -# define inflateBackInit(strm, windowBits, window) \ - inflateBackInit_((strm), (windowBits), (window), \ - ZLIB_VERSION, (int)sizeof(z_stream)) -#endif - -#ifndef Z_SOLO - -/* gzgetc() macro and its supporting function and exposed data structure. Note - * that the real internal state is much larger than the exposed structure. - * This abbreviated structure exposes just enough for the gzgetc() macro. The - * user should not mess with these exposed elements, since their names or - * behavior could change in the future, perhaps even capriciously. They can - * only be used by the gzgetc() macro. You have been warned. - */ -struct gzFile_s { - unsigned have; - unsigned char *next; - z_off64_t pos; -}; -ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ -#ifdef Z_PREFIX_SET -# undef z_gzgetc -# define z_gzgetc(g) \ - ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) -#else -# define gzgetc(g) \ - ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) -#endif - -/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or - * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if - * both are true, the application gets the *64 functions, and the regular - * functions are changed to 64 bits) -- in case these are set on systems - * without large file support, _LFS64_LARGEFILE must also be true - */ -#ifdef Z_LARGE64 - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); - ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); - ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off64_t)); -#endif - -#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) -# ifdef Z_PREFIX_SET -# define z_gzopen z_gzopen64 -# define z_gzseek z_gzseek64 -# define z_gztell z_gztell64 -# define z_gzoffset z_gzoffset64 -# define z_adler32_combine z_adler32_combine64 -# define z_crc32_combine z_crc32_combine64 -# define z_crc32_combine_gen z_crc32_combine_gen64 -# else -# define gzopen gzopen64 -# define gzseek gzseek64 -# define gztell gztell64 -# define gzoffset gzoffset64 -# define adler32_combine adler32_combine64 -# define crc32_combine crc32_combine64 -# define crc32_combine_gen crc32_combine_gen64 -# endif -# ifndef Z_LARGE64 - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); - ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off_t)); -# endif -#else - ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); - ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); - ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); - ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t)); -#endif - -#else /* Z_SOLO */ - - ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t)); - -#endif /* !Z_SOLO */ - -/* undocumented functions */ -ZEXTERN const char * ZEXPORT zError OF((int)); -ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); -ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void)); -ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); -ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int)); -ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF ((z_streamp)); -ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); -ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); -#if defined(_WIN32) && !defined(Z_SOLO) -ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path, - const char *mode)); -#endif -#if defined(STDC) || defined(Z_HAVE_STDARG_H) -# ifndef Z_SOLO -ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file, - const char *format, - va_list va)); -# endif -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* ZLIB_H */ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zlib.map b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zlib.map deleted file mode 100644 index 31544f2..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zlib.map +++ /dev/null @@ -1,100 +0,0 @@ -ZLIB_1.2.0 { - global: - compressBound; - deflateBound; - inflateBack; - inflateBackEnd; - inflateBackInit_; - inflateCopy; - local: - deflate_copyright; - inflate_copyright; - inflate_fast; - inflate_table; - zcalloc; - zcfree; - z_errmsg; - gz_error; - gz_intmax; - _*; -}; - -ZLIB_1.2.0.2 { - gzclearerr; - gzungetc; - zlibCompileFlags; -} ZLIB_1.2.0; - -ZLIB_1.2.0.8 { - deflatePrime; -} ZLIB_1.2.0.2; - -ZLIB_1.2.2 { - adler32_combine; - crc32_combine; - deflateSetHeader; - inflateGetHeader; -} ZLIB_1.2.0.8; - -ZLIB_1.2.2.3 { - deflateTune; - gzdirect; -} ZLIB_1.2.2; - -ZLIB_1.2.2.4 { - inflatePrime; -} ZLIB_1.2.2.3; - -ZLIB_1.2.3.3 { - adler32_combine64; - crc32_combine64; - gzopen64; - gzseek64; - gztell64; - inflateUndermine; -} ZLIB_1.2.2.4; - -ZLIB_1.2.3.4 { - inflateReset2; - inflateMark; -} ZLIB_1.2.3.3; - -ZLIB_1.2.3.5 { - gzbuffer; - gzoffset; - gzoffset64; - gzclose_r; - gzclose_w; -} ZLIB_1.2.3.4; - -ZLIB_1.2.5.1 { - deflatePending; -} ZLIB_1.2.3.5; - -ZLIB_1.2.5.2 { - deflateResetKeep; - gzgetc_; - inflateResetKeep; -} ZLIB_1.2.5.1; - -ZLIB_1.2.7.1 { - inflateGetDictionary; - gzvprintf; -} ZLIB_1.2.5.2; - -ZLIB_1.2.9 { - inflateCodesUsed; - inflateValidate; - uncompress2; - gzfread; - gzfwrite; - deflateGetDictionary; - adler32_z; - crc32_z; -} ZLIB_1.2.7.1; - -ZLIB_1.2.12 { - crc32_combine_gen; - crc32_combine_gen64; - crc32_combine_op; -} ZLIB_1.2.9; diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zlib.pc.cmakein b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zlib.pc.cmakein deleted file mode 100644 index a5e6429..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zlib.pc.cmakein +++ /dev/null @@ -1,13 +0,0 @@ -prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=@CMAKE_INSTALL_PREFIX@ -libdir=@INSTALL_LIB_DIR@ -sharedlibdir=@INSTALL_LIB_DIR@ -includedir=@INSTALL_INC_DIR@ - -Name: zlib -Description: zlib compression library -Version: @VERSION@ - -Requires: -Libs: -L${libdir} -L${sharedlibdir} -lz -Cflags: -I${includedir} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zlib.pc.in b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zlib.pc.in deleted file mode 100644 index 7e5acf9..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zlib.pc.in +++ /dev/null @@ -1,13 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -sharedlibdir=@sharedlibdir@ -includedir=@includedir@ - -Name: zlib -Description: zlib compression library -Version: @VERSION@ - -Requires: -Libs: -L${libdir} -L${sharedlibdir} -lz -Cflags: -I${includedir} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zlib2ansi b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zlib2ansi deleted file mode 100644 index 15e3e16..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zlib2ansi +++ /dev/null @@ -1,152 +0,0 @@ -#!/usr/bin/perl - -# Transform K&R C function definitions into ANSI equivalent. -# -# Author: Paul Marquess -# Version: 1.0 -# Date: 3 October 2006 - -# TODO -# -# Asumes no function pointer parameters. unless they are typedefed. -# Assumes no literal strings that look like function definitions -# Assumes functions start at the beginning of a line - -use strict; -use warnings; - -local $/; -$_ = <>; - -my $sp = qr{ \s* (?: /\* .*? \*/ )? \s* }x; # assume no nested comments - -my $d1 = qr{ $sp (?: [\w\*\s]+ $sp)* $sp \w+ $sp [\[\]\s]* $sp }x ; -my $decl = qr{ $sp (?: \w+ $sp )+ $d1 }xo ; -my $dList = qr{ $sp $decl (?: $sp , $d1 )* $sp ; $sp }xo ; - - -while (s/^ - ( # Start $1 - ( # Start $2 - .*? # Minimal eat content - ( ^ \w [\w\s\*]+ ) # $3 -- function name - \s* # optional whitespace - ) # $2 - Matched up to before parameter list - - \( \s* # Literal "(" + optional whitespace - ( [^\)]+ ) # $4 - one or more anythings except ")" - \s* \) # optional whitespace surrounding a Literal ")" - - ( (?: $dList )+ ) # $5 - - $sp ^ { # literal "{" at start of line - ) # Remember to $1 - //xsom - ) -{ - my $all = $1 ; - my $prefix = $2; - my $param_list = $4 ; - my $params = $5; - - StripComments($params); - StripComments($param_list); - $param_list =~ s/^\s+//; - $param_list =~ s/\s+$//; - - my $i = 0 ; - my %pList = map { $_ => $i++ } - split /\s*,\s*/, $param_list; - my $pMatch = '(\b' . join('|', keys %pList) . '\b)\W*$' ; - - my @params = split /\s*;\s*/, $params; - my @outParams = (); - foreach my $p (@params) - { - if ($p =~ /,/) - { - my @bits = split /\s*,\s*/, $p; - my $first = shift @bits; - $first =~ s/^\s*//; - push @outParams, $first; - $first =~ /^(\w+\s*)/; - my $type = $1 ; - push @outParams, map { $type . $_ } @bits; - } - else - { - $p =~ s/^\s+//; - push @outParams, $p; - } - } - - - my %tmp = map { /$pMatch/; $_ => $pList{$1} } - @outParams ; - - @outParams = map { " $_" } - sort { $tmp{$a} <=> $tmp{$b} } - @outParams ; - - print $prefix ; - print "(\n" . join(",\n", @outParams) . ")\n"; - print "{" ; - -} - -# Output any trailing code. -print ; -exit 0; - - -sub StripComments -{ - - no warnings; - - # Strip C & C++ coments - # From the perlfaq - $_[0] =~ - - s{ - /\* ## Start of /* ... */ comment - [^*]*\*+ ## Non-* followed by 1-or-more *'s - ( - [^/*][^*]*\*+ - )* ## 0-or-more things which don't start with / - ## but do end with '*' - / ## End of /* ... */ comment - - | ## OR C++ Comment - // ## Start of C++ comment // - [^\n]* ## followed by 0-or-more non end of line characters - - | ## OR various things which aren't comments: - - ( - " ## Start of " ... " string - ( - \\. ## Escaped char - | ## OR - [^"\\] ## Non "\ - )* - " ## End of " ... " string - - | ## OR - - ' ## Start of ' ... ' string - ( - \\. ## Escaped char - | ## OR - [^'\\] ## Non '\ - )* - ' ## End of ' ... ' string - - | ## OR - - . ## Anything other char - [^/"'\\]* ## Chars which doesn't start a comment, string or escape - ) - }{$2}gxs; - -} diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zutil.c b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zutil.c deleted file mode 100644 index dcab28a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zutil.c +++ /dev/null @@ -1,325 +0,0 @@ -/* zutil.c -- target dependent utility functions for the compression library - * Copyright (C) 1995-2017 Jean-loup Gailly - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#include "zutil.h" -#ifndef Z_SOLO -# include "gzguts.h" -#endif - -z_const char * const z_errmsg[10] = { - (z_const char *)"need dictionary", /* Z_NEED_DICT 2 */ - (z_const char *)"stream end", /* Z_STREAM_END 1 */ - (z_const char *)"", /* Z_OK 0 */ - (z_const char *)"file error", /* Z_ERRNO (-1) */ - (z_const char *)"stream error", /* Z_STREAM_ERROR (-2) */ - (z_const char *)"data error", /* Z_DATA_ERROR (-3) */ - (z_const char *)"insufficient memory", /* Z_MEM_ERROR (-4) */ - (z_const char *)"buffer error", /* Z_BUF_ERROR (-5) */ - (z_const char *)"incompatible version",/* Z_VERSION_ERROR (-6) */ - (z_const char *)"" -}; - - -const char * ZEXPORT zlibVersion() -{ - return ZLIB_VERSION; -} - -uLong ZEXPORT zlibCompileFlags() -{ - uLong flags; - - flags = 0; - switch ((int)(sizeof(uInt))) { - case 2: break; - case 4: flags += 1; break; - case 8: flags += 2; break; - default: flags += 3; - } - switch ((int)(sizeof(uLong))) { - case 2: break; - case 4: flags += 1 << 2; break; - case 8: flags += 2 << 2; break; - default: flags += 3 << 2; - } - switch ((int)(sizeof(voidpf))) { - case 2: break; - case 4: flags += 1 << 4; break; - case 8: flags += 2 << 4; break; - default: flags += 3 << 4; - } - switch ((int)(sizeof(z_off_t))) { - case 2: break; - case 4: flags += 1 << 6; break; - case 8: flags += 2 << 6; break; - default: flags += 3 << 6; - } -#ifdef ZLIB_DEBUG - flags += 1 << 8; -#endif -#if defined(ASMV) || defined(ASMINF) - flags += 1 << 9; -#endif -#ifdef ZLIB_WINAPI - flags += 1 << 10; -#endif -#ifdef BUILDFIXED - flags += 1 << 12; -#endif -#ifdef DYNAMIC_CRC_TABLE - flags += 1 << 13; -#endif -#ifdef NO_GZCOMPRESS - flags += 1L << 16; -#endif -#ifdef NO_GZIP - flags += 1L << 17; -#endif -#ifdef PKZIP_BUG_WORKAROUND - flags += 1L << 20; -#endif -#ifdef FASTEST - flags += 1L << 21; -#endif -#if defined(STDC) || defined(Z_HAVE_STDARG_H) -# ifdef NO_vsnprintf - flags += 1L << 25; -# ifdef HAS_vsprintf_void - flags += 1L << 26; -# endif -# else -# ifdef HAS_vsnprintf_void - flags += 1L << 26; -# endif -# endif -#else - flags += 1L << 24; -# ifdef NO_snprintf - flags += 1L << 25; -# ifdef HAS_sprintf_void - flags += 1L << 26; -# endif -# else -# ifdef HAS_snprintf_void - flags += 1L << 26; -# endif -# endif -#endif - return flags; -} - -#ifdef ZLIB_DEBUG -#include -# ifndef verbose -# define verbose 0 -# endif -int ZLIB_INTERNAL z_verbose = verbose; - -void ZLIB_INTERNAL z_error (m) - char *m; -{ - fprintf(stderr, "%s\n", m); - exit(1); -} -#endif - -/* exported to allow conversion of error code to string for compress() and - * uncompress() - */ -const char * ZEXPORT zError(err) - int err; -{ - return ERR_MSG(err); -} - -#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800 - /* The older Microsoft C Run-Time Library for Windows CE doesn't have - * errno. We define it as a global variable to simplify porting. - * Its value is always 0 and should not be used. - */ - int errno = 0; -#endif - -#ifndef HAVE_MEMCPY - -void ZLIB_INTERNAL zmemcpy(dest, source, len) - Bytef* dest; - const Bytef* source; - uInt len; -{ - if (len == 0) return; - do { - *dest++ = *source++; /* ??? to be unrolled */ - } while (--len != 0); -} - -int ZLIB_INTERNAL zmemcmp(s1, s2, len) - const Bytef* s1; - const Bytef* s2; - uInt len; -{ - uInt j; - - for (j = 0; j < len; j++) { - if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; - } - return 0; -} - -void ZLIB_INTERNAL zmemzero(dest, len) - Bytef* dest; - uInt len; -{ - if (len == 0) return; - do { - *dest++ = 0; /* ??? to be unrolled */ - } while (--len != 0); -} -#endif - -#ifndef Z_SOLO - -#ifdef SYS16BIT - -#ifdef __TURBOC__ -/* Turbo C in 16-bit mode */ - -# define MY_ZCALLOC - -/* Turbo C malloc() does not allow dynamic allocation of 64K bytes - * and farmalloc(64K) returns a pointer with an offset of 8, so we - * must fix the pointer. Warning: the pointer must be put back to its - * original form in order to free it, use zcfree(). - */ - -#define MAX_PTR 10 -/* 10*64K = 640K */ - -local int next_ptr = 0; - -typedef struct ptr_table_s { - voidpf org_ptr; - voidpf new_ptr; -} ptr_table; - -local ptr_table table[MAX_PTR]; -/* This table is used to remember the original form of pointers - * to large buffers (64K). Such pointers are normalized with a zero offset. - * Since MSDOS is not a preemptive multitasking OS, this table is not - * protected from concurrent access. This hack doesn't work anyway on - * a protected system like OS/2. Use Microsoft C instead. - */ - -voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size) -{ - voidpf buf; - ulg bsize = (ulg)items*size; - - (void)opaque; - - /* If we allocate less than 65520 bytes, we assume that farmalloc - * will return a usable pointer which doesn't have to be normalized. - */ - if (bsize < 65520L) { - buf = farmalloc(bsize); - if (*(ush*)&buf != 0) return buf; - } else { - buf = farmalloc(bsize + 16L); - } - if (buf == NULL || next_ptr >= MAX_PTR) return NULL; - table[next_ptr].org_ptr = buf; - - /* Normalize the pointer to seg:0 */ - *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; - *(ush*)&buf = 0; - table[next_ptr++].new_ptr = buf; - return buf; -} - -void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) -{ - int n; - - (void)opaque; - - if (*(ush*)&ptr != 0) { /* object < 64K */ - farfree(ptr); - return; - } - /* Find the original pointer */ - for (n = 0; n < next_ptr; n++) { - if (ptr != table[n].new_ptr) continue; - - farfree(table[n].org_ptr); - while (++n < next_ptr) { - table[n-1] = table[n]; - } - next_ptr--; - return; - } - Assert(0, "zcfree: ptr not found"); -} - -#endif /* __TURBOC__ */ - - -#ifdef M_I86 -/* Microsoft C in 16-bit mode */ - -# define MY_ZCALLOC - -#if (!defined(_MSC_VER) || (_MSC_VER <= 600)) -# define _halloc halloc -# define _hfree hfree -#endif - -voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size) -{ - (void)opaque; - return _halloc((long)items, size); -} - -void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) -{ - (void)opaque; - _hfree(ptr); -} - -#endif /* M_I86 */ - -#endif /* SYS16BIT */ - - -#ifndef MY_ZCALLOC /* Any system without a special alloc function */ - -#ifndef STDC -extern voidp malloc OF((uInt size)); -extern voidp calloc OF((uInt items, uInt size)); -extern void free OF((voidpf ptr)); -#endif - -voidpf ZLIB_INTERNAL zcalloc (opaque, items, size) - voidpf opaque; - unsigned items; - unsigned size; -{ - (void)opaque; - return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : - (voidpf)calloc(items, size); -} - -void ZLIB_INTERNAL zcfree (opaque, ptr) - voidpf opaque; - voidpf ptr; -{ - (void)opaque; - free(ptr); -} - -#endif /* MY_ZCALLOC */ - -#endif /* !Z_SOLO */ diff --git a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zutil.h b/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zutil.h deleted file mode 100644 index d9a20ae..0000000 --- a/xess/samples/xess_demo/MiniEngine/Dependencies/zlib/zutil.h +++ /dev/null @@ -1,274 +0,0 @@ -/* zutil.h -- internal interface and configuration of the compression library - * Copyright (C) 1995-2022 Jean-loup Gailly, Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* @(#) $Id$ */ - -#ifndef ZUTIL_H -#define ZUTIL_H - -#ifdef HAVE_HIDDEN -# define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) -#else -# define ZLIB_INTERNAL -#endif - -#include "zlib.h" - -#if defined(STDC) && !defined(Z_SOLO) -# if !(defined(_WIN32_WCE) && defined(_MSC_VER)) -# include -# endif -# include -# include -#endif - -#ifndef local -# define local static -#endif -/* since "static" is used to mean two completely different things in C, we - define "local" for the non-static meaning of "static", for readability - (compile with -Dlocal if your debugger can't find static symbols) */ - -typedef unsigned char uch; -typedef uch FAR uchf; -typedef unsigned short ush; -typedef ush FAR ushf; -typedef unsigned long ulg; - -#if !defined(Z_U8) && !defined(Z_SOLO) && defined(STDC) -# include -# if (ULONG_MAX == 0xffffffffffffffff) -# define Z_U8 unsigned long -# elif (ULLONG_MAX == 0xffffffffffffffff) -# define Z_U8 unsigned long long -# elif (UINT_MAX == 0xffffffffffffffff) -# define Z_U8 unsigned -# endif -#endif - -extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ -/* (size given to avoid silly warnings with Visual C++) */ - -#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] - -#define ERR_RETURN(strm,err) \ - return (strm->msg = ERR_MSG(err), (err)) -/* To be used only when the state is known to be valid */ - - /* common constants */ - -#ifndef DEF_WBITS -# define DEF_WBITS MAX_WBITS -#endif -/* default windowBits for decompression. MAX_WBITS is for compression only */ - -#if MAX_MEM_LEVEL >= 8 -# define DEF_MEM_LEVEL 8 -#else -# define DEF_MEM_LEVEL MAX_MEM_LEVEL -#endif -/* default memLevel */ - -#define STORED_BLOCK 0 -#define STATIC_TREES 1 -#define DYN_TREES 2 -/* The three kinds of block type */ - -#define MIN_MATCH 3 -#define MAX_MATCH 258 -/* The minimum and maximum match lengths */ - -#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ - - /* target dependencies */ - -#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) -# define OS_CODE 0x00 -# ifndef Z_SOLO -# if defined(__TURBOC__) || defined(__BORLANDC__) -# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) - /* Allow compilation with ANSI keywords only enabled */ - void _Cdecl farfree( void *block ); - void *_Cdecl farmalloc( unsigned long nbytes ); -# else -# include -# endif -# else /* MSC or DJGPP */ -# include -# endif -# endif -#endif - -#ifdef AMIGA -# define OS_CODE 1 -#endif - -#if defined(VAXC) || defined(VMS) -# define OS_CODE 2 -# define F_OPEN(name, mode) \ - fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") -#endif - -#ifdef __370__ -# if __TARGET_LIB__ < 0x20000000 -# define OS_CODE 4 -# elif __TARGET_LIB__ < 0x40000000 -# define OS_CODE 11 -# else -# define OS_CODE 8 -# endif -#endif - -#if defined(ATARI) || defined(atarist) -# define OS_CODE 5 -#endif - -#ifdef OS2 -# define OS_CODE 6 -# if defined(M_I86) && !defined(Z_SOLO) -# include -# endif -#endif - -#if defined(MACOS) || defined(TARGET_OS_MAC) -# define OS_CODE 7 -# ifndef Z_SOLO -# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os -# include /* for fdopen */ -# else -# ifndef fdopen -# define fdopen(fd,mode) NULL /* No fdopen() */ -# endif -# endif -# endif -#endif - -#ifdef __acorn -# define OS_CODE 13 -#endif - -#if defined(WIN32) && !defined(__CYGWIN__) -# define OS_CODE 10 -#endif - -#ifdef _BEOS_ -# define OS_CODE 16 -#endif - -#ifdef __TOS_OS400__ -# define OS_CODE 18 -#endif - -#ifdef __APPLE__ -# define OS_CODE 19 -#endif - -#if defined(_BEOS_) || defined(RISCOS) -# define fdopen(fd,mode) NULL /* No fdopen() */ -#endif - -#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX -# if defined(_WIN32_WCE) -# define fdopen(fd,mode) NULL /* No fdopen() */ -# else -# define fdopen(fd,type) _fdopen(fd,type) -# endif -#endif - -#if defined(__BORLANDC__) && !defined(MSDOS) - #pragma warn -8004 - #pragma warn -8008 - #pragma warn -8066 -#endif - -/* provide prototypes for these when building zlib without LFS */ -#if !defined(_WIN32) && \ - (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); -#endif - - /* common defaults */ - -#ifndef OS_CODE -# define OS_CODE 3 /* assume Unix */ -#endif - -#ifndef F_OPEN -# define F_OPEN(name, mode) fopen((name), (mode)) -#endif - - /* functions */ - -#if defined(pyr) || defined(Z_SOLO) -# define NO_MEMCPY -#endif -#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) - /* Use our own functions for small and medium model with MSC <= 5.0. - * You may have to use the same strategy for Borland C (untested). - * The __SC__ check is for Symantec. - */ -# define NO_MEMCPY -#endif -#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) -# define HAVE_MEMCPY -#endif -#ifdef HAVE_MEMCPY -# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ -# define zmemcpy _fmemcpy -# define zmemcmp _fmemcmp -# define zmemzero(dest, len) _fmemset(dest, 0, len) -# else -# define zmemcpy memcpy -# define zmemcmp memcmp -# define zmemzero(dest, len) memset(dest, 0, len) -# endif -#else - void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); - int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); - void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); -#endif - -/* Diagnostic functions */ -#ifdef ZLIB_DEBUG -# include - extern int ZLIB_INTERNAL z_verbose; - extern void ZLIB_INTERNAL z_error OF((char *m)); -# define Assert(cond,msg) {if(!(cond)) z_error(msg);} -# define Trace(x) {if (z_verbose>=0) fprintf x ;} -# define Tracev(x) {if (z_verbose>0) fprintf x ;} -# define Tracevv(x) {if (z_verbose>1) fprintf x ;} -# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} -# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} -#else -# define Assert(cond,msg) -# define Trace(x) -# define Tracev(x) -# define Tracevv(x) -# define Tracec(c,x) -# define Tracecv(c,x) -#endif - -#ifndef Z_SOLO - voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, - unsigned size)); - void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); -#endif - -#define ZALLOC(strm, items, size) \ - (*((strm)->zalloc))((strm)->opaque, (items), (size)) -#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) -#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} - -/* Reverse the bytes in a 32-bit value */ -#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ - (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) - -#endif /* ZUTIL_H */ diff --git a/xess/samples/xess_demo/MiniEngine/License.txt b/xess/samples/xess_demo/MiniEngine/License.txt deleted file mode 100644 index 8b755d1..0000000 --- a/xess/samples/xess_demo/MiniEngine/License.txt +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2013-2015 Microsoft - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Model/Animation.cpp b/xess/samples/xess_demo/MiniEngine/Model/Animation.cpp deleted file mode 100644 index 21ad11e..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Animation.cpp +++ /dev/null @@ -1,190 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "Animation.h" -#include "Model.h" -#include "../Core/Utility.h" -#include "../Core/Math/Common.h" -#include "../Core/Math/Quaternion.h" - -using Math::Quaternion; -using Math::Vector4; - -static inline float ToFloat(const int8_t x) { return Math::Max(x / 127.0f, -1.0f); } -static inline float ToFloat(const uint8_t x) { return x / 255.0f; } -static inline float ToFloat(const int16_t x) { return Math::Max(x / 32767.0f, -1.0f); } -static inline float ToFloat(const uint16_t x) { return x / 65535.0f; } - -static inline void Lerp3(float* Dest, const float* Key1, const float* Key2, float T) -{ - Dest[0] = Math::Lerp(Key1[0], Key2[0], T); - Dest[1] = Math::Lerp(Key1[1], Key2[1], T); - Dest[2] = Math::Lerp(Key1[2], Key2[2], T); -} - -template -static inline Quaternion ToQuat(const T* rot) -{ - return (Quaternion)Vector4(ToFloat(rot[0]), ToFloat(rot[1]), ToFloat(rot[2]), ToFloat(rot[3])); -} - -static inline Quaternion ToQuat(const float* rot) -{ - return Quaternion(XMLoadFloat4((const XMFLOAT4*)rot)); -} - -static inline void Slerp(float* Dest, const void* Key1, const void* Key2, float T, uint32_t Format) -{ - switch (Format) - { - case AnimationCurve::kSNorm8: - { - const int8_t* key1 = (const int8_t*)Key1; - const int8_t* key2 = (const int8_t*)Key2; - XMStoreFloat4((XMFLOAT4*)Dest, (FXMVECTOR)Math::Slerp(ToQuat(key1), ToQuat(key2), T)); - break; - } - case AnimationCurve::kUNorm8: - { - const uint8_t* key1 = (const uint8_t*)Key1; - const uint8_t* key2 = (const uint8_t*)Key2; - XMStoreFloat4((XMFLOAT4*)Dest, (FXMVECTOR)Math::Slerp(ToQuat(key1), ToQuat(key2), T)); - break; - } - case AnimationCurve::kSNorm16: - { - const int16_t* key1 = (const int16_t*)Key1; - const int16_t* key2 = (const int16_t*)Key2; - XMStoreFloat4((XMFLOAT4*)Dest, (FXMVECTOR)Math::Slerp(ToQuat(key1), ToQuat(key2), T)); - break; - } - case AnimationCurve::kUNorm16: - { - const uint16_t* key1 = (const uint16_t*)Key1; - const uint16_t* key2 = (const uint16_t*)Key2; - XMStoreFloat4((XMFLOAT4*)Dest, (FXMVECTOR)Math::Slerp(ToQuat(key1), ToQuat(key2), T)); - break; - } - case AnimationCurve::kFloat: - { - const float* key1 = (const float*)Key1; - const float* key2 = (const float*)Key2; - XMStoreFloat4((XMFLOAT4*)Dest, (FXMVECTOR)Math::Slerp(ToQuat(key1), ToQuat(key2), T)); - break; - } - default: - ASSERT(0, "Unexpected animation key frame data format"); - break; - } -} -void ModelInstance::UpdateAnimations(float deltaTime) -{ - uint32_t NumAnimations = m_Model->m_NumAnimations; - GraphNode* animGraph = m_AnimGraph.get(); - - for (uint32_t i = 0; i < NumAnimations; ++i) - { - AnimationState& anim = m_AnimState[i]; - if (anim.state == AnimationState::kStopped) - continue; - - anim.time += deltaTime; - - const AnimationSet& animation = m_Model->m_Animations[i]; - - if (anim.state == AnimationState::kLooping) - { - anim.time = fmodf(anim.time, animation.duration); - } - else if (anim.time > animation.duration) - { - anim.time = 0.0f; - anim.state = AnimationState::kStopped; - } - - const AnimationCurve* firstCurve = m_Model->m_CurveData.get() + animation.firstCurve; - - // Update animation nodes - for (uint32_t j = 0; j < animation.numCurves; ++j) - { - const AnimationCurve& curve = firstCurve[j]; - ASSERT(curve.numSegments > 0); - - const float progress = Math::Clamp((anim.time - curve.startTime) * curve.rangeScale, 0.0f, curve.numSegments); - const uint32_t segment = (uint32_t)progress; - const float lerpT = progress - (float)segment; - - const size_t stride = curve.keyFrameStride * 4; - const byte* key1 = m_Model->m_KeyFrameData.get() + curve.keyFrameOffset + stride * segment; - const byte* key2 = key1 + stride; - GraphNode& node = animGraph[curve.targetNode]; - - switch (curve.targetPath) - { - case AnimationCurve::kTranslation: - ASSERT(curve.keyFrameFormat == AnimationCurve::kFloat); - Lerp3((float*)&node.xform + 12, (const float*)key1, (const float*)key2, lerpT); - break; - case AnimationCurve::kRotation: - node.staleMatrix = true; - Slerp((float*)&node.rotation, key1, key2, lerpT, curve.keyFrameFormat); - break; - case AnimationCurve::kScale: - ASSERT(curve.keyFrameFormat == AnimationCurve::kFloat); - node.staleMatrix = true; - Lerp3((float*)&node.scale, (const float*)key1, (const float*)key2, lerpT); - break; - default: - case AnimationCurve::kWeights: - ASSERT(0, "Unhandled blend shape weights in animation"); - break; - } - } - } -} - -void ModelInstance::PlayAnimation(uint32_t animIdx, bool loop) -{ - if (animIdx < m_AnimState.size()) - m_AnimState[animIdx].state = loop ? AnimationState::kLooping : AnimationState::kPlaying; -} - -void ModelInstance::PauseAnimation(uint32_t animIdx) -{ - if (animIdx < m_AnimState.size()) - m_AnimState[animIdx].state = AnimationState::kStopped; -} - -void ModelInstance::ResetAnimation(uint32_t animIdx) -{ - if (animIdx >= m_AnimState.size()) - m_AnimState[animIdx].time = 0.0f; -} - -void ModelInstance::StopAnimation(uint32_t animIdx) -{ - if (animIdx >= m_AnimState.size()) - { - m_AnimState[animIdx].state = AnimationState::kStopped; - m_AnimState[animIdx].time = 0.0f; - } -} - -void ModelInstance::LoopAllAnimations(void) -{ - for (auto& anim : m_AnimState) - { - anim.state = AnimationState::kLooping; - anim.time = 0.0f; - } -} \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Model/Animation.h b/xess/samples/xess_demo/MiniEngine/Model/Animation.h deleted file mode 100644 index 0d9f871..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Animation.h +++ /dev/null @@ -1,62 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include -#include - -// -// An animation curve describes how a value (or values) change over time. -// Key frames punctuate the curve, and times inbetween key frames are interpolated -// using the selected method. Note that a curve does not have to be defined for -// the entire animation. Some property might only be animated for a portion of time. -// -struct AnimationCurve -{ - enum { kTranslation, kRotation, kScale, kWeights }; // targetPath - enum { kLinear, kStep, kCatmullRomSpline, kCubicSpline }; // interpolation - enum { kSNorm8, kUNorm8, kSNorm16, kUNorm16, kFloat }; // format - - uint32_t targetNode : 28; // Which node is being animated - uint32_t targetPath : 2; // What aspect of the transform is animated - uint32_t interpolation : 2; // The method of interpolation - uint32_t keyFrameOffset : 26; // Byte offset to first key frame - uint32_t keyFrameFormat : 3; // Data format for the key frames - uint32_t keyFrameStride : 3; // Number of 4-byte words for one key frame - float numSegments; // Number of evenly-spaced gaps between keyframes - float startTime; // Time stamp of the first key frame - float rangeScale; // numSegments / (endTime - startTime) -}; - -// -// An animation is composed of multiple animation curves. -// -struct AnimationSet -{ - float duration; // Time to play entire animation - uint32_t firstCurve; // Index of the first curve in this set (stored separately) - uint32_t numCurves; // Number of curves in this set -}; - -// -// Animation state indicates whether an animation is playing and keeps track of current -// position within the animation's playback. -// -struct AnimationState -{ - enum eMode { kStopped, kPlaying, kLooping }; - eMode state; - float time; - AnimationState() : state(kStopped), time(0.0f) {} -}; diff --git a/xess/samples/xess_demo/MiniEngine/Model/BuildH3D.cpp b/xess/samples/xess_demo/MiniEngine/Model/BuildH3D.cpp deleted file mode 100644 index 9cd8854..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/BuildH3D.cpp +++ /dev/null @@ -1,214 +0,0 @@ -#include "ModelH3D.h" -#include "ModelLoader.h" -#include "MeshConvert.h" -#include "TextureConvert.h" -#include "glTF.h" -#include -#include -#include -#include - -using namespace std; -using namespace Renderer; - -bool FileExists( const std::wstring& fileName ) -{ - struct _stat64 fileStat; - return _wstat64(fileName.c_str(), &fileStat) == 0; -} - -bool ModelH3D::BuildModel(ModelData& model, const std::wstring& basePath) const -{ - model.m_SceneGraph.resize(1); - - GraphNode& node = model.m_SceneGraph[0]; - node.xform = Matrix4(kIdentity); - node.rotation = Quaternion(kIdentity); - node.scale = XMFLOAT3(1.0f, 1.0f, 1.0f); - node.matrixIdx = 0; - node.hasSibling = 0; - - model.m_MaterialTextures.resize(m_Header.materialCount); - model.m_MaterialConstants.resize(m_Header.materialCount); - model.m_TextureNames.clear(); - model.m_TextureOptions.clear(); - - std::map fileNameMap; - - for (uint32_t i = 0; i < m_Header.materialCount; ++i) - { - const Material& material = GetMaterial(i); - MaterialTextureData& textureData = model.m_MaterialTextures[i]; - textureData.addressModes = 0x55555; - - const string& baseColorPath = material.texDiffusePath; - const string& metallicRoughnessPath = material.texSpecularPath; - const string& emissivePath = material.texEmissivePath; - const string& normalPath = material.texNormalPath; - - const wstring baseColorFullPath = basePath + Utility::UTF8ToWideString(baseColorPath); - const wstring metallicRoughnessFullPath = basePath + Utility::UTF8ToWideString(metallicRoughnessPath); - const wstring emissiveFullPath = basePath + Utility::UTF8ToWideString(emissivePath); - const wstring normalFullPath = basePath + Utility::UTF8ToWideString(normalPath); - - textureData.stringIdx[kBaseColor] = 0xFFFF; - textureData.stringIdx[kMetallicRoughness] = 0xFFFF; - textureData.stringIdx[kOcclusion] = 0xFFFF; - textureData.stringIdx[kEmissive] = 0xFFFF; - textureData.stringIdx[kNormal] = 0xFFFF; - - bool alphaTest = false; - const string lowerCaseName = Utility::ToLower(baseColorPath); - if (lowerCaseName.find("thorn") != string::npos || - lowerCaseName.find("plant") != string::npos || - lowerCaseName.find("chain") != string::npos) - { - alphaTest = true; - } - - // Handle base color texture - auto mapLookup = fileNameMap.find(baseColorPath); - if (mapLookup != fileNameMap.end()) - { - textureData.stringIdx[kBaseColor] = mapLookup->second; - } - else if (baseColorPath.size() > 0 && FileExists(baseColorFullPath)) - { - fileNameMap[baseColorPath] = (uint16_t)model.m_TextureNames.size(); - textureData.stringIdx[kBaseColor] = (uint16_t)model.m_TextureNames.size(); - model.m_TextureNames.push_back(baseColorPath); - model.m_TextureOptions.push_back(TextureOptions(true, alphaTest, true)); - } - - // Handle occlusionMetallicRoughness texture - mapLookup = fileNameMap.find(metallicRoughnessPath); - if (mapLookup != fileNameMap.end()) - { - textureData.stringIdx[kMetallicRoughness] = mapLookup->second; - } - else if (metallicRoughnessPath.size() > 0 && FileExists(metallicRoughnessFullPath)) - { - fileNameMap[metallicRoughnessPath] = (uint16_t)model.m_TextureNames.size(); - textureData.stringIdx[kMetallicRoughness] = (uint16_t)model.m_TextureNames.size(); - textureData.stringIdx[kOcclusion] = (uint16_t)model.m_TextureNames.size(); - model.m_TextureNames.push_back(metallicRoughnessPath); - model.m_TextureOptions.push_back(TextureOptions(false, false, true)); - } - - // Handle emissive texture - mapLookup = fileNameMap.find(emissivePath); - if (mapLookup != fileNameMap.end()) - { - textureData.stringIdx[kEmissive] = mapLookup->second; - } - else if (emissivePath.size() > 0 && FileExists(emissiveFullPath)) - { - fileNameMap[emissivePath] = (uint16_t)model.m_TextureNames.size(); - textureData.stringIdx[kEmissive] = (uint16_t)model.m_TextureNames.size(); - model.m_TextureNames.push_back(emissivePath); - model.m_TextureOptions.push_back(TextureOptions(true, false, true)); - } - - // Handle normal texture - mapLookup = fileNameMap.find(normalPath); - if (mapLookup != fileNameMap.end()) - { - textureData.stringIdx[kNormal] = mapLookup->second; - } - else if (normalPath.size() > 0 && FileExists(normalFullPath)) - { - fileNameMap[normalPath] = (uint16_t)model.m_TextureNames.size(); - textureData.stringIdx[kNormal] = (uint16_t)model.m_TextureNames.size(); - model.m_TextureNames.push_back(normalPath); - model.m_TextureOptions.push_back(TextureOptions(false, false, true)); - } - - MaterialConstantData& constantData = model.m_MaterialConstants[i]; - constantData.baseColorFactor[0] = 1.0f; - constantData.baseColorFactor[1] = 1.0f; - constantData.baseColorFactor[2] = 1.0f; - constantData.baseColorFactor[3] = 1.0f; - constantData.emissiveFactor[0] = 1.0f; - constantData.emissiveFactor[1] = 1.0f; - constantData.emissiveFactor[2] = 1.0f; - constantData.metallicFactor = 1.0f; - constantData.roughnessFactor = 1.0f; - constantData.normalTextureScale = 1.0f; - constantData.flags = 0x3C000000; - if (alphaTest) - constantData.flags |= 0x60; // twoSided + alphaTest - } - - ASSERT(model.m_TextureOptions.size() == model.m_TextureNames.size()); - for (size_t ti = 0; ti < model.m_TextureNames.size(); ++ti) - { - std::wstring fullPath = basePath + Utility::UTF8ToWideString(model.m_TextureNames[ti]); - CompileTextureOnDemand(fullPath, model.m_TextureOptions[ti]); - } - - model.m_BoundingSphere = BoundingSphere(kZero); - model.m_BoundingBox = AxisAlignedBox(kZero); - - // We're going to piggy-back off of the work to compile glTF meshes by pretending that's what - // we have. - for (uint32_t i = 0; i < m_Header.meshCount; ++i) - { - const Mesh& mesh = GetMesh(i); - - glTF::Accessor PosStream; - PosStream.dataPtr = m_pVertexData + mesh.vertexDataByteOffset; - PosStream.stride = mesh.vertexStride; - PosStream.count = mesh.vertexCount; - PosStream.componentType = glTF::Accessor::kFloat; - PosStream.type = glTF::Accessor::kVec3; - - glTF::Accessor UVStream; - UVStream.dataPtr = m_pVertexData + mesh.vertexDataByteOffset + 12; - UVStream.stride = mesh.vertexStride; - UVStream.count = mesh.vertexCount; - UVStream.componentType = glTF::Accessor::kFloat; - UVStream.type = glTF::Accessor::kVec2; - - glTF::Accessor NormalStream; - NormalStream.dataPtr = m_pVertexData + mesh.vertexDataByteOffset + 20; - NormalStream.stride = mesh.vertexStride; - NormalStream.count = mesh.vertexCount; - NormalStream.componentType = glTF::Accessor::kFloat; - NormalStream.type = glTF::Accessor::kVec3; - - glTF::Accessor IndexStream; - IndexStream.dataPtr = m_pIndexData + mesh.indexDataByteOffset; - IndexStream.stride = 2; - IndexStream.count = mesh.indexCount; - IndexStream.componentType = glTF::Accessor::kUnsignedShort; - IndexStream.type = glTF::Accessor::kScalar; - - glTF::Material material; - material.flags = model.m_MaterialConstants[mesh.materialIndex].flags; - material.index = mesh.materialIndex; - - glTF::Mesh gltfMesh; - gltfMesh.primitives.resize(1); - - glTF::Primitive& prim = gltfMesh.primitives[0]; - prim.attributes[glTF::Primitive::kPosition] = &PosStream; - prim.attributes[glTF::Primitive::kTexcoord0] = &UVStream; - prim.attributes[glTF::Primitive::kNormal] = &NormalStream; - prim.indices = &IndexStream; - prim.material = &material; - prim.attribMask = 0xB; - prim.mode = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; - memcpy(prim.minPos, &mesh.boundingBox.GetMin(), 12); - memcpy(prim.maxPos, &mesh.boundingBox.GetMax(), 12); - prim.minIndex = 0; - prim.maxIndex = 0; - - BoundingSphere sphereOS; - AxisAlignedBox boxOS; - Renderer::CompileMesh(model.m_Meshes, model.m_GeometryData, gltfMesh, 0, Matrix4(kIdentity), sphereOS, boxOS); - model.m_BoundingSphere = model.m_BoundingSphere.Union(sphereOS); - model.m_BoundingBox.AddBoundingBox(boxOS); - } - - return true; -} \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Model/ConstantBuffers.h b/xess/samples/xess_demo/MiniEngine/Model/ConstantBuffers.h deleted file mode 100644 index ced2379..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/ConstantBuffers.h +++ /dev/null @@ -1,83 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -// Modified 2022, Intel Corporation. -// Improved Forward+ lighting. - -#pragma once - -#include "../Core/Math/Matrix3.h" -#include "../Core/Math/Matrix4.h" -#include - -__declspec(align(16)) struct MeshConstants -{ - Math::Matrix4 World; // Object to world - Math::Matrix3 WorldIT; // Object normal to world normal, 3x4-float memory footprint - float padding[36]; // Padding so the constant buffer is 256-byte aligned. -}; - -// The order of textures for PBR materials -enum { kBaseColor, kMetallicRoughness, kOcclusion, kEmissive, kNormal, kNumTextures }; - -__declspec(align(16)) struct MaterialConstants -{ - float baseColorFactor[4]; // default=[1,1,1,1] - float emissiveFactor[3]; // default=[0,0,0] - float normalTextureScale; // default=1 - float metallicFactor; // default=1 - float roughnessFactor; // default=1 - union - { - uint32_t flags; - struct - { - // UV0 or UV1 for each texture - uint32_t baseColorUV : 1; - uint32_t metallicRoughnessUV : 1; - uint32_t occlusionUV : 1; - uint32_t emissiveUV : 1; - uint32_t normalUV : 1; - - // Three special modes - uint32_t twoSided : 1; - uint32_t alphaTest : 1; - uint32_t alphaBlend : 1; - - uint32_t _pad : 8; - - uint32_t alphaRef : 16; // half float - }; - }; - float padding[53]; // Padding so the constant buffer is 256-byte aligned. -}; - -__declspec(align(16)) struct GlobalConstants -{ - Math::Matrix4 ViewProjMatrix; - Math::Matrix4 SunShadowMatrix; - Math::Matrix3 EnvRotation; - Math::Vector3 CameraPos; // Vector3 has 4-float memory footprint, so no padding is needed. - Math::Vector3 SunDirection; - Math::Vector3 SunIntensity; - - float ShadowTexelSize[4]; - float InvTileDim[4]; - uint32_t TileCount[4]; - uint32_t FirstLightIndex[4]; - - float IBLRange; - float IBLBias; - float ViewMipBias; - float DebugFlag; -}; \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Model/IndexOptimizePostTransform.cpp b/xess/samples/xess_demo/MiniEngine/Model/IndexOptimizePostTransform.cpp deleted file mode 100644 index 183710b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/IndexOptimizePostTransform.cpp +++ /dev/null @@ -1,450 +0,0 @@ -//----------------------------------------------------------------------------- -// This is an implementation of Tom Forsyth's "Linear-Speed Vertex Cache -// Optimization" algorithm as described here: -// https://tomforsyth1000.github.io/papers/fast_vert_cache_opt.html -// -// This code was authored and released into the public domain by -// Adrian Stone (stone@gameangst.com). -// -// THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -// SHALL ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER -// LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -//----------------------------------------------------------------------------- - -// modified from original source to improve performance (especially in debug builds), memory allocations, etc. - -#include "../Core/Utility.h" - -#include -#include -#include -#include - -#include "IndexOptimizePostTransform.h" - -namespace -{ - // code for computing vertex score was taken, as much as possible - // directly from the original publication. - float ComputeVertexCacheScore(int cachePosition, size_t vertexCacheSize) - { - const float FindVertexScore_CacheDecayPower = 1.5f; - const float FindVertexScore_LastTriScore = 0.75f; - - float score = 0.0f; - if ( cachePosition < 0 ) - { - // Vertex is not in FIFO cache - no score. - } - else - { - if ( cachePosition < 3 ) - { - // This vertex was used in the last triangle, - // so it has a fixed score, whichever of the three - // it's in. Otherwise, you can get very different - // answers depending on whether you add - // the triangle 1,2,3 or 3,1,2 - which is silly. - score = FindVertexScore_LastTriScore; - } - else - { - ASSERT ( cachePosition < int(vertexCacheSize) ); - // Points for being high in the cache. - const float scaler = 1.0f / ( vertexCacheSize - 3 ); - score = 1.0f - ( cachePosition - 3 ) * scaler; - score = powf ( score, FindVertexScore_CacheDecayPower ); - } - } - - return score; - } - - float ComputeVertexValenceScore(size_t numActiveFaces) - { - const float FindVertexScore_ValenceBoostScale = 2.0f; - const float FindVertexScore_ValenceBoostPower = 0.5f; - - float score = 0.0f; - - // Bonus points for having a low number of tris still to - // use the vert, so we get rid of lone verts quickly. - float valenceBoost = powf ( static_cast(numActiveFaces), - -FindVertexScore_ValenceBoostPower ); - score += FindVertexScore_ValenceBoostScale * valenceBoost; - - return score; - } - - - enum - { - kMaxVertexCacheSize = 64, - kMaxPrecomputedVertexValenceScores = 64 - }; - - float s_vertexCacheScores[kMaxVertexCacheSize+1][kMaxVertexCacheSize]; - float s_vertexValenceScores[kMaxPrecomputedVertexValenceScores]; - - bool ComputeVertexScores() - { - for (uint32_t cacheSize = 0; cacheSize <= kMaxVertexCacheSize; ++cacheSize) - { - for (uint32_t cachePos = 0; cachePos < cacheSize; ++cachePos) - { - s_vertexCacheScores[cacheSize][cachePos] = ComputeVertexCacheScore(cachePos, cacheSize); - } - } - - for (uint32_t valence = 0; valence < kMaxPrecomputedVertexValenceScores; ++valence) - { - s_vertexValenceScores[valence] = ComputeVertexValenceScore(valence); - } - - return true; - } - bool s_vertexScoresComputed = ComputeVertexScores(); - - inline float FindVertexCacheScore(size_t cachePosition, size_t maxSizeVertexCache) - { - return s_vertexCacheScores[maxSizeVertexCache][cachePosition]; - } - - inline float FindVertexValenceScore(size_t numActiveTris) - { - return s_vertexValenceScores[numActiveTris]; - } - - float FindVertexScore(size_t numActiveFaces, size_t cachePosition, size_t vertexCacheSize) - { - //ASSERT(s_vertexScoresComputed); - - if (numActiveFaces == 0) - { - // No tri needs this vertex! - return -1.0f; - } - - float score = 0.0f; - if (cachePosition < vertexCacheSize) - { - score += s_vertexCacheScores[vertexCacheSize][cachePosition]; - } - - if (numActiveFaces < kMaxPrecomputedVertexValenceScores) - { - score += s_vertexValenceScores[numActiveFaces]; - } - else - { - score += ComputeVertexValenceScore(numActiveFaces); - } - - return score; - } - - struct OptimizeVertexData - { - float score; - size_t activeFaceListStart; - size_t activeFaceListSize; - size_t cachePos0; - size_t cachePos1; - OptimizeVertexData() : score(0.0f), activeFaceListStart(0), activeFaceListSize(0), cachePos0(0), cachePos1(0) { } - }; -} - -template -struct IndexSortCompareIndexed -{ - const IndexType* _indexData; - - IndexSortCompareIndexed(const IndexType* indexData) - : _indexData(indexData) - { - } - - bool operator()(size_t a, size_t b) const - { - IndexType indexA = _indexData[a]; - IndexType indexB = _indexData[b]; - - return indexA < indexB; - } -}; - -struct FaceValenceSort -{ - const OptimizeVertexData* _vertexData; - - FaceValenceSort(const OptimizeVertexData* vertexData) - : _vertexData(vertexData) - { - } - - bool operator()(size_t a, size_t b) const - { - const OptimizeVertexData* vA0 = _vertexData + a * 3 + 0; - const OptimizeVertexData* vA1 = _vertexData + a * 3 + 1; - const OptimizeVertexData* vA2 = _vertexData + a * 3 + 2; - const OptimizeVertexData* vB0 = _vertexData + b * 3 + 0; - const OptimizeVertexData* vB1 = _vertexData + b * 3 + 1; - const OptimizeVertexData* vB2 = _vertexData + b * 3 + 2; - - size_t aValence = vA0->activeFaceListSize + vA1->activeFaceListSize + vA2->activeFaceListSize; - size_t bValence = vB0->activeFaceListSize + vB1->activeFaceListSize + vB2->activeFaceListSize; - - // higher scoring faces are those with lower valence totals - // reverse sort (reverse of reverse) - return aValence < bValence; - } -}; - -//----------------------------------------------------------------------------- -// OptimizeFaces -//----------------------------------------------------------------------------- -// Parameters: -// indexList -// input index list -// indexCount -// the number of indices in the list -// vertexCount -// the largest index value in indexList -// newIndexList -// a pointer to a preallocated buffer the same size as indexList to -// hold the optimized index list -// lruCacheSize -// the size of the simulated post-transform cache (max:64) -//----------------------------------------------------------------------------- -template -void OptimizeFaces(const SrcIndexType* indexList, size_t indexCount, DstIndexType* newIndexList, size_t lruCacheSize) -{ - ASSERT(lruCacheSize <= kMaxVertexCacheSize); - - std::unique_ptr vertexDataList(new OptimizeVertexData[indexCount]); // upper bounds on size is indexCount - std::unique_ptr vertexRemap(new uint32_t[indexCount]); - std::unique_ptr activeFaceList(new uint32_t[indexCount]); - - size_t faceCount = indexCount / 3; - std::unique_ptr processedFaceList(new uint8_t[faceCount]); - memset(processedFaceList.get(), 0, sizeof(uint8_t) * faceCount); - std::unique_ptr faceSorted(new uint32_t[faceCount]); - std::unique_ptr faceReverseLookup(new uint32_t[faceCount]); - - // build the vertex remap table - uint32_t uniqueVertexCount = 0; - { - typedef IndexSortCompareIndexed indexSorter; - uint32_t* indexSorted = new uint32_t[indexCount]; - - for (uint32_t i = 0; i < indexCount; i++) - { - indexSorted[i] = i; - } - - indexSorter sortFunc(indexList); - std::sort(indexSorted, indexSorted + indexCount, sortFunc); - - for (uint32_t i = 0; i < indexCount; i++) - { - if (i == 0 || sortFunc(indexSorted[i - 1], indexSorted[i])) - { - // it's not a duplicate - vertexRemap[indexSorted[i]] = uniqueVertexCount; - uniqueVertexCount++; - } - else - { - vertexRemap[indexSorted[i]] = vertexRemap[indexSorted[i - 1]]; - } - } - - delete[] indexSorted; - } - - // compute face count per vertex - for (size_t i = 0; i < indexCount; ++i) - { - vertexDataList[vertexRemap[i]].activeFaceListSize++; - } - - const size_t kEvictedCacheIndex = std::numeric_limits::max(); - { - // allocate face list per vertex - size_t curActiveFaceListPos = 0; - for (uint32_t i = 0; i < uniqueVertexCount; ++i) - { - OptimizeVertexData& vertexData = vertexDataList[i]; - vertexData.cachePos0 = kEvictedCacheIndex; - vertexData.cachePos1 = kEvictedCacheIndex; - vertexData.activeFaceListStart = curActiveFaceListPos; - curActiveFaceListPos += vertexData.activeFaceListSize; - vertexData.score = FindVertexScore(vertexData.activeFaceListSize, vertexData.cachePos0, lruCacheSize); - vertexData.activeFaceListSize = 0; - } - ASSERT(curActiveFaceListPos == indexCount); - } - - // sort unprocessed faces by highest score - for (uint32_t f = 0; f < faceCount; f++) - { - faceSorted[f] = f; - } - FaceValenceSort faceValenceSort(vertexDataList.get()); - std::sort(faceSorted.get(), faceSorted.get() + faceCount, faceValenceSort); - for (uint32_t f = 0; f < faceCount; f++) - { - faceReverseLookup[faceSorted[f]] = f; - } - - // fill out face list per vertex - for (uint32_t i=0; i 0); - //ASSERT(vertexData.cachePos0 >= lruCacheSize); - - float vertexScore = vertexDataList[vertexRemap[face + k]].score; - faceScore += vertexScore; - } - - bestScore = faceScore; - bestFace = face; - - nextBestFace++; - break; // we're searching a pre-sorted list, first one we find will be the best - } - } - ASSERT(bestScore >= 0.0f); - } - - processedFaceList[bestFace / 3] = 1; - size_t entriesInCache1 = 0; - - // add bestFace to LRU cache and to newIndexList - for (uint32_t v = 0; v < 3; ++v) - { - uint32_t index = static_cast(indexList[bestFace + v]); - newIndexList[i+v] = (DstIndexType)index; - - OptimizeVertexData& vertexData = vertexDataList[vertexRemap[bestFace + v]]; - - if (vertexData.cachePos1 >= entriesInCache1) - { - vertexData.cachePos1 = entriesInCache1; - cache1[entriesInCache1++] = vertexRemap[bestFace + v]; - - if (vertexData.activeFaceListSize == 1) - { - --vertexData.activeFaceListSize; - continue; - } - } - - ASSERT(vertexData.activeFaceListSize > 0); - uint32_t* begin = activeFaceList.get() + vertexData.activeFaceListStart; - uint32_t* end = begin + vertexData.activeFaceListSize; - uint32_t* it = std::find(begin, end, bestFace); - ASSERT(it != end); - std::swap(*it, *(end-1)); - --vertexData.activeFaceListSize; - vertexData.score = FindVertexScore(vertexData.activeFaceListSize, vertexData.cachePos1, lruCacheSize); - - // need to re-sort the faces that use this vertex, as their score will change due to activeFaceListSize shrinking - for (uint32_t* fi = begin; fi != end - 1; ++fi) - { - uint32_t faceIndex = *fi / 3; - - uint32_t n = faceReverseLookup[faceIndex]; - ASSERT(faceSorted[n] == faceIndex); - - // found it, now move it up - for (n; n > 0; --n) - { - if (!faceValenceSort(n, n - 1)) - break; - - faceReverseLookup[faceSorted[n]] = n - 1; - faceReverseLookup[faceSorted[n - 1]] = n; - std::swap(faceSorted[n], faceSorted[n - 1]); - } - } - } - - // move the rest of the old verts in the cache down and compute their new scores - for (uint32_t c0 = 0; c0 < entriesInCache0; ++c0) - { - OptimizeVertexData& vertexData = vertexDataList[cache0[c0]]; - - if (vertexData.cachePos1 >= entriesInCache1) - { - vertexData.cachePos1 = entriesInCache1; - cache1[entriesInCache1++] = cache0[c0]; - vertexData.score = FindVertexScore(vertexData.activeFaceListSize, vertexData.cachePos1, lruCacheSize); - // don't need to re-sort this vertex... once it gets out of the cache, it'll have its original score - } - } - - // find the best scoring triangle in the current cache (including up to 3 that were just evicted) - bestScore = -1.0f; - for (uint32_t c1 = 0; c1 < entriesInCache1; ++c1) - { - OptimizeVertexData& vertexData = vertexDataList[cache1[c1]]; - vertexData.cachePos0 = vertexData.cachePos1; - vertexData.cachePos1 = kEvictedCacheIndex; - for (uint32_t j = 0; j < vertexData.activeFaceListSize; ++j) - { - uint32_t face = activeFaceList[vertexData.activeFaceListStart+j]; - float faceScore = 0.0f; - for (uint32_t v = 0; v < 3; ++v) - { - faceScore += vertexDataList[vertexRemap[face + v]].score; - } - if (faceScore > bestScore) - { - bestScore = faceScore; - bestFace = face; - } - } - } - - std::swap(cache0, cache1); - entriesInCache0 = std::min(entriesInCache1, lruCacheSize); - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Model/IndexOptimizePostTransform.h b/xess/samples/xess_demo/MiniEngine/Model/IndexOptimizePostTransform.h deleted file mode 100644 index e069598..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/IndexOptimizePostTransform.h +++ /dev/null @@ -1,51 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): Alex Nankervis -// James Stanard -// - -// Modified 2022, Intel Corporation. -// glTF support improved. - -#pragma once - -//----------------------------------------------------------------------------- -// OptimizeFaces -//----------------------------------------------------------------------------- -// Parameters: -// indexList -// input index list -// indexCount -// the number of indices in the list -// newIndexList -// a pointer to a preallocated buffer the same size as indexList to -// hold the optimized index list -// lruCacheSize -// the size of the simulated post-transform cache (max:64) -//----------------------------------------------------------------------------- -template -void OptimizeFaces(const SrcIndexType* indexList, size_t indexCount, DstIndexType* newIndexList, size_t lruCacheSize); - -template void OptimizeFaces(const int8_t* indexList, size_t indexCount, uint16_t* newIndexList, size_t lruCacheSize); -template void OptimizeFaces(const int8_t* indexList, size_t indexCount, uint32_t* newIndexList, size_t lruCacheSize); -template void OptimizeFaces(const uint8_t* indexList, size_t indexCount, uint16_t* newIndexList, size_t lruCacheSize); -template void OptimizeFaces(const uint8_t* indexList, size_t indexCount, uint32_t* newIndexList, size_t lruCacheSize); - -template void OptimizeFaces(const int16_t* indexList, size_t indexCount, uint16_t* newIndexList, size_t lruCacheSize); -template void OptimizeFaces(const int16_t* indexList, size_t indexCount, uint32_t* newIndexList, size_t lruCacheSize); -template void OptimizeFaces(const uint16_t* indexList, size_t indexCount, uint16_t* newIndexList, size_t lruCacheSize); -template void OptimizeFaces(const uint16_t* indexList, size_t indexCount, uint32_t* newIndexList, size_t lruCacheSize); - -template void OptimizeFaces(const uint32_t* indexList, size_t indexCount, uint16_t* newIndexList, size_t lruCacheSize); -template void OptimizeFaces(const uint32_t* indexList, size_t indexCount, uint32_t* newIndexList, size_t lruCacheSize); - -template void OptimizeFaces(const float* indexList, size_t indexCount, uint16_t* newIndexList, size_t lruCacheSize); -template void OptimizeFaces(const float* indexList, size_t indexCount, uint32_t* newIndexList, size_t lruCacheSize); diff --git a/xess/samples/xess_demo/MiniEngine/Model/LightManager.cpp b/xess/samples/xess_demo/MiniEngine/Model/LightManager.cpp deleted file mode 100644 index 58f31fc..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/LightManager.cpp +++ /dev/null @@ -1,366 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): Alex Nankervis -// James Stanard -// - -// Modified 2022, Intel Corporation. -// Forward+ lighting support improved. - -#include "LightManager.h" -#include "PipelineState.h" -#include "RootSignature.h" -#include "CommandContext.h" -#include "Camera.h" -#include "BufferManager.h" -#include "TemporalEffects.h" - -#include "CompiledShaders/FillLightGrid8CS.h" -#include "CompiledShaders/FillLightGrid16CS.h" -#include "CompiledShaders/FillLightGrid24CS.h" -#include "CompiledShaders/FillLightGrid32CS.h" - -using namespace Math; -using namespace Graphics; - -// must keep in sync with HLSL -__declspec(align(16)) struct LightData -{ - float pos[3]; - float radiusSq; - float color[3]; - - uint32_t type; - float coneDir[3]; - float coneAngles[2]; - - float shadowTextureMatrix[16]; - - float padding[3]; // Padding so the structure is 16-byte aligned. -}; - -enum { kMinLightGridDim = 8 }; - -namespace Lighting -{ - IntVar LightGridDim("Application/Forward+/Light Grid Dim", 16, kMinLightGridDim, 32, 8 ); - - RootSignature m_FillLightRootSig; - ComputePSO m_FillLightGridCS_8(L"Fill Light Grid 8 CS"); - ComputePSO m_FillLightGridCS_16(L"Fill Light Grid 16 CS"); - ComputePSO m_FillLightGridCS_24(L"Fill Light Grid 24 CS"); - ComputePSO m_FillLightGridCS_32(L"Fill Light Grid 32 CS"); - - LightData m_LightData[MaxLights]; - StructuredBuffer m_LightBuffer; - ByteAddressBuffer m_LightGrid; - ByteAddressBuffer m_LightGridBitMask; - ByteAddressBuffer m_LightGridTransparent; - ByteAddressBuffer m_LightGridBitMaskTransparent; - uint32_t m_FirstConeLight; - uint32_t m_FirstConeShadowedLight; - - enum {shadowDim = 512}; - ColorBuffer m_LightShadowArray; - ShadowBuffer m_LightShadowTempBuffer; - Matrix4 m_LightShadowMatrix[MaxLights]; - - void InitializeResources(void); - void CreateRandomLights(const Vector3 minBound, const Vector3 maxBound); - void Shutdown(void); -} - -void Lighting::InitializeResources( void ) -{ - m_FillLightRootSig.Reset(3, 0); - m_FillLightRootSig[0].InitAsConstantBuffer(0); - m_FillLightRootSig[1].InitAsDescriptorRange(D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 2); - m_FillLightRootSig[2].InitAsDescriptorRange(D3D12_DESCRIPTOR_RANGE_TYPE_UAV, 0, 2); - m_FillLightRootSig.Finalize(L"FillLightRS"); - - m_FillLightGridCS_8.SetRootSignature(m_FillLightRootSig); - m_FillLightGridCS_8.SetComputeShader(g_pFillLightGrid8CS, sizeof(g_pFillLightGrid8CS)); - m_FillLightGridCS_8.Finalize(); - - m_FillLightGridCS_16.SetRootSignature(m_FillLightRootSig); - m_FillLightGridCS_16.SetComputeShader(g_pFillLightGrid16CS, sizeof(g_pFillLightGrid16CS)); - m_FillLightGridCS_16.Finalize(); - - m_FillLightGridCS_24.SetRootSignature(m_FillLightRootSig); - m_FillLightGridCS_24.SetComputeShader(g_pFillLightGrid24CS, sizeof(g_pFillLightGrid24CS)); - m_FillLightGridCS_24.Finalize(); - - m_FillLightGridCS_32.SetRootSignature(m_FillLightRootSig); - m_FillLightGridCS_32.SetComputeShader(g_pFillLightGrid32CS, sizeof(g_pFillLightGrid32CS)); - m_FillLightGridCS_32.Finalize(); - - // Assumes max resolution of 3840x2160 - uint32_t lightGridCells = Math::DivideByMultiple(3840, kMinLightGridDim) * Math::DivideByMultiple(2160, kMinLightGridDim); - uint32_t lightGridSizeBytes = lightGridCells * (4 + MaxLights * 4); - m_LightGrid.Create(L"m_LightGrid", lightGridSizeBytes, 1); - m_LightGridTransparent.Create(L"m_LightGrid Alpha", lightGridSizeBytes, 1); - - uint32_t lightGridBitMaskSizeBytes = lightGridCells * 4 * 4; - m_LightGridBitMask.Create(L"m_LightGridBitMask", lightGridBitMaskSizeBytes, 1); - m_LightGridBitMaskTransparent.Create(L"m_LightGridBitMask Alpha", lightGridBitMaskSizeBytes, 1); - - m_LightShadowArray.CreateArray(L"m_LightShadowArray", shadowDim, shadowDim, MaxLights, DXGI_FORMAT_R16_UNORM); - m_LightShadowTempBuffer.Create(L"m_LightShadowTempBuffer", shadowDim, shadowDim); - - m_LightBuffer.Create(L"m_LightBuffer", MaxLights, sizeof(LightData)); -} - -void Lighting::CreateRandomLights( const Vector3 minBound, const Vector3 maxBound ) -{ - Vector3 posScale = maxBound - minBound; - Vector3 posBias = minBound; - - // todo: replace this with MT - srand(12645); - auto randUint = []() -> uint32_t - { - return rand(); // [0, RAND_MAX] - }; - auto randFloat = [randUint]() -> float - { - return randUint() * (1.0f / RAND_MAX); // convert [0, RAND_MAX] to [0, 1] - }; - auto randVecUniform = [randFloat]() -> Vector3 - { - return Vector3(randFloat(), randFloat(), randFloat()); - }; - auto randGaussian = [randFloat]() -> float - { - // polar box-muller - static bool gaussianPair = true; - static float y2; - - if (gaussianPair) - { - gaussianPair = false; - - float x1, x2, w; - do - { - x1 = 2 * randFloat() - 1; - x2 = 2 * randFloat() - 1; - w = x1 * x1 + x2 * x2; - } while (w >= 1); - - w = sqrtf(-2 * logf(w) / w); - y2 = x2 * w; - return x1 * w; - } - else - { - gaussianPair = true; - return y2; - } - }; - auto randVecGaussian = [randGaussian]() -> Vector3 - { - return Normalize(Vector3(randGaussian(), randGaussian(), randGaussian())); - }; - - const float pi = 3.14159265359f; - for (uint32_t n = 0; n < MaxLights; n++) - { - Vector3 pos = randVecUniform() * posScale + posBias; - float lightRadius = randFloat() * 800.0f + 200.0f; - - Vector3 color = randVecUniform(); - float colorScale = randFloat() * .3f + .3f; - color = color * colorScale; - - uint32_t type; - // force types to match 32-bit boundaries for the BIT_MASK_SORTED case - if (n < 32 * 1) - type = 0; - //else if (n < 32 * 3) // We make all spotlights with shadow - // type = 1; - else - type = 2; - - Vector3 coneDir = randVecGaussian(); - float coneInner = (randFloat() * .2f + .025f) * pi; - float coneOuter = coneInner + randFloat() * .1f * pi; - - if (type == 1 || type == 2) - { - // emphasize cone lights - color = color * 5.0f; - } - - Math::Camera shadowCamera; - shadowCamera.SetEyeAtUp(pos, pos + coneDir, Vector3(0, 1, 0)); - shadowCamera.SetPerspectiveMatrix(coneOuter * 2, 1.0f, lightRadius * .05f, lightRadius * 1.0f); - shadowCamera.Update(); - m_LightShadowMatrix[n] = shadowCamera.GetViewProjMatrix(); - Matrix4 shadowTextureMatrix = Matrix4(AffineTransform(Matrix3::MakeScale( 0.5f, -0.5f, 1.0f ), Vector3(0.5f, 0.5f, 0.0f))) * m_LightShadowMatrix[n]; - - m_LightData[n].pos[0] = pos.GetX(); - m_LightData[n].pos[1] = pos.GetY(); - m_LightData[n].pos[2] = pos.GetZ(); - m_LightData[n].radiusSq = lightRadius * lightRadius; - m_LightData[n].color[0] = color.GetX(); - m_LightData[n].color[1] = color.GetY(); - m_LightData[n].color[2] = color.GetZ(); - m_LightData[n].type = type; - m_LightData[n].coneDir[0] = coneDir.GetX(); - m_LightData[n].coneDir[1] = coneDir.GetY(); - m_LightData[n].coneDir[2] = coneDir.GetZ(); - m_LightData[n].coneAngles[0] = 1.0f / (cosf(coneInner) - cosf(coneOuter)); - m_LightData[n].coneAngles[1] = cosf(coneOuter); - std::memcpy(m_LightData[n].shadowTextureMatrix, &shadowTextureMatrix, sizeof(shadowTextureMatrix)); - //*(Matrix4*)(m_LightData[n].shadowTextureMatrix) = shadowTextureMatrix; - } - // sort lights by type, needed for efficiency in the BIT_MASK approach - /* { - Matrix4 copyLightShadowMatrix[MaxLights]; - memcpy(copyLightShadowMatrix, m_LightShadowMatrix, sizeof(Matrix4) * MaxLights); - LightData copyLightData[MaxLights]; - memcpy(copyLightData, m_LightData, sizeof(LightData) * MaxLights); - - uint32_t sortArray[MaxLights]; - for (uint32_t n = 0; n < MaxLights; n++) - { - sortArray[n] = n; - } - std::sort(sortArray, sortArray + MaxLights, - [this](const uint32_t &a, const uint32_t &b) -> bool - { - return this->m_LightData[a].type < this->m_LightData[b].type; - }); - for (uint32_t n = 0; n < MaxLights; n++) - { - m_LightShadowMatrix[n] = copyLightShadowMatrix[sortArray[n]]; - m_LightData[n] = copyLightData[sortArray[n]]; - } - }*/ - for (uint32_t n = 0; n < MaxLights; n++) - { - if (m_LightData[n].type == 1) - { - m_FirstConeLight = n; - break; - } - } - for (uint32_t n = 0; n < MaxLights; n++) - { - if (m_LightData[n].type == 2) - { - m_FirstConeShadowedLight = n; - break; - } - } - - CommandContext::InitializeBuffer(m_LightBuffer, m_LightData, MaxLights * sizeof(LightData)); -} - -void Lighting::Shutdown(void) -{ - m_LightBuffer.Destroy(); - m_LightGrid.Destroy(); - m_LightGridBitMask.Destroy(); - m_LightGridTransparent.Destroy(); - m_LightGridBitMaskTransparent.Destroy(); - m_LightShadowArray.Destroy(); - m_LightShadowTempBuffer.Destroy(); -} - -void Lighting::FillLightGrid(GraphicsContext& gfxContext, const Camera& camera, bool transparent) -{ - ScopedTimer _prof(L"FillLightGrid", gfxContext); - - ComputeContext& Context = gfxContext.GetComputeContext(); - - Context.SetRootSignature(m_FillLightRootSig); - - switch ((int)LightGridDim) - { - case 8: Context.SetPipelineState(m_FillLightGridCS_8 ); break; - case 16: Context.SetPipelineState(m_FillLightGridCS_16); break; - case 24: Context.SetPipelineState(m_FillLightGridCS_24); break; - case 32: Context.SetPipelineState(m_FillLightGridCS_32); break; - default: ASSERT(false); break; - } - - ColorBuffer& LinearDepth = g_LinearDepth[ TemporalEffects::GetFrameIndexMod2() ]; - - Context.TransitionResource(m_LightBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(LinearDepth, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_SceneDepthBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - - if (transparent) - { - Context.TransitionResource(m_LightGridTransparent, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(m_LightGridBitMaskTransparent, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - - Context.SetDynamicDescriptor(2, 0, m_LightGridTransparent.GetUAV()); - Context.SetDynamicDescriptor(2, 1, m_LightGridBitMaskTransparent.GetUAV()); - } - else - { - Context.TransitionResource(m_LightGrid, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - Context.TransitionResource(m_LightGridBitMask, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - - Context.SetDynamicDescriptor(2, 0, m_LightGrid.GetUAV()); - Context.SetDynamicDescriptor(2, 1, m_LightGridBitMask.GetUAV()); - } - - Context.SetDynamicDescriptor(1, 0, m_LightBuffer.GetSRV()); - Context.SetDynamicDescriptor(1, 1, LinearDepth.GetSRV()); - //Context.SetDynamicDescriptor(1, 1, g_SceneDepthBuffer.GetDepthSRV()); - - // todo: assumes 1920x1080 resolution - uint32_t tileCountX = Math::DivideByMultiple(g_SceneColorBuffer.GetWidth(), LightGridDim); - uint32_t tileCountY = Math::DivideByMultiple(g_SceneColorBuffer.GetHeight(), LightGridDim); - - float FarClipDist = camera.GetFarClip(); - float NearClipDist = camera.GetNearClip(); - const float RcpZMagic = NearClipDist / (FarClipDist - NearClipDist); - - __declspec(align(16)) struct CSConstants - { - Matrix4 ViewProjMatrix; - uint32_t ViewportWidth, ViewportHeight; - float InvTileDim; - float RcpZMagic; - uint32_t TileCount; - uint32_t Alpha; - } csConstants; - - // todo: assumes 1920x1080 resolution - csConstants.ViewportWidth = g_SceneColorBuffer.GetWidth(); - csConstants.ViewportHeight = g_SceneColorBuffer.GetHeight(); - csConstants.InvTileDim = 1.0f / LightGridDim; - csConstants.RcpZMagic = RcpZMagic; - csConstants.TileCount = tileCountX; - csConstants.ViewProjMatrix = camera.GetViewProjMatrix(); - csConstants.Alpha = transparent ? 1 : 0; - - Context.SetDynamicConstantBufferView(0, sizeof(CSConstants), &csConstants); - - Context.Dispatch(tileCountX, tileCountY, 1); - - Context.TransitionResource(m_LightBuffer, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - - if (transparent) - { - Context.TransitionResource(m_LightGridTransparent, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(m_LightGridBitMaskTransparent, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - } - else - { - Context.TransitionResource(m_LightGrid, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(m_LightGridBitMask, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Model/LightManager.h b/xess/samples/xess_demo/MiniEngine/Model/LightManager.h deleted file mode 100644 index e7d349a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/LightManager.h +++ /dev/null @@ -1,61 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): Alex Nankervis -// James Stanard -// - -// Modified 2022, Intel Corporation. -// Forward+ lighting support improved. - -#pragma once - -#include - -class StructuredBuffer; -class ByteAddressBuffer; -class ColorBuffer; -class ShadowBuffer; -class GraphicsContext; -class IntVar; -namespace Math -{ - class Vector3; - class Matrix4; - class Camera; -} - -namespace Lighting -{ - extern IntVar LightGridDim; - - enum { MaxLights = 128 }; - - //LightData m_LightData[MaxLights]; - extern StructuredBuffer m_LightBuffer; - - extern ByteAddressBuffer m_LightGrid; - extern ByteAddressBuffer m_LightGridBitMask; - - extern ByteAddressBuffer m_LightGridTransparent; - extern ByteAddressBuffer m_LightGridBitMaskTransparent; - - extern std::uint32_t m_FirstConeLight; - extern std::uint32_t m_FirstConeShadowedLight; - - extern ColorBuffer m_LightShadowArray; - extern ShadowBuffer m_LightShadowTempBuffer; - extern Math::Matrix4 m_LightShadowMatrix[MaxLights]; - - void InitializeResources(void); - void CreateRandomLights(const Math::Vector3 minBound, const Math::Vector3 maxBound); - void FillLightGrid(GraphicsContext& gfxContext, const Math::Camera& camera, bool transparent); - void Shutdown(void); -} diff --git a/xess/samples/xess_demo/MiniEngine/Model/MeshConvert.cpp b/xess/samples/xess_demo/MiniEngine/Model/MeshConvert.cpp deleted file mode 100644 index b8c800e..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/MeshConvert.cpp +++ /dev/null @@ -1,525 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// Chuck Walbourn (ATG) -// -// This code depends on DirectXTex -// - -// Modified 2022, Intel Corporation. -// glTF support improved. - -#include "MeshConvert.h" -#include "TextureConvert.h" -#include "glTF.h" -#include "Model.h" -#include "IndexOptimizePostTransform.h" -#include "../Core/VectorMath.h" -#include "DirectXMesh.h" - -using namespace DirectX; -using namespace glTF; -using namespace Math; - -static DXGI_FORMAT JointIndexFormat(const Accessor& accessor) -{ - switch (accessor.componentType) - { - case Accessor::kUnsignedByte: return DXGI_FORMAT_R8G8B8A8_UINT; - case Accessor::kUnsignedShort: return DXGI_FORMAT_R16G16B16A16_UINT; - default: - ASSERT("Invalid joint index format"); - return DXGI_FORMAT_UNKNOWN; - } -} - -static DXGI_FORMAT AccessorFormat(const Accessor& accessor) -{ - switch (accessor.componentType) - { - case Accessor::kUnsignedByte: - switch (accessor.type) - { - case Accessor::kScalar: return DXGI_FORMAT_R8_UNORM; - case Accessor::kVec2: return DXGI_FORMAT_R8G8_UNORM; - default: return DXGI_FORMAT_R8G8B8A8_UNORM; - } - case Accessor::kUnsignedShort: - switch (accessor.type) - { - case Accessor::kScalar: return DXGI_FORMAT_R16_UNORM; - case Accessor::kVec2: return DXGI_FORMAT_R16G16_UNORM; - default: return DXGI_FORMAT_R16G16B16A16_UNORM; - } - case Accessor::kFloat: - switch (accessor.type) - { - case Accessor::kScalar: return DXGI_FORMAT_R32_FLOAT; - case Accessor::kVec2: return DXGI_FORMAT_R32G32_FLOAT; - case Accessor::kVec3: return DXGI_FORMAT_R32G32B32_FLOAT; - default: return DXGI_FORMAT_R32G32B32A32_FLOAT; - } - default: - ASSERT("Invalid accessor format"); - return DXGI_FORMAT_UNKNOWN; - } -} - -uint32_t GetMaxIndex(const glTF::Primitive& inPrim) -{ - uint32_t maxIndex = 0; - - const uint32_t& indexCount = inPrim.indices->count; - - uint16_t compType = inPrim.indices->componentType; - - if (compType == Accessor::kByte) - { - int8_t* ib = (int8_t*)inPrim.indices->dataPtr; - for (uint32_t k = 0; k < indexCount; ++k) - maxIndex = std::max(ib[k], maxIndex); - } - else if (compType == Accessor::kUnsignedByte) - { - uint8_t* ib = (uint8_t*)inPrim.indices->dataPtr; - for (uint32_t k = 0; k < indexCount; ++k) - maxIndex = std::max(ib[k], maxIndex); - } - else if (compType == Accessor::kShort) - { - int16_t* ib = (int16_t*)inPrim.indices->dataPtr; - for (uint32_t k = 0; k < indexCount; ++k) - maxIndex = std::max(ib[k], maxIndex); - } - else if (compType == Accessor::kUnsignedShort) - { - uint16_t* ib = (uint16_t*)inPrim.indices->dataPtr; - for (uint32_t k = 0; k < indexCount; ++k) - maxIndex = std::max(ib[k], maxIndex); - } - else if (compType == Accessor::kUnsignedInt) - { - uint32_t* ib = (uint32_t*)inPrim.indices->dataPtr; - for (uint32_t k = 0; k < indexCount; ++k) - maxIndex = std::max(ib[k], maxIndex); - } - else if (compType == Accessor::kFloat) - { - float* ib = (float*)inPrim.indices->dataPtr; - for (uint32_t k = 0; k < indexCount; ++k) - maxIndex = std::max((uint32_t)ib[k], maxIndex); - } - else - { - LOG_ERROR("Invalid component type when looking for max index."); - } - - return maxIndex; -} - -void OptimizePrimitiveFaces(const glTF::Primitive& inPrim, bool b32BitIndices, Renderer::Primitive& outPrim) -{ - switch (inPrim.indices->componentType) - { - case Accessor::kByte: - if (b32BitIndices) - OptimizeFaces((int8_t*)inPrim.indices->dataPtr, inPrim.indices->count, (uint32_t*)outPrim.IB->data(), 64); - else - OptimizeFaces((int8_t*)inPrim.indices->dataPtr, inPrim.indices->count, (uint16_t*)outPrim.IB->data(), 64); - break; - case Accessor::kUnsignedByte: - if (b32BitIndices) - OptimizeFaces((uint8_t*)inPrim.indices->dataPtr, inPrim.indices->count, (uint32_t*)outPrim.IB->data(), 64); - else - OptimizeFaces((uint8_t*)inPrim.indices->dataPtr, inPrim.indices->count, (uint16_t*)outPrim.IB->data(), 64); - break; - case Accessor::kShort: - if (b32BitIndices) - OptimizeFaces((int16_t*)inPrim.indices->dataPtr, inPrim.indices->count, (uint32_t*)outPrim.IB->data(), 64); - else - OptimizeFaces((int16_t*)inPrim.indices->dataPtr, inPrim.indices->count, (uint16_t*)outPrim.IB->data(), 64); - break; - case Accessor::kUnsignedShort: - if (b32BitIndices) - OptimizeFaces((uint16_t*)inPrim.indices->dataPtr, inPrim.indices->count, (uint32_t*)outPrim.IB->data(), 64); - else - OptimizeFaces((uint16_t*)inPrim.indices->dataPtr, inPrim.indices->count, (uint16_t*)outPrim.IB->data(), 64); - break; - case Accessor::kUnsignedInt: - if (b32BitIndices) - OptimizeFaces((uint32_t*)inPrim.indices->dataPtr, inPrim.indices->count, (uint32_t*)outPrim.IB->data(), 64); - else - OptimizeFaces((uint32_t*)inPrim.indices->dataPtr, inPrim.indices->count, (uint16_t*)outPrim.IB->data(), 64); - break; - case Accessor::kFloat: - if (b32BitIndices) - OptimizeFaces((float*)inPrim.indices->dataPtr, inPrim.indices->count, (uint32_t*)outPrim.IB->data(), 64); - else - OptimizeFaces((float*)inPrim.indices->dataPtr, inPrim.indices->count, (uint16_t*)outPrim.IB->data(), 64); - break; - default: - LOG_ERROR("Unsupported component type for mesh index."); - return; - } -} - -void OptimizeMesh(Renderer::Primitive& outPrim, const glTF::Primitive& inPrim, const Math::Matrix4& localToObject) -{ - ASSERT(inPrim.attributes[0] != nullptr, "Must have POSITION"); - uint32_t vertexCount = inPrim.attributes[0]->count; - - void* indices = nullptr; - uint32_t indexCount; - bool b32BitIndices; - //uint32_t maxIndex = inPrim.maxIndex; - - if (inPrim.indices == nullptr) - { - ASSERT(inPrim.mode == 4, "Impossible primitive topology when lacking indices"); - - indexCount = vertexCount * 3; - //maxIndex = indexCount - 1; - if (indexCount > 0xFFFF) - { - b32BitIndices = true; - outPrim.IB = std::make_shared>(4 * indexCount); - indices = outPrim.IB->data(); - uint32_t* tmp = (uint32_t*)indices; - for (uint32_t i = 0; i < indexCount; ++i) - tmp[i] = i; - } - else - { - b32BitIndices = false; - outPrim.IB = std::make_shared>(2 * indexCount); - indices = outPrim.IB->data(); - uint16_t* tmp = (uint16_t*)indices; - for (uint16_t i = 0; i < indexCount; ++i) - tmp[i] = i; - } - } - else - { - switch (inPrim.mode) - { - default: - case 0: // POINT LIST - case 1: // LINE LIST - case 2: // LINE LOOP - case 3: // LINE STRIP - LOG_ERROR("Found unsupported primitive topology."); - return; - case 4: // TRIANGLE LIST - break; - case 5: // TODO: Convert TRIANGLE STRIP - case 6: // TODO: Convert TRIANGLE FAN - LOG_ERROR("Found an index buffer that needs to be converted to a triangle list."); - return; - } - - indices = inPrim.indices->dataPtr; - indexCount = inPrim.indices->count; - - //if (maxIndex == 0) - //{ - // maxIndex = GetMaxIndex(inPrim); - //} - - //b32BitIndices = maxIndex > 0xFFFF; - b32BitIndices = indexCount > 0xFFFF; - uint32_t indexSize = b32BitIndices ? 4 : 2; - - outPrim.IB = std::make_shared>(indexSize * indexCount); - - OptimizePrimitiveFaces(inPrim, b32BitIndices, outPrim); - - indices = outPrim.IB->data(); - } - - //ASSERT(maxIndex > 0); - - const bool HasNormals = inPrim.attributes[glTF::Primitive::kNormal] != nullptr; - const bool HasTangents = inPrim.attributes[glTF::Primitive::kTangent] != nullptr; - const bool HasUV0 = inPrim.attributes[glTF::Primitive::kTexcoord0] != nullptr; - const bool HasUV1 = inPrim.attributes[glTF::Primitive::kTexcoord1] != nullptr; - const bool HasJoints = inPrim.attributes[glTF::Primitive::kJoints0] != nullptr; - const bool HasWeights = inPrim.attributes[glTF::Primitive::kWeights0] != nullptr; - const bool HasSkin = HasJoints && HasWeights; - - std::vector InputElements; - InputElements.push_back({"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, glTF::Primitive::kPosition}); - if (HasNormals) - { - InputElements.push_back({"NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, glTF::Primitive::kNormal }); - } - if (HasTangents) - { - InputElements.push_back({"TANGENT", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, glTF::Primitive::kTangent }); - } - if (HasUV0) - { - InputElements.push_back({ "TEXCOORD", 0, - AccessorFormat(*inPrim.attributes[glTF::Primitive::kTexcoord0]), - glTF::Primitive::kTexcoord0 }); - } - if (HasUV1) - { - InputElements.push_back({ "TEXCOORD", 1, - AccessorFormat(*inPrim.attributes[glTF::Primitive::kTexcoord1]), - glTF::Primitive::kTexcoord1 }); - } - if (HasSkin) - { - InputElements.push_back({ "BLENDINDICES", 0, - JointIndexFormat(*inPrim.attributes[glTF::Primitive::kJoints0]), - glTF::Primitive::kJoints0 }); - InputElements.push_back({ "BLENDWEIGHT", 0, - AccessorFormat(*inPrim.attributes[glTF::Primitive::kWeights0]), - glTF::Primitive::kWeights0 }); - } - - VBReader vbr; - vbr.Initialize({InputElements.data(), (uint32_t)InputElements.size()}); - - for (uint32_t i = 0; i < Primitive::kNumAttribs; ++i) - { - Accessor* attrib = inPrim.attributes[i]; - if (attrib) - vbr.AddStream(attrib->dataPtr, vertexCount, i, attrib->stride); - } - - const glTF::Material& material = *inPrim.material; - - std::unique_ptr position; - std::unique_ptr normal; - std::unique_ptr tangent; - std::unique_ptr texcoord0; - std::unique_ptr texcoord1; - std::unique_ptr joints; - std::unique_ptr weights; - position.reset(new XMFLOAT3[vertexCount]); - normal.reset(new XMFLOAT3[vertexCount]); - - ASSERT_SUCCEEDED(vbr.Read(position.get(), "POSITION", 0, vertexCount)); - { - // Local space bounds - Vector3 sphereCenterLS = (Vector3(*(XMFLOAT3*)inPrim.minPos) + Vector3(*(XMFLOAT3*)inPrim.maxPos)) * 0.5f; - Scalar maxRadiusLSSq(kZero); - - // Object space bounds - // (This would be expressed better with an AffineTransform * Vector3) - Vector3 sphereCenterOS = Vector3(localToObject * Vector4(sphereCenterLS)); - Scalar maxRadiusOSSq(kZero); - - outPrim.m_BBoxLS = AxisAlignedBox(kZero); - outPrim.m_BBoxOS = AxisAlignedBox(kZero); - - for (uint32_t v = 0; v < vertexCount/*maxIndex*/; ++v) - { - Vector3 positionLS = Vector3(position[v]); - maxRadiusLSSq = Max(maxRadiusLSSq, LengthSquare(sphereCenterLS - positionLS)); - - outPrim.m_BBoxLS.AddPoint(positionLS); - - Vector3 positionOS = Vector3(localToObject * Vector4(positionLS)); - maxRadiusOSSq = Max(maxRadiusOSSq, LengthSquare(sphereCenterOS - positionOS)); - - outPrim.m_BBoxOS.AddPoint(positionOS); - } - - outPrim.m_BoundsLS = Math::BoundingSphere(sphereCenterLS, Sqrt(maxRadiusLSSq)); - outPrim.m_BoundsOS = Math::BoundingSphere(sphereCenterOS, Sqrt(maxRadiusOSSq)); - ASSERT(outPrim.m_BoundsOS.GetRadius() > 0.0f); - } - - if (HasNormals) - { - ASSERT_SUCCEEDED(vbr.Read(normal.get(), "NORMAL", 0, vertexCount)); - } - else - { - const size_t faceCount = indexCount / 3; - - if (b32BitIndices) - ComputeNormals((const uint32_t*)indices, faceCount, position.get(), vertexCount, CNORM_DEFAULT, normal.get()); - else - ComputeNormals((const uint16_t*)indices, faceCount, position.get(), vertexCount, CNORM_DEFAULT, normal.get()); - } - - if (HasUV0) - { - texcoord0.reset(new XMFLOAT2[vertexCount]); - ASSERT_SUCCEEDED(vbr.Read(texcoord0.get(), "TEXCOORD", 0, vertexCount)); - } - - if (HasUV1) - { - texcoord1.reset(new XMFLOAT2[vertexCount]); - ASSERT_SUCCEEDED(vbr.Read(texcoord1.get(), "TEXCOORD", 1, vertexCount)); - } - - if (HasTangents) - { - tangent.reset(new XMFLOAT4[vertexCount]); - ASSERT_SUCCEEDED(vbr.Read(tangent.get(), "TANGENT", 0, vertexCount)); - } - else - { - //ASSERT(maxIndex < vertexCount); - ASSERT(indexCount % 3 == 0); - - HRESULT hr = S_OK; - - if (HasUV0 && material.normalUV == 0) - { - tangent.reset(new XMFLOAT4[vertexCount]); - if (b32BitIndices) - { - hr = ComputeTangentFrame((uint32_t*)indices, indexCount / 3, position.get(), normal.get(), texcoord0.get(), - vertexCount, tangent.get()); - } - else - { - hr = ComputeTangentFrame((uint16_t*)indices, indexCount / 3, position.get(), normal.get(), texcoord0.get(), - vertexCount, tangent.get()); - } - } - else if (HasUV1 && material.normalUV == 1) - { - tangent.reset(new XMFLOAT4[vertexCount]); - if (b32BitIndices) - { - hr = ComputeTangentFrame((uint32_t*)indices, indexCount / 3, position.get(), normal.get(), texcoord1.get(), - vertexCount, tangent.get()); - } - else - { - hr = ComputeTangentFrame((uint16_t*)indices, indexCount / 3, position.get(), normal.get(), texcoord1.get(), - vertexCount, tangent.get()); - } - } - - ASSERT_SUCCEEDED(hr, "Error generating a tangent frame"); - } - - if (HasSkin) - { - joints.reset(new XMFLOAT4[vertexCount]); - weights.reset(new XMFLOAT4[vertexCount]); - ASSERT_SUCCEEDED(vbr.Read(joints.get(), "BLENDINDICES", 0, vertexCount)); - ASSERT_SUCCEEDED(vbr.Read(weights.get(), "BLENDWEIGHT", 0, vertexCount)); - } - - // Use VBWriter to generate a new, interleaved and compressed vertex buffer - std::vector OutputElements; - - outPrim.psoFlags = PSOFlags::kHasPosition | PSOFlags::kHasNormal; - OutputElements.push_back({"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D12_APPEND_ALIGNED_ELEMENT}); - OutputElements.push_back({"NORMAL", 0, DXGI_FORMAT_R10G10B10A2_UNORM, 0, D3D12_APPEND_ALIGNED_ELEMENT}); - if (tangent.get()) - { - OutputElements.push_back({"TANGENT", 0, DXGI_FORMAT_R10G10B10A2_UNORM, 0, D3D12_APPEND_ALIGNED_ELEMENT}); - outPrim.psoFlags |= PSOFlags::kHasTangent; - } - if (texcoord0.get()) - { - OutputElements.push_back({"TEXCOORD", 0, DXGI_FORMAT_R16G16_FLOAT, 0, D3D12_APPEND_ALIGNED_ELEMENT}); - outPrim.psoFlags |= PSOFlags::kHasUV0; - } - if (texcoord1.get()) - { - OutputElements.push_back({"TEXCOORD", 1, DXGI_FORMAT_R16G16_FLOAT, 0, D3D12_APPEND_ALIGNED_ELEMENT}); - outPrim.psoFlags |= PSOFlags::kHasUV1; - } - if (HasSkin) - { - OutputElements.push_back({ "BLENDINDICES", 0, DXGI_FORMAT_R16G16B16A16_UINT, 0, D3D12_APPEND_ALIGNED_ELEMENT }); - OutputElements.push_back({ "BLENDWEIGHT", 0, DXGI_FORMAT_R16G16B16A16_UNORM, 0, D3D12_APPEND_ALIGNED_ELEMENT }); - outPrim.psoFlags |= PSOFlags::kHasSkin; - } - if (material.alphaBlend) - outPrim.psoFlags |= PSOFlags::kAlphaBlend; - if (material.alphaTest) - outPrim.psoFlags |= PSOFlags::kAlphaTest; - if (material.twoSided) - outPrim.psoFlags |= PSOFlags::kTwoSided; - - D3D12_INPUT_LAYOUT_DESC layout = {OutputElements.data(), (uint32_t)OutputElements.size()}; - - VBWriter vbw; - vbw.Initialize(layout); - - uint32_t offsets[10]; - uint32_t strides[D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT]; - ComputeInputLayout(layout, offsets, strides); - uint32_t stride = strides[0]; - - outPrim.VB = std::make_shared>(stride * vertexCount); - ASSERT_SUCCEEDED(vbw.AddStream(outPrim.VB->data(), vertexCount, 0, stride)); - - vbw.Write( position.get(), "POSITION", 0, vertexCount ); - vbw.Write( normal.get(), "NORMAL", 0, vertexCount, true ); - if (tangent.get()) - vbw.Write( tangent.get(), "TANGENT", 0, vertexCount, true ); - if (texcoord0.get()) - vbw.Write( texcoord0.get(), "TEXCOORD", 0, vertexCount ); - if (texcoord1.get()) - vbw.Write( texcoord1.get(), "TEXCOORD", 1, vertexCount ); - if (HasSkin) - { - vbw.Write(joints.get(), "BLENDINDICES", 0, vertexCount); - vbw.Write(weights.get(), "BLENDWEIGHT", 0, vertexCount); - } - - // Now write a VB for positions only (or positions and UV when alpha testing) - uint32_t depthStride = 12; - std::vector DepthElements; - DepthElements.push_back({"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D12_APPEND_ALIGNED_ELEMENT}); - if (material.alphaTest) - { - depthStride += 4; - DepthElements.push_back({"TEXCOORD", 0, DXGI_FORMAT_R16G16_FLOAT, 0, D3D12_APPEND_ALIGNED_ELEMENT}); - } - if (HasSkin) - { - depthStride += 16; - DepthElements.push_back({ "BLENDINDICES", 0, DXGI_FORMAT_R16G16B16A16_UINT, 0, D3D12_APPEND_ALIGNED_ELEMENT }); - DepthElements.push_back({ "BLENDWEIGHT", 0, DXGI_FORMAT_R16G16B16A16_UNORM, 0, D3D12_APPEND_ALIGNED_ELEMENT }); - } - - VBWriter dvbw; - dvbw.Initialize({DepthElements.data(), (uint32_t)DepthElements.size()}); - - outPrim.DepthVB = std::make_shared>(depthStride * vertexCount); - ASSERT_SUCCEEDED(dvbw.AddStream(outPrim.DepthVB->data(), vertexCount, 0, depthStride)); - - dvbw.Write( position.get(), "POSITION", 0, vertexCount ); - if (material.alphaTest) - { - dvbw.Write(material.baseColorUV ? texcoord1.get() : texcoord0.get(), "TEXCOORD", 0, vertexCount); - } - if (HasSkin) - { - dvbw.Write(joints.get(), "BLENDINDICES", 0, vertexCount); - dvbw.Write(weights.get(), "BLENDWEIGHT", 0, vertexCount); - } - - ASSERT(material.index < 0x8000, "Only 15-bit material indices allowed"); - - outPrim.vertexStride = (uint16_t)stride; - outPrim.index32 = b32BitIndices ? 1 : 0; - outPrim.materialIdx = material.index; - - outPrim.primCount = indexCount; - - // TODO: Generate optimized depth-only streams -} - diff --git a/xess/samples/xess_demo/MiniEngine/Model/MeshConvert.h b/xess/samples/xess_demo/MiniEngine/Model/MeshConvert.h deleted file mode 100644 index 15459c4..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/MeshConvert.h +++ /dev/null @@ -1,50 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "glTF.h" -#include "../Core/Math/BoundingSphere.h" -#include "../Core/Math/BoundingBox.h" - -#include -#include - -namespace Renderer -{ - using namespace Math; - - struct Primitive - { - BoundingSphere m_BoundsLS; // local space bounds - BoundingSphere m_BoundsOS; // object space bounds - AxisAlignedBox m_BBoxLS; // local space AABB - AxisAlignedBox m_BBoxOS; // object space AABB - Utility::ByteArray VB; - Utility::ByteArray IB; - Utility::ByteArray DepthVB; - uint32_t primCount; - union - { - uint32_t hash; - struct { - uint32_t psoFlags : 16; - uint32_t index32 : 1; - uint32_t materialIdx : 15; - }; - }; - uint16_t vertexStride; - }; -} - -void OptimizeMesh( Renderer::Primitive& outPrim, const glTF::Primitive& inPrim, const Math::Matrix4& localToObject ); \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Model/Model.cpp b/xess/samples/xess_demo/MiniEngine/Model/Model.cpp deleted file mode 100644 index fefdd80..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Model.cpp +++ /dev/null @@ -1,282 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "Model.h" -#include "Renderer.h" -#include "ConstantBuffers.h" - -using namespace Math; -using namespace Renderer; - -void Model::Destroy() -{ - m_BoundingSphere = BoundingSphere(kZero); - m_DataBuffer.Destroy(); - m_MaterialConstants.Destroy(); - m_NumNodes = 0; - m_NumMeshes = 0; - m_MeshData = nullptr; - m_SceneGraph = nullptr; -} - -void Model::Render( - MeshSorter& sorter, - const GpuBuffer& meshConstants, - const ScaleAndTranslation sphereTransforms[], - const Joint* skeleton ) const -{ - // Pointer to current mesh - const uint8_t* pMesh = m_MeshData.get(); - - const Frustum& frustum = sorter.GetViewFrustum(); - const AffineTransform& viewMat = (const AffineTransform&)sorter.GetViewMatrix(); - - for (uint32_t i = 0; i < m_NumMeshes; ++i) - { - const Mesh& mesh = *(const Mesh*)pMesh; - - const ScaleAndTranslation& sphereXform = sphereTransforms[mesh.meshCBV]; - BoundingSphere sphereLS((const XMFLOAT4*)mesh.bounds); - BoundingSphere sphereWS = sphereXform * sphereLS; - BoundingSphere sphereVS = BoundingSphere(viewMat * sphereWS.GetCenter(), sphereWS.GetRadius()); - - //if (frustum.IntersectSphere(sphereVS)) - if (!sorter.IsCullEnabled() || frustum.IntersectSphere(sphereVS)) - { - float distance = -sphereVS.GetCenter().GetZ() - sphereVS.GetRadius(); - sorter.AddMesh(mesh, distance, - meshConstants.GetGpuVirtualAddress() + sizeof(MeshConstants) * mesh.meshCBV, - m_MaterialConstants.GetGpuVirtualAddress() + sizeof(MaterialConstants) * mesh.materialCBV, - m_DataBuffer.GetGpuVirtualAddress(), skeleton); - } - - pMesh += sizeof(Mesh) + (mesh.numDraws - 1) * sizeof(Mesh::Draw); - } -} - -void ModelInstance::Render(MeshSorter& sorter) const -{ - if (m_Model != nullptr) - { - //const Frustum& frustum = sorter.GetWorldFrustum(); - m_Model->Render(sorter, m_MeshConstantsGPU, (const ScaleAndTranslation*)m_BoundingSphereTransforms.get(), - m_Skeleton.get()); - } -} - -ModelInstance::ModelInstance( std::shared_ptr sourceModel ) - : m_Model(sourceModel), m_Locator(kIdentity) -{ - static_assert((sizeof(MeshConstants) % 256) == 0, "CBVs need 256 byte alignment"); - if (sourceModel == nullptr) - { - m_MeshConstantsCPU.Destroy(); - m_MeshConstantsGPU.Destroy(); - m_BoundingSphereTransforms = nullptr; - m_AnimGraph = nullptr; - m_AnimState.clear(); - m_Skeleton = nullptr; - } - else - { - m_MeshConstantsCPU.Create(L"Mesh Constant Upload Buffer", sourceModel->m_NumNodes * sizeof(MeshConstants)); - m_MeshConstantsGPU.Create(L"Mesh Constant GPU Buffer", sourceModel->m_NumNodes, sizeof(MeshConstants)); - m_BoundingSphereTransforms.reset(new __m128[sourceModel->m_NumNodes]); - m_Skeleton.reset(new Joint[sourceModel->m_NumJoints]); - - if (sourceModel->m_NumAnimations > 0) - { - m_AnimGraph.reset(new GraphNode[sourceModel->m_NumNodes]); - std::memcpy(m_AnimGraph.get(), sourceModel->m_SceneGraph.get(), sourceModel->m_NumNodes * sizeof(GraphNode)); - m_AnimState.resize(sourceModel->m_NumAnimations); - } - else - { - m_AnimGraph = nullptr; - m_AnimState.clear(); - } - } -} - -ModelInstance::ModelInstance( const ModelInstance& modelInstance ) - : ModelInstance(modelInstance.m_Model) -{ -} - -ModelInstance& ModelInstance::operator=( std::shared_ptr sourceModel ) -{ - m_Model = sourceModel; - m_Locator = UniformTransform(kIdentity); - if (sourceModel == nullptr) - { - m_MeshConstantsCPU.Destroy(); - m_MeshConstantsGPU.Destroy(); - m_BoundingSphereTransforms = nullptr; - m_AnimGraph = nullptr; - m_AnimState.clear(); - m_Skeleton = nullptr; - } - else - { - m_MeshConstantsCPU.Create(L"Mesh Constant Upload Buffer", sourceModel->m_NumNodes * sizeof(MeshConstants)); - m_MeshConstantsGPU.Create(L"Mesh Constant GPU Buffer", sourceModel->m_NumNodes, sizeof(MeshConstants)); - m_BoundingSphereTransforms.reset(new __m128[sourceModel->m_NumNodes]); - m_Skeleton.reset(new Joint[sourceModel->m_NumJoints]); - - if (sourceModel->m_NumAnimations > 0) - { - m_AnimGraph.reset(new GraphNode[sourceModel->m_NumNodes]); - std::memcpy(m_AnimGraph.get(), sourceModel->m_SceneGraph.get(), sourceModel->m_NumNodes * sizeof(GraphNode)); - m_AnimState.resize(sourceModel->m_NumAnimations); - } - else - { - m_AnimGraph = nullptr; - m_AnimState.clear(); - } - } - return *this; -} - -void ModelInstance::Update(GraphicsContext& gfxContext, float deltaTime) -{ - if (m_Model == nullptr) - return; - - static const size_t kMaxStackDepth = 32; - - size_t stackIdx = 0; - Matrix4 matrixStack[kMaxStackDepth]; - Matrix4 ParentMatrix = Matrix4((AffineTransform)m_Locator); - - ScaleAndTranslation* boundingSphereTransforms = (ScaleAndTranslation*)m_BoundingSphereTransforms.get(); - MeshConstants* cb = (MeshConstants*)m_MeshConstantsCPU.Map(); - - if (m_AnimGraph) - { - UpdateAnimations(deltaTime); - - for (uint32_t i = 0; i < m_Model->m_NumNodes; ++i) - { - GraphNode& node = m_AnimGraph[i]; - - // Regenerate the 3x3 matrix if it has scale or rotation - if (node.staleMatrix) - { - node.staleMatrix = false; - node.xform.Set3x3(Matrix3(node.rotation) * Matrix3::MakeScale(node.scale)); - } - } - } - - const GraphNode* sceneGraph = m_AnimGraph ? m_AnimGraph.get() : m_Model->m_SceneGraph.get(); - - // Traverse the scene graph in depth first order. This is the same as linear order - // for how the nodes are stored in memory. Uses a matrix stack instead of recursion. - for (const GraphNode* Node = sceneGraph; ; ++Node) - { - Matrix4 xform = Node->xform; - if (!Node->skeletonRoot) - xform = ParentMatrix * xform; - - // Concatenate the transform with the parent's matrix and update the matrix list - { - // Scoped so that I don't forget that I'm pointing to write-combined memory and - // should not read from it. - MeshConstants& cbv = cb[Node->matrixIdx]; - cbv.World = xform; - cbv.WorldIT = InverseTranspose(xform.Get3x3()); - - Scalar scaleXSqr = LengthSquare((Vector3)ParentMatrix.GetX()); - Scalar scaleYSqr = LengthSquare((Vector3)ParentMatrix.GetY()); - Scalar scaleZSqr = LengthSquare((Vector3)ParentMatrix.GetZ()); - Scalar sphereScale = Sqrt(Max(Max(scaleXSqr, scaleYSqr), scaleZSqr)); - boundingSphereTransforms[Node->matrixIdx] = ScaleAndTranslation((Vector3)ParentMatrix.GetW(), sphereScale); - } - - // If the next node will be a descendent, replace the parent matrix with our new matrix - if (Node->hasChildren) - { - // ...but if we have siblings, make sure to backup our current parent matrix on the stack - if (Node->hasSibling) - { - ASSERT(stackIdx < kMaxStackDepth, "Overflowed the matrix stack"); - matrixStack[stackIdx++] = ParentMatrix; - } - ParentMatrix = xform; - } - else if (!Node->hasSibling) - { - // There are no more siblings. If the stack is empty, we are done. Otherwise, pop - // a matrix off the stack and continue. - if (stackIdx == 0) - break; - - ParentMatrix = matrixStack[--stackIdx]; - } - } - - // Update skeletal joints - for (uint32_t i = 0; i < m_Model->m_NumJoints; ++i) - { - Joint& joint = m_Skeleton[i]; - joint.posXform = cb[m_Model->m_JointIndices[i]].World * m_Model->m_JointIBMs[i]; - joint.nrmXform = InverseTranspose(joint.posXform.Get3x3()); - } - - m_MeshConstantsCPU.Unmap(); - - gfxContext.TransitionResource(m_MeshConstantsGPU, D3D12_RESOURCE_STATE_COPY_DEST, true); - gfxContext.GetCommandList()->CopyBufferRegion(m_MeshConstantsGPU.GetResource(), 0, m_MeshConstantsCPU.GetResource(), 0, m_MeshConstantsCPU.GetBufferSize()); - gfxContext.TransitionResource(m_MeshConstantsGPU, D3D12_RESOURCE_STATE_GENERIC_READ); -} - -void ModelInstance::Resize( float newRadius ) -{ - if (m_Model == nullptr) - return; - - m_Locator.SetScale(newRadius / m_Model->m_BoundingSphere.GetRadius()); -} - -Vector3 ModelInstance::GetCenter() const -{ - if (m_Model == nullptr) - return Vector3(kOrigin); - - return m_Locator * m_Model->m_BoundingSphere.GetCenter(); -} - -Scalar ModelInstance::GetRadius() const -{ - if (m_Model == nullptr) - return Scalar(kZero); - - return m_Locator.GetScale() * m_Model->m_BoundingSphere.GetRadius(); -} - -Math::BoundingSphere ModelInstance::GetBoundingSphere() const -{ - if (m_Model == nullptr) - return BoundingSphere(kZero); - - return m_Locator * m_Model->m_BoundingSphere; -} - -Math::OrientedBox ModelInstance::GetBoundingBox() const -{ - if (m_Model == nullptr) - return AxisAlignedBox(Vector3(kZero), Vector3(kZero)); - - return m_Locator * m_Model->m_BoundingBox; -} diff --git a/xess/samples/xess_demo/MiniEngine/Model/Model.h b/xess/samples/xess_demo/MiniEngine/Model/Model.h deleted file mode 100644 index e075417..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Model.h +++ /dev/null @@ -1,177 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "Animation.h" -#include "../Core/GpuBuffer.h" -#include "../Core/VectorMath.h" -#include "../Core/Camera.h" -#include "../Core/CommandContext.h" -#include "../Core/UploadBuffer.h" -#include "../Core/TextureManager.h" -#include "../Core/Math/BoundingBox.h" -#include "../Core/Math/BoundingSphere.h" -#include - -namespace Renderer -{ - class MeshSorter; -} - -// -// To request a PSO index, provide flags that describe the kind of PSO -// you need. If one has not yet been created, it will be created. -// -namespace PSOFlags -{ - enum : uint16_t - { - kHasPosition = 0x001, // Required - kHasNormal = 0x002, // Required - kHasTangent = 0x004, - kHasUV0 = 0x008, // Required (for now) - kHasUV1 = 0x010, - kAlphaBlend = 0x020, - kAlphaTest = 0x040, - kTwoSided = 0x080, - kHasSkin = 0x100, // Implies having indices and weights - }; -} - -struct Mesh -{ - float bounds[4]; // A bounding sphere - uint32_t vbOffset; // BufferLocation - Buffer.GpuVirtualAddress - uint32_t vbSize; // SizeInBytes - uint32_t vbDepthOffset; // BufferLocation - Buffer.GpuVirtualAddress - uint32_t vbDepthSize; // SizeInBytes - uint32_t ibOffset; // BufferLocation - Buffer.GpuVirtualAddress - uint32_t ibSize; // SizeInBytes - uint8_t vbStride; // StrideInBytes - uint8_t ibFormat; // DXGI_FORMAT - uint16_t meshCBV; // Index of mesh constant buffer - uint16_t materialCBV; // Index of material constant buffer - uint16_t srvTable; // Offset into SRV descriptor heap for textures - uint16_t samplerTable; // Offset into sampler descriptor heap for samplers - uint16_t psoFlags; // Flags needed to request a PSO - uint16_t pso; // Index of pipeline state object - uint16_t numJoints; // Number of skeleton joints when skinning - uint16_t startJoint; // Flat offset to first joint index - uint16_t numDraws; // Number of draw groups - - struct Draw - { - uint32_t primCount; // Number of indices = 3 * number of triangles - uint32_t startIndex; // Offset to first index in index buffer - uint32_t baseVertex; // Offset to first vertex in vertex buffer - }; - Draw draw[1]; // Actually 1 or more draws -}; - -struct GraphNode // 96 bytes -{ - Math::Matrix4 xform; - Math::Quaternion rotation; - Math::XMFLOAT3 scale; - - uint32_t matrixIdx : 28; - uint32_t hasSibling : 1; - uint32_t hasChildren : 1; - uint32_t staleMatrix : 1; - uint32_t skeletonRoot : 1; -}; - -struct Joint -{ - Math::Matrix4 posXform; - Math::Matrix3 nrmXform; -}; - -class Model -{ -public: - - ~Model() { Destroy(); } - - void Render(Renderer::MeshSorter& sorter, - const GpuBuffer& meshConstants, - const Math::ScaleAndTranslation sphereTransforms[], - const Joint* skeleton) const; - - Math::BoundingSphere m_BoundingSphere; // Object-space bounding sphere - Math::AxisAlignedBox m_BoundingBox; - ByteAddressBuffer m_DataBuffer; - ByteAddressBuffer m_MaterialConstants; - uint32_t m_NumNodes; - uint32_t m_NumMeshes; - uint32_t m_NumAnimations; - uint32_t m_NumJoints; - std::unique_ptr m_MeshData; - std::unique_ptr m_SceneGraph; - std::vector textures; - std::unique_ptr m_KeyFrameData; - std::unique_ptr m_CurveData; - std::unique_ptr m_Animations; - std::unique_ptr m_JointIndices; - std::unique_ptr m_JointIBMs; - -protected: - void Destroy(); -}; - -class ModelInstance -{ -public: - ModelInstance() {} - ~ModelInstance() { - m_MeshConstantsCPU.Destroy(); - m_MeshConstantsGPU.Destroy(); - } - ModelInstance( std::shared_ptr sourceModel ); - ModelInstance( const ModelInstance& modelInstance ); - - ModelInstance& operator=( std::shared_ptr sourceModel ); - - bool IsNull(void) const { return m_Model == nullptr; } - - void Update(GraphicsContext& gfxContext, float deltaTime); - void Render(Renderer::MeshSorter& sorter) const; - - void Resize(float newRadius); - Math::Vector3 GetCenter() const; - Math::Scalar GetRadius() const; - Math::BoundingSphere GetBoundingSphere() const; - Math::OrientedBox GetBoundingBox() const; - - size_t GetNumAnimations(void) const { return m_AnimState.size(); } - void PlayAnimation(uint32_t animIdx, bool loop); - void PauseAnimation(uint32_t animIdx); - void ResetAnimation(uint32_t animIdx); - void StopAnimation(uint32_t animIdx); - void UpdateAnimations(float deltaTime); - void LoopAllAnimations(void); - - const Model* GetModel() const { return m_Model.get(); } - -private: - std::shared_ptr m_Model; - UploadBuffer m_MeshConstantsCPU; - ByteAddressBuffer m_MeshConstantsGPU; - std::unique_ptr<__m128[]> m_BoundingSphereTransforms; - Math::UniformTransform m_Locator; - - std::unique_ptr m_AnimGraph; // A copy of the scene graph when instancing animation - std::vector m_AnimState; // Per-animation (not per-curve) - std::unique_ptr m_Skeleton; -}; diff --git a/xess/samples/xess_demo/MiniEngine/Model/Model.vcxproj b/xess/samples/xess_demo/MiniEngine/Model/Model.vcxproj deleted file mode 100644 index 4acb68b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Model.vcxproj +++ /dev/null @@ -1,198 +0,0 @@ - - - - - Debug - x64 - - - Profile - x64 - - - Release - x64 - - - - Model - {5D3AEEFB-8789-48E5-9BD9-09C667052D09} - en-US - Win32Proj - 16.0 - 10.0.19041.0 - Native - - - - StaticLibrary - v142 - Unicode - false - false - - - - - - - - - - - - - - NotUsing - - true - - - - - d3d11.lib;dxguid.lib;winmm.lib;comctl32.lib;%(AdditionalDependencies) - Windows - true - - - true - - - ../../MiniEngine - - - ../../MiniEngine - - - ../../MiniEngine - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Pixel - - - Vertex - - - Vertex - - - Pixel - - - Vertex - - - Vertex - - - Pixel - - - Vertex - - - Vertex - - - Pixel - - - Vertex - - - Vertex - - - Vertex - - - Vertex - - - Vertex - - - Vertex - - - Pixel - - - Vertex - - - - - - - Pixel - - - Pixel - - - Vertex - - - Pixel - - - Vertex - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Model/Model.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Model/Model.vcxproj.filters deleted file mode 100644 index 9ac5839..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Model.vcxproj.filters +++ /dev/null @@ -1,203 +0,0 @@ - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - {3e74f37f-1e1e-47ed-9c44-213389384278} - - - {9169b7c9-f1a7-41d4-9098-58de36da850c} - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - - Shaders - - - Shaders - - - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - Shaders - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Model/ModelConvert.cpp b/xess/samples/xess_demo/MiniEngine/Model/ModelConvert.cpp deleted file mode 100644 index 72e85d8..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/ModelConvert.cpp +++ /dev/null @@ -1,559 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// Chuck Walbourn (ATG) -// -// This code depends on DirectXTex -// - -// Modified 2022, Intel Corporation. -// glTF support improved. - -#include "ModelLoader.h" -#include "Renderer.h" -#include "glTF.h" -#include "TextureConvert.h" -#include "MeshConvert.h" -#include "TextureManager.h" -#include "GraphicsCommon.h" -#include "../Core/Utility.h" -#include "../Core/Math/Common.h" - -#include -#include -#include - -using namespace DirectX; -using namespace Math; -using namespace Renderer; -using namespace Graphics; - -static inline Vector3 SafeNormalize(Vector3 x) -{ - float lenSq = LengthSquare(x); - return lenSq < 1e-10f ? Vector3(kXUnitVector) : x * RecipSqrt(lenSq); -} - -void Renderer::CompileMesh( - std::vector& meshList, - std::vector& bufferMemory, - glTF::Mesh& srcMesh, - uint32_t matrixIdx, - const Matrix4& localToObject, - BoundingSphere& boundingSphere, - AxisAlignedBox& boundingBox - ) -{ - // We still have a lot of work to do. Now that we know about all of the primitives in this mesh - // and have standardized their vertex buffer streams, we must set out to identify which primitives - // have the same vertex format and material. These can share a PSO and Vertex/Index buffer views. - // There may be more than one draw call per group due to 16-bit indices. - - size_t totalVertexSize = 0; - size_t totalDepthVertexSize = 0; - size_t totalIndexSize = 0; - - BoundingSphere sphereOS(kZero); - AxisAlignedBox bboxOS(kZero); - - std::vector primitives(srcMesh.primitives.size()); - for (uint32_t i = 0; i < primitives.size(); ++i) - { - OptimizeMesh(primitives[i], srcMesh.primitives[i], localToObject); - sphereOS = sphereOS.Union(primitives[i].m_BoundsOS); - bboxOS.AddBoundingBox(primitives[i].m_BBoxOS); - } - - boundingSphere = sphereOS; - boundingBox = bboxOS; - - std::map> renderMeshes; - for (auto& prim : primitives) - { - uint32_t hash = prim.hash; - renderMeshes[hash].push_back(&prim); - totalVertexSize += prim.VB->size(); - totalDepthVertexSize += prim.DepthVB->size(); - } - - // for each mesh - for (auto& iter : renderMeshes) - { - uint32_t meshIndexSize = 0; - // for each sub-mesh (a draw) - for (auto& draw : iter.second) - { - meshIndexSize += (uint32_t)draw->IB->size(); - } - - totalIndexSize += Math::AlignUp(meshIndexSize, 4); - } - - uint32_t totalBufferSize = (uint32_t)Math::AlignUp(totalVertexSize + totalDepthVertexSize, 4) + (uint32_t)totalIndexSize; - - Utility::ByteArray stagingBuffer; - stagingBuffer.reset(new std::vector(totalBufferSize)); - uint8_t* uploadMem = stagingBuffer->data(); - - uint32_t curVBOffset = 0; - uint32_t curDepthVBOffset = (uint32_t)totalVertexSize; - uint32_t curIBOffset = Math::AlignUp(curDepthVBOffset + (uint32_t)totalDepthVertexSize, 4); - - // for each mesh - for (auto& iter : renderMeshes) - { - size_t numDraws = iter.second.size(); - Mesh* mesh = (Mesh*)malloc(sizeof(Mesh) + sizeof(Mesh::Draw) * (numDraws - 1)); - size_t vbSize = 0; - size_t vbDepthSize = 0; - size_t ibSize = 0; - - // Compute local space bounding sphere for all submeshes - BoundingSphere collectiveSphere(kZero); - - // for each sub-mesh (a draw) - for (auto& draw : iter.second) - { - vbSize += draw->VB->size(); - vbDepthSize += draw->DepthVB->size(); - ibSize += draw->IB->size(); - collectiveSphere = collectiveSphere.Union(draw->m_BoundsOS); - } - - ibSize = (uint32_t)Math::AlignUp(ibSize, 4); - - mesh->bounds[0] = collectiveSphere.GetCenter().GetX(); - mesh->bounds[1] = collectiveSphere.GetCenter().GetY(); - mesh->bounds[2] = collectiveSphere.GetCenter().GetZ(); - mesh->bounds[3] = collectiveSphere.GetRadius(); - mesh->vbOffset = (uint32_t)bufferMemory.size() + curVBOffset; - mesh->vbSize = (uint32_t)vbSize; - mesh->vbDepthOffset = (uint32_t)bufferMemory.size() + curDepthVBOffset; - mesh->vbDepthSize = (uint32_t)vbDepthSize; - mesh->ibOffset = (uint32_t)bufferMemory.size() + curIBOffset; - mesh->ibSize = (uint32_t)ibSize; - mesh->vbStride = (uint8_t)iter.second[0]->vertexStride; - mesh->ibFormat = uint8_t(iter.second[0]->index32 ? DXGI_FORMAT_R32_UINT : DXGI_FORMAT_R16_UINT); - mesh->meshCBV = (uint16_t)matrixIdx; - mesh->materialCBV = iter.second[0]->materialIdx; - mesh->psoFlags = iter.second[0]->psoFlags; - mesh->pso = 0xFFFF; - if (srcMesh.skin >= 0) - { - mesh->numJoints = 0xFFFF; - mesh->startJoint = (uint16_t)srcMesh.skin; - } - else - { - mesh->numJoints = 0; - mesh->startJoint = 0xFFFF; - } - - mesh->numDraws = (uint16_t)numDraws; - - uint32_t drawIdx = 0; - uint32_t curVertOffset = 0; - uint32_t curDepthVertOffset = 0; - uint32_t curIndexOffset = 0; - - // for each sub-mesh (a draw) - for (auto& draw : iter.second) - { - Mesh::Draw& d = mesh->draw[drawIdx++]; - d.primCount = draw->primCount; - d.baseVertex = curVertOffset / draw->vertexStride; - d.startIndex = curIndexOffset >> (draw->index32 + 1); - - std::memcpy(uploadMem + curVBOffset + curVertOffset, draw->VB->data(), draw->VB->size()); - curVertOffset += (uint32_t)draw->VB->size(); - - std::memcpy(uploadMem + curDepthVBOffset + curDepthVertOffset, draw->DepthVB->data(), draw->DepthVB->size()); - curDepthVertOffset += (uint32_t)draw->DepthVB->size(); - - std::memcpy(uploadMem + curIBOffset + curIndexOffset, draw->IB->data(), draw->IB->size()); - curIndexOffset += (uint32_t)draw->IB->size(); - } - - curVBOffset += (uint32_t)vbSize; - curDepthVBOffset += (uint32_t)vbDepthSize; - curIBOffset += (uint32_t)ibSize; - - meshList.push_back(mesh); - } - - bufferMemory.insert(bufferMemory.end(), stagingBuffer->begin(), stagingBuffer->end()); -} - - -static uint32_t WalkGraph( - std::vector& sceneGraph, - BoundingSphere& modelBSphere, - AxisAlignedBox& modelBBox, - std::vector& meshList, - std::vector& bufferMemory, - const std::vector& siblings, - uint32_t curPos, - const Matrix4& xform - ) -{ - size_t numSiblings = siblings.size(); - - for (size_t i = 0; i < numSiblings; ++i) - { - glTF::Node* curNode = siblings[i]; - GraphNode& thisGraphNode = sceneGraph[curPos]; - thisGraphNode.hasChildren = 0; - thisGraphNode.hasSibling = 0; - thisGraphNode.matrixIdx = curPos; - thisGraphNode.skeletonRoot = curNode->skeletonRoot; - curNode->linearIdx = curPos; - - // They might not be used, but we have space to hold the neutral values which could be - // useful when updating the matrix via animation. - std::memcpy((float*)&thisGraphNode.scale, curNode->scale, sizeof(curNode->scale)); - std::memcpy((float*)&thisGraphNode.rotation, curNode->rotation, sizeof(curNode->rotation)); - - if (curNode->hasMatrix) - { - std::memcpy((float*)&thisGraphNode.xform, curNode->matrix, sizeof(curNode->matrix)); - } - else - { - thisGraphNode.xform = Matrix4( - Matrix3(thisGraphNode.rotation) * Matrix3::MakeScale(thisGraphNode.scale), - Vector3(*(const XMFLOAT3*)curNode->translation) - ); - } - - const Matrix4 LocalXform = xform * thisGraphNode.xform; - - if (!curNode->pointsToCamera && curNode->mesh != nullptr) - { - BoundingSphere sphereOS; - AxisAlignedBox boxOS; - CompileMesh(meshList, bufferMemory, *curNode->mesh, curPos, LocalXform, sphereOS, boxOS); - modelBSphere = modelBSphere.Union(sphereOS); - modelBBox.AddBoundingBox(boxOS); - } - - uint32_t nextPos = curPos + 1; - - if (curNode->children.size() > 0) - { - thisGraphNode.hasChildren = 1; - nextPos = WalkGraph(sceneGraph, modelBSphere, modelBBox, meshList, bufferMemory, curNode->children, nextPos, LocalXform); - } - - // Are there more siblings? - if (i + 1 < numSiblings) - { - thisGraphNode.hasSibling = 1; - } - - curPos = nextPos; - } - - return curPos; -} - -inline void CompileTexture(const std::wstring& basePath, const std::string& fileName, uint8_t flags) -{ - CompileTextureOnDemand(basePath + Utility::UTF8ToWideString(fileName), flags); -} - -inline void SetTextureOptions(std::map& optionsMap, glTF::Texture* texture, uint8_t options) -{ - if (texture && texture->source && optionsMap.find(texture->source->path) == optionsMap.end()) - optionsMap[texture->source->path] = options; -} - -void BuildMaterials(ModelData& model, const glTF::Asset& asset) -{ - static_assert((sizeof(MaterialConstants) % 256) == 0, "CBVs need 256 byte alignment"); - - // Replace texture filename extensions with "DDS" in the string table - model.m_TextureNames.resize(asset.m_images.size()); - for (size_t i = 0; i < asset.m_images.size(); ++i) - model.m_TextureNames[i] = asset.m_images[i].path; - - std::map textureOptions; - - const uint32_t numMaterials = (uint32_t)asset.m_materials.size(); - - model.m_MaterialConstants.resize(numMaterials); - model.m_MaterialTextures.resize(numMaterials); - - for (uint32_t i = 0; i < numMaterials; ++i) - { - const glTF::Material& srcMat = asset.m_materials[i]; - - MaterialConstantData& material = model.m_MaterialConstants[i]; - material.baseColorFactor[0] = srcMat.baseColorFactor[0]; - material.baseColorFactor[1] = srcMat.baseColorFactor[1]; - material.baseColorFactor[2] = srcMat.baseColorFactor[2]; - material.baseColorFactor[3] = srcMat.baseColorFactor[3]; - material.emissiveFactor[0] = srcMat.emissiveFactor[0]; - material.emissiveFactor[1] = srcMat.emissiveFactor[1]; - material.emissiveFactor[2] = srcMat.emissiveFactor[2]; - material.normalTextureScale = srcMat.normalTextureScale; - material.metallicFactor = srcMat.metallicFactor; - material.roughnessFactor = srcMat.roughnessFactor; - material.flags = srcMat.flags; - - MaterialTextureData& dstMat = model.m_MaterialTextures[i]; - dstMat.addressModes = 0; - - for (uint32_t ti = 0; ti < kNumTextures; ++ti) - { - dstMat.stringIdx[ti] = 0xFFFF; - - if (srcMat.textures[ti] != nullptr) - { - if (srcMat.textures[ti]->source != nullptr) - { - dstMat.stringIdx[ti] = uint16_t(srcMat.textures[ti]->source - asset.m_images.data()); - } - - if (srcMat.textures[ti]->sampler != nullptr) - { - dstMat.addressModes |= srcMat.textures[ti]->sampler->wrapS << (ti * 4); - dstMat.addressModes |= srcMat.textures[ti]->sampler->wrapT << (ti * 4 + 2); - } - else - { - dstMat.addressModes |= 0x5 << (ti * 4); - } - } - else - { - dstMat.addressModes |= 0x5 << (ti * 4); - } - } - - SetTextureOptions(textureOptions, srcMat.textures[kBaseColor], TextureOptions(true, srcMat.alphaBlend | srcMat.alphaTest)); - SetTextureOptions(textureOptions, srcMat.textures[kMetallicRoughness], TextureOptions(false)); - SetTextureOptions(textureOptions, srcMat.textures[kOcclusion], TextureOptions(false)); - SetTextureOptions(textureOptions, srcMat.textures[kEmissive], TextureOptions(true)); - SetTextureOptions(textureOptions, srcMat.textures[kNormal], TextureOptions(false)); - } - - model.m_TextureOptions.clear(); - for (auto name : model.m_TextureNames) - { - auto iter = textureOptions.find(name); - if (iter != textureOptions.end()) - { - model.m_TextureOptions.push_back(iter->second); - CompileTextureOnDemand(asset.m_basePath + Utility::UTF8ToWideString(iter->first), iter->second); - } - else - model.m_TextureOptions.push_back(0xFF); - } - ASSERT(model.m_TextureOptions.size() == model.m_TextureNames.size()); -} - -void BuildAnimations(ModelData& model, const glTF::Asset& asset) -{ - size_t numAnimations = asset.m_animations.size(); - if (numAnimations == 0) - return; - - model.m_Animations.resize(numAnimations); - uint32_t animIdx = 0; - - for (const glTF::Animation& anim : asset.m_animations) - { - AnimationSet& animSet = model.m_Animations[animIdx++]; - animSet.duration = 0.0f; - animSet.firstCurve = (uint32_t)model.m_AnimationCurves.size(); - animSet.numCurves = (uint32_t)anim.m_channels.size(); - - for (size_t i = 0; i < animSet.numCurves; ++i) - { - const glTF::AnimChannel& channel = anim.m_channels[i]; - const glTF::AnimSampler& sampler = *channel.m_sampler; - - ASSERT(channel.m_target->linearIdx >= 0); - - AnimationCurve curve; - curve.targetNode = channel.m_target->linearIdx; - curve.targetPath = channel.m_path; - curve.interpolation = sampler.m_interpolation; - curve.keyFrameOffset = model.m_AnimationKeyFrameData.size(); - curve.keyFrameFormat = std::min(sampler.m_output->componentType, AnimationCurve::kFloat); - curve.numSegments = sampler.m_output->count - 1.0f; - - // In glTF, stride==0 means "packed tightly" - if (sampler.m_output->stride == 0) - { - uint32_t numComponents = sampler.m_output->type + 1; - uint32_t bytesPerComponent = sampler.m_output->componentType / 2 + 1; - curve.keyFrameStride = numComponents * bytesPerComponent / 4; - } - else - { - ASSERT(sampler.m_output->stride <= 16 && sampler.m_output->stride % 4 == 0); - curve.keyFrameStride = sampler.m_output->stride / 4; - } - - // Determine start and stop time stamps - const float* timeStamps = (float*)sampler.m_input->dataPtr; - curve.startTime = timeStamps[0]; - - const float endTime = timeStamps[sampler.m_output->count - 1]; - curve.rangeScale = curve.numSegments / (endTime - curve.startTime); - - animSet.duration = std::max(animSet.duration, endTime); - - // Append this curve data - model.m_AnimationKeyFrameData.insert( - model.m_AnimationKeyFrameData.end(), - sampler.m_output->dataPtr, - sampler.m_output->dataPtr + sampler.m_output->count * curve.keyFrameStride * 4); - - model.m_AnimationCurves.push_back(curve); - } - } -} - -void BuildSkins(ModelData& model, const glTF::Asset& asset) -{ - size_t numSkins = asset.m_skins.size(); - if (numSkins == 0) - return; - - std::vector> skinMap; - skinMap.reserve(asset.m_skins.size()); - - for (const glTF::Skin& skin : asset.m_skins) - { - // Record offset and joint count - uint16_t numJoints = (uint16_t)skin.joints.size(); - uint16_t curOffset = (uint16_t)model.m_JointIndices.size(); - skinMap.push_back(std::make_pair(curOffset, numJoints)); - - // Append remapped joint indices - for (glTF::Node* joint : skin.joints) - { - ASSERT(joint->linearIdx >= 0, "Skin joint not present in node hierarchy"); - model.m_JointIndices.push_back((uint16_t)joint->linearIdx); - } - - // Append IBMs - Matrix4* IBMstart = (Matrix4*)skin.inverseBindMatrices->dataPtr; - Matrix4* IBMend = IBMstart + skin.inverseBindMatrices->count; - ASSERT(skin.inverseBindMatrices->count == numJoints); - model.m_JointIBMs.insert(model.m_JointIBMs.end(), IBMstart, IBMend); - } - - // Assign skinned meshes the proper joint offset and count - for (Mesh* mesh : model.m_Meshes) - { - if (mesh->numJoints != 0) - { - std::pair offsetAndCount = skinMap[mesh->startJoint]; - mesh->startJoint = offsetAndCount.first; - mesh->numJoints = offsetAndCount.second; - } - } -} - -bool Renderer::BuildModel(ModelData& model, const glTF::Asset& asset, int sceneIdx) -{ - BuildMaterials(model, asset); - - // Generate scene graph and meshes - model.m_SceneGraph.resize(asset.m_nodes.size()); - const glTF::Scene* scene = sceneIdx < 0 ? asset.m_scene : &asset.m_scenes[sceneIdx]; - if (scene == nullptr) - return false; - - // Aggregate all of the vertex and index buffers in this unified buffer - std::vector& bufferMemory = model.m_GeometryData; - - model.m_BoundingSphere = BoundingSphere(kZero); - model.m_BoundingBox = AxisAlignedBox(kZero); - uint32_t numNodes = WalkGraph(model.m_SceneGraph, model.m_BoundingSphere, model.m_BoundingBox, model.m_Meshes, bufferMemory, scene->nodes, 0, Matrix4(kIdentity)); - model.m_SceneGraph.resize(numNodes); - - BuildAnimations(model, asset); - BuildSkins(model, asset); - - return true; -} - -bool Renderer::SaveModel(const std::wstring& filePath, const ModelData& data) -{ - std::ofstream outFile(filePath, std::ios::out | std::ios::binary); - if (!outFile) - return false; - - FileHeader header; - std::memcpy(header.id, "MINI", 4); - header.version = CURRENT_MINI_FILE_VERSION; - header.numNodes = (uint32_t)data.m_SceneGraph.size(); - header.numMeshes = (uint32_t)data.m_Meshes.size(); - header.numMaterials = (uint32_t)data.m_MaterialConstants.size(); - header.meshDataSize = 0; - for (const Mesh* mesh : data.m_Meshes) - header.meshDataSize += (uint32_t)sizeof(Mesh) + (mesh->numDraws - 1) * (uint32_t)sizeof(Mesh::Draw); - header.numTextures = (uint32_t)data.m_TextureNames.size(); - header.stringTableSize = 0; - for (const std::string& str : data.m_TextureNames) - header.stringTableSize += (uint32_t)str.size() + 1; - header.geometrySize = (uint32_t)data.m_GeometryData.size(); - header.keyFrameDataSize = (uint32_t)data.m_AnimationKeyFrameData.size(); - header.numAnimationCurves = (uint32_t)data.m_AnimationCurves.size(); - header.numAnimations = (uint32_t)data.m_Animations.size(); - header.numJoints = (uint32_t)data.m_JointIndices.size(); - header.boundingSphere[0] = data.m_BoundingSphere.GetCenter().GetX(); - header.boundingSphere[1] = data.m_BoundingSphere.GetCenter().GetY(); - header.boundingSphere[2] = data.m_BoundingSphere.GetCenter().GetZ(); - header.boundingSphere[3] = data.m_BoundingSphere.GetRadius(); - header.minPos[0] = data.m_BoundingBox.GetMin().GetX(); - header.minPos[1] = data.m_BoundingBox.GetMin().GetY(); - header.minPos[2] = data.m_BoundingBox.GetMin().GetZ(); - header.maxPos[0] = data.m_BoundingBox.GetMax().GetX(); - header.maxPos[1] = data.m_BoundingBox.GetMax().GetY(); - header.maxPos[2] = data.m_BoundingBox.GetMax().GetZ(); - - outFile.write((char*)&header, sizeof(FileHeader)); - outFile.write((char*)data.m_GeometryData.data(), header.geometrySize); - outFile.write((char*)data.m_SceneGraph.data(), header.numNodes * sizeof(GraphNode)); - for (const Mesh* mesh : data.m_Meshes) - outFile.write((char*)mesh, sizeof(Mesh) + (mesh->numDraws - 1) * sizeof(Mesh::Draw)); - outFile.write((char*)data.m_MaterialConstants.data(), header.numMaterials * sizeof(MaterialConstantData)); - outFile.write((char*)data.m_MaterialTextures.data(), header.numMaterials * sizeof(MaterialTextureData)); - for (uint32_t i = 0; i < header.numTextures; ++i) - outFile << data.m_TextureNames[i] << '\0'; - outFile.write((char*)data.m_TextureOptions.data(), header.numTextures * sizeof(uint8_t)); - - if (header.numAnimations > 0) - { - ASSERT(header.keyFrameDataSize > 0 && header.numAnimationCurves > 0); - outFile.write((char*)data.m_AnimationKeyFrameData.data(), header.keyFrameDataSize); - outFile.write((char*)data.m_AnimationCurves.data(), header.numAnimationCurves * sizeof(AnimationCurve)); - outFile.write((char*)data.m_Animations.data(), header.numAnimations * sizeof(AnimationSet)); - } - else - { - ASSERT(header.keyFrameDataSize == 0 && header.numAnimationCurves == 0); - } - - if (header.numJoints) - { - ASSERT(header.numJoints == (uint32_t)data.m_JointIBMs.size()); - outFile.write((char*)data.m_JointIndices.data(), header.numJoints * sizeof(uint16_t)); - outFile.write((char*)data.m_JointIBMs.data(), header.numJoints * sizeof(Matrix4)); - } - - return true; -} diff --git a/xess/samples/xess_demo/MiniEngine/Model/ModelH3D.cpp b/xess/samples/xess_demo/MiniEngine/Model/ModelH3D.cpp deleted file mode 100644 index 4fb3ecc..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/ModelH3D.cpp +++ /dev/null @@ -1,349 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: Alex Nankervis -// - -#include "ModelH3D.h" -#include -#include - -#include "Utility.h" -#include "TextureManager.h" -#include "GraphicsCore.h" -#include "DescriptorHeap.h" -#include "CommandContext.h" -#include "UploadBuffer.h" -#include "GraphicsCommon.h" -#include - -using namespace std; -using namespace Math; - -namespace Renderer -{ - extern DescriptorHeap s_TextureHeap; - extern DescriptorHeap s_SamplerHeap; -} - -ModelH3D::ModelH3D() - : m_pMesh(nullptr) - , m_pMaterial(nullptr) - , m_pVertexData(nullptr) - , m_pIndexData(nullptr) - , m_pVertexDataDepth(nullptr) - , m_pIndexDataDepth(nullptr) -{ - Clear(); -} - -ModelH3D::~ModelH3D() -{ - Clear(); -} - -void ModelH3D::Clear() -{ - m_GeometryBuffer.Destroy(); - - delete [] m_pMesh; - m_pMesh = nullptr; - m_Header.meshCount = 0; - - delete [] m_pMaterial; - m_pMaterial = nullptr; - m_Header.materialCount = 0; - - delete [] m_pVertexData; - delete [] m_pIndexData; - delete [] m_pVertexDataDepth; - delete [] m_pIndexDataDepth; - - m_pVertexData = nullptr; - m_Header.vertexDataByteSize = 0; - m_pIndexData = nullptr; - m_Header.indexDataByteSize = 0; - m_pVertexDataDepth = nullptr; - m_Header.vertexDataByteSizeDepth = 0; - m_pIndexDataDepth = nullptr; - - m_TextureReferences.clear(); - - m_Header.boundingBox = AxisAlignedBox(); -} - -// assuming at least 3 floats for position -void ModelH3D::ComputeMeshBoundingBox(uint32_t meshIndex, AxisAlignedBox& bbox) const -{ - const Mesh *mesh = m_pMesh + meshIndex; - - bbox = AxisAlignedBox(); - - if (mesh->vertexCount > 0) - { - uint32_t vertexStride = mesh->vertexStride; - - const float *p = (float*)(m_pVertexData + mesh->vertexDataByteOffset + mesh->attrib[attrib_position].offset); - const float *pEnd = (float*)(m_pVertexData + mesh->vertexDataByteOffset + mesh->vertexCount * mesh->vertexStride + mesh->attrib[attrib_position].offset); - - while (p < pEnd) - { - Vector3 pos(*(p + 0), *(p + 1), *(p + 2)); - - bbox.AddPoint(pos); - - (*(uint8_t**)&p) += vertexStride; - } - } -} - -void ModelH3D::ComputeGlobalBoundingBox(AxisAlignedBox &bbox) const -{ - bbox = AxisAlignedBox(); - - if (m_Header.meshCount > 0) - { - for (uint32_t meshIndex = 0; meshIndex < m_Header.meshCount; meshIndex++) - { - const Mesh *mesh = m_pMesh + meshIndex; - bbox.AddBoundingBox(mesh->boundingBox); - } - } -} - -void ModelH3D::ComputeAllBoundingBoxes() -{ - for (uint32_t meshIndex = 0; meshIndex < m_Header.meshCount; meshIndex++) - { - Mesh *mesh = m_pMesh + meshIndex; - ComputeMeshBoundingBox(meshIndex, mesh->boundingBox); - } - ComputeGlobalBoundingBox(m_Header.boundingBox); -} - -bool ModelH3D::LoadH3D(const wstring& filename) -{ - std::ifstream file(filename, ios::in | ios::binary); - - file.read((char*)&m_Header, sizeof(Header)); - if (!file) - return false; - - m_pMesh = new Mesh[m_Header.meshCount]; - m_pMaterial = new Material[m_Header.materialCount]; - - if (m_Header.meshCount > 0) - { - file.read((char*)m_pMesh, sizeof(Mesh) * m_Header.meshCount); - if (!file) - return false; - } - if (m_Header.materialCount > 0) - { - file.read((char*)m_pMaterial, sizeof(Material) * m_Header.materialCount); - if (!file) - return false; - } - - m_VertexStride = m_pMesh[0].vertexStride; - m_VertexStrideDepth = m_pMesh[0].vertexStrideDepth; -#if _DEBUG - for (uint32_t meshIndex = 1; meshIndex < m_Header.meshCount; ++meshIndex) - { - const Mesh& mesh = m_pMesh[meshIndex]; - ASSERT(mesh.vertexStride == m_VertexStride); - ASSERT(mesh.vertexStrideDepth == m_VertexStrideDepth); - } - for (uint32_t meshIndex = 0; meshIndex < m_Header.meshCount; ++meshIndex) - { - const Mesh& mesh = m_pMesh[meshIndex]; - - ASSERT( mesh.attribsEnabled == - (attrib_mask_position | attrib_mask_texcoord0 | attrib_mask_normal | attrib_mask_tangent | attrib_mask_bitangent) ); - ASSERT(mesh.attrib[0].components == 3 && mesh.attrib[0].format == ModelH3D::attrib_format_float); // position - ASSERT(mesh.attrib[1].components == 2 && mesh.attrib[1].format == ModelH3D::attrib_format_float); // texcoord0 - ASSERT(mesh.attrib[2].components == 3 && mesh.attrib[2].format == ModelH3D::attrib_format_float); // normal - ASSERT(mesh.attrib[3].components == 3 && mesh.attrib[3].format == ModelH3D::attrib_format_float); // tangent - ASSERT(mesh.attrib[4].components == 3 && mesh.attrib[4].format == ModelH3D::attrib_format_float); // bitangent - - ASSERT( mesh.attribsEnabledDepth == - (attrib_mask_position) ); - ASSERT(mesh.attrib[0].components == 3 && mesh.attrib[0].format == ModelH3D::attrib_format_float); // position - } -#endif - - UploadBuffer geomBuffer; - - uint32_t totalBinarySize = m_Header.vertexDataByteSize - + m_Header.indexDataByteSize - + m_Header.vertexDataByteSizeDepth - + m_Header.indexDataByteSize; - - geomBuffer.Create(L"Geometry Upload Buffer", totalBinarySize); - uint8_t* uploadMem = (uint8_t*)geomBuffer.Map(); - - m_pVertexData = uploadMem; - m_pIndexData = m_pVertexData + m_Header.vertexDataByteSize; - m_pVertexDataDepth = m_pIndexData + m_Header.indexDataByteSize; - m_pIndexDataDepth = m_pVertexDataDepth + m_Header.vertexDataByteSizeDepth; - - if (m_Header.vertexDataByteSize > 0 && !file.read((char*)m_pVertexData, m_Header.vertexDataByteSize)) - return false; - if (m_Header.indexDataByteSize > 0 && !file.read((char*)m_pIndexData, m_Header.indexDataByteSize)) - return false; - - if (m_Header.vertexDataByteSizeDepth > 0 && !file.read((char*)m_pVertexDataDepth, m_Header.vertexDataByteSizeDepth)) - return false; - if (m_Header.indexDataByteSize > 0 && !file.read((char*)m_pIndexDataDepth, m_Header.indexDataByteSize)) - return false; - - m_GeometryBuffer.Create(L"Geometry Buffer", totalBinarySize, 1, geomBuffer); - - m_VertexBuffer = m_GeometryBuffer.VertexBufferView(0, m_Header.vertexDataByteSize, m_VertexStride); - m_IndexBuffer = m_GeometryBuffer.IndexBufferView(m_pIndexData - m_pVertexData, m_Header.indexDataByteSize, false); - m_VertexBufferDepth = m_GeometryBuffer.VertexBufferView(m_pVertexDataDepth - m_pVertexData, m_Header.vertexDataByteSizeDepth, m_VertexStride); - m_IndexBufferDepth = m_GeometryBuffer.IndexBufferView(m_pIndexDataDepth - m_pVertexData, m_Header.indexDataByteSize, false); - - m_pVertexData = new unsigned char[m_Header.vertexDataByteSize]; - m_pIndexData = new unsigned char[m_Header.indexDataByteSize]; - m_pVertexDataDepth = new unsigned char[m_Header.vertexDataByteSizeDepth]; - m_pIndexDataDepth = new unsigned char[m_Header.indexDataByteSize]; - - std::memcpy(m_pVertexData, uploadMem, m_Header.vertexDataByteSize); - uploadMem += m_Header.vertexDataByteSize; - std::memcpy(m_pIndexData, uploadMem, m_Header.indexDataByteSize); - uploadMem += m_Header.indexDataByteSize; - std::memcpy(m_pVertexDataDepth, uploadMem, m_Header.vertexDataByteSizeDepth); - uploadMem += m_Header.vertexDataByteSizeDepth; - std::memcpy(m_pIndexDataDepth, uploadMem, m_Header.indexDataByteSize); - - geomBuffer.Unmap(); - - - LoadTextures(Utility::GetBasePath(filename)); - - return true; -} - -void ModelH3D::CreateVertexBufferSRV(D3D12_CPU_DESCRIPTOR_HANDLE cpuHandle) const -{ - D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; - srvDesc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER; - srvDesc.Buffer.FirstElement = 0; - srvDesc.Buffer.NumElements = (UINT)(m_VertexBuffer.SizeInBytes / sizeof(UINT32)); - srvDesc.Buffer.Flags = D3D12_BUFFER_SRV_FLAG_RAW; - srvDesc.Format = DXGI_FORMAT_R32_TYPELESS; - srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; - - Graphics::g_Device->CreateShaderResourceView(const_cast(m_GeometryBuffer.GetResource()), &srvDesc, cpuHandle); -} - -void ModelH3D::CreateIndexBufferSRV(D3D12_CPU_DESCRIPTOR_HANDLE cpuHandle) const -{ - D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; - srvDesc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER; - srvDesc.Buffer.FirstElement = (UINT)(m_VertexBuffer.SizeInBytes / sizeof(UINT32)); - srvDesc.Buffer.NumElements = (UINT)(m_IndexBuffer.SizeInBytes / sizeof(UINT32)); - srvDesc.Buffer.Flags = D3D12_BUFFER_SRV_FLAG_RAW; - srvDesc.Format = DXGI_FORMAT_R32_TYPELESS; - srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; - - Graphics::g_Device->CreateShaderResourceView(const_cast(m_GeometryBuffer.GetResource()), &srvDesc, cpuHandle); -} - -bool ModelH3D::SaveH3D(const wstring& filename) const -{ - std::ofstream file(filename, ios::out | ios::binary); - if (!file) - return false; - - if (!file.write((char*)&m_Header, sizeof(Header))) - return false; - - if (m_Header.meshCount > 0 && !file.write((const char*)m_pMesh, sizeof(Mesh) * m_Header.meshCount)) - return false; - - if (m_Header.materialCount > 0 && !file.write((const char*)m_pMaterial, sizeof(Material) * m_Header.materialCount)) - return false; - - if (m_pVertexData != nullptr && m_Header.vertexDataByteSize > 0 && - !file.write((char*)m_pVertexData, m_Header.vertexDataByteSize)) - return false; - - if (m_pIndexData != nullptr && m_Header.indexDataByteSize > 0 && - !file.write((char*)m_pIndexData, m_Header.indexDataByteSize)) - return false; - - if (m_pVertexDataDepth != nullptr && m_Header.vertexDataByteSizeDepth > 0 && - !file.write((char*)m_pVertexDataDepth, m_Header.vertexDataByteSizeDepth)) - return false; - - if (m_pIndexDataDepth != nullptr && m_Header.indexDataByteSize > 0 && - !file.write((char*)m_pIndexDataDepth, m_Header.indexDataByteSize)) - return false; - - return true; -} - -static inline std::wstring RemoveExt(const char* filename) -{ - return Utility::RemoveExtension(Utility::UTF8ToWideString(std::string(filename))); -} - -void ModelH3D::LoadTextures(const std::wstring& basePath) -{ - using namespace Graphics; - using namespace TextureManager; - - m_TextureReferences.resize(m_Header.materialCount * 3); - m_SRVs = Renderer::s_TextureHeap.Alloc(m_Header.materialCount * 6); - m_SRVDescriptorSize = Renderer::s_TextureHeap.GetDescriptorSize(); - - DescriptorHandle SRVs = m_SRVs; - - TextureRef* MatTextures = m_TextureReferences.data(); - - for (uint32_t materialIdx = 0; materialIdx < m_Header.materialCount; ++materialIdx) - { - const Material& pMaterial = m_pMaterial[materialIdx]; - - // Load diffuse - std::wstring diffusePath = basePath + RemoveExt(pMaterial.texDiffusePath); - MatTextures[0] = LoadDDSFromFile(diffusePath + L".dds", kWhiteOpaque2D, true); - - // Load specular - std::wstring specularPath = basePath + RemoveExt(pMaterial.texSpecularPath); - MatTextures[1] = LoadDDSFromFile(specularPath + L".dds", kBlackOpaque2D, true); - if (!MatTextures[1].IsValid()) - MatTextures[1] = LoadDDSFromFile(diffusePath + L"_specular.dds", kBlackOpaque2D, true); - - // Load normal - std::wstring normalPath = basePath + RemoveExt(pMaterial.texNormalPath); - MatTextures[2] = LoadDDSFromFile(normalPath + L".dds", kDefaultNormalMap, false); - if (!MatTextures[2].IsValid()) - MatTextures[2] = LoadDDSFromFile(diffusePath + L"_normal.dds", kDefaultNormalMap, false); - - uint32_t DestCount = 6; - uint32_t SourceCounts[] = { 1, 1, 1, 1, 1, 1 }; - D3D12_CPU_DESCRIPTOR_HANDLE SourceTextures[6] = - { - MatTextures[0].GetSRV(), - MatTextures[1].GetSRV(), - GetDefaultTexture(kBlackTransparent2D), - MatTextures[2].GetSRV(), - GetDefaultTexture(kBlackTransparent2D), - GetDefaultTexture(kBlackCubeMap) - }; - Graphics::g_Device->CopyDescriptors(1, &SRVs, &DestCount, - DestCount, SourceTextures, SourceCounts, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - SRVs += (m_SRVDescriptorSize * 6); - MatTextures += 3; - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Model/ModelH3D.h b/xess/samples/xess_demo/MiniEngine/Model/ModelH3D.h deleted file mode 100644 index 167b9b9..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/ModelH3D.h +++ /dev/null @@ -1,244 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): Alex Nankervis -// James Stanard -// - -#pragma once - -#include "VectorMath.h" -#include "TextureManager.h" -#include "GpuBuffer.h" -#include "DescriptorHeap.h" -#include "../Core/Math/BoundingBox.h" - -namespace Renderer -{ - struct ModelData; -} - -class ModelH3D -{ -public: - - ModelH3D(); - ~ModelH3D(); - - void Clear(); - - enum - { - attrib_mask_0 = (1 << 0), - attrib_mask_1 = (1 << 1), - attrib_mask_2 = (1 << 2), - attrib_mask_3 = (1 << 3), - attrib_mask_4 = (1 << 4), - attrib_mask_5 = (1 << 5), - attrib_mask_6 = (1 << 6), - attrib_mask_7 = (1 << 7), - attrib_mask_8 = (1 << 8), - attrib_mask_9 = (1 << 9), - attrib_mask_10 = (1 << 10), - attrib_mask_11 = (1 << 11), - attrib_mask_12 = (1 << 12), - attrib_mask_13 = (1 << 13), - attrib_mask_14 = (1 << 14), - attrib_mask_15 = (1 << 15), - - // friendly name aliases - attrib_mask_position = attrib_mask_0, - attrib_mask_texcoord0 = attrib_mask_1, - attrib_mask_normal = attrib_mask_2, - attrib_mask_tangent = attrib_mask_3, - attrib_mask_bitangent = attrib_mask_4, - }; - - enum - { - attrib_0 = 0, - attrib_1 = 1, - attrib_2 = 2, - attrib_3 = 3, - attrib_4 = 4, - attrib_5 = 5, - attrib_6 = 6, - attrib_7 = 7, - attrib_8 = 8, - attrib_9 = 9, - attrib_10 = 10, - attrib_11 = 11, - attrib_12 = 12, - attrib_13 = 13, - attrib_14 = 14, - attrib_15 = 15, - - // friendly name aliases - attrib_position = attrib_0, - attrib_texcoord0 = attrib_1, - attrib_normal = attrib_2, - attrib_tangent = attrib_3, - attrib_bitangent = attrib_4, - - maxAttribs = 16 - }; - - enum - { - attrib_format_none = 0, - attrib_format_ubyte, - attrib_format_byte, - attrib_format_ushort, - attrib_format_short, - attrib_format_float, - - attrib_formats - }; - - struct Header - { - uint32_t meshCount; - uint32_t materialCount; - uint32_t vertexDataByteSize; - uint32_t indexDataByteSize; - uint32_t vertexDataByteSizeDepth; - Math::AxisAlignedBox boundingBox; - }; - - struct Attrib - { - uint16_t offset; // byte offset from the start of the vertex - uint16_t normalized; // if true, integer formats are interpreted as [-1, 1] or [0, 1] - uint16_t components; // 1-4 - uint16_t format; - }; - struct Mesh - { - Math::AxisAlignedBox boundingBox; - - uint32_t materialIndex; - - uint32_t attribsEnabled; - uint32_t attribsEnabledDepth; - uint32_t vertexStride; - uint32_t vertexStrideDepth; - Attrib attrib[maxAttribs]; - Attrib attribDepth[maxAttribs]; - - uint32_t vertexDataByteOffset; - uint32_t vertexCount; - uint32_t indexDataByteOffset; - uint32_t indexCount; - - uint32_t vertexDataByteOffsetDepth; - uint32_t vertexCountDepth; - }; - - struct Material - { - Color diffuse; - Color specular; - Color ambient; - Color emissive; - Color transparent; // light passing through a transparent surface is multiplied by this filter color - float opacity; - float shininess; // specular exponent - float specularStrength; // multiplier on top of specular color - - enum {maxTexPath = 128}; - enum {texCount = 6}; - char texDiffusePath[maxTexPath]; - char texSpecularPath[maxTexPath]; - char texEmissivePath[maxTexPath]; - char texNormalPath[maxTexPath]; - char texLightmapPath[maxTexPath]; - char texReflectionPath[maxTexPath]; - - enum {maxMaterialName = 128}; - char name[maxMaterialName]; - }; - - virtual bool Load(const std::wstring& filename) - { - return LoadH3D(filename); - } - - bool BuildModel(Renderer::ModelData& model, const std::wstring& basePath=L"") const; - - uint32_t GetMeshCount() const { return m_Header.meshCount; } - const Mesh& GetMesh(uint32_t meshIdx) const - { - ASSERT(meshIdx < m_Header.meshCount); - return m_pMesh[meshIdx]; - } - - uint32_t GetMaterialCount() const { return m_Header.materialCount; } - const Material& GetMaterial(uint32_t materialIdx) const - { - ASSERT(materialIdx < m_Header.materialCount); - return m_pMaterial[materialIdx]; - } - - const Math::AxisAlignedBox& GetBoundingBox() const { return m_Header.boundingBox; } - - uint32_t GetVertexStride() const { return m_VertexStride; } - const D3D12_VERTEX_BUFFER_VIEW& GetVertexBuffer() const { return m_VertexBuffer; } - const D3D12_INDEX_BUFFER_VIEW& GetIndexBuffer() const { return m_IndexBuffer; } - - DescriptorHandle GetSRVs(uint32_t materialIdx, uint32_t subIdx=0) const - { - return m_SRVs + (materialIdx * 6 + subIdx) * m_SRVDescriptorSize; - } - - const TextureRef* GetMaterialTextures(uint32_t materialIdx) const - { - return m_TextureReferences.data() + materialIdx * 3; - } - - void CreateVertexBufferSRV(D3D12_CPU_DESCRIPTOR_HANDLE cpuHandle) const; - void CreateIndexBufferSRV(D3D12_CPU_DESCRIPTOR_HANDLE cpuHandle) const; - -//protected: - - bool LoadH3D(const std::wstring& filename); - bool SaveH3D(const std::wstring& filename) const; - - void ComputeMeshBoundingBox(uint32_t meshIndex, Math::AxisAlignedBox& bbox) const; - void ComputeGlobalBoundingBox(Math::AxisAlignedBox& bbox) const; - void ComputeAllBoundingBoxes(); - - void LoadTextures(const std::wstring& basePath); - - Header m_Header; - Mesh *m_pMesh; - Material *m_pMaterial; - std::vector m_TextureReferences; - - DescriptorHandle m_SRVs; - uint32_t m_SRVDescriptorSize; - - // These are used at runtime during rendering - ByteAddressBuffer m_GeometryBuffer; - - D3D12_VERTEX_BUFFER_VIEW m_VertexBuffer; - D3D12_INDEX_BUFFER_VIEW m_IndexBuffer; - uint32_t m_VertexStride; - - // optimized for depth-only rendering - D3D12_VERTEX_BUFFER_VIEW m_VertexBufferDepth; - D3D12_INDEX_BUFFER_VIEW m_IndexBufferDepth; - uint32_t m_VertexStrideDepth; - - // These are allocated when constructing a model to be exported - unsigned char* m_pVertexData; - unsigned char* m_pIndexData; - unsigned char* m_pVertexDataDepth; - unsigned char* m_pIndexDataDepth; -}; diff --git a/xess/samples/xess_demo/MiniEngine/Model/ModelLoader.cpp b/xess/samples/xess_demo/MiniEngine/Model/ModelLoader.cpp deleted file mode 100644 index e56b19d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/ModelLoader.cpp +++ /dev/null @@ -1,301 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// Chuck Walbourn (ATG) -// -// This code depends on DirectXTex -// - -#include "ModelLoader.h" -#include "Renderer.h" -#include "Model.h" -#include "glTF.h" -#include "ModelH3D.h" -#include "TextureManager.h" -#include "TextureConvert.h" -#include "GraphicsCommon.h" - -#include -#include - -using namespace Renderer; -using namespace Graphics; - -std::unordered_map g_SamplerPermutations; - -D3D12_CPU_DESCRIPTOR_HANDLE GetSampler(uint32_t addressModes) -{ - SamplerDesc samplerDesc; - samplerDesc.AddressU = D3D12_TEXTURE_ADDRESS_MODE(addressModes & 0x3); - samplerDesc.AddressV = D3D12_TEXTURE_ADDRESS_MODE(addressModes >> 2); - return samplerDesc.CreateDescriptor(); -} - -void LoadMaterials(Model& model, - const std::vector& materialTextures, - const std::vector& textureNames, - const std::vector& textureOptions, - const std::wstring& basePath) -{ - static_assert((sizeof(MaterialConstants) % 256) == 0, "CBVs need 256 byte alignment"); - - // Load textures - const uint32_t numTextures = (uint32_t)textureNames.size(); - model.textures.resize(numTextures); - for (size_t ti = 0; ti < numTextures; ++ti) - { - std::wstring originalFile = basePath + textureNames[ti]; - CompileTextureOnDemand(originalFile, textureOptions[ti]); - - std::wstring ddsFile = Utility::RemoveExtension(originalFile) + L".dds"; - model.textures[ti] = TextureManager::LoadDDSFromFile(ddsFile); - } - - // Generate descriptor tables and record offsets for each material - const uint32_t numMaterials = (uint32_t)materialTextures.size(); - std::vector tableOffsets(numMaterials); - - for (uint32_t matIdx = 0; matIdx < numMaterials; ++matIdx) - { - const MaterialTextureData& srcMat = materialTextures[matIdx]; - - DescriptorHandle TextureHandles = Renderer::s_TextureHeap.Alloc(kNumTextures); - uint32_t SRVDescriptorTable = Renderer::s_TextureHeap.GetOffsetOfHandle(TextureHandles); - - uint32_t DestCount = kNumTextures; - uint32_t SourceCounts[kNumTextures] = { 1, 1, 1, 1, 1 }; - - D3D12_CPU_DESCRIPTOR_HANDLE DefaultTextures[kNumTextures] = - { - GetDefaultTexture(kWhiteOpaque2D), - GetDefaultTexture(kWhiteOpaque2D), - GetDefaultTexture(kWhiteOpaque2D), - GetDefaultTexture(kBlackTransparent2D), - GetDefaultTexture(kDefaultNormalMap) - }; - - D3D12_CPU_DESCRIPTOR_HANDLE SourceTextures[kNumTextures]; - for (uint32_t j = 0; j < kNumTextures; ++j) - { - if (srcMat.stringIdx[j] == 0xffff) - SourceTextures[j] = DefaultTextures[j]; - else - SourceTextures[j] = model.textures[srcMat.stringIdx[j]].GetSRV(); - } - - g_Device->CopyDescriptors(1, &TextureHandles, &DestCount, - DestCount, SourceTextures, SourceCounts, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - - // See if this combination of samplers has been used before. If not, allocate more from the heap - // and copy in the descriptors. - uint32_t addressModes = srcMat.addressModes; - auto samplerMapLookup = g_SamplerPermutations.find(addressModes); - - if (samplerMapLookup == g_SamplerPermutations.end()) - { - DescriptorHandle SamplerHandles = Renderer::s_SamplerHeap.Alloc(kNumTextures); - uint32_t SamplerDescriptorTable = Renderer::s_SamplerHeap.GetOffsetOfHandle(SamplerHandles); - g_SamplerPermutations[addressModes] = SamplerDescriptorTable; - tableOffsets[matIdx] = SRVDescriptorTable | SamplerDescriptorTable << 16; - - D3D12_CPU_DESCRIPTOR_HANDLE SourceSamplers[kNumTextures]; - for (uint32_t j = 0; j < kNumTextures; ++j) - { - SourceSamplers[j] = GetSampler(addressModes & 0xF); - addressModes >>= 4; - } - g_Device->CopyDescriptors(1, &SamplerHandles, &DestCount, - DestCount, SourceSamplers, SourceCounts, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER); - } - else - { - tableOffsets[matIdx] = SRVDescriptorTable | samplerMapLookup->second << 16; - } - } - - // Update table offsets for each mesh - uint8_t* meshPtr = model.m_MeshData.get(); - for (uint32_t i = 0; i < model.m_NumMeshes; ++i) - { - Mesh& mesh = *(Mesh*)meshPtr; - uint32_t offsetPair = tableOffsets[mesh.materialCBV]; - mesh.srvTable = offsetPair & 0xFFFF; - mesh.samplerTable = offsetPair >> 16; - mesh.pso = Renderer::GetPSO(mesh.psoFlags); - meshPtr += sizeof(Mesh) + (mesh.numDraws - 1) * sizeof(Mesh::Draw); - } -} - -std::shared_ptr Renderer::LoadModel(const std::wstring& filePath, bool forceRebuild) -{ - const std::wstring miniFileName = Utility::RemoveExtension(filePath) + L".mini"; - const std::wstring fileName = Utility::RemoveBasePath(filePath); - - struct _stat64 sourceFileStat; - struct _stat64 miniFileStat; - std::ifstream inFile; - FileHeader header; - - bool sourceFileMissing = _wstat64(filePath.c_str(), &sourceFileStat) == -1; - bool miniFileMissing = _wstat64(miniFileName.c_str(), &miniFileStat) == -1; - - if (sourceFileMissing) - forceRebuild = false; - - if (sourceFileMissing && miniFileMissing) - { - LOG_ERRORF("Error: Could not find %s.", Utility::WideStringToUTF8(fileName).c_str()); - return nullptr; - } - - bool needBuild = forceRebuild; - - // Check if .mini file exists and it is newer than source file - if (miniFileMissing || !sourceFileMissing && sourceFileStat.st_mtime > miniFileStat.st_mtime) - needBuild = true; - - // Check if it's an older version of .mini - if (!needBuild) - { - inFile = std::ifstream(miniFileName, std::ios::in | std::ios::binary); - inFile.read((char*)&header, sizeof(FileHeader)); - if (strncmp(header.id, "MINI", 4) != 0 || header.version != CURRENT_MINI_FILE_VERSION) - { - LOG_INFOF("Model version deprecated. Rebuilding %s...", Utility::WideStringToUTF8(fileName).c_str()); - needBuild = true; - inFile.close(); - } - } - - if (needBuild) - { - if (sourceFileMissing) - { - LOG_ERRORF("Error: Could not find %s.", Utility::WideStringToUTF8(fileName).c_str()); - return nullptr; - } - - ModelData modelData; - - const std::wstring fileExt = Utility::ToLower(Utility::GetFileExtension(filePath)); - - if (fileExt == L"gltf" || fileExt == L"glb") - { - glTF::Asset asset(filePath); - if (!BuildModel(modelData, asset)) - return nullptr; - } - else if (fileExt == L"h3d") - { - ModelH3D modelh3d; - const std::wstring basePath = Utility::GetBasePath(filePath); - if (!modelh3d.Load(filePath) || !modelh3d.BuildModel(modelData, basePath)) - return nullptr; - } - else - { - LOG_ERRORF("Unsupported model file extension: %s.", Utility::WideStringToUTF8(fileExt).c_str()); - return nullptr; - } - - if (!SaveModel(miniFileName, modelData)) - return nullptr; - - inFile = std::ifstream(miniFileName, std::ios::in | std::ios::binary); - inFile.read((char*)&header, sizeof(FileHeader)); - } - - if (!inFile) - return nullptr; - - ASSERT(strncmp(header.id, "MINI", 4) == 0 && header.version == CURRENT_MINI_FILE_VERSION); - - std::wstring basePath = Utility::GetBasePath(filePath); - - std::shared_ptr model(new Model); - - model->m_NumNodes = header.numNodes; - model->m_SceneGraph.reset(new GraphNode[header.numNodes]); - model->m_NumMeshes = header.numMeshes; - model->m_MeshData.reset(new uint8_t[header.meshDataSize]); - - if (header.geometrySize > 0) - { - UploadBuffer modelData; - modelData.Create(L"Model Data Upload", header.geometrySize); - inFile.read((char*)modelData.Map(), header.geometrySize); - modelData.Unmap(); - model->m_DataBuffer.Create(L"Model Data", header.geometrySize, 1, modelData); - } - - inFile.read((char*)model->m_SceneGraph.get(), header.numNodes * sizeof(GraphNode)); - inFile.read((char*)model->m_MeshData.get(), header.meshDataSize); - - if (header.numMaterials > 0) - { - UploadBuffer materialConstants; - materialConstants.Create(L"Material Constant Upload", header.numMaterials * sizeof(MaterialConstants)); - MaterialConstants* materialCBV = (MaterialConstants*)materialConstants.Map(); - for (uint32_t i = 0; i < header.numMaterials; ++i) - { - inFile.read((char*)materialCBV, sizeof(MaterialConstantData)); - materialCBV++; - } - materialConstants.Unmap(); - model->m_MaterialConstants.Create(L"Material Constants", header.numMaterials, sizeof(MaterialConstants), materialConstants); - } - - // Read material texture and sampler properties so we can load the material - std::vector materialTextures(header.numMaterials); - inFile.read((char*)materialTextures.data(), header.numMaterials * sizeof(MaterialTextureData)); - - std::vector textureNames(header.numTextures); - for (uint32_t i = 0; i < header.numTextures; ++i) - { - std::string utf8TextureName; - std::getline(inFile, utf8TextureName, '\0'); - textureNames[i] = Utility::UTF8ToWideString(utf8TextureName); - } - - std::vector textureOptions(header.numTextures); - inFile.read((char*)textureOptions.data(), header.numTextures * sizeof(uint8_t)); - - LoadMaterials(*model, materialTextures, textureNames, textureOptions, basePath); - - model->m_BoundingSphere = BoundingSphere(*(XMFLOAT4*)header.boundingSphere); - model->m_BoundingBox = AxisAlignedBox(Vector3(*(XMFLOAT3*)header.minPos), Vector3(*(XMFLOAT3*)header.maxPos)); - - // Load animation data - model->m_NumAnimations = header.numAnimations; - - if (header.numAnimations > 0) - { - ASSERT(header.keyFrameDataSize > 0 && header.numAnimationCurves > 0); - model->m_KeyFrameData.reset(new uint8_t[header.keyFrameDataSize]); - inFile.read((char*)model->m_KeyFrameData.get(), header.keyFrameDataSize); - model->m_CurveData.reset(new AnimationCurve[header.numAnimationCurves]); - inFile.read((char*)model->m_CurveData.get(), header.numAnimationCurves * sizeof(AnimationCurve)); - model->m_Animations.reset(new AnimationSet[header.numAnimations]); - inFile.read((char*)model->m_Animations.get(), header.numAnimations * sizeof(AnimationSet)); - } - - model->m_NumJoints = header.numJoints; - - if (header.numJoints > 0) - { - model->m_JointIndices.reset(new uint16_t[header.numJoints]); - inFile.read((char*)model->m_JointIndices.get(), header.numJoints * sizeof(uint16_t)); - model->m_JointIBMs.reset(new Matrix4[header.numJoints]); - inFile.read((char*)model->m_JointIBMs.get(), header.numJoints * sizeof(Matrix4)); - } - - return model; -} diff --git a/xess/samples/xess_demo/MiniEngine/Model/ModelLoader.h b/xess/samples/xess_demo/MiniEngine/Model/ModelLoader.h deleted file mode 100644 index 08dd382..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/ModelLoader.h +++ /dev/null @@ -1,104 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "Model.h" -#include "Animation.h" -#include "ConstantBuffers.h" -#include "../Core/Math/BoundingSphere.h" -#include "../Core/Math/BoundingBox.h" - -#include -#include - -namespace glTF { class Asset; struct Mesh; } - -#define CURRENT_MINI_FILE_VERSION 13 - -namespace Renderer -{ - using namespace Math; - - // Unaligned mirror of MaterialConstants - struct MaterialConstantData - { - float baseColorFactor[4]; // default=[1,1,1,1] - float emissiveFactor[3]; // default=[0,0,0] - float normalTextureScale; // default=1 - float metallicFactor; // default=1 - float roughnessFactor; // default=1 - uint32_t flags; - }; - - // Used at load time to construct descriptor tables - struct MaterialTextureData - { - uint16_t stringIdx[kNumTextures]; - uint32_t addressModes; - }; - - // All of the information that needs to be written to a .mini data file - struct ModelData - { - BoundingSphere m_BoundingSphere; - AxisAlignedBox m_BoundingBox; - std::vector m_GeometryData; - std::vector m_AnimationKeyFrameData; - std::vector m_AnimationCurves; - std::vector m_Animations; - std::vector m_JointIndices; - std::vector m_JointIBMs; - std::vector m_MaterialTextures; - std::vector m_MaterialConstants; - std::vector m_Meshes; - std::vector m_SceneGraph; - std::vector m_TextureNames; - std::vector m_TextureOptions; - }; - - struct FileHeader - { - char id[4]; // "MINI" - uint32_t version; // CURRENT_MINI_FILE_VERSION - uint32_t numNodes; - uint32_t numMeshes; - uint32_t numMaterials; - uint32_t meshDataSize; - uint32_t numTextures; - uint32_t stringTableSize; - uint32_t geometrySize; - uint32_t keyFrameDataSize; // Animation data - uint32_t numAnimationCurves; - uint32_t numAnimations; - uint32_t numJoints; // All joints for all skins - float boundingSphere[4]; - float minPos[3]; - float maxPos[3]; - }; - - void CompileMesh( - std::vector& meshList, - std::vector& bufferMemory, - glTF::Mesh& srcMesh, - uint32_t matrixIdx, - const Matrix4& localToObject, - Math::BoundingSphere& boundingSphere, - Math::AxisAlignedBox& boundingBox - ); - - bool BuildModel( ModelData& model, const glTF::Asset& asset, int sceneIdx = -1 ); - bool SaveModel( const std::wstring& filePath, const ModelData& model ); - - std::shared_ptr LoadModel( const std::wstring& filePath, bool forceRebuild = false ); -} \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Model/ParticleEffects.cpp b/xess/samples/xess_demo/MiniEngine/Model/ParticleEffects.cpp deleted file mode 100644 index 7714f33..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/ParticleEffects.cpp +++ /dev/null @@ -1,198 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// - -#include "ParticleEffects.h" -#include "../Core/ParticleEffectManager.h" -#include "TextureManager.h" -#include - -#pragma warning(push) -#pragma warning(disable : 4100) // unreferenced formal parameter -#include "json.hpp" -#pragma warning(pop) - -using namespace std; -using namespace Graphics; -using namespace Math; - -namespace -{ - map s_TextureArrayLookup; - vector s_TextureReferences; - - uint32_t GetTextureIndex(const wstring& name) - { - // Look for the texture already being assigned an index. If it's not found, - // load the texture and assign it an index. - auto iter = s_TextureArrayLookup.find(name); - - if (iter != s_TextureArrayLookup.end()) - { - return iter->second; - } - else - { - uint32_t index = (uint32_t)s_TextureArrayLookup.size(); - s_TextureArrayLookup[name] = index; - - // Load the texture and register it with the effect manager - TextureRef texture = TextureManager::LoadDDSFromFile(name, kMagenta2D, true); - s_TextureReferences.push_back(texture); - ParticleEffectManager::RegisterTexture(index, *texture.Get()); - - return index; - } - } - - void InstantiateEffect( ParticleEffectProperties& effectProperties ) - { - effectProperties.EmitProperties.TextureID = GetTextureIndex(effectProperties.TexturePath); - ParticleEffectManager::InstantiateEffect(effectProperties); - } - - void ClearEffectTexturePool() - { - s_TextureReferences.clear(); - } -} - -//--------------------------------------------------------------------- -// -// JSON Init File Handling -// -//--------------------------------------------------------------------- - -#define MAKE_FLOAT(it) (float)it.value() -#define MAKE_UINT(it) (uint32_t)it.value() -#define MAKE_WSTRING(it) Utility::UTF8ToWideString(it.value()) -#define MAKE_COLOR(it) Color((float)it.value()[0], (float)it.value()[1], (float)it.value()[2], (float)it.value()[3]) -#define MAKE_VECTOR3(it) Vector3((float)it.value()[0], (float)it.value()[1], (float)it.value()[2]) -#define MAKE_VECTOR4(it) Vector4((float)it.value()[0], (float)it.value()[1], (float)it.value()[2], (float)it.value()[3]) -#define MAKE_XMFLOAT2(it) XMFLOAT2((float)it.value()[0], (float)it.value()[1]) -#define MAKE_XMFLOAT3(it) XMFLOAT3((float)it.value()[0], (float)it.value()[1], (float)it.value()[2]) - -void ParticleEffects::InitFromJSON(const wstring& InitJsonFile, const wstring& AssetsRootDir) -{ - using json = nlohmann::json; - - json particle_setup; - ifstream(InitJsonFile) >> particle_setup; - - if (!particle_setup.is_object() || particle_setup.find("ParticleEmitters") == particle_setup.end()) - return; - - for (auto& emitter : particle_setup["ParticleEmitters"]) - { - ParticleEffectProperties Effect = ParticleEffectProperties(); - - for (json::iterator it = emitter.begin(); it != emitter.end(); ++it) - { - if (it.key() == "TexturePath") - { - Effect.TexturePath = AssetsRootDir + L"/" + MAKE_WSTRING(it); - } - else if (it.key() == "MinStartColor") - { - Effect.MinStartColor = MAKE_COLOR(it); - } - else if (it.key() == "MaxStartColor") - { - Effect.MaxStartColor = MAKE_COLOR(it); - } - else if (it.key() == "MinEndColor") - { - Effect.MinEndColor = MAKE_COLOR(it); - } - else if (it.key() == "MaxEndColor") - { - Effect.MaxEndColor = MAKE_COLOR(it); - } - else if (it.key() == "MaxEndColor") - { - Effect.MaxEndColor = MAKE_COLOR(it); - } - else if (it.key() == "TotalActiveLifetime") - { - Effect.TotalActiveLifetime = MAKE_FLOAT(it); - if (Effect.TotalActiveLifetime == 0.0f) - Effect.TotalActiveLifetime = FLT_MAX; - } - else if (it.key() == "EmitRate") - { - Effect.EmitRate = MAKE_FLOAT(it); - } - else if (it.key() == "Size") - { - Effect.Size = MAKE_VECTOR4(it); - } - else if (it.key() == "Velocity") - { - Effect.Velocity = MAKE_VECTOR4(it); - } - else if (it.key() == "LifeMinMax") - { - Effect.LifeMinMax = MAKE_XMFLOAT2(it); - } - else if (it.key() == "MassMinMax") - { - Effect.MassMinMax = MAKE_XMFLOAT2(it); - } - else if (it.key() == "Spread") - { - Effect.Spread = MAKE_XMFLOAT3(it); - } - else if (it.key() == "EmitProperties") - { - for (json::iterator it2 = it.value().begin(); it2 != it.value().end(); ++it2) - { - if (it2.key() == "Gravity") - { - Effect.EmitProperties.Gravity = MAKE_XMFLOAT3(it2); - } - else if (it2.key() == "FloorHeight") - { - Effect.EmitProperties.FloorHeight = MAKE_FLOAT(it2); - } - else if (it2.key() == "MaxParticles") - { - Effect.EmitProperties.MaxParticles = MAKE_UINT(it2); - } - else if (it2.key() == "EmitPosW") - { - Effect.EmitProperties.EmitPosW = MAKE_XMFLOAT3(it2); - } - else if (it2.key() == "LastEmitPosW") - { - Effect.EmitProperties.LastEmitPosW = MAKE_XMFLOAT3(it2); - } - else - { - LOG_WARNF("Warning: Emitter property \"%s\" not found.", it2.key().c_str()); - } - } - } - else - { - LOG_WARNF("Warning: Effect property \"%s\" not found.", it.key().c_str()); - } - - } - - InstantiateEffect(Effect); - } -} - -void ParticleEffects::ClearTexturePool() -{ - ClearEffectTexturePool(); -} diff --git a/xess/samples/xess_demo/MiniEngine/Model/ParticleEffects.h b/xess/samples/xess_demo/MiniEngine/Model/ParticleEffects.h deleted file mode 100644 index 02931c1..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/ParticleEffects.h +++ /dev/null @@ -1,22 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include - -namespace ParticleEffects -{ - void InitFromJSON(const std::wstring& InitJsonFile, const std::wstring& AssetsRootDir); - void ClearTexturePool(); -} diff --git a/xess/samples/xess_demo/MiniEngine/Model/Renderer.cpp b/xess/samples/xess_demo/MiniEngine/Model/Renderer.cpp deleted file mode 100644 index cb95e4b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Renderer.cpp +++ /dev/null @@ -1,806 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -// Modified 2022, Intel Corporation. -// Improved IBL, Forward+ and two-sided mesh rendering. - -#include "Renderer.h" -#include "Model.h" -#include "TextureManager.h" -#include "ConstantBuffers.h" -#include "LightManager.h" -#include "../Core/RootSignature.h" -#include "../Core/PipelineState.h" -#include "../Core/GraphicsCommon.h" -#include "../Core/BufferManager.h" -#include "../Core/ShadowCamera.h" - -#include "CompiledShaders/DefaultVS.h" -#include "CompiledShaders/DefaultSkinVS.h" -#include "CompiledShaders/DefaultPS.h" -#include "CompiledShaders/DefaultNoUV1VS.h" -#include "CompiledShaders/DefaultNoUV1SkinVS.h" -#include "CompiledShaders/DefaultNoUV1PS.h" -#include "CompiledShaders/DefaultNoTangentVS.h" -#include "CompiledShaders/DefaultNoTangentSkinVS.h" -#include "CompiledShaders/DefaultNoTangentPS.h" -#include "CompiledShaders/DefaultNoTangentNoUV1VS.h" -#include "CompiledShaders/DefaultNoTangentNoUV1SkinVS.h" -#include "CompiledShaders/DefaultNoTangentNoUV1PS.h" -#include "CompiledShaders/DepthOnlyVS.h" -#include "CompiledShaders/DepthOnlySkinVS.h" -#include "CompiledShaders/CutoutDepthVS.h" -#include "CompiledShaders/CutoutDepthSkinVS.h" -#include "CompiledShaders/CutoutDepthPS.h" -#include "CompiledShaders/SkyboxVS.h" -#include "CompiledShaders/SkyboxPS.h" - -#pragma warning(disable:4319) // '~': zero extending 'uint32_t' to 'uint64_t' of greater size - -using namespace Math; -using namespace Graphics; -using namespace Renderer; - -namespace Renderer -{ - float DebugFlag = 0.0f; - - BoolVar SeparateZPass("Renderer/Separate Z Pass", true); - - bool s_Initialized = false; - - DescriptorHeap s_TextureHeap; - DescriptorHeap s_SamplerHeap; - std::vector sm_PSOs; - - TextureRef s_RadianceCubeMap; - TextureRef s_IrradianceCubeMap; - TextureRef s_BRDFLUTTexture; - float s_SpecularIBLRange; - float s_SpecularIBLBias; - uint32_t g_SSAOFullScreenID; - uint32_t g_ShadowBufferID; - - RootSignature m_RootSig; - GraphicsPSO m_SkyboxPSO(L"Renderer: Skybox PSO"); - GraphicsPSO m_DefaultPSO(L"Renderer: Default PSO"); // Not finalized. Used as a template. - - DescriptorHandle m_CommonTextures; -} - -void Renderer::Initialize(void) -{ - if (s_Initialized) - return; - - SamplerDesc DefaultSamplerDesc; - DefaultSamplerDesc.MaxAnisotropy = 8; - - SamplerDesc CubeMapSamplerDesc = DefaultSamplerDesc; - //CubeMapSamplerDesc.MaxLOD = 6.0f; - - SamplerDesc ClampSamplerDesc = DefaultSamplerDesc; - ClampSamplerDesc.AddressU = D3D12_TEXTURE_ADDRESS_MODE_CLAMP; - ClampSamplerDesc.AddressV = D3D12_TEXTURE_ADDRESS_MODE_CLAMP; - ClampSamplerDesc.AddressW = D3D12_TEXTURE_ADDRESS_MODE_CLAMP; - - m_RootSig.Reset(kNumRootBindings, 4); - m_RootSig.InitStaticSampler(10, DefaultSamplerDesc, D3D12_SHADER_VISIBILITY_PIXEL); - m_RootSig.InitStaticSampler(11, SamplerShadowDesc, D3D12_SHADER_VISIBILITY_PIXEL); - m_RootSig.InitStaticSampler(12, CubeMapSamplerDesc, D3D12_SHADER_VISIBILITY_PIXEL); - m_RootSig.InitStaticSampler(13, ClampSamplerDesc, D3D12_SHADER_VISIBILITY_PIXEL); - m_RootSig[kMeshConstants].InitAsConstantBuffer(0, D3D12_SHADER_VISIBILITY_VERTEX); - m_RootSig[kMaterialConstants].InitAsConstantBuffer(0, D3D12_SHADER_VISIBILITY_PIXEL); - m_RootSig[kMaterialSRVs].InitAsDescriptorRange(D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 0, 10, D3D12_SHADER_VISIBILITY_PIXEL); - m_RootSig[kMaterialSamplers].InitAsDescriptorRange(D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER, 0, 10, D3D12_SHADER_VISIBILITY_PIXEL); - m_RootSig[kCommonSRVs].InitAsDescriptorRange(D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 10, 11, D3D12_SHADER_VISIBILITY_PIXEL); - m_RootSig[kCommonCBV].InitAsConstantBuffer(1); - m_RootSig[kSkinMatrices].InitAsBufferSRV(20, D3D12_SHADER_VISIBILITY_VERTEX); - m_RootSig.Finalize(L"RootSig", D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT); - - DXGI_FORMAT ColorFormat = g_SceneColorBuffer.GetFormat(); - DXGI_FORMAT DepthFormat = g_SceneDepthBuffer.GetFormat(); - - D3D12_INPUT_ELEMENT_DESC posOnly[] = - { - { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, - }; - - D3D12_INPUT_ELEMENT_DESC posAndUV[] = - { - { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, - { "TEXCOORD", 0, DXGI_FORMAT_R16G16_FLOAT, 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, - }; - - D3D12_INPUT_ELEMENT_DESC skinPos[] = - { - { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, - { "BLENDINDICES", 0, DXGI_FORMAT_R16G16B16A16_UINT, 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, - { "BLENDWEIGHT", 0, DXGI_FORMAT_R16G16B16A16_UNORM, 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, - }; - - D3D12_INPUT_ELEMENT_DESC skinPosAndUV[] = - { - { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, - { "TEXCOORD", 0, DXGI_FORMAT_R16G16_FLOAT, 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, - { "BLENDINDICES", 0, DXGI_FORMAT_R16G16B16A16_UINT, 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, - { "BLENDWEIGHT", 0, DXGI_FORMAT_R16G16B16A16_UNORM, 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, - }; - - ASSERT(sm_PSOs.size() == 0); - - // Depth Only PSOs - - // 0 - GraphicsPSO DepthOnlyPSO(L"Renderer: Depth Only PSO"); - DepthOnlyPSO.SetRootSignature(m_RootSig); - DepthOnlyPSO.SetRasterizerState(RasterizerDefault); - DepthOnlyPSO.SetBlendState(BlendDisable); - DepthOnlyPSO.SetDepthStencilState(DepthStateReadWrite); - DepthOnlyPSO.SetInputLayout(_countof(posOnly), posOnly); - DepthOnlyPSO.SetPrimitiveTopologyType(D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE); - DepthOnlyPSO.SetRenderTargetFormats(0, nullptr, DepthFormat); - DepthOnlyPSO.SetVertexShader(g_pDepthOnlyVS, sizeof(g_pDepthOnlyVS)); - DepthOnlyPSO.Finalize(); - sm_PSOs.push_back(DepthOnlyPSO); - - // 1 - GraphicsPSO CutoutDepthPSO(L"Renderer: Cutout Depth PSO"); - CutoutDepthPSO = DepthOnlyPSO; - CutoutDepthPSO.SetInputLayout(_countof(posAndUV), posAndUV); - CutoutDepthPSO.SetRasterizerState(RasterizerDefault); - CutoutDepthPSO.SetVertexShader(g_pCutoutDepthVS, sizeof(g_pCutoutDepthVS)); - CutoutDepthPSO.SetPixelShader(g_pCutoutDepthPS, sizeof(g_pCutoutDepthPS)); - CutoutDepthPSO.Finalize(); - sm_PSOs.push_back(CutoutDepthPSO); - - - // 2 - GraphicsPSO SkinDepthOnlyPSO(L"Renderer: Skin Depth PSO"); - SkinDepthOnlyPSO = DepthOnlyPSO; - SkinDepthOnlyPSO.SetInputLayout(_countof(skinPos), skinPos); - SkinDepthOnlyPSO.SetVertexShader(g_pDepthOnlySkinVS, sizeof(g_pDepthOnlySkinVS)); - SkinDepthOnlyPSO.Finalize(); - sm_PSOs.push_back(SkinDepthOnlyPSO); - - // 3 - GraphicsPSO SkinCutoutDepthPSO(L"Renderer: Skin Cutout Depth PSO"); - SkinCutoutDepthPSO = CutoutDepthPSO; - SkinCutoutDepthPSO.SetInputLayout(_countof(skinPosAndUV), skinPosAndUV); - SkinCutoutDepthPSO.SetVertexShader(g_pCutoutDepthSkinVS, sizeof(g_pCutoutDepthSkinVS)); - SkinCutoutDepthPSO.Finalize(); - sm_PSOs.push_back(SkinCutoutDepthPSO); - - // 4 - GraphicsPSO TwoSidedDepthPSO(L"Renderer: Two-sided Depth PSO"); - TwoSidedDepthPSO = DepthOnlyPSO; - TwoSidedDepthPSO.SetRasterizerState(RasterizerTwoSided); - TwoSidedDepthPSO.Finalize(); - sm_PSOs.push_back(TwoSidedDepthPSO); - - // 5 - GraphicsPSO TwoSidedCutoutDepthPSO(L"Renderer: Two-sided Cutout Depth PSO"); - TwoSidedCutoutDepthPSO = CutoutDepthPSO; - TwoSidedCutoutDepthPSO.SetRasterizerState(RasterizerTwoSided); - TwoSidedCutoutDepthPSO.Finalize(); - sm_PSOs.push_back(TwoSidedCutoutDepthPSO); - - // 6 - GraphicsPSO TwoSidedSkinDepthPSO(L"Renderer: Two-sided Skin Depth PSO"); - TwoSidedSkinDepthPSO = SkinDepthOnlyPSO; - TwoSidedSkinDepthPSO.SetRasterizerState(RasterizerTwoSided); - TwoSidedSkinDepthPSO.Finalize(); - sm_PSOs.push_back(TwoSidedSkinDepthPSO); - - // 7 - GraphicsPSO TwoSidedSkinCutoutDepthPSO(L"Renderer: Two-sided Skin Depth PSO"); - TwoSidedSkinCutoutDepthPSO = SkinCutoutDepthPSO; - TwoSidedSkinCutoutDepthPSO.SetRasterizerState(RasterizerTwoSided); - sm_PSOs.push_back(TwoSidedSkinCutoutDepthPSO); - - ASSERT(sm_PSOs.size() == 8); - - // Shadow PSOs - - // 8 - DepthOnlyPSO.SetRasterizerState(RasterizerShadow); - DepthOnlyPSO.SetRenderTargetFormats(0, nullptr, g_ShadowBuffer.GetFormat()); - DepthOnlyPSO.Finalize(); - sm_PSOs.push_back(DepthOnlyPSO); - - // 9 - CutoutDepthPSO.SetRasterizerState(RasterizerShadow); - CutoutDepthPSO.SetRenderTargetFormats(0, nullptr, g_ShadowBuffer.GetFormat()); - CutoutDepthPSO.Finalize(); - sm_PSOs.push_back(CutoutDepthPSO); - - // 10 - SkinDepthOnlyPSO.SetRasterizerState(RasterizerShadow); - SkinDepthOnlyPSO.SetRenderTargetFormats(0, nullptr, g_ShadowBuffer.GetFormat()); - SkinDepthOnlyPSO.Finalize(); - sm_PSOs.push_back(SkinDepthOnlyPSO); - - // 11 - SkinCutoutDepthPSO.SetRasterizerState(RasterizerShadow); - SkinCutoutDepthPSO.SetRenderTargetFormats(0, nullptr, g_ShadowBuffer.GetFormat()); - SkinCutoutDepthPSO.Finalize(); - sm_PSOs.push_back(SkinCutoutDepthPSO); - - // 12 - TwoSidedDepthPSO.SetRasterizerState(RasterizerShadow); - TwoSidedDepthPSO.SetRenderTargetFormats(0, nullptr, g_ShadowBuffer.GetFormat()); - TwoSidedDepthPSO.Finalize(); - sm_PSOs.push_back(TwoSidedDepthPSO); - - // 13 - TwoSidedCutoutDepthPSO.SetRasterizerState(RasterizerShadow); - TwoSidedCutoutDepthPSO.SetRenderTargetFormats(0, nullptr, g_ShadowBuffer.GetFormat()); - TwoSidedCutoutDepthPSO.Finalize(); - sm_PSOs.push_back(TwoSidedCutoutDepthPSO); - - // 14 - TwoSidedSkinDepthPSO.SetRasterizerState(RasterizerShadow); - TwoSidedSkinDepthPSO.SetRenderTargetFormats(0, nullptr, g_ShadowBuffer.GetFormat()); - TwoSidedSkinDepthPSO.Finalize(); - sm_PSOs.push_back(TwoSidedSkinDepthPSO); - - // 15 - TwoSidedSkinCutoutDepthPSO.SetRasterizerState(RasterizerShadow); - TwoSidedSkinCutoutDepthPSO.SetRenderTargetFormats(0, nullptr, g_ShadowBuffer.GetFormat()); - TwoSidedSkinCutoutDepthPSO.Finalize(); - sm_PSOs.push_back(TwoSidedSkinCutoutDepthPSO); - - ASSERT(sm_PSOs.size() == 16); - - // Default PSO - - m_DefaultPSO.SetRootSignature(m_RootSig); - m_DefaultPSO.SetRasterizerState(RasterizerDefault); - m_DefaultPSO.SetBlendState(BlendDisable); - m_DefaultPSO.SetDepthStencilState(DepthStateReadWrite); - m_DefaultPSO.SetInputLayout(0, nullptr); - m_DefaultPSO.SetPrimitiveTopologyType(D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE); - m_DefaultPSO.SetRenderTargetFormats(1, &ColorFormat, DepthFormat); - m_DefaultPSO.SetVertexShader(g_pDefaultVS, sizeof(g_pDefaultVS)); - m_DefaultPSO.SetPixelShader(g_pDefaultPS, sizeof(g_pDefaultPS)); - - // Skybox PSO - - m_SkyboxPSO = m_DefaultPSO; - m_SkyboxPSO.SetDepthStencilState(DepthStateReadOnly); - m_SkyboxPSO.SetInputLayout(0, nullptr); - m_SkyboxPSO.SetVertexShader(g_pSkyboxVS, sizeof(g_pSkyboxVS)); - m_SkyboxPSO.SetPixelShader(g_pSkyboxPS, sizeof(g_pSkyboxPS)); - m_SkyboxPSO.Finalize(); - - TextureManager::Initialize(L""); - - s_TextureHeap.Create(L"Scene Texture Descriptors", D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 4096); - - // Maybe only need 2 for wrap vs. clamp? Currently we allocate 1 for 1 with textures - s_SamplerHeap.Create(L"Scene Sampler Descriptors", D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER, 2048); - - Lighting::InitializeResources(); - - // Allocate a descriptor table for the common textures - m_CommonTextures = s_TextureHeap.Alloc(11); - - uint32_t DestCount = 11; - uint32_t SourceCounts[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; - - D3D12_CPU_DESCRIPTOR_HANDLE SourceTextures[] = - { - GetDefaultTexture(kBlackCubeMap), - GetDefaultTexture(kBlackCubeMap), - g_SSAOFullScreen.GetSRV(), - g_ShadowBuffer.GetSRV(), - GetDefaultTexture(kWhiteOpaque2D), - Lighting::m_LightBuffer.GetSRV(), - Lighting::m_LightShadowArray.GetSRV(), - Lighting::m_LightGrid.GetSRV(), - Lighting::m_LightGridBitMask.GetSRV(), - Lighting::m_LightGridTransparent.GetSRV(), - Lighting::m_LightGridBitMaskTransparent.GetSRV(), - }; - - g_Device->CopyDescriptors(1, &m_CommonTextures, &DestCount, DestCount, SourceTextures, SourceCounts, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - - g_SSAOFullScreenID = g_SSAOFullScreen.GetVersionID(); - g_ShadowBufferID = g_ShadowBuffer.GetVersionID(); - - s_Initialized = true; -} - -void Renderer::UpdateGlobalDescriptors(void) -{ - if (g_SSAOFullScreenID == g_SSAOFullScreen.GetVersionID() && - g_ShadowBufferID == g_ShadowBuffer.GetVersionID()) - { - return; - } - - uint32_t DestCount = 2; - uint32_t SourceCounts[] = { 1, 1 }; - - D3D12_CPU_DESCRIPTOR_HANDLE SourceTextures[] = - { - g_SSAOFullScreen.GetSRV(), - g_ShadowBuffer.GetSRV(), - }; - - DescriptorHandle dest = m_CommonTextures + 2 * s_TextureHeap.GetDescriptorSize(); - - g_Device->CopyDescriptors(1, &dest, &DestCount, DestCount, SourceTextures, SourceCounts, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); - - g_SSAOFullScreenID = g_SSAOFullScreen.GetVersionID(); - g_ShadowBufferID = g_ShadowBuffer.GetVersionID(); - -} - -void Renderer::SetIBLTextures(TextureRef diffuseIBL, TextureRef specularIBL) -{ - s_RadianceCubeMap = specularIBL; - s_IrradianceCubeMap = diffuseIBL; - - s_SpecularIBLRange = 0.0f; - if (s_RadianceCubeMap.IsValid()) - { - ID3D12Resource* texRes = const_cast(s_RadianceCubeMap.Get()->GetResource()); - const D3D12_RESOURCE_DESC& texDesc = texRes->GetDesc(); - s_SpecularIBLRange = Max(0.0f, (float)texDesc.MipLevels - 1); - s_SpecularIBLBias = Min(s_SpecularIBLBias, s_SpecularIBLRange); - } - - uint32_t DestCount = 2; - uint32_t SourceCounts[] = { 1, 1 }; - - D3D12_CPU_DESCRIPTOR_HANDLE SourceTextures[] = - { - specularIBL.IsValid() ? specularIBL.GetSRV() : GetDefaultTexture(kBlackCubeMap), - diffuseIBL.IsValid() ? diffuseIBL.GetSRV() : GetDefaultTexture(kBlackCubeMap) - }; - - g_Device->CopyDescriptors(1, &m_CommonTextures, &DestCount, DestCount, SourceTextures, SourceCounts, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); -} - -void Renderer::SetIBLBias(float LODBias) -{ - s_SpecularIBLBias = Min(LODBias, s_SpecularIBLRange); -} - -void Renderer::SetBRDFLUTTexture(TextureRef texture) -{ - s_BRDFLUTTexture = texture; - - uint32_t DestCount = 1; - uint32_t SourceCounts[] = { 1 }; - - D3D12_CPU_DESCRIPTOR_HANDLE SourceTextures[] = { - s_BRDFLUTTexture.IsValid() ? s_BRDFLUTTexture.GetSRV() : GetDefaultTexture(kWhiteOpaque2D), - }; - - DescriptorHandle dest = m_CommonTextures + 4 * s_TextureHeap.GetDescriptorSize(); - - g_Device->CopyDescriptors(1, &dest, &DestCount, DestCount, SourceTextures, SourceCounts, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); -} - -void Renderer::Shutdown(void) -{ - s_BRDFLUTTexture = nullptr; - s_RadianceCubeMap = nullptr; - s_IrradianceCubeMap = nullptr; - Lighting::Shutdown(); - TextureManager::Shutdown(); - s_TextureHeap.Destroy(); - s_SamplerHeap.Destroy(); -} - -uint8_t Renderer::GetPSO(uint16_t psoFlags) -{ - using namespace PSOFlags; - - GraphicsPSO ColorPSO = m_DefaultPSO; - - uint16_t Requirements = kHasPosition | kHasNormal; - ASSERT((psoFlags & Requirements) == Requirements); - - std::vector vertexLayout; - if (psoFlags & kHasPosition) - vertexLayout.push_back({"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D12_APPEND_ALIGNED_ELEMENT}); - if (psoFlags & kHasNormal) - vertexLayout.push_back({"NORMAL", 0, DXGI_FORMAT_R10G10B10A2_UNORM, 0, D3D12_APPEND_ALIGNED_ELEMENT}); - if (psoFlags & kHasTangent) - vertexLayout.push_back({"TANGENT", 0, DXGI_FORMAT_R10G10B10A2_UNORM, 0, D3D12_APPEND_ALIGNED_ELEMENT}); - if (psoFlags & kHasUV0) - vertexLayout.push_back({"TEXCOORD", 0, DXGI_FORMAT_R16G16_FLOAT, 0, D3D12_APPEND_ALIGNED_ELEMENT}); - else - vertexLayout.push_back({"TEXCOORD", 0, DXGI_FORMAT_R16G16_FLOAT, 1, D3D12_APPEND_ALIGNED_ELEMENT}); - if (psoFlags & kHasUV1) - vertexLayout.push_back({"TEXCOORD", 1, DXGI_FORMAT_R16G16_FLOAT, 0, D3D12_APPEND_ALIGNED_ELEMENT}); - if (psoFlags & kHasSkin) - { - vertexLayout.push_back({ "BLENDINDICES", 0, DXGI_FORMAT_R16G16B16A16_UINT, 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }); - vertexLayout.push_back({ "BLENDWEIGHT", 0, DXGI_FORMAT_R16G16B16A16_UNORM, 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }); - } - - ColorPSO.SetInputLayout((uint32_t)vertexLayout.size(), vertexLayout.data()); - - if (psoFlags & kHasSkin) - { - if (psoFlags & kHasTangent) - { - if (psoFlags & kHasUV1) - { - ColorPSO.SetVertexShader(g_pDefaultSkinVS, sizeof(g_pDefaultSkinVS)); - ColorPSO.SetPixelShader(g_pDefaultPS, sizeof(g_pDefaultPS)); - } - else - { - ColorPSO.SetVertexShader(g_pDefaultNoUV1SkinVS, sizeof(g_pDefaultNoUV1SkinVS)); - ColorPSO.SetPixelShader(g_pDefaultNoUV1PS, sizeof(g_pDefaultNoUV1PS)); - } - } - else - { - if (psoFlags & kHasUV1) - { - ColorPSO.SetVertexShader(g_pDefaultNoTangentSkinVS, sizeof(g_pDefaultNoTangentSkinVS)); - ColorPSO.SetPixelShader(g_pDefaultNoTangentPS, sizeof(g_pDefaultNoTangentPS)); - } - else - { - ColorPSO.SetVertexShader(g_pDefaultNoTangentNoUV1SkinVS, sizeof(g_pDefaultNoTangentNoUV1SkinVS)); - ColorPSO.SetPixelShader(g_pDefaultNoTangentNoUV1PS, sizeof(g_pDefaultNoTangentNoUV1PS)); - } - } - } - else - { - if (psoFlags & kHasTangent) - { - if (psoFlags & kHasUV1) - { - ColorPSO.SetVertexShader(g_pDefaultVS, sizeof(g_pDefaultVS)); - ColorPSO.SetPixelShader(g_pDefaultPS, sizeof(g_pDefaultPS)); - } - else - { - ColorPSO.SetVertexShader(g_pDefaultNoUV1VS, sizeof(g_pDefaultNoUV1VS)); - ColorPSO.SetPixelShader(g_pDefaultNoUV1PS, sizeof(g_pDefaultNoUV1PS)); - } - } - else - { - if (psoFlags & kHasUV1) - { - ColorPSO.SetVertexShader(g_pDefaultNoTangentVS, sizeof(g_pDefaultNoTangentVS)); - ColorPSO.SetPixelShader(g_pDefaultNoTangentPS, sizeof(g_pDefaultNoTangentPS)); - } - else - { - ColorPSO.SetVertexShader(g_pDefaultNoTangentNoUV1VS, sizeof(g_pDefaultNoTangentNoUV1VS)); - ColorPSO.SetPixelShader(g_pDefaultNoTangentNoUV1PS, sizeof(g_pDefaultNoTangentNoUV1PS)); - } - } - } - - if (psoFlags & kAlphaBlend) - { - ColorPSO.SetBlendState(BlendTraditional); - ColorPSO.SetDepthStencilState(DepthStateReadOnly); - } - if (psoFlags & kTwoSided) - { - ColorPSO.SetRasterizerState(RasterizerTwoSided); - } - ColorPSO.Finalize(); - - // Look for an existing PSO - for (uint32_t i = 0; i < sm_PSOs.size(); ++i) - { - if (ColorPSO.GetPipelineStateObject() == sm_PSOs[i].GetPipelineStateObject()) - { - return (uint8_t)i; - } - } - - // If not found, keep the new one, and return its index - sm_PSOs.push_back(ColorPSO); - - // The returned PSO index has read-write depth. The index+1 tests for equal depth. - ColorPSO.SetDepthStencilState(DepthStateTestEqual); - ColorPSO.Finalize(); -#ifdef DEBUG - for (uint32_t i = 0; i < sm_PSOs.size(); ++i) - ASSERT(ColorPSO.GetPipelineStateObject() != sm_PSOs[i].GetPipelineStateObject()); -#endif - sm_PSOs.push_back(ColorPSO); - - ASSERT(sm_PSOs.size() <= 256, "Ran out of room for unique PSOs"); - - return (uint8_t)sm_PSOs.size() - 2; -} - -void Renderer::DrawSkybox( GraphicsContext& gfxContext, const Camera& Camera, const D3D12_VIEWPORT& viewport, const D3D12_RECT& scissor, const Matrix3& Rotation) -{ - ScopedTimer _prof(L"Draw Skybox", gfxContext); - - __declspec(align(16)) struct SkyboxVSCB - { - Matrix4 ProjInverse; - Matrix3 ViewInverse; - Matrix3 Rotation; - } skyVSCB; - skyVSCB.ProjInverse = Invert(Camera.GetProjMatrix()); - skyVSCB.ViewInverse = Invert(Camera.GetViewMatrix()).Get3x3(); - skyVSCB.Rotation = Rotation; - - __declspec(align(16)) struct SkyboxPSCB - { - float TextureLevel; - } skyPSCB; - skyPSCB.TextureLevel = s_SpecularIBLBias; - - gfxContext.SetRootSignature(m_RootSig); - gfxContext.SetPipelineState(m_SkyboxPSO); - - gfxContext.TransitionResource(g_SceneDepthBuffer, D3D12_RESOURCE_STATE_DEPTH_READ); - gfxContext.TransitionResource(g_SceneColorBuffer, D3D12_RESOURCE_STATE_RENDER_TARGET, true); - gfxContext.SetRenderTarget(g_SceneColorBuffer.GetRTV(), g_SceneDepthBuffer.GetDSV_DepthReadOnly()); - gfxContext.SetViewportAndScissor(viewport, scissor); - - gfxContext.SetDescriptorHeap(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, s_TextureHeap.GetHeapPointer()); - gfxContext.SetDynamicConstantBufferView(kMeshConstants, sizeof(SkyboxVSCB), &skyVSCB); - gfxContext.SetDynamicConstantBufferView(kMaterialConstants, sizeof(SkyboxPSCB), &skyPSCB); - gfxContext.SetDescriptorTable(kCommonSRVs, m_CommonTextures); - gfxContext.Draw(3); -} - -void MeshSorter::AddMesh( const Mesh& mesh, float distance, - D3D12_GPU_VIRTUAL_ADDRESS meshCBV, - D3D12_GPU_VIRTUAL_ADDRESS materialCBV, - D3D12_GPU_VIRTUAL_ADDRESS bufferPtr, - const Joint* skeleton) -{ - SortKey key; - key.value = m_SortObjects.size(); - - bool alphaBlend = (mesh.psoFlags & PSOFlags::kAlphaBlend) == PSOFlags::kAlphaBlend; - bool alphaTest = (mesh.psoFlags & PSOFlags::kAlphaTest) == PSOFlags::kAlphaTest; - bool skinned = (mesh.psoFlags & PSOFlags::kHasSkin) == PSOFlags::kHasSkin; - bool twoSided = (mesh.psoFlags & PSOFlags::kTwoSided) == PSOFlags::kTwoSided; - - uint64_t depthPSO = (skinned ? 2 : 0) + (alphaTest ? 1 : 0) + (twoSided ? 4 : 0); - uint64_t shadowedDepthPSO = depthPSO + 8; - - union float_or_int { float f; uint32_t u; } dist; - dist.f = Max(distance, 0.0f); - - if (m_BatchType == kShadows) - { - if (alphaBlend) - return; - - key.passID = kZPass; - key.psoIdx = shadowedDepthPSO; - key.key = dist.u; - m_SortKeys.push_back(key.value); - m_PassCounts[kZPass]++; - } - else if (mesh.psoFlags & PSOFlags::kAlphaBlend) - { - key.passID = kTransparent; - key.psoIdx = mesh.pso; - key.key = ~dist.u; - m_SortKeys.push_back(key.value); - m_PassCounts[kTransparent]++; - } - else if (SeparateZPass || alphaTest) - { - key.passID = kZPass; - key.psoIdx = depthPSO; - key.key = dist.u; - m_SortKeys.push_back(key.value); - m_PassCounts[kZPass]++; - - key.passID = kOpaque; - key.psoIdx = mesh.pso + 1; - key.key = dist.u; - m_SortKeys.push_back(key.value); - m_PassCounts[kOpaque]++; - } - else - { - key.passID = kOpaque; - key.psoIdx = mesh.pso; - key.key = dist.u; - m_SortKeys.push_back(key.value); - m_PassCounts[kOpaque]++; - } - - SortObject object = { &mesh, skeleton, meshCBV, materialCBV, bufferPtr }; - m_SortObjects.push_back(object); -} - -void MeshSorter::Sort() -{ - struct { bool operator()(uint64_t a, uint64_t b) const { return a < b; } } Cmp; - std::sort(m_SortKeys.begin(), m_SortKeys.end(), Cmp); -} - -void MeshSorter::RenderMeshes( - DrawPass pass, - GraphicsContext& context, - GlobalConstants& globals) -{ - ASSERT(m_DSV != nullptr); - - Renderer::UpdateGlobalDescriptors(); - - context.SetRootSignature(m_RootSig); - context.SetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - context.SetDescriptorHeap(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, s_TextureHeap.GetHeapPointer()); - context.SetDescriptorHeap(D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER, s_SamplerHeap.GetHeapPointer()); - - // Set common textures - context.SetDescriptorTable(kCommonSRVs, m_CommonTextures); - - // Set common shader constants - globals.ViewProjMatrix = m_Camera->GetViewProjMatrix(); - globals.CameraPos = m_Camera->GetPosition(); - globals.IBLRange = s_SpecularIBLRange; - globals.IBLBias = 0; //s_SpecularIBLBias; - globals.DebugFlag = DebugFlag; - - globals.ShadowTexelSize[0] = 1.0f / g_ShadowBuffer.GetWidth(); - globals.InvTileDim[0] = 1.0f / Lighting::LightGridDim; - globals.InvTileDim[1] = 1.0f / Lighting::LightGridDim; - globals.TileCount[0] = Math::DivideByMultiple(g_SceneColorBuffer.GetWidth(), Lighting::LightGridDim); - globals.TileCount[1] = Math::DivideByMultiple(g_SceneColorBuffer.GetHeight(), Lighting::LightGridDim); - globals.FirstLightIndex[0] = Lighting::m_FirstConeLight; - globals.FirstLightIndex[1] = Lighting::m_FirstConeShadowedLight; - - context.SetDynamicConstantBufferView(kCommonCBV, sizeof(GlobalConstants), &globals); - - if (m_BatchType == kShadows) - { - context.TransitionResource(*m_DSV, D3D12_RESOURCE_STATE_DEPTH_WRITE, true); - context.ClearDepth(*m_DSV); - context.SetDepthStencilTarget(m_DSV->GetDSV()); - - if (m_Viewport.Width == 0) - { - m_Viewport.TopLeftX = 0.0f; - m_Viewport.TopLeftY = 0.0f; - m_Viewport.Width = (float)m_DSV->GetWidth(); - m_Viewport.Height = (float)m_DSV->GetHeight(); - m_Viewport.MaxDepth = 1.0f; - m_Viewport.MinDepth = 0.0f; - - m_Scissor.left = 1; - m_Scissor.right = m_DSV->GetWidth() - 2; - m_Scissor.top = 1; - m_Scissor.bottom = m_DSV->GetHeight() - 2; - } - } - else - { - for (uint32_t i = 0; i < m_NumRTVs; ++i) - { - ASSERT(m_RTV[i] != nullptr); - ASSERT(m_DSV->GetWidth() == m_RTV[i]->GetWidth()); - ASSERT(m_DSV->GetHeight() == m_RTV[i]->GetHeight()); - } - - if (m_Viewport.Width == 0) - { - m_Viewport.TopLeftX = 0.0f; - m_Viewport.TopLeftY = 0.0f; - m_Viewport.Width = (float)m_DSV->GetWidth(); - m_Viewport.Height = (float)m_DSV->GetHeight(); - m_Viewport.MaxDepth = 1.0f; - m_Viewport.MinDepth = 0.0f; - - m_Scissor.left = 0; - m_Scissor.right = m_DSV->GetWidth(); - m_Scissor.top = 0; - m_Scissor.bottom = m_DSV->GetWidth(); - } - } - - for ( ; m_CurrentPass <= pass; m_CurrentPass = (DrawPass)(m_CurrentPass + 1)) - { - const uint32_t passCount = m_PassCounts[m_CurrentPass]; - if (passCount == 0) - continue; - - if (m_BatchType == kDefault) - { - switch (m_CurrentPass) - { - case kZPass: - context.TransitionResource(*m_DSV, D3D12_RESOURCE_STATE_DEPTH_WRITE); - context.SetDepthStencilTarget(m_DSV->GetDSV()); - break; - case kOpaque: - if (SeparateZPass) - { - context.TransitionResource(*m_DSV, D3D12_RESOURCE_STATE_DEPTH_READ); - context.TransitionResource(g_SceneColorBuffer, D3D12_RESOURCE_STATE_RENDER_TARGET); - context.SetRenderTarget(g_SceneColorBuffer.GetRTV(), m_DSV->GetDSV_DepthReadOnly()); - } - else - { - context.TransitionResource(*m_DSV, D3D12_RESOURCE_STATE_DEPTH_WRITE); - context.TransitionResource(g_SceneColorBuffer, D3D12_RESOURCE_STATE_RENDER_TARGET); - context.SetRenderTarget(g_SceneColorBuffer.GetRTV(), m_DSV->GetDSV()); - } - break; - case kTransparent: - context.TransitionResource(*m_DSV, D3D12_RESOURCE_STATE_DEPTH_READ); - context.TransitionResource(g_SceneColorBuffer, D3D12_RESOURCE_STATE_RENDER_TARGET); - context.SetRenderTarget(g_SceneColorBuffer.GetRTV(), m_DSV->GetDSV_DepthReadOnly()); - break; - } - } - - context.SetViewportAndScissor(m_Viewport, m_Scissor); - context.FlushResourceBarriers(); - - const uint32_t lastDraw = m_CurrentDraw + passCount; - - while (m_CurrentDraw < lastDraw) - { - SortKey key; - key.value = m_SortKeys[m_CurrentDraw]; - const SortObject& object = m_SortObjects[key.objectIdx]; - const Mesh& mesh = *object.mesh; - - context.SetConstantBuffer(kMeshConstants, object.meshCBV); - context.SetConstantBuffer(kMaterialConstants, object.materialCBV); - context.SetDescriptorTable(kMaterialSRVs, s_TextureHeap[mesh.srvTable]); - context.SetDescriptorTable(kMaterialSamplers, s_SamplerHeap[mesh.samplerTable]); - if (mesh.numJoints > 0) - { - ASSERT(object.skeleton != nullptr, "Unspecified joint matrix array"); - context.SetDynamicSRV(kSkinMatrices, sizeof(Joint) * mesh.numJoints, object.skeleton + mesh.startJoint); - } - context.SetPipelineState(sm_PSOs[key.psoIdx]); - - if (m_CurrentPass == kZPass) - { - bool alphaTest = (mesh.psoFlags & PSOFlags::kAlphaTest) == PSOFlags::kAlphaTest; - uint32_t stride = alphaTest ? 16u : 12u; - if (mesh.numJoints > 0) - stride += 16; - context.SetVertexBuffer(0, {object.bufferPtr + mesh.vbDepthOffset, mesh.vbDepthSize, stride}); - } - else - { - context.SetVertexBuffer(0, {object.bufferPtr + mesh.vbOffset, mesh.vbSize, mesh.vbStride}); - } - - context.SetIndexBuffer({object.bufferPtr + mesh.ibOffset, mesh.ibSize, (DXGI_FORMAT)mesh.ibFormat}); - - for (uint32_t i = 0; i < mesh.numDraws; ++i) - context.DrawIndexed(mesh.draw[i].primCount, mesh.draw[i].startIndex, mesh.draw[i].baseVertex); - - ++m_CurrentDraw; - } - } - - if (m_BatchType == kShadows) - { - context.TransitionResource(*m_DSV, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Model/Renderer.h b/xess/samples/xess_demo/MiniEngine/Model/Renderer.h deleted file mode 100644 index 906ef79..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Renderer.h +++ /dev/null @@ -1,165 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include "../Core/GpuBuffer.h" -#include "../Core/VectorMath.h" -#include "../Core/Camera.h" -#include "../Core/CommandContext.h" -#include "../Core/UploadBuffer.h" -#include "../Core/TextureManager.h" -#include -#include - -#include - -class GraphicsPSO; -class RootSignature; -class DescriptorHeap; -class ShadowCamera; -class ShadowBuffer; -struct GlobalConstants; -struct Mesh; -struct Joint; - -namespace Renderer -{ - extern float DebugFlag; - extern BoolVar SeparateZPass; - - using namespace Math; - - extern std::vector sm_PSOs; - extern RootSignature m_RootSig; - extern DescriptorHeap s_TextureHeap; - extern DescriptorHeap s_SamplerHeap; - extern DescriptorHandle m_CommonTextures; - - enum RootBindings - { - kMeshConstants, - kMaterialConstants, - kMaterialSRVs, - kMaterialSamplers, - kCommonSRVs, - kCommonCBV, - kSkinMatrices, - - kNumRootBindings - }; - - void Initialize(void); - void Shutdown(void); - - uint8_t GetPSO(uint16_t psoFlags); - void SetIBLTextures(TextureRef diffuseIBL, TextureRef specularIBL); - void SetIBLBias(float LODBias); - void SetBRDFLUTTexture(TextureRef texture); - void UpdateGlobalDescriptors(void); - void DrawSkybox( GraphicsContext& gfxContext, const Camera& camera, const D3D12_VIEWPORT& viewport, const D3D12_RECT& scissor, const Matrix3& Rotation ); - - class MeshSorter - { - public: - enum BatchType { kDefault, kShadows }; - enum DrawPass { kZPass, kOpaque, kTransparent, kNumPasses }; - - MeshSorter(BatchType type) - { - m_BatchType = type; - m_Camera = nullptr; - m_Viewport = {}; - m_Scissor = {}; - m_NumRTVs = 0; - m_DSV = nullptr; - m_SortObjects.clear(); - m_SortKeys.clear(); - std::memset(m_PassCounts, 0, sizeof(m_PassCounts)); - m_CurrentPass = kZPass; - m_CurrentDraw = 0; - m_CullEnabled = true; - } - - void SetCamera( const BaseCamera& camera ) { m_Camera = &camera; } - void SetViewport( const D3D12_VIEWPORT& viewport ) { m_Viewport = viewport; } - void SetScissor( const D3D12_RECT& scissor ) { m_Scissor = scissor; } - void AddRenderTarget( ColorBuffer& RTV ) - { - ASSERT(m_NumRTVs < 8); - m_RTV[m_NumRTVs++] = &RTV; - } - void SetDepthStencilTarget( DepthBuffer& DSV ) { m_DSV = &DSV; } - - const Frustum& GetWorldFrustum() const { return m_Camera->GetWorldSpaceFrustum(); } - const Frustum& GetViewFrustum() const { return m_Camera->GetViewSpaceFrustum(); } - const Matrix4& GetViewMatrix() const { return m_Camera->GetViewMatrix(); } - - void AddMesh( const Mesh& mesh, float distance, - D3D12_GPU_VIRTUAL_ADDRESS meshCBV, - D3D12_GPU_VIRTUAL_ADDRESS materialCBV, - D3D12_GPU_VIRTUAL_ADDRESS bufferPtr, - const Joint* skeleton = nullptr); - - void Sort(); - - void RenderMeshes(DrawPass pass, GraphicsContext& context, GlobalConstants& globals); - - bool IsCullEnabled() const { return m_CullEnabled; } - void SetCullEnabled(bool enabled) { m_CullEnabled = enabled; } - - private: - - struct SortKey - { - union - { - uint64_t value; - struct - { - uint64_t objectIdx : 16; - uint64_t psoIdx : 12; - uint64_t key : 32; - uint64_t passID : 4; - }; - }; - }; - - struct SortObject - { - const Mesh* mesh; - const Joint* skeleton; - D3D12_GPU_VIRTUAL_ADDRESS meshCBV; - D3D12_GPU_VIRTUAL_ADDRESS materialCBV; - D3D12_GPU_VIRTUAL_ADDRESS bufferPtr; - }; - - std::vector m_SortObjects; - std::vector m_SortKeys; - BatchType m_BatchType; - uint32_t m_PassCounts[kNumPasses]; - DrawPass m_CurrentPass; - uint32_t m_CurrentDraw; - - const BaseCamera* m_Camera; - D3D12_VIEWPORT m_Viewport; - D3D12_RECT m_Scissor; - uint32_t m_NumRTVs; - ColorBuffer* m_RTV[8]; - DepthBuffer* m_DSV; - - // If culling is enabled. - bool m_CullEnabled; - }; - -} // namespace Renderer \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/BRDF.hlsli b/xess/samples/xess_demo/MiniEngine/Model/Shaders/BRDF.hlsli deleted file mode 100644 index 503a409..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/BRDF.hlsli +++ /dev/null @@ -1,161 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// Justin Saunders (ATG) - -#include "Common.hlsli" - -TextureCube radianceIBLTexture : register(t10); -TextureCube irradianceIBLTexture : register(t11); -Texture2D texSSAO : register(t12); -Texture2D texSunShadow : register(t13); -Texture2D BRDFLUTTexture : register(t14); - -// Numeric constants -static const float PI = 3.14159265; -static const float3 kDielectricSpecular = float3(0.04, 0.04, 0.04); - -struct SurfaceProperties -{ - float3 N; - float3 V; - float3 c_diff; - float3 c_spec; - float roughness; - float alpha; // roughness squared - float alphaSqr; // alpha squared - float NdotV; -}; - -struct LightProperties -{ - float3 L; - float NdotL; - float LdotH; - float NdotH; -}; - -// -// Shader Math -// - -float Pow5(float x) -{ - float xSq = x * x; - return xSq * xSq * x; -} - -// Shlick's approximation of Fresnel -float3 Fresnel_Shlick(float3 F0, float3 F90, float cosine) -{ - return lerp(F0, F90, Pow5(1.0 - cosine)); -} - -float Fresnel_Shlick(float F0, float F90, float cosine) -{ - return lerp(F0, F90, Pow5(1.0 - cosine)); -} - -// Lambertian diffuse -float3 Diffuse_Lambertian(SurfaceProperties Surface) -{ - return Surface.c_diff / PI; -} - -// Burley's diffuse BRDF -float3 Diffuse_Burley(SurfaceProperties Surface, LightProperties Light) -{ - float fd90 = 0.5 + 2.0 * Surface.roughness * Light.LdotH * Light.LdotH; - return Surface.c_diff * Fresnel_Shlick(1, fd90, Light.NdotL).x * Fresnel_Shlick(1, fd90, Surface.NdotV).x; -} - -// GGX specular D (normal distribution) -float Specular_D_GGX(SurfaceProperties Surface, LightProperties Light) -{ - float lower = Light.NdotH * Light.NdotH * (Surface.alphaSqr - 1.0) + 1.0; - return Surface.alphaSqr / max(1e-6, PI * lower * lower); -} - -float SchlickGGX(float NdotV, float alphaSqr) -{ - return 2.0 * NdotV / (NdotV + sqrt(alphaSqr + (1.0 - alphaSqr) * (NdotV * NdotV))); -} - -float G_Schlick_Smith(SurfaceProperties Surface, LightProperties Light) -{ - float GV = SchlickGGX(Surface.NdotV, Surface.alphaSqr); - float GL = SchlickGGX(Light.NdotL, Surface.alphaSqr); - - return GV * GL; -} - -// Schlick-Smith specular visibility with Hable's LdotH approximation -float G_Shlick_Smith_Hable(SurfaceProperties Surface, LightProperties Light) -{ - return 1.0 / lerp(Light.LdotH * Light.LdotH, 1, Surface.alphaSqr * 0.25); -} - -// A microfacet based BRDF. -// alpha: This is roughness squared as in the Disney PBR model by Burley et al. -// c_spec: The F0 reflectance value - 0.04 for non-metals, or RGB for metals. This is the specular albedo. -// NdotV, NdotL, LdotH, NdotH: vector dot products -// N - surface normal -// V - normalized view vector -// L - normalized direction to light -// H - normalized half vector (L+V)/2 -- halfway between L and V -float3 Specular_BRDF(SurfaceProperties Surface, LightProperties Light) -{ - // Normal Distribution term - float ND = Specular_D_GGX(Surface, Light); - - // Geometric Visibility term - //float GV = G_Shlick_Smith_Hable(Surface, Light); - float GV = G_Schlick_Smith(Surface, Light); - - // Fresnel term - float3 F = Fresnel_Shlick(Surface.c_spec, 1.0, Light.LdotH); - - return ND * GV * F; -} - -float3 Diffuse_IBL(SurfaceProperties Surface, float3x3 envRotation) -{ -#if 0 - // This is nicer but more expensive, and specular can often drown out the diffuse anyway - float LdotH = saturate(dot(Surface.N, normalize(Surface.N + Surface.V))); - float fd90 = 0.5 + 2.0 * Surface.roughness * LdotH * LdotH; - float3 DiffuseBurley = Surface.c_diff * Fresnel_Shlick(1, fd90, Surface.NdotV); - return DiffuseBurley * irradianceIBLTexture.Sample(cubeMapSampler, mul(envRotation, Surface.N)); -#else - float3 diffuseLight = irradianceIBLTexture.Sample(cubeMapSampler, mul(envRotation, Surface.N)).rgb; - float3 diffuse = diffuseLight * Surface.c_diff; - return diffuse; -#endif -} - -float3 Specular_IBL(SurfaceProperties Surface, float IBLRange, float IBLBias, float3x3 envRotation) -{ - float lod = Surface.roughness * IBLRange + IBLBias; - float2 brdf = BRDFLUTTexture.Sample(clampSampler, float2(Surface.NdotV, Surface.roughness)).rg; - float3 specularLight = radianceIBLTexture.SampleLevel(cubeMapSampler, mul(envRotation, reflect(-Surface.V, Surface.N)), lod).xyz; - float3 specular = specularLight * (Surface.c_spec * brdf.x + brdf.y); - - return specular; -} - -float3 AmbientLight( - float3 diffuse, // Diffuse albedo - float ao, // Pre-computed ambient-occlusion - float3 lightColor // Radiance of ambient light - ) -{ - return ao * diffuse * lightColor; -} \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/Common.hlsli b/xess/samples/xess_demo/MiniEngine/Model/Shaders/Common.hlsli deleted file mode 100644 index b2b697e..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/Common.hlsli +++ /dev/null @@ -1,71 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#ifndef __COMMON_HLSLI__ -#define __COMMON_HLSLI__ - -// outdated warning about for-loop variable scope -#pragma warning (disable: 3078) -// single-iteration loop -#pragma warning (disable: 3557) - -#define Renderer_RootSig \ - "RootFlags(ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT), " \ - "CBV(b0, visibility = SHADER_VISIBILITY_VERTEX), " \ - "CBV(b0, visibility = SHADER_VISIBILITY_PIXEL), " \ - "DescriptorTable(SRV(t0, numDescriptors = 10), visibility = SHADER_VISIBILITY_PIXEL)," \ - "DescriptorTable(Sampler(s0, numDescriptors = 10), visibility = SHADER_VISIBILITY_PIXEL)," \ - "DescriptorTable(SRV(t10, numDescriptors = 11), visibility = SHADER_VISIBILITY_PIXEL)," \ - "CBV(b1), " \ - "SRV(t20, visibility = SHADER_VISIBILITY_VERTEX), " \ - "StaticSampler(s10, maxAnisotropy = 8, visibility = SHADER_VISIBILITY_PIXEL)," \ - "StaticSampler(s11, visibility = SHADER_VISIBILITY_PIXEL," \ - "addressU = TEXTURE_ADDRESS_CLAMP," \ - "addressV = TEXTURE_ADDRESS_CLAMP," \ - "addressW = TEXTURE_ADDRESS_CLAMP," \ - "comparisonFunc = COMPARISON_GREATER_EQUAL," \ - "filter = FILTER_MIN_MAG_LINEAR_MIP_POINT)," \ - "StaticSampler(s12, maxAnisotropy = 8, visibility = SHADER_VISIBILITY_PIXEL)," \ - "StaticSampler(s13, maxAnisotropy = 8, visibility = SHADER_VISIBILITY_PIXEL)" - -// Common (static) samplers -SamplerState defaultSampler : register(s10); -SamplerComparisonState shadowSampler : register(s11); -SamplerState cubeMapSampler : register(s12); -SamplerState clampSampler : register(s13); - -#ifndef ENABLE_TRIANGLE_ID - #define ENABLE_TRIANGLE_ID 0 -#endif - -#if ENABLE_TRIANGLE_ID - -uint HashTriangleID(uint vertexID) -{ - // TBD SM6.1 stuff - uint Index0 = EvaluateAttributeAtVertex(vertexID, 0); - uint Index1 = EvaluateAttributeAtVertex(vertexID, 1); - uint Index2 = EvaluateAttributeAtVertex(vertexID, 2); - - // When triangles are clipped (to the near plane?) their interpolants can sometimes - // be reordered. To stabilize the ID generation, we need to sort the indices before - // forming the hash. - uint I0 = __XB_Min3_U32(Index0, Index1, Index2); - uint I1 = __XB_Med3_U32(Index0, Index1, Index2); - uint I2 = __XB_Max3_U32(Index0, Index1, Index2); - return (I2 & 0xFF) << 16 | (I1 & 0xFF) << 8 | (I0 & 0xFF0000FF); -} - -#endif // ENABLE_TRIANGLE_ID - -#endif // __COMMON_HLSLI__ diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/CutoutDepthPS.hlsl b/xess/samples/xess_demo/MiniEngine/Model/Shaders/CutoutDepthPS.hlsl deleted file mode 100644 index 15583ad..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/CutoutDepthPS.hlsl +++ /dev/null @@ -1,40 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// - -#include "Common.hlsli" - -struct VSOutput -{ - float4 pos : SV_Position; - float2 uv : TexCoord0; -}; - -Texture2D baseColorTexture : register(t0); -SamplerState baseColorSampler : register(s0); - -cbuffer MaterialConstants : register(b0) -{ - float4 baseColorFactor; - float3 emissiveFactor; - float normalTextureScale; - float2 metallicRoughnessFactor; - uint flags; -} - -[RootSignature(Renderer_RootSig)] -void main(VSOutput vsOutput) -{ - float cutoff = f16tof32(flags >> 16); - if (baseColorTexture.Sample(baseColorSampler, vsOutput.uv).a < cutoff) - discard; -} diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/CutoutDepthSkinVS.hlsl b/xess/samples/xess_demo/MiniEngine/Model/Shaders/CutoutDepthSkinVS.hlsl deleted file mode 100644 index 0e14c24..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/CutoutDepthSkinVS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// - -#define ENABLE_SKINNING -#include "CutoutDepthVS.hlsl" \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/CutoutDepthVS.hlsl b/xess/samples/xess_demo/MiniEngine/Model/Shaders/CutoutDepthVS.hlsl deleted file mode 100644 index 548bee1..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/CutoutDepthVS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// - -#define ENABLE_ALPHATEST -#include "DepthOnlyVS.hlsl" diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultNoTangentNoUV1PS.hlsl b/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultNoTangentNoUV1PS.hlsl deleted file mode 100644 index aa03a7d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultNoTangentNoUV1PS.hlsl +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// - -#define NO_TANGENT_FRAME 1 -#define NO_SECOND_UV 1 -#include "DefaultPS.hlsl" \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultNoTangentNoUV1SkinVS.hlsl b/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultNoTangentNoUV1SkinVS.hlsl deleted file mode 100644 index af2084f..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultNoTangentNoUV1SkinVS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// - -#define ENABLE_SKINNING -#include "DefaultNoTangentNoUV1VS.hlsl" \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultNoTangentNoUV1VS.hlsl b/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultNoTangentNoUV1VS.hlsl deleted file mode 100644 index 12f8327..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultNoTangentNoUV1VS.hlsl +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// - -#define NO_TANGENT_FRAME 1 -#define NO_SECOND_UV 1 -#include "DefaultVS.hlsl" \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultNoTangentPS.hlsl b/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultNoTangentPS.hlsl deleted file mode 100644 index eef71e6..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultNoTangentPS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// - -#define NO_TANGENT_FRAME 1 -#include "DefaultPS.hlsl" \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultNoTangentSkinVS.hlsl b/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultNoTangentSkinVS.hlsl deleted file mode 100644 index a21737a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultNoTangentSkinVS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// - -#define ENABLE_SKINNING -#include "DefaultNoTangentVS.hlsl" \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultNoTangentVS.hlsl b/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultNoTangentVS.hlsl deleted file mode 100644 index 7d46b74..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultNoTangentVS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// - -#define NO_TANGENT_FRAME 1 -#include "DefaultVS.hlsl" \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultNoUV1PS.hlsl b/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultNoUV1PS.hlsl deleted file mode 100644 index 63abd59..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultNoUV1PS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// - -#define NO_SECOND_UV 1 -#include "DefaultPS.hlsl" \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultNoUV1SkinVS.hlsl b/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultNoUV1SkinVS.hlsl deleted file mode 100644 index 6c36708..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultNoUV1SkinVS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// - -#define ENABLE_SKINNING -#include "DefaultNoUV1VS.hlsl" \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultNoUV1VS.hlsl b/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultNoUV1VS.hlsl deleted file mode 100644 index 2347557..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultNoUV1VS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// - -#define NO_SECOND_UV 1 -#include "DefaultVS.hlsl" \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultPS.hlsl b/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultPS.hlsl deleted file mode 100644 index 8124cc4..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultPS.hlsl +++ /dev/null @@ -1,185 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// Justin Saunders (ATG) - -#include "Common.hlsli" -#include "LightingPBR.hlsli" -#include "Core/Shaders/ShaderUtility.hlsli" - -//#define DEBUG_CHANNEL 1 - -Texture2D baseColorTexture : register(t0); -Texture2D metallicRoughnessTexture : register(t1); -Texture2D occlusionTexture : register(t2); -Texture2D emissiveTexture : register(t3); -Texture2D normalTexture : register(t4); - -SamplerState baseColorSampler : register(s0); -SamplerState metallicRoughnessSampler : register(s1); -SamplerState occlusionSampler : register(s2); -SamplerState emissiveSampler : register(s3); -SamplerState normalSampler : register(s4); - -cbuffer MaterialConstants : register(b0) -{ - float4 baseColorFactor; - float3 emissiveFactor; - float normalTextureScale; - float2 metallicRoughnessFactor; - uint flags; -} - -struct VSOutput -{ - float4 position : SV_POSITION; - float3 normal : NORMAL; -#ifndef NO_TANGENT_FRAME - float4 tangent : TANGENT; -#endif - float2 uv0 : TEXCOORD0; -#ifndef NO_SECOND_UV - float2 uv1 : TEXCOORD1; -#endif - float3 worldPos : TEXCOORD2; - float3 sunShadowCoord : TEXCOORD3; -}; - -// Flag helpers -static const uint BASECOLOR = 0; -static const uint METALLICROUGHNESS = 1; -static const uint OCCLUSION = 2; -static const uint EMISSIVE = 3; -static const uint NORMAL = 4; -#ifdef NO_SECOND_UV -#define UVSET( offset ) vsOutput.uv0 -#else -#define UVSET( offset ) lerp(vsOutput.uv0, vsOutput.uv1, (flags >> offset) & 1) -#endif - -float3 sRGBToLinear(float3 srgbColor) -{ - return RemoveDisplayProfile(srgbColor, DISPLAY_PLANE_FORMAT); -} - -float4 sRGBToLinear(float4 srgbColor) -{ - return float4(sRGBToLinear(srgbColor.xyz), srgbColor.w); -} - -float3 ComputeNormal(VSOutput vsOutput, bool isFrontFace) -{ - float3 normal = normalize(vsOutput.normal); - -#ifdef NO_TANGENT_FRAME - normal = normalize(lerp(-normal, normal, float(isFrontFace))); - return normal; -#else - // Construct tangent frame - float3 tangent = normalize(vsOutput.tangent.xyz); - float3 bitangent = normalize(cross(normal, tangent)) * vsOutput.tangent.w; - - float3x3 tangentFrame; - if (isFrontFace) - { - tangentFrame = float3x3(tangent, bitangent, normal); - } - else - { - tangentFrame = float3x3(-tangent, -bitangent, -normal); - } - - // Read normal map and convert to SNORM (TODO: convert all normal maps to R8G8B8A8_SNORM?) - normal = normalTexture.SampleBias(normalSampler, UVSET(NORMAL), ViewMipBias) * 2.0 - 1.0; - - // glTF spec says to normalize N before and after scaling, but that's excessive - normal = normalize(normal * float3(normalTextureScale, normalTextureScale, 1)); - - // Multiply by transpose (reverse order) - return mul(normal, tangentFrame); -#endif -} - - -[RootSignature(Renderer_RootSig)] -float4 main(VSOutput vsOutput, bool isFrontFace : SV_IsFrontFace) - : SV_Target0 -{ - // Load and modulate textures - float4 baseColor = baseColorFactor * sRGBToLinear(baseColorTexture.SampleBias(baseColorSampler, UVSET(BASECOLOR), ViewMipBias)); - float2 metallicRoughness = metallicRoughnessFactor * - metallicRoughnessTexture.SampleBias(metallicRoughnessSampler, UVSET(METALLICROUGHNESS), ViewMipBias).bg; // b: metallic, g: roughness - float occlusion = occlusionTexture.SampleBias(occlusionSampler, UVSET(OCCLUSION), ViewMipBias); - float3 emissive = emissiveFactor * sRGBToLinear(emissiveTexture.SampleBias(emissiveSampler, UVSET(EMISSIVE), ViewMipBias)); - float3 normal = ComputeNormal(vsOutput, isFrontFace); - - SurfaceProperties Surface; - Surface.N = normal; - Surface.V = normalize(ViewerPos - vsOutput.worldPos); - Surface.NdotV = clamp(dot(Surface.N, Surface.V), 1e-6, 1.0f); - Surface.c_diff = baseColor.rgb * (1 - kDielectricSpecular) * (1 - metallicRoughness.x) * occlusion; - Surface.c_spec = lerp(kDielectricSpecular, baseColor.rgb, metallicRoughness.x) * occlusion; - Surface.roughness = metallicRoughness.y; - Surface.alpha = metallicRoughness.y * metallicRoughness.y; - Surface.alphaSqr = Surface.alpha * Surface.alpha; - - // Begin accumulating light starting with emissive - float3 colorAccum = emissive; - - // Add IBL - colorAccum += Diffuse_IBL(Surface, EnvRotation); - colorAccum += Specular_IBL(Surface, IBLRange, IBLBias, EnvRotation); - - uint2 pixelPos = uint2(vsOutput.position.xy); - float ssao = texSSAO[pixelPos]; - - // Apply AO - Surface.c_diff *= ssao; - Surface.c_spec *= ssao; - - // Apply sun lighting - colorAccum += ApplyDirectionalLight(Surface, SunDirection, SunIntensity, vsOutput.sunShadowCoord, texSunShadow ); - - // Apply other scene lighting - ShadeLights(colorAccum, pixelPos, Surface, vsOutput.worldPos, flags); - -#ifndef DEBUG_CHANNEL - return float4(colorAccum, baseColor.a); -#else - int debug = (int)DebugFlag; - if (debug == 1) // albedo - { - return baseColor; - } - else if (debug == 2) // normal - { - return float4(normal, baseColor.a); - } - else if (debug == 3) // metal - { - return float4(metallicRoughness.x, metallicRoughness.x, metallicRoughness.x, baseColor.a); - } - else if (debug == 4) // roughness - { - return float4(metallicRoughness.y, metallicRoughness.y, metallicRoughness.y, baseColor.a); - } - else if (debug == 5) // occlusion - { - return float4(occlusion, occlusion, occlusion, baseColor.a); - } - else if (debug == 6) // emissive - { - return float4(emissive, baseColor.a); - } - else - return float4(colorAccum, baseColor.a); -#endif -} diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultSkinVS.hlsl b/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultSkinVS.hlsl deleted file mode 100644 index 1719b00..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultSkinVS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// - -#define ENABLE_SKINNING -#include "DefaultVS.hlsl" \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultVS.hlsl b/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultVS.hlsl deleted file mode 100644 index 54064de..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DefaultVS.hlsl +++ /dev/null @@ -1,126 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// - -#include "Common.hlsli" - -#ifdef ENABLE_SKINNING -//#undef ENABLE_SKINNING -#endif - -cbuffer MeshConstants : register(b0) -{ - float4x4 WorldMatrix; // Object to world - float3x3 WorldIT; // Object normal to world normal -}; - -cbuffer GlobalConstants : register(b1) -{ - float4x4 ViewProjMatrix; - float4x4 SunShadowMatrix; - float3 ViewerPos; - float3 SunDirection; - float3 SunIntensity; -} - -#ifdef ENABLE_SKINNING -struct Joint -{ - float4x4 PosMatrix; - float4x3 NrmMatrix; // Inverse-transpose of PosMatrix -}; - -StructuredBuffer Joints : register(t20); -#endif - -struct VSInput -{ - float3 position : POSITION; - float3 normal : NORMAL; -#ifndef NO_TANGENT_FRAME - float4 tangent : TANGENT; -#endif - float2 uv0 : TEXCOORD0; -#ifndef NO_SECOND_UV - float2 uv1 : TEXCOORD1; -#endif -#ifdef ENABLE_SKINNING - uint4 jointIndices : BLENDINDICES; - float4 jointWeights : BLENDWEIGHT; -#endif -}; - -struct VSOutput -{ - float4 position : SV_POSITION; - float3 normal : NORMAL; -#ifndef NO_TANGENT_FRAME - float4 tangent : TANGENT; -#endif - float2 uv0 : TEXCOORD0; -#ifndef NO_SECOND_UV - float2 uv1 : TEXCOORD1; -#endif - float3 worldPos : TEXCOORD2; - float3 sunShadowCoord : TEXCOORD3; -}; - -[RootSignature(Renderer_RootSig)] -VSOutput main(VSInput vsInput) -{ - VSOutput vsOutput; - - float4 position = float4(vsInput.position, 1.0); - float3 normal = vsInput.normal * 2 - 1; -#ifndef NO_TANGENT_FRAME - float4 tangent = vsInput.tangent * 2 - 1; -#endif - -#ifdef ENABLE_SKINNING - // I don't like this hack. The weights should be normalized already, but something is fishy. - float4 weights = vsInput.jointWeights / dot(vsInput.jointWeights, 1); - - float4x4 skinPosMat = - Joints[vsInput.jointIndices.x].PosMatrix * weights.x + - Joints[vsInput.jointIndices.y].PosMatrix * weights.y + - Joints[vsInput.jointIndices.z].PosMatrix * weights.z + - Joints[vsInput.jointIndices.w].PosMatrix * weights.w; - - position = mul(skinPosMat, position); - - float4x3 skinNrmMat = - Joints[vsInput.jointIndices.x].NrmMatrix * weights.x + - Joints[vsInput.jointIndices.y].NrmMatrix * weights.y + - Joints[vsInput.jointIndices.z].NrmMatrix * weights.z + - Joints[vsInput.jointIndices.w].NrmMatrix * weights.w; - - normal = mul(skinNrmMat, normal).xyz; -#ifndef NO_TANGENT_FRAME - tangent.xyz = mul(skinNrmMat, tangent.xyz).xyz; -#endif - -#endif - - vsOutput.worldPos = mul(WorldMatrix, position).xyz; - vsOutput.position = mul(ViewProjMatrix, float4(vsOutput.worldPos, 1.0)); - vsOutput.sunShadowCoord = mul(SunShadowMatrix, float4(vsOutput.worldPos, 1.0)).xyz; - vsOutput.normal = mul(WorldIT, normal); -#ifndef NO_TANGENT_FRAME - vsOutput.tangent = float4(mul(WorldIT, tangent.xyz), tangent.w); -#endif - vsOutput.uv0 = vsInput.uv0; -#ifndef NO_SECOND_UV - vsOutput.uv1 = vsInput.uv1; -#endif - - return vsOutput; -} diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DepthOnlySkinVS.hlsl b/xess/samples/xess_demo/MiniEngine/Model/Shaders/DepthOnlySkinVS.hlsl deleted file mode 100644 index 74ad2a7..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DepthOnlySkinVS.hlsl +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// - -#define ENABLE_SKINNING -#include "DepthOnlyVS.hlsl" \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DepthOnlyVS.hlsl b/xess/samples/xess_demo/MiniEngine/Model/Shaders/DepthOnlyVS.hlsl deleted file mode 100644 index 01ee81a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DepthOnlyVS.hlsl +++ /dev/null @@ -1,90 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// - -#include "Common.hlsli" - -#ifdef ENABLE_SKINNING -//#undef ENABLE_SKINNING -#endif - -cbuffer MeshConstants : register(b0) -{ - float4x4 WorldMatrix; // Object to world - float3x3 WorldIT; // Object normal to world normal -}; - -cbuffer GlobalConstants : register(b1) -{ - float4x4 ViewProjMatrix; -} - -#ifdef ENABLE_SKINNING -struct Joint -{ - float4x4 PosMatrix; - float4x3 NrmMatrix; // Inverse-transpose of PosMatrix -}; - -StructuredBuffer Joints : register(t20); -#endif - -struct VSInput -{ - float3 position : POSITION; -#ifdef ENABLE_ALPHATEST - float2 uv0 : TEXCOORD0; -#endif -#ifdef ENABLE_SKINNING - uint4 jointIndices : BLENDINDICES; - float4 jointWeights : BLENDWEIGHT; -#endif -}; - -struct VSOutput -{ - float4 position : SV_POSITION; -#ifdef ENABLE_ALPHATEST - float2 uv0 : TEXCOORD0; -#endif -}; - -[RootSignature(Renderer_RootSig)] -VSOutput main(VSInput vsInput) -{ - VSOutput vsOutput; - - float4 position = float4(vsInput.position, 1.0); - -#ifdef ENABLE_SKINNING - // I don't like this hack. The weights should be normalized already, but something is fishy. - float4 weights = vsInput.jointWeights / dot(vsInput.jointWeights, 1); - - float4x4 skinPosMat = - Joints[vsInput.jointIndices.x].PosMatrix * weights.x + - Joints[vsInput.jointIndices.y].PosMatrix * weights.y + - Joints[vsInput.jointIndices.z].PosMatrix * weights.z + - Joints[vsInput.jointIndices.w].PosMatrix * weights.w; - - position = mul(skinPosMat, position); - -#endif - - float3 worldPos = mul(WorldMatrix, position).xyz; - vsOutput.position = mul(ViewProjMatrix, float4(worldPos, 1.0)); - -#ifdef ENABLE_ALPHATEST - vsOutput.uv0 = vsInput.uv0; -#endif - - return vsOutput; -} diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DepthViewerPS.hlsl b/xess/samples/xess_demo/MiniEngine/Model/Shaders/DepthViewerPS.hlsl deleted file mode 100644 index 72f8e74..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DepthViewerPS.hlsl +++ /dev/null @@ -1,29 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// - -#include "Common.hlsli" - -struct VSOutput -{ - float4 pos : SV_Position; - float2 uv : TexCoord0; -}; - -Texture2D texDiffuse : register(t0); - -[RootSignature(Renderer_RootSig)] -void main(VSOutput vsOutput) -{ - if (texDiffuse.Sample(defaultSampler, vsOutput.uv).a < 0.5) - discard; -} diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DepthViewerVS.hlsl b/xess/samples/xess_demo/MiniEngine/Model/Shaders/DepthViewerVS.hlsl deleted file mode 100644 index e9f804a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/DepthViewerVS.hlsl +++ /dev/null @@ -1,40 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// - -#include "Common.hlsli" - -cbuffer VSConstants : register(b0) -{ - float4x4 WVP; -}; - -struct VSInput -{ - float3 pos : POSITION; - float2 uv : TEXCOORD; -}; - -struct VSOutput -{ - float4 pos : SV_Position; - float2 uv : TexCoord0; -}; - -[RootSignature(Renderer_RootSig)] -VSOutput main(VSInput vsInput) -{ - VSOutput vsOutput; - vsOutput.pos = mul(WVP, float4(vsInput.pos, 1.0)); - vsOutput.uv = vsInput.uv; - return vsOutput; -} diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/FillLightGrid16CS.hlsl b/xess/samples/xess_demo/MiniEngine/Model/Shaders/FillLightGrid16CS.hlsl deleted file mode 100644 index db498e1..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/FillLightGrid16CS.hlsl +++ /dev/null @@ -1,5 +0,0 @@ -#define WORK_GROUP_SIZE_X 16 -#define WORK_GROUP_SIZE_Y 16 -#define WORK_GROUP_SIZE_Z 1 - -#include "FillLightGridCS.hlsli" diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/FillLightGrid24CS.hlsl b/xess/samples/xess_demo/MiniEngine/Model/Shaders/FillLightGrid24CS.hlsl deleted file mode 100644 index 16e761d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/FillLightGrid24CS.hlsl +++ /dev/null @@ -1,5 +0,0 @@ -#define WORK_GROUP_SIZE_X 24 -#define WORK_GROUP_SIZE_Y 24 -#define WORK_GROUP_SIZE_Z 1 - -#include "FillLightGridCS.hlsli" diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/FillLightGrid32CS.hlsl b/xess/samples/xess_demo/MiniEngine/Model/Shaders/FillLightGrid32CS.hlsl deleted file mode 100644 index 7004ff5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/FillLightGrid32CS.hlsl +++ /dev/null @@ -1,5 +0,0 @@ -#define WORK_GROUP_SIZE_X 32 -#define WORK_GROUP_SIZE_Y 32 -#define WORK_GROUP_SIZE_Z 1 - -#include "FillLightGridCS.hlsli" diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/FillLightGrid8CS.hlsl b/xess/samples/xess_demo/MiniEngine/Model/Shaders/FillLightGrid8CS.hlsl deleted file mode 100644 index 3493cd6..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/FillLightGrid8CS.hlsl +++ /dev/null @@ -1,5 +0,0 @@ -#define WORK_GROUP_SIZE_X 8 -#define WORK_GROUP_SIZE_Y 8 -#define WORK_GROUP_SIZE_Z 1 - -#include "FillLightGridCS.hlsli" diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/FillLightGridCS.hlsli b/xess/samples/xess_demo/MiniEngine/Model/Shaders/FillLightGridCS.hlsli deleted file mode 100644 index 18569a8..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/FillLightGridCS.hlsli +++ /dev/null @@ -1,220 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): Alex Nankervis -// - -#include "LightGrid.hlsli" - -// outdated warning about for-loop variable scope -#pragma warning (disable: 3078) - -#define FLT_MIN 1.175494351e-38F // min positive value -#define FLT_MAX 3.402823466e+38F // max value -#define PI 3.1415926535f -#define TWOPI 6.283185307f - -cbuffer CSConstants : register(b0) -{ - float4x4 ViewProjMatrix; - uint ViewportWidth, ViewportHeight; - float InvTileDim; - float RcpZMagic; - uint TileCountX; - uint Transparent; -}; - -StructuredBuffer lightBuffer : register(t0); -Texture2D depthTex : register(t1); -RWByteAddressBuffer lightGrid : register(u0); -RWByteAddressBuffer lightGridBitMask : register(u1); - -groupshared uint minDepthUInt; -groupshared uint maxDepthUInt; - -groupshared uint tileLightCountSphere; -groupshared uint tileLightCountCone; -groupshared uint tileLightCountConeShadowed; - -groupshared uint tileLightIndicesSphere[MAX_LIGHTS]; -groupshared uint tileLightIndicesCone[MAX_LIGHTS]; -groupshared uint tileLightIndicesConeShadowed[MAX_LIGHTS]; - -groupshared uint4 tileLightBitMask; - -#define _RootSig \ - "RootFlags(0), " \ - "CBV(b0), " \ - "DescriptorTable(SRV(t0, numDescriptors = 2))," \ - "DescriptorTable(UAV(u0, numDescriptors = 2))" - -[RootSignature(_RootSig)] -[numthreads(8, 8, 1)] -void main( - uint2 Gid : SV_GroupID, - uint2 GTid : SV_GroupThreadID, - uint GI : SV_GroupIndex) -{ - // initialize shared data - if (GI == 0) - { - tileLightCountSphere = 0; - tileLightCountCone = 0; - tileLightCountConeShadowed = 0; - tileLightBitMask = 0; - minDepthUInt = 0xffffffff; - maxDepthUInt = 0; - } - GroupMemoryBarrierWithGroupSync(); - - // Read all depth values for this tile and compute the tile min and max values - for (uint dx = GTid.x; dx < WORK_GROUP_SIZE_X; dx += 8) - { - for (uint dy = GTid.y; dy < WORK_GROUP_SIZE_Y; dy += 8) - { - uint2 DTid = Gid * uint2(WORK_GROUP_SIZE_X, WORK_GROUP_SIZE_Y) + uint2(dx, dy); - - // If pixel coordinates are in bounds... - if (DTid.x < ViewportWidth && DTid.y < ViewportHeight) - { - // Load and compare depth - uint depthUInt = asuint(depthTex[DTid.xy]); - InterlockedMin(minDepthUInt, depthUInt); - InterlockedMax(maxDepthUInt, depthUInt); - } - } - } - - // Set to near plane for transparent objects - // since they have depth values in the depth buffer. - if (Transparent) - { - maxDepthUInt = 1; - } - - GroupMemoryBarrierWithGroupSync(); - //float tileMinDepth = asfloat(minDepthUInt); - //float tileMaxDepth = asfloat(maxDepthUInt); - float tileMinDepth = (rcp(asfloat(maxDepthUInt)) - 1.0) * RcpZMagic; - float tileMaxDepth = (rcp(asfloat(minDepthUInt)) - 1.0) * RcpZMagic; - float tileDepthRange = tileMaxDepth - tileMinDepth; - tileDepthRange = max(tileDepthRange, FLT_MIN); // don't allow a depth range of 0 - float invTileDepthRange = rcp(tileDepthRange); - // TODO: near/far clipping planes seem to be falling apart at or near the max depth with infinite projections - - // construct transform from world space to tile space (projection space constrained to tile area) - float2 invTileSize2X = float2(ViewportWidth, ViewportHeight) * InvTileDim; - // D3D-specific [0, 1] depth range ortho projection - // (but without negation of Z, since we already have that from the projection matrix) - float3 tileBias = float3( - -2.0 * float(Gid.x) + invTileSize2X.x - 1.0, - -2.0 * float(Gid.y) + invTileSize2X.y - 1.0, - -tileMinDepth * invTileDepthRange); - float4x4 projToTile = float4x4( - invTileSize2X.x, 0, 0, tileBias.x, - 0, -invTileSize2X.y, 0, tileBias.y, - 0, 0, invTileDepthRange, tileBias.z, - 0, 0, 0, 1 - ); - float4x4 tileMVP = mul(projToTile, ViewProjMatrix); - - // extract frustum planes (these will be in world space) - float4 frustumPlanes[6]; - frustumPlanes[0] = tileMVP[3] + tileMVP[0]; - frustumPlanes[1] = tileMVP[3] - tileMVP[0]; - frustumPlanes[2] = tileMVP[3] + tileMVP[1]; - frustumPlanes[3] = tileMVP[3] - tileMVP[1]; - frustumPlanes[4] = tileMVP[3] + tileMVP[2]; - frustumPlanes[5] = tileMVP[3] - tileMVP[2]; - for (int n = 0; n < 6; n++) - { - frustumPlanes[n] *= rsqrt(dot(frustumPlanes[n].xyz, frustumPlanes[n].xyz)); - } - - uint tileIndex = GetTileIndex(Gid.xy, TileCountX); - uint tileOffset = GetTileOffset(tileIndex); - - uint4 perThreadLightBitMask = 0; - - // find set of lights that overlap this tile - for (uint lightIndex = GI; lightIndex < MAX_LIGHTS; lightIndex += 64) - { - LightData lightData = lightBuffer[lightIndex]; - float3 lightWorldPos = lightData.pos; - float lightCullRadius = sqrt(lightData.radiusSq); - - bool overlapping = true; - for (int p = 0; p < 6; p++) - { - float d = dot(lightWorldPos, frustumPlanes[p].xyz) + frustumPlanes[p].w; - if (d < -lightCullRadius) - { - overlapping = false; - } - } - - if (!overlapping) - continue; - - uint slot; - - switch (lightData.type) - { - case 0: // sphere - InterlockedAdd(tileLightCountSphere, 1, slot); - tileLightIndicesSphere[slot] = lightIndex; - break; - - case 1: // cone - InterlockedAdd(tileLightCountCone, 1, slot); - tileLightIndicesCone[slot] = lightIndex; - break; - - case 2: // cone w/ shadow map - InterlockedAdd(tileLightCountConeShadowed, 1, slot); - tileLightIndicesConeShadowed[slot] = lightIndex; - break; - } - - // update bitmask - InterlockedOr(tileLightBitMask[lightIndex / 32], 1 << (lightIndex % 32)); - } - - GroupMemoryBarrierWithGroupSync(); - - if (GI == 0) - { - uint lightCount = - ((tileLightCountSphere & 0xff) << 0) | - ((tileLightCountCone & 0xff) << 8) | - ((tileLightCountConeShadowed & 0xff) << 16); - lightGrid.Store(tileOffset + 0, lightCount); - - uint storeOffset = tileOffset + 4; - uint n; - for (n = 0; n < tileLightCountSphere; n++) - { - lightGrid.Store(storeOffset, tileLightIndicesSphere[n]); - storeOffset += 4; - } - for (n = 0; n < tileLightCountCone; n++) - { - lightGrid.Store(storeOffset, tileLightIndicesCone[n]); - storeOffset += 4; - } - for (n = 0; n < tileLightCountConeShadowed; n++) - { - lightGrid.Store(storeOffset, tileLightIndicesConeShadowed[n]); - storeOffset += 4; - } - - lightGridBitMask.Store4(tileIndex * 16, tileLightBitMask); - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/LightGrid.hlsli b/xess/samples/xess_demo/MiniEngine/Model/Shaders/LightGrid.hlsli deleted file mode 100644 index 460e092..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/LightGrid.hlsli +++ /dev/null @@ -1,44 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): Alex Nankervis -// - -// keep in sync with C code -#define MAX_LIGHTS 128 -#define TILE_SIZE (4 + MAX_LIGHTS * 4) - -struct LightData -{ - float3 pos; - float radiusSq; - - float3 color; - uint type; - - float3 coneDir; - float2 coneAngles; // x = 1.0f / (cos(coneInner) - cos(coneOuter)), y = cos(coneOuter) - - float4x4 shadowTextureMatrix; - float padding[3]; -}; - -uint2 GetTilePos(float2 pos, float2 invTileDim) -{ - return pos * invTileDim; -} -uint GetTileIndex(uint2 tilePos, uint tileCountX) -{ - return tilePos.y * tileCountX + tilePos.x; -} -uint GetTileOffset(uint tileIndex) -{ - return tileIndex * TILE_SIZE; -} diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/Lighting.hlsli b/xess/samples/xess_demo/MiniEngine/Model/Shaders/Lighting.hlsli deleted file mode 100644 index 15aa79b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/Lighting.hlsli +++ /dev/null @@ -1,612 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// Alex Nankervis -// -// Thanks to Michal Drobot for his feedback. - -#include "Common.hlsli" -#include "LightGrid.hlsli" - -cbuffer PSConstants : register(b0) -{ - float3 SunDirection; - float3 SunColor; - float3 AmbientColor; - float4 ShadowTexelSize; - - float4 InvTileDim; - uint4 TileCount; - uint4 FirstLightIndex; - - uint FrameIndexMod2; -} - -StructuredBuffer lightBuffer : register(t14); -Texture2DArray lightShadowArrayTex : register(t15); -ByteAddressBuffer lightGrid : register(t16); -ByteAddressBuffer lightGridBitMask : register(t17); - -void AntiAliasSpecular( inout float3 texNormal, inout float gloss ) -{ - float normalLenSq = dot(texNormal, texNormal); - float invNormalLen = rsqrt(normalLenSq); - texNormal *= invNormalLen; - float normalLen = normalLenSq * invNormalLen; - float flatness = saturate(1 - abs(ddx(normalLen)) - abs(ddy(normalLen))); - gloss = exp2(lerp(0, log2(gloss), flatness)); -} - -// Apply fresnel to modulate the specular albedo -void FSchlick( inout float3 specular, inout float3 diffuse, float3 lightDir, float3 halfVec ) -{ - float fresnel = pow(1.0 - saturate(dot(lightDir, halfVec)), 5.0); - specular = lerp(specular, 1, fresnel); - diffuse = lerp(diffuse, 0, fresnel); -} - -float3 ApplyAmbientLight( - float3 diffuse, // Diffuse albedo - float ao, // Pre-computed ambient-occlusion - float3 lightColor // Radiance of ambient light - ) -{ - return ao * diffuse * lightColor; -} - -float GetDirectionalShadow( float3 ShadowCoord, Texture2D texShadow ) -{ -#ifdef SINGLE_SAMPLE - float result = texShadow.SampleCmpLevelZero( shadowSampler, ShadowCoord.xy, ShadowCoord.z ); -#else - const float Dilation = 2.0; - float d1 = Dilation * ShadowTexelSize.x * 0.125; - float d2 = Dilation * ShadowTexelSize.x * 0.875; - float d3 = Dilation * ShadowTexelSize.x * 0.625; - float d4 = Dilation * ShadowTexelSize.x * 0.375; - float result = ( - 2.0 * texShadow.SampleCmpLevelZero( shadowSampler, ShadowCoord.xy, ShadowCoord.z ) + - texShadow.SampleCmpLevelZero( shadowSampler, ShadowCoord.xy + float2(-d2, d1), ShadowCoord.z ) + - texShadow.SampleCmpLevelZero( shadowSampler, ShadowCoord.xy + float2(-d1, -d2), ShadowCoord.z ) + - texShadow.SampleCmpLevelZero( shadowSampler, ShadowCoord.xy + float2( d2, -d1), ShadowCoord.z ) + - texShadow.SampleCmpLevelZero( shadowSampler, ShadowCoord.xy + float2( d1, d2), ShadowCoord.z ) + - texShadow.SampleCmpLevelZero( shadowSampler, ShadowCoord.xy + float2(-d4, d3), ShadowCoord.z ) + - texShadow.SampleCmpLevelZero( shadowSampler, ShadowCoord.xy + float2(-d3, -d4), ShadowCoord.z ) + - texShadow.SampleCmpLevelZero( shadowSampler, ShadowCoord.xy + float2( d4, -d3), ShadowCoord.z ) + - texShadow.SampleCmpLevelZero( shadowSampler, ShadowCoord.xy + float2( d3, d4), ShadowCoord.z ) - ) / 10.0; -#endif - return result * result; -} - -float GetShadowConeLight(uint lightIndex, float3 shadowCoord) -{ - float result = lightShadowArrayTex.SampleCmpLevelZero( - shadowSampler, float3(shadowCoord.xy, lightIndex), shadowCoord.z); - return result * result; -} - -float3 ApplyLightCommon( - float3 diffuseColor, // Diffuse albedo - float3 specularColor, // Specular albedo - float specularMask, // Where is it shiny or dingy? - float gloss, // Specular power - float3 normal, // World-space normal - float3 viewDir, // World-space vector from eye to point - float3 lightDir, // World-space vector from point to light - float3 lightColor // Radiance of directional light - ) -{ - float3 halfVec = normalize(lightDir - viewDir); - float nDotH = saturate(dot(halfVec, normal)); - - FSchlick( diffuseColor, specularColor, lightDir, halfVec ); - - float specularFactor = specularMask * pow(nDotH, gloss) * (gloss + 2) / 8; - - float nDotL = saturate(dot(normal, lightDir)); - - return nDotL * lightColor * (diffuseColor + specularFactor * specularColor); -} - -float3 ApplyDirectionalLight( - float3 diffuseColor, // Diffuse albedo - float3 specularColor, // Specular albedo - float specularMask, // Where is it shiny or dingy? - float gloss, // Specular power - float3 normal, // World-space normal - float3 viewDir, // World-space vector from eye to point - float3 lightDir, // World-space vector from point to light - float3 lightColor, // Radiance of directional light - float3 shadowCoord, // Shadow coordinate (Shadow map UV & light-relative Z) - Texture2D ShadowMap - ) -{ - float shadow = GetDirectionalShadow(shadowCoord, ShadowMap); - - return shadow * ApplyLightCommon( - diffuseColor, - specularColor, - specularMask, - gloss, - normal, - viewDir, - lightDir, - lightColor - ); -} - -float3 ApplyPointLight( - float3 diffuseColor, // Diffuse albedo - float3 specularColor, // Specular albedo - float specularMask, // Where is it shiny or dingy? - float gloss, // Specular power - float3 normal, // World-space normal - float3 viewDir, // World-space vector from eye to point - float3 worldPos, // World-space fragment position - float3 lightPos, // World-space light position - float lightRadiusSq, - float3 lightColor // Radiance of directional light - ) -{ - float3 lightDir = lightPos - worldPos; - float lightDistSq = dot(lightDir, lightDir); - float invLightDist = rsqrt(lightDistSq); - lightDir *= invLightDist; - - // modify 1/d^2 * R^2 to fall off at a fixed radius - // (R/d)^2 - d/R = [(1/d^2) - (1/R^2)*(d/R)] * R^2 - float distanceFalloff = lightRadiusSq * (invLightDist * invLightDist); - distanceFalloff = max(0, distanceFalloff - rsqrt(distanceFalloff)); - - return distanceFalloff * ApplyLightCommon( - diffuseColor, - specularColor, - specularMask, - gloss, - normal, - viewDir, - lightDir, - lightColor - ); -} - -float3 ApplyConeLight( - float3 diffuseColor, // Diffuse albedo - float3 specularColor, // Specular albedo - float specularMask, // Where is it shiny or dingy? - float gloss, // Specular power - float3 normal, // World-space normal - float3 viewDir, // World-space vector from eye to point - float3 worldPos, // World-space fragment position - float3 lightPos, // World-space light position - float lightRadiusSq, - float3 lightColor, // Radiance of directional light - float3 coneDir, - float2 coneAngles - ) -{ - float3 lightDir = lightPos - worldPos; - float lightDistSq = dot(lightDir, lightDir); - float invLightDist = rsqrt(lightDistSq); - lightDir *= invLightDist; - - // modify 1/d^2 * R^2 to fall off at a fixed radius - // (R/d)^2 - d/R = [(1/d^2) - (1/R^2)*(d/R)] * R^2 - float distanceFalloff = lightRadiusSq * (invLightDist * invLightDist); - distanceFalloff = max(0, distanceFalloff - rsqrt(distanceFalloff)); - - float coneFalloff = dot(-lightDir, coneDir); - coneFalloff = saturate((coneFalloff - coneAngles.y) * coneAngles.x); - - return (coneFalloff * distanceFalloff) * ApplyLightCommon( - diffuseColor, - specularColor, - specularMask, - gloss, - normal, - viewDir, - lightDir, - lightColor - ); -} - -float3 ApplyConeShadowedLight( - float3 diffuseColor, // Diffuse albedo - float3 specularColor, // Specular albedo - float specularMask, // Where is it shiny or dingy? - float gloss, // Specular power - float3 normal, // World-space normal - float3 viewDir, // World-space vector from eye to point - float3 worldPos, // World-space fragment position - float3 lightPos, // World-space light position - float lightRadiusSq, - float3 lightColor, // Radiance of directional light - float3 coneDir, - float2 coneAngles, - float4x4 shadowTextureMatrix, - uint lightIndex - ) -{ - float4 shadowCoord = mul(shadowTextureMatrix, float4(worldPos, 1.0)); - shadowCoord.xyz *= rcp(shadowCoord.w); - float shadow = GetShadowConeLight(lightIndex, shadowCoord.xyz); - - return shadow * ApplyConeLight( - diffuseColor, - specularColor, - specularMask, - gloss, - normal, - viewDir, - worldPos, - lightPos, - lightRadiusSq, - lightColor, - coneDir, - coneAngles - ); -} - -// options for F+ variants and optimizations -#if 0 // SM6.0 -#define _WAVE_OP -#endif - -// options for F+ variants and optimizations -#ifdef _WAVE_OP // SM 6.0 (new shader compiler) - -// choose one of these: -//# define BIT_MASK -# define BIT_MASK_SORTED -//# define SCALAR_LOOP -//# define SCALAR_BRANCH - -// enable to amortize latency of vector read in exchange for additional VGPRs being held -# define LIGHT_GRID_PRELOADING - -// configured for 32 sphere lights, 64 cone lights, and 32 cone shadowed lights -# define POINT_LIGHT_GROUPS 1 -# define SPOT_LIGHT_GROUPS 2 -# define SHADOWED_SPOT_LIGHT_GROUPS 1 -# define POINT_LIGHT_GROUPS_TAIL POINT_LIGHT_GROUPS -# define SPOT_LIGHT_GROUPS_TAIL POINT_LIGHT_GROUPS_TAIL + SPOT_LIGHT_GROUPS -# define SHADOWED_SPOT_LIGHT_GROUPS_TAIL SPOT_LIGHT_GROUPS_TAIL + SHADOWED_SPOT_LIGHT_GROUPS - -uint GetGroupBits(uint groupIndex, uint tileIndex, uint lightBitMaskGroups[4]) -{ -#ifdef LIGHT_GRID_PRELOADING - return lightBitMaskGroups[groupIndex]; -#else - return lightGridBitMask.Load(tileIndex * 16 + groupIndex * 4); -#endif -} - -uint WaveOr(uint mask) -{ - return WaveActiveBitOr(mask); -} - -uint64_t Ballot64(bool b) -{ - uint4 ballots = WaveActiveBallot(b); - return (uint64_t)ballots.y << 32 | (uint64_t)ballots.x; -} - -#endif // _WAVE_OP - -// Helper function for iterating over a sparse list of bits. Gets the offset of the next -// set bit, clears it, and returns the offset. -uint PullNextBit( inout uint bits ) -{ - uint bitIndex = firstbitlow(bits); - bits ^= 1 << bitIndex; - return bitIndex; -} - -void ShadeLights(inout float3 colorSum, uint2 pixelPos, - float3 diffuseAlbedo, // Diffuse albedo - float3 specularAlbedo, // Specular albedo - float specularMask, // Where is it shiny or dingy? - float gloss, - float3 normal, - float3 viewDir, - float3 worldPos - ) -{ - uint2 tilePos = GetTilePos(pixelPos, InvTileDim.xy); - uint tileIndex = GetTileIndex(tilePos, TileCount.x); - uint tileOffset = GetTileOffset(tileIndex); - - // Light Grid Preloading setup - uint lightBitMaskGroups[4] = { 0, 0, 0, 0 }; -#if defined(LIGHT_GRID_PRELOADING) - uint4 lightBitMask = lightGridBitMask.Load4(tileIndex * 16); - - lightBitMaskGroups[0] = lightBitMask.x; - lightBitMaskGroups[1] = lightBitMask.y; - lightBitMaskGroups[2] = lightBitMask.z; - lightBitMaskGroups[3] = lightBitMask.w; -#endif - -#define POINT_LIGHT_ARGS \ - diffuseAlbedo, \ - specularAlbedo, \ - specularMask, \ - gloss, \ - normal, \ - viewDir, \ - worldPos, \ - lightData.pos, \ - lightData.radiusSq, \ - lightData.color - -#define CONE_LIGHT_ARGS \ - POINT_LIGHT_ARGS, \ - lightData.coneDir, \ - lightData.coneAngles - -#define SHADOWED_LIGHT_ARGS \ - CONE_LIGHT_ARGS, \ - lightData.shadowTextureMatrix, \ - lightIndex - -#if defined(BIT_MASK) - uint64_t threadMask = Ballot64(tileIndex != ~0); // attempt to get starting exec mask - - for (uint groupIndex = 0; groupIndex < 4; groupIndex++) - { - // combine across threads - uint groupBits = WaveOr(GetGroupBits(groupIndex, tileIndex, lightBitMaskGroups)); - - while (groupBits != 0) - { - uint bitIndex = PullNextBit(groupBits); - uint lightIndex = 32 * groupIndex + bitIndex; - - LightData lightData = lightBuffer[lightIndex]; - - if (lightIndex < FirstLightIndex.x) // sphere - { - colorSum += ApplyPointLight(POINT_LIGHT_ARGS); - } - else if (lightIndex < FirstLightIndex.y) // cone - { - colorSum += ApplyConeLight(CONE_LIGHT_ARGS); - } - else // cone w/ shadow map - { - colorSum += ApplyConeShadowedLight(SHADOWED_LIGHT_ARGS); - } - } - } - -#elif defined(BIT_MASK_SORTED) - - // Get light type groups - these can be predefined as compile time constants to enable unrolling and better scheduling of vector reads - uint pointLightGroupTail = POINT_LIGHT_GROUPS_TAIL; - uint spotLightGroupTail = SPOT_LIGHT_GROUPS_TAIL; - uint spotShadowLightGroupTail = SHADOWED_SPOT_LIGHT_GROUPS_TAIL; - - uint groupBitsMasks[4] = { 0, 0, 0, 0 }; - for (int i = 0; i < 4; i++) - { - // combine across threads - groupBitsMasks[i] = WaveOr(GetGroupBits(i, tileIndex, lightBitMaskGroups)); - } - - uint groupIndex; - - for (groupIndex = 0; groupIndex < pointLightGroupTail; groupIndex++) - { - uint groupBits = groupBitsMasks[groupIndex]; - - while (groupBits != 0) - { - uint bitIndex = PullNextBit(groupBits); - uint lightIndex = 32 * groupIndex + bitIndex; - - // sphere - LightData lightData = lightBuffer[lightIndex]; - colorSum += ApplyPointLight(POINT_LIGHT_ARGS); - } - } - - for (groupIndex = pointLightGroupTail; groupIndex < spotLightGroupTail; groupIndex++) - { - uint groupBits = groupBitsMasks[groupIndex]; - - while (groupBits != 0) - { - uint bitIndex = PullNextBit(groupBits); - uint lightIndex = 32 * groupIndex + bitIndex; - - // cone - LightData lightData = lightBuffer[lightIndex]; - colorSum += ApplyConeLight(CONE_LIGHT_ARGS); - } - } - - for (groupIndex = spotLightGroupTail; groupIndex < spotShadowLightGroupTail; groupIndex++) - { - uint groupBits = groupBitsMasks[groupIndex]; - - while (groupBits != 0) - { - uint bitIndex = PullNextBit(groupBits); - uint lightIndex = 32 * groupIndex + bitIndex; - - // cone w/ shadow map - LightData lightData = lightBuffer[lightIndex]; - colorSum += ApplyConeShadowedLight(SHADOWED_LIGHT_ARGS); - } - } - -#elif defined(SCALAR_LOOP) - uint64_t threadMask = Ballot64(tileOffset != ~0); // attempt to get starting exec mask - uint64_t laneBit = 1ull << WaveGetLaneIndex(); - - while ((threadMask & laneBit) != 0) // is this thread waiting to be processed? - { // exec is now the set of remaining threads - // grab the tile offset for the first active thread - uint uniformTileOffset = WaveReadLaneFirst(tileOffset); - // mask of which threads have the same tile offset as the first active thread - uint64_t uniformMask = Ballot64(tileOffset == uniformTileOffset); - - if (any((uniformMask & laneBit) != 0)) // is this thread one of the current set of uniform threads? - { - uint tileLightCount = lightGrid.Load(uniformTileOffset + 0); - uint tileLightCountSphere = (tileLightCount >> 0) & 0xff; - uint tileLightCountCone = (tileLightCount >> 8) & 0xff; - uint tileLightCountConeShadowed = (tileLightCount >> 16) & 0xff; - - uint tileLightLoadOffset = uniformTileOffset + 4; - uint n; - - // sphere - for (n = 0; n < tileLightCountSphere; n++, tileLightLoadOffset += 4) - { - uint lightIndex = lightGrid.Load(tileLightLoadOffset); - LightData lightData = lightBuffer[lightIndex]; - colorSum += ApplyPointLight(POINT_LIGHT_ARGS); - } - - // cone - for (n = 0; n < tileLightCountCone; n++, tileLightLoadOffset += 4) - { - uint lightIndex = lightGrid.Load(tileLightLoadOffset); - LightData lightData = lightBuffer[lightIndex]; - colorSum += ApplyConeLight(CONE_LIGHT_ARGS); - } - - // cone w/ shadow map - for (n = 0; n < tileLightCountConeShadowed; n++, tileLightLoadOffset += 4) - { - uint lightIndex = lightGrid.Load(tileLightLoadOffset); - LightData lightData = lightBuffer[lightIndex]; - colorSum += ApplyConeShadowedLight(SHADOWED_LIGHT_ARGS); - } - } - - // strip the current set of uniform threads from the exec mask for the next loop iteration - threadMask &= ~uniformMask; - } - -#elif defined(SCALAR_BRANCH) - - if (Ballot64(tileOffset == WaveReadLaneFirst(tileOffset)) == ~0ull) - { - // uniform branch - tileOffset = WaveReadLaneFirst(tileOffset); - - uint tileLightCount = lightGrid.Load(tileOffset + 0); - uint tileLightCountSphere = (tileLightCount >> 0) & 0xff; - uint tileLightCountCone = (tileLightCount >> 8) & 0xff; - uint tileLightCountConeShadowed = (tileLightCount >> 16) & 0xff; - - uint tileLightLoadOffset = tileOffset + 4; - uint n; - - // sphere - for (n = 0; n < tileLightCountSphere; n++, tileLightLoadOffset += 4) - { - uint lightIndex = lightGrid.Load(tileLightLoadOffset); - LightData lightData = lightBuffer[lightIndex]; - colorSum += ApplyPointLight(POINT_LIGHT_ARGS); - } - - // cone - for (n = 0; n < tileLightCountCone; n++, tileLightLoadOffset += 4) - { - uint lightIndex = lightGrid.Load(tileLightLoadOffset); - LightData lightData = lightBuffer[lightIndex]; - colorSum += ApplyConeLight(CONE_LIGHT_ARGS); - } - - // cone w/ shadow map - for (n = 0; n < tileLightCountConeShadowed; n++, tileLightLoadOffset += 4) - { - uint lightIndex = lightGrid.Load(tileLightLoadOffset); - LightData lightData = lightBuffer[lightIndex]; - colorSum += ApplyConeShadowedLight(SHADOWED_LIGHT_ARGS); - } - } - else - { - // divergent branch - uint tileLightCount = lightGrid.Load(tileOffset + 0); - uint tileLightCountSphere = (tileLightCount >> 0) & 0xff; - uint tileLightCountCone = (tileLightCount >> 8) & 0xff; - uint tileLightCountConeShadowed = (tileLightCount >> 16) & 0xff; - - uint tileLightLoadOffset = tileOffset + 4; - uint n; - - // sphere - for (n = 0; n < tileLightCountSphere; n++, tileLightLoadOffset += 4) - { - uint lightIndex = lightGrid.Load(tileLightLoadOffset); - LightData lightData = lightBuffer[lightIndex]; - colorSum += ApplyPointLight(POINT_LIGHT_ARGS); - } - - // cone - for (n = 0; n < tileLightCountCone; n++, tileLightLoadOffset += 4) - { - uint lightIndex = lightGrid.Load(tileLightLoadOffset); - LightData lightData = lightBuffer[lightIndex]; - colorSum += ApplyConeLight(CONE_LIGHT_ARGS); - } - - // cone w/ shadow map - for (n = 0; n < tileLightCountConeShadowed; n++, tileLightLoadOffset += 4) - { - uint lightIndex = lightGrid.Load(tileLightLoadOffset); - LightData lightData = lightBuffer[lightIndex]; - colorSum += ApplyConeShadowedLight(SHADOWED_LIGHT_ARGS); - } - } - -#else // SM 5.0 (no wave intrinsics) - - uint tileLightCount = lightGrid.Load(tileOffset + 0); - uint tileLightCountSphere = (tileLightCount >> 0) & 0xff; - uint tileLightCountCone = (tileLightCount >> 8) & 0xff; - uint tileLightCountConeShadowed = (tileLightCount >> 16) & 0xff; - - uint tileLightLoadOffset = tileOffset + 4; - - // sphere - uint n; - for (n = 0; n < tileLightCountSphere; n++, tileLightLoadOffset += 4) - { - uint lightIndex = lightGrid.Load(tileLightLoadOffset); - LightData lightData = lightBuffer[lightIndex]; - colorSum += ApplyPointLight(POINT_LIGHT_ARGS); - } - - // cone - for (n = 0; n < tileLightCountCone; n++, tileLightLoadOffset += 4) - { - uint lightIndex = lightGrid.Load(tileLightLoadOffset); - LightData lightData = lightBuffer[lightIndex]; - colorSum += ApplyConeLight(CONE_LIGHT_ARGS); - } - - // cone w/ shadow map - for (n = 0; n < tileLightCountConeShadowed; n++, tileLightLoadOffset += 4) - { - uint lightIndex = lightGrid.Load(tileLightLoadOffset); - LightData lightData = lightBuffer[lightIndex]; - colorSum += ApplyConeShadowedLight(SHADOWED_LIGHT_ARGS); - } -#endif -} diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/LightingPBR.hlsli b/xess/samples/xess_demo/MiniEngine/Model/Shaders/LightingPBR.hlsli deleted file mode 100644 index 12e3257..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/LightingPBR.hlsli +++ /dev/null @@ -1,645 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// Alex Nankervis -// -// Thanks to Michal Drobot for his feedback. - -#include "Common.hlsli" -#include "LightGrid.hlsli" -#include "BRDF.hlsli" - -cbuffer GlobalConstants : register(b1) -{ - float4x4 ViewProjMatrix; - float4x4 SunShadowMatrix; - float3x3 EnvRotation; - float3 ViewerPos; - float3 SunDirection; - float3 SunIntensity; - float4 ShadowTexelSize; - float4 InvTileDim; - uint4 TileCount; - uint4 FirstLightIndex; - float IBLRange; - float IBLBias; - float ViewMipBias; // MipBias value for sampling. - float DebugFlag; -} - - -StructuredBuffer lightBuffer : register(t15); -Texture2DArray lightShadowArrayTex : register(t16); - -ByteAddressBuffer lightGrid : register(t17); -ByteAddressBuffer lightGridBitMask : register(t18); -ByteAddressBuffer lightGridTransparent : register(t19); -ByteAddressBuffer lightGridBitMaskTransparent : register(t20); - -#define SHADOW_PCF_13 - -float GetDirectionalShadow( float3 ShadowCoord, Texture2D texShadow ) -{ - float result = 0; -#ifdef SINGLE_SAMPLE - result = texShadow.SampleCmpLevelZero( shadowSampler, ShadowCoord.xy, ShadowCoord.z ); -#elif defined(SHADOW_PCF_5) - float d = ShadowTexelSize.x; - result = ( - texShadow.SampleCmpLevelZero(shadowSampler, ShadowCoord.xy, ShadowCoord.z) + - texShadow.SampleCmpLevelZero(shadowSampler, ShadowCoord.xy + float2(d, 0), ShadowCoord.z) + - texShadow.SampleCmpLevelZero(shadowSampler, ShadowCoord.xy + float2(0, d), ShadowCoord.z) + - texShadow.SampleCmpLevelZero(shadowSampler, ShadowCoord.xy + float2(-d, 0), ShadowCoord.z) + - texShadow.SampleCmpLevelZero(shadowSampler, ShadowCoord.xy + float2(0, -d), ShadowCoord.z) - ) / 5.0; - -#elif defined(SHADOW_PCF_13) - float d = ShadowTexelSize.x; - result = ( - texShadow.SampleCmpLevelZero(shadowSampler, ShadowCoord.xy, ShadowCoord.z) + - texShadow.SampleCmpLevelZero(shadowSampler, ShadowCoord.xy + float2(d, 0), ShadowCoord.z) + - texShadow.SampleCmpLevelZero(shadowSampler, ShadowCoord.xy + float2(-d, 0), ShadowCoord.z) + - texShadow.SampleCmpLevelZero(shadowSampler, ShadowCoord.xy + float2(0, d), ShadowCoord.z) + - texShadow.SampleCmpLevelZero(shadowSampler, ShadowCoord.xy + float2(0, -d), ShadowCoord.z) + - texShadow.SampleCmpLevelZero(shadowSampler, ShadowCoord.xy + float2(d, d), ShadowCoord.z) + - texShadow.SampleCmpLevelZero(shadowSampler, ShadowCoord.xy + float2(-d, d), ShadowCoord.z) + - texShadow.SampleCmpLevelZero(shadowSampler, ShadowCoord.xy + float2(d, -d), ShadowCoord.z) + - texShadow.SampleCmpLevelZero(shadowSampler, ShadowCoord.xy + float2(-d, -d), ShadowCoord.z) + - texShadow.SampleCmpLevelZero(shadowSampler, ShadowCoord.xy + float2(d * 2.0, 0), ShadowCoord.z) + - texShadow.SampleCmpLevelZero(shadowSampler, ShadowCoord.xy + float2(-d * 2.0, 0), ShadowCoord.z) + - texShadow.SampleCmpLevelZero(shadowSampler, ShadowCoord.xy + float2(0, d * 2.0), ShadowCoord.z) + - texShadow.SampleCmpLevelZero(shadowSampler, ShadowCoord.xy + float2(0, -d * 2.0), ShadowCoord.z) - ) / 13.0; -#else - const float Dilation = 2.0; - float d1 = Dilation * ShadowTexelSize.x * 0.125; - float d2 = Dilation * ShadowTexelSize.x * 0.875; - float d3 = Dilation * ShadowTexelSize.x * 0.625; - float d4 = Dilation * ShadowTexelSize.x * 0.375; - float result = ( - 2.0 * texShadow.SampleCmpLevelZero( shadowSampler, ShadowCoord.xy, ShadowCoord.z ) + - texShadow.SampleCmpLevelZero( shadowSampler, ShadowCoord.xy + float2(-d2, d1), ShadowCoord.z ) + - texShadow.SampleCmpLevelZero( shadowSampler, ShadowCoord.xy + float2(-d1, -d2), ShadowCoord.z ) + - texShadow.SampleCmpLevelZero( shadowSampler, ShadowCoord.xy + float2( d2, -d1), ShadowCoord.z ) + - texShadow.SampleCmpLevelZero( shadowSampler, ShadowCoord.xy + float2( d1, d2), ShadowCoord.z ) + - texShadow.SampleCmpLevelZero( shadowSampler, ShadowCoord.xy + float2(-d4, d3), ShadowCoord.z ) + - texShadow.SampleCmpLevelZero( shadowSampler, ShadowCoord.xy + float2(-d3, -d4), ShadowCoord.z ) + - texShadow.SampleCmpLevelZero( shadowSampler, ShadowCoord.xy + float2( d4, -d3), ShadowCoord.z ) + - texShadow.SampleCmpLevelZero( shadowSampler, ShadowCoord.xy + float2( d3, d4), ShadowCoord.z ) - ) / 10.0; -#endif - - return result * result; -} - -float GetShadowConeLight(uint lightIndex, float3 shadowCoord) -{ -#if defined(SINGLE_SAMPLE) - float result = lightShadowArrayTex.SampleCmpLevelZero(shadowSampler, float3(shadowCoord.xy, lightIndex), shadowCoord.z); -#elif defined(SHADOW_PCF_5) - float texelSize = 1.0 / 512.0; - float result = ( - lightShadowArrayTex.SampleCmpLevelZero(shadowSampler, float3(shadowCoord.xy, lightIndex), shadowCoord.z) + - lightShadowArrayTex.SampleCmpLevelZero(shadowSampler, float3(shadowCoord.xy + float2(texelSize, 0), lightIndex), shadowCoord.z) + - lightShadowArrayTex.SampleCmpLevelZero(shadowSampler, float3(shadowCoord.xy + float2(0, texelSize), lightIndex), shadowCoord.z) + - lightShadowArrayTex.SampleCmpLevelZero(shadowSampler, float3(shadowCoord.xy + float2(-texelSize, 0), lightIndex), shadowCoord.z) + - lightShadowArrayTex.SampleCmpLevelZero(shadowSampler, float3(shadowCoord.xy + float2(0, -texelSize), lightIndex), shadowCoord.z) - ) / 5.0; -#elif defined(SHADOW_PCF_13) - float texelSize = 1.0 / 512.0; - float result = ( - lightShadowArrayTex.SampleCmpLevelZero(shadowSampler, float3(shadowCoord.xy, lightIndex), shadowCoord.z) + - lightShadowArrayTex.SampleCmpLevelZero(shadowSampler, float3(shadowCoord.xy + float2(texelSize, 0), lightIndex), shadowCoord.z) + - lightShadowArrayTex.SampleCmpLevelZero(shadowSampler, float3(shadowCoord.xy + float2(-texelSize, 0), lightIndex), shadowCoord.z) + - lightShadowArrayTex.SampleCmpLevelZero(shadowSampler, float3(shadowCoord.xy + float2(0, texelSize), lightIndex), shadowCoord.z) + - lightShadowArrayTex.SampleCmpLevelZero(shadowSampler, float3(shadowCoord.xy + float2(0, -texelSize), lightIndex), shadowCoord.z) + - lightShadowArrayTex.SampleCmpLevelZero(shadowSampler, float3(shadowCoord.xy + float2(texelSize, texelSize), lightIndex), shadowCoord.z) + - lightShadowArrayTex.SampleCmpLevelZero(shadowSampler, float3(shadowCoord.xy + float2(-texelSize, texelSize), lightIndex), shadowCoord.z) + - lightShadowArrayTex.SampleCmpLevelZero(shadowSampler, float3(shadowCoord.xy + float2(texelSize, -texelSize), lightIndex), shadowCoord.z) + - lightShadowArrayTex.SampleCmpLevelZero(shadowSampler, float3(shadowCoord.xy + float2(-texelSize, -texelSize), lightIndex), shadowCoord.z) + - lightShadowArrayTex.SampleCmpLevelZero(shadowSampler, float3(shadowCoord.xy + float2(texelSize * 2.0, 0), lightIndex), shadowCoord.z) + - lightShadowArrayTex.SampleCmpLevelZero(shadowSampler, float3(shadowCoord.xy + float2(-texelSize * 2.0, 0), lightIndex), shadowCoord.z) + - lightShadowArrayTex.SampleCmpLevelZero(shadowSampler, float3(shadowCoord.xy + float2(0, texelSize * 2.0), lightIndex), shadowCoord.z) + - lightShadowArrayTex.SampleCmpLevelZero(shadowSampler, float3(shadowCoord.xy + float2(0, -texelSize * 2.0), lightIndex), shadowCoord.z) - ) / 13.0; -#else - float texelSize = 1.0 / 512.0; - const float Dilation = 2.0; - float d1 = Dilation * texelSize * 0.125; - float d2 = Dilation * texelSize * 0.875; - float d3 = Dilation * texelSize * 0.625; - float d4 = Dilation * texelSize * 0.375; - - float result = ( - 2.0 * lightShadowArrayTex.SampleCmpLevelZero(shadowSampler, float3(shadowCoord.xy, lightIndex), shadowCoord.z) + - lightShadowArrayTex.SampleCmpLevelZero(shadowSampler, float3(shadowCoord.xy + float2(-d2, d1), lightIndex), shadowCoord.z) + - lightShadowArrayTex.SampleCmpLevelZero(shadowSampler, float3(shadowCoord.xy + float2(-d1, -d2), lightIndex), shadowCoord.z) + - lightShadowArrayTex.SampleCmpLevelZero(shadowSampler, float3(shadowCoord.xy + float2( d2, -d1), lightIndex), shadowCoord.z) + - lightShadowArrayTex.SampleCmpLevelZero(shadowSampler, float3(shadowCoord.xy + float2( d1, d2), lightIndex), shadowCoord.z) + - lightShadowArrayTex.SampleCmpLevelZero(shadowSampler, float3(shadowCoord.xy + float2(-d4, d3), lightIndex), shadowCoord.z) + - lightShadowArrayTex.SampleCmpLevelZero(shadowSampler, float3(shadowCoord.xy + float2(-d3, -d4), lightIndex), shadowCoord.z) + - lightShadowArrayTex.SampleCmpLevelZero(shadowSampler, float3(shadowCoord.xy + float2( d4, -d3), lightIndex), shadowCoord.z) + - lightShadowArrayTex.SampleCmpLevelZero(shadowSampler, float3(shadowCoord.xy + float2( d3, d4), lightIndex), shadowCoord.z) - ) / 10.0; -#endif - - return result * result; -} - -float3 ApplyLightCommon(SurfaceProperties surface, float3 lightDir, float3 lightColor) -{ - LightProperties Light; - Light.L = lightDir; - - // Half vector - float3 H = normalize(lightDir + surface.V); - - // Pre-compute dot products - Light.NdotL = clamp(dot(surface.N, lightDir), 1e-6, 1.0); - Light.LdotH = clamp(dot(lightDir, H), 1e-6, 1.0); - Light.NdotH = clamp(dot(surface.N, H), 1e-6, 1.0); - - // Diffuse & specular factors - float3 diffuse = Diffuse_Lambertian(surface); - float3 specular = Specular_BRDF(surface, Light); - - return Light.NdotL * lightColor * (diffuse + specular); -} - -float3 ApplyDirectionalLight(SurfaceProperties surface, - float3 lightDir, - float3 lightColor, - float3 shadowCoord, // Shadow coordinate (Shadow map UV & light-relative Z) - Texture2D ShadowMap - ) -{ - float shadow = GetDirectionalShadow(shadowCoord, ShadowMap); - - return shadow * ApplyLightCommon( - surface, - lightDir, - lightColor - ); -} - -float3 ApplyPointLight(SurfaceProperties surface, - float3 worldPos, // World-space fragment position - float3 lightPos, // World-space light position - float lightRadiusSq, - float3 lightColor // Radiance of directional light - ) -{ - float3 lightDir = lightPos - worldPos; - float lightDistSq = dot(lightDir, lightDir); - float invLightDist = rsqrt(lightDistSq); - lightDir *= invLightDist; - - // modify 1/d^2 * R^2 to fall off at a fixed radius - // (R/d)^2 - d/R = [(1/d^2) - (1/R^2)*(d/R)] * R^2 - float distanceFalloff = lightRadiusSq * (invLightDist * invLightDist); - distanceFalloff = max(0, distanceFalloff - rsqrt(distanceFalloff)); - - return distanceFalloff * ApplyLightCommon( - surface, - lightDir, - lightColor - ); -} - -float3 ApplyConeLight(SurfaceProperties surface, - float3 worldPos, // World-space fragment position - float3 lightPos, // World-space light position - float lightRadiusSq, - float3 lightColor, // Radiance of directional light - float3 coneDir, - float2 coneAngles - ) -{ - float3 lightDir = lightPos - worldPos; - float lightDistSq = dot(lightDir, lightDir); - float invLightDist = rsqrt(lightDistSq); - lightDir *= invLightDist; - - // modify 1/d^2 * R^2 to fall off at a fixed radius - // (R/d)^2 - d/R = [(1/d^2) - (1/R^2)*(d/R)] * R^2 - float distanceFalloff = lightRadiusSq * (invLightDist * invLightDist); - distanceFalloff = max(0, distanceFalloff - rsqrt(distanceFalloff)); - - float coneFalloff = dot(-lightDir, coneDir); - coneFalloff = saturate((coneFalloff - coneAngles.y) * coneAngles.x); - - return (coneFalloff * distanceFalloff) * ApplyLightCommon( - surface, - lightDir, - lightColor - ); -} - -float3 ApplyConeShadowedLight(SurfaceProperties surface, - float3 worldPos, // World-space fragment position - float3 lightPos, // World-space light position - float lightRadiusSq, - float3 lightColor, // Radiance of directional light - float3 coneDir, - float2 coneAngles, - float4x4 shadowTextureMatrix, - uint lightIndex - ) -{ - float4 shadowCoord = mul(shadowTextureMatrix, float4(worldPos, 1.0)); - shadowCoord.xyz *= rcp(shadowCoord.w); - float shadow = GetShadowConeLight(lightIndex, shadowCoord.xyz); - - return shadow * ApplyConeLight(surface, - worldPos, - lightPos, - lightRadiusSq, - lightColor, - coneDir, - coneAngles - ); -} - -// options for F+ variants and optimizations -#if 0 // SM6.0 -#define _WAVE_OP -#endif - -// options for F+ variants and optimizations -#ifdef _WAVE_OP // SM 6.0 (new shader compiler) - -// choose one of these: -//# define BIT_MASK -# define BIT_MASK_SORTED -//# define SCALAR_LOOP -//# define SCALAR_BRANCH - -// enable to amortize latency of vector read in exchange for additional VGPRs being held -# define LIGHT_GRID_PRELOADING - -// configured for 32 sphere lights, 64 cone lights, and 32 cone shadowed lights -# define POINT_LIGHT_GROUPS 1 -# define SPOT_LIGHT_GROUPS 2 -# define SHADOWED_SPOT_LIGHT_GROUPS 1 -# define POINT_LIGHT_GROUPS_TAIL POINT_LIGHT_GROUPS -# define SPOT_LIGHT_GROUPS_TAIL POINT_LIGHT_GROUPS_TAIL + SPOT_LIGHT_GROUPS -# define SHADOWED_SPOT_LIGHT_GROUPS_TAIL SPOT_LIGHT_GROUPS_TAIL + SHADOWED_SPOT_LIGHT_GROUPS - -uint GetGroupBits(uint groupIndex, uint tileIndex, uint lightBitMaskGroups[4]) -{ -#ifdef LIGHT_GRID_PRELOADING - return lightBitMaskGroups[groupIndex]; -#else - return lightGridBitMask.Load(tileIndex * 16 + groupIndex * 4); -#endif -} - -uint WaveOr(uint mask) -{ - return WaveActiveBitOr(mask); -} - -uint64_t Ballot64(bool b) -{ - uint4 ballots = WaveActiveBallot(b); - return (uint64_t)ballots.y << 32 | (uint64_t)ballots.x; -} - -#endif // _WAVE_OP - -// Helper function for iterating over a sparse list of bits. Gets the offset of the next -// set bit, clears it, and returns the offset. -uint PullNextBit( inout uint bits ) -{ - uint bitIndex = firstbitlow(bits); - bits ^= 1 << bitIndex; - return bitIndex; -} - -float3 ApplyAmbientLight( - float3 diffuse, // Diffuse albedo - float ao, // Pre-computed ambient-occlusion - float3 lightColor // Radiance of ambient light - ) -{ - return ao * diffuse * lightColor; -} - -void ShadeLightsTiled(inout float3 colorSum, - uint2 pixelPos, - SurfaceProperties surface, - float3 worldPos, - ByteAddressBuffer lightGrid, - ByteAddressBuffer lightGridBitMask - ) -{ - uint2 tilePos = GetTilePos(pixelPos, InvTileDim.xy); - uint tileIndex = GetTileIndex(tilePos, TileCount.x); - uint tileOffset = GetTileOffset(tileIndex); - - // Light Grid Preloading setup - uint lightBitMaskGroups[4] = { 0, 0, 0, 0 }; -#if defined(LIGHT_GRID_PRELOADING) - uint4 lightBitMask = lightGridBitMask.Load4(tileIndex * 16); - - lightBitMaskGroups[0] = lightBitMask.x; - lightBitMaskGroups[1] = lightBitMask.y; - lightBitMaskGroups[2] = lightBitMask.z; - lightBitMaskGroups[3] = lightBitMask.w; -#endif - -#define POINT_LIGHT_ARGS \ - surface, \ - worldPos, \ - lightData.pos, \ - lightData.radiusSq, \ - lightData.color - -#define CONE_LIGHT_ARGS \ - POINT_LIGHT_ARGS, \ - lightData.coneDir, \ - lightData.coneAngles - -#define SHADOWED_LIGHT_ARGS \ - CONE_LIGHT_ARGS, \ - lightData.shadowTextureMatrix, \ - lightIndex - -#if defined(BIT_MASK) - uint64_t threadMask = Ballot64(tileIndex != ~0); // attempt to get starting exec mask - - for (uint groupIndex = 0; groupIndex < 4; groupIndex++) - { - // combine across threads - uint groupBits = WaveOr(GetGroupBits(groupIndex, tileIndex, lightBitMaskGroups)); - - while (groupBits != 0) - { - uint bitIndex = PullNextBit(groupBits); - uint lightIndex = 32 * groupIndex + bitIndex; - - LightData lightData = lightBuffer[lightIndex]; - - if (lightIndex < FirstLightIndex.x) // sphere - { - colorSum += ApplyPointLight(POINT_LIGHT_ARGS); - } - else if (lightIndex < FirstLightIndex.y) // cone - { - colorSum += ApplyConeLight(CONE_LIGHT_ARGS); - } - else // cone w/ shadow map - { - colorSum += ApplyConeShadowedLight(SHADOWED_LIGHT_ARGS); - } - } - } - -#elif defined(BIT_MASK_SORTED) - - // Get light type groups - these can be predefined as compile time constants to enable unrolling and better scheduling of vector reads - uint pointLightGroupTail = POINT_LIGHT_GROUPS_TAIL; - uint spotLightGroupTail = SPOT_LIGHT_GROUPS_TAIL; - uint spotShadowLightGroupTail = SHADOWED_SPOT_LIGHT_GROUPS_TAIL; - - uint groupBitsMasks[4] = { 0, 0, 0, 0 }; - for (int i = 0; i < 4; i++) - { - // combine across threads - groupBitsMasks[i] = WaveOr(GetGroupBits(i, tileIndex, lightBitMaskGroups)); - } - - uint groupIndex; - - for (groupIndex = 0; groupIndex < pointLightGroupTail; groupIndex++) - { - uint groupBits = groupBitsMasks[groupIndex]; - - while (groupBits != 0) - { - uint bitIndex = PullNextBit(groupBits); - uint lightIndex = 32 * groupIndex + bitIndex; - - // sphere - LightData lightData = lightBuffer[lightIndex]; - colorSum += ApplyPointLight(POINT_LIGHT_ARGS); - } - } - - for (groupIndex = pointLightGroupTail; groupIndex < spotLightGroupTail; groupIndex++) - { - uint groupBits = groupBitsMasks[groupIndex]; - - while (groupBits != 0) - { - uint bitIndex = PullNextBit(groupBits); - uint lightIndex = 32 * groupIndex + bitIndex; - - // cone - LightData lightData = lightBuffer[lightIndex]; - colorSum += ApplyConeLight(CONE_LIGHT_ARGS); - } - } - - for (groupIndex = spotLightGroupTail; groupIndex < spotShadowLightGroupTail; groupIndex++) - { - uint groupBits = groupBitsMasks[groupIndex]; - - while (groupBits != 0) - { - uint bitIndex = PullNextBit(groupBits); - uint lightIndex = 32 * groupIndex + bitIndex; - - // cone w/ shadow map - LightData lightData = lightBuffer[lightIndex]; - colorSum += ApplyConeShadowedLight(SHADOWED_LIGHT_ARGS); - } - } - -#elif defined(SCALAR_LOOP) - uint64_t threadMask = Ballot64(tileOffset != ~0); // attempt to get starting exec mask - uint64_t laneBit = 1ull << WaveGetLaneIndex(); - - while ((threadMask & laneBit) != 0) // is this thread waiting to be processed? - { // exec is now the set of remaining threads - // grab the tile offset for the first active thread - uint uniformTileOffset = WaveReadLaneFirst(tileOffset); - // mask of which threads have the same tile offset as the first active thread - uint64_t uniformMask = Ballot64(tileOffset == uniformTileOffset); - - if (any((uniformMask & laneBit) != 0)) // is this thread one of the current set of uniform threads? - { - uint tileLightCount = lightGrid.Load(uniformTileOffset + 0); - uint tileLightCountSphere = (tileLightCount >> 0) & 0xff; - uint tileLightCountCone = (tileLightCount >> 8) & 0xff; - uint tileLightCountConeShadowed = (tileLightCount >> 16) & 0xff; - - uint tileLightLoadOffset = uniformTileOffset + 4; - uint n; - - // sphere - for (n = 0; n < tileLightCountSphere; n++, tileLightLoadOffset += 4) - { - uint lightIndex = lightGrid.Load(tileLightLoadOffset); - LightData lightData = lightBuffer[lightIndex]; - colorSum += ApplyPointLight(POINT_LIGHT_ARGS); - } - - // cone - for (n = 0; n < tileLightCountCone; n++, tileLightLoadOffset += 4) - { - uint lightIndex = lightGrid.Load(tileLightLoadOffset); - LightData lightData = lightBuffer[lightIndex]; - colorSum += ApplyConeLight(CONE_LIGHT_ARGS); - } - - // cone w/ shadow map - for (n = 0; n < tileLightCountConeShadowed; n++, tileLightLoadOffset += 4) - { - uint lightIndex = lightGrid.Load(tileLightLoadOffset); - LightData lightData = lightBuffer[lightIndex]; - colorSum += ApplyConeShadowedLight(SHADOWED_LIGHT_ARGS); - } - } - - // strip the current set of uniform threads from the exec mask for the next loop iteration - threadMask &= ~uniformMask; - } - -#elif defined(SCALAR_BRANCH) - - if (Ballot64(tileOffset == WaveReadLaneFirst(tileOffset)) == ~0ull) - { - // uniform branch - tileOffset = WaveReadLaneFirst(tileOffset); - - uint tileLightCount = lightGrid.Load(tileOffset + 0); - uint tileLightCountSphere = (tileLightCount >> 0) & 0xff; - uint tileLightCountCone = (tileLightCount >> 8) & 0xff; - uint tileLightCountConeShadowed = (tileLightCount >> 16) & 0xff; - - uint tileLightLoadOffset = tileOffset + 4; - uint n; - - // sphere - for (n = 0; n < tileLightCountSphere; n++, tileLightLoadOffset += 4) - { - uint lightIndex = lightGrid.Load(tileLightLoadOffset); - LightData lightData = lightBuffer[lightIndex]; - colorSum += ApplyPointLight(POINT_LIGHT_ARGS); - } - - // cone - for (n = 0; n < tileLightCountCone; n++, tileLightLoadOffset += 4) - { - uint lightIndex = lightGrid.Load(tileLightLoadOffset); - LightData lightData = lightBuffer[lightIndex]; - colorSum += ApplyConeLight(CONE_LIGHT_ARGS); - } - - // cone w/ shadow map - for (n = 0; n < tileLightCountConeShadowed; n++, tileLightLoadOffset += 4) - { - uint lightIndex = lightGrid.Load(tileLightLoadOffset); - LightData lightData = lightBuffer[lightIndex]; - colorSum += ApplyConeShadowedLight(SHADOWED_LIGHT_ARGS); - } - } - else - { - // divergent branch - uint tileLightCount = lightGrid.Load(tileOffset + 0); - uint tileLightCountSphere = (tileLightCount >> 0) & 0xff; - uint tileLightCountCone = (tileLightCount >> 8) & 0xff; - uint tileLightCountConeShadowed = (tileLightCount >> 16) & 0xff; - - uint tileLightLoadOffset = tileOffset + 4; - uint n; - - // sphere - for (n = 0; n < tileLightCountSphere; n++, tileLightLoadOffset += 4) - { - uint lightIndex = lightGrid.Load(tileLightLoadOffset); - LightData lightData = lightBuffer[lightIndex]; - colorSum += ApplyPointLight(POINT_LIGHT_ARGS); - } - - // cone - for (n = 0; n < tileLightCountCone; n++, tileLightLoadOffset += 4) - { - uint lightIndex = lightGrid.Load(tileLightLoadOffset); - LightData lightData = lightBuffer[lightIndex]; - colorSum += ApplyConeLight(CONE_LIGHT_ARGS); - } - - // cone w/ shadow map - for (n = 0; n < tileLightCountConeShadowed; n++, tileLightLoadOffset += 4) - { - uint lightIndex = lightGrid.Load(tileLightLoadOffset); - LightData lightData = lightBuffer[lightIndex]; - colorSum += ApplyConeShadowedLight(SHADOWED_LIGHT_ARGS); - } - } - -#else // SM 5.0 (no wave intrinsics) - - uint tileLightCount = lightGrid.Load(tileOffset + 0); - uint tileLightCountSphere = (tileLightCount >> 0) & 0xff; - uint tileLightCountCone = (tileLightCount >> 8) & 0xff; - uint tileLightCountConeShadowed = (tileLightCount >> 16) & 0xff; - - uint tileLightLoadOffset = tileOffset + 4; - - // sphere - uint n; - for (n = 0; n < tileLightCountSphere; n++, tileLightLoadOffset += 4) - { - uint lightIndex = lightGrid.Load(tileLightLoadOffset); - LightData lightData = lightBuffer[lightIndex]; - colorSum += ApplyPointLight(POINT_LIGHT_ARGS); - } - - // cone - for (n = 0; n < tileLightCountCone; n++, tileLightLoadOffset += 4) - { - uint lightIndex = lightGrid.Load(tileLightLoadOffset); - LightData lightData = lightBuffer[lightIndex]; - colorSum += ApplyConeLight(CONE_LIGHT_ARGS); - } - - // cone w/ shadow map - for (n = 0; n < tileLightCountConeShadowed; n++, tileLightLoadOffset += 4) - { - uint lightIndex = lightGrid.Load(tileLightLoadOffset); - LightData lightData = lightBuffer[lightIndex]; - colorSum += ApplyConeShadowedLight(SHADOWED_LIGHT_ARGS); - } -#endif -} - -static const uint ALPHA_BLEND = 7; - -void ShadeLights(inout float3 colorSum, - uint2 pixelPos, - SurfaceProperties surface, - float3 worldPos, - uint flags) -{ - bool transparent = (flags >> ALPHA_BLEND) & 1; - if (transparent) - { - ShadeLightsTiled(colorSum, pixelPos, surface, worldPos, lightGridTransparent, lightGridBitMaskTransparent); - } - else - { - ShadeLightsTiled(colorSum, pixelPos, surface, worldPos, lightGrid, lightGridBitMask); - } -} \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/ModelViewerPS.hlsl b/xess/samples/xess_demo/MiniEngine/Model/Shaders/ModelViewerPS.hlsl deleted file mode 100644 index e335635..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/ModelViewerPS.hlsl +++ /dev/null @@ -1,89 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard - -#include "Common.hlsli" -#include "Lighting.hlsli" - -Texture2D texDiffuse : register(t0); -Texture2D texSpecular : register(t1); -//Texture2D texEmissive : register(t2); -Texture2D texNormal : register(t3); -//Texture2D texLightmap : register(t4); -//Texture2D texReflection : register(t5); -Texture2D texSSAO : register(t12); -Texture2D texShadow : register(t13); - -SamplerState baseColorSampler : register(s0); - -struct VSOutput -{ - sample float4 position : SV_Position; - sample float3 worldPos : WorldPos; - sample float2 uv : TexCoord0; - sample float3 viewDir : TexCoord1; - sample float3 shadowCoord : TexCoord2; - sample float3 normal : Normal; - sample float3 tangent : Tangent; - sample float3 bitangent : Bitangent; -}; - -struct MRT -{ - float3 Color : SV_Target0; - float3 Normal : SV_Target1; -}; - -[RootSignature(Renderer_RootSig)] -MRT main(VSOutput vsOutput) -{ - MRT mrt; - - uint2 pixelPos = uint2(vsOutput.position.xy); - - // We use a dynamic sampler instead. -# define SAMPLE_TEX(texName) texName.Sample(/*defaultSampler*/baseColorSampler, vsOutput.uv) - - float3 diffuseAlbedo = SAMPLE_TEX(texDiffuse); - float3 colorSum = 0; - { - float ao = texSSAO[pixelPos]; - colorSum += ApplyAmbientLight( diffuseAlbedo, ao, AmbientColor ); - } - - float gloss = 128.0; - float3 normal; - { - normal = SAMPLE_TEX(texNormal) * 2.0 - 1.0; - AntiAliasSpecular(normal, gloss); - float3x3 tbn = float3x3(normalize(vsOutput.tangent), normalize(vsOutput.bitangent), normalize(vsOutput.normal)); - normal = normalize(mul(normal, tbn)); - } - - float3 specularAlbedo = float3( 0.56, 0.56, 0.56 ); - float specularMask = SAMPLE_TEX(texSpecular).g; - float3 viewDir = normalize(vsOutput.viewDir); - colorSum += ApplyDirectionalLight( diffuseAlbedo, specularAlbedo, specularMask, gloss, normal, viewDir, SunDirection, SunColor, vsOutput.shadowCoord, texShadow ); - - ShadeLights(colorSum, pixelPos, - diffuseAlbedo, - specularAlbedo, - specularMask, - gloss, - normal, - viewDir, - vsOutput.worldPos - ); - - mrt.Normal = normal; - mrt.Color = colorSum; - return mrt; -} diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/ModelViewerVS.hlsl b/xess/samples/xess_demo/MiniEngine/Model/Shaders/ModelViewerVS.hlsl deleted file mode 100644 index 3370130..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/ModelViewerVS.hlsl +++ /dev/null @@ -1,73 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// Alex Nankervis -// - -#include "Common.hlsli" - -cbuffer VSConstants : register(b0) -{ - float4x4 modelToProjection; - float4x4 modelToShadow; - float3 ViewerPos; -}; - -cbuffer StartVertex : register(b1) -{ - uint materialIdx; -}; - -struct VSInput -{ - float3 position : POSITION; - float2 texcoord0 : TEXCOORD; - float3 normal : NORMAL; - float3 tangent : TANGENT; - float3 bitangent : BITANGENT; -}; - -struct VSOutput -{ - float4 position : SV_Position; - float3 worldPos : WorldPos; - float2 texCoord : TexCoord0; - float3 viewDir : TexCoord1; - float3 shadowCoord : TexCoord2; - float3 normal : Normal; - float3 tangent : Tangent; - float3 bitangent : Bitangent; -#if ENABLE_TRIANGLE_ID - uint vertexID : TexCoord3; -#endif -}; - -[RootSignature(Renderer_RootSig)] -VSOutput main(VSInput vsInput, uint vertexID : SV_VertexID) -{ - VSOutput vsOutput; - - vsOutput.position = mul(modelToProjection, float4(vsInput.position, 1.0)); - vsOutput.worldPos = vsInput.position; - vsOutput.texCoord = vsInput.texcoord0; - vsOutput.viewDir = vsInput.position - ViewerPos; - vsOutput.shadowCoord = mul(modelToShadow, float4(vsInput.position, 1.0)).xyz; - - vsOutput.normal = vsInput.normal; - vsOutput.tangent = vsInput.tangent; - vsOutput.bitangent = vsInput.bitangent; - -#if ENABLE_TRIANGLE_ID - vsOutput.vertexID = materialIdx << 24 | (vertexID & 0xFFFF); -#endif - - return vsOutput; -} diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/SkyboxPS.hlsl b/xess/samples/xess_demo/MiniEngine/Model/Shaders/SkyboxPS.hlsl deleted file mode 100644 index 9a82855..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/SkyboxPS.hlsl +++ /dev/null @@ -1,38 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard - -#include "Common.hlsli" -#include "Core/Shaders/ShaderUtility.hlsli" - -cbuffer PSConstants : register(b0) -{ - float TextureLevel; -}; - -TextureCube radianceIBLTexture : register(t10); - -struct VSOutput -{ - float4 position : SV_POSITION; - float3 viewDir : TEXCOORD3; -}; - -float3 sRGBToLinear(float3 srgbColor) -{ - return RemoveDisplayProfile(srgbColor, DISPLAY_PLANE_FORMAT); -} - -[RootSignature(Renderer_RootSig)] -float4 main(VSOutput vsOutput) : SV_Target0 -{ - return float4(sRGBToLinear(radianceIBLTexture.SampleLevel(defaultSampler, vsOutput.viewDir, TextureLevel)), 1); -} diff --git a/xess/samples/xess_demo/MiniEngine/Model/Shaders/SkyboxVS.hlsl b/xess/samples/xess_demo/MiniEngine/Model/Shaders/SkyboxVS.hlsl deleted file mode 100644 index 473be0c..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/Shaders/SkyboxVS.hlsl +++ /dev/null @@ -1,41 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// - -#include "Common.hlsli" - -cbuffer VSConstants : register(b0) -{ - float4x4 ProjInverse; - float3x3 ViewInverse; - float3x3 Rotation; -}; - -struct VSOutput -{ - float4 position : SV_POSITION; - float3 viewDir : TEXCOORD3; -}; - -[RootSignature(Renderer_RootSig)] -VSOutput main(uint VertID : SV_VertexID) -{ - float2 ScreenUV = float2(uint2(VertID, VertID << 1) & 2); - float4 ProjectedPos = float4(lerp(float2(-1, 1), float2(1, -1), ScreenUV), 0, 1); - float4 PosViewSpace = mul(ProjInverse, ProjectedPos); - - VSOutput vsOutput; - vsOutput.position = ProjectedPos; - vsOutput.viewDir = mul(Rotation, mul(ViewInverse, PosViewSpace.xyz / PosViewSpace.w)); - - return vsOutput; -} diff --git a/xess/samples/xess_demo/MiniEngine/Model/SponzaRenderer.cpp b/xess/samples/xess_demo/MiniEngine/Model/SponzaRenderer.cpp deleted file mode 100644 index 7c048f5..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/SponzaRenderer.cpp +++ /dev/null @@ -1,432 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): Alex Nankervis -// James Stanard -// - -// From Core -#include "GraphicsCore.h" -#include "BufferManager.h" -#include "Camera.h" -#include "CommandContext.h" -#include "TemporalEffects.h" -#include "SSAO.h" -#include "SystemTime.h" -#include "ShadowCamera.h" -#include "ParticleEffects.h" -#include "SponzaRenderer.h" -#include "Renderer.h" - -// From Model -#include "ModelH3D.h" - -// From ModelViewer -#include "LightManager.h" - -#include "CompiledShaders/DepthViewerVS.h" -#include "CompiledShaders/DepthViewerPS.h" -#include "CompiledShaders/ModelViewerVS.h" -#include "CompiledShaders/ModelViewerPS.h" - -using namespace Math; -using namespace Graphics; - -namespace Sponza -{ - void RenderLightShadows(GraphicsContext& gfxContext, const Camera& camera); - - enum eObjectFilter { kOpaque = 0x1, kCutout = 0x2, kTransparent = 0x4, kAll = 0xF, kNone = 0x0 }; - void RenderObjects( GraphicsContext& Context, const Matrix4& ViewProjMat, const Vector3& viewerPos, eObjectFilter Filter = kAll ); - - GraphicsPSO m_DepthPSO = { (L"Sponza: Depth PSO") }; - GraphicsPSO m_CutoutDepthPSO = { (L"Sponza: Cutout Depth PSO") }; - GraphicsPSO m_ModelPSO = { (L"Sponza: Color PSO") }; - GraphicsPSO m_CutoutModelPSO = { (L"Sponza: Cutout Color PSO") }; - GraphicsPSO m_ShadowPSO(L"Sponza: Shadow PSO"); - GraphicsPSO m_CutoutShadowPSO(L"Sponza: Cutout Shadow PSO"); - - - D3D12_CPU_DESCRIPTOR_HANDLE m_SamplerHandler; - - ModelH3D m_Model; - std::vector m_pMaterialIsCutout; - - Vector3 m_SunDirection; - ShadowCamera m_SunShadow; - - float m_MipBias = 0.0f; - - ExpVar m_AmbientIntensity("Sponza/Lighting/Ambient Intensity", 0.1f, -16.0f, 16.0f, 0.1f); - ExpVar m_SunLightIntensity("Sponza/Lighting/Sun Light Intensity", 4.0f, 0.0f, 16.0f, 0.1f); - NumVar m_SunOrientation("Sponza/Lighting/Sun Orientation", -0.5f, -100.0f, 100.0f, 0.1f ); - NumVar m_SunInclination("Sponza/Lighting/Sun Inclination", 0.75f, 0.0f, 1.0f, 0.01f ); - NumVar ShadowDimX("Sponza/Lighting/Shadow Dim X", 5000, 1000, 10000, 100 ); - NumVar ShadowDimY("Sponza/Lighting/Shadow Dim Y", 3000, 1000, 10000, 100 ); - NumVar ShadowDimZ("Sponza/Lighting/Shadow Dim Z", 3000, 1000, 10000, 100 ); - - void CreateDiffuseSampler(float LodBias); -} - -void Sponza::Startup( Camera& Camera ) -{ - DXGI_FORMAT ColorFormat = g_SceneColorBuffer.GetFormat(); - DXGI_FORMAT NormalFormat = g_SceneNormalBuffer.GetFormat(); - DXGI_FORMAT DepthFormat = g_SceneDepthBuffer.GetFormat(); - //DXGI_FORMAT ShadowFormat = g_ShadowBuffer.GetFormat(); - - D3D12_INPUT_ELEMENT_DESC vertElem[] = - { - { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, - { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, - { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, - { "TANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, - { "BITANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D12_APPEND_ALIGNED_ELEMENT, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 } - }; - - // Depth-only (2x rate) - m_DepthPSO.SetRootSignature(Renderer::m_RootSig); - m_DepthPSO.SetRasterizerState(RasterizerDefault); - m_DepthPSO.SetBlendState(BlendNoColorWrite); - m_DepthPSO.SetDepthStencilState(DepthStateReadWrite); - m_DepthPSO.SetInputLayout(_countof(vertElem), vertElem); - m_DepthPSO.SetPrimitiveTopologyType(D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE); - m_DepthPSO.SetRenderTargetFormats(0, nullptr, DepthFormat); - m_DepthPSO.SetVertexShader(g_pDepthViewerVS, sizeof(g_pDepthViewerVS)); - m_DepthPSO.Finalize(); - - // Depth-only shading but with alpha testing - m_CutoutDepthPSO = m_DepthPSO; - m_CutoutDepthPSO.SetPixelShader(g_pDepthViewerPS, sizeof(g_pDepthViewerPS)); - m_CutoutDepthPSO.SetRasterizerState(RasterizerTwoSided); - m_CutoutDepthPSO.Finalize(); - - // Depth-only but with a depth bias and/or render only backfaces - m_ShadowPSO = m_DepthPSO; - m_ShadowPSO.SetRasterizerState(RasterizerShadow); - m_ShadowPSO.SetRenderTargetFormats(0, nullptr, g_ShadowBuffer.GetFormat()); - m_ShadowPSO.Finalize(); - - // Shadows with alpha testing - m_CutoutShadowPSO = m_ShadowPSO; - m_CutoutShadowPSO.SetPixelShader(g_pDepthViewerPS, sizeof(g_pDepthViewerPS)); - m_CutoutShadowPSO.SetRasterizerState(RasterizerShadowTwoSided); - m_CutoutShadowPSO.Finalize(); - - DXGI_FORMAT formats[2] = { ColorFormat, NormalFormat }; - - // Full color pass - m_ModelPSO = m_DepthPSO; - m_ModelPSO.SetBlendState(BlendDisable); - m_ModelPSO.SetDepthStencilState(DepthStateTestEqual); - m_ModelPSO.SetRenderTargetFormats(2, formats, DepthFormat); - m_ModelPSO.SetVertexShader( g_pModelViewerVS, sizeof(g_pModelViewerVS) ); - m_ModelPSO.SetPixelShader( g_pModelViewerPS, sizeof(g_pModelViewerPS) ); - m_ModelPSO.Finalize(); - - m_CutoutModelPSO = m_ModelPSO; - m_CutoutModelPSO.SetRasterizerState(RasterizerTwoSided); - m_CutoutModelPSO.Finalize(); - - ASSERT(m_Model.Load(L"Sponza/sponza.h3d"), "Failed to load model"); - ASSERT(m_Model.GetMeshCount() > 0, "Model contains no meshes"); - - // The caller of this function can override which materials are considered cutouts - m_pMaterialIsCutout.resize(m_Model.GetMaterialCount()); - for (uint32_t i = 0; i < m_Model.GetMaterialCount(); ++i) - { - const ModelH3D::Material& mat = m_Model.GetMaterial(i); - if (std::string(mat.texDiffusePath).find("thorn") != std::string::npos || - std::string(mat.texDiffusePath).find("plant") != std::string::npos || - std::string(mat.texDiffusePath).find("chain") != std::string::npos) - { - m_pMaterialIsCutout[i] = true; - } - else - { - m_pMaterialIsCutout[i] = false; - } - } - - ParticleEffects::InitFromJSON(L"Sponza/particles.json", L""); - - float modelRadius = Length(m_Model.GetBoundingBox().GetDimensions()) * 0.5f; - const Vector3 eye = m_Model.GetBoundingBox().GetCenter() + Vector3(modelRadius * 0.5f, 0.0f, 0.0f); - Camera.SetEyeAtUp( eye, Vector3(kZero), Vector3(kYUnitVector) ); - - Lighting::CreateRandomLights(m_Model.GetBoundingBox().GetMin(), m_Model.GetBoundingBox().GetMax()); - - CreateDiffuseSampler(0.0f); -} - -const ModelH3D& Sponza::GetModel() -{ - return Sponza::m_Model; -} - -void Sponza::Cleanup( void ) -{ - m_Model.Clear(); - ParticleEffects::ClearTexturePool(); - Lighting::Shutdown(); - TextureManager::Shutdown(); -} - -void Sponza::RenderObjects( GraphicsContext& gfxContext, const Matrix4& ViewProjMat, const Vector3& viewerPos, eObjectFilter Filter ) -{ - struct VSConstants - { - Matrix4 modelToProjection; - Matrix4 modelToShadow; - XMFLOAT3 viewerPos; - } vsConstants; - vsConstants.modelToProjection = ViewProjMat; - vsConstants.modelToShadow = m_SunShadow.GetShadowMatrix(); - XMStoreFloat3(&vsConstants.viewerPos, viewerPos); - - gfxContext.SetDynamicConstantBufferView(Renderer::kMeshConstants, sizeof(vsConstants), &vsConstants); - - __declspec(align(16)) uint32_t materialIdx = 0xFFFFFFFFul; - - uint32_t VertexStride = m_Model.GetVertexStride(); - - for (uint32_t meshIndex = 0; meshIndex < m_Model.GetMeshCount(); meshIndex++) - { - const ModelH3D::Mesh& mesh = m_Model.GetMesh(meshIndex); - - uint32_t indexCount = mesh.indexCount; - uint32_t startIndex = mesh.indexDataByteOffset / sizeof(uint16_t); - uint32_t baseVertex = mesh.vertexDataByteOffset / VertexStride; - - if (mesh.materialIndex != materialIdx) - { - if ( m_pMaterialIsCutout[mesh.materialIndex] && !(Filter & kCutout) || - !m_pMaterialIsCutout[mesh.materialIndex] && !(Filter & kOpaque) ) - continue; - - materialIdx = mesh.materialIndex; - gfxContext.SetDescriptorTable(Renderer::kMaterialSRVs, m_Model.GetSRVs(materialIdx)); - - gfxContext.SetDynamicConstantBufferView(Renderer::kCommonCBV, sizeof(uint32_t), &materialIdx); - } - - gfxContext.DrawIndexed(indexCount, startIndex, baseVertex); - } -} - -void Sponza::RenderLightShadows(GraphicsContext& gfxContext, const Camera& camera) -{ - using namespace Lighting; - - ScopedTimer _prof(L"RenderLightShadows", gfxContext); - - static uint32_t LightIndex = 0; - if (LightIndex >= MaxLights) - return; - - m_LightShadowTempBuffer.BeginRendering(gfxContext); - { - gfxContext.SetPipelineState(m_ShadowPSO); - RenderObjects(gfxContext, m_LightShadowMatrix[LightIndex], camera.GetPosition(), kOpaque); - gfxContext.SetPipelineState(m_CutoutShadowPSO); - RenderObjects(gfxContext, m_LightShadowMatrix[LightIndex], camera.GetPosition(), kCutout); - } - //m_LightShadowTempBuffer.EndRendering(gfxContext); - - gfxContext.TransitionResource(m_LightShadowTempBuffer, D3D12_RESOURCE_STATE_COPY_SOURCE); - gfxContext.TransitionResource(m_LightShadowArray, D3D12_RESOURCE_STATE_COPY_DEST); - - gfxContext.CopySubresource(m_LightShadowArray, LightIndex, m_LightShadowTempBuffer, 0); - - gfxContext.TransitionResource(m_LightShadowArray, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - - ++LightIndex; -} - -void Sponza::CreateDiffuseSampler(float MipBias) -{ - SamplerDesc diffuseSamplerDesc; - diffuseSamplerDesc.MaxAnisotropy = 8; - diffuseSamplerDesc.MipLODBias = MipBias; - - m_SamplerHandler = diffuseSamplerDesc.CreateDescriptor(); - - m_MipBias = MipBias; -} - -void Sponza::RenderScene( - GraphicsContext& gfxContext, - const Camera& camera, - const D3D12_VIEWPORT& viewport, - const D3D12_RECT& scissor, - bool skipDiffusePass, - bool skipShadowMap, - float MipBias) -{ - Renderer::UpdateGlobalDescriptors(); - - uint32_t FrameIndex = TemporalEffects::GetFrameIndexMod2(); - - float costheta = cosf(m_SunOrientation); - float sintheta = sinf(m_SunOrientation); - float cosphi = cosf(m_SunInclination * 3.14159f * 0.5f); - float sinphi = sinf(m_SunInclination * 3.14159f * 0.5f); - m_SunDirection = Normalize(Vector3( costheta * cosphi, sinphi, sintheta * cosphi )); - - __declspec(align(16)) struct - { - Vector3 sunDirection; - Vector3 sunLight; - Vector3 ambientLight; - float ShadowTexelSize[4]; - - float InvTileDim[4]; - uint32_t TileCount[4]; - uint32_t FirstLightIndex[4]; - - uint32_t FrameIndexMod2; - } psConstants; - - psConstants.sunDirection = m_SunDirection; - psConstants.sunLight = Vector3(1.0f, 1.0f, 1.0f) * m_SunLightIntensity; - psConstants.ambientLight = Vector3(1.0f, 1.0f, 1.0f) * m_AmbientIntensity; - psConstants.ShadowTexelSize[0] = 1.0f / g_ShadowBuffer.GetWidth(); - psConstants.InvTileDim[0] = 1.0f / Lighting::LightGridDim; - psConstants.InvTileDim[1] = 1.0f / Lighting::LightGridDim; - psConstants.TileCount[0] = Math::DivideByMultiple(g_SceneColorBuffer.GetWidth(), Lighting::LightGridDim); - psConstants.TileCount[1] = Math::DivideByMultiple(g_SceneColorBuffer.GetHeight(), Lighting::LightGridDim); - psConstants.FirstLightIndex[0] = Lighting::m_FirstConeLight; - psConstants.FirstLightIndex[1] = Lighting::m_FirstConeShadowedLight; - psConstants.FrameIndexMod2 = FrameIndex; - - // Set the default state for command lists - auto& pfnSetupGraphicsState = [&](void) - { - gfxContext.SetRootSignature(Renderer::m_RootSig); - gfxContext.SetDescriptorHeap(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, Renderer::s_TextureHeap.GetHeapPointer()); - gfxContext.SetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - gfxContext.SetIndexBuffer(m_Model.GetIndexBuffer()); - gfxContext.SetVertexBuffer(0, m_Model.GetVertexBuffer()); - }; - - pfnSetupGraphicsState(); - - if (MipBias != m_MipBias) - { - CreateDiffuseSampler(MipBias); - } - - // Here we use the first sampler of kMaterialSamplers - gfxContext.SetDynamicSampler(3, 0, m_SamplerHandler); - - RenderLightShadows(gfxContext, camera); - - { - ScopedTimer _prof(L"Z PrePass", gfxContext); - - gfxContext.SetDynamicConstantBufferView(Renderer::kMaterialConstants, sizeof(psConstants), &psConstants); - - { - ScopedTimer _prof2(L"Opaque", gfxContext); - { - gfxContext.TransitionResource(g_SceneDepthBuffer, D3D12_RESOURCE_STATE_DEPTH_WRITE, true); - gfxContext.ClearDepth(g_SceneDepthBuffer); - gfxContext.SetPipelineState(m_DepthPSO); - gfxContext.SetDepthStencilTarget(g_SceneDepthBuffer.GetDSV()); - gfxContext.SetViewportAndScissor(viewport, scissor); - } - RenderObjects(gfxContext, camera.GetViewProjMatrix(), camera.GetPosition(), kOpaque ); - } - - { - ScopedTimer _prof2(L"Cutout", gfxContext); - { - gfxContext.SetPipelineState(m_CutoutDepthPSO); - } - RenderObjects(gfxContext, camera.GetViewProjMatrix(), camera.GetPosition(), kCutout ); - } - } - - SSAO::Render(gfxContext, camera); - - if (!skipDiffusePass) - { - Lighting::FillLightGrid(gfxContext, camera, false); - - if (!SSAO::DebugDraw) - { - ScopedTimer _prof(L"Main Render", gfxContext); - { - gfxContext.TransitionResource(g_SceneColorBuffer, D3D12_RESOURCE_STATE_RENDER_TARGET, true); - gfxContext.TransitionResource(g_SceneNormalBuffer, D3D12_RESOURCE_STATE_RENDER_TARGET, true); - gfxContext.ClearColor(g_SceneColorBuffer); - } - } - } - - if (!skipShadowMap) - { - if (!SSAO::DebugDraw) - { - pfnSetupGraphicsState(); - { - ScopedTimer _prof2(L"Render Shadow Map", gfxContext); - - m_SunShadow.UpdateMatrix(-m_SunDirection, Vector3(0, -500.0f, 0), Vector3(ShadowDimX, ShadowDimY, ShadowDimZ), - (uint32_t)g_ShadowBuffer.GetWidth(), (uint32_t)g_ShadowBuffer.GetHeight(), 16); - - g_ShadowBuffer.BeginRendering(gfxContext); - gfxContext.SetPipelineState(m_ShadowPSO); - RenderObjects(gfxContext, m_SunShadow.GetViewProjMatrix(), camera.GetPosition(), kOpaque); - gfxContext.SetPipelineState(m_CutoutShadowPSO); - RenderObjects(gfxContext, m_SunShadow.GetViewProjMatrix(), camera.GetPosition(), kCutout); - g_ShadowBuffer.EndRendering(gfxContext); - } - } - } - - if (!skipDiffusePass) - { - if (!SSAO::DebugDraw) - { - if (SSAO::AsyncCompute) - { - gfxContext.Flush(); - pfnSetupGraphicsState(); - - // Make the 3D queue wait for the Compute queue to finish SSAO - g_CommandManager.GetGraphicsQueue().StallForProducer(g_CommandManager.GetComputeQueue()); - } - - { - ScopedTimer _prof2(L"Render Color", gfxContext); - - gfxContext.TransitionResource(g_SSAOFullScreen, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - - gfxContext.SetDescriptorTable(Renderer::kCommonSRVs, Renderer::m_CommonTextures); - gfxContext.SetDynamicConstantBufferView(Renderer::kMaterialConstants, sizeof(psConstants), &psConstants); - - { - gfxContext.SetPipelineState(m_ModelPSO); - - gfxContext.TransitionResource(g_SceneDepthBuffer, D3D12_RESOURCE_STATE_DEPTH_READ); - D3D12_CPU_DESCRIPTOR_HANDLE rtvs[]{ g_SceneColorBuffer.GetRTV(), g_SceneNormalBuffer.GetRTV() }; - gfxContext.SetRenderTargets(ARRAYSIZE(rtvs), rtvs, g_SceneDepthBuffer.GetDSV_DepthReadOnly()); - gfxContext.SetViewportAndScissor(viewport, scissor); - } - RenderObjects( gfxContext, camera.GetViewProjMatrix(), camera.GetPosition(), Sponza::kOpaque ); - - gfxContext.SetPipelineState(m_CutoutModelPSO); - - RenderObjects( gfxContext, camera.GetViewProjMatrix(), camera.GetPosition(), Sponza::kCutout ); - } - } - } -} diff --git a/xess/samples/xess_demo/MiniEngine/Model/SponzaRenderer.h b/xess/samples/xess_demo/MiniEngine/Model/SponzaRenderer.h deleted file mode 100644 index 8f63f4d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/SponzaRenderer.h +++ /dev/null @@ -1,50 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// - -#pragma once - -#include - -class GraphicsContext; -class ShadowCamera; -class ModelH3D; -class ExpVar; - -namespace Math -{ - class Camera; - class Vector3; -} - -namespace Sponza -{ - void Startup( Math::Camera& camera ); - void Cleanup( void ); - - void RenderScene( - GraphicsContext& gfxContext, - const Math::Camera& camera, - const D3D12_VIEWPORT& viewport, - const D3D12_RECT& scissor, - bool skipDiffusePass = false, - bool skipShadowMap = false, - float MipBias = 0.0f); - - const ModelH3D& GetModel(); - - extern Math::Vector3 m_SunDirection; - extern ShadowCamera m_SunShadow; - extern ExpVar m_AmbientIntensity; - extern ExpVar m_SunLightIntensity; - -} diff --git a/xess/samples/xess_demo/MiniEngine/Model/TextureConvert.cpp b/xess/samples/xess_demo/MiniEngine/Model/TextureConvert.cpp deleted file mode 100644 index 4514677..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/TextureConvert.cpp +++ /dev/null @@ -1,271 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// Chuck Walbourn (ATG) -// -// This code depends on DirectXTex -// - -#include "TextureConvert.h" -#include "../Core/Utility.h" -#include "DirectXTex.h" - -using namespace DirectX; - -#define GetFlag(f) ((Flags & f) != 0) - -void CompileTextureOnDemand(const std::wstring& originalFile, uint32_t flags) -{ - std::wstring ddsFile = Utility::RemoveExtension(originalFile) + L".dds"; - - struct _stat64 ddsFileStat, srcFileStat; - - bool srcFileMissing = _wstat64(originalFile.c_str(), &srcFileStat) == -1; - bool ddsFileMissing = _wstat64(ddsFile.c_str(), &ddsFileStat) == -1; - - if (srcFileMissing && ddsFileMissing) - { - LOG_ERRORF("Texture %s is missing.", Utility::WideStringToUTF8(Utility::RemoveBasePath(originalFile)).c_str()); - return; - } - - // If we can find the source texture and the DDS file is older, reconvert. - if (ddsFileMissing || !srcFileMissing && ddsFileStat.st_mtime < srcFileStat.st_mtime) - { - LOG_INFOF("DDS texture %s missing or older than source. Rebuilding.", Utility::WideStringToUTF8(Utility::RemoveBasePath(originalFile)).c_str()); - ConvertToDDS(originalFile, flags); - } -} - -bool ConvertToDDS( const std::wstring& filePath, uint32_t Flags ) -{ - bool bInterpretAsSRGB = GetFlag(kSRGB); - bool bPreserveAlpha = GetFlag(kPreserveAlpha); - bool bContainsNormals = GetFlag(kNormalMap); - bool bBumpMap = GetFlag(kBumpToNormal); - bool bBlockCompress = GetFlag(kDefaultBC); - bool bUseBestBC = GetFlag(kQualityBC); - bool bFlipImage = GetFlag(kFlipVertical); - - // Can't be both - ASSERT(!bInterpretAsSRGB || !bContainsNormals); - ASSERT(!bPreserveAlpha || !bContainsNormals); - - LOG_INFOF( "Converting file \"%s\" to DDS.", Utility::WideStringToUTF8(filePath).c_str() ); - - // Get extension as utf8 (ascii) - std::wstring ext = Utility::ToLower(Utility::GetFileExtension(filePath)); - - // Load texture image - TexMetadata info; - std::unique_ptr image(new ScratchImage); - - bool isDDS = false; - bool isHDR = false; - if ( ext == L"dds" ) - { - // TODO: It might be desired to compress or recompress existing DDS files - //Utility::Printf("Ignoring existing DDS \"%ws\".\n", filePath.c_str()); - //return false; - - isDDS = true; - HRESULT hr = LoadFromDDSFile( filePath.c_str(), DDS_FLAGS_NONE, &info, *image ); - if (FAILED(hr)) - { - LOG_ERRORF( "Could not load texture \"%s\" (DDS: %08X).", Utility::WideStringToUTF8(filePath).c_str(), hr ); - return false; - } - } - else if ( ext == L"tga" ) - { - HRESULT hr = LoadFromTGAFile( filePath.c_str(), &info, *image ); - if (FAILED(hr)) - { - LOG_ERRORF( "Could not load texture \"%s\" (TGA: %08X).", Utility::WideStringToUTF8(filePath).c_str(), hr ); - return false; - } - } - else if ( ext == L"hdr" ) - { - isHDR = true; - HRESULT hr = LoadFromHDRFile( filePath.c_str(), &info, *image ); - if (FAILED(hr)) - { - LOG_ERRORF( "Could not load texture \"%s\" (HDR: %08X).", Utility::WideStringToUTF8(filePath).c_str(), hr ); - return false; - } - } - else if ( ext == L"exr" ) - { -#ifdef USE_OPENEXR - isHDR = true; - HRESULT hr = LoadFromEXRFile(filePath.c_str(), &info, *image); - if (FAILED(hr)) - { - LOG_ERRORF("Could not load texture \"%s\" (EXR: %08X).", Utility::WideStringToUTF8(filePath).c_str(), hr); - return false; - } -#else - LOG_ERROR("OpenEXR not supported for this build of the content exporter."); - return false; -#endif - } - else - { - //WIC_FLAGS wicFlags = WIC_FLAGS_NONE; - //if (g_pScene->Settings().bIgnoreSRGB) - // wicFlags |= WIC_FLAGS_IGNORE_SRGB; - - WIC_FLAGS wicFlags = WIC_FLAGS_IGNORE_SRGB; - - HRESULT hr = LoadFromWICFile( filePath.c_str(), wicFlags, &info, *image ); - if (FAILED(hr)) - { - LOG_ERRORF( "Could not load texture \"%s\" (WIC: %08X).", Utility::WideStringToUTF8(filePath).c_str(), hr ); - return false; - } - } - - if ( info.width > 16384 || info.height > 16384 ) - { - LOG_ERRORF("Texture size (%Iu,%Iu) too large for feature level 11.0 or later (16384) \"%s\".", - info.width, info.height, Utility::WideStringToUTF8(filePath).c_str()); - return false; - } - - if (bFlipImage) - { - std::unique_ptr timage(new ScratchImage); - - HRESULT hr = FlipRotate( image->GetImages()[0], TEX_FR_FLIP_VERTICAL, *timage ); - - if (FAILED(hr)) - { - LOG_ERRORF( "Could not flip image \"%s\" (%08X).", Utility::WideStringToUTF8(filePath).c_str(), hr ); - } - else - { - image.swap(timage); - } - - } - - DXGI_FORMAT tformat; - DXGI_FORMAT cformat; - - if (isHDR) - { - tformat = DXGI_FORMAT_R9G9B9E5_SHAREDEXP; - cformat = bBlockCompress ? DXGI_FORMAT_BC6H_UF16 : DXGI_FORMAT_R9G9B9E5_SHAREDEXP; - } - else if (bBlockCompress) - { - tformat = bInterpretAsSRGB ? DXGI_FORMAT_R8G8B8A8_UNORM_SRGB : DXGI_FORMAT_R8G8B8A8_UNORM; - if (bUseBestBC) - cformat = bInterpretAsSRGB ? DXGI_FORMAT_BC7_UNORM_SRGB : DXGI_FORMAT_BC7_UNORM; - else if (bPreserveAlpha) - cformat = bInterpretAsSRGB ? DXGI_FORMAT_BC3_UNORM_SRGB : DXGI_FORMAT_BC3_UNORM; - else - cformat = bInterpretAsSRGB ? DXGI_FORMAT_BC1_UNORM_SRGB : DXGI_FORMAT_BC1_UNORM; - } - else - { - cformat = tformat = bInterpretAsSRGB ? DXGI_FORMAT_R8G8B8A8_UNORM_SRGB : DXGI_FORMAT_R8G8B8A8_UNORM; - } - - if (bBumpMap) - { - std::unique_ptr timage(new ScratchImage); - - HRESULT hr = ComputeNormalMap(image->GetImages(), image->GetImageCount(), image->GetMetadata(), - CNMAP_CHANNEL_LUMINANCE, 10.0f, tformat, *timage); - - if (FAILED(hr)) - { - LOG_ERRORF( "Could not compute normal map for \"%s\" (%08X).", Utility::WideStringToUTF8(filePath).c_str(), hr ); - } - else - { - image.swap(timage); - info.format = tformat; - } - } - else if ( info.format != tformat ) - { - std::unique_ptr timage(new ScratchImage); - - HRESULT hr = Convert( image->GetImages(), image->GetImageCount(), image->GetMetadata(), - tformat, TEX_FILTER_DEFAULT, 0.5f, *timage ); - - if (FAILED(hr)) - { - LOG_ERRORF( "Could not convert \"%s\" (%08X).", Utility::WideStringToUTF8(filePath).c_str(), hr ); - } - else - { - image.swap(timage); - info.format = tformat; - } - } - - // Handle mipmaps - if (info.mipLevels == 1) - { - std::unique_ptr timage(new ScratchImage); - - HRESULT hr = GenerateMipMaps( image->GetImages(), image->GetImageCount(), image->GetMetadata(), TEX_FILTER_DEFAULT, 0, *timage ); - - if (FAILED(hr)) - { - LOG_ERRORF( "Failing generating mimaps for \"%s\" (WIC: %08X).", Utility::WideStringToUTF8(filePath).c_str(), hr ); - } - else - { - image.swap(timage); - } - } - - // Handle compression - if (bBlockCompress) - { - if (info.width % 4 || info.height % 4) - { - LOG_ERRORF( "Texture size (%Iux%Iu) not a multiple of 4 \"%s\", so skipping compress.", info.width, info.height, Utility::WideStringToUTF8(filePath).c_str() ); - } - else - { - std::unique_ptr timage(new ScratchImage); - - HRESULT hr = Compress( image->GetImages(), image->GetImageCount(), image->GetMetadata(), cformat, TEX_COMPRESS_DEFAULT, 0.5f, *timage ); - if (FAILED(hr)) - { - LOG_ERRORF( "Failing compressing \"%s\" (WIC: %08X).", Utility::WideStringToUTF8(filePath).c_str(), hr ); - } - else - { - image.swap(timage); - } - } - } - - // Rename file extension to DDS - const std::wstring wDest = Utility::RemoveExtension(filePath) + L".dds"; - - // Save DDS - HRESULT hr = SaveToDDSFile( image->GetImages(), image->GetImageCount(), image->GetMetadata(), DDS_FLAGS_NONE, wDest.c_str() ); - if( FAILED( hr ) ) - { - LOG_ERRORF( "Could not write texture to file \"%s\" (%08X).", Utility::WideStringToUTF8(wDest).c_str(), hr ); - return false; - } - - return true; -} diff --git a/xess/samples/xess_demo/MiniEngine/Model/TextureConvert.h b/xess/samples/xess_demo/MiniEngine/Model/TextureConvert.h deleted file mode 100644 index 50d00eb..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/TextureConvert.h +++ /dev/null @@ -1,44 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#pragma once - -#include -#include - -enum TexConversionFlags -{ - kSRGB = 1, // Texture contains sRGB colors - kPreserveAlpha = 2, // Keep four channels - kNormalMap = 4, // Texture contains normals - kBumpToNormal = 8, // Generate a normal map from a bump map - kDefaultBC = 16, // Apply standard block compression (BC1-5) - kQualityBC = 32, // Apply quality block compression (BC6H/7) - kFlipVertical = 64, -}; - -inline uint8_t TextureOptions(bool sRGB, bool hasAlpha=false, bool invertY=false) -{ - return (sRGB ? kSRGB : 0) | (hasAlpha ? kPreserveAlpha : 0) | (invertY ? kFlipVertical : 0); -} - -// If the DDS version of the texture specified does not exist or is older than the source texture, reconvert it. -void CompileTextureOnDemand(const std::wstring& originalFile, uint32_t flags); - -// Loads a non-DDS texture such as TGA, PNG, or JPG, then converts it to a more optimal -// DDS format with a full mip chain. Resultant file has the same path with the file extension -// changed to "DDS". -bool ConvertToDDS( - const std::wstring& filePath, // UTF8-encoded path to source file - uint32_t Flags // flags ORed together -); diff --git a/xess/samples/xess_demo/MiniEngine/Model/glTF.cpp b/xess/samples/xess_demo/MiniEngine/Model/glTF.cpp deleted file mode 100644 index db43433..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/glTF.cpp +++ /dev/null @@ -1,805 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author: James Stanard -// - -#include "glTF.h" - -#include "../Core/CommandContext.h" -#include "../Core/SamplerManager.h" -#include "../Core/UploadBuffer.h" -#include "../Core/GraphicsCore.h" -#include "../Core/FileUtility.h" - -#include -#include - -using namespace glTF; -using namespace Graphics; -using namespace Utility; - -void ReadFloats( json& list, float flt_array[] ) -{ - uint32_t i = 0; - for (auto& flt : list) - flt_array[i++] = flt; -} - -void glTF::Asset::ProcessNodes( json& nodes ) -{ - m_nodes.resize(nodes.size()); - - uint32_t nodeIdx = 0; - - for (json::iterator it = nodes.begin(); it != nodes.end(); ++it) - { - glTF::Node& node = m_nodes[nodeIdx++]; - json& thisNode = it.value(); - - node.flags = 0; - node.mesh = nullptr; - node.linearIdx = -1; - - if (thisNode.find("camera") != thisNode.end()) - { - node.camera = &m_cameras[thisNode.at("camera")]; - node.pointsToCamera = true; - } - else if (thisNode.find("mesh") != thisNode.end()) - { - node.mesh = &m_meshes[thisNode.at("mesh")]; - } - - if (thisNode.find("skin") != thisNode.end()) - { - ASSERT(node.mesh != nullptr); - node.mesh->skin = thisNode.at("skin"); - } - - if (thisNode.find("children") != thisNode.end()) - { - json& children = thisNode["children"]; - node.children.reserve(children.size()); - for (auto& child : children) - node.children.push_back(&m_nodes[child]); - } - - if (thisNode.find("matrix") != thisNode.end()) - { - // TODO: Should check for negative determinant to reverse triangle winding - ReadFloats(thisNode["matrix"], node.matrix); - node.hasMatrix = true; - } - else - { - // TODO: Should check scale for 1 or 3 negative values to reverse triangle winding - json::iterator scale = thisNode.find("scale"); - if (scale != thisNode.end()) - { - ReadFloats(scale.value(), node.scale); - } - else - { - node.scale[0] = 1.0f; - node.scale[1] = 1.0f; - node.scale[2] = 1.0f; - } - - json::iterator rotation = thisNode.find("rotation"); - if (rotation != thisNode.end()) - { - ReadFloats(rotation.value(), node.rotation); - } - else - { - node.rotation[0] = 0.0f; - node.rotation[1] = 0.0f; - node.rotation[2] = 0.0f; - node.rotation[3] = 1.0f; - } - - json::iterator translation = thisNode.find("translation"); - if (translation != thisNode.end()) - { - ReadFloats(translation.value(), node.translation); - } - else - { - node.translation[0] = 0.0f; - node.translation[1] = 0.0f; - node.translation[2] = 0.0f; - } - } - } -} - -void glTF::Asset::ProcessScenes( json& scenes ) -{ - m_scenes.reserve(scenes.size()); - - for (json::iterator it = scenes.begin(); it != scenes.end(); ++it) - { - glTF::Scene scene; - json& thisScene = it.value(); - - if (thisScene.find("nodes") != thisScene.end()) - { - json& nodes = thisScene["nodes"]; - scene.nodes.reserve(nodes.size()); - for (auto& node : nodes) - scene.nodes.push_back(&m_nodes[node]); - } - - m_scenes.push_back(scene); - } -} - -void glTF::Asset::ProcessCameras( json& cameras ) -{ - m_cameras.reserve(cameras.size()); - - for (json::iterator it = cameras.begin(); it != cameras.end(); ++it) - { - glTF::Camera camera; - json& thisCamera = it.value(); - - if (thisCamera["type"] == "perspective") - { - json& perspective = thisCamera["perspective"]; - camera.type = Camera::kPerspective; - camera.aspectRatio = 0.0f; - if (perspective.find("aspectRatio") != perspective.end()) - camera.aspectRatio = perspective.at("aspectRatio"); - camera.yfov = perspective["yfov"]; - camera.znear = perspective["znear"]; - camera.zfar = 0.0f; - if (perspective.find("zfar") != perspective.end()) - camera.zfar = perspective.at("zfar"); - } - else - { - camera.type = Camera::kOrthographic; - json& orthographic = thisCamera["orthographic"]; - camera.xmag = orthographic["xmag"]; - camera.ymag = orthographic["ymag"]; - camera.znear = orthographic["znear"]; - camera.zfar = orthographic["zfar"]; - ASSERT(camera.zfar > camera.znear); - } - - m_cameras.push_back(camera); - } -} - -uint16_t TypeToEnum( const char type[] ) -{ - if (strncmp(type, "VEC", 3) == 0) - return Accessor::kVec2 + type[3] - '2'; - else if (strncmp(type, "MAT", 3) == 0) - return Accessor::kMat2 + type[3] - '2'; - else - return Accessor::kScalar; -} - -void glTF::Asset::ProcessAccessors( json& accessors ) -{ - m_accessors.reserve(accessors.size()); - - for (json::iterator it = accessors.begin(); it != accessors.end(); ++it) - { - glTF::Accessor accessor; - json& thisAccessor = it.value(); - - glTF::BufferView& bufferView = m_bufferViews[thisAccessor.at("bufferView")]; - accessor.dataPtr = m_buffers[bufferView.buffer]->data() + bufferView.byteOffset; - accessor.stride = bufferView.byteStride; - if (thisAccessor.find("byteOffset") != thisAccessor.end()) - accessor.dataPtr += thisAccessor.at("byteOffset"); - accessor.count = thisAccessor.at("count"); - accessor.componentType = thisAccessor.at("componentType").get() - 5120; - - char type[8]; - strcpy_s(type, thisAccessor.at("type").get().c_str()); - - accessor.type = TypeToEnum(type); - - m_accessors.push_back(accessor); - } -} - -void glTF::Asset::FindAttribute( Primitive& prim, json& attributes, Primitive::eAttribType type, const string& name ) -{ - json::iterator attrib = attributes.find(name); - if (attrib != attributes.end()) - { - prim.attribMask |= 1 << type; - prim.attributes[type] = &m_accessors[attrib.value()]; - } - else - { - prim.attributes[type] = nullptr; - } -} - -void glTF::Asset::ProcessMeshes( json& meshes, json& accessors ) -{ - m_meshes.resize(meshes.size()); - - uint32_t curMesh = 0; - for (json::iterator meshIt = meshes.begin(); meshIt != meshes.end(); ++meshIt, ++curMesh) - { - json& thisMesh = meshIt.value(); - json& primitives = thisMesh.at("primitives"); - - m_meshes[curMesh].primitives.resize(primitives.size()); - m_meshes[curMesh].skin = -1; - - uint32_t curSubMesh = 0; - for (json::iterator primIt = primitives.begin(); primIt != primitives.end(); ++primIt, ++curSubMesh) - { - glTF::Primitive& prim = m_meshes[curMesh].primitives[curSubMesh]; - json& thisPrim = primIt.value(); - - prim.attribMask = 0; - json& attributes = thisPrim.at("attributes"); - - FindAttribute(prim, attributes, Primitive::kPosition, "POSITION"); - FindAttribute(prim, attributes, Primitive::kNormal, "NORMAL"); - FindAttribute(prim, attributes, Primitive::kTangent, "TANGENT"); - FindAttribute(prim, attributes, Primitive::kTexcoord0, "TEXCOORD_0"); - FindAttribute(prim, attributes, Primitive::kTexcoord1, "TEXCOORD_1"); - FindAttribute(prim, attributes, Primitive::kColor0, "COLOR_0"); - FindAttribute(prim, attributes, Primitive::kJoints0, "JOINTS_0"); - FindAttribute(prim, attributes, Primitive::kWeights0, "WEIGHTS_0"); - - // Read position AABB - json& positionAccessor = accessors[attributes.at("POSITION").get()]; - ReadFloats(positionAccessor.at("min"), prim.minPos); - ReadFloats(positionAccessor.at("max"), prim.maxPos); - - prim.mode = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; - prim.indices = nullptr; - prim.material = nullptr; - prim.minIndex = 0; - prim.maxIndex = 0; - prim.mode = 4; - - if (thisPrim.find("mode") != thisPrim.end()) - prim.mode = thisPrim.at("mode"); - - if (thisPrim.find("indices") != thisPrim.end()) - { - uint32_t accessorIndex = thisPrim.at("indices"); - json& indicesAccessor = accessors[accessorIndex]; - prim.indices = &m_accessors[accessorIndex]; - if (indicesAccessor.find("max") != indicesAccessor.end()) - prim.maxIndex = indicesAccessor.at("max")[0]; - if (indicesAccessor.find("min") != indicesAccessor.end()) - prim.minIndex = indicesAccessor.at("min")[0]; - } - - if (thisPrim.find("material") != thisPrim.end()) - prim.material = &m_materials[thisPrim.at("material")]; - - // TODO: Add morph targets - //if (thisPrim.find("targets") != thisPrim.end()) - } - } -} - -void glTF::Asset::ProcessSkins( json& skins ) -{ - uint32_t skinIdx = 0; - - for (json::iterator it = skins.begin(); it != skins.end(); ++it) - { - glTF::Skin& skin = m_skins[skinIdx++]; - - json& thisSkin = it.value(); - - skin.inverseBindMatrices = nullptr; - skin.skeleton = nullptr; - - if (thisSkin.find("inverseBindMatrices") != thisSkin.end()) - skin.inverseBindMatrices = &m_accessors[thisSkin.at("inverseBindMatrices")]; - - if (thisSkin.find("skeleton") != thisSkin.end()) - { - skin.skeleton = &m_nodes[thisSkin.at("skeleton")]; - skin.skeleton->skeletonRoot = true; - } - - json& joints = thisSkin.at("joints"); - skin.joints.reserve(joints.size()); - for (auto& joint : joints) - skin.joints.push_back(&m_nodes[joint]); - } -} - -inline uint32_t floatToHalf( float f ) -{ - const float kF32toF16 = (1.0 / (1ull << 56)) * (1.0 / (1ull << 56)); // 2^-112 - union { float f; uint32_t u; } x; - x.f = Math::Clamp(f, 0.0f, 1.0f) * kF32toF16; - return x.u >> 13; -} - -uint32_t glTF::Asset::ReadTextureInfo( json& info_json, glTF::Texture* &info ) -{ - info = nullptr; - - if (info_json.find("index") != info_json.end()) - info = &m_textures[info_json.at("index")]; - - if (info_json.find("texCoord") != info_json.end()) - return info_json.at("texCoord"); - else - return 0; -} - -void Asset::DecodeURI( std::string& uri ) -{ - // TODO: real URI decoding - nlohmann::detail::replace_substring(uri, "%20", " "); -} - -void glTF::Asset::ProcessMaterials( json& materials ) -{ - m_materials.reserve(materials.size()); - - uint32_t materialIdx = 0; - - for (json::iterator it = materials.begin(); it != materials.end(); ++it) - { - glTF::Material material; - json& thisMaterial = it.value(); - - material.index = materialIdx++; - material.flags = 0; - material.alphaCutoff = floatToHalf(0.5f); - material.normalTextureScale = 1.0f; - material.emissiveFactor[0] = 0.0f; - material.emissiveFactor[1] = 0.0f; - material.emissiveFactor[2] = 0.0f; - - if (thisMaterial.find("alphaMode") != thisMaterial.end()) - { - string alphaMode = thisMaterial.at("alphaMode"); - if (alphaMode == "BLEND") - material.alphaBlend = true; - else if (alphaMode == "MASK") - material.alphaTest = true; - } - - if (thisMaterial.find("alphaCutoff") != thisMaterial.end()) - { - material.alphaCutoff = floatToHalf(thisMaterial.at("alphaCutoff")); - //material.alphaTest = true; // Should we alpha test and alpha blend? - } - - if (thisMaterial.find("pbrMetallicRoughness") != thisMaterial.end()) - { - json& metallicRoughness = thisMaterial.at("pbrMetallicRoughness"); - - material.baseColorFactor[0] = 1.0f; - material.baseColorFactor[1] = 1.0f; - material.baseColorFactor[2] = 1.0f; - material.baseColorFactor[3] = 1.0f; - material.metallicFactor = 1.0f; - material.roughnessFactor = 1.0f; - for (uint32_t i = 0; i < Material::kNumTextures; ++i) - material.textures[i] = nullptr; - - if (metallicRoughness.find("baseColorFactor") != metallicRoughness.end()) - ReadFloats(metallicRoughness.at("baseColorFactor"), material.baseColorFactor); - - if (metallicRoughness.find("metallicFactor") != metallicRoughness.end()) - material.metallicFactor = metallicRoughness.at("metallicFactor"); - - if (metallicRoughness.find("roughnessFactor") != metallicRoughness.end()) - material.roughnessFactor = metallicRoughness.at("roughnessFactor"); - - if (metallicRoughness.find("baseColorTexture") != metallicRoughness.end()) - material.baseColorUV = ReadTextureInfo(metallicRoughness.at("baseColorTexture"), - material.textures[Material::kBaseColor]); - - if (metallicRoughness.find("metallicRoughnessTexture") != metallicRoughness.end()) - material.metallicRoughnessUV = ReadTextureInfo(metallicRoughness.at("metallicRoughnessTexture"), - material.textures[Material::kMetallicRoughness]); - } - - if (thisMaterial.find("doubleSided") != thisMaterial.end()) - material.twoSided = thisMaterial.at("doubleSided"); - - if (thisMaterial.find("normalTextureScale") != thisMaterial.end()) - material.normalTextureScale = thisMaterial.at("normalTextureScale"); - - if (thisMaterial.find("emissiveFactor") != thisMaterial.end()) - ReadFloats(thisMaterial.at("emissiveFactor"), material.emissiveFactor); - - if (thisMaterial.find("occlusionTexture") != thisMaterial.end()) - material.occlusionUV = ReadTextureInfo(thisMaterial.at("occlusionTexture"), - material.textures[Material::kOcclusion]); - - if (thisMaterial.find("emissiveTexture") != thisMaterial.end()) - material.emissiveUV = ReadTextureInfo(thisMaterial.at("emissiveTexture"), - material.textures[Material::kEmissive]); - - if (thisMaterial.find("normalTexture") != thisMaterial.end()) - material.normalUV = ReadTextureInfo(thisMaterial.at("normalTexture"), - material.textures[Material::kNormal]); - - m_materials.push_back(material); - } -} - -bool ReadFile(const wstring& fileName, void* Dest, size_t Size) -{ - struct _stat64 fileStat; - int fileExists = _wstat64(fileName.c_str(), &fileStat); - if (fileExists == -1) - return false; - - ifstream file(fileName, ios::in | ios::binary); - if (!file) - return false; - - ASSERT(Size == (size_t)fileStat.st_size); - file.read((char*)Dest, Size); - file.close(); - - return true; -} - -void glTF::Asset::ProcessBuffers( json& buffers, ByteArray chunk1bin ) -{ - m_buffers.reserve(buffers.size()); - - for (json::iterator it = buffers.begin(); it != buffers.end(); ++it) - { - json& thisBuffer = it.value(); - - if (thisBuffer.find("uri") != thisBuffer.end()) - { - string uri = thisBuffer.at("uri"); - DecodeURI(uri); - - wstring filepath = m_basePath + Utility::UTF8ToWideString(uri); - - ByteArray ba = ReadFileSync(filepath); - ASSERT(ba->size() > 0, "Missing bin file %ws", filepath.c_str()); - m_buffers.push_back(ba); - } - else - { - ASSERT(it == buffers.begin(), "Only the 1st buffer allowed to be internal"); - ASSERT(chunk1bin->size() > 0, "GLB chunk1 missing data or not a GLB file"); - m_buffers.push_back(chunk1bin); - } - } -} - -void glTF::Asset::ProcessBufferViews( json& bufferViews ) -{ - m_bufferViews.reserve(bufferViews.size()); - - for (json::iterator it = bufferViews.begin(); it != bufferViews.end(); ++it) - { - glTF::BufferView bufferView; - json& thisBufferView = it.value(); - - bufferView.buffer = thisBufferView.at("buffer"); - bufferView.byteLength = thisBufferView.at("byteLength"); - bufferView.byteOffset = 0; - bufferView.byteStride = 0; - bufferView.elementArrayBuffer = false; - - if (thisBufferView.find("byteOffset") != thisBufferView.end()) - bufferView.byteOffset = thisBufferView.at("byteOffset"); - - if (thisBufferView.find("byteStride") != thisBufferView.end()) - bufferView.byteStride = thisBufferView.at("byteStride"); - - // 34962 = ARRAY_BUFFER; 34963 = ELEMENT_ARRAY_BUFFER - if (thisBufferView.find("target") != thisBufferView.end() && thisBufferView.at("target") == 34963) - bufferView.elementArrayBuffer = true; - - m_bufferViews.push_back(bufferView); - } -} - -void glTF::Asset::ProcessImages( json& images ) -{ - m_images.resize(images.size()); - - uint32_t imageIdx = 0; - - for (json::iterator it = images.begin(); it != images.end(); ++it) - { - json& thisImage = it.value(); - if (thisImage.find("uri") != thisImage.end()) - { - string uri = thisImage.at("uri").get(); - DecodeURI(uri); - - m_images[imageIdx++].path = uri; - } - else if (thisImage.find("bufferView") != thisImage.end()) - { - LOG_INFOF("GLB image at buffer view %d with mime type %s.", thisImage.at("bufferView").get(), thisImage.at("mimeType").get().c_str()); - } - else - { - ASSERT(0); - } - } -} - -D3D12_TEXTURE_ADDRESS_MODE GLtoD3DTextureAddressMode( int32_t glWrapMode ) -{ - switch (glWrapMode) - { - default: ERROR("Unexpected sampler wrap mode"); - case 33071: return D3D12_TEXTURE_ADDRESS_MODE_CLAMP; - case 33648: return D3D12_TEXTURE_ADDRESS_MODE_MIRROR; - case 10497: return D3D12_TEXTURE_ADDRESS_MODE_WRAP; - } -} - -/* -D3D12_FILTER GLtoD3DTextureFilterMode( int32_t magFilter, int32_t minFilter ) -{ - bool linearMag = magFilter == 9729; - switch (minFilter) - { - case 9728: //nearest - case 9984: return linearMag ? D3D12_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT : D3D12_FILTER_MIN_MAG_MIP_POINT;//nearest_mipmap_nearest - case 9729: //linear - case 9987: return linearMag ? D3D12_FILTER_MIN_MAG_MIP_LINEAR : D3D12_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR;//linear_mipmap_linear - case 9985: return linearMag ? D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT : D3D12_FILTER_MIN_LINEAR_MAG_MIP_POINT;//linear_mipmap_nearest - case 9986: break;//nearest_mipmap_linear - } -} -*/ - -void glTF::Asset::ProcessSamplers( json& samplers ) -{ - m_samplers.resize(samplers.size()); - - uint32_t samplerIdx = 0; - - for (json::iterator it = samplers.begin(); it != samplers.end(); ++it) - { - json& thisSampler = it.value(); - - glTF::Sampler& sampler = m_samplers[samplerIdx++]; - sampler.filter = D3D12_FILTER_ANISOTROPIC; - sampler.wrapS = D3D12_TEXTURE_ADDRESS_MODE_WRAP; - sampler.wrapT = D3D12_TEXTURE_ADDRESS_MODE_WRAP; - - /* - // Who cares what is provided? It's about what you can afford, generally - // speaking about materials. If you want anisotropic filtering, why let - // the asset dictate that. And AF isn't represented in WebGL, so blech. - int32_t magFilter = 9729; - int32_t minFilter = 9987; - if (thisSampler.find("magFilter") != thisSampler.end()) - magFilter = thisSampler.at("magFilter"); - if (thisSampler.find("minFilter") != thisSampler.end()) - minFilter = thisSampler.at("minFilter"); - sampler.filter = GLtoD3DTextureFilterMode(magFilter, minFilter); - */ - - // But these could matter for correctness. Though, where is border mode? - if (thisSampler.find("wrapS") != thisSampler.end()) - sampler.wrapS = GLtoD3DTextureAddressMode(thisSampler.at("wrapS")); - if (thisSampler.find("wrapT") != thisSampler.end()) - sampler.wrapT = GLtoD3DTextureAddressMode(thisSampler.at("wrapT")); - } -} - -void glTF::Asset::ProcessTextures( json& textures ) -{ - m_textures.resize(textures.size()); - - uint32_t texIdx = 0; - - for (json::iterator it = textures.begin(); it != textures.end(); ++it) - { - glTF::Texture& texture = m_textures[texIdx++]; - json& thisTexture = it.value(); - - texture.source = nullptr; - texture.sampler = nullptr; - - if (thisTexture.find("source") != thisTexture.end()) - texture.source = &m_images[thisTexture.at("source")]; - - if (thisTexture.find("sampler") != thisTexture.end()) - texture.sampler = &m_samplers[thisTexture.at("sampler")]; - } -} - -void glTF::Asset::ProcessAnimations(json& animations) -{ - m_animations.resize(animations.size()); - uint32_t animIdx = 0; - - // Process all animations - for (json::iterator it = animations.begin(); it != animations.end(); ++it) - { - json& thisAnimation = it.value(); - glTF::Animation& animation = m_animations[animIdx++]; - - // Process this animation's samplers - json& samplers = thisAnimation.at("samplers"); - animation.m_samplers.resize(samplers.size()); - uint32_t samplerIdx = 0; - - for (json::iterator it2 = samplers.begin(); it2 != samplers.end(); ++it2) - { - json& thisSampler = it2.value(); - glTF::AnimSampler& sampler = animation.m_samplers[samplerIdx++]; - sampler.m_input = &m_accessors[thisSampler.at("input")]; - sampler.m_output = &m_accessors[thisSampler.at("output")]; - sampler.m_interpolation = AnimSampler::kLinear; - if (thisSampler.find("interpolation") != thisSampler.end()) - { - const std::string& interpolation = thisSampler.at("interpolation"); - if (interpolation == "LINEAR") - sampler.m_interpolation = AnimSampler::kLinear; - else if (interpolation == "STEP") - sampler.m_interpolation = AnimSampler::kStep; - else if (interpolation == "CATMULLROMSPLINE") - sampler.m_interpolation = AnimSampler::kCatmullRomSpline; - else if (interpolation == "CUBICSPLINE") - sampler.m_interpolation = AnimSampler::kCubicSpline; - } - } - - // Process this animation's channels - json& channels = thisAnimation.at("channels"); - animation.m_channels.resize(channels.size()); - uint32_t channelIdx = 0; - - for (json::iterator it2 = channels.begin(); it2 != channels.end(); ++it2) - { - json& thisChannel = it2.value(); - glTF::AnimChannel& channel = animation.m_channels[channelIdx++]; - channel.m_sampler = &animation.m_samplers[thisChannel.at("sampler")]; - json& thisTarget = thisChannel.at("target"); - channel.m_target = &m_nodes[thisTarget.at("node")]; - const std::string& path = thisTarget.at("path"); - if (path == "translation") - channel.m_path = AnimChannel::kTranslation; - else if (path == "rotation") - channel.m_path = AnimChannel::kRotation; - else if (path == "scale") - channel.m_path = AnimChannel::kScale; - else if (path == "weights") - channel.m_path = AnimChannel::kWeights; - } - } -} - -void glTF::Asset::Parse(const std::wstring& filepath) -{ - // TODO: add GLB support by extracting JSON section and BIN sections - //https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#glb-file-format-specification - - ByteArray gltfFile; - ByteArray chunk1Bin; - - std::wstring fileExt = Utility::ToLower(Utility::GetFileExtension(filepath)); - - if (fileExt == L"glb") - { - ifstream glbFile(filepath, ios::in | ios::binary); - struct GLBHeader - { - char magic[4]; - uint32_t version; - uint32_t length; - } header; - glbFile.read((char*)&header, sizeof(GLBHeader)); - if (strncmp(header.magic, "glTF", 4) != 0) - { - LOG_ERROR("Error: Invalid glTF binary format."); - return; - } - if (header.version != 2) - { - LOG_ERROR("Error: Only glTF 2.0 is supported."); - return; - } - - uint32_t chunk0Length; - char chunk0Type[4]; - glbFile.read((char*)&chunk0Length, 4); - glbFile.read((char*)&chunk0Type, 4); - if (strncmp(chunk0Type, "JSON", 4) != 0) - { - LOG_ERROR("Error: Expected chunk0 to contain JSON."); - return; - } - gltfFile = make_shared>( chunk0Length + 1 ); - glbFile.read((char*)gltfFile->data(), chunk0Length); - (*gltfFile)[chunk0Length] = '\0'; - - uint32_t chunk1Length; - char chunk1Type[4]; - glbFile.read((char*)&chunk1Length, 4); - glbFile.read((char*)&chunk1Type, 4); - if (strncmp(chunk1Type, "BIN", 3) != 0) - { - LOG_ERROR("Error: Expected chunk1 to contain BIN."); - return; - } - - chunk1Bin = make_shared>(chunk1Length); - glbFile.read((char*)chunk1Bin->data(), chunk1Length); - } - else - { - ASSERT(fileExt == L"gltf"); - - // Null terminate the string (just in case) - gltfFile = ReadFileSync(filepath); - if (gltfFile->size() == 0) - return; - - gltfFile->push_back('\0'); - chunk1Bin = make_shared>(0); - } - - json root = json::parse((const char*)gltfFile->data()); - if (!root.is_object()) - { - LOG_ERRORF("Invalid glTF file: %s.", Utility::WideStringToUTF8(filepath).c_str()); - return; - } - - // Strip off file name to get root path to other related files - m_basePath = Utility::GetBasePath(filepath); - - // Parse all state - - if (root.find("buffers") != root.end()) - ProcessBuffers(root.at("buffers"), chunk1Bin); - if (root.find("bufferViews") != root.end()) - ProcessBufferViews(root.at("bufferViews")); - if (root.find("accessors") != root.end()) - ProcessAccessors(root.at("accessors")); - if (root.find("images") != root.end()) - ProcessImages(root.at("images")); - if (root.find("samplers") != root.end()) - ProcessSamplers(root.at("samplers")); - if (root.find("textures") != root.end()) - ProcessTextures(root.at("textures")); - if (root.find("materials") != root.end()) - ProcessMaterials(root.at("materials")); - if (root.find("meshes") != root.end()) - ProcessMeshes(root.at("meshes"), root.at("accessors")); - if (root.find("cameras") != root.end()) - ProcessCameras(root.at("cameras")); - if (root.find("skins") != root.end()) - m_skins.resize(root.at("skins").size()); - if (root.find("nodes") != root.end()) - ProcessNodes(root.at("nodes")); - if (root.find("skins") != root.end()) - ProcessSkins(root.at("skins")); - if (root.find("scenes") != root.end()) - ProcessScenes(root.at("scenes")); - if (root.find("animations") != root.end()) - ProcessAnimations(root.at("animations")); - if (root.find("scene") != root.end()) - m_scene = &m_scenes[root.at("scene")]; -} diff --git a/xess/samples/xess_demo/MiniEngine/Model/glTF.h b/xess/samples/xess_demo/MiniEngine/Model/glTF.h deleted file mode 100644 index c33335e..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/glTF.h +++ /dev/null @@ -1,285 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): James Stanard -// - -#pragma once - -#include "../Core/FileUtility.h" - -#ifndef _WIN32 -#define _WIN32 -#endif -#pragma warning(push) -#pragma warning(disable : 4100) // unreferenced formal parameter -#include "json.hpp" -#pragma warning(pop) - -#include - -namespace glTF -{ - using json = nlohmann::json; - using Utility::ByteArray; - - struct BufferView - { - uint32_t buffer; - uint32_t byteLength; - uint32_t byteOffset; - uint16_t byteStride; - bool elementArrayBuffer; - }; - - struct Accessor - { - enum // componentType - { - kByte, - kUnsignedByte, - kShort, - kUnsignedShort, - kSignedInt, // won't happen - kUnsignedInt, - kFloat - }; - - enum // type - { - kScalar, - kVec2, - kVec3, - kVec4, - kMat2, - kMat3, - kMat4 - }; - - //BufferView* bufferView; - //uint32_t byteOffset; // offset from start of buffer view - byte* dataPtr; - uint32_t stride; - uint32_t count; // number of elements - uint16_t componentType; - uint16_t type; - - // Nobody is doing this in the samples. Seems dumb. - //uint32_t sparseCount; // Number of sparse elements - //uint32_t sparseIndices; // Buffer view for indices into sparse data - //uint32_t sparseValues; // Buffer view for packed array of sparse values - }; - - struct Image - { - std::string path; // UTF8 - }; - - struct Sampler - { - D3D12_FILTER filter; - D3D12_TEXTURE_ADDRESS_MODE wrapS; - D3D12_TEXTURE_ADDRESS_MODE wrapT; - }; - - struct Texture - { - Image* source; - Sampler* sampler; - }; - - struct Material - { - union - { - struct - { - float baseColorFactor[4]; // default=[1,1,1,1] - float metallicFactor; // default=1 - float roughnessFactor; // default=1 - }; - }; - union - { - uint32_t flags; - struct - { - uint32_t baseColorUV : 1; - uint32_t metallicRoughnessUV : 1; - uint32_t occlusionUV : 1; - uint32_t emissiveUV : 1; - uint32_t normalUV : 1; - uint32_t twoSided : 1; - uint32_t alphaTest : 1; - uint32_t alphaBlend : 1; - uint32_t _pad : 8; - uint32_t alphaCutoff : 16; // FP16 - }; - }; - float emissiveFactor[3]; // default=[0,0,0] - float normalTextureScale; // default=1 - enum { kBaseColor, kMetallicRoughness, kOcclusion, kEmissive, kNormal, kNumTextures }; - Texture* textures[kNumTextures]; - uint32_t index; - - }; - - struct Primitive - { - enum eAttribType { kPosition, kNormal, kTangent, kTexcoord0, kTexcoord1, kColor0, kJoints0, kWeights0, kNumAttribs }; - Accessor* attributes[kNumAttribs]; - Accessor* indices; - Material* material; - uint16_t attribMask; - uint16_t mode; // D3D_PRIMITIVE_TOPOLOGY - __declspec(align(16)) float minPos[3]; - __declspec(align(16)) float maxPos[3]; - uint32_t minIndex; - uint32_t maxIndex; - //std::vector targets; - }; - - struct Mesh - { - std::vector primitives; - int32_t skin; - }; - - struct Camera - { - enum eType { kPerspective, kOrthographic } type; - union - { - struct - { - float aspectRatio; - float yfov; - }; - struct - { - float xmag; - float ymag; - }; - }; - float znear; - float zfar; - }; - - struct Node - { - union - { - uint8_t flags; - struct - { - bool pointsToCamera : 1; - bool hasMatrix : 1; - bool skeletonRoot : 1; - }; - }; - union - { - Mesh* mesh; - Camera* camera; - }; - std::vector children; - union - { - __declspec(align(16)) float matrix[16]; - struct - { - __declspec(align(16)) float scale[3]; - __declspec(align(16)) float rotation[4]; - __declspec(align(16)) float translation[3]; - }; - }; - int32_t linearIdx; // Assists with mapping scene nodes to flat arrays - }; - - struct Skin - { - Accessor* inverseBindMatrices; // An array of IBMs that match the order of joint nodes - Node* skeleton; // root node (if non-null, this node should be in the list of joints too) - std::vector joints; - }; - - struct Scene - { - std::vector nodes; - }; - - struct AnimSampler - { - Accessor* m_input; // key frame time stamps - Accessor* m_output; // key frame values - enum eInterpolation { kLinear, kStep, kCatmullRomSpline, kCubicSpline }; - eInterpolation m_interpolation; - }; - - struct AnimChannel - { - AnimSampler* m_sampler; - Node* m_target; - enum ePath { kTranslation, kRotation, kScale, kWeights }; - ePath m_path; - }; - - struct Animation - { - std::vector m_channels; - std::vector m_samplers; - }; - - class Asset - { - public: - Asset() : m_scene(nullptr) {} - Asset(const std::wstring& filepath) : m_scene(nullptr) { Parse(filepath); } - ~Asset() { m_meshes.clear(); } - - void Parse(const std::wstring& filepath); - - Scene* m_scene; - std::wstring m_basePath; - std::vector m_scenes; - std::vector m_nodes; - std::vector m_cameras; - std::vector m_meshes; - std::vector m_images; - std::vector m_samplers; - std::vector m_textures; - std::vector m_accessors; - std::vector m_skins; - std::vector m_materials; - std::vector m_buffers; - std::vector m_bufferViews; - std::vector m_animations; - - private: - void ProcessBuffers( json& buffers, ByteArray chunk1bin ); - void ProcessBufferViews( json& bufferViews ); - void ProcessAccessors( json& accessors ); - void ProcessMaterials( json& materials ); - void ProcessTextures( json& textures ); - void ProcessSamplers( json& samplers ); - void ProcessImages( json& images ); - void ProcessSkins( json& skins ); - void ProcessMeshes( json& meshes, json& accessors ); - void ProcessNodes( json& nodes ); - void ProcessAnimations( json& nodes ); - void ProcessCameras( json& cameras ); - void ProcessScenes( json& scenes ); - void FindAttribute( Primitive& prim, json& attributes, Primitive::eAttribType type, const std::string& name); - uint32_t ReadTextureInfo( json& info_json, glTF::Texture* &info ); - void DecodeURI( std::string& uri ); - }; - - -} // namespace glTF diff --git a/xess/samples/xess_demo/MiniEngine/Model/json.hpp b/xess/samples/xess_demo/MiniEngine/Model/json.hpp deleted file mode 100644 index a83971d..0000000 --- a/xess/samples/xess_demo/MiniEngine/Model/json.hpp +++ /dev/null @@ -1,25855 +0,0 @@ -/* - __ _____ _____ _____ - __| | __| | | | JSON for Modern C++ -| | |__ | | | | | | version 3.9.1 -|_____|_____|_____|_|___| https://github.com/nlohmann/json - -Licensed under the MIT License . -SPDX-License-Identifier: MIT -Copyright (c) 2013-2019 Niels Lohmann . - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#ifndef INCLUDE_NLOHMANN_JSON_HPP_ -#define INCLUDE_NLOHMANN_JSON_HPP_ - -#define NLOHMANN_JSON_VERSION_MAJOR 3 -#define NLOHMANN_JSON_VERSION_MINOR 9 -#define NLOHMANN_JSON_VERSION_PATCH 1 - -#include // all_of, find, for_each -#include // nullptr_t, ptrdiff_t, size_t -#include // hash, less -#include // initializer_list -#include // istream, ostream -#include // random_access_iterator_tag -#include // unique_ptr -#include // accumulate -#include // string, stoi, to_string -#include // declval, forward, move, pair, swap -#include // vector - -// #include - - -#include - -// #include - - -#include // transform -#include // array -#include // forward_list -#include // inserter, front_inserter, end -#include // map -#include // string -#include // tuple, make_tuple -#include // is_arithmetic, is_same, is_enum, underlying_type, is_convertible -#include // unordered_map -#include // pair, declval -#include // valarray - -// #include - - -#include // exception -#include // runtime_error -#include // to_string - -// #include - - -#include // array -#include // size_t -#include // uint8_t -#include // string - -namespace nlohmann -{ -namespace detail -{ -/////////////////////////// -// JSON type enumeration // -/////////////////////////// - -/*! -@brief the JSON type enumeration - -This enumeration collects the different JSON types. It is internally used to -distinguish the stored values, and the functions @ref basic_json::is_null(), -@ref basic_json::is_object(), @ref basic_json::is_array(), -@ref basic_json::is_string(), @ref basic_json::is_boolean(), -@ref basic_json::is_number() (with @ref basic_json::is_number_integer(), -@ref basic_json::is_number_unsigned(), and @ref basic_json::is_number_float()), -@ref basic_json::is_discarded(), @ref basic_json::is_primitive(), and -@ref basic_json::is_structured() rely on it. - -@note There are three enumeration entries (number_integer, number_unsigned, and -number_float), because the library distinguishes these three types for numbers: -@ref basic_json::number_unsigned_t is used for unsigned integers, -@ref basic_json::number_integer_t is used for signed integers, and -@ref basic_json::number_float_t is used for floating-point numbers or to -approximate integers which do not fit in the limits of their respective type. - -@sa see @ref basic_json::basic_json(const value_t value_type) -- create a JSON -value with the default value for a given type - -@since version 1.0.0 -*/ -enum class value_t : std::uint8_t -{ - null, ///< null value - object, ///< object (unordered set of name/value pairs) - array, ///< array (ordered collection of values) - string, ///< string value - boolean, ///< boolean value - number_integer, ///< number value (signed integer) - number_unsigned, ///< number value (unsigned integer) - number_float, ///< number value (floating-point) - binary, ///< binary array (ordered collection of bytes) - discarded ///< discarded by the parser callback function -}; - -/*! -@brief comparison operator for JSON types - -Returns an ordering that is similar to Python: -- order: null < boolean < number < object < array < string < binary -- furthermore, each type is not smaller than itself -- discarded values are not comparable -- binary is represented as a b"" string in python and directly comparable to a - string; however, making a binary array directly comparable with a string would - be surprising behavior in a JSON file. - -@since version 1.0.0 -*/ -inline bool operator<(const value_t lhs, const value_t rhs) noexcept -{ - static constexpr std::array order = {{ - 0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */, - 1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */, - 6 /* binary */ - } - }; - - const auto l_index = static_cast(lhs); - const auto r_index = static_cast(rhs); - return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index]; -} -} // namespace detail -} // namespace nlohmann - -// #include - - -#include -// #include - - -#include // pair -// #include -/* Hedley - https://nemequ.github.io/hedley - * Created by Evan Nemerson - * - * To the extent possible under law, the author(s) have dedicated all - * copyright and related and neighboring rights to this software to - * the public domain worldwide. This software is distributed without - * any warranty. - * - * For details, see . - * SPDX-License-Identifier: CC0-1.0 - */ - -#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15) -#if defined(JSON_HEDLEY_VERSION) - #undef JSON_HEDLEY_VERSION -#endif -#define JSON_HEDLEY_VERSION 15 - -#if defined(JSON_HEDLEY_STRINGIFY_EX) - #undef JSON_HEDLEY_STRINGIFY_EX -#endif -#define JSON_HEDLEY_STRINGIFY_EX(x) #x - -#if defined(JSON_HEDLEY_STRINGIFY) - #undef JSON_HEDLEY_STRINGIFY -#endif -#define JSON_HEDLEY_STRINGIFY(x) JSON_HEDLEY_STRINGIFY_EX(x) - -#if defined(JSON_HEDLEY_CONCAT_EX) - #undef JSON_HEDLEY_CONCAT_EX -#endif -#define JSON_HEDLEY_CONCAT_EX(a,b) a##b - -#if defined(JSON_HEDLEY_CONCAT) - #undef JSON_HEDLEY_CONCAT -#endif -#define JSON_HEDLEY_CONCAT(a,b) JSON_HEDLEY_CONCAT_EX(a,b) - -#if defined(JSON_HEDLEY_CONCAT3_EX) - #undef JSON_HEDLEY_CONCAT3_EX -#endif -#define JSON_HEDLEY_CONCAT3_EX(a,b,c) a##b##c - -#if defined(JSON_HEDLEY_CONCAT3) - #undef JSON_HEDLEY_CONCAT3 -#endif -#define JSON_HEDLEY_CONCAT3(a,b,c) JSON_HEDLEY_CONCAT3_EX(a,b,c) - -#if defined(JSON_HEDLEY_VERSION_ENCODE) - #undef JSON_HEDLEY_VERSION_ENCODE -#endif -#define JSON_HEDLEY_VERSION_ENCODE(major,minor,revision) (((major) * 1000000) + ((minor) * 1000) + (revision)) - -#if defined(JSON_HEDLEY_VERSION_DECODE_MAJOR) - #undef JSON_HEDLEY_VERSION_DECODE_MAJOR -#endif -#define JSON_HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000) - -#if defined(JSON_HEDLEY_VERSION_DECODE_MINOR) - #undef JSON_HEDLEY_VERSION_DECODE_MINOR -#endif -#define JSON_HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000) - -#if defined(JSON_HEDLEY_VERSION_DECODE_REVISION) - #undef JSON_HEDLEY_VERSION_DECODE_REVISION -#endif -#define JSON_HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000) - -#if defined(JSON_HEDLEY_GNUC_VERSION) - #undef JSON_HEDLEY_GNUC_VERSION -#endif -#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__) - #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) -#elif defined(__GNUC__) - #define JSON_HEDLEY_GNUC_VERSION JSON_HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0) -#endif - -#if defined(JSON_HEDLEY_GNUC_VERSION_CHECK) - #undef JSON_HEDLEY_GNUC_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_GNUC_VERSION) - #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GNUC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_MSVC_VERSION) - #undef JSON_HEDLEY_MSVC_VERSION -#endif -#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL) - #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) -#elif defined(_MSC_FULL_VER) && !defined(__ICL) - #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10) -#elif defined(_MSC_VER) && !defined(__ICL) - #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0) -#endif - -#if defined(JSON_HEDLEY_MSVC_VERSION_CHECK) - #undef JSON_HEDLEY_MSVC_VERSION_CHECK -#endif -#if !defined(JSON_HEDLEY_MSVC_VERSION) - #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0) -#elif defined(_MSC_VER) && (_MSC_VER >= 1400) - #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch))) -#elif defined(_MSC_VER) && (_MSC_VER >= 1200) - #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch))) -#else - #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_VER >= ((major * 100) + (minor))) -#endif - -#if defined(JSON_HEDLEY_INTEL_VERSION) - #undef JSON_HEDLEY_INTEL_VERSION -#endif -#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL) - #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE) -#elif defined(__INTEL_COMPILER) && !defined(__ICL) - #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) -#endif - -#if defined(JSON_HEDLEY_INTEL_VERSION_CHECK) - #undef JSON_HEDLEY_INTEL_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_INTEL_VERSION) - #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_INTEL_CL_VERSION) - #undef JSON_HEDLEY_INTEL_CL_VERSION -#endif -#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL) - #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0) -#endif - -#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK) - #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_INTEL_CL_VERSION) - #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_PGI_VERSION) - #undef JSON_HEDLEY_PGI_VERSION -#endif -#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && defined(__PGIC_PATCHLEVEL__) - #define JSON_HEDLEY_PGI_VERSION JSON_HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__) -#endif - -#if defined(JSON_HEDLEY_PGI_VERSION_CHECK) - #undef JSON_HEDLEY_PGI_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_PGI_VERSION) - #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PGI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_PGI_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_SUNPRO_VERSION) - #undef JSON_HEDLEY_SUNPRO_VERSION -#endif -#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000) - #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + ((__SUNPRO_C >> 12) & 0xf), (((__SUNPRO_C >> 8) & 0xf) * 10) + ((__SUNPRO_C >> 4) & 0xf), (__SUNPRO_C & 0xf) * 10) -#elif defined(__SUNPRO_C) - #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C) & 0xf) -#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000) - #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + ((__SUNPRO_CC >> 12) & 0xf), (((__SUNPRO_CC >> 8) & 0xf) * 10) + ((__SUNPRO_CC >> 4) & 0xf), (__SUNPRO_CC & 0xf) * 10) -#elif defined(__SUNPRO_CC) - #define JSON_HEDLEY_SUNPRO_VERSION JSON_HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC) & 0xf) -#endif - -#if defined(JSON_HEDLEY_SUNPRO_VERSION_CHECK) - #undef JSON_HEDLEY_SUNPRO_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_SUNPRO_VERSION) - #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_SUNPRO_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_SUNPRO_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION) - #undef JSON_HEDLEY_EMSCRIPTEN_VERSION -#endif -#if defined(__EMSCRIPTEN__) - #define JSON_HEDLEY_EMSCRIPTEN_VERSION JSON_HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, __EMSCRIPTEN_tiny__) -#endif - -#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK) - #undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_EMSCRIPTEN_VERSION) - #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_EMSCRIPTEN_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_ARM_VERSION) - #undef JSON_HEDLEY_ARM_VERSION -#endif -#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION) - #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, (__ARMCOMPILER_VERSION % 1000000) / 10000, (__ARMCOMPILER_VERSION % 10000) / 100) -#elif defined(__CC_ARM) && defined(__ARMCC_VERSION) - #define JSON_HEDLEY_ARM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, (__ARMCC_VERSION % 1000000) / 10000, (__ARMCC_VERSION % 10000) / 100) -#endif - -#if defined(JSON_HEDLEY_ARM_VERSION_CHECK) - #undef JSON_HEDLEY_ARM_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_ARM_VERSION) - #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_ARM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_ARM_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_IBM_VERSION) - #undef JSON_HEDLEY_IBM_VERSION -#endif -#if defined(__ibmxl__) - #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, __ibmxl_modification__) -#elif defined(__xlC__) && defined(__xlC_ver__) - #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, (__xlC_ver__ >> 8) & 0xff) -#elif defined(__xlC__) - #define JSON_HEDLEY_IBM_VERSION JSON_HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0) -#endif - -#if defined(JSON_HEDLEY_IBM_VERSION_CHECK) - #undef JSON_HEDLEY_IBM_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_IBM_VERSION) - #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IBM_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_IBM_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_VERSION) - #undef JSON_HEDLEY_TI_VERSION -#endif -#if \ - defined(__TI_COMPILER_VERSION__) && \ - ( \ - defined(__TMS470__) || defined(__TI_ARM__) || \ - defined(__MSP430__) || \ - defined(__TMS320C2000__) \ - ) -#if (__TI_COMPILER_VERSION__ >= 16000000) - #define JSON_HEDLEY_TI_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif -#endif - -#if defined(JSON_HEDLEY_TI_VERSION_CHECK) - #undef JSON_HEDLEY_TI_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_VERSION) - #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_CL2000_VERSION) - #undef JSON_HEDLEY_TI_CL2000_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C2000__) - #define JSON_HEDLEY_TI_CL2000_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(JSON_HEDLEY_TI_CL2000_VERSION_CHECK) - #undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_CL2000_VERSION) - #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL2000_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_CL2000_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_CL430_VERSION) - #undef JSON_HEDLEY_TI_CL430_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) && defined(__MSP430__) - #define JSON_HEDLEY_TI_CL430_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(JSON_HEDLEY_TI_CL430_VERSION_CHECK) - #undef JSON_HEDLEY_TI_CL430_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_CL430_VERSION) - #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL430_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_CL430_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_ARMCL_VERSION) - #undef JSON_HEDLEY_TI_ARMCL_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) && (defined(__TMS470__) || defined(__TI_ARM__)) - #define JSON_HEDLEY_TI_ARMCL_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(JSON_HEDLEY_TI_ARMCL_VERSION_CHECK) - #undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_ARMCL_VERSION) - #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_ARMCL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_CL6X_VERSION) - #undef JSON_HEDLEY_TI_CL6X_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) && defined(__TMS320C6X__) - #define JSON_HEDLEY_TI_CL6X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(JSON_HEDLEY_TI_CL6X_VERSION_CHECK) - #undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_CL6X_VERSION) - #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL6X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_CL6X_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_CL7X_VERSION) - #undef JSON_HEDLEY_TI_CL7X_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) && defined(__C7000__) - #define JSON_HEDLEY_TI_CL7X_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(JSON_HEDLEY_TI_CL7X_VERSION_CHECK) - #undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_CL7X_VERSION) - #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CL7X_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_CL7X_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TI_CLPRU_VERSION) - #undef JSON_HEDLEY_TI_CLPRU_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) && defined(__PRU__) - #define JSON_HEDLEY_TI_CLPRU_VERSION JSON_HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, (__TI_COMPILER_VERSION__ % 1000000) / 1000, (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(JSON_HEDLEY_TI_CLPRU_VERSION_CHECK) - #undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TI_CLPRU_VERSION) - #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TI_CLPRU_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_CRAY_VERSION) - #undef JSON_HEDLEY_CRAY_VERSION -#endif -#if defined(_CRAYC) - #if defined(_RELEASE_PATCHLEVEL) - #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, _RELEASE_PATCHLEVEL) - #else - #define JSON_HEDLEY_CRAY_VERSION JSON_HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0) - #endif -#endif - -#if defined(JSON_HEDLEY_CRAY_VERSION_CHECK) - #undef JSON_HEDLEY_CRAY_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_CRAY_VERSION) - #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_CRAY_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_CRAY_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_IAR_VERSION) - #undef JSON_HEDLEY_IAR_VERSION -#endif -#if defined(__IAR_SYSTEMS_ICC__) - #if __VER__ > 1000 - #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000)) - #else - #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0) - #endif -#endif - -#if defined(JSON_HEDLEY_IAR_VERSION_CHECK) - #undef JSON_HEDLEY_IAR_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_IAR_VERSION) - #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_IAR_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_IAR_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_TINYC_VERSION) - #undef JSON_HEDLEY_TINYC_VERSION -#endif -#if defined(__TINYC__) - #define JSON_HEDLEY_TINYC_VERSION JSON_HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, __TINYC__ % 100) -#endif - -#if defined(JSON_HEDLEY_TINYC_VERSION_CHECK) - #undef JSON_HEDLEY_TINYC_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_TINYC_VERSION) - #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_TINYC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_TINYC_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_DMC_VERSION) - #undef JSON_HEDLEY_DMC_VERSION -#endif -#if defined(__DMC__) - #define JSON_HEDLEY_DMC_VERSION JSON_HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf) -#endif - -#if defined(JSON_HEDLEY_DMC_VERSION_CHECK) - #undef JSON_HEDLEY_DMC_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_DMC_VERSION) - #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_DMC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_DMC_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_COMPCERT_VERSION) - #undef JSON_HEDLEY_COMPCERT_VERSION -#endif -#if defined(__COMPCERT_VERSION__) - #define JSON_HEDLEY_COMPCERT_VERSION JSON_HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, (__COMPCERT_VERSION__ / 100) % 100, __COMPCERT_VERSION__ % 100) -#endif - -#if defined(JSON_HEDLEY_COMPCERT_VERSION_CHECK) - #undef JSON_HEDLEY_COMPCERT_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_COMPCERT_VERSION) - #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_COMPCERT_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_COMPCERT_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_PELLES_VERSION) - #undef JSON_HEDLEY_PELLES_VERSION -#endif -#if defined(__POCC__) - #define JSON_HEDLEY_PELLES_VERSION JSON_HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0) -#endif - -#if defined(JSON_HEDLEY_PELLES_VERSION_CHECK) - #undef JSON_HEDLEY_PELLES_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_PELLES_VERSION) - #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_PELLES_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_MCST_LCC_VERSION) - #undef JSON_HEDLEY_MCST_LCC_VERSION -#endif -#if defined(__LCC__) && defined(__LCC_MINOR__) - #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__) -#endif - -#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK) - #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_MCST_LCC_VERSION) - #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_GCC_VERSION) - #undef JSON_HEDLEY_GCC_VERSION -#endif -#if \ - defined(JSON_HEDLEY_GNUC_VERSION) && \ - !defined(__clang__) && \ - !defined(JSON_HEDLEY_INTEL_VERSION) && \ - !defined(JSON_HEDLEY_PGI_VERSION) && \ - !defined(JSON_HEDLEY_ARM_VERSION) && \ - !defined(JSON_HEDLEY_CRAY_VERSION) && \ - !defined(JSON_HEDLEY_TI_VERSION) && \ - !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \ - !defined(JSON_HEDLEY_TI_CL430_VERSION) && \ - !defined(JSON_HEDLEY_TI_CL2000_VERSION) && \ - !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \ - !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \ - !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \ - !defined(__COMPCERT__) && \ - !defined(JSON_HEDLEY_MCST_LCC_VERSION) - #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION -#endif - -#if defined(JSON_HEDLEY_GCC_VERSION_CHECK) - #undef JSON_HEDLEY_GCC_VERSION_CHECK -#endif -#if defined(JSON_HEDLEY_GCC_VERSION) - #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_GCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else - #define JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) (0) -#endif - -#if defined(JSON_HEDLEY_HAS_ATTRIBUTE) - #undef JSON_HEDLEY_HAS_ATTRIBUTE -#endif -#if \ - defined(__has_attribute) && \ - ( \ - (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \ - ) -# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) -#else -# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE) - #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE -#endif -#if defined(__has_attribute) - #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) -#else - #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_ATTRIBUTE) - #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE -#endif -#if defined(__has_attribute) - #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) -#else - #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE) - #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE -#endif -#if \ - defined(__has_cpp_attribute) && \ - defined(__cplusplus) && \ - (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) - #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute) -#else - #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0) -#endif - -#if defined(JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS) - #undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS -#endif -#if !defined(__cplusplus) || !defined(__has_cpp_attribute) - #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0) -#elif \ - !defined(JSON_HEDLEY_PGI_VERSION) && \ - !defined(JSON_HEDLEY_IAR_VERSION) && \ - (!defined(JSON_HEDLEY_SUNPRO_VERSION) || JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0)) && \ - (!defined(JSON_HEDLEY_MSVC_VERSION) || JSON_HEDLEY_MSVC_VERSION_CHECK(19,20,0)) - #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(ns::attribute) -#else - #define JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(ns,attribute) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE) - #undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE -#endif -#if defined(__has_cpp_attribute) && defined(__cplusplus) - #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) -#else - #define JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE) - #undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE -#endif -#if defined(__has_cpp_attribute) && defined(__cplusplus) - #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) __has_cpp_attribute(attribute) -#else - #define JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_HAS_BUILTIN) - #undef JSON_HEDLEY_HAS_BUILTIN -#endif -#if defined(__has_builtin) - #define JSON_HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin) -#else - #define JSON_HEDLEY_HAS_BUILTIN(builtin) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_BUILTIN) - #undef JSON_HEDLEY_GNUC_HAS_BUILTIN -#endif -#if defined(__has_builtin) - #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) -#else - #define JSON_HEDLEY_GNUC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_BUILTIN) - #undef JSON_HEDLEY_GCC_HAS_BUILTIN -#endif -#if defined(__has_builtin) - #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) __has_builtin(builtin) -#else - #define JSON_HEDLEY_GCC_HAS_BUILTIN(builtin,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_HAS_FEATURE) - #undef JSON_HEDLEY_HAS_FEATURE -#endif -#if defined(__has_feature) - #define JSON_HEDLEY_HAS_FEATURE(feature) __has_feature(feature) -#else - #define JSON_HEDLEY_HAS_FEATURE(feature) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_FEATURE) - #undef JSON_HEDLEY_GNUC_HAS_FEATURE -#endif -#if defined(__has_feature) - #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) -#else - #define JSON_HEDLEY_GNUC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_FEATURE) - #undef JSON_HEDLEY_GCC_HAS_FEATURE -#endif -#if defined(__has_feature) - #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) __has_feature(feature) -#else - #define JSON_HEDLEY_GCC_HAS_FEATURE(feature,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_HAS_EXTENSION) - #undef JSON_HEDLEY_HAS_EXTENSION -#endif -#if defined(__has_extension) - #define JSON_HEDLEY_HAS_EXTENSION(extension) __has_extension(extension) -#else - #define JSON_HEDLEY_HAS_EXTENSION(extension) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_EXTENSION) - #undef JSON_HEDLEY_GNUC_HAS_EXTENSION -#endif -#if defined(__has_extension) - #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) -#else - #define JSON_HEDLEY_GNUC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_EXTENSION) - #undef JSON_HEDLEY_GCC_HAS_EXTENSION -#endif -#if defined(__has_extension) - #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) __has_extension(extension) -#else - #define JSON_HEDLEY_GCC_HAS_EXTENSION(extension,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE) - #undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE -#endif -#if defined(__has_declspec_attribute) - #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) __has_declspec_attribute(attribute) -#else - #define JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE) - #undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE -#endif -#if defined(__has_declspec_attribute) - #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) -#else - #define JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE) - #undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE -#endif -#if defined(__has_declspec_attribute) - #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) __has_declspec_attribute(attribute) -#else - #define JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_HAS_WARNING) - #undef JSON_HEDLEY_HAS_WARNING -#endif -#if defined(__has_warning) - #define JSON_HEDLEY_HAS_WARNING(warning) __has_warning(warning) -#else - #define JSON_HEDLEY_HAS_WARNING(warning) (0) -#endif - -#if defined(JSON_HEDLEY_GNUC_HAS_WARNING) - #undef JSON_HEDLEY_GNUC_HAS_WARNING -#endif -#if defined(__has_warning) - #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) -#else - #define JSON_HEDLEY_GNUC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_GCC_HAS_WARNING) - #undef JSON_HEDLEY_GCC_HAS_WARNING -#endif -#if defined(__has_warning) - #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) __has_warning(warning) -#else - #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if \ - (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ - defined(__clang__) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ - JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ - (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR)) - #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value) -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define JSON_HEDLEY_PRAGMA(value) __pragma(value) -#else - #define JSON_HEDLEY_PRAGMA(value) -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH) - #undef JSON_HEDLEY_DIAGNOSTIC_PUSH -#endif -#if defined(JSON_HEDLEY_DIAGNOSTIC_POP) - #undef JSON_HEDLEY_DIAGNOSTIC_POP -#endif -#if defined(__clang__) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") -#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) - #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) -#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop") -#elif \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") -#else - #define JSON_HEDLEY_DIAGNOSTIC_PUSH - #define JSON_HEDLEY_DIAGNOSTIC_POP -#endif - -/* JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ is for - HEDLEY INTERNAL USE ONLY. API subject to change without notice. */ -#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) - #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ -#endif -#if defined(__cplusplus) -# if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat") -# if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions") -# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions") -# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ - _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ - _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \ - xpr \ - JSON_HEDLEY_DIAGNOSTIC_POP -# else -# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ - _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ - xpr \ - JSON_HEDLEY_DIAGNOSTIC_POP -# endif -# else -# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ - xpr \ - JSON_HEDLEY_DIAGNOSTIC_POP -# endif -# endif -#endif -#if !defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(x) x -#endif - -#if defined(JSON_HEDLEY_CONST_CAST) - #undef JSON_HEDLEY_CONST_CAST -#endif -#if defined(__cplusplus) -# define JSON_HEDLEY_CONST_CAST(T, expr) (const_cast(expr)) -#elif \ - JSON_HEDLEY_HAS_WARNING("-Wcast-qual") || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define JSON_HEDLEY_CONST_CAST(T, expr) (__extension__ ({ \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \ - ((T) (expr)); \ - JSON_HEDLEY_DIAGNOSTIC_POP \ - })) -#else -# define JSON_HEDLEY_CONST_CAST(T, expr) ((T) (expr)) -#endif - -#if defined(JSON_HEDLEY_REINTERPRET_CAST) - #undef JSON_HEDLEY_REINTERPRET_CAST -#endif -#if defined(__cplusplus) - #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast(expr)) -#else - #define JSON_HEDLEY_REINTERPRET_CAST(T, expr) ((T) (expr)) -#endif - -#if defined(JSON_HEDLEY_STATIC_CAST) - #undef JSON_HEDLEY_STATIC_CAST -#endif -#if defined(__cplusplus) - #define JSON_HEDLEY_STATIC_CAST(T, expr) (static_cast(expr)) -#else - #define JSON_HEDLEY_STATIC_CAST(T, expr) ((T) (expr)) -#endif - -#if defined(JSON_HEDLEY_CPP_CAST) - #undef JSON_HEDLEY_CPP_CAST -#endif -#if defined(__cplusplus) -# if JSON_HEDLEY_HAS_WARNING("-Wold-style-cast") -# define JSON_HEDLEY_CPP_CAST(T, expr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wold-style-cast\"") \ - ((T) (expr)) \ - JSON_HEDLEY_DIAGNOSTIC_POP -# elif JSON_HEDLEY_IAR_VERSION_CHECK(8,3,0) -# define JSON_HEDLEY_CPP_CAST(T, expr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("diag_suppress=Pe137") \ - JSON_HEDLEY_DIAGNOSTIC_POP -# else -# define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr)) -# endif -#else -# define JSON_HEDLEY_CPP_CAST(T, expr) (expr) -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED) - #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wdeprecated-declarations") - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") -#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)") -#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786)) -#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445") -#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996)) -#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") -#elif \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718") -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && !defined(__cplusplus) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)") -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) && defined(__cplusplus) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("error_messages(off,symdeprecated,symdeprecated2)") -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress=Pe1444,Pe1215") -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)") -#else - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS) - #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") -#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)") -#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161)) -#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:4068)) -#elif \ - JSON_HEDLEY_TI_VERSION_CHECK(16,9,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") -#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161") -#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161") -#else - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES) - #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wunknown-attributes") - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("clang diagnostic ignored \"-Wunknown-attributes\"") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") -#elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)") -#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292)) -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030)) -#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098") -#elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("error_messages(off,attrskipunsup)") -#elif \ - JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173") -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097") -#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") -#else - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL) - #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wcast-qual") - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("clang diagnostic ignored \"-Wcast-qual\"") -#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("warning(disable:2203 2331)") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") -#else - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION) - #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wunused-function") - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"") -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505)) -#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142") -#else - #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION -#endif - -#if defined(JSON_HEDLEY_DEPRECATED) - #undef JSON_HEDLEY_DEPRECATED -#endif -#if defined(JSON_HEDLEY_DEPRECATED_FOR) - #undef JSON_HEDLEY_DEPRECATED_FOR -#endif -#if \ - JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since)) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) -#elif \ - (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,13,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(18,1,0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) -#elif defined(__cplusplus) && (__cplusplus >= 201402L) - #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]]) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]]) -#elif \ - JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) - #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_DEPRECATED(since) _Pragma("deprecated") - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated") -#else - #define JSON_HEDLEY_DEPRECATED(since) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) -#endif - -#if defined(JSON_HEDLEY_UNAVAILABLE) - #undef JSON_HEDLEY_UNAVAILABLE -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since))) -#else - #define JSON_HEDLEY_UNAVAILABLE(available_since) -#endif - -#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT) - #undef JSON_HEDLEY_WARN_UNUSED_RESULT -#endif -#if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG) - #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) - #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__)) -#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L) - #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) - #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]]) -#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) - #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) - #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) -#elif defined(_Check_return_) /* SAL */ - #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_ - #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_ -#else - #define JSON_HEDLEY_WARN_UNUSED_RESULT - #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) -#endif - -#if defined(JSON_HEDLEY_SENTINEL) - #undef JSON_HEDLEY_SENTINEL -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position))) -#else - #define JSON_HEDLEY_SENTINEL(position) -#endif - -#if defined(JSON_HEDLEY_NO_RETURN) - #undef JSON_HEDLEY_NO_RETURN -#endif -#if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_NO_RETURN __noreturn -#elif \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) -#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L - #define JSON_HEDLEY_NO_RETURN _Noreturn -#elif defined(__cplusplus) && (__cplusplus >= 201103L) - #define JSON_HEDLEY_NO_RETURN JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[noreturn]]) -#elif \ - JSON_HEDLEY_HAS_ATTRIBUTE(noreturn) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,2,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) - #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) - #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return") -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) -#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus) - #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") -#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) - #define JSON_HEDLEY_NO_RETURN __attribute((noreturn)) -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) - #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) -#else - #define JSON_HEDLEY_NO_RETURN -#endif - -#if defined(JSON_HEDLEY_NO_ESCAPE) - #undef JSON_HEDLEY_NO_ESCAPE -#endif -#if JSON_HEDLEY_HAS_ATTRIBUTE(noescape) - #define JSON_HEDLEY_NO_ESCAPE __attribute__((__noescape__)) -#else - #define JSON_HEDLEY_NO_ESCAPE -#endif - -#if defined(JSON_HEDLEY_UNREACHABLE) - #undef JSON_HEDLEY_UNREACHABLE -#endif -#if defined(JSON_HEDLEY_UNREACHABLE_RETURN) - #undef JSON_HEDLEY_UNREACHABLE_RETURN -#endif -#if defined(JSON_HEDLEY_ASSUME) - #undef JSON_HEDLEY_ASSUME -#endif -#if \ - JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_ASSUME(expr) __assume(expr) -#elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume) - #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr) -#elif \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) - #if defined(__cplusplus) - #define JSON_HEDLEY_ASSUME(expr) std::_nassert(expr) - #else - #define JSON_HEDLEY_ASSUME(expr) _nassert(expr) - #endif -#endif -#if \ - (JSON_HEDLEY_HAS_BUILTIN(__builtin_unreachable) && (!defined(JSON_HEDLEY_ARM_VERSION))) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable() -#elif defined(JSON_HEDLEY_ASSUME) - #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) -#endif -#if !defined(JSON_HEDLEY_ASSUME) - #if defined(JSON_HEDLEY_UNREACHABLE) - #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, ((expr) ? 1 : (JSON_HEDLEY_UNREACHABLE(), 1))) - #else - #define JSON_HEDLEY_ASSUME(expr) JSON_HEDLEY_STATIC_CAST(void, expr) - #endif -#endif -#if defined(JSON_HEDLEY_UNREACHABLE) - #if \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) - #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (JSON_HEDLEY_STATIC_CAST(void, JSON_HEDLEY_ASSUME(0)), (value)) - #else - #define JSON_HEDLEY_UNREACHABLE_RETURN(value) JSON_HEDLEY_UNREACHABLE() - #endif -#else - #define JSON_HEDLEY_UNREACHABLE_RETURN(value) return (value) -#endif -#if !defined(JSON_HEDLEY_UNREACHABLE) - #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) -#endif - -JSON_HEDLEY_DIAGNOSTIC_PUSH -#if JSON_HEDLEY_HAS_WARNING("-Wpedantic") - #pragma clang diagnostic ignored "-Wpedantic" -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") && defined(__cplusplus) - #pragma clang diagnostic ignored "-Wc++98-compat-pedantic" -#endif -#if JSON_HEDLEY_GCC_HAS_WARNING("-Wvariadic-macros",4,0,0) - #if defined(__clang__) - #pragma clang diagnostic ignored "-Wvariadic-macros" - #elif defined(JSON_HEDLEY_GCC_VERSION) - #pragma GCC diagnostic ignored "-Wvariadic-macros" - #endif -#endif -#if defined(JSON_HEDLEY_NON_NULL) - #undef JSON_HEDLEY_NON_NULL -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(nonnull) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) - #define JSON_HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__))) -#else - #define JSON_HEDLEY_NON_NULL(...) -#endif -JSON_HEDLEY_DIAGNOSTIC_POP - -#if defined(JSON_HEDLEY_PRINTF_FORMAT) - #undef JSON_HEDLEY_PRINTF_FORMAT -#endif -#if defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && !defined(__USE_MINGW_ANSI_STDIO) - #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(ms_printf, string_idx, first_to_check))) -#elif defined(__MINGW32__) && JSON_HEDLEY_GCC_HAS_ATTRIBUTE(format,4,4,0) && defined(__USE_MINGW_ANSI_STDIO) - #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(gnu_printf, string_idx, first_to_check))) -#elif \ - JSON_HEDLEY_HAS_ATTRIBUTE(format) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0) - #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check)) -#else - #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) -#endif - -#if defined(JSON_HEDLEY_CONSTEXPR) - #undef JSON_HEDLEY_CONSTEXPR -#endif -#if defined(__cplusplus) - #if __cplusplus >= 201103L - #define JSON_HEDLEY_CONSTEXPR JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(constexpr) - #endif -#endif -#if !defined(JSON_HEDLEY_CONSTEXPR) - #define JSON_HEDLEY_CONSTEXPR -#endif - -#if defined(JSON_HEDLEY_PREDICT) - #undef JSON_HEDLEY_PREDICT -#endif -#if defined(JSON_HEDLEY_LIKELY) - #undef JSON_HEDLEY_LIKELY -#endif -#if defined(JSON_HEDLEY_UNLIKELY) - #undef JSON_HEDLEY_UNLIKELY -#endif -#if defined(JSON_HEDLEY_UNPREDICTABLE) - #undef JSON_HEDLEY_UNPREDICTABLE -#endif -#if JSON_HEDLEY_HAS_BUILTIN(__builtin_unpredictable) - #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr)) -#endif -#if \ - (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) -# define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability)) -# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability)) -# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability)) -# define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 ) -# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 ) -#elif \ - (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) -# define JSON_HEDLEY_PREDICT(expr, expected, probability) \ - (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))) -# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \ - (__extension__ ({ \ - double hedley_probability_ = (probability); \ - ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 1) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 0) : !!(expr))); \ - })) -# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) \ - (__extension__ ({ \ - double hedley_probability_ = (probability); \ - ((hedley_probability_ >= 0.9) ? __builtin_expect(!!(expr), 0) : ((hedley_probability_ <= 0.1) ? __builtin_expect(!!(expr), 1) : !!(expr))); \ - })) -# define JSON_HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) -# define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) -#else -# define JSON_HEDLEY_PREDICT(expr, expected, probability) (JSON_HEDLEY_STATIC_CAST(void, expected), (expr)) -# define JSON_HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr)) -# define JSON_HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr)) -# define JSON_HEDLEY_LIKELY(expr) (!!(expr)) -# define JSON_HEDLEY_UNLIKELY(expr) (!!(expr)) -#endif -#if !defined(JSON_HEDLEY_UNPREDICTABLE) - #define JSON_HEDLEY_UNPREDICTABLE(expr) JSON_HEDLEY_PREDICT(expr, 1, 0.5) -#endif - -#if defined(JSON_HEDLEY_MALLOC) - #undef JSON_HEDLEY_MALLOC -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(malloc) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_MALLOC __attribute__((__malloc__)) -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) - #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory") -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_MALLOC __declspec(restrict) -#else - #define JSON_HEDLEY_MALLOC -#endif - -#if defined(JSON_HEDLEY_PURE) - #undef JSON_HEDLEY_PURE -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(pure) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(2,96,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) -# define JSON_HEDLEY_PURE __attribute__((__pure__)) -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) -# define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data") -#elif defined(__cplusplus) && \ - ( \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(4,0,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) \ - ) -# define JSON_HEDLEY_PURE _Pragma("FUNC_IS_PURE;") -#else -# define JSON_HEDLEY_PURE -#endif - -#if defined(JSON_HEDLEY_CONST) - #undef JSON_HEDLEY_CONST -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(const) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(2,5,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_CONST __attribute__((__const__)) -#elif \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) - #define JSON_HEDLEY_CONST _Pragma("no_side_effect") -#else - #define JSON_HEDLEY_CONST JSON_HEDLEY_PURE -#endif - -#if defined(JSON_HEDLEY_RESTRICT) - #undef JSON_HEDLEY_RESTRICT -#endif -#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && !defined(__cplusplus) - #define JSON_HEDLEY_RESTRICT restrict -#elif \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ - JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,4) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ - defined(__clang__) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_RESTRICT __restrict -#elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus) - #define JSON_HEDLEY_RESTRICT _Restrict -#else - #define JSON_HEDLEY_RESTRICT -#endif - -#if defined(JSON_HEDLEY_INLINE) - #undef JSON_HEDLEY_INLINE -#endif -#if \ - (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ - (defined(__cplusplus) && (__cplusplus >= 199711L)) - #define JSON_HEDLEY_INLINE inline -#elif \ - defined(JSON_HEDLEY_GCC_VERSION) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(6,2,0) - #define JSON_HEDLEY_INLINE __inline__ -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_INLINE __inline -#else - #define JSON_HEDLEY_INLINE -#endif - -#if defined(JSON_HEDLEY_ALWAYS_INLINE) - #undef JSON_HEDLEY_ALWAYS_INLINE -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(always_inline) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) -# define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) -# define JSON_HEDLEY_ALWAYS_INLINE __forceinline -#elif defined(__cplusplus) && \ - ( \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) \ - ) -# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) -# define JSON_HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") -#else -# define JSON_HEDLEY_ALWAYS_INLINE JSON_HEDLEY_INLINE -#endif - -#if defined(JSON_HEDLEY_NEVER_INLINE) - #undef JSON_HEDLEY_NEVER_INLINE -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(noinline) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - (JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,4,0) || \ - (JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,0,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,3,0) || \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) - #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__)) -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) -#elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0) - #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline") -#elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus) - #define JSON_HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;") -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) - #define JSON_HEDLEY_NEVER_INLINE _Pragma("inline=never") -#elif JSON_HEDLEY_COMPCERT_VERSION_CHECK(3,2,0) - #define JSON_HEDLEY_NEVER_INLINE __attribute((noinline)) -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(9,0,0) - #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) -#else - #define JSON_HEDLEY_NEVER_INLINE -#endif - -#if defined(JSON_HEDLEY_PRIVATE) - #undef JSON_HEDLEY_PRIVATE -#endif -#if defined(JSON_HEDLEY_PUBLIC) - #undef JSON_HEDLEY_PUBLIC -#endif -#if defined(JSON_HEDLEY_IMPORT) - #undef JSON_HEDLEY_IMPORT -#endif -#if defined(_WIN32) || defined(__CYGWIN__) -# define JSON_HEDLEY_PRIVATE -# define JSON_HEDLEY_PUBLIC __declspec(dllexport) -# define JSON_HEDLEY_IMPORT __declspec(dllimport) -#else -# if \ - JSON_HEDLEY_HAS_ATTRIBUTE(visibility) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,11,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ - ( \ - defined(__TI_EABI__) && \ - ( \ - (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \ - ) \ - ) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) -# define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) -# define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default"))) -# else -# define JSON_HEDLEY_PRIVATE -# define JSON_HEDLEY_PUBLIC -# endif -# define JSON_HEDLEY_IMPORT extern -#endif - -#if defined(JSON_HEDLEY_NO_THROW) - #undef JSON_HEDLEY_NO_THROW -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__)) -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) - #define JSON_HEDLEY_NO_THROW __declspec(nothrow) -#else - #define JSON_HEDLEY_NO_THROW -#endif - -#if defined(JSON_HEDLEY_FALL_THROUGH) - #undef JSON_HEDLEY_FALL_THROUGH -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) -#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough) - #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]]) -#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough) - #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[fallthrough]]) -#elif defined(__fallthrough) /* SAL */ - #define JSON_HEDLEY_FALL_THROUGH __fallthrough -#else - #define JSON_HEDLEY_FALL_THROUGH -#endif - -#if defined(JSON_HEDLEY_RETURNS_NON_NULL) - #undef JSON_HEDLEY_RETURNS_NON_NULL -#endif -#if \ - JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__)) -#elif defined(_Ret_notnull_) /* SAL */ - #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_ -#else - #define JSON_HEDLEY_RETURNS_NON_NULL -#endif - -#if defined(JSON_HEDLEY_ARRAY_PARAM) - #undef JSON_HEDLEY_ARRAY_PARAM -#endif -#if \ - defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ - !defined(__STDC_NO_VLA__) && \ - !defined(__cplusplus) && \ - !defined(JSON_HEDLEY_PGI_VERSION) && \ - !defined(JSON_HEDLEY_TINYC_VERSION) - #define JSON_HEDLEY_ARRAY_PARAM(name) (name) -#else - #define JSON_HEDLEY_ARRAY_PARAM(name) -#endif - -#if defined(JSON_HEDLEY_IS_CONSTANT) - #undef JSON_HEDLEY_IS_CONSTANT -#endif -#if defined(JSON_HEDLEY_REQUIRE_CONSTEXPR) - #undef JSON_HEDLEY_REQUIRE_CONSTEXPR -#endif -/* JSON_HEDLEY_IS_CONSTEXPR_ is for - HEDLEY INTERNAL USE ONLY. API subject to change without notice. */ -#if defined(JSON_HEDLEY_IS_CONSTEXPR_) - #undef JSON_HEDLEY_IS_CONSTEXPR_ -#endif -#if \ - JSON_HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,19) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ - (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ - JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) - #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) -#endif -#if !defined(__cplusplus) -# if \ - JSON_HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ - JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,24) -#if defined(__INTPTR_TYPE__) - #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0)), int*) -#else - #include - #define JSON_HEDLEY_IS_CONSTEXPR_(expr) __builtin_types_compatible_p(__typeof__((1 ? (void*) ((intptr_t) ((expr) * 0)) : (int*) 0)), int*) -#endif -# elif \ - ( \ - defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \ - !defined(JSON_HEDLEY_SUNPRO_VERSION) && \ - !defined(JSON_HEDLEY_PGI_VERSION) && \ - !defined(JSON_HEDLEY_IAR_VERSION)) || \ - (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5,3,0) -#if defined(__INTPTR_TYPE__) - #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((__INTPTR_TYPE__) ((expr) * 0)) : (int*) 0), int*: 1, void*: 0) -#else - #include - #define JSON_HEDLEY_IS_CONSTEXPR_(expr) _Generic((1 ? (void*) ((intptr_t) * 0) : (int*) 0), int*: 1, void*: 0) -#endif -# elif \ - defined(JSON_HEDLEY_GCC_VERSION) || \ - defined(JSON_HEDLEY_INTEL_VERSION) || \ - defined(JSON_HEDLEY_TINYC_VERSION) || \ - defined(JSON_HEDLEY_TI_ARMCL_VERSION) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(18,12,0) || \ - defined(JSON_HEDLEY_TI_CL2000_VERSION) || \ - defined(JSON_HEDLEY_TI_CL6X_VERSION) || \ - defined(JSON_HEDLEY_TI_CL7X_VERSION) || \ - defined(JSON_HEDLEY_TI_CLPRU_VERSION) || \ - defined(__clang__) -# define JSON_HEDLEY_IS_CONSTEXPR_(expr) ( \ - sizeof(void) != \ - sizeof(*( \ - 1 ? \ - ((void*) ((expr) * 0L) ) : \ -((struct { char v[sizeof(void) * 2]; } *) 1) \ - ) \ - ) \ - ) -# endif -#endif -#if defined(JSON_HEDLEY_IS_CONSTEXPR_) - #if !defined(JSON_HEDLEY_IS_CONSTANT) - #define JSON_HEDLEY_IS_CONSTANT(expr) JSON_HEDLEY_IS_CONSTEXPR_(expr) - #endif - #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (JSON_HEDLEY_IS_CONSTEXPR_(expr) ? (expr) : (-1)) -#else - #if !defined(JSON_HEDLEY_IS_CONSTANT) - #define JSON_HEDLEY_IS_CONSTANT(expr) (0) - #endif - #define JSON_HEDLEY_REQUIRE_CONSTEXPR(expr) (expr) -#endif - -#if defined(JSON_HEDLEY_BEGIN_C_DECLS) - #undef JSON_HEDLEY_BEGIN_C_DECLS -#endif -#if defined(JSON_HEDLEY_END_C_DECLS) - #undef JSON_HEDLEY_END_C_DECLS -#endif -#if defined(JSON_HEDLEY_C_DECL) - #undef JSON_HEDLEY_C_DECL -#endif -#if defined(__cplusplus) - #define JSON_HEDLEY_BEGIN_C_DECLS extern "C" { - #define JSON_HEDLEY_END_C_DECLS } - #define JSON_HEDLEY_C_DECL extern "C" -#else - #define JSON_HEDLEY_BEGIN_C_DECLS - #define JSON_HEDLEY_END_C_DECLS - #define JSON_HEDLEY_C_DECL -#endif - -#if defined(JSON_HEDLEY_STATIC_ASSERT) - #undef JSON_HEDLEY_STATIC_ASSERT -#endif -#if \ - !defined(__cplusplus) && ( \ - (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \ - (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - defined(_Static_assert) \ - ) -# define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) -#elif \ - (defined(__cplusplus) && (__cplusplus >= 201103L)) || \ - JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) -# define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message)) -#else -# define JSON_HEDLEY_STATIC_ASSERT(expr, message) -#endif - -#if defined(JSON_HEDLEY_NULL) - #undef JSON_HEDLEY_NULL -#endif -#if defined(__cplusplus) - #if __cplusplus >= 201103L - #define JSON_HEDLEY_NULL JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(nullptr) - #elif defined(NULL) - #define JSON_HEDLEY_NULL NULL - #else - #define JSON_HEDLEY_NULL JSON_HEDLEY_STATIC_CAST(void*, 0) - #endif -#elif defined(NULL) - #define JSON_HEDLEY_NULL NULL -#else - #define JSON_HEDLEY_NULL ((void*) 0) -#endif - -#if defined(JSON_HEDLEY_MESSAGE) - #undef JSON_HEDLEY_MESSAGE -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") -# define JSON_HEDLEY_MESSAGE(msg) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ - JSON_HEDLEY_PRAGMA(message msg) \ - JSON_HEDLEY_DIAGNOSTIC_POP -#elif \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,4,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message msg) -#elif JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) -# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(_CRI message msg) -#elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) -# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg)) -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,0,0) -# define JSON_HEDLEY_MESSAGE(msg) JSON_HEDLEY_PRAGMA(message(msg)) -#else -# define JSON_HEDLEY_MESSAGE(msg) -#endif - -#if defined(JSON_HEDLEY_WARNING) - #undef JSON_HEDLEY_WARNING -#endif -#if JSON_HEDLEY_HAS_WARNING("-Wunknown-pragmas") -# define JSON_HEDLEY_WARNING(msg) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ - JSON_HEDLEY_PRAGMA(clang warning msg) \ - JSON_HEDLEY_DIAGNOSTIC_POP -#elif \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,8,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) -# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg) -#elif \ - JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) -# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg)) -#else -# define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg) -#endif - -#if defined(JSON_HEDLEY_REQUIRE) - #undef JSON_HEDLEY_REQUIRE -#endif -#if defined(JSON_HEDLEY_REQUIRE_MSG) - #undef JSON_HEDLEY_REQUIRE_MSG -#endif -#if JSON_HEDLEY_HAS_ATTRIBUTE(diagnose_if) -# if JSON_HEDLEY_HAS_WARNING("-Wgcc-compat") -# define JSON_HEDLEY_REQUIRE(expr) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ - __attribute__((diagnose_if(!(expr), #expr, "error"))) \ - JSON_HEDLEY_DIAGNOSTIC_POP -# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ - __attribute__((diagnose_if(!(expr), msg, "error"))) \ - JSON_HEDLEY_DIAGNOSTIC_POP -# else -# define JSON_HEDLEY_REQUIRE(expr) __attribute__((diagnose_if(!(expr), #expr, "error"))) -# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) __attribute__((diagnose_if(!(expr), msg, "error"))) -# endif -#else -# define JSON_HEDLEY_REQUIRE(expr) -# define JSON_HEDLEY_REQUIRE_MSG(expr,msg) -#endif - -#if defined(JSON_HEDLEY_FLAGS) - #undef JSON_HEDLEY_FLAGS -#endif -#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion")) - #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__)) -#else - #define JSON_HEDLEY_FLAGS -#endif - -#if defined(JSON_HEDLEY_FLAGS_CAST) - #undef JSON_HEDLEY_FLAGS_CAST -#endif -#if JSON_HEDLEY_INTEL_VERSION_CHECK(19,0,0) -# define JSON_HEDLEY_FLAGS_CAST(T, expr) (__extension__ ({ \ - JSON_HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("warning(disable:188)") \ - ((T) (expr)); \ - JSON_HEDLEY_DIAGNOSTIC_POP \ - })) -#else -# define JSON_HEDLEY_FLAGS_CAST(T, expr) JSON_HEDLEY_STATIC_CAST(T, expr) -#endif - -#if defined(JSON_HEDLEY_EMPTY_BASES) - #undef JSON_HEDLEY_EMPTY_BASES -#endif -#if \ - (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \ - JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) - #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases) -#else - #define JSON_HEDLEY_EMPTY_BASES -#endif - -/* Remaining macros are deprecated. */ - -#if defined(JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK) - #undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK -#endif -#if defined(__clang__) - #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) (0) -#else - #define JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) -#endif - -#if defined(JSON_HEDLEY_CLANG_HAS_ATTRIBUTE) - #undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE -#endif -#define JSON_HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) - -#if defined(JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE) - #undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE -#endif -#define JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_CPP_ATTRIBUTE(attribute) - -#if defined(JSON_HEDLEY_CLANG_HAS_BUILTIN) - #undef JSON_HEDLEY_CLANG_HAS_BUILTIN -#endif -#define JSON_HEDLEY_CLANG_HAS_BUILTIN(builtin) JSON_HEDLEY_HAS_BUILTIN(builtin) - -#if defined(JSON_HEDLEY_CLANG_HAS_FEATURE) - #undef JSON_HEDLEY_CLANG_HAS_FEATURE -#endif -#define JSON_HEDLEY_CLANG_HAS_FEATURE(feature) JSON_HEDLEY_HAS_FEATURE(feature) - -#if defined(JSON_HEDLEY_CLANG_HAS_EXTENSION) - #undef JSON_HEDLEY_CLANG_HAS_EXTENSION -#endif -#define JSON_HEDLEY_CLANG_HAS_EXTENSION(extension) JSON_HEDLEY_HAS_EXTENSION(extension) - -#if defined(JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE) - #undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE -#endif -#define JSON_HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) - -#if defined(JSON_HEDLEY_CLANG_HAS_WARNING) - #undef JSON_HEDLEY_CLANG_HAS_WARNING -#endif -#define JSON_HEDLEY_CLANG_HAS_WARNING(warning) JSON_HEDLEY_HAS_WARNING(warning) - -#endif /* !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < X) */ - - -// This file contains all internal macro definitions -// You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them - -// exclude unsupported compilers -#if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK) - #if defined(__clang__) - #if (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) < 30400 - #error "unsupported Clang version - see https://github.com/nlohmann/json#supported-compilers" - #endif - #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER)) - #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800 - #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers" - #endif - #endif -#endif - -// C++ language standard detection -#if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) - #define JSON_HAS_CPP_20 - #define JSON_HAS_CPP_17 - #define JSON_HAS_CPP_14 -#elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 - #define JSON_HAS_CPP_17 - #define JSON_HAS_CPP_14 -#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) - #define JSON_HAS_CPP_14 -#endif - -// disable float-equal warnings on GCC/clang -#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wfloat-equal" -#endif - -// disable documentation warnings on clang -#if defined(__clang__) - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdocumentation" -#endif - -// allow to disable exceptions -#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION) - #define JSON_THROW(exception) throw exception - #define JSON_TRY try - #define JSON_CATCH(exception) catch(exception) - #define JSON_INTERNAL_CATCH(exception) catch(exception) -#else - #include - #define JSON_THROW(exception) std::abort() - #define JSON_TRY if(true) - #define JSON_CATCH(exception) if(false) - #define JSON_INTERNAL_CATCH(exception) if(false) -#endif - -// override exception macros -#if defined(JSON_THROW_USER) - #undef JSON_THROW - #define JSON_THROW JSON_THROW_USER -#endif -#if defined(JSON_TRY_USER) - #undef JSON_TRY - #define JSON_TRY JSON_TRY_USER -#endif -#if defined(JSON_CATCH_USER) - #undef JSON_CATCH - #define JSON_CATCH JSON_CATCH_USER - #undef JSON_INTERNAL_CATCH - #define JSON_INTERNAL_CATCH JSON_CATCH_USER -#endif -#if defined(JSON_INTERNAL_CATCH_USER) - #undef JSON_INTERNAL_CATCH - #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER -#endif - -// allow to override assert -#if !defined(JSON_ASSERT) - #include // assert - #define JSON_ASSERT(x) assert(x) -#endif - -// allow to access some private functions (needed by the test suite) -#if defined(JSON_TESTS_PRIVATE) - #define JSON_PRIVATE_UNLESS_TESTED public -#else - #define JSON_PRIVATE_UNLESS_TESTED private -#endif - -/*! -@brief macro to briefly define a mapping between an enum and JSON -@def NLOHMANN_JSON_SERIALIZE_ENUM -@since version 3.4.0 -*/ -#define NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE, ...) \ - template \ - inline void to_json(BasicJsonType& j, const ENUM_TYPE& e) \ - { \ - static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ - static const std::pair m[] = __VA_ARGS__; \ - auto it = std::find_if(std::begin(m), std::end(m), \ - [e](const std::pair& ej_pair) -> bool \ - { \ - return ej_pair.first == e; \ - }); \ - j = ((it != std::end(m)) ? it : std::begin(m))->second; \ - } \ - template \ - inline void from_json(const BasicJsonType& j, ENUM_TYPE& e) \ - { \ - static_assert(std::is_enum::value, #ENUM_TYPE " must be an enum!"); \ - static const std::pair m[] = __VA_ARGS__; \ - auto it = std::find_if(std::begin(m), std::end(m), \ - [&j](const std::pair& ej_pair) -> bool \ - { \ - return ej_pair.second == j; \ - }); \ - e = ((it != std::end(m)) ? it : std::begin(m))->first; \ - } - -// Ugly macros to avoid uglier copy-paste when specializing basic_json. They -// may be removed in the future once the class is split. - -#define NLOHMANN_BASIC_JSON_TPL_DECLARATION \ - template class ObjectType, \ - template class ArrayType, \ - class StringType, class BooleanType, class NumberIntegerType, \ - class NumberUnsignedType, class NumberFloatType, \ - template class AllocatorType, \ - template class JSONSerializer, \ - class BinaryType> - -#define NLOHMANN_BASIC_JSON_TPL \ - basic_json - -// Macros to simplify conversion from/to types - -#define NLOHMANN_JSON_EXPAND( x ) x -#define NLOHMANN_JSON_GET_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, NAME,...) NAME -#define NLOHMANN_JSON_PASTE(...) NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_GET_MACRO(__VA_ARGS__, \ - NLOHMANN_JSON_PASTE64, \ - NLOHMANN_JSON_PASTE63, \ - NLOHMANN_JSON_PASTE62, \ - NLOHMANN_JSON_PASTE61, \ - NLOHMANN_JSON_PASTE60, \ - NLOHMANN_JSON_PASTE59, \ - NLOHMANN_JSON_PASTE58, \ - NLOHMANN_JSON_PASTE57, \ - NLOHMANN_JSON_PASTE56, \ - NLOHMANN_JSON_PASTE55, \ - NLOHMANN_JSON_PASTE54, \ - NLOHMANN_JSON_PASTE53, \ - NLOHMANN_JSON_PASTE52, \ - NLOHMANN_JSON_PASTE51, \ - NLOHMANN_JSON_PASTE50, \ - NLOHMANN_JSON_PASTE49, \ - NLOHMANN_JSON_PASTE48, \ - NLOHMANN_JSON_PASTE47, \ - NLOHMANN_JSON_PASTE46, \ - NLOHMANN_JSON_PASTE45, \ - NLOHMANN_JSON_PASTE44, \ - NLOHMANN_JSON_PASTE43, \ - NLOHMANN_JSON_PASTE42, \ - NLOHMANN_JSON_PASTE41, \ - NLOHMANN_JSON_PASTE40, \ - NLOHMANN_JSON_PASTE39, \ - NLOHMANN_JSON_PASTE38, \ - NLOHMANN_JSON_PASTE37, \ - NLOHMANN_JSON_PASTE36, \ - NLOHMANN_JSON_PASTE35, \ - NLOHMANN_JSON_PASTE34, \ - NLOHMANN_JSON_PASTE33, \ - NLOHMANN_JSON_PASTE32, \ - NLOHMANN_JSON_PASTE31, \ - NLOHMANN_JSON_PASTE30, \ - NLOHMANN_JSON_PASTE29, \ - NLOHMANN_JSON_PASTE28, \ - NLOHMANN_JSON_PASTE27, \ - NLOHMANN_JSON_PASTE26, \ - NLOHMANN_JSON_PASTE25, \ - NLOHMANN_JSON_PASTE24, \ - NLOHMANN_JSON_PASTE23, \ - NLOHMANN_JSON_PASTE22, \ - NLOHMANN_JSON_PASTE21, \ - NLOHMANN_JSON_PASTE20, \ - NLOHMANN_JSON_PASTE19, \ - NLOHMANN_JSON_PASTE18, \ - NLOHMANN_JSON_PASTE17, \ - NLOHMANN_JSON_PASTE16, \ - NLOHMANN_JSON_PASTE15, \ - NLOHMANN_JSON_PASTE14, \ - NLOHMANN_JSON_PASTE13, \ - NLOHMANN_JSON_PASTE12, \ - NLOHMANN_JSON_PASTE11, \ - NLOHMANN_JSON_PASTE10, \ - NLOHMANN_JSON_PASTE9, \ - NLOHMANN_JSON_PASTE8, \ - NLOHMANN_JSON_PASTE7, \ - NLOHMANN_JSON_PASTE6, \ - NLOHMANN_JSON_PASTE5, \ - NLOHMANN_JSON_PASTE4, \ - NLOHMANN_JSON_PASTE3, \ - NLOHMANN_JSON_PASTE2, \ - NLOHMANN_JSON_PASTE1)(__VA_ARGS__)) -#define NLOHMANN_JSON_PASTE2(func, v1) func(v1) -#define NLOHMANN_JSON_PASTE3(func, v1, v2) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE2(func, v2) -#define NLOHMANN_JSON_PASTE4(func, v1, v2, v3) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE3(func, v2, v3) -#define NLOHMANN_JSON_PASTE5(func, v1, v2, v3, v4) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE4(func, v2, v3, v4) -#define NLOHMANN_JSON_PASTE6(func, v1, v2, v3, v4, v5) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE5(func, v2, v3, v4, v5) -#define NLOHMANN_JSON_PASTE7(func, v1, v2, v3, v4, v5, v6) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE6(func, v2, v3, v4, v5, v6) -#define NLOHMANN_JSON_PASTE8(func, v1, v2, v3, v4, v5, v6, v7) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE7(func, v2, v3, v4, v5, v6, v7) -#define NLOHMANN_JSON_PASTE9(func, v1, v2, v3, v4, v5, v6, v7, v8) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE8(func, v2, v3, v4, v5, v6, v7, v8) -#define NLOHMANN_JSON_PASTE10(func, v1, v2, v3, v4, v5, v6, v7, v8, v9) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE9(func, v2, v3, v4, v5, v6, v7, v8, v9) -#define NLOHMANN_JSON_PASTE11(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE10(func, v2, v3, v4, v5, v6, v7, v8, v9, v10) -#define NLOHMANN_JSON_PASTE12(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE11(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11) -#define NLOHMANN_JSON_PASTE13(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE12(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12) -#define NLOHMANN_JSON_PASTE14(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE13(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13) -#define NLOHMANN_JSON_PASTE15(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE14(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14) -#define NLOHMANN_JSON_PASTE16(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE15(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15) -#define NLOHMANN_JSON_PASTE17(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE16(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16) -#define NLOHMANN_JSON_PASTE18(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE17(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17) -#define NLOHMANN_JSON_PASTE19(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE18(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18) -#define NLOHMANN_JSON_PASTE20(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE19(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19) -#define NLOHMANN_JSON_PASTE21(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE20(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20) -#define NLOHMANN_JSON_PASTE22(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE21(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21) -#define NLOHMANN_JSON_PASTE23(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE22(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) -#define NLOHMANN_JSON_PASTE24(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE23(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23) -#define NLOHMANN_JSON_PASTE25(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE24(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24) -#define NLOHMANN_JSON_PASTE26(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE25(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25) -#define NLOHMANN_JSON_PASTE27(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE26(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26) -#define NLOHMANN_JSON_PASTE28(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE27(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27) -#define NLOHMANN_JSON_PASTE29(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE28(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28) -#define NLOHMANN_JSON_PASTE30(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE29(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29) -#define NLOHMANN_JSON_PASTE31(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE30(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30) -#define NLOHMANN_JSON_PASTE32(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE31(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31) -#define NLOHMANN_JSON_PASTE33(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE32(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32) -#define NLOHMANN_JSON_PASTE34(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE33(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33) -#define NLOHMANN_JSON_PASTE35(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE34(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34) -#define NLOHMANN_JSON_PASTE36(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE35(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35) -#define NLOHMANN_JSON_PASTE37(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE36(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36) -#define NLOHMANN_JSON_PASTE38(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE37(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37) -#define NLOHMANN_JSON_PASTE39(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE38(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38) -#define NLOHMANN_JSON_PASTE40(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE39(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39) -#define NLOHMANN_JSON_PASTE41(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE40(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40) -#define NLOHMANN_JSON_PASTE42(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE41(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41) -#define NLOHMANN_JSON_PASTE43(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE42(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42) -#define NLOHMANN_JSON_PASTE44(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE43(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43) -#define NLOHMANN_JSON_PASTE45(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE44(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44) -#define NLOHMANN_JSON_PASTE46(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE45(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45) -#define NLOHMANN_JSON_PASTE47(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE46(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46) -#define NLOHMANN_JSON_PASTE48(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE47(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47) -#define NLOHMANN_JSON_PASTE49(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE48(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48) -#define NLOHMANN_JSON_PASTE50(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE49(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49) -#define NLOHMANN_JSON_PASTE51(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE50(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50) -#define NLOHMANN_JSON_PASTE52(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE51(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51) -#define NLOHMANN_JSON_PASTE53(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE52(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52) -#define NLOHMANN_JSON_PASTE54(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE53(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53) -#define NLOHMANN_JSON_PASTE55(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE54(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54) -#define NLOHMANN_JSON_PASTE56(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE55(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55) -#define NLOHMANN_JSON_PASTE57(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE56(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56) -#define NLOHMANN_JSON_PASTE58(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE57(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57) -#define NLOHMANN_JSON_PASTE59(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE58(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58) -#define NLOHMANN_JSON_PASTE60(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE59(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59) -#define NLOHMANN_JSON_PASTE61(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE60(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60) -#define NLOHMANN_JSON_PASTE62(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE61(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61) -#define NLOHMANN_JSON_PASTE63(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE62(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62) -#define NLOHMANN_JSON_PASTE64(func, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) NLOHMANN_JSON_PASTE2(func, v1) NLOHMANN_JSON_PASTE63(func, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63) - -#define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1; -#define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1); - -/*! -@brief macro -@def NLOHMANN_DEFINE_TYPE_INTRUSIVE -@since version 3.9.0 -*/ -#define NLOHMANN_DEFINE_TYPE_INTRUSIVE(Type, ...) \ - friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ - friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } - -/*! -@brief macro -@def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE -@since version 3.9.0 -*/ -#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Type, ...) \ - inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ - inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } - -#ifndef JSON_USE_IMPLICIT_CONVERSIONS - #define JSON_USE_IMPLICIT_CONVERSIONS 1 -#endif - -#if JSON_USE_IMPLICIT_CONVERSIONS - #define JSON_EXPLICIT -#else - #define JSON_EXPLICIT explicit -#endif - - -namespace nlohmann -{ -namespace detail -{ - -/*! -@brief replace all occurrences of a substring by another string - -@param[in,out] s the string to manipulate; changed so that all - occurrences of @a f are replaced with @a t -@param[in] f the substring to replace with @a t -@param[in] t the string to replace @a f - -@pre The search string @a f must not be empty. **This precondition is -enforced with an assertion.** - -@since version 2.0.0 -*/ -inline void replace_substring(std::string& s, const std::string& f, - const std::string& t) -{ - JSON_ASSERT(!f.empty()); - for (auto pos = s.find(f); // find first occurrence of f - pos != std::string::npos; // make sure f was found - s.replace(pos, f.size(), t), // replace with t, and - pos = s.find(f, pos + t.size())) // find next occurrence of f - {} -} - -/*! - * @brief string escaping as described in RFC 6901 (Sect. 4) - * @param[in] s string to escape - * @return escaped string - * - * Note the order of escaping "~" to "~0" and "/" to "~1" is important. - */ -inline std::string escape(std::string s) -{ - replace_substring(s, "~", "~0"); - replace_substring(s, "/", "~1"); - return s; -} - -/*! - * @brief string unescaping as described in RFC 6901 (Sect. 4) - * @param[in] s string to unescape - * @return unescaped string - * - * Note the order of escaping "~1" to "/" and "~0" to "~" is important. - */ -static void unescape(std::string& s) -{ - replace_substring(s, "~1", "/"); - replace_substring(s, "~0", "~"); -} - -} // namespace detail -} // namespace nlohmann - -// #include - - -#include // size_t - -namespace nlohmann -{ -namespace detail -{ -/// struct to capture the start position of the current token -struct position_t -{ - /// the total number of characters read - std::size_t chars_read_total = 0; - /// the number of characters read in the current line - std::size_t chars_read_current_line = 0; - /// the number of lines read - std::size_t lines_read = 0; - - /// conversion to size_t to preserve SAX interface - constexpr operator size_t() const - { - return chars_read_total; - } -}; - -} // namespace detail -} // namespace nlohmann - -// #include - - -namespace nlohmann -{ -namespace detail -{ -//////////////// -// exceptions // -//////////////// - -/*! -@brief general exception of the @ref basic_json class - -This class is an extension of `std::exception` objects with a member @a id for -exception ids. It is used as the base class for all exceptions thrown by the -@ref basic_json class. This class can hence be used as "wildcard" to catch -exceptions. - -Subclasses: -- @ref parse_error for exceptions indicating a parse error -- @ref invalid_iterator for exceptions indicating errors with iterators -- @ref type_error for exceptions indicating executing a member function with - a wrong type -- @ref out_of_range for exceptions indicating access out of the defined range -- @ref other_error for exceptions indicating other library errors - -@internal -@note To have nothrow-copy-constructible exceptions, we internally use - `std::runtime_error` which can cope with arbitrary-length error messages. - Intermediate strings are built with static functions and then passed to - the actual constructor. -@endinternal - -@liveexample{The following code shows how arbitrary library exceptions can be -caught.,exception} - -@since version 3.0.0 -*/ -class exception : public std::exception -{ - public: - /// returns the explanatory string - JSON_HEDLEY_RETURNS_NON_NULL - const char* what() const noexcept override - { - return m.what(); - } - - /// the id of the exception - const int id; - - protected: - JSON_HEDLEY_NON_NULL(3) - exception(int id_, const char* what_arg) : id(id_), m(what_arg) {} - - static std::string name(const std::string& ename, int id_) - { - return "[json.exception." + ename + "." + std::to_string(id_) + "] "; - } - - template - static std::string diagnostics(const BasicJsonType& leaf_element) - { -#if JSON_DIAGNOSTICS - std::vector tokens; - for (const auto* current = &leaf_element; current->m_parent != nullptr; current = current->m_parent) - { - switch (current->m_parent->type()) - { - case value_t::array: - { - for (std::size_t i = 0; i < current->m_parent->m_value.array->size(); ++i) - { - if (¤t->m_parent->m_value.array->operator[](i) == current) - { - tokens.emplace_back(std::to_string(i)); - break; - } - } - break; - } - - case value_t::object: - { - for (const auto& element : *current->m_parent->m_value.object) - { - if (&element.second == current) - { - tokens.emplace_back(element.first.c_str()); - break; - } - } - break; - } - - default: // LCOV_EXCL_LINE - break; // LCOV_EXCL_LINE - } - } - - if (tokens.empty()) - { - return ""; - } - - return "(" + std::accumulate(tokens.rbegin(), tokens.rend(), std::string{}, - [](const std::string & a, const std::string & b) - { - return a + "/" + detail::escape(b); - }) + ") "; -#else - return ""; -#endif - } - - private: - /// an exception object as storage for error messages - std::runtime_error m; -}; - -/*! -@brief exception indicating a parse error - -This exception is thrown by the library when a parse error occurs. Parse errors -can occur during the deserialization of JSON text, CBOR, MessagePack, as well -as when using JSON Patch. - -Member @a byte holds the byte index of the last read character in the input -file. - -Exceptions have ids 1xx. - -name / id | example message | description ------------------------------- | --------------- | ------------------------- -json.exception.parse_error.101 | parse error at 2: unexpected end of input; expected string literal | This error indicates a syntax error while deserializing a JSON text. The error message describes that an unexpected token (character) was encountered, and the member @a byte indicates the error position. -json.exception.parse_error.102 | parse error at 14: missing or wrong low surrogate | JSON uses the `\uxxxx` format to describe Unicode characters. Code points above above 0xFFFF are split into two `\uxxxx` entries ("surrogate pairs"). This error indicates that the surrogate pair is incomplete or contains an invalid code point. -json.exception.parse_error.103 | parse error: code points above 0x10FFFF are invalid | Unicode supports code points up to 0x10FFFF. Code points above 0x10FFFF are invalid. -json.exception.parse_error.104 | parse error: JSON patch must be an array of objects | [RFC 6902](https://tools.ietf.org/html/rfc6902) requires a JSON Patch document to be a JSON document that represents an array of objects. -json.exception.parse_error.105 | parse error: operation must have string member 'op' | An operation of a JSON Patch document must contain exactly one "op" member, whose value indicates the operation to perform. Its value must be one of "add", "remove", "replace", "move", "copy", or "test"; other values are errors. -json.exception.parse_error.106 | parse error: array index '01' must not begin with '0' | An array index in a JSON Pointer ([RFC 6901](https://tools.ietf.org/html/rfc6901)) may be `0` or any number without a leading `0`. -json.exception.parse_error.107 | parse error: JSON pointer must be empty or begin with '/' - was: 'foo' | A JSON Pointer must be a Unicode string containing a sequence of zero or more reference tokens, each prefixed by a `/` character. -json.exception.parse_error.108 | parse error: escape character '~' must be followed with '0' or '1' | In a JSON Pointer, only `~0` and `~1` are valid escape sequences. -json.exception.parse_error.109 | parse error: array index 'one' is not a number | A JSON Pointer array index must be a number. -json.exception.parse_error.110 | parse error at 1: cannot read 2 bytes from vector | When parsing CBOR or MessagePack, the byte vector ends before the complete value has been read. -json.exception.parse_error.112 | parse error at 1: error reading CBOR; last byte: 0xF8 | Not all types of CBOR or MessagePack are supported. This exception occurs if an unsupported byte was read. -json.exception.parse_error.113 | parse error at 2: expected a CBOR string; last byte: 0x98 | While parsing a map key, a value that is not a string has been read. -json.exception.parse_error.114 | parse error: Unsupported BSON record type 0x0F | The parsing of the corresponding BSON record type is not implemented (yet). -json.exception.parse_error.115 | parse error at byte 5: syntax error while parsing UBJSON high-precision number: invalid number text: 1A | A UBJSON high-precision number could not be parsed. - -@note For an input with n bytes, 1 is the index of the first character and n+1 - is the index of the terminating null byte or the end of file. This also - holds true when reading a byte vector (CBOR or MessagePack). - -@liveexample{The following code shows how a `parse_error` exception can be -caught.,parse_error} - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref invalid_iterator for exceptions indicating errors with iterators -@sa - @ref type_error for exceptions indicating executing a member function with - a wrong type -@sa - @ref out_of_range for exceptions indicating access out of the defined range -@sa - @ref other_error for exceptions indicating other library errors - -@since version 3.0.0 -*/ -class parse_error : public exception -{ - public: - /*! - @brief create a parse error exception - @param[in] id_ the id of the exception - @param[in] pos the position where the error occurred (or with - chars_read_total=0 if the position cannot be - determined) - @param[in] what_arg the explanatory string - @return parse_error object - */ - template - static parse_error create(int id_, const position_t& pos, const std::string& what_arg, const BasicJsonType& context) - { - std::string w = exception::name("parse_error", id_) + "parse error" + - position_string(pos) + ": " + exception::diagnostics(context) + what_arg; - return parse_error(id_, pos.chars_read_total, w.c_str()); - } - - template - static parse_error create(int id_, std::size_t byte_, const std::string& what_arg, const BasicJsonType& context) - { - std::string w = exception::name("parse_error", id_) + "parse error" + - (byte_ != 0 ? (" at byte " + std::to_string(byte_)) : "") + - ": " + exception::diagnostics(context) + what_arg; - return parse_error(id_, byte_, w.c_str()); - } - - /*! - @brief byte index of the parse error - - The byte index of the last read character in the input file. - - @note For an input with n bytes, 1 is the index of the first character and - n+1 is the index of the terminating null byte or the end of file. - This also holds true when reading a byte vector (CBOR or MessagePack). - */ - const std::size_t byte; - - private: - parse_error(int id_, std::size_t byte_, const char* what_arg) - : exception(id_, what_arg), byte(byte_) {} - - static std::string position_string(const position_t& pos) - { - return " at line " + std::to_string(pos.lines_read + 1) + - ", column " + std::to_string(pos.chars_read_current_line); - } -}; - -/*! -@brief exception indicating errors with iterators - -This exception is thrown if iterators passed to a library function do not match -the expected semantics. - -Exceptions have ids 2xx. - -name / id | example message | description ------------------------------------ | --------------- | ------------------------- -json.exception.invalid_iterator.201 | iterators are not compatible | The iterators passed to constructor @ref basic_json(InputIT first, InputIT last) are not compatible, meaning they do not belong to the same container. Therefore, the range (@a first, @a last) is invalid. -json.exception.invalid_iterator.202 | iterator does not fit current value | In an erase or insert function, the passed iterator @a pos does not belong to the JSON value for which the function was called. It hence does not define a valid position for the deletion/insertion. -json.exception.invalid_iterator.203 | iterators do not fit current value | Either iterator passed to function @ref erase(IteratorType first, IteratorType last) does not belong to the JSON value from which values shall be erased. It hence does not define a valid range to delete values from. -json.exception.invalid_iterator.204 | iterators out of range | When an iterator range for a primitive type (number, boolean, or string) is passed to a constructor or an erase function, this range has to be exactly (@ref begin(), @ref end()), because this is the only way the single stored value is expressed. All other ranges are invalid. -json.exception.invalid_iterator.205 | iterator out of range | When an iterator for a primitive type (number, boolean, or string) is passed to an erase function, the iterator has to be the @ref begin() iterator, because it is the only way to address the stored value. All other iterators are invalid. -json.exception.invalid_iterator.206 | cannot construct with iterators from null | The iterators passed to constructor @ref basic_json(InputIT first, InputIT last) belong to a JSON null value and hence to not define a valid range. -json.exception.invalid_iterator.207 | cannot use key() for non-object iterators | The key() member function can only be used on iterators belonging to a JSON object, because other types do not have a concept of a key. -json.exception.invalid_iterator.208 | cannot use operator[] for object iterators | The operator[] to specify a concrete offset cannot be used on iterators belonging to a JSON object, because JSON objects are unordered. -json.exception.invalid_iterator.209 | cannot use offsets with object iterators | The offset operators (+, -, +=, -=) cannot be used on iterators belonging to a JSON object, because JSON objects are unordered. -json.exception.invalid_iterator.210 | iterators do not fit | The iterator range passed to the insert function are not compatible, meaning they do not belong to the same container. Therefore, the range (@a first, @a last) is invalid. -json.exception.invalid_iterator.211 | passed iterators may not belong to container | The iterator range passed to the insert function must not be a subrange of the container to insert to. -json.exception.invalid_iterator.212 | cannot compare iterators of different containers | When two iterators are compared, they must belong to the same container. -json.exception.invalid_iterator.213 | cannot compare order of object iterators | The order of object iterators cannot be compared, because JSON objects are unordered. -json.exception.invalid_iterator.214 | cannot get value | Cannot get value for iterator: Either the iterator belongs to a null value or it is an iterator to a primitive type (number, boolean, or string), but the iterator is different to @ref begin(). - -@liveexample{The following code shows how an `invalid_iterator` exception can be -caught.,invalid_iterator} - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref parse_error for exceptions indicating a parse error -@sa - @ref type_error for exceptions indicating executing a member function with - a wrong type -@sa - @ref out_of_range for exceptions indicating access out of the defined range -@sa - @ref other_error for exceptions indicating other library errors - -@since version 3.0.0 -*/ -class invalid_iterator : public exception -{ - public: - template - static invalid_iterator create(int id_, const std::string& what_arg, const BasicJsonType& context) - { - std::string w = exception::name("invalid_iterator", id_) + exception::diagnostics(context) + what_arg; - return invalid_iterator(id_, w.c_str()); - } - - private: - JSON_HEDLEY_NON_NULL(3) - invalid_iterator(int id_, const char* what_arg) - : exception(id_, what_arg) {} -}; - -/*! -@brief exception indicating executing a member function with a wrong type - -This exception is thrown in case of a type error; that is, a library function is -executed on a JSON value whose type does not match the expected semantics. - -Exceptions have ids 3xx. - -name / id | example message | description ------------------------------ | --------------- | ------------------------- -json.exception.type_error.301 | cannot create object from initializer list | To create an object from an initializer list, the initializer list must consist only of a list of pairs whose first element is a string. When this constraint is violated, an array is created instead. -json.exception.type_error.302 | type must be object, but is array | During implicit or explicit value conversion, the JSON type must be compatible to the target type. For instance, a JSON string can only be converted into string types, but not into numbers or boolean types. -json.exception.type_error.303 | incompatible ReferenceType for get_ref, actual type is object | To retrieve a reference to a value stored in a @ref basic_json object with @ref get_ref, the type of the reference must match the value type. For instance, for a JSON array, the @a ReferenceType must be @ref array_t &. -json.exception.type_error.304 | cannot use at() with string | The @ref at() member functions can only be executed for certain JSON types. -json.exception.type_error.305 | cannot use operator[] with string | The @ref operator[] member functions can only be executed for certain JSON types. -json.exception.type_error.306 | cannot use value() with string | The @ref value() member functions can only be executed for certain JSON types. -json.exception.type_error.307 | cannot use erase() with string | The @ref erase() member functions can only be executed for certain JSON types. -json.exception.type_error.308 | cannot use push_back() with string | The @ref push_back() and @ref operator+= member functions can only be executed for certain JSON types. -json.exception.type_error.309 | cannot use insert() with | The @ref insert() member functions can only be executed for certain JSON types. -json.exception.type_error.310 | cannot use swap() with number | The @ref swap() member functions can only be executed for certain JSON types. -json.exception.type_error.311 | cannot use emplace_back() with string | The @ref emplace_back() member function can only be executed for certain JSON types. -json.exception.type_error.312 | cannot use update() with string | The @ref update() member functions can only be executed for certain JSON types. -json.exception.type_error.313 | invalid value to unflatten | The @ref unflatten function converts an object whose keys are JSON Pointers back into an arbitrary nested JSON value. The JSON Pointers must not overlap, because then the resulting value would not be well defined. -json.exception.type_error.314 | only objects can be unflattened | The @ref unflatten function only works for an object whose keys are JSON Pointers. -json.exception.type_error.315 | values in object must be primitive | The @ref unflatten function only works for an object whose keys are JSON Pointers and whose values are primitive. -json.exception.type_error.316 | invalid UTF-8 byte at index 10: 0x7E | The @ref dump function only works with UTF-8 encoded strings; that is, if you assign a `std::string` to a JSON value, make sure it is UTF-8 encoded. | -json.exception.type_error.317 | JSON value cannot be serialized to requested format | The dynamic type of the object cannot be represented in the requested serialization format (e.g. a raw `true` or `null` JSON object cannot be serialized to BSON) | - -@liveexample{The following code shows how a `type_error` exception can be -caught.,type_error} - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref parse_error for exceptions indicating a parse error -@sa - @ref invalid_iterator for exceptions indicating errors with iterators -@sa - @ref out_of_range for exceptions indicating access out of the defined range -@sa - @ref other_error for exceptions indicating other library errors - -@since version 3.0.0 -*/ -class type_error : public exception -{ - public: - template - static type_error create(int id_, const std::string& what_arg, const BasicJsonType& context) - { - std::string w = exception::name("type_error", id_) + exception::diagnostics(context) + what_arg; - return type_error(id_, w.c_str()); - } - - private: - JSON_HEDLEY_NON_NULL(3) - type_error(int id_, const char* what_arg) : exception(id_, what_arg) {} -}; - -/*! -@brief exception indicating access out of the defined range - -This exception is thrown in case a library function is called on an input -parameter that exceeds the expected range, for instance in case of array -indices or nonexisting object keys. - -Exceptions have ids 4xx. - -name / id | example message | description -------------------------------- | --------------- | ------------------------- -json.exception.out_of_range.401 | array index 3 is out of range | The provided array index @a i is larger than @a size-1. -json.exception.out_of_range.402 | array index '-' (3) is out of range | The special array index `-` in a JSON Pointer never describes a valid element of the array, but the index past the end. That is, it can only be used to add elements at this position, but not to read it. -json.exception.out_of_range.403 | key 'foo' not found | The provided key was not found in the JSON object. -json.exception.out_of_range.404 | unresolved reference token 'foo' | A reference token in a JSON Pointer could not be resolved. -json.exception.out_of_range.405 | JSON pointer has no parent | The JSON Patch operations 'remove' and 'add' can not be applied to the root element of the JSON value. -json.exception.out_of_range.406 | number overflow parsing '10E1000' | A parsed number could not be stored as without changing it to NaN or INF. -json.exception.out_of_range.407 | number overflow serializing '9223372036854775808' | UBJSON and BSON only support integer numbers up to 9223372036854775807. (until version 3.8.0) | -json.exception.out_of_range.408 | excessive array size: 8658170730974374167 | The size (following `#`) of an UBJSON array or object exceeds the maximal capacity. | -json.exception.out_of_range.409 | BSON key cannot contain code point U+0000 (at byte 2) | Key identifiers to be serialized to BSON cannot contain code point U+0000, since the key is stored as zero-terminated c-string | - -@liveexample{The following code shows how an `out_of_range` exception can be -caught.,out_of_range} - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref parse_error for exceptions indicating a parse error -@sa - @ref invalid_iterator for exceptions indicating errors with iterators -@sa - @ref type_error for exceptions indicating executing a member function with - a wrong type -@sa - @ref other_error for exceptions indicating other library errors - -@since version 3.0.0 -*/ -class out_of_range : public exception -{ - public: - template - static out_of_range create(int id_, const std::string& what_arg, const BasicJsonType& context) - { - std::string w = exception::name("out_of_range", id_) + exception::diagnostics(context) + what_arg; - return out_of_range(id_, w.c_str()); - } - - private: - JSON_HEDLEY_NON_NULL(3) - out_of_range(int id_, const char* what_arg) : exception(id_, what_arg) {} -}; - -/*! -@brief exception indicating other library errors - -This exception is thrown in case of errors that cannot be classified with the -other exception types. - -Exceptions have ids 5xx. - -name / id | example message | description ------------------------------- | --------------- | ------------------------- -json.exception.other_error.501 | unsuccessful: {"op":"test","path":"/baz", "value":"bar"} | A JSON Patch operation 'test' failed. The unsuccessful operation is also printed. - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref parse_error for exceptions indicating a parse error -@sa - @ref invalid_iterator for exceptions indicating errors with iterators -@sa - @ref type_error for exceptions indicating executing a member function with - a wrong type -@sa - @ref out_of_range for exceptions indicating access out of the defined range - -@liveexample{The following code shows how an `other_error` exception can be -caught.,other_error} - -@since version 3.0.0 -*/ -class other_error : public exception -{ - public: - template - static other_error create(int id_, const std::string& what_arg, const BasicJsonType& context) - { - std::string w = exception::name("other_error", id_) + exception::diagnostics(context) + what_arg; - return other_error(id_, w.c_str()); - } - - private: - JSON_HEDLEY_NON_NULL(3) - other_error(int id_, const char* what_arg) : exception(id_, what_arg) {} -}; -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - - -#include // size_t -#include // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type -#include // index_sequence, make_index_sequence, index_sequence_for - -// #include - - -namespace nlohmann -{ -namespace detail -{ - -template -using uncvref_t = typename std::remove_cv::type>::type; - -#ifdef JSON_HAS_CPP_14 - -// the following utilities are natively available in C++14 -using std::enable_if_t; -using std::index_sequence; -using std::make_index_sequence; -using std::index_sequence_for; - -#else - -// alias templates to reduce boilerplate -template -using enable_if_t = typename std::enable_if::type; - -// source: https://stackoverflow.com/a/32223343 -template -struct index_sequence -{ - using type = index_sequence; - using value_type = std::size_t; - static constexpr std::size_t size() noexcept - { - return sizeof...(Ints); - } -}; - -template -struct merge_and_renumber; - -template -struct merge_and_renumber, index_sequence> - : index_sequence < I1..., (sizeof...(I1) + I2)... > {}; - -template -struct make_index_sequence - : merge_and_renumber < typename make_index_sequence < N / 2 >::type, - typename make_index_sequence < N - N / 2 >::type > {}; - -template<> struct make_index_sequence<0> : index_sequence<> {}; -template<> struct make_index_sequence<1> : index_sequence<0> {}; - -template -using index_sequence_for = make_index_sequence; - -#endif - -// dispatch utility (taken from ranges-v3) -template struct priority_tag : priority_tag < N - 1 > {}; -template<> struct priority_tag<0> {}; - -// taken from ranges-v3 -template -struct static_const -{ - static constexpr T value{}; -}; - -template -constexpr T static_const::value; - -} // namespace detail -} // namespace nlohmann - -// #include - - -#include // numeric_limits -#include // false_type, is_constructible, is_integral, is_same, true_type -#include // declval -#include // tuple - -// #include - - -#include // random_access_iterator_tag - -// #include - - -namespace nlohmann -{ -namespace detail -{ -template struct make_void -{ - using type = void; -}; -template using void_t = typename make_void::type; -} // namespace detail -} // namespace nlohmann - -// #include - - -namespace nlohmann -{ -namespace detail -{ -template -struct iterator_types {}; - -template -struct iterator_types < - It, - void_t> -{ - using difference_type = typename It::difference_type; - using value_type = typename It::value_type; - using pointer = typename It::pointer; - using reference = typename It::reference; - using iterator_category = typename It::iterator_category; -}; - -// This is required as some compilers implement std::iterator_traits in a way that -// doesn't work with SFINAE. See https://github.com/nlohmann/json/issues/1341. -template -struct iterator_traits -{ -}; - -template -struct iterator_traits < T, enable_if_t < !std::is_pointer::value >> - : iterator_types -{ -}; - -template -struct iterator_traits::value>> -{ - using iterator_category = std::random_access_iterator_tag; - using value_type = T; - using difference_type = ptrdiff_t; - using pointer = T*; - using reference = T&; -}; -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - -// #include - - -#include - -// #include - - -// https://en.cppreference.com/w/cpp/experimental/is_detected -namespace nlohmann -{ -namespace detail -{ -struct nonesuch -{ - nonesuch() = delete; - ~nonesuch() = delete; - nonesuch(nonesuch const&) = delete; - nonesuch(nonesuch const&&) = delete; - void operator=(nonesuch const&) = delete; - void operator=(nonesuch&&) = delete; -}; - -template class Op, - class... Args> -struct detector -{ - using value_t = std::false_type; - using type = Default; -}; - -template class Op, class... Args> -struct detector>, Op, Args...> -{ - using value_t = std::true_type; - using type = Op; -}; - -template class Op, class... Args> -using is_detected = typename detector::value_t; - -template class Op, class... Args> -using detected_t = typename detector::type; - -template class Op, class... Args> -using detected_or = detector; - -template class Op, class... Args> -using detected_or_t = typename detected_or::type; - -template class Op, class... Args> -using is_detected_exact = std::is_same>; - -template class Op, class... Args> -using is_detected_convertible = - std::is_convertible, To>; -} // namespace detail -} // namespace nlohmann - -// #include -#ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_ -#define INCLUDE_NLOHMANN_JSON_FWD_HPP_ - -#include // int64_t, uint64_t -#include // map -#include // allocator -#include // string -#include // vector - -/*! -@brief namespace for Niels Lohmann -@see https://github.com/nlohmann -@since version 1.0.0 -*/ -namespace nlohmann -{ -/*! -@brief default JSONSerializer template argument - -This serializer ignores the template arguments and uses ADL -([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl)) -for serialization. -*/ -template -struct adl_serializer; - -template class ObjectType = - std::map, - template class ArrayType = std::vector, - class StringType = std::string, class BooleanType = bool, - class NumberIntegerType = std::int64_t, - class NumberUnsignedType = std::uint64_t, - class NumberFloatType = double, - template class AllocatorType = std::allocator, - template class JSONSerializer = - adl_serializer, - class BinaryType = std::vector> -class basic_json; - -/*! -@brief JSON Pointer - -A JSON pointer defines a string syntax for identifying a specific value -within a JSON document. It can be used with functions `at` and -`operator[]`. Furthermore, JSON pointers are the base for JSON patches. - -@sa [RFC 6901](https://tools.ietf.org/html/rfc6901) - -@since version 2.0.0 -*/ -template -class json_pointer; - -/*! -@brief default JSON class - -This type is the default specialization of the @ref basic_json class which -uses the standard template types. - -@since version 1.0.0 -*/ -using json = basic_json<>; - -template -struct ordered_map; - -/*! -@brief ordered JSON class - -This type preserves the insertion order of object keys. - -@since version 3.9.0 -*/ -using ordered_json = basic_json; - -} // namespace nlohmann - -#endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_ - - -namespace nlohmann -{ -/*! -@brief detail namespace with internal helper functions - -This namespace collects functions that should not be exposed, -implementations of some @ref basic_json methods, and meta-programming helpers. - -@since version 2.1.0 -*/ -namespace detail -{ -///////////// -// helpers // -///////////// - -// Note to maintainers: -// -// Every trait in this file expects a non CV-qualified type. -// The only exceptions are in the 'aliases for detected' section -// (i.e. those of the form: decltype(T::member_function(std::declval()))) -// -// In this case, T has to be properly CV-qualified to constraint the function arguments -// (e.g. to_json(BasicJsonType&, const T&)) - -template struct is_basic_json : std::false_type {}; - -NLOHMANN_BASIC_JSON_TPL_DECLARATION -struct is_basic_json : std::true_type {}; - -////////////////////// -// json_ref helpers // -////////////////////// - -template -class json_ref; - -template -struct is_json_ref : std::false_type {}; - -template -struct is_json_ref> : std::true_type {}; - -////////////////////////// -// aliases for detected // -////////////////////////// - -template -using mapped_type_t = typename T::mapped_type; - -template -using key_type_t = typename T::key_type; - -template -using value_type_t = typename T::value_type; - -template -using difference_type_t = typename T::difference_type; - -template -using pointer_t = typename T::pointer; - -template -using reference_t = typename T::reference; - -template -using iterator_category_t = typename T::iterator_category; - -template -using iterator_t = typename T::iterator; - -template -using to_json_function = decltype(T::to_json(std::declval()...)); - -template -using from_json_function = decltype(T::from_json(std::declval()...)); - -template -using get_template_function = decltype(std::declval().template get()); - -// trait checking if JSONSerializer::from_json(json const&, udt&) exists -template -struct has_from_json : std::false_type {}; - -// trait checking if j.get is valid -// use this trait instead of std::is_constructible or std::is_convertible, -// both rely on, or make use of implicit conversions, and thus fail when T -// has several constructors/operator= (see https://github.com/nlohmann/json/issues/958) -template -struct is_getable -{ - static constexpr bool value = is_detected::value; -}; - -template -struct has_from_json < BasicJsonType, T, - enable_if_t < !is_basic_json::value >> -{ - using serializer = typename BasicJsonType::template json_serializer; - - static constexpr bool value = - is_detected_exact::value; -}; - -// This trait checks if JSONSerializer::from_json(json const&) exists -// this overload is used for non-default-constructible user-defined-types -template -struct has_non_default_from_json : std::false_type {}; - -template -struct has_non_default_from_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> -{ - using serializer = typename BasicJsonType::template json_serializer; - - static constexpr bool value = - is_detected_exact::value; -}; - -// This trait checks if BasicJsonType::json_serializer::to_json exists -// Do not evaluate the trait when T is a basic_json type, to avoid template instantiation infinite recursion. -template -struct has_to_json : std::false_type {}; - -template -struct has_to_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> -{ - using serializer = typename BasicJsonType::template json_serializer; - - static constexpr bool value = - is_detected_exact::value; -}; - - -/////////////////// -// is_ functions // -/////////////////// - -template -struct is_iterator_traits : std::false_type {}; - -template -struct is_iterator_traits> -{ - private: - using traits = iterator_traits; - - public: - static constexpr auto value = - is_detected::value && - is_detected::value && - is_detected::value && - is_detected::value && - is_detected::value; -}; - -// The following implementation of is_complete_type is taken from -// https://blogs.msdn.microsoft.com/vcblog/2015/12/02/partial-support-for-expression-sfinae-in-vs-2015-update-1/ -// and is written by Xiang Fan who agreed to using it in this library. - -template -struct is_complete_type : std::false_type {}; - -template -struct is_complete_type : std::true_type {}; - -template -struct is_compatible_object_type_impl : std::false_type {}; - -template -struct is_compatible_object_type_impl < - BasicJsonType, CompatibleObjectType, - enable_if_t < is_detected::value&& - is_detected::value >> -{ - using object_t = typename BasicJsonType::object_t; - - // macOS's is_constructible does not play well with nonesuch... - static constexpr bool value = - std::is_constructible::value && - std::is_constructible::value; -}; - -template -struct is_compatible_object_type - : is_compatible_object_type_impl {}; - -template -struct is_constructible_object_type_impl : std::false_type {}; - -template -struct is_constructible_object_type_impl < - BasicJsonType, ConstructibleObjectType, - enable_if_t < is_detected::value&& - is_detected::value >> -{ - using object_t = typename BasicJsonType::object_t; - - static constexpr bool value = - (std::is_default_constructible::value && - (std::is_move_assignable::value || - std::is_copy_assignable::value) && - (std::is_constructible::value && - std::is_same < - typename object_t::mapped_type, - typename ConstructibleObjectType::mapped_type >::value)) || - (has_from_json::value || - has_non_default_from_json < - BasicJsonType, - typename ConstructibleObjectType::mapped_type >::value); -}; - -template -struct is_constructible_object_type - : is_constructible_object_type_impl {}; - -template -struct is_compatible_string_type_impl : std::false_type {}; - -template -struct is_compatible_string_type_impl < - BasicJsonType, CompatibleStringType, - enable_if_t::value >> -{ - static constexpr auto value = - std::is_constructible::value; -}; - -template -struct is_compatible_string_type - : is_compatible_string_type_impl {}; - -template -struct is_constructible_string_type_impl : std::false_type {}; - -template -struct is_constructible_string_type_impl < - BasicJsonType, ConstructibleStringType, - enable_if_t::value >> -{ - static constexpr auto value = - std::is_constructible::value; -}; - -template -struct is_constructible_string_type - : is_constructible_string_type_impl {}; - -template -struct is_compatible_array_type_impl : std::false_type {}; - -template -struct is_compatible_array_type_impl < - BasicJsonType, CompatibleArrayType, - enable_if_t < is_detected::value&& - is_detected::value&& -// This is needed because json_reverse_iterator has a ::iterator type... -// Therefore it is detected as a CompatibleArrayType. -// The real fix would be to have an Iterable concept. - !is_iterator_traits < - iterator_traits>::value >> -{ - static constexpr bool value = - std::is_constructible::value; -}; - -template -struct is_compatible_array_type - : is_compatible_array_type_impl {}; - -template -struct is_constructible_array_type_impl : std::false_type {}; - -template -struct is_constructible_array_type_impl < - BasicJsonType, ConstructibleArrayType, - enable_if_t::value >> - : std::true_type {}; - -template -struct is_constructible_array_type_impl < - BasicJsonType, ConstructibleArrayType, - enable_if_t < !std::is_same::value&& - std::is_default_constructible::value&& -(std::is_move_assignable::value || - std::is_copy_assignable::value)&& -is_detected::value&& -is_detected::value&& -is_complete_type < -detected_t>::value >> -{ - static constexpr bool value = - // This is needed because json_reverse_iterator has a ::iterator type, - // furthermore, std::back_insert_iterator (and other iterators) have a - // base class `iterator`... Therefore it is detected as a - // ConstructibleArrayType. The real fix would be to have an Iterable - // concept. - !is_iterator_traits>::value && - - (std::is_same::value || - has_from_json::value || - has_non_default_from_json < - BasicJsonType, typename ConstructibleArrayType::value_type >::value); -}; - -template -struct is_constructible_array_type - : is_constructible_array_type_impl {}; - -template -struct is_compatible_integer_type_impl : std::false_type {}; - -template -struct is_compatible_integer_type_impl < - RealIntegerType, CompatibleNumberIntegerType, - enable_if_t < std::is_integral::value&& - std::is_integral::value&& - !std::is_same::value >> -{ - // is there an assert somewhere on overflows? - using RealLimits = std::numeric_limits; - using CompatibleLimits = std::numeric_limits; - - static constexpr auto value = - std::is_constructible::value && - CompatibleLimits::is_integer && - RealLimits::is_signed == CompatibleLimits::is_signed; -}; - -template -struct is_compatible_integer_type - : is_compatible_integer_type_impl {}; - -template -struct is_compatible_type_impl: std::false_type {}; - -template -struct is_compatible_type_impl < - BasicJsonType, CompatibleType, - enable_if_t::value >> -{ - static constexpr bool value = - has_to_json::value; -}; - -template -struct is_compatible_type - : is_compatible_type_impl {}; - -// https://en.cppreference.com/w/cpp/types/conjunction -template struct conjunction : std::true_type { }; -template struct conjunction : B1 { }; -template -struct conjunction -: std::conditional, B1>::type {}; - -template -struct is_constructible_tuple : std::false_type {}; - -template -struct is_constructible_tuple> : conjunction...> {}; -} // namespace detail -} // namespace nlohmann - -// #include - - -namespace nlohmann -{ -namespace detail -{ -template -void from_json(const BasicJsonType& j, typename std::nullptr_t& n) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_null())) - { - JSON_THROW(type_error::create(302, "type must be null, but is " + std::string(j.type_name()), j)); - } - n = nullptr; -} - -// overloads for basic_json template parameters -template < typename BasicJsonType, typename ArithmeticType, - enable_if_t < std::is_arithmetic::value&& - !std::is_same::value, - int > = 0 > -void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val) -{ - switch (static_cast(j)) - { - case value_t::number_unsigned: - { - val = static_cast(*j.template get_ptr()); - break; - } - case value_t::number_integer: - { - val = static_cast(*j.template get_ptr()); - break; - } - case value_t::number_float: - { - val = static_cast(*j.template get_ptr()); - break; - } - - default: - JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name()), j)); - } -} - -template -void from_json(const BasicJsonType& j, typename BasicJsonType::boolean_t& b) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_boolean())) - { - JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(j.type_name()), j)); - } - b = *j.template get_ptr(); -} - -template -void from_json(const BasicJsonType& j, typename BasicJsonType::string_t& s) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_string())) - { - JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()), j)); - } - s = *j.template get_ptr(); -} - -template < - typename BasicJsonType, typename ConstructibleStringType, - enable_if_t < - is_constructible_string_type::value&& - !std::is_same::value, - int > = 0 > -void from_json(const BasicJsonType& j, ConstructibleStringType& s) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_string())) - { - JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name()), j)); - } - - s = *j.template get_ptr(); -} - -template -void from_json(const BasicJsonType& j, typename BasicJsonType::number_float_t& val) -{ - get_arithmetic_value(j, val); -} - -template -void from_json(const BasicJsonType& j, typename BasicJsonType::number_unsigned_t& val) -{ - get_arithmetic_value(j, val); -} - -template -void from_json(const BasicJsonType& j, typename BasicJsonType::number_integer_t& val) -{ - get_arithmetic_value(j, val); -} - -template::value, int> = 0> -void from_json(const BasicJsonType& j, EnumType& e) -{ - typename std::underlying_type::type val; - get_arithmetic_value(j, val); - e = static_cast(val); -} - -// forward_list doesn't have an insert method -template::value, int> = 0> -void from_json(const BasicJsonType& j, std::forward_list& l) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_array())) - { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j)); - } - l.clear(); - std::transform(j.rbegin(), j.rend(), - std::front_inserter(l), [](const BasicJsonType & i) - { - return i.template get(); - }); -} - -// valarray doesn't have an insert method -template::value, int> = 0> -void from_json(const BasicJsonType& j, std::valarray& l) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_array())) - { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j)); - } - l.resize(j.size()); - std::transform(j.begin(), j.end(), std::begin(l), - [](const BasicJsonType & elem) - { - return elem.template get(); - }); -} - -template -auto from_json(const BasicJsonType& j, T (&arr)[N]) --> decltype(j.template get(), void()) -{ - for (std::size_t i = 0; i < N; ++i) - { - arr[i] = j.at(i).template get(); - } -} - -template -void from_json_array_impl(const BasicJsonType& j, typename BasicJsonType::array_t& arr, priority_tag<3> /*unused*/) -{ - arr = *j.template get_ptr(); -} - -template -auto from_json_array_impl(const BasicJsonType& j, std::array& arr, - priority_tag<2> /*unused*/) --> decltype(j.template get(), void()) -{ - for (std::size_t i = 0; i < N; ++i) - { - arr[i] = j.at(i).template get(); - } -} - -template -auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, priority_tag<1> /*unused*/) --> decltype( - arr.reserve(std::declval()), - j.template get(), - void()) -{ - using std::end; - - ConstructibleArrayType ret; - ret.reserve(j.size()); - std::transform(j.begin(), j.end(), - std::inserter(ret, end(ret)), [](const BasicJsonType & i) - { - // get() returns *this, this won't call a from_json - // method when value_type is BasicJsonType - return i.template get(); - }); - arr = std::move(ret); -} - -template -void from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, - priority_tag<0> /*unused*/) -{ - using std::end; - - ConstructibleArrayType ret; - std::transform( - j.begin(), j.end(), std::inserter(ret, end(ret)), - [](const BasicJsonType & i) - { - // get() returns *this, this won't call a from_json - // method when value_type is BasicJsonType - return i.template get(); - }); - arr = std::move(ret); -} - -template < typename BasicJsonType, typename ConstructibleArrayType, - enable_if_t < - is_constructible_array_type::value&& - !is_constructible_object_type::value&& - !is_constructible_string_type::value&& - !std::is_same::value&& - !is_basic_json::value, - int > = 0 > -auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr) --> decltype(from_json_array_impl(j, arr, priority_tag<3> {}), -j.template get(), -void()) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_array())) - { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j)); - } - - from_json_array_impl(j, arr, priority_tag<3> {}); -} - -template -void from_json(const BasicJsonType& j, typename BasicJsonType::binary_t& bin) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_binary())) - { - JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(j.type_name()), j)); - } - - bin = *j.template get_ptr(); -} - -template::value, int> = 0> -void from_json(const BasicJsonType& j, ConstructibleObjectType& obj) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_object())) - { - JSON_THROW(type_error::create(302, "type must be object, but is " + std::string(j.type_name()), j)); - } - - ConstructibleObjectType ret; - auto inner_object = j.template get_ptr(); - using value_type = typename ConstructibleObjectType::value_type; - std::transform( - inner_object->begin(), inner_object->end(), - std::inserter(ret, ret.begin()), - [](typename BasicJsonType::object_t::value_type const & p) - { - return value_type(p.first, p.second.template get()); - }); - obj = std::move(ret); -} - -// overload for arithmetic types, not chosen for basic_json template arguments -// (BooleanType, etc..); note: Is it really necessary to provide explicit -// overloads for boolean_t etc. in case of a custom BooleanType which is not -// an arithmetic type? -template < typename BasicJsonType, typename ArithmeticType, - enable_if_t < - std::is_arithmetic::value&& - !std::is_same::value&& - !std::is_same::value&& - !std::is_same::value&& - !std::is_same::value, - int > = 0 > -void from_json(const BasicJsonType& j, ArithmeticType& val) -{ - switch (static_cast(j)) - { - case value_t::number_unsigned: - { - val = static_cast(*j.template get_ptr()); - break; - } - case value_t::number_integer: - { - val = static_cast(*j.template get_ptr()); - break; - } - case value_t::number_float: - { - val = static_cast(*j.template get_ptr()); - break; - } - case value_t::boolean: - { - val = static_cast(*j.template get_ptr()); - break; - } - - default: - JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name()), j)); - } -} - -template -void from_json(const BasicJsonType& j, std::pair& p) -{ - p = {j.at(0).template get(), j.at(1).template get()}; -} - -template -void from_json_tuple_impl(const BasicJsonType& j, Tuple& t, index_sequence /*unused*/) -{ - t = std::make_tuple(j.at(Idx).template get::type>()...); -} - -template -void from_json(const BasicJsonType& j, std::tuple& t) -{ - from_json_tuple_impl(j, t, index_sequence_for {}); -} - -template < typename BasicJsonType, typename Key, typename Value, typename Compare, typename Allocator, - typename = enable_if_t < !std::is_constructible < - typename BasicJsonType::string_t, Key >::value >> -void from_json(const BasicJsonType& j, std::map& m) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_array())) - { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j)); - } - m.clear(); - for (const auto& p : j) - { - if (JSON_HEDLEY_UNLIKELY(!p.is_array())) - { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()), j)); - } - m.emplace(p.at(0).template get(), p.at(1).template get()); - } -} - -template < typename BasicJsonType, typename Key, typename Value, typename Hash, typename KeyEqual, typename Allocator, - typename = enable_if_t < !std::is_constructible < - typename BasicJsonType::string_t, Key >::value >> -void from_json(const BasicJsonType& j, std::unordered_map& m) -{ - if (JSON_HEDLEY_UNLIKELY(!j.is_array())) - { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name()), j)); - } - m.clear(); - for (const auto& p : j) - { - if (JSON_HEDLEY_UNLIKELY(!p.is_array())) - { - JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name()), j)); - } - m.emplace(p.at(0).template get(), p.at(1).template get()); - } -} - -struct from_json_fn -{ - template - auto operator()(const BasicJsonType& j, T& val) const - noexcept(noexcept(from_json(j, val))) - -> decltype(from_json(j, val), void()) - { - return from_json(j, val); - } -}; -} // namespace detail - -/// namespace to hold default `from_json` function -/// to see why this is required: -/// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4381.html -namespace -{ -constexpr const auto& from_json = detail::static_const::value; -} // namespace -} // namespace nlohmann - -// #include - - -#include // copy -#include // begin, end -#include // string -#include // tuple, get -#include // is_same, is_constructible, is_floating_point, is_enum, underlying_type -#include // move, forward, declval, pair -#include // valarray -#include // vector - -// #include - - -#include // size_t -#include // input_iterator_tag -#include // string, to_string -#include // tuple_size, get, tuple_element - -// #include - -// #include - - -namespace nlohmann -{ -namespace detail -{ -template -void int_to_string( string_type& target, std::size_t value ) -{ - // For ADL - using std::to_string; - target = to_string(value); -} -template class iteration_proxy_value -{ - public: - using difference_type = std::ptrdiff_t; - using value_type = iteration_proxy_value; - using pointer = value_type * ; - using reference = value_type & ; - using iterator_category = std::input_iterator_tag; - using string_type = typename std::remove_cv< typename std::remove_reference().key() ) >::type >::type; - - private: - /// the iterator - IteratorType anchor; - /// an index for arrays (used to create key names) - std::size_t array_index = 0; - /// last stringified array index - mutable std::size_t array_index_last = 0; - /// a string representation of the array index - mutable string_type array_index_str = "0"; - /// an empty string (to return a reference for primitive values) - const string_type empty_str{}; - - public: - explicit iteration_proxy_value(IteratorType it) noexcept : anchor(it) {} - - /// dereference operator (needed for range-based for) - iteration_proxy_value& operator*() - { - return *this; - } - - /// increment operator (needed for range-based for) - iteration_proxy_value& operator++() - { - ++anchor; - ++array_index; - - return *this; - } - - /// equality operator (needed for InputIterator) - bool operator==(const iteration_proxy_value& o) const - { - return anchor == o.anchor; - } - - /// inequality operator (needed for range-based for) - bool operator!=(const iteration_proxy_value& o) const - { - return anchor != o.anchor; - } - - /// return key of the iterator - const string_type& key() const - { - JSON_ASSERT(anchor.m_object != nullptr); - - switch (anchor.m_object->type()) - { - // use integer array index as key - case value_t::array: - { - if (array_index != array_index_last) - { - int_to_string( array_index_str, array_index ); - array_index_last = array_index; - } - return array_index_str; - } - - // use key from the object - case value_t::object: - return anchor.key(); - - // use an empty key for all primitive types - default: - return empty_str; - } - } - - /// return value of the iterator - typename IteratorType::reference value() const - { - return anchor.value(); - } -}; - -/// proxy class for the items() function -template class iteration_proxy -{ - private: - /// the container to iterate - typename IteratorType::reference container; - - public: - /// construct iteration proxy from a container - explicit iteration_proxy(typename IteratorType::reference cont) noexcept - : container(cont) {} - - /// return iterator begin (needed for range-based for) - iteration_proxy_value begin() noexcept - { - return iteration_proxy_value(container.begin()); - } - - /// return iterator end (needed for range-based for) - iteration_proxy_value end() noexcept - { - return iteration_proxy_value(container.end()); - } -}; -// Structured Bindings Support -// For further reference see https://blog.tartanllama.xyz/structured-bindings/ -// And see https://github.com/nlohmann/json/pull/1391 -template = 0> -auto get(const nlohmann::detail::iteration_proxy_value& i) -> decltype(i.key()) -{ - return i.key(); -} -// Structured Bindings Support -// For further reference see https://blog.tartanllama.xyz/structured-bindings/ -// And see https://github.com/nlohmann/json/pull/1391 -template = 0> -auto get(const nlohmann::detail::iteration_proxy_value& i) -> decltype(i.value()) -{ - return i.value(); -} -} // namespace detail -} // namespace nlohmann - -// The Addition to the STD Namespace is required to add -// Structured Bindings Support to the iteration_proxy_value class -// For further reference see https://blog.tartanllama.xyz/structured-bindings/ -// And see https://github.com/nlohmann/json/pull/1391 -namespace std -{ -#if defined(__clang__) - // Fix: https://github.com/nlohmann/json/issues/1401 - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wmismatched-tags" -#endif -template -class tuple_size<::nlohmann::detail::iteration_proxy_value> - : public std::integral_constant {}; - -template -class tuple_element> -{ - public: - using type = decltype( - get(std::declval < - ::nlohmann::detail::iteration_proxy_value> ())); -}; -#if defined(__clang__) - #pragma clang diagnostic pop -#endif -} // namespace std - -// #include - -// #include - -// #include - - -namespace nlohmann -{ -namespace detail -{ -////////////////// -// constructors // -////////////////// - -template struct external_constructor; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, typename BasicJsonType::boolean_t b) noexcept - { - j.m_type = value_t::boolean; - j.m_value = b; - j.assert_invariant(); - } -}; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, const typename BasicJsonType::string_t& s) - { - j.m_type = value_t::string; - j.m_value = s; - j.assert_invariant(); - } - - template - static void construct(BasicJsonType& j, typename BasicJsonType::string_t&& s) - { - j.m_type = value_t::string; - j.m_value = std::move(s); - j.assert_invariant(); - } - - template < typename BasicJsonType, typename CompatibleStringType, - enable_if_t < !std::is_same::value, - int > = 0 > - static void construct(BasicJsonType& j, const CompatibleStringType& str) - { - j.m_type = value_t::string; - j.m_value.string = j.template create(str); - j.assert_invariant(); - } -}; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, const typename BasicJsonType::binary_t& b) - { - j.m_type = value_t::binary; - typename BasicJsonType::binary_t value{b}; - j.m_value = value; - j.assert_invariant(); - } - - template - static void construct(BasicJsonType& j, typename BasicJsonType::binary_t&& b) - { - j.m_type = value_t::binary; - typename BasicJsonType::binary_t value{std::move(b)}; - j.m_value = value; - j.assert_invariant(); - } -}; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, typename BasicJsonType::number_float_t val) noexcept - { - j.m_type = value_t::number_float; - j.m_value = val; - j.assert_invariant(); - } -}; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, typename BasicJsonType::number_unsigned_t val) noexcept - { - j.m_type = value_t::number_unsigned; - j.m_value = val; - j.assert_invariant(); - } -}; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, typename BasicJsonType::number_integer_t val) noexcept - { - j.m_type = value_t::number_integer; - j.m_value = val; - j.assert_invariant(); - } -}; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, const typename BasicJsonType::array_t& arr) - { - j.m_type = value_t::array; - j.m_value = arr; - j.set_parents(); - j.assert_invariant(); - } - - template - static void construct(BasicJsonType& j, typename BasicJsonType::array_t&& arr) - { - j.m_type = value_t::array; - j.m_value = std::move(arr); - j.set_parents(); - j.assert_invariant(); - } - - template < typename BasicJsonType, typename CompatibleArrayType, - enable_if_t < !std::is_same::value, - int > = 0 > - static void construct(BasicJsonType& j, const CompatibleArrayType& arr) - { - using std::begin; - using std::end; - j.m_type = value_t::array; - j.m_value.array = j.template create(begin(arr), end(arr)); - j.set_parents(); - j.assert_invariant(); - } - - template - static void construct(BasicJsonType& j, const std::vector& arr) - { - j.m_type = value_t::array; - j.m_value = value_t::array; - j.m_value.array->reserve(arr.size()); - for (const bool x : arr) - { - j.m_value.array->push_back(x); - j.set_parent(j.m_value.array->back()); - } - j.assert_invariant(); - } - - template::value, int> = 0> - static void construct(BasicJsonType& j, const std::valarray& arr) - { - j.m_type = value_t::array; - j.m_value = value_t::array; - j.m_value.array->resize(arr.size()); - if (arr.size() > 0) - { - std::copy(std::begin(arr), std::end(arr), j.m_value.array->begin()); - } - j.set_parents(); - j.assert_invariant(); - } -}; - -template<> -struct external_constructor -{ - template - static void construct(BasicJsonType& j, const typename BasicJsonType::object_t& obj) - { - j.m_type = value_t::object; - j.m_value = obj; - j.set_parents(); - j.assert_invariant(); - } - - template - static void construct(BasicJsonType& j, typename BasicJsonType::object_t&& obj) - { - j.m_type = value_t::object; - j.m_value = std::move(obj); - j.set_parents(); - j.assert_invariant(); - } - - template < typename BasicJsonType, typename CompatibleObjectType, - enable_if_t < !std::is_same::value, int > = 0 > - static void construct(BasicJsonType& j, const CompatibleObjectType& obj) - { - using std::begin; - using std::end; - - j.m_type = value_t::object; - j.m_value.object = j.template create(begin(obj), end(obj)); - j.set_parents(); - j.assert_invariant(); - } -}; - -///////////// -// to_json // -///////////// - -template::value, int> = 0> -void to_json(BasicJsonType& j, T b) noexcept -{ - external_constructor::construct(j, b); -} - -template::value, int> = 0> -void to_json(BasicJsonType& j, const CompatibleString& s) -{ - external_constructor::construct(j, s); -} - -template -void to_json(BasicJsonType& j, typename BasicJsonType::string_t&& s) -{ - external_constructor::construct(j, std::move(s)); -} - -template::value, int> = 0> -void to_json(BasicJsonType& j, FloatType val) noexcept -{ - external_constructor::construct(j, static_cast(val)); -} - -template::value, int> = 0> -void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept -{ - external_constructor::construct(j, static_cast(val)); -} - -template::value, int> = 0> -void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept -{ - external_constructor::construct(j, static_cast(val)); -} - -template::value, int> = 0> -void to_json(BasicJsonType& j, EnumType e) noexcept -{ - using underlying_type = typename std::underlying_type::type; - external_constructor::construct(j, static_cast(e)); -} - -template -void to_json(BasicJsonType& j, const std::vector& e) -{ - external_constructor::construct(j, e); -} - -template < typename BasicJsonType, typename CompatibleArrayType, - enable_if_t < is_compatible_array_type::value&& - !is_compatible_object_type::value&& - !is_compatible_string_type::value&& - !std::is_same::value&& - !is_basic_json::value, - int > = 0 > -void to_json(BasicJsonType& j, const CompatibleArrayType& arr) -{ - external_constructor::construct(j, arr); -} - -template -void to_json(BasicJsonType& j, const typename BasicJsonType::binary_t& bin) -{ - external_constructor::construct(j, bin); -} - -template::value, int> = 0> -void to_json(BasicJsonType& j, const std::valarray& arr) -{ - external_constructor::construct(j, std::move(arr)); -} - -template -void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr) -{ - external_constructor::construct(j, std::move(arr)); -} - -template < typename BasicJsonType, typename CompatibleObjectType, - enable_if_t < is_compatible_object_type::value&& !is_basic_json::value, int > = 0 > -void to_json(BasicJsonType& j, const CompatibleObjectType& obj) -{ - external_constructor::construct(j, obj); -} - -template -void to_json(BasicJsonType& j, typename BasicJsonType::object_t&& obj) -{ - external_constructor::construct(j, std::move(obj)); -} - -template < - typename BasicJsonType, typename T, std::size_t N, - enable_if_t < !std::is_constructible::value, - int > = 0 > -void to_json(BasicJsonType& j, const T(&arr)[N]) -{ - external_constructor::construct(j, arr); -} - -template < typename BasicJsonType, typename T1, typename T2, enable_if_t < std::is_constructible::value&& std::is_constructible::value, int > = 0 > -void to_json(BasicJsonType& j, const std::pair& p) -{ - j = { p.first, p.second }; -} - -// for https://github.com/nlohmann/json/pull/1134 -template>::value, int> = 0> -void to_json(BasicJsonType& j, const T& b) -{ - j = { {b.key(), b.value()} }; -} - -template -void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence /*unused*/) -{ - j = { std::get(t)... }; -} - -template::value, int > = 0> -void to_json(BasicJsonType& j, const T& t) -{ - to_json_tuple_impl(j, t, make_index_sequence::value> {}); -} - -struct to_json_fn -{ - template - auto operator()(BasicJsonType& j, T&& val) const noexcept(noexcept(to_json(j, std::forward(val)))) - -> decltype(to_json(j, std::forward(val)), void()) - { - return to_json(j, std::forward(val)); - } -}; -} // namespace detail - -/// namespace to hold default `to_json` function -namespace -{ -constexpr const auto& to_json = detail::static_const::value; -} // namespace -} // namespace nlohmann - - -namespace nlohmann -{ - -template -struct adl_serializer -{ - /*! - @brief convert a JSON value to any value type - - This function is usually called by the `get()` function of the - @ref basic_json class (either explicit or via conversion operators). - - @param[in] j JSON value to read from - @param[in,out] val value to write to - */ - template - static auto from_json(BasicJsonType&& j, ValueType& val) noexcept( - noexcept(::nlohmann::from_json(std::forward(j), val))) - -> decltype(::nlohmann::from_json(std::forward(j), val), void()) - { - ::nlohmann::from_json(std::forward(j), val); - } - - /*! - @brief convert any value type to a JSON value - - This function is usually called by the constructors of the @ref basic_json - class. - - @param[in,out] j JSON value to write to - @param[in] val value to read from - */ - template - static auto to_json(BasicJsonType& j, ValueType&& val) noexcept( - noexcept(::nlohmann::to_json(j, std::forward(val)))) - -> decltype(::nlohmann::to_json(j, std::forward(val)), void()) - { - ::nlohmann::to_json(j, std::forward(val)); - } -}; - -} // namespace nlohmann - -// #include - - -#include // uint8_t -#include // tie -#include // move - -namespace nlohmann -{ - -/*! -@brief an internal type for a backed binary type - -This type extends the template parameter @a BinaryType provided to `basic_json` -with a subtype used by BSON and MessagePack. This type exists so that the user -does not have to specify a type themselves with a specific naming scheme in -order to override the binary type. - -@tparam BinaryType container to store bytes (`std::vector` by - default) - -@since version 3.8.0 -*/ -template -class byte_container_with_subtype : public BinaryType -{ - public: - /// the type of the underlying container - using container_type = BinaryType; - - byte_container_with_subtype() noexcept(noexcept(container_type())) - : container_type() - {} - - byte_container_with_subtype(const container_type& b) noexcept(noexcept(container_type(b))) - : container_type(b) - {} - - byte_container_with_subtype(container_type&& b) noexcept(noexcept(container_type(std::move(b)))) - : container_type(std::move(b)) - {} - - byte_container_with_subtype(const container_type& b, std::uint8_t subtype_) noexcept(noexcept(container_type(b))) - : container_type(b) - , m_subtype(subtype_) - , m_has_subtype(true) - {} - - byte_container_with_subtype(container_type&& b, std::uint8_t subtype_) noexcept(noexcept(container_type(std::move(b)))) - : container_type(std::move(b)) - , m_subtype(subtype_) - , m_has_subtype(true) - {} - - bool operator==(const byte_container_with_subtype& rhs) const - { - return std::tie(static_cast(*this), m_subtype, m_has_subtype) == - std::tie(static_cast(rhs), rhs.m_subtype, rhs.m_has_subtype); - } - - bool operator!=(const byte_container_with_subtype& rhs) const - { - return !(rhs == *this); - } - - /*! - @brief sets the binary subtype - - Sets the binary subtype of the value, also flags a binary JSON value as - having a subtype, which has implications for serialization. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @sa @ref subtype() -- return the binary subtype - @sa @ref clear_subtype() -- clears the binary subtype - @sa @ref has_subtype() -- returns whether or not the binary value has a - subtype - - @since version 3.8.0 - */ - void set_subtype(std::uint8_t subtype_) noexcept - { - m_subtype = subtype_; - m_has_subtype = true; - } - - /*! - @brief return the binary subtype - - Returns the numerical subtype of the value if it has a subtype. If it does - not have a subtype, this function will return size_t(-1) as a sentinel - value. - - @return the numerical subtype of the binary value - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @sa @ref set_subtype() -- sets the binary subtype - @sa @ref clear_subtype() -- clears the binary subtype - @sa @ref has_subtype() -- returns whether or not the binary value has a - subtype - - @since version 3.8.0 - */ - constexpr std::uint8_t subtype() const noexcept - { - return m_subtype; - } - - /*! - @brief return whether the value has a subtype - - @return whether the value has a subtype - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @sa @ref subtype() -- return the binary subtype - @sa @ref set_subtype() -- sets the binary subtype - @sa @ref clear_subtype() -- clears the binary subtype - - @since version 3.8.0 - */ - constexpr bool has_subtype() const noexcept - { - return m_has_subtype; - } - - /*! - @brief clears the binary subtype - - Clears the binary subtype and flags the value as not having a subtype, which - has implications for serialization; for instance MessagePack will prefer the - bin family over the ext family. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @sa @ref subtype() -- return the binary subtype - @sa @ref set_subtype() -- sets the binary subtype - @sa @ref has_subtype() -- returns whether or not the binary value has a - subtype - - @since version 3.8.0 - */ - void clear_subtype() noexcept - { - m_subtype = 0; - m_has_subtype = false; - } - - private: - std::uint8_t m_subtype = 0; - bool m_has_subtype = false; -}; - -} // namespace nlohmann - -// #include - -// #include - -// #include - -// #include - - -#include // size_t, uint8_t -#include // hash - -// #include - - -namespace nlohmann -{ -namespace detail -{ - -// boost::hash_combine -inline std::size_t combine(std::size_t seed, std::size_t h) noexcept -{ - seed ^= h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U); - return seed; -} - -/*! -@brief hash a JSON value - -The hash function tries to rely on std::hash where possible. Furthermore, the -type of the JSON value is taken into account to have different hash values for -null, 0, 0U, and false, etc. - -@tparam BasicJsonType basic_json specialization -@param j JSON value to hash -@return hash value of j -*/ -template -std::size_t hash(const BasicJsonType& j) -{ - using string_t = typename BasicJsonType::string_t; - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - - const auto type = static_cast(j.type()); - switch (j.type()) - { - case BasicJsonType::value_t::null: - case BasicJsonType::value_t::discarded: - { - return combine(type, 0); - } - - case BasicJsonType::value_t::object: - { - auto seed = combine(type, j.size()); - for (const auto& element : j.items()) - { - const auto h = std::hash {}(element.key()); - seed = combine(seed, h); - seed = combine(seed, hash(element.value())); - } - return seed; - } - - case BasicJsonType::value_t::array: - { - auto seed = combine(type, j.size()); - for (const auto& element : j) - { - seed = combine(seed, hash(element)); - } - return seed; - } - - case BasicJsonType::value_t::string: - { - const auto h = std::hash {}(j.template get_ref()); - return combine(type, h); - } - - case BasicJsonType::value_t::boolean: - { - const auto h = std::hash {}(j.template get()); - return combine(type, h); - } - - case BasicJsonType::value_t::number_integer: - { - const auto h = std::hash {}(j.template get()); - return combine(type, h); - } - - case BasicJsonType::value_t::number_unsigned: - { - const auto h = std::hash {}(j.template get()); - return combine(type, h); - } - - case BasicJsonType::value_t::number_float: - { - const auto h = std::hash {}(j.template get()); - return combine(type, h); - } - - case BasicJsonType::value_t::binary: - { - auto seed = combine(type, j.get_binary().size()); - const auto h = std::hash {}(j.get_binary().has_subtype()); - seed = combine(seed, h); - seed = combine(seed, j.get_binary().subtype()); - for (const auto byte : j.get_binary()) - { - seed = combine(seed, std::hash {}(byte)); - } - return seed; - } - - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // LCOV_EXCL_LINE - return 0; // LCOV_EXCL_LINE - } -} - -} // namespace detail -} // namespace nlohmann - -// #include - - -#include // generate_n -#include // array -#include // ldexp -#include // size_t -#include // uint8_t, uint16_t, uint32_t, uint64_t -#include // snprintf -#include // memcpy -#include // back_inserter -#include // numeric_limits -#include // char_traits, string -#include // make_pair, move -#include // vector - -// #include - -// #include - - -#include // array -#include // size_t -#include //FILE * -#include // strlen -#include // istream -#include // begin, end, iterator_traits, random_access_iterator_tag, distance, next -#include // shared_ptr, make_shared, addressof -#include // accumulate -#include // string, char_traits -#include // enable_if, is_base_of, is_pointer, is_integral, remove_pointer -#include // pair, declval - -// #include - -// #include - - -namespace nlohmann -{ -namespace detail -{ -/// the supported input formats -enum class input_format_t { json, cbor, msgpack, ubjson, bson }; - -//////////////////// -// input adapters // -//////////////////// - -/*! -Input adapter for stdio file access. This adapter read only 1 byte and do not use any - buffer. This adapter is a very low level adapter. -*/ -class file_input_adapter -{ - public: - using char_type = char; - - JSON_HEDLEY_NON_NULL(2) - explicit file_input_adapter(std::FILE* f) noexcept - : m_file(f) - {} - - // make class move-only - file_input_adapter(const file_input_adapter&) = delete; - file_input_adapter(file_input_adapter&&) = default; - file_input_adapter& operator=(const file_input_adapter&) = delete; - file_input_adapter& operator=(file_input_adapter&&) = delete; - - std::char_traits::int_type get_character() noexcept - { - return std::fgetc(m_file); - } - - private: - /// the file pointer to read from - std::FILE* m_file; -}; - - -/*! -Input adapter for a (caching) istream. Ignores a UFT Byte Order Mark at -beginning of input. Does not support changing the underlying std::streambuf -in mid-input. Maintains underlying std::istream and std::streambuf to support -subsequent use of standard std::istream operations to process any input -characters following those used in parsing the JSON input. Clears the -std::istream flags; any input errors (e.g., EOF) will be detected by the first -subsequent call for input from the std::istream. -*/ -class input_stream_adapter -{ - public: - using char_type = char; - - ~input_stream_adapter() - { - // clear stream flags; we use underlying streambuf I/O, do not - // maintain ifstream flags, except eof - if (is != nullptr) - { - is->clear(is->rdstate() & std::ios::eofbit); - } - } - - explicit input_stream_adapter(std::istream& i) - : is(&i), sb(i.rdbuf()) - {} - - // delete because of pointer members - input_stream_adapter(const input_stream_adapter&) = delete; - input_stream_adapter& operator=(input_stream_adapter&) = delete; - input_stream_adapter& operator=(input_stream_adapter&& rhs) = delete; - - input_stream_adapter(input_stream_adapter&& rhs) noexcept : is(rhs.is), sb(rhs.sb) - { - rhs.is = nullptr; - rhs.sb = nullptr; - } - - // std::istream/std::streambuf use std::char_traits::to_int_type, to - // ensure that std::char_traits::eof() and the character 0xFF do not - // end up as the same value, eg. 0xFFFFFFFF. - std::char_traits::int_type get_character() - { - auto res = sb->sbumpc(); - // set eof manually, as we don't use the istream interface. - if (JSON_HEDLEY_UNLIKELY(res == EOF)) - { - is->clear(is->rdstate() | std::ios::eofbit); - } - return res; - } - - private: - /// the associated input stream - std::istream* is = nullptr; - std::streambuf* sb = nullptr; -}; - -// General-purpose iterator-based adapter. It might not be as fast as -// theoretically possible for some containers, but it is extremely versatile. -template -class iterator_input_adapter -{ - public: - using char_type = typename std::iterator_traits::value_type; - - iterator_input_adapter(IteratorType first, IteratorType last) - : current(std::move(first)), end(std::move(last)) {} - - typename std::char_traits::int_type get_character() - { - if (JSON_HEDLEY_LIKELY(current != end)) - { - auto result = std::char_traits::to_int_type(*current); - std::advance(current, 1); - return result; - } - - return std::char_traits::eof(); - } - - private: - IteratorType current; - IteratorType end; - - template - friend struct wide_string_input_helper; - - bool empty() const - { - return current == end; - } - -}; - - -template -struct wide_string_input_helper; - -template -struct wide_string_input_helper -{ - // UTF-32 - static void fill_buffer(BaseInputAdapter& input, - std::array::int_type, 4>& utf8_bytes, - size_t& utf8_bytes_index, - size_t& utf8_bytes_filled) - { - utf8_bytes_index = 0; - - if (JSON_HEDLEY_UNLIKELY(input.empty())) - { - utf8_bytes[0] = std::char_traits::eof(); - utf8_bytes_filled = 1; - } - else - { - // get the current character - const auto wc = input.get_character(); - - // UTF-32 to UTF-8 encoding - if (wc < 0x80) - { - utf8_bytes[0] = static_cast::int_type>(wc); - utf8_bytes_filled = 1; - } - else if (wc <= 0x7FF) - { - utf8_bytes[0] = static_cast::int_type>(0xC0u | ((static_cast(wc) >> 6u) & 0x1Fu)); - utf8_bytes[1] = static_cast::int_type>(0x80u | (static_cast(wc) & 0x3Fu)); - utf8_bytes_filled = 2; - } - else if (wc <= 0xFFFF) - { - utf8_bytes[0] = static_cast::int_type>(0xE0u | ((static_cast(wc) >> 12u) & 0x0Fu)); - utf8_bytes[1] = static_cast::int_type>(0x80u | ((static_cast(wc) >> 6u) & 0x3Fu)); - utf8_bytes[2] = static_cast::int_type>(0x80u | (static_cast(wc) & 0x3Fu)); - utf8_bytes_filled = 3; - } - else if (wc <= 0x10FFFF) - { - utf8_bytes[0] = static_cast::int_type>(0xF0u | ((static_cast(wc) >> 18u) & 0x07u)); - utf8_bytes[1] = static_cast::int_type>(0x80u | ((static_cast(wc) >> 12u) & 0x3Fu)); - utf8_bytes[2] = static_cast::int_type>(0x80u | ((static_cast(wc) >> 6u) & 0x3Fu)); - utf8_bytes[3] = static_cast::int_type>(0x80u | (static_cast(wc) & 0x3Fu)); - utf8_bytes_filled = 4; - } - else - { - // unknown character - utf8_bytes[0] = static_cast::int_type>(wc); - utf8_bytes_filled = 1; - } - } - } -}; - -template -struct wide_string_input_helper -{ - // UTF-16 - static void fill_buffer(BaseInputAdapter& input, - std::array::int_type, 4>& utf8_bytes, - size_t& utf8_bytes_index, - size_t& utf8_bytes_filled) - { - utf8_bytes_index = 0; - - if (JSON_HEDLEY_UNLIKELY(input.empty())) - { - utf8_bytes[0] = std::char_traits::eof(); - utf8_bytes_filled = 1; - } - else - { - // get the current character - const auto wc = input.get_character(); - - // UTF-16 to UTF-8 encoding - if (wc < 0x80) - { - utf8_bytes[0] = static_cast::int_type>(wc); - utf8_bytes_filled = 1; - } - else if (wc <= 0x7FF) - { - utf8_bytes[0] = static_cast::int_type>(0xC0u | ((static_cast(wc) >> 6u))); - utf8_bytes[1] = static_cast::int_type>(0x80u | (static_cast(wc) & 0x3Fu)); - utf8_bytes_filled = 2; - } - else if (0xD800 > wc || wc >= 0xE000) - { - utf8_bytes[0] = static_cast::int_type>(0xE0u | ((static_cast(wc) >> 12u))); - utf8_bytes[1] = static_cast::int_type>(0x80u | ((static_cast(wc) >> 6u) & 0x3Fu)); - utf8_bytes[2] = static_cast::int_type>(0x80u | (static_cast(wc) & 0x3Fu)); - utf8_bytes_filled = 3; - } - else - { - if (JSON_HEDLEY_UNLIKELY(!input.empty())) - { - const auto wc2 = static_cast(input.get_character()); - const auto charcode = 0x10000u + (((static_cast(wc) & 0x3FFu) << 10u) | (wc2 & 0x3FFu)); - utf8_bytes[0] = static_cast::int_type>(0xF0u | (charcode >> 18u)); - utf8_bytes[1] = static_cast::int_type>(0x80u | ((charcode >> 12u) & 0x3Fu)); - utf8_bytes[2] = static_cast::int_type>(0x80u | ((charcode >> 6u) & 0x3Fu)); - utf8_bytes[3] = static_cast::int_type>(0x80u | (charcode & 0x3Fu)); - utf8_bytes_filled = 4; - } - else - { - utf8_bytes[0] = static_cast::int_type>(wc); - utf8_bytes_filled = 1; - } - } - } - } -}; - -// Wraps another input apdater to convert wide character types into individual bytes. -template -class wide_string_input_adapter -{ - public: - using char_type = char; - - wide_string_input_adapter(BaseInputAdapter base) - : base_adapter(base) {} - - typename std::char_traits::int_type get_character() noexcept - { - // check if buffer needs to be filled - if (utf8_bytes_index == utf8_bytes_filled) - { - fill_buffer(); - - JSON_ASSERT(utf8_bytes_filled > 0); - JSON_ASSERT(utf8_bytes_index == 0); - } - - // use buffer - JSON_ASSERT(utf8_bytes_filled > 0); - JSON_ASSERT(utf8_bytes_index < utf8_bytes_filled); - return utf8_bytes[utf8_bytes_index++]; - } - - private: - BaseInputAdapter base_adapter; - - template - void fill_buffer() - { - wide_string_input_helper::fill_buffer(base_adapter, utf8_bytes, utf8_bytes_index, utf8_bytes_filled); - } - - /// a buffer for UTF-8 bytes - std::array::int_type, 4> utf8_bytes = {{0, 0, 0, 0}}; - - /// index to the utf8_codes array for the next valid byte - std::size_t utf8_bytes_index = 0; - /// number of valid bytes in the utf8_codes array - std::size_t utf8_bytes_filled = 0; -}; - - -template -struct iterator_input_adapter_factory -{ - using iterator_type = IteratorType; - using char_type = typename std::iterator_traits::value_type; - using adapter_type = iterator_input_adapter; - - static adapter_type create(IteratorType first, IteratorType last) - { - return adapter_type(std::move(first), std::move(last)); - } -}; - -template -struct is_iterator_of_multibyte -{ - using value_type = typename std::iterator_traits::value_type; - enum - { - value = sizeof(value_type) > 1 - }; -}; - -template -struct iterator_input_adapter_factory::value>> -{ - using iterator_type = IteratorType; - using char_type = typename std::iterator_traits::value_type; - using base_adapter_type = iterator_input_adapter; - using adapter_type = wide_string_input_adapter; - - static adapter_type create(IteratorType first, IteratorType last) - { - return adapter_type(base_adapter_type(std::move(first), std::move(last))); - } -}; - -// General purpose iterator-based input -template -typename iterator_input_adapter_factory::adapter_type input_adapter(IteratorType first, IteratorType last) -{ - using factory_type = iterator_input_adapter_factory; - return factory_type::create(first, last); -} - -// Convenience shorthand from container to iterator -// Enables ADL on begin(container) and end(container) -// Encloses the using declarations in namespace for not to leak them to outside scope - -namespace container_input_adapter_factory_impl -{ - -using std::begin; -using std::end; - -template -struct container_input_adapter_factory {}; - -template -struct container_input_adapter_factory< ContainerType, - void_t()), end(std::declval()))>> - { - using adapter_type = decltype(input_adapter(begin(std::declval()), end(std::declval()))); - - static adapter_type create(const ContainerType& container) -{ - return input_adapter(begin(container), end(container)); -} - }; - -} - -template -typename container_input_adapter_factory_impl::container_input_adapter_factory::adapter_type input_adapter(const ContainerType& container) -{ - return container_input_adapter_factory_impl::container_input_adapter_factory::create(container); -} - -// Special cases with fast paths -inline file_input_adapter input_adapter(std::FILE* file) -{ - return file_input_adapter(file); -} - -inline input_stream_adapter input_adapter(std::istream& stream) -{ - return input_stream_adapter(stream); -} - -inline input_stream_adapter input_adapter(std::istream&& stream) -{ - return input_stream_adapter(stream); -} - -using contiguous_bytes_input_adapter = decltype(input_adapter(std::declval(), std::declval())); - -// Null-delimited strings, and the like. -template < typename CharT, - typename std::enable_if < - std::is_pointer::value&& - !std::is_array::value&& - std::is_integral::type>::value&& - sizeof(typename std::remove_pointer::type) == 1, - int >::type = 0 > -contiguous_bytes_input_adapter input_adapter(CharT b) -{ - auto length = std::strlen(reinterpret_cast(b)); - const auto* ptr = reinterpret_cast(b); - return input_adapter(ptr, ptr + length); -} - -template -auto input_adapter(T (&array)[N]) -> decltype(input_adapter(array, array + N)) -{ - return input_adapter(array, array + N); -} - -// This class only handles inputs of input_buffer_adapter type. -// It's required so that expressions like {ptr, len} can be implicitely casted -// to the correct adapter. -class span_input_adapter -{ - public: - template < typename CharT, - typename std::enable_if < - std::is_pointer::value&& - std::is_integral::type>::value&& - sizeof(typename std::remove_pointer::type) == 1, - int >::type = 0 > - span_input_adapter(CharT b, std::size_t l) - : ia(reinterpret_cast(b), reinterpret_cast(b) + l) {} - - template::iterator_category, std::random_access_iterator_tag>::value, - int>::type = 0> - span_input_adapter(IteratorType first, IteratorType last) - : ia(input_adapter(first, last)) {} - - contiguous_bytes_input_adapter&& get() - { - return std::move(ia); - } - - private: - contiguous_bytes_input_adapter ia; -}; -} // namespace detail -} // namespace nlohmann - -// #include - - -#include -#include // string -#include // move -#include // vector - -// #include - -// #include - - -namespace nlohmann -{ - -/*! -@brief SAX interface - -This class describes the SAX interface used by @ref nlohmann::json::sax_parse. -Each function is called in different situations while the input is parsed. The -boolean return value informs the parser whether to continue processing the -input. -*/ -template -struct json_sax -{ - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - - /*! - @brief a null value was read - @return whether parsing should proceed - */ - virtual bool null() = 0; - - /*! - @brief a boolean value was read - @param[in] val boolean value - @return whether parsing should proceed - */ - virtual bool boolean(bool val) = 0; - - /*! - @brief an integer number was read - @param[in] val integer value - @return whether parsing should proceed - */ - virtual bool number_integer(number_integer_t val) = 0; - - /*! - @brief an unsigned integer number was read - @param[in] val unsigned integer value - @return whether parsing should proceed - */ - virtual bool number_unsigned(number_unsigned_t val) = 0; - - /*! - @brief an floating-point number was read - @param[in] val floating-point value - @param[in] s raw token value - @return whether parsing should proceed - */ - virtual bool number_float(number_float_t val, const string_t& s) = 0; - - /*! - @brief a string was read - @param[in] val string value - @return whether parsing should proceed - @note It is safe to move the passed string. - */ - virtual bool string(string_t& val) = 0; - - /*! - @brief a binary string was read - @param[in] val binary value - @return whether parsing should proceed - @note It is safe to move the passed binary. - */ - virtual bool binary(binary_t& val) = 0; - - /*! - @brief the beginning of an object was read - @param[in] elements number of object elements or -1 if unknown - @return whether parsing should proceed - @note binary formats may report the number of elements - */ - virtual bool start_object(std::size_t elements) = 0; - - /*! - @brief an object key was read - @param[in] val object key - @return whether parsing should proceed - @note It is safe to move the passed string. - */ - virtual bool key(string_t& val) = 0; - - /*! - @brief the end of an object was read - @return whether parsing should proceed - */ - virtual bool end_object() = 0; - - /*! - @brief the beginning of an array was read - @param[in] elements number of array elements or -1 if unknown - @return whether parsing should proceed - @note binary formats may report the number of elements - */ - virtual bool start_array(std::size_t elements) = 0; - - /*! - @brief the end of an array was read - @return whether parsing should proceed - */ - virtual bool end_array() = 0; - - /*! - @brief a parse error occurred - @param[in] position the position in the input where the error occurs - @param[in] last_token the last read token - @param[in] ex an exception object describing the error - @return whether parsing should proceed (must return false) - */ - virtual bool parse_error(std::size_t position, - const std::string& last_token, - const detail::exception& ex) = 0; - - virtual ~json_sax() = default; -}; - - -namespace detail -{ -/*! -@brief SAX implementation to create a JSON value from SAX events - -This class implements the @ref json_sax interface and processes the SAX events -to create a JSON value which makes it basically a DOM parser. The structure or -hierarchy of the JSON value is managed by the stack `ref_stack` which contains -a pointer to the respective array or object for each recursion depth. - -After successful parsing, the value that is passed by reference to the -constructor contains the parsed value. - -@tparam BasicJsonType the JSON type -*/ -template -class json_sax_dom_parser -{ - public: - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - - /*! - @param[in, out] r reference to a JSON value that is manipulated while - parsing - @param[in] allow_exceptions_ whether parse errors yield exceptions - */ - explicit json_sax_dom_parser(BasicJsonType& r, const bool allow_exceptions_ = true) - : root(r), allow_exceptions(allow_exceptions_) - {} - - // make class move-only - json_sax_dom_parser(const json_sax_dom_parser&) = delete; - json_sax_dom_parser(json_sax_dom_parser&&) = default; - json_sax_dom_parser& operator=(const json_sax_dom_parser&) = delete; - json_sax_dom_parser& operator=(json_sax_dom_parser&&) = default; - ~json_sax_dom_parser() = default; - - bool null() - { - handle_value(nullptr); - return true; - } - - bool boolean(bool val) - { - handle_value(val); - return true; - } - - bool number_integer(number_integer_t val) - { - handle_value(val); - return true; - } - - bool number_unsigned(number_unsigned_t val) - { - handle_value(val); - return true; - } - - bool number_float(number_float_t val, const string_t& /*unused*/) - { - handle_value(val); - return true; - } - - bool string(string_t& val) - { - handle_value(val); - return true; - } - - bool binary(binary_t& val) - { - handle_value(std::move(val)); - return true; - } - - bool start_object(std::size_t len) - { - ref_stack.push_back(handle_value(BasicJsonType::value_t::object)); - - if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) - { - JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len), *ref_stack.back())); - } - - return true; - } - - bool key(string_t& val) - { - // add null at given key and store the reference for later - object_element = &(ref_stack.back()->m_value.object->operator[](val)); - return true; - } - - bool end_object() - { - ref_stack.back()->set_parents(); - ref_stack.pop_back(); - return true; - } - - bool start_array(std::size_t len) - { - ref_stack.push_back(handle_value(BasicJsonType::value_t::array)); - - if (JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) - { - JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len), *ref_stack.back())); - } - - return true; - } - - bool end_array() - { - ref_stack.back()->set_parents(); - ref_stack.pop_back(); - return true; - } - - template - bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, - const Exception& ex) - { - errored = true; - static_cast(ex); - if (allow_exceptions) - { - JSON_THROW(ex); - } - return false; - } - - constexpr bool is_errored() const - { - return errored; - } - - private: - /*! - @invariant If the ref stack is empty, then the passed value will be the new - root. - @invariant If the ref stack contains a value, then it is an array or an - object to which we can add elements - */ - template - JSON_HEDLEY_RETURNS_NON_NULL - BasicJsonType* handle_value(Value&& v) - { - if (ref_stack.empty()) - { - root = BasicJsonType(std::forward(v)); - return &root; - } - - JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object()); - - if (ref_stack.back()->is_array()) - { - ref_stack.back()->m_value.array->emplace_back(std::forward(v)); - return &(ref_stack.back()->m_value.array->back()); - } - - JSON_ASSERT(ref_stack.back()->is_object()); - JSON_ASSERT(object_element); - *object_element = BasicJsonType(std::forward(v)); - return object_element; - } - - /// the parsed JSON value - BasicJsonType& root; - /// stack to model hierarchy of values - std::vector ref_stack {}; - /// helper to hold the reference for the next object element - BasicJsonType* object_element = nullptr; - /// whether a syntax error occurred - bool errored = false; - /// whether to throw exceptions in case of errors - const bool allow_exceptions = true; -}; - -template -class json_sax_dom_callback_parser -{ - public: - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - using parser_callback_t = typename BasicJsonType::parser_callback_t; - using parse_event_t = typename BasicJsonType::parse_event_t; - - json_sax_dom_callback_parser(BasicJsonType& r, - const parser_callback_t cb, - const bool allow_exceptions_ = true) - : root(r), callback(cb), allow_exceptions(allow_exceptions_) - { - keep_stack.push_back(true); - } - - // make class move-only - json_sax_dom_callback_parser(const json_sax_dom_callback_parser&) = delete; - json_sax_dom_callback_parser(json_sax_dom_callback_parser&&) = default; - json_sax_dom_callback_parser& operator=(const json_sax_dom_callback_parser&) = delete; - json_sax_dom_callback_parser& operator=(json_sax_dom_callback_parser&&) = default; - ~json_sax_dom_callback_parser() = default; - - bool null() - { - handle_value(nullptr); - return true; - } - - bool boolean(bool val) - { - handle_value(val); - return true; - } - - bool number_integer(number_integer_t val) - { - handle_value(val); - return true; - } - - bool number_unsigned(number_unsigned_t val) - { - handle_value(val); - return true; - } - - bool number_float(number_float_t val, const string_t& /*unused*/) - { - handle_value(val); - return true; - } - - bool string(string_t& val) - { - handle_value(val); - return true; - } - - bool binary(binary_t& val) - { - handle_value(std::move(val)); - return true; - } - - bool start_object(std::size_t len) - { - // check callback for object start - const bool keep = callback(static_cast(ref_stack.size()), parse_event_t::object_start, discarded); - keep_stack.push_back(keep); - - auto val = handle_value(BasicJsonType::value_t::object, true); - ref_stack.push_back(val.second); - - // check object limit - if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) - { - JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len), *ref_stack.back())); - } - - return true; - } - - bool key(string_t& val) - { - BasicJsonType k = BasicJsonType(val); - - // check callback for key - const bool keep = callback(static_cast(ref_stack.size()), parse_event_t::key, k); - key_keep_stack.push_back(keep); - - // add discarded value at given key and store the reference for later - if (keep && ref_stack.back()) - { - object_element = &(ref_stack.back()->m_value.object->operator[](val) = discarded); - } - - return true; - } - - bool end_object() - { - if (ref_stack.back()) - { - if (!callback(static_cast(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back())) - { - // discard object - *ref_stack.back() = discarded; - } - else - { - ref_stack.back()->set_parents(); - } - } - - JSON_ASSERT(!ref_stack.empty()); - JSON_ASSERT(!keep_stack.empty()); - ref_stack.pop_back(); - keep_stack.pop_back(); - - if (!ref_stack.empty() && ref_stack.back() && ref_stack.back()->is_structured()) - { - // remove discarded value - for (auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it) - { - if (it->is_discarded()) - { - ref_stack.back()->erase(it); - break; - } - } - } - - return true; - } - - bool start_array(std::size_t len) - { - const bool keep = callback(static_cast(ref_stack.size()), parse_event_t::array_start, discarded); - keep_stack.push_back(keep); - - auto val = handle_value(BasicJsonType::value_t::array, true); - ref_stack.push_back(val.second); - - // check array limit - if (ref_stack.back() && JSON_HEDLEY_UNLIKELY(len != std::size_t(-1) && len > ref_stack.back()->max_size())) - { - JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len), *ref_stack.back())); - } - - return true; - } - - bool end_array() - { - bool keep = true; - - if (ref_stack.back()) - { - keep = callback(static_cast(ref_stack.size()) - 1, parse_event_t::array_end, *ref_stack.back()); - if (keep) - { - ref_stack.back()->set_parents(); - } - else - { - // discard array - *ref_stack.back() = discarded; - } - } - - JSON_ASSERT(!ref_stack.empty()); - JSON_ASSERT(!keep_stack.empty()); - ref_stack.pop_back(); - keep_stack.pop_back(); - - // remove discarded value - if (!keep && !ref_stack.empty() && ref_stack.back()->is_array()) - { - ref_stack.back()->m_value.array->pop_back(); - } - - return true; - } - - template - bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, - const Exception& ex) - { - errored = true; - static_cast(ex); - if (allow_exceptions) - { - JSON_THROW(ex); - } - return false; - } - - constexpr bool is_errored() const - { - return errored; - } - - private: - /*! - @param[in] v value to add to the JSON value we build during parsing - @param[in] skip_callback whether we should skip calling the callback - function; this is required after start_array() and - start_object() SAX events, because otherwise we would call the - callback function with an empty array or object, respectively. - - @invariant If the ref stack is empty, then the passed value will be the new - root. - @invariant If the ref stack contains a value, then it is an array or an - object to which we can add elements - - @return pair of boolean (whether value should be kept) and pointer (to the - passed value in the ref_stack hierarchy; nullptr if not kept) - */ - template - std::pair handle_value(Value&& v, const bool skip_callback = false) - { - JSON_ASSERT(!keep_stack.empty()); - - // do not handle this value if we know it would be added to a discarded - // container - if (!keep_stack.back()) - { - return {false, nullptr}; - } - - // create value - auto value = BasicJsonType(std::forward(v)); - - // check callback - const bool keep = skip_callback || callback(static_cast(ref_stack.size()), parse_event_t::value, value); - - // do not handle this value if we just learnt it shall be discarded - if (!keep) - { - return {false, nullptr}; - } - - if (ref_stack.empty()) - { - root = std::move(value); - return {true, &root}; - } - - // skip this value if we already decided to skip the parent - // (https://github.com/nlohmann/json/issues/971#issuecomment-413678360) - if (!ref_stack.back()) - { - return {false, nullptr}; - } - - // we now only expect arrays and objects - JSON_ASSERT(ref_stack.back()->is_array() || ref_stack.back()->is_object()); - - // array - if (ref_stack.back()->is_array()) - { - ref_stack.back()->m_value.array->emplace_back(std::move(value)); - return {true, &(ref_stack.back()->m_value.array->back())}; - } - - // object - JSON_ASSERT(ref_stack.back()->is_object()); - // check if we should store an element for the current key - JSON_ASSERT(!key_keep_stack.empty()); - const bool store_element = key_keep_stack.back(); - key_keep_stack.pop_back(); - - if (!store_element) - { - return {false, nullptr}; - } - - JSON_ASSERT(object_element); - *object_element = std::move(value); - return {true, object_element}; - } - - /// the parsed JSON value - BasicJsonType& root; - /// stack to model hierarchy of values - std::vector ref_stack {}; - /// stack to manage which values to keep - std::vector keep_stack {}; - /// stack to manage which object keys to keep - std::vector key_keep_stack {}; - /// helper to hold the reference for the next object element - BasicJsonType* object_element = nullptr; - /// whether a syntax error occurred - bool errored = false; - /// callback function - const parser_callback_t callback = nullptr; - /// whether to throw exceptions in case of errors - const bool allow_exceptions = true; - /// a discarded value for the callback - BasicJsonType discarded = BasicJsonType::value_t::discarded; -}; - -template -class json_sax_acceptor -{ - public: - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - - bool null() - { - return true; - } - - bool boolean(bool /*unused*/) - { - return true; - } - - bool number_integer(number_integer_t /*unused*/) - { - return true; - } - - bool number_unsigned(number_unsigned_t /*unused*/) - { - return true; - } - - bool number_float(number_float_t /*unused*/, const string_t& /*unused*/) - { - return true; - } - - bool string(string_t& /*unused*/) - { - return true; - } - - bool binary(binary_t& /*unused*/) - { - return true; - } - - bool start_object(std::size_t /*unused*/ = std::size_t(-1)) - { - return true; - } - - bool key(string_t& /*unused*/) - { - return true; - } - - bool end_object() - { - return true; - } - - bool start_array(std::size_t /*unused*/ = std::size_t(-1)) - { - return true; - } - - bool end_array() - { - return true; - } - - bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const detail::exception& /*unused*/) - { - return false; - } -}; -} // namespace detail - -} // namespace nlohmann - -// #include - - -#include // array -#include // localeconv -#include // size_t -#include // snprintf -#include // strtof, strtod, strtold, strtoll, strtoull -#include // initializer_list -#include // char_traits, string -#include // move -#include // vector - -// #include - -// #include - -// #include - - -namespace nlohmann -{ -namespace detail -{ -/////////// -// lexer // -/////////// - -template -class lexer_base -{ - public: - /// token types for the parser - enum class token_type - { - uninitialized, ///< indicating the scanner is uninitialized - literal_true, ///< the `true` literal - literal_false, ///< the `false` literal - literal_null, ///< the `null` literal - value_string, ///< a string -- use get_string() for actual value - value_unsigned, ///< an unsigned integer -- use get_number_unsigned() for actual value - value_integer, ///< a signed integer -- use get_number_integer() for actual value - value_float, ///< an floating point number -- use get_number_float() for actual value - begin_array, ///< the character for array begin `[` - begin_object, ///< the character for object begin `{` - end_array, ///< the character for array end `]` - end_object, ///< the character for object end `}` - name_separator, ///< the name separator `:` - value_separator, ///< the value separator `,` - parse_error, ///< indicating a parse error - end_of_input, ///< indicating the end of the input buffer - literal_or_value ///< a literal or the begin of a value (only for diagnostics) - }; - - /// return name of values of type token_type (only used for errors) - JSON_HEDLEY_RETURNS_NON_NULL - JSON_HEDLEY_CONST - static const char* token_type_name(const token_type t) noexcept - { - switch (t) - { - case token_type::uninitialized: - return ""; - case token_type::literal_true: - return "true literal"; - case token_type::literal_false: - return "false literal"; - case token_type::literal_null: - return "null literal"; - case token_type::value_string: - return "string literal"; - case token_type::value_unsigned: - case token_type::value_integer: - case token_type::value_float: - return "number literal"; - case token_type::begin_array: - return "'['"; - case token_type::begin_object: - return "'{'"; - case token_type::end_array: - return "']'"; - case token_type::end_object: - return "'}'"; - case token_type::name_separator: - return "':'"; - case token_type::value_separator: - return "','"; - case token_type::parse_error: - return ""; - case token_type::end_of_input: - return "end of input"; - case token_type::literal_or_value: - return "'[', '{', or a literal"; - // LCOV_EXCL_START - default: // catch non-enum values - return "unknown token"; - // LCOV_EXCL_STOP - } - } -}; -/*! -@brief lexical analysis - -This class organizes the lexical analysis during JSON deserialization. -*/ -template -class lexer : public lexer_base -{ - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using char_type = typename InputAdapterType::char_type; - using char_int_type = typename std::char_traits::int_type; - - public: - using token_type = typename lexer_base::token_type; - - explicit lexer(InputAdapterType&& adapter, bool ignore_comments_ = false) - : ia(std::move(adapter)) - , ignore_comments(ignore_comments_) - , decimal_point_char(static_cast(get_decimal_point())) - {} - - // delete because of pointer members - lexer(const lexer&) = delete; - lexer(lexer&&) = default; - lexer& operator=(lexer&) = delete; - lexer& operator=(lexer&&) = default; - ~lexer() = default; - - private: - ///////////////////// - // locales - ///////////////////// - - /// return the locale-dependent decimal point - JSON_HEDLEY_PURE - static char get_decimal_point() noexcept - { - const auto* loc = localeconv(); - JSON_ASSERT(loc != nullptr); - return (loc->decimal_point == nullptr) ? '.' : *(loc->decimal_point); - } - - ///////////////////// - // scan functions - ///////////////////// - - /*! - @brief get codepoint from 4 hex characters following `\u` - - For input "\u c1 c2 c3 c4" the codepoint is: - (c1 * 0x1000) + (c2 * 0x0100) + (c3 * 0x0010) + c4 - = (c1 << 12) + (c2 << 8) + (c3 << 4) + (c4 << 0) - - Furthermore, the possible characters '0'..'9', 'A'..'F', and 'a'..'f' - must be converted to the integers 0x0..0x9, 0xA..0xF, 0xA..0xF, resp. The - conversion is done by subtracting the offset (0x30, 0x37, and 0x57) - between the ASCII value of the character and the desired integer value. - - @return codepoint (0x0000..0xFFFF) or -1 in case of an error (e.g. EOF or - non-hex character) - */ - int get_codepoint() - { - // this function only makes sense after reading `\u` - JSON_ASSERT(current == 'u'); - int codepoint = 0; - - const auto factors = { 12u, 8u, 4u, 0u }; - for (const auto factor : factors) - { - get(); - - if (current >= '0' && current <= '9') - { - codepoint += static_cast((static_cast(current) - 0x30u) << factor); - } - else if (current >= 'A' && current <= 'F') - { - codepoint += static_cast((static_cast(current) - 0x37u) << factor); - } - else if (current >= 'a' && current <= 'f') - { - codepoint += static_cast((static_cast(current) - 0x57u) << factor); - } - else - { - return -1; - } - } - - JSON_ASSERT(0x0000 <= codepoint && codepoint <= 0xFFFF); - return codepoint; - } - - /*! - @brief check if the next byte(s) are inside a given range - - Adds the current byte and, for each passed range, reads a new byte and - checks if it is inside the range. If a violation was detected, set up an - error message and return false. Otherwise, return true. - - @param[in] ranges list of integers; interpreted as list of pairs of - inclusive lower and upper bound, respectively - - @pre The passed list @a ranges must have 2, 4, or 6 elements; that is, - 1, 2, or 3 pairs. This precondition is enforced by an assertion. - - @return true if and only if no range violation was detected - */ - bool next_byte_in_range(std::initializer_list ranges) - { - JSON_ASSERT(ranges.size() == 2 || ranges.size() == 4 || ranges.size() == 6); - add(current); - - for (auto range = ranges.begin(); range != ranges.end(); ++range) - { - get(); - if (JSON_HEDLEY_LIKELY(*range <= current && current <= *(++range))) - { - add(current); - } - else - { - error_message = "invalid string: ill-formed UTF-8 byte"; - return false; - } - } - - return true; - } - - /*! - @brief scan a string literal - - This function scans a string according to Sect. 7 of RFC 7159. While - scanning, bytes are escaped and copied into buffer token_buffer. Then the - function returns successfully, token_buffer is *not* null-terminated (as it - may contain \0 bytes), and token_buffer.size() is the number of bytes in the - string. - - @return token_type::value_string if string could be successfully scanned, - token_type::parse_error otherwise - - @note In case of errors, variable error_message contains a textual - description. - */ - token_type scan_string() - { - // reset token_buffer (ignore opening quote) - reset(); - - // we entered the function by reading an open quote - JSON_ASSERT(current == '\"'); - - while (true) - { - // get next character - switch (get()) - { - // end of file while parsing string - case std::char_traits::eof(): - { - error_message = "invalid string: missing closing quote"; - return token_type::parse_error; - } - - // closing quote - case '\"': - { - return token_type::value_string; - } - - // escapes - case '\\': - { - switch (get()) - { - // quotation mark - case '\"': - add('\"'); - break; - // reverse solidus - case '\\': - add('\\'); - break; - // solidus - case '/': - add('/'); - break; - // backspace - case 'b': - add('\b'); - break; - // form feed - case 'f': - add('\f'); - break; - // line feed - case 'n': - add('\n'); - break; - // carriage return - case 'r': - add('\r'); - break; - // tab - case 't': - add('\t'); - break; - - // unicode escapes - case 'u': - { - const int codepoint1 = get_codepoint(); - int codepoint = codepoint1; // start with codepoint1 - - if (JSON_HEDLEY_UNLIKELY(codepoint1 == -1)) - { - error_message = "invalid string: '\\u' must be followed by 4 hex digits"; - return token_type::parse_error; - } - - // check if code point is a high surrogate - if (0xD800 <= codepoint1 && codepoint1 <= 0xDBFF) - { - // expect next \uxxxx entry - if (JSON_HEDLEY_LIKELY(get() == '\\' && get() == 'u')) - { - const int codepoint2 = get_codepoint(); - - if (JSON_HEDLEY_UNLIKELY(codepoint2 == -1)) - { - error_message = "invalid string: '\\u' must be followed by 4 hex digits"; - return token_type::parse_error; - } - - // check if codepoint2 is a low surrogate - if (JSON_HEDLEY_LIKELY(0xDC00 <= codepoint2 && codepoint2 <= 0xDFFF)) - { - // overwrite codepoint - codepoint = static_cast( - // high surrogate occupies the most significant 22 bits - (static_cast(codepoint1) << 10u) - // low surrogate occupies the least significant 15 bits - + static_cast(codepoint2) - // there is still the 0xD800, 0xDC00 and 0x10000 noise - // in the result so we have to subtract with: - // (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00 - - 0x35FDC00u); - } - else - { - error_message = "invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF"; - return token_type::parse_error; - } - } - else - { - error_message = "invalid string: surrogate U+D800..U+DBFF must be followed by U+DC00..U+DFFF"; - return token_type::parse_error; - } - } - else - { - if (JSON_HEDLEY_UNLIKELY(0xDC00 <= codepoint1 && codepoint1 <= 0xDFFF)) - { - error_message = "invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF"; - return token_type::parse_error; - } - } - - // result of the above calculation yields a proper codepoint - JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF); - - // translate codepoint into bytes - if (codepoint < 0x80) - { - // 1-byte characters: 0xxxxxxx (ASCII) - add(static_cast(codepoint)); - } - else if (codepoint <= 0x7FF) - { - // 2-byte characters: 110xxxxx 10xxxxxx - add(static_cast(0xC0u | (static_cast(codepoint) >> 6u))); - add(static_cast(0x80u | (static_cast(codepoint) & 0x3Fu))); - } - else if (codepoint <= 0xFFFF) - { - // 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx - add(static_cast(0xE0u | (static_cast(codepoint) >> 12u))); - add(static_cast(0x80u | ((static_cast(codepoint) >> 6u) & 0x3Fu))); - add(static_cast(0x80u | (static_cast(codepoint) & 0x3Fu))); - } - else - { - // 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - add(static_cast(0xF0u | (static_cast(codepoint) >> 18u))); - add(static_cast(0x80u | ((static_cast(codepoint) >> 12u) & 0x3Fu))); - add(static_cast(0x80u | ((static_cast(codepoint) >> 6u) & 0x3Fu))); - add(static_cast(0x80u | (static_cast(codepoint) & 0x3Fu))); - } - - break; - } - - // other characters after escape - default: - error_message = "invalid string: forbidden character after backslash"; - return token_type::parse_error; - } - - break; - } - - // invalid control characters - case 0x00: - { - error_message = "invalid string: control character U+0000 (NUL) must be escaped to \\u0000"; - return token_type::parse_error; - } - - case 0x01: - { - error_message = "invalid string: control character U+0001 (SOH) must be escaped to \\u0001"; - return token_type::parse_error; - } - - case 0x02: - { - error_message = "invalid string: control character U+0002 (STX) must be escaped to \\u0002"; - return token_type::parse_error; - } - - case 0x03: - { - error_message = "invalid string: control character U+0003 (ETX) must be escaped to \\u0003"; - return token_type::parse_error; - } - - case 0x04: - { - error_message = "invalid string: control character U+0004 (EOT) must be escaped to \\u0004"; - return token_type::parse_error; - } - - case 0x05: - { - error_message = "invalid string: control character U+0005 (ENQ) must be escaped to \\u0005"; - return token_type::parse_error; - } - - case 0x06: - { - error_message = "invalid string: control character U+0006 (ACK) must be escaped to \\u0006"; - return token_type::parse_error; - } - - case 0x07: - { - error_message = "invalid string: control character U+0007 (BEL) must be escaped to \\u0007"; - return token_type::parse_error; - } - - case 0x08: - { - error_message = "invalid string: control character U+0008 (BS) must be escaped to \\u0008 or \\b"; - return token_type::parse_error; - } - - case 0x09: - { - error_message = "invalid string: control character U+0009 (HT) must be escaped to \\u0009 or \\t"; - return token_type::parse_error; - } - - case 0x0A: - { - error_message = "invalid string: control character U+000A (LF) must be escaped to \\u000A or \\n"; - return token_type::parse_error; - } - - case 0x0B: - { - error_message = "invalid string: control character U+000B (VT) must be escaped to \\u000B"; - return token_type::parse_error; - } - - case 0x0C: - { - error_message = "invalid string: control character U+000C (FF) must be escaped to \\u000C or \\f"; - return token_type::parse_error; - } - - case 0x0D: - { - error_message = "invalid string: control character U+000D (CR) must be escaped to \\u000D or \\r"; - return token_type::parse_error; - } - - case 0x0E: - { - error_message = "invalid string: control character U+000E (SO) must be escaped to \\u000E"; - return token_type::parse_error; - } - - case 0x0F: - { - error_message = "invalid string: control character U+000F (SI) must be escaped to \\u000F"; - return token_type::parse_error; - } - - case 0x10: - { - error_message = "invalid string: control character U+0010 (DLE) must be escaped to \\u0010"; - return token_type::parse_error; - } - - case 0x11: - { - error_message = "invalid string: control character U+0011 (DC1) must be escaped to \\u0011"; - return token_type::parse_error; - } - - case 0x12: - { - error_message = "invalid string: control character U+0012 (DC2) must be escaped to \\u0012"; - return token_type::parse_error; - } - - case 0x13: - { - error_message = "invalid string: control character U+0013 (DC3) must be escaped to \\u0013"; - return token_type::parse_error; - } - - case 0x14: - { - error_message = "invalid string: control character U+0014 (DC4) must be escaped to \\u0014"; - return token_type::parse_error; - } - - case 0x15: - { - error_message = "invalid string: control character U+0015 (NAK) must be escaped to \\u0015"; - return token_type::parse_error; - } - - case 0x16: - { - error_message = "invalid string: control character U+0016 (SYN) must be escaped to \\u0016"; - return token_type::parse_error; - } - - case 0x17: - { - error_message = "invalid string: control character U+0017 (ETB) must be escaped to \\u0017"; - return token_type::parse_error; - } - - case 0x18: - { - error_message = "invalid string: control character U+0018 (CAN) must be escaped to \\u0018"; - return token_type::parse_error; - } - - case 0x19: - { - error_message = "invalid string: control character U+0019 (EM) must be escaped to \\u0019"; - return token_type::parse_error; - } - - case 0x1A: - { - error_message = "invalid string: control character U+001A (SUB) must be escaped to \\u001A"; - return token_type::parse_error; - } - - case 0x1B: - { - error_message = "invalid string: control character U+001B (ESC) must be escaped to \\u001B"; - return token_type::parse_error; - } - - case 0x1C: - { - error_message = "invalid string: control character U+001C (FS) must be escaped to \\u001C"; - return token_type::parse_error; - } - - case 0x1D: - { - error_message = "invalid string: control character U+001D (GS) must be escaped to \\u001D"; - return token_type::parse_error; - } - - case 0x1E: - { - error_message = "invalid string: control character U+001E (RS) must be escaped to \\u001E"; - return token_type::parse_error; - } - - case 0x1F: - { - error_message = "invalid string: control character U+001F (US) must be escaped to \\u001F"; - return token_type::parse_error; - } - - // U+0020..U+007F (except U+0022 (quote) and U+005C (backspace)) - case 0x20: - case 0x21: - case 0x23: - case 0x24: - case 0x25: - case 0x26: - case 0x27: - case 0x28: - case 0x29: - case 0x2A: - case 0x2B: - case 0x2C: - case 0x2D: - case 0x2E: - case 0x2F: - case 0x30: - case 0x31: - case 0x32: - case 0x33: - case 0x34: - case 0x35: - case 0x36: - case 0x37: - case 0x38: - case 0x39: - case 0x3A: - case 0x3B: - case 0x3C: - case 0x3D: - case 0x3E: - case 0x3F: - case 0x40: - case 0x41: - case 0x42: - case 0x43: - case 0x44: - case 0x45: - case 0x46: - case 0x47: - case 0x48: - case 0x49: - case 0x4A: - case 0x4B: - case 0x4C: - case 0x4D: - case 0x4E: - case 0x4F: - case 0x50: - case 0x51: - case 0x52: - case 0x53: - case 0x54: - case 0x55: - case 0x56: - case 0x57: - case 0x58: - case 0x59: - case 0x5A: - case 0x5B: - case 0x5D: - case 0x5E: - case 0x5F: - case 0x60: - case 0x61: - case 0x62: - case 0x63: - case 0x64: - case 0x65: - case 0x66: - case 0x67: - case 0x68: - case 0x69: - case 0x6A: - case 0x6B: - case 0x6C: - case 0x6D: - case 0x6E: - case 0x6F: - case 0x70: - case 0x71: - case 0x72: - case 0x73: - case 0x74: - case 0x75: - case 0x76: - case 0x77: - case 0x78: - case 0x79: - case 0x7A: - case 0x7B: - case 0x7C: - case 0x7D: - case 0x7E: - case 0x7F: - { - add(current); - break; - } - - // U+0080..U+07FF: bytes C2..DF 80..BF - case 0xC2: - case 0xC3: - case 0xC4: - case 0xC5: - case 0xC6: - case 0xC7: - case 0xC8: - case 0xC9: - case 0xCA: - case 0xCB: - case 0xCC: - case 0xCD: - case 0xCE: - case 0xCF: - case 0xD0: - case 0xD1: - case 0xD2: - case 0xD3: - case 0xD4: - case 0xD5: - case 0xD6: - case 0xD7: - case 0xD8: - case 0xD9: - case 0xDA: - case 0xDB: - case 0xDC: - case 0xDD: - case 0xDE: - case 0xDF: - { - if (JSON_HEDLEY_UNLIKELY(!next_byte_in_range({0x80, 0xBF}))) - { - return token_type::parse_error; - } - break; - } - - // U+0800..U+0FFF: bytes E0 A0..BF 80..BF - case 0xE0: - { - if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0xA0, 0xBF, 0x80, 0xBF})))) - { - return token_type::parse_error; - } - break; - } - - // U+1000..U+CFFF: bytes E1..EC 80..BF 80..BF - // U+E000..U+FFFF: bytes EE..EF 80..BF 80..BF - case 0xE1: - case 0xE2: - case 0xE3: - case 0xE4: - case 0xE5: - case 0xE6: - case 0xE7: - case 0xE8: - case 0xE9: - case 0xEA: - case 0xEB: - case 0xEC: - case 0xEE: - case 0xEF: - { - if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0xBF, 0x80, 0xBF})))) - { - return token_type::parse_error; - } - break; - } - - // U+D000..U+D7FF: bytes ED 80..9F 80..BF - case 0xED: - { - if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0x9F, 0x80, 0xBF})))) - { - return token_type::parse_error; - } - break; - } - - // U+10000..U+3FFFF F0 90..BF 80..BF 80..BF - case 0xF0: - { - if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x90, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) - { - return token_type::parse_error; - } - break; - } - - // U+40000..U+FFFFF F1..F3 80..BF 80..BF 80..BF - case 0xF1: - case 0xF2: - case 0xF3: - { - if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0xBF, 0x80, 0xBF, 0x80, 0xBF})))) - { - return token_type::parse_error; - } - break; - } - - // U+100000..U+10FFFF F4 80..8F 80..BF 80..BF - case 0xF4: - { - if (JSON_HEDLEY_UNLIKELY(!(next_byte_in_range({0x80, 0x8F, 0x80, 0xBF, 0x80, 0xBF})))) - { - return token_type::parse_error; - } - break; - } - - // remaining bytes (80..C1 and F5..FF) are ill-formed - default: - { - error_message = "invalid string: ill-formed UTF-8 byte"; - return token_type::parse_error; - } - } - } - } - - /*! - * @brief scan a comment - * @return whether comment could be scanned successfully - */ - bool scan_comment() - { - switch (get()) - { - // single-line comments skip input until a newline or EOF is read - case '/': - { - while (true) - { - switch (get()) - { - case '\n': - case '\r': - case std::char_traits::eof(): - case '\0': - return true; - - default: - break; - } - } - } - - // multi-line comments skip input until */ is read - case '*': - { - while (true) - { - switch (get()) - { - case std::char_traits::eof(): - case '\0': - { - error_message = "invalid comment; missing closing '*/'"; - return false; - } - - case '*': - { - switch (get()) - { - case '/': - return true; - - default: - { - unget(); - continue; - } - } - } - - default: - continue; - } - } - } - - // unexpected character after reading '/' - default: - { - error_message = "invalid comment; expecting '/' or '*' after '/'"; - return false; - } - } - } - - JSON_HEDLEY_NON_NULL(2) - static void strtof(float& f, const char* str, char** endptr) noexcept - { - f = std::strtof(str, endptr); - } - - JSON_HEDLEY_NON_NULL(2) - static void strtof(double& f, const char* str, char** endptr) noexcept - { - f = std::strtod(str, endptr); - } - - JSON_HEDLEY_NON_NULL(2) - static void strtof(long double& f, const char* str, char** endptr) noexcept - { - f = std::strtold(str, endptr); - } - - /*! - @brief scan a number literal - - This function scans a string according to Sect. 6 of RFC 7159. - - The function is realized with a deterministic finite state machine derived - from the grammar described in RFC 7159. Starting in state "init", the - input is read and used to determined the next state. Only state "done" - accepts the number. State "error" is a trap state to model errors. In the - table below, "anything" means any character but the ones listed before. - - state | 0 | 1-9 | e E | + | - | . | anything - ---------|----------|----------|----------|---------|---------|----------|----------- - init | zero | any1 | [error] | [error] | minus | [error] | [error] - minus | zero | any1 | [error] | [error] | [error] | [error] | [error] - zero | done | done | exponent | done | done | decimal1 | done - any1 | any1 | any1 | exponent | done | done | decimal1 | done - decimal1 | decimal2 | decimal2 | [error] | [error] | [error] | [error] | [error] - decimal2 | decimal2 | decimal2 | exponent | done | done | done | done - exponent | any2 | any2 | [error] | sign | sign | [error] | [error] - sign | any2 | any2 | [error] | [error] | [error] | [error] | [error] - any2 | any2 | any2 | done | done | done | done | done - - The state machine is realized with one label per state (prefixed with - "scan_number_") and `goto` statements between them. The state machine - contains cycles, but any cycle can be left when EOF is read. Therefore, - the function is guaranteed to terminate. - - During scanning, the read bytes are stored in token_buffer. This string is - then converted to a signed integer, an unsigned integer, or a - floating-point number. - - @return token_type::value_unsigned, token_type::value_integer, or - token_type::value_float if number could be successfully scanned, - token_type::parse_error otherwise - - @note The scanner is independent of the current locale. Internally, the - locale's decimal point is used instead of `.` to work with the - locale-dependent converters. - */ - token_type scan_number() // lgtm [cpp/use-of-goto] - { - // reset token_buffer to store the number's bytes - reset(); - - // the type of the parsed number; initially set to unsigned; will be - // changed if minus sign, decimal point or exponent is read - token_type number_type = token_type::value_unsigned; - - // state (init): we just found out we need to scan a number - switch (current) - { - case '-': - { - add(current); - goto scan_number_minus; - } - - case '0': - { - add(current); - goto scan_number_zero; - } - - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_any1; - } - - // all other characters are rejected outside scan_number() - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // LCOV_EXCL_LINE - } - -scan_number_minus: - // state: we just parsed a leading minus sign - number_type = token_type::value_integer; - switch (get()) - { - case '0': - { - add(current); - goto scan_number_zero; - } - - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_any1; - } - - default: - { - error_message = "invalid number; expected digit after '-'"; - return token_type::parse_error; - } - } - -scan_number_zero: - // state: we just parse a zero (maybe with a leading minus sign) - switch (get()) - { - case '.': - { - add(decimal_point_char); - goto scan_number_decimal1; - } - - case 'e': - case 'E': - { - add(current); - goto scan_number_exponent; - } - - default: - goto scan_number_done; - } - -scan_number_any1: - // state: we just parsed a number 0-9 (maybe with a leading minus sign) - switch (get()) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_any1; - } - - case '.': - { - add(decimal_point_char); - goto scan_number_decimal1; - } - - case 'e': - case 'E': - { - add(current); - goto scan_number_exponent; - } - - default: - goto scan_number_done; - } - -scan_number_decimal1: - // state: we just parsed a decimal point - number_type = token_type::value_float; - switch (get()) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_decimal2; - } - - default: - { - error_message = "invalid number; expected digit after '.'"; - return token_type::parse_error; - } - } - -scan_number_decimal2: - // we just parsed at least one number after a decimal point - switch (get()) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_decimal2; - } - - case 'e': - case 'E': - { - add(current); - goto scan_number_exponent; - } - - default: - goto scan_number_done; - } - -scan_number_exponent: - // we just parsed an exponent - number_type = token_type::value_float; - switch (get()) - { - case '+': - case '-': - { - add(current); - goto scan_number_sign; - } - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_any2; - } - - default: - { - error_message = - "invalid number; expected '+', '-', or digit after exponent"; - return token_type::parse_error; - } - } - -scan_number_sign: - // we just parsed an exponent sign - switch (get()) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_any2; - } - - default: - { - error_message = "invalid number; expected digit after exponent sign"; - return token_type::parse_error; - } - } - -scan_number_any2: - // we just parsed a number after the exponent or exponent sign - switch (get()) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - add(current); - goto scan_number_any2; - } - - default: - goto scan_number_done; - } - -scan_number_done: - // unget the character after the number (we only read it to know that - // we are done scanning a number) - unget(); - - char* endptr = nullptr; - errno = 0; - - // try to parse integers first and fall back to floats - if (number_type == token_type::value_unsigned) - { - const auto x = std::strtoull(token_buffer.data(), &endptr, 10); - - // we checked the number format before - JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size()); - - if (errno == 0) - { - value_unsigned = static_cast(x); - if (value_unsigned == x) - { - return token_type::value_unsigned; - } - } - } - else if (number_type == token_type::value_integer) - { - const auto x = std::strtoll(token_buffer.data(), &endptr, 10); - - // we checked the number format before - JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size()); - - if (errno == 0) - { - value_integer = static_cast(x); - if (value_integer == x) - { - return token_type::value_integer; - } - } - } - - // this code is reached if we parse a floating-point number or if an - // integer conversion above failed - strtof(value_float, token_buffer.data(), &endptr); - - // we checked the number format before - JSON_ASSERT(endptr == token_buffer.data() + token_buffer.size()); - - return token_type::value_float; - } - - /*! - @param[in] literal_text the literal text to expect - @param[in] length the length of the passed literal text - @param[in] return_type the token type to return on success - */ - JSON_HEDLEY_NON_NULL(2) - token_type scan_literal(const char_type* literal_text, const std::size_t length, - token_type return_type) - { - JSON_ASSERT(std::char_traits::to_char_type(current) == literal_text[0]); - for (std::size_t i = 1; i < length; ++i) - { - if (JSON_HEDLEY_UNLIKELY(std::char_traits::to_char_type(get()) != literal_text[i])) - { - error_message = "invalid literal"; - return token_type::parse_error; - } - } - return return_type; - } - - ///////////////////// - // input management - ///////////////////// - - /// reset token_buffer; current character is beginning of token - void reset() noexcept - { - token_buffer.clear(); - token_string.clear(); - token_string.push_back(std::char_traits::to_char_type(current)); - } - - /* - @brief get next character from the input - - This function provides the interface to the used input adapter. It does - not throw in case the input reached EOF, but returns a - `std::char_traits::eof()` in that case. Stores the scanned characters - for use in error messages. - - @return character read from the input - */ - char_int_type get() - { - ++position.chars_read_total; - ++position.chars_read_current_line; - - if (next_unget) - { - // just reset the next_unget variable and work with current - next_unget = false; - } - else - { - current = ia.get_character(); - } - - if (JSON_HEDLEY_LIKELY(current != std::char_traits::eof())) - { - token_string.push_back(std::char_traits::to_char_type(current)); - } - - if (current == '\n') - { - ++position.lines_read; - position.chars_read_current_line = 0; - } - - return current; - } - - /*! - @brief unget current character (read it again on next get) - - We implement unget by setting variable next_unget to true. The input is not - changed - we just simulate ungetting by modifying chars_read_total, - chars_read_current_line, and token_string. The next call to get() will - behave as if the unget character is read again. - */ - void unget() - { - next_unget = true; - - --position.chars_read_total; - - // in case we "unget" a newline, we have to also decrement the lines_read - if (position.chars_read_current_line == 0) - { - if (position.lines_read > 0) - { - --position.lines_read; - } - } - else - { - --position.chars_read_current_line; - } - - if (JSON_HEDLEY_LIKELY(current != std::char_traits::eof())) - { - JSON_ASSERT(!token_string.empty()); - token_string.pop_back(); - } - } - - /// add a character to token_buffer - void add(char_int_type c) - { - token_buffer.push_back(static_cast(c)); - } - - public: - ///////////////////// - // value getters - ///////////////////// - - /// return integer value - constexpr number_integer_t get_number_integer() const noexcept - { - return value_integer; - } - - /// return unsigned integer value - constexpr number_unsigned_t get_number_unsigned() const noexcept - { - return value_unsigned; - } - - /// return floating-point value - constexpr number_float_t get_number_float() const noexcept - { - return value_float; - } - - /// return current string value (implicitly resets the token; useful only once) - string_t& get_string() - { - return token_buffer; - } - - ///////////////////// - // diagnostics - ///////////////////// - - /// return position of last read token - constexpr position_t get_position() const noexcept - { - return position; - } - - /// return the last read token (for errors only). Will never contain EOF - /// (an arbitrary value that is not a valid char value, often -1), because - /// 255 may legitimately occur. May contain NUL, which should be escaped. - std::string get_token_string() const - { - // escape control characters - std::string result; - for (const auto c : token_string) - { - if (static_cast(c) <= '\x1F') - { - // escape control characters - std::array cs{{}}; - (std::snprintf)(cs.data(), cs.size(), "", static_cast(c)); - result += cs.data(); - } - else - { - // add character as is - result.push_back(static_cast(c)); - } - } - - return result; - } - - /// return syntax error message - JSON_HEDLEY_RETURNS_NON_NULL - constexpr const char* get_error_message() const noexcept - { - return error_message; - } - - ///////////////////// - // actual scanner - ///////////////////// - - /*! - @brief skip the UTF-8 byte order mark - @return true iff there is no BOM or the correct BOM has been skipped - */ - bool skip_bom() - { - if (get() == 0xEF) - { - // check if we completely parse the BOM - return get() == 0xBB && get() == 0xBF; - } - - // the first character is not the beginning of the BOM; unget it to - // process is later - unget(); - return true; - } - - void skip_whitespace() - { - do - { - get(); - } - while (current == ' ' || current == '\t' || current == '\n' || current == '\r'); - } - - token_type scan() - { - // initially, skip the BOM - if (position.chars_read_total == 0 && !skip_bom()) - { - error_message = "invalid BOM; must be 0xEF 0xBB 0xBF if given"; - return token_type::parse_error; - } - - // read next character and ignore whitespace - skip_whitespace(); - - // ignore comments - while (ignore_comments && current == '/') - { - if (!scan_comment()) - { - return token_type::parse_error; - } - - // skip following whitespace - skip_whitespace(); - } - - switch (current) - { - // structural characters - case '[': - return token_type::begin_array; - case ']': - return token_type::end_array; - case '{': - return token_type::begin_object; - case '}': - return token_type::end_object; - case ':': - return token_type::name_separator; - case ',': - return token_type::value_separator; - - // literals - case 't': - { - std::array true_literal = {{char_type('t'), char_type('r'), char_type('u'), char_type('e')}}; - return scan_literal(true_literal.data(), true_literal.size(), token_type::literal_true); - } - case 'f': - { - std::array false_literal = {{char_type('f'), char_type('a'), char_type('l'), char_type('s'), char_type('e')}}; - return scan_literal(false_literal.data(), false_literal.size(), token_type::literal_false); - } - case 'n': - { - std::array null_literal = {{char_type('n'), char_type('u'), char_type('l'), char_type('l')}}; - return scan_literal(null_literal.data(), null_literal.size(), token_type::literal_null); - } - - // string - case '\"': - return scan_string(); - - // number - case '-': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - return scan_number(); - - // end of input (the null byte is needed when parsing from - // string literals) - case '\0': - case std::char_traits::eof(): - return token_type::end_of_input; - - // error - default: - error_message = "invalid literal"; - return token_type::parse_error; - } - } - - private: - /// input adapter - InputAdapterType ia; - - /// whether comments should be ignored (true) or signaled as errors (false) - const bool ignore_comments = false; - - /// the current character - char_int_type current = std::char_traits::eof(); - - /// whether the next get() call should just return current - bool next_unget = false; - - /// the start position of the current token - position_t position {}; - - /// raw input token string (for error messages) - std::vector token_string {}; - - /// buffer for variable-length tokens (numbers, strings) - string_t token_buffer {}; - - /// a description of occurred lexer errors - const char* error_message = ""; - - // number values - number_integer_t value_integer = 0; - number_unsigned_t value_unsigned = 0; - number_float_t value_float = 0; - - /// the decimal point - const char_int_type decimal_point_char = '.'; -}; -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - - -#include // size_t -#include // declval -#include // string - -// #include - -// #include - - -namespace nlohmann -{ -namespace detail -{ -template -using null_function_t = decltype(std::declval().null()); - -template -using boolean_function_t = - decltype(std::declval().boolean(std::declval())); - -template -using number_integer_function_t = - decltype(std::declval().number_integer(std::declval())); - -template -using number_unsigned_function_t = - decltype(std::declval().number_unsigned(std::declval())); - -template -using number_float_function_t = decltype(std::declval().number_float( - std::declval(), std::declval())); - -template -using string_function_t = - decltype(std::declval().string(std::declval())); - -template -using binary_function_t = - decltype(std::declval().binary(std::declval())); - -template -using start_object_function_t = - decltype(std::declval().start_object(std::declval())); - -template -using key_function_t = - decltype(std::declval().key(std::declval())); - -template -using end_object_function_t = decltype(std::declval().end_object()); - -template -using start_array_function_t = - decltype(std::declval().start_array(std::declval())); - -template -using end_array_function_t = decltype(std::declval().end_array()); - -template -using parse_error_function_t = decltype(std::declval().parse_error( - std::declval(), std::declval(), - std::declval())); - -template -struct is_sax -{ - private: - static_assert(is_basic_json::value, - "BasicJsonType must be of type basic_json<...>"); - - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - using exception_t = typename BasicJsonType::exception; - - public: - static constexpr bool value = - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value && - is_detected_exact::value; -}; - -template -struct is_sax_static_asserts -{ - private: - static_assert(is_basic_json::value, - "BasicJsonType must be of type basic_json<...>"); - - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - using exception_t = typename BasicJsonType::exception; - - public: - static_assert(is_detected_exact::value, - "Missing/invalid function: bool null()"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool boolean(bool)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool boolean(bool)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool number_integer(number_integer_t)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool number_unsigned(number_unsigned_t)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool number_float(number_float_t, const string_t&)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool string(string_t&)"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool binary(binary_t&)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool start_object(std::size_t)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool key(string_t&)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool end_object()"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool start_array(std::size_t)"); - static_assert(is_detected_exact::value, - "Missing/invalid function: bool end_array()"); - static_assert( - is_detected_exact::value, - "Missing/invalid function: bool parse_error(std::size_t, const " - "std::string&, const exception&)"); -}; -} // namespace detail -} // namespace nlohmann - -// #include - - -namespace nlohmann -{ -namespace detail -{ - -/// how to treat CBOR tags -enum class cbor_tag_handler_t -{ - error, ///< throw a parse_error exception in case of a tag - ignore ///< ignore tags -}; - -/*! -@brief determine system byte order - -@return true if and only if system's byte order is little endian - -@note from https://stackoverflow.com/a/1001328/266378 -*/ -static inline bool little_endianess(int num = 1) noexcept -{ - return *reinterpret_cast(&num) == 1; -} - - -/////////////////// -// binary reader // -/////////////////// - -/*! -@brief deserialization of CBOR, MessagePack, and UBJSON values -*/ -template> -class binary_reader -{ - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - using json_sax_t = SAX; - using char_type = typename InputAdapterType::char_type; - using char_int_type = typename std::char_traits::int_type; - - public: - /*! - @brief create a binary reader - - @param[in] adapter input adapter to read from - */ - explicit binary_reader(InputAdapterType&& adapter) : ia(std::move(adapter)) - { - (void)detail::is_sax_static_asserts {}; - } - - // make class move-only - binary_reader(const binary_reader&) = delete; - binary_reader(binary_reader&&) = default; - binary_reader& operator=(const binary_reader&) = delete; - binary_reader& operator=(binary_reader&&) = default; - ~binary_reader() = default; - - /*! - @param[in] format the binary format to parse - @param[in] sax_ a SAX event processor - @param[in] strict whether to expect the input to be consumed completed - @param[in] tag_handler how to treat CBOR tags - - @return - */ - JSON_HEDLEY_NON_NULL(3) - bool sax_parse(const input_format_t format, - json_sax_t* sax_, - const bool strict = true, - const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) - { - sax = sax_; - bool result = false; - - switch (format) - { - case input_format_t::bson: - result = parse_bson_internal(); - break; - - case input_format_t::cbor: - result = parse_cbor_internal(true, tag_handler); - break; - - case input_format_t::msgpack: - result = parse_msgpack_internal(); - break; - - case input_format_t::ubjson: - result = parse_ubjson_internal(); - break; - - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // LCOV_EXCL_LINE - } - - // strict mode: next byte must be EOF - if (result && strict) - { - if (format == input_format_t::ubjson) - { - get_ignore_noop(); - } - else - { - get(); - } - - if (JSON_HEDLEY_UNLIKELY(current != std::char_traits::eof())) - { - return sax->parse_error(chars_read, get_token_string(), - parse_error::create(110, chars_read, exception_message(format, "expected end of input; last byte: 0x" + get_token_string(), "value"), BasicJsonType())); - } - } - - return result; - } - - private: - ////////// - // BSON // - ////////// - - /*! - @brief Reads in a BSON-object and passes it to the SAX-parser. - @return whether a valid BSON-value was passed to the SAX parser - */ - bool parse_bson_internal() - { - std::int32_t document_size{}; - get_number(input_format_t::bson, document_size); - - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1)))) - { - return false; - } - - if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_list(/*is_array*/false))) - { - return false; - } - - return sax->end_object(); - } - - /*! - @brief Parses a C-style string from the BSON input. - @param[in, out] result A reference to the string variable where the read - string is to be stored. - @return `true` if the \x00-byte indicating the end of the string was - encountered before the EOF; false` indicates an unexpected EOF. - */ - bool get_bson_cstr(string_t& result) - { - auto out = std::back_inserter(result); - while (true) - { - get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::bson, "cstring"))) - { - return false; - } - if (current == 0x00) - { - return true; - } - *out++ = static_cast(current); - } - } - - /*! - @brief Parses a zero-terminated string of length @a len from the BSON - input. - @param[in] len The length (including the zero-byte at the end) of the - string to be read. - @param[in, out] result A reference to the string variable where the read - string is to be stored. - @tparam NumberType The type of the length @a len - @pre len >= 1 - @return `true` if the string was successfully parsed - */ - template - bool get_bson_string(const NumberType len, string_t& result) - { - if (JSON_HEDLEY_UNLIKELY(len < 1)) - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "string length must be at least 1, is " + std::to_string(len), "string"), BasicJsonType())); - } - - return get_string(input_format_t::bson, len - static_cast(1), result) && get() != std::char_traits::eof(); - } - - /*! - @brief Parses a byte array input of length @a len from the BSON input. - @param[in] len The length of the byte array to be read. - @param[in, out] result A reference to the binary variable where the read - array is to be stored. - @tparam NumberType The type of the length @a len - @pre len >= 0 - @return `true` if the byte array was successfully parsed - */ - template - bool get_bson_binary(const NumberType len, binary_t& result) - { - if (JSON_HEDLEY_UNLIKELY(len < 0)) - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "byte array length cannot be negative, is " + std::to_string(len), "binary"), BasicJsonType())); - } - - // All BSON binary values have a subtype - std::uint8_t subtype{}; - get_number(input_format_t::bson, subtype); - result.set_subtype(subtype); - - return get_binary(input_format_t::bson, len, result); - } - - /*! - @brief Read a BSON document element of the given @a element_type. - @param[in] element_type The BSON element type, c.f. http://bsonspec.org/spec.html - @param[in] element_type_parse_position The position in the input stream, - where the `element_type` was read. - @warning Not all BSON element types are supported yet. An unsupported - @a element_type will give rise to a parse_error.114: - Unsupported BSON record type 0x... - @return whether a valid BSON-object/array was passed to the SAX parser - */ - bool parse_bson_element_internal(const char_int_type element_type, - const std::size_t element_type_parse_position) - { - switch (element_type) - { - case 0x01: // double - { - double number{}; - return get_number(input_format_t::bson, number) && sax->number_float(static_cast(number), ""); - } - - case 0x02: // string - { - std::int32_t len{}; - string_t value; - return get_number(input_format_t::bson, len) && get_bson_string(len, value) && sax->string(value); - } - - case 0x03: // object - { - return parse_bson_internal(); - } - - case 0x04: // array - { - return parse_bson_array(); - } - - case 0x05: // binary - { - std::int32_t len{}; - binary_t value; - return get_number(input_format_t::bson, len) && get_bson_binary(len, value) && sax->binary(value); - } - - case 0x08: // boolean - { - return sax->boolean(get() != 0); - } - - case 0x0A: // null - { - return sax->null(); - } - - case 0x10: // int32 - { - std::int32_t value{}; - return get_number(input_format_t::bson, value) && sax->number_integer(value); - } - - case 0x12: // int64 - { - std::int64_t value{}; - return get_number(input_format_t::bson, value) && sax->number_integer(value); - } - - default: // anything else not supported (yet) - { - std::array cr{{}}; - (std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(element_type)); - return sax->parse_error(element_type_parse_position, std::string(cr.data()), parse_error::create(114, element_type_parse_position, "Unsupported BSON record type 0x" + std::string(cr.data()), BasicJsonType())); - } - } - } - - /*! - @brief Read a BSON element list (as specified in the BSON-spec) - - The same binary layout is used for objects and arrays, hence it must be - indicated with the argument @a is_array which one is expected - (true --> array, false --> object). - - @param[in] is_array Determines if the element list being read is to be - treated as an object (@a is_array == false), or as an - array (@a is_array == true). - @return whether a valid BSON-object/array was passed to the SAX parser - */ - bool parse_bson_element_list(const bool is_array) - { - string_t key; - - while (auto element_type = get()) - { - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::bson, "element list"))) - { - return false; - } - - const std::size_t element_type_parse_position = chars_read; - if (JSON_HEDLEY_UNLIKELY(!get_bson_cstr(key))) - { - return false; - } - - if (!is_array && !sax->key(key)) - { - return false; - } - - if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position))) - { - return false; - } - - // get_bson_cstr only appends - key.clear(); - } - - return true; - } - - /*! - @brief Reads an array from the BSON input and passes it to the SAX-parser. - @return whether a valid BSON-array was passed to the SAX parser - */ - bool parse_bson_array() - { - std::int32_t document_size{}; - get_number(input_format_t::bson, document_size); - - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1)))) - { - return false; - } - - if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_list(/*is_array*/true))) - { - return false; - } - - return sax->end_array(); - } - - ////////// - // CBOR // - ////////// - - /*! - @param[in] get_char whether a new character should be retrieved from the - input (true) or whether the last read character should - be considered instead (false) - @param[in] tag_handler how CBOR tags should be treated - - @return whether a valid CBOR value was passed to the SAX parser - */ - bool parse_cbor_internal(const bool get_char, - const cbor_tag_handler_t tag_handler) - { - switch (get_char ? get() : current) - { - // EOF - case std::char_traits::eof(): - return unexpect_eof(input_format_t::cbor, "value"); - - // Integer 0x00..0x17 (0..23) - case 0x00: - case 0x01: - case 0x02: - case 0x03: - case 0x04: - case 0x05: - case 0x06: - case 0x07: - case 0x08: - case 0x09: - case 0x0A: - case 0x0B: - case 0x0C: - case 0x0D: - case 0x0E: - case 0x0F: - case 0x10: - case 0x11: - case 0x12: - case 0x13: - case 0x14: - case 0x15: - case 0x16: - case 0x17: - return sax->number_unsigned(static_cast(current)); - - case 0x18: // Unsigned integer (one-byte uint8_t follows) - { - std::uint8_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); - } - - case 0x19: // Unsigned integer (two-byte uint16_t follows) - { - std::uint16_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); - } - - case 0x1A: // Unsigned integer (four-byte uint32_t follows) - { - std::uint32_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); - } - - case 0x1B: // Unsigned integer (eight-byte uint64_t follows) - { - std::uint64_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_unsigned(number); - } - - // Negative integer -1-0x00..-1-0x17 (-1..-24) - case 0x20: - case 0x21: - case 0x22: - case 0x23: - case 0x24: - case 0x25: - case 0x26: - case 0x27: - case 0x28: - case 0x29: - case 0x2A: - case 0x2B: - case 0x2C: - case 0x2D: - case 0x2E: - case 0x2F: - case 0x30: - case 0x31: - case 0x32: - case 0x33: - case 0x34: - case 0x35: - case 0x36: - case 0x37: - return sax->number_integer(static_cast(0x20 - 1 - current)); - - case 0x38: // Negative integer (one-byte uint8_t follows) - { - std::uint8_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast(-1) - number); - } - - case 0x39: // Negative integer -1-n (two-byte uint16_t follows) - { - std::uint16_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast(-1) - number); - } - - case 0x3A: // Negative integer -1-n (four-byte uint32_t follows) - { - std::uint32_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast(-1) - number); - } - - case 0x3B: // Negative integer -1-n (eight-byte uint64_t follows) - { - std::uint64_t number{}; - return get_number(input_format_t::cbor, number) && sax->number_integer(static_cast(-1) - - static_cast(number)); - } - - // Binary data (0x00..0x17 bytes follow) - case 0x40: - case 0x41: - case 0x42: - case 0x43: - case 0x44: - case 0x45: - case 0x46: - case 0x47: - case 0x48: - case 0x49: - case 0x4A: - case 0x4B: - case 0x4C: - case 0x4D: - case 0x4E: - case 0x4F: - case 0x50: - case 0x51: - case 0x52: - case 0x53: - case 0x54: - case 0x55: - case 0x56: - case 0x57: - case 0x58: // Binary data (one-byte uint8_t for n follows) - case 0x59: // Binary data (two-byte uint16_t for n follow) - case 0x5A: // Binary data (four-byte uint32_t for n follow) - case 0x5B: // Binary data (eight-byte uint64_t for n follow) - case 0x5F: // Binary data (indefinite length) - { - binary_t b; - return get_cbor_binary(b) && sax->binary(b); - } - - // UTF-8 string (0x00..0x17 bytes follow) - case 0x60: - case 0x61: - case 0x62: - case 0x63: - case 0x64: - case 0x65: - case 0x66: - case 0x67: - case 0x68: - case 0x69: - case 0x6A: - case 0x6B: - case 0x6C: - case 0x6D: - case 0x6E: - case 0x6F: - case 0x70: - case 0x71: - case 0x72: - case 0x73: - case 0x74: - case 0x75: - case 0x76: - case 0x77: - case 0x78: // UTF-8 string (one-byte uint8_t for n follows) - case 0x79: // UTF-8 string (two-byte uint16_t for n follow) - case 0x7A: // UTF-8 string (four-byte uint32_t for n follow) - case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow) - case 0x7F: // UTF-8 string (indefinite length) - { - string_t s; - return get_cbor_string(s) && sax->string(s); - } - - // array (0x00..0x17 data items follow) - case 0x80: - case 0x81: - case 0x82: - case 0x83: - case 0x84: - case 0x85: - case 0x86: - case 0x87: - case 0x88: - case 0x89: - case 0x8A: - case 0x8B: - case 0x8C: - case 0x8D: - case 0x8E: - case 0x8F: - case 0x90: - case 0x91: - case 0x92: - case 0x93: - case 0x94: - case 0x95: - case 0x96: - case 0x97: - return get_cbor_array(static_cast(static_cast(current) & 0x1Fu), tag_handler); - - case 0x98: // array (one-byte uint8_t for n follows) - { - std::uint8_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast(len), tag_handler); - } - - case 0x99: // array (two-byte uint16_t for n follow) - { - std::uint16_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast(len), tag_handler); - } - - case 0x9A: // array (four-byte uint32_t for n follow) - { - std::uint32_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast(len), tag_handler); - } - - case 0x9B: // array (eight-byte uint64_t for n follow) - { - std::uint64_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_array(static_cast(len), tag_handler); - } - - case 0x9F: // array (indefinite length) - return get_cbor_array(std::size_t(-1), tag_handler); - - // map (0x00..0x17 pairs of data items follow) - case 0xA0: - case 0xA1: - case 0xA2: - case 0xA3: - case 0xA4: - case 0xA5: - case 0xA6: - case 0xA7: - case 0xA8: - case 0xA9: - case 0xAA: - case 0xAB: - case 0xAC: - case 0xAD: - case 0xAE: - case 0xAF: - case 0xB0: - case 0xB1: - case 0xB2: - case 0xB3: - case 0xB4: - case 0xB5: - case 0xB6: - case 0xB7: - return get_cbor_object(static_cast(static_cast(current) & 0x1Fu), tag_handler); - - case 0xB8: // map (one-byte uint8_t for n follows) - { - std::uint8_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast(len), tag_handler); - } - - case 0xB9: // map (two-byte uint16_t for n follow) - { - std::uint16_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast(len), tag_handler); - } - - case 0xBA: // map (four-byte uint32_t for n follow) - { - std::uint32_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast(len), tag_handler); - } - - case 0xBB: // map (eight-byte uint64_t for n follow) - { - std::uint64_t len{}; - return get_number(input_format_t::cbor, len) && get_cbor_object(static_cast(len), tag_handler); - } - - case 0xBF: // map (indefinite length) - return get_cbor_object(std::size_t(-1), tag_handler); - - case 0xC6: // tagged item - case 0xC7: - case 0xC8: - case 0xC9: - case 0xCA: - case 0xCB: - case 0xCC: - case 0xCD: - case 0xCE: - case 0xCF: - case 0xD0: - case 0xD1: - case 0xD2: - case 0xD3: - case 0xD4: - case 0xD8: // tagged item (1 bytes follow) - case 0xD9: // tagged item (2 bytes follow) - case 0xDA: // tagged item (4 bytes follow) - case 0xDB: // tagged item (8 bytes follow) - { - switch (tag_handler) - { - case cbor_tag_handler_t::error: - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::cbor, "invalid byte: 0x" + last_token, "value"), BasicJsonType())); - } - - case cbor_tag_handler_t::ignore: - { - switch (current) - { - case 0xD8: - { - std::uint8_t len{}; - get_number(input_format_t::cbor, len); - break; - } - case 0xD9: - { - std::uint16_t len{}; - get_number(input_format_t::cbor, len); - break; - } - case 0xDA: - { - std::uint32_t len{}; - get_number(input_format_t::cbor, len); - break; - } - case 0xDB: - { - std::uint64_t len{}; - get_number(input_format_t::cbor, len); - break; - } - default: - break; - } - return parse_cbor_internal(true, tag_handler); - } - - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // LCOV_EXCL_LINE - return false; // LCOV_EXCL_LINE - } - } - - case 0xF4: // false - return sax->boolean(false); - - case 0xF5: // true - return sax->boolean(true); - - case 0xF6: // null - return sax->null(); - - case 0xF9: // Half-Precision Float (two-byte IEEE 754) - { - const auto byte1_raw = get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "number"))) - { - return false; - } - const auto byte2_raw = get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "number"))) - { - return false; - } - - const auto byte1 = static_cast(byte1_raw); - const auto byte2 = static_cast(byte2_raw); - - // code from RFC 7049, Appendix D, Figure 3: - // As half-precision floating-point numbers were only added - // to IEEE 754 in 2008, today's programming platforms often - // still only have limited support for them. It is very - // easy to include at least decoding support for them even - // without such support. An example of a small decoder for - // half-precision floating-point numbers in the C language - // is shown in Fig. 3. - const auto half = static_cast((byte1 << 8u) + byte2); - const double val = [&half] - { - const int exp = (half >> 10u) & 0x1Fu; - const unsigned int mant = half & 0x3FFu; - JSON_ASSERT(0 <= exp&& exp <= 32); - JSON_ASSERT(mant <= 1024); - switch (exp) - { - case 0: - return std::ldexp(mant, -24); - case 31: - return (mant == 0) - ? std::numeric_limits::infinity() - : std::numeric_limits::quiet_NaN(); - default: - return std::ldexp(mant + 1024, exp - 25); - } - }(); - return sax->number_float((half & 0x8000u) != 0 - ? static_cast(-val) - : static_cast(val), ""); - } - - case 0xFA: // Single-Precision Float (four-byte IEEE 754) - { - float number{}; - return get_number(input_format_t::cbor, number) && sax->number_float(static_cast(number), ""); - } - - case 0xFB: // Double-Precision Float (eight-byte IEEE 754) - { - double number{}; - return get_number(input_format_t::cbor, number) && sax->number_float(static_cast(number), ""); - } - - default: // anything else (0xFF is handled inside the other types) - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::cbor, "invalid byte: 0x" + last_token, "value"), BasicJsonType())); - } - } - } - - /*! - @brief reads a CBOR string - - This function first reads starting bytes to determine the expected - string length and then copies this number of bytes into a string. - Additionally, CBOR's strings with indefinite lengths are supported. - - @param[out] result created string - - @return whether string creation completed - */ - bool get_cbor_string(string_t& result) - { - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "string"))) - { - return false; - } - - switch (current) - { - // UTF-8 string (0x00..0x17 bytes follow) - case 0x60: - case 0x61: - case 0x62: - case 0x63: - case 0x64: - case 0x65: - case 0x66: - case 0x67: - case 0x68: - case 0x69: - case 0x6A: - case 0x6B: - case 0x6C: - case 0x6D: - case 0x6E: - case 0x6F: - case 0x70: - case 0x71: - case 0x72: - case 0x73: - case 0x74: - case 0x75: - case 0x76: - case 0x77: - { - return get_string(input_format_t::cbor, static_cast(current) & 0x1Fu, result); - } - - case 0x78: // UTF-8 string (one-byte uint8_t for n follows) - { - std::uint8_t len{}; - return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); - } - - case 0x79: // UTF-8 string (two-byte uint16_t for n follow) - { - std::uint16_t len{}; - return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); - } - - case 0x7A: // UTF-8 string (four-byte uint32_t for n follow) - { - std::uint32_t len{}; - return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); - } - - case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow) - { - std::uint64_t len{}; - return get_number(input_format_t::cbor, len) && get_string(input_format_t::cbor, len, result); - } - - case 0x7F: // UTF-8 string (indefinite length) - { - while (get() != 0xFF) - { - string_t chunk; - if (!get_cbor_string(chunk)) - { - return false; - } - result.append(chunk); - } - return true; - } - - default: - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::cbor, "expected length specification (0x60-0x7B) or indefinite string type (0x7F); last byte: 0x" + last_token, "string"), BasicJsonType())); - } - } - } - - /*! - @brief reads a CBOR byte array - - This function first reads starting bytes to determine the expected - byte array length and then copies this number of bytes into the byte array. - Additionally, CBOR's byte arrays with indefinite lengths are supported. - - @param[out] result created byte array - - @return whether byte array creation completed - */ - bool get_cbor_binary(binary_t& result) - { - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::cbor, "binary"))) - { - return false; - } - - switch (current) - { - // Binary data (0x00..0x17 bytes follow) - case 0x40: - case 0x41: - case 0x42: - case 0x43: - case 0x44: - case 0x45: - case 0x46: - case 0x47: - case 0x48: - case 0x49: - case 0x4A: - case 0x4B: - case 0x4C: - case 0x4D: - case 0x4E: - case 0x4F: - case 0x50: - case 0x51: - case 0x52: - case 0x53: - case 0x54: - case 0x55: - case 0x56: - case 0x57: - { - return get_binary(input_format_t::cbor, static_cast(current) & 0x1Fu, result); - } - - case 0x58: // Binary data (one-byte uint8_t for n follows) - { - std::uint8_t len{}; - return get_number(input_format_t::cbor, len) && - get_binary(input_format_t::cbor, len, result); - } - - case 0x59: // Binary data (two-byte uint16_t for n follow) - { - std::uint16_t len{}; - return get_number(input_format_t::cbor, len) && - get_binary(input_format_t::cbor, len, result); - } - - case 0x5A: // Binary data (four-byte uint32_t for n follow) - { - std::uint32_t len{}; - return get_number(input_format_t::cbor, len) && - get_binary(input_format_t::cbor, len, result); - } - - case 0x5B: // Binary data (eight-byte uint64_t for n follow) - { - std::uint64_t len{}; - return get_number(input_format_t::cbor, len) && - get_binary(input_format_t::cbor, len, result); - } - - case 0x5F: // Binary data (indefinite length) - { - while (get() != 0xFF) - { - binary_t chunk; - if (!get_cbor_binary(chunk)) - { - return false; - } - result.insert(result.end(), chunk.begin(), chunk.end()); - } - return true; - } - - default: - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::cbor, "expected length specification (0x40-0x5B) or indefinite binary array type (0x5F); last byte: 0x" + last_token, "binary"), BasicJsonType())); - } - } - } - - /*! - @param[in] len the length of the array or std::size_t(-1) for an - array of indefinite size - @param[in] tag_handler how CBOR tags should be treated - @return whether array creation completed - */ - bool get_cbor_array(const std::size_t len, - const cbor_tag_handler_t tag_handler) - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(len))) - { - return false; - } - - if (len != std::size_t(-1)) - { - for (std::size_t i = 0; i < len; ++i) - { - if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler))) - { - return false; - } - } - } - else - { - while (get() != 0xFF) - { - if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(false, tag_handler))) - { - return false; - } - } - } - - return sax->end_array(); - } - - /*! - @param[in] len the length of the object or std::size_t(-1) for an - object of indefinite size - @param[in] tag_handler how CBOR tags should be treated - @return whether object creation completed - */ - bool get_cbor_object(const std::size_t len, - const cbor_tag_handler_t tag_handler) - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(len))) - { - return false; - } - - string_t key; - if (len != std::size_t(-1)) - { - for (std::size_t i = 0; i < len; ++i) - { - get(); - if (JSON_HEDLEY_UNLIKELY(!get_cbor_string(key) || !sax->key(key))) - { - return false; - } - - if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler))) - { - return false; - } - key.clear(); - } - } - else - { - while (get() != 0xFF) - { - if (JSON_HEDLEY_UNLIKELY(!get_cbor_string(key) || !sax->key(key))) - { - return false; - } - - if (JSON_HEDLEY_UNLIKELY(!parse_cbor_internal(true, tag_handler))) - { - return false; - } - key.clear(); - } - } - - return sax->end_object(); - } - - ///////////// - // MsgPack // - ///////////// - - /*! - @return whether a valid MessagePack value was passed to the SAX parser - */ - bool parse_msgpack_internal() - { - switch (get()) - { - // EOF - case std::char_traits::eof(): - return unexpect_eof(input_format_t::msgpack, "value"); - - // positive fixint - case 0x00: - case 0x01: - case 0x02: - case 0x03: - case 0x04: - case 0x05: - case 0x06: - case 0x07: - case 0x08: - case 0x09: - case 0x0A: - case 0x0B: - case 0x0C: - case 0x0D: - case 0x0E: - case 0x0F: - case 0x10: - case 0x11: - case 0x12: - case 0x13: - case 0x14: - case 0x15: - case 0x16: - case 0x17: - case 0x18: - case 0x19: - case 0x1A: - case 0x1B: - case 0x1C: - case 0x1D: - case 0x1E: - case 0x1F: - case 0x20: - case 0x21: - case 0x22: - case 0x23: - case 0x24: - case 0x25: - case 0x26: - case 0x27: - case 0x28: - case 0x29: - case 0x2A: - case 0x2B: - case 0x2C: - case 0x2D: - case 0x2E: - case 0x2F: - case 0x30: - case 0x31: - case 0x32: - case 0x33: - case 0x34: - case 0x35: - case 0x36: - case 0x37: - case 0x38: - case 0x39: - case 0x3A: - case 0x3B: - case 0x3C: - case 0x3D: - case 0x3E: - case 0x3F: - case 0x40: - case 0x41: - case 0x42: - case 0x43: - case 0x44: - case 0x45: - case 0x46: - case 0x47: - case 0x48: - case 0x49: - case 0x4A: - case 0x4B: - case 0x4C: - case 0x4D: - case 0x4E: - case 0x4F: - case 0x50: - case 0x51: - case 0x52: - case 0x53: - case 0x54: - case 0x55: - case 0x56: - case 0x57: - case 0x58: - case 0x59: - case 0x5A: - case 0x5B: - case 0x5C: - case 0x5D: - case 0x5E: - case 0x5F: - case 0x60: - case 0x61: - case 0x62: - case 0x63: - case 0x64: - case 0x65: - case 0x66: - case 0x67: - case 0x68: - case 0x69: - case 0x6A: - case 0x6B: - case 0x6C: - case 0x6D: - case 0x6E: - case 0x6F: - case 0x70: - case 0x71: - case 0x72: - case 0x73: - case 0x74: - case 0x75: - case 0x76: - case 0x77: - case 0x78: - case 0x79: - case 0x7A: - case 0x7B: - case 0x7C: - case 0x7D: - case 0x7E: - case 0x7F: - return sax->number_unsigned(static_cast(current)); - - // fixmap - case 0x80: - case 0x81: - case 0x82: - case 0x83: - case 0x84: - case 0x85: - case 0x86: - case 0x87: - case 0x88: - case 0x89: - case 0x8A: - case 0x8B: - case 0x8C: - case 0x8D: - case 0x8E: - case 0x8F: - return get_msgpack_object(static_cast(static_cast(current) & 0x0Fu)); - - // fixarray - case 0x90: - case 0x91: - case 0x92: - case 0x93: - case 0x94: - case 0x95: - case 0x96: - case 0x97: - case 0x98: - case 0x99: - case 0x9A: - case 0x9B: - case 0x9C: - case 0x9D: - case 0x9E: - case 0x9F: - return get_msgpack_array(static_cast(static_cast(current) & 0x0Fu)); - - // fixstr - case 0xA0: - case 0xA1: - case 0xA2: - case 0xA3: - case 0xA4: - case 0xA5: - case 0xA6: - case 0xA7: - case 0xA8: - case 0xA9: - case 0xAA: - case 0xAB: - case 0xAC: - case 0xAD: - case 0xAE: - case 0xAF: - case 0xB0: - case 0xB1: - case 0xB2: - case 0xB3: - case 0xB4: - case 0xB5: - case 0xB6: - case 0xB7: - case 0xB8: - case 0xB9: - case 0xBA: - case 0xBB: - case 0xBC: - case 0xBD: - case 0xBE: - case 0xBF: - case 0xD9: // str 8 - case 0xDA: // str 16 - case 0xDB: // str 32 - { - string_t s; - return get_msgpack_string(s) && sax->string(s); - } - - case 0xC0: // nil - return sax->null(); - - case 0xC2: // false - return sax->boolean(false); - - case 0xC3: // true - return sax->boolean(true); - - case 0xC4: // bin 8 - case 0xC5: // bin 16 - case 0xC6: // bin 32 - case 0xC7: // ext 8 - case 0xC8: // ext 16 - case 0xC9: // ext 32 - case 0xD4: // fixext 1 - case 0xD5: // fixext 2 - case 0xD6: // fixext 4 - case 0xD7: // fixext 8 - case 0xD8: // fixext 16 - { - binary_t b; - return get_msgpack_binary(b) && sax->binary(b); - } - - case 0xCA: // float 32 - { - float number{}; - return get_number(input_format_t::msgpack, number) && sax->number_float(static_cast(number), ""); - } - - case 0xCB: // float 64 - { - double number{}; - return get_number(input_format_t::msgpack, number) && sax->number_float(static_cast(number), ""); - } - - case 0xCC: // uint 8 - { - std::uint8_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); - } - - case 0xCD: // uint 16 - { - std::uint16_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); - } - - case 0xCE: // uint 32 - { - std::uint32_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); - } - - case 0xCF: // uint 64 - { - std::uint64_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_unsigned(number); - } - - case 0xD0: // int 8 - { - std::int8_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_integer(number); - } - - case 0xD1: // int 16 - { - std::int16_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_integer(number); - } - - case 0xD2: // int 32 - { - std::int32_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_integer(number); - } - - case 0xD3: // int 64 - { - std::int64_t number{}; - return get_number(input_format_t::msgpack, number) && sax->number_integer(number); - } - - case 0xDC: // array 16 - { - std::uint16_t len{}; - return get_number(input_format_t::msgpack, len) && get_msgpack_array(static_cast(len)); - } - - case 0xDD: // array 32 - { - std::uint32_t len{}; - return get_number(input_format_t::msgpack, len) && get_msgpack_array(static_cast(len)); - } - - case 0xDE: // map 16 - { - std::uint16_t len{}; - return get_number(input_format_t::msgpack, len) && get_msgpack_object(static_cast(len)); - } - - case 0xDF: // map 32 - { - std::uint32_t len{}; - return get_number(input_format_t::msgpack, len) && get_msgpack_object(static_cast(len)); - } - - // negative fixint - case 0xE0: - case 0xE1: - case 0xE2: - case 0xE3: - case 0xE4: - case 0xE5: - case 0xE6: - case 0xE7: - case 0xE8: - case 0xE9: - case 0xEA: - case 0xEB: - case 0xEC: - case 0xED: - case 0xEE: - case 0xEF: - case 0xF0: - case 0xF1: - case 0xF2: - case 0xF3: - case 0xF4: - case 0xF5: - case 0xF6: - case 0xF7: - case 0xF8: - case 0xF9: - case 0xFA: - case 0xFB: - case 0xFC: - case 0xFD: - case 0xFE: - case 0xFF: - return sax->number_integer(static_cast(current)); - - default: // anything else - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::msgpack, "invalid byte: 0x" + last_token, "value"), BasicJsonType())); - } - } - } - - /*! - @brief reads a MessagePack string - - This function first reads starting bytes to determine the expected - string length and then copies this number of bytes into a string. - - @param[out] result created string - - @return whether string creation completed - */ - bool get_msgpack_string(string_t& result) - { - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::msgpack, "string"))) - { - return false; - } - - switch (current) - { - // fixstr - case 0xA0: - case 0xA1: - case 0xA2: - case 0xA3: - case 0xA4: - case 0xA5: - case 0xA6: - case 0xA7: - case 0xA8: - case 0xA9: - case 0xAA: - case 0xAB: - case 0xAC: - case 0xAD: - case 0xAE: - case 0xAF: - case 0xB0: - case 0xB1: - case 0xB2: - case 0xB3: - case 0xB4: - case 0xB5: - case 0xB6: - case 0xB7: - case 0xB8: - case 0xB9: - case 0xBA: - case 0xBB: - case 0xBC: - case 0xBD: - case 0xBE: - case 0xBF: - { - return get_string(input_format_t::msgpack, static_cast(current) & 0x1Fu, result); - } - - case 0xD9: // str 8 - { - std::uint8_t len{}; - return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result); - } - - case 0xDA: // str 16 - { - std::uint16_t len{}; - return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result); - } - - case 0xDB: // str 32 - { - std::uint32_t len{}; - return get_number(input_format_t::msgpack, len) && get_string(input_format_t::msgpack, len, result); - } - - default: - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::msgpack, "expected length specification (0xA0-0xBF, 0xD9-0xDB); last byte: 0x" + last_token, "string"), BasicJsonType())); - } - } - } - - /*! - @brief reads a MessagePack byte array - - This function first reads starting bytes to determine the expected - byte array length and then copies this number of bytes into a byte array. - - @param[out] result created byte array - - @return whether byte array creation completed - */ - bool get_msgpack_binary(binary_t& result) - { - // helper function to set the subtype - auto assign_and_return_true = [&result](std::int8_t subtype) - { - result.set_subtype(static_cast(subtype)); - return true; - }; - - switch (current) - { - case 0xC4: // bin 8 - { - std::uint8_t len{}; - return get_number(input_format_t::msgpack, len) && - get_binary(input_format_t::msgpack, len, result); - } - - case 0xC5: // bin 16 - { - std::uint16_t len{}; - return get_number(input_format_t::msgpack, len) && - get_binary(input_format_t::msgpack, len, result); - } - - case 0xC6: // bin 32 - { - std::uint32_t len{}; - return get_number(input_format_t::msgpack, len) && - get_binary(input_format_t::msgpack, len, result); - } - - case 0xC7: // ext 8 - { - std::uint8_t len{}; - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, len) && - get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, len, result) && - assign_and_return_true(subtype); - } - - case 0xC8: // ext 16 - { - std::uint16_t len{}; - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, len) && - get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, len, result) && - assign_and_return_true(subtype); - } - - case 0xC9: // ext 32 - { - std::uint32_t len{}; - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, len) && - get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, len, result) && - assign_and_return_true(subtype); - } - - case 0xD4: // fixext 1 - { - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 1, result) && - assign_and_return_true(subtype); - } - - case 0xD5: // fixext 2 - { - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 2, result) && - assign_and_return_true(subtype); - } - - case 0xD6: // fixext 4 - { - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 4, result) && - assign_and_return_true(subtype); - } - - case 0xD7: // fixext 8 - { - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 8, result) && - assign_and_return_true(subtype); - } - - case 0xD8: // fixext 16 - { - std::int8_t subtype{}; - return get_number(input_format_t::msgpack, subtype) && - get_binary(input_format_t::msgpack, 16, result) && - assign_and_return_true(subtype); - } - - default: // LCOV_EXCL_LINE - return false; // LCOV_EXCL_LINE - } - } - - /*! - @param[in] len the length of the array - @return whether array creation completed - */ - bool get_msgpack_array(const std::size_t len) - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(len))) - { - return false; - } - - for (std::size_t i = 0; i < len; ++i) - { - if (JSON_HEDLEY_UNLIKELY(!parse_msgpack_internal())) - { - return false; - } - } - - return sax->end_array(); - } - - /*! - @param[in] len the length of the object - @return whether object creation completed - */ - bool get_msgpack_object(const std::size_t len) - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(len))) - { - return false; - } - - string_t key; - for (std::size_t i = 0; i < len; ++i) - { - get(); - if (JSON_HEDLEY_UNLIKELY(!get_msgpack_string(key) || !sax->key(key))) - { - return false; - } - - if (JSON_HEDLEY_UNLIKELY(!parse_msgpack_internal())) - { - return false; - } - key.clear(); - } - - return sax->end_object(); - } - - //////////// - // UBJSON // - //////////// - - /*! - @param[in] get_char whether a new character should be retrieved from the - input (true, default) or whether the last read - character should be considered instead - - @return whether a valid UBJSON value was passed to the SAX parser - */ - bool parse_ubjson_internal(const bool get_char = true) - { - return get_ubjson_value(get_char ? get_ignore_noop() : current); - } - - /*! - @brief reads a UBJSON string - - This function is either called after reading the 'S' byte explicitly - indicating a string, or in case of an object key where the 'S' byte can be - left out. - - @param[out] result created string - @param[in] get_char whether a new character should be retrieved from the - input (true, default) or whether the last read - character should be considered instead - - @return whether string creation completed - */ - bool get_ubjson_string(string_t& result, const bool get_char = true) - { - if (get_char) - { - get(); // TODO(niels): may we ignore N here? - } - - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "value"))) - { - return false; - } - - switch (current) - { - case 'U': - { - std::uint8_t len{}; - return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); - } - - case 'i': - { - std::int8_t len{}; - return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); - } - - case 'I': - { - std::int16_t len{}; - return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); - } - - case 'l': - { - std::int32_t len{}; - return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); - } - - case 'L': - { - std::int64_t len{}; - return get_number(input_format_t::ubjson, len) && get_string(input_format_t::ubjson, len, result); - } - - default: - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "expected length type specification (U, i, I, l, L); last byte: 0x" + last_token, "string"), BasicJsonType())); - } - } - - /*! - @param[out] result determined size - @return whether size determination completed - */ - bool get_ubjson_size_value(std::size_t& result) - { - switch (get_ignore_noop()) - { - case 'U': - { - std::uint8_t number{}; - if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number))) - { - return false; - } - result = static_cast(number); - return true; - } - - case 'i': - { - std::int8_t number{}; - if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number))) - { - return false; - } - result = static_cast(number); - return true; - } - - case 'I': - { - std::int16_t number{}; - if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number))) - { - return false; - } - result = static_cast(number); - return true; - } - - case 'l': - { - std::int32_t number{}; - if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number))) - { - return false; - } - result = static_cast(number); - return true; - } - - case 'L': - { - std::int64_t number{}; - if (JSON_HEDLEY_UNLIKELY(!get_number(input_format_t::ubjson, number))) - { - return false; - } - result = static_cast(number); - return true; - } - - default: - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "expected length type specification (U, i, I, l, L) after '#'; last byte: 0x" + last_token, "size"), BasicJsonType())); - } - } - } - - /*! - @brief determine the type and size for a container - - In the optimized UBJSON format, a type and a size can be provided to allow - for a more compact representation. - - @param[out] result pair of the size and the type - - @return whether pair creation completed - */ - bool get_ubjson_size_type(std::pair& result) - { - result.first = string_t::npos; // size - result.second = 0; // type - - get_ignore_noop(); - - if (current == '$') - { - result.second = get(); // must not ignore 'N', because 'N' maybe the type - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "type"))) - { - return false; - } - - get_ignore_noop(); - if (JSON_HEDLEY_UNLIKELY(current != '#')) - { - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "value"))) - { - return false; - } - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::ubjson, "expected '#' after type information; last byte: 0x" + last_token, "size"), BasicJsonType())); - } - - return get_ubjson_size_value(result.first); - } - - if (current == '#') - { - return get_ubjson_size_value(result.first); - } - - return true; - } - - /*! - @param prefix the previously read or set type prefix - @return whether value creation completed - */ - bool get_ubjson_value(const char_int_type prefix) - { - switch (prefix) - { - case std::char_traits::eof(): // EOF - return unexpect_eof(input_format_t::ubjson, "value"); - - case 'T': // true - return sax->boolean(true); - case 'F': // false - return sax->boolean(false); - - case 'Z': // null - return sax->null(); - - case 'U': - { - std::uint8_t number{}; - return get_number(input_format_t::ubjson, number) && sax->number_unsigned(number); - } - - case 'i': - { - std::int8_t number{}; - return get_number(input_format_t::ubjson, number) && sax->number_integer(number); - } - - case 'I': - { - std::int16_t number{}; - return get_number(input_format_t::ubjson, number) && sax->number_integer(number); - } - - case 'l': - { - std::int32_t number{}; - return get_number(input_format_t::ubjson, number) && sax->number_integer(number); - } - - case 'L': - { - std::int64_t number{}; - return get_number(input_format_t::ubjson, number) && sax->number_integer(number); - } - - case 'd': - { - float number{}; - return get_number(input_format_t::ubjson, number) && sax->number_float(static_cast(number), ""); - } - - case 'D': - { - double number{}; - return get_number(input_format_t::ubjson, number) && sax->number_float(static_cast(number), ""); - } - - case 'H': - { - return get_ubjson_high_precision_number(); - } - - case 'C': // char - { - get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "char"))) - { - return false; - } - if (JSON_HEDLEY_UNLIKELY(current > 127)) - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "byte after 'C' must be in range 0x00..0x7F; last byte: 0x" + last_token, "char"), BasicJsonType())); - } - string_t s(1, static_cast(current)); - return sax->string(s); - } - - case 'S': // string - { - string_t s; - return get_ubjson_string(s) && sax->string(s); - } - - case '[': // array - return get_ubjson_array(); - - case '{': // object - return get_ubjson_object(); - - default: // anything else - { - auto last_token = get_token_string(); - return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::ubjson, "invalid byte: 0x" + last_token, "value"), BasicJsonType())); - } - } - } - - /*! - @return whether array creation completed - */ - bool get_ubjson_array() - { - std::pair size_and_type; - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_type(size_and_type))) - { - return false; - } - - if (size_and_type.first != string_t::npos) - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(size_and_type.first))) - { - return false; - } - - if (size_and_type.second != 0) - { - if (size_and_type.second != 'N') - { - for (std::size_t i = 0; i < size_and_type.first; ++i) - { - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_value(size_and_type.second))) - { - return false; - } - } - } - } - else - { - for (std::size_t i = 0; i < size_and_type.first; ++i) - { - if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal())) - { - return false; - } - } - } - } - else - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1)))) - { - return false; - } - - while (current != ']') - { - if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal(false))) - { - return false; - } - get_ignore_noop(); - } - } - - return sax->end_array(); - } - - /*! - @return whether object creation completed - */ - bool get_ubjson_object() - { - std::pair size_and_type; - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_size_type(size_and_type))) - { - return false; - } - - string_t key; - if (size_and_type.first != string_t::npos) - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(size_and_type.first))) - { - return false; - } - - if (size_and_type.second != 0) - { - for (std::size_t i = 0; i < size_and_type.first; ++i) - { - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_string(key) || !sax->key(key))) - { - return false; - } - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_value(size_and_type.second))) - { - return false; - } - key.clear(); - } - } - else - { - for (std::size_t i = 0; i < size_and_type.first; ++i) - { - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_string(key) || !sax->key(key))) - { - return false; - } - if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal())) - { - return false; - } - key.clear(); - } - } - } - else - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1)))) - { - return false; - } - - while (current != '}') - { - if (JSON_HEDLEY_UNLIKELY(!get_ubjson_string(key, false) || !sax->key(key))) - { - return false; - } - if (JSON_HEDLEY_UNLIKELY(!parse_ubjson_internal())) - { - return false; - } - get_ignore_noop(); - key.clear(); - } - } - - return sax->end_object(); - } - - // Note, no reader for UBJSON binary types is implemented because they do - // not exist - - bool get_ubjson_high_precision_number() - { - // get size of following number string - std::size_t size{}; - auto res = get_ubjson_size_value(size); - if (JSON_HEDLEY_UNLIKELY(!res)) - { - return res; - } - - // get number string - std::vector number_vector; - for (std::size_t i = 0; i < size; ++i) - { - get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::ubjson, "number"))) - { - return false; - } - number_vector.push_back(static_cast(current)); - } - - // parse number string - auto number_ia = detail::input_adapter(std::forward(number_vector)); - auto number_lexer = detail::lexer(std::move(number_ia), false); - const auto result_number = number_lexer.scan(); - const auto number_string = number_lexer.get_token_string(); - const auto result_remainder = number_lexer.scan(); - - using token_type = typename detail::lexer_base::token_type; - - if (JSON_HEDLEY_UNLIKELY(result_remainder != token_type::end_of_input)) - { - return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read, exception_message(input_format_t::ubjson, "invalid number text: " + number_lexer.get_token_string(), "high-precision number"), BasicJsonType())); - } - - switch (result_number) - { - case token_type::value_integer: - return sax->number_integer(number_lexer.get_number_integer()); - case token_type::value_unsigned: - return sax->number_unsigned(number_lexer.get_number_unsigned()); - case token_type::value_float: - return sax->number_float(number_lexer.get_number_float(), std::move(number_string)); - default: - return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read, exception_message(input_format_t::ubjson, "invalid number text: " + number_lexer.get_token_string(), "high-precision number"), BasicJsonType())); - } - } - - /////////////////////// - // Utility functions // - /////////////////////// - - /*! - @brief get next character from the input - - This function provides the interface to the used input adapter. It does - not throw in case the input reached EOF, but returns a -'ve valued - `std::char_traits::eof()` in that case. - - @return character read from the input - */ - char_int_type get() - { - ++chars_read; - return current = ia.get_character(); - } - - /*! - @return character read from the input after ignoring all 'N' entries - */ - char_int_type get_ignore_noop() - { - do - { - get(); - } - while (current == 'N'); - - return current; - } - - /* - @brief read a number from the input - - @tparam NumberType the type of the number - @param[in] format the current format (for diagnostics) - @param[out] result number of type @a NumberType - - @return whether conversion completed - - @note This function needs to respect the system's endianess, because - bytes in CBOR, MessagePack, and UBJSON are stored in network order - (big endian) and therefore need reordering on little endian systems. - */ - template - bool get_number(const input_format_t format, NumberType& result) - { - // step 1: read input into array with system's byte order - std::array vec; - for (std::size_t i = 0; i < sizeof(NumberType); ++i) - { - get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "number"))) - { - return false; - } - - // reverse byte order prior to conversion if necessary - if (is_little_endian != InputIsLittleEndian) - { - vec[sizeof(NumberType) - i - 1] = static_cast(current); - } - else - { - vec[i] = static_cast(current); // LCOV_EXCL_LINE - } - } - - // step 2: convert array into number of type T and return - std::memcpy(&result, vec.data(), sizeof(NumberType)); - return true; - } - - /*! - @brief create a string by reading characters from the input - - @tparam NumberType the type of the number - @param[in] format the current format (for diagnostics) - @param[in] len number of characters to read - @param[out] result string created by reading @a len bytes - - @return whether string creation completed - - @note We can not reserve @a len bytes for the result, because @a len - may be too large. Usually, @ref unexpect_eof() detects the end of - the input before we run out of string memory. - */ - template - bool get_string(const input_format_t format, - const NumberType len, - string_t& result) - { - bool success = true; - for (NumberType i = 0; i < len; i++) - { - get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "string"))) - { - success = false; - break; - } - result.push_back(static_cast(current)); - } - return success; - } - - /*! - @brief create a byte array by reading bytes from the input - - @tparam NumberType the type of the number - @param[in] format the current format (for diagnostics) - @param[in] len number of bytes to read - @param[out] result byte array created by reading @a len bytes - - @return whether byte array creation completed - - @note We can not reserve @a len bytes for the result, because @a len - may be too large. Usually, @ref unexpect_eof() detects the end of - the input before we run out of memory. - */ - template - bool get_binary(const input_format_t format, - const NumberType len, - binary_t& result) - { - bool success = true; - for (NumberType i = 0; i < len; i++) - { - get(); - if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(format, "binary"))) - { - success = false; - break; - } - result.push_back(static_cast(current)); - } - return success; - } - - /*! - @param[in] format the current format (for diagnostics) - @param[in] context further context information (for diagnostics) - @return whether the last read character is not EOF - */ - JSON_HEDLEY_NON_NULL(3) - bool unexpect_eof(const input_format_t format, const char* context) const - { - if (JSON_HEDLEY_UNLIKELY(current == std::char_traits::eof())) - { - return sax->parse_error(chars_read, "", - parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context), BasicJsonType())); - } - return true; - } - - /*! - @return a string representation of the last read byte - */ - std::string get_token_string() const - { - std::array cr{{}}; - (std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast(current)); - return std::string{cr.data()}; - } - - /*! - @param[in] format the current format - @param[in] detail a detailed error message - @param[in] context further context information - @return a message string to use in the parse_error exceptions - */ - std::string exception_message(const input_format_t format, - const std::string& detail, - const std::string& context) const - { - std::string error_msg = "syntax error while parsing "; - - switch (format) - { - case input_format_t::cbor: - error_msg += "CBOR"; - break; - - case input_format_t::msgpack: - error_msg += "MessagePack"; - break; - - case input_format_t::ubjson: - error_msg += "UBJSON"; - break; - - case input_format_t::bson: - error_msg += "BSON"; - break; - - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // LCOV_EXCL_LINE - } - - return error_msg + " " + context + ": " + detail; - } - - private: - /// input adapter - InputAdapterType ia; - - /// the current character - char_int_type current = std::char_traits::eof(); - - /// the number of characters read - std::size_t chars_read = 0; - - /// whether we can assume little endianess - const bool is_little_endian = little_endianess(); - - /// the SAX parser - json_sax_t* sax = nullptr; -}; -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - -// #include - - -#include // isfinite -#include // uint8_t -#include // function -#include // string -#include // move -#include // vector - -// #include - -// #include - -// #include - -// #include - -// #include - -// #include - -// #include - - -namespace nlohmann -{ -namespace detail -{ -//////////// -// parser // -//////////// - -enum class parse_event_t : uint8_t -{ - /// the parser read `{` and started to process a JSON object - object_start, - /// the parser read `}` and finished processing a JSON object - object_end, - /// the parser read `[` and started to process a JSON array - array_start, - /// the parser read `]` and finished processing a JSON array - array_end, - /// the parser read a key of a value in an object - key, - /// the parser finished reading a JSON value - value -}; - -template -using parser_callback_t = - std::function; - -/*! -@brief syntax analysis - -This class implements a recursive descent parser. -*/ -template -class parser -{ - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using number_float_t = typename BasicJsonType::number_float_t; - using string_t = typename BasicJsonType::string_t; - using lexer_t = lexer; - using token_type = typename lexer_t::token_type; - - public: - /// a parser reading from an input adapter - explicit parser(InputAdapterType&& adapter, - const parser_callback_t cb = nullptr, - const bool allow_exceptions_ = true, - const bool skip_comments = false) - : callback(cb) - , m_lexer(std::move(adapter), skip_comments) - , allow_exceptions(allow_exceptions_) - { - // read first token - get_token(); - } - - /*! - @brief public parser interface - - @param[in] strict whether to expect the last token to be EOF - @param[in,out] result parsed JSON value - - @throw parse_error.101 in case of an unexpected token - @throw parse_error.102 if to_unicode fails or surrogate error - @throw parse_error.103 if to_unicode fails - */ - void parse(const bool strict, BasicJsonType& result) - { - if (callback) - { - json_sax_dom_callback_parser sdp(result, callback, allow_exceptions); - sax_parse_internal(&sdp); - - // in strict mode, input must be completely read - if (strict && (get_token() != token_type::end_of_input)) - { - sdp.parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), - exception_message(token_type::end_of_input, "value"), BasicJsonType())); - } - - // in case of an error, return discarded value - if (sdp.is_errored()) - { - result = value_t::discarded; - return; - } - - // set top-level value to null if it was discarded by the callback - // function - if (result.is_discarded()) - { - result = nullptr; - } - } - else - { - json_sax_dom_parser sdp(result, allow_exceptions); - sax_parse_internal(&sdp); - - // in strict mode, input must be completely read - if (strict && (get_token() != token_type::end_of_input)) - { - sdp.parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input, "value"), BasicJsonType())); - } - - // in case of an error, return discarded value - if (sdp.is_errored()) - { - result = value_t::discarded; - return; - } - } - - result.assert_invariant(); - } - - /*! - @brief public accept interface - - @param[in] strict whether to expect the last token to be EOF - @return whether the input is a proper JSON text - */ - bool accept(const bool strict = true) - { - json_sax_acceptor sax_acceptor; - return sax_parse(&sax_acceptor, strict); - } - - template - JSON_HEDLEY_NON_NULL(2) - bool sax_parse(SAX* sax, const bool strict = true) - { - (void)detail::is_sax_static_asserts {}; - const bool result = sax_parse_internal(sax); - - // strict mode: next byte must be EOF - if (result && strict && (get_token() != token_type::end_of_input)) - { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input, "value"), BasicJsonType())); - } - - return result; - } - - private: - template - JSON_HEDLEY_NON_NULL(2) - bool sax_parse_internal(SAX* sax) - { - // stack to remember the hierarchy of structured values we are parsing - // true = array; false = object - std::vector states; - // value to avoid a goto (see comment where set to true) - bool skip_to_state_evaluation = false; - - while (true) - { - if (!skip_to_state_evaluation) - { - // invariant: get_token() was called before each iteration - switch (last_token) - { - case token_type::begin_object: - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1)))) - { - return false; - } - - // closing } -> we are done - if (get_token() == token_type::end_object) - { - if (JSON_HEDLEY_UNLIKELY(!sax->end_object())) - { - return false; - } - break; - } - - // parse key - if (JSON_HEDLEY_UNLIKELY(last_token != token_type::value_string)) - { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), BasicJsonType())); - } - if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string()))) - { - return false; - } - - // parse separator (:) - if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) - { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), BasicJsonType())); - } - - // remember we are now inside an object - states.push_back(false); - - // parse values - get_token(); - continue; - } - - case token_type::begin_array: - { - if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1)))) - { - return false; - } - - // closing ] -> we are done - if (get_token() == token_type::end_array) - { - if (JSON_HEDLEY_UNLIKELY(!sax->end_array())) - { - return false; - } - break; - } - - // remember we are now inside an array - states.push_back(true); - - // parse values (no need to call get_token) - continue; - } - - case token_type::value_float: - { - const auto res = m_lexer.get_number_float(); - - if (JSON_HEDLEY_UNLIKELY(!std::isfinite(res))) - { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - out_of_range::create(406, "number overflow parsing '" + m_lexer.get_token_string() + "'", BasicJsonType())); - } - - if (JSON_HEDLEY_UNLIKELY(!sax->number_float(res, m_lexer.get_string()))) - { - return false; - } - - break; - } - - case token_type::literal_false: - { - if (JSON_HEDLEY_UNLIKELY(!sax->boolean(false))) - { - return false; - } - break; - } - - case token_type::literal_null: - { - if (JSON_HEDLEY_UNLIKELY(!sax->null())) - { - return false; - } - break; - } - - case token_type::literal_true: - { - if (JSON_HEDLEY_UNLIKELY(!sax->boolean(true))) - { - return false; - } - break; - } - - case token_type::value_integer: - { - if (JSON_HEDLEY_UNLIKELY(!sax->number_integer(m_lexer.get_number_integer()))) - { - return false; - } - break; - } - - case token_type::value_string: - { - if (JSON_HEDLEY_UNLIKELY(!sax->string(m_lexer.get_string()))) - { - return false; - } - break; - } - - case token_type::value_unsigned: - { - if (JSON_HEDLEY_UNLIKELY(!sax->number_unsigned(m_lexer.get_number_unsigned()))) - { - return false; - } - break; - } - - case token_type::parse_error: - { - // using "uninitialized" to avoid "expected" message - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized, "value"), BasicJsonType())); - } - - default: // the last token was unexpected - { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::literal_or_value, "value"), BasicJsonType())); - } - } - } - else - { - skip_to_state_evaluation = false; - } - - // we reached this line after we successfully parsed a value - if (states.empty()) - { - // empty stack: we reached the end of the hierarchy: done - return true; - } - - if (states.back()) // array - { - // comma -> next value - if (get_token() == token_type::value_separator) - { - // parse a new value - get_token(); - continue; - } - - // closing ] - if (JSON_HEDLEY_LIKELY(last_token == token_type::end_array)) - { - if (JSON_HEDLEY_UNLIKELY(!sax->end_array())) - { - return false; - } - - // We are done with this array. Before we can parse a - // new value, we need to evaluate the new state first. - // By setting skip_to_state_evaluation to false, we - // are effectively jumping to the beginning of this if. - JSON_ASSERT(!states.empty()); - states.pop_back(); - skip_to_state_evaluation = true; - continue; - } - - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_array, "array"), BasicJsonType())); - } - - // states.back() is false -> object - - // comma -> next value - if (get_token() == token_type::value_separator) - { - // parse key - if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::value_string)) - { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::value_string, "object key"), BasicJsonType())); - } - - if (JSON_HEDLEY_UNLIKELY(!sax->key(m_lexer.get_string()))) - { - return false; - } - - // parse separator (:) - if (JSON_HEDLEY_UNLIKELY(get_token() != token_type::name_separator)) - { - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::name_separator, "object separator"), BasicJsonType())); - } - - // parse values - get_token(); - continue; - } - - // closing } - if (JSON_HEDLEY_LIKELY(last_token == token_type::end_object)) - { - if (JSON_HEDLEY_UNLIKELY(!sax->end_object())) - { - return false; - } - - // We are done with this object. Before we can parse a - // new value, we need to evaluate the new state first. - // By setting skip_to_state_evaluation to false, we - // are effectively jumping to the beginning of this if. - JSON_ASSERT(!states.empty()); - states.pop_back(); - skip_to_state_evaluation = true; - continue; - } - - return sax->parse_error(m_lexer.get_position(), - m_lexer.get_token_string(), - parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_object, "object"), BasicJsonType())); - } - } - - /// get next token from lexer - token_type get_token() - { - return last_token = m_lexer.scan(); - } - - std::string exception_message(const token_type expected, const std::string& context) - { - std::string error_msg = "syntax error "; - - if (!context.empty()) - { - error_msg += "while parsing " + context + " "; - } - - error_msg += "- "; - - if (last_token == token_type::parse_error) - { - error_msg += std::string(m_lexer.get_error_message()) + "; last read: '" + - m_lexer.get_token_string() + "'"; - } - else - { - error_msg += "unexpected " + std::string(lexer_t::token_type_name(last_token)); - } - - if (expected != token_type::uninitialized) - { - error_msg += "; expected " + std::string(lexer_t::token_type_name(expected)); - } - - return error_msg; - } - - private: - /// callback function - const parser_callback_t callback = nullptr; - /// the type of the last read token - token_type last_token = token_type::uninitialized; - /// the lexer - lexer_t m_lexer; - /// whether to throw exceptions in case of errors - const bool allow_exceptions = true; -}; -} // namespace detail -} // namespace nlohmann - -// #include - - -// #include - - -#include // ptrdiff_t -#include // numeric_limits - -// #include - - -namespace nlohmann -{ -namespace detail -{ -/* -@brief an iterator for primitive JSON types - -This class models an iterator for primitive JSON types (boolean, number, -string). It's only purpose is to allow the iterator/const_iterator classes -to "iterate" over primitive values. Internally, the iterator is modeled by -a `difference_type` variable. Value begin_value (`0`) models the begin, -end_value (`1`) models past the end. -*/ -class primitive_iterator_t -{ - private: - using difference_type = std::ptrdiff_t; - static constexpr difference_type begin_value = 0; - static constexpr difference_type end_value = begin_value + 1; - - JSON_PRIVATE_UNLESS_TESTED: - /// iterator as signed integer type - difference_type m_it = (std::numeric_limits::min)(); - - public: - constexpr difference_type get_value() const noexcept - { - return m_it; - } - - /// set iterator to a defined beginning - void set_begin() noexcept - { - m_it = begin_value; - } - - /// set iterator to a defined past the end - void set_end() noexcept - { - m_it = end_value; - } - - /// return whether the iterator can be dereferenced - constexpr bool is_begin() const noexcept - { - return m_it == begin_value; - } - - /// return whether the iterator is at end - constexpr bool is_end() const noexcept - { - return m_it == end_value; - } - - friend constexpr bool operator==(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept - { - return lhs.m_it == rhs.m_it; - } - - friend constexpr bool operator<(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept - { - return lhs.m_it < rhs.m_it; - } - - primitive_iterator_t operator+(difference_type n) noexcept - { - auto result = *this; - result += n; - return result; - } - - friend constexpr difference_type operator-(primitive_iterator_t lhs, primitive_iterator_t rhs) noexcept - { - return lhs.m_it - rhs.m_it; - } - - primitive_iterator_t& operator++() noexcept - { - ++m_it; - return *this; - } - - primitive_iterator_t const operator++(int) noexcept - { - auto result = *this; - ++m_it; - return result; - } - - primitive_iterator_t& operator--() noexcept - { - --m_it; - return *this; - } - - primitive_iterator_t const operator--(int) noexcept - { - auto result = *this; - --m_it; - return result; - } - - primitive_iterator_t& operator+=(difference_type n) noexcept - { - m_it += n; - return *this; - } - - primitive_iterator_t& operator-=(difference_type n) noexcept - { - m_it -= n; - return *this; - } -}; -} // namespace detail -} // namespace nlohmann - - -namespace nlohmann -{ -namespace detail -{ -/*! -@brief an iterator value - -@note This structure could easily be a union, but MSVC currently does not allow -unions members with complex constructors, see https://github.com/nlohmann/json/pull/105. -*/ -template struct internal_iterator -{ - /// iterator for JSON objects - typename BasicJsonType::object_t::iterator object_iterator {}; - /// iterator for JSON arrays - typename BasicJsonType::array_t::iterator array_iterator {}; - /// generic iterator for all other types - primitive_iterator_t primitive_iterator {}; -}; -} // namespace detail -} // namespace nlohmann - -// #include - - -#include // iterator, random_access_iterator_tag, bidirectional_iterator_tag, advance, next -#include // conditional, is_const, remove_const - -// #include - -// #include - -// #include - -// #include - -// #include - -// #include - -// #include - - -namespace nlohmann -{ -namespace detail -{ -// forward declare, to be able to friend it later on -template class iteration_proxy; -template class iteration_proxy_value; - -/*! -@brief a template for a bidirectional iterator for the @ref basic_json class -This class implements a both iterators (iterator and const_iterator) for the -@ref basic_json class. -@note An iterator is called *initialized* when a pointer to a JSON value has - been set (e.g., by a constructor or a copy assignment). If the iterator is - default-constructed, it is *uninitialized* and most methods are undefined. - **The library uses assertions to detect calls on uninitialized iterators.** -@requirement The class satisfies the following concept requirements: -- -[BidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator): - The iterator that can be moved can be moved in both directions (i.e. - incremented and decremented). -@since version 1.0.0, simplified in version 2.0.9, change to bidirectional - iterators in version 3.0.0 (see https://github.com/nlohmann/json/issues/593) -*/ -template -class iter_impl -{ - /// the iterator with BasicJsonType of different const-ness - using other_iter_impl = iter_impl::value, typename std::remove_const::type, const BasicJsonType>::type>; - /// allow basic_json to access private members - friend other_iter_impl; - friend BasicJsonType; - friend iteration_proxy; - friend iteration_proxy_value; - - using object_t = typename BasicJsonType::object_t; - using array_t = typename BasicJsonType::array_t; - // make sure BasicJsonType is basic_json or const basic_json - static_assert(is_basic_json::type>::value, - "iter_impl only accepts (const) basic_json"); - - public: - - /// The std::iterator class template (used as a base class to provide typedefs) is deprecated in C++17. - /// The C++ Standard has never required user-defined iterators to derive from std::iterator. - /// A user-defined iterator should provide publicly accessible typedefs named - /// iterator_category, value_type, difference_type, pointer, and reference. - /// Note that value_type is required to be non-const, even for constant iterators. - using iterator_category = std::bidirectional_iterator_tag; - - /// the type of the values when the iterator is dereferenced - using value_type = typename BasicJsonType::value_type; - /// a type to represent differences between iterators - using difference_type = typename BasicJsonType::difference_type; - /// defines a pointer to the type iterated over (value_type) - using pointer = typename std::conditional::value, - typename BasicJsonType::const_pointer, - typename BasicJsonType::pointer>::type; - /// defines a reference to the type iterated over (value_type) - using reference = - typename std::conditional::value, - typename BasicJsonType::const_reference, - typename BasicJsonType::reference>::type; - - /// default constructor - iter_impl() = default; - - /*! - @brief constructor for a given JSON instance - @param[in] object pointer to a JSON object for this iterator - @pre object != nullptr - @post The iterator is initialized; i.e. `m_object != nullptr`. - */ - explicit iter_impl(pointer object) noexcept : m_object(object) - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - { - m_it.object_iterator = typename object_t::iterator(); - break; - } - - case value_t::array: - { - m_it.array_iterator = typename array_t::iterator(); - break; - } - - default: - { - m_it.primitive_iterator = primitive_iterator_t(); - break; - } - } - } - - /*! - @note The conventional copy constructor and copy assignment are implicitly - defined. Combined with the following converting constructor and - assignment, they support: (1) copy from iterator to iterator, (2) - copy from const iterator to const iterator, and (3) conversion from - iterator to const iterator. However conversion from const iterator - to iterator is not defined. - */ - - /*! - @brief const copy constructor - @param[in] other const iterator to copy from - @note This copy constructor had to be defined explicitly to circumvent a bug - occurring on msvc v19.0 compiler (VS 2015) debug build. For more - information refer to: https://github.com/nlohmann/json/issues/1608 - */ - iter_impl(const iter_impl& other) noexcept - : m_object(other.m_object), m_it(other.m_it) - {} - - /*! - @brief converting assignment - @param[in] other const iterator to copy from - @return const/non-const iterator - @note It is not checked whether @a other is initialized. - */ - iter_impl& operator=(const iter_impl& other) noexcept - { - m_object = other.m_object; - m_it = other.m_it; - return *this; - } - - /*! - @brief converting constructor - @param[in] other non-const iterator to copy from - @note It is not checked whether @a other is initialized. - */ - iter_impl(const iter_impl::type>& other) noexcept - : m_object(other.m_object), m_it(other.m_it) - {} - - /*! - @brief converting assignment - @param[in] other non-const iterator to copy from - @return const/non-const iterator - @note It is not checked whether @a other is initialized. - */ - iter_impl& operator=(const iter_impl::type>& other) noexcept - { - m_object = other.m_object; - m_it = other.m_it; - return *this; - } - - JSON_PRIVATE_UNLESS_TESTED: - /*! - @brief set the iterator to the first value - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - void set_begin() noexcept - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - { - m_it.object_iterator = m_object->m_value.object->begin(); - break; - } - - case value_t::array: - { - m_it.array_iterator = m_object->m_value.array->begin(); - break; - } - - case value_t::null: - { - // set to end so begin()==end() is true: null is empty - m_it.primitive_iterator.set_end(); - break; - } - - default: - { - m_it.primitive_iterator.set_begin(); - break; - } - } - } - - /*! - @brief set the iterator past the last value - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - void set_end() noexcept - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - { - m_it.object_iterator = m_object->m_value.object->end(); - break; - } - - case value_t::array: - { - m_it.array_iterator = m_object->m_value.array->end(); - break; - } - - default: - { - m_it.primitive_iterator.set_end(); - break; - } - } - } - - public: - /*! - @brief return a reference to the value pointed to by the iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - reference operator*() const - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - { - JSON_ASSERT(m_it.object_iterator != m_object->m_value.object->end()); - return m_it.object_iterator->second; - } - - case value_t::array: - { - JSON_ASSERT(m_it.array_iterator != m_object->m_value.array->end()); - return *m_it.array_iterator; - } - - case value_t::null: - JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object)); - - default: - { - if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) - { - return *m_object; - } - - JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object)); - } - } - } - - /*! - @brief dereference the iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - pointer operator->() const - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - { - JSON_ASSERT(m_it.object_iterator != m_object->m_value.object->end()); - return &(m_it.object_iterator->second); - } - - case value_t::array: - { - JSON_ASSERT(m_it.array_iterator != m_object->m_value.array->end()); - return &*m_it.array_iterator; - } - - default: - { - if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) - { - return m_object; - } - - JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object)); - } - } - } - - /*! - @brief post-increment (it++) - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl const operator++(int) - { - auto result = *this; - ++(*this); - return result; - } - - /*! - @brief pre-increment (++it) - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl& operator++() - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - { - std::advance(m_it.object_iterator, 1); - break; - } - - case value_t::array: - { - std::advance(m_it.array_iterator, 1); - break; - } - - default: - { - ++m_it.primitive_iterator; - break; - } - } - - return *this; - } - - /*! - @brief post-decrement (it--) - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl const operator--(int) - { - auto result = *this; - --(*this); - return result; - } - - /*! - @brief pre-decrement (--it) - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl& operator--() - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - { - std::advance(m_it.object_iterator, -1); - break; - } - - case value_t::array: - { - std::advance(m_it.array_iterator, -1); - break; - } - - default: - { - --m_it.primitive_iterator; - break; - } - } - - return *this; - } - - /*! - @brief comparison: equal - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - template < typename IterImpl, detail::enable_if_t < (std::is_same::value || std::is_same::value), std::nullptr_t > = nullptr > - bool operator==(const IterImpl& other) const - { - // if objects are not the same, the comparison is undefined - if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object)) - { - JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers", *m_object)); - } - - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - return (m_it.object_iterator == other.m_it.object_iterator); - - case value_t::array: - return (m_it.array_iterator == other.m_it.array_iterator); - - default: - return (m_it.primitive_iterator == other.m_it.primitive_iterator); - } - } - - /*! - @brief comparison: not equal - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - template < typename IterImpl, detail::enable_if_t < (std::is_same::value || std::is_same::value), std::nullptr_t > = nullptr > - bool operator!=(const IterImpl& other) const - { - return !operator==(other); - } - - /*! - @brief comparison: smaller - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - bool operator<(const iter_impl& other) const - { - // if objects are not the same, the comparison is undefined - if (JSON_HEDLEY_UNLIKELY(m_object != other.m_object)) - { - JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers", *m_object)); - } - - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - JSON_THROW(invalid_iterator::create(213, "cannot compare order of object iterators", *m_object)); - - case value_t::array: - return (m_it.array_iterator < other.m_it.array_iterator); - - default: - return (m_it.primitive_iterator < other.m_it.primitive_iterator); - } - } - - /*! - @brief comparison: less than or equal - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - bool operator<=(const iter_impl& other) const - { - return !other.operator < (*this); - } - - /*! - @brief comparison: greater than - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - bool operator>(const iter_impl& other) const - { - return !operator<=(other); - } - - /*! - @brief comparison: greater than or equal - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - bool operator>=(const iter_impl& other) const - { - return !operator<(other); - } - - /*! - @brief add to iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl& operator+=(difference_type i) - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators", *m_object)); - - case value_t::array: - { - std::advance(m_it.array_iterator, i); - break; - } - - default: - { - m_it.primitive_iterator += i; - break; - } - } - - return *this; - } - - /*! - @brief subtract from iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl& operator-=(difference_type i) - { - return operator+=(-i); - } - - /*! - @brief add to iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl operator+(difference_type i) const - { - auto result = *this; - result += i; - return result; - } - - /*! - @brief addition of distance and iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - friend iter_impl operator+(difference_type i, const iter_impl& it) - { - auto result = it; - result += i; - return result; - } - - /*! - @brief subtract from iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - iter_impl operator-(difference_type i) const - { - auto result = *this; - result -= i; - return result; - } - - /*! - @brief return difference - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - difference_type operator-(const iter_impl& other) const - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators", *m_object)); - - case value_t::array: - return m_it.array_iterator - other.m_it.array_iterator; - - default: - return m_it.primitive_iterator - other.m_it.primitive_iterator; - } - } - - /*! - @brief access to successor - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - reference operator[](difference_type n) const - { - JSON_ASSERT(m_object != nullptr); - - switch (m_object->m_type) - { - case value_t::object: - JSON_THROW(invalid_iterator::create(208, "cannot use operator[] for object iterators", *m_object)); - - case value_t::array: - return *std::next(m_it.array_iterator, n); - - case value_t::null: - JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object)); - - default: - { - if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.get_value() == -n)) - { - return *m_object; - } - - JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object)); - } - } - } - - /*! - @brief return the key of an object iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - const typename object_t::key_type& key() const - { - JSON_ASSERT(m_object != nullptr); - - if (JSON_HEDLEY_LIKELY(m_object->is_object())) - { - return m_it.object_iterator->first; - } - - JSON_THROW(invalid_iterator::create(207, "cannot use key() for non-object iterators", *m_object)); - } - - /*! - @brief return the value of an iterator - @pre The iterator is initialized; i.e. `m_object != nullptr`. - */ - reference value() const - { - return operator*(); - } - - JSON_PRIVATE_UNLESS_TESTED: - /// associated JSON instance - pointer m_object = nullptr; - /// the actual iterator of the associated instance - internal_iterator::type> m_it {}; -}; -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - - -#include // ptrdiff_t -#include // reverse_iterator -#include // declval - -namespace nlohmann -{ -namespace detail -{ -////////////////////// -// reverse_iterator // -////////////////////// - -/*! -@brief a template for a reverse iterator class - -@tparam Base the base iterator type to reverse. Valid types are @ref -iterator (to create @ref reverse_iterator) and @ref const_iterator (to -create @ref const_reverse_iterator). - -@requirement The class satisfies the following concept requirements: -- -[BidirectionalIterator](https://en.cppreference.com/w/cpp/named_req/BidirectionalIterator): - The iterator that can be moved can be moved in both directions (i.e. - incremented and decremented). -- [OutputIterator](https://en.cppreference.com/w/cpp/named_req/OutputIterator): - It is possible to write to the pointed-to element (only if @a Base is - @ref iterator). - -@since version 1.0.0 -*/ -template -class json_reverse_iterator : public std::reverse_iterator -{ - public: - using difference_type = std::ptrdiff_t; - /// shortcut to the reverse iterator adapter - using base_iterator = std::reverse_iterator; - /// the reference type for the pointed-to element - using reference = typename Base::reference; - - /// create reverse iterator from iterator - explicit json_reverse_iterator(const typename base_iterator::iterator_type& it) noexcept - : base_iterator(it) {} - - /// create reverse iterator from base class - explicit json_reverse_iterator(const base_iterator& it) noexcept : base_iterator(it) {} - - /// post-increment (it++) - json_reverse_iterator const operator++(int) - { - return static_cast(base_iterator::operator++(1)); - } - - /// pre-increment (++it) - json_reverse_iterator& operator++() - { - return static_cast(base_iterator::operator++()); - } - - /// post-decrement (it--) - json_reverse_iterator const operator--(int) - { - return static_cast(base_iterator::operator--(1)); - } - - /// pre-decrement (--it) - json_reverse_iterator& operator--() - { - return static_cast(base_iterator::operator--()); - } - - /// add to iterator - json_reverse_iterator& operator+=(difference_type i) - { - return static_cast(base_iterator::operator+=(i)); - } - - /// add to iterator - json_reverse_iterator operator+(difference_type i) const - { - return static_cast(base_iterator::operator+(i)); - } - - /// subtract from iterator - json_reverse_iterator operator-(difference_type i) const - { - return static_cast(base_iterator::operator-(i)); - } - - /// return difference - difference_type operator-(const json_reverse_iterator& other) const - { - return base_iterator(*this) - base_iterator(other); - } - - /// access to successor - reference operator[](difference_type n) const - { - return *(this->operator+(n)); - } - - /// return the key of an object iterator - auto key() const -> decltype(std::declval().key()) - { - auto it = --this->base(); - return it.key(); - } - - /// return the value of an iterator - reference value() const - { - auto it = --this->base(); - return it.operator * (); - } -}; -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - - -#include // all_of -#include // isdigit -#include // max -#include // accumulate -#include // string -#include // move -#include // vector - -// #include - -// #include - -// #include - -// #include - - -namespace nlohmann -{ -template -class json_pointer -{ - // allow basic_json to access private members - NLOHMANN_BASIC_JSON_TPL_DECLARATION - friend class basic_json; - - public: - /*! - @brief create JSON pointer - - Create a JSON pointer according to the syntax described in - [Section 3 of RFC6901](https://tools.ietf.org/html/rfc6901#section-3). - - @param[in] s string representing the JSON pointer; if omitted, the empty - string is assumed which references the whole JSON value - - @throw parse_error.107 if the given JSON pointer @a s is nonempty and does - not begin with a slash (`/`); see example below - - @throw parse_error.108 if a tilde (`~`) in the given JSON pointer @a s is - not followed by `0` (representing `~`) or `1` (representing `/`); see - example below - - @liveexample{The example shows the construction several valid JSON pointers - as well as the exceptional behavior.,json_pointer} - - @since version 2.0.0 - */ - explicit json_pointer(const std::string& s = "") - : reference_tokens(split(s)) - {} - - /*! - @brief return a string representation of the JSON pointer - - @invariant For each JSON pointer `ptr`, it holds: - @code {.cpp} - ptr == json_pointer(ptr.to_string()); - @endcode - - @return a string representation of the JSON pointer - - @liveexample{The example shows the result of `to_string`.,json_pointer__to_string} - - @since version 2.0.0 - */ - std::string to_string() const - { - return std::accumulate(reference_tokens.begin(), reference_tokens.end(), - std::string{}, - [](const std::string & a, const std::string & b) - { - return a + "/" + detail::escape(b); - }); - } - - /// @copydoc to_string() - operator std::string() const - { - return to_string(); - } - - /*! - @brief append another JSON pointer at the end of this JSON pointer - - @param[in] ptr JSON pointer to append - @return JSON pointer with @a ptr appended - - @liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add} - - @complexity Linear in the length of @a ptr. - - @sa @ref operator/=(std::string) to append a reference token - @sa @ref operator/=(std::size_t) to append an array index - @sa @ref operator/(const json_pointer&, const json_pointer&) for a binary operator - - @since version 3.6.0 - */ - json_pointer& operator/=(const json_pointer& ptr) - { - reference_tokens.insert(reference_tokens.end(), - ptr.reference_tokens.begin(), - ptr.reference_tokens.end()); - return *this; - } - - /*! - @brief append an unescaped reference token at the end of this JSON pointer - - @param[in] token reference token to append - @return JSON pointer with @a token appended without escaping @a token - - @liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add} - - @complexity Amortized constant. - - @sa @ref operator/=(const json_pointer&) to append a JSON pointer - @sa @ref operator/=(std::size_t) to append an array index - @sa @ref operator/(const json_pointer&, std::size_t) for a binary operator - - @since version 3.6.0 - */ - json_pointer& operator/=(std::string token) - { - push_back(std::move(token)); - return *this; - } - - /*! - @brief append an array index at the end of this JSON pointer - - @param[in] array_idx array index to append - @return JSON pointer with @a array_idx appended - - @liveexample{The example shows the usage of `operator/=`.,json_pointer__operator_add} - - @complexity Amortized constant. - - @sa @ref operator/=(const json_pointer&) to append a JSON pointer - @sa @ref operator/=(std::string) to append a reference token - @sa @ref operator/(const json_pointer&, std::string) for a binary operator - - @since version 3.6.0 - */ - json_pointer& operator/=(std::size_t array_idx) - { - return *this /= std::to_string(array_idx); - } - - /*! - @brief create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer - - @param[in] lhs JSON pointer - @param[in] rhs JSON pointer - @return a new JSON pointer with @a rhs appended to @a lhs - - @liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary} - - @complexity Linear in the length of @a lhs and @a rhs. - - @sa @ref operator/=(const json_pointer&) to append a JSON pointer - - @since version 3.6.0 - */ - friend json_pointer operator/(const json_pointer& lhs, - const json_pointer& rhs) - { - return json_pointer(lhs) /= rhs; - } - - /*! - @brief create a new JSON pointer by appending the unescaped token at the end of the JSON pointer - - @param[in] ptr JSON pointer - @param[in] token reference token - @return a new JSON pointer with unescaped @a token appended to @a ptr - - @liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary} - - @complexity Linear in the length of @a ptr. - - @sa @ref operator/=(std::string) to append a reference token - - @since version 3.6.0 - */ - friend json_pointer operator/(const json_pointer& ptr, std::string token) - { - return json_pointer(ptr) /= std::move(token); - } - - /*! - @brief create a new JSON pointer by appending the array-index-token at the end of the JSON pointer - - @param[in] ptr JSON pointer - @param[in] array_idx array index - @return a new JSON pointer with @a array_idx appended to @a ptr - - @liveexample{The example shows the usage of `operator/`.,json_pointer__operator_add_binary} - - @complexity Linear in the length of @a ptr. - - @sa @ref operator/=(std::size_t) to append an array index - - @since version 3.6.0 - */ - friend json_pointer operator/(const json_pointer& ptr, std::size_t array_idx) - { - return json_pointer(ptr) /= array_idx; - } - - /*! - @brief returns the parent of this JSON pointer - - @return parent of this JSON pointer; in case this JSON pointer is the root, - the root itself is returned - - @complexity Linear in the length of the JSON pointer. - - @liveexample{The example shows the result of `parent_pointer` for different - JSON Pointers.,json_pointer__parent_pointer} - - @since version 3.6.0 - */ - json_pointer parent_pointer() const - { - if (empty()) - { - return *this; - } - - json_pointer res = *this; - res.pop_back(); - return res; - } - - /*! - @brief remove last reference token - - @pre not `empty()` - - @liveexample{The example shows the usage of `pop_back`.,json_pointer__pop_back} - - @complexity Constant. - - @throw out_of_range.405 if JSON pointer has no parent - - @since version 3.6.0 - */ - void pop_back() - { - if (JSON_HEDLEY_UNLIKELY(empty())) - { - JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent", BasicJsonType())); - } - - reference_tokens.pop_back(); - } - - /*! - @brief return last reference token - - @pre not `empty()` - @return last reference token - - @liveexample{The example shows the usage of `back`.,json_pointer__back} - - @complexity Constant. - - @throw out_of_range.405 if JSON pointer has no parent - - @since version 3.6.0 - */ - const std::string& back() const - { - if (JSON_HEDLEY_UNLIKELY(empty())) - { - JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent", BasicJsonType())); - } - - return reference_tokens.back(); - } - - /*! - @brief append an unescaped token at the end of the reference pointer - - @param[in] token token to add - - @complexity Amortized constant. - - @liveexample{The example shows the result of `push_back` for different - JSON Pointers.,json_pointer__push_back} - - @since version 3.6.0 - */ - void push_back(const std::string& token) - { - reference_tokens.push_back(token); - } - - /// @copydoc push_back(const std::string&) - void push_back(std::string&& token) - { - reference_tokens.push_back(std::move(token)); - } - - /*! - @brief return whether pointer points to the root document - - @return true iff the JSON pointer points to the root document - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @liveexample{The example shows the result of `empty` for different JSON - Pointers.,json_pointer__empty} - - @since version 3.6.0 - */ - bool empty() const noexcept - { - return reference_tokens.empty(); - } - - private: - /*! - @param[in] s reference token to be converted into an array index - - @return integer representation of @a s - - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index begins not with a digit - @throw out_of_range.404 if string @a s could not be converted to an integer - @throw out_of_range.410 if an array index exceeds size_type - */ - static typename BasicJsonType::size_type array_index(const std::string& s) - { - using size_type = typename BasicJsonType::size_type; - - // error condition (cf. RFC 6901, Sect. 4) - if (JSON_HEDLEY_UNLIKELY(s.size() > 1 && s[0] == '0')) - { - JSON_THROW(detail::parse_error::create(106, 0, "array index '" + s + "' must not begin with '0'", BasicJsonType())); - } - - // error condition (cf. RFC 6901, Sect. 4) - if (JSON_HEDLEY_UNLIKELY(s.size() > 1 && !(s[0] >= '1' && s[0] <= '9'))) - { - JSON_THROW(detail::parse_error::create(109, 0, "array index '" + s + "' is not a number", BasicJsonType())); - } - - std::size_t processed_chars = 0; - unsigned long long res = 0; - JSON_TRY - { - res = std::stoull(s, &processed_chars); - } - JSON_CATCH(std::out_of_range&) - { - JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'", BasicJsonType())); - } - - // check if the string was completely read - if (JSON_HEDLEY_UNLIKELY(processed_chars != s.size())) - { - JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + s + "'", BasicJsonType())); - } - - // only triggered on special platforms (like 32bit), see also - // https://github.com/nlohmann/json/pull/2203 - if (res >= static_cast((std::numeric_limits::max)())) - { - JSON_THROW(detail::out_of_range::create(410, "array index " + s + " exceeds size_type", BasicJsonType())); // LCOV_EXCL_LINE - } - - return static_cast(res); - } - - JSON_PRIVATE_UNLESS_TESTED: - json_pointer top() const - { - if (JSON_HEDLEY_UNLIKELY(empty())) - { - JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent", BasicJsonType())); - } - - json_pointer result = *this; - result.reference_tokens = {reference_tokens[0]}; - return result; - } - - private: - /*! - @brief create and return a reference to the pointed to value - - @complexity Linear in the number of reference tokens. - - @throw parse_error.109 if array index is not a number - @throw type_error.313 if value cannot be unflattened - */ - BasicJsonType& get_and_create(BasicJsonType& j) const - { - auto result = &j; - - // in case no reference tokens exist, return a reference to the JSON value - // j which will be overwritten by a primitive value - for (const auto& reference_token : reference_tokens) - { - switch (result->type()) - { - case detail::value_t::null: - { - if (reference_token == "0") - { - // start a new array if reference token is 0 - result = &result->operator[](0); - } - else - { - // start a new object otherwise - result = &result->operator[](reference_token); - } - break; - } - - case detail::value_t::object: - { - // create an entry in the object - result = &result->operator[](reference_token); - break; - } - - case detail::value_t::array: - { - // create an entry in the array - result = &result->operator[](array_index(reference_token)); - break; - } - - /* - The following code is only reached if there exists a reference - token _and_ the current value is primitive. In this case, we have - an error situation, because primitive values may only occur as - single value; that is, with an empty list of reference tokens. - */ - default: - JSON_THROW(detail::type_error::create(313, "invalid value to unflatten", j)); - } - } - - return *result; - } - - /*! - @brief return a reference to the pointed to value - - @note This version does not throw if a value is not present, but tries to - create nested values instead. For instance, calling this function - with pointer `"/this/that"` on a null value is equivalent to calling - `operator[]("this").operator[]("that")` on that value, effectively - changing the null value to an object. - - @param[in] ptr a JSON value - - @return reference to the JSON value pointed to by the JSON pointer - - @complexity Linear in the length of the JSON pointer. - - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index was not a number - @throw out_of_range.404 if the JSON pointer can not be resolved - */ - BasicJsonType& get_unchecked(BasicJsonType* ptr) const - { - for (const auto& reference_token : reference_tokens) - { - // convert null values to arrays or objects before continuing - if (ptr->is_null()) - { - // check if reference token is a number - const bool nums = - std::all_of(reference_token.begin(), reference_token.end(), - [](const unsigned char x) - { - return std::isdigit(x); - }); - - // change value to array for numbers or "-" or to object otherwise - *ptr = (nums || reference_token == "-") - ? detail::value_t::array - : detail::value_t::object; - } - - switch (ptr->type()) - { - case detail::value_t::object: - { - // use unchecked object access - ptr = &ptr->operator[](reference_token); - break; - } - - case detail::value_t::array: - { - if (reference_token == "-") - { - // explicitly treat "-" as index beyond the end - ptr = &ptr->operator[](ptr->m_value.array->size()); - } - else - { - // convert array index to number; unchecked access - ptr = &ptr->operator[](array_index(reference_token)); - } - break; - } - - default: - JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr)); - } - } - - return *ptr; - } - - /*! - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index was not a number - @throw out_of_range.402 if the array index '-' is used - @throw out_of_range.404 if the JSON pointer can not be resolved - */ - BasicJsonType& get_checked(BasicJsonType* ptr) const - { - for (const auto& reference_token : reference_tokens) - { - switch (ptr->type()) - { - case detail::value_t::object: - { - // note: at performs range check - ptr = &ptr->at(reference_token); - break; - } - - case detail::value_t::array: - { - if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) - { - // "-" always fails the range check - JSON_THROW(detail::out_of_range::create(402, - "array index '-' (" + std::to_string(ptr->m_value.array->size()) + - ") is out of range", *ptr)); - } - - // note: at performs range check - ptr = &ptr->at(array_index(reference_token)); - break; - } - - default: - JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr)); - } - } - - return *ptr; - } - - /*! - @brief return a const reference to the pointed to value - - @param[in] ptr a JSON value - - @return const reference to the JSON value pointed to by the JSON - pointer - - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index was not a number - @throw out_of_range.402 if the array index '-' is used - @throw out_of_range.404 if the JSON pointer can not be resolved - */ - const BasicJsonType& get_unchecked(const BasicJsonType* ptr) const - { - for (const auto& reference_token : reference_tokens) - { - switch (ptr->type()) - { - case detail::value_t::object: - { - // use unchecked object access - ptr = &ptr->operator[](reference_token); - break; - } - - case detail::value_t::array: - { - if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) - { - // "-" cannot be used for const access - JSON_THROW(detail::out_of_range::create(402, "array index '-' (" + std::to_string(ptr->m_value.array->size()) + ") is out of range", *ptr)); - } - - // use unchecked array access - ptr = &ptr->operator[](array_index(reference_token)); - break; - } - - default: - JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr)); - } - } - - return *ptr; - } - - /*! - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index was not a number - @throw out_of_range.402 if the array index '-' is used - @throw out_of_range.404 if the JSON pointer can not be resolved - */ - const BasicJsonType& get_checked(const BasicJsonType* ptr) const - { - for (const auto& reference_token : reference_tokens) - { - switch (ptr->type()) - { - case detail::value_t::object: - { - // note: at performs range check - ptr = &ptr->at(reference_token); - break; - } - - case detail::value_t::array: - { - if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) - { - // "-" always fails the range check - JSON_THROW(detail::out_of_range::create(402, - "array index '-' (" + std::to_string(ptr->m_value.array->size()) + - ") is out of range", *ptr)); - } - - // note: at performs range check - ptr = &ptr->at(array_index(reference_token)); - break; - } - - default: - JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr)); - } - } - - return *ptr; - } - - /*! - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index was not a number - */ - bool contains(const BasicJsonType* ptr) const - { - for (const auto& reference_token : reference_tokens) - { - switch (ptr->type()) - { - case detail::value_t::object: - { - if (!ptr->contains(reference_token)) - { - // we did not find the key in the object - return false; - } - - ptr = &ptr->operator[](reference_token); - break; - } - - case detail::value_t::array: - { - if (JSON_HEDLEY_UNLIKELY(reference_token == "-")) - { - // "-" always fails the range check - return false; - } - if (JSON_HEDLEY_UNLIKELY(reference_token.size() == 1 && !("0" <= reference_token && reference_token <= "9"))) - { - // invalid char - return false; - } - if (JSON_HEDLEY_UNLIKELY(reference_token.size() > 1)) - { - if (JSON_HEDLEY_UNLIKELY(!('1' <= reference_token[0] && reference_token[0] <= '9'))) - { - // first char should be between '1' and '9' - return false; - } - for (std::size_t i = 1; i < reference_token.size(); i++) - { - if (JSON_HEDLEY_UNLIKELY(!('0' <= reference_token[i] && reference_token[i] <= '9'))) - { - // other char should be between '0' and '9' - return false; - } - } - } - - const auto idx = array_index(reference_token); - if (idx >= ptr->size()) - { - // index out of range - return false; - } - - ptr = &ptr->operator[](idx); - break; - } - - default: - { - // we do not expect primitive values if there is still a - // reference token to process - return false; - } - } - } - - // no reference token left means we found a primitive value - return true; - } - - /*! - @brief split the string input to reference tokens - - @note This function is only called by the json_pointer constructor. - All exceptions below are documented there. - - @throw parse_error.107 if the pointer is not empty or begins with '/' - @throw parse_error.108 if character '~' is not followed by '0' or '1' - */ - static std::vector split(const std::string& reference_string) - { - std::vector result; - - // special case: empty reference string -> no reference tokens - if (reference_string.empty()) - { - return result; - } - - // check if nonempty reference string begins with slash - if (JSON_HEDLEY_UNLIKELY(reference_string[0] != '/')) - { - JSON_THROW(detail::parse_error::create(107, 1, "JSON pointer must be empty or begin with '/' - was: '" + reference_string + "'", BasicJsonType())); - } - - // extract the reference tokens: - // - slash: position of the last read slash (or end of string) - // - start: position after the previous slash - for ( - // search for the first slash after the first character - std::size_t slash = reference_string.find_first_of('/', 1), - // set the beginning of the first reference token - start = 1; - // we can stop if start == 0 (if slash == std::string::npos) - start != 0; - // set the beginning of the next reference token - // (will eventually be 0 if slash == std::string::npos) - start = (slash == std::string::npos) ? 0 : slash + 1, - // find next slash - slash = reference_string.find_first_of('/', start)) - { - // use the text between the beginning of the reference token - // (start) and the last slash (slash). - auto reference_token = reference_string.substr(start, slash - start); - - // check reference tokens are properly escaped - for (std::size_t pos = reference_token.find_first_of('~'); - pos != std::string::npos; - pos = reference_token.find_first_of('~', pos + 1)) - { - JSON_ASSERT(reference_token[pos] == '~'); - - // ~ must be followed by 0 or 1 - if (JSON_HEDLEY_UNLIKELY(pos == reference_token.size() - 1 || - (reference_token[pos + 1] != '0' && - reference_token[pos + 1] != '1'))) - { - JSON_THROW(detail::parse_error::create(108, 0, "escape character '~' must be followed with '0' or '1'", BasicJsonType())); - } - } - - // finally, store the reference token - detail::unescape(reference_token); - result.push_back(reference_token); - } - - return result; - } - - private: - /*! - @param[in] reference_string the reference string to the current value - @param[in] value the value to consider - @param[in,out] result the result object to insert values to - - @note Empty objects or arrays are flattened to `null`. - */ - static void flatten(const std::string& reference_string, - const BasicJsonType& value, - BasicJsonType& result) - { - switch (value.type()) - { - case detail::value_t::array: - { - if (value.m_value.array->empty()) - { - // flatten empty array as null - result[reference_string] = nullptr; - } - else - { - // iterate array and use index as reference string - for (std::size_t i = 0; i < value.m_value.array->size(); ++i) - { - flatten(reference_string + "/" + std::to_string(i), - value.m_value.array->operator[](i), result); - } - } - break; - } - - case detail::value_t::object: - { - if (value.m_value.object->empty()) - { - // flatten empty object as null - result[reference_string] = nullptr; - } - else - { - // iterate object and use keys as reference string - for (const auto& element : *value.m_value.object) - { - flatten(reference_string + "/" + detail::escape(element.first), element.second, result); - } - } - break; - } - - default: - { - // add primitive value with its reference string - result[reference_string] = value; - break; - } - } - } - - /*! - @param[in] value flattened JSON - - @return unflattened JSON - - @throw parse_error.109 if array index is not a number - @throw type_error.314 if value is not an object - @throw type_error.315 if object values are not primitive - @throw type_error.313 if value cannot be unflattened - */ - static BasicJsonType - unflatten(const BasicJsonType& value) - { - if (JSON_HEDLEY_UNLIKELY(!value.is_object())) - { - JSON_THROW(detail::type_error::create(314, "only objects can be unflattened", value)); - } - - BasicJsonType result; - - // iterate the JSON object values - for (const auto& element : *value.m_value.object) - { - if (JSON_HEDLEY_UNLIKELY(!element.second.is_primitive())) - { - JSON_THROW(detail::type_error::create(315, "values in object must be primitive", element.second)); - } - - // assign value to reference pointed to by JSON pointer; Note that if - // the JSON pointer is "" (i.e., points to the whole value), function - // get_and_create returns a reference to result itself. An assignment - // will then create a primitive value. - json_pointer(element.first).get_and_create(result) = element.second; - } - - return result; - } - - /*! - @brief compares two JSON pointers for equality - - @param[in] lhs JSON pointer to compare - @param[in] rhs JSON pointer to compare - @return whether @a lhs is equal to @a rhs - - @complexity Linear in the length of the JSON pointer - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - */ - friend bool operator==(json_pointer const& lhs, - json_pointer const& rhs) noexcept - { - return lhs.reference_tokens == rhs.reference_tokens; - } - - /*! - @brief compares two JSON pointers for inequality - - @param[in] lhs JSON pointer to compare - @param[in] rhs JSON pointer to compare - @return whether @a lhs is not equal @a rhs - - @complexity Linear in the length of the JSON pointer - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - */ - friend bool operator!=(json_pointer const& lhs, - json_pointer const& rhs) noexcept - { - return !(lhs == rhs); - } - - /// the reference tokens - std::vector reference_tokens; -}; -} // namespace nlohmann - -// #include - - -#include -#include - -// #include - - -namespace nlohmann -{ -namespace detail -{ -template -class json_ref -{ - public: - using value_type = BasicJsonType; - - json_ref(value_type&& value) - : owned_value(std::move(value)) - {} - - json_ref(const value_type& value) - : value_ref(&value) - {} - - json_ref(std::initializer_list init) - : owned_value(init) - {} - - template < - class... Args, - enable_if_t::value, int> = 0 > - json_ref(Args && ... args) - : owned_value(std::forward(args)...) - {} - - // class should be movable only - json_ref(json_ref&&) = default; - json_ref(const json_ref&) = delete; - json_ref& operator=(const json_ref&) = delete; - json_ref& operator=(json_ref&&) = delete; - ~json_ref() = default; - - value_type moved_or_copied() const - { - if (value_ref == nullptr) - { - return std::move(owned_value); - } - return *value_ref; - } - - value_type const& operator*() const - { - return value_ref ? *value_ref : owned_value; - } - - value_type const* operator->() const - { - return &** this; - } - - private: - mutable value_type owned_value = nullptr; - value_type const* value_ref = nullptr; -}; -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - -// #include - -// #include - - -#include // reverse -#include // array -#include // uint8_t, uint16_t, uint32_t, uint64_t -#include // memcpy -#include // numeric_limits -#include // string -#include // isnan, isinf - -// #include - -// #include - -// #include - - -#include // copy -#include // size_t -#include // streamsize -#include // back_inserter -#include // shared_ptr, make_shared -#include // basic_ostream -#include // basic_string -#include // vector -// #include - - -namespace nlohmann -{ -namespace detail -{ -/// abstract output adapter interface -template struct output_adapter_protocol -{ - virtual void write_character(CharType c) = 0; - virtual void write_characters(const CharType* s, std::size_t length) = 0; - virtual ~output_adapter_protocol() = default; -}; - -/// a type to simplify interfaces -template -using output_adapter_t = std::shared_ptr>; - -/// output adapter for byte vectors -template -class output_vector_adapter : public output_adapter_protocol -{ - public: - explicit output_vector_adapter(std::vector& vec) noexcept - : v(vec) - {} - - void write_character(CharType c) override - { - v.push_back(c); - } - - JSON_HEDLEY_NON_NULL(2) - void write_characters(const CharType* s, std::size_t length) override - { - std::copy(s, s + length, std::back_inserter(v)); - } - - private: - std::vector& v; -}; - -/// output adapter for output streams -template -class output_stream_adapter : public output_adapter_protocol -{ - public: - explicit output_stream_adapter(std::basic_ostream& s) noexcept - : stream(s) - {} - - void write_character(CharType c) override - { - stream.put(c); - } - - JSON_HEDLEY_NON_NULL(2) - void write_characters(const CharType* s, std::size_t length) override - { - stream.write(s, static_cast(length)); - } - - private: - std::basic_ostream& stream; -}; - -/// output adapter for basic_string -template> -class output_string_adapter : public output_adapter_protocol -{ - public: - explicit output_string_adapter(StringType& s) noexcept - : str(s) - {} - - void write_character(CharType c) override - { - str.push_back(c); - } - - JSON_HEDLEY_NON_NULL(2) - void write_characters(const CharType* s, std::size_t length) override - { - str.append(s, length); - } - - private: - StringType& str; -}; - -template> -class output_adapter -{ - public: - output_adapter(std::vector& vec) - : oa(std::make_shared>(vec)) {} - - output_adapter(std::basic_ostream& s) - : oa(std::make_shared>(s)) {} - - output_adapter(StringType& s) - : oa(std::make_shared>(s)) {} - - operator output_adapter_t() - { - return oa; - } - - private: - output_adapter_t oa = nullptr; -}; -} // namespace detail -} // namespace nlohmann - - -namespace nlohmann -{ -namespace detail -{ -/////////////////// -// binary writer // -/////////////////// - -/*! -@brief serialization to CBOR and MessagePack values -*/ -template -class binary_writer -{ - using string_t = typename BasicJsonType::string_t; - using binary_t = typename BasicJsonType::binary_t; - using number_float_t = typename BasicJsonType::number_float_t; - - public: - /*! - @brief create a binary writer - - @param[in] adapter output adapter to write to - */ - explicit binary_writer(output_adapter_t adapter) : oa(adapter) - { - JSON_ASSERT(oa); - } - - /*! - @param[in] j JSON value to serialize - @pre j.type() == value_t::object - */ - void write_bson(const BasicJsonType& j) - { - switch (j.type()) - { - case value_t::object: - { - write_bson_object(*j.m_value.object); - break; - } - - default: - { - JSON_THROW(type_error::create(317, "to serialize to BSON, top-level type must be object, but is " + std::string(j.type_name()), j));; - } - } - } - - /*! - @param[in] j JSON value to serialize - */ - void write_cbor(const BasicJsonType& j) - { - switch (j.type()) - { - case value_t::null: - { - oa->write_character(to_char_type(0xF6)); - break; - } - - case value_t::boolean: - { - oa->write_character(j.m_value.boolean - ? to_char_type(0xF5) - : to_char_type(0xF4)); - break; - } - - case value_t::number_integer: - { - if (j.m_value.number_integer >= 0) - { - // CBOR does not differentiate between positive signed - // integers and unsigned integers. Therefore, we used the - // code from the value_t::number_unsigned case here. - if (j.m_value.number_integer <= 0x17) - { - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_integer <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x18)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_integer <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x19)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_integer <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x1A)); - write_number(static_cast(j.m_value.number_integer)); - } - else - { - oa->write_character(to_char_type(0x1B)); - write_number(static_cast(j.m_value.number_integer)); - } - } - else - { - // The conversions below encode the sign in the first - // byte, and the value is converted to a positive number. - const auto positive_number = -1 - j.m_value.number_integer; - if (j.m_value.number_integer >= -24) - { - write_number(static_cast(0x20 + positive_number)); - } - else if (positive_number <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x38)); - write_number(static_cast(positive_number)); - } - else if (positive_number <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x39)); - write_number(static_cast(positive_number)); - } - else if (positive_number <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x3A)); - write_number(static_cast(positive_number)); - } - else - { - oa->write_character(to_char_type(0x3B)); - write_number(static_cast(positive_number)); - } - } - break; - } - - case value_t::number_unsigned: - { - if (j.m_value.number_unsigned <= 0x17) - { - write_number(static_cast(j.m_value.number_unsigned)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x18)); - write_number(static_cast(j.m_value.number_unsigned)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x19)); - write_number(static_cast(j.m_value.number_unsigned)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x1A)); - write_number(static_cast(j.m_value.number_unsigned)); - } - else - { - oa->write_character(to_char_type(0x1B)); - write_number(static_cast(j.m_value.number_unsigned)); - } - break; - } - - case value_t::number_float: - { - if (std::isnan(j.m_value.number_float)) - { - // NaN is 0xf97e00 in CBOR - oa->write_character(to_char_type(0xF9)); - oa->write_character(to_char_type(0x7E)); - oa->write_character(to_char_type(0x00)); - } - else if (std::isinf(j.m_value.number_float)) - { - // Infinity is 0xf97c00, -Infinity is 0xf9fc00 - oa->write_character(to_char_type(0xf9)); - oa->write_character(j.m_value.number_float > 0 ? to_char_type(0x7C) : to_char_type(0xFC)); - oa->write_character(to_char_type(0x00)); - } - else - { - write_compact_float(j.m_value.number_float, detail::input_format_t::cbor); - } - break; - } - - case value_t::string: - { - // step 1: write control byte and the string length - const auto N = j.m_value.string->size(); - if (N <= 0x17) - { - write_number(static_cast(0x60 + N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x78)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x79)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x7A)); - write_number(static_cast(N)); - } - // LCOV_EXCL_START - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x7B)); - write_number(static_cast(N)); - } - // LCOV_EXCL_STOP - - // step 2: write the string - oa->write_characters( - reinterpret_cast(j.m_value.string->c_str()), - j.m_value.string->size()); - break; - } - - case value_t::array: - { - // step 1: write control byte and the array size - const auto N = j.m_value.array->size(); - if (N <= 0x17) - { - write_number(static_cast(0x80 + N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x98)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x99)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x9A)); - write_number(static_cast(N)); - } - // LCOV_EXCL_START - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x9B)); - write_number(static_cast(N)); - } - // LCOV_EXCL_STOP - - // step 2: write each element - for (const auto& el : *j.m_value.array) - { - write_cbor(el); - } - break; - } - - case value_t::binary: - { - if (j.m_value.binary->has_subtype()) - { - write_number(static_cast(0xd8)); - write_number(j.m_value.binary->subtype()); - } - - // step 1: write control byte and the binary array size - const auto N = j.m_value.binary->size(); - if (N <= 0x17) - { - write_number(static_cast(0x40 + N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x58)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x59)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x5A)); - write_number(static_cast(N)); - } - // LCOV_EXCL_START - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0x5B)); - write_number(static_cast(N)); - } - // LCOV_EXCL_STOP - - // step 2: write each element - oa->write_characters( - reinterpret_cast(j.m_value.binary->data()), - N); - - break; - } - - case value_t::object: - { - // step 1: write control byte and the object size - const auto N = j.m_value.object->size(); - if (N <= 0x17) - { - write_number(static_cast(0xA0 + N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0xB8)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0xB9)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0xBA)); - write_number(static_cast(N)); - } - // LCOV_EXCL_START - else if (N <= (std::numeric_limits::max)()) - { - oa->write_character(to_char_type(0xBB)); - write_number(static_cast(N)); - } - // LCOV_EXCL_STOP - - // step 2: write each element - for (const auto& el : *j.m_value.object) - { - write_cbor(el.first); - write_cbor(el.second); - } - break; - } - - default: - break; - } - } - - /*! - @param[in] j JSON value to serialize - */ - void write_msgpack(const BasicJsonType& j) - { - switch (j.type()) - { - case value_t::null: // nil - { - oa->write_character(to_char_type(0xC0)); - break; - } - - case value_t::boolean: // true and false - { - oa->write_character(j.m_value.boolean - ? to_char_type(0xC3) - : to_char_type(0xC2)); - break; - } - - case value_t::number_integer: - { - if (j.m_value.number_integer >= 0) - { - // MessagePack does not differentiate between positive - // signed integers and unsigned integers. Therefore, we used - // the code from the value_t::number_unsigned case here. - if (j.m_value.number_unsigned < 128) - { - // positive fixnum - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - // uint 8 - oa->write_character(to_char_type(0xCC)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - // uint 16 - oa->write_character(to_char_type(0xCD)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - // uint 32 - oa->write_character(to_char_type(0xCE)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - // uint 64 - oa->write_character(to_char_type(0xCF)); - write_number(static_cast(j.m_value.number_integer)); - } - } - else - { - if (j.m_value.number_integer >= -32) - { - // negative fixnum - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_integer >= (std::numeric_limits::min)() && - j.m_value.number_integer <= (std::numeric_limits::max)()) - { - // int 8 - oa->write_character(to_char_type(0xD0)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_integer >= (std::numeric_limits::min)() && - j.m_value.number_integer <= (std::numeric_limits::max)()) - { - // int 16 - oa->write_character(to_char_type(0xD1)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_integer >= (std::numeric_limits::min)() && - j.m_value.number_integer <= (std::numeric_limits::max)()) - { - // int 32 - oa->write_character(to_char_type(0xD2)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_integer >= (std::numeric_limits::min)() && - j.m_value.number_integer <= (std::numeric_limits::max)()) - { - // int 64 - oa->write_character(to_char_type(0xD3)); - write_number(static_cast(j.m_value.number_integer)); - } - } - break; - } - - case value_t::number_unsigned: - { - if (j.m_value.number_unsigned < 128) - { - // positive fixnum - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - // uint 8 - oa->write_character(to_char_type(0xCC)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - // uint 16 - oa->write_character(to_char_type(0xCD)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - // uint 32 - oa->write_character(to_char_type(0xCE)); - write_number(static_cast(j.m_value.number_integer)); - } - else if (j.m_value.number_unsigned <= (std::numeric_limits::max)()) - { - // uint 64 - oa->write_character(to_char_type(0xCF)); - write_number(static_cast(j.m_value.number_integer)); - } - break; - } - - case value_t::number_float: - { - write_compact_float(j.m_value.number_float, detail::input_format_t::msgpack); - break; - } - - case value_t::string: - { - // step 1: write control byte and the string length - const auto N = j.m_value.string->size(); - if (N <= 31) - { - // fixstr - write_number(static_cast(0xA0 | N)); - } - else if (N <= (std::numeric_limits::max)()) - { - // str 8 - oa->write_character(to_char_type(0xD9)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - // str 16 - oa->write_character(to_char_type(0xDA)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - // str 32 - oa->write_character(to_char_type(0xDB)); - write_number(static_cast(N)); - } - - // step 2: write the string - oa->write_characters( - reinterpret_cast(j.m_value.string->c_str()), - j.m_value.string->size()); - break; - } - - case value_t::array: - { - // step 1: write control byte and the array size - const auto N = j.m_value.array->size(); - if (N <= 15) - { - // fixarray - write_number(static_cast(0x90 | N)); - } - else if (N <= (std::numeric_limits::max)()) - { - // array 16 - oa->write_character(to_char_type(0xDC)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - // array 32 - oa->write_character(to_char_type(0xDD)); - write_number(static_cast(N)); - } - - // step 2: write each element - for (const auto& el : *j.m_value.array) - { - write_msgpack(el); - } - break; - } - - case value_t::binary: - { - // step 0: determine if the binary type has a set subtype to - // determine whether or not to use the ext or fixext types - const bool use_ext = j.m_value.binary->has_subtype(); - - // step 1: write control byte and the byte string length - const auto N = j.m_value.binary->size(); - if (N <= (std::numeric_limits::max)()) - { - std::uint8_t output_type{}; - bool fixed = true; - if (use_ext) - { - switch (N) - { - case 1: - output_type = 0xD4; // fixext 1 - break; - case 2: - output_type = 0xD5; // fixext 2 - break; - case 4: - output_type = 0xD6; // fixext 4 - break; - case 8: - output_type = 0xD7; // fixext 8 - break; - case 16: - output_type = 0xD8; // fixext 16 - break; - default: - output_type = 0xC7; // ext 8 - fixed = false; - break; - } - - } - else - { - output_type = 0xC4; // bin 8 - fixed = false; - } - - oa->write_character(to_char_type(output_type)); - if (!fixed) - { - write_number(static_cast(N)); - } - } - else if (N <= (std::numeric_limits::max)()) - { - std::uint8_t output_type = use_ext - ? 0xC8 // ext 16 - : 0xC5; // bin 16 - - oa->write_character(to_char_type(output_type)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - std::uint8_t output_type = use_ext - ? 0xC9 // ext 32 - : 0xC6; // bin 32 - - oa->write_character(to_char_type(output_type)); - write_number(static_cast(N)); - } - - // step 1.5: if this is an ext type, write the subtype - if (use_ext) - { - write_number(static_cast(j.m_value.binary->subtype())); - } - - // step 2: write the byte string - oa->write_characters( - reinterpret_cast(j.m_value.binary->data()), - N); - - break; - } - - case value_t::object: - { - // step 1: write control byte and the object size - const auto N = j.m_value.object->size(); - if (N <= 15) - { - // fixmap - write_number(static_cast(0x80 | (N & 0xF))); - } - else if (N <= (std::numeric_limits::max)()) - { - // map 16 - oa->write_character(to_char_type(0xDE)); - write_number(static_cast(N)); - } - else if (N <= (std::numeric_limits::max)()) - { - // map 32 - oa->write_character(to_char_type(0xDF)); - write_number(static_cast(N)); - } - - // step 2: write each element - for (const auto& el : *j.m_value.object) - { - write_msgpack(el.first); - write_msgpack(el.second); - } - break; - } - - default: - break; - } - } - - /*! - @param[in] j JSON value to serialize - @param[in] use_count whether to use '#' prefixes (optimized format) - @param[in] use_type whether to use '$' prefixes (optimized format) - @param[in] add_prefix whether prefixes need to be used for this value - */ - void write_ubjson(const BasicJsonType& j, const bool use_count, - const bool use_type, const bool add_prefix = true) - { - switch (j.type()) - { - case value_t::null: - { - if (add_prefix) - { - oa->write_character(to_char_type('Z')); - } - break; - } - - case value_t::boolean: - { - if (add_prefix) - { - oa->write_character(j.m_value.boolean - ? to_char_type('T') - : to_char_type('F')); - } - break; - } - - case value_t::number_integer: - { - write_number_with_ubjson_prefix(j.m_value.number_integer, add_prefix); - break; - } - - case value_t::number_unsigned: - { - write_number_with_ubjson_prefix(j.m_value.number_unsigned, add_prefix); - break; - } - - case value_t::number_float: - { - write_number_with_ubjson_prefix(j.m_value.number_float, add_prefix); - break; - } - - case value_t::string: - { - if (add_prefix) - { - oa->write_character(to_char_type('S')); - } - write_number_with_ubjson_prefix(j.m_value.string->size(), true); - oa->write_characters( - reinterpret_cast(j.m_value.string->c_str()), - j.m_value.string->size()); - break; - } - - case value_t::array: - { - if (add_prefix) - { - oa->write_character(to_char_type('[')); - } - - bool prefix_required = true; - if (use_type && !j.m_value.array->empty()) - { - JSON_ASSERT(use_count); - const CharType first_prefix = ubjson_prefix(j.front()); - const bool same_prefix = std::all_of(j.begin() + 1, j.end(), - [this, first_prefix](const BasicJsonType & v) - { - return ubjson_prefix(v) == first_prefix; - }); - - if (same_prefix) - { - prefix_required = false; - oa->write_character(to_char_type('$')); - oa->write_character(first_prefix); - } - } - - if (use_count) - { - oa->write_character(to_char_type('#')); - write_number_with_ubjson_prefix(j.m_value.array->size(), true); - } - - for (const auto& el : *j.m_value.array) - { - write_ubjson(el, use_count, use_type, prefix_required); - } - - if (!use_count) - { - oa->write_character(to_char_type(']')); - } - - break; - } - - case value_t::binary: - { - if (add_prefix) - { - oa->write_character(to_char_type('[')); - } - - if (use_type && !j.m_value.binary->empty()) - { - JSON_ASSERT(use_count); - oa->write_character(to_char_type('$')); - oa->write_character('U'); - } - - if (use_count) - { - oa->write_character(to_char_type('#')); - write_number_with_ubjson_prefix(j.m_value.binary->size(), true); - } - - if (use_type) - { - oa->write_characters( - reinterpret_cast(j.m_value.binary->data()), - j.m_value.binary->size()); - } - else - { - for (size_t i = 0; i < j.m_value.binary->size(); ++i) - { - oa->write_character(to_char_type('U')); - oa->write_character(j.m_value.binary->data()[i]); - } - } - - if (!use_count) - { - oa->write_character(to_char_type(']')); - } - - break; - } - - case value_t::object: - { - if (add_prefix) - { - oa->write_character(to_char_type('{')); - } - - bool prefix_required = true; - if (use_type && !j.m_value.object->empty()) - { - JSON_ASSERT(use_count); - const CharType first_prefix = ubjson_prefix(j.front()); - const bool same_prefix = std::all_of(j.begin(), j.end(), - [this, first_prefix](const BasicJsonType & v) - { - return ubjson_prefix(v) == first_prefix; - }); - - if (same_prefix) - { - prefix_required = false; - oa->write_character(to_char_type('$')); - oa->write_character(first_prefix); - } - } - - if (use_count) - { - oa->write_character(to_char_type('#')); - write_number_with_ubjson_prefix(j.m_value.object->size(), true); - } - - for (const auto& el : *j.m_value.object) - { - write_number_with_ubjson_prefix(el.first.size(), true); - oa->write_characters( - reinterpret_cast(el.first.c_str()), - el.first.size()); - write_ubjson(el.second, use_count, use_type, prefix_required); - } - - if (!use_count) - { - oa->write_character(to_char_type('}')); - } - - break; - } - - default: - break; - } - } - - private: - ////////// - // BSON // - ////////// - - /*! - @return The size of a BSON document entry header, including the id marker - and the entry name size (and its null-terminator). - */ - static std::size_t calc_bson_entry_header_size(const string_t& name, const BasicJsonType& j) - { - const auto it = name.find(static_cast(0)); - if (JSON_HEDLEY_UNLIKELY(it != BasicJsonType::string_t::npos)) - { - JSON_THROW(out_of_range::create(409, "BSON key cannot contain code point U+0000 (at byte " + std::to_string(it) + ")", j)); - } - - return /*id*/ 1ul + name.size() + /*zero-terminator*/1u; - } - - /*! - @brief Writes the given @a element_type and @a name to the output adapter - */ - void write_bson_entry_header(const string_t& name, - const std::uint8_t element_type) - { - oa->write_character(to_char_type(element_type)); // boolean - oa->write_characters( - reinterpret_cast(name.c_str()), - name.size() + 1u); - } - - /*! - @brief Writes a BSON element with key @a name and boolean value @a value - */ - void write_bson_boolean(const string_t& name, - const bool value) - { - write_bson_entry_header(name, 0x08); - oa->write_character(value ? to_char_type(0x01) : to_char_type(0x00)); - } - - /*! - @brief Writes a BSON element with key @a name and double value @a value - */ - void write_bson_double(const string_t& name, - const double value) - { - write_bson_entry_header(name, 0x01); - write_number(value); - } - - /*! - @return The size of the BSON-encoded string in @a value - */ - static std::size_t calc_bson_string_size(const string_t& value) - { - return sizeof(std::int32_t) + value.size() + 1ul; - } - - /*! - @brief Writes a BSON element with key @a name and string value @a value - */ - void write_bson_string(const string_t& name, - const string_t& value) - { - write_bson_entry_header(name, 0x02); - - write_number(static_cast(value.size() + 1ul)); - oa->write_characters( - reinterpret_cast(value.c_str()), - value.size() + 1); - } - - /*! - @brief Writes a BSON element with key @a name and null value - */ - void write_bson_null(const string_t& name) - { - write_bson_entry_header(name, 0x0A); - } - - /*! - @return The size of the BSON-encoded integer @a value - */ - static std::size_t calc_bson_integer_size(const std::int64_t value) - { - return (std::numeric_limits::min)() <= value && value <= (std::numeric_limits::max)() - ? sizeof(std::int32_t) - : sizeof(std::int64_t); - } - - /*! - @brief Writes a BSON element with key @a name and integer @a value - */ - void write_bson_integer(const string_t& name, - const std::int64_t value) - { - if ((std::numeric_limits::min)() <= value && value <= (std::numeric_limits::max)()) - { - write_bson_entry_header(name, 0x10); // int32 - write_number(static_cast(value)); - } - else - { - write_bson_entry_header(name, 0x12); // int64 - write_number(static_cast(value)); - } - } - - /*! - @return The size of the BSON-encoded unsigned integer in @a j - */ - static constexpr std::size_t calc_bson_unsigned_size(const std::uint64_t value) noexcept - { - return (value <= static_cast((std::numeric_limits::max)())) - ? sizeof(std::int32_t) - : sizeof(std::int64_t); - } - - /*! - @brief Writes a BSON element with key @a name and unsigned @a value - */ - void write_bson_unsigned(const string_t& name, - const BasicJsonType& j) - { - if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) - { - write_bson_entry_header(name, 0x10 /* int32 */); - write_number(static_cast(j.m_value.number_unsigned)); - } - else if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) - { - write_bson_entry_header(name, 0x12 /* int64 */); - write_number(static_cast(j.m_value.number_unsigned)); - } - else - { - JSON_THROW(out_of_range::create(407, "integer number " + std::to_string(j.m_value.number_unsigned) + " cannot be represented by BSON as it does not fit int64", j)); - } - } - - /*! - @brief Writes a BSON element with key @a name and object @a value - */ - void write_bson_object_entry(const string_t& name, - const typename BasicJsonType::object_t& value) - { - write_bson_entry_header(name, 0x03); // object - write_bson_object(value); - } - - /*! - @return The size of the BSON-encoded array @a value - */ - static std::size_t calc_bson_array_size(const typename BasicJsonType::array_t& value) - { - std::size_t array_index = 0ul; - - const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value), std::size_t(0), [&array_index](std::size_t result, const typename BasicJsonType::array_t::value_type & el) - { - return result + calc_bson_element_size(std::to_string(array_index++), el); - }); - - return sizeof(std::int32_t) + embedded_document_size + 1ul; - } - - /*! - @return The size of the BSON-encoded binary array @a value - */ - static std::size_t calc_bson_binary_size(const typename BasicJsonType::binary_t& value) - { - return sizeof(std::int32_t) + value.size() + 1ul; - } - - /*! - @brief Writes a BSON element with key @a name and array @a value - */ - void write_bson_array(const string_t& name, - const typename BasicJsonType::array_t& value) - { - write_bson_entry_header(name, 0x04); // array - write_number(static_cast(calc_bson_array_size(value))); - - std::size_t array_index = 0ul; - - for (const auto& el : value) - { - write_bson_element(std::to_string(array_index++), el); - } - - oa->write_character(to_char_type(0x00)); - } - - /*! - @brief Writes a BSON element with key @a name and binary value @a value - */ - void write_bson_binary(const string_t& name, - const binary_t& value) - { - write_bson_entry_header(name, 0x05); - - write_number(static_cast(value.size())); - write_number(value.has_subtype() ? value.subtype() : std::uint8_t(0x00)); - - oa->write_characters(reinterpret_cast(value.data()), value.size()); - } - - /*! - @brief Calculates the size necessary to serialize the JSON value @a j with its @a name - @return The calculated size for the BSON document entry for @a j with the given @a name. - */ - static std::size_t calc_bson_element_size(const string_t& name, - const BasicJsonType& j) - { - const auto header_size = calc_bson_entry_header_size(name, j); - switch (j.type()) - { - case value_t::object: - return header_size + calc_bson_object_size(*j.m_value.object); - - case value_t::array: - return header_size + calc_bson_array_size(*j.m_value.array); - - case value_t::binary: - return header_size + calc_bson_binary_size(*j.m_value.binary); - - case value_t::boolean: - return header_size + 1ul; - - case value_t::number_float: - return header_size + 8ul; - - case value_t::number_integer: - return header_size + calc_bson_integer_size(j.m_value.number_integer); - - case value_t::number_unsigned: - return header_size + calc_bson_unsigned_size(j.m_value.number_unsigned); - - case value_t::string: - return header_size + calc_bson_string_size(*j.m_value.string); - - case value_t::null: - return header_size + 0ul; - - // LCOV_EXCL_START - default: - JSON_ASSERT(false); - return 0ul; - // LCOV_EXCL_STOP - } - } - - /*! - @brief Serializes the JSON value @a j to BSON and associates it with the - key @a name. - @param name The name to associate with the JSON entity @a j within the - current BSON document - @return The size of the BSON entry - */ - void write_bson_element(const string_t& name, - const BasicJsonType& j) - { - switch (j.type()) - { - case value_t::object: - return write_bson_object_entry(name, *j.m_value.object); - - case value_t::array: - return write_bson_array(name, *j.m_value.array); - - case value_t::binary: - return write_bson_binary(name, *j.m_value.binary); - - case value_t::boolean: - return write_bson_boolean(name, j.m_value.boolean); - - case value_t::number_float: - return write_bson_double(name, j.m_value.number_float); - - case value_t::number_integer: - return write_bson_integer(name, j.m_value.number_integer); - - case value_t::number_unsigned: - return write_bson_unsigned(name, j); - - case value_t::string: - return write_bson_string(name, *j.m_value.string); - - case value_t::null: - return write_bson_null(name); - - // LCOV_EXCL_START - default: - JSON_ASSERT(false); - return; - // LCOV_EXCL_STOP - } - } - - /*! - @brief Calculates the size of the BSON serialization of the given - JSON-object @a j. - @param[in] j JSON value to serialize - @pre j.type() == value_t::object - */ - static std::size_t calc_bson_object_size(const typename BasicJsonType::object_t& value) - { - std::size_t document_size = std::accumulate(value.begin(), value.end(), std::size_t(0), - [](size_t result, const typename BasicJsonType::object_t::value_type & el) - { - return result += calc_bson_element_size(el.first, el.second); - }); - - return sizeof(std::int32_t) + document_size + 1ul; - } - - /*! - @param[in] j JSON value to serialize - @pre j.type() == value_t::object - */ - void write_bson_object(const typename BasicJsonType::object_t& value) - { - write_number(static_cast(calc_bson_object_size(value))); - - for (const auto& el : value) - { - write_bson_element(el.first, el.second); - } - - oa->write_character(to_char_type(0x00)); - } - - ////////// - // CBOR // - ////////// - - static constexpr CharType get_cbor_float_prefix(float /*unused*/) - { - return to_char_type(0xFA); // Single-Precision Float - } - - static constexpr CharType get_cbor_float_prefix(double /*unused*/) - { - return to_char_type(0xFB); // Double-Precision Float - } - - ///////////// - // MsgPack // - ///////////// - - static constexpr CharType get_msgpack_float_prefix(float /*unused*/) - { - return to_char_type(0xCA); // float 32 - } - - static constexpr CharType get_msgpack_float_prefix(double /*unused*/) - { - return to_char_type(0xCB); // float 64 - } - - //////////// - // UBJSON // - //////////// - - // UBJSON: write number (floating point) - template::value, int>::type = 0> - void write_number_with_ubjson_prefix(const NumberType n, - const bool add_prefix) - { - if (add_prefix) - { - oa->write_character(get_ubjson_float_prefix(n)); - } - write_number(n); - } - - // UBJSON: write number (unsigned integer) - template::value, int>::type = 0> - void write_number_with_ubjson_prefix(const NumberType n, - const bool add_prefix) - { - if (n <= static_cast((std::numeric_limits::max)())) - { - if (add_prefix) - { - oa->write_character(to_char_type('i')); // int8 - } - write_number(static_cast(n)); - } - else if (n <= (std::numeric_limits::max)()) - { - if (add_prefix) - { - oa->write_character(to_char_type('U')); // uint8 - } - write_number(static_cast(n)); - } - else if (n <= static_cast((std::numeric_limits::max)())) - { - if (add_prefix) - { - oa->write_character(to_char_type('I')); // int16 - } - write_number(static_cast(n)); - } - else if (n <= static_cast((std::numeric_limits::max)())) - { - if (add_prefix) - { - oa->write_character(to_char_type('l')); // int32 - } - write_number(static_cast(n)); - } - else if (n <= static_cast((std::numeric_limits::max)())) - { - if (add_prefix) - { - oa->write_character(to_char_type('L')); // int64 - } - write_number(static_cast(n)); - } - else - { - if (add_prefix) - { - oa->write_character(to_char_type('H')); // high-precision number - } - - const auto number = BasicJsonType(n).dump(); - write_number_with_ubjson_prefix(number.size(), true); - for (std::size_t i = 0; i < number.size(); ++i) - { - oa->write_character(to_char_type(static_cast(number[i]))); - } - } - } - - // UBJSON: write number (signed integer) - template < typename NumberType, typename std::enable_if < - std::is_signed::value&& - !std::is_floating_point::value, int >::type = 0 > - void write_number_with_ubjson_prefix(const NumberType n, - const bool add_prefix) - { - if ((std::numeric_limits::min)() <= n && n <= (std::numeric_limits::max)()) - { - if (add_prefix) - { - oa->write_character(to_char_type('i')); // int8 - } - write_number(static_cast(n)); - } - else if (static_cast((std::numeric_limits::min)()) <= n && n <= static_cast((std::numeric_limits::max)())) - { - if (add_prefix) - { - oa->write_character(to_char_type('U')); // uint8 - } - write_number(static_cast(n)); - } - else if ((std::numeric_limits::min)() <= n && n <= (std::numeric_limits::max)()) - { - if (add_prefix) - { - oa->write_character(to_char_type('I')); // int16 - } - write_number(static_cast(n)); - } - else if ((std::numeric_limits::min)() <= n && n <= (std::numeric_limits::max)()) - { - if (add_prefix) - { - oa->write_character(to_char_type('l')); // int32 - } - write_number(static_cast(n)); - } - else if ((std::numeric_limits::min)() <= n && n <= (std::numeric_limits::max)()) - { - if (add_prefix) - { - oa->write_character(to_char_type('L')); // int64 - } - write_number(static_cast(n)); - } - // LCOV_EXCL_START - else - { - if (add_prefix) - { - oa->write_character(to_char_type('H')); // high-precision number - } - - const auto number = BasicJsonType(n).dump(); - write_number_with_ubjson_prefix(number.size(), true); - for (std::size_t i = 0; i < number.size(); ++i) - { - oa->write_character(to_char_type(static_cast(number[i]))); - } - } - // LCOV_EXCL_STOP - } - - /*! - @brief determine the type prefix of container values - */ - CharType ubjson_prefix(const BasicJsonType& j) const noexcept - { - switch (j.type()) - { - case value_t::null: - return 'Z'; - - case value_t::boolean: - return j.m_value.boolean ? 'T' : 'F'; - - case value_t::number_integer: - { - if ((std::numeric_limits::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits::max)()) - { - return 'i'; - } - if ((std::numeric_limits::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits::max)()) - { - return 'U'; - } - if ((std::numeric_limits::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits::max)()) - { - return 'I'; - } - if ((std::numeric_limits::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits::max)()) - { - return 'l'; - } - if ((std::numeric_limits::min)() <= j.m_value.number_integer && j.m_value.number_integer <= (std::numeric_limits::max)()) - { - return 'L'; - } - // anything else is treated as high-precision number - return 'H'; // LCOV_EXCL_LINE - } - - case value_t::number_unsigned: - { - if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) - { - return 'i'; - } - if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) - { - return 'U'; - } - if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) - { - return 'I'; - } - if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) - { - return 'l'; - } - if (j.m_value.number_unsigned <= static_cast((std::numeric_limits::max)())) - { - return 'L'; - } - // anything else is treated as high-precision number - return 'H'; // LCOV_EXCL_LINE - } - - case value_t::number_float: - return get_ubjson_float_prefix(j.m_value.number_float); - - case value_t::string: - return 'S'; - - case value_t::array: // fallthrough - case value_t::binary: - return '['; - - case value_t::object: - return '{'; - - default: // discarded values - return 'N'; - } - } - - static constexpr CharType get_ubjson_float_prefix(float /*unused*/) - { - return 'd'; // float 32 - } - - static constexpr CharType get_ubjson_float_prefix(double /*unused*/) - { - return 'D'; // float 64 - } - - /////////////////////// - // Utility functions // - /////////////////////// - - /* - @brief write a number to output input - @param[in] n number of type @a NumberType - @tparam NumberType the type of the number - @tparam OutputIsLittleEndian Set to true if output data is - required to be little endian - - @note This function needs to respect the system's endianess, because bytes - in CBOR, MessagePack, and UBJSON are stored in network order (big - endian) and therefore need reordering on little endian systems. - */ - template - void write_number(const NumberType n) - { - // step 1: write number to array of length NumberType - std::array vec; - std::memcpy(vec.data(), &n, sizeof(NumberType)); - - // step 2: write array to output (with possible reordering) - if (is_little_endian != OutputIsLittleEndian) - { - // reverse byte order prior to conversion if necessary - std::reverse(vec.begin(), vec.end()); - } - - oa->write_characters(vec.data(), sizeof(NumberType)); - } - - void write_compact_float(const number_float_t n, detail::input_format_t format) - { - if (static_cast(n) >= static_cast(std::numeric_limits::lowest()) && - static_cast(n) <= static_cast((std::numeric_limits::max)()) && - static_cast(static_cast(n)) == static_cast(n)) - { - oa->write_character(format == detail::input_format_t::cbor - ? get_cbor_float_prefix(static_cast(n)) - : get_msgpack_float_prefix(static_cast(n))); - write_number(static_cast(n)); - } - else - { - oa->write_character(format == detail::input_format_t::cbor - ? get_cbor_float_prefix(n) - : get_msgpack_float_prefix(n)); - write_number(n); - } - } - - public: - // The following to_char_type functions are implement the conversion - // between uint8_t and CharType. In case CharType is not unsigned, - // such a conversion is required to allow values greater than 128. - // See for a discussion. - template < typename C = CharType, - enable_if_t < std::is_signed::value && std::is_signed::value > * = nullptr > - static constexpr CharType to_char_type(std::uint8_t x) noexcept - { - return *reinterpret_cast(&x); - } - - template < typename C = CharType, - enable_if_t < std::is_signed::value && std::is_unsigned::value > * = nullptr > - static CharType to_char_type(std::uint8_t x) noexcept - { - static_assert(sizeof(std::uint8_t) == sizeof(CharType), "size of CharType must be equal to std::uint8_t"); - static_assert(std::is_trivial::value, "CharType must be trivial"); - CharType result; - std::memcpy(&result, &x, sizeof(x)); - return result; - } - - template::value>* = nullptr> - static constexpr CharType to_char_type(std::uint8_t x) noexcept - { - return x; - } - - template < typename InputCharType, typename C = CharType, - enable_if_t < - std::is_signed::value && - std::is_signed::value && - std::is_same::type>::value - > * = nullptr > - static constexpr CharType to_char_type(InputCharType x) noexcept - { - return x; - } - - private: - /// whether we can assume little endianess - const bool is_little_endian = little_endianess(); - - /// the output - output_adapter_t oa = nullptr; -}; -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - - -#include // reverse, remove, fill, find, none_of -#include // array -#include // localeconv, lconv -#include // labs, isfinite, isnan, signbit -#include // size_t, ptrdiff_t -#include // uint8_t -#include // snprintf -#include // numeric_limits -#include // string, char_traits -#include // is_same -#include // move - -// #include - - -#include // array -#include // signbit, isfinite -#include // intN_t, uintN_t -#include // memcpy, memmove -#include // numeric_limits -#include // conditional - -// #include - - -namespace nlohmann -{ -namespace detail -{ - -/*! -@brief implements the Grisu2 algorithm for binary to decimal floating-point -conversion. - -This implementation is a slightly modified version of the reference -implementation which may be obtained from -http://florian.loitsch.com/publications (bench.tar.gz). - -The code is distributed under the MIT license, Copyright (c) 2009 Florian Loitsch. - -For a detailed description of the algorithm see: - -[1] Loitsch, "Printing Floating-Point Numbers Quickly and Accurately with - Integers", Proceedings of the ACM SIGPLAN 2010 Conference on Programming - Language Design and Implementation, PLDI 2010 -[2] Burger, Dybvig, "Printing Floating-Point Numbers Quickly and Accurately", - Proceedings of the ACM SIGPLAN 1996 Conference on Programming Language - Design and Implementation, PLDI 1996 -*/ -namespace dtoa_impl -{ - -template -Target reinterpret_bits(const Source source) -{ - static_assert(sizeof(Target) == sizeof(Source), "size mismatch"); - - Target target; - std::memcpy(&target, &source, sizeof(Source)); - return target; -} - -struct diyfp // f * 2^e -{ - static constexpr int kPrecision = 64; // = q - - std::uint64_t f = 0; - int e = 0; - - constexpr diyfp(std::uint64_t f_, int e_) noexcept : f(f_), e(e_) {} - - /*! - @brief returns x - y - @pre x.e == y.e and x.f >= y.f - */ - static diyfp sub(const diyfp& x, const diyfp& y) noexcept - { - JSON_ASSERT(x.e == y.e); - JSON_ASSERT(x.f >= y.f); - - return {x.f - y.f, x.e}; - } - - /*! - @brief returns x * y - @note The result is rounded. (Only the upper q bits are returned.) - */ - static diyfp mul(const diyfp& x, const diyfp& y) noexcept - { - static_assert(kPrecision == 64, "internal error"); - - // Computes: - // f = round((x.f * y.f) / 2^q) - // e = x.e + y.e + q - - // Emulate the 64-bit * 64-bit multiplication: - // - // p = u * v - // = (u_lo + 2^32 u_hi) (v_lo + 2^32 v_hi) - // = (u_lo v_lo ) + 2^32 ((u_lo v_hi ) + (u_hi v_lo )) + 2^64 (u_hi v_hi ) - // = (p0 ) + 2^32 ((p1 ) + (p2 )) + 2^64 (p3 ) - // = (p0_lo + 2^32 p0_hi) + 2^32 ((p1_lo + 2^32 p1_hi) + (p2_lo + 2^32 p2_hi)) + 2^64 (p3 ) - // = (p0_lo ) + 2^32 (p0_hi + p1_lo + p2_lo ) + 2^64 (p1_hi + p2_hi + p3) - // = (p0_lo ) + 2^32 (Q ) + 2^64 (H ) - // = (p0_lo ) + 2^32 (Q_lo + 2^32 Q_hi ) + 2^64 (H ) - // - // (Since Q might be larger than 2^32 - 1) - // - // = (p0_lo + 2^32 Q_lo) + 2^64 (Q_hi + H) - // - // (Q_hi + H does not overflow a 64-bit int) - // - // = p_lo + 2^64 p_hi - - const std::uint64_t u_lo = x.f & 0xFFFFFFFFu; - const std::uint64_t u_hi = x.f >> 32u; - const std::uint64_t v_lo = y.f & 0xFFFFFFFFu; - const std::uint64_t v_hi = y.f >> 32u; - - const std::uint64_t p0 = u_lo * v_lo; - const std::uint64_t p1 = u_lo * v_hi; - const std::uint64_t p2 = u_hi * v_lo; - const std::uint64_t p3 = u_hi * v_hi; - - const std::uint64_t p0_hi = p0 >> 32u; - const std::uint64_t p1_lo = p1 & 0xFFFFFFFFu; - const std::uint64_t p1_hi = p1 >> 32u; - const std::uint64_t p2_lo = p2 & 0xFFFFFFFFu; - const std::uint64_t p2_hi = p2 >> 32u; - - std::uint64_t Q = p0_hi + p1_lo + p2_lo; - - // The full product might now be computed as - // - // p_hi = p3 + p2_hi + p1_hi + (Q >> 32) - // p_lo = p0_lo + (Q << 32) - // - // But in this particular case here, the full p_lo is not required. - // Effectively we only need to add the highest bit in p_lo to p_hi (and - // Q_hi + 1 does not overflow). - - Q += std::uint64_t{1} << (64u - 32u - 1u); // round, ties up - - const std::uint64_t h = p3 + p2_hi + p1_hi + (Q >> 32u); - - return {h, x.e + y.e + 64}; - } - - /*! - @brief normalize x such that the significand is >= 2^(q-1) - @pre x.f != 0 - */ - static diyfp normalize(diyfp x) noexcept - { - JSON_ASSERT(x.f != 0); - - while ((x.f >> 63u) == 0) - { - x.f <<= 1u; - x.e--; - } - - return x; - } - - /*! - @brief normalize x such that the result has the exponent E - @pre e >= x.e and the upper e - x.e bits of x.f must be zero. - */ - static diyfp normalize_to(const diyfp& x, const int target_exponent) noexcept - { - const int delta = x.e - target_exponent; - - JSON_ASSERT(delta >= 0); - JSON_ASSERT(((x.f << delta) >> delta) == x.f); - - return {x.f << delta, target_exponent}; - } -}; - -struct boundaries -{ - diyfp w; - diyfp minus; - diyfp plus; -}; - -/*! -Compute the (normalized) diyfp representing the input number 'value' and its -boundaries. - -@pre value must be finite and positive -*/ -template -boundaries compute_boundaries(FloatType value) -{ - JSON_ASSERT(std::isfinite(value)); - JSON_ASSERT(value > 0); - - // Convert the IEEE representation into a diyfp. - // - // If v is denormal: - // value = 0.F * 2^(1 - bias) = ( F) * 2^(1 - bias - (p-1)) - // If v is normalized: - // value = 1.F * 2^(E - bias) = (2^(p-1) + F) * 2^(E - bias - (p-1)) - - static_assert(std::numeric_limits::is_iec559, - "internal error: dtoa_short requires an IEEE-754 floating-point implementation"); - - constexpr int kPrecision = std::numeric_limits::digits; // = p (includes the hidden bit) - constexpr int kBias = std::numeric_limits::max_exponent - 1 + (kPrecision - 1); - constexpr int kMinExp = 1 - kBias; - constexpr std::uint64_t kHiddenBit = std::uint64_t{1} << (kPrecision - 1); // = 2^(p-1) - - using bits_type = typename std::conditional::type; - - const std::uint64_t bits = reinterpret_bits(value); - const std::uint64_t E = bits >> (kPrecision - 1); - const std::uint64_t F = bits & (kHiddenBit - 1); - - const bool is_denormal = E == 0; - const diyfp v = is_denormal - ? diyfp(F, kMinExp) - : diyfp(F + kHiddenBit, static_cast(E) - kBias); - - // Compute the boundaries m- and m+ of the floating-point value - // v = f * 2^e. - // - // Determine v- and v+, the floating-point predecessor and successor if v, - // respectively. - // - // v- = v - 2^e if f != 2^(p-1) or e == e_min (A) - // = v - 2^(e-1) if f == 2^(p-1) and e > e_min (B) - // - // v+ = v + 2^e - // - // Let m- = (v- + v) / 2 and m+ = (v + v+) / 2. All real numbers _strictly_ - // between m- and m+ round to v, regardless of how the input rounding - // algorithm breaks ties. - // - // ---+-------------+-------------+-------------+-------------+--- (A) - // v- m- v m+ v+ - // - // -----------------+------+------+-------------+-------------+--- (B) - // v- m- v m+ v+ - - const bool lower_boundary_is_closer = F == 0 && E > 1; - const diyfp m_plus = diyfp(2 * v.f + 1, v.e - 1); - const diyfp m_minus = lower_boundary_is_closer - ? diyfp(4 * v.f - 1, v.e - 2) // (B) - : diyfp(2 * v.f - 1, v.e - 1); // (A) - - // Determine the normalized w+ = m+. - const diyfp w_plus = diyfp::normalize(m_plus); - - // Determine w- = m- such that e_(w-) = e_(w+). - const diyfp w_minus = diyfp::normalize_to(m_minus, w_plus.e); - - return {diyfp::normalize(v), w_minus, w_plus}; -} - -// Given normalized diyfp w, Grisu needs to find a (normalized) cached -// power-of-ten c, such that the exponent of the product c * w = f * 2^e lies -// within a certain range [alpha, gamma] (Definition 3.2 from [1]) -// -// alpha <= e = e_c + e_w + q <= gamma -// -// or -// -// f_c * f_w * 2^alpha <= f_c 2^(e_c) * f_w 2^(e_w) * 2^q -// <= f_c * f_w * 2^gamma -// -// Since c and w are normalized, i.e. 2^(q-1) <= f < 2^q, this implies -// -// 2^(q-1) * 2^(q-1) * 2^alpha <= c * w * 2^q < 2^q * 2^q * 2^gamma -// -// or -// -// 2^(q - 2 + alpha) <= c * w < 2^(q + gamma) -// -// The choice of (alpha,gamma) determines the size of the table and the form of -// the digit generation procedure. Using (alpha,gamma)=(-60,-32) works out well -// in practice: -// -// The idea is to cut the number c * w = f * 2^e into two parts, which can be -// processed independently: An integral part p1, and a fractional part p2: -// -// f * 2^e = ( (f div 2^-e) * 2^-e + (f mod 2^-e) ) * 2^e -// = (f div 2^-e) + (f mod 2^-e) * 2^e -// = p1 + p2 * 2^e -// -// The conversion of p1 into decimal form requires a series of divisions and -// modulos by (a power of) 10. These operations are faster for 32-bit than for -// 64-bit integers, so p1 should ideally fit into a 32-bit integer. This can be -// achieved by choosing -// -// -e >= 32 or e <= -32 := gamma -// -// In order to convert the fractional part -// -// p2 * 2^e = p2 / 2^-e = d[-1] / 10^1 + d[-2] / 10^2 + ... -// -// into decimal form, the fraction is repeatedly multiplied by 10 and the digits -// d[-i] are extracted in order: -// -// (10 * p2) div 2^-e = d[-1] -// (10 * p2) mod 2^-e = d[-2] / 10^1 + ... -// -// The multiplication by 10 must not overflow. It is sufficient to choose -// -// 10 * p2 < 16 * p2 = 2^4 * p2 <= 2^64. -// -// Since p2 = f mod 2^-e < 2^-e, -// -// -e <= 60 or e >= -60 := alpha - -constexpr int kAlpha = -60; -constexpr int kGamma = -32; - -struct cached_power // c = f * 2^e ~= 10^k -{ - std::uint64_t f; - int e; - int k; -}; - -/*! -For a normalized diyfp w = f * 2^e, this function returns a (normalized) cached -power-of-ten c = f_c * 2^e_c, such that the exponent of the product w * c -satisfies (Definition 3.2 from [1]) - - alpha <= e_c + e + q <= gamma. -*/ -inline cached_power get_cached_power_for_binary_exponent(int e) -{ - // Now - // - // alpha <= e_c + e + q <= gamma (1) - // ==> f_c * 2^alpha <= c * 2^e * 2^q - // - // and since the c's are normalized, 2^(q-1) <= f_c, - // - // ==> 2^(q - 1 + alpha) <= c * 2^(e + q) - // ==> 2^(alpha - e - 1) <= c - // - // If c were an exact power of ten, i.e. c = 10^k, one may determine k as - // - // k = ceil( log_10( 2^(alpha - e - 1) ) ) - // = ceil( (alpha - e - 1) * log_10(2) ) - // - // From the paper: - // "In theory the result of the procedure could be wrong since c is rounded, - // and the computation itself is approximated [...]. In practice, however, - // this simple function is sufficient." - // - // For IEEE double precision floating-point numbers converted into - // normalized diyfp's w = f * 2^e, with q = 64, - // - // e >= -1022 (min IEEE exponent) - // -52 (p - 1) - // -52 (p - 1, possibly normalize denormal IEEE numbers) - // -11 (normalize the diyfp) - // = -1137 - // - // and - // - // e <= +1023 (max IEEE exponent) - // -52 (p - 1) - // -11 (normalize the diyfp) - // = 960 - // - // This binary exponent range [-1137,960] results in a decimal exponent - // range [-307,324]. One does not need to store a cached power for each - // k in this range. For each such k it suffices to find a cached power - // such that the exponent of the product lies in [alpha,gamma]. - // This implies that the difference of the decimal exponents of adjacent - // table entries must be less than or equal to - // - // floor( (gamma - alpha) * log_10(2) ) = 8. - // - // (A smaller distance gamma-alpha would require a larger table.) - - // NB: - // Actually this function returns c, such that -60 <= e_c + e + 64 <= -34. - - constexpr int kCachedPowersMinDecExp = -300; - constexpr int kCachedPowersDecStep = 8; - - static constexpr std::array kCachedPowers = - { - { - { 0xAB70FE17C79AC6CA, -1060, -300 }, - { 0xFF77B1FCBEBCDC4F, -1034, -292 }, - { 0xBE5691EF416BD60C, -1007, -284 }, - { 0x8DD01FAD907FFC3C, -980, -276 }, - { 0xD3515C2831559A83, -954, -268 }, - { 0x9D71AC8FADA6C9B5, -927, -260 }, - { 0xEA9C227723EE8BCB, -901, -252 }, - { 0xAECC49914078536D, -874, -244 }, - { 0x823C12795DB6CE57, -847, -236 }, - { 0xC21094364DFB5637, -821, -228 }, - { 0x9096EA6F3848984F, -794, -220 }, - { 0xD77485CB25823AC7, -768, -212 }, - { 0xA086CFCD97BF97F4, -741, -204 }, - { 0xEF340A98172AACE5, -715, -196 }, - { 0xB23867FB2A35B28E, -688, -188 }, - { 0x84C8D4DFD2C63F3B, -661, -180 }, - { 0xC5DD44271AD3CDBA, -635, -172 }, - { 0x936B9FCEBB25C996, -608, -164 }, - { 0xDBAC6C247D62A584, -582, -156 }, - { 0xA3AB66580D5FDAF6, -555, -148 }, - { 0xF3E2F893DEC3F126, -529, -140 }, - { 0xB5B5ADA8AAFF80B8, -502, -132 }, - { 0x87625F056C7C4A8B, -475, -124 }, - { 0xC9BCFF6034C13053, -449, -116 }, - { 0x964E858C91BA2655, -422, -108 }, - { 0xDFF9772470297EBD, -396, -100 }, - { 0xA6DFBD9FB8E5B88F, -369, -92 }, - { 0xF8A95FCF88747D94, -343, -84 }, - { 0xB94470938FA89BCF, -316, -76 }, - { 0x8A08F0F8BF0F156B, -289, -68 }, - { 0xCDB02555653131B6, -263, -60 }, - { 0x993FE2C6D07B7FAC, -236, -52 }, - { 0xE45C10C42A2B3B06, -210, -44 }, - { 0xAA242499697392D3, -183, -36 }, - { 0xFD87B5F28300CA0E, -157, -28 }, - { 0xBCE5086492111AEB, -130, -20 }, - { 0x8CBCCC096F5088CC, -103, -12 }, - { 0xD1B71758E219652C, -77, -4 }, - { 0x9C40000000000000, -50, 4 }, - { 0xE8D4A51000000000, -24, 12 }, - { 0xAD78EBC5AC620000, 3, 20 }, - { 0x813F3978F8940984, 30, 28 }, - { 0xC097CE7BC90715B3, 56, 36 }, - { 0x8F7E32CE7BEA5C70, 83, 44 }, - { 0xD5D238A4ABE98068, 109, 52 }, - { 0x9F4F2726179A2245, 136, 60 }, - { 0xED63A231D4C4FB27, 162, 68 }, - { 0xB0DE65388CC8ADA8, 189, 76 }, - { 0x83C7088E1AAB65DB, 216, 84 }, - { 0xC45D1DF942711D9A, 242, 92 }, - { 0x924D692CA61BE758, 269, 100 }, - { 0xDA01EE641A708DEA, 295, 108 }, - { 0xA26DA3999AEF774A, 322, 116 }, - { 0xF209787BB47D6B85, 348, 124 }, - { 0xB454E4A179DD1877, 375, 132 }, - { 0x865B86925B9BC5C2, 402, 140 }, - { 0xC83553C5C8965D3D, 428, 148 }, - { 0x952AB45CFA97A0B3, 455, 156 }, - { 0xDE469FBD99A05FE3, 481, 164 }, - { 0xA59BC234DB398C25, 508, 172 }, - { 0xF6C69A72A3989F5C, 534, 180 }, - { 0xB7DCBF5354E9BECE, 561, 188 }, - { 0x88FCF317F22241E2, 588, 196 }, - { 0xCC20CE9BD35C78A5, 614, 204 }, - { 0x98165AF37B2153DF, 641, 212 }, - { 0xE2A0B5DC971F303A, 667, 220 }, - { 0xA8D9D1535CE3B396, 694, 228 }, - { 0xFB9B7CD9A4A7443C, 720, 236 }, - { 0xBB764C4CA7A44410, 747, 244 }, - { 0x8BAB8EEFB6409C1A, 774, 252 }, - { 0xD01FEF10A657842C, 800, 260 }, - { 0x9B10A4E5E9913129, 827, 268 }, - { 0xE7109BFBA19C0C9D, 853, 276 }, - { 0xAC2820D9623BF429, 880, 284 }, - { 0x80444B5E7AA7CF85, 907, 292 }, - { 0xBF21E44003ACDD2D, 933, 300 }, - { 0x8E679C2F5E44FF8F, 960, 308 }, - { 0xD433179D9C8CB841, 986, 316 }, - { 0x9E19DB92B4E31BA9, 1013, 324 }, - } - }; - - // This computation gives exactly the same results for k as - // k = ceil((kAlpha - e - 1) * 0.30102999566398114) - // for |e| <= 1500, but doesn't require floating-point operations. - // NB: log_10(2) ~= 78913 / 2^18 - JSON_ASSERT(e >= -1500); - JSON_ASSERT(e <= 1500); - const int f = kAlpha - e - 1; - const int k = (f * 78913) / (1 << 18) + static_cast(f > 0); - - const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep; - JSON_ASSERT(index >= 0); - JSON_ASSERT(static_cast(index) < kCachedPowers.size()); - - const cached_power cached = kCachedPowers[static_cast(index)]; - JSON_ASSERT(kAlpha <= cached.e + e + 64); - JSON_ASSERT(kGamma >= cached.e + e + 64); - - return cached; -} - -/*! -For n != 0, returns k, such that pow10 := 10^(k-1) <= n < 10^k. -For n == 0, returns 1 and sets pow10 := 1. -*/ -inline int find_largest_pow10(const std::uint32_t n, std::uint32_t& pow10) -{ - // LCOV_EXCL_START - if (n >= 1000000000) - { - pow10 = 1000000000; - return 10; - } - // LCOV_EXCL_STOP - if (n >= 100000000) - { - pow10 = 100000000; - return 9; - } - if (n >= 10000000) - { - pow10 = 10000000; - return 8; - } - if (n >= 1000000) - { - pow10 = 1000000; - return 7; - } - if (n >= 100000) - { - pow10 = 100000; - return 6; - } - if (n >= 10000) - { - pow10 = 10000; - return 5; - } - if (n >= 1000) - { - pow10 = 1000; - return 4; - } - if (n >= 100) - { - pow10 = 100; - return 3; - } - if (n >= 10) - { - pow10 = 10; - return 2; - } - - pow10 = 1; - return 1; -} - -inline void grisu2_round(char* buf, int len, std::uint64_t dist, std::uint64_t delta, - std::uint64_t rest, std::uint64_t ten_k) -{ - JSON_ASSERT(len >= 1); - JSON_ASSERT(dist <= delta); - JSON_ASSERT(rest <= delta); - JSON_ASSERT(ten_k > 0); - - // <--------------------------- delta ----> - // <---- dist ---------> - // --------------[------------------+-------------------]-------------- - // M- w M+ - // - // ten_k - // <------> - // <---- rest ----> - // --------------[------------------+----+--------------]-------------- - // w V - // = buf * 10^k - // - // ten_k represents a unit-in-the-last-place in the decimal representation - // stored in buf. - // Decrement buf by ten_k while this takes buf closer to w. - - // The tests are written in this order to avoid overflow in unsigned - // integer arithmetic. - - while (rest < dist - && delta - rest >= ten_k - && (rest + ten_k < dist || dist - rest > rest + ten_k - dist)) - { - JSON_ASSERT(buf[len - 1] != '0'); - buf[len - 1]--; - rest += ten_k; - } -} - -/*! -Generates V = buffer * 10^decimal_exponent, such that M- <= V <= M+. -M- and M+ must be normalized and share the same exponent -60 <= e <= -32. -*/ -inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent, - diyfp M_minus, diyfp w, diyfp M_plus) -{ - static_assert(kAlpha >= -60, "internal error"); - static_assert(kGamma <= -32, "internal error"); - - // Generates the digits (and the exponent) of a decimal floating-point - // number V = buffer * 10^decimal_exponent in the range [M-, M+]. The diyfp's - // w, M- and M+ share the same exponent e, which satisfies alpha <= e <= gamma. - // - // <--------------------------- delta ----> - // <---- dist ---------> - // --------------[------------------+-------------------]-------------- - // M- w M+ - // - // Grisu2 generates the digits of M+ from left to right and stops as soon as - // V is in [M-,M+]. - - JSON_ASSERT(M_plus.e >= kAlpha); - JSON_ASSERT(M_plus.e <= kGamma); - - std::uint64_t delta = diyfp::sub(M_plus, M_minus).f; // (significand of (M+ - M-), implicit exponent is e) - std::uint64_t dist = diyfp::sub(M_plus, w ).f; // (significand of (M+ - w ), implicit exponent is e) - - // Split M+ = f * 2^e into two parts p1 and p2 (note: e < 0): - // - // M+ = f * 2^e - // = ((f div 2^-e) * 2^-e + (f mod 2^-e)) * 2^e - // = ((p1 ) * 2^-e + (p2 )) * 2^e - // = p1 + p2 * 2^e - - const diyfp one(std::uint64_t{1} << -M_plus.e, M_plus.e); - - auto p1 = static_cast(M_plus.f >> -one.e); // p1 = f div 2^-e (Since -e >= 32, p1 fits into a 32-bit int.) - std::uint64_t p2 = M_plus.f & (one.f - 1); // p2 = f mod 2^-e - - // 1) - // - // Generate the digits of the integral part p1 = d[n-1]...d[1]d[0] - - JSON_ASSERT(p1 > 0); - - std::uint32_t pow10; - const int k = find_largest_pow10(p1, pow10); - - // 10^(k-1) <= p1 < 10^k, pow10 = 10^(k-1) - // - // p1 = (p1 div 10^(k-1)) * 10^(k-1) + (p1 mod 10^(k-1)) - // = (d[k-1] ) * 10^(k-1) + (p1 mod 10^(k-1)) - // - // M+ = p1 + p2 * 2^e - // = d[k-1] * 10^(k-1) + (p1 mod 10^(k-1)) + p2 * 2^e - // = d[k-1] * 10^(k-1) + ((p1 mod 10^(k-1)) * 2^-e + p2) * 2^e - // = d[k-1] * 10^(k-1) + ( rest) * 2^e - // - // Now generate the digits d[n] of p1 from left to right (n = k-1,...,0) - // - // p1 = d[k-1]...d[n] * 10^n + d[n-1]...d[0] - // - // but stop as soon as - // - // rest * 2^e = (d[n-1]...d[0] * 2^-e + p2) * 2^e <= delta * 2^e - - int n = k; - while (n > 0) - { - // Invariants: - // M+ = buffer * 10^n + (p1 + p2 * 2^e) (buffer = 0 for n = k) - // pow10 = 10^(n-1) <= p1 < 10^n - // - const std::uint32_t d = p1 / pow10; // d = p1 div 10^(n-1) - const std::uint32_t r = p1 % pow10; // r = p1 mod 10^(n-1) - // - // M+ = buffer * 10^n + (d * 10^(n-1) + r) + p2 * 2^e - // = (buffer * 10 + d) * 10^(n-1) + (r + p2 * 2^e) - // - JSON_ASSERT(d <= 9); - buffer[length++] = static_cast('0' + d); // buffer := buffer * 10 + d - // - // M+ = buffer * 10^(n-1) + (r + p2 * 2^e) - // - p1 = r; - n--; - // - // M+ = buffer * 10^n + (p1 + p2 * 2^e) - // pow10 = 10^n - // - - // Now check if enough digits have been generated. - // Compute - // - // p1 + p2 * 2^e = (p1 * 2^-e + p2) * 2^e = rest * 2^e - // - // Note: - // Since rest and delta share the same exponent e, it suffices to - // compare the significands. - const std::uint64_t rest = (std::uint64_t{p1} << -one.e) + p2; - if (rest <= delta) - { - // V = buffer * 10^n, with M- <= V <= M+. - - decimal_exponent += n; - - // We may now just stop. But instead look if the buffer could be - // decremented to bring V closer to w. - // - // pow10 = 10^n is now 1 ulp in the decimal representation V. - // The rounding procedure works with diyfp's with an implicit - // exponent of e. - // - // 10^n = (10^n * 2^-e) * 2^e = ulp * 2^e - // - const std::uint64_t ten_n = std::uint64_t{pow10} << -one.e; - grisu2_round(buffer, length, dist, delta, rest, ten_n); - - return; - } - - pow10 /= 10; - // - // pow10 = 10^(n-1) <= p1 < 10^n - // Invariants restored. - } - - // 2) - // - // The digits of the integral part have been generated: - // - // M+ = d[k-1]...d[1]d[0] + p2 * 2^e - // = buffer + p2 * 2^e - // - // Now generate the digits of the fractional part p2 * 2^e. - // - // Note: - // No decimal point is generated: the exponent is adjusted instead. - // - // p2 actually represents the fraction - // - // p2 * 2^e - // = p2 / 2^-e - // = d[-1] / 10^1 + d[-2] / 10^2 + ... - // - // Now generate the digits d[-m] of p1 from left to right (m = 1,2,...) - // - // p2 * 2^e = d[-1]d[-2]...d[-m] * 10^-m - // + 10^-m * (d[-m-1] / 10^1 + d[-m-2] / 10^2 + ...) - // - // using - // - // 10^m * p2 = ((10^m * p2) div 2^-e) * 2^-e + ((10^m * p2) mod 2^-e) - // = ( d) * 2^-e + ( r) - // - // or - // 10^m * p2 * 2^e = d + r * 2^e - // - // i.e. - // - // M+ = buffer + p2 * 2^e - // = buffer + 10^-m * (d + r * 2^e) - // = (buffer * 10^m + d) * 10^-m + 10^-m * r * 2^e - // - // and stop as soon as 10^-m * r * 2^e <= delta * 2^e - - JSON_ASSERT(p2 > delta); - - int m = 0; - for (;;) - { - // Invariant: - // M+ = buffer * 10^-m + 10^-m * (d[-m-1] / 10 + d[-m-2] / 10^2 + ...) * 2^e - // = buffer * 10^-m + 10^-m * (p2 ) * 2^e - // = buffer * 10^-m + 10^-m * (1/10 * (10 * p2) ) * 2^e - // = buffer * 10^-m + 10^-m * (1/10 * ((10*p2 div 2^-e) * 2^-e + (10*p2 mod 2^-e)) * 2^e - // - JSON_ASSERT(p2 <= (std::numeric_limits::max)() / 10); - p2 *= 10; - const std::uint64_t d = p2 >> -one.e; // d = (10 * p2) div 2^-e - const std::uint64_t r = p2 & (one.f - 1); // r = (10 * p2) mod 2^-e - // - // M+ = buffer * 10^-m + 10^-m * (1/10 * (d * 2^-e + r) * 2^e - // = buffer * 10^-m + 10^-m * (1/10 * (d + r * 2^e)) - // = (buffer * 10 + d) * 10^(-m-1) + 10^(-m-1) * r * 2^e - // - JSON_ASSERT(d <= 9); - buffer[length++] = static_cast('0' + d); // buffer := buffer * 10 + d - // - // M+ = buffer * 10^(-m-1) + 10^(-m-1) * r * 2^e - // - p2 = r; - m++; - // - // M+ = buffer * 10^-m + 10^-m * p2 * 2^e - // Invariant restored. - - // Check if enough digits have been generated. - // - // 10^-m * p2 * 2^e <= delta * 2^e - // p2 * 2^e <= 10^m * delta * 2^e - // p2 <= 10^m * delta - delta *= 10; - dist *= 10; - if (p2 <= delta) - { - break; - } - } - - // V = buffer * 10^-m, with M- <= V <= M+. - - decimal_exponent -= m; - - // 1 ulp in the decimal representation is now 10^-m. - // Since delta and dist are now scaled by 10^m, we need to do the - // same with ulp in order to keep the units in sync. - // - // 10^m * 10^-m = 1 = 2^-e * 2^e = ten_m * 2^e - // - const std::uint64_t ten_m = one.f; - grisu2_round(buffer, length, dist, delta, p2, ten_m); - - // By construction this algorithm generates the shortest possible decimal - // number (Loitsch, Theorem 6.2) which rounds back to w. - // For an input number of precision p, at least - // - // N = 1 + ceil(p * log_10(2)) - // - // decimal digits are sufficient to identify all binary floating-point - // numbers (Matula, "In-and-Out conversions"). - // This implies that the algorithm does not produce more than N decimal - // digits. - // - // N = 17 for p = 53 (IEEE double precision) - // N = 9 for p = 24 (IEEE single precision) -} - -/*! -v = buf * 10^decimal_exponent -len is the length of the buffer (number of decimal digits) -The buffer must be large enough, i.e. >= max_digits10. -*/ -JSON_HEDLEY_NON_NULL(1) -inline void grisu2(char* buf, int& len, int& decimal_exponent, - diyfp m_minus, diyfp v, diyfp m_plus) -{ - JSON_ASSERT(m_plus.e == m_minus.e); - JSON_ASSERT(m_plus.e == v.e); - - // --------(-----------------------+-----------------------)-------- (A) - // m- v m+ - // - // --------------------(-----------+-----------------------)-------- (B) - // m- v m+ - // - // First scale v (and m- and m+) such that the exponent is in the range - // [alpha, gamma]. - - const cached_power cached = get_cached_power_for_binary_exponent(m_plus.e); - - const diyfp c_minus_k(cached.f, cached.e); // = c ~= 10^-k - - // The exponent of the products is = v.e + c_minus_k.e + q and is in the range [alpha,gamma] - const diyfp w = diyfp::mul(v, c_minus_k); - const diyfp w_minus = diyfp::mul(m_minus, c_minus_k); - const diyfp w_plus = diyfp::mul(m_plus, c_minus_k); - - // ----(---+---)---------------(---+---)---------------(---+---)---- - // w- w w+ - // = c*m- = c*v = c*m+ - // - // diyfp::mul rounds its result and c_minus_k is approximated too. w, w- and - // w+ are now off by a small amount. - // In fact: - // - // w - v * 10^k < 1 ulp - // - // To account for this inaccuracy, add resp. subtract 1 ulp. - // - // --------+---[---------------(---+---)---------------]---+-------- - // w- M- w M+ w+ - // - // Now any number in [M-, M+] (bounds included) will round to w when input, - // regardless of how the input rounding algorithm breaks ties. - // - // And digit_gen generates the shortest possible such number in [M-, M+]. - // Note that this does not mean that Grisu2 always generates the shortest - // possible number in the interval (m-, m+). - const diyfp M_minus(w_minus.f + 1, w_minus.e); - const diyfp M_plus (w_plus.f - 1, w_plus.e ); - - decimal_exponent = -cached.k; // = -(-k) = k - - grisu2_digit_gen(buf, len, decimal_exponent, M_minus, w, M_plus); -} - -/*! -v = buf * 10^decimal_exponent -len is the length of the buffer (number of decimal digits) -The buffer must be large enough, i.e. >= max_digits10. -*/ -template -JSON_HEDLEY_NON_NULL(1) -void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value) -{ - static_assert(diyfp::kPrecision >= std::numeric_limits::digits + 3, - "internal error: not enough precision"); - - JSON_ASSERT(std::isfinite(value)); - JSON_ASSERT(value > 0); - - // If the neighbors (and boundaries) of 'value' are always computed for double-precision - // numbers, all float's can be recovered using strtod (and strtof). However, the resulting - // decimal representations are not exactly "short". - // - // The documentation for 'std::to_chars' (https://en.cppreference.com/w/cpp/utility/to_chars) - // says "value is converted to a string as if by std::sprintf in the default ("C") locale" - // and since sprintf promotes float's to double's, I think this is exactly what 'std::to_chars' - // does. - // On the other hand, the documentation for 'std::to_chars' requires that "parsing the - // representation using the corresponding std::from_chars function recovers value exactly". That - // indicates that single precision floating-point numbers should be recovered using - // 'std::strtof'. - // - // NB: If the neighbors are computed for single-precision numbers, there is a single float - // (7.0385307e-26f) which can't be recovered using strtod. The resulting double precision - // value is off by 1 ulp. -#if 0 - const boundaries w = compute_boundaries(static_cast(value)); -#else - const boundaries w = compute_boundaries(value); -#endif - - grisu2(buf, len, decimal_exponent, w.minus, w.w, w.plus); -} - -/*! -@brief appends a decimal representation of e to buf -@return a pointer to the element following the exponent. -@pre -1000 < e < 1000 -*/ -JSON_HEDLEY_NON_NULL(1) -JSON_HEDLEY_RETURNS_NON_NULL -inline char* append_exponent(char* buf, int e) -{ - JSON_ASSERT(e > -1000); - JSON_ASSERT(e < 1000); - - if (e < 0) - { - e = -e; - *buf++ = '-'; - } - else - { - *buf++ = '+'; - } - - auto k = static_cast(e); - if (k < 10) - { - // Always print at least two digits in the exponent. - // This is for compatibility with printf("%g"). - *buf++ = '0'; - *buf++ = static_cast('0' + k); - } - else if (k < 100) - { - *buf++ = static_cast('0' + k / 10); - k %= 10; - *buf++ = static_cast('0' + k); - } - else - { - *buf++ = static_cast('0' + k / 100); - k %= 100; - *buf++ = static_cast('0' + k / 10); - k %= 10; - *buf++ = static_cast('0' + k); - } - - return buf; -} - -/*! -@brief prettify v = buf * 10^decimal_exponent - -If v is in the range [10^min_exp, 10^max_exp) it will be printed in fixed-point -notation. Otherwise it will be printed in exponential notation. - -@pre min_exp < 0 -@pre max_exp > 0 -*/ -JSON_HEDLEY_NON_NULL(1) -JSON_HEDLEY_RETURNS_NON_NULL -inline char* format_buffer(char* buf, int len, int decimal_exponent, - int min_exp, int max_exp) -{ - JSON_ASSERT(min_exp < 0); - JSON_ASSERT(max_exp > 0); - - const int k = len; - const int n = len + decimal_exponent; - - // v = buf * 10^(n-k) - // k is the length of the buffer (number of decimal digits) - // n is the position of the decimal point relative to the start of the buffer. - - if (k <= n && n <= max_exp) - { - // digits[000] - // len <= max_exp + 2 - - std::memset(buf + k, '0', static_cast(n) - static_cast(k)); - // Make it look like a floating-point number (#362, #378) - buf[n + 0] = '.'; - buf[n + 1] = '0'; - return buf + (static_cast(n) + 2); - } - - if (0 < n && n <= max_exp) - { - // dig.its - // len <= max_digits10 + 1 - - JSON_ASSERT(k > n); - - std::memmove(buf + (static_cast(n) + 1), buf + n, static_cast(k) - static_cast(n)); - buf[n] = '.'; - return buf + (static_cast(k) + 1U); - } - - if (min_exp < n && n <= 0) - { - // 0.[000]digits - // len <= 2 + (-min_exp - 1) + max_digits10 - - std::memmove(buf + (2 + static_cast(-n)), buf, static_cast(k)); - buf[0] = '0'; - buf[1] = '.'; - std::memset(buf + 2, '0', static_cast(-n)); - return buf + (2U + static_cast(-n) + static_cast(k)); - } - - if (k == 1) - { - // dE+123 - // len <= 1 + 5 - - buf += 1; - } - else - { - // d.igitsE+123 - // len <= max_digits10 + 1 + 5 - - std::memmove(buf + 2, buf + 1, static_cast(k) - 1); - buf[1] = '.'; - buf += 1 + static_cast(k); - } - - *buf++ = 'e'; - return append_exponent(buf, n - 1); -} - -} // namespace dtoa_impl - -/*! -@brief generates a decimal representation of the floating-point number value in [first, last). - -The format of the resulting decimal representation is similar to printf's %g -format. Returns an iterator pointing past-the-end of the decimal representation. - -@note The input number must be finite, i.e. NaN's and Inf's are not supported. -@note The buffer must be large enough. -@note The result is NOT null-terminated. -*/ -template -JSON_HEDLEY_NON_NULL(1, 2) -JSON_HEDLEY_RETURNS_NON_NULL -char* to_chars(char* first, const char* last, FloatType value) -{ - static_cast(last); // maybe unused - fix warning - JSON_ASSERT(std::isfinite(value)); - - // Use signbit(value) instead of (value < 0) since signbit works for -0. - if (std::signbit(value)) - { - value = -value; - *first++ = '-'; - } - - if (value == 0) // +-0 - { - *first++ = '0'; - // Make it look like a floating-point number (#362, #378) - *first++ = '.'; - *first++ = '0'; - return first; - } - - JSON_ASSERT(last - first >= std::numeric_limits::max_digits10); - - // Compute v = buffer * 10^decimal_exponent. - // The decimal digits are stored in the buffer, which needs to be interpreted - // as an unsigned decimal integer. - // len is the length of the buffer, i.e. the number of decimal digits. - int len = 0; - int decimal_exponent = 0; - dtoa_impl::grisu2(first, len, decimal_exponent, value); - - JSON_ASSERT(len <= std::numeric_limits::max_digits10); - - // Format the buffer like printf("%.*g", prec, value) - constexpr int kMinExp = -4; - // Use digits10 here to increase compatibility with version 2. - constexpr int kMaxExp = std::numeric_limits::digits10; - - JSON_ASSERT(last - first >= kMaxExp + 2); - JSON_ASSERT(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits::max_digits10); - JSON_ASSERT(last - first >= std::numeric_limits::max_digits10 + 6); - - return dtoa_impl::format_buffer(first, len, decimal_exponent, kMinExp, kMaxExp); -} - -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - -// #include - -// #include - -// #include - -// #include - - -namespace nlohmann -{ -namespace detail -{ -/////////////////// -// serialization // -/////////////////// - -/// how to treat decoding errors -enum class error_handler_t -{ - strict, ///< throw a type_error exception in case of invalid UTF-8 - replace, ///< replace invalid UTF-8 sequences with U+FFFD - ignore ///< ignore invalid UTF-8 sequences -}; - -template -class serializer -{ - using string_t = typename BasicJsonType::string_t; - using number_float_t = typename BasicJsonType::number_float_t; - using number_integer_t = typename BasicJsonType::number_integer_t; - using number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using binary_char_t = typename BasicJsonType::binary_t::value_type; - static constexpr std::uint8_t UTF8_ACCEPT = 0; - static constexpr std::uint8_t UTF8_REJECT = 1; - - public: - /*! - @param[in] s output stream to serialize to - @param[in] ichar indentation character to use - @param[in] error_handler_ how to react on decoding errors - */ - serializer(output_adapter_t s, const char ichar, - error_handler_t error_handler_ = error_handler_t::strict) - : o(std::move(s)) - , loc(std::localeconv()) - , thousands_sep(loc->thousands_sep == nullptr ? '\0' : std::char_traits::to_char_type(* (loc->thousands_sep))) - , decimal_point(loc->decimal_point == nullptr ? '\0' : std::char_traits::to_char_type(* (loc->decimal_point))) - , indent_char(ichar) - , indent_string(512, indent_char) - , error_handler(error_handler_) - {} - - // delete because of pointer members - serializer(const serializer&) = delete; - serializer& operator=(const serializer&) = delete; - serializer(serializer&&) = delete; - serializer& operator=(serializer&&) = delete; - ~serializer() = default; - - /*! - @brief internal implementation of the serialization function - - This function is called by the public member function dump and organizes - the serialization internally. The indentation level is propagated as - additional parameter. In case of arrays and objects, the function is - called recursively. - - - strings and object keys are escaped using `escape_string()` - - integer numbers are converted implicitly via `operator<<` - - floating-point numbers are converted to a string using `"%g"` format - - binary values are serialized as objects containing the subtype and the - byte array - - @param[in] val value to serialize - @param[in] pretty_print whether the output shall be pretty-printed - @param[in] ensure_ascii If @a ensure_ascii is true, all non-ASCII characters - in the output are escaped with `\uXXXX` sequences, and the result consists - of ASCII characters only. - @param[in] indent_step the indent level - @param[in] current_indent the current indent level (only used internally) - */ - void dump(const BasicJsonType& val, - const bool pretty_print, - const bool ensure_ascii, - const unsigned int indent_step, - const unsigned int current_indent = 0) - { - switch (val.m_type) - { - case value_t::object: - { - if (val.m_value.object->empty()) - { - o->write_characters("{}", 2); - return; - } - - if (pretty_print) - { - o->write_characters("{\n", 2); - - // variable to hold indentation for recursive calls - const auto new_indent = current_indent + indent_step; - if (JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent)) - { - indent_string.resize(indent_string.size() * 2, ' '); - } - - // first n-1 elements - auto i = val.m_value.object->cbegin(); - for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i) - { - o->write_characters(indent_string.c_str(), new_indent); - o->write_character('\"'); - dump_escaped(i->first, ensure_ascii); - o->write_characters("\": ", 3); - dump(i->second, true, ensure_ascii, indent_step, new_indent); - o->write_characters(",\n", 2); - } - - // last element - JSON_ASSERT(i != val.m_value.object->cend()); - JSON_ASSERT(std::next(i) == val.m_value.object->cend()); - o->write_characters(indent_string.c_str(), new_indent); - o->write_character('\"'); - dump_escaped(i->first, ensure_ascii); - o->write_characters("\": ", 3); - dump(i->second, true, ensure_ascii, indent_step, new_indent); - - o->write_character('\n'); - o->write_characters(indent_string.c_str(), current_indent); - o->write_character('}'); - } - else - { - o->write_character('{'); - - // first n-1 elements - auto i = val.m_value.object->cbegin(); - for (std::size_t cnt = 0; cnt < val.m_value.object->size() - 1; ++cnt, ++i) - { - o->write_character('\"'); - dump_escaped(i->first, ensure_ascii); - o->write_characters("\":", 2); - dump(i->second, false, ensure_ascii, indent_step, current_indent); - o->write_character(','); - } - - // last element - JSON_ASSERT(i != val.m_value.object->cend()); - JSON_ASSERT(std::next(i) == val.m_value.object->cend()); - o->write_character('\"'); - dump_escaped(i->first, ensure_ascii); - o->write_characters("\":", 2); - dump(i->second, false, ensure_ascii, indent_step, current_indent); - - o->write_character('}'); - } - - return; - } - - case value_t::array: - { - if (val.m_value.array->empty()) - { - o->write_characters("[]", 2); - return; - } - - if (pretty_print) - { - o->write_characters("[\n", 2); - - // variable to hold indentation for recursive calls - const auto new_indent = current_indent + indent_step; - if (JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent)) - { - indent_string.resize(indent_string.size() * 2, ' '); - } - - // first n-1 elements - for (auto i = val.m_value.array->cbegin(); - i != val.m_value.array->cend() - 1; ++i) - { - o->write_characters(indent_string.c_str(), new_indent); - dump(*i, true, ensure_ascii, indent_step, new_indent); - o->write_characters(",\n", 2); - } - - // last element - JSON_ASSERT(!val.m_value.array->empty()); - o->write_characters(indent_string.c_str(), new_indent); - dump(val.m_value.array->back(), true, ensure_ascii, indent_step, new_indent); - - o->write_character('\n'); - o->write_characters(indent_string.c_str(), current_indent); - o->write_character(']'); - } - else - { - o->write_character('['); - - // first n-1 elements - for (auto i = val.m_value.array->cbegin(); - i != val.m_value.array->cend() - 1; ++i) - { - dump(*i, false, ensure_ascii, indent_step, current_indent); - o->write_character(','); - } - - // last element - JSON_ASSERT(!val.m_value.array->empty()); - dump(val.m_value.array->back(), false, ensure_ascii, indent_step, current_indent); - - o->write_character(']'); - } - - return; - } - - case value_t::string: - { - o->write_character('\"'); - dump_escaped(*val.m_value.string, ensure_ascii); - o->write_character('\"'); - return; - } - - case value_t::binary: - { - if (pretty_print) - { - o->write_characters("{\n", 2); - - // variable to hold indentation for recursive calls - const auto new_indent = current_indent + indent_step; - if (JSON_HEDLEY_UNLIKELY(indent_string.size() < new_indent)) - { - indent_string.resize(indent_string.size() * 2, ' '); - } - - o->write_characters(indent_string.c_str(), new_indent); - - o->write_characters("\"bytes\": [", 10); - - if (!val.m_value.binary->empty()) - { - for (auto i = val.m_value.binary->cbegin(); - i != val.m_value.binary->cend() - 1; ++i) - { - dump_integer(*i); - o->write_characters(", ", 2); - } - dump_integer(val.m_value.binary->back()); - } - - o->write_characters("],\n", 3); - o->write_characters(indent_string.c_str(), new_indent); - - o->write_characters("\"subtype\": ", 11); - if (val.m_value.binary->has_subtype()) - { - dump_integer(val.m_value.binary->subtype()); - } - else - { - o->write_characters("null", 4); - } - o->write_character('\n'); - o->write_characters(indent_string.c_str(), current_indent); - o->write_character('}'); - } - else - { - o->write_characters("{\"bytes\":[", 10); - - if (!val.m_value.binary->empty()) - { - for (auto i = val.m_value.binary->cbegin(); - i != val.m_value.binary->cend() - 1; ++i) - { - dump_integer(*i); - o->write_character(','); - } - dump_integer(val.m_value.binary->back()); - } - - o->write_characters("],\"subtype\":", 12); - if (val.m_value.binary->has_subtype()) - { - dump_integer(val.m_value.binary->subtype()); - o->write_character('}'); - } - else - { - o->write_characters("null}", 5); - } - } - return; - } - - case value_t::boolean: - { - if (val.m_value.boolean) - { - o->write_characters("true", 4); - } - else - { - o->write_characters("false", 5); - } - return; - } - - case value_t::number_integer: - { - dump_integer(val.m_value.number_integer); - return; - } - - case value_t::number_unsigned: - { - dump_integer(val.m_value.number_unsigned); - return; - } - - case value_t::number_float: - { - dump_float(val.m_value.number_float); - return; - } - - case value_t::discarded: - { - o->write_characters("", 11); - return; - } - - case value_t::null: - { - o->write_characters("null", 4); - return; - } - - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // LCOV_EXCL_LINE - } - } - - JSON_PRIVATE_UNLESS_TESTED: - /*! - @brief dump escaped string - - Escape a string by replacing certain special characters by a sequence of an - escape character (backslash) and another character and other control - characters by a sequence of "\u" followed by a four-digit hex - representation. The escaped string is written to output stream @a o. - - @param[in] s the string to escape - @param[in] ensure_ascii whether to escape non-ASCII characters with - \uXXXX sequences - - @complexity Linear in the length of string @a s. - */ - void dump_escaped(const string_t& s, const bool ensure_ascii) - { - std::uint32_t codepoint; - std::uint8_t state = UTF8_ACCEPT; - std::size_t bytes = 0; // number of bytes written to string_buffer - - // number of bytes written at the point of the last valid byte - std::size_t bytes_after_last_accept = 0; - std::size_t undumped_chars = 0; - - for (std::size_t i = 0; i < s.size(); ++i) - { - const auto byte = static_cast(s[i]); - - switch (decode(state, codepoint, byte)) - { - case UTF8_ACCEPT: // decode found a new code point - { - switch (codepoint) - { - case 0x08: // backspace - { - string_buffer[bytes++] = '\\'; - string_buffer[bytes++] = 'b'; - break; - } - - case 0x09: // horizontal tab - { - string_buffer[bytes++] = '\\'; - string_buffer[bytes++] = 't'; - break; - } - - case 0x0A: // newline - { - string_buffer[bytes++] = '\\'; - string_buffer[bytes++] = 'n'; - break; - } - - case 0x0C: // formfeed - { - string_buffer[bytes++] = '\\'; - string_buffer[bytes++] = 'f'; - break; - } - - case 0x0D: // carriage return - { - string_buffer[bytes++] = '\\'; - string_buffer[bytes++] = 'r'; - break; - } - - case 0x22: // quotation mark - { - string_buffer[bytes++] = '\\'; - string_buffer[bytes++] = '\"'; - break; - } - - case 0x5C: // reverse solidus - { - string_buffer[bytes++] = '\\'; - string_buffer[bytes++] = '\\'; - break; - } - - default: - { - // escape control characters (0x00..0x1F) or, if - // ensure_ascii parameter is used, non-ASCII characters - if ((codepoint <= 0x1F) || (ensure_ascii && (codepoint >= 0x7F))) - { - if (codepoint <= 0xFFFF) - { - (std::snprintf)(string_buffer.data() + bytes, 7, "\\u%04x", - static_cast(codepoint)); - bytes += 6; - } - else - { - (std::snprintf)(string_buffer.data() + bytes, 13, "\\u%04x\\u%04x", - static_cast(0xD7C0u + (codepoint >> 10u)), - static_cast(0xDC00u + (codepoint & 0x3FFu))); - bytes += 12; - } - } - else - { - // copy byte to buffer (all previous bytes - // been copied have in default case above) - string_buffer[bytes++] = s[i]; - } - break; - } - } - - // write buffer and reset index; there must be 13 bytes - // left, as this is the maximal number of bytes to be - // written ("\uxxxx\uxxxx\0") for one code point - if (string_buffer.size() - bytes < 13) - { - o->write_characters(string_buffer.data(), bytes); - bytes = 0; - } - - // remember the byte position of this accept - bytes_after_last_accept = bytes; - undumped_chars = 0; - break; - } - - case UTF8_REJECT: // decode found invalid UTF-8 byte - { - switch (error_handler) - { - case error_handler_t::strict: - { - std::string sn(3, '\0'); - (std::snprintf)(&sn[0], sn.size(), "%.2X", byte); - JSON_THROW(type_error::create(316, "invalid UTF-8 byte at index " + std::to_string(i) + ": 0x" + sn, BasicJsonType())); - } - - case error_handler_t::ignore: - case error_handler_t::replace: - { - // in case we saw this character the first time, we - // would like to read it again, because the byte - // may be OK for itself, but just not OK for the - // previous sequence - if (undumped_chars > 0) - { - --i; - } - - // reset length buffer to the last accepted index; - // thus removing/ignoring the invalid characters - bytes = bytes_after_last_accept; - - if (error_handler == error_handler_t::replace) - { - // add a replacement character - if (ensure_ascii) - { - string_buffer[bytes++] = '\\'; - string_buffer[bytes++] = 'u'; - string_buffer[bytes++] = 'f'; - string_buffer[bytes++] = 'f'; - string_buffer[bytes++] = 'f'; - string_buffer[bytes++] = 'd'; - } - else - { - string_buffer[bytes++] = detail::binary_writer::to_char_type('\xEF'); - string_buffer[bytes++] = detail::binary_writer::to_char_type('\xBF'); - string_buffer[bytes++] = detail::binary_writer::to_char_type('\xBD'); - } - - // write buffer and reset index; there must be 13 bytes - // left, as this is the maximal number of bytes to be - // written ("\uxxxx\uxxxx\0") for one code point - if (string_buffer.size() - bytes < 13) - { - o->write_characters(string_buffer.data(), bytes); - bytes = 0; - } - - bytes_after_last_accept = bytes; - } - - undumped_chars = 0; - - // continue processing the string - state = UTF8_ACCEPT; - break; - } - - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // LCOV_EXCL_LINE - } - break; - } - - default: // decode found yet incomplete multi-byte code point - { - if (!ensure_ascii) - { - // code point will not be escaped - copy byte to buffer - string_buffer[bytes++] = s[i]; - } - ++undumped_chars; - break; - } - } - } - - // we finished processing the string - if (JSON_HEDLEY_LIKELY(state == UTF8_ACCEPT)) - { - // write buffer - if (bytes > 0) - { - o->write_characters(string_buffer.data(), bytes); - } - } - else - { - // we finish reading, but do not accept: string was incomplete - switch (error_handler) - { - case error_handler_t::strict: - { - std::string sn(3, '\0'); - (std::snprintf)(&sn[0], sn.size(), "%.2X", static_cast(s.back())); - JSON_THROW(type_error::create(316, "incomplete UTF-8 string; last byte: 0x" + sn, BasicJsonType())); - } - - case error_handler_t::ignore: - { - // write all accepted bytes - o->write_characters(string_buffer.data(), bytes_after_last_accept); - break; - } - - case error_handler_t::replace: - { - // write all accepted bytes - o->write_characters(string_buffer.data(), bytes_after_last_accept); - // add a replacement character - if (ensure_ascii) - { - o->write_characters("\\ufffd", 6); - } - else - { - o->write_characters("\xEF\xBF\xBD", 3); - } - break; - } - - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // LCOV_EXCL_LINE - } - } - } - - private: - /*! - @brief count digits - - Count the number of decimal (base 10) digits for an input unsigned integer. - - @param[in] x unsigned integer number to count its digits - @return number of decimal digits - */ - inline unsigned int count_digits(number_unsigned_t x) noexcept - { - unsigned int n_digits = 1; - for (;;) - { - if (x < 10) - { - return n_digits; - } - if (x < 100) - { - return n_digits + 1; - } - if (x < 1000) - { - return n_digits + 2; - } - if (x < 10000) - { - return n_digits + 3; - } - x = x / 10000u; - n_digits += 4; - } - } - - /*! - @brief dump an integer - - Dump a given integer to output stream @a o. Works internally with - @a number_buffer. - - @param[in] x integer number (signed or unsigned) to dump - @tparam NumberType either @a number_integer_t or @a number_unsigned_t - */ - template < typename NumberType, detail::enable_if_t < - std::is_same::value || - std::is_same::value || - std::is_same::value, - int > = 0 > - void dump_integer(NumberType x) - { - static constexpr std::array, 100> digits_to_99 - { - { - {{'0', '0'}}, {{'0', '1'}}, {{'0', '2'}}, {{'0', '3'}}, {{'0', '4'}}, {{'0', '5'}}, {{'0', '6'}}, {{'0', '7'}}, {{'0', '8'}}, {{'0', '9'}}, - {{'1', '0'}}, {{'1', '1'}}, {{'1', '2'}}, {{'1', '3'}}, {{'1', '4'}}, {{'1', '5'}}, {{'1', '6'}}, {{'1', '7'}}, {{'1', '8'}}, {{'1', '9'}}, - {{'2', '0'}}, {{'2', '1'}}, {{'2', '2'}}, {{'2', '3'}}, {{'2', '4'}}, {{'2', '5'}}, {{'2', '6'}}, {{'2', '7'}}, {{'2', '8'}}, {{'2', '9'}}, - {{'3', '0'}}, {{'3', '1'}}, {{'3', '2'}}, {{'3', '3'}}, {{'3', '4'}}, {{'3', '5'}}, {{'3', '6'}}, {{'3', '7'}}, {{'3', '8'}}, {{'3', '9'}}, - {{'4', '0'}}, {{'4', '1'}}, {{'4', '2'}}, {{'4', '3'}}, {{'4', '4'}}, {{'4', '5'}}, {{'4', '6'}}, {{'4', '7'}}, {{'4', '8'}}, {{'4', '9'}}, - {{'5', '0'}}, {{'5', '1'}}, {{'5', '2'}}, {{'5', '3'}}, {{'5', '4'}}, {{'5', '5'}}, {{'5', '6'}}, {{'5', '7'}}, {{'5', '8'}}, {{'5', '9'}}, - {{'6', '0'}}, {{'6', '1'}}, {{'6', '2'}}, {{'6', '3'}}, {{'6', '4'}}, {{'6', '5'}}, {{'6', '6'}}, {{'6', '7'}}, {{'6', '8'}}, {{'6', '9'}}, - {{'7', '0'}}, {{'7', '1'}}, {{'7', '2'}}, {{'7', '3'}}, {{'7', '4'}}, {{'7', '5'}}, {{'7', '6'}}, {{'7', '7'}}, {{'7', '8'}}, {{'7', '9'}}, - {{'8', '0'}}, {{'8', '1'}}, {{'8', '2'}}, {{'8', '3'}}, {{'8', '4'}}, {{'8', '5'}}, {{'8', '6'}}, {{'8', '7'}}, {{'8', '8'}}, {{'8', '9'}}, - {{'9', '0'}}, {{'9', '1'}}, {{'9', '2'}}, {{'9', '3'}}, {{'9', '4'}}, {{'9', '5'}}, {{'9', '6'}}, {{'9', '7'}}, {{'9', '8'}}, {{'9', '9'}}, - } - }; - - // special case for "0" - if (x == 0) - { - o->write_character('0'); - return; - } - - // use a pointer to fill the buffer - auto buffer_ptr = number_buffer.begin(); - - const bool is_negative = std::is_same::value && !(x >= 0); // see issue #755 - number_unsigned_t abs_value; - - unsigned int n_chars; - - if (is_negative) - { - *buffer_ptr = '-'; - abs_value = remove_sign(static_cast(x)); - - // account one more byte for the minus sign - n_chars = 1 + count_digits(abs_value); - } - else - { - abs_value = static_cast(x); - n_chars = count_digits(abs_value); - } - - // spare 1 byte for '\0' - JSON_ASSERT(n_chars < number_buffer.size() - 1); - - // jump to the end to generate the string from backward - // so we later avoid reversing the result - buffer_ptr += n_chars; - - // Fast int2ascii implementation inspired by "Fastware" talk by Andrei Alexandrescu - // See: https://www.youtube.com/watch?v=o4-CwDo2zpg - while (abs_value >= 100) - { - const auto digits_index = static_cast((abs_value % 100)); - abs_value /= 100; - *(--buffer_ptr) = digits_to_99[digits_index][1]; - *(--buffer_ptr) = digits_to_99[digits_index][0]; - } - - if (abs_value >= 10) - { - const auto digits_index = static_cast(abs_value); - *(--buffer_ptr) = digits_to_99[digits_index][1]; - *(--buffer_ptr) = digits_to_99[digits_index][0]; - } - else - { - *(--buffer_ptr) = static_cast('0' + abs_value); - } - - o->write_characters(number_buffer.data(), n_chars); - } - - /*! - @brief dump a floating-point number - - Dump a given floating-point number to output stream @a o. Works internally - with @a number_buffer. - - @param[in] x floating-point number to dump - */ - void dump_float(number_float_t x) - { - // NaN / inf - if (!std::isfinite(x)) - { - o->write_characters("null", 4); - return; - } - - // If number_float_t is an IEEE-754 single or double precision number, - // use the Grisu2 algorithm to produce short numbers which are - // guaranteed to round-trip, using strtof and strtod, resp. - // - // NB: The test below works if == . - static constexpr bool is_ieee_single_or_double - = (std::numeric_limits::is_iec559 && std::numeric_limits::digits == 24 && std::numeric_limits::max_exponent == 128) || - (std::numeric_limits::is_iec559 && std::numeric_limits::digits == 53 && std::numeric_limits::max_exponent == 1024); - - dump_float(x, std::integral_constant()); - } - - void dump_float(number_float_t x, std::true_type /*is_ieee_single_or_double*/) - { - char* begin = number_buffer.data(); - char* end = ::nlohmann::detail::to_chars(begin, begin + number_buffer.size(), x); - - o->write_characters(begin, static_cast(end - begin)); - } - - void dump_float(number_float_t x, std::false_type /*is_ieee_single_or_double*/) - { - // get number of digits for a float -> text -> float round-trip - static constexpr auto d = std::numeric_limits::max_digits10; - - // the actual conversion - std::ptrdiff_t len = (std::snprintf)(number_buffer.data(), number_buffer.size(), "%.*g", d, x); - - // negative value indicates an error - JSON_ASSERT(len > 0); - // check if buffer was large enough - JSON_ASSERT(static_cast(len) < number_buffer.size()); - - // erase thousands separator - if (thousands_sep != '\0') - { - const auto end = std::remove(number_buffer.begin(), - number_buffer.begin() + len, thousands_sep); - std::fill(end, number_buffer.end(), '\0'); - JSON_ASSERT((end - number_buffer.begin()) <= len); - len = (end - number_buffer.begin()); - } - - // convert decimal point to '.' - if (decimal_point != '\0' && decimal_point != '.') - { - const auto dec_pos = std::find(number_buffer.begin(), number_buffer.end(), decimal_point); - if (dec_pos != number_buffer.end()) - { - *dec_pos = '.'; - } - } - - o->write_characters(number_buffer.data(), static_cast(len)); - - // determine if need to append ".0" - const bool value_is_int_like = - std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1, - [](char c) - { - return c == '.' || c == 'e'; - }); - - if (value_is_int_like) - { - o->write_characters(".0", 2); - } - } - - /*! - @brief check whether a string is UTF-8 encoded - - The function checks each byte of a string whether it is UTF-8 encoded. The - result of the check is stored in the @a state parameter. The function must - be called initially with state 0 (accept). State 1 means the string must - be rejected, because the current byte is not allowed. If the string is - completely processed, but the state is non-zero, the string ended - prematurely; that is, the last byte indicated more bytes should have - followed. - - @param[in,out] state the state of the decoding - @param[in,out] codep codepoint (valid only if resulting state is UTF8_ACCEPT) - @param[in] byte next byte to decode - @return new state - - @note The function has been edited: a std::array is used. - - @copyright Copyright (c) 2008-2009 Bjoern Hoehrmann - @sa http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ - */ - static std::uint8_t decode(std::uint8_t& state, std::uint32_t& codep, const std::uint8_t byte) noexcept - { - static const std::array utf8d = - { - { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 00..1F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 20..3F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 40..5F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 60..7F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, // 80..9F - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // A0..BF - 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // C0..DF - 0xA, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3, // E0..EF - 0xB, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, // F0..FF - 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1, // s0..s0 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, // s1..s2 - 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, // s3..s4 - 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, // s5..s6 - 1, 3, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // s7..s8 - } - }; - - JSON_ASSERT(byte < utf8d.size()); - const std::uint8_t type = utf8d[byte]; - - codep = (state != UTF8_ACCEPT) - ? (byte & 0x3fu) | (codep << 6u) - : (0xFFu >> type) & (byte); - - std::size_t index = 256u + static_cast(state) * 16u + static_cast(type); - JSON_ASSERT(index < 400); - state = utf8d[index]; - return state; - } - - /* - * Overload to make the compiler happy while it is instantiating - * dump_integer for number_unsigned_t. - * Must never be called. - */ - number_unsigned_t remove_sign(number_unsigned_t x) - { - JSON_ASSERT(false); // LCOV_EXCL_LINE - return x; // LCOV_EXCL_LINE - } - - /* - * Helper function for dump_integer - * - * This function takes a negative signed integer and returns its absolute - * value as unsigned integer. The plus/minus shuffling is necessary as we can - * not directly remove the sign of an arbitrary signed integer as the - * absolute values of INT_MIN and INT_MAX are usually not the same. See - * #1708 for details. - */ - inline number_unsigned_t remove_sign(number_integer_t x) noexcept - { - JSON_ASSERT(x < 0 && x < (std::numeric_limits::max)()); - return static_cast(-(x + 1)) + 1; - } - - private: - /// the output of the serializer - output_adapter_t o = nullptr; - - /// a (hopefully) large enough character buffer - std::array number_buffer{{}}; - - /// the locale - const std::lconv* loc = nullptr; - /// the locale's thousand separator character - const char thousands_sep = '\0'; - /// the locale's decimal point character - const char decimal_point = '\0'; - - /// string buffer - std::array string_buffer{{}}; - - /// the indentation character - const char indent_char; - /// the indentation string - string_t indent_string; - - /// error_handler how to react on decoding errors - const error_handler_t error_handler; -}; -} // namespace detail -} // namespace nlohmann - -// #include - -// #include - -// #include - - -#include // less -#include // allocator -#include // pair -#include // vector - -// #include - - -namespace nlohmann -{ - -/// ordered_map: a minimal map-like container that preserves insertion order -/// for use within nlohmann::basic_json -template , - class Allocator = std::allocator>> - struct ordered_map : std::vector, Allocator> -{ - using key_type = Key; - using mapped_type = T; - using Container = std::vector, Allocator>; - using typename Container::iterator; - using typename Container::const_iterator; - using typename Container::size_type; - using typename Container::value_type; - - // Explicit constructors instead of `using Container::Container` - // otherwise older compilers choke on it (GCC <= 5.5, xcode <= 9.4) - ordered_map(const Allocator& alloc = Allocator()) : Container{alloc} {} - template - ordered_map(It first, It last, const Allocator& alloc = Allocator()) - : Container{first, last, alloc} {} - ordered_map(std::initializer_list init, const Allocator& alloc = Allocator() ) - : Container{init, alloc} {} - - std::pair emplace(const key_type& key, T&& t) - { - for (auto it = this->begin(); it != this->end(); ++it) - { - if (it->first == key) - { - return {it, false}; - } - } - Container::emplace_back(key, t); - return {--this->end(), true}; - } - - T& operator[](const Key& key) - { - return emplace(key, T{}).first->second; - } - - const T& operator[](const Key& key) const - { - return at(key); - } - - T& at(const Key& key) - { - for (auto it = this->begin(); it != this->end(); ++it) - { - if (it->first == key) - { - return it->second; - } - } - - JSON_THROW(std::out_of_range("key not found")); - } - - const T& at(const Key& key) const - { - for (auto it = this->begin(); it != this->end(); ++it) - { - if (it->first == key) - { - return it->second; - } - } - - JSON_THROW(std::out_of_range("key not found")); - } - - size_type erase(const Key& key) - { - for (auto it = this->begin(); it != this->end(); ++it) - { - if (it->first == key) - { - // Since we cannot move const Keys, re-construct them in place - for (auto next = it; ++next != this->end(); ++it) - { - it->~value_type(); // Destroy but keep allocation - new (&*it) value_type{std::move(*next)}; - } - Container::pop_back(); - return 1; - } - } - return 0; - } - - iterator erase(iterator pos) - { - auto it = pos; - - // Since we cannot move const Keys, re-construct them in place - for (auto next = it; ++next != this->end(); ++it) - { - it->~value_type(); // Destroy but keep allocation - new (&*it) value_type{std::move(*next)}; - } - Container::pop_back(); - return pos; - } - - size_type count(const Key& key) const - { - for (auto it = this->begin(); it != this->end(); ++it) - { - if (it->first == key) - { - return 1; - } - } - return 0; - } - - iterator find(const Key& key) - { - for (auto it = this->begin(); it != this->end(); ++it) - { - if (it->first == key) - { - return it; - } - } - return Container::end(); - } - - const_iterator find(const Key& key) const - { - for (auto it = this->begin(); it != this->end(); ++it) - { - if (it->first == key) - { - return it; - } - } - return Container::end(); - } - - std::pair insert( value_type&& value ) - { - return emplace(value.first, std::move(value.second)); - } - - std::pair insert( const value_type& value ) - { - for (auto it = this->begin(); it != this->end(); ++it) - { - if (it->first == value.first) - { - return {it, false}; - } - } - Container::push_back(value); - return {--this->end(), true}; - } - - template - using require_input_iter = typename std::enable_if::iterator_category, - std::input_iterator_tag>::value>::type; - - template> - void insert(InputIt first, InputIt last) - { - for (auto it = first; it != last; ++it) - { - insert(*it); - } - } -}; - -} // namespace nlohmann - - -#if defined(JSON_HAS_CPP_17) - #include -#endif - -/*! -@brief namespace for Niels Lohmann -@see https://github.com/nlohmann -@since version 1.0.0 -*/ -namespace nlohmann -{ - -/*! -@brief a class to store JSON values - -@tparam ObjectType type for JSON objects (`std::map` by default; will be used -in @ref object_t) -@tparam ArrayType type for JSON arrays (`std::vector` by default; will be used -in @ref array_t) -@tparam StringType type for JSON strings and object keys (`std::string` by -default; will be used in @ref string_t) -@tparam BooleanType type for JSON booleans (`bool` by default; will be used -in @ref boolean_t) -@tparam NumberIntegerType type for JSON integer numbers (`int64_t` by -default; will be used in @ref number_integer_t) -@tparam NumberUnsignedType type for JSON unsigned integer numbers (@c -`uint64_t` by default; will be used in @ref number_unsigned_t) -@tparam NumberFloatType type for JSON floating-point numbers (`double` by -default; will be used in @ref number_float_t) -@tparam BinaryType type for packed binary data for compatibility with binary -serialization formats (`std::vector` by default; will be used in -@ref binary_t) -@tparam AllocatorType type of the allocator to use (`std::allocator` by -default) -@tparam JSONSerializer the serializer to resolve internal calls to `to_json()` -and `from_json()` (@ref adl_serializer by default) - -@requirement The class satisfies the following concept requirements: -- Basic - - [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible): - JSON values can be default constructed. The result will be a JSON null - value. - - [MoveConstructible](https://en.cppreference.com/w/cpp/named_req/MoveConstructible): - A JSON value can be constructed from an rvalue argument. - - [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible): - A JSON value can be copy-constructed from an lvalue expression. - - [MoveAssignable](https://en.cppreference.com/w/cpp/named_req/MoveAssignable): - A JSON value van be assigned from an rvalue argument. - - [CopyAssignable](https://en.cppreference.com/w/cpp/named_req/CopyAssignable): - A JSON value can be copy-assigned from an lvalue expression. - - [Destructible](https://en.cppreference.com/w/cpp/named_req/Destructible): - JSON values can be destructed. -- Layout - - [StandardLayoutType](https://en.cppreference.com/w/cpp/named_req/StandardLayoutType): - JSON values have - [standard layout](https://en.cppreference.com/w/cpp/language/data_members#Standard_layout): - All non-static data members are private and standard layout types, the - class has no virtual functions or (virtual) base classes. -- Library-wide - - [EqualityComparable](https://en.cppreference.com/w/cpp/named_req/EqualityComparable): - JSON values can be compared with `==`, see @ref - operator==(const_reference,const_reference). - - [LessThanComparable](https://en.cppreference.com/w/cpp/named_req/LessThanComparable): - JSON values can be compared with `<`, see @ref - operator<(const_reference,const_reference). - - [Swappable](https://en.cppreference.com/w/cpp/named_req/Swappable): - Any JSON lvalue or rvalue of can be swapped with any lvalue or rvalue of - other compatible types, using unqualified function call @ref swap(). - - [NullablePointer](https://en.cppreference.com/w/cpp/named_req/NullablePointer): - JSON values can be compared against `std::nullptr_t` objects which are used - to model the `null` value. -- Container - - [Container](https://en.cppreference.com/w/cpp/named_req/Container): - JSON values can be used like STL containers and provide iterator access. - - [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer); - JSON values can be used like STL containers and provide reverse iterator - access. - -@invariant The member variables @a m_value and @a m_type have the following -relationship: -- If `m_type == value_t::object`, then `m_value.object != nullptr`. -- If `m_type == value_t::array`, then `m_value.array != nullptr`. -- If `m_type == value_t::string`, then `m_value.string != nullptr`. -The invariants are checked by member function assert_invariant(). - -@internal -@note ObjectType trick from https://stackoverflow.com/a/9860911 -@endinternal - -@see [RFC 7159: The JavaScript Object Notation (JSON) Data Interchange -Format](http://rfc7159.net/rfc7159) - -@since version 1.0.0 - -@nosubgrouping -*/ -NLOHMANN_BASIC_JSON_TPL_DECLARATION -class basic_json -{ - private: - template friend struct detail::external_constructor; - friend ::nlohmann::json_pointer; - - template - friend class ::nlohmann::detail::parser; - friend ::nlohmann::detail::serializer; - template - friend class ::nlohmann::detail::iter_impl; - template - friend class ::nlohmann::detail::binary_writer; - template - friend class ::nlohmann::detail::binary_reader; - template - friend class ::nlohmann::detail::json_sax_dom_parser; - template - friend class ::nlohmann::detail::json_sax_dom_callback_parser; - friend class ::nlohmann::detail::exception; - - /// workaround type for MSVC - using basic_json_t = NLOHMANN_BASIC_JSON_TPL; - - JSON_PRIVATE_UNLESS_TESTED: - // convenience aliases for types residing in namespace detail; - using lexer = ::nlohmann::detail::lexer_base; - - template - static ::nlohmann::detail::parser parser( - InputAdapterType adapter, - detail::parser_callback_tcb = nullptr, - const bool allow_exceptions = true, - const bool ignore_comments = false - ) - { - return ::nlohmann::detail::parser(std::move(adapter), - std::move(cb), allow_exceptions, ignore_comments); - } - - private: - using primitive_iterator_t = ::nlohmann::detail::primitive_iterator_t; - template - using internal_iterator = ::nlohmann::detail::internal_iterator; - template - using iter_impl = ::nlohmann::detail::iter_impl; - template - using iteration_proxy = ::nlohmann::detail::iteration_proxy; - template using json_reverse_iterator = ::nlohmann::detail::json_reverse_iterator; - - template - using output_adapter_t = ::nlohmann::detail::output_adapter_t; - - template - using binary_reader = ::nlohmann::detail::binary_reader; - template using binary_writer = ::nlohmann::detail::binary_writer; - - JSON_PRIVATE_UNLESS_TESTED: - using serializer = ::nlohmann::detail::serializer; - - public: - using value_t = detail::value_t; - /// JSON Pointer, see @ref nlohmann::json_pointer - using json_pointer = ::nlohmann::json_pointer; - template - using json_serializer = JSONSerializer; - /// how to treat decoding errors - using error_handler_t = detail::error_handler_t; - /// how to treat CBOR tags - using cbor_tag_handler_t = detail::cbor_tag_handler_t; - /// helper type for initializer lists of basic_json values - using initializer_list_t = std::initializer_list>; - - using input_format_t = detail::input_format_t; - /// SAX interface type, see @ref nlohmann::json_sax - using json_sax_t = json_sax; - - //////////////// - // exceptions // - //////////////// - - /// @name exceptions - /// Classes to implement user-defined exceptions. - /// @{ - - /// @copydoc detail::exception - using exception = detail::exception; - /// @copydoc detail::parse_error - using parse_error = detail::parse_error; - /// @copydoc detail::invalid_iterator - using invalid_iterator = detail::invalid_iterator; - /// @copydoc detail::type_error - using type_error = detail::type_error; - /// @copydoc detail::out_of_range - using out_of_range = detail::out_of_range; - /// @copydoc detail::other_error - using other_error = detail::other_error; - - /// @} - - - ///////////////////// - // container types // - ///////////////////// - - /// @name container types - /// The canonic container types to use @ref basic_json like any other STL - /// container. - /// @{ - - /// the type of elements in a basic_json container - using value_type = basic_json; - - /// the type of an element reference - using reference = value_type&; - /// the type of an element const reference - using const_reference = const value_type&; - - /// a type to represent differences between iterators - using difference_type = std::ptrdiff_t; - /// a type to represent container sizes - using size_type = std::size_t; - - /// the allocator type - using allocator_type = AllocatorType; - - /// the type of an element pointer - using pointer = typename std::allocator_traits::pointer; - /// the type of an element const pointer - using const_pointer = typename std::allocator_traits::const_pointer; - - /// an iterator for a basic_json container - using iterator = iter_impl; - /// a const iterator for a basic_json container - using const_iterator = iter_impl; - /// a reverse iterator for a basic_json container - using reverse_iterator = json_reverse_iterator; - /// a const reverse iterator for a basic_json container - using const_reverse_iterator = json_reverse_iterator; - - /// @} - - - /*! - @brief returns the allocator associated with the container - */ - static allocator_type get_allocator() - { - return allocator_type(); - } - - /*! - @brief returns version information on the library - - This function returns a JSON object with information about the library, - including the version number and information on the platform and compiler. - - @return JSON object holding version information - key | description - ----------- | --------------- - `compiler` | Information on the used compiler. It is an object with the following keys: `c++` (the used C++ standard), `family` (the compiler family; possible values are `clang`, `icc`, `gcc`, `ilecpp`, `msvc`, `pgcpp`, `sunpro`, and `unknown`), and `version` (the compiler version). - `copyright` | The copyright line for the library as string. - `name` | The name of the library as string. - `platform` | The used platform as string. Possible values are `win32`, `linux`, `apple`, `unix`, and `unknown`. - `url` | The URL of the project as string. - `version` | The version of the library. It is an object with the following keys: `major`, `minor`, and `patch` as defined by [Semantic Versioning](http://semver.org), and `string` (the version string). - - @liveexample{The following code shows an example output of the `meta()` - function.,meta} - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes to any JSON value. - - @complexity Constant. - - @since 2.1.0 - */ - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json meta() - { - basic_json result; - - result["copyright"] = "(C) 2013-2021 Niels Lohmann"; - result["name"] = "JSON for Modern C++"; - result["url"] = "https://github.com/nlohmann/json"; - result["version"]["string"] = - std::to_string(NLOHMANN_JSON_VERSION_MAJOR) + "." + - std::to_string(NLOHMANN_JSON_VERSION_MINOR) + "." + - std::to_string(NLOHMANN_JSON_VERSION_PATCH); - result["version"]["major"] = NLOHMANN_JSON_VERSION_MAJOR; - result["version"]["minor"] = NLOHMANN_JSON_VERSION_MINOR; - result["version"]["patch"] = NLOHMANN_JSON_VERSION_PATCH; - -#ifdef _WIN32 - result["platform"] = "win32"; -#elif defined __linux__ - result["platform"] = "linux"; -#elif defined __APPLE__ - result["platform"] = "apple"; -#elif defined __unix__ - result["platform"] = "unix"; -#else - result["platform"] = "unknown"; -#endif - -#if defined(__ICC) || defined(__INTEL_COMPILER) - result["compiler"] = {{"family", "icc"}, {"version", __INTEL_COMPILER}}; -#elif defined(__clang__) - result["compiler"] = {{"family", "clang"}, {"version", __clang_version__}}; -#elif defined(__GNUC__) || defined(__GNUG__) - result["compiler"] = {{"family", "gcc"}, {"version", std::to_string(__GNUC__) + "." + std::to_string(__GNUC_MINOR__) + "." + std::to_string(__GNUC_PATCHLEVEL__)}}; -#elif defined(__HP_cc) || defined(__HP_aCC) - result["compiler"] = "hp" -#elif defined(__IBMCPP__) - result["compiler"] = {{"family", "ilecpp"}, {"version", __IBMCPP__}}; -#elif defined(_MSC_VER) - result["compiler"] = {{"family", "msvc"}, {"version", _MSC_VER}}; -#elif defined(__PGI) - result["compiler"] = {{"family", "pgcpp"}, {"version", __PGI}}; -#elif defined(__SUNPRO_CC) - result["compiler"] = {{"family", "sunpro"}, {"version", __SUNPRO_CC}}; -#else - result["compiler"] = {{"family", "unknown"}, {"version", "unknown"}}; -#endif - -#ifdef __cplusplus - result["compiler"]["c++"] = std::to_string(__cplusplus); -#else - result["compiler"]["c++"] = "unknown"; -#endif - return result; - } - - - /////////////////////////// - // JSON value data types // - /////////////////////////// - - /// @name JSON value data types - /// The data types to store a JSON value. These types are derived from - /// the template arguments passed to class @ref basic_json. - /// @{ - -#if defined(JSON_HAS_CPP_14) - // Use transparent comparator if possible, combined with perfect forwarding - // on find() and count() calls prevents unnecessary string construction. - using object_comparator_t = std::less<>; -#else - using object_comparator_t = std::less; -#endif - - /*! - @brief a type for an object - - [RFC 7159](http://rfc7159.net/rfc7159) describes JSON objects as follows: - > An object is an unordered collection of zero or more name/value pairs, - > where a name is a string and a value is a string, number, boolean, null, - > object, or array. - - To store objects in C++, a type is defined by the template parameters - described below. - - @tparam ObjectType the container to store objects (e.g., `std::map` or - `std::unordered_map`) - @tparam StringType the type of the keys or names (e.g., `std::string`). - The comparison function `std::less` is used to order elements - inside the container. - @tparam AllocatorType the allocator to use for objects (e.g., - `std::allocator`) - - #### Default type - - With the default values for @a ObjectType (`std::map`), @a StringType - (`std::string`), and @a AllocatorType (`std::allocator`), the default - value for @a object_t is: - - @code {.cpp} - std::map< - std::string, // key_type - basic_json, // value_type - std::less, // key_compare - std::allocator> // allocator_type - > - @endcode - - #### Behavior - - The choice of @a object_t influences the behavior of the JSON class. With - the default type, objects have the following behavior: - - - When all names are unique, objects will be interoperable in the sense - that all software implementations receiving that object will agree on - the name-value mappings. - - When the names within an object are not unique, it is unspecified which - one of the values for a given key will be chosen. For instance, - `{"key": 2, "key": 1}` could be equal to either `{"key": 1}` or - `{"key": 2}`. - - Internally, name/value pairs are stored in lexicographical order of the - names. Objects will also be serialized (see @ref dump) in this order. - For instance, `{"b": 1, "a": 2}` and `{"a": 2, "b": 1}` will be stored - and serialized as `{"a": 2, "b": 1}`. - - When comparing objects, the order of the name/value pairs is irrelevant. - This makes objects interoperable in the sense that they will not be - affected by these differences. For instance, `{"b": 1, "a": 2}` and - `{"a": 2, "b": 1}` will be treated as equal. - - #### Limits - - [RFC 7159](http://rfc7159.net/rfc7159) specifies: - > An implementation may set limits on the maximum depth of nesting. - - In this class, the object's limit of nesting is not explicitly constrained. - However, a maximum depth of nesting may be introduced by the compiler or - runtime environment. A theoretical limit can be queried by calling the - @ref max_size function of a JSON object. - - #### Storage - - Objects are stored as pointers in a @ref basic_json type. That is, for any - access to object values, a pointer of type `object_t*` must be - dereferenced. - - @sa @ref array_t -- type for an array value - - @since version 1.0.0 - - @note The order name/value pairs are added to the object is *not* - preserved by the library. Therefore, iterating an object may return - name/value pairs in a different order than they were originally stored. In - fact, keys will be traversed in alphabetical order as `std::map` with - `std::less` is used by default. Please note this behavior conforms to [RFC - 7159](http://rfc7159.net/rfc7159), because any order implements the - specified "unordered" nature of JSON objects. - */ - using object_t = ObjectType>>; - - /*! - @brief a type for an array - - [RFC 7159](http://rfc7159.net/rfc7159) describes JSON arrays as follows: - > An array is an ordered sequence of zero or more values. - - To store objects in C++, a type is defined by the template parameters - explained below. - - @tparam ArrayType container type to store arrays (e.g., `std::vector` or - `std::list`) - @tparam AllocatorType allocator to use for arrays (e.g., `std::allocator`) - - #### Default type - - With the default values for @a ArrayType (`std::vector`) and @a - AllocatorType (`std::allocator`), the default value for @a array_t is: - - @code {.cpp} - std::vector< - basic_json, // value_type - std::allocator // allocator_type - > - @endcode - - #### Limits - - [RFC 7159](http://rfc7159.net/rfc7159) specifies: - > An implementation may set limits on the maximum depth of nesting. - - In this class, the array's limit of nesting is not explicitly constrained. - However, a maximum depth of nesting may be introduced by the compiler or - runtime environment. A theoretical limit can be queried by calling the - @ref max_size function of a JSON array. - - #### Storage - - Arrays are stored as pointers in a @ref basic_json type. That is, for any - access to array values, a pointer of type `array_t*` must be dereferenced. - - @sa @ref object_t -- type for an object value - - @since version 1.0.0 - */ - using array_t = ArrayType>; - - /*! - @brief a type for a string - - [RFC 7159](http://rfc7159.net/rfc7159) describes JSON strings as follows: - > A string is a sequence of zero or more Unicode characters. - - To store objects in C++, a type is defined by the template parameter - described below. Unicode values are split by the JSON class into - byte-sized characters during deserialization. - - @tparam StringType the container to store strings (e.g., `std::string`). - Note this container is used for keys/names in objects, see @ref object_t. - - #### Default type - - With the default values for @a StringType (`std::string`), the default - value for @a string_t is: - - @code {.cpp} - std::string - @endcode - - #### Encoding - - Strings are stored in UTF-8 encoding. Therefore, functions like - `std::string::size()` or `std::string::length()` return the number of - bytes in the string rather than the number of characters or glyphs. - - #### String comparison - - [RFC 7159](http://rfc7159.net/rfc7159) states: - > Software implementations are typically required to test names of object - > members for equality. Implementations that transform the textual - > representation into sequences of Unicode code units and then perform the - > comparison numerically, code unit by code unit, are interoperable in the - > sense that implementations will agree in all cases on equality or - > inequality of two strings. For example, implementations that compare - > strings with escaped characters unconverted may incorrectly find that - > `"a\\b"` and `"a\u005Cb"` are not equal. - - This implementation is interoperable as it does compare strings code unit - by code unit. - - #### Storage - - String values are stored as pointers in a @ref basic_json type. That is, - for any access to string values, a pointer of type `string_t*` must be - dereferenced. - - @since version 1.0.0 - */ - using string_t = StringType; - - /*! - @brief a type for a boolean - - [RFC 7159](http://rfc7159.net/rfc7159) implicitly describes a boolean as a - type which differentiates the two literals `true` and `false`. - - To store objects in C++, a type is defined by the template parameter @a - BooleanType which chooses the type to use. - - #### Default type - - With the default values for @a BooleanType (`bool`), the default value for - @a boolean_t is: - - @code {.cpp} - bool - @endcode - - #### Storage - - Boolean values are stored directly inside a @ref basic_json type. - - @since version 1.0.0 - */ - using boolean_t = BooleanType; - - /*! - @brief a type for a number (integer) - - [RFC 7159](http://rfc7159.net/rfc7159) describes numbers as follows: - > The representation of numbers is similar to that used in most - > programming languages. A number is represented in base 10 using decimal - > digits. It contains an integer component that may be prefixed with an - > optional minus sign, which may be followed by a fraction part and/or an - > exponent part. Leading zeros are not allowed. (...) Numeric values that - > cannot be represented in the grammar below (such as Infinity and NaN) - > are not permitted. - - This description includes both integer and floating-point numbers. - However, C++ allows more precise storage if it is known whether the number - is a signed integer, an unsigned integer or a floating-point number. - Therefore, three different types, @ref number_integer_t, @ref - number_unsigned_t and @ref number_float_t are used. - - To store integer numbers in C++, a type is defined by the template - parameter @a NumberIntegerType which chooses the type to use. - - #### Default type - - With the default values for @a NumberIntegerType (`int64_t`), the default - value for @a number_integer_t is: - - @code {.cpp} - int64_t - @endcode - - #### Default behavior - - - The restrictions about leading zeros is not enforced in C++. Instead, - leading zeros in integer literals lead to an interpretation as octal - number. Internally, the value will be stored as decimal number. For - instance, the C++ integer literal `010` will be serialized to `8`. - During deserialization, leading zeros yield an error. - - Not-a-number (NaN) values will be serialized to `null`. - - #### Limits - - [RFC 7159](http://rfc7159.net/rfc7159) specifies: - > An implementation may set limits on the range and precision of numbers. - - When the default type is used, the maximal integer number that can be - stored is `9223372036854775807` (INT64_MAX) and the minimal integer number - that can be stored is `-9223372036854775808` (INT64_MIN). Integer numbers - that are out of range will yield over/underflow when used in a - constructor. During deserialization, too large or small integer numbers - will be automatically be stored as @ref number_unsigned_t or @ref - number_float_t. - - [RFC 7159](http://rfc7159.net/rfc7159) further states: - > Note that when such software is used, numbers that are integers and are - > in the range \f$[-2^{53}+1, 2^{53}-1]\f$ are interoperable in the sense - > that implementations will agree exactly on their numeric values. - - As this range is a subrange of the exactly supported range [INT64_MIN, - INT64_MAX], this class's integer type is interoperable. - - #### Storage - - Integer number values are stored directly inside a @ref basic_json type. - - @sa @ref number_float_t -- type for number values (floating-point) - - @sa @ref number_unsigned_t -- type for number values (unsigned integer) - - @since version 1.0.0 - */ - using number_integer_t = NumberIntegerType; - - /*! - @brief a type for a number (unsigned) - - [RFC 7159](http://rfc7159.net/rfc7159) describes numbers as follows: - > The representation of numbers is similar to that used in most - > programming languages. A number is represented in base 10 using decimal - > digits. It contains an integer component that may be prefixed with an - > optional minus sign, which may be followed by a fraction part and/or an - > exponent part. Leading zeros are not allowed. (...) Numeric values that - > cannot be represented in the grammar below (such as Infinity and NaN) - > are not permitted. - - This description includes both integer and floating-point numbers. - However, C++ allows more precise storage if it is known whether the number - is a signed integer, an unsigned integer or a floating-point number. - Therefore, three different types, @ref number_integer_t, @ref - number_unsigned_t and @ref number_float_t are used. - - To store unsigned integer numbers in C++, a type is defined by the - template parameter @a NumberUnsignedType which chooses the type to use. - - #### Default type - - With the default values for @a NumberUnsignedType (`uint64_t`), the - default value for @a number_unsigned_t is: - - @code {.cpp} - uint64_t - @endcode - - #### Default behavior - - - The restrictions about leading zeros is not enforced in C++. Instead, - leading zeros in integer literals lead to an interpretation as octal - number. Internally, the value will be stored as decimal number. For - instance, the C++ integer literal `010` will be serialized to `8`. - During deserialization, leading zeros yield an error. - - Not-a-number (NaN) values will be serialized to `null`. - - #### Limits - - [RFC 7159](http://rfc7159.net/rfc7159) specifies: - > An implementation may set limits on the range and precision of numbers. - - When the default type is used, the maximal integer number that can be - stored is `18446744073709551615` (UINT64_MAX) and the minimal integer - number that can be stored is `0`. Integer numbers that are out of range - will yield over/underflow when used in a constructor. During - deserialization, too large or small integer numbers will be automatically - be stored as @ref number_integer_t or @ref number_float_t. - - [RFC 7159](http://rfc7159.net/rfc7159) further states: - > Note that when such software is used, numbers that are integers and are - > in the range \f$[-2^{53}+1, 2^{53}-1]\f$ are interoperable in the sense - > that implementations will agree exactly on their numeric values. - - As this range is a subrange (when considered in conjunction with the - number_integer_t type) of the exactly supported range [0, UINT64_MAX], - this class's integer type is interoperable. - - #### Storage - - Integer number values are stored directly inside a @ref basic_json type. - - @sa @ref number_float_t -- type for number values (floating-point) - @sa @ref number_integer_t -- type for number values (integer) - - @since version 2.0.0 - */ - using number_unsigned_t = NumberUnsignedType; - - /*! - @brief a type for a number (floating-point) - - [RFC 7159](http://rfc7159.net/rfc7159) describes numbers as follows: - > The representation of numbers is similar to that used in most - > programming languages. A number is represented in base 10 using decimal - > digits. It contains an integer component that may be prefixed with an - > optional minus sign, which may be followed by a fraction part and/or an - > exponent part. Leading zeros are not allowed. (...) Numeric values that - > cannot be represented in the grammar below (such as Infinity and NaN) - > are not permitted. - - This description includes both integer and floating-point numbers. - However, C++ allows more precise storage if it is known whether the number - is a signed integer, an unsigned integer or a floating-point number. - Therefore, three different types, @ref number_integer_t, @ref - number_unsigned_t and @ref number_float_t are used. - - To store floating-point numbers in C++, a type is defined by the template - parameter @a NumberFloatType which chooses the type to use. - - #### Default type - - With the default values for @a NumberFloatType (`double`), the default - value for @a number_float_t is: - - @code {.cpp} - double - @endcode - - #### Default behavior - - - The restrictions about leading zeros is not enforced in C++. Instead, - leading zeros in floating-point literals will be ignored. Internally, - the value will be stored as decimal number. For instance, the C++ - floating-point literal `01.2` will be serialized to `1.2`. During - deserialization, leading zeros yield an error. - - Not-a-number (NaN) values will be serialized to `null`. - - #### Limits - - [RFC 7159](http://rfc7159.net/rfc7159) states: - > This specification allows implementations to set limits on the range and - > precision of numbers accepted. Since software that implements IEEE - > 754-2008 binary64 (double precision) numbers is generally available and - > widely used, good interoperability can be achieved by implementations - > that expect no more precision or range than these provide, in the sense - > that implementations will approximate JSON numbers within the expected - > precision. - - This implementation does exactly follow this approach, as it uses double - precision floating-point numbers. Note values smaller than - `-1.79769313486232e+308` and values greater than `1.79769313486232e+308` - will be stored as NaN internally and be serialized to `null`. - - #### Storage - - Floating-point number values are stored directly inside a @ref basic_json - type. - - @sa @ref number_integer_t -- type for number values (integer) - - @sa @ref number_unsigned_t -- type for number values (unsigned integer) - - @since version 1.0.0 - */ - using number_float_t = NumberFloatType; - - /*! - @brief a type for a packed binary type - - This type is a type designed to carry binary data that appears in various - serialized formats, such as CBOR's Major Type 2, MessagePack's bin, and - BSON's generic binary subtype. This type is NOT a part of standard JSON and - exists solely for compatibility with these binary types. As such, it is - simply defined as an ordered sequence of zero or more byte values. - - Additionally, as an implementation detail, the subtype of the binary data is - carried around as a `std::uint8_t`, which is compatible with both of the - binary data formats that use binary subtyping, (though the specific - numbering is incompatible with each other, and it is up to the user to - translate between them). - - [CBOR's RFC 7049](https://tools.ietf.org/html/rfc7049) describes this type - as: - > Major type 2: a byte string. The string's length in bytes is represented - > following the rules for positive integers (major type 0). - - [MessagePack's documentation on the bin type - family](https://github.com/msgpack/msgpack/blob/master/spec.md#bin-format-family) - describes this type as: - > Bin format family stores an byte array in 2, 3, or 5 bytes of extra bytes - > in addition to the size of the byte array. - - [BSON's specifications](http://bsonspec.org/spec.html) describe several - binary types; however, this type is intended to represent the generic binary - type which has the description: - > Generic binary subtype - This is the most commonly used binary subtype and - > should be the 'default' for drivers and tools. - - None of these impose any limitations on the internal representation other - than the basic unit of storage be some type of array whose parts are - decomposable into bytes. - - The default representation of this binary format is a - `std::vector`, which is a very common way to represent a byte - array in modern C++. - - #### Default type - - The default values for @a BinaryType is `std::vector` - - #### Storage - - Binary Arrays are stored as pointers in a @ref basic_json type. That is, - for any access to array values, a pointer of the type `binary_t*` must be - dereferenced. - - #### Notes on subtypes - - - CBOR - - Binary values are represented as byte strings. No subtypes are - supported and will be ignored when CBOR is written. - - MessagePack - - If a subtype is given and the binary array contains exactly 1, 2, 4, 8, - or 16 elements, the fixext family (fixext1, fixext2, fixext4, fixext8) - is used. For other sizes, the ext family (ext8, ext16, ext32) is used. - The subtype is then added as singed 8-bit integer. - - If no subtype is given, the bin family (bin8, bin16, bin32) is used. - - BSON - - If a subtype is given, it is used and added as unsigned 8-bit integer. - - If no subtype is given, the generic binary subtype 0x00 is used. - - @sa @ref binary -- create a binary array - - @since version 3.8.0 - */ - using binary_t = nlohmann::byte_container_with_subtype; - /// @} - - private: - - /// helper for exception-safe object creation - template - JSON_HEDLEY_RETURNS_NON_NULL - static T* create(Args&& ... args) - { - AllocatorType alloc; - using AllocatorTraits = std::allocator_traits>; - - auto deleter = [&](T * obj) - { - AllocatorTraits::deallocate(alloc, obj, 1); - }; - std::unique_ptr obj(AllocatorTraits::allocate(alloc, 1), deleter); - AllocatorTraits::construct(alloc, obj.get(), std::forward(args)...); - JSON_ASSERT(obj != nullptr); - return obj.release(); - } - - //////////////////////// - // JSON value storage // - //////////////////////// - - JSON_PRIVATE_UNLESS_TESTED: - /*! - @brief a JSON value - - The actual storage for a JSON value of the @ref basic_json class. This - union combines the different storage types for the JSON value types - defined in @ref value_t. - - JSON type | value_t type | used type - --------- | --------------- | ------------------------ - object | object | pointer to @ref object_t - array | array | pointer to @ref array_t - string | string | pointer to @ref string_t - boolean | boolean | @ref boolean_t - number | number_integer | @ref number_integer_t - number | number_unsigned | @ref number_unsigned_t - number | number_float | @ref number_float_t - binary | binary | pointer to @ref binary_t - null | null | *no value is stored* - - @note Variable-length types (objects, arrays, and strings) are stored as - pointers. The size of the union should not exceed 64 bits if the default - value types are used. - - @since version 1.0.0 - */ - union json_value - { - /// object (stored with pointer to save storage) - object_t* object; - /// array (stored with pointer to save storage) - array_t* array; - /// string (stored with pointer to save storage) - string_t* string; - /// binary (stored with pointer to save storage) - binary_t* binary; - /// boolean - boolean_t boolean; - /// number (integer) - number_integer_t number_integer; - /// number (unsigned integer) - number_unsigned_t number_unsigned; - /// number (floating-point) - number_float_t number_float; - - /// default constructor (for null values) - json_value() = default; - /// constructor for booleans - json_value(boolean_t v) noexcept : boolean(v) {} - /// constructor for numbers (integer) - json_value(number_integer_t v) noexcept : number_integer(v) {} - /// constructor for numbers (unsigned) - json_value(number_unsigned_t v) noexcept : number_unsigned(v) {} - /// constructor for numbers (floating-point) - json_value(number_float_t v) noexcept : number_float(v) {} - /// constructor for empty values of a given type - json_value(value_t t) - { - switch (t) - { - case value_t::object: - { - object = create(); - break; - } - - case value_t::array: - { - array = create(); - break; - } - - case value_t::string: - { - string = create(""); - break; - } - - case value_t::binary: - { - binary = create(); - break; - } - - case value_t::boolean: - { - boolean = boolean_t(false); - break; - } - - case value_t::number_integer: - { - number_integer = number_integer_t(0); - break; - } - - case value_t::number_unsigned: - { - number_unsigned = number_unsigned_t(0); - break; - } - - case value_t::number_float: - { - number_float = number_float_t(0.0); - break; - } - - case value_t::null: - { - object = nullptr; // silence warning, see #821 - break; - } - - default: - { - object = nullptr; // silence warning, see #821 - if (JSON_HEDLEY_UNLIKELY(t == value_t::null)) - { - JSON_THROW(other_error::create(500, "961c151d2e87f2686a955a9be24d316f1362bf21 3.9.1", basic_json())); // LCOV_EXCL_LINE - } - break; - } - } - } - - /// constructor for strings - json_value(const string_t& value) - { - string = create(value); - } - - /// constructor for rvalue strings - json_value(string_t&& value) - { - string = create(std::move(value)); - } - - /// constructor for objects - json_value(const object_t& value) - { - object = create(value); - } - - /// constructor for rvalue objects - json_value(object_t&& value) - { - object = create(std::move(value)); - } - - /// constructor for arrays - json_value(const array_t& value) - { - array = create(value); - } - - /// constructor for rvalue arrays - json_value(array_t&& value) - { - array = create(std::move(value)); - } - - /// constructor for binary arrays - json_value(const typename binary_t::container_type& value) - { - binary = create(value); - } - - /// constructor for rvalue binary arrays - json_value(typename binary_t::container_type&& value) - { - binary = create(std::move(value)); - } - - /// constructor for binary arrays (internal type) - json_value(const binary_t& value) - { - binary = create(value); - } - - /// constructor for rvalue binary arrays (internal type) - json_value(binary_t&& value) - { - binary = create(std::move(value)); - } - - void destroy(value_t t) noexcept - { - // flatten the current json_value to a heap-allocated stack - std::vector stack; - - // move the top-level items to stack - if (t == value_t::array) - { - stack.reserve(array->size()); - std::move(array->begin(), array->end(), std::back_inserter(stack)); - } - else if (t == value_t::object) - { - stack.reserve(object->size()); - for (auto&& it : *object) - { - stack.push_back(std::move(it.second)); - } - } - - while (!stack.empty()) - { - // move the last item to local variable to be processed - basic_json current_item(std::move(stack.back())); - stack.pop_back(); - - // if current_item is array/object, move - // its children to the stack to be processed later - if (current_item.is_array()) - { - std::move(current_item.m_value.array->begin(), current_item.m_value.array->end(), - std::back_inserter(stack)); - - current_item.m_value.array->clear(); - } - else if (current_item.is_object()) - { - for (auto&& it : *current_item.m_value.object) - { - stack.push_back(std::move(it.second)); - } - - current_item.m_value.object->clear(); - } - - // it's now safe that current_item get destructed - // since it doesn't have any children - } - - switch (t) - { - case value_t::object: - { - AllocatorType alloc; - std::allocator_traits::destroy(alloc, object); - std::allocator_traits::deallocate(alloc, object, 1); - break; - } - - case value_t::array: - { - AllocatorType alloc; - std::allocator_traits::destroy(alloc, array); - std::allocator_traits::deallocate(alloc, array, 1); - break; - } - - case value_t::string: - { - AllocatorType alloc; - std::allocator_traits::destroy(alloc, string); - std::allocator_traits::deallocate(alloc, string, 1); - break; - } - - case value_t::binary: - { - AllocatorType alloc; - std::allocator_traits::destroy(alloc, binary); - std::allocator_traits::deallocate(alloc, binary, 1); - break; - } - - default: - { - break; - } - } - } - }; - - private: - /*! - @brief checks the class invariants - - This function asserts the class invariants. It needs to be called at the - end of every constructor to make sure that created objects respect the - invariant. Furthermore, it has to be called each time the type of a JSON - value is changed, because the invariant expresses a relationship between - @a m_type and @a m_value. - - Furthermore, the parent relation is checked for arrays and objects: If - @a check_parents true and the value is an array or object, then the - container's elements must have the current value as parent. - - @param[in] check_parents whether the parent relation should be checked. - The value is true by default and should only be set to false - during destruction of objects when the invariant does not - need to hold. - */ - void assert_invariant(bool check_parents = true) const noexcept - { - JSON_ASSERT(m_type != value_t::object || m_value.object != nullptr); - JSON_ASSERT(m_type != value_t::array || m_value.array != nullptr); - JSON_ASSERT(m_type != value_t::string || m_value.string != nullptr); - JSON_ASSERT(m_type != value_t::binary || m_value.binary != nullptr); - -#if JSON_DIAGNOSTICS - JSON_ASSERT(!check_parents || !is_structured() || std::all_of(begin(), end(), [this](const basic_json & j) - { - return j.m_parent == this; - })); -#else - static_cast(check_parents); -#endif - } - - void set_parents() - { -#if JSON_DIAGNOSTICS - switch (m_type) - { - case value_t::array: - { - for (auto& element : *m_value.array) - { - element.m_parent = this; - } - break; - } - - case value_t::object: - { - for (auto& element : *m_value.object) - { - element.second.m_parent = this; - } - break; - } - - default: - break; - } -#endif - } - - iterator set_parents(iterator it, typename iterator::difference_type count) - { -#if JSON_DIAGNOSTICS - for (typename iterator::difference_type i = 0; i < count; ++i) - { - (it + i)->m_parent = this; - } -#else - static_cast(count); -#endif - return it; - } - - reference set_parent(reference j) - { -#if JSON_DIAGNOSTICS - j.m_parent = this; -#else - static_cast(j); -#endif - return j; - } - - public: - ////////////////////////// - // JSON parser callback // - ////////////////////////// - - /*! - @brief parser event types - - The parser callback distinguishes the following events: - - `object_start`: the parser read `{` and started to process a JSON object - - `key`: the parser read a key of a value in an object - - `object_end`: the parser read `}` and finished processing a JSON object - - `array_start`: the parser read `[` and started to process a JSON array - - `array_end`: the parser read `]` and finished processing a JSON array - - `value`: the parser finished reading a JSON value - - @image html callback_events.png "Example when certain parse events are triggered" - - @sa @ref parser_callback_t for more information and examples - */ - using parse_event_t = detail::parse_event_t; - - /*! - @brief per-element parser callback type - - With a parser callback function, the result of parsing a JSON text can be - influenced. When passed to @ref parse, it is called on certain events - (passed as @ref parse_event_t via parameter @a event) with a set recursion - depth @a depth and context JSON value @a parsed. The return value of the - callback function is a boolean indicating whether the element that emitted - the callback shall be kept or not. - - We distinguish six scenarios (determined by the event type) in which the - callback function can be called. The following table describes the values - of the parameters @a depth, @a event, and @a parsed. - - parameter @a event | description | parameter @a depth | parameter @a parsed - ------------------ | ----------- | ------------------ | ------------------- - parse_event_t::object_start | the parser read `{` and started to process a JSON object | depth of the parent of the JSON object | a JSON value with type discarded - parse_event_t::key | the parser read a key of a value in an object | depth of the currently parsed JSON object | a JSON string containing the key - parse_event_t::object_end | the parser read `}` and finished processing a JSON object | depth of the parent of the JSON object | the parsed JSON object - parse_event_t::array_start | the parser read `[` and started to process a JSON array | depth of the parent of the JSON array | a JSON value with type discarded - parse_event_t::array_end | the parser read `]` and finished processing a JSON array | depth of the parent of the JSON array | the parsed JSON array - parse_event_t::value | the parser finished reading a JSON value | depth of the value | the parsed JSON value - - @image html callback_events.png "Example when certain parse events are triggered" - - Discarding a value (i.e., returning `false`) has different effects - depending on the context in which function was called: - - - Discarded values in structured types are skipped. That is, the parser - will behave as if the discarded value was never read. - - In case a value outside a structured type is skipped, it is replaced - with `null`. This case happens if the top-level element is skipped. - - @param[in] depth the depth of the recursion during parsing - - @param[in] event an event of type parse_event_t indicating the context in - the callback function has been called - - @param[in,out] parsed the current intermediate parse result; note that - writing to this value has no effect for parse_event_t::key events - - @return Whether the JSON value which called the function during parsing - should be kept (`true`) or not (`false`). In the latter case, it is either - skipped completely or replaced by an empty discarded object. - - @sa @ref parse for examples - - @since version 1.0.0 - */ - using parser_callback_t = detail::parser_callback_t; - - ////////////////// - // constructors // - ////////////////// - - /// @name constructors and destructors - /// Constructors of class @ref basic_json, copy/move constructor, copy - /// assignment, static functions creating objects, and the destructor. - /// @{ - - /*! - @brief create an empty value with a given type - - Create an empty JSON value with a given type. The value will be default - initialized with an empty value which depends on the type: - - Value type | initial value - ----------- | ------------- - null | `null` - boolean | `false` - string | `""` - number | `0` - object | `{}` - array | `[]` - binary | empty array - - @param[in] v the type of the value to create - - @complexity Constant. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes to any JSON value. - - @liveexample{The following code shows the constructor for different @ref - value_t values,basic_json__value_t} - - @sa @ref clear() -- restores the postcondition of this constructor - - @since version 1.0.0 - */ - basic_json(const value_t v) - : m_type(v), m_value(v) - { - assert_invariant(); - } - - /*! - @brief create a null object - - Create a `null` JSON value. It either takes a null pointer as parameter - (explicitly creating `null`) or no parameter (implicitly creating `null`). - The passed null pointer itself is not read -- it is only used to choose - the right constructor. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this constructor never throws - exceptions. - - @liveexample{The following code shows the constructor with and without a - null pointer parameter.,basic_json__nullptr_t} - - @since version 1.0.0 - */ - basic_json(std::nullptr_t = nullptr) noexcept - : basic_json(value_t::null) - { - assert_invariant(); - } - - /*! - @brief create a JSON value - - This is a "catch all" constructor for all compatible JSON types; that is, - types for which a `to_json()` method exists. The constructor forwards the - parameter @a val to that method (to `json_serializer::to_json` method - with `U = uncvref_t`, to be exact). - - Template type @a CompatibleType includes, but is not limited to, the - following types: - - **arrays**: @ref array_t and all kinds of compatible containers such as - `std::vector`, `std::deque`, `std::list`, `std::forward_list`, - `std::array`, `std::valarray`, `std::set`, `std::unordered_set`, - `std::multiset`, and `std::unordered_multiset` with a `value_type` from - which a @ref basic_json value can be constructed. - - **objects**: @ref object_t and all kinds of compatible associative - containers such as `std::map`, `std::unordered_map`, `std::multimap`, - and `std::unordered_multimap` with a `key_type` compatible to - @ref string_t and a `value_type` from which a @ref basic_json value can - be constructed. - - **strings**: @ref string_t, string literals, and all compatible string - containers can be used. - - **numbers**: @ref number_integer_t, @ref number_unsigned_t, - @ref number_float_t, and all convertible number types such as `int`, - `size_t`, `int64_t`, `float` or `double` can be used. - - **boolean**: @ref boolean_t / `bool` can be used. - - **binary**: @ref binary_t / `std::vector` may be used, - unfortunately because string literals cannot be distinguished from binary - character arrays by the C++ type system, all types compatible with `const - char*` will be directed to the string constructor instead. This is both - for backwards compatibility, and due to the fact that a binary type is not - a standard JSON type. - - See the examples below. - - @tparam CompatibleType a type such that: - - @a CompatibleType is not derived from `std::istream`, - - @a CompatibleType is not @ref basic_json (to avoid hijacking copy/move - constructors), - - @a CompatibleType is not a different @ref basic_json type (i.e. with different template arguments) - - @a CompatibleType is not a @ref basic_json nested type (e.g., - @ref json_pointer, @ref iterator, etc ...) - - @ref @ref json_serializer has a - `to_json(basic_json_t&, CompatibleType&&)` method - - @tparam U = `uncvref_t` - - @param[in] val the value to be forwarded to the respective constructor - - @complexity Usually linear in the size of the passed @a val, also - depending on the implementation of the called `to_json()` - method. - - @exceptionsafety Depends on the called constructor. For types directly - supported by the library (i.e., all types for which no `to_json()` function - was provided), strong guarantee holds: if an exception is thrown, there are - no changes to any JSON value. - - @liveexample{The following code shows the constructor with several - compatible types.,basic_json__CompatibleType} - - @since version 2.1.0 - */ - template < typename CompatibleType, - typename U = detail::uncvref_t, - detail::enable_if_t < - !detail::is_basic_json::value && detail::is_compatible_type::value, int > = 0 > - basic_json(CompatibleType && val) noexcept(noexcept( - JSONSerializer::to_json(std::declval(), - std::forward(val)))) - { - JSONSerializer::to_json(*this, std::forward(val)); - set_parents(); - assert_invariant(); - } - - /*! - @brief create a JSON value from an existing one - - This is a constructor for existing @ref basic_json types. - It does not hijack copy/move constructors, since the parameter has different - template arguments than the current ones. - - The constructor tries to convert the internal @ref m_value of the parameter. - - @tparam BasicJsonType a type such that: - - @a BasicJsonType is a @ref basic_json type. - - @a BasicJsonType has different template arguments than @ref basic_json_t. - - @param[in] val the @ref basic_json value to be converted. - - @complexity Usually linear in the size of the passed @a val, also - depending on the implementation of the called `to_json()` - method. - - @exceptionsafety Depends on the called constructor. For types directly - supported by the library (i.e., all types for which no `to_json()` function - was provided), strong guarantee holds: if an exception is thrown, there are - no changes to any JSON value. - - @since version 3.2.0 - */ - template < typename BasicJsonType, - detail::enable_if_t < - detail::is_basic_json::value&& !std::is_same::value, int > = 0 > - basic_json(const BasicJsonType& val) - { - using other_boolean_t = typename BasicJsonType::boolean_t; - using other_number_float_t = typename BasicJsonType::number_float_t; - using other_number_integer_t = typename BasicJsonType::number_integer_t; - using other_number_unsigned_t = typename BasicJsonType::number_unsigned_t; - using other_string_t = typename BasicJsonType::string_t; - using other_object_t = typename BasicJsonType::object_t; - using other_array_t = typename BasicJsonType::array_t; - using other_binary_t = typename BasicJsonType::binary_t; - - switch (val.type()) - { - case value_t::boolean: - JSONSerializer::to_json(*this, val.template get()); - break; - case value_t::number_float: - JSONSerializer::to_json(*this, val.template get()); - break; - case value_t::number_integer: - JSONSerializer::to_json(*this, val.template get()); - break; - case value_t::number_unsigned: - JSONSerializer::to_json(*this, val.template get()); - break; - case value_t::string: - JSONSerializer::to_json(*this, val.template get_ref()); - break; - case value_t::object: - JSONSerializer::to_json(*this, val.template get_ref()); - break; - case value_t::array: - JSONSerializer::to_json(*this, val.template get_ref()); - break; - case value_t::binary: - JSONSerializer::to_json(*this, val.template get_ref()); - break; - case value_t::null: - *this = nullptr; - break; - case value_t::discarded: - m_type = value_t::discarded; - break; - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // LCOV_EXCL_LINE - } - set_parents(); - assert_invariant(); - } - - /*! - @brief create a container (array or object) from an initializer list - - Creates a JSON value of type array or object from the passed initializer - list @a init. In case @a type_deduction is `true` (default), the type of - the JSON value to be created is deducted from the initializer list @a init - according to the following rules: - - 1. If the list is empty, an empty JSON object value `{}` is created. - 2. If the list consists of pairs whose first element is a string, a JSON - object value is created where the first elements of the pairs are - treated as keys and the second elements are as values. - 3. In all other cases, an array is created. - - The rules aim to create the best fit between a C++ initializer list and - JSON values. The rationale is as follows: - - 1. The empty initializer list is written as `{}` which is exactly an empty - JSON object. - 2. C++ has no way of describing mapped types other than to list a list of - pairs. As JSON requires that keys must be of type string, rule 2 is the - weakest constraint one can pose on initializer lists to interpret them - as an object. - 3. In all other cases, the initializer list could not be interpreted as - JSON object type, so interpreting it as JSON array type is safe. - - With the rules described above, the following JSON values cannot be - expressed by an initializer list: - - - the empty array (`[]`): use @ref array(initializer_list_t) - with an empty initializer list in this case - - arrays whose elements satisfy rule 2: use @ref - array(initializer_list_t) with the same initializer list - in this case - - @note When used without parentheses around an empty initializer list, @ref - basic_json() is called instead of this function, yielding the JSON null - value. - - @param[in] init initializer list with JSON values - - @param[in] type_deduction internal parameter; when set to `true`, the type - of the JSON value is deducted from the initializer list @a init; when set - to `false`, the type provided via @a manual_type is forced. This mode is - used by the functions @ref array(initializer_list_t) and - @ref object(initializer_list_t). - - @param[in] manual_type internal parameter; when @a type_deduction is set - to `false`, the created JSON value will use the provided type (only @ref - value_t::array and @ref value_t::object are valid); when @a type_deduction - is set to `true`, this parameter has no effect - - @throw type_error.301 if @a type_deduction is `false`, @a manual_type is - `value_t::object`, but @a init contains an element which is not a pair - whose first element is a string. In this case, the constructor could not - create an object. If @a type_deduction would have be `true`, an array - would have been created. See @ref object(initializer_list_t) - for an example. - - @complexity Linear in the size of the initializer list @a init. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes to any JSON value. - - @liveexample{The example below shows how JSON values are created from - initializer lists.,basic_json__list_init_t} - - @sa @ref array(initializer_list_t) -- create a JSON array - value from an initializer list - @sa @ref object(initializer_list_t) -- create a JSON object - value from an initializer list - - @since version 1.0.0 - */ - basic_json(initializer_list_t init, - bool type_deduction = true, - value_t manual_type = value_t::array) - { - // check if each element is an array with two elements whose first - // element is a string - bool is_an_object = std::all_of(init.begin(), init.end(), - [](const detail::json_ref& element_ref) - { - return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[0].is_string(); - }); - - // adjust type if type deduction is not wanted - if (!type_deduction) - { - // if array is wanted, do not create an object though possible - if (manual_type == value_t::array) - { - is_an_object = false; - } - - // if object is wanted but impossible, throw an exception - if (JSON_HEDLEY_UNLIKELY(manual_type == value_t::object && !is_an_object)) - { - JSON_THROW(type_error::create(301, "cannot create object from initializer list", basic_json())); - } - } - - if (is_an_object) - { - // the initializer list is a list of pairs -> create object - m_type = value_t::object; - m_value = value_t::object; - - for (auto& element_ref : init) - { - auto element = element_ref.moved_or_copied(); - m_value.object->emplace( - std::move(*((*element.m_value.array)[0].m_value.string)), - std::move((*element.m_value.array)[1])); - } - } - else - { - // the initializer list describes an array -> create array - m_type = value_t::array; - m_value.array = create(init.begin(), init.end()); - } - - set_parents(); - assert_invariant(); - } - - /*! - @brief explicitly create a binary array (without subtype) - - Creates a JSON binary array value from a given binary container. Binary - values are part of various binary formats, such as CBOR, MessagePack, and - BSON. This constructor is used to create a value for serialization to those - formats. - - @note Note, this function exists because of the difficulty in correctly - specifying the correct template overload in the standard value ctor, as both - JSON arrays and JSON binary arrays are backed with some form of a - `std::vector`. Because JSON binary arrays are a non-standard extension it - was decided that it would be best to prevent automatic initialization of a - binary array type, for backwards compatibility and so it does not happen on - accident. - - @param[in] init container containing bytes to use as binary type - - @return JSON binary array value - - @complexity Linear in the size of @a init. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes to any JSON value. - - @since version 3.8.0 - */ - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json binary(const typename binary_t::container_type& init) - { - auto res = basic_json(); - res.m_type = value_t::binary; - res.m_value = init; - return res; - } - - /*! - @brief explicitly create a binary array (with subtype) - - Creates a JSON binary array value from a given binary container. Binary - values are part of various binary formats, such as CBOR, MessagePack, and - BSON. This constructor is used to create a value for serialization to those - formats. - - @note Note, this function exists because of the difficulty in correctly - specifying the correct template overload in the standard value ctor, as both - JSON arrays and JSON binary arrays are backed with some form of a - `std::vector`. Because JSON binary arrays are a non-standard extension it - was decided that it would be best to prevent automatic initialization of a - binary array type, for backwards compatibility and so it does not happen on - accident. - - @param[in] init container containing bytes to use as binary type - @param[in] subtype subtype to use in MessagePack and BSON - - @return JSON binary array value - - @complexity Linear in the size of @a init. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes to any JSON value. - - @since version 3.8.0 - */ - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json binary(const typename binary_t::container_type& init, std::uint8_t subtype) - { - auto res = basic_json(); - res.m_type = value_t::binary; - res.m_value = binary_t(init, subtype); - return res; - } - - /// @copydoc binary(const typename binary_t::container_type&) - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json binary(typename binary_t::container_type&& init) - { - auto res = basic_json(); - res.m_type = value_t::binary; - res.m_value = std::move(init); - return res; - } - - /// @copydoc binary(const typename binary_t::container_type&, std::uint8_t) - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json binary(typename binary_t::container_type&& init, std::uint8_t subtype) - { - auto res = basic_json(); - res.m_type = value_t::binary; - res.m_value = binary_t(std::move(init), subtype); - return res; - } - - /*! - @brief explicitly create an array from an initializer list - - Creates a JSON array value from a given initializer list. That is, given a - list of values `a, b, c`, creates the JSON value `[a, b, c]`. If the - initializer list is empty, the empty array `[]` is created. - - @note This function is only needed to express two edge cases that cannot - be realized with the initializer list constructor (@ref - basic_json(initializer_list_t, bool, value_t)). These cases - are: - 1. creating an array whose elements are all pairs whose first element is a - string -- in this case, the initializer list constructor would create an - object, taking the first elements as keys - 2. creating an empty array -- passing the empty initializer list to the - initializer list constructor yields an empty object - - @param[in] init initializer list with JSON values to create an array from - (optional) - - @return JSON array value - - @complexity Linear in the size of @a init. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes to any JSON value. - - @liveexample{The following code shows an example for the `array` - function.,array} - - @sa @ref basic_json(initializer_list_t, bool, value_t) -- - create a JSON value from an initializer list - @sa @ref object(initializer_list_t) -- create a JSON object - value from an initializer list - - @since version 1.0.0 - */ - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json array(initializer_list_t init = {}) - { - return basic_json(init, false, value_t::array); - } - - /*! - @brief explicitly create an object from an initializer list - - Creates a JSON object value from a given initializer list. The initializer - lists elements must be pairs, and their first elements must be strings. If - the initializer list is empty, the empty object `{}` is created. - - @note This function is only added for symmetry reasons. In contrast to the - related function @ref array(initializer_list_t), there are - no cases which can only be expressed by this function. That is, any - initializer list @a init can also be passed to the initializer list - constructor @ref basic_json(initializer_list_t, bool, value_t). - - @param[in] init initializer list to create an object from (optional) - - @return JSON object value - - @throw type_error.301 if @a init is not a list of pairs whose first - elements are strings. In this case, no object can be created. When such a - value is passed to @ref basic_json(initializer_list_t, bool, value_t), - an array would have been created from the passed initializer list @a init. - See example below. - - @complexity Linear in the size of @a init. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes to any JSON value. - - @liveexample{The following code shows an example for the `object` - function.,object} - - @sa @ref basic_json(initializer_list_t, bool, value_t) -- - create a JSON value from an initializer list - @sa @ref array(initializer_list_t) -- create a JSON array - value from an initializer list - - @since version 1.0.0 - */ - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json object(initializer_list_t init = {}) - { - return basic_json(init, false, value_t::object); - } - - /*! - @brief construct an array with count copies of given value - - Constructs a JSON array value by creating @a cnt copies of a passed value. - In case @a cnt is `0`, an empty array is created. - - @param[in] cnt the number of JSON copies of @a val to create - @param[in] val the JSON value to copy - - @post `std::distance(begin(),end()) == cnt` holds. - - @complexity Linear in @a cnt. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes to any JSON value. - - @liveexample{The following code shows examples for the @ref - basic_json(size_type\, const basic_json&) - constructor.,basic_json__size_type_basic_json} - - @since version 1.0.0 - */ - basic_json(size_type cnt, const basic_json& val) - : m_type(value_t::array) - { - m_value.array = create(cnt, val); - set_parents(); - assert_invariant(); - } - - /*! - @brief construct a JSON container given an iterator range - - Constructs the JSON value with the contents of the range `[first, last)`. - The semantics depends on the different types a JSON value can have: - - In case of a null type, invalid_iterator.206 is thrown. - - In case of other primitive types (number, boolean, or string), @a first - must be `begin()` and @a last must be `end()`. In this case, the value is - copied. Otherwise, invalid_iterator.204 is thrown. - - In case of structured types (array, object), the constructor behaves as - similar versions for `std::vector` or `std::map`; that is, a JSON array - or object is constructed from the values in the range. - - @tparam InputIT an input iterator type (@ref iterator or @ref - const_iterator) - - @param[in] first begin of the range to copy from (included) - @param[in] last end of the range to copy from (excluded) - - @pre Iterators @a first and @a last must be initialized. **This - precondition is enforced with an assertion (see warning).** If - assertions are switched off, a violation of this precondition yields - undefined behavior. - - @pre Range `[first, last)` is valid. Usually, this precondition cannot be - checked efficiently. Only certain edge cases are detected; see the - description of the exceptions below. A violation of this precondition - yields undefined behavior. - - @warning A precondition is enforced with a runtime assertion that will - result in calling `std::abort` if this precondition is not met. - Assertions can be disabled by defining `NDEBUG` at compile time. - See https://en.cppreference.com/w/cpp/error/assert for more - information. - - @throw invalid_iterator.201 if iterators @a first and @a last are not - compatible (i.e., do not belong to the same JSON value). In this case, - the range `[first, last)` is undefined. - @throw invalid_iterator.204 if iterators @a first and @a last belong to a - primitive type (number, boolean, or string), but @a first does not point - to the first element any more. In this case, the range `[first, last)` is - undefined. See example code below. - @throw invalid_iterator.206 if iterators @a first and @a last belong to a - null value. In this case, the range `[first, last)` is undefined. - - @complexity Linear in distance between @a first and @a last. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes to any JSON value. - - @liveexample{The example below shows several ways to create JSON values by - specifying a subrange with iterators.,basic_json__InputIt_InputIt} - - @since version 1.0.0 - */ - template < class InputIT, typename std::enable_if < - std::is_same::value || - std::is_same::value, int >::type = 0 > - basic_json(InputIT first, InputIT last) - { - JSON_ASSERT(first.m_object != nullptr); - JSON_ASSERT(last.m_object != nullptr); - - // make sure iterator fits the current value - if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) - { - JSON_THROW(invalid_iterator::create(201, "iterators are not compatible", basic_json())); - } - - // copy type from first iterator - m_type = first.m_object->m_type; - - // check if iterator range is complete for primitive values - switch (m_type) - { - case value_t::boolean: - case value_t::number_float: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::string: - { - if (JSON_HEDLEY_UNLIKELY(!first.m_it.primitive_iterator.is_begin() - || !last.m_it.primitive_iterator.is_end())) - { - JSON_THROW(invalid_iterator::create(204, "iterators out of range", *first.m_object)); - } - break; - } - - default: - break; - } - - switch (m_type) - { - case value_t::number_integer: - { - m_value.number_integer = first.m_object->m_value.number_integer; - break; - } - - case value_t::number_unsigned: - { - m_value.number_unsigned = first.m_object->m_value.number_unsigned; - break; - } - - case value_t::number_float: - { - m_value.number_float = first.m_object->m_value.number_float; - break; - } - - case value_t::boolean: - { - m_value.boolean = first.m_object->m_value.boolean; - break; - } - - case value_t::string: - { - m_value = *first.m_object->m_value.string; - break; - } - - case value_t::object: - { - m_value.object = create(first.m_it.object_iterator, - last.m_it.object_iterator); - break; - } - - case value_t::array: - { - m_value.array = create(first.m_it.array_iterator, - last.m_it.array_iterator); - break; - } - - case value_t::binary: - { - m_value = *first.m_object->m_value.binary; - break; - } - - default: - JSON_THROW(invalid_iterator::create(206, "cannot construct with iterators from " + std::string(first.m_object->type_name()), *first.m_object)); - } - - set_parents(); - assert_invariant(); - } - - - /////////////////////////////////////// - // other constructors and destructor // - /////////////////////////////////////// - - template, - std::is_same>::value, int> = 0 > - basic_json(const JsonRef& ref) : basic_json(ref.moved_or_copied()) {} - - /*! - @brief copy constructor - - Creates a copy of a given JSON value. - - @param[in] other the JSON value to copy - - @post `*this == other` - - @complexity Linear in the size of @a other. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes to any JSON value. - - @requirement This function helps `basic_json` satisfying the - [Container](https://en.cppreference.com/w/cpp/named_req/Container) - requirements: - - The complexity is linear. - - As postcondition, it holds: `other == basic_json(other)`. - - @liveexample{The following code shows an example for the copy - constructor.,basic_json__basic_json} - - @since version 1.0.0 - */ - basic_json(const basic_json& other) - : m_type(other.m_type) - { - // check of passed value is valid - other.assert_invariant(); - - switch (m_type) - { - case value_t::object: - { - m_value = *other.m_value.object; - break; - } - - case value_t::array: - { - m_value = *other.m_value.array; - break; - } - - case value_t::string: - { - m_value = *other.m_value.string; - break; - } - - case value_t::boolean: - { - m_value = other.m_value.boolean; - break; - } - - case value_t::number_integer: - { - m_value = other.m_value.number_integer; - break; - } - - case value_t::number_unsigned: - { - m_value = other.m_value.number_unsigned; - break; - } - - case value_t::number_float: - { - m_value = other.m_value.number_float; - break; - } - - case value_t::binary: - { - m_value = *other.m_value.binary; - break; - } - - default: - break; - } - - set_parents(); - assert_invariant(); - } - - /*! - @brief move constructor - - Move constructor. Constructs a JSON value with the contents of the given - value @a other using move semantics. It "steals" the resources from @a - other and leaves it as JSON null value. - - @param[in,out] other value to move to this object - - @post `*this` has the same value as @a other before the call. - @post @a other is a JSON null value. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this constructor never throws - exceptions. - - @requirement This function helps `basic_json` satisfying the - [MoveConstructible](https://en.cppreference.com/w/cpp/named_req/MoveConstructible) - requirements. - - @liveexample{The code below shows the move constructor explicitly called - via std::move.,basic_json__moveconstructor} - - @since version 1.0.0 - */ - basic_json(basic_json&& other) noexcept - : m_type(std::move(other.m_type)), - m_value(std::move(other.m_value)) - { - // check that passed value is valid - other.assert_invariant(false); - - // invalidate payload - other.m_type = value_t::null; - other.m_value = {}; - - set_parents(); - assert_invariant(); - } - - /*! - @brief copy assignment - - Copy assignment operator. Copies a JSON value via the "copy and swap" - strategy: It is expressed in terms of the copy constructor, destructor, - and the `swap()` member function. - - @param[in] other value to copy from - - @complexity Linear. - - @requirement This function helps `basic_json` satisfying the - [Container](https://en.cppreference.com/w/cpp/named_req/Container) - requirements: - - The complexity is linear. - - @liveexample{The code below shows and example for the copy assignment. It - creates a copy of value `a` which is then swapped with `b`. Finally\, the - copy of `a` (which is the null value after the swap) is - destroyed.,basic_json__copyassignment} - - @since version 1.0.0 - */ - basic_json& operator=(basic_json other) noexcept ( - std::is_nothrow_move_constructible::value&& - std::is_nothrow_move_assignable::value&& - std::is_nothrow_move_constructible::value&& - std::is_nothrow_move_assignable::value - ) - { - // check that passed value is valid - other.assert_invariant(); - - using std::swap; - swap(m_type, other.m_type); - swap(m_value, other.m_value); - - set_parents(); - assert_invariant(); - return *this; - } - - /*! - @brief destructor - - Destroys the JSON value and frees all allocated memory. - - @complexity Linear. - - @requirement This function helps `basic_json` satisfying the - [Container](https://en.cppreference.com/w/cpp/named_req/Container) - requirements: - - The complexity is linear. - - All stored elements are destroyed and all memory is freed. - - @since version 1.0.0 - */ - ~basic_json() noexcept - { - assert_invariant(false); - m_value.destroy(m_type); - } - - /// @} - - public: - /////////////////////// - // object inspection // - /////////////////////// - - /// @name object inspection - /// Functions to inspect the type of a JSON value. - /// @{ - - /*! - @brief serialization - - Serialization function for JSON values. The function tries to mimic - Python's `json.dumps()` function, and currently supports its @a indent - and @a ensure_ascii parameters. - - @param[in] indent If indent is nonnegative, then array elements and object - members will be pretty-printed with that indent level. An indent level of - `0` will only insert newlines. `-1` (the default) selects the most compact - representation. - @param[in] indent_char The character to use for indentation if @a indent is - greater than `0`. The default is ` ` (space). - @param[in] ensure_ascii If @a ensure_ascii is true, all non-ASCII characters - in the output are escaped with `\uXXXX` sequences, and the result consists - of ASCII characters only. - @param[in] error_handler how to react on decoding errors; there are three - possible values: `strict` (throws and exception in case a decoding error - occurs; default), `replace` (replace invalid UTF-8 sequences with U+FFFD), - and `ignore` (ignore invalid UTF-8 sequences during serialization; all - bytes are copied to the output unchanged). - - @return string containing the serialization of the JSON value - - @throw type_error.316 if a string stored inside the JSON value is not - UTF-8 encoded and @a error_handler is set to strict - - @note Binary values are serialized as object containing two keys: - - "bytes": an array of bytes as integers - - "subtype": the subtype as integer or "null" if the binary has no subtype - - @complexity Linear. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes in the JSON value. - - @liveexample{The following example shows the effect of different @a indent\, - @a indent_char\, and @a ensure_ascii parameters to the result of the - serialization.,dump} - - @see https://docs.python.org/2/library/json.html#json.dump - - @since version 1.0.0; indentation character @a indent_char, option - @a ensure_ascii and exceptions added in version 3.0.0; error - handlers added in version 3.4.0; serialization of binary values added - in version 3.8.0. - */ - string_t dump(const int indent = -1, - const char indent_char = ' ', - const bool ensure_ascii = false, - const error_handler_t error_handler = error_handler_t::strict) const - { - string_t result; - serializer s(detail::output_adapter(result), indent_char, error_handler); - - if (indent >= 0) - { - s.dump(*this, true, ensure_ascii, static_cast(indent)); - } - else - { - s.dump(*this, false, ensure_ascii, 0); - } - - return result; - } - - /*! - @brief return the type of the JSON value (explicit) - - Return the type of the JSON value as a value from the @ref value_t - enumeration. - - @return the type of the JSON value - Value type | return value - ------------------------- | ------------------------- - null | value_t::null - boolean | value_t::boolean - string | value_t::string - number (integer) | value_t::number_integer - number (unsigned integer) | value_t::number_unsigned - number (floating-point) | value_t::number_float - object | value_t::object - array | value_t::array - binary | value_t::binary - discarded | value_t::discarded - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `type()` for all JSON - types.,type} - - @sa @ref operator value_t() -- return the type of the JSON value (implicit) - @sa @ref type_name() -- return the type as string - - @since version 1.0.0 - */ - constexpr value_t type() const noexcept - { - return m_type; - } - - /*! - @brief return whether type is primitive - - This function returns true if and only if the JSON type is primitive - (string, number, boolean, or null). - - @return `true` if type is primitive (string, number, boolean, or null), - `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_primitive()` for all JSON - types.,is_primitive} - - @sa @ref is_structured() -- returns whether JSON value is structured - @sa @ref is_null() -- returns whether JSON value is `null` - @sa @ref is_string() -- returns whether JSON value is a string - @sa @ref is_boolean() -- returns whether JSON value is a boolean - @sa @ref is_number() -- returns whether JSON value is a number - @sa @ref is_binary() -- returns whether JSON value is a binary array - - @since version 1.0.0 - */ - constexpr bool is_primitive() const noexcept - { - return is_null() || is_string() || is_boolean() || is_number() || is_binary(); - } - - /*! - @brief return whether type is structured - - This function returns true if and only if the JSON type is structured - (array or object). - - @return `true` if type is structured (array or object), `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_structured()` for all JSON - types.,is_structured} - - @sa @ref is_primitive() -- returns whether value is primitive - @sa @ref is_array() -- returns whether value is an array - @sa @ref is_object() -- returns whether value is an object - - @since version 1.0.0 - */ - constexpr bool is_structured() const noexcept - { - return is_array() || is_object(); - } - - /*! - @brief return whether value is null - - This function returns true if and only if the JSON value is null. - - @return `true` if type is null, `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_null()` for all JSON - types.,is_null} - - @since version 1.0.0 - */ - constexpr bool is_null() const noexcept - { - return m_type == value_t::null; - } - - /*! - @brief return whether value is a boolean - - This function returns true if and only if the JSON value is a boolean. - - @return `true` if type is boolean, `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_boolean()` for all JSON - types.,is_boolean} - - @since version 1.0.0 - */ - constexpr bool is_boolean() const noexcept - { - return m_type == value_t::boolean; - } - - /*! - @brief return whether value is a number - - This function returns true if and only if the JSON value is a number. This - includes both integer (signed and unsigned) and floating-point values. - - @return `true` if type is number (regardless whether integer, unsigned - integer or floating-type), `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_number()` for all JSON - types.,is_number} - - @sa @ref is_number_integer() -- check if value is an integer or unsigned - integer number - @sa @ref is_number_unsigned() -- check if value is an unsigned integer - number - @sa @ref is_number_float() -- check if value is a floating-point number - - @since version 1.0.0 - */ - constexpr bool is_number() const noexcept - { - return is_number_integer() || is_number_float(); - } - - /*! - @brief return whether value is an integer number - - This function returns true if and only if the JSON value is a signed or - unsigned integer number. This excludes floating-point values. - - @return `true` if type is an integer or unsigned integer number, `false` - otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_number_integer()` for all - JSON types.,is_number_integer} - - @sa @ref is_number() -- check if value is a number - @sa @ref is_number_unsigned() -- check if value is an unsigned integer - number - @sa @ref is_number_float() -- check if value is a floating-point number - - @since version 1.0.0 - */ - constexpr bool is_number_integer() const noexcept - { - return m_type == value_t::number_integer || m_type == value_t::number_unsigned; - } - - /*! - @brief return whether value is an unsigned integer number - - This function returns true if and only if the JSON value is an unsigned - integer number. This excludes floating-point and signed integer values. - - @return `true` if type is an unsigned integer number, `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_number_unsigned()` for all - JSON types.,is_number_unsigned} - - @sa @ref is_number() -- check if value is a number - @sa @ref is_number_integer() -- check if value is an integer or unsigned - integer number - @sa @ref is_number_float() -- check if value is a floating-point number - - @since version 2.0.0 - */ - constexpr bool is_number_unsigned() const noexcept - { - return m_type == value_t::number_unsigned; - } - - /*! - @brief return whether value is a floating-point number - - This function returns true if and only if the JSON value is a - floating-point number. This excludes signed and unsigned integer values. - - @return `true` if type is a floating-point number, `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_number_float()` for all - JSON types.,is_number_float} - - @sa @ref is_number() -- check if value is number - @sa @ref is_number_integer() -- check if value is an integer number - @sa @ref is_number_unsigned() -- check if value is an unsigned integer - number - - @since version 1.0.0 - */ - constexpr bool is_number_float() const noexcept - { - return m_type == value_t::number_float; - } - - /*! - @brief return whether value is an object - - This function returns true if and only if the JSON value is an object. - - @return `true` if type is object, `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_object()` for all JSON - types.,is_object} - - @since version 1.0.0 - */ - constexpr bool is_object() const noexcept - { - return m_type == value_t::object; - } - - /*! - @brief return whether value is an array - - This function returns true if and only if the JSON value is an array. - - @return `true` if type is array, `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_array()` for all JSON - types.,is_array} - - @since version 1.0.0 - */ - constexpr bool is_array() const noexcept - { - return m_type == value_t::array; - } - - /*! - @brief return whether value is a string - - This function returns true if and only if the JSON value is a string. - - @return `true` if type is string, `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_string()` for all JSON - types.,is_string} - - @since version 1.0.0 - */ - constexpr bool is_string() const noexcept - { - return m_type == value_t::string; - } - - /*! - @brief return whether value is a binary array - - This function returns true if and only if the JSON value is a binary array. - - @return `true` if type is binary array, `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_binary()` for all JSON - types.,is_binary} - - @since version 3.8.0 - */ - constexpr bool is_binary() const noexcept - { - return m_type == value_t::binary; - } - - /*! - @brief return whether value is discarded - - This function returns true if and only if the JSON value was discarded - during parsing with a callback function (see @ref parser_callback_t). - - @note This function will always be `false` for JSON values after parsing. - That is, discarded values can only occur during parsing, but will be - removed when inside a structured value or replaced by null in other cases. - - @return `true` if type is discarded, `false` otherwise. - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies `is_discarded()` for all JSON - types.,is_discarded} - - @since version 1.0.0 - */ - constexpr bool is_discarded() const noexcept - { - return m_type == value_t::discarded; - } - - /*! - @brief return the type of the JSON value (implicit) - - Implicitly return the type of the JSON value as a value from the @ref - value_t enumeration. - - @return the type of the JSON value - - @complexity Constant. - - @exceptionsafety No-throw guarantee: this member function never throws - exceptions. - - @liveexample{The following code exemplifies the @ref value_t operator for - all JSON types.,operator__value_t} - - @sa @ref type() -- return the type of the JSON value (explicit) - @sa @ref type_name() -- return the type as string - - @since version 1.0.0 - */ - constexpr operator value_t() const noexcept - { - return m_type; - } - - /// @} - - private: - ////////////////// - // value access // - ////////////////// - - /// get a boolean (explicit) - boolean_t get_impl(boolean_t* /*unused*/) const - { - if (JSON_HEDLEY_LIKELY(is_boolean())) - { - return m_value.boolean; - } - - JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(type_name()), *this)); - } - - /// get a pointer to the value (object) - object_t* get_impl_ptr(object_t* /*unused*/) noexcept - { - return is_object() ? m_value.object : nullptr; - } - - /// get a pointer to the value (object) - constexpr const object_t* get_impl_ptr(const object_t* /*unused*/) const noexcept - { - return is_object() ? m_value.object : nullptr; - } - - /// get a pointer to the value (array) - array_t* get_impl_ptr(array_t* /*unused*/) noexcept - { - return is_array() ? m_value.array : nullptr; - } - - /// get a pointer to the value (array) - constexpr const array_t* get_impl_ptr(const array_t* /*unused*/) const noexcept - { - return is_array() ? m_value.array : nullptr; - } - - /// get a pointer to the value (string) - string_t* get_impl_ptr(string_t* /*unused*/) noexcept - { - return is_string() ? m_value.string : nullptr; - } - - /// get a pointer to the value (string) - constexpr const string_t* get_impl_ptr(const string_t* /*unused*/) const noexcept - { - return is_string() ? m_value.string : nullptr; - } - - /// get a pointer to the value (boolean) - boolean_t* get_impl_ptr(boolean_t* /*unused*/) noexcept - { - return is_boolean() ? &m_value.boolean : nullptr; - } - - /// get a pointer to the value (boolean) - constexpr const boolean_t* get_impl_ptr(const boolean_t* /*unused*/) const noexcept - { - return is_boolean() ? &m_value.boolean : nullptr; - } - - /// get a pointer to the value (integer number) - number_integer_t* get_impl_ptr(number_integer_t* /*unused*/) noexcept - { - return is_number_integer() ? &m_value.number_integer : nullptr; - } - - /// get a pointer to the value (integer number) - constexpr const number_integer_t* get_impl_ptr(const number_integer_t* /*unused*/) const noexcept - { - return is_number_integer() ? &m_value.number_integer : nullptr; - } - - /// get a pointer to the value (unsigned number) - number_unsigned_t* get_impl_ptr(number_unsigned_t* /*unused*/) noexcept - { - return is_number_unsigned() ? &m_value.number_unsigned : nullptr; - } - - /// get a pointer to the value (unsigned number) - constexpr const number_unsigned_t* get_impl_ptr(const number_unsigned_t* /*unused*/) const noexcept - { - return is_number_unsigned() ? &m_value.number_unsigned : nullptr; - } - - /// get a pointer to the value (floating-point number) - number_float_t* get_impl_ptr(number_float_t* /*unused*/) noexcept - { - return is_number_float() ? &m_value.number_float : nullptr; - } - - /// get a pointer to the value (floating-point number) - constexpr const number_float_t* get_impl_ptr(const number_float_t* /*unused*/) const noexcept - { - return is_number_float() ? &m_value.number_float : nullptr; - } - - /// get a pointer to the value (binary) - binary_t* get_impl_ptr(binary_t* /*unused*/) noexcept - { - return is_binary() ? m_value.binary : nullptr; - } - - /// get a pointer to the value (binary) - constexpr const binary_t* get_impl_ptr(const binary_t* /*unused*/) const noexcept - { - return is_binary() ? m_value.binary : nullptr; - } - - /*! - @brief helper function to implement get_ref() - - This function helps to implement get_ref() without code duplication for - const and non-const overloads - - @tparam ThisType will be deduced as `basic_json` or `const basic_json` - - @throw type_error.303 if ReferenceType does not match underlying value - type of the current JSON - */ - template - static ReferenceType get_ref_impl(ThisType& obj) - { - // delegate the call to get_ptr<>() - auto ptr = obj.template get_ptr::type>(); - - if (JSON_HEDLEY_LIKELY(ptr != nullptr)) - { - return *ptr; - } - - JSON_THROW(type_error::create(303, "incompatible ReferenceType for get_ref, actual type is " + std::string(obj.type_name()), obj)); - } - - public: - /// @name value access - /// Direct access to the stored value of a JSON value. - /// @{ - - /*! - @brief get special-case overload - - This overloads avoids a lot of template boilerplate, it can be seen as the - identity method - - @tparam BasicJsonType == @ref basic_json - - @return a copy of *this - - @complexity Constant. - - @since version 2.1.0 - */ - template::type, basic_json_t>::value, - int> = 0> - basic_json get() const - { - return *this; - } - - /*! - @brief get special-case overload - - This overloads converts the current @ref basic_json in a different - @ref basic_json type - - @tparam BasicJsonType == @ref basic_json - - @return a copy of *this, converted into @tparam BasicJsonType - - @complexity Depending on the implementation of the called `from_json()` - method. - - @since version 3.2.0 - */ - template < typename BasicJsonType, detail::enable_if_t < - !std::is_same::value&& - detail::is_basic_json::value, int > = 0 > - BasicJsonType get() const - { - return *this; - } - - /*! - @brief get a value (explicit) - - Explicit type conversion between the JSON value and a compatible value - which is [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible) - and [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible). - The value is converted by calling the @ref json_serializer - `from_json()` method. - - The function is equivalent to executing - @code {.cpp} - ValueType ret; - JSONSerializer::from_json(*this, ret); - return ret; - @endcode - - This overloads is chosen if: - - @a ValueType is not @ref basic_json, - - @ref json_serializer has a `from_json()` method of the form - `void from_json(const basic_json&, ValueType&)`, and - - @ref json_serializer does not have a `from_json()` method of - the form `ValueType from_json(const basic_json&)` - - @tparam ValueTypeCV the provided value type - @tparam ValueType the returned value type - - @return copy of the JSON value, converted to @a ValueType - - @throw what @ref json_serializer `from_json()` method throws - - @liveexample{The example below shows several conversions from JSON values - to other types. There a few things to note: (1) Floating-point numbers can - be converted to integers\, (2) A JSON array can be converted to a standard - `std::vector`\, (3) A JSON object can be converted to C++ - associative containers such as `std::unordered_map`.,get__ValueType_const} - - @since version 2.1.0 - */ - template < typename ValueTypeCV, typename ValueType = detail::uncvref_t, - detail::enable_if_t < - !detail::is_basic_json::value && - detail::has_from_json::value && - !detail::has_non_default_from_json::value, - int > = 0 > - ValueType get() const noexcept(noexcept( - JSONSerializer::from_json(std::declval(), std::declval()))) - { - // we cannot static_assert on ValueTypeCV being non-const, because - // there is support for get(), which is why we - // still need the uncvref - static_assert(!std::is_reference::value, - "get() cannot be used with reference types, you might want to use get_ref()"); - static_assert(std::is_default_constructible::value, - "types must be DefaultConstructible when used with get()"); - - ValueType ret; - JSONSerializer::from_json(*this, ret); - return ret; - } - - /*! - @brief get a value (explicit); special case - - Explicit type conversion between the JSON value and a compatible value - which is **not** [CopyConstructible](https://en.cppreference.com/w/cpp/named_req/CopyConstructible) - and **not** [DefaultConstructible](https://en.cppreference.com/w/cpp/named_req/DefaultConstructible). - The value is converted by calling the @ref json_serializer - `from_json()` method. - - The function is equivalent to executing - @code {.cpp} - return JSONSerializer::from_json(*this); - @endcode - - This overloads is chosen if: - - @a ValueType is not @ref basic_json and - - @ref json_serializer has a `from_json()` method of the form - `ValueType from_json(const basic_json&)` - - @note If @ref json_serializer has both overloads of - `from_json()`, this one is chosen. - - @tparam ValueTypeCV the provided value type - @tparam ValueType the returned value type - - @return copy of the JSON value, converted to @a ValueType - - @throw what @ref json_serializer `from_json()` method throws - - @since version 2.1.0 - */ - template < typename ValueTypeCV, typename ValueType = detail::uncvref_t, - detail::enable_if_t < !std::is_same::value && - detail::has_non_default_from_json::value, - int > = 0 > - ValueType get() const noexcept(noexcept( - JSONSerializer::from_json(std::declval()))) - { - static_assert(!std::is_reference::value, - "get() cannot be used with reference types, you might want to use get_ref()"); - return JSONSerializer::from_json(*this); - } - - /*! - @brief get a value (explicit) - - Explicit type conversion between the JSON value and a compatible value. - The value is filled into the input parameter by calling the @ref json_serializer - `from_json()` method. - - The function is equivalent to executing - @code {.cpp} - ValueType v; - JSONSerializer::from_json(*this, v); - @endcode - - This overloads is chosen if: - - @a ValueType is not @ref basic_json, - - @ref json_serializer has a `from_json()` method of the form - `void from_json(const basic_json&, ValueType&)`, and - - @tparam ValueType the input parameter type. - - @return the input parameter, allowing chaining calls. - - @throw what @ref json_serializer `from_json()` method throws - - @liveexample{The example below shows several conversions from JSON values - to other types. There a few things to note: (1) Floating-point numbers can - be converted to integers\, (2) A JSON array can be converted to a standard - `std::vector`\, (3) A JSON object can be converted to C++ - associative containers such as `std::unordered_map`.,get_to} - - @since version 3.3.0 - */ - template < typename ValueType, - detail::enable_if_t < - !detail::is_basic_json::value&& - detail::has_from_json::value, - int > = 0 > - ValueType & get_to(ValueType& v) const noexcept(noexcept( - JSONSerializer::from_json(std::declval(), v))) - { - JSONSerializer::from_json(*this, v); - return v; - } - - // specialization to allow to call get_to with a basic_json value - // see https://github.com/nlohmann/json/issues/2175 - template::value, - int> = 0> - ValueType & get_to(ValueType& v) const - { - v = *this; - return v; - } - - template < - typename T, std::size_t N, - typename Array = T (&)[N], - detail::enable_if_t < - detail::has_from_json::value, int > = 0 > - Array get_to(T (&v)[N]) const - noexcept(noexcept(JSONSerializer::from_json( - std::declval(), v))) - { - JSONSerializer::from_json(*this, v); - return v; - } - - - /*! - @brief get a pointer value (implicit) - - Implicit pointer access to the internally stored JSON value. No copies are - made. - - @warning Writing data to the pointee of the result yields an undefined - state. - - @tparam PointerType pointer type; must be a pointer to @ref array_t, @ref - object_t, @ref string_t, @ref boolean_t, @ref number_integer_t, - @ref number_unsigned_t, or @ref number_float_t. Enforced by a static - assertion. - - @return pointer to the internally stored JSON value if the requested - pointer type @a PointerType fits to the JSON value; `nullptr` otherwise - - @complexity Constant. - - @liveexample{The example below shows how pointers to internal values of a - JSON value can be requested. Note that no type conversions are made and a - `nullptr` is returned if the value and the requested pointer type does not - match.,get_ptr} - - @since version 1.0.0 - */ - template::value, int>::type = 0> - auto get_ptr() noexcept -> decltype(std::declval().get_impl_ptr(std::declval())) - { - // delegate the call to get_impl_ptr<>() - return get_impl_ptr(static_cast(nullptr)); - } - - /*! - @brief get a pointer value (implicit) - @copydoc get_ptr() - */ - template < typename PointerType, typename std::enable_if < - std::is_pointer::value&& - std::is_const::type>::value, int >::type = 0 > - constexpr auto get_ptr() const noexcept -> decltype(std::declval().get_impl_ptr(std::declval())) - { - // delegate the call to get_impl_ptr<>() const - return get_impl_ptr(static_cast(nullptr)); - } - - /*! - @brief get a pointer value (explicit) - - Explicit pointer access to the internally stored JSON value. No copies are - made. - - @warning The pointer becomes invalid if the underlying JSON object - changes. - - @tparam PointerType pointer type; must be a pointer to @ref array_t, @ref - object_t, @ref string_t, @ref boolean_t, @ref number_integer_t, - @ref number_unsigned_t, or @ref number_float_t. - - @return pointer to the internally stored JSON value if the requested - pointer type @a PointerType fits to the JSON value; `nullptr` otherwise - - @complexity Constant. - - @liveexample{The example below shows how pointers to internal values of a - JSON value can be requested. Note that no type conversions are made and a - `nullptr` is returned if the value and the requested pointer type does not - match.,get__PointerType} - - @sa @ref get_ptr() for explicit pointer-member access - - @since version 1.0.0 - */ - template::value, int>::type = 0> - auto get() noexcept -> decltype(std::declval().template get_ptr()) - { - // delegate the call to get_ptr - return get_ptr(); - } - - /*! - @brief get a pointer value (explicit) - @copydoc get() - */ - template::value, int>::type = 0> - constexpr auto get() const noexcept -> decltype(std::declval().template get_ptr()) - { - // delegate the call to get_ptr - return get_ptr(); - } - - /*! - @brief get a reference value (implicit) - - Implicit reference access to the internally stored JSON value. No copies - are made. - - @warning Writing data to the referee of the result yields an undefined - state. - - @tparam ReferenceType reference type; must be a reference to @ref array_t, - @ref object_t, @ref string_t, @ref boolean_t, @ref number_integer_t, or - @ref number_float_t. Enforced by static assertion. - - @return reference to the internally stored JSON value if the requested - reference type @a ReferenceType fits to the JSON value; throws - type_error.303 otherwise - - @throw type_error.303 in case passed type @a ReferenceType is incompatible - with the stored JSON value; see example below - - @complexity Constant. - - @liveexample{The example shows several calls to `get_ref()`.,get_ref} - - @since version 1.1.0 - */ - template::value, int>::type = 0> - ReferenceType get_ref() - { - // delegate call to get_ref_impl - return get_ref_impl(*this); - } - - /*! - @brief get a reference value (implicit) - @copydoc get_ref() - */ - template < typename ReferenceType, typename std::enable_if < - std::is_reference::value&& - std::is_const::type>::value, int >::type = 0 > - ReferenceType get_ref() const - { - // delegate call to get_ref_impl - return get_ref_impl(*this); - } - - /*! - @brief get a value (implicit) - - Implicit type conversion between the JSON value and a compatible value. - The call is realized by calling @ref get() const. - - @tparam ValueType non-pointer type compatible to the JSON value, for - instance `int` for JSON integer numbers, `bool` for JSON booleans, or - `std::vector` types for JSON arrays. The character type of @ref string_t - as well as an initializer list of this type is excluded to avoid - ambiguities as these types implicitly convert to `std::string`. - - @return copy of the JSON value, converted to type @a ValueType - - @throw type_error.302 in case passed type @a ValueType is incompatible - to the JSON value type (e.g., the JSON value is of type boolean, but a - string is requested); see example below - - @complexity Linear in the size of the JSON value. - - @liveexample{The example below shows several conversions from JSON values - to other types. There a few things to note: (1) Floating-point numbers can - be converted to integers\, (2) A JSON array can be converted to a standard - `std::vector`\, (3) A JSON object can be converted to C++ - associative containers such as `std::unordered_map`.,operator__ValueType} - - @since version 1.0.0 - */ - template < typename ValueType, typename std::enable_if < - !std::is_pointer::value&& - !std::is_same>::value&& - !std::is_same::value&& - !detail::is_basic_json::value - && !std::is_same>::value -#if defined(JSON_HAS_CPP_17) && (defined(__GNUC__) || (defined(_MSC_VER) && _MSC_VER >= 1910 && _MSC_VER <= 1914)) - && !std::is_same::value -#endif - && detail::is_detected::value - , int >::type = 0 > - JSON_EXPLICIT operator ValueType() const - { - // delegate the call to get<>() const - return get(); - } - - /*! - @return reference to the binary value - - @throw type_error.302 if the value is not binary - - @sa @ref is_binary() to check if the value is binary - - @since version 3.8.0 - */ - binary_t& get_binary() - { - if (!is_binary()) - { - JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(type_name()), *this)); - } - - return *get_ptr(); - } - - /// @copydoc get_binary() - const binary_t& get_binary() const - { - if (!is_binary()) - { - JSON_THROW(type_error::create(302, "type must be binary, but is " + std::string(type_name()), *this)); - } - - return *get_ptr(); - } - - /// @} - - - //////////////////// - // element access // - //////////////////// - - /// @name element access - /// Access to the JSON value. - /// @{ - - /*! - @brief access specified array element with bounds checking - - Returns a reference to the element at specified location @a idx, with - bounds checking. - - @param[in] idx index of the element to access - - @return reference to the element at index @a idx - - @throw type_error.304 if the JSON value is not an array; in this case, - calling `at` with an index makes no sense. See example below. - @throw out_of_range.401 if the index @a idx is out of range of the array; - that is, `idx >= size()`. See example below. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes in the JSON value. - - @complexity Constant. - - @since version 1.0.0 - - @liveexample{The example below shows how array elements can be read and - written using `at()`. It also demonstrates the different exceptions that - can be thrown.,at__size_type} - */ - reference at(size_type idx) - { - // at only works for arrays - if (JSON_HEDLEY_LIKELY(is_array())) - { - JSON_TRY - { - return set_parent(m_value.array->at(idx)); - } - JSON_CATCH (std::out_of_range&) - { - // create better exception explanation - JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range", *this)); - } - } - else - { - JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name()), *this)); - } - } - - /*! - @brief access specified array element with bounds checking - - Returns a const reference to the element at specified location @a idx, - with bounds checking. - - @param[in] idx index of the element to access - - @return const reference to the element at index @a idx - - @throw type_error.304 if the JSON value is not an array; in this case, - calling `at` with an index makes no sense. See example below. - @throw out_of_range.401 if the index @a idx is out of range of the array; - that is, `idx >= size()`. See example below. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes in the JSON value. - - @complexity Constant. - - @since version 1.0.0 - - @liveexample{The example below shows how array elements can be read using - `at()`. It also demonstrates the different exceptions that can be thrown., - at__size_type_const} - */ - const_reference at(size_type idx) const - { - // at only works for arrays - if (JSON_HEDLEY_LIKELY(is_array())) - { - JSON_TRY - { - return m_value.array->at(idx); - } - JSON_CATCH (std::out_of_range&) - { - // create better exception explanation - JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range", *this)); - } - } - else - { - JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name()), *this)); - } - } - - /*! - @brief access specified object element with bounds checking - - Returns a reference to the element at with specified key @a key, with - bounds checking. - - @param[in] key key of the element to access - - @return reference to the element at key @a key - - @throw type_error.304 if the JSON value is not an object; in this case, - calling `at` with a key makes no sense. See example below. - @throw out_of_range.403 if the key @a key is is not stored in the object; - that is, `find(key) == end()`. See example below. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes in the JSON value. - - @complexity Logarithmic in the size of the container. - - @sa @ref operator[](const typename object_t::key_type&) for unchecked - access by reference - @sa @ref value() for access by value with a default value - - @since version 1.0.0 - - @liveexample{The example below shows how object elements can be read and - written using `at()`. It also demonstrates the different exceptions that - can be thrown.,at__object_t_key_type} - */ - reference at(const typename object_t::key_type& key) - { - // at only works for objects - if (JSON_HEDLEY_LIKELY(is_object())) - { - JSON_TRY - { - return set_parent(m_value.object->at(key)); - } - JSON_CATCH (std::out_of_range&) - { - // create better exception explanation - JSON_THROW(out_of_range::create(403, "key '" + key + "' not found", *this)); - } - } - else - { - JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name()), *this)); - } - } - - /*! - @brief access specified object element with bounds checking - - Returns a const reference to the element at with specified key @a key, - with bounds checking. - - @param[in] key key of the element to access - - @return const reference to the element at key @a key - - @throw type_error.304 if the JSON value is not an object; in this case, - calling `at` with a key makes no sense. See example below. - @throw out_of_range.403 if the key @a key is is not stored in the object; - that is, `find(key) == end()`. See example below. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes in the JSON value. - - @complexity Logarithmic in the size of the container. - - @sa @ref operator[](const typename object_t::key_type&) for unchecked - access by reference - @sa @ref value() for access by value with a default value - - @since version 1.0.0 - - @liveexample{The example below shows how object elements can be read using - `at()`. It also demonstrates the different exceptions that can be thrown., - at__object_t_key_type_const} - */ - const_reference at(const typename object_t::key_type& key) const - { - // at only works for objects - if (JSON_HEDLEY_LIKELY(is_object())) - { - JSON_TRY - { - return m_value.object->at(key); - } - JSON_CATCH (std::out_of_range&) - { - // create better exception explanation - JSON_THROW(out_of_range::create(403, "key '" + key + "' not found", *this)); - } - } - else - { - JSON_THROW(type_error::create(304, "cannot use at() with " + std::string(type_name()), *this)); - } - } - - /*! - @brief access specified array element - - Returns a reference to the element at specified location @a idx. - - @note If @a idx is beyond the range of the array (i.e., `idx >= size()`), - then the array is silently filled up with `null` values to make `idx` a - valid reference to the last stored element. - - @param[in] idx index of the element to access - - @return reference to the element at index @a idx - - @throw type_error.305 if the JSON value is not an array or null; in that - cases, using the [] operator with an index makes no sense. - - @complexity Constant if @a idx is in the range of the array. Otherwise - linear in `idx - size()`. - - @liveexample{The example below shows how array elements can be read and - written using `[]` operator. Note the addition of `null` - values.,operatorarray__size_type} - - @since version 1.0.0 - */ - reference operator[](size_type idx) - { - // implicitly convert null value to an empty array - if (is_null()) - { - m_type = value_t::array; - m_value.array = create(); - assert_invariant(); - } - - // operator[] only works for arrays - if (JSON_HEDLEY_LIKELY(is_array())) - { - // fill up array with null values if given idx is outside range - if (idx >= m_value.array->size()) - { -#if JSON_DIAGNOSTICS - // remember array size before resizing - const auto previous_size = m_value.array->size(); -#endif - m_value.array->resize(idx + 1); - -#if JSON_DIAGNOSTICS - // set parent for values added above - set_parents(begin() + static_cast(previous_size), static_cast(idx + 1 - previous_size)); -#endif - } - - return m_value.array->operator[](idx); - } - - JSON_THROW(type_error::create(305, "cannot use operator[] with a numeric argument with " + std::string(type_name()), *this)); - } - - /*! - @brief access specified array element - - Returns a const reference to the element at specified location @a idx. - - @param[in] idx index of the element to access - - @return const reference to the element at index @a idx - - @throw type_error.305 if the JSON value is not an array; in that case, - using the [] operator with an index makes no sense. - - @complexity Constant. - - @liveexample{The example below shows how array elements can be read using - the `[]` operator.,operatorarray__size_type_const} - - @since version 1.0.0 - */ - const_reference operator[](size_type idx) const - { - // const operator[] only works for arrays - if (JSON_HEDLEY_LIKELY(is_array())) - { - return m_value.array->operator[](idx); - } - - JSON_THROW(type_error::create(305, "cannot use operator[] with a numeric argument with " + std::string(type_name()), *this)); - } - - /*! - @brief access specified object element - - Returns a reference to the element at with specified key @a key. - - @note If @a key is not found in the object, then it is silently added to - the object and filled with a `null` value to make `key` a valid reference. - In case the value was `null` before, it is converted to an object. - - @param[in] key key of the element to access - - @return reference to the element at key @a key - - @throw type_error.305 if the JSON value is not an object or null; in that - cases, using the [] operator with a key makes no sense. - - @complexity Logarithmic in the size of the container. - - @liveexample{The example below shows how object elements can be read and - written using the `[]` operator.,operatorarray__key_type} - - @sa @ref at(const typename object_t::key_type&) for access by reference - with range checking - @sa @ref value() for access by value with a default value - - @since version 1.0.0 - */ - reference operator[](const typename object_t::key_type& key) - { - // implicitly convert null value to an empty object - if (is_null()) - { - m_type = value_t::object; - m_value.object = create(); - assert_invariant(); - } - - // operator[] only works for objects - if (JSON_HEDLEY_LIKELY(is_object())) - { - return set_parent(m_value.object->operator[](key)); - } - - JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()), *this)); - } - - /*! - @brief read-only access specified object element - - Returns a const reference to the element at with specified key @a key. No - bounds checking is performed. - - @warning If the element with key @a key does not exist, the behavior is - undefined. - - @param[in] key key of the element to access - - @return const reference to the element at key @a key - - @pre The element with key @a key must exist. **This precondition is - enforced with an assertion.** - - @throw type_error.305 if the JSON value is not an object; in that case, - using the [] operator with a key makes no sense. - - @complexity Logarithmic in the size of the container. - - @liveexample{The example below shows how object elements can be read using - the `[]` operator.,operatorarray__key_type_const} - - @sa @ref at(const typename object_t::key_type&) for access by reference - with range checking - @sa @ref value() for access by value with a default value - - @since version 1.0.0 - */ - const_reference operator[](const typename object_t::key_type& key) const - { - // const operator[] only works for objects - if (JSON_HEDLEY_LIKELY(is_object())) - { - JSON_ASSERT(m_value.object->find(key) != m_value.object->end()); - return m_value.object->find(key)->second; - } - - JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()), *this)); - } - - /*! - @brief access specified object element - - Returns a reference to the element at with specified key @a key. - - @note If @a key is not found in the object, then it is silently added to - the object and filled with a `null` value to make `key` a valid reference. - In case the value was `null` before, it is converted to an object. - - @param[in] key key of the element to access - - @return reference to the element at key @a key - - @throw type_error.305 if the JSON value is not an object or null; in that - cases, using the [] operator with a key makes no sense. - - @complexity Logarithmic in the size of the container. - - @liveexample{The example below shows how object elements can be read and - written using the `[]` operator.,operatorarray__key_type} - - @sa @ref at(const typename object_t::key_type&) for access by reference - with range checking - @sa @ref value() for access by value with a default value - - @since version 1.1.0 - */ - template - JSON_HEDLEY_NON_NULL(2) - reference operator[](T* key) - { - // implicitly convert null to object - if (is_null()) - { - m_type = value_t::object; - m_value = value_t::object; - assert_invariant(); - } - - // at only works for objects - if (JSON_HEDLEY_LIKELY(is_object())) - { - return set_parent(m_value.object->operator[](key)); - } - - JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()), *this)); - } - - /*! - @brief read-only access specified object element - - Returns a const reference to the element at with specified key @a key. No - bounds checking is performed. - - @warning If the element with key @a key does not exist, the behavior is - undefined. - - @param[in] key key of the element to access - - @return const reference to the element at key @a key - - @pre The element with key @a key must exist. **This precondition is - enforced with an assertion.** - - @throw type_error.305 if the JSON value is not an object; in that case, - using the [] operator with a key makes no sense. - - @complexity Logarithmic in the size of the container. - - @liveexample{The example below shows how object elements can be read using - the `[]` operator.,operatorarray__key_type_const} - - @sa @ref at(const typename object_t::key_type&) for access by reference - with range checking - @sa @ref value() for access by value with a default value - - @since version 1.1.0 - */ - template - JSON_HEDLEY_NON_NULL(2) - const_reference operator[](T* key) const - { - // at only works for objects - if (JSON_HEDLEY_LIKELY(is_object())) - { - JSON_ASSERT(m_value.object->find(key) != m_value.object->end()); - return m_value.object->find(key)->second; - } - - JSON_THROW(type_error::create(305, "cannot use operator[] with a string argument with " + std::string(type_name()), *this)); - } - - /*! - @brief access specified object element with default value - - Returns either a copy of an object's element at the specified key @a key - or a given default value if no element with key @a key exists. - - The function is basically equivalent to executing - @code {.cpp} - try { - return at(key); - } catch(out_of_range) { - return default_value; - } - @endcode - - @note Unlike @ref at(const typename object_t::key_type&), this function - does not throw if the given key @a key was not found. - - @note Unlike @ref operator[](const typename object_t::key_type& key), this - function does not implicitly add an element to the position defined by @a - key. This function is furthermore also applicable to const objects. - - @param[in] key key of the element to access - @param[in] default_value the value to return if @a key is not found - - @tparam ValueType type compatible to JSON values, for instance `int` for - JSON integer numbers, `bool` for JSON booleans, or `std::vector` types for - JSON arrays. Note the type of the expected value at @a key and the default - value @a default_value must be compatible. - - @return copy of the element at key @a key or @a default_value if @a key - is not found - - @throw type_error.302 if @a default_value does not match the type of the - value at @a key - @throw type_error.306 if the JSON value is not an object; in that case, - using `value()` with a key makes no sense. - - @complexity Logarithmic in the size of the container. - - @liveexample{The example below shows how object elements can be queried - with a default value.,basic_json__value} - - @sa @ref at(const typename object_t::key_type&) for access by reference - with range checking - @sa @ref operator[](const typename object_t::key_type&) for unchecked - access by reference - - @since version 1.0.0 - */ - // using std::is_convertible in a std::enable_if will fail when using explicit conversions - template < class ValueType, typename std::enable_if < - detail::is_getable::value - && !std::is_same::value, int >::type = 0 > - ValueType value(const typename object_t::key_type& key, const ValueType& default_value) const - { - // at only works for objects - if (JSON_HEDLEY_LIKELY(is_object())) - { - // if key is found, return value and given default value otherwise - const auto it = find(key); - if (it != end()) - { - return it->template get(); - } - - return default_value; - } - - JSON_THROW(type_error::create(306, "cannot use value() with " + std::string(type_name()), *this)); - } - - /*! - @brief overload for a default value of type const char* - @copydoc basic_json::value(const typename object_t::key_type&, const ValueType&) const - */ - string_t value(const typename object_t::key_type& key, const char* default_value) const - { - return value(key, string_t(default_value)); - } - - /*! - @brief access specified object element via JSON Pointer with default value - - Returns either a copy of an object's element at the specified key @a key - or a given default value if no element with key @a key exists. - - The function is basically equivalent to executing - @code {.cpp} - try { - return at(ptr); - } catch(out_of_range) { - return default_value; - } - @endcode - - @note Unlike @ref at(const json_pointer&), this function does not throw - if the given key @a key was not found. - - @param[in] ptr a JSON pointer to the element to access - @param[in] default_value the value to return if @a ptr found no value - - @tparam ValueType type compatible to JSON values, for instance `int` for - JSON integer numbers, `bool` for JSON booleans, or `std::vector` types for - JSON arrays. Note the type of the expected value at @a key and the default - value @a default_value must be compatible. - - @return copy of the element at key @a key or @a default_value if @a key - is not found - - @throw type_error.302 if @a default_value does not match the type of the - value at @a ptr - @throw type_error.306 if the JSON value is not an object; in that case, - using `value()` with a key makes no sense. - - @complexity Logarithmic in the size of the container. - - @liveexample{The example below shows how object elements can be queried - with a default value.,basic_json__value_ptr} - - @sa @ref operator[](const json_pointer&) for unchecked access by reference - - @since version 2.0.2 - */ - template::value, int>::type = 0> - ValueType value(const json_pointer& ptr, const ValueType& default_value) const - { - // at only works for objects - if (JSON_HEDLEY_LIKELY(is_object())) - { - // if pointer resolves a value, return it or use default value - JSON_TRY - { - return ptr.get_checked(this).template get(); - } - JSON_INTERNAL_CATCH (out_of_range&) - { - return default_value; - } - } - - JSON_THROW(type_error::create(306, "cannot use value() with " + std::string(type_name()), *this)); - } - - /*! - @brief overload for a default value of type const char* - @copydoc basic_json::value(const json_pointer&, ValueType) const - */ - JSON_HEDLEY_NON_NULL(3) - string_t value(const json_pointer& ptr, const char* default_value) const - { - return value(ptr, string_t(default_value)); - } - - /*! - @brief access the first element - - Returns a reference to the first element in the container. For a JSON - container `c`, the expression `c.front()` is equivalent to `*c.begin()`. - - @return In case of a structured type (array or object), a reference to the - first element is returned. In case of number, string, boolean, or binary - values, a reference to the value is returned. - - @complexity Constant. - - @pre The JSON value must not be `null` (would throw `std::out_of_range`) - or an empty array or object (undefined behavior, **guarded by - assertions**). - @post The JSON value remains unchanged. - - @throw invalid_iterator.214 when called on `null` value - - @liveexample{The following code shows an example for `front()`.,front} - - @sa @ref back() -- access the last element - - @since version 1.0.0 - */ - reference front() - { - return *begin(); - } - - /*! - @copydoc basic_json::front() - */ - const_reference front() const - { - return *cbegin(); - } - - /*! - @brief access the last element - - Returns a reference to the last element in the container. For a JSON - container `c`, the expression `c.back()` is equivalent to - @code {.cpp} - auto tmp = c.end(); - --tmp; - return *tmp; - @endcode - - @return In case of a structured type (array or object), a reference to the - last element is returned. In case of number, string, boolean, or binary - values, a reference to the value is returned. - - @complexity Constant. - - @pre The JSON value must not be `null` (would throw `std::out_of_range`) - or an empty array or object (undefined behavior, **guarded by - assertions**). - @post The JSON value remains unchanged. - - @throw invalid_iterator.214 when called on a `null` value. See example - below. - - @liveexample{The following code shows an example for `back()`.,back} - - @sa @ref front() -- access the first element - - @since version 1.0.0 - */ - reference back() - { - auto tmp = end(); - --tmp; - return *tmp; - } - - /*! - @copydoc basic_json::back() - */ - const_reference back() const - { - auto tmp = cend(); - --tmp; - return *tmp; - } - - /*! - @brief remove element given an iterator - - Removes the element specified by iterator @a pos. The iterator @a pos must - be valid and dereferenceable. Thus the `end()` iterator (which is valid, - but is not dereferenceable) cannot be used as a value for @a pos. - - If called on a primitive type other than `null`, the resulting JSON value - will be `null`. - - @param[in] pos iterator to the element to remove - @return Iterator following the last removed element. If the iterator @a - pos refers to the last element, the `end()` iterator is returned. - - @tparam IteratorType an @ref iterator or @ref const_iterator - - @post Invalidates iterators and references at or after the point of the - erase, including the `end()` iterator. - - @throw type_error.307 if called on a `null` value; example: `"cannot use - erase() with null"` - @throw invalid_iterator.202 if called on an iterator which does not belong - to the current JSON value; example: `"iterator does not fit current - value"` - @throw invalid_iterator.205 if called on a primitive type with invalid - iterator (i.e., any iterator which is not `begin()`); example: `"iterator - out of range"` - - @complexity The complexity depends on the type: - - objects: amortized constant - - arrays: linear in distance between @a pos and the end of the container - - strings and binary: linear in the length of the member - - other types: constant - - @liveexample{The example shows the result of `erase()` for different JSON - types.,erase__IteratorType} - - @sa @ref erase(IteratorType, IteratorType) -- removes the elements in - the given range - @sa @ref erase(const typename object_t::key_type&) -- removes the element - from an object at the given key - @sa @ref erase(const size_type) -- removes the element from an array at - the given index - - @since version 1.0.0 - */ - template < class IteratorType, typename std::enable_if < - std::is_same::value || - std::is_same::value, int >::type - = 0 > - IteratorType erase(IteratorType pos) - { - // make sure iterator fits the current value - if (JSON_HEDLEY_UNLIKELY(this != pos.m_object)) - { - JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", *this)); - } - - IteratorType result = end(); - - switch (m_type) - { - case value_t::boolean: - case value_t::number_float: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::string: - case value_t::binary: - { - if (JSON_HEDLEY_UNLIKELY(!pos.m_it.primitive_iterator.is_begin())) - { - JSON_THROW(invalid_iterator::create(205, "iterator out of range", *this)); - } - - if (is_string()) - { - AllocatorType alloc; - std::allocator_traits::destroy(alloc, m_value.string); - std::allocator_traits::deallocate(alloc, m_value.string, 1); - m_value.string = nullptr; - } - else if (is_binary()) - { - AllocatorType alloc; - std::allocator_traits::destroy(alloc, m_value.binary); - std::allocator_traits::deallocate(alloc, m_value.binary, 1); - m_value.binary = nullptr; - } - - m_type = value_t::null; - assert_invariant(); - break; - } - - case value_t::object: - { - result.m_it.object_iterator = m_value.object->erase(pos.m_it.object_iterator); - break; - } - - case value_t::array: - { - result.m_it.array_iterator = m_value.array->erase(pos.m_it.array_iterator); - break; - } - - default: - JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()), *this)); - } - - return result; - } - - /*! - @brief remove elements given an iterator range - - Removes the element specified by the range `[first; last)`. The iterator - @a first does not need to be dereferenceable if `first == last`: erasing - an empty range is a no-op. - - If called on a primitive type other than `null`, the resulting JSON value - will be `null`. - - @param[in] first iterator to the beginning of the range to remove - @param[in] last iterator past the end of the range to remove - @return Iterator following the last removed element. If the iterator @a - second refers to the last element, the `end()` iterator is returned. - - @tparam IteratorType an @ref iterator or @ref const_iterator - - @post Invalidates iterators and references at or after the point of the - erase, including the `end()` iterator. - - @throw type_error.307 if called on a `null` value; example: `"cannot use - erase() with null"` - @throw invalid_iterator.203 if called on iterators which does not belong - to the current JSON value; example: `"iterators do not fit current value"` - @throw invalid_iterator.204 if called on a primitive type with invalid - iterators (i.e., if `first != begin()` and `last != end()`); example: - `"iterators out of range"` - - @complexity The complexity depends on the type: - - objects: `log(size()) + std::distance(first, last)` - - arrays: linear in the distance between @a first and @a last, plus linear - in the distance between @a last and end of the container - - strings and binary: linear in the length of the member - - other types: constant - - @liveexample{The example shows the result of `erase()` for different JSON - types.,erase__IteratorType_IteratorType} - - @sa @ref erase(IteratorType) -- removes the element at a given position - @sa @ref erase(const typename object_t::key_type&) -- removes the element - from an object at the given key - @sa @ref erase(const size_type) -- removes the element from an array at - the given index - - @since version 1.0.0 - */ - template < class IteratorType, typename std::enable_if < - std::is_same::value || - std::is_same::value, int >::type - = 0 > - IteratorType erase(IteratorType first, IteratorType last) - { - // make sure iterator fits the current value - if (JSON_HEDLEY_UNLIKELY(this != first.m_object || this != last.m_object)) - { - JSON_THROW(invalid_iterator::create(203, "iterators do not fit current value", *this)); - } - - IteratorType result = end(); - - switch (m_type) - { - case value_t::boolean: - case value_t::number_float: - case value_t::number_integer: - case value_t::number_unsigned: - case value_t::string: - case value_t::binary: - { - if (JSON_HEDLEY_LIKELY(!first.m_it.primitive_iterator.is_begin() - || !last.m_it.primitive_iterator.is_end())) - { - JSON_THROW(invalid_iterator::create(204, "iterators out of range", *this)); - } - - if (is_string()) - { - AllocatorType alloc; - std::allocator_traits::destroy(alloc, m_value.string); - std::allocator_traits::deallocate(alloc, m_value.string, 1); - m_value.string = nullptr; - } - else if (is_binary()) - { - AllocatorType alloc; - std::allocator_traits::destroy(alloc, m_value.binary); - std::allocator_traits::deallocate(alloc, m_value.binary, 1); - m_value.binary = nullptr; - } - - m_type = value_t::null; - assert_invariant(); - break; - } - - case value_t::object: - { - result.m_it.object_iterator = m_value.object->erase(first.m_it.object_iterator, - last.m_it.object_iterator); - break; - } - - case value_t::array: - { - result.m_it.array_iterator = m_value.array->erase(first.m_it.array_iterator, - last.m_it.array_iterator); - break; - } - - default: - JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()), *this)); - } - - return result; - } - - /*! - @brief remove element from a JSON object given a key - - Removes elements from a JSON object with the key value @a key. - - @param[in] key value of the elements to remove - - @return Number of elements removed. If @a ObjectType is the default - `std::map` type, the return value will always be `0` (@a key was not - found) or `1` (@a key was found). - - @post References and iterators to the erased elements are invalidated. - Other references and iterators are not affected. - - @throw type_error.307 when called on a type other than JSON object; - example: `"cannot use erase() with null"` - - @complexity `log(size()) + count(key)` - - @liveexample{The example shows the effect of `erase()`.,erase__key_type} - - @sa @ref erase(IteratorType) -- removes the element at a given position - @sa @ref erase(IteratorType, IteratorType) -- removes the elements in - the given range - @sa @ref erase(const size_type) -- removes the element from an array at - the given index - - @since version 1.0.0 - */ - size_type erase(const typename object_t::key_type& key) - { - // this erase only works for objects - if (JSON_HEDLEY_LIKELY(is_object())) - { - return m_value.object->erase(key); - } - - JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()), *this)); - } - - /*! - @brief remove element from a JSON array given an index - - Removes element from a JSON array at the index @a idx. - - @param[in] idx index of the element to remove - - @throw type_error.307 when called on a type other than JSON object; - example: `"cannot use erase() with null"` - @throw out_of_range.401 when `idx >= size()`; example: `"array index 17 - is out of range"` - - @complexity Linear in distance between @a idx and the end of the container. - - @liveexample{The example shows the effect of `erase()`.,erase__size_type} - - @sa @ref erase(IteratorType) -- removes the element at a given position - @sa @ref erase(IteratorType, IteratorType) -- removes the elements in - the given range - @sa @ref erase(const typename object_t::key_type&) -- removes the element - from an object at the given key - - @since version 1.0.0 - */ - void erase(const size_type idx) - { - // this erase only works for arrays - if (JSON_HEDLEY_LIKELY(is_array())) - { - if (JSON_HEDLEY_UNLIKELY(idx >= size())) - { - JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range", *this)); - } - - m_value.array->erase(m_value.array->begin() + static_cast(idx)); - } - else - { - JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()), *this)); - } - } - - /// @} - - - //////////// - // lookup // - //////////// - - /// @name lookup - /// @{ - - /*! - @brief find an element in a JSON object - - Finds an element in a JSON object with key equivalent to @a key. If the - element is not found or the JSON value is not an object, end() is - returned. - - @note This method always returns @ref end() when executed on a JSON type - that is not an object. - - @param[in] key key value of the element to search for. - - @return Iterator to an element with key equivalent to @a key. If no such - element is found or the JSON value is not an object, past-the-end (see - @ref end()) iterator is returned. - - @complexity Logarithmic in the size of the JSON object. - - @liveexample{The example shows how `find()` is used.,find__key_type} - - @sa @ref contains(KeyT&&) const -- checks whether a key exists - - @since version 1.0.0 - */ - template - iterator find(KeyT&& key) - { - auto result = end(); - - if (is_object()) - { - result.m_it.object_iterator = m_value.object->find(std::forward(key)); - } - - return result; - } - - /*! - @brief find an element in a JSON object - @copydoc find(KeyT&&) - */ - template - const_iterator find(KeyT&& key) const - { - auto result = cend(); - - if (is_object()) - { - result.m_it.object_iterator = m_value.object->find(std::forward(key)); - } - - return result; - } - - /*! - @brief returns the number of occurrences of a key in a JSON object - - Returns the number of elements with key @a key. If ObjectType is the - default `std::map` type, the return value will always be `0` (@a key was - not found) or `1` (@a key was found). - - @note This method always returns `0` when executed on a JSON type that is - not an object. - - @param[in] key key value of the element to count - - @return Number of elements with key @a key. If the JSON value is not an - object, the return value will be `0`. - - @complexity Logarithmic in the size of the JSON object. - - @liveexample{The example shows how `count()` is used.,count} - - @since version 1.0.0 - */ - template - size_type count(KeyT&& key) const - { - // return 0 for all nonobject types - return is_object() ? m_value.object->count(std::forward(key)) : 0; - } - - /*! - @brief check the existence of an element in a JSON object - - Check whether an element exists in a JSON object with key equivalent to - @a key. If the element is not found or the JSON value is not an object, - false is returned. - - @note This method always returns false when executed on a JSON type - that is not an object. - - @param[in] key key value to check its existence. - - @return true if an element with specified @a key exists. If no such - element with such key is found or the JSON value is not an object, - false is returned. - - @complexity Logarithmic in the size of the JSON object. - - @liveexample{The following code shows an example for `contains()`.,contains} - - @sa @ref find(KeyT&&) -- returns an iterator to an object element - @sa @ref contains(const json_pointer&) const -- checks the existence for a JSON pointer - - @since version 3.6.0 - */ - template < typename KeyT, typename std::enable_if < - !std::is_same::type, json_pointer>::value, int >::type = 0 > - bool contains(KeyT && key) const - { - return is_object() && m_value.object->find(std::forward(key)) != m_value.object->end(); - } - - /*! - @brief check the existence of an element in a JSON object given a JSON pointer - - Check whether the given JSON pointer @a ptr can be resolved in the current - JSON value. - - @note This method can be executed on any JSON value type. - - @param[in] ptr JSON pointer to check its existence. - - @return true if the JSON pointer can be resolved to a stored value, false - otherwise. - - @post If `j.contains(ptr)` returns true, it is safe to call `j[ptr]`. - - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index was not a number - - @complexity Logarithmic in the size of the JSON object. - - @liveexample{The following code shows an example for `contains()`.,contains_json_pointer} - - @sa @ref contains(KeyT &&) const -- checks the existence of a key - - @since version 3.7.0 - */ - bool contains(const json_pointer& ptr) const - { - return ptr.contains(this); - } - - /// @} - - - /////////////// - // iterators // - /////////////// - - /// @name iterators - /// @{ - - /*! - @brief returns an iterator to the first element - - Returns an iterator to the first element. - - @image html range-begin-end.svg "Illustration from cppreference.com" - - @return iterator to the first element - - @complexity Constant. - - @requirement This function helps `basic_json` satisfying the - [Container](https://en.cppreference.com/w/cpp/named_req/Container) - requirements: - - The complexity is constant. - - @liveexample{The following code shows an example for `begin()`.,begin} - - @sa @ref cbegin() -- returns a const iterator to the beginning - @sa @ref end() -- returns an iterator to the end - @sa @ref cend() -- returns a const iterator to the end - - @since version 1.0.0 - */ - iterator begin() noexcept - { - iterator result(this); - result.set_begin(); - return result; - } - - /*! - @copydoc basic_json::cbegin() - */ - const_iterator begin() const noexcept - { - return cbegin(); - } - - /*! - @brief returns a const iterator to the first element - - Returns a const iterator to the first element. - - @image html range-begin-end.svg "Illustration from cppreference.com" - - @return const iterator to the first element - - @complexity Constant. - - @requirement This function helps `basic_json` satisfying the - [Container](https://en.cppreference.com/w/cpp/named_req/Container) - requirements: - - The complexity is constant. - - Has the semantics of `const_cast(*this).begin()`. - - @liveexample{The following code shows an example for `cbegin()`.,cbegin} - - @sa @ref begin() -- returns an iterator to the beginning - @sa @ref end() -- returns an iterator to the end - @sa @ref cend() -- returns a const iterator to the end - - @since version 1.0.0 - */ - const_iterator cbegin() const noexcept - { - const_iterator result(this); - result.set_begin(); - return result; - } - - /*! - @brief returns an iterator to one past the last element - - Returns an iterator to one past the last element. - - @image html range-begin-end.svg "Illustration from cppreference.com" - - @return iterator one past the last element - - @complexity Constant. - - @requirement This function helps `basic_json` satisfying the - [Container](https://en.cppreference.com/w/cpp/named_req/Container) - requirements: - - The complexity is constant. - - @liveexample{The following code shows an example for `end()`.,end} - - @sa @ref cend() -- returns a const iterator to the end - @sa @ref begin() -- returns an iterator to the beginning - @sa @ref cbegin() -- returns a const iterator to the beginning - - @since version 1.0.0 - */ - iterator end() noexcept - { - iterator result(this); - result.set_end(); - return result; - } - - /*! - @copydoc basic_json::cend() - */ - const_iterator end() const noexcept - { - return cend(); - } - - /*! - @brief returns a const iterator to one past the last element - - Returns a const iterator to one past the last element. - - @image html range-begin-end.svg "Illustration from cppreference.com" - - @return const iterator one past the last element - - @complexity Constant. - - @requirement This function helps `basic_json` satisfying the - [Container](https://en.cppreference.com/w/cpp/named_req/Container) - requirements: - - The complexity is constant. - - Has the semantics of `const_cast(*this).end()`. - - @liveexample{The following code shows an example for `cend()`.,cend} - - @sa @ref end() -- returns an iterator to the end - @sa @ref begin() -- returns an iterator to the beginning - @sa @ref cbegin() -- returns a const iterator to the beginning - - @since version 1.0.0 - */ - const_iterator cend() const noexcept - { - const_iterator result(this); - result.set_end(); - return result; - } - - /*! - @brief returns an iterator to the reverse-beginning - - Returns an iterator to the reverse-beginning; that is, the last element. - - @image html range-rbegin-rend.svg "Illustration from cppreference.com" - - @complexity Constant. - - @requirement This function helps `basic_json` satisfying the - [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer) - requirements: - - The complexity is constant. - - Has the semantics of `reverse_iterator(end())`. - - @liveexample{The following code shows an example for `rbegin()`.,rbegin} - - @sa @ref crbegin() -- returns a const reverse iterator to the beginning - @sa @ref rend() -- returns a reverse iterator to the end - @sa @ref crend() -- returns a const reverse iterator to the end - - @since version 1.0.0 - */ - reverse_iterator rbegin() noexcept - { - return reverse_iterator(end()); - } - - /*! - @copydoc basic_json::crbegin() - */ - const_reverse_iterator rbegin() const noexcept - { - return crbegin(); - } - - /*! - @brief returns an iterator to the reverse-end - - Returns an iterator to the reverse-end; that is, one before the first - element. - - @image html range-rbegin-rend.svg "Illustration from cppreference.com" - - @complexity Constant. - - @requirement This function helps `basic_json` satisfying the - [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer) - requirements: - - The complexity is constant. - - Has the semantics of `reverse_iterator(begin())`. - - @liveexample{The following code shows an example for `rend()`.,rend} - - @sa @ref crend() -- returns a const reverse iterator to the end - @sa @ref rbegin() -- returns a reverse iterator to the beginning - @sa @ref crbegin() -- returns a const reverse iterator to the beginning - - @since version 1.0.0 - */ - reverse_iterator rend() noexcept - { - return reverse_iterator(begin()); - } - - /*! - @copydoc basic_json::crend() - */ - const_reverse_iterator rend() const noexcept - { - return crend(); - } - - /*! - @brief returns a const reverse iterator to the last element - - Returns a const iterator to the reverse-beginning; that is, the last - element. - - @image html range-rbegin-rend.svg "Illustration from cppreference.com" - - @complexity Constant. - - @requirement This function helps `basic_json` satisfying the - [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer) - requirements: - - The complexity is constant. - - Has the semantics of `const_cast(*this).rbegin()`. - - @liveexample{The following code shows an example for `crbegin()`.,crbegin} - - @sa @ref rbegin() -- returns a reverse iterator to the beginning - @sa @ref rend() -- returns a reverse iterator to the end - @sa @ref crend() -- returns a const reverse iterator to the end - - @since version 1.0.0 - */ - const_reverse_iterator crbegin() const noexcept - { - return const_reverse_iterator(cend()); - } - - /*! - @brief returns a const reverse iterator to one before the first - - Returns a const reverse iterator to the reverse-end; that is, one before - the first element. - - @image html range-rbegin-rend.svg "Illustration from cppreference.com" - - @complexity Constant. - - @requirement This function helps `basic_json` satisfying the - [ReversibleContainer](https://en.cppreference.com/w/cpp/named_req/ReversibleContainer) - requirements: - - The complexity is constant. - - Has the semantics of `const_cast(*this).rend()`. - - @liveexample{The following code shows an example for `crend()`.,crend} - - @sa @ref rend() -- returns a reverse iterator to the end - @sa @ref rbegin() -- returns a reverse iterator to the beginning - @sa @ref crbegin() -- returns a const reverse iterator to the beginning - - @since version 1.0.0 - */ - const_reverse_iterator crend() const noexcept - { - return const_reverse_iterator(cbegin()); - } - - public: - /*! - @brief wrapper to access iterator member functions in range-based for - - This function allows to access @ref iterator::key() and @ref - iterator::value() during range-based for loops. In these loops, a - reference to the JSON values is returned, so there is no access to the - underlying iterator. - - For loop without iterator_wrapper: - - @code{cpp} - for (auto it = j_object.begin(); it != j_object.end(); ++it) - { - std::cout << "key: " << it.key() << ", value:" << it.value() << '\n'; - } - @endcode - - Range-based for loop without iterator proxy: - - @code{cpp} - for (auto it : j_object) - { - // "it" is of type json::reference and has no key() member - std::cout << "value: " << it << '\n'; - } - @endcode - - Range-based for loop with iterator proxy: - - @code{cpp} - for (auto it : json::iterator_wrapper(j_object)) - { - std::cout << "key: " << it.key() << ", value:" << it.value() << '\n'; - } - @endcode - - @note When iterating over an array, `key()` will return the index of the - element as string (see example). - - @param[in] ref reference to a JSON value - @return iteration proxy object wrapping @a ref with an interface to use in - range-based for loops - - @liveexample{The following code shows how the wrapper is used,iterator_wrapper} - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes in the JSON value. - - @complexity Constant. - - @note The name of this function is not yet final and may change in the - future. - - @deprecated This stream operator is deprecated and will be removed in - future 4.0.0 of the library. Please use @ref items() instead; - that is, replace `json::iterator_wrapper(j)` with `j.items()`. - */ - JSON_HEDLEY_DEPRECATED_FOR(3.1.0, items()) - static iteration_proxy iterator_wrapper(reference ref) noexcept - { - return ref.items(); - } - - /*! - @copydoc iterator_wrapper(reference) - */ - JSON_HEDLEY_DEPRECATED_FOR(3.1.0, items()) - static iteration_proxy iterator_wrapper(const_reference ref) noexcept - { - return ref.items(); - } - - /*! - @brief helper to access iterator member functions in range-based for - - This function allows to access @ref iterator::key() and @ref - iterator::value() during range-based for loops. In these loops, a - reference to the JSON values is returned, so there is no access to the - underlying iterator. - - For loop without `items()` function: - - @code{cpp} - for (auto it = j_object.begin(); it != j_object.end(); ++it) - { - std::cout << "key: " << it.key() << ", value:" << it.value() << '\n'; - } - @endcode - - Range-based for loop without `items()` function: - - @code{cpp} - for (auto it : j_object) - { - // "it" is of type json::reference and has no key() member - std::cout << "value: " << it << '\n'; - } - @endcode - - Range-based for loop with `items()` function: - - @code{cpp} - for (auto& el : j_object.items()) - { - std::cout << "key: " << el.key() << ", value:" << el.value() << '\n'; - } - @endcode - - The `items()` function also allows to use - [structured bindings](https://en.cppreference.com/w/cpp/language/structured_binding) - (C++17): - - @code{cpp} - for (auto& [key, val] : j_object.items()) - { - std::cout << "key: " << key << ", value:" << val << '\n'; - } - @endcode - - @note When iterating over an array, `key()` will return the index of the - element as string (see example). For primitive types (e.g., numbers), - `key()` returns an empty string. - - @warning Using `items()` on temporary objects is dangerous. Make sure the - object's lifetime exeeds the iteration. See - for more - information. - - @return iteration proxy object wrapping @a ref with an interface to use in - range-based for loops - - @liveexample{The following code shows how the function is used.,items} - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes in the JSON value. - - @complexity Constant. - - @since version 3.1.0, structured bindings support since 3.5.0. - */ - iteration_proxy items() noexcept - { - return iteration_proxy(*this); - } - - /*! - @copydoc items() - */ - iteration_proxy items() const noexcept - { - return iteration_proxy(*this); - } - - /// @} - - - ////////////// - // capacity // - ////////////// - - /// @name capacity - /// @{ - - /*! - @brief checks whether the container is empty. - - Checks if a JSON value has no elements (i.e. whether its @ref size is `0`). - - @return The return value depends on the different types and is - defined as follows: - Value type | return value - ----------- | ------------- - null | `true` - boolean | `false` - string | `false` - number | `false` - binary | `false` - object | result of function `object_t::empty()` - array | result of function `array_t::empty()` - - @liveexample{The following code uses `empty()` to check if a JSON - object contains any elements.,empty} - - @complexity Constant, as long as @ref array_t and @ref object_t satisfy - the Container concept; that is, their `empty()` functions have constant - complexity. - - @iterators No changes. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @note This function does not return whether a string stored as JSON value - is empty - it returns whether the JSON container itself is empty which is - false in the case of a string. - - @requirement This function helps `basic_json` satisfying the - [Container](https://en.cppreference.com/w/cpp/named_req/Container) - requirements: - - The complexity is constant. - - Has the semantics of `begin() == end()`. - - @sa @ref size() -- returns the number of elements - - @since version 1.0.0 - */ - bool empty() const noexcept - { - switch (m_type) - { - case value_t::null: - { - // null values are empty - return true; - } - - case value_t::array: - { - // delegate call to array_t::empty() - return m_value.array->empty(); - } - - case value_t::object: - { - // delegate call to object_t::empty() - return m_value.object->empty(); - } - - default: - { - // all other types are nonempty - return false; - } - } - } - - /*! - @brief returns the number of elements - - Returns the number of elements in a JSON value. - - @return The return value depends on the different types and is - defined as follows: - Value type | return value - ----------- | ------------- - null | `0` - boolean | `1` - string | `1` - number | `1` - binary | `1` - object | result of function object_t::size() - array | result of function array_t::size() - - @liveexample{The following code calls `size()` on the different value - types.,size} - - @complexity Constant, as long as @ref array_t and @ref object_t satisfy - the Container concept; that is, their size() functions have constant - complexity. - - @iterators No changes. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @note This function does not return the length of a string stored as JSON - value - it returns the number of elements in the JSON value which is 1 in - the case of a string. - - @requirement This function helps `basic_json` satisfying the - [Container](https://en.cppreference.com/w/cpp/named_req/Container) - requirements: - - The complexity is constant. - - Has the semantics of `std::distance(begin(), end())`. - - @sa @ref empty() -- checks whether the container is empty - @sa @ref max_size() -- returns the maximal number of elements - - @since version 1.0.0 - */ - size_type size() const noexcept - { - switch (m_type) - { - case value_t::null: - { - // null values are empty - return 0; - } - - case value_t::array: - { - // delegate call to array_t::size() - return m_value.array->size(); - } - - case value_t::object: - { - // delegate call to object_t::size() - return m_value.object->size(); - } - - default: - { - // all other types have size 1 - return 1; - } - } - } - - /*! - @brief returns the maximum possible number of elements - - Returns the maximum number of elements a JSON value is able to hold due to - system or library implementation limitations, i.e. `std::distance(begin(), - end())` for the JSON value. - - @return The return value depends on the different types and is - defined as follows: - Value type | return value - ----------- | ------------- - null | `0` (same as `size()`) - boolean | `1` (same as `size()`) - string | `1` (same as `size()`) - number | `1` (same as `size()`) - binary | `1` (same as `size()`) - object | result of function `object_t::max_size()` - array | result of function `array_t::max_size()` - - @liveexample{The following code calls `max_size()` on the different value - types. Note the output is implementation specific.,max_size} - - @complexity Constant, as long as @ref array_t and @ref object_t satisfy - the Container concept; that is, their `max_size()` functions have constant - complexity. - - @iterators No changes. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @requirement This function helps `basic_json` satisfying the - [Container](https://en.cppreference.com/w/cpp/named_req/Container) - requirements: - - The complexity is constant. - - Has the semantics of returning `b.size()` where `b` is the largest - possible JSON value. - - @sa @ref size() -- returns the number of elements - - @since version 1.0.0 - */ - size_type max_size() const noexcept - { - switch (m_type) - { - case value_t::array: - { - // delegate call to array_t::max_size() - return m_value.array->max_size(); - } - - case value_t::object: - { - // delegate call to object_t::max_size() - return m_value.object->max_size(); - } - - default: - { - // all other types have max_size() == size() - return size(); - } - } - } - - /// @} - - - /////////////// - // modifiers // - /////////////// - - /// @name modifiers - /// @{ - - /*! - @brief clears the contents - - Clears the content of a JSON value and resets it to the default value as - if @ref basic_json(value_t) would have been called with the current value - type from @ref type(): - - Value type | initial value - ----------- | ------------- - null | `null` - boolean | `false` - string | `""` - number | `0` - binary | An empty byte vector - object | `{}` - array | `[]` - - @post Has the same effect as calling - @code {.cpp} - *this = basic_json(type()); - @endcode - - @liveexample{The example below shows the effect of `clear()` to different - JSON types.,clear} - - @complexity Linear in the size of the JSON value. - - @iterators All iterators, pointers and references related to this container - are invalidated. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @sa @ref basic_json(value_t) -- constructor that creates an object with the - same value than calling `clear()` - - @since version 1.0.0 - */ - void clear() noexcept - { - switch (m_type) - { - case value_t::number_integer: - { - m_value.number_integer = 0; - break; - } - - case value_t::number_unsigned: - { - m_value.number_unsigned = 0; - break; - } - - case value_t::number_float: - { - m_value.number_float = 0.0; - break; - } - - case value_t::boolean: - { - m_value.boolean = false; - break; - } - - case value_t::string: - { - m_value.string->clear(); - break; - } - - case value_t::binary: - { - m_value.binary->clear(); - break; - } - - case value_t::array: - { - m_value.array->clear(); - break; - } - - case value_t::object: - { - m_value.object->clear(); - break; - } - - default: - break; - } - } - - /*! - @brief add an object to an array - - Appends the given element @a val to the end of the JSON value. If the - function is called on a JSON null value, an empty array is created before - appending @a val. - - @param[in] val the value to add to the JSON array - - @throw type_error.308 when called on a type other than JSON array or - null; example: `"cannot use push_back() with number"` - - @complexity Amortized constant. - - @liveexample{The example shows how `push_back()` and `+=` can be used to - add elements to a JSON array. Note how the `null` value was silently - converted to a JSON array.,push_back} - - @since version 1.0.0 - */ - void push_back(basic_json&& val) - { - // push_back only works for null objects or arrays - if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_array()))) - { - JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()), *this)); - } - - // transform null object into an array - if (is_null()) - { - m_type = value_t::array; - m_value = value_t::array; - assert_invariant(); - } - - // add element to array (move semantics) - m_value.array->push_back(std::move(val)); - set_parent(m_value.array->back()); - // if val is moved from, basic_json move constructor marks it null so we do not call the destructor - } - - /*! - @brief add an object to an array - @copydoc push_back(basic_json&&) - */ - reference operator+=(basic_json&& val) - { - push_back(std::move(val)); - return *this; - } - - /*! - @brief add an object to an array - @copydoc push_back(basic_json&&) - */ - void push_back(const basic_json& val) - { - // push_back only works for null objects or arrays - if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_array()))) - { - JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()), *this)); - } - - // transform null object into an array - if (is_null()) - { - m_type = value_t::array; - m_value = value_t::array; - assert_invariant(); - } - - // add element to array - m_value.array->push_back(val); - set_parent(m_value.array->back()); - } - - /*! - @brief add an object to an array - @copydoc push_back(basic_json&&) - */ - reference operator+=(const basic_json& val) - { - push_back(val); - return *this; - } - - /*! - @brief add an object to an object - - Inserts the given element @a val to the JSON object. If the function is - called on a JSON null value, an empty object is created before inserting - @a val. - - @param[in] val the value to add to the JSON object - - @throw type_error.308 when called on a type other than JSON object or - null; example: `"cannot use push_back() with number"` - - @complexity Logarithmic in the size of the container, O(log(`size()`)). - - @liveexample{The example shows how `push_back()` and `+=` can be used to - add elements to a JSON object. Note how the `null` value was silently - converted to a JSON object.,push_back__object_t__value} - - @since version 1.0.0 - */ - void push_back(const typename object_t::value_type& val) - { - // push_back only works for null objects or objects - if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_object()))) - { - JSON_THROW(type_error::create(308, "cannot use push_back() with " + std::string(type_name()), *this)); - } - - // transform null object into an object - if (is_null()) - { - m_type = value_t::object; - m_value = value_t::object; - assert_invariant(); - } - - // add element to object - auto res = m_value.object->insert(val); - set_parent(res.first->second); - } - - /*! - @brief add an object to an object - @copydoc push_back(const typename object_t::value_type&) - */ - reference operator+=(const typename object_t::value_type& val) - { - push_back(val); - return *this; - } - - /*! - @brief add an object to an object - - This function allows to use `push_back` with an initializer list. In case - - 1. the current value is an object, - 2. the initializer list @a init contains only two elements, and - 3. the first element of @a init is a string, - - @a init is converted into an object element and added using - @ref push_back(const typename object_t::value_type&). Otherwise, @a init - is converted to a JSON value and added using @ref push_back(basic_json&&). - - @param[in] init an initializer list - - @complexity Linear in the size of the initializer list @a init. - - @note This function is required to resolve an ambiguous overload error, - because pairs like `{"key", "value"}` can be both interpreted as - `object_t::value_type` or `std::initializer_list`, see - https://github.com/nlohmann/json/issues/235 for more information. - - @liveexample{The example shows how initializer lists are treated as - objects when possible.,push_back__initializer_list} - */ - void push_back(initializer_list_t init) - { - if (is_object() && init.size() == 2 && (*init.begin())->is_string()) - { - basic_json&& key = init.begin()->moved_or_copied(); - push_back(typename object_t::value_type( - std::move(key.get_ref()), (init.begin() + 1)->moved_or_copied())); - } - else - { - push_back(basic_json(init)); - } - } - - /*! - @brief add an object to an object - @copydoc push_back(initializer_list_t) - */ - reference operator+=(initializer_list_t init) - { - push_back(init); - return *this; - } - - /*! - @brief add an object to an array - - Creates a JSON value from the passed parameters @a args to the end of the - JSON value. If the function is called on a JSON null value, an empty array - is created before appending the value created from @a args. - - @param[in] args arguments to forward to a constructor of @ref basic_json - @tparam Args compatible types to create a @ref basic_json object - - @return reference to the inserted element - - @throw type_error.311 when called on a type other than JSON array or - null; example: `"cannot use emplace_back() with number"` - - @complexity Amortized constant. - - @liveexample{The example shows how `push_back()` can be used to add - elements to a JSON array. Note how the `null` value was silently converted - to a JSON array.,emplace_back} - - @since version 2.0.8, returns reference since 3.7.0 - */ - template - reference emplace_back(Args&& ... args) - { - // emplace_back only works for null objects or arrays - if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_array()))) - { - JSON_THROW(type_error::create(311, "cannot use emplace_back() with " + std::string(type_name()), *this)); - } - - // transform null object into an array - if (is_null()) - { - m_type = value_t::array; - m_value = value_t::array; - assert_invariant(); - } - - // add element to array (perfect forwarding) -#ifdef JSON_HAS_CPP_17 - return set_parent(m_value.array->emplace_back(std::forward(args)...)); -#else - m_value.array->emplace_back(std::forward(args)...); - return set_parent(m_value.array->back()); -#endif - } - - /*! - @brief add an object to an object if key does not exist - - Inserts a new element into a JSON object constructed in-place with the - given @a args if there is no element with the key in the container. If the - function is called on a JSON null value, an empty object is created before - appending the value created from @a args. - - @param[in] args arguments to forward to a constructor of @ref basic_json - @tparam Args compatible types to create a @ref basic_json object - - @return a pair consisting of an iterator to the inserted element, or the - already-existing element if no insertion happened, and a bool - denoting whether the insertion took place. - - @throw type_error.311 when called on a type other than JSON object or - null; example: `"cannot use emplace() with number"` - - @complexity Logarithmic in the size of the container, O(log(`size()`)). - - @liveexample{The example shows how `emplace()` can be used to add elements - to a JSON object. Note how the `null` value was silently converted to a - JSON object. Further note how no value is added if there was already one - value stored with the same key.,emplace} - - @since version 2.0.8 - */ - template - std::pair emplace(Args&& ... args) - { - // emplace only works for null objects or arrays - if (JSON_HEDLEY_UNLIKELY(!(is_null() || is_object()))) - { - JSON_THROW(type_error::create(311, "cannot use emplace() with " + std::string(type_name()), *this)); - } - - // transform null object into an object - if (is_null()) - { - m_type = value_t::object; - m_value = value_t::object; - assert_invariant(); - } - - // add element to array (perfect forwarding) - auto res = m_value.object->emplace(std::forward(args)...); - set_parent(res.first->second); - - // create result iterator and set iterator to the result of emplace - auto it = begin(); - it.m_it.object_iterator = res.first; - - // return pair of iterator and boolean - return {it, res.second}; - } - - /// Helper for insertion of an iterator - /// @note: This uses std::distance to support GCC 4.8, - /// see https://github.com/nlohmann/json/pull/1257 - template - iterator insert_iterator(const_iterator pos, Args&& ... args) - { - iterator result(this); - JSON_ASSERT(m_value.array != nullptr); - - auto insert_pos = std::distance(m_value.array->begin(), pos.m_it.array_iterator); - m_value.array->insert(pos.m_it.array_iterator, std::forward(args)...); - result.m_it.array_iterator = m_value.array->begin() + insert_pos; - - // This could have been written as: - // result.m_it.array_iterator = m_value.array->insert(pos.m_it.array_iterator, cnt, val); - // but the return value of insert is missing in GCC 4.8, so it is written this way instead. - - return result; - } - - /*! - @brief inserts element - - Inserts element @a val before iterator @a pos. - - @param[in] pos iterator before which the content will be inserted; may be - the end() iterator - @param[in] val element to insert - @return iterator pointing to the inserted @a val. - - @throw type_error.309 if called on JSON values other than arrays; - example: `"cannot use insert() with string"` - @throw invalid_iterator.202 if @a pos is not an iterator of *this; - example: `"iterator does not fit current value"` - - @complexity Constant plus linear in the distance between @a pos and end of - the container. - - @liveexample{The example shows how `insert()` is used.,insert} - - @since version 1.0.0 - */ - iterator insert(const_iterator pos, const basic_json& val) - { - // insert only works for arrays - if (JSON_HEDLEY_LIKELY(is_array())) - { - // check if iterator pos fits to this JSON value - if (JSON_HEDLEY_UNLIKELY(pos.m_object != this)) - { - JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", *this)); - } - - // insert to array and return iterator - return set_parents(insert_iterator(pos, val), static_cast(1)); - } - - JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()), *this)); - } - - /*! - @brief inserts element - @copydoc insert(const_iterator, const basic_json&) - */ - iterator insert(const_iterator pos, basic_json&& val) - { - return insert(pos, val); - } - - /*! - @brief inserts elements - - Inserts @a cnt copies of @a val before iterator @a pos. - - @param[in] pos iterator before which the content will be inserted; may be - the end() iterator - @param[in] cnt number of copies of @a val to insert - @param[in] val element to insert - @return iterator pointing to the first element inserted, or @a pos if - `cnt==0` - - @throw type_error.309 if called on JSON values other than arrays; example: - `"cannot use insert() with string"` - @throw invalid_iterator.202 if @a pos is not an iterator of *this; - example: `"iterator does not fit current value"` - - @complexity Linear in @a cnt plus linear in the distance between @a pos - and end of the container. - - @liveexample{The example shows how `insert()` is used.,insert__count} - - @since version 1.0.0 - */ - iterator insert(const_iterator pos, size_type cnt, const basic_json& val) - { - // insert only works for arrays - if (JSON_HEDLEY_LIKELY(is_array())) - { - // check if iterator pos fits to this JSON value - if (JSON_HEDLEY_UNLIKELY(pos.m_object != this)) - { - JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", *this)); - } - - // insert to array and return iterator - return set_parents(insert_iterator(pos, cnt, val), static_cast(cnt)); - } - - JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()), *this)); - } - - /*! - @brief inserts elements - - Inserts elements from range `[first, last)` before iterator @a pos. - - @param[in] pos iterator before which the content will be inserted; may be - the end() iterator - @param[in] first begin of the range of elements to insert - @param[in] last end of the range of elements to insert - - @throw type_error.309 if called on JSON values other than arrays; example: - `"cannot use insert() with string"` - @throw invalid_iterator.202 if @a pos is not an iterator of *this; - example: `"iterator does not fit current value"` - @throw invalid_iterator.210 if @a first and @a last do not belong to the - same JSON value; example: `"iterators do not fit"` - @throw invalid_iterator.211 if @a first or @a last are iterators into - container for which insert is called; example: `"passed iterators may not - belong to container"` - - @return iterator pointing to the first element inserted, or @a pos if - `first==last` - - @complexity Linear in `std::distance(first, last)` plus linear in the - distance between @a pos and end of the container. - - @liveexample{The example shows how `insert()` is used.,insert__range} - - @since version 1.0.0 - */ - iterator insert(const_iterator pos, const_iterator first, const_iterator last) - { - // insert only works for arrays - if (JSON_HEDLEY_UNLIKELY(!is_array())) - { - JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()), *this)); - } - - // check if iterator pos fits to this JSON value - if (JSON_HEDLEY_UNLIKELY(pos.m_object != this)) - { - JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", *this)); - } - - // check if range iterators belong to the same JSON object - if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) - { - JSON_THROW(invalid_iterator::create(210, "iterators do not fit", *this)); - } - - if (JSON_HEDLEY_UNLIKELY(first.m_object == this)) - { - JSON_THROW(invalid_iterator::create(211, "passed iterators may not belong to container", *this)); - } - - // insert to array and return iterator - return set_parents(insert_iterator(pos, first.m_it.array_iterator, last.m_it.array_iterator), std::distance(first, last)); - } - - /*! - @brief inserts elements - - Inserts elements from initializer list @a ilist before iterator @a pos. - - @param[in] pos iterator before which the content will be inserted; may be - the end() iterator - @param[in] ilist initializer list to insert the values from - - @throw type_error.309 if called on JSON values other than arrays; example: - `"cannot use insert() with string"` - @throw invalid_iterator.202 if @a pos is not an iterator of *this; - example: `"iterator does not fit current value"` - - @return iterator pointing to the first element inserted, or @a pos if - `ilist` is empty - - @complexity Linear in `ilist.size()` plus linear in the distance between - @a pos and end of the container. - - @liveexample{The example shows how `insert()` is used.,insert__ilist} - - @since version 1.0.0 - */ - iterator insert(const_iterator pos, initializer_list_t ilist) - { - // insert only works for arrays - if (JSON_HEDLEY_UNLIKELY(!is_array())) - { - JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()), *this)); - } - - // check if iterator pos fits to this JSON value - if (JSON_HEDLEY_UNLIKELY(pos.m_object != this)) - { - JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", *this)); - } - - // insert to array and return iterator - return set_parents(insert_iterator(pos, ilist.begin(), ilist.end()), static_cast(ilist.size())); - } - - /*! - @brief inserts elements - - Inserts elements from range `[first, last)`. - - @param[in] first begin of the range of elements to insert - @param[in] last end of the range of elements to insert - - @throw type_error.309 if called on JSON values other than objects; example: - `"cannot use insert() with string"` - @throw invalid_iterator.202 if iterator @a first or @a last does does not - point to an object; example: `"iterators first and last must point to - objects"` - @throw invalid_iterator.210 if @a first and @a last do not belong to the - same JSON value; example: `"iterators do not fit"` - - @complexity Logarithmic: `O(N*log(size() + N))`, where `N` is the number - of elements to insert. - - @liveexample{The example shows how `insert()` is used.,insert__range_object} - - @since version 3.0.0 - */ - void insert(const_iterator first, const_iterator last) - { - // insert only works for objects - if (JSON_HEDLEY_UNLIKELY(!is_object())) - { - JSON_THROW(type_error::create(309, "cannot use insert() with " + std::string(type_name()), *this)); - } - - // check if range iterators belong to the same JSON object - if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) - { - JSON_THROW(invalid_iterator::create(210, "iterators do not fit", *this)); - } - - // passed iterators must belong to objects - if (JSON_HEDLEY_UNLIKELY(!first.m_object->is_object())) - { - JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects", *this)); - } - - m_value.object->insert(first.m_it.object_iterator, last.m_it.object_iterator); - } - - /*! - @brief updates a JSON object from another object, overwriting existing keys - - Inserts all values from JSON object @a j and overwrites existing keys. - - @param[in] j JSON object to read values from - - @throw type_error.312 if called on JSON values other than objects; example: - `"cannot use update() with string"` - - @complexity O(N*log(size() + N)), where N is the number of elements to - insert. - - @liveexample{The example shows how `update()` is used.,update} - - @sa https://docs.python.org/3.6/library/stdtypes.html#dict.update - - @since version 3.0.0 - */ - void update(const_reference j) - { - // implicitly convert null value to an empty object - if (is_null()) - { - m_type = value_t::object; - m_value.object = create(); - assert_invariant(); - } - - if (JSON_HEDLEY_UNLIKELY(!is_object())) - { - JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name()), *this)); - } - if (JSON_HEDLEY_UNLIKELY(!j.is_object())) - { - JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(j.type_name()), *this)); - } - - for (auto it = j.cbegin(); it != j.cend(); ++it) - { - m_value.object->operator[](it.key()) = it.value(); - } - } - - /*! - @brief updates a JSON object from another object, overwriting existing keys - - Inserts all values from from range `[first, last)` and overwrites existing - keys. - - @param[in] first begin of the range of elements to insert - @param[in] last end of the range of elements to insert - - @throw type_error.312 if called on JSON values other than objects; example: - `"cannot use update() with string"` - @throw invalid_iterator.202 if iterator @a first or @a last does does not - point to an object; example: `"iterators first and last must point to - objects"` - @throw invalid_iterator.210 if @a first and @a last do not belong to the - same JSON value; example: `"iterators do not fit"` - - @complexity O(N*log(size() + N)), where N is the number of elements to - insert. - - @liveexample{The example shows how `update()` is used__range.,update} - - @sa https://docs.python.org/3.6/library/stdtypes.html#dict.update - - @since version 3.0.0 - */ - void update(const_iterator first, const_iterator last) - { - // implicitly convert null value to an empty object - if (is_null()) - { - m_type = value_t::object; - m_value.object = create(); - assert_invariant(); - } - - if (JSON_HEDLEY_UNLIKELY(!is_object())) - { - JSON_THROW(type_error::create(312, "cannot use update() with " + std::string(type_name()), *this)); - } - - // check if range iterators belong to the same JSON object - if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object)) - { - JSON_THROW(invalid_iterator::create(210, "iterators do not fit", *this)); - } - - // passed iterators must belong to objects - if (JSON_HEDLEY_UNLIKELY(!first.m_object->is_object() - || !last.m_object->is_object())) - { - JSON_THROW(invalid_iterator::create(202, "iterators first and last must point to objects", *this)); - } - - for (auto it = first; it != last; ++it) - { - m_value.object->operator[](it.key()) = it.value(); - } - } - - /*! - @brief exchanges the values - - Exchanges the contents of the JSON value with those of @a other. Does not - invoke any move, copy, or swap operations on individual elements. All - iterators and references remain valid. The past-the-end iterator is - invalidated. - - @param[in,out] other JSON value to exchange the contents with - - @complexity Constant. - - @liveexample{The example below shows how JSON values can be swapped with - `swap()`.,swap__reference} - - @since version 1.0.0 - */ - void swap(reference other) noexcept ( - std::is_nothrow_move_constructible::value&& - std::is_nothrow_move_assignable::value&& - std::is_nothrow_move_constructible::value&& - std::is_nothrow_move_assignable::value - ) - { - std::swap(m_type, other.m_type); - std::swap(m_value, other.m_value); - - set_parents(); - other.set_parents(); - assert_invariant(); - } - - /*! - @brief exchanges the values - - Exchanges the contents of the JSON value from @a left with those of @a right. Does not - invoke any move, copy, or swap operations on individual elements. All - iterators and references remain valid. The past-the-end iterator is - invalidated. implemented as a friend function callable via ADL. - - @param[in,out] left JSON value to exchange the contents with - @param[in,out] right JSON value to exchange the contents with - - @complexity Constant. - - @liveexample{The example below shows how JSON values can be swapped with - `swap()`.,swap__reference} - - @since version 1.0.0 - */ - friend void swap(reference left, reference right) noexcept ( - std::is_nothrow_move_constructible::value&& - std::is_nothrow_move_assignable::value&& - std::is_nothrow_move_constructible::value&& - std::is_nothrow_move_assignable::value - ) - { - left.swap(right); - } - - /*! - @brief exchanges the values - - Exchanges the contents of a JSON array with those of @a other. Does not - invoke any move, copy, or swap operations on individual elements. All - iterators and references remain valid. The past-the-end iterator is - invalidated. - - @param[in,out] other array to exchange the contents with - - @throw type_error.310 when JSON value is not an array; example: `"cannot - use swap() with string"` - - @complexity Constant. - - @liveexample{The example below shows how arrays can be swapped with - `swap()`.,swap__array_t} - - @since version 1.0.0 - */ - void swap(array_t& other) - { - // swap only works for arrays - if (JSON_HEDLEY_LIKELY(is_array())) - { - std::swap(*(m_value.array), other); - } - else - { - JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()), *this)); - } - } - - /*! - @brief exchanges the values - - Exchanges the contents of a JSON object with those of @a other. Does not - invoke any move, copy, or swap operations on individual elements. All - iterators and references remain valid. The past-the-end iterator is - invalidated. - - @param[in,out] other object to exchange the contents with - - @throw type_error.310 when JSON value is not an object; example: - `"cannot use swap() with string"` - - @complexity Constant. - - @liveexample{The example below shows how objects can be swapped with - `swap()`.,swap__object_t} - - @since version 1.0.0 - */ - void swap(object_t& other) - { - // swap only works for objects - if (JSON_HEDLEY_LIKELY(is_object())) - { - std::swap(*(m_value.object), other); - } - else - { - JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()), *this)); - } - } - - /*! - @brief exchanges the values - - Exchanges the contents of a JSON string with those of @a other. Does not - invoke any move, copy, or swap operations on individual elements. All - iterators and references remain valid. The past-the-end iterator is - invalidated. - - @param[in,out] other string to exchange the contents with - - @throw type_error.310 when JSON value is not a string; example: `"cannot - use swap() with boolean"` - - @complexity Constant. - - @liveexample{The example below shows how strings can be swapped with - `swap()`.,swap__string_t} - - @since version 1.0.0 - */ - void swap(string_t& other) - { - // swap only works for strings - if (JSON_HEDLEY_LIKELY(is_string())) - { - std::swap(*(m_value.string), other); - } - else - { - JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()), *this)); - } - } - - /*! - @brief exchanges the values - - Exchanges the contents of a JSON string with those of @a other. Does not - invoke any move, copy, or swap operations on individual elements. All - iterators and references remain valid. The past-the-end iterator is - invalidated. - - @param[in,out] other binary to exchange the contents with - - @throw type_error.310 when JSON value is not a string; example: `"cannot - use swap() with boolean"` - - @complexity Constant. - - @liveexample{The example below shows how strings can be swapped with - `swap()`.,swap__binary_t} - - @since version 3.8.0 - */ - void swap(binary_t& other) - { - // swap only works for strings - if (JSON_HEDLEY_LIKELY(is_binary())) - { - std::swap(*(m_value.binary), other); - } - else - { - JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()), *this)); - } - } - - /// @copydoc swap(binary_t) - void swap(typename binary_t::container_type& other) - { - // swap only works for strings - if (JSON_HEDLEY_LIKELY(is_binary())) - { - std::swap(*(m_value.binary), other); - } - else - { - JSON_THROW(type_error::create(310, "cannot use swap() with " + std::string(type_name()), *this)); - } - } - - /// @} - - public: - ////////////////////////////////////////// - // lexicographical comparison operators // - ////////////////////////////////////////// - - /// @name lexicographical comparison operators - /// @{ - - /*! - @brief comparison: equal - - Compares two JSON values for equality according to the following rules: - - Two JSON values are equal if (1) they are from the same type and (2) - their stored values are the same according to their respective - `operator==`. - - Integer and floating-point numbers are automatically converted before - comparison. Note that two NaN values are always treated as unequal. - - Two JSON null values are equal. - - @note Floating-point inside JSON values numbers are compared with - `json::number_float_t::operator==` which is `double::operator==` by - default. To compare floating-point while respecting an epsilon, an alternative - [comparison function](https://github.com/mariokonrad/marnav/blob/master/include/marnav/math/floatingpoint.hpp#L34-#L39) - could be used, for instance - @code {.cpp} - template::value, T>::type> - inline bool is_same(T a, T b, T epsilon = std::numeric_limits::epsilon()) noexcept - { - return std::abs(a - b) <= epsilon; - } - @endcode - Or you can self-defined operator equal function like this: - @code {.cpp} - bool my_equal(const_reference lhs, const_reference rhs) { - const auto lhs_type lhs.type(); - const auto rhs_type rhs.type(); - if (lhs_type == rhs_type) { - switch(lhs_type) - // self_defined case - case value_t::number_float: - return std::abs(lhs - rhs) <= std::numeric_limits::epsilon(); - // other cases remain the same with the original - ... - } - ... - } - @endcode - - @note NaN values never compare equal to themselves or to other NaN values. - - @param[in] lhs first JSON value to consider - @param[in] rhs second JSON value to consider - @return whether the values @a lhs and @a rhs are equal - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @complexity Linear. - - @liveexample{The example demonstrates comparing several JSON - types.,operator__equal} - - @since version 1.0.0 - */ - friend bool operator==(const_reference lhs, const_reference rhs) noexcept - { - const auto lhs_type = lhs.type(); - const auto rhs_type = rhs.type(); - - if (lhs_type == rhs_type) - { - switch (lhs_type) - { - case value_t::array: - return *lhs.m_value.array == *rhs.m_value.array; - - case value_t::object: - return *lhs.m_value.object == *rhs.m_value.object; - - case value_t::null: - return true; - - case value_t::string: - return *lhs.m_value.string == *rhs.m_value.string; - - case value_t::boolean: - return lhs.m_value.boolean == rhs.m_value.boolean; - - case value_t::number_integer: - return lhs.m_value.number_integer == rhs.m_value.number_integer; - - case value_t::number_unsigned: - return lhs.m_value.number_unsigned == rhs.m_value.number_unsigned; - - case value_t::number_float: - return lhs.m_value.number_float == rhs.m_value.number_float; - - case value_t::binary: - return *lhs.m_value.binary == *rhs.m_value.binary; - - default: - return false; - } - } - else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) - { - return static_cast(lhs.m_value.number_integer) == rhs.m_value.number_float; - } - else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) - { - return lhs.m_value.number_float == static_cast(rhs.m_value.number_integer); - } - else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) - { - return static_cast(lhs.m_value.number_unsigned) == rhs.m_value.number_float; - } - else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) - { - return lhs.m_value.number_float == static_cast(rhs.m_value.number_unsigned); - } - else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) - { - return static_cast(lhs.m_value.number_unsigned) == rhs.m_value.number_integer; - } - else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) - { - return lhs.m_value.number_integer == static_cast(rhs.m_value.number_unsigned); - } - - return false; - } - - /*! - @brief comparison: equal - @copydoc operator==(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator==(const_reference lhs, const ScalarType rhs) noexcept - { - return lhs == basic_json(rhs); - } - - /*! - @brief comparison: equal - @copydoc operator==(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator==(const ScalarType lhs, const_reference rhs) noexcept - { - return basic_json(lhs) == rhs; - } - - /*! - @brief comparison: not equal - - Compares two JSON values for inequality by calculating `not (lhs == rhs)`. - - @param[in] lhs first JSON value to consider - @param[in] rhs second JSON value to consider - @return whether the values @a lhs and @a rhs are not equal - - @complexity Linear. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @liveexample{The example demonstrates comparing several JSON - types.,operator__notequal} - - @since version 1.0.0 - */ - friend bool operator!=(const_reference lhs, const_reference rhs) noexcept - { - return !(lhs == rhs); - } - - /*! - @brief comparison: not equal - @copydoc operator!=(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator!=(const_reference lhs, const ScalarType rhs) noexcept - { - return lhs != basic_json(rhs); - } - - /*! - @brief comparison: not equal - @copydoc operator!=(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator!=(const ScalarType lhs, const_reference rhs) noexcept - { - return basic_json(lhs) != rhs; - } - - /*! - @brief comparison: less than - - Compares whether one JSON value @a lhs is less than another JSON value @a - rhs according to the following rules: - - If @a lhs and @a rhs have the same type, the values are compared using - the default `<` operator. - - Integer and floating-point numbers are automatically converted before - comparison - - In case @a lhs and @a rhs have different types, the values are ignored - and the order of the types is considered, see - @ref operator<(const value_t, const value_t). - - @param[in] lhs first JSON value to consider - @param[in] rhs second JSON value to consider - @return whether @a lhs is less than @a rhs - - @complexity Linear. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @liveexample{The example demonstrates comparing several JSON - types.,operator__less} - - @since version 1.0.0 - */ - friend bool operator<(const_reference lhs, const_reference rhs) noexcept - { - const auto lhs_type = lhs.type(); - const auto rhs_type = rhs.type(); - - if (lhs_type == rhs_type) - { - switch (lhs_type) - { - case value_t::array: - // note parentheses are necessary, see - // https://github.com/nlohmann/json/issues/1530 - return (*lhs.m_value.array) < (*rhs.m_value.array); - - case value_t::object: - return (*lhs.m_value.object) < (*rhs.m_value.object); - - case value_t::null: - return false; - - case value_t::string: - return (*lhs.m_value.string) < (*rhs.m_value.string); - - case value_t::boolean: - return (lhs.m_value.boolean) < (rhs.m_value.boolean); - - case value_t::number_integer: - return (lhs.m_value.number_integer) < (rhs.m_value.number_integer); - - case value_t::number_unsigned: - return (lhs.m_value.number_unsigned) < (rhs.m_value.number_unsigned); - - case value_t::number_float: - return (lhs.m_value.number_float) < (rhs.m_value.number_float); - - case value_t::binary: - return (*lhs.m_value.binary) < (*rhs.m_value.binary); - - default: - return false; - } - } - else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_float) - { - return static_cast(lhs.m_value.number_integer) < rhs.m_value.number_float; - } - else if (lhs_type == value_t::number_float && rhs_type == value_t::number_integer) - { - return lhs.m_value.number_float < static_cast(rhs.m_value.number_integer); - } - else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_float) - { - return static_cast(lhs.m_value.number_unsigned) < rhs.m_value.number_float; - } - else if (lhs_type == value_t::number_float && rhs_type == value_t::number_unsigned) - { - return lhs.m_value.number_float < static_cast(rhs.m_value.number_unsigned); - } - else if (lhs_type == value_t::number_integer && rhs_type == value_t::number_unsigned) - { - return lhs.m_value.number_integer < static_cast(rhs.m_value.number_unsigned); - } - else if (lhs_type == value_t::number_unsigned && rhs_type == value_t::number_integer) - { - return static_cast(lhs.m_value.number_unsigned) < rhs.m_value.number_integer; - } - - // We only reach this line if we cannot compare values. In that case, - // we compare types. Note we have to call the operator explicitly, - // because MSVC has problems otherwise. - return operator<(lhs_type, rhs_type); - } - - /*! - @brief comparison: less than - @copydoc operator<(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator<(const_reference lhs, const ScalarType rhs) noexcept - { - return lhs < basic_json(rhs); - } - - /*! - @brief comparison: less than - @copydoc operator<(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator<(const ScalarType lhs, const_reference rhs) noexcept - { - return basic_json(lhs) < rhs; - } - - /*! - @brief comparison: less than or equal - - Compares whether one JSON value @a lhs is less than or equal to another - JSON value by calculating `not (rhs < lhs)`. - - @param[in] lhs first JSON value to consider - @param[in] rhs second JSON value to consider - @return whether @a lhs is less than or equal to @a rhs - - @complexity Linear. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @liveexample{The example demonstrates comparing several JSON - types.,operator__greater} - - @since version 1.0.0 - */ - friend bool operator<=(const_reference lhs, const_reference rhs) noexcept - { - return !(rhs < lhs); - } - - /*! - @brief comparison: less than or equal - @copydoc operator<=(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator<=(const_reference lhs, const ScalarType rhs) noexcept - { - return lhs <= basic_json(rhs); - } - - /*! - @brief comparison: less than or equal - @copydoc operator<=(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator<=(const ScalarType lhs, const_reference rhs) noexcept - { - return basic_json(lhs) <= rhs; - } - - /*! - @brief comparison: greater than - - Compares whether one JSON value @a lhs is greater than another - JSON value by calculating `not (lhs <= rhs)`. - - @param[in] lhs first JSON value to consider - @param[in] rhs second JSON value to consider - @return whether @a lhs is greater than to @a rhs - - @complexity Linear. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @liveexample{The example demonstrates comparing several JSON - types.,operator__lessequal} - - @since version 1.0.0 - */ - friend bool operator>(const_reference lhs, const_reference rhs) noexcept - { - return !(lhs <= rhs); - } - - /*! - @brief comparison: greater than - @copydoc operator>(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator>(const_reference lhs, const ScalarType rhs) noexcept - { - return lhs > basic_json(rhs); - } - - /*! - @brief comparison: greater than - @copydoc operator>(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator>(const ScalarType lhs, const_reference rhs) noexcept - { - return basic_json(lhs) > rhs; - } - - /*! - @brief comparison: greater than or equal - - Compares whether one JSON value @a lhs is greater than or equal to another - JSON value by calculating `not (lhs < rhs)`. - - @param[in] lhs first JSON value to consider - @param[in] rhs second JSON value to consider - @return whether @a lhs is greater than or equal to @a rhs - - @complexity Linear. - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @liveexample{The example demonstrates comparing several JSON - types.,operator__greaterequal} - - @since version 1.0.0 - */ - friend bool operator>=(const_reference lhs, const_reference rhs) noexcept - { - return !(lhs < rhs); - } - - /*! - @brief comparison: greater than or equal - @copydoc operator>=(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator>=(const_reference lhs, const ScalarType rhs) noexcept - { - return lhs >= basic_json(rhs); - } - - /*! - @brief comparison: greater than or equal - @copydoc operator>=(const_reference, const_reference) - */ - template::value, int>::type = 0> - friend bool operator>=(const ScalarType lhs, const_reference rhs) noexcept - { - return basic_json(lhs) >= rhs; - } - - /// @} - - /////////////////// - // serialization // - /////////////////// - - /// @name serialization - /// @{ - - /*! - @brief serialize to stream - - Serialize the given JSON value @a j to the output stream @a o. The JSON - value will be serialized using the @ref dump member function. - - - The indentation of the output can be controlled with the member variable - `width` of the output stream @a o. For instance, using the manipulator - `std::setw(4)` on @a o sets the indentation level to `4` and the - serialization result is the same as calling `dump(4)`. - - - The indentation character can be controlled with the member variable - `fill` of the output stream @a o. For instance, the manipulator - `std::setfill('\\t')` sets indentation to use a tab character rather than - the default space character. - - @param[in,out] o stream to serialize to - @param[in] j JSON value to serialize - - @return the stream @a o - - @throw type_error.316 if a string stored inside the JSON value is not - UTF-8 encoded - - @complexity Linear. - - @liveexample{The example below shows the serialization with different - parameters to `width` to adjust the indentation level.,operator_serialize} - - @since version 1.0.0; indentation character added in version 3.0.0 - */ - friend std::ostream& operator<<(std::ostream& o, const basic_json& j) - { - // read width member and use it as indentation parameter if nonzero - const bool pretty_print = o.width() > 0; - const auto indentation = pretty_print ? o.width() : 0; - - // reset width to 0 for subsequent calls to this stream - o.width(0); - - // do the actual serialization - serializer s(detail::output_adapter(o), o.fill()); - s.dump(j, pretty_print, false, static_cast(indentation)); - return o; - } - - /*! - @brief serialize to stream - @deprecated This stream operator is deprecated and will be removed in - future 4.0.0 of the library. Please use - @ref operator<<(std::ostream&, const basic_json&) - instead; that is, replace calls like `j >> o;` with `o << j;`. - @since version 1.0.0; deprecated since version 3.0.0 - */ - JSON_HEDLEY_DEPRECATED_FOR(3.0.0, operator<<(std::ostream&, const basic_json&)) - friend std::ostream& operator>>(const basic_json& j, std::ostream& o) - { - return o << j; - } - - /// @} - - - ///////////////////// - // deserialization // - ///////////////////// - - /// @name deserialization - /// @{ - - /*! - @brief deserialize from a compatible input - - @tparam InputType A compatible input, for instance - - an std::istream object - - a FILE pointer - - a C-style array of characters - - a pointer to a null-terminated string of single byte characters - - an object obj for which begin(obj) and end(obj) produces a valid pair of - iterators. - - @param[in] i input to read from - @param[in] cb a parser callback function of type @ref parser_callback_t - which is used to control the deserialization by filtering unwanted values - (optional) - @param[in] allow_exceptions whether to throw exceptions in case of a - parse error (optional, true by default) - @param[in] ignore_comments whether comments should be ignored and treated - like whitespace (true) or yield a parse error (true); (optional, false by - default) - - @return deserialized JSON value; in case of a parse error and - @a allow_exceptions set to `false`, the return value will be - value_t::discarded. - - @throw parse_error.101 if a parse error occurs; example: `""unexpected end - of input; expected string literal""` - @throw parse_error.102 if to_unicode fails or surrogate error - @throw parse_error.103 if to_unicode fails - - @complexity Linear in the length of the input. The parser is a predictive - LL(1) parser. The complexity can be higher if the parser callback function - @a cb or reading from the input @a i has a super-linear complexity. - - @note A UTF-8 byte order mark is silently ignored. - - @liveexample{The example below demonstrates the `parse()` function reading - from an array.,parse__array__parser_callback_t} - - @liveexample{The example below demonstrates the `parse()` function with - and without callback function.,parse__string__parser_callback_t} - - @liveexample{The example below demonstrates the `parse()` function with - and without callback function.,parse__istream__parser_callback_t} - - @liveexample{The example below demonstrates the `parse()` function reading - from a contiguous container.,parse__contiguouscontainer__parser_callback_t} - - @since version 2.0.3 (contiguous containers); version 3.9.0 allowed to - ignore comments. - */ - template - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json parse(InputType&& i, - const parser_callback_t cb = nullptr, - const bool allow_exceptions = true, - const bool ignore_comments = false) - { - basic_json result; - parser(detail::input_adapter(std::forward(i)), cb, allow_exceptions, ignore_comments).parse(true, result); - return result; - } - - /*! - @brief deserialize from a pair of character iterators - - The value_type of the iterator must be a integral type with size of 1, 2 or - 4 bytes, which will be interpreted respectively as UTF-8, UTF-16 and UTF-32. - - @param[in] first iterator to start of character range - @param[in] last iterator to end of character range - @param[in] cb a parser callback function of type @ref parser_callback_t - which is used to control the deserialization by filtering unwanted values - (optional) - @param[in] allow_exceptions whether to throw exceptions in case of a - parse error (optional, true by default) - @param[in] ignore_comments whether comments should be ignored and treated - like whitespace (true) or yield a parse error (true); (optional, false by - default) - - @return deserialized JSON value; in case of a parse error and - @a allow_exceptions set to `false`, the return value will be - value_t::discarded. - - @throw parse_error.101 if a parse error occurs; example: `""unexpected end - of input; expected string literal""` - @throw parse_error.102 if to_unicode fails or surrogate error - @throw parse_error.103 if to_unicode fails - */ - template - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json parse(IteratorType first, - IteratorType last, - const parser_callback_t cb = nullptr, - const bool allow_exceptions = true, - const bool ignore_comments = false) - { - basic_json result; - parser(detail::input_adapter(std::move(first), std::move(last)), cb, allow_exceptions, ignore_comments).parse(true, result); - return result; - } - - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, parse(ptr, ptr + len)) - static basic_json parse(detail::span_input_adapter&& i, - const parser_callback_t cb = nullptr, - const bool allow_exceptions = true, - const bool ignore_comments = false) - { - basic_json result; - parser(i.get(), cb, allow_exceptions, ignore_comments).parse(true, result); - return result; - } - - /*! - @brief check if the input is valid JSON - - Unlike the @ref parse(InputType&&, const parser_callback_t,const bool) - function, this function neither throws an exception in case of invalid JSON - input (i.e., a parse error) nor creates diagnostic information. - - @tparam InputType A compatible input, for instance - - an std::istream object - - a FILE pointer - - a C-style array of characters - - a pointer to a null-terminated string of single byte characters - - an object obj for which begin(obj) and end(obj) produces a valid pair of - iterators. - - @param[in] i input to read from - @param[in] ignore_comments whether comments should be ignored and treated - like whitespace (true) or yield a parse error (true); (optional, false by - default) - - @return Whether the input read from @a i is valid JSON. - - @complexity Linear in the length of the input. The parser is a predictive - LL(1) parser. - - @note A UTF-8 byte order mark is silently ignored. - - @liveexample{The example below demonstrates the `accept()` function reading - from a string.,accept__string} - */ - template - static bool accept(InputType&& i, - const bool ignore_comments = false) - { - return parser(detail::input_adapter(std::forward(i)), nullptr, false, ignore_comments).accept(true); - } - - template - static bool accept(IteratorType first, IteratorType last, - const bool ignore_comments = false) - { - return parser(detail::input_adapter(std::move(first), std::move(last)), nullptr, false, ignore_comments).accept(true); - } - - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, accept(ptr, ptr + len)) - static bool accept(detail::span_input_adapter&& i, - const bool ignore_comments = false) - { - return parser(i.get(), nullptr, false, ignore_comments).accept(true); - } - - /*! - @brief generate SAX events - - The SAX event lister must follow the interface of @ref json_sax. - - This function reads from a compatible input. Examples are: - - an std::istream object - - a FILE pointer - - a C-style array of characters - - a pointer to a null-terminated string of single byte characters - - an object obj for which begin(obj) and end(obj) produces a valid pair of - iterators. - - @param[in] i input to read from - @param[in,out] sax SAX event listener - @param[in] format the format to parse (JSON, CBOR, MessagePack, or UBJSON) - @param[in] strict whether the input has to be consumed completely - @param[in] ignore_comments whether comments should be ignored and treated - like whitespace (true) or yield a parse error (true); (optional, false by - default); only applies to the JSON file format. - - @return return value of the last processed SAX event - - @throw parse_error.101 if a parse error occurs; example: `""unexpected end - of input; expected string literal""` - @throw parse_error.102 if to_unicode fails or surrogate error - @throw parse_error.103 if to_unicode fails - - @complexity Linear in the length of the input. The parser is a predictive - LL(1) parser. The complexity can be higher if the SAX consumer @a sax has - a super-linear complexity. - - @note A UTF-8 byte order mark is silently ignored. - - @liveexample{The example below demonstrates the `sax_parse()` function - reading from string and processing the events with a user-defined SAX - event consumer.,sax_parse} - - @since version 3.2.0 - */ - template - JSON_HEDLEY_NON_NULL(2) - static bool sax_parse(InputType&& i, SAX* sax, - input_format_t format = input_format_t::json, - const bool strict = true, - const bool ignore_comments = false) - { - auto ia = detail::input_adapter(std::forward(i)); - return format == input_format_t::json - ? parser(std::move(ia), nullptr, true, ignore_comments).sax_parse(sax, strict) - : detail::binary_reader(std::move(ia)).sax_parse(format, sax, strict); - } - - template - JSON_HEDLEY_NON_NULL(3) - static bool sax_parse(IteratorType first, IteratorType last, SAX* sax, - input_format_t format = input_format_t::json, - const bool strict = true, - const bool ignore_comments = false) - { - auto ia = detail::input_adapter(std::move(first), std::move(last)); - return format == input_format_t::json - ? parser(std::move(ia), nullptr, true, ignore_comments).sax_parse(sax, strict) - : detail::binary_reader(std::move(ia)).sax_parse(format, sax, strict); - } - - template - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, sax_parse(ptr, ptr + len, ...)) - JSON_HEDLEY_NON_NULL(2) - static bool sax_parse(detail::span_input_adapter&& i, SAX* sax, - input_format_t format = input_format_t::json, - const bool strict = true, - const bool ignore_comments = false) - { - auto ia = i.get(); - return format == input_format_t::json - ? parser(std::move(ia), nullptr, true, ignore_comments).sax_parse(sax, strict) - : detail::binary_reader(std::move(ia)).sax_parse(format, sax, strict); - } - - /*! - @brief deserialize from stream - @deprecated This stream operator is deprecated and will be removed in - version 4.0.0 of the library. Please use - @ref operator>>(std::istream&, basic_json&) - instead; that is, replace calls like `j << i;` with `i >> j;`. - @since version 1.0.0; deprecated since version 3.0.0 - */ - JSON_HEDLEY_DEPRECATED_FOR(3.0.0, operator>>(std::istream&, basic_json&)) - friend std::istream& operator<<(basic_json& j, std::istream& i) - { - return operator>>(i, j); - } - - /*! - @brief deserialize from stream - - Deserializes an input stream to a JSON value. - - @param[in,out] i input stream to read a serialized JSON value from - @param[in,out] j JSON value to write the deserialized input to - - @throw parse_error.101 in case of an unexpected token - @throw parse_error.102 if to_unicode fails or surrogate error - @throw parse_error.103 if to_unicode fails - - @complexity Linear in the length of the input. The parser is a predictive - LL(1) parser. - - @note A UTF-8 byte order mark is silently ignored. - - @liveexample{The example below shows how a JSON value is constructed by - reading a serialization from a stream.,operator_deserialize} - - @sa parse(std::istream&, const parser_callback_t) for a variant with a - parser callback function to filter values while parsing - - @since version 1.0.0 - */ - friend std::istream& operator>>(std::istream& i, basic_json& j) - { - parser(detail::input_adapter(i)).parse(false, j); - return i; - } - - /// @} - - /////////////////////////// - // convenience functions // - /////////////////////////// - - /*! - @brief return the type as string - - Returns the type name as string to be used in error messages - usually to - indicate that a function was called on a wrong JSON type. - - @return a string representation of a the @a m_type member: - Value type | return value - ----------- | ------------- - null | `"null"` - boolean | `"boolean"` - string | `"string"` - number | `"number"` (for all number types) - object | `"object"` - array | `"array"` - binary | `"binary"` - discarded | `"discarded"` - - @exceptionsafety No-throw guarantee: this function never throws exceptions. - - @complexity Constant. - - @liveexample{The following code exemplifies `type_name()` for all JSON - types.,type_name} - - @sa @ref type() -- return the type of the JSON value - @sa @ref operator value_t() -- return the type of the JSON value (implicit) - - @since version 1.0.0, public since 2.1.0, `const char*` and `noexcept` - since 3.0.0 - */ - JSON_HEDLEY_RETURNS_NON_NULL - const char* type_name() const noexcept - { - { - switch (m_type) - { - case value_t::null: - return "null"; - case value_t::object: - return "object"; - case value_t::array: - return "array"; - case value_t::string: - return "string"; - case value_t::boolean: - return "boolean"; - case value_t::binary: - return "binary"; - case value_t::discarded: - return "discarded"; - default: - return "number"; - } - } - } - - - JSON_PRIVATE_UNLESS_TESTED: - ////////////////////// - // member variables // - ////////////////////// - - /// the type of the current element - value_t m_type = value_t::null; - - /// the value of the current element - json_value m_value = {}; - -#if JSON_DIAGNOSTICS - /// a pointer to a parent value (for debugging purposes) - basic_json* m_parent = nullptr; -#endif - - ////////////////////////////////////////// - // binary serialization/deserialization // - ////////////////////////////////////////// - - /// @name binary serialization/deserialization support - /// @{ - - public: - /*! - @brief create a CBOR serialization of a given JSON value - - Serializes a given JSON value @a j to a byte vector using the CBOR (Concise - Binary Object Representation) serialization format. CBOR is a binary - serialization format which aims to be more compact than JSON itself, yet - more efficient to parse. - - The library uses the following mapping from JSON values types to - CBOR types according to the CBOR specification (RFC 7049): - - JSON value type | value/range | CBOR type | first byte - --------------- | ------------------------------------------ | ---------------------------------- | --------------- - null | `null` | Null | 0xF6 - boolean | `true` | True | 0xF5 - boolean | `false` | False | 0xF4 - number_integer | -9223372036854775808..-2147483649 | Negative integer (8 bytes follow) | 0x3B - number_integer | -2147483648..-32769 | Negative integer (4 bytes follow) | 0x3A - number_integer | -32768..-129 | Negative integer (2 bytes follow) | 0x39 - number_integer | -128..-25 | Negative integer (1 byte follow) | 0x38 - number_integer | -24..-1 | Negative integer | 0x20..0x37 - number_integer | 0..23 | Integer | 0x00..0x17 - number_integer | 24..255 | Unsigned integer (1 byte follow) | 0x18 - number_integer | 256..65535 | Unsigned integer (2 bytes follow) | 0x19 - number_integer | 65536..4294967295 | Unsigned integer (4 bytes follow) | 0x1A - number_integer | 4294967296..18446744073709551615 | Unsigned integer (8 bytes follow) | 0x1B - number_unsigned | 0..23 | Integer | 0x00..0x17 - number_unsigned | 24..255 | Unsigned integer (1 byte follow) | 0x18 - number_unsigned | 256..65535 | Unsigned integer (2 bytes follow) | 0x19 - number_unsigned | 65536..4294967295 | Unsigned integer (4 bytes follow) | 0x1A - number_unsigned | 4294967296..18446744073709551615 | Unsigned integer (8 bytes follow) | 0x1B - number_float | *any value representable by a float* | Single-Precision Float | 0xFA - number_float | *any value NOT representable by a float* | Double-Precision Float | 0xFB - string | *length*: 0..23 | UTF-8 string | 0x60..0x77 - string | *length*: 23..255 | UTF-8 string (1 byte follow) | 0x78 - string | *length*: 256..65535 | UTF-8 string (2 bytes follow) | 0x79 - string | *length*: 65536..4294967295 | UTF-8 string (4 bytes follow) | 0x7A - string | *length*: 4294967296..18446744073709551615 | UTF-8 string (8 bytes follow) | 0x7B - array | *size*: 0..23 | array | 0x80..0x97 - array | *size*: 23..255 | array (1 byte follow) | 0x98 - array | *size*: 256..65535 | array (2 bytes follow) | 0x99 - array | *size*: 65536..4294967295 | array (4 bytes follow) | 0x9A - array | *size*: 4294967296..18446744073709551615 | array (8 bytes follow) | 0x9B - object | *size*: 0..23 | map | 0xA0..0xB7 - object | *size*: 23..255 | map (1 byte follow) | 0xB8 - object | *size*: 256..65535 | map (2 bytes follow) | 0xB9 - object | *size*: 65536..4294967295 | map (4 bytes follow) | 0xBA - object | *size*: 4294967296..18446744073709551615 | map (8 bytes follow) | 0xBB - binary | *size*: 0..23 | byte string | 0x40..0x57 - binary | *size*: 23..255 | byte string (1 byte follow) | 0x58 - binary | *size*: 256..65535 | byte string (2 bytes follow) | 0x59 - binary | *size*: 65536..4294967295 | byte string (4 bytes follow) | 0x5A - binary | *size*: 4294967296..18446744073709551615 | byte string (8 bytes follow) | 0x5B - - @note The mapping is **complete** in the sense that any JSON value type - can be converted to a CBOR value. - - @note If NaN or Infinity are stored inside a JSON number, they are - serialized properly. This behavior differs from the @ref dump() - function which serializes NaN or Infinity to `null`. - - @note The following CBOR types are not used in the conversion: - - UTF-8 strings terminated by "break" (0x7F) - - arrays terminated by "break" (0x9F) - - maps terminated by "break" (0xBF) - - byte strings terminated by "break" (0x5F) - - date/time (0xC0..0xC1) - - bignum (0xC2..0xC3) - - decimal fraction (0xC4) - - bigfloat (0xC5) - - expected conversions (0xD5..0xD7) - - simple values (0xE0..0xF3, 0xF8) - - undefined (0xF7) - - half-precision floats (0xF9) - - break (0xFF) - - @param[in] j JSON value to serialize - @return CBOR serialization as byte vector - - @complexity Linear in the size of the JSON value @a j. - - @liveexample{The example shows the serialization of a JSON value to a byte - vector in CBOR format.,to_cbor} - - @sa http://cbor.io - @sa @ref from_cbor(detail::input_adapter&&, const bool, const bool, const cbor_tag_handler_t) for the - analogous deserialization - @sa @ref to_msgpack(const basic_json&) for the related MessagePack format - @sa @ref to_ubjson(const basic_json&, const bool, const bool) for the - related UBJSON format - - @since version 2.0.9; compact representation of floating-point numbers - since version 3.8.0 - */ - static std::vector to_cbor(const basic_json& j) - { - std::vector result; - to_cbor(j, result); - return result; - } - - static void to_cbor(const basic_json& j, detail::output_adapter o) - { - binary_writer(o).write_cbor(j); - } - - static void to_cbor(const basic_json& j, detail::output_adapter o) - { - binary_writer(o).write_cbor(j); - } - - /*! - @brief create a MessagePack serialization of a given JSON value - - Serializes a given JSON value @a j to a byte vector using the MessagePack - serialization format. MessagePack is a binary serialization format which - aims to be more compact than JSON itself, yet more efficient to parse. - - The library uses the following mapping from JSON values types to - MessagePack types according to the MessagePack specification: - - JSON value type | value/range | MessagePack type | first byte - --------------- | --------------------------------- | ---------------- | ---------- - null | `null` | nil | 0xC0 - boolean | `true` | true | 0xC3 - boolean | `false` | false | 0xC2 - number_integer | -9223372036854775808..-2147483649 | int64 | 0xD3 - number_integer | -2147483648..-32769 | int32 | 0xD2 - number_integer | -32768..-129 | int16 | 0xD1 - number_integer | -128..-33 | int8 | 0xD0 - number_integer | -32..-1 | negative fixint | 0xE0..0xFF - number_integer | 0..127 | positive fixint | 0x00..0x7F - number_integer | 128..255 | uint 8 | 0xCC - number_integer | 256..65535 | uint 16 | 0xCD - number_integer | 65536..4294967295 | uint 32 | 0xCE - number_integer | 4294967296..18446744073709551615 | uint 64 | 0xCF - number_unsigned | 0..127 | positive fixint | 0x00..0x7F - number_unsigned | 128..255 | uint 8 | 0xCC - number_unsigned | 256..65535 | uint 16 | 0xCD - number_unsigned | 65536..4294967295 | uint 32 | 0xCE - number_unsigned | 4294967296..18446744073709551615 | uint 64 | 0xCF - number_float | *any value representable by a float* | float 32 | 0xCA - number_float | *any value NOT representable by a float* | float 64 | 0xCB - string | *length*: 0..31 | fixstr | 0xA0..0xBF - string | *length*: 32..255 | str 8 | 0xD9 - string | *length*: 256..65535 | str 16 | 0xDA - string | *length*: 65536..4294967295 | str 32 | 0xDB - array | *size*: 0..15 | fixarray | 0x90..0x9F - array | *size*: 16..65535 | array 16 | 0xDC - array | *size*: 65536..4294967295 | array 32 | 0xDD - object | *size*: 0..15 | fix map | 0x80..0x8F - object | *size*: 16..65535 | map 16 | 0xDE - object | *size*: 65536..4294967295 | map 32 | 0xDF - binary | *size*: 0..255 | bin 8 | 0xC4 - binary | *size*: 256..65535 | bin 16 | 0xC5 - binary | *size*: 65536..4294967295 | bin 32 | 0xC6 - - @note The mapping is **complete** in the sense that any JSON value type - can be converted to a MessagePack value. - - @note The following values can **not** be converted to a MessagePack value: - - strings with more than 4294967295 bytes - - byte strings with more than 4294967295 bytes - - arrays with more than 4294967295 elements - - objects with more than 4294967295 elements - - @note Any MessagePack output created @ref to_msgpack can be successfully - parsed by @ref from_msgpack. - - @note If NaN or Infinity are stored inside a JSON number, they are - serialized properly. This behavior differs from the @ref dump() - function which serializes NaN or Infinity to `null`. - - @param[in] j JSON value to serialize - @return MessagePack serialization as byte vector - - @complexity Linear in the size of the JSON value @a j. - - @liveexample{The example shows the serialization of a JSON value to a byte - vector in MessagePack format.,to_msgpack} - - @sa http://msgpack.org - @sa @ref from_msgpack for the analogous deserialization - @sa @ref to_cbor(const basic_json& for the related CBOR format - @sa @ref to_ubjson(const basic_json&, const bool, const bool) for the - related UBJSON format - - @since version 2.0.9 - */ - static std::vector to_msgpack(const basic_json& j) - { - std::vector result; - to_msgpack(j, result); - return result; - } - - static void to_msgpack(const basic_json& j, detail::output_adapter o) - { - binary_writer(o).write_msgpack(j); - } - - static void to_msgpack(const basic_json& j, detail::output_adapter o) - { - binary_writer(o).write_msgpack(j); - } - - /*! - @brief create a UBJSON serialization of a given JSON value - - Serializes a given JSON value @a j to a byte vector using the UBJSON - (Universal Binary JSON) serialization format. UBJSON aims to be more compact - than JSON itself, yet more efficient to parse. - - The library uses the following mapping from JSON values types to - UBJSON types according to the UBJSON specification: - - JSON value type | value/range | UBJSON type | marker - --------------- | --------------------------------- | ----------- | ------ - null | `null` | null | `Z` - boolean | `true` | true | `T` - boolean | `false` | false | `F` - number_integer | -9223372036854775808..-2147483649 | int64 | `L` - number_integer | -2147483648..-32769 | int32 | `l` - number_integer | -32768..-129 | int16 | `I` - number_integer | -128..127 | int8 | `i` - number_integer | 128..255 | uint8 | `U` - number_integer | 256..32767 | int16 | `I` - number_integer | 32768..2147483647 | int32 | `l` - number_integer | 2147483648..9223372036854775807 | int64 | `L` - number_unsigned | 0..127 | int8 | `i` - number_unsigned | 128..255 | uint8 | `U` - number_unsigned | 256..32767 | int16 | `I` - number_unsigned | 32768..2147483647 | int32 | `l` - number_unsigned | 2147483648..9223372036854775807 | int64 | `L` - number_unsigned | 2147483649..18446744073709551615 | high-precision | `H` - number_float | *any value* | float64 | `D` - string | *with shortest length indicator* | string | `S` - array | *see notes on optimized format* | array | `[` - object | *see notes on optimized format* | map | `{` - - @note The mapping is **complete** in the sense that any JSON value type - can be converted to a UBJSON value. - - @note The following values can **not** be converted to a UBJSON value: - - strings with more than 9223372036854775807 bytes (theoretical) - - @note The following markers are not used in the conversion: - - `Z`: no-op values are not created. - - `C`: single-byte strings are serialized with `S` markers. - - @note Any UBJSON output created @ref to_ubjson can be successfully parsed - by @ref from_ubjson. - - @note If NaN or Infinity are stored inside a JSON number, they are - serialized properly. This behavior differs from the @ref dump() - function which serializes NaN or Infinity to `null`. - - @note The optimized formats for containers are supported: Parameter - @a use_size adds size information to the beginning of a container and - removes the closing marker. Parameter @a use_type further checks - whether all elements of a container have the same type and adds the - type marker to the beginning of the container. The @a use_type - parameter must only be used together with @a use_size = true. Note - that @a use_size = true alone may result in larger representations - - the benefit of this parameter is that the receiving side is - immediately informed on the number of elements of the container. - - @note If the JSON data contains the binary type, the value stored is a list - of integers, as suggested by the UBJSON documentation. In particular, - this means that serialization and the deserialization of a JSON - containing binary values into UBJSON and back will result in a - different JSON object. - - @param[in] j JSON value to serialize - @param[in] use_size whether to add size annotations to container types - @param[in] use_type whether to add type annotations to container types - (must be combined with @a use_size = true) - @return UBJSON serialization as byte vector - - @complexity Linear in the size of the JSON value @a j. - - @liveexample{The example shows the serialization of a JSON value to a byte - vector in UBJSON format.,to_ubjson} - - @sa http://ubjson.org - @sa @ref from_ubjson(detail::input_adapter&&, const bool, const bool) for the - analogous deserialization - @sa @ref to_cbor(const basic_json& for the related CBOR format - @sa @ref to_msgpack(const basic_json&) for the related MessagePack format - - @since version 3.1.0 - */ - static std::vector to_ubjson(const basic_json& j, - const bool use_size = false, - const bool use_type = false) - { - std::vector result; - to_ubjson(j, result, use_size, use_type); - return result; - } - - static void to_ubjson(const basic_json& j, detail::output_adapter o, - const bool use_size = false, const bool use_type = false) - { - binary_writer(o).write_ubjson(j, use_size, use_type); - } - - static void to_ubjson(const basic_json& j, detail::output_adapter o, - const bool use_size = false, const bool use_type = false) - { - binary_writer(o).write_ubjson(j, use_size, use_type); - } - - - /*! - @brief Serializes the given JSON object `j` to BSON and returns a vector - containing the corresponding BSON-representation. - - BSON (Binary JSON) is a binary format in which zero or more ordered key/value pairs are - stored as a single entity (a so-called document). - - The library uses the following mapping from JSON values types to BSON types: - - JSON value type | value/range | BSON type | marker - --------------- | --------------------------------- | ----------- | ------ - null | `null` | null | 0x0A - boolean | `true`, `false` | boolean | 0x08 - number_integer | -9223372036854775808..-2147483649 | int64 | 0x12 - number_integer | -2147483648..2147483647 | int32 | 0x10 - number_integer | 2147483648..9223372036854775807 | int64 | 0x12 - number_unsigned | 0..2147483647 | int32 | 0x10 - number_unsigned | 2147483648..9223372036854775807 | int64 | 0x12 - number_unsigned | 9223372036854775808..18446744073709551615| -- | -- - number_float | *any value* | double | 0x01 - string | *any value* | string | 0x02 - array | *any value* | document | 0x04 - object | *any value* | document | 0x03 - binary | *any value* | binary | 0x05 - - @warning The mapping is **incomplete**, since only JSON-objects (and things - contained therein) can be serialized to BSON. - Also, integers larger than 9223372036854775807 cannot be serialized to BSON, - and the keys may not contain U+0000, since they are serialized a - zero-terminated c-strings. - - @throw out_of_range.407 if `j.is_number_unsigned() && j.get() > 9223372036854775807` - @throw out_of_range.409 if a key in `j` contains a NULL (U+0000) - @throw type_error.317 if `!j.is_object()` - - @pre The input `j` is required to be an object: `j.is_object() == true`. - - @note Any BSON output created via @ref to_bson can be successfully parsed - by @ref from_bson. - - @param[in] j JSON value to serialize - @return BSON serialization as byte vector - - @complexity Linear in the size of the JSON value @a j. - - @liveexample{The example shows the serialization of a JSON value to a byte - vector in BSON format.,to_bson} - - @sa http://bsonspec.org/spec.html - @sa @ref from_bson(detail::input_adapter&&, const bool strict) for the - analogous deserialization - @sa @ref to_ubjson(const basic_json&, const bool, const bool) for the - related UBJSON format - @sa @ref to_cbor(const basic_json&) for the related CBOR format - @sa @ref to_msgpack(const basic_json&) for the related MessagePack format - */ - static std::vector to_bson(const basic_json& j) - { - std::vector result; - to_bson(j, result); - return result; - } - - /*! - @brief Serializes the given JSON object `j` to BSON and forwards the - corresponding BSON-representation to the given output_adapter `o`. - @param j The JSON object to convert to BSON. - @param o The output adapter that receives the binary BSON representation. - @pre The input `j` shall be an object: `j.is_object() == true` - @sa @ref to_bson(const basic_json&) - */ - static void to_bson(const basic_json& j, detail::output_adapter o) - { - binary_writer(o).write_bson(j); - } - - /*! - @copydoc to_bson(const basic_json&, detail::output_adapter) - */ - static void to_bson(const basic_json& j, detail::output_adapter o) - { - binary_writer(o).write_bson(j); - } - - - /*! - @brief create a JSON value from an input in CBOR format - - Deserializes a given input @a i to a JSON value using the CBOR (Concise - Binary Object Representation) serialization format. - - The library maps CBOR types to JSON value types as follows: - - CBOR type | JSON value type | first byte - ---------------------- | --------------- | ---------- - Integer | number_unsigned | 0x00..0x17 - Unsigned integer | number_unsigned | 0x18 - Unsigned integer | number_unsigned | 0x19 - Unsigned integer | number_unsigned | 0x1A - Unsigned integer | number_unsigned | 0x1B - Negative integer | number_integer | 0x20..0x37 - Negative integer | number_integer | 0x38 - Negative integer | number_integer | 0x39 - Negative integer | number_integer | 0x3A - Negative integer | number_integer | 0x3B - Byte string | binary | 0x40..0x57 - Byte string | binary | 0x58 - Byte string | binary | 0x59 - Byte string | binary | 0x5A - Byte string | binary | 0x5B - UTF-8 string | string | 0x60..0x77 - UTF-8 string | string | 0x78 - UTF-8 string | string | 0x79 - UTF-8 string | string | 0x7A - UTF-8 string | string | 0x7B - UTF-8 string | string | 0x7F - array | array | 0x80..0x97 - array | array | 0x98 - array | array | 0x99 - array | array | 0x9A - array | array | 0x9B - array | array | 0x9F - map | object | 0xA0..0xB7 - map | object | 0xB8 - map | object | 0xB9 - map | object | 0xBA - map | object | 0xBB - map | object | 0xBF - False | `false` | 0xF4 - True | `true` | 0xF5 - Null | `null` | 0xF6 - Half-Precision Float | number_float | 0xF9 - Single-Precision Float | number_float | 0xFA - Double-Precision Float | number_float | 0xFB - - @warning The mapping is **incomplete** in the sense that not all CBOR - types can be converted to a JSON value. The following CBOR types - are not supported and will yield parse errors (parse_error.112): - - date/time (0xC0..0xC1) - - bignum (0xC2..0xC3) - - decimal fraction (0xC4) - - bigfloat (0xC5) - - expected conversions (0xD5..0xD7) - - simple values (0xE0..0xF3, 0xF8) - - undefined (0xF7) - - @warning CBOR allows map keys of any type, whereas JSON only allows - strings as keys in object values. Therefore, CBOR maps with keys - other than UTF-8 strings are rejected (parse_error.113). - - @note Any CBOR output created @ref to_cbor can be successfully parsed by - @ref from_cbor. - - @param[in] i an input in CBOR format convertible to an input adapter - @param[in] strict whether to expect the input to be consumed until EOF - (true by default) - @param[in] allow_exceptions whether to throw exceptions in case of a - parse error (optional, true by default) - @param[in] tag_handler how to treat CBOR tags (optional, error by default) - - @return deserialized JSON value; in case of a parse error and - @a allow_exceptions set to `false`, the return value will be - value_t::discarded. - - @throw parse_error.110 if the given input ends prematurely or the end of - file was not reached when @a strict was set to true - @throw parse_error.112 if unsupported features from CBOR were - used in the given input @a v or if the input is not valid CBOR - @throw parse_error.113 if a string was expected as map key, but not found - - @complexity Linear in the size of the input @a i. - - @liveexample{The example shows the deserialization of a byte vector in CBOR - format to a JSON value.,from_cbor} - - @sa http://cbor.io - @sa @ref to_cbor(const basic_json&) for the analogous serialization - @sa @ref from_msgpack(detail::input_adapter&&, const bool, const bool) for the - related MessagePack format - @sa @ref from_ubjson(detail::input_adapter&&, const bool, const bool) for the - related UBJSON format - - @since version 2.0.9; parameter @a start_index since 2.1.1; changed to - consume input adapters, removed start_index parameter, and added - @a strict parameter since 3.0.0; added @a allow_exceptions parameter - since 3.2.0; added @a tag_handler parameter since 3.9.0. - */ - template - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json from_cbor(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true, - const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = detail::input_adapter(std::forward(i)); - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler); - return res ? result : basic_json(value_t::discarded); - } - - /*! - @copydoc from_cbor(detail::input_adapter&&, const bool, const bool, const cbor_tag_handler_t) - */ - template - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json from_cbor(IteratorType first, IteratorType last, - const bool strict = true, - const bool allow_exceptions = true, - const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = detail::input_adapter(std::move(first), std::move(last)); - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler); - return res ? result : basic_json(value_t::discarded); - } - - template - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len)) - static basic_json from_cbor(const T* ptr, std::size_t len, - const bool strict = true, - const bool allow_exceptions = true, - const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) - { - return from_cbor(ptr, ptr + len, strict, allow_exceptions, tag_handler); - } - - - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_cbor(ptr, ptr + len)) - static basic_json from_cbor(detail::span_input_adapter&& i, - const bool strict = true, - const bool allow_exceptions = true, - const cbor_tag_handler_t tag_handler = cbor_tag_handler_t::error) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = i.get(); - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::cbor, &sdp, strict, tag_handler); - return res ? result : basic_json(value_t::discarded); - } - - /*! - @brief create a JSON value from an input in MessagePack format - - Deserializes a given input @a i to a JSON value using the MessagePack - serialization format. - - The library maps MessagePack types to JSON value types as follows: - - MessagePack type | JSON value type | first byte - ---------------- | --------------- | ---------- - positive fixint | number_unsigned | 0x00..0x7F - fixmap | object | 0x80..0x8F - fixarray | array | 0x90..0x9F - fixstr | string | 0xA0..0xBF - nil | `null` | 0xC0 - false | `false` | 0xC2 - true | `true` | 0xC3 - float 32 | number_float | 0xCA - float 64 | number_float | 0xCB - uint 8 | number_unsigned | 0xCC - uint 16 | number_unsigned | 0xCD - uint 32 | number_unsigned | 0xCE - uint 64 | number_unsigned | 0xCF - int 8 | number_integer | 0xD0 - int 16 | number_integer | 0xD1 - int 32 | number_integer | 0xD2 - int 64 | number_integer | 0xD3 - str 8 | string | 0xD9 - str 16 | string | 0xDA - str 32 | string | 0xDB - array 16 | array | 0xDC - array 32 | array | 0xDD - map 16 | object | 0xDE - map 32 | object | 0xDF - bin 8 | binary | 0xC4 - bin 16 | binary | 0xC5 - bin 32 | binary | 0xC6 - ext 8 | binary | 0xC7 - ext 16 | binary | 0xC8 - ext 32 | binary | 0xC9 - fixext 1 | binary | 0xD4 - fixext 2 | binary | 0xD5 - fixext 4 | binary | 0xD6 - fixext 8 | binary | 0xD7 - fixext 16 | binary | 0xD8 - negative fixint | number_integer | 0xE0-0xFF - - @note Any MessagePack output created @ref to_msgpack can be successfully - parsed by @ref from_msgpack. - - @param[in] i an input in MessagePack format convertible to an input - adapter - @param[in] strict whether to expect the input to be consumed until EOF - (true by default) - @param[in] allow_exceptions whether to throw exceptions in case of a - parse error (optional, true by default) - - @return deserialized JSON value; in case of a parse error and - @a allow_exceptions set to `false`, the return value will be - value_t::discarded. - - @throw parse_error.110 if the given input ends prematurely or the end of - file was not reached when @a strict was set to true - @throw parse_error.112 if unsupported features from MessagePack were - used in the given input @a i or if the input is not valid MessagePack - @throw parse_error.113 if a string was expected as map key, but not found - - @complexity Linear in the size of the input @a i. - - @liveexample{The example shows the deserialization of a byte vector in - MessagePack format to a JSON value.,from_msgpack} - - @sa http://msgpack.org - @sa @ref to_msgpack(const basic_json&) for the analogous serialization - @sa @ref from_cbor(detail::input_adapter&&, const bool, const bool, const cbor_tag_handler_t) for the - related CBOR format - @sa @ref from_ubjson(detail::input_adapter&&, const bool, const bool) for - the related UBJSON format - @sa @ref from_bson(detail::input_adapter&&, const bool, const bool) for - the related BSON format - - @since version 2.0.9; parameter @a start_index since 2.1.1; changed to - consume input adapters, removed start_index parameter, and added - @a strict parameter since 3.0.0; added @a allow_exceptions parameter - since 3.2.0 - */ - template - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json from_msgpack(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = detail::input_adapter(std::forward(i)); - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::msgpack, &sdp, strict); - return res ? result : basic_json(value_t::discarded); - } - - /*! - @copydoc from_msgpack(detail::input_adapter&&, const bool, const bool) - */ - template - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json from_msgpack(IteratorType first, IteratorType last, - const bool strict = true, - const bool allow_exceptions = true) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = detail::input_adapter(std::move(first), std::move(last)); - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::msgpack, &sdp, strict); - return res ? result : basic_json(value_t::discarded); - } - - - template - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len)) - static basic_json from_msgpack(const T* ptr, std::size_t len, - const bool strict = true, - const bool allow_exceptions = true) - { - return from_msgpack(ptr, ptr + len, strict, allow_exceptions); - } - - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_msgpack(ptr, ptr + len)) - static basic_json from_msgpack(detail::span_input_adapter&& i, - const bool strict = true, - const bool allow_exceptions = true) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = i.get(); - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::msgpack, &sdp, strict); - return res ? result : basic_json(value_t::discarded); - } - - - /*! - @brief create a JSON value from an input in UBJSON format - - Deserializes a given input @a i to a JSON value using the UBJSON (Universal - Binary JSON) serialization format. - - The library maps UBJSON types to JSON value types as follows: - - UBJSON type | JSON value type | marker - ----------- | --------------------------------------- | ------ - no-op | *no value, next value is read* | `N` - null | `null` | `Z` - false | `false` | `F` - true | `true` | `T` - float32 | number_float | `d` - float64 | number_float | `D` - uint8 | number_unsigned | `U` - int8 | number_integer | `i` - int16 | number_integer | `I` - int32 | number_integer | `l` - int64 | number_integer | `L` - high-precision number | number_integer, number_unsigned, or number_float - depends on number string | 'H' - string | string | `S` - char | string | `C` - array | array (optimized values are supported) | `[` - object | object (optimized values are supported) | `{` - - @note The mapping is **complete** in the sense that any UBJSON value can - be converted to a JSON value. - - @param[in] i an input in UBJSON format convertible to an input adapter - @param[in] strict whether to expect the input to be consumed until EOF - (true by default) - @param[in] allow_exceptions whether to throw exceptions in case of a - parse error (optional, true by default) - - @return deserialized JSON value; in case of a parse error and - @a allow_exceptions set to `false`, the return value will be - value_t::discarded. - - @throw parse_error.110 if the given input ends prematurely or the end of - file was not reached when @a strict was set to true - @throw parse_error.112 if a parse error occurs - @throw parse_error.113 if a string could not be parsed successfully - - @complexity Linear in the size of the input @a i. - - @liveexample{The example shows the deserialization of a byte vector in - UBJSON format to a JSON value.,from_ubjson} - - @sa http://ubjson.org - @sa @ref to_ubjson(const basic_json&, const bool, const bool) for the - analogous serialization - @sa @ref from_cbor(detail::input_adapter&&, const bool, const bool, const cbor_tag_handler_t) for the - related CBOR format - @sa @ref from_msgpack(detail::input_adapter&&, const bool, const bool) for - the related MessagePack format - @sa @ref from_bson(detail::input_adapter&&, const bool, const bool) for - the related BSON format - - @since version 3.1.0; added @a allow_exceptions parameter since 3.2.0 - */ - template - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json from_ubjson(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = detail::input_adapter(std::forward(i)); - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::ubjson, &sdp, strict); - return res ? result : basic_json(value_t::discarded); - } - - /*! - @copydoc from_ubjson(detail::input_adapter&&, const bool, const bool) - */ - template - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json from_ubjson(IteratorType first, IteratorType last, - const bool strict = true, - const bool allow_exceptions = true) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = detail::input_adapter(std::move(first), std::move(last)); - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::ubjson, &sdp, strict); - return res ? result : basic_json(value_t::discarded); - } - - template - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len)) - static basic_json from_ubjson(const T* ptr, std::size_t len, - const bool strict = true, - const bool allow_exceptions = true) - { - return from_ubjson(ptr, ptr + len, strict, allow_exceptions); - } - - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_ubjson(ptr, ptr + len)) - static basic_json from_ubjson(detail::span_input_adapter&& i, - const bool strict = true, - const bool allow_exceptions = true) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = i.get(); - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::ubjson, &sdp, strict); - return res ? result : basic_json(value_t::discarded); - } - - - /*! - @brief Create a JSON value from an input in BSON format - - Deserializes a given input @a i to a JSON value using the BSON (Binary JSON) - serialization format. - - The library maps BSON record types to JSON value types as follows: - - BSON type | BSON marker byte | JSON value type - --------------- | ---------------- | --------------------------- - double | 0x01 | number_float - string | 0x02 | string - document | 0x03 | object - array | 0x04 | array - binary | 0x05 | binary - undefined | 0x06 | still unsupported - ObjectId | 0x07 | still unsupported - boolean | 0x08 | boolean - UTC Date-Time | 0x09 | still unsupported - null | 0x0A | null - Regular Expr. | 0x0B | still unsupported - DB Pointer | 0x0C | still unsupported - JavaScript Code | 0x0D | still unsupported - Symbol | 0x0E | still unsupported - JavaScript Code | 0x0F | still unsupported - int32 | 0x10 | number_integer - Timestamp | 0x11 | still unsupported - 128-bit decimal float | 0x13 | still unsupported - Max Key | 0x7F | still unsupported - Min Key | 0xFF | still unsupported - - @warning The mapping is **incomplete**. The unsupported mappings - are indicated in the table above. - - @param[in] i an input in BSON format convertible to an input adapter - @param[in] strict whether to expect the input to be consumed until EOF - (true by default) - @param[in] allow_exceptions whether to throw exceptions in case of a - parse error (optional, true by default) - - @return deserialized JSON value; in case of a parse error and - @a allow_exceptions set to `false`, the return value will be - value_t::discarded. - - @throw parse_error.114 if an unsupported BSON record type is encountered - - @complexity Linear in the size of the input @a i. - - @liveexample{The example shows the deserialization of a byte vector in - BSON format to a JSON value.,from_bson} - - @sa http://bsonspec.org/spec.html - @sa @ref to_bson(const basic_json&) for the analogous serialization - @sa @ref from_cbor(detail::input_adapter&&, const bool, const bool, const cbor_tag_handler_t) for the - related CBOR format - @sa @ref from_msgpack(detail::input_adapter&&, const bool, const bool) for - the related MessagePack format - @sa @ref from_ubjson(detail::input_adapter&&, const bool, const bool) for the - related UBJSON format - */ - template - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json from_bson(InputType&& i, - const bool strict = true, - const bool allow_exceptions = true) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = detail::input_adapter(std::forward(i)); - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::bson, &sdp, strict); - return res ? result : basic_json(value_t::discarded); - } - - /*! - @copydoc from_bson(detail::input_adapter&&, const bool, const bool) - */ - template - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json from_bson(IteratorType first, IteratorType last, - const bool strict = true, - const bool allow_exceptions = true) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = detail::input_adapter(std::move(first), std::move(last)); - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::bson, &sdp, strict); - return res ? result : basic_json(value_t::discarded); - } - - template - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len)) - static basic_json from_bson(const T* ptr, std::size_t len, - const bool strict = true, - const bool allow_exceptions = true) - { - return from_bson(ptr, ptr + len, strict, allow_exceptions); - } - - JSON_HEDLEY_WARN_UNUSED_RESULT - JSON_HEDLEY_DEPRECATED_FOR(3.8.0, from_bson(ptr, ptr + len)) - static basic_json from_bson(detail::span_input_adapter&& i, - const bool strict = true, - const bool allow_exceptions = true) - { - basic_json result; - detail::json_sax_dom_parser sdp(result, allow_exceptions); - auto ia = i.get(); - const bool res = binary_reader(std::move(ia)).sax_parse(input_format_t::bson, &sdp, strict); - return res ? result : basic_json(value_t::discarded); - } - /// @} - - ////////////////////////// - // JSON Pointer support // - ////////////////////////// - - /// @name JSON Pointer functions - /// @{ - - /*! - @brief access specified element via JSON Pointer - - Uses a JSON pointer to retrieve a reference to the respective JSON value. - No bound checking is performed. Similar to @ref operator[](const typename - object_t::key_type&), `null` values are created in arrays and objects if - necessary. - - In particular: - - If the JSON pointer points to an object key that does not exist, it - is created an filled with a `null` value before a reference to it - is returned. - - If the JSON pointer points to an array index that does not exist, it - is created an filled with a `null` value before a reference to it - is returned. All indices between the current maximum and the given - index are also filled with `null`. - - The special value `-` is treated as a synonym for the index past the - end. - - @param[in] ptr a JSON pointer - - @return reference to the element pointed to by @a ptr - - @complexity Constant. - - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index was not a number - @throw out_of_range.404 if the JSON pointer can not be resolved - - @liveexample{The behavior is shown in the example.,operatorjson_pointer} - - @since version 2.0.0 - */ - reference operator[](const json_pointer& ptr) - { - return ptr.get_unchecked(this); - } - - /*! - @brief access specified element via JSON Pointer - - Uses a JSON pointer to retrieve a reference to the respective JSON value. - No bound checking is performed. The function does not change the JSON - value; no `null` values are created. In particular, the special value - `-` yields an exception. - - @param[in] ptr JSON pointer to the desired element - - @return const reference to the element pointed to by @a ptr - - @complexity Constant. - - @throw parse_error.106 if an array index begins with '0' - @throw parse_error.109 if an array index was not a number - @throw out_of_range.402 if the array index '-' is used - @throw out_of_range.404 if the JSON pointer can not be resolved - - @liveexample{The behavior is shown in the example.,operatorjson_pointer_const} - - @since version 2.0.0 - */ - const_reference operator[](const json_pointer& ptr) const - { - return ptr.get_unchecked(this); - } - - /*! - @brief access specified element via JSON Pointer - - Returns a reference to the element at with specified JSON pointer @a ptr, - with bounds checking. - - @param[in] ptr JSON pointer to the desired element - - @return reference to the element pointed to by @a ptr - - @throw parse_error.106 if an array index in the passed JSON pointer @a ptr - begins with '0'. See example below. - - @throw parse_error.109 if an array index in the passed JSON pointer @a ptr - is not a number. See example below. - - @throw out_of_range.401 if an array index in the passed JSON pointer @a ptr - is out of range. See example below. - - @throw out_of_range.402 if the array index '-' is used in the passed JSON - pointer @a ptr. As `at` provides checked access (and no elements are - implicitly inserted), the index '-' is always invalid. See example below. - - @throw out_of_range.403 if the JSON pointer describes a key of an object - which cannot be found. See example below. - - @throw out_of_range.404 if the JSON pointer @a ptr can not be resolved. - See example below. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes in the JSON value. - - @complexity Constant. - - @since version 2.0.0 - - @liveexample{The behavior is shown in the example.,at_json_pointer} - */ - reference at(const json_pointer& ptr) - { - return ptr.get_checked(this); - } - - /*! - @brief access specified element via JSON Pointer - - Returns a const reference to the element at with specified JSON pointer @a - ptr, with bounds checking. - - @param[in] ptr JSON pointer to the desired element - - @return reference to the element pointed to by @a ptr - - @throw parse_error.106 if an array index in the passed JSON pointer @a ptr - begins with '0'. See example below. - - @throw parse_error.109 if an array index in the passed JSON pointer @a ptr - is not a number. See example below. - - @throw out_of_range.401 if an array index in the passed JSON pointer @a ptr - is out of range. See example below. - - @throw out_of_range.402 if the array index '-' is used in the passed JSON - pointer @a ptr. As `at` provides checked access (and no elements are - implicitly inserted), the index '-' is always invalid. See example below. - - @throw out_of_range.403 if the JSON pointer describes a key of an object - which cannot be found. See example below. - - @throw out_of_range.404 if the JSON pointer @a ptr can not be resolved. - See example below. - - @exceptionsafety Strong guarantee: if an exception is thrown, there are no - changes in the JSON value. - - @complexity Constant. - - @since version 2.0.0 - - @liveexample{The behavior is shown in the example.,at_json_pointer_const} - */ - const_reference at(const json_pointer& ptr) const - { - return ptr.get_checked(this); - } - - /*! - @brief return flattened JSON value - - The function creates a JSON object whose keys are JSON pointers (see [RFC - 6901](https://tools.ietf.org/html/rfc6901)) and whose values are all - primitive. The original JSON value can be restored using the @ref - unflatten() function. - - @return an object that maps JSON pointers to primitive values - - @note Empty objects and arrays are flattened to `null` and will not be - reconstructed correctly by the @ref unflatten() function. - - @complexity Linear in the size the JSON value. - - @liveexample{The following code shows how a JSON object is flattened to an - object whose keys consist of JSON pointers.,flatten} - - @sa @ref unflatten() for the reverse function - - @since version 2.0.0 - */ - basic_json flatten() const - { - basic_json result(value_t::object); - json_pointer::flatten("", *this, result); - return result; - } - - /*! - @brief unflatten a previously flattened JSON value - - The function restores the arbitrary nesting of a JSON value that has been - flattened before using the @ref flatten() function. The JSON value must - meet certain constraints: - 1. The value must be an object. - 2. The keys must be JSON pointers (see - [RFC 6901](https://tools.ietf.org/html/rfc6901)) - 3. The mapped values must be primitive JSON types. - - @return the original JSON from a flattened version - - @note Empty objects and arrays are flattened by @ref flatten() to `null` - values and can not unflattened to their original type. Apart from - this example, for a JSON value `j`, the following is always true: - `j == j.flatten().unflatten()`. - - @complexity Linear in the size the JSON value. - - @throw type_error.314 if value is not an object - @throw type_error.315 if object values are not primitive - - @liveexample{The following code shows how a flattened JSON object is - unflattened into the original nested JSON object.,unflatten} - - @sa @ref flatten() for the reverse function - - @since version 2.0.0 - */ - basic_json unflatten() const - { - return json_pointer::unflatten(*this); - } - - /// @} - - ////////////////////////// - // JSON Patch functions // - ////////////////////////// - - /// @name JSON Patch functions - /// @{ - - /*! - @brief applies a JSON patch - - [JSON Patch](http://jsonpatch.com) defines a JSON document structure for - expressing a sequence of operations to apply to a JSON) document. With - this function, a JSON Patch is applied to the current JSON value by - executing all operations from the patch. - - @param[in] json_patch JSON patch document - @return patched document - - @note The application of a patch is atomic: Either all operations succeed - and the patched document is returned or an exception is thrown. In - any case, the original value is not changed: the patch is applied - to a copy of the value. - - @throw parse_error.104 if the JSON patch does not consist of an array of - objects - - @throw parse_error.105 if the JSON patch is malformed (e.g., mandatory - attributes are missing); example: `"operation add must have member path"` - - @throw out_of_range.401 if an array index is out of range. - - @throw out_of_range.403 if a JSON pointer inside the patch could not be - resolved successfully in the current JSON value; example: `"key baz not - found"` - - @throw out_of_range.405 if JSON pointer has no parent ("add", "remove", - "move") - - @throw other_error.501 if "test" operation was unsuccessful - - @complexity Linear in the size of the JSON value and the length of the - JSON patch. As usually only a fraction of the JSON value is affected by - the patch, the complexity can usually be neglected. - - @liveexample{The following code shows how a JSON patch is applied to a - value.,patch} - - @sa @ref diff -- create a JSON patch by comparing two JSON values - - @sa [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902) - @sa [RFC 6901 (JSON Pointer)](https://tools.ietf.org/html/rfc6901) - - @since version 2.0.0 - */ - basic_json patch(const basic_json& json_patch) const - { - // make a working copy to apply the patch to - basic_json result = *this; - - // the valid JSON Patch operations - enum class patch_operations {add, remove, replace, move, copy, test, invalid}; - - const auto get_op = [](const std::string & op) - { - if (op == "add") - { - return patch_operations::add; - } - if (op == "remove") - { - return patch_operations::remove; - } - if (op == "replace") - { - return patch_operations::replace; - } - if (op == "move") - { - return patch_operations::move; - } - if (op == "copy") - { - return patch_operations::copy; - } - if (op == "test") - { - return patch_operations::test; - } - - return patch_operations::invalid; - }; - - // wrapper for "add" operation; add value at ptr - const auto operation_add = [&result](json_pointer & ptr, basic_json val) - { - // adding to the root of the target document means replacing it - if (ptr.empty()) - { - result = val; - return; - } - - // make sure the top element of the pointer exists - json_pointer top_pointer = ptr.top(); - if (top_pointer != ptr) - { - result.at(top_pointer); - } - - // get reference to parent of JSON pointer ptr - const auto last_path = ptr.back(); - ptr.pop_back(); - basic_json& parent = result[ptr]; - - switch (parent.m_type) - { - case value_t::null: - case value_t::object: - { - // use operator[] to add value - parent[last_path] = val; - break; - } - - case value_t::array: - { - if (last_path == "-") - { - // special case: append to back - parent.push_back(val); - } - else - { - const auto idx = json_pointer::array_index(last_path); - if (JSON_HEDLEY_UNLIKELY(idx > parent.size())) - { - // avoid undefined behavior - JSON_THROW(out_of_range::create(401, "array index " + std::to_string(idx) + " is out of range", parent)); - } - - // default case: insert add offset - parent.insert(parent.begin() + static_cast(idx), val); - } - break; - } - - // if there exists a parent it cannot be primitive - default: // LCOV_EXCL_LINE - JSON_ASSERT(false); // LCOV_EXCL_LINE - } - }; - - // wrapper for "remove" operation; remove value at ptr - const auto operation_remove = [this, &result](json_pointer & ptr) - { - // get reference to parent of JSON pointer ptr - const auto last_path = ptr.back(); - ptr.pop_back(); - basic_json& parent = result.at(ptr); - - // remove child - if (parent.is_object()) - { - // perform range check - auto it = parent.find(last_path); - if (JSON_HEDLEY_LIKELY(it != parent.end())) - { - parent.erase(it); - } - else - { - JSON_THROW(out_of_range::create(403, "key '" + last_path + "' not found", *this)); - } - } - else if (parent.is_array()) - { - // note erase performs range check - parent.erase(json_pointer::array_index(last_path)); - } - }; - - // type check: top level value must be an array - if (JSON_HEDLEY_UNLIKELY(!json_patch.is_array())) - { - JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects", json_patch)); - } - - // iterate and apply the operations - for (const auto& val : json_patch) - { - // wrapper to get a value for an operation - const auto get_value = [&val](const std::string & op, - const std::string & member, - bool string_type) -> basic_json & - { - // find value - auto it = val.m_value.object->find(member); - - // context-sensitive error message - const auto error_msg = (op == "op") ? "operation" : "operation '" + op + "'"; - - // check if desired value is present - if (JSON_HEDLEY_UNLIKELY(it == val.m_value.object->end())) - { - JSON_THROW(parse_error::create(105, 0, error_msg + " must have member '" + member + "'", val)); - } - - // check if result is of type string - if (JSON_HEDLEY_UNLIKELY(string_type && !it->second.is_string())) - { - JSON_THROW(parse_error::create(105, 0, error_msg + " must have string member '" + member + "'", val)); - } - - // no error: return value - return it->second; - }; - - // type check: every element of the array must be an object - if (JSON_HEDLEY_UNLIKELY(!val.is_object())) - { - JSON_THROW(parse_error::create(104, 0, "JSON patch must be an array of objects", val)); - } - - // collect mandatory members - const auto op = get_value("op", "op", true).template get(); - const auto path = get_value(op, "path", true).template get(); - json_pointer ptr(path); - - switch (get_op(op)) - { - case patch_operations::add: - { - operation_add(ptr, get_value("add", "value", false)); - break; - } - - case patch_operations::remove: - { - operation_remove(ptr); - break; - } - - case patch_operations::replace: - { - // the "path" location must exist - use at() - result.at(ptr) = get_value("replace", "value", false); - break; - } - - case patch_operations::move: - { - const auto from_path = get_value("move", "from", true).template get(); - json_pointer from_ptr(from_path); - - // the "from" location must exist - use at() - basic_json v = result.at(from_ptr); - - // The move operation is functionally identical to a - // "remove" operation on the "from" location, followed - // immediately by an "add" operation at the target - // location with the value that was just removed. - operation_remove(from_ptr); - operation_add(ptr, v); - break; - } - - case patch_operations::copy: - { - const auto from_path = get_value("copy", "from", true).template get(); - const json_pointer from_ptr(from_path); - - // the "from" location must exist - use at() - basic_json v = result.at(from_ptr); - - // The copy is functionally identical to an "add" - // operation at the target location using the value - // specified in the "from" member. - operation_add(ptr, v); - break; - } - - case patch_operations::test: - { - bool success = false; - JSON_TRY - { - // check if "value" matches the one at "path" - // the "path" location must exist - use at() - success = (result.at(ptr) == get_value("test", "value", false)); - } - JSON_INTERNAL_CATCH (out_of_range&) - { - // ignore out of range errors: success remains false - } - - // throw an exception if test fails - if (JSON_HEDLEY_UNLIKELY(!success)) - { - JSON_THROW(other_error::create(501, "unsuccessful: " + val.dump(), val)); - } - - break; - } - - default: - { - // op must be "add", "remove", "replace", "move", "copy", or - // "test" - JSON_THROW(parse_error::create(105, 0, "operation value '" + op + "' is invalid", val)); - } - } - } - - return result; - } - - /*! - @brief creates a diff as a JSON patch - - Creates a [JSON Patch](http://jsonpatch.com) so that value @a source can - be changed into the value @a target by calling @ref patch function. - - @invariant For two JSON values @a source and @a target, the following code - yields always `true`: - @code {.cpp} - source.patch(diff(source, target)) == target; - @endcode - - @note Currently, only `remove`, `add`, and `replace` operations are - generated. - - @param[in] source JSON value to compare from - @param[in] target JSON value to compare against - @param[in] path helper value to create JSON pointers - - @return a JSON patch to convert the @a source to @a target - - @complexity Linear in the lengths of @a source and @a target. - - @liveexample{The following code shows how a JSON patch is created as a - diff for two JSON values.,diff} - - @sa @ref patch -- apply a JSON patch - @sa @ref merge_patch -- apply a JSON Merge Patch - - @sa [RFC 6902 (JSON Patch)](https://tools.ietf.org/html/rfc6902) - - @since version 2.0.0 - */ - JSON_HEDLEY_WARN_UNUSED_RESULT - static basic_json diff(const basic_json& source, const basic_json& target, - const std::string& path = "") - { - // the patch - basic_json result(value_t::array); - - // if the values are the same, return empty patch - if (source == target) - { - return result; - } - - if (source.type() != target.type()) - { - // different types: replace value - result.push_back( - { - {"op", "replace"}, {"path", path}, {"value", target} - }); - return result; - } - - switch (source.type()) - { - case value_t::array: - { - // first pass: traverse common elements - std::size_t i = 0; - while (i < source.size() && i < target.size()) - { - // recursive call to compare array values at index i - auto temp_diff = diff(source[i], target[i], path + "/" + std::to_string(i)); - result.insert(result.end(), temp_diff.begin(), temp_diff.end()); - ++i; - } - - // i now reached the end of at least one array - // in a second pass, traverse the remaining elements - - // remove my remaining elements - const auto end_index = static_cast(result.size()); - while (i < source.size()) - { - // add operations in reverse order to avoid invalid - // indices - result.insert(result.begin() + end_index, object( - { - {"op", "remove"}, - {"path", path + "/" + std::to_string(i)} - })); - ++i; - } - - // add other remaining elements - while (i < target.size()) - { - result.push_back( - { - {"op", "add"}, - {"path", path + "/-"}, - {"value", target[i]} - }); - ++i; - } - - break; - } - - case value_t::object: - { - // first pass: traverse this object's elements - for (auto it = source.cbegin(); it != source.cend(); ++it) - { - // escape the key name to be used in a JSON patch - const auto key = detail::escape(it.key()); - - if (target.find(it.key()) != target.end()) - { - // recursive call to compare object values at key it - auto temp_diff = diff(it.value(), target[it.key()], path + "/" + key); - result.insert(result.end(), temp_diff.begin(), temp_diff.end()); - } - else - { - // found a key that is not in o -> remove it - result.push_back(object( - { - {"op", "remove"}, {"path", path + "/" + key} - })); - } - } - - // second pass: traverse other object's elements - for (auto it = target.cbegin(); it != target.cend(); ++it) - { - if (source.find(it.key()) == source.end()) - { - // found a key that is not in this -> add it - const auto key = detail::escape(it.key()); - result.push_back( - { - {"op", "add"}, {"path", path + "/" + key}, - {"value", it.value()} - }); - } - } - - break; - } - - default: - { - // both primitive type: replace value - result.push_back( - { - {"op", "replace"}, {"path", path}, {"value", target} - }); - break; - } - } - - return result; - } - - /// @} - - //////////////////////////////// - // JSON Merge Patch functions // - //////////////////////////////// - - /// @name JSON Merge Patch functions - /// @{ - - /*! - @brief applies a JSON Merge Patch - - The merge patch format is primarily intended for use with the HTTP PATCH - method as a means of describing a set of modifications to a target - resource's content. This function applies a merge patch to the current - JSON value. - - The function implements the following algorithm from Section 2 of - [RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396): - - ``` - define MergePatch(Target, Patch): - if Patch is an Object: - if Target is not an Object: - Target = {} // Ignore the contents and set it to an empty Object - for each Name/Value pair in Patch: - if Value is null: - if Name exists in Target: - remove the Name/Value pair from Target - else: - Target[Name] = MergePatch(Target[Name], Value) - return Target - else: - return Patch - ``` - - Thereby, `Target` is the current object; that is, the patch is applied to - the current value. - - @param[in] apply_patch the patch to apply - - @complexity Linear in the lengths of @a patch. - - @liveexample{The following code shows how a JSON Merge Patch is applied to - a JSON document.,merge_patch} - - @sa @ref patch -- apply a JSON patch - @sa [RFC 7396 (JSON Merge Patch)](https://tools.ietf.org/html/rfc7396) - - @since version 3.0.0 - */ - void merge_patch(const basic_json& apply_patch) - { - if (apply_patch.is_object()) - { - if (!is_object()) - { - *this = object(); - } - for (auto it = apply_patch.begin(); it != apply_patch.end(); ++it) - { - if (it.value().is_null()) - { - erase(it.key()); - } - else - { - operator[](it.key()).merge_patch(it.value()); - } - } - } - else - { - *this = apply_patch; - } - } - - /// @} -}; - -/*! -@brief user-defined to_string function for JSON values - -This function implements a user-defined to_string for JSON objects. - -@param[in] j a JSON object -@return a std::string object -*/ - -NLOHMANN_BASIC_JSON_TPL_DECLARATION -std::string to_string(const NLOHMANN_BASIC_JSON_TPL& j) -{ - return j.dump(); -} -} // namespace nlohmann - -/////////////////////// -// nonmember support // -/////////////////////// - -// specialization of std::swap, and std::hash -namespace std -{ - -/// hash value for JSON objects -template<> -struct hash -{ - /*! - @brief return a hash value for a JSON object - - @since version 1.0.0 - */ - std::size_t operator()(const nlohmann::json& j) const - { - return nlohmann::detail::hash(j); - } -}; - -/// specialization for std::less -/// @note: do not remove the space after '<', -/// see https://github.com/nlohmann/json/pull/679 -template<> -struct less<::nlohmann::detail::value_t> -{ - /*! - @brief compare two value_t enum values - @since version 3.0.0 - */ - bool operator()(nlohmann::detail::value_t lhs, - nlohmann::detail::value_t rhs) const noexcept - { - return nlohmann::detail::operator<(lhs, rhs); - } -}; - -// C++20 prohibit function specialization in the std namespace. -#ifndef JSON_HAS_CPP_20 - -/*! -@brief exchanges the values of two JSON objects - -@since version 1.0.0 -*/ -template<> -inline void swap(nlohmann::json& j1, nlohmann::json& j2) noexcept( - is_nothrow_move_constructible::value&& - is_nothrow_move_assignable::value - ) -{ - j1.swap(j2); -} - -#endif - -} // namespace std - -/*! -@brief user-defined string literal for JSON values - -This operator implements a user-defined string literal for JSON objects. It -can be used by adding `"_json"` to a string literal and returns a JSON object -if no parse error occurred. - -@param[in] s a string representation of a JSON object -@param[in] n the length of string @a s -@return a JSON object - -@since version 1.0.0 -*/ -JSON_HEDLEY_NON_NULL(1) -inline nlohmann::json operator "" _json(const char* s, std::size_t n) -{ - return nlohmann::json::parse(s, s + n); -} - -/*! -@brief user-defined string literal for JSON pointer - -This operator implements a user-defined string literal for JSON Pointers. It -can be used by adding `"_json_pointer"` to a string literal and returns a JSON pointer -object if no parse error occurred. - -@param[in] s a string representation of a JSON Pointer -@param[in] n the length of string @a s -@return a JSON pointer object - -@since version 2.0.0 -*/ -JSON_HEDLEY_NON_NULL(1) -inline nlohmann::json::json_pointer operator "" _json_pointer(const char* s, std::size_t n) -{ - return nlohmann::json::json_pointer(std::string(s, n)); -} - -// #include - - -// restore GCC/clang diagnostic settings -#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) - #pragma GCC diagnostic pop -#endif -#if defined(__clang__) - #pragma GCC diagnostic pop -#endif - -// clean up -#undef JSON_ASSERT -#undef JSON_INTERNAL_CATCH -#undef JSON_CATCH -#undef JSON_THROW -#undef JSON_TRY -#undef JSON_PRIVATE_UNLESS_TESTED -#undef JSON_HAS_CPP_14 -#undef JSON_HAS_CPP_17 -#undef NLOHMANN_BASIC_JSON_TPL_DECLARATION -#undef NLOHMANN_BASIC_JSON_TPL -#undef JSON_EXPLICIT - -// #include -#undef JSON_HEDLEY_ALWAYS_INLINE -#undef JSON_HEDLEY_ARM_VERSION -#undef JSON_HEDLEY_ARM_VERSION_CHECK -#undef JSON_HEDLEY_ARRAY_PARAM -#undef JSON_HEDLEY_ASSUME -#undef JSON_HEDLEY_BEGIN_C_DECLS -#undef JSON_HEDLEY_CLANG_HAS_ATTRIBUTE -#undef JSON_HEDLEY_CLANG_HAS_BUILTIN -#undef JSON_HEDLEY_CLANG_HAS_CPP_ATTRIBUTE -#undef JSON_HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE -#undef JSON_HEDLEY_CLANG_HAS_EXTENSION -#undef JSON_HEDLEY_CLANG_HAS_FEATURE -#undef JSON_HEDLEY_CLANG_HAS_WARNING -#undef JSON_HEDLEY_COMPCERT_VERSION -#undef JSON_HEDLEY_COMPCERT_VERSION_CHECK -#undef JSON_HEDLEY_CONCAT -#undef JSON_HEDLEY_CONCAT3 -#undef JSON_HEDLEY_CONCAT3_EX -#undef JSON_HEDLEY_CONCAT_EX -#undef JSON_HEDLEY_CONST -#undef JSON_HEDLEY_CONSTEXPR -#undef JSON_HEDLEY_CONST_CAST -#undef JSON_HEDLEY_CPP_CAST -#undef JSON_HEDLEY_CRAY_VERSION -#undef JSON_HEDLEY_CRAY_VERSION_CHECK -#undef JSON_HEDLEY_C_DECL -#undef JSON_HEDLEY_DEPRECATED -#undef JSON_HEDLEY_DEPRECATED_FOR -#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL -#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ -#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED -#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES -#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS -#undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION -#undef JSON_HEDLEY_DIAGNOSTIC_POP -#undef JSON_HEDLEY_DIAGNOSTIC_PUSH -#undef JSON_HEDLEY_DMC_VERSION -#undef JSON_HEDLEY_DMC_VERSION_CHECK -#undef JSON_HEDLEY_EMPTY_BASES -#undef JSON_HEDLEY_EMSCRIPTEN_VERSION -#undef JSON_HEDLEY_EMSCRIPTEN_VERSION_CHECK -#undef JSON_HEDLEY_END_C_DECLS -#undef JSON_HEDLEY_FLAGS -#undef JSON_HEDLEY_FLAGS_CAST -#undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE -#undef JSON_HEDLEY_GCC_HAS_BUILTIN -#undef JSON_HEDLEY_GCC_HAS_CPP_ATTRIBUTE -#undef JSON_HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE -#undef JSON_HEDLEY_GCC_HAS_EXTENSION -#undef JSON_HEDLEY_GCC_HAS_FEATURE -#undef JSON_HEDLEY_GCC_HAS_WARNING -#undef JSON_HEDLEY_GCC_NOT_CLANG_VERSION_CHECK -#undef JSON_HEDLEY_GCC_VERSION -#undef JSON_HEDLEY_GCC_VERSION_CHECK -#undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE -#undef JSON_HEDLEY_GNUC_HAS_BUILTIN -#undef JSON_HEDLEY_GNUC_HAS_CPP_ATTRIBUTE -#undef JSON_HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE -#undef JSON_HEDLEY_GNUC_HAS_EXTENSION -#undef JSON_HEDLEY_GNUC_HAS_FEATURE -#undef JSON_HEDLEY_GNUC_HAS_WARNING -#undef JSON_HEDLEY_GNUC_VERSION -#undef JSON_HEDLEY_GNUC_VERSION_CHECK -#undef JSON_HEDLEY_HAS_ATTRIBUTE -#undef JSON_HEDLEY_HAS_BUILTIN -#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE -#undef JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS -#undef JSON_HEDLEY_HAS_DECLSPEC_ATTRIBUTE -#undef JSON_HEDLEY_HAS_EXTENSION -#undef JSON_HEDLEY_HAS_FEATURE -#undef JSON_HEDLEY_HAS_WARNING -#undef JSON_HEDLEY_IAR_VERSION -#undef JSON_HEDLEY_IAR_VERSION_CHECK -#undef JSON_HEDLEY_IBM_VERSION -#undef JSON_HEDLEY_IBM_VERSION_CHECK -#undef JSON_HEDLEY_IMPORT -#undef JSON_HEDLEY_INLINE -#undef JSON_HEDLEY_INTEL_CL_VERSION -#undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK -#undef JSON_HEDLEY_INTEL_VERSION -#undef JSON_HEDLEY_INTEL_VERSION_CHECK -#undef JSON_HEDLEY_IS_CONSTANT -#undef JSON_HEDLEY_IS_CONSTEXPR_ -#undef JSON_HEDLEY_LIKELY -#undef JSON_HEDLEY_MALLOC -#undef JSON_HEDLEY_MCST_LCC_VERSION -#undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK -#undef JSON_HEDLEY_MESSAGE -#undef JSON_HEDLEY_MSVC_VERSION -#undef JSON_HEDLEY_MSVC_VERSION_CHECK -#undef JSON_HEDLEY_NEVER_INLINE -#undef JSON_HEDLEY_NON_NULL -#undef JSON_HEDLEY_NO_ESCAPE -#undef JSON_HEDLEY_NO_RETURN -#undef JSON_HEDLEY_NO_THROW -#undef JSON_HEDLEY_NULL -#undef JSON_HEDLEY_PELLES_VERSION -#undef JSON_HEDLEY_PELLES_VERSION_CHECK -#undef JSON_HEDLEY_PGI_VERSION -#undef JSON_HEDLEY_PGI_VERSION_CHECK -#undef JSON_HEDLEY_PREDICT -#undef JSON_HEDLEY_PRINTF_FORMAT -#undef JSON_HEDLEY_PRIVATE -#undef JSON_HEDLEY_PUBLIC -#undef JSON_HEDLEY_PURE -#undef JSON_HEDLEY_REINTERPRET_CAST -#undef JSON_HEDLEY_REQUIRE -#undef JSON_HEDLEY_REQUIRE_CONSTEXPR -#undef JSON_HEDLEY_REQUIRE_MSG -#undef JSON_HEDLEY_RESTRICT -#undef JSON_HEDLEY_RETURNS_NON_NULL -#undef JSON_HEDLEY_SENTINEL -#undef JSON_HEDLEY_STATIC_ASSERT -#undef JSON_HEDLEY_STATIC_CAST -#undef JSON_HEDLEY_STRINGIFY -#undef JSON_HEDLEY_STRINGIFY_EX -#undef JSON_HEDLEY_SUNPRO_VERSION -#undef JSON_HEDLEY_SUNPRO_VERSION_CHECK -#undef JSON_HEDLEY_TINYC_VERSION -#undef JSON_HEDLEY_TINYC_VERSION_CHECK -#undef JSON_HEDLEY_TI_ARMCL_VERSION -#undef JSON_HEDLEY_TI_ARMCL_VERSION_CHECK -#undef JSON_HEDLEY_TI_CL2000_VERSION -#undef JSON_HEDLEY_TI_CL2000_VERSION_CHECK -#undef JSON_HEDLEY_TI_CL430_VERSION -#undef JSON_HEDLEY_TI_CL430_VERSION_CHECK -#undef JSON_HEDLEY_TI_CL6X_VERSION -#undef JSON_HEDLEY_TI_CL6X_VERSION_CHECK -#undef JSON_HEDLEY_TI_CL7X_VERSION -#undef JSON_HEDLEY_TI_CL7X_VERSION_CHECK -#undef JSON_HEDLEY_TI_CLPRU_VERSION -#undef JSON_HEDLEY_TI_CLPRU_VERSION_CHECK -#undef JSON_HEDLEY_TI_VERSION -#undef JSON_HEDLEY_TI_VERSION_CHECK -#undef JSON_HEDLEY_UNAVAILABLE -#undef JSON_HEDLEY_UNLIKELY -#undef JSON_HEDLEY_UNPREDICTABLE -#undef JSON_HEDLEY_UNREACHABLE -#undef JSON_HEDLEY_UNREACHABLE_RETURN -#undef JSON_HEDLEY_VERSION -#undef JSON_HEDLEY_VERSION_DECODE_MAJOR -#undef JSON_HEDLEY_VERSION_DECODE_MINOR -#undef JSON_HEDLEY_VERSION_DECODE_REVISION -#undef JSON_HEDLEY_VERSION_ENCODE -#undef JSON_HEDLEY_WARNING -#undef JSON_HEDLEY_WARN_UNUSED_RESULT -#undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG -#undef JSON_HEDLEY_FALL_THROUGH - - - -#endif // INCLUDE_NLOHMANN_JSON_HPP_ diff --git a/xess/samples/xess_demo/MiniEngine/ModelConverter/IndexOptimizePostTransform.cpp b/xess/samples/xess_demo/MiniEngine/ModelConverter/IndexOptimizePostTransform.cpp deleted file mode 100644 index c95ed66..0000000 --- a/xess/samples/xess_demo/MiniEngine/ModelConverter/IndexOptimizePostTransform.cpp +++ /dev/null @@ -1,463 +0,0 @@ -//----------------------------------------------------------------------------- -// This is an implementation of Tom Forsyth's "Linear-Speed Vertex Cache -// Optimization" algorithm as described here: -// https://tomforsyth1000.github.io/papers/fast_vert_cache_opt.html -// -// This code was authored and released into the public domain by -// Adrian Stone (stone@gameangst.com). -// -// THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -// SHALL ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER -// LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -//----------------------------------------------------------------------------- - -// modified from original source to improve performance (especially in debug builds), memory allocations, etc. - -#include -#include -#include -#include - -#include "IndexOptimizePostTransform.h" - -namespace -{ - // code for computing vertex score was taken, as much as possible - // directly from the original publication. - float ComputeVertexCacheScore(int cachePosition, uint32_t vertexCacheSize) - { - const float FindVertexScore_CacheDecayPower = 1.5f; - const float FindVertexScore_LastTriScore = 0.75f; - - float score = 0.0f; - if ( cachePosition < 0 ) - { - // Vertex is not in FIFO cache - no score. - } - else - { - if ( cachePosition < 3 ) - { - // This vertex was used in the last triangle, - // so it has a fixed score, whichever of the three - // it's in. Otherwise, you can get very different - // answers depending on whether you add - // the triangle 1,2,3 or 3,1,2 - which is silly. - score = FindVertexScore_LastTriScore; - } - else - { - assert ( cachePosition < int(vertexCacheSize) ); - // Points for being high in the cache. - const float scaler = 1.0f / ( vertexCacheSize - 3 ); - score = 1.0f - ( cachePosition - 3 ) * scaler; - score = powf ( score, FindVertexScore_CacheDecayPower ); - } - } - - return score; - } - - float ComputeVertexValenceScore(uint32_t numActiveFaces) - { - const float FindVertexScore_ValenceBoostScale = 2.0f; - const float FindVertexScore_ValenceBoostPower = 0.5f; - - float score = 0.f; - - // Bonus points for having a low number of tris still to - // use the vert, so we get rid of lone verts quickly. - float valenceBoost = powf ( static_cast(numActiveFaces), - -FindVertexScore_ValenceBoostPower ); - score += FindVertexScore_ValenceBoostScale * valenceBoost; - - return score; - } - - - enum {kMaxVertexCacheSize = 64}; - enum {kMaxPrecomputedVertexValenceScores = 64}; - float s_vertexCacheScores[kMaxVertexCacheSize+1][kMaxVertexCacheSize]; - float s_vertexValenceScores[kMaxPrecomputedVertexValenceScores]; - - bool ComputeVertexScores() - { - for (uint32_t cacheSize=0; cacheSize<=kMaxVertexCacheSize; ++cacheSize) - { - for (uint32_t cachePos=0; cachePos - struct OptimizeVertexData - { - float score; - uint32_t activeFaceListStart; - uint32_t activeFaceListSize; - IndexType cachePos0; - IndexType cachePos1; - OptimizeVertexData() : score(0.f), activeFaceListStart(0), activeFaceListSize(0), cachePos0(0), cachePos1(0) { } - }; -} - -template -struct IndexSortCompareIndexed -{ - const IndexType *_indexData; - - IndexSortCompareIndexed(const IndexType *indexData) - : _indexData(indexData) - { - } - - bool operator()(T a, T b) const - { - IndexType indexA = _indexData[a]; - IndexType indexB = _indexData[b]; - - if (indexA < indexB) - return true; - return false; - } -}; - -template -struct FaceValenceSort -{ - const OptimizeVertexData *_vertexData; - - FaceValenceSort(const OptimizeVertexData *vertexData) - : _vertexData(vertexData) - { - } - - bool operator()(T a, T b) const - { - const OptimizeVertexData *vA0 = _vertexData + a * 3 + 0; - const OptimizeVertexData *vA1 = _vertexData + a * 3 + 1; - const OptimizeVertexData *vA2 = _vertexData + a * 3 + 2; - const OptimizeVertexData *vB0 = _vertexData + b * 3 + 0; - const OptimizeVertexData *vB1 = _vertexData + b * 3 + 1; - const OptimizeVertexData *vB2 = _vertexData + b * 3 + 2; - - int aValence = vA0->activeFaceListSize + vA1->activeFaceListSize + vA2->activeFaceListSize; - int bValence = vB0->activeFaceListSize + vB1->activeFaceListSize + vB2->activeFaceListSize; - - // higher scoring faces are those with lower valence totals - // reverse sort (reverse of reverse) - if (aValence < bValence) - return true; - return false; - } -}; - -//----------------------------------------------------------------------------- -// OptimizeFaces -//----------------------------------------------------------------------------- -// Parameters: -// indexList -// input index list -// indexCount -// the number of indices in the list -// vertexCount -// the largest index value in indexList -// newIndexList -// a pointer to a preallocated buffer the same size as indexList to -// hold the optimized index list -// lruCacheSize -// the size of the simulated post-transform cache (max:64) -//----------------------------------------------------------------------------- -template -void OptimizeFaces(const IndexType* indexList, uint32_t indexCount, IndexType* newIndexList, uint16_t lruCacheSize) -{ - OptimizeVertexData *vertexDataList = new OptimizeVertexData [indexCount]; // upper bounds on size is indexCount - IndexType *vertexRemap = new IndexType [indexCount]; - uint32_t *activeFaceList = new uint32_t [indexCount]; - - uint32_t faceCount = indexCount / 3; - uint8_t *processedFaceList = new uint8_t [faceCount]; - memset(processedFaceList, 0, sizeof(uint8_t) * faceCount); - unsigned int *faceSorted = new unsigned int [faceCount]; - unsigned int *faceReverseLookup = new unsigned int [faceCount]; - - // build the vertex remap table - unsigned int uniqueVertexCount = 0; - { - typedef IndexSortCompareIndexed indexSorter; - unsigned int *indexSorted = new unsigned int [indexCount]; - - for (unsigned int i = 0; i < indexCount; i++) - { - indexSorted[i] = i; - } - - indexSorter sortFunc(indexList); - std::sort(indexSorted, indexSorted + indexCount, sortFunc); - - for (unsigned int i = 0; i < indexCount; i++) - { - if (i == 0 - || sortFunc(indexSorted[i - 1], indexSorted[i])) - { - // it's not a duplicate - vertexRemap[indexSorted[i]] = uniqueVertexCount; - uniqueVertexCount++; - } - else - { - vertexRemap[indexSorted[i]] = vertexRemap[indexSorted[i - 1]]; - } - } - - delete [] indexSorted; - } - - // compute face count per vertex - for (uint32_t i=0; i& vertexData = vertexDataList[vertexRemap[i]]; - vertexData.activeFaceListSize++; - } - - const IndexType kEvictedCacheIndex = std::numeric_limits::max(); - { - // allocate face list per vertex - uint32_t curActiveFaceListPos = 0; - for (uint32_t i = 0; i < uniqueVertexCount; ++i) - { - OptimizeVertexData& vertexData = vertexDataList[i]; - vertexData.cachePos0 = kEvictedCacheIndex; - vertexData.cachePos1 = kEvictedCacheIndex; - vertexData.activeFaceListStart = curActiveFaceListPos; - curActiveFaceListPos += vertexData.activeFaceListSize; - vertexData.score = FindVertexScore(vertexData.activeFaceListSize, vertexData.cachePos0, lruCacheSize); - vertexData.activeFaceListSize = 0; - } - assert(curActiveFaceListPos == indexCount); - } - - // sort unprocessed faces by highest score - for (uint32_t f = 0; f < faceCount; f++) - { - faceSorted[f] = f; - } - FaceValenceSort faceValenceSort(vertexDataList); - std::sort(faceSorted, faceSorted + faceCount, faceValenceSort); - for (uint32_t f = 0; f < faceCount; f++) - { - faceReverseLookup[faceSorted[f]] = f; - } - - // fill out face list per vertex - for (uint32_t i=0; i& vertexData = vertexDataList[vertexRemap[i + j]]; - activeFaceList[vertexData.activeFaceListStart + vertexData.activeFaceListSize] = i; - vertexData.activeFaceListSize++; - } - } - - IndexType vertexCacheBuffer[(kMaxVertexCacheSize+3)*2]; - IndexType* cache0 = vertexCacheBuffer; - IndexType* cache1 = vertexCacheBuffer+(kMaxVertexCacheSize+3); - IndexType entriesInCache0 = 0; - - uint32_t bestFace = 0; - float bestScore = -1.f; - - const float maxValenceScore = FindVertexScore(1, kEvictedCacheIndex, lruCacheSize) * 3.f; - - unsigned int nextBestFace = 0; - for (uint32_t i = 0; i < indexCount; i += 3) - { - if (bestScore < 0.f) - { - // no verts in the cache are used by any unprocessed faces so - // search all unprocessed faces for a new starting point - for (; nextBestFace < faceCount; nextBestFace++) - { - unsigned int faceIndex = faceSorted[nextBestFace]; - if (processedFaceList[faceIndex] == 0) - { - uint32_t face = faceIndex * 3; - float faceScore = 0.f; - for (uint32_t k=0; k<3; ++k) - { - //assert(vertexData.activeFaceListSize > 0); - //assert(vertexData.cachePos0 >= lruCacheSize); - - float vertexScore = vertexDataList[vertexRemap[face + k]].score; - faceScore += vertexScore; - } - - bestScore = faceScore; - bestFace = face; - - nextBestFace++; - break; // we're searching a pre-sorted list, first one we find will be the best - } - } - assert(bestScore >= 0.f); - } - - processedFaceList[bestFace / 3] = 1; - uint16_t entriesInCache1 = 0; - - // add bestFace to LRU cache and to newIndexList - for (uint32_t v = 0; v < 3; ++v) - { - IndexType index = indexList[bestFace+v]; - newIndexList[i+v] = index; - - OptimizeVertexData& vertexData = vertexDataList[vertexRemap[bestFace + v]]; - - if (vertexData.cachePos1 >= entriesInCache1) - { - vertexData.cachePos1 = entriesInCache1; - cache1[entriesInCache1++] = vertexRemap[bestFace + v]; - - if (vertexData.activeFaceListSize == 1) - { - --vertexData.activeFaceListSize; - continue; - } - } - - assert(vertexData.activeFaceListSize > 0); - uint32_t* begin = activeFaceList + vertexData.activeFaceListStart; - uint32_t* end = activeFaceList + (vertexData.activeFaceListStart + vertexData.activeFaceListSize); - uint32_t* it = std::find(begin, end, bestFace); - assert(it != end); - std::swap(*it, *(end-1)); - --vertexData.activeFaceListSize; - vertexData.score = FindVertexScore(vertexData.activeFaceListSize, vertexData.cachePos1, lruCacheSize); - - // need to re-sort the faces that use this vertex, as their score will change due to activeFaceListSize shrinking - for (uint32_t *fi = begin; fi != end - 1; ++fi) - { - unsigned int faceIndex = *fi / 3; - - unsigned int n = faceReverseLookup[faceIndex]; - assert(faceSorted[n] == faceIndex); - - // found it, now move it up - while (n > 0) - { - if (faceValenceSort(n, n - 1)) - { - faceReverseLookup[faceSorted[n]] = n - 1; - faceReverseLookup[faceSorted[n - 1]] = n; - std::swap(faceSorted[n], faceSorted[n - 1]); - n--; - } - else - { - break; - } - } - } - } - - // move the rest of the old verts in the cache down and compute their new scores - for (uint32_t c0 = 0; c0 < entriesInCache0; ++c0) - { - OptimizeVertexData& vertexData = vertexDataList[cache0[c0]]; - - if (vertexData.cachePos1 >= entriesInCache1) - { - vertexData.cachePos1 = entriesInCache1; - cache1[entriesInCache1++] = cache0[c0]; - vertexData.score = FindVertexScore(vertexData.activeFaceListSize, vertexData.cachePos1, lruCacheSize); - // don't need to re-sort this vertex... once it gets out of the cache, it'll have its original score - } - } - - // find the best scoring triangle in the current cache (including up to 3 that were just evicted) - bestScore = -1.f; - for (uint32_t c1 = 0; c1 < entriesInCache1; ++c1) - { - OptimizeVertexData& vertexData = vertexDataList[cache1[c1]]; - vertexData.cachePos0 = vertexData.cachePos1; - vertexData.cachePos1 = kEvictedCacheIndex; - for (uint32_t j=0; j& faceVertexData = vertexDataList[vertexRemap[face + v]]; - faceScore += faceVertexData.score; - } - if (faceScore > bestScore) - { - bestScore = faceScore; - bestFace = face; - } - } - } - - std::swap(cache0, cache1); - entriesInCache0 = std::min(entriesInCache1, lruCacheSize); - } - - delete [] vertexDataList; - delete [] vertexRemap; - delete [] activeFaceList; - delete [] processedFaceList; - delete [] faceSorted; - delete [] faceReverseLookup; -} diff --git a/xess/samples/xess_demo/MiniEngine/ModelConverter/IndexOptimizePostTransform.h b/xess/samples/xess_demo/MiniEngine/ModelConverter/IndexOptimizePostTransform.h deleted file mode 100644 index d09ae75..0000000 --- a/xess/samples/xess_demo/MiniEngine/ModelConverter/IndexOptimizePostTransform.h +++ /dev/null @@ -1,34 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): Alex Nankervis -// - -#pragma once - -//----------------------------------------------------------------------------- -// OptimizeFaces -//----------------------------------------------------------------------------- -// Parameters: -// indexList -// input index list -// indexCount -// the number of indices in the list -// newIndexList -// a pointer to a preallocated buffer the same size as indexList to -// hold the optimized index list -// lruCacheSize -// the size of the simulated post-transform cache (max:64) -//----------------------------------------------------------------------------- -template -void OptimizeFaces(const IndexType* indexList, uint32_t indexCount, IndexType* newIndexList, uint16_t lruCacheSize); - -template void OptimizeFaces(const uint16_t* indexList, uint32_t indexCount, uint16_t* newIndexList, uint16_t lruCacheSize); -template void OptimizeFaces(const uint32_t* indexList, uint32_t indexCount, uint32_t* newIndexList, uint16_t lruCacheSize); diff --git a/xess/samples/xess_demo/MiniEngine/ModelConverter/Main.cpp b/xess/samples/xess_demo/MiniEngine/ModelConverter/Main.cpp deleted file mode 100644 index c689596..0000000 --- a/xess/samples/xess_demo/MiniEngine/ModelConverter/Main.cpp +++ /dev/null @@ -1,138 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): Alex Nankervis -// - -#include "ModelAssimp.h" - -#include -#include - -void PrintHelp() -{ - printf("model_convert\n"); - - printf("usage:\n"); - printf("model_convert input_file output_file\n"); -} - -void AssimpModel::PrintModelStats() -{ - printf("model stats:\n"); - - Math::AxisAlignedBox bbox = GetBoundingBox(); - printf("bounding box: <%f, %f, %f> <%f, %f, %f>\n", - (float)bbox.GetMin().GetX(), (float)bbox.GetMin().GetY(), (float)bbox.GetMin().GetZ(), - (float)bbox.GetMax().GetX(), (float)bbox.GetMax().GetY(), (float)bbox.GetMax().GetZ()); - - printf("vertex data size: %u\n", m_Header.vertexDataByteSize); - printf("index data size: %u\n", m_Header.indexDataByteSize); - printf("vertex data size depth-only: %u\n", m_Header.vertexDataByteSizeDepth); - printf("\n"); - - printf("mesh count: %u\n", m_Header.meshCount); - for (uint32_t meshIndex = 0; meshIndex < m_Header.meshCount; meshIndex++) - { - const Mesh* mesh = m_pMesh + meshIndex; - - auto printAttribFormat = [](uint32_t format) -> void - { - switch (format) - { - case attrib_format_ubyte: printf("ubyte"); break; - case attrib_format_byte: printf("byte"); break; - case attrib_format_ushort: printf("ushort"); break; - case attrib_format_short: printf("short"); break; - case attrib_format_float: printf("float"); break; - } - }; - - printf("mesh %u\n", meshIndex); - printf("vertices: %u\n", mesh->vertexCount); - printf("indices: %u\n", mesh->indexCount); - printf("vertex stride: %u\n", mesh->vertexStride); - for (int n = 0; n < maxAttribs; n++) - { - if (mesh->attrib[n].format == attrib_format_none) - continue; - - printf("attrib %d: offset %u, normalized %u, components %u, format " - , n, mesh->attrib[n].offset, mesh->attrib[n].normalized - , mesh->attrib[n].components); - printAttribFormat(mesh->attrib[n].format); - printf("\n"); - } - - printf("vertices depth-only: %u\n", mesh->vertexCountDepth); - printf("vertex stride depth-only: %u\n", mesh->vertexStrideDepth); - for (int n = 0; n < maxAttribs; n++) - { - if (mesh->attribDepth[n].format == attrib_format_none) - continue; - - printf("attrib %d: offset %u, normalized %u, components %u, format " - , n, mesh->attribDepth[n].offset, mesh->attribDepth[n].normalized - , mesh->attribDepth[n].components); - printAttribFormat(mesh->attrib[n].format); - printf("\n"); - } - } - printf("\n"); - - printf("material count: %u\n", m_Header.materialCount); - for (uint32_t materialIndex = 0; materialIndex < m_Header.materialCount; materialIndex++) - { - //const Material* material = m_pMaterial + materialIndex; - printf("material %u\n", materialIndex); - } - printf("\n"); -} - -int main(int argc, char **argv) -{ - if (argc != 3) - { - PrintHelp(); - return -1; - } - - const char *input_file = argv[1]; - const char *output_file = argv[2]; - - printf("input file %s\n", input_file); - printf("output file %s\n", output_file); - - AssimpModel model; - - printf("loading...\n"); - if (!model.Load(input_file)) - { - printf("failed to load model: %s\n", input_file); - return -1; - } - - printf("saving...\n"); - if (!model.Save(output_file)) - { - printf("failed to save model: %s\n", output_file); - return -1; - } - - printf("done\n"); - - model.PrintModelStats(); - - std::cout << "Press enter..."; - std::string trash; - std::getline(std::cin, trash); - - return 0; -} diff --git a/xess/samples/xess_demo/MiniEngine/ModelConverter/ModelAssimp.cpp b/xess/samples/xess_demo/MiniEngine/ModelConverter/ModelAssimp.cpp deleted file mode 100644 index e45d493..0000000 --- a/xess/samples/xess_demo/MiniEngine/ModelConverter/ModelAssimp.cpp +++ /dev/null @@ -1,387 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): Alex Nankervis -// - -#include "ModelAssimp.h" - -#include "../Model/ModelLoader.h" - -#include -#include -#include - -using namespace std; - -const char* AssimpModel::s_FormatString[] = -{ - "", - "h3d", - "mini" -}; -static_assert(_countof(AssimpModel::s_FormatString) == AssimpModel::formats, "s_FormatString doesn't match format enum"); - -int AssimpModel::FormatFromFilename(const string& filename) -{ - string ext = Utility::ToLower(Utility::GetFileExtension(filename)); - - for (int n = 1; n < formats; n++) - if (ext == s_FormatString[n]) - return n; - - return format_none; -} - -bool AssimpModel::Load(const string& filename) -{ - Clear(); - - bool rval = false; - bool needToOptimize = true; - switch (FormatFromFilename(filename)) - { - case format_none: - rval = LoadAssimp(filename); - break; - - case format_h3d: - rval = LoadH3D(Utility::UTF8ToWideString(filename)); - needToOptimize = false; - break; - } - - if (!rval) - return false; - - if (needToOptimize) - Optimize(); - - return true; -} - -bool AssimpModel::Save(const string& filename) const -{ - switch (FormatFromFilename(filename)) - { - default: - break; - - case format_h3d: - if (SaveH3D(Utility::UTF8ToWideString(filename))) - return true; - - case format_mini: - { - Renderer::ModelData model; - if (BuildModel(model) && Renderer::SaveModel(Utility::UTF8ToWideString(filename), model)) - return true; - } - } - - return false; -} - - -bool AssimpModel::LoadAssimp(const string& filename) -{ - Assimp::Importer importer; - - // remove unused data - importer.SetPropertyInteger(AI_CONFIG_PP_RVC_FLAGS, - aiComponent_COLORS | aiComponent_LIGHTS | aiComponent_CAMERAS); - - // max triangles and vertices per mesh, splits above this threshold - importer.SetPropertyInteger(AI_CONFIG_PP_SLM_TRIANGLE_LIMIT, INT_MAX); - importer.SetPropertyInteger(AI_CONFIG_PP_SLM_VERTEX_LIMIT, 0xfffe); // avoid the primitive restart index - - // remove points and lines - importer.SetPropertyInteger(AI_CONFIG_PP_SBP_REMOVE, aiPrimitiveType_POINT | aiPrimitiveType_LINE); - - const aiScene *scene = importer.ReadFile(filename, - aiProcess_CalcTangentSpace | - aiProcess_JoinIdenticalVertices | - aiProcess_Triangulate | - aiProcess_RemoveComponent | - aiProcess_GenSmoothNormals | - aiProcess_SplitLargeMeshes | - aiProcess_ValidateDataStructure | - //aiProcess_ImproveCacheLocality | // handled by optimizePostTransform() - aiProcess_RemoveRedundantMaterials | - aiProcess_SortByPType | - aiProcess_FindInvalidData | - aiProcess_GenUVCoords | - aiProcess_TransformUVCoords | - aiProcess_OptimizeMeshes | - aiProcess_OptimizeGraph); - - if (scene == nullptr) - return false; - - if (scene->HasTextures()) - { - // embedded textures... - } - - if (scene->HasAnimations()) - { - // todo - } - - m_Header.materialCount = scene->mNumMaterials; - m_pMaterial = new Material [m_Header.materialCount]; - memset(m_pMaterial, 0, sizeof(Material) * m_Header.materialCount); - for (unsigned int materialIndex = 0; materialIndex < scene->mNumMaterials; materialIndex++) - { - const aiMaterial *srcMat = scene->mMaterials[materialIndex]; - Material *dstMat = m_pMaterial + materialIndex; - - aiColor3D diffuse(1.0f, 1.0f, 1.0f); - aiColor3D specular(1.0f, 1.0f, 1.0f); - aiColor3D ambient(1.0f, 1.0f, 1.0f); - aiColor3D emissive(0.0f, 0.0f, 0.0f); - aiColor3D transparent(1.0f, 1.0f, 1.0f); - float opacity = 1.0f; - float shininess = 0.0f; - float specularStrength = 1.0f; - aiString texDiffusePath; - aiString texSpecularPath; - aiString texEmissivePath; - aiString texNormalPath; - aiString texLightmapPath; - aiString texReflectionPath; - srcMat->Get(AI_MATKEY_COLOR_DIFFUSE, diffuse); - srcMat->Get(AI_MATKEY_COLOR_SPECULAR, specular); - srcMat->Get(AI_MATKEY_COLOR_AMBIENT, ambient); - srcMat->Get(AI_MATKEY_COLOR_EMISSIVE, emissive); - srcMat->Get(AI_MATKEY_COLOR_TRANSPARENT, transparent); - srcMat->Get(AI_MATKEY_OPACITY, opacity); - srcMat->Get(AI_MATKEY_SHININESS, shininess); - srcMat->Get(AI_MATKEY_SHININESS_STRENGTH, specularStrength); - srcMat->Get(AI_MATKEY_TEXTURE(aiTextureType_DIFFUSE, 0), texDiffusePath); - srcMat->Get(AI_MATKEY_TEXTURE(aiTextureType_SPECULAR, 0), texSpecularPath); - srcMat->Get(AI_MATKEY_TEXTURE(aiTextureType_EMISSIVE, 0), texEmissivePath); - //srcMat->Get(AI_MATKEY_TEXTURE(aiTextureType_NORMALS, 0), texNormalPath); - srcMat->Get(AI_MATKEY_TEXTURE(aiTextureType_AMBIENT, 0), texNormalPath); - srcMat->Get(AI_MATKEY_TEXTURE(aiTextureType_LIGHTMAP, 0), texLightmapPath); - srcMat->Get(AI_MATKEY_TEXTURE(aiTextureType_REFLECTION, 0), texReflectionPath); - - dstMat->diffuse = Color(diffuse.r, diffuse.g, diffuse.b); - dstMat->specular = Color(specular.r, specular.g, specular.b); - dstMat->ambient = Color(ambient.r, ambient.g, ambient.b); - dstMat->emissive = Color(emissive.r, emissive.g, emissive.b); - dstMat->transparent = Color(transparent.r, transparent.g, transparent.b); - dstMat->opacity = opacity; - dstMat->shininess = shininess; - dstMat->specularStrength = specularStrength; - - char *pRem = nullptr; - - strncpy_s(dstMat->texDiffusePath, texDiffusePath.C_Str(), Material::maxTexPath - 1); - strncpy_s(dstMat->texSpecularPath, texSpecularPath.C_Str(), Material::maxTexPath - 1); - strncpy_s(dstMat->texEmissivePath, texEmissivePath.C_Str(), Material::maxTexPath - 1); - strncpy_s(dstMat->texNormalPath, texNormalPath.C_Str(), Material::maxTexPath - 1); - strncpy_s(dstMat->texLightmapPath, texLightmapPath.C_Str(), Material::maxTexPath - 1); - strncpy_s(dstMat->texReflectionPath, texReflectionPath.C_Str(), Material::maxTexPath - 1); - - aiString matName; - srcMat->Get(AI_MATKEY_NAME, matName); - strncpy_s(dstMat->name, matName.C_Str(), Material::maxMaterialName - 1); - } - - m_Header.meshCount = scene->mNumMeshes; - m_pMesh = new Mesh [m_Header.meshCount]; - memset(m_pMesh, 0, sizeof(Mesh) * m_Header.meshCount); - // first pass, count everything - for (unsigned int meshIndex = 0; meshIndex < scene->mNumMeshes; meshIndex++) - { - const aiMesh *srcMesh = scene->mMeshes[meshIndex]; - Mesh *dstMesh = m_pMesh + meshIndex; - - assert(srcMesh->mPrimitiveTypes == aiPrimitiveType_TRIANGLE); - - dstMesh->materialIndex = srcMesh->mMaterialIndex; - - // just store everything as float. Can quantize in Model::optimize() - dstMesh->attribsEnabled |= attrib_mask_position; - dstMesh->attrib[attrib_position].offset = dstMesh->vertexStride; - dstMesh->attrib[attrib_position].normalized = 0; - dstMesh->attrib[attrib_position].components = 3; - dstMesh->attrib[attrib_position].format = attrib_format_float; - dstMesh->vertexStride += sizeof(float) * 3; - - dstMesh->attribsEnabled |= attrib_mask_texcoord0; - dstMesh->attrib[attrib_texcoord0].offset = dstMesh->vertexStride; - dstMesh->attrib[attrib_texcoord0].normalized = 0; - dstMesh->attrib[attrib_texcoord0].components = 2; - dstMesh->attrib[attrib_texcoord0].format = attrib_format_float; - dstMesh->vertexStride += sizeof(float) * 2; - - dstMesh->attribsEnabled |= attrib_mask_normal; - dstMesh->attrib[attrib_normal].offset = dstMesh->vertexStride; - dstMesh->attrib[attrib_normal].normalized = 0; - dstMesh->attrib[attrib_normal].components = 3; - dstMesh->attrib[attrib_normal].format = attrib_format_float; - dstMesh->vertexStride += sizeof(float) * 3; - - dstMesh->attribsEnabled |= attrib_mask_tangent; - dstMesh->attrib[attrib_tangent].offset = dstMesh->vertexStride; - dstMesh->attrib[attrib_tangent].normalized = 0; - dstMesh->attrib[attrib_tangent].components = 3; - dstMesh->attrib[attrib_tangent].format = attrib_format_float; - dstMesh->vertexStride += sizeof(float) * 3; - - dstMesh->attribsEnabled |= attrib_mask_bitangent; - dstMesh->attrib[attrib_bitangent].offset = dstMesh->vertexStride; - dstMesh->attrib[attrib_bitangent].normalized = 0; - dstMesh->attrib[attrib_bitangent].components = 3; - dstMesh->attrib[attrib_bitangent].format = attrib_format_float; - dstMesh->vertexStride += sizeof(float) * 3; - - // depth-only - dstMesh->attribsEnabledDepth |= attrib_mask_position; - dstMesh->attribDepth[attrib_position].offset = dstMesh->vertexStrideDepth; - dstMesh->attribDepth[attrib_position].normalized = 0; - dstMesh->attribDepth[attrib_position].components = 3; - dstMesh->attribDepth[attrib_position].format = attrib_format_float; - dstMesh->vertexStrideDepth += sizeof(float) * 3; - - // color rendering - dstMesh->vertexDataByteOffset = m_Header.vertexDataByteSize; - dstMesh->vertexCount = srcMesh->mNumVertices; - - dstMesh->indexDataByteOffset = m_Header.indexDataByteSize; - dstMesh->indexCount = srcMesh->mNumFaces * 3; - - m_Header.vertexDataByteSize += dstMesh->vertexStride * dstMesh->vertexCount; - m_Header.indexDataByteSize += sizeof(uint16_t) * dstMesh->indexCount; - - // depth-only rendering - dstMesh->vertexDataByteOffsetDepth = m_Header.vertexDataByteSizeDepth; - dstMesh->vertexCountDepth = srcMesh->mNumVertices; - - m_Header.vertexDataByteSizeDepth += dstMesh->vertexStrideDepth * dstMesh->vertexCountDepth; - } - // allocate storage - m_pVertexData = new unsigned char [m_Header.vertexDataByteSize]; - m_pIndexData = new unsigned char [m_Header.indexDataByteSize]; - m_pVertexDataDepth = new unsigned char [m_Header.vertexDataByteSizeDepth]; - m_pIndexDataDepth = new unsigned char [m_Header.indexDataByteSize]; - // second pass, fill in vertex and index data - for (unsigned int meshIndex = 0; meshIndex < scene->mNumMeshes; meshIndex++) - { - const aiMesh *srcMesh = scene->mMeshes[meshIndex]; - Mesh *dstMesh = m_pMesh + meshIndex; - - float *dstPos = (float*)(m_pVertexData + dstMesh->vertexDataByteOffset + dstMesh->attrib[attrib_position].offset); - float *dstTexcoord0 = (float*)(m_pVertexData + dstMesh->vertexDataByteOffset + dstMesh->attrib[attrib_texcoord0].offset); - float *dstNormal = (float*)(m_pVertexData + dstMesh->vertexDataByteOffset + dstMesh->attrib[attrib_normal].offset); - float *dstTangent = (float*)(m_pVertexData + dstMesh->vertexDataByteOffset + dstMesh->attrib[attrib_tangent].offset); - float *dstBitangent = (float*)(m_pVertexData + dstMesh->vertexDataByteOffset + dstMesh->attrib[attrib_bitangent].offset); - - float *dstPosDepth = (float*)(m_pVertexDataDepth + dstMesh->vertexDataByteOffsetDepth + dstMesh->attribDepth[attrib_position].offset); - - for (unsigned int v = 0; v < dstMesh->vertexCount; v++) - { - if (srcMesh->mVertices) - { - dstPos[0] = srcMesh->mVertices[v].x; - dstPos[1] = srcMesh->mVertices[v].y; - dstPos[2] = srcMesh->mVertices[v].z; - - dstPosDepth[0] = srcMesh->mVertices[v].x; - dstPosDepth[1] = srcMesh->mVertices[v].y; - dstPosDepth[2] = srcMesh->mVertices[v].z; - } - else - { - // no position? That's kind of bad. - assert(0); - } - dstPos = (float*)((unsigned char*)dstPos + dstMesh->vertexStride); - dstPosDepth = (float*)((unsigned char*)dstPosDepth + dstMesh->vertexStrideDepth); - - if (srcMesh->mTextureCoords[0]) - { - dstTexcoord0[0] = srcMesh->mTextureCoords[0][v].x; - dstTexcoord0[1] = srcMesh->mTextureCoords[0][v].y; - } - else - { - dstTexcoord0[0] = 0.0f; - dstTexcoord0[1] = 0.0f; - } - dstTexcoord0 = (float*)((unsigned char*)dstTexcoord0 + dstMesh->vertexStride); - - if (srcMesh->mNormals) - { - dstNormal[0] = srcMesh->mNormals[v].x; - dstNormal[1] = srcMesh->mNormals[v].y; - dstNormal[2] = srcMesh->mNormals[v].z; - } - else - { - // Assimp should generate normals if they are missing, according to the postprocessing flag specified on load, - // so we should never get here. - assert(0); - } - dstNormal = (float*)((unsigned char*)dstNormal + dstMesh->vertexStride); - - if (srcMesh->mTangents) - { - dstTangent[0] = srcMesh->mTangents[v].x; - dstTangent[1] = srcMesh->mTangents[v].y; - dstTangent[2] = srcMesh->mTangents[v].z; - } - else - { - // TODO: generate tangents/bitangents if missing - dstTangent[0] = 1.0f; - dstTangent[1] = 0.0f; - dstTangent[2] = 0.0f; - } - dstTangent = (float*)((unsigned char*)dstTangent + dstMesh->vertexStride); - - if (srcMesh->mBitangents) - { - dstBitangent[0] = srcMesh->mBitangents[v].x; - dstBitangent[1] = srcMesh->mBitangents[v].y; - dstBitangent[2] = srcMesh->mBitangents[v].z; - } - else - { - // TODO: generate tangents/bitangents if missing - dstBitangent[0] = 0.0f; - dstBitangent[1] = 1.0f; - dstBitangent[2] = 0.0f; - } - dstBitangent = (float*)((unsigned char*)dstBitangent + dstMesh->vertexStride); - } - - uint16_t *dstIndex = (uint16_t*)(m_pIndexData + dstMesh->indexDataByteOffset); - uint16_t *dstIndexDepth = (uint16_t*)(m_pIndexDataDepth + dstMesh->indexDataByteOffset); - for (unsigned int f = 0; f < srcMesh->mNumFaces; f++) - { - assert(srcMesh->mFaces[f].mNumIndices == 3); - - *dstIndex++ = srcMesh->mFaces[f].mIndices[0]; - *dstIndex++ = srcMesh->mFaces[f].mIndices[1]; - *dstIndex++ = srcMesh->mFaces[f].mIndices[2]; - - *dstIndexDepth++ = srcMesh->mFaces[f].mIndices[0]; - *dstIndexDepth++ = srcMesh->mFaces[f].mIndices[1]; - *dstIndexDepth++ = srcMesh->mFaces[f].mIndices[2]; - } - } - - ComputeAllBoundingBoxes(); - - return true; -} diff --git a/xess/samples/xess_demo/MiniEngine/ModelConverter/ModelAssimp.h b/xess/samples/xess_demo/MiniEngine/ModelConverter/ModelAssimp.h deleted file mode 100644 index 73dd966..0000000 --- a/xess/samples/xess_demo/MiniEngine/ModelConverter/ModelAssimp.h +++ /dev/null @@ -1,45 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// - -#pragma once - -#include "ModelH3D.h" - -class AssimpModel : public ModelH3D -{ -public: - - enum - { - format_none = 0, - format_h3d, // native format - format_mini, - - formats, - }; - static const char *s_FormatString[]; - static int FormatFromFilename(const std::string& filename); - - bool Load(const std::string& filename); - bool Save(const std::string& filename) const; - - void PrintModelStats(); - -private: - - bool LoadAssimp(const std::string& filename); - - void Optimize(); - void OptimizeRemoveDuplicateVertices(bool depth); - void OptimizePostTransform(bool depth); - void OptimizePreTransform(bool depth); -}; - diff --git a/xess/samples/xess_demo/MiniEngine/ModelConverter/ModelConverter_VS15.sln b/xess/samples/xess_demo/MiniEngine/ModelConverter/ModelConverter_VS15.sln deleted file mode 100644 index e90cfa4..0000000 --- a/xess/samples/xess_demo/MiniEngine/ModelConverter/ModelConverter_VS15.sln +++ /dev/null @@ -1,34 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26430.16 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ModelConverter", "ModelConverter_VS15.vcxproj", "{1813BD6E-E2AF-4A3C-8C54-4E72119DA993}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Core", "..\Core\Core_VS15.vcxproj", "{86A58508-0D6A-4786-A32F-01A301FDC6F3}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Model", "..\Model\Model_VS15.vcxproj", "{5D3AEEFB-8789-48E5-9BD9-09C667052D09}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1813BD6E-E2AF-4A3C-8C54-4E72119DA993}.Debug|x64.ActiveCfg = Debug|x64 - {1813BD6E-E2AF-4A3C-8C54-4E72119DA993}.Debug|x64.Build.0 = Debug|x64 - {1813BD6E-E2AF-4A3C-8C54-4E72119DA993}.Release|x64.ActiveCfg = Release|x64 - {1813BD6E-E2AF-4A3C-8C54-4E72119DA993}.Release|x64.Build.0 = Release|x64 - {86A58508-0D6A-4786-A32F-01A301FDC6F3}.Debug|x64.ActiveCfg = Debug|x64 - {86A58508-0D6A-4786-A32F-01A301FDC6F3}.Debug|x64.Build.0 = Debug|x64 - {86A58508-0D6A-4786-A32F-01A301FDC6F3}.Release|x64.ActiveCfg = Release|x64 - {86A58508-0D6A-4786-A32F-01A301FDC6F3}.Release|x64.Build.0 = Release|x64 - {5D3AEEFB-8789-48E5-9BD9-09C667052D09}.Debug|x64.ActiveCfg = Debug|x64 - {5D3AEEFB-8789-48E5-9BD9-09C667052D09}.Debug|x64.Build.0 = Debug|x64 - {5D3AEEFB-8789-48E5-9BD9-09C667052D09}.Release|x64.ActiveCfg = Release|x64 - {5D3AEEFB-8789-48E5-9BD9-09C667052D09}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/xess/samples/xess_demo/MiniEngine/ModelConverter/ModelConverter_VS15.vcxproj b/xess/samples/xess_demo/MiniEngine/ModelConverter/ModelConverter_VS15.vcxproj deleted file mode 100644 index 52ededb..0000000 --- a/xess/samples/xess_demo/MiniEngine/ModelConverter/ModelConverter_VS15.vcxproj +++ /dev/null @@ -1,98 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {1813BD6E-E2AF-4A3C-8C54-4E72119DA993} - title - en-US - Win32Proj - ModelConverter - ModelConverter - v141 - 15.0 - Native - 10.0.15063.0 - - - - Application - v141 - Unicode - - - - - - - - - - - - - - - - - - - ..\Model;%(AdditionalIncludeDirectories) - - - /nodefaultlib:MSVCRT %(AdditionalOptions) - - - - - {86A58508-0D6A-4786-A32F-01A301FDC6F3} - false - - - {5d3aeefb-8789-48e5-9bd9-09c667052d09} - - - - - - - - - - - - - - - - - - - ..\Packages\zlib-vc140-static-64.1.2.11\lib\native\libs\x64\static\Release;%(AdditionalLibraryDirectories) - zlibstatic.lib;%(AdditionalDependencies) - /nodefaultlib:LIBCMT %(AdditionalOptions) - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/ModelConverter/ModelConverter_VS15.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/ModelConverter/ModelConverter_VS15.vcxproj.filters deleted file mode 100644 index 7a899bd..0000000 --- a/xess/samples/xess_demo/MiniEngine/ModelConverter/ModelConverter_VS15.vcxproj.filters +++ /dev/null @@ -1,34 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/ModelConverter/ModelOptimize.cpp b/xess/samples/xess_demo/MiniEngine/ModelConverter/ModelOptimize.cpp deleted file mode 100644 index 2032152..0000000 --- a/xess/samples/xess_demo/MiniEngine/ModelConverter/ModelOptimize.cpp +++ /dev/null @@ -1,184 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// -// Author(s): Alex Nankervis -// - -#include "ModelAssimp.h" -#include "IndexOptimizePostTransform.h" - -#include - -void AssimpModel::OptimizeRemoveDuplicateVertices(bool depth) -{ - unsigned char *deduplicatedVertexData = new unsigned char [depth ? m_Header.vertexDataByteSizeDepth : m_Header.vertexDataByteSize]; - uint32_t deduplicatedVertexDataSize = 0; - - for (unsigned int meshIndex = 0; meshIndex < m_Header.meshCount; meshIndex++) - { - Mesh *mesh = m_pMesh + meshIndex; - unsigned int vertexStride = depth ? mesh->vertexStrideDepth : mesh->vertexStride; - unsigned char *meshVertexData = depth ? (m_pVertexDataDepth + mesh->vertexDataByteOffsetDepth) : (m_pVertexData + mesh->vertexDataByteOffset); - - unsigned char *meshDeduplicatedVertexData = deduplicatedVertexData + deduplicatedVertexDataSize; - unsigned int deduplicatedCount = 0; - - unsigned int vertexCount = depth ? mesh->vertexCountDepth : mesh->vertexCount; - uint32_t *vertexRemap = new uint32_t [vertexCount]; - memset(vertexRemap, (uint32_t)-1, sizeof(uint32_t) * vertexCount); - assert(vertexCount <= (uint32_t)-1); - - for (unsigned int v1 = 0; v1 < vertexCount; v1++) - { - if (vertexRemap[v1] != (uint32_t)-1) - continue; // this was already found to be a duplicate - - const unsigned char *v1Data = meshVertexData + v1 * vertexStride; - - // this is a new unique vertex - uint32_t remappedSlot = deduplicatedCount++; - vertexRemap[v1] = remappedSlot; - memcpy(meshDeduplicatedVertexData + remappedSlot * vertexStride, v1Data, vertexStride); - - // scan for duplicates - for (unsigned int v2 = v1 + 1; v2 < vertexCount; v2++) - { - if (vertexRemap[v2] != (uint32_t)-1) - continue; // this was already found to be a duplicate of another vertex - - const unsigned char *v2Data = meshVertexData + v2 * vertexStride; - - if (0 == memcmp(v1Data, v2Data, vertexStride)) - { - vertexRemap[v2] = remappedSlot; - } - } - } - - unsigned int indexCount = mesh->indexCount; - uint16_t *indexArray = (uint16_t*)((depth ? m_pIndexDataDepth : m_pIndexData) + mesh->indexDataByteOffset); - for (unsigned int n = 0; n < indexCount; n++) - { - indexArray[n] = vertexRemap[indexArray[n]]; - } - - delete [] vertexRemap; - - if (depth) - { - mesh->vertexCountDepth = deduplicatedCount; - mesh->vertexDataByteOffsetDepth = deduplicatedVertexDataSize; - } - else - { - mesh->vertexCount = deduplicatedCount; - mesh->vertexDataByteOffset = deduplicatedVertexDataSize; - } - deduplicatedVertexDataSize += deduplicatedCount * vertexStride; - } - - if (depth) - { - delete [] m_pVertexDataDepth; - m_pVertexDataDepth = deduplicatedVertexData; - m_Header.vertexDataByteSizeDepth = deduplicatedVertexDataSize; - } - else - { - delete [] m_pVertexData; - m_pVertexData = deduplicatedVertexData; - m_Header.vertexDataByteSize = deduplicatedVertexDataSize; - } -} - -void AssimpModel::OptimizePostTransform(bool depth) -{ - enum {lruCacheSize = 64}; - - for (unsigned int meshIndex = 0; meshIndex < m_Header.meshCount; meshIndex++) - { - Mesh *mesh = m_pMesh + meshIndex; - - uint16_t *srcIndices = new uint16_t [mesh->indexCount]; - uint16_t *dstIndices = (uint16_t*)((depth ? m_pIndexDataDepth : m_pIndexData) + mesh->indexDataByteOffset); - memcpy(srcIndices, dstIndices, sizeof(uint16_t) * mesh->indexCount); - - OptimizeFaces(srcIndices, mesh->indexCount, dstIndices, lruCacheSize); - - delete [] srcIndices; - } -} - -void AssimpModel::OptimizePreTransform(bool depth) -{ - unsigned char *reorderedVertexData = new unsigned char [depth ? m_Header.vertexDataByteSizeDepth : m_Header.vertexDataByteSize]; - - for (unsigned int meshIndex = 0; meshIndex < m_Header.meshCount; meshIndex++) - { - Mesh *mesh = m_pMesh + meshIndex; - unsigned int indexCount = mesh->indexCount; - unsigned int vertexStride = depth ? mesh->vertexStrideDepth : mesh->vertexStride; - unsigned char *meshVertexData = depth ? (m_pVertexDataDepth + mesh->vertexDataByteOffsetDepth) : (m_pVertexData + mesh->vertexDataByteOffset); - - unsigned char *meshReorderedVertexData = reorderedVertexData + (depth ? mesh->vertexDataByteOffsetDepth : mesh->vertexDataByteOffset); - unsigned int reorderedCount = 0; - - unsigned int vertexCount = depth ? mesh->vertexCountDepth : mesh->vertexCount; - uint32_t *vertexRemap = new uint32_t [vertexCount]; - memset(vertexRemap, (uint32_t)-1, sizeof(uint32_t) * vertexCount); - assert(vertexCount <= (uint32_t)-1); - - uint16_t *indexArray = (uint16_t*)((depth ? m_pIndexDataDepth : m_pIndexData) + mesh->indexDataByteOffset); - for (unsigned int n = 0; n < indexCount; n++) - { - uint16_t index = indexArray[n]; - if (vertexRemap[index] == (uint32_t)-1) - { - // not relocated yet - const unsigned char *vSrc = meshVertexData + index * vertexStride; - unsigned char *vDst = meshReorderedVertexData + reorderedCount * vertexStride; - memcpy(vDst, vSrc, vertexStride); - - vertexRemap[index] = reorderedCount; - reorderedCount++; - } - indexArray[n] = vertexRemap[index]; - } - - delete [] vertexRemap; - } - - if (depth) - { - delete [] m_pVertexDataDepth; - m_pVertexDataDepth = reorderedVertexData; - } - else - { - delete [] m_pVertexData; - m_pVertexData = reorderedVertexData; - } -} - -void AssimpModel::Optimize() -{ - // TODO: quantize/compress vertex data - - OptimizeRemoveDuplicateVertices(false); - OptimizeRemoveDuplicateVertices(true); - - // re-order indices for post transform cache - OptimizePostTransform(false); - OptimizePostTransform(true); - - // re-order vertices for linear memory access - OptimizePreTransform(false); - OptimizePreTransform(true); -} diff --git a/xess/samples/xess_demo/MiniEngine/ModelConverter/README.txt b/xess/samples/xess_demo/MiniEngine/ModelConverter/README.txt deleted file mode 100644 index 5db9590..0000000 --- a/xess/samples/xess_demo/MiniEngine/ModelConverter/README.txt +++ /dev/null @@ -1,4 +0,0 @@ -The model converter leverages a 3rd party model importing library called "ASSIMP" (Asset Import Library). Due to an open source licensing concern, ASSIMP is not included in this GitHub repository. You will need to download ASSIMP and install it to the 3rdParty folder. The ModelConverter project file will look for ASSIMP in "../3rdParty/assimp-3.0" unless you change the additional include directories. You should also have "assimp.dll" in your path. We recommended copying this DLL to the ModelConverter folder. The most recent version of ASSIMP is 3.2, but we have only tested with 3.0. You are welcome to make the necessary (if any) changes to work with 3.2. Please notify us via pull request or forum post if you find some discrepencies. - -Regards, -Team Minigraph \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/ModelConverter/packages.config b/xess/samples/xess_demo/MiniEngine/ModelConverter/packages.config deleted file mode 100644 index 6905c08..0000000 --- a/xess/samples/xess_demo/MiniEngine/ModelConverter/packages.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/ModelConverter/readme.md b/xess/samples/xess_demo/MiniEngine/ModelConverter/readme.md deleted file mode 100644 index c812705..0000000 --- a/xess/samples/xess_demo/MiniEngine/ModelConverter/readme.md +++ /dev/null @@ -1,10 +0,0 @@ -The model converter leverages a 3rd party model importing library called "ASSIMP" (Asset Import Library). Due to an open source licensing concern, ASSIMP is not included in this GitHub repository. You will need to download ASSIMP and install it to the 3rdParty folder. The ModelConverter project file will look for ASSIMP in "../3rdParty/assimp-3.0" unless you change the additional include directories. You may need to rename some files/folders to make the Visual Studio project compile. It references ASSIMP as follows: - -* Include Path: ../3rdParty/assimp-3.0/include -* Library Path: ../3rdParty/assimp-3.0/lib/release -* Post-build: ../3rdParty/assimp-3.0/bin/release/assimp.dll - -You should also have "assimp.dll" in your path. We recommended copying this DLL to the ModelConverter folder. The most recent version of ASSIMP is 3.2, but we have only tested with 3.0. You are welcome to make the necessary (if any) changes to work with 3.2. Please notify us via pull request or forum post if you find some discrepencies. - -Regards, -Team Minigraph \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/NuGet.Config b/xess/samples/xess_demo/MiniEngine/NuGet.Config deleted file mode 100644 index e8cabf0..0000000 --- a/xess/samples/xess_demo/MiniEngine/NuGet.Config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/xess/samples/xess_demo/MiniEngine/PropertySheets/Build.props b/xess/samples/xess_demo/MiniEngine/PropertySheets/Build.props deleted file mode 100644 index 2f9e39f..0000000 --- a/xess/samples/xess_demo/MiniEngine/PropertySheets/Build.props +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - false - true - $(SolutionDir)\Build\$(Platform)\$(Configuration)\Output\$(ProjectName)\ - $(SolutionDir)\Build\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ - $(SolutionDir)\Build\$(Platform)\$(Configuration)\Output\$(ProjectName);$(IncludePath) - - - - ..\Core;..\ThirdParty\imgui;%(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - Level4 - true - Fast - - - _DEBUG;%(PreprocessorDefinitions) - false - Disabled - true - MultiThreadedDebugDLL - false - - - NDEBUG;PROFILE;%(PreprocessorDefinitions) - AnySuitable - MaxSpeed - MultiThreadedDLL - true - - - NDEBUG;RELEASE;%(PreprocessorDefinitions) - AnySuitable - MaxSpeed - MultiThreadedDLL - true - - - Windows - true - false - %(AdditionalDependencies) - - - - - true - true - - - true - true - - - /IGNORE:4221 %(AdditionalOptions) - - - Compute - g_p%(Filename) - $(SolutionDir)\Build\$(Platform)\$(Configuration)\Output\$(ProjectName)\CompiledShaders\%(Filename).h - false - - true - -Qembed_debug %(AdditionalOptions) - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/PropertySheets/Desktop.props b/xess/samples/xess_demo/MiniEngine/PropertySheets/Desktop.props deleted file mode 100644 index 27e0a08..0000000 --- a/xess/samples/xess_demo/MiniEngine/PropertySheets/Desktop.props +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - $(Console_SdkLibPath);$(LibraryPath) - $(Console_SdkIncludeRoot);$(IncludePath) - - - - $(Console_Libs);%(AdditionalDependencies) - - - __WRL_NO_DEFAULT_LIB__;%(PreprocessorDefinitions) - - - _GAMING_DESKTOP=1 - 6.2 - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Tools/SDFFontCreator/.gitignore b/xess/samples/xess_demo/MiniEngine/Tools/SDFFontCreator/.gitignore deleted file mode 100644 index b5b8c81..0000000 --- a/xess/samples/xess_demo/MiniEngine/Tools/SDFFontCreator/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/Debug -/Release -/*.bmp -/*.fnt -/*.ttf -/x64 \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Tools/SDFFontCreator/NuGet.Config b/xess/samples/xess_demo/MiniEngine/Tools/SDFFontCreator/NuGet.Config deleted file mode 100644 index 17ef8df..0000000 --- a/xess/samples/xess_demo/MiniEngine/Tools/SDFFontCreator/NuGet.Config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Tools/SDFFontCreator/SDFFontCreator.cpp b/xess/samples/xess_demo/MiniEngine/Tools/SDFFontCreator/SDFFontCreator.cpp deleted file mode 100644 index b7bc5df..0000000 --- a/xess/samples/xess_demo/MiniEngine/Tools/SDFFontCreator/SDFFontCreator.cpp +++ /dev/null @@ -1,702 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include FT_FREETYPE_H - -#define kMajorVersion 1 -#define kMinorVersion 0 - -#define kMaxTextureDimension 4096 - -using namespace std; - -template inline T align16( T val ) { return (val + 15) & ~15; } - -// All measurements are in 12.4 fixed point -struct GlyphInfo -{ - wchar_t c; // The unicode (UCS2) character code corresponding to the glyph - uint16_t u, v; // The upper left texture coordinate of the glyph, not counting border space - uint16_t width; // The width of the glyph (not counting horizontal spacing) - int16_t bearing; // The leading space before the glyph (sometimes negative) - uint16_t advance; // The total distance to advance the pen after printing -}; - -__declspec(thread) FT_Library g_FreeTypeLib = 0; // FreeType2 library wrapper -__declspec(thread) FT_Face g_FreeTypeFace = 0; // FreeType2 typeface -uint16_t g_numGlyphs = 0; // Number of glyphs to process -GlyphInfo g_glyphs[0xFFFF]; // An array of glyph information -uint16_t g_borderSize = 0; // Extra space around each glyph used for effects like glow and drop shadow -uint16_t g_maxDistance = 0; // Range of search space which controls the "steepness" of the contour map -bool g_fixNumberWidths = false; // Prints all numbers with fixed spacing -uint16_t g_maxGlyphHeight = 0; // Max height of glyph = ascender - descender -int16_t g_fontOffset = 0; // Baseline offset to center the text vertically -uint16_t g_fontAdvanceY = 0; // Distance from baseline to baseline (line height) - -float* g_DistanceMap = 0; -uint32_t g_MapWidth = 0; -uint32_t g_MapHeight = 0; -volatile int32_t g_nextGlyphIdx = 0; -volatile bool g_ReadyToPaint = false; - -void PrintAssertMessage( const char* file, uint32_t line, const char* cond, const char* msg, ...) -{ - printf("Assertion \"%s\" failed at %s:%u\n", cond, file, line); - - if (msg) - { - va_list ap; - va_start(ap, msg); - vprintf(msg, ap); - printf("\n"); - } -} - -// Assert which allows setting of file and line number -#define ASSERT_LINE( test, file, line, ... ) \ - if (!(test)) { \ - PrintAssertMessage(file, line, #test, ##__VA_ARGS__); \ - __debugbreak(); \ - } - -// Assert which automatically detects call location -#define ASSERT( test, ... ) ASSERT_LINE( test, __FILE__, __LINE__, __VA_ARGS__ ) - -void InitializeFont( const char* filename = 0, uint32_t size = 0) -{ - static const char* s_filename = 0; - static uint32_t s_size = 0; - - if (s_filename == 0) - { - ASSERT(filename != 0, "We must have a TrueType file to initialize FreeType"); - ASSERT(size > 0, "A size must be specified to initialize FreeType"); - } - else - { - filename = s_filename; - size = s_size; - } - - ASSERT(g_FreeTypeLib == 0, "FreeType is already initialized on this thread"); - - try - { - if (FT_Init_FreeType( &g_FreeTypeLib )) - throw exception("Failed to create library\n"); - if (FT_New_Face( g_FreeTypeLib, filename, 0, &g_FreeTypeFace )) - throw exception("Failed to create face\n"); - if (FT_Set_Pixel_Sizes( g_FreeTypeFace, 0, size )) - throw exception("Failed to set pixel sizes\n"); - } - catch (exception& e) - { - // If this is the first time, that filename is probably bad. Raise the error. - if (s_filename == 0) - throw; - - printf("Error: Unable to initialize FreeType for thread: %s\n", e.what()); - } - - s_filename = filename; - s_size = size; -} - -void ShutdownFont(void) -{ - if (g_FreeTypeFace) - FT_Done_Face( g_FreeTypeFace ); - - if (g_FreeTypeLib) - FT_Done_FreeType( g_FreeTypeLib ); -} - -struct Canvas -{ - uint8_t* bitmap; // Pointer to rendered glyph memory (from FT_Bitmap) - uint32_t pitch; // Width in bytes of a row in the canvas - uint32_t width; // Width in pixels of a row in the canvas - uint32_t rows; // Number of rows in the canvas - uint32_t xOff; // Amount to offset the x coordinate when reading - uint32_t yOff; // Amount to offset the y coordinate when reading -}; - -// Access the high res glyph canvas -inline bool ReadCanvasBit( const Canvas& canvas, uint32_t x, uint32_t y ) -{ - // Notice that negative values have been cast to large positive values - x -= canvas.xOff; - y -= canvas.yOff; - if (x >= canvas.width || y >= canvas.rows) - return false; - - uint32_t p = y * canvas.pitch + x / 8; - uint32_t k = x & 7; - return (canvas.bitmap[p] & (0x80 >> k)) ? true : false; -} - -// Setup pixel reads from the glyph canvas -inline Canvas LoadCanvas(FT_GlyphSlot glyph) -{ - Canvas ret; - ret.bitmap = glyph->bitmap.buffer; - ret.pitch = glyph->bitmap.pitch; - ret.width = glyph->bitmap.width; - ret.rows = glyph->bitmap.rows; - ret.xOff = g_borderSize * 16; - ret.yOff = g_borderSize * 16 + g_maxGlyphHeight + g_fontOffset - (glyph->metrics.horiBearingY >> 6); - return ret; -} - -float DistanceFromInside(const Canvas& canvas, uint32_t xCoord, uint32_t yCoord) -{ - const uint32_t radius = g_maxDistance * 32; - const uint32_t x0 = xCoord * 32 + 15; - const uint32_t y0 = yCoord * 32 + 15; - - uint32_t left = (uint32_t)max(0, (int32_t)(x0 - radius + 1)); - uint32_t right = x0 + radius - 1; - uint32_t top = (uint32_t)max(0, (int32_t)(y0 - radius + 1)); - uint32_t bottom = y0 + radius - 1; - - uint32_t bestDistSq = radius * radius; - - for (uint32_t y1 = top; y1 <= bottom; y1 += 2) - { - int32_t distY = (int32_t)(y1 - y0); - uint32_t distYSq = (uint32_t)(distY * distY); - - if (distYSq >= bestDistSq) - { - if (y1 > y0) - continue; - else - break; - } - - for (uint32_t x1 = left; x1 <= right; x1 += 2) - { - int32_t distX = (int32_t)(x1 - x0); - uint32_t distXSq = (uint32_t)(distX * distX); - - uint32_t distSq = (uint32_t)(distXSq + distYSq); - if (distSq < bestDistSq && !ReadCanvasBit(canvas, x1 >> 1, y1 >> 1)) - bestDistSq = distSq; - } - } - - return sqrt((float)bestDistSq) / (float)radius; -} - -float DistanceFromOutside(const Canvas& canvas, uint32_t xCoord, uint32_t yCoord) -{ - const uint32_t radius = g_maxDistance * 32; - const uint32_t x0 = xCoord * 32 + 15; - const uint32_t y0 = yCoord * 32 + 15; - - uint32_t left = (uint32_t)max(0, (int32_t)(x0 - radius + 1)); - uint32_t right = x0 + radius - 1; - uint32_t top = (uint32_t)max(0, (int32_t)(y0 - radius + 1)); - uint32_t bottom = y0 + radius - 1; - - uint32_t bestDistSq = radius * radius; - - for (uint32_t y1 = top; y1 <= bottom; y1 += 2) - { - int32_t distY = (int32_t)(y1 - y0); - uint32_t distYSq = (uint32_t)(distY * distY); - - if (distYSq >= bestDistSq) - { - if (y1 > y0) - continue; - else - break; - } - - for (uint32_t x1 = left; x1 <= right; x1 += 2) - { - int32_t distX = (int32_t)(x1 - x0); - uint32_t distXSq = (uint32_t)(distX * distX); - - uint32_t distSq = (uint32_t)(distXSq + distYSq); - if (distSq < bestDistSq && ReadCanvasBit(canvas, x1 >> 1, y1 >> 1)) - bestDistSq = distSq; - } - } - - return sqrt((float)bestDistSq) / (float)radius; -} - -// Get width and spacing of a given glyph to compute necessary space and layout in final texture. -inline uint16_t GetGlyphMetrics( wchar_t c, GlyphInfo& info ) -{ - if (FT_Load_Char( g_FreeTypeFace, c, FT_LOAD_TARGET_MONO )) - throw exception("Unable to access glyph data"); - - FT_Glyph_Metrics& metrics = g_FreeTypeFace->glyph->metrics; - info.bearing = (int16_t)(metrics.horiBearingX >> 6); - info.width = (uint16_t)(metrics.width >> 6); - info.advance = (uint16_t)(metrics.horiAdvance >> 6); - - return (uint16_t)info.width; -} - -// Compute glyph layout in bitmap for a given texture width. If the height exceeds a certain -// threshold, you should recompute the layout with a larger texture width. -uint32_t UnwrapUVs(uint32_t textureWidth) -{ - uint16_t glyphBorder = g_borderSize * 16; - uint16_t rowSize = align16(g_maxGlyphHeight); - - // Set the starting point for the drawing - uint32_t x = glyphBorder; - uint32_t y = glyphBorder; - - for (uint16_t i = 0; i < g_numGlyphs; ++i) - { - // We need a pixel border to surround the character because the distance field must enclose - // the bitmap. - uint32_t deltaX = align16(g_glyphs[i].width) + glyphBorder; - - // Check for line wrap - if (x + deltaX > textureWidth * 16) - { - x = glyphBorder; - y += rowSize + glyphBorder * 2; - } - - // The actual character UVs don't include the border pixels - g_glyphs[i].u = (uint16_t)x; - g_glyphs[i].v = (uint16_t)y; - - x += deltaX + glyphBorder; - } - - return (y + rowSize + glyphBorder) / 16; -} - -void PaintCharacters( float* distanceMap, uint32_t width, uint32_t /*height*/ ) -{ - int32_t i = -1; - while ((i = _InterlockedExchangeAdd((volatile long*)&g_nextGlyphIdx, 1)) < g_numGlyphs) - { - // Get the character info - const GlyphInfo& ch = g_glyphs[i]; - - if (FT_Load_Char( g_FreeTypeFace, ch.c, FT_LOAD_RENDER | FT_LOAD_MONOCHROME | FT_LOAD_TARGET_MONO )) - throw exception("Character bitmap rendering failed internally"); - - Canvas canvas = LoadCanvas(g_FreeTypeFace->glyph); - - uint32_t charWidth = align16(ch.width) / 16; - uint32_t charHeight = align16(g_maxGlyphHeight) / 16; - uint32_t startX = ch.u / 16 - g_borderSize; - uint32_t startY = ch.v / 16 - g_borderSize; - - // Convert high-res bitmap to low-res distance map - for (uint32_t x = 0; x < charWidth + g_borderSize * 2; ++x) - { - for (uint32_t y = 0; y < charHeight + g_borderSize * 2; ++y) - { - uint32_t left = x * 16 + 7; - uint32_t top = y * 16 + 7; - - bool inside = ReadCanvasBit(canvas, left, top) & ReadCanvasBit(canvas, left + 1, top) & - ReadCanvasBit(canvas, left, top + 1) & ReadCanvasBit(canvas, left + 1, top + 1); - - if (inside) - distanceMap[startX + x + (startY + y) * width] = +DistanceFromInside(canvas, x, y); - else - distanceMap[startX + x + (startY + y) * width] = -DistanceFromOutside(canvas, x, y); - } - } - } -} - -void WorkerFunc( void ) -{ - // We can initialize FreeType while we wait to paint the alphabet - InitializeFont(); - - // Sleep for 2 milliseconds per iteration until we're ready to paint - while (!g_ReadyToPaint) - std::this_thread::sleep_for(std::chrono::milliseconds(2)); - - PaintCharacters(g_DistanceMap, g_MapWidth, g_MapHeight); - - ShutdownFont(); -} - -struct BMP_Header -{ - // Bitmap file header - uint32_t filesz; - uint16_t creator1; - uint16_t creator2; - uint32_t bmp_offset; - - // DIB header - uint32_t header_sz; - uint32_t width; - uint32_t height; - uint16_t nplanes; - uint16_t bitspp; - uint32_t compress_type; - uint32_t bmp_bytesz; - uint32_t hres; - uint32_t vres; - uint32_t ncolors; - uint32_t nimpcolors; -}; - -void WritePreviewBMP(const string& fileName, const uint8_t* heightMap, uint32_t width, uint32_t height) -{ - // Append ".bmp" to file name - char fileWithSuffix[256]; - sprintf_s(fileWithSuffix, 256, "%s.bmp", fileName.c_str()); - - // Open file - ofstream file; - file.exceptions(ios_base::failbit | ios_base::badbit); - file.open(fileWithSuffix, ios_base::out | ios_base::binary | ios_base::trunc); - - file.write("BM", 2); - - // Write header - BMP_Header header; - memset(&header, 0, sizeof(BMP_Header)); - header.filesz = 54 + 256 * sizeof(uint32_t) + width * height; - header.bmp_offset = 54 + 256 * sizeof(uint32_t); - header.header_sz = 40; - header.width = width; - header.height = -(int32_t)height; - header.nplanes = 1; - header.bitspp = 8; - header.hres = 0x130B0000; - header.vres = 0x130B0000; - file.write((const char*)&header, sizeof(BMP_Header)); - - // Write color map table - uint32_t colorMap[256]; - for (uint32_t i = 0; i < 256; ++i) - colorMap[i] = i << 16 | i << 8 | i; - file.write((const char*)colorMap, 256 * sizeof(uint32_t)); - - // Write data - file.write((const char*)heightMap, width * height); - - // Close file - file.close(); -} - -void CompileFont(const string& outputName) -{ - // Figure out how many threads to create, and then spawn them. Leave their parameters blank. We'll fill them in - // before they're read. - - size_t numThreads = std::thread::hardware_concurrency(); - - std::vector Threads; - - if (numThreads > 1) - { - --numThreads; - - for (uint32_t i = 0; i < numThreads; ++i) - { - Threads.push_back(std::thread(WorkerFunc)); - } - } - - // This implicitly embeds space in the font texture, which wastes memory. What would be better is to just store - // the font height (i.e. the line spacing) in the final file header, and pack the texture as tightly as possible. - g_fontAdvanceY = (uint16_t)(g_FreeTypeFace->size->metrics.height >> 6); - g_maxGlyphHeight = (uint16_t)((g_FreeTypeFace->size->metrics.ascender - g_FreeTypeFace->size->metrics.descender) >> 6); - g_fontOffset = (int16_t)(g_FreeTypeFace->size->metrics.descender >> 6); - - // Get the dimensions of each glyph - for (uint16_t i = 0; i < g_numGlyphs; ++i) - GetGlyphMetrics(g_glyphs[i].c, g_glyphs[i]); - - // Adjust metrics for numerals if we want to coerce fixed number widths - if (g_fixNumberWidths) - { - // Compute maximum numeric advance - uint16_t numberWidth = 0; - for (uint16_t i = 0; i < g_numGlyphs; ++i) - { - wchar_t wc = g_glyphs[i].c; - if (wc >= L'0' && wc <= L'9') - numberWidth = max(numberWidth, g_glyphs[i].advance); - } - - // Adjust each numeral to advance the same amount and to center the digit by adjusting the bearing - for (uint16_t i = 0; i < g_numGlyphs; ++i) - { - wchar_t wc = g_glyphs[i].c; - if (wc >= L'0' && wc <= L'9') - { - g_glyphs[i].bearing = (numberWidth - g_glyphs[i].width) / 2; - g_glyphs[i].advance = numberWidth; - } - } - } - - // Compute the smallest rectangular texture with height < width that can contain the result. Use - // widths that are a power of two to accelerate the search. - for (g_MapWidth = 512; g_MapWidth <= kMaxTextureDimension; g_MapWidth *= 2) - { - g_MapHeight = UnwrapUVs(g_MapWidth); - - // Found a good size - if (g_MapHeight <= g_MapWidth) - break; - } - - // We ran through all possibilities and still couldn't fit the font - if (g_MapHeight > g_MapWidth) - throw exception("Texture dimensions exceeded maximum allowable"); - - // Render the glyphs and generate heightmaps. Place heightmaps in the - // locations set aside in the texture. - g_DistanceMap = new float[g_MapWidth * g_MapHeight]; - for (size_t x = g_MapWidth * g_MapHeight; x > 0; --x) - g_DistanceMap[x - 1] = -1.0f; - - // Make sure all of the parameters are flushed to memory before we trigger the threads to paint. - __faststorefence(); - - g_ReadyToPaint = true; - - // Also paint on the main thread - PaintCharacters(g_DistanceMap, g_MapWidth, g_MapHeight); - - // Wait for all of the other threads - if (numThreads > 0) - { - for_each( Threads.begin(), Threads.end(), []( std::thread& T ) { T.join(); } ); - } - - uint8_t* compressedMap8 = new uint8_t[g_MapWidth * g_MapHeight]; - - for (uint32_t i = 0; i < g_MapWidth * g_MapHeight; ++i) - compressedMap8[i] = (uint8_t)(g_DistanceMap[i] * 127.0f + 127.0f); // (Omit 255) - - WritePreviewBMP(outputName, compressedMap8, g_MapWidth, g_MapHeight); - - for (uint32_t i = 0; i < g_MapWidth * g_MapHeight; ++i) - compressedMap8[i] = (int8_t)(g_DistanceMap[i] * 127.0f); - - // Append ".fnt" to file name - char fileWithSuffix[256]; - sprintf_s(fileWithSuffix, 256, "%s.fnt", outputName.c_str()); - ofstream file; - file.exceptions(ios_base::failbit | ios_base::badbit); - file.open(fileWithSuffix, ios_base::out | ios_base::binary | ios_base::trunc); - - // The first part of the file is an identifier string to verify format and version - const char* idString = "SDFFONT"; - file.write(idString, 8); - - // The second part is information about the font - struct FontHeader - { - uint8_t majorVersion; - uint8_t minorVersion; - uint16_t borderSize; - uint16_t textureWidth; - uint16_t textureHeight; - uint16_t fontHeight; - uint16_t advanceY; - uint16_t numGlyphs; - uint16_t searchDist; - } header; - - header.majorVersion = kMajorVersion; - header.minorVersion = kMinorVersion; - header.borderSize = (uint8_t)g_borderSize; - header.textureWidth = (uint16_t)g_MapWidth; - header.textureHeight = (uint16_t)g_MapHeight; - header.fontHeight = g_maxGlyphHeight; - header.advanceY = g_fontAdvanceY; - header.numGlyphs = g_numGlyphs; - header.searchDist = g_maxDistance * 16; - file.write((const char*)&header, sizeof(FontHeader)); - - for (size_t i = 0; i < g_numGlyphs; ++i) - file.write( (const char*)&g_glyphs[i].c, 2 ); - - for (size_t i = 0; i < g_numGlyphs; ++i) - file.write( (const char*)&g_glyphs[i].c + 2, sizeof(GlyphInfo) - 2 ); - - file.write((const char*)compressedMap8, g_MapWidth * g_MapHeight); - - file.close(); - - printf("Finished creating %s\n", fileWithSuffix); -} - -void main( int argc, const char** argv ) -{ - string inputFile = ""; - string outputName = ""; - string characterSet = "ASCII"; - uint32_t size = 32; - bool extendedASCII = false; - - try - { - if (argc < 2) - throw exception("No font file specified"); - inputFile = argv[1]; - - for (int arg = 2; arg < argc; ++arg) - { - if (argv[arg][0] != '-') - throw exception("Malformed option"); - - if (arg + 1 == argc) - throw exception("Missing operand"); - else if (strcmp("-size", argv[arg]) == 0) - size = atoi(argv[++arg]); - else if (strcmp("-output", argv[arg]) == 0) - outputName = argv[++arg]; - else if (strcmp("-character_set", argv[arg]) == 0) - characterSet = argv[++arg]; - else if (strcmp("-border", argv[arg]) == 0) - g_borderSize = (uint16_t)atoi(argv[++arg]); - else if (strcmp("-radius", argv[arg]) == 0) - g_maxDistance = (uint16_t)atoi(argv[++arg]); - else - throw exception("Invalid option"); - } - } - catch (exception& e) - { - printf( - "Error: %s\n\n" - "Usage: %s [options]*\n\n" - "Options:\n\n" - "-character_set \n" - "\tA file containing the requested character set.\n\tWhen omitted, defaults to printable ASCII.\n" - "-output \n\tThe root name of resultant files.\n" - "-size \n\tThe font pixel resolution.\n" - "-radius \n\tThe search radius.\n\tDefaults to font size / 8.\n" - "-border_size \n\tExtra spacing around glyphs for various effects.\n\tDefaults to the search radius.\n" - "\n\nExample: %s myfont.ttf -character_set Japanese.txt -output japanese\n\n", e.what(), argv[0], argv[0]); - return; - } - - if (outputName.length() == 0) - { - outputName = inputFile.substr(0, inputFile.rfind('.')); - char sizeAsString[128]; - sprintf_s(sizeAsString, 128, "%u", size); - outputName += sizeAsString; - } - - if (g_maxDistance == 0) - g_maxDistance = (uint16_t)size / 8; - - if (g_borderSize == 0) - g_borderSize = g_maxDistance; - - if (_strcmpi(characterSet.c_str(), "extended") == 0) - { - characterSet = "ASCII"; - extendedASCII = true; - } - - printf("\n[ TrueType font compiler v.%d.%d ]\n\n", kMajorVersion, kMinorVersion); - printf("A tool for generating height maps for enhanced cutout magnification of\nbitmapped text.\n\n"); - printf("Font Name: \"%s\"\n", inputFile.c_str()); - printf("Font Size: %u\n", size); - printf("Border Size: %u\n", g_borderSize); - if (extendedASCII) - printf("Character Set: %s + Extended ASCII\n", characterSet.c_str()); - else - printf("Character Set: %s\n", characterSet.c_str()); - printf("Output Name: %s\n", outputName.c_str()); - printf("Threads: %u\n\n", std::thread::hardware_concurrency()); - - try - { - InitializeFont( inputFile.c_str(), size * 16 ); - - if (strcmp(characterSet.c_str(), "ASCII") == 0) - { - for (wchar_t c = 32; c < 127; ++c) - { - if (FT_Get_Char_Index(g_FreeTypeFace, c)) - g_glyphs[g_numGlyphs++].c = c; - } - if (extendedASCII) - for (wchar_t c = 128; c < 255; ++c) - if (FT_Get_Char_Index(g_FreeTypeFace, c)) - g_glyphs[g_numGlyphs++].c = c; - } - else - { - ifstream file; - file.exceptions(ios_base::badbit); - file.open(characterSet.c_str(), ios_base::in | ios_base::binary); - - set charSet; - wchar_t wtChar; - file.read((char*)&wtChar, 2); - - // Check for unicode (UCS2) or ASCII - if (wtChar == 0xFEFF) - while (file.read((char*)&wtChar, 2)) - charSet.insert(wtChar); - else - { - // ASCII files don't have extra bytes at the beginning; rewind. - file.seekg(0, ios_base::beg); - - char tChar = 0; - while (file.read(&tChar, 1)) - charSet.insert((wchar_t)tChar); - } - - // Make sure the set includes all extended ascii (except white space) - if (extendedASCII) - for (wchar_t c = 32; c < 255; ++c) - if (FT_Get_Char_Index(g_FreeTypeFace, c)) - charSet.insert(c); - - file.close(); - - // Sift out the duplicates by iterating across the STL set - for (set::iterator it = charSet.begin(); it != charSet.end(); ++it) - g_glyphs[g_numGlyphs++].c = *it; - } - - CompileFont(outputName); - - printf("\nComplete!\n"); - //printf("Elapsed Time: %g sec\n", t.getElapsed()); - } - catch (wofstream::failure& e) - { - printf("\nFile I/O Exception\n%s\n", e.what()); - } - catch (exception& e) - { - printf("\nFailed: %s\n", e.what()); - } - catch (...) - { - printf("\nFailed\n"); - } - - ShutdownFont(); -} diff --git a/xess/samples/xess_demo/MiniEngine/Tools/SDFFontCreator/SDFFontCreator_VS15.sln b/xess/samples/xess_demo/MiniEngine/Tools/SDFFontCreator/SDFFontCreator_VS15.sln deleted file mode 100644 index 154fa00..0000000 --- a/xess/samples/xess_demo/MiniEngine/Tools/SDFFontCreator/SDFFontCreator_VS15.sln +++ /dev/null @@ -1,24 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26403.7 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDFFontCreator", "SDFFontCreator_VS15.vcxproj", "{263D800B-80DF-45FB-B6FF-49EBBD6016FA}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Windows = Debug|Windows - Release|Windows = Release|Windows - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {263D800B-80DF-45FB-B6FF-49EBBD6016FA}.Debug|Windows.ActiveCfg = Debug|x64 - {263D800B-80DF-45FB-B6FF-49EBBD6016FA}.Debug|Windows.Build.0 = Debug|x64 - {263D800B-80DF-45FB-B6FF-49EBBD6016FA}.Profile|Windows.ActiveCfg = Profile|x64 - {263D800B-80DF-45FB-B6FF-49EBBD6016FA}.Profile|Windows.Build.0 = Profile|x64 - {263D800B-80DF-45FB-B6FF-49EBBD6016FA}.Release|Windows.ActiveCfg = Release|x64 - {263D800B-80DF-45FB-B6FF-49EBBD6016FA}.Release|Windows.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/xess/samples/xess_demo/MiniEngine/Tools/SDFFontCreator/SDFFontCreator_VS15.vcxproj b/xess/samples/xess_demo/MiniEngine/Tools/SDFFontCreator/SDFFontCreator_VS15.vcxproj deleted file mode 100644 index 4b7cc41..0000000 --- a/xess/samples/xess_demo/MiniEngine/Tools/SDFFontCreator/SDFFontCreator_VS15.vcxproj +++ /dev/null @@ -1,76 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {263D800B-80DF-45FB-B6FF-49EBBD6016FA} - title - en-US - Win32Proj - SDFFontCreator - SDFFontCreator - v141 - 15.0 - Native - 10.0.15063.0 - - - - Application - v141 - Unicode - - - - - - - - - - - - - - - - /nodefaultlib:MSVCRT %(AdditionalOptions) - - - - - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - - - - - - - ..\..\Packages\freetype.2.7.1.1\build\native\lib\x64\v140\static\Release;%(AdditionalLibraryDirectories) - freetype271.lib;%(AdditionalDependencies) - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Tools/SDFFontCreator/SDFFontCreator_VS15.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Tools/SDFFontCreator/SDFFontCreator_VS15.vcxproj.filters deleted file mode 100644 index fafecbb..0000000 --- a/xess/samples/xess_demo/MiniEngine/Tools/SDFFontCreator/SDFFontCreator_VS15.vcxproj.filters +++ /dev/null @@ -1,21 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Tools/SDFFontCreator/packages.config b/xess/samples/xess_demo/MiniEngine/Tools/SDFFontCreator/packages.config deleted file mode 100644 index 436c670..0000000 --- a/xess/samples/xess_demo/MiniEngine/Tools/SDFFontCreator/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/BinaryFileToCHeader.py b/xess/samples/xess_demo/MiniEngine/Tools/Scripts/BinaryFileToCHeader.py deleted file mode 100644 index bb2c2ae..0000000 --- a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/BinaryFileToCHeader.py +++ /dev/null @@ -1,49 +0,0 @@ -def ConvertFile( binaryFileName, headerFileName=None, symbolName=None ): - - # Open binary file for reading - print('Attempting to convert binary file ' + binaryFileName) - infile = open(binaryFileName, 'rb') - - # Create a header file name if none specified - if headerFileName == None: - suffixStart = binaryFileName.rfind('.') - if suffixStart > 0: - headerFileName = binaryFileName[:suffixStart] - else: - headerFileName = binaryFileName - headerFileName += '.h' - - # If no symbol name was specified, derive it from the header file name - if symbolName == None: - symbolName = 'g_p' + headerFileName.rstrip('.h') - - # Read contents - contents = infile.read() - - # Begin writing new file - outfile = open(headerFileName, 'w') - outfile.write('unsigned char {0}[{1}] =\n{{\n'.format(symbolName, len(contents))) - - bulkCount = len(contents) - remainder = bulkCount % 16 - if remainder == 0: - remainder = 16 - bulkCount -= remainder - - for idx in range(0, bulkCount, 16): - outfile.write('\t') - for c in contents[idx : idx + 16]: - outfile.write( '{0:#0{1}x},'.format(int(c), 4) ) - outfile.write('\n') - outfile.write('\t') - for c in contents[-remainder : -1]: - outfile.write( '{0:#0{1}x},'.format(int(c), 4) ) - outfile.write( '{0:#0{1}x}\n'.format(int(contents[-1]), 4) + '};\n' ) - - outfile.close() - - print('Created binary symbol {0} in header file {1} '.format(symbolName, headerFileName)) - -if __name__ == "__main__": - import sys - ConvertFile(sys.argv[1]) \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/CleanFiles.py b/xess/samples/xess_demo/MiniEngine/Tools/Scripts/CleanFiles.py deleted file mode 100644 index e934d8e..0000000 --- a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/CleanFiles.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -''' -Copyright (c) Microsoft. All rights reserved. -This code is licensed under the MIT License (MIT). -THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. - -Developed by Minigraph - -Author: James Stanard -''' - -import os -import sys - -def clean_line(line): - '''Cleans the white space on a single line of text''' - line = line.rstrip(' \n') + '\n' - leading_tabs = 0 - while line[leading_tabs] == '\t': - leading_tabs += 1 - return ' ' * leading_tabs + line[leading_tabs:] - -def clean_file(filename): - '''Cleans the white space in a file''' - print('processing ' + filename) - try: - lines = open(filename, 'r').readlines() - with open(filename, 'w') as outfile: - for line in lines: - outfile.write(clean_line(line)) - except OSError: - print(' ***Failed') - -if __name__ == "__main__": - start_path = '.' - if len(sys.argv) > 1: - start_path = sys.argv[1] - for root, dirs, files in os.walk(start_path): - # Clean only files with these extensions - for file in files: - if file.lower().endswith(('.h', '.cpp', '.hlsl', '.hlsli', '.py')): - clean_file(os.path.join(root, file)) - # Do not walk these subdirectories. Remove them from the list - i = 0 - while i < len(dirs): - if dirs[i].startswith(('3rdParty', 'Tools', 'Build', 'Durango', 'Fonts', 'users')): - del dirs[i] - else: - i += 1 diff --git a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/CreateNewProject.py b/xess/samples/xess_demo/MiniEngine/Tools/Scripts/CreateNewProject.py deleted file mode 100644 index 0c61419..0000000 --- a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/CreateNewProject.py +++ /dev/null @@ -1,74 +0,0 @@ -''' -Copyright (c) Microsoft. All rights reserved. -This code is licensed under the MIT License (MIT). -THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. - -Developed by Minigraph - -Author: James Stanard -''' - -import os -import sys -import shutil -from glob import glob -from uuid import uuid4 - -TEMPLATES_FOLDER = "./Tools/Scripts/ProjectTemplates" - -def copy_template_file(filename, project, guid): - '''Copies one template file and replaces templated values''' - template_filename = os.path.join(TEMPLATES_FOLDER, filename) - output_filename = os.path.join(project, filename) - output_filename = output_filename.replace('AppTemplate', project) - output_filename = output_filename.replace('LibTemplate', project) - with open(template_filename, 'r', encoding='utf-8') as infile: - with open(output_filename, 'w', encoding='utf-8') as outfile: - contents = infile.read() - contents = contents.replace('TEMPLATE_NAME', project) - contents = contents.replace('TEMPLATE_GUID', guid) - outfile.write(contents) - -def copy_app_template(project, guid): - '''Instantiates a new solution from a template''' - shutil.copy(os.path.join(TEMPLATES_FOLDER, 'packages.config'), project) - shutil.copy(os.path.join(TEMPLATES_FOLDER, 'pch.h'), project) - shutil.copy(os.path.join(TEMPLATES_FOLDER, 'pch.cpp'), project) - copy_template_file('Main.cpp', project, guid) - copy_template_file('AppTemplate.sln', project, guid) - copy_template_file('AppTemplate.vcxproj', project, guid) - copy_template_file('AppTemplate.vcxproj.filters', project, guid) - for file in glob(os.path.join(TEMPLATES_FOLDER, '*.png')): - shutil.copy(file, project) - -def copy_lib_template(project, guid): - '''Instantiates a new library project from a template''' - shutil.copy(os.path.join(TEMPLATES_FOLDER, 'pch.h'), project) - shutil.copy(os.path.join(TEMPLATES_FOLDER, 'pch.cpp'), project) - copy_template_file('LibTemplate.vcxproj', project, guid) - copy_template_file('LibTemplate.vcxproj.filters', project, guid) - -def create_project(): - if len(sys.argv) != 3 or sys.argv[1].lower() != 'app' and sys.argv[1].lower() != 'lib': - print('Usage: {0} [app|lib] '.format(sys.argv[0])) - return - - project_name = sys.argv[2] - folder_contents = set(os.listdir()) - expected_contents = set(['readme.md', 'Core', 'Tools']) - if not expected_contents.issubset(folder_contents): - print('Run this script from the root of MiniEngine') - elif project_name in folder_contents: - print('Project already exists') - else: - os.mkdir(project_name) - if sys.argv[1].lower() == 'app': - copy_app_template(project_name, str(uuid4()).upper()) - else: - copy_lib_template(project_name, str(uuid4()).upper()) - -if __name__ == "__main__": - create_project() diff --git a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/GenerateDoFSampleOffsets.py b/xess/samples/xess_demo/MiniEngine/Tools/Scripts/GenerateDoFSampleOffsets.py deleted file mode 100644 index 4b8660b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/GenerateDoFSampleOffsets.py +++ /dev/null @@ -1,41 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Created on Wed May 27 10:42:38 2015 - -@author: jstanard -""" - -from math import pi, sin, cos - -def GenerateCircularSamplePattern( name, numSamples, radius = 1.0): - print('static const float2 {}[{}] =\n{{'.format(name, numSamples)) - for sample in range(numSamples // 2): - angle = sample / numSamples * 2.0 * pi - x, y = radius * cos(angle), radius * sin(angle) - print(' {{ {: 8f}, {: 8f} }}, {{ {: 8f}, {: 8f} }},'.format(x, y, -x, -y)) - print('}; // ', name) - print(); - - -GenerateCircularSamplePattern('s_Ring1', 8, 6.0) - -GenerateCircularSamplePattern('s_Ring2', 16, 11.0) - -GenerateCircularSamplePattern('s_Ring3', 24, 16.0) - -def GenerateQuantizedCircularSamplePattern( name, numSamples, radius = 1.0): - print('static const int {}[{}] =\n{{'.format(name, numSamples)) - for sample in range(numSamples // 2): - angle = sample / numSamples * 2.0 * pi - x, y = radius * cos(angle), radius * sin(angle) - offset = round(x / 2) + round(y / 2) * 24 - print(' {: 4}, {: 4},'.format(offset, -offset)) - print('}; // ', name) - print(); - - -GenerateQuantizedCircularSamplePattern('s_Ring1Q', 8, 6.0) - -GenerateQuantizedCircularSamplePattern('s_Ring2Q', 16, 11.0) - -GenerateQuantizedCircularSamplePattern('s_Ring3Q', 24, 16.0) diff --git a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/AppTemplate.sln b/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/AppTemplate.sln deleted file mode 100644 index 017ebc0..0000000 --- a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/AppTemplate.sln +++ /dev/null @@ -1,33 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 16 -VisualStudioVersion = 16 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TEMPLATE_NAME", "TEMPLATE_NAME.vcxproj", "{TEMPLATE_GUID}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Core", "..\Core\Core.vcxproj", "{86A58508-0D6A-4786-A32F-01A301FDC6F3}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Windows = Debug|Windows - Profile|Windows = Profile|Windows - Release|Windows = Release|Windows - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {TEMPLATE_GUID}.Debug|Windows.ActiveCfg = Debug|x64 - {TEMPLATE_GUID}.Debug|Windows.Build.0 = Debug|x64 - {TEMPLATE_GUID}.Profile|Windows.ActiveCfg = Profile|x64 - {TEMPLATE_GUID}.Profile|Windows.Build.0 = Profile|x64 - {TEMPLATE_GUID}.Release|Windows.ActiveCfg = Release|x64 - {TEMPLATE_GUID}.Release|Windows.Build.0 = Release|x64 - {86A58508-0D6A-4786-A32F-01A301FDC6F3}.Debug|Windows.ActiveCfg = Debug|x64 - {86A58508-0D6A-4786-A32F-01A301FDC6F3}.Debug|Windows.Build.0 = Debug|x64 - {86A58508-0D6A-4786-A32F-01A301FDC6F3}.Profile|Windows.ActiveCfg = Profile|x64 - {86A58508-0D6A-4786-A32F-01A301FDC6F3}.Profile|Windows.Build.0 = Profile|x64 - {86A58508-0D6A-4786-A32F-01A301FDC6F3}.Release|Windows.ActiveCfg = Release|x64 - {86A58508-0D6A-4786-A32F-01A301FDC6F3}.Release|Windows.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/AppTemplate.vcxproj b/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/AppTemplate.vcxproj deleted file mode 100644 index d0e12ce..0000000 --- a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/AppTemplate.vcxproj +++ /dev/null @@ -1,97 +0,0 @@ - - - - - Debug - x64 - - - Profile - x64 - - - Release - x64 - - - - TEMPLATE_NAME - {TEMPLATE_GUID} - en-US - Win32Proj - TEMPLATE_NAME - v142 - 16.0 - Native - 10.0.19041.0 - - - - Application - v142 - Unicode - false - - - - - - - - - - - - NotUsing - - true - ..\Core;%(AdditionalIncludeDirectories) - - - /nodefaultlib:MSVCRT %(AdditionalOptions) - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - - - - Create - - - - - {86A58508-0D6A-4786-A32F-01A301FDC6F3} - false - - - - - - - - - - - - - - - ..\..\Packages\zlib-msvc-x64.1.2.11.8900\build\native\lib_release;%(AdditionalLibraryDirectories) - zlibstatic.lib;%(AdditionalDependencies) - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/AppTemplate.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/AppTemplate.vcxproj.filters deleted file mode 100644 index f20a21a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/AppTemplate.vcxproj.filters +++ /dev/null @@ -1,45 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {06dcf987-d5c3-489b-aa0a-88d547a323d5} - - - - - Source Files - - - - - - - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - Resource Files - - - diff --git a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/LibTemplate.vcxproj b/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/LibTemplate.vcxproj deleted file mode 100644 index 97ef61a..0000000 --- a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/LibTemplate.vcxproj +++ /dev/null @@ -1,64 +0,0 @@ - - - - - Debug - x64 - - - Profile - x64 - - - Release - x64 - - - - {TEMPLATE_GUID} - Win32Proj - TEMPLATE_NAME - TEMPLATE_NAME - en-US - Win32Proj - 16.0 - 10.0.19041.0 - Native - - - - StaticLibrary - v142 - Unicode - false - false - - - - - - - - - - - - - NotUsing - pch.h - true - - - d3d11.lib;dxguid.lib;winmm.lib;comctl32.lib;%(AdditionalDependencies) - Windows - true - MachineX64 - - - true - - - - - - diff --git a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/LibTemplate.vcxproj.filters b/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/LibTemplate.vcxproj.filters deleted file mode 100644 index 8390beb..0000000 --- a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/LibTemplate.vcxproj.filters +++ /dev/null @@ -1,8 +0,0 @@ - - - - - {3e74f37f-1e1e-47ed-9c44-213389384278} - - - diff --git a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/Logo.png b/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/Logo.png deleted file mode 100644 index 94df567..0000000 Binary files a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/Logo.png and /dev/null differ diff --git a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/Logo44.png b/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/Logo44.png deleted file mode 100644 index a07c1df..0000000 Binary files a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/Logo44.png and /dev/null differ diff --git a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/Main.cpp b/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/Main.cpp deleted file mode 100644 index b0efeaf..0000000 --- a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/Main.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "pch.h" -#include "GameCore.h" -#include "GraphicsCore.h" -#include "SystemTime.h" -#include "TextRenderer.h" -#include "GameInput.h" -#include "CommandContext.h" -#include "RootSignature.h" -#include "PipelineState.h" -#include "BufferManager.h" - -using namespace GameCore; -using namespace Graphics; - -class TEMPLATE_NAME : public GameCore::IGameApp -{ -public: - - TEMPLATE_NAME() - { - } - - virtual void Startup( void ) override; - virtual void Cleanup( void ) override; - - virtual void Update( float deltaT ) override; - virtual void RenderScene( void ) override; - -private: -}; - -CREATE_APPLICATION( TEMPLATE_NAME ) - -void TEMPLATE_NAME::Startup( void ) -{ - // Setup your data -} - -void TEMPLATE_NAME::Cleanup( void ) -{ - // Free up resources in an orderly fashion -} - -void TEMPLATE_NAME::Update( float /*deltaT*/ ) -{ - ScopedTimer _prof(L"Update State"); - - // Update something -} - -void TEMPLATE_NAME::RenderScene( void ) -{ - GraphicsContext& gfxContext = GraphicsContext::Begin(L"Scene Render"); - - gfxContext.TransitionResource(g_SceneColorBuffer, D3D12_RESOURCE_STATE_RENDER_TARGET, true); - gfxContext.ClearColor(g_SceneColorBuffer); - gfxContext.SetRenderTarget(g_SceneColorBuffer.GetRTV()); - gfxContext.SetViewportAndScissor(0, 0, g_SceneColorBuffer.GetWidth(), g_SceneColorBuffer.GetHeight()); - - // Rendering something - - gfxContext.Finish(); -} diff --git a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/SmallLogo.png b/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/SmallLogo.png deleted file mode 100644 index 2da88a2..0000000 Binary files a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/SmallLogo.png and /dev/null differ diff --git a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/SplashScreen.png b/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/SplashScreen.png deleted file mode 100644 index d450ace..0000000 Binary files a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/SplashScreen.png and /dev/null differ diff --git a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/StoreLogo.png b/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/StoreLogo.png deleted file mode 100644 index d562558..0000000 Binary files a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/StoreLogo.png and /dev/null differ diff --git a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/WideLogo.png b/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/WideLogo.png deleted file mode 100644 index 88a52a2..0000000 Binary files a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/WideLogo.png and /dev/null differ diff --git a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/packages.config b/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/packages.config deleted file mode 100644 index e41ca7b..0000000 --- a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/pch.cpp b/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/pch.cpp deleted file mode 100644 index 97b544e..0000000 --- a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/pch.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.cpp -// Include the standard header and generate the precompiled header. -// - -#include "pch.h" diff --git a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/pch.h b/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/pch.h deleted file mode 100644 index 0dc8c35..0000000 --- a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/ProjectTemplates/pch.h +++ /dev/null @@ -1,59 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// - -#pragma once - -#pragma warning(disable:4201) // nonstandard extension used : nameless struct/union -#pragma warning(disable:4328) // nonstandard extension used : class rvalue used as lvalue -#pragma warning(disable:4324) // structure was padded due to __declspec(align()) - -#include // for WINAPI_FAMILY -#include - -#ifndef WIN32_LEAN_AND_MEAN - #define WIN32_LEAN_AND_MEAN -#endif -#ifndef NOMINMAX - #define NOMINMAX -#endif -#include - -#include - -#pragma comment(lib, "d3d12.lib") -#pragma comment(lib, "dxgi.lib") - -#define D3D12_GPU_VIRTUAL_ADDRESS_NULL ((D3D12_GPU_VIRTUAL_ADDRESS)0) -#define D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN ((D3D12_GPU_VIRTUAL_ADDRESS)-1) -#define MY_IID_PPV_ARGS IID_PPV_ARGS - -#if _MSC_VER >= 1800 - #include - #include -#endif - -#include "d3dx12.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "Utility.h" -#include "VectorMath.h" -#include "EngineTuning.h" -#include "EngineProfiling.h" diff --git a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/TargaToDDS.py b/xess/samples/xess_demo/MiniEngine/Tools/Scripts/TargaToDDS.py deleted file mode 100644 index 192b7bd..0000000 --- a/xess/samples/xess_demo/MiniEngine/Tools/Scripts/TargaToDDS.py +++ /dev/null @@ -1,18 +0,0 @@ -def CompileTGA( filename, normalMap=False ): - import subprocess - - args = 'texconv.exe ' + filename + ' -nologo -vflip' - if normalMap: - args += ' -f BC1_UNORM' - else: - args += ' -srgbi -f BC1_UNORM_SRGB' - - print('Calling "{0}"'.format(args)) - subprocess.call(args.split()) - -if __name__ == "__main__": - import os - files = os.listdir() - for file in files: - if file.lower().endswith('.tga'): - CompileTGA(file, file.find('normal') != -1) diff --git a/xess/samples/xess_demo/MiniEngine/readme.md b/xess/samples/xess_demo/MiniEngine/readme.md deleted file mode 100644 index 527417c..0000000 --- a/xess/samples/xess_demo/MiniEngine/readme.md +++ /dev/null @@ -1,29 +0,0 @@ -# MiniEngine by Team Minigraph at Microsoft - -## Getting started: -* Open ModelViewer/ModelViewer_VS16.sln -* Select configuration: Debug (full validation), Profile (instrumented), Release -* Select platform -* Build and run - -## Controls: -* forward/backward/strafe: left thumbstick or WASD (FPS controls) -* up/down: triggers or E/Q -* yaw/pitch: right thumbstick or mouse -* toggle slow movement: click left thumbstick or lshift -* open debug menu: back button or backspace -* navigate debug menu: dpad or arrow keys -* toggle debug menu item: A button or return -* adjust debug menu value: dpad left/right or left/right arrow keys - -## glTF 2.0 Support: - -Get sample assets from https://github.com/KhronosGroup/glTF-Sample-Models or make your own. - -* Place asset folder underneath the ModelViewer folder -* Add to command line "-model [relative path to gltf or glb file]" -* Example: ModelViewer.exe -model SciFiHelmet/glTF/SciFiHelmet.gltf - -Notes: Some IBL cube maps are provided for physically based rendering in the ModelViewer/Textures folder. ModelViewer automatically detects cube maps in this folder so you can add your own. They must follow the same naming convention for diffuse and specular maps. You can change the active environment map in the tweak menu under the "ModelViewer" category. - -DirectXMesh and DirectXTex are used for compiling content the first time it is loaded. For example, image files will have mip maps generated, encoded to a block compressed format, and then saved as a DDS for subsequent loading. This means that first-time loading takes a little longer. diff --git a/xess/samples/xess_demo/README.md b/xess/samples/xess_demo/README.md deleted file mode 100644 index aa1d869..0000000 --- a/xess/samples/xess_demo/README.md +++ /dev/null @@ -1,43 +0,0 @@ -# XeSS-Demo -This is a demo of Intel Xe Super Sampling (XeSS), using the MiniEngine from [DirectX-Graphics-Sample](https://github.com/microsoft/DirectX-Graphics-Samples) - - -## Folder contents -| Folder / file | Description | -| ----------- | ----------- | -| README.md | This readme file | -| Source | Source code folder of the sample application | -| MiniEngine | Folder of the modified version of Microsoft MiniEngine supporting XeSS | -| Assets | Art assets folder | -| CMakeLists.txt | Build configuration file for CMake | - -## Sample code explanation -| Folder / file | Description | -| ----------- | ----------- | -| DemoApp.h/cpp | Application entry of the sample | -| DemoCameraController.h/cpp | Camera controller of the sample | -| DemoGui.h/cpp | ImGui based GUI code of the sample | -| XeSS/XeSSRuntime.h/cpp | XeSS DX12 runtime wrapper | -| XeSS/XeSSProcess.h/cpp | Management for XeSS processing | -| XeSS/XeSSJitter.h/cpp | Camera jittering management for XeSS | -| XeSS/XeSSDebug.h/cpp | Debugging for XeSS | -| Shaders/XeSSConvertLowResVelocityCS.hlsl | Shader code which converts velocity buffer from low-res to high-res | -| Shaders/XeSSGenerateHiResVelocityCS.hlsl | Shader code which generates high-res velocity buffer | -| Shaders/Debug/*.hlsl | Shaders for debugging purposes | - -## Keyboard and mouse controls: -- Toggle GUI display: F1 -- Forward/backward/strafe: WASD (FPS controls) / mouse wheel -- Up/down: E/Q key -- Yaw/pitch: Mouse move when any mouse button down -- Toggle fast movement: Shift key -- Open debug menu: Backspace -- Navigate debug menu: Arrow keys -- Toggle debug menu item: Return key -- Adjust debug menu value: Left/Right arrow keys - -## Build the sample: -``` -> cmake -S . -B build -> cmake --build build --config Debug --target ALL_BUILD -``` diff --git a/xess/samples/xess_demo/Script/utility.cmake b/xess/samples/xess_demo/Script/utility.cmake deleted file mode 100644 index 4544f51..0000000 --- a/xess/samples/xess_demo/Script/utility.cmake +++ /dev/null @@ -1,26 +0,0 @@ -function(hlsl_compile SHADER_FILES SHADER_TYPE SHADER_INC_PATH SHADER_DEFINES SHADER_DEBUG) - # HLSL compiler only receive path with back-slash. - STRING(REGEX REPLACE "/" "\\\\" SHADER_INC_PATH ${SHADER_INC_PATH}) - - if (${SHADER_DEBUG}) - set (SHADER_FLAGS "/Vn\"g_p%(Filename)\" /I\"${SHADER_INC_PATH}\" /D \"${SHADER_DEFINES}\" /Zi /Od -Qembed_debug") - else() - set (SHADER_FLAGS "/Vn\"g_p%(Filename)\" /I\"${SHADER_INC_PATH}\" /D \"${SHADER_DEFINES}\"") - endif() - - set_property(SOURCE ${SHADER_FILES} PROPERTY VS_SHADER_TYPE ${SHADER_TYPE}) - set_property(SOURCE ${SHADER_FILES} PROPERTY VS_SHADER_ENTRYPOINT main) - set_property(SOURCE ${SHADER_FILES} PROPERTY VS_SHADER_MODEL 6.2) - set_property(SOURCE ${SHADER_FILES} PROPERTY VS_SHADER_FLAGS ${SHADER_FLAGS}) - set_property(SOURCE ${SHADER_FILES} PROPERTY VS_SHADER_OUTPUT_HEADER_FILE "$(OutDir)CompiledShaders/%(Filename).h") - set_property(SOURCE ${SHADER_FILES} PROPERTY VS_SHADER_OBJECT_FILE_NAME "") -endfunction() - - -macro(set_msvc_precompiled_header PCH_HEADER PCH_CREATE_SOURCE_FILES PCH_USE_SOURCE_FILES) - if (MSVC) - set_source_files_properties(${PCH_USE_SOURCE_FILES} PROPERTIES COMPILE_FLAGS "/Yu\"${PCH_HEADER}\" /FI\"${PCH_HEADER}\"") - set_source_files_properties(${PCH_CREATE_SOURCE_FILES} PROPERTIES COMPILE_FLAGS "/Yc\"${PCH_HEADER}\"") - endif() -endmacro(set_msvc_precompiled_header) - diff --git a/xess/samples/xess_demo/Source/DemoApp.cpp b/xess/samples/xess_demo/Source/DemoApp.cpp deleted file mode 100644 index b4b41e2..0000000 --- a/xess/samples/xess_demo/Source/DemoApp.cpp +++ /dev/null @@ -1,575 +0,0 @@ -/******************************************************************************* - * Copyright 2021 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files(the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions : - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ - -#include "pch.h" -#include "DemoApp.h" -#include "GameCore.h" -#include "CommandContext.h" -#include "BufferManager.h" -#include "DemoCameraController.h" -#include "ImGuiModule.h" -#include "MotionBlur.h" -#include "TemporalEffects.h" -#include "PostEffects.h" -#include "Renderer.h" -#include "SponzaRenderer.h" -#include "SSAO.h" -#include "FXAA.h" -#include "GameInput.h" -#include "ParticleEffectManager.h" -#include "DepthOfField.h" -#include "Display.h" -#include "EngineProfiling.h" -#include "Utility.h" -#include "DemoGui.h" -#include "XeSS/XeSSJitter.h" -#include "XeSS/XeSSProcess.h" -#include "ModelLoader.h" -#include "LightManager.h" -#include "ParticleEffects.h" - -CREATE_APPLICATION(DemoApp) - -using namespace GameCore; -using namespace Graphics; -using namespace Utility; -using namespace Renderer; - -namespace GameInput -{ - extern bool g_bMouseExclusive; -} - -namespace GameCore -{ - extern HWND g_hWnd; -} - -namespace Graphics -{ - extern EnumVar DebugZoom; - extern EnumVar NativeResolution; - extern EnumVar DisplayResolution; -} // namespace Graphics - -namespace EngineProfiling -{ - extern BoolVar DrawFrameRate; -} - -ExpVar g_SunLightIntensity("Viewer/Lighting/Sun Light Intensity", 4.0f, 0.0f, 16.0f, 0.1f); -NumVar g_SunOrientation("Viewer/Lighting/Sun Orientation", -0.5f, -100.0f, 100.0f, 0.1f); -NumVar g_SunInclination("Viewer/Lighting/Sun Inclination", 0.75f, 0.0f, 1.0f, 0.01f); - -void ChangeIBLBias(EngineVar::ActionType); -NumVar g_IBLBias("Viewer/Lighting/EnvironmentMap Blur", 0.0f, 0.0f, 10.0f, 0.1f, ChangeIBLBias); - -NumVar g_EnvRotX("Viewer/Lighting/Environment Rotation X", 3, 0, 3, 1); -NumVar g_EnvRotY("Viewer/Lighting/Environment Rotation Y", 0, 0, 3, 1); - - -void ChangeIBLBias(EngineVar::ActionType) -{ - Renderer::SetIBLBias(g_IBLBias); -} - -DemoApp::DemoApp() - : m_ShowUI(true) - , m_Technique(kDemoTech_XeSS) -{ - // We register extra buffers handler before graphics initialization. - Graphics::SetExtraRenderingBuffersHandler(&m_ExtraBuffersHandler); - - // Use non-exclusive mouse input. - GameInput::g_bMouseExclusive = false; -} - -DemoApp::~DemoApp() -{ - Graphics::SetExtraRenderingBuffersHandler(nullptr); -} - -void DemoApp::Startup() -{ - SetWindowText(GameCore::g_hWnd, L"XeSS Demo"); - - std::wstring cwd = GetWorkingDirectory(); - SetWorkingDirectory(GetProgramDirectory()); - - FindAssetsDir(); - - Graphics::g_bArbitraryResolution = true; - Display::s_EnableVSync = false; - EngineProfiling::DrawFrameRate = false; - MotionBlur::Enable = true; - TemporalEffects::EnableTAA = true; - TemporalEffects::Sharpness = 0.0f; - FXAA::Enable = false; - PostEffects::EnableHDR = true; - PostEffects::EnableAdaptation = true; - SSAO::Enable = false; - SSAO::g_QualityLevel = SSAO::kSsaoQualityVeryHigh; - - Renderer::Initialize(); - - ImGuiModule::Initialize(); - - DemoGui::Initialize(); - - XeSS::Initialize(); - XeSS::SetEnabled(true); - XeSS::SetQuality(XeSS::kQualityBalanced); - XeSS::SetMotionVectorsMode(XeSS::kMotionVectorsHighRes); - XeSS::SetMipBiasMode(XeSS::kMipBiasAutomatic); - - LoadIBLTextures(); - - bool forceRebuild = false; - uint32_t rebuildValue; - if (CommandLineArgs::GetInteger(L"rebuild", rebuildValue)) - forceRebuild = rebuildValue != 0; - - std::wstring gltfFileName; - if (CommandLineArgs::GetString(L"model", gltfFileName) == false) - { - m_ModeInstance = Renderer::LoadModel(m_AssetRootDir + L"/Sponza/pbr/sponza2.gltf", forceRebuild); - } - else - { - m_ModeInstance = Renderer::LoadModel(gltfFileName, forceRebuild); - } - - if (!m_ModeInstance.IsNull()) - { - m_ModeInstance.LoopAllAnimations(); - - // Scale to match the size of old version of Sponza. - float modelScale = 4637.0f / Math::Max((float)(Length(m_ModeInstance.GetModel()->m_BoundingBox.GetDimensions())), 0.1f); - m_ModeInstance.Resize(m_ModeInstance.GetRadius() * modelScale); - - OrientedBox obb = m_ModeInstance.GetBoundingBox(); - float modelRadius = Length(obb.GetDimensions()) * 0.5f; - const Vector3 eye = obb.GetCenter() + Vector3(modelRadius * 0.5f, 0.0f, 0.0f); - m_Camera.SetEyeAtUp(eye, Vector3(kZero), Vector3(kYUnitVector)); - m_Camera.SetZRange(1.0f, 10000.0f); - - m_CameraController.reset(new DemoCameraController(m_Camera, Vector3(kYUnitVector))); - m_Camera.SetPerspectiveMatrix(XM_PIDIV4, g_DisplayHeight / static_cast(g_DisplayWidth), 1.0f, 10000.0f); - - Lighting::CreateRandomLights(m_ModeInstance.GetModel()->m_BoundingBox.GetMin() * modelScale, m_ModeInstance.GetModel()->m_BoundingBox.GetMax() * modelScale); - } - - ParticleEffects::InitFromJSON(m_AssetRootDir + L"/Particle/particles.json", m_AssetRootDir); - - SetWorkingDirectory(cwd); -} - -void DemoApp::Cleanup(void) -{ - m_Log.Flush(); - - DemoGui::Shutdown(); - - ImGuiModule::Shutdown(); - - XeSS::Shutdown(); - - ParticleEffects::ClearTexturePool(); - - m_ModeInstance = nullptr; - - Renderer::Shutdown(); -} - -void DemoApp::Update(float deltaTime) -{ - ScopedTimer _prof(L"Update State"); - - m_Log.Flush(); - - UpdateResolution(); - - ImGuiModule::PreGUI(); - - DemoGui::OnGUI(*this); - - XeSS::Update(); - - if (GameInput::IsFirstPressed(GameInput::kLShoulder)) - DebugZoom.Decrement(); - else if (GameInput::IsFirstPressed(GameInput::kRShoulder)) - DebugZoom.Increment(); - - if (m_Technique == kDemoTech_XeSS) - { - // Apply projection jitter for the main camera. - float jitterX, jitterY; - XeSSJitter::GetJitterValues(jitterX, jitterY); - XeSSJitter::ApplyCameraJitter(m_Camera, jitterX, jitterY); - } - else - { - float jitterX, jitterY; - TemporalEffects::GetJitterOffset(jitterX, jitterY); - - // Instead of using viewport offset, we use projection matrix jitter. - // So here we borrow function from XeSSJitter to apply jitter to the camera. - XeSSJitter::ApplyCameraJitter(m_Camera, jitterX, jitterY); - } - - m_CameraController->Update(deltaTime); - - m_MainViewport.TopLeftX = 0.0f; - m_MainViewport.TopLeftY = 0.0f; - m_MainViewport.Width = (float)g_SceneColorBuffer.GetWidth(); - m_MainViewport.Height = (float)g_SceneColorBuffer.GetHeight(); - m_MainViewport.MinDepth = 0.0f; - m_MainViewport.MaxDepth = 1.0f; - - m_MainScissor.left = 0; - m_MainScissor.top = 0; - m_MainScissor.right = (LONG)g_SceneColorBuffer.GetWidth(); - m_MainScissor.bottom = (LONG)g_SceneColorBuffer.GetHeight(); - - ImGuiModule::PostGUI(); - - GraphicsContext& gfxContext = GraphicsContext::Begin(L"Scene Update"); - - m_ModeInstance.Update(gfxContext, deltaTime); - - gfxContext.Finish(); -} - -void DemoApp::UpdateResolution() -{ - RECT rect; - if (!GetClientRect(g_hWnd, &rect)) - return; - - uint32_t width = rect.right - rect.left; - uint32_t height = rect.bottom - rect.top; - - if (!width || !height) - return; - - if (g_DisplayWidth != width || g_DisplayHeight != height) - { - Display::Resize(width, height); - - XeSS::SetOutputResolution(width, height); - XeSS::UpdateRuntime(); - - if (m_Technique == kDemoTech_XeSS) - { - XeSS::UpdateInputResolution(); - } - else if (m_Technique == kDemoTech_TAANative) - { - Graphics::SetNativeResolutionAndUpscaling(g_DisplayWidth, g_DisplayHeight, false); - } - else if (m_Technique == kDemoTech_TAAScaled) - { - uint32_t nativeWidth, nativeHeight; - XeSS::GetInputResolution(nativeWidth, nativeHeight); - Graphics::SetNativeResolutionAndUpscaling(nativeWidth, nativeHeight, false); - } - - g_DisplayWidth = width; - g_DisplayHeight = height; - - m_Camera.SetPerspectiveMatrix(XM_PIDIV4, height / static_cast(width), - m_Camera.GetNearClip(), m_Camera.GetFarClip()); - } -} - -void DemoApp::RenderScene(void) -{ - GraphicsContext& gfxContext = GraphicsContext::Begin(L"Scene Render"); - - uint32_t FrameIndex = TemporalEffects::GetFrameIndexMod2(); - const D3D12_VIEWPORT& viewport = m_MainViewport; - const D3D12_RECT& scissor = m_MainScissor; - - if (ParticleEffectManager::Enable) - { - ParticleEffectManager::Update(gfxContext.GetComputeContext(), Graphics::GetFrameTime()); - } - - float mipBias = (m_Technique == kDemoTech_XeSS || m_Technique == kDemoTech_TAAScaled) ? XeSS::GetMipBias() : 0.0f; - { - // Update global constants - float costheta = cosf(g_SunOrientation); - float sintheta = sinf(g_SunOrientation); - float cosphi = cosf(g_SunInclination * 3.14159f * 0.5f); - float sinphi = sinf(g_SunInclination * 3.14159f * 0.5f); - - Vector3 SunDirection = Normalize(Vector3(costheta * cosphi, sinphi, sintheta * cosphi)); - Vector3 ShadowBounds = Vector3(m_ModeInstance.GetRadius()); - m_SunShadowCamera.UpdateMatrix(-SunDirection, m_ModeInstance.GetCenter(), ShadowBounds, - (uint32_t)g_ShadowBuffer.GetWidth(), (uint32_t)g_ShadowBuffer.GetHeight(), 16); - - GlobalConstants globals; - globals.ViewProjMatrix = m_Camera.GetViewProjMatrix(); - globals.SunShadowMatrix = m_SunShadowCamera.GetShadowMatrix(); - globals.EnvRotation = Matrix3::MakeYRotation(XM_PIDIV2 * float(g_EnvRotX)) * Matrix3::MakeXRotation(XM_PIDIV2 * float(g_EnvRotY)); - globals.CameraPos = m_Camera.GetPosition(); - globals.SunDirection = SunDirection; - globals.SunIntensity = Scalar(g_SunLightIntensity); - globals.ViewMipBias = mipBias; - - // Lights shadow - { - using namespace Lighting; - - static uint32_t LightIndex = 0; - if (LightIndex < MaxLights) - { - ScopedTimer _prof(L"Generate lights shadow", gfxContext); - - m_LightShadowTempBuffer.BeginRendering(gfxContext); - { - ShadowCamera lightShadowCamera; - lightShadowCamera.SetPosition(m_Camera.GetPosition()); - lightShadowCamera.SetViewProjMatrix(m_LightShadowMatrix[LightIndex]); - - MeshSorter shadowSorter(MeshSorter::kShadows); - - shadowSorter.SetCullEnabled(false); - shadowSorter.SetCamera(lightShadowCamera); - shadowSorter.SetDepthStencilTarget(m_LightShadowTempBuffer); - - m_ModeInstance.Render(shadowSorter); - - shadowSorter.Sort(); - shadowSorter.RenderMeshes(MeshSorter::kZPass, gfxContext, globals); - } - - gfxContext.TransitionResource(m_LightShadowTempBuffer, D3D12_RESOURCE_STATE_COPY_SOURCE); - gfxContext.TransitionResource(m_LightShadowArray, D3D12_RESOURCE_STATE_COPY_DEST); - - gfxContext.CopySubresource(m_LightShadowArray, LightIndex, m_LightShadowTempBuffer, 0); - - gfxContext.TransitionResource(m_LightShadowArray, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - - ++LightIndex; - } - } - - // Begin rendering depth - gfxContext.TransitionResource(g_SceneDepthBuffer, D3D12_RESOURCE_STATE_DEPTH_WRITE, true); - gfxContext.ClearDepth(g_SceneDepthBuffer); - - MeshSorter sorter(MeshSorter::kDefault); - sorter.SetCamera(m_Camera); - sorter.SetViewport(viewport); - sorter.SetScissor(scissor); - sorter.SetDepthStencilTarget(g_SceneDepthBuffer); - sorter.AddRenderTarget(g_SceneColorBuffer); - - m_ModeInstance.Render(sorter); - - sorter.Sort(); - - { - ScopedTimer _prof(L"Depth Pre-Pass", gfxContext); - sorter.RenderMeshes(MeshSorter::kZPass, gfxContext, globals); - } - - SSAO::Render(gfxContext, m_Camera); - - // Fill light grid for transparent objects. - Lighting::FillLightGrid(gfxContext, m_Camera, true); - // Fill light grid for solid objects. - Lighting::FillLightGrid(gfxContext, m_Camera, false); - - if (!SSAO::DebugDraw) - { - ScopedTimer _outerprof(L"Main Render", gfxContext); - - { - ScopedTimer _prof(L"Sun Shadow Map", gfxContext); - - MeshSorter shadowSorter(MeshSorter::kShadows); - shadowSorter.SetCamera(m_SunShadowCamera); - shadowSorter.SetDepthStencilTarget(g_ShadowBuffer); - shadowSorter.SetCullEnabled(false); - - m_ModeInstance.Render(shadowSorter); - - shadowSorter.Sort(); - shadowSorter.RenderMeshes(MeshSorter::kZPass, gfxContext, globals); - } - - gfxContext.TransitionResource(g_SceneColorBuffer, D3D12_RESOURCE_STATE_RENDER_TARGET, true); - gfxContext.ClearColor(g_SceneColorBuffer); - - { - ScopedTimer _prof(L"Render Opaque", gfxContext); - - gfxContext.TransitionResource(g_SSAOFullScreen, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - gfxContext.TransitionResource(g_SceneDepthBuffer, D3D12_RESOURCE_STATE_DEPTH_READ); - gfxContext.SetRenderTarget(g_SceneColorBuffer.GetRTV(), g_SceneDepthBuffer.GetDSV_DepthReadOnly()); - gfxContext.SetViewportAndScissor(viewport, scissor); - - sorter.RenderMeshes(MeshSorter::kOpaque, gfxContext, globals); - } - - Renderer::DrawSkybox(gfxContext, m_Camera, viewport, scissor, globals.EnvRotation); - - { - ScopedTimer _prof(L"Render Transparent", gfxContext); - - sorter.RenderMeshes(MeshSorter::kTransparent, gfxContext, globals); - } - } - } - - // Only update responsive when XeSS, may become a common requirement. - const bool isUpdateResponsiveMask = (m_Technique == kDemoTech_XeSS && XeSS::IsResponsiveMaskEnabled()); - - // clear responsive mask if necessary - if (isUpdateResponsiveMask) - { - gfxContext.TransitionResource(g_ResponsiveMaskBuffer, D3D12_RESOURCE_STATE_RENDER_TARGET, true); - gfxContext.ClearColor(g_ResponsiveMaskBuffer); - } - - if (ParticleEffectManager::Enable) - { - ParticleEffectManager::Render(gfxContext, m_Camera, g_SceneColorBuffer, g_SceneDepthBuffer, g_ResponsiveMaskBuffer, g_LinearDepth[FrameIndex], isUpdateResponsiveMask); - } - - if (m_Technique == kDemoTech_XeSS) - { - if (XeSS::GetMotionVectorsMode() == XeSS::kMotionVectorsLowRes) - { - MotionBlur::GenerateCameraVelocityBuffer(gfxContext, m_Camera, true); - } - - XeSS::Process(gfxContext, m_Camera); - } - else - { - MotionBlur::GenerateCameraVelocityBuffer(gfxContext, m_Camera, true); - TemporalEffects::ResolveImage(gfxContext); - } - - MotionBlur::RenderObjectBlur(gfxContext, g_VelocityBuffer); - - gfxContext.Finish(); -} - -void DemoApp::RenderUI(GraphicsContext& Context) -{ - ImGuiModule::Render(Context); -} - -eDemoTechnique DemoApp::GetTechnique() const -{ - return m_Technique; -} - -void DemoApp::SetTechnique(eDemoTechnique tech) -{ - if (m_Technique == tech) - return; - - if (tech == kDemoTech_XeSS) - { - XeSS::SetEnabled(true); - TemporalEffects::EnableTAA = false; - XeSS::UpdateInputResolution(); - } - else if (tech == kDemoTech_TAANative) - { - XeSS::SetEnabled(false); - TemporalEffects::EnableTAA = true; - Graphics::SetNativeResolutionAndUpscaling(g_DisplayWidth, g_DisplayHeight, false); - } - else if (tech == kDemoTech_TAAScaled) - { - XeSS::SetEnabled(false); - TemporalEffects::EnableTAA = true; - - // We use same resolution as XeSS. - uint32_t width, height; - XeSS::GetInputResolution(width, height); - Graphics::SetNativeResolutionAndUpscaling(width, height, false); - } - - XeSSJitter::Reset(); - - m_Technique = tech; -} - -void DemoApp::LoadIBLTextures() -{ - TextureRef BRDFLUTTexture = TextureManager::LoadDDSFromFile(m_AssetRootDir + L"/Textures/BRDF_LUT.dds"); - Renderer::SetBRDFLUTTexture(BRDFLUTTexture); - - TextureRef diffuseTexture = TextureManager::LoadDDSFromFile(m_AssetRootDir + L"/Textures/Blouberg_diffuseIBL.dds"); - TextureRef specularTexture = TextureManager::LoadDDSFromFile(m_AssetRootDir + L"/Textures/Blouberg_specularIBL.dds"); - Renderer::SetIBLTextures(diffuseTexture, specularTexture); -} - -CameraController* DemoApp::GetCameraController() const -{ - return m_CameraController.get(); -} - -DemoLog& DemoApp::GetLog() -{ - return m_Log; -} - -bool DemoApp::FindAssetsDir() -{ - m_AssetRootDir = L""; - - const std::wstring& cwd = GetWorkingDirectory(); - - // Search under current working directory. - std::wstring assetDir = cwd + L"\\Assets"; - - struct _stat64 dirStat; - bool dirMissing = _wstat64(assetDir.c_str(), &dirStat) == -1; - if (!dirMissing) - { - m_AssetRootDir = assetDir; - return true; - } - - // Search under SDK demo folder - assetDir = cwd + L"\\..\\samples\\xess_demo\\Assets"; - dirMissing = _wstat64(assetDir.c_str(), &dirStat) == -1; - if (!dirMissing) - { - m_AssetRootDir = assetDir; - return true; - } - - LOG_ERROR("Could not find Assets folder, please copy it from \"{SDK_DIR}/samples/xess_demo\"."); - MessageBox(GameCore::g_hWnd, L"Could not find Assets folder, please copy it from \"{SDK_DIR}/samples/xess_demo\".", - L"XeSS Demo: Assets missing", MB_OK); - - return false; -} diff --git a/xess/samples/xess_demo/Source/DemoApp.h b/xess/samples/xess_demo/Source/DemoApp.h deleted file mode 100644 index ab6e4aa..0000000 --- a/xess/samples/xess_demo/Source/DemoApp.h +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright 2021 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files(the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions : - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ - -#include "GameCore.h" -#include "Camera.h" -#include "Model.h" -#include "ShadowCamera.h" -#include "DemoExtraBuffers.h" -#include "DemoLog.h" -#include - -class CameraController; - -enum eDemoTechnique -{ - kDemoTech_XeSS = 0, - kDemoTech_TAANative, - kDemoTech_TAAScaled, - kDemoTech_Num -}; - -/// XeSS Demo application class. -class DemoApp : public GameCore::IGameApp -{ -public: - /// Constructor. - DemoApp(); - /// Destructor. - ~DemoApp(); - - /// Called when application starting up. - virtual void Startup() override; - /// Called when application finalizing. - virtual void Cleanup() override; - /// Called in the update phase in the game loop. - virtual void Update(float deltaT) override; - - /// Called after Update in the game loop. - virtual void RenderScene() override; - /// Called at the end of the rendering. - virtual void RenderUI(GraphicsContext& Context) override; - - /// Get demo technique. - eDemoTechnique GetTechnique() const; - /// Set demo technique. - void SetTechnique(eDemoTechnique tech); - - /// Get camera controller. - CameraController* GetCameraController() const; - - /// Get Log Object - DemoLog& GetLog(); - - /// Find root directory of assets. - bool FindAssetsDir(); - -private: - /// Handle display resolution change. - void UpdateResolution(); - - /// Load IBL textures for the renderer. - void LoadIBLTextures(); - - /// Log object. - DemoLog m_Log; - /// Camera object. - Math::Camera m_Camera; - /// Shadow camera of the sun. - ShadowCamera m_SunShadowCamera; - /// Camera controller object, handles user interactions. - std::unique_ptr m_CameraController; - /// Viewport for scene rendering. - D3D12_VIEWPORT m_MainViewport; - /// Scissor for scene rendering. - D3D12_RECT m_MainScissor; - /// Extra buffers handler. - /// It takes care of creation and destruction of extra buffers when engine handles the default buffers. - DemoExtraBuffersHandler m_ExtraBuffersHandler; - /// If we should show UI. - bool m_ShowUI; - /// Current technique. - eDemoTechnique m_Technique; - /// Model of the scene. - ModelInstance m_ModeInstance; - /// Root assets folder - std::wstring m_AssetRootDir; -}; diff --git a/xess/samples/xess_demo/Source/DemoCameraController.cpp b/xess/samples/xess_demo/Source/DemoCameraController.cpp deleted file mode 100644 index 538e3a1..0000000 --- a/xess/samples/xess_demo/Source/DemoCameraController.cpp +++ /dev/null @@ -1,198 +0,0 @@ -/******************************************************************************* - * Copyright 2021 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files(the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions : - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ - -#include "pch.h" -#include "DemoCameraController.h" -#include "Camera.h" -#include "XeSS/XeSSDebug.h" - -namespace Graphics -{ - extern EnumVar DebugZoom; -} - -DemoCameraController::DemoCameraController(Camera& Camera_, Vector3 WorldUp) - : FlyingFPSCamera(Camera_, WorldUp) - , m_LastMousePos(0.0f, 0.0f) -{ - m_MoveSpeed = 500.0f; - m_StrafeSpeed = 500.0f; - m_MouseSensitivityX = 0.5f; - m_MouseSensitivityY = 0.5f; -} - -void DemoCameraController::Update(float DeltaTime) -{ - // Clamp delta time in case stutter happens. - DeltaTime = Math::Clamp(DeltaTime, 0.0f, 0.2f); - - float timeScale = Graphics::DebugZoom == 0 ? 1.0f : - Graphics::DebugZoom == 1 ? 0.5f : 0.25f; - - ImGuiIO& io = ImGui::GetIO(); - - bool speedUp = io.KeyShift; - - float speedScale = (speedUp ? 2.0f : 1.0f) * timeScale; - - float yaw = 0.0f; - float pitch = 0.0f; - float forward = 0.0f; - float strafe = 0.0f; - float ascent = 0.0f; - - // Update key interaction - if (!io.WantCaptureKeyboard && !XeSSDebug::IsFrameDumpOn()) - { - forward = m_MoveSpeed * speedScale * ((ImGui::IsKeyDown('W') ? DeltaTime : 0.0f) + (ImGui::IsKeyDown('S') ? -DeltaTime : 0.0f)); - strafe = m_StrafeSpeed * speedScale * ((ImGui::IsKeyDown('D') ? DeltaTime : 0.0f) + (ImGui::IsKeyDown('A') ? -DeltaTime : 0.0f)); - ascent = m_StrafeSpeed * speedScale * ((ImGui::IsKeyDown('E') ? DeltaTime : 0.0f) + (ImGui::IsKeyDown('Q') ? -DeltaTime : 0.0f)); - - // Mouse wheel interaction - if (!io.WantCaptureMouse) - { - const float mouseWheel = ImGui::GetIO().MouseWheel; - if (mouseWheel > 0.0f) - { - forward += m_MoveSpeed * speedScale * DeltaTime * 3.0f; - } - else if (mouseWheel < 0.0f) - { - forward -= m_MoveSpeed * speedScale * DeltaTime * 3.0f; - } - } - - if (m_Momentum) - { - ApplyMomentum(m_LastYaw, yaw, DeltaTime); - ApplyMomentum(m_LastPitch, pitch, DeltaTime); - ApplyMomentum(m_LastForward, forward, DeltaTime); - ApplyMomentum(m_LastStrafe, strafe, DeltaTime); - ApplyMomentum(m_LastAscent, ascent, DeltaTime); - } - } - - // Update mouse interaction - if (!io.WantCaptureMouse && !XeSSDebug::IsFrameDumpOn()) - { - if (ImGui::IsAnyMouseDown()) - { - ImGui::SetMouseCursor(ImGuiMouseCursor_None); - - ImVec2 mousePos = ImGui::GetMousePos(); - - ImVec4 bounds(2.0f, io.DisplaySize.x - 2.0f, 2.0f, io.DisplaySize.y - 2.0f); - - ImVec2 clampedPos = mousePos; - if (clampedPos.x < bounds.x) - { - clampedPos.x = bounds.y; - } - else if (clampedPos.x > bounds.y) - { - clampedPos.x = bounds.x; - } - - if (clampedPos.y < bounds.z) - { - clampedPos.y = bounds.w; - } - else if (clampedPos.y > bounds.w) - { - clampedPos.y = bounds.z; - } - - if (clampedPos.x != mousePos.x || clampedPos.y != mousePos.y) - { - io.WantSetMousePos = true; - io.MousePos = clampedPos; - } - else - { - io.WantSetMousePos = false; - - ImVec2 mouseDelta = ImVec2(clampedPos.x - m_LastMousePos.x, clampedPos.y - m_LastMousePos.y); - - yaw += mouseDelta.x * m_MouseSensitivityX * timeScale * 0.001f; - pitch += -mouseDelta.y * m_MouseSensitivityY * timeScale * 0.001f; - } - } - } - - // Correct pitch - m_CurrentPitch += pitch; - m_CurrentPitch = XMMin(XM_PIDIV2, m_CurrentPitch); - m_CurrentPitch = XMMax(-XM_PIDIV2, m_CurrentPitch); - - // Add some debug camera move. - if (XeSSDebug::IsFrameDumpOn()) - { - XeSSDebug::UpdateCameraYaw(yaw); - } - - // Correct yaw - m_CurrentHeading -= yaw; - if (m_CurrentHeading > XM_PI) - m_CurrentHeading -= XM_2PI; - else if (m_CurrentHeading <= -XM_PI) - m_CurrentHeading += XM_2PI; - - // Update camera transform - Matrix3 orientation = Matrix3(m_WorldEast, m_WorldUp, -m_WorldNorth) * Matrix3::MakeYRotation(m_CurrentHeading) * Matrix3::MakeXRotation(m_CurrentPitch); - Vector3 position = orientation * Vector3(strafe, ascent, -forward) + m_TargetCamera.GetPosition(); - - m_TargetCamera.SetTransform(AffineTransform(orientation, position)); - m_TargetCamera.Update(); - - m_LastMousePos = ImGui::GetMousePos(); -} - -void DemoCameraController::GetHeadingPitchAndPosition(float& Heading, float& Pitch, Vector3& Position) -{ - Heading = m_CurrentHeading; - Pitch = m_CurrentPitch; - Position = m_TargetCamera.GetPosition(); -} - -void DemoCameraController::SetHeadingAndPitch(float Heading, float Pitch) -{ - m_CurrentHeading = Heading; - m_CurrentPitch = Pitch; - - m_CurrentPitch = XMMin(XM_PIDIV2, m_CurrentPitch); - m_CurrentPitch = XMMax(-XM_PIDIV2, m_CurrentPitch); - if (m_CurrentHeading > XM_PI) - m_CurrentHeading -= XM_2PI; - else if (m_CurrentHeading <= -XM_PI) - m_CurrentHeading += XM_2PI; - - Quaternion rotation(Pitch, Heading, 0.0f); - m_TargetCamera.SetRotation(rotation); - - m_TargetCamera.Update(); -} - -void DemoCameraController::SetPosition(const Vector3& Position) -{ - m_TargetCamera.SetPosition(Position); - m_TargetCamera.Update(); -} diff --git a/xess/samples/xess_demo/Source/DemoCameraController.h b/xess/samples/xess_demo/Source/DemoCameraController.h deleted file mode 100644 index cd2a1b9..0000000 --- a/xess/samples/xess_demo/Source/DemoCameraController.h +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright 2021 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files(the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions : - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ - -#include "GameCore.h" -#include "CameraController.h" -#include "imgui.h" - -/// Camera controller for the demo, handles user interactions. -class DemoCameraController : public FlyingFPSCamera -{ -public: - /// Constructor. - DemoCameraController(Camera& Camera_, Vector3 WorldUp_); - /// Update interface. - void Update(float DeltaTime) override; - - /// Get heading, pitch and position values. - void GetHeadingPitchAndPosition(float& Heading, float& Pitch, Vector3& Position); - /// Set heading and pitch for the camera. - void SetHeadingAndPitch(float Heading, float Pitch); - /// Set camera position. - void SetPosition(const Vector3& Position); - -private: - ImVec2 m_LastMousePos; -}; diff --git a/xess/samples/xess_demo/Source/DemoExtraBuffers.cpp b/xess/samples/xess_demo/Source/DemoExtraBuffers.cpp deleted file mode 100644 index 0536e59..0000000 --- a/xess/samples/xess_demo/Source/DemoExtraBuffers.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright 2021 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files(the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions : - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ - -#include "pch.h" -#include "DemoExtraBuffers.h" -#include "ColorBuffer.h" -#include "XeSS/XeSSProcess.h" -#include "XeSS/XeSSDebug.h" - -namespace Graphics -{ - extern DXGI_FORMAT DefaultHdrColorFormat; -} - -DXGI_FORMAT VelocityBufferFormat = DXGI_FORMAT_R16G16_FLOAT; - -void DemoExtraBuffersHandler::InitializeBuffers(uint32_t NativeWidth, uint32_t NativeHeight, uint32_t UpscaledWidth, uint32_t UpscaledHeight) -{ - (UpscaledWidth); - (UpscaledHeight); - XeSS::g_ConvertedVelocityBuffer.Create(L"Motion Vectors - Converted", NativeWidth, NativeHeight, 1, VelocityBufferFormat); - XeSS::g_SharpenColorBuffer.Create(L"Sharpening Buffer", UpscaledWidth, UpscaledHeight, 1, DXGI_FORMAT_R16G16B16A16_FLOAT); - - if (XeSSDebug::IsBufferDebugEnabled()) - { - XeSSDebug::RecreateDebugBuffers(); - } -} - -void DemoExtraBuffersHandler::DestroyRenderingBuffers() -{ - if (XeSSDebug::IsBufferDebugEnabled()) - { - XeSSDebug::DestroyDebugBuffers(); - } - - XeSS::g_SharpenColorBuffer.Destroy(); - XeSS::g_ConvertedVelocityBuffer.Destroy(); -} diff --git a/xess/samples/xess_demo/Source/DemoExtraBuffers.h b/xess/samples/xess_demo/Source/DemoExtraBuffers.h deleted file mode 100644 index 2c6bb86..0000000 --- a/xess/samples/xess_demo/Source/DemoExtraBuffers.h +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright 2021 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files(the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions : - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ - -#pragma once - -#include "IExtraRenderingBuffers.h" - -/// Extra buffers handler creates and destroys extra buffers when engine handles its default buffers. -class DemoExtraBuffersHandler : public Graphics::IExtraRenderingBuffersHandler -{ -public: - /// Called when engine creates the default buffers. - void InitializeBuffers(uint32_t NativeWidth, uint32_t NativeHeight, uint32_t UpscaledWidth, uint32_t UpscaledHeight) override; - /// Called when engine destroys the default buffers. - void DestroyRenderingBuffers() override; -}; diff --git a/xess/samples/xess_demo/Source/DemoGui.cpp b/xess/samples/xess_demo/Source/DemoGui.cpp deleted file mode 100644 index 2bb0519..0000000 --- a/xess/samples/xess_demo/Source/DemoGui.cpp +++ /dev/null @@ -1,714 +0,0 @@ -/******************************************************************************* - * Copyright 2021 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files(the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions : - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ - -#include "pch.h" -#include "DemoGui.h" -#include "DemoApp.h" -#include "ImGuiModule.h" -#include "GraphicsCore.h" -#include "Display.h" -#include "TemporalEffects.h" -#include "ParticleEffectManager.h" -#include "PostEffects.h" -#include "SSAO.h" -#include "MotionBlur.h" -#include "BufferManager.h" -#include "XeSS/XeSSProcess.h" -#include "XeSS/XeSSDebug.h" -#include "imgui.h" -#include "DemoCameraController.h" -#include "Renderer.h" - -using namespace Graphics; -using namespace XeSS; - -namespace DemoGui -{ - static const ImVec4 DEF_TEXT_COLOR(0.94f, 0.94f, 0.94f, 1.00f); - - bool m_ShowUI = true; - bool m_ShowLog = false; - bool m_ShowInspectInput = false; - bool m_ShowInspectOutput = false; - bool m_ShowInspectMotionVectors = false; - bool m_ShowInspectDepth = false; - bool m_ShowInspectResponsiveMask = false; - - float m_DPIScale = 1.0f; - - inline float DESIGN_SIZE(float size); - inline ImVec2 DESIGN_SIZE(const ImVec2& size); - void DPISetNextWindowRect(bool& adjust, const ImVec4& winRect); - void DPIGetWindowRect(bool& resize, ImVec4& winRect); - - void OnGUI_XeSS(); - void OnGUI_Debug(); - void OnGUI_Rendering(); - void OnGUI_Camera(DemoApp& App); - void OnGUI_DebugBufferWindows(); - void OnGUI_LogWindow(DemoApp& Log); - - class BufferViewer - { - public: - BufferViewer(const std::string& title) - : m_Title(title) { } - void OnGUI(bool& Show, ColorBuffer& Buffer); - - private: - std::string m_Title; - int m_ZoomIndex = 0; - ImVec2 m_ImagePos; - ImVec2 m_LastMousePos; - bool m_ScrollDirty = false; - bool m_DPIAdjust = false; - ImVec4 m_DPIWinRect; - }; -} // namespace DemoGui - -float DemoGui::DESIGN_SIZE(float size) -{ - // We use DPI scale of 1.5 for the design. - float scale = Display::GetDPIScale() / 1.5f; - return size * scale; -} - -ImVec2 DemoGui::DESIGN_SIZE(const ImVec2& size) -{ - // We use DPI scale of 1.5 for the design. - float scale = Display::GetDPIScale() / 1.5f; - return ImVec2(size.x * scale, size.y * scale); -} - -void DemoGui::DPISetNextWindowRect(bool& adjust, const ImVec4& winRect) -{ - if (!adjust) - return; - - ImGui::SetNextWindowPos(ImVec2(winRect.x, winRect.y)); - ImGui::SetNextWindowSize(ImVec2(winRect.z, winRect.w)); - - adjust = false; - - LOG_DEBUG("DPI Set next GUI window rect for DPI change."); -} - -void DemoGui::DPIGetWindowRect(bool& adjust, ImVec4& winRect) -{ - float newDPIScale = Display::GetDPIScale(); - adjust = newDPIScale != m_DPIScale; - if (!adjust) - return; - - float scale = newDPIScale / m_DPIScale; - ImVec2 pos = ImGui::GetWindowPos(); - ImVec2 size = ImGui::GetWindowSize(); - - winRect = ImVec4(pos.x * scale, pos.y * scale, size.x * scale, size.y * scale); - - LOG_DEBUG("Get next GUI window rect for DPI change."); -} - -bool DemoGui::Initialize() -{ - ImGui::GetIO().IniFilename = nullptr; - - std::wstring programDir = Utility::GetProgramDirectory(); - std::wstring fontPath = programDir + L"DroidSans.ttf"; - ImGuiModule::AddFont(fontPath, 15.0f, false); - - ImVec4* colors = ImGui::GetStyle().Colors; - colors[ImGuiCol_WindowBg] = ImVec4(0.04f, 0.06f, 0.08f, 0.77f); - colors[ImGuiCol_Header] = ImVec4(0.13f, 0.35f, 0.55f, 0.87f); - colors[ImGuiCol_TitleBg] = ImVec4(0.12f, 0.20f, 0.29f, 1.00f); - colors[ImGuiCol_ButtonActive] = ImVec4(0.00f, 0.46f, 0.80f, 1.00f); - colors[ImGuiCol_PopupBg] = ImVec4(0.09f, 0.12f, 0.14f, 0.94f); - colors[ImGuiCol_Text] = DEF_TEXT_COLOR; - - m_DPIScale = Display::GetDPIScale(); - - return true; -} - -void DemoGui::Shutdown() -{ -} - -void DemoGui::OnGUI(DemoApp& App) -{ - // F1 key to toggle GUI. - if (ImGui::IsKeyPressed(VK_F1)) - { - m_ShowUI = !m_ShowUI; - } - - if (!m_ShowUI) - return; - - ImGui::SetNextWindowPos(DESIGN_SIZE(ImVec2(10, 10)), ImGuiCond_Once); - ImGui::SetNextWindowSize(DESIGN_SIZE(ImVec2(550, 1100)), ImGuiCond_Once); - - static bool adjust = false; - static ImVec4 winRect; - DPISetNextWindowRect(adjust, winRect); - - if (ImGui::Begin("Options (F1 to toggle)", &m_ShowUI)) - { - DPIGetWindowRect(adjust, winRect); - - ImGui::Text("Adapter: %s", g_AdapterName.c_str()); - - ImGui::Text("CPU %7.3f ms, GPU %7.3f ms, %3u Hz", - EngineProfiling::GetTotalCpuTime(), EngineProfiling::GetTotalGpuTime(), (uint32_t)(EngineProfiling::GetFrameRate() + 0.5f)); - - ImGui::Separator(); - - ImGui::Text("Output: %ux%u", g_DisplayWidth, g_DisplayHeight); - ImGui::Text("Input: %ux%u", g_NativeWidth, g_NativeHeight); - - ImGui::Separator(); - - bool fullscreen = Display::IsFullscreen(); - if (ImGui::Checkbox(Display::g_SupportTearing ? "Fullscreen" : "Borderless", &fullscreen)) - { - Display::SetFullscreen(fullscreen); - } - - ImGui::SameLine(); - - bool vsync = Display::s_EnableVSync; - if (ImGui::Checkbox("VSync", &vsync)) - { - Display::s_EnableVSync = vsync; - } - - ImGui::Separator(); - - if (ImGui::CollapsingHeader("Technique##Header", ImGuiTreeNodeFlags_DefaultOpen)) - { - static const char* TECHNIQUE_NAMES[] = { "XeSS", "TAA Without Upscaling", "TAA With Simple Upscaling" }; - - int upscalingIndex = App.GetTechnique(); - if (ImGui::Combo("Technique", &upscalingIndex, TECHNIQUE_NAMES, IM_ARRAYSIZE(TECHNIQUE_NAMES))) - { - App.SetTechnique(static_cast(upscalingIndex)); - } - - // XeSS selected - if (upscalingIndex == kDemoTech_XeSS) - { - OnGUI_XeSS(); - } - else - { - float sharpness = TemporalEffects::Sharpness; - if (ImGui::DragFloat("Sharpness", &sharpness, 0.01f, 0.0f, 1.0f, "%.2f")) - { - TemporalEffects::Sharpness = sharpness; - } - } - } - - if (ImGui::CollapsingHeader("Scene Rendering", ImGuiTreeNodeFlags_DefaultOpen)) - { - // Scene rendering GUI. - OnGUI_Rendering(); - } - - if (ImGui::CollapsingHeader("Camera")) - { - OnGUI_Camera(App); - } - - if (ImGui::CollapsingHeader("Other##Header", ImGuiTreeNodeFlags_DefaultOpen)) - { - ImGui::Checkbox("Show Log", &m_ShowLog); - } - - ImGui::Separator(); - - ImGui::Text("SDK Version: %s", XeSS::g_XeSSRuntime.GetVersionString().c_str()); - } - - ImGui::End(); - - // Show buffer viewers only when XeSS technique is used. - if (App.GetTechnique() == kDemoTech_XeSS) - { - // Buffer viewer windows - OnGUI_DebugBufferWindows(); - } - - // Log window. - OnGUI_LogWindow(App); - - // Update DPI scale for this frame. - m_DPIScale = Display::GetDPIScale(); -} - -void DemoGui::OnGUI_XeSS() -{ - if (!XeSS::IsSupported()) - { - ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1, 0, 0, 1)); - ImGui::Text("XeSS is not supported on this device."); - ImGui::PopStyleColor(); - return; - } - - float sharpness = XeSS::Sharpness; - if (ImGui::DragFloat("Sharpness", &sharpness, 0.01f, 0.0f, 1.0f, "%.2f")) - { - XeSS::Sharpness = sharpness; - } - - static const char* QUALITY_NAMES[] = { "Performance", "Balanced", "Quality", "Ultra Quality" }; - int32_t quality = XeSS::GetQuality(); - if (ImGui::Combo("Quality", &quality, QUALITY_NAMES, IM_ARRAYSIZE(QUALITY_NAMES))) - { - XeSS::SetQuality(static_cast(quality)); - } - - static const char* VELOCITY_MODE_NAMES[] = { "High-Res", "Low-Res" }; - int velocityMode = XeSS::GetMotionVectorsMode(); - if (ImGui::Combo("Motion Vectors", &velocityMode, VELOCITY_MODE_NAMES, IM_ARRAYSIZE(VELOCITY_MODE_NAMES))) - { - XeSS::SetMotionVectorsMode(static_cast(velocityMode)); - } - - int mipBiasMode = XeSS::GetMipBiasMode(); - static const char* MIPBIAS_METHOD_NAMES[] = { "Recommended", "Customized" }; - if (ImGui::Combo("Mip Bias", &mipBiasMode, MIPBIAS_METHOD_NAMES, IM_ARRAYSIZE(MIPBIAS_METHOD_NAMES))) - { - XeSS::SetMipBiasMode(static_cast(mipBiasMode)); - } - - if (mipBiasMode == 0) // Recommended - ImGui::BeginDisabled(true); - - float mipBias = XeSS::GetMipBias(); - if (ImGui::DragFloat("Mip Bias Value", &mipBias, 0.02f, -16.0f, 15.99f, "%.03f")) - { - XeSS::SetMipBias(mipBias); - } - if (mipBiasMode == 0) // Recommended - ImGui::EndDisabled(); - - bool isResponsiveMaskEnabled = XeSS::IsResponsiveMaskEnabled(); - if (ImGui::Checkbox("Responsive Mask", &isResponsiveMaskEnabled)) - { - XeSS::SetResponsiveMaskEnabled(isResponsiveMaskEnabled); - } - - if (ImGui::TreeNodeEx("Debug" /*, ImGuiTreeNodeFlags_DefaultOpen*/)) - { - OnGUI_Debug(); - ImGui::TreePop(); - } -} - -void DemoGui::OnGUI_Debug() -{ - static const char* NETWORK_NAMES[] = { - "KPSS" - }; - - int networkModel = XeSSDebug::GetNetworkModel(); - if (ImGui::Combo("Network Model", &networkModel, NETWORK_NAMES, IM_ARRAYSIZE(NETWORK_NAMES))) - { - XeSSDebug::SelectNetworkModel(networkModel); - } - - ImGui::PushItemWidth(DESIGN_SIZE(150.0f)); - - static float JitterScaleX = 1.0f; - static float JitterScaleY = 1.0f; - - bool jitterScaleDirty = false; - if (ImGui::DragFloat("Jitter Scale X", &JitterScaleX, 0.1f, -16.0f, 16.0f, "%.1f")) - jitterScaleDirty = true; - - //ImGui::SameLine(); - if (ImGui::DragFloat("Jitter Scale Y", &JitterScaleY, 0.1f, -16.0f, 16.0f, "%.1f")) - jitterScaleDirty = true; - - if (jitterScaleDirty) - { - XeSS::g_XeSSRuntime.SetJitterScale(JitterScaleX, JitterScaleY); - } - - static float VelocityScaleX = 1.0f; - static float VelocityScaleY = 1.0f; - - bool velocityScaleDirty = false; - if (ImGui::DragFloat("Velocity Scale X", &VelocityScaleX, 0.1f, -16.0f, 16.0f, "%.1f")) - velocityScaleDirty = true; - - //ImGui::SameLine(); - if (ImGui::DragFloat("Velocity Scale Y", &VelocityScaleY, 0.1f, -16.0f, 16.0f, "%.1f")) - velocityScaleDirty = true; - - if (velocityScaleDirty) - { - XeSS::g_XeSSRuntime.SetVelocityScale(VelocityScaleX, VelocityScaleY); - } - - ImGui::PopItemWidth(); - - // Buffer view options - - ImGui::Checkbox("Inspect Input", &m_ShowInspectInput); - ImGui::Checkbox("Inspect Output", &m_ShowInspectOutput); - ImGui::Checkbox("Inspect Motion Vectors", &m_ShowInspectMotionVectors); - - // Update the XeSS buffer debugging. - if (m_ShowInspectOutput != XeSSDebug::IsBufferDebugEnabled()) - { - XeSSDebug::SetBufferDebugEnabled(m_ShowInspectOutput); - } - - if (XeSS::GetMotionVectorsMode() == XeSS::kMotionVectorsLowRes) - { - ImGui::Checkbox("Inspect Depth", &m_ShowInspectDepth); - } - else - { - m_ShowInspectDepth = false; - } - - if (XeSS::IsResponsiveMaskEnabled()) - { - ImGui::Checkbox("Inspect Responsive Mask", &m_ShowInspectResponsiveMask); - } - else - { - m_ShowInspectResponsiveMask = false; - } - - if (ImGui::TreeNode("Frame Dump")) - { - bool isDumping = XeSSDebug::IsFrameDumpOn(); - - if (isDumping) - ImGui::BeginDisabled(true); - if (ImGui::Button("Dump Static Frames")) - { - XeSSDebug::BeginFrameDump(false); - } - if (isDumping) - ImGui::EndDisabled(); - - if (XeSSDebug::IsFrameDumpOn() && !XeSSDebug::IsDumpDynamic()) - { - ImGui::SameLine(); - ImGui::Text("Dumping Frame: %u/32...", XeSSDebug::GetDumpFrameIndex()); - } - - if (isDumping) - ImGui::BeginDisabled(true); - if (ImGui::Button("Dump Dynamic Frames")) - { - XeSSDebug::BeginFrameDump(true); - } - if (isDumping) - ImGui::EndDisabled(); - - if (XeSSDebug::IsFrameDumpOn() && XeSSDebug::IsDumpDynamic()) - { - ImGui::SameLine(); - ImGui::Text("Dumping Frame: %u/32...", XeSSDebug::GetDumpFrameIndex()); - } - - ImGui::TreePop(); - } -} - -void DemoGui::OnGUI_DebugBufferWindows() -{ - if (m_ShowInspectInput) - { - static BufferViewer viewer("Input Buffer"); - viewer.OnGUI(m_ShowInspectInput, g_SceneColorBuffer); - } - - if (m_ShowInspectOutput) - { - ASSERT(XeSSDebug::IsBufferDebugEnabled()); - static BufferViewer viewer("Output Buffer"); - viewer.OnGUI(m_ShowInspectOutput, XeSSDebug::g_DebugBufferOutput); - } - - if (m_ShowInspectMotionVectors) - { - static BufferViewer viewer("Motion Vectors Buffer"); - if (XeSS::GetMotionVectorsMode() == XeSS::kMotionVectorsHighRes) - viewer.OnGUI(m_ShowInspectMotionVectors, g_UpscaledVelocityBuffer); - else - viewer.OnGUI(m_ShowInspectMotionVectors, g_ConvertedVelocityBuffer); - } - - if (m_ShowInspectDepth) - { - static BufferViewer viewer("Depth Buffer"); - ColorBuffer& depthBuffer = g_LinearDepth[XeSS::GetFrameIndexMod2()]; - viewer.OnGUI(m_ShowInspectDepth, depthBuffer); - } - - if (m_ShowInspectResponsiveMask) - { - static BufferViewer viewer("Responsive Mask Buffer"); - viewer.OnGUI(m_ShowInspectResponsiveMask, g_ResponsiveMaskBuffer); - } -} - -void DemoGui::OnGUI_Rendering() -{ - bool enableParticle = ParticleEffectManager::Enable; - if (ImGui::Checkbox("Particle", &enableParticle)) - { - ParticleEffectManager::Enable = enableParticle; - } - - bool enableBloom = PostEffects::BloomEnable; - if (ImGui::Checkbox("Bloom", &enableBloom)) - { - PostEffects::BloomEnable = enableBloom; - } - - bool enableMotionBlur = MotionBlur::Enable; - if (ImGui::Checkbox("Motion Blur", &enableMotionBlur)) - { - MotionBlur::Enable = enableMotionBlur; - } - - bool enableSSAO = SSAO::Enable; - if (ImGui::Checkbox("SSAO", &enableSSAO)) - { - SSAO::Enable = enableSSAO; - } -} - -void DemoGui::OnGUI_Camera(DemoApp& App) -{ - DemoCameraController* controller = static_cast(App.GetCameraController()); - ASSERT(controller); - if (!controller) - return; - - float yaw, pitch; - Vector3 pos; - controller->GetHeadingPitchAndPosition(yaw, pitch, pos); - - { - ImGui::PushItemWidth(DESIGN_SIZE(150.0f)); - bool dirty = false; - if (ImGui::DragFloat("Yaw", &yaw, 0.01f, -FLT_MAX, FLT_MAX)) - dirty = true; - - ImGui::SameLine(); - if (ImGui::DragFloat("Pitch", &pitch, 0.01f, -FLT_MAX, FLT_MAX)) - dirty = true; - - if (dirty) - { - controller->SetHeadingAndPitch(yaw, pitch); - } - } - - { - bool dirty = false; - float x = pos.GetX(); - if (ImGui::DragFloat("X", &x, 0.1f, -FLT_MAX, FLT_MAX)) - dirty = true; - - ImGui::SameLine(); - - float y = pos.GetY(); - if (ImGui::DragFloat("Y", &y, 0.1f, -FLT_MAX, FLT_MAX)) - dirty = true; - - ImGui::SameLine(); - float z = pos.GetZ(); - if (ImGui::DragFloat("Z", &z, 0.1f, -FLT_MAX, FLT_MAX)) - dirty = true; - - if (dirty) - { - controller->SetPosition(Vector3(x, y, z)); - } - - ImGui::PopItemWidth(); - } -} - -void DemoGui::OnGUI_LogWindow(DemoApp& App) -{ - if (!m_ShowLog) - return; - - static const char* LEVEL_NAMES[] = { "[DEBUG]", "[INFO]", "[WARN]", "[ERROR]" }; - static const ImVec4 LEVEL_COLORS[] = { ImVec4(0, 1, 0, 1), DEF_TEXT_COLOR, ImVec4(1, 1, 0, 1), ImVec4(1, 0, 0, 1) }; - - ImGui::SetNextWindowPos(DESIGN_SIZE(ImVec2(ImGui::GetIO().DisplaySize.x * 0.5f, ImGui::GetIO().DisplaySize.y - 300.0f)), ImGuiCond_Once, ImVec2(0.5f, 0.5f)); - ImGui::SetNextWindowSize(DESIGN_SIZE(ImVec2(1000, 300)), ImGuiCond_Once); - - static bool adjust = false; - static ImVec4 winRect; - DPISetNextWindowRect(adjust, winRect); - - if (ImGui::Begin("Log", &m_ShowLog)) - { - DPIGetWindowRect(adjust, winRect); - - auto& messages = App.GetLog().GetMessages(); - - ImGui::BeginChild("Log scroll", ImVec2(0, 0), false, ImGuiWindowFlags_HorizontalScrollbar); - - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); - - ImGuiListClipper clipper; - clipper.Begin(static_cast(messages.size())); - - while (clipper.Step()) - { - for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; ++i) - { - const Log::LogMessage& message = messages[i]; - ImGui::TextColored(LEVEL_COLORS[message.m_Level], "%s %s", LEVEL_NAMES[message.m_Level], message.m_Message.c_str()); - } - } - ImGui::PopStyleVar(); - - ImGui::EndChild(); - } - - ImGui::End(); -} - -void DemoGui::BufferViewer::OnGUI(bool& Show, ColorBuffer& Buffer) -{ - DPISetNextWindowRect(m_DPIAdjust, m_DPIWinRect); - ImGui::SetNextWindowSize(DESIGN_SIZE(ImVec2(Buffer.GetWidth() * 0.25f + 100.0f, - Buffer.GetHeight() * 0.25f + 100.0f)), - ImGuiCond_Once); - - if (ImGui::Begin(m_Title.c_str(), &Show)) - { - DPIGetWindowRect(m_DPIAdjust, m_DPIWinRect); - - ImGui::Text("Resolution: %ux%u", Buffer.GetWidth(), Buffer.GetHeight()); - - ImGui::SameLine(); - float left = ImGui::GetContentRegionMax().x - DESIGN_SIZE(300); - ImGui::SetCursorPosX(left); - ImGui::PushItemWidth(DESIGN_SIZE(200)); - - static const char* ZOOM_NAMES[] = { "1/4", "1/2", "1", "2", "4", "8", "16" }; - static const int MAX_ZOOM_INDEX = IM_ARRAYSIZE(ZOOM_NAMES) - 1; - ImGui::Combo("Zoom", &m_ZoomIndex, ZOOM_NAMES, IM_ARRAYSIZE(ZOOM_NAMES)); - ImGui::PopItemWidth(); - - float scale = Math::Pow(2.0f, (float)m_ZoomIndex - 2.0f); - const ImVec2 imageSize = ImVec2(static_cast(Buffer.GetWidth()) * scale, static_cast(Buffer.GetHeight()) * scale); - - ImGui::BeginChild("Image Viewport", ImVec2(0, 0), false, ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_NoScrollWithMouse); - { - ImGuiModule::RegisterImage(Buffer); - - // Image button shows our buffer. - ImGui::ImageButton(&Buffer, imageSize, ImVec2(0, 0), ImVec2(1, 1), 0); - - if (!m_ScrollDirty) - { - m_ImagePos = ImVec2(ImGui::GetScrollX(), ImGui::GetScrollY()); - } - else - { - // We scroll the image to its place here. - ImGui::SetScrollX(m_ImagePos.x); - ImGui::SetScrollY(m_ImagePos.y); - - m_ScrollDirty = false; - } - - if (ImGui::IsItemHovered()) - { - const ImVec2 cursorPosInImage = ImVec2(ImGui::GetMousePos().x - ImGui::GetCursorScreenPos().x, - ImGui::GetMousePos().y - ImGui::GetCursorScreenPos().y + imageSize.y); - - ImGui::SetMouseCursor(ImGuiMouseCursor_Hand); - - ImVec2 mousePos = ImGui::GetMousePos(); - - // Handle mouse drag. - if (ImGui::IsAnyMouseDown()) - { - ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeAll); - ImVec2 mouseOffset(mousePos.x - m_LastMousePos.x, mousePos.y - m_LastMousePos.y); - - m_ImagePos.x -= mouseOffset.x; - m_ImagePos.y -= mouseOffset.y; - - m_ScrollDirty = true; - } - - // Handle mouse wheel. - float wheel = ImGui::GetIO().MouseWheel; - int zoom = m_ZoomIndex; - if (wheel > 0.0f) - { - zoom++; - zoom = (zoom > MAX_ZOOM_INDEX) ? MAX_ZOOM_INDEX : zoom; - } - else if (wheel < 0.0f) - { - zoom--; - zoom = (zoom < 0) ? 0 : zoom; - } - - if (zoom != m_ZoomIndex) - { - // Here we want to translate the image so the cursor still points to the same place. - float ratio = Math::Pow(2.0f, (float)(zoom - m_ZoomIndex)); - - float cursorPosInViewportX = cursorPosInImage.x - m_ImagePos.x; - float cursorPosInViewportY = cursorPosInImage.y - m_ImagePos.y; - - m_ImagePos.x = cursorPosInImage.x * ratio - cursorPosInViewportX; - m_ImagePos.y = cursorPosInImage.y * ratio - cursorPosInViewportY; - - m_ScrollDirty = true; - - m_ZoomIndex = zoom; - } - - m_LastMousePos = ImGui::GetMousePos(); - } - } - - ImGui::EndChild(); - ImGui::End(); - return; - } - - ImGui::End(); -} diff --git a/xess/samples/xess_demo/Source/DemoGui.h b/xess/samples/xess_demo/Source/DemoGui.h deleted file mode 100644 index dade305..0000000 --- a/xess/samples/xess_demo/Source/DemoGui.h +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright 2021 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files(the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions : - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ - -class DemoApp; - -/// Gui of the Demo -namespace DemoGui -{ - /// Initialization interface. - bool Initialize(); - /// Destruction interface. - void Shutdown(); - /// Called when GUI to be assembles. - void OnGUI(DemoApp& App); -} // namespace DemoGui diff --git a/xess/samples/xess_demo/Source/DemoLog.h b/xess/samples/xess_demo/Source/DemoLog.h deleted file mode 100644 index 1e69bda..0000000 --- a/xess/samples/xess_demo/Source/DemoLog.h +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright 2021 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files(the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions : - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ -#include "Log.h" - -/// Log class for the Demo. -class DemoLog : public Log -{ -public: - DemoLog() - : Log() - { -#ifdef _DEBUG - m_Level = LevelDebug; -#else - m_Level = LevelInfo; -#endif - } - /// We override the message output handling. - void HandleOutput(LogLevel Level, const std::string& Message) override - { - Log::HandleOutput(Level, Message); - - // save the message. - m_Messages.push_back(LogMessage(Level, Message)); - } - - const std::vector& GetMessages() const { return m_Messages; } - -private: - /// Log messages. - std::vector m_Messages; -}; diff --git a/xess/samples/xess_demo/Source/XeSS/Shaders/Debug/XeSSDebugSimpleUpsamplePS.hlsl b/xess/samples/xess_demo/Source/XeSS/Shaders/Debug/XeSSDebugSimpleUpsamplePS.hlsl deleted file mode 100644 index 7a1bc8c..0000000 --- a/xess/samples/xess_demo/Source/XeSS/Shaders/Debug/XeSSDebugSimpleUpsamplePS.hlsl +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright 2021 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files(the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions : - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ - -#include "../../../../MiniEngine/Core/Shaders/ShaderUtility.hlsli" -#include "../../../../MiniEngine/Core/Shaders/PresentRS.hlsli" - -Texture2D InTexture : register(t0); -SamplerState BilinearSampler : register(s0); - -[RootSignature(Present_RootSig)] -float3 main(float4 pos : SV_Position, float2 uv : TexCoord0) : SV_Target0 -{ - return InTexture.SampleLevel(BilinearSampler, uv, 0); -} diff --git a/xess/samples/xess_demo/Source/XeSS/Shaders/Debug/XeSSDebugSimpleUpsampleRGBAPS.hlsl b/xess/samples/xess_demo/Source/XeSS/Shaders/Debug/XeSSDebugSimpleUpsampleRGBAPS.hlsl deleted file mode 100644 index 14033ab..0000000 --- a/xess/samples/xess_demo/Source/XeSS/Shaders/Debug/XeSSDebugSimpleUpsampleRGBAPS.hlsl +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright 2021 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files(the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions : - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ - -#include "../../../../MiniEngine/Core/Shaders/ShaderUtility.hlsli" -#include "../../../../MiniEngine/Core/Shaders/PresentRS.hlsli" - -Texture2D InTexture : register(t0); -SamplerState BilinearSampler : register(s0); - -[RootSignature(Present_RootSig)] -float4 main(float4 pos : SV_Position, float2 uv : TexCoord0) : SV_Target0 -{ - return float4(InTexture.SampleLevel(BilinearSampler, uv, 0).rgb, 1.0f); -} diff --git a/xess/samples/xess_demo/Source/XeSS/Shaders/XeSSConvertLowResVelocityCS.hlsl b/xess/samples/xess_demo/Source/XeSS/Shaders/XeSSConvertLowResVelocityCS.hlsl deleted file mode 100644 index 4548d7d..0000000 --- a/xess/samples/xess_demo/Source/XeSS/Shaders/XeSSConvertLowResVelocityCS.hlsl +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright 2021 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files(the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions : - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ - -#include "../../../MiniEngine/Core/Shaders/CommonRS.hlsli" -#include "../../../MiniEngine/Core/Shaders/PixelPacking_Velocity.hlsli" - -Texture2D InVelocityBuffer : register(t0); -RWTexture2D OutVelocityBuffer : register(u0); - -[RootSignature(Common_RootSig)] -[numthreads(8, 8, 1)] -void main(uint3 DTid : SV_DispatchThreadID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 Gid : SV_GroupID) -{ - uint2 st = DTid.xy; - - packed_velocity_t velocityPacked = InVelocityBuffer[st]; - float2 velocity = UnpackVelocity(velocityPacked).xy; - - OutVelocityBuffer[st] = velocity; -} diff --git a/xess/samples/xess_demo/Source/XeSS/Shaders/XeSSGenerateHiResVelocityCS.hlsl b/xess/samples/xess_demo/Source/XeSS/Shaders/XeSSGenerateHiResVelocityCS.hlsl deleted file mode 100644 index b26dab0..0000000 --- a/xess/samples/xess_demo/Source/XeSS/Shaders/XeSSGenerateHiResVelocityCS.hlsl +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright 2021 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files(the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions : - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ - -#include "../../../MiniEngine/Core/Shaders/CommonRS.hlsli" -#include "../../../MiniEngine/Core/Shaders/ShaderUtility.hlsli" - -#define WITH_DILATE - -Texture2D InDepthBuffer : register(t1); - -SamplerState PointSampler : register(s3); - -RWTexture2D OutVelocityBuffer : register(u0); - -cbuffer CB1 : register(b1) -{ - float2 InBufferDim; - float2 OutBufferDim; - float2 RcpInBufferDim; - float2 RcpOutBufferDim; - float2 ViewportJitter; - matrix CurToPrevXForm; -} - -int2 GetClosestDepth(float2 uv, out float ClosestDepth) -{ -#ifdef WITH_DILATE - float DepthO = InDepthBuffer.SampleLevel(PointSampler, uv, 0).x; - float DepthA = InDepthBuffer.SampleLevel(PointSampler, uv, 0, int2(-1, -1)).x; - float DepthB = InDepthBuffer.SampleLevel(PointSampler, uv, 0, int2(1, -1)).x; - float DepthC = InDepthBuffer.SampleLevel(PointSampler, uv, 0, int2(-1, 1)).x; - float DepthD = InDepthBuffer.SampleLevel(PointSampler, uv, 0, int2(1, 1)).x; - - ClosestDepth = min(DepthO, min(min(DepthA, DepthB), min(DepthC, DepthD))); - - if (DepthA == ClosestDepth) - return int2(-1, -1); - else if (DepthB == ClosestDepth) - return int2(1, -1); - else if (DepthC == ClosestDepth) - return int2(-1, 1); - else if (DepthD == ClosestDepth) - return int2(1, 1); - - return int2(0, 0); -#else - ClosestDepth = InDepthBuffer.SampleLevel(PointSampler, uv, 0).x; - return int2(0, 0); -#endif -} - - -[RootSignature(Common_RootSig)] -[numthreads(8, 8, 1)] -void main(uint3 DTid : SV_DispatchThreadID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 Gid : SV_GroupID) -{ - uint2 st = DTid.xy; - - float2 uvOut = (float2(st) + 0.5) * RcpOutBufferDim; - float2 posIn = uvOut * InBufferDim + ViewportJitter; - - float2 pixelPosIn = floor(posIn) + 0.5; - float2 nearestUVIn = pixelPosIn * RcpInBufferDim; - - float closestDepth = 0.0; - int2 depthOffset = GetClosestDepth(nearestUVIn, closestDepth); - - float2 curPixel = st + 0.5; - float4 hPos = float4(curPixel * closestDepth, 1.0, closestDepth); - float4 prevHPos = mul(CurToPrevXForm, hPos); - prevHPos.xy /= prevHPos.w; - - float2 velocity = prevHPos.xy - curPixel; - - OutVelocityBuffer[st] = velocity; -} diff --git a/xess/samples/xess_demo/Source/XeSS/XeSSDebug.cpp b/xess/samples/xess_demo/Source/XeSS/XeSSDebug.cpp deleted file mode 100644 index 4054dba..0000000 --- a/xess/samples/xess_demo/Source/XeSS/XeSSDebug.cpp +++ /dev/null @@ -1,404 +0,0 @@ -/******************************************************************************* - * Copyright 2021 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files(the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions : - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ - -#include "pch.h" -#include "XeSSDebug.h" -#include "XeSSProcess.h" -#include "XeSSRuntime.h" -#include "DemoExtraBuffers.h" -#include "XeSSJitter.h" -#include "GraphicsCommon.h" -#include "RootSignature.h" -#include "PipelineState.h" -#include "CompiledShaders/ScreenQuadPresentVS.h" -#include "CompiledShaders/XeSSDebugSimpleUpsamplePS.h" -#include "CompiledShaders/XeSSDebugSimpleUpsampleRGBAPS.h" -#include "ColorBuffer.h" -#include "Display.h" -#include "CommandContext.h" -#include "Utility.h" -#include "GameInput.h" -#include "BufferManager.h" -#include "Camera.h" -#include "Math/Random.h" - -#include "xess/xess_d3d12_debug.h" -#include "xess/xess_debug.h" - -#include -#include -#include "Log.h" - -using namespace Graphics; -using namespace Math; -using namespace XeSS; -using namespace DirectX; - -namespace GameCore -{ - extern HWND g_hWnd; -} - -namespace Graphics -{ - extern RootSignature s_PresentRS; - extern DXGI_FORMAT DefaultHdrColorFormat; -} // namespace Graphics - -namespace XeSSDebug -{ - static const uint32_t TOTAL_DUMP_COUNT = 32; - - bool BypassXeSS = false; - - bool s_IsBufferDebugEnabled = false; - - ColorBuffer g_DebugBufferOutput; - - int32_t s_NetworkModel = XESS_NETWORK_MODEL_KPSS; - - int32_t g_JitterScaleConfig = 0; - int32_t g_VelocityScaleConfig = 0; - - bool s_DumpEnabled = false; - bool s_DumpDynamic = false; - uint32_t s_DumpFrameIndex = 0; - - std::wstring s_DumpRootFolder; - std::string s_DumpRootFolderAnsi; - - RandomNumberGenerator s_RNG; - - bool s_OldDrawFrameRate = false; - bool s_OldTuningIsVisible = false; - - GraphicsPSO s_SimpleUpsamplePS(L"Simple Upsample PSO for XeSS Debugging"); - GraphicsPSO s_SimpleUpsamplePS_RGBA(L"Simple Upsample PSO for XeSS Debugging - RGBA"); - - bool CreateFolderIfNotExist(const std::wstring& folder); - std::string GetTimeStampString(); - bool PrepareDumpFolder(); - - bool StartCurrentDump(); - void EndCurrentDump(); -} // namespace XeSSDebug - -void XeSSDebug::Initialize() -{ - uint32_t bypassXeSS = false; - if (CommandLineArgs::GetInteger(L"bypassxess", bypassXeSS) && bypassXeSS) - { - BypassXeSS = true; - } - - s_SimpleUpsamplePS.SetRootSignature(s_PresentRS); - s_SimpleUpsamplePS.SetRasterizerState(RasterizerTwoSided); - s_SimpleUpsamplePS.SetBlendState(BlendDisable); - s_SimpleUpsamplePS.SetDepthStencilState(DepthStateDisabled); - s_SimpleUpsamplePS.SetSampleMask(0xFFFFFFFF); - s_SimpleUpsamplePS.SetInputLayout(0, nullptr); - s_SimpleUpsamplePS.SetPrimitiveTopologyType(D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE); - s_SimpleUpsamplePS.SetVertexShader(g_pScreenQuadPresentVS, sizeof(g_pScreenQuadPresentVS)); - s_SimpleUpsamplePS.SetPixelShader(g_pXeSSDebugSimpleUpsamplePS, sizeof(g_pXeSSDebugSimpleUpsamplePS)); - s_SimpleUpsamplePS.SetRenderTargetFormat(DefaultHdrColorFormat, DXGI_FORMAT_UNKNOWN); - s_SimpleUpsamplePS.Finalize(); - - s_SimpleUpsamplePS_RGBA.SetRootSignature(s_PresentRS); - s_SimpleUpsamplePS_RGBA.SetRasterizerState(RasterizerTwoSided); - s_SimpleUpsamplePS_RGBA.SetBlendState(BlendDisable); - s_SimpleUpsamplePS_RGBA.SetDepthStencilState(DepthStateDisabled); - s_SimpleUpsamplePS_RGBA.SetSampleMask(0xFFFFFFFF); - s_SimpleUpsamplePS_RGBA.SetInputLayout(0, nullptr); - s_SimpleUpsamplePS_RGBA.SetPrimitiveTopologyType(D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE); - s_SimpleUpsamplePS_RGBA.SetVertexShader(g_pScreenQuadPresentVS, sizeof(g_pScreenQuadPresentVS)); - s_SimpleUpsamplePS_RGBA.SetPixelShader(g_pXeSSDebugSimpleUpsampleRGBAPS, sizeof(g_pXeSSDebugSimpleUpsampleRGBAPS)); - s_SimpleUpsamplePS_RGBA.SetRenderTargetFormat(DXGI_FORMAT_R16G16B16A16_FLOAT, DXGI_FORMAT_UNKNOWN); - s_SimpleUpsamplePS_RGBA.Finalize(); -} - -void XeSSDebug::Shutdown() -{ - // Nothing to do. -} - -bool XeSSDebug::IsBufferDebugEnabled() -{ - return s_IsBufferDebugEnabled; -} - -void XeSSDebug::SetBufferDebugEnabled(bool Enabled) -{ - if (s_IsBufferDebugEnabled == Enabled) - return; - - if (Enabled) - { - RecreateDebugBuffers(); - } - else - { - DestroyDebugBuffers(); - } - - s_IsBufferDebugEnabled = Enabled; -} - -void XeSSDebug::RecreateDebugBuffers() -{ - g_CommandManager.IdleGPU(); - g_DebugBufferOutput.Create(L"XeSS Output for Debugging", Graphics::g_DisplayWidth, Graphics::g_DisplayHeight, 1, Graphics::DefaultHdrColorFormat); - - LOG_DEBUG("XeSS: Debug buffers recreated."); -} - -void XeSSDebug::DestroyDebugBuffers() -{ - g_CommandManager.IdleGPU(); - g_DebugBufferOutput.Destroy(); - - LOG_DEBUG("XeSS: Debug buffers destroyed."); -} - -void XeSSDebug::UpscaleRGB(GraphicsContext& Context, ColorBuffer& source, ColorBuffer& destination) -{ - ScopedTimer _prof(L"XeSS Debug Upscale", Context); - - Context.SetRootSignature(s_PresentRS); - Context.SetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - Context.SetDynamicDescriptor(0, 0, source.GetSRV()); - Context.SetPipelineState(s_SimpleUpsamplePS); - Context.TransitionResource(source, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(destination, D3D12_RESOURCE_STATE_RENDER_TARGET); - Context.SetRenderTarget(destination.GetRTV()); - Context.SetViewportAndScissor(0, 0, destination.GetWidth(), destination.GetHeight()); - Context.SetDynamicDescriptor(0, 0, source.GetSRV()); - Context.Draw(3); -} - -void XeSSDebug::UpscaleRGBA(GraphicsContext& Context, ColorBuffer& source, ColorBuffer& destination) -{ - ScopedTimer _prof(L"XeSS Debug Upscale", Context); - - Context.SetRootSignature(s_PresentRS); - Context.SetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - Context.SetDynamicDescriptor(0, 0, source.GetSRV()); - Context.SetPipelineState(s_SimpleUpsamplePS_RGBA); - Context.TransitionResource(source, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(destination, D3D12_RESOURCE_STATE_RENDER_TARGET); - Context.SetRenderTarget(destination.GetRTV()); - Context.SetViewportAndScissor(0, 0, destination.GetWidth(), destination.GetHeight()); - Context.SetDynamicDescriptor(0, 0, source.GetSRV()); - Context.Draw(3); -} - -bool XeSSDebug::BeginFrameDump(bool DynamicCamera) -{ - if (!XeSS::IsEnabled() || BypassXeSS) - return false; - - if (s_DumpEnabled) - return true; - - bool ret = PrepareDumpFolder(); - ASSERT(ret); - if (!ret) - { - LOG_ERROR("XeSS Debug: Could not prepare folder for frame dump."); - return false; - } - - s_DumpEnabled = true; - s_DumpFrameIndex = 0; - s_DumpDynamic = DynamicCamera; - - s_RNG.SetSeed(static_cast(time(nullptr))); - - s_DumpRootFolderAnsi = Utility::WideStringToAnsi(s_DumpRootFolder); - - if (!StartCurrentDump()) - { - s_DumpEnabled = false; - return false; - } - - return true; -} - -bool XeSSDebug::IsFrameDumpOn() -{ - return s_DumpEnabled; -} - -uint32_t XeSSDebug::GetDumpFrameIndex() -{ - return s_DumpFrameIndex; -} - -bool XeSSDebug::IsDumpDynamic() -{ - return s_DumpDynamic; -} - -bool XeSSDebug::CreateFolderIfNotExist(const std::wstring& folder) -{ - DWORD attr = GetFileAttributesW(folder.c_str()); - if (attr == INVALID_FILE_ATTRIBUTES) - { - if (!CreateDirectoryW(folder.c_str(), nullptr)) - { - LOG_ERRORF("XeSS Debug: Could not create folder \"%s\"", Utility::WideStringToUTF8(folder).c_str()); - return false; - } - } - - return true; -} - -std::string XeSSDebug::GetTimeStampString() -{ - time_t t; - time(&t); - tm localTime; - errno_t err = localtime_s(&localTime, &t); - if (err) - { - LOG_ERROR("XeSS Debug: Could not get local time."); - return "00"; - } - - char timeBuf[128]; - strftime(timeBuf, sizeof(timeBuf), "%Y-%m-%d_%H_%M_%S", &localTime); - - return timeBuf; -} - -bool XeSSDebug::PrepareDumpFolder() -{ - wchar_t modulePath[MAX_PATH]; - modulePath[0] = 0; - GetModuleFileNameW(nullptr, modulePath, MAX_PATH); - - s_DumpRootFolder = modulePath; - std::wstring::size_type pos = s_DumpRootFolder.find_last_of(L"\\/"); - s_DumpRootFolder = s_DumpRootFolder.substr(0, pos); - s_DumpRootFolder.append(L"\\frame_dump"); - - if (!CreateFolderIfNotExist(s_DumpRootFolder)) - return false; - - std::string timeStamp = GetTimeStampString(); - - s_DumpRootFolder.append(L"\\dump_"); - s_DumpRootFolder.append(Utility::AnsiToWideString(timeStamp)); - - if (!CreateFolderIfNotExist(s_DumpRootFolder)) - return false; - - return true; -} - -bool XeSSDebug::StartCurrentDump() -{ - ASSERT(s_DumpEnabled); - if (!s_DumpEnabled) - return false; - - xess_dump_parameters_t param = { s_DumpRootFolderAnsi.c_str(), s_DumpFrameIndex, TOTAL_DUMP_COUNT, XESS_DUMP_ALL }; - xess_result_t ret = xessStartDump(g_XeSSRuntime.GetContext(), ¶m); - - ASSERT(ret == XESS_RESULT_SUCCESS); - if (ret != XESS_RESULT_SUCCESS) - { - LOG_ERRORF("XeSS: Could not start to dump. Result - %s.", ResultToString(ret)); - return false; - } - - LOG_INFO("XeSS: Frame dump started."); - - return true; -} - -void XeSSDebug::Update() -{ - if (s_DumpEnabled) - { - if (s_DumpFrameIndex >= TOTAL_DUMP_COUNT) - { - EndCurrentDump(); - return; - } - - s_DumpFrameIndex++; - } -} - -int32_t XeSSDebug::GetNetworkModel() -{ - return s_NetworkModel; -} - -bool XeSSDebug::SelectNetworkModel(int32_t model) -{ - if (s_NetworkModel == model) - return true; - - ASSERT(model == XESS_NETWORK_MODEL_KPSS); - - // We make sure the previous work is done. - g_CommandManager.IdleGPU(); - - xess_result_t ret = xessSelectNetworkModel(g_XeSSRuntime.GetContext(), static_cast(XESS_NETWORK_MODEL_KPSS + model)); - ASSERT(ret == XESS_RESULT_SUCCESS); - if (ret != XESS_RESULT_SUCCESS) - { - LOG_ERRORF("XeSS: Could not select network model to %d. Result - %s.", model, ResultToString(ret)); - return false; - } - - s_NetworkModel = model; - - // Update the runtime after new network model set. - XeSS::UpdateRuntime(); - - if (model == XESS_NETWORK_MODEL_KPSS) - { - LOG_INFO("XeSS: Network model set to KPSS."); - } - - return true; -} - -void XeSSDebug::EndCurrentDump() -{ - s_DumpEnabled = false; - s_DumpFrameIndex = 0; - s_DumpDynamic = false; -} - -void XeSSDebug::UpdateCameraYaw(float& yaw) -{ - if (!s_DumpEnabled || !s_DumpDynamic) - return; - - // We add some random camera rotation here. - yaw -= s_RNG.NextFloat(0.02f, 0.1f); -} diff --git a/xess/samples/xess_demo/Source/XeSS/XeSSDebug.h b/xess/samples/xess_demo/Source/XeSS/XeSSDebug.h deleted file mode 100644 index 60b5018..0000000 --- a/xess/samples/xess_demo/Source/XeSS/XeSSDebug.h +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * Copyright 2021 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files(the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions : - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ - -#pragma once - -class ColorBuffer; -class GraphicsContext; -class ComputeContext; - -namespace Math -{ - class Camera; -} - -namespace XeSSDebug -{ - /// If we should bypass XeSS. Used for debugging. - extern bool BypassXeSS; - - /// Intermediate buffer used for XeSS output debug. - extern ColorBuffer g_DebugBufferOutput; - - /// Initialization interface. - void Initialize(); - /// Destruction interface. - void Shutdown(); - /// Update interface, called very frame. - void Update(); - - /// Get if output buffer debugging is enabled. - bool IsBufferDebugEnabled(); - /// Set if output buffer debugging is enabled. - void SetBufferDebugEnabled(bool Enabled); - - /// Recreate buffers for debugging. - void RecreateDebugBuffers(); - /// Destroy buffers for debugging. - void DestroyDebugBuffers(); - - /// Returns network model index. - int32_t GetNetworkModel(); - /// Select network model of XeSS. - bool SelectNetworkModel(int32_t model); - - /// Upscale a RGB color buffer. - void UpscaleRGB(GraphicsContext& Context, ColorBuffer& source, ColorBuffer& destination); - /// Upscale a RGBA color buffer. - void UpscaleRGBA(GraphicsContext& Context, ColorBuffer& source, ColorBuffer& destination); - - /// Begin frame dumping. - bool BeginFrameDump(bool DynamicCamera = true); - /// Is frame dumping is in process. - bool IsFrameDumpOn(); - /// Get index of the frame being dumped. - uint32_t GetDumpFrameIndex(); - /// Return true if camera is moving when dumping, false when static camera is used. - bool IsDumpDynamic(); - - /// Update camera yaw. (Used in dynamic camera mode.) - void UpdateCameraYaw(float& yaw); -} // namespace XeSSDebug diff --git a/xess/samples/xess_demo/Source/XeSS/XeSSJitter.cpp b/xess/samples/xess_demo/Source/XeSS/XeSSJitter.cpp deleted file mode 100644 index 6977c6f..0000000 --- a/xess/samples/xess_demo/Source/XeSS/XeSSJitter.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************* - * Copyright 2021 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files(the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions : - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ - -#include "pch.h" -#include "XeSSJitter.h" -#include "Camera.h" -#include "BufferManager.h" - -using namespace Math; -using namespace Graphics; - -namespace XeSSJitter -{ - std::vector> g_HaltonSamples; - - size_t s_JitterIndex = 0; - - float GetCorput(uint32_t index, uint32_t base) - { - float result = 0; - float bk = 1.f; - - while (index > 0) - { - bk /= (float)base; - result += (float)(index % base) * bk; - index /= base; - } - - return result; - } - - void GenerateHalton(std::vector>& HaltonSamples, - std::uint32_t base1, std::uint32_t base2, - std::uint32_t start_index, std::uint32_t count, float offset1, float offset2) - { - HaltonSamples.reserve(count); - - for (std::uint32_t a = start_index; a < count + start_index; ++a) - { - HaltonSamples.emplace_back(GetCorput(a, base1) + offset1, GetCorput(a, base2) + offset2); - } - } - - void Initialize() - { - s_JitterIndex = 0; - g_HaltonSamples.clear(); - - GenerateHalton(g_HaltonSamples, 2, 3, 1, 32, -0.5f, -0.5f); - } - - void Reset() - { - s_JitterIndex = 0; - -#if _XESS_DEBUG_JITTER_ - LOG_DEBUG("XeSS Jitter: Reset."); -#endif - } - - void FrameMove() - { - s_JitterIndex = (s_JitterIndex + 1) % g_HaltonSamples.size(); - -#if _XESS_DEBUG_JITTER_ - LOG_DEBUG("XeSS Jitter: Frame Move."); -#endif - } - - void GetJitterValues(float& JitterX, float& JitterY) - { - ASSERT(!g_HaltonSamples.empty()); - auto haltonValue = g_HaltonSamples[s_JitterIndex]; - JitterX = haltonValue.first; - JitterY = haltonValue.second; - } - - void ApplyCameraJitter(Camera& Camera_, float JitterX, float JitterY) - { - uint32_t nativeWidth = g_SceneColorBuffer.GetWidth(); - uint32_t nativeHeight = g_SceneColorBuffer.GetHeight(); - if (nativeWidth && nativeHeight) // Make sure g_SceneColorBuffer is ready. - { - // MiniEngine uses right-handed coordinate system. - float projJitterX = -(JitterX * 2.0f) / nativeWidth; - float projJitterY = (JitterY * 2.0f) / nativeHeight; - - Camera_.SetProjectMatrixJitter(projJitterX, projJitterY); - -#if _XESS_DEBUG_JITTER_ - LOG_DEBUGF("XeSS Jitter: Camera Projection Jitter Applied = %f, %f.", JitterX, JitterY); -#endif - } - } - - void ClearCameraJitter(Camera& Camera_) - { - Camera_.SetProjectMatrixJitter(0.0f, 0.0f); - -#if _XESS_DEBUG_JITTER_ - LOG_DEBUG("XeSS Jitter: Camera Projection Jitter Removed."); -#endif - } -} // namespace XeSSJitter diff --git a/xess/samples/xess_demo/Source/XeSS/XeSSJitter.h b/xess/samples/xess_demo/Source/XeSS/XeSSJitter.h deleted file mode 100644 index c57574b..0000000 --- a/xess/samples/xess_demo/Source/XeSS/XeSSJitter.h +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright 2021 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files(the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions : - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ - -#pragma once - -/// Debugging output of jitter when enabled. -#define _XESS_DEBUG_JITTER_ 0 - -namespace Math -{ - class Camera; -} - -namespace XeSSJitter -{ - /// Initialization interface for jitter. - void Initialize(); - /// Reset jitter sequence. - void Reset(); - /// Move index of jitter sequence forward. - void FrameMove(); - /// Get jitter values. Sequence index does not change after this call. - void GetJitterValues(float& JitterX, float& JitterY); - /// Apply current jitter values to the camera. - void ApplyCameraJitter(Math::Camera& Camera_, float JitterX, float JitterY); - /// Clear jitter values from the camera. - void ClearCameraJitter(Math::Camera& Camera_); -} // namespace XeSSJitter diff --git a/xess/samples/xess_demo/Source/XeSS/XeSSProcess.cpp b/xess/samples/xess_demo/Source/XeSS/XeSSProcess.cpp deleted file mode 100644 index 31eb05c..0000000 --- a/xess/samples/xess_demo/Source/XeSS/XeSSProcess.cpp +++ /dev/null @@ -1,524 +0,0 @@ -/******************************************************************************* - * Copyright 2021 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files(the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions : - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ - -#include "pch.h" -#include "XeSSProcess.h" -#include "XeSSRuntime.h" -#include "XeSSJitter.h" -#include "XeSSDebug.h" -#include "BufferManager.h" -#include "Camera.h" -#include "CommandContext.h" -#include "Display.h" -#include "TemporalEffects.h" -#include "ImageScaling.h" -#include "DemoExtraBuffers.h" -#include "VectorMath.h" -#include "Log.h" -#include "CompiledShaders/XeSSConvertLowResVelocityCS.h" -#include "CompiledShaders/XeSSGenerateHiResVelocityCS.h" -#include "CompiledShaders/SharpenCS.h" - -using namespace Graphics; -using namespace Math; - -namespace XeSS -{ - bool s_Enabled = true; - - bool s_IsSupported = true; - - XeSSRuntime g_XeSSRuntime; - - ColorBuffer g_ConvertedVelocityBuffer; - ColorBuffer g_SharpenColorBuffer; - - NumVar Sharpness("XeSS/Sharpness", 0.0f, 0.0f, 1.0f, 0.02f); - - eMotionVectorsMode s_MotionVectorsMode = kMotionVectorsHighRes; - eQualityLevel s_Quality = kQualityQuality; - bool s_ResponsiveMaskEnabled = false; - eMipBiasMode s_MipBiasMode = kMipBiasAutomatic; - float s_CustomizedMipBias = FLT_MAX; - bool s_ResetHistory = false; - - uint32_t s_InputWidth = 0; - uint32_t s_InputHeight = 0; - uint32_t s_OutputWidth = 0; - uint32_t s_OutputHeight = 0; - - bool s_RuntimeDirty = true; - bool s_InputResolutionDirty = true; - - ComputePSO s_XeSSConvertLowResVelocityCS(L"ConvertLowResVelocityCS"); - ComputePSO s_XeSSGenerateHiResVelocityCS(L"GenerateHiResVelocityCS"); - ComputePSO s_SharpenImageCS(L"Sharpen Image CS"); - - void ConvertLowResVelocity(ComputeContext& Context); - void GenerateHighResVelocity(ComputeContext& Context, const Matrix4& CurToPrevXForm); - void ExecuteXeSS(ComputeContext& Context, ColorBuffer& OutputColorBuffer); - void GetRuntimeInputResolution(uint32_t& Width, uint32_t& Height); - - float GetDefaultMipBiasValue(); - - void SharpenImage(ComputeContext& Context, ColorBuffer& SourceColorBuffer, ColorBuffer& DestColorBuffer); -} // namespace XeSS - -bool XeSS::IsEnabled() -{ - return s_Enabled; -} - -void XeSS::SetEnabled(bool Enabled) -{ - if (s_Enabled == Enabled) - return; - - s_Enabled = Enabled; - - if (Enabled) - { - s_ResetHistory = true; - } -} - -void XeSS::Initialize() -{ - XeSSDebug::Initialize(); - - if (!XeSSDebug::BypassXeSS) - { - s_IsSupported = g_XeSSRuntime.CreateContext(); - if (!s_IsSupported) - { - LOG_ERROR("XeSS: Could not create context. XeSS function will not be available."); - } - else - { - LOG_INFO("XeSS: Context created."); - } - } - - XeSSJitter::Initialize(); - -#define CreatePSO(ObjName, ShaderByteCode) \ - ObjName.SetRootSignature(g_CommonRS); \ - ObjName.SetComputeShader(ShaderByteCode, sizeof(ShaderByteCode)); \ - ObjName.Finalize(); - - CreatePSO(s_XeSSConvertLowResVelocityCS, g_pXeSSConvertLowResVelocityCS); - CreatePSO(s_XeSSGenerateHiResVelocityCS, g_pXeSSGenerateHiResVelocityCS); - CreatePSO(s_SharpenImageCS, g_pSharpenCS); -#undef CreatePSO - - SetOutputResolution(g_DisplayWidth, g_DisplayHeight); -} - -void XeSS::Shutdown() -{ - if (g_XeSSRuntime.IsInitialzed()) - { - g_XeSSRuntime.Shutdown(); - - LOG_INFO("XeSS: Finalized."); - } - - XeSSDebug::Shutdown(); -} - -void XeSS::GetInputResolution(uint32_t& Width, uint32_t& Height) -{ - Width = g_NativeWidth; - Height = g_NativeHeight; - - GetRuntimeInputResolution(Width, Height); -} - -void XeSS::SetOutputResolution(uint32_t Width, uint32_t Height) -{ - if (s_OutputWidth == Width && s_OutputHeight == Height) - return; - - s_OutputWidth = Width; - s_OutputHeight = Height; - - s_InputResolutionDirty = true; - s_RuntimeDirty = true; -} - -XeSS::eMotionVectorsMode XeSS::GetMotionVectorsMode() -{ - return s_MotionVectorsMode; -} - -void XeSS::SetMotionVectorsMode(eMotionVectorsMode Mode) -{ - if (s_MotionVectorsMode == Mode) - return; - - s_MotionVectorsMode = Mode; - - s_RuntimeDirty = true; -} - -bool XeSS::IsResponsiveMaskEnabled() -{ - return s_ResponsiveMaskEnabled; -} - -void XeSS::SetResponsiveMaskEnabled(bool Enabled) -{ - if (s_ResponsiveMaskEnabled == Enabled) - return; - - s_ResponsiveMaskEnabled = Enabled; - - s_RuntimeDirty = true; -} - -void XeSS::UpdateInputResolution() -{ - uint32_t width, height; - GetInputResolution(width, height); - - Graphics::SetNativeResolutionAndUpscaling(width, height, true); - - s_InputWidth = width; - s_InputHeight = height; - - s_InputResolutionDirty = false; -} - -XeSS::eQualityLevel XeSS::GetQuality() -{ - return s_Quality; -} - -void XeSS::SetQuality(eQualityLevel Quality) -{ - if (s_Quality == Quality) - return; - - s_Quality = Quality; - - s_InputResolutionDirty = true; - - s_RuntimeDirty = true; -} - -XeSS::eMipBiasMode XeSS::GetMipBiasMode() -{ - return s_MipBiasMode; -} - -void XeSS::SetMipBiasMode(eMipBiasMode Mode) -{ - s_MipBiasMode = Mode; -} - -float XeSS::GetDefaultMipBiasValue() -{ - return log2f(g_NativeWidth / static_cast(g_DisplayWidth)); -} - -float XeSS::GetMipBias() -{ - if (s_MipBiasMode == kMipBiasAutomatic) - return GetDefaultMipBiasValue(); - else - { - if (s_CustomizedMipBias > 15.99f) - { - s_CustomizedMipBias = GetDefaultMipBiasValue(); - } - - return s_CustomizedMipBias; - } -} - -void XeSS::SetMipBias(float value) -{ - s_MipBiasMode = kMipBiasCustomized; - s_CustomizedMipBias = value; -} - -void XeSS::UpdateRuntime() -{ - bool isHiResMode = (s_MotionVectorsMode == kMotionVectorsHighRes); - - InitArguments initArgs = {}; - initArgs.OutputWidth = s_OutputWidth; - initArgs.OutputHeight = s_OutputHeight; - initArgs.Quality = s_Quality; - initArgs.UseHiResMotionVectors = isHiResMode; - initArgs.UseResponsiveMask = s_ResponsiveMaskEnabled; - - g_XeSSRuntime.Initialize(initArgs); - - s_RuntimeDirty = false; - - s_ResetHistory = true; -} - -void XeSS::Update() -{ - if (!s_Enabled) - return; - - if (s_RuntimeDirty) - { - UpdateRuntime(); - } - - if (s_InputResolutionDirty) - { - UpdateInputResolution(); - } - - XeSSDebug::Update(); - - if (s_ResetHistory) - { - XeSSJitter::Reset(); - } - else - { - XeSSJitter::FrameMove(); - } -} - -uint32_t XeSS::GetFrameIndexMod2() -{ - return TemporalEffects::GetFrameIndexMod2(); -} -bool XeSS::IsSupported() -{ - return s_IsSupported; -} - -void XeSS::Process(CommandContext& BaseContext, const Camera& camera) -{ - if (!s_Enabled || !g_XeSSRuntime.IsInitialzed()) - return; - - ScopedTimer _prof(L"XeSS Process", BaseContext); - - ComputeContext& Context = BaseContext.GetComputeContext(); - - uint32_t Width = g_UpscaledSceneColorBuffer.GetWidth(); - uint32_t Height = g_UpscaledSceneColorBuffer.GetHeight(); - - float RcpHalfDimX = 2.0f / Width; - float RcpHalfDimY = 2.0f / Height; - float RcpZMagic = camera.GetNearClip() / (camera.GetFarClip() - camera.GetNearClip()); - - Matrix4 preMult = Matrix4( - Vector4(RcpHalfDimX, 0.0f, 0.0f, 0.0f), - Vector4(0.0f, -RcpHalfDimY, 0.0f, 0.0f), - Vector4(0.0f, 0.0f, RcpZMagic, 0.0f), - Vector4(-1.0f, 1.0f, -RcpZMagic, 1.0f)); - - Matrix4 postMult = Matrix4( - Vector4(1.0f / RcpHalfDimX, 0.0f, 0.0f, 0.0f), - Vector4(0.0f, -1.0f / RcpHalfDimY, 0.0f, 0.0f), - Vector4(0.0f, 0.0f, 1.0f, 0.0f), - Vector4(1.0f / RcpHalfDimX, 1.0f / RcpHalfDimY, 0.0f, 1.0f)); - - Matrix4 CurToPrevXForm = postMult * camera.GetReprojectionMatrix() * preMult; - - if (s_MotionVectorsMode == XeSS::kMotionVectorsHighRes) - { - GenerateHighResVelocity(Context, CurToPrevXForm); - } - else - { - ConvertLowResVelocity(Context); - } - - if (!XeSSDebug::BypassXeSS) - { - bool sharpenEnabled = Sharpness > 0.001f; - - ExecuteXeSS(Context, sharpenEnabled ? g_SharpenColorBuffer : g_UpscaledSceneColorBuffer); - - if (XeSSDebug::IsBufferDebugEnabled()) - { - // If XeSS output debug is enabled, before drawing anything further we store the output to the debug buffer. - XeSSDebug::UpscaleRGB(BaseContext.GetGraphicsContext(), sharpenEnabled ? g_SharpenColorBuffer : g_UpscaledSceneColorBuffer, XeSSDebug::g_DebugBufferOutput); - } - - if (sharpenEnabled) - { - SharpenImage(Context, g_SharpenColorBuffer, g_UpscaledSceneColorBuffer); - } - } - else - { - XeSSDebug::UpscaleRGB(BaseContext.GetGraphicsContext(), g_SceneColorBuffer, g_UpscaledSceneColorBuffer); - } - - s_ResetHistory = false; -} - -void XeSS::GetRuntimeInputResolution(uint32_t& Width, uint32_t& Height) -{ - if (!g_XeSSRuntime.IsInitialzed()) - return; - - if (!g_XeSSRuntime.GetInputResolution(Width, Height)) - { - Width = 512; - Height = 512; - } -} - -void XeSS::ConvertLowResVelocity(ComputeContext& Context) -{ - ASSERT(s_MotionVectorsMode == kMotionVectorsLowRes); - if (s_MotionVectorsMode != kMotionVectorsLowRes) - return; - - ScopedTimer _prof(L"Convert Velocity", Context); - - Context.SetRootSignature(g_CommonRS); - Context.SetPipelineState(s_XeSSConvertLowResVelocityCS); - - Context.TransitionResource(g_VelocityBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_ConvertedVelocityBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - - Context.SetDynamicDescriptor(1, 0, g_VelocityBuffer.GetSRV()); - Context.SetDynamicDescriptor(2, 0, g_ConvertedVelocityBuffer.GetUAV()); - - Context.Dispatch2D(g_ConvertedVelocityBuffer.GetWidth(), g_ConvertedVelocityBuffer.GetHeight()); -} - -void XeSS::GenerateHighResVelocity(ComputeContext& Context, const Matrix4& CurToPrevXForm) -{ - ASSERT(s_MotionVectorsMode == kMotionVectorsHighRes); - if (s_MotionVectorsMode != kMotionVectorsHighRes) - return; - - ScopedTimer _prof(L"Upscale Velocity", Context); - - Context.SetRootSignature(g_CommonRS); - - Context.SetPipelineState(s_XeSSGenerateHiResVelocityCS); - - __declspec(align(16)) struct ConstantBuffer - { - float InBufferDim[2]; - float OutBufferDim[2]; - float RcpInBufferDim[2]; - float RcpOutBufferDim[2]; - float ViewportJitter[2]; - Matrix4 CurToPrevXForm; - }; - - ColorBuffer& LinearDepth = g_LinearDepth[XeSS::GetFrameIndexMod2()]; - - float jitterX, jitterY; - XeSSJitter::GetJitterValues(jitterX, jitterY); - - ConstantBuffer cbv = { - (float)g_VelocityBuffer.GetWidth(), (float)g_VelocityBuffer.GetHeight(), - (float)g_UpscaledVelocityBuffer.GetWidth(), (float)g_UpscaledVelocityBuffer.GetHeight(), - 1.0f / g_VelocityBuffer.GetWidth(), 1.0f / g_VelocityBuffer.GetHeight(), - 1.0f / g_UpscaledVelocityBuffer.GetWidth(), 1.0f / g_UpscaledVelocityBuffer.GetHeight(), - jitterX, jitterY, - CurToPrevXForm - }; - - Context.SetDynamicConstantBufferView(3, sizeof(cbv), &cbv); - - Context.TransitionResource(g_VelocityBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(LinearDepth, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(g_UpscaledVelocityBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - - Context.SetDynamicDescriptor(1, 0, g_VelocityBuffer.GetSRV()); - Context.SetDynamicDescriptor(1, 1, LinearDepth.GetSRV()); - Context.SetDynamicDescriptor(2, 0, g_UpscaledVelocityBuffer.GetUAV()); - - Context.Dispatch2D(g_UpscaledVelocityBuffer.GetWidth(), g_UpscaledVelocityBuffer.GetHeight()); -} - -void XeSS::ExecuteXeSS(ComputeContext& Context, ColorBuffer& OutputColorBuffer) -{ - if (!g_XeSSRuntime.IsInitialzed()) - return; - - ScopedTimer _prof(L"Execute XeSS", Context); - - bool isHiResMode = (s_MotionVectorsMode == kMotionVectorsHighRes); - - ColorBuffer& linearDepth = g_LinearDepth[XeSS::GetFrameIndexMod2()]; - - Context.TransitionResource(g_SceneColorBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(OutputColorBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - - if (isHiResMode) - { - Context.TransitionResource(g_UpscaledVelocityBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - } - else - { - Context.TransitionResource(g_ConvertedVelocityBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(linearDepth, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - } - - if (s_ResponsiveMaskEnabled) - { - Context.TransitionResource(g_ResponsiveMaskBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - } - - Context.FlushResourceBarriers(); - - ExecuteArguments exeArgs = {}; - exeArgs.CommandList = Context.GetComputeContext().GetCommandList(); - exeArgs.InputWidth = g_SceneColorBuffer.GetWidth(); - exeArgs.InputHeight = g_SceneColorBuffer.GetHeight(); - exeArgs.ResetHistory = s_ResetHistory; - - exeArgs.ColorTexture = &g_SceneColorBuffer; - exeArgs.VelocityTexture = isHiResMode ? &g_UpscaledVelocityBuffer : &g_ConvertedVelocityBuffer; - exeArgs.OutputTexture = &OutputColorBuffer; - exeArgs.DepthTexture = isHiResMode ? nullptr : &linearDepth; // Only low-res mode needs depth input. - exeArgs.ResponsiveMask = s_ResponsiveMaskEnabled ? &g_ResponsiveMaskBuffer : nullptr; - - g_XeSSRuntime.Execute(exeArgs); - - Context.GetComputeContext().InvalidateStates(); -} - -void XeSS::SharpenImage(ComputeContext& Context, ColorBuffer& SourceColorBuffer, ColorBuffer& DestColorBuffer) -{ - ScopedTimer _prof(L"Sharpen Image", Context); - - Context.TransitionResource(SourceColorBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); - Context.TransitionResource(DestColorBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - - Context.SetRootSignature(g_CommonRS); - Context.SetPipelineState(s_SharpenImageCS); - Context.SetConstants(0, 1.0f + Sharpness, 0.25f * Sharpness); - Context.SetDynamicDescriptor(1, 0, SourceColorBuffer.GetSRV()); - Context.SetDynamicDescriptor(2, 0, DestColorBuffer.GetUAV()); - Context.Dispatch2D(DestColorBuffer.GetWidth(), DestColorBuffer.GetHeight()); -} \ No newline at end of file diff --git a/xess/samples/xess_demo/Source/XeSS/XeSSProcess.h b/xess/samples/xess_demo/Source/XeSS/XeSSProcess.h deleted file mode 100644 index 0a8fe19..0000000 --- a/xess/samples/xess_demo/Source/XeSS/XeSSProcess.h +++ /dev/null @@ -1,116 +0,0 @@ -/******************************************************************************* - * Copyright 2021 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files(the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions : - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ - -#pragma once - -#include "EngineTuning.h" -#include "XeSSRuntime.h" - -class ColorBuffer; -class CommandContext; - -namespace XeSS -{ - class XeSSRuntime; -} - -namespace Math -{ - class Camera; -} - -namespace XeSS -{ - /// Motion vectors mode - enum eMotionVectorsMode - { - kMotionVectorsHighRes = 0, - kMotionVectorsLowRes, - kMotionVectorsModeNum - }; - - /// Mip-bias mode - enum eMipBiasMode - { - kMipBiasAutomatic = 0, - kMipBiasCustomized, - kMipBiasNum - }; - - extern NumVar Sharpness; - - /// XeSS runtime wrapper object - extern XeSSRuntime g_XeSSRuntime; - - extern ColorBuffer g_SharpenColorBuffer; - - /// Velocity buffer used in low-res motion vectors mode, converted from MiniEngine's packed velocity. - extern ColorBuffer g_ConvertedVelocityBuffer; // DXGI_FORMAT_R16G16_FLOAT - - /// Return if XeSS processing is enabled. - bool IsEnabled(); - /// Set if XeSS processing enabled. - void SetEnabled(bool Enabled); - - /// Initialization interface. - void Initialize(); - /// Destruction interface. - void Shutdown(); - /// Tick the processing. - void Update(); - /// Process the rendering content. XeSS execution happens inside this interface. - void Process(CommandContext& Context, const Math::Camera& camera); - - /// Set output resolution. - void SetOutputResolution(uint32_t Width, uint32_t Height); - /// Update XeSS runtime. - void UpdateRuntime(); - - /// Get input resolution. - void GetInputResolution(uint32_t& Width, uint32_t& Height); - /// Update input resolution. - void UpdateInputResolution(); - /// Get motion vectors mode. - eMotionVectorsMode GetMotionVectorsMode(); - /// Set motion vectors mode. - void SetMotionVectorsMode(eMotionVectorsMode Mode); - /// Get if responsive mask enabled. - bool IsResponsiveMaskEnabled(); - /// Set responsive mask enabled. - void SetResponsiveMaskEnabled(bool Enabled); - /// Get quality of XeSS. - eQualityLevel GetQuality(); - /// Set quality of XeSS. - void SetQuality(eQualityLevel Quality); - /// Get mip-bias mode. - eMipBiasMode GetMipBiasMode(); - /// Set mip-bias mode. - void SetMipBiasMode(eMipBiasMode Mode); - /// Get mip-bias value. - float GetMipBias(); - /// Set mip-bias Value. - void SetMipBias(float value); - /// Returns (frame-index % 2). - uint32_t GetFrameIndexMod2(); - /// Is XeSS supported. - bool IsSupported(); -} // namespace XeSS diff --git a/xess/samples/xess_demo/Source/XeSS/XeSSRuntime.cpp b/xess/samples/xess_demo/Source/XeSS/XeSSRuntime.cpp deleted file mode 100644 index 0a8256f..0000000 --- a/xess/samples/xess_demo/Source/XeSS/XeSSRuntime.cpp +++ /dev/null @@ -1,351 +0,0 @@ -/******************************************************************************* - * Copyright 2021 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files(the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions : - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ - -#include "pch.h" - -#include "XeSSRuntime.h" -#include "XeSSJitter.h" -#include "Utility.h" -#include "GraphicsCore.h" -#include "ColorBuffer.h" -#include "DepthBuffer.h" -#include "CommandContext.h" -#include "Log.h" - -#include "xess/xess_d3d12.h" - -using namespace Graphics; - -namespace XeSS -{ - /// Convert from xess_result_t to string. - const char* ResultToString(xess_result_t result) - { - switch (result) - { - case XESS_RESULT_WARNING_NONEXISTING_FOLDER: return "Warning Nonexistent Folder"; - case XESS_RESULT_SUCCESS: return "Success"; - case XESS_RESULT_ERROR_UNSUPPORTED_DEVICE: return "Unsupported Device"; - case XESS_RESULT_ERROR_UNSUPPORTED_DRIVER: return "Unsupported Driver"; - case XESS_RESULT_ERROR_UNINITIALIZED: return "Uninitialized"; - case XESS_RESULT_ERROR_INVALID_ARGUMENT: return "Invalid Argument"; - case XESS_RESULT_ERROR_DEVICE_OUT_OF_MEMORY: return "Device Out of Memory"; - case XESS_RESULT_ERROR_DEVICE: return "Device Error"; - case XESS_RESULT_ERROR_NOT_IMPLEMENTED: return "Not Implemented"; - case XESS_RESULT_ERROR_INVALID_CONTEXT: return "Invalid Context"; - case XESS_RESULT_ERROR_OPERATION_IN_PROGRESS: return "Operation in Progress"; - case XESS_RESULT_ERROR_UNKNOWN: - default: return "Unknown"; - } - } - - /// Convert application level Quality to - static _xess_quality_settings_t ToXeSSQuality(eQualityLevel Quality) - { - _xess_quality_settings_t qualityXeSS = static_cast<_xess_quality_settings_t>(XESS_QUALITY_SETTING_PERFORMANCE + Quality); - ASSERT(qualityXeSS >= XESS_QUALITY_SETTING_PERFORMANCE && qualityXeSS <= XESS_QUALITY_SETTING_ULTRA_QUALITY); - if (qualityXeSS < XESS_QUALITY_SETTING_PERFORMANCE) - qualityXeSS = XESS_QUALITY_SETTING_PERFORMANCE; - else if (qualityXeSS > XESS_QUALITY_SETTING_ULTRA_QUALITY) - qualityXeSS = XESS_QUALITY_SETTING_ULTRA_QUALITY; - - return qualityXeSS; - } - - void LogCallback(const char* Message, xess_logging_level_t Level) - { - Log::WriteFormat(static_cast(Level), "[XeSS Runtime]: %s", Message); - } - - XeSSRuntime::XeSSRuntime() - : m_Initialized(false) - , m_PipelineBuilt(false) - , m_PipelineBuiltFlag(0) - , m_Context(nullptr) - , m_PipelineLibBuilt(false) - { - } - - bool XeSSRuntime::CreateContext() - { - ASSERT(g_Device); - if (!g_Device) - return false; - - // Get version of XeSS - xess_version_t ver; - xess_result_t ret = xessGetVersion(&ver); - ASSERT(ret == XESS_RESULT_SUCCESS); - if (ret != XESS_RESULT_SUCCESS) - { - LOG_ERRORF("XeSS: Could not get version information. Result - %s.", ResultToString(ret)); - return false; - } - - char buf[128]; - sprintf_s(buf, "%u.%u.%u", ver.major, ver.minor, ver.patch); - - m_VersionStr = buf; - - LOG_INFOF("XeSS: Version - %s.", buf); - - // Create Context of XeSS - ret = xessD3D12CreateContext(g_Device, &m_Context); - ASSERT(ret == XESS_RESULT_SUCCESS && m_Context); - if (ret != XESS_RESULT_SUCCESS || !m_Context) - { - m_Context = nullptr; - - LOG_ERRORF("XeSS: XeSS is not supported on this device. Result - %s.", ResultToString(ret)); - return false; - } - - // Set logging callback here. - ret = xessSetLoggingCallback(m_Context, XESS_LOGGING_LEVEL_DEBUG, LogCallback); - ASSERT(ret == XESS_RESULT_SUCCESS); - if (ret != XESS_RESULT_SUCCESS) - { - LOG_ERRORF("XeSS: Could not set logging callback. Result - %s.", ResultToString(ret)); - return false; - } - - return true; - } - - bool XeSSRuntime::InitializePipeline(uint32_t initFlag, bool blocking) - { - // Create the Pipeline Library. - ComPtr device1; - if (FAILED(g_Device->QueryInterface(IID_PPV_ARGS(&device1)))) - { - LOG_ERROR("XeSS: Get ID3D12Device1 failed."); - return false; - } - - HRESULT hr = device1->CreatePipelineLibrary(nullptr, 0, IID_PPV_ARGS(&m_PipelineLibrary)); - if (FAILED(hr) || !m_PipelineLibrary) - { - LOG_ERROR("XeSS: Create D3D Pipeline library failed."); - return false; - } - -#ifndef RELEASE - m_PipelineLibrary->SetName(L"XeSS Pipeline Library Object"); -#endif - xess_result_t ret = xessD3D12BuildPipelines(m_Context, m_PipelineLibrary.Get(), blocking, initFlag); - if (ret != XESS_RESULT_SUCCESS) - { - LOG_ERRORF("XeSS: Could not build XeSS pipelines. Result - %s.", ResultToString(ret)); - return false; - } - - LOG_INFO("XeSS: Built XeSS pipelines."); - - m_PipelineBuilt = true; - m_PipelineBuiltBlocking = blocking; - m_PipelineBuiltFlag = initFlag; - - return true; - } - - void XeSSRuntime::Shutdown(void) - { - if (!m_Initialized) - return; - - // Destroy XeSS Context - xessDestroyContext(m_Context); - - m_Context = nullptr; - - m_PipelineLibrary = nullptr; - - m_PipelineLibBuilt = false; - - m_Initialized = false; - } - - bool XeSSRuntime::IsInitialzed() const - { - return m_Initialized; - } - - bool XeSSRuntime::Initialize(const InitArguments& Args) - { - m_Initialized = false; - - if (!m_Context) - return false; - - g_CommandManager.IdleGPU(); - - m_InitArguments = Args; - - xess_d3d12_init_params_t params {}; - params.outputResolution.x = Args.OutputWidth; - params.outputResolution.y = Args.OutputHeight; - params.qualitySetting = ToXeSSQuality(Args.Quality); - params.initFlags = Args.UseHiResMotionVectors ? XESS_INIT_FLAG_HIGH_RES_MV : 0; - if (Args.UseExposureTexture) - { - params.initFlags |= XESS_INIT_FLAG_EXPOSURE_SCALE_TEXTURE; - } - if (Args.UseResponsiveMask) - { - params.initFlags |= XESS_INIT_FLAG_RESPONSIVE_PIXEL_MASK; - } - - params.pPipelineLibrary = m_PipelineBuilt ? m_PipelineLibrary.Get() : nullptr; - - xess_result_t ret = xessD3D12Init(m_Context, ¶ms); - ASSERT(ret == XESS_RESULT_SUCCESS); - if (ret != XESS_RESULT_SUCCESS) - { - LOG_ERRORF("XeSS: Could not initialize. Result - %s.", ResultToString(ret)); - return false; - } - - LOG_INFO("XeSS: Initialized."); - - m_Initialized = true; - - return true; - } - - void XeSSRuntime::Execute(ExecuteArguments& ExeArgs) - { - if (!m_Initialized) - return; - - ASSERT(ExeArgs.ColorTexture && ExeArgs.VelocityTexture && ExeArgs.OutputTexture - && (m_InitArguments.UseHiResMotionVectors || ExeArgs.DepthTexture) - && (!m_InitArguments.UseExposureTexture || ExeArgs.ExposureTexture) - && (!m_InitArguments.UseResponsiveMask || ExeArgs.ResponsiveMask)); - - if (!ExeArgs.ColorTexture || !ExeArgs.VelocityTexture || !ExeArgs.OutputTexture - || (!m_InitArguments.UseHiResMotionVectors && !ExeArgs.DepthTexture) - || (m_InitArguments.UseExposureTexture && !ExeArgs.ExposureTexture) - || (m_InitArguments.UseResponsiveMask && !ExeArgs.ResponsiveMask)) - return; - - float jitterX, jitterY; - XeSSJitter::GetJitterValues(jitterX, jitterY); - - xess_d3d12_execute_params_t params {}; - params.jitterOffsetX = jitterX; - params.jitterOffsetY = jitterY; - params.inputWidth = ExeArgs.InputWidth; - params.inputHeight = ExeArgs.InputHeight; - params.resetHistory = ExeArgs.ResetHistory ? 1 : 0; - params.exposureScale = 1.0f; - - params.pColorTexture = ExeArgs.ColorTexture->GetResource(); - params.pVelocityTexture = ExeArgs.VelocityTexture->GetResource(); - params.pOutputTexture = ExeArgs.OutputTexture->GetResource(); - params.pDepthTexture = m_InitArguments.UseHiResMotionVectors ? nullptr : ExeArgs.DepthTexture->GetResource(); - params.pExposureScaleTexture = !m_InitArguments.UseExposureTexture ? nullptr : ExeArgs.ExposureTexture->GetResource(); - params.pResponsivePixelMaskTexture = !m_InitArguments.UseResponsiveMask ? nullptr : ExeArgs.ResponsiveMask->GetResource(); - -#if _XESS_DEBUG_JITTER_ - LOG_DEBUGF("XeSS Jitter: Input = %f, %f.", params.jitterOffsetX, params.jitterOffsetY); -#endif - - xess_result_t ret = xessD3D12Execute(m_Context, ExeArgs.CommandList, ¶ms); - - // Trigger error report once. - if (ret != XESS_RESULT_SUCCESS) - { - static bool s_Reported = false; - if (!s_Reported) - { - s_Reported = true; - ASSERT(ret != XESS_RESULT_SUCCESS); - LOG_ERRORF("XeSS: Failed to execute. Result - %s.", ResultToString(ret)); - } - } - } - - bool XeSSRuntime::GetInputResolution(uint32_t& Width, uint32_t& Height) - { - ASSERT(m_Context); - if (!m_Context) - return false; - - xess_2d_t inputRes = { 1, 1 }; - xess_2d_t outputRes = { m_InitArguments.OutputWidth, m_InitArguments.OutputHeight }; - - xess_result_t ret = xessGetInputResolution(m_Context, &outputRes, ToXeSSQuality(m_InitArguments.Quality), &inputRes); - ASSERT(ret == XESS_RESULT_SUCCESS); - if (ret != XESS_RESULT_SUCCESS) - { - LOG_ERRORF("XeSS: Could not get input resolution. Result - %s.", ResultToString(ret)); - return false; - } - - Width = inputRes.x; - Height = inputRes.y; - - return true; - } - - bool XeSSRuntime::SetJitterScale(float X, float Y) - { - xess_result_t ret = xessSetJitterScale(m_Context, X, Y); - ASSERT(ret == XESS_RESULT_SUCCESS); - if (ret != XESS_RESULT_SUCCESS) - { - LOG_ERRORF("XeSS: Could not set jitter scale. Result - %s.", ResultToString(ret)); - return false; - } - - return true; - } - - bool XeSSRuntime::SetVelocityScale(float X, float Y) - { - xess_result_t ret = xessSetVelocityScale(m_Context, X, Y); - ASSERT(ret == XESS_RESULT_SUCCESS); - if (ret != XESS_RESULT_SUCCESS) - { - LOG_ERRORF("XeSS: Could not set velocity scale. Result - %s.", ResultToString(ret)); - return false; - } - - return true; - } - - xess_context_handle_t XeSSRuntime::GetContext() - { - return m_Context; - } - - const std::string& XeSSRuntime::GetVersionString() - { - return m_VersionStr; - } - - void XeSSRuntime::SetInitArguments(const InitArguments& Args) - { - m_InitArguments = Args; - } - -} // namespace XeSS diff --git a/xess/samples/xess_demo/Source/XeSS/XeSSRuntime.h b/xess/samples/xess_demo/Source/XeSS/XeSSRuntime.h deleted file mode 100644 index 684d9dd..0000000 --- a/xess/samples/xess_demo/Source/XeSS/XeSSRuntime.h +++ /dev/null @@ -1,172 +0,0 @@ -/******************************************************************************* - * Copyright 2021 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files(the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions : - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - ******************************************************************************/ - -#pragma once - -#include "xess/xess.h" - -class ColorBuffer; -class DepthBuffer; -class ComputeContext; - -namespace XeSS -{ - /// Convert from xess_result_t to string. - extern const char* ResultToString(xess_result_t result); - - /// Quality level of XeSS. - enum eQualityLevel - { - kQualityPerformance = 0, - kQualityBalanced, - kQualityQuality, - kQualityUltraQuality - }; - - /// Arguments for initialization of XeSS. - struct InitArguments - { - /// Output buffer width. - uint32_t OutputWidth; - /// Output buffer height. - uint32_t OutputHeight; - /// Quality level of XeSS. - eQualityLevel Quality; - /// If we are in High-Res motion vectors mode. - bool UseHiResMotionVectors; - /// If use exposure texture. - bool UseExposureTexture; - /// If use responsive mask. - bool UseResponsiveMask; - - /// Constructor. - InitArguments() - : OutputWidth(0) - , OutputHeight(0) - , Quality(kQualityQuality) - , UseHiResMotionVectors(false) - , UseExposureTexture(false) - , UseResponsiveMask(false) - { - } - }; - - /// Arguments for execution of XeSS. - struct ExecuteArguments - { - /// CommandList which is used to record XeSS commands. - ID3D12GraphicsCommandList* CommandList; - /// Width of input buffer. - uint32_t InputWidth; - /// Height of input buffer. - uint32_t InputHeight; - /// If we should reset history when executing XeSS. - bool ResetHistory; - - /// Input color buffer. - ColorBuffer* ColorTexture; - /// Input motion vectors buffer. - ColorBuffer* VelocityTexture; - /// Output color buffer. - ColorBuffer* OutputTexture; - /// Input depth texture. (Used in low-res motion vectors mode.) - ColorBuffer* DepthTexture; - /// Input Exposure texture - ColorBuffer* ExposureTexture; - /// Input Responsive mask - ColorBuffer* ResponsiveMask; - - /// Constructor. - ExecuteArguments() - : CommandList(nullptr) - , InputWidth(0) - , InputHeight(0) - , ResetHistory(false) - , ColorTexture(nullptr) - , VelocityTexture(nullptr) - , OutputTexture(nullptr) - , DepthTexture(nullptr) - , ExposureTexture(nullptr) - , ResponsiveMask(nullptr) - { - } - }; - - /// A wrapper of XeSS SDK. - class XeSSRuntime - { - public: - /// Constructor. - XeSSRuntime(); - - /// Create XeSS context. - bool CreateContext(); - /// Build pipeline of XeSS. - bool InitializePipeline(uint32_t initFlag, bool blocking = false); - // Destruction interface. - void Shutdown(void); - /// Return if runtime is initialized. - bool IsInitialzed() const; - /// Create the effect of XeSS. - bool Initialize(const InitArguments& Args); - /// Execute XeSS. - void Execute(ExecuteArguments& ExeArgs); - /// Get recommenced input resolution. - bool GetInputResolution(uint32_t& Width, uint32_t& Height); - /// Set jitter scale values. - bool SetJitterScale(float X, float Y); - /// Set velocity scale values. - bool SetVelocityScale(float X, float Y); - /// Get XeSS Context. - xess_context_handle_t GetContext(); - /// Get version string. - const std::string& GetVersionString(); - private: - /// Save initialization arguments. - void SetInitArguments(const InitArguments& Args); - - /// If pipeline is already built. - bool m_PipelineBuilt; - /// If blocking build? - bool m_PipelineBuiltBlocking; - /// Current pipeline built flag - uint32_t m_PipelineBuiltFlag; - - /// If runtime is initialized. - bool m_Initialized; - - /// Initialization arguments. - InitArguments m_InitArguments; - - /// Context of XeSS. - xess_context_handle_t m_Context; - - /// Version string. - std::string m_VersionStr; - - /// If pipeline built. - bool m_PipelineLibBuilt; - - /// DX12 pipeline library object. - Microsoft::WRL::ComPtr m_PipelineLibrary; - }; -} // namespace XeSS diff --git a/xess/samples/xess_demo/Source/XeSSDemo.manifest b/xess/samples/xess_demo/Source/XeSSDemo.manifest deleted file mode 100644 index 6a8eff8..0000000 --- a/xess/samples/xess_demo/Source/XeSSDemo.manifest +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/xess/samples/xess_demo/Source/pch.cpp b/xess/samples/xess_demo/Source/pch.cpp deleted file mode 100644 index 97b544e..0000000 --- a/xess/samples/xess_demo/Source/pch.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// -// pch.cpp -// Include the standard header and generate the precompiled header. -// - -#include "pch.h" diff --git a/xess/samples/xess_demo/Source/pch.h b/xess/samples/xess_demo/Source/pch.h deleted file mode 100644 index d77dbfe..0000000 --- a/xess/samples/xess_demo/Source/pch.h +++ /dev/null @@ -1,61 +0,0 @@ -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -// Developed by Minigraph -// - -#pragma once - -#pragma warning(disable:4201) // nonstandard extension used : nameless struct/union -#pragma warning(disable:4328) // nonstandard extension used : class rvalue used as lvalue -#pragma warning(disable:4324) // structure was padded due to __declspec(align()) - -#include // for WINAPI_FAMILY -#include - -#ifndef WIN32_LEAN_AND_MEAN - #define WIN32_LEAN_AND_MEAN -#endif -#ifndef NOMINMAX - #define NOMINMAX -#endif -#include - -#include - -#pragma comment(lib, "d3d12.lib") -#pragma comment(lib, "dxgi.lib") - -#define D3D12_GPU_VIRTUAL_ADDRESS_NULL ((D3D12_GPU_VIRTUAL_ADDRESS)0) -#define D3D12_GPU_VIRTUAL_ADDRESS_UNKNOWN ((D3D12_GPU_VIRTUAL_ADDRESS)-1) -#define MY_IID_PPV_ARGS IID_PPV_ARGS - -#if _MSC_VER >= 1800 - #include - #include -#endif - -#include "d3dx12.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "Utility.h" -#include "VectorMath.h" -#include "EngineTuning.h" -#include "EngineProfiling.h"